diff --git a/articles/demo.md b/articles/demo.md index 3e394ef..0ee4409 100644 --- a/articles/demo.md +++ b/articles/demo.md @@ -12,12 +12,24 @@ function func(a, b) { } ``` +[mermaid API](https://mermaid.js.org/config/setup/modules/mermaidAPI.html) + +
+    graph TD
+    A[Client] --> B[Load Balancer]
+    B --> C[Server01]
+    B --> D[Server02]
+
+
+flowchart LR
+  A --> B
+
+ [What's In A Class?] [1]
alert - ## [alert](https://github.com/bent10/marked-extensions/tree/main/packages/alert) - [Enables GFM alerts](https://github.com/orgs/community/discussions/16925) diff --git a/dev-note/cmd.md b/dev-note/cmd.md index 833d1b0..04cc0ae 100644 --- a/dev-note/cmd.md +++ b/dev-note/cmd.md @@ -10,12 +10,8 @@ - set 变量名= // 置空 - set 变量名=%变量名%;变量内容 // 如set path=%path%;d:\nmake.exe -## powershell -拷贝目录到另一个目录 -xcopy /s /e /h /i /y .\third\snippet\ .\third2\snippet\ - -- [chcp](https://learn.microsoft.com/zh-cn/windows-server/administration/windows-commands/chcp) - - +- [chcp](https://learn.microsoft.com/zh-cn/windows-server/administration/windows-commands/chcp) 更新语言代码 - netstat -ano | findstr 3000 查看端口是否被占 -- taskkill /f /t /im 9340 \ No newline at end of file +- tasklist +- taskkill /f /t /im 9340 +- taskkill /IM "xxx.exe" /F \ No newline at end of file diff --git a/dev-note/git.md b/dev-note/git.md index ccf19b6..74d8971 100644 --- a/dev-note/git.md +++ b/dev-note/git.md @@ -82,6 +82,7 @@ git config --global user.name "lmj01" git config --global user.email "lmjie_good@163.com" git config --global color.ui auto 增强命令输出的可读性 git config --global init.defaultBranch main // 更改默认分支git2.28支持 +git config --local user.name ``` ### git ssh @@ -143,6 +144,8 @@ pox.xml merge=ours git checkout branch-with-history 切换到带有历史记录的分支中 git checkout -b XXX 新建本地分支XXX git reset --hard commit-id 回滚分支XXX上的某个提交点 +git reset --soft HEAD^ 撤销上一个提交,回到staging状态 +git reset --soft HEAD~2 撤销多个提交 ``` 此时代码就是某个提交点的,就可以修改了 diff --git a/dev-note/powershell.md b/dev-note/powershell.md index 289e18b..69b7c6f 100644 --- a/dev-note/powershell.md +++ b/dev-note/powershell.md @@ -18,7 +18,16 @@ # /exclude:FileName1[+[FileName2]][+[FileName3]( )] 排除指定文件,文件中列出了文件名,或字符串与复制文件的绝对路径存在匹配时,排除 # /q 不显示 xcopy src dst /W /u /s /y + + +# 进程 +Get-Process -Name sb* # 获取进程名 +Get-Process -Name sb* | Stop-Process +Stop-Process -Name t*,e* -Confirm ``` +## powershell +拷贝目录到另一个目录 +xcopy /s /e /h /i /y .\third\snippet\ .\third2\snippet\ ## ssh diff --git a/exercises/index.md b/exercises/index.md index fef1fa0..392ecfa 100644 --- a/exercises/index.md +++ b/exercises/index.md @@ -12,6 +12,7 @@ - [二次方程](/exercises/quadratic.equation.md) - [夹逼法](/exercises/sequeezing.md) - [几何](/exercises/geometry.md) +- [线性代数](/exercises/linear.algebra.md) ## 物理学 diff --git a/exercises/linear.algebra.md b/exercises/linear.algebra.md new file mode 100644 index 0000000..821ad3d --- /dev/null +++ b/exercises/linear.algebra.md @@ -0,0 +1,72 @@ +# Linear Algebra + +线性代数 + +- [基](https://www.douban.com/note/774496194/) + +## 域 + +## 矩阵 + +
+特征值与特征向量 + +### 特征值与特征向量 + +矩阵与向量相乘会产生另外一个向量,对于某些特定矩阵,存在一些向量,相乘后得到的向量方向不改变,此类向量称为给定矩阵的特征向量,而变换后的向量的缩放值被定义为与该特征向量对应的特征值。 + +$A\vec{v}=\lambda \vec{v}, \lambda \text{是特征向量}\vec{v}\text{对应的特征值}$ + +特征向量只能仅适应于方阵。特征向量所构成的空间(包含0向量)称为特征空间。 + +如果方阵可以写成下来式子,称为可对角化矩阵 + +$$ +A=PDP^{-1} \newline +D=\begin{pmatrix} + \lambda{1} & 0 & \cdots & 0 \newline + 0 & \lambda{2} & \cdots & 0 \newline + \vdots & \vdots & \ddots & \vdots \newline + 0 & 0 & \cdots & \lambda{n} \newline +\end{pmatrix} \newline +D\text{是以特征值作为对角元素的对角矩阵}, P\text{是特征向量堆叠在一起的矩阵} +$$ + +$\text{矩阵等于其自身的转置称为对称矩阵}, A=A^{T}$ + +$\text{矩阵的逆等于其自身的转置称为正交矩阵}, A^{-1}=A^{T} or A^{T}A=I$ + +有很多关于特征值和特征向量的性质,比如:仅具有实数特征值,始终可对角化,具有正交特征向量。由于对称矩阵的的特征向量相互正交,对角化矩阵A中的矩阵P为正交矩阵,常常说任何对称矩阵都是正交对角化的。 + +$A=PDP^{-1}=PDP^{T}$ + +非对称方阵时,可能有复数的特征值。这就是其局限性,就需要奇异值分解了。 + +
+ +### 矩阵分解技术 + +
+特征值与特征向量 + +#### [奇异值分解SVD]() + +[奇异值分解的简单想法](https://mp.weixin.qq.com/s/FwtDCVTiINpzP8tih0tu4w) + +在大数据时代,数据集可以使用二维矩阵表示,有时使用矩阵中所有元素进行计算成本很高,就需要恰当的形式的矩阵方便计算。SVD将任何矩阵分解为三个通用矩阵。 + +$$ +\text{设}A\text{是任意矩形(m,n)的矩阵,可以证明}A^{T}A和AA^{T}\text{分别是对称方阵(n,n)和(m,m)}. \newline +(A^{T}A)^{T}=A^{T}(A^{T})^{T}=A^{T}A \newline +(AA^{T})^=(A^{T})^{T}A^{T}=AA^{T} \newline +$$ + +还可以证明它们共享相同的特征值,但特征向量可能不同。根据对称矩阵正交对角化性质,矩阵可分解为 + +$$ +A^{T}A=VDV^{T} \newline +AA^{T}=UDU^{T} \newline +D\text{为特征值的对角矩阵,}V,U\text{为正交矩阵} +$$ + +
diff --git a/exercises/math.md b/exercises/math.md index f9669d4..15fea76 100644 --- a/exercises/math.md +++ b/exercises/math.md @@ -1,7 +1,9 @@ # Math -## 基础概念 -> 数学的精准是建立在一系列基本概念和逻辑推理之上。定义、公理、猜想、定理、证明和推论相互关联,形成了一个严密的逻辑体系。 +
+基础概念 + +数学的精准是建立在一系列基本概念和逻辑推理之上。定义、公理、猜想、定理、证明和推论相互关联,形成了一个严密的逻辑体系。 - 定义Definition,是对某个概念或术语清晰而精简的描述,它是利用已知的概念来解释新的数学对象 1. 数学概念是体现数学对象本质属性的思维模式,而定义是对我们所讨论的数学对象的本质属性进行描述的语句 @@ -34,7 +36,10 @@ 2. 鸽巢原理Pigeonhole principle(抽屉原理),是一个基本的组合数学原理,表明n+1个鸽子放置n个巢中,至少有一个巢有两个鸽子。 - 证明,是验证的过程 -### [西方数学发展史](https://mp.weixin.qq.com/s/38OPkhjaLuVXkXORGYOnfw) +
+西方数学发展史 + +[西方数学发展史](https://mp.weixin.qq.com/s/38OPkhjaLuVXkXORGYOnfw) 数学是一门研究数量、运算、结构、空间、图形、信息等概念的形式科学,它是人类对事物的抽象结构与模式进行严格描述、推导的一种通用手段,在人类历史的发展和社会生活中,数学发挥着不可替代的作用,是学习和研究现代科学技术必不可少的基本工具,对理解掌握各类科学技术的公式定理具有重要的意义。 @@ -50,17 +55,12 @@ 伽罗瓦是群论理论的重要创立者,他用其理论解决了代数方程的根式求解问题,并由此发展出了一整套关于群和域的理论(即伽罗瓦理论),对三次以上(至五次)方程的公式求解有着重要的帮助 -## Linear Algebra - -线性代数 - -- [基](https://www.douban.com/note/774496194/) - -## 域 +
## 观点 -### 读大师作品 +
+读大师作品 有几点理由可以说明为何最优秀的数学家被吸引去读经典著作,首先,他们似乎是天生的善于进行综合的人,数学的真谛在于理解看起来不同的概念间的逻辑联系。最成功的数学家都是涉足面最广、洞察相似之物和将概念联系起来的能力最强的数学家。历史在这样的研究活动中的作用是明显的。对某些相似性的认识往往要经历几代人,而且通过对普遍的历史事实的回顾,往往容易看出各种联系。**进步不是出自于新的概念,而是由于认识到可以把旧概念用于新的情况,这样的事实比我们所愿想象的要多得多。** @@ -73,4 +73,6 @@ Newton和Leibniz在分析方面的工作就是Newton以一个几何四维来思 几何是关于空间的,当你一眼观望完一个房间时,你的大脑所看到的太多东西了,空间直觉spatial intuition或空间知觉spatial perception,这些都是以几何形式出现的。这些都是在一个时间点上看到的结果,几何本质是静止的。而代数本质上是涉及的是时间,一步推导一步推导的结果,都是在上一个时间点上,是在前一个步骤上的结果,特别是计算机出现后的,算法,就是代数的形式化过程中的产物,任何算法,任何计算过程,都是一个接着一个的,并不是那个静止下的结果。 -几何本质是静止的,而代数,现代的算法,任何算法,任何计算过程都是有时间维度的。 \ No newline at end of file +几何本质是静止的,而代数,现代的算法,任何算法,任何计算过程都是有时间维度的。 + +
\ No newline at end of file diff --git a/exercises/math.secondary.md b/exercises/math.secondary.md index 6e9a7cc..ab4e70c 100644 --- a/exercises/math.secondary.md +++ b/exercises/math.secondary.md @@ -4,6 +4,14 @@ ## 几何 + +
+2024-5-33初三模拟习题 + +[几何之旅:塞瓦定理与角元塞瓦定理——角格点问题的通解方法](https://zhuanlan.zhihu.com/p/122455316?utm_campaign=shareopn&utm_medium=social&utm_psn=1781370747668807680&utm_source=wechat_session) + +
+
2024-5-33初三模拟习题 diff --git a/index.html b/index.html index 20ca0a7..3fec637 100644 --- a/index.html +++ b/index.html @@ -12,8 +12,8 @@ - - + + lmj01 Doc diff --git a/index.mjs b/index.mjs index 6034965..d27635f 100644 --- a/index.mjs +++ b/index.mjs @@ -1,8 +1,8 @@ -import { md2Html } from './libs/marked/mj-marked.mjs'; -import hljs from './highlight/core.min.mjs'; -import languageJavascript from './highlight/languages/javascript.min.mjs'; -import languageLua from './highlight/languages/lua.min.mjs'; -import languageCpp from './highlight/languages/cpp.min.mjs'; +import { md2Html, parseMermaidHtml } from './libs/marked/index.js'; +import hljs from './libs/highlight/core.min.mjs'; +import languageJavascript from './libs/highlight/languages/javascript.min.mjs'; +import languageLua from './libs/highlight/languages/lua.min.mjs'; +import languageCpp from './libs/highlight/languages/cpp.min.mjs'; hljs.registerLanguage('javascript', languageJavascript); hljs.registerLanguage('lua', languageLua); @@ -26,7 +26,7 @@ elBtnBack.addEventListener('click', ()=>{ tagLinkClickCaption(null, elTag) } }) -function updateContent(text, options = {}) { +async function updateContent(text, options = {}) { const elContent = document.getElementById('content'); elContent.classList.add('position-relative'); if (options.isLink) { @@ -48,11 +48,7 @@ function updateContent(text, options = {}) { elContent.classList.remove('iframe'); const ext = options.ext || 'md'; if (ext == 'md') { - const elDiv = document.createElement('div'); - elDiv.classList.add('w-100','h-100','d-flex','flex-column'); - elDiv.innerHTML = md2Html(text); - elContent.replaceChildren(); - elContent.appendChild(elDiv); + await toHtmlData(elContent, text); } else { const fixed = {js:'javascript', lua:'lua', cpp:'cpp'}; const res = hljs.highlight(text, {language:fixed[ext]}); @@ -68,6 +64,15 @@ function updateContent(text, options = {}) { elContent.appendChild(elBtnBack); } +async function toHtmlData(elContent, text) { + const elDiv = document.createElement('div'); + elDiv.classList.add('w-100','h-100','d-flex','flex-column'); + elDiv.innerHTML = md2Html(text); + elContent.replaceChildren(); + elContent.appendChild(elDiv); + await parseMermaidHtml(elDiv); +} + const patternExternal = /^(https?:|mailto:|tel:)/ function tagLinkClickCaption(event, aLink) { if (event) { @@ -111,5 +116,5 @@ function catchAllTagLink() { ud.cacheUrls = []; catchAllTagLink(); fetch('/articles/demo.md').then(res=>res.text()).then(text=>{ - document.getElementById('content').innerHTML = md2Html(text); + toHtmlData(document.getElementById('content'), text); }) \ No newline at end of file diff --git a/index/online.md b/index/online.md index 299bcd2..6aa3061 100644 --- a/index/online.md +++ b/index/online.md @@ -42,7 +42,15 @@ - [Javascript Playground--邮箱meijie.lmj@outlook.com](https://playcode.io/) -### 在线工具 +### 流程图 + +- [图示流程Developer Roadmaps Browse the ever-growing list of up-to-date, community driven roadmaps](https://roadmap.sh/roadmaps) +- [Mermaid Diagramming and charting tool](https://mermaid.js.org/) + - [github](https://github.com/mermaid-js/mermaid) + +- [在线办公软件Univer is an open-source alternative to Google Sheets, Slides, and Docs ](https://github.com/lmj01/univer) + +### 其他 - [在线计算器及工具](https://www.rapidtables.org/zh-CN/) - [图形计算器GeoGebra--在线绘制图形](https://www.geogebra.org/graphing?lang=zh_CN) - [在线编译文件](https://wandbox.org/) @@ -53,8 +61,7 @@ - [This is a online vector graphics editor.](https://skeditor.github.io/) - [github](https://github.com/skeditor/skeditor) -### 其他 - +- [文件管理器](http://q-dir.com/) - [MedPeer应用先进的新闻资讯抓取和分析技术,对用户关心的内容进行深度分类和整理,力求提供及时的生物医药行业资讯,依托MedPeer人工智能翻译系统对国外资讯、文献、报告和视频进行翻译,帮助国内用户轻松理解。编辑器免费,组件收费](https://medpeer.cn/) - [Design Editor JS SDK Polotno for canvas | Polotno](https://polotno.com/) - [github](https://github.com/polotno-project) diff --git a/highlight/core.min.mjs b/libs/highlight/core.min.mjs similarity index 100% rename from highlight/core.min.mjs rename to libs/highlight/core.min.mjs diff --git a/highlight/languages/cpp.min.mjs b/libs/highlight/languages/cpp.min.mjs similarity index 100% rename from highlight/languages/cpp.min.mjs rename to libs/highlight/languages/cpp.min.mjs diff --git a/highlight/languages/javascript.min.mjs b/libs/highlight/languages/javascript.min.mjs similarity index 100% rename from highlight/languages/javascript.min.mjs rename to libs/highlight/languages/javascript.min.mjs diff --git a/highlight/languages/lua.min.mjs b/libs/highlight/languages/lua.min.mjs similarity index 100% rename from highlight/languages/lua.min.mjs rename to libs/highlight/languages/lua.min.mjs diff --git a/highlight/styles/default.min.css b/libs/highlight/styles/default.min.css similarity index 100% rename from highlight/styles/default.min.css rename to libs/highlight/styles/default.min.css diff --git a/highlight/styles/xcode.min.css b/libs/highlight/styles/xcode.min.css similarity index 100% rename from highlight/styles/xcode.min.css rename to libs/highlight/styles/xcode.min.css diff --git a/libs/marked/Tableau10-CkeCzOvH.js b/libs/marked/Tableau10-CkeCzOvH.js new file mode 100644 index 0000000..fcfa991 --- /dev/null +++ b/libs/marked/Tableau10-CkeCzOvH.js @@ -0,0 +1,9 @@ +function colors(specifier) { + var n = specifier.length / 6 | 0, colors = new Array(n), i = 0; + while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6); + return colors; +} + +var schemeTableau10 = colors("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"); + +export { schemeTableau10 as s }; diff --git a/libs/marked/arc-CNdYl1O_.js b/libs/marked/arc-CNdYl1O_.js new file mode 100644 index 0000000..ab79dce --- /dev/null +++ b/libs/marked/arc-CNdYl1O_.js @@ -0,0 +1,269 @@ +import { w as withPath, c as constant } from './path-BZ3S9nBE.js'; +import { av as pi, aw as cos, ax as sin, ay as halfPi, az as epsilon, V as tau, aA as sqrt, aB as min, aC as abs, aD as atan2, aE as asin, aF as acos, aG as max } from './index-CN3YjQ0n.js'; + +function arcInnerRadius(d) { + return d.innerRadius; +} + +function arcOuterRadius(d) { + return d.outerRadius; +} + +function arcStartAngle(d) { + return d.startAngle; +} + +function arcEndAngle(d) { + return d.endAngle; +} + +function arcPadAngle(d) { + return d && d.padAngle; // Note: optional! +} + +function intersect(x0, y0, x1, y1, x2, y2, x3, y3) { + var x10 = x1 - x0, y10 = y1 - y0, + x32 = x3 - x2, y32 = y3 - y2, + t = y32 * x10 - x32 * y10; + if (t * t < epsilon) return; + t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t; + return [x0 + t * x10, y0 + t * y10]; +} + +// Compute perpendicular offset line of length rc. +// http://mathworld.wolfram.com/Circle-LineIntersection.html +function cornerTangents(x0, y0, x1, y1, r1, rc, cw) { + var x01 = x0 - x1, + y01 = y0 - y1, + lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), + ox = lo * y01, + oy = -lo * x01, + x11 = x0 + ox, + y11 = y0 + oy, + x10 = x1 + ox, + y10 = y1 + oy, + x00 = (x11 + x10) / 2, + y00 = (y11 + y10) / 2, + dx = x10 - x11, + dy = y10 - y11, + d2 = dx * dx + dy * dy, + r = r1 - rc, + D = x11 * y10 - x10 * y11, + d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), + cx0 = (D * dy - dx * d) / d2, + cy0 = (-D * dx - dy * d) / d2, + cx1 = (D * dy + dx * d) / d2, + cy1 = (-D * dx + dy * d) / d2, + dx0 = cx0 - x00, + dy0 = cy0 - y00, + dx1 = cx1 - x00, + dy1 = cy1 - y00; + + // Pick the closer of the two intersection points. + // TODO Is there a faster way to determine which intersection to use? + if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; + + return { + cx: cx0, + cy: cy0, + x01: -ox, + y01: -oy, + x11: cx0 * (r1 / r - 1), + y11: cy0 * (r1 / r - 1) + }; +} + +function arc() { + var innerRadius = arcInnerRadius, + outerRadius = arcOuterRadius, + cornerRadius = constant(0), + padRadius = null, + startAngle = arcStartAngle, + endAngle = arcEndAngle, + padAngle = arcPadAngle, + context = null, + path = withPath(arc); + + function arc() { + var buffer, + r, + r0 = +innerRadius.apply(this, arguments), + r1 = +outerRadius.apply(this, arguments), + a0 = startAngle.apply(this, arguments) - halfPi, + a1 = endAngle.apply(this, arguments) - halfPi, + da = abs(a1 - a0), + cw = a1 > a0; + + if (!context) context = buffer = path(); + + // Ensure that the outer radius is always larger than the inner radius. + if (r1 < r0) r = r1, r1 = r0, r0 = r; + + // Is it a point? + if (!(r1 > epsilon)) context.moveTo(0, 0); + + // Or is it a circle or annulus? + else if (da > tau - epsilon) { + context.moveTo(r1 * cos(a0), r1 * sin(a0)); + context.arc(0, 0, r1, a0, a1, !cw); + if (r0 > epsilon) { + context.moveTo(r0 * cos(a1), r0 * sin(a1)); + context.arc(0, 0, r0, a1, a0, cw); + } + } + + // Or is it a circular or annular sector? + else { + var a01 = a0, + a11 = a1, + a00 = a0, + a10 = a1, + da0 = da, + da1 = da, + ap = padAngle.apply(this, arguments) / 2, + rp = (ap > epsilon) && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), + rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), + rc0 = rc, + rc1 = rc, + t0, + t1; + + // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0. + if (rp > epsilon) { + var p0 = asin(rp / r0 * sin(ap)), + p1 = asin(rp / r1 * sin(ap)); + if ((da0 -= p0 * 2) > epsilon) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0; + else da0 = 0, a00 = a10 = (a0 + a1) / 2; + if ((da1 -= p1 * 2) > epsilon) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1; + else da1 = 0, a01 = a11 = (a0 + a1) / 2; + } + + var x01 = r1 * cos(a01), + y01 = r1 * sin(a01), + x10 = r0 * cos(a10), + y10 = r0 * sin(a10); + + // Apply rounded corners? + if (rc > epsilon) { + var x11 = r1 * cos(a11), + y11 = r1 * sin(a11), + x00 = r0 * cos(a00), + y00 = r0 * sin(a00), + oc; + + // Restrict the corner radius according to the sector angle. If this + // intersection fails, it’s probably because the arc is too small, so + // disable the corner radius entirely. + if (da < pi) { + if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) { + var ax = x01 - oc[0], + ay = y01 - oc[1], + bx = x11 - oc[0], + by = y11 - oc[1], + kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), + lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]); + rc0 = min(rc, (r0 - lc) / (kc - 1)); + rc1 = min(rc, (r1 - lc) / (kc + 1)); + } else { + rc0 = rc1 = 0; + } + } + } + + // Is the sector collapsed to a line? + if (!(da1 > epsilon)) context.moveTo(x01, y01); + + // Does the sector’s outer ring have rounded corners? + else if (rc1 > epsilon) { + t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw); + t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw); + + context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw); + context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the outer ring just a circular arc? + else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw); + + // Is there no inner ring, and it’s a circular sector? + // Or perhaps it’s an annular sector collapsed due to padding? + if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10); + + // Does the sector’s inner ring (or point) have rounded corners? + else if (rc0 > epsilon) { + t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw); + t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw); + + context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw); + context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the inner ring just a circular arc? + else context.arc(0, 0, r0, a10, a00, cw); + } + + context.closePath(); + + if (buffer) return context = null, buffer + "" || null; + } + + arc.centroid = function() { + var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, + a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2; + return [cos(a) * r, sin(a) * r]; + }; + + arc.innerRadius = function(_) { + return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc) : innerRadius; + }; + + arc.outerRadius = function(_) { + return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius; + }; + + arc.cornerRadius = function(_) { + return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius; + }; + + arc.padRadius = function(_) { + return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius; + }; + + arc.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle; + }; + + arc.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle; + }; + + arc.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle; + }; + + arc.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), arc) : context; + }; + + return arc; +} + +export { arc as a }; diff --git a/libs/marked/arc-DhQC9rXN.js b/libs/marked/arc-DhQC9rXN.js new file mode 100644 index 0000000..3b5956e --- /dev/null +++ b/libs/marked/arc-DhQC9rXN.js @@ -0,0 +1,269 @@ +import { w as withPath, c as constant } from './path-BZ3S9nBE.js'; +import { av as pi, aw as cos, ax as sin, ay as halfPi, az as epsilon, V as tau, aA as sqrt, aB as min, aC as abs, aD as atan2, aE as asin, aF as acos, aG as max } from './index-Bd_FDXSq.js'; + +function arcInnerRadius(d) { + return d.innerRadius; +} + +function arcOuterRadius(d) { + return d.outerRadius; +} + +function arcStartAngle(d) { + return d.startAngle; +} + +function arcEndAngle(d) { + return d.endAngle; +} + +function arcPadAngle(d) { + return d && d.padAngle; // Note: optional! +} + +function intersect(x0, y0, x1, y1, x2, y2, x3, y3) { + var x10 = x1 - x0, y10 = y1 - y0, + x32 = x3 - x2, y32 = y3 - y2, + t = y32 * x10 - x32 * y10; + if (t * t < epsilon) return; + t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t; + return [x0 + t * x10, y0 + t * y10]; +} + +// Compute perpendicular offset line of length rc. +// http://mathworld.wolfram.com/Circle-LineIntersection.html +function cornerTangents(x0, y0, x1, y1, r1, rc, cw) { + var x01 = x0 - x1, + y01 = y0 - y1, + lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), + ox = lo * y01, + oy = -lo * x01, + x11 = x0 + ox, + y11 = y0 + oy, + x10 = x1 + ox, + y10 = y1 + oy, + x00 = (x11 + x10) / 2, + y00 = (y11 + y10) / 2, + dx = x10 - x11, + dy = y10 - y11, + d2 = dx * dx + dy * dy, + r = r1 - rc, + D = x11 * y10 - x10 * y11, + d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), + cx0 = (D * dy - dx * d) / d2, + cy0 = (-D * dx - dy * d) / d2, + cx1 = (D * dy + dx * d) / d2, + cy1 = (-D * dx + dy * d) / d2, + dx0 = cx0 - x00, + dy0 = cy0 - y00, + dx1 = cx1 - x00, + dy1 = cy1 - y00; + + // Pick the closer of the two intersection points. + // TODO Is there a faster way to determine which intersection to use? + if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; + + return { + cx: cx0, + cy: cy0, + x01: -ox, + y01: -oy, + x11: cx0 * (r1 / r - 1), + y11: cy0 * (r1 / r - 1) + }; +} + +function arc() { + var innerRadius = arcInnerRadius, + outerRadius = arcOuterRadius, + cornerRadius = constant(0), + padRadius = null, + startAngle = arcStartAngle, + endAngle = arcEndAngle, + padAngle = arcPadAngle, + context = null, + path = withPath(arc); + + function arc() { + var buffer, + r, + r0 = +innerRadius.apply(this, arguments), + r1 = +outerRadius.apply(this, arguments), + a0 = startAngle.apply(this, arguments) - halfPi, + a1 = endAngle.apply(this, arguments) - halfPi, + da = abs(a1 - a0), + cw = a1 > a0; + + if (!context) context = buffer = path(); + + // Ensure that the outer radius is always larger than the inner radius. + if (r1 < r0) r = r1, r1 = r0, r0 = r; + + // Is it a point? + if (!(r1 > epsilon)) context.moveTo(0, 0); + + // Or is it a circle or annulus? + else if (da > tau - epsilon) { + context.moveTo(r1 * cos(a0), r1 * sin(a0)); + context.arc(0, 0, r1, a0, a1, !cw); + if (r0 > epsilon) { + context.moveTo(r0 * cos(a1), r0 * sin(a1)); + context.arc(0, 0, r0, a1, a0, cw); + } + } + + // Or is it a circular or annular sector? + else { + var a01 = a0, + a11 = a1, + a00 = a0, + a10 = a1, + da0 = da, + da1 = da, + ap = padAngle.apply(this, arguments) / 2, + rp = (ap > epsilon) && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), + rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), + rc0 = rc, + rc1 = rc, + t0, + t1; + + // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0. + if (rp > epsilon) { + var p0 = asin(rp / r0 * sin(ap)), + p1 = asin(rp / r1 * sin(ap)); + if ((da0 -= p0 * 2) > epsilon) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0; + else da0 = 0, a00 = a10 = (a0 + a1) / 2; + if ((da1 -= p1 * 2) > epsilon) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1; + else da1 = 0, a01 = a11 = (a0 + a1) / 2; + } + + var x01 = r1 * cos(a01), + y01 = r1 * sin(a01), + x10 = r0 * cos(a10), + y10 = r0 * sin(a10); + + // Apply rounded corners? + if (rc > epsilon) { + var x11 = r1 * cos(a11), + y11 = r1 * sin(a11), + x00 = r0 * cos(a00), + y00 = r0 * sin(a00), + oc; + + // Restrict the corner radius according to the sector angle. If this + // intersection fails, it’s probably because the arc is too small, so + // disable the corner radius entirely. + if (da < pi) { + if (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10)) { + var ax = x01 - oc[0], + ay = y01 - oc[1], + bx = x11 - oc[0], + by = y11 - oc[1], + kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), + lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]); + rc0 = min(rc, (r0 - lc) / (kc - 1)); + rc1 = min(rc, (r1 - lc) / (kc + 1)); + } else { + rc0 = rc1 = 0; + } + } + } + + // Is the sector collapsed to a line? + if (!(da1 > epsilon)) context.moveTo(x01, y01); + + // Does the sector’s outer ring have rounded corners? + else if (rc1 > epsilon) { + t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw); + t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw); + + context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw); + context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the outer ring just a circular arc? + else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw); + + // Is there no inner ring, and it’s a circular sector? + // Or perhaps it’s an annular sector collapsed due to padding? + if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10); + + // Does the sector’s inner ring (or point) have rounded corners? + else if (rc0 > epsilon) { + t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw); + t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw); + + context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw); + context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the inner ring just a circular arc? + else context.arc(0, 0, r0, a10, a00, cw); + } + + context.closePath(); + + if (buffer) return context = null, buffer + "" || null; + } + + arc.centroid = function() { + var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, + a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2; + return [cos(a) * r, sin(a) * r]; + }; + + arc.innerRadius = function(_) { + return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc) : innerRadius; + }; + + arc.outerRadius = function(_) { + return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius; + }; + + arc.cornerRadius = function(_) { + return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius; + }; + + arc.padRadius = function(_) { + return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius; + }; + + arc.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle; + }; + + arc.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle; + }; + + arc.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle; + }; + + arc.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), arc) : context; + }; + + return arc; +} + +export { arc as a }; diff --git a/libs/marked/array-DJxSMw-N.js b/libs/marked/array-DJxSMw-N.js new file mode 100644 index 0000000..2b2997b --- /dev/null +++ b/libs/marked/array-DJxSMw-N.js @@ -0,0 +1,7 @@ +function array(x) { + return typeof x === "object" && "length" in x + ? x // Array, TypedArray, NodeList, array-like + : Array.from(x); // Map, Set, iterable, string, or anything else +} + +export { array as a }; diff --git a/libs/marked/blockDiagram-9f4a6865-Bzsqusn3.js b/libs/marked/blockDiagram-9f4a6865-Bzsqusn3.js new file mode 100644 index 0000000..51595a3 --- /dev/null +++ b/libs/marked/blockDiagram-9f4a6865-Bzsqusn3.js @@ -0,0 +1,1818 @@ +import { c as getConfig, _ as getConfig$1, h as select, i as configureSvgSize, l as log$1, E as clear$1, B as rgba, j as common$1, o as getStylesFromArray } from './index-CN3YjQ0n.js'; +import { c as clone } from './clone-B4k62NSz.js'; +import { i as insertMarkers$1, c as insertEdge, b as insertEdgeLabel, d as positionEdgeLabel, a as insertNode, p as positionNode } from './edges-066a5561-a6s42o55.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { c as channel } from './channel-DcrZctv4.js'; +import { s as schemeTableau10 } from './Tableau10-CkeCzOvH.js'; +import './createText-ca0c5216-DF05SDfj.js'; +import './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; +import './init-zpY4DTin.js'; + +var _a, _b; +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 7], $V1 = [1, 13], $V2 = [1, 14], $V3 = [1, 15], $V4 = [1, 19], $V5 = [1, 16], $V6 = [1, 17], $V7 = [1, 18], $V8 = [8, 30], $V9 = [8, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Va = [1, 23], $Vb = [1, 24], $Vc = [8, 15, 16, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Vd = [8, 15, 16, 21, 27, 28, 29, 30, 31, 32, 40, 44, 47], $Ve = [1, 49]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "spaceLines": 3, "SPACELINE": 4, "NL": 5, "separator": 6, "SPACE": 7, "EOF": 8, "start": 9, "BLOCK_DIAGRAM_KEY": 10, "document": 11, "stop": 12, "statement": 13, "link": 14, "LINK": 15, "START_LINK": 16, "LINK_LABEL": 17, "STR": 18, "nodeStatement": 19, "columnsStatement": 20, "SPACE_BLOCK": 21, "blockStatement": 22, "classDefStatement": 23, "cssClassStatement": 24, "styleStatement": 25, "node": 26, "SIZE": 27, "COLUMNS": 28, "id-block": 29, "end": 30, "block": 31, "NODE_ID": 32, "nodeShapeNLabel": 33, "dirList": 34, "DIR": 35, "NODE_DSTART": 36, "NODE_DEND": 37, "BLOCK_ARROW_START": 38, "BLOCK_ARROW_END": 39, "classDef": 40, "CLASSDEF_ID": 41, "CLASSDEF_STYLEOPTS": 42, "DEFAULT": 43, "class": 44, "CLASSENTITY_IDS": 45, "STYLECLASS": 46, "style": 47, "STYLE_ENTITY_IDS": 48, "STYLE_DEFINITION_DATA": 49, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACELINE", 5: "NL", 7: "SPACE", 8: "EOF", 10: "BLOCK_DIAGRAM_KEY", 15: "LINK", 16: "START_LINK", 17: "LINK_LABEL", 18: "STR", 21: "SPACE_BLOCK", 27: "SIZE", 28: "COLUMNS", 29: "id-block", 30: "end", 31: "block", 32: "NODE_ID", 35: "DIR", 36: "NODE_DSTART", 37: "NODE_DEND", 38: "BLOCK_ARROW_START", 39: "BLOCK_ARROW_END", 40: "classDef", 41: "CLASSDEF_ID", 42: "CLASSDEF_STYLEOPTS", 43: "DEFAULT", 44: "class", 45: "CLASSENTITY_IDS", 46: "STYLECLASS", 47: "style", 48: "STYLE_ENTITY_IDS", 49: "STYLE_DEFINITION_DATA" }, + productions_: [0, [3, 1], [3, 2], [3, 2], [6, 1], [6, 1], [6, 1], [9, 3], [12, 1], [12, 1], [12, 2], [12, 2], [11, 1], [11, 2], [14, 1], [14, 4], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [19, 3], [19, 2], [19, 1], [20, 1], [22, 4], [22, 3], [26, 1], [26, 2], [34, 1], [34, 2], [33, 3], [33, 4], [23, 3], [23, 3], [24, 3], [25, 3]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 4: + yy.getLogger().debug("Rule: separator (NL) "); + break; + case 5: + yy.getLogger().debug("Rule: separator (Space) "); + break; + case 6: + yy.getLogger().debug("Rule: separator (EOF) "); + break; + case 7: + yy.getLogger().debug("Rule: hierarchy: ", $$[$0 - 1]); + yy.setHierarchy($$[$0 - 1]); + break; + case 8: + yy.getLogger().debug("Stop NL "); + break; + case 9: + yy.getLogger().debug("Stop EOF "); + break; + case 10: + yy.getLogger().debug("Stop NL2 "); + break; + case 11: + yy.getLogger().debug("Stop EOF2 "); + break; + case 12: + yy.getLogger().debug("Rule: statement: ", $$[$0]); + typeof $$[$0].length === "number" ? this.$ = $$[$0] : this.$ = [$$[$0]]; + break; + case 13: + yy.getLogger().debug("Rule: statement #2: ", $$[$0 - 1]); + this.$ = [$$[$0 - 1]].concat($$[$0]); + break; + case 14: + yy.getLogger().debug("Rule: link: ", $$[$0], yytext); + this.$ = { edgeTypeStr: $$[$0], label: "" }; + break; + case 15: + yy.getLogger().debug("Rule: LABEL link: ", $$[$0 - 3], $$[$0 - 1], $$[$0]); + this.$ = { edgeTypeStr: $$[$0], label: $$[$0 - 1] }; + break; + case 18: + const num = parseInt($$[$0]); + const spaceId = yy.generateId(); + this.$ = { id: spaceId, type: "space", label: "", width: num, children: [] }; + break; + case 23: + yy.getLogger().debug("Rule: (nodeStatement link node) ", $$[$0 - 2], $$[$0 - 1], $$[$0], " typestr: ", $$[$0 - 1].edgeTypeStr); + const edgeData = yy.edgeStrToEdgeData($$[$0 - 1].edgeTypeStr); + this.$ = [ + { id: $$[$0 - 2].id, label: $$[$0 - 2].label, type: $$[$0 - 2].type, directions: $$[$0 - 2].directions }, + { id: $$[$0 - 2].id + "-" + $$[$0].id, start: $$[$0 - 2].id, end: $$[$0].id, label: $$[$0 - 1].label, type: "edge", directions: $$[$0].directions, arrowTypeEnd: edgeData, arrowTypeStart: "arrow_open" }, + { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions } + ]; + break; + case 24: + yy.getLogger().debug("Rule: nodeStatement (abc88 node size) ", $$[$0 - 1], $$[$0]); + this.$ = { id: $$[$0 - 1].id, label: $$[$0 - 1].label, type: yy.typeStr2Type($$[$0 - 1].typeStr), directions: $$[$0 - 1].directions, widthInColumns: parseInt($$[$0], 10) }; + break; + case 25: + yy.getLogger().debug("Rule: nodeStatement (node) ", $$[$0]); + this.$ = { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions, widthInColumns: 1 }; + break; + case 26: + yy.getLogger().debug("APA123", this ? this : "na"); + yy.getLogger().debug("COLUMNS: ", $$[$0]); + this.$ = { type: "column-setting", columns: $$[$0] === "auto" ? -1 : parseInt($$[$0]) }; + break; + case 27: + yy.getLogger().debug("Rule: id-block statement : ", $$[$0 - 2], $$[$0 - 1]); + yy.generateId(); + this.$ = { ...$$[$0 - 2], type: "composite", children: $$[$0 - 1] }; + break; + case 28: + yy.getLogger().debug("Rule: blockStatement : ", $$[$0 - 2], $$[$0 - 1], $$[$0]); + const id = yy.generateId(); + this.$ = { id, type: "composite", label: "", children: $$[$0 - 1] }; + break; + case 29: + yy.getLogger().debug("Rule: node (NODE_ID separator): ", $$[$0]); + this.$ = { id: $$[$0] }; + break; + case 30: + yy.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", $$[$0 - 1], $$[$0]); + this.$ = { id: $$[$0 - 1], label: $$[$0].label, typeStr: $$[$0].typeStr, directions: $$[$0].directions }; + break; + case 31: + yy.getLogger().debug("Rule: dirList: ", $$[$0]); + this.$ = [$$[$0]]; + break; + case 32: + yy.getLogger().debug("Rule: dirList: ", $$[$0 - 1], $$[$0]); + this.$ = [$$[$0 - 1]].concat($$[$0]); + break; + case 33: + yy.getLogger().debug("Rule: nodeShapeNLabel: ", $$[$0 - 2], $$[$0 - 1], $$[$0]); + this.$ = { typeStr: $$[$0 - 2] + $$[$0], label: $$[$0 - 1] }; + break; + case 34: + yy.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", $$[$0 - 3], $$[$0 - 2], " #3:", $$[$0 - 1], $$[$0]); + this.$ = { typeStr: $$[$0 - 3] + $$[$0], label: $$[$0 - 2], directions: $$[$0 - 1] }; + break; + case 35: + case 36: + this.$ = { type: "classDef", id: $$[$0 - 1].trim(), css: $$[$0].trim() }; + break; + case 37: + this.$ = { type: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; + break; + case 38: + this.$ = { type: "applyStyles", id: $$[$0 - 1].trim(), stylesStr: $$[$0].trim() }; + break; + } + }, + table: [{ 9: 1, 10: [1, 2] }, { 1: [3] }, { 11: 3, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 8: [1, 20] }, o($V8, [2, 12], { 13: 4, 19: 5, 20: 6, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 11: 21, 21: $V0, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }), o($V9, [2, 16], { 14: 22, 15: $Va, 16: $Vb }), o($V9, [2, 17]), o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), o($V9, [2, 21]), o($V9, [2, 22]), o($Vc, [2, 25], { 27: [1, 25] }), o($V9, [2, 26]), { 19: 26, 26: 12, 32: $V4 }, { 11: 27, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 41: [1, 28], 43: [1, 29] }, { 45: [1, 30] }, { 48: [1, 31] }, o($Vd, [2, 29], { 33: 32, 36: [1, 33], 38: [1, 34] }), { 1: [2, 7] }, o($V8, [2, 13]), { 26: 35, 32: $V4 }, { 32: [2, 14] }, { 17: [1, 36] }, o($Vc, [2, 24]), { 11: 37, 13: 4, 14: 22, 15: $Va, 16: $Vb, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 30: [1, 38] }, { 42: [1, 39] }, { 42: [1, 40] }, { 46: [1, 41] }, { 49: [1, 42] }, o($Vd, [2, 30]), { 18: [1, 43] }, { 18: [1, 44] }, o($Vc, [2, 23]), { 18: [1, 45] }, { 30: [1, 46] }, o($V9, [2, 28]), o($V9, [2, 35]), o($V9, [2, 36]), o($V9, [2, 37]), o($V9, [2, 38]), { 37: [1, 47] }, { 34: 48, 35: $Ve }, { 15: [1, 50] }, o($V9, [2, 27]), o($Vd, [2, 33]), { 39: [1, 51] }, { 34: 52, 35: $Ve, 39: [2, 31] }, { 32: [2, 15] }, o($Vd, [2, 34]), { 39: [2, 32] }], + defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 10; + case 1: + yy.getLogger().debug("Found space-block"); + return 31; + case 2: + yy.getLogger().debug("Found nl-block"); + return 31; + case 3: + yy.getLogger().debug("Found space-block"); + return 29; + case 4: + yy.getLogger().debug(".", yy_.yytext); + break; + case 5: + yy.getLogger().debug("_", yy_.yytext); + break; + case 6: + return 5; + case 7: + yy_.yytext = -1; + return 28; + case 8: + yy_.yytext = yy_.yytext.replace(/columns\s+/, ""); + yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); + return 28; + case 9: + this.pushState("md_string"); + break; + case 10: + return "MD_STR"; + case 11: + this.popState(); + break; + case 12: + this.pushState("string"); + break; + case 13: + yy.getLogger().debug("LEX: POPPING STR:", yy_.yytext); + this.popState(); + break; + case 14: + yy.getLogger().debug("LEX: STR end:", yy_.yytext); + return "STR"; + case 15: + yy_.yytext = yy_.yytext.replace(/space\:/, ""); + yy.getLogger().debug("SPACE NUM (LEX)", yy_.yytext); + return 21; + case 16: + yy_.yytext = "1"; + yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); + return 21; + case 17: + return 43; + case 18: + return "LINKSTYLE"; + case 19: + return "INTERPOLATE"; + case 20: + this.pushState("CLASSDEF"); + return 40; + case 21: + this.popState(); + this.pushState("CLASSDEFID"); + return "DEFAULT_CLASSDEF_ID"; + case 22: + this.popState(); + this.pushState("CLASSDEFID"); + return 41; + case 23: + this.popState(); + return 42; + case 24: + this.pushState("CLASS"); + return 44; + case 25: + this.popState(); + this.pushState("CLASS_STYLE"); + return 45; + case 26: + this.popState(); + return 46; + case 27: + this.pushState("STYLE_STMNT"); + return 47; + case 28: + this.popState(); + this.pushState("STYLE_DEFINITION"); + return 48; + case 29: + this.popState(); + return 49; + case 30: + this.pushState("acc_title"); + return "acc_title"; + case 31: + this.popState(); + return "acc_title_value"; + case 32: + this.pushState("acc_descr"); + return "acc_descr"; + case 33: + this.popState(); + return "acc_descr_value"; + case 34: + this.pushState("acc_descr_multiline"); + break; + case 35: + this.popState(); + break; + case 36: + return "acc_descr_multiline_value"; + case 37: + return 30; + case 38: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 39: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 40: + this.popState(); + yy.getLogger().debug("Lex: ))"); + return "NODE_DEND"; + case 41: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 42: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 43: + this.popState(); + yy.getLogger().debug("Lex: (-"); + return "NODE_DEND"; + case 44: + this.popState(); + yy.getLogger().debug("Lex: -)"); + return "NODE_DEND"; + case 45: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 46: + this.popState(); + yy.getLogger().debug("Lex: ]]"); + return "NODE_DEND"; + case 47: + this.popState(); + yy.getLogger().debug("Lex: ("); + return "NODE_DEND"; + case 48: + this.popState(); + yy.getLogger().debug("Lex: ])"); + return "NODE_DEND"; + case 49: + this.popState(); + yy.getLogger().debug("Lex: /]"); + return "NODE_DEND"; + case 50: + this.popState(); + yy.getLogger().debug("Lex: /]"); + return "NODE_DEND"; + case 51: + this.popState(); + yy.getLogger().debug("Lex: )]"); + return "NODE_DEND"; + case 52: + this.popState(); + yy.getLogger().debug("Lex: )"); + return "NODE_DEND"; + case 53: + this.popState(); + yy.getLogger().debug("Lex: ]>"); + return "NODE_DEND"; + case 54: + this.popState(); + yy.getLogger().debug("Lex: ]"); + return "NODE_DEND"; + case 55: + yy.getLogger().debug("Lexa: -)"); + this.pushState("NODE"); + return 36; + case 56: + yy.getLogger().debug("Lexa: (-"); + this.pushState("NODE"); + return 36; + case 57: + yy.getLogger().debug("Lexa: ))"); + this.pushState("NODE"); + return 36; + case 58: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 59: + yy.getLogger().debug("Lex: ((("); + this.pushState("NODE"); + return 36; + case 60: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 61: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 62: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 63: + yy.getLogger().debug("Lexc: >"); + this.pushState("NODE"); + return 36; + case 64: + yy.getLogger().debug("Lexa: (["); + this.pushState("NODE"); + return 36; + case 65: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 66: + this.pushState("NODE"); + return 36; + case 67: + this.pushState("NODE"); + return 36; + case 68: + this.pushState("NODE"); + return 36; + case 69: + this.pushState("NODE"); + return 36; + case 70: + this.pushState("NODE"); + return 36; + case 71: + this.pushState("NODE"); + return 36; + case 72: + this.pushState("NODE"); + return 36; + case 73: + yy.getLogger().debug("Lexa: ["); + this.pushState("NODE"); + return 36; + case 74: + this.pushState("BLOCK_ARROW"); + yy.getLogger().debug("LEX ARR START"); + return 38; + case 75: + yy.getLogger().debug("Lex: NODE_ID", yy_.yytext); + return 32; + case 76: + yy.getLogger().debug("Lex: EOF", yy_.yytext); + return 8; + case 77: + this.pushState("md_string"); + break; + case 78: + this.pushState("md_string"); + break; + case 79: + return "NODE_DESCR"; + case 80: + this.popState(); + break; + case 81: + yy.getLogger().debug("Lex: Starting string"); + this.pushState("string"); + break; + case 82: + yy.getLogger().debug("LEX ARR: Starting string"); + this.pushState("string"); + break; + case 83: + yy.getLogger().debug("LEX: NODE_DESCR:", yy_.yytext); + return "NODE_DESCR"; + case 84: + yy.getLogger().debug("LEX POPPING"); + this.popState(); + break; + case 85: + yy.getLogger().debug("Lex: =>BAE"); + this.pushState("ARROW_DIR"); + break; + case 86: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (right): dir:", yy_.yytext); + return "DIR"; + case 87: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (left):", yy_.yytext); + return "DIR"; + case 88: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (x):", yy_.yytext); + return "DIR"; + case 89: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (y):", yy_.yytext); + return "DIR"; + case 90: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (up):", yy_.yytext); + return "DIR"; + case 91: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (down):", yy_.yytext); + return "DIR"; + case 92: + yy_.yytext = "]>"; + yy.getLogger().debug("Lex (ARROW_DIR end):", yy_.yytext); + this.popState(); + this.popState(); + return "BLOCK_ARROW_END"; + case 93: + yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); + return 15; + case 94: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 95: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 96: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 97: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 98: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 99: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 100: + this.pushState("md_string"); + break; + case 101: + yy.getLogger().debug("Lex: Starting string"); + this.pushState("string"); + return "LINK_LABEL"; + case 102: + this.popState(); + yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); + return 15; + case 103: + this.popState(); + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 104: + this.popState(); + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 105: + yy.getLogger().debug("Lex: COLON", yy_.yytext); + yy_.yytext = yy_.yytext.slice(1); + return 27; + } + }, + rules: [/^(?:block-beta\b)/, /^(?:block\s+)/, /^(?:block\n+)/, /^(?:block:)/, /^(?:[\s]+)/, /^(?:[\n]+)/, /^(?:((\u000D\u000A)|(\u000A)))/, /^(?:columns\s+auto\b)/, /^(?:columns\s+[\d]+)/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:space[:]\d+)/, /^(?:space\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\s+)/, /^(?:DEFAULT\s+)/, /^(?:\w+\s+)/, /^(?:[^\n]*)/, /^(?:class\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:style\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:end\b\s*)/, /^(?:\(\(\()/, /^(?:\)\)\))/, /^(?:[\)]\))/, /^(?:\}\})/, /^(?:\})/, /^(?:\(-)/, /^(?:-\))/, /^(?:\(\()/, /^(?:\]\])/, /^(?:\()/, /^(?:\]\))/, /^(?:\\\])/, /^(?:\/\])/, /^(?:\)\])/, /^(?:[\)])/, /^(?:\]>)/, /^(?:[\]])/, /^(?:-\))/, /^(?:\(-)/, /^(?:\)\))/, /^(?:\))/, /^(?:\(\(\()/, /^(?:\(\()/, /^(?:\{\{)/, /^(?:\{)/, /^(?:>)/, /^(?:\(\[)/, /^(?:\()/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\[\\)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:\[)/, /^(?:<\[)/, /^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/, /^(?:$)/, /^(?:["][`])/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:\]>\s*\()/, /^(?:,?\s*right\s*)/, /^(?:,?\s*left\s*)/, /^(?:,?\s*x\s*)/, /^(?:,?\s*y\s*)/, /^(?:,?\s*up\s*)/, /^(?:,?\s*down\s*)/, /^(?:\)\s*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*~~[\~]+\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:["][`])/, /^(?:["])/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?::\d+)/], + conditions: { "STYLE_DEFINITION": { "rules": [29], "inclusive": false }, "STYLE_STMNT": { "rules": [28], "inclusive": false }, "CLASSDEFID": { "rules": [23], "inclusive": false }, "CLASSDEF": { "rules": [21, 22], "inclusive": false }, "CLASS_STYLE": { "rules": [26], "inclusive": false }, "CLASS": { "rules": [25], "inclusive": false }, "LLABEL": { "rules": [100, 101, 102, 103, 104], "inclusive": false }, "ARROW_DIR": { "rules": [86, 87, 88, 89, 90, 91, 92], "inclusive": false }, "BLOCK_ARROW": { "rules": [77, 82, 85], "inclusive": false }, "NODE": { "rules": [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 78, 81], "inclusive": false }, "md_string": { "rules": [10, 11, 79, 80], "inclusive": false }, "space": { "rules": [], "inclusive": false }, "string": { "rules": [13, 14, 83, 84], "inclusive": false }, "acc_descr_multiline": { "rules": [35, 36], "inclusive": false }, "acc_descr": { "rules": [33], "inclusive": false }, "acc_title": { "rules": [31], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 24, 27, 30, 32, 34, 37, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 93, 94, 95, 96, 97, 98, 99, 105], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let blockDatabase = {}; +let edgeList = []; +let edgeCount = {}; +const COLOR_KEYWORD = "color"; +const FILL_KEYWORD = "fill"; +const BG_FILL = "bgFill"; +const STYLECLASS_SEP = ","; +const config = getConfig(); +let classes = {}; +const sanitizeText = (txt) => common$1.sanitizeText(txt, config); +const addStyleClass = function(id, styleAttributes = "") { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + const foundClass = classes[id]; + if (styleAttributes !== void 0 && styleAttributes !== null) { + styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { + const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); + if (attrib.match(COLOR_KEYWORD)) { + const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL); + const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD); + foundClass.textStyles.push(newStyle2); + } + foundClass.styles.push(fixedAttrib); + }); + } +}; +const addStyle2Node = function(id, styles = "") { + const foundBlock = blockDatabase[id]; + if (styles !== void 0 && styles !== null) { + foundBlock.styles = styles.split(STYLECLASS_SEP); + } +}; +const setCssClass = function(itemIds, cssClassName) { + itemIds.split(",").forEach(function(id) { + let foundBlock = blockDatabase[id]; + if (foundBlock === void 0) { + const trimmedId = id.trim(); + blockDatabase[trimmedId] = { id: trimmedId, type: "na", children: [] }; + foundBlock = blockDatabase[trimmedId]; + } + if (!foundBlock.classes) { + foundBlock.classes = []; + } + foundBlock.classes.push(cssClassName); + }); +}; +const populateBlockDatabase = (_blockList, parent) => { + const blockList = _blockList.flat(); + const children = []; + for (const block of blockList) { + if (block.label) { + block.label = sanitizeText(block.label); + } + if (block.type === "classDef") { + addStyleClass(block.id, block.css); + continue; + } + if (block.type === "applyClass") { + setCssClass(block.id, (block == null ? void 0 : block.styleClass) || ""); + continue; + } + if (block.type === "applyStyles") { + if (block == null ? void 0 : block.stylesStr) { + addStyle2Node(block.id, block == null ? void 0 : block.stylesStr); + } + continue; + } + if (block.type === "column-setting") { + parent.columns = block.columns || -1; + } else if (block.type === "edge") { + if (edgeCount[block.id]) { + edgeCount[block.id]++; + } else { + edgeCount[block.id] = 1; + } + block.id = edgeCount[block.id] + "-" + block.id; + edgeList.push(block); + } else { + if (!block.label) { + if (block.type === "composite") { + block.label = ""; + } else { + block.label = block.id; + } + } + const newBlock = !blockDatabase[block.id]; + if (newBlock) { + blockDatabase[block.id] = block; + } else { + if (block.type !== "na") { + blockDatabase[block.id].type = block.type; + } + if (block.label !== block.id) { + blockDatabase[block.id].label = block.label; + } + } + if (block.children) { + populateBlockDatabase(block.children, block); + } + if (block.type === "space") { + const w = block.width || 1; + for (let j = 0; j < w; j++) { + const newBlock2 = clone(block); + newBlock2.id = newBlock2.id + "-" + j; + blockDatabase[newBlock2.id] = newBlock2; + children.push(newBlock2); + } + } else if (newBlock) { + children.push(block); + } + } + } + parent.children = children; +}; +let blocks = []; +let rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; +const clear = () => { + log$1.debug("Clear called"); + clear$1(); + rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; + blockDatabase = { root: rootBlock }; + blocks = []; + classes = {}; + edgeList = []; + edgeCount = {}; +}; +function typeStr2Type(typeStr) { + log$1.debug("typeStr2Type", typeStr); + switch (typeStr) { + case "[]": + return "square"; + case "()": + log$1.debug("we have a round"); + return "round"; + case "(())": + return "circle"; + case ">]": + return "rect_left_inv_arrow"; + case "{}": + return "diamond"; + case "{{}}": + return "hexagon"; + case "([])": + return "stadium"; + case "[[]]": + return "subroutine"; + case "[()]": + return "cylinder"; + case "((()))": + return "doublecircle"; + case "[//]": + return "lean_right"; + case "[\\\\]": + return "lean_left"; + case "[/\\]": + return "trapezoid"; + case "[\\/]": + return "inv_trapezoid"; + case "<[]>": + return "block_arrow"; + default: + return "na"; + } +} +function edgeTypeStr2Type(typeStr) { + log$1.debug("typeStr2Type", typeStr); + switch (typeStr) { + case "==": + return "thick"; + default: + return "normal"; + } +} +function edgeStrToEdgeData(typeStr) { + switch (typeStr.trim()) { + case "--x": + return "arrow_cross"; + case "--o": + return "arrow_circle"; + default: + return "arrow_point"; + } +} +let cnt = 0; +const generateId = () => { + cnt++; + return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt; +}; +const setHierarchy = (block) => { + rootBlock.children = block; + populateBlockDatabase(block, rootBlock); + blocks = rootBlock.children; +}; +const getColumns = (blockId) => { + const block = blockDatabase[blockId]; + if (!block) { + return -1; + } + if (block.columns) { + return block.columns; + } + if (!block.children) { + return -1; + } + return block.children.length; +}; +const getBlocksFlat = () => { + return [...Object.values(blockDatabase)]; +}; +const getBlocks = () => { + return blocks || []; +}; +const getEdges = () => { + return edgeList; +}; +const getBlock = (id) => { + return blockDatabase[id]; +}; +const setBlock = (block) => { + blockDatabase[block.id] = block; +}; +const getLogger = () => console; +const getClasses$1 = function() { + return classes; +}; +const db = { + getConfig: () => getConfig$1().block, + typeStr2Type, + edgeTypeStr2Type, + edgeStrToEdgeData, + getLogger, + getBlocksFlat, + getBlocks, + getEdges, + setHierarchy, + getBlock, + setBlock, + getColumns, + getClasses: getClasses$1, + clear, + generateId +}; +const db$1 = db; +const fade = (color, opacity) => { + const channel$1 = channel; + const r = channel$1(color, "r"); + const g = channel$1(color, "g"); + const b = channel$1(color, "b"); + return rgba(r, g, b, opacity); +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span,p { + color: ${options.titleColor}; + } + + + + .label text,span,p { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + .flowchart-label text { + text-anchor: middle; + } + // .flowchart-label .text-outer-tspan { + // text-anchor: middle; + // } + // .flowchart-label .text-inner-tspan { + // text-anchor: start; + // } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + /* For html labels only */ + .labelBkg { + background-color: ${fade(options.edgeLabelBackground, 0.5)}; + // background-color: + } + + .node .cluster { + // fill: ${fade(options.mainBkg, 0.5)}; + fill: ${fade(options.clusterBkg, 0.5)}; + stroke: ${fade(options.clusterBorder, 0.2)}; + box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span,p { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } +`; +const flowStyles = getStyles; +function getNodeFromBlock(block, db2, positioned = false) { + var _a2, _b2, _c; + const vertex = block; + let classStr = "default"; + if ((((_a2 = vertex == null ? void 0 : vertex.classes) == null ? void 0 : _a2.length) || 0) > 0) { + classStr = ((vertex == null ? void 0 : vertex.classes) || []).join(" "); + } + classStr = classStr + " flowchart-label"; + let radius = 0; + let shape = ""; + let padding2; + switch (vertex.type) { + case "round": + radius = 5; + shape = "rect"; + break; + case "composite": + radius = 0; + shape = "composite"; + padding2 = 0; + break; + case "square": + shape = "rect"; + break; + case "diamond": + shape = "question"; + break; + case "hexagon": + shape = "hexagon"; + break; + case "block_arrow": + shape = "block_arrow"; + break; + case "odd": + shape = "rect_left_inv_arrow"; + break; + case "lean_right": + shape = "lean_right"; + break; + case "lean_left": + shape = "lean_left"; + break; + case "trapezoid": + shape = "trapezoid"; + break; + case "inv_trapezoid": + shape = "inv_trapezoid"; + break; + case "rect_left_inv_arrow": + shape = "rect_left_inv_arrow"; + break; + case "circle": + shape = "circle"; + break; + case "ellipse": + shape = "ellipse"; + break; + case "stadium": + shape = "stadium"; + break; + case "subroutine": + shape = "subroutine"; + break; + case "cylinder": + shape = "cylinder"; + break; + case "group": + shape = "rect"; + break; + case "doublecircle": + shape = "doublecircle"; + break; + default: + shape = "rect"; + } + const styles = getStylesFromArray((vertex == null ? void 0 : vertex.styles) || []); + const vertexText = vertex.label; + const bounds = vertex.size || { width: 0, height: 0, x: 0, y: 0 }; + const node = { + labelStyle: styles.labelStyle, + shape, + labelText: vertexText, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + directions: vertex.directions, + width: bounds.width, + height: bounds.height, + x: bounds.x, + y: bounds.y, + positioned, + intersect: void 0, + type: vertex.type, + padding: padding2 ?? (((_c = (_b2 = getConfig$1()) == null ? void 0 : _b2.block) == null ? void 0 : _c.padding) || 0) + }; + return node; +} +async function calculateBlockSize(elem, block, db2) { + const node = getNodeFromBlock(block, db2, false); + if (node.type === "group") { + return; + } + const nodeEl = await insertNode(elem, node); + const boundingBox = nodeEl.node().getBBox(); + const obj = db2.getBlock(node.id); + obj.size = { width: boundingBox.width, height: boundingBox.height, x: 0, y: 0, node: nodeEl }; + db2.setBlock(obj); + nodeEl.remove(); +} +async function insertBlockPositioned(elem, block, db2) { + const node = getNodeFromBlock(block, db2, true); + const obj = db2.getBlock(node.id); + if (obj.type !== "space") { + await insertNode(elem, node); + block.intersect = node == null ? void 0 : node.intersect; + positionNode(node); + } +} +async function performOperations(elem, blocks2, db2, operation) { + for (const block of blocks2) { + await operation(elem, block, db2); + if (block.children) { + await performOperations(elem, block.children, db2, operation); + } + } +} +async function calculateBlockSizes(elem, blocks2, db2) { + await performOperations(elem, blocks2, db2, calculateBlockSize); +} +async function insertBlocks(elem, blocks2, db2) { + await performOperations(elem, blocks2, db2, insertBlockPositioned); +} +async function insertEdges(elem, edges, blocks2, db2, id) { + const g = new Graph({ + multigraph: true, + compound: true + }); + g.setGraph({ + rankdir: "TB", + nodesep: 10, + ranksep: 10, + marginx: 8, + marginy: 8 + }); + for (const block of blocks2) { + if (block.size) { + g.setNode(block.id, { + width: block.size.width, + height: block.size.height, + intersect: block.intersect + }); + } + } + for (const edge of edges) { + if (edge.start && edge.end) { + const startBlock = db2.getBlock(edge.start); + const endBlock = db2.getBlock(edge.end); + if ((startBlock == null ? void 0 : startBlock.size) && (endBlock == null ? void 0 : endBlock.size)) { + const start = startBlock.size; + const end = endBlock.size; + const points = [ + { x: start.x, y: start.y }, + { x: start.x + (end.x - start.x) / 2, y: start.y + (end.y - start.y) / 2 }, + { x: end.x, y: end.y } + ]; + await insertEdge( + elem, + { v: edge.start, w: edge.end, name: edge.id }, + { + ...edge, + arrowTypeEnd: edge.arrowTypeEnd, + arrowTypeStart: edge.arrowTypeStart, + points, + classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" + }, + void 0, + "block", + g, + id + ); + if (edge.label) { + await insertEdgeLabel(elem, { + ...edge, + label: edge.label, + labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;", + arrowTypeEnd: edge.arrowTypeEnd, + arrowTypeStart: edge.arrowTypeStart, + points, + classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" + }); + await positionEdgeLabel( + { ...edge, x: points[1].x, y: points[1].y }, + { + originalPath: points + } + ); + } + } + } + } +} +const padding = ((_b = (_a = getConfig()) == null ? void 0 : _a.block) == null ? void 0 : _b.padding) || 8; +function calculateBlockPosition(columns, position) { + if (columns === 0 || !Number.isInteger(columns)) { + throw new Error("Columns must be an integer !== 0."); + } + if (position < 0 || !Number.isInteger(position)) { + throw new Error("Position must be a non-negative integer." + position); + } + if (columns < 0) { + return { px: position, py: 0 }; + } + if (columns === 1) { + return { px: 0, py: position }; + } + const px = position % columns; + const py = Math.floor(position / columns); + return { px, py }; +} +const getMaxChildSize = (block) => { + let maxWidth = 0; + let maxHeight = 0; + for (const child of block.children) { + const { width, height, x, y } = child.size || { width: 0, height: 0, x: 0, y: 0 }; + log$1.debug( + "getMaxChildSize abc95 child:", + child.id, + "width:", + width, + "height:", + height, + "x:", + x, + "y:", + y, + child.type + ); + if (child.type === "space") { + continue; + } + if (width > maxWidth) { + maxWidth = width / (block.widthInColumns || 1); + } + if (height > maxHeight) { + maxHeight = height; + } + } + return { width: maxWidth, height: maxHeight }; +}; +function setBlockSizes(block, db2, siblingWidth = 0, siblingHeight = 0) { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k; + log$1.debug( + "setBlockSizes abc95 (start)", + block.id, + (_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x, + "block width =", + block == null ? void 0 : block.size, + "sieblingWidth", + siblingWidth + ); + if (!((_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.width)) { + block.size = { + width: siblingWidth, + height: siblingHeight, + x: 0, + y: 0 + }; + } + let maxWidth = 0; + let maxHeight = 0; + if (((_c = block.children) == null ? void 0 : _c.length) > 0) { + for (const child of block.children) { + setBlockSizes(child, db2); + } + const childSize = getMaxChildSize(block); + maxWidth = childSize.width; + maxHeight = childSize.height; + log$1.debug("setBlockSizes abc95 maxWidth of", block.id, ":s children is ", maxWidth, maxHeight); + for (const child of block.children) { + if (child.size) { + log$1.debug( + `abc95 Setting size of children of ${block.id} id=${child.id} ${maxWidth} ${maxHeight} ${child.size}` + ); + child.size.width = maxWidth * (child.widthInColumns || 1) + padding * ((child.widthInColumns || 1) - 1); + child.size.height = maxHeight; + child.size.x = 0; + child.size.y = 0; + log$1.debug( + `abc95 updating size of ${block.id} children child:${child.id} maxWidth:${maxWidth} maxHeight:${maxHeight}` + ); + } + } + for (const child of block.children) { + setBlockSizes(child, db2, maxWidth, maxHeight); + } + const columns = block.columns || -1; + let numItems = 0; + for (const child of block.children) { + numItems += child.widthInColumns || 1; + } + let xSize = block.children.length; + if (columns > 0 && columns < numItems) { + xSize = columns; + } + block.widthInColumns || 1; + const ySize = Math.ceil(numItems / xSize); + let width = xSize * (maxWidth + padding) + padding; + let height = ySize * (maxHeight + padding) + padding; + if (width < siblingWidth) { + log$1.debug( + `Detected to small siebling: abc95 ${block.id} sieblingWidth ${siblingWidth} sieblingHeight ${siblingHeight} width ${width}` + ); + width = siblingWidth; + height = siblingHeight; + const childWidth = (siblingWidth - xSize * padding - padding) / xSize; + const childHeight = (siblingHeight - ySize * padding - padding) / ySize; + log$1.debug("Size indata abc88", block.id, "childWidth", childWidth, "maxWidth", maxWidth); + log$1.debug("Size indata abc88", block.id, "childHeight", childHeight, "maxHeight", maxHeight); + log$1.debug("Size indata abc88 xSize", xSize, "padding", padding); + for (const child of block.children) { + if (child.size) { + child.size.width = childWidth; + child.size.height = childHeight; + child.size.x = 0; + child.size.y = 0; + } + } + } + log$1.debug( + `abc95 (finale calc) ${block.id} xSize ${xSize} ySize ${ySize} columns ${columns}${block.children.length} width=${Math.max(width, ((_d = block.size) == null ? void 0 : _d.width) || 0)}` + ); + if (width < (((_e = block == null ? void 0 : block.size) == null ? void 0 : _e.width) || 0)) { + width = ((_f = block == null ? void 0 : block.size) == null ? void 0 : _f.width) || 0; + const num = columns > 0 ? Math.min(block.children.length, columns) : block.children.length; + if (num > 0) { + const childWidth = (width - num * padding - padding) / num; + log$1.debug("abc95 (growing to fit) width", block.id, width, (_g = block.size) == null ? void 0 : _g.width, childWidth); + for (const child of block.children) { + if (child.size) { + child.size.width = childWidth; + } + } + } + } + block.size = { + width, + height, + x: 0, + y: 0 + }; + } + log$1.debug( + "setBlockSizes abc94 (done)", + block.id, + (_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x, + (_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width, + (_j = block == null ? void 0 : block.size) == null ? void 0 : _j.y, + (_k = block == null ? void 0 : block.size) == null ? void 0 : _k.height + ); +} +function layoutBlocks(block, db2) { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q; + log$1.debug( + `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${(_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x} y: ${(_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.y} width: ${(_c = block == null ? void 0 : block.size) == null ? void 0 : _c.width}` + ); + const columns = block.columns || -1; + log$1.debug("layoutBlocks columns abc95", block.id, "=>", columns, block); + if (block.children && // find max width of children + block.children.length > 0) { + const width = ((_e = (_d = block == null ? void 0 : block.children[0]) == null ? void 0 : _d.size) == null ? void 0 : _e.width) || 0; + const widthOfChildren = block.children.length * width + (block.children.length - 1) * padding; + log$1.debug("widthOfChildren 88", widthOfChildren, "posX"); + let columnPos = 0; + log$1.debug("abc91 block?.size?.x", block.id, (_f = block == null ? void 0 : block.size) == null ? void 0 : _f.x); + let startingPosX = ((_g = block == null ? void 0 : block.size) == null ? void 0 : _g.x) ? ((_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x) + (-((_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width) / 2 || 0) : -padding; + let rowPos = 0; + for (const child of block.children) { + const parent = block; + if (!child.size) { + continue; + } + const { width: width2, height } = child.size; + const { px, py } = calculateBlockPosition(columns, columnPos); + if (py != rowPos) { + rowPos = py; + startingPosX = ((_j = block == null ? void 0 : block.size) == null ? void 0 : _j.x) ? ((_k = block == null ? void 0 : block.size) == null ? void 0 : _k.x) + (-((_l = block == null ? void 0 : block.size) == null ? void 0 : _l.width) / 2 || 0) : -padding; + log$1.debug("New row in layout for block", block.id, " and child ", child.id, rowPos); + } + log$1.debug( + `abc89 layout blocks (child) id: ${child.id} Pos: ${columnPos} (px, py) ${px},${py} (${(_m = parent == null ? void 0 : parent.size) == null ? void 0 : _m.x},${(_n = parent == null ? void 0 : parent.size) == null ? void 0 : _n.y}) parent: ${parent.id} width: ${width2}${padding}` + ); + if (parent.size) { + const halfWidth = width2 / 2; + child.size.x = startingPosX + padding + halfWidth; + log$1.debug( + `abc91 layout blocks (calc) px, pyid:${child.id} startingPos=X${startingPosX} new startingPosX${child.size.x} ${halfWidth} padding=${padding} width=${width2} halfWidth=${halfWidth} => x:${child.size.x} y:${child.size.y} ${child.widthInColumns} (width * (child?.w || 1)) / 2 ${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}` + ); + startingPosX = child.size.x + halfWidth; + child.size.y = parent.size.y - parent.size.height / 2 + py * (height + padding) + height / 2 + padding; + log$1.debug( + `abc88 layout blocks (calc) px, pyid:${child.id}startingPosX${startingPosX}${padding}${halfWidth}=>x:${child.size.x}y:${child.size.y}${child.widthInColumns}(width * (child?.w || 1)) / 2${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}` + ); + } + if (child.children) { + layoutBlocks(child); + } + columnPos += (child == null ? void 0 : child.widthInColumns) || 1; + log$1.debug("abc88 columnsPos", child, columnPos); + } + } + log$1.debug( + `layout blocks (<==layoutBlocks) ${block.id} x: ${(_o = block == null ? void 0 : block.size) == null ? void 0 : _o.x} y: ${(_p = block == null ? void 0 : block.size) == null ? void 0 : _p.y} width: ${(_q = block == null ? void 0 : block.size) == null ? void 0 : _q.width}` + ); +} +function findBounds(block, { minX, minY, maxX, maxY } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) { + if (block.size && block.id !== "root") { + const { x, y, width, height } = block.size; + if (x - width / 2 < minX) { + minX = x - width / 2; + } + if (y - height / 2 < minY) { + minY = y - height / 2; + } + if (x + width / 2 > maxX) { + maxX = x + width / 2; + } + if (y + height / 2 > maxY) { + maxY = y + height / 2; + } + } + if (block.children) { + for (const child of block.children) { + ({ minX, minY, maxX, maxY } = findBounds(child, { minX, minY, maxX, maxY })); + } + } + return { minX, minY, maxX, maxY }; +} +function layout(db2) { + const root = db2.getBlock("root"); + if (!root) { + return; + } + setBlockSizes(root, db2, 0, 0); + layoutBlocks(root); + log$1.debug("getBlocks", JSON.stringify(root, null, 2)); + const { minX, minY, maxX, maxY } = findBounds(root); + const height = maxY - minY; + const width = maxX - minX; + return { x: minX, y: minY, width, height }; +} +const getClasses = function(text, diagObj) { + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + const { securityLevel, block: conf } = getConfig$1(); + const db2 = diagObj.db; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const markers = ["point", "circle", "cross"]; + insertMarkers$1(svg, markers, diagObj.type, id); + const bl = db2.getBlocks(); + const blArr = db2.getBlocksFlat(); + const edges = db2.getEdges(); + const nodes = svg.insert("g").attr("class", "block"); + await calculateBlockSizes(nodes, bl, db2); + const bounds = layout(db2); + await insertBlocks(nodes, bl, db2); + await insertEdges(nodes, edges, blArr, db2, id); + if (bounds) { + const bounds2 = bounds; + const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height))); + const height = bounds2.height + magicFactor + 10; + const width = bounds2.width + 10; + const { useMaxWidth } = conf; + configureSvgSize(svg, height, width, !!useMaxWidth); + log$1.debug("Here Bounds", bounds, bounds2); + svg.attr( + "viewBox", + `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}` + ); + } + ordinal(schemeTableau10); +}; +const renderer = { + draw, + getClasses +}; +const diagram = { + parser: parser$1, + db: db$1, + renderer, + styles: flowStyles +}; + +export { diagram }; diff --git a/libs/marked/blockDiagram-9f4a6865-DpcS6J66.js b/libs/marked/blockDiagram-9f4a6865-DpcS6J66.js new file mode 100644 index 0000000..ae76b6b --- /dev/null +++ b/libs/marked/blockDiagram-9f4a6865-DpcS6J66.js @@ -0,0 +1,1818 @@ +import { c as getConfig, _ as getConfig$1, h as select, i as configureSvgSize, l as log$1, E as clear$1, B as rgba, j as common$1, o as getStylesFromArray } from './index-Bd_FDXSq.js'; +import { c as clone } from './clone-B-QllgkM.js'; +import { i as insertMarkers$1, c as insertEdge, b as insertEdgeLabel, d as positionEdgeLabel, a as insertNode, p as positionNode } from './edges-066a5561-Bqw9g7uz.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { c as channel } from './channel-BxFDB0yY.js'; +import { s as schemeTableau10 } from './Tableau10-CkeCzOvH.js'; +import './createText-ca0c5216-B9KlDTE8.js'; +import './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; +import './init-zpY4DTin.js'; + +var _a, _b; +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 7], $V1 = [1, 13], $V2 = [1, 14], $V3 = [1, 15], $V4 = [1, 19], $V5 = [1, 16], $V6 = [1, 17], $V7 = [1, 18], $V8 = [8, 30], $V9 = [8, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Va = [1, 23], $Vb = [1, 24], $Vc = [8, 15, 16, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Vd = [8, 15, 16, 21, 27, 28, 29, 30, 31, 32, 40, 44, 47], $Ve = [1, 49]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "spaceLines": 3, "SPACELINE": 4, "NL": 5, "separator": 6, "SPACE": 7, "EOF": 8, "start": 9, "BLOCK_DIAGRAM_KEY": 10, "document": 11, "stop": 12, "statement": 13, "link": 14, "LINK": 15, "START_LINK": 16, "LINK_LABEL": 17, "STR": 18, "nodeStatement": 19, "columnsStatement": 20, "SPACE_BLOCK": 21, "blockStatement": 22, "classDefStatement": 23, "cssClassStatement": 24, "styleStatement": 25, "node": 26, "SIZE": 27, "COLUMNS": 28, "id-block": 29, "end": 30, "block": 31, "NODE_ID": 32, "nodeShapeNLabel": 33, "dirList": 34, "DIR": 35, "NODE_DSTART": 36, "NODE_DEND": 37, "BLOCK_ARROW_START": 38, "BLOCK_ARROW_END": 39, "classDef": 40, "CLASSDEF_ID": 41, "CLASSDEF_STYLEOPTS": 42, "DEFAULT": 43, "class": 44, "CLASSENTITY_IDS": 45, "STYLECLASS": 46, "style": 47, "STYLE_ENTITY_IDS": 48, "STYLE_DEFINITION_DATA": 49, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACELINE", 5: "NL", 7: "SPACE", 8: "EOF", 10: "BLOCK_DIAGRAM_KEY", 15: "LINK", 16: "START_LINK", 17: "LINK_LABEL", 18: "STR", 21: "SPACE_BLOCK", 27: "SIZE", 28: "COLUMNS", 29: "id-block", 30: "end", 31: "block", 32: "NODE_ID", 35: "DIR", 36: "NODE_DSTART", 37: "NODE_DEND", 38: "BLOCK_ARROW_START", 39: "BLOCK_ARROW_END", 40: "classDef", 41: "CLASSDEF_ID", 42: "CLASSDEF_STYLEOPTS", 43: "DEFAULT", 44: "class", 45: "CLASSENTITY_IDS", 46: "STYLECLASS", 47: "style", 48: "STYLE_ENTITY_IDS", 49: "STYLE_DEFINITION_DATA" }, + productions_: [0, [3, 1], [3, 2], [3, 2], [6, 1], [6, 1], [6, 1], [9, 3], [12, 1], [12, 1], [12, 2], [12, 2], [11, 1], [11, 2], [14, 1], [14, 4], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [19, 3], [19, 2], [19, 1], [20, 1], [22, 4], [22, 3], [26, 1], [26, 2], [34, 1], [34, 2], [33, 3], [33, 4], [23, 3], [23, 3], [24, 3], [25, 3]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 4: + yy.getLogger().debug("Rule: separator (NL) "); + break; + case 5: + yy.getLogger().debug("Rule: separator (Space) "); + break; + case 6: + yy.getLogger().debug("Rule: separator (EOF) "); + break; + case 7: + yy.getLogger().debug("Rule: hierarchy: ", $$[$0 - 1]); + yy.setHierarchy($$[$0 - 1]); + break; + case 8: + yy.getLogger().debug("Stop NL "); + break; + case 9: + yy.getLogger().debug("Stop EOF "); + break; + case 10: + yy.getLogger().debug("Stop NL2 "); + break; + case 11: + yy.getLogger().debug("Stop EOF2 "); + break; + case 12: + yy.getLogger().debug("Rule: statement: ", $$[$0]); + typeof $$[$0].length === "number" ? this.$ = $$[$0] : this.$ = [$$[$0]]; + break; + case 13: + yy.getLogger().debug("Rule: statement #2: ", $$[$0 - 1]); + this.$ = [$$[$0 - 1]].concat($$[$0]); + break; + case 14: + yy.getLogger().debug("Rule: link: ", $$[$0], yytext); + this.$ = { edgeTypeStr: $$[$0], label: "" }; + break; + case 15: + yy.getLogger().debug("Rule: LABEL link: ", $$[$0 - 3], $$[$0 - 1], $$[$0]); + this.$ = { edgeTypeStr: $$[$0], label: $$[$0 - 1] }; + break; + case 18: + const num = parseInt($$[$0]); + const spaceId = yy.generateId(); + this.$ = { id: spaceId, type: "space", label: "", width: num, children: [] }; + break; + case 23: + yy.getLogger().debug("Rule: (nodeStatement link node) ", $$[$0 - 2], $$[$0 - 1], $$[$0], " typestr: ", $$[$0 - 1].edgeTypeStr); + const edgeData = yy.edgeStrToEdgeData($$[$0 - 1].edgeTypeStr); + this.$ = [ + { id: $$[$0 - 2].id, label: $$[$0 - 2].label, type: $$[$0 - 2].type, directions: $$[$0 - 2].directions }, + { id: $$[$0 - 2].id + "-" + $$[$0].id, start: $$[$0 - 2].id, end: $$[$0].id, label: $$[$0 - 1].label, type: "edge", directions: $$[$0].directions, arrowTypeEnd: edgeData, arrowTypeStart: "arrow_open" }, + { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions } + ]; + break; + case 24: + yy.getLogger().debug("Rule: nodeStatement (abc88 node size) ", $$[$0 - 1], $$[$0]); + this.$ = { id: $$[$0 - 1].id, label: $$[$0 - 1].label, type: yy.typeStr2Type($$[$0 - 1].typeStr), directions: $$[$0 - 1].directions, widthInColumns: parseInt($$[$0], 10) }; + break; + case 25: + yy.getLogger().debug("Rule: nodeStatement (node) ", $$[$0]); + this.$ = { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions, widthInColumns: 1 }; + break; + case 26: + yy.getLogger().debug("APA123", this ? this : "na"); + yy.getLogger().debug("COLUMNS: ", $$[$0]); + this.$ = { type: "column-setting", columns: $$[$0] === "auto" ? -1 : parseInt($$[$0]) }; + break; + case 27: + yy.getLogger().debug("Rule: id-block statement : ", $$[$0 - 2], $$[$0 - 1]); + yy.generateId(); + this.$ = { ...$$[$0 - 2], type: "composite", children: $$[$0 - 1] }; + break; + case 28: + yy.getLogger().debug("Rule: blockStatement : ", $$[$0 - 2], $$[$0 - 1], $$[$0]); + const id = yy.generateId(); + this.$ = { id, type: "composite", label: "", children: $$[$0 - 1] }; + break; + case 29: + yy.getLogger().debug("Rule: node (NODE_ID separator): ", $$[$0]); + this.$ = { id: $$[$0] }; + break; + case 30: + yy.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", $$[$0 - 1], $$[$0]); + this.$ = { id: $$[$0 - 1], label: $$[$0].label, typeStr: $$[$0].typeStr, directions: $$[$0].directions }; + break; + case 31: + yy.getLogger().debug("Rule: dirList: ", $$[$0]); + this.$ = [$$[$0]]; + break; + case 32: + yy.getLogger().debug("Rule: dirList: ", $$[$0 - 1], $$[$0]); + this.$ = [$$[$0 - 1]].concat($$[$0]); + break; + case 33: + yy.getLogger().debug("Rule: nodeShapeNLabel: ", $$[$0 - 2], $$[$0 - 1], $$[$0]); + this.$ = { typeStr: $$[$0 - 2] + $$[$0], label: $$[$0 - 1] }; + break; + case 34: + yy.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", $$[$0 - 3], $$[$0 - 2], " #3:", $$[$0 - 1], $$[$0]); + this.$ = { typeStr: $$[$0 - 3] + $$[$0], label: $$[$0 - 2], directions: $$[$0 - 1] }; + break; + case 35: + case 36: + this.$ = { type: "classDef", id: $$[$0 - 1].trim(), css: $$[$0].trim() }; + break; + case 37: + this.$ = { type: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; + break; + case 38: + this.$ = { type: "applyStyles", id: $$[$0 - 1].trim(), stylesStr: $$[$0].trim() }; + break; + } + }, + table: [{ 9: 1, 10: [1, 2] }, { 1: [3] }, { 11: 3, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 8: [1, 20] }, o($V8, [2, 12], { 13: 4, 19: 5, 20: 6, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 11: 21, 21: $V0, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }), o($V9, [2, 16], { 14: 22, 15: $Va, 16: $Vb }), o($V9, [2, 17]), o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), o($V9, [2, 21]), o($V9, [2, 22]), o($Vc, [2, 25], { 27: [1, 25] }), o($V9, [2, 26]), { 19: 26, 26: 12, 32: $V4 }, { 11: 27, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 41: [1, 28], 43: [1, 29] }, { 45: [1, 30] }, { 48: [1, 31] }, o($Vd, [2, 29], { 33: 32, 36: [1, 33], 38: [1, 34] }), { 1: [2, 7] }, o($V8, [2, 13]), { 26: 35, 32: $V4 }, { 32: [2, 14] }, { 17: [1, 36] }, o($Vc, [2, 24]), { 11: 37, 13: 4, 14: 22, 15: $Va, 16: $Vb, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 30: [1, 38] }, { 42: [1, 39] }, { 42: [1, 40] }, { 46: [1, 41] }, { 49: [1, 42] }, o($Vd, [2, 30]), { 18: [1, 43] }, { 18: [1, 44] }, o($Vc, [2, 23]), { 18: [1, 45] }, { 30: [1, 46] }, o($V9, [2, 28]), o($V9, [2, 35]), o($V9, [2, 36]), o($V9, [2, 37]), o($V9, [2, 38]), { 37: [1, 47] }, { 34: 48, 35: $Ve }, { 15: [1, 50] }, o($V9, [2, 27]), o($Vd, [2, 33]), { 39: [1, 51] }, { 34: 52, 35: $Ve, 39: [2, 31] }, { 32: [2, 15] }, o($Vd, [2, 34]), { 39: [2, 32] }], + defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 10; + case 1: + yy.getLogger().debug("Found space-block"); + return 31; + case 2: + yy.getLogger().debug("Found nl-block"); + return 31; + case 3: + yy.getLogger().debug("Found space-block"); + return 29; + case 4: + yy.getLogger().debug(".", yy_.yytext); + break; + case 5: + yy.getLogger().debug("_", yy_.yytext); + break; + case 6: + return 5; + case 7: + yy_.yytext = -1; + return 28; + case 8: + yy_.yytext = yy_.yytext.replace(/columns\s+/, ""); + yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); + return 28; + case 9: + this.pushState("md_string"); + break; + case 10: + return "MD_STR"; + case 11: + this.popState(); + break; + case 12: + this.pushState("string"); + break; + case 13: + yy.getLogger().debug("LEX: POPPING STR:", yy_.yytext); + this.popState(); + break; + case 14: + yy.getLogger().debug("LEX: STR end:", yy_.yytext); + return "STR"; + case 15: + yy_.yytext = yy_.yytext.replace(/space\:/, ""); + yy.getLogger().debug("SPACE NUM (LEX)", yy_.yytext); + return 21; + case 16: + yy_.yytext = "1"; + yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); + return 21; + case 17: + return 43; + case 18: + return "LINKSTYLE"; + case 19: + return "INTERPOLATE"; + case 20: + this.pushState("CLASSDEF"); + return 40; + case 21: + this.popState(); + this.pushState("CLASSDEFID"); + return "DEFAULT_CLASSDEF_ID"; + case 22: + this.popState(); + this.pushState("CLASSDEFID"); + return 41; + case 23: + this.popState(); + return 42; + case 24: + this.pushState("CLASS"); + return 44; + case 25: + this.popState(); + this.pushState("CLASS_STYLE"); + return 45; + case 26: + this.popState(); + return 46; + case 27: + this.pushState("STYLE_STMNT"); + return 47; + case 28: + this.popState(); + this.pushState("STYLE_DEFINITION"); + return 48; + case 29: + this.popState(); + return 49; + case 30: + this.pushState("acc_title"); + return "acc_title"; + case 31: + this.popState(); + return "acc_title_value"; + case 32: + this.pushState("acc_descr"); + return "acc_descr"; + case 33: + this.popState(); + return "acc_descr_value"; + case 34: + this.pushState("acc_descr_multiline"); + break; + case 35: + this.popState(); + break; + case 36: + return "acc_descr_multiline_value"; + case 37: + return 30; + case 38: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 39: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 40: + this.popState(); + yy.getLogger().debug("Lex: ))"); + return "NODE_DEND"; + case 41: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 42: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 43: + this.popState(); + yy.getLogger().debug("Lex: (-"); + return "NODE_DEND"; + case 44: + this.popState(); + yy.getLogger().debug("Lex: -)"); + return "NODE_DEND"; + case 45: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 46: + this.popState(); + yy.getLogger().debug("Lex: ]]"); + return "NODE_DEND"; + case 47: + this.popState(); + yy.getLogger().debug("Lex: ("); + return "NODE_DEND"; + case 48: + this.popState(); + yy.getLogger().debug("Lex: ])"); + return "NODE_DEND"; + case 49: + this.popState(); + yy.getLogger().debug("Lex: /]"); + return "NODE_DEND"; + case 50: + this.popState(); + yy.getLogger().debug("Lex: /]"); + return "NODE_DEND"; + case 51: + this.popState(); + yy.getLogger().debug("Lex: )]"); + return "NODE_DEND"; + case 52: + this.popState(); + yy.getLogger().debug("Lex: )"); + return "NODE_DEND"; + case 53: + this.popState(); + yy.getLogger().debug("Lex: ]>"); + return "NODE_DEND"; + case 54: + this.popState(); + yy.getLogger().debug("Lex: ]"); + return "NODE_DEND"; + case 55: + yy.getLogger().debug("Lexa: -)"); + this.pushState("NODE"); + return 36; + case 56: + yy.getLogger().debug("Lexa: (-"); + this.pushState("NODE"); + return 36; + case 57: + yy.getLogger().debug("Lexa: ))"); + this.pushState("NODE"); + return 36; + case 58: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 59: + yy.getLogger().debug("Lex: ((("); + this.pushState("NODE"); + return 36; + case 60: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 61: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 62: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 63: + yy.getLogger().debug("Lexc: >"); + this.pushState("NODE"); + return 36; + case 64: + yy.getLogger().debug("Lexa: (["); + this.pushState("NODE"); + return 36; + case 65: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 66: + this.pushState("NODE"); + return 36; + case 67: + this.pushState("NODE"); + return 36; + case 68: + this.pushState("NODE"); + return 36; + case 69: + this.pushState("NODE"); + return 36; + case 70: + this.pushState("NODE"); + return 36; + case 71: + this.pushState("NODE"); + return 36; + case 72: + this.pushState("NODE"); + return 36; + case 73: + yy.getLogger().debug("Lexa: ["); + this.pushState("NODE"); + return 36; + case 74: + this.pushState("BLOCK_ARROW"); + yy.getLogger().debug("LEX ARR START"); + return 38; + case 75: + yy.getLogger().debug("Lex: NODE_ID", yy_.yytext); + return 32; + case 76: + yy.getLogger().debug("Lex: EOF", yy_.yytext); + return 8; + case 77: + this.pushState("md_string"); + break; + case 78: + this.pushState("md_string"); + break; + case 79: + return "NODE_DESCR"; + case 80: + this.popState(); + break; + case 81: + yy.getLogger().debug("Lex: Starting string"); + this.pushState("string"); + break; + case 82: + yy.getLogger().debug("LEX ARR: Starting string"); + this.pushState("string"); + break; + case 83: + yy.getLogger().debug("LEX: NODE_DESCR:", yy_.yytext); + return "NODE_DESCR"; + case 84: + yy.getLogger().debug("LEX POPPING"); + this.popState(); + break; + case 85: + yy.getLogger().debug("Lex: =>BAE"); + this.pushState("ARROW_DIR"); + break; + case 86: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (right): dir:", yy_.yytext); + return "DIR"; + case 87: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (left):", yy_.yytext); + return "DIR"; + case 88: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (x):", yy_.yytext); + return "DIR"; + case 89: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (y):", yy_.yytext); + return "DIR"; + case 90: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (up):", yy_.yytext); + return "DIR"; + case 91: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (down):", yy_.yytext); + return "DIR"; + case 92: + yy_.yytext = "]>"; + yy.getLogger().debug("Lex (ARROW_DIR end):", yy_.yytext); + this.popState(); + this.popState(); + return "BLOCK_ARROW_END"; + case 93: + yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); + return 15; + case 94: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 95: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 96: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 97: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 98: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 99: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 100: + this.pushState("md_string"); + break; + case 101: + yy.getLogger().debug("Lex: Starting string"); + this.pushState("string"); + return "LINK_LABEL"; + case 102: + this.popState(); + yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); + return 15; + case 103: + this.popState(); + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 104: + this.popState(); + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 105: + yy.getLogger().debug("Lex: COLON", yy_.yytext); + yy_.yytext = yy_.yytext.slice(1); + return 27; + } + }, + rules: [/^(?:block-beta\b)/, /^(?:block\s+)/, /^(?:block\n+)/, /^(?:block:)/, /^(?:[\s]+)/, /^(?:[\n]+)/, /^(?:((\u000D\u000A)|(\u000A)))/, /^(?:columns\s+auto\b)/, /^(?:columns\s+[\d]+)/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:space[:]\d+)/, /^(?:space\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\s+)/, /^(?:DEFAULT\s+)/, /^(?:\w+\s+)/, /^(?:[^\n]*)/, /^(?:class\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:style\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:end\b\s*)/, /^(?:\(\(\()/, /^(?:\)\)\))/, /^(?:[\)]\))/, /^(?:\}\})/, /^(?:\})/, /^(?:\(-)/, /^(?:-\))/, /^(?:\(\()/, /^(?:\]\])/, /^(?:\()/, /^(?:\]\))/, /^(?:\\\])/, /^(?:\/\])/, /^(?:\)\])/, /^(?:[\)])/, /^(?:\]>)/, /^(?:[\]])/, /^(?:-\))/, /^(?:\(-)/, /^(?:\)\))/, /^(?:\))/, /^(?:\(\(\()/, /^(?:\(\()/, /^(?:\{\{)/, /^(?:\{)/, /^(?:>)/, /^(?:\(\[)/, /^(?:\()/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\[\\)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:\[)/, /^(?:<\[)/, /^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/, /^(?:$)/, /^(?:["][`])/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:\]>\s*\()/, /^(?:,?\s*right\s*)/, /^(?:,?\s*left\s*)/, /^(?:,?\s*x\s*)/, /^(?:,?\s*y\s*)/, /^(?:,?\s*up\s*)/, /^(?:,?\s*down\s*)/, /^(?:\)\s*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*~~[\~]+\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:["][`])/, /^(?:["])/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?::\d+)/], + conditions: { "STYLE_DEFINITION": { "rules": [29], "inclusive": false }, "STYLE_STMNT": { "rules": [28], "inclusive": false }, "CLASSDEFID": { "rules": [23], "inclusive": false }, "CLASSDEF": { "rules": [21, 22], "inclusive": false }, "CLASS_STYLE": { "rules": [26], "inclusive": false }, "CLASS": { "rules": [25], "inclusive": false }, "LLABEL": { "rules": [100, 101, 102, 103, 104], "inclusive": false }, "ARROW_DIR": { "rules": [86, 87, 88, 89, 90, 91, 92], "inclusive": false }, "BLOCK_ARROW": { "rules": [77, 82, 85], "inclusive": false }, "NODE": { "rules": [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 78, 81], "inclusive": false }, "md_string": { "rules": [10, 11, 79, 80], "inclusive": false }, "space": { "rules": [], "inclusive": false }, "string": { "rules": [13, 14, 83, 84], "inclusive": false }, "acc_descr_multiline": { "rules": [35, 36], "inclusive": false }, "acc_descr": { "rules": [33], "inclusive": false }, "acc_title": { "rules": [31], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 24, 27, 30, 32, 34, 37, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 93, 94, 95, 96, 97, 98, 99, 105], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let blockDatabase = {}; +let edgeList = []; +let edgeCount = {}; +const COLOR_KEYWORD = "color"; +const FILL_KEYWORD = "fill"; +const BG_FILL = "bgFill"; +const STYLECLASS_SEP = ","; +const config = getConfig(); +let classes = {}; +const sanitizeText = (txt) => common$1.sanitizeText(txt, config); +const addStyleClass = function(id, styleAttributes = "") { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + const foundClass = classes[id]; + if (styleAttributes !== void 0 && styleAttributes !== null) { + styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { + const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); + if (attrib.match(COLOR_KEYWORD)) { + const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL); + const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD); + foundClass.textStyles.push(newStyle2); + } + foundClass.styles.push(fixedAttrib); + }); + } +}; +const addStyle2Node = function(id, styles = "") { + const foundBlock = blockDatabase[id]; + if (styles !== void 0 && styles !== null) { + foundBlock.styles = styles.split(STYLECLASS_SEP); + } +}; +const setCssClass = function(itemIds, cssClassName) { + itemIds.split(",").forEach(function(id) { + let foundBlock = blockDatabase[id]; + if (foundBlock === void 0) { + const trimmedId = id.trim(); + blockDatabase[trimmedId] = { id: trimmedId, type: "na", children: [] }; + foundBlock = blockDatabase[trimmedId]; + } + if (!foundBlock.classes) { + foundBlock.classes = []; + } + foundBlock.classes.push(cssClassName); + }); +}; +const populateBlockDatabase = (_blockList, parent) => { + const blockList = _blockList.flat(); + const children = []; + for (const block of blockList) { + if (block.label) { + block.label = sanitizeText(block.label); + } + if (block.type === "classDef") { + addStyleClass(block.id, block.css); + continue; + } + if (block.type === "applyClass") { + setCssClass(block.id, (block == null ? void 0 : block.styleClass) || ""); + continue; + } + if (block.type === "applyStyles") { + if (block == null ? void 0 : block.stylesStr) { + addStyle2Node(block.id, block == null ? void 0 : block.stylesStr); + } + continue; + } + if (block.type === "column-setting") { + parent.columns = block.columns || -1; + } else if (block.type === "edge") { + if (edgeCount[block.id]) { + edgeCount[block.id]++; + } else { + edgeCount[block.id] = 1; + } + block.id = edgeCount[block.id] + "-" + block.id; + edgeList.push(block); + } else { + if (!block.label) { + if (block.type === "composite") { + block.label = ""; + } else { + block.label = block.id; + } + } + const newBlock = !blockDatabase[block.id]; + if (newBlock) { + blockDatabase[block.id] = block; + } else { + if (block.type !== "na") { + blockDatabase[block.id].type = block.type; + } + if (block.label !== block.id) { + blockDatabase[block.id].label = block.label; + } + } + if (block.children) { + populateBlockDatabase(block.children, block); + } + if (block.type === "space") { + const w = block.width || 1; + for (let j = 0; j < w; j++) { + const newBlock2 = clone(block); + newBlock2.id = newBlock2.id + "-" + j; + blockDatabase[newBlock2.id] = newBlock2; + children.push(newBlock2); + } + } else if (newBlock) { + children.push(block); + } + } + } + parent.children = children; +}; +let blocks = []; +let rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; +const clear = () => { + log$1.debug("Clear called"); + clear$1(); + rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; + blockDatabase = { root: rootBlock }; + blocks = []; + classes = {}; + edgeList = []; + edgeCount = {}; +}; +function typeStr2Type(typeStr) { + log$1.debug("typeStr2Type", typeStr); + switch (typeStr) { + case "[]": + return "square"; + case "()": + log$1.debug("we have a round"); + return "round"; + case "(())": + return "circle"; + case ">]": + return "rect_left_inv_arrow"; + case "{}": + return "diamond"; + case "{{}}": + return "hexagon"; + case "([])": + return "stadium"; + case "[[]]": + return "subroutine"; + case "[()]": + return "cylinder"; + case "((()))": + return "doublecircle"; + case "[//]": + return "lean_right"; + case "[\\\\]": + return "lean_left"; + case "[/\\]": + return "trapezoid"; + case "[\\/]": + return "inv_trapezoid"; + case "<[]>": + return "block_arrow"; + default: + return "na"; + } +} +function edgeTypeStr2Type(typeStr) { + log$1.debug("typeStr2Type", typeStr); + switch (typeStr) { + case "==": + return "thick"; + default: + return "normal"; + } +} +function edgeStrToEdgeData(typeStr) { + switch (typeStr.trim()) { + case "--x": + return "arrow_cross"; + case "--o": + return "arrow_circle"; + default: + return "arrow_point"; + } +} +let cnt = 0; +const generateId = () => { + cnt++; + return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt; +}; +const setHierarchy = (block) => { + rootBlock.children = block; + populateBlockDatabase(block, rootBlock); + blocks = rootBlock.children; +}; +const getColumns = (blockId) => { + const block = blockDatabase[blockId]; + if (!block) { + return -1; + } + if (block.columns) { + return block.columns; + } + if (!block.children) { + return -1; + } + return block.children.length; +}; +const getBlocksFlat = () => { + return [...Object.values(blockDatabase)]; +}; +const getBlocks = () => { + return blocks || []; +}; +const getEdges = () => { + return edgeList; +}; +const getBlock = (id) => { + return blockDatabase[id]; +}; +const setBlock = (block) => { + blockDatabase[block.id] = block; +}; +const getLogger = () => console; +const getClasses$1 = function() { + return classes; +}; +const db = { + getConfig: () => getConfig$1().block, + typeStr2Type, + edgeTypeStr2Type, + edgeStrToEdgeData, + getLogger, + getBlocksFlat, + getBlocks, + getEdges, + setHierarchy, + getBlock, + setBlock, + getColumns, + getClasses: getClasses$1, + clear, + generateId +}; +const db$1 = db; +const fade = (color, opacity) => { + const channel$1 = channel; + const r = channel$1(color, "r"); + const g = channel$1(color, "g"); + const b = channel$1(color, "b"); + return rgba(r, g, b, opacity); +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span,p { + color: ${options.titleColor}; + } + + + + .label text,span,p { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + .flowchart-label text { + text-anchor: middle; + } + // .flowchart-label .text-outer-tspan { + // text-anchor: middle; + // } + // .flowchart-label .text-inner-tspan { + // text-anchor: start; + // } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + /* For html labels only */ + .labelBkg { + background-color: ${fade(options.edgeLabelBackground, 0.5)}; + // background-color: + } + + .node .cluster { + // fill: ${fade(options.mainBkg, 0.5)}; + fill: ${fade(options.clusterBkg, 0.5)}; + stroke: ${fade(options.clusterBorder, 0.2)}; + box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span,p { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } +`; +const flowStyles = getStyles; +function getNodeFromBlock(block, db2, positioned = false) { + var _a2, _b2, _c; + const vertex = block; + let classStr = "default"; + if ((((_a2 = vertex == null ? void 0 : vertex.classes) == null ? void 0 : _a2.length) || 0) > 0) { + classStr = ((vertex == null ? void 0 : vertex.classes) || []).join(" "); + } + classStr = classStr + " flowchart-label"; + let radius = 0; + let shape = ""; + let padding2; + switch (vertex.type) { + case "round": + radius = 5; + shape = "rect"; + break; + case "composite": + radius = 0; + shape = "composite"; + padding2 = 0; + break; + case "square": + shape = "rect"; + break; + case "diamond": + shape = "question"; + break; + case "hexagon": + shape = "hexagon"; + break; + case "block_arrow": + shape = "block_arrow"; + break; + case "odd": + shape = "rect_left_inv_arrow"; + break; + case "lean_right": + shape = "lean_right"; + break; + case "lean_left": + shape = "lean_left"; + break; + case "trapezoid": + shape = "trapezoid"; + break; + case "inv_trapezoid": + shape = "inv_trapezoid"; + break; + case "rect_left_inv_arrow": + shape = "rect_left_inv_arrow"; + break; + case "circle": + shape = "circle"; + break; + case "ellipse": + shape = "ellipse"; + break; + case "stadium": + shape = "stadium"; + break; + case "subroutine": + shape = "subroutine"; + break; + case "cylinder": + shape = "cylinder"; + break; + case "group": + shape = "rect"; + break; + case "doublecircle": + shape = "doublecircle"; + break; + default: + shape = "rect"; + } + const styles = getStylesFromArray((vertex == null ? void 0 : vertex.styles) || []); + const vertexText = vertex.label; + const bounds = vertex.size || { width: 0, height: 0, x: 0, y: 0 }; + const node = { + labelStyle: styles.labelStyle, + shape, + labelText: vertexText, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + directions: vertex.directions, + width: bounds.width, + height: bounds.height, + x: bounds.x, + y: bounds.y, + positioned, + intersect: void 0, + type: vertex.type, + padding: padding2 ?? (((_c = (_b2 = getConfig$1()) == null ? void 0 : _b2.block) == null ? void 0 : _c.padding) || 0) + }; + return node; +} +async function calculateBlockSize(elem, block, db2) { + const node = getNodeFromBlock(block, db2, false); + if (node.type === "group") { + return; + } + const nodeEl = await insertNode(elem, node); + const boundingBox = nodeEl.node().getBBox(); + const obj = db2.getBlock(node.id); + obj.size = { width: boundingBox.width, height: boundingBox.height, x: 0, y: 0, node: nodeEl }; + db2.setBlock(obj); + nodeEl.remove(); +} +async function insertBlockPositioned(elem, block, db2) { + const node = getNodeFromBlock(block, db2, true); + const obj = db2.getBlock(node.id); + if (obj.type !== "space") { + await insertNode(elem, node); + block.intersect = node == null ? void 0 : node.intersect; + positionNode(node); + } +} +async function performOperations(elem, blocks2, db2, operation) { + for (const block of blocks2) { + await operation(elem, block, db2); + if (block.children) { + await performOperations(elem, block.children, db2, operation); + } + } +} +async function calculateBlockSizes(elem, blocks2, db2) { + await performOperations(elem, blocks2, db2, calculateBlockSize); +} +async function insertBlocks(elem, blocks2, db2) { + await performOperations(elem, blocks2, db2, insertBlockPositioned); +} +async function insertEdges(elem, edges, blocks2, db2, id) { + const g = new Graph({ + multigraph: true, + compound: true + }); + g.setGraph({ + rankdir: "TB", + nodesep: 10, + ranksep: 10, + marginx: 8, + marginy: 8 + }); + for (const block of blocks2) { + if (block.size) { + g.setNode(block.id, { + width: block.size.width, + height: block.size.height, + intersect: block.intersect + }); + } + } + for (const edge of edges) { + if (edge.start && edge.end) { + const startBlock = db2.getBlock(edge.start); + const endBlock = db2.getBlock(edge.end); + if ((startBlock == null ? void 0 : startBlock.size) && (endBlock == null ? void 0 : endBlock.size)) { + const start = startBlock.size; + const end = endBlock.size; + const points = [ + { x: start.x, y: start.y }, + { x: start.x + (end.x - start.x) / 2, y: start.y + (end.y - start.y) / 2 }, + { x: end.x, y: end.y } + ]; + await insertEdge( + elem, + { v: edge.start, w: edge.end, name: edge.id }, + { + ...edge, + arrowTypeEnd: edge.arrowTypeEnd, + arrowTypeStart: edge.arrowTypeStart, + points, + classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" + }, + void 0, + "block", + g, + id + ); + if (edge.label) { + await insertEdgeLabel(elem, { + ...edge, + label: edge.label, + labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;", + arrowTypeEnd: edge.arrowTypeEnd, + arrowTypeStart: edge.arrowTypeStart, + points, + classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" + }); + await positionEdgeLabel( + { ...edge, x: points[1].x, y: points[1].y }, + { + originalPath: points + } + ); + } + } + } + } +} +const padding = ((_b = (_a = getConfig()) == null ? void 0 : _a.block) == null ? void 0 : _b.padding) || 8; +function calculateBlockPosition(columns, position) { + if (columns === 0 || !Number.isInteger(columns)) { + throw new Error("Columns must be an integer !== 0."); + } + if (position < 0 || !Number.isInteger(position)) { + throw new Error("Position must be a non-negative integer." + position); + } + if (columns < 0) { + return { px: position, py: 0 }; + } + if (columns === 1) { + return { px: 0, py: position }; + } + const px = position % columns; + const py = Math.floor(position / columns); + return { px, py }; +} +const getMaxChildSize = (block) => { + let maxWidth = 0; + let maxHeight = 0; + for (const child of block.children) { + const { width, height, x, y } = child.size || { width: 0, height: 0, x: 0, y: 0 }; + log$1.debug( + "getMaxChildSize abc95 child:", + child.id, + "width:", + width, + "height:", + height, + "x:", + x, + "y:", + y, + child.type + ); + if (child.type === "space") { + continue; + } + if (width > maxWidth) { + maxWidth = width / (block.widthInColumns || 1); + } + if (height > maxHeight) { + maxHeight = height; + } + } + return { width: maxWidth, height: maxHeight }; +}; +function setBlockSizes(block, db2, siblingWidth = 0, siblingHeight = 0) { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k; + log$1.debug( + "setBlockSizes abc95 (start)", + block.id, + (_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x, + "block width =", + block == null ? void 0 : block.size, + "sieblingWidth", + siblingWidth + ); + if (!((_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.width)) { + block.size = { + width: siblingWidth, + height: siblingHeight, + x: 0, + y: 0 + }; + } + let maxWidth = 0; + let maxHeight = 0; + if (((_c = block.children) == null ? void 0 : _c.length) > 0) { + for (const child of block.children) { + setBlockSizes(child, db2); + } + const childSize = getMaxChildSize(block); + maxWidth = childSize.width; + maxHeight = childSize.height; + log$1.debug("setBlockSizes abc95 maxWidth of", block.id, ":s children is ", maxWidth, maxHeight); + for (const child of block.children) { + if (child.size) { + log$1.debug( + `abc95 Setting size of children of ${block.id} id=${child.id} ${maxWidth} ${maxHeight} ${child.size}` + ); + child.size.width = maxWidth * (child.widthInColumns || 1) + padding * ((child.widthInColumns || 1) - 1); + child.size.height = maxHeight; + child.size.x = 0; + child.size.y = 0; + log$1.debug( + `abc95 updating size of ${block.id} children child:${child.id} maxWidth:${maxWidth} maxHeight:${maxHeight}` + ); + } + } + for (const child of block.children) { + setBlockSizes(child, db2, maxWidth, maxHeight); + } + const columns = block.columns || -1; + let numItems = 0; + for (const child of block.children) { + numItems += child.widthInColumns || 1; + } + let xSize = block.children.length; + if (columns > 0 && columns < numItems) { + xSize = columns; + } + block.widthInColumns || 1; + const ySize = Math.ceil(numItems / xSize); + let width = xSize * (maxWidth + padding) + padding; + let height = ySize * (maxHeight + padding) + padding; + if (width < siblingWidth) { + log$1.debug( + `Detected to small siebling: abc95 ${block.id} sieblingWidth ${siblingWidth} sieblingHeight ${siblingHeight} width ${width}` + ); + width = siblingWidth; + height = siblingHeight; + const childWidth = (siblingWidth - xSize * padding - padding) / xSize; + const childHeight = (siblingHeight - ySize * padding - padding) / ySize; + log$1.debug("Size indata abc88", block.id, "childWidth", childWidth, "maxWidth", maxWidth); + log$1.debug("Size indata abc88", block.id, "childHeight", childHeight, "maxHeight", maxHeight); + log$1.debug("Size indata abc88 xSize", xSize, "padding", padding); + for (const child of block.children) { + if (child.size) { + child.size.width = childWidth; + child.size.height = childHeight; + child.size.x = 0; + child.size.y = 0; + } + } + } + log$1.debug( + `abc95 (finale calc) ${block.id} xSize ${xSize} ySize ${ySize} columns ${columns}${block.children.length} width=${Math.max(width, ((_d = block.size) == null ? void 0 : _d.width) || 0)}` + ); + if (width < (((_e = block == null ? void 0 : block.size) == null ? void 0 : _e.width) || 0)) { + width = ((_f = block == null ? void 0 : block.size) == null ? void 0 : _f.width) || 0; + const num = columns > 0 ? Math.min(block.children.length, columns) : block.children.length; + if (num > 0) { + const childWidth = (width - num * padding - padding) / num; + log$1.debug("abc95 (growing to fit) width", block.id, width, (_g = block.size) == null ? void 0 : _g.width, childWidth); + for (const child of block.children) { + if (child.size) { + child.size.width = childWidth; + } + } + } + } + block.size = { + width, + height, + x: 0, + y: 0 + }; + } + log$1.debug( + "setBlockSizes abc94 (done)", + block.id, + (_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x, + (_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width, + (_j = block == null ? void 0 : block.size) == null ? void 0 : _j.y, + (_k = block == null ? void 0 : block.size) == null ? void 0 : _k.height + ); +} +function layoutBlocks(block, db2) { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q; + log$1.debug( + `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${(_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x} y: ${(_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.y} width: ${(_c = block == null ? void 0 : block.size) == null ? void 0 : _c.width}` + ); + const columns = block.columns || -1; + log$1.debug("layoutBlocks columns abc95", block.id, "=>", columns, block); + if (block.children && // find max width of children + block.children.length > 0) { + const width = ((_e = (_d = block == null ? void 0 : block.children[0]) == null ? void 0 : _d.size) == null ? void 0 : _e.width) || 0; + const widthOfChildren = block.children.length * width + (block.children.length - 1) * padding; + log$1.debug("widthOfChildren 88", widthOfChildren, "posX"); + let columnPos = 0; + log$1.debug("abc91 block?.size?.x", block.id, (_f = block == null ? void 0 : block.size) == null ? void 0 : _f.x); + let startingPosX = ((_g = block == null ? void 0 : block.size) == null ? void 0 : _g.x) ? ((_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x) + (-((_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width) / 2 || 0) : -padding; + let rowPos = 0; + for (const child of block.children) { + const parent = block; + if (!child.size) { + continue; + } + const { width: width2, height } = child.size; + const { px, py } = calculateBlockPosition(columns, columnPos); + if (py != rowPos) { + rowPos = py; + startingPosX = ((_j = block == null ? void 0 : block.size) == null ? void 0 : _j.x) ? ((_k = block == null ? void 0 : block.size) == null ? void 0 : _k.x) + (-((_l = block == null ? void 0 : block.size) == null ? void 0 : _l.width) / 2 || 0) : -padding; + log$1.debug("New row in layout for block", block.id, " and child ", child.id, rowPos); + } + log$1.debug( + `abc89 layout blocks (child) id: ${child.id} Pos: ${columnPos} (px, py) ${px},${py} (${(_m = parent == null ? void 0 : parent.size) == null ? void 0 : _m.x},${(_n = parent == null ? void 0 : parent.size) == null ? void 0 : _n.y}) parent: ${parent.id} width: ${width2}${padding}` + ); + if (parent.size) { + const halfWidth = width2 / 2; + child.size.x = startingPosX + padding + halfWidth; + log$1.debug( + `abc91 layout blocks (calc) px, pyid:${child.id} startingPos=X${startingPosX} new startingPosX${child.size.x} ${halfWidth} padding=${padding} width=${width2} halfWidth=${halfWidth} => x:${child.size.x} y:${child.size.y} ${child.widthInColumns} (width * (child?.w || 1)) / 2 ${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}` + ); + startingPosX = child.size.x + halfWidth; + child.size.y = parent.size.y - parent.size.height / 2 + py * (height + padding) + height / 2 + padding; + log$1.debug( + `abc88 layout blocks (calc) px, pyid:${child.id}startingPosX${startingPosX}${padding}${halfWidth}=>x:${child.size.x}y:${child.size.y}${child.widthInColumns}(width * (child?.w || 1)) / 2${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}` + ); + } + if (child.children) { + layoutBlocks(child); + } + columnPos += (child == null ? void 0 : child.widthInColumns) || 1; + log$1.debug("abc88 columnsPos", child, columnPos); + } + } + log$1.debug( + `layout blocks (<==layoutBlocks) ${block.id} x: ${(_o = block == null ? void 0 : block.size) == null ? void 0 : _o.x} y: ${(_p = block == null ? void 0 : block.size) == null ? void 0 : _p.y} width: ${(_q = block == null ? void 0 : block.size) == null ? void 0 : _q.width}` + ); +} +function findBounds(block, { minX, minY, maxX, maxY } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) { + if (block.size && block.id !== "root") { + const { x, y, width, height } = block.size; + if (x - width / 2 < minX) { + minX = x - width / 2; + } + if (y - height / 2 < minY) { + minY = y - height / 2; + } + if (x + width / 2 > maxX) { + maxX = x + width / 2; + } + if (y + height / 2 > maxY) { + maxY = y + height / 2; + } + } + if (block.children) { + for (const child of block.children) { + ({ minX, minY, maxX, maxY } = findBounds(child, { minX, minY, maxX, maxY })); + } + } + return { minX, minY, maxX, maxY }; +} +function layout(db2) { + const root = db2.getBlock("root"); + if (!root) { + return; + } + setBlockSizes(root, db2, 0, 0); + layoutBlocks(root); + log$1.debug("getBlocks", JSON.stringify(root, null, 2)); + const { minX, minY, maxX, maxY } = findBounds(root); + const height = maxY - minY; + const width = maxX - minX; + return { x: minX, y: minY, width, height }; +} +const getClasses = function(text, diagObj) { + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + const { securityLevel, block: conf } = getConfig$1(); + const db2 = diagObj.db; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const markers = ["point", "circle", "cross"]; + insertMarkers$1(svg, markers, diagObj.type, id); + const bl = db2.getBlocks(); + const blArr = db2.getBlocksFlat(); + const edges = db2.getEdges(); + const nodes = svg.insert("g").attr("class", "block"); + await calculateBlockSizes(nodes, bl, db2); + const bounds = layout(db2); + await insertBlocks(nodes, bl, db2); + await insertEdges(nodes, edges, blArr, db2, id); + if (bounds) { + const bounds2 = bounds; + const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height))); + const height = bounds2.height + magicFactor + 10; + const width = bounds2.width + 10; + const { useMaxWidth } = conf; + configureSvgSize(svg, height, width, !!useMaxWidth); + log$1.debug("Here Bounds", bounds, bounds2); + svg.attr( + "viewBox", + `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}` + ); + } + ordinal(schemeTableau10); +}; +const renderer = { + draw, + getClasses +}; +const diagram = { + parser: parser$1, + db: db$1, + renderer, + styles: flowStyles +}; + +export { diagram }; diff --git a/libs/marked/c4Diagram-ae766693-R1FJdUX5.js b/libs/marked/c4Diagram-ae766693-R1FJdUX5.js new file mode 100644 index 0000000..739da4c --- /dev/null +++ b/libs/marked/c4Diagram-ae766693-R1FJdUX5.js @@ -0,0 +1,2463 @@ +import { s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, c as getConfig, d as sanitizeText$2, e as assignWithDepth$1, f as calculateTextWidth, h as select, l as log$1, i as configureSvgSize, w as wrapLabel, j as common$1, k as calculateTextHeight, m as dist } from './index-CN3YjQ0n.js'; +import { d as drawRect$1, g as getNoteRect } from './svgDrawCommon-5e1cfd1d-BKN147IX.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 24], $V1 = [1, 25], $V2 = [1, 26], $V3 = [1, 27], $V4 = [1, 28], $V5 = [1, 63], $V6 = [1, 64], $V7 = [1, 65], $V8 = [1, 66], $V9 = [1, 67], $Va = [1, 68], $Vb = [1, 69], $Vc = [1, 29], $Vd = [1, 30], $Ve = [1, 31], $Vf = [1, 32], $Vg = [1, 33], $Vh = [1, 34], $Vi = [1, 35], $Vj = [1, 36], $Vk = [1, 37], $Vl = [1, 38], $Vm = [1, 39], $Vn = [1, 40], $Vo = [1, 41], $Vp = [1, 42], $Vq = [1, 43], $Vr = [1, 44], $Vs = [1, 45], $Vt = [1, 46], $Vu = [1, 47], $Vv = [1, 48], $Vw = [1, 50], $Vx = [1, 51], $Vy = [1, 52], $Vz = [1, 53], $VA = [1, 54], $VB = [1, 55], $VC = [1, 56], $VD = [1, 57], $VE = [1, 58], $VF = [1, 59], $VG = [1, 60], $VH = [14, 42], $VI = [14, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74], $VJ = [12, 14, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74], $VK = [1, 82], $VL = [1, 83], $VM = [1, 84], $VN = [1, 85], $VO = [12, 14, 42], $VP = [12, 14, 33, 42], $VQ = [12, 14, 33, 42, 76, 77, 79, 80], $VR = [12, 33], $VS = [34, 36, 37, 38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mermaidDoc": 4, "direction": 5, "direction_tb": 6, "direction_bt": 7, "direction_rl": 8, "direction_lr": 9, "graphConfig": 10, "C4_CONTEXT": 11, "NEWLINE": 12, "statements": 13, "EOF": 14, "C4_CONTAINER": 15, "C4_COMPONENT": 16, "C4_DYNAMIC": 17, "C4_DEPLOYMENT": 18, "otherStatements": 19, "diagramStatements": 20, "otherStatement": 21, "title": 22, "accDescription": 23, "acc_title": 24, "acc_title_value": 25, "acc_descr": 26, "acc_descr_value": 27, "acc_descr_multiline_value": 28, "boundaryStatement": 29, "boundaryStartStatement": 30, "boundaryStopStatement": 31, "boundaryStart": 32, "LBRACE": 33, "ENTERPRISE_BOUNDARY": 34, "attributes": 35, "SYSTEM_BOUNDARY": 36, "BOUNDARY": 37, "CONTAINER_BOUNDARY": 38, "NODE": 39, "NODE_L": 40, "NODE_R": 41, "RBRACE": 42, "diagramStatement": 43, "PERSON": 44, "PERSON_EXT": 45, "SYSTEM": 46, "SYSTEM_DB": 47, "SYSTEM_QUEUE": 48, "SYSTEM_EXT": 49, "SYSTEM_EXT_DB": 50, "SYSTEM_EXT_QUEUE": 51, "CONTAINER": 52, "CONTAINER_DB": 53, "CONTAINER_QUEUE": 54, "CONTAINER_EXT": 55, "CONTAINER_EXT_DB": 56, "CONTAINER_EXT_QUEUE": 57, "COMPONENT": 58, "COMPONENT_DB": 59, "COMPONENT_QUEUE": 60, "COMPONENT_EXT": 61, "COMPONENT_EXT_DB": 62, "COMPONENT_EXT_QUEUE": 63, "REL": 64, "BIREL": 65, "REL_U": 66, "REL_D": 67, "REL_L": 68, "REL_R": 69, "REL_B": 70, "REL_INDEX": 71, "UPDATE_EL_STYLE": 72, "UPDATE_REL_STYLE": 73, "UPDATE_LAYOUT_CONFIG": 74, "attribute": 75, "STR": 76, "STR_KEY": 77, "STR_VALUE": 78, "ATTRIBUTE": 79, "ATTRIBUTE_EMPTY": 80, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 6: "direction_tb", 7: "direction_bt", 8: "direction_rl", 9: "direction_lr", 11: "C4_CONTEXT", 12: "NEWLINE", 14: "EOF", 15: "C4_CONTAINER", 16: "C4_COMPONENT", 17: "C4_DYNAMIC", 18: "C4_DEPLOYMENT", 22: "title", 23: "accDescription", 24: "acc_title", 25: "acc_title_value", 26: "acc_descr", 27: "acc_descr_value", 28: "acc_descr_multiline_value", 33: "LBRACE", 34: "ENTERPRISE_BOUNDARY", 36: "SYSTEM_BOUNDARY", 37: "BOUNDARY", 38: "CONTAINER_BOUNDARY", 39: "NODE", 40: "NODE_L", 41: "NODE_R", 42: "RBRACE", 44: "PERSON", 45: "PERSON_EXT", 46: "SYSTEM", 47: "SYSTEM_DB", 48: "SYSTEM_QUEUE", 49: "SYSTEM_EXT", 50: "SYSTEM_EXT_DB", 51: "SYSTEM_EXT_QUEUE", 52: "CONTAINER", 53: "CONTAINER_DB", 54: "CONTAINER_QUEUE", 55: "CONTAINER_EXT", 56: "CONTAINER_EXT_DB", 57: "CONTAINER_EXT_QUEUE", 58: "COMPONENT", 59: "COMPONENT_DB", 60: "COMPONENT_QUEUE", 61: "COMPONENT_EXT", 62: "COMPONENT_EXT_DB", 63: "COMPONENT_EXT_QUEUE", 64: "REL", 65: "BIREL", 66: "REL_U", 67: "REL_D", 68: "REL_L", 69: "REL_R", 70: "REL_B", 71: "REL_INDEX", 72: "UPDATE_EL_STYLE", 73: "UPDATE_REL_STYLE", 74: "UPDATE_LAYOUT_CONFIG", 76: "STR", 77: "STR_KEY", 78: "STR_VALUE", 79: "ATTRIBUTE", 80: "ATTRIBUTE_EMPTY" }, + productions_: [0, [3, 1], [3, 1], [5, 1], [5, 1], [5, 1], [5, 1], [4, 1], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [13, 1], [13, 1], [13, 2], [19, 1], [19, 2], [19, 3], [21, 1], [21, 1], [21, 2], [21, 2], [21, 1], [29, 3], [30, 3], [30, 3], [30, 4], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [31, 1], [20, 1], [20, 2], [20, 3], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 1], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [35, 1], [35, 2], [75, 1], [75, 2], [75, 1], [75, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setDirection("TB"); + break; + case 4: + yy.setDirection("BT"); + break; + case 5: + yy.setDirection("RL"); + break; + case 6: + yy.setDirection("LR"); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + yy.setC4Type($$[$0 - 3]); + break; + case 19: + yy.setTitle($$[$0].substring(6)); + this.$ = $$[$0].substring(6); + break; + case 20: + yy.setAccDescription($$[$0].substring(15)); + this.$ = $$[$0].substring(15); + break; + case 21: + this.$ = $$[$0].trim(); + yy.setTitle(this.$); + break; + case 22: + case 23: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 28: + case 29: + $$[$0].splice(2, 0, "ENTERPRISE"); + yy.addPersonOrSystemBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 30: + yy.addPersonOrSystemBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 31: + $$[$0].splice(2, 0, "CONTAINER"); + yy.addContainerBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 32: + yy.addDeploymentNode("node", ...$$[$0]); + this.$ = $$[$0]; + break; + case 33: + yy.addDeploymentNode("nodeL", ...$$[$0]); + this.$ = $$[$0]; + break; + case 34: + yy.addDeploymentNode("nodeR", ...$$[$0]); + this.$ = $$[$0]; + break; + case 35: + yy.popBoundaryParseStack(); + break; + case 39: + yy.addPersonOrSystem("person", ...$$[$0]); + this.$ = $$[$0]; + break; + case 40: + yy.addPersonOrSystem("external_person", ...$$[$0]); + this.$ = $$[$0]; + break; + case 41: + yy.addPersonOrSystem("system", ...$$[$0]); + this.$ = $$[$0]; + break; + case 42: + yy.addPersonOrSystem("system_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 43: + yy.addPersonOrSystem("system_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 44: + yy.addPersonOrSystem("external_system", ...$$[$0]); + this.$ = $$[$0]; + break; + case 45: + yy.addPersonOrSystem("external_system_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 46: + yy.addPersonOrSystem("external_system_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 47: + yy.addContainer("container", ...$$[$0]); + this.$ = $$[$0]; + break; + case 48: + yy.addContainer("container_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 49: + yy.addContainer("container_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 50: + yy.addContainer("external_container", ...$$[$0]); + this.$ = $$[$0]; + break; + case 51: + yy.addContainer("external_container_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 52: + yy.addContainer("external_container_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 53: + yy.addComponent("component", ...$$[$0]); + this.$ = $$[$0]; + break; + case 54: + yy.addComponent("component_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 55: + yy.addComponent("component_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 56: + yy.addComponent("external_component", ...$$[$0]); + this.$ = $$[$0]; + break; + case 57: + yy.addComponent("external_component_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 58: + yy.addComponent("external_component_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 60: + yy.addRel("rel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 61: + yy.addRel("birel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 62: + yy.addRel("rel_u", ...$$[$0]); + this.$ = $$[$0]; + break; + case 63: + yy.addRel("rel_d", ...$$[$0]); + this.$ = $$[$0]; + break; + case 64: + yy.addRel("rel_l", ...$$[$0]); + this.$ = $$[$0]; + break; + case 65: + yy.addRel("rel_r", ...$$[$0]); + this.$ = $$[$0]; + break; + case 66: + yy.addRel("rel_b", ...$$[$0]); + this.$ = $$[$0]; + break; + case 67: + $$[$0].splice(0, 1); + yy.addRel("rel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 68: + yy.updateElStyle("update_el_style", ...$$[$0]); + this.$ = $$[$0]; + break; + case 69: + yy.updateRelStyle("update_rel_style", ...$$[$0]); + this.$ = $$[$0]; + break; + case 70: + yy.updateLayoutConfig("update_layout_config", ...$$[$0]); + this.$ = $$[$0]; + break; + case 71: + this.$ = [$$[$0]]; + break; + case 72: + $$[$0].unshift($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 73: + case 75: + this.$ = $$[$0].trim(); + break; + case 74: + let kv = {}; + kv[$$[$0 - 1].trim()] = $$[$0].trim(); + this.$ = kv; + break; + case 76: + this.$ = ""; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 7: [1, 6], 8: [1, 7], 9: [1, 8], 10: 4, 11: [1, 9], 15: [1, 10], 16: [1, 11], 17: [1, 12], 18: [1, 13] }, { 1: [3] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 7] }, { 1: [2, 3] }, { 1: [2, 4] }, { 1: [2, 5] }, { 1: [2, 6] }, { 12: [1, 14] }, { 12: [1, 15] }, { 12: [1, 16] }, { 12: [1, 17] }, { 12: [1, 18] }, { 13: 19, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 70, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 71, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 72, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 73, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 14: [1, 74] }, o($VH, [2, 13], { 43: 23, 29: 49, 30: 61, 32: 62, 20: 75, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }), o($VH, [2, 14]), o($VI, [2, 16], { 12: [1, 76] }), o($VH, [2, 36], { 12: [1, 77] }), o($VJ, [2, 19]), o($VJ, [2, 20]), { 25: [1, 78] }, { 27: [1, 79] }, o($VJ, [2, 23]), { 35: 80, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 86, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 87, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 88, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 89, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 90, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 91, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 92, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 93, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 94, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 95, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 96, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 97, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 98, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 99, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 100, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 101, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 102, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 103, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 104, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, o($VO, [2, 59]), { 35: 105, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 106, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 107, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 108, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 109, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 110, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 111, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 112, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 113, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 114, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 115, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 20: 116, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 12: [1, 118], 33: [1, 117] }, { 35: 119, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 120, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 121, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 122, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 123, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 124, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 125, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 14: [1, 126] }, { 14: [1, 127] }, { 14: [1, 128] }, { 14: [1, 129] }, { 1: [2, 8] }, o($VH, [2, 15]), o($VI, [2, 17], { 21: 22, 19: 130, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4 }), o($VH, [2, 37], { 19: 20, 20: 21, 21: 22, 43: 23, 29: 49, 30: 61, 32: 62, 13: 131, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }), o($VJ, [2, 21]), o($VJ, [2, 22]), o($VO, [2, 39]), o($VP, [2, 71], { 75: 81, 35: 132, 76: $VK, 77: $VL, 79: $VM, 80: $VN }), o($VQ, [2, 73]), { 78: [1, 133] }, o($VQ, [2, 75]), o($VQ, [2, 76]), o($VO, [2, 40]), o($VO, [2, 41]), o($VO, [2, 42]), o($VO, [2, 43]), o($VO, [2, 44]), o($VO, [2, 45]), o($VO, [2, 46]), o($VO, [2, 47]), o($VO, [2, 48]), o($VO, [2, 49]), o($VO, [2, 50]), o($VO, [2, 51]), o($VO, [2, 52]), o($VO, [2, 53]), o($VO, [2, 54]), o($VO, [2, 55]), o($VO, [2, 56]), o($VO, [2, 57]), o($VO, [2, 58]), o($VO, [2, 60]), o($VO, [2, 61]), o($VO, [2, 62]), o($VO, [2, 63]), o($VO, [2, 64]), o($VO, [2, 65]), o($VO, [2, 66]), o($VO, [2, 67]), o($VO, [2, 68]), o($VO, [2, 69]), o($VO, [2, 70]), { 31: 134, 42: [1, 135] }, { 12: [1, 136] }, { 33: [1, 137] }, o($VR, [2, 28]), o($VR, [2, 29]), o($VR, [2, 30]), o($VR, [2, 31]), o($VR, [2, 32]), o($VR, [2, 33]), o($VR, [2, 34]), { 1: [2, 9] }, { 1: [2, 10] }, { 1: [2, 11] }, { 1: [2, 12] }, o($VI, [2, 18]), o($VH, [2, 38]), o($VP, [2, 72]), o($VQ, [2, 74]), o($VO, [2, 24]), o($VO, [2, 35]), o($VS, [2, 25]), o($VS, [2, 26], { 12: [1, 138] }), o($VS, [2, 27])], + defaultActions: { 2: [2, 1], 3: [2, 2], 4: [2, 7], 5: [2, 3], 6: [2, 4], 7: [2, 5], 8: [2, 6], 74: [2, 8], 126: [2, 9], 127: [2, 10], 128: [2, 11], 129: [2, 12] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c2 = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c2 + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 6; + case 1: + return 7; + case 2: + return 8; + case 3: + return 9; + case 4: + return 22; + case 5: + return 23; + case 6: + this.begin("acc_title"); + return 24; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 26; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + break; + case 14: + c; + break; + case 15: + return 12; + case 16: + break; + case 17: + return 11; + case 18: + return 15; + case 19: + return 16; + case 20: + return 17; + case 21: + return 18; + case 22: + this.begin("person_ext"); + return 45; + case 23: + this.begin("person"); + return 44; + case 24: + this.begin("system_ext_queue"); + return 51; + case 25: + this.begin("system_ext_db"); + return 50; + case 26: + this.begin("system_ext"); + return 49; + case 27: + this.begin("system_queue"); + return 48; + case 28: + this.begin("system_db"); + return 47; + case 29: + this.begin("system"); + return 46; + case 30: + this.begin("boundary"); + return 37; + case 31: + this.begin("enterprise_boundary"); + return 34; + case 32: + this.begin("system_boundary"); + return 36; + case 33: + this.begin("container_ext_queue"); + return 57; + case 34: + this.begin("container_ext_db"); + return 56; + case 35: + this.begin("container_ext"); + return 55; + case 36: + this.begin("container_queue"); + return 54; + case 37: + this.begin("container_db"); + return 53; + case 38: + this.begin("container"); + return 52; + case 39: + this.begin("container_boundary"); + return 38; + case 40: + this.begin("component_ext_queue"); + return 63; + case 41: + this.begin("component_ext_db"); + return 62; + case 42: + this.begin("component_ext"); + return 61; + case 43: + this.begin("component_queue"); + return 60; + case 44: + this.begin("component_db"); + return 59; + case 45: + this.begin("component"); + return 58; + case 46: + this.begin("node"); + return 39; + case 47: + this.begin("node"); + return 39; + case 48: + this.begin("node_l"); + return 40; + case 49: + this.begin("node_r"); + return 41; + case 50: + this.begin("rel"); + return 64; + case 51: + this.begin("birel"); + return 65; + case 52: + this.begin("rel_u"); + return 66; + case 53: + this.begin("rel_u"); + return 66; + case 54: + this.begin("rel_d"); + return 67; + case 55: + this.begin("rel_d"); + return 67; + case 56: + this.begin("rel_l"); + return 68; + case 57: + this.begin("rel_l"); + return 68; + case 58: + this.begin("rel_r"); + return 69; + case 59: + this.begin("rel_r"); + return 69; + case 60: + this.begin("rel_b"); + return 70; + case 61: + this.begin("rel_index"); + return 71; + case 62: + this.begin("update_el_style"); + return 72; + case 63: + this.begin("update_rel_style"); + return 73; + case 64: + this.begin("update_layout_config"); + return 74; + case 65: + return "EOF_IN_STRUCT"; + case 66: + this.begin("attribute"); + return "ATTRIBUTE_EMPTY"; + case 67: + this.begin("attribute"); + break; + case 68: + this.popState(); + this.popState(); + break; + case 69: + return 80; + case 70: + break; + case 71: + return 80; + case 72: + this.begin("string"); + break; + case 73: + this.popState(); + break; + case 74: + return "STR"; + case 75: + this.begin("string_kv"); + break; + case 76: + this.begin("string_kv_key"); + return "STR_KEY"; + case 77: + this.popState(); + this.begin("string_kv_value"); + break; + case 78: + return "STR_VALUE"; + case 79: + this.popState(); + this.popState(); + break; + case 80: + return "STR"; + case 81: + return "LBRACE"; + case 82: + return "RBRACE"; + case 83: + return "SPACE"; + case 84: + return "EOL"; + case 85: + return 14; + } + }, + rules: [/^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:title\s[^#\n;]+)/, /^(?:accDescription\s[^#\n;]+)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/, /^(?:%%[^\n]*(\r?\n)*)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:C4Context\b)/, /^(?:C4Container\b)/, /^(?:C4Component\b)/, /^(?:C4Dynamic\b)/, /^(?:C4Deployment\b)/, /^(?:Person_Ext\b)/, /^(?:Person\b)/, /^(?:SystemQueue_Ext\b)/, /^(?:SystemDb_Ext\b)/, /^(?:System_Ext\b)/, /^(?:SystemQueue\b)/, /^(?:SystemDb\b)/, /^(?:System\b)/, /^(?:Boundary\b)/, /^(?:Enterprise_Boundary\b)/, /^(?:System_Boundary\b)/, /^(?:ContainerQueue_Ext\b)/, /^(?:ContainerDb_Ext\b)/, /^(?:Container_Ext\b)/, /^(?:ContainerQueue\b)/, /^(?:ContainerDb\b)/, /^(?:Container\b)/, /^(?:Container_Boundary\b)/, /^(?:ComponentQueue_Ext\b)/, /^(?:ComponentDb_Ext\b)/, /^(?:Component_Ext\b)/, /^(?:ComponentQueue\b)/, /^(?:ComponentDb\b)/, /^(?:Component\b)/, /^(?:Deployment_Node\b)/, /^(?:Node\b)/, /^(?:Node_L\b)/, /^(?:Node_R\b)/, /^(?:Rel\b)/, /^(?:BiRel\b)/, /^(?:Rel_Up\b)/, /^(?:Rel_U\b)/, /^(?:Rel_Down\b)/, /^(?:Rel_D\b)/, /^(?:Rel_Left\b)/, /^(?:Rel_L\b)/, /^(?:Rel_Right\b)/, /^(?:Rel_R\b)/, /^(?:Rel_Back\b)/, /^(?:RelIndex\b)/, /^(?:UpdateElementStyle\b)/, /^(?:UpdateRelStyle\b)/, /^(?:UpdateLayoutConfig\b)/, /^(?:$)/, /^(?:[(][ ]*[,])/, /^(?:[(])/, /^(?:[)])/, /^(?:,,)/, /^(?:,)/, /^(?:[ ]*["]["])/, /^(?:[ ]*["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:[ ]*[\$])/, /^(?:[^=]*)/, /^(?:[=][ ]*["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:[^,]+)/, /^(?:\{)/, /^(?:\})/, /^(?:[\s]+)/, /^(?:[\n\r]+)/, /^(?:$)/], + conditions: { "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "string_kv_value": { "rules": [78, 79], "inclusive": false }, "string_kv_key": { "rules": [77], "inclusive": false }, "string_kv": { "rules": [76], "inclusive": false }, "string": { "rules": [73, 74], "inclusive": false }, "attribute": { "rules": [68, 69, 70, 71, 72, 75, 80], "inclusive": false }, "update_layout_config": { "rules": [65, 66, 67, 68], "inclusive": false }, "update_rel_style": { "rules": [65, 66, 67, 68], "inclusive": false }, "update_el_style": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_b": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_r": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_l": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_d": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_u": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_bi": { "rules": [], "inclusive": false }, "rel": { "rules": [65, 66, 67, 68], "inclusive": false }, "node_r": { "rules": [65, 66, 67, 68], "inclusive": false }, "node_l": { "rules": [65, 66, 67, 68], "inclusive": false }, "node": { "rules": [65, 66, 67, 68], "inclusive": false }, "index": { "rules": [], "inclusive": false }, "rel_index": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_ext_queue": { "rules": [], "inclusive": false }, "component_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "component": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "container": { "rules": [65, 66, 67, 68], "inclusive": false }, "birel": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "enterprise_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "system": { "rules": [65, 66, 67, 68], "inclusive": false }, "person_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "person": { "rules": [65, 66, 67, 68], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 81, 82, 83, 84, 85], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let c4ShapeArray = []; +let boundaryParseStack = [""]; +let currentBoundaryParse = "global"; +let parentBoundaryParse = ""; +let boundaries = [ + { + alias: "global", + label: { text: "global" }, + type: { text: "global" }, + tags: null, + link: null, + parentBoundary: "" + } +]; +let rels = []; +let title = ""; +let wrapEnabled = false; +let c4ShapeInRow$1 = 4; +let c4BoundaryInRow$1 = 2; +var c4Type; +const getC4Type = function() { + return c4Type; +}; +const setC4Type = function(c4TypeParam) { + let sanitizedText = sanitizeText$2(c4TypeParam, getConfig()); + c4Type = sanitizedText; +}; +const addRel = function(type, from, to, label, techn, descr, sprite, tags, link) { + if (type === void 0 || type === null || from === void 0 || from === null || to === void 0 || to === null || label === void 0 || label === null) { + return; + } + let rel = {}; + const old = rels.find((rel2) => rel2.from === from && rel2.to === to); + if (old) { + rel = old; + } else { + rels.push(rel); + } + rel.type = type; + rel.from = from; + rel.to = to; + rel.label = { text: label }; + if (techn === void 0 || techn === null) { + rel.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + rel[key] = { text: value }; + } else { + rel.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + rel.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + rel[key] = { text: value }; + } else { + rel.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + rel[key] = value; + } else { + rel.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + rel[key] = value; + } else { + rel.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + rel[key] = value; + } else { + rel.link = link; + } + rel.wrap = autoWrap(); +}; +const addPersonOrSystem = function(typeC4Shape, alias, label, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let personOrSystem = {}; + const old = c4ShapeArray.find((personOrSystem2) => personOrSystem2.alias === alias); + if (old && alias === old.alias) { + personOrSystem = old; + } else { + personOrSystem.alias = alias; + c4ShapeArray.push(personOrSystem); + } + if (label === void 0 || label === null) { + personOrSystem.label = { text: "" }; + } else { + personOrSystem.label = { text: label }; + } + if (descr === void 0 || descr === null) { + personOrSystem.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + personOrSystem[key] = { text: value }; + } else { + personOrSystem.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.link = link; + } + personOrSystem.typeC4Shape = { text: typeC4Shape }; + personOrSystem.parentBoundary = currentBoundaryParse; + personOrSystem.wrap = autoWrap(); +}; +const addContainer = function(typeC4Shape, alias, label, techn, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let container = {}; + const old = c4ShapeArray.find((container2) => container2.alias === alias); + if (old && alias === old.alias) { + container = old; + } else { + container.alias = alias; + c4ShapeArray.push(container); + } + if (label === void 0 || label === null) { + container.label = { text: "" }; + } else { + container.label = { text: label }; + } + if (techn === void 0 || techn === null) { + container.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + container[key] = { text: value }; + } else { + container.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + container.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + container[key] = { text: value }; + } else { + container.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + container[key] = value; + } else { + container.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + container[key] = value; + } else { + container.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + container[key] = value; + } else { + container.link = link; + } + container.wrap = autoWrap(); + container.typeC4Shape = { text: typeC4Shape }; + container.parentBoundary = currentBoundaryParse; +}; +const addComponent = function(typeC4Shape, alias, label, techn, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let component = {}; + const old = c4ShapeArray.find((component2) => component2.alias === alias); + if (old && alias === old.alias) { + component = old; + } else { + component.alias = alias; + c4ShapeArray.push(component); + } + if (label === void 0 || label === null) { + component.label = { text: "" }; + } else { + component.label = { text: label }; + } + if (techn === void 0 || techn === null) { + component.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + component[key] = { text: value }; + } else { + component.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + component.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + component[key] = { text: value }; + } else { + component.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + component[key] = value; + } else { + component.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + component[key] = value; + } else { + component.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + component[key] = value; + } else { + component.link = link; + } + component.wrap = autoWrap(); + component.typeC4Shape = { text: typeC4Shape }; + component.parentBoundary = currentBoundaryParse; +}; +const addPersonOrSystemBoundary = function(alias, label, type, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "system" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const addContainerBoundary = function(alias, label, type, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "container" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const addDeploymentNode = function(nodeType, alias, label, type, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "node" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (descr === void 0 || descr === null) { + boundary.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + boundary[key] = { text: value }; + } else { + boundary.descr = { text: descr }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.nodeType = nodeType; + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const popBoundaryParseStack = function() { + currentBoundaryParse = parentBoundaryParse; + boundaryParseStack.pop(); + parentBoundaryParse = boundaryParseStack.pop(); + boundaryParseStack.push(parentBoundaryParse); +}; +const updateElStyle = function(typeC4Shape, elementName, bgColor, fontColor, borderColor, shadowing, shape, sprite, techn, legendText, legendSprite) { + let old = c4ShapeArray.find((element) => element.alias === elementName); + if (old === void 0) { + old = boundaries.find((element) => element.alias === elementName); + if (old === void 0) { + return; + } + } + if (bgColor !== void 0 && bgColor !== null) { + if (typeof bgColor === "object") { + let [key, value] = Object.entries(bgColor)[0]; + old[key] = value; + } else { + old.bgColor = bgColor; + } + } + if (fontColor !== void 0 && fontColor !== null) { + if (typeof fontColor === "object") { + let [key, value] = Object.entries(fontColor)[0]; + old[key] = value; + } else { + old.fontColor = fontColor; + } + } + if (borderColor !== void 0 && borderColor !== null) { + if (typeof borderColor === "object") { + let [key, value] = Object.entries(borderColor)[0]; + old[key] = value; + } else { + old.borderColor = borderColor; + } + } + if (shadowing !== void 0 && shadowing !== null) { + if (typeof shadowing === "object") { + let [key, value] = Object.entries(shadowing)[0]; + old[key] = value; + } else { + old.shadowing = shadowing; + } + } + if (shape !== void 0 && shape !== null) { + if (typeof shape === "object") { + let [key, value] = Object.entries(shape)[0]; + old[key] = value; + } else { + old.shape = shape; + } + } + if (sprite !== void 0 && sprite !== null) { + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + old[key] = value; + } else { + old.sprite = sprite; + } + } + if (techn !== void 0 && techn !== null) { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + old[key] = value; + } else { + old.techn = techn; + } + } + if (legendText !== void 0 && legendText !== null) { + if (typeof legendText === "object") { + let [key, value] = Object.entries(legendText)[0]; + old[key] = value; + } else { + old.legendText = legendText; + } + } + if (legendSprite !== void 0 && legendSprite !== null) { + if (typeof legendSprite === "object") { + let [key, value] = Object.entries(legendSprite)[0]; + old[key] = value; + } else { + old.legendSprite = legendSprite; + } + } +}; +const updateRelStyle = function(typeC4Shape, from, to, textColor, lineColor, offsetX, offsetY) { + const old = rels.find((rel) => rel.from === from && rel.to === to); + if (old === void 0) { + return; + } + if (textColor !== void 0 && textColor !== null) { + if (typeof textColor === "object") { + let [key, value] = Object.entries(textColor)[0]; + old[key] = value; + } else { + old.textColor = textColor; + } + } + if (lineColor !== void 0 && lineColor !== null) { + if (typeof lineColor === "object") { + let [key, value] = Object.entries(lineColor)[0]; + old[key] = value; + } else { + old.lineColor = lineColor; + } + } + if (offsetX !== void 0 && offsetX !== null) { + if (typeof offsetX === "object") { + let [key, value] = Object.entries(offsetX)[0]; + old[key] = parseInt(value); + } else { + old.offsetX = parseInt(offsetX); + } + } + if (offsetY !== void 0 && offsetY !== null) { + if (typeof offsetY === "object") { + let [key, value] = Object.entries(offsetY)[0]; + old[key] = parseInt(value); + } else { + old.offsetY = parseInt(offsetY); + } + } +}; +const updateLayoutConfig = function(typeC4Shape, c4ShapeInRowParam, c4BoundaryInRowParam) { + let c4ShapeInRowValue = c4ShapeInRow$1; + let c4BoundaryInRowValue = c4BoundaryInRow$1; + if (typeof c4ShapeInRowParam === "object") { + const value = Object.values(c4ShapeInRowParam)[0]; + c4ShapeInRowValue = parseInt(value); + } else { + c4ShapeInRowValue = parseInt(c4ShapeInRowParam); + } + if (typeof c4BoundaryInRowParam === "object") { + const value = Object.values(c4BoundaryInRowParam)[0]; + c4BoundaryInRowValue = parseInt(value); + } else { + c4BoundaryInRowValue = parseInt(c4BoundaryInRowParam); + } + if (c4ShapeInRowValue >= 1) { + c4ShapeInRow$1 = c4ShapeInRowValue; + } + if (c4BoundaryInRowValue >= 1) { + c4BoundaryInRow$1 = c4BoundaryInRowValue; + } +}; +const getC4ShapeInRow = function() { + return c4ShapeInRow$1; +}; +const getC4BoundaryInRow = function() { + return c4BoundaryInRow$1; +}; +const getCurrentBoundaryParse = function() { + return currentBoundaryParse; +}; +const getParentBoundaryParse = function() { + return parentBoundaryParse; +}; +const getC4ShapeArray = function(parentBoundary) { + if (parentBoundary === void 0 || parentBoundary === null) { + return c4ShapeArray; + } else { + return c4ShapeArray.filter((personOrSystem) => { + return personOrSystem.parentBoundary === parentBoundary; + }); + } +}; +const getC4Shape = function(alias) { + return c4ShapeArray.find((personOrSystem) => personOrSystem.alias === alias); +}; +const getC4ShapeKeys = function(parentBoundary) { + return Object.keys(getC4ShapeArray(parentBoundary)); +}; +const getBoundaries = function(parentBoundary) { + if (parentBoundary === void 0 || parentBoundary === null) { + return boundaries; + } else { + return boundaries.filter((boundary) => boundary.parentBoundary === parentBoundary); + } +}; +const getBoundarys = getBoundaries; +const getRels = function() { + return rels; +}; +const getTitle = function() { + return title; +}; +const setWrap = function(wrapSetting) { + wrapEnabled = wrapSetting; +}; +const autoWrap = function() { + return wrapEnabled; +}; +const clear = function() { + c4ShapeArray = []; + boundaries = [ + { + alias: "global", + label: { text: "global" }, + type: { text: "global" }, + tags: null, + link: null, + parentBoundary: "" + } + ]; + parentBoundaryParse = ""; + currentBoundaryParse = "global"; + boundaryParseStack = [""]; + rels = []; + boundaryParseStack = [""]; + title = ""; + wrapEnabled = false; + c4ShapeInRow$1 = 4; + c4BoundaryInRow$1 = 2; +}; +const LINETYPE = { + SOLID: 0, + DOTTED: 1, + NOTE: 2, + SOLID_CROSS: 3, + DOTTED_CROSS: 4, + SOLID_OPEN: 5, + DOTTED_OPEN: 6, + LOOP_START: 10, + LOOP_END: 11, + ALT_START: 12, + ALT_ELSE: 13, + ALT_END: 14, + OPT_START: 15, + OPT_END: 16, + ACTIVE_START: 17, + ACTIVE_END: 18, + PAR_START: 19, + PAR_AND: 20, + PAR_END: 21, + RECT_START: 22, + RECT_END: 23, + SOLID_POINT: 24, + DOTTED_POINT: 25 +}; +const ARROWTYPE = { + FILLED: 0, + OPEN: 1 +}; +const PLACEMENT = { + LEFTOF: 0, + RIGHTOF: 1, + OVER: 2 +}; +const setTitle = function(txt) { + let sanitizedText = sanitizeText$2(txt, getConfig()); + title = sanitizedText; +}; +const db = { + addPersonOrSystem, + addPersonOrSystemBoundary, + addContainer, + addContainerBoundary, + addComponent, + addDeploymentNode, + popBoundaryParseStack, + addRel, + updateElStyle, + updateRelStyle, + updateLayoutConfig, + autoWrap, + setWrap, + getC4ShapeArray, + getC4Shape, + getC4ShapeKeys, + getBoundaries, + getBoundarys, + getCurrentBoundaryParse, + getParentBoundaryParse, + getRels, + getTitle, + getC4Type, + getC4ShapeInRow, + getC4BoundaryInRow, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + getConfig: () => getConfig().c4, + clear, + LINETYPE, + ARROWTYPE, + PLACEMENT, + setTitle, + setC4Type + // apply, +}; +const drawRect = function(elem, rectData) { + return drawRect$1(elem, rectData); +}; +const drawImage = function(elem, width, height, x, y, link) { + const imageElem = elem.append("image"); + imageElem.attr("width", width); + imageElem.attr("height", height); + imageElem.attr("x", x); + imageElem.attr("y", y); + let sanitizedLink = link.startsWith("data:image/png;base64") ? link : dist.sanitizeUrl(link); + imageElem.attr("xlink:href", sanitizedLink); +}; +const drawRels$1 = (elem, rels2, conf2) => { + const relsElem = elem.append("g"); + let i = 0; + for (let rel of rels2) { + let textColor = rel.textColor ? rel.textColor : "#444444"; + let strokeColor = rel.lineColor ? rel.lineColor : "#444444"; + let offsetX = rel.offsetX ? parseInt(rel.offsetX) : 0; + let offsetY = rel.offsetY ? parseInt(rel.offsetY) : 0; + let url = ""; + if (i === 0) { + let line = relsElem.append("line"); + line.attr("x1", rel.startPoint.x); + line.attr("y1", rel.startPoint.y); + line.attr("x2", rel.endPoint.x); + line.attr("y2", rel.endPoint.y); + line.attr("stroke-width", "1"); + line.attr("stroke", strokeColor); + line.style("fill", "none"); + if (rel.type !== "rel_b") { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (rel.type === "birel" || rel.type === "rel_b") { + line.attr("marker-start", "url(" + url + "#arrowend)"); + } + i = -1; + } else { + let line = relsElem.append("path"); + line.attr("fill", "none").attr("stroke-width", "1").attr("stroke", strokeColor).attr( + "d", + "Mstartx,starty Qcontrolx,controly stopx,stopy ".replaceAll("startx", rel.startPoint.x).replaceAll("starty", rel.startPoint.y).replaceAll( + "controlx", + rel.startPoint.x + (rel.endPoint.x - rel.startPoint.x) / 2 - (rel.endPoint.x - rel.startPoint.x) / 4 + ).replaceAll("controly", rel.startPoint.y + (rel.endPoint.y - rel.startPoint.y) / 2).replaceAll("stopx", rel.endPoint.x).replaceAll("stopy", rel.endPoint.y) + ); + if (rel.type !== "rel_b") { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (rel.type === "birel" || rel.type === "rel_b") { + line.attr("marker-start", "url(" + url + "#arrowend)"); + } + } + let messageConf = conf2.messageFont(); + _drawTextCandidateFunc(conf2)( + rel.label.text, + relsElem, + Math.min(rel.startPoint.x, rel.endPoint.x) + Math.abs(rel.endPoint.x - rel.startPoint.x) / 2 + offsetX, + Math.min(rel.startPoint.y, rel.endPoint.y) + Math.abs(rel.endPoint.y - rel.startPoint.y) / 2 + offsetY, + rel.label.width, + rel.label.height, + { fill: textColor }, + messageConf + ); + if (rel.techn && rel.techn.text !== "") { + messageConf = conf2.messageFont(); + _drawTextCandidateFunc(conf2)( + "[" + rel.techn.text + "]", + relsElem, + Math.min(rel.startPoint.x, rel.endPoint.x) + Math.abs(rel.endPoint.x - rel.startPoint.x) / 2 + offsetX, + Math.min(rel.startPoint.y, rel.endPoint.y) + Math.abs(rel.endPoint.y - rel.startPoint.y) / 2 + conf2.messageFontSize + 5 + offsetY, + Math.max(rel.label.width, rel.techn.width), + rel.techn.height, + { fill: textColor, "font-style": "italic" }, + messageConf + ); + } + } +}; +const drawBoundary$1 = function(elem, boundary, conf2) { + const boundaryElem = elem.append("g"); + let fillColor = boundary.bgColor ? boundary.bgColor : "none"; + let strokeColor = boundary.borderColor ? boundary.borderColor : "#444444"; + let fontColor = boundary.fontColor ? boundary.fontColor : "black"; + let attrsValue = { "stroke-width": 1, "stroke-dasharray": "7.0,7.0" }; + if (boundary.nodeType) { + attrsValue = { "stroke-width": 1 }; + } + let rectData = { + x: boundary.x, + y: boundary.y, + fill: fillColor, + stroke: strokeColor, + width: boundary.width, + height: boundary.height, + rx: 2.5, + ry: 2.5, + attrs: attrsValue + }; + drawRect(boundaryElem, rectData); + let boundaryConf = conf2.boundaryFont(); + boundaryConf.fontWeight = "bold"; + boundaryConf.fontSize = boundaryConf.fontSize + 2; + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + boundary.label.text, + boundaryElem, + boundary.x, + boundary.y + boundary.label.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + if (boundary.type && boundary.type.text !== "") { + boundaryConf = conf2.boundaryFont(); + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + boundary.type.text, + boundaryElem, + boundary.x, + boundary.y + boundary.type.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + } + if (boundary.descr && boundary.descr.text !== "") { + boundaryConf = conf2.boundaryFont(); + boundaryConf.fontSize = boundaryConf.fontSize - 2; + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + boundary.descr.text, + boundaryElem, + boundary.x, + boundary.y + boundary.descr.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + } +}; +const drawC4Shape = function(elem, c4Shape, conf2) { + var _a; + let fillColor = c4Shape.bgColor ? c4Shape.bgColor : conf2[c4Shape.typeC4Shape.text + "_bg_color"]; + let strokeColor = c4Shape.borderColor ? c4Shape.borderColor : conf2[c4Shape.typeC4Shape.text + "_border_color"]; + let fontColor = c4Shape.fontColor ? c4Shape.fontColor : "#FFFFFF"; + let personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII="; + switch (c4Shape.typeC4Shape.text) { + case "person": + personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII="; + break; + case "external_person": + personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAB6ElEQVR4Xu2YLY+EMBCG9+dWr0aj0Wg0Go1Go0+j8Xdv2uTCvv1gpt0ebHKPuhDaeW4605Z9mJvx4AdXUyTUdd08z+u6flmWZRnHsWkafk9DptAwDPu+f0eAYtu2PEaGWuj5fCIZrBAC2eLBAnRCsEkkxmeaJp7iDJ2QMDdHsLg8SxKFEJaAo8lAXnmuOFIhTMpxxKATebo4UiFknuNo4OniSIXQyRxEA3YsnjGCVEjVXD7yLUAqxBGUyPv/Y4W2beMgGuS7kVQIBycH0fD+oi5pezQETxdHKmQKGk1eQEYldK+jw5GxPfZ9z7Mk0Qnhf1W1m3w//EUn5BDmSZsbR44QQLBEqrBHqOrmSKaQAxdnLArCrxZcM7A7ZKs4ioRq8LFC+NpC3WCBJsvpVw5edm9iEXFuyNfxXAgSwfrFQ1c0iNda8AdejvUgnktOtJQQxmcfFzGglc5WVCj7oDgFqU18boeFSs52CUh8LE8BIVQDT1ABrB0HtgSEYlX5doJnCwv9TXocKCaKbnwhdDKPq4lf3SwU3HLq4V/+WYhHVMa/3b4IlfyikAduCkcBc7mQ3/z/Qq/cTuikhkzB12Ae/mcJC9U+Vo8Ej1gWAtgbeGgFsAMHr50BIWOLCbezvhpBFUdY6EJuJ/QDW0XoMX60zZ0AAAAASUVORK5CYII="; + break; + } + const c4ShapeElem = elem.append("g"); + c4ShapeElem.attr("class", "person-man"); + const rect = getNoteRect(); + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + case "system": + case "external_system": + case "container": + case "external_container": + case "component": + case "external_component": + rect.x = c4Shape.x; + rect.y = c4Shape.y; + rect.fill = fillColor; + rect.width = c4Shape.width; + rect.height = c4Shape.height; + rect.stroke = strokeColor; + rect.rx = 2.5; + rect.ry = 2.5; + rect.attrs = { "stroke-width": 0.5 }; + drawRect(c4ShapeElem, rect); + break; + case "system_db": + case "external_system_db": + case "container_db": + case "external_container_db": + case "component_db": + case "external_component_db": + c4ShapeElem.append("path").attr("fill", fillColor).attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc0,-10 half,-10 half,-10c0,0 half,0 half,10l0,heightc0,10 -half,10 -half,10c0,0 -half,0 -half,-10l0,-height".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.width / 2).replaceAll("height", c4Shape.height) + ); + c4ShapeElem.append("path").attr("fill", "none").attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc0,10 half,10 half,10c0,0 half,0 half,-10".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.width / 2) + ); + break; + case "system_queue": + case "external_system_queue": + case "container_queue": + case "external_container_queue": + case "component_queue": + case "external_component_queue": + c4ShapeElem.append("path").attr("fill", fillColor).attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startylwidth,0c5,0 5,half 5,halfc0,0 0,half -5,halfl-width,0c-5,0 -5,-half -5,-halfc0,0 0,-half 5,-half".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("width", c4Shape.width).replaceAll("half", c4Shape.height / 2) + ); + c4ShapeElem.append("path").attr("fill", "none").attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc-5,0 -5,half -5,halfc0,half 5,half 5,half".replaceAll("startx", c4Shape.x + c4Shape.width).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.height / 2) + ); + break; + } + let c4ShapeFontConf = getC4ShapeFont(conf2, c4Shape.typeC4Shape.text); + c4ShapeElem.append("text").attr("fill", fontColor).attr("font-family", c4ShapeFontConf.fontFamily).attr("font-size", c4ShapeFontConf.fontSize - 2).attr("font-style", "italic").attr("lengthAdjust", "spacing").attr("textLength", c4Shape.typeC4Shape.width).attr("x", c4Shape.x + c4Shape.width / 2 - c4Shape.typeC4Shape.width / 2).attr("y", c4Shape.y + c4Shape.typeC4Shape.Y).text("<<" + c4Shape.typeC4Shape.text + ">>"); + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + drawImage( + c4ShapeElem, + 48, + 48, + c4Shape.x + c4Shape.width / 2 - 24, + c4Shape.y + c4Shape.image.Y, + personImg + ); + break; + } + let textFontConf = conf2[c4Shape.typeC4Shape.text + "Font"](); + textFontConf.fontWeight = "bold"; + textFontConf.fontSize = textFontConf.fontSize + 2; + textFontConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + c4Shape.label.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.label.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor }, + textFontConf + ); + textFontConf = conf2[c4Shape.typeC4Shape.text + "Font"](); + textFontConf.fontColor = fontColor; + if (c4Shape.techn && ((_a = c4Shape.techn) == null ? void 0 : _a.text) !== "") { + _drawTextCandidateFunc(conf2)( + c4Shape.techn.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.techn.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor, "font-style": "italic" }, + textFontConf + ); + } else if (c4Shape.type && c4Shape.type.text !== "") { + _drawTextCandidateFunc(conf2)( + c4Shape.type.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.type.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor, "font-style": "italic" }, + textFontConf + ); + } + if (c4Shape.descr && c4Shape.descr.text !== "") { + textFontConf = conf2.personFont(); + textFontConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + c4Shape.descr.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.descr.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor }, + textFontConf + ); + } + return c4Shape.height; +}; +const insertDatabaseIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z" + ); +}; +const insertComputerIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z" + ); +}; +const insertClockIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z" + ); +}; +const insertArrowHead = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +}; +const insertArrowEnd = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowend").attr("refX", 1).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z"); +}; +const insertArrowFilledHead = function(elem) { + elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 18).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const insertDynamicNumber = function(elem) { + elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6); +}; +const insertArrowCrossHead = function(elem) { + const defs = elem.append("defs"); + const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 16).attr("refY", 4); + marker.append("path").attr("fill", "black").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1px").attr("d", "M 9,2 V 6 L16,4 Z"); + marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1px").attr("d", "M 0,1 L 6,7 M 6,1 L 0,7"); +}; +const getC4ShapeFont = (cnf, typeC4Shape) => { + return { + fontFamily: cnf[typeC4Shape + "FontFamily"], + fontSize: cnf[typeC4Shape + "FontSize"], + fontWeight: cnf[typeC4Shape + "FontWeight"] + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { fontSize, fontFamily, fontWeight } = conf2; + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * fontSize - fontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").attr("dominant-baseline", "middle").style("font-size", fontSize).style("font-weight", fontWeight).style("font-family", fontFamily); + text.append("tspan").attr("dy", dy).text(lines[i]).attr("alignment-baseline", "mathematical"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const svgDraw = { + drawRect, + drawBoundary: drawBoundary$1, + drawC4Shape, + drawRels: drawRels$1, + drawImage, + insertArrowHead, + insertArrowEnd, + insertArrowFilledHead, + insertDynamicNumber, + insertArrowCrossHead, + insertDatabaseIcon, + insertComputerIcon, + insertClockIcon +}; +let globalBoundaryMaxX = 0, globalBoundaryMaxY = 0; +let c4ShapeInRow = 4; +let c4BoundaryInRow = 2; +parser.yy = db; +let conf = {}; +class Bounds { + constructor(diagObj) { + this.name = ""; + this.data = {}; + this.data.startx = void 0; + this.data.stopx = void 0; + this.data.starty = void 0; + this.data.stopy = void 0; + this.data.widthLimit = void 0; + this.nextData = {}; + this.nextData.startx = void 0; + this.nextData.stopx = void 0; + this.nextData.starty = void 0; + this.nextData.stopy = void 0; + this.nextData.cnt = 0; + setConf(diagObj.db.getConfig()); + } + setData(startx, stopx, starty, stopy) { + this.nextData.startx = this.data.startx = startx; + this.nextData.stopx = this.data.stopx = stopx; + this.nextData.starty = this.data.starty = starty; + this.nextData.stopy = this.data.stopy = stopy; + } + updateVal(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + } + insert(c4Shape) { + this.nextData.cnt = this.nextData.cnt + 1; + let _startx = this.nextData.startx === this.nextData.stopx ? this.nextData.stopx + c4Shape.margin : this.nextData.stopx + c4Shape.margin * 2; + let _stopx = _startx + c4Shape.width; + let _starty = this.nextData.starty + c4Shape.margin * 2; + let _stopy = _starty + c4Shape.height; + if (_startx >= this.data.widthLimit || _stopx >= this.data.widthLimit || this.nextData.cnt > c4ShapeInRow) { + _startx = this.nextData.startx + c4Shape.margin + conf.nextLinePaddingX; + _starty = this.nextData.stopy + c4Shape.margin * 2; + this.nextData.stopx = _stopx = _startx + c4Shape.width; + this.nextData.starty = this.nextData.stopy; + this.nextData.stopy = _stopy = _starty + c4Shape.height; + this.nextData.cnt = 1; + } + c4Shape.x = _startx; + c4Shape.y = _starty; + this.updateVal(this.data, "startx", _startx, Math.min); + this.updateVal(this.data, "starty", _starty, Math.min); + this.updateVal(this.data, "stopx", _stopx, Math.max); + this.updateVal(this.data, "stopy", _stopy, Math.max); + this.updateVal(this.nextData, "startx", _startx, Math.min); + this.updateVal(this.nextData, "starty", _starty, Math.min); + this.updateVal(this.nextData, "stopx", _stopx, Math.max); + this.updateVal(this.nextData, "stopy", _stopy, Math.max); + } + init(diagObj) { + this.name = ""; + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0, + widthLimit: void 0 + }; + this.nextData = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0, + cnt: 0 + }; + setConf(diagObj.db.getConfig()); + } + bumpLastMargin(margin) { + this.data.stopx += margin; + this.data.stopy += margin; + } +} +const setConf = function(cnf) { + assignWithDepth$1(conf, cnf); + if (cnf.fontFamily) { + conf.personFontFamily = conf.systemFontFamily = conf.messageFontFamily = cnf.fontFamily; + } + if (cnf.fontSize) { + conf.personFontSize = conf.systemFontSize = conf.messageFontSize = cnf.fontSize; + } + if (cnf.fontWeight) { + conf.personFontWeight = conf.systemFontWeight = conf.messageFontWeight = cnf.fontWeight; + } +}; +const c4ShapeFont = (cnf, typeC4Shape) => { + return { + fontFamily: cnf[typeC4Shape + "FontFamily"], + fontSize: cnf[typeC4Shape + "FontSize"], + fontWeight: cnf[typeC4Shape + "FontWeight"] + }; +}; +const boundaryFont = (cnf) => { + return { + fontFamily: cnf.boundaryFontFamily, + fontSize: cnf.boundaryFontSize, + fontWeight: cnf.boundaryFontWeight + }; +}; +const messageFont = (cnf) => { + return { + fontFamily: cnf.messageFontFamily, + fontSize: cnf.messageFontSize, + fontWeight: cnf.messageFontWeight + }; +}; +function calcC4ShapeTextWH(textType, c4Shape, c4ShapeTextWrap, textConf, textLimitWidth) { + if (!c4Shape[textType].width) { + if (c4ShapeTextWrap) { + c4Shape[textType].text = wrapLabel(c4Shape[textType].text, textLimitWidth, textConf); + c4Shape[textType].textLines = c4Shape[textType].text.split(common$1.lineBreakRegex).length; + c4Shape[textType].width = textLimitWidth; + c4Shape[textType].height = calculateTextHeight(c4Shape[textType].text, textConf); + } else { + let lines = c4Shape[textType].text.split(common$1.lineBreakRegex); + c4Shape[textType].textLines = lines.length; + let lineHeight = 0; + c4Shape[textType].height = 0; + c4Shape[textType].width = 0; + for (const line of lines) { + c4Shape[textType].width = Math.max( + calculateTextWidth(line, textConf), + c4Shape[textType].width + ); + lineHeight = calculateTextHeight(line, textConf); + c4Shape[textType].height = c4Shape[textType].height + lineHeight; + } + } + } +} +const drawBoundary = function(diagram2, boundary, bounds) { + boundary.x = bounds.data.startx; + boundary.y = bounds.data.starty; + boundary.width = bounds.data.stopx - bounds.data.startx; + boundary.height = bounds.data.stopy - bounds.data.starty; + boundary.label.y = conf.c4ShapeMargin - 35; + let boundaryTextWrap = boundary.wrap && conf.wrap; + let boundaryLabelConf = boundaryFont(conf); + boundaryLabelConf.fontSize = boundaryLabelConf.fontSize + 2; + boundaryLabelConf.fontWeight = "bold"; + let textLimitWidth = calculateTextWidth(boundary.label.text, boundaryLabelConf); + calcC4ShapeTextWH("label", boundary, boundaryTextWrap, boundaryLabelConf, textLimitWidth); + svgDraw.drawBoundary(diagram2, boundary, conf); +}; +const drawC4ShapeArray = function(currentBounds, diagram2, c4ShapeArray2, c4ShapeKeys) { + let Y = 0; + for (const c4ShapeKey of c4ShapeKeys) { + Y = 0; + const c4Shape = c4ShapeArray2[c4ShapeKey]; + let c4ShapeTypeConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + c4ShapeTypeConf.fontSize = c4ShapeTypeConf.fontSize - 2; + c4Shape.typeC4Shape.width = calculateTextWidth( + "«" + c4Shape.typeC4Shape.text + "»", + c4ShapeTypeConf + ); + c4Shape.typeC4Shape.height = c4ShapeTypeConf.fontSize + 2; + c4Shape.typeC4Shape.Y = conf.c4ShapePadding; + Y = c4Shape.typeC4Shape.Y + c4Shape.typeC4Shape.height - 4; + c4Shape.image = { width: 0, height: 0, Y: 0 }; + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + c4Shape.image.width = 48; + c4Shape.image.height = 48; + c4Shape.image.Y = Y; + Y = c4Shape.image.Y + c4Shape.image.height; + break; + } + if (c4Shape.sprite) { + c4Shape.image.width = 48; + c4Shape.image.height = 48; + c4Shape.image.Y = Y; + Y = c4Shape.image.Y + c4Shape.image.height; + } + let c4ShapeTextWrap = c4Shape.wrap && conf.wrap; + let textLimitWidth = conf.width - conf.c4ShapePadding * 2; + let c4ShapeLabelConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + c4ShapeLabelConf.fontSize = c4ShapeLabelConf.fontSize + 2; + c4ShapeLabelConf.fontWeight = "bold"; + calcC4ShapeTextWH("label", c4Shape, c4ShapeTextWrap, c4ShapeLabelConf, textLimitWidth); + c4Shape["label"].Y = Y + 8; + Y = c4Shape["label"].Y + c4Shape["label"].height; + if (c4Shape.type && c4Shape.type.text !== "") { + c4Shape.type.text = "[" + c4Shape.type.text + "]"; + let c4ShapeTypeConf2 = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + calcC4ShapeTextWH("type", c4Shape, c4ShapeTextWrap, c4ShapeTypeConf2, textLimitWidth); + c4Shape["type"].Y = Y + 5; + Y = c4Shape["type"].Y + c4Shape["type"].height; + } else if (c4Shape.techn && c4Shape.techn.text !== "") { + c4Shape.techn.text = "[" + c4Shape.techn.text + "]"; + let c4ShapeTechnConf = c4ShapeFont(conf, c4Shape.techn.text); + calcC4ShapeTextWH("techn", c4Shape, c4ShapeTextWrap, c4ShapeTechnConf, textLimitWidth); + c4Shape["techn"].Y = Y + 5; + Y = c4Shape["techn"].Y + c4Shape["techn"].height; + } + let rectHeight = Y; + let rectWidth = c4Shape.label.width; + if (c4Shape.descr && c4Shape.descr.text !== "") { + let c4ShapeDescrConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + calcC4ShapeTextWH("descr", c4Shape, c4ShapeTextWrap, c4ShapeDescrConf, textLimitWidth); + c4Shape["descr"].Y = Y + 20; + Y = c4Shape["descr"].Y + c4Shape["descr"].height; + rectWidth = Math.max(c4Shape.label.width, c4Shape.descr.width); + rectHeight = Y - c4Shape["descr"].textLines * 5; + } + rectWidth = rectWidth + conf.c4ShapePadding; + c4Shape.width = Math.max(c4Shape.width || conf.width, rectWidth, conf.width); + c4Shape.height = Math.max(c4Shape.height || conf.height, rectHeight, conf.height); + c4Shape.margin = c4Shape.margin || conf.c4ShapeMargin; + currentBounds.insert(c4Shape); + svgDraw.drawC4Shape(diagram2, c4Shape, conf); + } + currentBounds.bumpLastMargin(conf.c4ShapeMargin); +}; +class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } +} +let getIntersectPoint = function(fromNode, endPoint) { + let x1 = fromNode.x; + let y1 = fromNode.y; + let x2 = endPoint.x; + let y2 = endPoint.y; + let fromCenterX = x1 + fromNode.width / 2; + let fromCenterY = y1 + fromNode.height / 2; + let dx = Math.abs(x1 - x2); + let dy = Math.abs(y1 - y2); + let tanDYX = dy / dx; + let fromDYX = fromNode.height / fromNode.width; + let returnPoint = null; + if (y1 == y2 && x1 < x2) { + returnPoint = new Point(x1 + fromNode.width, fromCenterY); + } else if (y1 == y2 && x1 > x2) { + returnPoint = new Point(x1, fromCenterY); + } else if (x1 == x2 && y1 < y2) { + returnPoint = new Point(fromCenterX, y1 + fromNode.height); + } else if (x1 == x2 && y1 > y2) { + returnPoint = new Point(fromCenterX, y1); + } + if (x1 > x2 && y1 < y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1, fromCenterY + tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point( + fromCenterX - dx / dy * fromNode.height / 2, + y1 + fromNode.height + ); + } + } else if (x1 < x2 && y1 < y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1 + fromNode.width, fromCenterY + tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point( + fromCenterX + dx / dy * fromNode.height / 2, + y1 + fromNode.height + ); + } + } else if (x1 < x2 && y1 > y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1 + fromNode.width, fromCenterY - tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point(fromCenterX + fromNode.height / 2 * dx / dy, y1); + } + } else if (x1 > x2 && y1 > y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1, fromCenterY - fromNode.width / 2 * tanDYX); + } else { + returnPoint = new Point(fromCenterX - fromNode.height / 2 * dx / dy, y1); + } + } + return returnPoint; +}; +let getIntersectPoints = function(fromNode, endNode) { + let endIntersectPoint = { x: 0, y: 0 }; + endIntersectPoint.x = endNode.x + endNode.width / 2; + endIntersectPoint.y = endNode.y + endNode.height / 2; + let startPoint = getIntersectPoint(fromNode, endIntersectPoint); + endIntersectPoint.x = fromNode.x + fromNode.width / 2; + endIntersectPoint.y = fromNode.y + fromNode.height / 2; + let endPoint = getIntersectPoint(endNode, endIntersectPoint); + return { startPoint, endPoint }; +}; +const drawRels = function(diagram2, rels2, getC4ShapeObj, diagObj) { + let i = 0; + for (let rel of rels2) { + i = i + 1; + let relTextWrap = rel.wrap && conf.wrap; + let relConf = messageFont(conf); + let diagramType = diagObj.db.getC4Type(); + if (diagramType === "C4Dynamic") { + rel.label.text = i + ": " + rel.label.text; + } + let textLimitWidth = calculateTextWidth(rel.label.text, relConf); + calcC4ShapeTextWH("label", rel, relTextWrap, relConf, textLimitWidth); + if (rel.techn && rel.techn.text !== "") { + textLimitWidth = calculateTextWidth(rel.techn.text, relConf); + calcC4ShapeTextWH("techn", rel, relTextWrap, relConf, textLimitWidth); + } + if (rel.descr && rel.descr.text !== "") { + textLimitWidth = calculateTextWidth(rel.descr.text, relConf); + calcC4ShapeTextWH("descr", rel, relTextWrap, relConf, textLimitWidth); + } + let fromNode = getC4ShapeObj(rel.from); + let endNode = getC4ShapeObj(rel.to); + let points = getIntersectPoints(fromNode, endNode); + rel.startPoint = points.startPoint; + rel.endPoint = points.endPoint; + } + svgDraw.drawRels(diagram2, rels2, conf); +}; +function drawInsideBoundary(diagram2, parentBoundaryAlias, parentBounds, currentBoundaries, diagObj) { + let currentBounds = new Bounds(diagObj); + currentBounds.data.widthLimit = parentBounds.data.widthLimit / Math.min(c4BoundaryInRow, currentBoundaries.length); + for (let [i, currentBoundary] of currentBoundaries.entries()) { + let Y = 0; + currentBoundary.image = { width: 0, height: 0, Y: 0 }; + if (currentBoundary.sprite) { + currentBoundary.image.width = 48; + currentBoundary.image.height = 48; + currentBoundary.image.Y = Y; + Y = currentBoundary.image.Y + currentBoundary.image.height; + } + let currentBoundaryTextWrap = currentBoundary.wrap && conf.wrap; + let currentBoundaryLabelConf = boundaryFont(conf); + currentBoundaryLabelConf.fontSize = currentBoundaryLabelConf.fontSize + 2; + currentBoundaryLabelConf.fontWeight = "bold"; + calcC4ShapeTextWH( + "label", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryLabelConf, + currentBounds.data.widthLimit + ); + currentBoundary["label"].Y = Y + 8; + Y = currentBoundary["label"].Y + currentBoundary["label"].height; + if (currentBoundary.type && currentBoundary.type.text !== "") { + currentBoundary.type.text = "[" + currentBoundary.type.text + "]"; + let currentBoundaryTypeConf = boundaryFont(conf); + calcC4ShapeTextWH( + "type", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryTypeConf, + currentBounds.data.widthLimit + ); + currentBoundary["type"].Y = Y + 5; + Y = currentBoundary["type"].Y + currentBoundary["type"].height; + } + if (currentBoundary.descr && currentBoundary.descr.text !== "") { + let currentBoundaryDescrConf = boundaryFont(conf); + currentBoundaryDescrConf.fontSize = currentBoundaryDescrConf.fontSize - 2; + calcC4ShapeTextWH( + "descr", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryDescrConf, + currentBounds.data.widthLimit + ); + currentBoundary["descr"].Y = Y + 20; + Y = currentBoundary["descr"].Y + currentBoundary["descr"].height; + } + if (i == 0 || i % c4BoundaryInRow === 0) { + let _x = parentBounds.data.startx + conf.diagramMarginX; + let _y = parentBounds.data.stopy + conf.diagramMarginY + Y; + currentBounds.setData(_x, _x, _y, _y); + } else { + let _x = currentBounds.data.stopx !== currentBounds.data.startx ? currentBounds.data.stopx + conf.diagramMarginX : currentBounds.data.startx; + let _y = currentBounds.data.starty; + currentBounds.setData(_x, _x, _y, _y); + } + currentBounds.name = currentBoundary.alias; + let currentPersonOrSystemArray = diagObj.db.getC4ShapeArray(currentBoundary.alias); + let currentPersonOrSystemKeys = diagObj.db.getC4ShapeKeys(currentBoundary.alias); + if (currentPersonOrSystemKeys.length > 0) { + drawC4ShapeArray( + currentBounds, + diagram2, + currentPersonOrSystemArray, + currentPersonOrSystemKeys + ); + } + parentBoundaryAlias = currentBoundary.alias; + let nextCurrentBoundaries = diagObj.db.getBoundarys(parentBoundaryAlias); + if (nextCurrentBoundaries.length > 0) { + drawInsideBoundary( + diagram2, + parentBoundaryAlias, + currentBounds, + nextCurrentBoundaries, + diagObj + ); + } + if (currentBoundary.alias !== "global") { + drawBoundary(diagram2, currentBoundary, currentBounds); + } + parentBounds.data.stopy = Math.max( + currentBounds.data.stopy + conf.c4ShapeMargin, + parentBounds.data.stopy + ); + parentBounds.data.stopx = Math.max( + currentBounds.data.stopx + conf.c4ShapeMargin, + parentBounds.data.stopx + ); + globalBoundaryMaxX = Math.max(globalBoundaryMaxX, parentBounds.data.stopx); + globalBoundaryMaxY = Math.max(globalBoundaryMaxY, parentBounds.data.stopy); + } +} +const draw = function(_text, id, _version, diagObj) { + conf = getConfig().c4; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + let db2 = diagObj.db; + diagObj.db.setWrap(conf.wrap); + c4ShapeInRow = db2.getC4ShapeInRow(); + c4BoundaryInRow = db2.getC4BoundaryInRow(); + log$1.debug(`C:${JSON.stringify(conf, null, 2)}`); + const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + svgDraw.insertComputerIcon(diagram2); + svgDraw.insertDatabaseIcon(diagram2); + svgDraw.insertClockIcon(diagram2); + let screenBounds = new Bounds(diagObj); + screenBounds.setData( + conf.diagramMarginX, + conf.diagramMarginX, + conf.diagramMarginY, + conf.diagramMarginY + ); + screenBounds.data.widthLimit = screen.availWidth; + globalBoundaryMaxX = conf.diagramMarginX; + globalBoundaryMaxY = conf.diagramMarginY; + const title2 = diagObj.db.getTitle(); + let currentBoundaries = diagObj.db.getBoundarys(""); + drawInsideBoundary(diagram2, "", screenBounds, currentBoundaries, diagObj); + svgDraw.insertArrowHead(diagram2); + svgDraw.insertArrowEnd(diagram2); + svgDraw.insertArrowCrossHead(diagram2); + svgDraw.insertArrowFilledHead(diagram2); + drawRels(diagram2, diagObj.db.getRels(), diagObj.db.getC4Shape, diagObj); + screenBounds.data.stopx = globalBoundaryMaxX; + screenBounds.data.stopy = globalBoundaryMaxY; + const box = screenBounds.data; + let boxHeight = box.stopy - box.starty; + let height = boxHeight + 2 * conf.diagramMarginY; + let boxWidth = box.stopx - box.startx; + const width = boxWidth + 2 * conf.diagramMarginX; + if (title2) { + diagram2.append("text").text(title2).attr("x", (box.stopx - box.startx) / 2 - 4 * conf.diagramMarginX).attr("y", box.starty + conf.diagramMarginY); + } + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const extraVertForTitle = title2 ? 60 : 0; + diagram2.attr( + "viewBox", + box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle) + ); + log$1.debug(`models:`, box); +}; +const renderer = { + drawPersonOrSystemArray: drawC4ShapeArray, + drawBoundary, + setConf, + draw +}; +const getStyles = (options) => `.person { + stroke: ${options.personBorder}; + fill: ${options.personBkg}; + } +`; +const styles = getStyles; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: ({ c4, wrap }) => { + renderer.setConf(c4); + db.setWrap(wrap); + } +}; + +export { diagram }; diff --git a/libs/marked/c4Diagram-ae766693-jqWCbSFz.js b/libs/marked/c4Diagram-ae766693-jqWCbSFz.js new file mode 100644 index 0000000..7db58f8 --- /dev/null +++ b/libs/marked/c4Diagram-ae766693-jqWCbSFz.js @@ -0,0 +1,2463 @@ +import { s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, c as getConfig, d as sanitizeText$2, e as assignWithDepth$1, f as calculateTextWidth, h as select, l as log$1, i as configureSvgSize, w as wrapLabel, j as common$1, k as calculateTextHeight, m as dist } from './index-Bd_FDXSq.js'; +import { d as drawRect$1, g as getNoteRect } from './svgDrawCommon-5e1cfd1d-CHZPGcFQ.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 24], $V1 = [1, 25], $V2 = [1, 26], $V3 = [1, 27], $V4 = [1, 28], $V5 = [1, 63], $V6 = [1, 64], $V7 = [1, 65], $V8 = [1, 66], $V9 = [1, 67], $Va = [1, 68], $Vb = [1, 69], $Vc = [1, 29], $Vd = [1, 30], $Ve = [1, 31], $Vf = [1, 32], $Vg = [1, 33], $Vh = [1, 34], $Vi = [1, 35], $Vj = [1, 36], $Vk = [1, 37], $Vl = [1, 38], $Vm = [1, 39], $Vn = [1, 40], $Vo = [1, 41], $Vp = [1, 42], $Vq = [1, 43], $Vr = [1, 44], $Vs = [1, 45], $Vt = [1, 46], $Vu = [1, 47], $Vv = [1, 48], $Vw = [1, 50], $Vx = [1, 51], $Vy = [1, 52], $Vz = [1, 53], $VA = [1, 54], $VB = [1, 55], $VC = [1, 56], $VD = [1, 57], $VE = [1, 58], $VF = [1, 59], $VG = [1, 60], $VH = [14, 42], $VI = [14, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74], $VJ = [12, 14, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74], $VK = [1, 82], $VL = [1, 83], $VM = [1, 84], $VN = [1, 85], $VO = [12, 14, 42], $VP = [12, 14, 33, 42], $VQ = [12, 14, 33, 42, 76, 77, 79, 80], $VR = [12, 33], $VS = [34, 36, 37, 38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mermaidDoc": 4, "direction": 5, "direction_tb": 6, "direction_bt": 7, "direction_rl": 8, "direction_lr": 9, "graphConfig": 10, "C4_CONTEXT": 11, "NEWLINE": 12, "statements": 13, "EOF": 14, "C4_CONTAINER": 15, "C4_COMPONENT": 16, "C4_DYNAMIC": 17, "C4_DEPLOYMENT": 18, "otherStatements": 19, "diagramStatements": 20, "otherStatement": 21, "title": 22, "accDescription": 23, "acc_title": 24, "acc_title_value": 25, "acc_descr": 26, "acc_descr_value": 27, "acc_descr_multiline_value": 28, "boundaryStatement": 29, "boundaryStartStatement": 30, "boundaryStopStatement": 31, "boundaryStart": 32, "LBRACE": 33, "ENTERPRISE_BOUNDARY": 34, "attributes": 35, "SYSTEM_BOUNDARY": 36, "BOUNDARY": 37, "CONTAINER_BOUNDARY": 38, "NODE": 39, "NODE_L": 40, "NODE_R": 41, "RBRACE": 42, "diagramStatement": 43, "PERSON": 44, "PERSON_EXT": 45, "SYSTEM": 46, "SYSTEM_DB": 47, "SYSTEM_QUEUE": 48, "SYSTEM_EXT": 49, "SYSTEM_EXT_DB": 50, "SYSTEM_EXT_QUEUE": 51, "CONTAINER": 52, "CONTAINER_DB": 53, "CONTAINER_QUEUE": 54, "CONTAINER_EXT": 55, "CONTAINER_EXT_DB": 56, "CONTAINER_EXT_QUEUE": 57, "COMPONENT": 58, "COMPONENT_DB": 59, "COMPONENT_QUEUE": 60, "COMPONENT_EXT": 61, "COMPONENT_EXT_DB": 62, "COMPONENT_EXT_QUEUE": 63, "REL": 64, "BIREL": 65, "REL_U": 66, "REL_D": 67, "REL_L": 68, "REL_R": 69, "REL_B": 70, "REL_INDEX": 71, "UPDATE_EL_STYLE": 72, "UPDATE_REL_STYLE": 73, "UPDATE_LAYOUT_CONFIG": 74, "attribute": 75, "STR": 76, "STR_KEY": 77, "STR_VALUE": 78, "ATTRIBUTE": 79, "ATTRIBUTE_EMPTY": 80, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 6: "direction_tb", 7: "direction_bt", 8: "direction_rl", 9: "direction_lr", 11: "C4_CONTEXT", 12: "NEWLINE", 14: "EOF", 15: "C4_CONTAINER", 16: "C4_COMPONENT", 17: "C4_DYNAMIC", 18: "C4_DEPLOYMENT", 22: "title", 23: "accDescription", 24: "acc_title", 25: "acc_title_value", 26: "acc_descr", 27: "acc_descr_value", 28: "acc_descr_multiline_value", 33: "LBRACE", 34: "ENTERPRISE_BOUNDARY", 36: "SYSTEM_BOUNDARY", 37: "BOUNDARY", 38: "CONTAINER_BOUNDARY", 39: "NODE", 40: "NODE_L", 41: "NODE_R", 42: "RBRACE", 44: "PERSON", 45: "PERSON_EXT", 46: "SYSTEM", 47: "SYSTEM_DB", 48: "SYSTEM_QUEUE", 49: "SYSTEM_EXT", 50: "SYSTEM_EXT_DB", 51: "SYSTEM_EXT_QUEUE", 52: "CONTAINER", 53: "CONTAINER_DB", 54: "CONTAINER_QUEUE", 55: "CONTAINER_EXT", 56: "CONTAINER_EXT_DB", 57: "CONTAINER_EXT_QUEUE", 58: "COMPONENT", 59: "COMPONENT_DB", 60: "COMPONENT_QUEUE", 61: "COMPONENT_EXT", 62: "COMPONENT_EXT_DB", 63: "COMPONENT_EXT_QUEUE", 64: "REL", 65: "BIREL", 66: "REL_U", 67: "REL_D", 68: "REL_L", 69: "REL_R", 70: "REL_B", 71: "REL_INDEX", 72: "UPDATE_EL_STYLE", 73: "UPDATE_REL_STYLE", 74: "UPDATE_LAYOUT_CONFIG", 76: "STR", 77: "STR_KEY", 78: "STR_VALUE", 79: "ATTRIBUTE", 80: "ATTRIBUTE_EMPTY" }, + productions_: [0, [3, 1], [3, 1], [5, 1], [5, 1], [5, 1], [5, 1], [4, 1], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [13, 1], [13, 1], [13, 2], [19, 1], [19, 2], [19, 3], [21, 1], [21, 1], [21, 2], [21, 2], [21, 1], [29, 3], [30, 3], [30, 3], [30, 4], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [31, 1], [20, 1], [20, 2], [20, 3], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 1], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [35, 1], [35, 2], [75, 1], [75, 2], [75, 1], [75, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setDirection("TB"); + break; + case 4: + yy.setDirection("BT"); + break; + case 5: + yy.setDirection("RL"); + break; + case 6: + yy.setDirection("LR"); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + yy.setC4Type($$[$0 - 3]); + break; + case 19: + yy.setTitle($$[$0].substring(6)); + this.$ = $$[$0].substring(6); + break; + case 20: + yy.setAccDescription($$[$0].substring(15)); + this.$ = $$[$0].substring(15); + break; + case 21: + this.$ = $$[$0].trim(); + yy.setTitle(this.$); + break; + case 22: + case 23: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 28: + case 29: + $$[$0].splice(2, 0, "ENTERPRISE"); + yy.addPersonOrSystemBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 30: + yy.addPersonOrSystemBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 31: + $$[$0].splice(2, 0, "CONTAINER"); + yy.addContainerBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 32: + yy.addDeploymentNode("node", ...$$[$0]); + this.$ = $$[$0]; + break; + case 33: + yy.addDeploymentNode("nodeL", ...$$[$0]); + this.$ = $$[$0]; + break; + case 34: + yy.addDeploymentNode("nodeR", ...$$[$0]); + this.$ = $$[$0]; + break; + case 35: + yy.popBoundaryParseStack(); + break; + case 39: + yy.addPersonOrSystem("person", ...$$[$0]); + this.$ = $$[$0]; + break; + case 40: + yy.addPersonOrSystem("external_person", ...$$[$0]); + this.$ = $$[$0]; + break; + case 41: + yy.addPersonOrSystem("system", ...$$[$0]); + this.$ = $$[$0]; + break; + case 42: + yy.addPersonOrSystem("system_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 43: + yy.addPersonOrSystem("system_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 44: + yy.addPersonOrSystem("external_system", ...$$[$0]); + this.$ = $$[$0]; + break; + case 45: + yy.addPersonOrSystem("external_system_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 46: + yy.addPersonOrSystem("external_system_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 47: + yy.addContainer("container", ...$$[$0]); + this.$ = $$[$0]; + break; + case 48: + yy.addContainer("container_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 49: + yy.addContainer("container_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 50: + yy.addContainer("external_container", ...$$[$0]); + this.$ = $$[$0]; + break; + case 51: + yy.addContainer("external_container_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 52: + yy.addContainer("external_container_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 53: + yy.addComponent("component", ...$$[$0]); + this.$ = $$[$0]; + break; + case 54: + yy.addComponent("component_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 55: + yy.addComponent("component_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 56: + yy.addComponent("external_component", ...$$[$0]); + this.$ = $$[$0]; + break; + case 57: + yy.addComponent("external_component_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 58: + yy.addComponent("external_component_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 60: + yy.addRel("rel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 61: + yy.addRel("birel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 62: + yy.addRel("rel_u", ...$$[$0]); + this.$ = $$[$0]; + break; + case 63: + yy.addRel("rel_d", ...$$[$0]); + this.$ = $$[$0]; + break; + case 64: + yy.addRel("rel_l", ...$$[$0]); + this.$ = $$[$0]; + break; + case 65: + yy.addRel("rel_r", ...$$[$0]); + this.$ = $$[$0]; + break; + case 66: + yy.addRel("rel_b", ...$$[$0]); + this.$ = $$[$0]; + break; + case 67: + $$[$0].splice(0, 1); + yy.addRel("rel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 68: + yy.updateElStyle("update_el_style", ...$$[$0]); + this.$ = $$[$0]; + break; + case 69: + yy.updateRelStyle("update_rel_style", ...$$[$0]); + this.$ = $$[$0]; + break; + case 70: + yy.updateLayoutConfig("update_layout_config", ...$$[$0]); + this.$ = $$[$0]; + break; + case 71: + this.$ = [$$[$0]]; + break; + case 72: + $$[$0].unshift($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 73: + case 75: + this.$ = $$[$0].trim(); + break; + case 74: + let kv = {}; + kv[$$[$0 - 1].trim()] = $$[$0].trim(); + this.$ = kv; + break; + case 76: + this.$ = ""; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 7: [1, 6], 8: [1, 7], 9: [1, 8], 10: 4, 11: [1, 9], 15: [1, 10], 16: [1, 11], 17: [1, 12], 18: [1, 13] }, { 1: [3] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 7] }, { 1: [2, 3] }, { 1: [2, 4] }, { 1: [2, 5] }, { 1: [2, 6] }, { 12: [1, 14] }, { 12: [1, 15] }, { 12: [1, 16] }, { 12: [1, 17] }, { 12: [1, 18] }, { 13: 19, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 70, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 71, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 72, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 73, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 14: [1, 74] }, o($VH, [2, 13], { 43: 23, 29: 49, 30: 61, 32: 62, 20: 75, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }), o($VH, [2, 14]), o($VI, [2, 16], { 12: [1, 76] }), o($VH, [2, 36], { 12: [1, 77] }), o($VJ, [2, 19]), o($VJ, [2, 20]), { 25: [1, 78] }, { 27: [1, 79] }, o($VJ, [2, 23]), { 35: 80, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 86, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 87, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 88, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 89, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 90, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 91, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 92, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 93, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 94, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 95, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 96, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 97, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 98, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 99, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 100, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 101, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 102, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 103, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 104, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, o($VO, [2, 59]), { 35: 105, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 106, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 107, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 108, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 109, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 110, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 111, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 112, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 113, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 114, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 115, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 20: 116, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 12: [1, 118], 33: [1, 117] }, { 35: 119, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 120, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 121, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 122, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 123, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 124, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 125, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 14: [1, 126] }, { 14: [1, 127] }, { 14: [1, 128] }, { 14: [1, 129] }, { 1: [2, 8] }, o($VH, [2, 15]), o($VI, [2, 17], { 21: 22, 19: 130, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4 }), o($VH, [2, 37], { 19: 20, 20: 21, 21: 22, 43: 23, 29: 49, 30: 61, 32: 62, 13: 131, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }), o($VJ, [2, 21]), o($VJ, [2, 22]), o($VO, [2, 39]), o($VP, [2, 71], { 75: 81, 35: 132, 76: $VK, 77: $VL, 79: $VM, 80: $VN }), o($VQ, [2, 73]), { 78: [1, 133] }, o($VQ, [2, 75]), o($VQ, [2, 76]), o($VO, [2, 40]), o($VO, [2, 41]), o($VO, [2, 42]), o($VO, [2, 43]), o($VO, [2, 44]), o($VO, [2, 45]), o($VO, [2, 46]), o($VO, [2, 47]), o($VO, [2, 48]), o($VO, [2, 49]), o($VO, [2, 50]), o($VO, [2, 51]), o($VO, [2, 52]), o($VO, [2, 53]), o($VO, [2, 54]), o($VO, [2, 55]), o($VO, [2, 56]), o($VO, [2, 57]), o($VO, [2, 58]), o($VO, [2, 60]), o($VO, [2, 61]), o($VO, [2, 62]), o($VO, [2, 63]), o($VO, [2, 64]), o($VO, [2, 65]), o($VO, [2, 66]), o($VO, [2, 67]), o($VO, [2, 68]), o($VO, [2, 69]), o($VO, [2, 70]), { 31: 134, 42: [1, 135] }, { 12: [1, 136] }, { 33: [1, 137] }, o($VR, [2, 28]), o($VR, [2, 29]), o($VR, [2, 30]), o($VR, [2, 31]), o($VR, [2, 32]), o($VR, [2, 33]), o($VR, [2, 34]), { 1: [2, 9] }, { 1: [2, 10] }, { 1: [2, 11] }, { 1: [2, 12] }, o($VI, [2, 18]), o($VH, [2, 38]), o($VP, [2, 72]), o($VQ, [2, 74]), o($VO, [2, 24]), o($VO, [2, 35]), o($VS, [2, 25]), o($VS, [2, 26], { 12: [1, 138] }), o($VS, [2, 27])], + defaultActions: { 2: [2, 1], 3: [2, 2], 4: [2, 7], 5: [2, 3], 6: [2, 4], 7: [2, 5], 8: [2, 6], 74: [2, 8], 126: [2, 9], 127: [2, 10], 128: [2, 11], 129: [2, 12] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c2 = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c2 + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 6; + case 1: + return 7; + case 2: + return 8; + case 3: + return 9; + case 4: + return 22; + case 5: + return 23; + case 6: + this.begin("acc_title"); + return 24; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 26; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + break; + case 14: + c; + break; + case 15: + return 12; + case 16: + break; + case 17: + return 11; + case 18: + return 15; + case 19: + return 16; + case 20: + return 17; + case 21: + return 18; + case 22: + this.begin("person_ext"); + return 45; + case 23: + this.begin("person"); + return 44; + case 24: + this.begin("system_ext_queue"); + return 51; + case 25: + this.begin("system_ext_db"); + return 50; + case 26: + this.begin("system_ext"); + return 49; + case 27: + this.begin("system_queue"); + return 48; + case 28: + this.begin("system_db"); + return 47; + case 29: + this.begin("system"); + return 46; + case 30: + this.begin("boundary"); + return 37; + case 31: + this.begin("enterprise_boundary"); + return 34; + case 32: + this.begin("system_boundary"); + return 36; + case 33: + this.begin("container_ext_queue"); + return 57; + case 34: + this.begin("container_ext_db"); + return 56; + case 35: + this.begin("container_ext"); + return 55; + case 36: + this.begin("container_queue"); + return 54; + case 37: + this.begin("container_db"); + return 53; + case 38: + this.begin("container"); + return 52; + case 39: + this.begin("container_boundary"); + return 38; + case 40: + this.begin("component_ext_queue"); + return 63; + case 41: + this.begin("component_ext_db"); + return 62; + case 42: + this.begin("component_ext"); + return 61; + case 43: + this.begin("component_queue"); + return 60; + case 44: + this.begin("component_db"); + return 59; + case 45: + this.begin("component"); + return 58; + case 46: + this.begin("node"); + return 39; + case 47: + this.begin("node"); + return 39; + case 48: + this.begin("node_l"); + return 40; + case 49: + this.begin("node_r"); + return 41; + case 50: + this.begin("rel"); + return 64; + case 51: + this.begin("birel"); + return 65; + case 52: + this.begin("rel_u"); + return 66; + case 53: + this.begin("rel_u"); + return 66; + case 54: + this.begin("rel_d"); + return 67; + case 55: + this.begin("rel_d"); + return 67; + case 56: + this.begin("rel_l"); + return 68; + case 57: + this.begin("rel_l"); + return 68; + case 58: + this.begin("rel_r"); + return 69; + case 59: + this.begin("rel_r"); + return 69; + case 60: + this.begin("rel_b"); + return 70; + case 61: + this.begin("rel_index"); + return 71; + case 62: + this.begin("update_el_style"); + return 72; + case 63: + this.begin("update_rel_style"); + return 73; + case 64: + this.begin("update_layout_config"); + return 74; + case 65: + return "EOF_IN_STRUCT"; + case 66: + this.begin("attribute"); + return "ATTRIBUTE_EMPTY"; + case 67: + this.begin("attribute"); + break; + case 68: + this.popState(); + this.popState(); + break; + case 69: + return 80; + case 70: + break; + case 71: + return 80; + case 72: + this.begin("string"); + break; + case 73: + this.popState(); + break; + case 74: + return "STR"; + case 75: + this.begin("string_kv"); + break; + case 76: + this.begin("string_kv_key"); + return "STR_KEY"; + case 77: + this.popState(); + this.begin("string_kv_value"); + break; + case 78: + return "STR_VALUE"; + case 79: + this.popState(); + this.popState(); + break; + case 80: + return "STR"; + case 81: + return "LBRACE"; + case 82: + return "RBRACE"; + case 83: + return "SPACE"; + case 84: + return "EOL"; + case 85: + return 14; + } + }, + rules: [/^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:title\s[^#\n;]+)/, /^(?:accDescription\s[^#\n;]+)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/, /^(?:%%[^\n]*(\r?\n)*)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:C4Context\b)/, /^(?:C4Container\b)/, /^(?:C4Component\b)/, /^(?:C4Dynamic\b)/, /^(?:C4Deployment\b)/, /^(?:Person_Ext\b)/, /^(?:Person\b)/, /^(?:SystemQueue_Ext\b)/, /^(?:SystemDb_Ext\b)/, /^(?:System_Ext\b)/, /^(?:SystemQueue\b)/, /^(?:SystemDb\b)/, /^(?:System\b)/, /^(?:Boundary\b)/, /^(?:Enterprise_Boundary\b)/, /^(?:System_Boundary\b)/, /^(?:ContainerQueue_Ext\b)/, /^(?:ContainerDb_Ext\b)/, /^(?:Container_Ext\b)/, /^(?:ContainerQueue\b)/, /^(?:ContainerDb\b)/, /^(?:Container\b)/, /^(?:Container_Boundary\b)/, /^(?:ComponentQueue_Ext\b)/, /^(?:ComponentDb_Ext\b)/, /^(?:Component_Ext\b)/, /^(?:ComponentQueue\b)/, /^(?:ComponentDb\b)/, /^(?:Component\b)/, /^(?:Deployment_Node\b)/, /^(?:Node\b)/, /^(?:Node_L\b)/, /^(?:Node_R\b)/, /^(?:Rel\b)/, /^(?:BiRel\b)/, /^(?:Rel_Up\b)/, /^(?:Rel_U\b)/, /^(?:Rel_Down\b)/, /^(?:Rel_D\b)/, /^(?:Rel_Left\b)/, /^(?:Rel_L\b)/, /^(?:Rel_Right\b)/, /^(?:Rel_R\b)/, /^(?:Rel_Back\b)/, /^(?:RelIndex\b)/, /^(?:UpdateElementStyle\b)/, /^(?:UpdateRelStyle\b)/, /^(?:UpdateLayoutConfig\b)/, /^(?:$)/, /^(?:[(][ ]*[,])/, /^(?:[(])/, /^(?:[)])/, /^(?:,,)/, /^(?:,)/, /^(?:[ ]*["]["])/, /^(?:[ ]*["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:[ ]*[\$])/, /^(?:[^=]*)/, /^(?:[=][ ]*["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:[^,]+)/, /^(?:\{)/, /^(?:\})/, /^(?:[\s]+)/, /^(?:[\n\r]+)/, /^(?:$)/], + conditions: { "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "string_kv_value": { "rules": [78, 79], "inclusive": false }, "string_kv_key": { "rules": [77], "inclusive": false }, "string_kv": { "rules": [76], "inclusive": false }, "string": { "rules": [73, 74], "inclusive": false }, "attribute": { "rules": [68, 69, 70, 71, 72, 75, 80], "inclusive": false }, "update_layout_config": { "rules": [65, 66, 67, 68], "inclusive": false }, "update_rel_style": { "rules": [65, 66, 67, 68], "inclusive": false }, "update_el_style": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_b": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_r": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_l": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_d": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_u": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_bi": { "rules": [], "inclusive": false }, "rel": { "rules": [65, 66, 67, 68], "inclusive": false }, "node_r": { "rules": [65, 66, 67, 68], "inclusive": false }, "node_l": { "rules": [65, 66, 67, 68], "inclusive": false }, "node": { "rules": [65, 66, 67, 68], "inclusive": false }, "index": { "rules": [], "inclusive": false }, "rel_index": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_ext_queue": { "rules": [], "inclusive": false }, "component_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "component": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "container": { "rules": [65, 66, 67, 68], "inclusive": false }, "birel": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "enterprise_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "system": { "rules": [65, 66, 67, 68], "inclusive": false }, "person_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "person": { "rules": [65, 66, 67, 68], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 81, 82, 83, 84, 85], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let c4ShapeArray = []; +let boundaryParseStack = [""]; +let currentBoundaryParse = "global"; +let parentBoundaryParse = ""; +let boundaries = [ + { + alias: "global", + label: { text: "global" }, + type: { text: "global" }, + tags: null, + link: null, + parentBoundary: "" + } +]; +let rels = []; +let title = ""; +let wrapEnabled = false; +let c4ShapeInRow$1 = 4; +let c4BoundaryInRow$1 = 2; +var c4Type; +const getC4Type = function() { + return c4Type; +}; +const setC4Type = function(c4TypeParam) { + let sanitizedText = sanitizeText$2(c4TypeParam, getConfig()); + c4Type = sanitizedText; +}; +const addRel = function(type, from, to, label, techn, descr, sprite, tags, link) { + if (type === void 0 || type === null || from === void 0 || from === null || to === void 0 || to === null || label === void 0 || label === null) { + return; + } + let rel = {}; + const old = rels.find((rel2) => rel2.from === from && rel2.to === to); + if (old) { + rel = old; + } else { + rels.push(rel); + } + rel.type = type; + rel.from = from; + rel.to = to; + rel.label = { text: label }; + if (techn === void 0 || techn === null) { + rel.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + rel[key] = { text: value }; + } else { + rel.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + rel.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + rel[key] = { text: value }; + } else { + rel.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + rel[key] = value; + } else { + rel.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + rel[key] = value; + } else { + rel.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + rel[key] = value; + } else { + rel.link = link; + } + rel.wrap = autoWrap(); +}; +const addPersonOrSystem = function(typeC4Shape, alias, label, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let personOrSystem = {}; + const old = c4ShapeArray.find((personOrSystem2) => personOrSystem2.alias === alias); + if (old && alias === old.alias) { + personOrSystem = old; + } else { + personOrSystem.alias = alias; + c4ShapeArray.push(personOrSystem); + } + if (label === void 0 || label === null) { + personOrSystem.label = { text: "" }; + } else { + personOrSystem.label = { text: label }; + } + if (descr === void 0 || descr === null) { + personOrSystem.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + personOrSystem[key] = { text: value }; + } else { + personOrSystem.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.link = link; + } + personOrSystem.typeC4Shape = { text: typeC4Shape }; + personOrSystem.parentBoundary = currentBoundaryParse; + personOrSystem.wrap = autoWrap(); +}; +const addContainer = function(typeC4Shape, alias, label, techn, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let container = {}; + const old = c4ShapeArray.find((container2) => container2.alias === alias); + if (old && alias === old.alias) { + container = old; + } else { + container.alias = alias; + c4ShapeArray.push(container); + } + if (label === void 0 || label === null) { + container.label = { text: "" }; + } else { + container.label = { text: label }; + } + if (techn === void 0 || techn === null) { + container.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + container[key] = { text: value }; + } else { + container.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + container.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + container[key] = { text: value }; + } else { + container.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + container[key] = value; + } else { + container.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + container[key] = value; + } else { + container.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + container[key] = value; + } else { + container.link = link; + } + container.wrap = autoWrap(); + container.typeC4Shape = { text: typeC4Shape }; + container.parentBoundary = currentBoundaryParse; +}; +const addComponent = function(typeC4Shape, alias, label, techn, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let component = {}; + const old = c4ShapeArray.find((component2) => component2.alias === alias); + if (old && alias === old.alias) { + component = old; + } else { + component.alias = alias; + c4ShapeArray.push(component); + } + if (label === void 0 || label === null) { + component.label = { text: "" }; + } else { + component.label = { text: label }; + } + if (techn === void 0 || techn === null) { + component.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + component[key] = { text: value }; + } else { + component.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + component.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + component[key] = { text: value }; + } else { + component.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + component[key] = value; + } else { + component.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + component[key] = value; + } else { + component.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + component[key] = value; + } else { + component.link = link; + } + component.wrap = autoWrap(); + component.typeC4Shape = { text: typeC4Shape }; + component.parentBoundary = currentBoundaryParse; +}; +const addPersonOrSystemBoundary = function(alias, label, type, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "system" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const addContainerBoundary = function(alias, label, type, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "container" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const addDeploymentNode = function(nodeType, alias, label, type, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "node" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (descr === void 0 || descr === null) { + boundary.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + boundary[key] = { text: value }; + } else { + boundary.descr = { text: descr }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.nodeType = nodeType; + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const popBoundaryParseStack = function() { + currentBoundaryParse = parentBoundaryParse; + boundaryParseStack.pop(); + parentBoundaryParse = boundaryParseStack.pop(); + boundaryParseStack.push(parentBoundaryParse); +}; +const updateElStyle = function(typeC4Shape, elementName, bgColor, fontColor, borderColor, shadowing, shape, sprite, techn, legendText, legendSprite) { + let old = c4ShapeArray.find((element) => element.alias === elementName); + if (old === void 0) { + old = boundaries.find((element) => element.alias === elementName); + if (old === void 0) { + return; + } + } + if (bgColor !== void 0 && bgColor !== null) { + if (typeof bgColor === "object") { + let [key, value] = Object.entries(bgColor)[0]; + old[key] = value; + } else { + old.bgColor = bgColor; + } + } + if (fontColor !== void 0 && fontColor !== null) { + if (typeof fontColor === "object") { + let [key, value] = Object.entries(fontColor)[0]; + old[key] = value; + } else { + old.fontColor = fontColor; + } + } + if (borderColor !== void 0 && borderColor !== null) { + if (typeof borderColor === "object") { + let [key, value] = Object.entries(borderColor)[0]; + old[key] = value; + } else { + old.borderColor = borderColor; + } + } + if (shadowing !== void 0 && shadowing !== null) { + if (typeof shadowing === "object") { + let [key, value] = Object.entries(shadowing)[0]; + old[key] = value; + } else { + old.shadowing = shadowing; + } + } + if (shape !== void 0 && shape !== null) { + if (typeof shape === "object") { + let [key, value] = Object.entries(shape)[0]; + old[key] = value; + } else { + old.shape = shape; + } + } + if (sprite !== void 0 && sprite !== null) { + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + old[key] = value; + } else { + old.sprite = sprite; + } + } + if (techn !== void 0 && techn !== null) { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + old[key] = value; + } else { + old.techn = techn; + } + } + if (legendText !== void 0 && legendText !== null) { + if (typeof legendText === "object") { + let [key, value] = Object.entries(legendText)[0]; + old[key] = value; + } else { + old.legendText = legendText; + } + } + if (legendSprite !== void 0 && legendSprite !== null) { + if (typeof legendSprite === "object") { + let [key, value] = Object.entries(legendSprite)[0]; + old[key] = value; + } else { + old.legendSprite = legendSprite; + } + } +}; +const updateRelStyle = function(typeC4Shape, from, to, textColor, lineColor, offsetX, offsetY) { + const old = rels.find((rel) => rel.from === from && rel.to === to); + if (old === void 0) { + return; + } + if (textColor !== void 0 && textColor !== null) { + if (typeof textColor === "object") { + let [key, value] = Object.entries(textColor)[0]; + old[key] = value; + } else { + old.textColor = textColor; + } + } + if (lineColor !== void 0 && lineColor !== null) { + if (typeof lineColor === "object") { + let [key, value] = Object.entries(lineColor)[0]; + old[key] = value; + } else { + old.lineColor = lineColor; + } + } + if (offsetX !== void 0 && offsetX !== null) { + if (typeof offsetX === "object") { + let [key, value] = Object.entries(offsetX)[0]; + old[key] = parseInt(value); + } else { + old.offsetX = parseInt(offsetX); + } + } + if (offsetY !== void 0 && offsetY !== null) { + if (typeof offsetY === "object") { + let [key, value] = Object.entries(offsetY)[0]; + old[key] = parseInt(value); + } else { + old.offsetY = parseInt(offsetY); + } + } +}; +const updateLayoutConfig = function(typeC4Shape, c4ShapeInRowParam, c4BoundaryInRowParam) { + let c4ShapeInRowValue = c4ShapeInRow$1; + let c4BoundaryInRowValue = c4BoundaryInRow$1; + if (typeof c4ShapeInRowParam === "object") { + const value = Object.values(c4ShapeInRowParam)[0]; + c4ShapeInRowValue = parseInt(value); + } else { + c4ShapeInRowValue = parseInt(c4ShapeInRowParam); + } + if (typeof c4BoundaryInRowParam === "object") { + const value = Object.values(c4BoundaryInRowParam)[0]; + c4BoundaryInRowValue = parseInt(value); + } else { + c4BoundaryInRowValue = parseInt(c4BoundaryInRowParam); + } + if (c4ShapeInRowValue >= 1) { + c4ShapeInRow$1 = c4ShapeInRowValue; + } + if (c4BoundaryInRowValue >= 1) { + c4BoundaryInRow$1 = c4BoundaryInRowValue; + } +}; +const getC4ShapeInRow = function() { + return c4ShapeInRow$1; +}; +const getC4BoundaryInRow = function() { + return c4BoundaryInRow$1; +}; +const getCurrentBoundaryParse = function() { + return currentBoundaryParse; +}; +const getParentBoundaryParse = function() { + return parentBoundaryParse; +}; +const getC4ShapeArray = function(parentBoundary) { + if (parentBoundary === void 0 || parentBoundary === null) { + return c4ShapeArray; + } else { + return c4ShapeArray.filter((personOrSystem) => { + return personOrSystem.parentBoundary === parentBoundary; + }); + } +}; +const getC4Shape = function(alias) { + return c4ShapeArray.find((personOrSystem) => personOrSystem.alias === alias); +}; +const getC4ShapeKeys = function(parentBoundary) { + return Object.keys(getC4ShapeArray(parentBoundary)); +}; +const getBoundaries = function(parentBoundary) { + if (parentBoundary === void 0 || parentBoundary === null) { + return boundaries; + } else { + return boundaries.filter((boundary) => boundary.parentBoundary === parentBoundary); + } +}; +const getBoundarys = getBoundaries; +const getRels = function() { + return rels; +}; +const getTitle = function() { + return title; +}; +const setWrap = function(wrapSetting) { + wrapEnabled = wrapSetting; +}; +const autoWrap = function() { + return wrapEnabled; +}; +const clear = function() { + c4ShapeArray = []; + boundaries = [ + { + alias: "global", + label: { text: "global" }, + type: { text: "global" }, + tags: null, + link: null, + parentBoundary: "" + } + ]; + parentBoundaryParse = ""; + currentBoundaryParse = "global"; + boundaryParseStack = [""]; + rels = []; + boundaryParseStack = [""]; + title = ""; + wrapEnabled = false; + c4ShapeInRow$1 = 4; + c4BoundaryInRow$1 = 2; +}; +const LINETYPE = { + SOLID: 0, + DOTTED: 1, + NOTE: 2, + SOLID_CROSS: 3, + DOTTED_CROSS: 4, + SOLID_OPEN: 5, + DOTTED_OPEN: 6, + LOOP_START: 10, + LOOP_END: 11, + ALT_START: 12, + ALT_ELSE: 13, + ALT_END: 14, + OPT_START: 15, + OPT_END: 16, + ACTIVE_START: 17, + ACTIVE_END: 18, + PAR_START: 19, + PAR_AND: 20, + PAR_END: 21, + RECT_START: 22, + RECT_END: 23, + SOLID_POINT: 24, + DOTTED_POINT: 25 +}; +const ARROWTYPE = { + FILLED: 0, + OPEN: 1 +}; +const PLACEMENT = { + LEFTOF: 0, + RIGHTOF: 1, + OVER: 2 +}; +const setTitle = function(txt) { + let sanitizedText = sanitizeText$2(txt, getConfig()); + title = sanitizedText; +}; +const db = { + addPersonOrSystem, + addPersonOrSystemBoundary, + addContainer, + addContainerBoundary, + addComponent, + addDeploymentNode, + popBoundaryParseStack, + addRel, + updateElStyle, + updateRelStyle, + updateLayoutConfig, + autoWrap, + setWrap, + getC4ShapeArray, + getC4Shape, + getC4ShapeKeys, + getBoundaries, + getBoundarys, + getCurrentBoundaryParse, + getParentBoundaryParse, + getRels, + getTitle, + getC4Type, + getC4ShapeInRow, + getC4BoundaryInRow, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + getConfig: () => getConfig().c4, + clear, + LINETYPE, + ARROWTYPE, + PLACEMENT, + setTitle, + setC4Type + // apply, +}; +const drawRect = function(elem, rectData) { + return drawRect$1(elem, rectData); +}; +const drawImage = function(elem, width, height, x, y, link) { + const imageElem = elem.append("image"); + imageElem.attr("width", width); + imageElem.attr("height", height); + imageElem.attr("x", x); + imageElem.attr("y", y); + let sanitizedLink = link.startsWith("data:image/png;base64") ? link : dist.sanitizeUrl(link); + imageElem.attr("xlink:href", sanitizedLink); +}; +const drawRels$1 = (elem, rels2, conf2) => { + const relsElem = elem.append("g"); + let i = 0; + for (let rel of rels2) { + let textColor = rel.textColor ? rel.textColor : "#444444"; + let strokeColor = rel.lineColor ? rel.lineColor : "#444444"; + let offsetX = rel.offsetX ? parseInt(rel.offsetX) : 0; + let offsetY = rel.offsetY ? parseInt(rel.offsetY) : 0; + let url = ""; + if (i === 0) { + let line = relsElem.append("line"); + line.attr("x1", rel.startPoint.x); + line.attr("y1", rel.startPoint.y); + line.attr("x2", rel.endPoint.x); + line.attr("y2", rel.endPoint.y); + line.attr("stroke-width", "1"); + line.attr("stroke", strokeColor); + line.style("fill", "none"); + if (rel.type !== "rel_b") { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (rel.type === "birel" || rel.type === "rel_b") { + line.attr("marker-start", "url(" + url + "#arrowend)"); + } + i = -1; + } else { + let line = relsElem.append("path"); + line.attr("fill", "none").attr("stroke-width", "1").attr("stroke", strokeColor).attr( + "d", + "Mstartx,starty Qcontrolx,controly stopx,stopy ".replaceAll("startx", rel.startPoint.x).replaceAll("starty", rel.startPoint.y).replaceAll( + "controlx", + rel.startPoint.x + (rel.endPoint.x - rel.startPoint.x) / 2 - (rel.endPoint.x - rel.startPoint.x) / 4 + ).replaceAll("controly", rel.startPoint.y + (rel.endPoint.y - rel.startPoint.y) / 2).replaceAll("stopx", rel.endPoint.x).replaceAll("stopy", rel.endPoint.y) + ); + if (rel.type !== "rel_b") { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (rel.type === "birel" || rel.type === "rel_b") { + line.attr("marker-start", "url(" + url + "#arrowend)"); + } + } + let messageConf = conf2.messageFont(); + _drawTextCandidateFunc(conf2)( + rel.label.text, + relsElem, + Math.min(rel.startPoint.x, rel.endPoint.x) + Math.abs(rel.endPoint.x - rel.startPoint.x) / 2 + offsetX, + Math.min(rel.startPoint.y, rel.endPoint.y) + Math.abs(rel.endPoint.y - rel.startPoint.y) / 2 + offsetY, + rel.label.width, + rel.label.height, + { fill: textColor }, + messageConf + ); + if (rel.techn && rel.techn.text !== "") { + messageConf = conf2.messageFont(); + _drawTextCandidateFunc(conf2)( + "[" + rel.techn.text + "]", + relsElem, + Math.min(rel.startPoint.x, rel.endPoint.x) + Math.abs(rel.endPoint.x - rel.startPoint.x) / 2 + offsetX, + Math.min(rel.startPoint.y, rel.endPoint.y) + Math.abs(rel.endPoint.y - rel.startPoint.y) / 2 + conf2.messageFontSize + 5 + offsetY, + Math.max(rel.label.width, rel.techn.width), + rel.techn.height, + { fill: textColor, "font-style": "italic" }, + messageConf + ); + } + } +}; +const drawBoundary$1 = function(elem, boundary, conf2) { + const boundaryElem = elem.append("g"); + let fillColor = boundary.bgColor ? boundary.bgColor : "none"; + let strokeColor = boundary.borderColor ? boundary.borderColor : "#444444"; + let fontColor = boundary.fontColor ? boundary.fontColor : "black"; + let attrsValue = { "stroke-width": 1, "stroke-dasharray": "7.0,7.0" }; + if (boundary.nodeType) { + attrsValue = { "stroke-width": 1 }; + } + let rectData = { + x: boundary.x, + y: boundary.y, + fill: fillColor, + stroke: strokeColor, + width: boundary.width, + height: boundary.height, + rx: 2.5, + ry: 2.5, + attrs: attrsValue + }; + drawRect(boundaryElem, rectData); + let boundaryConf = conf2.boundaryFont(); + boundaryConf.fontWeight = "bold"; + boundaryConf.fontSize = boundaryConf.fontSize + 2; + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + boundary.label.text, + boundaryElem, + boundary.x, + boundary.y + boundary.label.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + if (boundary.type && boundary.type.text !== "") { + boundaryConf = conf2.boundaryFont(); + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + boundary.type.text, + boundaryElem, + boundary.x, + boundary.y + boundary.type.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + } + if (boundary.descr && boundary.descr.text !== "") { + boundaryConf = conf2.boundaryFont(); + boundaryConf.fontSize = boundaryConf.fontSize - 2; + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + boundary.descr.text, + boundaryElem, + boundary.x, + boundary.y + boundary.descr.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + } +}; +const drawC4Shape = function(elem, c4Shape, conf2) { + var _a; + let fillColor = c4Shape.bgColor ? c4Shape.bgColor : conf2[c4Shape.typeC4Shape.text + "_bg_color"]; + let strokeColor = c4Shape.borderColor ? c4Shape.borderColor : conf2[c4Shape.typeC4Shape.text + "_border_color"]; + let fontColor = c4Shape.fontColor ? c4Shape.fontColor : "#FFFFFF"; + let personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII="; + switch (c4Shape.typeC4Shape.text) { + case "person": + personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII="; + break; + case "external_person": + personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAB6ElEQVR4Xu2YLY+EMBCG9+dWr0aj0Wg0Go1Go0+j8Xdv2uTCvv1gpt0ebHKPuhDaeW4605Z9mJvx4AdXUyTUdd08z+u6flmWZRnHsWkafk9DptAwDPu+f0eAYtu2PEaGWuj5fCIZrBAC2eLBAnRCsEkkxmeaJp7iDJ2QMDdHsLg8SxKFEJaAo8lAXnmuOFIhTMpxxKATebo4UiFknuNo4OniSIXQyRxEA3YsnjGCVEjVXD7yLUAqxBGUyPv/Y4W2beMgGuS7kVQIBycH0fD+oi5pezQETxdHKmQKGk1eQEYldK+jw5GxPfZ9z7Mk0Qnhf1W1m3w//EUn5BDmSZsbR44QQLBEqrBHqOrmSKaQAxdnLArCrxZcM7A7ZKs4ioRq8LFC+NpC3WCBJsvpVw5edm9iEXFuyNfxXAgSwfrFQ1c0iNda8AdejvUgnktOtJQQxmcfFzGglc5WVCj7oDgFqU18boeFSs52CUh8LE8BIVQDT1ABrB0HtgSEYlX5doJnCwv9TXocKCaKbnwhdDKPq4lf3SwU3HLq4V/+WYhHVMa/3b4IlfyikAduCkcBc7mQ3/z/Qq/cTuikhkzB12Ae/mcJC9U+Vo8Ej1gWAtgbeGgFsAMHr50BIWOLCbezvhpBFUdY6EJuJ/QDW0XoMX60zZ0AAAAASUVORK5CYII="; + break; + } + const c4ShapeElem = elem.append("g"); + c4ShapeElem.attr("class", "person-man"); + const rect = getNoteRect(); + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + case "system": + case "external_system": + case "container": + case "external_container": + case "component": + case "external_component": + rect.x = c4Shape.x; + rect.y = c4Shape.y; + rect.fill = fillColor; + rect.width = c4Shape.width; + rect.height = c4Shape.height; + rect.stroke = strokeColor; + rect.rx = 2.5; + rect.ry = 2.5; + rect.attrs = { "stroke-width": 0.5 }; + drawRect(c4ShapeElem, rect); + break; + case "system_db": + case "external_system_db": + case "container_db": + case "external_container_db": + case "component_db": + case "external_component_db": + c4ShapeElem.append("path").attr("fill", fillColor).attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc0,-10 half,-10 half,-10c0,0 half,0 half,10l0,heightc0,10 -half,10 -half,10c0,0 -half,0 -half,-10l0,-height".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.width / 2).replaceAll("height", c4Shape.height) + ); + c4ShapeElem.append("path").attr("fill", "none").attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc0,10 half,10 half,10c0,0 half,0 half,-10".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.width / 2) + ); + break; + case "system_queue": + case "external_system_queue": + case "container_queue": + case "external_container_queue": + case "component_queue": + case "external_component_queue": + c4ShapeElem.append("path").attr("fill", fillColor).attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startylwidth,0c5,0 5,half 5,halfc0,0 0,half -5,halfl-width,0c-5,0 -5,-half -5,-halfc0,0 0,-half 5,-half".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("width", c4Shape.width).replaceAll("half", c4Shape.height / 2) + ); + c4ShapeElem.append("path").attr("fill", "none").attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc-5,0 -5,half -5,halfc0,half 5,half 5,half".replaceAll("startx", c4Shape.x + c4Shape.width).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.height / 2) + ); + break; + } + let c4ShapeFontConf = getC4ShapeFont(conf2, c4Shape.typeC4Shape.text); + c4ShapeElem.append("text").attr("fill", fontColor).attr("font-family", c4ShapeFontConf.fontFamily).attr("font-size", c4ShapeFontConf.fontSize - 2).attr("font-style", "italic").attr("lengthAdjust", "spacing").attr("textLength", c4Shape.typeC4Shape.width).attr("x", c4Shape.x + c4Shape.width / 2 - c4Shape.typeC4Shape.width / 2).attr("y", c4Shape.y + c4Shape.typeC4Shape.Y).text("<<" + c4Shape.typeC4Shape.text + ">>"); + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + drawImage( + c4ShapeElem, + 48, + 48, + c4Shape.x + c4Shape.width / 2 - 24, + c4Shape.y + c4Shape.image.Y, + personImg + ); + break; + } + let textFontConf = conf2[c4Shape.typeC4Shape.text + "Font"](); + textFontConf.fontWeight = "bold"; + textFontConf.fontSize = textFontConf.fontSize + 2; + textFontConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + c4Shape.label.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.label.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor }, + textFontConf + ); + textFontConf = conf2[c4Shape.typeC4Shape.text + "Font"](); + textFontConf.fontColor = fontColor; + if (c4Shape.techn && ((_a = c4Shape.techn) == null ? void 0 : _a.text) !== "") { + _drawTextCandidateFunc(conf2)( + c4Shape.techn.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.techn.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor, "font-style": "italic" }, + textFontConf + ); + } else if (c4Shape.type && c4Shape.type.text !== "") { + _drawTextCandidateFunc(conf2)( + c4Shape.type.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.type.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor, "font-style": "italic" }, + textFontConf + ); + } + if (c4Shape.descr && c4Shape.descr.text !== "") { + textFontConf = conf2.personFont(); + textFontConf.fontColor = fontColor; + _drawTextCandidateFunc(conf2)( + c4Shape.descr.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.descr.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor }, + textFontConf + ); + } + return c4Shape.height; +}; +const insertDatabaseIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z" + ); +}; +const insertComputerIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z" + ); +}; +const insertClockIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z" + ); +}; +const insertArrowHead = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +}; +const insertArrowEnd = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowend").attr("refX", 1).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z"); +}; +const insertArrowFilledHead = function(elem) { + elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 18).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const insertDynamicNumber = function(elem) { + elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6); +}; +const insertArrowCrossHead = function(elem) { + const defs = elem.append("defs"); + const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 16).attr("refY", 4); + marker.append("path").attr("fill", "black").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1px").attr("d", "M 9,2 V 6 L16,4 Z"); + marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1px").attr("d", "M 0,1 L 6,7 M 6,1 L 0,7"); +}; +const getC4ShapeFont = (cnf, typeC4Shape) => { + return { + fontFamily: cnf[typeC4Shape + "FontFamily"], + fontSize: cnf[typeC4Shape + "FontSize"], + fontWeight: cnf[typeC4Shape + "FontWeight"] + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { fontSize, fontFamily, fontWeight } = conf2; + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * fontSize - fontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").attr("dominant-baseline", "middle").style("font-size", fontSize).style("font-weight", fontWeight).style("font-family", fontFamily); + text.append("tspan").attr("dy", dy).text(lines[i]).attr("alignment-baseline", "mathematical"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const svgDraw = { + drawRect, + drawBoundary: drawBoundary$1, + drawC4Shape, + drawRels: drawRels$1, + drawImage, + insertArrowHead, + insertArrowEnd, + insertArrowFilledHead, + insertDynamicNumber, + insertArrowCrossHead, + insertDatabaseIcon, + insertComputerIcon, + insertClockIcon +}; +let globalBoundaryMaxX = 0, globalBoundaryMaxY = 0; +let c4ShapeInRow = 4; +let c4BoundaryInRow = 2; +parser.yy = db; +let conf = {}; +class Bounds { + constructor(diagObj) { + this.name = ""; + this.data = {}; + this.data.startx = void 0; + this.data.stopx = void 0; + this.data.starty = void 0; + this.data.stopy = void 0; + this.data.widthLimit = void 0; + this.nextData = {}; + this.nextData.startx = void 0; + this.nextData.stopx = void 0; + this.nextData.starty = void 0; + this.nextData.stopy = void 0; + this.nextData.cnt = 0; + setConf(diagObj.db.getConfig()); + } + setData(startx, stopx, starty, stopy) { + this.nextData.startx = this.data.startx = startx; + this.nextData.stopx = this.data.stopx = stopx; + this.nextData.starty = this.data.starty = starty; + this.nextData.stopy = this.data.stopy = stopy; + } + updateVal(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + } + insert(c4Shape) { + this.nextData.cnt = this.nextData.cnt + 1; + let _startx = this.nextData.startx === this.nextData.stopx ? this.nextData.stopx + c4Shape.margin : this.nextData.stopx + c4Shape.margin * 2; + let _stopx = _startx + c4Shape.width; + let _starty = this.nextData.starty + c4Shape.margin * 2; + let _stopy = _starty + c4Shape.height; + if (_startx >= this.data.widthLimit || _stopx >= this.data.widthLimit || this.nextData.cnt > c4ShapeInRow) { + _startx = this.nextData.startx + c4Shape.margin + conf.nextLinePaddingX; + _starty = this.nextData.stopy + c4Shape.margin * 2; + this.nextData.stopx = _stopx = _startx + c4Shape.width; + this.nextData.starty = this.nextData.stopy; + this.nextData.stopy = _stopy = _starty + c4Shape.height; + this.nextData.cnt = 1; + } + c4Shape.x = _startx; + c4Shape.y = _starty; + this.updateVal(this.data, "startx", _startx, Math.min); + this.updateVal(this.data, "starty", _starty, Math.min); + this.updateVal(this.data, "stopx", _stopx, Math.max); + this.updateVal(this.data, "stopy", _stopy, Math.max); + this.updateVal(this.nextData, "startx", _startx, Math.min); + this.updateVal(this.nextData, "starty", _starty, Math.min); + this.updateVal(this.nextData, "stopx", _stopx, Math.max); + this.updateVal(this.nextData, "stopy", _stopy, Math.max); + } + init(diagObj) { + this.name = ""; + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0, + widthLimit: void 0 + }; + this.nextData = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0, + cnt: 0 + }; + setConf(diagObj.db.getConfig()); + } + bumpLastMargin(margin) { + this.data.stopx += margin; + this.data.stopy += margin; + } +} +const setConf = function(cnf) { + assignWithDepth$1(conf, cnf); + if (cnf.fontFamily) { + conf.personFontFamily = conf.systemFontFamily = conf.messageFontFamily = cnf.fontFamily; + } + if (cnf.fontSize) { + conf.personFontSize = conf.systemFontSize = conf.messageFontSize = cnf.fontSize; + } + if (cnf.fontWeight) { + conf.personFontWeight = conf.systemFontWeight = conf.messageFontWeight = cnf.fontWeight; + } +}; +const c4ShapeFont = (cnf, typeC4Shape) => { + return { + fontFamily: cnf[typeC4Shape + "FontFamily"], + fontSize: cnf[typeC4Shape + "FontSize"], + fontWeight: cnf[typeC4Shape + "FontWeight"] + }; +}; +const boundaryFont = (cnf) => { + return { + fontFamily: cnf.boundaryFontFamily, + fontSize: cnf.boundaryFontSize, + fontWeight: cnf.boundaryFontWeight + }; +}; +const messageFont = (cnf) => { + return { + fontFamily: cnf.messageFontFamily, + fontSize: cnf.messageFontSize, + fontWeight: cnf.messageFontWeight + }; +}; +function calcC4ShapeTextWH(textType, c4Shape, c4ShapeTextWrap, textConf, textLimitWidth) { + if (!c4Shape[textType].width) { + if (c4ShapeTextWrap) { + c4Shape[textType].text = wrapLabel(c4Shape[textType].text, textLimitWidth, textConf); + c4Shape[textType].textLines = c4Shape[textType].text.split(common$1.lineBreakRegex).length; + c4Shape[textType].width = textLimitWidth; + c4Shape[textType].height = calculateTextHeight(c4Shape[textType].text, textConf); + } else { + let lines = c4Shape[textType].text.split(common$1.lineBreakRegex); + c4Shape[textType].textLines = lines.length; + let lineHeight = 0; + c4Shape[textType].height = 0; + c4Shape[textType].width = 0; + for (const line of lines) { + c4Shape[textType].width = Math.max( + calculateTextWidth(line, textConf), + c4Shape[textType].width + ); + lineHeight = calculateTextHeight(line, textConf); + c4Shape[textType].height = c4Shape[textType].height + lineHeight; + } + } + } +} +const drawBoundary = function(diagram2, boundary, bounds) { + boundary.x = bounds.data.startx; + boundary.y = bounds.data.starty; + boundary.width = bounds.data.stopx - bounds.data.startx; + boundary.height = bounds.data.stopy - bounds.data.starty; + boundary.label.y = conf.c4ShapeMargin - 35; + let boundaryTextWrap = boundary.wrap && conf.wrap; + let boundaryLabelConf = boundaryFont(conf); + boundaryLabelConf.fontSize = boundaryLabelConf.fontSize + 2; + boundaryLabelConf.fontWeight = "bold"; + let textLimitWidth = calculateTextWidth(boundary.label.text, boundaryLabelConf); + calcC4ShapeTextWH("label", boundary, boundaryTextWrap, boundaryLabelConf, textLimitWidth); + svgDraw.drawBoundary(diagram2, boundary, conf); +}; +const drawC4ShapeArray = function(currentBounds, diagram2, c4ShapeArray2, c4ShapeKeys) { + let Y = 0; + for (const c4ShapeKey of c4ShapeKeys) { + Y = 0; + const c4Shape = c4ShapeArray2[c4ShapeKey]; + let c4ShapeTypeConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + c4ShapeTypeConf.fontSize = c4ShapeTypeConf.fontSize - 2; + c4Shape.typeC4Shape.width = calculateTextWidth( + "«" + c4Shape.typeC4Shape.text + "»", + c4ShapeTypeConf + ); + c4Shape.typeC4Shape.height = c4ShapeTypeConf.fontSize + 2; + c4Shape.typeC4Shape.Y = conf.c4ShapePadding; + Y = c4Shape.typeC4Shape.Y + c4Shape.typeC4Shape.height - 4; + c4Shape.image = { width: 0, height: 0, Y: 0 }; + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + c4Shape.image.width = 48; + c4Shape.image.height = 48; + c4Shape.image.Y = Y; + Y = c4Shape.image.Y + c4Shape.image.height; + break; + } + if (c4Shape.sprite) { + c4Shape.image.width = 48; + c4Shape.image.height = 48; + c4Shape.image.Y = Y; + Y = c4Shape.image.Y + c4Shape.image.height; + } + let c4ShapeTextWrap = c4Shape.wrap && conf.wrap; + let textLimitWidth = conf.width - conf.c4ShapePadding * 2; + let c4ShapeLabelConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + c4ShapeLabelConf.fontSize = c4ShapeLabelConf.fontSize + 2; + c4ShapeLabelConf.fontWeight = "bold"; + calcC4ShapeTextWH("label", c4Shape, c4ShapeTextWrap, c4ShapeLabelConf, textLimitWidth); + c4Shape["label"].Y = Y + 8; + Y = c4Shape["label"].Y + c4Shape["label"].height; + if (c4Shape.type && c4Shape.type.text !== "") { + c4Shape.type.text = "[" + c4Shape.type.text + "]"; + let c4ShapeTypeConf2 = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + calcC4ShapeTextWH("type", c4Shape, c4ShapeTextWrap, c4ShapeTypeConf2, textLimitWidth); + c4Shape["type"].Y = Y + 5; + Y = c4Shape["type"].Y + c4Shape["type"].height; + } else if (c4Shape.techn && c4Shape.techn.text !== "") { + c4Shape.techn.text = "[" + c4Shape.techn.text + "]"; + let c4ShapeTechnConf = c4ShapeFont(conf, c4Shape.techn.text); + calcC4ShapeTextWH("techn", c4Shape, c4ShapeTextWrap, c4ShapeTechnConf, textLimitWidth); + c4Shape["techn"].Y = Y + 5; + Y = c4Shape["techn"].Y + c4Shape["techn"].height; + } + let rectHeight = Y; + let rectWidth = c4Shape.label.width; + if (c4Shape.descr && c4Shape.descr.text !== "") { + let c4ShapeDescrConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text); + calcC4ShapeTextWH("descr", c4Shape, c4ShapeTextWrap, c4ShapeDescrConf, textLimitWidth); + c4Shape["descr"].Y = Y + 20; + Y = c4Shape["descr"].Y + c4Shape["descr"].height; + rectWidth = Math.max(c4Shape.label.width, c4Shape.descr.width); + rectHeight = Y - c4Shape["descr"].textLines * 5; + } + rectWidth = rectWidth + conf.c4ShapePadding; + c4Shape.width = Math.max(c4Shape.width || conf.width, rectWidth, conf.width); + c4Shape.height = Math.max(c4Shape.height || conf.height, rectHeight, conf.height); + c4Shape.margin = c4Shape.margin || conf.c4ShapeMargin; + currentBounds.insert(c4Shape); + svgDraw.drawC4Shape(diagram2, c4Shape, conf); + } + currentBounds.bumpLastMargin(conf.c4ShapeMargin); +}; +class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } +} +let getIntersectPoint = function(fromNode, endPoint) { + let x1 = fromNode.x; + let y1 = fromNode.y; + let x2 = endPoint.x; + let y2 = endPoint.y; + let fromCenterX = x1 + fromNode.width / 2; + let fromCenterY = y1 + fromNode.height / 2; + let dx = Math.abs(x1 - x2); + let dy = Math.abs(y1 - y2); + let tanDYX = dy / dx; + let fromDYX = fromNode.height / fromNode.width; + let returnPoint = null; + if (y1 == y2 && x1 < x2) { + returnPoint = new Point(x1 + fromNode.width, fromCenterY); + } else if (y1 == y2 && x1 > x2) { + returnPoint = new Point(x1, fromCenterY); + } else if (x1 == x2 && y1 < y2) { + returnPoint = new Point(fromCenterX, y1 + fromNode.height); + } else if (x1 == x2 && y1 > y2) { + returnPoint = new Point(fromCenterX, y1); + } + if (x1 > x2 && y1 < y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1, fromCenterY + tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point( + fromCenterX - dx / dy * fromNode.height / 2, + y1 + fromNode.height + ); + } + } else if (x1 < x2 && y1 < y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1 + fromNode.width, fromCenterY + tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point( + fromCenterX + dx / dy * fromNode.height / 2, + y1 + fromNode.height + ); + } + } else if (x1 < x2 && y1 > y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1 + fromNode.width, fromCenterY - tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point(fromCenterX + fromNode.height / 2 * dx / dy, y1); + } + } else if (x1 > x2 && y1 > y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point(x1, fromCenterY - fromNode.width / 2 * tanDYX); + } else { + returnPoint = new Point(fromCenterX - fromNode.height / 2 * dx / dy, y1); + } + } + return returnPoint; +}; +let getIntersectPoints = function(fromNode, endNode) { + let endIntersectPoint = { x: 0, y: 0 }; + endIntersectPoint.x = endNode.x + endNode.width / 2; + endIntersectPoint.y = endNode.y + endNode.height / 2; + let startPoint = getIntersectPoint(fromNode, endIntersectPoint); + endIntersectPoint.x = fromNode.x + fromNode.width / 2; + endIntersectPoint.y = fromNode.y + fromNode.height / 2; + let endPoint = getIntersectPoint(endNode, endIntersectPoint); + return { startPoint, endPoint }; +}; +const drawRels = function(diagram2, rels2, getC4ShapeObj, diagObj) { + let i = 0; + for (let rel of rels2) { + i = i + 1; + let relTextWrap = rel.wrap && conf.wrap; + let relConf = messageFont(conf); + let diagramType = diagObj.db.getC4Type(); + if (diagramType === "C4Dynamic") { + rel.label.text = i + ": " + rel.label.text; + } + let textLimitWidth = calculateTextWidth(rel.label.text, relConf); + calcC4ShapeTextWH("label", rel, relTextWrap, relConf, textLimitWidth); + if (rel.techn && rel.techn.text !== "") { + textLimitWidth = calculateTextWidth(rel.techn.text, relConf); + calcC4ShapeTextWH("techn", rel, relTextWrap, relConf, textLimitWidth); + } + if (rel.descr && rel.descr.text !== "") { + textLimitWidth = calculateTextWidth(rel.descr.text, relConf); + calcC4ShapeTextWH("descr", rel, relTextWrap, relConf, textLimitWidth); + } + let fromNode = getC4ShapeObj(rel.from); + let endNode = getC4ShapeObj(rel.to); + let points = getIntersectPoints(fromNode, endNode); + rel.startPoint = points.startPoint; + rel.endPoint = points.endPoint; + } + svgDraw.drawRels(diagram2, rels2, conf); +}; +function drawInsideBoundary(diagram2, parentBoundaryAlias, parentBounds, currentBoundaries, diagObj) { + let currentBounds = new Bounds(diagObj); + currentBounds.data.widthLimit = parentBounds.data.widthLimit / Math.min(c4BoundaryInRow, currentBoundaries.length); + for (let [i, currentBoundary] of currentBoundaries.entries()) { + let Y = 0; + currentBoundary.image = { width: 0, height: 0, Y: 0 }; + if (currentBoundary.sprite) { + currentBoundary.image.width = 48; + currentBoundary.image.height = 48; + currentBoundary.image.Y = Y; + Y = currentBoundary.image.Y + currentBoundary.image.height; + } + let currentBoundaryTextWrap = currentBoundary.wrap && conf.wrap; + let currentBoundaryLabelConf = boundaryFont(conf); + currentBoundaryLabelConf.fontSize = currentBoundaryLabelConf.fontSize + 2; + currentBoundaryLabelConf.fontWeight = "bold"; + calcC4ShapeTextWH( + "label", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryLabelConf, + currentBounds.data.widthLimit + ); + currentBoundary["label"].Y = Y + 8; + Y = currentBoundary["label"].Y + currentBoundary["label"].height; + if (currentBoundary.type && currentBoundary.type.text !== "") { + currentBoundary.type.text = "[" + currentBoundary.type.text + "]"; + let currentBoundaryTypeConf = boundaryFont(conf); + calcC4ShapeTextWH( + "type", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryTypeConf, + currentBounds.data.widthLimit + ); + currentBoundary["type"].Y = Y + 5; + Y = currentBoundary["type"].Y + currentBoundary["type"].height; + } + if (currentBoundary.descr && currentBoundary.descr.text !== "") { + let currentBoundaryDescrConf = boundaryFont(conf); + currentBoundaryDescrConf.fontSize = currentBoundaryDescrConf.fontSize - 2; + calcC4ShapeTextWH( + "descr", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryDescrConf, + currentBounds.data.widthLimit + ); + currentBoundary["descr"].Y = Y + 20; + Y = currentBoundary["descr"].Y + currentBoundary["descr"].height; + } + if (i == 0 || i % c4BoundaryInRow === 0) { + let _x = parentBounds.data.startx + conf.diagramMarginX; + let _y = parentBounds.data.stopy + conf.diagramMarginY + Y; + currentBounds.setData(_x, _x, _y, _y); + } else { + let _x = currentBounds.data.stopx !== currentBounds.data.startx ? currentBounds.data.stopx + conf.diagramMarginX : currentBounds.data.startx; + let _y = currentBounds.data.starty; + currentBounds.setData(_x, _x, _y, _y); + } + currentBounds.name = currentBoundary.alias; + let currentPersonOrSystemArray = diagObj.db.getC4ShapeArray(currentBoundary.alias); + let currentPersonOrSystemKeys = diagObj.db.getC4ShapeKeys(currentBoundary.alias); + if (currentPersonOrSystemKeys.length > 0) { + drawC4ShapeArray( + currentBounds, + diagram2, + currentPersonOrSystemArray, + currentPersonOrSystemKeys + ); + } + parentBoundaryAlias = currentBoundary.alias; + let nextCurrentBoundaries = diagObj.db.getBoundarys(parentBoundaryAlias); + if (nextCurrentBoundaries.length > 0) { + drawInsideBoundary( + diagram2, + parentBoundaryAlias, + currentBounds, + nextCurrentBoundaries, + diagObj + ); + } + if (currentBoundary.alias !== "global") { + drawBoundary(diagram2, currentBoundary, currentBounds); + } + parentBounds.data.stopy = Math.max( + currentBounds.data.stopy + conf.c4ShapeMargin, + parentBounds.data.stopy + ); + parentBounds.data.stopx = Math.max( + currentBounds.data.stopx + conf.c4ShapeMargin, + parentBounds.data.stopx + ); + globalBoundaryMaxX = Math.max(globalBoundaryMaxX, parentBounds.data.stopx); + globalBoundaryMaxY = Math.max(globalBoundaryMaxY, parentBounds.data.stopy); + } +} +const draw = function(_text, id, _version, diagObj) { + conf = getConfig().c4; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + let db2 = diagObj.db; + diagObj.db.setWrap(conf.wrap); + c4ShapeInRow = db2.getC4ShapeInRow(); + c4BoundaryInRow = db2.getC4BoundaryInRow(); + log$1.debug(`C:${JSON.stringify(conf, null, 2)}`); + const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + svgDraw.insertComputerIcon(diagram2); + svgDraw.insertDatabaseIcon(diagram2); + svgDraw.insertClockIcon(diagram2); + let screenBounds = new Bounds(diagObj); + screenBounds.setData( + conf.diagramMarginX, + conf.diagramMarginX, + conf.diagramMarginY, + conf.diagramMarginY + ); + screenBounds.data.widthLimit = screen.availWidth; + globalBoundaryMaxX = conf.diagramMarginX; + globalBoundaryMaxY = conf.diagramMarginY; + const title2 = diagObj.db.getTitle(); + let currentBoundaries = diagObj.db.getBoundarys(""); + drawInsideBoundary(diagram2, "", screenBounds, currentBoundaries, diagObj); + svgDraw.insertArrowHead(diagram2); + svgDraw.insertArrowEnd(diagram2); + svgDraw.insertArrowCrossHead(diagram2); + svgDraw.insertArrowFilledHead(diagram2); + drawRels(diagram2, diagObj.db.getRels(), diagObj.db.getC4Shape, diagObj); + screenBounds.data.stopx = globalBoundaryMaxX; + screenBounds.data.stopy = globalBoundaryMaxY; + const box = screenBounds.data; + let boxHeight = box.stopy - box.starty; + let height = boxHeight + 2 * conf.diagramMarginY; + let boxWidth = box.stopx - box.startx; + const width = boxWidth + 2 * conf.diagramMarginX; + if (title2) { + diagram2.append("text").text(title2).attr("x", (box.stopx - box.startx) / 2 - 4 * conf.diagramMarginX).attr("y", box.starty + conf.diagramMarginY); + } + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const extraVertForTitle = title2 ? 60 : 0; + diagram2.attr( + "viewBox", + box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle) + ); + log$1.debug(`models:`, box); +}; +const renderer = { + drawPersonOrSystemArray: drawC4ShapeArray, + drawBoundary, + setConf, + draw +}; +const getStyles = (options) => `.person { + stroke: ${options.personBorder}; + fill: ${options.personBkg}; + } +`; +const styles = getStyles; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: ({ c4, wrap }) => { + renderer.setConf(c4); + db.setWrap(wrap); + } +}; + +export { diagram }; diff --git a/libs/marked/channel-BxFDB0yY.js b/libs/marked/channel-BxFDB0yY.js new file mode 100644 index 0000000..4f6ffc2 --- /dev/null +++ b/libs/marked/channel-BxFDB0yY.js @@ -0,0 +1,9 @@ +import { aH as Utils, aI as Color } from './index-Bd_FDXSq.js'; + +/* IMPORT */ +/* MAIN */ +const channel = (color, channel) => { + return Utils.lang.round(Color.parse(color)[channel]); +}; + +export { channel as c }; diff --git a/libs/marked/channel-DcrZctv4.js b/libs/marked/channel-DcrZctv4.js new file mode 100644 index 0000000..bf07730 --- /dev/null +++ b/libs/marked/channel-DcrZctv4.js @@ -0,0 +1,9 @@ +import { aH as Utils, aI as Color } from './index-CN3YjQ0n.js'; + +/* IMPORT */ +/* MAIN */ +const channel = (color, channel) => { + return Utils.lang.round(Color.parse(color)[channel]); +}; + +export { channel as c }; diff --git a/libs/marked/classDiagram-fb54d2a0--Qxwqbp1.js b/libs/marked/classDiagram-fb54d2a0--Qxwqbp1.js new file mode 100644 index 0000000..e01333b --- /dev/null +++ b/libs/marked/classDiagram-fb54d2a0--Qxwqbp1.js @@ -0,0 +1,356 @@ +import { p as parser$1, d as db, s as styles } from './styles-b83b31c9-CoATnBwl.js'; +import { c as getConfig, l as log$1, h as select, i as configureSvgSize, F as curveBasis, A as utils, G as parseGenericTypes } from './index-Bd_FDXSq.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { l as layout } from './layout-BnytXFfq.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +let edgeCount = 0; +const drawEdge = function(elem, path, relation, conf, diagObj) { + const getRelationType = function(type) { + switch (type) { + case diagObj.db.relationType.AGGREGATION: + return "aggregation"; + case diagObj.db.relationType.EXTENSION: + return "extension"; + case diagObj.db.relationType.COMPOSITION: + return "composition"; + case diagObj.db.relationType.DEPENDENCY: + return "dependency"; + case diagObj.db.relationType.LOLLIPOP: + return "lollipop"; + } + }; + path.points = path.points.filter((p) => !Number.isNaN(p.y)); + const lineData = path.points; + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "relation"); + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + if (relation.relation.lineType == 1) { + svgPath.attr("class", "relation dashed-line"); + } + if (relation.relation.lineType == 10) { + svgPath.attr("class", "relation dotted-line"); + } + if (relation.relation.type1 !== "none") { + svgPath.attr( + "marker-start", + "url(" + url + "#" + getRelationType(relation.relation.type1) + "Start)" + ); + } + if (relation.relation.type2 !== "none") { + svgPath.attr( + "marker-end", + "url(" + url + "#" + getRelationType(relation.relation.type2) + "End)" + ); + } + let x, y; + const l = path.points.length; + let labelPosition = utils.calcLabelPosition(path.points); + x = labelPosition.x; + y = labelPosition.y; + let p1_card_x, p1_card_y; + let p2_card_x, p2_card_y; + if (l % 2 !== 0 && l > 1) { + let cardinality_1_point = utils.calcCardinalityPosition( + relation.relation.type1 !== "none", + path.points, + path.points[0] + ); + let cardinality_2_point = utils.calcCardinalityPosition( + relation.relation.type2 !== "none", + path.points, + path.points[l - 1] + ); + log$1.debug("cardinality_1_point " + JSON.stringify(cardinality_1_point)); + log$1.debug("cardinality_2_point " + JSON.stringify(cardinality_2_point)); + p1_card_x = cardinality_1_point.x; + p1_card_y = cardinality_1_point.y; + p2_card_x = cardinality_2_point.x; + p2_card_y = cardinality_2_point.y; + } + if (relation.title !== void 0) { + const g = elem.append("g").attr("class", "classLabel"); + const label = g.append("text").attr("class", "label").attr("x", x).attr("y", y).attr("fill", "red").attr("text-anchor", "middle").text(relation.title); + window.label = label; + const bounds = label.node().getBBox(); + g.insert("rect", ":first-child").attr("class", "box").attr("x", bounds.x - conf.padding / 2).attr("y", bounds.y - conf.padding / 2).attr("width", bounds.width + conf.padding).attr("height", bounds.height + conf.padding); + } + log$1.info("Rendering relation " + JSON.stringify(relation)); + if (relation.relationTitle1 !== void 0 && relation.relationTitle1 !== "none") { + const g = elem.append("g").attr("class", "cardinality"); + g.append("text").attr("class", "type1").attr("x", p1_card_x).attr("y", p1_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle1); + } + if (relation.relationTitle2 !== void 0 && relation.relationTitle2 !== "none") { + const g = elem.append("g").attr("class", "cardinality"); + g.append("text").attr("class", "type2").attr("x", p2_card_x).attr("y", p2_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle2); + } + edgeCount++; +}; +const drawClass = function(elem, classDef, conf, diagObj) { + log$1.debug("Rendering class ", classDef, conf); + const id = classDef.id; + const classInfo = { + id, + label: classDef.id, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", diagObj.db.lookUpDomId(id)).attr("class", "classGroup"); + let title; + if (classDef.link) { + title = g.append("svg:a").attr("xlink:href", classDef.link).attr("target", classDef.linkTarget).append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + } else { + title = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + } + let isFirst = true; + classDef.annotations.forEach(function(member) { + const titleText2 = title.append("tspan").text("«" + member + "»"); + if (!isFirst) { + titleText2.attr("dy", conf.textHeight); + } + isFirst = false; + }); + let classTitleString = getClassTitleString(classDef); + const classTitle = title.append("tspan").text(classTitleString).attr("class", "title"); + if (!isFirst) { + classTitle.attr("dy", conf.textHeight); + } + const titleHeight = title.node().getBBox().height; + let membersLine; + let membersBox; + let methodsLine; + if (classDef.members.length > 0) { + membersLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin / 2).attr("y2", conf.padding + titleHeight + conf.dividerMargin / 2); + const members = g.append("text").attr("x", conf.padding).attr("y", titleHeight + conf.dividerMargin + conf.textHeight).attr("fill", "white").attr("class", "classText"); + isFirst = true; + classDef.members.forEach(function(member) { + addTspan(members, member, isFirst, conf); + isFirst = false; + }); + membersBox = members.node().getBBox(); + } + if (classDef.methods.length > 0) { + methodsLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin + membersBox.height).attr("y2", conf.padding + titleHeight + conf.dividerMargin + membersBox.height); + const methods = g.append("text").attr("x", conf.padding).attr("y", titleHeight + 2 * conf.dividerMargin + membersBox.height + conf.textHeight).attr("fill", "white").attr("class", "classText"); + isFirst = true; + classDef.methods.forEach(function(method) { + addTspan(methods, method, isFirst, conf); + isFirst = false; + }); + } + const classBox = g.node().getBBox(); + var cssClassStr = " "; + if (classDef.cssClasses.length > 0) { + cssClassStr = cssClassStr + classDef.cssClasses.join(" "); + } + const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", classBox.width + 2 * conf.padding).attr("height", classBox.height + conf.padding + 0.5 * conf.dividerMargin).attr("class", cssClassStr); + const rectWidth = rect.node().getBBox().width; + title.node().childNodes.forEach(function(x) { + x.setAttribute("x", (rectWidth - x.getBBox().width) / 2); + }); + if (classDef.tooltip) { + title.insert("title").text(classDef.tooltip); + } + if (membersLine) { + membersLine.attr("x2", rectWidth); + } + if (methodsLine) { + methodsLine.attr("x2", rectWidth); + } + classInfo.width = rectWidth; + classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin; + return classInfo; +}; +const getClassTitleString = function(classDef) { + let classTitleString = classDef.id; + if (classDef.type) { + classTitleString += "<" + parseGenericTypes(classDef.type) + ">"; + } + return classTitleString; +}; +const drawNote = function(elem, note, conf, diagObj) { + log$1.debug("Rendering note ", note, conf); + const id = note.id; + const noteInfo = { + id, + text: note.text, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", id).attr("class", "classGroup"); + let text = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + const lines = JSON.parse(`"${note.text}"`).split("\n"); + lines.forEach(function(line2) { + log$1.debug(`Adding line: ${line2}`); + text.append("tspan").text(line2).attr("class", "title").attr("dy", conf.textHeight); + }); + const noteBox = g.node().getBBox(); + const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", noteBox.width + 2 * conf.padding).attr( + "height", + noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin + ); + const rectWidth = rect.node().getBBox().width; + text.node().childNodes.forEach(function(x) { + x.setAttribute("x", (rectWidth - x.getBBox().width) / 2); + }); + noteInfo.width = rectWidth; + noteInfo.height = noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin; + return noteInfo; +}; +const addTspan = function(textEl, member, isFirst, conf) { + const { displayText, cssStyle } = member.getDisplayDetails(); + const tSpan = textEl.append("tspan").attr("x", conf.padding).text(displayText); + if (cssStyle !== "") { + tSpan.attr("style", member.cssStyle); + } + if (!isFirst) { + tSpan.attr("dy", conf.textHeight); + } +}; +const svgDraw = { + getClassTitleString, + drawClass, + drawEdge, + drawNote +}; +let idCache = {}; +const padding = 20; +const getGraphId = function(label) { + const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label); + if (foundEntry) { + return foundEntry[0]; + } +}; +const insertMarkers = function(elem) { + elem.append("defs").append("marker").attr("id", "extensionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"); + elem.append("defs").append("marker").attr("id", "extensionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"); + elem.append("defs").append("marker").attr("id", "compositionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "compositionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "aggregationStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "aggregationEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "dependencyStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const draw = function(text, id, _version, diagObj) { + const conf = getConfig().class; + idCache = {}; + log$1.info("Rendering diagram " + text); + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const diagram2 = root.select(`[id='${id}']`); + insertMarkers(diagram2); + const g = new Graph({ + multigraph: true + }); + g.setGraph({ + isMultiGraph: true + }); + g.setDefaultEdgeLabel(function() { + return {}; + }); + const classes = diagObj.db.getClasses(); + const keys = Object.keys(classes); + for (const key of keys) { + const classDef = classes[key]; + const node = svgDraw.drawClass(diagram2, classDef, conf, diagObj); + idCache[node.id] = node; + g.setNode(node.id, node); + log$1.info("Org height: " + node.height); + } + const relations = diagObj.db.getRelations(); + relations.forEach(function(relation) { + log$1.info( + // cspell:ignore tjoho + "tjoho" + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation) + ); + g.setEdge( + getGraphId(relation.id1), + getGraphId(relation.id2), + { + relation + }, + relation.title || "DEFAULT" + ); + }); + const notes = diagObj.db.getNotes(); + notes.forEach(function(note) { + log$1.debug(`Adding note: ${JSON.stringify(note)}`); + const node = svgDraw.drawNote(diagram2, note, conf, diagObj); + idCache[node.id] = node; + g.setNode(node.id, node); + if (note.class && note.class in classes) { + g.setEdge( + note.id, + getGraphId(note.class), + { + relation: { + id1: note.id, + id2: note.class, + relation: { + type1: "none", + type2: "none", + lineType: 10 + } + } + }, + "DEFAULT" + ); + } + }); + layout(g); + g.nodes().forEach(function(v) { + if (v !== void 0 && g.node(v) !== void 0) { + log$1.debug("Node " + v + ": " + JSON.stringify(g.node(v))); + root.select("#" + (diagObj.db.lookUpDomId(v) || v)).attr( + "transform", + "translate(" + (g.node(v).x - g.node(v).width / 2) + "," + (g.node(v).y - g.node(v).height / 2) + " )" + ); + } + }); + g.edges().forEach(function(e) { + if (e !== void 0 && g.edge(e) !== void 0) { + log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(g.edge(e))); + svgDraw.drawEdge(diagram2, g.edge(e), g.edge(e).relation, conf, diagObj); + } + }); + const svgBounds = diagram2.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`; + log$1.debug(`viewBox ${vBox}`); + diagram2.attr("viewBox", vBox); +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.class) { + cnf.class = {}; + } + cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/classDiagram-fb54d2a0-ihSKvW6J.js b/libs/marked/classDiagram-fb54d2a0-ihSKvW6J.js new file mode 100644 index 0000000..24e113b --- /dev/null +++ b/libs/marked/classDiagram-fb54d2a0-ihSKvW6J.js @@ -0,0 +1,356 @@ +import { p as parser$1, d as db, s as styles } from './styles-b83b31c9-BFSyAItk.js'; +import { c as getConfig, l as log$1, h as select, i as configureSvgSize, F as curveBasis, A as utils, G as parseGenericTypes } from './index-CN3YjQ0n.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { l as layout } from './layout-BOZlZI7g.js'; +import { l as line } from './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +let edgeCount = 0; +const drawEdge = function(elem, path, relation, conf, diagObj) { + const getRelationType = function(type) { + switch (type) { + case diagObj.db.relationType.AGGREGATION: + return "aggregation"; + case diagObj.db.relationType.EXTENSION: + return "extension"; + case diagObj.db.relationType.COMPOSITION: + return "composition"; + case diagObj.db.relationType.DEPENDENCY: + return "dependency"; + case diagObj.db.relationType.LOLLIPOP: + return "lollipop"; + } + }; + path.points = path.points.filter((p) => !Number.isNaN(p.y)); + const lineData = path.points; + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "relation"); + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + if (relation.relation.lineType == 1) { + svgPath.attr("class", "relation dashed-line"); + } + if (relation.relation.lineType == 10) { + svgPath.attr("class", "relation dotted-line"); + } + if (relation.relation.type1 !== "none") { + svgPath.attr( + "marker-start", + "url(" + url + "#" + getRelationType(relation.relation.type1) + "Start)" + ); + } + if (relation.relation.type2 !== "none") { + svgPath.attr( + "marker-end", + "url(" + url + "#" + getRelationType(relation.relation.type2) + "End)" + ); + } + let x, y; + const l = path.points.length; + let labelPosition = utils.calcLabelPosition(path.points); + x = labelPosition.x; + y = labelPosition.y; + let p1_card_x, p1_card_y; + let p2_card_x, p2_card_y; + if (l % 2 !== 0 && l > 1) { + let cardinality_1_point = utils.calcCardinalityPosition( + relation.relation.type1 !== "none", + path.points, + path.points[0] + ); + let cardinality_2_point = utils.calcCardinalityPosition( + relation.relation.type2 !== "none", + path.points, + path.points[l - 1] + ); + log$1.debug("cardinality_1_point " + JSON.stringify(cardinality_1_point)); + log$1.debug("cardinality_2_point " + JSON.stringify(cardinality_2_point)); + p1_card_x = cardinality_1_point.x; + p1_card_y = cardinality_1_point.y; + p2_card_x = cardinality_2_point.x; + p2_card_y = cardinality_2_point.y; + } + if (relation.title !== void 0) { + const g = elem.append("g").attr("class", "classLabel"); + const label = g.append("text").attr("class", "label").attr("x", x).attr("y", y).attr("fill", "red").attr("text-anchor", "middle").text(relation.title); + window.label = label; + const bounds = label.node().getBBox(); + g.insert("rect", ":first-child").attr("class", "box").attr("x", bounds.x - conf.padding / 2).attr("y", bounds.y - conf.padding / 2).attr("width", bounds.width + conf.padding).attr("height", bounds.height + conf.padding); + } + log$1.info("Rendering relation " + JSON.stringify(relation)); + if (relation.relationTitle1 !== void 0 && relation.relationTitle1 !== "none") { + const g = elem.append("g").attr("class", "cardinality"); + g.append("text").attr("class", "type1").attr("x", p1_card_x).attr("y", p1_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle1); + } + if (relation.relationTitle2 !== void 0 && relation.relationTitle2 !== "none") { + const g = elem.append("g").attr("class", "cardinality"); + g.append("text").attr("class", "type2").attr("x", p2_card_x).attr("y", p2_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle2); + } + edgeCount++; +}; +const drawClass = function(elem, classDef, conf, diagObj) { + log$1.debug("Rendering class ", classDef, conf); + const id = classDef.id; + const classInfo = { + id, + label: classDef.id, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", diagObj.db.lookUpDomId(id)).attr("class", "classGroup"); + let title; + if (classDef.link) { + title = g.append("svg:a").attr("xlink:href", classDef.link).attr("target", classDef.linkTarget).append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + } else { + title = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + } + let isFirst = true; + classDef.annotations.forEach(function(member) { + const titleText2 = title.append("tspan").text("«" + member + "»"); + if (!isFirst) { + titleText2.attr("dy", conf.textHeight); + } + isFirst = false; + }); + let classTitleString = getClassTitleString(classDef); + const classTitle = title.append("tspan").text(classTitleString).attr("class", "title"); + if (!isFirst) { + classTitle.attr("dy", conf.textHeight); + } + const titleHeight = title.node().getBBox().height; + let membersLine; + let membersBox; + let methodsLine; + if (classDef.members.length > 0) { + membersLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin / 2).attr("y2", conf.padding + titleHeight + conf.dividerMargin / 2); + const members = g.append("text").attr("x", conf.padding).attr("y", titleHeight + conf.dividerMargin + conf.textHeight).attr("fill", "white").attr("class", "classText"); + isFirst = true; + classDef.members.forEach(function(member) { + addTspan(members, member, isFirst, conf); + isFirst = false; + }); + membersBox = members.node().getBBox(); + } + if (classDef.methods.length > 0) { + methodsLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin + membersBox.height).attr("y2", conf.padding + titleHeight + conf.dividerMargin + membersBox.height); + const methods = g.append("text").attr("x", conf.padding).attr("y", titleHeight + 2 * conf.dividerMargin + membersBox.height + conf.textHeight).attr("fill", "white").attr("class", "classText"); + isFirst = true; + classDef.methods.forEach(function(method) { + addTspan(methods, method, isFirst, conf); + isFirst = false; + }); + } + const classBox = g.node().getBBox(); + var cssClassStr = " "; + if (classDef.cssClasses.length > 0) { + cssClassStr = cssClassStr + classDef.cssClasses.join(" "); + } + const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", classBox.width + 2 * conf.padding).attr("height", classBox.height + conf.padding + 0.5 * conf.dividerMargin).attr("class", cssClassStr); + const rectWidth = rect.node().getBBox().width; + title.node().childNodes.forEach(function(x) { + x.setAttribute("x", (rectWidth - x.getBBox().width) / 2); + }); + if (classDef.tooltip) { + title.insert("title").text(classDef.tooltip); + } + if (membersLine) { + membersLine.attr("x2", rectWidth); + } + if (methodsLine) { + methodsLine.attr("x2", rectWidth); + } + classInfo.width = rectWidth; + classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin; + return classInfo; +}; +const getClassTitleString = function(classDef) { + let classTitleString = classDef.id; + if (classDef.type) { + classTitleString += "<" + parseGenericTypes(classDef.type) + ">"; + } + return classTitleString; +}; +const drawNote = function(elem, note, conf, diagObj) { + log$1.debug("Rendering note ", note, conf); + const id = note.id; + const noteInfo = { + id, + text: note.text, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", id).attr("class", "classGroup"); + let text = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + const lines = JSON.parse(`"${note.text}"`).split("\n"); + lines.forEach(function(line2) { + log$1.debug(`Adding line: ${line2}`); + text.append("tspan").text(line2).attr("class", "title").attr("dy", conf.textHeight); + }); + const noteBox = g.node().getBBox(); + const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", noteBox.width + 2 * conf.padding).attr( + "height", + noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin + ); + const rectWidth = rect.node().getBBox().width; + text.node().childNodes.forEach(function(x) { + x.setAttribute("x", (rectWidth - x.getBBox().width) / 2); + }); + noteInfo.width = rectWidth; + noteInfo.height = noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin; + return noteInfo; +}; +const addTspan = function(textEl, member, isFirst, conf) { + const { displayText, cssStyle } = member.getDisplayDetails(); + const tSpan = textEl.append("tspan").attr("x", conf.padding).text(displayText); + if (cssStyle !== "") { + tSpan.attr("style", member.cssStyle); + } + if (!isFirst) { + tSpan.attr("dy", conf.textHeight); + } +}; +const svgDraw = { + getClassTitleString, + drawClass, + drawEdge, + drawNote +}; +let idCache = {}; +const padding = 20; +const getGraphId = function(label) { + const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label); + if (foundEntry) { + return foundEntry[0]; + } +}; +const insertMarkers = function(elem) { + elem.append("defs").append("marker").attr("id", "extensionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"); + elem.append("defs").append("marker").attr("id", "extensionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"); + elem.append("defs").append("marker").attr("id", "compositionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "compositionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "aggregationStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "aggregationEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "dependencyStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const draw = function(text, id, _version, diagObj) { + const conf = getConfig().class; + idCache = {}; + log$1.info("Rendering diagram " + text); + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const diagram2 = root.select(`[id='${id}']`); + insertMarkers(diagram2); + const g = new Graph({ + multigraph: true + }); + g.setGraph({ + isMultiGraph: true + }); + g.setDefaultEdgeLabel(function() { + return {}; + }); + const classes = diagObj.db.getClasses(); + const keys = Object.keys(classes); + for (const key of keys) { + const classDef = classes[key]; + const node = svgDraw.drawClass(diagram2, classDef, conf, diagObj); + idCache[node.id] = node; + g.setNode(node.id, node); + log$1.info("Org height: " + node.height); + } + const relations = diagObj.db.getRelations(); + relations.forEach(function(relation) { + log$1.info( + // cspell:ignore tjoho + "tjoho" + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation) + ); + g.setEdge( + getGraphId(relation.id1), + getGraphId(relation.id2), + { + relation + }, + relation.title || "DEFAULT" + ); + }); + const notes = diagObj.db.getNotes(); + notes.forEach(function(note) { + log$1.debug(`Adding note: ${JSON.stringify(note)}`); + const node = svgDraw.drawNote(diagram2, note, conf, diagObj); + idCache[node.id] = node; + g.setNode(node.id, node); + if (note.class && note.class in classes) { + g.setEdge( + note.id, + getGraphId(note.class), + { + relation: { + id1: note.id, + id2: note.class, + relation: { + type1: "none", + type2: "none", + lineType: 10 + } + } + }, + "DEFAULT" + ); + } + }); + layout(g); + g.nodes().forEach(function(v) { + if (v !== void 0 && g.node(v) !== void 0) { + log$1.debug("Node " + v + ": " + JSON.stringify(g.node(v))); + root.select("#" + (diagObj.db.lookUpDomId(v) || v)).attr( + "transform", + "translate(" + (g.node(v).x - g.node(v).width / 2) + "," + (g.node(v).y - g.node(v).height / 2) + " )" + ); + } + }); + g.edges().forEach(function(e) { + if (e !== void 0 && g.edge(e) !== void 0) { + log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(g.edge(e))); + svgDraw.drawEdge(diagram2, g.edge(e), g.edge(e).relation, conf, diagObj); + } + }); + const svgBounds = diagram2.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`; + log$1.debug(`viewBox ${vBox}`); + diagram2.attr("viewBox", vBox); +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.class) { + cnf.class = {}; + } + cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/classDiagram-v2-a2b738ad-Dl8Cj6T-.js b/libs/marked/classDiagram-v2-a2b738ad-Dl8Cj6T-.js new file mode 100644 index 0000000..2f1211b --- /dev/null +++ b/libs/marked/classDiagram-v2-a2b738ad-Dl8Cj6T-.js @@ -0,0 +1,290 @@ +import { p as parser$1, d as db, s as styles } from './styles-b83b31c9-BFSyAItk.js'; +import { l as log$1, c as getConfig, h as select, A as utils, t as setupGraphViewbox$1, o as getStylesFromArray, q as interpolateToCurve, n as curveLinear, j as common$1 } from './index-CN3YjQ0n.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { r as render } from './index-01f381cb-CDFlKdjO.js'; +import './layout-BOZlZI7g.js'; +import './clone-B4k62NSz.js'; +import './edges-066a5561-a6s42o55.js'; +import './createText-ca0c5216-DF05SDfj.js'; +import './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +const sanitizeText = (txt) => common$1.sanitizeText(txt, getConfig()); +let conf = { + dividerMargin: 10, + padding: 5, + textHeight: 10, + curve: void 0 +}; +const addNamespaces = function(namespaces, g, _id, diagObj) { + const keys = Object.keys(namespaces); + log$1.info("keys:", keys); + log$1.info(namespaces); + keys.forEach(function(id) { + var _a, _b; + const vertex = namespaces[id]; + const shape = "rect"; + const node = { + shape, + id: vertex.id, + domId: vertex.domId, + labelText: sanitizeText(vertex.id), + labelStyle: "", + style: "fill: none; stroke: black", + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + addClasses(vertex.classes, g, _id, diagObj, vertex.id); + log$1.info("setNode", node); + }); +}; +const addClasses = function(classes, g, _id, diagObj, parent) { + const keys = Object.keys(classes); + log$1.info("keys:", keys); + log$1.info(classes); + keys.filter((id) => classes[id].parent == parent).forEach(function(id) { + var _a, _b; + const vertex = classes[id]; + const cssClassStr = vertex.cssClasses.join(" "); + const styles2 = getStylesFromArray(vertex.styles); + const vertexText = vertex.label ?? vertex.id; + const radius = 0; + const shape = "class_box"; + const node = { + labelStyle: styles2.labelStyle, + shape, + labelText: sanitizeText(vertexText), + classData: vertex, + rx: radius, + ry: radius, + class: cssClassStr, + style: styles2.style, + id: vertex.id, + domId: vertex.domId, + tooltip: diagObj.db.getTooltip(vertex.id, parent) || "", + haveCallback: vertex.haveCallback, + link: vertex.link, + width: vertex.type === "group" ? 500 : void 0, + type: vertex.type, + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + if (parent) { + g.setParent(vertex.id, parent); + } + log$1.info("setNode", node); + }); +}; +const addNotes = function(notes, g, startEdgeId, classes) { + log$1.info(notes); + notes.forEach(function(note, i) { + var _a, _b; + const vertex = note; + const cssNoteStr = ""; + const styles2 = { labelStyle: "", style: "" }; + const vertexText = vertex.text; + const radius = 0; + const shape = "note"; + const node = { + labelStyle: styles2.labelStyle, + shape, + labelText: sanitizeText(vertexText), + noteData: vertex, + rx: radius, + ry: radius, + class: cssNoteStr, + style: styles2.style, + id: vertex.id, + domId: vertex.id, + tooltip: "", + type: "note", + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + log$1.info("setNode", node); + if (!vertex.class || !(vertex.class in classes)) { + return; + } + const edgeId = startEdgeId + i; + const edgeData = { + id: `edgeNote${edgeId}`, + //Set relationship style and line type + classes: "relation", + pattern: "dotted", + // Set link type for rendering + arrowhead: "none", + //Set edge extra labels + startLabelRight: "", + endLabelLeft: "", + //Set relation arrow types + arrowTypeStart: "none", + arrowTypeEnd: "none", + style: "fill:none", + labelStyle: "", + curve: interpolateToCurve(conf.curve, curveLinear) + }; + g.setEdge(vertex.id, vertex.class, edgeData, edgeId); + }); +}; +const addRelations = function(relations, g) { + const conf2 = getConfig().flowchart; + let cnt = 0; + relations.forEach(function(edge) { + var _a; + cnt++; + const edgeData = { + //Set relationship style and line type + classes: "relation", + pattern: edge.relation.lineType == 1 ? "dashed" : "solid", + id: `id_${edge.id1}_${edge.id2}_${cnt}`, + // Set link type for rendering + arrowhead: edge.type === "arrow_open" ? "none" : "normal", + //Set edge extra labels + startLabelRight: edge.relationTitle1 === "none" ? "" : edge.relationTitle1, + endLabelLeft: edge.relationTitle2 === "none" ? "" : edge.relationTitle2, + //Set relation arrow types + arrowTypeStart: getArrowMarker(edge.relation.type1), + arrowTypeEnd: getArrowMarker(edge.relation.type2), + style: "fill:none", + labelStyle: "", + curve: interpolateToCurve(conf2 == null ? void 0 : conf2.curve, curveLinear) + }; + log$1.info(edgeData, edge); + if (edge.style !== void 0) { + const styles2 = getStylesFromArray(edge.style); + edgeData.style = styles2.style; + edgeData.labelStyle = styles2.labelStyle; + } + edge.text = edge.title; + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + if (((_a = getConfig().flowchart) == null ? void 0 : _a.htmlLabels) ?? getConfig().htmlLabels) { + edgeData.labelType = "html"; + edgeData.label = '' + edge.text + ""; + } else { + edgeData.labelType = "text"; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + } + } + g.setEdge(edge.id1, edge.id2, edgeData, cnt); + }); +}; +const setConf = function(cnf) { + conf = { + ...conf, + ...cnf + }; +}; +const draw = async function(text, id, _version, diagObj) { + log$1.info("Drawing class - ", id); + const conf2 = getConfig().flowchart ?? getConfig().class; + const securityLevel = getConfig().securityLevel; + log$1.info("config:", conf2); + const nodeSpacing = (conf2 == null ? void 0 : conf2.nodeSpacing) ?? 50; + const rankSpacing = (conf2 == null ? void 0 : conf2.rankSpacing) ?? 50; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: diagObj.db.getDirection(), + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + const namespaces = diagObj.db.getNamespaces(); + const classes = diagObj.db.getClasses(); + const relations = diagObj.db.getRelations(); + const notes = diagObj.db.getNotes(); + log$1.info(relations); + addNamespaces(namespaces, g, id, diagObj); + addClasses(classes, g, id, diagObj); + addRelations(relations, g); + addNotes(notes, g, relations.length + 1, classes); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render( + element, + g, + ["aggregation", "extension", "composition", "dependency", "lollipop"], + "classDiagram", + id + ); + utils.insertTitle(svg, "classTitleText", (conf2 == null ? void 0 : conf2.titleTopMargin) ?? 5, diagObj.db.getDiagramTitle()); + setupGraphViewbox$1(g, svg, conf2 == null ? void 0 : conf2.diagramPadding, conf2 == null ? void 0 : conf2.useMaxWidth); + if (!(conf2 == null ? void 0 : conf2.htmlLabels)) { + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } +}; +function getArrowMarker(type) { + let marker; + switch (type) { + case 0: + marker = "aggregation"; + break; + case 1: + marker = "extension"; + break; + case 2: + marker = "composition"; + break; + case 3: + marker = "dependency"; + break; + case 4: + marker = "lollipop"; + break; + default: + marker = "none"; + } + return marker; +} +const renderer = { + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.class) { + cnf.class = {}; + } + cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/classDiagram-v2-a2b738ad-ZVt6Q8y0.js b/libs/marked/classDiagram-v2-a2b738ad-ZVt6Q8y0.js new file mode 100644 index 0000000..532e7a7 --- /dev/null +++ b/libs/marked/classDiagram-v2-a2b738ad-ZVt6Q8y0.js @@ -0,0 +1,290 @@ +import { p as parser$1, d as db, s as styles } from './styles-b83b31c9-CoATnBwl.js'; +import { l as log$1, c as getConfig, h as select, A as utils, t as setupGraphViewbox$1, o as getStylesFromArray, q as interpolateToCurve, n as curveLinear, j as common$1 } from './index-Bd_FDXSq.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { r as render } from './index-01f381cb-BCBEZMaa.js'; +import './layout-BnytXFfq.js'; +import './clone-B-QllgkM.js'; +import './edges-066a5561-Bqw9g7uz.js'; +import './createText-ca0c5216-B9KlDTE8.js'; +import './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +const sanitizeText = (txt) => common$1.sanitizeText(txt, getConfig()); +let conf = { + dividerMargin: 10, + padding: 5, + textHeight: 10, + curve: void 0 +}; +const addNamespaces = function(namespaces, g, _id, diagObj) { + const keys = Object.keys(namespaces); + log$1.info("keys:", keys); + log$1.info(namespaces); + keys.forEach(function(id) { + var _a, _b; + const vertex = namespaces[id]; + const shape = "rect"; + const node = { + shape, + id: vertex.id, + domId: vertex.domId, + labelText: sanitizeText(vertex.id), + labelStyle: "", + style: "fill: none; stroke: black", + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + addClasses(vertex.classes, g, _id, diagObj, vertex.id); + log$1.info("setNode", node); + }); +}; +const addClasses = function(classes, g, _id, diagObj, parent) { + const keys = Object.keys(classes); + log$1.info("keys:", keys); + log$1.info(classes); + keys.filter((id) => classes[id].parent == parent).forEach(function(id) { + var _a, _b; + const vertex = classes[id]; + const cssClassStr = vertex.cssClasses.join(" "); + const styles2 = getStylesFromArray(vertex.styles); + const vertexText = vertex.label ?? vertex.id; + const radius = 0; + const shape = "class_box"; + const node = { + labelStyle: styles2.labelStyle, + shape, + labelText: sanitizeText(vertexText), + classData: vertex, + rx: radius, + ry: radius, + class: cssClassStr, + style: styles2.style, + id: vertex.id, + domId: vertex.domId, + tooltip: diagObj.db.getTooltip(vertex.id, parent) || "", + haveCallback: vertex.haveCallback, + link: vertex.link, + width: vertex.type === "group" ? 500 : void 0, + type: vertex.type, + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + if (parent) { + g.setParent(vertex.id, parent); + } + log$1.info("setNode", node); + }); +}; +const addNotes = function(notes, g, startEdgeId, classes) { + log$1.info(notes); + notes.forEach(function(note, i) { + var _a, _b; + const vertex = note; + const cssNoteStr = ""; + const styles2 = { labelStyle: "", style: "" }; + const vertexText = vertex.text; + const radius = 0; + const shape = "note"; + const node = { + labelStyle: styles2.labelStyle, + shape, + labelText: sanitizeText(vertexText), + noteData: vertex, + rx: radius, + ry: radius, + class: cssNoteStr, + style: styles2.style, + id: vertex.id, + domId: vertex.id, + tooltip: "", + type: "note", + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + log$1.info("setNode", node); + if (!vertex.class || !(vertex.class in classes)) { + return; + } + const edgeId = startEdgeId + i; + const edgeData = { + id: `edgeNote${edgeId}`, + //Set relationship style and line type + classes: "relation", + pattern: "dotted", + // Set link type for rendering + arrowhead: "none", + //Set edge extra labels + startLabelRight: "", + endLabelLeft: "", + //Set relation arrow types + arrowTypeStart: "none", + arrowTypeEnd: "none", + style: "fill:none", + labelStyle: "", + curve: interpolateToCurve(conf.curve, curveLinear) + }; + g.setEdge(vertex.id, vertex.class, edgeData, edgeId); + }); +}; +const addRelations = function(relations, g) { + const conf2 = getConfig().flowchart; + let cnt = 0; + relations.forEach(function(edge) { + var _a; + cnt++; + const edgeData = { + //Set relationship style and line type + classes: "relation", + pattern: edge.relation.lineType == 1 ? "dashed" : "solid", + id: `id_${edge.id1}_${edge.id2}_${cnt}`, + // Set link type for rendering + arrowhead: edge.type === "arrow_open" ? "none" : "normal", + //Set edge extra labels + startLabelRight: edge.relationTitle1 === "none" ? "" : edge.relationTitle1, + endLabelLeft: edge.relationTitle2 === "none" ? "" : edge.relationTitle2, + //Set relation arrow types + arrowTypeStart: getArrowMarker(edge.relation.type1), + arrowTypeEnd: getArrowMarker(edge.relation.type2), + style: "fill:none", + labelStyle: "", + curve: interpolateToCurve(conf2 == null ? void 0 : conf2.curve, curveLinear) + }; + log$1.info(edgeData, edge); + if (edge.style !== void 0) { + const styles2 = getStylesFromArray(edge.style); + edgeData.style = styles2.style; + edgeData.labelStyle = styles2.labelStyle; + } + edge.text = edge.title; + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + if (((_a = getConfig().flowchart) == null ? void 0 : _a.htmlLabels) ?? getConfig().htmlLabels) { + edgeData.labelType = "html"; + edgeData.label = '' + edge.text + ""; + } else { + edgeData.labelType = "text"; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + } + } + g.setEdge(edge.id1, edge.id2, edgeData, cnt); + }); +}; +const setConf = function(cnf) { + conf = { + ...conf, + ...cnf + }; +}; +const draw = async function(text, id, _version, diagObj) { + log$1.info("Drawing class - ", id); + const conf2 = getConfig().flowchart ?? getConfig().class; + const securityLevel = getConfig().securityLevel; + log$1.info("config:", conf2); + const nodeSpacing = (conf2 == null ? void 0 : conf2.nodeSpacing) ?? 50; + const rankSpacing = (conf2 == null ? void 0 : conf2.rankSpacing) ?? 50; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: diagObj.db.getDirection(), + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + const namespaces = diagObj.db.getNamespaces(); + const classes = diagObj.db.getClasses(); + const relations = diagObj.db.getRelations(); + const notes = diagObj.db.getNotes(); + log$1.info(relations); + addNamespaces(namespaces, g, id, diagObj); + addClasses(classes, g, id, diagObj); + addRelations(relations, g); + addNotes(notes, g, relations.length + 1, classes); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render( + element, + g, + ["aggregation", "extension", "composition", "dependency", "lollipop"], + "classDiagram", + id + ); + utils.insertTitle(svg, "classTitleText", (conf2 == null ? void 0 : conf2.titleTopMargin) ?? 5, diagObj.db.getDiagramTitle()); + setupGraphViewbox$1(g, svg, conf2 == null ? void 0 : conf2.diagramPadding, conf2 == null ? void 0 : conf2.useMaxWidth); + if (!(conf2 == null ? void 0 : conf2.htmlLabels)) { + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } +}; +function getArrowMarker(type) { + let marker; + switch (type) { + case 0: + marker = "aggregation"; + break; + case 1: + marker = "extension"; + break; + case 2: + marker = "composition"; + break; + case 3: + marker = "dependency"; + break; + case 4: + marker = "lollipop"; + break; + default: + marker = "none"; + } + return marker; +} +const renderer = { + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.class) { + cnf.class = {}; + } + cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/clone-B-QllgkM.js b/libs/marked/clone-B-QllgkM.js new file mode 100644 index 0000000..4f50499 --- /dev/null +++ b/libs/marked/clone-B-QllgkM.js @@ -0,0 +1,36 @@ +import { c as baseClone } from './graph-KZW2Npeo.js'; + +/** Used to compose bitmasks for cloning. */ +var CLONE_SYMBOLS_FLAG = 4; + +/** + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); + * // => true + */ +function clone(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG); +} + +export { clone as c }; diff --git a/libs/marked/clone-B4k62NSz.js b/libs/marked/clone-B4k62NSz.js new file mode 100644 index 0000000..91cbfc4 --- /dev/null +++ b/libs/marked/clone-B4k62NSz.js @@ -0,0 +1,36 @@ +import { c as baseClone } from './graph-DadsyNmk.js'; + +/** Used to compose bitmasks for cloning. */ +var CLONE_SYMBOLS_FLAG = 4; + +/** + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); + * // => true + */ +function clone(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG); +} + +export { clone as c }; diff --git a/libs/marked/createText-ca0c5216-B9KlDTE8.js b/libs/marked/createText-ca0c5216-B9KlDTE8.js new file mode 100644 index 0000000..b2a45d8 --- /dev/null +++ b/libs/marked/createText-ca0c5216-B9KlDTE8.js @@ -0,0 +1,12431 @@ +import { l as log$1, b6 as decodeEntities, b7 as dedent } from './index-Bd_FDXSq.js'; + +/** + * @typedef {import('mdast').Root|import('mdast').Content} Node + * + * @typedef Options + * Configuration (optional). + * @property {boolean | null | undefined} [includeImageAlt=true] + * Whether to use `alt` for `image`s. + * @property {boolean | null | undefined} [includeHtml=true] + * Whether to use `value` of HTML. + */ + +/** @type {Options} */ +const emptyOptions = {}; + +/** + * Get the text content of a node or list of nodes. + * + * Prefers the node’s plain-text fields, otherwise serializes its children, + * and if the given value is an array, serialize the nodes in it. + * + * @param {unknown} value + * Thing to serialize, typically `Node`. + * @param {Options | null | undefined} [options] + * Configuration (optional). + * @returns {string} + * Serialized `value`. + */ +function toString(value, options) { + const settings = emptyOptions; + const includeImageAlt = + typeof settings.includeImageAlt === 'boolean' + ? settings.includeImageAlt + : true; + const includeHtml = + typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true; + + return one(value, includeImageAlt, includeHtml) +} + +/** + * One node or several nodes. + * + * @param {unknown} value + * Thing to serialize. + * @param {boolean} includeImageAlt + * Include image `alt`s. + * @param {boolean} includeHtml + * Include HTML. + * @returns {string} + * Serialized node. + */ +function one(value, includeImageAlt, includeHtml) { + if (node(value)) { + if ('value' in value) { + return value.type === 'html' && !includeHtml ? '' : value.value + } + + if (includeImageAlt && 'alt' in value && value.alt) { + return value.alt + } + + if ('children' in value) { + return all(value.children, includeImageAlt, includeHtml) + } + } + + if (Array.isArray(value)) { + return all(value, includeImageAlt, includeHtml) + } + + return '' +} + +/** + * Serialize a list of nodes. + * + * @param {Array} values + * Thing to serialize. + * @param {boolean} includeImageAlt + * Include image `alt`s. + * @param {boolean} includeHtml + * Include HTML. + * @returns {string} + * Serialized nodes. + */ +function all(values, includeImageAlt, includeHtml) { + /** @type {Array} */ + const result = []; + let index = -1; + + while (++index < values.length) { + result[index] = one(values[index], includeImageAlt, includeHtml); + } + + return result.join('') +} + +/** + * Check if `value` looks like a node. + * + * @param {unknown} value + * Thing. + * @returns {value is Node} + * Whether `value` is a node. + */ +function node(value) { + return Boolean(value && typeof value === 'object') +} + +/** + * Like `Array#splice`, but smarter for giant arrays. + * + * `Array#splice` takes all items to be inserted as individual argument which + * causes a stack overflow in V8 when trying to insert 100k items for instance. + * + * Otherwise, this does not return the removed items, and takes `items` as an + * array instead of rest parameters. + * + * @template {unknown} T + * Item type. + * @param {Array} list + * List to operate on. + * @param {number} start + * Index to remove/insert at (can be negative). + * @param {number} remove + * Number of items to remove. + * @param {Array} items + * Items to inject into `list`. + * @returns {void} + * Nothing. + */ +function splice(list, start, remove, items) { + const end = list.length; + let chunkStart = 0; + /** @type {Array} */ + let parameters; + + // Make start between zero and `end` (included). + if (start < 0) { + start = -start > end ? 0 : end + start; + } else { + start = start > end ? end : start; + } + remove = remove > 0 ? remove : 0; + + // No need to chunk the items if there’s only a couple (10k) items. + if (items.length < 10000) { + parameters = Array.from(items); + parameters.unshift(start, remove); + // @ts-expect-error Hush, it’s fine. + list.splice(...parameters); + } else { + // Delete `remove` items starting from `start` + if (remove) list.splice(start, remove); + + // Insert the items in chunks to not cause stack overflows. + while (chunkStart < items.length) { + parameters = items.slice(chunkStart, chunkStart + 10000); + parameters.unshift(start, 0); + // @ts-expect-error Hush, it’s fine. + list.splice(...parameters); + chunkStart += 10000; + start += 10000; + } + } +} + +/** + * Append `items` (an array) at the end of `list` (another array). + * When `list` was empty, returns `items` instead. + * + * This prevents a potentially expensive operation when `list` is empty, + * and adds items in batches to prevent V8 from hanging. + * + * @template {unknown} T + * Item type. + * @param {Array} list + * List to operate on. + * @param {Array} items + * Items to add to `list`. + * @returns {Array} + * Either `list` or `items`. + */ +function push(list, items) { + if (list.length > 0) { + splice(list, list.length, 0, items); + return list + } + return items +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + * @typedef {import('micromark-util-types').Handles} Handles + * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension + * @typedef {import('micromark-util-types').NormalizedExtension} NormalizedExtension + */ + + +const hasOwnProperty = {}.hasOwnProperty; + +/** + * Combine multiple syntax extensions into one. + * + * @param {Array} extensions + * List of syntax extensions. + * @returns {NormalizedExtension} + * A single combined extension. + */ +function combineExtensions(extensions) { + /** @type {NormalizedExtension} */ + const all = {}; + let index = -1; + + while (++index < extensions.length) { + syntaxExtension(all, extensions[index]); + } + + return all +} + +/** + * Merge `extension` into `all`. + * + * @param {NormalizedExtension} all + * Extension to merge into. + * @param {Extension} extension + * Extension to merge. + * @returns {void} + */ +function syntaxExtension(all, extension) { + /** @type {keyof Extension} */ + let hook; + + for (hook in extension) { + const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined; + /** @type {Record} */ + const left = maybe || (all[hook] = {}); + /** @type {Record | undefined} */ + const right = extension[hook]; + /** @type {string} */ + let code; + + if (right) { + for (code in right) { + if (!hasOwnProperty.call(left, code)) left[code] = []; + const value = right[code]; + constructs( + // @ts-expect-error Looks like a list. + left[code], + Array.isArray(value) ? value : value ? [value] : [] + ); + } + } + } +} + +/** + * Merge `list` into `existing` (both lists of constructs). + * Mutates `existing`. + * + * @param {Array} existing + * @param {Array} list + * @returns {void} + */ +function constructs(existing, list) { + let index = -1; + /** @type {Array} */ + const before = []; + + while (++index < list.length) { +(list[index].add === 'after' ? existing : before).push(list[index]); + } + + splice(existing, 0, 0, before); +} + +// This module is generated by `script/`. +// +// CommonMark handles attention (emphasis, strong) markers based on what comes +// before or after them. +// One such difference is if those characters are Unicode punctuation. +// This script is generated from the Unicode data. + +/** + * Regular expression that matches a unicode punctuation character. + */ +const unicodePunctuationRegex = + /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; + +/** + * @typedef {import('micromark-util-types').Code} Code + */ + + +/** + * Check whether the character code represents an ASCII alpha (`a` through `z`, + * case insensitive). + * + * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha. + * + * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`) + * to U+005A (`Z`). + * + * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`) + * to U+007A (`z`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAlpha = regexCheck(/[A-Za-z]/); + +/** + * Check whether the character code represents an ASCII alphanumeric (`a` + * through `z`, case insensitive, or `0` through `9`). + * + * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha + * (see `asciiAlpha`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); + +/** + * Check whether the character code represents an ASCII atext. + * + * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in + * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`), + * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F + * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E + * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE + * (`{`) to U+007E TILDE (`~`). + * + * See: + * **\[RFC5322]**: + * [Internet Message Format](https://tools.ietf.org/html/rfc5322). + * P. Resnick. + * IETF. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); + +/** + * Check whether a character code is an ASCII control character. + * + * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL) + * to U+001F (US), or U+007F (DEL). + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function asciiControl(code) { + return ( + // Special whitespace codes (which have negative values), C0 and Control + // character DEL + code !== null && (code < 32 || code === 127) + ) +} + +/** + * Check whether the character code represents an ASCII digit (`0` through `9`). + * + * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to + * U+0039 (`9`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiDigit = regexCheck(/\d/); + +/** + * Check whether the character code represents an ASCII hex digit (`a` through + * `f`, case insensitive, or `0` through `9`). + * + * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex + * digit, or an ASCII lower hex digit. + * + * An **ASCII upper hex digit** is a character in the inclusive range U+0041 + * (`A`) to U+0046 (`F`). + * + * An **ASCII lower hex digit** is a character in the inclusive range U+0061 + * (`a`) to U+0066 (`f`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); + +/** + * Check whether the character code represents ASCII punctuation. + * + * An **ASCII punctuation** is a character in the inclusive ranges U+0021 + * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT + * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT + * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); + +/** + * Check whether a character code is a markdown line ending. + * + * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN + * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR). + * + * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE + * RETURN (CR) are replaced by these virtual characters depending on whether + * they occurred together. + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownLineEnding(code) { + return code !== null && code < -2 +} + +/** + * Check whether a character code is a markdown line ending (see + * `markdownLineEnding`) or markdown space (see `markdownSpace`). + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownLineEndingOrSpace(code) { + return code !== null && (code < 0 || code === 32) +} + +/** + * Check whether a character code is a markdown space. + * + * A **markdown space** is the concrete character U+0020 SPACE (SP) and the + * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT). + * + * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is + * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL + * SPACE (VS) characters, depending on the column at which the tab occurred. + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownSpace(code) { + return code === -2 || code === -1 || code === 32 +} + +// Size note: removing ASCII from the regex and using `asciiPunctuation` here +// In fact adds to the bundle size. +/** + * Check whether the character code represents Unicode punctuation. + * + * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation, + * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf` + * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po` + * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII + * punctuation (see `asciiPunctuation`). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const unicodePunctuation = regexCheck(unicodePunctuationRegex); + +/** + * Check whether the character code represents Unicode whitespace. + * + * Note that this does handle micromark specific markdown whitespace characters. + * See `markdownLineEndingOrSpace` to check that. + * + * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator, + * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), + * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const unicodeWhitespace = regexCheck(/\s/); + +/** + * Create a code check from a regex. + * + * @param {RegExp} regex + * @returns {(code: Code) => boolean} + */ +function regexCheck(regex) { + return check + + /** + * Check whether a code matches the bound regex. + * + * @param {Code} code + * Character code. + * @returns {boolean} + * Whether the character code matches the bound regex. + */ + function check(code) { + return code !== null && regex.test(String.fromCharCode(code)) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + + +// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`. + +/** + * Parse spaces and tabs. + * + * There is no `nok` parameter: + * + * * spaces in markdown are often optional, in which case this factory can be + * used and `ok` will be switched to whether spaces were found or not + * * one line ending or space can be detected with `markdownSpace(code)` right + * before using `factorySpace` + * + * ###### Examples + * + * Where `␉` represents a tab (plus how much it expands) and `␠` represents a + * single space. + * + * ```markdown + * ␉ + * ␠␠␠␠ + * ␉␠ + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {TokenType} type + * Type (`' \t'`). + * @param {number | undefined} [max=Infinity] + * Max (exclusive). + * @returns + * Start state. + */ +function factorySpace(effects, ok, type, max) { + const limit = max ? max - 1 : Number.POSITIVE_INFINITY; + let size = 0; + return start + + /** @type {State} */ + function start(code) { + if (markdownSpace(code)) { + effects.enter(type); + return prefix(code) + } + return ok(code) + } + + /** @type {State} */ + function prefix(code) { + if (markdownSpace(code) && size++ < limit) { + effects.consume(code); + return prefix + } + effects.exit(type); + return ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** @type {InitialConstruct} */ +const content$1 = { + tokenize: initializeContent +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeContent(effects) { + const contentStart = effects.attempt( + this.parser.constructs.contentInitial, + afterContentStartConstruct, + paragraphInitial + ); + /** @type {Token} */ + let previous; + return contentStart + + /** @type {State} */ + function afterContentStartConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, contentStart, 'linePrefix') + } + + /** @type {State} */ + function paragraphInitial(code) { + effects.enter('paragraph'); + return lineStart(code) + } + + /** @type {State} */ + function lineStart(code) { + const token = effects.enter('chunkText', { + contentType: 'text', + previous + }); + if (previous) { + previous.next = token; + } + previous = token; + return data(code) + } + + /** @type {State} */ + function data(code) { + if (code === null) { + effects.exit('chunkText'); + effects.exit('paragraph'); + effects.consume(code); + return + } + if (markdownLineEnding(code)) { + effects.consume(code); + effects.exit('chunkText'); + return lineStart + } + + // Data. + effects.consume(code); + return data + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ContainerState} ContainerState + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {InitialConstruct} */ +const document$1 = { + tokenize: initializeDocument +}; + +/** @type {Construct} */ +const containerConstruct = { + tokenize: tokenizeContainer +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeDocument(effects) { + const self = this; + /** @type {Array} */ + const stack = []; + let continued = 0; + /** @type {TokenizeContext | undefined} */ + let childFlow; + /** @type {Token | undefined} */ + let childToken; + /** @type {number} */ + let lineStartOffset; + return start + + /** @type {State} */ + function start(code) { + // First we iterate through the open blocks, starting with the root + // document, and descending through last children down to the last open + // block. + // Each block imposes a condition that the line must satisfy if the block is + // to remain open. + // For example, a block quote requires a `>` character. + // A paragraph requires a non-blank line. + // In this phase we may match all or just some of the open blocks. + // But we cannot close unmatched blocks yet, because we may have a lazy + // continuation line. + if (continued < stack.length) { + const item = stack[continued]; + self.containerState = item[1]; + return effects.attempt( + item[0].continuation, + documentContinue, + checkNewContainers + )(code) + } + + // Done. + return checkNewContainers(code) + } + + /** @type {State} */ + function documentContinue(code) { + continued++; + + // Note: this field is called `_closeFlow` but it also closes containers. + // Perhaps a good idea to rename it but it’s already used in the wild by + // extensions. + if (self.containerState._closeFlow) { + self.containerState._closeFlow = undefined; + if (childFlow) { + closeFlow(); + } + + // Note: this algorithm for moving events around is similar to the + // algorithm when dealing with lazy lines in `writeToChild`. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {Point | undefined} */ + let point; + + // Find the flow chunk. + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + point = self.events[indexBeforeFlow][1].end; + break + } + } + exitContainers(continued); + + // Fix positions. + let index = indexBeforeExits; + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } + + // Inject the exits earlier (they’re still also at the end). + splice( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); + + // Discard the duplicate exits. + self.events.length = index; + return checkNewContainers(code) + } + return start(code) + } + + /** @type {State} */ + function checkNewContainers(code) { + // Next, after consuming the continuation markers for existing blocks, we + // look for new block starts (e.g. `>` for a block quote). + // If we encounter a new block start, we close any blocks unmatched in + // step 1 before creating the new block as a child of the last matched + // block. + if (continued === stack.length) { + // No need to `check` whether there’s a container, of `exitContainers` + // would be moot. + // We can instead immediately `attempt` to parse one. + if (!childFlow) { + return documentContinued(code) + } + + // If we have concrete content, such as block HTML or fenced code, + // we can’t have containers “pierce” into them, so we can immediately + // start. + if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { + return flowStart(code) + } + + // If we do have flow, it could still be a blank line, + // but we’d be interrupting it w/ a new container if there’s a current + // construct. + // To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer + // needed in micromark-extension-gfm-table@1.0.6). + self.interrupt = Boolean( + childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack + ); + } + + // Check if there is a new container. + self.containerState = {}; + return effects.check( + containerConstruct, + thereIsANewContainer, + thereIsNoNewContainer + )(code) + } + + /** @type {State} */ + function thereIsANewContainer(code) { + if (childFlow) closeFlow(); + exitContainers(continued); + return documentContinued(code) + } + + /** @type {State} */ + function thereIsNoNewContainer(code) { + self.parser.lazy[self.now().line] = continued !== stack.length; + lineStartOffset = self.now().offset; + return flowStart(code) + } + + /** @type {State} */ + function documentContinued(code) { + // Try new containers. + self.containerState = {}; + return effects.attempt( + containerConstruct, + containerContinue, + flowStart + )(code) + } + + /** @type {State} */ + function containerContinue(code) { + continued++; + stack.push([self.currentConstruct, self.containerState]); + // Try another. + return documentContinued(code) + } + + /** @type {State} */ + function flowStart(code) { + if (code === null) { + if (childFlow) closeFlow(); + exitContainers(0); + effects.consume(code); + return + } + childFlow = childFlow || self.parser.flow(self.now()); + effects.enter('chunkFlow', { + contentType: 'flow', + previous: childToken, + _tokenizer: childFlow + }); + return flowContinue(code) + } + + /** @type {State} */ + function flowContinue(code) { + if (code === null) { + writeToChild(effects.exit('chunkFlow'), true); + exitContainers(0); + effects.consume(code); + return + } + if (markdownLineEnding(code)) { + effects.consume(code); + writeToChild(effects.exit('chunkFlow')); + // Get ready for the next line. + continued = 0; + self.interrupt = undefined; + return start + } + effects.consume(code); + return flowContinue + } + + /** + * @param {Token} token + * @param {boolean | undefined} [eof] + * @returns {void} + */ + function writeToChild(token, eof) { + const stream = self.sliceStream(token); + if (eof) stream.push(null); + token.previous = childToken; + if (childToken) childToken.next = token; + childToken = token; + childFlow.defineSkip(token.start); + childFlow.write(stream); + + // Alright, so we just added a lazy line: + // + // ```markdown + // > a + // b. + // + // Or: + // + // > ~~~c + // d + // + // Or: + // + // > | e | + // f + // ``` + // + // The construct in the second example (fenced code) does not accept lazy + // lines, so it marked itself as done at the end of its first line, and + // then the content construct parses `d`. + // Most constructs in markdown match on the first line: if the first line + // forms a construct, a non-lazy line can’t “unmake” it. + // + // The construct in the third example is potentially a GFM table, and + // those are *weird*. + // It *could* be a table, from the first line, if the following line + // matches a condition. + // In this case, that second line is lazy, which “unmakes” the first line + // and turns the whole into one content block. + // + // We’ve now parsed the non-lazy and the lazy line, and can figure out + // whether the lazy line started a new flow block. + // If it did, we exit the current containers between the two flow blocks. + if (self.parser.lazy[token.start.line]) { + let index = childFlow.events.length; + while (index--) { + if ( + // The token starts before the line ending… + childFlow.events[index][1].start.offset < lineStartOffset && + // …and either is not ended yet… + (!childFlow.events[index][1].end || + // …or ends after it. + childFlow.events[index][1].end.offset > lineStartOffset) + ) { + // Exit: there’s still something open, which means it’s a lazy line + // part of something. + return + } + } + + // Note: this algorithm for moving events around is similar to the + // algorithm when closing flow in `documentContinue`. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {boolean | undefined} */ + let seen; + /** @type {Point | undefined} */ + let point; + + // Find the previous chunk (the one before the lazy line). + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + if (seen) { + point = self.events[indexBeforeFlow][1].end; + break + } + seen = true; + } + } + exitContainers(continued); + + // Fix positions. + index = indexBeforeExits; + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } + + // Inject the exits earlier (they’re still also at the end). + splice( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); + + // Discard the duplicate exits. + self.events.length = index; + } + } + + /** + * @param {number} size + * @returns {void} + */ + function exitContainers(size) { + let index = stack.length; + + // Exit open containers. + while (index-- > size) { + const entry = stack[index]; + self.containerState = entry[1]; + entry[0].exit.call(self, effects); + } + stack.length = size; + } + function closeFlow() { + childFlow.write([null]); + childToken = undefined; + childFlow = undefined; + self.containerState._closeFlow = undefined; + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContainer(effects, ok, nok) { + // Always populated by defaults. + + return factorySpace( + effects, + effects.attempt(this.parser.constructs.document, ok, nok), + 'linePrefix', + this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + ) +} + +/** + * @typedef {import('micromark-util-types').Code} Code + */ + +/** + * Classify whether a code represents whitespace, punctuation, or something + * else. + * + * Used for attention (emphasis, strong), whose sequences can open or close + * based on the class of surrounding characters. + * + * > 👉 **Note**: eof (`null`) is seen as whitespace. + * + * @param {Code} code + * Code. + * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined} + * Group. + */ +function classifyCharacter(code) { + if ( + code === null || + markdownLineEndingOrSpace(code) || + unicodeWhitespace(code) + ) { + return 1 + } + if (unicodePunctuation(code)) { + return 2 + } +} + +/** + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** + * Call all `resolveAll`s. + * + * @param {Array<{resolveAll?: Resolver | undefined}>} constructs + * List of constructs, optionally with `resolveAll`s. + * @param {Array} events + * List of events. + * @param {TokenizeContext} context + * Context used by `tokenize`. + * @returns {Array} + * Changed events. + */ +function resolveAll(constructs, events, context) { + /** @type {Array} */ + const called = []; + let index = -1; + + while (++index < constructs.length) { + const resolve = constructs[index].resolveAll; + + if (resolve && !called.includes(resolve)) { + events = resolve(events, context); + called.push(resolve); + } + } + + return events +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const attention = { + name: 'attention', + tokenize: tokenizeAttention, + resolveAll: resolveAllAttention +}; + +/** + * Take all events and resolve attention to emphasis or strong. + * + * @type {Resolver} + */ +function resolveAllAttention(events, context) { + let index = -1; + /** @type {number} */ + let open; + /** @type {Token} */ + let group; + /** @type {Token} */ + let text; + /** @type {Token} */ + let openingSequence; + /** @type {Token} */ + let closingSequence; + /** @type {number} */ + let use; + /** @type {Array} */ + let nextEvents; + /** @type {number} */ + let offset; + + // Walk through all events. + // + // Note: performance of this is fine on an mb of normal markdown, but it’s + // a bottleneck for malicious stuff. + while (++index < events.length) { + // Find a token that can close. + if ( + events[index][0] === 'enter' && + events[index][1].type === 'attentionSequence' && + events[index][1]._close + ) { + open = index; + + // Now walk back to find an opener. + while (open--) { + // Find a token that can open the closer. + if ( + events[open][0] === 'exit' && + events[open][1].type === 'attentionSequence' && + events[open][1]._open && + // If the markers are the same: + context.sliceSerialize(events[open][1]).charCodeAt(0) === + context.sliceSerialize(events[index][1]).charCodeAt(0) + ) { + // If the opening can close or the closing can open, + // and the close size *is not* a multiple of three, + // but the sum of the opening and closing size *is* multiple of three, + // then don’t match. + if ( + (events[open][1]._close || events[index][1]._open) && + (events[index][1].end.offset - events[index][1].start.offset) % 3 && + !( + (events[open][1].end.offset - + events[open][1].start.offset + + events[index][1].end.offset - + events[index][1].start.offset) % + 3 + ) + ) { + continue + } + + // Number of markers to use from the sequence. + use = + events[open][1].end.offset - events[open][1].start.offset > 1 && + events[index][1].end.offset - events[index][1].start.offset > 1 + ? 2 + : 1; + const start = Object.assign({}, events[open][1].end); + const end = Object.assign({}, events[index][1].start); + movePoint(start, -use); + movePoint(end, use); + openingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start, + end: Object.assign({}, events[open][1].end) + }; + closingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start: Object.assign({}, events[index][1].start), + end + }; + text = { + type: use > 1 ? 'strongText' : 'emphasisText', + start: Object.assign({}, events[open][1].end), + end: Object.assign({}, events[index][1].start) + }; + group = { + type: use > 1 ? 'strong' : 'emphasis', + start: Object.assign({}, openingSequence.start), + end: Object.assign({}, closingSequence.end) + }; + events[open][1].end = Object.assign({}, openingSequence.start); + events[index][1].start = Object.assign({}, closingSequence.end); + nextEvents = []; + + // If there are more markers in the opening, add them before. + if (events[open][1].end.offset - events[open][1].start.offset) { + nextEvents = push(nextEvents, [ + ['enter', events[open][1], context], + ['exit', events[open][1], context] + ]); + } + + // Opening. + nextEvents = push(nextEvents, [ + ['enter', group, context], + ['enter', openingSequence, context], + ['exit', openingSequence, context], + ['enter', text, context] + ]); + + // Always populated by defaults. + + // Between. + nextEvents = push( + nextEvents, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + 1, index), + context + ) + ); + + // Closing. + nextEvents = push(nextEvents, [ + ['exit', text, context], + ['enter', closingSequence, context], + ['exit', closingSequence, context], + ['exit', group, context] + ]); + + // If there are more markers in the closing, add them after. + if (events[index][1].end.offset - events[index][1].start.offset) { + offset = 2; + nextEvents = push(nextEvents, [ + ['enter', events[index][1], context], + ['exit', events[index][1], context] + ]); + } else { + offset = 0; + } + splice(events, open - 1, index - open + 3, nextEvents); + index = open + nextEvents.length - offset - 2; + break + } + } + } + } + + // Remove remaining sequences. + index = -1; + while (++index < events.length) { + if (events[index][1].type === 'attentionSequence') { + events[index][1].type = 'data'; + } + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeAttention(effects, ok) { + const attentionMarkers = this.parser.constructs.attentionMarkers.null; + const previous = this.previous; + const before = classifyCharacter(previous); + + /** @type {NonNullable} */ + let marker; + return start + + /** + * Before a sequence. + * + * ```markdown + * > | ** + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + marker = code; + effects.enter('attentionSequence'); + return inside(code) + } + + /** + * In a sequence. + * + * ```markdown + * > | ** + * ^^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === marker) { + effects.consume(code); + return inside + } + const token = effects.exit('attentionSequence'); + + // To do: next major: move this to resolver, just like `markdown-rs`. + const after = classifyCharacter(code); + + // Always populated by defaults. + + const open = + !after || (after === 2 && before) || attentionMarkers.includes(code); + const close = + !before || (before === 2 && after) || attentionMarkers.includes(previous); + token._open = Boolean(marker === 42 ? open : open && (before || !close)); + token._close = Boolean(marker === 42 ? close : close && (after || !open)); + return ok(code) + } +} + +/** + * Move a point a bit. + * + * Note: `move` only works inside lines! It’s not possible to move past other + * chunks (replacement characters, tabs, or line endings). + * + * @param {Point} point + * @param {number} offset + * @returns {void} + */ +function movePoint(point, offset) { + point.column += offset; + point.offset += offset; + point._bufferIndex += offset; +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const autolink = { + name: 'autolink', + tokenize: tokenizeAutolink +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeAutolink(effects, ok, nok) { + let size = 0; + return start + + /** + * Start of an autolink. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('autolink'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.enter('autolinkProtocol'); + return open + } + + /** + * After `<`, at protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (asciiAlpha(code)) { + effects.consume(code); + return schemeOrEmailAtext + } + return emailAtext(code) + } + + /** + * At second byte of protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function schemeOrEmailAtext(code) { + // ASCII alphanumeric and `+`, `-`, and `.`. + if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) { + // Count the previous alphabetical from `open` too. + size = 1; + return schemeInsideOrEmailAtext(code) + } + return emailAtext(code) + } + + /** + * In ambiguous protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function schemeInsideOrEmailAtext(code) { + if (code === 58) { + effects.consume(code); + size = 0; + return urlInside + } + + // ASCII alphanumeric and `+`, `-`, and `.`. + if ( + (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && + size++ < 32 + ) { + effects.consume(code); + return schemeInsideOrEmailAtext + } + size = 0; + return emailAtext(code) + } + + /** + * After protocol, in URL. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function urlInside(code) { + if (code === 62) { + effects.exit('autolinkProtocol'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok + } + + // ASCII control, space, or `<`. + if (code === null || code === 32 || code === 60 || asciiControl(code)) { + return nok(code) + } + effects.consume(code); + return urlInside + } + + /** + * In email atext. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailAtext(code) { + if (code === 64) { + effects.consume(code); + return emailAtSignOrDot + } + if (asciiAtext(code)) { + effects.consume(code); + return emailAtext + } + return nok(code) + } + + /** + * In label, after at-sign or dot. + * + * ```markdown + * > | ab + * ^ ^ + * ``` + * + * @type {State} + */ + function emailAtSignOrDot(code) { + return asciiAlphanumeric(code) ? emailLabel(code) : nok(code) + } + + /** + * In label, where `.` and `>` are allowed. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailLabel(code) { + if (code === 46) { + effects.consume(code); + size = 0; + return emailAtSignOrDot + } + if (code === 62) { + // Exit, then change the token type. + effects.exit('autolinkProtocol').type = 'autolinkEmail'; + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok + } + return emailValue(code) + } + + /** + * In label, where `.` and `>` are *not* allowed. + * + * Though, this is also used in `emailLabel` to parse other values. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailValue(code) { + // ASCII alphanumeric or `-`. + if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) { + const next = code === 45 ? emailValue : emailLabel; + effects.consume(code); + return next + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const blankLine = { + tokenize: tokenizeBlankLine, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlankLine(effects, ok, nok) { + return start + + /** + * Start of blank line. + * + * > 👉 **Note**: `␠` represents a space character. + * + * ```markdown + * > | ␠␠␊ + * ^ + * > | ␊ + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + return markdownSpace(code) + ? factorySpace(effects, after, 'linePrefix')(code) + : after(code) + } + + /** + * At eof/eol, after optional whitespace. + * + * > 👉 **Note**: `␠` represents a space character. + * + * ```markdown + * > | ␠␠␊ + * ^ + * > | ␊ + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const blockQuote = { + name: 'blockQuote', + tokenize: tokenizeBlockQuoteStart, + continuation: { + tokenize: tokenizeBlockQuoteContinuation + }, + exit +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlockQuoteStart(effects, ok, nok) { + const self = this; + return start + + /** + * Start of block quote. + * + * ```markdown + * > | > a + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 62) { + const state = self.containerState; + if (!state.open) { + effects.enter('blockQuote', { + _container: true + }); + state.open = true; + } + effects.enter('blockQuotePrefix'); + effects.enter('blockQuoteMarker'); + effects.consume(code); + effects.exit('blockQuoteMarker'); + return after + } + return nok(code) + } + + /** + * After `>`, before optional whitespace. + * + * ```markdown + * > | > a + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + if (markdownSpace(code)) { + effects.enter('blockQuotePrefixWhitespace'); + effects.consume(code); + effects.exit('blockQuotePrefixWhitespace'); + effects.exit('blockQuotePrefix'); + return ok + } + effects.exit('blockQuotePrefix'); + return ok(code) + } +} + +/** + * Start of block quote continuation. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlockQuoteContinuation(effects, ok, nok) { + const self = this; + return contStart + + /** + * Start of block quote continuation. + * + * Also used to parse the first block quote opening. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @type {State} + */ + function contStart(code) { + if (markdownSpace(code)) { + // Always populated by defaults. + + return factorySpace( + effects, + contBefore, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } + return contBefore(code) + } + + /** + * At `>`, after optional whitespace. + * + * Also used to parse the first block quote opening. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @type {State} + */ + function contBefore(code) { + return effects.attempt(blockQuote, ok, nok)(code) + } +} + +/** @type {Exiter} */ +function exit(effects) { + effects.exit('blockQuote'); +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const characterEscape = { + name: 'characterEscape', + tokenize: tokenizeCharacterEscape +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCharacterEscape(effects, ok, nok) { + return start + + /** + * Start of character escape. + * + * ```markdown + * > | a\*b + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('characterEscape'); + effects.enter('escapeMarker'); + effects.consume(code); + effects.exit('escapeMarker'); + return inside + } + + /** + * After `\`, at punctuation. + * + * ```markdown + * > | a\*b + * ^ + * ``` + * + * @type {State} + */ + function inside(code) { + // ASCII punctuation. + if (asciiPunctuation(code)) { + effects.enter('characterEscapeValue'); + effects.consume(code); + effects.exit('characterEscapeValue'); + effects.exit('characterEscape'); + return ok + } + return nok(code) + } +} + +/** + * Map of named character references. + * + * @type {Record} + */ +const characterEntities = { + AElig: 'Æ', + AMP: '&', + Aacute: 'Á', + Abreve: 'Ă', + Acirc: 'Â', + Acy: 'А', + Afr: '𝔄', + Agrave: 'À', + Alpha: 'Α', + Amacr: 'Ā', + And: '⩓', + Aogon: 'Ą', + Aopf: '𝔸', + ApplyFunction: '⁡', + Aring: 'Å', + Ascr: '𝒜', + Assign: '≔', + Atilde: 'Ã', + Auml: 'Ä', + Backslash: '∖', + Barv: '⫧', + Barwed: '⌆', + Bcy: 'Б', + Because: '∵', + Bernoullis: 'ℬ', + Beta: 'Β', + Bfr: '𝔅', + Bopf: '𝔹', + Breve: '˘', + Bscr: 'ℬ', + Bumpeq: '≎', + CHcy: 'Ч', + COPY: '©', + Cacute: 'Ć', + Cap: '⋒', + CapitalDifferentialD: 'ⅅ', + Cayleys: 'ℭ', + Ccaron: 'Č', + Ccedil: 'Ç', + Ccirc: 'Ĉ', + Cconint: '∰', + Cdot: 'Ċ', + Cedilla: '¸', + CenterDot: '·', + Cfr: 'ℭ', + Chi: 'Χ', + CircleDot: '⊙', + CircleMinus: '⊖', + CirclePlus: '⊕', + CircleTimes: '⊗', + ClockwiseContourIntegral: '∲', + CloseCurlyDoubleQuote: '”', + CloseCurlyQuote: '’', + Colon: '∷', + Colone: '⩴', + Congruent: '≡', + Conint: '∯', + ContourIntegral: '∮', + Copf: 'ℂ', + Coproduct: '∐', + CounterClockwiseContourIntegral: '∳', + Cross: '⨯', + Cscr: '𝒞', + Cup: '⋓', + CupCap: '≍', + DD: 'ⅅ', + DDotrahd: '⤑', + DJcy: 'Ђ', + DScy: 'Ѕ', + DZcy: 'Џ', + Dagger: '‡', + Darr: '↡', + Dashv: '⫤', + Dcaron: 'Ď', + Dcy: 'Д', + Del: '∇', + Delta: 'Δ', + Dfr: '𝔇', + DiacriticalAcute: '´', + DiacriticalDot: '˙', + DiacriticalDoubleAcute: '˝', + DiacriticalGrave: '`', + DiacriticalTilde: '˜', + Diamond: '⋄', + DifferentialD: 'ⅆ', + Dopf: '𝔻', + Dot: '¨', + DotDot: '⃜', + DotEqual: '≐', + DoubleContourIntegral: '∯', + DoubleDot: '¨', + DoubleDownArrow: '⇓', + DoubleLeftArrow: '⇐', + DoubleLeftRightArrow: '⇔', + DoubleLeftTee: '⫤', + DoubleLongLeftArrow: '⟸', + DoubleLongLeftRightArrow: '⟺', + DoubleLongRightArrow: '⟹', + DoubleRightArrow: '⇒', + DoubleRightTee: '⊨', + DoubleUpArrow: '⇑', + DoubleUpDownArrow: '⇕', + DoubleVerticalBar: '∥', + DownArrow: '↓', + DownArrowBar: '⤓', + DownArrowUpArrow: '⇵', + DownBreve: '̑', + DownLeftRightVector: '⥐', + DownLeftTeeVector: '⥞', + DownLeftVector: '↽', + DownLeftVectorBar: '⥖', + DownRightTeeVector: '⥟', + DownRightVector: '⇁', + DownRightVectorBar: '⥗', + DownTee: '⊤', + DownTeeArrow: '↧', + Downarrow: '⇓', + Dscr: '𝒟', + Dstrok: 'Đ', + ENG: 'Ŋ', + ETH: 'Ð', + Eacute: 'É', + Ecaron: 'Ě', + Ecirc: 'Ê', + Ecy: 'Э', + Edot: 'Ė', + Efr: '𝔈', + Egrave: 'È', + Element: '∈', + Emacr: 'Ē', + EmptySmallSquare: '◻', + EmptyVerySmallSquare: '▫', + Eogon: 'Ę', + Eopf: '𝔼', + Epsilon: 'Ε', + Equal: '⩵', + EqualTilde: '≂', + Equilibrium: '⇌', + Escr: 'ℰ', + Esim: '⩳', + Eta: 'Η', + Euml: 'Ë', + Exists: '∃', + ExponentialE: 'ⅇ', + Fcy: 'Ф', + Ffr: '𝔉', + FilledSmallSquare: '◼', + FilledVerySmallSquare: '▪', + Fopf: '𝔽', + ForAll: '∀', + Fouriertrf: 'ℱ', + Fscr: 'ℱ', + GJcy: 'Ѓ', + GT: '>', + Gamma: 'Γ', + Gammad: 'Ϝ', + Gbreve: 'Ğ', + Gcedil: 'Ģ', + Gcirc: 'Ĝ', + Gcy: 'Г', + Gdot: 'Ġ', + Gfr: '𝔊', + Gg: '⋙', + Gopf: '𝔾', + GreaterEqual: '≥', + GreaterEqualLess: '⋛', + GreaterFullEqual: '≧', + GreaterGreater: '⪢', + GreaterLess: '≷', + GreaterSlantEqual: '⩾', + GreaterTilde: '≳', + Gscr: '𝒢', + Gt: '≫', + HARDcy: 'Ъ', + Hacek: 'ˇ', + Hat: '^', + Hcirc: 'Ĥ', + Hfr: 'ℌ', + HilbertSpace: 'ℋ', + Hopf: 'ℍ', + HorizontalLine: '─', + Hscr: 'ℋ', + Hstrok: 'Ħ', + HumpDownHump: '≎', + HumpEqual: '≏', + IEcy: 'Е', + IJlig: 'IJ', + IOcy: 'Ё', + Iacute: 'Í', + Icirc: 'Î', + Icy: 'И', + Idot: 'İ', + Ifr: 'ℑ', + Igrave: 'Ì', + Im: 'ℑ', + Imacr: 'Ī', + ImaginaryI: 'ⅈ', + Implies: '⇒', + Int: '∬', + Integral: '∫', + Intersection: '⋂', + InvisibleComma: '⁣', + InvisibleTimes: '⁢', + Iogon: 'Į', + Iopf: '𝕀', + Iota: 'Ι', + Iscr: 'ℐ', + Itilde: 'Ĩ', + Iukcy: 'І', + Iuml: 'Ï', + Jcirc: 'Ĵ', + Jcy: 'Й', + Jfr: '𝔍', + Jopf: '𝕁', + Jscr: '𝒥', + Jsercy: 'Ј', + Jukcy: 'Є', + KHcy: 'Х', + KJcy: 'Ќ', + Kappa: 'Κ', + Kcedil: 'Ķ', + Kcy: 'К', + Kfr: '𝔎', + Kopf: '𝕂', + Kscr: '𝒦', + LJcy: 'Љ', + LT: '<', + Lacute: 'Ĺ', + Lambda: 'Λ', + Lang: '⟪', + Laplacetrf: 'ℒ', + Larr: '↞', + Lcaron: 'Ľ', + Lcedil: 'Ļ', + Lcy: 'Л', + LeftAngleBracket: '⟨', + LeftArrow: '←', + LeftArrowBar: '⇤', + LeftArrowRightArrow: '⇆', + LeftCeiling: '⌈', + LeftDoubleBracket: '⟦', + LeftDownTeeVector: '⥡', + LeftDownVector: '⇃', + LeftDownVectorBar: '⥙', + LeftFloor: '⌊', + LeftRightArrow: '↔', + LeftRightVector: '⥎', + LeftTee: '⊣', + LeftTeeArrow: '↤', + LeftTeeVector: '⥚', + LeftTriangle: '⊲', + LeftTriangleBar: '⧏', + LeftTriangleEqual: '⊴', + LeftUpDownVector: '⥑', + LeftUpTeeVector: '⥠', + LeftUpVector: '↿', + LeftUpVectorBar: '⥘', + LeftVector: '↼', + LeftVectorBar: '⥒', + Leftarrow: '⇐', + Leftrightarrow: '⇔', + LessEqualGreater: '⋚', + LessFullEqual: '≦', + LessGreater: '≶', + LessLess: '⪡', + LessSlantEqual: '⩽', + LessTilde: '≲', + Lfr: '𝔏', + Ll: '⋘', + Lleftarrow: '⇚', + Lmidot: 'Ŀ', + LongLeftArrow: '⟵', + LongLeftRightArrow: '⟷', + LongRightArrow: '⟶', + Longleftarrow: '⟸', + Longleftrightarrow: '⟺', + Longrightarrow: '⟹', + Lopf: '𝕃', + LowerLeftArrow: '↙', + LowerRightArrow: '↘', + Lscr: 'ℒ', + Lsh: '↰', + Lstrok: 'Ł', + Lt: '≪', + Map: '⤅', + Mcy: 'М', + MediumSpace: ' ', + Mellintrf: 'ℳ', + Mfr: '𝔐', + MinusPlus: '∓', + Mopf: '𝕄', + Mscr: 'ℳ', + Mu: 'Μ', + NJcy: 'Њ', + Nacute: 'Ń', + Ncaron: 'Ň', + Ncedil: 'Ņ', + Ncy: 'Н', + NegativeMediumSpace: '​', + NegativeThickSpace: '​', + NegativeThinSpace: '​', + NegativeVeryThinSpace: '​', + NestedGreaterGreater: '≫', + NestedLessLess: '≪', + NewLine: '\n', + Nfr: '𝔑', + NoBreak: '⁠', + NonBreakingSpace: ' ', + Nopf: 'ℕ', + Not: '⫬', + NotCongruent: '≢', + NotCupCap: '≭', + NotDoubleVerticalBar: '∦', + NotElement: '∉', + NotEqual: '≠', + NotEqualTilde: '≂̸', + NotExists: '∄', + NotGreater: '≯', + NotGreaterEqual: '≱', + NotGreaterFullEqual: '≧̸', + NotGreaterGreater: '≫̸', + NotGreaterLess: '≹', + NotGreaterSlantEqual: '⩾̸', + NotGreaterTilde: '≵', + NotHumpDownHump: '≎̸', + NotHumpEqual: '≏̸', + NotLeftTriangle: '⋪', + NotLeftTriangleBar: '⧏̸', + NotLeftTriangleEqual: '⋬', + NotLess: '≮', + NotLessEqual: '≰', + NotLessGreater: '≸', + NotLessLess: '≪̸', + NotLessSlantEqual: '⩽̸', + NotLessTilde: '≴', + NotNestedGreaterGreater: '⪢̸', + NotNestedLessLess: '⪡̸', + NotPrecedes: '⊀', + NotPrecedesEqual: '⪯̸', + NotPrecedesSlantEqual: '⋠', + NotReverseElement: '∌', + NotRightTriangle: '⋫', + NotRightTriangleBar: '⧐̸', + NotRightTriangleEqual: '⋭', + NotSquareSubset: '⊏̸', + NotSquareSubsetEqual: '⋢', + NotSquareSuperset: '⊐̸', + NotSquareSupersetEqual: '⋣', + NotSubset: '⊂⃒', + NotSubsetEqual: '⊈', + NotSucceeds: '⊁', + NotSucceedsEqual: '⪰̸', + NotSucceedsSlantEqual: '⋡', + NotSucceedsTilde: '≿̸', + NotSuperset: '⊃⃒', + NotSupersetEqual: '⊉', + NotTilde: '≁', + NotTildeEqual: '≄', + NotTildeFullEqual: '≇', + NotTildeTilde: '≉', + NotVerticalBar: '∤', + Nscr: '𝒩', + Ntilde: 'Ñ', + Nu: 'Ν', + OElig: 'Œ', + Oacute: 'Ó', + Ocirc: 'Ô', + Ocy: 'О', + Odblac: 'Ő', + Ofr: '𝔒', + Ograve: 'Ò', + Omacr: 'Ō', + Omega: 'Ω', + Omicron: 'Ο', + Oopf: '𝕆', + OpenCurlyDoubleQuote: '“', + OpenCurlyQuote: '‘', + Or: '⩔', + Oscr: '𝒪', + Oslash: 'Ø', + Otilde: 'Õ', + Otimes: '⨷', + Ouml: 'Ö', + OverBar: '‾', + OverBrace: '⏞', + OverBracket: '⎴', + OverParenthesis: '⏜', + PartialD: '∂', + Pcy: 'П', + Pfr: '𝔓', + Phi: 'Φ', + Pi: 'Π', + PlusMinus: '±', + Poincareplane: 'ℌ', + Popf: 'ℙ', + Pr: '⪻', + Precedes: '≺', + PrecedesEqual: '⪯', + PrecedesSlantEqual: '≼', + PrecedesTilde: '≾', + Prime: '″', + Product: '∏', + Proportion: '∷', + Proportional: '∝', + Pscr: '𝒫', + Psi: 'Ψ', + QUOT: '"', + Qfr: '𝔔', + Qopf: 'ℚ', + Qscr: '𝒬', + RBarr: '⤐', + REG: '®', + Racute: 'Ŕ', + Rang: '⟫', + Rarr: '↠', + Rarrtl: '⤖', + Rcaron: 'Ř', + Rcedil: 'Ŗ', + Rcy: 'Р', + Re: 'ℜ', + ReverseElement: '∋', + ReverseEquilibrium: '⇋', + ReverseUpEquilibrium: '⥯', + Rfr: 'ℜ', + Rho: 'Ρ', + RightAngleBracket: '⟩', + RightArrow: '→', + RightArrowBar: '⇥', + RightArrowLeftArrow: '⇄', + RightCeiling: '⌉', + RightDoubleBracket: '⟧', + RightDownTeeVector: '⥝', + RightDownVector: '⇂', + RightDownVectorBar: '⥕', + RightFloor: '⌋', + RightTee: '⊢', + RightTeeArrow: '↦', + RightTeeVector: '⥛', + RightTriangle: '⊳', + RightTriangleBar: '⧐', + RightTriangleEqual: '⊵', + RightUpDownVector: '⥏', + RightUpTeeVector: '⥜', + RightUpVector: '↾', + RightUpVectorBar: '⥔', + RightVector: '⇀', + RightVectorBar: '⥓', + Rightarrow: '⇒', + Ropf: 'ℝ', + RoundImplies: '⥰', + Rrightarrow: '⇛', + Rscr: 'ℛ', + Rsh: '↱', + RuleDelayed: '⧴', + SHCHcy: 'Щ', + SHcy: 'Ш', + SOFTcy: 'Ь', + Sacute: 'Ś', + Sc: '⪼', + Scaron: 'Š', + Scedil: 'Ş', + Scirc: 'Ŝ', + Scy: 'С', + Sfr: '𝔖', + ShortDownArrow: '↓', + ShortLeftArrow: '←', + ShortRightArrow: '→', + ShortUpArrow: '↑', + Sigma: 'Σ', + SmallCircle: '∘', + Sopf: '𝕊', + Sqrt: '√', + Square: '□', + SquareIntersection: '⊓', + SquareSubset: '⊏', + SquareSubsetEqual: '⊑', + SquareSuperset: '⊐', + SquareSupersetEqual: '⊒', + SquareUnion: '⊔', + Sscr: '𝒮', + Star: '⋆', + Sub: '⋐', + Subset: '⋐', + SubsetEqual: '⊆', + Succeeds: '≻', + SucceedsEqual: '⪰', + SucceedsSlantEqual: '≽', + SucceedsTilde: '≿', + SuchThat: '∋', + Sum: '∑', + Sup: '⋑', + Superset: '⊃', + SupersetEqual: '⊇', + Supset: '⋑', + THORN: 'Þ', + TRADE: '™', + TSHcy: 'Ћ', + TScy: 'Ц', + Tab: '\t', + Tau: 'Τ', + Tcaron: 'Ť', + Tcedil: 'Ţ', + Tcy: 'Т', + Tfr: '𝔗', + Therefore: '∴', + Theta: 'Θ', + ThickSpace: '  ', + ThinSpace: ' ', + Tilde: '∼', + TildeEqual: '≃', + TildeFullEqual: '≅', + TildeTilde: '≈', + Topf: '𝕋', + TripleDot: '⃛', + Tscr: '𝒯', + Tstrok: 'Ŧ', + Uacute: 'Ú', + Uarr: '↟', + Uarrocir: '⥉', + Ubrcy: 'Ў', + Ubreve: 'Ŭ', + Ucirc: 'Û', + Ucy: 'У', + Udblac: 'Ű', + Ufr: '𝔘', + Ugrave: 'Ù', + Umacr: 'Ū', + UnderBar: '_', + UnderBrace: '⏟', + UnderBracket: '⎵', + UnderParenthesis: '⏝', + Union: '⋃', + UnionPlus: '⊎', + Uogon: 'Ų', + Uopf: '𝕌', + UpArrow: '↑', + UpArrowBar: '⤒', + UpArrowDownArrow: '⇅', + UpDownArrow: '↕', + UpEquilibrium: '⥮', + UpTee: '⊥', + UpTeeArrow: '↥', + Uparrow: '⇑', + Updownarrow: '⇕', + UpperLeftArrow: '↖', + UpperRightArrow: '↗', + Upsi: 'ϒ', + Upsilon: 'Υ', + Uring: 'Ů', + Uscr: '𝒰', + Utilde: 'Ũ', + Uuml: 'Ü', + VDash: '⊫', + Vbar: '⫫', + Vcy: 'В', + Vdash: '⊩', + Vdashl: '⫦', + Vee: '⋁', + Verbar: '‖', + Vert: '‖', + VerticalBar: '∣', + VerticalLine: '|', + VerticalSeparator: '❘', + VerticalTilde: '≀', + VeryThinSpace: ' ', + Vfr: '𝔙', + Vopf: '𝕍', + Vscr: '𝒱', + Vvdash: '⊪', + Wcirc: 'Ŵ', + Wedge: '⋀', + Wfr: '𝔚', + Wopf: '𝕎', + Wscr: '𝒲', + Xfr: '𝔛', + Xi: 'Ξ', + Xopf: '𝕏', + Xscr: '𝒳', + YAcy: 'Я', + YIcy: 'Ї', + YUcy: 'Ю', + Yacute: 'Ý', + Ycirc: 'Ŷ', + Ycy: 'Ы', + Yfr: '𝔜', + Yopf: '𝕐', + Yscr: '𝒴', + Yuml: 'Ÿ', + ZHcy: 'Ж', + Zacute: 'Ź', + Zcaron: 'Ž', + Zcy: 'З', + Zdot: 'Ż', + ZeroWidthSpace: '​', + Zeta: 'Ζ', + Zfr: 'ℨ', + Zopf: 'ℤ', + Zscr: '𝒵', + aacute: 'á', + abreve: 'ă', + ac: '∾', + acE: '∾̳', + acd: '∿', + acirc: 'â', + acute: '´', + acy: 'а', + aelig: 'æ', + af: '⁡', + afr: '𝔞', + agrave: 'à', + alefsym: 'ℵ', + aleph: 'ℵ', + alpha: 'α', + amacr: 'ā', + amalg: '⨿', + amp: '&', + and: '∧', + andand: '⩕', + andd: '⩜', + andslope: '⩘', + andv: '⩚', + ang: '∠', + ange: '⦤', + angle: '∠', + angmsd: '∡', + angmsdaa: '⦨', + angmsdab: '⦩', + angmsdac: '⦪', + angmsdad: '⦫', + angmsdae: '⦬', + angmsdaf: '⦭', + angmsdag: '⦮', + angmsdah: '⦯', + angrt: '∟', + angrtvb: '⊾', + angrtvbd: '⦝', + angsph: '∢', + angst: 'Å', + angzarr: '⍼', + aogon: 'ą', + aopf: '𝕒', + ap: '≈', + apE: '⩰', + apacir: '⩯', + ape: '≊', + apid: '≋', + apos: "'", + approx: '≈', + approxeq: '≊', + aring: 'å', + ascr: '𝒶', + ast: '*', + asymp: '≈', + asympeq: '≍', + atilde: 'ã', + auml: 'ä', + awconint: '∳', + awint: '⨑', + bNot: '⫭', + backcong: '≌', + backepsilon: '϶', + backprime: '‵', + backsim: '∽', + backsimeq: '⋍', + barvee: '⊽', + barwed: '⌅', + barwedge: '⌅', + bbrk: '⎵', + bbrktbrk: '⎶', + bcong: '≌', + bcy: 'б', + bdquo: '„', + becaus: '∵', + because: '∵', + bemptyv: '⦰', + bepsi: '϶', + bernou: 'ℬ', + beta: 'β', + beth: 'ℶ', + between: '≬', + bfr: '𝔟', + bigcap: '⋂', + bigcirc: '◯', + bigcup: '⋃', + bigodot: '⨀', + bigoplus: '⨁', + bigotimes: '⨂', + bigsqcup: '⨆', + bigstar: '★', + bigtriangledown: '▽', + bigtriangleup: '△', + biguplus: '⨄', + bigvee: '⋁', + bigwedge: '⋀', + bkarow: '⤍', + blacklozenge: '⧫', + blacksquare: '▪', + blacktriangle: '▴', + blacktriangledown: '▾', + blacktriangleleft: '◂', + blacktriangleright: '▸', + blank: '␣', + blk12: '▒', + blk14: '░', + blk34: '▓', + block: '█', + bne: '=⃥', + bnequiv: '≡⃥', + bnot: '⌐', + bopf: '𝕓', + bot: '⊥', + bottom: '⊥', + bowtie: '⋈', + boxDL: '╗', + boxDR: '╔', + boxDl: '╖', + boxDr: '╓', + boxH: '═', + boxHD: '╦', + boxHU: '╩', + boxHd: '╤', + boxHu: '╧', + boxUL: '╝', + boxUR: '╚', + boxUl: '╜', + boxUr: '╙', + boxV: '║', + boxVH: '╬', + boxVL: '╣', + boxVR: '╠', + boxVh: '╫', + boxVl: '╢', + boxVr: '╟', + boxbox: '⧉', + boxdL: '╕', + boxdR: '╒', + boxdl: '┐', + boxdr: '┌', + boxh: '─', + boxhD: '╥', + boxhU: '╨', + boxhd: '┬', + boxhu: '┴', + boxminus: '⊟', + boxplus: '⊞', + boxtimes: '⊠', + boxuL: '╛', + boxuR: '╘', + boxul: '┘', + boxur: '└', + boxv: '│', + boxvH: '╪', + boxvL: '╡', + boxvR: '╞', + boxvh: '┼', + boxvl: '┤', + boxvr: '├', + bprime: '‵', + breve: '˘', + brvbar: '¦', + bscr: '𝒷', + bsemi: '⁏', + bsim: '∽', + bsime: '⋍', + bsol: '\\', + bsolb: '⧅', + bsolhsub: '⟈', + bull: '•', + bullet: '•', + bump: '≎', + bumpE: '⪮', + bumpe: '≏', + bumpeq: '≏', + cacute: 'ć', + cap: '∩', + capand: '⩄', + capbrcup: '⩉', + capcap: '⩋', + capcup: '⩇', + capdot: '⩀', + caps: '∩︀', + caret: '⁁', + caron: 'ˇ', + ccaps: '⩍', + ccaron: 'č', + ccedil: 'ç', + ccirc: 'ĉ', + ccups: '⩌', + ccupssm: '⩐', + cdot: 'ċ', + cedil: '¸', + cemptyv: '⦲', + cent: '¢', + centerdot: '·', + cfr: '𝔠', + chcy: 'ч', + check: '✓', + checkmark: '✓', + chi: 'χ', + cir: '○', + cirE: '⧃', + circ: 'ˆ', + circeq: '≗', + circlearrowleft: '↺', + circlearrowright: '↻', + circledR: '®', + circledS: 'Ⓢ', + circledast: '⊛', + circledcirc: '⊚', + circleddash: '⊝', + cire: '≗', + cirfnint: '⨐', + cirmid: '⫯', + cirscir: '⧂', + clubs: '♣', + clubsuit: '♣', + colon: ':', + colone: '≔', + coloneq: '≔', + comma: ',', + commat: '@', + comp: '∁', + compfn: '∘', + complement: '∁', + complexes: 'ℂ', + cong: '≅', + congdot: '⩭', + conint: '∮', + copf: '𝕔', + coprod: '∐', + copy: '©', + copysr: '℗', + crarr: '↵', + cross: '✗', + cscr: '𝒸', + csub: '⫏', + csube: '⫑', + csup: '⫐', + csupe: '⫒', + ctdot: '⋯', + cudarrl: '⤸', + cudarrr: '⤵', + cuepr: '⋞', + cuesc: '⋟', + cularr: '↶', + cularrp: '⤽', + cup: '∪', + cupbrcap: '⩈', + cupcap: '⩆', + cupcup: '⩊', + cupdot: '⊍', + cupor: '⩅', + cups: '∪︀', + curarr: '↷', + curarrm: '⤼', + curlyeqprec: '⋞', + curlyeqsucc: '⋟', + curlyvee: '⋎', + curlywedge: '⋏', + curren: '¤', + curvearrowleft: '↶', + curvearrowright: '↷', + cuvee: '⋎', + cuwed: '⋏', + cwconint: '∲', + cwint: '∱', + cylcty: '⌭', + dArr: '⇓', + dHar: '⥥', + dagger: '†', + daleth: 'ℸ', + darr: '↓', + dash: '‐', + dashv: '⊣', + dbkarow: '⤏', + dblac: '˝', + dcaron: 'ď', + dcy: 'д', + dd: 'ⅆ', + ddagger: '‡', + ddarr: '⇊', + ddotseq: '⩷', + deg: '°', + delta: 'δ', + demptyv: '⦱', + dfisht: '⥿', + dfr: '𝔡', + dharl: '⇃', + dharr: '⇂', + diam: '⋄', + diamond: '⋄', + diamondsuit: '♦', + diams: '♦', + die: '¨', + digamma: 'ϝ', + disin: '⋲', + div: '÷', + divide: '÷', + divideontimes: '⋇', + divonx: '⋇', + djcy: 'ђ', + dlcorn: '⌞', + dlcrop: '⌍', + dollar: '$', + dopf: '𝕕', + dot: '˙', + doteq: '≐', + doteqdot: '≑', + dotminus: '∸', + dotplus: '∔', + dotsquare: '⊡', + doublebarwedge: '⌆', + downarrow: '↓', + downdownarrows: '⇊', + downharpoonleft: '⇃', + downharpoonright: '⇂', + drbkarow: '⤐', + drcorn: '⌟', + drcrop: '⌌', + dscr: '𝒹', + dscy: 'ѕ', + dsol: '⧶', + dstrok: 'đ', + dtdot: '⋱', + dtri: '▿', + dtrif: '▾', + duarr: '⇵', + duhar: '⥯', + dwangle: '⦦', + dzcy: 'џ', + dzigrarr: '⟿', + eDDot: '⩷', + eDot: '≑', + eacute: 'é', + easter: '⩮', + ecaron: 'ě', + ecir: '≖', + ecirc: 'ê', + ecolon: '≕', + ecy: 'э', + edot: 'ė', + ee: 'ⅇ', + efDot: '≒', + efr: '𝔢', + eg: '⪚', + egrave: 'è', + egs: '⪖', + egsdot: '⪘', + el: '⪙', + elinters: '⏧', + ell: 'ℓ', + els: '⪕', + elsdot: '⪗', + emacr: 'ē', + empty: '∅', + emptyset: '∅', + emptyv: '∅', + emsp13: ' ', + emsp14: ' ', + emsp: ' ', + eng: 'ŋ', + ensp: ' ', + eogon: 'ę', + eopf: '𝕖', + epar: '⋕', + eparsl: '⧣', + eplus: '⩱', + epsi: 'ε', + epsilon: 'ε', + epsiv: 'ϵ', + eqcirc: '≖', + eqcolon: '≕', + eqsim: '≂', + eqslantgtr: '⪖', + eqslantless: '⪕', + equals: '=', + equest: '≟', + equiv: '≡', + equivDD: '⩸', + eqvparsl: '⧥', + erDot: '≓', + erarr: '⥱', + escr: 'ℯ', + esdot: '≐', + esim: '≂', + eta: 'η', + eth: 'ð', + euml: 'ë', + euro: '€', + excl: '!', + exist: '∃', + expectation: 'ℰ', + exponentiale: 'ⅇ', + fallingdotseq: '≒', + fcy: 'ф', + female: '♀', + ffilig: 'ffi', + fflig: 'ff', + ffllig: 'ffl', + ffr: '𝔣', + filig: 'fi', + fjlig: 'fj', + flat: '♭', + fllig: 'fl', + fltns: '▱', + fnof: 'ƒ', + fopf: '𝕗', + forall: '∀', + fork: '⋔', + forkv: '⫙', + fpartint: '⨍', + frac12: '½', + frac13: '⅓', + frac14: '¼', + frac15: '⅕', + frac16: '⅙', + frac18: '⅛', + frac23: '⅔', + frac25: '⅖', + frac34: '¾', + frac35: '⅗', + frac38: '⅜', + frac45: '⅘', + frac56: '⅚', + frac58: '⅝', + frac78: '⅞', + frasl: '⁄', + frown: '⌢', + fscr: '𝒻', + gE: '≧', + gEl: '⪌', + gacute: 'ǵ', + gamma: 'γ', + gammad: 'ϝ', + gap: '⪆', + gbreve: 'ğ', + gcirc: 'ĝ', + gcy: 'г', + gdot: 'ġ', + ge: '≥', + gel: '⋛', + geq: '≥', + geqq: '≧', + geqslant: '⩾', + ges: '⩾', + gescc: '⪩', + gesdot: '⪀', + gesdoto: '⪂', + gesdotol: '⪄', + gesl: '⋛︀', + gesles: '⪔', + gfr: '𝔤', + gg: '≫', + ggg: '⋙', + gimel: 'ℷ', + gjcy: 'ѓ', + gl: '≷', + glE: '⪒', + gla: '⪥', + glj: '⪤', + gnE: '≩', + gnap: '⪊', + gnapprox: '⪊', + gne: '⪈', + gneq: '⪈', + gneqq: '≩', + gnsim: '⋧', + gopf: '𝕘', + grave: '`', + gscr: 'ℊ', + gsim: '≳', + gsime: '⪎', + gsiml: '⪐', + gt: '>', + gtcc: '⪧', + gtcir: '⩺', + gtdot: '⋗', + gtlPar: '⦕', + gtquest: '⩼', + gtrapprox: '⪆', + gtrarr: '⥸', + gtrdot: '⋗', + gtreqless: '⋛', + gtreqqless: '⪌', + gtrless: '≷', + gtrsim: '≳', + gvertneqq: '≩︀', + gvnE: '≩︀', + hArr: '⇔', + hairsp: ' ', + half: '½', + hamilt: 'ℋ', + hardcy: 'ъ', + harr: '↔', + harrcir: '⥈', + harrw: '↭', + hbar: 'ℏ', + hcirc: 'ĥ', + hearts: '♥', + heartsuit: '♥', + hellip: '…', + hercon: '⊹', + hfr: '𝔥', + hksearow: '⤥', + hkswarow: '⤦', + hoarr: '⇿', + homtht: '∻', + hookleftarrow: '↩', + hookrightarrow: '↪', + hopf: '𝕙', + horbar: '―', + hscr: '𝒽', + hslash: 'ℏ', + hstrok: 'ħ', + hybull: '⁃', + hyphen: '‐', + iacute: 'í', + ic: '⁣', + icirc: 'î', + icy: 'и', + iecy: 'е', + iexcl: '¡', + iff: '⇔', + ifr: '𝔦', + igrave: 'ì', + ii: 'ⅈ', + iiiint: '⨌', + iiint: '∭', + iinfin: '⧜', + iiota: '℩', + ijlig: 'ij', + imacr: 'ī', + image: 'ℑ', + imagline: 'ℐ', + imagpart: 'ℑ', + imath: 'ı', + imof: '⊷', + imped: 'Ƶ', + in: '∈', + incare: '℅', + infin: '∞', + infintie: '⧝', + inodot: 'ı', + int: '∫', + intcal: '⊺', + integers: 'ℤ', + intercal: '⊺', + intlarhk: '⨗', + intprod: '⨼', + iocy: 'ё', + iogon: 'į', + iopf: '𝕚', + iota: 'ι', + iprod: '⨼', + iquest: '¿', + iscr: '𝒾', + isin: '∈', + isinE: '⋹', + isindot: '⋵', + isins: '⋴', + isinsv: '⋳', + isinv: '∈', + it: '⁢', + itilde: 'ĩ', + iukcy: 'і', + iuml: 'ï', + jcirc: 'ĵ', + jcy: 'й', + jfr: '𝔧', + jmath: 'ȷ', + jopf: '𝕛', + jscr: '𝒿', + jsercy: 'ј', + jukcy: 'є', + kappa: 'κ', + kappav: 'ϰ', + kcedil: 'ķ', + kcy: 'к', + kfr: '𝔨', + kgreen: 'ĸ', + khcy: 'х', + kjcy: 'ќ', + kopf: '𝕜', + kscr: '𝓀', + lAarr: '⇚', + lArr: '⇐', + lAtail: '⤛', + lBarr: '⤎', + lE: '≦', + lEg: '⪋', + lHar: '⥢', + lacute: 'ĺ', + laemptyv: '⦴', + lagran: 'ℒ', + lambda: 'λ', + lang: '⟨', + langd: '⦑', + langle: '⟨', + lap: '⪅', + laquo: '«', + larr: '←', + larrb: '⇤', + larrbfs: '⤟', + larrfs: '⤝', + larrhk: '↩', + larrlp: '↫', + larrpl: '⤹', + larrsim: '⥳', + larrtl: '↢', + lat: '⪫', + latail: '⤙', + late: '⪭', + lates: '⪭︀', + lbarr: '⤌', + lbbrk: '❲', + lbrace: '{', + lbrack: '[', + lbrke: '⦋', + lbrksld: '⦏', + lbrkslu: '⦍', + lcaron: 'ľ', + lcedil: 'ļ', + lceil: '⌈', + lcub: '{', + lcy: 'л', + ldca: '⤶', + ldquo: '“', + ldquor: '„', + ldrdhar: '⥧', + ldrushar: '⥋', + ldsh: '↲', + le: '≤', + leftarrow: '←', + leftarrowtail: '↢', + leftharpoondown: '↽', + leftharpoonup: '↼', + leftleftarrows: '⇇', + leftrightarrow: '↔', + leftrightarrows: '⇆', + leftrightharpoons: '⇋', + leftrightsquigarrow: '↭', + leftthreetimes: '⋋', + leg: '⋚', + leq: '≤', + leqq: '≦', + leqslant: '⩽', + les: '⩽', + lescc: '⪨', + lesdot: '⩿', + lesdoto: '⪁', + lesdotor: '⪃', + lesg: '⋚︀', + lesges: '⪓', + lessapprox: '⪅', + lessdot: '⋖', + lesseqgtr: '⋚', + lesseqqgtr: '⪋', + lessgtr: '≶', + lesssim: '≲', + lfisht: '⥼', + lfloor: '⌊', + lfr: '𝔩', + lg: '≶', + lgE: '⪑', + lhard: '↽', + lharu: '↼', + lharul: '⥪', + lhblk: '▄', + ljcy: 'љ', + ll: '≪', + llarr: '⇇', + llcorner: '⌞', + llhard: '⥫', + lltri: '◺', + lmidot: 'ŀ', + lmoust: '⎰', + lmoustache: '⎰', + lnE: '≨', + lnap: '⪉', + lnapprox: '⪉', + lne: '⪇', + lneq: '⪇', + lneqq: '≨', + lnsim: '⋦', + loang: '⟬', + loarr: '⇽', + lobrk: '⟦', + longleftarrow: '⟵', + longleftrightarrow: '⟷', + longmapsto: '⟼', + longrightarrow: '⟶', + looparrowleft: '↫', + looparrowright: '↬', + lopar: '⦅', + lopf: '𝕝', + loplus: '⨭', + lotimes: '⨴', + lowast: '∗', + lowbar: '_', + loz: '◊', + lozenge: '◊', + lozf: '⧫', + lpar: '(', + lparlt: '⦓', + lrarr: '⇆', + lrcorner: '⌟', + lrhar: '⇋', + lrhard: '⥭', + lrm: '‎', + lrtri: '⊿', + lsaquo: '‹', + lscr: '𝓁', + lsh: '↰', + lsim: '≲', + lsime: '⪍', + lsimg: '⪏', + lsqb: '[', + lsquo: '‘', + lsquor: '‚', + lstrok: 'ł', + lt: '<', + ltcc: '⪦', + ltcir: '⩹', + ltdot: '⋖', + lthree: '⋋', + ltimes: '⋉', + ltlarr: '⥶', + ltquest: '⩻', + ltrPar: '⦖', + ltri: '◃', + ltrie: '⊴', + ltrif: '◂', + lurdshar: '⥊', + luruhar: '⥦', + lvertneqq: '≨︀', + lvnE: '≨︀', + mDDot: '∺', + macr: '¯', + male: '♂', + malt: '✠', + maltese: '✠', + map: '↦', + mapsto: '↦', + mapstodown: '↧', + mapstoleft: '↤', + mapstoup: '↥', + marker: '▮', + mcomma: '⨩', + mcy: 'м', + mdash: '—', + measuredangle: '∡', + mfr: '𝔪', + mho: '℧', + micro: 'µ', + mid: '∣', + midast: '*', + midcir: '⫰', + middot: '·', + minus: '−', + minusb: '⊟', + minusd: '∸', + minusdu: '⨪', + mlcp: '⫛', + mldr: '…', + mnplus: '∓', + models: '⊧', + mopf: '𝕞', + mp: '∓', + mscr: '𝓂', + mstpos: '∾', + mu: 'μ', + multimap: '⊸', + mumap: '⊸', + nGg: '⋙̸', + nGt: '≫⃒', + nGtv: '≫̸', + nLeftarrow: '⇍', + nLeftrightarrow: '⇎', + nLl: '⋘̸', + nLt: '≪⃒', + nLtv: '≪̸', + nRightarrow: '⇏', + nVDash: '⊯', + nVdash: '⊮', + nabla: '∇', + nacute: 'ń', + nang: '∠⃒', + nap: '≉', + napE: '⩰̸', + napid: '≋̸', + napos: 'ʼn', + napprox: '≉', + natur: '♮', + natural: '♮', + naturals: 'ℕ', + nbsp: ' ', + nbump: '≎̸', + nbumpe: '≏̸', + ncap: '⩃', + ncaron: 'ň', + ncedil: 'ņ', + ncong: '≇', + ncongdot: '⩭̸', + ncup: '⩂', + ncy: 'н', + ndash: '–', + ne: '≠', + neArr: '⇗', + nearhk: '⤤', + nearr: '↗', + nearrow: '↗', + nedot: '≐̸', + nequiv: '≢', + nesear: '⤨', + nesim: '≂̸', + nexist: '∄', + nexists: '∄', + nfr: '𝔫', + ngE: '≧̸', + nge: '≱', + ngeq: '≱', + ngeqq: '≧̸', + ngeqslant: '⩾̸', + nges: '⩾̸', + ngsim: '≵', + ngt: '≯', + ngtr: '≯', + nhArr: '⇎', + nharr: '↮', + nhpar: '⫲', + ni: '∋', + nis: '⋼', + nisd: '⋺', + niv: '∋', + njcy: 'њ', + nlArr: '⇍', + nlE: '≦̸', + nlarr: '↚', + nldr: '‥', + nle: '≰', + nleftarrow: '↚', + nleftrightarrow: '↮', + nleq: '≰', + nleqq: '≦̸', + nleqslant: '⩽̸', + nles: '⩽̸', + nless: '≮', + nlsim: '≴', + nlt: '≮', + nltri: '⋪', + nltrie: '⋬', + nmid: '∤', + nopf: '𝕟', + not: '¬', + notin: '∉', + notinE: '⋹̸', + notindot: '⋵̸', + notinva: '∉', + notinvb: '⋷', + notinvc: '⋶', + notni: '∌', + notniva: '∌', + notnivb: '⋾', + notnivc: '⋽', + npar: '∦', + nparallel: '∦', + nparsl: '⫽⃥', + npart: '∂̸', + npolint: '⨔', + npr: '⊀', + nprcue: '⋠', + npre: '⪯̸', + nprec: '⊀', + npreceq: '⪯̸', + nrArr: '⇏', + nrarr: '↛', + nrarrc: '⤳̸', + nrarrw: '↝̸', + nrightarrow: '↛', + nrtri: '⋫', + nrtrie: '⋭', + nsc: '⊁', + nsccue: '⋡', + nsce: '⪰̸', + nscr: '𝓃', + nshortmid: '∤', + nshortparallel: '∦', + nsim: '≁', + nsime: '≄', + nsimeq: '≄', + nsmid: '∤', + nspar: '∦', + nsqsube: '⋢', + nsqsupe: '⋣', + nsub: '⊄', + nsubE: '⫅̸', + nsube: '⊈', + nsubset: '⊂⃒', + nsubseteq: '⊈', + nsubseteqq: '⫅̸', + nsucc: '⊁', + nsucceq: '⪰̸', + nsup: '⊅', + nsupE: '⫆̸', + nsupe: '⊉', + nsupset: '⊃⃒', + nsupseteq: '⊉', + nsupseteqq: '⫆̸', + ntgl: '≹', + ntilde: 'ñ', + ntlg: '≸', + ntriangleleft: '⋪', + ntrianglelefteq: '⋬', + ntriangleright: '⋫', + ntrianglerighteq: '⋭', + nu: 'ν', + num: '#', + numero: '№', + numsp: ' ', + nvDash: '⊭', + nvHarr: '⤄', + nvap: '≍⃒', + nvdash: '⊬', + nvge: '≥⃒', + nvgt: '>⃒', + nvinfin: '⧞', + nvlArr: '⤂', + nvle: '≤⃒', + nvlt: '<⃒', + nvltrie: '⊴⃒', + nvrArr: '⤃', + nvrtrie: '⊵⃒', + nvsim: '∼⃒', + nwArr: '⇖', + nwarhk: '⤣', + nwarr: '↖', + nwarrow: '↖', + nwnear: '⤧', + oS: 'Ⓢ', + oacute: 'ó', + oast: '⊛', + ocir: '⊚', + ocirc: 'ô', + ocy: 'о', + odash: '⊝', + odblac: 'ő', + odiv: '⨸', + odot: '⊙', + odsold: '⦼', + oelig: 'œ', + ofcir: '⦿', + ofr: '𝔬', + ogon: '˛', + ograve: 'ò', + ogt: '⧁', + ohbar: '⦵', + ohm: 'Ω', + oint: '∮', + olarr: '↺', + olcir: '⦾', + olcross: '⦻', + oline: '‾', + olt: '⧀', + omacr: 'ō', + omega: 'ω', + omicron: 'ο', + omid: '⦶', + ominus: '⊖', + oopf: '𝕠', + opar: '⦷', + operp: '⦹', + oplus: '⊕', + or: '∨', + orarr: '↻', + ord: '⩝', + order: 'ℴ', + orderof: 'ℴ', + ordf: 'ª', + ordm: 'º', + origof: '⊶', + oror: '⩖', + orslope: '⩗', + orv: '⩛', + oscr: 'ℴ', + oslash: 'ø', + osol: '⊘', + otilde: 'õ', + otimes: '⊗', + otimesas: '⨶', + ouml: 'ö', + ovbar: '⌽', + par: '∥', + para: '¶', + parallel: '∥', + parsim: '⫳', + parsl: '⫽', + part: '∂', + pcy: 'п', + percnt: '%', + period: '.', + permil: '‰', + perp: '⊥', + pertenk: '‱', + pfr: '𝔭', + phi: 'φ', + phiv: 'ϕ', + phmmat: 'ℳ', + phone: '☎', + pi: 'π', + pitchfork: '⋔', + piv: 'ϖ', + planck: 'ℏ', + planckh: 'ℎ', + plankv: 'ℏ', + plus: '+', + plusacir: '⨣', + plusb: '⊞', + pluscir: '⨢', + plusdo: '∔', + plusdu: '⨥', + pluse: '⩲', + plusmn: '±', + plussim: '⨦', + plustwo: '⨧', + pm: '±', + pointint: '⨕', + popf: '𝕡', + pound: '£', + pr: '≺', + prE: '⪳', + prap: '⪷', + prcue: '≼', + pre: '⪯', + prec: '≺', + precapprox: '⪷', + preccurlyeq: '≼', + preceq: '⪯', + precnapprox: '⪹', + precneqq: '⪵', + precnsim: '⋨', + precsim: '≾', + prime: '′', + primes: 'ℙ', + prnE: '⪵', + prnap: '⪹', + prnsim: '⋨', + prod: '∏', + profalar: '⌮', + profline: '⌒', + profsurf: '⌓', + prop: '∝', + propto: '∝', + prsim: '≾', + prurel: '⊰', + pscr: '𝓅', + psi: 'ψ', + puncsp: ' ', + qfr: '𝔮', + qint: '⨌', + qopf: '𝕢', + qprime: '⁗', + qscr: '𝓆', + quaternions: 'ℍ', + quatint: '⨖', + quest: '?', + questeq: '≟', + quot: '"', + rAarr: '⇛', + rArr: '⇒', + rAtail: '⤜', + rBarr: '⤏', + rHar: '⥤', + race: '∽̱', + racute: 'ŕ', + radic: '√', + raemptyv: '⦳', + rang: '⟩', + rangd: '⦒', + range: '⦥', + rangle: '⟩', + raquo: '»', + rarr: '→', + rarrap: '⥵', + rarrb: '⇥', + rarrbfs: '⤠', + rarrc: '⤳', + rarrfs: '⤞', + rarrhk: '↪', + rarrlp: '↬', + rarrpl: '⥅', + rarrsim: '⥴', + rarrtl: '↣', + rarrw: '↝', + ratail: '⤚', + ratio: '∶', + rationals: 'ℚ', + rbarr: '⤍', + rbbrk: '❳', + rbrace: '}', + rbrack: ']', + rbrke: '⦌', + rbrksld: '⦎', + rbrkslu: '⦐', + rcaron: 'ř', + rcedil: 'ŗ', + rceil: '⌉', + rcub: '}', + rcy: 'р', + rdca: '⤷', + rdldhar: '⥩', + rdquo: '”', + rdquor: '”', + rdsh: '↳', + real: 'ℜ', + realine: 'ℛ', + realpart: 'ℜ', + reals: 'ℝ', + rect: '▭', + reg: '®', + rfisht: '⥽', + rfloor: '⌋', + rfr: '𝔯', + rhard: '⇁', + rharu: '⇀', + rharul: '⥬', + rho: 'ρ', + rhov: 'ϱ', + rightarrow: '→', + rightarrowtail: '↣', + rightharpoondown: '⇁', + rightharpoonup: '⇀', + rightleftarrows: '⇄', + rightleftharpoons: '⇌', + rightrightarrows: '⇉', + rightsquigarrow: '↝', + rightthreetimes: '⋌', + ring: '˚', + risingdotseq: '≓', + rlarr: '⇄', + rlhar: '⇌', + rlm: '‏', + rmoust: '⎱', + rmoustache: '⎱', + rnmid: '⫮', + roang: '⟭', + roarr: '⇾', + robrk: '⟧', + ropar: '⦆', + ropf: '𝕣', + roplus: '⨮', + rotimes: '⨵', + rpar: ')', + rpargt: '⦔', + rppolint: '⨒', + rrarr: '⇉', + rsaquo: '›', + rscr: '𝓇', + rsh: '↱', + rsqb: ']', + rsquo: '’', + rsquor: '’', + rthree: '⋌', + rtimes: '⋊', + rtri: '▹', + rtrie: '⊵', + rtrif: '▸', + rtriltri: '⧎', + ruluhar: '⥨', + rx: '℞', + sacute: 'ś', + sbquo: '‚', + sc: '≻', + scE: '⪴', + scap: '⪸', + scaron: 'š', + sccue: '≽', + sce: '⪰', + scedil: 'ş', + scirc: 'ŝ', + scnE: '⪶', + scnap: '⪺', + scnsim: '⋩', + scpolint: '⨓', + scsim: '≿', + scy: 'с', + sdot: '⋅', + sdotb: '⊡', + sdote: '⩦', + seArr: '⇘', + searhk: '⤥', + searr: '↘', + searrow: '↘', + sect: '§', + semi: ';', + seswar: '⤩', + setminus: '∖', + setmn: '∖', + sext: '✶', + sfr: '𝔰', + sfrown: '⌢', + sharp: '♯', + shchcy: 'щ', + shcy: 'ш', + shortmid: '∣', + shortparallel: '∥', + shy: '­', + sigma: 'σ', + sigmaf: 'ς', + sigmav: 'ς', + sim: '∼', + simdot: '⩪', + sime: '≃', + simeq: '≃', + simg: '⪞', + simgE: '⪠', + siml: '⪝', + simlE: '⪟', + simne: '≆', + simplus: '⨤', + simrarr: '⥲', + slarr: '←', + smallsetminus: '∖', + smashp: '⨳', + smeparsl: '⧤', + smid: '∣', + smile: '⌣', + smt: '⪪', + smte: '⪬', + smtes: '⪬︀', + softcy: 'ь', + sol: '/', + solb: '⧄', + solbar: '⌿', + sopf: '𝕤', + spades: '♠', + spadesuit: '♠', + spar: '∥', + sqcap: '⊓', + sqcaps: '⊓︀', + sqcup: '⊔', + sqcups: '⊔︀', + sqsub: '⊏', + sqsube: '⊑', + sqsubset: '⊏', + sqsubseteq: '⊑', + sqsup: '⊐', + sqsupe: '⊒', + sqsupset: '⊐', + sqsupseteq: '⊒', + squ: '□', + square: '□', + squarf: '▪', + squf: '▪', + srarr: '→', + sscr: '𝓈', + ssetmn: '∖', + ssmile: '⌣', + sstarf: '⋆', + star: '☆', + starf: '★', + straightepsilon: 'ϵ', + straightphi: 'ϕ', + strns: '¯', + sub: '⊂', + subE: '⫅', + subdot: '⪽', + sube: '⊆', + subedot: '⫃', + submult: '⫁', + subnE: '⫋', + subne: '⊊', + subplus: '⪿', + subrarr: '⥹', + subset: '⊂', + subseteq: '⊆', + subseteqq: '⫅', + subsetneq: '⊊', + subsetneqq: '⫋', + subsim: '⫇', + subsub: '⫕', + subsup: '⫓', + succ: '≻', + succapprox: '⪸', + succcurlyeq: '≽', + succeq: '⪰', + succnapprox: '⪺', + succneqq: '⪶', + succnsim: '⋩', + succsim: '≿', + sum: '∑', + sung: '♪', + sup1: '¹', + sup2: '²', + sup3: '³', + sup: '⊃', + supE: '⫆', + supdot: '⪾', + supdsub: '⫘', + supe: '⊇', + supedot: '⫄', + suphsol: '⟉', + suphsub: '⫗', + suplarr: '⥻', + supmult: '⫂', + supnE: '⫌', + supne: '⊋', + supplus: '⫀', + supset: '⊃', + supseteq: '⊇', + supseteqq: '⫆', + supsetneq: '⊋', + supsetneqq: '⫌', + supsim: '⫈', + supsub: '⫔', + supsup: '⫖', + swArr: '⇙', + swarhk: '⤦', + swarr: '↙', + swarrow: '↙', + swnwar: '⤪', + szlig: 'ß', + target: '⌖', + tau: 'τ', + tbrk: '⎴', + tcaron: 'ť', + tcedil: 'ţ', + tcy: 'т', + tdot: '⃛', + telrec: '⌕', + tfr: '𝔱', + there4: '∴', + therefore: '∴', + theta: 'θ', + thetasym: 'ϑ', + thetav: 'ϑ', + thickapprox: '≈', + thicksim: '∼', + thinsp: ' ', + thkap: '≈', + thksim: '∼', + thorn: 'þ', + tilde: '˜', + times: '×', + timesb: '⊠', + timesbar: '⨱', + timesd: '⨰', + tint: '∭', + toea: '⤨', + top: '⊤', + topbot: '⌶', + topcir: '⫱', + topf: '𝕥', + topfork: '⫚', + tosa: '⤩', + tprime: '‴', + trade: '™', + triangle: '▵', + triangledown: '▿', + triangleleft: '◃', + trianglelefteq: '⊴', + triangleq: '≜', + triangleright: '▹', + trianglerighteq: '⊵', + tridot: '◬', + trie: '≜', + triminus: '⨺', + triplus: '⨹', + trisb: '⧍', + tritime: '⨻', + trpezium: '⏢', + tscr: '𝓉', + tscy: 'ц', + tshcy: 'ћ', + tstrok: 'ŧ', + twixt: '≬', + twoheadleftarrow: '↞', + twoheadrightarrow: '↠', + uArr: '⇑', + uHar: '⥣', + uacute: 'ú', + uarr: '↑', + ubrcy: 'ў', + ubreve: 'ŭ', + ucirc: 'û', + ucy: 'у', + udarr: '⇅', + udblac: 'ű', + udhar: '⥮', + ufisht: '⥾', + ufr: '𝔲', + ugrave: 'ù', + uharl: '↿', + uharr: '↾', + uhblk: '▀', + ulcorn: '⌜', + ulcorner: '⌜', + ulcrop: '⌏', + ultri: '◸', + umacr: 'ū', + uml: '¨', + uogon: 'ų', + uopf: '𝕦', + uparrow: '↑', + updownarrow: '↕', + upharpoonleft: '↿', + upharpoonright: '↾', + uplus: '⊎', + upsi: 'υ', + upsih: 'ϒ', + upsilon: 'υ', + upuparrows: '⇈', + urcorn: '⌝', + urcorner: '⌝', + urcrop: '⌎', + uring: 'ů', + urtri: '◹', + uscr: '𝓊', + utdot: '⋰', + utilde: 'ũ', + utri: '▵', + utrif: '▴', + uuarr: '⇈', + uuml: 'ü', + uwangle: '⦧', + vArr: '⇕', + vBar: '⫨', + vBarv: '⫩', + vDash: '⊨', + vangrt: '⦜', + varepsilon: 'ϵ', + varkappa: 'ϰ', + varnothing: '∅', + varphi: 'ϕ', + varpi: 'ϖ', + varpropto: '∝', + varr: '↕', + varrho: 'ϱ', + varsigma: 'ς', + varsubsetneq: '⊊︀', + varsubsetneqq: '⫋︀', + varsupsetneq: '⊋︀', + varsupsetneqq: '⫌︀', + vartheta: 'ϑ', + vartriangleleft: '⊲', + vartriangleright: '⊳', + vcy: 'в', + vdash: '⊢', + vee: '∨', + veebar: '⊻', + veeeq: '≚', + vellip: '⋮', + verbar: '|', + vert: '|', + vfr: '𝔳', + vltri: '⊲', + vnsub: '⊂⃒', + vnsup: '⊃⃒', + vopf: '𝕧', + vprop: '∝', + vrtri: '⊳', + vscr: '𝓋', + vsubnE: '⫋︀', + vsubne: '⊊︀', + vsupnE: '⫌︀', + vsupne: '⊋︀', + vzigzag: '⦚', + wcirc: 'ŵ', + wedbar: '⩟', + wedge: '∧', + wedgeq: '≙', + weierp: '℘', + wfr: '𝔴', + wopf: '𝕨', + wp: '℘', + wr: '≀', + wreath: '≀', + wscr: '𝓌', + xcap: '⋂', + xcirc: '◯', + xcup: '⋃', + xdtri: '▽', + xfr: '𝔵', + xhArr: '⟺', + xharr: '⟷', + xi: 'ξ', + xlArr: '⟸', + xlarr: '⟵', + xmap: '⟼', + xnis: '⋻', + xodot: '⨀', + xopf: '𝕩', + xoplus: '⨁', + xotime: '⨂', + xrArr: '⟹', + xrarr: '⟶', + xscr: '𝓍', + xsqcup: '⨆', + xuplus: '⨄', + xutri: '△', + xvee: '⋁', + xwedge: '⋀', + yacute: 'ý', + yacy: 'я', + ycirc: 'ŷ', + ycy: 'ы', + yen: '¥', + yfr: '𝔶', + yicy: 'ї', + yopf: '𝕪', + yscr: '𝓎', + yucy: 'ю', + yuml: 'ÿ', + zacute: 'ź', + zcaron: 'ž', + zcy: 'з', + zdot: 'ż', + zeetrf: 'ℨ', + zeta: 'ζ', + zfr: '𝔷', + zhcy: 'ж', + zigrarr: '⇝', + zopf: '𝕫', + zscr: '𝓏', + zwj: '‍', + zwnj: '‌' +}; + +const own$1 = {}.hasOwnProperty; + +/** + * Decode a single character reference (without the `&` or `;`). + * You probably only need this when you’re building parsers yourself that follow + * different rules compared to HTML. + * This is optimized to be tiny in browsers. + * + * @param {string} value + * `notin` (named), `#123` (deci), `#x123` (hexa). + * @returns {string|false} + * Decoded reference. + */ +function decodeNamedCharacterReference(value) { + return own$1.call(characterEntities, value) ? characterEntities[value] : false +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const characterReference = { + name: 'characterReference', + tokenize: tokenizeCharacterReference +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCharacterReference(effects, ok, nok) { + const self = this; + let size = 0; + /** @type {number} */ + let max; + /** @type {(code: Code) => boolean} */ + let test; + return start + + /** + * Start of character reference. + * + * ```markdown + * > | a&b + * ^ + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('characterReference'); + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + return open + } + + /** + * After `&`, at `#` for numeric references or alphanumeric for named + * references. + * + * ```markdown + * > | a&b + * ^ + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 35) { + effects.enter('characterReferenceMarkerNumeric'); + effects.consume(code); + effects.exit('characterReferenceMarkerNumeric'); + return numeric + } + effects.enter('characterReferenceValue'); + max = 31; + test = asciiAlphanumeric; + return value(code) + } + + /** + * After `#`, at `x` for hexadecimals or digit for decimals. + * + * ```markdown + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function numeric(code) { + if (code === 88 || code === 120) { + effects.enter('characterReferenceMarkerHexadecimal'); + effects.consume(code); + effects.exit('characterReferenceMarkerHexadecimal'); + effects.enter('characterReferenceValue'); + max = 6; + test = asciiHexDigit; + return value + } + effects.enter('characterReferenceValue'); + max = 7; + test = asciiDigit; + return value(code) + } + + /** + * After markers (`&#x`, `&#`, or `&`), in value, before `;`. + * + * The character reference kind defines what and how many characters are + * allowed. + * + * ```markdown + * > | a&b + * ^^^ + * > | a{b + * ^^^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function value(code) { + if (code === 59 && size) { + const token = effects.exit('characterReferenceValue'); + if ( + test === asciiAlphanumeric && + !decodeNamedCharacterReference(self.sliceSerialize(token)) + ) { + return nok(code) + } + + // To do: `markdown-rs` uses a different name: + // `CharacterReferenceMarkerSemi`. + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + effects.exit('characterReference'); + return ok + } + if (test(code) && size++ < max) { + effects.consume(code); + return value + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const nonLazyContinuation = { + tokenize: tokenizeNonLazyContinuation, + partial: true +}; + +/** @type {Construct} */ +const codeFenced = { + name: 'codeFenced', + tokenize: tokenizeCodeFenced, + concrete: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeFenced(effects, ok, nok) { + const self = this; + /** @type {Construct} */ + const closeStart = { + tokenize: tokenizeCloseStart, + partial: true + }; + let initialPrefix = 0; + let sizeOpen = 0; + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of code. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse whitespace like `markdown-rs`. + return beforeSequenceOpen(code) + } + + /** + * In opening fence, after prefix, at sequence. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function beforeSequenceOpen(code) { + const tail = self.events[self.events.length - 1]; + initialPrefix = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + marker = code; + effects.enter('codeFenced'); + effects.enter('codeFencedFence'); + effects.enter('codeFencedFenceSequence'); + return sequenceOpen(code) + } + + /** + * In opening fence sequence. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === marker) { + sizeOpen++; + effects.consume(code); + return sequenceOpen + } + if (sizeOpen < 3) { + return nok(code) + } + effects.exit('codeFencedFenceSequence'); + return markdownSpace(code) + ? factorySpace(effects, infoBefore, 'whitespace')(code) + : infoBefore(code) + } + + /** + * In opening fence, after the sequence (and optional whitespace), before info. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function infoBefore(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return self.interrupt + ? ok(code) + : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) + } + effects.enter('codeFencedFenceInfo'); + effects.enter('chunkString', { + contentType: 'string' + }); + return info(code) + } + + /** + * In info. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function info(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return infoBefore(code) + } + if (markdownSpace(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return factorySpace(effects, metaBefore, 'whitespace')(code) + } + if (code === 96 && code === marker) { + return nok(code) + } + effects.consume(code); + return info + } + + /** + * In opening fence, after info and whitespace, before meta. + * + * ```markdown + * > | ~~~js eval + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function metaBefore(code) { + if (code === null || markdownLineEnding(code)) { + return infoBefore(code) + } + effects.enter('codeFencedFenceMeta'); + effects.enter('chunkString', { + contentType: 'string' + }); + return meta(code) + } + + /** + * In meta. + * + * ```markdown + * > | ~~~js eval + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function meta(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceMeta'); + return infoBefore(code) + } + if (code === 96 && code === marker) { + return nok(code) + } + effects.consume(code); + return meta + } + + /** + * At eol/eof in code, before a non-lazy closing fence or content. + * + * ```markdown + * > | ~~~js + * ^ + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function atNonLazyBreak(code) { + return effects.attempt(closeStart, after, contentBefore)(code) + } + + /** + * Before code content, not a closing fence, at eol. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentBefore(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return contentStart + } + + /** + * Before code content, not a closing fence. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentStart(code) { + return initialPrefix > 0 && markdownSpace(code) + ? factorySpace( + effects, + beforeContentChunk, + 'linePrefix', + initialPrefix + 1 + )(code) + : beforeContentChunk(code) + } + + /** + * Before code content, after optional prefix. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function beforeContentChunk(code) { + if (code === null || markdownLineEnding(code)) { + return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) + } + effects.enter('codeFlowValue'); + return contentChunk(code) + } + + /** + * In code content. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^^^^^^^^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentChunk(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return beforeContentChunk(code) + } + effects.consume(code); + return contentChunk + } + + /** + * After code. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + effects.exit('codeFenced'); + return ok(code) + } + + /** + * @this {TokenizeContext} + * @type {Tokenizer} + */ + function tokenizeCloseStart(effects, ok, nok) { + let size = 0; + return startBefore + + /** + * + * + * @type {State} + */ + function startBefore(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return start + } + + /** + * Before closing fence, at optional whitespace. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // Always populated by defaults. + + // To do: `enter` here or in next state? + effects.enter('codeFencedFence'); + return markdownSpace(code) + ? factorySpace( + effects, + beforeSequenceClose, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + : beforeSequenceClose(code) + } + + /** + * In closing fence, after optional whitespace, at sequence. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function beforeSequenceClose(code) { + if (code === marker) { + effects.enter('codeFencedFenceSequence'); + return sequenceClose(code) + } + return nok(code) + } + + /** + * In closing fence sequence. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function sequenceClose(code) { + if (code === marker) { + size++; + effects.consume(code); + return sequenceClose + } + if (size >= sizeOpen) { + effects.exit('codeFencedFenceSequence'); + return markdownSpace(code) + ? factorySpace(effects, sequenceCloseAfter, 'whitespace')(code) + : sequenceCloseAfter(code) + } + return nok(code) + } + + /** + * After closing fence sequence, after optional whitespace. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function sequenceCloseAfter(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return ok(code) + } + return nok(code) + } + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeNonLazyContinuation(effects, ok, nok) { + const self = this; + return start + + /** + * + * + * @type {State} + */ + function start(code) { + if (code === null) { + return nok(code) + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineStart + } + + /** + * + * + * @type {State} + */ + function lineStart(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const codeIndented = { + name: 'codeIndented', + tokenize: tokenizeCodeIndented +}; + +/** @type {Construct} */ +const furtherStart = { + tokenize: tokenizeFurtherStart, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeIndented(effects, ok, nok) { + const self = this; + return start + + /** + * Start of code (indented). + * + * > **Parsing note**: it is not needed to check if this first line is a + * > filled line (that it has a non-whitespace character), because blank lines + * > are parsed already, so we never run into that. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: manually check if interrupting like `markdown-rs`. + + effects.enter('codeIndented'); + // To do: use an improved `space_or_tab` function like `markdown-rs`, + // so that we can drop the next state. + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + + /** + * At start, after 1 or 4 spaces. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? atBreak(code) + : nok(code) + } + + /** + * At a break. + * + * ```markdown + * > | aaa + * ^ ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === null) { + return after(code) + } + if (markdownLineEnding(code)) { + return effects.attempt(furtherStart, atBreak, after)(code) + } + effects.enter('codeFlowValue'); + return inside(code) + } + + /** + * In code content. + * + * ```markdown + * > | aaa + * ^^^^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return atBreak(code) + } + effects.consume(code); + return inside + } + + /** @type {State} */ + function after(code) { + effects.exit('codeIndented'); + // To do: allow interrupting like `markdown-rs`. + // Feel free to interrupt. + // tokenizer.interrupt = false + return ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeFurtherStart(effects, ok, nok) { + const self = this; + return furtherStart + + /** + * At eol, trying to parse another indent. + * + * ```markdown + * > | aaa + * ^ + * | bbb + * ``` + * + * @type {State} + */ + function furtherStart(code) { + // To do: improve `lazy` / `pierce` handling. + // If this is a lazy line, it can’t be code. + if (self.parser.lazy[self.now().line]) { + return nok(code) + } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return furtherStart + } + + // To do: the code here in `micromark-js` is a bit different from + // `markdown-rs` because there it can attempt spaces. + // We can’t yet. + // + // To do: use an improved `space_or_tab` function like `markdown-rs`, + // so that we can drop the next state. + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + + /** + * At start, after 1 or 4 spaces. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? ok(code) + : markdownLineEnding(code) + ? furtherStart(code) + : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Previous} Previous + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const codeText = { + name: 'codeText', + tokenize: tokenizeCodeText, + resolve: resolveCodeText, + previous +}; + +// To do: next major: don’t resolve, like `markdown-rs`. +/** @type {Resolver} */ +function resolveCodeText(events) { + let tailExitIndex = events.length - 4; + let headEnterIndex = 3; + /** @type {number} */ + let index; + /** @type {number | undefined} */ + let enter; + + // If we start and end with an EOL or a space. + if ( + (events[headEnterIndex][1].type === 'lineEnding' || + events[headEnterIndex][1].type === 'space') && + (events[tailExitIndex][1].type === 'lineEnding' || + events[tailExitIndex][1].type === 'space') + ) { + index = headEnterIndex; + + // And we have data. + while (++index < tailExitIndex) { + if (events[index][1].type === 'codeTextData') { + // Then we have padding. + events[headEnterIndex][1].type = 'codeTextPadding'; + events[tailExitIndex][1].type = 'codeTextPadding'; + headEnterIndex += 2; + tailExitIndex -= 2; + break + } + } + } + + // Merge adjacent spaces and data. + index = headEnterIndex - 1; + tailExitIndex++; + while (++index <= tailExitIndex) { + if (enter === undefined) { + if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { + enter = index; + } + } else if ( + index === tailExitIndex || + events[index][1].type === 'lineEnding' + ) { + events[enter][1].type = 'codeTextData'; + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + tailExitIndex -= index - enter - 2; + index = enter + 2; + } + enter = undefined; + } + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Previous} + */ +function previous(code) { + // If there is a previous code, there will always be a tail. + return ( + code !== 96 || + this.events[this.events.length - 1][1].type === 'characterEscape' + ) +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeText(effects, ok, nok) { + let sizeOpen = 0; + /** @type {number} */ + let size; + /** @type {Token} */ + let token; + return start + + /** + * Start of code (text). + * + * ```markdown + * > | `a` + * ^ + * > | \`a` + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('codeText'); + effects.enter('codeTextSequence'); + return sequenceOpen(code) + } + + /** + * In opening sequence. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === 96) { + effects.consume(code); + sizeOpen++; + return sequenceOpen + } + effects.exit('codeTextSequence'); + return between(code) + } + + /** + * Between something and something else. + * + * ```markdown + * > | `a` + * ^^ + * ``` + * + * @type {State} + */ + function between(code) { + // EOF. + if (code === null) { + return nok(code) + } + + // To do: next major: don’t do spaces in resolve, but when compiling, + // like `markdown-rs`. + // Tabs don’t work, and virtual spaces don’t make sense. + if (code === 32) { + effects.enter('space'); + effects.consume(code); + effects.exit('space'); + return between + } + + // Closing fence? Could also be data. + if (code === 96) { + token = effects.enter('codeTextSequence'); + size = 0; + return sequenceClose(code) + } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return between + } + + // Data. + effects.enter('codeTextData'); + return data(code) + } + + /** + * In data. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function data(code) { + if ( + code === null || + code === 32 || + code === 96 || + markdownLineEnding(code) + ) { + effects.exit('codeTextData'); + return between(code) + } + effects.consume(code); + return data + } + + /** + * In closing sequence. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function sequenceClose(code) { + // More. + if (code === 96) { + effects.consume(code); + size++; + return sequenceClose + } + + // Done! + if (size === sizeOpen) { + effects.exit('codeTextSequence'); + effects.exit('codeText'); + return ok(code) + } + + // More or less accents: mark as data. + token.type = 'codeTextData'; + return data(code) + } +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Token} Token + */ + +/** + * Tokenize subcontent. + * + * @param {Array} events + * List of events. + * @returns {boolean} + * Whether subtokens were found. + */ +function subtokenize(events) { + /** @type {Record} */ + const jumps = {}; + let index = -1; + /** @type {Event} */ + let event; + /** @type {number | undefined} */ + let lineIndex; + /** @type {number} */ + let otherIndex; + /** @type {Event} */ + let otherEvent; + /** @type {Array} */ + let parameters; + /** @type {Array} */ + let subevents; + /** @type {boolean | undefined} */ + let more; + while (++index < events.length) { + while (index in jumps) { + index = jumps[index]; + } + event = events[index]; + + // Add a hook for the GFM tasklist extension, which needs to know if text + // is in the first content of a list item. + if ( + index && + event[1].type === 'chunkFlow' && + events[index - 1][1].type === 'listItemPrefix' + ) { + subevents = event[1]._tokenizer.events; + otherIndex = 0; + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'lineEndingBlank' + ) { + otherIndex += 2; + } + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'content' + ) { + while (++otherIndex < subevents.length) { + if (subevents[otherIndex][1].type === 'content') { + break + } + if (subevents[otherIndex][1].type === 'chunkText') { + subevents[otherIndex][1]._isInFirstContentOfListItem = true; + otherIndex++; + } + } + } + } + + // Enter. + if (event[0] === 'enter') { + if (event[1].contentType) { + Object.assign(jumps, subcontent(events, index)); + index = jumps[index]; + more = true; + } + } + // Exit. + else if (event[1]._container) { + otherIndex = index; + lineIndex = undefined; + while (otherIndex--) { + otherEvent = events[otherIndex]; + if ( + otherEvent[1].type === 'lineEnding' || + otherEvent[1].type === 'lineEndingBlank' + ) { + if (otherEvent[0] === 'enter') { + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + } + otherEvent[1].type = 'lineEnding'; + lineIndex = otherIndex; + } + } else { + break + } + } + if (lineIndex) { + // Fix position. + event[1].end = Object.assign({}, events[lineIndex][1].start); + + // Switch container exit w/ line endings. + parameters = events.slice(lineIndex, index); + parameters.unshift(event); + splice(events, lineIndex, index - lineIndex + 1, parameters); + } + } + } + return !more +} + +/** + * Tokenize embedded tokens. + * + * @param {Array} events + * @param {number} eventIndex + * @returns {Record} + */ +function subcontent(events, eventIndex) { + const token = events[eventIndex][1]; + const context = events[eventIndex][2]; + let startPosition = eventIndex - 1; + /** @type {Array} */ + const startPositions = []; + const tokenizer = + token._tokenizer || context.parser[token.contentType](token.start); + const childEvents = tokenizer.events; + /** @type {Array<[number, number]>} */ + const jumps = []; + /** @type {Record} */ + const gaps = {}; + /** @type {Array} */ + let stream; + /** @type {Token | undefined} */ + let previous; + let index = -1; + /** @type {Token | undefined} */ + let current = token; + let adjust = 0; + let start = 0; + const breaks = [start]; + + // Loop forward through the linked tokens to pass them in order to the + // subtokenizer. + while (current) { + // Find the position of the event for this token. + while (events[++startPosition][1] !== current) { + // Empty. + } + startPositions.push(startPosition); + if (!current._tokenizer) { + stream = context.sliceStream(current); + if (!current.next) { + stream.push(null); + } + if (previous) { + tokenizer.defineSkip(current.start); + } + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = true; + } + tokenizer.write(stream); + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = undefined; + } + } + + // Unravel the next token. + previous = current; + current = current.next; + } + + // Now, loop back through all events (and linked tokens), to figure out which + // parts belong where. + current = token; + while (++index < childEvents.length) { + if ( + // Find a void token that includes a break. + childEvents[index][0] === 'exit' && + childEvents[index - 1][0] === 'enter' && + childEvents[index][1].type === childEvents[index - 1][1].type && + childEvents[index][1].start.line !== childEvents[index][1].end.line + ) { + start = index + 1; + breaks.push(start); + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + current = current.next; + } + } + + // Help GC. + tokenizer.events = []; + + // If there’s one more token (which is the cases for lines that end in an + // EOF), that’s perfect: the last point we found starts it. + // If there isn’t then make sure any remaining content is added to it. + if (current) { + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + } else { + breaks.pop(); + } + + // Now splice the events from the subtokenizer into the current events, + // moving back to front so that splice indices aren’t affected. + index = breaks.length; + while (index--) { + const slice = childEvents.slice(breaks[index], breaks[index + 1]); + const start = startPositions.pop(); + jumps.unshift([start, start + slice.length - 1]); + splice(events, start, 2, slice); + } + index = -1; + while (++index < jumps.length) { + gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; + adjust += jumps[index][1] - jumps[index][0] - 1; + } + return gaps +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** + * No name because it must not be turned off. + * @type {Construct} + */ +const content = { + tokenize: tokenizeContent, + resolve: resolveContent +}; + +/** @type {Construct} */ +const continuationConstruct = { + tokenize: tokenizeContinuation, + partial: true +}; + +/** + * Content is transparent: it’s parsed right now. That way, definitions are also + * parsed right now: before text in paragraphs (specifically, media) are parsed. + * + * @type {Resolver} + */ +function resolveContent(events) { + subtokenize(events); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContent(effects, ok) { + /** @type {Token | undefined} */ + let previous; + return chunkStart + + /** + * Before a content chunk. + * + * ```markdown + * > | abc + * ^ + * ``` + * + * @type {State} + */ + function chunkStart(code) { + effects.enter('content'); + previous = effects.enter('chunkContent', { + contentType: 'content' + }); + return chunkInside(code) + } + + /** + * In a content chunk. + * + * ```markdown + * > | abc + * ^^^ + * ``` + * + * @type {State} + */ + function chunkInside(code) { + if (code === null) { + return contentEnd(code) + } + + // To do: in `markdown-rs`, each line is parsed on its own, and everything + // is stitched together resolving. + if (markdownLineEnding(code)) { + return effects.check( + continuationConstruct, + contentContinue, + contentEnd + )(code) + } + + // Data. + effects.consume(code); + return chunkInside + } + + /** + * + * + * @type {State} + */ + function contentEnd(code) { + effects.exit('chunkContent'); + effects.exit('content'); + return ok(code) + } + + /** + * + * + * @type {State} + */ + function contentContinue(code) { + effects.consume(code); + effects.exit('chunkContent'); + previous.next = effects.enter('chunkContent', { + contentType: 'content', + previous + }); + previous = previous.next; + return chunkInside + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContinuation(effects, ok, nok) { + const self = this; + return startLookahead + + /** + * + * + * @type {State} + */ + function startLookahead(code) { + effects.exit('chunkContent'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, prefixed, 'linePrefix') + } + + /** + * + * + * @type {State} + */ + function prefixed(code) { + if (code === null || markdownLineEnding(code)) { + return nok(code) + } + + // Always populated by defaults. + + const tail = self.events[self.events.length - 1]; + if ( + !self.parser.constructs.disable.null.includes('codeIndented') && + tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ) { + return ok(code) + } + return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse destinations. + * + * ###### Examples + * + * ```markdown + * + * b> + * + * + * a + * a\)b + * a(b)c + * a(b) + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type for whole (`` or `b`). + * @param {TokenType} literalType + * Type when enclosed (``). + * @param {TokenType} literalMarkerType + * Type for enclosing (`<` and `>`). + * @param {TokenType} rawType + * Type when not enclosed (`b`). + * @param {TokenType} stringType + * Type for the value (`a` or `b`). + * @param {number | undefined} [max=Infinity] + * Depth of nested parens (inclusive). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryDestination( + effects, + ok, + nok, + type, + literalType, + literalMarkerType, + rawType, + stringType, + max +) { + const limit = max || Number.POSITIVE_INFINITY; + let balance = 0; + return start + + /** + * Start of destination. + * + * ```markdown + * > | + * ^ + * > | aa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 60) { + effects.enter(type); + effects.enter(literalType); + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + return enclosedBefore + } + + // ASCII control, space, closing paren. + if (code === null || code === 32 || code === 41 || asciiControl(code)) { + return nok(code) + } + effects.enter(type); + effects.enter(rawType); + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return raw(code) + } + + /** + * After `<`, at an enclosed destination. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosedBefore(code) { + if (code === 62) { + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + effects.exit(literalType); + effects.exit(type); + return ok + } + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return enclosed(code) + } + + /** + * In enclosed destination. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosed(code) { + if (code === 62) { + effects.exit('chunkString'); + effects.exit(stringType); + return enclosedBefore(code) + } + if (code === null || code === 60 || markdownLineEnding(code)) { + return nok(code) + } + effects.consume(code); + return code === 92 ? enclosedEscape : enclosed + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosedEscape(code) { + if (code === 60 || code === 62 || code === 92) { + effects.consume(code); + return enclosed + } + return enclosed(code) + } + + /** + * In raw destination. + * + * ```markdown + * > | aa + * ^ + * ``` + * + * @type {State} + */ + function raw(code) { + if ( + !balance && + (code === null || code === 41 || markdownLineEndingOrSpace(code)) + ) { + effects.exit('chunkString'); + effects.exit(stringType); + effects.exit(rawType); + effects.exit(type); + return ok(code) + } + if (balance < limit && code === 40) { + effects.consume(code); + balance++; + return raw + } + if (code === 41) { + effects.consume(code); + balance--; + return raw + } + + // ASCII control (but *not* `\0`) and space and `(`. + // Note: in `markdown-rs`, `\0` exists in codes, in `micromark-js` it + // doesn’t. + if (code === null || code === 32 || code === 40 || asciiControl(code)) { + return nok(code) + } + effects.consume(code); + return code === 92 ? rawEscape : raw + } + + /** + * After `\`, at special character. + * + * ```markdown + * > | a\*a + * ^ + * ``` + * + * @type {State} + */ + function rawEscape(code) { + if (code === 40 || code === 41 || code === 92) { + effects.consume(code); + return raw + } + return raw(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse labels. + * + * > 👉 **Note**: labels in markdown are capped at 999 characters in the string. + * + * ###### Examples + * + * ```markdown + * [a] + * [a + * b] + * [a\]b] + * ``` + * + * @this {TokenizeContext} + * Tokenize context. + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type of the whole label (`[a]`). + * @param {TokenType} markerType + * Type for the markers (`[` and `]`). + * @param {TokenType} stringType + * Type for the identifier (`a`). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryLabel(effects, ok, nok, type, markerType, stringType) { + const self = this; + let size = 0; + /** @type {boolean} */ + let seen; + return start + + /** + * Start of label. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.enter(stringType); + return atBreak + } + + /** + * In label, at something, before something else. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if ( + size > 999 || + code === null || + code === 91 || + (code === 93 && !seen) || + // To do: remove in the future once we’ve switched from + // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`, + // which doesn’t need this. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + (code === 94 && + !size && + '_hiddenFootnoteSupport' in self.parser.constructs) + ) { + return nok(code) + } + if (code === 93) { + effects.exit(stringType); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } + + // To do: indent? Link chunks and EOLs together? + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return atBreak + } + effects.enter('chunkString', { + contentType: 'string' + }); + return labelInside(code) + } + + /** + * In label, in text. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function labelInside(code) { + if ( + code === null || + code === 91 || + code === 93 || + markdownLineEnding(code) || + size++ > 999 + ) { + effects.exit('chunkString'); + return atBreak(code) + } + effects.consume(code); + if (!seen) seen = !markdownSpace(code); + return code === 92 ? labelEscape : labelInside + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | [a\*a] + * ^ + * ``` + * + * @type {State} + */ + function labelEscape(code) { + if (code === 91 || code === 92 || code === 93) { + effects.consume(code); + size++; + return labelInside + } + return labelInside(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse titles. + * + * ###### Examples + * + * ```markdown + * "a" + * 'b' + * (c) + * "a + * b" + * 'a + * b' + * (a\)b) + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type of the whole title (`"a"`, `'b'`, `(c)`). + * @param {TokenType} markerType + * Type for the markers (`"`, `'`, `(`, and `)`). + * @param {TokenType} stringType + * Type for the value (`a`). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryTitle(effects, ok, nok, type, markerType, stringType) { + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of title. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 34 || code === 39 || code === 40) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + marker = code === 40 ? 41 : code; + return begin + } + return nok(code) + } + + /** + * After opening marker. + * + * This is also used at the closing marker. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function begin(code) { + if (code === marker) { + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } + effects.enter(stringType); + return atBreak(code) + } + + /** + * At something, before something else. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === marker) { + effects.exit(stringType); + return begin(marker) + } + if (code === null) { + return nok(code) + } + + // Note: blank lines can’t exist in content. + if (markdownLineEnding(code)) { + // To do: use `space_or_tab_eol_with_options`, connect. + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, atBreak, 'linePrefix') + } + effects.enter('chunkString', { + contentType: 'string' + }); + return inside(code) + } + + /** + * + * + * @type {State} + */ + function inside(code) { + if (code === marker || code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + return atBreak(code) + } + effects.consume(code); + return code === 92 ? escape : inside + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | "a\*b" + * ^ + * ``` + * + * @type {State} + */ + function escape(code) { + if (code === marker || code === 92) { + effects.consume(code); + return inside + } + return inside(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + */ + +/** + * Parse spaces and tabs. + * + * There is no `nok` parameter: + * + * * line endings or spaces in markdown are often optional, in which case this + * factory can be used and `ok` will be switched to whether spaces were found + * or not + * * one line ending or space can be detected with + * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @returns + * Start state. + */ +function factoryWhitespace(effects, ok) { + /** @type {boolean} */ + let seen; + return start + + /** @type {State} */ + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + seen = true; + return start + } + if (markdownSpace(code)) { + return factorySpace( + effects, + start, + seen ? 'linePrefix' : 'lineSuffix' + )(code) + } + return ok(code) + } +} + +/** + * Normalize an identifier (as found in references, definitions). + * + * Collapses markdown whitespace, trim, and then lower- and uppercase. + * + * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their + * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different + * uppercase character (U+0398 (`Θ`)). + * So, to get a canonical form, we perform both lower- and uppercase. + * + * Using uppercase last makes sure keys will never interact with default + * prototypal values (such as `constructor`): nothing in the prototype of + * `Object` is uppercase. + * + * @param {string} value + * Identifier to normalize. + * @returns {string} + * Normalized identifier. + */ +function normalizeIdentifier(value) { + return ( + value + // Collapse markdown whitespace. + .replace(/[\t\n\r ]+/g, ' ') + // Trim. + .replace(/^ | $/g, '') + // Some characters are considered “uppercase”, but if their lowercase + // counterpart is uppercased will result in a different uppercase + // character. + // Hence, to get that form, we perform both lower- and uppercase. + // Upper case makes sure keys will not interact with default prototypal + // methods: no method is uppercase. + .toLowerCase() + .toUpperCase() + ) +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const definition = { + name: 'definition', + tokenize: tokenizeDefinition +}; + +/** @type {Construct} */ +const titleBefore = { + tokenize: tokenizeTitleBefore, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeDefinition(effects, ok, nok) { + const self = this; + /** @type {string} */ + let identifier; + return start + + /** + * At start of a definition. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // Do not interrupt paragraphs (but do follow definitions). + // To do: do `interrupt` the way `markdown-rs` does. + // To do: parse whitespace the way `markdown-rs` does. + effects.enter('definition'); + return before(code) + } + + /** + * After optional whitespace, at `[`. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + // To do: parse whitespace the way `markdown-rs` does. + + return factoryLabel.call( + self, + effects, + labelAfter, + // Note: we don’t need to reset the way `markdown-rs` does. + nok, + 'definitionLabel', + 'definitionLabelMarker', + 'definitionLabelString' + )(code) + } + + /** + * After label. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function labelAfter(code) { + identifier = normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ); + if (code === 58) { + effects.enter('definitionMarker'); + effects.consume(code); + effects.exit('definitionMarker'); + return markerAfter + } + return nok(code) + } + + /** + * After marker. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function markerAfter(code) { + // Note: whitespace is optional. + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, destinationBefore)(code) + : destinationBefore(code) + } + + /** + * Before destination. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function destinationBefore(code) { + return factoryDestination( + effects, + destinationAfter, + // Note: we don’t need to reset the way `markdown-rs` does. + nok, + 'definitionDestination', + 'definitionDestinationLiteral', + 'definitionDestinationLiteralMarker', + 'definitionDestinationRaw', + 'definitionDestinationString' + )(code) + } + + /** + * After destination. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function destinationAfter(code) { + return effects.attempt(titleBefore, after, after)(code) + } + + /** + * After definition. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return markdownSpace(code) + ? factorySpace(effects, afterWhitespace, 'whitespace')(code) + : afterWhitespace(code) + } + + /** + * After definition, after optional whitespace. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function afterWhitespace(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('definition'); + + // Note: we don’t care about uniqueness. + // It’s likely that that doesn’t happen very frequently. + // It is more likely that it wastes precious time. + self.parser.defined.push(identifier); + + // To do: `markdown-rs` interrupt. + // // You’d be interrupting. + // tokenizer.interrupt = true + return ok(code) + } + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeTitleBefore(effects, ok, nok) { + return titleBefore + + /** + * After destination, at whitespace. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleBefore(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, beforeMarker)(code) + : nok(code) + } + + /** + * At title. + * + * ```markdown + * | [a]: b + * > | "c" + * ^ + * ``` + * + * @type {State} + */ + function beforeMarker(code) { + return factoryTitle( + effects, + titleAfter, + nok, + 'definitionTitle', + 'definitionTitleMarker', + 'definitionTitleString' + )(code) + } + + /** + * After title. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleAfter(code) { + return markdownSpace(code) + ? factorySpace(effects, titleAfterOptionalWhitespace, 'whitespace')(code) + : titleAfterOptionalWhitespace(code) + } + + /** + * After title, after optional whitespace. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleAfterOptionalWhitespace(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const hardBreakEscape = { + name: 'hardBreakEscape', + tokenize: tokenizeHardBreakEscape +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHardBreakEscape(effects, ok, nok) { + return start + + /** + * Start of a hard break (escape). + * + * ```markdown + * > | a\ + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('hardBreakEscape'); + effects.consume(code); + return after + } + + /** + * After `\`, at eol. + * + * ```markdown + * > | a\ + * ^ + * | b + * ``` + * + * @type {State} + */ + function after(code) { + if (markdownLineEnding(code)) { + effects.exit('hardBreakEscape'); + return ok(code) + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const headingAtx = { + name: 'headingAtx', + tokenize: tokenizeHeadingAtx, + resolve: resolveHeadingAtx +}; + +/** @type {Resolver} */ +function resolveHeadingAtx(events, context) { + let contentEnd = events.length - 2; + let contentStart = 3; + /** @type {Token} */ + let content; + /** @type {Token} */ + let text; + + // Prefix whitespace, part of the opening. + if (events[contentStart][1].type === 'whitespace') { + contentStart += 2; + } + + // Suffix whitespace, part of the closing. + if ( + contentEnd - 2 > contentStart && + events[contentEnd][1].type === 'whitespace' + ) { + contentEnd -= 2; + } + if ( + events[contentEnd][1].type === 'atxHeadingSequence' && + (contentStart === contentEnd - 1 || + (contentEnd - 4 > contentStart && + events[contentEnd - 2][1].type === 'whitespace')) + ) { + contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; + } + if (contentEnd > contentStart) { + content = { + type: 'atxHeadingText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end + }; + text = { + type: 'chunkText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end, + contentType: 'text' + }; + splice(events, contentStart, contentEnd - contentStart + 1, [ + ['enter', content, context], + ['enter', text, context], + ['exit', text, context], + ['exit', content, context] + ]); + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHeadingAtx(effects, ok, nok) { + let size = 0; + return start + + /** + * Start of a heading (atx). + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse indent like `markdown-rs`. + effects.enter('atxHeading'); + return before(code) + } + + /** + * After optional whitespace, at `#`. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('atxHeadingSequence'); + return sequenceOpen(code) + } + + /** + * In opening sequence. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === 35 && size++ < 6) { + effects.consume(code); + return sequenceOpen + } + + // Always at least one `#`. + if (code === null || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingSequence'); + return atBreak(code) + } + return nok(code) + } + + /** + * After something, before something else. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === 35) { + effects.enter('atxHeadingSequence'); + return sequenceFurther(code) + } + if (code === null || markdownLineEnding(code)) { + effects.exit('atxHeading'); + // To do: interrupt like `markdown-rs`. + // // Feel free to interrupt. + // tokenizer.interrupt = false + return ok(code) + } + if (markdownSpace(code)) { + return factorySpace(effects, atBreak, 'whitespace')(code) + } + + // To do: generate `data` tokens, add the `text` token later. + // Needs edit map, see: `markdown.rs`. + effects.enter('atxHeadingText'); + return data(code) + } + + /** + * In further sequence (after whitespace). + * + * Could be normal “visible” hashes in the heading or a final sequence. + * + * ```markdown + * > | ## aa ## + * ^ + * ``` + * + * @type {State} + */ + function sequenceFurther(code) { + if (code === 35) { + effects.consume(code); + return sequenceFurther + } + effects.exit('atxHeadingSequence'); + return atBreak(code) + } + + /** + * In text. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function data(code) { + if (code === null || code === 35 || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingText'); + return atBreak(code) + } + effects.consume(code); + return data + } +} + +/** + * List of lowercase HTML “block” tag names. + * + * The list, when parsing HTML (flow), results in more relaxed rules (condition + * 6). + * Because they are known blocks, the HTML-like syntax doesn’t have to be + * strictly parsed. + * For tag names not in this list, a more strict algorithm (condition 7) is used + * to detect whether the HTML-like syntax is seen as HTML (flow) or not. + * + * This is copied from: + * . + * + * > 👉 **Note**: `search` was added in `CommonMark@0.31`. + */ +const htmlBlockNames = [ + 'address', + 'article', + 'aside', + 'base', + 'basefont', + 'blockquote', + 'body', + 'caption', + 'center', + 'col', + 'colgroup', + 'dd', + 'details', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', + 'fieldset', + 'figcaption', + 'figure', + 'footer', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hr', + 'html', + 'iframe', + 'legend', + 'li', + 'link', + 'main', + 'menu', + 'menuitem', + 'nav', + 'noframes', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'search', + 'section', + 'summary', + 'table', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'title', + 'tr', + 'track', + 'ul' +]; + +/** + * List of lowercase HTML “raw” tag names. + * + * The list, when parsing HTML (flow), results in HTML that can include lines + * without exiting, until a closing tag also in this list is found (condition + * 1). + * + * This module is copied from: + * . + * + * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`. + */ +const htmlRawNames = ['pre', 'script', 'style', 'textarea']; + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const htmlFlow = { + name: 'htmlFlow', + tokenize: tokenizeHtmlFlow, + resolveTo: resolveToHtmlFlow, + concrete: true +}; + +/** @type {Construct} */ +const blankLineBefore = { + tokenize: tokenizeBlankLineBefore, + partial: true +}; +const nonLazyContinuationStart = { + tokenize: tokenizeNonLazyContinuationStart, + partial: true +}; + +/** @type {Resolver} */ +function resolveToHtmlFlow(events) { + let index = events.length; + while (index--) { + if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { + break + } + } + if (index > 1 && events[index - 2][1].type === 'linePrefix') { + // Add the prefix start to the HTML token. + events[index][1].start = events[index - 2][1].start; + // Add the prefix start to the HTML line token. + events[index + 1][1].start = events[index - 2][1].start; + // Remove the line prefix. + events.splice(index - 2, 2); + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHtmlFlow(effects, ok, nok) { + const self = this; + /** @type {number} */ + let marker; + /** @type {boolean} */ + let closingTag; + /** @type {string} */ + let buffer; + /** @type {number} */ + let index; + /** @type {Code} */ + let markerB; + return start + + /** + * Start of HTML (flow). + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse indent like `markdown-rs`. + return before(code) + } + + /** + * At `<`, after optional whitespace. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('htmlFlow'); + effects.enter('htmlFlowData'); + effects.consume(code); + return open + } + + /** + * After `<`, at tag name or other stuff. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } + if (code === 47) { + effects.consume(code); + closingTag = true; + return tagCloseStart + } + if (code === 63) { + effects.consume(code); + marker = 3; + // To do: + // tokenizer.concrete = true + // To do: use `markdown-rs` style interrupt. + // While we’re in an instruction instead of a declaration, we’re on a `?` + // right now, so we do need to search for `>`, similar to declarations. + return self.interrupt ? ok : continuationDeclarationInside + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + // @ts-expect-error: not null. + buffer = String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * After ` | + * ^ + * > | + * ^ + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + marker = 2; + return commentOpenInside + } + if (code === 91) { + effects.consume(code); + marker = 5; + index = 0; + return cdataOpenInside + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + marker = 4; + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuationDeclarationInside + } + return nok(code) + } + + /** + * After ` | + * ^ + * ``` + * + * @type {State} + */ + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuationDeclarationInside + } + return nok(code) + } + + /** + * After ` | &<]]> + * ^^^^^^ + * ``` + * + * @type {State} + */ + function cdataOpenInside(code) { + const value = 'CDATA['; + if (code === value.charCodeAt(index++)) { + effects.consume(code); + if (index === value.length) { + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuation + } + return cdataOpenInside + } + return nok(code) + } + + /** + * After ` | + * ^ + * ``` + * + * @type {State} + */ + function tagCloseStart(code) { + if (asciiAlpha(code)) { + effects.consume(code); + // @ts-expect-error: not null. + buffer = String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * In tag name. + * + * ```markdown + * > | + * ^^ + * > | + * ^^ + * ``` + * + * @type {State} + */ + function tagName(code) { + if ( + code === null || + code === 47 || + code === 62 || + markdownLineEndingOrSpace(code) + ) { + const slash = code === 47; + const name = buffer.toLowerCase(); + if (!slash && !closingTag && htmlRawNames.includes(name)) { + marker = 1; + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok(code) : continuation(code) + } + if (htmlBlockNames.includes(buffer.toLowerCase())) { + marker = 6; + if (slash) { + effects.consume(code); + return basicSelfClosing + } + + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok(code) : continuation(code) + } + marker = 7; + // Do not support complete HTML when interrupting. + return self.interrupt && !self.parser.lazy[self.now().line] + ? nok(code) + : closingTag + ? completeClosingTagAfter(code) + : completeAttributeNameBefore(code) + } + + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + buffer += String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * After closing slash of a basic tag name. + * + * ```markdown + * > |
+ * ^ + * ``` + * + * @type {State} + */ + function basicSelfClosing(code) { + if (code === 62) { + effects.consume(code); + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuation + } + return nok(code) + } + + /** + * After closing slash of a complete tag name. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeClosingTagAfter(code) { + if (markdownSpace(code)) { + effects.consume(code); + return completeClosingTagAfter + } + return completeEnd(code) + } + + /** + * At an attribute name. + * + * At first, this state is used after a complete tag name, after whitespace, + * where it expects optional attributes or the end of the tag. + * It is also reused after attributes, when expecting more optional + * attributes. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeNameBefore(code) { + if (code === 47) { + effects.consume(code); + return completeEnd + } + + // ASCII alphanumerical and `:` and `_`. + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return completeAttributeName + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameBefore + } + return completeEnd(code) + } + + /** + * In attribute name. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeName(code) { + // ASCII alphanumerical and `-`, `.`, `:`, and `_`. + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return completeAttributeName + } + return completeAttributeNameAfter(code) + } + + /** + * After attribute name, at an optional initializer, the end of the tag, or + * whitespace. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return completeAttributeValueBefore + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameAfter + } + return completeAttributeNameBefore(code) + } + + /** + * Before unquoted, double quoted, or single quoted attribute value, allowing + * whitespace. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } + if (code === 34 || code === 39) { + effects.consume(code); + markerB = code; + return completeAttributeValueQuoted + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeValueBefore + } + return completeAttributeValueUnquoted(code) + } + + /** + * In double or single quoted attribute value. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueQuoted(code) { + if (code === markerB) { + effects.consume(code); + markerB = null; + return completeAttributeValueQuotedAfter + } + if (code === null || markdownLineEnding(code)) { + return nok(code) + } + effects.consume(code); + return completeAttributeValueQuoted + } + + /** + * In unquoted attribute value. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 47 || + code === 60 || + code === 61 || + code === 62 || + code === 96 || + markdownLineEndingOrSpace(code) + ) { + return completeAttributeNameAfter(code) + } + effects.consume(code); + return completeAttributeValueUnquoted + } + + /** + * After double or single quoted attribute value, before whitespace or the + * end of the tag. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownSpace(code)) { + return completeAttributeNameBefore(code) + } + return nok(code) + } + + /** + * In certain circumstances of a complete tag where only an `>` is allowed. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeEnd(code) { + if (code === 62) { + effects.consume(code); + return completeAfter + } + return nok(code) + } + + /** + * After `>` in a complete tag. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAfter(code) { + if (code === null || markdownLineEnding(code)) { + // // Do not form containers. + // tokenizer.concrete = true + return continuation(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAfter + } + return nok(code) + } + + /** + * In continuation of any HTML kind. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuation(code) { + if (code === 45 && marker === 2) { + effects.consume(code); + return continuationCommentInside + } + if (code === 60 && marker === 1) { + effects.consume(code); + return continuationRawTagOpen + } + if (code === 62 && marker === 4) { + effects.consume(code); + return continuationClose + } + if (code === 63 && marker === 3) { + effects.consume(code); + return continuationDeclarationInside + } + if (code === 93 && marker === 5) { + effects.consume(code); + return continuationCdataInside + } + if (markdownLineEnding(code) && (marker === 6 || marker === 7)) { + effects.exit('htmlFlowData'); + return effects.check( + blankLineBefore, + continuationAfter, + continuationStart + )(code) + } + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return continuationStart(code) + } + effects.consume(code); + return continuation + } + + /** + * In continuation, at eol. + * + * ```markdown + * > | + * ^ + * | asd + * ``` + * + * @type {State} + */ + function continuationStart(code) { + return effects.check( + nonLazyContinuationStart, + continuationStartNonLazy, + continuationAfter + )(code) + } + + /** + * In continuation, at eol, before non-lazy content. + * + * ```markdown + * > | + * ^ + * | asd + * ``` + * + * @type {State} + */ + function continuationStartNonLazy(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return continuationBefore + } + + /** + * In continuation, before non-lazy content. + * + * ```markdown + * | + * > | asd + * ^ + * ``` + * + * @type {State} + */ + function continuationBefore(code) { + if (code === null || markdownLineEnding(code)) { + return continuationStart(code) + } + effects.enter('htmlFlowData'); + return continuation(code) + } + + /** + * In comment continuation, after one `-`, expecting another. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationCommentInside(code) { + if (code === 45) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In raw continuation, after `<`, at `/`. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationRawTagOpen(code) { + if (code === 47) { + effects.consume(code); + buffer = ''; + return continuationRawEndTag + } + return continuation(code) + } + + /** + * In raw continuation, after ` | + * ^^^^^^ + * ``` + * + * @type {State} + */ + function continuationRawEndTag(code) { + if (code === 62) { + const name = buffer.toLowerCase(); + if (htmlRawNames.includes(name)) { + effects.consume(code); + return continuationClose + } + return continuation(code) + } + if (asciiAlpha(code) && buffer.length < 8) { + effects.consume(code); + // @ts-expect-error: not null. + buffer += String.fromCharCode(code); + return continuationRawEndTag + } + return continuation(code) + } + + /** + * In cdata continuation, after `]`, expecting `]>`. + * + * ```markdown + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function continuationCdataInside(code) { + if (code === 93) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In declaration or instruction continuation, at `>`. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function continuationDeclarationInside(code) { + if (code === 62) { + effects.consume(code); + return continuationClose + } + + // More dashes. + if (code === 45 && marker === 2) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In closed continuation: everything we get until the eol/eof is part of it. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationClose(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return continuationAfter(code) + } + effects.consume(code); + return continuationClose + } + + /** + * Done. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationAfter(code) { + effects.exit('htmlFlow'); + // // Feel free to interrupt. + // tokenizer.interrupt = false + // // No longer concrete. + // tokenizer.concrete = false + return ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeNonLazyContinuationStart(effects, ok, nok) { + const self = this; + return start + + /** + * At eol, before continuation. + * + * ```markdown + * > | * ```js + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return after + } + return nok(code) + } + + /** + * A continuation. + * + * ```markdown + * | * ```js + * > | b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlankLineBefore(effects, ok, nok) { + return start + + /** + * Before eol, expecting blank line. + * + * ```markdown + * > |
+ * ^ + * | + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return effects.attempt(blankLine, ok, nok) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const htmlText = { + name: 'htmlText', + tokenize: tokenizeHtmlText +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHtmlText(effects, ok, nok) { + const self = this; + /** @type {NonNullable | undefined} */ + let marker; + /** @type {number} */ + let index; + /** @type {State} */ + let returnState; + return start + + /** + * Start of HTML (text). + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('htmlText'); + effects.enter('htmlTextData'); + effects.consume(code); + return open + } + + /** + * After `<`, at tag name or other stuff. + * + * ```markdown + * > | a c + * ^ + * > | a c + * ^ + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } + if (code === 47) { + effects.consume(code); + return tagCloseStart + } + if (code === 63) { + effects.consume(code); + return instruction + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + return tagOpen + } + return nok(code) + } + + /** + * After ` | a c + * ^ + * > | a c + * ^ + * > | a &<]]> c + * ^ + * ``` + * + * @type {State} + */ + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + return commentOpenInside + } + if (code === 91) { + effects.consume(code); + index = 0; + return cdataOpenInside + } + if (asciiAlpha(code)) { + effects.consume(code); + return declaration + } + return nok(code) + } + + /** + * In a comment, after ` | a c + * ^ + * ``` + * + * @type {State} + */ + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + return commentEnd + } + return nok(code) + } + + /** + * In comment. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function comment(code) { + if (code === null) { + return nok(code) + } + if (code === 45) { + effects.consume(code); + return commentClose + } + if (markdownLineEnding(code)) { + returnState = comment; + return lineEndingBefore(code) + } + effects.consume(code); + return comment + } + + /** + * In comment, after `-`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function commentClose(code) { + if (code === 45) { + effects.consume(code); + return commentEnd + } + return comment(code) + } + + /** + * In comment, after `--`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function commentEnd(code) { + return code === 62 + ? end(code) + : code === 45 + ? commentClose(code) + : comment(code) + } + + /** + * After ` | a &<]]> b + * ^^^^^^ + * ``` + * + * @type {State} + */ + function cdataOpenInside(code) { + const value = 'CDATA['; + if (code === value.charCodeAt(index++)) { + effects.consume(code); + return index === value.length ? cdata : cdataOpenInside + } + return nok(code) + } + + /** + * In CDATA. + * + * ```markdown + * > | a &<]]> b + * ^^^ + * ``` + * + * @type {State} + */ + function cdata(code) { + if (code === null) { + return nok(code) + } + if (code === 93) { + effects.consume(code); + return cdataClose + } + if (markdownLineEnding(code)) { + returnState = cdata; + return lineEndingBefore(code) + } + effects.consume(code); + return cdata + } + + /** + * In CDATA, after `]`, at another `]`. + * + * ```markdown + * > | a &<]]> b + * ^ + * ``` + * + * @type {State} + */ + function cdataClose(code) { + if (code === 93) { + effects.consume(code); + return cdataEnd + } + return cdata(code) + } + + /** + * In CDATA, after `]]`, at `>`. + * + * ```markdown + * > | a &<]]> b + * ^ + * ``` + * + * @type {State} + */ + function cdataEnd(code) { + if (code === 62) { + return end(code) + } + if (code === 93) { + effects.consume(code); + return cdataEnd + } + return cdata(code) + } + + /** + * In declaration. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function declaration(code) { + if (code === null || code === 62) { + return end(code) + } + if (markdownLineEnding(code)) { + returnState = declaration; + return lineEndingBefore(code) + } + effects.consume(code); + return declaration + } + + /** + * In instruction. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function instruction(code) { + if (code === null) { + return nok(code) + } + if (code === 63) { + effects.consume(code); + return instructionClose + } + if (markdownLineEnding(code)) { + returnState = instruction; + return lineEndingBefore(code) + } + effects.consume(code); + return instruction + } + + /** + * In instruction, after `?`, at `>`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function instructionClose(code) { + return code === 62 ? end(code) : instruction(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagCloseStart(code) { + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + return tagClose + } + return nok(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagClose(code) { + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagClose + } + return tagCloseBetween(code) + } + + /** + * In closing tag, after tag name. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function tagCloseBetween(code) { + if (markdownLineEnding(code)) { + returnState = tagCloseBetween; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagCloseBetween + } + return end(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagOpen(code) { + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagOpen + } + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + return nok(code) + } + + /** + * In opening tag, after tag name. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function tagOpenBetween(code) { + if (code === 47) { + effects.consume(code); + return end + } + + // ASCII alphabetical and `:` and `_`. + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return tagOpenAttributeName + } + if (markdownLineEnding(code)) { + returnState = tagOpenBetween; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenBetween + } + return end(code) + } + + /** + * In attribute name. + * + * ```markdown + * > | a d + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeName(code) { + // ASCII alphabetical and `-`, `.`, `:`, and `_`. + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return tagOpenAttributeName + } + return tagOpenAttributeNameAfter(code) + } + + /** + * After attribute name, before initializer, the end of the tag, or + * whitespace. + * + * ```markdown + * > | a d + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return tagOpenAttributeValueBefore + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeNameAfter; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeNameAfter + } + return tagOpenBetween(code) + } + + /** + * Before unquoted, double quoted, or single quoted attribute value, allowing + * whitespace. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } + if (code === 34 || code === 39) { + effects.consume(code); + marker = code; + return tagOpenAttributeValueQuoted + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueBefore; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeValueBefore + } + effects.consume(code); + return tagOpenAttributeValueUnquoted + } + + /** + * In double or single quoted attribute value. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueQuoted(code) { + if (code === marker) { + effects.consume(code); + marker = undefined; + return tagOpenAttributeValueQuotedAfter + } + if (code === null) { + return nok(code) + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueQuoted; + return lineEndingBefore(code) + } + effects.consume(code); + return tagOpenAttributeValueQuoted + } + + /** + * In unquoted attribute value. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 60 || + code === 61 || + code === 96 + ) { + return nok(code) + } + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + effects.consume(code); + return tagOpenAttributeValueUnquoted + } + + /** + * After double or single quoted attribute value, before whitespace or the end + * of the tag. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + return nok(code) + } + + /** + * In certain circumstances of a tag where only an `>` is allowed. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function end(code) { + if (code === 62) { + effects.consume(code); + effects.exit('htmlTextData'); + effects.exit('htmlText'); + return ok + } + return nok(code) + } + + /** + * At eol. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * > | a + * ``` + * + * @type {State} + */ + function lineEndingBefore(code) { + effects.exit('htmlTextData'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineEndingAfter + } + + /** + * After eol, at optional whitespace. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * | a + * ^ + * ``` + * + * @type {State} + */ + function lineEndingAfter(code) { + // Always populated by defaults. + + return markdownSpace(code) + ? factorySpace( + effects, + lineEndingAfterPrefix, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + : lineEndingAfterPrefix(code) + } + + /** + * After eol, after optional whitespace. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * | a + * ^ + * ``` + * + * @type {State} + */ + function lineEndingAfterPrefix(code) { + effects.enter('htmlTextData'); + return returnState(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const labelEnd = { + name: 'labelEnd', + tokenize: tokenizeLabelEnd, + resolveTo: resolveToLabelEnd, + resolveAll: resolveAllLabelEnd +}; + +/** @type {Construct} */ +const resourceConstruct = { + tokenize: tokenizeResource +}; +/** @type {Construct} */ +const referenceFullConstruct = { + tokenize: tokenizeReferenceFull +}; +/** @type {Construct} */ +const referenceCollapsedConstruct = { + tokenize: tokenizeReferenceCollapsed +}; + +/** @type {Resolver} */ +function resolveAllLabelEnd(events) { + let index = -1; + while (++index < events.length) { + const token = events[index][1]; + if ( + token.type === 'labelImage' || + token.type === 'labelLink' || + token.type === 'labelEnd' + ) { + // Remove the marker. + events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); + token.type = 'data'; + index++; + } + } + return events +} + +/** @type {Resolver} */ +function resolveToLabelEnd(events, context) { + let index = events.length; + let offset = 0; + /** @type {Token} */ + let token; + /** @type {number | undefined} */ + let open; + /** @type {number | undefined} */ + let close; + /** @type {Array} */ + let media; + + // Find an opening. + while (index--) { + token = events[index][1]; + if (open) { + // If we see another link, or inactive link label, we’ve been here before. + if ( + token.type === 'link' || + (token.type === 'labelLink' && token._inactive) + ) { + break + } + + // Mark other link openings as inactive, as we can’t have links in + // links. + if (events[index][0] === 'enter' && token.type === 'labelLink') { + token._inactive = true; + } + } else if (close) { + if ( + events[index][0] === 'enter' && + (token.type === 'labelImage' || token.type === 'labelLink') && + !token._balanced + ) { + open = index; + if (token.type !== 'labelLink') { + offset = 2; + break + } + } + } else if (token.type === 'labelEnd') { + close = index; + } + } + const group = { + type: events[open][1].type === 'labelLink' ? 'link' : 'image', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + const label = { + type: 'label', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[close][1].end) + }; + const text = { + type: 'labelText', + start: Object.assign({}, events[open + offset + 2][1].end), + end: Object.assign({}, events[close - 2][1].start) + }; + media = [ + ['enter', group, context], + ['enter', label, context] + ]; + + // Opening marker. + media = push(media, events.slice(open + 1, open + offset + 3)); + + // Text open. + media = push(media, [['enter', text, context]]); + + // Always populated by defaults. + + // Between. + media = push( + media, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + offset + 4, close - 3), + context + ) + ); + + // Text close, marker close, label close. + media = push(media, [ + ['exit', text, context], + events[close - 2], + events[close - 1], + ['exit', label, context] + ]); + + // Reference, resource, or so. + media = push(media, events.slice(close + 1)); + + // Media close. + media = push(media, [['exit', group, context]]); + splice(events, open, events.length, media); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelEnd(effects, ok, nok) { + const self = this; + let index = self.events.length; + /** @type {Token} */ + let labelStart; + /** @type {boolean} */ + let defined; + + // Find an opening. + while (index--) { + if ( + (self.events[index][1].type === 'labelImage' || + self.events[index][1].type === 'labelLink') && + !self.events[index][1]._balanced + ) { + labelStart = self.events[index][1]; + break + } + } + return start + + /** + * Start of label end. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ``` + * + * @type {State} + */ + function start(code) { + // If there is not an okay opening. + if (!labelStart) { + return nok(code) + } + + // If the corresponding label (link) start is marked as inactive, + // it means we’d be wrapping a link, like this: + // + // ```markdown + // > | a [b [c](d) e](f) g. + // ^ + // ``` + // + // We can’t have that, so it’s just balanced brackets. + if (labelStart._inactive) { + return labelEndNok(code) + } + defined = self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize({ + start: labelStart.end, + end: self.now() + }) + ) + ); + effects.enter('labelEnd'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelEnd'); + return after + } + + /** + * After `]`. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + // Note: `markdown-rs` also parses GFM footnotes here, which for us is in + // an extension. + + // Resource (`[asd](fgh)`)? + if (code === 40) { + return effects.attempt( + resourceConstruct, + labelEndOk, + defined ? labelEndOk : labelEndNok + )(code) + } + + // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference? + if (code === 91) { + return effects.attempt( + referenceFullConstruct, + labelEndOk, + defined ? referenceNotFull : labelEndNok + )(code) + } + + // Shortcut (`[asd]`) reference? + return defined ? labelEndOk(code) : labelEndNok(code) + } + + /** + * After `]`, at `[`, but not at a full reference. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function referenceNotFull(code) { + return effects.attempt( + referenceCollapsedConstruct, + labelEndOk, + labelEndNok + )(code) + } + + /** + * Done, we found something. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function labelEndOk(code) { + // Note: `markdown-rs` does a bunch of stuff here. + return ok(code) + } + + /** + * Done, it’s nothing. + * + * There was an okay opening, but we didn’t match anything. + * + * ```markdown + * > | [a](b c + * ^ + * > | [a][b c + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function labelEndNok(code) { + labelStart._balanced = true; + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeResource(effects, ok, nok) { + return resourceStart + + /** + * At a resource. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceStart(code) { + effects.enter('resource'); + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + return resourceBefore + } + + /** + * In resource, after `(`, at optional whitespace. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceBefore(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceOpen)(code) + : resourceOpen(code) + } + + /** + * In resource, after optional whitespace, at `)` or a destination. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceOpen(code) { + if (code === 41) { + return resourceEnd(code) + } + return factoryDestination( + effects, + resourceDestinationAfter, + resourceDestinationMissing, + 'resourceDestination', + 'resourceDestinationLiteral', + 'resourceDestinationLiteralMarker', + 'resourceDestinationRaw', + 'resourceDestinationString', + 32 + )(code) + } + + /** + * In resource, after destination, at optional whitespace. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceDestinationAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceBetween)(code) + : resourceEnd(code) + } + + /** + * At invalid destination. + * + * ```markdown + * > | [a](<<) b + * ^ + * ``` + * + * @type {State} + */ + function resourceDestinationMissing(code) { + return nok(code) + } + + /** + * In resource, after destination and whitespace, at `(` or title. + * + * ```markdown + * > | [a](b ) c + * ^ + * ``` + * + * @type {State} + */ + function resourceBetween(code) { + if (code === 34 || code === 39 || code === 40) { + return factoryTitle( + effects, + resourceTitleAfter, + nok, + 'resourceTitle', + 'resourceTitleMarker', + 'resourceTitleString' + )(code) + } + return resourceEnd(code) + } + + /** + * In resource, after title, at optional whitespace. + * + * ```markdown + * > | [a](b "c") d + * ^ + * ``` + * + * @type {State} + */ + function resourceTitleAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceEnd)(code) + : resourceEnd(code) + } + + /** + * In resource, at `)`. + * + * ```markdown + * > | [a](b) d + * ^ + * ``` + * + * @type {State} + */ + function resourceEnd(code) { + if (code === 41) { + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + effects.exit('resource'); + return ok + } + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeReferenceFull(effects, ok, nok) { + const self = this; + return referenceFull + + /** + * In a reference (full), at the `[`. + * + * ```markdown + * > | [a][b] d + * ^ + * ``` + * + * @type {State} + */ + function referenceFull(code) { + return factoryLabel.call( + self, + effects, + referenceFullAfter, + referenceFullMissing, + 'reference', + 'referenceMarker', + 'referenceString' + )(code) + } + + /** + * In a reference (full), after `]`. + * + * ```markdown + * > | [a][b] d + * ^ + * ``` + * + * @type {State} + */ + function referenceFullAfter(code) { + return self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ) + ) + ? ok(code) + : nok(code) + } + + /** + * In reference (full) that was missing. + * + * ```markdown + * > | [a][b d + * ^ + * ``` + * + * @type {State} + */ + function referenceFullMissing(code) { + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeReferenceCollapsed(effects, ok, nok) { + return referenceCollapsedStart + + /** + * In reference (collapsed), at `[`. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] d + * ^ + * ``` + * + * @type {State} + */ + function referenceCollapsedStart(code) { + // We only attempt a collapsed label if there’s a `[`. + + effects.enter('reference'); + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + return referenceCollapsedOpen + } + + /** + * In reference (collapsed), at `]`. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] d + * ^ + * ``` + * + * @type {State} + */ + function referenceCollapsedOpen(code) { + if (code === 93) { + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + effects.exit('reference'); + return ok + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const labelStartImage = { + name: 'labelStartImage', + tokenize: tokenizeLabelStartImage, + resolveAll: labelEnd.resolveAll +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelStartImage(effects, ok, nok) { + const self = this; + return start + + /** + * Start of label (image) start. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('labelImage'); + effects.enter('labelImageMarker'); + effects.consume(code); + effects.exit('labelImageMarker'); + return open + } + + /** + * After `!`, at `[`. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 91) { + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelImage'); + return after + } + return nok(code) + } + + /** + * After `![`. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * This is needed in because, when GFM footnotes are enabled, images never + * form when started with a `^`. + * Instead, links form: + * + * ```markdown + * ![^a](b) + * + * ![^a][b] + * + * [b]: c + * ``` + * + * ```html + *

!^a

+ *

!^a

+ * ``` + * + * @type {State} + */ + function after(code) { + // To do: use a new field to do this, this is still needed for + // `micromark-extension-gfm-footnote`, but the `label-start-link` + // behavior isn’t. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const labelStartLink = { + name: 'labelStartLink', + tokenize: tokenizeLabelStartLink, + resolveAll: labelEnd.resolveAll +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelStartLink(effects, ok, nok) { + const self = this; + return start + + /** + * Start of label (link) start. + * + * ```markdown + * > | a [b] c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('labelLink'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelLink'); + return after + } + + /** @type {State} */ + function after(code) { + // To do: this isn’t needed in `micromark-extension-gfm-footnote`, + // remove. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const lineEnding = { + name: 'lineEnding', + tokenize: tokenizeLineEnding +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLineEnding(effects, ok) { + return start + + /** @type {State} */ + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, ok, 'linePrefix') + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const thematicBreak = { + name: 'thematicBreak', + tokenize: tokenizeThematicBreak +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeThematicBreak(effects, ok, nok) { + let size = 0; + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of thematic break. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('thematicBreak'); + // To do: parse indent like `markdown-rs`. + return before(code) + } + + /** + * After optional whitespace, at marker. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + marker = code; + return atBreak(code) + } + + /** + * After something, before something else. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === marker) { + effects.enter('thematicBreakSequence'); + return sequence(code) + } + if (size >= 3 && (code === null || markdownLineEnding(code))) { + effects.exit('thematicBreak'); + return ok(code) + } + return nok(code) + } + + /** + * In sequence. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function sequence(code) { + if (code === marker) { + effects.consume(code); + size++; + return sequence + } + effects.exit('thematicBreakSequence'); + return markdownSpace(code) + ? factorySpace(effects, atBreak, 'whitespace')(code) + : atBreak(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ContainerState} ContainerState + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const list = { + name: 'list', + tokenize: tokenizeListStart, + continuation: { + tokenize: tokenizeListContinuation + }, + exit: tokenizeListEnd +}; + +/** @type {Construct} */ +const listItemPrefixWhitespaceConstruct = { + tokenize: tokenizeListItemPrefixWhitespace, + partial: true +}; + +/** @type {Construct} */ +const indentConstruct = { + tokenize: tokenizeIndent, + partial: true +}; + +// To do: `markdown-rs` parses list items on their own and later stitches them +// together. + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListStart(effects, ok, nok) { + const self = this; + const tail = self.events[self.events.length - 1]; + let initialSize = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + let size = 0; + return start + + /** @type {State} */ + function start(code) { + const kind = + self.containerState.type || + (code === 42 || code === 43 || code === 45 + ? 'listUnordered' + : 'listOrdered'); + if ( + kind === 'listUnordered' + ? !self.containerState.marker || code === self.containerState.marker + : asciiDigit(code) + ) { + if (!self.containerState.type) { + self.containerState.type = kind; + effects.enter(kind, { + _container: true + }); + } + if (kind === 'listUnordered') { + effects.enter('listItemPrefix'); + return code === 42 || code === 45 + ? effects.check(thematicBreak, nok, atMarker)(code) + : atMarker(code) + } + if (!self.interrupt || code === 49) { + effects.enter('listItemPrefix'); + effects.enter('listItemValue'); + return inside(code) + } + } + return nok(code) + } + + /** @type {State} */ + function inside(code) { + if (asciiDigit(code) && ++size < 10) { + effects.consume(code); + return inside + } + if ( + (!self.interrupt || size < 2) && + (self.containerState.marker + ? code === self.containerState.marker + : code === 41 || code === 46) + ) { + effects.exit('listItemValue'); + return atMarker(code) + } + return nok(code) + } + + /** + * @type {State} + **/ + function atMarker(code) { + effects.enter('listItemMarker'); + effects.consume(code); + effects.exit('listItemMarker'); + self.containerState.marker = self.containerState.marker || code; + return effects.check( + blankLine, + // Can’t be empty when interrupting. + self.interrupt ? nok : onBlank, + effects.attempt( + listItemPrefixWhitespaceConstruct, + endOfPrefix, + otherPrefix + ) + ) + } + + /** @type {State} */ + function onBlank(code) { + self.containerState.initialBlankLine = true; + initialSize++; + return endOfPrefix(code) + } + + /** @type {State} */ + function otherPrefix(code) { + if (markdownSpace(code)) { + effects.enter('listItemPrefixWhitespace'); + effects.consume(code); + effects.exit('listItemPrefixWhitespace'); + return endOfPrefix + } + return nok(code) + } + + /** @type {State} */ + function endOfPrefix(code) { + self.containerState.size = + initialSize + + self.sliceSerialize(effects.exit('listItemPrefix'), true).length; + return ok(code) + } +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListContinuation(effects, ok, nok) { + const self = this; + self.containerState._closeFlow = undefined; + return effects.check(blankLine, onBlank, notBlank) + + /** @type {State} */ + function onBlank(code) { + self.containerState.furtherBlankLines = + self.containerState.furtherBlankLines || + self.containerState.initialBlankLine; + + // We have a blank line. + // Still, try to consume at most the items size. + return factorySpace( + effects, + ok, + 'listItemIndent', + self.containerState.size + 1 + )(code) + } + + /** @type {State} */ + function notBlank(code) { + if (self.containerState.furtherBlankLines || !markdownSpace(code)) { + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return notInCurrentItem(code) + } + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) + } + + /** @type {State} */ + function notInCurrentItem(code) { + // While we do continue, we signal that the flow should be closed. + self.containerState._closeFlow = true; + // As we’re closing flow, we’re no longer interrupting. + self.interrupt = undefined; + // Always populated by defaults. + + return factorySpace( + effects, + effects.attempt(list, ok, nok), + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeIndent(effects, ok, nok) { + const self = this; + return factorySpace( + effects, + afterPrefix, + 'listItemIndent', + self.containerState.size + 1 + ) + + /** @type {State} */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'listItemIndent' && + tail[2].sliceSerialize(tail[1], true).length === self.containerState.size + ? ok(code) + : nok(code) + } +} + +/** + * @type {Exiter} + * @this {TokenizeContext} + */ +function tokenizeListEnd(effects) { + effects.exit(this.containerState.type); +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListItemPrefixWhitespace(effects, ok, nok) { + const self = this; + + // Always populated by defaults. + + return factorySpace( + effects, + afterPrefix, + 'listItemPrefixWhitespace', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + 1 + ) + + /** @type {State} */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return !markdownSpace(code) && + tail && + tail[1].type === 'listItemPrefixWhitespace' + ? ok(code) + : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const setextUnderline = { + name: 'setextUnderline', + tokenize: tokenizeSetextUnderline, + resolveTo: resolveToSetextUnderline +}; + +/** @type {Resolver} */ +function resolveToSetextUnderline(events, context) { + // To do: resolve like `markdown-rs`. + let index = events.length; + /** @type {number | undefined} */ + let content; + /** @type {number | undefined} */ + let text; + /** @type {number | undefined} */ + let definition; + + // Find the opening of the content. + // It’ll always exist: we don’t tokenize if it isn’t there. + while (index--) { + if (events[index][0] === 'enter') { + if (events[index][1].type === 'content') { + content = index; + break + } + if (events[index][1].type === 'paragraph') { + text = index; + } + } + // Exit + else { + if (events[index][1].type === 'content') { + // Remove the content end (if needed we’ll add it later) + events.splice(index, 1); + } + if (!definition && events[index][1].type === 'definition') { + definition = index; + } + } + } + const heading = { + type: 'setextHeading', + start: Object.assign({}, events[text][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + + // Change the paragraph to setext heading text. + events[text][1].type = 'setextHeadingText'; + + // If we have definitions in the content, we’ll keep on having content, + // but we need move it. + if (definition) { + events.splice(text, 0, ['enter', heading, context]); + events.splice(definition + 1, 0, ['exit', events[content][1], context]); + events[content][1].end = Object.assign({}, events[definition][1].end); + } else { + events[content][1] = heading; + } + + // Add the heading exit at the end. + events.push(['exit', heading, context]); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeSetextUnderline(effects, ok, nok) { + const self = this; + /** @type {NonNullable} */ + let marker; + return start + + /** + * At start of heading (setext) underline. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + let index = self.events.length; + /** @type {boolean | undefined} */ + let paragraph; + // Find an opening. + while (index--) { + // Skip enter/exit of line ending, line prefix, and content. + // We can now either have a definition or a paragraph. + if ( + self.events[index][1].type !== 'lineEnding' && + self.events[index][1].type !== 'linePrefix' && + self.events[index][1].type !== 'content' + ) { + paragraph = self.events[index][1].type === 'paragraph'; + break + } + } + + // To do: handle lazy/pierce like `markdown-rs`. + // To do: parse indent like `markdown-rs`. + if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { + effects.enter('setextHeadingLine'); + marker = code; + return before(code) + } + return nok(code) + } + + /** + * After optional whitespace, at `-` or `=`. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('setextHeadingLineSequence'); + return inside(code) + } + + /** + * In sequence. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === marker) { + effects.consume(code); + return inside + } + effects.exit('setextHeadingLineSequence'); + return markdownSpace(code) + ? factorySpace(effects, after, 'lineSuffix')(code) + : after(code) + } + + /** + * After sequence, after optional whitespace. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('setextHeadingLine'); + return ok(code) + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** @type {InitialConstruct} */ +const flow$1 = { + tokenize: initializeFlow +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeFlow(effects) { + const self = this; + const initial = effects.attempt( + // Try to parse a blank line. + blankLine, + atBlankEnding, + // Try to parse initial flow (essentially, only code). + effects.attempt( + this.parser.constructs.flowInitial, + afterConstruct, + factorySpace( + effects, + effects.attempt( + this.parser.constructs.flow, + afterConstruct, + effects.attempt(content, afterConstruct) + ), + 'linePrefix' + ) + ) + ); + return initial + + /** @type {State} */ + function atBlankEnding(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEndingBlank'); + effects.consume(code); + effects.exit('lineEndingBlank'); + self.currentConstruct = undefined; + return initial + } + + /** @type {State} */ + function afterConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + self.currentConstruct = undefined; + return initial + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +const resolver = { + resolveAll: createResolver() +}; +const string$1 = initializeFactory('string'); +const text$1 = initializeFactory('text'); + +/** + * @param {'string' | 'text'} field + * @returns {InitialConstruct} + */ +function initializeFactory(field) { + return { + tokenize: initializeText, + resolveAll: createResolver( + field === 'text' ? resolveAllLineSuffixes : undefined + ) + } + + /** + * @this {TokenizeContext} + * @type {Initializer} + */ + function initializeText(effects) { + const self = this; + const constructs = this.parser.constructs[field]; + const text = effects.attempt(constructs, start, notText); + return start + + /** @type {State} */ + function start(code) { + return atBreak(code) ? text(code) : notText(code) + } + + /** @type {State} */ + function notText(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('data'); + effects.consume(code); + return data + } + + /** @type {State} */ + function data(code) { + if (atBreak(code)) { + effects.exit('data'); + return text(code) + } + + // Data. + effects.consume(code); + return data + } + + /** + * @param {Code} code + * @returns {boolean} + */ + function atBreak(code) { + if (code === null) { + return true + } + const list = constructs[code]; + let index = -1; + if (list) { + // Always populated by defaults. + + while (++index < list.length) { + const item = list[index]; + if (!item.previous || item.previous.call(self, self.previous)) { + return true + } + } + } + return false + } + } +} + +/** + * @param {Resolver | undefined} [extraResolver] + * @returns {Resolver} + */ +function createResolver(extraResolver) { + return resolveAllText + + /** @type {Resolver} */ + function resolveAllText(events, context) { + let index = -1; + /** @type {number | undefined} */ + let enter; + + // A rather boring computation (to merge adjacent `data` events) which + // improves mm performance by 29%. + while (++index <= events.length) { + if (enter === undefined) { + if (events[index] && events[index][1].type === 'data') { + enter = index; + index++; + } + } else if (!events[index] || events[index][1].type !== 'data') { + // Don’t do anything if there is one data token. + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + index = enter + 2; + } + enter = undefined; + } + } + return extraResolver ? extraResolver(events, context) : events + } +} + +/** + * A rather ugly set of instructions which again looks at chunks in the input + * stream. + * The reason to do this here is that it is *much* faster to parse in reverse. + * And that we can’t hook into `null` to split the line suffix before an EOF. + * To do: figure out if we can make this into a clean utility, or even in core. + * As it will be useful for GFMs literal autolink extension (and maybe even + * tables?) + * + * @type {Resolver} + */ +function resolveAllLineSuffixes(events, context) { + let eventIndex = 0; // Skip first. + + while (++eventIndex <= events.length) { + if ( + (eventIndex === events.length || + events[eventIndex][1].type === 'lineEnding') && + events[eventIndex - 1][1].type === 'data' + ) { + const data = events[eventIndex - 1][1]; + const chunks = context.sliceStream(data); + let index = chunks.length; + let bufferIndex = -1; + let size = 0; + /** @type {boolean | undefined} */ + let tabs; + while (index--) { + const chunk = chunks[index]; + if (typeof chunk === 'string') { + bufferIndex = chunk.length; + while (chunk.charCodeAt(bufferIndex - 1) === 32) { + size++; + bufferIndex--; + } + if (bufferIndex) break + bufferIndex = -1; + } + // Number + else if (chunk === -2) { + tabs = true; + size++; + } else if (chunk === -1) ; else { + // Replacement character, exit. + index++; + break + } + } + if (size) { + const token = { + type: + eventIndex === events.length || tabs || size < 2 + ? 'lineSuffix' + : 'hardBreakTrailing', + start: { + line: data.end.line, + column: data.end.column - size, + offset: data.end.offset - size, + _index: data.start._index + index, + _bufferIndex: index + ? bufferIndex + : data.start._bufferIndex + bufferIndex + }, + end: Object.assign({}, data.end) + }; + data.end = Object.assign({}, token.start); + if (data.start.offset === data.end.offset) { + Object.assign(data, token); + } else { + events.splice( + eventIndex, + 0, + ['enter', token, context], + ['exit', token, context] + ); + eventIndex += 2; + } + } + eventIndex++; + } + } + return events +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ConstructRecord} ConstructRecord + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenType} TokenType + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** + * Create a tokenizer. + * Tokenizers deal with one type of data (e.g., containers, flow, text). + * The parser is the object dealing with it all. + * `initialize` works like other constructs, except that only its `tokenize` + * function is used, in which case it doesn’t receive an `ok` or `nok`. + * `from` can be given to set the point before the first character, although + * when further lines are indented, they must be set with `defineSkip`. + * + * @param {ParseContext} parser + * @param {InitialConstruct} initialize + * @param {Omit | undefined} [from] + * @returns {TokenizeContext} + */ +function createTokenizer(parser, initialize, from) { + /** @type {Point} */ + let point = Object.assign( + from + ? Object.assign({}, from) + : { + line: 1, + column: 1, + offset: 0 + }, + { + _index: 0, + _bufferIndex: -1 + } + ); + /** @type {Record} */ + const columnStart = {}; + /** @type {Array} */ + const resolveAllConstructs = []; + /** @type {Array} */ + let chunks = []; + /** @type {Array} */ + let stack = []; + + /** + * Tools used for tokenizing. + * + * @type {Effects} + */ + const effects = { + consume, + enter, + exit, + attempt: constructFactory(onsuccessfulconstruct), + check: constructFactory(onsuccessfulcheck), + interrupt: constructFactory(onsuccessfulcheck, { + interrupt: true + }) + }; + + /** + * State and tools for resolving and serializing. + * + * @type {TokenizeContext} + */ + const context = { + previous: null, + code: null, + containerState: {}, + events: [], + parser, + sliceStream, + sliceSerialize, + now, + defineSkip, + write + }; + + /** + * The state function. + * + * @type {State | void} + */ + let state = initialize.tokenize.call(context, effects); + if (initialize.resolveAll) { + resolveAllConstructs.push(initialize); + } + return context + + /** @type {TokenizeContext['write']} */ + function write(slice) { + chunks = push(chunks, slice); + main(); + + // Exit if we’re not done, resolve might change stuff. + if (chunks[chunks.length - 1] !== null) { + return [] + } + addResult(initialize, 0); + + // Otherwise, resolve, and exit. + context.events = resolveAll(resolveAllConstructs, context.events, context); + return context.events + } + + // + // Tools. + // + + /** @type {TokenizeContext['sliceSerialize']} */ + function sliceSerialize(token, expandTabs) { + return serializeChunks(sliceStream(token), expandTabs) + } + + /** @type {TokenizeContext['sliceStream']} */ + function sliceStream(token) { + return sliceChunks(chunks, token) + } + + /** @type {TokenizeContext['now']} */ + function now() { + // This is a hot path, so we clone manually instead of `Object.assign({}, point)` + const {line, column, offset, _index, _bufferIndex} = point; + return { + line, + column, + offset, + _index, + _bufferIndex + } + } + + /** @type {TokenizeContext['defineSkip']} */ + function defineSkip(value) { + columnStart[value.line] = value.column; + accountForPotentialSkip(); + } + + // + // State management. + // + + /** + * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by + * `consume`). + * Here is where we walk through the chunks, which either include strings of + * several characters, or numerical character codes. + * The reason to do this in a loop instead of a call is so the stack can + * drain. + * + * @returns {void} + */ + function main() { + /** @type {number} */ + let chunkIndex; + while (point._index < chunks.length) { + const chunk = chunks[point._index]; + + // If we’re in a buffer chunk, loop through it. + if (typeof chunk === 'string') { + chunkIndex = point._index; + if (point._bufferIndex < 0) { + point._bufferIndex = 0; + } + while ( + point._index === chunkIndex && + point._bufferIndex < chunk.length + ) { + go(chunk.charCodeAt(point._bufferIndex)); + } + } else { + go(chunk); + } + } + } + + /** + * Deal with one code. + * + * @param {Code} code + * @returns {void} + */ + function go(code) { + state = state(code); + } + + /** @type {Effects['consume']} */ + function consume(code) { + if (markdownLineEnding(code)) { + point.line++; + point.column = 1; + point.offset += code === -3 ? 2 : 1; + accountForPotentialSkip(); + } else if (code !== -1) { + point.column++; + point.offset++; + } + + // Not in a string chunk. + if (point._bufferIndex < 0) { + point._index++; + } else { + point._bufferIndex++; + + // At end of string chunk. + // @ts-expect-error Points w/ non-negative `_bufferIndex` reference + // strings. + if (point._bufferIndex === chunks[point._index].length) { + point._bufferIndex = -1; + point._index++; + } + } + + // Expose the previous character. + context.previous = code; + } + + /** @type {Effects['enter']} */ + function enter(type, fields) { + /** @type {Token} */ + // @ts-expect-error Patch instead of assign required fields to help GC. + const token = fields || {}; + token.type = type; + token.start = now(); + context.events.push(['enter', token, context]); + stack.push(token); + return token + } + + /** @type {Effects['exit']} */ + function exit(type) { + const token = stack.pop(); + token.end = now(); + context.events.push(['exit', token, context]); + return token + } + + /** + * Use results. + * + * @type {ReturnHandle} + */ + function onsuccessfulconstruct(construct, info) { + addResult(construct, info.from); + } + + /** + * Discard results. + * + * @type {ReturnHandle} + */ + function onsuccessfulcheck(_, info) { + info.restore(); + } + + /** + * Factory to attempt/check/interrupt. + * + * @param {ReturnHandle} onreturn + * @param {{interrupt?: boolean | undefined} | undefined} [fields] + */ + function constructFactory(onreturn, fields) { + return hook + + /** + * Handle either an object mapping codes to constructs, a list of + * constructs, or a single construct. + * + * @param {Array | Construct | ConstructRecord} constructs + * @param {State} returnState + * @param {State | undefined} [bogusState] + * @returns {State} + */ + function hook(constructs, returnState, bogusState) { + /** @type {Array} */ + let listOfConstructs; + /** @type {number} */ + let constructIndex; + /** @type {Construct} */ + let currentConstruct; + /** @type {Info} */ + let info; + return Array.isArray(constructs) /* c8 ignore next 1 */ + ? handleListOfConstructs(constructs) + : 'tokenize' in constructs + ? // @ts-expect-error Looks like a construct. + handleListOfConstructs([constructs]) + : handleMapOfConstructs(constructs) + + /** + * Handle a list of construct. + * + * @param {ConstructRecord} map + * @returns {State} + */ + function handleMapOfConstructs(map) { + return start + + /** @type {State} */ + function start(code) { + const def = code !== null && map[code]; + const all = code !== null && map.null; + const list = [ + // To do: add more extension tests. + /* c8 ignore next 2 */ + ...(Array.isArray(def) ? def : def ? [def] : []), + ...(Array.isArray(all) ? all : all ? [all] : []) + ]; + return handleListOfConstructs(list)(code) + } + } + + /** + * Handle a list of construct. + * + * @param {Array} list + * @returns {State} + */ + function handleListOfConstructs(list) { + listOfConstructs = list; + constructIndex = 0; + if (list.length === 0) { + return bogusState + } + return handleConstruct(list[constructIndex]) + } + + /** + * Handle a single construct. + * + * @param {Construct} construct + * @returns {State} + */ + function handleConstruct(construct) { + return start + + /** @type {State} */ + function start(code) { + // To do: not needed to store if there is no bogus state, probably? + // Currently doesn’t work because `inspect` in document does a check + // w/o a bogus, which doesn’t make sense. But it does seem to help perf + // by not storing. + info = store(); + currentConstruct = construct; + if (!construct.partial) { + context.currentConstruct = construct; + } + + // Always populated by defaults. + + if ( + construct.name && + context.parser.constructs.disable.null.includes(construct.name) + ) { + return nok() + } + return construct.tokenize.call( + // If we do have fields, create an object w/ `context` as its + // prototype. + // This allows a “live binding”, which is needed for `interrupt`. + fields ? Object.assign(Object.create(context), fields) : context, + effects, + ok, + nok + )(code) + } + } + + /** @type {State} */ + function ok(code) { + onreturn(currentConstruct, info); + return returnState + } + + /** @type {State} */ + function nok(code) { + info.restore(); + if (++constructIndex < listOfConstructs.length) { + return handleConstruct(listOfConstructs[constructIndex]) + } + return bogusState + } + } + } + + /** + * @param {Construct} construct + * @param {number} from + * @returns {void} + */ + function addResult(construct, from) { + if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { + resolveAllConstructs.push(construct); + } + if (construct.resolve) { + splice( + context.events, + from, + context.events.length - from, + construct.resolve(context.events.slice(from), context) + ); + } + if (construct.resolveTo) { + context.events = construct.resolveTo(context.events, context); + } + } + + /** + * Store state. + * + * @returns {Info} + */ + function store() { + const startPoint = now(); + const startPrevious = context.previous; + const startCurrentConstruct = context.currentConstruct; + const startEventsIndex = context.events.length; + const startStack = Array.from(stack); + return { + restore, + from: startEventsIndex + } + + /** + * Restore state. + * + * @returns {void} + */ + function restore() { + point = startPoint; + context.previous = startPrevious; + context.currentConstruct = startCurrentConstruct; + context.events.length = startEventsIndex; + stack = startStack; + accountForPotentialSkip(); + } + } + + /** + * Move the current point a bit forward in the line when it’s on a column + * skip. + * + * @returns {void} + */ + function accountForPotentialSkip() { + if (point.line in columnStart && point.column < 2) { + point.column = columnStart[point.line]; + point.offset += columnStart[point.line] - 1; + } + } +} + +/** + * Get the chunks from a slice of chunks in the range of a token. + * + * @param {Array} chunks + * @param {Pick} token + * @returns {Array} + */ +function sliceChunks(chunks, token) { + const startIndex = token.start._index; + const startBufferIndex = token.start._bufferIndex; + const endIndex = token.end._index; + const endBufferIndex = token.end._bufferIndex; + /** @type {Array} */ + let view; + if (startIndex === endIndex) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; + } else { + view = chunks.slice(startIndex, endIndex); + if (startBufferIndex > -1) { + const head = view[0]; + if (typeof head === 'string') { + view[0] = head.slice(startBufferIndex); + } else { + view.shift(); + } + } + if (endBufferIndex > 0) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view.push(chunks[endIndex].slice(0, endBufferIndex)); + } + } + return view +} + +/** + * Get the string value of a slice of chunks. + * + * @param {Array} chunks + * @param {boolean | undefined} [expandTabs=false] + * @returns {string} + */ +function serializeChunks(chunks, expandTabs) { + let index = -1; + /** @type {Array} */ + const result = []; + /** @type {boolean | undefined} */ + let atTab; + while (++index < chunks.length) { + const chunk = chunks[index]; + /** @type {string} */ + let value; + if (typeof chunk === 'string') { + value = chunk; + } else + switch (chunk) { + case -5: { + value = '\r'; + break + } + case -4: { + value = '\n'; + break + } + case -3: { + value = '\r' + '\n'; + break + } + case -2: { + value = expandTabs ? ' ' : '\t'; + break + } + case -1: { + if (!expandTabs && atTab) continue + value = ' '; + break + } + default: { + // Currently only replacement character. + value = String.fromCharCode(chunk); + } + } + atTab = chunk === -2; + result.push(value); + } + return result.join('') +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + */ + + +/** @satisfies {Extension['document']} */ +const document = { + [42]: list, + [43]: list, + [45]: list, + [48]: list, + [49]: list, + [50]: list, + [51]: list, + [52]: list, + [53]: list, + [54]: list, + [55]: list, + [56]: list, + [57]: list, + [62]: blockQuote +}; + +/** @satisfies {Extension['contentInitial']} */ +const contentInitial = { + [91]: definition +}; + +/** @satisfies {Extension['flowInitial']} */ +const flowInitial = { + [-2]: codeIndented, + [-1]: codeIndented, + [32]: codeIndented +}; + +/** @satisfies {Extension['flow']} */ +const flow = { + [35]: headingAtx, + [42]: thematicBreak, + [45]: [setextUnderline, thematicBreak], + [60]: htmlFlow, + [61]: setextUnderline, + [95]: thematicBreak, + [96]: codeFenced, + [126]: codeFenced +}; + +/** @satisfies {Extension['string']} */ +const string = { + [38]: characterReference, + [92]: characterEscape +}; + +/** @satisfies {Extension['text']} */ +const text = { + [-5]: lineEnding, + [-4]: lineEnding, + [-3]: lineEnding, + [33]: labelStartImage, + [38]: characterReference, + [42]: attention, + [60]: [autolink, htmlText], + [91]: labelStartLink, + [92]: [hardBreakEscape, characterEscape], + [93]: labelEnd, + [95]: attention, + [96]: codeText +}; + +/** @satisfies {Extension['insideSpan']} */ +const insideSpan = { + null: [attention, resolver] +}; + +/** @satisfies {Extension['attentionMarkers']} */ +const attentionMarkers = { + null: [42, 95] +}; + +/** @satisfies {Extension['disable']} */ +const disable = { + null: [] +}; + +var defaultConstructs = /*#__PURE__*/Object.freeze({ + __proto__: null, + attentionMarkers: attentionMarkers, + contentInitial: contentInitial, + disable: disable, + document: document, + flow: flow, + flowInitial: flowInitial, + insideSpan: insideSpan, + string: string, + text: text +}); + +/** + * @typedef {import('micromark-util-types').Create} Create + * @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + */ + + +/** + * @param {ParseOptions | null | undefined} [options] + * @returns {ParseContext} + */ +function parse(options) { + const settings = options || {}; + const constructs = + /** @type {FullNormalizedExtension} */ + combineExtensions([defaultConstructs, ...(settings.extensions || [])]); + + /** @type {ParseContext} */ + const parser = { + defined: [], + lazy: {}, + constructs, + content: create(content$1), + document: create(document$1), + flow: create(flow$1), + string: create(string$1), + text: create(text$1) + }; + return parser + + /** + * @param {InitialConstruct} initial + */ + function create(initial) { + return creator + /** @type {Create} */ + function creator(from) { + return createTokenizer(parser, initial, from) + } + } +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Value} Value + */ + +/** + * @callback Preprocessor + * @param {Value} value + * @param {Encoding | null | undefined} [encoding] + * @param {boolean | null | undefined} [end=false] + * @returns {Array} + */ + +const search = /[\0\t\n\r]/g; + +/** + * @returns {Preprocessor} + */ +function preprocess() { + let column = 1; + let buffer = ''; + /** @type {boolean | undefined} */ + let start = true; + /** @type {boolean | undefined} */ + let atCarriageReturn; + return preprocessor + + /** @type {Preprocessor} */ + function preprocessor(value, encoding, end) { + /** @type {Array} */ + const chunks = []; + /** @type {RegExpMatchArray | null} */ + let match; + /** @type {number} */ + let next; + /** @type {number} */ + let startPosition; + /** @type {number} */ + let endPosition; + /** @type {Code} */ + let code; + + // @ts-expect-error `Buffer` does allow an encoding. + value = buffer + value.toString(encoding); + startPosition = 0; + buffer = ''; + if (start) { + // To do: `markdown-rs` actually parses BOMs (byte order mark). + if (value.charCodeAt(0) === 65279) { + startPosition++; + } + start = undefined; + } + while (startPosition < value.length) { + search.lastIndex = startPosition; + match = search.exec(value); + endPosition = + match && match.index !== undefined ? match.index : value.length; + code = value.charCodeAt(endPosition); + if (!match) { + buffer = value.slice(startPosition); + break + } + if (code === 10 && startPosition === endPosition && atCarriageReturn) { + chunks.push(-3); + atCarriageReturn = undefined; + } else { + if (atCarriageReturn) { + chunks.push(-5); + atCarriageReturn = undefined; + } + if (startPosition < endPosition) { + chunks.push(value.slice(startPosition, endPosition)); + column += endPosition - startPosition; + } + switch (code) { + case 0: { + chunks.push(65533); + column++; + break + } + case 9: { + next = Math.ceil(column / 4) * 4; + chunks.push(-2); + while (column++ < next) chunks.push(-1); + break + } + case 10: { + chunks.push(-4); + column = 1; + break + } + default: { + atCarriageReturn = true; + column = 1; + } + } + } + startPosition = endPosition + 1; + } + if (end) { + if (atCarriageReturn) chunks.push(-5); + if (buffer) chunks.push(buffer); + chunks.push(null); + } + return chunks + } +} + +/** + * @typedef {import('micromark-util-types').Event} Event + */ + + +/** + * @param {Array} events + * @returns {Array} + */ +function postprocess(events) { + while (!subtokenize(events)) { + // Empty + } + return events +} + +/** + * Turn the number (in string form as either hexa- or plain decimal) coming from + * a numeric character reference into a character. + * + * Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes + * non-characters and control characters safe. + * + * @param {string} value + * Value to decode. + * @param {number} base + * Numeric base. + * @returns {string} + * Character. + */ +function decodeNumericCharacterReference(value, base) { + const code = Number.parseInt(value, base); + if ( + // C0 except for HT, LF, FF, CR, space. + code < 9 || + code === 11 || + (code > 13 && code < 32) || + // Control character (DEL) of C0, and C1 controls. + (code > 126 && code < 160) || + // Lone high surrogates and low surrogates. + (code > 55295 && code < 57344) || + // Noncharacters. + (code > 64975 && code < 65008) /* eslint-disable no-bitwise */ || + (code & 65535) === 65535 || + (code & 65535) === 65534 /* eslint-enable no-bitwise */ || + // Out of range + code > 1114111 + ) { + return '\uFFFD' + } + return String.fromCharCode(code) +} + +const characterEscapeOrReference = + /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; + +/** + * Decode markdown strings (which occur in places such as fenced code info + * strings, destinations, labels, and titles). + * + * The “string” content type allows character escapes and -references. + * This decodes those. + * + * @param {string} value + * Value to decode. + * @returns {string} + * Decoded value. + */ +function decodeString(value) { + return value.replace(characterEscapeOrReference, decode) +} + +/** + * @param {string} $0 + * @param {string} $1 + * @param {string} $2 + * @returns {string} + */ +function decode($0, $1, $2) { + if ($1) { + // Escape. + return $1 + } + + // Reference. + const head = $2.charCodeAt(0); + if (head === 35) { + const head = $2.charCodeAt(1); + const hex = head === 120 || head === 88; + return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10) + } + return decodeNamedCharacterReference($2) || $0 +} + +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Point} Point + * @typedef {import('unist').Position} Position + */ + +/** + * @typedef NodeLike + * @property {string} type + * @property {PositionLike | null | undefined} [position] + * + * @typedef PositionLike + * @property {PointLike | null | undefined} [start] + * @property {PointLike | null | undefined} [end] + * + * @typedef PointLike + * @property {number | null | undefined} [line] + * @property {number | null | undefined} [column] + * @property {number | null | undefined} [offset] + */ + +/** + * Serialize the positional info of a point, position (start and end points), + * or node. + * + * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] + * Node, position, or point. + * @returns {string} + * Pretty printed positional info of a node (`string`). + * + * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) + * or a point `l:c` (when given `point`), where `l` stands for line, `c` for + * column, `s` for `start`, and `e` for end. + * An empty string (`''`) is returned if the given value is neither `node`, + * `position`, nor `point`. + */ +function stringifyPosition(value) { + // Nothing. + if (!value || typeof value !== 'object') { + return '' + } + + // Node. + if ('position' in value || 'type' in value) { + return position(value.position) + } + + // Position. + if ('start' in value || 'end' in value) { + return position(value) + } + + // Point. + if ('line' in value || 'column' in value) { + return point$1(value) + } + + // ? + return '' +} + +/** + * @param {Point | PointLike | null | undefined} point + * @returns {string} + */ +function point$1(point) { + return index(point && point.line) + ':' + index(point && point.column) +} + +/** + * @param {Position | PositionLike | null | undefined} pos + * @returns {string} + */ +function position(pos) { + return point$1(pos && pos.start) + '-' + point$1(pos && pos.end) +} + +/** + * @param {number | null | undefined} value + * @returns {number} + */ +function index(value) { + return value && typeof value === 'number' ? value : 1 +} + +/** + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Value} Value + * + * @typedef {import('unist').Parent} UnistParent + * @typedef {import('unist').Point} Point + * + * @typedef {import('mdast').PhrasingContent} PhrasingContent + * @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent + * @typedef {import('mdast').Content} Content + * @typedef {import('mdast').Break} Break + * @typedef {import('mdast').Blockquote} Blockquote + * @typedef {import('mdast').Code} Code + * @typedef {import('mdast').Definition} Definition + * @typedef {import('mdast').Emphasis} Emphasis + * @typedef {import('mdast').Heading} Heading + * @typedef {import('mdast').HTML} HTML + * @typedef {import('mdast').Image} Image + * @typedef {import('mdast').ImageReference} ImageReference + * @typedef {import('mdast').InlineCode} InlineCode + * @typedef {import('mdast').Link} Link + * @typedef {import('mdast').LinkReference} LinkReference + * @typedef {import('mdast').List} List + * @typedef {import('mdast').ListItem} ListItem + * @typedef {import('mdast').Paragraph} Paragraph + * @typedef {import('mdast').Root} Root + * @typedef {import('mdast').Strong} Strong + * @typedef {import('mdast').Text} Text + * @typedef {import('mdast').ThematicBreak} ThematicBreak + * @typedef {import('mdast').ReferenceType} ReferenceType + * @typedef {import('../index.js').CompileData} CompileData + */ + +const own = {}.hasOwnProperty; + +/** + * @param value + * Markdown to parse. + * @param encoding + * Character encoding for when `value` is `Buffer`. + * @param options + * Configuration. + * @returns + * mdast tree. + */ +const fromMarkdown = + /** + * @type {( + * ((value: Value, encoding: Encoding, options?: Options | null | undefined) => Root) & + * ((value: Value, options?: Options | null | undefined) => Root) + * )} + */ + + /** + * @param {Value} value + * @param {Encoding | Options | null | undefined} [encoding] + * @param {Options | null | undefined} [options] + * @returns {Root} + */ + function (value, encoding, options) { + if (typeof encoding !== 'string') { + options = encoding; + encoding = undefined; + } + return compiler(options)( + postprocess( + parse(options).document().write(preprocess()(value, encoding, true)) + ) + ) + }; + +/** + * Note this compiler only understand complete buffering, not streaming. + * + * @param {Options | null | undefined} [options] + */ +function compiler(options) { + /** @type {Config} */ + const config = { + transforms: [], + canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'], + enter: { + autolink: opener(link), + autolinkProtocol: onenterdata, + autolinkEmail: onenterdata, + atxHeading: opener(heading), + blockQuote: opener(blockQuote), + characterEscape: onenterdata, + characterReference: onenterdata, + codeFenced: opener(codeFlow), + codeFencedFenceInfo: buffer, + codeFencedFenceMeta: buffer, + codeIndented: opener(codeFlow, buffer), + codeText: opener(codeText, buffer), + codeTextData: onenterdata, + data: onenterdata, + codeFlowValue: onenterdata, + definition: opener(definition), + definitionDestinationString: buffer, + definitionLabelString: buffer, + definitionTitleString: buffer, + emphasis: opener(emphasis), + hardBreakEscape: opener(hardBreak), + hardBreakTrailing: opener(hardBreak), + htmlFlow: opener(html, buffer), + htmlFlowData: onenterdata, + htmlText: opener(html, buffer), + htmlTextData: onenterdata, + image: opener(image), + label: buffer, + link: opener(link), + listItem: opener(listItem), + listItemValue: onenterlistitemvalue, + listOrdered: opener(list, onenterlistordered), + listUnordered: opener(list), + paragraph: opener(paragraph), + reference: onenterreference, + referenceString: buffer, + resourceDestinationString: buffer, + resourceTitleString: buffer, + setextHeading: opener(heading), + strong: opener(strong), + thematicBreak: opener(thematicBreak) + }, + exit: { + atxHeading: closer(), + atxHeadingSequence: onexitatxheadingsequence, + autolink: closer(), + autolinkEmail: onexitautolinkemail, + autolinkProtocol: onexitautolinkprotocol, + blockQuote: closer(), + characterEscapeValue: onexitdata, + characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, + characterReferenceMarkerNumeric: onexitcharacterreferencemarker, + characterReferenceValue: onexitcharacterreferencevalue, + codeFenced: closer(onexitcodefenced), + codeFencedFence: onexitcodefencedfence, + codeFencedFenceInfo: onexitcodefencedfenceinfo, + codeFencedFenceMeta: onexitcodefencedfencemeta, + codeFlowValue: onexitdata, + codeIndented: closer(onexitcodeindented), + codeText: closer(onexitcodetext), + codeTextData: onexitdata, + data: onexitdata, + definition: closer(), + definitionDestinationString: onexitdefinitiondestinationstring, + definitionLabelString: onexitdefinitionlabelstring, + definitionTitleString: onexitdefinitiontitlestring, + emphasis: closer(), + hardBreakEscape: closer(onexithardbreak), + hardBreakTrailing: closer(onexithardbreak), + htmlFlow: closer(onexithtmlflow), + htmlFlowData: onexitdata, + htmlText: closer(onexithtmltext), + htmlTextData: onexitdata, + image: closer(onexitimage), + label: onexitlabel, + labelText: onexitlabeltext, + lineEnding: onexitlineending, + link: closer(onexitlink), + listItem: closer(), + listOrdered: closer(), + listUnordered: closer(), + paragraph: closer(), + referenceString: onexitreferencestring, + resourceDestinationString: onexitresourcedestinationstring, + resourceTitleString: onexitresourcetitlestring, + resource: onexitresource, + setextHeading: closer(onexitsetextheading), + setextHeadingLineSequence: onexitsetextheadinglinesequence, + setextHeadingText: onexitsetextheadingtext, + strong: closer(), + thematicBreak: closer() + } + }; + configure(config, (options || {}).mdastExtensions || []); + + /** @type {CompileData} */ + const data = {}; + return compile + + /** + * Turn micromark events into an mdast tree. + * + * @param {Array} events + * Events. + * @returns {Root} + * mdast tree. + */ + function compile(events) { + /** @type {Root} */ + let tree = { + type: 'root', + children: [] + }; + /** @type {Omit} */ + const context = { + stack: [tree], + tokenStack: [], + config, + enter, + exit, + buffer, + resume, + setData, + getData + }; + /** @type {Array} */ + const listStack = []; + let index = -1; + while (++index < events.length) { + // We preprocess lists to add `listItem` tokens, and to infer whether + // items the list itself are spread out. + if ( + events[index][1].type === 'listOrdered' || + events[index][1].type === 'listUnordered' + ) { + if (events[index][0] === 'enter') { + listStack.push(index); + } else { + const tail = listStack.pop(); + index = prepareList(events, tail, index); + } + } + } + index = -1; + while (++index < events.length) { + const handler = config[events[index][0]]; + if (own.call(handler, events[index][1].type)) { + handler[events[index][1].type].call( + Object.assign( + { + sliceSerialize: events[index][2].sliceSerialize + }, + context + ), + events[index][1] + ); + } + } + + // Handle tokens still being open. + if (context.tokenStack.length > 0) { + const tail = context.tokenStack[context.tokenStack.length - 1]; + const handler = tail[1] || defaultOnError; + handler.call(context, undefined, tail[0]); + } + + // Figure out `root` position. + tree.position = { + start: point( + events.length > 0 + ? events[0][1].start + : { + line: 1, + column: 1, + offset: 0 + } + ), + end: point( + events.length > 0 + ? events[events.length - 2][1].end + : { + line: 1, + column: 1, + offset: 0 + } + ) + }; + + // Call transforms. + index = -1; + while (++index < config.transforms.length) { + tree = config.transforms[index](tree) || tree; + } + return tree + } + + /** + * @param {Array} events + * @param {number} start + * @param {number} length + * @returns {number} + */ + function prepareList(events, start, length) { + let index = start - 1; + let containerBalance = -1; + let listSpread = false; + /** @type {Token | undefined} */ + let listItem; + /** @type {number | undefined} */ + let lineIndex; + /** @type {number | undefined} */ + let firstBlankLineIndex; + /** @type {boolean | undefined} */ + let atMarker; + while (++index <= length) { + const event = events[index]; + if ( + event[1].type === 'listUnordered' || + event[1].type === 'listOrdered' || + event[1].type === 'blockQuote' + ) { + if (event[0] === 'enter') { + containerBalance++; + } else { + containerBalance--; + } + atMarker = undefined; + } else if (event[1].type === 'lineEndingBlank') { + if (event[0] === 'enter') { + if ( + listItem && + !atMarker && + !containerBalance && + !firstBlankLineIndex + ) { + firstBlankLineIndex = index; + } + atMarker = undefined; + } + } else if ( + event[1].type === 'linePrefix' || + event[1].type === 'listItemValue' || + event[1].type === 'listItemMarker' || + event[1].type === 'listItemPrefix' || + event[1].type === 'listItemPrefixWhitespace' + ) ; else { + atMarker = undefined; + } + if ( + (!containerBalance && + event[0] === 'enter' && + event[1].type === 'listItemPrefix') || + (containerBalance === -1 && + event[0] === 'exit' && + (event[1].type === 'listUnordered' || + event[1].type === 'listOrdered')) + ) { + if (listItem) { + let tailIndex = index; + lineIndex = undefined; + while (tailIndex--) { + const tailEvent = events[tailIndex]; + if ( + tailEvent[1].type === 'lineEnding' || + tailEvent[1].type === 'lineEndingBlank' + ) { + if (tailEvent[0] === 'exit') continue + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + listSpread = true; + } + tailEvent[1].type = 'lineEnding'; + lineIndex = tailIndex; + } else if ( + tailEvent[1].type === 'linePrefix' || + tailEvent[1].type === 'blockQuotePrefix' || + tailEvent[1].type === 'blockQuotePrefixWhitespace' || + tailEvent[1].type === 'blockQuoteMarker' || + tailEvent[1].type === 'listItemIndent' + ) ; else { + break + } + } + if ( + firstBlankLineIndex && + (!lineIndex || firstBlankLineIndex < lineIndex) + ) { + listItem._spread = true; + } + + // Fix position. + listItem.end = Object.assign( + {}, + lineIndex ? events[lineIndex][1].start : event[1].end + ); + events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); + index++; + length++; + } + + // Create a new list item. + if (event[1].type === 'listItemPrefix') { + listItem = { + type: 'listItem', + _spread: false, + start: Object.assign({}, event[1].start), + // @ts-expect-error: we’ll add `end` in a second. + end: undefined + }; + // @ts-expect-error: `listItem` is most definitely defined, TS... + events.splice(index, 0, ['enter', listItem, event[2]]); + index++; + length++; + firstBlankLineIndex = undefined; + atMarker = true; + } + } + } + events[start][1]._spread = listSpread; + return length + } + + /** + * Set data. + * + * @template {keyof CompileData} Key + * Field type. + * @param {Key} key + * Key of field. + * @param {CompileData[Key]} [value] + * New value. + * @returns {void} + * Nothing. + */ + function setData(key, value) { + data[key] = value; + } + + /** + * Get data. + * + * @template {keyof CompileData} Key + * Field type. + * @param {Key} key + * Key of field. + * @returns {CompileData[Key]} + * Value. + */ + function getData(key) { + return data[key] + } + + /** + * Create an opener handle. + * + * @param {(token: Token) => Node} create + * Create a node. + * @param {Handle} [and] + * Optional function to also run. + * @returns {Handle} + * Handle. + */ + function opener(create, and) { + return open + + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + function open(token) { + enter.call(this, create(token), token); + if (and) and.call(this, token); + } + } + + /** + * @this {CompileContext} + * @returns {void} + */ + function buffer() { + this.stack.push({ + type: 'fragment', + children: [] + }); + } + + /** + * @template {Node} Kind + * Node type. + * @this {CompileContext} + * Context. + * @param {Kind} node + * Node to enter. + * @param {Token} token + * Corresponding token. + * @param {OnEnterError | undefined} [errorHandler] + * Handle the case where this token is open, but it is closed by something else. + * @returns {Kind} + * The given node. + */ + function enter(node, token, errorHandler) { + const parent = this.stack[this.stack.length - 1]; + // @ts-expect-error: Assume `Node` can exist as a child of `parent`. + parent.children.push(node); + this.stack.push(node); + this.tokenStack.push([token, errorHandler]); + // @ts-expect-error: `end` will be patched later. + node.position = { + start: point(token.start) + }; + return node + } + + /** + * Create a closer handle. + * + * @param {Handle} [and] + * Optional function to also run. + * @returns {Handle} + * Handle. + */ + function closer(and) { + return close + + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + function close(token) { + if (and) and.call(this, token); + exit.call(this, token); + } + } + + /** + * @this {CompileContext} + * Context. + * @param {Token} token + * Corresponding token. + * @param {OnExitError | undefined} [onExitError] + * Handle the case where another token is open. + * @returns {Node} + * The closed node. + */ + function exit(token, onExitError) { + const node = this.stack.pop(); + const open = this.tokenStack.pop(); + if (!open) { + throw new Error( + 'Cannot close `' + + token.type + + '` (' + + stringifyPosition({ + start: token.start, + end: token.end + }) + + '): it’s not open' + ) + } else if (open[0].type !== token.type) { + if (onExitError) { + onExitError.call(this, token, open[0]); + } else { + const handler = open[1] || defaultOnError; + handler.call(this, token, open[0]); + } + } + node.position.end = point(token.end); + return node + } + + /** + * @this {CompileContext} + * @returns {string} + */ + function resume() { + return toString(this.stack.pop()) + } + + // + // Handlers. + // + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onenterlistordered() { + setData('expectingFirstListItemValue', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onenterlistitemvalue(token) { + if (getData('expectingFirstListItemValue')) { + const ancestor = this.stack[this.stack.length - 2]; + ancestor.start = Number.parseInt(this.sliceSerialize(token), 10); + setData('expectingFirstListItemValue'); + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfenceinfo() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.lang = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfencemeta() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.meta = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfence() { + // Exit if this is the closing fence. + if (getData('flowCodeInside')) return + this.buffer(); + setData('flowCodeInside', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefenced() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); + setData('flowCodeInside'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodeindented() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data.replace(/(\r?\n|\r)$/g, ''); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitionlabelstring(token) { + const label = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.label = label; + node.identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitiontitlestring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.title = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitiondestinationstring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.url = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitatxheadingsequence(token) { + const node = this.stack[this.stack.length - 1]; + if (!node.depth) { + const depth = this.sliceSerialize(token).length; + node.depth = depth; + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheadingtext() { + setData('setextHeadingSlurpLineEnding', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheadinglinesequence(token) { + const node = this.stack[this.stack.length - 1]; + node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheading() { + setData('setextHeadingSlurpLineEnding'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onenterdata(token) { + const node = this.stack[this.stack.length - 1]; + let tail = node.children[node.children.length - 1]; + if (!tail || tail.type !== 'text') { + // Add a new text node. + tail = text(); + // @ts-expect-error: we’ll add `end` later. + tail.position = { + start: point(token.start) + }; + // @ts-expect-error: Assume `parent` accepts `text`. + node.children.push(tail); + } + this.stack.push(tail); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitdata(token) { + const tail = this.stack.pop(); + tail.value += this.sliceSerialize(token); + tail.position.end = point(token.end); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlineending(token) { + const context = this.stack[this.stack.length - 1]; + // If we’re at a hard break, include the line ending in there. + if (getData('atHardBreak')) { + const tail = context.children[context.children.length - 1]; + tail.position.end = point(token.end); + setData('atHardBreak'); + return + } + if ( + !getData('setextHeadingSlurpLineEnding') && + config.canContainEols.includes(context.type) + ) { + onenterdata.call(this, token); + onexitdata.call(this, token); + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithardbreak() { + setData('atHardBreak', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithtmlflow() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithtmltext() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitcodetext() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlink() { + const node = this.stack[this.stack.length - 1]; + // Note: there are also `identifier` and `label` fields on this link node! + // These are used / cleaned here. + // To do: clean. + if (getData('inReference')) { + /** @type {ReferenceType} */ + const referenceType = getData('referenceType') || 'shortcut'; + node.type += 'Reference'; + // @ts-expect-error: mutate. + node.referenceType = referenceType; + // @ts-expect-error: mutate. + delete node.url; + delete node.title; + } else { + // @ts-expect-error: mutate. + delete node.identifier; + // @ts-expect-error: mutate. + delete node.label; + } + setData('referenceType'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitimage() { + const node = this.stack[this.stack.length - 1]; + // Note: there are also `identifier` and `label` fields on this link node! + // These are used / cleaned here. + // To do: clean. + if (getData('inReference')) { + /** @type {ReferenceType} */ + const referenceType = getData('referenceType') || 'shortcut'; + node.type += 'Reference'; + // @ts-expect-error: mutate. + node.referenceType = referenceType; + // @ts-expect-error: mutate. + delete node.url; + delete node.title; + } else { + // @ts-expect-error: mutate. + delete node.identifier; + // @ts-expect-error: mutate. + delete node.label; + } + setData('referenceType'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlabeltext(token) { + const string = this.sliceSerialize(token); + const ancestor = this.stack[this.stack.length - 2]; + // @ts-expect-error: stash this on the node, as it might become a reference + // later. + ancestor.label = decodeString(string); + // @ts-expect-error: same as above. + ancestor.identifier = normalizeIdentifier(string).toLowerCase(); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlabel() { + const fragment = this.stack[this.stack.length - 1]; + const value = this.resume(); + const node = this.stack[this.stack.length - 1]; + // Assume a reference. + setData('inReference', true); + if (node.type === 'link') { + /** @type {Array} */ + // @ts-expect-error: Assume static phrasing content. + const children = fragment.children; + node.children = children; + } else { + node.alt = value; + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresourcedestinationstring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.url = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresourcetitlestring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.title = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresource() { + setData('inReference'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onenterreference() { + setData('referenceType', 'collapsed'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitreferencestring(token) { + const label = this.resume(); + const node = this.stack[this.stack.length - 1]; + // @ts-expect-error: stash this on the node, as it might become a reference + // later. + node.label = label; + // @ts-expect-error: same as above. + node.identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + setData('referenceType', 'full'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitcharacterreferencemarker(token) { + setData('characterReferenceType', token.type); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcharacterreferencevalue(token) { + const data = this.sliceSerialize(token); + const type = getData('characterReferenceType'); + /** @type {string} */ + let value; + if (type) { + value = decodeNumericCharacterReference( + data, + type === 'characterReferenceMarkerNumeric' ? 10 : 16 + ); + setData('characterReferenceType'); + } else { + const result = decodeNamedCharacterReference(data); + value = result; + } + const tail = this.stack.pop(); + tail.value += value; + tail.position.end = point(token.end); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitautolinkprotocol(token) { + onexitdata.call(this, token); + const node = this.stack[this.stack.length - 1]; + node.url = this.sliceSerialize(token); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitautolinkemail(token) { + onexitdata.call(this, token); + const node = this.stack[this.stack.length - 1]; + node.url = 'mailto:' + this.sliceSerialize(token); + } + + // + // Creaters. + // + + /** @returns {Blockquote} */ + function blockQuote() { + return { + type: 'blockquote', + children: [] + } + } + + /** @returns {Code} */ + function codeFlow() { + return { + type: 'code', + lang: null, + meta: null, + value: '' + } + } + + /** @returns {InlineCode} */ + function codeText() { + return { + type: 'inlineCode', + value: '' + } + } + + /** @returns {Definition} */ + function definition() { + return { + type: 'definition', + identifier: '', + label: null, + title: null, + url: '' + } + } + + /** @returns {Emphasis} */ + function emphasis() { + return { + type: 'emphasis', + children: [] + } + } + + /** @returns {Heading} */ + function heading() { + // @ts-expect-error `depth` will be set later. + return { + type: 'heading', + depth: undefined, + children: [] + } + } + + /** @returns {Break} */ + function hardBreak() { + return { + type: 'break' + } + } + + /** @returns {HTML} */ + function html() { + return { + type: 'html', + value: '' + } + } + + /** @returns {Image} */ + function image() { + return { + type: 'image', + title: null, + url: '', + alt: null + } + } + + /** @returns {Link} */ + function link() { + return { + type: 'link', + title: null, + url: '', + children: [] + } + } + + /** + * @param {Token} token + * @returns {List} + */ + function list(token) { + return { + type: 'list', + ordered: token.type === 'listOrdered', + start: null, + spread: token._spread, + children: [] + } + } + + /** + * @param {Token} token + * @returns {ListItem} + */ + function listItem(token) { + return { + type: 'listItem', + spread: token._spread, + checked: null, + children: [] + } + } + + /** @returns {Paragraph} */ + function paragraph() { + return { + type: 'paragraph', + children: [] + } + } + + /** @returns {Strong} */ + function strong() { + return { + type: 'strong', + children: [] + } + } + + /** @returns {Text} */ + function text() { + return { + type: 'text', + value: '' + } + } + + /** @returns {ThematicBreak} */ + function thematicBreak() { + return { + type: 'thematicBreak' + } + } +} + +/** + * Copy a point-like value. + * + * @param {Point} d + * Point-like value. + * @returns {Point} + * unist point. + */ +function point(d) { + return { + line: d.line, + column: d.column, + offset: d.offset + } +} + +/** + * @param {Config} combined + * @param {Array>} extensions + * @returns {void} + */ +function configure(combined, extensions) { + let index = -1; + while (++index < extensions.length) { + const value = extensions[index]; + if (Array.isArray(value)) { + configure(combined, value); + } else { + extension(combined, value); + } + } +} + +/** + * @param {Config} combined + * @param {Extension} extension + * @returns {void} + */ +function extension(combined, extension) { + /** @type {keyof Extension} */ + let key; + for (key in extension) { + if (own.call(extension, key)) { + if (key === 'canContainEols') { + const right = extension[key]; + if (right) { + combined[key].push(...right); + } + } else if (key === 'transforms') { + const right = extension[key]; + if (right) { + combined[key].push(...right); + } + } else if (key === 'enter' || key === 'exit') { + const right = extension[key]; + if (right) { + Object.assign(combined[key], right); + } + } + } + } +} + +/** @type {OnEnterError} */ +function defaultOnError(left, right) { + if (left) { + throw new Error( + 'Cannot close `' + + left.type + + '` (' + + stringifyPosition({ + start: left.start, + end: left.end + }) + + '): a different token (`' + + right.type + + '`, ' + + stringifyPosition({ + start: right.start, + end: right.end + }) + + ') is open' + ) + } else { + throw new Error( + 'Cannot close document, a token (`' + + right.type + + '`, ' + + stringifyPosition({ + start: right.start, + end: right.end + }) + + ') is still open' + ) + } +} + +function preprocessMarkdown(markdown) { + const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, "\n"); + const withoutExtraSpaces = dedent(withoutMultipleNewlines); + return withoutExtraSpaces; +} +function markdownToLines(markdown) { + const preprocessedMarkdown = preprocessMarkdown(markdown); + const { children } = fromMarkdown(preprocessedMarkdown); + const lines = [[]]; + let currentLine = 0; + function processNode(node, parentType = "normal") { + if (node.type === "text") { + const textLines = node.value.split("\n"); + textLines.forEach((textLine, index) => { + if (index !== 0) { + currentLine++; + lines.push([]); + } + textLine.split(" ").forEach((word) => { + if (word) { + lines[currentLine].push({ content: word, type: parentType }); + } + }); + }); + } else if (node.type === "strong" || node.type === "emphasis") { + node.children.forEach((contentNode) => { + processNode(contentNode, node.type); + }); + } + } + children.forEach((treeNode) => { + if (treeNode.type === "paragraph") { + treeNode.children.forEach((contentNode) => { + processNode(contentNode); + }); + } + }); + return lines; +} +function markdownToHTML(markdown) { + const { children } = fromMarkdown(markdown); + function output(node) { + if (node.type === "text") { + return node.value.replace(/\n/g, "
"); + } else if (node.type === "strong") { + return `${node.children.map(output).join("")}`; + } else if (node.type === "emphasis") { + return `${node.children.map(output).join("")}`; + } else if (node.type === "paragraph") { + return `

${node.children.map(output).join("")}

`; + } + return `Unsupported markdown: ${node.type}`; + } + return children.map(output).join(""); +} +function splitTextToChars(text) { + if (Intl.Segmenter) { + return [...new Intl.Segmenter().segment(text)].map((s) => s.segment); + } + return [...text]; +} +function splitWordToFitWidth(checkFit, word) { + const characters = splitTextToChars(word.content); + return splitWordToFitWidthRecursion(checkFit, [], characters, word.type); +} +function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) { + if (remainingChars.length === 0) { + return [ + { content: usedChars.join(""), type }, + { content: "", type } + ]; + } + const [nextChar, ...rest] = remainingChars; + const newWord = [...usedChars, nextChar]; + if (checkFit([{ content: newWord.join(""), type }])) { + return splitWordToFitWidthRecursion(checkFit, newWord, rest, type); + } + if (usedChars.length === 0 && nextChar) { + usedChars.push(nextChar); + remainingChars.shift(); + } + return [ + { content: usedChars.join(""), type }, + { content: remainingChars.join(""), type } + ]; +} +function splitLineToFitWidth(line, checkFit) { + if (line.some(({ content }) => content.includes("\n"))) { + throw new Error("splitLineToFitWidth does not support newlines in the line"); + } + return splitLineToFitWidthRecursion(line, checkFit); +} +function splitLineToFitWidthRecursion(words, checkFit, lines = [], newLine = []) { + if (words.length === 0) { + if (newLine.length > 0) { + lines.push(newLine); + } + return lines.length > 0 ? lines : []; + } + let joiner = ""; + if (words[0].content === " ") { + joiner = " "; + words.shift(); + } + const nextWord = words.shift() ?? { content: " ", type: "normal" }; + const lineWithNextWord = [...newLine]; + if (joiner !== "") { + lineWithNextWord.push({ content: joiner, type: "normal" }); + } + lineWithNextWord.push(nextWord); + if (checkFit(lineWithNextWord)) { + return splitLineToFitWidthRecursion(words, checkFit, lines, lineWithNextWord); + } + if (newLine.length > 0) { + lines.push(newLine); + words.unshift(nextWord); + } else if (nextWord.content) { + const [line, rest] = splitWordToFitWidth(checkFit, nextWord); + lines.push([line]); + if (rest.content) { + words.unshift(rest); + } + } + return splitLineToFitWidthRecursion(words, checkFit, lines); +} +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr("style", styleFn); + } +} +function addHtmlSpan(element, node, width, classes, addBackground = false) { + const fo = element.append("foreignObject"); + const div = fo.append("xhtml:div"); + const label = node.label; + const labelClass = node.isNode ? "nodeLabel" : "edgeLabel"; + div.html( + ` + " + label + "" + ); + applyStyle(div, node.labelStyle); + div.style("display", "table-cell"); + div.style("white-space", "nowrap"); + div.style("max-width", width + "px"); + div.attr("xmlns", "http://www.w3.org/1999/xhtml"); + if (addBackground) { + div.attr("class", "labelBkg"); + } + let bbox = div.node().getBoundingClientRect(); + if (bbox.width === width) { + div.style("display", "table"); + div.style("white-space", "break-spaces"); + div.style("width", width + "px"); + bbox = div.node().getBoundingClientRect(); + } + fo.style("width", bbox.width); + fo.style("height", bbox.height); + return fo.node(); +} +function createTspan(textElement, lineIndex, lineHeight) { + return textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em"); +} +function computeWidthOfText(parentNode, lineHeight, line) { + const testElement = parentNode.append("text"); + const testSpan = createTspan(testElement, 1, lineHeight); + updateTextContentAndStyles(testSpan, line); + const textLength = testSpan.node().getComputedTextLength(); + testElement.remove(); + return textLength; +} +function computeDimensionOfText(parentNode, lineHeight, text) { + var _a; + const testElement = parentNode.append("text"); + const testSpan = createTspan(testElement, 1, lineHeight); + updateTextContentAndStyles(testSpan, [{ content: text, type: "normal" }]); + const textDimension = (_a = testSpan.node()) == null ? void 0 : _a.getBoundingClientRect(); + if (textDimension) { + testElement.remove(); + } + return textDimension; +} +function createFormattedText(width, g, structuredText, addBackground = false) { + const lineHeight = 1.1; + const labelGroup = g.append("g"); + const bkg = labelGroup.insert("rect").attr("class", "background"); + const textElement = labelGroup.append("text").attr("y", "-10.1"); + let lineIndex = 0; + for (const line of structuredText) { + const checkWidth = (line2) => computeWidthOfText(labelGroup, lineHeight, line2) <= width; + const linesUnderWidth = checkWidth(line) ? [line] : splitLineToFitWidth(line, checkWidth); + for (const preparedLine of linesUnderWidth) { + const tspan = createTspan(textElement, lineIndex, lineHeight); + updateTextContentAndStyles(tspan, preparedLine); + lineIndex++; + } + } + if (addBackground) { + const bbox = textElement.node().getBBox(); + const padding = 2; + bkg.attr("x", -padding).attr("y", -padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding); + return labelGroup.node(); + } else { + return textElement.node(); + } +} +function updateTextContentAndStyles(tspan, wrappedLine) { + tspan.text(""); + wrappedLine.forEach((word, index) => { + const innerTspan = tspan.append("tspan").attr("font-style", word.type === "emphasis" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", word.type === "strong" ? "bold" : "normal"); + if (index === 0) { + innerTspan.text(word.content); + } else { + innerTspan.text(" " + word.content); + } + }); +} +const createText = (el, text = "", { + style = "", + isTitle = false, + classes = "", + useHtmlLabels = true, + isNode = true, + width = 200, + addSvgBackground = false +} = {}) => { + log$1.info("createText", text, style, isTitle, classes, useHtmlLabels, isNode, addSvgBackground); + if (useHtmlLabels) { + const htmlText = markdownToHTML(text); + const node = { + isNode, + label: decodeEntities(htmlText).replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell: disable-line + (s) => `` + ), + labelStyle: style.replace("fill:", "color:") + }; + const vertexNode = addHtmlSpan(el, node, width, classes, addSvgBackground); + return vertexNode; + } else { + const structuredText = markdownToLines(text); + const svgLabel = createFormattedText(width, el, structuredText, addSvgBackground); + return svgLabel; + } +}; + +export { createText as a, computeDimensionOfText as c }; diff --git a/libs/marked/createText-ca0c5216-DF05SDfj.js b/libs/marked/createText-ca0c5216-DF05SDfj.js new file mode 100644 index 0000000..2b480bb --- /dev/null +++ b/libs/marked/createText-ca0c5216-DF05SDfj.js @@ -0,0 +1,12431 @@ +import { l as log$1, b6 as decodeEntities, b7 as dedent } from './index-CN3YjQ0n.js'; + +/** + * @typedef {import('mdast').Root|import('mdast').Content} Node + * + * @typedef Options + * Configuration (optional). + * @property {boolean | null | undefined} [includeImageAlt=true] + * Whether to use `alt` for `image`s. + * @property {boolean | null | undefined} [includeHtml=true] + * Whether to use `value` of HTML. + */ + +/** @type {Options} */ +const emptyOptions = {}; + +/** + * Get the text content of a node or list of nodes. + * + * Prefers the node’s plain-text fields, otherwise serializes its children, + * and if the given value is an array, serialize the nodes in it. + * + * @param {unknown} value + * Thing to serialize, typically `Node`. + * @param {Options | null | undefined} [options] + * Configuration (optional). + * @returns {string} + * Serialized `value`. + */ +function toString(value, options) { + const settings = emptyOptions; + const includeImageAlt = + typeof settings.includeImageAlt === 'boolean' + ? settings.includeImageAlt + : true; + const includeHtml = + typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true; + + return one(value, includeImageAlt, includeHtml) +} + +/** + * One node or several nodes. + * + * @param {unknown} value + * Thing to serialize. + * @param {boolean} includeImageAlt + * Include image `alt`s. + * @param {boolean} includeHtml + * Include HTML. + * @returns {string} + * Serialized node. + */ +function one(value, includeImageAlt, includeHtml) { + if (node(value)) { + if ('value' in value) { + return value.type === 'html' && !includeHtml ? '' : value.value + } + + if (includeImageAlt && 'alt' in value && value.alt) { + return value.alt + } + + if ('children' in value) { + return all(value.children, includeImageAlt, includeHtml) + } + } + + if (Array.isArray(value)) { + return all(value, includeImageAlt, includeHtml) + } + + return '' +} + +/** + * Serialize a list of nodes. + * + * @param {Array} values + * Thing to serialize. + * @param {boolean} includeImageAlt + * Include image `alt`s. + * @param {boolean} includeHtml + * Include HTML. + * @returns {string} + * Serialized nodes. + */ +function all(values, includeImageAlt, includeHtml) { + /** @type {Array} */ + const result = []; + let index = -1; + + while (++index < values.length) { + result[index] = one(values[index], includeImageAlt, includeHtml); + } + + return result.join('') +} + +/** + * Check if `value` looks like a node. + * + * @param {unknown} value + * Thing. + * @returns {value is Node} + * Whether `value` is a node. + */ +function node(value) { + return Boolean(value && typeof value === 'object') +} + +/** + * Like `Array#splice`, but smarter for giant arrays. + * + * `Array#splice` takes all items to be inserted as individual argument which + * causes a stack overflow in V8 when trying to insert 100k items for instance. + * + * Otherwise, this does not return the removed items, and takes `items` as an + * array instead of rest parameters. + * + * @template {unknown} T + * Item type. + * @param {Array} list + * List to operate on. + * @param {number} start + * Index to remove/insert at (can be negative). + * @param {number} remove + * Number of items to remove. + * @param {Array} items + * Items to inject into `list`. + * @returns {void} + * Nothing. + */ +function splice(list, start, remove, items) { + const end = list.length; + let chunkStart = 0; + /** @type {Array} */ + let parameters; + + // Make start between zero and `end` (included). + if (start < 0) { + start = -start > end ? 0 : end + start; + } else { + start = start > end ? end : start; + } + remove = remove > 0 ? remove : 0; + + // No need to chunk the items if there’s only a couple (10k) items. + if (items.length < 10000) { + parameters = Array.from(items); + parameters.unshift(start, remove); + // @ts-expect-error Hush, it’s fine. + list.splice(...parameters); + } else { + // Delete `remove` items starting from `start` + if (remove) list.splice(start, remove); + + // Insert the items in chunks to not cause stack overflows. + while (chunkStart < items.length) { + parameters = items.slice(chunkStart, chunkStart + 10000); + parameters.unshift(start, 0); + // @ts-expect-error Hush, it’s fine. + list.splice(...parameters); + chunkStart += 10000; + start += 10000; + } + } +} + +/** + * Append `items` (an array) at the end of `list` (another array). + * When `list` was empty, returns `items` instead. + * + * This prevents a potentially expensive operation when `list` is empty, + * and adds items in batches to prevent V8 from hanging. + * + * @template {unknown} T + * Item type. + * @param {Array} list + * List to operate on. + * @param {Array} items + * Items to add to `list`. + * @returns {Array} + * Either `list` or `items`. + */ +function push(list, items) { + if (list.length > 0) { + splice(list, list.length, 0, items); + return list + } + return items +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + * @typedef {import('micromark-util-types').Handles} Handles + * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension + * @typedef {import('micromark-util-types').NormalizedExtension} NormalizedExtension + */ + + +const hasOwnProperty = {}.hasOwnProperty; + +/** + * Combine multiple syntax extensions into one. + * + * @param {Array} extensions + * List of syntax extensions. + * @returns {NormalizedExtension} + * A single combined extension. + */ +function combineExtensions(extensions) { + /** @type {NormalizedExtension} */ + const all = {}; + let index = -1; + + while (++index < extensions.length) { + syntaxExtension(all, extensions[index]); + } + + return all +} + +/** + * Merge `extension` into `all`. + * + * @param {NormalizedExtension} all + * Extension to merge into. + * @param {Extension} extension + * Extension to merge. + * @returns {void} + */ +function syntaxExtension(all, extension) { + /** @type {keyof Extension} */ + let hook; + + for (hook in extension) { + const maybe = hasOwnProperty.call(all, hook) ? all[hook] : undefined; + /** @type {Record} */ + const left = maybe || (all[hook] = {}); + /** @type {Record | undefined} */ + const right = extension[hook]; + /** @type {string} */ + let code; + + if (right) { + for (code in right) { + if (!hasOwnProperty.call(left, code)) left[code] = []; + const value = right[code]; + constructs( + // @ts-expect-error Looks like a list. + left[code], + Array.isArray(value) ? value : value ? [value] : [] + ); + } + } + } +} + +/** + * Merge `list` into `existing` (both lists of constructs). + * Mutates `existing`. + * + * @param {Array} existing + * @param {Array} list + * @returns {void} + */ +function constructs(existing, list) { + let index = -1; + /** @type {Array} */ + const before = []; + + while (++index < list.length) { +(list[index].add === 'after' ? existing : before).push(list[index]); + } + + splice(existing, 0, 0, before); +} + +// This module is generated by `script/`. +// +// CommonMark handles attention (emphasis, strong) markers based on what comes +// before or after them. +// One such difference is if those characters are Unicode punctuation. +// This script is generated from the Unicode data. + +/** + * Regular expression that matches a unicode punctuation character. + */ +const unicodePunctuationRegex = + /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; + +/** + * @typedef {import('micromark-util-types').Code} Code + */ + + +/** + * Check whether the character code represents an ASCII alpha (`a` through `z`, + * case insensitive). + * + * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha. + * + * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`) + * to U+005A (`Z`). + * + * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`) + * to U+007A (`z`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAlpha = regexCheck(/[A-Za-z]/); + +/** + * Check whether the character code represents an ASCII alphanumeric (`a` + * through `z`, case insensitive, or `0` through `9`). + * + * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha + * (see `asciiAlpha`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); + +/** + * Check whether the character code represents an ASCII atext. + * + * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in + * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`), + * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F + * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E + * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE + * (`{`) to U+007E TILDE (`~`). + * + * See: + * **\[RFC5322]**: + * [Internet Message Format](https://tools.ietf.org/html/rfc5322). + * P. Resnick. + * IETF. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); + +/** + * Check whether a character code is an ASCII control character. + * + * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL) + * to U+001F (US), or U+007F (DEL). + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function asciiControl(code) { + return ( + // Special whitespace codes (which have negative values), C0 and Control + // character DEL + code !== null && (code < 32 || code === 127) + ) +} + +/** + * Check whether the character code represents an ASCII digit (`0` through `9`). + * + * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to + * U+0039 (`9`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiDigit = regexCheck(/\d/); + +/** + * Check whether the character code represents an ASCII hex digit (`a` through + * `f`, case insensitive, or `0` through `9`). + * + * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex + * digit, or an ASCII lower hex digit. + * + * An **ASCII upper hex digit** is a character in the inclusive range U+0041 + * (`A`) to U+0046 (`F`). + * + * An **ASCII lower hex digit** is a character in the inclusive range U+0061 + * (`a`) to U+0066 (`f`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); + +/** + * Check whether the character code represents ASCII punctuation. + * + * An **ASCII punctuation** is a character in the inclusive ranges U+0021 + * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT + * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT + * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); + +/** + * Check whether a character code is a markdown line ending. + * + * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN + * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR). + * + * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE + * RETURN (CR) are replaced by these virtual characters depending on whether + * they occurred together. + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownLineEnding(code) { + return code !== null && code < -2 +} + +/** + * Check whether a character code is a markdown line ending (see + * `markdownLineEnding`) or markdown space (see `markdownSpace`). + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownLineEndingOrSpace(code) { + return code !== null && (code < 0 || code === 32) +} + +/** + * Check whether a character code is a markdown space. + * + * A **markdown space** is the concrete character U+0020 SPACE (SP) and the + * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT). + * + * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is + * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL + * SPACE (VS) characters, depending on the column at which the tab occurred. + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownSpace(code) { + return code === -2 || code === -1 || code === 32 +} + +// Size note: removing ASCII from the regex and using `asciiPunctuation` here +// In fact adds to the bundle size. +/** + * Check whether the character code represents Unicode punctuation. + * + * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation, + * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf` + * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po` + * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII + * punctuation (see `asciiPunctuation`). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const unicodePunctuation = regexCheck(unicodePunctuationRegex); + +/** + * Check whether the character code represents Unicode whitespace. + * + * Note that this does handle micromark specific markdown whitespace characters. + * See `markdownLineEndingOrSpace` to check that. + * + * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator, + * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), + * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const unicodeWhitespace = regexCheck(/\s/); + +/** + * Create a code check from a regex. + * + * @param {RegExp} regex + * @returns {(code: Code) => boolean} + */ +function regexCheck(regex) { + return check + + /** + * Check whether a code matches the bound regex. + * + * @param {Code} code + * Character code. + * @returns {boolean} + * Whether the character code matches the bound regex. + */ + function check(code) { + return code !== null && regex.test(String.fromCharCode(code)) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + + +// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`. + +/** + * Parse spaces and tabs. + * + * There is no `nok` parameter: + * + * * spaces in markdown are often optional, in which case this factory can be + * used and `ok` will be switched to whether spaces were found or not + * * one line ending or space can be detected with `markdownSpace(code)` right + * before using `factorySpace` + * + * ###### Examples + * + * Where `␉` represents a tab (plus how much it expands) and `␠` represents a + * single space. + * + * ```markdown + * ␉ + * ␠␠␠␠ + * ␉␠ + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {TokenType} type + * Type (`' \t'`). + * @param {number | undefined} [max=Infinity] + * Max (exclusive). + * @returns + * Start state. + */ +function factorySpace(effects, ok, type, max) { + const limit = max ? max - 1 : Number.POSITIVE_INFINITY; + let size = 0; + return start + + /** @type {State} */ + function start(code) { + if (markdownSpace(code)) { + effects.enter(type); + return prefix(code) + } + return ok(code) + } + + /** @type {State} */ + function prefix(code) { + if (markdownSpace(code) && size++ < limit) { + effects.consume(code); + return prefix + } + effects.exit(type); + return ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** @type {InitialConstruct} */ +const content$1 = { + tokenize: initializeContent +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeContent(effects) { + const contentStart = effects.attempt( + this.parser.constructs.contentInitial, + afterContentStartConstruct, + paragraphInitial + ); + /** @type {Token} */ + let previous; + return contentStart + + /** @type {State} */ + function afterContentStartConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, contentStart, 'linePrefix') + } + + /** @type {State} */ + function paragraphInitial(code) { + effects.enter('paragraph'); + return lineStart(code) + } + + /** @type {State} */ + function lineStart(code) { + const token = effects.enter('chunkText', { + contentType: 'text', + previous + }); + if (previous) { + previous.next = token; + } + previous = token; + return data(code) + } + + /** @type {State} */ + function data(code) { + if (code === null) { + effects.exit('chunkText'); + effects.exit('paragraph'); + effects.consume(code); + return + } + if (markdownLineEnding(code)) { + effects.consume(code); + effects.exit('chunkText'); + return lineStart + } + + // Data. + effects.consume(code); + return data + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ContainerState} ContainerState + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {InitialConstruct} */ +const document$1 = { + tokenize: initializeDocument +}; + +/** @type {Construct} */ +const containerConstruct = { + tokenize: tokenizeContainer +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeDocument(effects) { + const self = this; + /** @type {Array} */ + const stack = []; + let continued = 0; + /** @type {TokenizeContext | undefined} */ + let childFlow; + /** @type {Token | undefined} */ + let childToken; + /** @type {number} */ + let lineStartOffset; + return start + + /** @type {State} */ + function start(code) { + // First we iterate through the open blocks, starting with the root + // document, and descending through last children down to the last open + // block. + // Each block imposes a condition that the line must satisfy if the block is + // to remain open. + // For example, a block quote requires a `>` character. + // A paragraph requires a non-blank line. + // In this phase we may match all or just some of the open blocks. + // But we cannot close unmatched blocks yet, because we may have a lazy + // continuation line. + if (continued < stack.length) { + const item = stack[continued]; + self.containerState = item[1]; + return effects.attempt( + item[0].continuation, + documentContinue, + checkNewContainers + )(code) + } + + // Done. + return checkNewContainers(code) + } + + /** @type {State} */ + function documentContinue(code) { + continued++; + + // Note: this field is called `_closeFlow` but it also closes containers. + // Perhaps a good idea to rename it but it’s already used in the wild by + // extensions. + if (self.containerState._closeFlow) { + self.containerState._closeFlow = undefined; + if (childFlow) { + closeFlow(); + } + + // Note: this algorithm for moving events around is similar to the + // algorithm when dealing with lazy lines in `writeToChild`. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {Point | undefined} */ + let point; + + // Find the flow chunk. + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + point = self.events[indexBeforeFlow][1].end; + break + } + } + exitContainers(continued); + + // Fix positions. + let index = indexBeforeExits; + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } + + // Inject the exits earlier (they’re still also at the end). + splice( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); + + // Discard the duplicate exits. + self.events.length = index; + return checkNewContainers(code) + } + return start(code) + } + + /** @type {State} */ + function checkNewContainers(code) { + // Next, after consuming the continuation markers for existing blocks, we + // look for new block starts (e.g. `>` for a block quote). + // If we encounter a new block start, we close any blocks unmatched in + // step 1 before creating the new block as a child of the last matched + // block. + if (continued === stack.length) { + // No need to `check` whether there’s a container, of `exitContainers` + // would be moot. + // We can instead immediately `attempt` to parse one. + if (!childFlow) { + return documentContinued(code) + } + + // If we have concrete content, such as block HTML or fenced code, + // we can’t have containers “pierce” into them, so we can immediately + // start. + if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { + return flowStart(code) + } + + // If we do have flow, it could still be a blank line, + // but we’d be interrupting it w/ a new container if there’s a current + // construct. + // To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer + // needed in micromark-extension-gfm-table@1.0.6). + self.interrupt = Boolean( + childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack + ); + } + + // Check if there is a new container. + self.containerState = {}; + return effects.check( + containerConstruct, + thereIsANewContainer, + thereIsNoNewContainer + )(code) + } + + /** @type {State} */ + function thereIsANewContainer(code) { + if (childFlow) closeFlow(); + exitContainers(continued); + return documentContinued(code) + } + + /** @type {State} */ + function thereIsNoNewContainer(code) { + self.parser.lazy[self.now().line] = continued !== stack.length; + lineStartOffset = self.now().offset; + return flowStart(code) + } + + /** @type {State} */ + function documentContinued(code) { + // Try new containers. + self.containerState = {}; + return effects.attempt( + containerConstruct, + containerContinue, + flowStart + )(code) + } + + /** @type {State} */ + function containerContinue(code) { + continued++; + stack.push([self.currentConstruct, self.containerState]); + // Try another. + return documentContinued(code) + } + + /** @type {State} */ + function flowStart(code) { + if (code === null) { + if (childFlow) closeFlow(); + exitContainers(0); + effects.consume(code); + return + } + childFlow = childFlow || self.parser.flow(self.now()); + effects.enter('chunkFlow', { + contentType: 'flow', + previous: childToken, + _tokenizer: childFlow + }); + return flowContinue(code) + } + + /** @type {State} */ + function flowContinue(code) { + if (code === null) { + writeToChild(effects.exit('chunkFlow'), true); + exitContainers(0); + effects.consume(code); + return + } + if (markdownLineEnding(code)) { + effects.consume(code); + writeToChild(effects.exit('chunkFlow')); + // Get ready for the next line. + continued = 0; + self.interrupt = undefined; + return start + } + effects.consume(code); + return flowContinue + } + + /** + * @param {Token} token + * @param {boolean | undefined} [eof] + * @returns {void} + */ + function writeToChild(token, eof) { + const stream = self.sliceStream(token); + if (eof) stream.push(null); + token.previous = childToken; + if (childToken) childToken.next = token; + childToken = token; + childFlow.defineSkip(token.start); + childFlow.write(stream); + + // Alright, so we just added a lazy line: + // + // ```markdown + // > a + // b. + // + // Or: + // + // > ~~~c + // d + // + // Or: + // + // > | e | + // f + // ``` + // + // The construct in the second example (fenced code) does not accept lazy + // lines, so it marked itself as done at the end of its first line, and + // then the content construct parses `d`. + // Most constructs in markdown match on the first line: if the first line + // forms a construct, a non-lazy line can’t “unmake” it. + // + // The construct in the third example is potentially a GFM table, and + // those are *weird*. + // It *could* be a table, from the first line, if the following line + // matches a condition. + // In this case, that second line is lazy, which “unmakes” the first line + // and turns the whole into one content block. + // + // We’ve now parsed the non-lazy and the lazy line, and can figure out + // whether the lazy line started a new flow block. + // If it did, we exit the current containers between the two flow blocks. + if (self.parser.lazy[token.start.line]) { + let index = childFlow.events.length; + while (index--) { + if ( + // The token starts before the line ending… + childFlow.events[index][1].start.offset < lineStartOffset && + // …and either is not ended yet… + (!childFlow.events[index][1].end || + // …or ends after it. + childFlow.events[index][1].end.offset > lineStartOffset) + ) { + // Exit: there’s still something open, which means it’s a lazy line + // part of something. + return + } + } + + // Note: this algorithm for moving events around is similar to the + // algorithm when closing flow in `documentContinue`. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {boolean | undefined} */ + let seen; + /** @type {Point | undefined} */ + let point; + + // Find the previous chunk (the one before the lazy line). + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + if (seen) { + point = self.events[indexBeforeFlow][1].end; + break + } + seen = true; + } + } + exitContainers(continued); + + // Fix positions. + index = indexBeforeExits; + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } + + // Inject the exits earlier (they’re still also at the end). + splice( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); + + // Discard the duplicate exits. + self.events.length = index; + } + } + + /** + * @param {number} size + * @returns {void} + */ + function exitContainers(size) { + let index = stack.length; + + // Exit open containers. + while (index-- > size) { + const entry = stack[index]; + self.containerState = entry[1]; + entry[0].exit.call(self, effects); + } + stack.length = size; + } + function closeFlow() { + childFlow.write([null]); + childToken = undefined; + childFlow = undefined; + self.containerState._closeFlow = undefined; + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContainer(effects, ok, nok) { + // Always populated by defaults. + + return factorySpace( + effects, + effects.attempt(this.parser.constructs.document, ok, nok), + 'linePrefix', + this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + ) +} + +/** + * @typedef {import('micromark-util-types').Code} Code + */ + +/** + * Classify whether a code represents whitespace, punctuation, or something + * else. + * + * Used for attention (emphasis, strong), whose sequences can open or close + * based on the class of surrounding characters. + * + * > 👉 **Note**: eof (`null`) is seen as whitespace. + * + * @param {Code} code + * Code. + * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined} + * Group. + */ +function classifyCharacter(code) { + if ( + code === null || + markdownLineEndingOrSpace(code) || + unicodeWhitespace(code) + ) { + return 1 + } + if (unicodePunctuation(code)) { + return 2 + } +} + +/** + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** + * Call all `resolveAll`s. + * + * @param {Array<{resolveAll?: Resolver | undefined}>} constructs + * List of constructs, optionally with `resolveAll`s. + * @param {Array} events + * List of events. + * @param {TokenizeContext} context + * Context used by `tokenize`. + * @returns {Array} + * Changed events. + */ +function resolveAll(constructs, events, context) { + /** @type {Array} */ + const called = []; + let index = -1; + + while (++index < constructs.length) { + const resolve = constructs[index].resolveAll; + + if (resolve && !called.includes(resolve)) { + events = resolve(events, context); + called.push(resolve); + } + } + + return events +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const attention = { + name: 'attention', + tokenize: tokenizeAttention, + resolveAll: resolveAllAttention +}; + +/** + * Take all events and resolve attention to emphasis or strong. + * + * @type {Resolver} + */ +function resolveAllAttention(events, context) { + let index = -1; + /** @type {number} */ + let open; + /** @type {Token} */ + let group; + /** @type {Token} */ + let text; + /** @type {Token} */ + let openingSequence; + /** @type {Token} */ + let closingSequence; + /** @type {number} */ + let use; + /** @type {Array} */ + let nextEvents; + /** @type {number} */ + let offset; + + // Walk through all events. + // + // Note: performance of this is fine on an mb of normal markdown, but it’s + // a bottleneck for malicious stuff. + while (++index < events.length) { + // Find a token that can close. + if ( + events[index][0] === 'enter' && + events[index][1].type === 'attentionSequence' && + events[index][1]._close + ) { + open = index; + + // Now walk back to find an opener. + while (open--) { + // Find a token that can open the closer. + if ( + events[open][0] === 'exit' && + events[open][1].type === 'attentionSequence' && + events[open][1]._open && + // If the markers are the same: + context.sliceSerialize(events[open][1]).charCodeAt(0) === + context.sliceSerialize(events[index][1]).charCodeAt(0) + ) { + // If the opening can close or the closing can open, + // and the close size *is not* a multiple of three, + // but the sum of the opening and closing size *is* multiple of three, + // then don’t match. + if ( + (events[open][1]._close || events[index][1]._open) && + (events[index][1].end.offset - events[index][1].start.offset) % 3 && + !( + (events[open][1].end.offset - + events[open][1].start.offset + + events[index][1].end.offset - + events[index][1].start.offset) % + 3 + ) + ) { + continue + } + + // Number of markers to use from the sequence. + use = + events[open][1].end.offset - events[open][1].start.offset > 1 && + events[index][1].end.offset - events[index][1].start.offset > 1 + ? 2 + : 1; + const start = Object.assign({}, events[open][1].end); + const end = Object.assign({}, events[index][1].start); + movePoint(start, -use); + movePoint(end, use); + openingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start, + end: Object.assign({}, events[open][1].end) + }; + closingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start: Object.assign({}, events[index][1].start), + end + }; + text = { + type: use > 1 ? 'strongText' : 'emphasisText', + start: Object.assign({}, events[open][1].end), + end: Object.assign({}, events[index][1].start) + }; + group = { + type: use > 1 ? 'strong' : 'emphasis', + start: Object.assign({}, openingSequence.start), + end: Object.assign({}, closingSequence.end) + }; + events[open][1].end = Object.assign({}, openingSequence.start); + events[index][1].start = Object.assign({}, closingSequence.end); + nextEvents = []; + + // If there are more markers in the opening, add them before. + if (events[open][1].end.offset - events[open][1].start.offset) { + nextEvents = push(nextEvents, [ + ['enter', events[open][1], context], + ['exit', events[open][1], context] + ]); + } + + // Opening. + nextEvents = push(nextEvents, [ + ['enter', group, context], + ['enter', openingSequence, context], + ['exit', openingSequence, context], + ['enter', text, context] + ]); + + // Always populated by defaults. + + // Between. + nextEvents = push( + nextEvents, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + 1, index), + context + ) + ); + + // Closing. + nextEvents = push(nextEvents, [ + ['exit', text, context], + ['enter', closingSequence, context], + ['exit', closingSequence, context], + ['exit', group, context] + ]); + + // If there are more markers in the closing, add them after. + if (events[index][1].end.offset - events[index][1].start.offset) { + offset = 2; + nextEvents = push(nextEvents, [ + ['enter', events[index][1], context], + ['exit', events[index][1], context] + ]); + } else { + offset = 0; + } + splice(events, open - 1, index - open + 3, nextEvents); + index = open + nextEvents.length - offset - 2; + break + } + } + } + } + + // Remove remaining sequences. + index = -1; + while (++index < events.length) { + if (events[index][1].type === 'attentionSequence') { + events[index][1].type = 'data'; + } + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeAttention(effects, ok) { + const attentionMarkers = this.parser.constructs.attentionMarkers.null; + const previous = this.previous; + const before = classifyCharacter(previous); + + /** @type {NonNullable} */ + let marker; + return start + + /** + * Before a sequence. + * + * ```markdown + * > | ** + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + marker = code; + effects.enter('attentionSequence'); + return inside(code) + } + + /** + * In a sequence. + * + * ```markdown + * > | ** + * ^^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === marker) { + effects.consume(code); + return inside + } + const token = effects.exit('attentionSequence'); + + // To do: next major: move this to resolver, just like `markdown-rs`. + const after = classifyCharacter(code); + + // Always populated by defaults. + + const open = + !after || (after === 2 && before) || attentionMarkers.includes(code); + const close = + !before || (before === 2 && after) || attentionMarkers.includes(previous); + token._open = Boolean(marker === 42 ? open : open && (before || !close)); + token._close = Boolean(marker === 42 ? close : close && (after || !open)); + return ok(code) + } +} + +/** + * Move a point a bit. + * + * Note: `move` only works inside lines! It’s not possible to move past other + * chunks (replacement characters, tabs, or line endings). + * + * @param {Point} point + * @param {number} offset + * @returns {void} + */ +function movePoint(point, offset) { + point.column += offset; + point.offset += offset; + point._bufferIndex += offset; +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const autolink = { + name: 'autolink', + tokenize: tokenizeAutolink +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeAutolink(effects, ok, nok) { + let size = 0; + return start + + /** + * Start of an autolink. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('autolink'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.enter('autolinkProtocol'); + return open + } + + /** + * After `<`, at protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (asciiAlpha(code)) { + effects.consume(code); + return schemeOrEmailAtext + } + return emailAtext(code) + } + + /** + * At second byte of protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function schemeOrEmailAtext(code) { + // ASCII alphanumeric and `+`, `-`, and `.`. + if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) { + // Count the previous alphabetical from `open` too. + size = 1; + return schemeInsideOrEmailAtext(code) + } + return emailAtext(code) + } + + /** + * In ambiguous protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function schemeInsideOrEmailAtext(code) { + if (code === 58) { + effects.consume(code); + size = 0; + return urlInside + } + + // ASCII alphanumeric and `+`, `-`, and `.`. + if ( + (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && + size++ < 32 + ) { + effects.consume(code); + return schemeInsideOrEmailAtext + } + size = 0; + return emailAtext(code) + } + + /** + * After protocol, in URL. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function urlInside(code) { + if (code === 62) { + effects.exit('autolinkProtocol'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok + } + + // ASCII control, space, or `<`. + if (code === null || code === 32 || code === 60 || asciiControl(code)) { + return nok(code) + } + effects.consume(code); + return urlInside + } + + /** + * In email atext. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailAtext(code) { + if (code === 64) { + effects.consume(code); + return emailAtSignOrDot + } + if (asciiAtext(code)) { + effects.consume(code); + return emailAtext + } + return nok(code) + } + + /** + * In label, after at-sign or dot. + * + * ```markdown + * > | ab + * ^ ^ + * ``` + * + * @type {State} + */ + function emailAtSignOrDot(code) { + return asciiAlphanumeric(code) ? emailLabel(code) : nok(code) + } + + /** + * In label, where `.` and `>` are allowed. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailLabel(code) { + if (code === 46) { + effects.consume(code); + size = 0; + return emailAtSignOrDot + } + if (code === 62) { + // Exit, then change the token type. + effects.exit('autolinkProtocol').type = 'autolinkEmail'; + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok + } + return emailValue(code) + } + + /** + * In label, where `.` and `>` are *not* allowed. + * + * Though, this is also used in `emailLabel` to parse other values. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailValue(code) { + // ASCII alphanumeric or `-`. + if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) { + const next = code === 45 ? emailValue : emailLabel; + effects.consume(code); + return next + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const blankLine = { + tokenize: tokenizeBlankLine, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlankLine(effects, ok, nok) { + return start + + /** + * Start of blank line. + * + * > 👉 **Note**: `␠` represents a space character. + * + * ```markdown + * > | ␠␠␊ + * ^ + * > | ␊ + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + return markdownSpace(code) + ? factorySpace(effects, after, 'linePrefix')(code) + : after(code) + } + + /** + * At eof/eol, after optional whitespace. + * + * > 👉 **Note**: `␠` represents a space character. + * + * ```markdown + * > | ␠␠␊ + * ^ + * > | ␊ + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const blockQuote = { + name: 'blockQuote', + tokenize: tokenizeBlockQuoteStart, + continuation: { + tokenize: tokenizeBlockQuoteContinuation + }, + exit +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlockQuoteStart(effects, ok, nok) { + const self = this; + return start + + /** + * Start of block quote. + * + * ```markdown + * > | > a + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 62) { + const state = self.containerState; + if (!state.open) { + effects.enter('blockQuote', { + _container: true + }); + state.open = true; + } + effects.enter('blockQuotePrefix'); + effects.enter('blockQuoteMarker'); + effects.consume(code); + effects.exit('blockQuoteMarker'); + return after + } + return nok(code) + } + + /** + * After `>`, before optional whitespace. + * + * ```markdown + * > | > a + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + if (markdownSpace(code)) { + effects.enter('blockQuotePrefixWhitespace'); + effects.consume(code); + effects.exit('blockQuotePrefixWhitespace'); + effects.exit('blockQuotePrefix'); + return ok + } + effects.exit('blockQuotePrefix'); + return ok(code) + } +} + +/** + * Start of block quote continuation. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlockQuoteContinuation(effects, ok, nok) { + const self = this; + return contStart + + /** + * Start of block quote continuation. + * + * Also used to parse the first block quote opening. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @type {State} + */ + function contStart(code) { + if (markdownSpace(code)) { + // Always populated by defaults. + + return factorySpace( + effects, + contBefore, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } + return contBefore(code) + } + + /** + * At `>`, after optional whitespace. + * + * Also used to parse the first block quote opening. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @type {State} + */ + function contBefore(code) { + return effects.attempt(blockQuote, ok, nok)(code) + } +} + +/** @type {Exiter} */ +function exit(effects) { + effects.exit('blockQuote'); +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const characterEscape = { + name: 'characterEscape', + tokenize: tokenizeCharacterEscape +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCharacterEscape(effects, ok, nok) { + return start + + /** + * Start of character escape. + * + * ```markdown + * > | a\*b + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('characterEscape'); + effects.enter('escapeMarker'); + effects.consume(code); + effects.exit('escapeMarker'); + return inside + } + + /** + * After `\`, at punctuation. + * + * ```markdown + * > | a\*b + * ^ + * ``` + * + * @type {State} + */ + function inside(code) { + // ASCII punctuation. + if (asciiPunctuation(code)) { + effects.enter('characterEscapeValue'); + effects.consume(code); + effects.exit('characterEscapeValue'); + effects.exit('characterEscape'); + return ok + } + return nok(code) + } +} + +/** + * Map of named character references. + * + * @type {Record} + */ +const characterEntities = { + AElig: 'Æ', + AMP: '&', + Aacute: 'Á', + Abreve: 'Ă', + Acirc: 'Â', + Acy: 'А', + Afr: '𝔄', + Agrave: 'À', + Alpha: 'Α', + Amacr: 'Ā', + And: '⩓', + Aogon: 'Ą', + Aopf: '𝔸', + ApplyFunction: '⁡', + Aring: 'Å', + Ascr: '𝒜', + Assign: '≔', + Atilde: 'Ã', + Auml: 'Ä', + Backslash: '∖', + Barv: '⫧', + Barwed: '⌆', + Bcy: 'Б', + Because: '∵', + Bernoullis: 'ℬ', + Beta: 'Β', + Bfr: '𝔅', + Bopf: '𝔹', + Breve: '˘', + Bscr: 'ℬ', + Bumpeq: '≎', + CHcy: 'Ч', + COPY: '©', + Cacute: 'Ć', + Cap: '⋒', + CapitalDifferentialD: 'ⅅ', + Cayleys: 'ℭ', + Ccaron: 'Č', + Ccedil: 'Ç', + Ccirc: 'Ĉ', + Cconint: '∰', + Cdot: 'Ċ', + Cedilla: '¸', + CenterDot: '·', + Cfr: 'ℭ', + Chi: 'Χ', + CircleDot: '⊙', + CircleMinus: '⊖', + CirclePlus: '⊕', + CircleTimes: '⊗', + ClockwiseContourIntegral: '∲', + CloseCurlyDoubleQuote: '”', + CloseCurlyQuote: '’', + Colon: '∷', + Colone: '⩴', + Congruent: '≡', + Conint: '∯', + ContourIntegral: '∮', + Copf: 'ℂ', + Coproduct: '∐', + CounterClockwiseContourIntegral: '∳', + Cross: '⨯', + Cscr: '𝒞', + Cup: '⋓', + CupCap: '≍', + DD: 'ⅅ', + DDotrahd: '⤑', + DJcy: 'Ђ', + DScy: 'Ѕ', + DZcy: 'Џ', + Dagger: '‡', + Darr: '↡', + Dashv: '⫤', + Dcaron: 'Ď', + Dcy: 'Д', + Del: '∇', + Delta: 'Δ', + Dfr: '𝔇', + DiacriticalAcute: '´', + DiacriticalDot: '˙', + DiacriticalDoubleAcute: '˝', + DiacriticalGrave: '`', + DiacriticalTilde: '˜', + Diamond: '⋄', + DifferentialD: 'ⅆ', + Dopf: '𝔻', + Dot: '¨', + DotDot: '⃜', + DotEqual: '≐', + DoubleContourIntegral: '∯', + DoubleDot: '¨', + DoubleDownArrow: '⇓', + DoubleLeftArrow: '⇐', + DoubleLeftRightArrow: '⇔', + DoubleLeftTee: '⫤', + DoubleLongLeftArrow: '⟸', + DoubleLongLeftRightArrow: '⟺', + DoubleLongRightArrow: '⟹', + DoubleRightArrow: '⇒', + DoubleRightTee: '⊨', + DoubleUpArrow: '⇑', + DoubleUpDownArrow: '⇕', + DoubleVerticalBar: '∥', + DownArrow: '↓', + DownArrowBar: '⤓', + DownArrowUpArrow: '⇵', + DownBreve: '̑', + DownLeftRightVector: '⥐', + DownLeftTeeVector: '⥞', + DownLeftVector: '↽', + DownLeftVectorBar: '⥖', + DownRightTeeVector: '⥟', + DownRightVector: '⇁', + DownRightVectorBar: '⥗', + DownTee: '⊤', + DownTeeArrow: '↧', + Downarrow: '⇓', + Dscr: '𝒟', + Dstrok: 'Đ', + ENG: 'Ŋ', + ETH: 'Ð', + Eacute: 'É', + Ecaron: 'Ě', + Ecirc: 'Ê', + Ecy: 'Э', + Edot: 'Ė', + Efr: '𝔈', + Egrave: 'È', + Element: '∈', + Emacr: 'Ē', + EmptySmallSquare: '◻', + EmptyVerySmallSquare: '▫', + Eogon: 'Ę', + Eopf: '𝔼', + Epsilon: 'Ε', + Equal: '⩵', + EqualTilde: '≂', + Equilibrium: '⇌', + Escr: 'ℰ', + Esim: '⩳', + Eta: 'Η', + Euml: 'Ë', + Exists: '∃', + ExponentialE: 'ⅇ', + Fcy: 'Ф', + Ffr: '𝔉', + FilledSmallSquare: '◼', + FilledVerySmallSquare: '▪', + Fopf: '𝔽', + ForAll: '∀', + Fouriertrf: 'ℱ', + Fscr: 'ℱ', + GJcy: 'Ѓ', + GT: '>', + Gamma: 'Γ', + Gammad: 'Ϝ', + Gbreve: 'Ğ', + Gcedil: 'Ģ', + Gcirc: 'Ĝ', + Gcy: 'Г', + Gdot: 'Ġ', + Gfr: '𝔊', + Gg: '⋙', + Gopf: '𝔾', + GreaterEqual: '≥', + GreaterEqualLess: '⋛', + GreaterFullEqual: '≧', + GreaterGreater: '⪢', + GreaterLess: '≷', + GreaterSlantEqual: '⩾', + GreaterTilde: '≳', + Gscr: '𝒢', + Gt: '≫', + HARDcy: 'Ъ', + Hacek: 'ˇ', + Hat: '^', + Hcirc: 'Ĥ', + Hfr: 'ℌ', + HilbertSpace: 'ℋ', + Hopf: 'ℍ', + HorizontalLine: '─', + Hscr: 'ℋ', + Hstrok: 'Ħ', + HumpDownHump: '≎', + HumpEqual: '≏', + IEcy: 'Е', + IJlig: 'IJ', + IOcy: 'Ё', + Iacute: 'Í', + Icirc: 'Î', + Icy: 'И', + Idot: 'İ', + Ifr: 'ℑ', + Igrave: 'Ì', + Im: 'ℑ', + Imacr: 'Ī', + ImaginaryI: 'ⅈ', + Implies: '⇒', + Int: '∬', + Integral: '∫', + Intersection: '⋂', + InvisibleComma: '⁣', + InvisibleTimes: '⁢', + Iogon: 'Į', + Iopf: '𝕀', + Iota: 'Ι', + Iscr: 'ℐ', + Itilde: 'Ĩ', + Iukcy: 'І', + Iuml: 'Ï', + Jcirc: 'Ĵ', + Jcy: 'Й', + Jfr: '𝔍', + Jopf: '𝕁', + Jscr: '𝒥', + Jsercy: 'Ј', + Jukcy: 'Є', + KHcy: 'Х', + KJcy: 'Ќ', + Kappa: 'Κ', + Kcedil: 'Ķ', + Kcy: 'К', + Kfr: '𝔎', + Kopf: '𝕂', + Kscr: '𝒦', + LJcy: 'Љ', + LT: '<', + Lacute: 'Ĺ', + Lambda: 'Λ', + Lang: '⟪', + Laplacetrf: 'ℒ', + Larr: '↞', + Lcaron: 'Ľ', + Lcedil: 'Ļ', + Lcy: 'Л', + LeftAngleBracket: '⟨', + LeftArrow: '←', + LeftArrowBar: '⇤', + LeftArrowRightArrow: '⇆', + LeftCeiling: '⌈', + LeftDoubleBracket: '⟦', + LeftDownTeeVector: '⥡', + LeftDownVector: '⇃', + LeftDownVectorBar: '⥙', + LeftFloor: '⌊', + LeftRightArrow: '↔', + LeftRightVector: '⥎', + LeftTee: '⊣', + LeftTeeArrow: '↤', + LeftTeeVector: '⥚', + LeftTriangle: '⊲', + LeftTriangleBar: '⧏', + LeftTriangleEqual: '⊴', + LeftUpDownVector: '⥑', + LeftUpTeeVector: '⥠', + LeftUpVector: '↿', + LeftUpVectorBar: '⥘', + LeftVector: '↼', + LeftVectorBar: '⥒', + Leftarrow: '⇐', + Leftrightarrow: '⇔', + LessEqualGreater: '⋚', + LessFullEqual: '≦', + LessGreater: '≶', + LessLess: '⪡', + LessSlantEqual: '⩽', + LessTilde: '≲', + Lfr: '𝔏', + Ll: '⋘', + Lleftarrow: '⇚', + Lmidot: 'Ŀ', + LongLeftArrow: '⟵', + LongLeftRightArrow: '⟷', + LongRightArrow: '⟶', + Longleftarrow: '⟸', + Longleftrightarrow: '⟺', + Longrightarrow: '⟹', + Lopf: '𝕃', + LowerLeftArrow: '↙', + LowerRightArrow: '↘', + Lscr: 'ℒ', + Lsh: '↰', + Lstrok: 'Ł', + Lt: '≪', + Map: '⤅', + Mcy: 'М', + MediumSpace: ' ', + Mellintrf: 'ℳ', + Mfr: '𝔐', + MinusPlus: '∓', + Mopf: '𝕄', + Mscr: 'ℳ', + Mu: 'Μ', + NJcy: 'Њ', + Nacute: 'Ń', + Ncaron: 'Ň', + Ncedil: 'Ņ', + Ncy: 'Н', + NegativeMediumSpace: '​', + NegativeThickSpace: '​', + NegativeThinSpace: '​', + NegativeVeryThinSpace: '​', + NestedGreaterGreater: '≫', + NestedLessLess: '≪', + NewLine: '\n', + Nfr: '𝔑', + NoBreak: '⁠', + NonBreakingSpace: ' ', + Nopf: 'ℕ', + Not: '⫬', + NotCongruent: '≢', + NotCupCap: '≭', + NotDoubleVerticalBar: '∦', + NotElement: '∉', + NotEqual: '≠', + NotEqualTilde: '≂̸', + NotExists: '∄', + NotGreater: '≯', + NotGreaterEqual: '≱', + NotGreaterFullEqual: '≧̸', + NotGreaterGreater: '≫̸', + NotGreaterLess: '≹', + NotGreaterSlantEqual: '⩾̸', + NotGreaterTilde: '≵', + NotHumpDownHump: '≎̸', + NotHumpEqual: '≏̸', + NotLeftTriangle: '⋪', + NotLeftTriangleBar: '⧏̸', + NotLeftTriangleEqual: '⋬', + NotLess: '≮', + NotLessEqual: '≰', + NotLessGreater: '≸', + NotLessLess: '≪̸', + NotLessSlantEqual: '⩽̸', + NotLessTilde: '≴', + NotNestedGreaterGreater: '⪢̸', + NotNestedLessLess: '⪡̸', + NotPrecedes: '⊀', + NotPrecedesEqual: '⪯̸', + NotPrecedesSlantEqual: '⋠', + NotReverseElement: '∌', + NotRightTriangle: '⋫', + NotRightTriangleBar: '⧐̸', + NotRightTriangleEqual: '⋭', + NotSquareSubset: '⊏̸', + NotSquareSubsetEqual: '⋢', + NotSquareSuperset: '⊐̸', + NotSquareSupersetEqual: '⋣', + NotSubset: '⊂⃒', + NotSubsetEqual: '⊈', + NotSucceeds: '⊁', + NotSucceedsEqual: '⪰̸', + NotSucceedsSlantEqual: '⋡', + NotSucceedsTilde: '≿̸', + NotSuperset: '⊃⃒', + NotSupersetEqual: '⊉', + NotTilde: '≁', + NotTildeEqual: '≄', + NotTildeFullEqual: '≇', + NotTildeTilde: '≉', + NotVerticalBar: '∤', + Nscr: '𝒩', + Ntilde: 'Ñ', + Nu: 'Ν', + OElig: 'Œ', + Oacute: 'Ó', + Ocirc: 'Ô', + Ocy: 'О', + Odblac: 'Ő', + Ofr: '𝔒', + Ograve: 'Ò', + Omacr: 'Ō', + Omega: 'Ω', + Omicron: 'Ο', + Oopf: '𝕆', + OpenCurlyDoubleQuote: '“', + OpenCurlyQuote: '‘', + Or: '⩔', + Oscr: '𝒪', + Oslash: 'Ø', + Otilde: 'Õ', + Otimes: '⨷', + Ouml: 'Ö', + OverBar: '‾', + OverBrace: '⏞', + OverBracket: '⎴', + OverParenthesis: '⏜', + PartialD: '∂', + Pcy: 'П', + Pfr: '𝔓', + Phi: 'Φ', + Pi: 'Π', + PlusMinus: '±', + Poincareplane: 'ℌ', + Popf: 'ℙ', + Pr: '⪻', + Precedes: '≺', + PrecedesEqual: '⪯', + PrecedesSlantEqual: '≼', + PrecedesTilde: '≾', + Prime: '″', + Product: '∏', + Proportion: '∷', + Proportional: '∝', + Pscr: '𝒫', + Psi: 'Ψ', + QUOT: '"', + Qfr: '𝔔', + Qopf: 'ℚ', + Qscr: '𝒬', + RBarr: '⤐', + REG: '®', + Racute: 'Ŕ', + Rang: '⟫', + Rarr: '↠', + Rarrtl: '⤖', + Rcaron: 'Ř', + Rcedil: 'Ŗ', + Rcy: 'Р', + Re: 'ℜ', + ReverseElement: '∋', + ReverseEquilibrium: '⇋', + ReverseUpEquilibrium: '⥯', + Rfr: 'ℜ', + Rho: 'Ρ', + RightAngleBracket: '⟩', + RightArrow: '→', + RightArrowBar: '⇥', + RightArrowLeftArrow: '⇄', + RightCeiling: '⌉', + RightDoubleBracket: '⟧', + RightDownTeeVector: '⥝', + RightDownVector: '⇂', + RightDownVectorBar: '⥕', + RightFloor: '⌋', + RightTee: '⊢', + RightTeeArrow: '↦', + RightTeeVector: '⥛', + RightTriangle: '⊳', + RightTriangleBar: '⧐', + RightTriangleEqual: '⊵', + RightUpDownVector: '⥏', + RightUpTeeVector: '⥜', + RightUpVector: '↾', + RightUpVectorBar: '⥔', + RightVector: '⇀', + RightVectorBar: '⥓', + Rightarrow: '⇒', + Ropf: 'ℝ', + RoundImplies: '⥰', + Rrightarrow: '⇛', + Rscr: 'ℛ', + Rsh: '↱', + RuleDelayed: '⧴', + SHCHcy: 'Щ', + SHcy: 'Ш', + SOFTcy: 'Ь', + Sacute: 'Ś', + Sc: '⪼', + Scaron: 'Š', + Scedil: 'Ş', + Scirc: 'Ŝ', + Scy: 'С', + Sfr: '𝔖', + ShortDownArrow: '↓', + ShortLeftArrow: '←', + ShortRightArrow: '→', + ShortUpArrow: '↑', + Sigma: 'Σ', + SmallCircle: '∘', + Sopf: '𝕊', + Sqrt: '√', + Square: '□', + SquareIntersection: '⊓', + SquareSubset: '⊏', + SquareSubsetEqual: '⊑', + SquareSuperset: '⊐', + SquareSupersetEqual: '⊒', + SquareUnion: '⊔', + Sscr: '𝒮', + Star: '⋆', + Sub: '⋐', + Subset: '⋐', + SubsetEqual: '⊆', + Succeeds: '≻', + SucceedsEqual: '⪰', + SucceedsSlantEqual: '≽', + SucceedsTilde: '≿', + SuchThat: '∋', + Sum: '∑', + Sup: '⋑', + Superset: '⊃', + SupersetEqual: '⊇', + Supset: '⋑', + THORN: 'Þ', + TRADE: '™', + TSHcy: 'Ћ', + TScy: 'Ц', + Tab: '\t', + Tau: 'Τ', + Tcaron: 'Ť', + Tcedil: 'Ţ', + Tcy: 'Т', + Tfr: '𝔗', + Therefore: '∴', + Theta: 'Θ', + ThickSpace: '  ', + ThinSpace: ' ', + Tilde: '∼', + TildeEqual: '≃', + TildeFullEqual: '≅', + TildeTilde: '≈', + Topf: '𝕋', + TripleDot: '⃛', + Tscr: '𝒯', + Tstrok: 'Ŧ', + Uacute: 'Ú', + Uarr: '↟', + Uarrocir: '⥉', + Ubrcy: 'Ў', + Ubreve: 'Ŭ', + Ucirc: 'Û', + Ucy: 'У', + Udblac: 'Ű', + Ufr: '𝔘', + Ugrave: 'Ù', + Umacr: 'Ū', + UnderBar: '_', + UnderBrace: '⏟', + UnderBracket: '⎵', + UnderParenthesis: '⏝', + Union: '⋃', + UnionPlus: '⊎', + Uogon: 'Ų', + Uopf: '𝕌', + UpArrow: '↑', + UpArrowBar: '⤒', + UpArrowDownArrow: '⇅', + UpDownArrow: '↕', + UpEquilibrium: '⥮', + UpTee: '⊥', + UpTeeArrow: '↥', + Uparrow: '⇑', + Updownarrow: '⇕', + UpperLeftArrow: '↖', + UpperRightArrow: '↗', + Upsi: 'ϒ', + Upsilon: 'Υ', + Uring: 'Ů', + Uscr: '𝒰', + Utilde: 'Ũ', + Uuml: 'Ü', + VDash: '⊫', + Vbar: '⫫', + Vcy: 'В', + Vdash: '⊩', + Vdashl: '⫦', + Vee: '⋁', + Verbar: '‖', + Vert: '‖', + VerticalBar: '∣', + VerticalLine: '|', + VerticalSeparator: '❘', + VerticalTilde: '≀', + VeryThinSpace: ' ', + Vfr: '𝔙', + Vopf: '𝕍', + Vscr: '𝒱', + Vvdash: '⊪', + Wcirc: 'Ŵ', + Wedge: '⋀', + Wfr: '𝔚', + Wopf: '𝕎', + Wscr: '𝒲', + Xfr: '𝔛', + Xi: 'Ξ', + Xopf: '𝕏', + Xscr: '𝒳', + YAcy: 'Я', + YIcy: 'Ї', + YUcy: 'Ю', + Yacute: 'Ý', + Ycirc: 'Ŷ', + Ycy: 'Ы', + Yfr: '𝔜', + Yopf: '𝕐', + Yscr: '𝒴', + Yuml: 'Ÿ', + ZHcy: 'Ж', + Zacute: 'Ź', + Zcaron: 'Ž', + Zcy: 'З', + Zdot: 'Ż', + ZeroWidthSpace: '​', + Zeta: 'Ζ', + Zfr: 'ℨ', + Zopf: 'ℤ', + Zscr: '𝒵', + aacute: 'á', + abreve: 'ă', + ac: '∾', + acE: '∾̳', + acd: '∿', + acirc: 'â', + acute: '´', + acy: 'а', + aelig: 'æ', + af: '⁡', + afr: '𝔞', + agrave: 'à', + alefsym: 'ℵ', + aleph: 'ℵ', + alpha: 'α', + amacr: 'ā', + amalg: '⨿', + amp: '&', + and: '∧', + andand: '⩕', + andd: '⩜', + andslope: '⩘', + andv: '⩚', + ang: '∠', + ange: '⦤', + angle: '∠', + angmsd: '∡', + angmsdaa: '⦨', + angmsdab: '⦩', + angmsdac: '⦪', + angmsdad: '⦫', + angmsdae: '⦬', + angmsdaf: '⦭', + angmsdag: '⦮', + angmsdah: '⦯', + angrt: '∟', + angrtvb: '⊾', + angrtvbd: '⦝', + angsph: '∢', + angst: 'Å', + angzarr: '⍼', + aogon: 'ą', + aopf: '𝕒', + ap: '≈', + apE: '⩰', + apacir: '⩯', + ape: '≊', + apid: '≋', + apos: "'", + approx: '≈', + approxeq: '≊', + aring: 'å', + ascr: '𝒶', + ast: '*', + asymp: '≈', + asympeq: '≍', + atilde: 'ã', + auml: 'ä', + awconint: '∳', + awint: '⨑', + bNot: '⫭', + backcong: '≌', + backepsilon: '϶', + backprime: '‵', + backsim: '∽', + backsimeq: '⋍', + barvee: '⊽', + barwed: '⌅', + barwedge: '⌅', + bbrk: '⎵', + bbrktbrk: '⎶', + bcong: '≌', + bcy: 'б', + bdquo: '„', + becaus: '∵', + because: '∵', + bemptyv: '⦰', + bepsi: '϶', + bernou: 'ℬ', + beta: 'β', + beth: 'ℶ', + between: '≬', + bfr: '𝔟', + bigcap: '⋂', + bigcirc: '◯', + bigcup: '⋃', + bigodot: '⨀', + bigoplus: '⨁', + bigotimes: '⨂', + bigsqcup: '⨆', + bigstar: '★', + bigtriangledown: '▽', + bigtriangleup: '△', + biguplus: '⨄', + bigvee: '⋁', + bigwedge: '⋀', + bkarow: '⤍', + blacklozenge: '⧫', + blacksquare: '▪', + blacktriangle: '▴', + blacktriangledown: '▾', + blacktriangleleft: '◂', + blacktriangleright: '▸', + blank: '␣', + blk12: '▒', + blk14: '░', + blk34: '▓', + block: '█', + bne: '=⃥', + bnequiv: '≡⃥', + bnot: '⌐', + bopf: '𝕓', + bot: '⊥', + bottom: '⊥', + bowtie: '⋈', + boxDL: '╗', + boxDR: '╔', + boxDl: '╖', + boxDr: '╓', + boxH: '═', + boxHD: '╦', + boxHU: '╩', + boxHd: '╤', + boxHu: '╧', + boxUL: '╝', + boxUR: '╚', + boxUl: '╜', + boxUr: '╙', + boxV: '║', + boxVH: '╬', + boxVL: '╣', + boxVR: '╠', + boxVh: '╫', + boxVl: '╢', + boxVr: '╟', + boxbox: '⧉', + boxdL: '╕', + boxdR: '╒', + boxdl: '┐', + boxdr: '┌', + boxh: '─', + boxhD: '╥', + boxhU: '╨', + boxhd: '┬', + boxhu: '┴', + boxminus: '⊟', + boxplus: '⊞', + boxtimes: '⊠', + boxuL: '╛', + boxuR: '╘', + boxul: '┘', + boxur: '└', + boxv: '│', + boxvH: '╪', + boxvL: '╡', + boxvR: '╞', + boxvh: '┼', + boxvl: '┤', + boxvr: '├', + bprime: '‵', + breve: '˘', + brvbar: '¦', + bscr: '𝒷', + bsemi: '⁏', + bsim: '∽', + bsime: '⋍', + bsol: '\\', + bsolb: '⧅', + bsolhsub: '⟈', + bull: '•', + bullet: '•', + bump: '≎', + bumpE: '⪮', + bumpe: '≏', + bumpeq: '≏', + cacute: 'ć', + cap: '∩', + capand: '⩄', + capbrcup: '⩉', + capcap: '⩋', + capcup: '⩇', + capdot: '⩀', + caps: '∩︀', + caret: '⁁', + caron: 'ˇ', + ccaps: '⩍', + ccaron: 'č', + ccedil: 'ç', + ccirc: 'ĉ', + ccups: '⩌', + ccupssm: '⩐', + cdot: 'ċ', + cedil: '¸', + cemptyv: '⦲', + cent: '¢', + centerdot: '·', + cfr: '𝔠', + chcy: 'ч', + check: '✓', + checkmark: '✓', + chi: 'χ', + cir: '○', + cirE: '⧃', + circ: 'ˆ', + circeq: '≗', + circlearrowleft: '↺', + circlearrowright: '↻', + circledR: '®', + circledS: 'Ⓢ', + circledast: '⊛', + circledcirc: '⊚', + circleddash: '⊝', + cire: '≗', + cirfnint: '⨐', + cirmid: '⫯', + cirscir: '⧂', + clubs: '♣', + clubsuit: '♣', + colon: ':', + colone: '≔', + coloneq: '≔', + comma: ',', + commat: '@', + comp: '∁', + compfn: '∘', + complement: '∁', + complexes: 'ℂ', + cong: '≅', + congdot: '⩭', + conint: '∮', + copf: '𝕔', + coprod: '∐', + copy: '©', + copysr: '℗', + crarr: '↵', + cross: '✗', + cscr: '𝒸', + csub: '⫏', + csube: '⫑', + csup: '⫐', + csupe: '⫒', + ctdot: '⋯', + cudarrl: '⤸', + cudarrr: '⤵', + cuepr: '⋞', + cuesc: '⋟', + cularr: '↶', + cularrp: '⤽', + cup: '∪', + cupbrcap: '⩈', + cupcap: '⩆', + cupcup: '⩊', + cupdot: '⊍', + cupor: '⩅', + cups: '∪︀', + curarr: '↷', + curarrm: '⤼', + curlyeqprec: '⋞', + curlyeqsucc: '⋟', + curlyvee: '⋎', + curlywedge: '⋏', + curren: '¤', + curvearrowleft: '↶', + curvearrowright: '↷', + cuvee: '⋎', + cuwed: '⋏', + cwconint: '∲', + cwint: '∱', + cylcty: '⌭', + dArr: '⇓', + dHar: '⥥', + dagger: '†', + daleth: 'ℸ', + darr: '↓', + dash: '‐', + dashv: '⊣', + dbkarow: '⤏', + dblac: '˝', + dcaron: 'ď', + dcy: 'д', + dd: 'ⅆ', + ddagger: '‡', + ddarr: '⇊', + ddotseq: '⩷', + deg: '°', + delta: 'δ', + demptyv: '⦱', + dfisht: '⥿', + dfr: '𝔡', + dharl: '⇃', + dharr: '⇂', + diam: '⋄', + diamond: '⋄', + diamondsuit: '♦', + diams: '♦', + die: '¨', + digamma: 'ϝ', + disin: '⋲', + div: '÷', + divide: '÷', + divideontimes: '⋇', + divonx: '⋇', + djcy: 'ђ', + dlcorn: '⌞', + dlcrop: '⌍', + dollar: '$', + dopf: '𝕕', + dot: '˙', + doteq: '≐', + doteqdot: '≑', + dotminus: '∸', + dotplus: '∔', + dotsquare: '⊡', + doublebarwedge: '⌆', + downarrow: '↓', + downdownarrows: '⇊', + downharpoonleft: '⇃', + downharpoonright: '⇂', + drbkarow: '⤐', + drcorn: '⌟', + drcrop: '⌌', + dscr: '𝒹', + dscy: 'ѕ', + dsol: '⧶', + dstrok: 'đ', + dtdot: '⋱', + dtri: '▿', + dtrif: '▾', + duarr: '⇵', + duhar: '⥯', + dwangle: '⦦', + dzcy: 'џ', + dzigrarr: '⟿', + eDDot: '⩷', + eDot: '≑', + eacute: 'é', + easter: '⩮', + ecaron: 'ě', + ecir: '≖', + ecirc: 'ê', + ecolon: '≕', + ecy: 'э', + edot: 'ė', + ee: 'ⅇ', + efDot: '≒', + efr: '𝔢', + eg: '⪚', + egrave: 'è', + egs: '⪖', + egsdot: '⪘', + el: '⪙', + elinters: '⏧', + ell: 'ℓ', + els: '⪕', + elsdot: '⪗', + emacr: 'ē', + empty: '∅', + emptyset: '∅', + emptyv: '∅', + emsp13: ' ', + emsp14: ' ', + emsp: ' ', + eng: 'ŋ', + ensp: ' ', + eogon: 'ę', + eopf: '𝕖', + epar: '⋕', + eparsl: '⧣', + eplus: '⩱', + epsi: 'ε', + epsilon: 'ε', + epsiv: 'ϵ', + eqcirc: '≖', + eqcolon: '≕', + eqsim: '≂', + eqslantgtr: '⪖', + eqslantless: '⪕', + equals: '=', + equest: '≟', + equiv: '≡', + equivDD: '⩸', + eqvparsl: '⧥', + erDot: '≓', + erarr: '⥱', + escr: 'ℯ', + esdot: '≐', + esim: '≂', + eta: 'η', + eth: 'ð', + euml: 'ë', + euro: '€', + excl: '!', + exist: '∃', + expectation: 'ℰ', + exponentiale: 'ⅇ', + fallingdotseq: '≒', + fcy: 'ф', + female: '♀', + ffilig: 'ffi', + fflig: 'ff', + ffllig: 'ffl', + ffr: '𝔣', + filig: 'fi', + fjlig: 'fj', + flat: '♭', + fllig: 'fl', + fltns: '▱', + fnof: 'ƒ', + fopf: '𝕗', + forall: '∀', + fork: '⋔', + forkv: '⫙', + fpartint: '⨍', + frac12: '½', + frac13: '⅓', + frac14: '¼', + frac15: '⅕', + frac16: '⅙', + frac18: '⅛', + frac23: '⅔', + frac25: '⅖', + frac34: '¾', + frac35: '⅗', + frac38: '⅜', + frac45: '⅘', + frac56: '⅚', + frac58: '⅝', + frac78: '⅞', + frasl: '⁄', + frown: '⌢', + fscr: '𝒻', + gE: '≧', + gEl: '⪌', + gacute: 'ǵ', + gamma: 'γ', + gammad: 'ϝ', + gap: '⪆', + gbreve: 'ğ', + gcirc: 'ĝ', + gcy: 'г', + gdot: 'ġ', + ge: '≥', + gel: '⋛', + geq: '≥', + geqq: '≧', + geqslant: '⩾', + ges: '⩾', + gescc: '⪩', + gesdot: '⪀', + gesdoto: '⪂', + gesdotol: '⪄', + gesl: '⋛︀', + gesles: '⪔', + gfr: '𝔤', + gg: '≫', + ggg: '⋙', + gimel: 'ℷ', + gjcy: 'ѓ', + gl: '≷', + glE: '⪒', + gla: '⪥', + glj: '⪤', + gnE: '≩', + gnap: '⪊', + gnapprox: '⪊', + gne: '⪈', + gneq: '⪈', + gneqq: '≩', + gnsim: '⋧', + gopf: '𝕘', + grave: '`', + gscr: 'ℊ', + gsim: '≳', + gsime: '⪎', + gsiml: '⪐', + gt: '>', + gtcc: '⪧', + gtcir: '⩺', + gtdot: '⋗', + gtlPar: '⦕', + gtquest: '⩼', + gtrapprox: '⪆', + gtrarr: '⥸', + gtrdot: '⋗', + gtreqless: '⋛', + gtreqqless: '⪌', + gtrless: '≷', + gtrsim: '≳', + gvertneqq: '≩︀', + gvnE: '≩︀', + hArr: '⇔', + hairsp: ' ', + half: '½', + hamilt: 'ℋ', + hardcy: 'ъ', + harr: '↔', + harrcir: '⥈', + harrw: '↭', + hbar: 'ℏ', + hcirc: 'ĥ', + hearts: '♥', + heartsuit: '♥', + hellip: '…', + hercon: '⊹', + hfr: '𝔥', + hksearow: '⤥', + hkswarow: '⤦', + hoarr: '⇿', + homtht: '∻', + hookleftarrow: '↩', + hookrightarrow: '↪', + hopf: '𝕙', + horbar: '―', + hscr: '𝒽', + hslash: 'ℏ', + hstrok: 'ħ', + hybull: '⁃', + hyphen: '‐', + iacute: 'í', + ic: '⁣', + icirc: 'î', + icy: 'и', + iecy: 'е', + iexcl: '¡', + iff: '⇔', + ifr: '𝔦', + igrave: 'ì', + ii: 'ⅈ', + iiiint: '⨌', + iiint: '∭', + iinfin: '⧜', + iiota: '℩', + ijlig: 'ij', + imacr: 'ī', + image: 'ℑ', + imagline: 'ℐ', + imagpart: 'ℑ', + imath: 'ı', + imof: '⊷', + imped: 'Ƶ', + in: '∈', + incare: '℅', + infin: '∞', + infintie: '⧝', + inodot: 'ı', + int: '∫', + intcal: '⊺', + integers: 'ℤ', + intercal: '⊺', + intlarhk: '⨗', + intprod: '⨼', + iocy: 'ё', + iogon: 'į', + iopf: '𝕚', + iota: 'ι', + iprod: '⨼', + iquest: '¿', + iscr: '𝒾', + isin: '∈', + isinE: '⋹', + isindot: '⋵', + isins: '⋴', + isinsv: '⋳', + isinv: '∈', + it: '⁢', + itilde: 'ĩ', + iukcy: 'і', + iuml: 'ï', + jcirc: 'ĵ', + jcy: 'й', + jfr: '𝔧', + jmath: 'ȷ', + jopf: '𝕛', + jscr: '𝒿', + jsercy: 'ј', + jukcy: 'є', + kappa: 'κ', + kappav: 'ϰ', + kcedil: 'ķ', + kcy: 'к', + kfr: '𝔨', + kgreen: 'ĸ', + khcy: 'х', + kjcy: 'ќ', + kopf: '𝕜', + kscr: '𝓀', + lAarr: '⇚', + lArr: '⇐', + lAtail: '⤛', + lBarr: '⤎', + lE: '≦', + lEg: '⪋', + lHar: '⥢', + lacute: 'ĺ', + laemptyv: '⦴', + lagran: 'ℒ', + lambda: 'λ', + lang: '⟨', + langd: '⦑', + langle: '⟨', + lap: '⪅', + laquo: '«', + larr: '←', + larrb: '⇤', + larrbfs: '⤟', + larrfs: '⤝', + larrhk: '↩', + larrlp: '↫', + larrpl: '⤹', + larrsim: '⥳', + larrtl: '↢', + lat: '⪫', + latail: '⤙', + late: '⪭', + lates: '⪭︀', + lbarr: '⤌', + lbbrk: '❲', + lbrace: '{', + lbrack: '[', + lbrke: '⦋', + lbrksld: '⦏', + lbrkslu: '⦍', + lcaron: 'ľ', + lcedil: 'ļ', + lceil: '⌈', + lcub: '{', + lcy: 'л', + ldca: '⤶', + ldquo: '“', + ldquor: '„', + ldrdhar: '⥧', + ldrushar: '⥋', + ldsh: '↲', + le: '≤', + leftarrow: '←', + leftarrowtail: '↢', + leftharpoondown: '↽', + leftharpoonup: '↼', + leftleftarrows: '⇇', + leftrightarrow: '↔', + leftrightarrows: '⇆', + leftrightharpoons: '⇋', + leftrightsquigarrow: '↭', + leftthreetimes: '⋋', + leg: '⋚', + leq: '≤', + leqq: '≦', + leqslant: '⩽', + les: '⩽', + lescc: '⪨', + lesdot: '⩿', + lesdoto: '⪁', + lesdotor: '⪃', + lesg: '⋚︀', + lesges: '⪓', + lessapprox: '⪅', + lessdot: '⋖', + lesseqgtr: '⋚', + lesseqqgtr: '⪋', + lessgtr: '≶', + lesssim: '≲', + lfisht: '⥼', + lfloor: '⌊', + lfr: '𝔩', + lg: '≶', + lgE: '⪑', + lhard: '↽', + lharu: '↼', + lharul: '⥪', + lhblk: '▄', + ljcy: 'љ', + ll: '≪', + llarr: '⇇', + llcorner: '⌞', + llhard: '⥫', + lltri: '◺', + lmidot: 'ŀ', + lmoust: '⎰', + lmoustache: '⎰', + lnE: '≨', + lnap: '⪉', + lnapprox: '⪉', + lne: '⪇', + lneq: '⪇', + lneqq: '≨', + lnsim: '⋦', + loang: '⟬', + loarr: '⇽', + lobrk: '⟦', + longleftarrow: '⟵', + longleftrightarrow: '⟷', + longmapsto: '⟼', + longrightarrow: '⟶', + looparrowleft: '↫', + looparrowright: '↬', + lopar: '⦅', + lopf: '𝕝', + loplus: '⨭', + lotimes: '⨴', + lowast: '∗', + lowbar: '_', + loz: '◊', + lozenge: '◊', + lozf: '⧫', + lpar: '(', + lparlt: '⦓', + lrarr: '⇆', + lrcorner: '⌟', + lrhar: '⇋', + lrhard: '⥭', + lrm: '‎', + lrtri: '⊿', + lsaquo: '‹', + lscr: '𝓁', + lsh: '↰', + lsim: '≲', + lsime: '⪍', + lsimg: '⪏', + lsqb: '[', + lsquo: '‘', + lsquor: '‚', + lstrok: 'ł', + lt: '<', + ltcc: '⪦', + ltcir: '⩹', + ltdot: '⋖', + lthree: '⋋', + ltimes: '⋉', + ltlarr: '⥶', + ltquest: '⩻', + ltrPar: '⦖', + ltri: '◃', + ltrie: '⊴', + ltrif: '◂', + lurdshar: '⥊', + luruhar: '⥦', + lvertneqq: '≨︀', + lvnE: '≨︀', + mDDot: '∺', + macr: '¯', + male: '♂', + malt: '✠', + maltese: '✠', + map: '↦', + mapsto: '↦', + mapstodown: '↧', + mapstoleft: '↤', + mapstoup: '↥', + marker: '▮', + mcomma: '⨩', + mcy: 'м', + mdash: '—', + measuredangle: '∡', + mfr: '𝔪', + mho: '℧', + micro: 'µ', + mid: '∣', + midast: '*', + midcir: '⫰', + middot: '·', + minus: '−', + minusb: '⊟', + minusd: '∸', + minusdu: '⨪', + mlcp: '⫛', + mldr: '…', + mnplus: '∓', + models: '⊧', + mopf: '𝕞', + mp: '∓', + mscr: '𝓂', + mstpos: '∾', + mu: 'μ', + multimap: '⊸', + mumap: '⊸', + nGg: '⋙̸', + nGt: '≫⃒', + nGtv: '≫̸', + nLeftarrow: '⇍', + nLeftrightarrow: '⇎', + nLl: '⋘̸', + nLt: '≪⃒', + nLtv: '≪̸', + nRightarrow: '⇏', + nVDash: '⊯', + nVdash: '⊮', + nabla: '∇', + nacute: 'ń', + nang: '∠⃒', + nap: '≉', + napE: '⩰̸', + napid: '≋̸', + napos: 'ʼn', + napprox: '≉', + natur: '♮', + natural: '♮', + naturals: 'ℕ', + nbsp: ' ', + nbump: '≎̸', + nbumpe: '≏̸', + ncap: '⩃', + ncaron: 'ň', + ncedil: 'ņ', + ncong: '≇', + ncongdot: '⩭̸', + ncup: '⩂', + ncy: 'н', + ndash: '–', + ne: '≠', + neArr: '⇗', + nearhk: '⤤', + nearr: '↗', + nearrow: '↗', + nedot: '≐̸', + nequiv: '≢', + nesear: '⤨', + nesim: '≂̸', + nexist: '∄', + nexists: '∄', + nfr: '𝔫', + ngE: '≧̸', + nge: '≱', + ngeq: '≱', + ngeqq: '≧̸', + ngeqslant: '⩾̸', + nges: '⩾̸', + ngsim: '≵', + ngt: '≯', + ngtr: '≯', + nhArr: '⇎', + nharr: '↮', + nhpar: '⫲', + ni: '∋', + nis: '⋼', + nisd: '⋺', + niv: '∋', + njcy: 'њ', + nlArr: '⇍', + nlE: '≦̸', + nlarr: '↚', + nldr: '‥', + nle: '≰', + nleftarrow: '↚', + nleftrightarrow: '↮', + nleq: '≰', + nleqq: '≦̸', + nleqslant: '⩽̸', + nles: '⩽̸', + nless: '≮', + nlsim: '≴', + nlt: '≮', + nltri: '⋪', + nltrie: '⋬', + nmid: '∤', + nopf: '𝕟', + not: '¬', + notin: '∉', + notinE: '⋹̸', + notindot: '⋵̸', + notinva: '∉', + notinvb: '⋷', + notinvc: '⋶', + notni: '∌', + notniva: '∌', + notnivb: '⋾', + notnivc: '⋽', + npar: '∦', + nparallel: '∦', + nparsl: '⫽⃥', + npart: '∂̸', + npolint: '⨔', + npr: '⊀', + nprcue: '⋠', + npre: '⪯̸', + nprec: '⊀', + npreceq: '⪯̸', + nrArr: '⇏', + nrarr: '↛', + nrarrc: '⤳̸', + nrarrw: '↝̸', + nrightarrow: '↛', + nrtri: '⋫', + nrtrie: '⋭', + nsc: '⊁', + nsccue: '⋡', + nsce: '⪰̸', + nscr: '𝓃', + nshortmid: '∤', + nshortparallel: '∦', + nsim: '≁', + nsime: '≄', + nsimeq: '≄', + nsmid: '∤', + nspar: '∦', + nsqsube: '⋢', + nsqsupe: '⋣', + nsub: '⊄', + nsubE: '⫅̸', + nsube: '⊈', + nsubset: '⊂⃒', + nsubseteq: '⊈', + nsubseteqq: '⫅̸', + nsucc: '⊁', + nsucceq: '⪰̸', + nsup: '⊅', + nsupE: '⫆̸', + nsupe: '⊉', + nsupset: '⊃⃒', + nsupseteq: '⊉', + nsupseteqq: '⫆̸', + ntgl: '≹', + ntilde: 'ñ', + ntlg: '≸', + ntriangleleft: '⋪', + ntrianglelefteq: '⋬', + ntriangleright: '⋫', + ntrianglerighteq: '⋭', + nu: 'ν', + num: '#', + numero: '№', + numsp: ' ', + nvDash: '⊭', + nvHarr: '⤄', + nvap: '≍⃒', + nvdash: '⊬', + nvge: '≥⃒', + nvgt: '>⃒', + nvinfin: '⧞', + nvlArr: '⤂', + nvle: '≤⃒', + nvlt: '<⃒', + nvltrie: '⊴⃒', + nvrArr: '⤃', + nvrtrie: '⊵⃒', + nvsim: '∼⃒', + nwArr: '⇖', + nwarhk: '⤣', + nwarr: '↖', + nwarrow: '↖', + nwnear: '⤧', + oS: 'Ⓢ', + oacute: 'ó', + oast: '⊛', + ocir: '⊚', + ocirc: 'ô', + ocy: 'о', + odash: '⊝', + odblac: 'ő', + odiv: '⨸', + odot: '⊙', + odsold: '⦼', + oelig: 'œ', + ofcir: '⦿', + ofr: '𝔬', + ogon: '˛', + ograve: 'ò', + ogt: '⧁', + ohbar: '⦵', + ohm: 'Ω', + oint: '∮', + olarr: '↺', + olcir: '⦾', + olcross: '⦻', + oline: '‾', + olt: '⧀', + omacr: 'ō', + omega: 'ω', + omicron: 'ο', + omid: '⦶', + ominus: '⊖', + oopf: '𝕠', + opar: '⦷', + operp: '⦹', + oplus: '⊕', + or: '∨', + orarr: '↻', + ord: '⩝', + order: 'ℴ', + orderof: 'ℴ', + ordf: 'ª', + ordm: 'º', + origof: '⊶', + oror: '⩖', + orslope: '⩗', + orv: '⩛', + oscr: 'ℴ', + oslash: 'ø', + osol: '⊘', + otilde: 'õ', + otimes: '⊗', + otimesas: '⨶', + ouml: 'ö', + ovbar: '⌽', + par: '∥', + para: '¶', + parallel: '∥', + parsim: '⫳', + parsl: '⫽', + part: '∂', + pcy: 'п', + percnt: '%', + period: '.', + permil: '‰', + perp: '⊥', + pertenk: '‱', + pfr: '𝔭', + phi: 'φ', + phiv: 'ϕ', + phmmat: 'ℳ', + phone: '☎', + pi: 'π', + pitchfork: '⋔', + piv: 'ϖ', + planck: 'ℏ', + planckh: 'ℎ', + plankv: 'ℏ', + plus: '+', + plusacir: '⨣', + plusb: '⊞', + pluscir: '⨢', + plusdo: '∔', + plusdu: '⨥', + pluse: '⩲', + plusmn: '±', + plussim: '⨦', + plustwo: '⨧', + pm: '±', + pointint: '⨕', + popf: '𝕡', + pound: '£', + pr: '≺', + prE: '⪳', + prap: '⪷', + prcue: '≼', + pre: '⪯', + prec: '≺', + precapprox: '⪷', + preccurlyeq: '≼', + preceq: '⪯', + precnapprox: '⪹', + precneqq: '⪵', + precnsim: '⋨', + precsim: '≾', + prime: '′', + primes: 'ℙ', + prnE: '⪵', + prnap: '⪹', + prnsim: '⋨', + prod: '∏', + profalar: '⌮', + profline: '⌒', + profsurf: '⌓', + prop: '∝', + propto: '∝', + prsim: '≾', + prurel: '⊰', + pscr: '𝓅', + psi: 'ψ', + puncsp: ' ', + qfr: '𝔮', + qint: '⨌', + qopf: '𝕢', + qprime: '⁗', + qscr: '𝓆', + quaternions: 'ℍ', + quatint: '⨖', + quest: '?', + questeq: '≟', + quot: '"', + rAarr: '⇛', + rArr: '⇒', + rAtail: '⤜', + rBarr: '⤏', + rHar: '⥤', + race: '∽̱', + racute: 'ŕ', + radic: '√', + raemptyv: '⦳', + rang: '⟩', + rangd: '⦒', + range: '⦥', + rangle: '⟩', + raquo: '»', + rarr: '→', + rarrap: '⥵', + rarrb: '⇥', + rarrbfs: '⤠', + rarrc: '⤳', + rarrfs: '⤞', + rarrhk: '↪', + rarrlp: '↬', + rarrpl: '⥅', + rarrsim: '⥴', + rarrtl: '↣', + rarrw: '↝', + ratail: '⤚', + ratio: '∶', + rationals: 'ℚ', + rbarr: '⤍', + rbbrk: '❳', + rbrace: '}', + rbrack: ']', + rbrke: '⦌', + rbrksld: '⦎', + rbrkslu: '⦐', + rcaron: 'ř', + rcedil: 'ŗ', + rceil: '⌉', + rcub: '}', + rcy: 'р', + rdca: '⤷', + rdldhar: '⥩', + rdquo: '”', + rdquor: '”', + rdsh: '↳', + real: 'ℜ', + realine: 'ℛ', + realpart: 'ℜ', + reals: 'ℝ', + rect: '▭', + reg: '®', + rfisht: '⥽', + rfloor: '⌋', + rfr: '𝔯', + rhard: '⇁', + rharu: '⇀', + rharul: '⥬', + rho: 'ρ', + rhov: 'ϱ', + rightarrow: '→', + rightarrowtail: '↣', + rightharpoondown: '⇁', + rightharpoonup: '⇀', + rightleftarrows: '⇄', + rightleftharpoons: '⇌', + rightrightarrows: '⇉', + rightsquigarrow: '↝', + rightthreetimes: '⋌', + ring: '˚', + risingdotseq: '≓', + rlarr: '⇄', + rlhar: '⇌', + rlm: '‏', + rmoust: '⎱', + rmoustache: '⎱', + rnmid: '⫮', + roang: '⟭', + roarr: '⇾', + robrk: '⟧', + ropar: '⦆', + ropf: '𝕣', + roplus: '⨮', + rotimes: '⨵', + rpar: ')', + rpargt: '⦔', + rppolint: '⨒', + rrarr: '⇉', + rsaquo: '›', + rscr: '𝓇', + rsh: '↱', + rsqb: ']', + rsquo: '’', + rsquor: '’', + rthree: '⋌', + rtimes: '⋊', + rtri: '▹', + rtrie: '⊵', + rtrif: '▸', + rtriltri: '⧎', + ruluhar: '⥨', + rx: '℞', + sacute: 'ś', + sbquo: '‚', + sc: '≻', + scE: '⪴', + scap: '⪸', + scaron: 'š', + sccue: '≽', + sce: '⪰', + scedil: 'ş', + scirc: 'ŝ', + scnE: '⪶', + scnap: '⪺', + scnsim: '⋩', + scpolint: '⨓', + scsim: '≿', + scy: 'с', + sdot: '⋅', + sdotb: '⊡', + sdote: '⩦', + seArr: '⇘', + searhk: '⤥', + searr: '↘', + searrow: '↘', + sect: '§', + semi: ';', + seswar: '⤩', + setminus: '∖', + setmn: '∖', + sext: '✶', + sfr: '𝔰', + sfrown: '⌢', + sharp: '♯', + shchcy: 'щ', + shcy: 'ш', + shortmid: '∣', + shortparallel: '∥', + shy: '­', + sigma: 'σ', + sigmaf: 'ς', + sigmav: 'ς', + sim: '∼', + simdot: '⩪', + sime: '≃', + simeq: '≃', + simg: '⪞', + simgE: '⪠', + siml: '⪝', + simlE: '⪟', + simne: '≆', + simplus: '⨤', + simrarr: '⥲', + slarr: '←', + smallsetminus: '∖', + smashp: '⨳', + smeparsl: '⧤', + smid: '∣', + smile: '⌣', + smt: '⪪', + smte: '⪬', + smtes: '⪬︀', + softcy: 'ь', + sol: '/', + solb: '⧄', + solbar: '⌿', + sopf: '𝕤', + spades: '♠', + spadesuit: '♠', + spar: '∥', + sqcap: '⊓', + sqcaps: '⊓︀', + sqcup: '⊔', + sqcups: '⊔︀', + sqsub: '⊏', + sqsube: '⊑', + sqsubset: '⊏', + sqsubseteq: '⊑', + sqsup: '⊐', + sqsupe: '⊒', + sqsupset: '⊐', + sqsupseteq: '⊒', + squ: '□', + square: '□', + squarf: '▪', + squf: '▪', + srarr: '→', + sscr: '𝓈', + ssetmn: '∖', + ssmile: '⌣', + sstarf: '⋆', + star: '☆', + starf: '★', + straightepsilon: 'ϵ', + straightphi: 'ϕ', + strns: '¯', + sub: '⊂', + subE: '⫅', + subdot: '⪽', + sube: '⊆', + subedot: '⫃', + submult: '⫁', + subnE: '⫋', + subne: '⊊', + subplus: '⪿', + subrarr: '⥹', + subset: '⊂', + subseteq: '⊆', + subseteqq: '⫅', + subsetneq: '⊊', + subsetneqq: '⫋', + subsim: '⫇', + subsub: '⫕', + subsup: '⫓', + succ: '≻', + succapprox: '⪸', + succcurlyeq: '≽', + succeq: '⪰', + succnapprox: '⪺', + succneqq: '⪶', + succnsim: '⋩', + succsim: '≿', + sum: '∑', + sung: '♪', + sup1: '¹', + sup2: '²', + sup3: '³', + sup: '⊃', + supE: '⫆', + supdot: '⪾', + supdsub: '⫘', + supe: '⊇', + supedot: '⫄', + suphsol: '⟉', + suphsub: '⫗', + suplarr: '⥻', + supmult: '⫂', + supnE: '⫌', + supne: '⊋', + supplus: '⫀', + supset: '⊃', + supseteq: '⊇', + supseteqq: '⫆', + supsetneq: '⊋', + supsetneqq: '⫌', + supsim: '⫈', + supsub: '⫔', + supsup: '⫖', + swArr: '⇙', + swarhk: '⤦', + swarr: '↙', + swarrow: '↙', + swnwar: '⤪', + szlig: 'ß', + target: '⌖', + tau: 'τ', + tbrk: '⎴', + tcaron: 'ť', + tcedil: 'ţ', + tcy: 'т', + tdot: '⃛', + telrec: '⌕', + tfr: '𝔱', + there4: '∴', + therefore: '∴', + theta: 'θ', + thetasym: 'ϑ', + thetav: 'ϑ', + thickapprox: '≈', + thicksim: '∼', + thinsp: ' ', + thkap: '≈', + thksim: '∼', + thorn: 'þ', + tilde: '˜', + times: '×', + timesb: '⊠', + timesbar: '⨱', + timesd: '⨰', + tint: '∭', + toea: '⤨', + top: '⊤', + topbot: '⌶', + topcir: '⫱', + topf: '𝕥', + topfork: '⫚', + tosa: '⤩', + tprime: '‴', + trade: '™', + triangle: '▵', + triangledown: '▿', + triangleleft: '◃', + trianglelefteq: '⊴', + triangleq: '≜', + triangleright: '▹', + trianglerighteq: '⊵', + tridot: '◬', + trie: '≜', + triminus: '⨺', + triplus: '⨹', + trisb: '⧍', + tritime: '⨻', + trpezium: '⏢', + tscr: '𝓉', + tscy: 'ц', + tshcy: 'ћ', + tstrok: 'ŧ', + twixt: '≬', + twoheadleftarrow: '↞', + twoheadrightarrow: '↠', + uArr: '⇑', + uHar: '⥣', + uacute: 'ú', + uarr: '↑', + ubrcy: 'ў', + ubreve: 'ŭ', + ucirc: 'û', + ucy: 'у', + udarr: '⇅', + udblac: 'ű', + udhar: '⥮', + ufisht: '⥾', + ufr: '𝔲', + ugrave: 'ù', + uharl: '↿', + uharr: '↾', + uhblk: '▀', + ulcorn: '⌜', + ulcorner: '⌜', + ulcrop: '⌏', + ultri: '◸', + umacr: 'ū', + uml: '¨', + uogon: 'ų', + uopf: '𝕦', + uparrow: '↑', + updownarrow: '↕', + upharpoonleft: '↿', + upharpoonright: '↾', + uplus: '⊎', + upsi: 'υ', + upsih: 'ϒ', + upsilon: 'υ', + upuparrows: '⇈', + urcorn: '⌝', + urcorner: '⌝', + urcrop: '⌎', + uring: 'ů', + urtri: '◹', + uscr: '𝓊', + utdot: '⋰', + utilde: 'ũ', + utri: '▵', + utrif: '▴', + uuarr: '⇈', + uuml: 'ü', + uwangle: '⦧', + vArr: '⇕', + vBar: '⫨', + vBarv: '⫩', + vDash: '⊨', + vangrt: '⦜', + varepsilon: 'ϵ', + varkappa: 'ϰ', + varnothing: '∅', + varphi: 'ϕ', + varpi: 'ϖ', + varpropto: '∝', + varr: '↕', + varrho: 'ϱ', + varsigma: 'ς', + varsubsetneq: '⊊︀', + varsubsetneqq: '⫋︀', + varsupsetneq: '⊋︀', + varsupsetneqq: '⫌︀', + vartheta: 'ϑ', + vartriangleleft: '⊲', + vartriangleright: '⊳', + vcy: 'в', + vdash: '⊢', + vee: '∨', + veebar: '⊻', + veeeq: '≚', + vellip: '⋮', + verbar: '|', + vert: '|', + vfr: '𝔳', + vltri: '⊲', + vnsub: '⊂⃒', + vnsup: '⊃⃒', + vopf: '𝕧', + vprop: '∝', + vrtri: '⊳', + vscr: '𝓋', + vsubnE: '⫋︀', + vsubne: '⊊︀', + vsupnE: '⫌︀', + vsupne: '⊋︀', + vzigzag: '⦚', + wcirc: 'ŵ', + wedbar: '⩟', + wedge: '∧', + wedgeq: '≙', + weierp: '℘', + wfr: '𝔴', + wopf: '𝕨', + wp: '℘', + wr: '≀', + wreath: '≀', + wscr: '𝓌', + xcap: '⋂', + xcirc: '◯', + xcup: '⋃', + xdtri: '▽', + xfr: '𝔵', + xhArr: '⟺', + xharr: '⟷', + xi: 'ξ', + xlArr: '⟸', + xlarr: '⟵', + xmap: '⟼', + xnis: '⋻', + xodot: '⨀', + xopf: '𝕩', + xoplus: '⨁', + xotime: '⨂', + xrArr: '⟹', + xrarr: '⟶', + xscr: '𝓍', + xsqcup: '⨆', + xuplus: '⨄', + xutri: '△', + xvee: '⋁', + xwedge: '⋀', + yacute: 'ý', + yacy: 'я', + ycirc: 'ŷ', + ycy: 'ы', + yen: '¥', + yfr: '𝔶', + yicy: 'ї', + yopf: '𝕪', + yscr: '𝓎', + yucy: 'ю', + yuml: 'ÿ', + zacute: 'ź', + zcaron: 'ž', + zcy: 'з', + zdot: 'ż', + zeetrf: 'ℨ', + zeta: 'ζ', + zfr: '𝔷', + zhcy: 'ж', + zigrarr: '⇝', + zopf: '𝕫', + zscr: '𝓏', + zwj: '‍', + zwnj: '‌' +}; + +const own$1 = {}.hasOwnProperty; + +/** + * Decode a single character reference (without the `&` or `;`). + * You probably only need this when you’re building parsers yourself that follow + * different rules compared to HTML. + * This is optimized to be tiny in browsers. + * + * @param {string} value + * `notin` (named), `#123` (deci), `#x123` (hexa). + * @returns {string|false} + * Decoded reference. + */ +function decodeNamedCharacterReference(value) { + return own$1.call(characterEntities, value) ? characterEntities[value] : false +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const characterReference = { + name: 'characterReference', + tokenize: tokenizeCharacterReference +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCharacterReference(effects, ok, nok) { + const self = this; + let size = 0; + /** @type {number} */ + let max; + /** @type {(code: Code) => boolean} */ + let test; + return start + + /** + * Start of character reference. + * + * ```markdown + * > | a&b + * ^ + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('characterReference'); + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + return open + } + + /** + * After `&`, at `#` for numeric references or alphanumeric for named + * references. + * + * ```markdown + * > | a&b + * ^ + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 35) { + effects.enter('characterReferenceMarkerNumeric'); + effects.consume(code); + effects.exit('characterReferenceMarkerNumeric'); + return numeric + } + effects.enter('characterReferenceValue'); + max = 31; + test = asciiAlphanumeric; + return value(code) + } + + /** + * After `#`, at `x` for hexadecimals or digit for decimals. + * + * ```markdown + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function numeric(code) { + if (code === 88 || code === 120) { + effects.enter('characterReferenceMarkerHexadecimal'); + effects.consume(code); + effects.exit('characterReferenceMarkerHexadecimal'); + effects.enter('characterReferenceValue'); + max = 6; + test = asciiHexDigit; + return value + } + effects.enter('characterReferenceValue'); + max = 7; + test = asciiDigit; + return value(code) + } + + /** + * After markers (`&#x`, `&#`, or `&`), in value, before `;`. + * + * The character reference kind defines what and how many characters are + * allowed. + * + * ```markdown + * > | a&b + * ^^^ + * > | a{b + * ^^^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function value(code) { + if (code === 59 && size) { + const token = effects.exit('characterReferenceValue'); + if ( + test === asciiAlphanumeric && + !decodeNamedCharacterReference(self.sliceSerialize(token)) + ) { + return nok(code) + } + + // To do: `markdown-rs` uses a different name: + // `CharacterReferenceMarkerSemi`. + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + effects.exit('characterReference'); + return ok + } + if (test(code) && size++ < max) { + effects.consume(code); + return value + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const nonLazyContinuation = { + tokenize: tokenizeNonLazyContinuation, + partial: true +}; + +/** @type {Construct} */ +const codeFenced = { + name: 'codeFenced', + tokenize: tokenizeCodeFenced, + concrete: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeFenced(effects, ok, nok) { + const self = this; + /** @type {Construct} */ + const closeStart = { + tokenize: tokenizeCloseStart, + partial: true + }; + let initialPrefix = 0; + let sizeOpen = 0; + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of code. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse whitespace like `markdown-rs`. + return beforeSequenceOpen(code) + } + + /** + * In opening fence, after prefix, at sequence. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function beforeSequenceOpen(code) { + const tail = self.events[self.events.length - 1]; + initialPrefix = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + marker = code; + effects.enter('codeFenced'); + effects.enter('codeFencedFence'); + effects.enter('codeFencedFenceSequence'); + return sequenceOpen(code) + } + + /** + * In opening fence sequence. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === marker) { + sizeOpen++; + effects.consume(code); + return sequenceOpen + } + if (sizeOpen < 3) { + return nok(code) + } + effects.exit('codeFencedFenceSequence'); + return markdownSpace(code) + ? factorySpace(effects, infoBefore, 'whitespace')(code) + : infoBefore(code) + } + + /** + * In opening fence, after the sequence (and optional whitespace), before info. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function infoBefore(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return self.interrupt + ? ok(code) + : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) + } + effects.enter('codeFencedFenceInfo'); + effects.enter('chunkString', { + contentType: 'string' + }); + return info(code) + } + + /** + * In info. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function info(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return infoBefore(code) + } + if (markdownSpace(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return factorySpace(effects, metaBefore, 'whitespace')(code) + } + if (code === 96 && code === marker) { + return nok(code) + } + effects.consume(code); + return info + } + + /** + * In opening fence, after info and whitespace, before meta. + * + * ```markdown + * > | ~~~js eval + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function metaBefore(code) { + if (code === null || markdownLineEnding(code)) { + return infoBefore(code) + } + effects.enter('codeFencedFenceMeta'); + effects.enter('chunkString', { + contentType: 'string' + }); + return meta(code) + } + + /** + * In meta. + * + * ```markdown + * > | ~~~js eval + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function meta(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceMeta'); + return infoBefore(code) + } + if (code === 96 && code === marker) { + return nok(code) + } + effects.consume(code); + return meta + } + + /** + * At eol/eof in code, before a non-lazy closing fence or content. + * + * ```markdown + * > | ~~~js + * ^ + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function atNonLazyBreak(code) { + return effects.attempt(closeStart, after, contentBefore)(code) + } + + /** + * Before code content, not a closing fence, at eol. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentBefore(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return contentStart + } + + /** + * Before code content, not a closing fence. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentStart(code) { + return initialPrefix > 0 && markdownSpace(code) + ? factorySpace( + effects, + beforeContentChunk, + 'linePrefix', + initialPrefix + 1 + )(code) + : beforeContentChunk(code) + } + + /** + * Before code content, after optional prefix. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function beforeContentChunk(code) { + if (code === null || markdownLineEnding(code)) { + return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) + } + effects.enter('codeFlowValue'); + return contentChunk(code) + } + + /** + * In code content. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^^^^^^^^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentChunk(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return beforeContentChunk(code) + } + effects.consume(code); + return contentChunk + } + + /** + * After code. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + effects.exit('codeFenced'); + return ok(code) + } + + /** + * @this {TokenizeContext} + * @type {Tokenizer} + */ + function tokenizeCloseStart(effects, ok, nok) { + let size = 0; + return startBefore + + /** + * + * + * @type {State} + */ + function startBefore(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return start + } + + /** + * Before closing fence, at optional whitespace. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // Always populated by defaults. + + // To do: `enter` here or in next state? + effects.enter('codeFencedFence'); + return markdownSpace(code) + ? factorySpace( + effects, + beforeSequenceClose, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + : beforeSequenceClose(code) + } + + /** + * In closing fence, after optional whitespace, at sequence. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function beforeSequenceClose(code) { + if (code === marker) { + effects.enter('codeFencedFenceSequence'); + return sequenceClose(code) + } + return nok(code) + } + + /** + * In closing fence sequence. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function sequenceClose(code) { + if (code === marker) { + size++; + effects.consume(code); + return sequenceClose + } + if (size >= sizeOpen) { + effects.exit('codeFencedFenceSequence'); + return markdownSpace(code) + ? factorySpace(effects, sequenceCloseAfter, 'whitespace')(code) + : sequenceCloseAfter(code) + } + return nok(code) + } + + /** + * After closing fence sequence, after optional whitespace. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function sequenceCloseAfter(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return ok(code) + } + return nok(code) + } + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeNonLazyContinuation(effects, ok, nok) { + const self = this; + return start + + /** + * + * + * @type {State} + */ + function start(code) { + if (code === null) { + return nok(code) + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineStart + } + + /** + * + * + * @type {State} + */ + function lineStart(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const codeIndented = { + name: 'codeIndented', + tokenize: tokenizeCodeIndented +}; + +/** @type {Construct} */ +const furtherStart = { + tokenize: tokenizeFurtherStart, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeIndented(effects, ok, nok) { + const self = this; + return start + + /** + * Start of code (indented). + * + * > **Parsing note**: it is not needed to check if this first line is a + * > filled line (that it has a non-whitespace character), because blank lines + * > are parsed already, so we never run into that. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: manually check if interrupting like `markdown-rs`. + + effects.enter('codeIndented'); + // To do: use an improved `space_or_tab` function like `markdown-rs`, + // so that we can drop the next state. + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + + /** + * At start, after 1 or 4 spaces. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? atBreak(code) + : nok(code) + } + + /** + * At a break. + * + * ```markdown + * > | aaa + * ^ ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === null) { + return after(code) + } + if (markdownLineEnding(code)) { + return effects.attempt(furtherStart, atBreak, after)(code) + } + effects.enter('codeFlowValue'); + return inside(code) + } + + /** + * In code content. + * + * ```markdown + * > | aaa + * ^^^^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return atBreak(code) + } + effects.consume(code); + return inside + } + + /** @type {State} */ + function after(code) { + effects.exit('codeIndented'); + // To do: allow interrupting like `markdown-rs`. + // Feel free to interrupt. + // tokenizer.interrupt = false + return ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeFurtherStart(effects, ok, nok) { + const self = this; + return furtherStart + + /** + * At eol, trying to parse another indent. + * + * ```markdown + * > | aaa + * ^ + * | bbb + * ``` + * + * @type {State} + */ + function furtherStart(code) { + // To do: improve `lazy` / `pierce` handling. + // If this is a lazy line, it can’t be code. + if (self.parser.lazy[self.now().line]) { + return nok(code) + } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return furtherStart + } + + // To do: the code here in `micromark-js` is a bit different from + // `markdown-rs` because there it can attempt spaces. + // We can’t yet. + // + // To do: use an improved `space_or_tab` function like `markdown-rs`, + // so that we can drop the next state. + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + + /** + * At start, after 1 or 4 spaces. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? ok(code) + : markdownLineEnding(code) + ? furtherStart(code) + : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Previous} Previous + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const codeText = { + name: 'codeText', + tokenize: tokenizeCodeText, + resolve: resolveCodeText, + previous +}; + +// To do: next major: don’t resolve, like `markdown-rs`. +/** @type {Resolver} */ +function resolveCodeText(events) { + let tailExitIndex = events.length - 4; + let headEnterIndex = 3; + /** @type {number} */ + let index; + /** @type {number | undefined} */ + let enter; + + // If we start and end with an EOL or a space. + if ( + (events[headEnterIndex][1].type === 'lineEnding' || + events[headEnterIndex][1].type === 'space') && + (events[tailExitIndex][1].type === 'lineEnding' || + events[tailExitIndex][1].type === 'space') + ) { + index = headEnterIndex; + + // And we have data. + while (++index < tailExitIndex) { + if (events[index][1].type === 'codeTextData') { + // Then we have padding. + events[headEnterIndex][1].type = 'codeTextPadding'; + events[tailExitIndex][1].type = 'codeTextPadding'; + headEnterIndex += 2; + tailExitIndex -= 2; + break + } + } + } + + // Merge adjacent spaces and data. + index = headEnterIndex - 1; + tailExitIndex++; + while (++index <= tailExitIndex) { + if (enter === undefined) { + if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { + enter = index; + } + } else if ( + index === tailExitIndex || + events[index][1].type === 'lineEnding' + ) { + events[enter][1].type = 'codeTextData'; + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + tailExitIndex -= index - enter - 2; + index = enter + 2; + } + enter = undefined; + } + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Previous} + */ +function previous(code) { + // If there is a previous code, there will always be a tail. + return ( + code !== 96 || + this.events[this.events.length - 1][1].type === 'characterEscape' + ) +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeText(effects, ok, nok) { + let sizeOpen = 0; + /** @type {number} */ + let size; + /** @type {Token} */ + let token; + return start + + /** + * Start of code (text). + * + * ```markdown + * > | `a` + * ^ + * > | \`a` + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('codeText'); + effects.enter('codeTextSequence'); + return sequenceOpen(code) + } + + /** + * In opening sequence. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === 96) { + effects.consume(code); + sizeOpen++; + return sequenceOpen + } + effects.exit('codeTextSequence'); + return between(code) + } + + /** + * Between something and something else. + * + * ```markdown + * > | `a` + * ^^ + * ``` + * + * @type {State} + */ + function between(code) { + // EOF. + if (code === null) { + return nok(code) + } + + // To do: next major: don’t do spaces in resolve, but when compiling, + // like `markdown-rs`. + // Tabs don’t work, and virtual spaces don’t make sense. + if (code === 32) { + effects.enter('space'); + effects.consume(code); + effects.exit('space'); + return between + } + + // Closing fence? Could also be data. + if (code === 96) { + token = effects.enter('codeTextSequence'); + size = 0; + return sequenceClose(code) + } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return between + } + + // Data. + effects.enter('codeTextData'); + return data(code) + } + + /** + * In data. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function data(code) { + if ( + code === null || + code === 32 || + code === 96 || + markdownLineEnding(code) + ) { + effects.exit('codeTextData'); + return between(code) + } + effects.consume(code); + return data + } + + /** + * In closing sequence. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function sequenceClose(code) { + // More. + if (code === 96) { + effects.consume(code); + size++; + return sequenceClose + } + + // Done! + if (size === sizeOpen) { + effects.exit('codeTextSequence'); + effects.exit('codeText'); + return ok(code) + } + + // More or less accents: mark as data. + token.type = 'codeTextData'; + return data(code) + } +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Token} Token + */ + +/** + * Tokenize subcontent. + * + * @param {Array} events + * List of events. + * @returns {boolean} + * Whether subtokens were found. + */ +function subtokenize(events) { + /** @type {Record} */ + const jumps = {}; + let index = -1; + /** @type {Event} */ + let event; + /** @type {number | undefined} */ + let lineIndex; + /** @type {number} */ + let otherIndex; + /** @type {Event} */ + let otherEvent; + /** @type {Array} */ + let parameters; + /** @type {Array} */ + let subevents; + /** @type {boolean | undefined} */ + let more; + while (++index < events.length) { + while (index in jumps) { + index = jumps[index]; + } + event = events[index]; + + // Add a hook for the GFM tasklist extension, which needs to know if text + // is in the first content of a list item. + if ( + index && + event[1].type === 'chunkFlow' && + events[index - 1][1].type === 'listItemPrefix' + ) { + subevents = event[1]._tokenizer.events; + otherIndex = 0; + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'lineEndingBlank' + ) { + otherIndex += 2; + } + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'content' + ) { + while (++otherIndex < subevents.length) { + if (subevents[otherIndex][1].type === 'content') { + break + } + if (subevents[otherIndex][1].type === 'chunkText') { + subevents[otherIndex][1]._isInFirstContentOfListItem = true; + otherIndex++; + } + } + } + } + + // Enter. + if (event[0] === 'enter') { + if (event[1].contentType) { + Object.assign(jumps, subcontent(events, index)); + index = jumps[index]; + more = true; + } + } + // Exit. + else if (event[1]._container) { + otherIndex = index; + lineIndex = undefined; + while (otherIndex--) { + otherEvent = events[otherIndex]; + if ( + otherEvent[1].type === 'lineEnding' || + otherEvent[1].type === 'lineEndingBlank' + ) { + if (otherEvent[0] === 'enter') { + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + } + otherEvent[1].type = 'lineEnding'; + lineIndex = otherIndex; + } + } else { + break + } + } + if (lineIndex) { + // Fix position. + event[1].end = Object.assign({}, events[lineIndex][1].start); + + // Switch container exit w/ line endings. + parameters = events.slice(lineIndex, index); + parameters.unshift(event); + splice(events, lineIndex, index - lineIndex + 1, parameters); + } + } + } + return !more +} + +/** + * Tokenize embedded tokens. + * + * @param {Array} events + * @param {number} eventIndex + * @returns {Record} + */ +function subcontent(events, eventIndex) { + const token = events[eventIndex][1]; + const context = events[eventIndex][2]; + let startPosition = eventIndex - 1; + /** @type {Array} */ + const startPositions = []; + const tokenizer = + token._tokenizer || context.parser[token.contentType](token.start); + const childEvents = tokenizer.events; + /** @type {Array<[number, number]>} */ + const jumps = []; + /** @type {Record} */ + const gaps = {}; + /** @type {Array} */ + let stream; + /** @type {Token | undefined} */ + let previous; + let index = -1; + /** @type {Token | undefined} */ + let current = token; + let adjust = 0; + let start = 0; + const breaks = [start]; + + // Loop forward through the linked tokens to pass them in order to the + // subtokenizer. + while (current) { + // Find the position of the event for this token. + while (events[++startPosition][1] !== current) { + // Empty. + } + startPositions.push(startPosition); + if (!current._tokenizer) { + stream = context.sliceStream(current); + if (!current.next) { + stream.push(null); + } + if (previous) { + tokenizer.defineSkip(current.start); + } + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = true; + } + tokenizer.write(stream); + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = undefined; + } + } + + // Unravel the next token. + previous = current; + current = current.next; + } + + // Now, loop back through all events (and linked tokens), to figure out which + // parts belong where. + current = token; + while (++index < childEvents.length) { + if ( + // Find a void token that includes a break. + childEvents[index][0] === 'exit' && + childEvents[index - 1][0] === 'enter' && + childEvents[index][1].type === childEvents[index - 1][1].type && + childEvents[index][1].start.line !== childEvents[index][1].end.line + ) { + start = index + 1; + breaks.push(start); + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + current = current.next; + } + } + + // Help GC. + tokenizer.events = []; + + // If there’s one more token (which is the cases for lines that end in an + // EOF), that’s perfect: the last point we found starts it. + // If there isn’t then make sure any remaining content is added to it. + if (current) { + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + } else { + breaks.pop(); + } + + // Now splice the events from the subtokenizer into the current events, + // moving back to front so that splice indices aren’t affected. + index = breaks.length; + while (index--) { + const slice = childEvents.slice(breaks[index], breaks[index + 1]); + const start = startPositions.pop(); + jumps.unshift([start, start + slice.length - 1]); + splice(events, start, 2, slice); + } + index = -1; + while (++index < jumps.length) { + gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; + adjust += jumps[index][1] - jumps[index][0] - 1; + } + return gaps +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** + * No name because it must not be turned off. + * @type {Construct} + */ +const content = { + tokenize: tokenizeContent, + resolve: resolveContent +}; + +/** @type {Construct} */ +const continuationConstruct = { + tokenize: tokenizeContinuation, + partial: true +}; + +/** + * Content is transparent: it’s parsed right now. That way, definitions are also + * parsed right now: before text in paragraphs (specifically, media) are parsed. + * + * @type {Resolver} + */ +function resolveContent(events) { + subtokenize(events); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContent(effects, ok) { + /** @type {Token | undefined} */ + let previous; + return chunkStart + + /** + * Before a content chunk. + * + * ```markdown + * > | abc + * ^ + * ``` + * + * @type {State} + */ + function chunkStart(code) { + effects.enter('content'); + previous = effects.enter('chunkContent', { + contentType: 'content' + }); + return chunkInside(code) + } + + /** + * In a content chunk. + * + * ```markdown + * > | abc + * ^^^ + * ``` + * + * @type {State} + */ + function chunkInside(code) { + if (code === null) { + return contentEnd(code) + } + + // To do: in `markdown-rs`, each line is parsed on its own, and everything + // is stitched together resolving. + if (markdownLineEnding(code)) { + return effects.check( + continuationConstruct, + contentContinue, + contentEnd + )(code) + } + + // Data. + effects.consume(code); + return chunkInside + } + + /** + * + * + * @type {State} + */ + function contentEnd(code) { + effects.exit('chunkContent'); + effects.exit('content'); + return ok(code) + } + + /** + * + * + * @type {State} + */ + function contentContinue(code) { + effects.consume(code); + effects.exit('chunkContent'); + previous.next = effects.enter('chunkContent', { + contentType: 'content', + previous + }); + previous = previous.next; + return chunkInside + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContinuation(effects, ok, nok) { + const self = this; + return startLookahead + + /** + * + * + * @type {State} + */ + function startLookahead(code) { + effects.exit('chunkContent'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, prefixed, 'linePrefix') + } + + /** + * + * + * @type {State} + */ + function prefixed(code) { + if (code === null || markdownLineEnding(code)) { + return nok(code) + } + + // Always populated by defaults. + + const tail = self.events[self.events.length - 1]; + if ( + !self.parser.constructs.disable.null.includes('codeIndented') && + tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ) { + return ok(code) + } + return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse destinations. + * + * ###### Examples + * + * ```markdown + * + * b> + * + * + * a + * a\)b + * a(b)c + * a(b) + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type for whole (`` or `b`). + * @param {TokenType} literalType + * Type when enclosed (``). + * @param {TokenType} literalMarkerType + * Type for enclosing (`<` and `>`). + * @param {TokenType} rawType + * Type when not enclosed (`b`). + * @param {TokenType} stringType + * Type for the value (`a` or `b`). + * @param {number | undefined} [max=Infinity] + * Depth of nested parens (inclusive). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryDestination( + effects, + ok, + nok, + type, + literalType, + literalMarkerType, + rawType, + stringType, + max +) { + const limit = max || Number.POSITIVE_INFINITY; + let balance = 0; + return start + + /** + * Start of destination. + * + * ```markdown + * > | + * ^ + * > | aa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 60) { + effects.enter(type); + effects.enter(literalType); + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + return enclosedBefore + } + + // ASCII control, space, closing paren. + if (code === null || code === 32 || code === 41 || asciiControl(code)) { + return nok(code) + } + effects.enter(type); + effects.enter(rawType); + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return raw(code) + } + + /** + * After `<`, at an enclosed destination. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosedBefore(code) { + if (code === 62) { + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + effects.exit(literalType); + effects.exit(type); + return ok + } + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return enclosed(code) + } + + /** + * In enclosed destination. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosed(code) { + if (code === 62) { + effects.exit('chunkString'); + effects.exit(stringType); + return enclosedBefore(code) + } + if (code === null || code === 60 || markdownLineEnding(code)) { + return nok(code) + } + effects.consume(code); + return code === 92 ? enclosedEscape : enclosed + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosedEscape(code) { + if (code === 60 || code === 62 || code === 92) { + effects.consume(code); + return enclosed + } + return enclosed(code) + } + + /** + * In raw destination. + * + * ```markdown + * > | aa + * ^ + * ``` + * + * @type {State} + */ + function raw(code) { + if ( + !balance && + (code === null || code === 41 || markdownLineEndingOrSpace(code)) + ) { + effects.exit('chunkString'); + effects.exit(stringType); + effects.exit(rawType); + effects.exit(type); + return ok(code) + } + if (balance < limit && code === 40) { + effects.consume(code); + balance++; + return raw + } + if (code === 41) { + effects.consume(code); + balance--; + return raw + } + + // ASCII control (but *not* `\0`) and space and `(`. + // Note: in `markdown-rs`, `\0` exists in codes, in `micromark-js` it + // doesn’t. + if (code === null || code === 32 || code === 40 || asciiControl(code)) { + return nok(code) + } + effects.consume(code); + return code === 92 ? rawEscape : raw + } + + /** + * After `\`, at special character. + * + * ```markdown + * > | a\*a + * ^ + * ``` + * + * @type {State} + */ + function rawEscape(code) { + if (code === 40 || code === 41 || code === 92) { + effects.consume(code); + return raw + } + return raw(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse labels. + * + * > 👉 **Note**: labels in markdown are capped at 999 characters in the string. + * + * ###### Examples + * + * ```markdown + * [a] + * [a + * b] + * [a\]b] + * ``` + * + * @this {TokenizeContext} + * Tokenize context. + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type of the whole label (`[a]`). + * @param {TokenType} markerType + * Type for the markers (`[` and `]`). + * @param {TokenType} stringType + * Type for the identifier (`a`). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryLabel(effects, ok, nok, type, markerType, stringType) { + const self = this; + let size = 0; + /** @type {boolean} */ + let seen; + return start + + /** + * Start of label. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.enter(stringType); + return atBreak + } + + /** + * In label, at something, before something else. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if ( + size > 999 || + code === null || + code === 91 || + (code === 93 && !seen) || + // To do: remove in the future once we’ve switched from + // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`, + // which doesn’t need this. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + (code === 94 && + !size && + '_hiddenFootnoteSupport' in self.parser.constructs) + ) { + return nok(code) + } + if (code === 93) { + effects.exit(stringType); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } + + // To do: indent? Link chunks and EOLs together? + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return atBreak + } + effects.enter('chunkString', { + contentType: 'string' + }); + return labelInside(code) + } + + /** + * In label, in text. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function labelInside(code) { + if ( + code === null || + code === 91 || + code === 93 || + markdownLineEnding(code) || + size++ > 999 + ) { + effects.exit('chunkString'); + return atBreak(code) + } + effects.consume(code); + if (!seen) seen = !markdownSpace(code); + return code === 92 ? labelEscape : labelInside + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | [a\*a] + * ^ + * ``` + * + * @type {State} + */ + function labelEscape(code) { + if (code === 91 || code === 92 || code === 93) { + effects.consume(code); + size++; + return labelInside + } + return labelInside(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse titles. + * + * ###### Examples + * + * ```markdown + * "a" + * 'b' + * (c) + * "a + * b" + * 'a + * b' + * (a\)b) + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type of the whole title (`"a"`, `'b'`, `(c)`). + * @param {TokenType} markerType + * Type for the markers (`"`, `'`, `(`, and `)`). + * @param {TokenType} stringType + * Type for the value (`a`). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryTitle(effects, ok, nok, type, markerType, stringType) { + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of title. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 34 || code === 39 || code === 40) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + marker = code === 40 ? 41 : code; + return begin + } + return nok(code) + } + + /** + * After opening marker. + * + * This is also used at the closing marker. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function begin(code) { + if (code === marker) { + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } + effects.enter(stringType); + return atBreak(code) + } + + /** + * At something, before something else. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === marker) { + effects.exit(stringType); + return begin(marker) + } + if (code === null) { + return nok(code) + } + + // Note: blank lines can’t exist in content. + if (markdownLineEnding(code)) { + // To do: use `space_or_tab_eol_with_options`, connect. + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, atBreak, 'linePrefix') + } + effects.enter('chunkString', { + contentType: 'string' + }); + return inside(code) + } + + /** + * + * + * @type {State} + */ + function inside(code) { + if (code === marker || code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + return atBreak(code) + } + effects.consume(code); + return code === 92 ? escape : inside + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | "a\*b" + * ^ + * ``` + * + * @type {State} + */ + function escape(code) { + if (code === marker || code === 92) { + effects.consume(code); + return inside + } + return inside(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + */ + +/** + * Parse spaces and tabs. + * + * There is no `nok` parameter: + * + * * line endings or spaces in markdown are often optional, in which case this + * factory can be used and `ok` will be switched to whether spaces were found + * or not + * * one line ending or space can be detected with + * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @returns + * Start state. + */ +function factoryWhitespace(effects, ok) { + /** @type {boolean} */ + let seen; + return start + + /** @type {State} */ + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + seen = true; + return start + } + if (markdownSpace(code)) { + return factorySpace( + effects, + start, + seen ? 'linePrefix' : 'lineSuffix' + )(code) + } + return ok(code) + } +} + +/** + * Normalize an identifier (as found in references, definitions). + * + * Collapses markdown whitespace, trim, and then lower- and uppercase. + * + * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their + * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different + * uppercase character (U+0398 (`Θ`)). + * So, to get a canonical form, we perform both lower- and uppercase. + * + * Using uppercase last makes sure keys will never interact with default + * prototypal values (such as `constructor`): nothing in the prototype of + * `Object` is uppercase. + * + * @param {string} value + * Identifier to normalize. + * @returns {string} + * Normalized identifier. + */ +function normalizeIdentifier(value) { + return ( + value + // Collapse markdown whitespace. + .replace(/[\t\n\r ]+/g, ' ') + // Trim. + .replace(/^ | $/g, '') + // Some characters are considered “uppercase”, but if their lowercase + // counterpart is uppercased will result in a different uppercase + // character. + // Hence, to get that form, we perform both lower- and uppercase. + // Upper case makes sure keys will not interact with default prototypal + // methods: no method is uppercase. + .toLowerCase() + .toUpperCase() + ) +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const definition = { + name: 'definition', + tokenize: tokenizeDefinition +}; + +/** @type {Construct} */ +const titleBefore = { + tokenize: tokenizeTitleBefore, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeDefinition(effects, ok, nok) { + const self = this; + /** @type {string} */ + let identifier; + return start + + /** + * At start of a definition. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // Do not interrupt paragraphs (but do follow definitions). + // To do: do `interrupt` the way `markdown-rs` does. + // To do: parse whitespace the way `markdown-rs` does. + effects.enter('definition'); + return before(code) + } + + /** + * After optional whitespace, at `[`. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + // To do: parse whitespace the way `markdown-rs` does. + + return factoryLabel.call( + self, + effects, + labelAfter, + // Note: we don’t need to reset the way `markdown-rs` does. + nok, + 'definitionLabel', + 'definitionLabelMarker', + 'definitionLabelString' + )(code) + } + + /** + * After label. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function labelAfter(code) { + identifier = normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ); + if (code === 58) { + effects.enter('definitionMarker'); + effects.consume(code); + effects.exit('definitionMarker'); + return markerAfter + } + return nok(code) + } + + /** + * After marker. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function markerAfter(code) { + // Note: whitespace is optional. + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, destinationBefore)(code) + : destinationBefore(code) + } + + /** + * Before destination. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function destinationBefore(code) { + return factoryDestination( + effects, + destinationAfter, + // Note: we don’t need to reset the way `markdown-rs` does. + nok, + 'definitionDestination', + 'definitionDestinationLiteral', + 'definitionDestinationLiteralMarker', + 'definitionDestinationRaw', + 'definitionDestinationString' + )(code) + } + + /** + * After destination. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function destinationAfter(code) { + return effects.attempt(titleBefore, after, after)(code) + } + + /** + * After definition. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return markdownSpace(code) + ? factorySpace(effects, afterWhitespace, 'whitespace')(code) + : afterWhitespace(code) + } + + /** + * After definition, after optional whitespace. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function afterWhitespace(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('definition'); + + // Note: we don’t care about uniqueness. + // It’s likely that that doesn’t happen very frequently. + // It is more likely that it wastes precious time. + self.parser.defined.push(identifier); + + // To do: `markdown-rs` interrupt. + // // You’d be interrupting. + // tokenizer.interrupt = true + return ok(code) + } + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeTitleBefore(effects, ok, nok) { + return titleBefore + + /** + * After destination, at whitespace. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleBefore(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, beforeMarker)(code) + : nok(code) + } + + /** + * At title. + * + * ```markdown + * | [a]: b + * > | "c" + * ^ + * ``` + * + * @type {State} + */ + function beforeMarker(code) { + return factoryTitle( + effects, + titleAfter, + nok, + 'definitionTitle', + 'definitionTitleMarker', + 'definitionTitleString' + )(code) + } + + /** + * After title. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleAfter(code) { + return markdownSpace(code) + ? factorySpace(effects, titleAfterOptionalWhitespace, 'whitespace')(code) + : titleAfterOptionalWhitespace(code) + } + + /** + * After title, after optional whitespace. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleAfterOptionalWhitespace(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const hardBreakEscape = { + name: 'hardBreakEscape', + tokenize: tokenizeHardBreakEscape +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHardBreakEscape(effects, ok, nok) { + return start + + /** + * Start of a hard break (escape). + * + * ```markdown + * > | a\ + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('hardBreakEscape'); + effects.consume(code); + return after + } + + /** + * After `\`, at eol. + * + * ```markdown + * > | a\ + * ^ + * | b + * ``` + * + * @type {State} + */ + function after(code) { + if (markdownLineEnding(code)) { + effects.exit('hardBreakEscape'); + return ok(code) + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const headingAtx = { + name: 'headingAtx', + tokenize: tokenizeHeadingAtx, + resolve: resolveHeadingAtx +}; + +/** @type {Resolver} */ +function resolveHeadingAtx(events, context) { + let contentEnd = events.length - 2; + let contentStart = 3; + /** @type {Token} */ + let content; + /** @type {Token} */ + let text; + + // Prefix whitespace, part of the opening. + if (events[contentStart][1].type === 'whitespace') { + contentStart += 2; + } + + // Suffix whitespace, part of the closing. + if ( + contentEnd - 2 > contentStart && + events[contentEnd][1].type === 'whitespace' + ) { + contentEnd -= 2; + } + if ( + events[contentEnd][1].type === 'atxHeadingSequence' && + (contentStart === contentEnd - 1 || + (contentEnd - 4 > contentStart && + events[contentEnd - 2][1].type === 'whitespace')) + ) { + contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; + } + if (contentEnd > contentStart) { + content = { + type: 'atxHeadingText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end + }; + text = { + type: 'chunkText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end, + contentType: 'text' + }; + splice(events, contentStart, contentEnd - contentStart + 1, [ + ['enter', content, context], + ['enter', text, context], + ['exit', text, context], + ['exit', content, context] + ]); + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHeadingAtx(effects, ok, nok) { + let size = 0; + return start + + /** + * Start of a heading (atx). + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse indent like `markdown-rs`. + effects.enter('atxHeading'); + return before(code) + } + + /** + * After optional whitespace, at `#`. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('atxHeadingSequence'); + return sequenceOpen(code) + } + + /** + * In opening sequence. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === 35 && size++ < 6) { + effects.consume(code); + return sequenceOpen + } + + // Always at least one `#`. + if (code === null || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingSequence'); + return atBreak(code) + } + return nok(code) + } + + /** + * After something, before something else. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === 35) { + effects.enter('atxHeadingSequence'); + return sequenceFurther(code) + } + if (code === null || markdownLineEnding(code)) { + effects.exit('atxHeading'); + // To do: interrupt like `markdown-rs`. + // // Feel free to interrupt. + // tokenizer.interrupt = false + return ok(code) + } + if (markdownSpace(code)) { + return factorySpace(effects, atBreak, 'whitespace')(code) + } + + // To do: generate `data` tokens, add the `text` token later. + // Needs edit map, see: `markdown.rs`. + effects.enter('atxHeadingText'); + return data(code) + } + + /** + * In further sequence (after whitespace). + * + * Could be normal “visible” hashes in the heading or a final sequence. + * + * ```markdown + * > | ## aa ## + * ^ + * ``` + * + * @type {State} + */ + function sequenceFurther(code) { + if (code === 35) { + effects.consume(code); + return sequenceFurther + } + effects.exit('atxHeadingSequence'); + return atBreak(code) + } + + /** + * In text. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function data(code) { + if (code === null || code === 35 || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingText'); + return atBreak(code) + } + effects.consume(code); + return data + } +} + +/** + * List of lowercase HTML “block” tag names. + * + * The list, when parsing HTML (flow), results in more relaxed rules (condition + * 6). + * Because they are known blocks, the HTML-like syntax doesn’t have to be + * strictly parsed. + * For tag names not in this list, a more strict algorithm (condition 7) is used + * to detect whether the HTML-like syntax is seen as HTML (flow) or not. + * + * This is copied from: + * . + * + * > 👉 **Note**: `search` was added in `CommonMark@0.31`. + */ +const htmlBlockNames = [ + 'address', + 'article', + 'aside', + 'base', + 'basefont', + 'blockquote', + 'body', + 'caption', + 'center', + 'col', + 'colgroup', + 'dd', + 'details', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', + 'fieldset', + 'figcaption', + 'figure', + 'footer', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hr', + 'html', + 'iframe', + 'legend', + 'li', + 'link', + 'main', + 'menu', + 'menuitem', + 'nav', + 'noframes', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'search', + 'section', + 'summary', + 'table', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'title', + 'tr', + 'track', + 'ul' +]; + +/** + * List of lowercase HTML “raw” tag names. + * + * The list, when parsing HTML (flow), results in HTML that can include lines + * without exiting, until a closing tag also in this list is found (condition + * 1). + * + * This module is copied from: + * . + * + * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`. + */ +const htmlRawNames = ['pre', 'script', 'style', 'textarea']; + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const htmlFlow = { + name: 'htmlFlow', + tokenize: tokenizeHtmlFlow, + resolveTo: resolveToHtmlFlow, + concrete: true +}; + +/** @type {Construct} */ +const blankLineBefore = { + tokenize: tokenizeBlankLineBefore, + partial: true +}; +const nonLazyContinuationStart = { + tokenize: tokenizeNonLazyContinuationStart, + partial: true +}; + +/** @type {Resolver} */ +function resolveToHtmlFlow(events) { + let index = events.length; + while (index--) { + if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { + break + } + } + if (index > 1 && events[index - 2][1].type === 'linePrefix') { + // Add the prefix start to the HTML token. + events[index][1].start = events[index - 2][1].start; + // Add the prefix start to the HTML line token. + events[index + 1][1].start = events[index - 2][1].start; + // Remove the line prefix. + events.splice(index - 2, 2); + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHtmlFlow(effects, ok, nok) { + const self = this; + /** @type {number} */ + let marker; + /** @type {boolean} */ + let closingTag; + /** @type {string} */ + let buffer; + /** @type {number} */ + let index; + /** @type {Code} */ + let markerB; + return start + + /** + * Start of HTML (flow). + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse indent like `markdown-rs`. + return before(code) + } + + /** + * At `<`, after optional whitespace. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('htmlFlow'); + effects.enter('htmlFlowData'); + effects.consume(code); + return open + } + + /** + * After `<`, at tag name or other stuff. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } + if (code === 47) { + effects.consume(code); + closingTag = true; + return tagCloseStart + } + if (code === 63) { + effects.consume(code); + marker = 3; + // To do: + // tokenizer.concrete = true + // To do: use `markdown-rs` style interrupt. + // While we’re in an instruction instead of a declaration, we’re on a `?` + // right now, so we do need to search for `>`, similar to declarations. + return self.interrupt ? ok : continuationDeclarationInside + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + // @ts-expect-error: not null. + buffer = String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * After ` | + * ^ + * > | + * ^ + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + marker = 2; + return commentOpenInside + } + if (code === 91) { + effects.consume(code); + marker = 5; + index = 0; + return cdataOpenInside + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + marker = 4; + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuationDeclarationInside + } + return nok(code) + } + + /** + * After ` | + * ^ + * ``` + * + * @type {State} + */ + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuationDeclarationInside + } + return nok(code) + } + + /** + * After ` | &<]]> + * ^^^^^^ + * ``` + * + * @type {State} + */ + function cdataOpenInside(code) { + const value = 'CDATA['; + if (code === value.charCodeAt(index++)) { + effects.consume(code); + if (index === value.length) { + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuation + } + return cdataOpenInside + } + return nok(code) + } + + /** + * After ` | + * ^ + * ``` + * + * @type {State} + */ + function tagCloseStart(code) { + if (asciiAlpha(code)) { + effects.consume(code); + // @ts-expect-error: not null. + buffer = String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * In tag name. + * + * ```markdown + * > | + * ^^ + * > | + * ^^ + * ``` + * + * @type {State} + */ + function tagName(code) { + if ( + code === null || + code === 47 || + code === 62 || + markdownLineEndingOrSpace(code) + ) { + const slash = code === 47; + const name = buffer.toLowerCase(); + if (!slash && !closingTag && htmlRawNames.includes(name)) { + marker = 1; + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok(code) : continuation(code) + } + if (htmlBlockNames.includes(buffer.toLowerCase())) { + marker = 6; + if (slash) { + effects.consume(code); + return basicSelfClosing + } + + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok(code) : continuation(code) + } + marker = 7; + // Do not support complete HTML when interrupting. + return self.interrupt && !self.parser.lazy[self.now().line] + ? nok(code) + : closingTag + ? completeClosingTagAfter(code) + : completeAttributeNameBefore(code) + } + + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + buffer += String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * After closing slash of a basic tag name. + * + * ```markdown + * > |
+ * ^ + * ``` + * + * @type {State} + */ + function basicSelfClosing(code) { + if (code === 62) { + effects.consume(code); + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuation + } + return nok(code) + } + + /** + * After closing slash of a complete tag name. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeClosingTagAfter(code) { + if (markdownSpace(code)) { + effects.consume(code); + return completeClosingTagAfter + } + return completeEnd(code) + } + + /** + * At an attribute name. + * + * At first, this state is used after a complete tag name, after whitespace, + * where it expects optional attributes or the end of the tag. + * It is also reused after attributes, when expecting more optional + * attributes. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeNameBefore(code) { + if (code === 47) { + effects.consume(code); + return completeEnd + } + + // ASCII alphanumerical and `:` and `_`. + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return completeAttributeName + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameBefore + } + return completeEnd(code) + } + + /** + * In attribute name. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeName(code) { + // ASCII alphanumerical and `-`, `.`, `:`, and `_`. + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return completeAttributeName + } + return completeAttributeNameAfter(code) + } + + /** + * After attribute name, at an optional initializer, the end of the tag, or + * whitespace. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return completeAttributeValueBefore + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameAfter + } + return completeAttributeNameBefore(code) + } + + /** + * Before unquoted, double quoted, or single quoted attribute value, allowing + * whitespace. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } + if (code === 34 || code === 39) { + effects.consume(code); + markerB = code; + return completeAttributeValueQuoted + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeValueBefore + } + return completeAttributeValueUnquoted(code) + } + + /** + * In double or single quoted attribute value. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueQuoted(code) { + if (code === markerB) { + effects.consume(code); + markerB = null; + return completeAttributeValueQuotedAfter + } + if (code === null || markdownLineEnding(code)) { + return nok(code) + } + effects.consume(code); + return completeAttributeValueQuoted + } + + /** + * In unquoted attribute value. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 47 || + code === 60 || + code === 61 || + code === 62 || + code === 96 || + markdownLineEndingOrSpace(code) + ) { + return completeAttributeNameAfter(code) + } + effects.consume(code); + return completeAttributeValueUnquoted + } + + /** + * After double or single quoted attribute value, before whitespace or the + * end of the tag. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownSpace(code)) { + return completeAttributeNameBefore(code) + } + return nok(code) + } + + /** + * In certain circumstances of a complete tag where only an `>` is allowed. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeEnd(code) { + if (code === 62) { + effects.consume(code); + return completeAfter + } + return nok(code) + } + + /** + * After `>` in a complete tag. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAfter(code) { + if (code === null || markdownLineEnding(code)) { + // // Do not form containers. + // tokenizer.concrete = true + return continuation(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAfter + } + return nok(code) + } + + /** + * In continuation of any HTML kind. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuation(code) { + if (code === 45 && marker === 2) { + effects.consume(code); + return continuationCommentInside + } + if (code === 60 && marker === 1) { + effects.consume(code); + return continuationRawTagOpen + } + if (code === 62 && marker === 4) { + effects.consume(code); + return continuationClose + } + if (code === 63 && marker === 3) { + effects.consume(code); + return continuationDeclarationInside + } + if (code === 93 && marker === 5) { + effects.consume(code); + return continuationCdataInside + } + if (markdownLineEnding(code) && (marker === 6 || marker === 7)) { + effects.exit('htmlFlowData'); + return effects.check( + blankLineBefore, + continuationAfter, + continuationStart + )(code) + } + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return continuationStart(code) + } + effects.consume(code); + return continuation + } + + /** + * In continuation, at eol. + * + * ```markdown + * > | + * ^ + * | asd + * ``` + * + * @type {State} + */ + function continuationStart(code) { + return effects.check( + nonLazyContinuationStart, + continuationStartNonLazy, + continuationAfter + )(code) + } + + /** + * In continuation, at eol, before non-lazy content. + * + * ```markdown + * > | + * ^ + * | asd + * ``` + * + * @type {State} + */ + function continuationStartNonLazy(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return continuationBefore + } + + /** + * In continuation, before non-lazy content. + * + * ```markdown + * | + * > | asd + * ^ + * ``` + * + * @type {State} + */ + function continuationBefore(code) { + if (code === null || markdownLineEnding(code)) { + return continuationStart(code) + } + effects.enter('htmlFlowData'); + return continuation(code) + } + + /** + * In comment continuation, after one `-`, expecting another. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationCommentInside(code) { + if (code === 45) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In raw continuation, after `<`, at `/`. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationRawTagOpen(code) { + if (code === 47) { + effects.consume(code); + buffer = ''; + return continuationRawEndTag + } + return continuation(code) + } + + /** + * In raw continuation, after ` | + * ^^^^^^ + * ``` + * + * @type {State} + */ + function continuationRawEndTag(code) { + if (code === 62) { + const name = buffer.toLowerCase(); + if (htmlRawNames.includes(name)) { + effects.consume(code); + return continuationClose + } + return continuation(code) + } + if (asciiAlpha(code) && buffer.length < 8) { + effects.consume(code); + // @ts-expect-error: not null. + buffer += String.fromCharCode(code); + return continuationRawEndTag + } + return continuation(code) + } + + /** + * In cdata continuation, after `]`, expecting `]>`. + * + * ```markdown + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function continuationCdataInside(code) { + if (code === 93) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In declaration or instruction continuation, at `>`. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function continuationDeclarationInside(code) { + if (code === 62) { + effects.consume(code); + return continuationClose + } + + // More dashes. + if (code === 45 && marker === 2) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In closed continuation: everything we get until the eol/eof is part of it. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationClose(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return continuationAfter(code) + } + effects.consume(code); + return continuationClose + } + + /** + * Done. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationAfter(code) { + effects.exit('htmlFlow'); + // // Feel free to interrupt. + // tokenizer.interrupt = false + // // No longer concrete. + // tokenizer.concrete = false + return ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeNonLazyContinuationStart(effects, ok, nok) { + const self = this; + return start + + /** + * At eol, before continuation. + * + * ```markdown + * > | * ```js + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return after + } + return nok(code) + } + + /** + * A continuation. + * + * ```markdown + * | * ```js + * > | b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlankLineBefore(effects, ok, nok) { + return start + + /** + * Before eol, expecting blank line. + * + * ```markdown + * > |
+ * ^ + * | + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return effects.attempt(blankLine, ok, nok) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const htmlText = { + name: 'htmlText', + tokenize: tokenizeHtmlText +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHtmlText(effects, ok, nok) { + const self = this; + /** @type {NonNullable | undefined} */ + let marker; + /** @type {number} */ + let index; + /** @type {State} */ + let returnState; + return start + + /** + * Start of HTML (text). + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('htmlText'); + effects.enter('htmlTextData'); + effects.consume(code); + return open + } + + /** + * After `<`, at tag name or other stuff. + * + * ```markdown + * > | a c + * ^ + * > | a c + * ^ + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } + if (code === 47) { + effects.consume(code); + return tagCloseStart + } + if (code === 63) { + effects.consume(code); + return instruction + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + return tagOpen + } + return nok(code) + } + + /** + * After ` | a c + * ^ + * > | a c + * ^ + * > | a &<]]> c + * ^ + * ``` + * + * @type {State} + */ + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + return commentOpenInside + } + if (code === 91) { + effects.consume(code); + index = 0; + return cdataOpenInside + } + if (asciiAlpha(code)) { + effects.consume(code); + return declaration + } + return nok(code) + } + + /** + * In a comment, after ` | a c + * ^ + * ``` + * + * @type {State} + */ + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + return commentEnd + } + return nok(code) + } + + /** + * In comment. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function comment(code) { + if (code === null) { + return nok(code) + } + if (code === 45) { + effects.consume(code); + return commentClose + } + if (markdownLineEnding(code)) { + returnState = comment; + return lineEndingBefore(code) + } + effects.consume(code); + return comment + } + + /** + * In comment, after `-`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function commentClose(code) { + if (code === 45) { + effects.consume(code); + return commentEnd + } + return comment(code) + } + + /** + * In comment, after `--`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function commentEnd(code) { + return code === 62 + ? end(code) + : code === 45 + ? commentClose(code) + : comment(code) + } + + /** + * After ` | a &<]]> b + * ^^^^^^ + * ``` + * + * @type {State} + */ + function cdataOpenInside(code) { + const value = 'CDATA['; + if (code === value.charCodeAt(index++)) { + effects.consume(code); + return index === value.length ? cdata : cdataOpenInside + } + return nok(code) + } + + /** + * In CDATA. + * + * ```markdown + * > | a &<]]> b + * ^^^ + * ``` + * + * @type {State} + */ + function cdata(code) { + if (code === null) { + return nok(code) + } + if (code === 93) { + effects.consume(code); + return cdataClose + } + if (markdownLineEnding(code)) { + returnState = cdata; + return lineEndingBefore(code) + } + effects.consume(code); + return cdata + } + + /** + * In CDATA, after `]`, at another `]`. + * + * ```markdown + * > | a &<]]> b + * ^ + * ``` + * + * @type {State} + */ + function cdataClose(code) { + if (code === 93) { + effects.consume(code); + return cdataEnd + } + return cdata(code) + } + + /** + * In CDATA, after `]]`, at `>`. + * + * ```markdown + * > | a &<]]> b + * ^ + * ``` + * + * @type {State} + */ + function cdataEnd(code) { + if (code === 62) { + return end(code) + } + if (code === 93) { + effects.consume(code); + return cdataEnd + } + return cdata(code) + } + + /** + * In declaration. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function declaration(code) { + if (code === null || code === 62) { + return end(code) + } + if (markdownLineEnding(code)) { + returnState = declaration; + return lineEndingBefore(code) + } + effects.consume(code); + return declaration + } + + /** + * In instruction. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function instruction(code) { + if (code === null) { + return nok(code) + } + if (code === 63) { + effects.consume(code); + return instructionClose + } + if (markdownLineEnding(code)) { + returnState = instruction; + return lineEndingBefore(code) + } + effects.consume(code); + return instruction + } + + /** + * In instruction, after `?`, at `>`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function instructionClose(code) { + return code === 62 ? end(code) : instruction(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagCloseStart(code) { + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + return tagClose + } + return nok(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagClose(code) { + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagClose + } + return tagCloseBetween(code) + } + + /** + * In closing tag, after tag name. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function tagCloseBetween(code) { + if (markdownLineEnding(code)) { + returnState = tagCloseBetween; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagCloseBetween + } + return end(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagOpen(code) { + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagOpen + } + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + return nok(code) + } + + /** + * In opening tag, after tag name. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function tagOpenBetween(code) { + if (code === 47) { + effects.consume(code); + return end + } + + // ASCII alphabetical and `:` and `_`. + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return tagOpenAttributeName + } + if (markdownLineEnding(code)) { + returnState = tagOpenBetween; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenBetween + } + return end(code) + } + + /** + * In attribute name. + * + * ```markdown + * > | a d + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeName(code) { + // ASCII alphabetical and `-`, `.`, `:`, and `_`. + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return tagOpenAttributeName + } + return tagOpenAttributeNameAfter(code) + } + + /** + * After attribute name, before initializer, the end of the tag, or + * whitespace. + * + * ```markdown + * > | a d + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return tagOpenAttributeValueBefore + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeNameAfter; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeNameAfter + } + return tagOpenBetween(code) + } + + /** + * Before unquoted, double quoted, or single quoted attribute value, allowing + * whitespace. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } + if (code === 34 || code === 39) { + effects.consume(code); + marker = code; + return tagOpenAttributeValueQuoted + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueBefore; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeValueBefore + } + effects.consume(code); + return tagOpenAttributeValueUnquoted + } + + /** + * In double or single quoted attribute value. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueQuoted(code) { + if (code === marker) { + effects.consume(code); + marker = undefined; + return tagOpenAttributeValueQuotedAfter + } + if (code === null) { + return nok(code) + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueQuoted; + return lineEndingBefore(code) + } + effects.consume(code); + return tagOpenAttributeValueQuoted + } + + /** + * In unquoted attribute value. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 60 || + code === 61 || + code === 96 + ) { + return nok(code) + } + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + effects.consume(code); + return tagOpenAttributeValueUnquoted + } + + /** + * After double or single quoted attribute value, before whitespace or the end + * of the tag. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + return nok(code) + } + + /** + * In certain circumstances of a tag where only an `>` is allowed. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function end(code) { + if (code === 62) { + effects.consume(code); + effects.exit('htmlTextData'); + effects.exit('htmlText'); + return ok + } + return nok(code) + } + + /** + * At eol. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * > | a + * ``` + * + * @type {State} + */ + function lineEndingBefore(code) { + effects.exit('htmlTextData'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineEndingAfter + } + + /** + * After eol, at optional whitespace. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * | a + * ^ + * ``` + * + * @type {State} + */ + function lineEndingAfter(code) { + // Always populated by defaults. + + return markdownSpace(code) + ? factorySpace( + effects, + lineEndingAfterPrefix, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + : lineEndingAfterPrefix(code) + } + + /** + * After eol, after optional whitespace. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * | a + * ^ + * ``` + * + * @type {State} + */ + function lineEndingAfterPrefix(code) { + effects.enter('htmlTextData'); + return returnState(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const labelEnd = { + name: 'labelEnd', + tokenize: tokenizeLabelEnd, + resolveTo: resolveToLabelEnd, + resolveAll: resolveAllLabelEnd +}; + +/** @type {Construct} */ +const resourceConstruct = { + tokenize: tokenizeResource +}; +/** @type {Construct} */ +const referenceFullConstruct = { + tokenize: tokenizeReferenceFull +}; +/** @type {Construct} */ +const referenceCollapsedConstruct = { + tokenize: tokenizeReferenceCollapsed +}; + +/** @type {Resolver} */ +function resolveAllLabelEnd(events) { + let index = -1; + while (++index < events.length) { + const token = events[index][1]; + if ( + token.type === 'labelImage' || + token.type === 'labelLink' || + token.type === 'labelEnd' + ) { + // Remove the marker. + events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); + token.type = 'data'; + index++; + } + } + return events +} + +/** @type {Resolver} */ +function resolveToLabelEnd(events, context) { + let index = events.length; + let offset = 0; + /** @type {Token} */ + let token; + /** @type {number | undefined} */ + let open; + /** @type {number | undefined} */ + let close; + /** @type {Array} */ + let media; + + // Find an opening. + while (index--) { + token = events[index][1]; + if (open) { + // If we see another link, or inactive link label, we’ve been here before. + if ( + token.type === 'link' || + (token.type === 'labelLink' && token._inactive) + ) { + break + } + + // Mark other link openings as inactive, as we can’t have links in + // links. + if (events[index][0] === 'enter' && token.type === 'labelLink') { + token._inactive = true; + } + } else if (close) { + if ( + events[index][0] === 'enter' && + (token.type === 'labelImage' || token.type === 'labelLink') && + !token._balanced + ) { + open = index; + if (token.type !== 'labelLink') { + offset = 2; + break + } + } + } else if (token.type === 'labelEnd') { + close = index; + } + } + const group = { + type: events[open][1].type === 'labelLink' ? 'link' : 'image', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + const label = { + type: 'label', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[close][1].end) + }; + const text = { + type: 'labelText', + start: Object.assign({}, events[open + offset + 2][1].end), + end: Object.assign({}, events[close - 2][1].start) + }; + media = [ + ['enter', group, context], + ['enter', label, context] + ]; + + // Opening marker. + media = push(media, events.slice(open + 1, open + offset + 3)); + + // Text open. + media = push(media, [['enter', text, context]]); + + // Always populated by defaults. + + // Between. + media = push( + media, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + offset + 4, close - 3), + context + ) + ); + + // Text close, marker close, label close. + media = push(media, [ + ['exit', text, context], + events[close - 2], + events[close - 1], + ['exit', label, context] + ]); + + // Reference, resource, or so. + media = push(media, events.slice(close + 1)); + + // Media close. + media = push(media, [['exit', group, context]]); + splice(events, open, events.length, media); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelEnd(effects, ok, nok) { + const self = this; + let index = self.events.length; + /** @type {Token} */ + let labelStart; + /** @type {boolean} */ + let defined; + + // Find an opening. + while (index--) { + if ( + (self.events[index][1].type === 'labelImage' || + self.events[index][1].type === 'labelLink') && + !self.events[index][1]._balanced + ) { + labelStart = self.events[index][1]; + break + } + } + return start + + /** + * Start of label end. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ``` + * + * @type {State} + */ + function start(code) { + // If there is not an okay opening. + if (!labelStart) { + return nok(code) + } + + // If the corresponding label (link) start is marked as inactive, + // it means we’d be wrapping a link, like this: + // + // ```markdown + // > | a [b [c](d) e](f) g. + // ^ + // ``` + // + // We can’t have that, so it’s just balanced brackets. + if (labelStart._inactive) { + return labelEndNok(code) + } + defined = self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize({ + start: labelStart.end, + end: self.now() + }) + ) + ); + effects.enter('labelEnd'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelEnd'); + return after + } + + /** + * After `]`. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + // Note: `markdown-rs` also parses GFM footnotes here, which for us is in + // an extension. + + // Resource (`[asd](fgh)`)? + if (code === 40) { + return effects.attempt( + resourceConstruct, + labelEndOk, + defined ? labelEndOk : labelEndNok + )(code) + } + + // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference? + if (code === 91) { + return effects.attempt( + referenceFullConstruct, + labelEndOk, + defined ? referenceNotFull : labelEndNok + )(code) + } + + // Shortcut (`[asd]`) reference? + return defined ? labelEndOk(code) : labelEndNok(code) + } + + /** + * After `]`, at `[`, but not at a full reference. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function referenceNotFull(code) { + return effects.attempt( + referenceCollapsedConstruct, + labelEndOk, + labelEndNok + )(code) + } + + /** + * Done, we found something. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function labelEndOk(code) { + // Note: `markdown-rs` does a bunch of stuff here. + return ok(code) + } + + /** + * Done, it’s nothing. + * + * There was an okay opening, but we didn’t match anything. + * + * ```markdown + * > | [a](b c + * ^ + * > | [a][b c + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function labelEndNok(code) { + labelStart._balanced = true; + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeResource(effects, ok, nok) { + return resourceStart + + /** + * At a resource. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceStart(code) { + effects.enter('resource'); + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + return resourceBefore + } + + /** + * In resource, after `(`, at optional whitespace. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceBefore(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceOpen)(code) + : resourceOpen(code) + } + + /** + * In resource, after optional whitespace, at `)` or a destination. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceOpen(code) { + if (code === 41) { + return resourceEnd(code) + } + return factoryDestination( + effects, + resourceDestinationAfter, + resourceDestinationMissing, + 'resourceDestination', + 'resourceDestinationLiteral', + 'resourceDestinationLiteralMarker', + 'resourceDestinationRaw', + 'resourceDestinationString', + 32 + )(code) + } + + /** + * In resource, after destination, at optional whitespace. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceDestinationAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceBetween)(code) + : resourceEnd(code) + } + + /** + * At invalid destination. + * + * ```markdown + * > | [a](<<) b + * ^ + * ``` + * + * @type {State} + */ + function resourceDestinationMissing(code) { + return nok(code) + } + + /** + * In resource, after destination and whitespace, at `(` or title. + * + * ```markdown + * > | [a](b ) c + * ^ + * ``` + * + * @type {State} + */ + function resourceBetween(code) { + if (code === 34 || code === 39 || code === 40) { + return factoryTitle( + effects, + resourceTitleAfter, + nok, + 'resourceTitle', + 'resourceTitleMarker', + 'resourceTitleString' + )(code) + } + return resourceEnd(code) + } + + /** + * In resource, after title, at optional whitespace. + * + * ```markdown + * > | [a](b "c") d + * ^ + * ``` + * + * @type {State} + */ + function resourceTitleAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceEnd)(code) + : resourceEnd(code) + } + + /** + * In resource, at `)`. + * + * ```markdown + * > | [a](b) d + * ^ + * ``` + * + * @type {State} + */ + function resourceEnd(code) { + if (code === 41) { + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + effects.exit('resource'); + return ok + } + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeReferenceFull(effects, ok, nok) { + const self = this; + return referenceFull + + /** + * In a reference (full), at the `[`. + * + * ```markdown + * > | [a][b] d + * ^ + * ``` + * + * @type {State} + */ + function referenceFull(code) { + return factoryLabel.call( + self, + effects, + referenceFullAfter, + referenceFullMissing, + 'reference', + 'referenceMarker', + 'referenceString' + )(code) + } + + /** + * In a reference (full), after `]`. + * + * ```markdown + * > | [a][b] d + * ^ + * ``` + * + * @type {State} + */ + function referenceFullAfter(code) { + return self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ) + ) + ? ok(code) + : nok(code) + } + + /** + * In reference (full) that was missing. + * + * ```markdown + * > | [a][b d + * ^ + * ``` + * + * @type {State} + */ + function referenceFullMissing(code) { + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeReferenceCollapsed(effects, ok, nok) { + return referenceCollapsedStart + + /** + * In reference (collapsed), at `[`. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] d + * ^ + * ``` + * + * @type {State} + */ + function referenceCollapsedStart(code) { + // We only attempt a collapsed label if there’s a `[`. + + effects.enter('reference'); + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + return referenceCollapsedOpen + } + + /** + * In reference (collapsed), at `]`. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] d + * ^ + * ``` + * + * @type {State} + */ + function referenceCollapsedOpen(code) { + if (code === 93) { + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + effects.exit('reference'); + return ok + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const labelStartImage = { + name: 'labelStartImage', + tokenize: tokenizeLabelStartImage, + resolveAll: labelEnd.resolveAll +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelStartImage(effects, ok, nok) { + const self = this; + return start + + /** + * Start of label (image) start. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('labelImage'); + effects.enter('labelImageMarker'); + effects.consume(code); + effects.exit('labelImageMarker'); + return open + } + + /** + * After `!`, at `[`. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 91) { + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelImage'); + return after + } + return nok(code) + } + + /** + * After `![`. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * This is needed in because, when GFM footnotes are enabled, images never + * form when started with a `^`. + * Instead, links form: + * + * ```markdown + * ![^a](b) + * + * ![^a][b] + * + * [b]: c + * ``` + * + * ```html + *

!^a

+ *

!^a

+ * ``` + * + * @type {State} + */ + function after(code) { + // To do: use a new field to do this, this is still needed for + // `micromark-extension-gfm-footnote`, but the `label-start-link` + // behavior isn’t. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const labelStartLink = { + name: 'labelStartLink', + tokenize: tokenizeLabelStartLink, + resolveAll: labelEnd.resolveAll +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelStartLink(effects, ok, nok) { + const self = this; + return start + + /** + * Start of label (link) start. + * + * ```markdown + * > | a [b] c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('labelLink'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelLink'); + return after + } + + /** @type {State} */ + function after(code) { + // To do: this isn’t needed in `micromark-extension-gfm-footnote`, + // remove. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const lineEnding = { + name: 'lineEnding', + tokenize: tokenizeLineEnding +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLineEnding(effects, ok) { + return start + + /** @type {State} */ + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, ok, 'linePrefix') + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const thematicBreak = { + name: 'thematicBreak', + tokenize: tokenizeThematicBreak +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeThematicBreak(effects, ok, nok) { + let size = 0; + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of thematic break. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('thematicBreak'); + // To do: parse indent like `markdown-rs`. + return before(code) + } + + /** + * After optional whitespace, at marker. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + marker = code; + return atBreak(code) + } + + /** + * After something, before something else. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === marker) { + effects.enter('thematicBreakSequence'); + return sequence(code) + } + if (size >= 3 && (code === null || markdownLineEnding(code))) { + effects.exit('thematicBreak'); + return ok(code) + } + return nok(code) + } + + /** + * In sequence. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function sequence(code) { + if (code === marker) { + effects.consume(code); + size++; + return sequence + } + effects.exit('thematicBreakSequence'); + return markdownSpace(code) + ? factorySpace(effects, atBreak, 'whitespace')(code) + : atBreak(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ContainerState} ContainerState + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const list = { + name: 'list', + tokenize: tokenizeListStart, + continuation: { + tokenize: tokenizeListContinuation + }, + exit: tokenizeListEnd +}; + +/** @type {Construct} */ +const listItemPrefixWhitespaceConstruct = { + tokenize: tokenizeListItemPrefixWhitespace, + partial: true +}; + +/** @type {Construct} */ +const indentConstruct = { + tokenize: tokenizeIndent, + partial: true +}; + +// To do: `markdown-rs` parses list items on their own and later stitches them +// together. + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListStart(effects, ok, nok) { + const self = this; + const tail = self.events[self.events.length - 1]; + let initialSize = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + let size = 0; + return start + + /** @type {State} */ + function start(code) { + const kind = + self.containerState.type || + (code === 42 || code === 43 || code === 45 + ? 'listUnordered' + : 'listOrdered'); + if ( + kind === 'listUnordered' + ? !self.containerState.marker || code === self.containerState.marker + : asciiDigit(code) + ) { + if (!self.containerState.type) { + self.containerState.type = kind; + effects.enter(kind, { + _container: true + }); + } + if (kind === 'listUnordered') { + effects.enter('listItemPrefix'); + return code === 42 || code === 45 + ? effects.check(thematicBreak, nok, atMarker)(code) + : atMarker(code) + } + if (!self.interrupt || code === 49) { + effects.enter('listItemPrefix'); + effects.enter('listItemValue'); + return inside(code) + } + } + return nok(code) + } + + /** @type {State} */ + function inside(code) { + if (asciiDigit(code) && ++size < 10) { + effects.consume(code); + return inside + } + if ( + (!self.interrupt || size < 2) && + (self.containerState.marker + ? code === self.containerState.marker + : code === 41 || code === 46) + ) { + effects.exit('listItemValue'); + return atMarker(code) + } + return nok(code) + } + + /** + * @type {State} + **/ + function atMarker(code) { + effects.enter('listItemMarker'); + effects.consume(code); + effects.exit('listItemMarker'); + self.containerState.marker = self.containerState.marker || code; + return effects.check( + blankLine, + // Can’t be empty when interrupting. + self.interrupt ? nok : onBlank, + effects.attempt( + listItemPrefixWhitespaceConstruct, + endOfPrefix, + otherPrefix + ) + ) + } + + /** @type {State} */ + function onBlank(code) { + self.containerState.initialBlankLine = true; + initialSize++; + return endOfPrefix(code) + } + + /** @type {State} */ + function otherPrefix(code) { + if (markdownSpace(code)) { + effects.enter('listItemPrefixWhitespace'); + effects.consume(code); + effects.exit('listItemPrefixWhitespace'); + return endOfPrefix + } + return nok(code) + } + + /** @type {State} */ + function endOfPrefix(code) { + self.containerState.size = + initialSize + + self.sliceSerialize(effects.exit('listItemPrefix'), true).length; + return ok(code) + } +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListContinuation(effects, ok, nok) { + const self = this; + self.containerState._closeFlow = undefined; + return effects.check(blankLine, onBlank, notBlank) + + /** @type {State} */ + function onBlank(code) { + self.containerState.furtherBlankLines = + self.containerState.furtherBlankLines || + self.containerState.initialBlankLine; + + // We have a blank line. + // Still, try to consume at most the items size. + return factorySpace( + effects, + ok, + 'listItemIndent', + self.containerState.size + 1 + )(code) + } + + /** @type {State} */ + function notBlank(code) { + if (self.containerState.furtherBlankLines || !markdownSpace(code)) { + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return notInCurrentItem(code) + } + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) + } + + /** @type {State} */ + function notInCurrentItem(code) { + // While we do continue, we signal that the flow should be closed. + self.containerState._closeFlow = true; + // As we’re closing flow, we’re no longer interrupting. + self.interrupt = undefined; + // Always populated by defaults. + + return factorySpace( + effects, + effects.attempt(list, ok, nok), + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeIndent(effects, ok, nok) { + const self = this; + return factorySpace( + effects, + afterPrefix, + 'listItemIndent', + self.containerState.size + 1 + ) + + /** @type {State} */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'listItemIndent' && + tail[2].sliceSerialize(tail[1], true).length === self.containerState.size + ? ok(code) + : nok(code) + } +} + +/** + * @type {Exiter} + * @this {TokenizeContext} + */ +function tokenizeListEnd(effects) { + effects.exit(this.containerState.type); +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListItemPrefixWhitespace(effects, ok, nok) { + const self = this; + + // Always populated by defaults. + + return factorySpace( + effects, + afterPrefix, + 'listItemPrefixWhitespace', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + 1 + ) + + /** @type {State} */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return !markdownSpace(code) && + tail && + tail[1].type === 'listItemPrefixWhitespace' + ? ok(code) + : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const setextUnderline = { + name: 'setextUnderline', + tokenize: tokenizeSetextUnderline, + resolveTo: resolveToSetextUnderline +}; + +/** @type {Resolver} */ +function resolveToSetextUnderline(events, context) { + // To do: resolve like `markdown-rs`. + let index = events.length; + /** @type {number | undefined} */ + let content; + /** @type {number | undefined} */ + let text; + /** @type {number | undefined} */ + let definition; + + // Find the opening of the content. + // It’ll always exist: we don’t tokenize if it isn’t there. + while (index--) { + if (events[index][0] === 'enter') { + if (events[index][1].type === 'content') { + content = index; + break + } + if (events[index][1].type === 'paragraph') { + text = index; + } + } + // Exit + else { + if (events[index][1].type === 'content') { + // Remove the content end (if needed we’ll add it later) + events.splice(index, 1); + } + if (!definition && events[index][1].type === 'definition') { + definition = index; + } + } + } + const heading = { + type: 'setextHeading', + start: Object.assign({}, events[text][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + + // Change the paragraph to setext heading text. + events[text][1].type = 'setextHeadingText'; + + // If we have definitions in the content, we’ll keep on having content, + // but we need move it. + if (definition) { + events.splice(text, 0, ['enter', heading, context]); + events.splice(definition + 1, 0, ['exit', events[content][1], context]); + events[content][1].end = Object.assign({}, events[definition][1].end); + } else { + events[content][1] = heading; + } + + // Add the heading exit at the end. + events.push(['exit', heading, context]); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeSetextUnderline(effects, ok, nok) { + const self = this; + /** @type {NonNullable} */ + let marker; + return start + + /** + * At start of heading (setext) underline. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + let index = self.events.length; + /** @type {boolean | undefined} */ + let paragraph; + // Find an opening. + while (index--) { + // Skip enter/exit of line ending, line prefix, and content. + // We can now either have a definition or a paragraph. + if ( + self.events[index][1].type !== 'lineEnding' && + self.events[index][1].type !== 'linePrefix' && + self.events[index][1].type !== 'content' + ) { + paragraph = self.events[index][1].type === 'paragraph'; + break + } + } + + // To do: handle lazy/pierce like `markdown-rs`. + // To do: parse indent like `markdown-rs`. + if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { + effects.enter('setextHeadingLine'); + marker = code; + return before(code) + } + return nok(code) + } + + /** + * After optional whitespace, at `-` or `=`. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('setextHeadingLineSequence'); + return inside(code) + } + + /** + * In sequence. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === marker) { + effects.consume(code); + return inside + } + effects.exit('setextHeadingLineSequence'); + return markdownSpace(code) + ? factorySpace(effects, after, 'lineSuffix')(code) + : after(code) + } + + /** + * After sequence, after optional whitespace. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('setextHeadingLine'); + return ok(code) + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** @type {InitialConstruct} */ +const flow$1 = { + tokenize: initializeFlow +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeFlow(effects) { + const self = this; + const initial = effects.attempt( + // Try to parse a blank line. + blankLine, + atBlankEnding, + // Try to parse initial flow (essentially, only code). + effects.attempt( + this.parser.constructs.flowInitial, + afterConstruct, + factorySpace( + effects, + effects.attempt( + this.parser.constructs.flow, + afterConstruct, + effects.attempt(content, afterConstruct) + ), + 'linePrefix' + ) + ) + ); + return initial + + /** @type {State} */ + function atBlankEnding(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEndingBlank'); + effects.consume(code); + effects.exit('lineEndingBlank'); + self.currentConstruct = undefined; + return initial + } + + /** @type {State} */ + function afterConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + self.currentConstruct = undefined; + return initial + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +const resolver = { + resolveAll: createResolver() +}; +const string$1 = initializeFactory('string'); +const text$1 = initializeFactory('text'); + +/** + * @param {'string' | 'text'} field + * @returns {InitialConstruct} + */ +function initializeFactory(field) { + return { + tokenize: initializeText, + resolveAll: createResolver( + field === 'text' ? resolveAllLineSuffixes : undefined + ) + } + + /** + * @this {TokenizeContext} + * @type {Initializer} + */ + function initializeText(effects) { + const self = this; + const constructs = this.parser.constructs[field]; + const text = effects.attempt(constructs, start, notText); + return start + + /** @type {State} */ + function start(code) { + return atBreak(code) ? text(code) : notText(code) + } + + /** @type {State} */ + function notText(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('data'); + effects.consume(code); + return data + } + + /** @type {State} */ + function data(code) { + if (atBreak(code)) { + effects.exit('data'); + return text(code) + } + + // Data. + effects.consume(code); + return data + } + + /** + * @param {Code} code + * @returns {boolean} + */ + function atBreak(code) { + if (code === null) { + return true + } + const list = constructs[code]; + let index = -1; + if (list) { + // Always populated by defaults. + + while (++index < list.length) { + const item = list[index]; + if (!item.previous || item.previous.call(self, self.previous)) { + return true + } + } + } + return false + } + } +} + +/** + * @param {Resolver | undefined} [extraResolver] + * @returns {Resolver} + */ +function createResolver(extraResolver) { + return resolveAllText + + /** @type {Resolver} */ + function resolveAllText(events, context) { + let index = -1; + /** @type {number | undefined} */ + let enter; + + // A rather boring computation (to merge adjacent `data` events) which + // improves mm performance by 29%. + while (++index <= events.length) { + if (enter === undefined) { + if (events[index] && events[index][1].type === 'data') { + enter = index; + index++; + } + } else if (!events[index] || events[index][1].type !== 'data') { + // Don’t do anything if there is one data token. + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + index = enter + 2; + } + enter = undefined; + } + } + return extraResolver ? extraResolver(events, context) : events + } +} + +/** + * A rather ugly set of instructions which again looks at chunks in the input + * stream. + * The reason to do this here is that it is *much* faster to parse in reverse. + * And that we can’t hook into `null` to split the line suffix before an EOF. + * To do: figure out if we can make this into a clean utility, or even in core. + * As it will be useful for GFMs literal autolink extension (and maybe even + * tables?) + * + * @type {Resolver} + */ +function resolveAllLineSuffixes(events, context) { + let eventIndex = 0; // Skip first. + + while (++eventIndex <= events.length) { + if ( + (eventIndex === events.length || + events[eventIndex][1].type === 'lineEnding') && + events[eventIndex - 1][1].type === 'data' + ) { + const data = events[eventIndex - 1][1]; + const chunks = context.sliceStream(data); + let index = chunks.length; + let bufferIndex = -1; + let size = 0; + /** @type {boolean | undefined} */ + let tabs; + while (index--) { + const chunk = chunks[index]; + if (typeof chunk === 'string') { + bufferIndex = chunk.length; + while (chunk.charCodeAt(bufferIndex - 1) === 32) { + size++; + bufferIndex--; + } + if (bufferIndex) break + bufferIndex = -1; + } + // Number + else if (chunk === -2) { + tabs = true; + size++; + } else if (chunk === -1) ; else { + // Replacement character, exit. + index++; + break + } + } + if (size) { + const token = { + type: + eventIndex === events.length || tabs || size < 2 + ? 'lineSuffix' + : 'hardBreakTrailing', + start: { + line: data.end.line, + column: data.end.column - size, + offset: data.end.offset - size, + _index: data.start._index + index, + _bufferIndex: index + ? bufferIndex + : data.start._bufferIndex + bufferIndex + }, + end: Object.assign({}, data.end) + }; + data.end = Object.assign({}, token.start); + if (data.start.offset === data.end.offset) { + Object.assign(data, token); + } else { + events.splice( + eventIndex, + 0, + ['enter', token, context], + ['exit', token, context] + ); + eventIndex += 2; + } + } + eventIndex++; + } + } + return events +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ConstructRecord} ConstructRecord + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenType} TokenType + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** + * Create a tokenizer. + * Tokenizers deal with one type of data (e.g., containers, flow, text). + * The parser is the object dealing with it all. + * `initialize` works like other constructs, except that only its `tokenize` + * function is used, in which case it doesn’t receive an `ok` or `nok`. + * `from` can be given to set the point before the first character, although + * when further lines are indented, they must be set with `defineSkip`. + * + * @param {ParseContext} parser + * @param {InitialConstruct} initialize + * @param {Omit | undefined} [from] + * @returns {TokenizeContext} + */ +function createTokenizer(parser, initialize, from) { + /** @type {Point} */ + let point = Object.assign( + from + ? Object.assign({}, from) + : { + line: 1, + column: 1, + offset: 0 + }, + { + _index: 0, + _bufferIndex: -1 + } + ); + /** @type {Record} */ + const columnStart = {}; + /** @type {Array} */ + const resolveAllConstructs = []; + /** @type {Array} */ + let chunks = []; + /** @type {Array} */ + let stack = []; + + /** + * Tools used for tokenizing. + * + * @type {Effects} + */ + const effects = { + consume, + enter, + exit, + attempt: constructFactory(onsuccessfulconstruct), + check: constructFactory(onsuccessfulcheck), + interrupt: constructFactory(onsuccessfulcheck, { + interrupt: true + }) + }; + + /** + * State and tools for resolving and serializing. + * + * @type {TokenizeContext} + */ + const context = { + previous: null, + code: null, + containerState: {}, + events: [], + parser, + sliceStream, + sliceSerialize, + now, + defineSkip, + write + }; + + /** + * The state function. + * + * @type {State | void} + */ + let state = initialize.tokenize.call(context, effects); + if (initialize.resolveAll) { + resolveAllConstructs.push(initialize); + } + return context + + /** @type {TokenizeContext['write']} */ + function write(slice) { + chunks = push(chunks, slice); + main(); + + // Exit if we’re not done, resolve might change stuff. + if (chunks[chunks.length - 1] !== null) { + return [] + } + addResult(initialize, 0); + + // Otherwise, resolve, and exit. + context.events = resolveAll(resolveAllConstructs, context.events, context); + return context.events + } + + // + // Tools. + // + + /** @type {TokenizeContext['sliceSerialize']} */ + function sliceSerialize(token, expandTabs) { + return serializeChunks(sliceStream(token), expandTabs) + } + + /** @type {TokenizeContext['sliceStream']} */ + function sliceStream(token) { + return sliceChunks(chunks, token) + } + + /** @type {TokenizeContext['now']} */ + function now() { + // This is a hot path, so we clone manually instead of `Object.assign({}, point)` + const {line, column, offset, _index, _bufferIndex} = point; + return { + line, + column, + offset, + _index, + _bufferIndex + } + } + + /** @type {TokenizeContext['defineSkip']} */ + function defineSkip(value) { + columnStart[value.line] = value.column; + accountForPotentialSkip(); + } + + // + // State management. + // + + /** + * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by + * `consume`). + * Here is where we walk through the chunks, which either include strings of + * several characters, or numerical character codes. + * The reason to do this in a loop instead of a call is so the stack can + * drain. + * + * @returns {void} + */ + function main() { + /** @type {number} */ + let chunkIndex; + while (point._index < chunks.length) { + const chunk = chunks[point._index]; + + // If we’re in a buffer chunk, loop through it. + if (typeof chunk === 'string') { + chunkIndex = point._index; + if (point._bufferIndex < 0) { + point._bufferIndex = 0; + } + while ( + point._index === chunkIndex && + point._bufferIndex < chunk.length + ) { + go(chunk.charCodeAt(point._bufferIndex)); + } + } else { + go(chunk); + } + } + } + + /** + * Deal with one code. + * + * @param {Code} code + * @returns {void} + */ + function go(code) { + state = state(code); + } + + /** @type {Effects['consume']} */ + function consume(code) { + if (markdownLineEnding(code)) { + point.line++; + point.column = 1; + point.offset += code === -3 ? 2 : 1; + accountForPotentialSkip(); + } else if (code !== -1) { + point.column++; + point.offset++; + } + + // Not in a string chunk. + if (point._bufferIndex < 0) { + point._index++; + } else { + point._bufferIndex++; + + // At end of string chunk. + // @ts-expect-error Points w/ non-negative `_bufferIndex` reference + // strings. + if (point._bufferIndex === chunks[point._index].length) { + point._bufferIndex = -1; + point._index++; + } + } + + // Expose the previous character. + context.previous = code; + } + + /** @type {Effects['enter']} */ + function enter(type, fields) { + /** @type {Token} */ + // @ts-expect-error Patch instead of assign required fields to help GC. + const token = fields || {}; + token.type = type; + token.start = now(); + context.events.push(['enter', token, context]); + stack.push(token); + return token + } + + /** @type {Effects['exit']} */ + function exit(type) { + const token = stack.pop(); + token.end = now(); + context.events.push(['exit', token, context]); + return token + } + + /** + * Use results. + * + * @type {ReturnHandle} + */ + function onsuccessfulconstruct(construct, info) { + addResult(construct, info.from); + } + + /** + * Discard results. + * + * @type {ReturnHandle} + */ + function onsuccessfulcheck(_, info) { + info.restore(); + } + + /** + * Factory to attempt/check/interrupt. + * + * @param {ReturnHandle} onreturn + * @param {{interrupt?: boolean | undefined} | undefined} [fields] + */ + function constructFactory(onreturn, fields) { + return hook + + /** + * Handle either an object mapping codes to constructs, a list of + * constructs, or a single construct. + * + * @param {Array | Construct | ConstructRecord} constructs + * @param {State} returnState + * @param {State | undefined} [bogusState] + * @returns {State} + */ + function hook(constructs, returnState, bogusState) { + /** @type {Array} */ + let listOfConstructs; + /** @type {number} */ + let constructIndex; + /** @type {Construct} */ + let currentConstruct; + /** @type {Info} */ + let info; + return Array.isArray(constructs) /* c8 ignore next 1 */ + ? handleListOfConstructs(constructs) + : 'tokenize' in constructs + ? // @ts-expect-error Looks like a construct. + handleListOfConstructs([constructs]) + : handleMapOfConstructs(constructs) + + /** + * Handle a list of construct. + * + * @param {ConstructRecord} map + * @returns {State} + */ + function handleMapOfConstructs(map) { + return start + + /** @type {State} */ + function start(code) { + const def = code !== null && map[code]; + const all = code !== null && map.null; + const list = [ + // To do: add more extension tests. + /* c8 ignore next 2 */ + ...(Array.isArray(def) ? def : def ? [def] : []), + ...(Array.isArray(all) ? all : all ? [all] : []) + ]; + return handleListOfConstructs(list)(code) + } + } + + /** + * Handle a list of construct. + * + * @param {Array} list + * @returns {State} + */ + function handleListOfConstructs(list) { + listOfConstructs = list; + constructIndex = 0; + if (list.length === 0) { + return bogusState + } + return handleConstruct(list[constructIndex]) + } + + /** + * Handle a single construct. + * + * @param {Construct} construct + * @returns {State} + */ + function handleConstruct(construct) { + return start + + /** @type {State} */ + function start(code) { + // To do: not needed to store if there is no bogus state, probably? + // Currently doesn’t work because `inspect` in document does a check + // w/o a bogus, which doesn’t make sense. But it does seem to help perf + // by not storing. + info = store(); + currentConstruct = construct; + if (!construct.partial) { + context.currentConstruct = construct; + } + + // Always populated by defaults. + + if ( + construct.name && + context.parser.constructs.disable.null.includes(construct.name) + ) { + return nok() + } + return construct.tokenize.call( + // If we do have fields, create an object w/ `context` as its + // prototype. + // This allows a “live binding”, which is needed for `interrupt`. + fields ? Object.assign(Object.create(context), fields) : context, + effects, + ok, + nok + )(code) + } + } + + /** @type {State} */ + function ok(code) { + onreturn(currentConstruct, info); + return returnState + } + + /** @type {State} */ + function nok(code) { + info.restore(); + if (++constructIndex < listOfConstructs.length) { + return handleConstruct(listOfConstructs[constructIndex]) + } + return bogusState + } + } + } + + /** + * @param {Construct} construct + * @param {number} from + * @returns {void} + */ + function addResult(construct, from) { + if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { + resolveAllConstructs.push(construct); + } + if (construct.resolve) { + splice( + context.events, + from, + context.events.length - from, + construct.resolve(context.events.slice(from), context) + ); + } + if (construct.resolveTo) { + context.events = construct.resolveTo(context.events, context); + } + } + + /** + * Store state. + * + * @returns {Info} + */ + function store() { + const startPoint = now(); + const startPrevious = context.previous; + const startCurrentConstruct = context.currentConstruct; + const startEventsIndex = context.events.length; + const startStack = Array.from(stack); + return { + restore, + from: startEventsIndex + } + + /** + * Restore state. + * + * @returns {void} + */ + function restore() { + point = startPoint; + context.previous = startPrevious; + context.currentConstruct = startCurrentConstruct; + context.events.length = startEventsIndex; + stack = startStack; + accountForPotentialSkip(); + } + } + + /** + * Move the current point a bit forward in the line when it’s on a column + * skip. + * + * @returns {void} + */ + function accountForPotentialSkip() { + if (point.line in columnStart && point.column < 2) { + point.column = columnStart[point.line]; + point.offset += columnStart[point.line] - 1; + } + } +} + +/** + * Get the chunks from a slice of chunks in the range of a token. + * + * @param {Array} chunks + * @param {Pick} token + * @returns {Array} + */ +function sliceChunks(chunks, token) { + const startIndex = token.start._index; + const startBufferIndex = token.start._bufferIndex; + const endIndex = token.end._index; + const endBufferIndex = token.end._bufferIndex; + /** @type {Array} */ + let view; + if (startIndex === endIndex) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; + } else { + view = chunks.slice(startIndex, endIndex); + if (startBufferIndex > -1) { + const head = view[0]; + if (typeof head === 'string') { + view[0] = head.slice(startBufferIndex); + } else { + view.shift(); + } + } + if (endBufferIndex > 0) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view.push(chunks[endIndex].slice(0, endBufferIndex)); + } + } + return view +} + +/** + * Get the string value of a slice of chunks. + * + * @param {Array} chunks + * @param {boolean | undefined} [expandTabs=false] + * @returns {string} + */ +function serializeChunks(chunks, expandTabs) { + let index = -1; + /** @type {Array} */ + const result = []; + /** @type {boolean | undefined} */ + let atTab; + while (++index < chunks.length) { + const chunk = chunks[index]; + /** @type {string} */ + let value; + if (typeof chunk === 'string') { + value = chunk; + } else + switch (chunk) { + case -5: { + value = '\r'; + break + } + case -4: { + value = '\n'; + break + } + case -3: { + value = '\r' + '\n'; + break + } + case -2: { + value = expandTabs ? ' ' : '\t'; + break + } + case -1: { + if (!expandTabs && atTab) continue + value = ' '; + break + } + default: { + // Currently only replacement character. + value = String.fromCharCode(chunk); + } + } + atTab = chunk === -2; + result.push(value); + } + return result.join('') +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + */ + + +/** @satisfies {Extension['document']} */ +const document = { + [42]: list, + [43]: list, + [45]: list, + [48]: list, + [49]: list, + [50]: list, + [51]: list, + [52]: list, + [53]: list, + [54]: list, + [55]: list, + [56]: list, + [57]: list, + [62]: blockQuote +}; + +/** @satisfies {Extension['contentInitial']} */ +const contentInitial = { + [91]: definition +}; + +/** @satisfies {Extension['flowInitial']} */ +const flowInitial = { + [-2]: codeIndented, + [-1]: codeIndented, + [32]: codeIndented +}; + +/** @satisfies {Extension['flow']} */ +const flow = { + [35]: headingAtx, + [42]: thematicBreak, + [45]: [setextUnderline, thematicBreak], + [60]: htmlFlow, + [61]: setextUnderline, + [95]: thematicBreak, + [96]: codeFenced, + [126]: codeFenced +}; + +/** @satisfies {Extension['string']} */ +const string = { + [38]: characterReference, + [92]: characterEscape +}; + +/** @satisfies {Extension['text']} */ +const text = { + [-5]: lineEnding, + [-4]: lineEnding, + [-3]: lineEnding, + [33]: labelStartImage, + [38]: characterReference, + [42]: attention, + [60]: [autolink, htmlText], + [91]: labelStartLink, + [92]: [hardBreakEscape, characterEscape], + [93]: labelEnd, + [95]: attention, + [96]: codeText +}; + +/** @satisfies {Extension['insideSpan']} */ +const insideSpan = { + null: [attention, resolver] +}; + +/** @satisfies {Extension['attentionMarkers']} */ +const attentionMarkers = { + null: [42, 95] +}; + +/** @satisfies {Extension['disable']} */ +const disable = { + null: [] +}; + +var defaultConstructs = /*#__PURE__*/Object.freeze({ + __proto__: null, + attentionMarkers: attentionMarkers, + contentInitial: contentInitial, + disable: disable, + document: document, + flow: flow, + flowInitial: flowInitial, + insideSpan: insideSpan, + string: string, + text: text +}); + +/** + * @typedef {import('micromark-util-types').Create} Create + * @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + */ + + +/** + * @param {ParseOptions | null | undefined} [options] + * @returns {ParseContext} + */ +function parse(options) { + const settings = options || {}; + const constructs = + /** @type {FullNormalizedExtension} */ + combineExtensions([defaultConstructs, ...(settings.extensions || [])]); + + /** @type {ParseContext} */ + const parser = { + defined: [], + lazy: {}, + constructs, + content: create(content$1), + document: create(document$1), + flow: create(flow$1), + string: create(string$1), + text: create(text$1) + }; + return parser + + /** + * @param {InitialConstruct} initial + */ + function create(initial) { + return creator + /** @type {Create} */ + function creator(from) { + return createTokenizer(parser, initial, from) + } + } +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Value} Value + */ + +/** + * @callback Preprocessor + * @param {Value} value + * @param {Encoding | null | undefined} [encoding] + * @param {boolean | null | undefined} [end=false] + * @returns {Array} + */ + +const search = /[\0\t\n\r]/g; + +/** + * @returns {Preprocessor} + */ +function preprocess() { + let column = 1; + let buffer = ''; + /** @type {boolean | undefined} */ + let start = true; + /** @type {boolean | undefined} */ + let atCarriageReturn; + return preprocessor + + /** @type {Preprocessor} */ + function preprocessor(value, encoding, end) { + /** @type {Array} */ + const chunks = []; + /** @type {RegExpMatchArray | null} */ + let match; + /** @type {number} */ + let next; + /** @type {number} */ + let startPosition; + /** @type {number} */ + let endPosition; + /** @type {Code} */ + let code; + + // @ts-expect-error `Buffer` does allow an encoding. + value = buffer + value.toString(encoding); + startPosition = 0; + buffer = ''; + if (start) { + // To do: `markdown-rs` actually parses BOMs (byte order mark). + if (value.charCodeAt(0) === 65279) { + startPosition++; + } + start = undefined; + } + while (startPosition < value.length) { + search.lastIndex = startPosition; + match = search.exec(value); + endPosition = + match && match.index !== undefined ? match.index : value.length; + code = value.charCodeAt(endPosition); + if (!match) { + buffer = value.slice(startPosition); + break + } + if (code === 10 && startPosition === endPosition && atCarriageReturn) { + chunks.push(-3); + atCarriageReturn = undefined; + } else { + if (atCarriageReturn) { + chunks.push(-5); + atCarriageReturn = undefined; + } + if (startPosition < endPosition) { + chunks.push(value.slice(startPosition, endPosition)); + column += endPosition - startPosition; + } + switch (code) { + case 0: { + chunks.push(65533); + column++; + break + } + case 9: { + next = Math.ceil(column / 4) * 4; + chunks.push(-2); + while (column++ < next) chunks.push(-1); + break + } + case 10: { + chunks.push(-4); + column = 1; + break + } + default: { + atCarriageReturn = true; + column = 1; + } + } + } + startPosition = endPosition + 1; + } + if (end) { + if (atCarriageReturn) chunks.push(-5); + if (buffer) chunks.push(buffer); + chunks.push(null); + } + return chunks + } +} + +/** + * @typedef {import('micromark-util-types').Event} Event + */ + + +/** + * @param {Array} events + * @returns {Array} + */ +function postprocess(events) { + while (!subtokenize(events)) { + // Empty + } + return events +} + +/** + * Turn the number (in string form as either hexa- or plain decimal) coming from + * a numeric character reference into a character. + * + * Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes + * non-characters and control characters safe. + * + * @param {string} value + * Value to decode. + * @param {number} base + * Numeric base. + * @returns {string} + * Character. + */ +function decodeNumericCharacterReference(value, base) { + const code = Number.parseInt(value, base); + if ( + // C0 except for HT, LF, FF, CR, space. + code < 9 || + code === 11 || + (code > 13 && code < 32) || + // Control character (DEL) of C0, and C1 controls. + (code > 126 && code < 160) || + // Lone high surrogates and low surrogates. + (code > 55295 && code < 57344) || + // Noncharacters. + (code > 64975 && code < 65008) /* eslint-disable no-bitwise */ || + (code & 65535) === 65535 || + (code & 65535) === 65534 /* eslint-enable no-bitwise */ || + // Out of range + code > 1114111 + ) { + return '\uFFFD' + } + return String.fromCharCode(code) +} + +const characterEscapeOrReference = + /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; + +/** + * Decode markdown strings (which occur in places such as fenced code info + * strings, destinations, labels, and titles). + * + * The “string” content type allows character escapes and -references. + * This decodes those. + * + * @param {string} value + * Value to decode. + * @returns {string} + * Decoded value. + */ +function decodeString(value) { + return value.replace(characterEscapeOrReference, decode) +} + +/** + * @param {string} $0 + * @param {string} $1 + * @param {string} $2 + * @returns {string} + */ +function decode($0, $1, $2) { + if ($1) { + // Escape. + return $1 + } + + // Reference. + const head = $2.charCodeAt(0); + if (head === 35) { + const head = $2.charCodeAt(1); + const hex = head === 120 || head === 88; + return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10) + } + return decodeNamedCharacterReference($2) || $0 +} + +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Point} Point + * @typedef {import('unist').Position} Position + */ + +/** + * @typedef NodeLike + * @property {string} type + * @property {PositionLike | null | undefined} [position] + * + * @typedef PositionLike + * @property {PointLike | null | undefined} [start] + * @property {PointLike | null | undefined} [end] + * + * @typedef PointLike + * @property {number | null | undefined} [line] + * @property {number | null | undefined} [column] + * @property {number | null | undefined} [offset] + */ + +/** + * Serialize the positional info of a point, position (start and end points), + * or node. + * + * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] + * Node, position, or point. + * @returns {string} + * Pretty printed positional info of a node (`string`). + * + * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) + * or a point `l:c` (when given `point`), where `l` stands for line, `c` for + * column, `s` for `start`, and `e` for end. + * An empty string (`''`) is returned if the given value is neither `node`, + * `position`, nor `point`. + */ +function stringifyPosition(value) { + // Nothing. + if (!value || typeof value !== 'object') { + return '' + } + + // Node. + if ('position' in value || 'type' in value) { + return position(value.position) + } + + // Position. + if ('start' in value || 'end' in value) { + return position(value) + } + + // Point. + if ('line' in value || 'column' in value) { + return point$1(value) + } + + // ? + return '' +} + +/** + * @param {Point | PointLike | null | undefined} point + * @returns {string} + */ +function point$1(point) { + return index(point && point.line) + ':' + index(point && point.column) +} + +/** + * @param {Position | PositionLike | null | undefined} pos + * @returns {string} + */ +function position(pos) { + return point$1(pos && pos.start) + '-' + point$1(pos && pos.end) +} + +/** + * @param {number | null | undefined} value + * @returns {number} + */ +function index(value) { + return value && typeof value === 'number' ? value : 1 +} + +/** + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Value} Value + * + * @typedef {import('unist').Parent} UnistParent + * @typedef {import('unist').Point} Point + * + * @typedef {import('mdast').PhrasingContent} PhrasingContent + * @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent + * @typedef {import('mdast').Content} Content + * @typedef {import('mdast').Break} Break + * @typedef {import('mdast').Blockquote} Blockquote + * @typedef {import('mdast').Code} Code + * @typedef {import('mdast').Definition} Definition + * @typedef {import('mdast').Emphasis} Emphasis + * @typedef {import('mdast').Heading} Heading + * @typedef {import('mdast').HTML} HTML + * @typedef {import('mdast').Image} Image + * @typedef {import('mdast').ImageReference} ImageReference + * @typedef {import('mdast').InlineCode} InlineCode + * @typedef {import('mdast').Link} Link + * @typedef {import('mdast').LinkReference} LinkReference + * @typedef {import('mdast').List} List + * @typedef {import('mdast').ListItem} ListItem + * @typedef {import('mdast').Paragraph} Paragraph + * @typedef {import('mdast').Root} Root + * @typedef {import('mdast').Strong} Strong + * @typedef {import('mdast').Text} Text + * @typedef {import('mdast').ThematicBreak} ThematicBreak + * @typedef {import('mdast').ReferenceType} ReferenceType + * @typedef {import('../index.js').CompileData} CompileData + */ + +const own = {}.hasOwnProperty; + +/** + * @param value + * Markdown to parse. + * @param encoding + * Character encoding for when `value` is `Buffer`. + * @param options + * Configuration. + * @returns + * mdast tree. + */ +const fromMarkdown = + /** + * @type {( + * ((value: Value, encoding: Encoding, options?: Options | null | undefined) => Root) & + * ((value: Value, options?: Options | null | undefined) => Root) + * )} + */ + + /** + * @param {Value} value + * @param {Encoding | Options | null | undefined} [encoding] + * @param {Options | null | undefined} [options] + * @returns {Root} + */ + function (value, encoding, options) { + if (typeof encoding !== 'string') { + options = encoding; + encoding = undefined; + } + return compiler(options)( + postprocess( + parse(options).document().write(preprocess()(value, encoding, true)) + ) + ) + }; + +/** + * Note this compiler only understand complete buffering, not streaming. + * + * @param {Options | null | undefined} [options] + */ +function compiler(options) { + /** @type {Config} */ + const config = { + transforms: [], + canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'], + enter: { + autolink: opener(link), + autolinkProtocol: onenterdata, + autolinkEmail: onenterdata, + atxHeading: opener(heading), + blockQuote: opener(blockQuote), + characterEscape: onenterdata, + characterReference: onenterdata, + codeFenced: opener(codeFlow), + codeFencedFenceInfo: buffer, + codeFencedFenceMeta: buffer, + codeIndented: opener(codeFlow, buffer), + codeText: opener(codeText, buffer), + codeTextData: onenterdata, + data: onenterdata, + codeFlowValue: onenterdata, + definition: opener(definition), + definitionDestinationString: buffer, + definitionLabelString: buffer, + definitionTitleString: buffer, + emphasis: opener(emphasis), + hardBreakEscape: opener(hardBreak), + hardBreakTrailing: opener(hardBreak), + htmlFlow: opener(html, buffer), + htmlFlowData: onenterdata, + htmlText: opener(html, buffer), + htmlTextData: onenterdata, + image: opener(image), + label: buffer, + link: opener(link), + listItem: opener(listItem), + listItemValue: onenterlistitemvalue, + listOrdered: opener(list, onenterlistordered), + listUnordered: opener(list), + paragraph: opener(paragraph), + reference: onenterreference, + referenceString: buffer, + resourceDestinationString: buffer, + resourceTitleString: buffer, + setextHeading: opener(heading), + strong: opener(strong), + thematicBreak: opener(thematicBreak) + }, + exit: { + atxHeading: closer(), + atxHeadingSequence: onexitatxheadingsequence, + autolink: closer(), + autolinkEmail: onexitautolinkemail, + autolinkProtocol: onexitautolinkprotocol, + blockQuote: closer(), + characterEscapeValue: onexitdata, + characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, + characterReferenceMarkerNumeric: onexitcharacterreferencemarker, + characterReferenceValue: onexitcharacterreferencevalue, + codeFenced: closer(onexitcodefenced), + codeFencedFence: onexitcodefencedfence, + codeFencedFenceInfo: onexitcodefencedfenceinfo, + codeFencedFenceMeta: onexitcodefencedfencemeta, + codeFlowValue: onexitdata, + codeIndented: closer(onexitcodeindented), + codeText: closer(onexitcodetext), + codeTextData: onexitdata, + data: onexitdata, + definition: closer(), + definitionDestinationString: onexitdefinitiondestinationstring, + definitionLabelString: onexitdefinitionlabelstring, + definitionTitleString: onexitdefinitiontitlestring, + emphasis: closer(), + hardBreakEscape: closer(onexithardbreak), + hardBreakTrailing: closer(onexithardbreak), + htmlFlow: closer(onexithtmlflow), + htmlFlowData: onexitdata, + htmlText: closer(onexithtmltext), + htmlTextData: onexitdata, + image: closer(onexitimage), + label: onexitlabel, + labelText: onexitlabeltext, + lineEnding: onexitlineending, + link: closer(onexitlink), + listItem: closer(), + listOrdered: closer(), + listUnordered: closer(), + paragraph: closer(), + referenceString: onexitreferencestring, + resourceDestinationString: onexitresourcedestinationstring, + resourceTitleString: onexitresourcetitlestring, + resource: onexitresource, + setextHeading: closer(onexitsetextheading), + setextHeadingLineSequence: onexitsetextheadinglinesequence, + setextHeadingText: onexitsetextheadingtext, + strong: closer(), + thematicBreak: closer() + } + }; + configure(config, (options || {}).mdastExtensions || []); + + /** @type {CompileData} */ + const data = {}; + return compile + + /** + * Turn micromark events into an mdast tree. + * + * @param {Array} events + * Events. + * @returns {Root} + * mdast tree. + */ + function compile(events) { + /** @type {Root} */ + let tree = { + type: 'root', + children: [] + }; + /** @type {Omit} */ + const context = { + stack: [tree], + tokenStack: [], + config, + enter, + exit, + buffer, + resume, + setData, + getData + }; + /** @type {Array} */ + const listStack = []; + let index = -1; + while (++index < events.length) { + // We preprocess lists to add `listItem` tokens, and to infer whether + // items the list itself are spread out. + if ( + events[index][1].type === 'listOrdered' || + events[index][1].type === 'listUnordered' + ) { + if (events[index][0] === 'enter') { + listStack.push(index); + } else { + const tail = listStack.pop(); + index = prepareList(events, tail, index); + } + } + } + index = -1; + while (++index < events.length) { + const handler = config[events[index][0]]; + if (own.call(handler, events[index][1].type)) { + handler[events[index][1].type].call( + Object.assign( + { + sliceSerialize: events[index][2].sliceSerialize + }, + context + ), + events[index][1] + ); + } + } + + // Handle tokens still being open. + if (context.tokenStack.length > 0) { + const tail = context.tokenStack[context.tokenStack.length - 1]; + const handler = tail[1] || defaultOnError; + handler.call(context, undefined, tail[0]); + } + + // Figure out `root` position. + tree.position = { + start: point( + events.length > 0 + ? events[0][1].start + : { + line: 1, + column: 1, + offset: 0 + } + ), + end: point( + events.length > 0 + ? events[events.length - 2][1].end + : { + line: 1, + column: 1, + offset: 0 + } + ) + }; + + // Call transforms. + index = -1; + while (++index < config.transforms.length) { + tree = config.transforms[index](tree) || tree; + } + return tree + } + + /** + * @param {Array} events + * @param {number} start + * @param {number} length + * @returns {number} + */ + function prepareList(events, start, length) { + let index = start - 1; + let containerBalance = -1; + let listSpread = false; + /** @type {Token | undefined} */ + let listItem; + /** @type {number | undefined} */ + let lineIndex; + /** @type {number | undefined} */ + let firstBlankLineIndex; + /** @type {boolean | undefined} */ + let atMarker; + while (++index <= length) { + const event = events[index]; + if ( + event[1].type === 'listUnordered' || + event[1].type === 'listOrdered' || + event[1].type === 'blockQuote' + ) { + if (event[0] === 'enter') { + containerBalance++; + } else { + containerBalance--; + } + atMarker = undefined; + } else if (event[1].type === 'lineEndingBlank') { + if (event[0] === 'enter') { + if ( + listItem && + !atMarker && + !containerBalance && + !firstBlankLineIndex + ) { + firstBlankLineIndex = index; + } + atMarker = undefined; + } + } else if ( + event[1].type === 'linePrefix' || + event[1].type === 'listItemValue' || + event[1].type === 'listItemMarker' || + event[1].type === 'listItemPrefix' || + event[1].type === 'listItemPrefixWhitespace' + ) ; else { + atMarker = undefined; + } + if ( + (!containerBalance && + event[0] === 'enter' && + event[1].type === 'listItemPrefix') || + (containerBalance === -1 && + event[0] === 'exit' && + (event[1].type === 'listUnordered' || + event[1].type === 'listOrdered')) + ) { + if (listItem) { + let tailIndex = index; + lineIndex = undefined; + while (tailIndex--) { + const tailEvent = events[tailIndex]; + if ( + tailEvent[1].type === 'lineEnding' || + tailEvent[1].type === 'lineEndingBlank' + ) { + if (tailEvent[0] === 'exit') continue + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + listSpread = true; + } + tailEvent[1].type = 'lineEnding'; + lineIndex = tailIndex; + } else if ( + tailEvent[1].type === 'linePrefix' || + tailEvent[1].type === 'blockQuotePrefix' || + tailEvent[1].type === 'blockQuotePrefixWhitespace' || + tailEvent[1].type === 'blockQuoteMarker' || + tailEvent[1].type === 'listItemIndent' + ) ; else { + break + } + } + if ( + firstBlankLineIndex && + (!lineIndex || firstBlankLineIndex < lineIndex) + ) { + listItem._spread = true; + } + + // Fix position. + listItem.end = Object.assign( + {}, + lineIndex ? events[lineIndex][1].start : event[1].end + ); + events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); + index++; + length++; + } + + // Create a new list item. + if (event[1].type === 'listItemPrefix') { + listItem = { + type: 'listItem', + _spread: false, + start: Object.assign({}, event[1].start), + // @ts-expect-error: we’ll add `end` in a second. + end: undefined + }; + // @ts-expect-error: `listItem` is most definitely defined, TS... + events.splice(index, 0, ['enter', listItem, event[2]]); + index++; + length++; + firstBlankLineIndex = undefined; + atMarker = true; + } + } + } + events[start][1]._spread = listSpread; + return length + } + + /** + * Set data. + * + * @template {keyof CompileData} Key + * Field type. + * @param {Key} key + * Key of field. + * @param {CompileData[Key]} [value] + * New value. + * @returns {void} + * Nothing. + */ + function setData(key, value) { + data[key] = value; + } + + /** + * Get data. + * + * @template {keyof CompileData} Key + * Field type. + * @param {Key} key + * Key of field. + * @returns {CompileData[Key]} + * Value. + */ + function getData(key) { + return data[key] + } + + /** + * Create an opener handle. + * + * @param {(token: Token) => Node} create + * Create a node. + * @param {Handle} [and] + * Optional function to also run. + * @returns {Handle} + * Handle. + */ + function opener(create, and) { + return open + + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + function open(token) { + enter.call(this, create(token), token); + if (and) and.call(this, token); + } + } + + /** + * @this {CompileContext} + * @returns {void} + */ + function buffer() { + this.stack.push({ + type: 'fragment', + children: [] + }); + } + + /** + * @template {Node} Kind + * Node type. + * @this {CompileContext} + * Context. + * @param {Kind} node + * Node to enter. + * @param {Token} token + * Corresponding token. + * @param {OnEnterError | undefined} [errorHandler] + * Handle the case where this token is open, but it is closed by something else. + * @returns {Kind} + * The given node. + */ + function enter(node, token, errorHandler) { + const parent = this.stack[this.stack.length - 1]; + // @ts-expect-error: Assume `Node` can exist as a child of `parent`. + parent.children.push(node); + this.stack.push(node); + this.tokenStack.push([token, errorHandler]); + // @ts-expect-error: `end` will be patched later. + node.position = { + start: point(token.start) + }; + return node + } + + /** + * Create a closer handle. + * + * @param {Handle} [and] + * Optional function to also run. + * @returns {Handle} + * Handle. + */ + function closer(and) { + return close + + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + function close(token) { + if (and) and.call(this, token); + exit.call(this, token); + } + } + + /** + * @this {CompileContext} + * Context. + * @param {Token} token + * Corresponding token. + * @param {OnExitError | undefined} [onExitError] + * Handle the case where another token is open. + * @returns {Node} + * The closed node. + */ + function exit(token, onExitError) { + const node = this.stack.pop(); + const open = this.tokenStack.pop(); + if (!open) { + throw new Error( + 'Cannot close `' + + token.type + + '` (' + + stringifyPosition({ + start: token.start, + end: token.end + }) + + '): it’s not open' + ) + } else if (open[0].type !== token.type) { + if (onExitError) { + onExitError.call(this, token, open[0]); + } else { + const handler = open[1] || defaultOnError; + handler.call(this, token, open[0]); + } + } + node.position.end = point(token.end); + return node + } + + /** + * @this {CompileContext} + * @returns {string} + */ + function resume() { + return toString(this.stack.pop()) + } + + // + // Handlers. + // + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onenterlistordered() { + setData('expectingFirstListItemValue', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onenterlistitemvalue(token) { + if (getData('expectingFirstListItemValue')) { + const ancestor = this.stack[this.stack.length - 2]; + ancestor.start = Number.parseInt(this.sliceSerialize(token), 10); + setData('expectingFirstListItemValue'); + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfenceinfo() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.lang = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfencemeta() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.meta = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfence() { + // Exit if this is the closing fence. + if (getData('flowCodeInside')) return + this.buffer(); + setData('flowCodeInside', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefenced() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); + setData('flowCodeInside'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodeindented() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data.replace(/(\r?\n|\r)$/g, ''); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitionlabelstring(token) { + const label = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.label = label; + node.identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitiontitlestring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.title = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitiondestinationstring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.url = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitatxheadingsequence(token) { + const node = this.stack[this.stack.length - 1]; + if (!node.depth) { + const depth = this.sliceSerialize(token).length; + node.depth = depth; + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheadingtext() { + setData('setextHeadingSlurpLineEnding', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheadinglinesequence(token) { + const node = this.stack[this.stack.length - 1]; + node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheading() { + setData('setextHeadingSlurpLineEnding'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onenterdata(token) { + const node = this.stack[this.stack.length - 1]; + let tail = node.children[node.children.length - 1]; + if (!tail || tail.type !== 'text') { + // Add a new text node. + tail = text(); + // @ts-expect-error: we’ll add `end` later. + tail.position = { + start: point(token.start) + }; + // @ts-expect-error: Assume `parent` accepts `text`. + node.children.push(tail); + } + this.stack.push(tail); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitdata(token) { + const tail = this.stack.pop(); + tail.value += this.sliceSerialize(token); + tail.position.end = point(token.end); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlineending(token) { + const context = this.stack[this.stack.length - 1]; + // If we’re at a hard break, include the line ending in there. + if (getData('atHardBreak')) { + const tail = context.children[context.children.length - 1]; + tail.position.end = point(token.end); + setData('atHardBreak'); + return + } + if ( + !getData('setextHeadingSlurpLineEnding') && + config.canContainEols.includes(context.type) + ) { + onenterdata.call(this, token); + onexitdata.call(this, token); + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithardbreak() { + setData('atHardBreak', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithtmlflow() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithtmltext() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitcodetext() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlink() { + const node = this.stack[this.stack.length - 1]; + // Note: there are also `identifier` and `label` fields on this link node! + // These are used / cleaned here. + // To do: clean. + if (getData('inReference')) { + /** @type {ReferenceType} */ + const referenceType = getData('referenceType') || 'shortcut'; + node.type += 'Reference'; + // @ts-expect-error: mutate. + node.referenceType = referenceType; + // @ts-expect-error: mutate. + delete node.url; + delete node.title; + } else { + // @ts-expect-error: mutate. + delete node.identifier; + // @ts-expect-error: mutate. + delete node.label; + } + setData('referenceType'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitimage() { + const node = this.stack[this.stack.length - 1]; + // Note: there are also `identifier` and `label` fields on this link node! + // These are used / cleaned here. + // To do: clean. + if (getData('inReference')) { + /** @type {ReferenceType} */ + const referenceType = getData('referenceType') || 'shortcut'; + node.type += 'Reference'; + // @ts-expect-error: mutate. + node.referenceType = referenceType; + // @ts-expect-error: mutate. + delete node.url; + delete node.title; + } else { + // @ts-expect-error: mutate. + delete node.identifier; + // @ts-expect-error: mutate. + delete node.label; + } + setData('referenceType'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlabeltext(token) { + const string = this.sliceSerialize(token); + const ancestor = this.stack[this.stack.length - 2]; + // @ts-expect-error: stash this on the node, as it might become a reference + // later. + ancestor.label = decodeString(string); + // @ts-expect-error: same as above. + ancestor.identifier = normalizeIdentifier(string).toLowerCase(); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlabel() { + const fragment = this.stack[this.stack.length - 1]; + const value = this.resume(); + const node = this.stack[this.stack.length - 1]; + // Assume a reference. + setData('inReference', true); + if (node.type === 'link') { + /** @type {Array} */ + // @ts-expect-error: Assume static phrasing content. + const children = fragment.children; + node.children = children; + } else { + node.alt = value; + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresourcedestinationstring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.url = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresourcetitlestring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.title = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresource() { + setData('inReference'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onenterreference() { + setData('referenceType', 'collapsed'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitreferencestring(token) { + const label = this.resume(); + const node = this.stack[this.stack.length - 1]; + // @ts-expect-error: stash this on the node, as it might become a reference + // later. + node.label = label; + // @ts-expect-error: same as above. + node.identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + setData('referenceType', 'full'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitcharacterreferencemarker(token) { + setData('characterReferenceType', token.type); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcharacterreferencevalue(token) { + const data = this.sliceSerialize(token); + const type = getData('characterReferenceType'); + /** @type {string} */ + let value; + if (type) { + value = decodeNumericCharacterReference( + data, + type === 'characterReferenceMarkerNumeric' ? 10 : 16 + ); + setData('characterReferenceType'); + } else { + const result = decodeNamedCharacterReference(data); + value = result; + } + const tail = this.stack.pop(); + tail.value += value; + tail.position.end = point(token.end); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitautolinkprotocol(token) { + onexitdata.call(this, token); + const node = this.stack[this.stack.length - 1]; + node.url = this.sliceSerialize(token); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitautolinkemail(token) { + onexitdata.call(this, token); + const node = this.stack[this.stack.length - 1]; + node.url = 'mailto:' + this.sliceSerialize(token); + } + + // + // Creaters. + // + + /** @returns {Blockquote} */ + function blockQuote() { + return { + type: 'blockquote', + children: [] + } + } + + /** @returns {Code} */ + function codeFlow() { + return { + type: 'code', + lang: null, + meta: null, + value: '' + } + } + + /** @returns {InlineCode} */ + function codeText() { + return { + type: 'inlineCode', + value: '' + } + } + + /** @returns {Definition} */ + function definition() { + return { + type: 'definition', + identifier: '', + label: null, + title: null, + url: '' + } + } + + /** @returns {Emphasis} */ + function emphasis() { + return { + type: 'emphasis', + children: [] + } + } + + /** @returns {Heading} */ + function heading() { + // @ts-expect-error `depth` will be set later. + return { + type: 'heading', + depth: undefined, + children: [] + } + } + + /** @returns {Break} */ + function hardBreak() { + return { + type: 'break' + } + } + + /** @returns {HTML} */ + function html() { + return { + type: 'html', + value: '' + } + } + + /** @returns {Image} */ + function image() { + return { + type: 'image', + title: null, + url: '', + alt: null + } + } + + /** @returns {Link} */ + function link() { + return { + type: 'link', + title: null, + url: '', + children: [] + } + } + + /** + * @param {Token} token + * @returns {List} + */ + function list(token) { + return { + type: 'list', + ordered: token.type === 'listOrdered', + start: null, + spread: token._spread, + children: [] + } + } + + /** + * @param {Token} token + * @returns {ListItem} + */ + function listItem(token) { + return { + type: 'listItem', + spread: token._spread, + checked: null, + children: [] + } + } + + /** @returns {Paragraph} */ + function paragraph() { + return { + type: 'paragraph', + children: [] + } + } + + /** @returns {Strong} */ + function strong() { + return { + type: 'strong', + children: [] + } + } + + /** @returns {Text} */ + function text() { + return { + type: 'text', + value: '' + } + } + + /** @returns {ThematicBreak} */ + function thematicBreak() { + return { + type: 'thematicBreak' + } + } +} + +/** + * Copy a point-like value. + * + * @param {Point} d + * Point-like value. + * @returns {Point} + * unist point. + */ +function point(d) { + return { + line: d.line, + column: d.column, + offset: d.offset + } +} + +/** + * @param {Config} combined + * @param {Array>} extensions + * @returns {void} + */ +function configure(combined, extensions) { + let index = -1; + while (++index < extensions.length) { + const value = extensions[index]; + if (Array.isArray(value)) { + configure(combined, value); + } else { + extension(combined, value); + } + } +} + +/** + * @param {Config} combined + * @param {Extension} extension + * @returns {void} + */ +function extension(combined, extension) { + /** @type {keyof Extension} */ + let key; + for (key in extension) { + if (own.call(extension, key)) { + if (key === 'canContainEols') { + const right = extension[key]; + if (right) { + combined[key].push(...right); + } + } else if (key === 'transforms') { + const right = extension[key]; + if (right) { + combined[key].push(...right); + } + } else if (key === 'enter' || key === 'exit') { + const right = extension[key]; + if (right) { + Object.assign(combined[key], right); + } + } + } + } +} + +/** @type {OnEnterError} */ +function defaultOnError(left, right) { + if (left) { + throw new Error( + 'Cannot close `' + + left.type + + '` (' + + stringifyPosition({ + start: left.start, + end: left.end + }) + + '): a different token (`' + + right.type + + '`, ' + + stringifyPosition({ + start: right.start, + end: right.end + }) + + ') is open' + ) + } else { + throw new Error( + 'Cannot close document, a token (`' + + right.type + + '`, ' + + stringifyPosition({ + start: right.start, + end: right.end + }) + + ') is still open' + ) + } +} + +function preprocessMarkdown(markdown) { + const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, "\n"); + const withoutExtraSpaces = dedent(withoutMultipleNewlines); + return withoutExtraSpaces; +} +function markdownToLines(markdown) { + const preprocessedMarkdown = preprocessMarkdown(markdown); + const { children } = fromMarkdown(preprocessedMarkdown); + const lines = [[]]; + let currentLine = 0; + function processNode(node, parentType = "normal") { + if (node.type === "text") { + const textLines = node.value.split("\n"); + textLines.forEach((textLine, index) => { + if (index !== 0) { + currentLine++; + lines.push([]); + } + textLine.split(" ").forEach((word) => { + if (word) { + lines[currentLine].push({ content: word, type: parentType }); + } + }); + }); + } else if (node.type === "strong" || node.type === "emphasis") { + node.children.forEach((contentNode) => { + processNode(contentNode, node.type); + }); + } + } + children.forEach((treeNode) => { + if (treeNode.type === "paragraph") { + treeNode.children.forEach((contentNode) => { + processNode(contentNode); + }); + } + }); + return lines; +} +function markdownToHTML(markdown) { + const { children } = fromMarkdown(markdown); + function output(node) { + if (node.type === "text") { + return node.value.replace(/\n/g, "
"); + } else if (node.type === "strong") { + return `${node.children.map(output).join("")}`; + } else if (node.type === "emphasis") { + return `${node.children.map(output).join("")}`; + } else if (node.type === "paragraph") { + return `

${node.children.map(output).join("")}

`; + } + return `Unsupported markdown: ${node.type}`; + } + return children.map(output).join(""); +} +function splitTextToChars(text) { + if (Intl.Segmenter) { + return [...new Intl.Segmenter().segment(text)].map((s) => s.segment); + } + return [...text]; +} +function splitWordToFitWidth(checkFit, word) { + const characters = splitTextToChars(word.content); + return splitWordToFitWidthRecursion(checkFit, [], characters, word.type); +} +function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) { + if (remainingChars.length === 0) { + return [ + { content: usedChars.join(""), type }, + { content: "", type } + ]; + } + const [nextChar, ...rest] = remainingChars; + const newWord = [...usedChars, nextChar]; + if (checkFit([{ content: newWord.join(""), type }])) { + return splitWordToFitWidthRecursion(checkFit, newWord, rest, type); + } + if (usedChars.length === 0 && nextChar) { + usedChars.push(nextChar); + remainingChars.shift(); + } + return [ + { content: usedChars.join(""), type }, + { content: remainingChars.join(""), type } + ]; +} +function splitLineToFitWidth(line, checkFit) { + if (line.some(({ content }) => content.includes("\n"))) { + throw new Error("splitLineToFitWidth does not support newlines in the line"); + } + return splitLineToFitWidthRecursion(line, checkFit); +} +function splitLineToFitWidthRecursion(words, checkFit, lines = [], newLine = []) { + if (words.length === 0) { + if (newLine.length > 0) { + lines.push(newLine); + } + return lines.length > 0 ? lines : []; + } + let joiner = ""; + if (words[0].content === " ") { + joiner = " "; + words.shift(); + } + const nextWord = words.shift() ?? { content: " ", type: "normal" }; + const lineWithNextWord = [...newLine]; + if (joiner !== "") { + lineWithNextWord.push({ content: joiner, type: "normal" }); + } + lineWithNextWord.push(nextWord); + if (checkFit(lineWithNextWord)) { + return splitLineToFitWidthRecursion(words, checkFit, lines, lineWithNextWord); + } + if (newLine.length > 0) { + lines.push(newLine); + words.unshift(nextWord); + } else if (nextWord.content) { + const [line, rest] = splitWordToFitWidth(checkFit, nextWord); + lines.push([line]); + if (rest.content) { + words.unshift(rest); + } + } + return splitLineToFitWidthRecursion(words, checkFit, lines); +} +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr("style", styleFn); + } +} +function addHtmlSpan(element, node, width, classes, addBackground = false) { + const fo = element.append("foreignObject"); + const div = fo.append("xhtml:div"); + const label = node.label; + const labelClass = node.isNode ? "nodeLabel" : "edgeLabel"; + div.html( + ` + " + label + "" + ); + applyStyle(div, node.labelStyle); + div.style("display", "table-cell"); + div.style("white-space", "nowrap"); + div.style("max-width", width + "px"); + div.attr("xmlns", "http://www.w3.org/1999/xhtml"); + if (addBackground) { + div.attr("class", "labelBkg"); + } + let bbox = div.node().getBoundingClientRect(); + if (bbox.width === width) { + div.style("display", "table"); + div.style("white-space", "break-spaces"); + div.style("width", width + "px"); + bbox = div.node().getBoundingClientRect(); + } + fo.style("width", bbox.width); + fo.style("height", bbox.height); + return fo.node(); +} +function createTspan(textElement, lineIndex, lineHeight) { + return textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em"); +} +function computeWidthOfText(parentNode, lineHeight, line) { + const testElement = parentNode.append("text"); + const testSpan = createTspan(testElement, 1, lineHeight); + updateTextContentAndStyles(testSpan, line); + const textLength = testSpan.node().getComputedTextLength(); + testElement.remove(); + return textLength; +} +function computeDimensionOfText(parentNode, lineHeight, text) { + var _a; + const testElement = parentNode.append("text"); + const testSpan = createTspan(testElement, 1, lineHeight); + updateTextContentAndStyles(testSpan, [{ content: text, type: "normal" }]); + const textDimension = (_a = testSpan.node()) == null ? void 0 : _a.getBoundingClientRect(); + if (textDimension) { + testElement.remove(); + } + return textDimension; +} +function createFormattedText(width, g, structuredText, addBackground = false) { + const lineHeight = 1.1; + const labelGroup = g.append("g"); + const bkg = labelGroup.insert("rect").attr("class", "background"); + const textElement = labelGroup.append("text").attr("y", "-10.1"); + let lineIndex = 0; + for (const line of structuredText) { + const checkWidth = (line2) => computeWidthOfText(labelGroup, lineHeight, line2) <= width; + const linesUnderWidth = checkWidth(line) ? [line] : splitLineToFitWidth(line, checkWidth); + for (const preparedLine of linesUnderWidth) { + const tspan = createTspan(textElement, lineIndex, lineHeight); + updateTextContentAndStyles(tspan, preparedLine); + lineIndex++; + } + } + if (addBackground) { + const bbox = textElement.node().getBBox(); + const padding = 2; + bkg.attr("x", -padding).attr("y", -padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding); + return labelGroup.node(); + } else { + return textElement.node(); + } +} +function updateTextContentAndStyles(tspan, wrappedLine) { + tspan.text(""); + wrappedLine.forEach((word, index) => { + const innerTspan = tspan.append("tspan").attr("font-style", word.type === "emphasis" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", word.type === "strong" ? "bold" : "normal"); + if (index === 0) { + innerTspan.text(word.content); + } else { + innerTspan.text(" " + word.content); + } + }); +} +const createText = (el, text = "", { + style = "", + isTitle = false, + classes = "", + useHtmlLabels = true, + isNode = true, + width = 200, + addSvgBackground = false +} = {}) => { + log$1.info("createText", text, style, isTitle, classes, useHtmlLabels, isNode, addSvgBackground); + if (useHtmlLabels) { + const htmlText = markdownToHTML(text); + const node = { + isNode, + label: decodeEntities(htmlText).replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell: disable-line + (s) => `` + ), + labelStyle: style.replace("fill:", "color:") + }; + const vertexNode = addHtmlSpan(el, node, width, classes, addSvgBackground); + return vertexNode; + } else { + const structuredText = markdownToLines(text); + const svgLabel = createFormattedText(width, el, structuredText, addSvgBackground); + return svgLabel; + } +}; + +export { createText as a, computeDimensionOfText as c }; diff --git a/libs/marked/edges-066a5561-Bqw9g7uz.js b/libs/marked/edges-066a5561-Bqw9g7uz.js new file mode 100644 index 0000000..3d25270 --- /dev/null +++ b/libs/marked/edges-066a5561-Bqw9g7uz.js @@ -0,0 +1,1825 @@ +import { p as evaluate, c as getConfig, d as sanitizeText$2, b6 as decodeEntities, h as select, l as log$1, A as utils, F as curveBasis } from './index-Bd_FDXSq.js'; +import { a as createText } from './createText-ca0c5216-B9KlDTE8.js'; +import { l as line } from './line-DUwhS6kk.js'; + +const insertMarkers = (elem, markerArray, type, id) => { + markerArray.forEach((markerName) => { + markers[markerName](elem, type, id); + }); +}; +const extension = (elem, type, id) => { + log$1.trace("Making markers for ", id); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-extensionStart").attr("class", "marker extension " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-extensionEnd").attr("class", "marker extension " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"); +}; +const composition = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-compositionStart").attr("class", "marker composition " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-compositionEnd").attr("class", "marker composition " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); +}; +const aggregation = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-aggregationStart").attr("class", "marker aggregation " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-aggregationEnd").attr("class", "marker aggregation " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); +}; +const dependency = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-dependencyStart").attr("class", "marker dependency " + type).attr("refX", 6).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-dependencyEnd").attr("class", "marker dependency " + type).attr("refX", 13).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const lollipop = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-lollipopStart").attr("class", "marker lollipop " + type).attr("refX", 13).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("circle").attr("stroke", "black").attr("fill", "transparent").attr("cx", 7).attr("cy", 7).attr("r", 6); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-lollipopEnd").attr("class", "marker lollipop " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("circle").attr("stroke", "black").attr("fill", "transparent").attr("cx", 7).attr("cy", 7).attr("r", 6); +}; +const point = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-pointEnd").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 6).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-pointStart").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 4.5).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 5 L 10 10 L 10 0 z").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); +}; +const circle$1 = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-circleEnd").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 11).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("circle").attr("cx", "5").attr("cy", "5").attr("r", "5").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-circleStart").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", -1).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("circle").attr("cx", "5").attr("cy", "5").attr("r", "5").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); +}; +const cross = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-crossEnd").attr("class", "marker cross " + type).attr("viewBox", "0 0 11 11").attr("refX", 12).attr("refY", 5.2).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("path").attr("d", "M 1,1 l 9,9 M 10,1 l -9,9").attr("class", "arrowMarkerPath").style("stroke-width", 2).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-crossStart").attr("class", "marker cross " + type).attr("viewBox", "0 0 11 11").attr("refX", -1).attr("refY", 5.2).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("path").attr("d", "M 1,1 l 9,9 M 10,1 l -9,9").attr("class", "arrowMarkerPath").style("stroke-width", 2).style("stroke-dasharray", "1,0"); +}; +const barb = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-barbEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 14).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z"); +}; +const markers = { + extension, + composition, + aggregation, + dependency, + lollipop, + point, + circle: circle$1, + cross, + barb +}; +const insertMarkers$1 = insertMarkers; +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr("style", styleFn); + } +} +function addHtmlLabel(node) { + const fo = select(document.createElementNS("http://www.w3.org/2000/svg", "foreignObject")); + const div = fo.append("xhtml:div"); + const label = node.label; + const labelClass = node.isNode ? "nodeLabel" : "edgeLabel"; + div.html( + '" + label + "" + ); + applyStyle(div, node.labelStyle); + div.style("display", "inline-block"); + div.style("white-space", "nowrap"); + div.attr("xmlns", "http://www.w3.org/1999/xhtml"); + return fo.node(); +} +const createLabel = (_vertexText, style, isTitle, isNode) => { + let vertexText = _vertexText || ""; + if (typeof vertexText === "object") { + vertexText = vertexText[0]; + } + if (evaluate(getConfig().flowchart.htmlLabels)) { + vertexText = vertexText.replace(/\\n|\n/g, "
"); + log$1.debug("vertexText" + vertexText); + const node = { + isNode, + label: decodeEntities(vertexText).replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell: disable-line + (s) => `` + ), + labelStyle: style.replace("fill:", "color:") + }; + let vertexNode = addHtmlLabel(node); + return vertexNode; + } else { + const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", style.replace("color:", "fill:")); + let rows = []; + if (typeof vertexText === "string") { + rows = vertexText.split(/\\n|\n|/gi); + } else if (Array.isArray(vertexText)) { + rows = vertexText; + } else { + rows = []; + } + for (const row of rows) { + const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "0"); + if (isTitle) { + tspan.setAttribute("class", "title-row"); + } else { + tspan.setAttribute("class", "row"); + } + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + } + return svgLabel; + } +}; +const createLabel$1 = createLabel; +const labelHelper = async (parent, node, _classes, isNode) => { + let classes; + const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig().flowchart.htmlLabels); + if (!_classes) { + classes = "node default"; + } else { + classes = _classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const label = shapeSvg.insert("g").attr("class", "label").attr("style", node.labelStyle); + let labelText; + if (node.labelText === void 0) { + labelText = ""; + } else { + labelText = typeof node.labelText === "string" ? node.labelText : node.labelText[0]; + } + const textNode = label.node(); + let text; + if (node.labelType === "markdown") { + text = createText(label, sanitizeText$2(decodeEntities(labelText), getConfig()), { + useHtmlLabels, + width: node.width || getConfig().flowchart.wrappingWidth, + classes: "markdown-node-label" + }); + } else { + text = textNode.appendChild( + createLabel$1( + sanitizeText$2(decodeEntities(labelText), getConfig()), + node.labelStyle, + false, + isNode + ) + ); + } + let bbox = text.getBBox(); + const halfPadding = node.padding / 2; + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + const images = div.getElementsByTagName("img"); + if (images) { + const noImgText = labelText.replace(/]*>/g, "").trim() === ""; + await Promise.all( + [...images].map( + (img) => new Promise((res) => { + function setupImage() { + img.style.display = "flex"; + img.style.flexDirection = "column"; + if (noImgText) { + const bodyFontSize = getConfig().fontSize ? getConfig().fontSize : window.getComputedStyle(document.body).fontSize; + const enlargingFactor = 5; + const width = parseInt(bodyFontSize, 10) * enlargingFactor + "px"; + img.style.minWidth = width; + img.style.maxWidth = width; + } else { + img.style.width = "100%"; + } + res(img); + } + setTimeout(() => { + if (img.complete) { + setupImage(); + } + }); + img.addEventListener("error", setupImage); + img.addEventListener("load", setupImage); + }) + ) + ); + } + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (useHtmlLabels) { + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + } else { + label.attr("transform", "translate(0, " + -bbox.height / 2 + ")"); + } + if (node.centerLabel) { + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + } + label.insert("rect", ":first-child"); + return { shapeSvg, bbox, halfPadding, label }; +}; +const updateNodeBounds = (node, element) => { + const bbox = element.node().getBBox(); + node.width = bbox.width; + node.height = bbox.height; +}; +function insertPolygonShape(parent, w, h, points) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("class", "label-container").attr("transform", "translate(" + -w / 2 + "," + h / 2 + ")"); +} +function intersectNode(node, point2) { + return node.intersect(point2); +} +function intersectEllipse(node, rx, ry, point2) { + var cx = node.x; + var cy = node.y; + var px = cx - point2.x; + var py = cy - point2.y; + var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px); + var dx = Math.abs(rx * ry * px / det); + if (point2.x < cx) { + dx = -dx; + } + var dy = Math.abs(rx * ry * py / det); + if (point2.y < cy) { + dy = -dy; + } + return { x: cx + dx, y: cy + dy }; +} +function intersectCircle(node, rx, point2) { + return intersectEllipse(node, rx, rx, point2); +} +function intersectLine(p1, p2, q1, q2) { + var a1, a2, b1, b2, c1, c2; + var r1, r2, r3, r4; + var denom, offset, num; + var x, y; + a1 = p2.y - p1.y; + b1 = p1.x - p2.x; + c1 = p2.x * p1.y - p1.x * p2.y; + r3 = a1 * q1.x + b1 * q1.y + c1; + r4 = a1 * q2.x + b1 * q2.y + c1; + if (r3 !== 0 && r4 !== 0 && sameSign(r3, r4)) { + return; + } + a2 = q2.y - q1.y; + b2 = q1.x - q2.x; + c2 = q2.x * q1.y - q1.x * q2.y; + r1 = a2 * p1.x + b2 * p1.y + c2; + r2 = a2 * p2.x + b2 * p2.y + c2; + if (r1 !== 0 && r2 !== 0 && sameSign(r1, r2)) { + return; + } + denom = a1 * b2 - a2 * b1; + if (denom === 0) { + return; + } + offset = Math.abs(denom / 2); + num = b1 * c2 - b2 * c1; + x = num < 0 ? (num - offset) / denom : (num + offset) / denom; + num = a2 * c1 - a1 * c2; + y = num < 0 ? (num - offset) / denom : (num + offset) / denom; + return { x, y }; +} +function sameSign(r1, r2) { + return r1 * r2 > 0; +} +function intersectPolygon(node, polyPoints, point2) { + var x1 = node.x; + var y1 = node.y; + var intersections = []; + var minX = Number.POSITIVE_INFINITY; + var minY = Number.POSITIVE_INFINITY; + if (typeof polyPoints.forEach === "function") { + polyPoints.forEach(function(entry) { + minX = Math.min(minX, entry.x); + minY = Math.min(minY, entry.y); + }); + } else { + minX = Math.min(minX, polyPoints.x); + minY = Math.min(minY, polyPoints.y); + } + var left = x1 - node.width / 2 - minX; + var top = y1 - node.height / 2 - minY; + for (var i = 0; i < polyPoints.length; i++) { + var p1 = polyPoints[i]; + var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0]; + var intersect2 = intersectLine( + node, + point2, + { x: left + p1.x, y: top + p1.y }, + { x: left + p2.x, y: top + p2.y } + ); + if (intersect2) { + intersections.push(intersect2); + } + } + if (!intersections.length) { + return node; + } + if (intersections.length > 1) { + intersections.sort(function(p, q) { + var pdx = p.x - point2.x; + var pdy = p.y - point2.y; + var distp = Math.sqrt(pdx * pdx + pdy * pdy); + var qdx = q.x - point2.x; + var qdy = q.y - point2.y; + var distq = Math.sqrt(qdx * qdx + qdy * qdy); + return distp < distq ? -1 : distp === distq ? 0 : 1; + }); + } + return intersections[0]; +} +const intersectRect = (node, point2) => { + var x = node.x; + var y = node.y; + var dx = point2.x - x; + var dy = point2.y - y; + var w = node.width / 2; + var h = node.height / 2; + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + if (dy < 0) { + h = -h; + } + sx = dy === 0 ? 0 : h * dx / dy; + sy = h; + } else { + if (dx < 0) { + w = -w; + } + sx = w; + sy = dx === 0 ? 0 : w * dy / dx; + } + return { x: x + sx, y: y + sy }; +}; +const intersectRect$1 = intersectRect; +const intersect = { + node: intersectNode, + circle: intersectCircle, + ellipse: intersectEllipse, + polygon: intersectPolygon, + rect: intersectRect$1 +}; +const note = async (parent, node) => { + const useHtmlLabels = node.useHtmlLabels || getConfig().flowchart.htmlLabels; + if (!useHtmlLabels) { + node.centerLabel = true; + } + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes, + true + ); + log$1.info("Classes = ", node.classes); + const rect2 = shapeSvg.insert("rect", ":first-child"); + rect2.attr("rx", node.rx).attr("ry", node.ry).attr("x", -bbox.width / 2 - halfPadding).attr("y", -bbox.height / 2 - halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const note$1 = note; +const expandAndDeduplicateDirections = (directions) => { + const uniqueDirections = /* @__PURE__ */ new Set(); + for (const direction of directions) { + switch (direction) { + case "x": + uniqueDirections.add("right"); + uniqueDirections.add("left"); + break; + case "y": + uniqueDirections.add("up"); + uniqueDirections.add("down"); + break; + default: + uniqueDirections.add(direction); + break; + } + } + return uniqueDirections; +}; +const getArrowPoints = (duplicatedDirections, bbox, node) => { + const directions = expandAndDeduplicateDirections(duplicatedDirections); + const f = 2; + const height = bbox.height + 2 * node.padding; + const midpoint = height / f; + const width = bbox.width + 2 * midpoint + node.padding; + const padding = node.padding / 2; + if (directions.has("right") && directions.has("left") && directions.has("up") && directions.has("down")) { + return [ + // Bottom + { x: 0, y: 0 }, + { x: midpoint, y: 0 }, + { x: width / 2, y: 2 * padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: 0 }, + // Right + { x: width, y: -height / 3 }, + { x: width + 2 * padding, y: -height / 2 }, + { x: width, y: -2 * height / 3 }, + { x: width, y: -height }, + // Top + { x: width - midpoint, y: -height }, + { x: width / 2, y: -height - 2 * padding }, + { x: midpoint, y: -height }, + // Left + { x: 0, y: -height }, + { x: 0, y: -2 * height / 3 }, + { x: -2 * padding, y: -height / 2 }, + { x: 0, y: -height / 3 } + ]; + } + if (directions.has("right") && directions.has("left") && directions.has("up")) { + return [ + { x: midpoint, y: 0 }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("right") && directions.has("left") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: midpoint, y: -height }, + { x: width - midpoint, y: -height }, + { x: width, y: 0 } + ]; + } + if (directions.has("right") && directions.has("up") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: width, y: -midpoint }, + { x: width, y: -height + midpoint }, + { x: 0, y: -height } + ]; + } + if (directions.has("left") && directions.has("up") && directions.has("down")) { + return [ + { x: width, y: 0 }, + { x: 0, y: -midpoint }, + { x: 0, y: -height + midpoint }, + { x: width, y: -height } + ]; + } + if (directions.has("right") && directions.has("left")) { + return [ + { x: midpoint, y: 0 }, + { x: midpoint, y: -padding }, + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: width - midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("up") && directions.has("down")) { + return [ + // Bottom center + { x: width / 2, y: 0 }, + // Left pont of bottom arrow + { x: 0, y: -padding }, + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: 0, y: -height + padding }, + // Top of arrow + { x: width / 2, y: -height }, + { x: width, y: -height + padding }, + // Top of right vertical bar + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding }, + { x: width, y: -padding } + ]; + } + if (directions.has("right") && directions.has("up")) { + return [ + { x: 0, y: 0 }, + { x: width, y: -midpoint }, + { x: 0, y: -height } + ]; + } + if (directions.has("right") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: width, y: 0 }, + { x: 0, y: -height } + ]; + } + if (directions.has("left") && directions.has("up")) { + return [ + { x: width, y: 0 }, + { x: 0, y: -midpoint }, + { x: width, y: -height } + ]; + } + if (directions.has("left") && directions.has("down")) { + return [ + { x: width, y: 0 }, + { x: 0, y: 0 }, + { x: width, y: -height } + ]; + } + if (directions.has("right")) { + return [ + { x: midpoint, y: -padding }, + { x: midpoint, y: -padding }, + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: width - midpoint, y: -height + padding }, + // top left corner of arrow + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding } + ]; + } + if (directions.has("left")) { + return [ + { x: midpoint, y: 0 }, + { x: midpoint, y: -padding }, + // Two points, the right corners + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("up")) { + return [ + // Bottom center + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: 0, y: -height + padding }, + // Top of arrow + { x: width / 2, y: -height }, + { x: width, y: -height + padding }, + // Top of right vertical bar + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding } + ]; + } + if (directions.has("down")) { + return [ + // Bottom center + { x: width / 2, y: 0 }, + // Left pont of bottom arrow + { x: 0, y: -padding }, + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding }, + { x: width, y: -padding } + ]; + } + return [{ x: 0, y: 0 }]; +}; +const formatClass = (str) => { + if (str) { + return " " + str; + } + return ""; +}; +const getClassesFromNode = (node, otherClasses) => { + return `${"node default"}${formatClass(node.classes)} ${formatClass( + node.class + )}`; +}; +const question = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const s = w + h; + const points = [ + { x: s / 2, y: 0 }, + { x: s, y: -s / 2 }, + { x: s / 2, y: -s }, + { x: 0, y: -s / 2 } + ]; + log$1.info("Question main (Circle)"); + const questionElem = insertPolygonShape(shapeSvg, s, s, points); + questionElem.attr("style", node.style); + updateNodeBounds(node, questionElem); + node.intersect = function(point2) { + log$1.warn("Intersect called"); + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const choice = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const s = 28; + const points = [ + { x: 0, y: s / 2 }, + { x: s / 2, y: 0 }, + { x: 0, y: -s / 2 }, + { x: -s / 2, y: 0 } + ]; + const choice2 = shapeSvg.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ); + choice2.attr("class", "state-start").attr("r", 7).attr("width", 28).attr("height", 28); + node.width = 28; + node.height = 28; + node.intersect = function(point2) { + return intersect.circle(node, 14, point2); + }; + return shapeSvg; +}; +const hexagon = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const f = 4; + const h = bbox.height + node.padding; + const m = h / f; + const w = bbox.width + 2 * m + node.padding; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + const hex = insertPolygonShape(shapeSvg, w, h, points); + hex.attr("style", node.style); + updateNodeBounds(node, hex); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const block_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper(parent, node, void 0, true); + const f = 2; + const h = bbox.height + 2 * node.padding; + const m = h / f; + const w = bbox.width + 2 * m + node.padding; + const points = getArrowPoints(node.directions, bbox, node); + const blockArrow = insertPolygonShape(shapeSvg, w, h, points); + blockArrow.attr("style", node.style); + updateNodeBounds(node, blockArrow); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const rect_left_inv_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -h / 2, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: -h / 2, y: -h }, + { x: 0, y: -h / 2 } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + node.width = w + h; + node.height = h; + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const lean_right = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper(parent, node, getClassesFromNode(node), true); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const lean_left = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 2 * h / 6, y: 0 }, + { x: w + h / 6, y: 0 }, + { x: w - 2 * h / 6, y: -h }, + { x: -h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const trapezoid = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w + 2 * h / 6, y: 0 }, + { x: w - h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const inv_trapezoid = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: -2 * h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const rect_right_inv_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 0, y: 0 }, + { x: w + h / 2, y: 0 }, + { x: w, y: -h / 2 }, + { x: w + h / 2, y: -h }, + { x: 0, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const cylinder = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const rx = w / 2; + const ry = rx / (2.5 + w / 50); + const h = bbox.height + ry + node.padding; + const shape = "M 0," + ry + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 a " + rx + "," + ry + " 0,0,0 " + -w + " 0 l 0," + h + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 l 0," + -h; + const el = shapeSvg.attr("label-offset-y", ry).insert("path", ":first-child").attr("style", node.style).attr("d", shape).attr("transform", "translate(" + -w / 2 + "," + -(h / 2 + ry) + ")"); + updateNodeBounds(node, el); + node.intersect = function(point2) { + const pos = intersect.rect(node, point2); + const x = pos.x - node.x; + if (rx != 0 && (Math.abs(x) < node.width / 2 || Math.abs(x) == node.width / 2 && Math.abs(pos.y - node.y) > node.height / 2 - ry)) { + let y = ry * ry * (1 - x * x / (rx * rx)); + if (y != 0) { + y = Math.sqrt(y); + } + y = ry - y; + if (point2.y - node.y > 0) { + y = -y; + } + pos.y += y; + } + return pos; + }; + return shapeSvg; +}; +const rect = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes + " " + node.class, + true + ); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = node.positioned ? node.width : bbox.width + node.padding; + const totalHeight = node.positioned ? node.height : bbox.height + node.padding; + const x = node.positioned ? -totalWidth / 2 : -bbox.width / 2 - halfPadding; + const y = node.positioned ? -totalHeight / 2 : -bbox.height / 2 - halfPadding; + rect2.attr("class", "basic label-container").attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", x).attr("y", y).attr("width", totalWidth).attr("height", totalHeight); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const composite = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes, + true + ); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = node.positioned ? node.width : bbox.width + node.padding; + const totalHeight = node.positioned ? node.height : bbox.height + node.padding; + const x = node.positioned ? -totalWidth / 2 : -bbox.width / 2 - halfPadding; + const y = node.positioned ? -totalHeight / 2 : -bbox.height / 2 - halfPadding; + rect2.attr("class", "basic cluster composite label-container").attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", x).attr("y", y).attr("width", totalWidth).attr("height", totalHeight); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const labelRect = async (parent, node) => { + const { shapeSvg } = await labelHelper(parent, node, "label", true); + log$1.trace("Classes = ", node.class); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = 0; + const totalHeight = 0; + rect2.attr("width", totalWidth).attr("height", totalHeight); + shapeSvg.attr("class", "label edgeLabel"); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +function applyNodePropertyBorders(rect2, borders, totalWidth, totalHeight) { + const strokeDashArray = []; + const addBorder = (length) => { + strokeDashArray.push(length, 0); + }; + const skipBorder = (length) => { + strokeDashArray.push(0, length); + }; + if (borders.includes("t")) { + log$1.debug("add top border"); + addBorder(totalWidth); + } else { + skipBorder(totalWidth); + } + if (borders.includes("r")) { + log$1.debug("add right border"); + addBorder(totalHeight); + } else { + skipBorder(totalHeight); + } + if (borders.includes("b")) { + log$1.debug("add bottom border"); + addBorder(totalWidth); + } else { + skipBorder(totalWidth); + } + if (borders.includes("l")) { + log$1.debug("add left border"); + addBorder(totalHeight); + } else { + skipBorder(totalHeight); + } + rect2.attr("stroke-dasharray", strokeDashArray.join(" ")); +} +const rectWithTitle = (parent, node) => { + let classes; + if (!node.classes) { + classes = "node default"; + } else { + classes = "node " + node.classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const innerLine = shapeSvg.insert("line"); + const label = shapeSvg.insert("g").attr("class", "label"); + const text2 = node.labelText.flat ? node.labelText.flat() : node.labelText; + let title = ""; + if (typeof text2 === "object") { + title = text2[0]; + } else { + title = text2; + } + log$1.info("Label text abc79", title, text2, typeof text2 === "object"); + const text = label.node().appendChild(createLabel$1(title, node.labelStyle, true, true)); + let bbox = { width: 0, height: 0 }; + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + log$1.info("Text 2", text2); + const textRows = text2.slice(1, text2.length); + let titleBox = text.getBBox(); + const descr = label.node().appendChild( + createLabel$1(textRows.join ? textRows.join("
") : textRows, node.labelStyle, true, true) + ); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = descr.children[0]; + const dv = select(descr); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + const halfPadding = node.padding / 2; + select(descr).attr( + "transform", + "translate( " + // (titleBox.width - bbox.width) / 2 + + (bbox.width > titleBox.width ? 0 : (titleBox.width - bbox.width) / 2) + ", " + (titleBox.height + halfPadding + 5) + ")" + ); + select(text).attr( + "transform", + "translate( " + // (titleBox.width - bbox.width) / 2 + + (bbox.width < titleBox.width ? 0 : -(titleBox.width - bbox.width) / 2) + ", 0)" + ); + bbox = label.node().getBBox(); + label.attr( + "transform", + "translate(" + -bbox.width / 2 + ", " + (-bbox.height / 2 - halfPadding + 3) + ")" + ); + rect2.attr("class", "outer title-state").attr("x", -bbox.width / 2 - halfPadding).attr("y", -bbox.height / 2 - halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + innerLine.attr("class", "divider").attr("x1", -bbox.width / 2 - halfPadding).attr("x2", bbox.width / 2 + halfPadding).attr("y1", -bbox.height / 2 - halfPadding + titleBox.height + halfPadding).attr("y2", -bbox.height / 2 - halfPadding + titleBox.height + halfPadding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const stadium = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const h = bbox.height + node.padding; + const w = bbox.width + h / 4 + node.padding; + const rect2 = shapeSvg.insert("rect", ":first-child").attr("style", node.style).attr("rx", h / 2).attr("ry", h / 2).attr("x", -w / 2).attr("y", -h / 2).attr("width", w).attr("height", h); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const circle = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + log$1.info("Circle main"); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + log$1.info("Circle intersect", node, bbox.width / 2 + halfPadding, point2); + return intersect.circle(node, bbox.width / 2 + halfPadding, point2); + }; + return shapeSvg; +}; +const doublecircle = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const gap = 5; + const circleGroup = shapeSvg.insert("g", ":first-child"); + const outerCircle = circleGroup.insert("circle"); + const innerCircle = circleGroup.insert("circle"); + circleGroup.attr("class", node.class); + outerCircle.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding + gap).attr("width", bbox.width + node.padding + gap * 2).attr("height", bbox.height + node.padding + gap * 2); + innerCircle.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + log$1.info("DoubleCircle main"); + updateNodeBounds(node, outerCircle); + node.intersect = function(point2) { + log$1.info("DoubleCircle intersect", node, bbox.width / 2 + halfPadding + gap, point2); + return intersect.circle(node, bbox.width / 2 + halfPadding + gap, point2); + }; + return shapeSvg; +}; +const subroutine = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 0, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: 0, y: -h }, + { x: 0, y: 0 }, + { x: -8, y: 0 }, + { x: w + 8, y: 0 }, + { x: w + 8, y: -h }, + { x: -8, y: -h }, + { x: -8, y: 0 } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const start = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("class", "state-start").attr("r", 7).attr("width", 14).attr("height", 14); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + return intersect.circle(node, 7, point2); + }; + return shapeSvg; +}; +const forkJoin = (parent, node, dir) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + let width = 70; + let height = 10; + if (dir === "LR") { + width = 10; + height = 70; + } + const shape = shapeSvg.append("rect").attr("x", -1 * width / 2).attr("y", -1 * height / 2).attr("width", width).attr("height", height).attr("class", "fork-join"); + updateNodeBounds(node, shape); + node.height = node.height + node.padding / 2; + node.width = node.width + node.padding / 2; + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const end = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const innerCircle = shapeSvg.insert("circle", ":first-child"); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("class", "state-start").attr("r", 7).attr("width", 14).attr("height", 14); + innerCircle.attr("class", "state-end").attr("r", 5).attr("width", 10).attr("height", 10); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + return intersect.circle(node, 7, point2); + }; + return shapeSvg; +}; +const class_box = (parent, node) => { + const halfPadding = node.padding / 2; + const rowPadding = 4; + const lineHeight = 8; + let classes; + if (!node.classes) { + classes = "node default"; + } else { + classes = "node " + node.classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const topLine = shapeSvg.insert("line"); + const bottomLine = shapeSvg.insert("line"); + let maxWidth = 0; + let maxHeight = rowPadding; + const labelContainer = shapeSvg.insert("g").attr("class", "label"); + let verticalPos = 0; + const hasInterface = node.classData.annotations && node.classData.annotations[0]; + const interfaceLabelText = node.classData.annotations[0] ? "«" + node.classData.annotations[0] + "»" : ""; + const interfaceLabel = labelContainer.node().appendChild(createLabel$1(interfaceLabelText, node.labelStyle, true, true)); + let interfaceBBox = interfaceLabel.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = interfaceLabel.children[0]; + const dv = select(interfaceLabel); + interfaceBBox = div.getBoundingClientRect(); + dv.attr("width", interfaceBBox.width); + dv.attr("height", interfaceBBox.height); + } + if (node.classData.annotations[0]) { + maxHeight += interfaceBBox.height + rowPadding; + maxWidth += interfaceBBox.width; + } + let classTitleString = node.classData.label; + if (node.classData.type !== void 0 && node.classData.type !== "") { + if (getConfig().flowchart.htmlLabels) { + classTitleString += "<" + node.classData.type + ">"; + } else { + classTitleString += "<" + node.classData.type + ">"; + } + } + const classTitleLabel = labelContainer.node().appendChild(createLabel$1(classTitleString, node.labelStyle, true, true)); + select(classTitleLabel).attr("class", "classTitle"); + let classTitleBBox = classTitleLabel.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = classTitleLabel.children[0]; + const dv = select(classTitleLabel); + classTitleBBox = div.getBoundingClientRect(); + dv.attr("width", classTitleBBox.width); + dv.attr("height", classTitleBBox.height); + } + maxHeight += classTitleBBox.height + rowPadding; + if (classTitleBBox.width > maxWidth) { + maxWidth = classTitleBBox.width; + } + const classAttributes = []; + node.classData.members.forEach((member) => { + const parsedInfo = member.getDisplayDetails(); + let parsedText = parsedInfo.displayText; + if (getConfig().flowchart.htmlLabels) { + parsedText = parsedText.replace(//g, ">"); + } + const lbl = labelContainer.node().appendChild( + createLabel$1( + parsedText, + parsedInfo.cssStyle ? parsedInfo.cssStyle : node.labelStyle, + true, + true + ) + ); + let bbox = lbl.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = lbl.children[0]; + const dv = select(lbl); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (bbox.width > maxWidth) { + maxWidth = bbox.width; + } + maxHeight += bbox.height + rowPadding; + classAttributes.push(lbl); + }); + maxHeight += lineHeight; + const classMethods = []; + node.classData.methods.forEach((member) => { + const parsedInfo = member.getDisplayDetails(); + let displayText = parsedInfo.displayText; + if (getConfig().flowchart.htmlLabels) { + displayText = displayText.replace(//g, ">"); + } + const lbl = labelContainer.node().appendChild( + createLabel$1( + displayText, + parsedInfo.cssStyle ? parsedInfo.cssStyle : node.labelStyle, + true, + true + ) + ); + let bbox = lbl.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = lbl.children[0]; + const dv = select(lbl); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (bbox.width > maxWidth) { + maxWidth = bbox.width; + } + maxHeight += bbox.height + rowPadding; + classMethods.push(lbl); + }); + maxHeight += lineHeight; + if (hasInterface) { + let diffX2 = (maxWidth - interfaceBBox.width) / 2; + select(interfaceLabel).attr( + "transform", + "translate( " + (-1 * maxWidth / 2 + diffX2) + ", " + -1 * maxHeight / 2 + ")" + ); + verticalPos = interfaceBBox.height + rowPadding; + } + let diffX = (maxWidth - classTitleBBox.width) / 2; + select(classTitleLabel).attr( + "transform", + "translate( " + (-1 * maxWidth / 2 + diffX) + ", " + (-1 * maxHeight / 2 + verticalPos) + ")" + ); + verticalPos += classTitleBBox.height + rowPadding; + topLine.attr("class", "divider").attr("x1", -maxWidth / 2 - halfPadding).attr("x2", maxWidth / 2 + halfPadding).attr("y1", -maxHeight / 2 - halfPadding + lineHeight + verticalPos).attr("y2", -maxHeight / 2 - halfPadding + lineHeight + verticalPos); + verticalPos += lineHeight; + classAttributes.forEach((lbl) => { + select(lbl).attr( + "transform", + "translate( " + -maxWidth / 2 + ", " + (-1 * maxHeight / 2 + verticalPos + lineHeight / 2) + ")" + ); + const memberBBox = lbl == null ? void 0 : lbl.getBBox(); + verticalPos += ((memberBBox == null ? void 0 : memberBBox.height) ?? 0) + rowPadding; + }); + verticalPos += lineHeight; + bottomLine.attr("class", "divider").attr("x1", -maxWidth / 2 - halfPadding).attr("x2", maxWidth / 2 + halfPadding).attr("y1", -maxHeight / 2 - halfPadding + lineHeight + verticalPos).attr("y2", -maxHeight / 2 - halfPadding + lineHeight + verticalPos); + verticalPos += lineHeight; + classMethods.forEach((lbl) => { + select(lbl).attr( + "transform", + "translate( " + -maxWidth / 2 + ", " + (-1 * maxHeight / 2 + verticalPos) + ")" + ); + const memberBBox = lbl == null ? void 0 : lbl.getBBox(); + verticalPos += ((memberBBox == null ? void 0 : memberBBox.height) ?? 0) + rowPadding; + }); + rect2.attr("style", node.style).attr("class", "outer title-state").attr("x", -maxWidth / 2 - halfPadding).attr("y", -(maxHeight / 2) - halfPadding).attr("width", maxWidth + node.padding).attr("height", maxHeight + node.padding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const shapes = { + rhombus: question, + composite, + question, + rect, + labelRect, + rectWithTitle, + choice, + circle, + doublecircle, + stadium, + hexagon, + block_arrow, + rect_left_inv_arrow, + lean_right, + lean_left, + trapezoid, + inv_trapezoid, + rect_right_inv_arrow, + cylinder, + start, + end, + note: note$1, + subroutine, + fork: forkJoin, + join: forkJoin, + class_box +}; +let nodeElems = {}; +const insertNode = async (elem, node, dir) => { + let newEl; + let el; + if (node.link) { + let target; + if (getConfig().securityLevel === "sandbox") { + target = "_top"; + } else if (node.linkTarget) { + target = node.linkTarget || "_blank"; + } + newEl = elem.insert("svg:a").attr("xlink:href", node.link).attr("target", target); + el = await shapes[node.shape](newEl, node, dir); + } else { + el = await shapes[node.shape](elem, node, dir); + newEl = el; + } + if (node.tooltip) { + el.attr("title", node.tooltip); + } + if (node.class) { + el.attr("class", "node default " + node.class); + } + newEl.attr("data-node", "true"); + newEl.attr("data-id", node.id); + nodeElems[node.id] = newEl; + if (node.haveCallback) { + nodeElems[node.id].attr("class", nodeElems[node.id].attr("class") + " clickable"); + } + return newEl; +}; +const setNodeElem = (elem, node) => { + nodeElems[node.id] = elem; +}; +const clear$1 = () => { + nodeElems = {}; +}; +const positionNode = (node) => { + const el = nodeElems[node.id]; + log$1.trace( + "Transforming node", + node.diff, + node, + "translate(" + (node.x - node.width / 2 - 5) + ", " + node.width / 2 + ")" + ); + const padding = 8; + const diff = node.diff || 0; + if (node.clusterNode) { + el.attr( + "transform", + "translate(" + (node.x + diff - node.width / 2) + ", " + (node.y - node.height / 2 - padding) + ")" + ); + } else { + el.attr("transform", "translate(" + node.x + ", " + node.y + ")"); + } + return diff; +}; +const getSubGraphTitleMargins = ({ + flowchart +}) => { + var _a, _b; + const subGraphTitleTopMargin = ((_a = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _a.top) ?? 0; + const subGraphTitleBottomMargin = ((_b = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _b.bottom) ?? 0; + const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin; + return { + subGraphTitleTopMargin, + subGraphTitleBottomMargin, + subGraphTitleTotalMargin + }; +}; +const markerOffsets = { + aggregation: 18, + extension: 18, + composition: 18, + dependency: 6, + lollipop: 13.5, + arrow_point: 5.3 +}; +function calculateDeltaAndAngle(point1, point2) { + if (point1 === void 0 || point2 === void 0) { + return { angle: 0, deltaX: 0, deltaY: 0 }; + } + point1 = pointTransformer(point1); + point2 = pointTransformer(point2); + const [x1, y1] = [point1.x, point1.y]; + const [x2, y2] = [point2.x, point2.y]; + const deltaX = x2 - x1; + const deltaY = y2 - y1; + return { angle: Math.atan(deltaY / deltaX), deltaX, deltaY }; +} +const pointTransformer = (data) => { + if (Array.isArray(data)) { + return { x: data[0], y: data[1] }; + } + return data; +}; +const getLineFunctionsWithOffset = (edge) => { + return { + x: function(d, i, data) { + let offset = 0; + if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { + const { angle, deltaX } = calculateDeltaAndAngle(data[0], data[1]); + offset = markerOffsets[edge.arrowTypeStart] * Math.cos(angle) * (deltaX >= 0 ? 1 : -1); + } else if (i === data.length - 1 && Object.hasOwn(markerOffsets, edge.arrowTypeEnd)) { + const { angle, deltaX } = calculateDeltaAndAngle( + data[data.length - 1], + data[data.length - 2] + ); + offset = markerOffsets[edge.arrowTypeEnd] * Math.cos(angle) * (deltaX >= 0 ? 1 : -1); + } + return pointTransformer(d).x + offset; + }, + y: function(d, i, data) { + let offset = 0; + if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { + const { angle, deltaY } = calculateDeltaAndAngle(data[0], data[1]); + offset = markerOffsets[edge.arrowTypeStart] * Math.abs(Math.sin(angle)) * (deltaY >= 0 ? 1 : -1); + } else if (i === data.length - 1 && Object.hasOwn(markerOffsets, edge.arrowTypeEnd)) { + const { angle, deltaY } = calculateDeltaAndAngle( + data[data.length - 1], + data[data.length - 2] + ); + offset = markerOffsets[edge.arrowTypeEnd] * Math.abs(Math.sin(angle)) * (deltaY >= 0 ? 1 : -1); + } + return pointTransformer(d).y + offset; + } + }; +}; +const addEdgeMarkers = (svgPath, edge, url, id, diagramType) => { + if (edge.arrowTypeStart) { + addEdgeMarker(svgPath, "start", edge.arrowTypeStart, url, id, diagramType); + } + if (edge.arrowTypeEnd) { + addEdgeMarker(svgPath, "end", edge.arrowTypeEnd, url, id, diagramType); + } +}; +const arrowTypesMap = { + arrow_cross: "cross", + arrow_point: "point", + arrow_barb: "barb", + arrow_circle: "circle", + aggregation: "aggregation", + extension: "extension", + composition: "composition", + dependency: "dependency", + lollipop: "lollipop" +}; +const addEdgeMarker = (svgPath, position, arrowType, url, id, diagramType) => { + const endMarkerType = arrowTypesMap[arrowType]; + if (!endMarkerType) { + log$1.warn(`Unknown arrow type: ${arrowType}`); + return; + } + const suffix = position === "start" ? "Start" : "End"; + svgPath.attr(`marker-${position}`, `url(${url}#${id}_${diagramType}-${endMarkerType}${suffix})`); +}; +let edgeLabels = {}; +let terminalLabels = {}; +const clear = () => { + edgeLabels = {}; + terminalLabels = {}; +}; +const insertEdgeLabel = (elem, edge) => { + const useHtmlLabels = evaluate(getConfig().flowchart.htmlLabels); + const labelElement = edge.labelType === "markdown" ? createText(elem, edge.label, { + style: edge.labelStyle, + useHtmlLabels, + addSvgBackground: true + }) : createLabel$1(edge.label, edge.labelStyle); + const edgeLabel = elem.insert("g").attr("class", "edgeLabel"); + const label = edgeLabel.insert("g").attr("class", "label"); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + if (useHtmlLabels) { + const div = labelElement.children[0]; + const dv = select(labelElement); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + edgeLabels[edge.id] = edgeLabel; + edge.width = bbox.width; + edge.height = bbox.height; + let fo; + if (edge.startLabelLeft) { + const startLabelElement = createLabel$1(edge.startLabelLeft, edge.labelStyle); + const startEdgeLabelLeft = elem.insert("g").attr("class", "edgeTerminals"); + const inner = startEdgeLabelLeft.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(startLabelElement); + const slBox = startLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].startLeft = startEdgeLabelLeft; + setTerminalWidth(fo, edge.startLabelLeft); + } + if (edge.startLabelRight) { + const startLabelElement = createLabel$1(edge.startLabelRight, edge.labelStyle); + const startEdgeLabelRight = elem.insert("g").attr("class", "edgeTerminals"); + const inner = startEdgeLabelRight.insert("g").attr("class", "inner"); + fo = startEdgeLabelRight.node().appendChild(startLabelElement); + inner.node().appendChild(startLabelElement); + const slBox = startLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].startRight = startEdgeLabelRight; + setTerminalWidth(fo, edge.startLabelRight); + } + if (edge.endLabelLeft) { + const endLabelElement = createLabel$1(edge.endLabelLeft, edge.labelStyle); + const endEdgeLabelLeft = elem.insert("g").attr("class", "edgeTerminals"); + const inner = endEdgeLabelLeft.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(endLabelElement); + const slBox = endLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + endEdgeLabelLeft.node().appendChild(endLabelElement); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].endLeft = endEdgeLabelLeft; + setTerminalWidth(fo, edge.endLabelLeft); + } + if (edge.endLabelRight) { + const endLabelElement = createLabel$1(edge.endLabelRight, edge.labelStyle); + const endEdgeLabelRight = elem.insert("g").attr("class", "edgeTerminals"); + const inner = endEdgeLabelRight.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(endLabelElement); + const slBox = endLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + endEdgeLabelRight.node().appendChild(endLabelElement); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].endRight = endEdgeLabelRight; + setTerminalWidth(fo, edge.endLabelRight); + } + return labelElement; +}; +function setTerminalWidth(fo, value) { + if (getConfig().flowchart.htmlLabels && fo) { + fo.style.width = value.length * 9 + "px"; + fo.style.height = "12px"; + } +} +const positionEdgeLabel = (edge, paths) => { + log$1.debug("Moving label abc88 ", edge.id, edge.label, edgeLabels[edge.id], paths); + let path = paths.updatedPath ? paths.updatedPath : paths.originalPath; + const siteConfig = getConfig(); + const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig); + if (edge.label) { + const el = edgeLabels[edge.id]; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcLabelPosition(path); + log$1.debug( + "Moving label " + edge.label + " from (", + x, + ",", + y, + ") to (", + pos.x, + ",", + pos.y, + ") abc88" + ); + if (paths.updatedPath) { + x = pos.x; + y = pos.y; + } + } + el.attr("transform", `translate(${x}, ${y + subGraphTitleTotalMargin / 2})`); + } + if (edge.startLabelLeft) { + const el = terminalLabels[edge.id].startLeft; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeStart ? 10 : 0, "start_left", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.startLabelRight) { + const el = terminalLabels[edge.id].startRight; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition( + edge.arrowTypeStart ? 10 : 0, + "start_right", + path + ); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.endLabelLeft) { + const el = terminalLabels[edge.id].endLeft; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_left", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.endLabelRight) { + const el = terminalLabels[edge.id].endRight; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_right", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } +}; +const outsideNode = (node, point2) => { + const x = node.x; + const y = node.y; + const dx = Math.abs(point2.x - x); + const dy = Math.abs(point2.y - y); + const w = node.width / 2; + const h = node.height / 2; + if (dx >= w || dy >= h) { + return true; + } + return false; +}; +const intersection = (node, outsidePoint, insidePoint) => { + log$1.debug(`intersection calc abc89: + outsidePoint: ${JSON.stringify(outsidePoint)} + insidePoint : ${JSON.stringify(insidePoint)} + node : x:${node.x} y:${node.y} w:${node.width} h:${node.height}`); + const x = node.x; + const y = node.y; + const dx = Math.abs(x - insidePoint.x); + const w = node.width / 2; + let r = insidePoint.x < outsidePoint.x ? w - dx : w + dx; + const h = node.height / 2; + const Q = Math.abs(outsidePoint.y - insidePoint.y); + const R = Math.abs(outsidePoint.x - insidePoint.x); + if (Math.abs(y - outsidePoint.y) * w > Math.abs(x - outsidePoint.x) * h) { + let q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y; + r = R * q / Q; + const res = { + x: insidePoint.x < outsidePoint.x ? insidePoint.x + r : insidePoint.x - R + r, + y: insidePoint.y < outsidePoint.y ? insidePoint.y + Q - q : insidePoint.y - Q + q + }; + if (r === 0) { + res.x = outsidePoint.x; + res.y = outsidePoint.y; + } + if (R === 0) { + res.x = outsidePoint.x; + } + if (Q === 0) { + res.y = outsidePoint.y; + } + log$1.debug(`abc89 topp/bott calc, Q ${Q}, q ${q}, R ${R}, r ${r}`, res); + return res; + } else { + if (insidePoint.x < outsidePoint.x) { + r = outsidePoint.x - w - x; + } else { + r = x - w - outsidePoint.x; + } + let q = Q * r / R; + let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : insidePoint.x - R + r; + let _y = insidePoint.y < outsidePoint.y ? insidePoint.y + q : insidePoint.y - q; + log$1.debug(`sides calc abc89, Q ${Q}, q ${q}, R ${R}, r ${r}`, { _x, _y }); + if (r === 0) { + _x = outsidePoint.x; + _y = outsidePoint.y; + } + if (R === 0) { + _x = outsidePoint.x; + } + if (Q === 0) { + _y = outsidePoint.y; + } + return { x: _x, y: _y }; + } +}; +const cutPathAtIntersect = (_points, boundaryNode) => { + log$1.debug("abc88 cutPathAtIntersect", _points, boundaryNode); + let points = []; + let lastPointOutside = _points[0]; + let isInside = false; + _points.forEach((point2) => { + if (!outsideNode(boundaryNode, point2) && !isInside) { + const inter = intersection(boundaryNode, lastPointOutside, point2); + let pointPresent = false; + points.forEach((p) => { + pointPresent = pointPresent || p.x === inter.x && p.y === inter.y; + }); + if (!points.some((e) => e.x === inter.x && e.y === inter.y)) { + points.push(inter); + } + isInside = true; + } else { + lastPointOutside = point2; + if (!isInside) { + points.push(point2); + } + } + }); + return points; +}; +const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph, id) { + let points = edge.points; + log$1.debug("abc88 InsertEdge: edge=", edge, "e=", e); + let pointsHasChanged = false; + const tail = graph.node(e.v); + var head = graph.node(e.w); + if ((head == null ? void 0 : head.intersect) && (tail == null ? void 0 : tail.intersect)) { + points = points.slice(1, edge.points.length - 1); + points.unshift(tail.intersect(points[0])); + points.push(head.intersect(points[points.length - 1])); + } + if (edge.toCluster) { + log$1.debug("to cluster abc88", clusterDb[edge.toCluster]); + points = cutPathAtIntersect(edge.points, clusterDb[edge.toCluster].node); + pointsHasChanged = true; + } + if (edge.fromCluster) { + log$1.debug("from cluster abc88", clusterDb[edge.fromCluster]); + points = cutPathAtIntersect(points.reverse(), clusterDb[edge.fromCluster].node).reverse(); + pointsHasChanged = true; + } + const lineData = points.filter((p) => !Number.isNaN(p.y)); + let curve = curveBasis; + if (edge.curve && (diagramType === "graph" || diagramType === "flowchart")) { + curve = edge.curve; + } + const { x, y } = getLineFunctionsWithOffset(edge); + const lineFunction = line().x(x).y(y).curve(curve); + let strokeClasses; + switch (edge.thickness) { + case "normal": + strokeClasses = "edge-thickness-normal"; + break; + case "thick": + strokeClasses = "edge-thickness-thick"; + break; + case "invisible": + strokeClasses = "edge-thickness-thick"; + break; + default: + strokeClasses = ""; + } + switch (edge.pattern) { + case "solid": + strokeClasses += " edge-pattern-solid"; + break; + case "dotted": + strokeClasses += " edge-pattern-dotted"; + break; + case "dashed": + strokeClasses += " edge-pattern-dashed"; + break; + } + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", edge.id).attr("class", " " + strokeClasses + (edge.classes ? " " + edge.classes : "")).attr("style", edge.style); + let url = ""; + if (getConfig().flowchart.arrowMarkerAbsolute || getConfig().state.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + addEdgeMarkers(svgPath, edge, url, id, diagramType); + let paths = {}; + if (pointsHasChanged) { + paths.updatedPath = points; + } + paths.originalPath = edge.points; + return paths; +}; + +export { insertNode as a, insertEdgeLabel as b, insertEdge as c, positionEdgeLabel as d, clear$1 as e, clear as f, getSubGraphTitleMargins as g, createLabel$1 as h, insertMarkers$1 as i, intersectRect$1 as j, getLineFunctionsWithOffset as k, labelHelper as l, addEdgeMarkers as m, positionNode as p, setNodeElem as s, updateNodeBounds as u }; diff --git a/libs/marked/edges-066a5561-a6s42o55.js b/libs/marked/edges-066a5561-a6s42o55.js new file mode 100644 index 0000000..732012c --- /dev/null +++ b/libs/marked/edges-066a5561-a6s42o55.js @@ -0,0 +1,1825 @@ +import { p as evaluate, c as getConfig, d as sanitizeText$2, b6 as decodeEntities, h as select, l as log$1, A as utils, F as curveBasis } from './index-CN3YjQ0n.js'; +import { a as createText } from './createText-ca0c5216-DF05SDfj.js'; +import { l as line } from './line-D1aCvau7.js'; + +const insertMarkers = (elem, markerArray, type, id) => { + markerArray.forEach((markerName) => { + markers[markerName](elem, type, id); + }); +}; +const extension = (elem, type, id) => { + log$1.trace("Making markers for ", id); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-extensionStart").attr("class", "marker extension " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-extensionEnd").attr("class", "marker extension " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"); +}; +const composition = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-compositionStart").attr("class", "marker composition " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-compositionEnd").attr("class", "marker composition " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); +}; +const aggregation = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-aggregationStart").attr("class", "marker aggregation " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-aggregationEnd").attr("class", "marker aggregation " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); +}; +const dependency = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-dependencyStart").attr("class", "marker dependency " + type).attr("refX", 6).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-dependencyEnd").attr("class", "marker dependency " + type).attr("refX", 13).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const lollipop = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-lollipopStart").attr("class", "marker lollipop " + type).attr("refX", 13).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("circle").attr("stroke", "black").attr("fill", "transparent").attr("cx", 7).attr("cy", 7).attr("r", 6); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-lollipopEnd").attr("class", "marker lollipop " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("circle").attr("stroke", "black").attr("fill", "transparent").attr("cx", 7).attr("cy", 7).attr("r", 6); +}; +const point = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-pointEnd").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 6).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-pointStart").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 4.5).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 5 L 10 10 L 10 0 z").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); +}; +const circle$1 = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-circleEnd").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 11).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("circle").attr("cx", "5").attr("cy", "5").attr("r", "5").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-circleStart").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", -1).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("circle").attr("cx", "5").attr("cy", "5").attr("r", "5").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); +}; +const cross = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-crossEnd").attr("class", "marker cross " + type).attr("viewBox", "0 0 11 11").attr("refX", 12).attr("refY", 5.2).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("path").attr("d", "M 1,1 l 9,9 M 10,1 l -9,9").attr("class", "arrowMarkerPath").style("stroke-width", 2).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-crossStart").attr("class", "marker cross " + type).attr("viewBox", "0 0 11 11").attr("refX", -1).attr("refY", 5.2).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("path").attr("d", "M 1,1 l 9,9 M 10,1 l -9,9").attr("class", "arrowMarkerPath").style("stroke-width", 2).style("stroke-dasharray", "1,0"); +}; +const barb = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-barbEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 14).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z"); +}; +const markers = { + extension, + composition, + aggregation, + dependency, + lollipop, + point, + circle: circle$1, + cross, + barb +}; +const insertMarkers$1 = insertMarkers; +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr("style", styleFn); + } +} +function addHtmlLabel(node) { + const fo = select(document.createElementNS("http://www.w3.org/2000/svg", "foreignObject")); + const div = fo.append("xhtml:div"); + const label = node.label; + const labelClass = node.isNode ? "nodeLabel" : "edgeLabel"; + div.html( + '" + label + "" + ); + applyStyle(div, node.labelStyle); + div.style("display", "inline-block"); + div.style("white-space", "nowrap"); + div.attr("xmlns", "http://www.w3.org/1999/xhtml"); + return fo.node(); +} +const createLabel = (_vertexText, style, isTitle, isNode) => { + let vertexText = _vertexText || ""; + if (typeof vertexText === "object") { + vertexText = vertexText[0]; + } + if (evaluate(getConfig().flowchart.htmlLabels)) { + vertexText = vertexText.replace(/\\n|\n/g, "
"); + log$1.debug("vertexText" + vertexText); + const node = { + isNode, + label: decodeEntities(vertexText).replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell: disable-line + (s) => `` + ), + labelStyle: style.replace("fill:", "color:") + }; + let vertexNode = addHtmlLabel(node); + return vertexNode; + } else { + const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", style.replace("color:", "fill:")); + let rows = []; + if (typeof vertexText === "string") { + rows = vertexText.split(/\\n|\n|/gi); + } else if (Array.isArray(vertexText)) { + rows = vertexText; + } else { + rows = []; + } + for (const row of rows) { + const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "0"); + if (isTitle) { + tspan.setAttribute("class", "title-row"); + } else { + tspan.setAttribute("class", "row"); + } + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + } + return svgLabel; + } +}; +const createLabel$1 = createLabel; +const labelHelper = async (parent, node, _classes, isNode) => { + let classes; + const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig().flowchart.htmlLabels); + if (!_classes) { + classes = "node default"; + } else { + classes = _classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const label = shapeSvg.insert("g").attr("class", "label").attr("style", node.labelStyle); + let labelText; + if (node.labelText === void 0) { + labelText = ""; + } else { + labelText = typeof node.labelText === "string" ? node.labelText : node.labelText[0]; + } + const textNode = label.node(); + let text; + if (node.labelType === "markdown") { + text = createText(label, sanitizeText$2(decodeEntities(labelText), getConfig()), { + useHtmlLabels, + width: node.width || getConfig().flowchart.wrappingWidth, + classes: "markdown-node-label" + }); + } else { + text = textNode.appendChild( + createLabel$1( + sanitizeText$2(decodeEntities(labelText), getConfig()), + node.labelStyle, + false, + isNode + ) + ); + } + let bbox = text.getBBox(); + const halfPadding = node.padding / 2; + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + const images = div.getElementsByTagName("img"); + if (images) { + const noImgText = labelText.replace(/]*>/g, "").trim() === ""; + await Promise.all( + [...images].map( + (img) => new Promise((res) => { + function setupImage() { + img.style.display = "flex"; + img.style.flexDirection = "column"; + if (noImgText) { + const bodyFontSize = getConfig().fontSize ? getConfig().fontSize : window.getComputedStyle(document.body).fontSize; + const enlargingFactor = 5; + const width = parseInt(bodyFontSize, 10) * enlargingFactor + "px"; + img.style.minWidth = width; + img.style.maxWidth = width; + } else { + img.style.width = "100%"; + } + res(img); + } + setTimeout(() => { + if (img.complete) { + setupImage(); + } + }); + img.addEventListener("error", setupImage); + img.addEventListener("load", setupImage); + }) + ) + ); + } + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (useHtmlLabels) { + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + } else { + label.attr("transform", "translate(0, " + -bbox.height / 2 + ")"); + } + if (node.centerLabel) { + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + } + label.insert("rect", ":first-child"); + return { shapeSvg, bbox, halfPadding, label }; +}; +const updateNodeBounds = (node, element) => { + const bbox = element.node().getBBox(); + node.width = bbox.width; + node.height = bbox.height; +}; +function insertPolygonShape(parent, w, h, points) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("class", "label-container").attr("transform", "translate(" + -w / 2 + "," + h / 2 + ")"); +} +function intersectNode(node, point2) { + return node.intersect(point2); +} +function intersectEllipse(node, rx, ry, point2) { + var cx = node.x; + var cy = node.y; + var px = cx - point2.x; + var py = cy - point2.y; + var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px); + var dx = Math.abs(rx * ry * px / det); + if (point2.x < cx) { + dx = -dx; + } + var dy = Math.abs(rx * ry * py / det); + if (point2.y < cy) { + dy = -dy; + } + return { x: cx + dx, y: cy + dy }; +} +function intersectCircle(node, rx, point2) { + return intersectEllipse(node, rx, rx, point2); +} +function intersectLine(p1, p2, q1, q2) { + var a1, a2, b1, b2, c1, c2; + var r1, r2, r3, r4; + var denom, offset, num; + var x, y; + a1 = p2.y - p1.y; + b1 = p1.x - p2.x; + c1 = p2.x * p1.y - p1.x * p2.y; + r3 = a1 * q1.x + b1 * q1.y + c1; + r4 = a1 * q2.x + b1 * q2.y + c1; + if (r3 !== 0 && r4 !== 0 && sameSign(r3, r4)) { + return; + } + a2 = q2.y - q1.y; + b2 = q1.x - q2.x; + c2 = q2.x * q1.y - q1.x * q2.y; + r1 = a2 * p1.x + b2 * p1.y + c2; + r2 = a2 * p2.x + b2 * p2.y + c2; + if (r1 !== 0 && r2 !== 0 && sameSign(r1, r2)) { + return; + } + denom = a1 * b2 - a2 * b1; + if (denom === 0) { + return; + } + offset = Math.abs(denom / 2); + num = b1 * c2 - b2 * c1; + x = num < 0 ? (num - offset) / denom : (num + offset) / denom; + num = a2 * c1 - a1 * c2; + y = num < 0 ? (num - offset) / denom : (num + offset) / denom; + return { x, y }; +} +function sameSign(r1, r2) { + return r1 * r2 > 0; +} +function intersectPolygon(node, polyPoints, point2) { + var x1 = node.x; + var y1 = node.y; + var intersections = []; + var minX = Number.POSITIVE_INFINITY; + var minY = Number.POSITIVE_INFINITY; + if (typeof polyPoints.forEach === "function") { + polyPoints.forEach(function(entry) { + minX = Math.min(minX, entry.x); + minY = Math.min(minY, entry.y); + }); + } else { + minX = Math.min(minX, polyPoints.x); + minY = Math.min(minY, polyPoints.y); + } + var left = x1 - node.width / 2 - minX; + var top = y1 - node.height / 2 - minY; + for (var i = 0; i < polyPoints.length; i++) { + var p1 = polyPoints[i]; + var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0]; + var intersect2 = intersectLine( + node, + point2, + { x: left + p1.x, y: top + p1.y }, + { x: left + p2.x, y: top + p2.y } + ); + if (intersect2) { + intersections.push(intersect2); + } + } + if (!intersections.length) { + return node; + } + if (intersections.length > 1) { + intersections.sort(function(p, q) { + var pdx = p.x - point2.x; + var pdy = p.y - point2.y; + var distp = Math.sqrt(pdx * pdx + pdy * pdy); + var qdx = q.x - point2.x; + var qdy = q.y - point2.y; + var distq = Math.sqrt(qdx * qdx + qdy * qdy); + return distp < distq ? -1 : distp === distq ? 0 : 1; + }); + } + return intersections[0]; +} +const intersectRect = (node, point2) => { + var x = node.x; + var y = node.y; + var dx = point2.x - x; + var dy = point2.y - y; + var w = node.width / 2; + var h = node.height / 2; + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + if (dy < 0) { + h = -h; + } + sx = dy === 0 ? 0 : h * dx / dy; + sy = h; + } else { + if (dx < 0) { + w = -w; + } + sx = w; + sy = dx === 0 ? 0 : w * dy / dx; + } + return { x: x + sx, y: y + sy }; +}; +const intersectRect$1 = intersectRect; +const intersect = { + node: intersectNode, + circle: intersectCircle, + ellipse: intersectEllipse, + polygon: intersectPolygon, + rect: intersectRect$1 +}; +const note = async (parent, node) => { + const useHtmlLabels = node.useHtmlLabels || getConfig().flowchart.htmlLabels; + if (!useHtmlLabels) { + node.centerLabel = true; + } + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes, + true + ); + log$1.info("Classes = ", node.classes); + const rect2 = shapeSvg.insert("rect", ":first-child"); + rect2.attr("rx", node.rx).attr("ry", node.ry).attr("x", -bbox.width / 2 - halfPadding).attr("y", -bbox.height / 2 - halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const note$1 = note; +const expandAndDeduplicateDirections = (directions) => { + const uniqueDirections = /* @__PURE__ */ new Set(); + for (const direction of directions) { + switch (direction) { + case "x": + uniqueDirections.add("right"); + uniqueDirections.add("left"); + break; + case "y": + uniqueDirections.add("up"); + uniqueDirections.add("down"); + break; + default: + uniqueDirections.add(direction); + break; + } + } + return uniqueDirections; +}; +const getArrowPoints = (duplicatedDirections, bbox, node) => { + const directions = expandAndDeduplicateDirections(duplicatedDirections); + const f = 2; + const height = bbox.height + 2 * node.padding; + const midpoint = height / f; + const width = bbox.width + 2 * midpoint + node.padding; + const padding = node.padding / 2; + if (directions.has("right") && directions.has("left") && directions.has("up") && directions.has("down")) { + return [ + // Bottom + { x: 0, y: 0 }, + { x: midpoint, y: 0 }, + { x: width / 2, y: 2 * padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: 0 }, + // Right + { x: width, y: -height / 3 }, + { x: width + 2 * padding, y: -height / 2 }, + { x: width, y: -2 * height / 3 }, + { x: width, y: -height }, + // Top + { x: width - midpoint, y: -height }, + { x: width / 2, y: -height - 2 * padding }, + { x: midpoint, y: -height }, + // Left + { x: 0, y: -height }, + { x: 0, y: -2 * height / 3 }, + { x: -2 * padding, y: -height / 2 }, + { x: 0, y: -height / 3 } + ]; + } + if (directions.has("right") && directions.has("left") && directions.has("up")) { + return [ + { x: midpoint, y: 0 }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("right") && directions.has("left") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: midpoint, y: -height }, + { x: width - midpoint, y: -height }, + { x: width, y: 0 } + ]; + } + if (directions.has("right") && directions.has("up") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: width, y: -midpoint }, + { x: width, y: -height + midpoint }, + { x: 0, y: -height } + ]; + } + if (directions.has("left") && directions.has("up") && directions.has("down")) { + return [ + { x: width, y: 0 }, + { x: 0, y: -midpoint }, + { x: 0, y: -height + midpoint }, + { x: width, y: -height } + ]; + } + if (directions.has("right") && directions.has("left")) { + return [ + { x: midpoint, y: 0 }, + { x: midpoint, y: -padding }, + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: width - midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("up") && directions.has("down")) { + return [ + // Bottom center + { x: width / 2, y: 0 }, + // Left pont of bottom arrow + { x: 0, y: -padding }, + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: 0, y: -height + padding }, + // Top of arrow + { x: width / 2, y: -height }, + { x: width, y: -height + padding }, + // Top of right vertical bar + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding }, + { x: width, y: -padding } + ]; + } + if (directions.has("right") && directions.has("up")) { + return [ + { x: 0, y: 0 }, + { x: width, y: -midpoint }, + { x: 0, y: -height } + ]; + } + if (directions.has("right") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: width, y: 0 }, + { x: 0, y: -height } + ]; + } + if (directions.has("left") && directions.has("up")) { + return [ + { x: width, y: 0 }, + { x: 0, y: -midpoint }, + { x: width, y: -height } + ]; + } + if (directions.has("left") && directions.has("down")) { + return [ + { x: width, y: 0 }, + { x: 0, y: 0 }, + { x: width, y: -height } + ]; + } + if (directions.has("right")) { + return [ + { x: midpoint, y: -padding }, + { x: midpoint, y: -padding }, + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: width - midpoint, y: -height + padding }, + // top left corner of arrow + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding } + ]; + } + if (directions.has("left")) { + return [ + { x: midpoint, y: 0 }, + { x: midpoint, y: -padding }, + // Two points, the right corners + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("up")) { + return [ + // Bottom center + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: 0, y: -height + padding }, + // Top of arrow + { x: width / 2, y: -height }, + { x: width, y: -height + padding }, + // Top of right vertical bar + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding } + ]; + } + if (directions.has("down")) { + return [ + // Bottom center + { x: width / 2, y: 0 }, + // Left pont of bottom arrow + { x: 0, y: -padding }, + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding }, + { x: width, y: -padding } + ]; + } + return [{ x: 0, y: 0 }]; +}; +const formatClass = (str) => { + if (str) { + return " " + str; + } + return ""; +}; +const getClassesFromNode = (node, otherClasses) => { + return `${"node default"}${formatClass(node.classes)} ${formatClass( + node.class + )}`; +}; +const question = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const s = w + h; + const points = [ + { x: s / 2, y: 0 }, + { x: s, y: -s / 2 }, + { x: s / 2, y: -s }, + { x: 0, y: -s / 2 } + ]; + log$1.info("Question main (Circle)"); + const questionElem = insertPolygonShape(shapeSvg, s, s, points); + questionElem.attr("style", node.style); + updateNodeBounds(node, questionElem); + node.intersect = function(point2) { + log$1.warn("Intersect called"); + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const choice = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const s = 28; + const points = [ + { x: 0, y: s / 2 }, + { x: s / 2, y: 0 }, + { x: 0, y: -s / 2 }, + { x: -s / 2, y: 0 } + ]; + const choice2 = shapeSvg.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ); + choice2.attr("class", "state-start").attr("r", 7).attr("width", 28).attr("height", 28); + node.width = 28; + node.height = 28; + node.intersect = function(point2) { + return intersect.circle(node, 14, point2); + }; + return shapeSvg; +}; +const hexagon = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const f = 4; + const h = bbox.height + node.padding; + const m = h / f; + const w = bbox.width + 2 * m + node.padding; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + const hex = insertPolygonShape(shapeSvg, w, h, points); + hex.attr("style", node.style); + updateNodeBounds(node, hex); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const block_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper(parent, node, void 0, true); + const f = 2; + const h = bbox.height + 2 * node.padding; + const m = h / f; + const w = bbox.width + 2 * m + node.padding; + const points = getArrowPoints(node.directions, bbox, node); + const blockArrow = insertPolygonShape(shapeSvg, w, h, points); + blockArrow.attr("style", node.style); + updateNodeBounds(node, blockArrow); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const rect_left_inv_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -h / 2, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: -h / 2, y: -h }, + { x: 0, y: -h / 2 } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + node.width = w + h; + node.height = h; + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const lean_right = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper(parent, node, getClassesFromNode(node), true); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const lean_left = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 2 * h / 6, y: 0 }, + { x: w + h / 6, y: 0 }, + { x: w - 2 * h / 6, y: -h }, + { x: -h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const trapezoid = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w + 2 * h / 6, y: 0 }, + { x: w - h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const inv_trapezoid = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: -2 * h / 6, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const rect_right_inv_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 0, y: 0 }, + { x: w + h / 2, y: 0 }, + { x: w, y: -h / 2 }, + { x: w + h / 2, y: -h }, + { x: 0, y: -h } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const cylinder = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const rx = w / 2; + const ry = rx / (2.5 + w / 50); + const h = bbox.height + ry + node.padding; + const shape = "M 0," + ry + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 a " + rx + "," + ry + " 0,0,0 " + -w + " 0 l 0," + h + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 l 0," + -h; + const el = shapeSvg.attr("label-offset-y", ry).insert("path", ":first-child").attr("style", node.style).attr("d", shape).attr("transform", "translate(" + -w / 2 + "," + -(h / 2 + ry) + ")"); + updateNodeBounds(node, el); + node.intersect = function(point2) { + const pos = intersect.rect(node, point2); + const x = pos.x - node.x; + if (rx != 0 && (Math.abs(x) < node.width / 2 || Math.abs(x) == node.width / 2 && Math.abs(pos.y - node.y) > node.height / 2 - ry)) { + let y = ry * ry * (1 - x * x / (rx * rx)); + if (y != 0) { + y = Math.sqrt(y); + } + y = ry - y; + if (point2.y - node.y > 0) { + y = -y; + } + pos.y += y; + } + return pos; + }; + return shapeSvg; +}; +const rect = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes + " " + node.class, + true + ); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = node.positioned ? node.width : bbox.width + node.padding; + const totalHeight = node.positioned ? node.height : bbox.height + node.padding; + const x = node.positioned ? -totalWidth / 2 : -bbox.width / 2 - halfPadding; + const y = node.positioned ? -totalHeight / 2 : -bbox.height / 2 - halfPadding; + rect2.attr("class", "basic label-container").attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", x).attr("y", y).attr("width", totalWidth).attr("height", totalHeight); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const composite = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes, + true + ); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = node.positioned ? node.width : bbox.width + node.padding; + const totalHeight = node.positioned ? node.height : bbox.height + node.padding; + const x = node.positioned ? -totalWidth / 2 : -bbox.width / 2 - halfPadding; + const y = node.positioned ? -totalHeight / 2 : -bbox.height / 2 - halfPadding; + rect2.attr("class", "basic cluster composite label-container").attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", x).attr("y", y).attr("width", totalWidth).attr("height", totalHeight); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const labelRect = async (parent, node) => { + const { shapeSvg } = await labelHelper(parent, node, "label", true); + log$1.trace("Classes = ", node.class); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = 0; + const totalHeight = 0; + rect2.attr("width", totalWidth).attr("height", totalHeight); + shapeSvg.attr("class", "label edgeLabel"); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +function applyNodePropertyBorders(rect2, borders, totalWidth, totalHeight) { + const strokeDashArray = []; + const addBorder = (length) => { + strokeDashArray.push(length, 0); + }; + const skipBorder = (length) => { + strokeDashArray.push(0, length); + }; + if (borders.includes("t")) { + log$1.debug("add top border"); + addBorder(totalWidth); + } else { + skipBorder(totalWidth); + } + if (borders.includes("r")) { + log$1.debug("add right border"); + addBorder(totalHeight); + } else { + skipBorder(totalHeight); + } + if (borders.includes("b")) { + log$1.debug("add bottom border"); + addBorder(totalWidth); + } else { + skipBorder(totalWidth); + } + if (borders.includes("l")) { + log$1.debug("add left border"); + addBorder(totalHeight); + } else { + skipBorder(totalHeight); + } + rect2.attr("stroke-dasharray", strokeDashArray.join(" ")); +} +const rectWithTitle = (parent, node) => { + let classes; + if (!node.classes) { + classes = "node default"; + } else { + classes = "node " + node.classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const innerLine = shapeSvg.insert("line"); + const label = shapeSvg.insert("g").attr("class", "label"); + const text2 = node.labelText.flat ? node.labelText.flat() : node.labelText; + let title = ""; + if (typeof text2 === "object") { + title = text2[0]; + } else { + title = text2; + } + log$1.info("Label text abc79", title, text2, typeof text2 === "object"); + const text = label.node().appendChild(createLabel$1(title, node.labelStyle, true, true)); + let bbox = { width: 0, height: 0 }; + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + log$1.info("Text 2", text2); + const textRows = text2.slice(1, text2.length); + let titleBox = text.getBBox(); + const descr = label.node().appendChild( + createLabel$1(textRows.join ? textRows.join("
") : textRows, node.labelStyle, true, true) + ); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = descr.children[0]; + const dv = select(descr); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + const halfPadding = node.padding / 2; + select(descr).attr( + "transform", + "translate( " + // (titleBox.width - bbox.width) / 2 + + (bbox.width > titleBox.width ? 0 : (titleBox.width - bbox.width) / 2) + ", " + (titleBox.height + halfPadding + 5) + ")" + ); + select(text).attr( + "transform", + "translate( " + // (titleBox.width - bbox.width) / 2 + + (bbox.width < titleBox.width ? 0 : -(titleBox.width - bbox.width) / 2) + ", 0)" + ); + bbox = label.node().getBBox(); + label.attr( + "transform", + "translate(" + -bbox.width / 2 + ", " + (-bbox.height / 2 - halfPadding + 3) + ")" + ); + rect2.attr("class", "outer title-state").attr("x", -bbox.width / 2 - halfPadding).attr("y", -bbox.height / 2 - halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + innerLine.attr("class", "divider").attr("x1", -bbox.width / 2 - halfPadding).attr("x2", bbox.width / 2 + halfPadding).attr("y1", -bbox.height / 2 - halfPadding + titleBox.height + halfPadding).attr("y2", -bbox.height / 2 - halfPadding + titleBox.height + halfPadding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const stadium = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const h = bbox.height + node.padding; + const w = bbox.width + h / 4 + node.padding; + const rect2 = shapeSvg.insert("rect", ":first-child").attr("style", node.style).attr("rx", h / 2).attr("ry", h / 2).attr("x", -w / 2).attr("y", -h / 2).attr("width", w).attr("height", h); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const circle = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + log$1.info("Circle main"); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + log$1.info("Circle intersect", node, bbox.width / 2 + halfPadding, point2); + return intersect.circle(node, bbox.width / 2 + halfPadding, point2); + }; + return shapeSvg; +}; +const doublecircle = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const gap = 5; + const circleGroup = shapeSvg.insert("g", ":first-child"); + const outerCircle = circleGroup.insert("circle"); + const innerCircle = circleGroup.insert("circle"); + circleGroup.attr("class", node.class); + outerCircle.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding + gap).attr("width", bbox.width + node.padding + gap * 2).attr("height", bbox.height + node.padding + gap * 2); + innerCircle.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + log$1.info("DoubleCircle main"); + updateNodeBounds(node, outerCircle); + node.intersect = function(point2) { + log$1.info("DoubleCircle intersect", node, bbox.width / 2 + halfPadding + gap, point2); + return intersect.circle(node, bbox.width / 2 + halfPadding + gap, point2); + }; + return shapeSvg; +}; +const subroutine = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 0, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: 0, y: -h }, + { x: 0, y: 0 }, + { x: -8, y: 0 }, + { x: w + 8, y: 0 }, + { x: w + 8, y: -h }, + { x: -8, y: -h }, + { x: -8, y: 0 } + ]; + const el = insertPolygonShape(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const start = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("class", "state-start").attr("r", 7).attr("width", 14).attr("height", 14); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + return intersect.circle(node, 7, point2); + }; + return shapeSvg; +}; +const forkJoin = (parent, node, dir) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + let width = 70; + let height = 10; + if (dir === "LR") { + width = 10; + height = 70; + } + const shape = shapeSvg.append("rect").attr("x", -1 * width / 2).attr("y", -1 * height / 2).attr("width", width).attr("height", height).attr("class", "fork-join"); + updateNodeBounds(node, shape); + node.height = node.height + node.padding / 2; + node.width = node.width + node.padding / 2; + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const end = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const innerCircle = shapeSvg.insert("circle", ":first-child"); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("class", "state-start").attr("r", 7).attr("width", 14).attr("height", 14); + innerCircle.attr("class", "state-end").attr("r", 5).attr("width", 10).attr("height", 10); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + return intersect.circle(node, 7, point2); + }; + return shapeSvg; +}; +const class_box = (parent, node) => { + const halfPadding = node.padding / 2; + const rowPadding = 4; + const lineHeight = 8; + let classes; + if (!node.classes) { + classes = "node default"; + } else { + classes = "node " + node.classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const topLine = shapeSvg.insert("line"); + const bottomLine = shapeSvg.insert("line"); + let maxWidth = 0; + let maxHeight = rowPadding; + const labelContainer = shapeSvg.insert("g").attr("class", "label"); + let verticalPos = 0; + const hasInterface = node.classData.annotations && node.classData.annotations[0]; + const interfaceLabelText = node.classData.annotations[0] ? "«" + node.classData.annotations[0] + "»" : ""; + const interfaceLabel = labelContainer.node().appendChild(createLabel$1(interfaceLabelText, node.labelStyle, true, true)); + let interfaceBBox = interfaceLabel.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = interfaceLabel.children[0]; + const dv = select(interfaceLabel); + interfaceBBox = div.getBoundingClientRect(); + dv.attr("width", interfaceBBox.width); + dv.attr("height", interfaceBBox.height); + } + if (node.classData.annotations[0]) { + maxHeight += interfaceBBox.height + rowPadding; + maxWidth += interfaceBBox.width; + } + let classTitleString = node.classData.label; + if (node.classData.type !== void 0 && node.classData.type !== "") { + if (getConfig().flowchart.htmlLabels) { + classTitleString += "<" + node.classData.type + ">"; + } else { + classTitleString += "<" + node.classData.type + ">"; + } + } + const classTitleLabel = labelContainer.node().appendChild(createLabel$1(classTitleString, node.labelStyle, true, true)); + select(classTitleLabel).attr("class", "classTitle"); + let classTitleBBox = classTitleLabel.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = classTitleLabel.children[0]; + const dv = select(classTitleLabel); + classTitleBBox = div.getBoundingClientRect(); + dv.attr("width", classTitleBBox.width); + dv.attr("height", classTitleBBox.height); + } + maxHeight += classTitleBBox.height + rowPadding; + if (classTitleBBox.width > maxWidth) { + maxWidth = classTitleBBox.width; + } + const classAttributes = []; + node.classData.members.forEach((member) => { + const parsedInfo = member.getDisplayDetails(); + let parsedText = parsedInfo.displayText; + if (getConfig().flowchart.htmlLabels) { + parsedText = parsedText.replace(//g, ">"); + } + const lbl = labelContainer.node().appendChild( + createLabel$1( + parsedText, + parsedInfo.cssStyle ? parsedInfo.cssStyle : node.labelStyle, + true, + true + ) + ); + let bbox = lbl.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = lbl.children[0]; + const dv = select(lbl); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (bbox.width > maxWidth) { + maxWidth = bbox.width; + } + maxHeight += bbox.height + rowPadding; + classAttributes.push(lbl); + }); + maxHeight += lineHeight; + const classMethods = []; + node.classData.methods.forEach((member) => { + const parsedInfo = member.getDisplayDetails(); + let displayText = parsedInfo.displayText; + if (getConfig().flowchart.htmlLabels) { + displayText = displayText.replace(//g, ">"); + } + const lbl = labelContainer.node().appendChild( + createLabel$1( + displayText, + parsedInfo.cssStyle ? parsedInfo.cssStyle : node.labelStyle, + true, + true + ) + ); + let bbox = lbl.getBBox(); + if (evaluate(getConfig().flowchart.htmlLabels)) { + const div = lbl.children[0]; + const dv = select(lbl); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (bbox.width > maxWidth) { + maxWidth = bbox.width; + } + maxHeight += bbox.height + rowPadding; + classMethods.push(lbl); + }); + maxHeight += lineHeight; + if (hasInterface) { + let diffX2 = (maxWidth - interfaceBBox.width) / 2; + select(interfaceLabel).attr( + "transform", + "translate( " + (-1 * maxWidth / 2 + diffX2) + ", " + -1 * maxHeight / 2 + ")" + ); + verticalPos = interfaceBBox.height + rowPadding; + } + let diffX = (maxWidth - classTitleBBox.width) / 2; + select(classTitleLabel).attr( + "transform", + "translate( " + (-1 * maxWidth / 2 + diffX) + ", " + (-1 * maxHeight / 2 + verticalPos) + ")" + ); + verticalPos += classTitleBBox.height + rowPadding; + topLine.attr("class", "divider").attr("x1", -maxWidth / 2 - halfPadding).attr("x2", maxWidth / 2 + halfPadding).attr("y1", -maxHeight / 2 - halfPadding + lineHeight + verticalPos).attr("y2", -maxHeight / 2 - halfPadding + lineHeight + verticalPos); + verticalPos += lineHeight; + classAttributes.forEach((lbl) => { + select(lbl).attr( + "transform", + "translate( " + -maxWidth / 2 + ", " + (-1 * maxHeight / 2 + verticalPos + lineHeight / 2) + ")" + ); + const memberBBox = lbl == null ? void 0 : lbl.getBBox(); + verticalPos += ((memberBBox == null ? void 0 : memberBBox.height) ?? 0) + rowPadding; + }); + verticalPos += lineHeight; + bottomLine.attr("class", "divider").attr("x1", -maxWidth / 2 - halfPadding).attr("x2", maxWidth / 2 + halfPadding).attr("y1", -maxHeight / 2 - halfPadding + lineHeight + verticalPos).attr("y2", -maxHeight / 2 - halfPadding + lineHeight + verticalPos); + verticalPos += lineHeight; + classMethods.forEach((lbl) => { + select(lbl).attr( + "transform", + "translate( " + -maxWidth / 2 + ", " + (-1 * maxHeight / 2 + verticalPos) + ")" + ); + const memberBBox = lbl == null ? void 0 : lbl.getBBox(); + verticalPos += ((memberBBox == null ? void 0 : memberBBox.height) ?? 0) + rowPadding; + }); + rect2.attr("style", node.style).attr("class", "outer title-state").attr("x", -maxWidth / 2 - halfPadding).attr("y", -(maxHeight / 2) - halfPadding).attr("width", maxWidth + node.padding).attr("height", maxHeight + node.padding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const shapes = { + rhombus: question, + composite, + question, + rect, + labelRect, + rectWithTitle, + choice, + circle, + doublecircle, + stadium, + hexagon, + block_arrow, + rect_left_inv_arrow, + lean_right, + lean_left, + trapezoid, + inv_trapezoid, + rect_right_inv_arrow, + cylinder, + start, + end, + note: note$1, + subroutine, + fork: forkJoin, + join: forkJoin, + class_box +}; +let nodeElems = {}; +const insertNode = async (elem, node, dir) => { + let newEl; + let el; + if (node.link) { + let target; + if (getConfig().securityLevel === "sandbox") { + target = "_top"; + } else if (node.linkTarget) { + target = node.linkTarget || "_blank"; + } + newEl = elem.insert("svg:a").attr("xlink:href", node.link).attr("target", target); + el = await shapes[node.shape](newEl, node, dir); + } else { + el = await shapes[node.shape](elem, node, dir); + newEl = el; + } + if (node.tooltip) { + el.attr("title", node.tooltip); + } + if (node.class) { + el.attr("class", "node default " + node.class); + } + newEl.attr("data-node", "true"); + newEl.attr("data-id", node.id); + nodeElems[node.id] = newEl; + if (node.haveCallback) { + nodeElems[node.id].attr("class", nodeElems[node.id].attr("class") + " clickable"); + } + return newEl; +}; +const setNodeElem = (elem, node) => { + nodeElems[node.id] = elem; +}; +const clear$1 = () => { + nodeElems = {}; +}; +const positionNode = (node) => { + const el = nodeElems[node.id]; + log$1.trace( + "Transforming node", + node.diff, + node, + "translate(" + (node.x - node.width / 2 - 5) + ", " + node.width / 2 + ")" + ); + const padding = 8; + const diff = node.diff || 0; + if (node.clusterNode) { + el.attr( + "transform", + "translate(" + (node.x + diff - node.width / 2) + ", " + (node.y - node.height / 2 - padding) + ")" + ); + } else { + el.attr("transform", "translate(" + node.x + ", " + node.y + ")"); + } + return diff; +}; +const getSubGraphTitleMargins = ({ + flowchart +}) => { + var _a, _b; + const subGraphTitleTopMargin = ((_a = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _a.top) ?? 0; + const subGraphTitleBottomMargin = ((_b = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _b.bottom) ?? 0; + const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin; + return { + subGraphTitleTopMargin, + subGraphTitleBottomMargin, + subGraphTitleTotalMargin + }; +}; +const markerOffsets = { + aggregation: 18, + extension: 18, + composition: 18, + dependency: 6, + lollipop: 13.5, + arrow_point: 5.3 +}; +function calculateDeltaAndAngle(point1, point2) { + if (point1 === void 0 || point2 === void 0) { + return { angle: 0, deltaX: 0, deltaY: 0 }; + } + point1 = pointTransformer(point1); + point2 = pointTransformer(point2); + const [x1, y1] = [point1.x, point1.y]; + const [x2, y2] = [point2.x, point2.y]; + const deltaX = x2 - x1; + const deltaY = y2 - y1; + return { angle: Math.atan(deltaY / deltaX), deltaX, deltaY }; +} +const pointTransformer = (data) => { + if (Array.isArray(data)) { + return { x: data[0], y: data[1] }; + } + return data; +}; +const getLineFunctionsWithOffset = (edge) => { + return { + x: function(d, i, data) { + let offset = 0; + if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { + const { angle, deltaX } = calculateDeltaAndAngle(data[0], data[1]); + offset = markerOffsets[edge.arrowTypeStart] * Math.cos(angle) * (deltaX >= 0 ? 1 : -1); + } else if (i === data.length - 1 && Object.hasOwn(markerOffsets, edge.arrowTypeEnd)) { + const { angle, deltaX } = calculateDeltaAndAngle( + data[data.length - 1], + data[data.length - 2] + ); + offset = markerOffsets[edge.arrowTypeEnd] * Math.cos(angle) * (deltaX >= 0 ? 1 : -1); + } + return pointTransformer(d).x + offset; + }, + y: function(d, i, data) { + let offset = 0; + if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { + const { angle, deltaY } = calculateDeltaAndAngle(data[0], data[1]); + offset = markerOffsets[edge.arrowTypeStart] * Math.abs(Math.sin(angle)) * (deltaY >= 0 ? 1 : -1); + } else if (i === data.length - 1 && Object.hasOwn(markerOffsets, edge.arrowTypeEnd)) { + const { angle, deltaY } = calculateDeltaAndAngle( + data[data.length - 1], + data[data.length - 2] + ); + offset = markerOffsets[edge.arrowTypeEnd] * Math.abs(Math.sin(angle)) * (deltaY >= 0 ? 1 : -1); + } + return pointTransformer(d).y + offset; + } + }; +}; +const addEdgeMarkers = (svgPath, edge, url, id, diagramType) => { + if (edge.arrowTypeStart) { + addEdgeMarker(svgPath, "start", edge.arrowTypeStart, url, id, diagramType); + } + if (edge.arrowTypeEnd) { + addEdgeMarker(svgPath, "end", edge.arrowTypeEnd, url, id, diagramType); + } +}; +const arrowTypesMap = { + arrow_cross: "cross", + arrow_point: "point", + arrow_barb: "barb", + arrow_circle: "circle", + aggregation: "aggregation", + extension: "extension", + composition: "composition", + dependency: "dependency", + lollipop: "lollipop" +}; +const addEdgeMarker = (svgPath, position, arrowType, url, id, diagramType) => { + const endMarkerType = arrowTypesMap[arrowType]; + if (!endMarkerType) { + log$1.warn(`Unknown arrow type: ${arrowType}`); + return; + } + const suffix = position === "start" ? "Start" : "End"; + svgPath.attr(`marker-${position}`, `url(${url}#${id}_${diagramType}-${endMarkerType}${suffix})`); +}; +let edgeLabels = {}; +let terminalLabels = {}; +const clear = () => { + edgeLabels = {}; + terminalLabels = {}; +}; +const insertEdgeLabel = (elem, edge) => { + const useHtmlLabels = evaluate(getConfig().flowchart.htmlLabels); + const labelElement = edge.labelType === "markdown" ? createText(elem, edge.label, { + style: edge.labelStyle, + useHtmlLabels, + addSvgBackground: true + }) : createLabel$1(edge.label, edge.labelStyle); + const edgeLabel = elem.insert("g").attr("class", "edgeLabel"); + const label = edgeLabel.insert("g").attr("class", "label"); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + if (useHtmlLabels) { + const div = labelElement.children[0]; + const dv = select(labelElement); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + edgeLabels[edge.id] = edgeLabel; + edge.width = bbox.width; + edge.height = bbox.height; + let fo; + if (edge.startLabelLeft) { + const startLabelElement = createLabel$1(edge.startLabelLeft, edge.labelStyle); + const startEdgeLabelLeft = elem.insert("g").attr("class", "edgeTerminals"); + const inner = startEdgeLabelLeft.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(startLabelElement); + const slBox = startLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].startLeft = startEdgeLabelLeft; + setTerminalWidth(fo, edge.startLabelLeft); + } + if (edge.startLabelRight) { + const startLabelElement = createLabel$1(edge.startLabelRight, edge.labelStyle); + const startEdgeLabelRight = elem.insert("g").attr("class", "edgeTerminals"); + const inner = startEdgeLabelRight.insert("g").attr("class", "inner"); + fo = startEdgeLabelRight.node().appendChild(startLabelElement); + inner.node().appendChild(startLabelElement); + const slBox = startLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].startRight = startEdgeLabelRight; + setTerminalWidth(fo, edge.startLabelRight); + } + if (edge.endLabelLeft) { + const endLabelElement = createLabel$1(edge.endLabelLeft, edge.labelStyle); + const endEdgeLabelLeft = elem.insert("g").attr("class", "edgeTerminals"); + const inner = endEdgeLabelLeft.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(endLabelElement); + const slBox = endLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + endEdgeLabelLeft.node().appendChild(endLabelElement); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].endLeft = endEdgeLabelLeft; + setTerminalWidth(fo, edge.endLabelLeft); + } + if (edge.endLabelRight) { + const endLabelElement = createLabel$1(edge.endLabelRight, edge.labelStyle); + const endEdgeLabelRight = elem.insert("g").attr("class", "edgeTerminals"); + const inner = endEdgeLabelRight.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(endLabelElement); + const slBox = endLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + endEdgeLabelRight.node().appendChild(endLabelElement); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].endRight = endEdgeLabelRight; + setTerminalWidth(fo, edge.endLabelRight); + } + return labelElement; +}; +function setTerminalWidth(fo, value) { + if (getConfig().flowchart.htmlLabels && fo) { + fo.style.width = value.length * 9 + "px"; + fo.style.height = "12px"; + } +} +const positionEdgeLabel = (edge, paths) => { + log$1.debug("Moving label abc88 ", edge.id, edge.label, edgeLabels[edge.id], paths); + let path = paths.updatedPath ? paths.updatedPath : paths.originalPath; + const siteConfig = getConfig(); + const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig); + if (edge.label) { + const el = edgeLabels[edge.id]; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcLabelPosition(path); + log$1.debug( + "Moving label " + edge.label + " from (", + x, + ",", + y, + ") to (", + pos.x, + ",", + pos.y, + ") abc88" + ); + if (paths.updatedPath) { + x = pos.x; + y = pos.y; + } + } + el.attr("transform", `translate(${x}, ${y + subGraphTitleTotalMargin / 2})`); + } + if (edge.startLabelLeft) { + const el = terminalLabels[edge.id].startLeft; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeStart ? 10 : 0, "start_left", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.startLabelRight) { + const el = terminalLabels[edge.id].startRight; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition( + edge.arrowTypeStart ? 10 : 0, + "start_right", + path + ); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.endLabelLeft) { + const el = terminalLabels[edge.id].endLeft; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_left", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.endLabelRight) { + const el = terminalLabels[edge.id].endRight; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_right", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } +}; +const outsideNode = (node, point2) => { + const x = node.x; + const y = node.y; + const dx = Math.abs(point2.x - x); + const dy = Math.abs(point2.y - y); + const w = node.width / 2; + const h = node.height / 2; + if (dx >= w || dy >= h) { + return true; + } + return false; +}; +const intersection = (node, outsidePoint, insidePoint) => { + log$1.debug(`intersection calc abc89: + outsidePoint: ${JSON.stringify(outsidePoint)} + insidePoint : ${JSON.stringify(insidePoint)} + node : x:${node.x} y:${node.y} w:${node.width} h:${node.height}`); + const x = node.x; + const y = node.y; + const dx = Math.abs(x - insidePoint.x); + const w = node.width / 2; + let r = insidePoint.x < outsidePoint.x ? w - dx : w + dx; + const h = node.height / 2; + const Q = Math.abs(outsidePoint.y - insidePoint.y); + const R = Math.abs(outsidePoint.x - insidePoint.x); + if (Math.abs(y - outsidePoint.y) * w > Math.abs(x - outsidePoint.x) * h) { + let q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y; + r = R * q / Q; + const res = { + x: insidePoint.x < outsidePoint.x ? insidePoint.x + r : insidePoint.x - R + r, + y: insidePoint.y < outsidePoint.y ? insidePoint.y + Q - q : insidePoint.y - Q + q + }; + if (r === 0) { + res.x = outsidePoint.x; + res.y = outsidePoint.y; + } + if (R === 0) { + res.x = outsidePoint.x; + } + if (Q === 0) { + res.y = outsidePoint.y; + } + log$1.debug(`abc89 topp/bott calc, Q ${Q}, q ${q}, R ${R}, r ${r}`, res); + return res; + } else { + if (insidePoint.x < outsidePoint.x) { + r = outsidePoint.x - w - x; + } else { + r = x - w - outsidePoint.x; + } + let q = Q * r / R; + let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : insidePoint.x - R + r; + let _y = insidePoint.y < outsidePoint.y ? insidePoint.y + q : insidePoint.y - q; + log$1.debug(`sides calc abc89, Q ${Q}, q ${q}, R ${R}, r ${r}`, { _x, _y }); + if (r === 0) { + _x = outsidePoint.x; + _y = outsidePoint.y; + } + if (R === 0) { + _x = outsidePoint.x; + } + if (Q === 0) { + _y = outsidePoint.y; + } + return { x: _x, y: _y }; + } +}; +const cutPathAtIntersect = (_points, boundaryNode) => { + log$1.debug("abc88 cutPathAtIntersect", _points, boundaryNode); + let points = []; + let lastPointOutside = _points[0]; + let isInside = false; + _points.forEach((point2) => { + if (!outsideNode(boundaryNode, point2) && !isInside) { + const inter = intersection(boundaryNode, lastPointOutside, point2); + let pointPresent = false; + points.forEach((p) => { + pointPresent = pointPresent || p.x === inter.x && p.y === inter.y; + }); + if (!points.some((e) => e.x === inter.x && e.y === inter.y)) { + points.push(inter); + } + isInside = true; + } else { + lastPointOutside = point2; + if (!isInside) { + points.push(point2); + } + } + }); + return points; +}; +const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph, id) { + let points = edge.points; + log$1.debug("abc88 InsertEdge: edge=", edge, "e=", e); + let pointsHasChanged = false; + const tail = graph.node(e.v); + var head = graph.node(e.w); + if ((head == null ? void 0 : head.intersect) && (tail == null ? void 0 : tail.intersect)) { + points = points.slice(1, edge.points.length - 1); + points.unshift(tail.intersect(points[0])); + points.push(head.intersect(points[points.length - 1])); + } + if (edge.toCluster) { + log$1.debug("to cluster abc88", clusterDb[edge.toCluster]); + points = cutPathAtIntersect(edge.points, clusterDb[edge.toCluster].node); + pointsHasChanged = true; + } + if (edge.fromCluster) { + log$1.debug("from cluster abc88", clusterDb[edge.fromCluster]); + points = cutPathAtIntersect(points.reverse(), clusterDb[edge.fromCluster].node).reverse(); + pointsHasChanged = true; + } + const lineData = points.filter((p) => !Number.isNaN(p.y)); + let curve = curveBasis; + if (edge.curve && (diagramType === "graph" || diagramType === "flowchart")) { + curve = edge.curve; + } + const { x, y } = getLineFunctionsWithOffset(edge); + const lineFunction = line().x(x).y(y).curve(curve); + let strokeClasses; + switch (edge.thickness) { + case "normal": + strokeClasses = "edge-thickness-normal"; + break; + case "thick": + strokeClasses = "edge-thickness-thick"; + break; + case "invisible": + strokeClasses = "edge-thickness-thick"; + break; + default: + strokeClasses = ""; + } + switch (edge.pattern) { + case "solid": + strokeClasses += " edge-pattern-solid"; + break; + case "dotted": + strokeClasses += " edge-pattern-dotted"; + break; + case "dashed": + strokeClasses += " edge-pattern-dashed"; + break; + } + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", edge.id).attr("class", " " + strokeClasses + (edge.classes ? " " + edge.classes : "")).attr("style", edge.style); + let url = ""; + if (getConfig().flowchart.arrowMarkerAbsolute || getConfig().state.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + addEdgeMarkers(svgPath, edge, url, id, diagramType); + let paths = {}; + if (pointsHasChanged) { + paths.updatedPath = points; + } + paths.originalPath = edge.points; + return paths; +}; + +export { insertNode as a, insertEdgeLabel as b, insertEdge as c, positionEdgeLabel as d, clear$1 as e, clear as f, getSubGraphTitleMargins as g, createLabel$1 as h, insertMarkers$1 as i, intersectRect$1 as j, getLineFunctionsWithOffset as k, labelHelper as l, addEdgeMarkers as m, positionNode as p, setNodeElem as s, updateNodeBounds as u }; diff --git a/libs/marked/erDiagram-09d1c15f-CNysBsxR.js b/libs/marked/erDiagram-09d1c15f-CNysBsxR.js new file mode 100644 index 0000000..d6d55b3 --- /dev/null +++ b/libs/marked/erDiagram-09d1c15f-CNysBsxR.js @@ -0,0 +1,1384 @@ +import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, E as clear$1, h as select, A as utils, i as configureSvgSize, F as curveBasis, G as parseGenericTypes } from './index-Bd_FDXSq.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { l as layout } from './layout-BnytXFfq.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; + +function validate(uuid) { + return typeof uuid === 'string' && REGEX.test(uuid); +} + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ + +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).slice(1)); +} + +function unsafeStringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; +} + +function parse(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; +} + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +function v35(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + var _namespace; + + if (typeof value === 'string') { + value = stringToBytes(value); + } + + if (typeof namespace === 'string') { + namespace = parse(namespace); + } + + if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; + } + + return unsafeStringify(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +// Adapted from Chris Veness' SHA1 code at +// http://www.movable-type.co.uk/scripts/sha1.html +function f(s, x, y, z) { + switch (s) { + case 0: + return x & y ^ ~x & z; + + case 1: + return x ^ y ^ z; + + case 2: + return x & y ^ x & z ^ y & z; + + case 3: + return x ^ y ^ z; + } +} + +function ROTL(x, n) { + return x << n | x >>> 32 - n; +} + +function sha1(bytes) { + const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; + const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]; + + if (typeof bytes === 'string') { + const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape + + bytes = []; + + for (let i = 0; i < msg.length; ++i) { + bytes.push(msg.charCodeAt(i)); + } + } else if (!Array.isArray(bytes)) { + // Convert Array-like to Array + bytes = Array.prototype.slice.call(bytes); + } + + bytes.push(0x80); + const l = bytes.length / 4 + 2; + const N = Math.ceil(l / 16); + const M = new Array(N); + + for (let i = 0; i < N; ++i) { + const arr = new Uint32Array(16); + + for (let j = 0; j < 16; ++j) { + arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3]; + } + + M[i] = arr; + } + + M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32); + M[N - 1][14] = Math.floor(M[N - 1][14]); + M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff; + + for (let i = 0; i < N; ++i) { + const W = new Uint32Array(80); + + for (let t = 0; t < 16; ++t) { + W[t] = M[i][t]; + } + + for (let t = 16; t < 80; ++t) { + W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); + } + + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + let e = H[4]; + + for (let t = 0; t < 80; ++t) { + const s = Math.floor(t / 20); + const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0; + e = d; + d = c; + c = ROTL(b, 30) >>> 0; + b = a; + a = T; + } + + H[0] = H[0] + a >>> 0; + H[1] = H[1] + b >>> 0; + H[2] = H[2] + c >>> 0; + H[3] = H[3] + d >>> 0; + H[4] = H[4] + e >>> 0; + } + + return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff]; +} + +const v5 = v35('v5', 0x50, sha1); + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 20, 22, 24, 26, 27, 28], $V1 = [1, 10], $V2 = [1, 11], $V3 = [1, 12], $V4 = [1, 13], $V5 = [1, 14], $V6 = [1, 15], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 25], $Vc = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], $Vd = [1, 34], $Ve = [27, 28, 46, 47], $Vf = [41, 42, 43, 44, 45], $Vg = [17, 34], $Vh = [1, 54], $Vi = [1, 53], $Vj = [17, 34, 36, 38]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "ER_DIAGRAM": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "entityName": 11, "relSpec": 12, ":": 13, "role": 14, "BLOCK_START": 15, "attributes": 16, "BLOCK_STOP": 17, "SQS": 18, "SQE": 19, "title": 20, "title_value": 21, "acc_title": 22, "acc_title_value": 23, "acc_descr": 24, "acc_descr_value": 25, "acc_descr_multiline_value": 26, "ALPHANUM": 27, "ENTITY_NAME": 28, "attribute": 29, "attributeType": 30, "attributeName": 31, "attributeKeyTypeList": 32, "attributeComment": 33, "ATTRIBUTE_WORD": 34, "attributeKeyType": 35, "COMMA": 36, "ATTRIBUTE_KEY": 37, "COMMENT": 38, "cardinality": 39, "relType": 40, "ZERO_OR_ONE": 41, "ZERO_OR_MORE": 42, "ONE_OR_MORE": 43, "ONLY_ONE": 44, "MD_PARENT": 45, "NON_IDENTIFYING": 46, "IDENTIFYING": 47, "WORD": 48, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "ER_DIAGRAM", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 13: ":", 15: "BLOCK_START", 17: "BLOCK_STOP", 18: "SQS", 19: "SQE", 20: "title", 21: "title_value", 22: "acc_title", 23: "acc_title_value", 24: "acc_descr", 25: "acc_descr_value", 26: "acc_descr_multiline_value", 27: "ALPHANUM", 28: "ENTITY_NAME", 34: "ATTRIBUTE_WORD", 36: "COMMA", 37: "ATTRIBUTE_KEY", 38: "COMMENT", 41: "ZERO_OR_ONE", 42: "ZERO_OR_MORE", 43: "ONE_OR_MORE", 44: "ONLY_ONE", 45: "MD_PARENT", 46: "NON_IDENTIFYING", 47: "IDENTIFYING", 48: "WORD" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + break; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.addEntity($$[$0 - 4]); + yy.addEntity($$[$0 - 2]); + yy.addRelationship($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 3]); + break; + case 9: + yy.addEntity($$[$0 - 3]); + yy.addAttributes($$[$0 - 3], $$[$0 - 1]); + break; + case 10: + yy.addEntity($$[$0 - 2]); + break; + case 11: + yy.addEntity($$[$0]); + break; + case 12: + yy.addEntity($$[$0 - 6], $$[$0 - 4]); + yy.addAttributes($$[$0 - 6], $$[$0 - 1]); + break; + case 13: + yy.addEntity($$[$0 - 5], $$[$0 - 3]); + break; + case 14: + yy.addEntity($$[$0 - 3], $$[$0 - 1]); + break; + case 15: + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + case 43: + this.$ = $$[$0]; + break; + case 20: + case 41: + case 42: + this.$ = $$[$0].replace(/"/g, ""); + break; + case 21: + case 29: + this.$ = [$$[$0]]; + break; + case 22: + $$[$0].push($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 23: + this.$ = { attributeType: $$[$0 - 1], attributeName: $$[$0] }; + break; + case 24: + this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeKeyTypeList: $$[$0] }; + break; + case 25: + this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeComment: $$[$0] }; + break; + case 26: + this.$ = { attributeType: $$[$0 - 3], attributeName: $$[$0 - 2], attributeKeyTypeList: $$[$0 - 1], attributeComment: $$[$0] }; + break; + case 27: + case 28: + case 31: + this.$ = $$[$0]; + break; + case 30: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 32: + this.$ = $$[$0].replace(/"/g, ""); + break; + case 33: + this.$ = { cardA: $$[$0], relType: $$[$0 - 1], cardB: $$[$0 - 2] }; + break; + case 34: + this.$ = yy.Cardinality.ZERO_OR_ONE; + break; + case 35: + this.$ = yy.Cardinality.ZERO_OR_MORE; + break; + case 36: + this.$ = yy.Cardinality.ONE_OR_MORE; + break; + case 37: + this.$ = yy.Cardinality.ONLY_ONE; + break; + case 38: + this.$ = yy.Cardinality.MD_PARENT; + break; + case 39: + this.$ = yy.Identification.NON_IDENTIFYING; + break; + case 40: + this.$ = yy.Identification.IDENTIFYING; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 16, 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, o($V0, [2, 18]), o($Vc, [2, 19]), o($Vc, [2, 20]), o($V0, [2, 4]), { 11: 29, 27: $V5, 28: $V6 }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: $Vd }, { 11: 35, 27: $V5, 28: $V6 }, { 40: 36, 46: [1, 37], 47: [1, 38] }, o($Ve, [2, 34]), o($Ve, [2, 35]), o($Ve, [2, 36]), o($Ve, [2, 37]), o($Ve, [2, 38]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, o($V0, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: $Vd }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }, o($Vf, [2, 39]), o($Vf, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, o($V0, [2, 9]), { 17: [2, 22] }, o($Vg, [2, 23], { 32: 50, 33: 51, 35: 52, 37: $Vh, 38: $Vi }), o([17, 34, 37, 38], [2, 28]), o($V0, [2, 14], { 15: [1, 55] }), o([27, 28], [2, 33]), o($V0, [2, 8]), o($V0, [2, 41]), o($V0, [2, 42]), o($V0, [2, 43]), o($Vg, [2, 24], { 33: 56, 36: [1, 57], 38: $Vi }), o($Vg, [2, 25]), o($Vj, [2, 29]), o($Vg, [2, 32]), o($Vj, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: $Vd }, o($Vg, [2, 26]), { 35: 60, 37: $Vh }, { 17: [1, 61] }, o($V0, [2, 13]), o($Vj, [2, 30]), o($V0, [2, 12])], + defaultActions: { 34: [2, 27], 41: [2, 22] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 22; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 24; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + return 10; + case 8: + break; + case 9: + return 8; + case 10: + return 28; + case 11: + return 48; + case 12: + return 4; + case 13: + this.begin("block"); + return 15; + case 14: + return 36; + case 15: + break; + case 16: + return 37; + case 17: + return 34; + case 18: + return 34; + case 19: + return 38; + case 20: + break; + case 21: + this.popState(); + return 17; + case 22: + return yy_.yytext[0]; + case 23: + return 18; + case 24: + return 19; + case 25: + return 41; + case 26: + return 43; + case 27: + return 43; + case 28: + return 43; + case 29: + return 41; + case 30: + return 41; + case 31: + return 42; + case 32: + return 42; + case 33: + return 42; + case 34: + return 42; + case 35: + return 42; + case 36: + return 43; + case 37: + return 42; + case 38: + return 43; + case 39: + return 44; + case 40: + return 44; + case 41: + return 44; + case 42: + return 44; + case 43: + return 41; + case 44: + return 42; + case 45: + return 43; + case 46: + return 45; + case 47: + return 46; + case 48: + return 47; + case 49: + return 47; + case 50: + return 46; + case 51: + return 46; + case 52: + return 46; + case 53: + return 27; + case 54: + return yy_.yytext[0]; + case 55: + return 6; + } + }, + rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:[\s]+)/i, /^(?:"[^"%\r\n\v\b\\]+")/i, /^(?:"[^"]*")/i, /^(?:erDiagram\b)/i, /^(?:\{)/i, /^(?:,)/i, /^(?:\s+)/i, /^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]*)/i, /^(?:"[^"]*")/i, /^(?:[\n]+)/i, /^(?:\})/i, /^(?:.)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:one or zero\b)/i, /^(?:one or more\b)/i, /^(?:one or many\b)/i, /^(?:1\+)/i, /^(?:\|o\b)/i, /^(?:zero or one\b)/i, /^(?:zero or more\b)/i, /^(?:zero or many\b)/i, /^(?:0\+)/i, /^(?:\}o\b)/i, /^(?:many\(0\))/i, /^(?:many\(1\))/i, /^(?:many\b)/i, /^(?:\}\|)/i, /^(?:one\b)/i, /^(?:only one\b)/i, /^(?:1\b)/i, /^(?:\|\|)/i, /^(?:o\|)/i, /^(?:o\{)/i, /^(?:\|\{)/i, /^(?:\s*u\b)/i, /^(?:\.\.)/i, /^(?:--)/i, /^(?:to\b)/i, /^(?:optionally to\b)/i, /^(?:\.-)/i, /^(?:-\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i, /^(?:.)/i, /^(?:$)/i], + conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "block": { "rules": [14, 15, 16, 17, 18, 19, 20, 21, 22], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const erParser = parser; +let entities = {}; +let relationships = []; +const Cardinality = { + ZERO_OR_ONE: "ZERO_OR_ONE", + ZERO_OR_MORE: "ZERO_OR_MORE", + ONE_OR_MORE: "ONE_OR_MORE", + ONLY_ONE: "ONLY_ONE", + MD_PARENT: "MD_PARENT" +}; +const Identification = { + NON_IDENTIFYING: "NON_IDENTIFYING", + IDENTIFYING: "IDENTIFYING" +}; +const addEntity = function(name, alias = void 0) { + if (entities[name] === void 0) { + entities[name] = { attributes: [], alias }; + log$1.info("Added new entity :", name); + } else if (entities[name] && !entities[name].alias && alias) { + entities[name].alias = alias; + log$1.info(`Add alias '${alias}' to entity '${name}'`); + } + return entities[name]; +}; +const getEntities = () => entities; +const addAttributes = function(entityName, attribs) { + let entity = addEntity(entityName); + let i; + for (i = attribs.length - 1; i >= 0; i--) { + entity.attributes.push(attribs[i]); + log$1.debug("Added attribute ", attribs[i].attributeName); + } +}; +const addRelationship = function(entA, rolA, entB, rSpec) { + let rel = { + entityA: entA, + roleA: rolA, + entityB: entB, + relSpec: rSpec + }; + relationships.push(rel); + log$1.debug("Added new relationship :", rel); +}; +const getRelationships = () => relationships; +const clear = function() { + entities = {}; + relationships = []; + clear$1(); +}; +const erDb = { + Cardinality, + Identification, + getConfig: () => getConfig().er, + addEntity, + addAttributes, + getEntities, + addRelationship, + getRelationships, + clear, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + setDiagramTitle, + getDiagramTitle +}; +const ERMarkers = { + ONLY_ONE_START: "ONLY_ONE_START", + ONLY_ONE_END: "ONLY_ONE_END", + ZERO_OR_ONE_START: "ZERO_OR_ONE_START", + ZERO_OR_ONE_END: "ZERO_OR_ONE_END", + ONE_OR_MORE_START: "ONE_OR_MORE_START", + ONE_OR_MORE_END: "ONE_OR_MORE_END", + ZERO_OR_MORE_START: "ZERO_OR_MORE_START", + ZERO_OR_MORE_END: "ZERO_OR_MORE_END", + MD_PARENT_END: "MD_PARENT_END", + MD_PARENT_START: "MD_PARENT_START" +}; +const insertMarkers = function(elem, conf2) { + let marker; + elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_START).attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_END).attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18 M15,0 L15,18"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_END).attr("refX", 18).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,0 L3,18 M9,0 L9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 21).attr("cy", 9).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_END).attr("refX", 30).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 9).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,0 L21,18"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_END).attr("refX", 27).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 48).attr("cy", 18).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q18,0 36,18 Q18,36 0,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_END).attr("refX", 39).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 18).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,18 Q39,0 57,18 Q39,36 21,18"); + return; +}; +const erMarkers = { + ERMarkers, + insertMarkers +}; +const BAD_ID_CHARS_REGEXP = /[^\dA-Za-z](\W)*/g; +let conf = {}; +let entityNameIds = /* @__PURE__ */ new Map(); +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf[key] = cnf[key]; + } +}; +const drawAttributes = (groupNode, entityTextNode, attributes) => { + const heightPadding = conf.entityPadding / 3; + const widthPadding = conf.entityPadding / 3; + const attrFontSize = conf.fontSize * 0.85; + const labelBBox = entityTextNode.node().getBBox(); + const attributeNodes = []; + let hasKeyType = false; + let hasComment = false; + let maxTypeWidth = 0; + let maxNameWidth = 0; + let maxKeyWidth = 0; + let maxCommentWidth = 0; + let cumulativeHeight = labelBBox.height + heightPadding * 2; + let attrNum = 1; + attributes.forEach((item) => { + if (item.attributeKeyTypeList !== void 0 && item.attributeKeyTypeList.length > 0) { + hasKeyType = true; + } + if (item.attributeComment !== void 0) { + hasComment = true; + } + }); + attributes.forEach((item) => { + const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`; + let nodeHeight = 0; + const attributeType = parseGenericTypes(item.attributeType); + const typeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-type`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(attributeType); + const nameNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-name`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeName); + const attributeNode = {}; + attributeNode.tn = typeNode; + attributeNode.nn = nameNode; + const typeBBox = typeNode.node().getBBox(); + const nameBBox = nameNode.node().getBBox(); + maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width); + maxNameWidth = Math.max(maxNameWidth, nameBBox.width); + nodeHeight = Math.max(typeBBox.height, nameBBox.height); + if (hasKeyType) { + const keyTypeNodeText = item.attributeKeyTypeList !== void 0 ? item.attributeKeyTypeList.join(",") : ""; + const keyTypeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-key`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(keyTypeNodeText); + attributeNode.kn = keyTypeNode; + const keyTypeBBox = keyTypeNode.node().getBBox(); + maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width); + nodeHeight = Math.max(nodeHeight, keyTypeBBox.height); + } + if (hasComment) { + const commentNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-comment`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeComment || ""); + attributeNode.cn = commentNode; + const commentNodeBBox = commentNode.node().getBBox(); + maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width); + nodeHeight = Math.max(nodeHeight, commentNodeBBox.height); + } + attributeNode.height = nodeHeight; + attributeNodes.push(attributeNode); + cumulativeHeight += nodeHeight + heightPadding * 2; + attrNum += 1; + }); + let widthPaddingFactor = 4; + if (hasKeyType) { + widthPaddingFactor += 2; + } + if (hasComment) { + widthPaddingFactor += 2; + } + const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth; + const bBox = { + width: Math.max( + conf.minEntityWidth, + Math.max( + labelBBox.width + conf.entityPadding * 2, + maxWidth + widthPadding * widthPaddingFactor + ) + ), + height: attributes.length > 0 ? cumulativeHeight : Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2) + }; + if (attributes.length > 0) { + const spareColumnWidth = Math.max( + 0, + (bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2) + ); + entityTextNode.attr( + "transform", + "translate(" + bBox.width / 2 + "," + (heightPadding + labelBBox.height / 2) + ")" + ); + let heightOffset = labelBBox.height + heightPadding * 2; + let attribStyle = "attributeBoxOdd"; + attributeNodes.forEach((attributeNode) => { + const alignY = heightOffset + heightPadding + attributeNode.height / 2; + attributeNode.tn.attr("transform", "translate(" + widthPadding + "," + alignY + ")"); + const typeRect = groupNode.insert("rect", "#" + attributeNode.tn.node().id).classed(`er ${attribStyle}`, true).attr("x", 0).attr("y", heightOffset).attr("width", maxTypeWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + const nameXOffset = parseFloat(typeRect.attr("x")) + parseFloat(typeRect.attr("width")); + attributeNode.nn.attr( + "transform", + "translate(" + (nameXOffset + widthPadding) + "," + alignY + ")" + ); + const nameRect = groupNode.insert("rect", "#" + attributeNode.nn.node().id).classed(`er ${attribStyle}`, true).attr("x", nameXOffset).attr("y", heightOffset).attr("width", maxNameWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + let keyTypeAndCommentXOffset = parseFloat(nameRect.attr("x")) + parseFloat(nameRect.attr("width")); + if (hasKeyType) { + attributeNode.kn.attr( + "transform", + "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")" + ); + const keyTypeRect = groupNode.insert("rect", "#" + attributeNode.kn.node().id).classed(`er ${attribStyle}`, true).attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxKeyWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + keyTypeAndCommentXOffset = parseFloat(keyTypeRect.attr("x")) + parseFloat(keyTypeRect.attr("width")); + } + if (hasComment) { + attributeNode.cn.attr( + "transform", + "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")" + ); + groupNode.insert("rect", "#" + attributeNode.cn.node().id).classed(`er ${attribStyle}`, "true").attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxCommentWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + } + heightOffset += attributeNode.height + heightPadding * 2; + attribStyle = attribStyle === "attributeBoxOdd" ? "attributeBoxEven" : "attributeBoxOdd"; + }); + } else { + bBox.height = Math.max(conf.minEntityHeight, cumulativeHeight); + entityTextNode.attr("transform", "translate(" + bBox.width / 2 + "," + bBox.height / 2 + ")"); + } + return bBox; +}; +const drawEntities = function(svgNode, entities2, graph) { + const keys = Object.keys(entities2); + let firstOne; + keys.forEach(function(entityName) { + const entityId = generateId(entityName, "entity"); + entityNameIds.set(entityName, entityId); + const groupNode = svgNode.append("g").attr("id", entityId); + firstOne = firstOne === void 0 ? entityId : firstOne; + const textId = "text-" + entityId; + const textNode = groupNode.append("text").classed("er entityLabel", true).attr("id", textId).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "middle").style("font-family", getConfig().fontFamily).style("font-size", conf.fontSize + "px").text(entities2[entityName].alias ?? entityName); + const { width: entityWidth, height: entityHeight } = drawAttributes( + groupNode, + textNode, + entities2[entityName].attributes + ); + const rectNode = groupNode.insert("rect", "#" + textId).classed("er entityBox", true).attr("x", 0).attr("y", 0).attr("width", entityWidth).attr("height", entityHeight); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(entityId, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id: entityId + }); + }); + return firstOne; +}; +const adjustEntities = function(svgNode, graph) { + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + svgNode.select("#" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )" + ); + } + }); +}; +const getEdgeName = function(rel) { + return (rel.entityA + rel.roleA + rel.entityB).replace(/\s/g, ""); +}; +const addRelationships = function(relationships2, g) { + relationships2.forEach(function(r) { + g.setEdge( + entityNameIds.get(r.entityA), + entityNameIds.get(r.entityB), + { relationship: r }, + getEdgeName(r) + ); + }); + return relationships2; +}; +let relCnt = 0; +const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) { + relCnt++; + const edge = g.edge( + entityNameIds.get(rel.entityA), + entityNameIds.get(rel.entityB), + getEdgeName(rel) + ); + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = svg.insert("path", "#" + insert).classed("er relationshipLine", true).attr("d", lineFunction(edge.points)).style("stroke", conf.stroke).style("fill", "none"); + if (rel.relSpec.relType === diagObj.db.Identification.NON_IDENTIFYING) { + svgPath.attr("stroke-dasharray", "8,8"); + } + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + switch (rel.relSpec.cardA) { + case diagObj.db.Cardinality.ZERO_OR_ONE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_END + ")"); + break; + case diagObj.db.Cardinality.ZERO_OR_MORE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_END + ")"); + break; + case diagObj.db.Cardinality.ONE_OR_MORE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_END + ")"); + break; + case diagObj.db.Cardinality.ONLY_ONE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_END + ")"); + break; + case diagObj.db.Cardinality.MD_PARENT: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_END + ")"); + break; + } + switch (rel.relSpec.cardB) { + case diagObj.db.Cardinality.ZERO_OR_ONE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_START + ")" + ); + break; + case diagObj.db.Cardinality.ZERO_OR_MORE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_START + ")" + ); + break; + case diagObj.db.Cardinality.ONE_OR_MORE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_START + ")" + ); + break; + case diagObj.db.Cardinality.ONLY_ONE: + svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_START + ")"); + break; + case diagObj.db.Cardinality.MD_PARENT: + svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_START + ")"); + break; + } + const len = svgPath.node().getTotalLength(); + const labelPoint = svgPath.node().getPointAtLength(len * 0.5); + const labelId = "rel" + relCnt; + const labelNode = svg.append("text").classed("er relationshipLabel", true).attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).style("text-anchor", "middle").style("dominant-baseline", "middle").style("font-family", getConfig().fontFamily).style("font-size", conf.fontSize + "px").text(rel.roleA); + const labelBBox = labelNode.node().getBBox(); + svg.insert("rect", "#" + labelId).classed("er relationshipLabelBox", true).attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height); +}; +const draw = function(text, id, _version, diagObj) { + conf = getConfig().er; + log$1.info("Drawing ER diagram"); + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id='${id}']`); + erMarkers.insertMarkers(svg, conf); + let g; + g = new Graph({ + multigraph: true, + directed: true, + compound: false + }).setGraph({ + rankdir: conf.layoutDirection, + marginx: 20, + marginy: 20, + nodesep: 100, + edgesep: 100, + ranksep: 100 + }).setDefaultEdgeLabel(function() { + return {}; + }); + const firstEntity = drawEntities(svg, diagObj.db.getEntities(), g); + const relationships2 = addRelationships(diagObj.db.getRelationships(), g); + layout(g); + adjustEntities(svg, g); + relationships2.forEach(function(rel) { + drawRelationshipFromLayout(svg, rel, g, firstEntity, diagObj); + }); + const padding = conf.diagramPadding; + utils.insertTitle(svg, "entityTitleText", conf.titleTopMargin, diagObj.db.getDiagramTitle()); + const svgBounds = svg.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(svg, height, width, conf.useMaxWidth); + svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); +}; +const MERMAID_ERDIAGRAM_UUID = "28e9f9db-3c8d-5aa5-9faf-44286ae5937c"; +function generateId(str = "", prefix = "") { + const simplifiedStr = str.replace(BAD_ID_CHARS_REGEXP, ""); + return `${strWithHyphen(prefix)}${strWithHyphen(simplifiedStr)}${v5( + str, + MERMAID_ERDIAGRAM_UUID + )}`; +} +function strWithHyphen(str = "") { + return str.length > 0 ? `${str}-` : ""; +} +const erRenderer = { + setConf, + draw +}; +const getStyles = (options) => ` + .entityBox { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + } + + .attributeBoxOdd { + fill: ${options.attributeBackgroundColorOdd}; + stroke: ${options.nodeBorder}; + } + + .attributeBoxEven { + fill: ${options.attributeBackgroundColorEven}; + stroke: ${options.nodeBorder}; + } + + .relationshipLabelBox { + fill: ${options.tertiaryColor}; + opacity: 0.7; + background-color: ${options.tertiaryColor}; + rect { + opacity: 0.5; + } + } + + .relationshipLine { + stroke: ${options.lineColor}; + } + + .entityTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } + #MD_PARENT_START { + fill: #f5f5f5 !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; + } + #MD_PARENT_END { + fill: #f5f5f5 !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; + } + +`; +const erStyles = getStyles; +const diagram = { + parser: erParser, + db: erDb, + renderer: erRenderer, + styles: erStyles +}; + +export { diagram }; diff --git a/libs/marked/erDiagram-09d1c15f-DYT5JEfx.js b/libs/marked/erDiagram-09d1c15f-DYT5JEfx.js new file mode 100644 index 0000000..3908541 --- /dev/null +++ b/libs/marked/erDiagram-09d1c15f-DYT5JEfx.js @@ -0,0 +1,1384 @@ +import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, E as clear$1, h as select, A as utils, i as configureSvgSize, F as curveBasis, G as parseGenericTypes } from './index-CN3YjQ0n.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { l as layout } from './layout-BOZlZI7g.js'; +import { l as line } from './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; + +function validate(uuid) { + return typeof uuid === 'string' && REGEX.test(uuid); +} + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ + +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).slice(1)); +} + +function unsafeStringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; +} + +function parse(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; +} + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +function v35(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + var _namespace; + + if (typeof value === 'string') { + value = stringToBytes(value); + } + + if (typeof namespace === 'string') { + namespace = parse(namespace); + } + + if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; + } + + return unsafeStringify(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +// Adapted from Chris Veness' SHA1 code at +// http://www.movable-type.co.uk/scripts/sha1.html +function f(s, x, y, z) { + switch (s) { + case 0: + return x & y ^ ~x & z; + + case 1: + return x ^ y ^ z; + + case 2: + return x & y ^ x & z ^ y & z; + + case 3: + return x ^ y ^ z; + } +} + +function ROTL(x, n) { + return x << n | x >>> 32 - n; +} + +function sha1(bytes) { + const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; + const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]; + + if (typeof bytes === 'string') { + const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape + + bytes = []; + + for (let i = 0; i < msg.length; ++i) { + bytes.push(msg.charCodeAt(i)); + } + } else if (!Array.isArray(bytes)) { + // Convert Array-like to Array + bytes = Array.prototype.slice.call(bytes); + } + + bytes.push(0x80); + const l = bytes.length / 4 + 2; + const N = Math.ceil(l / 16); + const M = new Array(N); + + for (let i = 0; i < N; ++i) { + const arr = new Uint32Array(16); + + for (let j = 0; j < 16; ++j) { + arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3]; + } + + M[i] = arr; + } + + M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32); + M[N - 1][14] = Math.floor(M[N - 1][14]); + M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff; + + for (let i = 0; i < N; ++i) { + const W = new Uint32Array(80); + + for (let t = 0; t < 16; ++t) { + W[t] = M[i][t]; + } + + for (let t = 16; t < 80; ++t) { + W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); + } + + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + let e = H[4]; + + for (let t = 0; t < 80; ++t) { + const s = Math.floor(t / 20); + const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0; + e = d; + d = c; + c = ROTL(b, 30) >>> 0; + b = a; + a = T; + } + + H[0] = H[0] + a >>> 0; + H[1] = H[1] + b >>> 0; + H[2] = H[2] + c >>> 0; + H[3] = H[3] + d >>> 0; + H[4] = H[4] + e >>> 0; + } + + return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff]; +} + +const v5 = v35('v5', 0x50, sha1); + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 20, 22, 24, 26, 27, 28], $V1 = [1, 10], $V2 = [1, 11], $V3 = [1, 12], $V4 = [1, 13], $V5 = [1, 14], $V6 = [1, 15], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 25], $Vc = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], $Vd = [1, 34], $Ve = [27, 28, 46, 47], $Vf = [41, 42, 43, 44, 45], $Vg = [17, 34], $Vh = [1, 54], $Vi = [1, 53], $Vj = [17, 34, 36, 38]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "ER_DIAGRAM": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "entityName": 11, "relSpec": 12, ":": 13, "role": 14, "BLOCK_START": 15, "attributes": 16, "BLOCK_STOP": 17, "SQS": 18, "SQE": 19, "title": 20, "title_value": 21, "acc_title": 22, "acc_title_value": 23, "acc_descr": 24, "acc_descr_value": 25, "acc_descr_multiline_value": 26, "ALPHANUM": 27, "ENTITY_NAME": 28, "attribute": 29, "attributeType": 30, "attributeName": 31, "attributeKeyTypeList": 32, "attributeComment": 33, "ATTRIBUTE_WORD": 34, "attributeKeyType": 35, "COMMA": 36, "ATTRIBUTE_KEY": 37, "COMMENT": 38, "cardinality": 39, "relType": 40, "ZERO_OR_ONE": 41, "ZERO_OR_MORE": 42, "ONE_OR_MORE": 43, "ONLY_ONE": 44, "MD_PARENT": 45, "NON_IDENTIFYING": 46, "IDENTIFYING": 47, "WORD": 48, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "ER_DIAGRAM", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 13: ":", 15: "BLOCK_START", 17: "BLOCK_STOP", 18: "SQS", 19: "SQE", 20: "title", 21: "title_value", 22: "acc_title", 23: "acc_title_value", 24: "acc_descr", 25: "acc_descr_value", 26: "acc_descr_multiline_value", 27: "ALPHANUM", 28: "ENTITY_NAME", 34: "ATTRIBUTE_WORD", 36: "COMMA", 37: "ATTRIBUTE_KEY", 38: "COMMENT", 41: "ZERO_OR_ONE", 42: "ZERO_OR_MORE", 43: "ONE_OR_MORE", 44: "ONLY_ONE", 45: "MD_PARENT", 46: "NON_IDENTIFYING", 47: "IDENTIFYING", 48: "WORD" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + break; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.addEntity($$[$0 - 4]); + yy.addEntity($$[$0 - 2]); + yy.addRelationship($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 3]); + break; + case 9: + yy.addEntity($$[$0 - 3]); + yy.addAttributes($$[$0 - 3], $$[$0 - 1]); + break; + case 10: + yy.addEntity($$[$0 - 2]); + break; + case 11: + yy.addEntity($$[$0]); + break; + case 12: + yy.addEntity($$[$0 - 6], $$[$0 - 4]); + yy.addAttributes($$[$0 - 6], $$[$0 - 1]); + break; + case 13: + yy.addEntity($$[$0 - 5], $$[$0 - 3]); + break; + case 14: + yy.addEntity($$[$0 - 3], $$[$0 - 1]); + break; + case 15: + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + case 43: + this.$ = $$[$0]; + break; + case 20: + case 41: + case 42: + this.$ = $$[$0].replace(/"/g, ""); + break; + case 21: + case 29: + this.$ = [$$[$0]]; + break; + case 22: + $$[$0].push($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 23: + this.$ = { attributeType: $$[$0 - 1], attributeName: $$[$0] }; + break; + case 24: + this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeKeyTypeList: $$[$0] }; + break; + case 25: + this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeComment: $$[$0] }; + break; + case 26: + this.$ = { attributeType: $$[$0 - 3], attributeName: $$[$0 - 2], attributeKeyTypeList: $$[$0 - 1], attributeComment: $$[$0] }; + break; + case 27: + case 28: + case 31: + this.$ = $$[$0]; + break; + case 30: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 32: + this.$ = $$[$0].replace(/"/g, ""); + break; + case 33: + this.$ = { cardA: $$[$0], relType: $$[$0 - 1], cardB: $$[$0 - 2] }; + break; + case 34: + this.$ = yy.Cardinality.ZERO_OR_ONE; + break; + case 35: + this.$ = yy.Cardinality.ZERO_OR_MORE; + break; + case 36: + this.$ = yy.Cardinality.ONE_OR_MORE; + break; + case 37: + this.$ = yy.Cardinality.ONLY_ONE; + break; + case 38: + this.$ = yy.Cardinality.MD_PARENT; + break; + case 39: + this.$ = yy.Identification.NON_IDENTIFYING; + break; + case 40: + this.$ = yy.Identification.IDENTIFYING; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 16, 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, o($V0, [2, 18]), o($Vc, [2, 19]), o($Vc, [2, 20]), o($V0, [2, 4]), { 11: 29, 27: $V5, 28: $V6 }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: $Vd }, { 11: 35, 27: $V5, 28: $V6 }, { 40: 36, 46: [1, 37], 47: [1, 38] }, o($Ve, [2, 34]), o($Ve, [2, 35]), o($Ve, [2, 36]), o($Ve, [2, 37]), o($Ve, [2, 38]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, o($V0, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: $Vd }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }, o($Vf, [2, 39]), o($Vf, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, o($V0, [2, 9]), { 17: [2, 22] }, o($Vg, [2, 23], { 32: 50, 33: 51, 35: 52, 37: $Vh, 38: $Vi }), o([17, 34, 37, 38], [2, 28]), o($V0, [2, 14], { 15: [1, 55] }), o([27, 28], [2, 33]), o($V0, [2, 8]), o($V0, [2, 41]), o($V0, [2, 42]), o($V0, [2, 43]), o($Vg, [2, 24], { 33: 56, 36: [1, 57], 38: $Vi }), o($Vg, [2, 25]), o($Vj, [2, 29]), o($Vg, [2, 32]), o($Vj, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: $Vd }, o($Vg, [2, 26]), { 35: 60, 37: $Vh }, { 17: [1, 61] }, o($V0, [2, 13]), o($Vj, [2, 30]), o($V0, [2, 12])], + defaultActions: { 34: [2, 27], 41: [2, 22] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 22; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 24; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + return 10; + case 8: + break; + case 9: + return 8; + case 10: + return 28; + case 11: + return 48; + case 12: + return 4; + case 13: + this.begin("block"); + return 15; + case 14: + return 36; + case 15: + break; + case 16: + return 37; + case 17: + return 34; + case 18: + return 34; + case 19: + return 38; + case 20: + break; + case 21: + this.popState(); + return 17; + case 22: + return yy_.yytext[0]; + case 23: + return 18; + case 24: + return 19; + case 25: + return 41; + case 26: + return 43; + case 27: + return 43; + case 28: + return 43; + case 29: + return 41; + case 30: + return 41; + case 31: + return 42; + case 32: + return 42; + case 33: + return 42; + case 34: + return 42; + case 35: + return 42; + case 36: + return 43; + case 37: + return 42; + case 38: + return 43; + case 39: + return 44; + case 40: + return 44; + case 41: + return 44; + case 42: + return 44; + case 43: + return 41; + case 44: + return 42; + case 45: + return 43; + case 46: + return 45; + case 47: + return 46; + case 48: + return 47; + case 49: + return 47; + case 50: + return 46; + case 51: + return 46; + case 52: + return 46; + case 53: + return 27; + case 54: + return yy_.yytext[0]; + case 55: + return 6; + } + }, + rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:[\s]+)/i, /^(?:"[^"%\r\n\v\b\\]+")/i, /^(?:"[^"]*")/i, /^(?:erDiagram\b)/i, /^(?:\{)/i, /^(?:,)/i, /^(?:\s+)/i, /^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]*)/i, /^(?:"[^"]*")/i, /^(?:[\n]+)/i, /^(?:\})/i, /^(?:.)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:one or zero\b)/i, /^(?:one or more\b)/i, /^(?:one or many\b)/i, /^(?:1\+)/i, /^(?:\|o\b)/i, /^(?:zero or one\b)/i, /^(?:zero or more\b)/i, /^(?:zero or many\b)/i, /^(?:0\+)/i, /^(?:\}o\b)/i, /^(?:many\(0\))/i, /^(?:many\(1\))/i, /^(?:many\b)/i, /^(?:\}\|)/i, /^(?:one\b)/i, /^(?:only one\b)/i, /^(?:1\b)/i, /^(?:\|\|)/i, /^(?:o\|)/i, /^(?:o\{)/i, /^(?:\|\{)/i, /^(?:\s*u\b)/i, /^(?:\.\.)/i, /^(?:--)/i, /^(?:to\b)/i, /^(?:optionally to\b)/i, /^(?:\.-)/i, /^(?:-\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i, /^(?:.)/i, /^(?:$)/i], + conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "block": { "rules": [14, 15, 16, 17, 18, 19, 20, 21, 22], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const erParser = parser; +let entities = {}; +let relationships = []; +const Cardinality = { + ZERO_OR_ONE: "ZERO_OR_ONE", + ZERO_OR_MORE: "ZERO_OR_MORE", + ONE_OR_MORE: "ONE_OR_MORE", + ONLY_ONE: "ONLY_ONE", + MD_PARENT: "MD_PARENT" +}; +const Identification = { + NON_IDENTIFYING: "NON_IDENTIFYING", + IDENTIFYING: "IDENTIFYING" +}; +const addEntity = function(name, alias = void 0) { + if (entities[name] === void 0) { + entities[name] = { attributes: [], alias }; + log$1.info("Added new entity :", name); + } else if (entities[name] && !entities[name].alias && alias) { + entities[name].alias = alias; + log$1.info(`Add alias '${alias}' to entity '${name}'`); + } + return entities[name]; +}; +const getEntities = () => entities; +const addAttributes = function(entityName, attribs) { + let entity = addEntity(entityName); + let i; + for (i = attribs.length - 1; i >= 0; i--) { + entity.attributes.push(attribs[i]); + log$1.debug("Added attribute ", attribs[i].attributeName); + } +}; +const addRelationship = function(entA, rolA, entB, rSpec) { + let rel = { + entityA: entA, + roleA: rolA, + entityB: entB, + relSpec: rSpec + }; + relationships.push(rel); + log$1.debug("Added new relationship :", rel); +}; +const getRelationships = () => relationships; +const clear = function() { + entities = {}; + relationships = []; + clear$1(); +}; +const erDb = { + Cardinality, + Identification, + getConfig: () => getConfig().er, + addEntity, + addAttributes, + getEntities, + addRelationship, + getRelationships, + clear, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + setDiagramTitle, + getDiagramTitle +}; +const ERMarkers = { + ONLY_ONE_START: "ONLY_ONE_START", + ONLY_ONE_END: "ONLY_ONE_END", + ZERO_OR_ONE_START: "ZERO_OR_ONE_START", + ZERO_OR_ONE_END: "ZERO_OR_ONE_END", + ONE_OR_MORE_START: "ONE_OR_MORE_START", + ONE_OR_MORE_END: "ONE_OR_MORE_END", + ZERO_OR_MORE_START: "ZERO_OR_MORE_START", + ZERO_OR_MORE_END: "ZERO_OR_MORE_END", + MD_PARENT_END: "MD_PARENT_END", + MD_PARENT_START: "MD_PARENT_START" +}; +const insertMarkers = function(elem, conf2) { + let marker; + elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_START).attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_END).attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18 M15,0 L15,18"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_END).attr("refX", 18).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,0 L3,18 M9,0 L9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 21).attr("cy", 9).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_END).attr("refX", 30).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 9).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,0 L21,18"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_END).attr("refX", 27).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 48).attr("cy", 18).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q18,0 36,18 Q18,36 0,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_END).attr("refX", 39).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 18).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,18 Q39,0 57,18 Q39,36 21,18"); + return; +}; +const erMarkers = { + ERMarkers, + insertMarkers +}; +const BAD_ID_CHARS_REGEXP = /[^\dA-Za-z](\W)*/g; +let conf = {}; +let entityNameIds = /* @__PURE__ */ new Map(); +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf[key] = cnf[key]; + } +}; +const drawAttributes = (groupNode, entityTextNode, attributes) => { + const heightPadding = conf.entityPadding / 3; + const widthPadding = conf.entityPadding / 3; + const attrFontSize = conf.fontSize * 0.85; + const labelBBox = entityTextNode.node().getBBox(); + const attributeNodes = []; + let hasKeyType = false; + let hasComment = false; + let maxTypeWidth = 0; + let maxNameWidth = 0; + let maxKeyWidth = 0; + let maxCommentWidth = 0; + let cumulativeHeight = labelBBox.height + heightPadding * 2; + let attrNum = 1; + attributes.forEach((item) => { + if (item.attributeKeyTypeList !== void 0 && item.attributeKeyTypeList.length > 0) { + hasKeyType = true; + } + if (item.attributeComment !== void 0) { + hasComment = true; + } + }); + attributes.forEach((item) => { + const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`; + let nodeHeight = 0; + const attributeType = parseGenericTypes(item.attributeType); + const typeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-type`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(attributeType); + const nameNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-name`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeName); + const attributeNode = {}; + attributeNode.tn = typeNode; + attributeNode.nn = nameNode; + const typeBBox = typeNode.node().getBBox(); + const nameBBox = nameNode.node().getBBox(); + maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width); + maxNameWidth = Math.max(maxNameWidth, nameBBox.width); + nodeHeight = Math.max(typeBBox.height, nameBBox.height); + if (hasKeyType) { + const keyTypeNodeText = item.attributeKeyTypeList !== void 0 ? item.attributeKeyTypeList.join(",") : ""; + const keyTypeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-key`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(keyTypeNodeText); + attributeNode.kn = keyTypeNode; + const keyTypeBBox = keyTypeNode.node().getBBox(); + maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width); + nodeHeight = Math.max(nodeHeight, keyTypeBBox.height); + } + if (hasComment) { + const commentNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-comment`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeComment || ""); + attributeNode.cn = commentNode; + const commentNodeBBox = commentNode.node().getBBox(); + maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width); + nodeHeight = Math.max(nodeHeight, commentNodeBBox.height); + } + attributeNode.height = nodeHeight; + attributeNodes.push(attributeNode); + cumulativeHeight += nodeHeight + heightPadding * 2; + attrNum += 1; + }); + let widthPaddingFactor = 4; + if (hasKeyType) { + widthPaddingFactor += 2; + } + if (hasComment) { + widthPaddingFactor += 2; + } + const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth; + const bBox = { + width: Math.max( + conf.minEntityWidth, + Math.max( + labelBBox.width + conf.entityPadding * 2, + maxWidth + widthPadding * widthPaddingFactor + ) + ), + height: attributes.length > 0 ? cumulativeHeight : Math.max(conf.minEntityHeight, labelBBox.height + conf.entityPadding * 2) + }; + if (attributes.length > 0) { + const spareColumnWidth = Math.max( + 0, + (bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2) + ); + entityTextNode.attr( + "transform", + "translate(" + bBox.width / 2 + "," + (heightPadding + labelBBox.height / 2) + ")" + ); + let heightOffset = labelBBox.height + heightPadding * 2; + let attribStyle = "attributeBoxOdd"; + attributeNodes.forEach((attributeNode) => { + const alignY = heightOffset + heightPadding + attributeNode.height / 2; + attributeNode.tn.attr("transform", "translate(" + widthPadding + "," + alignY + ")"); + const typeRect = groupNode.insert("rect", "#" + attributeNode.tn.node().id).classed(`er ${attribStyle}`, true).attr("x", 0).attr("y", heightOffset).attr("width", maxTypeWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + const nameXOffset = parseFloat(typeRect.attr("x")) + parseFloat(typeRect.attr("width")); + attributeNode.nn.attr( + "transform", + "translate(" + (nameXOffset + widthPadding) + "," + alignY + ")" + ); + const nameRect = groupNode.insert("rect", "#" + attributeNode.nn.node().id).classed(`er ${attribStyle}`, true).attr("x", nameXOffset).attr("y", heightOffset).attr("width", maxNameWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + let keyTypeAndCommentXOffset = parseFloat(nameRect.attr("x")) + parseFloat(nameRect.attr("width")); + if (hasKeyType) { + attributeNode.kn.attr( + "transform", + "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")" + ); + const keyTypeRect = groupNode.insert("rect", "#" + attributeNode.kn.node().id).classed(`er ${attribStyle}`, true).attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxKeyWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + keyTypeAndCommentXOffset = parseFloat(keyTypeRect.attr("x")) + parseFloat(keyTypeRect.attr("width")); + } + if (hasComment) { + attributeNode.cn.attr( + "transform", + "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")" + ); + groupNode.insert("rect", "#" + attributeNode.cn.node().id).classed(`er ${attribStyle}`, "true").attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxCommentWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + } + heightOffset += attributeNode.height + heightPadding * 2; + attribStyle = attribStyle === "attributeBoxOdd" ? "attributeBoxEven" : "attributeBoxOdd"; + }); + } else { + bBox.height = Math.max(conf.minEntityHeight, cumulativeHeight); + entityTextNode.attr("transform", "translate(" + bBox.width / 2 + "," + bBox.height / 2 + ")"); + } + return bBox; +}; +const drawEntities = function(svgNode, entities2, graph) { + const keys = Object.keys(entities2); + let firstOne; + keys.forEach(function(entityName) { + const entityId = generateId(entityName, "entity"); + entityNameIds.set(entityName, entityId); + const groupNode = svgNode.append("g").attr("id", entityId); + firstOne = firstOne === void 0 ? entityId : firstOne; + const textId = "text-" + entityId; + const textNode = groupNode.append("text").classed("er entityLabel", true).attr("id", textId).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "middle").style("font-family", getConfig().fontFamily).style("font-size", conf.fontSize + "px").text(entities2[entityName].alias ?? entityName); + const { width: entityWidth, height: entityHeight } = drawAttributes( + groupNode, + textNode, + entities2[entityName].attributes + ); + const rectNode = groupNode.insert("rect", "#" + textId).classed("er entityBox", true).attr("x", 0).attr("y", 0).attr("width", entityWidth).attr("height", entityHeight); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(entityId, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id: entityId + }); + }); + return firstOne; +}; +const adjustEntities = function(svgNode, graph) { + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + svgNode.select("#" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )" + ); + } + }); +}; +const getEdgeName = function(rel) { + return (rel.entityA + rel.roleA + rel.entityB).replace(/\s/g, ""); +}; +const addRelationships = function(relationships2, g) { + relationships2.forEach(function(r) { + g.setEdge( + entityNameIds.get(r.entityA), + entityNameIds.get(r.entityB), + { relationship: r }, + getEdgeName(r) + ); + }); + return relationships2; +}; +let relCnt = 0; +const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) { + relCnt++; + const edge = g.edge( + entityNameIds.get(rel.entityA), + entityNameIds.get(rel.entityB), + getEdgeName(rel) + ); + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = svg.insert("path", "#" + insert).classed("er relationshipLine", true).attr("d", lineFunction(edge.points)).style("stroke", conf.stroke).style("fill", "none"); + if (rel.relSpec.relType === diagObj.db.Identification.NON_IDENTIFYING) { + svgPath.attr("stroke-dasharray", "8,8"); + } + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + switch (rel.relSpec.cardA) { + case diagObj.db.Cardinality.ZERO_OR_ONE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_END + ")"); + break; + case diagObj.db.Cardinality.ZERO_OR_MORE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_END + ")"); + break; + case diagObj.db.Cardinality.ONE_OR_MORE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_END + ")"); + break; + case diagObj.db.Cardinality.ONLY_ONE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_END + ")"); + break; + case diagObj.db.Cardinality.MD_PARENT: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_END + ")"); + break; + } + switch (rel.relSpec.cardB) { + case diagObj.db.Cardinality.ZERO_OR_ONE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_START + ")" + ); + break; + case diagObj.db.Cardinality.ZERO_OR_MORE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_START + ")" + ); + break; + case diagObj.db.Cardinality.ONE_OR_MORE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_START + ")" + ); + break; + case diagObj.db.Cardinality.ONLY_ONE: + svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_START + ")"); + break; + case diagObj.db.Cardinality.MD_PARENT: + svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_START + ")"); + break; + } + const len = svgPath.node().getTotalLength(); + const labelPoint = svgPath.node().getPointAtLength(len * 0.5); + const labelId = "rel" + relCnt; + const labelNode = svg.append("text").classed("er relationshipLabel", true).attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).style("text-anchor", "middle").style("dominant-baseline", "middle").style("font-family", getConfig().fontFamily).style("font-size", conf.fontSize + "px").text(rel.roleA); + const labelBBox = labelNode.node().getBBox(); + svg.insert("rect", "#" + labelId).classed("er relationshipLabelBox", true).attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height); +}; +const draw = function(text, id, _version, diagObj) { + conf = getConfig().er; + log$1.info("Drawing ER diagram"); + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id='${id}']`); + erMarkers.insertMarkers(svg, conf); + let g; + g = new Graph({ + multigraph: true, + directed: true, + compound: false + }).setGraph({ + rankdir: conf.layoutDirection, + marginx: 20, + marginy: 20, + nodesep: 100, + edgesep: 100, + ranksep: 100 + }).setDefaultEdgeLabel(function() { + return {}; + }); + const firstEntity = drawEntities(svg, diagObj.db.getEntities(), g); + const relationships2 = addRelationships(diagObj.db.getRelationships(), g); + layout(g); + adjustEntities(svg, g); + relationships2.forEach(function(rel) { + drawRelationshipFromLayout(svg, rel, g, firstEntity, diagObj); + }); + const padding = conf.diagramPadding; + utils.insertTitle(svg, "entityTitleText", conf.titleTopMargin, diagObj.db.getDiagramTitle()); + const svgBounds = svg.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(svg, height, width, conf.useMaxWidth); + svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); +}; +const MERMAID_ERDIAGRAM_UUID = "28e9f9db-3c8d-5aa5-9faf-44286ae5937c"; +function generateId(str = "", prefix = "") { + const simplifiedStr = str.replace(BAD_ID_CHARS_REGEXP, ""); + return `${strWithHyphen(prefix)}${strWithHyphen(simplifiedStr)}${v5( + str, + MERMAID_ERDIAGRAM_UUID + )}`; +} +function strWithHyphen(str = "") { + return str.length > 0 ? `${str}-` : ""; +} +const erRenderer = { + setConf, + draw +}; +const getStyles = (options) => ` + .entityBox { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + } + + .attributeBoxOdd { + fill: ${options.attributeBackgroundColorOdd}; + stroke: ${options.nodeBorder}; + } + + .attributeBoxEven { + fill: ${options.attributeBackgroundColorEven}; + stroke: ${options.nodeBorder}; + } + + .relationshipLabelBox { + fill: ${options.tertiaryColor}; + opacity: 0.7; + background-color: ${options.tertiaryColor}; + rect { + opacity: 0.5; + } + } + + .relationshipLine { + stroke: ${options.lineColor}; + } + + .entityTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } + #MD_PARENT_START { + fill: #f5f5f5 !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; + } + #MD_PARENT_END { + fill: #f5f5f5 !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; + } + +`; +const erStyles = getStyles; +const diagram = { + parser: erParser, + db: erDb, + renderer: erRenderer, + styles: erStyles +}; + +export { diagram }; diff --git a/libs/marked/flowDb-c1833063-C_SlfbWJ.js b/libs/marked/flowDb-c1833063-C_SlfbWJ.js new file mode 100644 index 0000000..172b73b --- /dev/null +++ b/libs/marked/flowDb-c1833063-C_SlfbWJ.js @@ -0,0 +1,1711 @@ +import { c as getConfig, aq as defaultConfig, s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, A as utils, E as clear$1, j as common$1, h as select } from './index-CN3YjQ0n.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 4], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 8, 9, 10, 11, 27, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $V4 = [2, 2], $V5 = [1, 13], $V6 = [1, 14], $V7 = [1, 15], $V8 = [1, 16], $V9 = [1, 23], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 49], $Ve = [1, 48], $Vf = [1, 29], $Vg = [1, 30], $Vh = [1, 31], $Vi = [1, 32], $Vj = [1, 33], $Vk = [1, 44], $Vl = [1, 46], $Vm = [1, 42], $Vn = [1, 47], $Vo = [1, 43], $Vp = [1, 50], $Vq = [1, 45], $Vr = [1, 51], $Vs = [1, 52], $Vt = [1, 34], $Vu = [1, 35], $Vv = [1, 36], $Vw = [1, 37], $Vx = [1, 57], $Vy = [1, 8, 9, 10, 11, 27, 32, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $Vz = [1, 61], $VA = [1, 60], $VB = [1, 62], $VC = [8, 9, 11, 73, 75], $VD = [1, 88], $VE = [1, 93], $VF = [1, 92], $VG = [1, 89], $VH = [1, 85], $VI = [1, 91], $VJ = [1, 87], $VK = [1, 94], $VL = [1, 90], $VM = [1, 95], $VN = [1, 86], $VO = [8, 9, 10, 11, 73, 75], $VP = [8, 9, 10, 11, 44, 73, 75], $VQ = [8, 9, 10, 11, 29, 42, 44, 46, 48, 50, 52, 54, 56, 58, 61, 63, 65, 66, 68, 73, 75, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VR = [8, 9, 11, 42, 58, 73, 75, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VS = [42, 58, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VT = [1, 121], $VU = [1, 120], $VV = [1, 128], $VW = [1, 142], $VX = [1, 143], $VY = [1, 144], $VZ = [1, 145], $V_ = [1, 130], $V$ = [1, 132], $V01 = [1, 136], $V11 = [1, 137], $V21 = [1, 138], $V31 = [1, 139], $V41 = [1, 140], $V51 = [1, 141], $V61 = [1, 146], $V71 = [1, 147], $V81 = [1, 126], $V91 = [1, 127], $Va1 = [1, 134], $Vb1 = [1, 129], $Vc1 = [1, 133], $Vd1 = [1, 131], $Ve1 = [8, 9, 10, 11, 27, 32, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $Vf1 = [1, 149], $Vg1 = [8, 9, 11], $Vh1 = [8, 9, 10, 11, 14, 42, 58, 86, 102, 103, 106, 108, 111, 112, 113], $Vi1 = [1, 169], $Vj1 = [1, 165], $Vk1 = [1, 166], $Vl1 = [1, 170], $Vm1 = [1, 167], $Vn1 = [1, 168], $Vo1 = [75, 113, 116], $Vp1 = [8, 9, 10, 11, 12, 14, 27, 29, 32, 42, 58, 73, 81, 82, 83, 84, 85, 86, 87, 102, 106, 108, 111, 112, 113], $Vq1 = [10, 103], $Vr1 = [31, 47, 49, 51, 53, 55, 60, 62, 64, 65, 67, 69, 113, 114, 115], $Vs1 = [1, 235], $Vt1 = [1, 233], $Vu1 = [1, 237], $Vv1 = [1, 231], $Vw1 = [1, 232], $Vx1 = [1, 234], $Vy1 = [1, 236], $Vz1 = [1, 238], $VA1 = [1, 255], $VB1 = [8, 9, 11, 103], $VC1 = [8, 9, 10, 11, 58, 81, 102, 103, 106, 107, 108, 109]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "graphConfig": 4, "document": 5, "line": 6, "statement": 7, "SEMI": 8, "NEWLINE": 9, "SPACE": 10, "EOF": 11, "GRAPH": 12, "NODIR": 13, "DIR": 14, "FirstStmtSeparator": 15, "ending": 16, "endToken": 17, "spaceList": 18, "spaceListNewline": 19, "vertexStatement": 20, "separator": 21, "styleStatement": 22, "linkStyleStatement": 23, "classDefStatement": 24, "classStatement": 25, "clickStatement": 26, "subgraph": 27, "textNoTags": 28, "SQS": 29, "text": 30, "SQE": 31, "end": 32, "direction": 33, "acc_title": 34, "acc_title_value": 35, "acc_descr": 36, "acc_descr_value": 37, "acc_descr_multiline_value": 38, "link": 39, "node": 40, "styledVertex": 41, "AMP": 42, "vertex": 43, "STYLE_SEPARATOR": 44, "idString": 45, "DOUBLECIRCLESTART": 46, "DOUBLECIRCLEEND": 47, "PS": 48, "PE": 49, "(-": 50, "-)": 51, "STADIUMSTART": 52, "STADIUMEND": 53, "SUBROUTINESTART": 54, "SUBROUTINEEND": 55, "VERTEX_WITH_PROPS_START": 56, "NODE_STRING[field]": 57, "COLON": 58, "NODE_STRING[value]": 59, "PIPE": 60, "CYLINDERSTART": 61, "CYLINDEREND": 62, "DIAMOND_START": 63, "DIAMOND_STOP": 64, "TAGEND": 65, "TRAPSTART": 66, "TRAPEND": 67, "INVTRAPSTART": 68, "INVTRAPEND": 69, "linkStatement": 70, "arrowText": 71, "TESTSTR": 72, "START_LINK": 73, "edgeText": 74, "LINK": 75, "edgeTextToken": 76, "STR": 77, "MD_STR": 78, "textToken": 79, "keywords": 80, "STYLE": 81, "LINKSTYLE": 82, "CLASSDEF": 83, "CLASS": 84, "CLICK": 85, "DOWN": 86, "UP": 87, "textNoTagsToken": 88, "stylesOpt": 89, "idString[vertex]": 90, "idString[class]": 91, "CALLBACKNAME": 92, "CALLBACKARGS": 93, "HREF": 94, "LINK_TARGET": 95, "STR[link]": 96, "STR[tooltip]": 97, "alphaNum": 98, "DEFAULT": 99, "numList": 100, "INTERPOLATE": 101, "NUM": 102, "COMMA": 103, "style": 104, "styleComponent": 105, "NODE_STRING": 106, "UNIT": 107, "BRKT": 108, "PCT": 109, "idStringToken": 110, "MINUS": 111, "MULT": 112, "UNICODE_TEXT": 113, "TEXT": 114, "TAGSTART": 115, "EDGE_TEXT": 116, "alphaNumToken": 117, "direction_tb": 118, "direction_bt": 119, "direction_rl": 120, "direction_lr": 121, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 8: "SEMI", 9: "NEWLINE", 10: "SPACE", 11: "EOF", 12: "GRAPH", 13: "NODIR", 14: "DIR", 27: "subgraph", 29: "SQS", 31: "SQE", 32: "end", 34: "acc_title", 35: "acc_title_value", 36: "acc_descr", 37: "acc_descr_value", 38: "acc_descr_multiline_value", 42: "AMP", 44: "STYLE_SEPARATOR", 46: "DOUBLECIRCLESTART", 47: "DOUBLECIRCLEEND", 48: "PS", 49: "PE", 50: "(-", 51: "-)", 52: "STADIUMSTART", 53: "STADIUMEND", 54: "SUBROUTINESTART", 55: "SUBROUTINEEND", 56: "VERTEX_WITH_PROPS_START", 57: "NODE_STRING[field]", 58: "COLON", 59: "NODE_STRING[value]", 60: "PIPE", 61: "CYLINDERSTART", 62: "CYLINDEREND", 63: "DIAMOND_START", 64: "DIAMOND_STOP", 65: "TAGEND", 66: "TRAPSTART", 67: "TRAPEND", 68: "INVTRAPSTART", 69: "INVTRAPEND", 72: "TESTSTR", 73: "START_LINK", 75: "LINK", 77: "STR", 78: "MD_STR", 81: "STYLE", 82: "LINKSTYLE", 83: "CLASSDEF", 84: "CLASS", 85: "CLICK", 86: "DOWN", 87: "UP", 90: "idString[vertex]", 91: "idString[class]", 92: "CALLBACKNAME", 93: "CALLBACKARGS", 94: "HREF", 95: "LINK_TARGET", 96: "STR[link]", 97: "STR[tooltip]", 99: "DEFAULT", 101: "INTERPOLATE", 102: "NUM", 103: "COMMA", 106: "NODE_STRING", 107: "UNIT", 108: "BRKT", 109: "PCT", 111: "MINUS", 112: "MULT", 113: "UNICODE_TEXT", 114: "TEXT", 115: "TAGSTART", 116: "EDGE_TEXT", 118: "direction_tb", 119: "direction_bt", 120: "direction_rl", 121: "direction_lr" }, + productions_: [0, [3, 2], [5, 0], [5, 2], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [4, 2], [4, 2], [4, 2], [4, 3], [16, 2], [16, 1], [17, 1], [17, 1], [17, 1], [15, 1], [15, 1], [15, 2], [19, 2], [19, 2], [19, 1], [19, 1], [18, 2], [18, 1], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 9], [7, 6], [7, 4], [7, 1], [7, 2], [7, 2], [7, 1], [21, 1], [21, 1], [21, 1], [20, 3], [20, 4], [20, 2], [20, 1], [40, 1], [40, 5], [41, 1], [41, 3], [43, 4], [43, 4], [43, 6], [43, 4], [43, 4], [43, 4], [43, 8], [43, 4], [43, 4], [43, 4], [43, 6], [43, 4], [43, 4], [43, 4], [43, 4], [43, 4], [43, 1], [39, 2], [39, 3], [39, 3], [39, 1], [39, 3], [74, 1], [74, 2], [74, 1], [74, 1], [70, 1], [71, 3], [30, 1], [30, 2], [30, 1], [30, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [28, 1], [28, 2], [28, 1], [28, 1], [24, 5], [25, 5], [26, 2], [26, 4], [26, 3], [26, 5], [26, 3], [26, 5], [26, 5], [26, 7], [26, 2], [26, 4], [26, 2], [26, 4], [26, 4], [26, 6], [22, 5], [23, 5], [23, 5], [23, 9], [23, 9], [23, 7], [23, 7], [100, 1], [100, 3], [89, 1], [89, 3], [104, 1], [104, 2], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [79, 1], [79, 1], [79, 1], [79, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [76, 1], [76, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [45, 1], [45, 2], [98, 1], [98, 2], [33, 1], [33, 1], [33, 1], [33, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 2: + this.$ = []; + break; + case 3: + if (!Array.isArray($$[$0]) || $$[$0].length > 0) { + $$[$0 - 1].push($$[$0]); + } + this.$ = $$[$0 - 1]; + break; + case 4: + case 176: + this.$ = $$[$0]; + break; + case 11: + yy.setDirection("TB"); + this.$ = "TB"; + break; + case 12: + yy.setDirection($$[$0 - 1]); + this.$ = $$[$0 - 1]; + break; + case 27: + this.$ = $$[$0 - 1].nodes; + break; + case 28: + case 29: + case 30: + case 31: + case 32: + this.$ = []; + break; + case 33: + this.$ = yy.addSubGraph($$[$0 - 6], $$[$0 - 1], $$[$0 - 4]); + break; + case 34: + this.$ = yy.addSubGraph($$[$0 - 3], $$[$0 - 1], $$[$0 - 3]); + break; + case 35: + this.$ = yy.addSubGraph(void 0, $$[$0 - 1], void 0); + break; + case 37: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 38: + case 39: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 43: + yy.addLink($$[$0 - 2].stmt, $$[$0], $$[$0 - 1]); + this.$ = { stmt: $$[$0], nodes: $$[$0].concat($$[$0 - 2].nodes) }; + break; + case 44: + yy.addLink($$[$0 - 3].stmt, $$[$0 - 1], $$[$0 - 2]); + this.$ = { stmt: $$[$0 - 1], nodes: $$[$0 - 1].concat($$[$0 - 3].nodes) }; + break; + case 45: + this.$ = { stmt: $$[$0 - 1], nodes: $$[$0 - 1] }; + break; + case 46: + this.$ = { stmt: $$[$0], nodes: $$[$0] }; + break; + case 47: + this.$ = [$$[$0]]; + break; + case 48: + this.$ = $$[$0 - 4].concat($$[$0]); + break; + case 49: + this.$ = $$[$0]; + break; + case 50: + this.$ = $$[$0 - 2]; + yy.setClass($$[$0 - 2], $$[$0]); + break; + case 51: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "square"); + break; + case 52: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "doublecircle"); + break; + case 53: + this.$ = $$[$0 - 5]; + yy.addVertex($$[$0 - 5], $$[$0 - 2], "circle"); + break; + case 54: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "ellipse"); + break; + case 55: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "stadium"); + break; + case 56: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "subroutine"); + break; + case 57: + this.$ = $$[$0 - 7]; + yy.addVertex($$[$0 - 7], $$[$0 - 1], "rect", void 0, void 0, void 0, Object.fromEntries([[$$[$0 - 5], $$[$0 - 3]]])); + break; + case 58: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "cylinder"); + break; + case 59: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "round"); + break; + case 60: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "diamond"); + break; + case 61: + this.$ = $$[$0 - 5]; + yy.addVertex($$[$0 - 5], $$[$0 - 2], "hexagon"); + break; + case 62: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "odd"); + break; + case 63: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "trapezoid"); + break; + case 64: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "inv_trapezoid"); + break; + case 65: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "lean_right"); + break; + case 66: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "lean_left"); + break; + case 67: + this.$ = $$[$0]; + yy.addVertex($$[$0]); + break; + case 68: + $$[$0 - 1].text = $$[$0]; + this.$ = $$[$0 - 1]; + break; + case 69: + case 70: + $$[$0 - 2].text = $$[$0 - 1]; + this.$ = $$[$0 - 2]; + break; + case 71: + this.$ = $$[$0]; + break; + case 72: + var inf = yy.destructLink($$[$0], $$[$0 - 2]); + this.$ = { "type": inf.type, "stroke": inf.stroke, "length": inf.length, "text": $$[$0 - 1] }; + break; + case 73: + this.$ = { text: $$[$0], type: "text" }; + break; + case 74: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 75: + this.$ = { text: $$[$0], type: "string" }; + break; + case 76: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 77: + var inf = yy.destructLink($$[$0]); + this.$ = { "type": inf.type, "stroke": inf.stroke, "length": inf.length }; + break; + case 78: + this.$ = $$[$0 - 1]; + break; + case 79: + this.$ = { text: $$[$0], type: "text" }; + break; + case 80: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 81: + this.$ = { text: $$[$0], type: "string" }; + break; + case 82: + case 97: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 94: + this.$ = { text: $$[$0], type: "text" }; + break; + case 95: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 96: + this.$ = { text: $$[$0], type: "text" }; + break; + case 98: + this.$ = $$[$0 - 4]; + yy.addClass($$[$0 - 2], $$[$0]); + break; + case 99: + this.$ = $$[$0 - 4]; + yy.setClass($$[$0 - 2], $$[$0]); + break; + case 100: + case 108: + this.$ = $$[$0 - 1]; + yy.setClickEvent($$[$0 - 1], $$[$0]); + break; + case 101: + case 109: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 102: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 103: + this.$ = $$[$0 - 4]; + yy.setClickEvent($$[$0 - 4], $$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 4], $$[$0]); + break; + case 104: + this.$ = $$[$0 - 2]; + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 105: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 4], $$[$0 - 2]); + yy.setTooltip($$[$0 - 4], $$[$0]); + break; + case 106: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 107: + this.$ = $$[$0 - 6]; + yy.setLink($$[$0 - 6], $$[$0 - 4], $$[$0]); + yy.setTooltip($$[$0 - 6], $$[$0 - 2]); + break; + case 110: + this.$ = $$[$0 - 1]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 111: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 112: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 3], $$[$0 - 2], $$[$0]); + break; + case 113: + this.$ = $$[$0 - 5]; + yy.setLink($$[$0 - 5], $$[$0 - 4], $$[$0]); + yy.setTooltip($$[$0 - 5], $$[$0 - 2]); + break; + case 114: + this.$ = $$[$0 - 4]; + yy.addVertex($$[$0 - 2], void 0, void 0, $$[$0]); + break; + case 115: + this.$ = $$[$0 - 4]; + yy.updateLink([$$[$0 - 2]], $$[$0]); + break; + case 116: + this.$ = $$[$0 - 4]; + yy.updateLink($$[$0 - 2], $$[$0]); + break; + case 117: + this.$ = $$[$0 - 8]; + yy.updateLinkInterpolate([$$[$0 - 6]], $$[$0 - 2]); + yy.updateLink([$$[$0 - 6]], $$[$0]); + break; + case 118: + this.$ = $$[$0 - 8]; + yy.updateLinkInterpolate($$[$0 - 6], $$[$0 - 2]); + yy.updateLink($$[$0 - 6], $$[$0]); + break; + case 119: + this.$ = $$[$0 - 6]; + yy.updateLinkInterpolate([$$[$0 - 4]], $$[$0]); + break; + case 120: + this.$ = $$[$0 - 6]; + yy.updateLinkInterpolate($$[$0 - 4], $$[$0]); + break; + case 121: + case 123: + this.$ = [$$[$0]]; + break; + case 122: + case 124: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 126: + this.$ = $$[$0 - 1] + $$[$0]; + break; + case 174: + this.$ = $$[$0]; + break; + case 175: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + case 177: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + case 178: + this.$ = { stmt: "dir", value: "TB" }; + break; + case 179: + this.$ = { stmt: "dir", value: "BT" }; + break; + case 180: + this.$ = { stmt: "dir", value: "RL" }; + break; + case 181: + this.$ = { stmt: "dir", value: "LR" }; + break; + } + }, + table: [{ 3: 1, 4: 2, 9: $V0, 10: $V1, 12: $V2 }, { 1: [3] }, o($V3, $V4, { 5: 6 }), { 4: 7, 9: $V0, 10: $V1, 12: $V2 }, { 4: 8, 9: $V0, 10: $V1, 12: $V2 }, { 13: [1, 9], 14: [1, 10] }, { 1: [2, 1], 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, o($V3, [2, 9]), o($V3, [2, 10]), o($V3, [2, 11]), { 8: [1, 54], 9: [1, 55], 10: $Vx, 15: 53, 18: 56 }, o($Vy, [2, 3]), o($Vy, [2, 4]), o($Vy, [2, 5]), o($Vy, [2, 6]), o($Vy, [2, 7]), o($Vy, [2, 8]), { 8: $Vz, 9: $VA, 11: $VB, 21: 58, 39: 59, 70: 63, 73: [1, 64], 75: [1, 65] }, { 8: $Vz, 9: $VA, 11: $VB, 21: 66 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 67 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 68 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 69 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 70 }, { 8: $Vz, 9: $VA, 10: [1, 71], 11: $VB, 21: 72 }, o($Vy, [2, 36]), { 35: [1, 73] }, { 37: [1, 74] }, o($Vy, [2, 39]), o($VC, [2, 46], { 18: 75, 10: $Vx }), { 10: [1, 76] }, { 10: [1, 77] }, { 10: [1, 78] }, { 10: [1, 79] }, { 14: $VD, 42: $VE, 58: $VF, 77: [1, 83], 86: $VG, 92: [1, 80], 94: [1, 81], 98: 82, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, o($Vy, [2, 178]), o($Vy, [2, 179]), o($Vy, [2, 180]), o($Vy, [2, 181]), o($VO, [2, 47]), o($VO, [2, 49], { 44: [1, 96] }), o($VP, [2, 67], { 110: 109, 29: [1, 97], 42: $Vd, 46: [1, 98], 48: [1, 99], 50: [1, 100], 52: [1, 101], 54: [1, 102], 56: [1, 103], 58: $Ve, 61: [1, 104], 63: [1, 105], 65: [1, 106], 66: [1, 107], 68: [1, 108], 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), o($VQ, [2, 174]), o($VQ, [2, 135]), o($VQ, [2, 136]), o($VQ, [2, 137]), o($VQ, [2, 138]), o($VQ, [2, 139]), o($VQ, [2, 140]), o($VQ, [2, 141]), o($VQ, [2, 142]), o($VQ, [2, 143]), o($VQ, [2, 144]), o($VQ, [2, 145]), o($V3, [2, 12]), o($V3, [2, 18]), o($V3, [2, 19]), { 9: [1, 110] }, o($VR, [2, 26], { 18: 111, 10: $Vx }), o($Vy, [2, 27]), { 40: 112, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vy, [2, 40]), o($Vy, [2, 41]), o($Vy, [2, 42]), o($VS, [2, 71], { 71: 113, 60: [1, 115], 72: [1, 114] }), { 74: 116, 76: 117, 77: [1, 118], 78: [1, 119], 113: $VT, 116: $VU }, o([42, 58, 60, 72, 86, 99, 102, 103, 106, 108, 111, 112, 113], [2, 77]), o($Vy, [2, 28]), o($Vy, [2, 29]), o($Vy, [2, 30]), o($Vy, [2, 31]), o($Vy, [2, 32]), { 10: $VV, 12: $VW, 14: $VX, 27: $VY, 28: 122, 32: $VZ, 42: $V_, 58: $V$, 73: $V01, 77: [1, 124], 78: [1, 125], 80: 135, 81: $V11, 82: $V21, 83: $V31, 84: $V41, 85: $V51, 86: $V61, 87: $V71, 88: 123, 102: $V81, 106: $V91, 108: $Va1, 111: $Vb1, 112: $Vc1, 113: $Vd1 }, o($Ve1, $V4, { 5: 148 }), o($Vy, [2, 37]), o($Vy, [2, 38]), o($VC, [2, 45], { 42: $Vf1 }), { 42: $Vd, 45: 150, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 99: [1, 151], 100: 152, 102: [1, 153] }, { 42: $Vd, 45: 154, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 42: $Vd, 45: 155, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vg1, [2, 100], { 10: [1, 156], 93: [1, 157] }), { 77: [1, 158] }, o($Vg1, [2, 108], { 117: 160, 10: [1, 159], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 110], { 10: [1, 161] }), o($Vh1, [2, 176]), o($Vh1, [2, 163]), o($Vh1, [2, 164]), o($Vh1, [2, 165]), o($Vh1, [2, 166]), o($Vh1, [2, 167]), o($Vh1, [2, 168]), o($Vh1, [2, 169]), o($Vh1, [2, 170]), o($Vh1, [2, 171]), o($Vh1, [2, 172]), o($Vh1, [2, 173]), { 42: $Vd, 45: 162, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 30: 163, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 171, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 173, 48: [1, 172], 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 174, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 175, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 176, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 106: [1, 177] }, { 30: 178, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 179, 63: [1, 180], 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 181, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 182, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 183, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VQ, [2, 175]), o($V3, [2, 20]), o($VR, [2, 25]), o($VC, [2, 43], { 18: 184, 10: $Vx }), o($VS, [2, 68], { 10: [1, 185] }), { 10: [1, 186] }, { 30: 187, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 75: [1, 188], 76: 189, 113: $VT, 116: $VU }, o($Vo1, [2, 73]), o($Vo1, [2, 75]), o($Vo1, [2, 76]), o($Vo1, [2, 161]), o($Vo1, [2, 162]), { 8: $Vz, 9: $VA, 10: $VV, 11: $VB, 12: $VW, 14: $VX, 21: 191, 27: $VY, 29: [1, 190], 32: $VZ, 42: $V_, 58: $V$, 73: $V01, 80: 135, 81: $V11, 82: $V21, 83: $V31, 84: $V41, 85: $V51, 86: $V61, 87: $V71, 88: 192, 102: $V81, 106: $V91, 108: $Va1, 111: $Vb1, 112: $Vc1, 113: $Vd1 }, o($Vp1, [2, 94]), o($Vp1, [2, 96]), o($Vp1, [2, 97]), o($Vp1, [2, 150]), o($Vp1, [2, 151]), o($Vp1, [2, 152]), o($Vp1, [2, 153]), o($Vp1, [2, 154]), o($Vp1, [2, 155]), o($Vp1, [2, 156]), o($Vp1, [2, 157]), o($Vp1, [2, 158]), o($Vp1, [2, 159]), o($Vp1, [2, 160]), o($Vp1, [2, 83]), o($Vp1, [2, 84]), o($Vp1, [2, 85]), o($Vp1, [2, 86]), o($Vp1, [2, 87]), o($Vp1, [2, 88]), o($Vp1, [2, 89]), o($Vp1, [2, 90]), o($Vp1, [2, 91]), o($Vp1, [2, 92]), o($Vp1, [2, 93]), { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 193], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, { 10: $Vx, 18: 194 }, { 10: [1, 195], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: [1, 196] }, { 10: [1, 197], 103: [1, 198] }, o($Vq1, [2, 121]), { 10: [1, 199], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: [1, 200], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 77: [1, 201] }, o($Vg1, [2, 102], { 10: [1, 202] }), o($Vg1, [2, 104], { 10: [1, 203] }), { 77: [1, 204] }, o($Vh1, [2, 177]), { 77: [1, 205], 95: [1, 206] }, o($VO, [2, 50], { 110: 109, 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), { 31: [1, 207], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($Vr1, [2, 79]), o($Vr1, [2, 81]), o($Vr1, [2, 82]), o($Vr1, [2, 146]), o($Vr1, [2, 147]), o($Vr1, [2, 148]), o($Vr1, [2, 149]), { 47: [1, 209], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 210, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 49: [1, 211], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 51: [1, 212], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 53: [1, 213], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 55: [1, 214], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 58: [1, 215] }, { 62: [1, 216], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 64: [1, 217], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 218, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 31: [1, 219], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 65: $Vi1, 67: [1, 220], 69: [1, 221], 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 65: $Vi1, 67: [1, 223], 69: [1, 222], 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VC, [2, 44], { 42: $Vf1 }), o($VS, [2, 70]), o($VS, [2, 69]), { 60: [1, 224], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VS, [2, 72]), o($Vo1, [2, 74]), { 30: 225, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($Ve1, $V4, { 5: 226 }), o($Vp1, [2, 95]), o($Vy, [2, 35]), { 41: 227, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 228, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 239, 101: [1, 240], 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 241, 101: [1, 242], 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 102: [1, 243] }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 244, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 42: $Vd, 45: 245, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vg1, [2, 101]), { 77: [1, 246] }, { 77: [1, 247], 95: [1, 248] }, o($Vg1, [2, 109]), o($Vg1, [2, 111], { 10: [1, 249] }), o($Vg1, [2, 112]), o($VP, [2, 51]), o($Vr1, [2, 80]), o($VP, [2, 52]), { 49: [1, 250], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 59]), o($VP, [2, 54]), o($VP, [2, 55]), o($VP, [2, 56]), { 106: [1, 251] }, o($VP, [2, 58]), o($VP, [2, 60]), { 64: [1, 252], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 62]), o($VP, [2, 63]), o($VP, [2, 65]), o($VP, [2, 64]), o($VP, [2, 66]), o([10, 42, 58, 86, 99, 102, 103, 106, 108, 111, 112, 113], [2, 78]), { 31: [1, 253], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 254], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, o($VO, [2, 48]), o($Vg1, [2, 114], { 103: $VA1 }), o($VB1, [2, 123], { 105: 256, 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }), o($VC1, [2, 125]), o($VC1, [2, 127]), o($VC1, [2, 128]), o($VC1, [2, 129]), o($VC1, [2, 130]), o($VC1, [2, 131]), o($VC1, [2, 132]), o($VC1, [2, 133]), o($VC1, [2, 134]), o($Vg1, [2, 115], { 103: $VA1 }), { 10: [1, 257] }, o($Vg1, [2, 116], { 103: $VA1 }), { 10: [1, 258] }, o($Vq1, [2, 122]), o($Vg1, [2, 98], { 103: $VA1 }), o($Vg1, [2, 99], { 110: 109, 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), o($Vg1, [2, 103]), o($Vg1, [2, 105], { 10: [1, 259] }), o($Vg1, [2, 106]), { 95: [1, 260] }, { 49: [1, 261] }, { 60: [1, 262] }, { 64: [1, 263] }, { 8: $Vz, 9: $VA, 11: $VB, 21: 264 }, o($Vy, [2, 34]), { 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 104: 265, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, o($VC1, [2, 126]), { 14: $VD, 42: $VE, 58: $VF, 86: $VG, 98: 266, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, { 14: $VD, 42: $VE, 58: $VF, 86: $VG, 98: 267, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, { 95: [1, 268] }, o($Vg1, [2, 113]), o($VP, [2, 53]), { 30: 269, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 61]), o($Ve1, $V4, { 5: 270 }), o($VB1, [2, 124], { 105: 256, 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }), o($Vg1, [2, 119], { 117: 160, 10: [1, 271], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 120], { 117: 160, 10: [1, 272], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 107]), { 31: [1, 273], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 274], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 275, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 276, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, o($VP, [2, 57]), o($Vy, [2, 33]), o($Vg1, [2, 117], { 103: $VA1 }), o($Vg1, [2, 118], { 103: $VA1 })], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex2() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex2(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex2() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 34; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 36; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + this.begin("callbackname"); + break; + case 8: + this.popState(); + break; + case 9: + this.popState(); + this.begin("callbackargs"); + break; + case 10: + return 92; + case 11: + this.popState(); + break; + case 12: + return 93; + case 13: + return "MD_STR"; + case 14: + this.popState(); + break; + case 15: + this.begin("md_string"); + break; + case 16: + return "STR"; + case 17: + this.popState(); + break; + case 18: + this.pushState("string"); + break; + case 19: + return 81; + case 20: + return 99; + case 21: + return 82; + case 22: + return 101; + case 23: + return 83; + case 24: + return 84; + case 25: + return 94; + case 26: + this.begin("click"); + break; + case 27: + this.popState(); + break; + case 28: + return 85; + case 29: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 30: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 31: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 32: + return 27; + case 33: + return 32; + case 34: + return 95; + case 35: + return 95; + case 36: + return 95; + case 37: + return 95; + case 38: + this.popState(); + return 13; + case 39: + this.popState(); + return 14; + case 40: + this.popState(); + return 14; + case 41: + this.popState(); + return 14; + case 42: + this.popState(); + return 14; + case 43: + this.popState(); + return 14; + case 44: + this.popState(); + return 14; + case 45: + this.popState(); + return 14; + case 46: + this.popState(); + return 14; + case 47: + this.popState(); + return 14; + case 48: + this.popState(); + return 14; + case 49: + return 118; + case 50: + return 119; + case 51: + return 120; + case 52: + return 121; + case 53: + return 102; + case 54: + return 108; + case 55: + return 44; + case 56: + return 58; + case 57: + return 42; + case 58: + return 8; + case 59: + return 103; + case 60: + return 112; + case 61: + this.popState(); + return 75; + case 62: + this.pushState("edgeText"); + return 73; + case 63: + return 116; + case 64: + this.popState(); + return 75; + case 65: + this.pushState("thickEdgeText"); + return 73; + case 66: + return 116; + case 67: + this.popState(); + return 75; + case 68: + this.pushState("dottedEdgeText"); + return 73; + case 69: + return 116; + case 70: + return 75; + case 71: + this.popState(); + return 51; + case 72: + return "TEXT"; + case 73: + this.pushState("ellipseText"); + return 50; + case 74: + this.popState(); + return 53; + case 75: + this.pushState("text"); + return 52; + case 76: + this.popState(); + return 55; + case 77: + this.pushState("text"); + return 54; + case 78: + return 56; + case 79: + this.pushState("text"); + return 65; + case 80: + this.popState(); + return 62; + case 81: + this.pushState("text"); + return 61; + case 82: + this.popState(); + return 47; + case 83: + this.pushState("text"); + return 46; + case 84: + this.popState(); + return 67; + case 85: + this.popState(); + return 69; + case 86: + return 114; + case 87: + this.pushState("trapText"); + return 66; + case 88: + this.pushState("trapText"); + return 68; + case 89: + return 115; + case 90: + return 65; + case 91: + return 87; + case 92: + return "SEP"; + case 93: + return 86; + case 94: + return 112; + case 95: + return 108; + case 96: + return 42; + case 97: + return 106; + case 98: + return 111; + case 99: + return 113; + case 100: + this.popState(); + return 60; + case 101: + this.pushState("text"); + return 60; + case 102: + this.popState(); + return 49; + case 103: + this.pushState("text"); + return 48; + case 104: + this.popState(); + return 31; + case 105: + this.pushState("text"); + return 29; + case 106: + this.popState(); + return 64; + case 107: + this.pushState("text"); + return 63; + case 108: + return "TEXT"; + case 109: + return "QUOTE"; + case 110: + return 9; + case 111: + return 10; + case 112: + return 11; + } + }, + rules: [/^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:call[\s]+)/, /^(?:\([\s]*\))/, /^(?:\()/, /^(?:[^(]*)/, /^(?:\))/, /^(?:[^)]*)/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["][`])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:["])/, /^(?:style\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\b)/, /^(?:class\b)/, /^(?:href[\s])/, /^(?:click[\s]+)/, /^(?:[\s\n])/, /^(?:[^\s\n]*)/, /^(?:flowchart-elk\b)/, /^(?:graph\b)/, /^(?:flowchart\b)/, /^(?:subgraph\b)/, /^(?:end\b\s*)/, /^(?:_self\b)/, /^(?:_blank\b)/, /^(?:_parent\b)/, /^(?:_top\b)/, /^(?:(\r?\n)*\s*\n)/, /^(?:\s*LR\b)/, /^(?:\s*RL\b)/, /^(?:\s*TB\b)/, /^(?:\s*BT\b)/, /^(?:\s*TD\b)/, /^(?:\s*BR\b)/, /^(?:\s*<)/, /^(?:\s*>)/, /^(?:\s*\^)/, /^(?:\s*v\b)/, /^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:[0-9]+)/, /^(?:#)/, /^(?::::)/, /^(?::)/, /^(?:&)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:[^-]|-(?!-)+)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:[^=]|=(?!))/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:[^\.]|\.(?!))/, /^(?:\s*~~[\~]+\s*)/, /^(?:[-/\)][\)])/, /^(?:[^\(\)\[\]\{\}]|!\)+)/, /^(?:\(-)/, /^(?:\]\))/, /^(?:\(\[)/, /^(?:\]\])/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:>)/, /^(?:\)\])/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\(\(\()/, /^(?:[\\(?=\])][\]])/, /^(?:\/(?=\])\])/, /^(?:\/(?!\])|\\(?!\])|[^\\\[\]\(\)\{\}\/]+)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:<)/, /^(?:>)/, /^(?:\^)/, /^(?:\\\|)/, /^(?:v\b)/, /^(?:\*)/, /^(?:#)/, /^(?:&)/, /^(?:([A-Za-z0-9!"\#$%&'*+\.`?\\_\/]|-(?=[^\>\-\.])|(?!))+)/, /^(?:-)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\|)/, /^(?:\|)/, /^(?:\))/, /^(?:\()/, /^(?:\])/, /^(?:\[)/, /^(?:(\}))/, /^(?:\{)/, /^(?:[^\[\]\(\)\{\}\|\"]+)/, /^(?:")/, /^(?:(\r?\n)+)/, /^(?:\s)/, /^(?:$)/], + conditions: { "callbackargs": { "rules": [11, 12, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "callbackname": { "rules": [8, 9, 10, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "href": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "click": { "rules": [15, 18, 27, 28, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "dottedEdgeText": { "rules": [15, 18, 67, 69, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "thickEdgeText": { "rules": [15, 18, 64, 66, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "edgeText": { "rules": [15, 18, 61, 63, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "trapText": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 84, 85, 86, 87, 88, 101, 103, 105, 107], "inclusive": false }, "ellipseText": { "rules": [15, 18, 70, 71, 72, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "text": { "rules": [15, 18, 70, 73, 74, 75, 76, 77, 80, 81, 82, 83, 87, 88, 100, 101, 102, 103, 104, 105, 106, 107, 108], "inclusive": false }, "vertex": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "dir": { "rules": [15, 18, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_descr_multiline": { "rules": [5, 6, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_descr": { "rules": [3, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_title": { "rules": [1, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "md_string": { "rules": [13, 14, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "string": { "rules": [15, 16, 17, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 67, 68, 70, 73, 75, 77, 78, 79, 81, 83, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 103, 105, 107, 109, 110, 111, 112], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const MERMAID_DOM_ID_PREFIX = "flowchart-"; +let vertexCounter = 0; +let config = getConfig(); +let vertices = {}; +let edges = []; +let classes = {}; +let subGraphs = []; +let subGraphLookup = {}; +let tooltips = {}; +let subCount = 0; +let firstGraphFlag = true; +let direction; +let version; +let funs = []; +const sanitizeText = (txt) => common$1.sanitizeText(txt, config); +const lookUpDomId = function(id) { + const vertexKeys = Object.keys(vertices); + for (const vertexKey of vertexKeys) { + if (vertices[vertexKey].id === id) { + return vertices[vertexKey].domId; + } + } + return id; +}; +const addVertex = function(_id, textObj, type, style, classes2, dir, props = {}) { + let txt; + let id = _id; + if (id === void 0) { + return; + } + if (id.trim().length === 0) { + return; + } + if (vertices[id] === void 0) { + vertices[id] = { + id, + labelType: "text", + domId: MERMAID_DOM_ID_PREFIX + id + "-" + vertexCounter, + styles: [], + classes: [] + }; + } + vertexCounter++; + if (textObj !== void 0) { + config = getConfig(); + txt = sanitizeText(textObj.text.trim()); + vertices[id].labelType = textObj.type; + if (txt[0] === '"' && txt[txt.length - 1] === '"') { + txt = txt.substring(1, txt.length - 1); + } + vertices[id].text = txt; + } else { + if (vertices[id].text === void 0) { + vertices[id].text = _id; + } + } + if (type !== void 0) { + vertices[id].type = type; + } + if (style !== void 0 && style !== null) { + style.forEach(function(s) { + vertices[id].styles.push(s); + }); + } + if (classes2 !== void 0 && classes2 !== null) { + classes2.forEach(function(s) { + vertices[id].classes.push(s); + }); + } + if (dir !== void 0) { + vertices[id].dir = dir; + } + if (vertices[id].props === void 0) { + vertices[id].props = props; + } else if (props !== void 0) { + Object.assign(vertices[id].props, props); + } +}; +const addSingleLink = function(_start, _end, type) { + let start = _start; + let end = _end; + const edge = { start, end, type: void 0, text: "", labelType: "text" }; + log$1.info("abc78 Got edge...", edge); + const linkTextObj = type.text; + if (linkTextObj !== void 0) { + edge.text = sanitizeText(linkTextObj.text.trim()); + if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') { + edge.text = edge.text.substring(1, edge.text.length - 1); + } + edge.labelType = linkTextObj.type; + } + if (type !== void 0) { + edge.type = type.type; + edge.stroke = type.stroke; + edge.length = type.length; + } + if ((edge == null ? void 0 : edge.length) > 10) { + edge.length = 10; + } + if (edges.length < (config.maxEdges ?? 500)) { + log$1.info("abc78 pushing edge..."); + edges.push(edge); + } else { + throw new Error( + `Edge limit exceeded. ${edges.length} edges found, but the limit is ${config.maxEdges}. + +Initialize mermaid with maxEdges set to a higher number to allow more edges. +You cannot set this config via configuration inside the diagram as it is a secure config. +You have to call mermaid.initialize.` + ); + } +}; +const addLink = function(_start, _end, type) { + log$1.info("addLink (abc78)", _start, _end, type); + let i, j; + for (i = 0; i < _start.length; i++) { + for (j = 0; j < _end.length; j++) { + addSingleLink(_start[i], _end[j], type); + } + } +}; +const updateLinkInterpolate = function(positions, interp) { + positions.forEach(function(pos) { + if (pos === "default") { + edges.defaultInterpolate = interp; + } else { + edges[pos].interpolate = interp; + } + }); +}; +const updateLink = function(positions, style) { + positions.forEach(function(pos) { + if (pos >= edges.length) { + throw new Error( + `The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${edges.length - 1}. (Help: Ensure that the index is within the range of existing edges.)` + ); + } + if (pos === "default") { + edges.defaultStyle = style; + } else { + if (utils.isSubstringInArray("fill", style) === -1) { + style.push("fill:none"); + } + edges[pos].style = style; + } + }); +}; +const addClass = function(ids, style) { + ids.split(",").forEach(function(id) { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + if (style !== void 0 && style !== null) { + style.forEach(function(s) { + if (s.match("color")) { + const newStyle = s.replace("fill", "bgFill").replace("color", "fill"); + classes[id].textStyles.push(newStyle); + } + classes[id].styles.push(s); + }); + } + }); +}; +const setDirection = function(dir) { + direction = dir; + if (direction.match(/.*/)) { + direction = "LR"; + } + if (direction.match(/.*v/)) { + direction = "TB"; + } + if (direction === "TD") { + direction = "TB"; + } +}; +const setClass = function(ids, className) { + ids.split(",").forEach(function(_id) { + let id = _id; + if (vertices[id] !== void 0) { + vertices[id].classes.push(className); + } + if (subGraphLookup[id] !== void 0) { + subGraphLookup[id].classes.push(className); + } + }); +}; +const setTooltip = function(ids, tooltip) { + ids.split(",").forEach(function(id) { + if (tooltip !== void 0) { + tooltips[version === "gen-1" ? lookUpDomId(id) : id] = sanitizeText(tooltip); + } + }); +}; +const setClickFun = function(id, functionName, functionArgs) { + let domId = lookUpDomId(id); + if (getConfig().securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(id); + } + if (vertices[id] !== void 0) { + vertices[id].haveCallback = true; + funs.push(function() { + const elem = document.querySelector(`[id="${domId}"]`); + if (elem !== null) { + elem.addEventListener( + "click", + function() { + utils.runFunc(functionName, ...argList); + }, + false + ); + } + }); + } +}; +const setLink = function(ids, linkStr, target) { + ids.split(",").forEach(function(id) { + if (vertices[id] !== void 0) { + vertices[id].link = utils.formatUrl(linkStr, config); + vertices[id].linkTarget = target; + } + }); + setClass(ids, "clickable"); +}; +const getTooltip = function(id) { + if (tooltips.hasOwnProperty(id)) { + return tooltips[id]; + } + return void 0; +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFun(id, functionName, functionArgs); + }); + setClass(ids, "clickable"); +}; +const bindFunctions = function(element) { + funs.forEach(function(fun) { + fun(element); + }); +}; +const getDirection = function() { + return direction.trim(); +}; +const getVertices = function() { + return vertices; +}; +const getEdges = function() { + return edges; +}; +const getClasses = function() { + return classes; +}; +const setupToolTips = function(element) { + let tooltipElem = select(".mermaidTooltip"); + if ((tooltipElem._groups || tooltipElem)[0][0] === null) { + tooltipElem = select("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0); + } + const svg = select(element).select("svg"); + const nodes = svg.selectAll("g.node"); + nodes.on("mouseover", function() { + const el = select(this); + const title = el.attr("title"); + if (title === null) { + return; + } + const rect = this.getBoundingClientRect(); + tooltipElem.transition().duration(200).style("opacity", ".9"); + tooltipElem.text(el.attr("title")).style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.bottom + "px"); + tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, "
")); + el.classed("hover", true); + }).on("mouseout", function() { + tooltipElem.transition().duration(500).style("opacity", 0); + const el = select(this); + el.classed("hover", false); + }); +}; +funs.push(setupToolTips); +const clear = function(ver = "gen-1") { + vertices = {}; + classes = {}; + edges = []; + funs = [setupToolTips]; + subGraphs = []; + subGraphLookup = {}; + subCount = 0; + tooltips = {}; + firstGraphFlag = true; + version = ver; + config = getConfig(); + clear$1(); +}; +const setGen = (ver) => { + version = ver || "gen-2"; +}; +const defaultStyle = function() { + return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; +}; +const addSubGraph = function(_id, list, _title) { + let id = _id.text.trim(); + let title = _title.text; + if (_id === _title && _title.text.match(/\s/)) { + id = void 0; + } + function uniq(a) { + const prims = { boolean: {}, number: {}, string: {} }; + const objs = []; + let dir2; + const nodeList2 = a.filter(function(item) { + const type = typeof item; + if (item.stmt && item.stmt === "dir") { + dir2 = item.value; + return false; + } + if (item.trim() === "") { + return false; + } + if (type in prims) { + return prims[type].hasOwnProperty(item) ? false : prims[type][item] = true; + } else { + return objs.includes(item) ? false : objs.push(item); + } + }); + return { nodeList: nodeList2, dir: dir2 }; + } + let nodeList = []; + const { nodeList: nl, dir } = uniq(nodeList.concat.apply(nodeList, list)); + nodeList = nl; + if (version === "gen-1") { + for (let i = 0; i < nodeList.length; i++) { + nodeList[i] = lookUpDomId(nodeList[i]); + } + } + id = id || "subGraph" + subCount; + title = title || ""; + title = sanitizeText(title); + subCount = subCount + 1; + const subGraph = { + id, + nodes: nodeList, + title: title.trim(), + classes: [], + dir, + labelType: _title.type + }; + log$1.info("Adding", subGraph.id, subGraph.nodes, subGraph.dir); + subGraph.nodes = makeUniq(subGraph, subGraphs).nodes; + subGraphs.push(subGraph); + subGraphLookup[id] = subGraph; + return id; +}; +const getPosForId = function(id) { + for (const [i, subGraph] of subGraphs.entries()) { + if (subGraph.id === id) { + return i; + } + } + return -1; +}; +let secCount = -1; +const posCrossRef = []; +const indexNodes2 = function(id, pos) { + const nodes = subGraphs[pos].nodes; + secCount = secCount + 1; + if (secCount > 2e3) { + return; + } + posCrossRef[secCount] = pos; + if (subGraphs[pos].id === id) { + return { + result: true, + count: 0 + }; + } + let count = 0; + let posCount = 1; + while (count < nodes.length) { + const childPos = getPosForId(nodes[count]); + if (childPos >= 0) { + const res = indexNodes2(id, childPos); + if (res.result) { + return { + result: true, + count: posCount + res.count + }; + } else { + posCount = posCount + res.count; + } + } + count = count + 1; + } + return { + result: false, + count: posCount + }; +}; +const getDepthFirstPos = function(pos) { + return posCrossRef[pos]; +}; +const indexNodes = function() { + secCount = -1; + if (subGraphs.length > 0) { + indexNodes2("none", subGraphs.length - 1); + } +}; +const getSubGraphs = function() { + return subGraphs; +}; +const firstGraph = () => { + if (firstGraphFlag) { + firstGraphFlag = false; + return true; + } + return false; +}; +const destructStartLink = (_str) => { + let str = _str.trim(); + let type = "arrow_open"; + switch (str[0]) { + case "<": + type = "arrow_point"; + str = str.slice(1); + break; + case "x": + type = "arrow_cross"; + str = str.slice(1); + break; + case "o": + type = "arrow_circle"; + str = str.slice(1); + break; + } + let stroke = "normal"; + if (str.includes("=")) { + stroke = "thick"; + } + if (str.includes(".")) { + stroke = "dotted"; + } + return { type, stroke }; +}; +const countChar = (char, str) => { + const length = str.length; + let count = 0; + for (let i = 0; i < length; ++i) { + if (str[i] === char) { + ++count; + } + } + return count; +}; +const destructEndLink = (_str) => { + const str = _str.trim(); + let line = str.slice(0, -1); + let type = "arrow_open"; + switch (str.slice(-1)) { + case "x": + type = "arrow_cross"; + if (str[0] === "x") { + type = "double_" + type; + line = line.slice(1); + } + break; + case ">": + type = "arrow_point"; + if (str[0] === "<") { + type = "double_" + type; + line = line.slice(1); + } + break; + case "o": + type = "arrow_circle"; + if (str[0] === "o") { + type = "double_" + type; + line = line.slice(1); + } + break; + } + let stroke = "normal"; + let length = line.length - 1; + if (line[0] === "=") { + stroke = "thick"; + } + if (line[0] === "~") { + stroke = "invisible"; + } + let dots = countChar(".", line); + if (dots) { + stroke = "dotted"; + length = dots; + } + return { type, stroke, length }; +}; +const destructLink = (_str, _startStr) => { + const info = destructEndLink(_str); + let startInfo; + if (_startStr) { + startInfo = destructStartLink(_startStr); + if (startInfo.stroke !== info.stroke) { + return { type: "INVALID", stroke: "INVALID" }; + } + if (startInfo.type === "arrow_open") { + startInfo.type = info.type; + } else { + if (startInfo.type !== info.type) { + return { type: "INVALID", stroke: "INVALID" }; + } + startInfo.type = "double_" + startInfo.type; + } + if (startInfo.type === "double_arrow") { + startInfo.type = "double_arrow_point"; + } + startInfo.length = info.length; + return startInfo; + } + return info; +}; +const exists = (allSgs, _id) => { + let res = false; + allSgs.forEach((sg) => { + const pos = sg.nodes.indexOf(_id); + if (pos >= 0) { + res = true; + } + }); + return res; +}; +const makeUniq = (sg, allSubgraphs) => { + const res = []; + sg.nodes.forEach((_id, pos) => { + if (!exists(allSubgraphs, _id)) { + res.push(sg.nodes[pos]); + } + }); + return { nodes: res }; +}; +const lex = { + firstGraph +}; +const flowDb = { + defaultConfig: () => defaultConfig.flowchart, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + addVertex, + lookUpDomId, + addLink, + updateLinkInterpolate, + updateLink, + addClass, + setDirection, + setClass, + setTooltip, + getTooltip, + setClickEvent, + setLink, + bindFunctions, + getDirection, + getVertices, + getEdges, + getClasses, + clear, + setGen, + defaultStyle, + addSubGraph, + getDepthFirstPos, + indexNodes, + getSubGraphs, + destructLink, + lex, + exists, + makeUniq, + setDiagramTitle, + getDiagramTitle +}; +const db = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + addClass, + addLink, + addSingleLink, + addSubGraph, + addVertex, + bindFunctions, + clear, + default: flowDb, + defaultStyle, + destructLink, + firstGraph, + getClasses, + getDepthFirstPos, + getDirection, + getEdges, + getSubGraphs, + getTooltip, + getVertices, + indexNodes, + lex, + lookUpDomId, + setClass, + setClickEvent, + setDirection, + setGen, + setLink, + updateLink, + updateLinkInterpolate +}, Symbol.toStringTag, { value: "Module" })); + +export { db as d, flowDb as f, parser$1 as p }; diff --git a/libs/marked/flowDb-c1833063-Df5kDQr4.js b/libs/marked/flowDb-c1833063-Df5kDQr4.js new file mode 100644 index 0000000..45aded0 --- /dev/null +++ b/libs/marked/flowDb-c1833063-Df5kDQr4.js @@ -0,0 +1,1711 @@ +import { c as getConfig, aq as defaultConfig, s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, A as utils, E as clear$1, j as common$1, h as select } from './index-Bd_FDXSq.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 4], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 8, 9, 10, 11, 27, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $V4 = [2, 2], $V5 = [1, 13], $V6 = [1, 14], $V7 = [1, 15], $V8 = [1, 16], $V9 = [1, 23], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 49], $Ve = [1, 48], $Vf = [1, 29], $Vg = [1, 30], $Vh = [1, 31], $Vi = [1, 32], $Vj = [1, 33], $Vk = [1, 44], $Vl = [1, 46], $Vm = [1, 42], $Vn = [1, 47], $Vo = [1, 43], $Vp = [1, 50], $Vq = [1, 45], $Vr = [1, 51], $Vs = [1, 52], $Vt = [1, 34], $Vu = [1, 35], $Vv = [1, 36], $Vw = [1, 37], $Vx = [1, 57], $Vy = [1, 8, 9, 10, 11, 27, 32, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $Vz = [1, 61], $VA = [1, 60], $VB = [1, 62], $VC = [8, 9, 11, 73, 75], $VD = [1, 88], $VE = [1, 93], $VF = [1, 92], $VG = [1, 89], $VH = [1, 85], $VI = [1, 91], $VJ = [1, 87], $VK = [1, 94], $VL = [1, 90], $VM = [1, 95], $VN = [1, 86], $VO = [8, 9, 10, 11, 73, 75], $VP = [8, 9, 10, 11, 44, 73, 75], $VQ = [8, 9, 10, 11, 29, 42, 44, 46, 48, 50, 52, 54, 56, 58, 61, 63, 65, 66, 68, 73, 75, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VR = [8, 9, 11, 42, 58, 73, 75, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VS = [42, 58, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VT = [1, 121], $VU = [1, 120], $VV = [1, 128], $VW = [1, 142], $VX = [1, 143], $VY = [1, 144], $VZ = [1, 145], $V_ = [1, 130], $V$ = [1, 132], $V01 = [1, 136], $V11 = [1, 137], $V21 = [1, 138], $V31 = [1, 139], $V41 = [1, 140], $V51 = [1, 141], $V61 = [1, 146], $V71 = [1, 147], $V81 = [1, 126], $V91 = [1, 127], $Va1 = [1, 134], $Vb1 = [1, 129], $Vc1 = [1, 133], $Vd1 = [1, 131], $Ve1 = [8, 9, 10, 11, 27, 32, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $Vf1 = [1, 149], $Vg1 = [8, 9, 11], $Vh1 = [8, 9, 10, 11, 14, 42, 58, 86, 102, 103, 106, 108, 111, 112, 113], $Vi1 = [1, 169], $Vj1 = [1, 165], $Vk1 = [1, 166], $Vl1 = [1, 170], $Vm1 = [1, 167], $Vn1 = [1, 168], $Vo1 = [75, 113, 116], $Vp1 = [8, 9, 10, 11, 12, 14, 27, 29, 32, 42, 58, 73, 81, 82, 83, 84, 85, 86, 87, 102, 106, 108, 111, 112, 113], $Vq1 = [10, 103], $Vr1 = [31, 47, 49, 51, 53, 55, 60, 62, 64, 65, 67, 69, 113, 114, 115], $Vs1 = [1, 235], $Vt1 = [1, 233], $Vu1 = [1, 237], $Vv1 = [1, 231], $Vw1 = [1, 232], $Vx1 = [1, 234], $Vy1 = [1, 236], $Vz1 = [1, 238], $VA1 = [1, 255], $VB1 = [8, 9, 11, 103], $VC1 = [8, 9, 10, 11, 58, 81, 102, 103, 106, 107, 108, 109]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "graphConfig": 4, "document": 5, "line": 6, "statement": 7, "SEMI": 8, "NEWLINE": 9, "SPACE": 10, "EOF": 11, "GRAPH": 12, "NODIR": 13, "DIR": 14, "FirstStmtSeparator": 15, "ending": 16, "endToken": 17, "spaceList": 18, "spaceListNewline": 19, "vertexStatement": 20, "separator": 21, "styleStatement": 22, "linkStyleStatement": 23, "classDefStatement": 24, "classStatement": 25, "clickStatement": 26, "subgraph": 27, "textNoTags": 28, "SQS": 29, "text": 30, "SQE": 31, "end": 32, "direction": 33, "acc_title": 34, "acc_title_value": 35, "acc_descr": 36, "acc_descr_value": 37, "acc_descr_multiline_value": 38, "link": 39, "node": 40, "styledVertex": 41, "AMP": 42, "vertex": 43, "STYLE_SEPARATOR": 44, "idString": 45, "DOUBLECIRCLESTART": 46, "DOUBLECIRCLEEND": 47, "PS": 48, "PE": 49, "(-": 50, "-)": 51, "STADIUMSTART": 52, "STADIUMEND": 53, "SUBROUTINESTART": 54, "SUBROUTINEEND": 55, "VERTEX_WITH_PROPS_START": 56, "NODE_STRING[field]": 57, "COLON": 58, "NODE_STRING[value]": 59, "PIPE": 60, "CYLINDERSTART": 61, "CYLINDEREND": 62, "DIAMOND_START": 63, "DIAMOND_STOP": 64, "TAGEND": 65, "TRAPSTART": 66, "TRAPEND": 67, "INVTRAPSTART": 68, "INVTRAPEND": 69, "linkStatement": 70, "arrowText": 71, "TESTSTR": 72, "START_LINK": 73, "edgeText": 74, "LINK": 75, "edgeTextToken": 76, "STR": 77, "MD_STR": 78, "textToken": 79, "keywords": 80, "STYLE": 81, "LINKSTYLE": 82, "CLASSDEF": 83, "CLASS": 84, "CLICK": 85, "DOWN": 86, "UP": 87, "textNoTagsToken": 88, "stylesOpt": 89, "idString[vertex]": 90, "idString[class]": 91, "CALLBACKNAME": 92, "CALLBACKARGS": 93, "HREF": 94, "LINK_TARGET": 95, "STR[link]": 96, "STR[tooltip]": 97, "alphaNum": 98, "DEFAULT": 99, "numList": 100, "INTERPOLATE": 101, "NUM": 102, "COMMA": 103, "style": 104, "styleComponent": 105, "NODE_STRING": 106, "UNIT": 107, "BRKT": 108, "PCT": 109, "idStringToken": 110, "MINUS": 111, "MULT": 112, "UNICODE_TEXT": 113, "TEXT": 114, "TAGSTART": 115, "EDGE_TEXT": 116, "alphaNumToken": 117, "direction_tb": 118, "direction_bt": 119, "direction_rl": 120, "direction_lr": 121, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 8: "SEMI", 9: "NEWLINE", 10: "SPACE", 11: "EOF", 12: "GRAPH", 13: "NODIR", 14: "DIR", 27: "subgraph", 29: "SQS", 31: "SQE", 32: "end", 34: "acc_title", 35: "acc_title_value", 36: "acc_descr", 37: "acc_descr_value", 38: "acc_descr_multiline_value", 42: "AMP", 44: "STYLE_SEPARATOR", 46: "DOUBLECIRCLESTART", 47: "DOUBLECIRCLEEND", 48: "PS", 49: "PE", 50: "(-", 51: "-)", 52: "STADIUMSTART", 53: "STADIUMEND", 54: "SUBROUTINESTART", 55: "SUBROUTINEEND", 56: "VERTEX_WITH_PROPS_START", 57: "NODE_STRING[field]", 58: "COLON", 59: "NODE_STRING[value]", 60: "PIPE", 61: "CYLINDERSTART", 62: "CYLINDEREND", 63: "DIAMOND_START", 64: "DIAMOND_STOP", 65: "TAGEND", 66: "TRAPSTART", 67: "TRAPEND", 68: "INVTRAPSTART", 69: "INVTRAPEND", 72: "TESTSTR", 73: "START_LINK", 75: "LINK", 77: "STR", 78: "MD_STR", 81: "STYLE", 82: "LINKSTYLE", 83: "CLASSDEF", 84: "CLASS", 85: "CLICK", 86: "DOWN", 87: "UP", 90: "idString[vertex]", 91: "idString[class]", 92: "CALLBACKNAME", 93: "CALLBACKARGS", 94: "HREF", 95: "LINK_TARGET", 96: "STR[link]", 97: "STR[tooltip]", 99: "DEFAULT", 101: "INTERPOLATE", 102: "NUM", 103: "COMMA", 106: "NODE_STRING", 107: "UNIT", 108: "BRKT", 109: "PCT", 111: "MINUS", 112: "MULT", 113: "UNICODE_TEXT", 114: "TEXT", 115: "TAGSTART", 116: "EDGE_TEXT", 118: "direction_tb", 119: "direction_bt", 120: "direction_rl", 121: "direction_lr" }, + productions_: [0, [3, 2], [5, 0], [5, 2], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [4, 2], [4, 2], [4, 2], [4, 3], [16, 2], [16, 1], [17, 1], [17, 1], [17, 1], [15, 1], [15, 1], [15, 2], [19, 2], [19, 2], [19, 1], [19, 1], [18, 2], [18, 1], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 9], [7, 6], [7, 4], [7, 1], [7, 2], [7, 2], [7, 1], [21, 1], [21, 1], [21, 1], [20, 3], [20, 4], [20, 2], [20, 1], [40, 1], [40, 5], [41, 1], [41, 3], [43, 4], [43, 4], [43, 6], [43, 4], [43, 4], [43, 4], [43, 8], [43, 4], [43, 4], [43, 4], [43, 6], [43, 4], [43, 4], [43, 4], [43, 4], [43, 4], [43, 1], [39, 2], [39, 3], [39, 3], [39, 1], [39, 3], [74, 1], [74, 2], [74, 1], [74, 1], [70, 1], [71, 3], [30, 1], [30, 2], [30, 1], [30, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [28, 1], [28, 2], [28, 1], [28, 1], [24, 5], [25, 5], [26, 2], [26, 4], [26, 3], [26, 5], [26, 3], [26, 5], [26, 5], [26, 7], [26, 2], [26, 4], [26, 2], [26, 4], [26, 4], [26, 6], [22, 5], [23, 5], [23, 5], [23, 9], [23, 9], [23, 7], [23, 7], [100, 1], [100, 3], [89, 1], [89, 3], [104, 1], [104, 2], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [79, 1], [79, 1], [79, 1], [79, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [76, 1], [76, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [45, 1], [45, 2], [98, 1], [98, 2], [33, 1], [33, 1], [33, 1], [33, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 2: + this.$ = []; + break; + case 3: + if (!Array.isArray($$[$0]) || $$[$0].length > 0) { + $$[$0 - 1].push($$[$0]); + } + this.$ = $$[$0 - 1]; + break; + case 4: + case 176: + this.$ = $$[$0]; + break; + case 11: + yy.setDirection("TB"); + this.$ = "TB"; + break; + case 12: + yy.setDirection($$[$0 - 1]); + this.$ = $$[$0 - 1]; + break; + case 27: + this.$ = $$[$0 - 1].nodes; + break; + case 28: + case 29: + case 30: + case 31: + case 32: + this.$ = []; + break; + case 33: + this.$ = yy.addSubGraph($$[$0 - 6], $$[$0 - 1], $$[$0 - 4]); + break; + case 34: + this.$ = yy.addSubGraph($$[$0 - 3], $$[$0 - 1], $$[$0 - 3]); + break; + case 35: + this.$ = yy.addSubGraph(void 0, $$[$0 - 1], void 0); + break; + case 37: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 38: + case 39: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 43: + yy.addLink($$[$0 - 2].stmt, $$[$0], $$[$0 - 1]); + this.$ = { stmt: $$[$0], nodes: $$[$0].concat($$[$0 - 2].nodes) }; + break; + case 44: + yy.addLink($$[$0 - 3].stmt, $$[$0 - 1], $$[$0 - 2]); + this.$ = { stmt: $$[$0 - 1], nodes: $$[$0 - 1].concat($$[$0 - 3].nodes) }; + break; + case 45: + this.$ = { stmt: $$[$0 - 1], nodes: $$[$0 - 1] }; + break; + case 46: + this.$ = { stmt: $$[$0], nodes: $$[$0] }; + break; + case 47: + this.$ = [$$[$0]]; + break; + case 48: + this.$ = $$[$0 - 4].concat($$[$0]); + break; + case 49: + this.$ = $$[$0]; + break; + case 50: + this.$ = $$[$0 - 2]; + yy.setClass($$[$0 - 2], $$[$0]); + break; + case 51: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "square"); + break; + case 52: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "doublecircle"); + break; + case 53: + this.$ = $$[$0 - 5]; + yy.addVertex($$[$0 - 5], $$[$0 - 2], "circle"); + break; + case 54: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "ellipse"); + break; + case 55: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "stadium"); + break; + case 56: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "subroutine"); + break; + case 57: + this.$ = $$[$0 - 7]; + yy.addVertex($$[$0 - 7], $$[$0 - 1], "rect", void 0, void 0, void 0, Object.fromEntries([[$$[$0 - 5], $$[$0 - 3]]])); + break; + case 58: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "cylinder"); + break; + case 59: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "round"); + break; + case 60: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "diamond"); + break; + case 61: + this.$ = $$[$0 - 5]; + yy.addVertex($$[$0 - 5], $$[$0 - 2], "hexagon"); + break; + case 62: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "odd"); + break; + case 63: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "trapezoid"); + break; + case 64: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "inv_trapezoid"); + break; + case 65: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "lean_right"); + break; + case 66: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "lean_left"); + break; + case 67: + this.$ = $$[$0]; + yy.addVertex($$[$0]); + break; + case 68: + $$[$0 - 1].text = $$[$0]; + this.$ = $$[$0 - 1]; + break; + case 69: + case 70: + $$[$0 - 2].text = $$[$0 - 1]; + this.$ = $$[$0 - 2]; + break; + case 71: + this.$ = $$[$0]; + break; + case 72: + var inf = yy.destructLink($$[$0], $$[$0 - 2]); + this.$ = { "type": inf.type, "stroke": inf.stroke, "length": inf.length, "text": $$[$0 - 1] }; + break; + case 73: + this.$ = { text: $$[$0], type: "text" }; + break; + case 74: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 75: + this.$ = { text: $$[$0], type: "string" }; + break; + case 76: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 77: + var inf = yy.destructLink($$[$0]); + this.$ = { "type": inf.type, "stroke": inf.stroke, "length": inf.length }; + break; + case 78: + this.$ = $$[$0 - 1]; + break; + case 79: + this.$ = { text: $$[$0], type: "text" }; + break; + case 80: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 81: + this.$ = { text: $$[$0], type: "string" }; + break; + case 82: + case 97: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 94: + this.$ = { text: $$[$0], type: "text" }; + break; + case 95: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 96: + this.$ = { text: $$[$0], type: "text" }; + break; + case 98: + this.$ = $$[$0 - 4]; + yy.addClass($$[$0 - 2], $$[$0]); + break; + case 99: + this.$ = $$[$0 - 4]; + yy.setClass($$[$0 - 2], $$[$0]); + break; + case 100: + case 108: + this.$ = $$[$0 - 1]; + yy.setClickEvent($$[$0 - 1], $$[$0]); + break; + case 101: + case 109: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 102: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 103: + this.$ = $$[$0 - 4]; + yy.setClickEvent($$[$0 - 4], $$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 4], $$[$0]); + break; + case 104: + this.$ = $$[$0 - 2]; + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 105: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 4], $$[$0 - 2]); + yy.setTooltip($$[$0 - 4], $$[$0]); + break; + case 106: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 107: + this.$ = $$[$0 - 6]; + yy.setLink($$[$0 - 6], $$[$0 - 4], $$[$0]); + yy.setTooltip($$[$0 - 6], $$[$0 - 2]); + break; + case 110: + this.$ = $$[$0 - 1]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 111: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 112: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 3], $$[$0 - 2], $$[$0]); + break; + case 113: + this.$ = $$[$0 - 5]; + yy.setLink($$[$0 - 5], $$[$0 - 4], $$[$0]); + yy.setTooltip($$[$0 - 5], $$[$0 - 2]); + break; + case 114: + this.$ = $$[$0 - 4]; + yy.addVertex($$[$0 - 2], void 0, void 0, $$[$0]); + break; + case 115: + this.$ = $$[$0 - 4]; + yy.updateLink([$$[$0 - 2]], $$[$0]); + break; + case 116: + this.$ = $$[$0 - 4]; + yy.updateLink($$[$0 - 2], $$[$0]); + break; + case 117: + this.$ = $$[$0 - 8]; + yy.updateLinkInterpolate([$$[$0 - 6]], $$[$0 - 2]); + yy.updateLink([$$[$0 - 6]], $$[$0]); + break; + case 118: + this.$ = $$[$0 - 8]; + yy.updateLinkInterpolate($$[$0 - 6], $$[$0 - 2]); + yy.updateLink($$[$0 - 6], $$[$0]); + break; + case 119: + this.$ = $$[$0 - 6]; + yy.updateLinkInterpolate([$$[$0 - 4]], $$[$0]); + break; + case 120: + this.$ = $$[$0 - 6]; + yy.updateLinkInterpolate($$[$0 - 4], $$[$0]); + break; + case 121: + case 123: + this.$ = [$$[$0]]; + break; + case 122: + case 124: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 126: + this.$ = $$[$0 - 1] + $$[$0]; + break; + case 174: + this.$ = $$[$0]; + break; + case 175: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + case 177: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + case 178: + this.$ = { stmt: "dir", value: "TB" }; + break; + case 179: + this.$ = { stmt: "dir", value: "BT" }; + break; + case 180: + this.$ = { stmt: "dir", value: "RL" }; + break; + case 181: + this.$ = { stmt: "dir", value: "LR" }; + break; + } + }, + table: [{ 3: 1, 4: 2, 9: $V0, 10: $V1, 12: $V2 }, { 1: [3] }, o($V3, $V4, { 5: 6 }), { 4: 7, 9: $V0, 10: $V1, 12: $V2 }, { 4: 8, 9: $V0, 10: $V1, 12: $V2 }, { 13: [1, 9], 14: [1, 10] }, { 1: [2, 1], 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, o($V3, [2, 9]), o($V3, [2, 10]), o($V3, [2, 11]), { 8: [1, 54], 9: [1, 55], 10: $Vx, 15: 53, 18: 56 }, o($Vy, [2, 3]), o($Vy, [2, 4]), o($Vy, [2, 5]), o($Vy, [2, 6]), o($Vy, [2, 7]), o($Vy, [2, 8]), { 8: $Vz, 9: $VA, 11: $VB, 21: 58, 39: 59, 70: 63, 73: [1, 64], 75: [1, 65] }, { 8: $Vz, 9: $VA, 11: $VB, 21: 66 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 67 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 68 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 69 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 70 }, { 8: $Vz, 9: $VA, 10: [1, 71], 11: $VB, 21: 72 }, o($Vy, [2, 36]), { 35: [1, 73] }, { 37: [1, 74] }, o($Vy, [2, 39]), o($VC, [2, 46], { 18: 75, 10: $Vx }), { 10: [1, 76] }, { 10: [1, 77] }, { 10: [1, 78] }, { 10: [1, 79] }, { 14: $VD, 42: $VE, 58: $VF, 77: [1, 83], 86: $VG, 92: [1, 80], 94: [1, 81], 98: 82, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, o($Vy, [2, 178]), o($Vy, [2, 179]), o($Vy, [2, 180]), o($Vy, [2, 181]), o($VO, [2, 47]), o($VO, [2, 49], { 44: [1, 96] }), o($VP, [2, 67], { 110: 109, 29: [1, 97], 42: $Vd, 46: [1, 98], 48: [1, 99], 50: [1, 100], 52: [1, 101], 54: [1, 102], 56: [1, 103], 58: $Ve, 61: [1, 104], 63: [1, 105], 65: [1, 106], 66: [1, 107], 68: [1, 108], 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), o($VQ, [2, 174]), o($VQ, [2, 135]), o($VQ, [2, 136]), o($VQ, [2, 137]), o($VQ, [2, 138]), o($VQ, [2, 139]), o($VQ, [2, 140]), o($VQ, [2, 141]), o($VQ, [2, 142]), o($VQ, [2, 143]), o($VQ, [2, 144]), o($VQ, [2, 145]), o($V3, [2, 12]), o($V3, [2, 18]), o($V3, [2, 19]), { 9: [1, 110] }, o($VR, [2, 26], { 18: 111, 10: $Vx }), o($Vy, [2, 27]), { 40: 112, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vy, [2, 40]), o($Vy, [2, 41]), o($Vy, [2, 42]), o($VS, [2, 71], { 71: 113, 60: [1, 115], 72: [1, 114] }), { 74: 116, 76: 117, 77: [1, 118], 78: [1, 119], 113: $VT, 116: $VU }, o([42, 58, 60, 72, 86, 99, 102, 103, 106, 108, 111, 112, 113], [2, 77]), o($Vy, [2, 28]), o($Vy, [2, 29]), o($Vy, [2, 30]), o($Vy, [2, 31]), o($Vy, [2, 32]), { 10: $VV, 12: $VW, 14: $VX, 27: $VY, 28: 122, 32: $VZ, 42: $V_, 58: $V$, 73: $V01, 77: [1, 124], 78: [1, 125], 80: 135, 81: $V11, 82: $V21, 83: $V31, 84: $V41, 85: $V51, 86: $V61, 87: $V71, 88: 123, 102: $V81, 106: $V91, 108: $Va1, 111: $Vb1, 112: $Vc1, 113: $Vd1 }, o($Ve1, $V4, { 5: 148 }), o($Vy, [2, 37]), o($Vy, [2, 38]), o($VC, [2, 45], { 42: $Vf1 }), { 42: $Vd, 45: 150, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 99: [1, 151], 100: 152, 102: [1, 153] }, { 42: $Vd, 45: 154, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 42: $Vd, 45: 155, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vg1, [2, 100], { 10: [1, 156], 93: [1, 157] }), { 77: [1, 158] }, o($Vg1, [2, 108], { 117: 160, 10: [1, 159], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 110], { 10: [1, 161] }), o($Vh1, [2, 176]), o($Vh1, [2, 163]), o($Vh1, [2, 164]), o($Vh1, [2, 165]), o($Vh1, [2, 166]), o($Vh1, [2, 167]), o($Vh1, [2, 168]), o($Vh1, [2, 169]), o($Vh1, [2, 170]), o($Vh1, [2, 171]), o($Vh1, [2, 172]), o($Vh1, [2, 173]), { 42: $Vd, 45: 162, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 30: 163, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 171, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 173, 48: [1, 172], 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 174, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 175, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 176, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 106: [1, 177] }, { 30: 178, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 179, 63: [1, 180], 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 181, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 182, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 183, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VQ, [2, 175]), o($V3, [2, 20]), o($VR, [2, 25]), o($VC, [2, 43], { 18: 184, 10: $Vx }), o($VS, [2, 68], { 10: [1, 185] }), { 10: [1, 186] }, { 30: 187, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 75: [1, 188], 76: 189, 113: $VT, 116: $VU }, o($Vo1, [2, 73]), o($Vo1, [2, 75]), o($Vo1, [2, 76]), o($Vo1, [2, 161]), o($Vo1, [2, 162]), { 8: $Vz, 9: $VA, 10: $VV, 11: $VB, 12: $VW, 14: $VX, 21: 191, 27: $VY, 29: [1, 190], 32: $VZ, 42: $V_, 58: $V$, 73: $V01, 80: 135, 81: $V11, 82: $V21, 83: $V31, 84: $V41, 85: $V51, 86: $V61, 87: $V71, 88: 192, 102: $V81, 106: $V91, 108: $Va1, 111: $Vb1, 112: $Vc1, 113: $Vd1 }, o($Vp1, [2, 94]), o($Vp1, [2, 96]), o($Vp1, [2, 97]), o($Vp1, [2, 150]), o($Vp1, [2, 151]), o($Vp1, [2, 152]), o($Vp1, [2, 153]), o($Vp1, [2, 154]), o($Vp1, [2, 155]), o($Vp1, [2, 156]), o($Vp1, [2, 157]), o($Vp1, [2, 158]), o($Vp1, [2, 159]), o($Vp1, [2, 160]), o($Vp1, [2, 83]), o($Vp1, [2, 84]), o($Vp1, [2, 85]), o($Vp1, [2, 86]), o($Vp1, [2, 87]), o($Vp1, [2, 88]), o($Vp1, [2, 89]), o($Vp1, [2, 90]), o($Vp1, [2, 91]), o($Vp1, [2, 92]), o($Vp1, [2, 93]), { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 193], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, { 10: $Vx, 18: 194 }, { 10: [1, 195], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: [1, 196] }, { 10: [1, 197], 103: [1, 198] }, o($Vq1, [2, 121]), { 10: [1, 199], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: [1, 200], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 77: [1, 201] }, o($Vg1, [2, 102], { 10: [1, 202] }), o($Vg1, [2, 104], { 10: [1, 203] }), { 77: [1, 204] }, o($Vh1, [2, 177]), { 77: [1, 205], 95: [1, 206] }, o($VO, [2, 50], { 110: 109, 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), { 31: [1, 207], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($Vr1, [2, 79]), o($Vr1, [2, 81]), o($Vr1, [2, 82]), o($Vr1, [2, 146]), o($Vr1, [2, 147]), o($Vr1, [2, 148]), o($Vr1, [2, 149]), { 47: [1, 209], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 210, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 49: [1, 211], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 51: [1, 212], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 53: [1, 213], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 55: [1, 214], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 58: [1, 215] }, { 62: [1, 216], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 64: [1, 217], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 218, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 31: [1, 219], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 65: $Vi1, 67: [1, 220], 69: [1, 221], 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 65: $Vi1, 67: [1, 223], 69: [1, 222], 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VC, [2, 44], { 42: $Vf1 }), o($VS, [2, 70]), o($VS, [2, 69]), { 60: [1, 224], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VS, [2, 72]), o($Vo1, [2, 74]), { 30: 225, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($Ve1, $V4, { 5: 226 }), o($Vp1, [2, 95]), o($Vy, [2, 35]), { 41: 227, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 228, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 239, 101: [1, 240], 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 241, 101: [1, 242], 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 102: [1, 243] }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 244, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 42: $Vd, 45: 245, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vg1, [2, 101]), { 77: [1, 246] }, { 77: [1, 247], 95: [1, 248] }, o($Vg1, [2, 109]), o($Vg1, [2, 111], { 10: [1, 249] }), o($Vg1, [2, 112]), o($VP, [2, 51]), o($Vr1, [2, 80]), o($VP, [2, 52]), { 49: [1, 250], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 59]), o($VP, [2, 54]), o($VP, [2, 55]), o($VP, [2, 56]), { 106: [1, 251] }, o($VP, [2, 58]), o($VP, [2, 60]), { 64: [1, 252], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 62]), o($VP, [2, 63]), o($VP, [2, 65]), o($VP, [2, 64]), o($VP, [2, 66]), o([10, 42, 58, 86, 99, 102, 103, 106, 108, 111, 112, 113], [2, 78]), { 31: [1, 253], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 254], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, o($VO, [2, 48]), o($Vg1, [2, 114], { 103: $VA1 }), o($VB1, [2, 123], { 105: 256, 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }), o($VC1, [2, 125]), o($VC1, [2, 127]), o($VC1, [2, 128]), o($VC1, [2, 129]), o($VC1, [2, 130]), o($VC1, [2, 131]), o($VC1, [2, 132]), o($VC1, [2, 133]), o($VC1, [2, 134]), o($Vg1, [2, 115], { 103: $VA1 }), { 10: [1, 257] }, o($Vg1, [2, 116], { 103: $VA1 }), { 10: [1, 258] }, o($Vq1, [2, 122]), o($Vg1, [2, 98], { 103: $VA1 }), o($Vg1, [2, 99], { 110: 109, 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), o($Vg1, [2, 103]), o($Vg1, [2, 105], { 10: [1, 259] }), o($Vg1, [2, 106]), { 95: [1, 260] }, { 49: [1, 261] }, { 60: [1, 262] }, { 64: [1, 263] }, { 8: $Vz, 9: $VA, 11: $VB, 21: 264 }, o($Vy, [2, 34]), { 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 104: 265, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, o($VC1, [2, 126]), { 14: $VD, 42: $VE, 58: $VF, 86: $VG, 98: 266, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, { 14: $VD, 42: $VE, 58: $VF, 86: $VG, 98: 267, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, { 95: [1, 268] }, o($Vg1, [2, 113]), o($VP, [2, 53]), { 30: 269, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 61]), o($Ve1, $V4, { 5: 270 }), o($VB1, [2, 124], { 105: 256, 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }), o($Vg1, [2, 119], { 117: 160, 10: [1, 271], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 120], { 117: 160, 10: [1, 272], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 107]), { 31: [1, 273], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 274], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 275, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 276, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, o($VP, [2, 57]), o($Vy, [2, 33]), o($Vg1, [2, 117], { 103: $VA1 }), o($Vg1, [2, 118], { 103: $VA1 })], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex2() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex2(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex2() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 34; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 36; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + this.begin("callbackname"); + break; + case 8: + this.popState(); + break; + case 9: + this.popState(); + this.begin("callbackargs"); + break; + case 10: + return 92; + case 11: + this.popState(); + break; + case 12: + return 93; + case 13: + return "MD_STR"; + case 14: + this.popState(); + break; + case 15: + this.begin("md_string"); + break; + case 16: + return "STR"; + case 17: + this.popState(); + break; + case 18: + this.pushState("string"); + break; + case 19: + return 81; + case 20: + return 99; + case 21: + return 82; + case 22: + return 101; + case 23: + return 83; + case 24: + return 84; + case 25: + return 94; + case 26: + this.begin("click"); + break; + case 27: + this.popState(); + break; + case 28: + return 85; + case 29: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 30: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 31: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 32: + return 27; + case 33: + return 32; + case 34: + return 95; + case 35: + return 95; + case 36: + return 95; + case 37: + return 95; + case 38: + this.popState(); + return 13; + case 39: + this.popState(); + return 14; + case 40: + this.popState(); + return 14; + case 41: + this.popState(); + return 14; + case 42: + this.popState(); + return 14; + case 43: + this.popState(); + return 14; + case 44: + this.popState(); + return 14; + case 45: + this.popState(); + return 14; + case 46: + this.popState(); + return 14; + case 47: + this.popState(); + return 14; + case 48: + this.popState(); + return 14; + case 49: + return 118; + case 50: + return 119; + case 51: + return 120; + case 52: + return 121; + case 53: + return 102; + case 54: + return 108; + case 55: + return 44; + case 56: + return 58; + case 57: + return 42; + case 58: + return 8; + case 59: + return 103; + case 60: + return 112; + case 61: + this.popState(); + return 75; + case 62: + this.pushState("edgeText"); + return 73; + case 63: + return 116; + case 64: + this.popState(); + return 75; + case 65: + this.pushState("thickEdgeText"); + return 73; + case 66: + return 116; + case 67: + this.popState(); + return 75; + case 68: + this.pushState("dottedEdgeText"); + return 73; + case 69: + return 116; + case 70: + return 75; + case 71: + this.popState(); + return 51; + case 72: + return "TEXT"; + case 73: + this.pushState("ellipseText"); + return 50; + case 74: + this.popState(); + return 53; + case 75: + this.pushState("text"); + return 52; + case 76: + this.popState(); + return 55; + case 77: + this.pushState("text"); + return 54; + case 78: + return 56; + case 79: + this.pushState("text"); + return 65; + case 80: + this.popState(); + return 62; + case 81: + this.pushState("text"); + return 61; + case 82: + this.popState(); + return 47; + case 83: + this.pushState("text"); + return 46; + case 84: + this.popState(); + return 67; + case 85: + this.popState(); + return 69; + case 86: + return 114; + case 87: + this.pushState("trapText"); + return 66; + case 88: + this.pushState("trapText"); + return 68; + case 89: + return 115; + case 90: + return 65; + case 91: + return 87; + case 92: + return "SEP"; + case 93: + return 86; + case 94: + return 112; + case 95: + return 108; + case 96: + return 42; + case 97: + return 106; + case 98: + return 111; + case 99: + return 113; + case 100: + this.popState(); + return 60; + case 101: + this.pushState("text"); + return 60; + case 102: + this.popState(); + return 49; + case 103: + this.pushState("text"); + return 48; + case 104: + this.popState(); + return 31; + case 105: + this.pushState("text"); + return 29; + case 106: + this.popState(); + return 64; + case 107: + this.pushState("text"); + return 63; + case 108: + return "TEXT"; + case 109: + return "QUOTE"; + case 110: + return 9; + case 111: + return 10; + case 112: + return 11; + } + }, + rules: [/^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:call[\s]+)/, /^(?:\([\s]*\))/, /^(?:\()/, /^(?:[^(]*)/, /^(?:\))/, /^(?:[^)]*)/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["][`])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:["])/, /^(?:style\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\b)/, /^(?:class\b)/, /^(?:href[\s])/, /^(?:click[\s]+)/, /^(?:[\s\n])/, /^(?:[^\s\n]*)/, /^(?:flowchart-elk\b)/, /^(?:graph\b)/, /^(?:flowchart\b)/, /^(?:subgraph\b)/, /^(?:end\b\s*)/, /^(?:_self\b)/, /^(?:_blank\b)/, /^(?:_parent\b)/, /^(?:_top\b)/, /^(?:(\r?\n)*\s*\n)/, /^(?:\s*LR\b)/, /^(?:\s*RL\b)/, /^(?:\s*TB\b)/, /^(?:\s*BT\b)/, /^(?:\s*TD\b)/, /^(?:\s*BR\b)/, /^(?:\s*<)/, /^(?:\s*>)/, /^(?:\s*\^)/, /^(?:\s*v\b)/, /^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:[0-9]+)/, /^(?:#)/, /^(?::::)/, /^(?::)/, /^(?:&)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:[^-]|-(?!-)+)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:[^=]|=(?!))/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:[^\.]|\.(?!))/, /^(?:\s*~~[\~]+\s*)/, /^(?:[-/\)][\)])/, /^(?:[^\(\)\[\]\{\}]|!\)+)/, /^(?:\(-)/, /^(?:\]\))/, /^(?:\(\[)/, /^(?:\]\])/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:>)/, /^(?:\)\])/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\(\(\()/, /^(?:[\\(?=\])][\]])/, /^(?:\/(?=\])\])/, /^(?:\/(?!\])|\\(?!\])|[^\\\[\]\(\)\{\}\/]+)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:<)/, /^(?:>)/, /^(?:\^)/, /^(?:\\\|)/, /^(?:v\b)/, /^(?:\*)/, /^(?:#)/, /^(?:&)/, /^(?:([A-Za-z0-9!"\#$%&'*+\.`?\\_\/]|-(?=[^\>\-\.])|(?!))+)/, /^(?:-)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\|)/, /^(?:\|)/, /^(?:\))/, /^(?:\()/, /^(?:\])/, /^(?:\[)/, /^(?:(\}))/, /^(?:\{)/, /^(?:[^\[\]\(\)\{\}\|\"]+)/, /^(?:")/, /^(?:(\r?\n)+)/, /^(?:\s)/, /^(?:$)/], + conditions: { "callbackargs": { "rules": [11, 12, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "callbackname": { "rules": [8, 9, 10, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "href": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "click": { "rules": [15, 18, 27, 28, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "dottedEdgeText": { "rules": [15, 18, 67, 69, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "thickEdgeText": { "rules": [15, 18, 64, 66, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "edgeText": { "rules": [15, 18, 61, 63, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "trapText": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 84, 85, 86, 87, 88, 101, 103, 105, 107], "inclusive": false }, "ellipseText": { "rules": [15, 18, 70, 71, 72, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "text": { "rules": [15, 18, 70, 73, 74, 75, 76, 77, 80, 81, 82, 83, 87, 88, 100, 101, 102, 103, 104, 105, 106, 107, 108], "inclusive": false }, "vertex": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "dir": { "rules": [15, 18, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_descr_multiline": { "rules": [5, 6, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_descr": { "rules": [3, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_title": { "rules": [1, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "md_string": { "rules": [13, 14, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "string": { "rules": [15, 16, 17, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 67, 68, 70, 73, 75, 77, 78, 79, 81, 83, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 103, 105, 107, 109, 110, 111, 112], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const MERMAID_DOM_ID_PREFIX = "flowchart-"; +let vertexCounter = 0; +let config = getConfig(); +let vertices = {}; +let edges = []; +let classes = {}; +let subGraphs = []; +let subGraphLookup = {}; +let tooltips = {}; +let subCount = 0; +let firstGraphFlag = true; +let direction; +let version; +let funs = []; +const sanitizeText = (txt) => common$1.sanitizeText(txt, config); +const lookUpDomId = function(id) { + const vertexKeys = Object.keys(vertices); + for (const vertexKey of vertexKeys) { + if (vertices[vertexKey].id === id) { + return vertices[vertexKey].domId; + } + } + return id; +}; +const addVertex = function(_id, textObj, type, style, classes2, dir, props = {}) { + let txt; + let id = _id; + if (id === void 0) { + return; + } + if (id.trim().length === 0) { + return; + } + if (vertices[id] === void 0) { + vertices[id] = { + id, + labelType: "text", + domId: MERMAID_DOM_ID_PREFIX + id + "-" + vertexCounter, + styles: [], + classes: [] + }; + } + vertexCounter++; + if (textObj !== void 0) { + config = getConfig(); + txt = sanitizeText(textObj.text.trim()); + vertices[id].labelType = textObj.type; + if (txt[0] === '"' && txt[txt.length - 1] === '"') { + txt = txt.substring(1, txt.length - 1); + } + vertices[id].text = txt; + } else { + if (vertices[id].text === void 0) { + vertices[id].text = _id; + } + } + if (type !== void 0) { + vertices[id].type = type; + } + if (style !== void 0 && style !== null) { + style.forEach(function(s) { + vertices[id].styles.push(s); + }); + } + if (classes2 !== void 0 && classes2 !== null) { + classes2.forEach(function(s) { + vertices[id].classes.push(s); + }); + } + if (dir !== void 0) { + vertices[id].dir = dir; + } + if (vertices[id].props === void 0) { + vertices[id].props = props; + } else if (props !== void 0) { + Object.assign(vertices[id].props, props); + } +}; +const addSingleLink = function(_start, _end, type) { + let start = _start; + let end = _end; + const edge = { start, end, type: void 0, text: "", labelType: "text" }; + log$1.info("abc78 Got edge...", edge); + const linkTextObj = type.text; + if (linkTextObj !== void 0) { + edge.text = sanitizeText(linkTextObj.text.trim()); + if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') { + edge.text = edge.text.substring(1, edge.text.length - 1); + } + edge.labelType = linkTextObj.type; + } + if (type !== void 0) { + edge.type = type.type; + edge.stroke = type.stroke; + edge.length = type.length; + } + if ((edge == null ? void 0 : edge.length) > 10) { + edge.length = 10; + } + if (edges.length < (config.maxEdges ?? 500)) { + log$1.info("abc78 pushing edge..."); + edges.push(edge); + } else { + throw new Error( + `Edge limit exceeded. ${edges.length} edges found, but the limit is ${config.maxEdges}. + +Initialize mermaid with maxEdges set to a higher number to allow more edges. +You cannot set this config via configuration inside the diagram as it is a secure config. +You have to call mermaid.initialize.` + ); + } +}; +const addLink = function(_start, _end, type) { + log$1.info("addLink (abc78)", _start, _end, type); + let i, j; + for (i = 0; i < _start.length; i++) { + for (j = 0; j < _end.length; j++) { + addSingleLink(_start[i], _end[j], type); + } + } +}; +const updateLinkInterpolate = function(positions, interp) { + positions.forEach(function(pos) { + if (pos === "default") { + edges.defaultInterpolate = interp; + } else { + edges[pos].interpolate = interp; + } + }); +}; +const updateLink = function(positions, style) { + positions.forEach(function(pos) { + if (pos >= edges.length) { + throw new Error( + `The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${edges.length - 1}. (Help: Ensure that the index is within the range of existing edges.)` + ); + } + if (pos === "default") { + edges.defaultStyle = style; + } else { + if (utils.isSubstringInArray("fill", style) === -1) { + style.push("fill:none"); + } + edges[pos].style = style; + } + }); +}; +const addClass = function(ids, style) { + ids.split(",").forEach(function(id) { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + if (style !== void 0 && style !== null) { + style.forEach(function(s) { + if (s.match("color")) { + const newStyle = s.replace("fill", "bgFill").replace("color", "fill"); + classes[id].textStyles.push(newStyle); + } + classes[id].styles.push(s); + }); + } + }); +}; +const setDirection = function(dir) { + direction = dir; + if (direction.match(/.*/)) { + direction = "LR"; + } + if (direction.match(/.*v/)) { + direction = "TB"; + } + if (direction === "TD") { + direction = "TB"; + } +}; +const setClass = function(ids, className) { + ids.split(",").forEach(function(_id) { + let id = _id; + if (vertices[id] !== void 0) { + vertices[id].classes.push(className); + } + if (subGraphLookup[id] !== void 0) { + subGraphLookup[id].classes.push(className); + } + }); +}; +const setTooltip = function(ids, tooltip) { + ids.split(",").forEach(function(id) { + if (tooltip !== void 0) { + tooltips[version === "gen-1" ? lookUpDomId(id) : id] = sanitizeText(tooltip); + } + }); +}; +const setClickFun = function(id, functionName, functionArgs) { + let domId = lookUpDomId(id); + if (getConfig().securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(id); + } + if (vertices[id] !== void 0) { + vertices[id].haveCallback = true; + funs.push(function() { + const elem = document.querySelector(`[id="${domId}"]`); + if (elem !== null) { + elem.addEventListener( + "click", + function() { + utils.runFunc(functionName, ...argList); + }, + false + ); + } + }); + } +}; +const setLink = function(ids, linkStr, target) { + ids.split(",").forEach(function(id) { + if (vertices[id] !== void 0) { + vertices[id].link = utils.formatUrl(linkStr, config); + vertices[id].linkTarget = target; + } + }); + setClass(ids, "clickable"); +}; +const getTooltip = function(id) { + if (tooltips.hasOwnProperty(id)) { + return tooltips[id]; + } + return void 0; +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFun(id, functionName, functionArgs); + }); + setClass(ids, "clickable"); +}; +const bindFunctions = function(element) { + funs.forEach(function(fun) { + fun(element); + }); +}; +const getDirection = function() { + return direction.trim(); +}; +const getVertices = function() { + return vertices; +}; +const getEdges = function() { + return edges; +}; +const getClasses = function() { + return classes; +}; +const setupToolTips = function(element) { + let tooltipElem = select(".mermaidTooltip"); + if ((tooltipElem._groups || tooltipElem)[0][0] === null) { + tooltipElem = select("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0); + } + const svg = select(element).select("svg"); + const nodes = svg.selectAll("g.node"); + nodes.on("mouseover", function() { + const el = select(this); + const title = el.attr("title"); + if (title === null) { + return; + } + const rect = this.getBoundingClientRect(); + tooltipElem.transition().duration(200).style("opacity", ".9"); + tooltipElem.text(el.attr("title")).style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.bottom + "px"); + tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, "
")); + el.classed("hover", true); + }).on("mouseout", function() { + tooltipElem.transition().duration(500).style("opacity", 0); + const el = select(this); + el.classed("hover", false); + }); +}; +funs.push(setupToolTips); +const clear = function(ver = "gen-1") { + vertices = {}; + classes = {}; + edges = []; + funs = [setupToolTips]; + subGraphs = []; + subGraphLookup = {}; + subCount = 0; + tooltips = {}; + firstGraphFlag = true; + version = ver; + config = getConfig(); + clear$1(); +}; +const setGen = (ver) => { + version = ver || "gen-2"; +}; +const defaultStyle = function() { + return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; +}; +const addSubGraph = function(_id, list, _title) { + let id = _id.text.trim(); + let title = _title.text; + if (_id === _title && _title.text.match(/\s/)) { + id = void 0; + } + function uniq(a) { + const prims = { boolean: {}, number: {}, string: {} }; + const objs = []; + let dir2; + const nodeList2 = a.filter(function(item) { + const type = typeof item; + if (item.stmt && item.stmt === "dir") { + dir2 = item.value; + return false; + } + if (item.trim() === "") { + return false; + } + if (type in prims) { + return prims[type].hasOwnProperty(item) ? false : prims[type][item] = true; + } else { + return objs.includes(item) ? false : objs.push(item); + } + }); + return { nodeList: nodeList2, dir: dir2 }; + } + let nodeList = []; + const { nodeList: nl, dir } = uniq(nodeList.concat.apply(nodeList, list)); + nodeList = nl; + if (version === "gen-1") { + for (let i = 0; i < nodeList.length; i++) { + nodeList[i] = lookUpDomId(nodeList[i]); + } + } + id = id || "subGraph" + subCount; + title = title || ""; + title = sanitizeText(title); + subCount = subCount + 1; + const subGraph = { + id, + nodes: nodeList, + title: title.trim(), + classes: [], + dir, + labelType: _title.type + }; + log$1.info("Adding", subGraph.id, subGraph.nodes, subGraph.dir); + subGraph.nodes = makeUniq(subGraph, subGraphs).nodes; + subGraphs.push(subGraph); + subGraphLookup[id] = subGraph; + return id; +}; +const getPosForId = function(id) { + for (const [i, subGraph] of subGraphs.entries()) { + if (subGraph.id === id) { + return i; + } + } + return -1; +}; +let secCount = -1; +const posCrossRef = []; +const indexNodes2 = function(id, pos) { + const nodes = subGraphs[pos].nodes; + secCount = secCount + 1; + if (secCount > 2e3) { + return; + } + posCrossRef[secCount] = pos; + if (subGraphs[pos].id === id) { + return { + result: true, + count: 0 + }; + } + let count = 0; + let posCount = 1; + while (count < nodes.length) { + const childPos = getPosForId(nodes[count]); + if (childPos >= 0) { + const res = indexNodes2(id, childPos); + if (res.result) { + return { + result: true, + count: posCount + res.count + }; + } else { + posCount = posCount + res.count; + } + } + count = count + 1; + } + return { + result: false, + count: posCount + }; +}; +const getDepthFirstPos = function(pos) { + return posCrossRef[pos]; +}; +const indexNodes = function() { + secCount = -1; + if (subGraphs.length > 0) { + indexNodes2("none", subGraphs.length - 1); + } +}; +const getSubGraphs = function() { + return subGraphs; +}; +const firstGraph = () => { + if (firstGraphFlag) { + firstGraphFlag = false; + return true; + } + return false; +}; +const destructStartLink = (_str) => { + let str = _str.trim(); + let type = "arrow_open"; + switch (str[0]) { + case "<": + type = "arrow_point"; + str = str.slice(1); + break; + case "x": + type = "arrow_cross"; + str = str.slice(1); + break; + case "o": + type = "arrow_circle"; + str = str.slice(1); + break; + } + let stroke = "normal"; + if (str.includes("=")) { + stroke = "thick"; + } + if (str.includes(".")) { + stroke = "dotted"; + } + return { type, stroke }; +}; +const countChar = (char, str) => { + const length = str.length; + let count = 0; + for (let i = 0; i < length; ++i) { + if (str[i] === char) { + ++count; + } + } + return count; +}; +const destructEndLink = (_str) => { + const str = _str.trim(); + let line = str.slice(0, -1); + let type = "arrow_open"; + switch (str.slice(-1)) { + case "x": + type = "arrow_cross"; + if (str[0] === "x") { + type = "double_" + type; + line = line.slice(1); + } + break; + case ">": + type = "arrow_point"; + if (str[0] === "<") { + type = "double_" + type; + line = line.slice(1); + } + break; + case "o": + type = "arrow_circle"; + if (str[0] === "o") { + type = "double_" + type; + line = line.slice(1); + } + break; + } + let stroke = "normal"; + let length = line.length - 1; + if (line[0] === "=") { + stroke = "thick"; + } + if (line[0] === "~") { + stroke = "invisible"; + } + let dots = countChar(".", line); + if (dots) { + stroke = "dotted"; + length = dots; + } + return { type, stroke, length }; +}; +const destructLink = (_str, _startStr) => { + const info = destructEndLink(_str); + let startInfo; + if (_startStr) { + startInfo = destructStartLink(_startStr); + if (startInfo.stroke !== info.stroke) { + return { type: "INVALID", stroke: "INVALID" }; + } + if (startInfo.type === "arrow_open") { + startInfo.type = info.type; + } else { + if (startInfo.type !== info.type) { + return { type: "INVALID", stroke: "INVALID" }; + } + startInfo.type = "double_" + startInfo.type; + } + if (startInfo.type === "double_arrow") { + startInfo.type = "double_arrow_point"; + } + startInfo.length = info.length; + return startInfo; + } + return info; +}; +const exists = (allSgs, _id) => { + let res = false; + allSgs.forEach((sg) => { + const pos = sg.nodes.indexOf(_id); + if (pos >= 0) { + res = true; + } + }); + return res; +}; +const makeUniq = (sg, allSubgraphs) => { + const res = []; + sg.nodes.forEach((_id, pos) => { + if (!exists(allSubgraphs, _id)) { + res.push(sg.nodes[pos]); + } + }); + return { nodes: res }; +}; +const lex = { + firstGraph +}; +const flowDb = { + defaultConfig: () => defaultConfig.flowchart, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + addVertex, + lookUpDomId, + addLink, + updateLinkInterpolate, + updateLink, + addClass, + setDirection, + setClass, + setTooltip, + getTooltip, + setClickEvent, + setLink, + bindFunctions, + getDirection, + getVertices, + getEdges, + getClasses, + clear, + setGen, + defaultStyle, + addSubGraph, + getDepthFirstPos, + indexNodes, + getSubGraphs, + destructLink, + lex, + exists, + makeUniq, + setDiagramTitle, + getDiagramTitle +}; +const db = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + addClass, + addLink, + addSingleLink, + addSubGraph, + addVertex, + bindFunctions, + clear, + default: flowDb, + defaultStyle, + destructLink, + firstGraph, + getClasses, + getDepthFirstPos, + getDirection, + getEdges, + getSubGraphs, + getTooltip, + getVertices, + indexNodes, + lex, + lookUpDomId, + setClass, + setClickEvent, + setDirection, + setGen, + setLink, + updateLink, + updateLinkInterpolate +}, Symbol.toStringTag, { value: "Module" })); + +export { db as d, flowDb as f, parser$1 as p }; diff --git a/libs/marked/flowDiagram-b222e15a-BK68zTn6.js b/libs/marked/flowDiagram-b222e15a-BK68zTn6.js new file mode 100644 index 0000000..c032238 --- /dev/null +++ b/libs/marked/flowDiagram-b222e15a-BK68zTn6.js @@ -0,0 +1,1583 @@ +import { p as parser$1, f as flowDb } from './flowDb-c1833063-Df5kDQr4.js'; +import { h as has, f as forEach, G as Graph } from './graph-KZW2Npeo.js'; +import { h as select, n as curveLinear, o as getStylesFromArray, p as evaluate, c as getConfig, r as renderKatex, j as common$1, l as log$1, q as interpolateToCurve, t as setupGraphViewbox$1 } from './index-Bd_FDXSq.js'; +import { u as uniqueId, r as range, p as pick, l as layout, d as defaults } from './layout-BnytXFfq.js'; +import { a as applyStyle, b as addHtmlLabel, i as isSubgraph, c as applyTransition, e as edgeToId, d as applyClass, f as flowRendererV2, g as flowStyles, s as selectAll } from './styles-483fbfea-DDPjh658.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './index-01f381cb-BCBEZMaa.js'; +import './clone-B-QllgkM.js'; +import './edges-066a5561-Bqw9g7uz.js'; +import './createText-ca0c5216-B9KlDTE8.js'; +import './channel-BxFDB0yY.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +function responseText(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + return response.text(); +} + +function text(input, init) { + return fetch(input, init).then(responseText); +} + +function parser(type) { + return (input, init) => text(input, init) + .then(text => (new DOMParser).parseFromString(text, type)); +} + +var svg = parser("image/svg+xml"); + +var arrows = { + normal, + vee, + undirected, +}; + +function setArrows(value) { + arrows = value; +} + +function normal(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 0 L 10 5 L 0 10 z') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function vee(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 0 L 10 5 L 0 10 L 4 5 z') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function undirected(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 5 L 10 5') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function addSVGLabel(root, node) { + var domNode = root; + + domNode.node().appendChild(node.label); + + applyStyle(domNode, node.labelStyle); + + return domNode; +} + +/* + * Attaches a text label to the specified root. Handles escape sequences. + */ +function addTextLabel(root, node) { + var domNode = root.append('text'); + + var lines = processEscapeSequences(node.label).split('\n'); + for (var i = 0; i < lines.length; i++) { + domNode + .append('tspan') + .attr('xml:space', 'preserve') + .attr('dy', '1em') + .attr('x', '1') + .text(lines[i]); + } + + applyStyle(domNode, node.labelStyle); + + return domNode; +} + +function processEscapeSequences(text) { + var newText = ''; + var escaped = false; + var ch; + for (var i = 0; i < text.length; ++i) { + ch = text[i]; + if (escaped) { + switch (ch) { + case 'n': + newText += '\n'; + break; + default: + newText += ch; + } + escaped = false; + } else if (ch === '\\') { + escaped = true; + } else { + newText += ch; + } + } + return newText; +} + +function addLabel(root, node, location) { + var label = node.label; + var labelSvg = root.append('g'); + + // Allow the label to be a string, a function that returns a DOM element, or + // a DOM element itself. + if (node.labelType === 'svg') { + addSVGLabel(labelSvg, node); + } else if (typeof label !== 'string' || node.labelType === 'html') { + addHtmlLabel(labelSvg, node); + } else { + addTextLabel(labelSvg, node); + } + + var labelBBox = labelSvg.node().getBBox(); + var y; + switch (location) { + case 'top': + y = -node.height / 2; + break; + case 'bottom': + y = node.height / 2 - labelBBox.height; + break; + default: + y = -labelBBox.height / 2; + } + labelSvg.attr('transform', 'translate(' + -labelBBox.width / 2 + ',' + y + ')'); + + return labelSvg; +} + +var createClusters = function (selection, g) { + var clusters = g.nodes().filter(function (v) { + return isSubgraph(g, v); + }); + var svgClusters = selection.selectAll('g.cluster').data(clusters, function (v) { + return v; + }); + + applyTransition(svgClusters.exit(), g).style('opacity', 0).remove(); + + var enterSelection = svgClusters + .enter() + .append('g') + .attr('class', 'cluster') + .attr('id', function (v) { + var node = g.node(v); + return node.id; + }) + .style('opacity', 0) + .each(function (v) { + var node = g.node(v); + var thisGroup = select(this); + select(this).append('rect'); + var labelGroup = thisGroup.append('g').attr('class', 'label'); + addLabel(labelGroup, node, node.clusterLabelPos); + }); + + svgClusters = svgClusters.merge(enterSelection); + + svgClusters = applyTransition(svgClusters, g).style('opacity', 1); + + svgClusters.selectAll('rect').each(function (c) { + var node = g.node(c); + var domCluster = select(this); + applyStyle(domCluster, node.style); + }); + + return svgClusters; +}; + +function setCreateClusters(value) { + createClusters = value; +} + +let createEdgeLabels = function (selection, g) { + var svgEdgeLabels = selection + .selectAll('g.edgeLabel') + .data(g.edges(), function (e) { + return edgeToId(e); + }) + .classed('update', true); + + svgEdgeLabels.exit().remove(); + svgEdgeLabels.enter().append('g').classed('edgeLabel', true).style('opacity', 0); + + svgEdgeLabels = selection.selectAll('g.edgeLabel'); + + svgEdgeLabels.each(function (e) { + var root = select(this); + root.select('.label').remove(); + var edge = g.edge(e); + var label = addLabel(root, g.edge(e), 0).classed('label', true); + var bbox = label.node().getBBox(); + + if (edge.labelId) { + label.attr('id', edge.labelId); + } + if (!has(edge, 'width')) { + edge.width = bbox.width; + } + if (!has(edge, 'height')) { + edge.height = bbox.height; + } + }); + + var exitSelection; + + if (svgEdgeLabels.exit) { + exitSelection = svgEdgeLabels.exit(); + } else { + exitSelection = svgEdgeLabels.selectAll(null); // empty selection + } + + applyTransition(exitSelection, g).style('opacity', 0).remove(); + + return svgEdgeLabels; +}; + +function setCreateEdgeLabels(value) { + createEdgeLabels = value; +} + +function intersectNode(node, point) { + return node.intersect(point); +} + +var createEdgePaths = function (selection, g, arrows) { + var previousPaths = selection + .selectAll('g.edgePath') + .data(g.edges(), function (e) { + return edgeToId(e); + }) + .classed('update', true); + + var newPaths = enter(previousPaths, g); + exit(previousPaths, g); + + var svgPaths = previousPaths.merge !== undefined ? previousPaths.merge(newPaths) : previousPaths; + applyTransition(svgPaths, g).style('opacity', 1); + + // Save DOM element in the path group, and set ID and class + svgPaths.each(function (e) { + var domEdge = select(this); + var edge = g.edge(e); + edge.elem = this; + + if (edge.id) { + domEdge.attr('id', edge.id); + } + + applyClass( + domEdge, + edge['class'], + (domEdge.classed('update') ? 'update ' : '') + 'edgePath' + ); + }); + + svgPaths.selectAll('path.path').each(function (e) { + var edge = g.edge(e); + edge.arrowheadId = uniqueId('arrowhead'); + + var domEdge = select(this) + .attr('marker-end', function () { + return 'url(' + makeFragmentRef(location.href, edge.arrowheadId) + ')'; + }) + .style('fill', 'none'); + + applyTransition(domEdge, g).attr('d', function (e) { + return calcPoints(g, e); + }); + + applyStyle(domEdge, edge.style); + }); + + svgPaths.selectAll('defs *').remove(); + svgPaths.selectAll('defs').each(function (e) { + var edge = g.edge(e); + var arrowhead = arrows[edge.arrowhead]; + arrowhead(select(this), edge.arrowheadId, edge, 'arrowhead'); + }); + + return svgPaths; +}; + +function setCreateEdgePaths(value) { + createEdgePaths = value; +} + +function makeFragmentRef(url, fragmentId) { + var baseUrl = url.split('#')[0]; + return baseUrl + '#' + fragmentId; +} + +function calcPoints(g, e) { + var edge = g.edge(e); + var tail = g.node(e.v); + var head = g.node(e.w); + var points = edge.points.slice(1, edge.points.length - 1); + points.unshift(intersectNode(tail, points[0])); + points.push(intersectNode(head, points[points.length - 1])); + + return createLine(edge, points); +} + +function createLine(edge, points) { + // @ts-expect-error + var line$1 = (line || svg.line)() + .x(function (d) { + return d.x; + }) + .y(function (d) { + return d.y; + }); + + (line$1.curve || line$1.interpolate)(edge.curve); + + return line$1(points); +} + +function getCoords(elem) { + var bbox = elem.getBBox(); + var matrix = elem.ownerSVGElement + .getScreenCTM() + .inverse() + .multiply(elem.getScreenCTM()) + .translate(bbox.width / 2, bbox.height / 2); + return { x: matrix.e, y: matrix.f }; +} + +function enter(svgPaths, g) { + var svgPathsEnter = svgPaths.enter().append('g').attr('class', 'edgePath').style('opacity', 0); + svgPathsEnter + .append('path') + .attr('class', 'path') + .attr('d', function (e) { + var edge = g.edge(e); + var sourceElem = g.node(e.v).elem; + var points = range(edge.points.length).map(function () { + return getCoords(sourceElem); + }); + return createLine(edge, points); + }); + svgPathsEnter.append('defs'); + return svgPathsEnter; +} + +function exit(svgPaths, g) { + var svgPathExit = svgPaths.exit(); + applyTransition(svgPathExit, g).style('opacity', 0).remove(); +} + +var createNodes = function (selection, g, shapes) { + var simpleNodes = g.nodes().filter(function (v) { + return !isSubgraph(g, v); + }); + var svgNodes = selection + .selectAll('g.node') + .data(simpleNodes, function (v) { + return v; + }) + .classed('update', true); + + svgNodes.exit().remove(); + + svgNodes.enter().append('g').attr('class', 'node').style('opacity', 0); + + svgNodes = selection.selectAll('g.node'); + + svgNodes.each(function (v) { + var node = g.node(v); + var thisGroup = select(this); + applyClass( + thisGroup, + node['class'], + (thisGroup.classed('update') ? 'update ' : '') + 'node' + ); + + thisGroup.select('g.label').remove(); + var labelGroup = thisGroup.append('g').attr('class', 'label'); + var labelDom = addLabel(labelGroup, node); + var shape = shapes[node.shape]; + var bbox = pick(labelDom.node().getBBox(), 'width', 'height'); + + node.elem = this; + + if (node.id) { + thisGroup.attr('id', node.id); + } + if (node.labelId) { + labelGroup.attr('id', node.labelId); + } + + if (has(node, 'width')) { + bbox.width = node.width; + } + if (has(node, 'height')) { + bbox.height = node.height; + } + + bbox.width += node.paddingLeft + node.paddingRight; + bbox.height += node.paddingTop + node.paddingBottom; + labelGroup.attr( + 'transform', + 'translate(' + + (node.paddingLeft - node.paddingRight) / 2 + + ',' + + (node.paddingTop - node.paddingBottom) / 2 + + ')' + ); + + var root = select(this); + root.select('.label-container').remove(); + var shapeSvg = shape(root, bbox, node).classed('label-container', true); + applyStyle(shapeSvg, node.style); + + var shapeBBox = shapeSvg.node().getBBox(); + node.width = shapeBBox.width; + node.height = shapeBBox.height; + }); + + var exitSelection; + + if (svgNodes.exit) { + exitSelection = svgNodes.exit(); + } else { + exitSelection = svgNodes.selectAll(null); // empty selection + } + + applyTransition(exitSelection, g).style('opacity', 0).remove(); + + return svgNodes; +}; + +function setCreateNodes(value) { + createNodes = value; +} + +function positionClusters(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(v) { + var node = g.node(v); + return 'translate(' + node.x + ',' + node.y + ')'; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); + + applyTransition(created.selectAll('rect'), g) + .attr('width', function (v) { + return g.node(v).width; + }) + .attr('height', function (v) { + return g.node(v).height; + }) + .attr('x', function (v) { + var node = g.node(v); + return -node.width / 2; + }) + .attr('y', function (v) { + var node = g.node(v); + return -node.height / 2; + }); +} + +function positionEdgeLabels(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(e) { + var edge = g.edge(e); + return has(edge, 'x') ? 'translate(' + edge.x + ',' + edge.y + ')' : ''; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); +} + +function positionNodes(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(v) { + var node = g.node(v); + return 'translate(' + node.x + ',' + node.y + ')'; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); +} + +function intersectEllipse(node, rx, ry, point) { + // Formulae from: http://mathworld.wolfram.com/Ellipse-LineIntersection.html + + var cx = node.x; + var cy = node.y; + + var px = cx - point.x; + var py = cy - point.y; + + var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px); + + var dx = Math.abs((rx * ry * px) / det); + if (point.x < cx) { + dx = -dx; + } + var dy = Math.abs((rx * ry * py) / det); + if (point.y < cy) { + dy = -dy; + } + + return { x: cx + dx, y: cy + dy }; +} + +function intersectCircle(node, rx, point) { + return intersectEllipse(node, rx, rx, point); +} + +/* + * Returns the point at which two lines, p and q, intersect or returns + * undefined if they do not intersect. + */ +function intersectLine(p1, p2, q1, q2) { + // Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994, + // p7 and p473. + + var a1, a2, b1, b2, c1, c2; + var r1, r2, r3, r4; + var denom, offset, num; + var x, y; + + // Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x + + // b1 y + c1 = 0. + a1 = p2.y - p1.y; + b1 = p1.x - p2.x; + c1 = p2.x * p1.y - p1.x * p2.y; + + // Compute r3 and r4. + r3 = a1 * q1.x + b1 * q1.y + c1; + r4 = a1 * q2.x + b1 * q2.y + c1; + + // Check signs of r3 and r4. If both point 3 and point 4 lie on + // same side of line 1, the line segments do not intersect. + if (r3 !== 0 && r4 !== 0 && sameSign(r3, r4)) { + return /*DONT_INTERSECT*/; + } + + // Compute a2, b2, c2 where line joining points 3 and 4 is G(x,y) = a2 x + b2 y + c2 = 0 + a2 = q2.y - q1.y; + b2 = q1.x - q2.x; + c2 = q2.x * q1.y - q1.x * q2.y; + + // Compute r1 and r2 + r1 = a2 * p1.x + b2 * p1.y + c2; + r2 = a2 * p2.x + b2 * p2.y + c2; + + // Check signs of r1 and r2. If both point 1 and point 2 lie + // on same side of second line segment, the line segments do + // not intersect. + if (r1 !== 0 && r2 !== 0 && sameSign(r1, r2)) { + return /*DONT_INTERSECT*/; + } + + // Line segments intersect: compute intersection point. + denom = a1 * b2 - a2 * b1; + if (denom === 0) { + return /*COLLINEAR*/; + } + + offset = Math.abs(denom / 2); + + // The denom/2 is to get rounding instead of truncating. It + // is added or subtracted to the numerator, depending upon the + // sign of the numerator. + num = b1 * c2 - b2 * c1; + x = num < 0 ? (num - offset) / denom : (num + offset) / denom; + + num = a2 * c1 - a1 * c2; + y = num < 0 ? (num - offset) / denom : (num + offset) / denom; + + return { x: x, y: y }; +} + +function sameSign(r1, r2) { + return r1 * r2 > 0; +} + +/* + * Returns the point ({x, y}) at which the point argument intersects with the + * node argument assuming that it has the shape specified by polygon. + */ +function intersectPolygon(node, polyPoints, point) { + var x1 = node.x; + var y1 = node.y; + + var intersections = []; + + var minX = Number.POSITIVE_INFINITY; + var minY = Number.POSITIVE_INFINITY; + polyPoints.forEach(function (entry) { + minX = Math.min(minX, entry.x); + minY = Math.min(minY, entry.y); + }); + + var left = x1 - node.width / 2 - minX; + var top = y1 - node.height / 2 - minY; + + for (var i = 0; i < polyPoints.length; i++) { + var p1 = polyPoints[i]; + var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0]; + var intersect = intersectLine( + node, + point, + { x: left + p1.x, y: top + p1.y }, + { x: left + p2.x, y: top + p2.y } + ); + if (intersect) { + intersections.push(intersect); + } + } + + if (!intersections.length) { + console.log('NO INTERSECTION FOUND, RETURN NODE CENTER', node); + return node; + } + + if (intersections.length > 1) { + // More intersections, find the one nearest to edge end point + intersections.sort(function (p, q) { + var pdx = p.x - point.x; + var pdy = p.y - point.y; + var distp = Math.sqrt(pdx * pdx + pdy * pdy); + + var qdx = q.x - point.x; + var qdy = q.y - point.y; + var distq = Math.sqrt(qdx * qdx + qdy * qdy); + + return distp < distq ? -1 : distp === distq ? 0 : 1; + }); + } + return intersections[0]; +} + +function intersectRect(node, point) { + var x = node.x; + var y = node.y; + + // Rectangle intersection algorithm from: + // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes + var dx = point.x - x; + var dy = point.y - y; + var w = node.width / 2; + var h = node.height / 2; + + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + // Intersection is top or bottom of rect. + if (dy < 0) { + h = -h; + } + sx = dy === 0 ? 0 : (h * dx) / dy; + sy = h; + } else { + // Intersection is left or right of rect. + if (dx < 0) { + w = -w; + } + sx = w; + sy = dx === 0 ? 0 : (w * dy) / dx; + } + + return { x: x + sx, y: y + sy }; +} + +var shapes = { + rect, + ellipse, + circle, + diamond, +}; + +function setShapes(value) { + shapes = value; +} + +function rect(parent, bbox, node) { + var shapeSvg = parent + .insert('rect', ':first-child') + .attr('rx', node.rx) + .attr('ry', node.ry) + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('width', bbox.width) + .attr('height', bbox.height); + + node.intersect = function (point) { + return intersectRect(node, point); + }; + + return shapeSvg; +} + +function ellipse(parent, bbox, node) { + var rx = bbox.width / 2; + var ry = bbox.height / 2; + var shapeSvg = parent + .insert('ellipse', ':first-child') + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('rx', rx) + .attr('ry', ry); + + node.intersect = function (point) { + return intersectEllipse(node, rx, ry, point); + }; + + return shapeSvg; +} + +function circle(parent, bbox, node) { + var r = Math.max(bbox.width, bbox.height) / 2; + var shapeSvg = parent + .insert('circle', ':first-child') + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('r', r); + + node.intersect = function (point) { + return intersectCircle(node, r, point); + }; + + return shapeSvg; +} + +// Circumscribe an ellipse for the bounding box with a diamond shape. I derived +// the function to calculate the diamond shape from: +// http://mathforum.org/kb/message.jspa?messageID=3750236 +function diamond(parent, bbox, node) { + var w = (bbox.width * Math.SQRT2) / 2; + var h = (bbox.height * Math.SQRT2) / 2; + var points = [ + { x: 0, y: -h }, + { x: -w, y: 0 }, + { x: 0, y: h }, + { x: w, y: 0 }, + ]; + var shapeSvg = parent.insert('polygon', ':first-child').attr( + 'points', + points + .map(function (p) { + return p.x + ',' + p.y; + }) + .join(' ') + ); + + node.intersect = function (p) { + return intersectPolygon(node, points, p); + }; + + return shapeSvg; +} + +// This design is based on http://bost.ocks.org/mike/chart/. +function render() { + var fn = function (svg, g) { + preProcessGraph(g); + + var outputGroup = createOrSelectGroup(svg, 'output'); + var clustersGroup = createOrSelectGroup(outputGroup, 'clusters'); + var edgePathsGroup = createOrSelectGroup(outputGroup, 'edgePaths'); + var edgeLabels = createEdgeLabels(createOrSelectGroup(outputGroup, 'edgeLabels'), g); + var nodes = createNodes(createOrSelectGroup(outputGroup, 'nodes'), g, shapes); + + layout(g); + + positionNodes(nodes, g); + positionEdgeLabels(edgeLabels, g); + createEdgePaths(edgePathsGroup, g, arrows); + + var clusters = createClusters(clustersGroup, g); + positionClusters(clusters, g); + + postProcessGraph(g); + }; + + fn.createNodes = function (value) { + if (!arguments.length) return createNodes; + setCreateNodes(value); + return fn; + }; + + fn.createClusters = function (value) { + if (!arguments.length) return createClusters; + setCreateClusters(value); + return fn; + }; + + fn.createEdgeLabels = function (value) { + if (!arguments.length) return createEdgeLabels; + setCreateEdgeLabels(value); + return fn; + }; + + fn.createEdgePaths = function (value) { + if (!arguments.length) return createEdgePaths; + setCreateEdgePaths(value); + return fn; + }; + + fn.shapes = function (value) { + if (!arguments.length) return shapes; + setShapes(value); + return fn; + }; + + fn.arrows = function (value) { + if (!arguments.length) return arrows; + setArrows(value); + return fn; + }; + + return fn; +} + +var NODE_DEFAULT_ATTRS = { + paddingLeft: 10, + paddingRight: 10, + paddingTop: 10, + paddingBottom: 10, + rx: 0, + ry: 0, + shape: 'rect', +}; + +var EDGE_DEFAULT_ATTRS = { + arrowhead: 'normal', + curve: curveLinear, +}; + +function preProcessGraph(g) { + g.nodes().forEach(function (v) { + var node = g.node(v); + if (!has(node, 'label') && !g.children(v).length) { + node.label = v; + } + + if (has(node, 'paddingX')) { + defaults(node, { + paddingLeft: node.paddingX, + paddingRight: node.paddingX, + }); + } + + if (has(node, 'paddingY')) { + defaults(node, { + paddingTop: node.paddingY, + paddingBottom: node.paddingY, + }); + } + + if (has(node, 'padding')) { + defaults(node, { + paddingLeft: node.padding, + paddingRight: node.padding, + paddingTop: node.padding, + paddingBottom: node.padding, + }); + } + + defaults(node, NODE_DEFAULT_ATTRS); + + forEach(['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'], function (k) { + node[k] = Number(node[k]); + }); + + // Save dimensions for restore during post-processing + if (has(node, 'width')) { + node._prevWidth = node.width; + } + if (has(node, 'height')) { + node._prevHeight = node.height; + } + }); + + g.edges().forEach(function (e) { + var edge = g.edge(e); + if (!has(edge, 'label')) { + edge.label = ''; + } + defaults(edge, EDGE_DEFAULT_ATTRS); + }); +} + +function postProcessGraph(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + + // Restore original dimensions + if (has(node, '_prevWidth')) { + node.width = node._prevWidth; + } else { + delete node.width; + } + + if (has(node, '_prevHeight')) { + node.height = node._prevHeight; + } else { + delete node.height; + } + + delete node._prevWidth; + delete node._prevHeight; + }); +} + +function createOrSelectGroup(root, name) { + var selection = root.select('g.' + name); + if (selection.empty()) { + selection = root.append('g').attr('class', name); + } + return selection; +} + +function question(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const s = (w + h) * 0.9; + const points = [ + { x: s / 2, y: 0 }, + { x: s, y: -s / 2 }, + { x: s / 2, y: -s }, + { x: 0, y: -s / 2 } + ]; + const shapeSvg = insertPolygonShape(parent, s, s, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function hexagon(parent, bbox, node) { + const f = 4; + const h = bbox.height; + const m = h / f; + const w = bbox.width + 2 * m; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function rect_left_inv_arrow(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -h / 2, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: -h / 2, y: -h }, + { x: 0, y: -h / 2 } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function lean_right(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function lean_left(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 2 * h / 6, y: 0 }, + { x: w + h / 6, y: 0 }, + { x: w - 2 * h / 6, y: -h }, + { x: -h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function trapezoid(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w + 2 * h / 6, y: 0 }, + { x: w - h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function inv_trapezoid(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: -2 * h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function rect_right_inv_arrow(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 0, y: 0 }, + { x: w + h / 2, y: 0 }, + { x: w, y: -h / 2 }, + { x: w + h / 2, y: -h }, + { x: 0, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function stadium(parent, bbox, node) { + const h = bbox.height; + const w = bbox.width + h / 4; + const shapeSvg = parent.insert("rect", ":first-child").attr("rx", h / 2).attr("ry", h / 2).attr("x", -w / 2).attr("y", -h / 2).attr("width", w).attr("height", h); + node.intersect = function(point) { + return intersectRect(node, point); + }; + return shapeSvg; +} +function subroutine(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 0, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: 0, y: -h }, + { x: 0, y: 0 }, + { x: -8, y: 0 }, + { x: w + 8, y: 0 }, + { x: w + 8, y: -h }, + { x: -8, y: -h }, + { x: -8, y: 0 } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function cylinder(parent, bbox, node) { + const w = bbox.width; + const rx = w / 2; + const ry = rx / (2.5 + w / 50); + const h = bbox.height + ry; + const shape = "M 0," + ry + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 a " + rx + "," + ry + " 0,0,0 " + -w + " 0 l 0," + h + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 l 0," + -h; + const shapeSvg = parent.attr("label-offset-y", ry).insert("path", ":first-child").attr("d", shape).attr("transform", "translate(" + -w / 2 + "," + -(h / 2 + ry) + ")"); + node.intersect = function(point) { + const pos = intersectRect(node, point); + const x = pos.x - node.x; + if (rx != 0 && (Math.abs(x) < node.width / 2 || Math.abs(x) == node.width / 2 && Math.abs(pos.y - node.y) > node.height / 2 - ry)) { + let y = ry * ry * (1 - x * x / (rx * rx)); + if (y != 0) { + y = Math.sqrt(y); + } + y = ry - y; + if (point.y - node.y > 0) { + y = -y; + } + pos.y += y; + } + return pos; + }; + return shapeSvg; +} +function addToRender(render2) { + render2.shapes().question = question; + render2.shapes().hexagon = hexagon; + render2.shapes().stadium = stadium; + render2.shapes().subroutine = subroutine; + render2.shapes().cylinder = cylinder; + render2.shapes().rect_left_inv_arrow = rect_left_inv_arrow; + render2.shapes().lean_right = lean_right; + render2.shapes().lean_left = lean_left; + render2.shapes().trapezoid = trapezoid; + render2.shapes().inv_trapezoid = inv_trapezoid; + render2.shapes().rect_right_inv_arrow = rect_right_inv_arrow; +} +function addToRenderV2(addShape) { + addShape({ question }); + addShape({ hexagon }); + addShape({ stadium }); + addShape({ subroutine }); + addShape({ cylinder }); + addShape({ rect_left_inv_arrow }); + addShape({ lean_right }); + addShape({ lean_left }); + addShape({ trapezoid }); + addShape({ inv_trapezoid }); + addShape({ rect_right_inv_arrow }); +} +function insertPolygonShape(parent, w, h, points) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("transform", "translate(" + -w / 2 + "," + h / 2 + ")"); +} +const flowChartShapes = { + addToRender, + addToRenderV2 +}; +const conf = {}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf[key] = cnf[key]; + } +}; +const addVertices = async function(vert, g, svgId, root, _doc, diagObj) { + const svg = !root ? select(`[id="${svgId}"]`) : root.select(`[id="${svgId}"]`); + const doc = !_doc ? document : _doc; + const keys = Object.keys(vert); + for (const id of keys) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + const styles = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + let vertexNode; + if (evaluate(getConfig().flowchart.htmlLabels)) { + const node = { + label: await renderKatex( + vertexText.replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell:disable-line + (s) => `` + ), + getConfig() + ) + }; + vertexNode = addHtmlLabel(svg, node).node(); + vertexNode.parentNode.removeChild(vertexNode); + } else { + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", styles.labelStyle.replace("color:", "fill:")); + const rows = vertexText.split(common$1.lineBreakRegex); + for (const row of rows) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "1"); + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + vertexNode = svgLabel; + } + let radius = 0; + let _shape = ""; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + default: + _shape = "rect"; + } + log$1.warn("Adding node", vertex.id, vertex.domId); + g.setNode(diagObj.db.lookUpDomId(vertex.id), { + labelType: "svg", + labelStyle: styles.labelStyle, + shape: _shape, + label: vertexNode, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: diagObj.db.lookUpDomId(vertex.id) + }); + } +}; +const addEdges = async function(edges, g, diagObj) { + let cnt = 0; + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + for (const edge of edges) { + cnt++; + const linkId = "L-" + edge.start + "-" + edge.end; + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = {}; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + let style = ""; + let labelStyle = ""; + if (edge.style !== void 0) { + const styles = getStylesFromArray(edge.style); + style = styles.style; + labelStyle = styles.labelStyle; + } else { + switch (edge.stroke) { + case "normal": + style = "fill:none"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + break; + case "dotted": + style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + style = " stroke-width: 3.5px;fill:none"; + break; + } + } + edgeData.style = style; + edgeData.labelStyle = labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + if (evaluate(getConfig().flowchart.htmlLabels)) { + edgeData.labelType = "html"; + edgeData.label = `${await renderKatex( + edge.text.replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell:disable-line + (s) => `` + ), + getConfig() + )}`; + } else { + edgeData.labelType = "text"; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + } + } + edgeData.id = linkId; + edgeData.class = linkNameStart + " " + linkNameEnd; + edgeData.minlen = edge.length || 1; + g.setEdge(diagObj.db.lookUpDomId(edge.start), diagObj.db.lookUpDomId(edge.end), edgeData, cnt); + } +}; +const getClasses = function(text, diagObj) { + log$1.info("Extracting classes"); + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + log$1.info("Drawing flowchart"); + const { securityLevel, flowchart: conf2 } = getConfig(); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + let dir = diagObj.db.getDirection(); + if (dir === void 0) { + dir = "TD"; + } + const nodeSpacing = conf2.nodeSpacing || 50; + const rankSpacing = conf2.rankSpacing || 50; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + for (let i2 = subGraphs.length - 1; i2 >= 0; i2--) { + subG = subGraphs[i2]; + diagObj.db.addVertex(subG.id, subG.title, "group", void 0, subG.classes); + } + const vert = diagObj.db.getVertices(); + log$1.warn("Get vertices", vert); + const edges = diagObj.db.getEdges(); + let i = 0; + for (i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + selectAll("cluster").append("text"); + for (let j = 0; j < subG.nodes.length; j++) { + log$1.warn( + "Setting subgraph", + subG.nodes[j], + diagObj.db.lookUpDomId(subG.nodes[j]), + diagObj.db.lookUpDomId(subG.id) + ); + g.setParent(diagObj.db.lookUpDomId(subG.nodes[j]), diagObj.db.lookUpDomId(subG.id)); + } + } + await addVertices(vert, g, id, root, doc, diagObj); + await addEdges(edges, g, diagObj); + const render$1 = new render(); + flowChartShapes.addToRender(render$1); + render$1.arrows().none = function normal(parent, id2, edge, type) { + const marker = parent.append("marker").attr("id", id2).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 6).attr("orient", "auto"); + const path = marker.append("path").attr("d", "M 0 0 L 0 0 L 0 0 z"); + applyStyle(path, edge[type + "Style"]); + }; + render$1.arrows().normal = function normal(parent, id2) { + const marker = parent.append("marker").attr("id", id2).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 6).attr("orient", "auto"); + marker.append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("class", "arrowheadPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + }; + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + render$1(element, g); + element.selectAll("g.node").attr("title", function() { + return diagObj.db.getTooltip(this.id); + }); + diagObj.db.indexNodes("subGraph" + i); + for (i = 0; i < subGraphs.length; i++) { + subG = subGraphs[i]; + if (subG.title !== "undefined") { + const clusterRects = doc.querySelectorAll( + "#" + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"] rect' + ); + const clusterEl = doc.querySelectorAll( + "#" + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"]' + ); + const xPos = clusterRects[0].x.baseVal.value; + const yPos = clusterRects[0].y.baseVal.value; + const _width = clusterRects[0].width.baseVal.value; + const cluster = select(clusterEl[0]); + const te = cluster.select(".label"); + te.attr("transform", `translate(${xPos + _width / 2}, ${yPos + 14})`); + te.attr("id", id + "Text"); + for (let j = 0; j < subG.classes.length; j++) { + clusterEl[0].classList.add(subG.classes[j]); + } + } + } + if (!conf2.htmlLabels) { + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } + setupGraphViewbox$1(g, svg, conf2.diagramPadding, conf2.useMaxWidth); + const keys = Object.keys(vert); + keys.forEach(function(key) { + const vertex = vert[key]; + if (vertex.link) { + const node = root.select("#" + id + ' [id="' + diagObj.db.lookUpDomId(key) + '"]'); + if (node) { + const link = doc.createElementNS("http://www.w3.org/2000/svg", "a"); + link.setAttributeNS("http://www.w3.org/2000/svg", "class", vertex.classes.join(" ")); + link.setAttributeNS("http://www.w3.org/2000/svg", "href", vertex.link); + link.setAttributeNS("http://www.w3.org/2000/svg", "rel", "noopener"); + if (securityLevel === "sandbox") { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", "_top"); + } else if (vertex.linkTarget) { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", vertex.linkTarget); + } + const linkNode = node.insert(function() { + return link; + }, ":first-child"); + const shape = node.select(".label-container"); + if (shape) { + linkNode.append(function() { + return shape.node(); + }); + } + const label = node.select(".label"); + if (label) { + linkNode.append(function() { + return label.node(); + }); + } + } + } + }); +}; +const flowRenderer = { + setConf, + addVertices, + addEdges, + getClasses, + draw +}; +const diagram = { + parser: parser$1, + db: flowDb, + renderer: flowRendererV2, + styles: flowStyles, + init: (cnf) => { + if (!cnf.flowchart) { + cnf.flowchart = {}; + } + cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + flowRenderer.setConf(cnf.flowchart); + flowDb.clear(); + flowDb.setGen("gen-1"); + } +}; + +export { diagram }; diff --git a/libs/marked/flowDiagram-b222e15a-CZXxO4wD.js b/libs/marked/flowDiagram-b222e15a-CZXxO4wD.js new file mode 100644 index 0000000..9e86ad8 --- /dev/null +++ b/libs/marked/flowDiagram-b222e15a-CZXxO4wD.js @@ -0,0 +1,1583 @@ +import { p as parser$1, f as flowDb } from './flowDb-c1833063-C_SlfbWJ.js'; +import { h as has, f as forEach, G as Graph } from './graph-DadsyNmk.js'; +import { h as select, n as curveLinear, o as getStylesFromArray, p as evaluate, c as getConfig, r as renderKatex, j as common$1, l as log$1, q as interpolateToCurve, t as setupGraphViewbox$1 } from './index-CN3YjQ0n.js'; +import { u as uniqueId, r as range, p as pick, l as layout, d as defaults } from './layout-BOZlZI7g.js'; +import { a as applyStyle, b as addHtmlLabel, i as isSubgraph, c as applyTransition, e as edgeToId, d as applyClass, f as flowRendererV2, g as flowStyles, s as selectAll } from './styles-483fbfea-Bj8pmBPH.js'; +import { l as line } from './line-D1aCvau7.js'; +import './index-01f381cb-CDFlKdjO.js'; +import './clone-B4k62NSz.js'; +import './edges-066a5561-a6s42o55.js'; +import './createText-ca0c5216-DF05SDfj.js'; +import './channel-DcrZctv4.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +function responseText(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + return response.text(); +} + +function text(input, init) { + return fetch(input, init).then(responseText); +} + +function parser(type) { + return (input, init) => text(input, init) + .then(text => (new DOMParser).parseFromString(text, type)); +} + +var svg = parser("image/svg+xml"); + +var arrows = { + normal, + vee, + undirected, +}; + +function setArrows(value) { + arrows = value; +} + +function normal(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 0 L 10 5 L 0 10 z') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function vee(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 0 L 10 5 L 0 10 L 4 5 z') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function undirected(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 5 L 10 5') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function addSVGLabel(root, node) { + var domNode = root; + + domNode.node().appendChild(node.label); + + applyStyle(domNode, node.labelStyle); + + return domNode; +} + +/* + * Attaches a text label to the specified root. Handles escape sequences. + */ +function addTextLabel(root, node) { + var domNode = root.append('text'); + + var lines = processEscapeSequences(node.label).split('\n'); + for (var i = 0; i < lines.length; i++) { + domNode + .append('tspan') + .attr('xml:space', 'preserve') + .attr('dy', '1em') + .attr('x', '1') + .text(lines[i]); + } + + applyStyle(domNode, node.labelStyle); + + return domNode; +} + +function processEscapeSequences(text) { + var newText = ''; + var escaped = false; + var ch; + for (var i = 0; i < text.length; ++i) { + ch = text[i]; + if (escaped) { + switch (ch) { + case 'n': + newText += '\n'; + break; + default: + newText += ch; + } + escaped = false; + } else if (ch === '\\') { + escaped = true; + } else { + newText += ch; + } + } + return newText; +} + +function addLabel(root, node, location) { + var label = node.label; + var labelSvg = root.append('g'); + + // Allow the label to be a string, a function that returns a DOM element, or + // a DOM element itself. + if (node.labelType === 'svg') { + addSVGLabel(labelSvg, node); + } else if (typeof label !== 'string' || node.labelType === 'html') { + addHtmlLabel(labelSvg, node); + } else { + addTextLabel(labelSvg, node); + } + + var labelBBox = labelSvg.node().getBBox(); + var y; + switch (location) { + case 'top': + y = -node.height / 2; + break; + case 'bottom': + y = node.height / 2 - labelBBox.height; + break; + default: + y = -labelBBox.height / 2; + } + labelSvg.attr('transform', 'translate(' + -labelBBox.width / 2 + ',' + y + ')'); + + return labelSvg; +} + +var createClusters = function (selection, g) { + var clusters = g.nodes().filter(function (v) { + return isSubgraph(g, v); + }); + var svgClusters = selection.selectAll('g.cluster').data(clusters, function (v) { + return v; + }); + + applyTransition(svgClusters.exit(), g).style('opacity', 0).remove(); + + var enterSelection = svgClusters + .enter() + .append('g') + .attr('class', 'cluster') + .attr('id', function (v) { + var node = g.node(v); + return node.id; + }) + .style('opacity', 0) + .each(function (v) { + var node = g.node(v); + var thisGroup = select(this); + select(this).append('rect'); + var labelGroup = thisGroup.append('g').attr('class', 'label'); + addLabel(labelGroup, node, node.clusterLabelPos); + }); + + svgClusters = svgClusters.merge(enterSelection); + + svgClusters = applyTransition(svgClusters, g).style('opacity', 1); + + svgClusters.selectAll('rect').each(function (c) { + var node = g.node(c); + var domCluster = select(this); + applyStyle(domCluster, node.style); + }); + + return svgClusters; +}; + +function setCreateClusters(value) { + createClusters = value; +} + +let createEdgeLabels = function (selection, g) { + var svgEdgeLabels = selection + .selectAll('g.edgeLabel') + .data(g.edges(), function (e) { + return edgeToId(e); + }) + .classed('update', true); + + svgEdgeLabels.exit().remove(); + svgEdgeLabels.enter().append('g').classed('edgeLabel', true).style('opacity', 0); + + svgEdgeLabels = selection.selectAll('g.edgeLabel'); + + svgEdgeLabels.each(function (e) { + var root = select(this); + root.select('.label').remove(); + var edge = g.edge(e); + var label = addLabel(root, g.edge(e), 0).classed('label', true); + var bbox = label.node().getBBox(); + + if (edge.labelId) { + label.attr('id', edge.labelId); + } + if (!has(edge, 'width')) { + edge.width = bbox.width; + } + if (!has(edge, 'height')) { + edge.height = bbox.height; + } + }); + + var exitSelection; + + if (svgEdgeLabels.exit) { + exitSelection = svgEdgeLabels.exit(); + } else { + exitSelection = svgEdgeLabels.selectAll(null); // empty selection + } + + applyTransition(exitSelection, g).style('opacity', 0).remove(); + + return svgEdgeLabels; +}; + +function setCreateEdgeLabels(value) { + createEdgeLabels = value; +} + +function intersectNode(node, point) { + return node.intersect(point); +} + +var createEdgePaths = function (selection, g, arrows) { + var previousPaths = selection + .selectAll('g.edgePath') + .data(g.edges(), function (e) { + return edgeToId(e); + }) + .classed('update', true); + + var newPaths = enter(previousPaths, g); + exit(previousPaths, g); + + var svgPaths = previousPaths.merge !== undefined ? previousPaths.merge(newPaths) : previousPaths; + applyTransition(svgPaths, g).style('opacity', 1); + + // Save DOM element in the path group, and set ID and class + svgPaths.each(function (e) { + var domEdge = select(this); + var edge = g.edge(e); + edge.elem = this; + + if (edge.id) { + domEdge.attr('id', edge.id); + } + + applyClass( + domEdge, + edge['class'], + (domEdge.classed('update') ? 'update ' : '') + 'edgePath' + ); + }); + + svgPaths.selectAll('path.path').each(function (e) { + var edge = g.edge(e); + edge.arrowheadId = uniqueId('arrowhead'); + + var domEdge = select(this) + .attr('marker-end', function () { + return 'url(' + makeFragmentRef(location.href, edge.arrowheadId) + ')'; + }) + .style('fill', 'none'); + + applyTransition(domEdge, g).attr('d', function (e) { + return calcPoints(g, e); + }); + + applyStyle(domEdge, edge.style); + }); + + svgPaths.selectAll('defs *').remove(); + svgPaths.selectAll('defs').each(function (e) { + var edge = g.edge(e); + var arrowhead = arrows[edge.arrowhead]; + arrowhead(select(this), edge.arrowheadId, edge, 'arrowhead'); + }); + + return svgPaths; +}; + +function setCreateEdgePaths(value) { + createEdgePaths = value; +} + +function makeFragmentRef(url, fragmentId) { + var baseUrl = url.split('#')[0]; + return baseUrl + '#' + fragmentId; +} + +function calcPoints(g, e) { + var edge = g.edge(e); + var tail = g.node(e.v); + var head = g.node(e.w); + var points = edge.points.slice(1, edge.points.length - 1); + points.unshift(intersectNode(tail, points[0])); + points.push(intersectNode(head, points[points.length - 1])); + + return createLine(edge, points); +} + +function createLine(edge, points) { + // @ts-expect-error + var line$1 = (line || svg.line)() + .x(function (d) { + return d.x; + }) + .y(function (d) { + return d.y; + }); + + (line$1.curve || line$1.interpolate)(edge.curve); + + return line$1(points); +} + +function getCoords(elem) { + var bbox = elem.getBBox(); + var matrix = elem.ownerSVGElement + .getScreenCTM() + .inverse() + .multiply(elem.getScreenCTM()) + .translate(bbox.width / 2, bbox.height / 2); + return { x: matrix.e, y: matrix.f }; +} + +function enter(svgPaths, g) { + var svgPathsEnter = svgPaths.enter().append('g').attr('class', 'edgePath').style('opacity', 0); + svgPathsEnter + .append('path') + .attr('class', 'path') + .attr('d', function (e) { + var edge = g.edge(e); + var sourceElem = g.node(e.v).elem; + var points = range(edge.points.length).map(function () { + return getCoords(sourceElem); + }); + return createLine(edge, points); + }); + svgPathsEnter.append('defs'); + return svgPathsEnter; +} + +function exit(svgPaths, g) { + var svgPathExit = svgPaths.exit(); + applyTransition(svgPathExit, g).style('opacity', 0).remove(); +} + +var createNodes = function (selection, g, shapes) { + var simpleNodes = g.nodes().filter(function (v) { + return !isSubgraph(g, v); + }); + var svgNodes = selection + .selectAll('g.node') + .data(simpleNodes, function (v) { + return v; + }) + .classed('update', true); + + svgNodes.exit().remove(); + + svgNodes.enter().append('g').attr('class', 'node').style('opacity', 0); + + svgNodes = selection.selectAll('g.node'); + + svgNodes.each(function (v) { + var node = g.node(v); + var thisGroup = select(this); + applyClass( + thisGroup, + node['class'], + (thisGroup.classed('update') ? 'update ' : '') + 'node' + ); + + thisGroup.select('g.label').remove(); + var labelGroup = thisGroup.append('g').attr('class', 'label'); + var labelDom = addLabel(labelGroup, node); + var shape = shapes[node.shape]; + var bbox = pick(labelDom.node().getBBox(), 'width', 'height'); + + node.elem = this; + + if (node.id) { + thisGroup.attr('id', node.id); + } + if (node.labelId) { + labelGroup.attr('id', node.labelId); + } + + if (has(node, 'width')) { + bbox.width = node.width; + } + if (has(node, 'height')) { + bbox.height = node.height; + } + + bbox.width += node.paddingLeft + node.paddingRight; + bbox.height += node.paddingTop + node.paddingBottom; + labelGroup.attr( + 'transform', + 'translate(' + + (node.paddingLeft - node.paddingRight) / 2 + + ',' + + (node.paddingTop - node.paddingBottom) / 2 + + ')' + ); + + var root = select(this); + root.select('.label-container').remove(); + var shapeSvg = shape(root, bbox, node).classed('label-container', true); + applyStyle(shapeSvg, node.style); + + var shapeBBox = shapeSvg.node().getBBox(); + node.width = shapeBBox.width; + node.height = shapeBBox.height; + }); + + var exitSelection; + + if (svgNodes.exit) { + exitSelection = svgNodes.exit(); + } else { + exitSelection = svgNodes.selectAll(null); // empty selection + } + + applyTransition(exitSelection, g).style('opacity', 0).remove(); + + return svgNodes; +}; + +function setCreateNodes(value) { + createNodes = value; +} + +function positionClusters(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(v) { + var node = g.node(v); + return 'translate(' + node.x + ',' + node.y + ')'; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); + + applyTransition(created.selectAll('rect'), g) + .attr('width', function (v) { + return g.node(v).width; + }) + .attr('height', function (v) { + return g.node(v).height; + }) + .attr('x', function (v) { + var node = g.node(v); + return -node.width / 2; + }) + .attr('y', function (v) { + var node = g.node(v); + return -node.height / 2; + }); +} + +function positionEdgeLabels(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(e) { + var edge = g.edge(e); + return has(edge, 'x') ? 'translate(' + edge.x + ',' + edge.y + ')' : ''; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); +} + +function positionNodes(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(v) { + var node = g.node(v); + return 'translate(' + node.x + ',' + node.y + ')'; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); +} + +function intersectEllipse(node, rx, ry, point) { + // Formulae from: http://mathworld.wolfram.com/Ellipse-LineIntersection.html + + var cx = node.x; + var cy = node.y; + + var px = cx - point.x; + var py = cy - point.y; + + var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px); + + var dx = Math.abs((rx * ry * px) / det); + if (point.x < cx) { + dx = -dx; + } + var dy = Math.abs((rx * ry * py) / det); + if (point.y < cy) { + dy = -dy; + } + + return { x: cx + dx, y: cy + dy }; +} + +function intersectCircle(node, rx, point) { + return intersectEllipse(node, rx, rx, point); +} + +/* + * Returns the point at which two lines, p and q, intersect or returns + * undefined if they do not intersect. + */ +function intersectLine(p1, p2, q1, q2) { + // Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994, + // p7 and p473. + + var a1, a2, b1, b2, c1, c2; + var r1, r2, r3, r4; + var denom, offset, num; + var x, y; + + // Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x + + // b1 y + c1 = 0. + a1 = p2.y - p1.y; + b1 = p1.x - p2.x; + c1 = p2.x * p1.y - p1.x * p2.y; + + // Compute r3 and r4. + r3 = a1 * q1.x + b1 * q1.y + c1; + r4 = a1 * q2.x + b1 * q2.y + c1; + + // Check signs of r3 and r4. If both point 3 and point 4 lie on + // same side of line 1, the line segments do not intersect. + if (r3 !== 0 && r4 !== 0 && sameSign(r3, r4)) { + return /*DONT_INTERSECT*/; + } + + // Compute a2, b2, c2 where line joining points 3 and 4 is G(x,y) = a2 x + b2 y + c2 = 0 + a2 = q2.y - q1.y; + b2 = q1.x - q2.x; + c2 = q2.x * q1.y - q1.x * q2.y; + + // Compute r1 and r2 + r1 = a2 * p1.x + b2 * p1.y + c2; + r2 = a2 * p2.x + b2 * p2.y + c2; + + // Check signs of r1 and r2. If both point 1 and point 2 lie + // on same side of second line segment, the line segments do + // not intersect. + if (r1 !== 0 && r2 !== 0 && sameSign(r1, r2)) { + return /*DONT_INTERSECT*/; + } + + // Line segments intersect: compute intersection point. + denom = a1 * b2 - a2 * b1; + if (denom === 0) { + return /*COLLINEAR*/; + } + + offset = Math.abs(denom / 2); + + // The denom/2 is to get rounding instead of truncating. It + // is added or subtracted to the numerator, depending upon the + // sign of the numerator. + num = b1 * c2 - b2 * c1; + x = num < 0 ? (num - offset) / denom : (num + offset) / denom; + + num = a2 * c1 - a1 * c2; + y = num < 0 ? (num - offset) / denom : (num + offset) / denom; + + return { x: x, y: y }; +} + +function sameSign(r1, r2) { + return r1 * r2 > 0; +} + +/* + * Returns the point ({x, y}) at which the point argument intersects with the + * node argument assuming that it has the shape specified by polygon. + */ +function intersectPolygon(node, polyPoints, point) { + var x1 = node.x; + var y1 = node.y; + + var intersections = []; + + var minX = Number.POSITIVE_INFINITY; + var minY = Number.POSITIVE_INFINITY; + polyPoints.forEach(function (entry) { + minX = Math.min(minX, entry.x); + minY = Math.min(minY, entry.y); + }); + + var left = x1 - node.width / 2 - minX; + var top = y1 - node.height / 2 - minY; + + for (var i = 0; i < polyPoints.length; i++) { + var p1 = polyPoints[i]; + var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0]; + var intersect = intersectLine( + node, + point, + { x: left + p1.x, y: top + p1.y }, + { x: left + p2.x, y: top + p2.y } + ); + if (intersect) { + intersections.push(intersect); + } + } + + if (!intersections.length) { + console.log('NO INTERSECTION FOUND, RETURN NODE CENTER', node); + return node; + } + + if (intersections.length > 1) { + // More intersections, find the one nearest to edge end point + intersections.sort(function (p, q) { + var pdx = p.x - point.x; + var pdy = p.y - point.y; + var distp = Math.sqrt(pdx * pdx + pdy * pdy); + + var qdx = q.x - point.x; + var qdy = q.y - point.y; + var distq = Math.sqrt(qdx * qdx + qdy * qdy); + + return distp < distq ? -1 : distp === distq ? 0 : 1; + }); + } + return intersections[0]; +} + +function intersectRect(node, point) { + var x = node.x; + var y = node.y; + + // Rectangle intersection algorithm from: + // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes + var dx = point.x - x; + var dy = point.y - y; + var w = node.width / 2; + var h = node.height / 2; + + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + // Intersection is top or bottom of rect. + if (dy < 0) { + h = -h; + } + sx = dy === 0 ? 0 : (h * dx) / dy; + sy = h; + } else { + // Intersection is left or right of rect. + if (dx < 0) { + w = -w; + } + sx = w; + sy = dx === 0 ? 0 : (w * dy) / dx; + } + + return { x: x + sx, y: y + sy }; +} + +var shapes = { + rect, + ellipse, + circle, + diamond, +}; + +function setShapes(value) { + shapes = value; +} + +function rect(parent, bbox, node) { + var shapeSvg = parent + .insert('rect', ':first-child') + .attr('rx', node.rx) + .attr('ry', node.ry) + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('width', bbox.width) + .attr('height', bbox.height); + + node.intersect = function (point) { + return intersectRect(node, point); + }; + + return shapeSvg; +} + +function ellipse(parent, bbox, node) { + var rx = bbox.width / 2; + var ry = bbox.height / 2; + var shapeSvg = parent + .insert('ellipse', ':first-child') + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('rx', rx) + .attr('ry', ry); + + node.intersect = function (point) { + return intersectEllipse(node, rx, ry, point); + }; + + return shapeSvg; +} + +function circle(parent, bbox, node) { + var r = Math.max(bbox.width, bbox.height) / 2; + var shapeSvg = parent + .insert('circle', ':first-child') + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('r', r); + + node.intersect = function (point) { + return intersectCircle(node, r, point); + }; + + return shapeSvg; +} + +// Circumscribe an ellipse for the bounding box with a diamond shape. I derived +// the function to calculate the diamond shape from: +// http://mathforum.org/kb/message.jspa?messageID=3750236 +function diamond(parent, bbox, node) { + var w = (bbox.width * Math.SQRT2) / 2; + var h = (bbox.height * Math.SQRT2) / 2; + var points = [ + { x: 0, y: -h }, + { x: -w, y: 0 }, + { x: 0, y: h }, + { x: w, y: 0 }, + ]; + var shapeSvg = parent.insert('polygon', ':first-child').attr( + 'points', + points + .map(function (p) { + return p.x + ',' + p.y; + }) + .join(' ') + ); + + node.intersect = function (p) { + return intersectPolygon(node, points, p); + }; + + return shapeSvg; +} + +// This design is based on http://bost.ocks.org/mike/chart/. +function render() { + var fn = function (svg, g) { + preProcessGraph(g); + + var outputGroup = createOrSelectGroup(svg, 'output'); + var clustersGroup = createOrSelectGroup(outputGroup, 'clusters'); + var edgePathsGroup = createOrSelectGroup(outputGroup, 'edgePaths'); + var edgeLabels = createEdgeLabels(createOrSelectGroup(outputGroup, 'edgeLabels'), g); + var nodes = createNodes(createOrSelectGroup(outputGroup, 'nodes'), g, shapes); + + layout(g); + + positionNodes(nodes, g); + positionEdgeLabels(edgeLabels, g); + createEdgePaths(edgePathsGroup, g, arrows); + + var clusters = createClusters(clustersGroup, g); + positionClusters(clusters, g); + + postProcessGraph(g); + }; + + fn.createNodes = function (value) { + if (!arguments.length) return createNodes; + setCreateNodes(value); + return fn; + }; + + fn.createClusters = function (value) { + if (!arguments.length) return createClusters; + setCreateClusters(value); + return fn; + }; + + fn.createEdgeLabels = function (value) { + if (!arguments.length) return createEdgeLabels; + setCreateEdgeLabels(value); + return fn; + }; + + fn.createEdgePaths = function (value) { + if (!arguments.length) return createEdgePaths; + setCreateEdgePaths(value); + return fn; + }; + + fn.shapes = function (value) { + if (!arguments.length) return shapes; + setShapes(value); + return fn; + }; + + fn.arrows = function (value) { + if (!arguments.length) return arrows; + setArrows(value); + return fn; + }; + + return fn; +} + +var NODE_DEFAULT_ATTRS = { + paddingLeft: 10, + paddingRight: 10, + paddingTop: 10, + paddingBottom: 10, + rx: 0, + ry: 0, + shape: 'rect', +}; + +var EDGE_DEFAULT_ATTRS = { + arrowhead: 'normal', + curve: curveLinear, +}; + +function preProcessGraph(g) { + g.nodes().forEach(function (v) { + var node = g.node(v); + if (!has(node, 'label') && !g.children(v).length) { + node.label = v; + } + + if (has(node, 'paddingX')) { + defaults(node, { + paddingLeft: node.paddingX, + paddingRight: node.paddingX, + }); + } + + if (has(node, 'paddingY')) { + defaults(node, { + paddingTop: node.paddingY, + paddingBottom: node.paddingY, + }); + } + + if (has(node, 'padding')) { + defaults(node, { + paddingLeft: node.padding, + paddingRight: node.padding, + paddingTop: node.padding, + paddingBottom: node.padding, + }); + } + + defaults(node, NODE_DEFAULT_ATTRS); + + forEach(['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'], function (k) { + node[k] = Number(node[k]); + }); + + // Save dimensions for restore during post-processing + if (has(node, 'width')) { + node._prevWidth = node.width; + } + if (has(node, 'height')) { + node._prevHeight = node.height; + } + }); + + g.edges().forEach(function (e) { + var edge = g.edge(e); + if (!has(edge, 'label')) { + edge.label = ''; + } + defaults(edge, EDGE_DEFAULT_ATTRS); + }); +} + +function postProcessGraph(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + + // Restore original dimensions + if (has(node, '_prevWidth')) { + node.width = node._prevWidth; + } else { + delete node.width; + } + + if (has(node, '_prevHeight')) { + node.height = node._prevHeight; + } else { + delete node.height; + } + + delete node._prevWidth; + delete node._prevHeight; + }); +} + +function createOrSelectGroup(root, name) { + var selection = root.select('g.' + name); + if (selection.empty()) { + selection = root.append('g').attr('class', name); + } + return selection; +} + +function question(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const s = (w + h) * 0.9; + const points = [ + { x: s / 2, y: 0 }, + { x: s, y: -s / 2 }, + { x: s / 2, y: -s }, + { x: 0, y: -s / 2 } + ]; + const shapeSvg = insertPolygonShape(parent, s, s, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function hexagon(parent, bbox, node) { + const f = 4; + const h = bbox.height; + const m = h / f; + const w = bbox.width + 2 * m; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function rect_left_inv_arrow(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -h / 2, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: -h / 2, y: -h }, + { x: 0, y: -h / 2 } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function lean_right(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function lean_left(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 2 * h / 6, y: 0 }, + { x: w + h / 6, y: 0 }, + { x: w - 2 * h / 6, y: -h }, + { x: -h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function trapezoid(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w + 2 * h / 6, y: 0 }, + { x: w - h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function inv_trapezoid(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: -2 * h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function rect_right_inv_arrow(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 0, y: 0 }, + { x: w + h / 2, y: 0 }, + { x: w, y: -h / 2 }, + { x: w + h / 2, y: -h }, + { x: 0, y: -h } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function stadium(parent, bbox, node) { + const h = bbox.height; + const w = bbox.width + h / 4; + const shapeSvg = parent.insert("rect", ":first-child").attr("rx", h / 2).attr("ry", h / 2).attr("x", -w / 2).attr("y", -h / 2).attr("width", w).attr("height", h); + node.intersect = function(point) { + return intersectRect(node, point); + }; + return shapeSvg; +} +function subroutine(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 0, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: 0, y: -h }, + { x: 0, y: 0 }, + { x: -8, y: 0 }, + { x: w + 8, y: 0 }, + { x: w + 8, y: -h }, + { x: -8, y: -h }, + { x: -8, y: 0 } + ]; + const shapeSvg = insertPolygonShape(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon(node, points, point); + }; + return shapeSvg; +} +function cylinder(parent, bbox, node) { + const w = bbox.width; + const rx = w / 2; + const ry = rx / (2.5 + w / 50); + const h = bbox.height + ry; + const shape = "M 0," + ry + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 a " + rx + "," + ry + " 0,0,0 " + -w + " 0 l 0," + h + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 l 0," + -h; + const shapeSvg = parent.attr("label-offset-y", ry).insert("path", ":first-child").attr("d", shape).attr("transform", "translate(" + -w / 2 + "," + -(h / 2 + ry) + ")"); + node.intersect = function(point) { + const pos = intersectRect(node, point); + const x = pos.x - node.x; + if (rx != 0 && (Math.abs(x) < node.width / 2 || Math.abs(x) == node.width / 2 && Math.abs(pos.y - node.y) > node.height / 2 - ry)) { + let y = ry * ry * (1 - x * x / (rx * rx)); + if (y != 0) { + y = Math.sqrt(y); + } + y = ry - y; + if (point.y - node.y > 0) { + y = -y; + } + pos.y += y; + } + return pos; + }; + return shapeSvg; +} +function addToRender(render2) { + render2.shapes().question = question; + render2.shapes().hexagon = hexagon; + render2.shapes().stadium = stadium; + render2.shapes().subroutine = subroutine; + render2.shapes().cylinder = cylinder; + render2.shapes().rect_left_inv_arrow = rect_left_inv_arrow; + render2.shapes().lean_right = lean_right; + render2.shapes().lean_left = lean_left; + render2.shapes().trapezoid = trapezoid; + render2.shapes().inv_trapezoid = inv_trapezoid; + render2.shapes().rect_right_inv_arrow = rect_right_inv_arrow; +} +function addToRenderV2(addShape) { + addShape({ question }); + addShape({ hexagon }); + addShape({ stadium }); + addShape({ subroutine }); + addShape({ cylinder }); + addShape({ rect_left_inv_arrow }); + addShape({ lean_right }); + addShape({ lean_left }); + addShape({ trapezoid }); + addShape({ inv_trapezoid }); + addShape({ rect_right_inv_arrow }); +} +function insertPolygonShape(parent, w, h, points) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("transform", "translate(" + -w / 2 + "," + h / 2 + ")"); +} +const flowChartShapes = { + addToRender, + addToRenderV2 +}; +const conf = {}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf[key] = cnf[key]; + } +}; +const addVertices = async function(vert, g, svgId, root, _doc, diagObj) { + const svg = !root ? select(`[id="${svgId}"]`) : root.select(`[id="${svgId}"]`); + const doc = !_doc ? document : _doc; + const keys = Object.keys(vert); + for (const id of keys) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + const styles = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + let vertexNode; + if (evaluate(getConfig().flowchart.htmlLabels)) { + const node = { + label: await renderKatex( + vertexText.replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell:disable-line + (s) => `` + ), + getConfig() + ) + }; + vertexNode = addHtmlLabel(svg, node).node(); + vertexNode.parentNode.removeChild(vertexNode); + } else { + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", styles.labelStyle.replace("color:", "fill:")); + const rows = vertexText.split(common$1.lineBreakRegex); + for (const row of rows) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "1"); + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + vertexNode = svgLabel; + } + let radius = 0; + let _shape = ""; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + default: + _shape = "rect"; + } + log$1.warn("Adding node", vertex.id, vertex.domId); + g.setNode(diagObj.db.lookUpDomId(vertex.id), { + labelType: "svg", + labelStyle: styles.labelStyle, + shape: _shape, + label: vertexNode, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: diagObj.db.lookUpDomId(vertex.id) + }); + } +}; +const addEdges = async function(edges, g, diagObj) { + let cnt = 0; + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + for (const edge of edges) { + cnt++; + const linkId = "L-" + edge.start + "-" + edge.end; + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = {}; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + let style = ""; + let labelStyle = ""; + if (edge.style !== void 0) { + const styles = getStylesFromArray(edge.style); + style = styles.style; + labelStyle = styles.labelStyle; + } else { + switch (edge.stroke) { + case "normal": + style = "fill:none"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + break; + case "dotted": + style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + style = " stroke-width: 3.5px;fill:none"; + break; + } + } + edgeData.style = style; + edgeData.labelStyle = labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + if (evaluate(getConfig().flowchart.htmlLabels)) { + edgeData.labelType = "html"; + edgeData.label = `${await renderKatex( + edge.text.replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell:disable-line + (s) => `` + ), + getConfig() + )}`; + } else { + edgeData.labelType = "text"; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + } + } + edgeData.id = linkId; + edgeData.class = linkNameStart + " " + linkNameEnd; + edgeData.minlen = edge.length || 1; + g.setEdge(diagObj.db.lookUpDomId(edge.start), diagObj.db.lookUpDomId(edge.end), edgeData, cnt); + } +}; +const getClasses = function(text, diagObj) { + log$1.info("Extracting classes"); + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + log$1.info("Drawing flowchart"); + const { securityLevel, flowchart: conf2 } = getConfig(); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + let dir = diagObj.db.getDirection(); + if (dir === void 0) { + dir = "TD"; + } + const nodeSpacing = conf2.nodeSpacing || 50; + const rankSpacing = conf2.rankSpacing || 50; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + for (let i2 = subGraphs.length - 1; i2 >= 0; i2--) { + subG = subGraphs[i2]; + diagObj.db.addVertex(subG.id, subG.title, "group", void 0, subG.classes); + } + const vert = diagObj.db.getVertices(); + log$1.warn("Get vertices", vert); + const edges = diagObj.db.getEdges(); + let i = 0; + for (i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + selectAll("cluster").append("text"); + for (let j = 0; j < subG.nodes.length; j++) { + log$1.warn( + "Setting subgraph", + subG.nodes[j], + diagObj.db.lookUpDomId(subG.nodes[j]), + diagObj.db.lookUpDomId(subG.id) + ); + g.setParent(diagObj.db.lookUpDomId(subG.nodes[j]), diagObj.db.lookUpDomId(subG.id)); + } + } + await addVertices(vert, g, id, root, doc, diagObj); + await addEdges(edges, g, diagObj); + const render$1 = new render(); + flowChartShapes.addToRender(render$1); + render$1.arrows().none = function normal(parent, id2, edge, type) { + const marker = parent.append("marker").attr("id", id2).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 6).attr("orient", "auto"); + const path = marker.append("path").attr("d", "M 0 0 L 0 0 L 0 0 z"); + applyStyle(path, edge[type + "Style"]); + }; + render$1.arrows().normal = function normal(parent, id2) { + const marker = parent.append("marker").attr("id", id2).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 6).attr("orient", "auto"); + marker.append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("class", "arrowheadPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + }; + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + render$1(element, g); + element.selectAll("g.node").attr("title", function() { + return diagObj.db.getTooltip(this.id); + }); + diagObj.db.indexNodes("subGraph" + i); + for (i = 0; i < subGraphs.length; i++) { + subG = subGraphs[i]; + if (subG.title !== "undefined") { + const clusterRects = doc.querySelectorAll( + "#" + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"] rect' + ); + const clusterEl = doc.querySelectorAll( + "#" + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"]' + ); + const xPos = clusterRects[0].x.baseVal.value; + const yPos = clusterRects[0].y.baseVal.value; + const _width = clusterRects[0].width.baseVal.value; + const cluster = select(clusterEl[0]); + const te = cluster.select(".label"); + te.attr("transform", `translate(${xPos + _width / 2}, ${yPos + 14})`); + te.attr("id", id + "Text"); + for (let j = 0; j < subG.classes.length; j++) { + clusterEl[0].classList.add(subG.classes[j]); + } + } + } + if (!conf2.htmlLabels) { + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } + setupGraphViewbox$1(g, svg, conf2.diagramPadding, conf2.useMaxWidth); + const keys = Object.keys(vert); + keys.forEach(function(key) { + const vertex = vert[key]; + if (vertex.link) { + const node = root.select("#" + id + ' [id="' + diagObj.db.lookUpDomId(key) + '"]'); + if (node) { + const link = doc.createElementNS("http://www.w3.org/2000/svg", "a"); + link.setAttributeNS("http://www.w3.org/2000/svg", "class", vertex.classes.join(" ")); + link.setAttributeNS("http://www.w3.org/2000/svg", "href", vertex.link); + link.setAttributeNS("http://www.w3.org/2000/svg", "rel", "noopener"); + if (securityLevel === "sandbox") { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", "_top"); + } else if (vertex.linkTarget) { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", vertex.linkTarget); + } + const linkNode = node.insert(function() { + return link; + }, ":first-child"); + const shape = node.select(".label-container"); + if (shape) { + linkNode.append(function() { + return shape.node(); + }); + } + const label = node.select(".label"); + if (label) { + linkNode.append(function() { + return label.node(); + }); + } + } + } + }); +}; +const flowRenderer = { + setConf, + addVertices, + addEdges, + getClasses, + draw +}; +const diagram = { + parser: parser$1, + db: flowDb, + renderer: flowRendererV2, + styles: flowStyles, + init: (cnf) => { + if (!cnf.flowchart) { + cnf.flowchart = {}; + } + cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + flowRenderer.setConf(cnf.flowchart); + flowDb.clear(); + flowDb.setGen("gen-1"); + } +}; + +export { diagram }; diff --git a/libs/marked/flowDiagram-v2-13329dc7-BhMMoQnO.js b/libs/marked/flowDiagram-v2-13329dc7-BhMMoQnO.js new file mode 100644 index 0000000..dc6a1d4 --- /dev/null +++ b/libs/marked/flowDiagram-v2-13329dc7-BhMMoQnO.js @@ -0,0 +1,32 @@ +import { p as parser$1, f as flowDb } from './flowDb-c1833063-Df5kDQr4.js'; +import { f as flowRendererV2, g as flowStyles } from './styles-483fbfea-DDPjh658.js'; +import { u as setConfig } from './index-Bd_FDXSq.js'; +import './graph-KZW2Npeo.js'; +import './layout-BnytXFfq.js'; +import './index-01f381cb-BCBEZMaa.js'; +import './clone-B-QllgkM.js'; +import './edges-066a5561-Bqw9g7uz.js'; +import './createText-ca0c5216-B9KlDTE8.js'; +import './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; +import './channel-BxFDB0yY.js'; + +const diagram = { + parser: parser$1, + db: flowDb, + renderer: flowRendererV2, + styles: flowStyles, + init: (cnf) => { + if (!cnf.flowchart) { + cnf.flowchart = {}; + } + cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } }); + flowRendererV2.setConf(cnf.flowchart); + flowDb.clear(); + flowDb.setGen("gen-2"); + } +}; + +export { diagram }; diff --git a/libs/marked/flowDiagram-v2-13329dc7-BmGiwYxl.js b/libs/marked/flowDiagram-v2-13329dc7-BmGiwYxl.js new file mode 100644 index 0000000..4de0c4d --- /dev/null +++ b/libs/marked/flowDiagram-v2-13329dc7-BmGiwYxl.js @@ -0,0 +1,32 @@ +import { p as parser$1, f as flowDb } from './flowDb-c1833063-C_SlfbWJ.js'; +import { f as flowRendererV2, g as flowStyles } from './styles-483fbfea-Bj8pmBPH.js'; +import { u as setConfig } from './index-CN3YjQ0n.js'; +import './graph-DadsyNmk.js'; +import './layout-BOZlZI7g.js'; +import './index-01f381cb-CDFlKdjO.js'; +import './clone-B4k62NSz.js'; +import './edges-066a5561-a6s42o55.js'; +import './createText-ca0c5216-DF05SDfj.js'; +import './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; +import './channel-DcrZctv4.js'; + +const diagram = { + parser: parser$1, + db: flowDb, + renderer: flowRendererV2, + styles: flowStyles, + init: (cnf) => { + if (!cnf.flowchart) { + cnf.flowchart = {}; + } + cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } }); + flowRendererV2.setConf(cnf.flowchart); + flowDb.clear(); + flowDb.setGen("gen-2"); + } +}; + +export { diagram }; diff --git a/libs/marked/flowchart-elk-definition-ae0efee6-BGp9zXvL.js b/libs/marked/flowchart-elk-definition-ae0efee6-BGp9zXvL.js new file mode 100644 index 0000000..fb7feca --- /dev/null +++ b/libs/marked/flowchart-elk-definition-ae0efee6-BGp9zXvL.js @@ -0,0 +1,7505 @@ +import { d as db, p as parser$1 } from './flowDb-c1833063-C_SlfbWJ.js'; +import { P as commonjsGlobal, Q as getDefaultExportFromCjs, l as log$1, h as select, _ as getConfig$1, t as setupGraphViewbox$1, o as getStylesFromArray, q as interpolateToCurve, n as curveLinear, j as common$1 } from './index-CN3YjQ0n.js'; +import { i as insertMarkers$1, a as insertNode, l as labelHelper, b as insertEdgeLabel, k as getLineFunctionsWithOffset, m as addEdgeMarkers } from './edges-066a5561-a6s42o55.js'; +import { l as line } from './line-D1aCvau7.js'; +import './createText-ca0c5216-DF05SDfj.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var elk_bundled = {exports: {}}; + +(function (module, exports) { + (function(f){{module.exports=f();}})(function(){return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof commonjsRequire&&commonjsRequire;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t);}return n[i].exports}for(var u="function"==typeof commonjsRequire&&commonjsRequire,i=0;i 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$defaultLayoutOpt = _ref.defaultLayoutOptions, + defaultLayoutOptions = _ref$defaultLayoutOpt === undefined ? {} : _ref$defaultLayoutOpt, + _ref$algorithms = _ref.algorithms, + algorithms = _ref$algorithms === undefined ? ['layered', 'stress', 'mrtree', 'radial', 'force', 'disco', 'sporeOverlap', 'sporeCompaction', 'rectpacking'] : _ref$algorithms, + workerFactory = _ref.workerFactory, + workerUrl = _ref.workerUrl; + + _classCallCheck(this, ELK); + + this.defaultLayoutOptions = defaultLayoutOptions; + this.initialized = false; + + // check valid worker construction possible + if (typeof workerUrl === 'undefined' && typeof workerFactory === 'undefined') { + throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'."); + } + var factory = workerFactory; + if (typeof workerUrl !== 'undefined' && typeof workerFactory === 'undefined') { + // use default Web Worker + factory = function factory(url) { + return new Worker(url); + }; + } + + // create the worker + var worker = factory(workerUrl); + if (typeof worker.postMessage !== 'function') { + throw new TypeError("Created worker does not provide" + " the required 'postMessage' function."); + } + + // wrap the worker to return promises + this.worker = new PromisedWorker(worker); + + // initially register algorithms + this.worker.postMessage({ + cmd: 'register', + algorithms: algorithms + }).then(function (r) { + return _this.initialized = true; + }).catch(console.err); + } + + _createClass(ELK, [{ + key: 'layout', + value: function layout(graph) { + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$layoutOptions = _ref2.layoutOptions, + layoutOptions = _ref2$layoutOptions === undefined ? this.defaultLayoutOptions : _ref2$layoutOptions, + _ref2$logging = _ref2.logging, + logging = _ref2$logging === undefined ? false : _ref2$logging, + _ref2$measureExecutio = _ref2.measureExecutionTime, + measureExecutionTime = _ref2$measureExecutio === undefined ? false : _ref2$measureExecutio; + + if (!graph) { + return Promise.reject(new Error("Missing mandatory parameter 'graph'.")); + } + return this.worker.postMessage({ + cmd: 'layout', + graph: graph, + layoutOptions: layoutOptions, + options: { + logging: logging, + measureExecutionTime: measureExecutionTime + } + }); + } + }, { + key: 'knownLayoutAlgorithms', + value: function knownLayoutAlgorithms() { + return this.worker.postMessage({ cmd: 'algorithms' }); + } + }, { + key: 'knownLayoutOptions', + value: function knownLayoutOptions() { + return this.worker.postMessage({ cmd: 'options' }); + } + }, { + key: 'knownLayoutCategories', + value: function knownLayoutCategories() { + return this.worker.postMessage({ cmd: 'categories' }); + } + }, { + key: 'terminateWorker', + value: function terminateWorker() { + if (this.worker) this.worker.terminate(); + } + }]); + + return ELK; + }(); + + exports.default = ELK; + + var PromisedWorker = function () { + function PromisedWorker(worker) { + var _this2 = this; + + _classCallCheck(this, PromisedWorker); + + if (worker === undefined) { + throw new Error("Missing mandatory parameter 'worker'."); + } + this.resolvers = {}; + this.worker = worker; + this.worker.onmessage = function (answer) { + // why is this necessary? + setTimeout(function () { + _this2.receive(_this2, answer); + }, 0); + }; + } + + _createClass(PromisedWorker, [{ + key: 'postMessage', + value: function postMessage(msg) { + var id = this.id || 0; + this.id = id + 1; + msg.id = id; + var self = this; + return new Promise(function (resolve, reject) { + // prepare the resolver + self.resolvers[id] = function (err, res) { + if (err) { + self.convertGwtStyleError(err); + reject(err); + } else { + resolve(res); + } + }; + // post the message + self.worker.postMessage(msg); + }); + } + }, { + key: 'receive', + value: function receive(self, answer) { + var json = answer.data; + var resolver = self.resolvers[json.id]; + if (resolver) { + delete self.resolvers[json.id]; + if (json.error) { + resolver(json.error); + } else { + resolver(null, json.data); + } + } + } + }, { + key: 'terminate', + value: function terminate() { + if (this.worker) { + this.worker.terminate(); + } + } + }, { + key: 'convertGwtStyleError', + value: function convertGwtStyleError(err) { + if (!err) { + return; + } + // Somewhat flatten the way GWT stores nested exception(s) + var javaException = err['__java$exception']; + if (javaException) { + // Note that the property name of the nested exception is different + // in the non-minified ('cause') and the minified (not deterministic) version. + // Hence, the version below only works for the non-minified version. + // However, as the minified stack trace is not of much use anyway, one + // should switch the used version for debugging in such a case. + if (javaException.cause && javaException.cause.backingJsObject) { + err.cause = javaException.cause.backingJsObject; + this.convertGwtStyleError(err.cause); + } + delete err['__java$exception']; + } + } + }]); + + return PromisedWorker; + }(); + },{}],2:[function(require,module,exports){ + (function (global){(function (){ + + // -------------- FAKE ELEMENTS GWT ASSUMES EXIST -------------- + var $wnd; + if (typeof window !== 'undefined') + $wnd = window; + else if (typeof global !== 'undefined') + $wnd = global; // nodejs + else if (typeof self !== 'undefined') + $wnd = self; // web worker + + // -------------- WORKAROUND STRICT MODE, SEE #127 -------------- + var o; + + // -------------- GENERATED CODE -------------- + function nb(){} + function xb(){} + function Fd(){} + function hh(){} + function lq(){} + function Nq(){} + function ir(){} + function Ws(){} + function Zw(){} + function jx(){} + function rx(){} + function sx(){} + function My(){} + function bA(){} + function mA(){} + function tA(){} + function aB(){} + function dB(){} + function jB(){} + function dC(){} + function keb(){} + function geb(){} + function oeb(){} + function iob(){} + function Job(){} + function Rob(){} + function apb(){} + function ipb(){} + function nrb(){} + function wrb(){} + function Brb(){} + function Prb(){} + function ltb(){} + function svb(){} + function xvb(){} + function zvb(){} + function $xb(){} + function Gzb(){} + function NAb(){} + function VAb(){} + function rBb(){} + function RBb(){} + function TBb(){} + function XBb(){} + function ZBb(){} + function _Bb(){} + function bCb(){} + function dCb(){} + function fCb(){} + function jCb(){} + function rCb(){} + function uCb(){} + function wCb(){} + function yCb(){} + function ACb(){} + function ECb(){} + function FEb(){} + function IEb(){} + function KEb(){} + function MEb(){} + function gFb(){} + function FFb(){} + function JFb(){} + function xGb(){} + function AGb(){} + function YGb(){} + function oHb(){} + function tHb(){} + function xHb(){} + function pIb(){} + function BJb(){} + function kLb(){} + function mLb(){} + function oLb(){} + function qLb(){} + function FLb(){} + function JLb(){} + function KMb(){} + function MMb(){} + function OMb(){} + function YMb(){} + function MNb(){} + function ONb(){} + function aOb(){} + function eOb(){} + function xOb(){} + function BOb(){} + function DOb(){} + function FOb(){} + function IOb(){} + function MOb(){} + function POb(){} + function UOb(){} + function ZOb(){} + function cPb(){} + function gPb(){} + function nPb(){} + function qPb(){} + function tPb(){} + function wPb(){} + function CPb(){} + function qQb(){} + function GQb(){} + function bRb(){} + function gRb(){} + function kRb(){} + function pRb(){} + function wRb(){} + function xSb(){} + function TSb(){} + function VSb(){} + function XSb(){} + function ZSb(){} + function _Sb(){} + function tTb(){} + function DTb(){} + function FTb(){} + function FXb(){} + function hXb(){} + function hWb(){} + function mWb(){} + function CVb(){} + function XXb(){} + function $Xb(){} + function bYb(){} + function lYb(){} + function FYb(){} + function XYb(){} + function aZb(){} + function SZb(){} + function ZZb(){} + function Z_b(){} + function j_b(){} + function j$b(){} + function b$b(){} + function f$b(){} + function n$b(){} + function K_b(){} + function V_b(){} + function b0b(){} + function l0b(){} + function X1b(){} + function _1b(){} + function x3b(){} + function r4b(){} + function w4b(){} + function A4b(){} + function E4b(){} + function I4b(){} + function M4b(){} + function o5b(){} + function q5b(){} + function w5b(){} + function A5b(){} + function E5b(){} + function h6b(){} + function j6b(){} + function l6b(){} + function q6b(){} + function v6b(){} + function y6b(){} + function G6b(){} + function K6b(){} + function N6b(){} + function P6b(){} + function R6b(){} + function b7b(){} + function f7b(){} + function j7b(){} + function n7b(){} + function C7b(){} + function H7b(){} + function J7b(){} + function L7b(){} + function N7b(){} + function P7b(){} + function a8b(){} + function c8b(){} + function e8b(){} + function g8b(){} + function i8b(){} + function m8b(){} + function Z8b(){} + function f9b(){} + function i9b(){} + function o9b(){} + function C9b(){} + function F9b(){} + function K9b(){} + function Q9b(){} + function aac(){} + function bac(){} + function eac(){} + function mac(){} + function pac(){} + function rac(){} + function tac(){} + function xac(){} + function Aac(){} + function Dac(){} + function Iac(){} + function Oac(){} + function Uac(){} + function Ucc(){} + function scc(){} + function ycc(){} + function Acc(){} + function Ccc(){} + function Ncc(){} + function Wcc(){} + function ydc(){} + function Adc(){} + function Gdc(){} + function Ldc(){} + function Zdc(){} + function fec(){} + function Dec(){} + function Gec(){} + function Kec(){} + function efc(){} + function jfc(){} + function nfc(){} + function Bfc(){} + function Ifc(){} + function Lfc(){} + function Rfc(){} + function Ufc(){} + function Zfc(){} + function cgc(){} + function egc(){} + function ggc(){} + function igc(){} + function kgc(){} + function Dgc(){} + function Hgc(){} + function Lgc(){} + function Ngc(){} + function Pgc(){} + function Vgc(){} + function Ygc(){} + function chc(){} + function ehc(){} + function ghc(){} + function ihc(){} + function mhc(){} + function rhc(){} + function uhc(){} + function whc(){} + function yhc(){} + function Ahc(){} + function Chc(){} + function Ghc(){} + function Nhc(){} + function Phc(){} + function Rhc(){} + function Thc(){} + function $hc(){} + function aic(){} + function cic(){} + function eic(){} + function jic(){} + function nic(){} + function pic(){} + function ric(){} + function vic(){} + function yic(){} + function Dic(){} + function Ric(){} + function Zic(){} + function bjc(){} + function djc(){} + function jjc(){} + function njc(){} + function rjc(){} + function tjc(){} + function zjc(){} + function Djc(){} + function Fjc(){} + function Ljc(){} + function Pjc(){} + function Rjc(){} + function fkc(){} + function Kkc(){} + function Mkc(){} + function Okc(){} + function Qkc(){} + function Skc(){} + function Ukc(){} + function Wkc(){} + function clc(){} + function elc(){} + function klc(){} + function mlc(){} + function olc(){} + function qlc(){} + function wlc(){} + function ylc(){} + function Alc(){} + function Jlc(){} + function Joc(){} + function poc(){} + function roc(){} + function toc(){} + function voc(){} + function Boc(){} + function Foc(){} + function Hoc(){} + function Loc(){} + function Noc(){} + function Poc(){} + function qnc(){} + function unc(){} + function upc(){} + function kpc(){} + function mpc(){} + function opc(){} + function qpc(){} + function ypc(){} + function Cpc(){} + function Mpc(){} + function Qpc(){} + function dqc(){} + function jqc(){} + function Aqc(){} + function Eqc(){} + function Gqc(){} + function Sqc(){} + function arc(){} + function lrc(){} + function zrc(){} + function Hrc(){} + function bsc(){} + function dsc(){} + function fsc(){} + function ksc(){} + function msc(){} + function Asc(){} + function Csc(){} + function Esc(){} + function Ksc(){} + function Nsc(){} + function Ssc(){} + function CCc(){} + function tGc(){} + function aHc(){} + function gHc(){} + function nIc(){} + function PJc(){} + function XKc(){} + function fLc(){} + function hLc(){} + function lLc(){} + function eNc(){} + function IOc(){} + function MOc(){} + function WOc(){} + function YOc(){} + function $Oc(){} + function cPc(){} + function iPc(){} + function mPc(){} + function oPc(){} + function qPc(){} + function sPc(){} + function wPc(){} + function APc(){} + function FPc(){} + function HPc(){} + function NPc(){} + function PPc(){} + function TPc(){} + function VPc(){} + function ZPc(){} + function _Pc(){} + function bQc(){} + function dQc(){} + function SQc(){} + function hRc(){} + function HRc(){} + function HSc(){} + function pSc(){} + function xSc(){} + function zSc(){} + function BSc(){} + function DSc(){} + function FSc(){} + function CTc(){} + function ITc(){} + function KTc(){} + function MTc(){} + function XTc(){} + function ZTc(){} + function jVc(){} + function lVc(){} + function zVc(){} + function IVc(){} + function KVc(){} + function KWc(){} + function uWc(){} + function xWc(){} + function AWc(){} + function QWc(){} + function UWc(){} + function qXc(){} + function KXc(){} + function OXc(){} + function SXc(){} + function $Xc(){} + function mYc(){} + function rYc(){} + function zYc(){} + function DYc(){} + function FYc(){} + function HYc(){} + function JYc(){} + function cZc(){} + function gZc(){} + function iZc(){} + function pZc(){} + function tZc(){} + function vZc(){} + function AZc(){} + function GZc(){} + function l_c(){} + function l1c(){} + function b1c(){} + function d1c(){} + function h1c(){} + function n1c(){} + function r1c(){} + function v1c(){} + function x1c(){} + function D1c(){} + function H1c(){} + function L1c(){} + function R1c(){} + function V1c(){} + function Z1c(){} + function Z0c(){} + function a0c(){} + function c0c(){} + function e0c(){} + function k0c(){} + function o0c(){} + function b2c(){} + function l2c(){} + function p2c(){} + function Y2c(){} + function _2c(){} + function A3c(){} + function F3c(){} + function I3c(){} + function K3c(){} + function M3c(){} + function Q3c(){} + function U3c(){} + function c5c(){} + function D5c(){} + function G5c(){} + function J5c(){} + function N5c(){} + function V5c(){} + function p6c(){} + function s6c(){} + function H6c(){} + function K6c(){} + function _7c(){} + function h8c(){} + function j8c(){} + function o8c(){} + function r8c(){} + function u8c(){} + function R8c(){} + function X8c(){} + function o9c(){} + function s9c(){} + function x9c(){} + function Qad(){} + function rcd(){} + function Xcd(){} + function vdd(){} + function Tdd(){} + function _dd(){} + function qed(){} + function sed(){} + function ved(){} + function Hed(){} + function Zed(){} + function bfd(){} + function ifd(){} + function Gfd(){} + function Ifd(){} + function Igd(){} + function agd(){} + function dgd(){} + function pgd(){} + function Hgd(){} + function Kgd(){} + function Mgd(){} + function Ogd(){} + function Qgd(){} + function Sgd(){} + function Ugd(){} + function Wgd(){} + function Ygd(){} + function $gd(){} + function ahd(){} + function chd(){} + function ehd(){} + function ghd(){} + function ihd(){} + function khd(){} + function mhd(){} + function ohd(){} + function qhd(){} + function shd(){} + function Shd(){} + function lkd(){} + function znd(){} + function Jpd(){} + function jrd(){} + function Mrd(){} + function Qrd(){} + function Urd(){} + function Yrd(){} + function Yud(){} + function eud(){} + function asd(){} + function Lsd(){} + function btd(){} + function dtd(){} + function jtd(){} + function otd(){} + function ztd(){} + function Xxd(){} + function $yd(){} + function rzd(){} + function Rzd(){} + function KAd(){} + function hCd(){} + function _Cd(){} + function _Sd(){} + function OSd(){} + function BDd(){} + function BId(){} + function JId(){} + function YHd(){} + function fLd(){} + function cPd(){} + function hQd(){} + function AQd(){} + function kUd(){} + function VUd(){} + function pVd(){} + function W$d(){} + function Z$d(){} + function a_d(){} + function i_d(){} + function v_d(){} + function y_d(){} + function f1d(){} + function L5d(){} + function v6d(){} + function b8d(){} + function e8d(){} + function h8d(){} + function k8d(){} + function n8d(){} + function q8d(){} + function t8d(){} + function w8d(){} + function z8d(){} + function X9d(){} + function _9d(){} + function Mae(){} + function cbe(){} + function ebe(){} + function hbe(){} + function kbe(){} + function nbe(){} + function qbe(){} + function tbe(){} + function wbe(){} + function zbe(){} + function Cbe(){} + function Fbe(){} + function Ibe(){} + function Lbe(){} + function Obe(){} + function Rbe(){} + function Ube(){} + function Xbe(){} + function $be(){} + function bce(){} + function ece(){} + function hce(){} + function kce(){} + function nce(){} + function qce(){} + function tce(){} + function wce(){} + function zce(){} + function Cce(){} + function Fce(){} + function Ice(){} + function Lce(){} + function Oce(){} + function Rce(){} + function Uce(){} + function Xce(){} + function $ce(){} + function bde(){} + function ede(){} + function hde(){} + function kde(){} + function nde(){} + function qde(){} + function tde(){} + function wde(){} + function Hie(){} + function rke(){} + function rne(){} + function Ene(){} + function Gne(){} + function Jne(){} + function Mne(){} + function Pne(){} + function Sne(){} + function Vne(){} + function Yne(){} + function _ne(){} + function yme(){} + function coe(){} + function foe(){} + function ioe(){} + function loe(){} + function ooe(){} + function roe(){} + function uoe(){} + function xoe(){} + function Aoe(){} + function Doe(){} + function Goe(){} + function Joe(){} + function Moe(){} + function Poe(){} + function Soe(){} + function Voe(){} + function Yoe(){} + function _oe(){} + function cpe(){} + function fpe(){} + function ipe(){} + function lpe(){} + function ope(){} + function rpe(){} + function upe(){} + function xpe(){} + function Ape(){} + function Dpe(){} + function Gpe(){} + function Jpe(){} + function Mpe(){} + function Ppe(){} + function Spe(){} + function Vpe(){} + function Ype(){} + function _pe(){} + function cqe(){} + function fqe(){} + function iqe(){} + function lqe(){} + function oqe(){} + function rqe(){} + function uqe(){} + function Tqe(){} + function sue(){} + function Cue(){} + function zl(){wb();} + function z7b(){s7b();} + function ZHb(){YHb();} + function fSb(){eSb();} + function vSb(){tSb();} + function PUb(){OUb();} + function AVb(){yVb();} + function RVb(){QVb();} + function fWb(){dWb();} + function N5b(){H5b();} + function $9b(){U9b();} + function Lcc(){Hcc();} + function pdc(){Zcc();} + function pec(){iec();} + function pGc(){nGc();} + function jGc(){gGc();} + function YGc(){SGc();} + function cGc(){_Fc();} + function NFc(){KFc();} + function xgc(){sgc();} + function xHc(){tHc();} + function pHc(){lHc();} + function IHc(){CHc();} + function XHc(){RHc();} + function boc(){Mnc();} + function yqc(){mqc();} + function Pzc(){Ozc();} + function ACc(){yCc();} + function aKc(){YJc();} + function FLc(){DLc();} + function DNc(){ANc();} + function TNc(){JNc();} + function iQc(){gQc();} + function WRc(){TRc();} + function C$c(){B$c();} + function J0c(){B0c();} + function x0c(){r0c();} + function j_c(){h_c();} + function N_c(){H_c();} + function V_c(){R_c();} + function E4c(){D4c();} + function a5c(){$4c();} + function v7c(){u7c();} + function Z7c(){X7c();} + function pcd(){ncd();} + function Lcd(){Kcd();} + function Vcd(){Tcd();} + function fUd(){TTd();} + function Bfd(){Afd();} + function jkd(){hkd();} + function vmd(){umd();} + function xnd(){vnd();} + function Hpd(){Fpd();} + function HYd(){lYd();} + function yAd(){qAd();} + function gke(){rue();} + function Yxb(a){uFb(a);} + function Yb(a){this.a=a;} + function cc(a){this.a=a;} + function df(a){this.a=a;} + function kf(a){this.a=a;} + function kj(a){this.a=a;} + function qj(a){this.a=a;} + function Lj(a){this.a=a;} + function jh(a){this.a=a;} + function th(a){this.a=a;} + function Bh(a){this.a=a;} + function Xh(a){this.a=a;} + function Xn(a){this.a=a;} + function Di(a){this.a=a;} + function Ki(a){this.a=a;} + function Ik(a){this.a=a;} + function Qk(a){this.a=a;} + function mp(a){this.a=a;} + function Lp(a){this.a=a;} + function iq(a){this.a=a;} + function Eq(a){this.a=a;} + function Vq(a){this.a=a;} + function Or(a){this.a=a;} + function $r(a){this.b=a;} + function Aj(a){this.c=a;} + function vu(a){this.a=a;} + function vw(a){this.a=a;} + function gw(a){this.a=a;} + function lw(a){this.a=a;} + function Iw(a){this.a=a;} + function Nw(a){this.a=a;} + function Sw(a){this.a=a;} + function ex(a){this.a=a;} + function fx(a){this.a=a;} + function lx(a){this.a=a;} + function my(a){this.a=a;} + function qy(a){this.a=a;} + function Oy(a){this.a=a;} + function NB(a){this.a=a;} + function XB(a){this.a=a;} + function hC(a){this.a=a;} + function vC(a){this.a=a;} + function MB(){this.a=[];} + function HEb(a,b){a.a=b;} + function E2b(a,b){a.a=b;} + function F2b(a,b){a.b=b;} + function PRb(a,b){a.b=b;} + function RRb(a,b){a.b=b;} + function QJb(a,b){a.j=b;} + function hQb(a,b){a.g=b;} + function iQb(a,b){a.i=b;} + function _Tb(a,b){a.c=b;} + function G2b(a,b){a.c=b;} + function H2b(a,b){a.d=b;} + function aUb(a,b){a.d=b;} + function h3b(a,b){a.k=b;} + function O3b(a,b){a.c=b;} + function Tmc(a,b){a.c=b;} + function Smc(a,b){a.a=b;} + function DJc(a,b){a.a=b;} + function EJc(a,b){a.f=b;} + function NSc(a,b){a.a=b;} + function OSc(a,b){a.b=b;} + function PSc(a,b){a.d=b;} + function QSc(a,b){a.i=b;} + function RSc(a,b){a.o=b;} + function SSc(a,b){a.r=b;} + function yUc(a,b){a.a=b;} + function zUc(a,b){a.b=b;} + function q3c(a,b){a.e=b;} + function r3c(a,b){a.f=b;} + function s3c(a,b){a.g=b;} + function Y9c(a,b){a.e=b;} + function Z9c(a,b){a.f=b;} + function kad(a,b){a.f=b;} + function Ntd(a,b){a.a=b;} + function Otd(a,b){a.b=b;} + function BWd(a,b){a.n=b;} + function $ee(a,b){a.a=b;} + function _ee(a,b){a.c=b;} + function ife(a,b){a.c=b;} + function Efe(a,b){a.c=b;} + function hfe(a,b){a.a=b;} + function Dfe(a,b){a.a=b;} + function jfe(a,b){a.d=b;} + function Ffe(a,b){a.d=b;} + function kfe(a,b){a.e=b;} + function Gfe(a,b){a.e=b;} + function lfe(a,b){a.g=b;} + function Hfe(a,b){a.f=b;} + function Ife(a,b){a.j=b;} + function wme(a,b){a.a=b;} + function Fme(a,b){a.a=b;} + function xme(a,b){a.b=b;} + function gmc(a){a.b=a.a;} + function Lg(a){a.c=a.d.d;} + function fgb(a){this.a=a;} + function zgb(a){this.a=a;} + function Xgb(a){this.a=a;} + function Xkb(a){this.a=a;} + function mkb(a){this.a=a;} + function reb(a){this.a=a;} + function Seb(a){this.a=a;} + function bfb(a){this.a=a;} + function Tfb(a){this.a=a;} + function blb(a){this.a=a;} + function glb(a){this.a=a;} + function llb(a){this.a=a;} + function Ulb(a){this.a=a;} + function _lb(a){this.a=a;} + function Plb(a){this.b=a;} + function Ppb(a){this.b=a;} + function xpb(a){this.b=a;} + function mpb(a){this.a=a;} + function Yqb(a){this.a=a;} + function uqb(a){this.c=a;} + function Anb(a){this.c=a;} + function zwb(a){this.c=a;} + function Dkb(a){this.d=a;} + function brb(a){this.a=a;} + function Frb(a){this.a=a;} + function hsb(a){this.a=a;} + function ctb(a){this.a=a;} + function cxb(a){this.a=a;} + function axb(a){this.a=a;} + function exb(a){this.a=a;} + function gxb(a){this.a=a;} + function wub(a){this.a=a;} + function zAb(a){this.a=a;} + function JAb(a){this.a=a;} + function LAb(a){this.a=a;} + function PAb(a){this.a=a;} + function VBb(a){this.a=a;} + function lCb(a){this.a=a;} + function nCb(a){this.a=a;} + function pCb(a){this.a=a;} + function CCb(a){this.a=a;} + function GCb(a){this.a=a;} + function bDb(a){this.a=a;} + function dDb(a){this.a=a;} + function fDb(a){this.a=a;} + function uDb(a){this.a=a;} + function $Db(a){this.a=a;} + function aEb(a){this.a=a;} + function eEb(a){this.a=a;} + function OEb(a){this.a=a;} + function SEb(a){this.a=a;} + function SFb(a){this.a=a;} + function HFb(a){this.a=a;} + function NFb(a){this.a=a;} + function WGb(a){this.a=a;} + function HJb(a){this.a=a;} + function PJb(a){this.a=a;} + function kNb(a){this.a=a;} + function tOb(a){this.a=a;} + function APb(a){this.a=a;} + function IQb(a){this.a=a;} + function bTb(a){this.a=a;} + function dTb(a){this.a=a;} + function wTb(a){this.a=a;} + function GWb(a){this.a=a;} + function UWb(a){this.a=a;} + function WWb(a){this.a=a;} + function fXb(a){this.a=a;} + function jXb(a){this.a=a;} + function M0b(a){this.a=a;} + function r1b(a){this.a=a;} + function D1b(a){this.e=a;} + function T3b(a){this.a=a;} + function W3b(a){this.a=a;} + function _3b(a){this.a=a;} + function c4b(a){this.a=a;} + function s5b(a){this.a=a;} + function u5b(a){this.a=a;} + function y5b(a){this.a=a;} + function C5b(a){this.a=a;} + function Q5b(a){this.a=a;} + function S5b(a){this.a=a;} + function U5b(a){this.a=a;} + function W5b(a){this.a=a;} + function l7b(a){this.a=a;} + function p7b(a){this.a=a;} + function k8b(a){this.a=a;} + function L8b(a){this.a=a;} + function Rac(a){this.a=a;} + function Xac(a){this.a=a;} + function $ac(a){this.a=a;} + function bbc(a){this.a=a;} + function Cdc(a){this.a=a;} + function Edc(a){this.a=a;} + function Ehc(a){this.a=a;} + function khc(a){this.a=a;} + function Ihc(a){this.a=a;} + function qfc(a){this.a=a;} + function tfc(a){this.a=a;} + function Wfc(a){this.a=a;} + function Fic(a){this.a=a;} + function Vic(a){this.a=a;} + function fjc(a){this.a=a;} + function pjc(a){this.a=a;} + function ckc(a){this.a=a;} + function hkc(a){this.a=a;} + function Ykc(a){this.a=a;} + function $kc(a){this.a=a;} + function alc(a){this.a=a;} + function glc(a){this.a=a;} + function ilc(a){this.a=a;} + function slc(a){this.a=a;} + function Clc(a){this.a=a;} + function xoc(a){this.a=a;} + function zoc(a){this.a=a;} + function spc(a){this.a=a;} + function Vqc(a){this.a=a;} + function Xqc(a){this.a=a;} + function Gsc(a){this.a=a;} + function Isc(a){this.a=a;} + function JGc(a){this.a=a;} + function NGc(a){this.a=a;} + function MHc(a){this.a=a;} + function JIc(a){this.a=a;} + function fJc(a){this.a=a;} + function BJc(a){this.a=a;} + function dJc(a){this.c=a;} + function Trc(a){this.b=a;} + function eKc(a){this.a=a;} + function IKc(a){this.a=a;} + function KKc(a){this.a=a;} + function MKc(a){this.a=a;} + function yLc(a){this.a=a;} + function HMc(a){this.a=a;} + function LMc(a){this.a=a;} + function PMc(a){this.a=a;} + function TMc(a){this.a=a;} + function XMc(a){this.a=a;} + function ZMc(a){this.a=a;} + function aNc(a){this.a=a;} + function jNc(a){this.a=a;} + function aPc(a){this.a=a;} + function gPc(a){this.a=a;} + function kPc(a){this.a=a;} + function yPc(a){this.a=a;} + function CPc(a){this.a=a;} + function JPc(a){this.a=a;} + function RPc(a){this.a=a;} + function XPc(a){this.a=a;} + function mRc(a){this.a=a;} + function xTc(a){this.a=a;} + function CWc(a){this.a=a;} + function EWc(a){this.a=a;} + function IWc(a){this.a=a;} + function OWc(a){this.a=a;} + function dXc(a){this.a=a;} + function gXc(a){this.a=a;} + function EXc(a){this.a=a;} + function WXc(a){this.a=a;} + function YXc(a){this.a=a;} + function aYc(a){this.a=a;} + function cYc(a){this.a=a;} + function eYc(a){this.a=a;} + function iYc(a){this.a=a;} + function i0c(a){this.a=a;} + function g0c(a){this.a=a;} + function P1c(a){this.a=a;} + function Sad(a){this.a=a;} + function Uad(a){this.a=a;} + function Wad(a){this.a=a;} + function Yad(a){this.a=a;} + function cbd(a){this.a=a;} + function ydd(a){this.a=a;} + function Kdd(a){this.a=a;} + function Mdd(a){this.a=a;} + function _ed(a){this.a=a;} + function dfd(a){this.a=a;} + function Kfd(a){this.a=a;} + function prd(a){this.a=a;} + function $rd(a){this.a=a;} + function csd(a){this.a=a;} + function Usd(a){this.a=a;} + function Vtd(a){this.a=a;} + function wud(a){this.a=a;} + function Rud(a){this.f=a;} + function LEd(a){this.a=a;} + function UEd(a){this.a=a;} + function VEd(a){this.a=a;} + function WEd(a){this.a=a;} + function XEd(a){this.a=a;} + function YEd(a){this.a=a;} + function ZEd(a){this.a=a;} + function $Ed(a){this.a=a;} + function _Ed(a){this.a=a;} + function aFd(a){this.a=a;} + function gFd(a){this.a=a;} + function iFd(a){this.a=a;} + function jFd(a){this.a=a;} + function kFd(a){this.a=a;} + function lFd(a){this.a=a;} + function nFd(a){this.a=a;} + function qFd(a){this.a=a;} + function wFd(a){this.a=a;} + function xFd(a){this.a=a;} + function zFd(a){this.a=a;} + function AFd(a){this.a=a;} + function BFd(a){this.a=a;} + function CFd(a){this.a=a;} + function DFd(a){this.a=a;} + function MFd(a){this.a=a;} + function OFd(a){this.a=a;} + function QFd(a){this.a=a;} + function SFd(a){this.a=a;} + function uGd(a){this.a=a;} + function QGd(a){this.a=a;} + function jGd(a){this.b=a;} + function YOd(a){this.a=a;} + function ePd(a){this.a=a;} + function kPd(a){this.a=a;} + function qPd(a){this.a=a;} + function IPd(a){this.a=a;} + function w$d(a){this.a=a;} + function e_d(a){this.a=a;} + function Q_d(a){this.b=a;} + function c1d(a){this.a=a;} + function c2d(a){this.a=a;} + function l5d(a){this.a=a;} + function I9d(a){this.a=a;} + function L6d(a){this.c=a;} + function t7d(a){this.e=a;} + function pae(a){this.a=a;} + function xae(a){this.a=a;} + function Zde(a){this.a=a;} + function Sde(a){this.d=a;} + function mee(a){this.a=a;} + function uje(a){this.a=a;} + function Bte(a){this.a=a;} + function Wse(a){this.e=a;} + function Xsd(){this.a=0;} + function Tsb(){akb(this);} + function bnb(){Pmb(this);} + function cHb(){bHb(this);} + function I2b(){} + function s2d(){this.c=d2d;} + function Prc(a,b){a.b+=b;} + function Uje(a,b){b.Wb(a);} + function UC(a){return a.a} + function nC(a){return a.a} + function BC(a){return a.a} + function TB(a){return a.a} + function _B(a){return a.a} + function Adb(a){return a.e} + function gC(){return null} + function MC(){return null} + function leb(){MId();OId();} + function qMb(a){a.b.Of(a.e);} + function A$b(a){a.b=new Ri;} + function A8b(a,b){a.b=b-a.b;} + function x8b(a,b){a.a=b-a.a;} + function ZEb(a,b){a.push(b);} + function bFb(a,b){a.sort(b);} + function Q5c(a,b){b.jd(a.a);} + function Voc(a,b){Q3b(b,a);} + function tp(a,b,c){a.Yd(c,b);} + function Ss(a,b){a.e=b;b.b=a;} + function im(a){_l();this.a=a;} + function xq(a){_l();this.a=a;} + function Gq(a){_l();this.a=a;} + function Xq(a){tm();this.a=a;} + function gA(a){fA();eA.le(a);} + function vA(){vA=geb;new Tsb;} + function xz(){mz.call(this);} + function Ceb(){mz.call(this);} + function ueb(){xz.call(this);} + function yeb(){xz.call(this);} + function Hfb(){xz.call(this);} + function _fb(){xz.call(this);} + function cgb(){xz.call(this);} + function Ngb(){xz.call(this);} + function jib(){xz.call(this);} + function Jrb(){xz.call(this);} + function Srb(){xz.call(this);} + function Dvb(){xz.call(this);} + function Ied(){xz.call(this);} + function R1d(){this.a=this;} + function k1d(){this.Bb|=256;} + function vWb(){this.b=new Et;} + function aFb(a,b){a.length=b;} + function dyb(a,b){Rmb(a.a,b);} + function jNb(a,b){LKb(a.c,b);} + function qRc(a,b){Ysb(a.b,b);} + function VOd(a,b){UNd(a.a,b);} + function WOd(a,b){VNd(a.a,b);} + function eZd(a,b){qvd(a.e,b);} + function Cke(a){bge(a.c,a.b);} + function uj(a,b){a.kc().Nb(b);} + function Ufb(a){this.a=Zfb(a);} + function _sb(){this.a=new Tsb;} + function $Ab(){this.a=new Tsb;} + function xAb(){this.a=new dzb;} + function gyb(){this.a=new bnb;} + function BIb(){this.a=new bnb;} + function GIb(){this.a=new bnb;} + function wIb(){this.a=new pIb;} + function gJb(){this.a=new DIb;} + function TTb(){this.a=new DTb;} + function jGb(){this.a=new fGb;} + function qGb(){this.a=new kGb;} + function q_b(){this.a=new bnb;} + function E_b(){this.a=new bnb;} + function EZb(){this.a=new bnb;} + function J$b(){this.a=new bnb;} + function YNb(){this.d=new bnb;} + function lXb(){this.a=new RWb;} + function y_b(){this.a=new _sb;} + function k5b(){this.a=new Tsb;} + function E0b(){this.b=new Tsb;} + function jHc(){this.b=new bnb;} + function ZNc(){this.e=new bnb;} + function ahc(){this.a=new boc;} + function UQc(){this.d=new bnb;} + function uRc(){tRc.call(this);} + function BRc(){tRc.call(this);} + function VOc(){bnb.call(this);} + function web(){ueb.call(this);} + function Fyb(){gyb.call(this);} + function fKb(){RJb.call(this);} + function N$b(){J$b.call(this);} + function P2b(){I2b.call(this);} + function T2b(){P2b.call(this);} + function z3b(){I2b.call(this);} + function C3b(){z3b.call(this);} + function cUc(){aUc.call(this);} + function hUc(){aUc.call(this);} + function mUc(){aUc.call(this);} + function Hdd(){Ddd.call(this);} + function ACd(){$yd.call(this);} + function PCd(){$yd.call(this);} + function Ejd(){Yub.call(this);} + function LQd(){wQd.call(this);} + function lRd(){wQd.call(this);} + function MSd(){Tsb.call(this);} + function VSd(){Tsb.call(this);} + function eTd(){Tsb.call(this);} + function mXd(){HWd.call(this);} + function i1d(){_sb.call(this);} + function A1d(){k1d.call(this);} + function q4d(){dWd.call(this);} + function O5d(){Tsb.call(this);} + function R5d(){dWd.call(this);} + function lae(){Tsb.call(this);} + function Cae(){Tsb.call(this);} + function ome(){kUd.call(this);} + function Hme(){ome.call(this);} + function Nme(){kUd.call(this);} + function Gre(){Tqe.call(this);} + function aUc(){this.a=new _sb;} + function nZc(){this.a=new Tsb;} + function DZc(){this.a=new bnb;} + function Ddd(){this.a=new Tsb;} + function Oqd(){this.a=new Yub;} + function Oed(){this.j=new bnb;} + function obd(){this.a=new nbd;} + function wQd(){this.a=new AQd;} + function R5c(){this.a=new V5c;} + function wb(){wb=geb;vb=new xb;} + function Wk(){Wk=geb;Vk=new Xk;} + function kl(){kl=geb;jl=new ll;} + function ll(){Qk.call(this,'');} + function Xk(){Qk.call(this,'');} + function Dd(a){yd.call(this,a);} + function Hd(a){yd.call(this,a);} + function xh(a){th.call(this,a);} + function $h(a){Wc.call(this,a);} + function Qi(a){Wc.call(this,a);} + function wi(a){$h.call(this,a);} + function Sp(a){$h.call(this,a);} + function Js(a){$h.call(this,a);} + function Jp(a){Xo.call(this,a);} + function Qp(a){Xo.call(this,a);} + function dq(a){ho.call(this,a);} + function Fv(a){uv.call(this,a);} + function aw(a){Tr.call(this,a);} + function cw(a){Tr.call(this,a);} + function _w(a){Tr.call(this,a);} + function Mx(a){Gn.call(this,a);} + function Nx(a){Mx.call(this,a);} + function yz(a){nz.call(this,a);} + function aC(a){yz.call(this,a);} + function uC(){vC.call(this,{});} + function cC(){cC=geb;bC=new dC;} + function zs(){zs=geb;ys=new As;} + function Az(){Az=geb;zz=new nb;} + function $z(){$z=geb;Zz=new bA;} + function $A(){$A=geb;ZA=new aB;} + function Ovb(a){Kvb();this.a=a;} + function FKc(a){jKc();this.a=a;} + function zud(a){nud();this.f=a;} + function Bud(a){nud();this.f=a;} + function Cde(a){KMd();this.a=a;} + function Lyb(a){a.b=null;a.c=0;} + function kz(a,b){a.e=b;hz(a,b);} + function NYb(a,b){a.a=b;PYb(a);} + function cLb(a,b,c){a.a[b.g]=c;} + function zsd(a,b,c){Hsd(c,a,b);} + function shc(a,b){Xmc(b.i,a.n);} + function HCc(a,b){ICc(a).Cd(b);} + function yw(a,b){a.a.ec().Mc(b);} + function ns(a,b){return a.g-b.g} + function AUb(a,b){return a*a/b} + function Heb(a){return uFb(a),a} + function Kfb(a){return uFb(a),a} + function Mfb(a){return uFb(a),a} + function JC(a){return new hC(a)} + function LC(a){return new OC(a)} + function shb(a){return uFb(a),a} + function Chb(a){return uFb(a),a} + function teb(a){yz.call(this,a);} + function veb(a){yz.call(this,a);} + function zeb(a){yz.call(this,a);} + function Aeb(a){nz.call(this,a);} + function Ifb(a){yz.call(this,a);} + function agb(a){yz.call(this,a);} + function dgb(a){yz.call(this,a);} + function Mgb(a){yz.call(this,a);} + function Ogb(a){yz.call(this,a);} + function kib(a){yz.call(this,a);} + function Jed(a){yz.call(this,a);} + function Ked(a){yz.call(this,a);} + function CDd(a){yz.call(this,a);} + function Mle(a){yz.call(this,a);} + function Lqe(a){yz.call(this,a);} + function mob(a){uFb(a);this.a=a;} + function yYb(a){sYb(a);return a} + function Nnb(a){Snb(a,a.length);} + function nmb(a){return a.b==a.c} + function Vyb(a){return !!a&&a.b} + function gLb(a){return !!a&&a.k} + function hLb(a){return !!a&&a.j} + function F_b(a,b,c){a.c.Ef(b,c);} + function Ts(a,b){a.be(b);b.ae(a);} + function Fy(a){_l();this.a=Qb(a);} + function Gb(){this.a=WD(Qb(pve));} + function jc(){throw Adb(new jib)} + function jn(){throw Adb(new jib)} + function Hh(){throw Adb(new jib)} + function Xi(){throw Adb(new jib)} + function Xj(){throw Adb(new jib)} + function Yj(){throw Adb(new jib)} + function Qz(){Qz=geb;!!(fA(),eA);} + function Qhb(){reb.call(this,'');} + function Rhb(){reb.call(this,'');} + function bib(){reb.call(this,'');} + function cib(){reb.call(this,'');} + function eib(a){veb.call(this,a);} + function xeb(a){veb.call(this,a);} + function Vgb(a){agb.call(this,a);} + function Lqb(a){xpb.call(this,a);} + function Sqb(a){Lqb.call(this,a);} + function irb(a){Upb.call(this,a);} + function pc(a){qc.call(this,a,0);} + function Ri(){Si.call(this,12,3);} + function WC(a,b){return xfb(a,b)} + function cFb(a,b){return dD(a,b)} + function Reb(a,b){return a.a-b.a} + function afb(a,b){return a.a-b.a} + function Wgb(a,b){return a.a-b.a} + function pC(b,a){return a in b.a} + function Vvb(a){return a.a?a.b:0} + function cwb(a){return a.a?a.b:0} + function Fxb(a,b,c){b.Cd(a.a[c]);} + function Kxb(a,b,c){b.Pe(a.a[c]);} + function uKb(a,b){a.b=new sjd(b);} + function QGb(a,b){a.b=b;return a} + function RGb(a,b){a.c=b;return a} + function SGb(a,b){a.f=b;return a} + function TGb(a,b){a.g=b;return a} + function yJb(a,b){a.a=b;return a} + function zJb(a,b){a.f=b;return a} + function AJb(a,b){a.k=b;return a} + function WNb(a,b){a.a=b;return a} + function XNb(a,b){a.e=b;return a} + function BYb(a,b){a.e=b;return a} + function CYb(a,b){a.f=b;return a} + function BRb(a,b){a.b=true;a.d=b;} + function WNc(a,b){return a.b-b.b} + function KSc(a,b){return a.g-b.g} + function pmc(a,b){return a?0:b-1} + function qKc(a,b){return a?0:b-1} + function pKc(a,b){return a?b-1:0} + function uVc(a,b){return a.s-b.s} + function Xed(a,b){return b.rg(a)} + function Xfd(a,b){a.b=b;return a} + function Wfd(a,b){a.a=b;return a} + function Yfd(a,b){a.c=b;return a} + function Zfd(a,b){a.d=b;return a} + function $fd(a,b){a.e=b;return a} + function _fd(a,b){a.f=b;return a} + function mgd(a,b){a.a=b;return a} + function ngd(a,b){a.b=b;return a} + function ogd(a,b){a.c=b;return a} + function Khd(a,b){a.c=b;return a} + function Jhd(a,b){a.b=b;return a} + function Lhd(a,b){a.d=b;return a} + function Mhd(a,b){a.e=b;return a} + function Nhd(a,b){a.f=b;return a} + function Ohd(a,b){a.g=b;return a} + function Phd(a,b){a.a=b;return a} + function Qhd(a,b){a.i=b;return a} + function Rhd(a,b){a.j=b;return a} + function coc(a,b){Mnc();P3b(b,a);} + function bbd(a,b,c){_ad(a.a,b,c);} + function Fjd(a){Zub.call(this,a);} + function TRb(a){SRb.call(this,a);} + function pLc(a){CIc.call(this,a);} + function ILc(a){CIc.call(this,a);} + function gLd(a){ZHd.call(this,a);} + function DPd(a){xPd.call(this,a);} + function FPd(a){xPd.call(this,a);} + function x2b(){y2b.call(this,'');} + function pjd(){this.a=0;this.b=0;} + function ATc(){this.b=0;this.a=0;} + function lXd(a,b){a.b=0;bWd(a,b);} + function Kqd(a,b){a.k=b;return a} + function Lqd(a,b){a.j=b;return a} + function vfe(a,b){a.c=b;a.b=true;} + function Etb(){Etb=geb;Dtb=Gtb();} + function bvd(){bvd=geb;avd=OAd();} + function dvd(){dvd=geb;cvd=aCd();} + function MId(){MId=geb;LId=ygd();} + function jTd(){jTd=geb;iTd=Qae();} + function Ole(){Ole=geb;Nle=vne();} + function Qle(){Qle=geb;Ple=Cne();} + function mfb(a){return a.e&&a.e()} + function FD(a){return a.l|a.m<<22} + function Oc(a,b){return a.c._b(b)} + function En(a,b){return Wv(a.b,b)} + function Vd(a){return !a?null:a.d} + function Vv(a){return !a?null:a.g} + function $v(a){return !a?null:a.i} + function nfb(a){lfb(a);return a.o} + function Khb(a,b){a.a+=b;return a} + function Lhb(a,b){a.a+=b;return a} + function Ohb(a,b){a.a+=b;return a} + function Uhb(a,b){a.a+=b;return a} + function _wb(a,b){while(a.Bd(b));} + function atb(a){this.a=new Usb(a);} + function $tb(){throw Adb(new jib)} + function qpb(){throw Adb(new jib)} + function rpb(){throw Adb(new jib)} + function spb(){throw Adb(new jib)} + function vpb(){throw Adb(new jib)} + function Opb(){throw Adb(new jib)} + function yAb(a){this.a=new ezb(a);} + function H2c(){this.a=new Wed(s0);} + function TVc(){this.b=new Wed(H$);} + function l6c(){this.a=new Wed(V0);} + function $ad(){this.b=new Wed(I1);} + function nbd(){this.b=new Wed(I1);} + function T2c(a){this.a=0;this.b=a;} + function Bib(a){tib();vib(this,a);} + function QDb(a){LCb(a);return a.a} + function dvb(a){return a.b!=a.d.c} + function AMc(a,b){return a.d[b.p]} + function ued(a,b){return ned(a,b)} + function $Eb(a,b,c){a.splice(b,c);} + function ixb(a,b){while(a.Re(b));} + function NKb(a){a.c?MKb(a):OKb(a);} + function mQd(){throw Adb(new jib)} + function nQd(){throw Adb(new jib)} + function oQd(){throw Adb(new jib)} + function pQd(){throw Adb(new jib)} + function qQd(){throw Adb(new jib)} + function rQd(){throw Adb(new jib)} + function sQd(){throw Adb(new jib)} + function tQd(){throw Adb(new jib)} + function uQd(){throw Adb(new jib)} + function vQd(){throw Adb(new jib)} + function zue(){throw Adb(new Dvb)} + function Aue(){throw Adb(new Dvb)} + function oue(a){this.a=new Dte(a);} + function Dte(a){Cte(this,a,sse());} + function cve(a){return !a||bve(a)} + function Cqe(a){return xqe[a]!=-1} + function Yz(){Nz!=0&&(Nz=0);Pz=-1;} + function beb(){_db==null&&(_db=[]);} + function eg(a,b){zf.call(this,a,b);} + function gg(a,b){eg.call(this,a,b);} + function Nj(a,b){this.a=a;this.b=b;} + function hk(a,b){this.a=a;this.b=b;} + function nk(a,b){this.a=a;this.b=b;} + function pk(a,b){this.a=a;this.b=b;} + function xk(a,b){this.a=a;this.b=b;} + function zk(a,b){this.a=a;this.b=b;} + function Kk(a,b){this.a=a;this.b=b;} + function ne(a,b){this.e=a;this.d=b;} + function Hf(a,b){this.b=a;this.c=b;} + function cp(a,b){this.b=a;this.a=b;} + function Cp(a,b){this.b=a;this.a=b;} + function qr(a,b){this.b=a;this.a=b;} + function Rr(a,b){this.b=a;this.a=b;} + function vr(a,b){this.a=a;this.b=b;} + function su(a,b){this.a=a;this.b=b;} + function Hu(a,b){this.a=a;this.f=b;} + function gp(a,b){this.g=a;this.i=b;} + function qs(a,b){this.f=a;this.g=b;} + function Gv(a,b){this.b=a;this.c=b;} + function Wc(a){Lb(a.dc());this.c=a;} + function Ex(a,b){this.a=a;this.b=b;} + function ey(a,b){this.a=a;this.b=b;} + function pv(a){this.a=RD(Qb(a),15);} + function uv(a){this.a=RD(Qb(a),15);} + function nw(a){this.a=RD(Qb(a),85);} + function rf(a){this.b=RD(Qb(a),85);} + function Tr(a){this.b=RD(Qb(a),51);} + function uB(){this.q=new $wnd.Date;} + function CC(a,b){this.a=a;this.b=b;} + function Bt(a,b){return Ujb(a.b,b)} + function tpb(a,b){return a.b.Hc(b)} + function upb(a,b){return a.b.Ic(b)} + function wpb(a,b){return a.b.Qc(b)} + function Pqb(a,b){return a.b.Hc(b)} + function pqb(a,b){return a.c.uc(b)} + function rqb(a,b){return pb(a.c,b)} + function Zsb(a,b){return a.a._b(b)} + function Xp(a,b){return a>b&&b0} + function Ldb(a,b){return Ddb(a,b)<0} + function Urb(a,b){return Bsb(a.a,b)} + function Beb(a,b){oz.call(this,a,b);} + function Qx(a){Px();ho.call(this,a);} + function Lnb(a,b){Pnb(a,a.length,b);} + function Mnb(a,b){Rnb(a,a.length,b);} + function Ktb(a,b){return a.a.get(b)} + function bub(a,b){return Ujb(a.e,b)} + function Zxb(a){return uFb(a),false} + function zw(a){this.a=RD(Qb(a),229);} + function $wb(a){Swb.call(this,a,21);} + function dAb(a,b){qs.call(this,a,b);} + function yBb(a,b){qs.call(this,a,b);} + function ssb(a,b){this.b=a;this.a=b;} + function xlb(a,b){this.d=a;this.e=b;} + function jEb(a,b){this.a=a;this.b=b;} + function pEb(a,b){this.a=a;this.b=b;} + function vEb(a,b){this.a=a;this.b=b;} + function BEb(a,b){this.a=a;this.b=b;} + function TFb(a,b){this.a=a;this.b=b;} + function QEb(a,b){this.b=a;this.a=b;} + function sHb(a,b){this.b=a;this.a=b;} + function EHb(a,b){qs.call(this,a,b);} + function MHb(a,b){qs.call(this,a,b);} + function jIb(a,b){qs.call(this,a,b);} + function $Jb(a,b){qs.call(this,a,b);} + function FKb(a,b){qs.call(this,a,b);} + function wLb(a,b){qs.call(this,a,b);} + function nOb(a,b){qs.call(this,a,b);} + function kPb(a,b){this.b=a;this.a=b;} + function JPb(a,b){qs.call(this,a,b);} + function fRb(a,b){this.b=a;this.a=b;} + function JRb(a,b){qs.call(this,a,b);} + function OTb(a,b){this.b=a;this.a=b;} + function UUb(a,b){qs.call(this,a,b);} + function BWb(a,b){qs.call(this,a,b);} + function tXb(a,b){qs.call(this,a,b);} + function XEb(a,b,c){a.splice(b,0,c);} + function pr(a,b,c){a.Mb(c)&&b.Cd(c);} + function lEb(a,b,c){b.Pe(a.a.Ye(c));} + function rEb(a,b,c){b.Dd(a.a.Ze(c));} + function xEb(a,b,c){b.Cd(a.a.Kb(c));} + function eYb(a,b){return Csb(a.c,b)} + function cGb(a,b){return Csb(a.e,b)} + function qZb(a,b){qs.call(this,a,b);} + function V$b(a,b){qs.call(this,a,b);} + function s3b(a,b){qs.call(this,a,b);} + function Q8b(a,b){qs.call(this,a,b);} + function icc(a,b){qs.call(this,a,b);} + function xec(a,b){qs.call(this,a,b);} + function gic(a,b){this.a=a;this.b=b;} + function Xic(a,b){this.a=a;this.b=b;} + function h4b(a,b){this.a=a;this.b=b;} + function vjc(a,b){this.a=a;this.b=b;} + function xjc(a,b){this.a=a;this.b=b;} + function Hjc(a,b){this.a=a;this.b=b;} + function hjc(a,b){this.b=a;this.a=b;} + function Jjc(a,b){this.b=a;this.a=b;} + function _Yb(a,b){this.b=a;this.a=b;} + function eZb(a,b){this.c=a;this.d=b;} + function Q1b(a,b){this.e=a;this.d=b;} + function Tjc(a,b){this.a=a;this.b=b;} + function ulc(a,b){this.a=a;this.b=b;} + function Elc(a,b){this.a=a;this.b=b;} + function fqc(a,b){this.b=a;this.a=b;} + function smc(a,b){this.b=b;this.c=a;} + function fnc(a,b){qs.call(this,a,b);} + function Cnc(a,b){qs.call(this,a,b);} + function koc(a,b){qs.call(this,a,b);} + function ktc(a,b){qs.call(this,a,b);} + function ctc(a,b){qs.call(this,a,b);} + function utc(a,b){qs.call(this,a,b);} + function Ftc(a,b){qs.call(this,a,b);} + function Rtc(a,b){qs.call(this,a,b);} + function _tc(a,b){qs.call(this,a,b);} + function iuc(a,b){qs.call(this,a,b);} + function vuc(a,b){qs.call(this,a,b);} + function Duc(a,b){qs.call(this,a,b);} + function Puc(a,b){qs.call(this,a,b);} + function _uc(a,b){qs.call(this,a,b);} + function pvc(a,b){qs.call(this,a,b);} + function yvc(a,b){qs.call(this,a,b);} + function Hvc(a,b){qs.call(this,a,b);} + function Pvc(a,b){qs.call(this,a,b);} + function dxc(a,b){qs.call(this,a,b);} + function bDc(a,b){qs.call(this,a,b);} + function nDc(a,b){qs.call(this,a,b);} + function yDc(a,b){qs.call(this,a,b);} + function LDc(a,b){qs.call(this,a,b);} + function bEc(a,b){qs.call(this,a,b);} + function lEc(a,b){qs.call(this,a,b);} + function tEc(a,b){qs.call(this,a,b);} + function CEc(a,b){qs.call(this,a,b);} + function LEc(a,b){qs.call(this,a,b);} + function UEc(a,b){qs.call(this,a,b);} + function mFc(a,b){qs.call(this,a,b);} + function vFc(a,b){qs.call(this,a,b);} + function EFc(a,b){qs.call(this,a,b);} + function SKc(a,b){qs.call(this,a,b);} + function cNc(a,b){this.b=a;this.a=b;} + function tNc(a,b){qs.call(this,a,b);} + function QOc(a,b){this.a=a;this.b=b;} + function ePc(a,b){this.a=a;this.b=b;} + function LPc(a,b){this.a=a;this.b=b;} + function xQc(a,b){qs.call(this,a,b);} + function FQc(a,b){qs.call(this,a,b);} + function MQc(a,b){this.a=a;this.b=b;} + function FMc(a,b){dMc();return b!=a} + function Uvb(a){sFb(a.a);return a.b} + function qYb(a){rYb(a,a.c);return a} + function Itb(){Etb();return new Dtb} + function _ec(){Rec();this.a=new e6b;} + function lSc(){dSc();this.a=new _sb;} + function aRc(){WQc();this.b=new _sb;} + function xRc(a,b){this.b=a;this.d=b;} + function nVc(a,b){this.a=a;this.b=b;} + function pVc(a,b){this.a=a;this.b=b;} + function GWc(a,b){this.a=a;this.b=b;} + function IXc(a,b){this.b=a;this.a=b;} + function gTc(a,b){qs.call(this,a,b);} + function eVc(a,b){qs.call(this,a,b);} + function $Vc(a,b){qs.call(this,a,b);} + function XYc(a,b){qs.call(this,a,b);} + function MZc(a,b){qs.call(this,a,b);} + function t_c(a,b){qs.call(this,a,b);} + function B_c(a,b){qs.call(this,a,b);} + function z2c(a,b){qs.call(this,a,b);} + function h3c(a,b){qs.call(this,a,b);} + function $3c(a,b){qs.call(this,a,b);} + function i4c(a,b){qs.call(this,a,b);} + function l5c(a,b){qs.call(this,a,b);} + function v5c(a,b){qs.call(this,a,b);} + function g6c(a,b){qs.call(this,a,b);} + function A6c(a,b){qs.call(this,a,b);} + function a7c(a,b){qs.call(this,a,b);} + function B8c(a,b){qs.call(this,a,b);} + function d9c(a,b){qs.call(this,a,b);} + function D9c(a,b){qs.call(this,a,b);} + function tad(a,b){qs.call(this,a,b);} + function hbd(a,b){qs.call(this,a,b);} + function Nbd(a,b){qs.call(this,a,b);} + function Ybd(a,b){qs.call(this,a,b);} + function ndd(a,b){qs.call(this,a,b);} + function z1c(a,b){this.b=a;this.a=b;} + function B1c(a,b){this.b=a;this.a=b;} + function d2c(a,b){this.b=a;this.a=b;} + function f2c(a,b){this.b=a;this.a=b;} + function m9c(a,b){this.a=a;this.b=b;} + function xed(a,b){this.a=a;this.b=b;} + function ffd(a,b){this.a=a;this.b=b;} + function rjd(a,b){this.a=a;this.b=b;} + function Sjd(a,b){qs.call(this,a,b);} + function Zhd(a,b){qs.call(this,a,b);} + function lid(a,b){qs.call(this,a,b);} + function vkd(a,b){qs.call(this,a,b);} + function Gmd(a,b){qs.call(this,a,b);} + function Pmd(a,b){qs.call(this,a,b);} + function Zmd(a,b){qs.call(this,a,b);} + function jnd(a,b){qs.call(this,a,b);} + function Gnd(a,b){qs.call(this,a,b);} + function Rnd(a,b){qs.call(this,a,b);} + function eod(a,b){qs.call(this,a,b);} + function qod(a,b){qs.call(this,a,b);} + function Eod(a,b){qs.call(this,a,b);} + function Qod(a,b){qs.call(this,a,b);} + function upd(a,b){qs.call(this,a,b);} + function Rpd(a,b){qs.call(this,a,b);} + function eqd(a,b){qs.call(this,a,b);} + function nqd(a,b){qs.call(this,a,b);} + function vqd(a,b){qs.call(this,a,b);} + function Hrd(a,b){qs.call(this,a,b);} + function esd(a,b){this.a=a;this.b=b;} + function gsd(a,b){this.a=a;this.b=b;} + function isd(a,b){this.a=a;this.b=b;} + function Osd(a,b){this.a=a;this.b=b;} + function Qsd(a,b){this.a=a;this.b=b;} + function Ssd(a,b){this.a=a;this.b=b;} + function Ptd(a,b){this.a=a;this.b=b;} + function JEd(a,b){this.a=a;this.b=b;} + function KEd(a,b){this.a=a;this.b=b;} + function MEd(a,b){this.a=a;this.b=b;} + function NEd(a,b){this.a=a;this.b=b;} + function QEd(a,b){this.a=a;this.b=b;} + function REd(a,b){this.a=a;this.b=b;} + function SEd(a,b){this.b=a;this.a=b;} + function TEd(a,b){this.b=a;this.a=b;} + function bFd(a,b){this.b=a;this.a=b;} + function dFd(a,b){this.b=a;this.a=b;} + function fFd(a,b){this.a=a;this.b=b;} + function hFd(a,b){this.a=a;this.b=b;} + function utd(a,b){qs.call(this,a,b);} + function sFd(a,b){this.a=a;this.b=b;} + function uFd(a,b){this.a=a;this.b=b;} + function bGd(a,b){qs.call(this,a,b);} + function uId(a,b){this.f=a;this.c=b;} + function Ofd(a,b){return Csb(a.g,b)} + function Tqc(a,b){return Csb(b.b,a)} + function HPd(a,b){return QNd(a.a,b)} + function Idd(a,b){return -a.b.af(b)} + function IId(a,b){!!a&&Zjb(CId,a,b);} + function yWd(a,b){a.i=null;zWd(a,b);} + function kEd(a,b,c){pDd(b,KDd(a,c));} + function lEd(a,b,c){pDd(b,KDd(a,c));} + function mFd(a,b){vEd(a.a,RD(b,58));} + function _Mc(a,b){GMc(a.a,RD(b,12));} + function KTd(a,b){this.a=a;this.b=b;} + function NTd(a,b){this.a=a;this.b=b;} + function B5d(a,b){this.a=a;this.b=b;} + function Z6d(a,b){this.a=a;this.b=b;} + function Ble(a,b){this.a=a;this.b=b;} + function afe(a,b){this.d=a;this.b=b;} + function wfe(a,b){this.e=a;this.a=b;} + function Eke(a,b){this.b=a;this.c=b;} + function zNd(a,b){this.i=a;this.g=b;} + function kZd(a,b){this.d=a;this.e=b;} + function ave(a,b){eve(new dMd(a),b);} + function Dke(a){return pge(a.c,a.b)} + function Wd(a){return !a?null:a.md()} + function dE(a){return a==null?null:a} + function bE(a){return typeof a===jve} + function $D(a){return typeof a===hve} + function _D(a){return typeof a===ive} + function Gdb(a,b){return Ddb(a,b)==0} + function Jdb(a,b){return Ddb(a,b)>=0} + function Pdb(a,b){return Ddb(a,b)!=0} + function ar(a,b){return zr(a.Kc(),b)} + function Qm(a,b){return a.Rd().Xb(b)} + function kg(a){ig(a);return a.d.gc()} + function fE(a){CFb(a==null);return a} + function Mhb(a,b){a.a+=''+b;return a} + function Nhb(a,b){a.a+=''+b;return a} + function Whb(a,b){a.a+=''+b;return a} + function Yhb(a,b){a.a+=''+b;return a} + function Zhb(a,b){a.a+=''+b;return a} + function Vhb(a,b){return a.a+=''+b,a} + function Pfb(a){return ''+(uFb(a),a)} + function Vsb(a){akb(this);Ld(this,a);} + function YFc(){RFc();UFc.call(this);} + function pxb(a,b){kxb.call(this,a,b);} + function txb(a,b){kxb.call(this,a,b);} + function xxb(a,b){kxb.call(this,a,b);} + function Oub(a,b){Pub(a,b,a.c.b,a.c);} + function Nub(a,b){Pub(a,b,a.a,a.a.a);} + function Iob(a){tFb(a,0);return null} + function Xvb(){this.b=0;this.a=false;} + function dwb(){this.b=0;this.a=false;} + function Et(){this.b=new Usb(Sv(12));} + function pMb(){pMb=geb;oMb=ss(nMb());} + function ncc(){ncc=geb;mcc=ss(lcc());} + function aZc(){aZc=geb;_Yc=ss($Yc());} + function WA(){WA=geb;vA();VA=new Tsb;} + function hjd(a){a.a=0;a.b=0;return a} + function qfd(a,b){a.a=b.g+1;return a} + function yNd(a,b){aMd.call(this,a,b);} + function lGd(a,b){kGd.call(this,a,b);} + function N$d(a,b){zNd.call(this,a,b);} + function Whe(a,b){Q2d.call(this,a,b);} + function She(a,b){Phe.call(this,a,b);} + function RRd(a,b){PRd();Zjb(ORd,a,b);} + function sB(a,b){a.q.setTime(Xdb(b));} + function Xz(a){$wnd.clearTimeout(a);} + function cr(a){return Qb(a),new Dl(a)} + function mb(a,b){return dE(a)===dE(b)} + function Mw(a,b){return a.a.a.a.cc(b)} + function qeb(a,b){return zhb(a.a,0,b)} + function SSb(a){return MSb(RD(a,74))} + function Nfb(a){return eE((uFb(a),a))} + function Ofb(a){return eE((uFb(a),a))} + function gD(a){return hD(a.l,a.m,a.h)} + function egb(a,b){return hgb(a.a,b.a)} + function ygb(a,b){return Agb(a.a,b.a)} + function Sfb(a,b){return Qfb(a.a,b.a)} + function qhb(a,b){return a.indexOf(b)} + function nOc(a,b){return a.j[b.p]==2} + function cz(a,b){return a==b?0:a?1:-1} + function AB(a){return a<10?'0'+a:''+a} + function Kdb(a){return typeof a===ive} + function oZb(a){return a==jZb||a==mZb} + function pZb(a){return a==jZb||a==kZb} + function ELb(a,b){return hgb(a.g,b.g)} + function Q4b(a){return Wmb(a.b.b,a,0)} + function Q2b(){J2b.call(this,0,0,0,0);} + function Iub(){ctb.call(this,new gub);} + function Znb(a,b){Wnb(a,0,a.length,b);} + function Eyb(a,b){Rmb(a.a,b);return b} + function Fkc(a,b){lkc();return b.a+=a} + function Hkc(a,b){lkc();return b.a+=a} + function Gkc(a,b){lkc();return b.c+=a} + function ied(a,b){Rmb(a.c,b);return a} + function Ped(a,b){ofd(a.a,b);return a} + function ttb(a){this.a=Itb();this.b=a;} + function Ntb(a){this.a=Itb();this.b=a;} + function sjd(a){this.a=a.a;this.b=a.b;} + function Dl(a){this.a=a;zl.call(this);} + function Gl(a){this.a=a;zl.call(this);} + function Tid(){Uid.call(this,0,0,0,0);} + function vfd(a){return ofd(new ufd,a)} + function Ksd(a){return iyd(RD(a,123))} + function Mvd(a){return a.vh()&&a.wh()} + function Dod(a){return a!=zod&&a!=Aod} + function Dmd(a){return a==ymd||a==zmd} + function Emd(a){return a==Bmd||a==xmd} + function xDc(a){return a==tDc||a==sDc} + function yrc(a,b){return hgb(a.g,b.g)} + function Yfe(a,b){return new Phe(b,a)} + function Zfe(a,b){return new Phe(b,a)} + function lr(a){return Dr(a.b.Kc(),a.a)} + function IXd(a,b){yXd(a,b);zXd(a,a.D);} + function Uxd(a,b,c){Vxd(a,b);Wxd(a,c);} + function zyd(a,b,c){Cyd(a,b);Ayd(a,c);} + function Byd(a,b,c){Dyd(a,b);Eyd(a,c);} + function Gzd(a,b,c){Hzd(a,b);Izd(a,c);} + function Nzd(a,b,c){Ozd(a,b);Pzd(a,c);} + function eh(a,b,c){bh.call(this,a,b,c);} + function zId(a){uId.call(this,a,true);} + function nAb(){dAb.call(this,'Tail',3);} + function iAb(){dAb.call(this,'Head',1);} + function ejb(a){Pib();fjb.call(this,a);} + function A3b(a){J2b.call(this,a,a,a,a);} + function Pmb(a){a.c=$C(jJ,rve,1,0,5,1);} + function yRb(a){a.b&&CRb(a);return a.a} + function zRb(a){a.b&&CRb(a);return a.c} + function mBb(a,b){if(dBb){return}a.b=b;} + function YCb(a,b){return a[a.length]=b} + function _Cb(a,b){return a[a.length]=b} + function l5b(a,b){return NGd(b,MCd(a))} + function m5b(a,b){return NGd(b,MCd(a))} + function DDd(a,b){return lp(Co(a.d),b)} + function EDd(a,b){return lp(Co(a.g),b)} + function FDd(a,b){return lp(Co(a.j),b)} + function mGd(a,b){kGd.call(this,a.b,b);} + function s0d(a,b){WGd(tYd(a.a),v0d(b));} + function B4d(a,b){WGd(o4d(a.a),E4d(b));} + function Asd(a,b,c){Byd(c,c.i+a,c.j+b);} + function eFc(a,b,c){bD(a.c[b.g],b.g,c);} + function zVd(a,b,c){RD(a.c,71).Gi(b,c);} + function LMd(a,b,c){bD(a,b,c);return c} + function DJb(a){Umb(a.Sf(),new HJb(a));} + function Gvb(a){return a!=null?tb(a):0} + function aOd(a){return a==null?0:tb(a)} + function iue(a){Vse();Wse.call(this,a);} + function Ug(a){this.a=a;Og.call(this,a);} + function Zy(){Zy=geb;$wnd.Math.log(2);} + function s7d(){s7d=geb;r7d=($Sd(),ZSd);} + function FRc(){FRc=geb;ERc=new Zrb(u3);} + function Hde(){Hde=geb;new Ide;new bnb;} + function Ide(){new Tsb;new Tsb;new Tsb;} + function yue(){throw Adb(new kib(bMe))} + function Nue(){throw Adb(new kib(bMe))} + function Bue(){throw Adb(new kib(cMe))} + function Que(){throw Adb(new kib(cMe))} + function Gp(a){this.a=a;rf.call(this,a);} + function Np(a){this.a=a;rf.call(this,a);} + function Sq(a,b){tm();this.a=a;this.b=b;} + function Jh(a,b){Qb(b);Ih(a).Jc(new jx);} + function _mb(a,b){Ynb(a.c,a.c.length,b);} + function xnb(a){return a.ab?1:0} + function Kgb(a,b){return Ddb(a,b)>0?a:b} + function hD(a,b,c){return {l:a,m:b,h:c}} + function Mvb(a,b){a.a!=null&&_Mc(b,a.a);} + function Lhc(a){Y0b(a,null);Z0b(a,null);} + function xkc(a,b,c){return Zjb(a.g,c,b)} + function bFc(a,b,c){return _Ec(b,c,a.c)} + function jOc(a,b,c){return Zjb(a.k,c,b)} + function pOc(a,b,c){qOc(a,b,c);return c} + function FOc(a,b){dOc();return b.n.b+=a} + function lUb(a){VTb.call(this);this.b=a;} + function y2b(a){v2b.call(this);this.a=a;} + function kAb(){dAb.call(this,'Range',2);} + function $Fb(a){this.b=a;this.a=new bnb;} + function WQb(a){this.b=new gRb;this.a=a;} + function Lub(a){a.a=new svb;a.c=new svb;} + function nrc(a){a.a=new Tsb;a.d=new Tsb;} + function $Sc(a){_Sc(a,null);aTc(a,null);} + function a2d(a,b){return xA(a.a,b,null)} + function Cdd(a,b){return Zjb(a.a,b.a,b)} + function ajd(a){return new rjd(a.a,a.b)} + function Pid(a){return new rjd(a.c,a.d)} + function Qid(a){return new rjd(a.c,a.d)} + function Ake(a,b){return Tfe(a.c,a.b,b)} + function ZD(a,b){return a!=null&&QD(a,b)} + function br(a,b){return Jr(a.Kc(),b)!=-1} + function Hr(a){return a.Ob()?a.Pb():null} + function _p(a){this.b=(yob(),new uqb(a));} + function zke(a){this.a=a;Tsb.call(this);} + function Uhe(){Q2d.call(this,null,null);} + function Yhe(){p3d.call(this,null,null);} + function As(){qs.call(this,'INSTANCE',0);} + function dXb(){_Wb();this.a=new Wed(UP);} + function Hhb(a){return Ihb(a,0,a.length)} + function Rv(a,b){return new ew(a.Kc(),b)} + function $sb(a,b){return a.a.Bc(b)!=null} + function hZd(a,b){sLd(a);a.Gc(RD(b,15));} + function ONd(a,b,c){a.c.bd(b,RD(c,136));} + function eOd(a,b,c){a.c.Ui(b,RD(c,136));} + function eub(a,b){if(a.c){rub(b);qub(b);}} + function oB(a,b){a.q.setHours(b);mB(a,b);} + function vTb(a,b){Zid(b,a.a.a.a,a.a.a.b);} + function tKb(a,b,c,d){bD(a.a[b.g],c.g,d);} + function oKb(a,b,c){return a.a[b.g][c.g]} + function AIc(a,b){return a.e[b.c.p][b.p]} + function TIc(a,b){return a.c[b.c.p][b.p]} + function pJc(a,b){return a.a[b.c.p][b.p]} + function mOc(a,b){return a.j[b.p]=AOc(b)} + function wAb(a,b){return a.a.Bc(b)!=null} + function wXc(a,b){return Kfb(UD(b.a))<=a} + function xXc(a,b){return Kfb(UD(b.a))>=a} + function vhd(a,b){return jhb(a.f,b.Pg())} + function cjd(a,b){return a.a*b.a+a.b*b.b} + function Wsd(a,b){return a.a0?b/(a*a):b*100} + function FUb(a,b){return a>0?b*b/a:b*b*100} + function $5b(a,b){return RD(cub(a.a,b),34)} + function doc(a,b){Mnc();return Rc(a,b.e,b)} + function NCc(a,b,c){GCc();return c.Mg(a,b)} + function L0c(a){B0c();return a.e.a+a.f.a/2} + function N0c(a,b,c){B0c();return c.e.a-a*b} + function V0c(a){B0c();return a.e.b+a.f.b/2} + function X0c(a,b,c){B0c();return c.e.b-a*b} + function _tb(a){a.d=new tub(a);a.e=new Tsb;} + function x3c(){this.a=new Tp;this.b=new Tp;} + function hmc(a){this.c=a;this.a=1;this.b=1;} + function C$b(a){z$b();A$b(this);this.Ff(a);} + function Efd(a,b,c){Afd();a.pf(b)&&c.Cd(a);} + function Red(a,b,c){return Rmb(b,Ted(a,c))} + function Zid(a,b,c){a.a+=b;a.b+=c;return a} + function jjd(a,b,c){a.a*=b;a.b*=c;return a} + function mjd(a,b){a.a=b.a;a.b=b.b;return a} + function fjd(a){a.a=-a.a;a.b=-a.b;return a} + function njd(a,b,c){a.a-=b;a.b-=c;return a} + function Gjd(a){Yub.call(this);zjd(this,a);} + function Dbd(){qs.call(this,'GROW_TREE',0);} + function WRb(){qs.call(this,'POLYOMINO',0);} + function SVd(a,b,c){DVd.call(this,a,b,c,2);} + function r0d(a,b,c){VGd(tYd(a.a),b,v0d(c));} + function e3d(a,b){N2d();Q2d.call(this,a,b);} + function D3d(a,b){j3d();p3d.call(this,a,b);} + function F3d(a,b){j3d();D3d.call(this,a,b);} + function H3d(a,b){j3d();p3d.call(this,a,b);} + function PNd(a,b){return a.c.Fc(RD(b,136))} + function A4d(a,b,c){VGd(o4d(a.a),b,E4d(c));} + function Ard(a){this.c=a;Dyd(a,0);Eyd(a,0);} + function Z8d(a,b){s7d();N8d.call(this,a,b);} + function _8d(a,b){s7d();Z8d.call(this,a,b);} + function b9d(a,b){s7d();Z8d.call(this,a,b);} + function n9d(a,b){s7d();N8d.call(this,a,b);} + function d9d(a,b){s7d();b9d.call(this,a,b);} + function p9d(a,b){s7d();n9d.call(this,a,b);} + function v9d(a,b){s7d();N8d.call(this,a,b);} + function lge(a,b,c){return b.zl(a.e,a.c,c)} + function nge(a,b,c){return b.Al(a.e,a.c,c)} + function Wee(a,b,c){return tfe(Pee(a,b),c)} + function Age(a,b){return Vvd(a.e,RD(b,54))} + function _me(a){return a==null?null:Bqe(a)} + function dne(a){return a==null?null:Iqe(a)} + function gne(a){return a==null?null:jeb(a)} + function hne(a){return a==null?null:jeb(a)} + function TD(a){CFb(a==null||$D(a));return a} + function UD(a){CFb(a==null||_D(a));return a} + function WD(a){CFb(a==null||bE(a));return a} + function lfb(a){if(a.o!=null){return}Bfb(a);} + function lFb(a){if(!a){throw Adb(new _fb)}} + function pFb(a){if(!a){throw Adb(new yeb)}} + function sFb(a){if(!a){throw Adb(new Dvb)}} + function yFb(a){if(!a){throw Adb(new cgb)}} + function zmb(a){if(!a){throw Adb(new Jrb)}} + function jQd(){jQd=geb;iQd=new LQd;new lRd;} + function u2c(){u2c=geb;t2c=new jGd('root');} + function d6d(){HWd.call(this);this.Bb|=txe;} + function Pg(a,b){this.d=a;Lg(this);this.b=b;} + function WCb(a,b){NCb.call(this,a);this.a=b;} + function oDb(a,b){NCb.call(this,a);this.a=b;} + function bh(a,b,c){lg.call(this,a,b,c,null);} + function fh(a,b,c){lg.call(this,a,b,c,null);} + function Mf(a,b){this.c=a;ne.call(this,a,b);} + function Uf(a,b){this.a=a;Mf.call(this,a,b);} + function wB(a){this.q=new $wnd.Date(Xdb(a));} + function OPb(a){if(a>8){return 0}return a+1} + function iBb(a,b){if(dBb){return}Rmb(a.a,b);} + function P5b(a,b){H5b();return n2b(b.d.i,a)} + function qdc(a,b){Zcc();return new xdc(b,a)} + function HAb(a,b,c){return a.Ne(b,c)<=0?c:b} + function IAb(a,b,c){return a.Ne(b,c)<=0?b:c} + function rgd(a,b){return RD(cub(a.b,b),143)} + function tgd(a,b){return RD(cub(a.c,b),233)} + function amc(a){return RD(Vmb(a.a,a.b),294)} + function Mid(a){return new rjd(a.c,a.d+a.a)} + function Jeb(a){return (uFb(a),a)?1231:1237} + function EPc(a){return dOc(),xDc(RD(a,203))} + function RMb(){RMb=geb;QMb=xsb((Qpd(),Ppd));} + function YQb(a,b){b.a?ZQb(a,b):wAb(a.a,b.b);} + function aJd(a,b,c){++a.j;a.tj();$Gd(a,b,c);} + function $Id(a,b,c){++a.j;a.qj(b,a.Zi(b,c));} + function B2d(a,b,c){var d;d=a.fd(b);d.Rb(c);} + function Bzd(a,b,c){c=xvd(a,b,6,c);return c} + function izd(a,b,c){c=xvd(a,b,3,c);return c} + function KCd(a,b,c){c=xvd(a,b,9,c);return c} + function SKb(a,b){Ivb(b,Pye);a.f=b;return a} + function bOd(a,b){return (b&lve)%a.d.length} + function Bke(a,b,c){return age(a.c,a.b,b,c)} + function ZLd(a,b){this.c=a;ZHd.call(this,b);} + function w0d(a,b){this.a=a;Q_d.call(this,b);} + function F4d(a,b){this.a=a;Q_d.call(this,b);} + function kGd(a,b){jGd.call(this,a);this.a=b;} + function U6d(a,b){L6d.call(this,a);this.a=b;} + function S9d(a,b){L6d.call(this,a);this.a=b;} + function jQb(a){gQb.call(this,0,0);this.f=a;} + function _hb(a,b,c){a.a+=Ihb(b,0,c);return a} + function _A(a){!a.a&&(a.a=new jB);return a.a} + function qlb(a,b){var c;c=a.e;a.e=b;return c} + function Clb(a,b){var c;c=b;return !!a.Fe(c)} + function Keb(a,b){Geb();return a==b?0:a?1:-1} + function Ikb(a,b){a.a.bd(a.b,b);++a.b;a.c=-1;} + function hg(a){a.b?hg(a.b):a.f.c.zc(a.e,a.d);} + function aub(a){akb(a.e);a.d.b=a.d;a.d.a=a.d;} + function VDb(a,b,c){xDb();HEb(a,b.Ve(a.a,c));} + function Xrb(a,b,c){return Wrb(a,RD(b,22),c)} + function WEb(a,b){return cFb(new Array(b),a)} + function Fgb(a){return Ydb(Udb(a,32))^Ydb(a)} + function XD(a){return String.fromCharCode(a)} + function Dz(a){return a==null?null:a.message} + function Rz(a,b,c){return a.apply(b,c);} + function Btb(a,b){var c;c=a[Jxe];c.call(a,b);} + function Ctb(a,b){var c;c=a[Jxe];c.call(a,b);} + function O5b(a,b){H5b();return !n2b(b.d.i,a)} + function R2b(a,b,c,d){J2b.call(this,a,b,c,d);} + function TJb(){RJb.call(this);this.a=new pjd;} + function v2b(){this.n=new pjd;this.o=new pjd;} + function kGb(){this.b=new pjd;this.c=new bnb;} + function cUb(){this.a=new bnb;this.b=new bnb;} + function kWb(){this.a=new DTb;this.b=new vWb;} + function e6b(){this.b=new gub;this.a=new gub;} + function jIc(){this.b=new _sb;this.a=new _sb;} + function vYc(){this.b=new Tsb;this.a=new Tsb;} + function fWc(){this.b=new TVc;this.a=new IVc;} + function Yhc(){this.a=new yqc;this.b=new Sqc;} + function lNc(){this.a=new bnb;this.d=new bnb;} + function RJb(){this.n=new z3b;this.i=new Tid;} + function hq(a){this.a=(dk(a,iwe),new cnb(a));} + function oq(a){this.a=(dk(a,iwe),new cnb(a));} + function tLd(a){return a<100?null:new gLd(a)} + function Lac(a,b){return a.n.a=(uFb(b),b)+10} + function Mac(a,b){return a.n.a=(uFb(b),b)+10} + function DYd(a,b){return b==a||PHd(sYd(b),a)} + function nae(a,b){return Zjb(a.a,b,'')==null} + function Hee(a,b){var c;c=b.qi(a.a);return c} + function $id(a,b){a.a+=b.a;a.b+=b.b;return a} + function ojd(a,b){a.a-=b.a;a.b-=b.b;return a} + function sfd(a){aFb(a.j.c,0);a.a=-1;return a} + function rCd(a,b,c){c=xvd(a,b,11,c);return c} + function SDd(a,b,c){c!=null&&Kzd(b,uEd(a,c));} + function TDd(a,b,c){c!=null&&Lzd(b,uEd(a,c));} + function G5d(a,b,c,d){C5d.call(this,a,b,c,d);} + function oie(a,b,c,d){C5d.call(this,a,b,c,d);} + function sie(a,b,c,d){oie.call(this,a,b,c,d);} + function Nie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Pie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Vie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Tie(a,b,c,d){Pie.call(this,a,b,c,d);} + function $ie(a,b,c,d){Pie.call(this,a,b,c,d);} + function Yie(a,b,c,d){Vie.call(this,a,b,c,d);} + function bje(a,b,c,d){$ie.call(this,a,b,c,d);} + function Dje(a,b,c,d){wje.call(this,a,b,c,d);} + function aMd(a,b){veb.call(this,HJe+a+NIe+b);} + function Hje(a,b){return a.jk().wi().ri(a,b)} + function Ije(a,b){return a.jk().wi().ti(a,b)} + function Lfb(a,b){return uFb(a),dE(a)===dE(b)} + function lhb(a,b){return uFb(a),dE(a)===dE(b)} + function mEb(a,b){return a.b.Bd(new pEb(a,b))} + function sEb(a,b){return a.b.Bd(new vEb(a,b))} + function yEb(a,b){return a.b.Bd(new BEb(a,b))} + function Bk(a,b){return a.e=RD(a.d.Kb(b),159)} + function uhb(a,b,c){return a.lastIndexOf(b,c)} + function wWb(a,b,c){return Qfb(a[b.a],a[c.a])} + function TWb(a,b){return pQb(b,(yCc(),gAc),a)} + function Lpc(a,b){return hgb(b.a.d.p,a.a.d.p)} + function Kpc(a,b){return hgb(a.a.d.p,b.a.d.p)} + function zTc(a,b){return Qfb(a.c-a.s,b.c-b.s)} + function qWc(a,b){return Qfb(a.b.e.a,b.b.e.a)} + function sWc(a,b){return Qfb(a.c.e.a,b.c.e.a)} + function $2b(a){return !a.c?-1:Wmb(a.c.a,a,0)} + function Cod(a){return a==vod||a==xod||a==wod} + function CMd(a,b){this.c=a;nMd.call(this,a,b);} + function fq(a,b,c){this.a=a;qc.call(this,b,c);} + function YDb(a){this.c=a;xxb.call(this,Sve,0);} + function rk(a,b,c){this.c=b;this.b=c;this.a=a;} + function DMc(a){dMc();this.d=a;this.a=new wmb;} + function ho(a){_l();this.a=(yob(),new Lqb(a));} + function Xmc(a,b){Dmd(a.f)?Ymc(a,b):Zmc(a,b);} + function Lxb(a,b){Mxb.call(this,a,a.length,b);} + function nBb(a,b){if(dBb){return}!!b&&(a.d=b);} + function ZNd(a,b){return ZD(b,15)&&_Gd(a.c,b)} + function AVd(a,b,c){return RD(a.c,71).Wk(b,c)} + function BVd(a,b,c){return RD(a.c,71).Xk(b,c)} + function mge(a,b,c){return lge(a,RD(b,343),c)} + function oge(a,b,c){return nge(a,RD(b,343),c)} + function Ige(a,b,c){return Hge(a,RD(b,343),c)} + function Kge(a,b,c){return Jge(a,RD(b,343),c)} + function Fn(a,b){return b==null?null:Xv(a.b,b)} + function Qeb(a){return _D(a)?(uFb(a),a):a.ue()} + function Rfb(a){return !isNaN(a)&&!isFinite(a)} + function Zub(a){Lub(this);Xub(this);ye(this,a);} + function dnb(a){Pmb(this);YEb(this.c,0,a.Pc());} + function Fsb(a,b,c){this.a=a;this.b=b;this.c=c;} + function Vtb(a,b,c){this.a=a;this.b=b;this.c=c;} + function hvb(a,b,c){this.d=a;this.b=c;this.a=b;} + function aBb(a){this.a=a;gib();Hdb(Date.now());} + function wzb(a){Ckb(a.a);Yyb(a.c,a.b);a.b=null;} + function wvb(){wvb=geb;uvb=new xvb;vvb=new zvb;} + function KMd(){KMd=geb;JMd=$C(jJ,rve,1,0,5,1);} + function TTd(){TTd=geb;STd=$C(jJ,rve,1,0,5,1);} + function yUd(){yUd=geb;xUd=$C(jJ,rve,1,0,5,1);} + function _l(){_l=geb;new im((yob(),yob(),vob));} + function gAb(a){cAb();return ws((qAb(),pAb),a)} + function zBb(a){xBb();return ws((CBb(),BBb),a)} + function FHb(a){DHb();return ws((IHb(),HHb),a)} + function NHb(a){LHb();return ws((QHb(),PHb),a)} + function kIb(a){iIb();return ws((nIb(),mIb),a)} + function _Jb(a){ZJb();return ws((cKb(),bKb),a)} + function GKb(a){EKb();return ws((JKb(),IKb),a)} + function xLb(a){vLb();return ws((ALb(),zLb),a)} + function mMb(a){hMb();return ws((pMb(),oMb),a)} + function oOb(a){mOb();return ws((rOb(),qOb),a)} + function KPb(a){IPb();return ws((NPb(),MPb),a)} + function KRb(a){IRb();return ws((NRb(),MRb),a)} + function XRb(a){VRb();return ws(($Rb(),ZRb),a)} + function VUb(a){TUb();return ws((YUb(),XUb),a)} + function CWb(a){AWb();return ws((FWb(),EWb),a)} + function uXb(a){sXb();return ws((xXb(),wXb),a)} + function tZb(a){nZb();return ws((wZb(),vZb),a)} + function W$b(a){U$b();return ws((Z$b(),Y$b),a)} + function Mb(a,b){if(!a){throw Adb(new agb(b))}} + function Vb(a){if(!a){throw Adb(new dgb(tve))}} + function rFb(a,b){if(a!=b){throw Adb(new Jrb)}} + function KQb(a,b,c){this.a=a;this.b=b;this.c=c;} + function lRb(a,b,c){this.a=a;this.b=b;this.c=c;} + function h7b(a,b,c){this.a=a;this.b=b;this.c=c;} + function J0b(a,b,c){this.b=a;this.a=b;this.c=c;} + function dNb(a,b,c){this.b=a;this.c=b;this.a=c;} + function oac(a,b,c){this.a=a;this.b=b;this.c=c;} + function F1b(a,b,c){this.e=b;this.b=a;this.d=c;} + function Ecc(a,b,c){this.b=a;this.a=b;this.c=c;} + function UDb(a,b,c){xDb();a.a.Yd(b,c);return b} + function CJb(a){var b;b=new BJb;b.e=a;return b} + function _Nb(a){var b;b=new YNb;b.b=a;return b} + function U9b(){U9b=geb;S9b=new bac;T9b=new eac;} + function Rec(){Rec=geb;Qec=new efc;Pec=new jfc;} + function lkc(){lkc=geb;jkc=new Mkc;kkc=new Okc;} + function loc(a){joc();return ws((ooc(),noc),a)} + function kcc(a){hcc();return ws((ncc(),mcc),a)} + function yec(a){vec();return ws((Bec(),Aec),a)} + function gnc(a){enc();return ws((jnc(),inc),a)} + function Enc(a){Bnc();return ws((Hnc(),Gnc),a)} + function gpc(a){epc();return ws((jpc(),ipc),a)} + function dtc(a){btc();return ws((gtc(),ftc),a)} + function ltc(a){jtc();return ws((otc(),ntc),a)} + function xtc(a){stc();return ws((Atc(),ztc),a)} + function Gtc(a){Etc();return ws((Jtc(),Itc),a)} + function Utc(a){Ptc();return ws((Xtc(),Wtc),a)} + function auc(a){$tc();return ws((duc(),cuc),a)} + function avc(a){$uc();return ws((dvc(),cvc),a)} + function qvc(a){ovc();return ws((tvc(),svc),a)} + function zvc(a){xvc();return ws((Cvc(),Bvc),a)} + function Ivc(a){Gvc();return ws((Lvc(),Kvc),a)} + function Qvc(a){Ovc();return ws((Tvc(),Svc),a)} + function Quc(a){Ouc();return ws((Tuc(),Suc),a)} + function juc(a){huc();return ws((muc(),luc),a)} + function wuc(a){tuc();return ws((zuc(),yuc),a)} + function Euc(a){Cuc();return ws((Huc(),Guc),a)} + function exc(a){cxc();return ws((hxc(),gxc),a)} + function eDc(a){_Cc();return ws((hDc(),gDc),a)} + function oDc(a){lDc();return ws((rDc(),qDc),a)} + function ADc(a){wDc();return ws((DDc(),CDc),a)} + function ODc(a){JDc();return ws((RDc(),QDc),a)} + function cEc(a){aEc();return ws((fEc(),eEc),a)} + function mEc(a){kEc();return ws((pEc(),oEc),a)} + function uEc(a){sEc();return ws((xEc(),wEc),a)} + function DEc(a){BEc();return ws((GEc(),FEc),a)} + function MEc(a){KEc();return ws((PEc(),OEc),a)} + function VEc(a){TEc();return ws((YEc(),XEc),a)} + function nFc(a){lFc();return ws((qFc(),pFc),a)} + function wFc(a){uFc();return ws((zFc(),yFc),a)} + function FFc(a){DFc();return ws((IFc(),HFc),a)} + function TKc(a){RKc();return ws((WKc(),VKc),a)} + function uNc(a){sNc();return ws((xNc(),wNc),a)} + function yQc(a){wQc();return ws((BQc(),AQc),a)} + function GQc(a){EQc();return ws((JQc(),IQc),a)} + function hTc(a){fTc();return ws((kTc(),jTc),a)} + function fVc(a){dVc();return ws((iVc(),hVc),a)} + function bWc(a){YVc();return ws((eWc(),dWc),a)} + function ZYc(a){WYc();return ws((aZc(),_Yc),a)} + function NZc(a){LZc();return ws((QZc(),PZc),a)} + function u_c(a){s_c();return ws((x_c(),w_c),a)} + function C_c(a){A_c();return ws((F_c(),E_c),a)} + function C2c(a){x2c();return ws((F2c(),E2c),a)} + function j3c(a){g3c();return ws((m3c(),l3c),a)} + function j4c(a){g4c();return ws((m4c(),l4c),a)} + function _3c(a){Y3c();return ws((c4c(),b4c),a)} + function m5c(a){j5c();return ws((p5c(),o5c),a)} + function w5c(a){t5c();return ws((z5c(),y5c),a)} + function h6c(a){f6c();return ws((k6c(),j6c),a)} + function C6c(a){z6c();return ws((F6c(),E6c),a)} + function b7c(a){_6c();return ws((e7c(),d7c),a)} + function E8c(a){z8c();return ws((H8c(),G8c),a)} + function R8b(a){P8b();return ws((U8b(),T8b),a)} + function t3b(a){r3b();return ws((w3b(),v3b),a)} + function g9c(a){b9c();return ws((j9c(),i9c),a)} + function G9c(a){B9c();return ws((J9c(),I9c),a)} + function uad(a){sad();return ws((xad(),wad),a)} + function xbd(a){sbd();return ws((Abd(),zbd),a)} + function ibd(a){gbd();return ws((lbd(),kbd),a)} + function Gbd(a){Cbd();return ws((Jbd(),Ibd),a)} + function Obd(a){Mbd();return ws((Rbd(),Qbd),a)} + function Zbd(a){Xbd();return ws((acd(),_bd),a)} + function fdd(a){_cd();return ws((idd(),hdd),a)} + function qdd(a){ldd();return ws((tdd(),sdd),a)} + function $hd(a){Yhd();return ws((bid(),aid),a)} + function mid(a){kid();return ws((pid(),oid),a)} + function Tjd(a){Rjd();return ws((Wjd(),Vjd),a)} + function wkd(a){ukd();return ws((zkd(),ykd),a)} + function Hmd(a){Cmd();return ws((Kmd(),Jmd),a)} + function Qmd(a){Omd();return ws((Tmd(),Smd),a)} + function $md(a){Ymd();return ws((bnd(),and),a)} + function knd(a){ind();return ws((nnd(),mnd),a)} + function Hnd(a){Fnd();return ws((Knd(),Jnd),a)} + function Snd(a){Pnd();return ws((Vnd(),Und),a)} + function god(a){dod();return ws((jod(),iod),a)} + function rod(a){pod();return ws((uod(),tod),a)} + function Fod(a){Bod();return ws((Iod(),Hod),a)} + function Tod(a){Pod();return ws((Wod(),Vod),a)} + function wpd(a){qpd();return ws((zpd(),ypd),a)} + function Spd(a){Qpd();return ws((Vpd(),Upd),a)} + function fqd(a){dqd();return ws((iqd(),hqd),a)} + function oqd(a){mqd();return ws((rqd(),qqd),a)} + function zsc(a,b){return (uFb(a),a)+(uFb(b),b)} + function wqd(a){uqd();return ws((Eqd(),Dqd),a)} + function Ird(a){Grd();return ws((Lrd(),Krd),a)} + function vtd(a){ttd();return ws((ytd(),xtd),a)} + function dMc(){dMc=geb;bMc=(qpd(),ppd);cMc=Xod;} + function uqd(){uqd=geb;sqd=new zqd;tqd=new Bqd;} + function wJc(a){!a.e&&(a.e=new bnb);return a.e} + function BTc(a,b){this.c=a;this.a=b;this.b=b-a;} + function g8c(a,b,c){this.a=a;this.b=b;this.c=c;} + function gud(a,b,c){this.a=a;this.b=b;this.c=c;} + function Wdd(a,b,c){this.a=a;this.b=b;this.c=c;} + function ced(a,b,c){this.a=a;this.b=b;this.c=c;} + function pFd(a,b,c){this.a=a;this.b=b;this.c=c;} + function ZPd(a,b,c){this.a=a;this.b=b;this.c=c;} + function g7d(a,b,c){this.e=a;this.a=b;this.c=c;} + function K7d(a,b,c){s7d();C7d.call(this,a,b,c);} + function f9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function r9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function x9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function h9d(a,b,c){s7d();f9d.call(this,a,b,c);} + function j9d(a,b,c){s7d();f9d.call(this,a,b,c);} + function l9d(a,b,c){s7d();j9d.call(this,a,b,c);} + function t9d(a,b,c){s7d();r9d.call(this,a,b,c);} + function z9d(a,b,c){s7d();x9d.call(this,a,b,c);} + function S2b(a){J2b.call(this,a.d,a.c,a.a,a.b);} + function B3b(a){J2b.call(this,a.d,a.c,a.a,a.b);} + function Og(a){this.d=a;Lg(this);this.b=ed(a.d);} + function cGd(a){aGd();return ws((fGd(),eGd),a)} + function gk(a,b){Qb(a);Qb(b);return new hk(a,b)} + function dr(a,b){Qb(a);Qb(b);return new mr(a,b)} + function hr(a,b){Qb(a);Qb(b);return new sr(a,b)} + function Dr(a,b){Qb(a);Qb(b);return new Rr(a,b)} + function Uub(a){sFb(a.b!=0);return Wub(a,a.a.a)} + function Vub(a){sFb(a.b!=0);return Wub(a,a.c.b)} + function q$d(a){!a.c&&(a.c=new X9d);return a.c} + function cv(a){var b;b=new bnb;xr(b,a);return b} + function Vx(a){var b;b=new _sb;xr(b,a);return b} + function Yx(a){var b;b=new xAb;_q(b,a);return b} + function gv(a){var b;b=new Yub;_q(b,a);return b} + function RD(a,b){CFb(a==null||QD(a,b));return a} + function Mxb(a,b,c){Axb.call(this,b,c);this.a=a;} + function kB(a,b){this.c=a;this.b=b;this.a=false;} + function hCb(){this.a=';,;';this.b='';this.c='';} + function $Cb(a,b,c){this.b=a;pxb.call(this,b,c);} + function uub(a,b,c){this.c=a;xlb.call(this,b,c);} + function fZb(a,b,c){eZb.call(this,a,b);this.b=c;} + function YEb(a,b,c){VEb(c,0,a,b,c.length,false);} + function JYb(a,b,c,d,e){a.b=b;a.c=c;a.d=d;a.a=e;} + function D2b(a,b,c,d,e){a.d=b;a.c=c;a.a=d;a.b=e;} + function XDb(a,b){if(b){a.b=b;a.a=(LCb(b),b.a);}} + function mFb(a,b){if(!a){throw Adb(new agb(b))}} + function zFb(a,b){if(!a){throw Adb(new dgb(b))}} + function qFb(a,b){if(!a){throw Adb(new zeb(b))}} + function zqc(a,b){mqc();return hgb(a.d.p,b.d.p)} + function T0c(a,b){B0c();return Qfb(a.e.b,b.e.b)} + function U0c(a,b){B0c();return Qfb(a.e.a,b.e.a)} + function Xoc(a,b){return hgb(N3b(a.d),N3b(b.d))} + function Izb(a,b){return !!b&&Jzb(a,b.d)?b:null} + function $lc(a,b){return b==(qpd(),ppd)?a.c:a.d} + function Qdb(a){return Edb(yD(Kdb(a)?Wdb(a):a))} + function Nid(a){return new rjd(a.c+a.b,a.d+a.a)} + function GSd(a){return a!=null&&!mSd(a,aSd,bSd)} + function DSd(a,b){return (JSd(a)<<4|JSd(b))&Bwe} + function Rid(a,b,c,d,e){a.c=b;a.d=c;a.b=d;a.a=e;} + function y8b(a){var b,c;b=a.b;c=a.c;a.b=c;a.c=b;} + function B8b(a){var b,c;c=a.d;b=a.a;a.d=b;a.a=c;} + function u6d(a,b){var c;c=a.c;t6d(a,b);return c} + function Nqd(a,b){b<0?(a.g=-1):(a.g=b);return a} + function kjd(a,b){gjd(a);a.a*=b;a.b*=b;return a} + function hrc(a,b,c){grc.call(this,b,c);this.d=a;} + function PZd(a,b,c){kZd.call(this,a,b);this.c=c;} + function Kfe(a,b,c){kZd.call(this,a,b);this.c=c;} + function zUd(a){yUd();kUd.call(this);this.ci(a);} + function Yee(){ree();Zee.call(this,(YSd(),XSd));} + function Yse(a){Vse();return new Hte(0,a)} + function uke(){uke=geb;tke=(yob(),new mpb(eLe));} + function ux(){ux=geb;new wx((kl(),jl),(Wk(),Vk));} + function ugb(){ugb=geb;tgb=$C(bJ,Nve,17,256,0,1);} + function zUb(){this.b=Kfb(UD(iGd((yVb(),sVb))));} + function Pq(a){this.b=a;this.a=gn(this.b.a).Od();} + function mr(a,b){this.b=a;this.a=b;zl.call(this);} + function sr(a,b){this.a=a;this.b=b;zl.call(this);} + function s_d(a,b,c){this.a=a;N$d.call(this,b,c);} + function n_d(a,b,c){this.a=a;N$d.call(this,b,c);} + function sDd(a,b,c){var d;d=new OC(c);sC(a,b,d);} + function _Eb(a,b,c){var d;d=a[b];a[b]=c;return d} + function UEb(a){var b;b=a.slice();return dD(b,a)} + function SJb(a){var b;b=a.n;return a.a.b+b.d+b.a} + function PKb(a){var b;b=a.n;return a.e.b+b.d+b.a} + function QKb(a){var b;b=a.n;return a.e.a+b.b+b.c} + function rub(a){a.a.b=a.b;a.b.a=a.a;a.a=a.b=null;} + function Mub(a,b){Pub(a,b,a.c.b,a.c);return true} + function w2b(a){if(a.a){return a.a}return R0b(a)} + function NSb(a){HSb();return JGd(a)==vCd(LGd(a))} + function OSb(a){HSb();return LGd(a)==vCd(JGd(a))} + function l_b(a,b){return k_b(a,new eZb(b.a,b.b))} + function xn(a,b){return fn(),ck(a,b),new zy(a,b)} + function fmc(a,b){return a.c=b){throw Adb(new web)}} + function JDb(a,b){return MDb(a,(uFb(b),new JAb(b)))} + function KDb(a,b){return MDb(a,(uFb(b),new LAb(b)))} + function prc(a,b,c){return qrc(a,RD(b,12),RD(c,12))} + function q4b(a){return J3b(),RD(a,12).g.c.length!=0} + function v4b(a){return J3b(),RD(a,12).e.c.length!=0} + function sdc(a,b){Zcc();return Qfb(b.a.o.a,a.a.o.a)} + function d_d(a,b){(b.Bb&QHe)!=0&&!a.a.o&&(a.a.o=b);} + function T3c(a,b){b.Ug("General 'Rotator",1);S3c(a);} + function MCc(a,b,c){b.qf(c,Kfb(UD(Wjb(a.b,c)))*a.a);} + function yid(a,b,c){tid();return xid(a,b)&&xid(a,c)} + function Rod(a){Pod();return !a.Hc(Lod)&&!a.Hc(Nod)} + function Nrc(a){if(a.e){return Src(a.e)}return null} + function Zdb(a){if(Kdb(a)){return ''+a}return GD(a)} + function XNc(a){var b;b=a;while(b.f){b=b.f;}return b} + function HBb(a,b,c){bD(b,0,tCb(b[0],c[0]));return b} + function Gpc(a,b,c,d){var e;e=a.i;e.i=b;e.a=c;e.b=d;} + function C5d(a,b,c,d){XZd.call(this,a,b,c);this.b=d;} + function N3d(a,b,c,d,e){O3d.call(this,a,b,c,d,e,-1);} + function b4d(a,b,c,d,e){c4d.call(this,a,b,c,d,e,-1);} + function Iie(a,b,c,d){PZd.call(this,a,b,c);this.b=d;} + function Xde(a){uId.call(this,a,false);this.a=false;} + function Bqd(){vqd.call(this,'LOOKAHEAD_LAYOUT',1);} + function nNd(a){this.b=a;mMd.call(this,a);mNd(this);} + function vNd(a){this.b=a;BMd.call(this,a);uNd(this);} + function J5d(a,b,c){this.a=a;G5d.call(this,b,c,5,6);} + function wje(a,b,c,d){this.b=a;XZd.call(this,b,c,d);} + function Tj(a,b){this.b=a;Aj.call(this,a.b);this.a=b;} + function NLc(a){this.a=LLc(a.a);this.b=new dnb(a.b);} + function Fx(a,b){tm();Ex.call(this,a,Pm(new mob(b)));} + function _se(a,b){Vse();return new aue(a,b,0)} + function bte(a,b){Vse();return new aue(6,a,b)} + function Ztb(a,b){uFb(b);while(a.Ob()){b.Cd(a.Pb());}} + function Ujb(a,b){return bE(b)?Yjb(a,b):!!qtb(a.f,b)} + function O_d(a,b){return b.Vh()?Vvd(a.b,RD(b,54)):b} + function whb(a,b){return lhb(a.substr(0,b.length),b)} + function Fl(a){return new is(new Il(a.a.length,a.a))} + function Oid(a){return new rjd(a.c+a.b/2,a.d+a.a/2)} + function yD(a){return hD(~a.l&dxe,~a.m&dxe,~a.h&exe)} + function cE(a){return typeof a===gve||typeof a===kve} + function akb(a){a.f=new ttb(a);a.i=new Ntb(a);++a.g;} + function Klb(a){if(!a){throw Adb(new Dvb)}return a.d} + function smb(a){var b;b=omb(a);sFb(b!=null);return b} + function tmb(a){var b;b=pmb(a);sFb(b!=null);return b} + function tv(a,b){var c;c=a.a.gc();Sb(b,c);return c-b} + function Ysb(a,b){var c;c=a.a.zc(b,a);return c==null} + function rAb(a,b){return a.a.zc(b,(Geb(),Eeb))==null} + function _nb(a){return new SDb(null,$nb(a,a.length))} + function yPb(a,b,c){return zPb(a,RD(b,42),RD(c,176))} + function Wrb(a,b,c){zsb(a.a,b);return _Eb(a.b,b.g,c)} + function fyb(a,b,c){lyb(c,a.a.c.length);$mb(a.a,c,b);} + function Knb(a,b,c,d){nFb(b,c,a.length);Onb(a,b,c,d);} + function Onb(a,b,c,d){var e;for(e=b;e0?$wnd.Math.log(a/b):-100} + function Agb(a,b){return Ddb(a,b)<0?-1:Ddb(a,b)>0?1:0} + function Dge(a,b){hZd(a,ZD(b,160)?b:RD(b,2036).Rl());} + function vFb(a,b){if(a==null){throw Adb(new Ogb(b))}} + function $nb(a,b){return jxb(b,a.length),new Gxb(a,b)} + function hsc(a,b){if(!b){return false}return ye(a,b)} + function Gs(){zs();return cD(WC(RG,1),jwe,549,0,[ys])} + function Xib(a){return a.e==0?a:new cjb(-a.e,a.d,a.a)} + function $Nb(a,b){return Qfb(a.c.c+a.c.b,b.c.c+b.c.b)} + function cvb(a,b){Pub(a.d,b,a.b.b,a.b);++a.a;a.c=null;} + function JCb(a,b){!a.c?Rmb(a.b,b):JCb(a.c,b);return a} + function KB(a,b,c){var d;d=JB(a,b);LB(a,b,c);return d} + function Rnb(a,b,c){var d;for(d=0;d=a.g} + function bD(a,b,c){pFb(c==null||VC(a,c));return a[b]=c} + function yhb(a,b){BFb(b,a.length+1);return a.substr(b)} + function yxb(a,b){uFb(b);while(a.c=a){return new rDb}return iDb(a-1)} + function Y2b(a){if(!a.a&&!!a.c){return a.c.b}return a.a} + function Zx(a){if(ZD(a,616)){return a}return new sy(a)} + function LCb(a){if(!a.c){MCb(a);a.d=true;}else {LCb(a.c);}} + function ICb(a){if(!a.c){a.d=true;KCb(a);}else {a.c.$e();}} + function bHb(a){a.b=false;a.c=false;a.d=false;a.a=false;} + function uMc(a){var b,c;b=a.c.i.c;c=a.d.i.c;return b==c} + function _vd(a,b){var c;c=a.Ih(b);c>=0?a.ki(c):Tvd(a,b);} + function mtd(a,b){a.c<0||a.b.b0){a=a<<1|(a<0?1:0);}return a} + function BGc(a,b){var c;c=new R4b(a);ZEb(b.c,c);return c} + function FMb(a,b){a.u.Hc((Pod(),Lod))&&DMb(a,b);HMb(a,b);} + function Fvb(a,b){return dE(a)===dE(b)||a!=null&&pb(a,b)} + function Vrb(a,b){return Bsb(a.a,b)?a.b[RD(b,22).g]:null} + function YRb(){VRb();return cD(WC($O,1),jwe,489,0,[URb])} + function ybd(){sbd();return cD(WC(M1,1),jwe,490,0,[rbd])} + function Hbd(){Cbd();return cD(WC(N1,1),jwe,558,0,[Bbd])} + function gdd(){_cd();return cD(WC(V1,1),jwe,539,0,[$cd])} + function iyd(a){!a.n&&(a.n=new C5d(I4,a,1,7));return a.n} + function wCd(a){!a.c&&(a.c=new C5d(K4,a,9,9));return a.c} + function mzd(a){!a.c&&(a.c=new Yie(E4,a,5,8));return a.c} + function lzd(a){!a.b&&(a.b=new Yie(E4,a,4,7));return a.b} + function Sed(a){a.j.c.length=0;Ae(a.c);sfd(a.a);return a} + function Afe(a){a.e==fLe&&Gfe(a,Aee(a.g,a.b));return a.e} + function Bfe(a){a.f==fLe&&Hfe(a,Bee(a.g,a.b));return a.f} + function xBd(a,b,c,d){wBd(a,b,c,false);j1d(a,d);return a} + function oNd(a,b){this.b=a;nMd.call(this,a,b);mNd(this);} + function wNd(a,b){this.b=a;CMd.call(this,a,b);uNd(this);} + function Kmb(a){this.d=a;this.a=this.d.b;this.b=this.d.c;} + function oy(a,b){this.b=a;this.c=b;this.a=new Osb(this.b);} + function ihb(a,b){BFb(b,a.length);return a.charCodeAt(b)} + function NDd(a,b){CGd(a,Kfb(vDd(b,'x')),Kfb(vDd(b,'y')));} + function $Dd(a,b){CGd(a,Kfb(vDd(b,'x')),Kfb(vDd(b,'y')));} + function CDb(a,b){MCb(a);return new SDb(a,new hEb(b,a.a))} + function GDb(a,b){MCb(a);return new SDb(a,new zEb(b,a.a))} + function HDb(a,b){MCb(a);return new WCb(a,new nEb(b,a.a))} + function IDb(a,b){MCb(a);return new oDb(a,new tEb(b,a.a))} + function Ty(a,b){return new Ry(RD(Qb(a),50),RD(Qb(b),50))} + function nHb(a,b){return Qfb(a.d.c+a.d.b/2,b.d.c+b.d.b/2)} + function gTb(a,b,c){c.a?Eyd(a,b.b-a.f/2):Dyd(a,b.a-a.g/2);} + function WYb(a,b){return Qfb(a.g.c+a.g.b/2,b.g.c+b.g.b/2)} + function RZb(a,b){NZb();return Qfb((uFb(a),a),(uFb(b),b))} + function wSd(a){return a!=null&&tpb(eSd,a.toLowerCase())} + function Ae(a){var b;for(b=a.Kc();b.Ob();){b.Pb();b.Qb();}} + function Ih(a){var b;b=a.b;!b&&(a.b=b=new Xh(a));return b} + function R0b(a){var b;b=Z5b(a);if(b){return b}return null} + function BSb(a,b){var c,d;c=a/b;d=eE(c);c>d&&++d;return d} + function Ck(a,b,c){var d;d=RD(a.d.Kb(c),159);!!d&&d.Nb(b);} + function Vhc(a,b,c){tqc(a.a,c);Jpc(c);Kqc(a.b,c);bqc(b,c);} + function oNc(a,b,c,d){this.a=a;this.c=b;this.b=c;this.d=d;} + function ROc(a,b,c,d){this.c=a;this.b=b;this.a=c;this.d=d;} + function uPc(a,b,c,d){this.c=a;this.b=b;this.d=c;this.a=d;} + function Uid(a,b,c,d){this.c=a;this.d=b;this.b=c;this.a=d;} + function GTc(a,b,c,d){this.a=a;this.d=b;this.c=c;this.b=d;} + function t1b(a,b,c,d){this.a=a;this.e=b;this.d=c;this.c=d;} + function $td(a,b,c,d){this.a=a;this.c=b;this.d=c;this.b=d;} + function ehb(a,b,c){this.a=ywe;this.d=a;this.b=b;this.c=c;} + function fpc(a,b,c,d){qs.call(this,a,b);this.a=c;this.b=d;} + function Uwb(a,b){this.d=(uFb(a),a);this.a=16449;this.c=b;} + function CIc(a){this.a=new bnb;this.e=$C(kE,Nve,53,a,0,2);} + function ELc(a){a.Ug('No crossing minimization',1);a.Vg();} + function Evb(){yz.call(this,'There is no more element.');} + function OEd(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;} + function PEd(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;} + function h7d(a,b,c,d){this.e=a;this.a=b;this.c=c;this.d=d;} + function x7d(a,b,c,d){this.a=a;this.c=b;this.d=c;this.b=d;} + function C8d(a,b,c,d){s7d();M7d.call(this,b,c,d);this.a=a;} + function J8d(a,b,c,d){s7d();M7d.call(this,b,c,d);this.a=a;} + function lwd(a,b,c){var d,e;d=oSd(a);e=b.ti(c,d);return e} + function lBd(a){var b,c;c=(b=new s2d,b);l2d(c,a);return c} + function mBd(a){var b,c;c=(b=new s2d,b);p2d(c,a);return c} + function HDd(a,b){var c;c=Wjb(a.f,b);wEd(b,c);return null} + function uCd(a){!a.b&&(a.b=new C5d(G4,a,12,3));return a.b} + function VD(a){CFb(a==null||cE(a)&&!(a.Tm===keb));return a} + function gz(a){if(a.n){a.e!==rwe&&a.je();a.j=null;}return a} + function Ng(a){ig(a.d);if(a.d.d!=a.c){throw Adb(new Jrb)}} + function Bkb(a){sFb(a.b0&&wPd(this);} + function Vg(a,b){this.a=a;Pg.call(this,a,RD(a.d,15).fd(b));} + function lrd(a,b){return Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function mrd(a,b){return Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function n5b(a){return ozd(a)&&Heb(TD(Gxd(a,(yCc(),OAc))))} + function Sfc(a,b){return Rc(a,RD(mQb(b,(yCc(),tBc)),17),b)} + function lic(a,b){RD(mQb(a,(Ywc(),qwc)),15).Fc(b);return b} + function C2b(a,b){a.b=b.b;a.c=b.c;a.d=b.d;a.a=b.a;return a} + function cEb(a,b,c,d){this.b=a;this.c=d;xxb.call(this,b,c);} + function Ulc(a,b,c){a.i=0;a.e=0;if(b==c){return}Qlc(a,b,c);} + function Vlc(a,b,c){a.i=0;a.e=0;if(b==c){return}Rlc(a,b,c);} + function akc(a,b,c){Wjc();return _Gb(RD(Wjb(a.e,b),529),c)} + function nd(a){var b;return b=a.f,!b?(a.f=new ne(a,a.c)):b} + function nTc(a,b){return VTc(a.j,b.s,b.c)+VTc(b.e,a.s,a.c)} + function Rrc(a,b){if(!!a.e&&!a.e.a){Prc(a.e,b);Rrc(a.e,b);}} + function Qrc(a,b){if(!!a.d&&!a.d.a){Prc(a.d,b);Qrc(a.d,b);}} + function krd(a,b){return -Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function gtd(a){return RD(a.ld(),149).Pg()+':'+jeb(a.md())} + function EBd(){BBd(this,new yAd);this.wb=(lTd(),kTd);jTd();} + function G7b(a){this.b=new bnb;Tmb(this.b,this.b);this.a=a;} + function WWc(a,b){new Yub;this.a=new Ejd;this.b=a;this.c=b;} + function urb(){urb=geb;rrb=new wrb;srb=new wrb;trb=new Brb;} + function yob(){yob=geb;vob=new Job;wob=new apb;xob=new ipb;} + function FGb(){FGb=geb;CGb=new AGb;EGb=new fHb;DGb=new YGb;} + function HSb(){HSb=geb;GSb=new bnb;FSb=new Tsb;ESb=new bnb;} + function Rb(a,b){if(a==null){throw Adb(new Ogb(b))}return a} + function tCd(a){!a.a&&(a.a=new C5d(J4,a,10,11));return a.a} + function uYd(a){!a.q&&(a.q=new C5d(s7,a,11,10));return a.q} + function xYd(a){!a.s&&(a.s=new C5d(y7,a,21,17));return a.s} + function er(a){Qb(a);return Er(new is(Mr(a.a.Kc(),new ir)))} + function hfd(a,b){rb(a);rb(b);return ns(RD(a,22),RD(b,22))} + function qDd(a,b,c){var d,e;d=Qeb(c);e=new hC(d);sC(a,b,e);} + function d4d(a,b,c,d,e,f){c4d.call(this,a,b,c,d,e,f?-2:-1);} + function sje(a,b,c,d){kZd.call(this,b,c);this.b=a;this.a=d;} + function Ry(a,b){wi.call(this,new ezb(a));this.a=a;this.b=b;} + function Gu(a){this.b=a;this.c=a;a.e=null;a.c=null;this.a=1;} + function Dkc(a){lkc();var b;b=RD(a.g,10);b.n.a=a.d.c+b.d.b;} + function fA(){fA=geb;var a,b;b=!lA();a=new tA;eA=b?new mA:a;} + function Hob(a){yob();return ZD(a,59)?new irb(a):new Upb(a)} + function Ux(a){return ZD(a,16)?new btb(RD(a,16)):Vx(a.Kc())} + function Vi(a){return new ij(a,a.e.Rd().gc()*a.c.Rd().gc())} + function fj(a){return new sj(a,a.e.Rd().gc()*a.c.Rd().gc())} + function Iz(a){return !!a&&!!a.hashCode?a.hashCode():kFb(a)} + function Yjb(a,b){return b==null?!!qtb(a.f,null):Jtb(a.i,b)} + function hYb(a,b){var c;c=$sb(a.a,b);c&&(b.d=null);return c} + function MGb(a,b,c){if(a.f){return a.f.ef(b,c)}return false} + function cFc(a,b,c,d){bD(a.c[b.g],c.g,d);bD(a.c[c.g],b.g,d);} + function fFc(a,b,c,d){bD(a.c[b.g],b.g,c);bD(a.b[b.g],b.g,d);} + function sXc(a,b,c){return Kfb(UD(c.a))<=a&&Kfb(UD(c.b))>=b} + function yJc(a,b){this.g=a;this.d=cD(WC(jR,1),WAe,10,0,[b]);} + function lHb(a){this.c=a;this.b=new yAb(RD(Qb(new oHb),50));} + function UYb(a){this.c=a;this.b=new yAb(RD(Qb(new XYb),50));} + function $Qb(a){this.b=a;this.a=new yAb(RD(Qb(new bRb),50));} + function tRc(){this.b=new _sb;this.d=new Yub;this.e=new Fyb;} + function VTb(){this.c=new pjd;this.d=new pjd;this.e=new pjd;} + function a1b(){this.a=new Ejd;this.b=(dk(3,iwe),new cnb(3));} + function i7d(a,b){this.e=a;this.a=jJ;this.b=pje(b);this.c=b;} + function Vid(a){this.c=a.c;this.d=a.d;this.b=a.b;this.a=a.a;} + function VLd(a,b,c,d,e,f){this.a=a;NKd.call(this,b,c,d,e,f);} + function aLd(a,b,c,d,e,f){this.a=a;NKd.call(this,b,c,d,e,f);} + function fge(a,b,c,d,e,f,g){return new lle(a.e,b,c,d,e,f,g)} + function xhb(a,b,c){return c>=0&&lhb(a.substr(c,b.length),b)} + function hGd(a,b){return ZD(b,149)&&lhb(a.b,RD(b,149).Pg())} + function Tde(a,b){return a.a?b.Gh().Kc():RD(b.Gh(),71).Ii()} + function Qqb(a,b){var c;c=a.b.Qc(b);Rqb(c,a.b.gc());return c} + function Ivb(a,b){if(a==null){throw Adb(new Ogb(b))}return a} + function zYd(a){if(!a.u){yYd(a);a.u=new w0d(a,a);}return a.u} + function Kx(a){this.a=(yob(),ZD(a,59)?new irb(a):new Upb(a));} + function Uwd(a){var b;b=RD(Ywd(a,16),29);return !b?a.ii():b} + function lz(a,b){var c;c=nfb(a.Rm);return b==null?c:c+': '+b} + function zhb(a,b,c){AFb(b,c,a.length);return a.substr(b,c-b)} + function VKb(a,b){RJb.call(this);KKb(this);this.a=a;this.c=b;} + function neb(a){!a?vve:lz(a,a.ie());} + function Wz(a){Qz();$wnd.setTimeout(function(){throw a},0);} + function GHb(){DHb();return cD(WC(uN,1),jwe,436,0,[CHb,BHb])} + function OHb(){LHb();return cD(WC(vN,1),jwe,435,0,[JHb,KHb])} + function WUb(){TUb();return cD(WC(BP,1),jwe,432,0,[RUb,SUb])} + function S8b(){P8b();return cD(WC(vS,1),jwe,517,0,[O8b,N8b])} + function Rvc(){Ovc();return cD(WC(lX,1),jwe,429,0,[Mvc,Nvc])} + function buc(){$tc();return cD(WC(cX,1),jwe,428,0,[Ytc,Ztc])} + function mtc(){jtc();return cD(WC($W,1),jwe,431,0,[htc,itc])} + function vEc(){sEc();return cD(WC(xX,1),jwe,430,0,[qEc,rEc])} + function vNc(){sNc();return cD(WC(MY,1),jwe,531,0,[rNc,qNc])} + function D2c(){x2c();return cD(WC(s0,1),jwe,501,0,[v2c,w2c])} + function zQc(){wQc();return cD(WC(FZ,1),jwe,523,0,[vQc,uQc])} + function HQc(){EQc();return cD(WC(GZ,1),jwe,522,0,[CQc,DQc])} + function iTc(){fTc();return cD(WC(b$,1),jwe,528,0,[eTc,dTc])} + function Fuc(){Cuc();return cD(WC(fX,1),jwe,488,0,[Buc,Auc])} + function F8c(){z8c();return cD(WC(l1,1),jwe,491,0,[x8c,y8c])} + function H9c(){B9c();return cD(WC(t1,1),jwe,492,0,[z9c,A9c])} + function D_c(){A_c();return cD(WC(K_,1),jwe,433,0,[z_c,y_c])} + function a4c(){Y3c();return cD(WC(H0,1),jwe,434,0,[W3c,X3c])} + function gVc(){dVc();return cD(WC(w$,1),jwe,465,0,[bVc,cVc])} + function Pbd(){Mbd();return cD(WC(O1,1),jwe,438,0,[Lbd,Kbd])} + function rdd(){ldd();return cD(WC(W1,1),jwe,437,0,[kdd,jdd])} + function xqd(){uqd();return cD(WC(M3,1),jwe,347,0,[sqd,tqd])} + function Jvd(a,b,c,d){return c>=0?a.Uh(b,c,d):a.Ch(null,c,d)} + function ltd(a){if(a.b.b==0){return a.a.sf()}return Uub(a.b)} + function vKd(a){if(a.p!=5)throw Adb(new cgb);return Ydb(a.f)} + function EKd(a){if(a.p!=5)throw Adb(new cgb);return Ydb(a.k)} + function P$d(a){dE(a.a)===dE((lYd(),kYd))&&Q$d(a);return a.a} + function iad(a,b){a.b=b;a.c>0&&a.b>0&&(a.g=Aad(a.c,a.b,a.a));} + function jad(a,b){a.c=b;a.c>0&&a.b>0&&(a.g=Aad(a.c,a.b,a.a));} + function BUc(a,b){yUc(this,new rjd(a.a,a.b));zUc(this,gv(b));} + function Tp(){Sp.call(this,new Usb(Sv(12)));Lb(true);this.a=2;} + function eue(a,b,c){Vse();Wse.call(this,a);this.b=b;this.a=c;} + function C7d(a,b,c){s7d();t7d.call(this,b);this.a=a;this.b=c;} + function qub(a){var b;b=a.c.d.b;a.b=b;a.a=a.c.d;b.a=a.c.d.b=a;} + function Tub(a){return a.b==0?null:(sFb(a.b!=0),Wub(a,a.a.a))} + function Xjb(a,b){return b==null?Wd(qtb(a.f,null)):Ktb(a.i,b)} + function bzb(a,b,c,d,e){return new Kzb(a,(cAb(),aAb),b,c,d,e)} + function Fnb(a,b){oFb(b);return Hnb(a,$C(kE,Pwe,28,b,15,1),b)} + function Tx(a,b){Rb(a,'set1');Rb(b,'set2');return new ey(a,b)} + function Kz(a,b){var c=Jz[a.charCodeAt(0)];return c==null?a:c} + function Xyb(a,b){var c,d;c=b;d=new Gzb;Zyb(a,c,d);return d.d} + function EMb(a,b,c,d){var e;e=new TJb;b.a[c.g]=e;Wrb(a.b,d,e);} + function SXb(a,b){var c;c=BXb(a.f,b);return $id(fjd(c),a.f.d)} + function RFb(a){var b;EJb(a.a);DJb(a.a);b=new PJb(a.a);LJb(b);} + function _Mb(a,b){$Mb(a,true);Umb(a.e.Rf(),new dNb(a,true,b));} + function PSb(a,b){HSb();return a==vCd(JGd(b))||a==vCd(LGd(b))} + function R0c(a,b){B0c();return RD(mQb(b,(h_c(),f_c)),17).a==a} + function eE(a){return Math.max(Math.min(a,lve),-2147483648)|0} + function sy(a){this.a=RD(Qb(a),277);this.b=(yob(),new jrb(a));} + function qbd(a,b,c){this.i=new bnb;this.b=a;this.g=b;this.a=c;} + function had(a,b,c){this.a=new bnb;this.e=a;this.f=b;this.c=c;} + function _9c(a,b,c){this.c=new bnb;this.e=a;this.f=b;this.b=c;} + function TKb(a){RJb.call(this);KKb(this);this.a=a;this.c=true;} + function ieb(a){function b(){} +b.prototype=a||{};return new b} + function zfb(a){if(a.Ae()){return null}var b=a.n;return eeb[b]} + function kzd(a){if(a.Db>>16!=3)return null;return RD(a.Cb,27)} + function MCd(a){if(a.Db>>16!=9)return null;return RD(a.Cb,27)} + function Fzd(a){if(a.Db>>16!=6)return null;return RD(a.Cb,74)} + function dVc(){dVc=geb;bVc=new eVc(Nye,0);cVc=new eVc(Oye,1);} + function wQc(){wQc=geb;vQc=new xQc(Oye,0);uQc=new xQc(Nye,1);} + function EQc(){EQc=geb;CQc=new FQc(Zye,0);DQc=new FQc('UP',1);} + function Is(){Is=geb;Hs=ss((zs(),cD(WC(RG,1),jwe,549,0,[ys])));} + function Wx(a){var b;b=new atb(Sv(a.length));zob(b,a);return b} + function B2b(a,b){a.b+=b.b;a.c+=b.c;a.d+=b.d;a.a+=b.a;return a} + function qmb(a,b){if(kmb(a,b)){Jmb(a);return true}return false} + function qC(a,b){if(b==null){throw Adb(new Ngb)}return rC(a,b)} + function nB(a,b){var c;c=a.q.getHours();a.q.setDate(b);mB(a,c);} + function Xvd(a,b,c){var d;d=a.Ih(b);d>=0?a.bi(d,c):Svd(a,b,c);} + function Lvd(a,b){var c;c=a.Ih(b);return c>=0?a.Wh(c):Rvd(a,b)} + function zo(a,b){var c;Qb(b);for(c=a.a;c;c=c.c){b.Yd(c.g,c.i);}} + function pMc(a,b,c){var d;d=qMc(a,b,c);a.b=new _Lc(d.c.length);} + function HId(a,b,c){EId();!!a&&Zjb(DId,a,b);!!a&&Zjb(CId,a,c);} + function bfc(a,b){Rec();return Geb(),RD(b.a,17).a0} + function sId(a){var b;b=a.d;b=a.bj(a.f);WGd(a,b);return b.Ob()} + function bHd(a,b){var c;c=new Kub(b);Ve(c,a);return new dnb(c)} + function qKd(a){if(a.p!=0)throw Adb(new cgb);return Pdb(a.f,0)} + function zKd(a){if(a.p!=0)throw Adb(new cgb);return Pdb(a.k,0)} + function gBd(a){if(a.Db>>16!=7)return null;return RD(a.Cb,241)} + function xXd(a){if(a.Db>>16!=6)return null;return RD(a.Cb,241)} + function dCd(a){if(a.Db>>16!=7)return null;return RD(a.Cb,167)} + function vCd(a){if(a.Db>>16!=11)return null;return RD(a.Cb,27)} + function uWd(a){if(a.Db>>16!=17)return null;return RD(a.Cb,29)} + function kVd(a){if(a.Db>>16!=3)return null;return RD(a.Cb,155)} + function BDb(a){var b;MCb(a);b=new _sb;return CDb(a,new aEb(b))} + function xfb(a,b){var c=a.a=a.a||[];return c[b]||(c[b]=a.ve(b))} + function qB(a,b){var c;c=a.q.getHours();a.q.setMonth(b);mB(a,c);} + function oz(a,b){ez(this);this.f=b;this.g=a;gz(this);this.je();} + function TQb(a,b){this.a=a;this.c=ajd(this.a);this.b=new Vid(b);} + function aGb(a,b,c){this.a=b;this.c=a;this.b=(Qb(c),new dnb(c));} + function s$b(a,b,c){this.a=b;this.c=a;this.b=(Qb(c),new dnb(c));} + function _Kc(a){this.a=a;this.b=$C(qY,Nve,2043,a.e.length,0,2);} + function fGb(){this.a=new Iub;this.e=new _sb;this.g=0;this.i=0;} + function EId(){EId=geb;DId=new Tsb;CId=new Tsb;IId(zK,new JId);} + function KFc(){KFc=geb;JFc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function RFc(){RFc=geb;QFc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function gGc(){gGc=geb;fGc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function ANc(){ANc=geb;zNc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function dOc(){dOc=geb;cOc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function gQc(){gQc=geb;fQc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function WQc(){WQc=geb;VQc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function dZd(a,b,c,d,e,f){return new P3d(a.e,b,a.Lj(),c,d,e,f)} + function $jb(a,b,c){return b==null?rtb(a.f,null,c):Ltb(a.i,b,c)} + function Y0b(a,b){!!a.c&&Ymb(a.c.g,a);a.c=b;!!a.c&&Rmb(a.c.g,a);} + function g3b(a,b){!!a.c&&Ymb(a.c.a,a);a.c=b;!!a.c&&Rmb(a.c.a,a);} + function P3b(a,b){!!a.i&&Ymb(a.i.j,a);a.i=b;!!a.i&&Rmb(a.i.j,a);} + function Z0b(a,b){!!a.d&&Ymb(a.d.e,a);a.d=b;!!a.d&&Rmb(a.d.e,a);} + function _Sc(a,b){!!a.a&&Ymb(a.a.k,a);a.a=b;!!a.a&&Rmb(a.a.k,a);} + function aTc(a,b){!!a.b&&Ymb(a.b.f,a);a.b=b;!!a.b&&Rmb(a.b.f,a);} + function Odd(a,b){Pdd(a,a.b,a.c);RD(a.b.b,68);!!b&&RD(b.b,68).b;} + function j2c(a,b){return Qfb(RD(a.c,65).c.e.b,RD(b.c,65).c.e.b)} + function k2c(a,b){return Qfb(RD(a.c,65).c.e.a,RD(b.c,65).c.e.a)} + function YXb(a){NXb();return Geb(),RD(a.a,86).d.e!=0?true:false} + function LXd(a,b){ZD(a.Cb,184)&&(RD(a.Cb,184).tb=null);PAd(a,b);} + function CWd(a,b){ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),4);PAd(a,b);} + function _5d(a,b){a6d(a,b);ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),2);} + function JFd(a,b){var c,d;c=b.c;d=c!=null;d&&oDd(a,new OC(b.c));} + function v0d(a){var b,c;c=(jTd(),b=new s2d,b);l2d(c,a);return c} + function E4d(a){var b,c;c=(jTd(),b=new s2d,b);l2d(c,a);return c} + function Fr(a){var b;while(true){b=a.Pb();if(!a.Ob()){return b}}} + function nq(a,b,c){Rmb(a.a,(fn(),ck(b,c),new gp(b,c)));return a} + function rge(a,b){return nke(),wWd(b)?new ole(b,a):new Eke(b,a)} + function ojb(a){Pib();return Ddb(a,0)>=0?jjb(a):Xib(jjb(Odb(a)))} + function Asb(a){var b;b=RD(UEb(a.b),9);return new Fsb(a.a,b,a.c)} + function Qw(a,b){var c;c=RD(Xv(nd(a.a),b),16);return !c?0:c.gc()} + function Zmb(a,b,c){var d;xFb(b,c,a.c.length);d=c-b;$Eb(a.c,b,d);} + function Rkb(a,b,c){xFb(b,c,a.gc());this.c=a;this.a=b;this.b=c-b;} + function fgd(a){this.c=new Yub;this.b=a.b;this.d=a.c;this.a=a.a;} + function qjd(a){this.a=$wnd.Math.cos(a);this.b=$wnd.Math.sin(a);} + function bTc(a,b,c,d){this.c=a;this.d=d;_Sc(this,b);aTc(this,c);} + function Si(a,b){Qi.call(this,new Usb(Sv(a)));dk(b,Mve);this.a=b;} + function Ryb(a,b,c){return new Kzb(a,(cAb(),_zb),null,false,b,c)} + function czb(a,b,c){return new Kzb(a,(cAb(),bAb),b,c,null,false)} + function ABb(){xBb();return cD(WC(QL,1),jwe,108,0,[uBb,vBb,wBb])} + function yLb(){vLb();return cD(WC(TN,1),jwe,472,0,[uLb,tLb,sLb])} + function HKb(){EKb();return cD(WC(MN,1),jwe,471,0,[CKb,BKb,DKb])} + function aKb(){ZJb();return cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])} + function DWb(){AWb();return cD(WC(JP,1),jwe,391,0,[yWb,xWb,zWb])} + function moc(){joc();return cD(WC(UV,1),jwe,372,0,[ioc,hoc,goc])} + function ytc(){stc();return cD(WC(_W,1),jwe,322,0,[qtc,ptc,rtc])} + function Htc(){Etc();return cD(WC(aX,1),jwe,351,0,[Btc,Dtc,Ctc])} + function kuc(){huc();return cD(WC(dX,1),jwe,460,0,[fuc,euc,guc])} + function Avc(){xvc();return cD(WC(jX,1),jwe,299,0,[vvc,wvc,uvc])} + function Jvc(){Gvc();return cD(WC(kX,1),jwe,311,0,[Evc,Fvc,Dvc])} + function pDc(){lDc();return cD(WC(sX,1),jwe,390,0,[iDc,jDc,kDc])} + function EEc(){BEc();return cD(WC(yX,1),jwe,463,0,[AEc,yEc,zEc])} + function NEc(){KEc();return cD(WC(zX,1),jwe,387,0,[HEc,IEc,JEc])} + function WEc(){TEc();return cD(WC(AX,1),jwe,349,0,[SEc,QEc,REc])} + function oFc(){lFc();return cD(WC(CX,1),jwe,350,0,[iFc,jFc,kFc])} + function xFc(){uFc();return cD(WC(DX,1),jwe,352,0,[tFc,rFc,sFc])} + function GFc(){DFc();return cD(WC(EX,1),jwe,388,0,[BFc,CFc,AFc])} + function UKc(){RKc();return cD(WC(nY,1),jwe,464,0,[OKc,PKc,QKc])} + function K3b(a){return xjd(cD(WC(l3,1),Nve,8,0,[a.i.n,a.n,a.a]))} + function OZc(){LZc();return cD(WC(F_,1),jwe,392,0,[KZc,JZc,IZc])} + function H_c(){H_c=geb;G_c=nfd(new ufd,(YVc(),WVc),(WYc(),MYc));} + function A_c(){A_c=geb;z_c=new B_c('DFS',0);y_c=new B_c('BFS',1);} + function TQc(a,b,c){var d;d=new SQc;d.b=b;d.a=c;++b.b;Rmb(a.d,d);} + function NTb(a,b,c){var d;d=new sjd(c.d);$id(d,a);CGd(b,d.a,d.b);} + function Nwb(a,b){Mwb(a,Ydb(Cdb(Tdb(b,24),Pxe)),Ydb(Cdb(b,Pxe)));} + function wFb(a,b){if(a<0||a>b){throw Adb(new veb(cye+a+dye+b))}} + function tFb(a,b){if(a<0||a>=b){throw Adb(new veb(cye+a+dye+b))}} + function BFb(a,b){if(a<0||a>=b){throw Adb(new eib(cye+a+dye+b))}} + function Swb(a,b){this.b=(uFb(a),a);this.a=(b&qxe)==0?b|64|Ove:b;} + function ODb(a){var b;MCb(a);b=(urb(),urb(),srb);return PDb(a,b)} + function R9c(a,b,c){var d;d=S9c(a,b,false);return d.b<=b&&d.a<=c} + function h9c(){b9c();return cD(WC(o1,1),jwe,439,0,[$8c,a9c,_8c])} + function c7c(){_6c();return cD(WC(a1,1),jwe,394,0,[Z6c,$6c,Y6c])} + function i6c(){f6c();return cD(WC(V0,1),jwe,445,0,[c6c,d6c,e6c])} + function D6c(){z6c();return cD(WC(Z0,1),jwe,456,0,[w6c,y6c,x6c])} + function k4c(){g4c();return cD(WC(I0,1),jwe,393,0,[d4c,e4c,f4c])} + function x5c(){t5c();return cD(WC(N0,1),jwe,300,0,[r5c,s5c,q5c])} + function Ind(){Fnd();return cD(WC(y3,1),jwe,346,0,[Dnd,Cnd,End])} + function jbd(){gbd();return cD(WC(I1,1),jwe,444,0,[dbd,ebd,fbd])} + function Rmd(){Omd();return cD(WC(t3,1),jwe,278,0,[Lmd,Mmd,Nmd])} + function pqd(){mqd();return cD(WC(J3,1),jwe,280,0,[kqd,jqd,lqd])} + function bv(a){Qb(a);return ZD(a,16)?new dnb(RD(a,16)):cv(a.Kc())} + function Hz(a,b){return !!a&&!!a.equals?a.equals(b):dE(a)===dE(b)} + function Cdb(a,b){return Edb(tD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function Rdb(a,b){return Edb(zD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function $db(a,b){return Edb(HD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function xs(a,b){var c;c=(uFb(a),a).g;lFb(!!c);uFb(b);return c(b)} + function rv(a,b){var c,d;d=tv(a,b);c=a.a.fd(d);return new Gv(a,c)} + function CXd(a){if(a.Db>>16!=6)return null;return RD(yvd(a),241)} + function sKd(a){if(a.p!=2)throw Adb(new cgb);return Ydb(a.f)&Bwe} + function BKd(a){if(a.p!=2)throw Adb(new cgb);return Ydb(a.k)&Bwe} + function ynb(a){sFb(a.ad?1:0} + function Hmc(a,b){var c,d;c=Gmc(b);d=c;return RD(Wjb(a.c,d),17).a} + function CMc(a,b,c){var d;d=a.d[b.p];a.d[b.p]=a.d[c.p];a.d[c.p]=d;} + function Jqd(a,b,c){var d;if(a.n&&!!b&&!!c){d=new otd;Rmb(a.e,d);}} + function gYb(a,b){Ysb(a.a,b);if(b.d){throw Adb(new yz(jye))}b.d=a;} + function Had(a,b){this.a=new bnb;this.d=new bnb;this.f=a;this.c=b;} + function RWb(){this.c=new dXb;this.a=new I_b;this.b=new E0b;g0b();} + function med(){hed();this.b=new Tsb;this.a=new Tsb;this.c=new bnb;} + function KKd(a,b,c){this.d=a;this.j=b;this.e=c;this.o=-1;this.p=3;} + function LKd(a,b,c){this.d=a;this.k=b;this.f=c;this.o=-1;this.p=5;} + function S3d(a,b,c,d,e,f){R3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function U3d(a,b,c,d,e,f){T3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function W3d(a,b,c,d,e,f){V3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function Y3d(a,b,c,d,e,f){X3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function $3d(a,b,c,d,e,f){Z3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function a4d(a,b,c,d,e,f){_3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function f4d(a,b,c,d,e,f){e4d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function h4d(a,b,c,d,e,f){g4d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function N7d(a,b,c,d){t7d.call(this,c);this.b=a;this.c=b;this.d=d;} + function mfe(a,b){this.f=a;this.a=(ree(),pee);this.c=pee;this.b=b;} + function Jfe(a,b){this.g=a;this.d=(ree(),qee);this.a=qee;this.b=b;} + function Gme(a,b){!a.c&&(a.c=new Uge(a,0));Fge(a.c,(nme(),fme),b);} + function Oge(a,b){return Pge(a,b,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function lB(a,b){return Agb(Hdb(a.q.getTime()),Hdb(b.q.getTime()))} + function gj(a){return fk(a.e.Rd().gc()*a.c.Rd().gc(),16,new qj(a))} + function CYd(a){return !!a.u&&tYd(a.u.a).i!=0&&!(!!a.n&&d$d(a.n))} + function p4d(a){return !!a.a&&o4d(a.a.a).i!=0&&!(!!a.b&&o5d(a.b))} + function Cxd(a,b){if(b==0){return !!a.o&&a.o.f!=0}return Kvd(a,b)} + function Cc(a,b,c){var d;d=RD(a.Zb().xc(b),16);return !!d&&d.Hc(c)} + function Gc(a,b,c){var d;d=RD(a.Zb().xc(b),16);return !!d&&d.Mc(c)} + function _yb(a,b){var c;c=1-b;a.a[c]=azb(a.a[c],c);return azb(a,b)} + function DFb(a,b){var c,d;d=Cdb(a,yxe);c=Sdb(b,32);return Rdb(c,d)} + function bGb(a,b,c){var d;d=(Qb(a),new dnb(a));_Fb(new aGb(d,b,c));} + function t$b(a,b,c){var d;d=(Qb(a),new dnb(a));r$b(new s$b(d,b,c));} + function vBd(a,b,c,d,e,f){wBd(a,b,c,f);EYd(a,d);FYd(a,e);return a} + function Xhb(a,b,c,d){a.a+=''+zhb(b==null?vve:jeb(b),c,d);return a} + function Jkb(a,b){this.a=a;Dkb.call(this,a);wFb(b,a.gc());this.b=b;} + function xmb(a){this.a=$C(jJ,rve,1,mgb($wnd.Math.max(8,a))<<1,5,1);} + function t2b(a){return RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199)} + function s2b(a){return RD(anb(a,$C(WQ,VAe,18,a.c.length,0,1)),483)} + function Iyb(a){return !a.a?a.c:a.e.length==0?a.a.a:a.a.a+(''+a.e)} + function Rib(a){while(a.d>0&&a.a[--a.d]==0);a.a[a.d++]==0&&(a.e=0);} + function fvb(a){sFb(a.b.b!=a.d.a);a.c=a.b=a.b.b;--a.a;return a.c.c} + function sRc(a,b,c){a.a=b;a.c=c;a.b.a.$b();Xub(a.d);aFb(a.e.a.c,0);} + function Z5c(a,b){var c;a.e=new R5c;c=Q2c(b);_mb(c,a.c);$5c(a,c,0);} + function zgd(a,b,c,d){var e;e=new Hgd;e.a=b;e.b=c;e.c=d;Mub(a.a,e);} + function Agd(a,b,c,d){var e;e=new Hgd;e.a=b;e.b=c;e.c=d;Mub(a.b,e);} + function Tb(a,b,c){if(a<0||bc){throw Adb(new veb(Kb(a,b,c)))}} + function Pb(a,b){if(a<0||a>=b){throw Adb(new veb(Ib(a,b)))}return a} + function qz(b){if(!('stack' in b)){try{throw b}catch(a){}}return b} + function Zjc(a){Wjc();if(ZD(a.g,10)){return RD(a.g,10)}return null} + function nx(a){if(Ih(a).dc()){return false}Jh(a,new rx);return true} + function Xdb(a){var b;if(Kdb(a)){b=a;return b==-0.?0:b}return ED(a)} + function lkb(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function gsb(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function vub(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function RCb(a){var b;LCb(a);b=new Prb;ixb(a.a,new fDb(b));return b} + function Vae(){var a,b,c;b=(c=(a=new s2d,a),c);Rmb(Rae,b);return b} + function mDb(a){var b;LCb(a);b=new ltb;ixb(a.a,new uDb(b));return b} + function jDb(a,b){if(a.a<=a.b){b.Dd(a.a++);return true}return false} + function xzb(a){yzb.call(this,a,(cAb(),$zb),null,false,null,false);} + function $Rb(){$Rb=geb;ZRb=ss((VRb(),cD(WC($O,1),jwe,489,0,[URb])));} + function CHc(){CHc=geb;BHc=yx(sgb(1),sgb(4));AHc=yx(sgb(1),sgb(2));} + function yXc(a,b){return new gud(b,njd(ajd(b.e),a,a),(Geb(),true))} + function fv(a){return new cnb((dk(a,lwe),dz(Bdb(Bdb(5,a),a/10|0))))} + function Wi(a){return fk(a.e.Rd().gc()*a.c.Rd().gc(),273,new kj(a))} + function u2b(a){return RD(anb(a,$C(xR,XAe,12,a.c.length,0,1)),2042)} + function COc(a){dOc();return !W0b(a)&&!(!W0b(a)&&a.c.i.c==a.d.i.c)} + function Y_c(a,b){R_c();return RD(mQb(b,(h_c(),W$c)),17).a>=a.gc()} + function q8b(a,b){w8b(b,a);y8b(a.d);y8b(RD(mQb(a,(yCc(),cBc)),214));} + function r8b(a,b){z8b(b,a);B8b(a.d);B8b(RD(mQb(a,(yCc(),cBc)),214));} + function $0b(a,b,c){!!a.d&&Ymb(a.d.e,a);a.d=b;!!a.d&&Qmb(a.d.e,c,a);} + function jPb(a,b,c){return c.f.c.length>0?yPb(a.a,b,c):yPb(a.b,b,c)} + function Uz(a,b,c){var d;d=Sz();try{return Rz(a,b,c)}finally{Vz(d);}} + function wDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=c.pe());return d} + function yDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=c.se());return d} + function xDd(a,b){var c,d;c=JB(a,b);d=null;!!c&&(d=c.se());return d} + function zDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=ADd(c));return d} + function rEd(a,b,c){var d;d=uDd(c);Do(a.g,d,b);Do(a.i,b,c);return b} + function UIc(a,b,c){this.d=new fJc(this);this.e=a;this.i=b;this.f=c;} + function Mk(a,b,c,d){this.e=null;this.c=a;this.d=b;this.a=c;this.b=d;} + function urc(a,b,c,d){nrc(this);this.c=a;this.e=b;this.f=c;this.b=d;} + function MKd(a,b,c,d){this.d=a;this.n=b;this.g=c;this.o=d;this.p=-1;} + function Vc(a,b,c,d){return ZD(c,59)?new Kg(a,b,c,d):new yg(a,b,c,d)} + function gr(a){if(ZD(a,16)){return RD(a,16).dc()}return !a.Kc().Ob()} + function Wo(a){if(a.e.g!=a.b){throw Adb(new Jrb)}return !!a.c&&a.d>0} + function evb(a){sFb(a.b!=a.d.c);a.c=a.b;a.b=a.b.a;++a.a;return a.c.c} + function imb(a,b){uFb(b);bD(a.a,a.c,b);a.c=a.c+1&a.a.length-1;mmb(a);} + function hmb(a,b){uFb(b);a.b=a.b-1&a.a.length-1;bD(a.a,a.b,b);mmb(a);} + function _je(a){var b;b=a.Gh();this.a=ZD(b,71)?RD(b,71).Ii():b.Kc();} + function px(a){return new Swb(Dob(RD(a.a.md(),16).gc(),a.a.ld()),16)} + function Abd(){Abd=geb;zbd=ss((sbd(),cD(WC(M1,1),jwe,490,0,[rbd])));} + function Jbd(){Jbd=geb;Ibd=ss((Cbd(),cD(WC(N1,1),jwe,558,0,[Bbd])));} + function idd(){idd=geb;hdd=ss((_cd(),cD(WC(V1,1),jwe,539,0,[$cd])));} + function X$b(){U$b();return cD(WC(CQ,1),jwe,389,0,[T$b,R$b,Q$b,S$b])} + function hAb(){cAb();return cD(WC(AL,1),jwe,304,0,[$zb,_zb,aAb,bAb])} + function LPb(){IPb();return cD(WC(DO,1),jwe,332,0,[FPb,EPb,GPb,HPb])} + function LRb(){IRb();return cD(WC(WO,1),jwe,406,0,[FRb,ERb,GRb,HRb])} + function pOb(){mOb();return cD(WC(hO,1),jwe,417,0,[lOb,iOb,jOb,kOb])} + function uZb(){nZb();return cD(WC(lQ,1),jwe,416,0,[jZb,mZb,kZb,lZb])} + function hnc(){enc();return cD(WC(LV,1),jwe,421,0,[anc,bnc,cnc,dnc])} + function zec(){vec();return cD(WC(qT,1),jwe,371,0,[uec,sec,tec,rec])} + function BDc(){wDc();return cD(WC(tX,1),jwe,203,0,[uDc,vDc,tDc,sDc])} + function nEc(){kEc();return cD(WC(wX,1),jwe,284,0,[hEc,gEc,iEc,jEc])} + function Unc(a){var b;return a.j==(qpd(),npd)&&(b=Vnc(a),Csb(b,Xod))} + function qhc(a,b){var c;c=b.a;Y0b(c,b.c.d);Z0b(c,b.d.d);Cjd(c.a,a.n);} + function _5b(a,b){var c;c=RD(cub(a.b,b),67);!c&&(c=new Yub);return c} + function $jc(a){Wjc();if(ZD(a.g,154)){return RD(a.g,154)}return null} + function gRc(a){a.a=null;a.e=null;aFb(a.b.c,0);aFb(a.f.c,0);a.c=null;} + function Ovc(){Ovc=geb;Mvc=new Pvc(Kye,0);Nvc=new Pvc('TOP_LEFT',1);} + function sNc(){sNc=geb;rNc=new tNc('UPPER',0);qNc=new tNc('LOWER',1);} + function nWc(a,b){return cjd(new rjd(b.e.a+b.f.a/2,b.e.b+b.f.b/2),a)} + function wqc(a,b){return RD(Lvb(JDb(RD(Qc(a.k,b),15).Oc(),lqc)),113)} + function xqc(a,b){return RD(Lvb(KDb(RD(Qc(a.k,b),15).Oc(),lqc)),113)} + function cWc(){YVc();return cD(WC(H$,1),jwe,405,0,[UVc,VVc,WVc,XVc])} + function v_c(){s_c();return cD(WC(J_,1),jwe,353,0,[r_c,p_c,q_c,o_c])} + function n5c(){j5c();return cD(WC(M0,1),jwe,354,0,[i5c,g5c,h5c,f5c])} + function Tpd(){Qpd();return cD(WC(H3,1),jwe,386,0,[Opd,Ppd,Npd,Mpd])} + function Tnd(){Pnd();return cD(WC(z3,1),jwe,291,0,[Ond,Lnd,Mnd,Nnd])} + function _md(){Ymd();return cD(WC(u3,1),jwe,223,0,[Xmd,Vmd,Umd,Wmd])} + function Jrd(){Grd();return cD(WC(R3,1),jwe,320,0,[Frd,Crd,Erd,Drd])} + function wtd(){ttd();return cD(WC(n4,1),jwe,415,0,[qtd,rtd,ptd,std])} + function GId(a){EId();return Ujb(DId,a)?RD(Wjb(DId,a),341).Qg():null} + function Avd(a,b,c){return b<0?Rvd(a,c):RD(c,69).wk().Bk(a,a.hi(),b)} + function sEd(a,b,c){var d;d=uDd(c);Do(a.j,d,b);Zjb(a.k,b,c);return b} + function qEd(a,b,c){var d;d=uDd(c);Do(a.d,d,b);Zjb(a.e,b,c);return b} + function DGd(a){var b,c;b=(bvd(),c=new rzd,c);!!a&&pzd(b,a);return b} + function WHd(a){var b;b=a.aj(a.i);a.i>0&&hib(a.g,0,b,0,a.i);return b} + function Led(a,b){var c;for(c=a.j.c.length;c>24} + function AKd(a){if(a.p!=1)throw Adb(new cgb);return Ydb(a.k)<<24>>24} + function GKd(a){if(a.p!=7)throw Adb(new cgb);return Ydb(a.k)<<16>>16} + function xKd(a){if(a.p!=7)throw Adb(new cgb);return Ydb(a.f)<<16>>16} + function Wib(a,b){if(b.e==0||a.e==0){return Oib}return Ljb(),Mjb(a,b)} + function Nd(a,b){return dE(b)===dE(a)?'(this Map)':b==null?vve:jeb(b)} + function MFb(a,b,c){return Jfb(UD(Wd(qtb(a.f,b))),UD(Wd(qtb(a.f,c))))} + function wkc(a,b,c){var d;d=RD(Wjb(a.g,c),60);Rmb(a.a.c,new Ptd(b,d));} + function Slc(a,b,c){a.i=0;a.e=0;if(b==c){return}Rlc(a,b,c);Qlc(a,b,c);} + function rTc(a,b,c,d,e){var f;f=mTc(e,c,d);Rmb(b,TSc(e,f));vTc(a,e,b);} + function Jrc(a,b,c,d,e){this.i=a;this.a=b;this.e=c;this.j=d;this.f=e;} + function iUb(a,b){VTb.call(this);this.a=a;this.b=b;Rmb(this.a.b,this);} + function rTb(a){this.b=new Tsb;this.c=new Tsb;this.d=new Tsb;this.a=a;} + function Dx(a,b){var c;c=new cib;a.Gd(c);c.a+='..';b.Hd(c);return c.a} + function Fsd(a,b){var c;c=b;while(c){Zid(a,c.i,c.j);c=vCd(c);}return a} + function pEd(a,b,c){var d;d=uDd(c);Zjb(a.b,d,b);Zjb(a.c,b,c);return b} + function Kr(a){var b;b=0;while(a.Ob()){a.Pb();b=Bdb(b,1);}return dz(b)} + function oke(a,b){nke();var c;c=RD(a,69).vk();K6d(c,b);return c.xl(b)} + function tC(d,a,b){if(b){var c=b.oe();d.a[a]=c(b);}else {delete d.a[a];}} + function tB(a,b){var c;c=a.q.getHours();a.q.setFullYear(b+Owe);mB(a,c);} + function KSd(a,b){return RD(b==null?Wd(qtb(a.f,null)):Ktb(a.i,b),288)} + function hOc(a,b){return a==(r3b(),p3b)&&b==p3b?4:a==p3b||b==p3b?8:32} + function cge(a,b,c){return dge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function jge(a,b,c){return kge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function Qge(a,b,c){return Rge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function jmb(a){if(a.b==a.c){return}a.a=$C(jJ,rve,1,8,5,1);a.b=0;a.c=0;} + function Nsb(a){sFb(a.a=0&&a.a[c]===b[c];c--);return c<0} + function Xx(a){var b;if(a){return new Kub(a)}b=new Iub;_q(b,a);return b} + function nmc(a,b){var c,d;d=false;do{c=qmc(a,b);d=d|c;}while(c);return d} + function Vz(a){a&&aA(($z(),Zz));--Nz;if(a){if(Pz!=-1){Xz(Pz);Pz=-1;}}} + function Pwb(a){Hwb();Mwb(this,Ydb(Cdb(Tdb(a,24),Pxe)),Ydb(Cdb(a,Pxe)));} + function IHb(){IHb=geb;HHb=ss((DHb(),cD(WC(uN,1),jwe,436,0,[CHb,BHb])));} + function QHb(){QHb=geb;PHb=ss((LHb(),cD(WC(vN,1),jwe,435,0,[JHb,KHb])));} + function YUb(){YUb=geb;XUb=ss((TUb(),cD(WC(BP,1),jwe,432,0,[RUb,SUb])));} + function U8b(){U8b=geb;T8b=ss((P8b(),cD(WC(vS,1),jwe,517,0,[O8b,N8b])));} + function Tvc(){Tvc=geb;Svc=ss((Ovc(),cD(WC(lX,1),jwe,429,0,[Mvc,Nvc])));} + function duc(){duc=geb;cuc=ss(($tc(),cD(WC(cX,1),jwe,428,0,[Ytc,Ztc])));} + function Huc(){Huc=geb;Guc=ss((Cuc(),cD(WC(fX,1),jwe,488,0,[Buc,Auc])));} + function xEc(){xEc=geb;wEc=ss((sEc(),cD(WC(xX,1),jwe,430,0,[qEc,rEc])));} + function xNc(){xNc=geb;wNc=ss((sNc(),cD(WC(MY,1),jwe,531,0,[rNc,qNc])));} + function otc(){otc=geb;ntc=ss((jtc(),cD(WC($W,1),jwe,431,0,[htc,itc])));} + function F_c(){F_c=geb;E_c=ss((A_c(),cD(WC(K_,1),jwe,433,0,[z_c,y_c])));} + function F2c(){F2c=geb;E2c=ss((x2c(),cD(WC(s0,1),jwe,501,0,[v2c,w2c])));} + function BQc(){BQc=geb;AQc=ss((wQc(),cD(WC(FZ,1),jwe,523,0,[vQc,uQc])));} + function JQc(){JQc=geb;IQc=ss((EQc(),cD(WC(GZ,1),jwe,522,0,[CQc,DQc])));} + function kTc(){kTc=geb;jTc=ss((fTc(),cD(WC(b$,1),jwe,528,0,[eTc,dTc])));} + function iVc(){iVc=geb;hVc=ss((dVc(),cD(WC(w$,1),jwe,465,0,[bVc,cVc])));} + function c4c(){c4c=geb;b4c=ss((Y3c(),cD(WC(H0,1),jwe,434,0,[W3c,X3c])));} + function H8c(){H8c=geb;G8c=ss((z8c(),cD(WC(l1,1),jwe,491,0,[x8c,y8c])));} + function J9c(){J9c=geb;I9c=ss((B9c(),cD(WC(t1,1),jwe,492,0,[z9c,A9c])));} + function Rbd(){Rbd=geb;Qbd=ss((Mbd(),cD(WC(O1,1),jwe,438,0,[Lbd,Kbd])));} + function tdd(){tdd=geb;sdd=ss((ldd(),cD(WC(W1,1),jwe,437,0,[kdd,jdd])));} + function Eqd(){Eqd=geb;Dqd=ss((uqd(),cD(WC(M3,1),jwe,347,0,[sqd,tqd])));} + function Imd(){Cmd();return cD(WC(s3,1),jwe,88,0,[Amd,zmd,ymd,xmd,Bmd])} + function xpd(){qpd();return cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])} + function LSd(a,b,c){return RD(b==null?rtb(a.f,null,c):Ltb(a.i,b,c),288)} + function L6b(a){return (a.k==(r3b(),p3b)||a.k==m3b)&&nQb(a,(Ywc(),cwc))} + function bUb(a){return !!a.c&&!!a.d?kUb(a.c)+'->'+kUb(a.d):'e_'+kFb(a)} + function xgb(a,b){var c,d;uFb(b);for(d=a.Kc();d.Ob();){c=d.Pb();b.Cd(c);}} + function jEd(a,b){var c;c=new uC;qDd(c,'x',b.a);qDd(c,'y',b.b);oDd(a,c);} + function mEd(a,b){var c;c=new uC;qDd(c,'x',b.a);qDd(c,'y',b.b);oDd(a,c);} + function Gsd(a,b){var c;c=b;while(c){Zid(a,-c.i,-c.j);c=vCd(c);}return a} + function ZLc(a,b){var c,d;c=b;d=0;while(c>0){d+=a.a[c];c-=c&-c;}return d} + function $mb(a,b,c){var d;d=(tFb(b,a.c.length),a.c[b]);a.c[b]=c;return d} + function uIc(a,b,c){a.a.c.length=0;yIc(a,b,c);a.a.c.length==0||rIc(a,b);} + function wo(a){a.i=0;Mnb(a.b,null);Mnb(a.c,null);a.a=null;a.e=null;++a.g;} + function gBb(){gBb=geb;dBb=true;bBb=false;cBb=false;fBb=false;eBb=false;} + function oBb(a){gBb();if(dBb){return}this.c=a;this.e=true;this.a=new bnb;} + function kDb(a,b){this.c=0;this.b=b;txb.call(this,a,17493);this.a=this.c;} + function S_b(a){P_b();A$b(this);this.a=new Yub;Q_b(this,a);Mub(this.a,a);} + function m_b(){Pmb(this);this.b=new rjd(oxe,oxe);this.a=new rjd(pxe,pxe);} + function z8c(){z8c=geb;x8c=new B8c(CBe,0);y8c=new B8c('TARGET_WIDTH',1);} + function yDb(a,b){return (MCb(a),QDb(new SDb(a,new hEb(b,a.a)))).Bd(wDb)} + function vXb(){sXb();return cD(WC(UP,1),jwe,367,0,[nXb,oXb,pXb,qXb,rXb])} + function Fnc(){Bnc();return cD(WC(TV,1),jwe,375,0,[xnc,znc,Anc,ync,wnc])} + function Vtc(){Ptc();return cD(WC(bX,1),jwe,348,0,[Ltc,Ktc,Ntc,Otc,Mtc])} + function PDc(){JDc();return cD(WC(uX,1),jwe,323,0,[IDc,FDc,GDc,EDc,HDc])} + function fxc(){cxc();return cD(WC(mX,1),jwe,171,0,[bxc,Zwc,$wc,_wc,axc])} + function k3c(){g3c();return cD(WC(x0,1),jwe,368,0,[e3c,b3c,f3c,c3c,d3c])} + function vad(){sad();return cD(WC(x1,1),jwe,373,0,[oad,nad,qad,pad,rad])} + function $bd(){Xbd();return cD(WC(P1,1),jwe,324,0,[Sbd,Tbd,Wbd,Ubd,Vbd])} + function _hd(){Yhd();return cD(WC(d3,1),jwe,170,0,[Whd,Vhd,Thd,Xhd,Uhd])} + function sod(){pod();return cD(WC(B3,1),jwe,256,0,[mod,ood,kod,lod,nod])} + function Tz(b){Qz();return function(){return Uz(b,this,arguments);}} + function W0b(a){if(!a.c||!a.d){return false}return !!a.c.i&&a.c.i==a.d.i} + function Nfd(a,b){if(ZD(b,143)){return lhb(a.c,RD(b,143).c)}return false} + function yYd(a){if(!a.t){a.t=new w$d(a);VGd(new Cde(a),0,a.t);}return a.t} + function jNd(a){this.b=a;dMd.call(this,a);this.a=RD(Ywd(this.b.a,4),129);} + function sNd(a){this.b=a;yMd.call(this,a);this.a=RD(Ywd(this.b.a,4),129);} + function Q3d(a,b,c,d,e){OKd.call(this,b,d,e);this.c=a;this.b=c;} + function V3d(a,b,c,d,e){KKd.call(this,b,d,e);this.c=a;this.a=c;} + function Z3d(a,b,c,d,e){LKd.call(this,b,d,e);this.c=a;this.a=c;} + function g4d(a,b,c,d,e){OKd.call(this,b,d,e);this.c=a;this.a=c;} + function ugd(a,b){var c;c=RD(cub(a.d,b),23);return c?c:RD(cub(a.e,b),23)} + function Blb(a,b){var c,d;c=b.ld();d=a.Fe(c);return !!d&&Fvb(d.e,b.md())} + function me(a,b){var c;c=b.ld();return new gp(c,a.e.pc(c,RD(b.md(),16)))} + function ptb(a,b){var c;c=a.a.get(b);return c==null?$C(jJ,rve,1,0,5,1):c} + function khb(a){var b;b=a.length;return lhb(sxe.substr(sxe.length-b,b),a)} + function hs(a){if(gs(a)){a.c=a.a;return a.a.Pb()}else {throw Adb(new Dvb)}} + function $ib(a,b){if(b==0||a.e==0){return a}return b>0?tjb(a,b):qjb(a,-b)} + function Zib(a,b){if(b==0||a.e==0){return a}return b>0?qjb(a,b):tjb(a,-b)} + function Deb(a){Beb.call(this,a==null?vve:jeb(a),ZD(a,82)?RD(a,82):null);} + function Y5d(a){var b;if(!a.c){b=a.r;ZD(b,90)&&(a.c=RD(b,29));}return a.c} + function s0b(a){var b;b=new a1b;kQb(b,a);pQb(b,(yCc(),RAc),null);return b} + function lec(a){var b,c;b=a.c.i;c=a.d.i;return b.k==(r3b(),m3b)&&c.k==m3b} + function fD(a){var b,c,d;b=a&dxe;c=a>>22&dxe;d=a<0?exe:0;return hD(b,c,d)} + function Ky(a){var b,c,d,e;for(c=a,d=0,e=c.length;d=0?a.Lh(d,c,true):Qvd(a,b,c)} + function AXc(a,b,c){return Qfb(cjd(jWc(a),ajd(b.b)),cjd(jWc(a),ajd(c.b)))} + function BXc(a,b,c){return Qfb(cjd(jWc(a),ajd(b.e)),cjd(jWc(a),ajd(c.e)))} + function Kad(a,b){return $wnd.Math.min(bjd(b.a,a.d.d.c),bjd(b.b,a.d.d.c))} + function LHd(a,b){a._i(a.i+1);MHd(a,a.i,a.Zi(a.i,b));a.Mi(a.i++,b);a.Ni();} + function OHd(a){var b,c;++a.j;b=a.g;c=a.i;a.g=null;a.i=0;a.Oi(c,b);a.Ni();} + function yke(a,b,c){var d;d=new zke(a.a);Ld(d,a.a.a);rtb(d.f,b,c);a.a.a=d;} + function mKb(a,b,c,d){var e;for(e=0;eb){throw Adb(new veb(Jb(a,b,'index')))}return a} + function Xmb(a,b){var c;c=(tFb(b,a.c.length),a.c[b]);$Eb(a.c,b,1);return c} + function jhb(a,b){var c,d;c=(uFb(a),a);d=(uFb(b),b);return c==d?0:cb.p){return -1}return 0} + function hXd(a){var b;if(!a.a){b=a.r;ZD(b,156)&&(a.a=RD(b,156));}return a.a} + function iOd(a,b,c){var d;++a.e;--a.f;d=RD(a.d[b].gd(c),136);return d.md()} + function fd(a){var b,c;b=a.ld();c=RD(a.md(),16);return gk(c.Nc(),new jh(b))} + function oae(a,b){if(Ujb(a.a,b)){_jb(a.a,b);return true}else {return false}} + function Ui(a,b,c){Pb(b,a.e.Rd().gc());Pb(c,a.c.Rd().gc());return a.a[b][c]} + function _Uc(a,b,c){this.a=a;this.b=b;this.c=c;Rmb(a.t,this);Rmb(b.i,this);} + function lg(a,b,c,d){this.f=a;this.e=b;this.d=c;this.b=d;this.c=!d?null:d.d;} + function YWc(){this.b=new Yub;this.a=new Yub;this.b=new Yub;this.a=new Yub;} + function ree(){ree=geb;var a,b;pee=(jTd(),b=new k1d,b);qee=(a=new mXd,a);} + function UCb(a){var b;MCb(a);b=new $Cb(a,a.a.e,a.a.d|4);return new WCb(a,b)} + function ADb(a){var b;LCb(a);b=0;while(a.a.Bd(new MEb)){b=Bdb(b,1);}return b} + function zxb(a,b){uFb(b);if(a.c=0,'Initial capacity must not be negative');} + function rid(){rid=geb;qid=new jGd('org.eclipse.elk.labels.labelManager');} + function iec(){iec=geb;hec=new kGd('separateLayerConnections',(vec(),uec));} + function fTc(){fTc=geb;eTc=new gTc('REGULAR',0);dTc=new gTc('CRITICAL',1);} + function Mbd(){Mbd=geb;Lbd=new Nbd('FIXED',0);Kbd=new Nbd('CENTER_NODE',1);} + function jtc(){jtc=geb;htc=new ktc('QUADRATIC',0);itc=new ktc('SCANLINE',1);} + function Atc(){Atc=geb;ztc=ss((stc(),cD(WC(_W,1),jwe,322,0,[qtc,ptc,rtc])));} + function Jtc(){Jtc=geb;Itc=ss((Etc(),cD(WC(aX,1),jwe,351,0,[Btc,Dtc,Ctc])));} + function ooc(){ooc=geb;noc=ss((joc(),cD(WC(UV,1),jwe,372,0,[ioc,hoc,goc])));} + function muc(){muc=geb;luc=ss((huc(),cD(WC(dX,1),jwe,460,0,[fuc,euc,guc])));} + function Cvc(){Cvc=geb;Bvc=ss((xvc(),cD(WC(jX,1),jwe,299,0,[vvc,wvc,uvc])));} + function Lvc(){Lvc=geb;Kvc=ss((Gvc(),cD(WC(kX,1),jwe,311,0,[Evc,Fvc,Dvc])));} + function rDc(){rDc=geb;qDc=ss((lDc(),cD(WC(sX,1),jwe,390,0,[iDc,jDc,kDc])));} + function PEc(){PEc=geb;OEc=ss((KEc(),cD(WC(zX,1),jwe,387,0,[HEc,IEc,JEc])));} + function YEc(){YEc=geb;XEc=ss((TEc(),cD(WC(AX,1),jwe,349,0,[SEc,QEc,REc])));} + function GEc(){GEc=geb;FEc=ss((BEc(),cD(WC(yX,1),jwe,463,0,[AEc,yEc,zEc])));} + function qFc(){qFc=geb;pFc=ss((lFc(),cD(WC(CX,1),jwe,350,0,[iFc,jFc,kFc])));} + function zFc(){zFc=geb;yFc=ss((uFc(),cD(WC(DX,1),jwe,352,0,[tFc,rFc,sFc])));} + function IFc(){IFc=geb;HFc=ss((DFc(),cD(WC(EX,1),jwe,388,0,[BFc,CFc,AFc])));} + function QZc(){QZc=geb;PZc=ss((LZc(),cD(WC(F_,1),jwe,392,0,[KZc,JZc,IZc])));} + function m4c(){m4c=geb;l4c=ss((g4c(),cD(WC(I0,1),jwe,393,0,[d4c,e4c,f4c])));} + function z5c(){z5c=geb;y5c=ss((t5c(),cD(WC(N0,1),jwe,300,0,[r5c,s5c,q5c])));} + function k6c(){k6c=geb;j6c=ss((f6c(),cD(WC(V0,1),jwe,445,0,[c6c,d6c,e6c])));} + function F6c(){F6c=geb;E6c=ss((z6c(),cD(WC(Z0,1),jwe,456,0,[w6c,y6c,x6c])));} + function e7c(){e7c=geb;d7c=ss((_6c(),cD(WC(a1,1),jwe,394,0,[Z6c,$6c,Y6c])));} + function j9c(){j9c=geb;i9c=ss((b9c(),cD(WC(o1,1),jwe,439,0,[$8c,a9c,_8c])));} + function WKc(){WKc=geb;VKc=ss((RKc(),cD(WC(nY,1),jwe,464,0,[OKc,PKc,QKc])));} + function JKb(){JKb=geb;IKb=ss((EKb(),cD(WC(MN,1),jwe,471,0,[CKb,BKb,DKb])));} + function cKb(){cKb=geb;bKb=ss((ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])));} + function ALb(){ALb=geb;zLb=ss((vLb(),cD(WC(TN,1),jwe,472,0,[uLb,tLb,sLb])));} + function CBb(){CBb=geb;BBb=ss((xBb(),cD(WC(QL,1),jwe,108,0,[uBb,vBb,wBb])));} + function FWb(){FWb=geb;EWb=ss((AWb(),cD(WC(JP,1),jwe,391,0,[yWb,xWb,zWb])));} + function Knd(){Knd=geb;Jnd=ss((Fnd(),cD(WC(y3,1),jwe,346,0,[Dnd,Cnd,End])));} + function lbd(){lbd=geb;kbd=ss((gbd(),cD(WC(I1,1),jwe,444,0,[dbd,ebd,fbd])));} + function Tmd(){Tmd=geb;Smd=ss((Omd(),cD(WC(t3,1),jwe,278,0,[Lmd,Mmd,Nmd])));} + function rqd(){rqd=geb;qqd=ss((mqd(),cD(WC(J3,1),jwe,280,0,[kqd,jqd,lqd])));} + function Hxd(a,b){return !a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),QNd(a.o,b)} + function HMb(a,b){var c;if(a.C){c=RD(Vrb(a.b,b),127).n;c.d=a.C.d;c.a=a.C.a;}} + function F8b(a){var b,c,d,e;e=a.d;b=a.a;c=a.b;d=a.c;a.d=c;a.a=d;a.b=e;a.c=b;} + function cOd(a){!a.g&&(a.g=new hQd);!a.g.b&&(a.g.b=new ePd(a));return a.g.b} + function dOd(a){!a.g&&(a.g=new hQd);!a.g.c&&(a.g.c=new IPd(a));return a.g.c} + function lOd(a){!a.g&&(a.g=new hQd);!a.g.d&&(a.g.d=new kPd(a));return a.g.d} + function YNd(a){!a.g&&(a.g=new hQd);!a.g.a&&(a.g.a=new qPd(a));return a.g.a} + function B9d(a,b,c,d){!!c&&(d=c.Rh(b,BYd(c.Dh(),a.c.uk()),null,d));return d} + function C9d(a,b,c,d){!!c&&(d=c.Th(b,BYd(c.Dh(),a.c.uk()),null,d));return d} + function Cjb(a,b,c,d){var e;e=$C(kE,Pwe,28,b+1,15,1);Djb(e,a,b,c,d);return e} + function $C(a,b,c,d,e,f){var g;g=_C(e,d);e!=10&&cD(WC(a,f),b,c,e,g);return g} + function $fe(a,b,c){var d,e;e=new Phe(b,a);for(d=0;dc||b=0?a.Lh(c,true,true):Qvd(a,b,true)} + function gMc(a,b,c){var d;d=qMc(a,b,c);a.b=new _Lc(d.c.length);return iMc(a,d)} + function Pue(a){if(a.b<=0)throw Adb(new Dvb);--a.b;a.a-=a.c.c;return sgb(a.a)} + function PGd(a){var b;if(!a.a){throw Adb(new Evb)}b=a.a;a.a=vCd(a.a);return b} + function WDb(a){while(!a.a){if(!yEb(a.c,new $Db(a))){return false}}return true} + function Nr(a){var b;Qb(a);if(ZD(a,204)){b=RD(a,204);return b}return new Or(a)} + function Cfd(a){Afd();RD(a.of((umd(),Lld)),181).Fc((Pod(),Mod));a.qf(Kld,null);} + function Afd(){Afd=geb;xfd=new Gfd;zfd=new Ifd;yfd=yn((umd(),Kld),xfd,pld,zfd);} + function Y3c(){Y3c=geb;W3c=new $3c('LEAF_NUMBER',0);X3c=new $3c('NODE_SIZE',1);} + function YLc(a){a.a=$C(kE,Pwe,28,a.b+1,15,1);a.c=$C(kE,Pwe,28,a.b,15,1);a.d=0;} + function OZb(a,b){if(a.a.Ne(b.d,a.b)>0){Rmb(a.c,new fZb(b.c,b.d,a.d));a.b=b.d;}} + function NHd(a,b){if(a.g==null||b>=a.i)throw Adb(new yNd(b,a.i));return a.g[b]} + function P_d(a,b,c){gHd(a,c);if(c!=null&&!a.fk(c)){throw Adb(new yeb)}return c} + function dD(a,b){XC(b)!=10&&cD(rb(b),b.Sm,b.__elementTypeId$,XC(b),a);return a} + function Wnb(a,b,c,d){var e;d=(urb(),!d?rrb:d);e=a.slice(b,c);Xnb(e,a,b,c,-b,d);} + function zvd(a,b,c,d,e){return b<0?Qvd(a,c,d):RD(c,69).wk().yk(a,a.hi(),b,d,e)} + function J9b(a,b){return Qfb(Kfb(UD(mQb(a,(Ywc(),Jwc)))),Kfb(UD(mQb(b,Jwc))))} + function qAb(){qAb=geb;pAb=ss((cAb(),cD(WC(AL,1),jwe,304,0,[$zb,_zb,aAb,bAb])));} + function cAb(){cAb=geb;$zb=new dAb('All',0);_zb=new iAb;aAb=new kAb;bAb=new nAb;} + function EKb(){EKb=geb;CKb=new FKb(Nye,0);BKb=new FKb(Kye,1);DKb=new FKb(Oye,2);} + function Zme(){Zme=geb;qAd();Wme=oxe;Vme=pxe;Yme=new Tfb(oxe);Xme=new Tfb(pxe);} + function rOb(){rOb=geb;qOb=ss((mOb(),cD(WC(hO,1),jwe,417,0,[lOb,iOb,jOb,kOb])));} + function NRb(){NRb=geb;MRb=ss((IRb(),cD(WC(WO,1),jwe,406,0,[FRb,ERb,GRb,HRb])));} + function NPb(){NPb=geb;MPb=ss((IPb(),cD(WC(DO,1),jwe,332,0,[FPb,EPb,GPb,HPb])));} + function Z$b(){Z$b=geb;Y$b=ss((U$b(),cD(WC(CQ,1),jwe,389,0,[T$b,R$b,Q$b,S$b])));} + function wZb(){wZb=geb;vZb=ss((nZb(),cD(WC(lQ,1),jwe,416,0,[jZb,mZb,kZb,lZb])));} + function jnc(){jnc=geb;inc=ss((enc(),cD(WC(LV,1),jwe,421,0,[anc,bnc,cnc,dnc])));} + function Bec(){Bec=geb;Aec=ss((vec(),cD(WC(qT,1),jwe,371,0,[uec,sec,tec,rec])));} + function DDc(){DDc=geb;CDc=ss((wDc(),cD(WC(tX,1),jwe,203,0,[uDc,vDc,tDc,sDc])));} + function pEc(){pEc=geb;oEc=ss((kEc(),cD(WC(wX,1),jwe,284,0,[hEc,gEc,iEc,jEc])));} + function Cuc(){Cuc=geb;Buc=new Duc(LAe,0);Auc=new Duc('IMPROVE_STRAIGHTNESS',1);} + function _i(a,b){var c,d;d=b/a.c.Rd().gc()|0;c=b%a.c.Rd().gc();return Ui(a,d,c)} + function iZd(a){var b;if(a.nl()){for(b=a.i-1;b>=0;--b){QHd(a,b);}}return WHd(a)} + function Nyb(a){var b,c;if(!a.b){return null}c=a.b;while(b=c.a[0]){c=b;}return c} + function Oyb(a){var b,c;if(!a.b){return null}c=a.b;while(b=c.a[1]){c=b;}return c} + function Hae(a){if(ZD(a,180)){return ''+RD(a,180).a}return a==null?null:jeb(a)} + function Iae(a){if(ZD(a,180)){return ''+RD(a,180).a}return a==null?null:jeb(a)} + function eGb(a,b){if(b.a){throw Adb(new yz(jye))}Ysb(a.a,b);b.a=a;!a.j&&(a.j=b);} + function hEb(a,b){xxb.call(this,b.zd(),b.yd()&-16449);uFb(a);this.a=a;this.c=b;} + function zXc(a,b){return new gud(b,Zid(ajd(b.e),b.f.a+a,b.f.b+a),(Geb(),false))} + function EMc(a,b){dMc();return Rmb(a,new Ptd(b,sgb(b.e.c.length+b.g.c.length)))} + function GMc(a,b){dMc();return Rmb(a,new Ptd(b,sgb(b.e.c.length+b.g.c.length)))} + function p5c(){p5c=geb;o5c=ss((j5c(),cD(WC(M0,1),jwe,354,0,[i5c,g5c,h5c,f5c])));} + function x_c(){x_c=geb;w_c=ss((s_c(),cD(WC(J_,1),jwe,353,0,[r_c,p_c,q_c,o_c])));} + function eWc(){eWc=geb;dWc=ss((YVc(),cD(WC(H$,1),jwe,405,0,[UVc,VVc,WVc,XVc])));} + function bnd(){bnd=geb;and=ss((Ymd(),cD(WC(u3,1),jwe,223,0,[Xmd,Vmd,Umd,Wmd])));} + function Vnd(){Vnd=geb;Und=ss((Pnd(),cD(WC(z3,1),jwe,291,0,[Ond,Lnd,Mnd,Nnd])));} + function Vpd(){Vpd=geb;Upd=ss((Qpd(),cD(WC(H3,1),jwe,386,0,[Opd,Ppd,Npd,Mpd])));} + function Lrd(){Lrd=geb;Krd=ss((Grd(),cD(WC(R3,1),jwe,320,0,[Frd,Crd,Erd,Drd])));} + function ytd(){ytd=geb;xtd=ss((ttd(),cD(WC(n4,1),jwe,415,0,[qtd,rtd,ptd,std])));} + function b9c(){b9c=geb;$8c=new d9c(iFe,0);a9c=new d9c(mEe,1);_8c=new d9c(LAe,2);} + function sBb(a,b,c,d,e){uFb(a);uFb(b);uFb(c);uFb(d);uFb(e);return new DBb(a,b,d)} + function fub(a,b){var c;c=RD(_jb(a.e,b),400);if(c){rub(c);return c.e}return null} + function Ymb(a,b){var c;c=Wmb(a,b,0);if(c==-1){return false}Xmb(a,c);return true} + function LDb(a,b,c){var d;LCb(a);d=new IEb;d.a=b;a.a.Nb(new QEb(d,c));return d.a} + function VCb(a){var b;LCb(a);b=$C(iE,vxe,28,0,15,1);ixb(a.a,new dDb(b));return b} + function yc(a){var b;if(!xc(a)){throw Adb(new Dvb)}a.e=1;b=a.d;a.d=null;return b} + function Odb(a){var b;if(Kdb(a)){b=0-a;if(!isNaN(b)){return b}}return Edb(xD(a))} + function Wmb(a,b,c){for(;c=0?Dvd(a,c,true,true):Qvd(a,b,true)} + function Vwd(a){var b;b=SD(Ywd(a,32));if(b==null){Wwd(a);b=SD(Ywd(a,32));}return b} + function Yvd(a){var b;if(!a.Oh()){b=AYd(a.Dh())-a.ji();a.$h().Mk(b);}return a.zh()} + function zQb(a,b){yQb=new kRb;wQb=b;xQb=a;RD(xQb.b,68);BQb(xQb,yQb,null);AQb(xQb);} + function AWb(){AWb=geb;yWb=new BWb('XY',0);xWb=new BWb('X',1);zWb=new BWb('Y',2);} + function vLb(){vLb=geb;uLb=new wLb('TOP',0);tLb=new wLb(Kye,1);sLb=new wLb(Qye,2);} + function Gvc(){Gvc=geb;Evc=new Hvc(LAe,0);Fvc=new Hvc('TOP',1);Dvc=new Hvc(Qye,2);} + function sEc(){sEc=geb;qEc=new tEc('INPUT_ORDER',0);rEc=new tEc('PORT_DEGREE',1);} + function MD(){MD=geb;ID=hD(dxe,dxe,524287);JD=hD(0,0,fxe);KD=fD(1);fD(2);LD=fD(0);} + function wWd(a){var b;if(a.d!=a.r){b=WVd(a);a.e=!!b&&b.lk()==aKe;a.d=b;}return a.e} + function UHd(a,b,c){var d;d=a.g[b];MHd(a,b,a.Zi(b,c));a.Ri(b,c,d);a.Ni();return d} + function dHd(a,b){var c;c=a.dd(b);if(c>=0){a.gd(c);return true}else {return false}} + function xr(a,b){var c;Qb(a);Qb(b);c=false;while(b.Ob()){c=c|a.Fc(b.Pb());}return c} + function cub(a,b){var c;c=RD(Wjb(a.e,b),400);if(c){eub(a,c);return c.e}return null} + function iB(a){var b,c;b=a/60|0;c=a%60;if(c==0){return ''+b}return ''+b+':'+(''+c)} + function JB(d,a){var b=d.a[a];var c=(HC(),GC)[typeof b];return c?c(b):NC(typeof b)} + function EDb(a,b){var c,d;MCb(a);d=new zEb(b,a.a);c=new YDb(d);return new SDb(a,c)} + function mwb(a){var b;b=a.b.c.length==0?null:Vmb(a.b,0);b!=null&&owb(a,0);return b} + function ukc(a,b){var c,d,e;e=b.c.i;c=RD(Wjb(a.f,e),60);d=c.d.c-c.e.c;Bjd(b.a,d,0);} + function XLc(a,b){var c;++a.d;++a.c[b];c=b+1;while(c=0){++b[0];}} + function eEd(a,b){Dyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function fEd(a,b){Eyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function gEd(a,b){Cyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function hEd(a,b){Ayd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function oWc(a,b,c){return cjd(new rjd(c.e.a+c.f.a/2,c.e.b+c.f.b/2),a)==(uFb(b),b)} + function qge(a,b){return ZD(b,102)&&(RD(b,19).Bb&txe)!=0?new She(b,a):new Phe(b,a)} + function sge(a,b){return ZD(b,102)&&(RD(b,19).Bb&txe)!=0?new She(b,a):new Phe(b,a)} + function XC(a){return a.__elementTypeCategory$==null?10:a.__elementTypeCategory$} + function Bhb(a,b){return b==(wvb(),wvb(),vvb)?a.toLocaleLowerCase():a.toLowerCase()} + function Mu(a){if(!a.e){throw Adb(new Dvb)}a.c=a.a=a.e;a.e=a.e.e;--a.d;return a.a.f} + function Lu(a){if(!a.c){throw Adb(new Dvb)}a.e=a.a=a.c;a.c=a.c.c;++a.d;return a.a.f} + function Lsb(a){var b;++a.a;for(b=a.c.a.length;a.aa.a[d]&&(d=c);}return d} + function Krc(a){var b;b=RD(mQb(a,(Ywc(),Wvc)),313);if(b){return b.a==a}return false} + function Lrc(a){var b;b=RD(mQb(a,(Ywc(),Wvc)),313);if(b){return b.i==a}return false} + function xXb(){xXb=geb;wXb=ss((sXb(),cD(WC(UP,1),jwe,367,0,[nXb,oXb,pXb,qXb,rXb])));} + function Hnc(){Hnc=geb;Gnc=ss((Bnc(),cD(WC(TV,1),jwe,375,0,[xnc,znc,Anc,ync,wnc])));} + function Xtc(){Xtc=geb;Wtc=ss((Ptc(),cD(WC(bX,1),jwe,348,0,[Ltc,Ktc,Ntc,Otc,Mtc])));} + function RDc(){RDc=geb;QDc=ss((JDc(),cD(WC(uX,1),jwe,323,0,[IDc,FDc,GDc,EDc,HDc])));} + function hxc(){hxc=geb;gxc=ss((cxc(),cD(WC(mX,1),jwe,171,0,[bxc,Zwc,$wc,_wc,axc])));} + function m3c(){m3c=geb;l3c=ss((g3c(),cD(WC(x0,1),jwe,368,0,[e3c,b3c,f3c,c3c,d3c])));} + function xad(){xad=geb;wad=ss((sad(),cD(WC(x1,1),jwe,373,0,[oad,nad,qad,pad,rad])));} + function acd(){acd=geb;_bd=ss((Xbd(),cD(WC(P1,1),jwe,324,0,[Sbd,Tbd,Wbd,Ubd,Vbd])));} + function Kmd(){Kmd=geb;Jmd=ss((Cmd(),cD(WC(s3,1),jwe,88,0,[Amd,zmd,ymd,xmd,Bmd])));} + function bid(){bid=geb;aid=ss((Yhd(),cD(WC(d3,1),jwe,170,0,[Whd,Vhd,Thd,Xhd,Uhd])));} + function uod(){uod=geb;tod=ss((pod(),cD(WC(B3,1),jwe,256,0,[mod,ood,kod,lod,nod])));} + function zpd(){zpd=geb;ypd=ss((qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])));} + function LHb(){LHb=geb;JHb=new MHb('BY_SIZE',0);KHb=new MHb('BY_SIZE_AND_SHAPE',1);} + function TUb(){TUb=geb;RUb=new UUb('EADES',0);SUb=new UUb('FRUCHTERMAN_REINGOLD',1);} + function $tc(){$tc=geb;Ytc=new _tc('READING_DIRECTION',0);Ztc=new _tc('ROTATION',1);} + function CZb(){CZb=geb;zZb=new ZZb;AZb=new b$b;xZb=new f$b;yZb=new j$b;BZb=new n$b;} + function dGb(a){this.b=new bnb;this.a=new bnb;this.c=new bnb;this.d=new bnb;this.e=a;} + function XZb(a){this.g=a;this.f=new bnb;this.a=$wnd.Math.min(this.g.c.c,this.g.d.c);} + function UKb(a,b,c){RJb.call(this);KKb(this);this.a=a;this.c=c;this.b=b.d;this.f=b.e;} + function d6b(a,b,c){var d,e;for(e=new Anb(c);e.a=0&&b0?b-1:b;return Kqd(Lqd(Mqd(Nqd(new Oqd,c),a.n),a.j),a.k)} + function nBd(a){var b,c;c=(b=new q4d,b);WGd((!a.q&&(a.q=new C5d(s7,a,11,10)),a.q),c);} + function ofb(a){return ((a.i&2)!=0?'interface ':(a.i&1)!=0?'':'class ')+(lfb(a),a.o)} + function dz(a){if(Ddb(a,lve)>0){return lve}if(Ddb(a,qwe)<0){return qwe}return Ydb(a)} + function Sv(a){if(a<3){dk(a,fwe);return a+1}if(a=-0.01&&a.a<=Tye&&(a.a=0);a.b>=-0.01&&a.b<=Tye&&(a.b=0);return a} + function Hid(a){tid();var b,c;c=KEe;for(b=0;bc&&(c=a[b]);}return c} + function Zvd(a,b){var c;c=wYd(a.Dh(),b);if(!c){throw Adb(new agb(KHe+b+NHe))}return c} + function NGd(a,b){var c;c=a;while(vCd(c)){c=vCd(c);if(c==b){return true}}return false} + function ix(a,b){var c,d,e;d=b.a.ld();c=RD(b.a.md(),16).gc();for(e=0;ea||a>b){throw Adb(new xeb('fromIndex: 0, toIndex: '+a+Qxe+b))}} + function ZHd(a){if(a<0){throw Adb(new agb('Illegal Capacity: '+a))}this.g=this.aj(a);} + function _y(a,b){Zy();bz(pwe);return $wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)} + function xJc(a,b){var c,d,e,f;for(d=a.d,e=0,f=d.length;e0){a.a/=b;a.b/=b;}return a} + function BXd(a){var b;if(a.w){return a.w}else {b=CXd(a);!!b&&!b.Vh()&&(a.w=b);return b}} + function l2d(a,b){var c,d;d=a.a;c=m2d(a,b,null);d!=b&&!a.e&&(c=o2d(a,b,c));!!c&&c.oj();} + function rQc(a,b,c){var d,e;d=b;do{e=Kfb(a.p[d.p])+c;a.p[d.p]=e;d=a.a[d.p];}while(d!=b)} + function heb(a,b,c){var d=function(){return a.apply(d,arguments)};b.apply(d,c);return d} + function Gae(a){var b;if(a==null){return null}else {b=RD(a,195);return sAd(b,b.length)}} + function QHd(a,b){if(a.g==null||b>=a.i)throw Adb(new yNd(b,a.i));return a.Wi(b,a.g[b])} + function Dob(a,b){yob();var c,d;d=new bnb;for(c=0;c=14&&b<=16)));return a} + function ws(a,b){var c;uFb(b);c=a[':'+b];mFb(!!c,'Enum constant undefined: '+b);return c} + function tfb(a,b,c,d,e,f){var g;g=rfb(a,b);Ffb(c,g);g.i=e?8:0;g.f=d;g.e=e;g.g=f;return g} + function R3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=1;this.c=a;this.a=c;} + function T3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=2;this.c=a;this.a=c;} + function _3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=6;this.c=a;this.a=c;} + function e4d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=7;this.c=a;this.a=c;} + function X3d(a,b,c,d,e){this.d=b;this.j=d;this.e=e;this.o=-1;this.p=4;this.c=a;this.a=c;} + function iGb(a,b){var c,d,e,f;for(d=b,e=0,f=d.length;e=0)){throw Adb(new agb('tolerance ('+a+') must be >= 0'))}return a} + function hOd(a,b){var c;if(ZD(b,44)){return a.c.Mc(b)}else {c=QNd(a,b);jOd(a,b);return c}} + function yBd(a,b,c){YVd(a,b);PAd(a,c);$Vd(a,0);bWd(a,1);aWd(a,true);_Vd(a,true);return a} + function ZGd(a,b){var c;c=a.gc();if(b<0||b>c)throw Adb(new aMd(b,c));return new CMd(a,b)} + function Cad(a,b){a.b=$wnd.Math.max(a.b,b.d);a.e+=b.r+(a.a.c.length==0?0:a.c);Rmb(a.a,b);} + function Jmb(a){yFb(a.c>=0);if(rmb(a.d,a.c)<0){a.a=a.a-1&a.d.a.length-1;a.b=a.d.c;}a.c=-1;} + function Nc(a){var b,c;for(c=a.c.Cc().Kc();c.Ob();){b=RD(c.Pb(),16);b.$b();}a.c.$b();a.d=0;} + function Zi(a){var b,c,d,e;for(c=a.a,d=0,e=c.length;d=0} + function Iqd(a,b){if(a.r>0&&a.c0&&a.g!=0&&Iqd(a.i,b/a.r*a.i.d);}} + function $Cd(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.c));} + function P1d(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,4,c,a.c));} + function jyd(a,b){var c;c=a.k;a.k=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,2,c,a.k));} + function JXd(a,b){var c;c=a.D;a.D=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,2,c,a.D));} + function Kzd(a,b){var c;c=a.f;a.f=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,8,c,a.f));} + function Lzd(a,b){var c;c=a.i;a.i=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,7,c,a.i));} + function fCd(a,b){var c;c=a.a;a.a=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,8,c,a.a));} + function ZCd(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,c,a.b));} + function s6d(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,c,a.b));} + function t6d(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.c));} + function nVd(a,b){var c;c=a.d;a.d=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.d));} + function Cte(a,b,c){var d;a.b=b;a.a=c;d=(a.a&512)==512?new Gre:new Tqe;a.c=Nqe(d,a.b,a.a);} + function Gge(a,b){return qke(a.e,b)?(nke(),wWd(b)?new ole(b,a):new Eke(b,a)):new Ble(b,a)} + function iDb(a){var b,c;if(0>a){return new rDb}b=a+1;c=new kDb(b,a);return new oDb(null,c)} + function Gob(a,b){yob();var c;c=new Usb(1);bE(a)?$jb(c,a,b):rtb(c.f,a,b);return new uqb(c)} + function pQc(a,b){var c,d;c=a.c;d=b.e[a.p];if(d>0){return RD(Vmb(c.a,d-1),10)}return null} + function TOb(a,b){var c,d;c=a.o+a.p;d=b.o+b.p;if(cb){b<<=1;return b>0?b:hwe}return b} + function xc(a){Ub(a.e!=3);switch(a.e){case 2:return false;case 0:return true;}return zc(a)} + function djd(a,b){var c;if(ZD(b,8)){c=RD(b,8);return a.a==c.a&&a.b==c.b}else {return false}} + function Ydd(a,b){var c;c=new kRb;RD(b.b,68);RD(b.b,68);RD(b.b,68);Umb(b.a,new ced(a,c,b));} + function gOd(a,b){var c,d;for(d=b.vc().Kc();d.Ob();){c=RD(d.Pb(),44);fOd(a,c.ld(),c.md());}} + function Jzd(a,b){var c;c=a.d;a.d=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,11,c,a.d));} + function zWd(a,b){var c;c=a.j;a.j=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,13,c,a.j));} + function b6d(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,21,c,a.b));} + function YAb(a,b){((gBb(),dBb)?null:b.c).length==0&&iBb(b,new rBb);$jb(a.a,dBb?null:b.c,b);} + function b9b(a,b){b.Ug('Hierarchical port constraint processing',1);c9b(a);e9b(a);b.Vg();} + function joc(){joc=geb;ioc=new koc('START',0);hoc=new koc('MIDDLE',1);goc=new koc('END',2);} + function x2c(){x2c=geb;v2c=new z2c('P1_NODE_PLACEMENT',0);w2c=new z2c('P2_EDGE_ROUTING',1);} + function JVb(){JVb=geb;HVb=new jGd(rAe);IVb=new jGd(sAe);GVb=new jGd(tAe);FVb=new jGd(uAe);} + function tkb(a){var b;rFb(a.f.g,a.d);sFb(a.b);a.c=a.a;b=RD(a.a.Pb(),44);a.b=skb(a);return b} + function P2d(a){var b;if(a.b==null){return j3d(),j3d(),i3d}b=a.ul()?a.tl():a.sl();return b} + function nwb(a,b){var c;c=b==null?-1:Wmb(a.b,b,0);if(c<0){return false}owb(a,c);return true} + function zsb(a,b){var c;uFb(b);c=b.g;if(!a.b[c]){bD(a.b,c,b);++a.c;return true}return false} + function azb(a,b){var c,d;c=1-b;d=a.a[c];a.a[c]=d.a[b];d.a[b]=a;a.b=true;d.b=false;return d} + function xRb(a,b){var c,d;for(d=b.Kc();d.Ob();){c=RD(d.Pb(),272);a.b=true;Ysb(a.e,c);c.b=a;}} + function kic(a,b){var c,d;c=RD(mQb(a,(yCc(),IBc)),8);d=RD(mQb(b,IBc),8);return Qfb(c.b,d.b)} + function SPb(a,b,c){var d,e,f;f=b>>5;e=b&31;d=Cdb(Udb(a.n[c][f],Ydb(Sdb(e,1))),3);return d} + function lmb(a,b,c){var d,e,f;f=a.a.length-1;for(e=a.b,d=0;d0?1:0}return (!a.c&&(a.c=ojb(Hdb(a.f))),a.c).e} + function GXd(a,b){if(b){if(a.B==null){a.B=a.D;a.D=null;}}else if(a.B!=null){a.D=a.B;a.B=null;}} + function rZb(a,b){nZb();return a==jZb&&b==mZb||a==mZb&&b==jZb||a==lZb&&b==kZb||a==kZb&&b==lZb} + function sZb(a,b){nZb();return a==jZb&&b==kZb||a==jZb&&b==lZb||a==mZb&&b==lZb||a==mZb&&b==kZb} + function zMb(a,b){return Zy(),bz(Tye),$wnd.Math.abs(0-b)<=Tye||0==b||isNaN(0)&&isNaN(b)?0:a/b} + function qsc(a,b){return Kfb(UD(Lvb(MDb(GDb(new SDb(null,new Swb(a.c.b,16)),new Isc(a)),b))))} + function tsc(a,b){return Kfb(UD(Lvb(MDb(GDb(new SDb(null,new Swb(a.c.b,16)),new Gsc(a)),b))))} + function rvc(){ovc();return cD(WC(iX,1),jwe,259,0,[fvc,hvc,ivc,jvc,kvc,lvc,nvc,evc,gvc,mvc])} + function dEc(){aEc();return cD(WC(vX,1),jwe,243,0,[$Dc,VDc,YDc,WDc,XDc,SDc,ZDc,_Dc,TDc,UDc])} + function z3c(a,b){var c;b.Ug('General Compactor',1);c=h4c(RD(Gxd(a,($4c(),I4c)),393));c.Cg(a);} + function T5c(a,b){var c,d;c=RD(Gxd(a,($4c(),P4c)),17);d=RD(Gxd(b,P4c),17);return hgb(c.a,d.a)} + function Bjd(a,b,c){var d,e;for(e=Sub(a,0);e.b!=e.d.c;){d=RD(evb(e),8);d.a+=b;d.b+=c;}return a} + function Go(a,b,c){var d;for(d=a.b[c&a.f];d;d=d.b){if(c==d.a&&Hb(b,d.g)){return d}}return null} + function Ho(a,b,c){var d;for(d=a.c[c&a.f];d;d=d.d){if(c==d.f&&Hb(b,d.i)){return d}}return null} + function sjb(a,b,c){var d,e,f;d=0;for(e=0;e>>31;}d!=0&&(a[c]=d);} + function yzb(a,b,c,d,e,f){var g;this.c=a;g=new bnb;Syb(a,g,b,a.b,c,d,e,f);this.a=new Jkb(g,0);} + function _5c(){this.c=new T2c(0);this.b=new T2c(FEe);this.d=new T2c(EEe);this.a=new T2c(Gze);} + function kMb(a,b,c,d,e,f,g){qs.call(this,a,b);this.d=c;this.e=d;this.c=e;this.b=f;this.a=dv(g);} + function tBd(a,b,c,d,e,f,g,h,i,j,k,l,m){ABd(a,b,c,d,e,f,g,h,i,j,k,l,m);kXd(a,false);return a} + function H0b(a){if(a.b.c.i.k==(r3b(),m3b)){return RD(mQb(a.b.c.i,(Ywc(),Awc)),12)}return a.b.c} + function I0b(a){if(a.b.d.i.k==(r3b(),m3b)){return RD(mQb(a.b.d.i,(Ywc(),Awc)),12)}return a.b.d} + function nDb(a){var b;b=mDb(a);if(Gdb(b.a,0)){return bwb(),bwb(),awb}return bwb(),new ewb(b.b)} + function SCb(a){var b;b=RCb(a);if(Gdb(b.a,0)){return Tvb(),Tvb(),Svb}return Tvb(),new Yvb(b.b)} + function TCb(a){var b;b=RCb(a);if(Gdb(b.a,0)){return Tvb(),Tvb(),Svb}return Tvb(),new Yvb(b.c)} + function o8b(a){switch(a.g){case 2:return qpd(),ppd;case 4:return qpd(),Xod;default:return a;}} + function p8b(a){switch(a.g){case 1:return qpd(),npd;case 3:return qpd(),Yod;default:return a;}} + function C9c(a){switch(a.g){case 0:return new s9c;case 1:return new x9c;default:return null;}} + function Zcc(){Zcc=geb;Ycc=new kGd('edgelabelcenterednessanalysis.includelabel',(Geb(),Eeb));} + function jKc(){jKc=geb;iKc=mfd(qfd(pfd(pfd(new ufd,(sXb(),pXb),(hcc(),Qbc)),qXb,Gbc),rXb),Pbc);} + function DLc(){DLc=geb;CLc=mfd(qfd(pfd(pfd(new ufd,(sXb(),pXb),(hcc(),Qbc)),qXb,Gbc),rXb),Pbc);} + function lYd(){lYd=geb;iYd=new i1d;kYd=cD(WC(y7,1),lKe,179,0,[]);jYd=cD(WC(s7,1),mKe,62,0,[]);} + function P8b(){P8b=geb;O8b=new Q8b('TO_INTERNAL_LTR',0);N8b=new Q8b('TO_INPUT_DIRECTION',1);} + function J3b(){J3b=geb;G3b=new r4b;E3b=new w4b;F3b=new A4b;D3b=new E4b;H3b=new I4b;I3b=new M4b;} + function Cac(a,b){b.Ug(iBe,1);LJb(KJb(new PJb((i1b(),new t1b(a,false,false,new _1b)))));b.Vg();} + function M_c(a,b,c){c.Ug('DFS Treeifying phase',1);L_c(a,b);J_c(a,b);a.a=null;a.b=null;c.Vg();} + function Leb(a,b){Geb();return bE(a)?jhb(a,WD(b)):_D(a)?Jfb(a,UD(b)):$D(a)?Ieb(a,TD(b)):a.Fd(b)} + function Ld(a,b){var c,d;uFb(b);for(d=b.vc().Kc();d.Ob();){c=RD(d.Pb(),44);a.zc(c.ld(),c.md());}} + function ege(a,b,c){var d;for(d=c.Kc();d.Ob();){if(!cge(a,b,d.Pb())){return false}}return true} + function S6d(a,b,c,d,e){var f;if(c){f=BYd(b.Dh(),a.c);e=c.Rh(b,-1-(f==-1?d:f),null,e);}return e} + function T6d(a,b,c,d,e){var f;if(c){f=BYd(b.Dh(),a.c);e=c.Th(b,-1-(f==-1?d:f),null,e);}return e} + function Uib(a){var b;if(a.b==-2){if(a.e==0){b=-1;}else {for(b=0;a.a[b]==0;b++);}a.b=b;}return a.b} + function fjb(a){uFb(a);if(a.length==0){throw Adb(new Vgb('Zero length BigInteger'))}mjb(this,a);} + function $Hd(a){this.i=a.gc();if(this.i>0){this.g=this.aj(this.i+(this.i/8|0)+1);a.Qc(this.g);}} + function dmc(a,b,c){this.g=a;this.d=b;this.e=c;this.a=new bnb;bmc(this);yob();_mb(this.a,null);} + function aad(a,b){b.q=a;a.d=$wnd.Math.max(a.d,b.r);a.b+=b.d+(a.a.c.length==0?0:a.c);Rmb(a.a,b);} + function xid(a,b){var c,d,e,f;e=a.c;c=a.c+a.b;f=a.d;d=a.d+a.a;return b.a>e&&b.af&&b.be?(c=e):BFb(b,c+1);a.a=zhb(a.a,0,b)+(''+d)+yhb(a.a,c);} + function ktb(a,b){a.a=Bdb(a.a,1);a.c=$wnd.Math.min(a.c,b);a.b=$wnd.Math.max(a.b,b);a.d=Bdb(a.d,b);} + function wdc(a,b){return b1||a.Ob()){++a.a;a.g=0;b=a.i;a.Ob();return b}else {throw Adb(new Dvb)}} + function GRc(a){switch(a.a.g){case 1:return new lSc;case 3:return new VUc;default:return new WRc;}} + function fyd(a,b){switch(b){case 1:return !!a.n&&a.n.i!=0;case 2:return a.k!=null;}return Cxd(a,b)} + function Hdb(a){if(jxe>22);e=a.h+b.h+(d>>22);return hD(c&dxe,d&dxe,e&exe)} + function DD(a,b){var c,d,e;c=a.l-b.l;d=a.m-b.m+(c>>22);e=a.h-b.h+(d>>22);return hD(c&dxe,d&dxe,e&exe)} + function Jpc(a){var b,c;Hpc(a);for(c=new Anb(a.d);c.ad)throw Adb(new aMd(b,d));a.Si()&&(c=bHd(a,c));return a.Ei(b,c)} + function eQb(a,b,c,d,e){var f,g;for(g=c;g<=e;g++){for(f=b;f<=d;f++){PPb(a,f,g)||TPb(a,f,g,true,false);}}} + function uid(a){tid();var b,c,d;c=$C(l3,Nve,8,2,0,1);d=0;for(b=0;b<2;b++){d+=0.5;c[b]=Cid(d,a);}return c} + function xD(a){var b,c,d;b=~a.l+1&dxe;c=~a.m+(b==0?1:0)&dxe;d=~a.h+(b==0&&c==0?1:0)&exe;return hD(b,c,d)} + function mgb(a){var b;if(a<0){return qwe}else if(a==0){return 0}else {for(b=hwe;(b&a)==0;b>>=1);return b}} + function zSd(a,b,c){if(a>=128)return false;return a<64?Pdb(Cdb(Sdb(1,a),c),0):Pdb(Cdb(Sdb(1,a-64),b),0)} + function oQb(a,b,c){return c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c)),a} + function pQb(a,b,c){c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c));return a} + function KTb(a){var b,c;c=new gUb;kQb(c,a);pQb(c,(JVb(),HVb),a);b=new Tsb;MTb(a,c,b);LTb(a,c,b);return c} + function cIc(a){var b,c;b=a.t-a.k[a.o.p]*a.d+a.j[a.o.p]>a.f;c=a.u+a.e[a.o.p]*a.d>a.f*a.s*a.d;return b||c} + function qmc(a,b){var c,d,e,f;c=false;d=a.a[b].length;for(f=0;f=0,'Negative initial capacity');mFb(b>=0,'Non-positive load factor');akb(this);} + function iib(a,b,c,d,e){var f,g;g=a.length;f=c.length;if(b<0||d<0||e<0||b+e>g||d+e>f){throw Adb(new ueb)}} + function zob(a,b){yob();var c,d,e,f,g;g=false;for(d=b,e=0,f=d.length;e1||b>=0&&a.b<3} + function nD(a){var b,c,d;b=~a.l+1&dxe;c=~a.m+(b==0?1:0)&dxe;d=~a.h+(b==0&&c==0?1:0)&exe;a.l=b;a.m=c;a.h=d;} + function Cob(a){yob();var b,c,d;d=1;for(c=a.Kc();c.Ob();){b=c.Pb();d=31*d+(b!=null?tb(b):0);d=d|0;}return d} + function kD(a,b,c,d,e){var f;f=BD(a,b);c&&nD(f);if(e){a=mD(a,b);d?(eD=xD(a)):(eD=hD(a.l,a.m,a.h));}return f} + function Qlc(a,b,c){a.g=Wlc(a,b,(qpd(),Xod),a.b);a.d=Wlc(a,c,Xod,a.b);if(a.g.c==0||a.d.c==0){return}Tlc(a);} + function Rlc(a,b,c){a.g=Wlc(a,b,(qpd(),ppd),a.j);a.d=Wlc(a,c,ppd,a.j);if(a.g.c==0||a.d.c==0){return}Tlc(a);} + function Xyd(a,b){switch(b){case 7:return !!a.e&&a.e.i!=0;case 8:return !!a.d&&a.d.i!=0;}return wyd(a,b)} + function STb(a,b){switch(b.g){case 0:ZD(a.b,641)||(a.b=new tUb);break;case 1:ZD(a.b,642)||(a.b=new zUb);}} + function tbd(a){switch(a.g){case 0:return new _dd;default:throw Adb(new agb(eGe+(a.f!=null?a.f:''+a.g)));}} + function bdd(a){switch(a.g){case 0:return new vdd;default:throw Adb(new agb(eGe+(a.f!=null?a.f:''+a.g)));}} + function LCc(a,b,c){return !QDb(CDb(new SDb(null,new Swb(a.c,16)),new PAb(new gsd(b,c)))).Bd((xDb(),wDb))} + function mWc(a,b){return cjd(jWc(RD(mQb(b,(h_c(),H$c)),88)),new rjd(a.c.e.a-a.b.e.a,a.c.e.b-a.b.e.b))<=0} + function dve(a,b){while(a.g==null&&!a.c?sId(a):a.g==null||a.i!=0&&RD(a.g[a.i-1],51).Ob()){mFd(b,tId(a));}} + function sYb(a){var b,c;for(c=new Anb(a.a.b);c.ad?1:0} + function ICc(a){Rmb(a.c,(hed(),fed));if(_y(a.a,Kfb(UD(iGd((QCc(),OCc)))))){return new asd}return new csd(a)} + function fs(a){while(!a.d||!a.d.Ob()){if(!!a.b&&!nmb(a.b)){a.d=RD(smb(a.b),51);}else {return null}}return a.d} + function BVc(a){switch(a.g){case 1:return EEe;default:case 2:return 0;case 3:return Gze;case 4:return FEe;}} + function fte(){Vse();var a;if(Cse)return Cse;a=Zse(hte('M',true));a=$se(hte('M',false),a);Cse=a;return Cse} + function ttd(){ttd=geb;qtd=new utd('ELK',0);rtd=new utd('JSON',1);ptd=new utd('DOT',2);std=new utd('SVG',3);} + function TEc(){TEc=geb;SEc=new UEc('STACKED',0);QEc=new UEc('REVERSE_STACKED',1);REc=new UEc('SEQUENCED',2);} + function LZc(){LZc=geb;KZc=new MZc(LAe,0);JZc=new MZc('MIDDLE_TO_MIDDLE',1);IZc=new MZc('AVOID_OVERLAP',2);} + function sgc(){sgc=geb;qgc=new Lgc;rgc=new Ngc;pgc=new Dgc;ogc=new Pgc;ngc=new Hgc;mgc=(uFb(ngc),new nrb);} + function vnd(){vnd=geb;tnd=new A3b(15);snd=new mGd((umd(),tld),tnd);und=Qld;ond=Ekd;pnd=kld;rnd=nld;qnd=mld;} + function wgd(a,b){var c,d,e,f,g;for(d=b,e=0,f=d.length;e=a.b.c.length){return}jwb(a,2*b+1);c=2*b+2;c0){b.Cd(c);c.i&&zKc(c);}}} + function Ejb(a,b,c){var d;for(d=c-1;d>=0&&a[d]===b[d];d--);return d<0?0:Ldb(Cdb(a[d],yxe),Cdb(b[d],yxe))?-1:1} + function it(a,b,c){var d,e;this.g=a;this.c=b;this.a=this;this.d=this;e=Wp(c);d=$C(UG,ewe,227,e,0,1);this.b=d;} + function fQb(a,b,c,d,e){var f,g;for(g=c;g<=e;g++){for(f=b;f<=d;f++){if(PPb(a,f,g)){return true}}}return false} + function Dc(a,b){var c,d;for(d=a.Zb().Cc().Kc();d.Ob();){c=RD(d.Pb(),16);if(c.Hc(b)){return true}}return false} + function iu(a,b,c){var d,e,f,g;uFb(c);g=false;f=a.fd(b);for(e=c.Kc();e.Ob();){d=e.Pb();f.Rb(d);g=true;}return g} + function NMd(a,b){var c,d;d=RD(Ywd(a.a,4),129);c=$C(d6,IJe,424,b,0,1);d!=null&&hib(d,0,c,0,d.length);return c} + function hSd(a,b){var c;c=new lSd((a.f&256)!=0,a.i,a.a,a.d,(a.f&16)!=0,a.j,a.g,b);a.e!=null||(c.c=a);return c} + function Tv(a,b){var c;if(a===b){return true}else if(ZD(b,85)){c=RD(b,85);return Rx(gn(a),c.vc())}return false} + function Vjb(a,b,c){var d,e;for(e=c.Kc();e.Ob();){d=RD(e.Pb(),44);if(a.Be(b,d.md())){return true}}return false} + function lmc(a,b,c){if(!a.d[b.p][c.p]){kmc(a,b,c);a.d[b.p][c.p]=true;a.d[c.p][b.p]=true;}return a.a[b.p][c.p]} + function vMc(a,b){var c;if(!a||a==b||!nQb(b,(Ywc(),pwc))){return false}c=RD(mQb(b,(Ywc(),pwc)),10);return c!=a} + function Bhe(a){switch(a.i){case 2:{return true}case 1:{return false}case -1:{++a.c;}default:{return a.$l()}}} + function Che(a){switch(a.i){case -2:{return true}case -1:{return false}case 1:{--a.c;}default:{return a._l()}}} + function bgb(a){oz.call(this,'The given string does not match the expected format for individual spacings.',a);} + function J6c(a,b){var c;b.Ug('Min Size Preprocessing',1);c=vsd(a);Ixd(a,(X6c(),U6c),c.a);Ixd(a,R6c,c.b);b.Vg();} + function Djd(a){var b,c,d;b=0;d=$C(l3,Nve,8,a.b,0,1);c=Sub(a,0);while(c.b!=c.d.c){d[b++]=RD(evb(c),8);}return d} + function Ajd(a,b,c){var d,e,f;d=new Yub;for(f=Sub(c,0);f.b!=f.d.c;){e=RD(evb(f),8);Mub(d,new sjd(e));}iu(a,b,d);} + function az(a,b){var c;c=Bdb(a,b);if(Ldb($db(a,b),0)|Jdb($db(a,c),0)){return c}return Bdb(Sve,$db(Udb(c,63),1))} + function le(a,b){var c,d;c=RD(a.d.Bc(b),16);if(!c){return null}d=a.e.hc();d.Gc(c);a.e.d-=c.gc();c.$b();return d} + function Dyb(a){var b;b=a.a.c.length;if(b>0){return lyb(b-1,a.a.c.length),Xmb(a.a,b-1)}else {throw Adb(new Srb)}} + function nFb(a,b,c){if(a>b){throw Adb(new agb(_xe+a+aye+b))}if(a<0||b>c){throw Adb(new xeb(_xe+a+bye+b+Qxe+c))}} + function yXd(a,b){if(a.D==null&&a.B!=null){a.D=a.B;a.B=null;}JXd(a,b==null?null:(uFb(b),b));!!a.C&&a.hl(null);} + function JCc(a,b){var c;c=iGd((QCc(),OCc))!=null&&b.Sg()!=null?Kfb(UD(b.Sg()))/Kfb(UD(iGd(OCc))):1;Zjb(a.b,b,c);} + function $Lc(a,b){var c,d;d=a.c[b];if(d==0){return}a.c[b]=0;a.d-=d;c=b+1;while(cDEe?a-c>DEe:c-a>DEe} + function vjd(a,b){var c;for(c=0;ce){ead(b.q,e);d=c!=b.q.d;}}return d} + function C3c(a,b){var c,d,e,f,g,h,i,j;i=b.i;j=b.j;d=a.f;e=d.i;f=d.j;g=i-e;h=j-f;c=$wnd.Math.sqrt(g*g+h*h);return c} + function pBd(a,b){var c,d;d=Hvd(a);if(!d){c=(gSd(),nSd(b));d=new Sde(c);WGd(d.El(),a);}return d} + function Sc(a,b){var c,d;c=RD(a.c.Bc(b),16);if(!c){return a.jc()}d=a.hc();d.Gc(c);a.d-=c.gc();c.$b();return a.mc(d)} + function tKc(a,b){var c,d;d=Kwb(a.d,1)!=0;c=true;while(c){c=false;c=b.c.mg(b.e,d);c=c|DKc(a,b,d,false);d=!d;}yKc(a);} + function omc(a,b,c,d){var e,f;a.a=b;f=d?0:1;a.f=(e=new mmc(a.c,a.a,c,f),new Pmc(c,a.a,e,a.e,a.b,a.c==(RKc(),PKc)));} + function Imb(a){var b;sFb(a.a!=a.b);b=a.d.a[a.a];zmb(a.b==a.d.c&&b!=null);a.c=a.a;a.a=a.a+1&a.d.a.length-1;return b} + function Vib(a){var b;if(a.c!=0){return a.c}for(b=0;b=a.c.b:a.a<=a.c.b)){throw Adb(new Dvb)}b=a.a;a.a+=a.c.c;++a.b;return sgb(b)} + function h5b(a){var b;b=new y2b(a.a);kQb(b,a);pQb(b,(Ywc(),Awc),a);b.o.a=a.g;b.o.b=a.f;b.n.a=a.i;b.n.b=a.j;return b} + function tVc(a){return (qpd(),hpd).Hc(a.j)?Kfb(UD(mQb(a,(Ywc(),Swc)))):xjd(cD(WC(l3,1),Nve,8,0,[a.i.n,a.n,a.a])).b} + function ZJc(a){var b;b=vfd(XJc);RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),kvc))&&pfd(b,(sXb(),pXb),(hcc(),Ybc));return b} + function M2c(a){var b,c,d,e;e=new _sb;for(d=new Anb(a);d.a=0?b:-b;while(d>0){if(d%2==0){c*=c;d=d/2|0;}else {e*=c;d-=1;}}return b<0?1/e:e} + function Jid(a,b){var c,d,e;e=1;c=a;d=b>=0?b:-b;while(d>0){if(d%2==0){c*=c;d=d/2|0;}else {e*=c;d-=1;}}return b<0?1/e:e} + function Vvd(a,b){var c,d,e,f;f=(e=a?Hvd(a):null,Pje((d=b,e?e.Gl():null,d)));if(f==b){c=Hvd(a);!!c&&c.Gl();}return f} + function g2d(a,b,c){var d,e;e=a.f;a.f=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,0,e,b);!c?(c=d):c.nj(d);}return c} + function e2d(a,b,c){var d,e;e=a.b;a.b=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,3,e,b);!c?(c=d):c.nj(d);}return c} + function rAd(a,b,c){var d,e;e=a.a;a.a=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,1,e,b);!c?(c=d):c.nj(d);}return c} + function SNd(a){var b,c;if(a!=null){for(c=0;c=d||b-129&&a<128){return ugb(),b=a+128,c=tgb[b],!c&&(c=tgb[b]=new fgb(a)),c}return new fgb(a)} + function bhb(a){var b,c;if(a>-129&&a<128){return dhb(),b=a+128,c=chb[b],!c&&(c=chb[b]=new Xgb(a)),c}return new Xgb(a)} + function M$b(a,b){var c;if(a.a.c.length>0){c=RD(Vmb(a.a,a.a.c.length-1),579);if(Q_b(c,b)){return}}Rmb(a.a,new S_b(b));} + function Ekc(a){lkc();var b,c;b=a.d.c-a.e.c;c=RD(a.g,154);Umb(c.b,new Ykc(b));Umb(c.c,new $kc(b));xgb(c.i,new alc(b));} + function Mlc(a){var b;b=new bib;b.a+='VerticalSegment ';Yhb(b,a.e);b.a+=' ';Zhb(b,Eb(new Gb,new Anb(a.k)));return b.a} + function Fmc(a,b){var c,d,e;c=0;for(e=b3b(a,b).Kc();e.Ob();){d=RD(e.Pb(),12);c+=mQb(d,(Ywc(),Iwc))!=null?1:0;}return c} + function VTc(a,b,c){var d,e,f;d=0;for(f=Sub(a,0);f.b!=f.d.c;){e=Kfb(UD(evb(f)));if(e>c){break}else e>=b&&++d;}return d} + function Wv(b,c){Qb(b);try{return b._b(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Nk(b,c){Qb(b);try{return b.Hc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Ok(b,c){Qb(b);try{return b.Mc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Xv(b,c){Qb(b);try{return b.xc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return null}else throw Adb(a)}} + function Yv(b,c){Qb(b);try{return b.Bc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return null}else throw Adb(a)}} + function aMc(a,b){switch(b.g){case 2:case 1:return b3b(a,b);case 3:case 4:return hv(b3b(a,b));}return yob(),yob(),vob} + function QAd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (name: ';Nhb(b,a.zb);b.a+=')';return b.a} + function Fgd(a){var b;b=RD(cub(a.c.c,''),233);if(!b){b=new fgd(ogd(ngd(new pgd,''),'Other'));dub(a.c.c,'',b);}return b} + function hBd(a,b,c){var d,e;e=a.sb;a.sb=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,4,e,b);!c?(c=d):c.nj(d);}return c} + function ZVd(a,b,c){var d,e;e=a.r;a.r=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,8,e,a.r);!c?(c=d):c.nj(d);}return c} + function q5d(a,b,c){var d,e;d=new P3d(a.e,4,13,(e=b.c,e?e:(JTd(),wTd)),null,fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function p5d(a,b,c){var d,e;d=new P3d(a.e,3,13,null,(e=b.c,e?e:(JTd(),wTd)),fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function Oee(a,b){var c,d;c=RD(b,691);d=c.el();!d&&c.fl(d=ZD(b,90)?new afe(a,RD(b,29)):new mfe(a,RD(b,156)));return d} + function KHd(a,b,c){var d;a._i(a.i+1);d=a.Zi(b,c);b!=a.i&&hib(a.g,b,a.g,b+1,a.i-b);bD(a.g,b,d);++a.i;a.Mi(b,c);a.Ni();} + function Hyb(a,b){var c;if(b.a){c=b.a.a.length;!a.a?(a.a=new dib(a.d)):Zhb(a.a,a.b);Xhb(a.a,b.a,b.d.length,c);}return a} + function wib(a,b){var c;a.c=b;a.a=pjb(b);a.a<54&&(a.f=(c=b.d>1?DFb(b.a[0],b.a[1]):DFb(b.a[0],0),Xdb(b.e>0?c:Odb(c))));} + function MDb(a,b){var c;c=new IEb;if(!a.a.Bd(c)){LCb(a);return Kvb(),Kvb(),Jvb}return Kvb(),new Ovb(uFb(LDb(a,c.a,b)))} + function t9b(a,b){var c;if(a.c.length==0){return}c=RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199);Znb(c,new F9b);q9b(c,b);} + function z9b(a,b){var c;if(a.c.length==0){return}c=RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199);Znb(c,new K9b);q9b(c,b);} + function pb(a,b){return bE(a)?lhb(a,b):_D(a)?Lfb(a,b):$D(a)?(uFb(a),dE(a)===dE(b)):YD(a)?a.Fb(b):aD(a)?mb(a,b):Hz(a,b)} + function Cvd(a,b,c){if(b<0){Tvd(a,c);}else {if(!c.rk()){throw Adb(new agb(KHe+c.xe()+LHe))}RD(c,69).wk().Ek(a,a.hi(),b);}} + function xFb(a,b,c){if(a<0||b>c){throw Adb(new veb(_xe+a+bye+b+', size: '+c))}if(a>b){throw Adb(new agb(_xe+a+aye+b))}} + function oVd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (source: ';Nhb(b,a.d);b.a+=')';return b.a} + function JSd(a){if(a>=65&&a<=70){return a-65+10}if(a>=97&&a<=102){return a-97+10}if(a>=48&&a<=57){return a-48}return 0} + function lMb(a){hMb();var b,c,d,e;for(c=nMb(),d=0,e=c.length;d=0?jjb(a):Xib(jjb(Odb(a)))));} + function G0b(a,b,c,d,e,f){this.e=new bnb;this.f=(BEc(),AEc);Rmb(this.e,a);this.d=b;this.a=c;this.b=d;this.f=e;this.c=f;} + function bQb(a,b,c){a.n=YC(lE,[Nve,rxe],[376,28],14,[c,eE($wnd.Math.ceil(b/32))],2);a.o=b;a.p=c;a.j=b-1>>1;a.k=c-1>>1;} + function ggb(a){a-=a>>1&1431655765;a=(a>>2&858993459)+(a&858993459);a=(a>>4)+a&252645135;a+=a>>8;a+=a>>16;return a&63} + function C4d(a,b){var c,d;for(d=new dMd(a);d.e!=d.i.gc();){c=RD(bMd(d),142);if(dE(b)===dE(c)){return true}}return false} + function Iee(a,b,c){var d,e,f;f=(e=N5d(a.b,b),e);if(f){d=RD(tfe(Pee(a,f),''),29);if(d){return Ree(a,d,b,c)}}return null} + function Lee(a,b,c){var d,e,f;f=(e=N5d(a.b,b),e);if(f){d=RD(tfe(Pee(a,f),''),29);if(d){return See(a,d,b,c)}}return null} + function IDd(a,b){var c;c=Ao(a.i,b);if(c==null){throw Adb(new CDd('Node did not exist in input.'))}wEd(b,c);return null} + function wvd(a,b){var c;c=wYd(a,b);if(ZD(c,331)){return RD(c,35)}throw Adb(new agb(KHe+b+"' is not a valid attribute"))} + function VGd(a,b,c){var d;d=a.gc();if(b>d)throw Adb(new aMd(b,d));if(a.Si()&&a.Hc(c)){throw Adb(new agb(LIe))}a.Gi(b,c);} + function w7b(a,b){b.Ug('Sort end labels',1);FDb(CDb(EDb(new SDb(null,new Swb(a.b,16)),new H7b),new J7b),new L7b);b.Vg();} + function Cmd(){Cmd=geb;Amd=new Gmd(Sye,0);zmd=new Gmd(Oye,1);ymd=new Gmd(Nye,2);xmd=new Gmd(Zye,3);Bmd=new Gmd('UP',4);} + function gbd(){gbd=geb;dbd=new hbd('P1_STRUCTURE',0);ebd=new hbd('P2_PROCESSING_ORDER',1);fbd=new hbd('P3_EXECUTION',2);} + function r0c(){r0c=geb;q0c=mfd(mfd(rfd(mfd(mfd(rfd(pfd(new ufd,(YVc(),VVc),(WYc(),VYc)),WVc),RYc),TYc),XVc),NYc),UYc);} + function s8b(a){switch(RD(mQb(a,(Ywc(),owc)),311).g){case 1:pQb(a,owc,(Gvc(),Dvc));break;case 2:pQb(a,owc,(Gvc(),Fvc));}} + function bUc(a){switch(a){case 0:return new mUc;case 1:return new cUc;case 2:return new hUc;default:throw Adb(new _fb);}} + function Fmd(a){switch(a.g){case 2:return zmd;case 1:return ymd;case 4:return xmd;case 3:return Bmd;default:return Amd;}} + function UNb(a,b){switch(a.b.g){case 0:case 1:return b;case 2:case 3:return new Uid(b.d,0,b.a,b.b);default:return null;}} + function rpd(a){switch(a.g){case 1:return ppd;case 2:return Yod;case 3:return Xod;case 4:return npd;default:return opd;}} + function spd(a){switch(a.g){case 1:return npd;case 2:return ppd;case 3:return Yod;case 4:return Xod;default:return opd;}} + function tpd(a){switch(a.g){case 1:return Xod;case 2:return npd;case 3:return ppd;case 4:return Yod;default:return opd;}} + function cyd(a,b,c,d){switch(b){case 1:return !a.n&&(a.n=new C5d(I4,a,1,7)),a.n;case 2:return a.k;}return Axd(a,b,c,d)} + function uLd(a,b,c){var d,e;if(a.Pj()){e=a.Qj();d=SHd(a,b,c);a.Jj(a.Ij(7,sgb(c),d,b,e));return d}else {return SHd(a,b,c)}} + function VNd(a,b){var c,d,e;if(a.d==null){++a.e;--a.f;}else {e=b.ld();c=b.Bi();d=(c&lve)%a.d.length;iOd(a,d,XNd(a,d,c,e));}} + function xWd(a,b){var c;c=(a.Bb&gwe)!=0;b?(a.Bb|=gwe):(a.Bb&=-1025);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,10,c,b));} + function DWd(a,b){var c;c=(a.Bb&qxe)!=0;b?(a.Bb|=qxe):(a.Bb&=-4097);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,12,c,b));} + function EWd(a,b){var c;c=(a.Bb&bKe)!=0;b?(a.Bb|=bKe):(a.Bb&=-8193);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,15,c,b));} + function FWd(a,b){var c;c=(a.Bb&cKe)!=0;b?(a.Bb|=cKe):(a.Bb&=-2049);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,11,c,b));} + function zKc(a){var b;if(a.g){b=a.c.kg()?a.f:a.a;BKc(b.a,a.o,true);BKc(b.a,a.o,false);pQb(a.o,(yCc(),BBc),(Bod(),vod));}} + function Orc(a){var b;if(!a.a){throw Adb(new dgb('Cannot offset an unassigned cut.'))}b=a.c-a.b;a.b+=b;Qrc(a,b);Rrc(a,b);} + function JDd(a,b){var c;c=Wjb(a.k,b);if(c==null){throw Adb(new CDd('Port did not exist in input.'))}wEd(b,c);return null} + function Jje(a){var b,c;for(c=Kje(BXd(a)).Kc();c.Ob();){b=WD(c.Pb());if(bAd(a,b)){return USd((TSd(),SSd),b)}}return null} + function qJb(a){var b,c;for(c=a.p.a.ec().Kc();c.Ob();){b=RD(c.Pb(),218);if(b.f&&a.b[b.c]<-1.0E-10){return b}}return null} + function Lr(a){var b,c;c=Thb(new bib,91);b=true;while(a.Ob()){b||(c.a+=pve,c);b=false;Yhb(c,a.Pb());}return (c.a+=']',c).a} + function o_b(a){var b,c,d;b=new bnb;for(d=new Anb(a.b);d.ab){return 1}if(a==b){return a==0?Qfb(1/a,1/b):0}return isNaN(a)?isNaN(b)?0:1:-1} + function pmb(a){var b;b=a.a[a.c-1&a.a.length-1];if(b==null){return null}a.c=a.c-1&a.a.length-1;bD(a.a,a.c,null);return b} + function Dqe(a){var b,c,d;d=0;c=a.length;for(b=0;b=1?zmd:xmd}return c} + function Xhc(a){switch(RD(mQb(a,(yCc(),yAc)),223).g){case 1:return new jqc;case 3:return new arc;default:return new dqc;}} + function MCb(a){if(a.c){MCb(a.c);}else if(a.d){throw Adb(new dgb("Stream already terminated, can't be modified or used"))}} + function Ltb(a,b,c){var d;d=a.a.get(b);a.a.set(b,c===undefined?null:c);if(d===undefined){++a.c;++a.b.g;}else {++a.d;}return d} + function HHc(a,b,c){var d,e;for(e=a.a.ec().Kc();e.Ob();){d=RD(e.Pb(),10);if(Be(c,RD(Vmb(b,d.p),16))){return d}}return null} + function u0c(a,b,c){var d;d=0;!!b&&(Emd(a.a)?(d+=b.f.a/2):(d+=b.f.b/2));!!c&&(Emd(a.a)?(d+=c.f.a/2):(d+=c.f.b/2));return d} + function LWb(a,b,c){var d;d=c;!d&&(d=Nqd(new Oqd,0));d.Ug(EAe,2);y0b(a.b,b,d.eh(1));NWb(a,b,d.eh(1));h0b(b,d.eh(1));d.Vg();} + function CGd(a,b,c){var d,e;d=(bvd(),e=new Xxd,e);Vxd(d,b);Wxd(d,c);!!a&&WGd((!a.a&&(a.a=new XZd(D4,a,5)),a.a),d);return d} + function kyd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (identifier: ';Nhb(b,a.k);b.a+=')';return b.a} + function kXd(a,b){var c;c=(a.Bb&QHe)!=0;b?(a.Bb|=QHe):(a.Bb&=-32769);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,18,c,b));} + function a6d(a,b){var c;c=(a.Bb&QHe)!=0;b?(a.Bb|=QHe):(a.Bb&=-32769);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,18,c,b));} + function AWd(a,b){var c;c=(a.Bb&Ove)!=0;b?(a.Bb|=Ove):(a.Bb&=-16385);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,16,c,b));} + function c6d(a,b){var c;c=(a.Bb&txe)!=0;b?(a.Bb|=txe):(a.Bb&=-65537);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,20,c,b));} + function qse(a){var b;b=$C(hE,zwe,28,2,15,1);a-=txe;b[0]=(a>>10)+uxe&Bwe;b[1]=(a&1023)+56320&Bwe;return Ihb(b,0,b.length)} + function Zfb(a){var b;b=Neb(a);if(b>3.4028234663852886E38){return oxe}else if(b<-3.4028234663852886E38){return pxe}return b} + function Bdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a+b;if(jxe'+aXc(b.c):'e_'+tb(b),!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))} + function rWc(a,b){return lhb(!!b.b&&!!b.c?aXc(b.b)+'->'+aXc(b.c):'e_'+tb(b),!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))} + function $y(a,b){Zy();return bz(pwe),$wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b))} + function Ymd(){Ymd=geb;Xmd=new Zmd(Sye,0);Vmd=new Zmd('POLYLINE',1);Umd=new Zmd('ORTHOGONAL',2);Wmd=new Zmd('SPLINES',3);} + function _6c(){_6c=geb;Z6c=new a7c('ASPECT_RATIO_DRIVEN',0);$6c=new a7c('MAX_SCALE_DRIVEN',1);Y6c=new a7c('AREA_DRIVEN',2);} + function Db(b,c,d){var e;try{Cb(b,c,d);}catch(a){a=zdb(a);if(ZD(a,606)){e=a;throw Adb(new Deb(e))}else throw Adb(a)}return c} + function Im(a){var b,c,d;for(c=0,d=a.length;cb&&d.Ne(a[f-1],a[f])>0;--f){g=a[f];bD(a,f,a[f-1]);bD(a,f-1,g);}}} + function Egd(a,b){var c,d,e,f,g;c=b.f;dub(a.c.d,c,b);if(b.g!=null){for(e=b.g,f=0,g=e.length;fb){fvb(c);break}}cvb(c,b);} + function Kic(a,b){var c,d,e;d=Zjc(b);e=Kfb(UD(hFc(d,(yCc(),TBc))));c=$wnd.Math.max(0,e/2-0.5);Iic(b,c,1);Rmb(a,new hjc(b,c));} + function L5c(a,b,c){var d;c.Ug('Straight Line Edge Routing',1);c.dh(b,eFe);d=RD(Gxd(b,(u2c(),t2c)),27);M5c(a,d);c.dh(b,gFe);} + function K9c(a,b){a.n.c.length==0&&Rmb(a.n,new _9c(a.s,a.t,a.i));Rmb(a.b,b);W9c(RD(Vmb(a.n,a.n.c.length-1),209),b);M9c(a,b);} + function Zrb(a){var b;this.a=(b=RD(a.e&&a.e(),9),new Fsb(b,RD(WEb(b,b.length),9),0));this.b=$C(jJ,rve,1,this.a.a.length,5,1);} + function jeb(a){var b;if(Array.isArray(a)&&a.Tm===keb){return nfb(rb(a))+'@'+(b=tb(a)>>>0,b.toString(16))}return a.toString()} + function jD(a,b){if(a.h==fxe&&a.m==0&&a.l==0){b&&(eD=hD(0,0,0));return gD((MD(),KD))}b&&(eD=hD(a.l,a.m,a.h));return hD(0,0,0)} + function _Gb(a,b){switch(b.g){case 2:return a.b;case 1:return a.c;case 4:return a.d;case 3:return a.a;default:return false;}} + function IYb(a,b){switch(b.g){case 2:return a.b;case 1:return a.c;case 4:return a.d;case 3:return a.a;default:return false;}} + function vyd(a,b,c,d){switch(b){case 3:return a.f;case 4:return a.g;case 5:return a.i;case 6:return a.j;}return cyd(a,b,c,d)} + function oIb(a,b){if(b==a.d){return a.e}else if(b==a.e){return a.d}else {throw Adb(new agb('Node '+b+' not part of edge '+a))}} + function Uvd(a,b){var c;c=wYd(a.Dh(),b);if(ZD(c,102)){return RD(c,19)}throw Adb(new agb(KHe+b+"' is not a valid reference"))} + function Bvd(a,b,c,d){if(b<0){Svd(a,c,d);}else {if(!c.rk()){throw Adb(new agb(KHe+c.xe()+LHe))}RD(c,69).wk().Ck(a,a.hi(),b,d);}} + function ig(a){var b;if(a.b){ig(a.b);if(a.b.d!=a.c){throw Adb(new Jrb)}}else if(a.d.dc()){b=RD(a.f.c.xc(a.e),16);!!b&&(a.d=b);}} + function VMb(a){RMb();var b,c,d,e;b=a.o.b;for(d=RD(RD(Qc(a.r,(qpd(),npd)),21),87).Kc();d.Ob();){c=RD(d.Pb(),117);e=c.e;e.b+=b;}} + function SRb(a){var b,c,d;this.a=new Iub;for(d=new Anb(a);d.a=e){return b.c+c}}return b.c+b.b.gc()} + function lQd(a,b){jQd();var c,d,e,f;d=iZd(a);e=b;Wnb(d,0,d.length,e);for(c=0;c0){d+=e;++c;}}c>1&&(d+=a.d*(c-1));return d} + function FFd(a){var b,c,d,e,f;f=HFd(a);c=cve(a.c);d=!c;if(d){e=new MB;sC(f,'knownLayouters',e);b=new QFd(e);xgb(a.c,b);}return f} + function fHd(a){var b,c,d;d=new Qhb;d.a+='[';for(b=0,c=a.gc();b0&&(BFb(b-1,a.length),a.charCodeAt(b-1)==58)&&!mSd(a,aSd,bSd)} + function Sib(a,b){var c;if(dE(a)===dE(b)){return true}if(ZD(b,92)){c=RD(b,92);return a.e==c.e&&a.d==c.d&&Tib(a,c.a)}return false} + function vpd(a){qpd();switch(a.g){case 4:return Yod;case 1:return Xod;case 3:return npd;case 2:return ppd;default:return opd;}} + function jBb(a){var b,c;if(a.b){return a.b}c=dBb?null:a.d;while(c){b=dBb?null:c.b;if(b){return b}c=dBb?null:c.d;}return SAb(),RAb} + function LJb(a){var b,c,d;d=Kfb(UD(a.a.of((umd(),cmd))));for(c=new Anb(a.a.Sf());c.a>5;b=a&31;d=$C(kE,Pwe,28,c+1,15,1);d[c]=1<3){e*=10;--f;}a=(a+(e>>1))/e|0;}d.i=a;return true} + function BYd(a,b){var c,d,e;c=(a.i==null&&rYd(a),a.i);d=b.Lj();if(d!=-1){for(e=c.length;d=0;--d){b=c[d];for(e=0;e>1;this.k=b-1>>1;} + function Dfd(a){Afd();if(RD(a.of((umd(),pld)),181).Hc((dqd(),bqd))){RD(a.of(Lld),181).Fc((Pod(),Ood));RD(a.of(pld),181).Mc(bqd);}} + function ndc(a){var b,c;b=a.d==(btc(),Ysc);c=jdc(a);b&&!c||!b&&c?pQb(a.a,(yCc(),Rzc),(Rjd(),Pjd)):pQb(a.a,(yCc(),Rzc),(Rjd(),Ojd));} + function QCc(){QCc=geb;GCc();OCc=(yCc(),bCc);PCc=dv(cD(WC(V5,1),kEe,149,0,[SBc,TBc,VBc,WBc,ZBc,$Bc,_Bc,aCc,dCc,fCc,UBc,XBc,cCc]));} + function RDb(a,b){var c;c=RD(zDb(a,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);return c.Qc(__c(c.gc()))} + function nXc(a,b){var c,d;d=new zAb(a.a.ad(b,true));if(d.a.gc()<=1){throw Adb(new Ngb)}c=d.a.ec().Kc();c.Pb();return RD(c.Pb(),40)} + function lQc(a,b,c){var d,e;d=Kfb(a.p[b.i.p])+Kfb(a.d[b.i.p])+b.n.b+b.a.b;e=Kfb(a.p[c.i.p])+Kfb(a.d[c.i.p])+c.n.b+c.a.b;return e-d} + function XHd(a,b){var c;if(a.i>0){if(b.lengtha.i&&bD(b,a.i,null);return b} + function MXd(a){var b;if((a.Db&64)!=0)return QAd(a);b=new Shb(QAd(a));b.a+=' (instanceClassName: ';Nhb(b,a.D);b.a+=')';return b.a} + function ySd(a){var b,c,d,e;e=0;for(c=0,d=a.length;c0){a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=XNd(a,e,d,b);return c!=-1}else {return false}} + function Nrb(a,b){var c,d;a.a=Bdb(a.a,1);a.c=$wnd.Math.min(a.c,b);a.b=$wnd.Math.max(a.b,b);a.d+=b;c=b-a.f;d=a.e+c;a.f=d-a.e-c;a.e=d;} + function yyd(a,b){switch(b){case 3:Ayd(a,0);return;case 4:Cyd(a,0);return;case 5:Dyd(a,0);return;case 6:Eyd(a,0);return;}hyd(a,b);} + function c3b(a,b){switch(b.g){case 1:return dr(a.j,(J3b(),E3b));case 2:return dr(a.j,(J3b(),G3b));default:return yob(),yob(),vob;}} + function zm(a){tm();var b;b=a.Pc();switch(b.length){case 0:return sm;case 1:return new Dy(Qb(b[0]));default:return new Kx(Im(b));}} + function kMd(b,c){b.Xj();try{b.d.bd(b.e++,c);b.f=b.d.j;b.g=-1;}catch(a){a=zdb(a);if(ZD(a,77)){throw Adb(new Jrb)}else throw Adb(a)}} + function a8d(){a8d=geb;$7d=new b8d;T7d=new e8d;U7d=new h8d;V7d=new k8d;W7d=new n8d;X7d=new q8d;Y7d=new t8d;Z7d=new w8d;_7d=new z8d;} + function YA(a,b){WA();var c,d;c=_A(($A(),$A(),ZA));d=null;b==c&&(d=RD(Xjb(VA,a),624));if(!d){d=new XA(a);b==c&&$jb(VA,a,d);}return d} + function zDc(a){wDc();var b;(!a.q?(yob(),yob(),wob):a.q)._b((yCc(),iBc))?(b=RD(mQb(a,iBc),203)):(b=RD(mQb(Y2b(a),jBc),203));return b} + function hFc(a,b){var c,d;d=null;if(nQb(a,(yCc(),YBc))){c=RD(mQb(a,YBc),96);c.pf(b)&&(d=c.of(b));}d==null&&(d=mQb(Y2b(a),b));return d} + function Ze(a,b){var c,d,e;if(ZD(b,44)){c=RD(b,44);d=c.ld();e=Xv(a.Rc(),d);return Hb(e,c.md())&&(e!=null||a.Rc()._b(d))}return false} + function $Nd(a,b){var c,d,e;if(a.f>0){a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=WNd(a,e,d,b);if(c){return c.md()}}return null} + function qLd(a,b,c){var d,e,f;if(a.Pj()){d=a.i;f=a.Qj();KHd(a,d,b);e=a.Ij(3,null,b,d,f);!c?(c=e):c.nj(e);}else {KHd(a,a.i,b);}return c} + function f$d(a,b,c){var d,e;d=new P3d(a.e,4,10,(e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)),null,fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function e$d(a,b,c){var d,e;d=new P3d(a.e,3,10,null,(e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)),fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function SMb(a){RMb();var b;b=new sjd(RD(a.e.of((umd(),nld)),8));if(a.B.Hc((dqd(),Ypd))){b.a<=0&&(b.a=20);b.b<=0&&(b.b=20);}return b} + function jjb(a){Pib();var b,c;c=Ydb(a);b=Ydb(Udb(a,32));if(b!=0){return new bjb(c,b)}if(c>10||c<0){return new ajb(1,c)}return Lib[c]} + function Mdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a%b;if(jxe=0){f=f.a[1];}else {e=f;f=f.a[0];}}return e} + function Qyb(a,b,c){var d,e,f;e=null;f=a.b;while(f){d=a.a.Ne(b,f.d);if(c&&d==0){return f}if(d<=0){f=f.a[0];}else {e=f;f=f.a[1];}}return e} + function rmc(a,b,c,d){var e,f,g;e=false;if(Lmc(a.f,c,d)){Omc(a.f,a.a[b][c],a.a[b][d]);f=a.a[b];g=f[d];f[d]=f[c];f[c]=g;e=true;}return e} + function Nqc(a,b,c){var d,e,f,g;e=RD(Wjb(a.b,c),183);d=0;for(g=new Anb(b.j);g.a>5;b&=31;e=a.d+c+(b==0?0:1);d=$C(kE,Pwe,28,e,15,1);rjb(d,a.a,c,b);f=new cjb(a.e,e,d);Rib(f);return f} + function zGc(a,b){var c,d,e;for(d=new is(Mr(a3b(a).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);e=c.d.i;if(e.c==b){return false}}return true} + function _Ec(a,b,c){var d,e,f,g,h;g=a.k;h=b.k;d=c[g.g][h.g];e=UD(hFc(a,d));f=UD(hFc(b,d));return $wnd.Math.max((uFb(e),e),(uFb(f),f))} + function lA(){if(Error.stackTraceLimit>0){$wnd.Error.stackTraceLimit=Error.stackTraceLimit=64;return true}return 'stack' in new Error} + function sGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))>0} + function uGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))<0} + function tGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))<=0} + function Efb(a,b){var c=0;while(!b[c]||b[c]==''){c++;}var d=b[c++];for(;c0&&this.b>0&&(this.g=Aad(this.c,this.b,this.a));} + function rC(f,a){var b=f.a;var c;a=String(a);b.hasOwnProperty(a)&&(c=b[a]);var d=(HC(),GC)[typeof c];var e=d?d(c):NC(typeof c);return e} + function uDd(a){var b,c,d;d=null;b=uIe in a.a;c=!b;if(c){throw Adb(new CDd('Every element must have an id.'))}d=tDd(qC(a,uIe));return d} + function Qqe(a){var b,c;c=Rqe(a);b=null;while(a.c==2){Mqe(a);if(!b){b=(Vse(),Vse(),new iue(2));hue(b,c);c=b;}c.Jm(Rqe(a));}return c} + function jOd(a,b){var c,d,e;a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=WNd(a,e,d,b);if(c){hOd(a,c);return c.md()}else {return null}} + function Qib(a,b){if(a.e>b.e){return 1}if(a.eb.d){return a.e}if(a.d=48&&a<48+$wnd.Math.min(10,10)){return a-48}if(a>=97&&a<97){return a-97+10}if(a>=65&&a<65){return a-65+10}return -1} + function UHc(a,b){if(b.c==a){return b.d}else if(b.d==a){return b.c}throw Adb(new agb('Input edge is not connected to the input port.'))} + function Fae(a){if(mhb(FGe,a)){return Geb(),Feb}else if(mhb(GGe,a)){return Geb(),Eeb}else {throw Adb(new agb('Expecting true or false'))}} + function jFb(a){switch(typeof(a)){case jve:return ohb(a);case ive:return Nfb(a);case hve:return Jeb(a);default:return a==null?0:kFb(a);}} + function mfd(a,b){if(a.a<0){throw Adb(new dgb('Did not call before(...) or after(...) before calling add(...).'))}tfd(a,a.a,b);return a} + function FId(a){EId();if(ZD(a,162)){return RD(Wjb(CId,zK),295).Rg(a)}if(Ujb(CId,rb(a))){return RD(Wjb(CId,rb(a)),295).Rg(a)}return null} + function Wwd(a){var b,c;if((a.Db&32)==0){c=(b=RD(Ywd(a,16),29),AYd(!b?a.ii():b)-AYd(a.ii()));c!=0&&$wd(a,32,$C(jJ,rve,1,c,5,1));}return a} + function $wd(a,b,c){var d;if((a.Db&b)!=0){if(c==null){Zwd(a,b);}else {d=Xwd(a,b);d==-1?(a.Eb=c):bD(SD(a.Eb),d,c);}}else c!=null&&Twd(a,b,c);} + function tTc(a,b,c,d){var e,f;if(b.c.length==0){return}e=pTc(c,d);f=oTc(b);FDb(PDb(new SDb(null,new Swb(f,1)),new CTc),new GTc(a,c,e,d));} + function rmb(a,b){var c,d,e,f;d=a.a.length-1;c=b-a.b&d;f=a.c-b&d;e=a.c-a.b&d;zmb(c=f){umb(a,b);return -1}else {vmb(a,b);return 1}} + function Hvd(a){var b,c,d;d=a.Jh();if(!d){b=0;for(c=a.Ph();c;c=c.Ph()){if(++b>wxe){return c.Qh()}d=c.Jh();if(!!d||c==a){break}}}return d} + function Ue(a,b){var c;if(dE(b)===dE(a)){return true}if(!ZD(b,21)){return false}c=RD(b,21);if(c.gc()!=a.gc()){return false}return a.Ic(c)} + function kNc(a,b){if(a.eb.e){return 1}else if(a.fb.f){return 1}return tb(a)-tb(b)} + function mhb(a,b){uFb(a);if(b==null){return false}if(lhb(a,b)){return true}return a.length==b.length&&lhb(a.toLowerCase(),b.toLowerCase())} + function Hgb(a){var b,c;if(Ddb(a,-129)>0&&Ddb(a,128)<0){return Jgb(),b=Ydb(a)+128,c=Igb[b],!c&&(c=Igb[b]=new zgb(a)),c}return new zgb(a)} + function U$b(){U$b=geb;T$b=new V$b(LAe,0);R$b=new V$b('INSIDE_PORT_SIDE_GROUPS',1);Q$b=new V$b('GROUP_MODEL_ORDER',2);S$b=new V$b(MAe,3);} + function ufe(a){var b;a.b||vfe(a,(b=Hee(a.e,a.a),!b||!lhb(GGe,$Nd((!b.b&&(b.b=new SVd((JTd(),FTd),C8,b)),b.b),'qualified'))));return a.c} + function BA(a,b){var c,d;c=(BFb(b,a.length),a.charCodeAt(b));d=b+1;while(d2000){Oz=a;Pz=$wnd.setTimeout(Yz,10);}}if(Nz++==0){_z(($z(),Zz));return true}return false} + function lBb(a,b,c){var d;(bBb?(jBb(a),true):cBb?(SAb(),true):fBb?(SAb(),true):eBb&&(SAb(),false))&&(d=new aBb(b),d.b=c,hBb(a,d),undefined);} + function oNb(a,b){var c;c=!a.A.Hc((Qpd(),Ppd))||a.q==(Bod(),wod);a.u.Hc((Pod(),Lod))?c?mNb(a,b):qNb(a,b):a.u.Hc(Nod)&&(c?nNb(a,b):rNb(a,b));} + function Bed(a){var b;if(dE(Gxd(a,(umd(),Xkd)))===dE((Fnd(),Dnd))){if(!vCd(a)){Ixd(a,Xkd,End);}else {b=RD(Gxd(vCd(a),Xkd),346);Ixd(a,Xkd,b);}}} + function _fc(a){var b,c;if(nQb(a.d.i,(yCc(),tBc))){b=RD(mQb(a.c.i,tBc),17);c=RD(mQb(a.d.i,tBc),17);return hgb(b.a,c.a)>0}else {return false}} + function g_b(a,b,c){return new Uid($wnd.Math.min(a.a,b.a)-c/2,$wnd.Math.min(a.b,b.b)-c/2,$wnd.Math.abs(a.a-b.a)+c,$wnd.Math.abs(a.b-b.b)+c)} + function _mc(a){var b;this.d=new bnb;this.j=new pjd;this.g=new pjd;b=a.g.b;this.f=RD(mQb(Y2b(b),(yCc(),rAc)),88);this.e=Kfb(UD(k2b(b,ZBc)));} + function onc(a){this.d=new bnb;this.e=new gub;this.c=$C(kE,Pwe,28,(qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,15,1);this.b=a;} + function $pc(a,b,c){var d;d=c[a.g][b];switch(a.g){case 1:case 3:return new rjd(0,d);case 2:case 4:return new rjd(d,0);default:return null;}} + function Ced(b,c,d){var e,f;f=RD(ltd(c.f),205);try{f.rf(b,d);mtd(c.f,f);}catch(a){a=zdb(a);if(ZD(a,103)){e=a;throw Adb(e)}else throw Adb(a)}} + function tEd(a,b,c){var d,e,f,g,h,i;d=null;h=vgd(ygd(),b);f=null;if(h){e=null;i=zhd(h,c);g=null;i!=null&&(g=a.qf(h,i));e=g;f=e;}d=f;return d} + function sSd(a,b,c,d){var e;e=a.length;if(b>=e)return e;for(b=b>0?b:0;bd&&bD(b,d,null);return b} + function lob(a,b){var c,d;d=a.a.length;b.lengthd&&bD(b,d,null);return b} + function Bde(a,b){var c,d;++a.j;if(b!=null){c=(d=a.a.Cb,ZD(d,99)?RD(d,99).th():null);if(Jnb(b,c)){$wd(a.a,4,c);return}}$wd(a.a,4,RD(b,129));} + function mne(a){var b;if(a==null)return null;b=Hqe(nue(a,true));if(b==null){throw Adb(new Mle("Invalid hexBinary value: '"+a+"'"))}return b} + function wA(a,b,c){var d;if(b.a.length>0){Rmb(a.b,new kB(b.a,c));d=b.a.length;0d&&(b.a+=Hhb($C(hE,zwe,28,-d,15,1)));}} + function yIb(a,b,c){var d,e,f;if(c[b.d]){return}c[b.d]=true;for(e=new Anb(CIb(b));e.a=a.b>>1){d=a.c;for(c=a.b;c>b;--c){d=d.b;}}else {d=a.a.a;for(c=0;c=0?a.Wh(e):Rvd(a,d)):c<0?Rvd(a,d):RD(d,69).wk().Bk(a,a.hi(),c)} + function Fxd(a){var b,c,d;d=(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),a.o);for(c=d.c.Kc();c.e!=c.i.gc();){b=RD(c.Yj(),44);b.md();}return dOd(d)} + function iGd(a){var b;if(ZD(a.a,4)){b=FId(a.a);if(b==null){throw Adb(new dgb(HGe+a.b+"'. "+DGe+(lfb(b6),b6.k)+EGe))}return b}else {return a.a}} + function iSd(a,b){var c,d;if(a.j.length!=b.j.length)return false;for(c=0,d=a.j.length;c=64&&b<128&&(e=Rdb(e,Sdb(1,b-64)));}return e} + function k2b(a,b){var c,d;d=null;if(nQb(a,(umd(),amd))){c=RD(mQb(a,amd),96);c.pf(b)&&(d=c.of(b));}d==null&&!!Y2b(a)&&(d=mQb(Y2b(a),b));return d} + function i0b(a,b){var c;c=RD(mQb(a,(yCc(),RAc)),75);if(br(b,f0b)){if(!c){c=new Ejd;pQb(a,RAc,c);}else {Xub(c);}}else !!c&&pQb(a,RAc,null);return c} + function tSb(){tSb=geb;sSb=(umd(),Yld);mSb=Ukd;hSb=Dkd;nSb=tld;qSb=(YHb(),UHb);pSb=SHb;rSb=WHb;oSb=RHb;jSb=(eSb(),aSb);iSb=_Rb;kSb=cSb;lSb=dSb;} + function PZb(a){NZb();this.c=new bnb;this.d=a;switch(a.g){case 0:case 2:this.a=Fob(MZb);this.b=oxe;break;case 3:case 1:this.a=MZb;this.b=pxe;}} + function c9b(a){var b;if(!Cod(RD(mQb(a,(yCc(),BBc)),101))){return}b=a.b;d9b((tFb(0,b.c.length),RD(b.c[0],30)));d9b(RD(Vmb(b,b.c.length-1),30));} + function ohc(a,b){b.Ug('Self-Loop post-processing',1);FDb(CDb(CDb(EDb(new SDb(null,new Swb(a.b,16)),new uhc),new whc),new yhc),new Ahc);b.Vg();} + function xrd(a,b,c){var d,e;if(a.c){Dyd(a.c,a.c.i+b);Eyd(a.c,a.c.j+c);}else {for(e=new Anb(a.b);e.a=0&&(c.d=a.t);break;case 3:a.t>=0&&(c.a=a.t);}if(a.C){c.b=a.C.b;c.c=a.C.c;}} + function JDc(){JDc=geb;IDc=new LDc(mEe,0);FDc=new LDc(BBe,1);GDc=new LDc('LINEAR_SEGMENTS',2);EDc=new LDc('BRANDES_KOEPF',3);HDc=new LDc(lEe,4);} + function IRb(){IRb=geb;FRb=new JRb(_ye,0);ERb=new JRb(aze,1);GRb=new JRb(bze,2);HRb=new JRb(cze,3);FRb.a=false;ERb.a=true;GRb.a=false;HRb.a=true;} + function IPb(){IPb=geb;FPb=new JPb(_ye,0);EPb=new JPb(aze,1);GPb=new JPb(bze,2);HPb=new JPb(cze,3);FPb.a=false;EPb.a=true;GPb.a=false;HPb.a=true;} + function Ivd(a,b,c,d){var e;if(c>=0){return a.Sh(b,c,d)}else {!!a.Ph()&&(d=(e=a.Fh(),e>=0?a.Ah(d):a.Ph().Th(a,-1-e,null,d)));return a.Ch(b,c,d)}} + function Zyd(a,b){switch(b){case 7:!a.e&&(a.e=new Yie(G4,a,7,4));sLd(a.e);return;case 8:!a.d&&(a.d=new Yie(G4,a,8,5));sLd(a.d);return;}yyd(a,b);} + function Ixd(a,b,c){c==null?(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),jOd(a.o,b)):(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),fOd(a.o,b,c));return a} + function Aob(a,b){yob();var c,d,e,f;c=a;f=b;if(ZD(a,21)&&!ZD(b,21)){c=b;f=a;}for(e=c.Kc();e.Ob();){d=e.Pb();if(f.Hc(d)){return false}}return true} + function qTc(a,b,c,d){if(b.ac.b){return true}}}return false} + function QD(a,b){if(bE(a)){return !!PD[b]}else if(a.Sm){return !!a.Sm[b]}else if(_D(a)){return !!OD[b]}else if($D(a)){return !!ND[b]}return false} + function udc(a){var b;b=a.a;do{b=RD(hs(new is(Mr(Z2b(b).a.Kc(),new ir))),18).c.i;b.k==(r3b(),o3b)&&a.b.Fc(b);}while(b.k==(r3b(),o3b));a.b=hv(a.b);} + function UGc(a,b){var c,d,e;e=a;for(d=new is(Mr(Z2b(b).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);!!c.c.i.c&&(e=$wnd.Math.max(e,c.c.i.c.p));}return e} + function INb(a,b){var c,d,e;e=0;d=RD(RD(Qc(a.r,b),21),87).Kc();while(d.Ob()){c=RD(d.Pb(),117);e+=c.d.d+c.b.Mf().b+c.d.a;d.Ob()&&(e+=a.w);}return e} + function AMb(a,b){var c,d,e;e=0;d=RD(RD(Qc(a.r,b),21),87).Kc();while(d.Ob()){c=RD(d.Pb(),117);e+=c.d.b+c.b.Mf().a+c.d.c;d.Ob()&&(e+=a.w);}return e} + function O2c(a){var b,c,d,e;d=0;e=Q2c(a);if(e.c.length==0){return 1}else {for(c=new Anb(e);c.a=0?a.Lh(g,c,true):Qvd(a,f,c)):RD(f,69).wk().yk(a,a.hi(),e,c,d)} + function aNb(a,b,c,d){var e,f;f=b.pf((umd(),ild))?RD(b.of(ild),21):a.j;e=lMb(f);if(e==(hMb(),gMb)){return}if(c&&!jMb(e)){return}LKb(cNb(a,e,d),b);} + function Y6b(a){switch(a.g){case 1:return mOb(),lOb;case 3:return mOb(),iOb;case 2:return mOb(),kOb;case 4:return mOb(),jOb;default:return null;}} + function kmc(a,b,c){if(a.e){switch(a.b){case 1:Ulc(a.c,b,c);break;case 0:Vlc(a.c,b,c);}}else {Slc(a.c,b,c);}a.a[b.p][c.p]=a.c.i;a.a[c.p][b.p]=a.c.e;} + function LLc(a){var b,c;if(a==null){return null}c=$C(jR,Nve,199,a.length,0,2);for(b=0;b=0)return e;if(a.ol()){for(d=0;d=e)throw Adb(new aMd(b,e));if(a.Si()){d=a.dd(c);if(d>=0&&d!=b){throw Adb(new agb(LIe))}}return a.Xi(b,c)} + function wx(a,b){this.a=RD(Qb(a),253);this.b=RD(Qb(b),253);if(a.Ed(b)>0||a==(Wk(),Vk)||b==(kl(),jl)){throw Adb(new agb('Invalid range: '+Dx(a,b)))}} + function p_b(a){var b,c;this.b=new bnb;this.c=a;this.a=false;for(c=new Anb(a.a);c.a0);if((b&-b)==b){return eE(b*Kwb(a,31)*4.6566128730773926E-10)}do{c=Kwb(a,31);d=c%b;}while(c-d+(b-1)<0);return eE(d)} + function d2b(a,b,c){switch(c.g){case 1:a.a=b.a/2;a.b=0;break;case 2:a.a=b.a;a.b=b.b/2;break;case 3:a.a=b.a/2;a.b=b.b;break;case 4:a.a=0;a.b=b.b/2;}} + function Onc(a,b,c,d){var e,f;for(e=b;e1&&(f=xIb(a,b));return f} + function yqd(a){var b;b=Kfb(UD(Gxd(a,(umd(),lmd))))*$wnd.Math.sqrt((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a).i);return new rjd(b,b/Kfb(UD(Gxd(a,kmd))))} + function Dzd(a){var b;if(!!a.f&&a.f.Vh()){b=RD(a.f,54);a.f=RD(Vvd(a,b),84);a.f!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,8,b,a.f));}return a.f} + function Ezd(a){var b;if(!!a.i&&a.i.Vh()){b=RD(a.i,54);a.i=RD(Vvd(a,b),84);a.i!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,7,b,a.i));}return a.i} + function Z5d(a){var b;if(!!a.b&&(a.b.Db&64)!=0){b=a.b;a.b=RD(Vvd(a,b),19);a.b!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,21,b,a.b));}return a.b} + function UNd(a,b){var c,d,e;if(a.d==null){++a.e;++a.f;}else {d=b.Bi();_Nd(a,a.f+1);e=(d&lve)%a.d.length;c=a.d[e];!c&&(c=a.d[e]=a.dk());c.Fc(b);++a.f;}} + function Mge(a,b,c){var d;if(b.tk()){return false}else if(b.Ik()!=-2){d=b.ik();return d==null?c==null:pb(d,c)}else return b.qk()==a.e.Dh()&&c==null} + function Io(){var a;dk(16,fwe);a=Wp(16);this.b=$C(XF,ewe,303,a,0,1);this.c=$C(XF,ewe,303,a,0,1);this.a=null;this.e=null;this.i=0;this.f=a-1;this.g=0;} + function j3b(a){v2b.call(this);this.k=(r3b(),p3b);this.j=(dk(6,iwe),new cnb(6));this.b=(dk(2,iwe),new cnb(2));this.d=new T2b;this.f=new C3b;this.a=a;} + function wgc(a){var b,c;if(a.c.length<=1){return}b=tgc(a,(qpd(),npd));vgc(a,RD(b.a,17).a,RD(b.b,17).a);c=tgc(a,ppd);vgc(a,RD(c.a,17).a,RD(c.b,17).a);} + function vHc(a,b,c){var d,e;e=a.a.b;for(d=e.c.length;d102)return -1;if(a<=57)return a-48;if(a<65)return -1;if(a<=70)return a-65+10;if(a<97)return -1;return a-97+10} + function ck(a,b){if(a==null){throw Adb(new Ogb('null key in entry: null='+b))}else if(b==null){throw Adb(new Ogb('null value in entry: '+a+'=null'))}} + function Cr(a,b){var c,d;while(a.Ob()){if(!b.Ob()){return false}c=a.Pb();d=b.Pb();if(!(dE(c)===dE(d)||c!=null&&pb(c,d))){return false}}return !b.Ob()} + function aLb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[gKb(a.a[0],b),gKb(a.a[1],b),gKb(a.a[2],b)]);if(a.d){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function bLb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[hKb(a.a[0],b),hKb(a.a[1],b),hKb(a.a[2],b)]);if(a.d){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function vIc(a,b,c){if(!Cod(RD(mQb(b,(yCc(),BBc)),101))){uIc(a,b,e3b(b,c));uIc(a,b,e3b(b,(qpd(),npd)));uIc(a,b,e3b(b,Yod));yob();_mb(b.j,new JIc(a));}} + function sUc(a){var b,c;a.c||vUc(a);c=new Ejd;b=new Anb(a.a);ynb(b);while(b.a0&&(BFb(0,b.length),b.charCodeAt(0)==43)?(BFb(1,b.length+1),b.substr(1)):b))} + function qne(a){var b;return a==null?null:new ejb((b=nue(a,true),b.length>0&&(BFb(0,b.length),b.charCodeAt(0)==43)?(BFb(1,b.length+1),b.substr(1)):b))} + function Syb(a,b,c,d,e,f,g,h){var i,j;if(!d){return}i=d.a[0];!!i&&Syb(a,b,c,i,e,f,g,h);Tyb(a,c,d.d,e,f,g,h)&&b.Fc(d);j=d.a[1];!!j&&Syb(a,b,c,j,e,f,g,h);} + function PPb(b,c,d){try{return Gdb(SPb(b,c,d),1)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function QPb(b,c,d){try{return Gdb(SPb(b,c,d),0)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function RPb(b,c,d){try{return Gdb(SPb(b,c,d),2)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function lMd(b,c){if(b.g==-1){throw Adb(new cgb)}b.Xj();try{b.d.hd(b.g,c);b.f=b.d.j;}catch(a){a=zdb(a);if(ZD(a,77)){throw Adb(new Jrb)}else throw Adb(a)}} + function Y7b(a){var b,c,d,e,f;for(d=new Anb(a.b);d.af&&bD(b,f,null);return b} + function av(a,b){var c,d;d=a.gc();if(b==null){for(c=0;c0&&(i+=e);j[k]=g;g+=h*(i+d);}} + function vsc(a){var b,c,d;d=a.f;a.n=$C(iE,vxe,28,d,15,1);a.d=$C(iE,vxe,28,d,15,1);for(b=0;b0?a.c:0);++e;}a.b=d;a.d=f;} + function rKb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[qKb(a,(ZJb(),WJb),b),qKb(a,XJb,b),qKb(a,YJb,b)]);if(a.f){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function cQb(b,c,d){var e;try{TPb(b,c+b.j,d+b.k,false,true);}catch(a){a=zdb(a);if(ZD(a,77)){e=a;throw Adb(new veb(e.g+ize+c+pve+d+').'))}else throw Adb(a)}} + function dQb(b,c,d){var e;try{TPb(b,c+b.j,d+b.k,true,false);}catch(a){a=zdb(a);if(ZD(a,77)){e=a;throw Adb(new veb(e.g+ize+c+pve+d+').'))}else throw Adb(a)}} + function u8b(a){var b;if(!nQb(a,(yCc(),dBc))){return}b=RD(mQb(a,dBc),21);if(b.Hc((dod(),Xnd))){b.Mc(Xnd);b.Fc(Znd);}else if(b.Hc(Znd)){b.Mc(Znd);b.Fc(Xnd);}} + function v8b(a){var b;if(!nQb(a,(yCc(),dBc))){return}b=RD(mQb(a,dBc),21);if(b.Hc((dod(),cod))){b.Mc(cod);b.Fc(aod);}else if(b.Hc(aod)){b.Mc(aod);b.Fc(cod);}} + function oqc(a,b,c,d){var e,f,g,h;a.a==null&&rqc(a,b);g=b.b.j.c.length;f=c.d.p;h=d.d.p;e=h-1;e<0&&(e=g-1);return f<=e?a.a[e]-a.a[f]:a.a[g-1]-a.a[f]+a.a[e]} + function Cud(a){var b,c;if(!a.b){a.b=fv(RD(a.f,27).kh().i);for(c=new dMd(RD(a.f,27).kh());c.e!=c.i.gc();){b=RD(bMd(c),135);Rmb(a.b,new Bud(b));}}return a.b} + function Dud(a){var b,c;if(!a.e){a.e=fv(wCd(RD(a.f,27)).i);for(c=new dMd(wCd(RD(a.f,27)));c.e!=c.i.gc();){b=RD(bMd(c),123);Rmb(a.e,new Rud(b));}}return a.e} + function yud(a){var b,c;if(!a.a){a.a=fv(tCd(RD(a.f,27)).i);for(c=new dMd(tCd(RD(a.f,27)));c.e!=c.i.gc();){b=RD(bMd(c),27);Rmb(a.a,new Fud(a,b));}}return a.a} + function DXd(b){var c;if(!b.C&&(b.D!=null||b.B!=null)){c=EXd(b);if(c){b.hl(c);}else {try{b.hl(null);}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}}return b.C} + function xMb(a){switch(a.q.g){case 5:uMb(a,(qpd(),Yod));uMb(a,npd);break;case 4:vMb(a,(qpd(),Yod));vMb(a,npd);break;default:wMb(a,(qpd(),Yod));wMb(a,npd);}} + function GNb(a){switch(a.q.g){case 5:DNb(a,(qpd(),Xod));DNb(a,ppd);break;case 4:ENb(a,(qpd(),Xod));ENb(a,ppd);break;default:FNb(a,(qpd(),Xod));FNb(a,ppd);}} + function G$b(a,b){var c,d,e;e=new pjd;for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);w$b(c,e.a,0);e.a+=c.f.a+b;e.b=$wnd.Math.max(e.b,c.f.b);}e.b>0&&(e.b+=b);return e} + function I$b(a,b){var c,d,e;e=new pjd;for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);w$b(c,0,e.b);e.b+=c.f.b+b;e.a=$wnd.Math.max(e.a,c.f.a);}e.a>0&&(e.a+=b);return e} + function l2b(a){var b,c,d;d=lve;for(c=new Anb(a.a);c.a>16==6){return a.Cb.Th(a,5,t7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?a.ii():c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function kA(a){fA();var b=a.e;if(b&&b.stack){var c=b.stack;var d=b+'\n';c.substring(0,d.length)==d&&(c=c.substring(d.length));return c.split('\n')}return []} + function pgb(a){var b;b=(wgb(),vgb);return b[a>>>28]|b[a>>24&15]<<4|b[a>>20&15]<<8|b[a>>16&15]<<12|b[a>>12&15]<<16|b[a>>8&15]<<20|b[a>>4&15]<<24|b[a&15]<<28} + function mmb(a){var b,c,d;if(a.b!=a.c){return}d=a.a.length;c=mgb($wnd.Math.max(8,d))<<1;if(a.b!=0){b=WEb(a.a,c);lmb(a,b,d);a.a=b;a.b=0;}else {aFb(a.a,c);}a.c=d;} + function uNb(a,b){var c;c=a.b;return c.pf((umd(),Gld))?c.ag()==(qpd(),ppd)?-c.Mf().a-Kfb(UD(c.of(Gld))):b+Kfb(UD(c.of(Gld))):c.ag()==(qpd(),ppd)?-c.Mf().a:b} + function X2b(a){var b;if(a.b.c.length!=0&&!!RD(Vmb(a.b,0),72).a){return RD(Vmb(a.b,0),72).a}b=R0b(a);if(b!=null){return b}return ''+(!a.c?-1:Wmb(a.c.a,a,0))} + function M3b(a){var b;if(a.f.c.length!=0&&!!RD(Vmb(a.f,0),72).a){return RD(Vmb(a.f,0),72).a}b=R0b(a);if(b!=null){return b}return ''+(!a.i?-1:Wmb(a.i.j,a,0))} + function skc(a,b){var c,d;if(b<0||b>=a.gc()){return null}for(c=b;c0?a.c:0);e=$wnd.Math.max(e,b.d);++d;}a.e=f;a.b=e;} + function Qud(a){var b,c;if(!a.b){a.b=fv(RD(a.f,123).kh().i);for(c=new dMd(RD(a.f,123).kh());c.e!=c.i.gc();){b=RD(bMd(c),135);Rmb(a.b,new Bud(b));}}return a.b} + function aHd(a,b){var c,d,e;if(b.dc()){return jQd(),jQd(),iQd}else {c=new ZLd(a,b.gc());for(e=new dMd(a);e.e!=e.i.gc();){d=bMd(e);b.Hc(d)&&WGd(c,d);}return c}} + function Axd(a,b,c,d){if(b==0){return d?(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),a.o):(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),dOd(a.o))}return Dvd(a,b,c,d)} + function rBd(a){var b,c;if(a.rb){for(b=0,c=a.rb.i;b>22);e+=d>>22;if(e<0){return false}a.l=c&dxe;a.m=d&dxe;a.h=e&exe;return true} + function Tyb(a,b,c,d,e,f,g){var h,i;if(b.Te()&&(i=a.a.Ne(c,d),i<0||!e&&i==0)){return false}if(b.Ue()&&(h=a.a.Ne(c,f),h>0||!g&&h==0)){return false}return true} + function Agc(a,b){sgc();var c;c=a.j.g-b.j.g;if(c!=0){return 0}switch(a.j.g){case 2:return Cgc(b,rgc)-Cgc(a,rgc);case 4:return Cgc(a,qgc)-Cgc(b,qgc);}return 0} + function uuc(a){switch(a.g){case 0:return nuc;case 1:return ouc;case 2:return puc;case 3:return quc;case 4:return ruc;case 5:return suc;default:return null;}} + function cBd(a,b,c){var d,e;d=(e=new R5d,YVd(e,b),PAd(e,c),WGd((!a.c&&(a.c=new C5d(u7,a,12,10)),a.c),e),e);$Vd(d,0);bWd(d,1);aWd(d,true);_Vd(d,true);return d} + function THd(a,b){var c,d;if(b>=a.i)throw Adb(new yNd(b,a.i));++a.j;c=a.g[b];d=a.i-b-1;d>0&&hib(a.g,b+1,a.g,b,d);bD(a.g,--a.i,null);a.Qi(b,c);a.Ni();return c} + function sWd(a,b){var c,d;if(a.Db>>16==17){return a.Cb.Th(a,21,h7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?a.ii():c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function _Fb(a){var b,c,d,e;yob();_mb(a.c,a.a);for(e=new Anb(a.c);e.ac.a.c.length)){throw Adb(new agb('index must be >= 0 and <= layer node count'))}!!a.c&&Ymb(a.c.a,a);a.c=c;!!c&&Qmb(c.a,b,a);} + function Gac(a,b){var c,d,e;for(d=new is(Mr(W2b(a).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);e=RD(b.Kb(c),10);return new cc(Qb(e.n.b+e.o.b/2))}return wb(),wb(),vb} + function RQc(a,b){this.c=new Tsb;this.a=a;this.b=b;this.d=RD(mQb(a,(Ywc(),Qwc)),312);dE(mQb(a,(yCc(),eBc)))===dE((Cuc(),Auc))?(this.e=new BRc):(this.e=new uRc);} + function ftd(a,b){var c,d;d=null;if(a.pf((umd(),amd))){c=RD(a.of(amd),96);c.pf(b)&&(d=c.of(b));}d==null&&!!a.Tf()&&(d=a.Tf().of(b));d==null&&(d=iGd(b));return d} + function ku(b,c){var d,e;d=b.fd(c);try{e=d.Pb();d.Qb();return e}catch(a){a=zdb(a);if(ZD(a,112)){throw Adb(new veb("Can't remove element "+c))}else throw Adb(a)}} + function GA(a,b){var c,d,e;d=new uB;e=new vB(d.q.getFullYear()-Owe,d.q.getMonth(),d.q.getDate());c=FA(a,b,e);if(c==0||c0?b:0);++c;}return new rjd(d,e)} + function Czd(a,b){var c,d;if(a.Db>>16==6){return a.Cb.Th(a,6,G4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),hvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function cCd(a,b){var c,d;if(a.Db>>16==7){return a.Cb.Th(a,1,H4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),jvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function LCd(a,b){var c,d;if(a.Db>>16==9){return a.Cb.Th(a,9,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),lvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function M1d(a,b){var c,d;if(a.Db>>16==5){return a.Cb.Th(a,9,m7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),tTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function qBd(a,b){var c,d;if(a.Db>>16==7){return a.Cb.Th(a,6,t7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),CTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function iVd(a,b){var c,d;if(a.Db>>16==3){return a.Cb.Th(a,0,p7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),mTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function IEd(){this.a=new BDd;this.g=new Io;this.j=new Io;this.b=new Tsb;this.d=new Io;this.i=new Io;this.k=new Tsb;this.c=new Tsb;this.e=new Tsb;this.f=new Tsb;} + function kQd(a,b,c){var d,e,f;c<0&&(c=0);f=a.i;for(e=c;ewxe){return Oje(a,d)}if(d==a){return true}}}return false} + function yNb(a){tNb();switch(a.q.g){case 5:vNb(a,(qpd(),Yod));vNb(a,npd);break;case 4:wNb(a,(qpd(),Yod));wNb(a,npd);break;default:xNb(a,(qpd(),Yod));xNb(a,npd);}} + function CNb(a){tNb();switch(a.q.g){case 5:zNb(a,(qpd(),Xod));zNb(a,ppd);break;case 4:ANb(a,(qpd(),Xod));ANb(a,ppd);break;default:BNb(a,(qpd(),Xod));BNb(a,ppd);}} + function RTb(a){var b,c;b=RD(mQb(a,(yVb(),mVb)),17);if(b){c=b.a;c==0?pQb(a,(JVb(),IVb),new Owb):pQb(a,(JVb(),IVb),new Pwb(c));}else {pQb(a,(JVb(),IVb),new Pwb(1));}} + function b2b(a,b){var c;c=a.i;switch(b.g){case 1:return -(a.n.b+a.o.b);case 2:return a.n.a-c.o.a;case 3:return a.n.b-c.o.b;case 4:return -(a.n.a+a.o.a);}return 0} + function wec(a,b){switch(a.g){case 0:return b==(cxc(),$wc)?sec:tec;case 1:return b==(cxc(),$wc)?sec:rec;case 2:return b==(cxc(),$wc)?rec:tec;default:return rec;}} + function Fad(a,b){var c,d,e;Ymb(a.a,b);a.e-=b.r+(a.a.c.length==0?0:a.c);e=fFe;for(d=new Anb(a.a);d.a>16==3){return a.Cb.Th(a,12,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),gvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function sCd(a,b){var c,d;if(a.Db>>16==11){return a.Cb.Th(a,10,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),kvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function n4d(a,b){var c,d;if(a.Db>>16==10){return a.Cb.Th(a,11,h7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),ATd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function Q5d(a,b){var c,d;if(a.Db>>16==10){return a.Cb.Th(a,12,s7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),DTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function WVd(a){var b;if((a.Bb&1)==0&&!!a.r&&a.r.Vh()){b=RD(a.r,54);a.r=RD(Vvd(a,b),142);a.r!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,8,b,a.r));}return a.r} + function pKb(a,b,c){var d;d=cD(WC(iE,1),vxe,28,15,[sKb(a,(ZJb(),WJb),b,c),sKb(a,XJb,b,c),sKb(a,YJb,b,c)]);if(a.f){d[0]=$wnd.Math.max(d[0],d[2]);d[2]=d[0];}return d} + function ddc(a,b){var c,d,e;e=kdc(a,b);if(e.c.length==0){return}_mb(e,new Gdc);c=e.c.length;for(d=0;d>19;j=b.h>>19;if(i!=j){return j-i}e=a.h;h=b.h;if(e!=h){return e-h}d=a.m;g=b.m;if(d!=g){return d-g}c=a.l;f=b.l;return c-f} + function YHb(){YHb=geb;XHb=(iIb(),fIb);WHb=new lGd(Aye,XHb);VHb=(LHb(),KHb);UHb=new lGd(Bye,VHb);THb=(DHb(),CHb);SHb=new lGd(Cye,THb);RHb=new lGd(Dye,(Geb(),true));} + function Iic(a,b,c){var d,e;d=b*c;if(ZD(a.g,154)){e=$jc(a);if(e.f.d){e.f.a||(a.d.a+=d+Tye);}else {a.d.d-=d+Tye;a.d.a+=d+Tye;}}else if(ZD(a.g,10)){a.d.d-=d;a.d.a+=2*d;}} + function _pc(a,b,c){var d,e,f,g,h;e=a[c.g];for(h=new Anb(b.d);h.a0?a.b:0);++c;}b.b=d;b.e=e;} + function Fo(a){var b,c,d;d=a.b;if(Xp(a.i,d.length)){c=d.length*2;a.b=$C(XF,ewe,303,c,0,1);a.c=$C(XF,ewe,303,c,0,1);a.f=c-1;a.i=0;for(b=a.a;b;b=b.c){Bo(a,b,b);}++a.g;}} + function VPb(a,b,c,d){var e,f,g,h;for(e=0;eg&&(h=g/d);e>f&&(i=f/e);ijd(a,$wnd.Math.min(h,i));return a} + function OAd(){qAd();var b,c;try{c=RD(M5d((YSd(),XSd),$He),2113);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new KAd} + function Qae(){qAd();var b,c;try{c=RD(M5d((YSd(),XSd),AKe),2040);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new Mae} + function vne(){Zme();var b,c;try{c=RD(M5d((YSd(),XSd),dLe),2122);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new rne} + function f2d(a,b,c){var d,e;e=a.e;a.e=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,4,e,b);!c?(c=d):c.nj(d);}e!=b&&(b?(c=o2d(a,k2d(a,b),c)):(c=o2d(a,a.a,c)));return c} + function DB(){uB.call(this);this.e=-1;this.a=false;this.p=qwe;this.k=-1;this.c=-1;this.b=-1;this.g=false;this.f=-1;this.j=-1;this.n=-1;this.i=-1;this.d=-1;this.o=qwe;} + function hHb(a,b){var c,d,e;d=a.b.d.d;a.a||(d+=a.b.d.a);e=b.b.d.d;b.a||(e+=b.b.d.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function XQb(a,b){var c,d,e;d=a.b.b.d;a.a||(d+=a.b.b.a);e=b.b.b.d;b.a||(e+=b.b.b.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function RYb(a,b){var c,d,e;d=a.b.g.d;a.a||(d+=a.b.g.a);e=b.b.g.d;b.a||(e+=b.b.g.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function _Wb(){_Wb=geb;YWb=nfd(pfd(pfd(pfd(new ufd,(sXb(),qXb),(hcc(),Dbc)),qXb,Hbc),rXb,Obc),rXb,rbc);$Wb=pfd(pfd(new ufd,qXb,hbc),qXb,sbc);ZWb=nfd(new ufd,rXb,ubc);} + function J6b(a){var b,c,d,e,f;b=RD(mQb(a,(Ywc(),cwc)),85);f=a.n;for(d=b.Cc().Kc();d.Ob();){c=RD(d.Pb(),314);e=c.i;e.c+=f.a;e.d+=f.b;c.c?MKb(c):OKb(c);}pQb(a,cwc,null);} + function Wpc(a,b,c){var d,e;e=a.b;d=e.d;switch(b.g){case 1:return -d.d-c;case 2:return e.o.a+d.c+c;case 3:return e.o.b+d.a+c;case 4:return -d.b-c;default:return -1;}} + function CNc(a,b,c){var d,e;c.Ug('Interactive node placement',1);a.a=RD(mQb(b,(Ywc(),Qwc)),312);for(e=new Anb(b.b);e.a0){g=(f&lve)%a.d.length;e=WNd(a,g,f,b);if(e){h=e.nd(c);return h}}d=a.ck(f,b,c);a.c.Fc(d);return null} + function Tee(a,b){var c,d,e,f;switch(Oee(a,b).Kl()){case 3:case 2:{c=mYd(b);for(e=0,f=c.i;e=0;d--){if(lhb(a[d].d,b)||lhb(a[d].d,c)){a.length>=d+1&&a.splice(0,d+1);break}}return a} + function Fdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a/b;if(jxe0){a.b+=2;a.a+=d;}}else {a.b+=1;a.a+=$wnd.Math.min(d,e);}} + function CVc(a){var b;b=RD(mQb(RD(ju(a.b,0),40),(h_c(),T$c)),107);pQb(a,(q$c(),SZc),new rjd(0,0));FVc(new YWc,a,b.b+b.c-Kfb(UD(mQb(a,ZZc))),b.d+b.a-Kfb(UD(mQb(a,_Zc))));} + function pDd(a,b){var c,d;d=false;if(bE(b)){d=true;oDd(a,new OC(WD(b)));}if(!d){if(ZD(b,242)){d=true;oDd(a,(c=Qeb(RD(b,242)),new hC(c)));}}if(!d){throw Adb(new Aeb(tIe))}} + function g$d(a,b,c,d){var e,f,g;e=new P3d(a.e,1,10,(g=b.c,ZD(g,90)?RD(g,29):(JTd(),zTd)),(f=c.c,ZD(f,90)?RD(f,29):(JTd(),zTd)),fZd(a,b),false);!d?(d=e):d.nj(e);return d} + function _2b(a){var b,c;switch(RD(mQb(Y2b(a),(yCc(),QAc)),429).g){case 0:b=a.n;c=a.o;return new rjd(b.a+c.a/2,b.b+c.b/2);case 1:return new sjd(a.n);default:return null;}} + function Ouc(){Ouc=geb;Luc=new Puc(LAe,0);Kuc=new Puc('LEFTUP',1);Nuc=new Puc('RIGHTUP',2);Juc=new Puc('LEFTDOWN',3);Muc=new Puc('RIGHTDOWN',4);Iuc=new Puc('BALANCED',5);} + function dKc(a,b,c){var d,e,f;d=Qfb(a.a[b.p],a.a[c.p]);if(d==0){e=RD(mQb(b,(Ywc(),qwc)),15);f=RD(mQb(c,qwc),15);if(e.Hc(c)){return -1}else if(f.Hc(b)){return 1}}return d} + function k5c(a){switch(a.g){case 1:return new K3c;case 2:return new M3c;case 3:return new I3c;case 0:return null;default:throw Adb(new agb(mFe+(a.f!=null?a.f:''+a.g)));}} + function gyd(a,b,c){switch(b){case 1:!a.n&&(a.n=new C5d(I4,a,1,7));sLd(a.n);!a.n&&(a.n=new C5d(I4,a,1,7));YGd(a.n,RD(c,16));return;case 2:jyd(a,WD(c));return;}Dxd(a,b,c);} + function xyd(a,b,c){switch(b){case 3:Ayd(a,Kfb(UD(c)));return;case 4:Cyd(a,Kfb(UD(c)));return;case 5:Dyd(a,Kfb(UD(c)));return;case 6:Eyd(a,Kfb(UD(c)));return;}gyd(a,b,c);} + function dBd(a,b,c){var d,e,f;f=(d=new R5d,d);e=XVd(f,b,null);!!e&&e.oj();PAd(f,c);WGd((!a.c&&(a.c=new C5d(u7,a,12,10)),a.c),f);$Vd(f,0);bWd(f,1);aWd(f,true);_Vd(f,true);} + function M5d(a,b){var c,d,e;c=Ktb(a.i,b);if(ZD(c,241)){e=RD(c,241);e.zi()==null&&undefined;return e.wi()}else if(ZD(c,507)){d=RD(c,2037);e=d.b;return e}else {return null}} + function aj(a,b,c,d){var e,f;Qb(b);Qb(c);f=RD(Fn(a.d,b),17);Ob(!!f,'Row %s not in %s',b,a.e);e=RD(Fn(a.b,c),17);Ob(!!e,'Column %s not in %s',c,a.c);return cj(a,f.a,e.a,d)} + function ZC(a,b,c,d,e,f,g){var h,i,j,k,l;k=e[f];j=f==g-1;h=j?d:0;l=_C(h,k);d!=10&&cD(WC(a,g-f),b[f],c[f],h,l);if(!j){++f;for(i=0;i1||h==-1){f=RD(i,15);e.Wb(Sje(a,f));}else {e.Wb(Rje(a,RD(i,58)));}}}} + function ceb(b,c,d,e){beb();var f=_db;function g(){for(var a=0;a0){return false}}return true} + function okc(a){var b,c,d,e,f;for(d=new vkb((new mkb(a.b)).a);d.b;){c=tkb(d);b=RD(c.ld(),10);f=RD(RD(c.md(),42).a,10);e=RD(RD(c.md(),42).b,8);$id(hjd(b.n),$id(ajd(f.n),e));}} + function Roc(a){switch(RD(mQb(a.b,(yCc(),BAc)),387).g){case 1:FDb(GDb(EDb(new SDb(null,new Swb(a.d,16)),new kpc),new mpc),new opc);break;case 2:Toc(a);break;case 0:Soc(a);}} + function SVc(a,b,c){var d,e,f;d=c;!d&&(d=new Oqd);d.Ug('Layout',a.a.c.length);for(f=new Anb(a.a);f.aAEe){return c}else e>-1.0E-6&&++c;}return c} + function n2d(a,b){var c;if(b!=a.b){c=null;!!a.b&&(c=Jvd(a.b,a,-4,c));!!b&&(c=Ivd(b,a,-4,c));c=e2d(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function q2d(a,b){var c;if(b!=a.f){c=null;!!a.f&&(c=Jvd(a.f,a,-1,c));!!b&&(c=Ivd(b,a,-1,c));c=g2d(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,b,b));} + function Lge(a,b,c,d){var e,f,g,h;if(Mvd(a.e)){e=b.Lk();h=b.md();f=c.md();g=fge(a,1,e,h,f,e.Jk()?kge(a,e,f,ZD(e,102)&&(RD(e,19).Bb&txe)!=0):-1,true);d?d.nj(g):(d=g);}return d} + function bne(a){var b,c,d;if(a==null)return null;c=RD(a,15);if(c.dc())return '';d=new Qhb;for(b=c.Kc();b.Ob();){Nhb(d,(nme(),WD(b.Pb())));d.a+=' ';}return qeb(d,d.a.length-1)} + function fne(a){var b,c,d;if(a==null)return null;c=RD(a,15);if(c.dc())return '';d=new Qhb;for(b=c.Kc();b.Ob();){Nhb(d,(nme(),WD(b.Pb())));d.a+=' ';}return qeb(d,d.a.length-1)} + function QIc(a,b,c){var d,e;d=a.c[b.c.p][b.p];e=a.c[c.c.p][c.p];if(d.a!=null&&e.a!=null){return Jfb(d.a,e.a)}else if(d.a!=null){return -1}else if(e.a!=null){return 1}return 0} + function RVc(a,b,c){c.Ug('Tree layout',1);Sed(a.b);Ved(a.b,(YVc(),UVc),UVc);Ved(a.b,VVc,VVc);Ved(a.b,WVc,WVc);Ved(a.b,XVc,XVc);a.a=Qed(a.b,b);SVc(a,b,c.eh(1));c.Vg();return b} + function ZDd(a,b){var c,d,e,f,g,h;if(b){f=b.a.length;c=new vue(f);for(h=(c.b-c.a)*c.c<0?(uue(),tue):new Rue(c);h.Ob();){g=RD(h.Pb(),17);e=xDd(b,g.a);d=new aFd(a);$Dd(d.a,e);}}} + function oEd(a,b){var c,d,e,f,g,h;if(b){f=b.a.length;c=new vue(f);for(h=(c.b-c.a)*c.c<0?(uue(),tue):new Rue(c);h.Ob();){g=RD(h.Pb(),17);e=xDd(b,g.a);d=new LEd(a);NDd(d.a,e);}}} + function ESd(b){var c;if(b!=null&&b.length>0&&ihb(b,b.length-1)==33){try{c=nSd(zhb(b,0,b.length-1));return c.e==null}catch(a){a=zdb(a);if(!ZD(a,33))throw Adb(a)}}return false} + function u0b(a,b,c){var d,e,f;d=Y2b(b);e=i2b(d);f=new R3b;P3b(f,b);switch(c.g){case 1:Q3b(f,spd(vpd(e)));break;case 2:Q3b(f,vpd(e));}pQb(f,(yCc(),ABc),UD(mQb(a,ABc)));return f} + function jdc(a){var b,c;b=RD(hs(new is(Mr(Z2b(a.a).a.Kc(),new ir))),18);c=RD(hs(new is(Mr(a3b(a.a).a.Kc(),new ir))),18);return Heb(TD(mQb(b,(Ywc(),Nwc))))||Heb(TD(mQb(c,Nwc)))} + function Bnc(){Bnc=geb;xnc=new Cnc('ONE_SIDE',0);znc=new Cnc('TWO_SIDES_CORNER',1);Anc=new Cnc('TWO_SIDES_OPPOSING',2);ync=new Cnc('THREE_SIDES',3);wnc=new Cnc('FOUR_SIDES',4);} + function Usc(a,b){var c,d,e,f;f=new bnb;e=0;d=b.Kc();while(d.Ob()){c=sgb(RD(d.Pb(),17).a+e);while(c.a=a.f){break}ZEb(f.c,c);}return f} + function iIc(a,b){var c,d,e,f,g;for(f=new Anb(b.a);f.a0&&Xlc(this,this.c-1,(qpd(),Xod));this.c0&&a[0].length>0&&(this.c=Heb(TD(mQb(Y2b(a[0][0]),(Ywc(),rwc)))));this.a=$C(aY,Nve,2117,a.length,0,2);this.b=$C(dY,Nve,2118,a.length,0,2);this.d=new Ks;} + function TOc(a){if(a.c.length==0){return false}if((tFb(0,a.c.length),RD(a.c[0],18)).c.i.k==(r3b(),o3b)){return true}return yDb(GDb(new SDb(null,new Swb(a,16)),new WOc),new YOc)} + function I5c(a,b){var c,d,e,f,g,h,i;h=Q2c(b);f=b.f;i=b.g;g=$wnd.Math.sqrt(f*f+i*i);e=0;for(d=new Anb(h);d.a=0){c=Fdb(a,ixe);d=Mdb(a,ixe);}else {b=Udb(a,1);c=Fdb(b,500000000);d=Mdb(b,500000000);d=Bdb(Sdb(d,1),Cdb(a,1));}return Rdb(Sdb(d,32),Cdb(c,yxe))} + function fTb(a,b,c){var d,e;d=(sFb(b.b!=0),RD(Wub(b,b.a.a),8));switch(c.g){case 0:d.b=0;break;case 2:d.b=a.f;break;case 3:d.a=0;break;default:d.a=a.g;}e=Sub(b,0);cvb(e,d);return b} + function Vpc(a,b,c,d){var e,f,g,h,i;i=a.b;f=b.d;g=f.j;h=$pc(g,i.d[g.g],c);e=$id(ajd(f.n),f.a);switch(f.j.g){case 1:case 3:h.a+=e.a;break;case 2:case 4:h.b+=e.b;}Pub(d,h,d.c.b,d.c);} + function YNc(a,b,c){var d,e,f,g;g=Wmb(a.e,b,0);f=new ZNc;f.b=c;d=new Jkb(a.e,g);while(d.b1;b>>=1){(b&1)!=0&&(d=Wib(d,c));c.d==1?(c=Wib(c,c)):(c=new djb(Tjb(c.a,c.d,$C(kE,Pwe,28,c.d<<1,15,1))));}d=Wib(d,c);return d} + function Hwb(){Hwb=geb;var a,b,c,d;Ewb=$C(iE,vxe,28,25,15,1);Fwb=$C(iE,vxe,28,33,15,1);d=1.52587890625E-5;for(b=32;b>=0;b--){Fwb[b]=d;d*=0.5;}c=1;for(a=24;a>=0;a--){Ewb[a]=c;c*=0.5;}} + function a5b(a){var b,c;if(Heb(TD(Gxd(a,(yCc(),NAc))))){for(c=new is(Mr(zGd(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),74);if(ozd(b)){if(Heb(TD(Gxd(b,OAc)))){return true}}}}return false} + function Qmc(a,b){var c,d,e;if(Ysb(a.f,b)){b.b=a;d=b.c;Wmb(a.j,d,0)!=-1||Rmb(a.j,d);e=b.d;Wmb(a.j,e,0)!=-1||Rmb(a.j,e);c=b.a.b;if(c.c.length!=0){!a.i&&(a.i=new _mc(a));Wmc(a.i,c);}}} + function Xpc(a){var b,c,d,e,f;c=a.c.d;d=c.j;e=a.d.d;f=e.j;if(d==f){return c.p=0&&lhb(a.substr(b,'GMT'.length),'GMT')){c[0]=b+3;return JA(a,c,d)}if(b>=0&&lhb(a.substr(b,'UTC'.length),'UTC')){c[0]=b+3;return JA(a,c,d)}return JA(a,c,d)} + function Zmc(a,b){var c,d,e,f,g;f=a.g.a;g=a.g.b;for(d=new Anb(a.d);d.ac;f--){a[f]|=b[f-c-1]>>>g;a[f-1]=b[f-c-1]<0&&hib(a.g,b,a.g,b+d,h);g=c.Kc();a.i+=d;for(e=0;e>4&15;f=a[d]&15;g[e++]=oAd[c];g[e++]=oAd[f];}return Ihb(g,0,g.length)}} + function Fhb(a){var b,c;if(a>=txe){b=uxe+(a-txe>>10&1023)&Bwe;c=56320+(a-txe&1023)&Bwe;return String.fromCharCode(b)+(''+String.fromCharCode(c))}else {return String.fromCharCode(a&Bwe)}} + function UMb(a,b){RMb();var c,d,e,f;e=RD(RD(Qc(a.r,b),21),87);if(e.gc()>=2){d=RD(e.Kc().Pb(),117);c=a.u.Hc((Pod(),Kod));f=a.u.Hc(Ood);return !d.a&&!c&&(e.gc()==2||f)}else {return false}} + function v3c(a,b,c,d,e){var f,g,h;f=w3c(a,b,c,d,e);h=false;while(!f){n3c(a,e,true);h=true;f=w3c(a,b,c,d,e);}h&&n3c(a,e,false);g=N2c(e);if(g.c.length!=0){!!a.d&&a.d.Gg(g);v3c(a,e,c,d,g);}} + function ind(){ind=geb;gnd=new jnd(LAe,0);end=new jnd('DIRECTED',1);hnd=new jnd('UNDIRECTED',2);cnd=new jnd('ASSOCIATION',3);fnd=new jnd('GENERALIZATION',4);dnd=new jnd('DEPENDENCY',5);} + function nsd(a,b){var c;if(!MCd(a)){throw Adb(new dgb(sHe))}c=MCd(a);switch(b.g){case 1:return -(a.j+a.f);case 2:return a.i-c.g;case 3:return a.j-c.f;case 4:return -(a.i+a.g);}return 0} + function Jge(a,b,c){var d,e,f;d=b.Lk();f=b.md();e=d.Jk()?fge(a,4,d,f,null,kge(a,d,f,ZD(d,102)&&(RD(d,19).Bb&txe)!=0),true):fge(a,d.tk()?2:1,d,f,d.ik(),-1,true);c?c.nj(e):(c=e);return c} + function lwb(a,b){var c,d;uFb(b);d=a.b.c.length;Rmb(a.b,b);while(d>0){c=d;d=(d-1)/2|0;if(a.a.Ne(Vmb(a.b,d),b)<=0){$mb(a.b,c,b);return true}$mb(a.b,c,Vmb(a.b,d));}$mb(a.b,d,b);return true} + function sKb(a,b,c,d){var e,f;e=0;if(!c){for(f=0;f=h} + function A8c(a){switch(a.g){case 0:return new o8c;case 1:return new u8c;default:throw Adb(new agb('No implementation is available for the width approximator '+(a.f!=null?a.f:''+a.g)));}} + function rDd(a,b,c,d){var e;e=false;if(bE(d)){e=true;sDd(b,c,WD(d));}if(!e){if($D(d)){e=true;rDd(a,b,c,d);}}if(!e){if(ZD(d,242)){e=true;qDd(b,c,RD(d,242));}}if(!e){throw Adb(new Aeb(tIe))}} + function uee(a,b){var c,d,e;c=b.qi(a.a);if(c){e=$Nd((!c.b&&(c.b=new SVd((JTd(),FTd),C8,c)),c.b),rKe);if(e!=null){for(d=1;d<(lke(),hke).length;++d){if(lhb(hke[d],e)){return d}}}}return 0} + function vee(a,b){var c,d,e;c=b.qi(a.a);if(c){e=$Nd((!c.b&&(c.b=new SVd((JTd(),FTd),C8,c)),c.b),rKe);if(e!=null){for(d=1;d<(lke(),ike).length;++d){if(lhb(ike[d],e)){return d}}}}return 0} + function Ve(a,b){var c,d,e,f;uFb(b);f=a.a.gc();if(f0?1:0;while(f.a[e]!=c){f=f.a[e];e=a.a.Ne(c.d,f.d)>0?1:0;}f.a[e]=d;d.b=c.b;d.a[0]=c.a[0];d.a[1]=c.a[1];c.a[0]=null;c.a[1]=null;} + function zIb(a){var b,c,d,e;b=new bnb;c=$C(xdb,Hye,28,a.a.c.length,16,1);Snb(c,c.length);for(e=new Anb(a.a);e.a0&&O9b((tFb(0,c.c.length),RD(c.c[0],30)),a);c.c.length>1&&O9b(RD(Vmb(c,c.c.length-1),30),a);b.Vg();} + function Sod(a){Pod();var b,c;b=ysb(Lod,cD(WC(D3,1),jwe,279,0,[Nod]));if(dy(Tx(b,a))>1){return false}c=ysb(Kod,cD(WC(D3,1),jwe,279,0,[Jod,Ood]));if(dy(Tx(c,a))>1){return false}return true} + function FBd(a,b){var c;c=Xjb((YSd(),XSd),a);ZD(c,507)?$jb(XSd,a,new B5d(this,b)):$jb(XSd,a,this);BBd(this,b);if(b==(jTd(),iTd)){this.wb=RD(this,2038);RD(b,2040);}else {this.wb=(lTd(),kTd);}} + function Lae(b){var c,d,e;if(b==null){return null}c=null;for(d=0;d=Awe?'error':d>=900?'warn':d>=800?'info':'log');eFb(c,a.a);!!a.b&&fFb(b,c,a.b,'Exception: ',true);} + function mQb(a,b){var c,d;d=(!a.q&&(a.q=new Tsb),Wjb(a.q,b));if(d!=null){return d}c=b.Sg();ZD(c,4)&&(c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c)),a);return c} + function sXb(){sXb=geb;nXb=new tXb('P1_CYCLE_BREAKING',0);oXb=new tXb('P2_LAYERING',1);pXb=new tXb('P3_NODE_ORDERING',2);qXb=new tXb('P4_NODE_PLACEMENT',3);rXb=new tXb('P5_EDGE_ROUTING',4);} + function KZb(a,b){CZb();var c;if(a.c==b.c){if(a.b==b.b||rZb(a.b,b.b)){c=oZb(a.b)?1:-1;if(a.a&&!b.a){return c}else if(!a.a&&b.a){return -c}}return hgb(a.b.g,b.b.g)}else {return Qfb(a.c,b.c)}} + function E3c(a,b){var c,d,e;if(p3c(a,b)){return true}for(d=new Anb(b);d.a=e||b<0)throw Adb(new veb(MIe+b+NIe+e));if(c>=e||c<0)throw Adb(new veb(OIe+c+NIe+e));b!=c?(d=(f=a.Cj(c),a.qj(b,f),f)):(d=a.xj(c));return d} + function Lje(a){var b,c,d;d=a;if(a){b=0;for(c=a.Eh();c;c=c.Eh()){if(++b>wxe){return Lje(c)}d=c;if(c==a){throw Adb(new dgb('There is a cycle in the containment hierarchy of '+a))}}}return d} + function Fe(a){var b,c,d;d=new Jyb(pve,'[',']');for(c=a.Kc();c.Ob();){b=c.Pb();Gyb(d,dE(b)===dE(a)?'(this Collection)':b==null?vve:jeb(b));}return !d.a?d.c:d.e.length==0?d.a.a:d.a.a+(''+d.e)} + function p3c(a,b){var c,d;d=false;if(b.gc()<2){return false}for(c=0;c1&&(a.j.b+=a.e);}else {a.j.a+=c.a;a.j.b=$wnd.Math.max(a.j.b,c.b);a.d.c.length>1&&(a.j.a+=a.e);}} + function Mnc(){Mnc=geb;Jnc=cD(WC(E3,1),NAe,64,0,[(qpd(),Yod),Xod,npd]);Inc=cD(WC(E3,1),NAe,64,0,[Xod,npd,ppd]);Knc=cD(WC(E3,1),NAe,64,0,[npd,ppd,Yod]);Lnc=cD(WC(E3,1),NAe,64,0,[ppd,Yod,Xod]);} + function Upc(a,b,c,d){var e,f,g,h,i,j,k;g=a.c.d;h=a.d.d;if(g.j==h.j){return}k=a.b;e=g.j;i=null;while(e!=h.j){i=b==0?tpd(e):rpd(e);f=$pc(e,k.d[e.g],c);j=$pc(i,k.d[i.g],c);Mub(d,$id(f,j));e=i;}} + function OJc(a,b,c,d){var e,f,g,h,i;g=hMc(a.a,b,c);h=RD(g.a,17).a;f=RD(g.b,17).a;if(d){i=RD(mQb(b,(Ywc(),Iwc)),10);e=RD(mQb(c,Iwc),10);if(!!i&&!!e){Slc(a.b,i,e);h+=a.b.i;f+=a.b.e;}}return h>f} + function OLc(a){var b,c,d,e,f,g,h,i,j;this.a=LLc(a);this.b=new bnb;for(c=a,d=0,e=c.length;damc(a.d).c){a.i+=a.g.c;cmc(a.d);}else if(amc(a.d).c>amc(a.g).c){a.e+=a.d.c;cmc(a.g);}else {a.i+=_lc(a.g);a.e+=_lc(a.d);cmc(a.g);cmc(a.d);}}} + function vTc(a,b,c){var d,e,f,g;f=b.q;g=b.r;new bTc((fTc(),dTc),b,f,1);new bTc(dTc,f,g,1);for(e=new Anb(c);e.ah&&(i=h/d);e>f&&(j=f/e);g=$wnd.Math.min(i,j);a.a+=g*(b.a-a.a);a.b+=g*(b.b-a.b);} + function I8c(a,b,c,d,e){var f,g;g=false;f=RD(Vmb(c.b,0),27);while(V8c(a,b,f,d,e)){g=true;T9c(c,f);if(c.b.c.length==0){break}f=RD(Vmb(c.b,0),27);}c.b.c.length==0&&Fad(c.j,c);g&&gad(b.q);return g} + function Eid(a,b){tid();var c,d,e,f;if(b.b<2){return false}f=Sub(b,0);c=RD(evb(f),8);d=c;while(f.b!=f.d.c){e=RD(evb(f),8);if(Did(a,d,e)){return true}d=e;}if(Did(a,d,c)){return true}return false} + function Bxd(a,b,c,d){var e,f;if(c==0){return !a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),BVd(a.o,b,d)}return f=RD(vYd((e=RD(Ywd(a,16),29),!e?a.ii():e),c),69),f.wk().Ak(a,Wwd(a),c-AYd(a.ii()),b,d)} + function BBd(a,b){var c;if(b!=a.sb){c=null;!!a.sb&&(c=RD(a.sb,54).Th(a,1,n7,c));!!b&&(c=RD(b,54).Rh(a,1,n7,c));c=hBd(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,4,b,b));} + function YDd(a,b){var c,d,e,f;if(b){e=vDd(b,'x');c=new ZEd(a);Hzd(c.a,(uFb(e),e));f=vDd(b,'y');d=new $Ed(a);Izd(d.a,(uFb(f),f));}else {throw Adb(new CDd('All edge sections need an end point.'))}} + function WDd(a,b){var c,d,e,f;if(b){e=vDd(b,'x');c=new WEd(a);Ozd(c.a,(uFb(e),e));f=vDd(b,'y');d=new XEd(a);Pzd(d.a,(uFb(f),f));}else {throw Adb(new CDd('All edge sections need a start point.'))}} + function hBb(a,b){var c,d,e,f,g,h,i;for(d=kBb(a),f=0,h=d.length;f>22-b;e=a.h<>22-b;}else if(b<44){c=0;d=a.l<>44-b;}else {c=0;d=0;e=a.l<a){throw Adb(new agb('k must be smaller than n'))}else return b==0||b==a?1:a==0?0:Bid(a)/(Bid(b)*Bid(a-b))} + function msd(a,b){var c,d,e,f;c=new zId(a);while(c.g==null&&!c.c?sId(c):c.g==null||c.i!=0&&RD(c.g[c.i-1],51).Ob()){f=RD(tId(c),58);if(ZD(f,167)){d=RD(f,167);for(e=0;e>4];b[c*2+1]=Fqe[f&15];}return Ihb(b,0,b.length)} + function sn(a){fn();var b,c,d;d=a.c.length;switch(d){case 0:return en;case 1:b=RD(Ir(new Anb(a)),44);return xn(b.ld(),b.md());default:c=RD(anb(a,$C(UK,Zve,44,a.c.length,0,1)),173);return new Mx(c);}} + function KWb(a){var b,c,d,e,f,g;b=new wmb;c=new wmb;hmb(b,a);hmb(c,a);while(c.b!=c.c){e=RD(smb(c),36);for(g=new Anb(e.a);g.a0&&uLc(a,c,b);return e}return rLc(a,b,c)} + function $4c(){$4c=geb;R4c=(umd(),Qld);Y4c=fmd;K4c=kld;L4c=nld;M4c=pld;J4c=ild;N4c=sld;Q4c=Lld;H4c=(D4c(),o4c);I4c=p4c;T4c=v4c;W4c=y4c;U4c=w4c;V4c=x4c;O4c=r4c;P4c=t4c;S4c=u4c;X4c=z4c;Z4c=B4c;G4c=n4c;} + function P9c(a,b){var c,d,e,f,g;if(a.e<=b){return a.g}if(R9c(a,a.g,b)){return a.g}f=a.r;d=a.g;g=a.r;e=(f-d)/2+d;while(d+11&&(a.e.b+=a.a);}else {a.e.a+=c.a;a.e.b=$wnd.Math.max(a.e.b,c.b);a.d.c.length>1&&(a.e.a+=a.a);}} + function Ipc(a){var b,c,d,e;e=a.i;b=e.b;d=e.j;c=e.g;switch(e.a.g){case 0:c.a=(a.g.b.o.a-d.a)/2;break;case 1:c.a=b.d.n.a+b.d.a.a;break;case 2:c.a=b.d.n.a+b.d.a.a-d.a;break;case 3:c.b=b.d.n.b+b.d.a.b;}} + function oOc(a,b,c){var d,e,f;for(e=new is(Mr(W2b(c).a.Kc(),new ir));gs(e);){d=RD(hs(e),18);if(!(!W0b(d)&&!(!W0b(d)&&d.c.i.c==d.d.i.c))){continue}f=gOc(a,d,c,new VOc);f.c.length>1&&(ZEb(b.c,f),true);}} + function _id(a,b,c,d,e){if(dd&&(a.a=d);a.be&&(a.b=e);return a} + function LFd(a){if(ZD(a,143)){return EFd(RD(a,143))}else if(ZD(a,233)){return FFd(RD(a,233))}else if(ZD(a,23)){return GFd(RD(a,23))}else {throw Adb(new agb(wIe+Fe(new mob(cD(WC(jJ,1),rve,1,5,[a])))))}} + function ujb(a,b,c,d,e){var f,g,h;f=true;for(g=0;g>>e|c[g+d+1]<>>e;++g;}return f} + function ZQc(a,b,c,d){var e,f,g;if(b.k==(r3b(),o3b)){for(f=new is(Mr(Z2b(b).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);g=e.c.i.k;if(g==o3b&&a.c.a[e.c.i.c.p]==d&&a.c.a[b.c.p]==c){return true}}}return false} + function CD(a,b){var c,d,e,f;b&=63;c=a.h&exe;if(b<22){f=c>>>b;e=a.m>>b|c<<22-b;d=a.l>>b|a.m<<22-b;}else if(b<44){f=0;e=c>>>b-22;d=a.m>>b-22|a.h<<44-b;}else {f=0;e=0;d=c>>>b-44;}return hD(d&dxe,e&dxe,f&exe)} + function mmc(a,b,c,d){var e;this.b=d;this.e=a==(RKc(),PKc);e=b[c];this.d=YC(xdb,[Nve,Hye],[183,28],16,[e.length,e.length],2);this.a=YC(kE,[Nve,Pwe],[53,28],15,[e.length,e.length],2);this.c=new Ylc(b,c);} + function Rmc(a){var b,c,d;a.k=new Si((qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,a.j.c.length);for(d=new Anb(a.j);d.a=c){_cc(a,b,d.p);return true}}return false} + function EA(a,b,c,d){var e,f,g,h,i,j;g=c.length;f=0;e=-1;j=Bhb((BFb(b,a.length+1),a.substr(b)),(wvb(),uvb));for(h=0;hf&&whb(j,Bhb(c[h],uvb))){e=h;f=i;}}e>=0&&(d[0]=b+f);return e} + function gCd(a){var b;if((a.Db&64)!=0)return Fyd(a);b=new dib(FHe);!a.a||Zhb(Zhb((b.a+=' "',b),a.a),'"');Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function xge(a,b,c){var d,e,f,g,h;h=pke(a.e.Dh(),b);e=RD(a.g,124);d=0;for(g=0;gc){return Jb(a,c,'start index')}if(b<0||b>c){return Jb(b,c,'end index')}return hc('end index (%s) must not be less than start index (%s)',cD(WC(jJ,1),rve,1,5,[sgb(b),sgb(a)]))} + function dA(b,c){var d,e,f,g;for(e=0,f=b.length;e0&&aGc(a,f,c));}}b.p=0;} + function Ahd(a){var b;this.c=new Yub;this.f=a.e;this.e=a.d;this.i=a.g;this.d=a.c;this.b=a.b;this.k=a.j;this.a=a.a;!a.i?(this.j=(b=RD(mfb(d3),9),new Fsb(b,RD(WEb(b,b.length),9),0))):(this.j=a.i);this.g=a.f;} + function Wb(a){var b,c,d,e;b=Thb(Zhb(new dib('Predicates.'),'and'),40);c=true;for(e=new Dkb(a);e.b0?h[g-1]:$C(jR,WAe,10,0,0,1);e=h[g];j=g=0?a.ki(e):Tvd(a,d);}else {throw Adb(new agb(KHe+d.xe()+LHe))}}else {Cvd(a,c,d);}} + function ADd(a){var b,c;c=null;b=false;if(ZD(a,211)){b=true;c=RD(a,211).a;}if(!b){if(ZD(a,263)){b=true;c=''+RD(a,263).a;}}if(!b){if(ZD(a,493)){b=true;c=''+RD(a,493).a;}}if(!b){throw Adb(new Aeb(tIe))}return c} + function gge(a,b,c){var d,e,f,g,h,i;i=pke(a.e.Dh(),b);d=0;h=a.i;e=RD(a.g,124);for(g=0;g=a.d.b.c.length){b=new R4b(a.d);b.p=d.p-1;Rmb(a.d.b,b);c=new R4b(a.d);c.p=d.p;Rmb(a.d.b,c);}g3b(d,RD(Vmb(a.d.b,d.p),30));}} + function DVc(a,b,c){var d,e,f;if(!a.b[b.g]){a.b[b.g]=true;d=c;!d&&(d=new YWc);Mub(d.b,b);for(f=a.a[b.g].Kc();f.Ob();){e=RD(f.Pb(),65);e.b!=b&&DVc(a,e.b,d);e.c!=b&&DVc(a,e.c,d);Mub(d.a,e);}return d}return null} + function iMb(a){switch(a.g){case 0:case 1:case 2:return qpd(),Yod;case 3:case 4:case 5:return qpd(),npd;case 6:case 7:case 8:return qpd(),ppd;case 9:case 10:case 11:return qpd(),Xod;default:return qpd(),opd;}} + function SOc(a,b){var c;if(a.c.length==0){return false}c=zDc((tFb(0,a.c.length),RD(a.c[0],18)).c.i);dOc();if(c==(wDc(),tDc)||c==sDc){return true}return yDb(GDb(new SDb(null,new Swb(a,16)),new $Oc),new aPc(b))} + function KDd(a,b){if(ZD(b,207)){return EDd(a,RD(b,27))}else if(ZD(b,193)){return FDd(a,RD(b,123))}else if(ZD(b,452)){return DDd(a,RD(b,166))}else {throw Adb(new agb(wIe+Fe(new mob(cD(WC(jJ,1),rve,1,5,[b])))))}} + function Ou(a,b,c){var d,e;this.f=a;d=RD(Wjb(a.b,b),260);e=!d?0:d.a;Sb(c,e);if(c>=(e/2|0)){this.e=!d?null:d.c;this.d=e;while(c++0){Lu(this);}}this.b=b;this.a=null;} + function iHb(a,b){var c,d;b.a?jHb(a,b):(c=RD(vAb(a.b,b.b),60),!!c&&c==a.a[b.b.f]&&!!c.a&&c.a!=b.b.a&&c.c.Fc(b.b),d=RD(uAb(a.b,b.b),60),!!d&&a.a[d.f]==b.b&&!!d.a&&d.a!=b.b.a&&b.b.c.Fc(d),wAb(a.b,b.b),undefined);} + function wMb(a,b){var c,d;c=RD(Vrb(a.b,b),127);if(RD(RD(Qc(a.r,b),21),87).dc()){c.n.b=0;c.n.c=0;return}c.n.b=a.C.b;c.n.c=a.C.c;a.A.Hc((Qpd(),Ppd))&&BMb(a,b);d=AMb(a,b);BLb(a,b)==(pod(),mod)&&(d+=2*a.w);c.a.a=d;} + function FNb(a,b){var c,d;c=RD(Vrb(a.b,b),127);if(RD(RD(Qc(a.r,b),21),87).dc()){c.n.d=0;c.n.a=0;return}c.n.d=a.C.d;c.n.a=a.C.a;a.A.Hc((Qpd(),Ppd))&&JNb(a,b);d=INb(a,b);BLb(a,b)==(pod(),mod)&&(d+=2*a.w);c.a.b=d;} + function VQb(a,b){var c,d,e,f;f=new bnb;for(d=new Anb(b);d.ad&&(BFb(b-1,a.length),a.charCodeAt(b-1)<=32)){--b;}return d>0||bc.a&&(d.Hc((ukd(),okd))?(e=(b.a-c.a)/2):d.Hc(qkd)&&(e=b.a-c.a));b.b>c.b&&(d.Hc((ukd(),skd))?(f=(b.b-c.b)/2):d.Hc(rkd)&&(f=b.b-c.b));Isd(a,e,f);} + function ABd(a,b,c,d,e,f,g,h,i,j,k,l,m){ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),4);PAd(a,c);a.f=g;DWd(a,h);FWd(a,i);xWd(a,j);EWd(a,k);aWd(a,l);AWd(a,m);_Vd(a,true);$Vd(a,e);a.Zk(f);YVd(a,b);d!=null&&(a.i=null,zWd(a,d));} + function Jb(a,b,c){if(a<0){return hc(qve,cD(WC(jJ,1),rve,1,5,[c,sgb(a)]))}else if(b<0){throw Adb(new agb(sve+b))}else {return hc('%s (%s) must not be greater than size (%s)',cD(WC(jJ,1),rve,1,5,[c,sgb(a),sgb(b)]))}} + function Xnb(a,b,c,d,e,f){var g,h,i,j;g=d-c;if(g<7){Unb(b,c,d,f);return}i=c+e;h=d+e;j=i+(h-i>>1);Xnb(b,a,i,j,-e,f);Xnb(b,a,j,h,-e,f);if(f.Ne(a[j-1],a[j])<=0){while(c=0?a.bi(f,c):Svd(a,e,c);}else {throw Adb(new agb(KHe+e.xe()+LHe))}}else {Bvd(a,d,e,c);}} + function n3d(a){var b,c;if(a.f){while(a.n>0){b=RD(a.k.Xb(a.n-1),76);c=b.Lk();if(ZD(c,102)&&(RD(c,19).Bb&QHe)!=0&&(!a.e||c.pk()!=C4||c.Lj()!=0)&&b.md()!=null){return true}else {--a.n;}}return false}else {return a.n>0}} + function Pje(b){var c,d,e,f;d=RD(b,54)._h();if(d){try{e=null;c=N5d((YSd(),XSd),jSd(kSd(d)));if(c){f=c.ai();!!f&&(e=f.Fl(Chb(d.e)));}if(!!e&&e!=b){return Pje(e)}}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}return b} + function P3c(a,b,c){var d,e,f;c.Ug('Remove overlaps',1);c.dh(b,eFe);d=RD(Gxd(b,(u2c(),t2c)),27);a.f=d;a.a=u5c(RD(Gxd(b,($4c(),X4c)),300));e=UD(Gxd(b,(umd(),fmd)));s3c(a,(uFb(e),e));f=Q2c(d);O3c(a,b,f,c);c.dh(b,gFe);} + function Ded(a){var b,c,d;if(Heb(TD(Gxd(a,(umd(),$kd))))){d=new bnb;for(c=new is(Mr(zGd(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),74);ozd(b)&&Heb(TD(Gxd(b,_kd)))&&(ZEb(d.c,b),true);}return d}else {return yob(),yob(),vob}} + function KC(a){if(!a){return cC(),bC}var b=a.valueOf?a.valueOf():a;if(b!==a){var c=GC[typeof b];return c?c(b):NC(typeof b)}else if(a instanceof Array||a instanceof $wnd.Array){return new NB(a)}else {return new vC(a)}} + function IMb(a,b,c){var d,e,f;f=a.o;d=RD(Vrb(a.p,c),252);e=d.i;e.b=ZKb(d);e.a=YKb(d);e.b=$wnd.Math.max(e.b,f.a);e.b>f.a&&!b&&(e.b=f.a);e.c=-(e.b-f.a)/2;switch(c.g){case 1:e.d=-e.a;break;case 3:e.d=f.b;}$Kb(d);_Kb(d);} + function JMb(a,b,c){var d,e,f;f=a.o;d=RD(Vrb(a.p,c),252);e=d.i;e.b=ZKb(d);e.a=YKb(d);e.a=$wnd.Math.max(e.a,f.b);e.a>f.b&&!b&&(e.a=f.b);e.d=-(e.a-f.b)/2;switch(c.g){case 4:e.c=-e.b;break;case 2:e.c=f.a;}$Kb(d);_Kb(d);} + function nkc(a,b){var c,d,e,f,g;if(b.dc()){return}e=RD(b.Xb(0),131);if(b.gc()==1){mkc(a,e,e,1,0,b);return}c=1;while(c0){try{f=Oeb(c,qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){e=a;throw Adb(new RSd(e))}else throw Adb(a)}}d=(!b.a&&(b.a=new Zde(b)),b.a);return f=0?RD(QHd(d,f),58):null} + function Ib(a,b){if(a<0){return hc(qve,cD(WC(jJ,1),rve,1,5,['index',sgb(a)]))}else if(b<0){throw Adb(new agb(sve+b))}else {return hc('%s (%s) must be less than size (%s)',cD(WC(jJ,1),rve,1,5,['index',sgb(a),sgb(b)]))}} + function cob(a){var b,c,d,e,f;if(a==null){return vve}f=new Jyb(pve,'[',']');for(c=a,d=0,e=c.length;d=0?a.Lh(c,true,true):Qvd(a,e,true),160));RD(d,220).Zl(b);}else {throw Adb(new agb(KHe+b.xe()+LHe))}} + function Cib(a){var b,c;if(a>-140737488355328&&a<140737488355328){if(a==0){return 0}b=a<0;b&&(a=-a);c=eE($wnd.Math.floor($wnd.Math.log(a)/0.6931471805599453));(!b||a!=$wnd.Math.pow(2,c))&&++c;return c}return Dib(Hdb(a))} + function oTc(a){var b,c,d,e,f,g,h;f=new Iub;for(c=new Anb(a);c.a2&&h.e.b+h.j.b<=2){e=h;d=g;}f.a.zc(e,f);e.q=d;}return f} + function B5c(a,b,c){c.Ug('Eades radial',1);c.dh(b,gFe);a.d=RD(Gxd(b,(u2c(),t2c)),27);a.c=Kfb(UD(Gxd(b,($4c(),S4c))));a.e=u5c(RD(Gxd(b,X4c),300));a.a=Z3c(RD(Gxd(b,Z4c),434));a.b=k5c(RD(Gxd(b,O4c),354));C5c(a);c.dh(b,gFe);} + function t8c(a,b){b.Ug('Target Width Setter',1);if(Hxd(a,(X7c(),W7c))){Ixd(a,(X6c(),W6c),UD(Gxd(a,W7c)));}else {throw Adb(new Jed('A target width has to be set if the TargetWidthWidthApproximator should be used.'))}b.Vg();} + function _8b(a,b){var c,d,e;d=new j3b(a);kQb(d,b);pQb(d,(Ywc(),gwc),b);pQb(d,(yCc(),BBc),(Bod(),wod));pQb(d,Rzc,(Rjd(),Njd));h3b(d,(r3b(),m3b));c=new R3b;P3b(c,d);Q3b(c,(qpd(),ppd));e=new R3b;P3b(e,d);Q3b(e,Xod);return d} + function ttc(a){switch(a.g){case 0:return new FKc((RKc(),OKc));case 1:return new aKc;case 2:return new FLc;default:throw Adb(new agb('No implementation is available for the crossing minimizer '+(a.f!=null?a.f:''+a.g)));}} + function THc(a,b){var c,d,e,f,g;a.c[b.p]=true;Rmb(a.a,b);for(g=new Anb(b.j);g.a=f){g.$b();}else {e=g.Kc();for(d=0;d0?Hh():g<0&&Rw(a,b,-g);return true}else {return false}} + function YKb(a){var b,c,d,e,f,g,h;h=0;if(a.b==0){g=aLb(a,true);b=0;for(d=g,e=0,f=d.length;e0){h+=c;++b;}}b>1&&(h+=a.c*(b-1));}else {h=Vvb(SCb(HDb(CDb(_nb(a.a),new oLb),new qLb)));}return h>0?h+a.n.d+a.n.a:0} + function ZKb(a){var b,c,d,e,f,g,h;h=0;if(a.b==0){h=Vvb(SCb(HDb(CDb(_nb(a.a),new kLb),new mLb)));}else {g=bLb(a,true);b=0;for(d=g,e=0,f=d.length;e0){h+=c;++b;}}b>1&&(h+=a.c*(b-1));}return h>0?h+a.n.b+a.n.c:0} + function UOc(a){var b,c;if(a.c.length!=2){throw Adb(new dgb('Order only allowed for two paths.'))}b=(tFb(0,a.c.length),RD(a.c[0],18));c=(tFb(1,a.c.length),RD(a.c[1],18));if(b.d.i!=c.c.i){a.c.length=0;ZEb(a.c,c);ZEb(a.c,b);}} + function O8c(a,b,c){var d;zyd(c,b.g,b.f);Byd(c,b.i,b.j);for(d=0;d<(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i;d++){O8c(a,RD(QHd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),d),27),RD(QHd((!c.a&&(c.a=new C5d(J4,c,10,11)),c.a),d),27));}} + function DMb(a,b){var c,d,e,f;f=RD(Vrb(a.b,b),127);c=f.a;for(e=RD(RD(Qc(a.r,b),21),87).Kc();e.Ob();){d=RD(e.Pb(),117);!!d.c&&(c.a=$wnd.Math.max(c.a,QKb(d.c)));}if(c.a>0){switch(b.g){case 2:f.n.c=a.s;break;case 4:f.n.b=a.s;}}} + function ETb(a,b){var c,d,e;c=RD(mQb(b,(yVb(),lVb)),17).a-RD(mQb(a,lVb),17).a;if(c==0){d=ojd(ajd(RD(mQb(a,(JVb(),FVb)),8)),RD(mQb(a,GVb),8));e=ojd(ajd(RD(mQb(b,FVb),8)),RD(mQb(b,GVb),8));return Qfb(d.a*d.b,e.a*e.b)}return c} + function JVc(a,b){var c,d,e;c=RD(mQb(b,(h_c(),X$c)),17).a-RD(mQb(a,X$c),17).a;if(c==0){d=ojd(ajd(RD(mQb(a,(q$c(),RZc)),8)),RD(mQb(a,SZc),8));e=ojd(ajd(RD(mQb(b,RZc),8)),RD(mQb(b,SZc),8));return Qfb(d.a*d.b,e.a*e.b)}return c} + function _0b(a){var b,c;c=new bib;c.a+='e_';b=S0b(a);b!=null&&(c.a+=''+b,c);if(!!a.c&&!!a.d){Zhb((c.a+=' ',c),M3b(a.c));Zhb(Yhb((c.a+='[',c),a.c.i),']');Zhb((c.a+=SAe,c),M3b(a.d));Zhb(Yhb((c.a+='[',c),a.d.i),']');}return c.a} + function ZVc(a){switch(a.g){case 0:return new N_c;case 1:return new V_c;case 2:return new x0c;case 3:return new J0c;default:throw Adb(new agb('No implementation is available for the layout phase '+(a.f!=null?a.f:''+a.g)));}} + function qsd(a,b,c,d,e){var f;f=0;switch(e.g){case 1:f=$wnd.Math.max(0,b.b+a.b-(c.b+d));break;case 3:f=$wnd.Math.max(0,-a.b-d);break;case 2:f=$wnd.Math.max(0,-a.a-d);break;case 4:f=$wnd.Math.max(0,b.a+a.a-(c.a+d));}return f} + function MDd(a,b,c){var d,e,f,g,h;if(c){e=c.a.length;d=new vue(e);for(h=(d.b-d.a)*d.c<0?(uue(),tue):new Rue(d);h.Ob();){g=RD(h.Pb(),17);f=xDd(c,g.a);kIe in f.a||lIe in f.a?yEd(a,f,b):EEd(a,f,b);OGd(RD(Wjb(a.b,uDd(f)),74));}}} + function jXd(a){var b,c;switch(a.b){case -1:{return true}case 0:{c=a.t;if(c>1||c==-1){a.b=-1;return true}else {b=WVd(a);if(!!b&&(nke(),b.lk()==aKe)){a.b=-1;return true}else {a.b=1;return false}}}default:case 1:{return false}}} + function Sqe(a,b){var c,d,e,f;Mqe(a);if(a.c!=0||a.a!=123)throw Adb(new Lqe(TId((Hde(),eJe))));f=b==112;d=a.d;c=phb(a.i,125,d);if(c<0)throw Adb(new Lqe(TId((Hde(),fJe))));e=zhb(a.i,d,c);a.d=c+1;return ite(e,f,(a.e&512)==512)} + function YTb(a){var b,c,d,e,f,g,h;d=a.a.c.length;if(d>0){g=a.c.d;h=a.d.d;e=ijd(ojd(new rjd(h.a,h.b),g),1/(d+1));f=new rjd(g.a,g.b);for(c=new Anb(a.a);c.a=0&&f=0?a.Lh(c,true,true):Qvd(a,e,true),160));return RD(d,220).Wl(b)}else {throw Adb(new agb(KHe+b.xe()+NHe))}} + function _ae(){Tae();var a;if(Sae)return RD(N5d((YSd(),XSd),AKe),2038);RRd(UK,new hde);abe();a=RD(ZD(Xjb((YSd(),XSd),AKe),560)?Xjb(XSd,AKe):new $ae,560);Sae=true;Yae(a);Zae(a);Zjb((hTd(),gTd),a,new cbe);$jb(XSd,AKe,a);return a} + function Vfe(a,b){var c,d,e,f;a.j=-1;if(Mvd(a.e)){c=a.i;f=a.i!=0;LHd(a,b);d=new P3d(a.e,3,a.c,null,b,c,f);e=b.zl(a.e,a.c,null);e=Hge(a,b,e);if(!e){qvd(a.e,d);}else {e.nj(d);e.oj();}}else {LHd(a,b);e=b.zl(a.e,a.c,null);!!e&&e.oj();}} + function HA(a,b){var c,d,e;e=0;d=b[0];if(d>=a.length){return -1}c=(BFb(d,a.length),a.charCodeAt(d));while(c>=48&&c<=57){e=e*10+(c-48);++d;if(d>=a.length){break}c=(BFb(d,a.length),a.charCodeAt(d));}d>b[0]?(b[0]=d):(e=-1);return e} + function mPb(a){var b,c,d,e,f;e=RD(a.a,17).a;f=RD(a.b,17).a;c=e;d=f;b=$wnd.Math.max($wnd.Math.abs(e),$wnd.Math.abs(f));if(e<=0&&e==f){c=0;d=f-1;}else {if(e==-b&&f!=b){c=f;d=e;f>=0&&++c;}else {c=-f;d=e;}}return new Ptd(sgb(c),sgb(d))} + function YPb(a,b,c,d){var e,f,g,h,i,j;for(e=0;e=0&&j>=0&&i=a.i)throw Adb(new veb(MIe+b+NIe+a.i));if(c>=a.i)throw Adb(new veb(OIe+c+NIe+a.i));d=a.g[c];if(b!=c){b>16);b=d>>16&16;c=16-b;a=a>>b;d=a-256;b=d>>16&8;c+=b;a<<=b;d=a-qxe;b=d>>16&4;c+=b;a<<=b;d=a-Ove;b=d>>16&2;c+=b;a<<=b;d=a>>14;b=d&~(d>>1);return c+2-b}} + function RSb(a){HSb();var b,c,d,e;GSb=new bnb;FSb=new Tsb;ESb=new bnb;b=(!a.a&&(a.a=new C5d(J4,a,10,11)),a.a);JSb(b);for(e=new dMd(b);e.e!=e.i.gc();){d=RD(bMd(e),27);if(Wmb(GSb,d,0)==-1){c=new bnb;Rmb(ESb,c);KSb(d,c);}}return ESb} + function sTb(a,b,c){var d,e,f,g;a.a=c.b.d;if(ZD(b,326)){e=IGd(RD(b,74),false,false);f=ssd(e);d=new wTb(a);xgb(f,d);lsd(f,e);b.of((umd(),cld))!=null&&xgb(RD(b.of(cld),75),d);}else {g=RD(b,422);g.rh(g.nh()+a.a.a);g.sh(g.oh()+a.a.b);}} + function hWc(a,b){var c,d,e;e=new bnb;for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);c.c.g==a.g&&dE(mQb(c.b,(h_c(),f_c)))!==dE(mQb(c.c,f_c))&&!yDb(new SDb(null,new Swb(e,16)),new IWc(c))&&(ZEb(e.c,c),true);}_mb(e,new KWc);return e} + function fUb(a,b,c){var d,e,f,g;if(ZD(b,153)&&ZD(c,153)){f=RD(b,153);g=RD(c,153);return a.a[f.a][g.a]+a.a[g.a][f.a]}else if(ZD(b,250)&&ZD(c,250)){d=RD(b,250);e=RD(c,250);if(d.a==e.a){return RD(mQb(e.a,(yVb(),lVb)),17).a}}return 0} + function q9b(a,b){var c,d,e,f,g,h,i,j;j=Kfb(UD(mQb(b,(yCc(),fCc))));i=a[0].n.a+a[0].o.a+a[0].d.c+j;for(h=1;h=0){return c}h=ejd(ojd(new rjd(g.c+g.b/2,g.d+g.a/2),new rjd(f.c+f.b/2,f.d+f.a/2)));return -(oRb(f,g)-1)*h} + function ysd(a,b,c){var d;FDb(new SDb(null,(!c.a&&(c.a=new C5d(F4,c,6,6)),new Swb(c.a,16))),new Qsd(a,b));FDb(new SDb(null,(!c.n&&(c.n=new C5d(I4,c,1,7)),new Swb(c.n,16))),new Ssd(a,b));d=RD(Gxd(c,(umd(),cld)),75);!!d&&Bjd(d,a,b);} + function Qvd(a,b,c){var d,e,f;f=Eee((lke(),jke),a.Dh(),b);if(f){nke();RD(f,69).xk()||(f=zfe(Qee(jke,f)));e=(d=a.Ih(f),RD(d>=0?a.Lh(d,true,true):Qvd(a,f,true),160));return RD(e,220).Sl(b,c)}else {throw Adb(new agb(KHe+b.xe()+NHe))}} + function WNd(a,b,c,d){var e,f,g,h,i;e=a.d[b];if(e){f=e.g;i=e.i;if(d!=null){for(h=0;h=c){d=b;j=(i.c+i.a)/2;g=j-c;if(i.c<=j-c){e=new BTc(i.c,g);Qmb(a,d++,e);}h=j+c;if(h<=i.a){f=new BTc(h,i.a);wFb(d,a.c.length);XEb(a.c,d,f);}}} + function mZc(a,b,c){var d,e,f,g,h,i;if(!b.dc()){e=new Yub;for(i=b.Kc();i.Ob();){h=RD(i.Pb(),40);Zjb(a.a,sgb(h.g),sgb(c));for(g=(d=Sub((new dXc(h)).a.d,0),new gXc(d));dvb(g.a);){f=RD(evb(g.a),65).c;Pub(e,f,e.c.b,e.c);}}mZc(a,e,c+1);}} + function Ude(a){var b;if(!a.c&&a.g==null){a.d=a.bj(a.f);WGd(a,a.d);b=a.d;}else {if(a.g==null){return true}else if(a.i==0){return false}else {b=RD(a.g[a.i-1],51);}}if(b==a.b&&null.Vm>=null.Um()){tId(a);return Ude(a)}else {return b.Ob()}} + function t_b(a){this.a=a;if(a.c.i.k==(r3b(),m3b)){this.c=a.c;this.d=RD(mQb(a.c.i,(Ywc(),hwc)),64);}else if(a.d.i.k==m3b){this.c=a.d;this.d=RD(mQb(a.d.i,(Ywc(),hwc)),64);}else {throw Adb(new agb('Edge '+a+' is not an external edge.'))}} + function O1d(a,b){var c,d,e;e=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,e,a.b));if(!b){PAd(a,null);Q1d(a,0);P1d(a,null);}else if(b!=a){PAd(a,b.zb);Q1d(a,b.d);c=(d=b.c,d==null?b.zb:d);P1d(a,c==null||lhb(c,b.zb)?null:c);}} + function hj(a,b){var c;this.e=(tm(),Qb(a),tm(),zm(a));this.c=(Qb(b),zm(b));Lb(this.e.Rd().dc()==this.c.Rd().dc());this.d=Uv(this.e);this.b=Uv(this.c);c=YC(jJ,[Nve,rve],[5,1],5,[this.e.Rd().gc(),this.c.Rd().gc()],2);this.a=c;Zi(this);} + function Lz(b){(!Jz&&(Jz=Mz()),Jz);var d=b.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(a){return Kz(a)});return '"'+d+'"'} + function VEb(a,b,c,d,e,f){var g,h,i,j,k;if(e==0){return}if(dE(a)===dE(c)){a=a.slice(b,b+e);b=0;}i=c;for(h=b,j=b+e;h=g)throw Adb(new aMd(b,g));e=c[b];if(g==1){d=null;}else {d=$C(d6,IJe,424,g-1,0,1);hib(c,0,d,0,b);f=g-b-1;f>0&&hib(c,b+1,d,b,f);}Bde(a,d);Ade(a,b,e);return e} + function l3d(a){var b,c;if(a.f){while(a.n0?(f=vpd(c)):(f=spd(vpd(c)));}Ixd(b,GBc,f);} + function agc(a,b){var c;b.Ug('Partition preprocessing',1);c=RD(zDb(CDb(EDb(CDb(new SDb(null,new Swb(a.a,16)),new egc),new ggc),new igc),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);FDb(c.Oc(),new kgc);b.Vg();} + function Uoc(a,b){var c,d,e,f,g;g=a.j;b.a!=b.b&&_mb(g,new ypc);e=g.c.length/2|0;for(d=0;d0&&uLc(a,c,b);return f}else if(d.a!=null){uLc(a,b,c);return -1}else if(e.a!=null){uLc(a,c,b);return 1}return 0} + function EVc(a,b){var c,d,e,f,g;e=b.b.b;a.a=$C(QK,Ize,15,e,0,1);a.b=$C(xdb,Hye,28,e,16,1);for(g=Sub(b.b,0);g.b!=g.d.c;){f=RD(evb(g),40);a.a[f.g]=new Yub;}for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);a.a[c.b.g].Fc(c);a.a[c.c.g].Fc(c);}} + function SJd(a,b){var c,d,e,f;if(a.Pj()){c=a.Ej();f=a.Qj();++a.j;a.qj(c,a.Zi(c,b));d=a.Ij(3,null,b,c,f);if(a.Mj()){e=a.Nj(b,null);if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Jj(d);}}else {_Id(a,b);if(a.Mj()){e=a.Nj(b,null);!!e&&e.oj();}}} + function oLd(a,b,c){var d,e,f;if(a.Pj()){f=a.Qj();KHd(a,b,c);d=a.Ij(3,null,c,b,f);if(a.Mj()){e=a.Nj(c,null);a.Tj()&&(e=a.Uj(c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Jj(d);}}else {KHd(a,b,c);if(a.Mj()){e=a.Nj(c,null);!!e&&e.oj();}}} + function bge(a,b){var c,d,e,f,g;g=pke(a.e.Dh(),b);e=new YHd;c=RD(a.g,124);for(f=a.i;--f>=0;){d=c[f];g.am(d.Lk())&&WGd(e,d);}!wLd(a,e)&&Mvd(a.e)&&eZd(a,b.Jk()?fge(a,6,b,(yob(),vob),null,-1,false):fge(a,b.tk()?2:1,b,null,null,-1,false));} + function _7b(a,b){var c,d,e,f,g;if(a.a==($uc(),Yuc)){return true}f=b.a.c;c=b.a.c+b.a.b;if(b.j){d=b.A;g=d.c.c.a-d.o.a/2;e=f-(d.n.a+d.o.a);if(e>g){return false}}if(b.q){d=b.C;g=d.c.c.a-d.o.a/2;e=d.n.a-c;if(e>g){return false}}return true} + function bRc(a){WQc();var b,c,d,e,f,g,h;c=new gub;for(e=new Anb(a.e.b);e.a1?(a.e*=Kfb(a.a)):(a.f/=Kfb(a.a));uRb(a);vRb(a);rRb(a);pQb(a.b,(tSb(),lSb),a.g);} + function n9b(a,b,c){var d,e,f,g,h,i;d=0;i=c;if(!b){d=c*(a.c.length-1);i*=-1;}for(f=new Anb(a);f.a=0?a.Ah(null):a.Ph().Th(a,-1-b,null,null));a.Bh(RD(e,54),c);!!d&&d.oj();a.vh()&&a.wh()&&c>-1&&qvd(a,new N3d(a,9,c,f,e));return e}}}return f} + function stb(a,b){var c,d,e,f,g;f=a.b.Ce(b);d=(c=a.a.get(f),c==null?$C(jJ,rve,1,0,5,1):c);for(g=0;g>5;if(e>=a.d){return a.e<0}c=a.a[e];b=1<<(b&31);if(a.e<0){d=Uib(a);if(e>16)),15).dd(f);if(h0){!(Dmd(a.a.c)&&b.n.d)&&!(Emd(a.a.c)&&b.n.b)&&(b.g.d+=$wnd.Math.max(0,d/2-0.5));!(Dmd(a.a.c)&&b.n.a)&&!(Emd(a.a.c)&&b.n.c)&&(b.g.a-=d-1);}}} + function c7b(a){var b,c,d,e,f;e=new bnb;f=d7b(a,e);b=RD(mQb(a,(Ywc(),Iwc)),10);if(b){for(d=new Anb(b.j);d.a>b;f=a.m>>b|c<<22-b;e=a.l>>b|a.m<<22-b;}else if(b<44){g=d?exe:0;f=c>>b-22;e=a.m>>b-22|c<<44-b;}else {g=d?exe:0;f=d?dxe:0;e=c>>b-44;}return hD(e&dxe,f&dxe,g&exe)} + function ORb(a){var b,c,d,e,f,g;this.c=new bnb;this.d=a;d=oxe;e=oxe;b=pxe;c=pxe;for(g=Sub(a,0);g.b!=g.d.c;){f=RD(evb(g),8);d=$wnd.Math.min(d,f.a);e=$wnd.Math.min(e,f.b);b=$wnd.Math.max(b,f.a);c=$wnd.Math.max(c,f.b);}this.a=new Uid(d,e,b-d,c-e);} + function Udc(a,b){var c,d,e,f,g,h;for(f=new Anb(a.b);f.a0&&ZD(b,44)){a.a._j();j=RD(b,44);i=j.ld();f=i==null?0:tb(i);g=bOd(a.a,f);c=a.a.d[g];if(c){d=RD(c.g,379);k=c.i;for(h=0;h=2){c=e.Kc();b=UD(c.Pb());while(c.Ob()){f=b;b=UD(c.Pb());d=$wnd.Math.min(d,(uFb(b),b)-(uFb(f),f));}}return d} + function iWc(a,b){var c,d,e;e=new bnb;for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);c.b.g==a.g&&!lhb(c.b.c,IEe)&&dE(mQb(c.b,(h_c(),f_c)))!==dE(mQb(c.c,f_c))&&!yDb(new SDb(null,new Swb(e,16)),new OWc(c))&&(ZEb(e.c,c),true);}_mb(e,new QWc);return e} + function $u(a,b){var c,d,e;if(dE(b)===dE(Qb(a))){return true}if(!ZD(b,15)){return false}d=RD(b,15);e=a.gc();if(e!=d.gc()){return false}if(ZD(d,59)){for(c=0;c0&&(e=c);for(g=new Anb(a.f.e);g.a0){b-=1;c-=1;}else {if(d>=0&&e<0){b+=1;c+=1;}else {if(d>0&&e>=0){b-=1;c+=1;}else {b+=1;c-=1;}}}}}return new Ptd(sgb(b),sgb(c))} + function nNc(a,b){if(a.cb.c){return 1}else if(a.bb.b){return 1}else if(a.a!=b.a){return tb(a.a)-tb(b.a)}else if(a.d==(sNc(),rNc)&&b.d==qNc){return -1}else if(a.d==qNc&&b.d==rNc){return 1}return 0} + function ARc(a,b){var c,d,e,f,g;f=b.a;f.c.i==b.b?(g=f.d):(g=f.c);f.c.i==b.b?(d=f.c):(d=f.d);e=lQc(a.a,g,d);if(e>0&&e0}else if(e<0&&-e0}return false} + function X9c(a,b,c,d){var e,f,g,h,i,j,k,l;e=(b-a.d)/a.c.c.length;f=0;a.a+=c;a.d=b;for(l=new Anb(a.c);l.a>24;}return g} + function Bfb(a){if(a.ze()){var b=a.c;b.Ae()?(a.o='['+b.n):!b.ze()?(a.o='[L'+b.xe()+';'):(a.o='['+b.xe());a.b=b.we()+'[]';a.k=b.ye()+'[]';return}var c=a.j;var d=a.d;d=d.split('/');a.o=Efb('.',[c,Efb('$',d)]);a.b=Efb('.',[c,Efb('.',d)]);a.k=d[d.length-1];} + function hJb(a,b){var c,d,e,f,g;g=null;for(f=new Anb(a.e.a);f.a=0;b-=2){for(c=0;c<=b;c+=2){if(a.b[c]>a.b[c+2]||a.b[c]===a.b[c+2]&&a.b[c+1]>a.b[c+3]){d=a.b[c+2];a.b[c+2]=a.b[c];a.b[c]=d;d=a.b[c+3];a.b[c+3]=a.b[c+1];a.b[c+1]=d;}}}a.c=true;} + function nKc(a,b){var c,d,e,f,g,h,i,j,k;j=-1;k=0;for(g=a,h=0,i=g.length;h0&&++k;}}++j;}return k} + function awd(a){var b,c;c=new dib(nfb(a.Rm));c.a+='@';Zhb(c,(b=tb(a)>>>0,b.toString(16)));if(a.Vh()){c.a+=' (eProxyURI: ';Yhb(c,a._h());if(a.Kh()){c.a+=' eClass: ';Yhb(c,a.Kh());}c.a+=')';}else if(a.Kh()){c.a+=' (eClass: ';Yhb(c,a.Kh());c.a+=')';}return c.a} + function KGb(a){var b,c,d,e;if(a.e){throw Adb(new dgb((lfb(lN),lye+lN.k+mye)))}a.d==(Cmd(),Amd)&&JGb(a,ymd);for(c=new Anb(a.a.a);c.a>24;}return c} + function cNb(a,b,c){var d,e,f;e=RD(Vrb(a.i,b),314);if(!e){e=new UKb(a.d,b,c);Wrb(a.i,b,e);if(jMb(b)){tKb(a.a,b.c,b.b,e);}else {f=iMb(b);d=RD(Vrb(a.p,f),252);switch(f.g){case 1:case 3:e.j=true;cLb(d,b.b,e);break;case 4:case 2:e.k=true;cLb(d,b.c,e);}}}return e} + function Ndc(a,b){var c,d,e,f,g,h,i,j,k;i=ev(a.c-a.b&a.a.length-1);j=null;k=null;for(f=new Kmb(a);f.a!=f.b;){e=RD(Imb(f),10);c=(h=RD(mQb(e,(Ywc(),vwc)),12),!h?null:h.i);d=(g=RD(mQb(e,wwc),12),!g?null:g.i);if(j!=c||k!=d){Rdc(i,b);j=c;k=d;}ZEb(i.c,e);}Rdc(i,b);} + function Rge(a,b,c,d){var e,f,g,h,i,j;h=new YHd;i=pke(a.e.Dh(),b);e=RD(a.g,124);nke();if(RD(b,69).xk()){for(g=0;g=0){return e}else {f=1;for(h=new Anb(b.j);h.a=0){return e}else {f=1;for(h=new Anb(b.j);h.a0&&b.Ne((tFb(e-1,a.c.length),RD(a.c[e-1],10)),f)>0){$mb(a,e,(tFb(e-1,a.c.length),RD(a.c[e-1],10)));--e;}tFb(e,a.c.length);a.c[e]=f;}c.a=new Tsb;c.b=new Tsb;} + function yhd(a,b,c){var d,e,f,g,h,i,j,k;k=(d=RD(b.e&&b.e(),9),new Fsb(d,RD(WEb(d,d.length),9),0));i=vhb(c,'[\\[\\]\\s,]+');for(f=i,g=0,h=f.length;g=0){if(!b){b=new Rhb;d>0&&Nhb(b,(AFb(0,d,a.length),a.substr(0,d)));}b.a+='\\';Jhb(b,c&Bwe);}else !!b&&Jhb(b,c&Bwe);}return b?b.a:a} + function MYb(a){var b,c,d;for(c=new Anb(a.a.a.b);c.a0){!(Dmd(a.a.c)&&b.n.d)&&!(Emd(a.a.c)&&b.n.b)&&(b.g.d-=$wnd.Math.max(0,d/2-0.5));!(Dmd(a.a.c)&&b.n.a)&&!(Emd(a.a.c)&&b.n.c)&&(b.g.a+=$wnd.Math.max(0,d-1));}}} + function Ydc(a,b,c){var d,e;if((a.c-a.b&a.a.length-1)==2){if(b==(qpd(),Yod)||b==Xod){Odc(RD(omb(a),15),(Pnd(),Lnd));Odc(RD(omb(a),15),Mnd);}else {Odc(RD(omb(a),15),(Pnd(),Mnd));Odc(RD(omb(a),15),Lnd);}}else {for(e=new Kmb(a);e.a!=e.b;){d=RD(Imb(e),15);Odc(d,c);}}} + function HGd(a,b){var c,d,e,f,g,h,i;e=cv(new QGd(a));h=new Jkb(e,e.c.length);f=cv(new QGd(b));i=new Jkb(f,f.c.length);g=null;while(h.b>0&&i.b>0){c=(sFb(h.b>0),RD(h.a.Xb(h.c=--h.b),27));d=(sFb(i.b>0),RD(i.a.Xb(i.c=--i.b),27));if(c==d){g=c;}else {break}}return g} + function Dmc(a,b,c){var d,e,f,g;if(Hmc(a,b)>Hmc(a,c)){d=b3b(c,(qpd(),Xod));a.d=d.dc()?0:L3b(RD(d.Xb(0),12));g=b3b(b,ppd);a.b=g.dc()?0:L3b(RD(g.Xb(0),12));}else {e=b3b(c,(qpd(),ppd));a.d=e.dc()?0:L3b(RD(e.Xb(0),12));f=b3b(b,Xod);a.b=f.dc()?0:L3b(RD(f.Xb(0),12));}} + function wNb(a,b){var c,d,e,f;c=a.o.a;for(f=RD(RD(Qc(a.r,b),21),87).Kc();f.Ob();){e=RD(f.Pb(),117);e.e.a=c*Kfb(UD(e.b.of(sNb)));e.e.b=(d=e.b,d.pf((umd(),Gld))?d.ag()==(qpd(),Yod)?-d.Mf().b-Kfb(UD(d.of(Gld))):Kfb(UD(d.of(Gld))):d.ag()==(qpd(),Yod)?-d.Mf().b:0);}} + function Mhc(a,b){var c,d,e,f;b.Ug('Self-Loop pre-processing',1);for(d=new Anb(a.a);d.aa.c){break}else if(e.a>=a.s){f<0&&(f=g);h=g;}}i=(a.s+a.c)/2;if(f>=0){d=lTc(a,b,f,h);i=yTc((tFb(d,b.c.length),RD(b.c[d],339)));wTc(b,d,c);}return i} + function _Ad(a,b,c){var d,e,f,g,h,i,j;g=(f=new pVd,f);nVd(g,(uFb(b),b));j=(!g.b&&(g.b=new SVd((JTd(),FTd),C8,g)),g.b);for(i=1;i0&&ASb(this,e);}} + function zTb(a,b,c,d,e,f){var g,h,i;if(!e[b.a]){e[b.a]=true;g=d;!g&&(g=new gUb);Rmb(g.e,b);for(i=f[b.a].Kc();i.Ob();){h=RD(i.Pb(),290);if(h.d==c||h.c==c){continue}h.c!=b&&zTb(a,h.c,b,g,e,f);h.d!=b&&zTb(a,h.d,b,g,e,f);Rmb(g.c,h);Tmb(g.d,h.b);}return g}return null} + function v7b(a){var b,c,d,e,f,g,h;b=0;for(e=new Anb(a.e);e.a=2} + function _qc(a,b,c,d,e){var f,g,h,i,j,k;f=a.c.d.j;g=RD(ju(c,0),8);for(k=1;k1){return false}b=ysb(Xnd,cD(WC(A3,1),jwe,95,0,[Wnd,Znd]));if(dy(Tx(b,a))>1){return false}d=ysb(cod,cD(WC(A3,1),jwe,95,0,[bod,aod]));if(dy(Tx(d,a))>1){return false}return true} + function $Uc(a,b,c){var d,e,f;for(f=new Anb(a.t);f.a0){d.b.n-=d.c;d.b.n<=0&&d.b.u>0&&Mub(b,d.b);}}for(e=new Anb(a.i);e.a0){d.a.u-=d.c;d.a.u<=0&&d.a.n>0&&Mub(c,d.a);}}} + function tId(a){var b,c,d,e,f;if(a.g==null){a.d=a.bj(a.f);WGd(a,a.d);if(a.c){f=a.f;return f}}b=RD(a.g[a.i-1],51);e=b.Pb();a.e=b;c=a.bj(e);if(c.Ob()){a.d=c;WGd(a,c);}else {a.d=null;while(!b.Ob()){bD(a.g,--a.i,null);if(a.i==0){break}d=RD(a.g[a.i-1],51);b=d;}}return e} + function Rfe(a,b){var c,d,e,f,g,h;d=b;e=d.Lk();if(qke(a.e,e)){if(e.Si()&&cge(a,e,d.md())){return false}}else {h=pke(a.e.Dh(),e);c=RD(a.g,124);for(f=0;f1||c>1){return 2}}if(b+c==1){return 2}return 0} + function Kwb(a,b){var c,d,e,f,g,h;f=a.a*Mxe+a.b*1502;h=a.b*Mxe+11;c=$wnd.Math.floor(h*Nxe);f+=c;h-=c*Oxe;f%=Oxe;a.a=f;a.b=h;if(b<=24){return $wnd.Math.floor(a.a*Ewb[b])}else {e=a.a*(1<=2147483648&&(d-=4294967296);return d}} + function uSc(a,b,c){var d,e,f,g,h,i,j;f=new bnb;j=new Yub;g=new Yub;vSc(a,j,g,b);tSc(a,j,g,b,c);for(i=new Anb(a);i.ad.b.g&&(ZEb(f.c,d),true);}}return f} + function jed(a,b,c){var d,e,f,g,h,i;h=a.c;for(g=(!c.q?(yob(),yob(),wob):c.q).vc().Kc();g.Ob();){f=RD(g.Pb(),44);d=!QDb(CDb(new SDb(null,new Swb(h,16)),new PAb(new xed(b,f)))).Bd((xDb(),wDb));if(d){i=f.md();if(ZD(i,4)){e=FId(i);e!=null&&(i=e);}b.qf(RD(f.ld(),149),i);}}} + function mbd(a,b,c){var d,e;Sed(a.b);Ved(a.b,(gbd(),dbd),(_cd(),$cd));Ved(a.b,ebd,b.g);Ved(a.b,fbd,b.a);a.a=Qed(a.b,b);c.Ug('Compaction by shrinking a tree',a.a.c.length);if(b.i.c.length>1){for(e=new Anb(a.a);e.a=0?a.Lh(d,true,true):Qvd(a,f,true),160));RD(e,220).Xl(b,c);}else {throw Adb(new agb(KHe+b.xe()+LHe))}} + function k2d(a,b){var c,d,e,f,g;if(!b){return null}else {f=ZD(a.Cb,90)||ZD(a.Cb,102);g=!f&&ZD(a.Cb,331);for(d=new dMd((!b.a&&(b.a=new iae(b,o7,b)),b.a));d.e!=d.i.gc();){c=RD(bMd(d),89);e=i2d(c);if(f?ZD(e,90):g?ZD(e,156):!!e){return e}}return f?(JTd(),zTd):(JTd(),wTd)}} + function W8b(a,b){var c,d,e,f;b.Ug('Resize child graph to fit parent.',1);for(d=new Anb(a.b);d.a=2*b&&Rmb(c,new BTc(g[d-1]+b,g[d]-b));}return c} + function dEd(a,b,c){var d,e,f,g,h,j,k,l;if(c){f=c.a.length;d=new vue(f);for(h=(d.b-d.a)*d.c<0?(uue(),tue):new Rue(d);h.Ob();){g=RD(h.Pb(),17);e=xDd(c,g.a);!!e&&(j=sEd(a,(k=(bvd(),l=new PCd,l),!!b&&NCd(k,b),k),e),jyd(j,zDd(e,uIe)),GEd(e,j),HEd(e,j),CEd(a,e,j));}}} + function sYd(a){var b,c,d,e,f,g;if(!a.j){g=new f1d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(zYd(a));d.e!=d.i.gc();){c=RD(bMd(d),29);e=sYd(c);YGd(g,e);WGd(g,c);}b.a.Bc(a)!=null;}VHd(g);a.j=new N$d((RD(QHd(xYd((lTd(),kTd).o),11),19),g.i),g.g);yYd(a).b&=-33;}return a.j} + function lne(a){var b,c,d,e;if(a==null){return null}else {d=nue(a,true);e=mLe.length;if(lhb(d.substr(d.length-e,e),mLe)){c=d.length;if(c==4){b=(BFb(0,d.length),d.charCodeAt(0));if(b==43){return Yme}else if(b==45){return Xme}}else if(c==3){return Yme}}return new Ufb(d)}} + function pD(a){var b,c,d;c=a.l;if((c&c-1)!=0){return -1}d=a.m;if((d&d-1)!=0){return -1}b=a.h;if((b&b-1)!=0){return -1}if(b==0&&d==0&&c==0){return -1}if(b==0&&d==0&&c!=0){return ogb(c)}if(b==0&&d!=0&&c==0){return ogb(d)+22}if(b!=0&&d==0&&c==0){return ogb(b)+44}return -1} + function yo(a,b){var c,d,e,f,g;e=b.a&a.f;f=null;for(d=a.b[e];true;d=d.b){if(d==b){!f?(a.b[e]=b.b):(f.b=b.b);break}f=d;}g=b.f&a.f;f=null;for(c=a.c[g];true;c=c.d){if(c==b){!f?(a.c[g]=b.d):(f.d=b.d);break}f=c;}!b.e?(a.a=b.c):(b.e.c=b.c);!b.c?(a.e=b.e):(b.c.e=b.e);--a.i;++a.g;} + function Dt(a,b){var c;b.d?(b.d.b=b.b):(a.a=b.b);b.b?(b.b.d=b.d):(a.e=b.d);if(!b.e&&!b.c){c=RD(Hvb(RD(_jb(a.b,b.a),260)),260);c.a=0;++a.c;}else {c=RD(Hvb(RD(Wjb(a.b,b.a),260)),260);--c.a;!b.e?(c.b=RD(Hvb(b.c),511)):(b.e.c=b.c);!b.c?(c.c=RD(Hvb(b.e),511)):(b.c.e=b.e);}--a.d;} + function XPb(a){var b,c,d,e,f,g,h,i,j,k;c=a.o;b=a.p;g=lve;e=qwe;h=lve;f=qwe;for(j=0;j0);f.a.Xb(f.c=--f.b);Ikb(f,e);sFb(f.b3&&UA(a,0,b-3);}} + function eXb(a){var b,c,d,e;if(dE(mQb(a,(yCc(),IAc)))===dE((Fnd(),Cnd))){return !a.e&&dE(mQb(a,gAc))!==dE((xvc(),uvc))}d=RD(mQb(a,hAc),299);e=Heb(TD(mQb(a,nAc)))||dE(mQb(a,oAc))===dE((stc(),ptc));b=RD(mQb(a,fAc),17).a;c=a.a.c.length;return !e&&d!=(xvc(),uvc)&&(b==0||b>c)} + function Rnc(a){var b,c;c=0;for(;c0){break}}if(c>0&&c0){break}}if(b>0&&c>16!=6&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+Qzd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?Czd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,6,d));d=Bzd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,6,b,b));} + function pzd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=3&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+qzd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?jzd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,12,d));d=izd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function NCd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=9&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+OCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?LCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,9,d));d=KCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,9,b,b));} + function tWd(b){var c,d,e,f,g;e=WVd(b);g=b.j;if(g==null&&!!e){return b.Jk()?null:e.ik()}else if(ZD(e,156)){d=e.jk();if(d){f=d.wi();if(f!=b.i){c=RD(e,156);if(c.nk()){try{b.g=f.ti(c,g);}catch(a){a=zdb(a);if(ZD(a,82)){b.g=null;}else throw Adb(a)}}b.i=f;}}return b.g}return null} + function nRb(a){var b;b=new bnb;Rmb(b,new TFb(new rjd(a.c,a.d),new rjd(a.c+a.b,a.d)));Rmb(b,new TFb(new rjd(a.c,a.d),new rjd(a.c,a.d+a.a)));Rmb(b,new TFb(new rjd(a.c+a.b,a.d+a.a),new rjd(a.c+a.b,a.d)));Rmb(b,new TFb(new rjd(a.c+a.b,a.d+a.a),new rjd(a.c,a.d+a.a)));return b} + function ic(b){var c,d,e;if(b==null){return vve}try{return jeb(b)}catch(a){a=zdb(a);if(ZD(a,103)){c=a;e=nfb(rb(b))+'@'+(d=(gib(),jFb(b))>>>0,d.toString(16));lBb(pBb(),(SAb(),'Exception during lenientFormat for '+e),c);return '<'+e+' threw '+nfb(c.Rm)+'>'}else throw Adb(a)}} + function mTb(a,b,c){var d,e,f;for(f=b.a.ec().Kc();f.Ob();){e=RD(f.Pb(),74);d=RD(Wjb(a.b,e),272);!d&&(vCd(JGd(e))==vCd(LGd(e))?lTb(a,e,c):JGd(e)==vCd(LGd(e))?Wjb(a.c,e)==null&&Wjb(a.b,LGd(e))!=null&&oTb(a,e,c,false):Wjb(a.d,e)==null&&Wjb(a.b,JGd(e))!=null&&oTb(a,e,c,true));}} + function Pfc(a,b){var c,d,e,f,g,h,i;for(e=a.Kc();e.Ob();){d=RD(e.Pb(),10);h=new R3b;P3b(h,d);Q3b(h,(qpd(),Xod));pQb(h,(Ywc(),Hwc),(Geb(),true));for(g=b.Kc();g.Ob();){f=RD(g.Pb(),10);i=new R3b;P3b(i,f);Q3b(i,ppd);pQb(i,Hwc,true);c=new a1b;pQb(c,Hwc,true);Y0b(c,h);Z0b(c,i);}}} + function Pqc(a,b,c,d){var e,f,g,h;e=Nqc(a,b,c);f=Nqc(a,c,b);g=RD(Wjb(a.c,b),118);h=RD(Wjb(a.c,c),118);if(e1){b=eJb((c=new gJb,++a.b,c),a.d);for(h=Sub(f,0);h.b!=h.d.c;){g=RD(evb(h),125);rIb(uIb(tIb(vIb(sIb(new wIb,1),0),b),g));}}} + function isc(a,b,c){var d,e,f,g,h;c.Ug('Breaking Point Removing',1);a.a=RD(mQb(b,(yCc(),yAc)),223);for(f=new Anb(b.b);f.a>16!=11&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+zCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?sCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,10,d));d=rCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,11,b,b));} + function C0b(a){var b,c,d,e;for(d=new vkb((new mkb(a.b)).a);d.b;){c=tkb(d);e=RD(c.ld(),12);b=RD(c.md(),10);pQb(b,(Ywc(),Awc),e);pQb(e,Iwc,b);pQb(e,nwc,(Geb(),true));Q3b(e,RD(mQb(b,hwc),64));mQb(b,hwc);pQb(e.i,(yCc(),BBc),(Bod(),yod));RD(mQb(Y2b(e.i),kwc),21).Fc((ovc(),kvc));}} + function X7b(a,b,c){var d,e,f,g,h,i;f=0;g=0;if(a.c){for(i=new Anb(a.d.i.j);i.af.a){return -1}else if(e.ai){k=a.d;a.d=$C(D6,KJe,66,2*i+4,0,1);for(f=0;f=9223372036854775807){return MD(),ID}e=false;if(a<0){e=true;a=-a;}d=0;if(a>=hxe){d=eE(a/hxe);a-=d*hxe;}c=0;if(a>=gxe){c=eE(a/gxe);a-=c*gxe;}b=eE(a);f=hD(b,c,d);e&&nD(f);return f} + function KCb(a){var b,c,d,e,f;f=new bnb;Umb(a.b,new SEb(f));a.b.c.length=0;if(f.c.length!=0){b=(tFb(0,f.c.length),RD(f.c[0],82));for(c=1,d=f.c.length;c=-b&&d==b){return new Ptd(sgb(c-1),sgb(d))}return new Ptd(sgb(c),sgb(d-1))} + function lcc(){hcc();return cD(WC(YS,1),jwe,81,0,[nbc,kbc,obc,Ebc,Xbc,Ibc,bcc,Nbc,Vbc,zbc,Rbc,Mbc,Wbc,vbc,dcc,ebc,Qbc,Zbc,Fbc,Ybc,fcc,Tbc,fbc,Ubc,gcc,_bc,ecc,Gbc,sbc,Hbc,Dbc,ccc,ibc,qbc,Kbc,hbc,Lbc,Bbc,wbc,Obc,ybc,lbc,jbc,Cbc,xbc,Pbc,acc,gbc,Sbc,Abc,Jbc,tbc,rbc,$bc,pbc,ubc,mbc])} + function Cmc(a,b,c){a.d=0;a.b=0;b.k==(r3b(),q3b)&&c.k==q3b&&RD(mQb(b,(Ywc(),Awc)),10)==RD(mQb(c,Awc),10)&&(Gmc(b).j==(qpd(),Yod)?Dmc(a,b,c):Dmc(a,c,b));b.k==q3b&&c.k==o3b?Gmc(b).j==(qpd(),Yod)?(a.d=1):(a.b=1):c.k==q3b&&b.k==o3b&&(Gmc(c).j==(qpd(),Yod)?(a.b=1):(a.d=1));Imc(a,b,c);} + function EFd(a){var b,c,d,e,f,g,h,i,j,k,l;l=HFd(a);b=a.a;i=b!=null;i&&sDd(l,'category',a.a);e=cve(new Xkb(a.d));g=!e;if(g){j=new MB;sC(l,'knownOptions',j);c=new MFd(j);xgb(new Xkb(a.d),c);}f=cve(a.g);h=!f;if(h){k=new MB;sC(l,'supportedFeatures',k);d=new OFd(k);xgb(a.g,d);}return l} + function Ly(a){var b,c,d,e,f,g,h,i,j;d=false;b=336;c=0;f=new hq(a.length);for(h=a,i=0,j=h.length;i>16!=7&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+gCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?cCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=RD(b,54).Rh(a,1,H4,d));d=bCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,7,b,b));} + function lVd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=3&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+oVd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?iVd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=RD(b,54).Rh(a,0,p7,d));d=hVd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function Mjb(a,b){Ljb();var c,d,e,f,g,h,i,j,k;if(b.d>a.d){h=a;a=b;b=h;}if(b.d<63){return Qjb(a,b)}g=(a.d&-2)<<4;j=$ib(a,g);k=$ib(b,g);d=Gjb(a,Zib(j,g));e=Gjb(b,Zib(k,g));i=Mjb(j,k);c=Mjb(d,e);f=Mjb(Gjb(j,d),Gjb(e,k));f=Bjb(Bjb(f,i),c);f=Zib(f,g);i=Zib(i,g<<1);return Bjb(Bjb(i,f),c)} + function _Cc(){_Cc=geb;ZCc=new bDc(lEe,0);WCc=new bDc('LONGEST_PATH',1);XCc=new bDc('LONGEST_PATH_SOURCE',2);TCc=new bDc('COFFMAN_GRAHAM',3);VCc=new bDc(BBe,4);$Cc=new bDc('STRETCH_WIDTH',5);YCc=new bDc('MIN_WIDTH',6);SCc=new bDc('BF_MODEL_ORDER',7);UCc=new bDc('DF_MODEL_ORDER',8);} + function AKc(a,b,c){var d,e,f,g,h;g=aMc(a,c);h=$C(jR,WAe,10,b.length,0,1);d=0;for(f=g.Kc();f.Ob();){e=RD(f.Pb(),12);Heb(TD(mQb(e,(Ywc(),nwc))))&&(h[d++]=RD(mQb(e,Iwc),10));}if(d=0;f+=c?1:-1){g=g|b.c.lg(i,f,c,d&&!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,(Ywc(),Owc)))));g=g|b.q.ug(i,f,c);g=g|CKc(a,i[f],c,d);}Ysb(a.c,b);return g} + function F6b(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(k=u2b(a.j),l=0,m=k.length;l1&&(a.a=true);QQb(RD(c.b,68),$id(ajd(RD(b.b,68).c),ijd(ojd(ajd(RD(c.b,68).a),RD(b.b,68).a),e)));Odd(a,b);Qdd(a,c);}} + function tYb(a){var b,c,d,e,f,g,h;for(f=new Anb(a.a.a);f.a0&&f>0?(g.p=b++):d>0?(g.p=c++):f>0?(g.p=e++):(g.p=c++);}}yob();_mb(a.j,new Lfc);} + function zic(a){var b,c;c=null;b=RD(Vmb(a.g,0),18);do{c=b.d.i;if(nQb(c,(Ywc(),wwc))){return RD(mQb(c,wwc),12).i}if(c.k!=(r3b(),p3b)&&gs(new is(Mr(a3b(c).a.Kc(),new ir)))){b=RD(hs(new is(Mr(a3b(c).a.Kc(),new ir))),18);}else if(c.k!=p3b){return null}}while(!!c&&c.k!=(r3b(),p3b));return c} + function sqc(a,b){var c,d,e,f,g,h,i,j,k;h=b.j;g=b.g;i=RD(Vmb(h,h.c.length-1),113);k=(tFb(0,h.c.length),RD(h.c[0],113));j=oqc(a,g,i,k);for(f=1;fj){i=c;k=e;j=d;}}b.a=k;b.c=i;} + function fMc(a,b,c){var d,e,f,g,h,i,j;j=new yAb(new TMc(a));for(g=cD(WC(xR,1),XAe,12,0,[b,c]),h=0,i=g.length;hi-a.b&&hi-a.a&&h0){if(f.a){h=f.b.Mf().a;if(c>h){e=(c-h)/2;f.d.b=e;f.d.c=e;}}else {f.d.c=a.s+c;}}else if(Rod(a.u)){d=wsd(f.b);d.c<0&&(f.d.b=-d.c);d.c+d.b>f.b.Mf().a&&(f.d.c=d.c+d.b-f.b.Mf().a);}}} + function RUc(a,b){var c,d,e,f,g;g=new bnb;c=b;do{f=RD(Wjb(a.b,c),131);f.B=c.c;f.D=c.d;ZEb(g.c,f);c=RD(Wjb(a.k,c),18);}while(c);d=(tFb(0,g.c.length),RD(g.c[0],131));d.j=true;d.A=RD(d.d.a.ec().Kc().Pb(),18).c.i;e=RD(Vmb(g,g.c.length-1),131);e.q=true;e.C=RD(e.d.a.ec().Kc().Pb(),18).d.i;return g} + function pPb(a){var b,c;b=RD(a.a,17).a;c=RD(a.b,17).a;if(b>=0){if(b==c){return new Ptd(sgb(-b-1),sgb(-b-1))}if(b==-c){return new Ptd(sgb(-b),sgb(c+1))}}if($wnd.Math.abs(b)>$wnd.Math.abs(c)){if(b<0){return new Ptd(sgb(-b),sgb(c))}return new Ptd(sgb(-b),sgb(c+1))}return new Ptd(sgb(b+1),sgb(c))} + function H8b(a){var b,c;c=RD(mQb(a,(yCc(),UAc)),171);b=RD(mQb(a,(Ywc(),owc)),311);if(c==(cxc(),$wc)){pQb(a,UAc,bxc);pQb(a,owc,(Gvc(),Fvc));}else if(c==axc){pQb(a,UAc,bxc);pQb(a,owc,(Gvc(),Dvc));}else if(b==(Gvc(),Fvc)){pQb(a,UAc,$wc);pQb(a,owc,Evc);}else if(b==Dvc){pQb(a,UAc,axc);pQb(a,owc,Evc);}} + function dSc(){dSc=geb;bSc=new pSc;ZRc=pfd(new ufd,(sXb(),pXb),(hcc(),Fbc));aSc=nfd(pfd(new ufd,pXb,Tbc),rXb,Sbc);cSc=mfd(mfd(rfd(nfd(pfd(new ufd,nXb,bcc),rXb,acc),qXb),_bc),ccc);$Rc=nfd(pfd(pfd(pfd(new ufd,oXb,Ibc),qXb,Kbc),qXb,Lbc),rXb,Jbc);_Rc=nfd(pfd(pfd(new ufd,qXb,Lbc),qXb,qbc),rXb,pbc);} + function HUc(){HUc=geb;CUc=pfd(nfd(new ufd,(sXb(),rXb),(hcc(),tbc)),pXb,Fbc);GUc=mfd(mfd(rfd(nfd(pfd(new ufd,nXb,bcc),rXb,acc),qXb),_bc),ccc);DUc=nfd(pfd(pfd(pfd(new ufd,oXb,Ibc),qXb,Kbc),qXb,Lbc),rXb,Jbc);FUc=pfd(pfd(new ufd,pXb,Tbc),rXb,Sbc);EUc=nfd(pfd(pfd(new ufd,qXb,Lbc),qXb,qbc),rXb,pbc);} + function eSc(a,b,c,d,e){var f,g;if((!W0b(b)&&b.c.i.c==b.d.i.c||!djd(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])),c))&&!W0b(b)){b.c==e?hu(b.a,0,new sjd(c)):Mub(b.a,new sjd(c));if(d&&!Zsb(a.a,c)){g=RD(mQb(b,(yCc(),RAc)),75);if(!g){g=new Ejd;pQb(b,RAc,g);}f=new sjd(c);Pub(g,f,g.c.b,g.c);Ysb(a.a,f);}}} + function ht(a,b){var c,d,e,f;f=Ydb(Ndb(cwe,qgb(Ydb(Ndb(b==null?0:tb(b),dwe)),15)));c=f&a.b.length-1;e=null;for(d=a.b[c];d;e=d,d=d.a){if(d.d==f&&Hb(d.i,b)){!e?(a.b[c]=d.a):(e.a=d.a);Ts(RD(Hvb(d.c),604),RD(Hvb(d.f),604));Ss(RD(Hvb(d.b),227),RD(Hvb(d.e),227));--a.f;++a.e;return true}}return false} + function dec(a){var b,c;for(c=new is(Mr(Z2b(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),18);if(b.c.i.k!=(r3b(),n3b)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to FIRST, but has at least one incoming edge that "+' does not come from a FIRST_SEPARATE node. That must not happen.'))}}} + function Twd(a,b,c){var d,e,f,g,h,i,j;e=ggb(a.Db&254);if(e==0){a.Eb=c;}else {if(e==1){h=$C(jJ,rve,1,2,5,1);f=Xwd(a,b);if(f==0){h[0]=c;h[1]=a.Eb;}else {h[0]=a.Eb;h[1]=c;}}else {h=$C(jJ,rve,1,e+1,5,1);g=SD(a.Eb);for(d=2,i=0,j=0;d<=128;d<<=1){d==b?(h[j++]=c):(a.Db&d)!=0&&(h[j++]=g[i++]);}}a.Eb=h;}a.Db|=b;} + function vQb(a,b,c){var d,e,f,g;this.b=new bnb;e=0;d=0;for(g=new Anb(a);g.a0){f=RD(Vmb(this.b,0),176);e+=f.o;d+=f.p;}e*=2;d*=2;b>1?(e=eE($wnd.Math.ceil(e*b))):(d=eE($wnd.Math.ceil(d/b)));this.a=new gQb(e,d);} + function mkc(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r;k=d;if(b.j&&b.o){n=RD(Wjb(a.f,b.A),60);p=n.d.c+n.d.b;--k;}else {p=b.a.c+b.a.b;}l=e;if(c.q&&c.o){n=RD(Wjb(a.f,c.C),60);j=n.d.c;++l;}else {j=c.a.c;}q=j-p;i=$wnd.Math.max(2,l-k);h=q/i;o=p+h;for(m=k;m=0;g+=e?1:-1){h=b[g];i=d==(qpd(),Xod)?e?b3b(h,d):hv(b3b(h,d)):e?hv(b3b(h,d)):b3b(h,d);f&&(a.c[h.p]=i.gc());for(l=i.Kc();l.Ob();){k=RD(l.Pb(),12);a.d[k.p]=j++;}Tmb(c,i);}} + function AUc(a,b,c){var d,e,f,g,h,i,j,k;f=Kfb(UD(a.b.Kc().Pb()));j=Kfb(UD(fr(b.b)));d=ijd(ajd(a.a),j-c);e=ijd(ajd(b.a),c-f);k=$id(d,e);ijd(k,1/(j-f));this.a=k;this.b=new bnb;h=true;g=a.b.Kc();g.Pb();while(g.Ob()){i=Kfb(UD(g.Pb()));if(h&&i-c>AEe){this.b.Fc(c);h=false;}this.b.Fc(i);}h&&this.b.Fc(c);} + function mJb(a){var b,c,d,e;pJb(a,a.n);if(a.d.c.length>0){Nnb(a.c);while(xJb(a,RD(ynb(new Anb(a.e.a)),125))>5;b&=31;if(d>=a.d){return a.e<0?(Pib(),Jib):(Pib(),Oib)}f=a.d-d;e=$C(kE,Pwe,28,f+1,15,1);ujb(e,f,a.a,d,b);if(a.e<0){for(c=0;c0&&a.a[c]<<32-b!=0){for(c=0;c=0){return false}else {c=Eee((lke(),jke),e,b);if(!c){return true}else {d=c.Ik();return (d>1||d==-1)&&yfe(Qee(jke,c))!=3}}}}else {return false}} + function _4b(a,b,c,d){var e,f,g,h,i;h=AGd(RD(QHd((!b.b&&(b.b=new Yie(E4,b,4,7)),b.b),0),84));i=AGd(RD(QHd((!b.c&&(b.c=new Yie(E4,b,5,8)),b.c),0),84));if(vCd(h)==vCd(i)){return null}if(NGd(i,h)){return null}g=kzd(b);if(g==c){return d}else {f=RD(Wjb(a.a,g),10);if(f){e=f.e;if(e){return e}}}return null} + function uHc(a,b,c){var d,e,f,g,h;c.Ug('Longest path to source layering',1);a.a=b;h=a.a.a;a.b=$C(kE,Pwe,28,h.c.length,15,1);d=0;for(g=new Anb(h);g.a0){c[0]+=a.d;g-=c[0];}if(c[2]>0){c[2]+=a.d;g-=c[2];}f=$wnd.Math.max(0,g);c[1]=$wnd.Math.max(c[1],g);mKb(a,XJb,e.c+d.b+c[0]-(c[1]-g)/2,c);if(b==XJb){a.c.b=f;a.c.c=e.c+d.b+(f-g)/2;}} + function D_b(){this.c=$C(iE,vxe,28,(qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,15,1);this.b=$C(iE,vxe,28,cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd]).length,15,1);this.a=$C(iE,vxe,28,cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd]).length,15,1);Lnb(this.c,oxe);Lnb(this.b,pxe);Lnb(this.a,pxe);} + function rte(a,b,c){var d,e,f,g;if(b<=c){e=b;f=c;}else {e=c;f=b;}d=0;if(a.b==null){a.b=$C(kE,Pwe,28,2,15,1);a.b[0]=e;a.b[1]=f;a.c=true;}else {d=a.b.length;if(a.b[d-1]+1==e){a.b[d-1]=f;return}g=$C(kE,Pwe,28,d+2,15,1);hib(a.b,0,g,0,d);a.b=g;a.b[d-1]>=e&&(a.c=false,a.a=false);a.b[d++]=e;a.b[d]=f;a.c||vte(a);}} + function Oqc(a,b,c){var d,e,f,g,h,i,j;j=b.d;a.a=new cnb(j.c.length);a.c=new Tsb;for(h=new Anb(j);h.a=0?a.Lh(j,false,true):Qvd(a,c,false),61));n:for(f=l.Kc();f.Ob();){e=RD(f.Pb(),58);for(k=0;k1){vLd(e,e.i-1);}}return d}} + function Vdc(a,b){var c,d,e,f,g,h,i;c=new wmb;for(f=new Anb(a.b);f.aa.d[g.p]){c+=ZLc(a.b,f);hmb(a.a,sgb(f));}}while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function Uec(a){var b,c,d,e,f,g,h,i,j;a.a=new e6b;j=0;e=0;for(d=new Anb(a.i.b);d.ah.d&&(k=h.d+h.a+j);}}c.c.d=k;b.a.zc(c,b);i=$wnd.Math.max(i,c.c.d+c.c.a);}return i} + function ovc(){ovc=geb;fvc=new pvc('COMMENTS',0);hvc=new pvc('EXTERNAL_PORTS',1);ivc=new pvc('HYPEREDGES',2);jvc=new pvc('HYPERNODES',3);kvc=new pvc('NON_FREE_PORTS',4);lvc=new pvc('NORTH_SOUTH_PORTS',5);nvc=new pvc(FBe,6);evc=new pvc('CENTER_LABELS',7);gvc=new pvc('END_LABELS',8);mvc=new pvc('PARTITIONS',9);} + function PA(a,b,c,d,e){if(d<0){d=EA(a,e,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe]),b);d<0&&(d=EA(a,e,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec']),b));if(d<0){return false}c.k=d;return true}else if(d>0){c.k=d-1;return true}return false} + function RA(a,b,c,d,e){if(d<0){d=EA(a,e,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe]),b);d<0&&(d=EA(a,e,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec']),b));if(d<0){return false}c.k=d;return true}else if(d>0){c.k=d-1;return true}return false} + function TA(a,b,c,d,e,f){var g,h,i,j;h=32;if(d<0){if(b[0]>=a.length){return false}h=ihb(a,b[0]);if(h!=43&&h!=45){return false}++b[0];d=HA(a,b);if(d<0){return false}h==45&&(d=-d);}if(h==32&&b[0]-c==2&&e.b==2){i=new uB;j=i.q.getFullYear()-Owe+Owe-80;g=j%100;f.a=d==g;d+=(j/100|0)*100+(d=0?jjb(a):Xib(jjb(Odb(a))));Kjb[b]=Jdb(Sdb(a,b),0)?jjb(Sdb(a,b)):Xib(jjb(Odb(Sdb(a,b))));a=Ndb(a,5);}for(;b=j&&(i=d);}!!i&&(k=$wnd.Math.max(k,i.a.o.a));if(k>m){l=j;m=k;}}return l} + function SNb(a){var b,c,d,e,f,g,h;f=new yAb(RD(Qb(new eOb),50));h=pxe;for(c=new Anb(a.d);c.aFFe?_mb(i,a.b):d<=FFe&&d>GFe?_mb(i,a.d):d<=GFe&&d>HFe?_mb(i,a.c):d<=HFe&&_mb(i,a.a);f=$5c(a,i,f);}return e} + function sTc(a,b,c,d){var e,f,g,h,i,j;e=(d.c+d.a)/2;Xub(b.j);Mub(b.j,e);Xub(c.e);Mub(c.e,e);j=new ATc;for(h=new Anb(a.f);h.a1;if(h){d=new rjd(e,c.b);Mub(b.a,d);}zjd(b.a,cD(WC(l3,1),Nve,8,0,[m,l]));} + function TGc(a,b,c){var d,e;if(b=48;c--){Eqe[c]=c-48<<24>>24;}for(d=70;d>=65;d--){Eqe[d]=d-65+10<<24>>24;}for(e=102;e>=97;e--){Eqe[e]=e-97+10<<24>>24;}for(f=0;f<10;f++)Fqe[f]=48+f&Bwe;for(a=10;a<=15;a++)Fqe[a]=65+a-10&Bwe;} + function yYc(a,b){b.Ug('Process graph bounds',1);pQb(a,(q$c(),ZZc),Uvb(TCb(HDb(new SDb(null,new Swb(a.b,16)),new DYc))));pQb(a,_Zc,Uvb(TCb(HDb(new SDb(null,new Swb(a.b,16)),new FYc))));pQb(a,YZc,Uvb(SCb(HDb(new SDb(null,new Swb(a.b,16)),new HYc))));pQb(a,$Zc,Uvb(SCb(HDb(new SDb(null,new Swb(a.b,16)),new JYc))));b.Vg();} + function PWb(a){var b,c,d,e,f;e=RD(mQb(a,(yCc(),lBc)),21);f=RD(mQb(a,oBc),21);c=new rjd(a.f.a+a.d.b+a.d.c,a.f.b+a.d.d+a.d.a);b=new sjd(c);if(e.Hc((Qpd(),Mpd))){d=RD(mQb(a,nBc),8);if(f.Hc((dqd(),Ypd))){d.a<=0&&(d.a=20);d.b<=0&&(d.b=20);}b.a=$wnd.Math.max(c.a,d.a);b.b=$wnd.Math.max(c.b,d.b);}Heb(TD(mQb(a,mBc)))||QWb(a,c,b);} + function lOc(a,b){var c,d,e,f;for(f=b3b(b,(qpd(),npd)).Kc();f.Ob();){d=RD(f.Pb(),12);c=RD(mQb(d,(Ywc(),Iwc)),10);!!c&&rIb(uIb(tIb(vIb(sIb(new wIb,0),0.1),a.i[b.p].d),a.i[c.p].a));}for(e=b3b(b,Yod).Kc();e.Ob();){d=RD(e.Pb(),12);c=RD(mQb(d,(Ywc(),Iwc)),10);!!c&&rIb(uIb(tIb(vIb(sIb(new wIb,0),0.1),a.i[c.p].d),a.i[b.p].a));}} + function oYd(a){var b,c,d,e,f,g;if(!a.c){g=new W$d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(tYd(a));d.e!=d.i.gc();){c=RD(bMd(d),89);e=i2d(c);ZD(e,90)&&YGd(g,oYd(RD(e,29)));WGd(g,c);}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}T$d(g);VHd(g);a.c=new N$d((RD(QHd(xYd((lTd(),kTd).o),15),19),g.i),g.g);yYd(a).b&=-33;}return a.c} + function Dre(a){var b;if(a.c!=10)throw Adb(new Lqe(TId((Hde(),VIe))));b=a.a;switch(b){case 110:b=10;break;case 114:b=13;break;case 116:b=9;break;case 92:case 124:case 46:case 94:case 45:case 63:case 42:case 43:case 123:case 125:case 40:case 41:case 91:case 93:break;default:throw Adb(new Lqe(TId((Hde(),xJe))));}return b} + function GD(a){var b,c,d,e,f;if(a.l==0&&a.m==0&&a.h==0){return '0'}if(a.h==fxe&&a.m==0&&a.l==0){return '-9223372036854775808'}if(a.h>>19!=0){return '-'+GD(xD(a))}c=a;d='';while(!(c.l==0&&c.m==0&&c.h==0)){e=fD(ixe);c=iD(c,e,true);b=''+FD(eD);if(!(c.l==0&&c.m==0&&c.h==0)){f=9-b.length;for(;f>0;f--){b='0'+b;}}d=b+d;}return d} + function tkc(a){var b,c,d,e,f,g,h;b=false;c=0;for(e=new Anb(a.d.b);e.a=a.a){return -1}if(!W9b(b,c)){return -1}if(gr(RD(d.Kb(b),20))){return 1}e=0;for(g=RD(d.Kb(b),20).Kc();g.Ob();){f=RD(g.Pb(),18);i=f.c.i==b?f.d.i:f.c.i;h=X9b(a,i,c,d);if(h==-1){return -1}e=$wnd.Math.max(e,h);if(e>a.c-1){return -1}}return e+1} + function _Gd(a,b){var c,d,e,f,g,h;if(dE(b)===dE(a)){return true}if(!ZD(b,15)){return false}d=RD(b,15);h=a.gc();if(d.gc()!=h){return false}g=d.Kc();if(a.Yi()){for(c=0;c0){a._j();if(b!=null){for(f=0;f>24}case 97:case 98:case 99:case 100:case 101:case 102:{return a-97+10<<24>>24}case 65:case 66:case 67:case 68:case 69:case 70:{return a-65+10<<24>>24}default:{throw Adb(new Vgb('Invalid hexadecimal'))}}} + function iIb(){iIb=geb;hIb=new jIb('SPIRAL',0);cIb=new jIb('LINE_BY_LINE',1);dIb=new jIb('MANHATTAN',2);bIb=new jIb('JITTER',3);fIb=new jIb('QUADRANTS_LINE_BY_LINE',4);gIb=new jIb('QUADRANTS_MANHATTAN',5);eIb=new jIb('QUADRANTS_JITTER',6);aIb=new jIb('COMBINE_LINE_BY_LINE_MANHATTAN',7);_Hb=new jIb('COMBINE_JITTER_MANHATTAN',8);} + function Urc(a,b,c,d){var e,f,g,h,i,j;i=Zrc(a,c);j=Zrc(b,c);e=false;while(!!i&&!!j){if(d||Xrc(i,j,c)){g=Zrc(i,c);h=Zrc(j,c);asc(b);asc(a);f=i.c;Hec(i,false);Hec(j,false);if(c){f3b(b,j.p,f);b.p=j.p;f3b(a,i.p+1,f);a.p=i.p;}else {f3b(a,i.p,f);a.p=i.p;f3b(b,j.p+1,f);b.p=j.p;}g3b(i,null);g3b(j,null);i=g;j=h;e=true;}else {break}}return e} + function aDc(a){switch(a.g){case 0:return new XHc;case 1:return new pHc;case 3:return new GGc;case 4:return new gHc;case 5:return new jIc;case 6:return new IHc;case 2:return new xHc;case 7:return new pGc;case 8:return new YGc;default:throw Adb(new agb('No implementation is available for the layerer '+(a.f!=null?a.f:''+a.g)));}} + function tIc(a,b,c,d){var e,f,g,h,i;e=false;f=false;for(h=new Anb(d.j);h.a=b.length){throw Adb(new veb('Greedy SwitchDecider: Free layer not in graph.'))}this.c=b[a];this.e=new DMc(d);rMc(this.e,this.c,(qpd(),ppd));this.i=new DMc(d);rMc(this.i,this.c,Xod);this.f=new Kmc(this.c);this.a=!f&&e.i&&!e.s&&this.c[0].k==(r3b(),m3b);this.a&&Nmc(this,a,b.length);} + function $Mb(a,b){var c,d,e,f,g,h;f=!a.B.Hc((dqd(),Wpd));g=a.B.Hc(Zpd);a.a=new wKb(g,f,a.c);!!a.n&&C2b(a.a.n,a.n);cLb(a.g,(ZJb(),XJb),a.a);if(!b){d=new dLb(1,f,a.c);d.n.a=a.k;Wrb(a.p,(qpd(),Yod),d);e=new dLb(1,f,a.c);e.n.d=a.k;Wrb(a.p,npd,e);h=new dLb(0,f,a.c);h.n.c=a.k;Wrb(a.p,ppd,h);c=new dLb(0,f,a.c);c.n.b=a.k;Wrb(a.p,Xod,c);}} + function zkc(a){var b,c,d;b=RD(mQb(a.d,(yCc(),yAc)),223);switch(b.g){case 2:c=rkc(a);break;case 3:c=(d=new bnb,FDb(CDb(GDb(EDb(EDb(new SDb(null,new Swb(a.d.b,16)),new wlc),new ylc),new Alc),new Kkc),new Clc(d)),d);break;default:throw Adb(new dgb('Compaction not supported for '+b+' edges.'));}ykc(a,c);xgb(new Xkb(a.g),new ilc(a));} + function qYc(a,b){var c,d,e,f,g,h,i;b.Ug('Process directions',1);c=RD(mQb(a,(h_c(),H$c)),88);if(c!=(Cmd(),xmd)){for(e=Sub(a.b,0);e.b!=e.d.c;){d=RD(evb(e),40);h=RD(mQb(d,(q$c(),o$c)),17).a;i=RD(mQb(d,p$c),17).a;switch(c.g){case 4:i*=-1;break;case 1:f=h;h=i;i=f;break;case 2:g=h;h=-i;i=g;}pQb(d,o$c,sgb(h));pQb(d,p$c,sgb(i));}}b.Vg();} + function led(a,b){var c;c=new qQb;!!b&&kQb(c,RD(Wjb(a.a,H4),96));ZD(b,422)&&kQb(c,RD(Wjb(a.a,L4),96));if(ZD(b,366)){kQb(c,RD(Wjb(a.a,I4),96));return c}ZD(b,84)&&kQb(c,RD(Wjb(a.a,E4),96));if(ZD(b,207)){kQb(c,RD(Wjb(a.a,J4),96));return c}if(ZD(b,193)){kQb(c,RD(Wjb(a.a,K4),96));return c}ZD(b,326)&&kQb(c,RD(Wjb(a.a,G4),96));return c} + function a_b(a){var b,c,d,e,f,g,h,i;i=new m_b;for(h=new Anb(a.a);h.a0&&b=0){return false}else {b.p=c.b;Rmb(c.e,b);}if(e==(r3b(),o3b)||e==q3b){for(g=new Anb(b.j);g.aa.d[h.p]){c+=ZLc(a.b,f);hmb(a.a,sgb(f));}}else {++g;}}c+=a.b.d*g;while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function pje(a){var b,c,d,e,f,g;f=0;b=WVd(a);!!b.kk()&&(f|=4);(a.Bb&bKe)!=0&&(f|=2);if(ZD(a,102)){c=RD(a,19);e=Z5d(c);(c.Bb&QHe)!=0&&(f|=32);if(e){AYd(uWd(e));f|=8;g=e.t;(g>1||g==-1)&&(f|=16);(e.Bb&QHe)!=0&&(f|=64);}(c.Bb&txe)!=0&&(f|=cKe);f|=gwe;}else {if(ZD(b,469)){f|=512;}else {d=b.kk();!!d&&(d.i&1)!=0&&(f|=256);}}(a.Bb&512)!=0&&(f|=128);return f} + function vke(a,b){var c;if(a.f==tke){c=yfe(Qee((lke(),jke),b));return a.e?c==4&&b!=(Lle(),Jle)&&b!=(Lle(),Gle)&&b!=(Lle(),Hle)&&b!=(Lle(),Ile):c==2}if(!!a.d&&(a.d.Hc(b)||a.d.Hc(zfe(Qee((lke(),jke),b)))||a.d.Hc(Eee((lke(),jke),a.b,b)))){return true}if(a.f){if(Xee((lke(),a.f),Bfe(Qee(jke,b)))){c=yfe(Qee(jke,b));return a.e?c==4:c==2}}return false} + function oKc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;m=-1;n=0;for(j=a,k=0,l=j.length;k0&&++n;}}}++m;}return n} + function S2c(a,b,c,d){var e,f,g,h,i,j,k,l;g=RD(Gxd(c,(umd(),Qld)),8);i=g.a;k=g.b+a;e=$wnd.Math.atan2(k,i);e<0&&(e+=dFe);e+=b;e>dFe&&(e-=dFe);h=RD(Gxd(d,Qld),8);j=h.a;l=h.b+a;f=$wnd.Math.atan2(l,j);f<0&&(f+=dFe);f+=b;f>dFe&&(f-=dFe);return Zy(),bz(1.0E-10),$wnd.Math.abs(e-f)<=1.0E-10||e==f||isNaN(e)&&isNaN(f)?0:ef?1:cz(isNaN(e),isNaN(f))} + function PGb(a){var b,c,d,e,f,g,h;h=new Tsb;for(d=new Anb(a.a.b);d.a=b.o){throw Adb(new web)}i=c>>5;h=c&31;g=Sdb(1,Ydb(Sdb(h,1)));f?(b.n[d][i]=Rdb(b.n[d][i],g)):(b.n[d][i]=Cdb(b.n[d][i],Qdb(g)));g=Sdb(g,1);e?(b.n[d][i]=Rdb(b.n[d][i],g)):(b.n[d][i]=Cdb(b.n[d][i],Qdb(g)));}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function eMc(a,b,c,d){var e,f,g,h,i,j,k,l,m;m=new yAb(new PMc(a));for(h=cD(WC(jR,1),WAe,10,0,[b,c]),i=0,j=h.length;i0){d=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!d||Zhb(Zhb((b.a+=' "',b),d),'"');}}else {Zhb(Zhb((b.a+=' "',b),c),'"');}Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function OCd(a){var b,c,d;if((a.Db&64)!=0)return Fyd(a);b=new dib(HHe);c=a.k;if(!c){!a.n&&(a.n=new C5d(I4,a,1,7));if(a.n.i>0){d=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!d||Zhb(Zhb((b.a+=' "',b),d),'"');}}else {Zhb(Zhb((b.a+=' "',b),c),'"');}Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function Xnc(a,b){var c,d,e,f,g;b==(TEc(),QEc)&&Eob(RD(Qc(a.a,(Bnc(),xnc)),15));for(e=RD(Qc(a.a,(Bnc(),xnc)),15).Kc();e.Ob();){d=RD(e.Pb(),105);c=RD(Vmb(d.j,0),113).d.j;f=new dnb(d.j);_mb(f,new Boc);switch(b.g){case 2:Pnc(a,f,c,(joc(),hoc),1);break;case 1:case 0:g=Rnc(f);Pnc(a,new Rkb(f,0,g),c,(joc(),hoc),0);Pnc(a,new Rkb(f,g,f.c.length),c,hoc,1);}}} + function sgd(a,b){var c,d,e,f,g,h,i;if(b==null||b.length==0){return null}e=RD(Xjb(a.a,b),143);if(!e){for(d=(h=(new glb(a.b)).a.vc().Kc(),new llb(h));d.a.Ob();){c=(f=RD(d.a.Pb(),44),RD(f.md(),143));g=c.c;i=b.length;if(lhb(g.substr(g.length-i,i),b)&&(b.length==g.length||ihb(g,g.length-b.length-1)==46)){if(e){return null}e=c;}}!!e&&$jb(a.a,b,e);}return e} + function HOb(a,b){var c,d,e,f;c=new MOb;d=RD(zDb(GDb(new SDb(null,new Swb(a.f,16)),c),sBb(new _Bb,new bCb,new yCb,new ACb,cD(WC(QL,1),jwe,108,0,[(xBb(),wBb),vBb]))),21);e=d.gc();d=RD(zDb(GDb(new SDb(null,new Swb(b.f,16)),c),sBb(new _Bb,new bCb,new yCb,new ACb,cD(WC(QL,1),jwe,108,0,[wBb,vBb]))),21);f=d.gc();if(ee.p){Q3b(f,npd);if(f.d){h=f.o.b;b=f.a.b;f.a.b=h-b;}}else if(f.j==npd&&e.p>a.p){Q3b(f,Yod);if(f.d){h=f.o.b;b=f.a.b;f.a.b=-(h-b);}}break}}return e} + function nTb(a,b,c,d,e){var f,g,h,i,j,k,l;if(!(ZD(b,207)||ZD(b,366)||ZD(b,193))){throw Adb(new agb('Method only works for ElkNode-, ElkLabel and ElkPort-objects.'))}g=a.a/2;i=b.i+d-g;k=b.j+e-g;j=i+b.g+a.a;l=k+b.f+a.a;f=new Ejd;Mub(f,new rjd(i,k));Mub(f,new rjd(i,l));Mub(f,new rjd(j,l));Mub(f,new rjd(j,k));h=new ORb(f);kQb(h,b);c&&Zjb(a.b,b,h);return h} + function w$b(a,b,c){var d,e,f,g,h,i,j,k,l,m;f=new rjd(b,c);for(k=new Anb(a.a);k.a1;if(h){d=new rjd(e,c.b);Mub(b.a,d);}zjd(b.a,cD(WC(l3,1),Nve,8,0,[m,l]));} + function aEc(){aEc=geb;$Dc=new bEc(LAe,0);VDc=new bEc('NIKOLOV',1);YDc=new bEc('NIKOLOV_PIXEL',2);WDc=new bEc('NIKOLOV_IMPROVED',3);XDc=new bEc('NIKOLOV_IMPROVED_PIXEL',4);SDc=new bEc('DUMMYNODE_PERCENTAGE',5);ZDc=new bEc('NODECOUNT_PERCENTAGE',6);_Dc=new bEc('NO_BOUNDARY',7);TDc=new bEc('MODEL_ORDER_LEFT_TO_RIGHT',8);UDc=new bEc('MODEL_ORDER_RIGHT_TO_LEFT',9);} + function use(a){var b,c,d,e,f;d=a.length;b=new Rhb;f=0;while(f=40;g&&wJb(a);nJb(a);mJb(a);c=qJb(a);d=0;while(!!c&&d0&&Mub(a.f,f);}else {a.c[g]-=j+1;a.c[g]<=0&&a.a[g]>0&&Mub(a.e,f);}}}}} + function FVc(a,b,c,d){var e,f,g,h,i,j,k;i=new rjd(c,d);ojd(i,RD(mQb(b,(q$c(),SZc)),8));for(k=Sub(b.b,0);k.b!=k.d.c;){j=RD(evb(k),40);$id(j.e,i);Mub(a.b,j);}for(h=RD(zDb(BDb(new SDb(null,new Swb(b.a,16))),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15).Kc();h.Ob();){g=RD(h.Pb(),65);for(f=Sub(g.a,0);f.b!=f.d.c;){e=RD(evb(f),8);e.a+=i.a;e.b+=i.b;}Mub(a.a,g);}} + function kWc(a,b){var c,d,e,f;if(0<(ZD(a,16)?RD(a,16).gc():Kr(a.Kc()))){e=b;if(1=0&&if*2){k=new zrd(l);j=urd(g)/trd(g);i=ird(k,b,new z3b,c,d,e,j);$id(hjd(k.e),i);l.c.length=0;f=0;ZEb(l.c,k);ZEb(l.c,g);f=urd(k)*trd(k)+urd(g)*trd(g);}else {ZEb(l.c,g);f+=urd(g)*trd(g);}}return l} + function O9b(a,b){var c,d,e,f,g,h;h=RD(mQb(b,(yCc(),BBc)),101);if(!(h==(Bod(),xod)||h==wod)){return}e=(new rjd(b.f.a+b.d.b+b.d.c,b.f.b+b.d.d+b.d.a)).b;for(g=new Anb(a.a);g.ac?b:c;j<=l;++j){if(j==c){h=d++;}else {f=e[j];k=o.am(f.Lk());j==b&&(i=j==l&&!k?d-1:d);k&&++d;}}m=RD(uLd(a,b,c),76);h!=i&&eZd(a,new c4d(a.e,7,g,sgb(h),n.md(),i));return m}}}else {return RD(SHd(a,b,c),76)}return RD(uLd(a,b,c),76)} + function ugc(a,b){var c,d,e,f,g,h,i;b.Ug('Port order processing',1);i=RD(mQb(a,(yCc(),HBc)),430);for(d=new Anb(a.b);d.a=0){h=rD(a,g);if(h){j<22?(i.l|=1<>>1;g.m=k>>>1|(l&1)<<21;g.l=m>>>1|(k&1)<<21;--j;}c&&nD(i);if(f){if(d){eD=xD(a);e&&(eD=DD(eD,(MD(),KD)));}else {eD=hD(a.l,a.m,a.h);}}return i} + function rIc(a,b){var c,d,e,f,g,h,i,j,k,l;j=a.e[b.c.p][b.p]+1;i=b.c.a.c.length+1;for(h=new Anb(a.a);h.a0&&(BFb(0,a.length),a.charCodeAt(0)==45||(BFb(0,a.length),a.charCodeAt(0)==43))?1:0;for(d=g;dc){throw Adb(new Vgb(nxe+a+'"'))}return h} + function Jqc(a){var b,c,d,e,f,g,h;g=new Yub;for(f=new Anb(a.a);f.a1)&&b==1&&RD(a.a[a.b],10).k==(r3b(),n3b)){Qdc(RD(a.a[a.b],10),(Pnd(),Lnd));}else if(d&&(!c||(a.c-a.b&a.a.length-1)>1)&&b==1&&RD(a.a[a.c-1&a.a.length-1],10).k==(r3b(),n3b)){Qdc(RD(a.a[a.c-1&a.a.length-1],10),(Pnd(),Mnd));}else if((a.c-a.b&a.a.length-1)==2){Qdc(RD(omb(a),10),(Pnd(),Lnd));Qdc(RD(omb(a),10),Mnd);}else {Ndc(a,e);}jmb(a);} + function QVc(a,b,c){var d,e,f,g,h;f=0;for(e=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));e.e!=e.i.gc();){d=RD(bMd(e),27);g='';(!d.n&&(d.n=new C5d(I4,d,1,7)),d.n).i==0||(g=RD(QHd((!d.n&&(d.n=new C5d(I4,d,1,7)),d.n),0),135).a);h=new bXc(f++,b,g);kQb(h,d);pQb(h,(q$c(),h$c),d);h.e.b=d.j+d.f/2;h.f.a=$wnd.Math.max(d.g,1);h.e.a=d.i+d.g/2;h.f.b=$wnd.Math.max(d.f,1);Mub(b.b,h);rtb(c.f,d,h);}} + function L5b(a){var b,c,d,e,f;d=RD(mQb(a,(Ywc(),Awc)),27);f=RD(Gxd(d,(yCc(),lBc)),181).Hc((Qpd(),Ppd));if(!a.e){e=RD(mQb(a,kwc),21);b=new rjd(a.f.a+a.d.b+a.d.c,a.f.b+a.d.d+a.d.a);if(e.Hc((ovc(),hvc))){Ixd(d,BBc,(Bod(),wod));Esd(d,b.a,b.b,false,true);}else {Heb(TD(Gxd(d,mBc)))||Esd(d,b.a,b.b,true,true);}}f?Ixd(d,lBc,xsb(Ppd)):Ixd(d,lBc,(c=RD(mfb(H3),9),new Fsb(c,RD(WEb(c,c.length),9),0)));} + function JA(a,b,c){var d,e,f,g;if(b[0]>=a.length){c.o=0;return true}switch(ihb(a,b[0])){case 43:e=1;break;case 45:e=-1;break;default:c.o=0;return true;}++b[0];f=b[0];g=HA(a,b);if(g==0&&b[0]==f){return false}if(b[0]h){h=e;k.c.length=0;}e==h&&Rmb(k,new Ptd(c.c.i,c));}yob();_mb(k,a.c);Qmb(a.b,i.p,k);}}} + function kRc(a,b){var c,d,e,f,g,h,i,j,k;for(g=new Anb(b.b);g.ah){h=e;k.c.length=0;}e==h&&Rmb(k,new Ptd(c.d.i,c));}yob();_mb(k,a.c);Qmb(a.f,i.p,k);}}} + function HVc(a,b){var c,d,e,f,g,h,i,j;j=TD(mQb(b,(h_c(),Z$c)));if(j==null||(uFb(j),j)){EVc(a,b);e=new bnb;for(i=Sub(b.b,0);i.b!=i.d.c;){g=RD(evb(i),40);c=DVc(a,g,null);if(c){kQb(c,b);ZEb(e.c,c);}}a.a=null;a.b=null;if(e.c.length>1){for(d=new Anb(e);d.a=0&&h!=c){f=new N3d(a,1,h,g,null);!d?(d=f):d.nj(f);}if(c>=0){f=new N3d(a,1,c,h==c?g:null,b);!d?(d=f):d.nj(f);}}return d} + function jSd(a){var b,c,d;if(a.b==null){d=new Qhb;if(a.i!=null){Nhb(d,a.i);d.a+=':';}if((a.f&256)!=0){if((a.f&256)!=0&&a.a!=null){wSd(a.i)||(d.a+='//',d);Nhb(d,a.a);}if(a.d!=null){d.a+='/';Nhb(d,a.d);}(a.f&16)!=0&&(d.a+='/',d);for(b=0,c=a.j.length;bm){return false}l=(i=S9c(d,m,false),i.a);if(k+h+l<=b.b){Q9c(c,f-c.s);c.c=true;Q9c(d,f-c.s);U9c(d,c.s,c.t+c.d+h);d.k=true;aad(c.q,d);n=true;if(e){Cad(b,d);d.j=b;if(a.c.length>g){Fad((tFb(g,a.c.length),RD(a.c[g],186)),d);(tFb(g,a.c.length),RD(a.c[g],186)).a.c.length==0&&Xmb(a,g);}}}return n} + function Qfc(a,b){var c,d,e,f,g,h;b.Ug('Partition midprocessing',1);e=new Tp;FDb(CDb(new SDb(null,new Swb(a.a,16)),new Ufc),new Wfc(e));if(e.d==0){return}h=RD(zDb(ODb((f=e.i,new SDb(null,(!f?(e.i=new zf(e,e.c)):f).Nc()))),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);d=h.Kc();c=RD(d.Pb(),17);while(d.Ob()){g=RD(d.Pb(),17);Pfc(RD(Qc(e,c),21),RD(Qc(e,g),21));c=g;}b.Vg();} + function G_b(a,b,c){var d,e,f,g,h,i,j,k;if(b.p==0){b.p=1;g=c;if(!g){e=new bnb;f=(d=RD(mfb(E3),9),new Fsb(d,RD(WEb(d,d.length),9),0));g=new Ptd(e,f);}RD(g.a,15).Fc(b);b.k==(r3b(),m3b)&&RD(g.b,21).Fc(RD(mQb(b,(Ywc(),hwc)),64));for(i=new Anb(b.j);i.a0){e=RD(a.Ab.g,2033);if(b==null){for(f=0;fc.s&&hg){return qpd(),Xod}break;case 4:case 3:if(k<0){return qpd(),Yod}else if(k+c>f){return qpd(),npd}}i=(j+h/2)/g;d=(k+c/2)/f;return i+d<=1&&i-d<=0?(qpd(),ppd):i+d>=1&&i-d>=0?(qpd(),Xod):d<0.5?(qpd(),Yod):(qpd(),npd)} + function PNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;c=false;k=Kfb(UD(mQb(b,(yCc(),bCc))));o=pwe*k;for(e=new Anb(b.b);e.ai+o){p=l.g+m.g;m.a=(m.g*m.a+l.g*l.a)/p;m.g=p;l.f=m;c=true;}}f=h;l=m;}}return c} + function MJb(a,b,c,d,e,f,g){var h,i,j,k,l,m;m=new Tid;for(j=b.Kc();j.Ob();){h=RD(j.Pb(),853);for(l=new Anb(h.Rf());l.a0){if(h.a){j=h.b.Mf().b;if(e>j){if(a.v||h.c.d.c.length==1){g=(e-j)/2;h.d.d=g;h.d.a=g;}else {c=RD(Vmb(h.c.d,0),187).Mf().b;d=(c-j)/2;h.d.d=$wnd.Math.max(0,d);h.d.a=e-d-j;}}}else {h.d.a=a.t+e;}}else if(Rod(a.u)){f=wsd(h.b);f.d<0&&(h.d.d=-f.d);f.d+f.a>h.b.Mf().b&&(h.d.a=f.d+f.a-h.b.Mf().b);}}} + function yVb(){yVb=geb;lVb=new mGd((umd(),Rld),sgb(1));rVb=new mGd(fmd,80);qVb=new mGd($ld,5);ZUb=new mGd(Dkd,Yze);mVb=new mGd(Sld,sgb(1));pVb=new mGd(Vld,(Geb(),true));iVb=new A3b(50);hVb=new mGd(tld,iVb);_Ub=ald;jVb=Hld;$Ub=new mGd(Pkd,false);gVb=sld;eVb=mld;fVb=pld;dVb=kld;cVb=ild;kVb=Lld;bVb=(OUb(),HUb);sVb=MUb;aVb=GUb;nVb=JUb;oVb=LUb;vVb=mmd;xVb=qmd;uVb=lmd;tVb=kmd;wVb=(mqd(),jqd);new mGd(nmd,wVb);} + function VC(a,b){var c;switch(XC(a)){case 6:return bE(b);case 7:return _D(b);case 8:return $D(b);case 3:return Array.isArray(b)&&(c=XC(b),!(c>=14&&c<=16));case 11:return b!=null&&typeof b===kve;case 12:return b!=null&&(typeof b===gve||typeof b==kve);case 0:return QD(b,a.__elementTypeId$);case 2:return cE(b)&&!(b.Tm===keb);case 1:return cE(b)&&!(b.Tm===keb)||QD(b,a.__elementTypeId$);default:return true;}} + function gNb(a){var b,c,d,e;d=a.o;RMb();if(a.A.dc()||pb(a.A,QMb)){e=d.a;}else {a.D?(e=$wnd.Math.max(d.a,ZKb(a.f))):(e=ZKb(a.f));if(a.A.Hc((Qpd(),Npd))&&!a.B.Hc((dqd(),_pd))){e=$wnd.Math.max(e,ZKb(RD(Vrb(a.p,(qpd(),Yod)),252)));e=$wnd.Math.max(e,ZKb(RD(Vrb(a.p,npd),252)));}b=TMb(a);!!b&&(e=$wnd.Math.max(e,b.a));}Heb(TD(a.e.Tf().of((umd(),mld))))?(d.a=$wnd.Math.max(d.a,e)):(d.a=e);c=a.f.i;c.c=0;c.b=e;$Kb(a.f);} + function oRb(a,b){var c,d,e,f;d=$wnd.Math.min($wnd.Math.abs(a.c-(b.c+b.b)),$wnd.Math.abs(a.c+a.b-b.c));f=$wnd.Math.min($wnd.Math.abs(a.d-(b.d+b.a)),$wnd.Math.abs(a.d+a.a-b.d));c=$wnd.Math.abs(a.c+a.b/2-(b.c+b.b/2));if(c>a.b/2+b.b/2){return 1}e=$wnd.Math.abs(a.d+a.a/2-(b.d+b.a/2));if(e>a.a/2+b.a/2){return 1}if(c==0&&e==0){return 0}if(c==0){return f/e+1}if(e==0){return d/c+1}return $wnd.Math.min(d/c,f/e)+1} + function oWb(a,b){var c,d,e,f,g,h,i;f=0;h=0;i=0;for(e=new Anb(a.f.e);e.a0&&a.d!=(AWb(),zWb)&&(h+=g*(d.d.a+a.a[b.a][d.a]*(b.d.a-d.d.a)/c));c>0&&a.d!=(AWb(),xWb)&&(i+=g*(d.d.b+a.a[b.a][d.a]*(b.d.b-d.d.b)/c));}switch(a.d.g){case 1:return new rjd(h/f,b.d.b);case 2:return new rjd(b.d.a,i/f);default:return new rjd(h/f,i/f);}} + function xsd(a){var b,c,d,e,f,g;c=(!a.a&&(a.a=new XZd(D4,a,5)),a.a).i+2;g=new cnb(c);Rmb(g,new rjd(a.j,a.k));FDb(new SDb(null,(!a.a&&(a.a=new XZd(D4,a,5)),new Swb(a.a,16))),new Usd(g));Rmb(g,new rjd(a.b,a.c));b=1;while(b0){aHb(i,false,(Cmd(),ymd));aHb(i,true,zmd);}Umb(b.g,new Elc(a,c));Zjb(a.g,b,c);} + function Ugb(){Ugb=geb;var a;Qgb=cD(WC(kE,1),Pwe,28,15,[-1,-1,30,19,15,13,11,11,10,9,9,8,8,8,8,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5]);Rgb=$C(kE,Pwe,28,37,15,1);Sgb=cD(WC(kE,1),Pwe,28,15,[-1,-1,63,40,32,28,25,23,21,20,19,19,18,18,17,17,16,16,16,15,15,15,15,14,14,14,14,14,14,13,13,13,13,13,13,13,13]);Tgb=$C(lE,rxe,28,37,14,1);for(a=2;a<=36;a++){Rgb[a]=eE($wnd.Math.pow(a,Qgb[a]));Tgb[a]=Fdb(Sve,Rgb[a]);}} + function tsd(a){var b;if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i!=1){throw Adb(new agb(tHe+(!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i))}b=new Ejd;!!BGd(RD(QHd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b),0),84))&&ye(b,usd(a,BGd(RD(QHd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b),0),84)),false));!!BGd(RD(QHd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c),0),84))&&ye(b,usd(a,BGd(RD(QHd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c),0),84)),true));return b} + function zRc(a,b){var c,d,e,f,g;b.d?(e=a.a.c==(wQc(),vQc)?Z2b(b.b):a3b(b.b)):(e=a.a.c==(wQc(),uQc)?Z2b(b.b):a3b(b.b));f=false;for(d=new is(Mr(e.a.Kc(),new ir));gs(d);){c=RD(hs(d),18);g=Heb(a.a.f[a.a.g[b.b.p].p]);if(!g&&!W0b(c)&&c.c.i.c==c.d.i.c){continue}if(Heb(a.a.n[a.a.g[b.b.p].p])||Heb(a.a.n[a.a.g[b.b.p].p])){continue}f=true;if(Zsb(a.b,a.a.g[rRc(c,b.b).p])){b.c=true;b.a=c;return b}}b.c=f;b.a=null;return b} + function QJd(a,b,c){var d,e,f,g,h,i,j;d=c.gc();if(d==0){return false}else {if(a.Pj()){i=a.Qj();ZId(a,b,c);g=d==1?a.Ij(3,null,c.Kc().Pb(),b,i):a.Ij(5,null,c,b,i);if(a.Mj()){h=d<100?null:new gLd(d);f=b+d;for(e=b;e0){for(g=0;g>16==-15&&a.Cb.Yh()&&pKd(new O3d(a.Cb,9,13,c,a.c,fZd(o4d(RD(a.Cb,62)),a)));}else if(ZD(a.Cb,90)){if(a.Db>>16==-23&&a.Cb.Yh()){b=a.c;ZD(b,90)||(b=(JTd(),zTd));ZD(c,90)||(c=(JTd(),zTd));pKd(new O3d(a.Cb,9,10,c,b,fZd(tYd(RD(a.Cb,29)),a)));}}}}return a.c} + function lac(a,b,c){var d,e,f,g,h,i,j,k,l;c.Ug('Hyperedge merging',1);jac(a,b);i=new Jkb(b.b,0);while(i.b0;h=oIb(b,f);c?FIb(h.b,b):FIb(h.g,b);CIb(h).c.length==1&&(Pub(d,h,d.c.b,d.c),true);e=new Ptd(f,b);hmb(a.o,e);Ymb(a.e.a,f);}} + function SQb(a,b){var c,d,e,f,g,h,i;d=$wnd.Math.abs(Oid(a.b).a-Oid(b.b).a);h=$wnd.Math.abs(Oid(a.b).b-Oid(b.b).b);e=0;i=0;c=1;g=1;if(d>a.b.b/2+b.b.b/2){e=$wnd.Math.min($wnd.Math.abs(a.b.c-(b.b.c+b.b.b)),$wnd.Math.abs(a.b.c+a.b.b-b.b.c));c=1-e/d;}if(h>a.b.a/2+b.b.a/2){i=$wnd.Math.min($wnd.Math.abs(a.b.d-(b.b.d+b.b.a)),$wnd.Math.abs(a.b.d+a.b.a-b.b.d));g=1-i/h;}f=$wnd.Math.min(c,g);return (1-f)*$wnd.Math.sqrt(d*d+h*h)} + function LUc(a){var b,c,d,e;NUc(a,a.e,a.f,(dVc(),bVc),true,a.c,a.i);NUc(a,a.e,a.f,bVc,false,a.c,a.i);NUc(a,a.e,a.f,cVc,true,a.c,a.i);NUc(a,a.e,a.f,cVc,false,a.c,a.i);MUc(a,a.c,a.e,a.f,a.i);d=new Jkb(a.i,0);while(d.b=65;c--){xqe[c]=c-65<<24>>24;}for(d=122;d>=97;d--){xqe[d]=d-97+26<<24>>24;}for(e=57;e>=48;e--){xqe[e]=e-48+52<<24>>24;}xqe[43]=62;xqe[47]=63;for(f=0;f<=25;f++)yqe[f]=65+f&Bwe;for(g=26,i=0;g<=51;++g,i++)yqe[g]=97+i&Bwe;for(a=52,h=0;a<=61;++a,h++)yqe[a]=48+h&Bwe;yqe[62]=43;yqe[63]=47;} + function uib(a,b){var c,d,e,f,g,h;e=xib(a);h=xib(b);if(e==h){if(a.e==b.e&&a.a<54&&b.a<54){return a.fb.f?1:0}d=a.e-b.e;c=(a.d>0?a.d:$wnd.Math.floor((a.a-1)*xxe)+1)-(b.d>0?b.d:$wnd.Math.floor((b.a-1)*xxe)+1);if(c>d+1){return e}else if(c0&&(g=Wib(g,Sjb(d)));return Qib(f,g)}}else return ej){m=0;n+=i+b;i=0;}w$b(g,m,n);c=$wnd.Math.max(c,m+k.a);i=$wnd.Math.max(i,k.b);m+=k.a+b;}return new rjd(c+b,n+i+b)} + function osd(a,b){var c,d,e,f,g,h,i;if(!MCd(a)){throw Adb(new dgb(sHe))}d=MCd(a);f=d.g;e=d.f;if(f<=0&&e<=0){return qpd(),opd}h=a.i;i=a.j;switch(b.g){case 2:case 1:if(h<0){return qpd(),ppd}else if(h+a.g>f){return qpd(),Xod}break;case 4:case 3:if(i<0){return qpd(),Yod}else if(i+a.f>e){return qpd(),npd}}g=(h+a.g/2)/f;c=(i+a.f/2)/e;return g+c<=1&&g-c<=0?(qpd(),ppd):g+c>=1&&g-c>=0?(qpd(),Xod):c<0.5?(qpd(),Yod):(qpd(),npd)} + function Djb(a,b,c,d,e){var f,g;f=Bdb(Cdb(b[0],yxe),Cdb(d[0],yxe));a[0]=Ydb(f);f=Tdb(f,32);if(c>=e){for(g=1;g0){e.b[g++]=0;e.b[g++]=f.b[0]-1;}for(b=1;b0){PSc(i,i.d-e.d);e.c==(fTc(),dTc)&&NSc(i,i.a-e.d);i.d<=0&&i.i>0&&(Pub(b,i,b.c.b,b.c),true);}}}for(f=new Anb(a.f);f.a0){QSc(h,h.i-e.d);e.c==(fTc(),dTc)&&OSc(h,h.b-e.d);h.i<=0&&h.d>0&&(Pub(c,h,c.c.b,c.c),true);}}}} + function drd(a,b,c,d,e){var f,g,h,i,j,k,l,m,n;yob();_mb(a,new Mrd);g=gv(a);n=new bnb;m=new bnb;h=null;i=0;while(g.b!=0){f=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),163);if(!h||urd(h)*trd(h)/21&&(i>urd(h)*trd(h)/2||g.b==0)){l=new zrd(m);k=urd(h)/trd(h);j=ird(l,b,new z3b,c,d,e,k);$id(hjd(l.e),j);h=l;ZEb(n.c,l);i=0;m.c.length=0;}}}Tmb(n,m);return n} + function hib(a,b,c,d,e){gib();var f,g,h,i,j,k,l;vFb(a,'src');vFb(c,'dest');l=rb(a);i=rb(c);qFb((l.i&4)!=0,'srcType is not an array');qFb((i.i&4)!=0,'destType is not an array');k=l.c;g=i.c;qFb((k.i&1)!=0?k==g:(g.i&1)==0,"Array types don't match");iib(a,b,c,d,e);if((k.i&1)==0&&l!=i){j=SD(a);f=SD(c);if(dE(a)===dE(c)&&bd;){bD(f,h,j[--b]);}}else {for(h=d+e;d0);d.a.Xb(d.c=--d.b);l>m+i&&Ckb(d);}for(g=new Anb(n);g.a0);d.a.Xb(d.c=--d.b);}}}} + function gte(){Vse();var a,b,c,d,e,f;if(Fse)return Fse;a=(new xte(4));ute(a,hte(WLe,true));wte(a,hte('M',true));wte(a,hte('C',true));f=(new xte(4));for(d=0;d<11;d++){rte(f,d,d);}b=(new xte(4));ute(b,hte('M',true));rte(b,4448,4607);rte(b,65438,65439);e=(new iue(2));hue(e,a);hue(e,Ese);c=(new iue(2));c.Jm($se(f,hte('L',true)));c.Jm(b);c=(new Kte(3,c));c=(new Qte(e,c));Fse=c;return Fse} + function vhb(a,b){var c,d,e,f,g,h,i,j;c=new RegExp(b,'g');i=$C(qJ,Nve,2,0,6,1);d=0;j=a;f=null;while(true){h=c.exec(j);if(h==null||j==''){i[d]=j;break}else {g=h.index;i[d]=(AFb(0,g,j.length),j.substr(0,g));j=zhb(j,g+h[0].length,j.length);c.lastIndex=0;if(f==j){i[d]=(AFb(0,1,j.length),j.substr(0,1));j=(BFb(1,j.length+1),j.substr(1));}f=j;++d;}}if(a.length>0){e=i.length;while(e>0&&i[e-1]==''){--e;}e0){l-=d[0]+a.c;d[0]+=a.c;}d[2]>0&&(l-=d[2]+a.c);d[1]=$wnd.Math.max(d[1],l);dKb(a.a[1],c.c+b.b+d[0]-(d[1]-l)/2,d[1]);}for(f=a.a,h=0,j=f.length;h0?(a.n.c.length-1)*a.i:0;for(d=new Anb(a.n);d.a1){for(d=Sub(e,0);d.b!=d.d.c;){c=RD(evb(d),235);f=0;for(i=new Anb(c.e);i.a0){b[0]+=a.c;l-=b[0];}b[2]>0&&(l-=b[2]+a.c);b[1]=$wnd.Math.max(b[1],l);eKb(a.a[1],d.d+c.d+b[0]-(b[1]-l)/2,b[1]);}else {o=d.d+c.d;n=d.a-c.d-c.a;for(g=a.a,i=0,k=g.length;i0||$y(e.b.d,a.b.d+a.b.a)==0&&d.b<0||$y(e.b.d+e.b.a,a.b.d)==0&&d.b>0){h=0;break}}else {h=$wnd.Math.min(h,PQb(a,e,d));}h=$wnd.Math.min(h,FQb(a,f,h,d));}return h} + function lsd(a,b){var c,d,e,f,g,h,i;if(a.b<2){throw Adb(new agb('The vector chain must contain at least a source and a target point.'))}e=(sFb(a.b!=0),RD(a.a.a.c,8));Nzd(b,e.a,e.b);i=new mMd((!b.a&&(b.a=new XZd(D4,b,5)),b.a));g=Sub(a,1);while(g.a=0&&f!=c){throw Adb(new agb(LIe))}}e=0;for(i=0;iKfb(pJc(g.g,g.d[0]).a)){sFb(i.b>0);i.a.Xb(i.c=--i.b);Ikb(i,g);e=true;}else if(!!h.e&&h.e.gc()>0){f=(!h.e&&(h.e=new bnb),h.e).Mc(b);j=(!h.e&&(h.e=new bnb),h.e).Mc(c);if(f||j){(!h.e&&(h.e=new bnb),h.e).Fc(g);++g.c;}}}e||(ZEb(d.c,g),true);} + function H3c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;l=a.a.i+a.a.g/2;m=a.a.i+a.a.g/2;o=b.i+b.g/2;q=b.j+b.f/2;h=new rjd(o,q);j=RD(Gxd(b,(umd(),Qld)),8);j.a=j.a+l;j.b=j.b+m;f=(h.b-j.b)/(h.a-j.a);d=h.b-f*h.a;p=c.i+c.g/2;r=c.j+c.f/2;i=new rjd(p,r);k=RD(Gxd(c,Qld),8);k.a=k.a+l;k.b=k.b+m;g=(i.b-k.b)/(i.a-k.a);e=i.b-g*i.a;n=(d-e)/(g-f);if(j.a>>0,'0'+b.toString(16));d='\\x'+zhb(c,c.length-2,c.length);}else if(a>=txe){c=(b=a>>>0,'0'+b.toString(16));d='\\v'+zhb(c,c.length-6,c.length);}else d=''+String.fromCharCode(a&Bwe);}return d} + function Ugc(a){var b,c,d;if(Dod(RD(mQb(a,(yCc(),BBc)),101))){for(c=new Anb(a.j);c.a=b.o&&c.f<=b.f||b.a*0.5<=c.f&&b.a*1.5>=c.f){g=RD(Vmb(b.n,b.n.c.length-1),209);if(g.e+g.d+c.g+e<=d&&(f=RD(Vmb(b.n,b.n.c.length-1),209),f.f-a.f+c.f<=a.b||a.a.c.length==1)){K9c(b,c);return true}else if(b.s+c.g<=d&&(b.t+b.d+c.f+e<=a.b||a.a.c.length==1)){Rmb(b.b,c);h=RD(Vmb(b.n,b.n.c.length-1),209);Rmb(b.n,new _9c(b.s,h.f+h.a+b.i,b.i));W9c(RD(Vmb(b.n,b.n.c.length-1),209),c);M9c(b,c);return true}}return false} + function xLd(a,b,c){var d,e,f,g;if(a.Pj()){e=null;f=a.Qj();d=a.Ij(1,g=UHd(a,b,c),c,b,f);if(a.Mj()&&!(a.Yi()&&g!=null?pb(g,c):dE(g)===dE(c))){g!=null&&(e=a.Oj(g,e));e=a.Nj(c,e);a.Tj()&&(e=a.Wj(g,c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Tj()&&(e=a.Wj(g,c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}return g}else {g=UHd(a,b,c);if(a.Mj()&&!(a.Yi()&&g!=null?pb(g,c):dE(g)===dE(c))){e=null;g!=null&&(e=a.Oj(g,null));e=a.Nj(c,e);!!e&&e.oj();}return g}} + function Rsc(a,b){var c,d,e,f,g;b.Ug('Path-Like Graph Wrapping',1);if(a.b.c.length==0){b.Vg();return}e=new ysc(a);g=(e.i==null&&(e.i=tsc(e,new Asc)),Kfb(e.i)*e.f);c=g/(e.i==null&&(e.i=tsc(e,new Asc)),Kfb(e.i));if(e.b>c){b.Vg();return}switch(RD(mQb(a,(yCc(),rCc)),351).g){case 2:f=new Ksc;break;case 0:f=new zrc;break;default:f=new Nsc;}d=f.og(a,e);if(!f.pg()){switch(RD(mQb(a,xCc),352).g){case 2:d=Wsc(e,d);break;case 1:d=Usc(e,d);}}Qsc(a,e,d);b.Vg();} + function mB(a,b){var c,d,e,f,g,h,i,j;b%=24;if(a.q.getHours()!=b){d=new $wnd.Date(a.q.getTime());d.setDate(d.getDate()+1);h=a.q.getTimezoneOffset()-d.getTimezoneOffset();if(h>0){i=h/60|0;j=h%60;e=a.q.getDate();c=a.q.getHours();c+i>=24&&++e;f=new $wnd.Date(a.q.getFullYear(),a.q.getMonth(),e,b+i,a.q.getMinutes()+j,a.q.getSeconds(),a.q.getMilliseconds());a.q.setTime(f.getTime());}}g=a.q.getTime();a.q.setTime(g+3600000);a.q.getHours()!=b&&a.q.setTime(g);} + function kKc(a,b){var c,d,e,f;Nwb(a.d,a.e);a.c.a.$b();if(Kfb(UD(mQb(b.j,(yCc(),Zzc))))!=0||Kfb(UD(mQb(b.j,Zzc)))!=0){c=Hze;dE(mQb(b.j,cAc))!==dE((kEc(),hEc))&&pQb(b.j,(Ywc(),jwc),(Geb(),true));f=RD(mQb(b.j,gCc),17).a;for(e=0;ee&&++j;Rmb(g,(tFb(h+j,b.c.length),RD(b.c[h+j],17)));i+=(tFb(h+j,b.c.length),RD(b.c[h+j],17)).a-d;++c;while(c=q&&a.e[i.p]>o*a.b||t>=c*q){ZEb(m.c,h);h=new bnb;ye(g,f);f.a.$b();j-=k;n=$wnd.Math.max(n,j*a.b+p);j+=t;s=t;t=0;k=0;p=0;}}return new Ptd(n,m)} + function pYd(a){var b,c,d,e,f,g,h;if(!a.d){h=new v_d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(zYd(a));d.e!=d.i.gc();){c=RD(bMd(d),29);YGd(h,pYd(c));}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}g=h.i;for(e=(!a.q&&(a.q=new C5d(s7,a,11,10)),new dMd(a.q));e.e!=e.i.gc();++g){RD(bMd(e),411);}YGd(h,(!a.q&&(a.q=new C5d(s7,a,11,10)),a.q));VHd(h);a.d=new N$d((RD(QHd(xYd((lTd(),kTd).o),9),19),h.i),h.g);a.e=RD(h.g,688);a.e==null&&(a.e=jYd);yYd(a).b&=-17;}return a.d} + function kge(a,b,c,d){var e,f,g,h,i,j;j=pke(a.e.Dh(),b);i=0;e=RD(a.g,124);nke();if(RD(b,69).xk()){for(g=0;g1||o==-1){l=RD(p,71);m=RD(k,71);if(l.dc()){m.$b();}else {g=!!Z5d(b);f=0;for(h=a.a?l.Kc():l.Ii();h.Ob();){j=RD(h.Pb(),58);e=RD(cub(a,j),58);if(!e){if(a.b&&!g){m.Gi(f,j);++f;}}else {if(g){i=m.dd(e);i==-1?m.Gi(f,e):f!=i&&m.Ui(f,e);}else {m.Gi(f,e);}++f;}}}}else {if(p==null){k.Wb(null);}else {e=cub(a,p);e==null?a.b&&!Z5d(b)&&k.Wb(p):k.Wb(e);}}}}} + function V9b(a,b){var c,d,e,f,g,h,i,j;c=new aac;for(e=new is(Mr(Z2b(b).a.Kc(),new ir));gs(e);){d=RD(hs(e),18);if(W0b(d)){continue}h=d.c.i;if(W9b(h,T9b)){j=X9b(a,h,T9b,S9b);if(j==-1){continue}c.b=$wnd.Math.max(c.b,j);!c.a&&(c.a=new bnb);Rmb(c.a,h);}}for(g=new is(Mr(a3b(b).a.Kc(),new ir));gs(g);){f=RD(hs(g),18);if(W0b(f)){continue}i=f.d.i;if(W9b(i,S9b)){j=X9b(a,i,S9b,T9b);if(j==-1){continue}c.d=$wnd.Math.max(c.d,j);!c.c&&(c.c=new bnb);Rmb(c.c,i);}}return c} + function pcc(a,b,c,d){var e,f,g,h,i,j,k;if(c.d.i==b.i){return}e=new j3b(a);h3b(e,(r3b(),o3b));pQb(e,(Ywc(),Awc),c);pQb(e,(yCc(),BBc),(Bod(),wod));ZEb(d.c,e);g=new R3b;P3b(g,e);Q3b(g,(qpd(),ppd));h=new R3b;P3b(h,e);Q3b(h,Xod);k=c.d;Z0b(c,g);f=new a1b;kQb(f,c);pQb(f,RAc,null);Y0b(f,h);Z0b(f,k);j=new Jkb(c.b,0);while(j.b1000000){throw Adb(new teb('power of ten too big'))}if(a<=lve){return Zib(Yib(Jjb[1],b),b)}d=Yib(Jjb[1],lve);e=d;c=Hdb(a-lve);b=eE(a%lve);while(Ddb(c,lve)>0){e=Wib(e,d);c=Vdb(c,lve);}e=Wib(e,Yib(Jjb[1],b));e=Zib(e,lve);c=Hdb(a-lve);while(Ddb(c,lve)>0){e=Zib(e,lve);c=Vdb(c,lve);}e=Zib(e,b);return e} + function s9b(a){var b,c,d,e,f,g,h,i,j,k;for(i=new Anb(a.a);i.aj&&d>j){k=h;j=Kfb(b.p[h.p])+Kfb(b.d[h.p])+h.o.b+h.d.a;}else {e=false;c._g()&&c.bh('bk node placement breaks on '+h+' which should have been after '+k);break}}if(!e){break}}c._g()&&c.bh(b+' is feasible: '+e);return e} + function Dfc(a,b,c,d){var e,f,g,h,i,j,k,l,m;f=new j3b(a);h3b(f,(r3b(),q3b));pQb(f,(yCc(),BBc),(Bod(),wod));e=0;if(b){g=new R3b;pQb(g,(Ywc(),Awc),b);pQb(f,Awc,b.i);Q3b(g,(qpd(),ppd));P3b(g,f);m=s2b(b.e);for(j=m,k=0,l=j.length;k0){if(e<0&&k.a){e=i;f=j[0];d=0;}if(e>=0){h=k.b;if(i==e){h-=d++;if(h==0){return 0}}if(!MA(b,j,k,h,g)){i=e-1;j[0]=f;continue}}else {e=-1;if(!MA(b,j,k,0,g)){return 0}}}else {e=-1;if(ihb(k.c,0)==32){l=j[0];KA(b,j);if(j[0]>l){continue}}else if(xhb(b,k.c,j[0])){j[0]+=k.c.length;continue}return 0}}if(!CB(g,c)){return 0}return j[0]} + function qWb(a,b,c){var d,e,f,g,h,i,j,k,l,m;k=new pwb(new GWb(c));h=$C(xdb,Hye,28,a.f.e.c.length,16,1);Snb(h,h.length);c[b.a]=0;for(j=new Anb(a.f.e);j.a=0&&!PPb(a,k,l)){--l;}e[k]=l;}for(n=0;n=0&&!PPb(a,h,o)){--h;}f[o]=h;}for(i=0;ib[m]&&md[i]&&TPb(a,i,m,false,true);}}} + function hUb(a){var b,c,d,e,f,g,h,i;c=Heb(TD(mQb(a,(yVb(),$Ub))));f=a.a.c.d;h=a.a.d.d;if(c){g=ijd(ojd(new rjd(h.a,h.b),f),0.5);i=ijd(ajd(a.e),0.5);b=ojd($id(new rjd(f.a,f.b),g),i);mjd(a.d,b);}else {e=Kfb(UD(mQb(a.a,qVb)));d=a.d;if(f.a>=h.a){if(f.b>=h.b){d.a=h.a+(f.a-h.a)/2+e;d.b=h.b+(f.b-h.b)/2-e-a.e.b;}else {d.a=h.a+(f.a-h.a)/2+e;d.b=f.b+(h.b-f.b)/2+e;}}else {if(f.b>=h.b){d.a=f.a+(h.a-f.a)/2+e;d.b=h.b+(f.b-h.b)/2+e;}else {d.a=f.a+(h.a-f.a)/2+e;d.b=f.b+(h.b-f.b)/2-e-a.e.b;}}}} + function qYd(a){var b,c,d,e,f,g,h,i;if(!a.f){i=new a_d;h=new a_d;b=iYd;g=b.a.zc(a,b);if(g==null){for(f=new dMd(zYd(a));f.e!=f.i.gc();){e=RD(bMd(f),29);YGd(i,qYd(e));}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}for(d=(!a.s&&(a.s=new C5d(y7,a,21,17)),new dMd(a.s));d.e!=d.i.gc();){c=RD(bMd(d),179);ZD(c,102)&&WGd(h,RD(c,19));}VHd(h);a.r=new s_d(a,(RD(QHd(xYd((lTd(),kTd).o),6),19),h.i),h.g);YGd(i,a.r);VHd(i);a.f=new N$d((RD(QHd(xYd(kTd.o),5),19),i.i),i.g);yYd(a).b&=-3;}return a.f} + function uSb(a){Cgd(a,new Pfd($fd(Xfd(Zfd(Yfd(new agd,Aze),'ELK DisCo'),'Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out.'),new xSb)));Agd(a,Aze,Bze,iGd(sSb));Agd(a,Aze,Cze,iGd(mSb));Agd(a,Aze,Dze,iGd(hSb));Agd(a,Aze,Eze,iGd(nSb));Agd(a,Aze,Bye,iGd(qSb));Agd(a,Aze,Cye,iGd(pSb));Agd(a,Aze,Aye,iGd(rSb));Agd(a,Aze,Dye,iGd(oSb));Agd(a,Aze,vze,iGd(jSb));Agd(a,Aze,wze,iGd(iSb));Agd(a,Aze,xze,iGd(kSb));Agd(a,Aze,yze,iGd(lSb));} + function qAd(){qAd=geb;oAd=cD(WC(hE,1),zwe,28,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]);pAd=new RegExp('[ \t\n\r\f]+');try{nAd=cD(WC(h8,1),rve,2114,0,[new c2d((WA(),YA("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",_A(($A(),$A(),ZA))))),new c2d(YA("yyyy-MM-dd'T'HH:mm:ss'.'SSS",_A((null,ZA)))),new c2d(YA("yyyy-MM-dd'T'HH:mm:ss",_A((null,ZA)))),new c2d(YA("yyyy-MM-dd'T'HH:mm",_A((null,ZA)))),new c2d(YA('yyyy-MM-dd',_A((null,ZA))))]);}catch(a){a=zdb(a);if(!ZD(a,82))throw Adb(a)}} + function uKc(a,b){var c,d,e,f;e=Kwb(a.d,1)!=0;d=mKc(a,b);if(d==0&&Heb(TD(mQb(b.j,(Ywc(),jwc))))){return 0}!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,Owc)))||dE(mQb(b.j,(yCc(),cAc)))===dE((kEc(),hEc))?b.c.mg(b.e,e):(e=Heb(TD(mQb(b.j,jwc))));DKc(a,b,e,true);Heb(TD(mQb(b.j,Owc)))&&pQb(b.j,Owc,(Geb(),false));if(Heb(TD(mQb(b.j,jwc)))){pQb(b.j,jwc,(Geb(),false));pQb(b.j,Owc,true);}c=mKc(a,b);do{yKc(a);if(c==0){return 0}e=!e;f=c;DKc(a,b,e,false);c=mKc(a,b);}while(f>c);return f} + function vKc(a,b){var c,d,e,f;e=Kwb(a.d,1)!=0;d=lKc(a,b);if(d==0&&Heb(TD(mQb(b.j,(Ywc(),jwc))))){return 0}!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,Owc)))||dE(mQb(b.j,(yCc(),cAc)))===dE((kEc(),hEc))?b.c.mg(b.e,e):(e=Heb(TD(mQb(b.j,jwc))));DKc(a,b,e,true);Heb(TD(mQb(b.j,Owc)))&&pQb(b.j,Owc,(Geb(),false));if(Heb(TD(mQb(b.j,jwc)))){pQb(b.j,jwc,(Geb(),false));pQb(b.j,Owc,true);}c=lKc(a,b);do{yKc(a);if(c==0){return 0}e=!e;f=c;DKc(a,b,e,false);c=lKc(a,b);}while(f>c);return f} + function Gid(a,b,c,d){var e,f,g,h,i,j,k,l,m;i=ojd(new rjd(c.a,c.b),a);j=i.a*b.b-i.b*b.a;k=b.a*d.b-b.b*d.a;l=(i.a*d.b-i.b*d.a)/k;m=j/k;if(k==0){if(j==0){e=$id(new rjd(c.a,c.b),ijd(new rjd(d.a,d.b),0.5));f=bjd(a,e);g=bjd($id(new rjd(a.a,a.b),b),e);h=$wnd.Math.sqrt(d.a*d.a+d.b*d.b)*0.5;if(f=0&&l<=1&&m>=0&&m<=1?$id(new rjd(a.a,a.b),ijd(new rjd(b.a,b.b),l)):null}} + function QWb(a,b,c){var d,e,f,g,h;d=RD(mQb(a,(yCc(),dAc)),21);c.a>b.a&&(d.Hc((ukd(),okd))?(a.c.a+=(c.a-b.a)/2):d.Hc(qkd)&&(a.c.a+=c.a-b.a));c.b>b.b&&(d.Hc((ukd(),skd))?(a.c.b+=(c.b-b.b)/2):d.Hc(rkd)&&(a.c.b+=c.b-b.b));if(RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),hvc))&&(c.a>b.a||c.b>b.b)){for(h=new Anb(a.a);h.ab.a&&(d.Hc((ukd(),okd))?(a.c.a+=(c.a-b.a)/2):d.Hc(qkd)&&(a.c.a+=c.a-b.a));c.b>b.b&&(d.Hc((ukd(),skd))?(a.c.b+=(c.b-b.b)/2):d.Hc(rkd)&&(a.c.b+=c.b-b.b));if(RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),hvc))&&(c.a>b.a||c.b>b.b)){for(g=new Anb(a.a);g.a0?a.i:0)>b&&i>0){f=0;g+=i+a.i;e=$wnd.Math.max(e,m);d+=i+a.i;i=0;m=0;if(c){++l;Rmb(a.n,new _9c(a.s,g,a.i));}h=0;}m+=j.g+(h>0?a.i:0);i=$wnd.Math.max(i,j.f);c&&W9c(RD(Vmb(a.n,l),209),j);f+=j.g+(h>0?a.i:0);++h;}e=$wnd.Math.max(e,m);d+=i;if(c){a.r=e;a.d=d;Ead(a.j);}return new Uid(a.s,a.t,e,d)} + function CRb(a){var b,c,d,e,f,g,h,i,j,k,l,m;a.b=false;l=oxe;i=pxe;m=oxe;j=pxe;for(d=a.e.a.ec().Kc();d.Ob();){c=RD(d.Pb(),272);e=c.a;l=$wnd.Math.min(l,e.c);i=$wnd.Math.max(i,e.c+e.b);m=$wnd.Math.min(m,e.d);j=$wnd.Math.max(j,e.d+e.a);for(g=new Anb(c.c);g.aa.o.a){k=(i-a.o.a)/2;h.b=$wnd.Math.max(h.b,k);h.c=$wnd.Math.max(h.c,k);}} + function RId(a){var b,c,d,e,f,g,h,i;f=new med;ied(f,(hed(),eed));for(d=(e=oC(a,$C(qJ,Nve,2,0,6,1)),new Dkb(new mob((new CC(a,e)).b)));d.bh?1:-1:Ejb(a.a,b.a,f);if(e==-1){l=-i;k=g==i?Hjb(b.a,h,a.a,f):Cjb(b.a,h,a.a,f);}else {l=g;if(g==i){if(e==0){return Pib(),Oib}k=Hjb(a.a,f,b.a,h);}else {k=Cjb(a.a,f,b.a,h);}}j=new cjb(l,k.length,k);Rib(j);return j} + function c5b(a,b){var c,d,e,f;f=Z4b(b);!b.c&&(b.c=new C5d(K4,b,9,9));FDb(new SDb(null,(!b.c&&(b.c=new C5d(K4,b,9,9)),new Swb(b.c,16))),new s5b(f));e=RD(mQb(f,(Ywc(),kwc)),21);Y4b(b,e);if(e.Hc((ovc(),hvc))){for(d=new dMd((!b.c&&(b.c=new C5d(K4,b,9,9)),b.c));d.e!=d.i.gc();){c=RD(bMd(d),123);g5b(a,b,f,c);}}RD(Gxd(b,(yCc(),lBc)),181).gc()!=0&&V4b(b,f);Heb(TD(mQb(f,sBc)))&&e.Fc(mvc);nQb(f,PBc)&&HCc(new RCc(Kfb(UD(mQb(f,PBc)))),f);dE(Gxd(b,IAc))===dE((Fnd(),Cnd))?d5b(a,b,f):b5b(a,b,f);return f} + function Vrc(a){var b,c,d,e,f,g,h,i;for(e=new Anb(a.b);e.a0?zhb(c.a,0,f-1):''}}else {return !c?a:c.a}} + function xic(a,b){var c,d,e,f,g,h,i;b.Ug('Sort By Input Model '+mQb(a,(yCc(),cAc)),1);e=0;for(d=new Anb(a.b);d.a=a.b.length){f[e++]=g.b[d++];f[e++]=g.b[d++];}else if(d>=g.b.length){f[e++]=a.b[c++];f[e++]=a.b[c++];}else if(g.b[d]0?a.i:0);}++b;}Ce(a.n,i);a.d=c;a.r=d;a.g=0;a.f=0;a.e=0;a.o=oxe;a.p=oxe;for(f=new Anb(a.b);f.a0){e=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!e||Zhb(Zhb((b.a+=' "',b),e),'"');}}else {Zhb(Zhb((b.a+=' "',b),d),'"');}c=(!a.b&&(a.b=new Yie(E4,a,4,7)),!(a.b.i<=1&&(!a.c&&(a.c=new Yie(E4,a,5,8)),a.c.i<=1)));c?(b.a+=' [',b):(b.a+=' ',b);Zhb(b,Eb(new Gb,new dMd(a.b)));c&&(b.a+=']',b);b.a+=SAe;c&&(b.a+='[',b);Zhb(b,Eb(new Gb,new dMd(a.c)));c&&(b.a+=']',b);return b.a} + function odc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;v=a.c;w=b.c;c=Wmb(v.a,a,0);d=Wmb(w.a,b,0);t=RD(c3b(a,(BEc(),yEc)).Kc().Pb(),12);C=RD(c3b(a,zEc).Kc().Pb(),12);u=RD(c3b(b,yEc).Kc().Pb(),12);D=RD(c3b(b,zEc).Kc().Pb(),12);r=s2b(t.e);A=s2b(C.g);s=s2b(u.e);B=s2b(D.g);f3b(a,d,w);for(g=s,k=0,o=g.length;kk){new bTc((fTc(),eTc),c,b,j-k);}else if(j>0&&k>0){new bTc((fTc(),eTc),b,c,0);new bTc(eTc,c,b,0);}}return g} + function pXc(a,b,c){var d,e,f;a.a=new bnb;for(f=Sub(b.b,0);f.b!=f.d.c;){e=RD(evb(f),40);while(RD(mQb(e,(h_c(),f_c)),17).a>a.a.c.length-1){Rmb(a.a,new Ptd(Hze,KEe));}d=RD(mQb(e,f_c),17).a;if(c==(Cmd(),ymd)||c==zmd){e.e.aKfb(UD(RD(Vmb(a.a,d),42).b))&&Otd(RD(Vmb(a.a,d),42),e.e.a+e.f.a);}else {e.e.bKfb(UD(RD(Vmb(a.a,d),42).b))&&Otd(RD(Vmb(a.a,d),42),e.e.b+e.f.b);}}} + function g2b(a,b,c,d){var e,f,g,h,i,j,k;f=i2b(d);h=Heb(TD(mQb(d,(yCc(),aBc))));if((h||Heb(TD(mQb(a,MAc))))&&!Dod(RD(mQb(a,BBc),101))){e=vpd(f);i=q2b(a,c,c==(BEc(),zEc)?e:spd(e));}else {i=new R3b;P3b(i,a);if(b){k=i.n;k.a=b.a-a.n.a;k.b=b.b-a.n.b;_id(k,0,0,a.o.a,a.o.b);Q3b(i,c2b(i,f));}else {e=vpd(f);Q3b(i,c==(BEc(),zEc)?e:spd(e));}g=RD(mQb(d,(Ywc(),kwc)),21);j=i.j;switch(f.g){case 2:case 1:(j==(qpd(),Yod)||j==npd)&&g.Fc((ovc(),lvc));break;case 4:case 3:(j==(qpd(),Xod)||j==ppd)&&g.Fc((ovc(),lvc));}}return i} + function VXb(a,b){var c,d,e,f,g,h;for(g=new vkb((new mkb(a.f.b)).a);g.b;){f=tkb(g);e=RD(f.ld(),602);if(b==1){if(e.Af()!=(Cmd(),Bmd)&&e.Af()!=xmd){continue}}else {if(e.Af()!=(Cmd(),ymd)&&e.Af()!=zmd){continue}}d=RD(RD(f.md(),42).b,86);h=RD(RD(f.md(),42).a,194);c=h.c;switch(e.Af().g){case 2:d.g.c=a.e.a;d.g.b=$wnd.Math.max(1,d.g.b+c);break;case 1:d.g.c=d.g.c+c;d.g.b=$wnd.Math.max(1,d.g.b-c);break;case 4:d.g.d=a.e.b;d.g.a=$wnd.Math.max(1,d.g.a+c);break;case 3:d.g.d=d.g.d+c;d.g.a=$wnd.Math.max(1,d.g.a-c);}}} + function NNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;h=$C(kE,Pwe,28,b.b.c.length,15,1);j=$C(hR,jwe,273,b.b.c.length,0,1);i=$C(jR,WAe,10,b.b.c.length,0,1);for(l=a.a,m=0,n=l.length;m0&&!!i[d]&&(o=bFc(a.b,i[d],e));p=$wnd.Math.max(p,e.c.c.b+o);}for(f=new Anb(k.e);f.a1){throw Adb(new agb(gLe))}if(!i){f=oke(b,d.Kc().Pb());g.Fc(f);}}return XGd(a,gge(a,b,c),g)} + function Fge(a,b,c){var d,e,f,g,h,i,j,k;if(qke(a.e,b)){i=(nke(),RD(b,69).xk()?new ole(b,a):new Eke(b,a));bge(i.c,i.b);Ake(i,RD(c,16));}else {k=pke(a.e.Dh(),b);d=RD(a.g,124);for(g=0;g';}i!=null&&(b.a+=''+i,b);}else if(a.e){h=a.e.zb;h!=null&&(b.a+=''+h,b);}else {b.a+='?';if(a.b){b.a+=' super ';r2d(a.b,b);}else {if(a.f){b.a+=' extends ';r2d(a.f,b);}}}} + function Uae(a){a.b=null;a.a=null;a.o=null;a.q=null;a.v=null;a.w=null;a.B=null;a.p=null;a.Q=null;a.R=null;a.S=null;a.T=null;a.U=null;a.V=null;a.W=null;a.bb=null;a.eb=null;a.ab=null;a.H=null;a.db=null;a.c=null;a.d=null;a.f=null;a.n=null;a.r=null;a.s=null;a.u=null;a.G=null;a.J=null;a.e=null;a.j=null;a.i=null;a.g=null;a.k=null;a.t=null;a.F=null;a.I=null;a.L=null;a.M=null;a.O=null;a.P=null;a.$=null;a.N=null;a.Z=null;a.cb=null;a.K=null;a.D=null;a.A=null;a.C=null;a._=null;a.fb=null;a.X=null;a.Y=null;a.gb=false;a.hb=false;} + function yib(a){var b,c,d,e;d=Ajb((!a.c&&(a.c=ojb(Hdb(a.f))),a.c),0);if(a.e==0||a.a==0&&a.f!=-1&&a.e<0){return d}b=xib(a)<0?1:0;c=a.e;e=(d.length+1+$wnd.Math.abs(eE(a.e)),new cib);b==1&&(e.a+='-',e);if(a.e>0){c-=d.length-b;if(c>=0){e.a+='0.';for(;c>mib.length;c-=mib.length){$hb(e,mib);}_hb(e,mib,eE(c));Zhb(e,(BFb(b,d.length+1),d.substr(b)));}else {c=b-c;Zhb(e,zhb(d,b,eE(c)));e.a+='.';Zhb(e,yhb(d,eE(c)));}}else {Zhb(e,(BFb(b,d.length+1),d.substr(b)));for(;c<-mib.length;c+=mib.length){$hb(e,mib);}_hb(e,mib,eE(-c));}return e.a} + function BOc(a){var b,c,d,e,f,g,h,i,j;if(a.k!=(r3b(),p3b)){return false}if(a.j.c.length<=1){return false}f=RD(mQb(a,(yCc(),BBc)),101);if(f==(Bod(),wod)){return false}e=(wDc(),(!a.q?(yob(),yob(),wob):a.q)._b(iBc)?(d=RD(mQb(a,iBc),203)):(d=RD(mQb(Y2b(a),jBc),203)),d);if(e==uDc){return false}if(!(e==tDc||e==sDc)){g=Kfb(UD(hFc(a,fCc)));b=RD(mQb(a,eCc),140);!b&&(b=new R2b(g,g,g,g));j=b3b(a,(qpd(),ppd));i=b.d+b.a+(j.gc()-1)*g;if(i>a.o.b){return false}c=b3b(a,Xod);h=b.d+b.a+(c.gc()-1)*g;if(h>a.o.b){return false}}return true} + function VRc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;b.Ug('Orthogonal edge routing',1);j=Kfb(UD(mQb(a,(yCc(),cCc))));c=Kfb(UD(mQb(a,UBc)));d=Kfb(UD(mQb(a,XBc)));m=new TTc(0,c);q=0;g=new Jkb(a.b,0);h=null;k=null;i=null;l=null;do{k=g.b0){n=(o-1)*c;!!h&&(n+=d);!!k&&(n+=d);nb||Heb(TD(Gxd(i,(X7c(),D7c))))){e=0;f+=k.b+c;ZEb(l.c,k);k=new Had(f,c);d=new V9c(0,k.f,k,c);Cad(k,d);e=0;}if(d.b.c.length==0||!Heb(TD(Gxd(vCd(i),(X7c(),L7c))))&&(i.f>=d.o&&i.f<=d.f||d.a*0.5<=i.f&&d.a*1.5>=i.f)){K9c(d,i);}else {g=new V9c(d.s+d.r+c,k.f,k,c);Cad(k,g);K9c(g,i);}e=i.i+i.g;}ZEb(l.c,k);return l} + function ste(a){var b,c,d,e;if(a.b==null||a.b.length<=2)return;if(a.a)return;b=0;e=0;while(e=a.b[e+1]){e+=2;}else if(c0){d=new dnb(RD(Qc(a.a,f),21));yob();_mb(d,new M0b(b));e=new Jkb(f.b,0);while(e.b0&&d>=-6){if(d>=0){aib(f,c-eE(a.e),String.fromCharCode(46));}else {peb(f,b-1,b-1,'0.');aib(f,b+1,Ihb(mib,0,-eE(d)-1));}}else {if(c-b>=1){aib(f,b,String.fromCharCode(46));++c;}aib(f,c,String.fromCharCode(69));d>0&&aib(f,++c,String.fromCharCode(43));aib(f,++c,''+Zdb(Hdb(d)));}a.g=f.a;return a.g} + function KNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;d=Kfb(UD(mQb(b,(yCc(),hBc))));v=RD(mQb(b,gCc),17).a;m=4;e=3;w=20/v;n=false;i=0;g=lve;do{f=i!=1;l=i!=0;A=0;for(q=a.a,s=0,u=q.length;sv)){i=2;g=lve;}else if(i==0){i=1;g=A;}else {i=0;g=A;}}else {n=A>=g||g-A0?1:cz(isNaN(d),isNaN(0)))>=0^(bz(vEe),($wnd.Math.abs(h)<=vEe||h==0||isNaN(h)&&isNaN(0)?0:h<0?-1:h>0?1:cz(isNaN(h),isNaN(0)))>=0)){return $wnd.Math.max(h,d)}bz(vEe);if(($wnd.Math.abs(d)<=vEe||d==0||isNaN(d)&&isNaN(0)?0:d<0?-1:d>0?1:cz(isNaN(d),isNaN(0)))>0){return $wnd.Math.sqrt(h*h+d*d)}return -$wnd.Math.sqrt(h*h+d*d)} + function hue(a,b){var c,d,e,f,g,h;if(!b)return;!a.a&&(a.a=new gyb);if(a.e==2){dyb(a.a,b);return}if(b.e==1){for(e=0;e=txe?Nhb(c,qse(d)):Jhb(c,d&Bwe);g=(new eue(10,null,0));fyb(a.a,g,h-1);}else {c=(g.Mm().length+f,new Rhb);Nhb(c,g.Mm());}if(b.e==0){d=b.Km();d>=txe?Nhb(c,qse(d)):Jhb(c,d&Bwe);}else {Nhb(c,b.Mm());}RD(g,530).b=c.a;} + function Qsc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(c.dc()){return}h=0;m=0;d=c.Kc();o=RD(d.Pb(),17).a;while(h1&&(i=j.Hg(i,a.a,h));}if(i.c.length==1){return RD(Vmb(i,i.c.length-1),238)}if(i.c.length==2){return e8c((tFb(0,i.c.length),RD(i.c[0],238)),(tFb(1,i.c.length),RD(i.c[1],238)),g,f)}return null} + function CZc(a,b,c){var d,e,f,g,h,i,j;c.Ug('Find roots',1);a.a.c.length=0;for(e=Sub(b.b,0);e.b!=e.d.c;){d=RD(evb(e),40);if(d.b.b==0){pQb(d,(q$c(),n$c),(Geb(),true));Rmb(a.a,d);}}switch(a.a.c.length){case 0:f=new bXc(0,b,'DUMMY_ROOT');pQb(f,(q$c(),n$c),(Geb(),true));pQb(f,WZc,true);Mub(b.b,f);break;case 1:break;default:g=new bXc(0,b,IEe);for(i=new Anb(a.a);i.a=$wnd.Math.abs(d.b)){d.b=0;f.d+f.a>g.d&&f.dg.c&&f.c0){b=new zNd(a.i,a.g);c=a.i;f=c<100?null:new gLd(c);if(a.Tj()){for(d=0;d0){h=a.g;j=a.i;OHd(a);f=j<100?null:new gLd(j);for(d=0;d>13|(a.m&15)<<9;e=a.m>>4&8191;f=a.m>>17|(a.h&255)<<5;g=(a.h&1048320)>>8;h=b.l&8191;i=b.l>>13|(b.m&15)<<9;j=b.m>>4&8191;k=b.m>>17|(b.h&255)<<5;l=(b.h&1048320)>>8;B=c*h;C=d*h;D=e*h;F=f*h;G=g*h;if(i!=0){C+=c*i;D+=d*i;F+=e*i;G+=f*i;}if(j!=0){D+=c*j;F+=d*j;G+=e*j;}if(k!=0){F+=c*k;G+=d*k;}l!=0&&(G+=c*l);n=B&dxe;o=(C&511)<<13;m=n+o;q=B>>22;r=C>>9;s=(D&262143)<<4;t=(F&31)<<17;p=q+r+s+t;v=D>>18;w=F>>5;A=(G&4095)<<8;u=v+w+A;p+=m>>22;m&=dxe;u+=p>>22;p&=dxe;u&=exe;return hD(m,p,u)} + function Fac(a){var b,c,d,e,f,g,h;h=RD(Vmb(a.j,0),12);if(h.g.c.length!=0&&h.e.c.length!=0){throw Adb(new dgb('Interactive layout does not support NORTH/SOUTH ports with incoming _and_ outgoing edges.'))}if(h.g.c.length!=0){f=oxe;for(c=new Anb(h.g);c.a4){if(a.fk(b)){if(a.al()){e=RD(b,54);d=e.Eh();i=d==a.e&&(a.ml()?e.yh(e.Fh(),a.il())==a.jl():-1-e.Fh()==a.Lj());if(a.nl()&&!i&&!d&&!!e.Jh()){for(f=0;f0&&aGc(a,h,l);}for(e=new Anb(l);e.aa.d[g.p]){c+=ZLc(a.b,f)*RD(i.b,17).a;hmb(a.a,sgb(f));}}while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function x9b(a,b){var c,d,e,f,g,h,i,j,k,l;k=RD(mQb(a,(Ywc(),hwc)),64);d=RD(Vmb(a.j,0),12);k==(qpd(),Yod)?Q3b(d,npd):k==npd&&Q3b(d,Yod);if(RD(mQb(b,(yCc(),lBc)),181).Hc((Qpd(),Ppd))){i=Kfb(UD(mQb(a,_Bc)));j=Kfb(UD(mQb(a,aCc)));g=Kfb(UD(mQb(a,ZBc)));h=RD(mQb(b,EBc),21);if(h.Hc((Pod(),Lod))){c=j;l=a.o.a/2-d.n.a;for(f=new Anb(d.f);f.a0&&(j=a.n.a/f);break;case 2:case 4:e=a.i.o.b;e>0&&(j=a.n.b/e);}pQb(a,(Ywc(),Jwc),j);}i=a.o;g=a.a;if(d){g.a=d.a;g.b=d.b;a.d=true;}else if(b!=zod&&b!=Aod&&h!=opd){switch(h.g){case 1:g.a=i.a/2;break;case 2:g.a=i.a;g.b=i.b/2;break;case 3:g.a=i.a/2;g.b=i.b;break;case 4:g.b=i.b/2;}}else {g.a=i.a/2;g.b=i.b/2;}} + function VJd(a){var b,c,d,e,f,g,h,i,j,k;if(a.Pj()){k=a.Ej();i=a.Qj();if(k>0){b=new $Hd(a.pj());c=k;f=c<100?null:new gLd(c);aJd(a,c,b.g);e=c==1?a.Ij(4,QHd(b,0),null,0,i):a.Ij(6,b,null,-1,i);if(a.Mj()){for(d=new dMd(b);d.e!=d.i.gc();){f=a.Oj(bMd(d),f);}if(!f){a.Jj(e);}else {f.nj(e);f.oj();}}else {if(!f){a.Jj(e);}else {f.nj(e);f.oj();}}}else {aJd(a,a.Ej(),a.Fj());a.Jj(a.Ij(6,(yob(),vob),null,-1,i));}}else if(a.Mj()){k=a.Ej();if(k>0){h=a.Fj();j=k;aJd(a,k,h);f=j<100?null:new gLd(j);for(d=0;d1&&urd(g)*trd(g)/2>h[0]){f=0;while(fh[f]){++f;}o=new Rkb(p,0,f+1);l=new zrd(o);k=urd(g)/trd(g);i=ird(l,b,new z3b,c,d,e,k);$id(hjd(l.e),i);zFb(lwb(m,l),Bxe);n=new Rkb(p,f+1,p.c.length);iwb(m,n);p.c.length=0;j=0;Pnb(h,h.length,0);}else {q=m.b.c.length==0?null:Vmb(m.b,0);q!=null&&owb(m,0);j>0&&(h[j]=h[j-1]);h[j]+=urd(g)*trd(g);++j;ZEb(p.c,g);}}return p} + function _nc(a,b){var c,d,e,f;c=b.b;f=new dnb(c.j);e=0;d=c.j;d.c.length=0;Nnc(RD($i(a.b,(qpd(),Yod),(joc(),ioc)),15),c);e=Onc(f,e,new Hoc,d);Nnc(RD($i(a.b,Yod,hoc),15),c);e=Onc(f,e,new Joc,d);Nnc(RD($i(a.b,Yod,goc),15),c);Nnc(RD($i(a.b,Xod,ioc),15),c);Nnc(RD($i(a.b,Xod,hoc),15),c);e=Onc(f,e,new Loc,d);Nnc(RD($i(a.b,Xod,goc),15),c);Nnc(RD($i(a.b,npd,ioc),15),c);e=Onc(f,e,new Noc,d);Nnc(RD($i(a.b,npd,hoc),15),c);e=Onc(f,e,new Poc,d);Nnc(RD($i(a.b,npd,goc),15),c);Nnc(RD($i(a.b,ppd,ioc),15),c);e=Onc(f,e,new toc,d);Nnc(RD($i(a.b,ppd,hoc),15),c);Nnc(RD($i(a.b,ppd,goc),15),c);} + function jJc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;for(h=new Anb(b);h.a0.5?(r-=g*2*(o-0.5)):o<0.5&&(r+=f*2*(0.5-o));e=h.d.b;rq.a-p-k&&(r=q.a-p-k);h.n.a=b+r;}} + function jec(a){var b,c,d,e,f;d=RD(mQb(a,(yCc(),UAc)),171);if(d==(cxc(),$wc)){for(c=new is(Mr(Z2b(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),18);if(!lec(b)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to FIRST_SEPARATE, but has at least one incoming edge. "+'FIRST_SEPARATE nodes must not have incoming edges.'))}}}else if(d==axc){for(f=new is(Mr(a3b(a).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(!lec(e)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to LAST_SEPARATE, but has at least one outgoing edge. "+'LAST_SEPARATE nodes must not have outgoing edges.'))}}}} + function Qed(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;if(a.e&&a.c.c>19!=0){b=xD(b);i=!i;}g=pD(b);f=false;e=false;d=false;if(a.h==fxe&&a.m==0&&a.l==0){e=true;f=true;if(g==-1){a=gD((MD(),ID));d=true;i=!i;}else {h=BD(a,g);i&&nD(h);c&&(eD=hD(0,0,0));return h}}else if(a.h>>19!=0){f=true;a=xD(a);d=true;i=!i;}if(g!=-1){return kD(a,g,i,f,c)}if(uD(a,b)<0){c&&(f?(eD=xD(a)):(eD=hD(a.l,a.m,a.h)));return hD(0,0,0)}return lD(d?a:hD(a.l,a.m,a.h),b,i,f,e,c)} + function Bjb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;g=a.e;i=b.e;if(g==0){return b}if(i==0){return a}f=a.d;h=b.d;if(f+h==2){c=Cdb(a.a[0],yxe);d=Cdb(b.a[0],yxe);if(g==i){k=Bdb(c,d);o=Ydb(k);n=Ydb(Udb(k,32));return n==0?new ajb(g,o):new cjb(g,2,cD(WC(kE,1),Pwe,28,15,[o,n]))}return Pib(),Jdb(g<0?Vdb(d,c):Vdb(c,d),0)?jjb(g<0?Vdb(d,c):Vdb(c,d)):Xib(jjb(Odb(g<0?Vdb(d,c):Vdb(c,d))))}else if(g==i){m=g;l=f>=h?Cjb(a.a,f,b.a,h):Cjb(b.a,h,a.a,f);}else {e=f!=h?f>h?1:-1:Ejb(a.a,b.a,f);if(e==0){return Pib(),Oib}if(e==1){m=g;l=Hjb(a.a,f,b.a,h);}else {m=i;l=Hjb(b.a,h,a.a,f);}}j=new cjb(m,l.length,l);Rib(j);return j} + function KUc(a,b){var c,d,e,f,g,h,i;if(a.g>b.f||b.g>a.f){return}c=0;d=0;for(g=a.w.a.ec().Kc();g.Ob();){e=RD(g.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,b.g,b.f)&&++c;}for(h=a.r.a.ec().Kc();h.Ob();){e=RD(h.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,b.g,b.f)&&--c;}for(i=b.w.a.ec().Kc();i.Ob();){e=RD(i.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,a.g,a.f)&&++d;}for(f=b.r.a.ec().Kc();f.Ob();){e=RD(f.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,a.g,a.f)&&--d;}if(c=0){return c}switch(yfe(Qee(a,c))){case 2:{if(lhb('',Oee(a,c.qk()).xe())){i=Bfe(Qee(a,c));h=Afe(Qee(a,c));k=Ree(a,b,i,h);if(k){return k}e=Fee(a,b);for(g=0,l=e.gc();g1){throw Adb(new agb(gLe))}k=pke(a.e.Dh(),b);d=RD(a.g,124);for(g=0;g1;for(j=new l4b(m.b);xnb(j.a)||xnb(j.b);){i=RD(xnb(j.a)?ynb(j.a):ynb(j.b),18);l=i.c==m?i.d:i.c;$wnd.Math.abs(xjd(cD(WC(l3,1),Nve,8,0,[l.i.n,l.n,l.a])).b-g.b)>1&&eSc(a,i,g,f,m);}}} + function vUc(a){var b,c,d,e,f,g;e=new Jkb(a.e,0);d=new Jkb(a.a,0);if(a.d){for(c=0;cAEe){f=b;g=0;while($wnd.Math.abs(b-f)0);e.a.Xb(e.c=--e.b);uUc(a,a.b-g,f,d,e);sFb(e.b0);d.a.Xb(d.c=--d.b);}if(!a.d){for(c=0;c0){a.f[k.p]=n/(k.e.c.length+k.g.c.length);a.c=$wnd.Math.min(a.c,a.f[k.p]);a.b=$wnd.Math.max(a.b,a.f[k.p]);}else h&&(a.f[k.p]=n);}} + function xne(a){a.b=null;a.bb=null;a.fb=null;a.qb=null;a.a=null;a.c=null;a.d=null;a.e=null;a.f=null;a.n=null;a.M=null;a.L=null;a.Q=null;a.R=null;a.K=null;a.db=null;a.eb=null;a.g=null;a.i=null;a.j=null;a.k=null;a.gb=null;a.o=null;a.p=null;a.q=null;a.r=null;a.$=null;a.ib=null;a.S=null;a.T=null;a.t=null;a.s=null;a.u=null;a.v=null;a.w=null;a.B=null;a.A=null;a.C=null;a.D=null;a.F=null;a.G=null;a.H=null;a.I=null;a.J=null;a.P=null;a.Z=null;a.U=null;a.V=null;a.W=null;a.X=null;a.Y=null;a._=null;a.ab=null;a.cb=null;a.hb=null;a.nb=null;a.lb=null;a.mb=null;a.ob=null;a.pb=null;a.jb=null;a.kb=null;a.N=false;a.O=false;} + function C8b(a,b,c){var d,e,f,g;c.Ug('Graph transformation ('+a.a+')',1);g=bv(b.a);for(f=new Anb(b.b);f.a=h.b.c)&&(h.b=b);if(!h.c||b.c<=h.c.c){h.d=h.c;h.c=b;}(!h.e||b.d>=h.e.d)&&(h.e=b);(!h.f||b.d<=h.f.d)&&(h.f=b);}d=new PZb((nZb(),jZb));t$b(a,AZb,new mob(cD(WC(wQ,1),rve,382,0,[d])));g=new PZb(mZb);t$b(a,zZb,new mob(cD(WC(wQ,1),rve,382,0,[g])));e=new PZb(kZb);t$b(a,yZb,new mob(cD(WC(wQ,1),rve,382,0,[e])));f=new PZb(lZb);t$b(a,xZb,new mob(cD(WC(wQ,1),rve,382,0,[f])));FZb(d.c,jZb);FZb(e.c,kZb);FZb(f.c,lZb);FZb(g.c,mZb);h.a.c.length=0;Tmb(h.a,d.c);Tmb(h.a,hv(e.c));Tmb(h.a,f.c);Tmb(h.a,hv(g.c));return h} + function n9c(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;b.Ug(bGe,1);n=Kfb(UD(Gxd(a,(X6c(),W6c))));g=Kfb(UD(Gxd(a,(X7c(),Q7c))));h=RD(Gxd(a,N7c),107);Bad((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));k=U8c((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a),n,g);!a.a&&(a.a=new C5d(J4,a,10,11));for(j=new Anb(k);j.a0){a.a=i+(n-1)*f;b.c.b+=a.a;b.f.b+=a.a;}}if(o.a.gc()!=0){m=new TTc(1,f);n=STc(m,b,o,p,b.f.b+i-b.c.b);n>0&&(b.f.b+=i+(n-1)*f);}} + function osc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;k=Kfb(UD(mQb(a,(yCc(),WBc))));d=Kfb(UD(mQb(a,nCc)));m=new dtd;pQb(m,WBc,k+d);j=b;r=j.d;p=j.c.i;s=j.d.i;q=Q4b(p.c);t=Q4b(s.c);e=new bnb;for(l=q;l<=t;l++){h=new j3b(a);h3b(h,(r3b(),o3b));pQb(h,(Ywc(),Awc),j);pQb(h,BBc,(Bod(),wod));pQb(h,YBc,m);n=RD(Vmb(a.b,l),30);l==q?f3b(h,n.a.c.length-c,n):g3b(h,n);u=Kfb(UD(mQb(j,FAc)));if(u<0){u=0;pQb(j,FAc,u);}h.o.b=u;o=$wnd.Math.floor(u/2);g=new R3b;Q3b(g,(qpd(),ppd));P3b(g,h);g.n.b=o;i=new R3b;Q3b(i,Xod);P3b(i,h);i.n.b=o;Z0b(j,g);f=new a1b;kQb(f,j);pQb(f,RAc,null);Y0b(f,i);Z0b(f,r);psc(h,j,f);ZEb(e.c,f);j=f;}return e} + function Hec(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;i=RD(e3b(a,(qpd(),ppd)).Kc().Pb(),12).e;n=RD(e3b(a,Xod).Kc().Pb(),12).g;h=i.c.length;t=K3b(RD(Vmb(a.j,0),12));while(h-->0){p=(tFb(0,i.c.length),RD(i.c[0],18));e=(tFb(0,n.c.length),RD(n.c[0],18));s=e.d.e;f=Wmb(s,e,0);$0b(p,e.d,f);Y0b(e,null);Z0b(e,null);o=p.a;b&&Mub(o,new sjd(t));for(d=Sub(e.a,0);d.b!=d.d.c;){c=RD(evb(d),8);Mub(o,new sjd(c));}r=p.b;for(m=new Anb(e.b);m.ag)&&Ysb(a.b,RD(q.b,18));}}++h;}f=g;}}}} + function zhd(b,c){var d;if(c==null||lhb(c,vve)){return null}if(c.length==0&&b.k!=(kid(),fid)){return null}switch(b.k.g){case 1:return mhb(c,FGe)?(Geb(),Feb):mhb(c,GGe)?(Geb(),Eeb):null;case 2:try{return sgb(Oeb(c,qwe,lve))}catch(a){a=zdb(a);if(ZD(a,130)){return null}else throw Adb(a)}case 4:try{return Neb(c)}catch(a){a=zdb(a);if(ZD(a,130)){return null}else throw Adb(a)}case 3:return c;case 5:uhd(b);return xhd(b,c);case 6:uhd(b);return yhd(b,b.a,c);case 7:try{d=whd(b);d.cg(c);return d}catch(a){a=zdb(a);if(ZD(a,33)){return null}else throw Adb(a)}default:throw Adb(new dgb('Invalid type set for this layout option.'));}} + function JKd(a){var b;switch(a.d){case 1:{if(a.Sj()){return a.o!=-2}break}case 2:{if(a.Sj()){return a.o==-2}break}case 3:case 5:case 4:case 6:case 7:{return a.o>-2}default:{return false}}b=a.Rj();switch(a.p){case 0:return b!=null&&Heb(TD(b))!=Pdb(a.k,0);case 1:return b!=null&&RD(b,222).a!=Ydb(a.k)<<24>>24;case 2:return b!=null&&RD(b,180).a!=(Ydb(a.k)&Bwe);case 6:return b!=null&&Pdb(RD(b,168).a,a.k);case 5:return b!=null&&RD(b,17).a!=Ydb(a.k);case 7:return b!=null&&RD(b,191).a!=Ydb(a.k)<<16>>16;case 3:return b!=null&&Kfb(UD(b))!=a.j;case 4:return b!=null&&RD(b,161).a!=a.j;default:return b==null?a.n!=null:!pb(b,a.n);}} + function N_d(a,b,c){var d,e,f,g;if(a.ol()&&a.nl()){g=O_d(a,RD(c,58));if(dE(g)!==dE(c)){a.xj(b);a.Dj(b,P_d(a,b,g));if(a.al()){f=(e=RD(c,54),a.ml()?a.kl()?e.Th(a.b,Z5d(RD(vYd(Uwd(a.b),a.Lj()),19)).n,RD(vYd(Uwd(a.b),a.Lj()).Hk(),29).kk(),null):e.Th(a.b,BYd(e.Dh(),Z5d(RD(vYd(Uwd(a.b),a.Lj()),19))),null,null):e.Th(a.b,-1-a.Lj(),null,null));!RD(g,54).Ph()&&(f=(d=RD(g,54),a.ml()?a.kl()?d.Rh(a.b,Z5d(RD(vYd(Uwd(a.b),a.Lj()),19)).n,RD(vYd(Uwd(a.b),a.Lj()).Hk(),29).kk(),f):d.Rh(a.b,BYd(d.Dh(),Z5d(RD(vYd(Uwd(a.b),a.Lj()),19))),null,f):d.Rh(a.b,-1-a.Lj(),null,f)));!!f&&f.oj();}Mvd(a.b)&&a.Jj(a.Ij(9,c,g,b,false));return g}}return c} + function iJb(a){var b,c,d,e,f,g,h,i,j,k;d=new bnb;for(g=new Anb(a.e.a);g.a0&&(g=$wnd.Math.max(g,zMb(a.C.b+d.d.b,e)));}else {n=m+k.d.c+a.w+d.d.b;g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(l-e)<=Tye||l==e||isNaN(l)&&isNaN(e)?0:n/(e-l)));}k=d;l=e;m=f;}if(!!a.C&&a.C.c>0){n=m+a.C.c;j&&(n+=k.d.c);g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(l-1)<=Tye||l==1||isNaN(l)&&isNaN(1)?0:n/(1-l)));}c.n.b=0;c.a.a=g;} + function ENb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;c=RD(Vrb(a.b,b),127);i=RD(RD(Qc(a.r,b),21),87);if(i.dc()){c.n.d=0;c.n.a=0;return}j=a.u.Hc((Pod(),Lod));g=0;a.A.Hc((Qpd(),Ppd))&&JNb(a,b);h=i.Kc();k=null;m=0;l=0;while(h.Ob()){d=RD(h.Pb(),117);f=Kfb(UD(d.b.of((tNb(),sNb))));e=d.b.Mf().b;if(!k){!!a.C&&a.C.d>0&&(g=$wnd.Math.max(g,zMb(a.C.d+d.d.d,f)));}else {n=l+k.d.a+a.w+d.d.d;g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(m-f)<=Tye||m==f||isNaN(m)&&isNaN(f)?0:n/(f-m)));}k=d;m=f;l=e;}if(!!a.C&&a.C.a>0){n=l+a.C.a;j&&(n+=k.d.a);g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(m-1)<=Tye||m==1||isNaN(m)&&isNaN(1)?0:n/(1-m)));}c.n.d=0;c.a.b=g;} + function L8c(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r;o=false;j=dad(c.q,b.f+b.b-c.q.f);n=d.f>b.b&&h;r=e-(c.q.e+j-g);l=(i=S9c(d,r,false),i.a);if(n&&l>d.f){return false}if(n){m=0;for(q=new Anb(b.d);q.a=(tFb(f,a.c.length),RD(a.c[f],186)).e;if(!n&&l>b.b&&!k){return false}if(k||n||l<=b.b){if(k&&l>b.b){c.d=l;Q9c(c,P9c(c,l));}else {ead(c.q,j);c.c=true;}Q9c(d,e-(c.s+c.r));U9c(d,c.q.e+c.q.d,b.f);Cad(b,d);if(a.c.length>f){Fad((tFb(f,a.c.length),RD(a.c[f],186)),d);(tFb(f,a.c.length),RD(a.c[f],186)).a.c.length==0&&Xmb(a,f);}o=true;}return o} + function zJc(a,b,c){var d,e,f,g,h,i;this.g=a;h=b.d.length;i=c.d.length;this.d=$C(jR,WAe,10,h+i,0,1);for(g=0;g0?xJc(this,this.f/this.a):pJc(b.g,b.d[0]).a!=null&&pJc(c.g,c.d[0]).a!=null?xJc(this,(Kfb(pJc(b.g,b.d[0]).a)+Kfb(pJc(c.g,c.d[0]).a))/2):pJc(b.g,b.d[0]).a!=null?xJc(this,pJc(b.g,b.d[0]).a):pJc(c.g,c.d[0]).a!=null&&xJc(this,pJc(c.g,c.d[0]).a);} + function DXb(a,b){var c,d,e,f,g,h,i,j,k,l;a.a=new fYb(wsb(s3));for(d=new Anb(b.a);d.a=1){if(q-g>0&&l>=0){i.n.a+=p;i.n.b+=f*g;}else if(q-g<0&&k>=0){i.n.a+=p*q;i.n.b+=f;}}}a.o.a=b.a;a.o.b=b.b;pQb(a,(yCc(),lBc),(Qpd(),d=RD(mfb(H3),9),new Fsb(d,RD(WEb(d,d.length),9),0)));} + function ISd(a,b,c,d,e,f){var g;if(!(b==null||!mSd(b,ZRd,$Rd))){throw Adb(new agb('invalid scheme: '+b))}if(!a&&!(c!=null&&qhb(c,Fhb(35))==-1&&c.length>0&&(BFb(0,c.length),c.charCodeAt(0)!=47))){throw Adb(new agb('invalid opaquePart: '+c))}if(a&&!(b!=null&&tpb(eSd,b.toLowerCase()))&&!(c==null||!mSd(c,aSd,bSd))){throw Adb(new agb(NJe+c))}if(a&&b!=null&&tpb(eSd,b.toLowerCase())&&!ESd(c)){throw Adb(new agb(NJe+c))}if(!FSd(d)){throw Adb(new agb('invalid device: '+d))}if(!HSd(e)){g=e==null?'invalid segments: null':'invalid segment: '+tSd(e);throw Adb(new agb(g))}if(!(f==null||qhb(f,Fhb(35))==-1)){throw Adb(new agb('invalid query: '+f))}} + function WHc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;c.Ug('Network simplex layering',1);a.b=b;r=RD(mQb(b,(yCc(),gCc)),17).a*4;q=a.b.a;if(q.c.length<1){c.Vg();return}f=SHc(a,q);p=null;for(e=Sub(f,0);e.b!=e.d.c;){d=RD(evb(e),15);h=r*eE($wnd.Math.sqrt(d.gc()));g=VHc(d);lJb(yJb(AJb(zJb(CJb(g),h),p),true),c.eh(1));m=a.b.b;for(o=new Anb(g.a);o.a1){p=$C(kE,Pwe,28,a.b.b.c.length,15,1);l=0;for(j=new Anb(a.b.b);j.a0){wA(a,c,0);c.a+=String.fromCharCode(d);e=BA(b,f);wA(a,c,e);f+=e-1;continue}if(d==39){if(f+10&&o.a<=0){i.c.length=0;ZEb(i.c,o);break}n=o.i-o.d;if(n>=h){if(n>h){i.c.length=0;h=n;}ZEb(i.c,o);}}if(i.c.length!=0){g=RD(Vmb(i,Jwb(e,i.c.length)),118);t.a.Bc(g)!=null;g.g=k++;wSc(g,b,c,d);i.c.length=0;}}q=a.c.length+1;for(m=new Anb(a);m.apxe||b.o==CQc&&k=h&&e<=i){if(h<=e&&f<=i){c[k++]=e;c[k++]=f;d+=2;}else if(h<=e){c[k++]=e;c[k++]=i;a.b[d]=i+1;g+=2;}else if(f<=i){c[k++]=h;c[k++]=f;d+=2;}else {c[k++]=h;c[k++]=i;a.b[d]=i+1;}}else if(ipwe)&&h<10);BYb(a.c,new bYb);QXb(a);xYb(a.c);AXb(a.f);} + function B9b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;c=RD(mQb(a,(yCc(),BBc)),101);g=a.f;f=a.d;h=g.a+f.b+f.c;i=0-f.d-a.c.b;k=g.b+f.d+f.a-a.c.b;j=new bnb;l=new bnb;for(e=new Anb(b);e.a=2){i=Sub(c,0);g=RD(evb(i),8);h=RD(evb(i),8);while(h.a0&&aHb(j,true,(Cmd(),zmd));h.k==(r3b(),m3b)&&bHb(j);Zjb(a.f,h,b);}}} + function OVc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;e=RD(mQb(a,(q$c(),h$c)),27);j=lve;k=lve;h=qwe;i=qwe;for(t=Sub(a.b,0);t.b!=t.d.c;){r=RD(evb(t),40);n=r.e;o=r.f;j=$wnd.Math.min(j,n.a-o.a/2);k=$wnd.Math.min(k,n.b-o.b/2);h=$wnd.Math.max(h,n.a+o.a/2);i=$wnd.Math.max(i,n.b+o.b/2);}m=RD(Gxd(e,(h_c(),T$c)),107);for(s=Sub(a.b,0);s.b!=s.d.c;){r=RD(evb(s),40);l=mQb(r,h$c);if(ZD(l,207)){f=RD(l,27);Byd(f,r.e.a,r.e.b);zxd(f,r);}}for(q=Sub(a.a,0);q.b!=q.d.c;){p=RD(evb(q),65);d=RD(mQb(p,h$c),74);if(d){b=p.a;c=IGd(d,true,true);lsd(b,c);}}u=h-j+(m.b+m.c);g=i-k+(m.d+m.a);Heb(TD(Gxd(e,(umd(),mld))))||Esd(e,u,g,false,false);Ixd(e,Ikd,u-(m.b+m.c));Ixd(e,Hkd,g-(m.d+m.a));} + function Wec(a,b){var c,d,e,f,g,h,i,j,k,l;i=true;e=0;j=a.g[b.p];k=b.o.b+a.o;c=a.d[b.p][2];$mb(a.b,j,sgb(RD(Vmb(a.b,j),17).a-1+c));$mb(a.c,j,Kfb(UD(Vmb(a.c,j)))-k+c*a.f);++j;if(j>=a.j){++a.j;Rmb(a.b,sgb(1));Rmb(a.c,k);}else {d=a.d[b.p][1];$mb(a.b,j,sgb(RD(Vmb(a.b,j),17).a+1-d));$mb(a.c,j,Kfb(UD(Vmb(a.c,j)))+k-d*a.f);}(a.r==(aEc(),VDc)&&(RD(Vmb(a.b,j),17).a>a.k||RD(Vmb(a.b,j-1),17).a>a.k)||a.r==YDc&&(Kfb(UD(Vmb(a.c,j)))>a.n||Kfb(UD(Vmb(a.c,j-1)))>a.n))&&(i=false);for(g=new is(Mr(Z2b(b).a.Kc(),new ir));gs(g);){f=RD(hs(g),18);h=f.c.i;if(a.g[h.p]==j){l=Wec(a,h);e=e+RD(l.a,17).a;i=i&&Heb(TD(l.b));}}a.g[b.p]=j;e=e+a.d[b.p][0];return new Ptd(sgb(e),(Geb(),i?true:false))} + function cXb(a,b){var c,d,e,f,g;c=Kfb(UD(mQb(b,(yCc(),TBc))));c<2&&pQb(b,TBc,2);d=RD(mQb(b,rAc),88);d==(Cmd(),Amd)&&pQb(b,rAc,i2b(b));e=RD(mQb(b,NBc),17);e.a==0?pQb(b,(Ywc(),Lwc),new Owb):pQb(b,(Ywc(),Lwc),new Pwb(e.a));f=TD(mQb(b,gBc));f==null&&pQb(b,gBc,(Geb(),dE(mQb(b,yAc))===dE((Ymd(),Umd))?true:false));FDb(new SDb(null,new Swb(b.a,16)),new fXb(a));FDb(EDb(new SDb(null,new Swb(b.b,16)),new hXb),new jXb(a));g=new gFc(b);pQb(b,(Ywc(),Qwc),g);Sed(a.a);Ved(a.a,(sXb(),nXb),RD(mQb(b,pAc),188));Ved(a.a,oXb,RD(mQb(b,$Ac),188));Ved(a.a,pXb,RD(mQb(b,oAc),188));Ved(a.a,qXb,RD(mQb(b,kBc),188));Ved(a.a,rXb,KRc(RD(mQb(b,yAc),223)));Ped(a.a,bXb(b));pQb(b,Kwc,Qed(a.a,b));} + function STc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r;l=new Tsb;g=new bnb;QTc(a,c,a.d.Ag(),g,l);QTc(a,d,a.d.Bg(),g,l);a.b=0.2*(p=RTc(EDb(new SDb(null,new Swb(g,16)),new XTc)),q=RTc(EDb(new SDb(null,new Swb(g,16)),new ZTc)),$wnd.Math.min(p,q));f=0;for(h=0;h=2&&(r=uSc(g,true,m),!a.e&&(a.e=new xTc(a)),tTc(a.e,r,g,a.b),undefined);UTc(g,m);WTc(g);n=-1;for(k=new Anb(g);k.ah} + function Iad(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;j=oxe;k=oxe;h=pxe;i=pxe;for(m=new Anb(b.i);m.a-1){for(e=Sub(h,0);e.b!=e.d.c;){d=RD(evb(e),131);d.v=g;}while(h.b!=0){d=RD(ku(h,0),131);for(c=new Anb(d.i);c.a-1){for(f=new Anb(h);f.a0){continue}RSc(i,$wnd.Math.min(i.o,e.o-1));QSc(i,i.i-1);i.i==0&&(ZEb(h.c,i),true);}}}} + function Lid(a,b,c,d,e){var f,g,h,i;i=oxe;g=false;h=Gid(a,ojd(new rjd(b.a,b.b),a),$id(new rjd(c.a,c.b),e),ojd(new rjd(d.a,d.b),c));f=!!h&&!($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe||$wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe);h=Gid(a,ojd(new rjd(b.a,b.b),a),c,e);!!h&&(($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe)==($wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe)||f?(i=$wnd.Math.min(i,ejd(ojd(h,c)))):(g=true));h=Gid(a,ojd(new rjd(b.a,b.b),a),d,e);!!h&&(g||($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe)==($wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe)||f)&&(i=$wnd.Math.min(i,ejd(ojd(h,d))));return i} + function eWb(a){Cgd(a,new Pfd(Wfd($fd(Xfd(Zfd(Yfd(new agd,AAe),BAe),"Minimizes the stress within a layout using stress majorization. Stress exists if the euclidean distance between a pair of nodes doesn't match their graph theoretic distance, that is, the shortest path between the two nodes. The method allows to specify individual edge lengths."),new hWb),Zze)));Agd(a,AAe,dAe,iGd(XVb));Agd(a,AAe,fAe,(Geb(),true));Agd(a,AAe,jAe,iGd($Vb));Agd(a,AAe,CAe,iGd(_Vb));Agd(a,AAe,iAe,iGd(aWb));Agd(a,AAe,kAe,iGd(ZVb));Agd(a,AAe,gAe,iGd(bWb));Agd(a,AAe,lAe,iGd(cWb));Agd(a,AAe,vAe,iGd(WVb));Agd(a,AAe,xAe,iGd(UVb));Agd(a,AAe,yAe,iGd(VVb));Agd(a,AAe,zAe,iGd(YVb));Agd(a,AAe,wAe,iGd(TVb));} + function kJc(a){var b,c,d,e,f,g,h,i;b=null;for(d=new Anb(a);d.a0&&c.c==0){!b&&(b=new bnb);ZEb(b.c,c);}}if(b){while(b.c.length!=0){c=RD(Xmb(b,0),239);if(!!c.b&&c.b.c.length>0){for(f=(!c.b&&(c.b=new bnb),new Anb(c.b));f.aWmb(a,c,0)){return new Ptd(e,c)}}else if(Kfb(pJc(e.g,e.d[0]).a)>Kfb(pJc(c.g,c.d[0]).a)){return new Ptd(e,c)}}}for(h=(!c.e&&(c.e=new bnb),c.e).Kc();h.Ob();){g=RD(h.Pb(),239);i=(!g.b&&(g.b=new bnb),g.b);wFb(0,i.c.length);XEb(i.c,0,c);g.c==i.c.length&&(ZEb(b.c,g),true);}}}return null} + function _Jc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;b.Ug('Interactive crossing minimization',1);g=0;for(f=new Anb(a.b);f.a0){c+=i.n.a+i.o.a/2;++l;}for(o=new Anb(i.j);o.a0&&(c/=l);r=$C(iE,vxe,28,d.a.c.length,15,1);h=0;for(j=new Anb(d.a);j.a=h&&e<=i){if(h<=e&&f<=i){d+=2;}else if(h<=e){a.b[d]=i+1;g+=2;}else if(f<=i){c[k++]=e;c[k++]=h-1;d+=2;}else {c[k++]=e;c[k++]=h-1;a.b[d]=i+1;g+=2;}}else if(i2){k=new bnb;Tmb(k,new Rkb(r,1,r.b));f=jTb(k,t+a.a);s=new ORb(f);kQb(s,b);ZEb(c.c,s);}else {d?(s=RD(Wjb(a.b,JGd(b)),272)):(s=RD(Wjb(a.b,LGd(b)),272));}i=JGd(b);d&&(i=LGd(b));g=qTb(q,i);j=t+a.a;if(g.a){j+=$wnd.Math.abs(q.b-l.b);p=new rjd(l.a,(l.b+q.b)/2);}else {j+=$wnd.Math.abs(q.a-l.a);p=new rjd((l.a+q.a)/2,l.b);}d?Zjb(a.d,b,new QRb(s,g,p,j)):Zjb(a.c,b,new QRb(s,g,p,j));Zjb(a.b,b,s);o=(!b.n&&(b.n=new C5d(I4,b,1,7)),b.n);for(n=new dMd(o);n.e!=n.i.gc();){m=RD(bMd(n),135);e=nTb(a,m,true,0,0);ZEb(c.c,e);}} + function sMb(a){var b,c,d,e,f,g,h;if(a.A.dc()){return}if(a.A.Hc((Qpd(),Opd))){RD(Vrb(a.b,(qpd(),Yod)),127).k=true;RD(Vrb(a.b,npd),127).k=true;b=a.q!=(Bod(),xod)&&a.q!=wod;QJb(RD(Vrb(a.b,Xod),127),b);QJb(RD(Vrb(a.b,ppd),127),b);QJb(a.g,b);if(a.A.Hc(Ppd)){RD(Vrb(a.b,Yod),127).j=true;RD(Vrb(a.b,npd),127).j=true;RD(Vrb(a.b,Xod),127).k=true;RD(Vrb(a.b,ppd),127).k=true;a.g.k=true;}}if(a.A.Hc(Npd)){a.a.j=true;a.a.k=true;a.g.j=true;a.g.k=true;h=a.B.Hc((dqd(),_pd));for(e=nMb(),f=0,g=e.length;f0),RD(k.a.Xb(k.c=--k.b),18));while(f!=d&&k.b>0){a.a[f.p]=true;a.a[d.p]=true;f=(sFb(k.b>0),RD(k.a.Xb(k.c=--k.b),18));}k.b>0&&Ckb(k);}}}}} + function Zyb(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;if(!a.b){return false}g=null;m=null;i=new Fzb(null,null);e=1;i.a[1]=a.b;l=i;while(l.a[e]){j=e;h=m;m=l;l=l.a[e];d=a.a.Ne(b,l.d);e=d<0?0:1;d==0&&(!c.c||Fvb(l.e,c.d))&&(g=l);if(!(!!l&&l.b)&&!Vyb(l.a[e])){if(Vyb(l.a[1-e])){m=m.a[j]=azb(l,e);}else if(!Vyb(l.a[1-e])){n=m.a[1-j];if(n){if(!Vyb(n.a[1-j])&&!Vyb(n.a[j])){m.b=false;n.b=true;l.b=true;}else {f=h.a[1]==m?1:0;Vyb(n.a[j])?(h.a[f]=_yb(m,j)):Vyb(n.a[1-j])&&(h.a[f]=azb(m,j));l.b=h.a[f].b=true;h.a[f].a[0].b=false;h.a[f].a[1].b=false;}}}}}if(g){c.b=true;c.d=g.e;if(l!=g){k=new Fzb(l.d,l.e);$yb(a,i,g,k);m==g&&(m=k);}m.a[m.a[1]==l?1:0]=l.a[!l.a[0]?1:0];--a.c;}a.b=i.a[1];!!a.b&&(a.b.b=false);return c.b} + function Ilc(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(e=new Anb(a.a.a.b);e.a0?(e-=86400000):(e+=86400000);i=new wB(Bdb(Hdb(b.q.getTime()),e));}k=new cib;j=a.a.length;for(f=0;f=97&&d<=122||d>=65&&d<=90){for(g=f+1;g=j){throw Adb(new agb("Missing trailing '"))}g+1=14&&k<=16))){if(b.a._b(d)){!c.a?(c.a=new dib(c.d)):Zhb(c.a,c.b);Whb(c.a,'[...]');}else {h=SD(d);j=new btb(b);Gyb(c,Inb(h,j));}}else ZD(d,183)?Gyb(c,hob(RD(d,183))):ZD(d,195)?Gyb(c,aob(RD(d,195))):ZD(d,201)?Gyb(c,bob(RD(d,201))):ZD(d,2111)?Gyb(c,gob(RD(d,2111))):ZD(d,53)?Gyb(c,eob(RD(d,53))):ZD(d,376)?Gyb(c,fob(RD(d,376))):ZD(d,846)?Gyb(c,dob(RD(d,846))):ZD(d,109)&&Gyb(c,cob(RD(d,109)));}else {Gyb(c,d==null?vve:jeb(d));}}return !c.a?c.c:c.e.length==0?c.a.a:c.a.a+(''+c.e)} + function KXd(a,b){var c,d,e,f;f=a.F;if(b==null){a.F=null;yXd(a,null);}else {a.F=(uFb(b),b);d=qhb(b,Fhb(60));if(d!=-1){e=(AFb(0,d,b.length),b.substr(0,d));qhb(b,Fhb(46))==-1&&!lhb(e,hve)&&!lhb(e,dKe)&&!lhb(e,eKe)&&!lhb(e,fKe)&&!lhb(e,gKe)&&!lhb(e,hKe)&&!lhb(e,iKe)&&!lhb(e,jKe)&&(e=kKe);c=thb(b,Fhb(62));c!=-1&&(e+=''+(BFb(c+1,b.length+1),b.substr(c+1)));yXd(a,e);}else {e=b;if(qhb(b,Fhb(46))==-1){d=qhb(b,Fhb(91));d!=-1&&(e=(AFb(0,d,b.length),b.substr(0,d)));if(!lhb(e,hve)&&!lhb(e,dKe)&&!lhb(e,eKe)&&!lhb(e,fKe)&&!lhb(e,gKe)&&!lhb(e,hKe)&&!lhb(e,iKe)&&!lhb(e,jKe)){e=kKe;d!=-1&&(e+=''+(BFb(d,b.length+1),b.substr(d)));}else {e=b;}}yXd(a,e);e==b&&(a.F=a.D);}}(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,5,f,b));} + function Pvd(b,c){var d,e,f,g,h,i,j,k,l,m;j=c.length-1;i=(BFb(j,c.length),c.charCodeAt(j));if(i==93){h=qhb(c,Fhb(91));if(h>=0){f=Uvd(b,(AFb(1,h,c.length),c.substr(1,h-1)));l=(AFb(h+1,j,c.length),c.substr(h+1,j-(h+1)));return Nvd(b,l,f)}}else {d=-1;_eb==null&&(_eb=new RegExp('\\d'));if(_eb.test(String.fromCharCode(i))){d=uhb(c,Fhb(46),j-1);if(d>=0){e=RD(Fvd(b,Zvd(b,(AFb(1,d,c.length),c.substr(1,d-1))),false),61);k=0;try{k=Oeb((BFb(d+1,c.length+1),c.substr(d+1)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){g=a;throw Adb(new RSd(g))}else throw Adb(a)}if(k>16==-10){c=RD(a.Cb,292).Yk(b,c);}else if(a.Db>>16==-15){!b&&(b=(JTd(),wTd));!j&&(j=(JTd(),wTd));if(a.Cb.Yh()){i=new P3d(a.Cb,1,13,j,b,fZd(o4d(RD(a.Cb,62)),a),false);!c?(c=i):c.nj(i);}}}else if(ZD(a.Cb,90)){if(a.Db>>16==-23){ZD(b,90)||(b=(JTd(),zTd));ZD(j,90)||(j=(JTd(),zTd));if(a.Cb.Yh()){i=new P3d(a.Cb,1,10,j,b,fZd(tYd(RD(a.Cb,29)),a),false);!c?(c=i):c.nj(i);}}}else if(ZD(a.Cb,457)){h=RD(a.Cb,850);g=(!h.b&&(h.b=new pae(new lae)),h.b);for(f=(d=new vkb((new mkb(g.a)).a),new xae(d));f.a.b;){e=RD(tkb(f.a).ld(),89);c=o2d(e,k2d(e,h),c);}}}return c} + function Y4b(a,b){var c,d,e,f,g,h,i,j,k,l,m;g=Heb(TD(Gxd(a,(yCc(),NAc))));m=RD(Gxd(a,EBc),21);i=false;j=false;l=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));while(l.e!=l.i.gc()&&(!i||!j)){f=RD(bMd(l),123);h=0;for(e=Fl(Al(cD(WC(cJ,1),rve,20,0,[(!f.d&&(f.d=new Yie(G4,f,8,5)),f.d),(!f.e&&(f.e=new Yie(G4,f,7,4)),f.e)])));gs(e);){d=RD(hs(e),74);k=g&&ozd(d)&&Heb(TD(Gxd(d,OAc)));c=cZd((!d.b&&(d.b=new Yie(E4,d,4,7)),d.b),f)?a==vCd(AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))):a==vCd(AGd(RD(QHd((!d.b&&(d.b=new Yie(E4,d,4,7)),d.b),0),84)));if(k||c){++h;if(h>1){break}}}h>0?(i=true):m.Hc((Pod(),Lod))&&(!f.n&&(f.n=new C5d(I4,f,1,7)),f.n).i>0&&(i=true);h>1&&(j=true);}i&&b.Fc((ovc(),hvc));j&&b.Fc((ovc(),ivc));} + function Dsd(a){var b,c,d,e,f,g,h,i,j,k,l,m;m=RD(Gxd(a,(umd(),kld)),21);if(m.dc()){return null}h=0;g=0;if(m.Hc((Qpd(),Opd))){k=RD(Gxd(a,Hld),101);d=2;c=2;e=2;f=2;b=!vCd(a)?RD(Gxd(a,Nkd),88):RD(Gxd(vCd(a),Nkd),88);for(j=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));j.e!=j.i.gc();){i=RD(bMd(j),123);l=RD(Gxd(i,Old),64);if(l==(qpd(),opd)){l=osd(i,b);Ixd(i,Old,l);}if(k==(Bod(),wod)){switch(l.g){case 1:d=$wnd.Math.max(d,i.i+i.g);break;case 2:c=$wnd.Math.max(c,i.j+i.f);break;case 3:e=$wnd.Math.max(e,i.i+i.g);break;case 4:f=$wnd.Math.max(f,i.j+i.f);}}else {switch(l.g){case 1:d+=i.g+2;break;case 2:c+=i.f+2;break;case 3:e+=i.g+2;break;case 4:f+=i.f+2;}}}h=$wnd.Math.max(d,e);g=$wnd.Math.max(c,f);}return Esd(a,h,g,true,true)} + function Rqc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;s=RD(zDb(PDb(CDb(new SDb(null,new Swb(b.d,16)),new Vqc(c)),new Xqc(c)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);l=lve;k=qwe;for(i=new Anb(b.b.j);i.a0;if(j){if(j){m=r.p;g?++m:--m;l=RD(Vmb(r.c.a,m),10);d=Z7b(l);n=!(Did(d,w,c[0])||yid(d,w,c[0]));}}else {n=true;}}o=false;v=b.D.i;if(!!v&&!!v.c&&h.e){k=g&&v.p>0||!g&&v.p=0){i=null;h=new Jkb(k.a,j+1);while(h.bg?1:cz(isNaN(0),isNaN(g)))<0&&(bz(vEe),($wnd.Math.abs(g-1)<=vEe||g==1||isNaN(g)&&isNaN(1)?0:g<1?-1:g>1?1:cz(isNaN(g),isNaN(1)))<0)&&(bz(vEe),($wnd.Math.abs(0-h)<=vEe||0==h||isNaN(0)&&isNaN(h)?0:0h?1:cz(isNaN(0),isNaN(h)))<0)&&(bz(vEe),($wnd.Math.abs(h-1)<=vEe||h==1||isNaN(h)&&isNaN(1)?0:h<1?-1:h>1?1:cz(isNaN(h),isNaN(1)))<0));return f} + function EXd(b){var c,d,e,f;d=b.D!=null?b.D:b.B;c=qhb(d,Fhb(91));if(c!=-1){e=(AFb(0,c,d.length),d.substr(0,c));f=new Qhb;do f.a+='[';while((c=phb(d,91,++c))!=-1);if(lhb(e,hve))f.a+='Z';else if(lhb(e,dKe))f.a+='B';else if(lhb(e,eKe))f.a+='C';else if(lhb(e,fKe))f.a+='D';else if(lhb(e,gKe))f.a+='F';else if(lhb(e,hKe))f.a+='I';else if(lhb(e,iKe))f.a+='J';else if(lhb(e,jKe))f.a+='S';else {f.a+='L';f.a+=''+e;f.a+=';';}try{return null}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}else if(qhb(d,Fhb(46))==-1){if(lhb(d,hve))return xdb;else if(lhb(d,dKe))return gE;else if(lhb(d,eKe))return hE;else if(lhb(d,fKe))return iE;else if(lhb(d,gKe))return jE;else if(lhb(d,hKe))return kE;else if(lhb(d,iKe))return lE;else if(lhb(d,jKe))return wdb}return null} + function pTb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;a.e=b;h=RSb(b);w=new bnb;for(d=new Anb(h);d.a=0&&p=j.c.c.length?(k=hOc((r3b(),p3b),o3b)):(k=hOc((r3b(),o3b),o3b));k*=2;f=c.a.g;c.a.g=$wnd.Math.max(f,f+(k-f));g=c.b.g;c.b.g=$wnd.Math.max(g,g+(k-g));e=b;}}} + function qkc(a){var b,c,d,e;FDb(CDb(new SDb(null,new Swb(a.a.b,16)),new Qkc),new Skc);okc(a);FDb(CDb(new SDb(null,new Swb(a.a.b,16)),new Ukc),new Wkc);if(a.c==(Ymd(),Wmd)){FDb(CDb(EDb(new SDb(null,new Swb(new Xkb(a.f),1)),new clc),new elc),new glc(a));FDb(CDb(GDb(EDb(EDb(new SDb(null,new Swb(a.d.b,16)),new klc),new mlc),new olc),new qlc),new slc(a));}e=new rjd(oxe,oxe);b=new rjd(pxe,pxe);for(d=new Anb(a.a.b);d.a0&&(b.a+=pve,b);Csd(RD(bMd(h),167),b);}b.a+=SAe;i=new mMd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c));while(i.e!=i.i.gc()){i.e>0&&(b.a+=pve,b);Csd(RD(bMd(i),167),b);}b.a+=')';}}} + function LTb(a,b,c){var d,e,f,g,h,i,j,k;for(i=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));i.e!=i.i.gc();){h=RD(bMd(i),27);for(e=new is(Mr(zGd(h).a.Kc(),new ir));gs(e);){d=RD(hs(e),74);!d.b&&(d.b=new Yie(E4,d,4,7));if(!(d.b.i<=1&&(!d.c&&(d.c=new Yie(E4,d,5,8)),d.c.i<=1))){throw Adb(new Ked('Graph must not contain hyperedges.'))}if(!nzd(d)&&h!=AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))){j=new cUb;kQb(j,d);pQb(j,(JVb(),HVb),d);_Tb(j,RD(Wd(qtb(c.f,h)),153));aUb(j,RD(Wjb(c,AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))),153));Rmb(b.c,j);for(g=new dMd((!d.n&&(d.n=new C5d(I4,d,1,7)),d.n));g.e!=g.i.gc();){f=RD(bMd(g),135);k=new iUb(j,f.a);kQb(k,f);pQb(k,HVb,f);k.e.a=$wnd.Math.max(f.g,1);k.e.b=$wnd.Math.max(f.f,1);hUb(k);Rmb(b.d,k);}}}}} + function Vec(a,b,c){var d,e,f,g,h,i,j,k,l,m;c.Ug('Node promotion heuristic',1);a.i=b;a.r=RD(mQb(b,(yCc(),ZAc)),243);a.r!=(aEc(),TDc)&&a.r!=UDc?Tec(a):Uec(a);k=RD(mQb(a.i,YAc),17).a;f=new nfc;switch(a.r.g){case 2:case 1:Yec(a,f);break;case 3:a.r=_Dc;Yec(a,f);i=0;for(h=new Anb(a.b);h.aa.k){a.r=VDc;Yec(a,f);}break;case 4:a.r=_Dc;Yec(a,f);j=0;for(e=new Anb(a.c);e.aa.n){a.r=YDc;Yec(a,f);}break;case 6:m=eE($wnd.Math.ceil(a.g.length*k/100));Yec(a,new qfc(m));break;case 5:l=eE($wnd.Math.ceil(a.e*k/100));Yec(a,new tfc(l));break;case 8:Sec(a,true);break;case 9:Sec(a,false);break;default:Yec(a,f);}a.r!=TDc&&a.r!=UDc?Zec(a,b):$ec(a,b);c.Vg();} + function $rc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;l=a.b;k=new Jkb(l,0);Ikb(k,new R4b(a));s=false;g=1;while(k.b0){m.d+=k.n.d;m.d+=k.d;}if(m.a>0){m.a+=k.n.a;m.a+=k.d;}if(m.b>0){m.b+=k.n.b;m.b+=k.d;}if(m.c>0){m.c+=k.n.c;m.c+=k.d;}return m} + function u9b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;m=c.d;l=c.c;f=new rjd(c.f.a+c.d.b+c.d.c,c.f.b+c.d.d+c.d.a);g=f.b;for(j=new Anb(a.a);j.a0){a.c[b.c.p][b.p].d+=Kwb(a.i,24)*Nxe*0.07000000029802322-0.03500000014901161;a.c[b.c.p][b.p].a=a.c[b.c.p][b.p].d/a.c[b.c.p][b.p].b;}} + function D8b(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(o=new Anb(a);o.ad.d;d.d=$wnd.Math.max(d.d,b);if(h&&c){d.d=$wnd.Math.max(d.d,d.a);d.a=d.d+e;}break;case 3:c=b>d.a;d.a=$wnd.Math.max(d.a,b);if(h&&c){d.a=$wnd.Math.max(d.a,d.d);d.d=d.a+e;}break;case 2:c=b>d.c;d.c=$wnd.Math.max(d.c,b);if(h&&c){d.c=$wnd.Math.max(d.b,d.c);d.b=d.c+e;}break;case 4:c=b>d.b;d.b=$wnd.Math.max(d.b,b);if(h&&c){d.b=$wnd.Math.max(d.b,d.c);d.c=d.b+e;}}}}} + function pA(a,b){var c,d,e,f,g,h,i,j,k;j='';if(b.length==0){return a.ne(ywe,wwe,-1,-1)}k=Dhb(b);lhb(k.substr(0,3),'at ')&&(k=(BFb(3,k.length+1),k.substr(3)));k=k.replace(/\[.*?\]/g,'');g=k.indexOf('(');if(g==-1){g=k.indexOf('@');if(g==-1){j=k;k='';}else {j=Dhb((BFb(g+1,k.length+1),k.substr(g+1)));k=Dhb((AFb(0,g,k.length),k.substr(0,g)));}}else {c=k.indexOf(')',g);j=(AFb(g+1,c,k.length),k.substr(g+1,c-(g+1)));k=Dhb((AFb(0,g,k.length),k.substr(0,g)));}g=qhb(k,Fhb(46));g!=-1&&(k=(BFb(g+1,k.length+1),k.substr(g+1)));(k.length==0||lhb(k,'Anonymous function'))&&(k=wwe);h=thb(j,Fhb(58));e=uhb(j,Fhb(58),h-1);i=-1;d=-1;f=ywe;if(h!=-1&&e!=-1){f=(AFb(0,e,j.length),j.substr(0,e));i=jA((AFb(e+1,h,j.length),j.substr(e+1,h-(e+1))));d=jA((BFb(h+1,j.length+1),j.substr(h+1)));}return a.ne(f,k,i,d)} + function C6b(a){var b,c,d,e,f,g,h,i,j,k,l;for(j=new Anb(a);j.a0||k.j==ppd&&k.e.c.length-k.g.c.length<0)){b=false;break}for(e=new Anb(k.g);e.a=j&&v>=q){m+=o.n.b+p.n.b+p.a.b-u;++h;}}}}if(c){for(g=new Anb(s.e);g.a=j&&v>=q){m+=o.n.b+p.n.b+p.a.b-u;++h;}}}}}if(h>0){w+=m/h;++n;}}if(n>0){b.a=e*w/n;b.g=n;}else {b.a=0;b.g=0;}} + function hTb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;f=a.f.b;m=f.a;k=f.b;o=a.e.g;n=a.e.f;zyd(a.e,f.a,f.b);w=m/o;A=k/n;for(j=new dMd(iyd(a.e));j.e!=j.i.gc();){i=RD(bMd(j),135);Dyd(i,i.i*w);Eyd(i,i.j*A);}for(s=new dMd(wCd(a.e));s.e!=s.i.gc();){r=RD(bMd(s),123);u=r.i;v=r.j;u>0&&Dyd(r,u*w);v>0&&Eyd(r,v*A);}Bvb(a.b,new tTb);b=new bnb;for(h=new vkb((new mkb(a.c)).a);h.b;){g=tkb(h);d=RD(g.ld(),74);c=RD(g.md(),407).a;e=IGd(d,false,false);l=fTb(JGd(d),ssd(e),c);lsd(l,e);t=KGd(d);if(!!t&&Wmb(b,t,0)==-1){ZEb(b.c,t);gTb(t,(sFb(l.b!=0),RD(l.a.a.c,8)),c);}}for(q=new vkb((new mkb(a.d)).a);q.b;){p=tkb(q);d=RD(p.ld(),74);c=RD(p.md(),407).a;e=IGd(d,false,false);l=fTb(LGd(d),Ijd(ssd(e)),c);l=Ijd(l);lsd(l,e);t=MGd(d);if(!!t&&Wmb(b,t,0)==-1){ZEb(b.c,t);gTb(t,(sFb(l.b!=0),RD(l.c.b.c,8)),c);}}} + function GJb(a,b,c,d){var e,f,g,h,i;h=new CLb(b);iNb(h,d);e=true;if(!!a&&a.pf((umd(),Nkd))){f=RD(a.of((umd(),Nkd)),88);e=f==(Cmd(),Amd)||f==ymd||f==zmd;}$Mb(h,false);Umb(h.e.Rf(),new dNb(h,false,e));EMb(h,h.f,(ZJb(),WJb),(qpd(),Yod));EMb(h,h.f,YJb,npd);EMb(h,h.g,WJb,ppd);EMb(h,h.g,YJb,Xod);GMb(h,Yod);GMb(h,npd);FMb(h,Xod);FMb(h,ppd);RMb();g=h.A.Hc((Qpd(),Mpd))&&h.B.Hc((dqd(),$pd))?SMb(h):null;!!g&&uKb(h.a,g);XMb(h);xMb(h);GNb(h);sMb(h);gNb(h);yNb(h);oNb(h,Yod);oNb(h,npd);tMb(h);fNb(h);if(!c){return h.o}VMb(h);CNb(h);oNb(h,Xod);oNb(h,ppd);i=h.B.Hc((dqd(),_pd));IMb(h,i,Yod);IMb(h,i,npd);JMb(h,i,Xod);JMb(h,i,ppd);FDb(new SDb(null,new Swb(new glb(h.i),0)),new KMb);FDb(CDb(new SDb(null,ki(h.r).a.oc()),new MMb),new OMb);WMb(h);h.e.Pf(h.o);FDb(new SDb(null,ki(h.r).a.oc()),new YMb);return h.o} + function LYb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;j=oxe;for(d=new Anb(a.a.b);d.a1){n=new xVc(o,t,d);xgb(t,new nVc(a,n));ZEb(g.c,n);for(l=t.a.ec().Kc();l.Ob();){k=RD(l.Pb(),42);Ymb(f,k.b);}}if(h.a.gc()>1){n=new xVc(o,h,d);xgb(h,new pVc(a,n));ZEb(g.c,n);for(l=h.a.ec().Kc();l.Ob();){k=RD(l.Pb(),42);Ymb(f,k.b);}}}} + function p6b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;p=a.n;q=a.o;m=a.d;l=Kfb(UD(hFc(a,(yCc(),QBc))));if(b){k=l*(b.gc()-1);n=0;for(i=b.Kc();i.Ob();){g=RD(i.Pb(),10);k+=g.o.a;n=$wnd.Math.max(n,g.o.b);}r=p.a-(k-q.a)/2;f=p.b-m.d+n;d=q.a/(b.gc()+1);e=d;for(h=b.Kc();h.Ob();){g=RD(h.Pb(),10);g.n.a=r;g.n.b=f-g.o.b;r+=g.o.a+l;j=n6b(g);j.n.a=g.o.a/2-j.a.a;j.n.b=g.o.b;o=RD(mQb(g,(Ywc(),Xvc)),12);if(o.e.c.length+o.g.c.length==1){o.n.a=e-o.a.a;o.n.b=0;P3b(o,a);}e+=d;}}if(c){k=l*(c.gc()-1);n=0;for(i=c.Kc();i.Ob();){g=RD(i.Pb(),10);k+=g.o.a;n=$wnd.Math.max(n,g.o.b);}r=p.a-(k-q.a)/2;f=p.b+q.b+m.a-n;d=q.a/(c.gc()+1);e=d;for(h=c.Kc();h.Ob();){g=RD(h.Pb(),10);g.n.a=r;g.n.b=f;r+=g.o.a+l;j=n6b(g);j.n.a=g.o.a/2-j.a.a;j.n.b=0;o=RD(mQb(g,(Ywc(),Xvc)),12);if(o.e.c.length+o.g.c.length==1){o.n.a=e-o.a.a;o.n.b=q.b;P3b(o,a);}e+=d;}}} + function Hac(a,b){var c,d,e,f,g,h;if(!RD(mQb(b,(Ywc(),kwc)),21).Hc((ovc(),hvc))){return}for(h=new Anb(b.a);h.a=0&&g0&&(RD(Vrb(a.b,b),127).a.b=c);} + function wcc(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;m=Kfb(UD(mQb(a,(yCc(),_Bc))));n=Kfb(UD(mQb(a,aCc)));l=Kfb(UD(mQb(a,ZBc)));h=a.o;f=RD(Vmb(a.j,0),12);g=f.n;p=ucc(f,l);if(!p){return}if(b.Hc((Pod(),Lod))){switch(RD(mQb(a,(Ywc(),hwc)),64).g){case 1:p.c=(h.a-p.b)/2-g.a;p.d=n;break;case 3:p.c=(h.a-p.b)/2-g.a;p.d=-n-p.a;break;case 2:if(c&&f.e.c.length==0&&f.g.c.length==0){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=h.b+n-g.b;}p.c=-m-p.b;break;case 4:if(c&&f.e.c.length==0&&f.g.c.length==0){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=h.b+n-g.b;}p.c=m;}}else if(b.Hc(Nod)){switch(RD(mQb(a,(Ywc(),hwc)),64).g){case 1:case 3:p.c=g.a+m;break;case 2:case 4:if(c&&!f.c){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=g.b+n;}}}e=p.d;for(j=new Anb(f.f);j.a=b.length)return {done:true};var a=b[d++];return {value:[a,c.get(a)],done:false}}}};if(!Ftb()){e.prototype.createObject=function(){return {}};e.prototype.get=function(a){return this.obj[':'+a]};e.prototype.set=function(a,b){this.obj[':'+a]=b;};e.prototype[Jxe]=function(a){delete this.obj[':'+a];};e.prototype.keys=function(){var a=[];for(var b in this.obj){b.charCodeAt(0)==58&&a.push(b.substring(1));}return a};}return e} + function q$c(){q$c=geb;h$c=new jGd(rAe);new kGd('DEPTH',sgb(0));XZc=new kGd('FAN',sgb(0));VZc=new kGd(QEe,sgb(0));n$c=new kGd('ROOT',(Geb(),false));b$c=new kGd('LEFTNEIGHBOR',null);l$c=new kGd('RIGHTNEIGHBOR',null);c$c=new kGd('LEFTSIBLING',null);m$c=new kGd('RIGHTSIBLING',null);WZc=new kGd('DUMMY',false);new kGd('LEVEL',sgb(0));k$c=new kGd('REMOVABLE_EDGES',new Yub);o$c=new kGd('XCOOR',sgb(0));p$c=new kGd('YCOOR',sgb(0));d$c=new kGd('LEVELHEIGHT',0);f$c=new kGd('LEVELMIN',0);e$c=new kGd('LEVELMAX',0);ZZc=new kGd('GRAPH_XMIN',0);_Zc=new kGd('GRAPH_YMIN',0);YZc=new kGd('GRAPH_XMAX',0);$Zc=new kGd('GRAPH_YMAX',0);UZc=new kGd('COMPACT_LEVEL_ASCENSION',false);TZc=new kGd('COMPACT_CONSTRAINTS',new bnb);a$c=new kGd('ID','');i$c=new kGd('POSITION',sgb(0));j$c=new kGd('PRELIM',0);g$c=new kGd('MODIFIER',0);SZc=new jGd(tAe);RZc=new jGd(uAe);} + function Bqe(a){zqe();var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(a==null)return null;l=a.length*8;if(l==0){return ''}h=l%24;n=l/24|0;m=h!=0?n+1:n;f=null;f=$C(hE,zwe,28,m*4,15,1);j=0;k=0;b=0;c=0;d=0;g=0;e=0;for(i=0;i>24;j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;p=(c&-128)==0?c>>4<<24>>24:(c>>4^240)<<24>>24;q=(d&-128)==0?d>>6<<24>>24:(d>>6^252)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[p|j<<4];f[g++]=yqe[k<<2|q];f[g++]=yqe[d&63];}if(h==8){b=a[e];j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[j<<4];f[g++]=61;f[g++]=61;}else if(h==16){b=a[e];c=a[e+1];k=(c&15)<<24>>24;j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;p=(c&-128)==0?c>>4<<24>>24:(c>>4^240)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[p|j<<4];f[g++]=yqe[k<<2];f[g++]=61;}return Ihb(f,0,f.length)} + function CB(a,b){var c,d,e,f,g,h,i;a.e==0&&a.p>0&&(a.p=-(a.p-1));a.p>qwe&&tB(b,a.p-Owe);g=b.q.getDate();nB(b,1);a.k>=0&&qB(b,a.k);if(a.c>=0){nB(b,a.c);}else if(a.k>=0){i=new vB(b.q.getFullYear()-Owe,b.q.getMonth(),35);d=35-i.q.getDate();nB(b,$wnd.Math.min(d,g));}else {nB(b,g);}a.f<0&&(a.f=b.q.getHours());a.b>0&&a.f<12&&(a.f+=12);oB(b,a.f==24&&a.g?0:a.f);a.j>=0&&pB(b,a.j);a.n>=0&&rB(b,a.n);a.i>=0&&sB(b,Bdb(Ndb(Fdb(Hdb(b.q.getTime()),Awe),Awe),a.i));if(a.a){e=new uB;tB(e,e.q.getFullYear()-Owe-80);Ldb(Hdb(b.q.getTime()),Hdb(e.q.getTime()))&&tB(b,e.q.getFullYear()-Owe+100);}if(a.d>=0){if(a.c==-1){c=(7+a.d-b.q.getDay())%7;c>3&&(c-=7);h=b.q.getMonth();nB(b,b.q.getDate()+c);b.q.getMonth()!=h&&nB(b,b.q.getDate()+(c>0?-7:7));}else {if(b.q.getDay()!=a.d){return false}}}if(a.o>qwe){f=b.q.getTimezoneOffset();sB(b,Bdb(Hdb(b.q.getTime()),(a.o-f)*60*Awe));}return true} + function J5b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;e=mQb(b,(Ywc(),Awc));if(!ZD(e,207)){return}o=RD(e,27);p=b.e;m=new sjd(b.c);f=b.d;m.a+=f.b;m.b+=f.d;u=RD(Gxd(o,(yCc(),oBc)),181);if(Csb(u,(dqd(),Xpd))){n=RD(Gxd(o,qBc),107);E2b(n,f.a);H2b(n,f.d);F2b(n,f.b);G2b(n,f.c);}c=new bnb;for(k=new Anb(b.a);k.ad.c.length-1){Rmb(d,new Ptd(Hze,KEe));}c=RD(mQb(e,f_c),17).a;if(Dmd(RD(mQb(a,H$c),88))){e.e.aKfb(UD((tFb(c,d.c.length),RD(d.c[c],42)).b))&&Otd((tFb(c,d.c.length),RD(d.c[c],42)),e.e.a+e.f.a);}else {e.e.bKfb(UD((tFb(c,d.c.length),RD(d.c[c],42)).b))&&Otd((tFb(c,d.c.length),RD(d.c[c],42)),e.e.b+e.f.b);}}for(f=Sub(a.b,0);f.b!=f.d.c;){e=RD(evb(f),40);c=RD(mQb(e,(h_c(),f_c)),17).a;pQb(e,(q$c(),f$c),UD((tFb(c,d.c.length),RD(d.c[c],42)).a));pQb(e,e$c,UD((tFb(c,d.c.length),RD(d.c[c],42)).b));}b.Vg();} + function Tec(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;a.o=Kfb(UD(mQb(a.i,(yCc(),bCc))));a.f=Kfb(UD(mQb(a.i,XBc)));a.j=a.i.b.c.length;h=a.j-1;m=0;a.k=0;a.n=0;a.b=dv($C(bJ,Nve,17,a.j,0,1));a.c=dv($C(VI,Nve,345,a.j,7,1));for(g=new Anb(a.i.b);g.a0&&Rmb(a.q,k);Rmb(a.p,k);}b-=d;n=i+b;j+=b*a.f;$mb(a.b,h,sgb(n));$mb(a.c,h,j);a.k=$wnd.Math.max(a.k,n);a.n=$wnd.Math.max(a.n,j);a.e+=b;b+=p;}} + function qpd(){qpd=geb;var a;opd=new upd(Sye,0);Yod=new upd(_ye,1);Xod=new upd(aze,2);npd=new upd(bze,3);ppd=new upd(cze,4);bpd=(yob(),new Lqb((a=RD(mfb(E3),9),new Fsb(a,RD(WEb(a,a.length),9),0))));cpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[])));Zod=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[])));kpd=eq(ysb(npd,cD(WC(E3,1),NAe,64,0,[])));mpd=eq(ysb(ppd,cD(WC(E3,1),NAe,64,0,[])));hpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[npd])));apd=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[ppd])));jpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[ppd])));dpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod])));lpd=eq(ysb(npd,cD(WC(E3,1),NAe,64,0,[ppd])));$od=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[npd])));gpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,ppd])));_od=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[npd,ppd])));ipd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[npd,ppd])));epd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,npd])));fpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,npd,ppd])));} + function Gfc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;b.Ug(qBe,1);p=new bnb;w=new bnb;for(j=new Anb(a.b);j.a0&&(t-=n);p2b(g,t);k=0;for(m=new Anb(g.a);m.a0);h.a.Xb(h.c=--h.b);}i=0.4*d*k;!f&&h.b0){j=(BFb(0,c.length),c.charCodeAt(0));if(j!=64){if(j==37){m=c.lastIndexOf('%');k=false;if(m!=0&&(m==n-1||(k=(BFb(m+1,c.length),c.charCodeAt(m+1)==46)))){h=(AFb(1,m,c.length),c.substr(1,m-1));u=lhb('%',h)?null:oSd(h);e=0;if(k){try{e=Oeb((BFb(m+2,c.length+1),c.substr(m+2)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){i=a;throw Adb(new RSd(i))}else throw Adb(a)}}for(r=P2d(b.Gh());r.Ob();){p=k3d(r);if(ZD(p,519)){f=RD(p,598);t=f.d;if((u==null?t==null:lhb(u,t))&&e--==0){return f}}}return null}}l=c.lastIndexOf('.');o=l==-1?c:(AFb(0,l,c.length),c.substr(0,l));d=0;if(l!=-1){try{d=Oeb((BFb(l+1,c.length+1),c.substr(l+1)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){o=c;}else throw Adb(a)}}o=lhb('%',o)?null:oSd(o);for(q=P2d(b.Gh());q.Ob();){p=k3d(q);if(ZD(p,197)){g=RD(p,197);s=g.xe();if((o==null?s==null:lhb(o,s))&&d--==0){return g}}}return null}}return Pvd(b,c)} + function Hlc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;k=new Tsb;i=new Tp;for(d=new Anb(a.a.a.b);d.ab.d.c){n=a.c[b.a.d];q=a.c[l.a.d];if(n==q){continue}rIb(uIb(tIb(vIb(sIb(new wIb,1),100),n),q));}}}}}}} + function mNb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;m=RD(RD(Qc(a.r,b),21),87);if(b==(qpd(),Xod)||b==ppd){qNb(a,b);return}f=b==Yod?(mOb(),iOb):(mOb(),lOb);u=b==Yod?(vLb(),uLb):(vLb(),sLb);c=RD(Vrb(a.b,b),127);d=c.i;e=d.c+Hid(cD(WC(iE,1),vxe,28,15,[c.n.b,a.C.b,a.k]));r=d.c+d.b-Hid(cD(WC(iE,1),vxe,28,15,[c.n.c,a.C.c,a.k]));g=WNb(_Nb(f),a.t);s=b==Yod?pxe:oxe;for(l=m.Kc();l.Ob();){j=RD(l.Pb(),117);if(!j.c||j.c.d.c.length<=0){continue}q=j.b.Mf();p=j.e;n=j.c;o=n.i;o.b=(i=n.n,n.e.a+i.b+i.c);o.a=(h=n.n,n.e.b+h.d+h.a);Ivb(u,Pye);n.f=u;RKb(n,(EKb(),DKb));o.c=p.a-(o.b-q.a)/2;v=$wnd.Math.min(e,p.a);w=$wnd.Math.max(r,p.a+q.a);o.cw&&(o.c=w-o.b);Rmb(g.d,new sOb(o,UNb(g,o)));s=b==Yod?$wnd.Math.max(s,p.b+j.b.Mf().b):$wnd.Math.min(s,p.b);}s+=b==Yod?a.t:-a.t;t=VNb((g.e=s,g));t>0&&(RD(Vrb(a.b,b),127).a.b=t);for(k=m.Kc();k.Ob();){j=RD(k.Pb(),117);if(!j.c||j.c.d.c.length<=0){continue}o=j.c.i;o.c-=j.e.a;o.d-=j.e.b;}} + function JSb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;b=new Tsb;for(i=new dMd(a);i.e!=i.i.gc();){h=RD(bMd(i),27);c=new _sb;Zjb(FSb,h,c);n=new TSb;e=RD(zDb(new SDb(null,new Twb(new is(Mr(yGd(h).a.Kc(),new ir)))),OBb(n,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)])))),85);ISb(c,RD(e.xc((Geb(),true)),16),new VSb);d=RD(zDb(CDb(RD(e.xc(false),15).Lc(),new XSb),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);for(g=d.Kc();g.Ob();){f=RD(g.Pb(),74);m=KGd(f);if(m){j=RD(Wd(qtb(b.f,m)),21);if(!j){j=LSb(m);rtb(b.f,m,j);}ye(c,j);}}e=RD(zDb(new SDb(null,new Twb(new is(Mr(zGd(h).a.Kc(),new ir)))),OBb(n,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb])))),85);ISb(c,RD(e.xc(true),16),new ZSb);d=RD(zDb(CDb(RD(e.xc(false),15).Lc(),new _Sb),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);for(l=d.Kc();l.Ob();){k=RD(l.Pb(),74);m=MGd(k);if(m){j=RD(Wd(qtb(b.f,m)),21);if(!j){j=LSb(m);rtb(b.f,m,j);}ye(c,j);}}}} + function zjb(a,b){xjb();var c,d,e,f,g,h,i,j,k,l,m,n,o,p;i=Ddb(a,0)<0;i&&(a=Odb(a));if(Ddb(a,0)==0){switch(b){case 0:return '0';case 1:return zxe;case 2:return '0.00';case 3:return '0.000';case 4:return '0.0000';case 5:return '0.00000';case 6:return '0.000000';default:n=new bib;b<0?(n.a+='0E+',n):(n.a+='0E',n);n.a+=b==qwe?'2147483648':''+-b;return n.a;}}k=18;l=$C(hE,zwe,28,k+1,15,1);c=k;p=a;do{j=p;p=Fdb(p,10);l[--c]=Ydb(Bdb(48,Vdb(j,Ndb(p,10))))&Bwe;}while(Ddb(p,0)!=0);e=Vdb(Vdb(Vdb(k,c),b),1);if(b==0){i&&(l[--c]=45);return Ihb(l,c,k-c)}if(b>0&&Ddb(e,-6)>=0){if(Ddb(e,0)>=0){f=c+Ydb(e);for(h=k-1;h>=f;h--){l[h+1]=l[h];}l[++f]=46;i&&(l[--c]=45);return Ihb(l,c,k-c+1)}for(g=2;Ldb(g,Bdb(Odb(e),1));g++){l[--c]=48;}l[--c]=46;l[--c]=48;i&&(l[--c]=45);return Ihb(l,c,k-c)}o=c+1;d=k;m=new cib;i&&(m.a+='-',m);if(d-o>=1){Thb(m,l[c]);m.a+='.';m.a+=Ihb(l,c+1,k-c-1);}else {m.a+=Ihb(l,c,k-c);}m.a+='E';Ddb(e,0)>0&&(m.a+='+',m);m.a+=''+Zdb(e);return m.a} + function Esd(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;q=new rjd(a.g,a.f);p=vsd(a);p.a=$wnd.Math.max(p.a,b);p.b=$wnd.Math.max(p.b,c);w=p.a/q.a;k=p.b/q.b;u=p.a-q.a;i=p.b-q.b;if(d){g=!vCd(a)?RD(Gxd(a,(umd(),Nkd)),88):RD(Gxd(vCd(a),(umd(),Nkd)),88);h=dE(Gxd(a,(umd(),Hld)))===dE((Bod(),wod));for(s=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));s.e!=s.i.gc();){r=RD(bMd(s),123);t=RD(Gxd(r,Old),64);if(t==(qpd(),opd)){t=osd(r,g);Ixd(r,Old,t);}switch(t.g){case 1:h||Dyd(r,r.i*w);break;case 2:Dyd(r,r.i+u);h||Eyd(r,r.j*k);break;case 3:h||Dyd(r,r.i*w);Eyd(r,r.j+i);break;case 4:h||Eyd(r,r.j*k);}}}zyd(a,p.a,p.b);if(e){for(m=new dMd((!a.n&&(a.n=new C5d(I4,a,1,7)),a.n));m.e!=m.i.gc();){l=RD(bMd(m),135);n=l.i+l.g/2;o=l.j+l.f/2;v=n/q.a;j=o/q.b;if(v+j>=1){if(v-j>0&&o>=0){Dyd(l,l.i+u);Eyd(l,l.j+i*j);}else if(v-j<0&&n>=0){Dyd(l,l.i+u*v);Eyd(l,l.j+i);}}}}Ixd(a,(umd(),kld),(Qpd(),f=RD(mfb(H3),9),new Fsb(f,RD(WEb(f,f.length),9),0)));return new rjd(w,k)} + function _4c(a){Cgd(a,new Pfd(Wfd($fd(Xfd(Zfd(Yfd(new agd,CFe),'ELK Radial'),'A radial layout provider which is based on the algorithm of Peter Eades published in "Drawing free trees.", published by International Institute for Advanced Study of Social Information Science, Fujitsu Limited in 1991. The radial layouter takes a tree and places the nodes in radial order around the root. The nodes of the same tree level are placed on the same radius.'),new c5c),CFe)));Agd(a,CFe,fEe,iGd(R4c));Agd(a,CFe,_ze,iGd(Y4c));Agd(a,CFe,jAe,iGd(K4c));Agd(a,CFe,CAe,iGd(L4c));Agd(a,CFe,iAe,iGd(M4c));Agd(a,CFe,kAe,iGd(J4c));Agd(a,CFe,gAe,iGd(N4c));Agd(a,CFe,lAe,iGd(Q4c));Agd(a,CFe,tFe,iGd(H4c));Agd(a,CFe,sFe,iGd(I4c));Agd(a,CFe,rFe,iGd(T4c));Agd(a,CFe,xFe,iGd(W4c));Agd(a,CFe,yFe,iGd(U4c));Agd(a,CFe,zFe,iGd(V4c));Agd(a,CFe,wFe,iGd(O4c));Agd(a,CFe,pFe,iGd(P4c));Agd(a,CFe,qFe,iGd(S4c));Agd(a,CFe,uFe,iGd(X4c));Agd(a,CFe,vFe,iGd(Z4c));Agd(a,CFe,oFe,iGd(G4c));} + function Peb(a){var b,c,d,e,f,g,h,i,j,k,l;if(a==null){throw Adb(new Vgb(vve))}j=a;f=a.length;i=false;if(f>0){b=(BFb(0,a.length),a.charCodeAt(0));if(b==45||b==43){a=(BFb(1,a.length+1),a.substr(1));--f;i=b==45;}}if(f==0){throw Adb(new Vgb(nxe+j+'"'))}while(a.length>0&&(BFb(0,a.length),a.charCodeAt(0)==48)){a=(BFb(1,a.length+1),a.substr(1));--f;}if(f>(Ugb(),Sgb)[10]){throw Adb(new Vgb(nxe+j+'"'))}for(e=0;e0){l=-parseInt((AFb(0,d,a.length),a.substr(0,d)),10);a=(BFb(d,a.length+1),a.substr(d));f-=d;c=false;}while(f>=g){d=parseInt((AFb(0,g,a.length),a.substr(0,g)),10);a=(BFb(g,a.length+1),a.substr(g));f-=g;if(c){c=false;}else {if(Ddb(l,h)<0){throw Adb(new Vgb(nxe+j+'"'))}l=Ndb(l,k);}l=Vdb(l,d);}if(Ddb(l,0)>0){throw Adb(new Vgb(nxe+j+'"'))}if(!i){l=Odb(l);if(Ddb(l,0)<0){throw Adb(new Vgb(nxe+j+'"'))}}return l} + function oSd(a){gSd();var b,c,d,e,f,g,h,i;if(a==null)return null;e=qhb(a,Fhb(37));if(e<0){return a}else {i=new dib((AFb(0,e,a.length),a.substr(0,e)));b=$C(gE,YHe,28,4,15,1);h=0;d=0;for(g=a.length;ee+2&&zSd((BFb(e+1,a.length),a.charCodeAt(e+1)),XRd,YRd)&&zSd((BFb(e+2,a.length),a.charCodeAt(e+2)),XRd,YRd)){c=DSd((BFb(e+1,a.length),a.charCodeAt(e+1)),(BFb(e+2,a.length),a.charCodeAt(e+2)));e+=2;if(d>0){(c&192)==128?(b[h++]=c<<24>>24):(d=0);}else if(c>=128){if((c&224)==192){b[h++]=c<<24>>24;d=2;}else if((c&240)==224){b[h++]=c<<24>>24;d=3;}else if((c&248)==240){b[h++]=c<<24>>24;d=4;}}if(d>0){if(h==d){switch(h){case 2:{Thb(i,((b[0]&31)<<6|b[1]&63)&Bwe);break}case 3:{Thb(i,((b[0]&15)<<12|(b[1]&63)<<6|b[2]&63)&Bwe);break}}h=0;d=0;}}else {for(f=0;f=2){if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i==0){c=(bvd(),e=new Rzd,e);WGd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),c);}else if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i>1){m=new mMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));while(m.e!=m.i.gc()){cMd(m);}}lsd(b,RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166));}if(l){for(d=new dMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));d.e!=d.i.gc();){c=RD(bMd(d),166);for(j=new dMd((!c.a&&(c.a=new XZd(D4,c,5)),c.a));j.e!=j.i.gc();){i=RD(bMd(j),377);h.a=$wnd.Math.max(h.a,i.a);h.b=$wnd.Math.max(h.b,i.b);}}}for(g=new dMd((!a.n&&(a.n=new C5d(I4,a,1,7)),a.n));g.e!=g.i.gc();){f=RD(bMd(g),135);k=RD(Gxd(f,und),8);!!k&&Byd(f,k.a,k.b);if(l){h.a=$wnd.Math.max(h.a,f.i+f.g);h.b=$wnd.Math.max(h.b,f.j+f.f);}}return h} + function MA(a,b,c,d,e){var f,g,h;KA(a,b);g=b[0];f=ihb(c.c,0);h=-1;if(DA(c)){if(d>0){if(g+d>a.length){return false}h=HA((AFb(0,g+d,a.length),a.substr(0,g+d)),b);}else {h=HA(a,b);}}switch(f){case 71:h=EA(a,g,cD(WC(qJ,1),Nve,2,6,[Qwe,Rwe]),b);e.e=h;return true;case 77:return PA(a,b,e,h,g);case 76:return RA(a,b,e,h,g);case 69:return NA(a,b,g,e);case 99:return QA(a,b,g,e);case 97:h=EA(a,g,cD(WC(qJ,1),Nve,2,6,['AM','PM']),b);e.b=h;return true;case 121:return TA(a,b,g,h,c,e);case 100:if(h<=0){return false}e.c=h;return true;case 83:if(h<0){return false}return OA(h,g,b[0],e);case 104:h==12&&(h=0);case 75:case 72:if(h<0){return false}e.f=h;e.g=false;return true;case 107:if(h<0){return false}e.f=h;e.g=true;return true;case 109:if(h<0){return false}e.j=h;return true;case 115:if(h<0){return false}e.n=h;return true;case 90:if(gB[i]&&(q=i);for(l=new Anb(a.a.b);l.a1){e=N8c(b);l=f.g;o=RD(Gxd(b,N7c),107);p=Kfb(UD(Gxd(b,x7c)));(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i>1&&Kfb(UD(Gxd(b,(X6c(),T6c))))!=oxe&&(f.c+(o.b+o.c))/(f.b+(o.d+o.a))1&&Kfb(UD(Gxd(b,(X6c(),S6c))))!=oxe&&(f.c+(o.b+o.c))/(f.b+(o.d+o.a))>p&&Ixd(e,(X6c(),W6c),$wnd.Math.max(Kfb(UD(Gxd(b,U6c))),Kfb(UD(Gxd(e,W6c)))-Kfb(UD(Gxd(b,S6c)))));n=new m9c(d,k);i=l9c(n,e,m);j=i.g;if(j>=l&&j==j){for(g=0;g<(!e.a&&(e.a=new C5d(J4,e,10,11)),e.a).i;g++){O8c(a,RD(QHd((!e.a&&(e.a=new C5d(J4,e,10,11)),e.a),g),27),RD(QHd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),g),27));}P8c(b,n);jad(f,i.c);iad(f,i.b);}--h;}Ixd(b,(X6c(),N6c),f.b);Ixd(b,O6c,f.c);c.Vg();} + function fHc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;b.Ug('Interactive node layering',1);c=new bnb;for(m=new Anb(a.a);m.a=h){sFb(s.b>0);s.a.Xb(s.c=--s.b);break}else if(q.a>i){if(!d){Rmb(q.b,k);q.c=$wnd.Math.min(q.c,i);q.a=$wnd.Math.max(q.a,h);d=q;}else {Tmb(d.b,q.b);d.a=$wnd.Math.max(d.a,q.a);Ckb(s);}}}if(!d){d=new jHc;d.c=i;d.a=h;Ikb(s,d);Rmb(d.b,k);}}g=a.b;j=0;for(r=new Anb(c);r.an){if(f){Oub(w,m);Oub(B,sgb(j.b-1));}H=c.b;I+=m+b;m=0;k=$wnd.Math.max(k,c.b+c.c+G);}Dyd(h,H);Eyd(h,I);k=$wnd.Math.max(k,H+G+c.c);m=$wnd.Math.max(m,l);H+=G+b;}k=$wnd.Math.max(k,d);F=I+m+c.a;if(FVze;C=$wnd.Math.abs(m.b-o.b)>Vze;(!c&&B&&C||c&&(B||C))&&Mub(q.a,u);}ye(q.a,d);d.b==0?(m=u):(m=(sFb(d.b!=0),RD(d.c.b.c,8)));j0b(n,l,p);if(I0b(e)==A){if(Y2b(A.i)!=e.a){p=new pjd;e2b(p,Y2b(A.i),s);}pQb(q,Wwc,p);}k0b(n,q,s);k.a.zc(n,k);}Y0b(q,v);Z0b(q,A);}for(j=k.a.ec().Kc();j.Ob();){i=RD(j.Pb(),18);Y0b(i,null);Z0b(i,null);}b.Vg();} + function lXc(a,b){var c,d,e,f,g,h,i,j,k,l,m;e=RD(mQb(a,(h_c(),H$c)),88);k=e==(Cmd(),ymd)||e==zmd?xmd:zmd;c=RD(zDb(CDb(new SDb(null,new Swb(a.b,16)),new $Xc),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);i=RD(zDb(GDb(c.Oc(),new aYc(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);i.Gc(RD(zDb(GDb(c.Oc(),new cYc(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),16));i.jd(new eYc(k));m=new yAb(new iYc(e));d=new Tsb;for(h=i.Kc();h.Ob();){g=RD(h.Pb(),240);j=RD(g.a,40);if(Heb(TD(g.c))){m.a.zc(j,(Geb(),Eeb))==null;(new zAb(m.a.Zc(j,false))).a.gc()>0&&Zjb(d,j,RD((new zAb(m.a.Zc(j,false))).a.Vc(),40));(new zAb(m.a.ad(j,true))).a.gc()>1&&Zjb(d,nXc(m,j),j);}else {if((new zAb(m.a.Zc(j,false))).a.gc()>0){f=RD((new zAb(m.a.Zc(j,false))).a.Vc(),40);dE(f)===dE(Wd(qtb(d.f,j)))&&RD(mQb(j,(q$c(),TZc)),15).Fc(f);}if((new zAb(m.a.ad(j,true))).a.gc()>1){l=nXc(m,j);dE(Wd(qtb(d.f,l)))===dE(j)&&RD(mQb(l,(q$c(),TZc)),15).Fc(j);}m.a.Bc(j)!=null;}}} + function BTb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(a.gc()==1){return RD(a.Xb(0),235)}else if(a.gc()<=0){return new gUb}for(e=a.Kc();e.Ob();){c=RD(e.Pb(),235);o=0;k=lve;l=lve;i=qwe;j=qwe;for(n=new Anb(c.e);n.ah){t=0;u+=g+r;g=0;}ATb(p,c,t,u);b=$wnd.Math.max(b,t+q.a);g=$wnd.Math.max(g,q.b);t+=q.a+r;}return p} + function Aqe(a){zqe();var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(a==null)return null;f=Ahb(a);o=Dqe(f);if(o%4!=0){return null}p=o/4|0;if(p==0)return $C(gE,YHe,28,0,15,1);l=null;b=0;c=0;d=0;e=0;g=0;h=0;i=0;j=0;n=0;m=0;k=0;l=$C(gE,YHe,28,p*3,15,1);for(;n>4)<<24>>24;l[m++]=((c&15)<<4|d>>2&15)<<24>>24;l[m++]=(d<<6|e)<<24>>24;}if(!Cqe(g=f[k++])||!Cqe(h=f[k++])){return null}b=xqe[g];c=xqe[h];i=f[k++];j=f[k++];if(xqe[i]==-1||xqe[j]==-1){if(i==61&&j==61){if((c&15)!=0)return null;q=$C(gE,YHe,28,n*3+1,15,1);hib(l,0,q,0,n*3);q[m]=(b<<2|c>>4)<<24>>24;return q}else if(i!=61&&j==61){d=xqe[i];if((d&3)!=0)return null;q=$C(gE,YHe,28,n*3+2,15,1);hib(l,0,q,0,n*3);q[m++]=(b<<2|c>>4)<<24>>24;q[m]=((c&15)<<4|d>>2&15)<<24>>24;return q}else {return null}}else {d=xqe[i];e=xqe[j];l[m++]=(b<<2|c>>4)<<24>>24;l[m++]=((c&15)<<4|d>>2&15)<<24>>24;l[m++]=(d<<6|e)<<24>>24;}return l} + function wfc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;b.Ug(qBe,1);o=RD(mQb(a,(yCc(),yAc)),223);for(e=new Anb(a.b);e.a=2){p=true;m=new Anb(f.j);c=RD(ynb(m),12);n=null;while(m.a0){d=l.gc();j=eE($wnd.Math.floor((d+1)/2))-1;e=eE($wnd.Math.ceil((d+1)/2))-1;if(b.o==DQc){for(k=e;k>=j;k--){if(b.a[u.p]==u){p=RD(l.Xb(k),42);o=RD(p.a,10);if(!Zsb(c,p.b)&&n>a.b.e[o.p]){b.a[o.p]=u;b.g[u.p]=b.g[o.p];b.a[u.p]=b.g[u.p];b.f[b.g[u.p].p]=(Geb(),Heb(b.f[b.g[u.p].p])&u.k==(r3b(),o3b)?true:false);n=a.b.e[o.p];}}}}else {for(k=j;k<=e;k++){if(b.a[u.p]==u){r=RD(l.Xb(k),42);q=RD(r.a,10);if(!Zsb(c,r.b)&&n0){e=RD(Vmb(q.c.a,w-1),10);g=a.i[e.p];B=$wnd.Math.ceil(bFc(a.n,e,q));f=v.a.e-q.d.d-(g.a.e+e.o.b+e.d.a)-B;}j=oxe;if(w0&&A.a.e.e-A.a.a-(A.b.e.e-A.b.a)<0;o=t.a.e.e-t.a.a-(t.b.e.e-t.b.a)<0&&A.a.e.e-A.a.a-(A.b.e.e-A.b.a)>0;n=t.a.e.e+t.b.aA.b.e.e+A.a.a;u=0;!p&&!o&&(m?f+l>0?(u=l):j-d>0&&(u=d):n&&(f+h>0?(u=h):j-s>0&&(u=s)));v.a.e+=u;v.b&&(v.d.e+=u);return false} + function OJb(a,b,c){var d,e,f,g,h,i,j,k,l,m;d=new Uid(b.Lf().a,b.Lf().b,b.Mf().a,b.Mf().b);e=new Tid;if(a.c){for(g=new Anb(b.Rf());g.aj&&(d.a+=Hhb($C(hE,zwe,28,-j,15,1)));d.a+='Is';if(qhb(i,Fhb(32))>=0){for(e=0;e=d.o.b/2;}else {s=!l;}if(s){r=RD(mQb(d,(Ywc(),Xwc)),15);if(!r){f=new bnb;pQb(d,Xwc,f);}else if(m){f=r;}else {e=RD(mQb(d,Vvc),15);if(!e){f=new bnb;pQb(d,Vvc,f);}else {r.gc()<=e.gc()?(f=r):(f=e);}}}else {e=RD(mQb(d,(Ywc(),Vvc)),15);if(!e){f=new bnb;pQb(d,Vvc,f);}else if(l){f=e;}else {r=RD(mQb(d,Xwc),15);if(!r){f=new bnb;pQb(d,Xwc,f);}else {e.gc()<=r.gc()?(f=e):(f=r);}}}f.Fc(a);pQb(a,(Ywc(),Xvc),c);if(b.d==c){Z0b(b,null);c.e.c.length+c.g.c.length==0&&P3b(c,null);u6b(c);}else {Y0b(b,null);c.e.c.length+c.g.c.length==0&&P3b(c,null);}Xub(b.a);} + function GHc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;c.Ug('MinWidth layering',1);n=b.b;A=b.a;I=RD(mQb(b,(yCc(),WAc)),17).a;h=RD(mQb(b,XAc),17).a;a.b=Kfb(UD(mQb(b,TBc)));a.d=oxe;for(u=new Anb(A);u.a0){j=0;!!q&&(j+=h);j+=(C-1)*g;!!t&&(j+=h);B&&!!t&&(j=$wnd.Math.max(j,JUc(t,g,s,A)));if(j=a.a){d=V9b(a,s);k=$wnd.Math.max(k,d.b);u=$wnd.Math.max(u,d.d);Rmb(h,new Ptd(s,d));}}B=new bnb;for(j=0;j0),q.a.Xb(q.c=--q.b),C=new R4b(a.b),Ikb(q,C),sFb(q.b0){m=k<100?null:new gLd(k);j=new $Hd(b);o=j.g;r=$C(kE,Pwe,28,k,15,1);d=0;u=new ZHd(k);for(e=0;e=0;){if(n!=null?pb(n,o[i]):dE(n)===dE(o[i])){if(r.length<=d){q=r;r=$C(kE,Pwe,28,2*r.length,15,1);hib(q,0,r,0,d);}r[d++]=e;WGd(u,o[i]);break v}}n=n;if(dE(n)===dE(h)){break}}}j=u;o=u.g;k=d;if(d>r.length){q=r;r=$C(kE,Pwe,28,d,15,1);hib(q,0,r,0,d);}if(d>0){t=true;for(f=0;f=0;){THd(a,r[g]);}if(d!=k){for(e=k;--e>=d;){THd(j,e);}q=r;r=$C(kE,Pwe,28,d,15,1);hib(q,0,r,0,d);}b=j;}}}else {b=aHd(a,b);for(e=a.i;--e>=0;){if(b.Hc(a.g[e])){THd(a,e);t=true;}}}if(t){if(r!=null){c=b.gc();l=c==1?dZd(a,4,b.Kc().Pb(),null,r[0],p):dZd(a,6,b,r,r[0],p);m=c<100?null:new gLd(c);for(e=b.Kc();e.Ob();){n=e.Pb();m=oge(a,RD(n,76),m);}if(!m){qvd(a.e,l);}else {m.nj(l);m.oj();}}else {m=tLd(b.gc());for(e=b.Kc();e.Ob();){n=e.Pb();m=oge(a,RD(n,76),m);}!!m&&m.oj();}return true}else {return false}} + function i_b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;c=new p_b(b);c.a||b_b(b);j=a_b(b);i=new Tp;q=new D_b;for(p=new Anb(b.a);p.a0||c.o==DQc&&e=c} + function zEd(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G;t=b;s=new Tp;u=new Tp;k=wDd(t,mIe);d=new OEd(a,c,s,u);QDd(d.a,d.b,d.c,d.d,k);i=(A=s.i,!A?(s.i=new zf(s,s.c)):A);for(C=i.Kc();C.Ob();){B=RD(C.Pb(),166);e=RD(Qc(s,B),21);for(p=e.Kc();p.Ob();){o=p.Pb();v=RD(Ao(a.d,o),166);if(v){h=(!B.e&&(B.e=new Yie(F4,B,10,9)),B.e);WGd(h,v);}else {g=zDd(t,uIe);m=AIe+o+BIe+g;n=m+zIe;throw Adb(new CDd(n))}}}j=(w=u.i,!w?(u.i=new zf(u,u.c)):w);for(F=j.Kc();F.Ob();){D=RD(F.Pb(),166);f=RD(Qc(u,D),21);for(r=f.Kc();r.Ob();){q=r.Pb();v=RD(Ao(a.d,q),166);if(v){l=(!D.g&&(D.g=new Yie(F4,D,9,10)),D.g);WGd(l,v);}else {g=zDd(t,uIe);m=AIe+q+BIe+g;n=m+zIe;throw Adb(new CDd(n))}}}!c.b&&(c.b=new Yie(E4,c,4,7));if(c.b.i!=0&&(!c.c&&(c.c=new Yie(E4,c,5,8)),c.c.i!=0)&&(!c.b&&(c.b=new Yie(E4,c,4,7)),c.b.i<=1&&(!c.c&&(c.c=new Yie(E4,c,5,8)),c.c.i<=1))&&(!c.a&&(c.a=new C5d(F4,c,6,6)),c.a).i==1){G=RD(QHd((!c.a&&(c.a=new C5d(F4,c,6,6)),c.a),0),166);if(!Dzd(G)&&!Ezd(G)){Kzd(G,RD(QHd((!c.b&&(c.b=new Yie(E4,c,4,7)),c.b),0),84));Lzd(G,RD(QHd((!c.c&&(c.c=new Yie(E4,c,5,8)),c.c),0),84));}}} + function QNc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;for(t=a.a,u=0,v=t.length;u0){l=RD(Vmb(m.c.a,g-1),10);B=bFc(a.b,m,l);q=m.n.b-m.d.d-(l.n.b+l.o.b+l.d.a+B);}else {q=m.n.b-m.d.d;}j=$wnd.Math.min(q,j);if(g1&&(g=$wnd.Math.min(g,$wnd.Math.abs(RD(ju(h.a,1),8).b-k.b)));}}}}}else {for(p=new Anb(b.j);p.ae){f=m.a-e;g=lve;d.c.length=0;e=m.a;}if(m.a>=e){ZEb(d.c,h);h.a.b>1&&(g=$wnd.Math.min(g,$wnd.Math.abs(RD(ju(h.a,h.a.b-2),8).b-m.b)));}}}}}if(d.c.length!=0&&f>b.o.a/2&&g>b.o.b/2){n=new R3b;P3b(n,b);Q3b(n,(qpd(),Yod));n.n.a=b.o.a/2;r=new R3b;P3b(r,b);Q3b(r,npd);r.n.a=b.o.a/2;r.n.b=b.o.b;for(i=new Anb(d);i.a=j.b?Y0b(h,r):Y0b(h,n);}else {j=RD(Vub(h.a),8);q=h.a.b==0?K3b(h.c):RD(Rub(h.a),8);q.b>=j.b?Z0b(h,r):Z0b(h,n);}l=RD(mQb(h,(yCc(),RAc)),75);!!l&&ze(l,j,true);}b.n.a=e-b.o.a/2;}} + function E0c(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(h=Sub(a.b,0);h.b!=h.d.c;){g=RD(evb(h),40);if(lhb(g.c,IEe)){continue}j=iWc(g,a);b==(Cmd(),ymd)||b==zmd?_mb(j,new D1c):_mb(j,new H1c);i=j.c.length;for(d=0;d=0?(n=vpd(h)):(n=spd(vpd(h)));a.qf(GBc,n);}j=new pjd;m=false;if(a.pf(zBc)){mjd(j,RD(a.of(zBc),8));m=true;}else {ljd(j,g.a/2,g.b/2);}switch(n.g){case 4:pQb(k,UAc,(cxc(),$wc));pQb(k,bwc,(huc(),guc));k.o.b=g.b;p<0&&(k.o.a=-p);Q3b(l,(qpd(),Xod));m||(j.a=g.a);j.a-=g.a;break;case 2:pQb(k,UAc,(cxc(),axc));pQb(k,bwc,(huc(),euc));k.o.b=g.b;p<0&&(k.o.a=-p);Q3b(l,(qpd(),ppd));m||(j.a=0);break;case 1:pQb(k,owc,(Gvc(),Fvc));k.o.a=g.a;p<0&&(k.o.b=-p);Q3b(l,(qpd(),npd));m||(j.b=g.b);j.b-=g.b;break;case 3:pQb(k,owc,(Gvc(),Dvc));k.o.a=g.a;p<0&&(k.o.b=-p);Q3b(l,(qpd(),Yod));m||(j.b=0);}mjd(l.n,j);pQb(k,zBc,j);if(b==vod||b==xod||b==wod){o=0;if(b==vod&&a.pf(CBc)){switch(n.g){case 1:case 2:o=RD(a.of(CBc),17).a;break;case 3:case 4:o=-RD(a.of(CBc),17).a;}}else {switch(n.g){case 4:case 2:o=f.b;b==xod&&(o/=e.b);break;case 1:case 3:o=f.a;b==xod&&(o/=e.a);}}pQb(k,Jwc,o);}pQb(k,hwc,n);return k} + function OId(){MId();function h(f){var g=this;this.dispatch=function(a){var b=a.data;switch(b.cmd){case 'algorithms':var c=PId((yob(),new xpb(new glb(LId.b))));f.postMessage({id:b.id,data:c});break;case 'categories':var d=PId((yob(),new xpb(new glb(LId.c))));f.postMessage({id:b.id,data:d});break;case 'options':var e=PId((yob(),new xpb(new glb(LId.d))));f.postMessage({id:b.id,data:e});break;case 'register':SId(b.algorithms);f.postMessage({id:b.id});break;case 'layout':QId(b.graph,b.layoutOptions||{},b.options||{});f.postMessage({id:b.id,data:b.graph});break;}};this.saveDispatch=function(b){try{g.dispatch(b);}catch(a){f.postMessage({id:b.data.id,error:a});}};} + function j(b){var c=this;this.dispatcher=new h({postMessage:function(a){c.onmessage({data:a});}});this.postMessage=function(a){setTimeout(function(){c.dispatcher.saveDispatch({data:a});},0);};} + if(typeof document===Yxe&&typeof self!==Yxe){var i=new h(self);self.onmessage=i.saveDispatch;}else if(typeof module!==Yxe&&module.exports){Object.defineProperty(exports,'__esModule',{value:true});module.exports={'default':j,Worker:j};}} + function i5b(a,b,c){var d,e,f,g,h,i,j,k,l,m;k=new j3b(c);kQb(k,b);pQb(k,(Ywc(),Awc),b);k.o.a=b.g;k.o.b=b.f;k.n.a=b.i;k.n.b=b.j;Rmb(c.a,k);Zjb(a.a,b,k);((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i!=0||Heb(TD(Gxd(b,(yCc(),NAc)))))&&pQb(k,Yvc,(Geb(),true));j=RD(mQb(c,kwc),21);l=RD(mQb(k,(yCc(),BBc)),101);l==(Bod(),Aod)?pQb(k,BBc,zod):l!=zod&&j.Fc((ovc(),kvc));m=0;d=RD(mQb(c,rAc),88);for(i=new dMd((!b.c&&(b.c=new C5d(K4,b,9,9)),b.c));i.e!=i.i.gc();){h=RD(bMd(i),123);e=vCd(b);(dE(Gxd(e,cAc))!==dE((kEc(),hEc))||dE(Gxd(e,pAc))===dE((Ptc(),Otc))||dE(Gxd(e,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(e,eAc)))||dE(Gxd(e,Yzc))!==dE((U$b(),T$b))||dE(Gxd(e,ZAc))===dE((aEc(),TDc))||dE(Gxd(e,ZAc))===dE((aEc(),UDc))||dE(Gxd(e,$Ac))===dE((_Cc(),SCc))||dE(Gxd(e,$Ac))===dE((_Cc(),UCc)))&&!Heb(TD(Gxd(b,aAc)))&&Ixd(h,zwc,sgb(m++));Heb(TD(Gxd(h,pBc)))||j5b(a,h,k,j,d,l);}for(g=new dMd((!b.n&&(b.n=new C5d(I4,b,1,7)),b.n));g.e!=g.i.gc();){f=RD(bMd(g),135);!Heb(TD(Gxd(f,pBc)))&&!!f.a&&Rmb(k.b,h5b(f));}Heb(TD(mQb(k,Uzc)))&&j.Fc((ovc(),fvc));if(Heb(TD(mQb(k,MAc)))){j.Fc((ovc(),jvc));j.Fc(ivc);pQb(k,BBc,zod);}return k} + function ird(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;p=0;D=0;for(j=new Anb(a.b);j.ap){if(f){Oub(w,n);Oub(B,sgb(k.b-1));Rmb(a.d,o);h.c.length=0;}H=c.b;I+=n+b;n=0;l=$wnd.Math.max(l,c.b+c.c+G);}ZEb(h.c,i);xrd(i,H,I);l=$wnd.Math.max(l,H+G+c.c);n=$wnd.Math.max(n,m);H+=G+b;o=i;}Tmb(a.a,h);Rmb(a.d,RD(Vmb(h,h.c.length-1),163));l=$wnd.Math.max(l,d);F=I+n+c.a;if(Fe.d.d+e.d.a){k.f.d=true;}else {k.f.d=true;k.f.a=true;}}}d.b!=d.d.c&&(b=c);}if(k){f=RD(Wjb(a.f,g.d.i),60);if(b.bf.d.d+f.d.a){k.f.d=true;}else {k.f.d=true;k.f.a=true;}}}}for(h=new is(Mr(Z2b(n).a.Kc(),new ir));gs(h);){g=RD(hs(h),18);if(g.a.b!=0){b=RD(Rub(g.a),8);if(g.d.j==(qpd(),Yod)){q=new Nlc(b,new rjd(b.a,e.d.d),e,g);q.f.a=true;q.a=g.d;ZEb(p.c,q);}if(g.d.j==npd){q=new Nlc(b,new rjd(b.a,e.d.d+e.d.a),e,g);q.f.d=true;q.a=g.d;ZEb(p.c,q);}}}}}return p} + function Nvd(a,b,c){var d,e,f,g,h,i,j,k,l,m;i=new bnb;l=b.length;g=$5d(c);for(j=0;j=o){if(s>o){n.c.length=0;o=s;}ZEb(n.c,g);}}if(n.c.length!=0){m=RD(Vmb(n,Jwb(b,n.c.length)),131);F.a.Bc(m)!=null;m.s=p++;$Uc(m,C,w);n.c.length=0;}}u=a.c.length+1;for(h=new Anb(a);h.aD.s){Ckb(c);Ymb(D.i,d);if(d.c>0){d.a=D;Rmb(D.t,d);d.b=A;Rmb(A.i,d);}}}}} + function Efc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F;p=new cnb(b.b);u=new cnb(b.b);m=new cnb(b.b);B=new cnb(b.b);q=new cnb(b.b);for(A=Sub(b,0);A.b!=A.d.c;){v=RD(evb(A),12);for(h=new Anb(v.g);h.a0;r=v.g.c.length>0;j&&r?(ZEb(m.c,v),true):j?(ZEb(p.c,v),true):r&&(ZEb(u.c,v),true);}for(o=new Anb(p);o.as.nh()-j.b&&(m=s.nh()-j.b);n>s.oh()-j.d&&(n=s.oh()-j.d);k0){for(t=Sub(a.f,0);t.b!=t.d.c;){s=RD(evb(t),10);s.p+=m-a.e;}WGc(a);Xub(a.f);TGc(a,d,n);}else {Mub(a.f,n);n.p=d;a.e=$wnd.Math.max(a.e,d);for(f=new is(Mr(Z2b(n).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(!e.c.i.c&&e.c.i.k==(r3b(),n3b)){Mub(a.f,e.c.i);e.c.i.p=d-1;}}a.c=d;}}}else {WGc(a);Xub(a.f);d=0;if(gs(new is(Mr(Z2b(n).a.Kc(),new ir)))){m=0;m=UGc(m,n);d=m+2;TGc(a,d,n);}else {Mub(a.f,n);n.p=0;a.e=$wnd.Math.max(a.e,0);a.b=RD(Vmb(a.d.b,0),30);a.c=0;}}}}a.f.b==0||WGc(a);a.d.a.c.length=0;r=new bnb;for(j=new Anb(a.d.b);j.a=48&&b<=57){d=b-48;while(e=48&&b<=57){d=d*10+b-48;if(d<0)throw Adb(new Lqe(TId((Hde(),CJe))))}}else {throw Adb(new Lqe(TId((Hde(),yJe))))}c=d;if(b==44){if(e>=a.j){throw Adb(new Lqe(TId((Hde(),AJe))))}else if((b=ihb(a.i,e++))>=48&&b<=57){c=b-48;while(e=48&&b<=57){c=c*10+b-48;if(c<0)throw Adb(new Lqe(TId((Hde(),CJe))))}if(d>c)throw Adb(new Lqe(TId((Hde(),BJe))))}else {c=-1;}}if(b!=125)throw Adb(new Lqe(TId((Hde(),zJe))));if(a.bm(e)){f=(Vse(),Vse(),new Kte(9,f));a.d=e+1;}else {f=(Vse(),Vse(),new Kte(3,f));a.d=e;}f.Om(d);f.Nm(c);Mqe(a);}}return f} + function bXb(a){var b,c,d,e,f;c=RD(mQb(a,(Ywc(),kwc)),21);b=vfd(YWb);e=RD(mQb(a,(yCc(),IAc)),346);e==(Fnd(),Cnd)&&ofd(b,ZWb);Heb(TD(mQb(a,GAc)))?pfd(b,(sXb(),nXb),(hcc(),Zbc)):pfd(b,(sXb(),pXb),(hcc(),Zbc));mQb(a,(rid(),qid))!=null&&ofd(b,$Wb);(Heb(TD(mQb(a,PAc)))||Heb(TD(mQb(a,HAc))))&&nfd(b,(sXb(),rXb),(hcc(),lbc));switch(RD(mQb(a,rAc),88).g){case 2:case 3:case 4:nfd(pfd(b,(sXb(),nXb),(hcc(),nbc)),rXb,mbc);}c.Hc((ovc(),fvc))&&nfd(pfd(pfd(b,(sXb(),nXb),(hcc(),kbc)),qXb,ibc),rXb,jbc);dE(mQb(a,ZAc))!==dE((aEc(),$Dc))&&pfd(b,(sXb(),pXb),(hcc(),Rbc));if(c.Hc(mvc)){pfd(b,(sXb(),nXb),(hcc(),Xbc));pfd(b,oXb,Vbc);pfd(b,pXb,Wbc);}dE(mQb(a,Xzc))!==dE(($uc(),Yuc))&&dE(mQb(a,yAc))!==dE((Ymd(),Vmd))&&nfd(b,(sXb(),rXb),(hcc(),Abc));Heb(TD(mQb(a,KAc)))&&pfd(b,(sXb(),pXb),(hcc(),zbc));Heb(TD(mQb(a,nAc)))&&pfd(b,(sXb(),pXb),(hcc(),dcc));if(eXb(a)){dE(mQb(a,IAc))===dE(Cnd)?(d=RD(mQb(a,gAc),299)):(d=RD(mQb(a,hAc),299));f=d==(xvc(),vvc)?(hcc(),Ubc):(hcc(),gcc);pfd(b,(sXb(),qXb),f);}switch(RD(mQb(a,vCc),388).g){case 1:pfd(b,(sXb(),qXb),(hcc(),ecc));break;case 2:nfd(pfd(pfd(b,(sXb(),pXb),(hcc(),ebc)),qXb,fbc),rXb,gbc);}dE(mQb(a,cAc))!==dE((kEc(),hEc))&&pfd(b,(sXb(),pXb),(hcc(),fcc));return b} + function crc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;if(Ujb(a.a,b)){if(Zsb(RD(Wjb(a.a,b),49),c)){return 1}}else {Zjb(a.a,b,new _sb);}if(Ujb(a.a,c)){if(Zsb(RD(Wjb(a.a,c),49),b)){return -1}}else {Zjb(a.a,c,new _sb);}if(Ujb(a.e,b)){if(Zsb(RD(Wjb(a.e,b),49),c)){return -1}}else {Zjb(a.e,b,new _sb);}if(Ujb(a.e,c)){if(Zsb(RD(Wjb(a.a,c),49),b)){return 1}}else {Zjb(a.e,c,new _sb);}if(a.c==(kEc(),iEc)||!nQb(b,(Ywc(),zwc))||!nQb(c,(Ywc(),zwc))){l=null;for(j=new Anb(b.j);j.ag?erc(a,b,c):erc(a,c,b);return eg?1:0}}d=RD(mQb(b,(Ywc(),zwc)),17).a;f=RD(mQb(c,zwc),17).a;d>f?erc(a,b,c):erc(a,c,b);return df?1:0} + function uAd(b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(d==null){return null}if(b.a!=c.jk()){throw Adb(new agb(VHe+c.xe()+WHe))}if(ZD(c,469)){r=z1d(RD(c,685),d);if(!r){throw Adb(new agb(XHe+d+"' is not a valid enumerator of '"+c.xe()+"'"))}return r}switch(Oee((lke(),jke),c).Nl()){case 2:{d=nue(d,false);break}case 3:{d=nue(d,true);break}}e=Oee(jke,c).Jl();if(e){return e.jk().wi().ti(e,d)}n=Oee(jke,c).Ll();if(n){r=new bnb;for(k=xAd(d),l=0,m=k.length;l1){o=new mMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));while(o.e!=o.i.gc()){cMd(o);}}g=RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166);q=H;H>v+u?(q=v+u):Hw+p?(r=w+p):Iv-u&&qw-p&&rH+G?(B=H+G):vI+A?(C=I+A):wH-G&&BI-A&&Cc&&(m=c-1);n=N+Kwb(b,24)*Nxe*l-l/2;n<0?(n=1):n>d&&(n=d-1);e=(bvd(),i=new Xxd,i);Vxd(e,m);Wxd(e,n);WGd((!g.a&&(g.a=new XZd(D4,g,5)),g.a),e);}} + function Y7c(a){Cgd(a,new Pfd($fd(Xfd(Zfd(Yfd(new agd,$Fe),'ELK Rectangle Packing'),'Algorithm for packing of unconnected boxes, i.e. graphs without edges. The given order of the boxes is always preserved and the main reading direction of the boxes is left to right. The algorithm is divided into two phases. One phase approximates the width in which the rectangles can be placed. The next phase places the rectangles in rows using the previously calculated width as bounding width and bundles rectangles with a similar height in blocks. A compaction step reduces the size of the drawing. Finally, the rectangles are expanded to fill their bounding box and eliminate empty unused spaces.'),new _7c)));Agd(a,$Fe,Dze,1.3);Agd(a,$Fe,hAe,(Geb(),false));Agd(a,$Fe,Eze,O7c);Agd(a,$Fe,_ze,15);Agd(a,$Fe,YDe,iGd(y7c));Agd(a,$Fe,jAe,iGd(F7c));Agd(a,$Fe,CAe,iGd(H7c));Agd(a,$Fe,iAe,iGd(I7c));Agd(a,$Fe,kAe,iGd(E7c));Agd(a,$Fe,gAe,iGd(J7c));Agd(a,$Fe,lAe,iGd(P7c));Agd(a,$Fe,RFe,iGd(U7c));Agd(a,$Fe,SFe,iGd(T7c));Agd(a,$Fe,QFe,iGd(W7c));Agd(a,$Fe,PFe,iGd(V7c));Agd(a,$Fe,TFe,iGd(M7c));Agd(a,$Fe,UFe,iGd(L7c));Agd(a,$Fe,VFe,iGd(K7c));Agd(a,$Fe,WFe,iGd(S7c));Agd(a,$Fe,dAe,iGd(B7c));Agd(a,$Fe,iEe,iGd(C7c));Agd(a,$Fe,NFe,iGd(A7c));Agd(a,$Fe,MFe,iGd(z7c));Agd(a,$Fe,OFe,iGd(D7c));Agd(a,$Fe,LFe,iGd(R7c));} + function Ajb(a,b){xjb();var c,d,e,h,i,j,l,n,o,p,q,r,s,t,u,w,A,B,D,F,G,H;B=a.e;o=a.d;e=a.a;if(B==0){switch(b){case 0:return '0';case 1:return zxe;case 2:return '0.00';case 3:return '0.000';case 4:return '0.0000';case 5:return '0.00000';case 6:return '0.000000';default:w=new bib;(w.a+='0E',w);w.a+=-b;return w.a;}}t=o*10+1+7;u=$C(hE,zwe,28,t+1,15,1);c=t;if(o==1){h=e[0];if(h<0){H=Cdb(h,yxe);do{p=H;H=Fdb(H,10);u[--c]=48+Ydb(Vdb(p,Ndb(H,10)))&Bwe;}while(Ddb(H,0)!=0)}else {H=h;do{p=H;H=H/10|0;u[--c]=48+(p-H*10)&Bwe;}while(H!=0)}}else {D=$C(kE,Pwe,28,o,15,1);G=o;hib(e,0,D,0,G);I:while(true){A=0;for(j=G-1;j>=0;j--){F=Bdb(Sdb(A,32),Cdb(D[j],yxe));r=yjb(F);D[j]=Ydb(r);A=Ydb(Tdb(r,32));}s=Ydb(A);q=c;do{u[--c]=48+s%10&Bwe;}while((s=s/10|0)!=0&&c!=0);d=9-q+c;for(i=0;i0;i++){u[--c]=48;}l=G-1;for(;D[l]==0;l--){if(l==0){break I}}G=l+1;}while(u[c]==48){++c;}}n=B<0;{n&&(u[--c]=45);return Ihb(u,c,t-c)}} + function Jad(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;a.c=b;a.g=new Tsb;c=(lud(),new zud(a.c));d=new PJb(c);LJb(d);t=WD(Gxd(a.c,(ncd(),gcd)));i=RD(Gxd(a.c,icd),324);v=RD(Gxd(a.c,jcd),437);g=RD(Gxd(a.c,bcd),490);u=RD(Gxd(a.c,hcd),438);a.j=Kfb(UD(Gxd(a.c,kcd)));h=a.a;switch(i.g){case 0:h=a.a;break;case 1:h=a.b;break;case 2:h=a.i;break;case 3:h=a.e;break;case 4:h=a.f;break;default:throw Adb(new agb(eGe+(i.f!=null?i.f:''+i.g)));}a.d=new qbd(h,v,g);pQb(a.d,(OQb(),MQb),TD(Gxd(a.c,dcd)));a.d.c=Heb(TD(Gxd(a.c,ccd)));if(tCd(a.c).i==0){return a.d}for(l=new dMd(tCd(a.c));l.e!=l.i.gc();){k=RD(bMd(l),27);n=k.g/2;m=k.f/2;w=new rjd(k.i+n,k.j+m);while(Ujb(a.g,w)){Zid(w,($wnd.Math.random()-0.5)*Vze,($wnd.Math.random()-0.5)*Vze);}p=RD(Gxd(k,(umd(),eld)),140);q=new TQb(w,new Uid(w.a-n-a.j/2-p.b,w.b-m-a.j/2-p.d,k.g+a.j+(p.b+p.c),k.f+a.j+(p.d+p.a)));Rmb(a.d.i,q);Zjb(a.g,w,new Ptd(q,k));}switch(u.g){case 0:if(t==null){a.d.d=RD(Vmb(a.d.i,0),68);}else {for(s=new Anb(a.d.i);s.a0?G+1:1;}for(g=new Anb(w.g);g.a0?G+1:1;}}a.c[j]==0?Mub(a.e,p):a.a[j]==0&&Mub(a.f,p);++j;}o=-1;n=1;l=new bnb;a.d=RD(mQb(b,(Ywc(),Lwc)),234);while(L>0){while(a.e.b!=0){I=RD(Uub(a.e),10);a.b[I.p]=o--;TFc(a,I);--L;}while(a.f.b!=0){J=RD(Uub(a.f),10);a.b[J.p]=n++;TFc(a,J);--L;}if(L>0){m=qwe;for(s=new Anb(t);s.a=m){if(u>m){l.c.length=0;m=u;}ZEb(l.c,p);}}}k=a.sg(l);a.b[k.p]=n++;TFc(a,k);--L;}}H=t.c.length+1;for(j=0;ja.b[K]){X0b(d,true);pQb(b,awc,(Geb(),true));}}}}a.a=null;a.c=null;a.b=null;Xub(a.f);Xub(a.e);c.Vg();} + function usd(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;v=RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166);k=new Ejd;u=new Tsb;w=xsd(v);rtb(u.f,v,w);m=new Tsb;d=new Yub;for(o=Fl(Al(cD(WC(cJ,1),rve,20,0,[(!b.d&&(b.d=new Yie(G4,b,8,5)),b.d),(!b.e&&(b.e=new Yie(G4,b,7,4)),b.e)])));gs(o);){n=RD(hs(o),74);if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i!=1){throw Adb(new agb(tHe+(!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i))}if(n!=a){q=RD(QHd((!n.a&&(n.a=new C5d(F4,n,6,6)),n.a),0),166);Pub(d,q,d.c.b,d.c);p=RD(Wd(qtb(u.f,q)),13);if(!p){p=xsd(q);rtb(u.f,q,p);}l=c?ojd(new sjd(RD(Vmb(w,w.c.length-1),8)),RD(Vmb(p,p.c.length-1),8)):ojd(new sjd((tFb(0,w.c.length),RD(w.c[0],8))),(tFb(0,p.c.length),RD(p.c[0],8)));rtb(m.f,q,l);}}if(d.b!=0){r=RD(Vmb(w,c?w.c.length-1:0),8);for(j=1;j1&&(Pub(k,r,k.c.b,k.c),true);gvb(e);}}}r=s;}}return k} + function S_c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;c.Ug(_Ee,1);D=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new e0c),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);k=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new g0c(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);o=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new i0c(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);p=$C(Z$,NEe,40,b.gc(),0,1);for(g=0;g=0&&C=0&&!p[n]){p[n]=e;k.gd(h);--h;break}n=C-m;if(n=0&&!p[n]){p[n]=e;k.gd(h);--h;break}}}o.jd(new k0c);for(i=p.length-1;i>=0;i--){if(!p[i]&&!o.dc()){p[i]=RD(o.Xb(0),40);o.gd(0);}}for(j=0;j=0;i--){Mub(c,(tFb(i,g.c.length),RD(g.c[i],8)));}return c} + function l9c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;t=Kfb(UD(Gxd(b,(X6c(),W6c))));n=Kfb(UD(Gxd(b,U6c)));m=Kfb(UD(Gxd(b,R6c)));Bad((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));r=U8c((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),t,a.b);for(q=0;qm&&Fad((tFb(m,b.c.length),RD(b.c[m],186)),k);k=null;while(b.c.length>m&&(tFb(m,b.c.length),RD(b.c[m],186)).a.c.length==0){Ymb(b,(tFb(m,b.c.length),b.c[m]));}}if(!k){--g;continue}if(!Heb(TD(RD(Vmb(k.b,0),27).of((X7c(),D7c))))&&K8c(b,o,f,k,q,c,m,d)){p=true;continue}if(q){n=o.b;l=k.f;if(!Heb(TD(RD(Vmb(k.b,0),27).of(D7c)))&&L8c(b,o,f,k,c,m,d,e)){p=true;if(n=a.j){a.a=-1;a.c=1;return}b=ihb(a.i,a.d++);a.a=b;if(a.b==1){switch(b){case 92:d=10;if(a.d>=a.j)throw Adb(new Lqe(TId((Hde(),VIe))));a.a=ihb(a.i,a.d++);break;case 45:if((a.e&512)==512&&a.d=a.j)break;if(ihb(a.i,a.d)!=63)break;if(++a.d>=a.j)throw Adb(new Lqe(TId((Hde(),WIe))));b=ihb(a.i,a.d++);switch(b){case 58:d=13;break;case 61:d=14;break;case 33:d=15;break;case 91:d=19;break;case 62:d=18;break;case 60:if(a.d>=a.j)throw Adb(new Lqe(TId((Hde(),WIe))));b=ihb(a.i,a.d++);if(b==61){d=16;}else if(b==33){d=17;}else throw Adb(new Lqe(TId((Hde(),XIe))));break;case 35:while(a.d=a.j)throw Adb(new Lqe(TId((Hde(),VIe))));a.a=ihb(a.i,a.d++);break;default:d=0;}a.c=d;} + function oXc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;c.Ug('Process compaction',1);if(!Heb(TD(mQb(b,(h_c(),F$c))))){return}e=RD(mQb(b,H$c),88);n=Kfb(UD(mQb(b,_$c)));pXc(a,b,e);lXc(b,n/2/2);o=b.b;tvb(o,new EXc(e));for(j=Sub(o,0);j.b!=j.d.c;){i=RD(evb(j),40);if(!Heb(TD(mQb(i,(q$c(),n$c))))){d=mXc(i,e);p=lWc(i,b);l=0;m=0;if(d){q=d.e;switch(e.g){case 2:l=q.a-n-i.f.a;p.e.a-n-i.f.al&&(l=p.e.a+p.f.a+n);m=l+i.f.a;break;case 4:l=q.b-n-i.f.b;p.e.b-n-i.f.bl&&(l=p.e.b+p.f.b+n);m=l+i.f.b;}}else if(p){switch(e.g){case 2:l=p.e.a-n-i.f.a;m=l+i.f.a;break;case 1:l=p.e.a+p.f.a+n;m=l+i.f.a;break;case 4:l=p.e.b-n-i.f.b;m=l+i.f.b;break;case 3:l=p.e.b+p.f.b+n;m=l+i.f.b;}}if(dE(mQb(b,K$c))===dE((LZc(),IZc))){f=l;g=m;h=DDb(CDb(new SDb(null,new Swb(a.a,16)),new IXc(f,g)));if(h.a!=null){e==(Cmd(),ymd)||e==zmd?(i.e.a=l):(i.e.b=l);}else {e==(Cmd(),ymd)||e==Bmd?(h=DDb(CDb(NDb(new SDb(null,new Swb(a.a,16))),new WXc(f)))):(h=DDb(CDb(NDb(new SDb(null,new Swb(a.a,16))),new YXc(f))));h.a!=null&&(e==ymd||e==zmd?(i.e.a=Kfb(UD((sFb(h.a!=null),RD(h.a,42)).a))):(i.e.b=Kfb(UD((sFb(h.a!=null),RD(h.a,42)).a))));}if(h.a!=null){k=Wmb(a.a,(sFb(h.a!=null),h.a),0);if(k>0&&k!=RD(mQb(i,f_c),17).a){pQb(i,UZc,(Geb(),true));pQb(i,f_c,sgb(k));}}}else {e==(Cmd(),ymd)||e==zmd?(i.e.a=l):(i.e.b=l);}}}c.Vg();} + function Fre(a){var b,c,d,e,f,g,h,i,j;a.b=1;Mqe(a);b=null;if(a.c==0&&a.a==94){Mqe(a);b=(Vse(),Vse(),new xte(4));rte(b,0,MLe);h=(new xte(4));}else {h=(Vse(),Vse(),new xte(4));}e=true;while((j=a.c)!=1){if(j==0&&a.a==93&&!e){if(b){wte(b,h);h=b;}break}c=a.a;d=false;if(j==10){switch(c){case 100:case 68:case 119:case 87:case 115:case 83:ute(h,Ere(c));d=true;break;case 105:case 73:case 99:case 67:c=(ute(h,Ere(c)),-1);c<0&&(d=true);break;case 112:case 80:i=Sqe(a,c);if(!i)throw Adb(new Lqe(TId((Hde(),hJe))));ute(h,i);d=true;break;default:c=Dre(a);}}else if(j==24&&!e){if(b){wte(b,h);h=b;}f=Fre(a);wte(h,f);if(a.c!=0||a.a!=93)throw Adb(new Lqe(TId((Hde(),lJe))));break}Mqe(a);if(!d){if(j==0){if(c==91)throw Adb(new Lqe(TId((Hde(),mJe))));if(c==93)throw Adb(new Lqe(TId((Hde(),nJe))));if(c==45&&!e&&a.a!=93)throw Adb(new Lqe(TId((Hde(),oJe))))}if(a.c!=0||a.a!=45||c==45&&e){rte(h,c,c);}else {Mqe(a);if((j=a.c)==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(j==0&&a.a==93){rte(h,c,c);rte(h,45,45);}else if(j==0&&a.a==93||j==24){throw Adb(new Lqe(TId((Hde(),oJe))))}else {g=a.a;if(j==0){if(g==91)throw Adb(new Lqe(TId((Hde(),mJe))));if(g==93)throw Adb(new Lqe(TId((Hde(),nJe))));if(g==45)throw Adb(new Lqe(TId((Hde(),oJe))))}else j==10&&(g=Dre(a));Mqe(a);if(c>g)throw Adb(new Lqe(TId((Hde(),rJe))));rte(h,c,g);}}}e=false;}if(a.c==1)throw Adb(new Lqe(TId((Hde(),jJe))));vte(h);ste(h);a.b=0;Mqe(a);return h} + function EGc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;c.Ug('Coffman-Graham Layering',1);if(b.a.c.length==0){c.Vg();return}v=RD(mQb(b,(yCc(),SAc)),17).a;i=0;g=0;for(m=new Anb(b.a);m.a=v||!zGc(r,d))&&(d=BGc(b,k));g3b(r,d);for(f=new is(Mr(Z2b(r).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(a.a[e.p]){continue}p=e.c.i;--a.e[p.p];a.e[p.p]==0&&(zFb(lwb(n,p),Bxe),true);}}for(j=k.c.length-1;j>=0;--j){Rmb(b.b,(tFb(j,k.c.length),RD(k.c[j],30)));}b.a.c.length=0;c.Vg();} + function Sec(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;u=false;do{u=false;for(f=b?(new Xkb(a.a.b)).a.gc()-2:1;b?f>=0:f<(new Xkb(a.a.b)).a.gc();f+=b?-1:1){e=_5b(a.a,sgb(f));for(n=0;nRD(mQb(q,zwc),17).a)&&(t=false);}if(!t){continue}i=b?f+1:f-1;h=_5b(a.a,sgb(i));g=false;s=true;d=false;for(k=Sub(h,0);k.b!=k.d.c;){j=RD(evb(k),10);if(nQb(j,zwc)){if(j.p!=l.p){g=g|(b?RD(mQb(j,zwc),17).aRD(mQb(l,zwc),17).a);s=false;}}else if(!g&&s){if(j.k==(r3b(),n3b)){d=true;b?(m=RD(hs(new is(Mr(Z2b(j).a.Kc(),new ir))),18).c.i):(m=RD(hs(new is(Mr(a3b(j).a.Kc(),new ir))),18).d.i);if(m==l){b?(c=RD(hs(new is(Mr(a3b(j).a.Kc(),new ir))),18).d.i):(c=RD(hs(new is(Mr(Z2b(j).a.Kc(),new ir))),18).c.i);(b?RD($5b(a.a,c),17).a-RD($5b(a.a,m),17).a:RD($5b(a.a,m),17).a-RD($5b(a.a,c),17).a)<=2&&(s=false);}}}}if(d&&s){b?(c=RD(hs(new is(Mr(a3b(l).a.Kc(),new ir))),18).d.i):(c=RD(hs(new is(Mr(Z2b(l).a.Kc(),new ir))),18).c.i);(b?RD($5b(a.a,c),17).a-RD($5b(a.a,l),17).a:RD($5b(a.a,l),17).a-RD($5b(a.a,c),17).a)<=2&&c.k==(r3b(),p3b)&&(s=false);}if(g||s){p=Xec(a,l,b);while(p.a.gc()!=0){o=RD(p.a.ec().Kc().Pb(),10);p.a.Bc(o)!=null;ye(p,Xec(a,o,b));}--n;u=true;}}}}while(u)} + function Xae(a){_Ad(a.c,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#decimal']));_Ad(a.d,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#integer']));_Ad(a.e,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#boolean']));_Ad(a.f,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EBoolean',GIe,'EBoolean:Object']));_Ad(a.i,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#byte']));_Ad(a.g,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#hexBinary']));_Ad(a.j,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EByte',GIe,'EByte:Object']));_Ad(a.n,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EChar',GIe,'EChar:Object']));_Ad(a.t,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#double']));_Ad(a.u,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EDouble',GIe,'EDouble:Object']));_Ad(a.F,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#float']));_Ad(a.G,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EFloat',GIe,'EFloat:Object']));_Ad(a.I,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#int']));_Ad(a.J,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EInt',GIe,'EInt:Object']));_Ad(a.N,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#long']));_Ad(a.O,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'ELong',GIe,'ELong:Object']));_Ad(a.Z,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#short']));_Ad(a.$,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EShort',GIe,'EShort:Object']));_Ad(a._,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#string']));} + function C0c(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o;m=RD(d.a,17).a;n=RD(d.b,17).a;l=a.b;o=a.c;h=0;k=0;if(b==(Cmd(),ymd)||b==zmd){k=Uvb(QCb(HDb(GDb(new SDb(null,new Swb(c.b,16)),new b2c),new b1c)));if(l.e.b+l.f.b/2>k){j=++n;h=Kfb(UD(Lvb(JDb(GDb(new SDb(null,new Swb(c.b,16)),new d2c(e,j)),new d1c))));}else {i=++m;h=Kfb(UD(Lvb(KDb(GDb(new SDb(null,new Swb(c.b,16)),new f2c(e,i)),new h1c))));}}else {k=Uvb(QCb(HDb(GDb(new SDb(null,new Swb(c.b,16)),new x1c),new l1c)));if(l.e.a+l.f.a/2>k){j=++n;h=Kfb(UD(Lvb(JDb(GDb(new SDb(null,new Swb(c.b,16)),new z1c(e,j)),new n1c))));}else {i=++m;h=Kfb(UD(Lvb(KDb(GDb(new SDb(null,new Swb(c.b,16)),new B1c(e,i)),new r1c))));}}if(b==ymd){Oub(a.a,new rjd(Kfb(UD(mQb(l,(q$c(),f$c))))-e,h));Oub(a.a,new rjd(o.e.a+o.f.a+e+f,h));Oub(a.a,new rjd(o.e.a+o.f.a+e+f,o.e.b+o.f.b/2));Oub(a.a,new rjd(o.e.a+o.f.a,o.e.b+o.f.b/2));}else if(b==zmd){Oub(a.a,new rjd(Kfb(UD(mQb(l,(q$c(),e$c))))+e,l.e.b+l.f.b/2));Oub(a.a,new rjd(l.e.a+l.f.a+e,h));Oub(a.a,new rjd(o.e.a-e-f,h));Oub(a.a,new rjd(o.e.a-e-f,o.e.b+o.f.b/2));Oub(a.a,new rjd(o.e.a,o.e.b+o.f.b/2));}else if(b==Bmd){Oub(a.a,new rjd(h,Kfb(UD(mQb(l,(q$c(),f$c))))-e));Oub(a.a,new rjd(h,o.e.b+o.f.b+e+f));Oub(a.a,new rjd(o.e.a+o.f.a/2,o.e.b+o.f.b+e+f));Oub(a.a,new rjd(o.e.a+o.f.a/2,o.e.b+o.f.b+e));}else {a.a.b==0||(RD(Rub(a.a),8).b=Kfb(UD(mQb(l,(q$c(),e$c))))+e*RD(g.b,17).a);Oub(a.a,new rjd(h,Kfb(UD(mQb(l,(q$c(),e$c))))+e*RD(g.b,17).a));Oub(a.a,new rjd(h,o.e.b-e*RD(g.a,17).a-f));}return new Ptd(sgb(m),sgb(n))} + function ASd(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;g=true;l=null;d=null;e=null;b=false;n=_Rd;j=null;f=null;h=0;i=sSd(a,h,ZRd,$Rd);if(i=0&&lhb(a.substr(h,'//'.length),'//')){h+=2;i=sSd(a,h,aSd,bSd);d=(AFb(h,i,a.length),a.substr(h,i-h));h=i;}else if(l!=null&&(h==a.length||(BFb(h,a.length),a.charCodeAt(h)!=47))){g=false;i=rhb(a,Fhb(35),h);i==-1&&(i=a.length);d=(AFb(h,i,a.length),a.substr(h,i-h));h=i;}if(!c&&h0&&ihb(k,k.length-1)==58){e=k;h=i;}}if(hqQc(f))&&(l=f);}}!l&&(l=(tFb(0,q.c.length),RD(q.c[0],185)));for(p=new Anb(b.b);p.al){F=0;G+=k+A;k=0;}FVc(v,g,F,G);b=$wnd.Math.max(b,F+w.a);k=$wnd.Math.max(k,w.b);F+=w.a+A;}u=new Tsb;c=new Tsb;for(C=new Anb(a);C.a=-1900?1:0;c>=4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Qwe,Rwe])[h]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['BC','AD'])[h]);break;case 121:AA(a,c,d);break;case 77:zA(a,c,d);break;case 107:i=e.q.getHours();i==0?UA(a,24,c):UA(a,i,c);break;case 83:yA(a,c,e);break;case 69:k=d.q.getDay();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['S','M','T','W','T','F','S'])[k]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Swe,Twe,Uwe,Vwe,Wwe,Xwe,Ywe])[k]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[k]);break;case 97:e.q.getHours()>=12&&e.q.getHours()<24?Zhb(a,cD(WC(qJ,1),Nve,2,6,['AM','PM'])[1]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['AM','PM'])[0]);break;case 104:l=e.q.getHours()%12;l==0?UA(a,12,c):UA(a,l,c);break;case 75:m=e.q.getHours()%12;UA(a,m,c);break;case 72:n=e.q.getHours();UA(a,n,c);break;case 99:o=d.q.getDay();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['S','M','T','W','T','F','S'])[o]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Swe,Twe,Uwe,Vwe,Wwe,Xwe,Ywe])[o]):c==3?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[o]):UA(a,o,1);break;case 76:p=d.q.getMonth();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['J','F','M','A','M','J','J','A','S','O','N','D'])[p]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe])[p]):c==3?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec'])[p]):UA(a,p+1,c);break;case 81:q=d.q.getMonth()/3|0;c<4?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Q1','Q2','Q3','Q4'])[q]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['1st quarter','2nd quarter','3rd quarter','4th quarter'])[q]);break;case 100:r=d.q.getDate();UA(a,r,c);break;case 109:j=e.q.getMinutes();UA(a,j,c);break;case 115:g=e.q.getSeconds();UA(a,g,c);break;case 122:c<4?Zhb(a,f.c[0]):Zhb(a,f.c[1]);break;case 118:Zhb(a,f.b);break;case 90:c<3?Zhb(a,cB(f)):c==3?Zhb(a,bB(f)):Zhb(a,eB(f.a));break;default:return false;}return true} + function f5b(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H;X4b(b);i=RD(QHd((!b.b&&(b.b=new Yie(E4,b,4,7)),b.b),0),84);k=RD(QHd((!b.c&&(b.c=new Yie(E4,b,5,8)),b.c),0),84);h=AGd(i);j=AGd(k);g=(!b.a&&(b.a=new C5d(F4,b,6,6)),b.a).i==0?null:RD(QHd((!b.a&&(b.a=new C5d(F4,b,6,6)),b.a),0),166);A=RD(Wjb(a.a,h),10);F=RD(Wjb(a.a,j),10);B=null;G=null;if(ZD(i,193)){w=RD(Wjb(a.a,i),305);if(ZD(w,12)){B=RD(w,12);}else if(ZD(w,10)){A=RD(w,10);B=RD(Vmb(A.j,0),12);}}if(ZD(k,193)){D=RD(Wjb(a.a,k),305);if(ZD(D,12)){G=RD(D,12);}else if(ZD(D,10)){F=RD(D,10);G=RD(Vmb(F.j,0),12);}}if(!A||!F){throw Adb(new Ked('The source or the target of edge '+b+' could not be found. '+'This usually happens when an edge connects a node laid out by ELK Layered to a node in '+'another level of hierarchy laid out by either another instance of ELK Layered or another '+'layout algorithm alltogether. The former can be solved by setting the hierarchyHandling '+'option to INCLUDE_CHILDREN.'))}p=new a1b;kQb(p,b);pQb(p,(Ywc(),Awc),b);pQb(p,(yCc(),RAc),null);n=RD(mQb(d,kwc),21);A==F&&n.Fc((ovc(),nvc));if(!B){v=(BEc(),zEc);C=null;if(!!g&&Dod(RD(mQb(A,BBc),101))){C=new rjd(g.j,g.k);Fsd(C,kzd(b));Gsd(C,c);if(NGd(j,h)){v=yEc;$id(C,A.n);}}B=g2b(A,C,v,d);}if(!G){v=(BEc(),yEc);H=null;if(!!g&&Dod(RD(mQb(F,BBc),101))){H=new rjd(g.b,g.c);Fsd(H,kzd(b));Gsd(H,c);}G=g2b(F,H,v,Y2b(F));}Y0b(p,B);Z0b(p,G);(B.e.c.length>1||B.g.c.length>1||G.e.c.length>1||G.g.c.length>1)&&n.Fc((ovc(),ivc));for(m=new dMd((!b.n&&(b.n=new C5d(I4,b,1,7)),b.n));m.e!=m.i.gc();){l=RD(bMd(m),135);if(!Heb(TD(Gxd(l,pBc)))&&!!l.a){q=h5b(l);Rmb(p.b,q);switch(RD(mQb(q,wAc),278).g){case 1:case 2:n.Fc((ovc(),gvc));break;case 0:n.Fc((ovc(),evc));pQb(q,wAc,(Omd(),Lmd));}}}f=RD(mQb(d,oAc),322);r=RD(mQb(d,kBc),323);e=f==(stc(),ptc)||r==(JDc(),FDc);if(!!g&&(!g.a&&(g.a=new XZd(D4,g,5)),g.a).i!=0&&e){s=ssd(g);o=new Ejd;for(u=Sub(s,0);u.b!=u.d.c;){t=RD(evb(u),8);Mub(o,new sjd(t));}pQb(p,Bwc,o);}return p} + function F0c(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;C=0;D=0;A=new Tsb;v=RD(Lvb(JDb(GDb(new SDb(null,new Swb(a.b,16)),new v1c),new Z0c)),17).a+1;B=$C(kE,Pwe,28,v,15,1);q=$C(kE,Pwe,28,v,15,1);for(p=0;p1){for(h=G+1;hj.b.e.b*(1-r)+j.c.e.b*r){break}}if(w.gc()>0){H=j.a.b==0?ajd(j.b.e):RD(Rub(j.a),8);t=$id(ajd(RD(w.Xb(w.gc()-1),40).e),RD(w.Xb(w.gc()-1),40).f);m=$id(ajd(RD(w.Xb(0),40).e),RD(w.Xb(0),40).f);if(o>=w.gc()-1&&H.b>t.b&&j.c.e.b>t.b){continue}if(o<=0&&H.bj.b.e.a*(1-r)+j.c.e.a*r){break}}if(w.gc()>0){H=j.a.b==0?ajd(j.b.e):RD(Rub(j.a),8);t=$id(ajd(RD(w.Xb(w.gc()-1),40).e),RD(w.Xb(w.gc()-1),40).f);m=$id(ajd(RD(w.Xb(0),40).e),RD(w.Xb(0),40).f);if(o>=w.gc()-1&&H.a>t.a&&j.c.e.a>t.a){continue}if(o<=0&&H.a=Kfb(UD(mQb(a,(q$c(),$Zc))))&&++D;}else {n.f&&n.d.e.a<=Kfb(UD(mQb(a,(q$c(),ZZc))))&&++C;n.g&&n.c.e.a+n.c.f.a>=Kfb(UD(mQb(a,(q$c(),YZc))))&&++D;}}}else if(u==0){H0c(j);}else if(u<0){++B[G];++q[I];F=C0c(j,b,a,new Ptd(sgb(C),sgb(D)),c,d,new Ptd(sgb(q[I]),sgb(B[G])));C=RD(F.a,17).a;D=RD(F.b,17).a;}}} + function qrc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;d=b;i=c;if(a.b&&d.j==(qpd(),ppd)&&i.j==(qpd(),ppd)){s=d;d=i;i=s;}if(Ujb(a.a,d)){if(Zsb(RD(Wjb(a.a,d),49),i)){return 1}}else {Zjb(a.a,d,new _sb);}if(Ujb(a.a,i)){if(Zsb(RD(Wjb(a.a,i),49),d)){return -1}}else {Zjb(a.a,i,new _sb);}if(Ujb(a.d,d)){if(Zsb(RD(Wjb(a.d,d),49),i)){return -1}}else {Zjb(a.d,d,new _sb);}if(Ujb(a.d,i)){if(Zsb(RD(Wjb(a.a,i),49),d)){return 1}}else {Zjb(a.d,i,new _sb);}if(d.j!=i.j){r=yrc(d.j,i.j);r==-1?rrc(a,i,d):rrc(a,d,i);return r}if(d.e.c.length!=0&&i.e.c.length!=0){if(a.b){r=orc(d,i);if(r!=0){r==-1?rrc(a,i,d):r==1&&rrc(a,d,i);return r}}f=RD(Vmb(d.e,0),18).c.i;k=RD(Vmb(i.e,0),18).c.i;if(f==k){e=RD(mQb(RD(Vmb(d.e,0),18),(Ywc(),zwc)),17).a;j=RD(mQb(RD(Vmb(i.e,0),18),zwc),17).a;e>j?rrc(a,d,i):rrc(a,i,d);return ej?1:0}for(o=a.c,p=0,q=o.length;pj?rrc(a,d,i):rrc(a,i,d);return ej?1:0}if(a.b){r=orc(d,i);if(r!=0){r==-1?rrc(a,i,d):r==1&&rrc(a,d,i);return r}}g=0;l=0;nQb(RD(Vmb(d.g,0),18),zwc)&&(g=RD(mQb(RD(Vmb(d.g,0),18),zwc),17).a);nQb(RD(Vmb(i.g,0),18),zwc)&&(l=RD(mQb(RD(Vmb(d.g,0),18),zwc),17).a);if(!!h&&h==m){if(Heb(TD(mQb(RD(Vmb(d.g,0),18),Nwc)))&&!Heb(TD(mQb(RD(Vmb(i.g,0),18),Nwc)))){rrc(a,d,i);return 1}else if(!Heb(TD(mQb(RD(Vmb(d.g,0),18),Nwc)))&&Heb(TD(mQb(RD(Vmb(i.g,0),18),Nwc)))){rrc(a,i,d);return -1}g>l?rrc(a,d,i):rrc(a,i,d);return gl?1:0}if(a.f){a.f._b(h)&&(g=RD(a.f.xc(h),17).a);a.f._b(m)&&(l=RD(a.f.xc(m),17).a);}g>l?rrc(a,d,i):rrc(a,i,d);return gl?1:0}if(d.e.c.length!=0&&i.g.c.length!=0){rrc(a,d,i);return 1}else if(d.g.c.length!=0&&i.e.c.length!=0){rrc(a,i,d);return -1}else if(nQb(d,(Ywc(),zwc))&&nQb(i,zwc)){e=RD(mQb(d,zwc),17).a;j=RD(mQb(i,zwc),17).a;e>j?rrc(a,d,i):rrc(a,i,d);return ej?1:0}else {rrc(a,i,d);return -1}} + function Yae(a){if(a.gb)return;a.gb=true;a.b=jBd(a,0);iBd(a.b,18);oBd(a.b,19);a.a=jBd(a,1);iBd(a.a,1);oBd(a.a,2);oBd(a.a,3);oBd(a.a,4);oBd(a.a,5);a.o=jBd(a,2);iBd(a.o,8);iBd(a.o,9);oBd(a.o,10);oBd(a.o,11);oBd(a.o,12);oBd(a.o,13);oBd(a.o,14);oBd(a.o,15);oBd(a.o,16);oBd(a.o,17);oBd(a.o,18);oBd(a.o,19);oBd(a.o,20);oBd(a.o,21);oBd(a.o,22);oBd(a.o,23);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);a.p=jBd(a,3);iBd(a.p,2);iBd(a.p,3);iBd(a.p,4);iBd(a.p,5);oBd(a.p,6);oBd(a.p,7);nBd(a.p);nBd(a.p);a.q=jBd(a,4);iBd(a.q,8);a.v=jBd(a,5);oBd(a.v,9);nBd(a.v);nBd(a.v);nBd(a.v);a.w=jBd(a,6);iBd(a.w,2);iBd(a.w,3);iBd(a.w,4);oBd(a.w,5);a.B=jBd(a,7);oBd(a.B,1);nBd(a.B);nBd(a.B);nBd(a.B);a.Q=jBd(a,8);oBd(a.Q,0);nBd(a.Q);a.R=jBd(a,9);iBd(a.R,1);a.S=jBd(a,10);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);a.T=jBd(a,11);oBd(a.T,10);oBd(a.T,11);oBd(a.T,12);oBd(a.T,13);oBd(a.T,14);nBd(a.T);nBd(a.T);a.U=jBd(a,12);iBd(a.U,2);iBd(a.U,3);oBd(a.U,4);oBd(a.U,5);oBd(a.U,6);oBd(a.U,7);nBd(a.U);a.V=jBd(a,13);oBd(a.V,10);a.W=jBd(a,14);iBd(a.W,18);iBd(a.W,19);iBd(a.W,20);oBd(a.W,21);oBd(a.W,22);oBd(a.W,23);a.bb=jBd(a,15);iBd(a.bb,10);iBd(a.bb,11);iBd(a.bb,12);iBd(a.bb,13);iBd(a.bb,14);iBd(a.bb,15);iBd(a.bb,16);oBd(a.bb,17);nBd(a.bb);nBd(a.bb);a.eb=jBd(a,16);iBd(a.eb,2);iBd(a.eb,3);iBd(a.eb,4);iBd(a.eb,5);iBd(a.eb,6);iBd(a.eb,7);oBd(a.eb,8);oBd(a.eb,9);a.ab=jBd(a,17);iBd(a.ab,0);iBd(a.ab,1);a.H=jBd(a,18);oBd(a.H,0);oBd(a.H,1);oBd(a.H,2);oBd(a.H,3);oBd(a.H,4);oBd(a.H,5);nBd(a.H);a.db=jBd(a,19);oBd(a.db,2);a.c=kBd(a,20);a.d=kBd(a,21);a.e=kBd(a,22);a.f=kBd(a,23);a.i=kBd(a,24);a.g=kBd(a,25);a.j=kBd(a,26);a.k=kBd(a,27);a.n=kBd(a,28);a.r=kBd(a,29);a.s=kBd(a,30);a.t=kBd(a,31);a.u=kBd(a,32);a.fb=kBd(a,33);a.A=kBd(a,34);a.C=kBd(a,35);a.D=kBd(a,36);a.F=kBd(a,37);a.G=kBd(a,38);a.I=kBd(a,39);a.J=kBd(a,40);a.L=kBd(a,41);a.M=kBd(a,42);a.N=kBd(a,43);a.O=kBd(a,44);a.P=kBd(a,45);a.X=kBd(a,46);a.Y=kBd(a,47);a.Z=kBd(a,48);a.$=kBd(a,49);a._=kBd(a,50);a.cb=kBd(a,51);a.K=kBd(a,52);} + function d5b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G;g=new Yub;w=RD(mQb(c,(yCc(),rAc)),88);p=0;ye(g,(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));while(g.b!=0){k=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),27);j=vCd(k);(dE(Gxd(j,cAc))!==dE((kEc(),hEc))||dE(Gxd(j,pAc))===dE((Ptc(),Otc))||dE(Gxd(j,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(j,eAc)))||dE(Gxd(j,Yzc))!==dE((U$b(),T$b))||dE(Gxd(j,ZAc))===dE((aEc(),TDc))||dE(Gxd(j,ZAc))===dE((aEc(),UDc))||dE(Gxd(j,$Ac))===dE((_Cc(),SCc))||dE(Gxd(j,$Ac))===dE((_Cc(),UCc)))&&!Heb(TD(Gxd(k,aAc)))&&Ixd(k,(Ywc(),zwc),sgb(p++));r=!Heb(TD(Gxd(k,pBc)));if(r){m=(!k.a&&(k.a=new C5d(J4,k,10,11)),k.a).i!=0;o=a5b(k);n=dE(Gxd(k,IAc))===dE((Fnd(),Cnd));G=!Hxd(k,(umd(),Akd))||khb(WD(Gxd(k,Akd)));u=null;if(G&&n&&(m||o)){u=Z4b(k);pQb(u,rAc,w);nQb(u,PBc)&&HCc(new RCc(Kfb(UD(mQb(u,PBc)))),u);if(RD(Gxd(k,lBc),181).gc()!=0){l=u;FDb(new SDb(null,(!k.c&&(k.c=new C5d(K4,k,9,9)),new Swb(k.c,16))),new u5b(l));V4b(k,u);}}A=c;B=RD(Wjb(a.a,vCd(k)),10);!!B&&(A=B.e);t=i5b(a,k,A);if(u){t.e=u;u.e=t;ye(g,(!k.a&&(k.a=new C5d(J4,k,10,11)),k.a));}}}p=0;Pub(g,b,g.c.b,g.c);while(g.b!=0){f=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),27);for(i=new dMd((!f.b&&(f.b=new C5d(G4,f,12,3)),f.b));i.e!=i.i.gc();){h=RD(bMd(i),74);X4b(h);(dE(Gxd(b,cAc))!==dE((kEc(),hEc))||dE(Gxd(b,pAc))===dE((Ptc(),Otc))||dE(Gxd(b,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(b,eAc)))||dE(Gxd(b,Yzc))!==dE((U$b(),T$b))||dE(Gxd(b,ZAc))===dE((aEc(),TDc))||dE(Gxd(b,ZAc))===dE((aEc(),UDc))||dE(Gxd(b,$Ac))===dE((_Cc(),SCc))||dE(Gxd(b,$Ac))===dE((_Cc(),UCc)))&&Ixd(h,(Ywc(),zwc),sgb(p++));D=AGd(RD(QHd((!h.b&&(h.b=new Yie(E4,h,4,7)),h.b),0),84));F=AGd(RD(QHd((!h.c&&(h.c=new Yie(E4,h,5,8)),h.c),0),84));if(Heb(TD(Gxd(h,pBc)))||Heb(TD(Gxd(D,pBc)))||Heb(TD(Gxd(F,pBc)))){continue}q=ozd(h)&&Heb(TD(Gxd(D,NAc)))&&Heb(TD(Gxd(h,OAc)));v=f;q||NGd(F,D)?(v=D):NGd(D,F)&&(v=F);A=c;B=RD(Wjb(a.a,v),10);!!B&&(A=B.e);s=f5b(a,h,v,A);pQb(s,(Ywc(),Zvc),_4b(a,h,b,c));}n=dE(Gxd(f,IAc))===dE((Fnd(),Cnd));if(n){for(e=new dMd((!f.a&&(f.a=new C5d(J4,f,10,11)),f.a));e.e!=e.i.gc();){d=RD(bMd(e),27);G=!Hxd(d,(umd(),Akd))||khb(WD(Gxd(d,Akd)));C=dE(Gxd(d,IAc))===dE(Cnd);G&&C&&(Pub(g,d,g.c.b,g.c),true);}}}} + function Ywc(){Ywc=geb;var a,b;Awc=new jGd(rAe);Zvc=new jGd('coordinateOrigin');Kwc=new jGd('processors');Yvc=new kGd('compoundNode',(Geb(),false));nwc=new kGd('insideConnections',false);Bwc=new jGd('originalBendpoints');Cwc=new jGd('originalDummyNodePosition');Dwc=new jGd('originalLabelEdge');Mwc=new jGd('representedLabels');cwc=new jGd('endLabels');dwc=new jGd('endLabel.origin');swc=new kGd('labelSide',(Pnd(),Ond));ywc=new kGd('maxEdgeThickness',0);Nwc=new kGd('reversed',false);Lwc=new jGd(sAe);vwc=new kGd('longEdgeSource',null);wwc=new kGd('longEdgeTarget',null);uwc=new kGd('longEdgeHasLabelDummies',false);twc=new kGd('longEdgeBeforeLabelDummy',false);bwc=new kGd('edgeConstraint',(huc(),fuc));pwc=new jGd('inLayerLayoutUnit');owc=new kGd('inLayerConstraint',(Gvc(),Evc));qwc=new kGd('inLayerSuccessorConstraint',new bnb);rwc=new kGd('inLayerSuccessorConstraintBetweenNonDummies',false);Iwc=new jGd('portDummy');$vc=new kGd('crossingHint',sgb(0));kwc=new kGd('graphProperties',(b=RD(mfb(iX),9),new Fsb(b,RD(WEb(b,b.length),9),0)));hwc=new kGd('externalPortSide',(qpd(),opd));iwc=new kGd('externalPortSize',new pjd);fwc=new jGd('externalPortReplacedDummies');gwc=new jGd('externalPortReplacedDummy');ewc=new kGd('externalPortConnections',(a=RD(mfb(E3),9),new Fsb(a,RD(WEb(a,a.length),9),0)));Jwc=new kGd(Xye,0);Uvc=new jGd('barycenterAssociates');Xwc=new jGd('TopSideComments');Vvc=new jGd('BottomSideComments');Xvc=new jGd('CommentConnectionPort');mwc=new kGd('inputCollect',false);Gwc=new kGd('outputCollect',false);awc=new kGd('cyclic',false);_vc=new jGd('crossHierarchyMap');Wwc=new jGd('targetOffset');new kGd('splineLabelSize',new pjd);Qwc=new jGd('spacings');Hwc=new kGd('partitionConstraint',false);Wvc=new jGd('breakingPoint.info');Uwc=new jGd('splines.survivingEdge');Twc=new jGd('splines.route.start');Rwc=new jGd('splines.edgeChain');Fwc=new jGd('originalPortConstraints');Pwc=new jGd('selfLoopHolder');Swc=new jGd('splines.nsPortY');zwc=new jGd('modelOrder');xwc=new jGd('longEdgeTargetNode');jwc=new kGd(GBe,false);Owc=new kGd(GBe,false);lwc=new jGd('layerConstraints.hiddenNodes');Ewc=new jGd('layerConstraints.opposidePort');Vwc=new jGd('targetNode.modelOrder');} + function D0c(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o;for(l=Sub(a.b,0);l.b!=l.d.c;){k=RD(evb(l),40);if(lhb(k.c,IEe)){continue}f=RD(zDb(new SDb(null,new Swb(hWc(k,a),16)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);b==(Cmd(),ymd)||b==zmd?f.jd(new L1c):f.jd(new R1c);o=f.gc();for(e=0;e0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(i-n)/($wnd.Math.abs(h-m)/40)>50&&(n>i?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a+d/5.3,k.e.b+k.f.b*g-d/2)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a+d/5.3,k.e.b+k.f.b*g+d/2)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a,k.e.b+k.f.b*g));}else if(b==zmd){j=Kfb(UD(mQb(k,(q$c(),f$c))));if(k.e.a-d>j){Oub(RD(f.Xb(e),65).a,new rjd(j-c,k.e.b+k.f.b*g));}else if(RD(f.Xb(e),65).a.b>0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(i-n)/($wnd.Math.abs(h-m)/40)>50&&(n>i?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a-d/5.3,k.e.b+k.f.b*g-d/2)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a-d/5.3,k.e.b+k.f.b*g+d/2)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a,k.e.b+k.f.b*g));}else if(b==Bmd){j=Kfb(UD(mQb(k,(q$c(),e$c))));if(k.e.b+k.f.b+d0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(h-m)/($wnd.Math.abs(i-n)/40)>50&&(m>h?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g-d/2,k.e.b+d/5.3+k.f.b)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g+d/2,k.e.b+d/5.3+k.f.b)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,k.e.b+k.f.b));}else {j=Kfb(UD(mQb(k,(q$c(),f$c))));if(mWc(RD(f.Xb(e),65),a)){Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,RD(Rub(RD(f.Xb(e),65).a),8).b));}else if(k.e.b-d>j){Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,j-c));}else if(RD(f.Xb(e),65).a.b>0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(h-m)/($wnd.Math.abs(i-n)/40)>50&&(m>h?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g-d/2,k.e.b-d/5.3)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g+d/2,k.e.b-d/5.3)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,k.e.b));}}}} + function umd(){umd=geb;var a,b;Akd=new jGd(OGe);Tld=new jGd(PGe);Ckd=(Rjd(),Ljd);Bkd=new lGd(MDe,Ckd);Dkd=new lGd(Dze,null);Ekd=new jGd(QGe);Lkd=(ukd(),ysb(tkd,cD(WC(q3,1),jwe,298,0,[pkd])));Kkd=new lGd(YDe,Lkd);Mkd=new lGd(LDe,(Geb(),false));Okd=(Cmd(),Amd);Nkd=new lGd(PDe,Okd);Tkd=(Ymd(),Xmd);Skd=new lGd(kDe,Tkd);Wkd=new lGd(MGe,false);Ykd=(Fnd(),Dnd);Xkd=new lGd(fDe,Ykd);uld=new A3b(12);tld=new lGd(Eze,uld);ald=new lGd(dAe,false);bld=new lGd(iEe,false);sld=new lGd(gAe,false);Ild=(Bod(),Aod);Hld=new lGd(eAe,Ild);Qld=new jGd(fEe);Rld=new jGd($ze);Sld=new jGd(bAe);Vld=new jGd(cAe);dld=new Ejd;cld=new lGd(ZDe,dld);Jkd=new lGd(aEe,false);Zkd=new lGd(bEe,false);fld=new P2b;eld=new lGd(gEe,fld);rld=new lGd(JDe,false);Uld=new lGd(SGe,1);Ikd=new jGd(TGe);Hkd=new jGd(UGe);mmd=new lGd(mAe,false);new lGd(VGe,true);sgb(0);new lGd(WGe,sgb(100));new lGd(XGe,false);sgb(0);new lGd(YGe,sgb(4000));sgb(0);new lGd(ZGe,sgb(400));new lGd($Ge,false);new lGd(_Ge,false);new lGd(aHe,true);new lGd(bHe,false);Gkd=(Grd(),Frd);Fkd=new lGd(NGe,Gkd);Wld=new lGd(xDe,10);Xld=new lGd(yDe,10);Yld=new lGd(Bze,20);Zld=new lGd(zDe,10);$ld=new lGd(aAe,2);_ld=new lGd(ADe,10);bmd=new lGd(BDe,0);cmd=new lGd(EDe,5);dmd=new lGd(CDe,1);emd=new lGd(DDe,1);fmd=new lGd(_ze,20);gmd=new lGd(FDe,10);jmd=new lGd(GDe,10);amd=new jGd(HDe);imd=new Q2b;hmd=new lGd(hEe,imd);xld=new jGd(eEe);wld=false;vld=new lGd(dEe,wld);hld=new A3b(5);gld=new lGd(QDe,hld);jld=(dod(),b=RD(mfb(A3),9),new Fsb(b,RD(WEb(b,b.length),9),0));ild=new lGd(kAe,jld);Ald=(pod(),mod);zld=new lGd(TDe,Ald);Cld=new jGd(UDe);Dld=new jGd(VDe);Eld=new jGd(WDe);Bld=new jGd(XDe);lld=(a=RD(mfb(H3),9),new Fsb(a,RD(WEb(a,a.length),9),0));kld=new lGd(jAe,lld);qld=xsb((dqd(),Ypd));pld=new lGd(iAe,qld);old=new rjd(0,0);nld=new lGd(CAe,old);mld=new lGd(hAe,false);Rkd=(Omd(),Lmd);Qkd=new lGd($De,Rkd);Pkd=new lGd(fAe,false);sgb(1);new lGd(dHe,null);Fld=new jGd(cEe);Jld=new jGd(_De);Pld=(qpd(),opd);Old=new lGd(KDe,Pld);Gld=new jGd(IDe);Mld=(Pod(),xsb(Nod));Lld=new lGd(lAe,Mld);Kld=new lGd(RDe,false);Nld=new lGd(SDe,true);qmd=new lGd(nAe,1);smd=new lGd(eHe,null);lmd=new lGd(oAe,150);kmd=new lGd(pAe,1.414);nmd=new lGd(qAe,null);omd=new lGd(fHe,1);$kd=new lGd(NDe,false);_kd=new lGd(ODe,false);Ukd=new lGd(Cze,1);Vkd=(ind(),gnd);new lGd(gHe,Vkd);yld=true;rmd=(mqd(),jqd);tmd=jqd;pmd=jqd;} + function hcc(){hcc=geb;nbc=new icc('DIRECTION_PREPROCESSOR',0);kbc=new icc('COMMENT_PREPROCESSOR',1);obc=new icc('EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER',2);Ebc=new icc('INTERACTIVE_EXTERNAL_PORT_POSITIONER',3);Xbc=new icc('PARTITION_PREPROCESSOR',4);Ibc=new icc('LABEL_DUMMY_INSERTER',5);bcc=new icc('SELF_LOOP_PREPROCESSOR',6);Nbc=new icc('LAYER_CONSTRAINT_PREPROCESSOR',7);Vbc=new icc('PARTITION_MIDPROCESSOR',8);zbc=new icc('HIGH_DEGREE_NODE_LAYER_PROCESSOR',9);Rbc=new icc('NODE_PROMOTION',10);Mbc=new icc('LAYER_CONSTRAINT_POSTPROCESSOR',11);Wbc=new icc('PARTITION_POSTPROCESSOR',12);vbc=new icc('HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR',13);dcc=new icc('SEMI_INTERACTIVE_CROSSMIN_PROCESSOR',14);ebc=new icc('BREAKING_POINT_INSERTER',15);Qbc=new icc('LONG_EDGE_SPLITTER',16);Zbc=new icc('PORT_SIDE_PROCESSOR',17);Fbc=new icc('INVERTED_PORT_PROCESSOR',18);Ybc=new icc('PORT_LIST_SORTER',19);fcc=new icc('SORT_BY_INPUT_ORDER_OF_MODEL',20);Tbc=new icc('NORTH_SOUTH_PORT_PREPROCESSOR',21);fbc=new icc('BREAKING_POINT_PROCESSOR',22);Ubc=new icc(jBe,23);gcc=new icc(kBe,24);_bc=new icc('SELF_LOOP_PORT_RESTORER',25);ecc=new icc('SINGLE_EDGE_GRAPH_WRAPPER',26);Gbc=new icc('IN_LAYER_CONSTRAINT_PROCESSOR',27);sbc=new icc('END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR',28);Hbc=new icc('LABEL_AND_NODE_SIZE_PROCESSOR',29);Dbc=new icc('INNERMOST_NODE_MARGIN_CALCULATOR',30);ccc=new icc('SELF_LOOP_ROUTER',31);ibc=new icc('COMMENT_NODE_MARGIN_CALCULATOR',32);qbc=new icc('END_LABEL_PREPROCESSOR',33);Kbc=new icc('LABEL_DUMMY_SWITCHER',34);hbc=new icc('CENTER_LABEL_MANAGEMENT_PROCESSOR',35);Lbc=new icc('LABEL_SIDE_SELECTOR',36);Bbc=new icc('HYPEREDGE_DUMMY_MERGER',37);wbc=new icc('HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR',38);Obc=new icc('LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR',39);ybc=new icc('HIERARCHICAL_PORT_POSITION_PROCESSOR',40);lbc=new icc('CONSTRAINTS_POSTPROCESSOR',41);jbc=new icc('COMMENT_POSTPROCESSOR',42);Cbc=new icc('HYPERNODE_PROCESSOR',43);xbc=new icc('HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER',44);Pbc=new icc('LONG_EDGE_JOINER',45);acc=new icc('SELF_LOOP_POSTPROCESSOR',46);gbc=new icc('BREAKING_POINT_REMOVER',47);Sbc=new icc('NORTH_SOUTH_PORT_POSTPROCESSOR',48);Abc=new icc('HORIZONTAL_COMPACTOR',49);Jbc=new icc('LABEL_DUMMY_REMOVER',50);tbc=new icc('FINAL_SPLINE_BENDPOINTS_CALCULATOR',51);rbc=new icc('END_LABEL_SORTER',52);$bc=new icc('REVERSED_EDGE_RESTORER',53);pbc=new icc('END_LABEL_POSTPROCESSOR',54);ubc=new icc('HIERARCHICAL_NODE_RESIZER',55);mbc=new icc('DIRECTION_POSTPROCESSOR',56);} + function Ozc(){Ozc=geb;Uxc=($tc(),Ytc);Txc=new lGd(HBe,Uxc);jyc=new lGd(IBe,(Geb(),false));pyc=(Ovc(),Mvc);oyc=new lGd(JBe,pyc);Hyc=new lGd(KBe,false);Iyc=new lGd(LBe,true);ixc=new lGd(MBe,false);azc=(sEc(),qEc);_yc=new lGd(NBe,azc);sgb(1);izc=new lGd(OBe,sgb(7));jzc=new lGd(PBe,false);kyc=new lGd(QBe,false);Sxc=(Ptc(),Ltc);Rxc=new lGd(RBe,Sxc);Gyc=(_Cc(),ZCc);Fyc=new lGd(SBe,Gyc);wyc=(cxc(),bxc);vyc=new lGd(TBe,wyc);sgb(-1);uyc=new lGd(UBe,null);sgb(-1);xyc=new lGd(VBe,sgb(-1));sgb(-1);yyc=new lGd(WBe,sgb(4));sgb(-1);Ayc=new lGd(XBe,sgb(2));Eyc=(aEc(),$Dc);Dyc=new lGd(YBe,Eyc);sgb(0);Cyc=new lGd(ZBe,sgb(0));syc=new lGd($Be,sgb(lve));Qxc=(stc(),qtc);Pxc=new lGd(_Be,Qxc);yxc=new lGd(aCe,false);Hxc=new lGd(bCe,0.1);Nxc=new lGd(cCe,false);Jxc=new lGd(dCe,null);Kxc=new lGd(eCe,null);sgb(-1);Lxc=new lGd(fCe,null);sgb(-1);Mxc=new lGd(gCe,sgb(-1));sgb(0);zxc=new lGd(hCe,sgb(40));Fxc=(xvc(),wvc);Exc=new lGd(iCe,Fxc);Bxc=uvc;Axc=new lGd(jCe,Bxc);$yc=(JDc(),EDc);Zyc=new lGd(kCe,$yc);Pyc=new jGd(lCe);Kyc=(Cuc(),Auc);Jyc=new lGd(mCe,Kyc);Nyc=(Ouc(),Luc);Myc=new lGd(nCe,Nyc);Syc=new lGd(oCe,0.3);Uyc=new jGd(pCe);Wyc=(wDc(),uDc);Vyc=new lGd(qCe,Wyc);ayc=(KEc(),IEc);_xc=new lGd(rCe,ayc);cyc=(TEc(),SEc);byc=new lGd(sCe,cyc);eyc=(lFc(),kFc);dyc=new lGd(tCe,eyc);gyc=new lGd(uCe,0.2);Zxc=new lGd(vCe,2);ezc=new lGd(wCe,null);gzc=new lGd(xCe,10);fzc=new lGd(yCe,10);hzc=new lGd(zCe,20);sgb(0);bzc=new lGd(ACe,sgb(0));sgb(0);czc=new lGd(BCe,sgb(0));sgb(0);dzc=new lGd(CCe,sgb(0));jxc=new lGd(DCe,false);nxc=($uc(),Yuc);mxc=new lGd(ECe,nxc);lxc=(jtc(),itc);kxc=new lGd(FCe,lxc);myc=new lGd(GCe,false);sgb(0);lyc=new lGd(HCe,sgb(16));sgb(0);nyc=new lGd(ICe,sgb(5));Gzc=(DFc(),BFc);Fzc=new lGd(JCe,Gzc);kzc=new lGd(KCe,10);nzc=new lGd(LCe,1);wzc=(Etc(),Dtc);vzc=new lGd(MCe,wzc);qzc=new jGd(NCe);tzc=sgb(1);sgb(0);szc=new lGd(OCe,tzc);Lzc=(uFc(),rFc);Kzc=new lGd(PCe,Lzc);Hzc=new jGd(QCe);Bzc=new lGd(RCe,true);zzc=new lGd(SCe,2);Dzc=new lGd(TCe,true);Yxc=(tuc(),ruc);Xxc=new lGd(UCe,Yxc);Wxc=(btc(),Zsc);Vxc=new lGd(VCe,Wxc);xxc=(kEc(),hEc);wxc=new lGd(WCe,xxc);vxc=new lGd(XCe,false);uxc=new lGd(YCe,false);pxc=(U$b(),T$b);oxc=new lGd(ZCe,pxc);txc=(lDc(),iDc);sxc=new lGd($Ce,txc);qxc=new lGd(_Ce,0);rxc=new lGd(aDe,0);ryc=Ntc;qyc=ptc;zyc=YCc;Byc=YCc;tyc=TCc;Ixc=(Fnd(),Cnd);Oxc=qtc;Gxc=qtc;Cxc=qtc;Dxc=Cnd;Qyc=HDc;Ryc=EDc;Lyc=EDc;Oyc=EDc;Tyc=GDc;Yyc=HDc;Xyc=HDc;fyc=(Ymd(),Wmd);hyc=Wmd;iyc=kFc;$xc=Vmd;lzc=CFc;mzc=AFc;ozc=CFc;pzc=AFc;xzc=CFc;yzc=AFc;rzc=Ctc;uzc=Dtc;Mzc=CFc;Nzc=AFc;Izc=CFc;Jzc=AFc;Czc=AFc;Azc=AFc;Ezc=AFc;} + function iNc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,ab,bb,cb,db,eb,fb,gb,hb,ib,jb,kb,lb;cb=0;for(H=b,K=0,N=H.length;K0&&(a.a[U.p]=cb++);}}hb=0;for(I=c,L=0,O=I.length;L0){U=(sFb(Y.b>0),RD(Y.a.Xb(Y.c=--Y.b),12));X=0;for(h=new Anb(U.e);h.a0){if(U.j==(qpd(),Yod)){a.a[U.p]=hb;++hb;}else {a.a[U.p]=hb+P+R;++R;}}}hb+=R;}W=new Tsb;o=new Iub;for(G=b,J=0,M=G.length;Jj.b&&(j.b=Z);}else if(U.i.c==bb){Zj.c&&(j.c=Z);}}}Wnb(p,0,p.length,null);gb=$C(kE,Pwe,28,p.length,15,1);d=$C(kE,Pwe,28,hb+1,15,1);for(r=0;r0){A%2>0&&(e+=kb[A+1]);A=(A-1)/2|0;++kb[A];}}C=$C(NY,rve,374,p.length*2,0,1);for(u=0;u0&&(ltd(J.f),false)){if(RD(Gxd(r,nmd),280)==jqd){throw Adb(new Jed('Topdown Layout Providers should only be used on parallel nodes.'))}fE(ltd(J.f));null.Um();zyd(r,$wnd.Math.max(r.g,null.Vm),$wnd.Math.max(r.f,null.Vm));}else if(Gxd(r,smd)!=null){h=RD(Gxd(r,smd),347);W=h.Tg(r);zyd(r,$wnd.Math.max(r.g,W.a),$wnd.Math.max(r.f,W.b));}}}O=RD(Gxd(b,tld),107);n=b.g-(O.b+O.c);m=b.f-(O.d+O.a);Z.bh('Available Child Area: ('+n+'|'+m+')');Ixd(b,Dkd,n/m);Ced(b,e,d.eh(M));if(RD(Gxd(b,nmd),280)==lqd){psd(b);zyd(b,O.b+Kfb(UD(Gxd(b,Ikd)))+O.c,O.d+Kfb(UD(Gxd(b,Hkd)))+O.a);}Z.bh('Executed layout algorithm: '+WD(Gxd(b,Akd))+' on node '+b.k);if(RD(Gxd(b,nmd),280)==jqd){if(n<0||m<0){throw Adb(new Jed('The size defined by the parent parallel node is too small for the space provided by the paddings of the child hierarchical node. '+b.k))}Hxd(b,Ikd)||Hxd(b,Hkd)||psd(b);p=Kfb(UD(Gxd(b,Ikd)));o=Kfb(UD(Gxd(b,Hkd)));Z.bh('Desired Child Area: ('+p+'|'+o+')');Q=n/p;R=m/o;P=$wnd.Math.min(Q,$wnd.Math.min(R,Kfb(UD(Gxd(b,omd)))));Ixd(b,qmd,P);Z.bh(b.k+' -- Local Scale Factor (X|Y): ('+Q+'|'+R+')');u=RD(Gxd(b,Kkd),21);f=0;g=0;P'?":lhb(XIe,a)?"'(?<' or '(? toIndex: ',bye=', toIndex: ',cye='Index: ',dye=', Size: ',eye='org.eclipse.elk.alg.common',fye={50:1},gye='org.eclipse.elk.alg.common.compaction',hye='Scanline/EventHandler',iye='org.eclipse.elk.alg.common.compaction.oned',jye='CNode belongs to another CGroup.',kye='ISpacingsHandler/1',lye='The ',mye=' instance has been finished already.',nye='The direction ',oye=' is not supported by the CGraph instance.',pye='OneDimensionalCompactor',qye='OneDimensionalCompactor/lambda$0$Type',rye='Quadruplet',sye='ScanlineConstraintCalculator',tye='ScanlineConstraintCalculator/ConstraintsScanlineHandler',uye='ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type',vye='ScanlineConstraintCalculator/Timestamp',wye='ScanlineConstraintCalculator/lambda$0$Type',xye={178:1,46:1},yye='org.eclipse.elk.alg.common.compaction.options',zye='org.eclipse.elk.core.data',Aye='org.eclipse.elk.polyomino.traversalStrategy',Bye='org.eclipse.elk.polyomino.lowLevelSort',Cye='org.eclipse.elk.polyomino.highLevelSort',Dye='org.eclipse.elk.polyomino.fill',Eye={134:1},Fye='polyomino',Gye='org.eclipse.elk.alg.common.networksimplex',Hye={183:1,3:1,4:1},Iye='org.eclipse.elk.alg.common.nodespacing',Jye='org.eclipse.elk.alg.common.nodespacing.cellsystem',Kye='CENTER',Lye={217:1,336:1},Mye={3:1,4:1,5:1,603:1},Nye='LEFT',Oye='RIGHT',Pye='Vertical alignment cannot be null',Qye='BOTTOM',Rye='org.eclipse.elk.alg.common.nodespacing.internal',Sye='UNDEFINED',Tye=0.01,Uye='org.eclipse.elk.alg.common.nodespacing.internal.algorithm',Vye='LabelPlacer/lambda$0$Type',Wye='LabelPlacer/lambda$1$Type',Xye='portRatioOrPosition',Yye='org.eclipse.elk.alg.common.overlaps',Zye='DOWN',$ye='org.eclipse.elk.alg.common.polyomino',_ye='NORTH',aze='EAST',bze='SOUTH',cze='WEST',dze='org.eclipse.elk.alg.common.polyomino.structures',eze='Direction',fze='Grid is only of size ',gze='. Requested point (',hze=') is out of bounds.',ize=' Given center based coordinates were (',jze='org.eclipse.elk.graph.properties',kze='IPropertyHolder',lze={3:1,96:1,137:1},mze='org.eclipse.elk.alg.common.spore',nze='org.eclipse.elk.alg.common.utils',oze={205:1},pze='org.eclipse.elk.core',qze='Connected Components Compaction',rze='org.eclipse.elk.alg.disco',sze='org.eclipse.elk.alg.disco.graph',tze='org.eclipse.elk.alg.disco.options',uze='CompactionStrategy',vze='org.eclipse.elk.disco.componentCompaction.strategy',wze='org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm',xze='org.eclipse.elk.disco.debug.discoGraph',yze='org.eclipse.elk.disco.debug.discoPolys',zze='componentCompaction',Aze='org.eclipse.elk.disco',Bze='org.eclipse.elk.spacing.componentComponent',Cze='org.eclipse.elk.edge.thickness',Dze='org.eclipse.elk.aspectRatio',Eze='org.eclipse.elk.padding',Fze='org.eclipse.elk.alg.disco.transform',Gze=1.5707963267948966,Hze=1.7976931348623157E308,Ize={3:1,4:1,5:1,198:1},Jze={3:1,6:1,4:1,5:1,100:1,115:1},Kze='org.eclipse.elk.alg.force',Lze='ComponentsProcessor',Mze='ComponentsProcessor/1',Nze='ElkGraphImporter/lambda$0$Type',Oze='org.eclipse.elk.alg.force.graph',Pze='Component Layout',Qze='org.eclipse.elk.alg.force.model',Rze='org.eclipse.elk.force.model',Sze='org.eclipse.elk.force.iterations',Tze='org.eclipse.elk.force.repulsivePower',Uze='org.eclipse.elk.force.temperature',Vze=0.001,Wze='org.eclipse.elk.force.repulsion',Xze='org.eclipse.elk.alg.force.options',Yze=1.600000023841858,Zze='org.eclipse.elk.force',$ze='org.eclipse.elk.priority',_ze='org.eclipse.elk.spacing.nodeNode',aAe='org.eclipse.elk.spacing.edgeLabel',bAe='org.eclipse.elk.randomSeed',cAe='org.eclipse.elk.separateConnectedComponents',dAe='org.eclipse.elk.interactive',eAe='org.eclipse.elk.portConstraints',fAe='org.eclipse.elk.edgeLabels.inline',gAe='org.eclipse.elk.omitNodeMicroLayout',hAe='org.eclipse.elk.nodeSize.fixedGraphSize',iAe='org.eclipse.elk.nodeSize.options',jAe='org.eclipse.elk.nodeSize.constraints',kAe='org.eclipse.elk.nodeLabels.placement',lAe='org.eclipse.elk.portLabels.placement',mAe='org.eclipse.elk.topdownLayout',nAe='org.eclipse.elk.topdown.scaleFactor',oAe='org.eclipse.elk.topdown.hierarchicalNodeWidth',pAe='org.eclipse.elk.topdown.hierarchicalNodeAspectRatio',qAe='org.eclipse.elk.topdown.nodeType',rAe='origin',sAe='random',tAe='boundingBox.upLeft',uAe='boundingBox.lowRight',vAe='org.eclipse.elk.stress.fixed',wAe='org.eclipse.elk.stress.desiredEdgeLength',xAe='org.eclipse.elk.stress.dimension',yAe='org.eclipse.elk.stress.epsilon',zAe='org.eclipse.elk.stress.iterationLimit',AAe='org.eclipse.elk.stress',BAe='ELK Stress',CAe='org.eclipse.elk.nodeSize.minimum',DAe='org.eclipse.elk.alg.force.stress',EAe='Layered layout',FAe='org.eclipse.elk.alg.layered',GAe='org.eclipse.elk.alg.layered.compaction.components',HAe='org.eclipse.elk.alg.layered.compaction.oned',IAe='org.eclipse.elk.alg.layered.compaction.oned.algs',JAe='org.eclipse.elk.alg.layered.compaction.recthull',KAe='org.eclipse.elk.alg.layered.components',LAe='NONE',MAe='MODEL_ORDER',NAe={3:1,6:1,4:1,9:1,5:1,126:1},OAe={3:1,6:1,4:1,5:1,150:1,100:1,115:1},PAe='org.eclipse.elk.alg.layered.compound',QAe={47:1},RAe='org.eclipse.elk.alg.layered.graph',SAe=' -> ',TAe='Not supported by LGraph',UAe='Port side is undefined',VAe={3:1,6:1,4:1,5:1,483:1,150:1,100:1,115:1},WAe={3:1,6:1,4:1,5:1,150:1,199:1,210:1,100:1,115:1},XAe={3:1,6:1,4:1,5:1,150:1,2042:1,210:1,100:1,115:1},YAe='([{"\' \t\r\n',ZAe=')]}"\' \t\r\n',$Ae='The given string contains parts that cannot be parsed as numbers.',_Ae='org.eclipse.elk.core.math',aBe={3:1,4:1,140:1,214:1,423:1},bBe={3:1,4:1,107:1,214:1,423:1},cBe='org.eclipse.elk.alg.layered.graph.transform',dBe='ElkGraphImporter',eBe='ElkGraphImporter/lambda$1$Type',fBe='ElkGraphImporter/lambda$2$Type',gBe='ElkGraphImporter/lambda$4$Type',hBe='org.eclipse.elk.alg.layered.intermediate',iBe='Node margin calculation',jBe='ONE_SIDED_GREEDY_SWITCH',kBe='TWO_SIDED_GREEDY_SWITCH',lBe='No implementation is available for the layout processor ',mBe='IntermediateProcessorStrategy',nBe="Node '",oBe='FIRST_SEPARATE',pBe='LAST_SEPARATE',qBe='Odd port side processing',rBe='org.eclipse.elk.alg.layered.intermediate.compaction',sBe='org.eclipse.elk.alg.layered.intermediate.greedyswitch',tBe='org.eclipse.elk.alg.layered.p3order.counting',uBe={230:1},vBe='org.eclipse.elk.alg.layered.intermediate.loops',wBe='org.eclipse.elk.alg.layered.intermediate.loops.ordering',xBe='org.eclipse.elk.alg.layered.intermediate.loops.routing',yBe='org.eclipse.elk.alg.layered.intermediate.preserveorder',zBe='org.eclipse.elk.alg.layered.intermediate.wrapping',ABe='org.eclipse.elk.alg.layered.options',BBe='INTERACTIVE',CBe='GREEDY',DBe='DEPTH_FIRST',EBe='EDGE_LENGTH',FBe='SELF_LOOPS',GBe='firstTryWithInitialOrder',HBe='org.eclipse.elk.layered.directionCongruency',IBe='org.eclipse.elk.layered.feedbackEdges',JBe='org.eclipse.elk.layered.interactiveReferencePoint',KBe='org.eclipse.elk.layered.mergeEdges',LBe='org.eclipse.elk.layered.mergeHierarchyEdges',MBe='org.eclipse.elk.layered.allowNonFlowPortsToSwitchSides',NBe='org.eclipse.elk.layered.portSortingStrategy',OBe='org.eclipse.elk.layered.thoroughness',PBe='org.eclipse.elk.layered.unnecessaryBendpoints',QBe='org.eclipse.elk.layered.generatePositionAndLayerIds',RBe='org.eclipse.elk.layered.cycleBreaking.strategy',SBe='org.eclipse.elk.layered.layering.strategy',TBe='org.eclipse.elk.layered.layering.layerConstraint',UBe='org.eclipse.elk.layered.layering.layerChoiceConstraint',VBe='org.eclipse.elk.layered.layering.layerId',WBe='org.eclipse.elk.layered.layering.minWidth.upperBoundOnWidth',XBe='org.eclipse.elk.layered.layering.minWidth.upperLayerEstimationScalingFactor',YBe='org.eclipse.elk.layered.layering.nodePromotion.strategy',ZBe='org.eclipse.elk.layered.layering.nodePromotion.maxIterations',$Be='org.eclipse.elk.layered.layering.coffmanGraham.layerBound',_Be='org.eclipse.elk.layered.crossingMinimization.strategy',aCe='org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder',bCe='org.eclipse.elk.layered.crossingMinimization.hierarchicalSweepiness',cCe='org.eclipse.elk.layered.crossingMinimization.semiInteractive',dCe='org.eclipse.elk.layered.crossingMinimization.inLayerPredOf',eCe='org.eclipse.elk.layered.crossingMinimization.inLayerSuccOf',fCe='org.eclipse.elk.layered.crossingMinimization.positionChoiceConstraint',gCe='org.eclipse.elk.layered.crossingMinimization.positionId',hCe='org.eclipse.elk.layered.crossingMinimization.greedySwitch.activationThreshold',iCe='org.eclipse.elk.layered.crossingMinimization.greedySwitch.type',jCe='org.eclipse.elk.layered.crossingMinimization.greedySwitchHierarchical.type',kCe='org.eclipse.elk.layered.nodePlacement.strategy',lCe='org.eclipse.elk.layered.nodePlacement.favorStraightEdges',mCe='org.eclipse.elk.layered.nodePlacement.bk.edgeStraightening',nCe='org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment',oCe='org.eclipse.elk.layered.nodePlacement.linearSegments.deflectionDampening',pCe='org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility',qCe='org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default',rCe='org.eclipse.elk.layered.edgeRouting.selfLoopDistribution',sCe='org.eclipse.elk.layered.edgeRouting.selfLoopOrdering',tCe='org.eclipse.elk.layered.edgeRouting.splines.mode',uCe='org.eclipse.elk.layered.edgeRouting.splines.sloppy.layerSpacingFactor',vCe='org.eclipse.elk.layered.edgeRouting.polyline.slopedEdgeZoneWidth',wCe='org.eclipse.elk.layered.spacing.baseValue',xCe='org.eclipse.elk.layered.spacing.edgeNodeBetweenLayers',yCe='org.eclipse.elk.layered.spacing.edgeEdgeBetweenLayers',zCe='org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers',ACe='org.eclipse.elk.layered.priority.direction',BCe='org.eclipse.elk.layered.priority.shortness',CCe='org.eclipse.elk.layered.priority.straightness',DCe='org.eclipse.elk.layered.compaction.connectedComponents',ECe='org.eclipse.elk.layered.compaction.postCompaction.strategy',FCe='org.eclipse.elk.layered.compaction.postCompaction.constraints',GCe='org.eclipse.elk.layered.highDegreeNodes.treatment',HCe='org.eclipse.elk.layered.highDegreeNodes.threshold',ICe='org.eclipse.elk.layered.highDegreeNodes.treeHeight',JCe='org.eclipse.elk.layered.wrapping.strategy',KCe='org.eclipse.elk.layered.wrapping.additionalEdgeSpacing',LCe='org.eclipse.elk.layered.wrapping.correctionFactor',MCe='org.eclipse.elk.layered.wrapping.cutting.strategy',NCe='org.eclipse.elk.layered.wrapping.cutting.cuts',OCe='org.eclipse.elk.layered.wrapping.cutting.msd.freedom',PCe='org.eclipse.elk.layered.wrapping.validify.strategy',QCe='org.eclipse.elk.layered.wrapping.validify.forbiddenIndices',RCe='org.eclipse.elk.layered.wrapping.multiEdge.improveCuts',SCe='org.eclipse.elk.layered.wrapping.multiEdge.distancePenalty',TCe='org.eclipse.elk.layered.wrapping.multiEdge.improveWrappedEdges',UCe='org.eclipse.elk.layered.edgeLabels.sideSelection',VCe='org.eclipse.elk.layered.edgeLabels.centerLabelPlacementStrategy',WCe='org.eclipse.elk.layered.considerModelOrder.strategy',XCe='org.eclipse.elk.layered.considerModelOrder.portModelOrder',YCe='org.eclipse.elk.layered.considerModelOrder.noModelOrder',ZCe='org.eclipse.elk.layered.considerModelOrder.components',$Ce='org.eclipse.elk.layered.considerModelOrder.longEdgeStrategy',_Ce='org.eclipse.elk.layered.considerModelOrder.crossingCounterNodeInfluence',aDe='org.eclipse.elk.layered.considerModelOrder.crossingCounterPortInfluence',bDe='layering',cDe='layering.minWidth',dDe='layering.nodePromotion',eDe='crossingMinimization',fDe='org.eclipse.elk.hierarchyHandling',gDe='crossingMinimization.greedySwitch',hDe='nodePlacement',iDe='nodePlacement.bk',jDe='edgeRouting',kDe='org.eclipse.elk.edgeRouting',lDe='spacing',mDe='priority',nDe='compaction',oDe='compaction.postCompaction',pDe='Specifies whether and how post-process compaction is applied.',qDe='highDegreeNodes',rDe='wrapping',sDe='wrapping.cutting',tDe='wrapping.validify',uDe='wrapping.multiEdge',vDe='edgeLabels',wDe='considerModelOrder',xDe='org.eclipse.elk.spacing.commentComment',yDe='org.eclipse.elk.spacing.commentNode',zDe='org.eclipse.elk.spacing.edgeEdge',ADe='org.eclipse.elk.spacing.edgeNode',BDe='org.eclipse.elk.spacing.labelLabel',CDe='org.eclipse.elk.spacing.labelPortHorizontal',DDe='org.eclipse.elk.spacing.labelPortVertical',EDe='org.eclipse.elk.spacing.labelNode',FDe='org.eclipse.elk.spacing.nodeSelfLoop',GDe='org.eclipse.elk.spacing.portPort',HDe='org.eclipse.elk.spacing.individual',IDe='org.eclipse.elk.port.borderOffset',JDe='org.eclipse.elk.noLayout',KDe='org.eclipse.elk.port.side',LDe='org.eclipse.elk.debugMode',MDe='org.eclipse.elk.alignment',NDe='org.eclipse.elk.insideSelfLoops.activate',ODe='org.eclipse.elk.insideSelfLoops.yo',PDe='org.eclipse.elk.direction',QDe='org.eclipse.elk.nodeLabels.padding',RDe='org.eclipse.elk.portLabels.nextToPortIfPossible',SDe='org.eclipse.elk.portLabels.treatAsGroup',TDe='org.eclipse.elk.portAlignment.default',UDe='org.eclipse.elk.portAlignment.north',VDe='org.eclipse.elk.portAlignment.south',WDe='org.eclipse.elk.portAlignment.west',XDe='org.eclipse.elk.portAlignment.east',YDe='org.eclipse.elk.contentAlignment',ZDe='org.eclipse.elk.junctionPoints',$De='org.eclipse.elk.edgeLabels.placement',_De='org.eclipse.elk.port.index',aEe='org.eclipse.elk.commentBox',bEe='org.eclipse.elk.hypernode',cEe='org.eclipse.elk.port.anchor',dEe='org.eclipse.elk.partitioning.activate',eEe='org.eclipse.elk.partitioning.partition',fEe='org.eclipse.elk.position',gEe='org.eclipse.elk.margins',hEe='org.eclipse.elk.spacing.portsSurrounding',iEe='org.eclipse.elk.interactiveLayout',jEe='org.eclipse.elk.core.util',kEe={3:1,4:1,5:1,601:1},lEe='NETWORK_SIMPLEX',mEe='SIMPLE',nEe={106:1,47:1},oEe='org.eclipse.elk.alg.layered.p1cycles',pEe='org.eclipse.elk.alg.layered.p2layers',qEe={413:1,230:1},rEe={846:1,3:1,4:1},sEe='org.eclipse.elk.alg.layered.p3order',tEe='org.eclipse.elk.alg.layered.p4nodes',uEe={3:1,4:1,5:1,854:1},vEe=1.0E-5,wEe='org.eclipse.elk.alg.layered.p4nodes.bk',xEe='org.eclipse.elk.alg.layered.p5edges',yEe='org.eclipse.elk.alg.layered.p5edges.orthogonal',zEe='org.eclipse.elk.alg.layered.p5edges.orthogonal.direction',AEe=1.0E-6,BEe='org.eclipse.elk.alg.layered.p5edges.splines',CEe=0.09999999999999998,DEe=1.0E-8,EEe=4.71238898038469,FEe=3.141592653589793,GEe='org.eclipse.elk.alg.mrtree',HEe=0.10000000149011612,IEe='SUPER_ROOT',JEe='org.eclipse.elk.alg.mrtree.graph',KEe=-1.7976931348623157E308,LEe='org.eclipse.elk.alg.mrtree.intermediate',MEe='Processor compute fanout',NEe={3:1,6:1,4:1,5:1,534:1,100:1,115:1},OEe='Set neighbors in level',PEe='org.eclipse.elk.alg.mrtree.options',QEe='DESCENDANTS',REe='org.eclipse.elk.mrtree.compaction',SEe='org.eclipse.elk.mrtree.edgeEndTextureLength',TEe='org.eclipse.elk.mrtree.treeLevel',UEe='org.eclipse.elk.mrtree.positionConstraint',VEe='org.eclipse.elk.mrtree.weighting',WEe='org.eclipse.elk.mrtree.edgeRoutingMode',XEe='org.eclipse.elk.mrtree.searchOrder',YEe='Position Constraint',ZEe='org.eclipse.elk.mrtree',$Ee='org.eclipse.elk.tree',_Ee='Processor arrange level',aFe='org.eclipse.elk.alg.mrtree.p2order',bFe='org.eclipse.elk.alg.mrtree.p4route',cFe='org.eclipse.elk.alg.radial',dFe=6.283185307179586,eFe='Before',fFe=4.9E-324,gFe='After',hFe='org.eclipse.elk.alg.radial.intermediate',iFe='COMPACTION',jFe='org.eclipse.elk.alg.radial.intermediate.compaction',kFe={3:1,4:1,5:1,100:1},lFe='org.eclipse.elk.alg.radial.intermediate.optimization',mFe='No implementation is available for the layout option ',nFe='org.eclipse.elk.alg.radial.options',oFe='org.eclipse.elk.radial.centerOnRoot',pFe='org.eclipse.elk.radial.orderId',qFe='org.eclipse.elk.radial.radius',rFe='org.eclipse.elk.radial.rotate',sFe='org.eclipse.elk.radial.compactor',tFe='org.eclipse.elk.radial.compactionStepSize',uFe='org.eclipse.elk.radial.sorter',vFe='org.eclipse.elk.radial.wedgeCriteria',wFe='org.eclipse.elk.radial.optimizationCriteria',xFe='org.eclipse.elk.radial.rotation.targetAngle',yFe='org.eclipse.elk.radial.rotation.computeAdditionalWedgeSpace',zFe='org.eclipse.elk.radial.rotation.outgoingEdgeAngles',AFe='Compaction',BFe='rotation',CFe='org.eclipse.elk.radial',DFe='org.eclipse.elk.alg.radial.p1position.wedge',EFe='org.eclipse.elk.alg.radial.sorting',FFe=5.497787143782138,GFe=3.9269908169872414,HFe=2.356194490192345,IFe='org.eclipse.elk.alg.rectpacking',JFe='org.eclipse.elk.alg.rectpacking.intermediate',KFe='org.eclipse.elk.alg.rectpacking.options',LFe='org.eclipse.elk.rectpacking.trybox',MFe='org.eclipse.elk.rectpacking.currentPosition',NFe='org.eclipse.elk.rectpacking.desiredPosition',OFe='org.eclipse.elk.rectpacking.inNewRow',PFe='org.eclipse.elk.rectpacking.widthApproximation.strategy',QFe='org.eclipse.elk.rectpacking.widthApproximation.targetWidth',RFe='org.eclipse.elk.rectpacking.widthApproximation.optimizationGoal',SFe='org.eclipse.elk.rectpacking.widthApproximation.lastPlaceShift',TFe='org.eclipse.elk.rectpacking.packing.strategy',UFe='org.eclipse.elk.rectpacking.packing.compaction.rowHeightReevaluation',VFe='org.eclipse.elk.rectpacking.packing.compaction.iterations',WFe='org.eclipse.elk.rectpacking.whiteSpaceElimination.strategy',XFe='widthApproximation',YFe='Compaction Strategy',ZFe='packing.compaction',$Fe='org.eclipse.elk.rectpacking',_Fe='org.eclipse.elk.alg.rectpacking.p1widthapproximation',aGe='org.eclipse.elk.alg.rectpacking.p2packing',bGe='No Compaction',cGe='org.eclipse.elk.alg.rectpacking.p3whitespaceelimination',dGe='org.eclipse.elk.alg.rectpacking.util',eGe='No implementation available for ',fGe='org.eclipse.elk.alg.spore',gGe='org.eclipse.elk.alg.spore.options',hGe='org.eclipse.elk.sporeCompaction',iGe='org.eclipse.elk.underlyingLayoutAlgorithm',jGe='org.eclipse.elk.processingOrder.treeConstruction',kGe='org.eclipse.elk.processingOrder.spanningTreeCostFunction',lGe='org.eclipse.elk.processingOrder.preferredRoot',mGe='org.eclipse.elk.processingOrder.rootSelection',nGe='org.eclipse.elk.structure.structureExtractionStrategy',oGe='org.eclipse.elk.compaction.compactionStrategy',pGe='org.eclipse.elk.compaction.orthogonal',qGe='org.eclipse.elk.overlapRemoval.maxIterations',rGe='org.eclipse.elk.overlapRemoval.runScanline',sGe='processingOrder',tGe='overlapRemoval',uGe='org.eclipse.elk.sporeOverlap',vGe='org.eclipse.elk.alg.spore.p1structure',wGe='org.eclipse.elk.alg.spore.p2processingorder',xGe='org.eclipse.elk.alg.spore.p3execution',yGe='Topdown Layout',zGe='Invalid index: ',AGe='org.eclipse.elk.core.alg',BGe={341:1},CGe={295:1},DGe='Make sure its type is registered with the ',EGe=' utility class.',FGe='true',GGe='false',HGe="Couldn't clone property '",IGe=0.05,JGe='org.eclipse.elk.core.options',KGe=1.2999999523162842,LGe='org.eclipse.elk.box',MGe='org.eclipse.elk.expandNodes',NGe='org.eclipse.elk.box.packingMode',OGe='org.eclipse.elk.algorithm',PGe='org.eclipse.elk.resolvedAlgorithm',QGe='org.eclipse.elk.bendPoints',RGe='org.eclipse.elk.labelManager',SGe='org.eclipse.elk.scaleFactor',TGe='org.eclipse.elk.childAreaWidth',UGe='org.eclipse.elk.childAreaHeight',VGe='org.eclipse.elk.animate',WGe='org.eclipse.elk.animTimeFactor',XGe='org.eclipse.elk.layoutAncestors',YGe='org.eclipse.elk.maxAnimTime',ZGe='org.eclipse.elk.minAnimTime',$Ge='org.eclipse.elk.progressBar',_Ge='org.eclipse.elk.validateGraph',aHe='org.eclipse.elk.validateOptions',bHe='org.eclipse.elk.zoomToFit',cHe='org.eclipse.elk.font.name',dHe='org.eclipse.elk.font.size',eHe='org.eclipse.elk.topdown.sizeApproximator',fHe='org.eclipse.elk.topdown.scaleCap',gHe='org.eclipse.elk.edge.type',hHe='partitioning',iHe='nodeLabels',jHe='portAlignment',kHe='nodeSize',lHe='port',mHe='portLabels',nHe='topdown',oHe='insideSelfLoops',pHe='org.eclipse.elk.fixed',qHe='org.eclipse.elk.random',rHe={3:1,34:1,22:1,347:1},sHe='port must have a parent node to calculate the port side',tHe='The edge needs to have exactly one edge section. Found: ',uHe='org.eclipse.elk.core.util.adapters',vHe='org.eclipse.emf.ecore',wHe='org.eclipse.elk.graph',xHe='EMapPropertyHolder',yHe='ElkBendPoint',zHe='ElkGraphElement',AHe='ElkConnectableShape',BHe='ElkEdge',CHe='ElkEdgeSection',DHe='EModelElement',EHe='ENamedElement',FHe='ElkLabel',GHe='ElkNode',HHe='ElkPort',IHe={94:1,93:1},JHe='org.eclipse.emf.common.notify.impl',KHe="The feature '",LHe="' is not a valid changeable feature",MHe='Expecting null',NHe="' is not a valid feature",OHe='The feature ID',PHe=' is not a valid feature ID',QHe=32768,RHe={110:1,94:1,93:1,58:1,54:1,99:1},SHe='org.eclipse.emf.ecore.impl',THe='org.eclipse.elk.graph.impl',UHe='Recursive containment not allowed for ',VHe="The datatype '",WHe="' is not a valid classifier",XHe="The value '",YHe={195:1,3:1,4:1},ZHe="The class '",$He='http://www.eclipse.org/elk/ElkGraph',_He='property',aIe='value',bIe='source',cIe='properties',dIe='identifier',eIe='height',fIe='width',gIe='parent',hIe='text',iIe='children',jIe='hierarchical',kIe='sources',lIe='targets',mIe='sections',nIe='bendPoints',oIe='outgoingShape',pIe='incomingShape',qIe='outgoingSections',rIe='incomingSections',sIe='org.eclipse.emf.common.util',tIe='Severe implementation error in the Json to ElkGraph importer.',uIe='id',vIe='org.eclipse.elk.graph.json',wIe='Unhandled parameter types: ',xIe='startPoint',yIe="An edge must have at least one source and one target (edge id: '",zIe="').",AIe='Referenced edge section does not exist: ',BIe=" (edge id: '",CIe='target',DIe='sourcePoint',EIe='targetPoint',FIe='group',GIe='name',HIe='connectableShape cannot be null',IIe='edge cannot be null',JIe="Passed edge is not 'simple'.",KIe='org.eclipse.elk.graph.util',LIe="The 'no duplicates' constraint is violated",MIe='targetIndex=',NIe=', size=',OIe='sourceIndex=',PIe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1},QIe={3:1,4:1,20:1,31:1,56:1,16:1,51:1,15:1,59:1,70:1,66:1,61:1,596:1},RIe='logging',SIe='measureExecutionTime',TIe='parser.parse.1',UIe='parser.parse.2',VIe='parser.next.1',WIe='parser.next.2',XIe='parser.next.3',YIe='parser.next.4',ZIe='parser.factor.1',$Ie='parser.factor.2',_Ie='parser.factor.3',aJe='parser.factor.4',bJe='parser.factor.5',cJe='parser.factor.6',dJe='parser.atom.1',eJe='parser.atom.2',fJe='parser.atom.3',gJe='parser.atom.4',hJe='parser.atom.5',iJe='parser.cc.1',jJe='parser.cc.2',kJe='parser.cc.3',lJe='parser.cc.5',mJe='parser.cc.6',nJe='parser.cc.7',oJe='parser.cc.8',pJe='parser.ope.1',qJe='parser.ope.2',rJe='parser.ope.3',sJe='parser.descape.1',tJe='parser.descape.2',uJe='parser.descape.3',vJe='parser.descape.4',wJe='parser.descape.5',xJe='parser.process.1',yJe='parser.quantifier.1',zJe='parser.quantifier.2',AJe='parser.quantifier.3',BJe='parser.quantifier.4',CJe='parser.quantifier.5',DJe='org.eclipse.emf.common.notify',EJe={424:1,686:1},FJe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,70:1,61:1},GJe={378:1,152:1},HJe='index=',IJe={3:1,4:1,5:1,129:1},JJe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,61:1},KJe={3:1,6:1,4:1,5:1,198:1},LJe={3:1,4:1,5:1,173:1,379:1},MJe=';/?:@&=+$,',NJe='invalid authority: ',OJe='EAnnotation',PJe='ETypedElement',QJe='EStructuralFeature',RJe='EAttribute',SJe='EClassifier',TJe='EEnumLiteral',UJe='EGenericType',VJe='EOperation',WJe='EParameter',XJe='EReference',YJe='ETypeParameter',ZJe='org.eclipse.emf.ecore.util',$Je={79:1},_Je={3:1,20:1,16:1,15:1,61:1,597:1,79:1,71:1,97:1},aKe='org.eclipse.emf.ecore.util.FeatureMap$Entry',bKe=8192,cKe=2048,dKe='byte',eKe='char',fKe='double',gKe='float',hKe='int',iKe='long',jKe='short',kKe='java.lang.Object',lKe={3:1,4:1,5:1,254:1},mKe={3:1,4:1,5:1,688:1},nKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,71:1},oKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,79:1,71:1,97:1},pKe='mixed',qKe='http:///org/eclipse/emf/ecore/util/ExtendedMetaData',rKe='kind',sKe={3:1,4:1,5:1,689:1},tKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,70:1,61:1,79:1,71:1,97:1},uKe={20:1,31:1,56:1,16:1,15:1,61:1,71:1},vKe={51:1,128:1,287:1},wKe={76:1,343:1},xKe="The value of type '",yKe="' must be of type '",zKe=1352,AKe='http://www.eclipse.org/emf/2002/Ecore',BKe=-32768,CKe='constraints',DKe='baseType',EKe='getEStructuralFeature',FKe='getFeatureID',GKe='feature',HKe='getOperationID',IKe='operation',JKe='defaultValue',KKe='eTypeParameters',LKe='isInstance',MKe='getEEnumLiteral',NKe='eContainingClass',OKe={57:1},PKe={3:1,4:1,5:1,124:1},QKe='org.eclipse.emf.ecore.resource',RKe={94:1,93:1,599:1,2034:1},SKe='org.eclipse.emf.ecore.resource.impl',TKe='unspecified',UKe='simple',VKe='attribute',WKe='attributeWildcard',XKe='element',YKe='elementWildcard',ZKe='collapse',$Ke='itemType',_Ke='namespace',aLe='##targetNamespace',bLe='whiteSpace',cLe='wildcards',dLe='http://www.eclipse.org/emf/2003/XMLType',eLe='##any',fLe='uninitialized',gLe='The multiplicity constraint is violated',hLe='org.eclipse.emf.ecore.xml.type',iLe='ProcessingInstruction',jLe='SimpleAnyType',kLe='XMLTypeDocumentRoot',lLe='org.eclipse.emf.ecore.xml.type.impl',mLe='INF',nLe='processing',oLe='ENTITIES_._base',pLe='minLength',qLe='ENTITY',rLe='NCName',sLe='IDREFS_._base',tLe='integer',uLe='token',vLe='pattern',wLe='[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*',xLe='\\i\\c*',yLe='[\\i-[:]][\\c-[:]]*',zLe='nonPositiveInteger',ALe='maxInclusive',BLe='NMTOKEN',CLe='NMTOKENS_._base',DLe='nonNegativeInteger',ELe='minInclusive',FLe='normalizedString',GLe='unsignedByte',HLe='unsignedInt',ILe='18446744073709551615',JLe='unsignedShort',KLe='processingInstruction',LLe='org.eclipse.emf.ecore.xml.type.internal',MLe=1114111,NLe='Internal Error: shorthands: \\u',OLe='xml:isDigit',PLe='xml:isWord',QLe='xml:isSpace',RLe='xml:isNameChar',SLe='xml:isInitialNameChar',TLe='09\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9\u0F20\u0F29',ULe='AZaz\xC0\xD6\xD8\xF6\xF8\u0131\u0134\u013E\u0141\u0148\u014A\u017E\u0180\u01C3\u01CD\u01F0\u01F4\u01F5\u01FA\u0217\u0250\u02A8\u02BB\u02C1\u0386\u0386\u0388\u038A\u038C\u038C\u038E\u03A1\u03A3\u03CE\u03D0\u03D6\u03DA\u03DA\u03DC\u03DC\u03DE\u03DE\u03E0\u03E0\u03E2\u03F3\u0401\u040C\u040E\u044F\u0451\u045C\u045E\u0481\u0490\u04C4\u04C7\u04C8\u04CB\u04CC\u04D0\u04EB\u04EE\u04F5\u04F8\u04F9\u0531\u0556\u0559\u0559\u0561\u0586\u05D0\u05EA\u05F0\u05F2\u0621\u063A\u0641\u064A\u0671\u06B7\u06BA\u06BE\u06C0\u06CE\u06D0\u06D3\u06D5\u06D5\u06E5\u06E6\u0905\u0939\u093D\u093D\u0958\u0961\u0985\u098C\u098F\u0990\u0993\u09A8\u09AA\u09B0\u09B2\u09B2\u09B6\u09B9\u09DC\u09DD\u09DF\u09E1\u09F0\u09F1\u0A05\u0A0A\u0A0F\u0A10\u0A13\u0A28\u0A2A\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59\u0A5C\u0A5E\u0A5E\u0A72\u0A74\u0A85\u0A8B\u0A8D\u0A8D\u0A8F\u0A91\u0A93\u0AA8\u0AAA\u0AB0\u0AB2\u0AB3\u0AB5\u0AB9\u0ABD\u0ABD\u0AE0\u0AE0\u0B05\u0B0C\u0B0F\u0B10\u0B13\u0B28\u0B2A\u0B30\u0B32\u0B33\u0B36\u0B39\u0B3D\u0B3D\u0B5C\u0B5D\u0B5F\u0B61\u0B85\u0B8A\u0B8E\u0B90\u0B92\u0B95\u0B99\u0B9A\u0B9C\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8\u0BAA\u0BAE\u0BB5\u0BB7\u0BB9\u0C05\u0C0C\u0C0E\u0C10\u0C12\u0C28\u0C2A\u0C33\u0C35\u0C39\u0C60\u0C61\u0C85\u0C8C\u0C8E\u0C90\u0C92\u0CA8\u0CAA\u0CB3\u0CB5\u0CB9\u0CDE\u0CDE\u0CE0\u0CE1\u0D05\u0D0C\u0D0E\u0D10\u0D12\u0D28\u0D2A\u0D39\u0D60\u0D61\u0E01\u0E2E\u0E30\u0E30\u0E32\u0E33\u0E40\u0E45\u0E81\u0E82\u0E84\u0E84\u0E87\u0E88\u0E8A\u0E8A\u0E8D\u0E8D\u0E94\u0E97\u0E99\u0E9F\u0EA1\u0EA3\u0EA5\u0EA5\u0EA7\u0EA7\u0EAA\u0EAB\u0EAD\u0EAE\u0EB0\u0EB0\u0EB2\u0EB3\u0EBD\u0EBD\u0EC0\u0EC4\u0F40\u0F47\u0F49\u0F69\u10A0\u10C5\u10D0\u10F6\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110B\u110C\u110E\u1112\u113C\u113C\u113E\u113E\u1140\u1140\u114C\u114C\u114E\u114E\u1150\u1150\u1154\u1155\u1159\u1159\u115F\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116D\u116E\u1172\u1173\u1175\u1175\u119E\u119E\u11A8\u11A8\u11AB\u11AB\u11AE\u11AF\u11B7\u11B8\u11BA\u11BA\u11BC\u11C2\u11EB\u11EB\u11F0\u11F0\u11F9\u11F9\u1E00\u1E9B\u1EA0\u1EF9\u1F00\u1F15\u1F18\u1F1D\u1F20\u1F45\u1F48\u1F4D\u1F50\u1F57\u1F59\u1F59\u1F5B\u1F5B\u1F5D\u1F5D\u1F5F\u1F7D\u1F80\u1FB4\u1FB6\u1FBC\u1FBE\u1FBE\u1FC2\u1FC4\u1FC6\u1FCC\u1FD0\u1FD3\u1FD6\u1FDB\u1FE0\u1FEC\u1FF2\u1FF4\u1FF6\u1FFC\u2126\u2126\u212A\u212B\u212E\u212E\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30A1\u30FA\u3105\u312C\u4E00\u9FA5\uAC00\uD7A3',VLe='Private Use',WLe='ASSIGNED',XLe='\x00\x7F\x80\xFF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF',YLe='UNASSIGNED',ZLe={3:1,122:1},$Le='org.eclipse.emf.ecore.xml.type.util',_Le={3:1,4:1,5:1,381:1},aMe='org.eclipse.xtext.xbase.lib',bMe='Cannot add elements to a Range',cMe='Cannot set elements in a Range',dMe='Cannot remove elements from a Range',eMe='user.agent';var _,eeb,_db;$wnd.goog=$wnd.goog||{};$wnd.goog.global=$wnd.goog.global||$wnd;eeb={};feb(1,null,{},nb);_.Fb=function ob(a){return mb(this,a)};_.Gb=function qb(){return this.Rm};_.Hb=function sb(){return kFb(this)};_.Ib=function ub(){var a;return nfb(rb(this))+'@'+(a=tb(this)>>>0,a.toString(16))};_.equals=function(a){return this.Fb(a)};_.hashCode=function(){return this.Hb()};_.toString=function(){return this.Ib()};var ND,OD,PD;feb(297,1,{297:1,2124:1},pfb);_.ve=function qfb(a){var b;b=new pfb;b.i=4;a>1?(b.c=xfb(this,a-1)):(b.c=this);return b};_.we=function wfb(){lfb(this);return this.b};_.xe=function yfb(){return nfb(this)};_.ye=function Afb(){return lfb(this),this.k};_.ze=function Cfb(){return (this.i&4)!=0};_.Ae=function Dfb(){return (this.i&1)!=0};_.Ib=function Gfb(){return ofb(this)};_.i=0;var jJ=sfb(mve,'Object',1);var UI=sfb(mve,'Class',297);feb(2096,1,nve);sfb(ove,'Optional',2096);feb(1191,2096,nve,xb);_.Fb=function yb(a){return a===this};_.Hb=function zb(){return 2040732332};_.Ib=function Ab(){return 'Optional.absent()'};_.Jb=function Bb(a){Qb(a);return wb(),vb};var vb;sfb(ove,'Absent',1191);feb(636,1,{},Gb);sfb(ove,'Joiner',636);var pE=ufb(ove,'Predicate');feb(589,1,{178:1,589:1,3:1,46:1},Yb);_.Mb=function ac(a){return Xb(this,a)};_.Lb=function Zb(a){return Xb(this,a)};_.Fb=function $b(a){var b;if(ZD(a,589)){b=RD(a,589);return Rt(this.a,b.a)}return false};_.Hb=function _b(){return Cob(this.a)+306654252};_.Ib=function bc(){return Wb(this.a)};sfb(ove,'Predicates/AndPredicate',589);feb(419,2096,{419:1,3:1},cc);_.Fb=function dc(a){var b;if(ZD(a,419)){b=RD(a,419);return pb(this.a,b.a)}return false};_.Hb=function ec(){return 1502476572+tb(this.a)};_.Ib=function fc(){return uve+this.a+')'};_.Jb=function gc(a){return new cc(Rb(a.Kb(this.a),'the Function passed to Optional.transform() must not return null.'))};sfb(ove,'Present',419);feb(204,1,wve);_.Nb=function kc(a){Ztb(this,a);};_.Qb=function lc(){jc();};sfb(xve,'UnmodifiableIterator',204);feb(2076,204,yve);_.Qb=function nc(){jc();};_.Rb=function mc(a){throw Adb(new jib)};_.Wb=function oc(a){throw Adb(new jib)};sfb(xve,'UnmodifiableListIterator',2076);feb(399,2076,yve);_.Ob=function rc(){return this.c0};_.Pb=function tc(){if(this.c>=this.d){throw Adb(new Dvb)}return this.Xb(this.c++)};_.Tb=function uc(){return this.c};_.Ub=function vc(){if(this.c<=0){throw Adb(new Dvb)}return this.Xb(--this.c)};_.Vb=function wc(){return this.c-1};_.c=0;_.d=0;sfb(xve,'AbstractIndexedListIterator',399);feb(713,204,wve);_.Ob=function Ac(){return xc(this)};_.Pb=function Bc(){return yc(this)};_.e=1;sfb(xve,'AbstractIterator',713);feb(2084,1,{229:1});_.Zb=function Hc(){var a;return a=this.f,!a?(this.f=this.ac()):a};_.Fb=function Ic(a){return xw(this,a)};_.Hb=function Jc(){return tb(this.Zb())};_.dc=function Kc(){return this.gc()==0};_.ec=function Lc(){return Ec(this)};_.Ib=function Mc(){return jeb(this.Zb())};sfb(xve,'AbstractMultimap',2084);feb(742,2084,zve);_.$b=function Xc(){Nc(this);};_._b=function Yc(a){return Oc(this,a)};_.ac=function Zc(){return new ne(this,this.c)};_.ic=function $c(a){return this.hc()};_.bc=function _c(){return new zf(this,this.c)};_.jc=function ad(){return this.mc(this.hc())};_.kc=function bd(){return new Hd(this)};_.lc=function cd(){return ek(this.c.vc().Nc(),new hh,64,this.d)};_.cc=function dd(a){return Qc(this,a)};_.fc=function gd(a){return Sc(this,a)};_.gc=function hd(){return this.d};_.mc=function jd(a){return yob(),new xpb(a)};_.nc=function kd(){return new Dd(this)};_.oc=function ld(){return ek(this.c.Cc().Nc(),new Fd,64,this.d)};_.pc=function md(a,b){return new lg(this,a,b,null)};_.d=0;sfb(xve,'AbstractMapBasedMultimap',742);feb(1696,742,zve);_.hc=function pd(){return new cnb(this.a)};_.jc=function qd(){return yob(),yob(),vob};_.cc=function sd(a){return RD(Qc(this,a),15)};_.fc=function ud(a){return RD(Sc(this,a),15)};_.Zb=function od(){return nd(this)};_.Fb=function rd(a){return xw(this,a)};_.qc=function td(a){return RD(Qc(this,a),15)};_.rc=function vd(a){return RD(Sc(this,a),15)};_.mc=function wd(a){return Hob(RD(a,15))};_.pc=function xd(a,b){return Vc(this,a,RD(b,15),null)};sfb(xve,'AbstractListMultimap',1696);feb(748,1,Ave);_.Nb=function zd(a){Ztb(this,a);};_.Ob=function Ad(){return this.c.Ob()||this.e.Ob()};_.Pb=function Bd(){var a;if(!this.e.Ob()){a=RD(this.c.Pb(),44);this.b=a.ld();this.a=RD(a.md(),16);this.e=this.a.Kc();}return this.sc(this.b,this.e.Pb())};_.Qb=function Cd(){this.e.Qb();RD(Hvb(this.a),16).dc()&&this.c.Qb();--this.d.d;};sfb(xve,'AbstractMapBasedMultimap/Itr',748);feb(1129,748,Ave,Dd);_.sc=function Ed(a,b){return b};sfb(xve,'AbstractMapBasedMultimap/1',1129);feb(1130,1,{},Fd);_.Kb=function Gd(a){return RD(a,16).Nc()};sfb(xve,'AbstractMapBasedMultimap/1methodref$spliterator$Type',1130);feb(1131,748,Ave,Hd);_.sc=function Id(a,b){return new gp(a,b)};sfb(xve,'AbstractMapBasedMultimap/2',1131);var VK=ufb(Bve,'Map');feb(2065,1,Cve);_.wc=function Td(a){Bvb(this,a);};_.yc=function $d(a,b,c){return Cvb(this,a,b,c)};_.$b=function Od(){this.vc().$b();};_.tc=function Pd(a){return Jd(this,a)};_._b=function Qd(a){return !!Kd(this,a,false)};_.uc=function Rd(a){var b,c,d;for(c=this.vc().Kc();c.Ob();){b=RD(c.Pb(),44);d=b.md();if(dE(a)===dE(d)||a!=null&&pb(a,d)){return true}}return false};_.Fb=function Sd(a){var b,c,d;if(a===this){return true}if(!ZD(a,85)){return false}d=RD(a,85);if(this.gc()!=d.gc()){return false}for(c=d.vc().Kc();c.Ob();){b=RD(c.Pb(),44);if(!this.tc(b)){return false}}return true};_.xc=function Ud(a){return Wd(Kd(this,a,false))};_.Hb=function Xd(){return Bob(this.vc())};_.dc=function Yd(){return this.gc()==0};_.ec=function Zd(){return new Xkb(this)};_.zc=function _d(a,b){throw Adb(new kib('Put not supported on this map'))};_.Ac=function ae(a){Ld(this,a);};_.Bc=function be(a){return Wd(Kd(this,a,true))};_.gc=function ce(){return this.vc().gc()};_.Ib=function de(){return Md(this)};_.Cc=function ee(){return new glb(this)};sfb(Bve,'AbstractMap',2065);feb(2085,2065,Cve);_.bc=function ge(){return new rf(this)};_.vc=function he(){return fe(this)};_.ec=function ie(){var a;a=this.g;return !a?(this.g=this.bc()):a};_.Cc=function je(){var a;a=this.i;return !a?(this.i=new nw(this)):a};sfb(xve,'Maps/ViewCachingAbstractMap',2085);feb(402,2085,Cve,ne);_.xc=function se(a){return ke(this,a)};_.Bc=function ve(a){return le(this,a)};_.$b=function oe(){this.d==this.e.c?this.e.$b():Ar(new mf(this));};_._b=function pe(a){return Wv(this.d,a)};_.Ec=function qe(){return new df(this)};_.Dc=function(){return this.Ec()};_.Fb=function re(a){return this===a||pb(this.d,a)};_.Hb=function te(){return tb(this.d)};_.ec=function ue(){return this.e.ec()};_.gc=function we(){return this.d.gc()};_.Ib=function xe(){return jeb(this.d)};sfb(xve,'AbstractMapBasedMultimap/AsMap',402);var cJ=ufb(mve,'Iterable');feb(31,1,Dve);_.Jc=function Le(a){xgb(this,a);};_.Lc=function Ne(){return this.Oc()};_.Nc=function Pe(){return new Swb(this,0)};_.Oc=function Qe(){return new SDb(null,this.Nc())};_.Fc=function Ge(a){throw Adb(new kib('Add not supported on this collection'))};_.Gc=function He(a){return ye(this,a)};_.$b=function Ie(){Ae(this);};_.Hc=function Je(a){return ze(this,a,false)};_.Ic=function Ke(a){return Be(this,a)};_.dc=function Me(){return this.gc()==0};_.Mc=function Oe(a){return ze(this,a,true)};_.Pc=function Re(){return De(this)};_.Qc=function Se(a){return Ee(this,a)};_.Ib=function Te(){return Fe(this)};sfb(Bve,'AbstractCollection',31);var bL=ufb(Bve,'Set');feb(Eve,31,Fve);_.Nc=function Ye(){return new Swb(this,1)};_.Fb=function We(a){return Ue(this,a)};_.Hb=function Xe(){return Bob(this)};sfb(Bve,'AbstractSet',Eve);feb(2068,Eve,Fve);sfb(xve,'Sets/ImprovedAbstractSet',2068);feb(2069,2068,Fve);_.$b=function $e(){this.Rc().$b();};_.Hc=function _e(a){return Ze(this,a)};_.dc=function af(){return this.Rc().dc()};_.Mc=function bf(a){var b;if(this.Hc(a)&&ZD(a,44)){b=RD(a,44);return this.Rc().ec().Mc(b.ld())}return false};_.gc=function cf(){return this.Rc().gc()};sfb(xve,'Maps/EntrySet',2069);feb(1127,2069,Fve,df);_.Hc=function ef(a){return Nk(this.a.d.vc(),a)};_.Kc=function ff(){return new mf(this.a)};_.Rc=function gf(){return this.a};_.Mc=function hf(a){var b;if(!Nk(this.a.d.vc(),a)){return false}b=RD(Hvb(RD(a,44)),44);Tc(this.a.e,b.ld());return true};_.Nc=function jf(){return gk(this.a.d.vc().Nc(),new kf(this.a))};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapEntries',1127);feb(1128,1,{},kf);_.Kb=function lf(a){return me(this.a,RD(a,44))};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type',1128);feb(746,1,Ave,mf);_.Nb=function nf(a){Ztb(this,a);};_.Pb=function pf(){var a;return a=RD(this.b.Pb(),44),this.a=RD(a.md(),16),me(this.c,a)};_.Ob=function of(){return this.b.Ob()};_.Qb=function qf(){Vb(!!this.a);this.b.Qb();this.c.e.d-=this.a.gc();this.a.$b();this.a=null;};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapIterator',746);feb(542,2068,Fve,rf);_.$b=function sf(){this.b.$b();};_.Hc=function tf(a){return this.b._b(a)};_.Jc=function uf(a){Qb(a);this.b.wc(new lw(a));};_.dc=function vf(){return this.b.dc()};_.Kc=function wf(){return new aw(this.b.vc().Kc())};_.Mc=function xf(a){if(this.b._b(a)){this.b.Bc(a);return true}return false};_.gc=function yf(){return this.b.gc()};sfb(xve,'Maps/KeySet',542);feb(327,542,Fve,zf);_.$b=function Af(){var a;Ar((a=this.b.vc().Kc(),new Hf(this,a)));};_.Ic=function Bf(a){return this.b.ec().Ic(a)};_.Fb=function Cf(a){return this===a||pb(this.b.ec(),a)};_.Hb=function Df(){return tb(this.b.ec())};_.Kc=function Ef(){var a;return a=this.b.vc().Kc(),new Hf(this,a)};_.Mc=function Ff(a){var b,c;c=0;b=RD(this.b.Bc(a),16);if(b){c=b.gc();b.$b();this.a.d-=c;}return c>0};_.Nc=function Gf(){return this.b.ec().Nc()};sfb(xve,'AbstractMapBasedMultimap/KeySet',327);feb(747,1,Ave,Hf);_.Nb=function If(a){Ztb(this,a);};_.Ob=function Jf(){return this.c.Ob()};_.Pb=function Kf(){this.a=RD(this.c.Pb(),44);return this.a.ld()};_.Qb=function Lf(){var a;Vb(!!this.a);a=RD(this.a.md(),16);this.c.Qb();this.b.a.d-=a.gc();a.$b();this.a=null;};sfb(xve,'AbstractMapBasedMultimap/KeySet/1',747);feb(503,402,{85:1,133:1},Mf);_.bc=function Nf(){return this.Sc()};_.ec=function Qf(){return this.Uc()};_.Sc=function Of(){return new eg(this.c,this.Wc())};_.Tc=function Pf(){return this.Wc().Tc()};_.Uc=function Rf(){var a;return a=this.b,!a?(this.b=this.Sc()):a};_.Vc=function Sf(){return this.Wc().Vc()};_.Wc=function Tf(){return RD(this.d,133)};sfb(xve,'AbstractMapBasedMultimap/SortedAsMap',503);feb(446,503,Gve,Uf);_.bc=function Wf(){return new gg(this.a,RD(RD(this.d,133),139))};_.Sc=function Xf(){return new gg(this.a,RD(RD(this.d,133),139))};_.ec=function _f(){var a;return a=this.b,RD(!a?(this.b=new gg(this.a,RD(RD(this.d,133),139))):a,277)};_.Uc=function ag(){var a;return a=this.b,RD(!a?(this.b=new gg(this.a,RD(RD(this.d,133),139))):a,277)};_.Wc=function cg(){return RD(RD(this.d,133),139)};_.Xc=function Vf(a){return RD(RD(this.d,133),139).Xc(a)};_.Yc=function Yf(a){return RD(RD(this.d,133),139).Yc(a)};_.Zc=function Zf(a,b){return new Uf(this.a,RD(RD(this.d,133),139).Zc(a,b))};_.$c=function $f(a){return RD(RD(this.d,133),139).$c(a)};_._c=function bg(a){return RD(RD(this.d,133),139)._c(a)};_.ad=function dg(a,b){return new Uf(this.a,RD(RD(this.d,133),139).ad(a,b))};sfb(xve,'AbstractMapBasedMultimap/NavigableAsMap',446);feb(502,327,Hve,eg);_.Nc=function fg(){return this.b.ec().Nc()};sfb(xve,'AbstractMapBasedMultimap/SortedKeySet',502);feb(401,502,Ive,gg);sfb(xve,'AbstractMapBasedMultimap/NavigableKeySet',401);feb(551,31,Dve,lg);_.Fc=function mg(a){var b,c;ig(this);c=this.d.dc();b=this.d.Fc(a);if(b){++this.f.d;c&&hg(this);}return b};_.Gc=function ng(a){var b,c,d;if(a.dc()){return false}d=(ig(this),this.d.gc());b=this.d.Gc(a);if(b){c=this.d.gc();this.f.d+=c-d;d==0&&hg(this);}return b};_.$b=function og(){var a;a=(ig(this),this.d.gc());if(a==0){return}this.d.$b();this.f.d-=a;jg(this);};_.Hc=function pg(a){ig(this);return this.d.Hc(a)};_.Ic=function qg(a){ig(this);return this.d.Ic(a)};_.Fb=function rg(a){if(a===this){return true}ig(this);return pb(this.d,a)};_.Hb=function sg(){ig(this);return tb(this.d)};_.Kc=function tg(){ig(this);return new Og(this)};_.Mc=function ug(a){var b;ig(this);b=this.d.Mc(a);if(b){--this.f.d;jg(this);}return b};_.gc=function vg(){return kg(this)};_.Nc=function wg(){return ig(this),this.d.Nc()};_.Ib=function xg(){ig(this);return jeb(this.d)};sfb(xve,'AbstractMapBasedMultimap/WrappedCollection',551);var QK=ufb(Bve,'List');feb(744,551,{20:1,31:1,16:1,15:1},yg);_.jd=function Hg(a){tvb(this,a);};_.Nc=function Ig(){return ig(this),this.d.Nc()};_.bd=function zg(a,b){var c;ig(this);c=this.d.dc();RD(this.d,15).bd(a,b);++this.a.d;c&&hg(this);};_.cd=function Ag(a,b){var c,d,e;if(b.dc()){return false}e=(ig(this),this.d.gc());c=RD(this.d,15).cd(a,b);if(c){d=this.d.gc();this.a.d+=d-e;e==0&&hg(this);}return c};_.Xb=function Bg(a){ig(this);return RD(this.d,15).Xb(a)};_.dd=function Cg(a){ig(this);return RD(this.d,15).dd(a)};_.ed=function Dg(){ig(this);return new Ug(this)};_.fd=function Eg(a){ig(this);return new Vg(this,a)};_.gd=function Fg(a){var b;ig(this);b=RD(this.d,15).gd(a);--this.a.d;jg(this);return b};_.hd=function Gg(a,b){ig(this);return RD(this.d,15).hd(a,b)};_.kd=function Jg(a,b){ig(this);return Vc(this.a,this.e,RD(this.d,15).kd(a,b),!this.b?this:this.b)};sfb(xve,'AbstractMapBasedMultimap/WrappedList',744);feb(1126,744,{20:1,31:1,16:1,15:1,59:1},Kg);sfb(xve,'AbstractMapBasedMultimap/RandomAccessWrappedList',1126);feb(628,1,Ave,Og);_.Nb=function Qg(a){Ztb(this,a);};_.Ob=function Rg(){Ng(this);return this.b.Ob()};_.Pb=function Sg(){Ng(this);return this.b.Pb()};_.Qb=function Tg(){Mg(this);};sfb(xve,'AbstractMapBasedMultimap/WrappedCollection/WrappedIterator',628);feb(745,628,Jve,Ug,Vg);_.Qb=function _g(){Mg(this);};_.Rb=function Wg(a){var b;b=kg(this.a)==0;(Ng(this),RD(this.b,128)).Rb(a);++this.a.a.d;b&&hg(this.a);};_.Sb=function Xg(){return (Ng(this),RD(this.b,128)).Sb()};_.Tb=function Yg(){return (Ng(this),RD(this.b,128)).Tb()};_.Ub=function Zg(){return (Ng(this),RD(this.b,128)).Ub()};_.Vb=function $g(){return (Ng(this),RD(this.b,128)).Vb()};_.Wb=function ah(a){(Ng(this),RD(this.b,128)).Wb(a);};sfb(xve,'AbstractMapBasedMultimap/WrappedList/WrappedListIterator',745);feb(743,551,Hve,bh);_.Nc=function dh(){return ig(this),this.d.Nc()};sfb(xve,'AbstractMapBasedMultimap/WrappedSortedSet',743);feb(1125,743,Ive,eh);sfb(xve,'AbstractMapBasedMultimap/WrappedNavigableSet',1125);feb(1124,551,Fve,fh);_.Nc=function gh(){return ig(this),this.d.Nc()};sfb(xve,'AbstractMapBasedMultimap/WrappedSet',1124);feb(1133,1,{},hh);_.Kb=function ih(a){return fd(RD(a,44))};sfb(xve,'AbstractMapBasedMultimap/lambda$1$Type',1133);feb(1132,1,{},jh);_.Kb=function kh(a){return new gp(this.a,a)};sfb(xve,'AbstractMapBasedMultimap/lambda$2$Type',1132);var UK=ufb(Bve,'Map/Entry');feb(358,1,Kve);_.Fb=function lh(a){var b;if(ZD(a,44)){b=RD(a,44);return Hb(this.ld(),b.ld())&&Hb(this.md(),b.md())}return false};_.Hb=function mh(){var a,b;a=this.ld();b=this.md();return (a==null?0:tb(a))^(b==null?0:tb(b))};_.nd=function nh(a){throw Adb(new jib)};_.Ib=function oh(){return this.ld()+'='+this.md()};sfb(xve,Lve,358);feb(2086,31,Dve);_.$b=function ph(){this.od().$b();};_.Hc=function qh(a){var b;if(ZD(a,44)){b=RD(a,44);return Cc(this.od(),b.ld(),b.md())}return false};_.Mc=function rh(a){var b;if(ZD(a,44)){b=RD(a,44);return Gc(this.od(),b.ld(),b.md())}return false};_.gc=function sh(){return this.od().d};sfb(xve,'Multimaps/Entries',2086);feb(749,2086,Dve,th);_.Kc=function uh(){return this.a.kc()};_.od=function vh(){return this.a};_.Nc=function wh(){return this.a.lc()};sfb(xve,'AbstractMultimap/Entries',749);feb(750,749,Fve,xh);_.Nc=function Ah(){return this.a.lc()};_.Fb=function yh(a){return Rx(this,a)};_.Hb=function zh(){return Sx(this)};sfb(xve,'AbstractMultimap/EntrySet',750);feb(751,31,Dve,Bh);_.$b=function Ch(){this.a.$b();};_.Hc=function Dh(a){return Dc(this.a,a)};_.Kc=function Eh(){return this.a.nc()};_.gc=function Fh(){return this.a.d};_.Nc=function Gh(){return this.a.oc()};sfb(xve,'AbstractMultimap/Values',751);feb(2087,31,{849:1,20:1,31:1,16:1});_.Jc=function Oh(a){Qb(a);Ih(this).Jc(new lx(a));};_.Nc=function Sh(){var a;return a=Ih(this).Nc(),ek(a,new sx,64|a.yd()&1296,this.a.d)};_.Fc=function Kh(a){Hh();return true};_.Gc=function Lh(a){return Qb(this),Qb(a),ZD(a,552)?nx(RD(a,849)):!a.dc()&&xr(this,a.Kc())};_.Hc=function Mh(a){var b;return b=RD(Xv(nd(this.a),a),16),(!b?0:b.gc())>0};_.Fb=function Nh(a){return ox(this,a)};_.Hb=function Ph(){return tb(Ih(this))};_.dc=function Qh(){return Ih(this).dc()};_.Mc=function Rh(a){return Rw(this,a,1)>0};_.Ib=function Th(){return jeb(Ih(this))};sfb(xve,'AbstractMultiset',2087);feb(2089,2068,Fve);_.$b=function Uh(){Nc(this.a.a);};_.Hc=function Vh(a){var b,c;if(ZD(a,504)){c=RD(a,425);if(RD(c.a.md(),16).gc()<=0){return false}b=Qw(this.a,c.a.ld());return b==RD(c.a.md(),16).gc()}return false};_.Mc=function Wh(a){var b,c,d,e;if(ZD(a,504)){c=RD(a,425);b=c.a.ld();d=RD(c.a.md(),16).gc();if(d!=0){e=this.a;return qx(e,b,d)}}return false};sfb(xve,'Multisets/EntrySet',2089);feb(1139,2089,Fve,Xh);_.Kc=function Yh(){return new _w(fe(nd(this.a.a)).Kc())};_.gc=function Zh(){return nd(this.a.a).gc()};sfb(xve,'AbstractMultiset/EntrySet',1139);feb(627,742,zve);_.hc=function ai(){return this.pd()};_.jc=function bi(){return this.qd()};_.cc=function ei(a){return this.rd(a)};_.fc=function gi(a){return this.sd(a)};_.Zb=function _h(){var a;return a=this.f,!a?(this.f=this.ac()):a};_.qd=function ci(){return yob(),yob(),xob};_.Fb=function di(a){return xw(this,a)};_.rd=function fi(a){return RD(Qc(this,a),21)};_.sd=function hi(a){return RD(Sc(this,a),21)};_.mc=function ii(a){return yob(),new Lqb(RD(a,21))};_.pc=function ji(a,b){return new fh(this,a,RD(b,21))};sfb(xve,'AbstractSetMultimap',627);feb(1723,627,zve);_.hc=function mi(){return new yAb(this.b)};_.pd=function ni(){return new yAb(this.b)};_.jc=function oi(){return Zx(new yAb(this.b))};_.qd=function pi(){return Zx(new yAb(this.b))};_.cc=function qi(a){return RD(RD(Qc(this,a),21),87)};_.rd=function ri(a){return RD(RD(Qc(this,a),21),87)};_.fc=function si(a){return RD(RD(Sc(this,a),21),87)};_.sd=function ti(a){return RD(RD(Sc(this,a),21),87)};_.mc=function ui(a){return ZD(a,277)?Zx(RD(a,277)):(yob(),new jrb(RD(a,87)))};_.Zb=function li(){var a;return a=this.f,!a?(this.f=ZD(this.c,139)?new Uf(this,RD(this.c,139)):ZD(this.c,133)?new Mf(this,RD(this.c,133)):new ne(this,this.c)):a};_.pc=function vi(a,b){return ZD(b,277)?new eh(this,a,RD(b,277)):new bh(this,a,RD(b,87))};sfb(xve,'AbstractSortedSetMultimap',1723);feb(1724,1723,zve);_.Zb=function xi(){var a;return a=this.f,RD(RD(!a?(this.f=ZD(this.c,139)?new Uf(this,RD(this.c,139)):ZD(this.c,133)?new Mf(this,RD(this.c,133)):new ne(this,this.c)):a,133),139)};_.ec=function zi(){var a;return a=this.i,RD(RD(!a?(this.i=ZD(this.c,139)?new gg(this,RD(this.c,139)):ZD(this.c,133)?new eg(this,RD(this.c,133)):new zf(this,this.c)):a,87),277)};_.bc=function yi(){return ZD(this.c,139)?new gg(this,RD(this.c,139)):ZD(this.c,133)?new eg(this,RD(this.c,133)):new zf(this,this.c)};sfb(xve,'AbstractSortedKeySortedSetMultimap',1724);feb(2109,1,{2046:1});_.Fb=function Ai(a){return Qy(this,a)};_.Hb=function Bi(){var a;return Bob((a=this.g,!a?(this.g=new Di(this)):a))};_.Ib=function Ci(){var a;return Md((a=this.f,!a?(this.f=new Zj(this)):a))};sfb(xve,'AbstractTable',2109);feb(679,Eve,Fve,Di);_.$b=function Ei(){Xi();};_.Hc=function Fi(a){var b,c;if(ZD(a,479)){b=RD(a,697);c=RD(Xv(bj(this.a),Qm(b.c.e,b.b)),85);return !!c&&Nk(c.vc(),new gp(Qm(b.c.c,b.a),Ui(b.c,b.b,b.a)))}return false};_.Kc=function Gi(){return Vi(this.a)};_.Mc=function Hi(a){var b,c;if(ZD(a,479)){b=RD(a,697);c=RD(Xv(bj(this.a),Qm(b.c.e,b.b)),85);return !!c&&Ok(c.vc(),new gp(Qm(b.c.c,b.a),Ui(b.c,b.b,b.a)))}return false};_.gc=function Ii(){return dj(this.a)};_.Nc=function Ji(){return Wi(this.a)};sfb(xve,'AbstractTable/CellSet',679);feb(2025,31,Dve,Ki);_.$b=function Li(){Xi();};_.Hc=function Mi(a){return Yi(this.a,a)};_.Kc=function Ni(){return fj(this.a)};_.gc=function Oi(){return dj(this.a)};_.Nc=function Pi(){return gj(this.a)};sfb(xve,'AbstractTable/Values',2025);feb(1697,1696,zve);sfb(xve,'ArrayListMultimapGwtSerializationDependencies',1697);feb(520,1697,zve,Ri,Si);_.hc=function Ti(){return new cnb(this.a)};_.a=0;sfb(xve,'ArrayListMultimap',520);feb(678,2109,{678:1,2046:1,3:1},hj);sfb(xve,'ArrayTable',678);feb(2021,399,yve,ij);_.Xb=function jj(a){return new pj(this.a,a)};sfb(xve,'ArrayTable/1',2021);feb(2022,1,{},kj);_.td=function lj(a){return new pj(this.a,a)};sfb(xve,'ArrayTable/1methodref$getCell$Type',2022);feb(2110,1,{697:1});_.Fb=function mj(a){var b;if(a===this){return true}if(ZD(a,479)){b=RD(a,697);return Hb(Qm(this.c.e,this.b),Qm(b.c.e,b.b))&&Hb(Qm(this.c.c,this.a),Qm(b.c.c,b.a))&&Hb(Ui(this.c,this.b,this.a),Ui(b.c,b.b,b.a))}return false};_.Hb=function nj(){return Tnb(cD(WC(jJ,1),rve,1,5,[Qm(this.c.e,this.b),Qm(this.c.c,this.a),Ui(this.c,this.b,this.a)]))};_.Ib=function oj(){return '('+Qm(this.c.e,this.b)+','+Qm(this.c.c,this.a)+')='+Ui(this.c,this.b,this.a)};sfb(xve,'Tables/AbstractCell',2110);feb(479,2110,{479:1,697:1},pj);_.a=0;_.b=0;_.d=0;sfb(xve,'ArrayTable/2',479);feb(2024,1,{},qj);_.td=function rj(a){return _i(this.a,a)};sfb(xve,'ArrayTable/2methodref$getValue$Type',2024);feb(2023,399,yve,sj);_.Xb=function tj(a){return _i(this.a,a)};sfb(xve,'ArrayTable/3',2023);feb(2077,2065,Cve);_.$b=function vj(){Ar(this.kc());};_.vc=function wj(){return new gw(this)};_.lc=function xj(){return new Uwb(this.kc(),this.gc())};sfb(xve,'Maps/IteratorBasedAbstractMap',2077);feb(842,2077,Cve);_.$b=function Bj(){throw Adb(new jib)};_._b=function Cj(a){return En(this.c,a)};_.kc=function Dj(){return new Rj(this,this.c.b.c.gc())};_.lc=function Ej(){return fk(this.c.b.c.gc(),16,new Lj(this))};_.xc=function Fj(a){var b;b=RD(Fn(this.c,a),17);return !b?null:this.vd(b.a)};_.dc=function Gj(){return this.c.b.c.dc()};_.ec=function Hj(){return hn(this.c)};_.zc=function Ij(a,b){var c;c=RD(Fn(this.c,a),17);if(!c){throw Adb(new agb(this.ud()+' '+a+' not in '+hn(this.c)))}return this.wd(c.a,b)};_.Bc=function Jj(a){throw Adb(new jib)};_.gc=function Kj(){return this.c.b.c.gc()};sfb(xve,'ArrayTable/ArrayMap',842);feb(2020,1,{},Lj);_.td=function Mj(a){return yj(this.a,a)};sfb(xve,'ArrayTable/ArrayMap/0methodref$getEntry$Type',2020);feb(2018,358,Kve,Nj);_.ld=function Oj(){return zj(this.a,this.b)};_.md=function Pj(){return this.a.vd(this.b)};_.nd=function Qj(a){return this.a.wd(this.b,a)};_.b=0;sfb(xve,'ArrayTable/ArrayMap/1',2018);feb(2019,399,yve,Rj);_.Xb=function Sj(a){return yj(this.a,a)};sfb(xve,'ArrayTable/ArrayMap/2',2019);feb(2017,842,Cve,Tj);_.ud=function Uj(){return 'Column'};_.vd=function Vj(a){return Ui(this.b,this.a,a)};_.wd=function Wj(a,b){return cj(this.b,this.a,a,b)};_.a=0;sfb(xve,'ArrayTable/Row',2017);feb(843,842,Cve,Zj);_.vd=function _j(a){return new Tj(this.a,a)};_.zc=function ak(a,b){return RD(b,85),Xj()};_.wd=function bk(a,b){return RD(b,85),Yj()};_.ud=function $j(){return 'Row'};sfb(xve,'ArrayTable/RowMap',843);feb(1157,1,Pve,hk);_.Ad=function lk(a){return (this.a.yd()&-262&a)!=0};_.yd=function ik(){return this.a.yd()&-262};_.zd=function jk(){return this.a.zd()};_.Nb=function kk(a){this.a.Nb(new pk(a,this.b));};_.Bd=function mk(a){return this.a.Bd(new nk(a,this.b))};sfb(xve,'CollectSpliterators/1',1157);feb(1158,1,Qve,nk);_.Cd=function ok(a){this.a.Cd(this.b.Kb(a));};sfb(xve,'CollectSpliterators/1/lambda$0$Type',1158);feb(1159,1,Qve,pk);_.Cd=function qk(a){this.a.Cd(this.b.Kb(a));};sfb(xve,'CollectSpliterators/1/lambda$1$Type',1159);feb(1154,1,Pve,rk);_.Ad=function vk(a){return ((16464|this.b)&a)!=0};_.yd=function sk(){return 16464|this.b};_.zd=function tk(){return this.a.zd()};_.Nb=function uk(a){this.a.Qe(new zk(a,this.c));};_.Bd=function wk(a){return this.a.Re(new xk(a,this.c))};_.b=0;sfb(xve,'CollectSpliterators/1WithCharacteristics',1154);feb(1155,1,Rve,xk);_.Dd=function yk(a){this.a.Cd(this.b.td(a));};sfb(xve,'CollectSpliterators/1WithCharacteristics/lambda$0$Type',1155);feb(1156,1,Rve,zk);_.Dd=function Ak(a){this.a.Cd(this.b.td(a));};sfb(xve,'CollectSpliterators/1WithCharacteristics/lambda$1$Type',1156);feb(1150,1,Pve);_.Ad=function Gk(a){return (this.a&a)!=0};_.yd=function Dk(){return this.a};_.zd=function Ek(){!!this.e&&(this.b=Kgb(this.b,this.e.zd()));return Kgb(this.b,0)};_.Nb=function Fk(a){if(this.e){this.e.Nb(a);this.e=null;}this.c.Nb(new Kk(this,a));this.b=0;};_.Bd=function Hk(a){while(true){if(!!this.e&&this.e.Bd(a)){Pdb(this.b,Sve)&&(this.b=Vdb(this.b,1));return true}else {this.e=null;}if(!this.c.Bd(new Ik(this))){return false}}};_.a=0;_.b=0;sfb(xve,'CollectSpliterators/FlatMapSpliterator',1150);feb(1152,1,Qve,Ik);_.Cd=function Jk(a){Bk(this.a,a);};sfb(xve,'CollectSpliterators/FlatMapSpliterator/lambda$0$Type',1152);feb(1153,1,Qve,Kk);_.Cd=function Lk(a){Ck(this.a,this.b,a);};sfb(xve,'CollectSpliterators/FlatMapSpliterator/lambda$1$Type',1153);feb(1151,1150,Pve,Mk);sfb(xve,'CollectSpliterators/FlatMapSpliteratorOfObject',1151);feb(253,1,Tve);_.Fd=function Sk(a){return this.Ed(RD(a,253))};_.Ed=function Rk(a){var b;if(a==(kl(),jl)){return 1}if(a==(Wk(),Vk)){return -1}b=(ux(),Leb(this.a,a.a));if(b!=0){return b}return ZD(this,526)==ZD(a,526)?0:ZD(this,526)?1:-1};_.Id=function Tk(){return this.a};_.Fb=function Uk(a){return Pk(this,a)};sfb(xve,'Cut',253);feb(1823,253,Tve,Xk);_.Ed=function Yk(a){return a==this?0:1};_.Gd=function Zk(a){throw Adb(new Ceb)};_.Hd=function $k(a){a.a+='+\u221E)';};_.Id=function _k(){throw Adb(new dgb(Uve))};_.Hb=function al(){return gib(),jFb(this)};_.Jd=function bl(a){return false};_.Ib=function cl(){return '+\u221E'};var Vk;sfb(xve,'Cut/AboveAll',1823);feb(526,253,{253:1,526:1,3:1,34:1},dl);_.Gd=function el(a){Yhb((a.a+='(',a),this.a);};_.Hd=function fl(a){Thb(Yhb(a,this.a),93);};_.Hb=function gl(){return ~tb(this.a)};_.Jd=function hl(a){return ux(),Leb(this.a,a)<0};_.Ib=function il(){return '/'+this.a+'\\'};sfb(xve,'Cut/AboveValue',526);feb(1822,253,Tve,ll);_.Ed=function ml(a){return a==this?0:-1};_.Gd=function nl(a){a.a+='(-\u221E';};_.Hd=function ol(a){throw Adb(new Ceb)};_.Id=function pl(){throw Adb(new dgb(Uve))};_.Hb=function ql(){return gib(),jFb(this)};_.Jd=function rl(a){return true};_.Ib=function sl(){return '-\u221E'};var jl;sfb(xve,'Cut/BelowAll',1822);feb(1824,253,Tve,tl);_.Gd=function ul(a){Yhb((a.a+='[',a),this.a);};_.Hd=function vl(a){Thb(Yhb(a,this.a),41);};_.Hb=function wl(){return tb(this.a)};_.Jd=function xl(a){return ux(),Leb(this.a,a)<=0};_.Ib=function yl(){return '\\'+this.a+'/'};sfb(xve,'Cut/BelowValue',1824);feb(547,1,Vve);_.Jc=function Bl(a){xgb(this,a);};_.Ib=function Cl(){return Lr(RD(Rb(this,'use Optional.orNull() instead of Optional.or(null)'),20).Kc())};sfb(xve,'FluentIterable',547);feb(442,547,Vve,Dl);_.Kc=function El(){return new is(Mr(this.a.Kc(),new ir))};sfb(xve,'FluentIterable/2',442);feb(1059,547,Vve,Gl);_.Kc=function Hl(){return Fl(this)};sfb(xve,'FluentIterable/3',1059);feb(724,399,yve,Il);_.Xb=function Jl(a){return this.a[a].Kc()};sfb(xve,'FluentIterable/3/1',724);feb(2070,1,{});_.Ib=function Kl(){return jeb(this.Kd().b)};sfb(xve,'ForwardingObject',2070);feb(2071,2070,Wve);_.Kd=function Ql(){return this.Ld()};_.Jc=function Rl(a){xgb(this,a);};_.Lc=function Ul(){return this.Oc()};_.Nc=function Xl(){return new Swb(this,0)};_.Oc=function Yl(){return new SDb(null,this.Nc())};_.Fc=function Ll(a){return this.Ld(),qpb()};_.Gc=function Ml(a){return this.Ld(),rpb()};_.$b=function Nl(){this.Ld(),spb();};_.Hc=function Ol(a){return this.Ld().Hc(a)};_.Ic=function Pl(a){return this.Ld().Ic(a)};_.dc=function Sl(){return this.Ld().b.dc()};_.Kc=function Tl(){return this.Ld().Kc()};_.Mc=function Vl(a){return this.Ld(),vpb()};_.gc=function Wl(){return this.Ld().b.gc()};_.Pc=function Zl(){return this.Ld().Pc()};_.Qc=function $l(a){return this.Ld().Qc(a)};sfb(xve,'ForwardingCollection',2071);feb(2078,31,Xve);_.Kc=function gm(){return this.Od()};_.Fc=function am(a){throw Adb(new jib)};_.Gc=function bm(a){throw Adb(new jib)};_.Md=function cm(){var a;a=this.c;return !a?(this.c=this.Nd()):a};_.$b=function dm(){throw Adb(new jib)};_.Hc=function em(a){return a!=null&&ze(this,a,false)};_.Nd=function fm(){switch(this.gc()){case 0:return tm(),tm(),sm;case 1:return tm(),new Dy(Qb(this.Od().Pb()));default:return new Fx(this,this.Pc());}};_.Mc=function hm(a){throw Adb(new jib)};sfb(xve,'ImmutableCollection',2078);feb(727,2078,Xve,im);_.Kc=function nm(){return Nr(this.a.Kc())};_.Hc=function jm(a){return a!=null&&this.a.Hc(a)};_.Ic=function km(a){return this.a.Ic(a)};_.dc=function lm(){return this.a.dc()};_.Od=function mm(){return Nr(this.a.Kc())};_.gc=function om(){return this.a.gc()};_.Pc=function pm(){return this.a.Pc()};_.Qc=function qm(a){return this.a.Qc(a)};_.Ib=function rm(){return jeb(this.a)};sfb(xve,'ForwardingImmutableCollection',727);feb(307,2078,Yve);_.Kc=function Em(){return this.Od()};_.ed=function Fm(){return this.Pd(0)};_.fd=function Hm(a){return this.Pd(a)};_.jd=function Lm(a){tvb(this,a);};_.Nc=function Mm(){return new Swb(this,16)};_.kd=function Om(a,b){return this.Qd(a,b)};_.bd=function wm(a,b){throw Adb(new jib)};_.cd=function xm(a,b){throw Adb(new jib)};_.Md=function ym(){return this};_.Fb=function Am(a){return $u(this,a)};_.Hb=function Bm(){return _u(this)};_.dd=function Cm(a){return a==null?-1:av(this,a)};_.Od=function Dm(){return this.Pd(0)};_.Pd=function Gm(a){return um(this,a)};_.gd=function Jm(a){throw Adb(new jib)};_.hd=function Km(a,b){throw Adb(new jib)};_.Qd=function Nm(a,b){var c;return Pm((c=new pv(this),new Rkb(c,a,b)))};var sm;sfb(xve,'ImmutableList',307);feb(2105,307,Yve);_.Kc=function Zm(){return Nr(this.Rd().Kc())};_.kd=function an(a,b){return Pm(this.Rd().kd(a,b))};_.Hc=function Rm(a){return a!=null&&this.Rd().Hc(a)};_.Ic=function Sm(a){return this.Rd().Ic(a)};_.Fb=function Tm(a){return pb(this.Rd(),a)};_.Xb=function Um(a){return Qm(this,a)};_.Hb=function Vm(){return tb(this.Rd())};_.dd=function Wm(a){return this.Rd().dd(a)};_.dc=function Xm(){return this.Rd().dc()};_.Od=function Ym(){return Nr(this.Rd().Kc())};_.gc=function $m(){return this.Rd().gc()};_.Qd=function _m(a,b){return Pm(this.Rd().kd(a,b))};_.Pc=function bn(){return this.Rd().Qc($C(jJ,rve,1,this.Rd().gc(),5,1))};_.Qc=function cn(a){return this.Rd().Qc(a)};_.Ib=function dn(){return jeb(this.Rd())};sfb(xve,'ForwardingImmutableList',2105);feb(729,1,$ve);_.vc=function pn(){return gn(this)};_.wc=function rn(a){Bvb(this,a);};_.ec=function vn(){return hn(this)};_.yc=function wn(a,b,c){return Cvb(this,a,b,c)};_.Cc=function Dn(){return this.Vd()};_.$b=function kn(){throw Adb(new jib)};_._b=function ln(a){return this.xc(a)!=null};_.uc=function mn(a){return this.Vd().Hc(a)};_.Td=function nn(){return new xq(this)};_.Ud=function on(){return new Gq(this)};_.Fb=function qn(a){return Tv(this,a)};_.Hb=function tn(){return gn(this).Hb()};_.dc=function un(){return this.gc()==0};_.zc=function zn(a,b){return jn()};_.Bc=function An(a){throw Adb(new jib)};_.Ib=function Bn(){return Zv(this)};_.Vd=function Cn(){if(this.e){return this.e}return this.e=this.Ud()};_.c=null;_.d=null;_.e=null;var en;sfb(xve,'ImmutableMap',729);feb(730,729,$ve);_._b=function Hn(a){return En(this,a)};_.uc=function In(a){return pqb(this.b,a)};_.Sd=function Jn(){return go(new Xn(this))};_.Td=function Kn(){return go(sqb(this.b))};_.Ud=function Ln(){return _l(),new im(tqb(this.b))};_.Fb=function Mn(a){return rqb(this.b,a)};_.xc=function Nn(a){return Fn(this,a)};_.Hb=function On(){return tb(this.b.c)};_.dc=function Pn(){return this.b.c.dc()};_.gc=function Qn(){return this.b.c.gc()};_.Ib=function Rn(){return jeb(this.b.c)};sfb(xve,'ForwardingImmutableMap',730);feb(2072,2071,_ve);_.Kd=function Sn(){return this.Wd()};_.Ld=function Tn(){return this.Wd()};_.Nc=function Wn(){return new Swb(this,1)};_.Fb=function Un(a){return a===this||this.Wd().Fb(a)};_.Hb=function Vn(){return this.Wd().Hb()};sfb(xve,'ForwardingSet',2072);feb(1085,2072,_ve,Xn);_.Kd=function Zn(){return qqb(this.a.b)};_.Ld=function $n(){return qqb(this.a.b)};_.Hc=function Yn(b){if(ZD(b,44)&&RD(b,44).ld()==null){return false}try{return Pqb(qqb(this.a.b),b)}catch(a){a=zdb(a);if(ZD(a,212)){return false}else throw Adb(a)}};_.Wd=function _n(){return qqb(this.a.b)};_.Qc=function ao(a){var b;b=Qqb(qqb(this.a.b),a);qqb(this.a.b).b.gc()=0?'+':'')+(c/60|0);b=AB($wnd.Math.abs(c)%60);return (Mrb(),Krb)[this.q.getDay()]+' '+Lrb[this.q.getMonth()]+' '+AB(this.q.getDate())+' '+AB(this.q.getHours())+':'+AB(this.q.getMinutes())+':'+AB(this.q.getSeconds())+' GMT'+a+b+' '+this.q.getFullYear()};var qK=sfb(Bve,'Date',206);feb(2015,206,bxe,DB);_.a=false;_.b=0;_.c=0;_.d=0;_.e=0;_.f=0;_.g=false;_.i=0;_.j=0;_.k=0;_.n=0;_.o=0;_.p=0;sfb('com.google.gwt.i18n.shared.impl','DateRecord',2015);feb(2064,1,{});_.pe=function EB(){return null};_.qe=function FB(){return null};_.re=function GB(){return null};_.se=function HB(){return null};_.te=function IB(){return null};sfb(cxe,'JSONValue',2064);feb(221,2064,{221:1},MB,NB);_.Fb=function OB(a){if(!ZD(a,221)){return false}return Hz(this.a,RD(a,221).a)};_.oe=function PB(){return TB};_.Hb=function QB(){return Iz(this.a)};_.pe=function RB(){return this};_.Ib=function SB(){var a,b,c;c=new dib('[');for(b=0,a=this.a.length;b0&&(c.a+=',',c);Yhb(c,JB(this,b));}c.a+=']';return c.a};sfb(cxe,'JSONArray',221);feb(493,2064,{493:1},XB);_.oe=function YB(){return _B};_.qe=function ZB(){return this};_.Ib=function $B(){return Geb(),''+this.a};_.a=false;var UB,VB;sfb(cxe,'JSONBoolean',493);feb(997,63,swe,aC);sfb(cxe,'JSONException',997);feb(1036,2064,{},dC);_.oe=function eC(){return gC};_.Ib=function fC(){return vve};var bC;sfb(cxe,'JSONNull',1036);feb(263,2064,{263:1},hC);_.Fb=function iC(a){if(!ZD(a,263)){return false}return this.a==RD(a,263).a};_.oe=function jC(){return nC};_.Hb=function kC(){return Nfb(this.a)};_.re=function lC(){return this};_.Ib=function mC(){return this.a+''};_.a=0;sfb(cxe,'JSONNumber',263);feb(190,2064,{190:1},uC,vC);_.Fb=function wC(a){if(!ZD(a,190)){return false}return Hz(this.a,RD(a,190).a)};_.oe=function xC(){return BC};_.Hb=function yC(){return Iz(this.a)};_.se=function zC(){return this};_.Ib=function AC(){var a,b,c,d,e,f,g;g=new dib('{');a=true;f=oC(this,$C(qJ,Nve,2,0,6,1));for(c=f,d=0,e=c.length;d=0?':'+this.c:'')+')'};_.c=0;var mJ=sfb(mve,'StackTraceElement',319);PD={3:1,484:1,34:1,2:1};var qJ=sfb(mve,uwe,2);feb(111,427,{484:1},Qhb,Rhb,Shb);sfb(mve,'StringBuffer',111);feb(104,427,{484:1},bib,cib,dib);sfb(mve,'StringBuilder',104);feb(702,77,lxe,eib);sfb(mve,'StringIndexOutOfBoundsException',702);feb(2145,1,{});var fib;feb(48,63,{3:1,103:1,63:1,82:1,48:1},jib,kib);sfb(mve,'UnsupportedOperationException',48);feb(247,242,{3:1,34:1,242:1,247:1},Aib,Bib);_.Fd=function Eib(a){return uib(this,RD(a,247))};_.ue=function Fib(){return Neb(zib(this))};_.Fb=function Gib(a){var b;if(this===a){return true}if(ZD(a,247)){b=RD(a,247);return this.e==b.e&&uib(this,b)==0}return false};_.Hb=function Hib(){var a;if(this.b!=0){return this.b}if(this.a<54){a=Hdb(this.f);this.b=Ydb(Cdb(a,-1));this.b=33*this.b+Ydb(Cdb(Tdb(a,32),-1));this.b=17*this.b+eE(this.e);return this.b}this.b=17*Vib(this.c)+eE(this.e);return this.b};_.Ib=function Iib(){return zib(this)};_.a=0;_.b=0;_.d=0;_.e=0;_.f=0;var lib,mib,nib,oib,pib,qib,rib,sib;var tJ=sfb('java.math','BigDecimal',247);feb(92,242,{3:1,34:1,242:1,92:1},ajb,bjb,cjb,djb,ejb);_.Fd=function gjb(a){return Qib(this,RD(a,92))};_.ue=function hjb(){return Neb(Ajb(this,0))};_.Fb=function ijb(a){return Sib(this,a)};_.Hb=function ljb(){return Vib(this)};_.Ib=function njb(){return Ajb(this,0)};_.b=-2;_.c=0;_.d=0;_.e=0;var Jib,Kib,Lib,Mib,Nib,Oib;var uJ=sfb('java.math','BigInteger',92);var vjb,wjb;var Jjb,Kjb;feb(498,2065,Cve);_.$b=function dkb(){akb(this);};_._b=function ekb(a){return Ujb(this,a)};_.uc=function fkb(a){return Vjb(this,a,this.i)||Vjb(this,a,this.f)};_.vc=function gkb(){return new mkb(this)};_.xc=function hkb(a){return Wjb(this,a)};_.zc=function ikb(a,b){return Zjb(this,a,b)};_.Bc=function jkb(a){return _jb(this,a)};_.gc=function kkb(){return bkb(this)};_.g=0;sfb(Bve,'AbstractHashMap',498);feb(267,Eve,Fve,mkb);_.$b=function nkb(){this.a.$b();};_.Hc=function okb(a){return lkb(this,a)};_.Kc=function pkb(){return new vkb(this.a)};_.Mc=function qkb(a){var b;if(lkb(this,a)){b=RD(a,44).ld();this.a.Bc(b);return true}return false};_.gc=function rkb(){return this.a.gc()};sfb(Bve,'AbstractHashMap/EntrySet',267);feb(268,1,Ave,vkb);_.Nb=function wkb(a){Ztb(this,a);};_.Pb=function ykb(){return tkb(this)};_.Ob=function xkb(){return this.b};_.Qb=function zkb(){ukb(this);};_.b=false;_.d=0;sfb(Bve,'AbstractHashMap/EntrySetIterator',268);feb(426,1,Ave,Dkb);_.Nb=function Ekb(a){Ztb(this,a);};_.Ob=function Fkb(){return Akb(this)};_.Pb=function Gkb(){return Bkb(this)};_.Qb=function Hkb(){Ckb(this);};_.b=0;_.c=-1;sfb(Bve,'AbstractList/IteratorImpl',426);feb(98,426,Jve,Jkb);_.Qb=function Pkb(){Ckb(this);};_.Rb=function Kkb(a){Ikb(this,a);};_.Sb=function Lkb(){return this.b>0};_.Tb=function Mkb(){return this.b};_.Ub=function Nkb(){return sFb(this.b>0),this.a.Xb(this.c=--this.b)};_.Vb=function Okb(){return this.b-1};_.Wb=function Qkb(a){yFb(this.c!=-1);this.a.hd(this.c,a);};sfb(Bve,'AbstractList/ListIteratorImpl',98);feb(244,56,kwe,Rkb);_.bd=function Skb(a,b){wFb(a,this.b);this.c.bd(this.a+a,b);++this.b;};_.Xb=function Tkb(a){tFb(a,this.b);return this.c.Xb(this.a+a)};_.gd=function Ukb(a){var b;tFb(a,this.b);b=this.c.gd(this.a+a);--this.b;return b};_.hd=function Vkb(a,b){tFb(a,this.b);return this.c.hd(this.a+a,b)};_.gc=function Wkb(){return this.b};_.a=0;_.b=0;sfb(Bve,'AbstractList/SubList',244);feb(266,Eve,Fve,Xkb);_.$b=function Ykb(){this.a.$b();};_.Hc=function Zkb(a){return this.a._b(a)};_.Kc=function $kb(){var a;return a=this.a.vc().Kc(),new blb(a)};_.Mc=function _kb(a){if(this.a._b(a)){this.a.Bc(a);return true}return false};_.gc=function alb(){return this.a.gc()};sfb(Bve,'AbstractMap/1',266);feb(541,1,Ave,blb);_.Nb=function clb(a){Ztb(this,a);};_.Ob=function dlb(){return this.a.Ob()};_.Pb=function elb(){var a;return a=RD(this.a.Pb(),44),a.ld()};_.Qb=function flb(){this.a.Qb();};sfb(Bve,'AbstractMap/1/1',541);feb(231,31,Dve,glb);_.$b=function hlb(){this.a.$b();};_.Hc=function ilb(a){return this.a.uc(a)};_.Kc=function jlb(){var a;return a=this.a.vc().Kc(),new llb(a)};_.gc=function klb(){return this.a.gc()};sfb(Bve,'AbstractMap/2',231);feb(301,1,Ave,llb);_.Nb=function mlb(a){Ztb(this,a);};_.Ob=function nlb(){return this.a.Ob()};_.Pb=function olb(){var a;return a=RD(this.a.Pb(),44),a.md()};_.Qb=function plb(){this.a.Qb();};sfb(Bve,'AbstractMap/2/1',301);feb(494,1,{494:1,44:1});_.Fb=function rlb(a){var b;if(!ZD(a,44)){return false}b=RD(a,44);return Fvb(this.d,b.ld())&&Fvb(this.e,b.md())};_.ld=function slb(){return this.d};_.md=function tlb(){return this.e};_.Hb=function ulb(){return Gvb(this.d)^Gvb(this.e)};_.nd=function vlb(a){return qlb(this,a)};_.Ib=function wlb(){return this.d+'='+this.e};sfb(Bve,'AbstractMap/AbstractEntry',494);feb(397,494,{494:1,397:1,44:1},xlb);sfb(Bve,'AbstractMap/SimpleEntry',397);feb(2082,1,Axe);_.Fb=function ylb(a){var b;if(!ZD(a,44)){return false}b=RD(a,44);return Fvb(this.ld(),b.ld())&&Fvb(this.md(),b.md())};_.Hb=function zlb(){return Gvb(this.ld())^Gvb(this.md())};_.Ib=function Alb(){return this.ld()+'='+this.md()};sfb(Bve,Lve,2082);feb(2090,2065,Gve);_.Xc=function Dlb(a){return Vd(this.Ee(a))};_.tc=function Elb(a){return Blb(this,a)};_._b=function Flb(a){return Clb(this,a)};_.vc=function Glb(){return new Plb(this)};_.Tc=function Hlb(){return Klb(this.Ge())};_.Yc=function Ilb(a){return Vd(this.He(a))};_.xc=function Jlb(a){var b;b=a;return Wd(this.Fe(b))};_.$c=function Llb(a){return Vd(this.Ie(a))};_.ec=function Mlb(){return new Ulb(this)};_.Vc=function Nlb(){return Klb(this.Je())};_._c=function Olb(a){return Vd(this.Ke(a))};sfb(Bve,'AbstractNavigableMap',2090);feb(629,Eve,Fve,Plb);_.Hc=function Qlb(a){return ZD(a,44)&&Blb(this.b,RD(a,44))};_.Kc=function Rlb(){return this.b.De()};_.Mc=function Slb(a){var b;if(ZD(a,44)){b=RD(a,44);return this.b.Le(b)}return false};_.gc=function Tlb(){return this.b.gc()};sfb(Bve,'AbstractNavigableMap/EntrySet',629);feb(1146,Eve,Ive,Ulb);_.Nc=function $lb(){return new $wb(this)};_.$b=function Vlb(){this.a.$b();};_.Hc=function Wlb(a){return Clb(this.a,a)};_.Kc=function Xlb(){var a;a=this.a.vc().b.De();return new _lb(a)};_.Mc=function Ylb(a){if(Clb(this.a,a)){this.a.Bc(a);return true}return false};_.gc=function Zlb(){return this.a.gc()};sfb(Bve,'AbstractNavigableMap/NavigableKeySet',1146);feb(1147,1,Ave,_lb);_.Nb=function amb(a){Ztb(this,a);};_.Ob=function bmb(){return Akb(this.a.a)};_.Pb=function cmb(){var a;a=vzb(this.a);return a.ld()};_.Qb=function dmb(){wzb(this.a);};sfb(Bve,'AbstractNavigableMap/NavigableKeySet/1',1147);feb(2103,31,Dve);_.Fc=function emb(a){return zFb(lwb(this,a),Bxe),true};_.Gc=function fmb(a){uFb(a);mFb(a!=this,"Can't add a queue to itself");return ye(this,a)};_.$b=function gmb(){while(mwb(this)!=null);};sfb(Bve,'AbstractQueue',2103);feb(310,31,{4:1,20:1,31:1,16:1},wmb,xmb);_.Fc=function ymb(a){return imb(this,a),true};_.$b=function Amb(){jmb(this);};_.Hc=function Bmb(a){return kmb(new Kmb(this),a)};_.dc=function Cmb(){return nmb(this)};_.Kc=function Dmb(){return new Kmb(this)};_.Mc=function Emb(a){return qmb(new Kmb(this),a)};_.gc=function Fmb(){return this.c-this.b&this.a.length-1};_.Nc=function Gmb(){return new Swb(this,272)};_.Qc=function Hmb(a){var b;b=this.c-this.b&this.a.length-1;a.lengthb&&bD(a,b,null);return a};_.b=0;_.c=0;sfb(Bve,'ArrayDeque',310);feb(459,1,Ave,Kmb);_.Nb=function Lmb(a){Ztb(this,a);};_.Ob=function Mmb(){return this.a!=this.b};_.Pb=function Nmb(){return Imb(this)};_.Qb=function Omb(){Jmb(this);};_.a=0;_.b=0;_.c=-1;sfb(Bve,'ArrayDeque/IteratorImpl',459);feb(13,56,Cxe,bnb,cnb,dnb);_.bd=function enb(a,b){Qmb(this,a,b);};_.Fc=function fnb(a){return Rmb(this,a)};_.cd=function gnb(a,b){return Smb(this,a,b)};_.Gc=function hnb(a){return Tmb(this,a)};_.$b=function inb(){aFb(this.c,0);};_.Hc=function jnb(a){return Wmb(this,a,0)!=-1};_.Jc=function knb(a){Umb(this,a);};_.Xb=function lnb(a){return Vmb(this,a)};_.dd=function mnb(a){return Wmb(this,a,0)};_.dc=function nnb(){return this.c.length==0};_.Kc=function onb(){return new Anb(this)};_.gd=function pnb(a){return Xmb(this,a)};_.Mc=function qnb(a){return Ymb(this,a)};_.ce=function rnb(a,b){Zmb(this,a,b);};_.hd=function snb(a,b){return $mb(this,a,b)};_.gc=function tnb(){return this.c.length};_.jd=function unb(a){_mb(this,a);};_.Pc=function vnb(){return UEb(this.c)};_.Qc=function wnb(a){return anb(this,a)};var VJ=sfb(Bve,'ArrayList',13);feb(7,1,Ave,Anb);_.Nb=function Bnb(a){Ztb(this,a);};_.Ob=function Cnb(){return xnb(this)};_.Pb=function Dnb(){return ynb(this)};_.Qb=function Enb(){znb(this);};_.a=0;_.b=-1;sfb(Bve,'ArrayList/1',7);feb(2112,$wnd.Function,{},iob);_.Me=function job(a,b){return Qfb(a,b)};feb(151,56,Dxe,mob);_.Hc=function nob(a){return St(this,a)!=-1};_.Jc=function oob(a){var b,c,d,e;uFb(a);for(c=this.a,d=0,e=c.length;d0){throw Adb(new agb(Sxe+a+' greater than '+this.e))}return this.f.Te()?bzb(this.c,this.b,this.a,a,b):Ryb(this.c,a,b)};_.zc=function Vzb(a,b){if(!Tyb(this.c,this.f,a,this.b,this.a,this.e,this.d)){throw Adb(new agb(a+' outside the range '+this.b+' to '+this.e))}return Wyb(this.c,a,b)};_.Bc=function Wzb(a){var b;b=a;if(!Tyb(this.c,this.f,b,this.b,this.a,this.e,this.d)){return null}return Xyb(this.c,b)};_.Le=function Xzb(a){return Jzb(this,a.ld())&&Yyb(this.c,a)};_.gc=function Yzb(){var a,b,c;this.f.Te()?this.a?(b=Pyb(this.c,this.b,true)):(b=Pyb(this.c,this.b,false)):(b=Nyb(this.c));if(!(!!b&&Jzb(this,b.d)?b:null)){return 0}a=0;for(c=new yzb(this.c,this.f,this.b,this.a,this.e,this.d);Akb(c.a);c.b=RD(Bkb(c.a),44)){++a;}return a};_.ad=function Zzb(a,b){if(this.f.Te()&&this.c.a.Ne(a,this.b)<0){throw Adb(new agb(Sxe+a+Txe+this.b))}return this.f.Ue()?bzb(this.c,a,b,this.e,this.d):czb(this.c,a,b)};_.a=false;_.d=false;sfb(Bve,'TreeMap/SubMap',631);feb(304,22,Uxe,dAb);_.Te=function eAb(){return false};_.Ue=function fAb(){return false};var $zb,_zb,aAb,bAb;var AL=tfb(Bve,'TreeMap/SubMapType',304,WI,hAb,gAb);feb(1143,304,Uxe,iAb);_.Ue=function jAb(){return true};tfb(Bve,'TreeMap/SubMapType/1',1143,AL,null,null);feb(1144,304,Uxe,kAb);_.Te=function lAb(){return true};_.Ue=function mAb(){return true};tfb(Bve,'TreeMap/SubMapType/2',1144,AL,null,null);feb(1145,304,Uxe,nAb);_.Te=function oAb(){return true};tfb(Bve,'TreeMap/SubMapType/3',1145,AL,null,null);var pAb;feb(157,Eve,{3:1,20:1,31:1,16:1,277:1,21:1,87:1,157:1},xAb,yAb,zAb);_.Nc=function GAb(){return new $wb(this)};_.Fc=function AAb(a){return rAb(this,a)};_.$b=function BAb(){this.a.$b();};_.Hc=function CAb(a){return this.a._b(a)};_.Kc=function DAb(){return this.a.ec().Kc()};_.Mc=function EAb(a){return wAb(this,a)};_.gc=function FAb(){return this.a.gc()};var DL=sfb(Bve,'TreeSet',157);feb(1082,1,{},JAb);_.Ve=function KAb(a,b){return HAb(this.a,a,b)};sfb(Vxe,'BinaryOperator/lambda$0$Type',1082);feb(1083,1,{},LAb);_.Ve=function MAb(a,b){return IAb(this.a,a,b)};sfb(Vxe,'BinaryOperator/lambda$1$Type',1083);feb(952,1,{},NAb);_.Kb=function OAb(a){return a};sfb(Vxe,'Function/lambda$0$Type',952);feb(395,1,nwe,PAb);_.Mb=function QAb(a){return !this.a.Mb(a)};sfb(Vxe,'Predicate/lambda$2$Type',395);feb(581,1,{581:1});var JL=sfb(Wxe,'Handler',581);feb(2107,1,nve);_.xe=function TAb(){return 'DUMMY'};_.Ib=function UAb(){return this.xe()};var RAb;sfb(Wxe,'Level',2107);feb(1706,2107,nve,VAb);_.xe=function WAb(){return 'INFO'};sfb(Wxe,'Level/LevelInfo',1706);feb(1843,1,{},$Ab);var XAb;sfb(Wxe,'LogManager',1843);feb(1896,1,nve,aBb);_.b=null;sfb(Wxe,'LogRecord',1896);feb(525,1,{525:1},oBb);_.e=false;var bBb=false,cBb=false,dBb=false,eBb=false,fBb=false;sfb(Wxe,'Logger',525);feb(835,581,{581:1},rBb);sfb(Wxe,'SimpleConsoleLogHandler',835);feb(108,22,{3:1,34:1,22:1,108:1},yBb);var uBb,vBb,wBb;var QL=tfb(Zxe,'Collector/Characteristics',108,WI,ABb,zBb);var BBb;feb(758,1,{},DBb);sfb(Zxe,'CollectorImpl',758);feb(1074,1,{},RBb);_.Ve=function SBb(a,b){return Hyb(RD(a,213),RD(b,213))};sfb(Zxe,'Collectors/10methodref$merge$Type',1074);feb(1075,1,{},TBb);_.Kb=function UBb(a){return Iyb(RD(a,213))};sfb(Zxe,'Collectors/11methodref$toString$Type',1075);feb(1076,1,{},VBb);_.Kb=function WBb(a){return Geb(),SSb(a)?true:false};sfb(Zxe,'Collectors/12methodref$test$Type',1076);feb(144,1,{},XBb);_.Yd=function YBb(a,b){RD(a,16).Fc(b);};sfb(Zxe,'Collectors/20methodref$add$Type',144);feb(146,1,{},ZBb);_.Xe=function $Bb(){return new bnb};sfb(Zxe,'Collectors/21methodref$ctor$Type',146);feb(359,1,{},_Bb);_.Xe=function aCb(){return new _sb};sfb(Zxe,'Collectors/23methodref$ctor$Type',359);feb(360,1,{},bCb);_.Yd=function cCb(a,b){Ysb(RD(a,49),b);};sfb(Zxe,'Collectors/24methodref$add$Type',360);feb(1069,1,{},dCb);_.Ve=function eCb(a,b){return EBb(RD(a,15),RD(b,16))};sfb(Zxe,'Collectors/4methodref$addAll$Type',1069);feb(1073,1,{},fCb);_.Yd=function gCb(a,b){Gyb(RD(a,213),RD(b,484));};sfb(Zxe,'Collectors/9methodref$add$Type',1073);feb(1072,1,{},hCb);_.Xe=function iCb(){return new Jyb(this.a,this.b,this.c)};sfb(Zxe,'Collectors/lambda$15$Type',1072);feb(1077,1,{},jCb);_.Xe=function kCb(){var a;return a=new gub,dub(a,(Geb(),false),new bnb),dub(a,true,new bnb),a};sfb(Zxe,'Collectors/lambda$22$Type',1077);feb(1078,1,{},lCb);_.Xe=function mCb(){return cD(WC(jJ,1),rve,1,5,[this.a])};sfb(Zxe,'Collectors/lambda$25$Type',1078);feb(1079,1,{},nCb);_.Yd=function oCb(a,b){GBb(this.a,SD(a));};sfb(Zxe,'Collectors/lambda$26$Type',1079);feb(1080,1,{},pCb);_.Ve=function qCb(a,b){return HBb(this.a,SD(a),SD(b))};sfb(Zxe,'Collectors/lambda$27$Type',1080);feb(1081,1,{},rCb);_.Kb=function sCb(a){return SD(a)[0]};sfb(Zxe,'Collectors/lambda$28$Type',1081);feb(728,1,{},uCb);_.Ve=function vCb(a,b){return tCb(a,b)};sfb(Zxe,'Collectors/lambda$4$Type',728);feb(145,1,{},wCb);_.Ve=function xCb(a,b){return JBb(RD(a,16),RD(b,16))};sfb(Zxe,'Collectors/lambda$42$Type',145);feb(361,1,{},yCb);_.Ve=function zCb(a,b){return KBb(RD(a,49),RD(b,49))};sfb(Zxe,'Collectors/lambda$50$Type',361);feb(362,1,{},ACb);_.Kb=function BCb(a){return RD(a,49)};sfb(Zxe,'Collectors/lambda$51$Type',362);feb(1068,1,{},CCb);_.Yd=function DCb(a,b){LBb(this.a,RD(a,85),b);};sfb(Zxe,'Collectors/lambda$7$Type',1068);feb(1070,1,{},ECb);_.Ve=function FCb(a,b){return NBb(RD(a,85),RD(b,85),new dCb)};sfb(Zxe,'Collectors/lambda$8$Type',1070);feb(1071,1,{},GCb);_.Kb=function HCb(a){return MBb(this.a,RD(a,85))};sfb(Zxe,'Collectors/lambda$9$Type',1071);feb(550,1,{});_.$e=function OCb(){ICb(this);};_.d=false;sfb(Zxe,'TerminatableStream',550);feb(827,550,$xe,WCb);_.$e=function XCb(){ICb(this);};sfb(Zxe,'DoubleStreamImpl',827);feb(1847,736,Pve,$Cb);_.Re=function aDb(a){return ZCb(this,RD(a,189))};_.a=null;sfb(Zxe,'DoubleStreamImpl/2',1847);feb(1848,1,Gxe,bDb);_.Pe=function cDb(a){_Cb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/2/lambda$0$Type',1848);feb(1845,1,Gxe,dDb);_.Pe=function eDb(a){YCb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/lambda$0$Type',1845);feb(1846,1,Gxe,fDb);_.Pe=function gDb(a){Nrb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/lambda$2$Type',1846);feb(1397,735,Pve,kDb);_.Re=function lDb(a){return jDb(this,RD(a,202))};_.a=0;_.b=0;_.c=0;sfb(Zxe,'IntStream/5',1397);feb(806,550,$xe,oDb);_.$e=function pDb(){ICb(this);};_._e=function qDb(){return LCb(this),this.a};sfb(Zxe,'IntStreamImpl',806);feb(807,550,$xe,rDb);_.$e=function sDb(){ICb(this);};_._e=function tDb(){return LCb(this),Txb(),Sxb};sfb(Zxe,'IntStreamImpl/Empty',807);feb(1687,1,Rve,uDb);_.Dd=function vDb(a){ktb(this.a,a);};sfb(Zxe,'IntStreamImpl/lambda$4$Type',1687);var RM=ufb(Zxe,'Stream');feb(26,550,{533:1,687:1,848:1},SDb);_.$e=function TDb(){ICb(this);};var wDb;sfb(Zxe,'StreamImpl',26);feb(1102,500,Pve,YDb);_.Bd=function ZDb(a){while(WDb(this)){if(this.a.Bd(a)){return true}else {ICb(this.b);this.b=null;this.a=null;}}return false};sfb(Zxe,'StreamImpl/1',1102);feb(1103,1,Qve,$Db);_.Cd=function _Db(a){XDb(this.a,RD(a,848));};sfb(Zxe,'StreamImpl/1/lambda$0$Type',1103);feb(1104,1,nwe,aEb);_.Mb=function bEb(a){return Ysb(this.a,a)};sfb(Zxe,'StreamImpl/1methodref$add$Type',1104);feb(1105,500,Pve,cEb);_.Bd=function dEb(a){var b;if(!this.a){b=new bnb;this.b.a.Nb(new eEb(b));yob();_mb(b,this.c);this.a=new Swb(b,16);}return Rwb(this.a,a)};_.a=null;sfb(Zxe,'StreamImpl/5',1105);feb(1106,1,Qve,eEb);_.Cd=function fEb(a){Rmb(this.a,a);};sfb(Zxe,'StreamImpl/5/2methodref$add$Type',1106);feb(737,500,Pve,hEb);_.Bd=function iEb(a){this.b=false;while(!this.b&&this.c.Bd(new jEb(this,a)));return this.b};_.b=false;sfb(Zxe,'StreamImpl/FilterSpliterator',737);feb(1096,1,Qve,jEb);_.Cd=function kEb(a){gEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/FilterSpliterator/lambda$0$Type',1096);feb(1091,736,Pve,nEb);_.Re=function oEb(a){return mEb(this,RD(a,189))};sfb(Zxe,'StreamImpl/MapToDoubleSpliterator',1091);feb(1095,1,Qve,pEb);_.Cd=function qEb(a){lEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToDoubleSpliterator/lambda$0$Type',1095);feb(1090,735,Pve,tEb);_.Re=function uEb(a){return sEb(this,RD(a,202))};sfb(Zxe,'StreamImpl/MapToIntSpliterator',1090);feb(1094,1,Qve,vEb);_.Cd=function wEb(a){rEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToIntSpliterator/lambda$0$Type',1094);feb(734,500,Pve,zEb);_.Bd=function AEb(a){return yEb(this,a)};sfb(Zxe,'StreamImpl/MapToObjSpliterator',734);feb(1093,1,Qve,BEb);_.Cd=function CEb(a){xEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToObjSpliterator/lambda$0$Type',1093);feb(1092,500,Pve,DEb);_.Bd=function EEb(a){while(Idb(this.b,0)){if(!this.a.Bd(new FEb)){return false}this.b=Vdb(this.b,1);}return this.a.Bd(a)};_.b=0;sfb(Zxe,'StreamImpl/SkipSpliterator',1092);feb(1097,1,Qve,FEb);_.Cd=function GEb(a){};sfb(Zxe,'StreamImpl/SkipSpliterator/lambda$0$Type',1097);feb(626,1,Qve,IEb);_.Cd=function JEb(a){HEb(this,a);};sfb(Zxe,'StreamImpl/ValueConsumer',626);feb(1098,1,Qve,KEb);_.Cd=function LEb(a){xDb();};sfb(Zxe,'StreamImpl/lambda$0$Type',1098);feb(1099,1,Qve,MEb);_.Cd=function NEb(a){xDb();};sfb(Zxe,'StreamImpl/lambda$1$Type',1099);feb(1100,1,{},OEb);_.Ve=function PEb(a,b){return UDb(this.a,a,b)};sfb(Zxe,'StreamImpl/lambda$4$Type',1100);feb(1101,1,Qve,QEb);_.Cd=function REb(a){VDb(this.b,this.a,a);};sfb(Zxe,'StreamImpl/lambda$5$Type',1101);feb(1107,1,Qve,SEb);_.Cd=function TEb(a){PCb(this.a,RD(a,380));};sfb(Zxe,'TerminatableStream/lambda$0$Type',1107);feb(2142,1,{});feb(2014,1,{},gFb);sfb('javaemul.internal','ConsoleLogger',2014);var iFb=0;feb(2134,1,{});feb(1830,1,Qve,FFb);_.Cd=function GFb(a){RD(a,317);};sfb(eye,'BowyerWatsonTriangulation/lambda$0$Type',1830);feb(1831,1,Qve,HFb);_.Cd=function IFb(a){ye(this.a,RD(a,317).e);};sfb(eye,'BowyerWatsonTriangulation/lambda$1$Type',1831);feb(1832,1,Qve,JFb);_.Cd=function KFb(a){RD(a,177);};sfb(eye,'BowyerWatsonTriangulation/lambda$2$Type',1832);feb(1827,1,fye,NFb);_.Ne=function OFb(a,b){return MFb(this.a,RD(a,177),RD(b,177))};_.Fb=function PFb(a){return this===a};_.Oe=function QFb(){return new Frb(this)};sfb(eye,'NaiveMinST/lambda$0$Type',1827);feb(449,1,{},SFb);sfb(eye,'NodeMicroLayout',449);feb(177,1,{177:1},TFb);_.Fb=function UFb(a){var b;if(ZD(a,177)){b=RD(a,177);return Fvb(this.a,b.a)&&Fvb(this.b,b.b)||Fvb(this.a,b.b)&&Fvb(this.b,b.a)}else {return false}};_.Hb=function VFb(){return Gvb(this.a)+Gvb(this.b)};var $M=sfb(eye,'TEdge',177);feb(317,1,{317:1},XFb);_.Fb=function YFb(a){var b;if(ZD(a,317)){b=RD(a,317);return WFb(this,b.a)&&WFb(this,b.b)&&WFb(this,b.c)}else {return false}};_.Hb=function ZFb(){return Gvb(this.a)+Gvb(this.b)+Gvb(this.c)};sfb(eye,'TTriangle',317);feb(225,1,{225:1},$Fb);sfb(eye,'Tree',225);feb(1218,1,{},aGb);sfb(gye,'Scanline',1218);var bN=ufb(gye,hye);feb(1758,1,{},dGb);sfb(iye,'CGraph',1758);feb(316,1,{316:1},fGb);_.b=0;_.c=0;_.d=0;_.g=0;_.i=0;_.k=pxe;sfb(iye,'CGroup',316);feb(830,1,{},jGb);sfb(iye,'CGroup/CGroupBuilder',830);feb(60,1,{60:1},kGb);_.Ib=function lGb(){var a;if(this.j){return WD(this.j.Kb(this))}return lfb(hN),hN.o+'@'+(a=kFb(this)>>>0,a.toString(16))};_.f=0;_.i=pxe;var hN=sfb(iye,'CNode',60);feb(829,1,{},qGb);sfb(iye,'CNode/CNodeBuilder',829);var vGb;feb(1590,1,{},xGb);_.ff=function yGb(a,b){return 0};_.gf=function zGb(a,b){return 0};sfb(iye,kye,1590);feb(1853,1,{},AGb);_.cf=function BGb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;j=oxe;for(d=new Anb(a.a.b);d.ad.d.c||d.d.c==f.d.c&&d.d.b0?a+this.n.d+this.n.a:0};_.kf=function yKb(){var a,b,c,d,e;e=0;if(this.e){this.b?(e=this.b.a):!!this.a[1][1]&&(e=this.a[1][1].kf());}else if(this.g){e=vKb(this,pKb(this,null,true));}else {for(b=(ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])),c=0,d=b.length;c0?e+this.n.b+this.n.c:0};_.lf=function zKb(){var a,b,c,d,e;if(this.g){a=pKb(this,null,false);for(c=(ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])),d=0,e=c.length;d0){d[0]+=this.d;c-=d[0];}if(d[2]>0){d[2]+=this.d;c-=d[2];}this.c.a=$wnd.Math.max(0,c);this.c.d=b.d+a.d+(this.c.a-c)/2;d[1]=$wnd.Math.max(d[1],c);lKb(this,XJb,b.d+a.d+d[0]-(d[1]-c)/2,d);};_.b=null;_.d=0;_.e=false;_.f=false;_.g=false;var iKb=0,jKb=0;sfb(Jye,'GridContainerCell',1538);feb(471,22,{3:1,34:1,22:1,471:1},FKb);var BKb,CKb,DKb;var MN=tfb(Jye,'HorizontalLabelAlignment',471,WI,HKb,GKb);var IKb;feb(314,217,{217:1,314:1},TKb,UKb,VKb);_.jf=function WKb(){return PKb(this)};_.kf=function XKb(){return QKb(this)};_.a=0;_.c=false;var NN=sfb(Jye,'LabelCell',314);feb(252,336,{217:1,336:1,252:1},dLb);_.jf=function eLb(){return YKb(this)};_.kf=function fLb(){return ZKb(this)};_.lf=function iLb(){$Kb(this);};_.mf=function jLb(){_Kb(this);};_.b=0;_.c=0;_.d=false;sfb(Jye,'StripContainerCell',252);feb(1691,1,nwe,kLb);_.Mb=function lLb(a){return gLb(RD(a,217))};sfb(Jye,'StripContainerCell/lambda$0$Type',1691);feb(1692,1,{},mLb);_.Ye=function nLb(a){return RD(a,217).kf()};sfb(Jye,'StripContainerCell/lambda$1$Type',1692);feb(1693,1,nwe,oLb);_.Mb=function pLb(a){return hLb(RD(a,217))};sfb(Jye,'StripContainerCell/lambda$2$Type',1693);feb(1694,1,{},qLb);_.Ye=function rLb(a){return RD(a,217).jf()};sfb(Jye,'StripContainerCell/lambda$3$Type',1694);feb(472,22,{3:1,34:1,22:1,472:1},wLb);var sLb,tLb,uLb;var TN=tfb(Jye,'VerticalLabelAlignment',472,WI,yLb,xLb);var zLb;feb(800,1,{},CLb);_.c=0;_.d=0;_.k=0;_.s=0;_.t=0;_.v=false;_.w=0;_.D=false;_.F=false;sfb(Rye,'NodeContext',800);feb(1536,1,fye,FLb);_.Ne=function GLb(a,b){return ELb(RD(a,64),RD(b,64))};_.Fb=function HLb(a){return this===a};_.Oe=function ILb(){return new Frb(this)};sfb(Rye,'NodeContext/0methodref$comparePortSides$Type',1536);feb(1537,1,fye,JLb);_.Ne=function KLb(a,b){return DLb(RD(a,117),RD(b,117))};_.Fb=function LLb(a){return this===a};_.Oe=function MLb(){return new Frb(this)};sfb(Rye,'NodeContext/1methodref$comparePortContexts$Type',1537);feb(164,22,{3:1,34:1,22:1,164:1},kMb);var NLb,OLb,PLb,QLb,RLb,SLb,TLb,ULb,VLb,WLb,XLb,YLb,ZLb,$Lb,_Lb,aMb,bMb,cMb,dMb,eMb,fMb,gMb;var XN=tfb(Rye,'NodeLabelLocation',164,WI,nMb,mMb);var oMb;feb(117,1,{117:1},rMb);_.a=false;sfb(Rye,'PortContext',117);feb(1541,1,Qve,KMb);_.Cd=function LMb(a){NKb(RD(a,314));};sfb(Uye,Vye,1541);feb(1542,1,nwe,MMb);_.Mb=function NMb(a){return !!RD(a,117).c};sfb(Uye,Wye,1542);feb(1543,1,Qve,OMb);_.Cd=function PMb(a){NKb(RD(a,117).c);};sfb(Uye,'LabelPlacer/lambda$2$Type',1543);var QMb;feb(1540,1,Qve,YMb);_.Cd=function ZMb(a){RMb();qMb(RD(a,117));};sfb(Uye,'NodeLabelAndSizeUtilities/lambda$0$Type',1540);feb(801,1,Qve,dNb);_.Cd=function eNb(a){bNb(this.b,this.c,this.a,RD(a,187));};_.a=false;_.c=false;sfb(Uye,'NodeLabelCellCreator/lambda$0$Type',801);feb(1539,1,Qve,kNb);_.Cd=function lNb(a){jNb(this.a,RD(a,187));};sfb(Uye,'PortContextCreator/lambda$0$Type',1539);var sNb;feb(1902,1,{},MNb);sfb(Yye,'GreedyRectangleStripOverlapRemover',1902);feb(1903,1,fye,ONb);_.Ne=function PNb(a,b){return NNb(RD(a,226),RD(b,226))};_.Fb=function QNb(a){return this===a};_.Oe=function RNb(){return new Frb(this)};sfb(Yye,'GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type',1903);feb(1849,1,{},YNb);_.a=5;_.e=0;sfb(Yye,'RectangleStripOverlapRemover',1849);feb(1850,1,fye,aOb);_.Ne=function bOb(a,b){return ZNb(RD(a,226),RD(b,226))};_.Fb=function cOb(a){return this===a};_.Oe=function dOb(){return new Frb(this)};sfb(Yye,'RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type',1850);feb(1852,1,fye,eOb);_.Ne=function fOb(a,b){return $Nb(RD(a,226),RD(b,226))};_.Fb=function gOb(a){return this===a};_.Oe=function hOb(){return new Frb(this)};sfb(Yye,'RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type',1852);feb(417,22,{3:1,34:1,22:1,417:1},nOb);var iOb,jOb,kOb,lOb;var hO=tfb(Yye,'RectangleStripOverlapRemover/OverlapRemovalDirection',417,WI,pOb,oOb);var qOb;feb(226,1,{226:1},sOb);sfb(Yye,'RectangleStripOverlapRemover/RectangleNode',226);feb(1851,1,Qve,tOb);_.Cd=function uOb(a){TNb(this.a,RD(a,226));};sfb(Yye,'RectangleStripOverlapRemover/lambda$1$Type',1851);feb(1323,1,fye,xOb);_.Ne=function yOb(a,b){return wOb(RD(a,176),RD(b,176))};_.Fb=function zOb(a){return this===a};_.Oe=function AOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator',1323);feb(1326,1,{},BOb);_.Kb=function COb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$0$Type',1326);feb(1327,1,nwe,DOb);_.Mb=function EOb(a){return RD(a,332).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$1$Type',1327);feb(1328,1,nwe,FOb);_.Mb=function GOb(a){return RD(a,332).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$2$Type',1328);feb(1321,1,fye,IOb);_.Ne=function JOb(a,b){return HOb(RD(a,176),RD(b,176))};_.Fb=function KOb(a){return this===a};_.Oe=function LOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinNumOfExtensionDirectionsComparator',1321);feb(1324,1,{},MOb);_.Kb=function NOb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/MinNumOfExtensionDirectionsComparator/lambda$0$Type',1324);feb(781,1,fye,POb);_.Ne=function QOb(a,b){return OOb(RD(a,176),RD(b,176))};_.Fb=function ROb(a){return this===a};_.Oe=function SOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinNumOfExtensionsComparator',781);feb(1319,1,fye,UOb);_.Ne=function VOb(a,b){return TOb(RD(a,330),RD(b,330))};_.Fb=function WOb(a){return this===a};_.Oe=function XOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinPerimeterComparator',1319);feb(1320,1,fye,ZOb);_.Ne=function $Ob(a,b){return YOb(RD(a,330),RD(b,330))};_.Fb=function _Ob(a){return this===a};_.Oe=function aPb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinPerimeterComparatorWithShape',1320);feb(1322,1,fye,cPb);_.Ne=function dPb(a,b){return bPb(RD(a,176),RD(b,176))};_.Fb=function ePb(a){return this===a};_.Oe=function fPb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/SingleExtensionSideGreaterThanRestComparator',1322);feb(1325,1,{},gPb);_.Kb=function hPb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/SingleExtensionSideGreaterThanRestComparator/lambda$0$Type',1325);feb(782,1,{},kPb);_.Ve=function lPb(a,b){return jPb(this,RD(a,42),RD(b,176))};sfb($ye,'SuccessorCombination',782);feb(649,1,{},nPb);_.Ve=function oPb(a,b){var c;return mPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorJitter',649);feb(648,1,{},qPb);_.Ve=function rPb(a,b){var c;return pPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorLineByLine',648);feb(573,1,{},tPb);_.Ve=function uPb(a,b){var c;return sPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorManhattan',573);feb(1344,1,{},wPb);_.Ve=function xPb(a,b){var c;return vPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorMaxNormWindingInMathPosSense',1344);feb(409,1,{},APb);_.Ve=function BPb(a,b){return yPb(this,a,b)};_.c=false;_.d=false;_.e=false;_.f=false;sfb($ye,'SuccessorQuadrantsGeneric',409);feb(1345,1,{},CPb);_.Kb=function DPb(a){return RD(a,334).a};sfb($ye,'SuccessorQuadrantsGeneric/lambda$0$Type',1345);feb(332,22,{3:1,34:1,22:1,332:1},JPb);_.a=false;var EPb,FPb,GPb,HPb;var DO=tfb(dze,eze,332,WI,LPb,KPb);var MPb;feb(1317,1,{});_.Ib=function UPb(){var a,b,c,d,e,f;c=' ';a=sgb(0);for(e=0;e=0?'b'+a+'['+bUb(this.a)+']':'b['+bUb(this.a)+']'}return 'b_'+kFb(this)};sfb(Oze,'FBendpoint',250);feb(290,137,{3:1,290:1,96:1,137:1},cUb);_.Ib=function dUb(){return bUb(this)};sfb(Oze,'FEdge',290);feb(235,137,{3:1,235:1,96:1,137:1},gUb);var tP=sfb(Oze,'FGraph',235);feb(454,309,{3:1,454:1,309:1,96:1,137:1},iUb);_.Ib=function jUb(){return this.b==null||this.b.length==0?'l['+bUb(this.a)+']':'l_'+this.b};sfb(Oze,'FLabel',454);feb(153,309,{3:1,153:1,309:1,96:1,137:1},lUb);_.Ib=function mUb(){return kUb(this)};_.a=0;sfb(Oze,'FNode',153);feb(2100,1,{});_.vf=function rUb(a){nUb(this,a);};_.wf=function sUb(){oUb(this);};_.d=0;sfb(Qze,'AbstractForceModel',2100);feb(641,2100,{641:1},tUb);_.uf=function vUb(a,b){var c,d,e,f,g;qUb(this.f,a,b);e=ojd(ajd(b.d),a.d);g=$wnd.Math.sqrt(e.a*e.a+e.b*e.b);d=$wnd.Math.max(0,g-ejd(a.e)/2-ejd(b.e)/2);c=fUb(this.e,a,b);c>0?(f=-uUb(d,this.c)*c):(f=yUb(d,this.b)*RD(mQb(a,(yVb(),lVb)),17).a);ijd(e,f/g);return e};_.vf=function wUb(a){nUb(this,a);this.a=RD(mQb(a,(yVb(),aVb)),17).a;this.c=Kfb(UD(mQb(a,rVb)));this.b=Kfb(UD(mQb(a,nVb)));};_.xf=function xUb(a){return a0&&(f-=AUb(d,this.a)*c);ijd(e,f*this.b/g);return e};_.vf=function CUb(a){var b,c,d,e,f,g,h;nUb(this,a);this.b=Kfb(UD(mQb(a,(yVb(),sVb))));this.c=this.b/RD(mQb(a,aVb),17).a;d=a.e.c.length;f=0;e=0;for(h=new Anb(a.e);h.a0};_.a=0;_.b=0;_.c=0;sfb(Qze,'FruchtermanReingoldModel',642);feb(860,1,Eye,PUb);_.hf=function QUb(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Rze),''),'Force Model'),'Determines the model for force calculation.'),IUb),(kid(),eid)),BP),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Sze),''),'Iterations'),'The number of iterations on the force model.'),sgb(300)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Tze),''),'Repulsive Power'),'Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Uze),''),'FR Temperature'),'The temperature is used as a scaling factor for particle displacements.'),Vze),did),VI),xsb(Whd))));zgd(a,Uze,Rze,NUb);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Wze),''),'Eades Repulsion'),"Factor for repulsive forces in Eades' model."),5),did),VI),xsb(Whd))));zgd(a,Wze,Rze,KUb);zVb((new AVb,a));};var GUb,HUb,IUb,JUb,KUb,LUb,MUb,NUb;sfb(Xze,'ForceMetaDataProvider',860);feb(432,22,{3:1,34:1,22:1,432:1},UUb);var RUb,SUb;var BP=tfb(Xze,'ForceModelStrategy',432,WI,WUb,VUb);var XUb;feb(Awe,1,Eye,AVb);_.hf=function BVb(a){zVb(a);};var ZUb,$Ub,_Ub,aVb,bVb,cVb,dVb,eVb,fVb,gVb,hVb,iVb,jVb,kVb,lVb,mVb,nVb,oVb,pVb,qVb,rVb,sVb,tVb,uVb,vVb,wVb,xVb;sfb(Xze,'ForceOptions',Awe);feb(1001,1,{},CVb);_.sf=function DVb(){var a;return a=new TTb,a};_.tf=function EVb(a){};sfb(Xze,'ForceOptions/ForceFactory',1001);var FVb,GVb,HVb,IVb;feb(861,1,Eye,RVb);_.hf=function SVb(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,vAe),''),'Fixed Position'),'Prevent that the node is moved by the layout algorithm.'),(Geb(),false)),(kid(),cid)),QI),xsb((Yhd(),Vhd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,wAe),''),'Desired Edge Length'),'Either specified for parent nodes or for individual edges, where the latter takes higher precedence.'),100),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Thd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xAe),''),'Layout Dimension'),'Dimensions that are permitted to be altered during layout.'),MVb),eid),JP),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yAe),''),'Stress Epsilon'),'Termination criterion for the iterative process.'),Vze),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zAe),''),'Iteration Limit'),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),sgb(lve)),gid),bJ),xsb(Whd))));eWb((new fWb,a));};var KVb,LVb,MVb,NVb,OVb,PVb;sfb(Xze,'StressMetaDataProvider',861);feb(1004,1,Eye,fWb);_.hf=function gWb(a){eWb(a);};var TVb,UVb,VVb,WVb,XVb,YVb,ZVb,$Vb,_Vb,aWb,bWb,cWb;sfb(Xze,'StressOptions',1004);feb(1005,1,{},hWb);_.sf=function iWb(){var a;return a=new kWb,a};_.tf=function jWb(a){};sfb(Xze,'StressOptions/StressFactory',1005);feb(1110,205,oze,kWb);_.rf=function lWb(a,b){var c,d,e,f,g;b.Ug(BAe,1);Heb(TD(Gxd(a,(dWb(),XVb))))?Heb(TD(Gxd(a,bWb)))||RFb((c=new SFb((lud(),new zud(a))),c)):QTb(new TTb,a,b.eh(1));e=KTb(a);d=CTb(this.a,e);for(g=d.Kc();g.Ob();){f=RD(g.Pb(),235);if(f.e.c.length<=1){continue}uWb(this.b,f);sWb(this.b);Umb(f.d,new mWb);}e=BTb(d);JTb(e);b.Vg();};sfb(DAe,'StressLayoutProvider',1110);feb(1111,1,Qve,mWb);_.Cd=function nWb(a){hUb(RD(a,454));};sfb(DAe,'StressLayoutProvider/lambda$0$Type',1111);feb(1002,1,{},vWb);_.c=0;_.e=0;_.g=0;sfb(DAe,'StressMajorization',1002);feb(391,22,{3:1,34:1,22:1,391:1},BWb);var xWb,yWb,zWb;var JP=tfb(DAe,'StressMajorization/Dimension',391,WI,DWb,CWb);var EWb;feb(1003,1,fye,GWb);_.Ne=function HWb(a,b){return wWb(this.a,RD(a,153),RD(b,153))};_.Fb=function IWb(a){return this===a};_.Oe=function JWb(){return new Frb(this)};sfb(DAe,'StressMajorization/lambda$0$Type',1003);feb(1192,1,{},RWb);sfb(FAe,'ElkLayered',1192);feb(1193,1,Qve,UWb);_.Cd=function VWb(a){SWb(this.a,RD(a,36));};sfb(FAe,'ElkLayered/lambda$0$Type',1193);feb(1194,1,Qve,WWb);_.Cd=function XWb(a){TWb(this.a,RD(a,36));};sfb(FAe,'ElkLayered/lambda$1$Type',1194);feb(1281,1,{},dXb);var YWb,ZWb,$Wb;sfb(FAe,'GraphConfigurator',1281);feb(770,1,Qve,fXb);_.Cd=function gXb(a){aXb(this.a,RD(a,10));};sfb(FAe,'GraphConfigurator/lambda$0$Type',770);feb(771,1,{},hXb);_.Kb=function iXb(a){return _Wb(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(FAe,'GraphConfigurator/lambda$1$Type',771);feb(772,1,Qve,jXb);_.Cd=function kXb(a){aXb(this.a,RD(a,10));};sfb(FAe,'GraphConfigurator/lambda$2$Type',772);feb(1109,205,oze,lXb);_.rf=function mXb(a,b){var c;c=c5b(new k5b,a);dE(Gxd(a,(yCc(),IAc)))===dE((Fnd(),Cnd))?LWb(this.a,c,b):MWb(this.a,c,b);b.$g()||J5b(new N5b,c);};sfb(FAe,'LayeredLayoutProvider',1109);feb(367,22,{3:1,34:1,22:1,367:1},tXb);var nXb,oXb,pXb,qXb,rXb;var UP=tfb(FAe,'LayeredPhases',367,WI,vXb,uXb);var wXb;feb(1717,1,{},EXb);_.i=0;var yXb;sfb(GAe,'ComponentsToCGraphTransformer',1717);var jYb;feb(1718,1,{},FXb);_.yf=function GXb(a,b){return $wnd.Math.min(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};_.zf=function HXb(a,b){return $wnd.Math.min(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};sfb(GAe,'ComponentsToCGraphTransformer/1',1718);feb(86,1,{86:1});_.i=0;_.k=true;_.o=pxe;var bQ=sfb(HAe,'CNode',86);feb(470,86,{470:1,86:1},IXb,JXb);_.Ib=function KXb(){return ''};sfb(GAe,'ComponentsToCGraphTransformer/CRectNode',470);feb(1688,1,{},XXb);var LXb,MXb;sfb(GAe,'OneDimensionalComponentsCompaction',1688);feb(1689,1,{},$Xb);_.Kb=function _Xb(a){return YXb(RD(a,42))};_.Fb=function aYb(a){return this===a};sfb(GAe,'OneDimensionalComponentsCompaction/lambda$0$Type',1689);feb(1690,1,{},bYb);_.Kb=function cYb(a){return ZXb(RD(a,42))};_.Fb=function dYb(a){return this===a};sfb(GAe,'OneDimensionalComponentsCompaction/lambda$1$Type',1690);feb(1720,1,{},fYb);sfb(HAe,'CGraph',1720);feb(194,1,{194:1},iYb);_.b=0;_.c=0;_.e=0;_.g=true;_.i=pxe;sfb(HAe,'CGroup',194);feb(1719,1,{},lYb);_.yf=function mYb(a,b){return $wnd.Math.max(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};_.zf=function nYb(a,b){return $wnd.Math.max(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};sfb(HAe,kye,1719);feb(1721,1,{},EYb);_.d=false;var oYb;var eQ=sfb(HAe,pye,1721);feb(1722,1,{},FYb);_.Kb=function GYb(a){return pYb(),Geb(),RD(RD(a,42).a,86).d.e!=0?true:false};_.Fb=function HYb(a){return this===a};sfb(HAe,qye,1722);feb(833,1,{},KYb);_.a=false;_.b=false;_.c=false;_.d=false;sfb(HAe,rye,833);feb(1898,1,{},QYb);sfb(IAe,sye,1898);var wQ=ufb(JAe,hye);feb(1899,1,{382:1},UYb);_.bf=function VYb(a){SYb(this,RD(a,476));};sfb(IAe,tye,1899);feb(Owe,1,fye,XYb);_.Ne=function YYb(a,b){return WYb(RD(a,86),RD(b,86))};_.Fb=function ZYb(a){return this===a};_.Oe=function $Yb(){return new Frb(this)};sfb(IAe,uye,Owe);feb(476,1,{476:1},_Yb);_.a=false;sfb(IAe,vye,476);feb(1901,1,fye,aZb);_.Ne=function bZb(a,b){return RYb(RD(a,476),RD(b,476))};_.Fb=function cZb(a){return this===a};_.Oe=function dZb(){return new Frb(this)};sfb(IAe,wye,1901);feb(148,1,{148:1},eZb,fZb);_.Fb=function gZb(a){var b;if(a==null){return false}if(mQ!=rb(a)){return false}b=RD(a,148);return Fvb(this.c,b.c)&&Fvb(this.d,b.d)};_.Hb=function hZb(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.c,this.d]))};_.Ib=function iZb(){return '('+this.c+pve+this.d+(this.a?'cx':'')+this.b+')'};_.a=true;_.c=0;_.d=0;var mQ=sfb(JAe,'Point',148);feb(416,22,{3:1,34:1,22:1,416:1},qZb);var jZb,kZb,lZb,mZb;var lQ=tfb(JAe,'Point/Quadrant',416,WI,uZb,tZb);var vZb;feb(1708,1,{},EZb);_.b=null;_.c=null;_.d=null;_.e=null;_.f=null;var xZb,yZb,zZb,AZb,BZb;sfb(JAe,'RectilinearConvexHull',1708);feb(583,1,{382:1},PZb);_.bf=function QZb(a){OZb(this,RD(a,148));};_.b=0;var MZb;sfb(JAe,'RectilinearConvexHull/MaximalElementsEventHandler',583);feb(1710,1,fye,SZb);_.Ne=function TZb(a,b){return RZb(UD(a),UD(b))};_.Fb=function UZb(a){return this===a};_.Oe=function VZb(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type',1710);feb(1709,1,{382:1},XZb);_.bf=function YZb(a){WZb(this,RD(a,148));};_.a=0;_.b=null;_.c=null;_.d=null;_.e=null;sfb(JAe,'RectilinearConvexHull/RectangleEventHandler',1709);feb(1711,1,fye,ZZb);_.Ne=function $Zb(a,b){return GZb(RD(a,148),RD(b,148))};_.Fb=function _Zb(a){return this===a};_.Oe=function a$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$0$Type',1711);feb(1712,1,fye,b$b);_.Ne=function c$b(a,b){return HZb(RD(a,148),RD(b,148))};_.Fb=function d$b(a){return this===a};_.Oe=function e$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$1$Type',1712);feb(1713,1,fye,f$b);_.Ne=function g$b(a,b){return IZb(RD(a,148),RD(b,148))};_.Fb=function h$b(a){return this===a};_.Oe=function i$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$2$Type',1713);feb(1714,1,fye,j$b);_.Ne=function k$b(a,b){return JZb(RD(a,148),RD(b,148))};_.Fb=function l$b(a){return this===a};_.Oe=function m$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$3$Type',1714);feb(1715,1,fye,n$b);_.Ne=function o$b(a,b){return KZb(RD(a,148),RD(b,148))};_.Fb=function p$b(a){return this===a};_.Oe=function q$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$4$Type',1715);feb(1716,1,{},s$b);sfb(JAe,'Scanline',1716);feb(2104,1,{});sfb(KAe,'AbstractGraphPlacer',2104);feb(335,1,{335:1},C$b);_.Ff=function D$b(a){if(this.Gf(a)){Rc(this.b,RD(mQb(a,(Ywc(),ewc)),21),a);return true}else {return false}};_.Gf=function E$b(a){var b,c,d,e;b=RD(mQb(a,(Ywc(),ewc)),21);e=RD(Qc(y$b,b),21);for(d=e.Kc();d.Ob();){c=RD(d.Pb(),21);if(!RD(Qc(this.b,c),15).dc()){return false}}return true};var y$b;sfb(KAe,'ComponentGroup',335);feb(779,2104,{},J$b);_.Hf=function K$b(a){var b,c;for(c=new Anb(this.a);c.ac){k=0;l+=h+d;h=0;}i=f.c;w$b(f,k+i.a,l+i.b);hjd(i);e=$wnd.Math.max(e,k+j.a);h=$wnd.Math.max(h,j.b);k+=j.a+d;}b.f.a=e;b.f.b=l+h;};_.Jf=function Y_b(a,b){var c,d,e,f,g;if(dE(mQb(b,(yCc(),Yzc)))===dE((U$b(),T$b))){for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);g=0;for(f=new Anb(c.a);f.ac&&!RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),Yod))||!!i&&RD(mQb(i,(Ywc(),ewc)),21).Hc((qpd(),Xod))||RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),ppd))){m=l;n+=h+d;h=0;}j=f.c;RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),Yod))&&(m=e+d);w$b(f,m+j.a,n+j.b);e=$wnd.Math.max(e,m+k.a);RD(mQb(f,ewc),21).Hc(npd)&&(l=$wnd.Math.max(l,m+k.a+d));hjd(j);h=$wnd.Math.max(h,k.b);m+=k.a+d;i=f;}b.f.a=e;b.f.b=n+h;};_.Jf=function __b(a,b){};sfb(KAe,'ModelOrderRowGraphPlacer',1313);feb(1311,1,fye,b0b);_.Ne=function c0b(a,b){return a0b(RD(a,36),RD(b,36))};_.Fb=function d0b(a){return this===a};_.Oe=function e0b(){return new Frb(this)};sfb(KAe,'SimpleRowGraphPlacer/1',1311);var f0b;feb(1280,1,xye,l0b);_.Lb=function m0b(a){var b;return b=RD(mQb(RD(a,249).b,(yCc(),RAc)),75),!!b&&b.b!=0};_.Fb=function n0b(a){return this===a};_.Mb=function o0b(a){var b;return b=RD(mQb(RD(a,249).b,(yCc(),RAc)),75),!!b&&b.b!=0};sfb(PAe,'CompoundGraphPostprocessor/1',1280);feb(1279,1,QAe,E0b);_.Kf=function F0b(a,b){y0b(this,RD(a,36),b);};sfb(PAe,'CompoundGraphPreprocessor',1279);feb(453,1,{453:1},G0b);_.c=false;sfb(PAe,'CompoundGraphPreprocessor/ExternalPort',453);feb(249,1,{249:1},J0b);_.Ib=function K0b(){return ps(this.c)+':'+_0b(this.b)};sfb(PAe,'CrossHierarchyEdge',249);feb(777,1,fye,M0b);_.Ne=function N0b(a,b){return L0b(this,RD(a,249),RD(b,249))};_.Fb=function O0b(a){return this===a};_.Oe=function Q0b(){return new Frb(this)};sfb(PAe,'CrossHierarchyEdgeComparator',777);feb(305,137,{3:1,305:1,96:1,137:1});_.p=0;sfb(RAe,'LGraphElement',305);feb(18,305,{3:1,18:1,305:1,96:1,137:1},a1b);_.Ib=function b1b(){return _0b(this)};var WQ=sfb(RAe,'LEdge',18);feb(36,305,{3:1,20:1,36:1,305:1,96:1,137:1},d1b);_.Jc=function e1b(a){xgb(this,a);};_.Kc=function f1b(){return new Anb(this.b)};_.Ib=function g1b(){if(this.b.c.length==0){return 'G-unlayered'+Fe(this.a)}else if(this.a.c.length==0){return 'G-layered'+Fe(this.b)}return 'G[layerless'+Fe(this.a)+', layers'+Fe(this.b)+']'};var eR=sfb(RAe,'LGraph',36);var h1b;feb(666,1,{});_.Lf=function j1b(){return this.e.n};_.of=function k1b(a){return mQb(this.e,a)};_.Mf=function l1b(){return this.e.o};_.Nf=function m1b(){return this.e.p};_.pf=function n1b(a){return nQb(this.e,a)};_.Of=function o1b(a){this.e.n.a=a.a;this.e.n.b=a.b;};_.Pf=function p1b(a){this.e.o.a=a.a;this.e.o.b=a.b;};_.Qf=function q1b(a){this.e.p=a;};sfb(RAe,'LGraphAdapters/AbstractLShapeAdapter',666);feb(474,1,{853:1},r1b);_.Rf=function s1b(){var a,b;if(!this.b){this.b=ev(this.a.b.c.length);for(b=new Anb(this.a.b);b.a0&&M2b((BFb(c-1,b.length),b.charCodeAt(c-1)),ZAe)){--c;}if(g> ',a),M3b(c));Zhb(Yhb((a.a+='[',a),c.i),']');}return a.a};_.c=true;_.d=false;var D3b,E3b,F3b,G3b,H3b,I3b;var xR=sfb(RAe,'LPort',12);feb(408,1,Vve,T3b);_.Jc=function U3b(a){xgb(this,a);};_.Kc=function V3b(){var a;a=new Anb(this.a.e);return new W3b(a)};sfb(RAe,'LPort/1',408);feb(1309,1,Ave,W3b);_.Nb=function X3b(a){Ztb(this,a);};_.Pb=function Z3b(){return RD(ynb(this.a),18).c};_.Ob=function Y3b(){return xnb(this.a)};_.Qb=function $3b(){znb(this.a);};sfb(RAe,'LPort/1/1',1309);feb(369,1,Vve,_3b);_.Jc=function a4b(a){xgb(this,a);};_.Kc=function b4b(){var a;return a=new Anb(this.a.g),new c4b(a)};sfb(RAe,'LPort/2',369);feb(776,1,Ave,c4b);_.Nb=function d4b(a){Ztb(this,a);};_.Pb=function f4b(){return RD(ynb(this.a),18).d};_.Ob=function e4b(){return xnb(this.a)};_.Qb=function g4b(){znb(this.a);};sfb(RAe,'LPort/2/1',776);feb(1302,1,Vve,h4b);_.Jc=function i4b(a){xgb(this,a);};_.Kc=function j4b(){return new l4b(this)};sfb(RAe,'LPort/CombineIter',1302);feb(208,1,Ave,l4b);_.Nb=function m4b(a){Ztb(this,a);};_.Qb=function p4b(){$tb();};_.Ob=function n4b(){return k4b(this)};_.Pb=function o4b(){return xnb(this.a)?ynb(this.a):ynb(this.b)};sfb(RAe,'LPort/CombineIter/1',208);feb(1303,1,xye,r4b);_.Lb=function s4b(a){return q4b(a)};_.Fb=function t4b(a){return this===a};_.Mb=function u4b(a){return J3b(),RD(a,12).g.c.length!=0};sfb(RAe,'LPort/lambda$0$Type',1303);feb(1304,1,xye,w4b);_.Lb=function x4b(a){return v4b(a)};_.Fb=function y4b(a){return this===a};_.Mb=function z4b(a){return J3b(),RD(a,12).e.c.length!=0};sfb(RAe,'LPort/lambda$1$Type',1304);feb(1305,1,xye,A4b);_.Lb=function B4b(a){return J3b(),RD(a,12).j==(qpd(),Yod)};_.Fb=function C4b(a){return this===a};_.Mb=function D4b(a){return J3b(),RD(a,12).j==(qpd(),Yod)};sfb(RAe,'LPort/lambda$2$Type',1305);feb(1306,1,xye,E4b);_.Lb=function F4b(a){return J3b(),RD(a,12).j==(qpd(),Xod)};_.Fb=function G4b(a){return this===a};_.Mb=function H4b(a){return J3b(),RD(a,12).j==(qpd(),Xod)};sfb(RAe,'LPort/lambda$3$Type',1306);feb(1307,1,xye,I4b);_.Lb=function J4b(a){return J3b(),RD(a,12).j==(qpd(),npd)};_.Fb=function K4b(a){return this===a};_.Mb=function L4b(a){return J3b(),RD(a,12).j==(qpd(),npd)};sfb(RAe,'LPort/lambda$4$Type',1307);feb(1308,1,xye,M4b);_.Lb=function N4b(a){return J3b(),RD(a,12).j==(qpd(),ppd)};_.Fb=function O4b(a){return this===a};_.Mb=function P4b(a){return J3b(),RD(a,12).j==(qpd(),ppd)};sfb(RAe,'LPort/lambda$5$Type',1308);feb(30,305,{3:1,20:1,305:1,30:1,96:1,137:1},R4b);_.Jc=function S4b(a){xgb(this,a);};_.Kc=function T4b(){return new Anb(this.a)};_.Ib=function U4b(){return 'L_'+Wmb(this.b.b,this,0)+Fe(this.a)};sfb(RAe,'Layer',30);feb(1330,1,{},k5b);sfb(cBe,dBe,1330);feb(1334,1,{},o5b);_.Kb=function p5b(a){return AGd(RD(a,84))};sfb(cBe,'ElkGraphImporter/0methodref$connectableShapeToNode$Type',1334);feb(1337,1,{},q5b);_.Kb=function r5b(a){return AGd(RD(a,84))};sfb(cBe,'ElkGraphImporter/1methodref$connectableShapeToNode$Type',1337);feb(1331,1,Qve,s5b);_.Cd=function t5b(a){$4b(this.a,RD(a,123));};sfb(cBe,Nze,1331);feb(1332,1,Qve,u5b);_.Cd=function v5b(a){$4b(this.a,RD(a,123));};sfb(cBe,eBe,1332);feb(1333,1,{},w5b);_.Kb=function x5b(a){return new SDb(null,new Swb(mzd(RD(a,74)),16))};sfb(cBe,fBe,1333);feb(1335,1,nwe,y5b);_.Mb=function z5b(a){return l5b(this.a,RD(a,27))};sfb(cBe,gBe,1335);feb(1336,1,{},A5b);_.Kb=function B5b(a){return new SDb(null,new Swb(lzd(RD(a,74)),16))};sfb(cBe,'ElkGraphImporter/lambda$5$Type',1336);feb(1338,1,nwe,C5b);_.Mb=function D5b(a){return m5b(this.a,RD(a,27))};sfb(cBe,'ElkGraphImporter/lambda$7$Type',1338);feb(1339,1,nwe,E5b);_.Mb=function F5b(a){return n5b(RD(a,74))};sfb(cBe,'ElkGraphImporter/lambda$8$Type',1339);feb(1297,1,{},N5b);var G5b;sfb(cBe,'ElkGraphLayoutTransferrer',1297);feb(1298,1,nwe,Q5b);_.Mb=function R5b(a){return O5b(this.a,RD(a,18))};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$0$Type',1298);feb(1299,1,Qve,S5b);_.Cd=function T5b(a){H5b();Rmb(this.a,RD(a,18));};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$1$Type',1299);feb(1300,1,nwe,U5b);_.Mb=function V5b(a){return P5b(this.a,RD(a,18))};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$2$Type',1300);feb(1301,1,Qve,W5b);_.Cd=function X5b(a){H5b();Rmb(this.a,RD(a,18));};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$3$Type',1301);feb(819,1,{},e6b);sfb(hBe,'BiLinkedHashMultiMap',819);feb(1550,1,QAe,h6b);_.Kf=function i6b(a,b){f6b(RD(a,36),b);};sfb(hBe,'CommentNodeMarginCalculator',1550);feb(1551,1,{},j6b);_.Kb=function k6b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'CommentNodeMarginCalculator/lambda$0$Type',1551);feb(1552,1,Qve,l6b);_.Cd=function m6b(a){g6b(RD(a,10));};sfb(hBe,'CommentNodeMarginCalculator/lambda$1$Type',1552);feb(1553,1,QAe,q6b);_.Kf=function r6b(a,b){o6b(RD(a,36),b);};sfb(hBe,'CommentPostprocessor',1553);feb(1554,1,QAe,v6b);_.Kf=function w6b(a,b){s6b(RD(a,36),b);};sfb(hBe,'CommentPreprocessor',1554);feb(1555,1,QAe,y6b);_.Kf=function z6b(a,b){x6b(RD(a,36),b);};sfb(hBe,'ConstraintsPostprocessor',1555);feb(1556,1,QAe,G6b);_.Kf=function H6b(a,b){E6b(RD(a,36),b);};sfb(hBe,'EdgeAndLayerConstraintEdgeReverser',1556);feb(1557,1,QAe,K6b);_.Kf=function M6b(a,b){I6b(RD(a,36),b);};sfb(hBe,'EndLabelPostprocessor',1557);feb(1558,1,{},N6b);_.Kb=function O6b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelPostprocessor/lambda$0$Type',1558);feb(1559,1,nwe,P6b);_.Mb=function Q6b(a){return L6b(RD(a,10))};sfb(hBe,'EndLabelPostprocessor/lambda$1$Type',1559);feb(1560,1,Qve,R6b);_.Cd=function S6b(a){J6b(RD(a,10));};sfb(hBe,'EndLabelPostprocessor/lambda$2$Type',1560);feb(1561,1,QAe,b7b);_.Kf=function e7b(a,b){Z6b(RD(a,36),b);};sfb(hBe,'EndLabelPreprocessor',1561);feb(1562,1,{},f7b);_.Kb=function g7b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelPreprocessor/lambda$0$Type',1562);feb(1563,1,Qve,h7b);_.Cd=function i7b(a){V6b(this.a,this.b,this.c,RD(a,10));};_.a=0;_.b=0;_.c=false;sfb(hBe,'EndLabelPreprocessor/lambda$1$Type',1563);feb(1564,1,nwe,j7b);_.Mb=function k7b(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Nmd))};sfb(hBe,'EndLabelPreprocessor/lambda$2$Type',1564);feb(1565,1,Qve,l7b);_.Cd=function m7b(a){Mub(this.a,RD(a,72));};sfb(hBe,'EndLabelPreprocessor/lambda$3$Type',1565);feb(1566,1,nwe,n7b);_.Mb=function o7b(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Mmd))};sfb(hBe,'EndLabelPreprocessor/lambda$4$Type',1566);feb(1567,1,Qve,p7b);_.Cd=function q7b(a){Mub(this.a,RD(a,72));};sfb(hBe,'EndLabelPreprocessor/lambda$5$Type',1567);feb(1615,1,QAe,z7b);_.Kf=function A7b(a,b){w7b(RD(a,36),b);};var r7b;sfb(hBe,'EndLabelSorter',1615);feb(1616,1,fye,C7b);_.Ne=function D7b(a,b){return B7b(RD(a,466),RD(b,466))};_.Fb=function E7b(a){return this===a};_.Oe=function F7b(){return new Frb(this)};sfb(hBe,'EndLabelSorter/1',1616);feb(466,1,{466:1},G7b);sfb(hBe,'EndLabelSorter/LabelGroup',466);feb(1617,1,{},H7b);_.Kb=function I7b(a){return s7b(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelSorter/lambda$0$Type',1617);feb(1618,1,nwe,J7b);_.Mb=function K7b(a){return s7b(),RD(a,10).k==(r3b(),p3b)};sfb(hBe,'EndLabelSorter/lambda$1$Type',1618);feb(1619,1,Qve,L7b);_.Cd=function M7b(a){x7b(RD(a,10));};sfb(hBe,'EndLabelSorter/lambda$2$Type',1619);feb(1620,1,nwe,N7b);_.Mb=function O7b(a){return s7b(),dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Mmd))};sfb(hBe,'EndLabelSorter/lambda$3$Type',1620);feb(1621,1,nwe,P7b);_.Mb=function Q7b(a){return s7b(),dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Nmd))};sfb(hBe,'EndLabelSorter/lambda$4$Type',1621);feb(1568,1,QAe,a8b);_.Kf=function b8b(a,b){$7b(this,RD(a,36));};_.b=0;_.c=0;sfb(hBe,'FinalSplineBendpointsCalculator',1568);feb(1569,1,{},c8b);_.Kb=function d8b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$0$Type',1569);feb(1570,1,{},e8b);_.Kb=function f8b(a){return new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$1$Type',1570);feb(1571,1,nwe,g8b);_.Mb=function h8b(a){return !W0b(RD(a,18))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$2$Type',1571);feb(1572,1,nwe,i8b);_.Mb=function j8b(a){return nQb(RD(a,18),(Ywc(),Twc))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$3$Type',1572);feb(1573,1,Qve,k8b);_.Cd=function l8b(a){T7b(this.a,RD(a,131));};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$4$Type',1573);feb(1574,1,Qve,m8b);_.Cd=function n8b(a){Eob(RD(a,18).a);};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$5$Type',1574);feb(803,1,QAe,L8b);_.Kf=function M8b(a,b){C8b(this,RD(a,36),b);};sfb(hBe,'GraphTransformer',803);feb(517,22,{3:1,34:1,22:1,517:1},Q8b);var N8b,O8b;var vS=tfb(hBe,'GraphTransformer/Mode',517,WI,S8b,R8b);var T8b;feb(1575,1,QAe,Z8b);_.Kf=function $8b(a,b){W8b(RD(a,36),b);};sfb(hBe,'HierarchicalNodeResizingProcessor',1575);feb(1576,1,QAe,f9b);_.Kf=function g9b(a,b){b9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortConstraintProcessor',1576);feb(1577,1,fye,i9b);_.Ne=function j9b(a,b){return h9b(RD(a,10),RD(b,10))};_.Fb=function k9b(a){return this===a};_.Oe=function l9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortConstraintProcessor/NodeComparator',1577);feb(1578,1,QAe,o9b);_.Kf=function p9b(a,b){m9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortDummySizeProcessor',1578);feb(1579,1,QAe,C9b);_.Kf=function D9b(a,b){v9b(this,RD(a,36),b);};_.a=0;sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter',1579);feb(1580,1,fye,F9b);_.Ne=function G9b(a,b){return E9b(RD(a,10),RD(b,10))};_.Fb=function H9b(a){return this===a};_.Oe=function I9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter/1',1580);feb(1581,1,fye,K9b);_.Ne=function L9b(a,b){return J9b(RD(a,10),RD(b,10))};_.Fb=function M9b(a){return this===a};_.Oe=function N9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter/2',1581);feb(1582,1,QAe,Q9b);_.Kf=function R9b(a,b){P9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortPositionProcessor',1582);feb(1583,1,QAe,$9b);_.Kf=function _9b(a,b){Z9b(this,RD(a,36));};_.a=0;_.c=0;var S9b,T9b;sfb(hBe,'HighDegreeNodeLayeringProcessor',1583);feb(580,1,{580:1},aac);_.b=-1;_.d=-1;sfb(hBe,'HighDegreeNodeLayeringProcessor/HighDegreeNodeInformation',580);feb(1584,1,{},bac);_.Kb=function cac(a){return U9b(),Z2b(RD(a,10))};_.Fb=function dac(a){return this===a};sfb(hBe,'HighDegreeNodeLayeringProcessor/lambda$0$Type',1584);feb(1585,1,{},eac);_.Kb=function fac(a){return U9b(),a3b(RD(a,10))};_.Fb=function gac(a){return this===a};sfb(hBe,'HighDegreeNodeLayeringProcessor/lambda$1$Type',1585);feb(1591,1,QAe,mac);_.Kf=function nac(a,b){lac(this,RD(a,36),b);};sfb(hBe,'HyperedgeDummyMerger',1591);feb(804,1,{},oac);_.a=false;_.b=false;_.c=false;sfb(hBe,'HyperedgeDummyMerger/MergeState',804);feb(1592,1,{},pac);_.Kb=function qac(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'HyperedgeDummyMerger/lambda$0$Type',1592);feb(1593,1,{},rac);_.Kb=function sac(a){return new SDb(null,new Swb(RD(a,10).j,16))};sfb(hBe,'HyperedgeDummyMerger/lambda$1$Type',1593);feb(1594,1,Qve,tac);_.Cd=function uac(a){RD(a,12).p=-1;};sfb(hBe,'HyperedgeDummyMerger/lambda$2$Type',1594);feb(1595,1,QAe,xac);_.Kf=function yac(a,b){wac(RD(a,36),b);};sfb(hBe,'HypernodesProcessor',1595);feb(1596,1,QAe,Aac);_.Kf=function Bac(a,b){zac(RD(a,36),b);};sfb(hBe,'InLayerConstraintProcessor',1596);feb(1597,1,QAe,Dac);_.Kf=function Eac(a,b){Cac(RD(a,36),b);};sfb(hBe,'InnermostNodeMarginCalculator',1597);feb(1598,1,QAe,Iac);_.Kf=function Nac(a,b){Hac(this,RD(a,36));};_.a=pxe;_.b=pxe;_.c=oxe;_.d=oxe;var XS=sfb(hBe,'InteractiveExternalPortPositioner',1598);feb(1599,1,{},Oac);_.Kb=function Pac(a){return RD(a,18).d.i};_.Fb=function Qac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$0$Type',1599);feb(1600,1,{},Rac);_.Kb=function Sac(a){return Jac(this.a,UD(a))};_.Fb=function Tac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$1$Type',1600);feb(1601,1,{},Uac);_.Kb=function Vac(a){return RD(a,18).c.i};_.Fb=function Wac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$2$Type',1601);feb(1602,1,{},Xac);_.Kb=function Yac(a){return Kac(this.a,UD(a))};_.Fb=function Zac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$3$Type',1602);feb(1603,1,{},$ac);_.Kb=function _ac(a){return Lac(this.a,UD(a))};_.Fb=function abc(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$4$Type',1603);feb(1604,1,{},bbc);_.Kb=function cbc(a){return Mac(this.a,UD(a))};_.Fb=function dbc(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$5$Type',1604);feb(81,22,{3:1,34:1,22:1,81:1,196:1},icc);_.dg=function jcc(){switch(this.g){case 15:return new Hrc;case 22:return new bsc;case 47:return new ksc;case 28:case 35:return new Ldc;case 32:return new h6b;case 42:return new q6b;case 1:return new v6b;case 41:return new y6b;case 56:return new L8b((P8b(),O8b));case 0:return new L8b((P8b(),N8b));case 2:return new G6b;case 54:return new K6b;case 33:return new b7b;case 51:return new a8b;case 55:return new Z8b;case 13:return new f9b;case 38:return new o9b;case 44:return new C9b;case 40:return new Q9b;case 9:return new $9b;case 49:return new Yjc;case 37:return new mac;case 43:return new xac;case 27:return new Aac;case 30:return new Dac;case 3:return new Iac;case 18:return new scc;case 29:return new ycc;case 5:return new Lcc;case 50:return new Ucc;case 34:return new pdc;case 36:return new Zdc;case 52:return new z7b;case 11:return new fec;case 7:return new pec;case 39:return new Dec;case 45:return new Gec;case 16:return new Kec;case 10:return new _ec;case 48:return new Bfc;case 21:return new Ifc;case 23:return new FKc((RKc(),PKc));case 8:return new Rfc;case 12:return new Zfc;case 4:return new cgc;case 19:return new xgc;case 17:return new Vgc;case 53:return new Ygc;case 6:return new Nhc;case 25:return new ahc;case 46:return new rhc;case 31:return new Yhc;case 14:return new jic;case 26:return new Ssc;case 20:return new yic;case 24:return new FKc((RKc(),QKc));default:throw Adb(new agb(lBe+(this.f!=null?this.f:''+this.g)));}};var ebc,fbc,gbc,hbc,ibc,jbc,kbc,lbc,mbc,nbc,obc,pbc,qbc,rbc,sbc,tbc,ubc,vbc,wbc,xbc,ybc,zbc,Abc,Bbc,Cbc,Dbc,Ebc,Fbc,Gbc,Hbc,Ibc,Jbc,Kbc,Lbc,Mbc,Nbc,Obc,Pbc,Qbc,Rbc,Sbc,Tbc,Ubc,Vbc,Wbc,Xbc,Ybc,Zbc,$bc,_bc,acc,bcc,ccc,dcc,ecc,fcc,gcc;var YS=tfb(hBe,mBe,81,WI,lcc,kcc);var mcc;feb(1605,1,QAe,scc);_.Kf=function tcc(a,b){qcc(RD(a,36),b);};sfb(hBe,'InvertedPortProcessor',1605);feb(1606,1,QAe,ycc);_.Kf=function zcc(a,b){xcc(RD(a,36),b);};sfb(hBe,'LabelAndNodeSizeProcessor',1606);feb(1607,1,nwe,Acc);_.Mb=function Bcc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'LabelAndNodeSizeProcessor/lambda$0$Type',1607);feb(1608,1,nwe,Ccc);_.Mb=function Dcc(a){return RD(a,10).k==(r3b(),m3b)};sfb(hBe,'LabelAndNodeSizeProcessor/lambda$1$Type',1608);feb(1609,1,Qve,Ecc);_.Cd=function Fcc(a){vcc(this.b,this.a,this.c,RD(a,10));};_.a=false;_.c=false;sfb(hBe,'LabelAndNodeSizeProcessor/lambda$2$Type',1609);feb(1610,1,QAe,Lcc);_.Kf=function Mcc(a,b){Jcc(RD(a,36),b);};var Gcc;sfb(hBe,'LabelDummyInserter',1610);feb(1611,1,xye,Ncc);_.Lb=function Occ(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Lmd))};_.Fb=function Pcc(a){return this===a};_.Mb=function Qcc(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Lmd))};sfb(hBe,'LabelDummyInserter/1',1611);feb(1612,1,QAe,Ucc);_.Kf=function Vcc(a,b){Tcc(RD(a,36),b);};sfb(hBe,'LabelDummyRemover',1612);feb(1613,1,nwe,Wcc);_.Mb=function Xcc(a){return Heb(TD(mQb(RD(a,72),(yCc(),vAc))))};sfb(hBe,'LabelDummyRemover/lambda$0$Type',1613);feb(1378,1,QAe,pdc);_.Kf=function tdc(a,b){ldc(this,RD(a,36),b);};_.a=null;var Ycc;sfb(hBe,'LabelDummySwitcher',1378);feb(293,1,{293:1},xdc);_.c=0;_.d=null;_.f=0;sfb(hBe,'LabelDummySwitcher/LabelDummyInfo',293);feb(1379,1,{},ydc);_.Kb=function zdc(a){return Zcc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'LabelDummySwitcher/lambda$0$Type',1379);feb(1380,1,nwe,Adc);_.Mb=function Bdc(a){return Zcc(),RD(a,10).k==(r3b(),n3b)};sfb(hBe,'LabelDummySwitcher/lambda$1$Type',1380);feb(1381,1,{},Cdc);_.Kb=function Ddc(a){return qdc(this.a,RD(a,10))};sfb(hBe,'LabelDummySwitcher/lambda$2$Type',1381);feb(1382,1,Qve,Edc);_.Cd=function Fdc(a){rdc(this.a,RD(a,293));};sfb(hBe,'LabelDummySwitcher/lambda$3$Type',1382);feb(1383,1,fye,Gdc);_.Ne=function Hdc(a,b){return sdc(RD(a,293),RD(b,293))};_.Fb=function Idc(a){return this===a};_.Oe=function Jdc(){return new Frb(this)};sfb(hBe,'LabelDummySwitcher/lambda$4$Type',1383);feb(802,1,QAe,Ldc);_.Kf=function Mdc(a,b){Kdc(RD(a,36),b);};sfb(hBe,'LabelManagementProcessor',802);feb(1614,1,QAe,Zdc);_.Kf=function $dc(a,b){Tdc(RD(a,36),b);};sfb(hBe,'LabelSideSelector',1614);feb(1622,1,QAe,fec);_.Kf=function gec(a,b){bec(RD(a,36),b);};sfb(hBe,'LayerConstraintPostprocessor',1622);feb(1623,1,QAe,pec);_.Kf=function qec(a,b){nec(RD(a,36),b);};var hec;sfb(hBe,'LayerConstraintPreprocessor',1623);feb(371,22,{3:1,34:1,22:1,371:1},xec);var rec,sec,tec,uec;var qT=tfb(hBe,'LayerConstraintPreprocessor/HiddenNodeConnections',371,WI,zec,yec);var Aec;feb(1624,1,QAe,Dec);_.Kf=function Eec(a,b){Cec(RD(a,36),b);};sfb(hBe,'LayerSizeAndGraphHeightCalculator',1624);feb(1625,1,QAe,Gec);_.Kf=function Iec(a,b){Fec(RD(a,36),b);};sfb(hBe,'LongEdgeJoiner',1625);feb(1626,1,QAe,Kec);_.Kf=function Mec(a,b){Jec(RD(a,36),b);};sfb(hBe,'LongEdgeSplitter',1626);feb(1627,1,QAe,_ec);_.Kf=function cfc(a,b){Vec(this,RD(a,36),b);};_.e=0;_.f=0;_.j=0;_.k=0;_.n=0;_.o=0;var Pec,Qec;sfb(hBe,'NodePromotion',1627);feb(1628,1,fye,efc);_.Ne=function ffc(a,b){return dfc(RD(a,10),RD(b,10))};_.Fb=function gfc(a){return this===a};_.Oe=function hfc(){return new Frb(this)};sfb(hBe,'NodePromotion/1',1628);feb(1629,1,fye,jfc);_.Ne=function kfc(a,b){return ifc(RD(a,10),RD(b,10))};_.Fb=function lfc(a){return this===a};_.Oe=function mfc(){return new Frb(this)};sfb(hBe,'NodePromotion/2',1629);feb(1630,1,{},nfc);_.Kb=function ofc(a){return RD(a,42),Rec(),Geb(),true};_.Fb=function pfc(a){return this===a};sfb(hBe,'NodePromotion/lambda$0$Type',1630);feb(1631,1,{},qfc);_.Kb=function rfc(a){return afc(this.a,RD(a,42))};_.Fb=function sfc(a){return this===a};_.a=0;sfb(hBe,'NodePromotion/lambda$1$Type',1631);feb(1632,1,{},tfc);_.Kb=function ufc(a){return bfc(this.a,RD(a,42))};_.Fb=function vfc(a){return this===a};_.a=0;sfb(hBe,'NodePromotion/lambda$2$Type',1632);feb(1633,1,QAe,Bfc);_.Kf=function Cfc(a,b){wfc(RD(a,36),b);};sfb(hBe,'NorthSouthPortPostprocessor',1633);feb(1634,1,QAe,Ifc);_.Kf=function Kfc(a,b){Gfc(RD(a,36),b);};sfb(hBe,'NorthSouthPortPreprocessor',1634);feb(1635,1,fye,Lfc);_.Ne=function Mfc(a,b){return Jfc(RD(a,12),RD(b,12))};_.Fb=function Nfc(a){return this===a};_.Oe=function Ofc(){return new Frb(this)};sfb(hBe,'NorthSouthPortPreprocessor/lambda$0$Type',1635);feb(1636,1,QAe,Rfc);_.Kf=function Tfc(a,b){Qfc(RD(a,36),b);};sfb(hBe,'PartitionMidprocessor',1636);feb(1637,1,nwe,Ufc);_.Mb=function Vfc(a){return nQb(RD(a,10),(yCc(),tBc))};sfb(hBe,'PartitionMidprocessor/lambda$0$Type',1637);feb(1638,1,Qve,Wfc);_.Cd=function Xfc(a){Sfc(this.a,RD(a,10));};sfb(hBe,'PartitionMidprocessor/lambda$1$Type',1638);feb(1639,1,QAe,Zfc);_.Kf=function $fc(a,b){Yfc(RD(a,36),b);};sfb(hBe,'PartitionPostprocessor',1639);feb(1640,1,QAe,cgc);_.Kf=function dgc(a,b){agc(RD(a,36),b);};sfb(hBe,'PartitionPreprocessor',1640);feb(1641,1,nwe,egc);_.Mb=function fgc(a){return nQb(RD(a,10),(yCc(),tBc))};sfb(hBe,'PartitionPreprocessor/lambda$0$Type',1641);feb(1642,1,{},ggc);_.Kb=function hgc(a){return new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(hBe,'PartitionPreprocessor/lambda$1$Type',1642);feb(1643,1,nwe,igc);_.Mb=function jgc(a){return _fc(RD(a,18))};sfb(hBe,'PartitionPreprocessor/lambda$2$Type',1643);feb(1644,1,Qve,kgc);_.Cd=function lgc(a){bgc(RD(a,18));};sfb(hBe,'PartitionPreprocessor/lambda$3$Type',1644);feb(1645,1,QAe,xgc);_.Kf=function Bgc(a,b){ugc(RD(a,36),b);};var mgc,ngc,ogc,pgc,qgc,rgc;sfb(hBe,'PortListSorter',1645);feb(1648,1,fye,Dgc);_.Ne=function Egc(a,b){return ygc(RD(a,12),RD(b,12))};_.Fb=function Fgc(a){return this===a};_.Oe=function Ggc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$0$Type',1648);feb(1650,1,fye,Hgc);_.Ne=function Igc(a,b){return zgc(RD(a,12),RD(b,12))};_.Fb=function Jgc(a){return this===a};_.Oe=function Kgc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$1$Type',1650);feb(1646,1,{},Lgc);_.Kb=function Mgc(a){return sgc(),RD(a,12).e};sfb(hBe,'PortListSorter/lambda$2$Type',1646);feb(1647,1,{},Ngc);_.Kb=function Ogc(a){return sgc(),RD(a,12).g};sfb(hBe,'PortListSorter/lambda$3$Type',1647);feb(1649,1,fye,Pgc);_.Ne=function Qgc(a,b){return Agc(RD(a,12),RD(b,12))};_.Fb=function Rgc(a){return this===a};_.Oe=function Sgc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$4$Type',1649);feb(1651,1,QAe,Vgc);_.Kf=function Wgc(a,b){Tgc(RD(a,36),b);};sfb(hBe,'PortSideProcessor',1651);feb(1652,1,QAe,Ygc);_.Kf=function Zgc(a,b){Xgc(RD(a,36),b);};sfb(hBe,'ReversedEdgeRestorer',1652);feb(1657,1,QAe,ahc);_.Kf=function bhc(a,b){$gc(this,RD(a,36),b);};sfb(hBe,'SelfLoopPortRestorer',1657);feb(1658,1,{},chc);_.Kb=function dhc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopPortRestorer/lambda$0$Type',1658);feb(1659,1,nwe,ehc);_.Mb=function fhc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopPortRestorer/lambda$1$Type',1659);feb(1660,1,nwe,ghc);_.Mb=function hhc(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopPortRestorer/lambda$2$Type',1660);feb(1661,1,{},ihc);_.Kb=function jhc(a){return RD(mQb(RD(a,10),(Ywc(),Pwc)),337)};sfb(hBe,'SelfLoopPortRestorer/lambda$3$Type',1661);feb(1662,1,Qve,khc);_.Cd=function lhc(a){_gc(this.a,RD(a,337));};sfb(hBe,'SelfLoopPortRestorer/lambda$4$Type',1662);feb(805,1,Qve,mhc);_.Cd=function nhc(a){Rmc(RD(a,105));};sfb(hBe,'SelfLoopPortRestorer/lambda$5$Type',805);feb(1663,1,QAe,rhc);_.Kf=function thc(a,b){ohc(RD(a,36),b);};sfb(hBe,'SelfLoopPostProcessor',1663);feb(1664,1,{},uhc);_.Kb=function vhc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopPostProcessor/lambda$0$Type',1664);feb(1665,1,nwe,whc);_.Mb=function xhc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopPostProcessor/lambda$1$Type',1665);feb(1666,1,nwe,yhc);_.Mb=function zhc(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopPostProcessor/lambda$2$Type',1666);feb(1667,1,Qve,Ahc);_.Cd=function Bhc(a){phc(RD(a,10));};sfb(hBe,'SelfLoopPostProcessor/lambda$3$Type',1667);feb(1668,1,{},Chc);_.Kb=function Dhc(a){return new SDb(null,new Swb(RD(a,105).f,1))};sfb(hBe,'SelfLoopPostProcessor/lambda$4$Type',1668);feb(1669,1,Qve,Ehc);_.Cd=function Fhc(a){qhc(this.a,RD(a,340));};sfb(hBe,'SelfLoopPostProcessor/lambda$5$Type',1669);feb(1670,1,nwe,Ghc);_.Mb=function Hhc(a){return !!RD(a,105).i};sfb(hBe,'SelfLoopPostProcessor/lambda$6$Type',1670);feb(1671,1,Qve,Ihc);_.Cd=function Jhc(a){shc(this.a,RD(a,105));};sfb(hBe,'SelfLoopPostProcessor/lambda$7$Type',1671);feb(1653,1,QAe,Nhc);_.Kf=function Ohc(a,b){Mhc(RD(a,36),b);};sfb(hBe,'SelfLoopPreProcessor',1653);feb(1654,1,{},Phc);_.Kb=function Qhc(a){return new SDb(null,new Swb(RD(a,105).f,1))};sfb(hBe,'SelfLoopPreProcessor/lambda$0$Type',1654);feb(1655,1,{},Rhc);_.Kb=function Shc(a){return RD(a,340).a};sfb(hBe,'SelfLoopPreProcessor/lambda$1$Type',1655);feb(1656,1,Qve,Thc);_.Cd=function Uhc(a){Lhc(RD(a,18));};sfb(hBe,'SelfLoopPreProcessor/lambda$2$Type',1656);feb(1672,1,QAe,Yhc);_.Kf=function Zhc(a,b){Whc(this,RD(a,36),b);};sfb(hBe,'SelfLoopRouter',1672);feb(1673,1,{},$hc);_.Kb=function _hc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopRouter/lambda$0$Type',1673);feb(1674,1,nwe,aic);_.Mb=function bic(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopRouter/lambda$1$Type',1674);feb(1675,1,nwe,cic);_.Mb=function dic(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopRouter/lambda$2$Type',1675);feb(1676,1,{},eic);_.Kb=function fic(a){return RD(mQb(RD(a,10),(Ywc(),Pwc)),337)};sfb(hBe,'SelfLoopRouter/lambda$3$Type',1676);feb(1677,1,Qve,gic);_.Cd=function hic(a){Vhc(this.a,this.b,RD(a,337));};sfb(hBe,'SelfLoopRouter/lambda$4$Type',1677);feb(1678,1,QAe,jic);_.Kf=function mic(a,b){iic(RD(a,36),b);};sfb(hBe,'SemiInteractiveCrossMinProcessor',1678);feb(1679,1,nwe,nic);_.Mb=function oic(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$0$Type',1679);feb(1680,1,nwe,pic);_.Mb=function qic(a){return lQb(RD(a,10))._b((yCc(),IBc))};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$1$Type',1680);feb(1681,1,fye,ric);_.Ne=function sic(a,b){return kic(RD(a,10),RD(b,10))};_.Fb=function tic(a){return this===a};_.Oe=function uic(){return new Frb(this)};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$2$Type',1681);feb(1682,1,{},vic);_.Ve=function wic(a,b){return lic(RD(a,10),RD(b,10))};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$3$Type',1682);feb(1684,1,QAe,yic);_.Kf=function Cic(a,b){xic(RD(a,36),b);};sfb(hBe,'SortByInputModelProcessor',1684);feb(1685,1,nwe,Dic);_.Mb=function Eic(a){return RD(a,12).g.c.length!=0};sfb(hBe,'SortByInputModelProcessor/lambda$0$Type',1685);feb(1686,1,Qve,Fic);_.Cd=function Gic(a){Aic(this.a,RD(a,12));};sfb(hBe,'SortByInputModelProcessor/lambda$1$Type',1686);feb(1759,817,{},Pic);_.df=function Qic(a){var b,c,d,e;this.c=a;switch(this.a.g){case 2:b=new bnb;FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new Rjc),new Tjc(this,b));eHb(this,new Zic);Umb(b,new bjc);b.c.length=0;FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new djc),new fjc(b));eHb(this,new jjc);Umb(b,new njc);b.c.length=0;c=Wvb(TCb(HDb(new SDb(null,new Swb(this.c.a.b,16)),new pjc(this))),new rjc);FDb(new SDb(null,new Swb(this.c.a.a,16)),new vjc(c,b));eHb(this,new zjc);Umb(b,new Djc);b.c.length=0;break;case 3:d=new bnb;eHb(this,new Ric);e=Wvb(TCb(HDb(new SDb(null,new Swb(this.c.a.b,16)),new Vic(this))),new tjc);FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new Fjc),new Hjc(e,d));eHb(this,new Ljc);Umb(d,new Pjc);d.c.length=0;break;default:throw Adb(new Ied);}};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation',1759);feb(1760,1,xye,Ric);_.Lb=function Sic(a){return ZD(RD(a,60).g,154)};_.Fb=function Tic(a){return this===a};_.Mb=function Uic(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$0$Type',1760);feb(1761,1,{},Vic);_.Ye=function Wic(a){return Jic(this.a,RD(a,60))};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$1$Type',1761);feb(1769,1,owe,Xic);_.de=function Yic(){Iic(this.a,this.b,-1);};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$10$Type',1769);feb(1771,1,xye,Zic);_.Lb=function $ic(a){return ZD(RD(a,60).g,154)};_.Fb=function _ic(a){return this===a};_.Mb=function ajc(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$11$Type',1771);feb(1772,1,Qve,bjc);_.Cd=function cjc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$12$Type',1772);feb(1773,1,nwe,djc);_.Mb=function ejc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$13$Type',1773);feb(1775,1,Qve,fjc);_.Cd=function gjc(a){Kic(this.a,RD(a,60));};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$14$Type',1775);feb(1774,1,owe,hjc);_.de=function ijc(){Iic(this.b,this.a,-1);};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$15$Type',1774);feb(1776,1,xye,jjc);_.Lb=function kjc(a){return ZD(RD(a,60).g,10)};_.Fb=function ljc(a){return this===a};_.Mb=function mjc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$16$Type',1776);feb(1777,1,Qve,njc);_.Cd=function ojc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$17$Type',1777);feb(1778,1,{},pjc);_.Ye=function qjc(a){return Lic(this.a,RD(a,60))};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$18$Type',1778);feb(1779,1,{},rjc);_.We=function sjc(){return 0};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$19$Type',1779);feb(1762,1,{},tjc);_.We=function ujc(){return 0};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$2$Type',1762);feb(1781,1,Qve,vjc);_.Cd=function wjc(a){Mic(this.a,this.b,RD(a,316));};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$20$Type',1781);feb(1780,1,owe,xjc);_.de=function yjc(){Hic(this.a,this.b,-1);};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$21$Type',1780);feb(1782,1,xye,zjc);_.Lb=function Ajc(a){return RD(a,60),true};_.Fb=function Bjc(a){return this===a};_.Mb=function Cjc(a){return RD(a,60),true};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$22$Type',1782);feb(1783,1,Qve,Djc);_.Cd=function Ejc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$23$Type',1783);feb(1763,1,nwe,Fjc);_.Mb=function Gjc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$3$Type',1763);feb(1765,1,Qve,Hjc);_.Cd=function Ijc(a){Nic(this.a,this.b,RD(a,60));};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$4$Type',1765);feb(1764,1,owe,Jjc);_.de=function Kjc(){Iic(this.b,this.a,-1);};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$5$Type',1764);feb(1766,1,xye,Ljc);_.Lb=function Mjc(a){return RD(a,60),true};_.Fb=function Njc(a){return this===a};_.Mb=function Ojc(a){return RD(a,60),true};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$6$Type',1766);feb(1767,1,Qve,Pjc);_.Cd=function Qjc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$7$Type',1767);feb(1768,1,nwe,Rjc);_.Mb=function Sjc(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$8$Type',1768);feb(1770,1,Qve,Tjc);_.Cd=function Ujc(a){Oic(this.a,this.b,RD(a,60));};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$9$Type',1770);feb(1586,1,QAe,Yjc);_.Kf=function bkc(a,b){Xjc(this,RD(a,36),b);};var Vjc;sfb(rBe,'HorizontalGraphCompactor',1586);feb(1587,1,{},ckc);_.ff=function dkc(a,b){var c,d,e;if(_jc(a,b)){return 0}c=Zjc(a);d=Zjc(b);if(!!c&&c.k==(r3b(),m3b)||!!d&&d.k==(r3b(),m3b)){return 0}e=RD(mQb(this.a.a,(Ywc(),Qwc)),312);return ZEc(e,c?c.k:(r3b(),o3b),d?d.k:(r3b(),o3b))};_.gf=function ekc(a,b){var c,d,e;if(_jc(a,b)){return 1}c=Zjc(a);d=Zjc(b);e=RD(mQb(this.a.a,(Ywc(),Qwc)),312);return aFc(e,c?c.k:(r3b(),o3b),d?d.k:(r3b(),o3b))};sfb(rBe,'HorizontalGraphCompactor/1',1587);feb(1588,1,{},fkc);_.ef=function gkc(a,b){return Wjc(),a.a.i==0};sfb(rBe,'HorizontalGraphCompactor/lambda$0$Type',1588);feb(1589,1,{},hkc);_.ef=function ikc(a,b){return akc(this.a,a,b)};sfb(rBe,'HorizontalGraphCompactor/lambda$1$Type',1589);feb(1730,1,{},Ckc);var jkc,kkc;sfb(rBe,'LGraphToCGraphTransformer',1730);feb(1738,1,nwe,Kkc);_.Mb=function Lkc(a){return a!=null};sfb(rBe,'LGraphToCGraphTransformer/0methodref$nonNull$Type',1738);feb(1731,1,{},Mkc);_.Kb=function Nkc(a){return lkc(),jeb(mQb(RD(RD(a,60).g,10),(Ywc(),Awc)))};sfb(rBe,'LGraphToCGraphTransformer/lambda$0$Type',1731);feb(1732,1,{},Okc);_.Kb=function Pkc(a){return lkc(),Mlc(RD(RD(a,60).g,154))};sfb(rBe,'LGraphToCGraphTransformer/lambda$1$Type',1732);feb(1741,1,nwe,Qkc);_.Mb=function Rkc(a){return lkc(),ZD(RD(a,60).g,10)};sfb(rBe,'LGraphToCGraphTransformer/lambda$10$Type',1741);feb(1742,1,Qve,Skc);_.Cd=function Tkc(a){Dkc(RD(a,60));};sfb(rBe,'LGraphToCGraphTransformer/lambda$11$Type',1742);feb(1743,1,nwe,Ukc);_.Mb=function Vkc(a){return lkc(),ZD(RD(a,60).g,154)};sfb(rBe,'LGraphToCGraphTransformer/lambda$12$Type',1743);feb(1747,1,Qve,Wkc);_.Cd=function Xkc(a){Ekc(RD(a,60));};sfb(rBe,'LGraphToCGraphTransformer/lambda$13$Type',1747);feb(1744,1,Qve,Ykc);_.Cd=function Zkc(a){Fkc(this.a,RD(a,8));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$14$Type',1744);feb(1745,1,Qve,$kc);_.Cd=function _kc(a){Gkc(this.a,RD(a,116));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$15$Type',1745);feb(1746,1,Qve,alc);_.Cd=function blc(a){Hkc(this.a,RD(a,8));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$16$Type',1746);feb(1748,1,{},clc);_.Kb=function dlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$17$Type',1748);feb(1749,1,nwe,elc);_.Mb=function flc(a){return lkc(),W0b(RD(a,18))};sfb(rBe,'LGraphToCGraphTransformer/lambda$18$Type',1749);feb(1750,1,Qve,glc);_.Cd=function hlc(a){ukc(this.a,RD(a,18));};sfb(rBe,'LGraphToCGraphTransformer/lambda$19$Type',1750);feb(1734,1,Qve,ilc);_.Cd=function jlc(a){vkc(this.a,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$2$Type',1734);feb(1751,1,{},klc);_.Kb=function llc(a){return lkc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(rBe,'LGraphToCGraphTransformer/lambda$20$Type',1751);feb(1752,1,{},mlc);_.Kb=function nlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$21$Type',1752);feb(1753,1,{},olc);_.Kb=function plc(a){return lkc(),RD(mQb(RD(a,18),(Ywc(),Twc)),15)};sfb(rBe,'LGraphToCGraphTransformer/lambda$22$Type',1753);feb(1754,1,nwe,qlc);_.Mb=function rlc(a){return Ikc(RD(a,15))};sfb(rBe,'LGraphToCGraphTransformer/lambda$23$Type',1754);feb(1755,1,Qve,slc);_.Cd=function tlc(a){nkc(this.a,RD(a,15));};sfb(rBe,'LGraphToCGraphTransformer/lambda$24$Type',1755);feb(1733,1,Qve,ulc);_.Cd=function vlc(a){wkc(this.a,this.b,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$3$Type',1733);feb(1735,1,{},wlc);_.Kb=function xlc(a){return lkc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(rBe,'LGraphToCGraphTransformer/lambda$4$Type',1735);feb(1736,1,{},ylc);_.Kb=function zlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$5$Type',1736);feb(1737,1,{},Alc);_.Kb=function Blc(a){return lkc(),RD(mQb(RD(a,18),(Ywc(),Twc)),15)};sfb(rBe,'LGraphToCGraphTransformer/lambda$6$Type',1737);feb(1739,1,Qve,Clc);_.Cd=function Dlc(a){Jkc(this.a,RD(a,15));};sfb(rBe,'LGraphToCGraphTransformer/lambda$8$Type',1739);feb(1740,1,Qve,Elc);_.Cd=function Flc(a){xkc(this.a,this.b,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$9$Type',1740);feb(1729,1,{},Jlc);_.cf=function Klc(a){var b,c,d,e,f;this.a=a;this.d=new BIb;this.c=$C(DN,rve,125,this.a.a.a.c.length,0,1);this.b=0;for(c=new Anb(this.a.a.a);c.a=p){Rmb(f,sgb(k));s=$wnd.Math.max(s,t[k-1]-l);h+=o;q+=t[k-1]-q;l=t[k-1];o=i[k];}o=$wnd.Math.max(o,i[k]);++k;}h+=o;}n=$wnd.Math.min(1/s,1/b.b/h);if(n>d){d=n;c=f;}}return c};_.pg=function Psc(){return false};sfb(zBe,'MSDCutIndexHeuristic',816);feb(1683,1,QAe,Ssc);_.Kf=function Tsc(a,b){Rsc(RD(a,36),b);};sfb(zBe,'SingleEdgeGraphWrapper',1683);feb(232,22,{3:1,34:1,22:1,232:1},ctc);var Xsc,Ysc,Zsc,$sc,_sc,atc;var ZW=tfb(ABe,'CenterEdgeLabelPlacementStrategy',232,WI,etc,dtc);var ftc;feb(431,22,{3:1,34:1,22:1,431:1},ktc);var htc,itc;var $W=tfb(ABe,'ConstraintCalculationStrategy',431,WI,mtc,ltc);var ntc;feb(322,22,{3:1,34:1,22:1,322:1,188:1,196:1},utc);_.dg=function wtc(){return ttc(this)};_.qg=function vtc(){return ttc(this)};var ptc,qtc,rtc;var _W=tfb(ABe,'CrossingMinimizationStrategy',322,WI,ytc,xtc);var ztc;feb(351,22,{3:1,34:1,22:1,351:1},Ftc);var Btc,Ctc,Dtc;var aX=tfb(ABe,'CuttingStrategy',351,WI,Htc,Gtc);var Itc;feb(348,22,{3:1,34:1,22:1,348:1,188:1,196:1},Rtc);_.dg=function Ttc(){return Qtc(this)};_.qg=function Stc(){return Qtc(this)};var Ktc,Ltc,Mtc,Ntc,Otc;var bX=tfb(ABe,'CycleBreakingStrategy',348,WI,Vtc,Utc);var Wtc;feb(428,22,{3:1,34:1,22:1,428:1},_tc);var Ytc,Ztc;var cX=tfb(ABe,'DirectionCongruency',428,WI,buc,auc);var cuc;feb(460,22,{3:1,34:1,22:1,460:1},iuc);var euc,fuc,guc;var dX=tfb(ABe,'EdgeConstraint',460,WI,kuc,juc);var luc;feb(283,22,{3:1,34:1,22:1,283:1},vuc);var nuc,ouc,puc,quc,ruc,suc;var eX=tfb(ABe,'EdgeLabelSideSelection',283,WI,xuc,wuc);var yuc;feb(488,22,{3:1,34:1,22:1,488:1},Duc);var Auc,Buc;var fX=tfb(ABe,'EdgeStraighteningStrategy',488,WI,Fuc,Euc);var Guc;feb(281,22,{3:1,34:1,22:1,281:1},Puc);var Iuc,Juc,Kuc,Luc,Muc,Nuc;var gX=tfb(ABe,'FixedAlignment',281,WI,Ruc,Quc);var Suc;feb(282,22,{3:1,34:1,22:1,282:1},_uc);var Uuc,Vuc,Wuc,Xuc,Yuc,Zuc;var hX=tfb(ABe,'GraphCompactionStrategy',282,WI,bvc,avc);var cvc;feb(259,22,{3:1,34:1,22:1,259:1},pvc);var evc,fvc,gvc,hvc,ivc,jvc,kvc,lvc,mvc,nvc;var iX=tfb(ABe,'GraphProperties',259,WI,rvc,qvc);var svc;feb(299,22,{3:1,34:1,22:1,299:1},yvc);var uvc,vvc,wvc;var jX=tfb(ABe,'GreedySwitchType',299,WI,Avc,zvc);var Bvc;feb(311,22,{3:1,34:1,22:1,311:1},Hvc);var Dvc,Evc,Fvc;var kX=tfb(ABe,'InLayerConstraint',311,WI,Jvc,Ivc);var Kvc;feb(429,22,{3:1,34:1,22:1,429:1},Pvc);var Mvc,Nvc;var lX=tfb(ABe,'InteractiveReferencePoint',429,WI,Rvc,Qvc);var Svc;var Uvc,Vvc,Wvc,Xvc,Yvc,Zvc,$vc,_vc,awc,bwc,cwc,dwc,ewc,fwc,gwc,hwc,iwc,jwc,kwc,lwc,mwc,nwc,owc,pwc,qwc,rwc,swc,twc,uwc,vwc,wwc,xwc,ywc,zwc,Awc,Bwc,Cwc,Dwc,Ewc,Fwc,Gwc,Hwc,Iwc,Jwc,Kwc,Lwc,Mwc,Nwc,Owc,Pwc,Qwc,Rwc,Swc,Twc,Uwc,Vwc,Wwc,Xwc;feb(171,22,{3:1,34:1,22:1,171:1},dxc);var Zwc,$wc,_wc,axc,bxc;var mX=tfb(ABe,'LayerConstraint',171,WI,fxc,exc);var gxc;feb(859,1,Eye,Pzc);_.hf=function Qzc(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,HBe),''),'Direction Congruency'),'Specifies how drawings of the same graph with different layout directions compare to each other: either a natural reading direction is preserved or the drawings are rotated versions of each other.'),Uxc),(kid(),eid)),cX),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,IBe),''),'Feedback Edges'),'Whether feedback edges should be highlighted by routing around the nodes.'),(Geb(),false)),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JBe),''),'Interactive Reference Point'),'Determines which point of a node is considered by interactive layout phases.'),pyc),eid),lX),xsb(Whd))));zgd(a,JBe,RBe,ryc);zgd(a,JBe,_Be,qyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KBe),''),'Merge Edges'),'Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LBe),''),'Merge Hierarchy-Crossing Edges'),'If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Nhd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MBe),''),'Allow Non-Flow Ports To Switch Sides'),"Specifies whether non-flow ports may switch sides if their node's port constraints are either FIXED_SIDE or FIXED_ORDER. A non-flow port is a port on a side that is not part of the currently configured layout flow. For instance, given a left-to-right layout direction, north and south ports would be considered non-flow ports. Further note that the underlying criterium whether to switch sides or not solely relies on the minimization of edge crossings. Hence, edge length and other aesthetics criteria are not addressed."),false),cid),QI),xsb(Xhd)),cD(WC(qJ,1),Nve,2,6,['org.eclipse.elk.layered.northOrSouthPort']))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NBe),''),'Port Sorting Strategy'),"Only relevant for nodes with FIXED_SIDE port constraints. Determines the way a node's ports are distributed on the sides of a node if their order is not prescribed. The option is set on parent nodes."),azc),eid),xX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,OBe),''),'Thoroughness'),'How much effort should be spent to produce a nice layout.'),sgb(7)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PBe),''),'Add Unnecessary Bendpoints'),'Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,QBe),''),'Generate Position and Layer IDs'),'If enabled position id and layer id are generated, which are usually only used internally when setting the interactiveLayout option. This option should be specified on the root node.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RBe),'cycleBreaking'),'Cycle Breaking Strategy'),'Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right).'),Sxc),eid),bX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SBe),bDe),'Node Layering Strategy'),'Strategy for node layering.'),Gyc),eid),rX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TBe),bDe),'Layer Constraint'),'Determines a constraint on the placement of the node regarding the layering.'),wyc),eid),mX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UBe),bDe),'Layer Choice Constraint'),"Allows to set a constraint regarding the layer placement of a node. Let i be the value of teh constraint. Assumed the drawing has n layers and i < n. If set to i, it expresses that the node should be placed in i-th layer. Should i>=n be true then the node is placed in the last layer of the drawing. Note that this option is not part of any of ELK Layered's default configurations but is only evaluated as part of the `InteractiveLayeredGraphVisitor`, which must be applied manually or used via the `DiagramLayoutEngine."),null),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VBe),bDe),'Layer ID'),'Layer identifier that was calculated by ELK Layered for a node. This is only generated if interactiveLayot or generatePositionAndLayerIds is set.'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WBe),cDe),'Upper Bound On Width [MinWidth Layerer]'),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),sgb(4)),gid),bJ),xsb(Whd))));zgd(a,WBe,SBe,zyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XBe),cDe),'Upper Layer Estimation Scaling Factor [MinWidth Layerer]'),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),sgb(2)),gid),bJ),xsb(Whd))));zgd(a,XBe,SBe,Byc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YBe),dDe),'Node Promotion Strategy'),'Reduces number of dummy nodes after layering phase (if possible).'),Eyc),eid),vX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZBe),dDe),'Max Node Promotion Iterations'),'Limits the number of iterations for node promotion.'),sgb(0)),gid),bJ),xsb(Whd))));zgd(a,ZBe,YBe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Be),'layering.coffmanGraham'),'Layer Bound'),'The maximum number of nodes allowed per layer.'),sgb(lve)),gid),bJ),xsb(Whd))));zgd(a,$Be,SBe,tyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Be),eDe),'Crossing Minimization Strategy'),'Strategy for crossing minimization.'),Qxc),eid),_W),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aCe),eDe),'Force Node Model Order'),'The node order given by the model does not change to produce a better layout. E.g. if node A is before node B in the model this is not changed during crossing minimization. This assumes that the node model order is already respected before crossing minimization. This can be achieved by setting considerModelOrder.strategy to NODES_AND_EDGES.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bCe),eDe),'Hierarchical Sweepiness'),'How likely it is to use cross-hierarchy (1) vs bottom-up (-1).'),0.1),did),VI),xsb(Whd))));zgd(a,bCe,fDe,Ixc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,cCe),eDe),'Semi-Interactive Crossing Minimization'),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),false),cid),QI),xsb(Whd))));zgd(a,cCe,_Be,Oxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dCe),eDe),'In Layer Predecessor of'),"Allows to set a constraint which specifies of which node the current node is the predecessor. If set to 's' then the node is the predecessor of 's' and is in the same layer"),null),iid),qJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eCe),eDe),'In Layer Successor of'),"Allows to set a constraint which specifies of which node the current node is the successor. If set to 's' then the node is the successor of 's' and is in the same layer"),null),iid),qJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fCe),eDe),'Position Choice Constraint'),"Allows to set a constraint regarding the position placement of a node in a layer. Assumed the layer in which the node placed includes n other nodes and i < n. If set to i, it expresses that the node should be placed at the i-th position. Should i>=n be true then the node is placed at the last position in the layer. Note that this option is not part of any of ELK Layered's default configurations but is only evaluated as part of the `InteractiveLayeredGraphVisitor`, which must be applied manually or used via the `DiagramLayoutEngine."),null),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gCe),eDe),'Position ID'),'Position within a layer that was determined by ELK Layered for a node. This is only generated if interactiveLayot or generatePositionAndLayerIds is set.'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hCe),gDe),'Greedy Switch Activation Threshold'),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),sgb(40)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iCe),gDe),'Greedy Switch Crossing Minimization'),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular crossing minimization as a post-processor. Note that if 'hierarchyHandling' is set to 'INCLUDE_CHILDREN', the 'greedySwitchHierarchical.type' option must be used."),Fxc),eid),jX),xsb(Whd))));zgd(a,iCe,_Be,Gxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,jCe),'crossingMinimization.greedySwitchHierarchical'),'Greedy Switch Crossing Minimization (hierarchical)'),"Activates the greedy switch heuristic in case hierarchical layout is used. The differences to the non-hierarchical case (see 'greedySwitch.type') are: 1) greedy switch is inactive by default, 3) only the option value set on the node at which hierarchical layout starts is relevant, and 2) if it's activated by the user, it properly addresses hierarchy-crossing edges."),Bxc),eid),jX),xsb(Whd))));zgd(a,jCe,_Be,Cxc);zgd(a,jCe,fDe,Dxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kCe),hDe),'Node Placement Strategy'),'Strategy for node placement.'),$yc),eid),uX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,lCe),hDe),'Favor Straight Edges Over Balancing'),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),cid),QI),xsb(Whd))));zgd(a,lCe,kCe,Qyc);zgd(a,lCe,kCe,Ryc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,mCe),iDe),'BK Edge Straightening'),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),Kyc),eid),fX),xsb(Whd))));zgd(a,mCe,kCe,Lyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,nCe),iDe),'BK Fixed Alignment'),'Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four.'),Nyc),eid),gX),xsb(Whd))));zgd(a,nCe,kCe,Oyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,oCe),'nodePlacement.linearSegments'),'Linear Segments Deflection Dampening'),'Dampens the movement of nodes to keep the diagram from getting too large.'),0.3),did),VI),xsb(Whd))));zgd(a,oCe,kCe,Tyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,pCe),'nodePlacement.networkSimplex'),'Node Flexibility'),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),eid),tX),xsb(Vhd))));zgd(a,pCe,kCe,Yyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,qCe),'nodePlacement.networkSimplex.nodeFlexibility'),'Node Flexibility Default'),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),Wyc),eid),tX),xsb(Whd))));zgd(a,qCe,kCe,Xyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,rCe),jDe),'Self-Loop Distribution'),'Alter the distribution of the loops around the node. It only takes effect for PortConstraints.FREE.'),ayc),eid),zX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,sCe),jDe),'Self-Loop Ordering'),'Alter the ordering of the loops they can either be stacked or sequenced. It only takes effect for PortConstraints.FREE.'),cyc),eid),AX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,tCe),'edgeRouting.splines'),'Spline Routing Mode'),'Specifies the way control points are assembled for each individual edge. CONSERVATIVE ensures that edges are properly routed around the nodes but feels rather orthogonal at times. SLOPPY uses fewer control points to obtain curvier edge routes but may result in edges overlapping nodes.'),eyc),eid),CX),xsb(Whd))));zgd(a,tCe,kDe,fyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,uCe),'edgeRouting.splines.sloppy'),'Sloppy Spline Layer Spacing Factor'),'Spacing factor for routing area between layers when using sloppy spline routing.'),0.2),did),VI),xsb(Whd))));zgd(a,uCe,kDe,hyc);zgd(a,uCe,tCe,iyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,vCe),'edgeRouting.polyline'),'Sloped Edge Zone Width'),'Width of the strip to the left and to the right of each layer where the polyline edge router is allowed to refrain from ensuring that edges are routed horizontally. This prevents awkward bend points for nodes that extent almost to the edge of their layer.'),2),did),VI),xsb(Whd))));zgd(a,vCe,kDe,$xc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,wCe),lDe),'Spacing Base Value'),"An optional base value for all other layout options of the 'spacing' group. It can be used to conveniently alter the overall 'spaciousness' of the drawing. Whenever an explicit value is set for the other layout options, this base value will have no effect. The base value is not inherited, i.e. it must be set for each hierarchical node."),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xCe),lDe),'Edge Node Between Layers Spacing'),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yCe),lDe),'Edge Edge Between Layer Spacing'),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zCe),lDe),'Node Node Between Layers Spacing'),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ACe),mDe),'Direction Priority'),'Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,BCe),mDe),'Shortness Priority'),'Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CCe),mDe),'Straightness Priority'),'Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,DCe),nDe),qze),'Tries to further compact components (disconnected sub-graphs).'),false),cid),QI),xsb(Whd))));zgd(a,DCe,cAe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ECe),oDe),'Post Compaction Strategy'),pDe),nxc),eid),hX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,FCe),oDe),'Post Compaction Constraint Calculation'),pDe),lxc),eid),$W),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,GCe),qDe),'High Degree Node Treatment'),'Makes room around high degree nodes to place leafs and trees.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,HCe),qDe),'High Degree Node Threshold'),'Whether a node is considered to have a high degree.'),sgb(16)),gid),bJ),xsb(Whd))));zgd(a,HCe,GCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ICe),qDe),'High Degree Node Maximum Tree Height'),'Maximum height of a subtree connected to a high degree node to be moved to separate layers.'),sgb(5)),gid),bJ),xsb(Whd))));zgd(a,ICe,GCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JCe),rDe),'Graph Wrapping Strategy'),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),Gzc),eid),EX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KCe),rDe),'Additional Wrapped Edges Spacing'),'To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing.'),10),did),VI),xsb(Whd))));zgd(a,KCe,JCe,lzc);zgd(a,KCe,JCe,mzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LCe),rDe),'Correction Factor for Wrapping'),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simply multiplied with the 'aspect ratio' layout option."),1),did),VI),xsb(Whd))));zgd(a,LCe,JCe,ozc);zgd(a,LCe,JCe,pzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MCe),sDe),'Cutting Strategy'),'The strategy by which the layer indexes are determined at which the layering crumbles into chunks.'),wzc),eid),aX),xsb(Whd))));zgd(a,MCe,JCe,xzc);zgd(a,MCe,JCe,yzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,NCe),sDe),'Manually Specified Cuts'),'Allows the user to specify her own cuts for a certain graph.'),hid),QK),xsb(Whd))));zgd(a,NCe,MCe,rzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,OCe),'wrapping.cutting.msd'),'MSD Freedom'),'The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts.'),tzc),gid),bJ),xsb(Whd))));zgd(a,OCe,MCe,uzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PCe),tDe),'Validification Strategy'),'When wrapping graphs, one can specify indices that are not allowed as split points. The validification strategy makes sure every computed split point is allowed.'),Lzc),eid),DX),xsb(Whd))));zgd(a,PCe,JCe,Mzc);zgd(a,PCe,JCe,Nzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,QCe),tDe),'Valid Indices for Wrapping'),null),hid),QK),xsb(Whd))));zgd(a,QCe,JCe,Izc);zgd(a,QCe,JCe,Jzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RCe),uDe),'Improve Cuts'),'For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought.'),true),cid),QI),xsb(Whd))));zgd(a,RCe,JCe,Czc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SCe),uDe),'Distance Penalty When Improving Cuts'),null),2),did),VI),xsb(Whd))));zgd(a,SCe,JCe,Azc);zgd(a,SCe,RCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TCe),uDe),'Improve Wrapped Edges'),'The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges.'),true),cid),QI),xsb(Whd))));zgd(a,TCe,JCe,Ezc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UCe),vDe),'Edge Label Side Selection'),'Method to decide on edge label sides.'),Yxc),eid),eX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VCe),vDe),'Edge Center Label Placement Strategy'),'Determines in which layer center labels of long edges should be placed.'),Wxc),eid),ZW),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WCe),wDe),'Consider Model Order'),'Preserves the order of nodes and edges in the model file if this does not lead to additional edge crossings. Depending on the strategy this is not always possible since the node and edge order might be conflicting.'),xxc),eid),wX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XCe),wDe),'Consider Port Order'),'If disabled the port order of output ports is derived from the edge order and input ports are ordered by their incoming connections. If enabled all ports are ordered by the port model order.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YCe),wDe),'No Model Order'),'Set on a node to not set a model order for this node even though it is a real node.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZCe),wDe),'Consider Model Order for Components'),'If set to NONE the usual ordering strategy (by cumulative node priority and size of nodes) is used. INSIDE_PORT_SIDES orders the components with external ports only inside the groups with the same port side. FORCE_MODEL_ORDER enforces the mode order on components. This option might produce bad alignments and sub optimal drawings in terms of used area since the ordering should be respected.'),pxc),eid),CQ),xsb(Whd))));zgd(a,ZCe,cAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Ce),wDe),'Long Edge Ordering Strategy'),'Indicates whether long edges are sorted under, over, or equal to nodes that have no connection to a previous layer in a left-to-right or right-to-left layout. Under and over changes to right and left in a vertical layout.'),txc),eid),sX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Ce),wDe),'Crossing Counter Node Order Influence'),'Indicates with what percentage (1 for 100%) violations of the node model order are weighted against the crossings e.g. a value of 0.5 means two model order violations are as important as on edge crossing. This allows some edge crossings in favor of preserving the model order. It is advised to set this value to a very small positive value (e.g. 0.001) to have minimal crossing and a optimal node order. Defaults to no influence (0).'),0),did),VI),xsb(Whd))));zgd(a,_Ce,WCe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aDe),wDe),'Crossing Counter Port Order Influence'),'Indicates with what percentage (1 for 100%) violations of the port model order are weighted against the crossings e.g. a value of 0.5 means two model order violations are as important as on edge crossing. This allows some edge crossings in favor of preserving the model order. It is advised to set this value to a very small positive value (e.g. 0.001) to have minimal crossing and a optimal port order. Defaults to no influence (0).'),0),did),VI),xsb(Whd))));zgd(a,aDe,WCe,null);zCc((new ACc,a));};var ixc,jxc,kxc,lxc,mxc,nxc,oxc,pxc,qxc,rxc,sxc,txc,uxc,vxc,wxc,xxc,yxc,zxc,Axc,Bxc,Cxc,Dxc,Exc,Fxc,Gxc,Hxc,Ixc,Jxc,Kxc,Lxc,Mxc,Nxc,Oxc,Pxc,Qxc,Rxc,Sxc,Txc,Uxc,Vxc,Wxc,Xxc,Yxc,Zxc,$xc,_xc,ayc,byc,cyc,dyc,eyc,fyc,gyc,hyc,iyc,jyc,kyc,lyc,myc,nyc,oyc,pyc,qyc,ryc,syc,tyc,uyc,vyc,wyc,xyc,yyc,zyc,Ayc,Byc,Cyc,Dyc,Eyc,Fyc,Gyc,Hyc,Iyc,Jyc,Kyc,Lyc,Myc,Nyc,Oyc,Pyc,Qyc,Ryc,Syc,Tyc,Uyc,Vyc,Wyc,Xyc,Yyc,Zyc,$yc,_yc,azc,bzc,czc,dzc,ezc,fzc,gzc,hzc,izc,jzc,kzc,lzc,mzc,nzc,ozc,pzc,qzc,rzc,szc,tzc,uzc,vzc,wzc,xzc,yzc,zzc,Azc,Bzc,Czc,Dzc,Ezc,Fzc,Gzc,Hzc,Izc,Jzc,Kzc,Lzc,Mzc,Nzc;sfb(ABe,'LayeredMetaDataProvider',859);feb(998,1,Eye,ACc);_.hf=function BCc(a){zCc(a);};var Rzc,Szc,Tzc,Uzc,Vzc,Wzc,Xzc,Yzc,Zzc,$zc,_zc,aAc,bAc,cAc,dAc,eAc,fAc,gAc,hAc,iAc,jAc,kAc,lAc,mAc,nAc,oAc,pAc,qAc,rAc,sAc,tAc,uAc,vAc,wAc,xAc,yAc,zAc,AAc,BAc,CAc,DAc,EAc,FAc,GAc,HAc,IAc,JAc,KAc,LAc,MAc,NAc,OAc,PAc,QAc,RAc,SAc,TAc,UAc,VAc,WAc,XAc,YAc,ZAc,$Ac,_Ac,aBc,bBc,cBc,dBc,eBc,fBc,gBc,hBc,iBc,jBc,kBc,lBc,mBc,nBc,oBc,pBc,qBc,rBc,sBc,tBc,uBc,vBc,wBc,xBc,yBc,zBc,ABc,BBc,CBc,DBc,EBc,FBc,GBc,HBc,IBc,JBc,KBc,LBc,MBc,NBc,OBc,PBc,QBc,RBc,SBc,TBc,UBc,VBc,WBc,XBc,YBc,ZBc,$Bc,_Bc,aCc,bCc,cCc,dCc,eCc,fCc,gCc,hCc,iCc,jCc,kCc,lCc,mCc,nCc,oCc,pCc,qCc,rCc,sCc,tCc,uCc,vCc,wCc,xCc;sfb(ABe,'LayeredOptions',998);feb(999,1,{},CCc);_.sf=function DCc(){var a;return a=new lXb,a};_.tf=function ECc(a){};sfb(ABe,'LayeredOptions/LayeredFactory',999);feb(1391,1,{});_.a=0;var FCc;sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder',1391);feb(792,1391,{},RCc);var OCc,PCc;sfb(ABe,'LayeredSpacings/LayeredSpacingsBuilder',792);feb(265,22,{3:1,34:1,22:1,265:1,188:1,196:1},bDc);_.dg=function dDc(){return aDc(this)};_.qg=function cDc(){return aDc(this)};var SCc,TCc,UCc,VCc,WCc,XCc,YCc,ZCc,$Cc;var rX=tfb(ABe,'LayeringStrategy',265,WI,fDc,eDc);var gDc;feb(390,22,{3:1,34:1,22:1,390:1},nDc);var iDc,jDc,kDc;var sX=tfb(ABe,'LongEdgeOrderingStrategy',390,WI,pDc,oDc);var qDc;feb(203,22,{3:1,34:1,22:1,203:1},yDc);var sDc,tDc,uDc,vDc;var tX=tfb(ABe,'NodeFlexibility',203,WI,BDc,ADc);var CDc;feb(323,22,{3:1,34:1,22:1,323:1,188:1,196:1},LDc);_.dg=function NDc(){return KDc(this)};_.qg=function MDc(){return KDc(this)};var EDc,FDc,GDc,HDc,IDc;var uX=tfb(ABe,'NodePlacementStrategy',323,WI,PDc,ODc);var QDc;feb(243,22,{3:1,34:1,22:1,243:1},bEc);var SDc,TDc,UDc,VDc,WDc,XDc,YDc,ZDc,$Dc,_Dc;var vX=tfb(ABe,'NodePromotionStrategy',243,WI,dEc,cEc);var eEc;feb(284,22,{3:1,34:1,22:1,284:1},lEc);var gEc,hEc,iEc,jEc;var wX=tfb(ABe,'OrderingStrategy',284,WI,nEc,mEc);var oEc;feb(430,22,{3:1,34:1,22:1,430:1},tEc);var qEc,rEc;var xX=tfb(ABe,'PortSortingStrategy',430,WI,vEc,uEc);var wEc;feb(463,22,{3:1,34:1,22:1,463:1},CEc);var yEc,zEc,AEc;var yX=tfb(ABe,'PortType',463,WI,EEc,DEc);var FEc;feb(387,22,{3:1,34:1,22:1,387:1},LEc);var HEc,IEc,JEc;var zX=tfb(ABe,'SelfLoopDistributionStrategy',387,WI,NEc,MEc);var OEc;feb(349,22,{3:1,34:1,22:1,349:1},UEc);var QEc,REc,SEc;var AX=tfb(ABe,'SelfLoopOrderingStrategy',349,WI,WEc,VEc);var XEc;feb(312,1,{312:1},gFc);sfb(ABe,'Spacings',312);feb(350,22,{3:1,34:1,22:1,350:1},mFc);var iFc,jFc,kFc;var CX=tfb(ABe,'SplineRoutingMode',350,WI,oFc,nFc);var pFc;feb(352,22,{3:1,34:1,22:1,352:1},vFc);var rFc,sFc,tFc;var DX=tfb(ABe,'ValidifyStrategy',352,WI,xFc,wFc);var yFc;feb(388,22,{3:1,34:1,22:1,388:1},EFc);var AFc,BFc,CFc;var EX=tfb(ABe,'WrappingStrategy',388,WI,GFc,FFc);var HFc;feb(1398,1,nEe,NFc);_.rg=function OFc(a){return RD(a,36),JFc};_.Kf=function PFc(a,b){MFc(this,RD(a,36),b);};var JFc;sfb(oEe,'DepthFirstCycleBreaker',1398);feb(793,1,nEe,UFc);_.rg=function WFc(a){return RD(a,36),QFc};_.Kf=function XFc(a,b){SFc(this,RD(a,36),b);};_.sg=function VFc(a){return RD(Vmb(a,Jwb(this.d,a.c.length)),10)};var QFc;sfb(oEe,'GreedyCycleBreaker',793);feb(1401,793,nEe,YFc);_.sg=function ZFc(a){var b,c,d,e;e=null;b=lve;for(d=new Anb(a);d.a1){Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),(yCc(),eAc))))?wLc(a,this.d,RD(this,669)):(yob(),_mb(a,this.d));nJc(this.e,a);}};_.lg=function bJc(a,b,c,d){var e,f,g,h,i,j,k;if(b!=SIc(c,a.length)){f=a[b-(c?1:-1)];sIc(this.f,f,c?(BEc(),zEc):(BEc(),yEc));}e=a[b][0];k=!d||e.k==(r3b(),m3b);j=dv(a[b]);this.vg(j,k,false,c);g=0;for(i=new Anb(j);i.a');a0?(pMc(this.a,a[b-1],a[b]),undefined):!c&&b1){Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),(yCc(),eAc))))?wLc(a,this.d,this):(yob(),_mb(a,this.d));Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),eAc)))||nJc(this.e,a);}};sfb(sEe,'ModelOrderBarycenterHeuristic',669);feb(1866,1,fye,yLc);_.Ne=function zLc(a,b){return tLc(this.a,RD(a,10),RD(b,10))};_.Fb=function ALc(a){return this===a};_.Oe=function BLc(){return new Frb(this)};sfb(sEe,'ModelOrderBarycenterHeuristic/lambda$0$Type',1866);feb(1423,1,nEe,FLc);_.rg=function GLc(a){var b;return RD(a,36),b=vfd(CLc),pfd(b,(sXb(),pXb),(hcc(),Ybc)),b};_.Kf=function HLc(a,b){ELc((RD(a,36),b));};var CLc;sfb(sEe,'NoCrossingMinimizer',1423);feb(809,413,qEe,ILc);_.tg=function JLc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;l=this.g;switch(c.g){case 1:{e=0;f=0;for(k=new Anb(a.j);k.a1&&(e.j==(qpd(),Xod)?(this.b[a]=true):e.j==ppd&&a>0&&(this.b[a-1]=true));};_.f=0;sfb(tBe,'AllCrossingsCounter',1861);feb(595,1,{},_Lc);_.b=0;_.d=0;sfb(tBe,'BinaryIndexedTree',595);feb(532,1,{},DMc);var bMc,cMc;sfb(tBe,'CrossingsCounter',532);feb(1950,1,fye,HMc);_.Ne=function IMc(a,b){return wMc(this.a,RD(a,12),RD(b,12))};_.Fb=function JMc(a){return this===a};_.Oe=function KMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$0$Type',1950);feb(1951,1,fye,LMc);_.Ne=function MMc(a,b){return xMc(this.a,RD(a,12),RD(b,12))};_.Fb=function NMc(a){return this===a};_.Oe=function OMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$1$Type',1951);feb(1952,1,fye,PMc);_.Ne=function QMc(a,b){return yMc(this.a,RD(a,12),RD(b,12))};_.Fb=function RMc(a){return this===a};_.Oe=function SMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$2$Type',1952);feb(1953,1,fye,TMc);_.Ne=function UMc(a,b){return zMc(this.a,RD(a,12),RD(b,12))};_.Fb=function VMc(a){return this===a};_.Oe=function WMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$3$Type',1953);feb(1954,1,Qve,XMc);_.Cd=function YMc(a){EMc(this.a,RD(a,12));};sfb(tBe,'CrossingsCounter/lambda$4$Type',1954);feb(1955,1,nwe,ZMc);_.Mb=function $Mc(a){return FMc(this.a,RD(a,12))};sfb(tBe,'CrossingsCounter/lambda$5$Type',1955);feb(1956,1,Qve,aNc);_.Cd=function bNc(a){_Mc(this,a);};sfb(tBe,'CrossingsCounter/lambda$6$Type',1956);feb(1957,1,Qve,cNc);_.Cd=function dNc(a){var b;dMc();hmb(this.b,(b=this.a,RD(a,12),b));};sfb(tBe,'CrossingsCounter/lambda$7$Type',1957);feb(839,1,xye,eNc);_.Lb=function fNc(a){return dMc(),nQb(RD(a,12),(Ywc(),Iwc))};_.Fb=function gNc(a){return this===a};_.Mb=function hNc(a){return dMc(),nQb(RD(a,12),(Ywc(),Iwc))};sfb(tBe,'CrossingsCounter/lambda$8$Type',839);feb(1949,1,{},jNc);sfb(tBe,'HyperedgeCrossingsCounter',1949);feb(478,1,{34:1,478:1},lNc);_.Fd=function mNc(a){return kNc(this,RD(a,478))};_.b=0;_.c=0;_.e=0;_.f=0;var OY=sfb(tBe,'HyperedgeCrossingsCounter/Hyperedge',478);feb(374,1,{34:1,374:1},oNc);_.Fd=function pNc(a){return nNc(this,RD(a,374))};_.b=0;_.c=0;var NY=sfb(tBe,'HyperedgeCrossingsCounter/HyperedgeCorner',374);feb(531,22,{3:1,34:1,22:1,531:1},tNc);var qNc,rNc;var MY=tfb(tBe,'HyperedgeCrossingsCounter/HyperedgeCorner/Type',531,WI,vNc,uNc);var wNc;feb(1425,1,nEe,DNc);_.rg=function ENc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?zNc:null};_.Kf=function FNc(a,b){CNc(this,RD(a,36),b);};var zNc;sfb(tEe,'InteractiveNodePlacer',1425);feb(1426,1,nEe,TNc);_.rg=function UNc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?GNc:null};_.Kf=function VNc(a,b){RNc(this,RD(a,36),b);};var GNc,HNc,INc;sfb(tEe,'LinearSegmentsNodePlacer',1426);feb(261,1,{34:1,261:1},ZNc);_.Fd=function $Nc(a){return WNc(this,RD(a,261))};_.Fb=function _Nc(a){var b;if(ZD(a,261)){b=RD(a,261);return this.b==b.b}return false};_.Hb=function aOc(){return this.b};_.Ib=function bOc(){return 'ls'+Fe(this.e)};_.a=0;_.b=0;_.c=-1;_.d=-1;_.g=0;var SY=sfb(tEe,'LinearSegmentsNodePlacer/LinearSegment',261);feb(1428,1,nEe,yOc);_.rg=function zOc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?cOc:null};_.Kf=function HOc(a,b){uOc(this,RD(a,36),b);};_.b=0;_.g=0;var cOc;sfb(tEe,'NetworkSimplexPlacer',1428);feb(1447,1,fye,IOc);_.Ne=function JOc(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function KOc(a){return this===a};_.Oe=function LOc(){return new Frb(this)};sfb(tEe,'NetworkSimplexPlacer/0methodref$compare$Type',1447);feb(1449,1,fye,MOc);_.Ne=function NOc(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function OOc(a){return this===a};_.Oe=function POc(){return new Frb(this)};sfb(tEe,'NetworkSimplexPlacer/1methodref$compare$Type',1449);feb(655,1,{655:1},QOc);var WY=sfb(tEe,'NetworkSimplexPlacer/EdgeRep',655);feb(412,1,{412:1},ROc);_.b=false;var XY=sfb(tEe,'NetworkSimplexPlacer/NodeRep',412);feb(515,13,{3:1,4:1,20:1,31:1,56:1,13:1,16:1,15:1,59:1,515:1},VOc);sfb(tEe,'NetworkSimplexPlacer/Path',515);feb(1429,1,{},WOc);_.Kb=function XOc(a){return RD(a,18).d.i.k};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$0$Type',1429);feb(1430,1,nwe,YOc);_.Mb=function ZOc(a){return RD(a,273)==(r3b(),o3b)};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$1$Type',1430);feb(1431,1,{},$Oc);_.Kb=function _Oc(a){return RD(a,18).d.i};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$2$Type',1431);feb(1432,1,nwe,aPc);_.Mb=function bPc(a){return EPc(zDc(RD(a,10)))};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$3$Type',1432);feb(1433,1,nwe,cPc);_.Mb=function dPc(a){return DOc(RD(a,12))};sfb(tEe,'NetworkSimplexPlacer/lambda$0$Type',1433);feb(1434,1,Qve,ePc);_.Cd=function fPc(a){jOc(this.a,this.b,RD(a,12));};sfb(tEe,'NetworkSimplexPlacer/lambda$1$Type',1434);feb(1443,1,Qve,gPc);_.Cd=function hPc(a){kOc(this.a,RD(a,18));};sfb(tEe,'NetworkSimplexPlacer/lambda$10$Type',1443);feb(1444,1,{},iPc);_.Kb=function jPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$11$Type',1444);feb(1445,1,Qve,kPc);_.Cd=function lPc(a){lOc(this.a,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$12$Type',1445);feb(1446,1,{},mPc);_.Kb=function nPc(a){return dOc(),sgb(RD(a,125).e)};sfb(tEe,'NetworkSimplexPlacer/lambda$13$Type',1446);feb(1448,1,{},oPc);_.Kb=function pPc(a){return dOc(),sgb(RD(a,125).e)};sfb(tEe,'NetworkSimplexPlacer/lambda$15$Type',1448);feb(1450,1,nwe,qPc);_.Mb=function rPc(a){return dOc(),RD(a,412).c.k==(r3b(),p3b)};sfb(tEe,'NetworkSimplexPlacer/lambda$17$Type',1450);feb(1451,1,nwe,sPc);_.Mb=function tPc(a){return dOc(),RD(a,412).c.j.c.length>1};sfb(tEe,'NetworkSimplexPlacer/lambda$18$Type',1451);feb(1452,1,Qve,uPc);_.Cd=function vPc(a){EOc(this.c,this.b,this.d,this.a,RD(a,412));};_.c=0;_.d=0;sfb(tEe,'NetworkSimplexPlacer/lambda$19$Type',1452);feb(1435,1,{},wPc);_.Kb=function xPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$2$Type',1435);feb(1453,1,Qve,yPc);_.Cd=function zPc(a){FOc(this.a,RD(a,12));};_.a=0;sfb(tEe,'NetworkSimplexPlacer/lambda$20$Type',1453);feb(1454,1,{},APc);_.Kb=function BPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$21$Type',1454);feb(1455,1,Qve,CPc);_.Cd=function DPc(a){mOc(this.a,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$22$Type',1455);feb(1456,1,nwe,FPc);_.Mb=function GPc(a){return EPc(a)};sfb(tEe,'NetworkSimplexPlacer/lambda$23$Type',1456);feb(1457,1,{},HPc);_.Kb=function IPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$24$Type',1457);feb(1458,1,nwe,JPc);_.Mb=function KPc(a){return nOc(this.a,RD(a,10))};sfb(tEe,'NetworkSimplexPlacer/lambda$25$Type',1458);feb(1459,1,Qve,LPc);_.Cd=function MPc(a){oOc(this.a,this.b,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$26$Type',1459);feb(1460,1,nwe,NPc);_.Mb=function OPc(a){return dOc(),!W0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$27$Type',1460);feb(1461,1,nwe,PPc);_.Mb=function QPc(a){return dOc(),!W0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$28$Type',1461);feb(1462,1,{},RPc);_.Ve=function SPc(a,b){return pOc(this.a,RD(a,30),RD(b,30))};sfb(tEe,'NetworkSimplexPlacer/lambda$29$Type',1462);feb(1436,1,{},TPc);_.Kb=function UPc(a){return dOc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(tEe,'NetworkSimplexPlacer/lambda$3$Type',1436);feb(1437,1,nwe,VPc);_.Mb=function WPc(a){return dOc(),COc(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$4$Type',1437);feb(1438,1,Qve,XPc);_.Cd=function YPc(a){vOc(this.a,RD(a,18));};sfb(tEe,'NetworkSimplexPlacer/lambda$5$Type',1438);feb(1439,1,{},ZPc);_.Kb=function $Pc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$6$Type',1439);feb(1440,1,nwe,_Pc);_.Mb=function aQc(a){return dOc(),RD(a,10).k==(r3b(),p3b)};sfb(tEe,'NetworkSimplexPlacer/lambda$7$Type',1440);feb(1441,1,{},bQc);_.Kb=function cQc(a){return dOc(),new SDb(null,new Twb(new is(Mr(W2b(RD(a,10)).a.Kc(),new ir))))};sfb(tEe,'NetworkSimplexPlacer/lambda$8$Type',1441);feb(1442,1,nwe,dQc);_.Mb=function eQc(a){return dOc(),V0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$9$Type',1442);feb(1424,1,nEe,iQc);_.rg=function jQc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?fQc:null};_.Kf=function kQc(a,b){hQc(RD(a,36),b);};var fQc;sfb(tEe,'SimpleNodePlacer',1424);feb(185,1,{185:1},sQc);_.Ib=function tQc(){var a;a='';this.c==(wQc(),vQc)?(a+=Oye):this.c==uQc&&(a+=Nye);this.o==(EQc(),CQc)?(a+=Zye):this.o==DQc?(a+='UP'):(a+='BALANCED');return a};sfb(wEe,'BKAlignedLayout',185);feb(523,22,{3:1,34:1,22:1,523:1},xQc);var uQc,vQc;var FZ=tfb(wEe,'BKAlignedLayout/HDirection',523,WI,zQc,yQc);var AQc;feb(522,22,{3:1,34:1,22:1,522:1},FQc);var CQc,DQc;var GZ=tfb(wEe,'BKAlignedLayout/VDirection',522,WI,HQc,GQc);var IQc;feb(1699,1,{},MQc);sfb(wEe,'BKAligner',1699);feb(1702,1,{},RQc);sfb(wEe,'BKCompactor',1702);feb(663,1,{663:1},SQc);_.a=0;sfb(wEe,'BKCompactor/ClassEdge',663);feb(467,1,{467:1},UQc);_.a=null;_.b=0;sfb(wEe,'BKCompactor/ClassNode',467);feb(1427,1,nEe,aRc);_.rg=function eRc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?VQc:null};_.Kf=function fRc(a,b){_Qc(this,RD(a,36),b);};_.d=false;var VQc;sfb(wEe,'BKNodePlacer',1427);feb(1700,1,{},hRc);_.d=0;sfb(wEe,'NeighborhoodInformation',1700);feb(1701,1,fye,mRc);_.Ne=function nRc(a,b){return lRc(this,RD(a,42),RD(b,42))};_.Fb=function oRc(a){return this===a};_.Oe=function pRc(){return new Frb(this)};sfb(wEe,'NeighborhoodInformation/NeighborComparator',1701);feb(823,1,{});sfb(wEe,'ThresholdStrategy',823);feb(1825,823,{},uRc);_.wg=function vRc(a,b,c){return this.a.o==(EQc(),DQc)?oxe:pxe};_.xg=function wRc(){};sfb(wEe,'ThresholdStrategy/NullThresholdStrategy',1825);feb(587,1,{587:1},xRc);_.c=false;_.d=false;sfb(wEe,'ThresholdStrategy/Postprocessable',587);feb(1826,823,{},BRc);_.wg=function CRc(a,b,c){var d,e,f;e=b==c;d=this.a.a[c.p]==b;if(!(e||d)){return a}f=a;if(this.a.c==(wQc(),vQc)){e&&(f=yRc(this,b,true));!isNaN(f)&&!isFinite(f)&&d&&(f=yRc(this,c,false));}else {e&&(f=yRc(this,b,true));!isNaN(f)&&!isFinite(f)&&d&&(f=yRc(this,c,false));}return f};_.xg=function DRc(){var a,b,c,d,e;while(this.d.b!=0){e=RD(Tub(this.d),587);d=zRc(this,e);if(!d.a){continue}a=d.a;c=Heb(this.a.f[this.a.g[e.b.p].p]);if(!c&&!W0b(a)&&a.c.i.c==a.d.i.c){continue}b=ARc(this,e);b||Eyb(this.e,e);}while(this.e.a.c.length!=0){ARc(this,RD(Dyb(this.e),587));}};sfb(wEe,'ThresholdStrategy/SimpleThresholdStrategy',1826);feb(645,1,{645:1,188:1,196:1},HRc);_.dg=function JRc(){return GRc(this)};_.qg=function IRc(){return GRc(this)};var ERc;sfb(xEe,'EdgeRouterFactory',645);feb(1485,1,nEe,WRc);_.rg=function XRc(a){return URc(RD(a,36))};_.Kf=function YRc(a,b){VRc(RD(a,36),b);};var LRc,MRc,NRc,ORc,PRc,QRc,RRc,SRc;sfb(xEe,'OrthogonalEdgeRouter',1485);feb(1478,1,nEe,lSc);_.rg=function mSc(a){return gSc(RD(a,36))};_.Kf=function nSc(a,b){iSc(this,RD(a,36),b);};var ZRc,$Rc,_Rc,aSc,bSc,cSc;sfb(xEe,'PolylineEdgeRouter',1478);feb(1479,1,xye,pSc);_.Lb=function qSc(a){return oSc(RD(a,10))};_.Fb=function rSc(a){return this===a};_.Mb=function sSc(a){return oSc(RD(a,10))};sfb(xEe,'PolylineEdgeRouter/1',1479);feb(1872,1,nwe,xSc);_.Mb=function ySc(a){return RD(a,132).c==(fTc(),dTc)};sfb(yEe,'HyperEdgeCycleDetector/lambda$0$Type',1872);feb(1873,1,{},zSc);_.Ze=function ASc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$1$Type',1873);feb(1874,1,nwe,BSc);_.Mb=function CSc(a){return RD(a,132).c==(fTc(),dTc)};sfb(yEe,'HyperEdgeCycleDetector/lambda$2$Type',1874);feb(1875,1,{},DSc);_.Ze=function ESc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$3$Type',1875);feb(1876,1,{},FSc);_.Ze=function GSc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$4$Type',1876);feb(1877,1,{},HSc);_.Ze=function ISc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$5$Type',1877);feb(118,1,{34:1,118:1},USc);_.Fd=function VSc(a){return KSc(this,RD(a,118))};_.Fb=function WSc(a){var b;if(ZD(a,118)){b=RD(a,118);return this.g==b.g}return false};_.Hb=function XSc(){return this.g};_.Ib=function ZSc(){var a,b,c,d;a=new dib('{');d=new Anb(this.n);while(d.a'+this.b+' ('+os(this.c)+')'};_.d=0;sfb(yEe,'HyperEdgeSegmentDependency',132);feb(528,22,{3:1,34:1,22:1,528:1},gTc);var dTc,eTc;var b$=tfb(yEe,'HyperEdgeSegmentDependency/DependencyType',528,WI,iTc,hTc);var jTc;feb(1878,1,{},xTc);sfb(yEe,'HyperEdgeSegmentSplitter',1878);feb(1879,1,{},ATc);_.a=0;_.b=0;sfb(yEe,'HyperEdgeSegmentSplitter/AreaRating',1879);feb(339,1,{339:1},BTc);_.a=0;_.b=0;_.c=0;sfb(yEe,'HyperEdgeSegmentSplitter/FreeArea',339);feb(1880,1,fye,CTc);_.Ne=function DTc(a,b){return zTc(RD(a,118),RD(b,118))};_.Fb=function ETc(a){return this===a};_.Oe=function FTc(){return new Frb(this)};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$0$Type',1880);feb(1881,1,Qve,GTc);_.Cd=function HTc(a){rTc(this.a,this.d,this.c,this.b,RD(a,118));};_.b=0;sfb(yEe,'HyperEdgeSegmentSplitter/lambda$1$Type',1881);feb(1882,1,{},ITc);_.Kb=function JTc(a){return new SDb(null,new Swb(RD(a,118).e,16))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$2$Type',1882);feb(1883,1,{},KTc);_.Kb=function LTc(a){return new SDb(null,new Swb(RD(a,118).j,16))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$3$Type',1883);feb(1884,1,{},MTc);_.Ye=function NTc(a){return Kfb(UD(a))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$4$Type',1884);feb(664,1,{},TTc);_.a=0;_.b=0;_.c=0;sfb(yEe,'OrthogonalRoutingGenerator',664);feb(1703,1,{},XTc);_.Kb=function YTc(a){return new SDb(null,new Swb(RD(a,118).e,16))};sfb(yEe,'OrthogonalRoutingGenerator/lambda$0$Type',1703);feb(1704,1,{},ZTc);_.Kb=function $Tc(a){return new SDb(null,new Swb(RD(a,118).j,16))};sfb(yEe,'OrthogonalRoutingGenerator/lambda$1$Type',1704);feb(670,1,{});sfb(zEe,'BaseRoutingDirectionStrategy',670);feb(1870,670,{},cUc);_.yg=function dUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b+a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(l,f);Mub(g.a,d);_Tc(this,g,e,d,false);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);f=b+m.o*c;e=m;d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);}d=new rjd(p,f);Mub(g.a,d);_Tc(this,g,e,d,false);}}}}};_.zg=function eUc(a){return a.i.n.a+a.n.a+a.a.a};_.Ag=function fUc(){return qpd(),npd};_.Bg=function gUc(){return qpd(),Yod};sfb(zEe,'NorthToSouthRoutingStrategy',1870);feb(1871,670,{},hUc);_.yg=function iUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b-a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(l,f);Mub(g.a,d);_Tc(this,g,e,d,false);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);f=b-m.o*c;e=m;d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);}d=new rjd(p,f);Mub(g.a,d);_Tc(this,g,e,d,false);}}}}};_.zg=function jUc(a){return a.i.n.a+a.n.a+a.a.a};_.Ag=function kUc(){return qpd(),Yod};_.Bg=function lUc(){return qpd(),npd};sfb(zEe,'SouthToNorthRoutingStrategy',1871);feb(1869,670,{},mUc);_.yg=function nUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b+a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(f,l);Mub(g.a,d);_Tc(this,g,e,d,true);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(f,n);Mub(g.a,d);_Tc(this,g,e,d,true);f=b+m.o*c;e=m;d=new rjd(f,n);Mub(g.a,d);_Tc(this,g,e,d,true);}d=new rjd(f,p);Mub(g.a,d);_Tc(this,g,e,d,true);}}}}};_.zg=function oUc(a){return a.i.n.b+a.n.b+a.a.b};_.Ag=function pUc(){return qpd(),Xod};_.Bg=function qUc(){return qpd(),ppd};sfb(zEe,'WestToEastRoutingStrategy',1869);feb(828,1,{},wUc);_.Ib=function xUc(){return Fe(this.a)};_.b=0;_.c=false;_.d=false;_.f=0;sfb(BEe,'NubSpline',828);feb(418,1,{418:1},AUc,BUc);sfb(BEe,'NubSpline/PolarCP',418);feb(1480,1,nEe,VUc);_.rg=function XUc(a){return QUc(RD(a,36))};_.Kf=function YUc(a,b){UUc(this,RD(a,36),b);};var CUc,DUc,EUc,FUc,GUc;sfb(BEe,'SplineEdgeRouter',1480);feb(274,1,{274:1},_Uc);_.Ib=function aVc(){return this.a+' ->('+this.c+') '+this.b};_.c=0;sfb(BEe,'SplineEdgeRouter/Dependency',274);feb(465,22,{3:1,34:1,22:1,465:1},eVc);var bVc,cVc;var w$=tfb(BEe,'SplineEdgeRouter/SideToProcess',465,WI,gVc,fVc);var hVc;feb(1481,1,nwe,jVc);_.Mb=function kVc(a){return HUc(),!RD(a,131).o};sfb(BEe,'SplineEdgeRouter/lambda$0$Type',1481);feb(1482,1,{},lVc);_.Ze=function mVc(a){return HUc(),RD(a,131).v+1};sfb(BEe,'SplineEdgeRouter/lambda$1$Type',1482);feb(1483,1,Qve,nVc);_.Cd=function oVc(a){SUc(this.a,this.b,RD(a,42));};sfb(BEe,'SplineEdgeRouter/lambda$2$Type',1483);feb(1484,1,Qve,pVc);_.Cd=function qVc(a){TUc(this.a,this.b,RD(a,42));};sfb(BEe,'SplineEdgeRouter/lambda$3$Type',1484);feb(131,1,{34:1,131:1},wVc,xVc);_.Fd=function yVc(a){return uVc(this,RD(a,131))};_.b=0;_.e=false;_.f=0;_.g=0;_.j=false;_.k=false;_.n=0;_.o=false;_.p=false;_.q=false;_.s=0;_.u=0;_.v=0;_.F=0;sfb(BEe,'SplineSegment',131);feb(468,1,{468:1},zVc);_.a=0;_.b=false;_.c=false;_.d=false;_.e=false;_.f=0;sfb(BEe,'SplineSegment/EdgeInformation',468);feb(1198,1,{},IVc);sfb(GEe,Lze,1198);feb(1199,1,fye,KVc);_.Ne=function LVc(a,b){return JVc(RD(a,121),RD(b,121))};_.Fb=function MVc(a){return this===a};_.Oe=function NVc(){return new Frb(this)};sfb(GEe,Mze,1199);feb(1197,1,{},TVc);sfb(GEe,'MrTree',1197);feb(405,22,{3:1,34:1,22:1,405:1,188:1,196:1},$Vc);_.dg=function aWc(){return ZVc(this)};_.qg=function _Vc(){return ZVc(this)};var UVc,VVc,WVc,XVc;var H$=tfb(GEe,'TreeLayoutPhases',405,WI,cWc,bWc);var dWc;feb(1112,205,oze,fWc);_.rf=function gWc(a,b){var c,d,e,f,g,h,i,j;Heb(TD(Gxd(a,(h_c(),S$c))))||RFb((c=new SFb((lud(),new zud(a))),c));g=b.eh(HEe);g.Ug('build tGraph',1);h=(i=new YWc,kQb(i,a),pQb(i,(q$c(),h$c),a),j=new Tsb,QVc(a,i,j),PVc(a,i,j),i);g.Vg();g=b.eh(HEe);g.Ug('Split graph',1);f=HVc(this.a,h);g.Vg();for(e=new Anb(f);e.a'+aXc(this.c):'e_'+tb(this)};sfb(JEe,'TEdge',65);feb(121,137,{3:1,121:1,96:1,137:1},YWc);_.Ib=function ZWc(){var a,b,c,d,e;e=null;for(d=Sub(this.b,0);d.b!=d.d.c;){c=RD(evb(d),40);e+=(c.c==null||c.c.length==0?'n_'+c.g:'n_'+c.c)+'\n';}for(b=Sub(this.a,0);b.b!=b.d.c;){a=RD(evb(b),65);e+=(!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))+'\n';}return e};var W$=sfb(JEe,'TGraph',121);feb(643,508,{3:1,508:1,643:1,96:1,137:1});sfb(JEe,'TShape',643);feb(40,643,{3:1,508:1,40:1,643:1,96:1,137:1},bXc);_.Ib=function cXc(){return aXc(this)};var Z$=sfb(JEe,'TNode',40);feb(236,1,Vve,dXc);_.Jc=function eXc(a){xgb(this,a);};_.Kc=function fXc(){var a;return a=Sub(this.a.d,0),new gXc(a)};sfb(JEe,'TNode/2',236);feb(329,1,Ave,gXc);_.Nb=function hXc(a){Ztb(this,a);};_.Pb=function jXc(){return RD(evb(this.a),65).c};_.Ob=function iXc(){return dvb(this.a)};_.Qb=function kXc(){gvb(this.a);};sfb(JEe,'TNode/2/1',329);feb(1923,1,QAe,qXc);_.Kf=function DXc(a,b){oXc(this,RD(a,121),b);};sfb(LEe,'CompactionProcessor',1923);feb(1924,1,fye,EXc);_.Ne=function FXc(a,b){return rXc(this.a,RD(a,40),RD(b,40))};_.Fb=function GXc(a){return this===a};_.Oe=function HXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$0$Type',1924);feb(1925,1,nwe,IXc);_.Mb=function JXc(a){return sXc(this.b,this.a,RD(a,42))};_.a=0;_.b=0;sfb(LEe,'CompactionProcessor/lambda$1$Type',1925);feb(1934,1,fye,KXc);_.Ne=function LXc(a,b){return tXc(RD(a,40),RD(b,40))};_.Fb=function MXc(a){return this===a};_.Oe=function NXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$10$Type',1934);feb(1935,1,fye,OXc);_.Ne=function PXc(a,b){return uXc(RD(a,40),RD(b,40))};_.Fb=function QXc(a){return this===a};_.Oe=function RXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$11$Type',1935);feb(1936,1,fye,SXc);_.Ne=function TXc(a,b){return vXc(RD(a,40),RD(b,40))};_.Fb=function UXc(a){return this===a};_.Oe=function VXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$12$Type',1936);feb(1926,1,nwe,WXc);_.Mb=function XXc(a){return wXc(this.a,RD(a,42))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$2$Type',1926);feb(1927,1,nwe,YXc);_.Mb=function ZXc(a){return xXc(this.a,RD(a,42))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$3$Type',1927);feb(1928,1,nwe,$Xc);_.Mb=function _Xc(a){return RD(a,40).c.indexOf(IEe)==-1};sfb(LEe,'CompactionProcessor/lambda$4$Type',1928);feb(1929,1,{},aYc);_.Kb=function bYc(a){return yXc(this.a,RD(a,40))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$5$Type',1929);feb(1930,1,{},cYc);_.Kb=function dYc(a){return zXc(this.a,RD(a,40))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$6$Type',1930);feb(1931,1,fye,eYc);_.Ne=function fYc(a,b){return AXc(this.a,RD(a,240),RD(b,240))};_.Fb=function gYc(a){return this===a};_.Oe=function hYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$7$Type',1931);feb(1932,1,fye,iYc);_.Ne=function jYc(a,b){return BXc(this.a,RD(a,40),RD(b,40))};_.Fb=function kYc(a){return this===a};_.Oe=function lYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$8$Type',1932);feb(1933,1,fye,mYc);_.Ne=function nYc(a,b){return CXc(RD(a,40),RD(b,40))};_.Fb=function oYc(a){return this===a};_.Oe=function pYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$9$Type',1933);feb(1921,1,QAe,rYc);_.Kf=function sYc(a,b){qYc(RD(a,121),b);};sfb(LEe,'DirectionProcessor',1921);feb(1913,1,QAe,vYc);_.Kf=function xYc(a,b){uYc(this,RD(a,121),b);};sfb(LEe,'FanProcessor',1913);feb(1937,1,QAe,zYc);_.Kf=function CYc(a,b){yYc(RD(a,121),b);};sfb(LEe,'GraphBoundsProcessor',1937);feb(1938,1,{},DYc);_.Ye=function EYc(a){return RD(a,40).e.a};sfb(LEe,'GraphBoundsProcessor/lambda$0$Type',1938);feb(1939,1,{},FYc);_.Ye=function GYc(a){return RD(a,40).e.b};sfb(LEe,'GraphBoundsProcessor/lambda$1$Type',1939);feb(1940,1,{},HYc);_.Ye=function IYc(a){return AYc(RD(a,40))};sfb(LEe,'GraphBoundsProcessor/lambda$2$Type',1940);feb(1941,1,{},JYc);_.Ye=function KYc(a){return BYc(RD(a,40))};sfb(LEe,'GraphBoundsProcessor/lambda$3$Type',1941);feb(262,22,{3:1,34:1,22:1,262:1,196:1},XYc);_.dg=function YYc(){switch(this.g){case 0:return new DZc;case 1:return new vYc;case 2:return new nZc;case 3:return new tZc;case 4:return new gZc;case 8:return new cZc;case 5:return new rYc;case 6:return new AZc;case 7:return new qXc;case 9:return new zYc;case 10:return new GZc;default:throw Adb(new agb(lBe+(this.f!=null?this.f:''+this.g)));}};var LYc,MYc,NYc,OYc,PYc,QYc,RYc,SYc,TYc,UYc,VYc;var u_=tfb(LEe,mBe,262,WI,$Yc,ZYc);var _Yc;feb(1920,1,QAe,cZc);_.Kf=function dZc(a,b){bZc(RD(a,121),b);};sfb(LEe,'LevelCoordinatesProcessor',1920);feb(1918,1,QAe,gZc);_.Kf=function hZc(a,b){eZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'LevelHeightProcessor',1918);feb(1919,1,Vve,iZc);_.Jc=function jZc(a){xgb(this,a);};_.Kc=function kZc(){return yob(),Qob(),Pob};sfb(LEe,'LevelHeightProcessor/1',1919);feb(1914,1,QAe,nZc);_.Kf=function oZc(a,b){lZc(this,RD(a,121),b);};sfb(LEe,'LevelProcessor',1914);feb(1915,1,nwe,pZc);_.Mb=function qZc(a){return Heb(TD(mQb(RD(a,40),(q$c(),n$c))))};sfb(LEe,'LevelProcessor/lambda$0$Type',1915);feb(1916,1,QAe,tZc);_.Kf=function uZc(a,b){rZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'NeighborsProcessor',1916);feb(1917,1,Vve,vZc);_.Jc=function wZc(a){xgb(this,a);};_.Kc=function xZc(){return yob(),Qob(),Pob};sfb(LEe,'NeighborsProcessor/1',1917);feb(1922,1,QAe,AZc);_.Kf=function BZc(a,b){yZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'NodePositionProcessor',1922);feb(1912,1,QAe,DZc);_.Kf=function EZc(a,b){CZc(this,RD(a,121),b);};sfb(LEe,'RootProcessor',1912);feb(1942,1,QAe,GZc);_.Kf=function HZc(a,b){FZc(RD(a,121),b);};sfb(LEe,'Untreeifyer',1942);feb(392,22,{3:1,34:1,22:1,392:1},MZc);var IZc,JZc,KZc;var F_=tfb(PEe,'EdgeRoutingMode',392,WI,OZc,NZc);var PZc;var RZc,SZc,TZc,UZc,VZc,WZc,XZc,YZc,ZZc,$Zc,_Zc,a$c,b$c,c$c,d$c,e$c,f$c,g$c,h$c,i$c,j$c,k$c,l$c,m$c,n$c,o$c,p$c;feb(862,1,Eye,C$c);_.hf=function D$c(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,REe),''),YEe),'Turns on Tree compaction which decreases the size of the whole tree by placing nodes of multiple levels in one large level'),(Geb(),false)),(kid(),cid)),QI),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SEe),''),'Edge End Texture Length'),'Should be set to the length of the texture at the end of an edge. This value can be used to improve the Edge Routing.'),7),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TEe),''),'Tree Level'),'The index for the tree level the node is in'),sgb(0)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UEe),''),YEe),'When set to a positive number this option will force the algorithm to place the node to the specified position within the trees layer if weighting is set to constraint'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VEe),''),'Weighting of Nodes'),'Which weighting to use when computing a node order.'),A$c),eid),J_),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WEe),''),'Edge Routing Mode'),'Chooses an Edge Routing algorithm.'),u$c),eid),F_),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XEe),''),'Search Order'),'Which search order to use when computing a spanning tree.'),x$c),eid),K_),xsb(Whd))));i_c((new j_c,a));};var r$c,s$c,t$c,u$c,v$c,w$c,x$c,y$c,z$c,A$c;sfb(PEe,'MrTreeMetaDataProvider',862);feb(1006,1,Eye,j_c);_.hf=function k_c(a){i_c(a);};var E$c,F$c,G$c,H$c,I$c,J$c,K$c,L$c,M$c,N$c,O$c,P$c,Q$c,R$c,S$c,T$c,U$c,V$c,W$c,X$c,Y$c,Z$c,$$c,_$c,a_c,b_c,c_c,d_c,e_c,f_c,g_c;sfb(PEe,'MrTreeOptions',1006);feb(1007,1,{},l_c);_.sf=function m_c(){var a;return a=new fWc,a};_.tf=function n_c(a){};sfb(PEe,'MrTreeOptions/MrtreeFactory',1007);feb(353,22,{3:1,34:1,22:1,353:1},t_c);var o_c,p_c,q_c,r_c;var J_=tfb(PEe,'OrderWeighting',353,WI,v_c,u_c);var w_c;feb(433,22,{3:1,34:1,22:1,433:1},B_c);var y_c,z_c;var K_=tfb(PEe,'TreeifyingOrder',433,WI,D_c,C_c);var E_c;feb(1486,1,nEe,N_c);_.rg=function O_c(a){return RD(a,121),G_c};_.Kf=function P_c(a,b){M_c(this,RD(a,121),b);};var G_c;sfb('org.eclipse.elk.alg.mrtree.p1treeify','DFSTreeifyer',1486);feb(1487,1,nEe,V_c);_.rg=function W_c(a){return RD(a,121),Q_c};_.Kf=function $_c(a,b){U_c(this,RD(a,121),b);};var Q_c;sfb(aFe,'NodeOrderer',1487);feb(1494,1,{},a0c);_.td=function b0c(a){return __c(a)};sfb(aFe,'NodeOrderer/0methodref$lambda$6$Type',1494);feb(1488,1,nwe,c0c);_.Mb=function d0c(a){return R_c(),Heb(TD(mQb(RD(a,40),(q$c(),n$c))))};sfb(aFe,'NodeOrderer/lambda$0$Type',1488);feb(1489,1,nwe,e0c);_.Mb=function f0c(a){return R_c(),RD(mQb(RD(a,40),(h_c(),W$c)),17).a<0};sfb(aFe,'NodeOrderer/lambda$1$Type',1489);feb(1490,1,nwe,g0c);_.Mb=function h0c(a){return X_c(this.a,RD(a,40))};sfb(aFe,'NodeOrderer/lambda$2$Type',1490);feb(1491,1,nwe,i0c);_.Mb=function j0c(a){return Y_c(this.a,RD(a,40))};sfb(aFe,'NodeOrderer/lambda$3$Type',1491);feb(1492,1,fye,k0c);_.Ne=function l0c(a,b){return Z_c(RD(a,40),RD(b,40))};_.Fb=function m0c(a){return this===a};_.Oe=function n0c(){return new Frb(this)};sfb(aFe,'NodeOrderer/lambda$4$Type',1492);feb(1493,1,nwe,o0c);_.Mb=function p0c(a){return R_c(),RD(mQb(RD(a,40),(q$c(),XZc)),17).a!=0};sfb(aFe,'NodeOrderer/lambda$5$Type',1493);feb(1495,1,nEe,x0c);_.rg=function y0c(a){return RD(a,121),q0c};_.Kf=function z0c(a,b){v0c(this,RD(a,121),b);};_.b=0;var q0c;sfb('org.eclipse.elk.alg.mrtree.p3place','NodePlacer',1495);feb(1496,1,nEe,J0c);_.rg=function K0c(a){return RD(a,121),A0c};_.Kf=function Y0c(a,b){I0c(RD(a,121),b);};var A0c;var o0=sfb(bFe,'EdgeRouter',1496);feb(1498,1,fye,Z0c);_.Ne=function $0c(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function _0c(a){return this===a};_.Oe=function a1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/0methodref$compare$Type',1498);feb(1503,1,{},b1c);_.Ye=function c1c(a){return Kfb(UD(a))};sfb(bFe,'EdgeRouter/1methodref$doubleValue$Type',1503);feb(1505,1,fye,d1c);_.Ne=function e1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function f1c(a){return this===a};_.Oe=function g1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/2methodref$compare$Type',1505);feb(1507,1,fye,h1c);_.Ne=function i1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function j1c(a){return this===a};_.Oe=function k1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/3methodref$compare$Type',1507);feb(1509,1,{},l1c);_.Ye=function m1c(a){return Kfb(UD(a))};sfb(bFe,'EdgeRouter/4methodref$doubleValue$Type',1509);feb(1511,1,fye,n1c);_.Ne=function o1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function p1c(a){return this===a};_.Oe=function q1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/5methodref$compare$Type',1511);feb(1513,1,fye,r1c);_.Ne=function s1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function t1c(a){return this===a};_.Oe=function u1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/6methodref$compare$Type',1513);feb(1497,1,{},v1c);_.Kb=function w1c(a){return B0c(),RD(mQb(RD(a,40),(h_c(),f_c)),17)};sfb(bFe,'EdgeRouter/lambda$0$Type',1497);feb(1508,1,{},x1c);_.Kb=function y1c(a){return L0c(RD(a,40))};sfb(bFe,'EdgeRouter/lambda$11$Type',1508);feb(1510,1,{},z1c);_.Kb=function A1c(a){return M0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$13$Type',1510);feb(1512,1,{},B1c);_.Kb=function C1c(a){return N0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$15$Type',1512);feb(1514,1,fye,D1c);_.Ne=function E1c(a,b){return O0c(RD(a,65),RD(b,65))};_.Fb=function F1c(a){return this===a};_.Oe=function G1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$17$Type',1514);feb(1515,1,fye,H1c);_.Ne=function I1c(a,b){return P0c(RD(a,65),RD(b,65))};_.Fb=function J1c(a){return this===a};_.Oe=function K1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$18$Type',1515);feb(1516,1,fye,L1c);_.Ne=function M1c(a,b){return Q0c(RD(a,65),RD(b,65))};_.Fb=function N1c(a){return this===a};_.Oe=function O1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$19$Type',1516);feb(1499,1,nwe,P1c);_.Mb=function Q1c(a){return R0c(this.a,RD(a,40))};_.a=0;sfb(bFe,'EdgeRouter/lambda$2$Type',1499);feb(1517,1,fye,R1c);_.Ne=function S1c(a,b){return S0c(RD(a,65),RD(b,65))};_.Fb=function T1c(a){return this===a};_.Oe=function U1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$20$Type',1517);feb(1500,1,fye,V1c);_.Ne=function W1c(a,b){return T0c(RD(a,40),RD(b,40))};_.Fb=function X1c(a){return this===a};_.Oe=function Y1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$3$Type',1500);feb(1501,1,fye,Z1c);_.Ne=function $1c(a,b){return U0c(RD(a,40),RD(b,40))};_.Fb=function _1c(a){return this===a};_.Oe=function a2c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$4$Type',1501);feb(1502,1,{},b2c);_.Kb=function c2c(a){return V0c(RD(a,40))};sfb(bFe,'EdgeRouter/lambda$5$Type',1502);feb(1504,1,{},d2c);_.Kb=function e2c(a){return W0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$7$Type',1504);feb(1506,1,{},f2c);_.Kb=function g2c(a){return X0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$9$Type',1506);feb(675,1,{675:1},i2c);_.e=0;_.f=false;_.g=false;sfb(bFe,'MultiLevelEdgeNodeNodeGap',675);feb(1943,1,fye,l2c);_.Ne=function m2c(a,b){return j2c(RD(a,240),RD(b,240))};_.Fb=function n2c(a){return this===a};_.Oe=function o2c(){return new Frb(this)};sfb(bFe,'MultiLevelEdgeNodeNodeGap/lambda$0$Type',1943);feb(1944,1,fye,p2c);_.Ne=function q2c(a,b){return k2c(RD(a,240),RD(b,240))};_.Fb=function r2c(a){return this===a};_.Oe=function s2c(){return new Frb(this)};sfb(bFe,'MultiLevelEdgeNodeNodeGap/lambda$1$Type',1944);var t2c;feb(501,22,{3:1,34:1,22:1,501:1,188:1,196:1},z2c);_.dg=function B2c(){return y2c(this)};_.qg=function A2c(){return y2c(this)};var v2c,w2c;var s0=tfb(cFe,'RadialLayoutPhases',501,WI,D2c,C2c);var E2c;feb(1113,205,oze,H2c);_.rf=function I2c(a,b){var c,d,e,f,g,h;c=G2c(this,a);b.Ug('Radial layout',c.c.length);Heb(TD(Gxd(a,($4c(),N4c))))||RFb((d=new SFb((lud(),new zud(a))),d));h=K2c(a);Ixd(a,(u2c(),t2c),h);if(!h){throw Adb(new agb('The given graph is not a tree!'))}e=Kfb(UD(Gxd(a,S4c)));e==0&&(e=J2c(a));Ixd(a,S4c,e);for(g=new Anb(G2c(this,a));g.a=3){v=RD(QHd(t,0),27);w=RD(QHd(t,1),27);f=0;while(f+2=v.f+w.f+k||w.f>=u.f+v.f+k){B=true;break}else {++f;}}}else {B=true;}if(!B){m=t.i;for(h=new dMd(t);h.e!=h.i.gc();){g=RD(bMd(h),27);Ixd(g,(umd(),Rld),sgb(m));--m;}crd(a,new Oqd);b.Vg();return}c=(Sed(this.a),Ved(this.a,(f6c(),c6c),RD(Gxd(a,V7c),188)),Ved(this.a,d6c,RD(Gxd(a,M7c),188)),Ved(this.a,e6c,RD(Gxd(a,S7c),188)),Ped(this.a,(D=new ufd,pfd(D,c6c,(z6c(),y6c)),pfd(D,d6c,x6c),Heb(TD(Gxd(a,B7c)))&&pfd(D,c6c,w6c),D)),Qed(this.a,a));j=1/c.c.length;for(o=new Anb(c);o.a0&&vjd((BFb(c-1,b.length),b.charCodeAt(c-1)),ZAe)){--c;}if(e>=c){throw Adb(new agb('The given string does not contain any numbers.'))}f=vhb((AFb(e,c,b.length),b.substr(e,c-e)),',|;|\r|\n');if(f.length!=2){throw Adb(new agb('Exactly two numbers are expected, '+f.length+' were found.'))}try{this.a=Neb(Dhb(f[0]));this.b=Neb(Dhb(f[1]));}catch(a){a=zdb(a);if(ZD(a,130)){d=a;throw Adb(new agb($Ae+d))}else throw Adb(a)}};_.Ib=function yjd(){return '('+this.a+','+this.b+')'};_.a=0;_.b=0;var l3=sfb(_Ae,'KVector',8);feb(75,67,{3:1,4:1,20:1,31:1,56:1,16:1,67:1,15:1,75:1,423:1},Ejd,Fjd,Gjd);_.Pc=function Jjd(){return Djd(this)};_.cg=function Hjd(b){var c,d,e,f,g,h;e=vhb(b,',|;|\\(|\\)|\\[|\\]|\\{|\\}| |\t|\n');Xub(this);try{d=0;g=0;f=0;h=0;while(d0){g%2==0?(f=Neb(e[d])):(h=Neb(e[d]));g>0&&g%2!=0&&Mub(this,new rjd(f,h));++g;}++d;}}catch(a){a=zdb(a);if(ZD(a,130)){c=a;throw Adb(new agb('The given string does not match the expected format for vectors.'+c))}else throw Adb(a)}};_.Ib=function Kjd(){var a,b,c;a=new dib('(');b=Sub(this,0);while(b.b!=b.d.c){c=RD(evb(b),8);Zhb(a,c.a+','+c.b);b.b!=b.d.c&&(a.a+='; ',a);}return (a.a+=')',a).a};var k3=sfb(_Ae,'KVectorChain',75);feb(255,22,{3:1,34:1,22:1,255:1},Sjd);var Ljd,Mjd,Njd,Ojd,Pjd,Qjd;var n3=tfb(JGe,'Alignment',255,WI,Ujd,Tjd);var Vjd;feb(991,1,Eye,jkd);_.hf=function kkd(a){ikd(a);};var Xjd,Yjd,Zjd,$jd,_jd,akd,bkd,ckd,dkd,ekd,fkd,gkd;sfb(JGe,'BoxLayouterOptions',991);feb(992,1,{},lkd);_.sf=function mkd(){var a;return a=new jrd,a};_.tf=function nkd(a){};sfb(JGe,'BoxLayouterOptions/BoxFactory',992);feb(298,22,{3:1,34:1,22:1,298:1},vkd);var okd,pkd,qkd,rkd,skd,tkd;var q3=tfb(JGe,'ContentAlignment',298,WI,xkd,wkd);var ykd;feb(699,1,Eye,vmd);_.hf=function wmd(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,OGe),''),'Layout Algorithm'),'Select a specific layout algorithm.'),(kid(),iid)),qJ),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,PGe),''),'Resolved Layout Algorithm'),'Meta data associated with the selected algorithm.'),hid),D2),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MDe),''),'Alignment'),'Alignment of the selected node relative to other nodes; the exact meaning depends on the used algorithm.'),Ckd),eid),n3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,Dze),''),'Aspect Ratio'),'The desired aspect ratio of the drawing, that is the quotient of width by height.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,QGe),''),'Bend Points'),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),hid),k3),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YDe),''),'Content Alignment'),'Specifies how the content of a node are aligned. Each node can individually control the alignment of its contents. I.e. if a node should be aligned top left in its parent node, the parent node should specify that option.'),Lkd),fid),q3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LDe),''),'Debug Mode'),'Whether additional debug information shall be generated.'),(Geb(),false)),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PDe),''),eze),'Overall direction of edges: horizontal (right / left) or vertical (down / up).'),Okd),eid),s3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kDe),''),'Edge Routing'),'What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline.'),Tkd),eid),u3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MGe),''),'Expand Nodes'),'If active, nodes are expanded to fill the area of their parent.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fDe),''),'Hierarchy Handling'),"Determines whether separate layout runs are triggered for different compound nodes in a hierarchical graph. Setting a node's hierarchy handling to `INCLUDE_CHILDREN` will lay out that node and all of its descendants in a single layout run, until a descendant is encountered which has its hierarchy handling set to `SEPARATE_CHILDREN`. In general, `SEPARATE_CHILDREN` will ensure that a new layout run is triggered for a node with that setting. Including multiple levels of hierarchy in a single layout run may allow cross-hierarchical edges to be laid out properly. If the root node is set to `INHERIT` (or not set at all), the default behavior is `SEPARATE_CHILDREN`."),Ykd),eid),y3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Eze),''),'Padding'),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),uld),hid),i3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dAe),''),'Interactive'),'Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iEe),''),'interactive Layout'),'Whether the graph should be changeable interactively and by setting constraints'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gAe),''),'Omit Node Micro Layout'),"Node micro layout comprises the computation of node dimensions (if requested), the placement of ports and their labels, and the placement of node labels. The functionality is implemented independent of any specific layout algorithm and shouldn't have any negative impact on the layout algorithm's performance itself. Yet, if any unforeseen behavior occurs, this option allows to deactivate the micro layout."),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eAe),''),'Port Constraints'),'Defines constraints of the position of the ports of a node.'),Ild),eid),C3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,fEe),''),'Position'),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),hid),l3),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,$ze),''),'Priority'),'Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used.'),gid),bJ),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,bAe),''),'Randomization Seed'),'Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time).'),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cAe),''),'Separate Connected Components'),'Whether each connected component should be processed separately.'),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZDe),''),'Junction Points'),'This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order.'),dld),hid),k3),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aEe),''),'Comment Box'),'Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bEe),''),'Hypernode'),'Whether the node should be handled as a hypernode.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,RGe),''),'Label Manager'),"Label managers can shorten labels upon a layout algorithm's request."),hid),g3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gEe),''),'Margins'),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),fld),hid),h3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JDe),''),'No Layout'),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),false),cid),QI),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd,Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SGe),''),'Scale Factor'),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),did),VI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,TGe),''),'Child Area Width'),'The width of the area occupied by the laid out children of a node.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,UGe),''),'Child Area Height'),'The height of the area occupied by the laid out children of a node.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,mAe),''),yGe),"Turns topdown layout on and off. If this option is enabled, hierarchical layout will be computed first for the root node and then for its children recursively. Layouts are then scaled down to fit the area provided by their parents. Graphs must follow a certain structure for topdown layout to work properly. {@link TopdownNodeTypes.PARALLEL_NODE} nodes must have children of type {@link TopdownNodeTypes.HIERARCHICAL_NODE} and must define {@link topdown.hierarchicalNodeWidth} and {@link topdown.hierarchicalNodeAspectRatio} for their children. Furthermore they need to be laid out using an algorithm that is a {@link TopdownLayoutProvider}. Hierarchical nodes can also be parents of other hierarchical nodes and can optionally use a {@link TopdownSizeApproximator} to dynamically set sizes during topdown layout. In this case {@link topdown.hierarchicalNodeWidth} and {@link topdown.hierarchicalNodeAspectRatio} should be set on the node itself rather than the parent. The values are then used by the size approximator as base values. Hierarchical nodes require the layout option {@link nodeSize.fixedGraphSize} to be true to prevent the algorithm used there from resizing the hierarchical node. This option is not supported if 'Hierarchy Handling' is set to 'INCLUDE_CHILDREN'"),false),cid),QI),xsb(Whd))));zgd(a,mAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VGe),''),'Animate'),'Whether the shift from the old layout to the new computed layout shall be animated.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WGe),''),'Animation Time Factor'),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),sgb(100)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XGe),''),'Layout Ancestors'),'Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YGe),''),'Maximal Animation Time'),'The maximal time for animations, in milliseconds.'),sgb(4000)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZGe),''),'Minimal Animation Time'),'The minimal time for animations, in milliseconds.'),sgb(400)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Ge),''),'Progress Bar'),'Whether a progress bar shall be displayed during layout computations.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Ge),''),'Validate Graph'),'Whether the graph shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aHe),''),'Validate Options'),'Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bHe),''),'Zoom to Fit'),'Whether the zoom level shall be set to view the whole diagram after layout.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NGe),'box'),'Box Layout Mode'),'Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better.'),Gkd),eid),R3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xDe),lDe),'Comment Comment Spacing'),'Spacing to be preserved between a comment box and other comment boxes connected to the same node. The space left between comment boxes of different nodes is controlled by the node-node spacing.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yDe),lDe),'Comment Node Spacing'),'Spacing to be preserved between a node and its connected comment boxes. The space left between a node and the comments of another node is controlled by the node-node spacing.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Bze),lDe),'Components Spacing'),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zDe),lDe),'Edge Spacing'),'Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aAe),lDe),'Edge Label Spacing'),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ADe),lDe),'Edge Node Spacing'),'Spacing to be preserved between nodes and edges.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,BDe),lDe),'Label Spacing'),'Determines the amount of space to be left between two labels of the same graph element.'),0),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,EDe),lDe),'Label Node Spacing'),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CDe),lDe),'Horizontal spacing between Label and Port'),"Horizontal spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,DDe),lDe),'Vertical spacing between Label and Port'),"Vertical spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_ze),lDe),'Node Spacing'),'The minimal distance to be preserved between each two nodes.'),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,FDe),lDe),'Node Self Loop Spacing'),'Spacing to be preserved between a node and its self loops.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,GDe),lDe),'Port Spacing'),'Spacing between pairs of ports of the same node.'),10),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,HDe),lDe),'Individual Spacing'),"Allows to specify individual spacing values for graph elements that shall be different from the value specified for the element's parent."),hid),l4),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd,Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hEe),lDe),'Additional Port Space'),'Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border.'),imd),hid),h3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,eEe),hHe),'Layout Partition'),'Partition to which the node belongs. This requires Layout Partitioning to be active. Nodes with lower partition IDs will appear to the left of nodes with higher partition IDs (assuming a left-to-right layout direction).'),gid),bJ),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,eEe,dEe,yld);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dEe),hHe),'Layout Partitioning'),'Whether to activate partitioned layout. This will allow to group nodes through the Layout Partition option. a pair of nodes with different partition indices is then placed such that the node with lower index is placed to the left of the other node (with left-to-right layout direction). Depending on the layout algorithm, this may only be guaranteed to work if all nodes have a layout partition configured, or at least if edges that cross partitions are not part of a partition-crossing cycle.'),wld),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,QDe),iHe),'Node Label Padding'),'Define padding for node labels that are placed inside of a node.'),hld),hid),i3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kAe),iHe),'Node Label Placement'),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),jld),fid),A3),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TDe),jHe),'Port Alignment'),'Defines the default port distribution for a node. May be overridden for each side individually.'),Ald),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,UDe),jHe),'Port Alignment (North)'),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,VDe),jHe),'Port Alignment (South)'),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,WDe),jHe),'Port Alignment (West)'),"Defines how ports on the western side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,XDe),jHe),'Port Alignment (East)'),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,jAe),kHe),'Node Size Constraints'),"What should be taken into account when calculating a node's size. Empty size constraints specify that a node's size is already fixed and should not be changed."),lld),fid),H3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iAe),kHe),'Node Size Options'),'Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications.'),qld),fid),I3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CAe),kHe),'Node Size Minimum'),'The minimal size to which a node can be reduced.'),old),hid),l3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hAe),kHe),'Fixed Graph Size'),"By default, the fixed layout provider will enlarge a graph until it is large enough to contain its children. If this option is set, it won't do so."),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$De),vDe),'Edge Label Placement'),'Gives a hint on where to put edge labels.'),Rkd),eid),t3),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fAe),vDe),'Inline Edge Labels'),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),false),cid),QI),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cHe),'font'),'Font Name'),'Font name used for a label.'),iid),qJ),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,dHe),'font'),'Font Size'),'Font size used for a label.'),gid),bJ),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cEe),lHe),'Port Anchor Offset'),'The offset to the port position where connections shall be attached.'),hid),l3),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,_De),lHe),'Port Index'),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),gid),bJ),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KDe),lHe),'Port Side'),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),Pld),eid),E3),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,IDe),lHe),'Port Border Offset'),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),did),VI),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,lAe),mHe),'Port Label Placement'),"Decides on a placement method for port labels; if empty, the node label's position is not modified."),Mld),fid),D3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RDe),mHe),'Port Labels Next to Port'),"Use 'portLabels.placement': NEXT_TO_PORT_OF_POSSIBLE."),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SDe),mHe),'Treat Port Labels as Group'),'If this option is true (default), the labels of a port will be treated as a group when it comes to centering them next to their port. If this option is false, only the first label will be centered next to the port, with the others being placed below. This only applies to labels of eastern and western ports and will have no effect if labels are not placed next to their port.'),true),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,nAe),nHe),'Topdown Scale Factor'),"The scaling factor to be applied to the nodes laid out within the node in recursive topdown layout. The difference to 'Scale Factor' is that the node itself is not scaled. This value has to be set on hierarchical nodes."),1),did),VI),xsb(Whd))));zgd(a,nAe,qAe,rmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eHe),nHe),'Topdown Size Approximator'),'The size approximator to be used to set sizes of hierarchical nodes during topdown layout. The default value is null, which results in nodes keeping whatever size is defined for them e.g. through parent parallel node or by manually setting the size.'),null),eid),M3),xsb(Vhd))));zgd(a,eHe,qAe,tmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,oAe),nHe),'Topdown Hierarchical Node Width'),'The fixed size of a hierarchical node when using topdown layout. If this value is set on a parallel node it applies to its children, when set on a hierarchical node it applies to the node itself.'),150),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,oAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,pAe),nHe),'Topdown Hierarchical Node Aspect Ratio'),'The fixed aspect ratio of a hierarchical node when using topdown layout. Default is 1/sqrt(2). If this value is set on a parallel node it applies to its children, when set on a hierarchical node it applies to the node itself.'),1.414),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,pAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,qAe),nHe),'Topdown Node Type'),'The different node types used for topdown layout. If the node type is set to {@link TopdownNodeTypes.PARALLEL_NODE} the algorithm must be set to a {@link TopdownLayoutProvider} such as {@link TopdownPacking}. The {@link nodeSize.fixedGraphSize} option is technically only required for hierarchical nodes.'),null),eid),J3),xsb(Vhd))));zgd(a,qAe,hAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fHe),nHe),'Topdown Scale Cap'),'Determines the upper limit for the topdown scale factor. The default value is 1.0 which ensures that nested children never end up appearing larger than their parents in terms of unit sizes such as the font size. If the limit is larger, nodes will fully utilize the available space, but it is counteriniuitive for inner nodes to have a larger scale than outer nodes.'),1),did),VI),xsb(Whd))));zgd(a,fHe,qAe,pmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NDe),oHe),'Activate Inside Self Loops'),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ODe),oHe),'Inside Self Loop'),'Whether a self loop should be routed inside a node instead of around that node.'),false),cid),QI),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Cze),'edge'),'Edge Thickness'),'The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it.'),1),did),VI),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gHe),'edge'),'Edge Type'),'The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations.'),Vkd),eid),v3),xsb(Thd))));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,sxe),'Layered'),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.orthogonal'),'Orthogonal'),'Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia \'86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,Zze),'Force'),'Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.circle'),'Circle'),'Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,$Ee),'Tree'),'Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.planar'),'Planar'),'Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,CFe),'Radial'),'Radial layout algorithms usually position the nodes of the graph on concentric circles.')));wnd((new xnd,a));ikd((new jkd,a));Gpd((new Hpd,a));};var Akd,Bkd,Ckd,Dkd,Ekd,Fkd,Gkd,Hkd,Ikd,Jkd,Kkd,Lkd,Mkd,Nkd,Okd,Pkd,Qkd,Rkd,Skd,Tkd,Ukd,Vkd,Wkd,Xkd,Ykd,Zkd,$kd,_kd,ald,bld,cld,dld,eld,fld,gld,hld,ild,jld,kld,lld,mld,nld,old,pld,qld,rld,sld,tld,uld,vld,wld,xld,yld,zld,Ald,Bld,Cld,Dld,Eld,Fld,Gld,Hld,Ild,Jld,Kld,Lld,Mld,Nld,Old,Pld,Qld,Rld,Sld,Tld,Uld,Vld,Wld,Xld,Yld,Zld,$ld,_ld,amd,bmd,cmd,dmd,emd,fmd,gmd,hmd,imd,jmd,kmd,lmd,mmd,nmd,omd,pmd,qmd,rmd,smd,tmd;sfb(JGe,'CoreOptions',699);feb(88,22,{3:1,34:1,22:1,88:1},Gmd);var xmd,ymd,zmd,Amd,Bmd;var s3=tfb(JGe,eze,88,WI,Imd,Hmd);var Jmd;feb(278,22,{3:1,34:1,22:1,278:1},Pmd);var Lmd,Mmd,Nmd;var t3=tfb(JGe,'EdgeLabelPlacement',278,WI,Rmd,Qmd);var Smd;feb(223,22,{3:1,34:1,22:1,223:1},Zmd);var Umd,Vmd,Wmd,Xmd;var u3=tfb(JGe,'EdgeRouting',223,WI,_md,$md);var and;feb(321,22,{3:1,34:1,22:1,321:1},jnd);var cnd,dnd,end,fnd,gnd,hnd;var v3=tfb(JGe,'EdgeType',321,WI,lnd,knd);var mnd;feb(989,1,Eye,xnd);_.hf=function ynd(a){wnd(a);};var ond,pnd,qnd,rnd,snd,tnd,und;sfb(JGe,'FixedLayouterOptions',989);feb(990,1,{},znd);_.sf=function And(){var a;return a=new btd,a};_.tf=function Bnd(a){};sfb(JGe,'FixedLayouterOptions/FixedFactory',990);feb(346,22,{3:1,34:1,22:1,346:1},Gnd);var Cnd,Dnd,End;var y3=tfb(JGe,'HierarchyHandling',346,WI,Ind,Hnd);var Jnd;feb(291,22,{3:1,34:1,22:1,291:1},Rnd);var Lnd,Mnd,Nnd,Ond;var z3=tfb(JGe,'LabelSide',291,WI,Tnd,Snd);var Und;feb(95,22,{3:1,34:1,22:1,95:1},eod);var Wnd,Xnd,Ynd,Znd,$nd,_nd,aod,bod,cod;var A3=tfb(JGe,'NodeLabelPlacement',95,WI,hod,god);var iod;feb(256,22,{3:1,34:1,22:1,256:1},qod);var kod,lod,mod,nod,ood;var B3=tfb(JGe,'PortAlignment',256,WI,sod,rod);var tod;feb(101,22,{3:1,34:1,22:1,101:1},Eod);var vod,wod,xod,yod,zod,Aod;var C3=tfb(JGe,'PortConstraints',101,WI,God,Fod);var Hod;feb(279,22,{3:1,34:1,22:1,279:1},Qod);var Jod,Kod,Lod,Mod,Nod,Ood;var D3=tfb(JGe,'PortLabelPlacement',279,WI,Uod,Tod);var Vod;feb(64,22,{3:1,34:1,22:1,64:1},upd);var Xod,Yod,Zod,$od,_od,apd,bpd,cpd,dpd,epd,fpd,gpd,hpd,ipd,jpd,kpd,lpd,mpd,npd,opd,ppd;var E3=tfb(JGe,'PortSide',64,WI,xpd,wpd);var ypd;feb(993,1,Eye,Hpd);_.hf=function Ipd(a){Gpd(a);};var Apd,Bpd,Cpd,Dpd,Epd;sfb(JGe,'RandomLayouterOptions',993);feb(994,1,{},Jpd);_.sf=function Kpd(){var a;return a=new eud,a};_.tf=function Lpd(a){};sfb(JGe,'RandomLayouterOptions/RandomFactory',994);feb(386,22,{3:1,34:1,22:1,386:1},Rpd);var Mpd,Npd,Opd,Ppd;var H3=tfb(JGe,'SizeConstraint',386,WI,Tpd,Spd);var Upd;feb(264,22,{3:1,34:1,22:1,264:1},eqd);var Wpd,Xpd,Ypd,Zpd,$pd,_pd,aqd,bqd,cqd;var I3=tfb(JGe,'SizeOptions',264,WI,gqd,fqd);var hqd;feb(280,22,{3:1,34:1,22:1,280:1},nqd);var jqd,kqd,lqd;var J3=tfb(JGe,'TopdownNodeTypes',280,WI,pqd,oqd);var qqd;feb(347,22,rHe);var sqd,tqd;var M3=tfb(JGe,'TopdownSizeApproximator',347,WI,xqd,wqd);feb(987,347,rHe,zqd);_.Tg=function Aqd(a){return yqd(a)};tfb(JGe,'TopdownSizeApproximator/1',987,M3,null,null);feb(988,347,rHe,Bqd);_.Tg=function Cqd(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;c=RD(Gxd(b,(umd(),Tld)),143);A=(bvd(),o=new ACd,o);zxd(A,b);B=new Tsb;for(g=new dMd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));g.e!=g.i.gc();){e=RD(bMd(g),27);t=(n=new ACd,n);yCd(t,A);zxd(t,e);D=yqd(e);zyd(t,$wnd.Math.max(e.g,D.a),$wnd.Math.max(e.f,D.b));rtb(B.f,e,t);}for(f=new dMd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));f.e!=f.i.gc();){e=RD(bMd(f),27);for(l=new dMd((!e.e&&(e.e=new Yie(G4,e,7,4)),e.e));l.e!=l.i.gc();){k=RD(bMd(l),74);v=RD(Wd(qtb(B.f,e)),27);w=RD(Wjb(B,QHd((!k.c&&(k.c=new Yie(E4,k,5,8)),k.c),0)),27);u=(m=new rzd,m);WGd((!u.b&&(u.b=new Yie(E4,u,4,7)),u.b),v);WGd((!u.c&&(u.c=new Yie(E4,u,5,8)),u.c),w);pzd(u,vCd(v));zxd(u,k);}}q=RD(ltd(c.f),205);try{q.rf(A,new ztd);mtd(c.f,q);}catch(a){a=zdb(a);if(ZD(a,103)){p=a;throw Adb(p)}else throw Adb(a)}Hxd(A,Ikd)||Hxd(A,Hkd)||psd(A);j=Kfb(UD(Gxd(A,Ikd)));i=Kfb(UD(Gxd(A,Hkd)));h=j/i;d=Kfb(UD(Gxd(A,lmd)))*$wnd.Math.sqrt((!A.a&&(A.a=new C5d(J4,A,10,11)),A.a).i);C=RD(Gxd(A,tld),107);s=C.b+C.c+1;r=C.d+C.a+1;return new rjd($wnd.Math.max(s,d),$wnd.Math.max(r,d/h))};tfb(JGe,'TopdownSizeApproximator/2',988,M3,null,null);var Dqd;feb(344,1,{871:1},Oqd);_.Ug=function Pqd(a,b){return Fqd(this,a,b)};_.Vg=function Qqd(){Hqd(this);};_.Wg=function Rqd(){return this.q};_.Xg=function Sqd(){return !this.f?null:Hob(this.f)};_.Yg=function Tqd(){return Hob(this.a)};_.Zg=function Uqd(){return this.p};_.$g=function Vqd(){return false};_._g=function Wqd(){return this.n};_.ah=function Xqd(){return this.p!=null&&!this.b};_.bh=function Yqd(a){var b;if(this.n){b=a;Rmb(this.f,b);}};_.dh=function Zqd(a,b){var c,d;this.n&&!!a&&Jqd(this,(c=new Zje,d=Rje(c,a),Yje(c),d),(ttd(),qtd));};_.eh=function $qd(a){var b;if(this.b){return null}else {b=Gqd(this,this.g);Mub(this.a,b);b.i=this;this.d=a;return b}};_.fh=function _qd(a){a>0&&!this.b&&Iqd(this,a);};_.b=false;_.c=0;_.d=-1;_.e=null;_.f=null;_.g=-1;_.j=false;_.k=false;_.n=false;_.o=0;_.q=0;_.r=0;sfb(jEe,'BasicProgressMonitor',344);feb(717,205,oze,jrd);_.rf=function nrd(a,b){crd(a,b);};sfb(jEe,'BoxLayoutProvider',717);feb(983,1,fye,prd);_.Ne=function qrd(a,b){return ord(this,RD(a,27),RD(b,27))};_.Fb=function rrd(a){return this===a};_.Oe=function srd(){return new Frb(this)};_.a=false;sfb(jEe,'BoxLayoutProvider/1',983);feb(163,1,{163:1},zrd,Ard);_.Ib=function Brd(){return this.c?zCd(this.c):Fe(this.b)};sfb(jEe,'BoxLayoutProvider/Group',163);feb(320,22,{3:1,34:1,22:1,320:1},Hrd);var Crd,Drd,Erd,Frd;var R3=tfb(jEe,'BoxLayoutProvider/PackingMode',320,WI,Jrd,Ird);var Krd;feb(984,1,fye,Mrd);_.Ne=function Nrd(a,b){return krd(RD(a,163),RD(b,163))};_.Fb=function Ord(a){return this===a};_.Oe=function Prd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$0$Type',984);feb(985,1,fye,Qrd);_.Ne=function Rrd(a,b){return lrd(RD(a,163),RD(b,163))};_.Fb=function Srd(a){return this===a};_.Oe=function Trd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$1$Type',985);feb(986,1,fye,Urd);_.Ne=function Vrd(a,b){return mrd(RD(a,163),RD(b,163))};_.Fb=function Wrd(a){return this===a};_.Oe=function Xrd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$2$Type',986);feb(1384,1,{845:1},Yrd);_.Mg=function Zrd(a,b){return GCc(),!ZD(b,167)||ued((hed(),RD(a,167)),b)};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$0$Type',1384);feb(1385,1,Qve,$rd);_.Cd=function _rd(a){JCc(this.a,RD(a,149));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$1$Type',1385);feb(1386,1,Qve,asd);_.Cd=function bsd(a){RD(a,96);GCc();};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$2$Type',1386);feb(1390,1,Qve,csd);_.Cd=function dsd(a){KCc(this.a,RD(a,96));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$3$Type',1390);feb(1388,1,nwe,esd);_.Mb=function fsd(a){return LCc(this.a,this.b,RD(a,149))};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$4$Type',1388);feb(1387,1,nwe,gsd);_.Mb=function hsd(a){return NCc(this.a,this.b,RD(a,845))};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$5$Type',1387);feb(1389,1,Qve,isd);_.Cd=function jsd(a){MCc(this.a,this.b,RD(a,149));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$6$Type',1389);feb(947,1,{},Lsd);_.Kb=function Msd(a){return Ksd(a)};_.Fb=function Nsd(a){return this===a};sfb(jEe,'ElkUtil/lambda$0$Type',947);feb(948,1,Qve,Osd);_.Cd=function Psd(a){ysd(this.a,this.b,RD(a,74));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$1$Type',948);feb(949,1,Qve,Qsd);_.Cd=function Rsd(a){zsd(this.a,this.b,RD(a,166));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$2$Type',949);feb(950,1,Qve,Ssd);_.Cd=function Tsd(a){Asd(this.a,this.b,RD(a,135));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$3$Type',950);feb(951,1,Qve,Usd);_.Cd=function Vsd(a){Bsd(this.a,RD(a,377));};sfb(jEe,'ElkUtil/lambda$4$Type',951);feb(325,1,{34:1,325:1},Xsd);_.Fd=function Ysd(a){return Wsd(this,RD(a,242))};_.Fb=function Zsd(a){var b;if(ZD(a,325)){b=RD(a,325);return this.a==b.a}return false};_.Hb=function $sd(){return eE(this.a)};_.Ib=function _sd(){return this.a+' (exclusive)'};_.a=0;sfb(jEe,'ExclusiveBounds/ExclusiveLowerBound',325);feb(1119,205,oze,btd);_.rf=function ctd(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B;b.Ug('Fixed Layout',1);f=RD(Gxd(a,(umd(),Skd)),223);l=0;m=0;for(s=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));s.e!=s.i.gc();){q=RD(bMd(s),27);B=RD(Gxd(q,(vnd(),und)),8);if(B){Byd(q,B.a,B.b);if(RD(Gxd(q,pnd),181).Hc((Qpd(),Mpd))){n=RD(Gxd(q,rnd),8);n.a>0&&n.b>0&&Esd(q,n.a,n.b,true,true);}}l=$wnd.Math.max(l,q.i+q.g);m=$wnd.Math.max(m,q.j+q.f);for(j=new dMd((!q.n&&(q.n=new C5d(I4,q,1,7)),q.n));j.e!=j.i.gc();){h=RD(bMd(j),135);B=RD(Gxd(h,und),8);!!B&&Byd(h,B.a,B.b);l=$wnd.Math.max(l,q.i+h.i+h.g);m=$wnd.Math.max(m,q.j+h.j+h.f);}for(v=new dMd((!q.c&&(q.c=new C5d(K4,q,9,9)),q.c));v.e!=v.i.gc();){u=RD(bMd(v),123);B=RD(Gxd(u,und),8);!!B&&Byd(u,B.a,B.b);w=q.i+u.i;A=q.j+u.j;l=$wnd.Math.max(l,w+u.g);m=$wnd.Math.max(m,A+u.f);for(i=new dMd((!u.n&&(u.n=new C5d(I4,u,1,7)),u.n));i.e!=i.i.gc();){h=RD(bMd(i),135);B=RD(Gxd(h,und),8);!!B&&Byd(h,B.a,B.b);l=$wnd.Math.max(l,w+h.i+h.g);m=$wnd.Math.max(m,A+h.j+h.f);}}for(e=new is(Mr(zGd(q).a.Kc(),new ir));gs(e);){c=RD(hs(e),74);k=atd(c);l=$wnd.Math.max(l,k.a);m=$wnd.Math.max(m,k.b);}for(d=new is(Mr(yGd(q).a.Kc(),new ir));gs(d);){c=RD(hs(d),74);if(vCd(JGd(c))!=a){k=atd(c);l=$wnd.Math.max(l,k.a);m=$wnd.Math.max(m,k.b);}}}if(f==(Ymd(),Umd)){for(r=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));r.e!=r.i.gc();){q=RD(bMd(r),27);for(d=new is(Mr(zGd(q).a.Kc(),new ir));gs(d);){c=RD(hs(d),74);g=tsd(c);g.b==0?Ixd(c,cld,null):Ixd(c,cld,g);}}}if(!Heb(TD(Gxd(a,(vnd(),qnd))))){t=RD(Gxd(a,snd),107);p=l+t.b+t.c;o=m+t.d+t.a;Esd(a,p,o,true,true);}b.Vg();};sfb(jEe,'FixedLayoutProvider',1119);feb(385,137,{3:1,423:1,385:1,96:1,137:1},dtd,etd);_.cg=function htd(b){var c,d,e,f,g,h,i,j,k;if(!b){return}try{j=vhb(b,';,;');for(g=j,h=0,i=g.length;h>16&Bwe|b^d<<16};_.Kc=function Ttd(){return new Vtd(this)};_.Ib=function Utd(){return this.a==null&&this.b==null?'pair(null,null)':this.a==null?'pair(null,'+jeb(this.b)+')':this.b==null?'pair('+jeb(this.a)+',null)':'pair('+jeb(this.a)+','+jeb(this.b)+')'};sfb(jEe,'Pair',42);feb(995,1,Ave,Vtd);_.Nb=function Wtd(a){Ztb(this,a);};_.Ob=function Xtd(){return !this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)};_.Pb=function Ytd(){if(!this.c&&!this.b&&this.a.a!=null){this.b=true;return this.a.a}else if(!this.c&&this.a.b!=null){this.c=true;return this.a.b}throw Adb(new Dvb)};_.Qb=function Ztd(){this.c&&this.a.b!=null?(this.a.b=null):this.b&&this.a.a!=null&&(this.a.a=null);throw Adb(new cgb)};_.b=false;_.c=false;sfb(jEe,'Pair/1',995);feb(455,1,{455:1},$td);_.Fb=function _td(a){return Fvb(this.a,RD(a,455).a)&&Fvb(this.c,RD(a,455).c)&&Fvb(this.d,RD(a,455).d)&&Fvb(this.b,RD(a,455).b)};_.Hb=function aud(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.a,this.c,this.d,this.b]))};_.Ib=function bud(){return '('+this.a+pve+this.c+pve+this.d+pve+this.b+')'};sfb(jEe,'Quadruple',455);feb(1108,205,oze,eud);_.rf=function fud(a,b){var c,d,e,f,g;b.Ug('Random Layout',1);if((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a).i==0){b.Vg();return}f=RD(Gxd(a,(Fpd(),Dpd)),17);!!f&&f.a!=0?(e=new Pwb(f.a)):(e=new Owb);c=Mfb(UD(Gxd(a,Apd)));g=Mfb(UD(Gxd(a,Epd)));d=RD(Gxd(a,Bpd),107);dud(a,e,c,g,d);b.Vg();};sfb(jEe,'RandomLayoutProvider',1108);feb(240,1,{240:1},gud);_.Fb=function hud(a){return Fvb(this.a,RD(a,240).a)&&Fvb(this.b,RD(a,240).b)&&Fvb(this.c,RD(a,240).c)};_.Hb=function iud(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.a,this.b,this.c]))};_.Ib=function jud(){return '('+this.a+pve+this.b+pve+this.c+')'};sfb(jEe,'Triple',240);var kud;feb(562,1,{});_.Lf=function oud(){return new rjd(this.f.i,this.f.j)};_.of=function pud(a){if(hGd(a,(umd(),Gld))){return Gxd(this.f,mud)}return Gxd(this.f,a)};_.Mf=function qud(){return new rjd(this.f.g,this.f.f)};_.Nf=function rud(){return this.g};_.pf=function sud(a){return Hxd(this.f,a)};_.Of=function tud(a){Dyd(this.f,a.a);Eyd(this.f,a.b);};_.Pf=function uud(a){Cyd(this.f,a.a);Ayd(this.f,a.b);};_.Qf=function vud(a){this.g=a;};_.g=0;var mud;sfb(uHe,'ElkGraphAdapters/AbstractElkGraphElementAdapter',562);feb(563,1,{853:1},wud);_.Rf=function xud(){var a,b;if(!this.b){this.b=fv(iyd(this.a).i);for(b=new dMd(iyd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),135);Rmb(this.b,new Bud(a));}}return this.b};_.b=null;sfb(uHe,'ElkGraphAdapters/ElkEdgeAdapter',563);feb(289,562,{},zud);_.Sf=function Aud(){return yud(this)};_.a=null;sfb(uHe,'ElkGraphAdapters/ElkGraphAdapter',289);feb(640,562,{187:1},Bud);sfb(uHe,'ElkGraphAdapters/ElkLabelAdapter',640);feb(639,562,{695:1},Fud);_.Rf=function Iud(){return Cud(this)};_.Vf=function Jud(){var a;return a=RD(Gxd(this.f,(umd(),eld)),140),!a&&(a=new P2b),a};_.Xf=function Lud(){return Dud(this)};_.Zf=function Nud(a){var b;b=new S2b(a);Ixd(this.f,(umd(),eld),b);};_.$f=function Oud(a){Ixd(this.f,(umd(),tld),new B3b(a));};_.Tf=function Gud(){return this.d};_.Uf=function Hud(){var a,b;if(!this.a){this.a=new bnb;for(b=new is(Mr(yGd(RD(this.f,27)).a.Kc(),new ir));gs(b);){a=RD(hs(b),74);Rmb(this.a,new wud(a));}}return this.a};_.Wf=function Kud(){var a,b;if(!this.c){this.c=new bnb;for(b=new is(Mr(zGd(RD(this.f,27)).a.Kc(),new ir));gs(b);){a=RD(hs(b),74);Rmb(this.c,new wud(a));}}return this.c};_.Yf=function Mud(){return tCd(RD(this.f,27)).i!=0||Heb(TD(RD(this.f,27).of((umd(),$kd))))};_._f=function Pud(){Eud(this,(lud(),kud));};_.a=null;_.b=null;_.c=null;_.d=null;_.e=null;sfb(uHe,'ElkGraphAdapters/ElkNodeAdapter',639);feb(1284,562,{852:1},Rud);_.Rf=function Tud(){return Qud(this)};_.Uf=function Sud(){var a,b;if(!this.a){this.a=ev(RD(this.f,123).hh().i);for(b=new dMd(RD(this.f,123).hh());b.e!=b.i.gc();){a=RD(bMd(b),74);Rmb(this.a,new wud(a));}}return this.a};_.Wf=function Uud(){var a,b;if(!this.c){this.c=ev(RD(this.f,123).ih().i);for(b=new dMd(RD(this.f,123).ih());b.e!=b.i.gc();){a=RD(bMd(b),74);Rmb(this.c,new wud(a));}}return this.c};_.ag=function Vud(){return RD(RD(this.f,123).of((umd(),Old)),64)};_.bg=function Wud(){var a,b,c,d,e,f,g,h;d=MCd(RD(this.f,123));for(c=new dMd(RD(this.f,123).ih());c.e!=c.i.gc();){a=RD(bMd(c),74);for(h=new dMd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c));h.e!=h.i.gc();){g=RD(bMd(h),84);if(NGd(AGd(g),d)){return true}else if(AGd(g)==d&&Heb(TD(Gxd(a,(umd(),_kd))))){return true}}}for(b=new dMd(RD(this.f,123).hh());b.e!=b.i.gc();){a=RD(bMd(b),74);for(f=new dMd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b));f.e!=f.i.gc();){e=RD(bMd(f),84);if(NGd(AGd(e),d)){return true}}}return false};_.a=null;_.b=null;_.c=null;sfb(uHe,'ElkGraphAdapters/ElkPortAdapter',1284);feb(1285,1,fye,Yud);_.Ne=function Zud(a,b){return Xud(RD(a,123),RD(b,123))};_.Fb=function $ud(a){return this===a};_.Oe=function _ud(){return new Frb(this)};sfb(uHe,'ElkGraphAdapters/PortComparator',1285);var r7=ufb(vHe,'EObject');var C4=ufb(wHe,xHe);var D4=ufb(wHe,yHe);var H4=ufb(wHe,zHe);var L4=ufb(wHe,'ElkShape');var E4=ufb(wHe,AHe);var G4=ufb(wHe,BHe);var F4=ufb(wHe,CHe);var p7=ufb(vHe,DHe);var n7=ufb(vHe,'EFactory');var avd;var q7=ufb(vHe,EHe);var t7=ufb(vHe,'EPackage');var cvd;var evd,fvd,gvd,hvd,ivd,jvd,kvd,lvd,mvd,nvd,ovd;var I4=ufb(wHe,FHe);var J4=ufb(wHe,GHe);var K4=ufb(wHe,HHe);feb(93,1,IHe);_.th=function rvd(){this.uh();return null};_.uh=function svd(){return null};_.vh=function tvd(){return this.uh(),false};_.wh=function uvd(){return false};_.xh=function vvd(a){qvd(this,a);};sfb(JHe,'BasicNotifierImpl',93);feb(99,93,RHe);_.Yh=function Dwd(){return Mvd(this)};_.yh=function bwd(a,b){return a};_.zh=function cwd(){throw Adb(new jib)};_.Ah=function dwd(a){var b;return b=Z5d(RD(vYd(this.Dh(),this.Fh()),19)),this.Ph().Th(this,b.n,b.f,a)};_.Bh=function ewd(a,b){throw Adb(new jib)};_.Ch=function fwd(a,b,c){return xvd(this,a,b,c)};_.Dh=function gwd(){var a;if(this.zh()){a=this.zh().Nk();if(a){return a}}return this.ii()};_.Eh=function hwd(){return yvd(this)};_.Fh=function iwd(){throw Adb(new jib)};_.Gh=function kwd(){var a,b;b=this.$h().Ok();!b&&this.zh().Tk(b=(N2d(),a=P$d(rYd(this.Dh())),a==null?M2d:new Q2d(this,a)));return b};_.Hh=function mwd(a,b){return a};_.Ih=function nwd(a){var b;b=a.pk();return !b?BYd(this.Dh(),a):a.Lj()};_.Jh=function owd(){var a;a=this.zh();return !a?null:a.Qk()};_.Kh=function pwd(){return !this.zh()?null:this.zh().Nk()};_.Lh=function qwd(a,b,c){return Dvd(this,a,b,c)};_.Mh=function rwd(a){return Evd(this,a)};_.Nh=function swd(a,b){return Fvd(this,a,b)};_.Oh=function twd(){var a;a=this.zh();return !!a&&a.Rk()};_.Ph=function uwd(){throw Adb(new jib)};_.Qh=function vwd(){return Hvd(this)};_.Rh=function wwd(a,b,c,d){return Ivd(this,a,b,d)};_.Sh=function xwd(a,b,c){var d;return d=RD(vYd(this.Dh(),b),69),d.wk().zk(this,this.hi(),b-this.ji(),a,c)};_.Th=function ywd(a,b,c,d){return Jvd(this,a,b,d)};_.Uh=function zwd(a,b,c){var d;return d=RD(vYd(this.Dh(),b),69),d.wk().Ak(this,this.hi(),b-this.ji(),a,c)};_.Vh=function Awd(){return !!this.zh()&&!!this.zh().Pk()};_.Wh=function Bwd(a){return Kvd(this,a)};_.Xh=function Cwd(a){return Lvd(this,a)};_.Zh=function Ewd(a){return Pvd(this,a)};_.$h=function Fwd(){throw Adb(new jib)};_._h=function Gwd(){return !this.zh()?null:this.zh().Pk()};_.ai=function Hwd(){return Hvd(this)};_.bi=function Iwd(a,b){Wvd(this,a,b);};_.ci=function Jwd(a){this.$h().Sk(a);};_.di=function Kwd(a){this.$h().Vk(a);};_.ei=function Lwd(a){this.$h().Uk(a);};_.fi=function Mwd(a,b){var c,d,e,f;f=this.Jh();if(!!f&&!!a){b=rLd(f.El(),this,b);f.Il(this);}d=this.Ph();if(d){if((jwd(this,this.Ph(),this.Fh()).Bb&txe)!=0){e=d.Qh();!!e&&(!a?e.Hl(this):!f&&e.Il(this));}else {b=(c=this.Fh(),c>=0?this.Ah(b):this.Ph().Th(this,-1-c,null,b));b=this.Ch(null,-1,b);}}this.di(a);return b};_.gi=function Nwd(a){var b,c,d,e,f,g,h,i;c=this.Dh();f=BYd(c,a);b=this.ji();if(f>=b){return RD(a,69).wk().Dk(this,this.hi(),f-b)}else if(f<=-1){g=Eee((lke(),jke),c,a);if(g){nke();RD(g,69).xk()||(g=zfe(Qee(jke,g)));e=(d=this.Ih(g),RD(d>=0?this.Lh(d,true,true):Qvd(this,g,true),160));i=g.Ik();if(i>1||i==-1){return RD(RD(e,220).Sl(a,false),79)}}else {throw Adb(new agb(KHe+a.xe()+NHe))}}else if(a.Jk()){return d=this.Ih(a),RD(d>=0?this.Lh(d,false,true):Qvd(this,a,false),79)}h=new NTd(this,a);return h};_.hi=function Owd(){return Yvd(this)};_.ii=function Pwd(){return (lTd(),kTd).S};_.ji=function Qwd(){return AYd(this.ii())};_.ki=function Rwd(a){$vd(this,a);};_.Ib=function Swd(){return awd(this)};sfb(SHe,'BasicEObjectImpl',99);var ZSd;feb(119,99,{110:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1});_.li=function _wd(a){var b;b=Vwd(this);return b[a]};_.mi=function axd(a,b){var c;c=Vwd(this);bD(c,a,b);};_.ni=function bxd(a){var b;b=Vwd(this);bD(b,a,null);};_.th=function cxd(){return RD(Ywd(this,4),129)};_.uh=function dxd(){throw Adb(new jib)};_.vh=function exd(){return (this.Db&4)!=0};_.zh=function fxd(){throw Adb(new jib)};_.oi=function gxd(a){$wd(this,2,a);};_.Bh=function hxd(a,b){this.Db=b<<16|this.Db&255;this.oi(a);};_.Dh=function ixd(){return Uwd(this)};_.Fh=function jxd(){return this.Db>>16};_.Gh=function kxd(){var a,b;return N2d(),b=P$d(rYd((a=RD(Ywd(this,16),29),!a?this.ii():a))),b==null?(M2d):new Q2d(this,b)};_.wh=function lxd(){return (this.Db&1)==0};_.Jh=function mxd(){return RD(Ywd(this,128),2034)};_.Kh=function nxd(){return RD(Ywd(this,16),29)};_.Oh=function oxd(){return (this.Db&32)!=0};_.Ph=function pxd(){return RD(Ywd(this,2),54)};_.Vh=function qxd(){return (this.Db&64)!=0};_.$h=function rxd(){throw Adb(new jib)};_._h=function sxd(){return RD(Ywd(this,64),288)};_.ci=function txd(a){$wd(this,16,a);};_.di=function uxd(a){$wd(this,128,a);};_.ei=function vxd(a){$wd(this,64,a);};_.hi=function wxd(){return Wwd(this)};_.Db=0;sfb(SHe,'MinimalEObjectImpl',119);feb(120,119,{110:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.oi=function xxd(a){this.Cb=a;};_.Ph=function yxd(){return this.Cb};sfb(SHe,'MinimalEObjectImpl/Container',120);feb(2083,120,{110:1,342:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function Jxd(a,b,c){return Axd(this,a,b,c)};_.Uh=function Kxd(a,b,c){return Bxd(this,a,b,c)};_.Wh=function Lxd(a){return Cxd(this,a)};_.bi=function Mxd(a,b){Dxd(this,a,b);};_.ii=function Nxd(){return pvd(),ovd};_.ki=function Oxd(a){Exd(this,a);};_.nf=function Pxd(){return Fxd(this)};_.gh=function Qxd(){return !this.o&&(this.o=new DVd((pvd(),mvd),X4,this,0)),this.o};_.of=function Rxd(a){return Gxd(this,a)};_.pf=function Sxd(a){return Hxd(this,a)};_.qf=function Txd(a,b){return Ixd(this,a,b)};sfb(THe,'EMapPropertyHolderImpl',2083);feb(572,120,{110:1,377:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},Xxd);_.Lh=function Yxd(a,b,c){switch(a){case 0:return this.a;case 1:return this.b;}return Dvd(this,a,b,c)};_.Wh=function Zxd(a){switch(a){case 0:return this.a!=0;case 1:return this.b!=0;}return Kvd(this,a)};_.bi=function $xd(a,b){switch(a){case 0:Vxd(this,Kfb(UD(b)));return;case 1:Wxd(this,Kfb(UD(b)));return;}Wvd(this,a,b);};_.ii=function _xd(){return pvd(),evd};_.ki=function ayd(a){switch(a){case 0:Vxd(this,0);return;case 1:Wxd(this,0);return;}$vd(this,a);};_.Ib=function byd(){var a;if((this.Db&64)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (x: ';Khb(a,this.a);a.a+=', y: ';Khb(a,this.b);a.a+=')';return a.a};_.a=0;_.b=0;sfb(THe,'ElkBendPointImpl',572);feb(739,2083,{110:1,342:1,167:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function lyd(a,b,c){return cyd(this,a,b,c)};_.Sh=function myd(a,b,c){return dyd(this,a,b,c)};_.Uh=function nyd(a,b,c){return eyd(this,a,b,c)};_.Wh=function oyd(a){return fyd(this,a)};_.bi=function pyd(a,b){gyd(this,a,b);};_.ii=function qyd(){return pvd(),ivd};_.ki=function ryd(a){hyd(this,a);};_.jh=function syd(){return this.k};_.kh=function tyd(){return iyd(this)};_.Ib=function uyd(){return kyd(this)};_.k=null;sfb(THe,'ElkGraphElementImpl',739);feb(740,739,{110:1,342:1,167:1,422:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function Gyd(a,b,c){return vyd(this,a,b,c)};_.Wh=function Hyd(a){return wyd(this,a)};_.bi=function Iyd(a,b){xyd(this,a,b);};_.ii=function Jyd(){return pvd(),nvd};_.ki=function Kyd(a){yyd(this,a);};_.lh=function Lyd(){return this.f};_.mh=function Myd(){return this.g};_.nh=function Nyd(){return this.i};_.oh=function Oyd(){return this.j};_.ph=function Pyd(a,b){zyd(this,a,b);};_.qh=function Qyd(a,b){Byd(this,a,b);};_.rh=function Ryd(a){Dyd(this,a);};_.sh=function Syd(a){Eyd(this,a);};_.Ib=function Tyd(){return Fyd(this)};_.f=0;_.g=0;_.i=0;_.j=0;sfb(THe,'ElkShapeImpl',740);feb(741,740,{110:1,342:1,84:1,167:1,422:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function _yd(a,b,c){return Uyd(this,a,b,c)};_.Sh=function azd(a,b,c){return Vyd(this,a,b,c)};_.Uh=function bzd(a,b,c){return Wyd(this,a,b,c)};_.Wh=function czd(a){return Xyd(this,a)};_.bi=function dzd(a,b){Yyd(this,a,b);};_.ii=function ezd(){return pvd(),fvd};_.ki=function fzd(a){Zyd(this,a);};_.hh=function gzd(){return !this.d&&(this.d=new Yie(G4,this,8,5)),this.d};_.ih=function hzd(){return !this.e&&(this.e=new Yie(G4,this,7,4)),this.e};sfb(THe,'ElkConnectableShapeImpl',741);feb(326,739,{110:1,342:1,74:1,167:1,326:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},rzd);_.Ah=function szd(a){return jzd(this,a)};_.Lh=function tzd(a,b,c){switch(a){case 3:return kzd(this);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),this.b;case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),this.c;case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),this.a;case 7:return Geb(),!this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i<=1&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i<=1)?false:true;case 8:return Geb(),nzd(this)?true:false;case 9:return Geb(),ozd(this)?true:false;case 10:return Geb(),!this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i!=0)?true:false;}return cyd(this,a,b,c)};_.Sh=function uzd(a,b,c){var d;switch(b){case 3:!!this.Cb&&(c=(d=this.Db>>16,d>=0?jzd(this,c):this.Cb.Th(this,-1-d,null,c)));return izd(this,RD(a,27),c);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),qLd(this.b,a,c);case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),qLd(this.c,a,c);case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),qLd(this.a,a,c);}return dyd(this,a,b,c)};_.Uh=function vzd(a,b,c){switch(b){case 3:return izd(this,null,c);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),rLd(this.b,a,c);case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),rLd(this.c,a,c);case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),rLd(this.a,a,c);}return eyd(this,a,b,c)};_.Wh=function wzd(a){switch(a){case 3:return !!kzd(this);case 4:return !!this.b&&this.b.i!=0;case 5:return !!this.c&&this.c.i!=0;case 6:return !!this.a&&this.a.i!=0;case 7:return !this.b&&(this.b=new Yie(E4,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i<=1));case 8:return nzd(this);case 9:return ozd(this);case 10:return !this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i!=0);}return fyd(this,a)};_.bi=function xzd(a,b){switch(a){case 3:pzd(this,RD(b,27));return;case 4:!this.b&&(this.b=new Yie(E4,this,4,7));sLd(this.b);!this.b&&(this.b=new Yie(E4,this,4,7));YGd(this.b,RD(b,16));return;case 5:!this.c&&(this.c=new Yie(E4,this,5,8));sLd(this.c);!this.c&&(this.c=new Yie(E4,this,5,8));YGd(this.c,RD(b,16));return;case 6:!this.a&&(this.a=new C5d(F4,this,6,6));sLd(this.a);!this.a&&(this.a=new C5d(F4,this,6,6));YGd(this.a,RD(b,16));return;}gyd(this,a,b);};_.ii=function yzd(){return pvd(),gvd};_.ki=function zzd(a){switch(a){case 3:pzd(this,null);return;case 4:!this.b&&(this.b=new Yie(E4,this,4,7));sLd(this.b);return;case 5:!this.c&&(this.c=new Yie(E4,this,5,8));sLd(this.c);return;case 6:!this.a&&(this.a=new C5d(F4,this,6,6));sLd(this.a);return;}hyd(this,a);};_.Ib=function Azd(){return qzd(this)};sfb(THe,'ElkEdgeImpl',326);feb(452,2083,{110:1,342:1,166:1,452:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},Rzd);_.Ah=function Szd(a){return Czd(this,a)};_.Lh=function Tzd(a,b,c){switch(a){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return !this.a&&(this.a=new XZd(D4,this,5)),this.a;case 6:return Fzd(this);case 7:if(b)return Ezd(this);return this.i;case 8:if(b)return Dzd(this);return this.f;case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),this.g;case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),this.e;case 11:return this.d;}return Axd(this,a,b,c)};_.Sh=function Uzd(a,b,c){var d,e,f;switch(b){case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?Czd(this,c):this.Cb.Th(this,-1-e,null,c)));return Bzd(this,RD(a,74),c);case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),qLd(this.g,a,c);case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),qLd(this.e,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(pvd(),hvd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((pvd(),hvd)),a,c)};_.Uh=function Vzd(a,b,c){switch(b){case 5:return !this.a&&(this.a=new XZd(D4,this,5)),rLd(this.a,a,c);case 6:return Bzd(this,null,c);case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),rLd(this.g,a,c);case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),rLd(this.e,a,c);}return Bxd(this,a,b,c)};_.Wh=function Wzd(a){switch(a){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return !!this.a&&this.a.i!=0;case 6:return !!Fzd(this);case 7:return !!this.i;case 8:return !!this.f;case 9:return !!this.g&&this.g.i!=0;case 10:return !!this.e&&this.e.i!=0;case 11:return this.d!=null;}return Cxd(this,a)};_.bi=function Xzd(a,b){switch(a){case 1:Ozd(this,Kfb(UD(b)));return;case 2:Pzd(this,Kfb(UD(b)));return;case 3:Hzd(this,Kfb(UD(b)));return;case 4:Izd(this,Kfb(UD(b)));return;case 5:!this.a&&(this.a=new XZd(D4,this,5));sLd(this.a);!this.a&&(this.a=new XZd(D4,this,5));YGd(this.a,RD(b,16));return;case 6:Mzd(this,RD(b,74));return;case 7:Lzd(this,RD(b,84));return;case 8:Kzd(this,RD(b,84));return;case 9:!this.g&&(this.g=new Yie(F4,this,9,10));sLd(this.g);!this.g&&(this.g=new Yie(F4,this,9,10));YGd(this.g,RD(b,16));return;case 10:!this.e&&(this.e=new Yie(F4,this,10,9));sLd(this.e);!this.e&&(this.e=new Yie(F4,this,10,9));YGd(this.e,RD(b,16));return;case 11:Jzd(this,WD(b));return;}Dxd(this,a,b);};_.ii=function Yzd(){return pvd(),hvd};_.ki=function Zzd(a){switch(a){case 1:Ozd(this,0);return;case 2:Pzd(this,0);return;case 3:Hzd(this,0);return;case 4:Izd(this,0);return;case 5:!this.a&&(this.a=new XZd(D4,this,5));sLd(this.a);return;case 6:Mzd(this,null);return;case 7:Lzd(this,null);return;case 8:Kzd(this,null);return;case 9:!this.g&&(this.g=new Yie(F4,this,9,10));sLd(this.g);return;case 10:!this.e&&(this.e=new Yie(F4,this,10,9));sLd(this.e);return;case 11:Jzd(this,null);return;}Exd(this,a);};_.Ib=function $zd(){return Qzd(this)};_.b=0;_.c=0;_.d=null;_.j=0;_.k=0;sfb(THe,'ElkEdgeSectionImpl',452);feb(158,120,{110:1,94:1,93:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1});_.Lh=function cAd(a,b,c){var d;if(a==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function dAd(a,b,c){var d,e;if(b==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c)}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function eAd(a,b,c){var d,e;if(b==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c)}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function fAd(a){var b;if(a==0){return !!this.Ab&&this.Ab.i!=0}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.Zh=function gAd(a){return _zd(this,a)};_.bi=function hAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.di=function iAd(a){$wd(this,128,a);};_.ii=function jAd(){return JTd(),xTd};_.ki=function kAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function lAd(){this.Bb|=1;};_.qi=function mAd(a){return bAd(this,a)};_.Bb=0;sfb(SHe,'EModelElementImpl',158);feb(720,158,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1},yAd);_.ri=function zAd(a,b){return tAd(this,a,b)};_.si=function AAd(a){var b,c,d,e,f;if(this.a!=BXd(a)||(a.Bb&256)!=0){throw Adb(new agb(ZHe+a.zb+WHe))}for(d=zYd(a);tYd(d.a).i!=0;){c=RD(N_d(d,0,(b=RD(QHd(tYd(d.a),0),89),f=b.c,ZD(f,90)?RD(f,29):(JTd(),zTd))),29);if(DXd(c)){e=BXd(c).wi().si(c);RD(e,54).ci(a);return e}d=zYd(c);}return (a.D!=null?a.D:a.B)=='java.util.Map$Entry'?new LUd(a):new zUd(a)};_.ti=function BAd(a,b){return uAd(this,a,b)};_.Lh=function CAd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.a;}return zvd(this,a-AYd((JTd(),uTd)),vYd((d=RD(Ywd(this,16),29),!d?uTd:d),a),b,c)};_.Sh=function DAd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 1:!!this.a&&(c=RD(this.a,54).Th(this,4,t7,c));return rAd(this,RD(a,241),c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),uTd):d),b),69),e.wk().zk(this,Wwd(this),b-AYd((JTd(),uTd)),a,c)};_.Uh=function EAd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 1:return rAd(this,null,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),uTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),uTd)),a,c)};_.Wh=function FAd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return !!this.a;}return Avd(this,a-AYd((JTd(),uTd)),vYd((b=RD(Ywd(this,16),29),!b?uTd:b),a))};_.bi=function GAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:wAd(this,RD(b,241));return;}Bvd(this,a-AYd((JTd(),uTd)),vYd((c=RD(Ywd(this,16),29),!c?uTd:c),a),b);};_.ii=function HAd(){return JTd(),uTd};_.ki=function IAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:wAd(this,null);return;}Cvd(this,a-AYd((JTd(),uTd)),vYd((b=RD(Ywd(this,16),29),!b?uTd:b),a));};var nAd,oAd,pAd;sfb(SHe,'EFactoryImpl',720);feb(1037,720,{110:1,2113:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1},KAd);_.ri=function LAd(a,b){switch(a.hk()){case 12:return RD(b,149).Pg();case 13:return jeb(b);default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function MAd(a){var b,c,d,e,f,g,h,i;switch(a.G==-1&&(a.G=(b=BXd(a),b?fZd(b.vi(),a):-1)),a.G){case 4:return f=new hCd,f;case 6:return g=new ACd,g;case 7:return h=new PCd,h;case 8:return d=new rzd,d;case 9:return c=new Xxd,c;case 10:return e=new Rzd,e;case 11:return i=new _Cd,i;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function NAd(a,b){switch(a.hk()){case 13:case 12:return null;default:throw Adb(new agb(VHe+a.xe()+WHe));}};sfb(THe,'ElkGraphFactoryImpl',1037);feb(448,158,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1});_.Gh=function RAd(){var a,b;b=(a=RD(Ywd(this,16),29),P$d(rYd(!a?this.ii():a)));return b==null?(N2d(),N2d(),M2d):new e3d(this,b)};_.Lh=function SAd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.xe();}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Wh=function TAd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function UAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:this.ui(WD(b));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function VAd(){return JTd(),yTd};_.ki=function WAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:this.ui(null);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.xe=function XAd(){return this.zb};_.ui=function YAd(a){PAd(this,a);};_.Ib=function ZAd(){return QAd(this)};_.zb=null;sfb(SHe,'ENamedElementImpl',448);feb(184,448,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1},EBd);_.Ah=function GBd(a){return qBd(this,a)};_.Lh=function HBd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),this.rb;case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),this.vb;case 7:if(b)return this.Db>>16==7?RD(this.Cb,241):null;return gBd(this);}return zvd(this,a-AYd((JTd(),CTd)),vYd((d=RD(Ywd(this,16),29),!d?CTd:d),a),b,c)};_.Sh=function IBd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 4:!!this.sb&&(c=RD(this.sb,54).Th(this,1,n7,c));return hBd(this,RD(a,480),c);case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),qLd(this.rb,a,c);case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),qLd(this.vb,a,c);case 7:!!this.Cb&&(c=(e=this.Db>>16,e>=0?qBd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,7,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),CTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),CTd)),a,c)};_.Uh=function JBd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 4:return hBd(this,null,c);case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),rLd(this.rb,a,c);case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),rLd(this.vb,a,c);case 7:return xvd(this,null,7,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),CTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),CTd)),a,c)};_.Wh=function KBd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return !!this.sb;case 5:return !!this.rb&&this.rb.i!=0;case 6:return !!this.vb&&this.vb.i!=0;case 7:return !!gBd(this);}return Avd(this,a-AYd((JTd(),CTd)),vYd((b=RD(Ywd(this,16),29),!b?CTd:b),a))};_.Zh=function LBd(a){var b;b=sBd(this,a);return b?b:_zd(this,a)};_.bi=function MBd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:DBd(this,WD(b));return;case 3:CBd(this,WD(b));return;case 4:BBd(this,RD(b,480));return;case 5:!this.rb&&(this.rb=new J5d(this,i7,this));sLd(this.rb);!this.rb&&(this.rb=new J5d(this,i7,this));YGd(this.rb,RD(b,16));return;case 6:!this.vb&&(this.vb=new G5d(t7,this,6,7));sLd(this.vb);!this.vb&&(this.vb=new G5d(t7,this,6,7));YGd(this.vb,RD(b,16));return;}Bvd(this,a-AYd((JTd(),CTd)),vYd((c=RD(Ywd(this,16),29),!c?CTd:c),a),b);};_.ei=function NBd(a){var b,c;if(!!a&&!!this.rb){for(c=new dMd(this.rb);c.e!=c.i.gc();){b=bMd(c);ZD(b,364)&&(RD(b,364).w=null);}}$wd(this,64,a);};_.ii=function OBd(){return JTd(),CTd};_.ki=function PBd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:DBd(this,null);return;case 3:CBd(this,null);return;case 4:BBd(this,null);return;case 5:!this.rb&&(this.rb=new J5d(this,i7,this));sLd(this.rb);return;case 6:!this.vb&&(this.vb=new G5d(t7,this,6,7));sLd(this.vb);return;}Cvd(this,a-AYd((JTd(),CTd)),vYd((b=RD(Ywd(this,16),29),!b?CTd:b),a));};_.pi=function QBd(){rBd(this);};_.vi=function RBd(){return !this.rb&&(this.rb=new J5d(this,i7,this)),this.rb};_.wi=function SBd(){return this.sb};_.xi=function TBd(){return this.ub};_.yi=function UBd(){return this.xb};_.zi=function VBd(){return this.yb};_.Ai=function WBd(a){this.ub=a;};_.Ib=function XBd(){var a;if((this.Db&64)!=0)return QAd(this);a=new Shb(QAd(this));a.a+=' (nsURI: ';Nhb(a,this.yb);a.a+=', nsPrefix: ';Nhb(a,this.xb);a.a+=')';return a.a};_.xb=null;_.yb=null;sfb(SHe,'EPackageImpl',184);feb(569,184,{110:1,2115:1,569:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1},_Bd);_.q=false;_.r=false;var YBd=false;sfb(THe,'ElkGraphPackageImpl',569);feb(366,740,{110:1,342:1,167:1,135:1,422:1,366:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},hCd);_.Ah=function iCd(a){return cCd(this,a)};_.Lh=function jCd(a,b,c){switch(a){case 7:return dCd(this);case 8:return this.a;}return vyd(this,a,b,c)};_.Sh=function kCd(a,b,c){var d;switch(b){case 7:!!this.Cb&&(c=(d=this.Db>>16,d>=0?cCd(this,c):this.Cb.Th(this,-1-d,null,c)));return bCd(this,RD(a,167),c);}return dyd(this,a,b,c)};_.Uh=function lCd(a,b,c){if(b==7){return bCd(this,null,c)}return eyd(this,a,b,c)};_.Wh=function mCd(a){switch(a){case 7:return !!dCd(this);case 8:return !lhb('',this.a);}return wyd(this,a)};_.bi=function nCd(a,b){switch(a){case 7:eCd(this,RD(b,167));return;case 8:fCd(this,WD(b));return;}xyd(this,a,b);};_.ii=function oCd(){return pvd(),jvd};_.ki=function pCd(a){switch(a){case 7:eCd(this,null);return;case 8:fCd(this,'');return;}yyd(this,a);};_.Ib=function qCd(){return gCd(this)};_.a='';sfb(THe,'ElkLabelImpl',366);feb(207,741,{110:1,342:1,84:1,167:1,27:1,422:1,207:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},ACd);_.Ah=function BCd(a){return sCd(this,a)};_.Lh=function CCd(a,b,c){switch(a){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),this.c;case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),this.a;case 11:return vCd(this);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),this.b;case 13:return Geb(),!this.a&&(this.a=new C5d(J4,this,10,11)),this.a.i>0?true:false;}return Uyd(this,a,b,c)};_.Sh=function DCd(a,b,c){var d;switch(b){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),qLd(this.c,a,c);case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),qLd(this.a,a,c);case 11:!!this.Cb&&(c=(d=this.Db>>16,d>=0?sCd(this,c):this.Cb.Th(this,-1-d,null,c)));return rCd(this,RD(a,27),c);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),qLd(this.b,a,c);}return Vyd(this,a,b,c)};_.Uh=function ECd(a,b,c){switch(b){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),rLd(this.c,a,c);case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),rLd(this.a,a,c);case 11:return rCd(this,null,c);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),rLd(this.b,a,c);}return Wyd(this,a,b,c)};_.Wh=function FCd(a){switch(a){case 9:return !!this.c&&this.c.i!=0;case 10:return !!this.a&&this.a.i!=0;case 11:return !!vCd(this);case 12:return !!this.b&&this.b.i!=0;case 13:return !this.a&&(this.a=new C5d(J4,this,10,11)),this.a.i>0;}return Xyd(this,a)};_.bi=function GCd(a,b){switch(a){case 9:!this.c&&(this.c=new C5d(K4,this,9,9));sLd(this.c);!this.c&&(this.c=new C5d(K4,this,9,9));YGd(this.c,RD(b,16));return;case 10:!this.a&&(this.a=new C5d(J4,this,10,11));sLd(this.a);!this.a&&(this.a=new C5d(J4,this,10,11));YGd(this.a,RD(b,16));return;case 11:yCd(this,RD(b,27));return;case 12:!this.b&&(this.b=new C5d(G4,this,12,3));sLd(this.b);!this.b&&(this.b=new C5d(G4,this,12,3));YGd(this.b,RD(b,16));return;}Yyd(this,a,b);};_.ii=function HCd(){return pvd(),kvd};_.ki=function ICd(a){switch(a){case 9:!this.c&&(this.c=new C5d(K4,this,9,9));sLd(this.c);return;case 10:!this.a&&(this.a=new C5d(J4,this,10,11));sLd(this.a);return;case 11:yCd(this,null);return;case 12:!this.b&&(this.b=new C5d(G4,this,12,3));sLd(this.b);return;}Zyd(this,a);};_.Ib=function JCd(){return zCd(this)};sfb(THe,'ElkNodeImpl',207);feb(193,741,{110:1,342:1,84:1,167:1,123:1,422:1,193:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},PCd);_.Ah=function QCd(a){return LCd(this,a)};_.Lh=function RCd(a,b,c){if(a==9){return MCd(this)}return Uyd(this,a,b,c)};_.Sh=function SCd(a,b,c){var d;switch(b){case 9:!!this.Cb&&(c=(d=this.Db>>16,d>=0?LCd(this,c):this.Cb.Th(this,-1-d,null,c)));return KCd(this,RD(a,27),c);}return Vyd(this,a,b,c)};_.Uh=function TCd(a,b,c){if(b==9){return KCd(this,null,c)}return Wyd(this,a,b,c)};_.Wh=function UCd(a){if(a==9){return !!MCd(this)}return Xyd(this,a)};_.bi=function VCd(a,b){switch(a){case 9:NCd(this,RD(b,27));return;}Yyd(this,a,b);};_.ii=function WCd(){return pvd(),lvd};_.ki=function XCd(a){switch(a){case 9:NCd(this,null);return;}Zyd(this,a);};_.Ib=function YCd(){return OCd(this)};sfb(THe,'ElkPortImpl',193);var O6=ufb(sIe,'BasicEMap/Entry');feb(1122,120,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1,119:1,120:1},_Cd);_.Fb=function fDd(a){return this===a};_.ld=function hDd(){return this.b};_.Hb=function jDd(){return kFb(this)};_.Di=function lDd(a){ZCd(this,RD(a,149));};_.Lh=function aDd(a,b,c){switch(a){case 0:return this.b;case 1:return this.c;}return Dvd(this,a,b,c)};_.Wh=function bDd(a){switch(a){case 0:return !!this.b;case 1:return this.c!=null;}return Kvd(this,a)};_.bi=function cDd(a,b){switch(a){case 0:ZCd(this,RD(b,149));return;case 1:$Cd(this,b);return;}Wvd(this,a,b);};_.ii=function dDd(){return pvd(),mvd};_.ki=function eDd(a){switch(a){case 0:ZCd(this,null);return;case 1:$Cd(this,null);return;}$vd(this,a);};_.Bi=function gDd(){var a;if(this.a==-1){a=this.b;this.a=!a?0:tb(a);}return this.a};_.md=function iDd(){return this.c};_.Ci=function kDd(a){this.a=a;};_.nd=function mDd(a){var b;b=this.c;$Cd(this,a);return b};_.Ib=function nDd(){var a;if((this.Db&64)!=0)return awd(this);a=new bib;Zhb(Zhb(Zhb(a,this.b?this.b.Pg():vve),SAe),Ghb(this.c));return a.a};_.a=-1;_.c=null;var X4=sfb(THe,'ElkPropertyToValueMapEntryImpl',1122);feb(996,1,{},BDd);sfb(vIe,'JsonAdapter',996);feb(216,63,swe,CDd);sfb(vIe,'JsonImportException',216);feb(868,1,{},IEd);sfb(vIe,'JsonImporter',868);feb(903,1,{},JEd);sfb(vIe,'JsonImporter/lambda$0$Type',903);feb(904,1,{},KEd);sfb(vIe,'JsonImporter/lambda$1$Type',904);feb(912,1,{},LEd);sfb(vIe,'JsonImporter/lambda$10$Type',912);feb(914,1,{},MEd);sfb(vIe,'JsonImporter/lambda$11$Type',914);feb(915,1,{},NEd);sfb(vIe,'JsonImporter/lambda$12$Type',915);feb(921,1,{},OEd);sfb(vIe,'JsonImporter/lambda$13$Type',921);feb(920,1,{},PEd);sfb(vIe,'JsonImporter/lambda$14$Type',920);feb(916,1,{},QEd);sfb(vIe,'JsonImporter/lambda$15$Type',916);feb(917,1,{},REd);sfb(vIe,'JsonImporter/lambda$16$Type',917);feb(918,1,{},SEd);sfb(vIe,'JsonImporter/lambda$17$Type',918);feb(919,1,{},TEd);sfb(vIe,'JsonImporter/lambda$18$Type',919);feb(924,1,{},UEd);sfb(vIe,'JsonImporter/lambda$19$Type',924);feb(905,1,{},VEd);sfb(vIe,'JsonImporter/lambda$2$Type',905);feb(922,1,{},WEd);sfb(vIe,'JsonImporter/lambda$20$Type',922);feb(923,1,{},XEd);sfb(vIe,'JsonImporter/lambda$21$Type',923);feb(927,1,{},YEd);sfb(vIe,'JsonImporter/lambda$22$Type',927);feb(925,1,{},ZEd);sfb(vIe,'JsonImporter/lambda$23$Type',925);feb(926,1,{},$Ed);sfb(vIe,'JsonImporter/lambda$24$Type',926);feb(929,1,{},_Ed);sfb(vIe,'JsonImporter/lambda$25$Type',929);feb(928,1,{},aFd);sfb(vIe,'JsonImporter/lambda$26$Type',928);feb(930,1,Qve,bFd);_.Cd=function cFd(a){_Dd(this.b,this.a,WD(a));};sfb(vIe,'JsonImporter/lambda$27$Type',930);feb(931,1,Qve,dFd);_.Cd=function eFd(a){aEd(this.b,this.a,WD(a));};sfb(vIe,'JsonImporter/lambda$28$Type',931);feb(932,1,{},fFd);sfb(vIe,'JsonImporter/lambda$29$Type',932);feb(908,1,{},gFd);sfb(vIe,'JsonImporter/lambda$3$Type',908);feb(933,1,{},hFd);sfb(vIe,'JsonImporter/lambda$30$Type',933);feb(934,1,{},iFd);sfb(vIe,'JsonImporter/lambda$31$Type',934);feb(935,1,{},jFd);sfb(vIe,'JsonImporter/lambda$32$Type',935);feb(936,1,{},kFd);sfb(vIe,'JsonImporter/lambda$33$Type',936);feb(937,1,{},lFd);sfb(vIe,'JsonImporter/lambda$34$Type',937);feb(870,1,{},nFd);sfb(vIe,'JsonImporter/lambda$35$Type',870);feb(941,1,{},pFd);sfb(vIe,'JsonImporter/lambda$36$Type',941);feb(938,1,Qve,qFd);_.Cd=function rFd(a){jEd(this.a,RD(a,377));};sfb(vIe,'JsonImporter/lambda$37$Type',938);feb(939,1,Qve,sFd);_.Cd=function tFd(a){kEd(this.a,this.b,RD(a,166));};sfb(vIe,'JsonImporter/lambda$38$Type',939);feb(940,1,Qve,uFd);_.Cd=function vFd(a){lEd(this.a,this.b,RD(a,166));};sfb(vIe,'JsonImporter/lambda$39$Type',940);feb(906,1,{},wFd);sfb(vIe,'JsonImporter/lambda$4$Type',906);feb(942,1,Qve,xFd);_.Cd=function yFd(a){mEd(this.a,RD(a,8));};sfb(vIe,'JsonImporter/lambda$40$Type',942);feb(907,1,{},zFd);sfb(vIe,'JsonImporter/lambda$5$Type',907);feb(911,1,{},AFd);sfb(vIe,'JsonImporter/lambda$6$Type',911);feb(909,1,{},BFd);sfb(vIe,'JsonImporter/lambda$7$Type',909);feb(910,1,{},CFd);sfb(vIe,'JsonImporter/lambda$8$Type',910);feb(913,1,{},DFd);sfb(vIe,'JsonImporter/lambda$9$Type',913);feb(961,1,Qve,MFd);_.Cd=function NFd(a){oDd(this.a,new OC(WD(a)));};sfb(vIe,'JsonMetaDataConverter/lambda$0$Type',961);feb(962,1,Qve,OFd);_.Cd=function PFd(a){IFd(this.a,RD(a,245));};sfb(vIe,'JsonMetaDataConverter/lambda$1$Type',962);feb(963,1,Qve,QFd);_.Cd=function RFd(a){JFd(this.a,RD(a,143));};sfb(vIe,'JsonMetaDataConverter/lambda$2$Type',963);feb(964,1,Qve,SFd);_.Cd=function TFd(a){KFd(this.a,RD(a,170));};sfb(vIe,'JsonMetaDataConverter/lambda$3$Type',964);feb(245,22,{3:1,34:1,22:1,245:1},bGd);var UFd,VFd,WFd,XFd,YFd,ZFd,$Fd,_Fd;var T5=tfb(jze,'GraphFeature',245,WI,dGd,cGd);var eGd;feb(11,1,{34:1,149:1},jGd,kGd,lGd,mGd);_.Fd=function nGd(a){return gGd(this,RD(a,149))};_.Fb=function oGd(a){return hGd(this,a)};_.Sg=function pGd(){return iGd(this)};_.Pg=function qGd(){return this.b};_.Hb=function rGd(){return ohb(this.b)};_.Ib=function sGd(){return this.b};sfb(jze,'Property',11);feb(671,1,fye,uGd);_.Ne=function vGd(a,b){return tGd(this,RD(a,96),RD(b,96))};_.Fb=function wGd(a){return this===a};_.Oe=function xGd(){return new Frb(this)};sfb(jze,'PropertyHolderComparator',671);feb(709,1,Ave,QGd);_.Nb=function RGd(a){Ztb(this,a);};_.Pb=function TGd(){return PGd(this)};_.Qb=function UGd(){$tb();};_.Ob=function SGd(){return !!this.a};sfb(KIe,'ElkGraphUtil/AncestorIterator',709);var Y6=ufb(sIe,'EList');feb(70,56,{20:1,31:1,56:1,16:1,15:1,70:1,61:1});_.bd=function hHd(a,b){VGd(this,a,b);};_.Fc=function iHd(a){return WGd(this,a)};_.cd=function jHd(a,b){return XGd(this,a,b)};_.Gc=function kHd(a){return YGd(this,a)};_.Ii=function lHd(){return new yMd(this)};_.Ji=function mHd(){return new BMd(this)};_.Ki=function nHd(a){return ZGd(this,a)};_.Li=function oHd(){return true};_.Mi=function pHd(a,b){};_.Ni=function qHd(){};_.Oi=function rHd(a,b){$Gd(this,a,b);};_.Pi=function sHd(a,b,c){};_.Qi=function tHd(a,b){};_.Ri=function uHd(a,b,c){};_.Fb=function vHd(a){return _Gd(this,a)};_.Hb=function wHd(){return cHd(this)};_.Si=function xHd(){return false};_.Kc=function yHd(){return new dMd(this)};_.ed=function zHd(){return new mMd(this)};_.fd=function AHd(a){var b;b=this.gc();if(a<0||a>b)throw Adb(new aMd(a,b));return new nMd(this,a)};_.Ui=function BHd(a,b){this.Ti(a,this.dd(b));};_.Mc=function CHd(a){return dHd(this,a)};_.Wi=function DHd(a,b){return b};_.hd=function EHd(a,b){return eHd(this,a,b)};_.Ib=function FHd(){return fHd(this)};_.Yi=function GHd(){return true};_.Zi=function HHd(a,b){return gHd(this,b)};sfb(sIe,'AbstractEList',70);feb(66,70,PIe,YHd,ZHd,$Hd);_.Ei=function _Hd(a,b){return IHd(this,a,b)};_.Fi=function aId(a){return JHd(this,a)};_.Gi=function bId(a,b){KHd(this,a,b);};_.Hi=function cId(a){LHd(this,a);};_.$i=function dId(a){return NHd(this,a)};_.$b=function eId(){OHd(this);};_.Hc=function fId(a){return PHd(this,a)};_.Xb=function gId(a){return QHd(this,a)};_._i=function hId(a){var b,c,d;++this.j;c=this.g==null?0:this.g.length;if(a>c){d=this.g;b=c+(c/2|0)+4;b=0){this.gd(b);return true}else {return false}};_.Xi=function LJd(a,b){return this.Dj(a,this.Zi(a,b))};_.gc=function MJd(){return this.Ej()};_.Pc=function NJd(){return this.Fj()};_.Qc=function OJd(a){return this.Gj(a)};_.Ib=function PJd(){return this.Hj()};sfb(sIe,'DelegatingEList',2093);feb(2094,2093,FJe);_.Ei=function XJd(a,b){return QJd(this,a,b)};_.Fi=function YJd(a){return this.Ei(this.Ej(),a)};_.Gi=function ZJd(a,b){RJd(this,a,b);};_.Hi=function $Jd(a){SJd(this,a);};_.Li=function _Jd(){return !this.Mj()};_.$b=function aKd(){VJd(this);};_.Ij=function bKd(a,b,c,d,e){return new aLd(this,a,b,c,d,e)};_.Jj=function cKd(a){qvd(this.jj(),a);};_.Kj=function dKd(){return null};_.Lj=function eKd(){return -1};_.jj=function fKd(){return null};_.Mj=function gKd(){return false};_.Nj=function hKd(a,b){return b};_.Oj=function iKd(a,b){return b};_.Pj=function jKd(){return false};_.Qj=function kKd(){return !this.Aj()};_.Ti=function lKd(a,b){var c,d;if(this.Pj()){d=this.Qj();c=bJd(this,a,b);this.Jj(this.Ij(7,sgb(b),c,a,d));return c}else {return bJd(this,a,b)}};_.gd=function mKd(a){var b,c,d,e;if(this.Pj()){c=null;d=this.Qj();b=this.Ij(4,e=cJd(this,a),null,a,d);if(this.Mj()&&!!e){c=this.Oj(e,c);if(!c){this.Jj(b);}else {c.nj(b);c.oj();}}else {if(!c){this.Jj(b);}else {c.nj(b);c.oj();}}return e}else {e=cJd(this,a);if(this.Mj()&&!!e){c=this.Oj(e,null);!!c&&c.oj();}return e}};_.Xi=function nKd(a,b){return WJd(this,a,b)};sfb(JHe,'DelegatingNotifyingListImpl',2094);feb(152,1,GJe);_.nj=function PKd(a){return oKd(this,a)};_.oj=function QKd(){pKd(this);};_.gj=function RKd(){return this.d};_.Kj=function SKd(){return null};_.Rj=function TKd(){return null};_.hj=function UKd(a){return -1};_.ij=function VKd(){return yKd(this)};_.jj=function WKd(){return null};_.kj=function XKd(){return HKd(this)};_.lj=function YKd(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o};_.Sj=function ZKd(){return false};_.mj=function $Kd(a){var b,c,d,e,f,g,h,i,j,k,l;switch(this.d){case 1:case 2:{e=a.gj();switch(e){case 1:case 2:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){this.g=a.ij();a.gj()==1&&(this.d=1);return true}}}}case 4:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){j=JKd(this);i=this.o<0?this.o<-2?-2-this.o-1:-1:this.o;g=a.lj();this.d=6;l=new ZHd(2);if(i<=g){WGd(l,this.n);WGd(l,a.kj());this.g=cD(WC(kE,1),Pwe,28,15,[this.o=i,g+1]);}else {WGd(l,a.kj());WGd(l,this.n);this.g=cD(WC(kE,1),Pwe,28,15,[this.o=g,i]);}this.n=l;j||(this.o=-2-this.o-1);return true}break}}break}case 6:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){j=JKd(this);g=a.lj();k=RD(this.g,53);d=$C(kE,Pwe,28,k.length+1,15,1);b=0;while(b>>0,b.toString(16)));d.a+=' (eventType: ';switch(this.d){case 1:{d.a+='SET';break}case 2:{d.a+='UNSET';break}case 3:{d.a+='ADD';break}case 5:{d.a+='ADD_MANY';break}case 4:{d.a+='REMOVE';break}case 6:{d.a+='REMOVE_MANY';break}case 7:{d.a+='MOVE';break}case 8:{d.a+='REMOVING_ADAPTER';break}case 9:{d.a+='RESOLVE';break}default:{Lhb(d,this.d);break}}IKd(this)&&(d.a+=', touch: true',d);d.a+=', position: ';Lhb(d,this.o<0?this.o<-2?-2-this.o-1:-1:this.o);d.a+=', notifier: ';Mhb(d,this.jj());d.a+=', feature: ';Mhb(d,this.Kj());d.a+=', oldValue: ';Mhb(d,HKd(this));d.a+=', newValue: ';if(this.d==6&&ZD(this.g,53)){c=RD(this.g,53);d.a+='[';for(a=0;a10){if(!this.b||this.c.j!=this.a){this.b=new btb(this);this.a=this.j;}return Zsb(this.b,a)}else {return PHd(this,a)}};_.Yi=function _Ld(){return true};_.a=0;sfb(sIe,'AbstractEList/1',966);feb(302,77,lxe,aMd);sfb(sIe,'AbstractEList/BasicIndexOutOfBoundsException',302);feb(37,1,Ave,dMd);_.Nb=function gMd(a){Ztb(this,a);};_.Xj=function eMd(){if(this.i.j!=this.f){throw Adb(new Jrb)}};_.Yj=function fMd(){return bMd(this)};_.Ob=function hMd(){return this.e!=this.i.gc()};_.Pb=function iMd(){return this.Yj()};_.Qb=function jMd(){cMd(this);};_.e=0;_.f=0;_.g=-1;sfb(sIe,'AbstractEList/EIterator',37);feb(286,37,Jve,mMd,nMd);_.Qb=function vMd(){cMd(this);};_.Rb=function oMd(a){kMd(this,a);};_.Zj=function pMd(){var b;try{b=this.d.Xb(--this.e);this.Xj();this.g=this.e;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.$j=function qMd(a){lMd(this,a);};_.Sb=function rMd(){return this.e!=0};_.Tb=function sMd(){return this.e};_.Ub=function tMd(){return this.Zj()};_.Vb=function uMd(){return this.e-1};_.Wb=function wMd(a){this.$j(a);};sfb(sIe,'AbstractEList/EListIterator',286);feb(355,37,Ave,yMd);_.Yj=function zMd(){return xMd(this)};_.Qb=function AMd(){throw Adb(new jib)};sfb(sIe,'AbstractEList/NonResolvingEIterator',355);feb(398,286,Jve,BMd,CMd);_.Rb=function DMd(a){throw Adb(new jib)};_.Yj=function EMd(){var b;try{b=this.c.Vi(this.e);this.Xj();this.g=this.e++;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.Zj=function FMd(){var b;try{b=this.c.Vi(--this.e);this.Xj();this.g=this.e;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.Qb=function GMd(){throw Adb(new jib)};_.Wb=function HMd(a){throw Adb(new jib)};sfb(sIe,'AbstractEList/NonResolvingEListIterator',398);feb(2080,70,JJe);_.Ei=function PMd(a,b){var c,d,e,f,g,h,i,j,k,l,m;e=b.gc();if(e!=0){j=RD(Ywd(this.a,4),129);k=j==null?0:j.length;m=k+e;d=NMd(this,m);l=k-a;l>0&&hib(j,a,d,a+e,l);i=b.Kc();for(g=0;gc)throw Adb(new aMd(a,c));return new wNd(this,a)};_.$b=function WMd(){var a,b;++this.j;a=RD(Ywd(this.a,4),129);b=a==null?0:a.length;Bde(this,null);$Gd(this,b,a);};_.Hc=function XMd(a){var b,c,d,e,f;b=RD(Ywd(this.a,4),129);if(b!=null){if(a!=null){for(d=b,e=0,f=d.length;e=c)throw Adb(new aMd(a,c));return b[a]};_.dd=function ZMd(a){var b,c,d;b=RD(Ywd(this.a,4),129);if(b!=null){if(a!=null){for(c=0,d=b.length;cc)throw Adb(new aMd(a,c));return new oNd(this,a)};_.Ti=function cNd(a,b){var c,d,e;c=MMd(this);e=c==null?0:c.length;if(a>=e)throw Adb(new veb(MIe+a+NIe+e));if(b>=e)throw Adb(new veb(OIe+b+NIe+e));d=c[b];if(a!=b){a0&&hib(a,0,b,0,c);return b};_.Qc=function iNd(a){var b,c,d;b=RD(Ywd(this.a,4),129);d=b==null?0:b.length;if(d>0){if(a.lengthd&&bD(a,d,null);return a};var JMd;sfb(sIe,'ArrayDelegatingEList',2080);feb(1051,37,Ave,jNd);_.Xj=function kNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};_.Qb=function lNd(){cMd(this);this.a=RD(Ywd(this.b.a,4),129);};sfb(sIe,'ArrayDelegatingEList/EIterator',1051);feb(722,286,Jve,nNd,oNd);_.Xj=function pNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};_.$j=function qNd(a){lMd(this,a);this.a=RD(Ywd(this.b.a,4),129);};_.Qb=function rNd(){cMd(this);this.a=RD(Ywd(this.b.a,4),129);};sfb(sIe,'ArrayDelegatingEList/EListIterator',722);feb(1052,355,Ave,sNd);_.Xj=function tNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};sfb(sIe,'ArrayDelegatingEList/NonResolvingEIterator',1052);feb(723,398,Jve,vNd,wNd);_.Xj=function xNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};sfb(sIe,'ArrayDelegatingEList/NonResolvingEListIterator',723);feb(615,302,lxe,yNd);sfb(sIe,'BasicEList/BasicIndexOutOfBoundsException',615);feb(710,66,PIe,zNd);_.bd=function ANd(a,b){throw Adb(new jib)};_.Fc=function BNd(a){throw Adb(new jib)};_.cd=function CNd(a,b){throw Adb(new jib)};_.Gc=function DNd(a){throw Adb(new jib)};_.$b=function ENd(){throw Adb(new jib)};_._i=function FNd(a){throw Adb(new jib)};_.Kc=function GNd(){return this.Ii()};_.ed=function HNd(){return this.Ji()};_.fd=function INd(a){return this.Ki(a)};_.Ti=function JNd(a,b){throw Adb(new jib)};_.Ui=function KNd(a,b){throw Adb(new jib)};_.gd=function LNd(a){throw Adb(new jib)};_.Mc=function MNd(a){throw Adb(new jib)};_.hd=function NNd(a,b){throw Adb(new jib)};sfb(sIe,'BasicEList/UnmodifiableEList',710);feb(721,1,{3:1,20:1,16:1,15:1,61:1,597:1});_.bd=function mOd(a,b){ONd(this,a,RD(b,44));};_.Fc=function nOd(a){return PNd(this,RD(a,44))};_.Jc=function vOd(a){xgb(this,a);};_.Xb=function wOd(a){return RD(QHd(this.c,a),136)};_.Ti=function FOd(a,b){return RD(this.c.Ti(a,b),44)};_.Ui=function GOd(a,b){eOd(this,a,RD(b,44));};_.Lc=function JOd(){return new SDb(null,new Swb(this,16))};_.gd=function KOd(a){return RD(this.c.gd(a),44)};_.hd=function MOd(a,b){return kOd(this,a,RD(b,44))};_.jd=function OOd(a){tvb(this,a);};_.Nc=function POd(){return new Swb(this,16)};_.Oc=function QOd(){return new SDb(null,new Swb(this,16))};_.cd=function oOd(a,b){return this.c.cd(a,b)};_.Gc=function pOd(a){return this.c.Gc(a)};_.$b=function qOd(){this.c.$b();};_.Hc=function rOd(a){return this.c.Hc(a)};_.Ic=function sOd(a){return Be(this.c,a)};_._j=function tOd(){var a,b,c;if(this.d==null){this.d=$C(D6,KJe,66,2*this.f+1,0,1);c=this.e;this.f=0;for(b=this.c.Kc();b.e!=b.i.gc();){a=RD(b.Yj(),136);UNd(this,a);}this.e=c;}};_.Fb=function uOd(a){return ZNd(this,a)};_.Hb=function xOd(){return cHd(this.c)};_.dd=function yOd(a){return this.c.dd(a)};_.ak=function zOd(){this.c=new YOd(this);};_.dc=function AOd(){return this.f==0};_.Kc=function BOd(){return this.c.Kc()};_.ed=function COd(){return this.c.ed()};_.fd=function DOd(a){return this.c.fd(a)};_.bk=function EOd(){return dOd(this)};_.ck=function HOd(a,b,c){return new ZPd(a,b,c)};_.dk=function IOd(){return new cPd};_.Mc=function LOd(a){return hOd(this,a)};_.gc=function NOd(){return this.f};_.kd=function ROd(a,b){return new Rkb(this.c,a,b)};_.Pc=function SOd(){return this.c.Pc()};_.Qc=function TOd(a){return this.c.Qc(a)};_.Ib=function UOd(){return fHd(this.c)};_.e=0;_.f=0;sfb(sIe,'BasicEMap',721);feb(1046,66,PIe,YOd);_.Mi=function ZOd(a,b){VOd(this,RD(b,136));};_.Pi=function _Od(a,b,c){var d;++(d=this,RD(b,136),d).a.e;};_.Qi=function aPd(a,b){WOd(this,RD(b,136));};_.Ri=function bPd(a,b,c){XOd(this,RD(b,136),RD(c,136));};_.Oi=function $Od(a,b){TNd(this.a);};sfb(sIe,'BasicEMap/1',1046);feb(1047,66,PIe,cPd);_.aj=function dPd(a){return $C(N6,LJe,621,a,0,1)};sfb(sIe,'BasicEMap/2',1047);feb(1048,Eve,Fve,ePd);_.$b=function fPd(){this.a.c.$b();};_.Hc=function gPd(a){return QNd(this.a,a)};_.Kc=function hPd(){return this.a.f==0?(jQd(),iQd.a):new DPd(this.a)};_.Mc=function iPd(a){var b;b=this.a.f;jOd(this.a,a);return this.a.f!=b};_.gc=function jPd(){return this.a.f};sfb(sIe,'BasicEMap/3',1048);feb(1049,31,Dve,kPd);_.$b=function lPd(){this.a.c.$b();};_.Hc=function mPd(a){return RNd(this.a,a)};_.Kc=function nPd(){return this.a.f==0?(jQd(),iQd.a):new FPd(this.a)};_.gc=function oPd(){return this.a.f};sfb(sIe,'BasicEMap/4',1049);feb(1050,Eve,Fve,qPd);_.$b=function rPd(){this.a.c.$b();};_.Hc=function sPd(a){var b,c,d,e,f,g,h,i,j;if(this.a.f>0&&ZD(a,44)){this.a._j();i=RD(a,44);h=i.ld();e=h==null?0:tb(h);f=bOd(this.a,e);b=this.a.d[f];if(b){c=RD(b.g,379);j=b.i;for(g=0;g'+this.c};_.a=0;var N6=sfb(sIe,'BasicEMap/EntryImpl',621);feb(546,1,{},hQd);sfb(sIe,'BasicEMap/View',546);var iQd;feb(783,1,{});_.Fb=function xQd(a){return Rt((yob(),vob),a)};_.Hb=function yQd(){return Cob((yob(),vob))};_.Ib=function zQd(){return Fe((yob(),vob))};sfb(sIe,'ECollections/BasicEmptyUnmodifiableEList',783);feb(1348,1,Jve,AQd);_.Nb=function CQd(a){Ztb(this,a);};_.Rb=function BQd(a){throw Adb(new jib)};_.Ob=function DQd(){return false};_.Sb=function EQd(){return false};_.Pb=function FQd(){throw Adb(new Dvb)};_.Tb=function GQd(){return 0};_.Ub=function HQd(){throw Adb(new Dvb)};_.Vb=function IQd(){return -1};_.Qb=function JQd(){throw Adb(new jib)};_.Wb=function KQd(a){throw Adb(new jib)};sfb(sIe,'ECollections/BasicEmptyUnmodifiableEList/1',1348);feb(1346,783,{20:1,16:1,15:1,61:1},LQd);_.bd=function MQd(a,b){mQd();};_.Fc=function NQd(a){return nQd()};_.cd=function OQd(a,b){return oQd()};_.Gc=function PQd(a){return pQd()};_.$b=function QQd(){qQd();};_.Hc=function RQd(a){return false};_.Ic=function SQd(a){return false};_.Jc=function TQd(a){xgb(this,a);};_.Xb=function UQd(a){return Iob((yob(),a)),null};_.dd=function VQd(a){return -1};_.dc=function WQd(){return true};_.Kc=function XQd(){return this.a};_.ed=function YQd(){return this.a};_.fd=function ZQd(a){return this.a};_.Ti=function $Qd(a,b){return rQd()};_.Ui=function _Qd(a,b){sQd();};_.Lc=function aRd(){return new SDb(null,new Swb(this,16))};_.gd=function bRd(a){return tQd()};_.Mc=function cRd(a){return uQd()};_.hd=function dRd(a,b){return vQd()};_.gc=function eRd(){return 0};_.jd=function fRd(a){tvb(this,a);};_.Nc=function gRd(){return new Swb(this,16)};_.Oc=function hRd(){return new SDb(null,new Swb(this,16))};_.kd=function iRd(a,b){return yob(),new Rkb(vob,a,b)};_.Pc=function jRd(){return De((yob(),vob))};_.Qc=function kRd(a){return yob(),Ee(vob,a)};sfb(sIe,'ECollections/EmptyUnmodifiableEList',1346);feb(1347,783,{20:1,16:1,15:1,61:1,597:1},lRd);_.bd=function mRd(a,b){mQd();};_.Fc=function nRd(a){return nQd()};_.cd=function oRd(a,b){return oQd()};_.Gc=function pRd(a){return pQd()};_.$b=function qRd(){qQd();};_.Hc=function rRd(a){return false};_.Ic=function sRd(a){return false};_.Jc=function tRd(a){xgb(this,a);};_.Xb=function uRd(a){return Iob((yob(),a)),null};_.dd=function vRd(a){return -1};_.dc=function wRd(){return true};_.Kc=function xRd(){return this.a};_.ed=function yRd(){return this.a};_.fd=function zRd(a){return this.a};_.Ti=function BRd(a,b){return rQd()};_.Ui=function CRd(a,b){sQd();};_.Lc=function DRd(){return new SDb(null,new Swb(this,16))};_.gd=function ERd(a){return tQd()};_.Mc=function FRd(a){return uQd()};_.hd=function GRd(a,b){return vQd()};_.gc=function HRd(){return 0};_.jd=function IRd(a){tvb(this,a);};_.Nc=function JRd(){return new Swb(this,16)};_.Oc=function KRd(){return new SDb(null,new Swb(this,16))};_.kd=function LRd(a,b){return yob(),new Rkb(vob,a,b)};_.Pc=function MRd(){return De((yob(),vob))};_.Qc=function NRd(a){return yob(),Ee(vob,a)};_.bk=function ARd(){return yob(),yob(),wob};sfb(sIe,'ECollections/EmptyUnmodifiableEMap',1347);var Z6=ufb(sIe,'Enumerator');var ORd;feb(288,1,{288:1},lSd);_.Fb=function pSd(a){var b;if(this===a)return true;if(!ZD(a,288))return false;b=RD(a,288);return this.f==b.f&&rSd(this.i,b.i)&&qSd(this.a,(this.f&256)!=0?(b.f&256)!=0?b.a:null:(b.f&256)!=0?null:b.a)&&qSd(this.d,b.d)&&qSd(this.g,b.g)&&qSd(this.e,b.e)&&iSd(this,b)};_.Hb=function uSd(){return this.f};_.Ib=function CSd(){return jSd(this)};_.f=0;var SRd=0,TRd=0,URd=0,VRd=0,WRd=0,XRd=0,YRd=0,ZRd=0,$Rd=0,_Rd,aSd=0,bSd=0,cSd=0,dSd=0,eSd,fSd;sfb(sIe,'URI',288);feb(1121,45,Hxe,MSd);_.zc=function NSd(a,b){return RD($jb(this,WD(a),RD(b,288)),288)};sfb(sIe,'URI/URICache',1121);feb(506,66,PIe,OSd,PSd);_.Si=function QSd(){return true};sfb(sIe,'UniqueEList',506);feb(590,63,swe,RSd);sfb(sIe,'WrappedException',590);var f7=ufb(vHe,OJe);var A7=ufb(vHe,PJe);var y7=ufb(vHe,QJe);var g7=ufb(vHe,RJe);var i7=ufb(vHe,SJe);var h7=ufb(vHe,'EClass');var k7=ufb(vHe,'EDataType');var SSd;feb(1233,45,Hxe,VSd);_.xc=function WSd(a){return bE(a)?Xjb(this,a):Wd(qtb(this.f,a))};sfb(vHe,'EDataType/Internal/ConversionDelegate/Factory/Registry/Impl',1233);var m7=ufb(vHe,'EEnum');var l7=ufb(vHe,TJe);var o7=ufb(vHe,UJe);var s7=ufb(vHe,VJe);var XSd;var u7=ufb(vHe,WJe);var v7=ufb(vHe,XJe);feb(1042,1,{},_Sd);_.Ib=function aTd(){return 'NIL'};sfb(vHe,'EStructuralFeature/Internal/DynamicValueHolder/1',1042);var bTd;feb(1041,45,Hxe,eTd);_.xc=function fTd(a){return bE(a)?Xjb(this,a):Wd(qtb(this.f,a))};sfb(vHe,'EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl',1041);var z7=ufb(vHe,YJe);var B7=ufb(vHe,'EValidator/PatternMatcher');var gTd;var iTd;var kTd;var mTd,nTd,oTd,pTd,qTd,rTd,sTd,tTd,uTd,vTd,wTd,xTd,yTd,zTd,ATd,BTd,CTd,DTd,ETd,FTd,GTd,HTd,ITd;var Jbb=ufb(ZJe,'FeatureMap/Entry');feb(545,1,{76:1},KTd);_.Lk=function LTd(){return this.a};_.md=function MTd(){return this.b};sfb(SHe,'BasicEObjectImpl/1',545);feb(1040,1,$Je,NTd);_.Fk=function OTd(a){return Fvd(this.a,this.b,a)};_.Qj=function PTd(){return Lvd(this.a,this.b)};_.Wb=function QTd(a){Xvd(this.a,this.b,a);};_.Gk=function RTd(){_vd(this.a,this.b);};sfb(SHe,'BasicEObjectImpl/4',1040);feb(2081,1,{114:1});_.Mk=function UTd(a){this.e=a==0?STd:$C(jJ,rve,1,a,5,1);};_.li=function VTd(a){return this.e[a]};_.mi=function WTd(a,b){this.e[a]=b;};_.ni=function XTd(a){this.e[a]=null;};_.Nk=function YTd(){return this.c};_.Ok=function ZTd(){throw Adb(new jib)};_.Pk=function $Td(){throw Adb(new jib)};_.Qk=function _Td(){return this.d};_.Rk=function aUd(){return this.e!=null};_.Sk=function bUd(a){this.c=a;};_.Tk=function cUd(a){throw Adb(new jib)};_.Uk=function dUd(a){throw Adb(new jib)};_.Vk=function eUd(a){this.d=a;};var STd;sfb(SHe,'BasicEObjectImpl/EPropertiesHolderBaseImpl',2081);feb(192,2081,{114:1},fUd);_.Ok=function gUd(){return this.a};_.Pk=function hUd(){return this.b};_.Tk=function iUd(a){this.a=a;};_.Uk=function jUd(a){this.b=a;};sfb(SHe,'BasicEObjectImpl/EPropertiesHolderImpl',192);feb(516,99,RHe,kUd);_.uh=function lUd(){return this.f};_.zh=function mUd(){return this.k};_.Bh=function nUd(a,b){this.g=a;this.i=b;};_.Dh=function oUd(){return (this.j&2)==0?this.ii():this.$h().Nk()};_.Fh=function pUd(){return this.i};_.wh=function qUd(){return (this.j&1)!=0};_.Ph=function rUd(){return this.g};_.Vh=function sUd(){return (this.j&4)!=0};_.$h=function tUd(){return !this.k&&(this.k=new fUd),this.k};_.ci=function uUd(a){this.$h().Sk(a);a?(this.j|=2):(this.j&=-3);};_.ei=function vUd(a){this.$h().Uk(a);a?(this.j|=4):(this.j&=-5);};_.ii=function wUd(){return (lTd(),kTd).S};_.i=0;_.j=1;sfb(SHe,'EObjectImpl',516);feb(798,516,{110:1,94:1,93:1,58:1,114:1,54:1,99:1},zUd);_.li=function AUd(a){return this.e[a]};_.mi=function BUd(a,b){this.e[a]=b;};_.ni=function CUd(a){this.e[a]=null;};_.Dh=function DUd(){return this.d};_.Ih=function EUd(a){return BYd(this.d,a)};_.Kh=function FUd(){return this.d};_.Oh=function GUd(){return this.e!=null};_.$h=function HUd(){!this.k&&(this.k=new VUd);return this.k};_.ci=function IUd(a){this.d=a;};_.hi=function JUd(){var a;if(this.e==null){a=AYd(this.d);this.e=a==0?xUd:$C(jJ,rve,1,a,5,1);}return this};_.ji=function KUd(){return 0};var xUd;sfb(SHe,'DynamicEObjectImpl',798);feb(1522,798,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1},LUd);_.Fb=function NUd(a){return this===a};_.Hb=function RUd(){return kFb(this)};_.ci=function MUd(a){this.d=a;this.b=wYd(a,'key');this.c=wYd(a,aIe);};_.Bi=function OUd(){var a;if(this.a==-1){a=Gvd(this,this.b);this.a=a==null?0:tb(a);}return this.a};_.ld=function PUd(){return Gvd(this,this.b)};_.md=function QUd(){return Gvd(this,this.c)};_.Ci=function SUd(a){this.a=a;};_.Di=function TUd(a){Xvd(this,this.b,a);};_.nd=function UUd(a){var b;b=Gvd(this,this.c);Xvd(this,this.c,a);return b};_.a=0;sfb(SHe,'DynamicEObjectImpl/BasicEMapEntry',1522);feb(1523,1,{114:1},VUd);_.Mk=function WUd(a){throw Adb(new jib)};_.li=function XUd(a){throw Adb(new jib)};_.mi=function YUd(a,b){throw Adb(new jib)};_.ni=function ZUd(a){throw Adb(new jib)};_.Nk=function $Ud(){throw Adb(new jib)};_.Ok=function _Ud(){return this.a};_.Pk=function aVd(){return this.b};_.Qk=function bVd(){return this.c};_.Rk=function cVd(){throw Adb(new jib)};_.Sk=function dVd(a){throw Adb(new jib)};_.Tk=function eVd(a){this.a=a;};_.Uk=function fVd(a){this.b=a;};_.Vk=function gVd(a){this.c=a;};sfb(SHe,'DynamicEObjectImpl/DynamicEPropertiesHolderImpl',1523);feb(519,158,{110:1,94:1,93:1,598:1,155:1,58:1,114:1,54:1,99:1,519:1,158:1,119:1,120:1},pVd);_.Ah=function qVd(a){return iVd(this,a)};_.Lh=function rVd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.d;case 2:return c?(!this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),this.b):(!this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),dOd(this.b));case 3:return kVd(this);case 4:return !this.a&&(this.a=new XZd(r7,this,4)),this.a;case 5:return !this.c&&(this.c=new zie(r7,this,5)),this.c;}return zvd(this,a-AYd((JTd(),mTd)),vYd((d=RD(Ywd(this,16),29),!d?mTd:d),a),b,c)};_.Sh=function sVd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 3:!!this.Cb&&(c=(e=this.Db>>16,e>=0?iVd(this,c):this.Cb.Th(this,-1-e,null,c)));return hVd(this,RD(a,155),c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),mTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),mTd)),a,c)};_.Uh=function tVd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 2:return !this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),BVd(this.b,a,c);case 3:return hVd(this,null,c);case 4:return !this.a&&(this.a=new XZd(r7,this,4)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),mTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),mTd)),a,c)};_.Wh=function uVd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return !!this.b&&this.b.f!=0;case 3:return !!kVd(this);case 4:return !!this.a&&this.a.i!=0;case 5:return !!this.c&&this.c.i!=0;}return Avd(this,a-AYd((JTd(),mTd)),vYd((b=RD(Ywd(this,16),29),!b?mTd:b),a))};_.bi=function vVd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:mVd(this,WD(b));return;case 2:!this.b&&(this.b=new SVd((JTd(),FTd),C8,this));CVd(this.b,b);return;case 3:lVd(this,RD(b,155));return;case 4:!this.a&&(this.a=new XZd(r7,this,4));sLd(this.a);!this.a&&(this.a=new XZd(r7,this,4));YGd(this.a,RD(b,16));return;case 5:!this.c&&(this.c=new zie(r7,this,5));sLd(this.c);!this.c&&(this.c=new zie(r7,this,5));YGd(this.c,RD(b,16));return;}Bvd(this,a-AYd((JTd(),mTd)),vYd((c=RD(Ywd(this,16),29),!c?mTd:c),a),b);};_.ii=function wVd(){return JTd(),mTd};_.ki=function xVd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:nVd(this,null);return;case 2:!this.b&&(this.b=new SVd((JTd(),FTd),C8,this));this.b.c.$b();return;case 3:lVd(this,null);return;case 4:!this.a&&(this.a=new XZd(r7,this,4));sLd(this.a);return;case 5:!this.c&&(this.c=new zie(r7,this,5));sLd(this.c);return;}Cvd(this,a-AYd((JTd(),mTd)),vYd((b=RD(Ywd(this,16),29),!b?mTd:b),a));};_.Ib=function yVd(){return oVd(this)};_.d=null;sfb(SHe,'EAnnotationImpl',519);feb(141,721,_Je,DVd);_.Gi=function EVd(a,b){zVd(this,a,RD(b,44));};_.Wk=function FVd(a,b){return AVd(this,RD(a,44),b)};_.$i=function GVd(a){return RD(RD(this.c,71).$i(a),136)};_.Ii=function HVd(){return RD(this.c,71).Ii()};_.Ji=function IVd(){return RD(this.c,71).Ji()};_.Ki=function JVd(a){return RD(this.c,71).Ki(a)};_.Xk=function KVd(a,b){return BVd(this,a,b)};_.Fk=function LVd(a){return RD(this.c,79).Fk(a)};_.ak=function MVd(){};_.Qj=function NVd(){return RD(this.c,79).Qj()};_.ck=function OVd(a,b,c){var d;d=RD(BXd(this.b).wi().si(this.b),136);d.Ci(a);d.Di(b);d.nd(c);return d};_.dk=function PVd(){return new uje(this)};_.Wb=function QVd(a){CVd(this,a);};_.Gk=function RVd(){RD(this.c,79).Gk();};sfb(ZJe,'EcoreEMap',141);feb(165,141,_Je,SVd);_._j=function TVd(){var a,b,c,d,e,f;if(this.d==null){f=$C(D6,KJe,66,2*this.f+1,0,1);for(c=this.c.Kc();c.e!=c.i.gc();){b=RD(c.Yj(),136);d=b.Bi();e=(d&lve)%f.length;a=f[e];!a&&(a=f[e]=new uje(this));a.Fc(b);}this.d=f;}};sfb(SHe,'EAnnotationImpl/1',165);feb(292,448,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,481:1,54:1,99:1,158:1,292:1,119:1,120:1});_.Lh=function eWd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),this.Jk()?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Uh=function fWd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function gWd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.Jk();case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function hWd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:this.ui(WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:this.Zk(RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function iWd(){return JTd(),HTd};_.ki=function jWd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:this.ui(null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.Zk(1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function kWd(){WVd(this);this.Bb|=1;};_.Hk=function lWd(){return WVd(this)};_.Ik=function mWd(){return this.t};_.Jk=function nWd(){var a;return a=this.t,a>1||a==-1};_.Si=function oWd(){return (this.Bb&512)!=0};_.Yk=function pWd(a,b){return ZVd(this,a,b)};_.Zk=function qWd(a){bWd(this,a);};_.Ib=function rWd(){return cWd(this)};_.s=0;_.t=1;sfb(SHe,'ETypedElementImpl',292);feb(462,292,{110:1,94:1,93:1,155:1,197:1,58:1,179:1,69:1,114:1,481:1,54:1,99:1,158:1,462:1,292:1,119:1,120:1,692:1});_.Ah=function IWd(a){return sWd(this,a)};_.Lh=function JWd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),this.Jk()?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function KWd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 17:!!this.Cb&&(c=(e=this.Db>>16,e>=0?sWd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,17,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),f.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function LWd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 17:return xvd(this,null,17,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function MWd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.Jk();case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function NWd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:this.Zk(RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function OWd(){return JTd(),GTd};_.ki=function PWd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.Zk(1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function QWd(){Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.pk=function RWd(){return this.f};_.ik=function SWd(){return tWd(this)};_.qk=function TWd(){return uWd(this)};_.uk=function UWd(){return null};_.$k=function VWd(){return this.k};_.Lj=function WWd(){return this.n};_.vk=function XWd(){return vWd(this)};_.wk=function YWd(){var a,b,c,d,e,f,g,h,i;if(!this.p){c=uWd(this);(c.i==null&&rYd(c),c.i).length;d=this.uk();!!d&&AYd(uWd(d));e=WVd(this);g=e.kk();a=!g?null:(g.i&1)!=0?g==xdb?QI:g==kE?bJ:g==jE?ZI:g==iE?VI:g==lE?eJ:g==wdb?lJ:g==gE?RI:SI:g;b=tWd(this);h=e.ik();Mje(this);(this.Bb&Ove)!=0&&(!!(f=Tee((lke(),jke),c))&&f!=this||!!(f=zfe(Qee(jke,this))))?(this.p=new Z6d(this,f)):this.Jk()?this.al()?!d?(this.Bb&bKe)!=0?!a?this.bl()?(this.p=new i7d(42,this)):(this.p=new i7d(0,this)):a==UK?(this.p=new g7d(50,O6,this)):this.bl()?(this.p=new g7d(43,a,this)):(this.p=new g7d(1,a,this)):!a?this.bl()?(this.p=new i7d(44,this)):(this.p=new i7d(2,this)):a==UK?(this.p=new g7d(41,O6,this)):this.bl()?(this.p=new g7d(45,a,this)):(this.p=new g7d(3,a,this)):(this.Bb&bKe)!=0?!a?this.bl()?(this.p=new j7d(46,this,d)):(this.p=new j7d(4,this,d)):this.bl()?(this.p=new h7d(47,a,this,d)):(this.p=new h7d(5,a,this,d)):!a?this.bl()?(this.p=new j7d(48,this,d)):(this.p=new j7d(6,this,d)):this.bl()?(this.p=new h7d(49,a,this,d)):(this.p=new h7d(7,a,this,d)):ZD(e,156)?a==Jbb?(this.p=new i7d(40,this)):(this.Bb&512)!=0?(this.Bb&bKe)!=0?!a?(this.p=new i7d(8,this)):(this.p=new g7d(9,a,this)):!a?(this.p=new i7d(10,this)):(this.p=new g7d(11,a,this)):(this.Bb&bKe)!=0?!a?(this.p=new i7d(12,this)):(this.p=new g7d(13,a,this)):!a?(this.p=new i7d(14,this)):(this.p=new g7d(15,a,this)):!d?this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new i7d(16,this)):(this.p=new g7d(17,a,this)):!a?(this.p=new i7d(18,this)):(this.p=new g7d(19,a,this)):(this.Bb&bKe)!=0?!a?(this.p=new i7d(20,this)):(this.p=new g7d(21,a,this)):!a?(this.p=new i7d(22,this)):(this.p=new g7d(23,a,this)):(i=d.t,i>1||i==-1?this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new j7d(24,this,d)):(this.p=new h7d(25,a,this,d)):!a?(this.p=new j7d(26,this,d)):(this.p=new h7d(27,a,this,d)):(this.Bb&bKe)!=0?!a?(this.p=new j7d(28,this,d)):(this.p=new h7d(29,a,this,d)):!a?(this.p=new j7d(30,this,d)):(this.p=new h7d(31,a,this,d)):this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new j7d(32,this,d)):(this.p=new h7d(33,a,this,d)):!a?(this.p=new j7d(34,this,d)):(this.p=new h7d(35,a,this,d)):(this.Bb&bKe)!=0?!a?(this.p=new j7d(36,this,d)):(this.p=new h7d(37,a,this,d)):!a?(this.p=new j7d(38,this,d)):(this.p=new h7d(39,a,this,d))):this._k()?this.bl()?(this.p=new K7d(RD(e,29),this,d)):(this.p=new C7d(RD(e,29),this,d)):ZD(e,156)?a==Jbb?(this.p=new i7d(40,this)):(this.Bb&bKe)!=0?!a?(this.p=new J8d(RD(e,156),b,h,this)):(this.p=new L8d(b,h,this,(a8d(),g==kE?Y7d:g==xdb?T7d:g==lE?Z7d:g==jE?X7d:g==iE?W7d:g==wdb?_7d:g==gE?U7d:g==hE?V7d:$7d))):!a?(this.p=new C8d(RD(e,156),b,h,this)):(this.p=new E8d(b,h,this,(a8d(),g==kE?Y7d:g==xdb?T7d:g==lE?Z7d:g==jE?X7d:g==iE?W7d:g==wdb?_7d:g==gE?U7d:g==hE?V7d:$7d))):this.al()?!d?(this.Bb&bKe)!=0?this.bl()?(this.p=new d9d(RD(e,29),this)):(this.p=new b9d(RD(e,29),this)):this.bl()?(this.p=new _8d(RD(e,29),this)):(this.p=new Z8d(RD(e,29),this)):(this.Bb&bKe)!=0?this.bl()?(this.p=new l9d(RD(e,29),this,d)):(this.p=new j9d(RD(e,29),this,d)):this.bl()?(this.p=new h9d(RD(e,29),this,d)):(this.p=new f9d(RD(e,29),this,d)):this.bl()?!d?(this.Bb&bKe)!=0?(this.p=new p9d(RD(e,29),this)):(this.p=new n9d(RD(e,29),this)):(this.Bb&bKe)!=0?(this.p=new t9d(RD(e,29),this,d)):(this.p=new r9d(RD(e,29),this,d)):!d?(this.Bb&bKe)!=0?(this.p=new v9d(RD(e,29),this)):(this.p=new N8d(RD(e,29),this)):(this.Bb&bKe)!=0?(this.p=new z9d(RD(e,29),this,d)):(this.p=new x9d(RD(e,29),this,d));}return this.p};_.rk=function ZWd(){return (this.Bb&gwe)!=0};_._k=function $Wd(){return false};_.al=function _Wd(){return false};_.sk=function aXd(){return (this.Bb&Ove)!=0};_.xk=function bXd(){return wWd(this)};_.bl=function cXd(){return false};_.tk=function dXd(){return (this.Bb&bKe)!=0};_.cl=function eXd(a){this.k=a;};_.ui=function fXd(a){CWd(this,a);};_.Ib=function gXd(){return GWd(this)};_.e=false;_.n=0;sfb(SHe,'EStructuralFeatureImpl',462);feb(331,462,{110:1,94:1,93:1,35:1,155:1,197:1,58:1,179:1,69:1,114:1,481:1,54:1,99:1,331:1,158:1,462:1,292:1,119:1,120:1,692:1},mXd);_.Lh=function nXd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),jXd(this)?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);case 18:return Geb(),(this.Bb&QHe)!=0?true:false;case 19:if(b)return iXd(this);return hXd(this);}return zvd(this,a-AYd((JTd(),nTd)),vYd((d=RD(Ywd(this,16),29),!d?nTd:d),a),b,c)};_.Wh=function oXd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return jXd(this);case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);case 18:return (this.Bb&QHe)!=0;case 19:return !!hXd(this);}return Avd(this,a-AYd((JTd(),nTd)),vYd((b=RD(Ywd(this,16),29),!b?nTd:b),a))};_.bi=function pXd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:lXd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;case 18:kXd(this,Heb(TD(b)));return;}Bvd(this,a-AYd((JTd(),nTd)),vYd((c=RD(Ywd(this,16),29),!c?nTd:c),a),b);};_.ii=function qXd(){return JTd(),nTd};_.ki=function rXd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.b=0;bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;case 18:kXd(this,false);return;}Cvd(this,a-AYd((JTd(),nTd)),vYd((b=RD(Ywd(this,16),29),!b?nTd:b),a));};_.pi=function sXd(){iXd(this);Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.Jk=function tXd(){return jXd(this)};_.Yk=function uXd(a,b){this.b=0;this.a=null;return ZVd(this,a,b)};_.Zk=function vXd(a){lXd(this,a);};_.Ib=function wXd(){var a;if((this.Db&64)!=0)return GWd(this);a=new Shb(GWd(this));a.a+=' (iD: ';Ohb(a,(this.Bb&QHe)!=0);a.a+=')';return a.a};_.b=0;sfb(SHe,'EAttributeImpl',331);feb(364,448,{110:1,94:1,93:1,142:1,155:1,197:1,58:1,114:1,54:1,99:1,364:1,158:1,119:1,120:1,691:1});_.dl=function NXd(a){return a.Dh()==this};_.Ah=function OXd(a){return AXd(this,a)};_.Bh=function PXd(a,b){this.w=null;this.Db=b<<16|this.Db&255;this.Cb=a;};_.Lh=function QXd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return DXd(this);case 4:return this.ik();case 5:return this.F;case 6:if(b)return BXd(this);return xXd(this);case 7:return !this.A&&(this.A=new iie(z7,this,7)),this.A;}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function RXd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),f.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function SXd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function TXd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return this.ik()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function UXd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function VXd(){return JTd(),pTd};_.ki=function WXd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.hk=function XXd(){var a;return this.G==-1&&(this.G=(a=BXd(this),a?fZd(a.vi(),this):-1)),this.G};_.ik=function YXd(){return null};_.jk=function ZXd(){return BXd(this)};_.el=function $Xd(){return this.v};_.kk=function _Xd(){return DXd(this)};_.lk=function aYd(){return this.D!=null?this.D:this.B};_.mk=function bYd(){return this.F};_.fk=function cYd(a){return FXd(this,a)};_.fl=function dYd(a){this.v=a;};_.gl=function eYd(a){GXd(this,a);};_.hl=function fYd(a){this.C=a;};_.ui=function gYd(a){LXd(this,a);};_.Ib=function hYd(){return MXd(this)};_.C=null;_.D=null;_.G=-1;sfb(SHe,'EClassifierImpl',364);feb(90,364,{110:1,94:1,93:1,29:1,142:1,155:1,197:1,58:1,114:1,54:1,99:1,90:1,364:1,158:1,482:1,119:1,120:1,691:1},HYd);_.dl=function IYd(a){return DYd(this,a.Dh())};_.Lh=function JYd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return DXd(this);case 4:return null;case 5:return this.F;case 6:if(b)return BXd(this);return xXd(this);case 7:return !this.A&&(this.A=new iie(z7,this,7)),this.A;case 8:return Geb(),(this.Bb&256)!=0?true:false;case 9:return Geb(),(this.Bb&512)!=0?true:false;case 10:return zYd(this);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),this.q;case 12:return mYd(this);case 13:return qYd(this);case 14:return qYd(this),this.r;case 15:return mYd(this),this.k;case 16:return nYd(this);case 17:return pYd(this);case 18:return rYd(this);case 19:return sYd(this);case 20:return mYd(this),this.o;case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),this.s;case 22:return tYd(this);case 23:return oYd(this);}return zvd(this,a-AYd((JTd(),oTd)),vYd((d=RD(Ywd(this,16),29),!d?oTd:d),a),b,c)};_.Sh=function KYd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),qLd(this.q,a,c);case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),qLd(this.s,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),oTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),oTd)),a,c)};_.Uh=function LYd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),rLd(this.q,a,c);case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),rLd(this.s,a,c);case 22:return rLd(tYd(this),a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),oTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),oTd)),a,c)};_.Wh=function MYd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return false;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;case 8:return (this.Bb&256)!=0;case 9:return (this.Bb&512)!=0;case 10:return !!this.u&&tYd(this.u.a).i!=0&&!(!!this.n&&d$d(this.n));case 11:return !!this.q&&this.q.i!=0;case 12:return mYd(this).i!=0;case 13:return qYd(this).i!=0;case 14:return qYd(this),this.r.i!=0;case 15:return mYd(this),this.k.i!=0;case 16:return nYd(this).i!=0;case 17:return pYd(this).i!=0;case 18:return rYd(this).i!=0;case 19:return sYd(this).i!=0;case 20:return mYd(this),!!this.o;case 21:return !!this.s&&this.s.i!=0;case 22:return !!this.n&&d$d(this.n);case 23:return oYd(this).i!=0;}return Avd(this,a-AYd((JTd(),oTd)),vYd((b=RD(Ywd(this,16),29),!b?oTd:b),a))};_.Zh=function NYd(a){var b;b=this.i==null||!!this.q&&this.q.i!=0?null:wYd(this,a);return b?b:_zd(this,a)};_.bi=function OYd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;case 8:EYd(this,Heb(TD(b)));return;case 9:FYd(this,Heb(TD(b)));return;case 10:VJd(zYd(this));YGd(zYd(this),RD(b,16));return;case 11:!this.q&&(this.q=new C5d(s7,this,11,10));sLd(this.q);!this.q&&(this.q=new C5d(s7,this,11,10));YGd(this.q,RD(b,16));return;case 21:!this.s&&(this.s=new C5d(y7,this,21,17));sLd(this.s);!this.s&&(this.s=new C5d(y7,this,21,17));YGd(this.s,RD(b,16));return;case 22:sLd(tYd(this));YGd(tYd(this),RD(b,16));return;}Bvd(this,a-AYd((JTd(),oTd)),vYd((c=RD(Ywd(this,16),29),!c?oTd:c),a),b);};_.ii=function PYd(){return JTd(),oTd};_.ki=function QYd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;case 8:EYd(this,false);return;case 9:FYd(this,false);return;case 10:!!this.u&&VJd(this.u);return;case 11:!this.q&&(this.q=new C5d(s7,this,11,10));sLd(this.q);return;case 21:!this.s&&(this.s=new C5d(y7,this,21,17));sLd(this.s);return;case 22:!!this.n&&sLd(this.n);return;}Cvd(this,a-AYd((JTd(),oTd)),vYd((b=RD(Ywd(this,16),29),!b?oTd:b),a));};_.pi=function RYd(){var a,b;mYd(this);qYd(this);nYd(this);pYd(this);rYd(this);sYd(this);oYd(this);OHd(q$d(yYd(this)));if(this.s){for(a=0,b=this.s.i;a=0;--b){QHd(this,b);}}return XHd(this,a)};_.Gk=function NZd(){sLd(this);};_.Zi=function OZd(a,b){return jZd(this,a,b)};sfb(ZJe,'EcoreEList',632);feb(505,632,oKe,PZd);_.Li=function QZd(){return false};_.Lj=function RZd(){return this.c};_.Mj=function SZd(){return false};_.ol=function TZd(){return true};_.Si=function UZd(){return true};_.Wi=function VZd(a,b){return b};_.Yi=function WZd(){return false};_.c=0;sfb(ZJe,'EObjectEList',505);feb(83,505,oKe,XZd);_.Mj=function YZd(){return true};_.ml=function ZZd(){return false};_.al=function $Zd(){return true};sfb(ZJe,'EObjectContainmentEList',83);feb(555,83,oKe,_Zd);_.Ni=function a$d(){this.b=true;};_.Qj=function b$d(){return this.b};_.Gk=function c$d(){var a;sLd(this);if(Mvd(this.e)){a=this.b;this.b=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.b=false;}};_.b=false;sfb(ZJe,'EObjectContainmentEList/Unsettable',555);feb(1161,555,oKe,h$d);_.Ti=function l$d(a,b){var c,d;return c=RD(uLd(this,a,b),89),Mvd(this.e)&&eZd(this,new c4d(this.a,7,(JTd(),qTd),sgb(b),(d=c.c,ZD(d,90)?RD(d,29):zTd),a)),c};_.Uj=function m$d(a,b){return e$d(this,RD(a,89),b)};_.Vj=function n$d(a,b){return f$d(this,RD(a,89),b)};_.Wj=function o$d(a,b,c){return g$d(this,RD(a,89),RD(b,89),c)};_.Ij=function i$d(a,b,c,d,e){switch(a){case 3:{return dZd(this,a,b,c,d,this.i>1)}case 5:{return dZd(this,a,b,c,d,this.i-RD(c,15).gc()>0)}default:{return new P3d(this.e,a,this.c,b,c,d,true)}}};_.Tj=function j$d(){return true};_.Qj=function k$d(){return d$d(this)};_.Gk=function p$d(){sLd(this);};sfb(SHe,'EClassImpl/1',1161);feb(1175,1174,EJe);_.dj=function t$d(a){var b,c,d,e,f,g,h;c=a.gj();if(c!=8){d=s$d(a);if(d==0){switch(c){case 1:case 9:{h=a.kj();if(h!=null){b=yYd(RD(h,482));!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}g=a.ij();if(g!=null){e=RD(g,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}break}case 3:{g=a.ij();if(g!=null){e=RD(g,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}break}case 5:{g=a.ij();if(g!=null){for(f=RD(g,16).Kc();f.Ob();){e=RD(f.Pb(),482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}}break}case 4:{h=a.kj();if(h!=null){e=RD(h,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}}break}case 6:{h=a.kj();if(h!=null){for(f=RD(h,16).Kc();f.Ob();){e=RD(f.Pb(),482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}}}break}}}this.ql(d);}};_.ql=function u$d(a){r$d(this,a);};_.b=63;sfb(SHe,'ESuperAdapter',1175);feb(1176,1175,EJe,w$d);_.ql=function x$d(a){v$d(this,a);};sfb(SHe,'EClassImpl/10',1176);feb(1165,710,oKe);_.Ei=function y$d(a,b){return IHd(this,a,b)};_.Fi=function z$d(a){return JHd(this,a)};_.Gi=function A$d(a,b){KHd(this,a,b);};_.Hi=function B$d(a){LHd(this,a);};_.$i=function D$d(a){return NHd(this,a)};_.Xi=function L$d(a,b){return UHd(this,a,b)};_.Wk=function C$d(a,b){throw Adb(new jib)};_.Ii=function E$d(){return new yMd(this)};_.Ji=function F$d(){return new BMd(this)};_.Ki=function G$d(a){return ZGd(this,a)};_.Xk=function H$d(a,b){throw Adb(new jib)};_.Fk=function I$d(a){return this};_.Qj=function J$d(){return this.i!=0};_.Wb=function K$d(a){throw Adb(new jib)};_.Gk=function M$d(){throw Adb(new jib)};sfb(ZJe,'EcoreEList/UnmodifiableEList',1165);feb(328,1165,oKe,N$d);_.Yi=function O$d(){return false};sfb(ZJe,'EcoreEList/UnmodifiableEList/FastCompare',328);feb(1168,328,oKe,R$d);_.dd=function S$d(a){var b,c,d;if(ZD(a,179)){b=RD(a,179);c=b.Lj();if(c!=-1){for(d=this.i;c4){if(this.fk(a)){if(this.al()){d=RD(a,54);c=d.Eh();h=c==this.b&&(this.ml()?d.yh(d.Fh(),RD(vYd(Uwd(this.b),this.Lj()).Hk(),29).kk())==Z5d(RD(vYd(Uwd(this.b),this.Lj()),19)).n:-1-d.Fh()==this.Lj());if(this.nl()&&!h&&!c&&!!d.Jh()){for(e=0;e1||d==-1)}else {return false}};_.ml=function a0d(){var a,b,c;b=vYd(Uwd(this.b),this.Lj());if(ZD(b,102)){a=RD(b,19);c=Z5d(a);return !!c}else {return false}};_.nl=function b0d(){var a,b;b=vYd(Uwd(this.b),this.Lj());if(ZD(b,102)){a=RD(b,19);return (a.Bb&txe)!=0}else {return false}};_.dd=function c0d(a){var b,c,d,e;d=this.zj(a);if(d>=0)return d;if(this.ol()){for(c=0,e=this.Ej();c=0;--a){N_d(this,a,this.xj(a));}}return this.Fj()};_.Qc=function o0d(a){var b;if(this.nl()){for(b=this.Ej()-1;b>=0;--b){N_d(this,b,this.xj(b));}}return this.Gj(a)};_.Gk=function p0d(){VJd(this);};_.Zi=function q0d(a,b){return P_d(this,a,b)};sfb(ZJe,'DelegatingEcoreEList',756);feb(1171,756,tKe,w0d);_.qj=function z0d(a,b){r0d(this,a,RD(b,29));};_.rj=function A0d(a){s0d(this,RD(a,29));};_.xj=function G0d(a){var b,c;return b=RD(QHd(tYd(this.a),a),89),c=b.c,ZD(c,90)?RD(c,29):(JTd(),zTd)};_.Cj=function L0d(a){var b,c;return b=RD(vLd(tYd(this.a),a),89),c=b.c,ZD(c,90)?RD(c,29):(JTd(),zTd)};_.Dj=function M0d(a,b){return u0d(this,a,RD(b,29))};_.Li=function x0d(){return false};_.Ij=function y0d(a,b,c,d,e){return null};_.sj=function B0d(){return new c1d(this)};_.tj=function C0d(){sLd(tYd(this.a));};_.uj=function D0d(a){return t0d(this,a)};_.vj=function E0d(a){var b,c;for(c=a.Kc();c.Ob();){b=c.Pb();if(!t0d(this,b)){return false}}return true};_.wj=function F0d(a){var b,c,d;if(ZD(a,15)){d=RD(a,15);if(d.gc()==tYd(this.a).i){for(b=d.Kc(),c=new dMd(this);b.Ob();){if(dE(b.Pb())!==dE(bMd(c))){return false}}return true}}return false};_.yj=function H0d(){var a,b,c,d,e;c=1;for(b=new dMd(tYd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),89);d=(e=a.c,ZD(e,90)?RD(e,29):(JTd(),zTd));c=31*c+(!d?0:kFb(d));}return c};_.zj=function I0d(a){var b,c,d,e;d=0;for(c=new dMd(tYd(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);if(dE(a)===dE((e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)))){return d}++d;}return -1};_.Aj=function J0d(){return tYd(this.a).i==0};_.Bj=function K0d(){return null};_.Ej=function N0d(){return tYd(this.a).i};_.Fj=function O0d(){var a,b,c,d,e,f;f=tYd(this.a).i;e=$C(jJ,rve,1,f,5,1);c=0;for(b=new dMd(tYd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),89);e[c++]=(d=a.c,ZD(d,90)?RD(d,29):(JTd(),zTd));}return e};_.Gj=function P0d(a){var b,c,d,e,f,g,h;h=tYd(this.a).i;if(a.lengthh&&bD(a,h,null);d=0;for(c=new dMd(tYd(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);f=(g=b.c,ZD(g,90)?RD(g,29):(JTd(),zTd));bD(a,d++,f);}return a};_.Hj=function Q0d(){var a,b,c,d,e;e=new Qhb;e.a+='[';a=tYd(this.a);for(b=0,d=tYd(this.a).i;b>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);case 9:return !this.a&&(this.a=new C5d(l7,this,9,5)),qLd(this.a,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),sTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),sTd)),a,c)};_.Uh=function D1d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);case 9:return !this.a&&(this.a=new C5d(l7,this,9,5)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),sTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),sTd)),a,c)};_.Wh=function E1d(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return !!y1d(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;case 8:return (this.Bb&256)==0;case 9:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),sTd)),vYd((b=RD(Ywd(this,16),29),!b?sTd:b),a))};_.bi=function F1d(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;case 8:j1d(this,Heb(TD(b)));return;case 9:!this.a&&(this.a=new C5d(l7,this,9,5));sLd(this.a);!this.a&&(this.a=new C5d(l7,this,9,5));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),sTd)),vYd((c=RD(Ywd(this,16),29),!c?sTd:c),a),b);};_.ii=function G1d(){return JTd(),sTd};_.ki=function H1d(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;case 8:j1d(this,true);return;case 9:!this.a&&(this.a=new C5d(l7,this,9,5));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),sTd)),vYd((b=RD(Ywd(this,16),29),!b?sTd:b),a));};_.pi=function I1d(){var a,b;if(this.a){for(a=0,b=this.a.i;a>16==5?RD(this.Cb,685):null;}return zvd(this,a-AYd((JTd(),tTd)),vYd((d=RD(Ywd(this,16),29),!d?tTd:d),a),b,c)};_.Sh=function U1d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 5:!!this.Cb&&(c=(e=this.Db>>16,e>=0?M1d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,5,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),tTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),tTd)),a,c)};_.Uh=function V1d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 5:return xvd(this,null,5,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),tTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),tTd)),a,c)};_.Wh=function W1d(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return !!this.b;case 4:return this.c!=null;case 5:return !!(this.Db>>16==5?RD(this.Cb,685):null);}return Avd(this,a-AYd((JTd(),tTd)),vYd((b=RD(Ywd(this,16),29),!b?tTd:b),a))};_.bi=function X1d(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:Q1d(this,RD(b,17).a);return;case 3:O1d(this,RD(b,2039));return;case 4:P1d(this,WD(b));return;}Bvd(this,a-AYd((JTd(),tTd)),vYd((c=RD(Ywd(this,16),29),!c?tTd:c),a),b);};_.ii=function Y1d(){return JTd(),tTd};_.ki=function Z1d(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:Q1d(this,0);return;case 3:O1d(this,null);return;case 4:P1d(this,null);return;}Cvd(this,a-AYd((JTd(),tTd)),vYd((b=RD(Ywd(this,16),29),!b?tTd:b),a));};_.Ib=function _1d(){var a;return a=this.c,a==null?this.zb:a};_.b=null;_.c=null;_.d=0;sfb(SHe,'EEnumLiteralImpl',582);var h8=ufb(SHe,'EFactoryImpl/InternalEDateTimeFormat');feb(499,1,{2114:1},c2d);sfb(SHe,'EFactoryImpl/1ClientInternalEDateTimeFormat',499);feb(248,120,{110:1,94:1,93:1,89:1,58:1,114:1,54:1,99:1,248:1,119:1,120:1},s2d);_.Ch=function t2d(a,b,c){var d;c=xvd(this,a,b,c);if(!!this.e&&ZD(a,179)){d=k2d(this,this.e);d!=this.c&&(c=o2d(this,d,c));}return c};_.Lh=function u2d(a,b,c){var d;switch(a){case 0:return this.f;case 1:return !this.d&&(this.d=new XZd(o7,this,1)),this.d;case 2:if(b)return i2d(this);return this.c;case 3:return this.b;case 4:return this.e;case 5:if(b)return h2d(this);return this.a;}return zvd(this,a-AYd((JTd(),vTd)),vYd((d=RD(Ywd(this,16),29),!d?vTd:d),a),b,c)};_.Uh=function v2d(a,b,c){var d,e;switch(b){case 0:return g2d(this,null,c);case 1:return !this.d&&(this.d=new XZd(o7,this,1)),rLd(this.d,a,c);case 3:return e2d(this,null,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),vTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),vTd)),a,c)};_.Wh=function w2d(a){var b;switch(a){case 0:return !!this.f;case 1:return !!this.d&&this.d.i!=0;case 2:return !!this.c;case 3:return !!this.b;case 4:return !!this.e;case 5:return !!this.a;}return Avd(this,a-AYd((JTd(),vTd)),vYd((b=RD(Ywd(this,16),29),!b?vTd:b),a))};_.bi=function x2d(a,b){var c;switch(a){case 0:q2d(this,RD(b,89));return;case 1:!this.d&&(this.d=new XZd(o7,this,1));sLd(this.d);!this.d&&(this.d=new XZd(o7,this,1));YGd(this.d,RD(b,16));return;case 3:n2d(this,RD(b,89));return;case 4:p2d(this,RD(b,850));return;case 5:l2d(this,RD(b,142));return;}Bvd(this,a-AYd((JTd(),vTd)),vYd((c=RD(Ywd(this,16),29),!c?vTd:c),a),b);};_.ii=function y2d(){return JTd(),vTd};_.ki=function z2d(a){var b;switch(a){case 0:q2d(this,null);return;case 1:!this.d&&(this.d=new XZd(o7,this,1));sLd(this.d);return;case 3:n2d(this,null);return;case 4:p2d(this,null);return;case 5:l2d(this,null);return;}Cvd(this,a-AYd((JTd(),vTd)),vYd((b=RD(Ywd(this,16),29),!b?vTd:b),a));};_.Ib=function A2d(){var a;a=new dib(awd(this));a.a+=' (expression: ';r2d(this,a);a.a+=')';return a.a};var d2d;sfb(SHe,'EGenericTypeImpl',248);feb(2067,2062,uKe);_.Gi=function C2d(a,b){B2d(this,a,b);};_.Wk=function D2d(a,b){B2d(this,this.gc(),a);return b};_.$i=function E2d(a){return ju(this.pj(),a)};_.Ii=function F2d(){return this.Ji()};_.pj=function G2d(){return new mee(this)};_.Ji=function H2d(){return this.Ki(0)};_.Ki=function I2d(a){return this.pj().fd(a)};_.Xk=function J2d(a,b){ze(this,a,true);return b};_.Ti=function K2d(a,b){var c,d;d=ku(this,b);c=this.fd(a);c.Rb(d);return d};_.Ui=function L2d(a,b){var c;ze(this,b,true);c=this.fd(a);c.Rb(b);};sfb(ZJe,'AbstractSequentialInternalEList',2067);feb(496,2067,uKe,Q2d);_.$i=function R2d(a){return ju(this.pj(),a)};_.Ii=function S2d(){if(this.b==null){return j3d(),j3d(),i3d}return this.sl()};_.pj=function T2d(){return new Whe(this.a,this.b)};_.Ji=function U2d(){if(this.b==null){return j3d(),j3d(),i3d}return this.sl()};_.Ki=function V2d(a){var b,c;if(this.b==null){if(a<0||a>1){throw Adb(new veb(HJe+a+', size=0'))}return j3d(),j3d(),i3d}c=this.sl();for(b=0;b0){b=this.c[--this.d];if((!this.e||b.pk()!=C4||b.Lj()!=0)&&(!this.vl()||this.b.Xh(b))){f=this.b.Nh(b,this.ul());this.f=(nke(),RD(b,69).xk());if(this.f||b.Jk()){if(this.ul()){d=RD(f,15);this.k=d;}else {d=RD(f,71);this.k=this.j=d;}if(ZD(this.k,59)){this.o=this.k.gc();this.n=this.o;}else {this.p=!this.j?this.k.fd(this.k.gc()):this.j.Ki(this.k.gc());}if(!this.p?n3d(this):o3d(this,this.p)){e=!this.p?!this.j?this.k.Xb(--this.n):this.j.$i(--this.n):this.p.Ub();if(this.f){a=RD(e,76);a.Lk();c=a.md();this.i=c;}else {c=e;this.i=c;}this.g=-3;return true}}else if(f!=null){this.k=null;this.p=null;c=f;this.i=c;this.g=-2;return true}}}this.k=null;this.p=null;this.g=-1;return false}else {e=!this.p?!this.j?this.k.Xb(--this.n):this.j.$i(--this.n):this.p.Ub();if(this.f){a=RD(e,76);a.Lk();c=a.md();this.i=c;}else {c=e;this.i=c;}this.g=-3;return true}}}};_.Pb=function v3d(){return k3d(this)};_.Tb=function w3d(){return this.a};_.Ub=function x3d(){var a;if(this.g<-1||this.Sb()){--this.a;this.g=0;a=this.i;this.Sb();return a}else {throw Adb(new Dvb)}};_.Vb=function y3d(){return this.a-1};_.Qb=function z3d(){throw Adb(new jib)};_.ul=function A3d(){return false};_.Wb=function B3d(a){throw Adb(new jib)};_.vl=function C3d(){return true};_.a=0;_.d=0;_.f=false;_.g=0;_.n=0;_.o=0;var i3d;sfb(ZJe,'EContentsEList/FeatureIteratorImpl',287);feb(711,287,vKe,D3d);_.ul=function E3d(){return true};sfb(ZJe,'EContentsEList/ResolvingFeatureIteratorImpl',711);feb(1178,711,vKe,F3d);_.vl=function G3d(){return false};sfb(SHe,'ENamedElementImpl/1/1',1178);feb(1179,287,vKe,H3d);_.vl=function I3d(){return false};sfb(SHe,'ENamedElementImpl/1/2',1179);feb(39,152,GJe,L3d,M3d,N3d,O3d,P3d,Q3d,R3d,S3d,T3d,U3d,V3d,W3d,X3d,Y3d,Z3d,$3d,_3d,a4d,b4d,c4d,d4d,e4d,f4d,g4d,h4d);_.Kj=function i4d(){return K3d(this)};_.Rj=function j4d(){var a;a=K3d(this);if(a){return a.ik()}return null};_.hj=function k4d(a){this.b==-1&&!!this.a&&(this.b=this.c.Hh(this.a.Lj(),this.a.pk()));return this.c.yh(this.b,a)};_.jj=function l4d(){return this.c};_.Sj=function m4d(){var a;a=K3d(this);if(a){return a.tk()}return false};_.b=-1;sfb(SHe,'ENotificationImpl',39);feb(411,292,{110:1,94:1,93:1,155:1,197:1,58:1,62:1,114:1,481:1,54:1,99:1,158:1,411:1,292:1,119:1,120:1},q4d);_.Ah=function r4d(a){return n4d(this,a)};_.Lh=function s4d(a,b,c){var d,e,f;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),f=this.t,f>1||f==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return this.Db>>16==10?RD(this.Cb,29):null;case 11:return !this.d&&(this.d=new iie(z7,this,11)),this.d;case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),this.c;case 13:return !this.a&&(this.a=new F4d(this,this)),this.a;case 14:return o4d(this);}return zvd(this,a-AYd((JTd(),ATd)),vYd((d=RD(Ywd(this,16),29),!d?ATd:d),a),b,c)};_.Sh=function t4d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 10:!!this.Cb&&(c=(e=this.Db>>16,e>=0?n4d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,10,c);case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),qLd(this.c,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ATd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),ATd)),a,c)};_.Uh=function u4d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 10:return xvd(this,null,10,c);case 11:return !this.d&&(this.d=new iie(z7,this,11)),rLd(this.d,a,c);case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),rLd(this.c,a,c);case 14:return rLd(o4d(this),a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ATd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),ATd)),a,c)};_.Wh=function v4d(a){var b,c,d;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return d=this.t,d>1||d==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return !!(this.Db>>16==10?RD(this.Cb,29):null);case 11:return !!this.d&&this.d.i!=0;case 12:return !!this.c&&this.c.i!=0;case 13:return !!this.a&&o4d(this.a.a).i!=0&&!(!!this.b&&o5d(this.b));case 14:return !!this.b&&o5d(this.b);}return Avd(this,a-AYd((JTd(),ATd)),vYd((b=RD(Ywd(this,16),29),!b?ATd:b),a))};_.bi=function w4d(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:bWd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 11:!this.d&&(this.d=new iie(z7,this,11));sLd(this.d);!this.d&&(this.d=new iie(z7,this,11));YGd(this.d,RD(b,16));return;case 12:!this.c&&(this.c=new C5d(u7,this,12,10));sLd(this.c);!this.c&&(this.c=new C5d(u7,this,12,10));YGd(this.c,RD(b,16));return;case 13:!this.a&&(this.a=new F4d(this,this));VJd(this.a);!this.a&&(this.a=new F4d(this,this));YGd(this.a,RD(b,16));return;case 14:sLd(o4d(this));YGd(o4d(this),RD(b,16));return;}Bvd(this,a-AYd((JTd(),ATd)),vYd((c=RD(Ywd(this,16),29),!c?ATd:c),a),b);};_.ii=function x4d(){return JTd(),ATd};_.ki=function y4d(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 11:!this.d&&(this.d=new iie(z7,this,11));sLd(this.d);return;case 12:!this.c&&(this.c=new C5d(u7,this,12,10));sLd(this.c);return;case 13:!!this.a&&VJd(this.a);return;case 14:!!this.b&&sLd(this.b);return;}Cvd(this,a-AYd((JTd(),ATd)),vYd((b=RD(Ywd(this,16),29),!b?ATd:b),a));};_.pi=function z4d(){var a,b;if(this.c){for(a=0,b=this.c.i;ah&&bD(a,h,null);d=0;for(c=new dMd(o4d(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);f=(g=b.c,g?g:(JTd(),wTd));bD(a,d++,f);}return a};_.Hj=function Z4d(){var a,b,c,d,e;e=new Qhb;e.a+='[';a=o4d(this.a);for(b=0,d=o4d(this.a).i;b1)}case 5:{return dZd(this,a,b,c,d,this.i-RD(c,15).gc()>0)}default:{return new P3d(this.e,a,this.c,b,c,d,true)}}};_.Tj=function u5d(){return true};_.Qj=function v5d(){return o5d(this)};_.Gk=function A5d(){sLd(this);};sfb(SHe,'EOperationImpl/2',1377);feb(507,1,{2037:1,507:1},B5d);sfb(SHe,'EPackageImpl/1',507);feb(14,83,oKe,C5d);_.il=function D5d(){return this.d};_.jl=function E5d(){return this.b};_.ml=function F5d(){return true};_.b=0;sfb(ZJe,'EObjectContainmentWithInverseEList',14);feb(365,14,oKe,G5d);_.nl=function H5d(){return true};_.Wi=function I5d(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentWithInverseEList/Resolving',365);feb(308,365,oKe,J5d);_.Ni=function K5d(){this.a.tb=null;};sfb(SHe,'EPackageImpl/2',308);feb(1278,1,{},L5d);sfb(SHe,'EPackageImpl/3',1278);feb(733,45,Hxe,O5d);_._b=function P5d(a){return bE(a)?Yjb(this,a):!!qtb(this.f,a)};sfb(SHe,'EPackageRegistryImpl',733);feb(518,292,{110:1,94:1,93:1,155:1,197:1,58:1,2116:1,114:1,481:1,54:1,99:1,158:1,518:1,292:1,119:1,120:1},R5d);_.Ah=function S5d(a){return Q5d(this,a)};_.Lh=function T5d(a,b,c){var d,e,f;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),f=this.t,f>1||f==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return this.Db>>16==10?RD(this.Cb,62):null;}return zvd(this,a-AYd((JTd(),DTd)),vYd((d=RD(Ywd(this,16),29),!d?DTd:d),a),b,c)};_.Sh=function U5d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 10:!!this.Cb&&(c=(e=this.Db>>16,e>=0?Q5d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,10,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),DTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),DTd)),a,c)};_.Uh=function V5d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 10:return xvd(this,null,10,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),DTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),DTd)),a,c)};_.Wh=function W5d(a){var b,c,d;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return d=this.t,d>1||d==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return !!(this.Db>>16==10?RD(this.Cb,62):null);}return Avd(this,a-AYd((JTd(),DTd)),vYd((b=RD(Ywd(this,16),29),!b?DTd:b),a))};_.ii=function X5d(){return JTd(),DTd};sfb(SHe,'EParameterImpl',518);feb(102,462,{110:1,94:1,93:1,155:1,197:1,58:1,19:1,179:1,69:1,114:1,481:1,54:1,99:1,158:1,102:1,462:1,292:1,119:1,120:1,692:1},d6d);_.Lh=function e6d(a,b,c){var d,e,f,g;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),g=this.t,g>1||g==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);case 18:return Geb(),(this.Bb&QHe)!=0?true:false;case 19:return Geb(),f=Z5d(this),!!f&&(f.Bb&QHe)!=0?true:false;case 20:return Geb(),(this.Bb&txe)!=0?true:false;case 21:if(b)return Z5d(this);return this.b;case 22:if(b)return $5d(this);return Y5d(this);case 23:return !this.a&&(this.a=new zie(g7,this,23)),this.a;}return zvd(this,a-AYd((JTd(),ETd)),vYd((d=RD(Ywd(this,16),29),!d?ETd:d),a),b,c)};_.Wh=function f6d(a){var b,c,d,e;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return e=this.t,e>1||e==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);case 18:return (this.Bb&QHe)!=0;case 19:return d=Z5d(this),!!d&&(d.Bb&QHe)!=0;case 20:return (this.Bb&txe)==0;case 21:return !!this.b;case 22:return !!Y5d(this);case 23:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),ETd)),vYd((b=RD(Ywd(this,16),29),!b?ETd:b),a))};_.bi=function g6d(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:bWd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;case 18:_5d(this,Heb(TD(b)));return;case 20:c6d(this,Heb(TD(b)));return;case 21:b6d(this,RD(b,19));return;case 23:!this.a&&(this.a=new zie(g7,this,23));sLd(this.a);!this.a&&(this.a=new zie(g7,this,23));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),ETd)),vYd((c=RD(Ywd(this,16),29),!c?ETd:c),a),b);};_.ii=function h6d(){return JTd(),ETd};_.ki=function i6d(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;case 18:a6d(this,false);ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),2);return;case 20:c6d(this,true);return;case 21:b6d(this,null);return;case 23:!this.a&&(this.a=new zie(g7,this,23));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),ETd)),vYd((b=RD(Ywd(this,16),29),!b?ETd:b),a));};_.pi=function j6d(){$5d(this);Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.uk=function k6d(){return Z5d(this)};_._k=function l6d(){var a;return a=Z5d(this),!!a&&(a.Bb&QHe)!=0};_.al=function m6d(){return (this.Bb&QHe)!=0};_.bl=function n6d(){return (this.Bb&txe)!=0};_.Yk=function o6d(a,b){this.c=null;return ZVd(this,a,b)};_.Ib=function p6d(){var a;if((this.Db&64)!=0)return GWd(this);a=new Shb(GWd(this));a.a+=' (containment: ';Ohb(a,(this.Bb&QHe)!=0);a.a+=', resolveProxies: ';Ohb(a,(this.Bb&txe)!=0);a.a+=')';return a.a};sfb(SHe,'EReferenceImpl',102);feb(561,120,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1,561:1,119:1,120:1},v6d);_.Fb=function B6d(a){return this===a};_.ld=function D6d(){return this.b};_.md=function E6d(){return this.c};_.Hb=function F6d(){return kFb(this)};_.Di=function H6d(a){q6d(this,WD(a));};_.nd=function I6d(a){return u6d(this,WD(a))};_.Lh=function w6d(a,b,c){var d;switch(a){case 0:return this.b;case 1:return this.c;}return zvd(this,a-AYd((JTd(),FTd)),vYd((d=RD(Ywd(this,16),29),!d?FTd:d),a),b,c)};_.Wh=function x6d(a){var b;switch(a){case 0:return this.b!=null;case 1:return this.c!=null;}return Avd(this,a-AYd((JTd(),FTd)),vYd((b=RD(Ywd(this,16),29),!b?FTd:b),a))};_.bi=function y6d(a,b){var c;switch(a){case 0:r6d(this,WD(b));return;case 1:t6d(this,WD(b));return;}Bvd(this,a-AYd((JTd(),FTd)),vYd((c=RD(Ywd(this,16),29),!c?FTd:c),a),b);};_.ii=function z6d(){return JTd(),FTd};_.ki=function A6d(a){var b;switch(a){case 0:s6d(this,null);return;case 1:t6d(this,null);return;}Cvd(this,a-AYd((JTd(),FTd)),vYd((b=RD(Ywd(this,16),29),!b?FTd:b),a));};_.Bi=function C6d(){var a;if(this.a==-1){a=this.b;this.a=a==null?0:ohb(a);}return this.a};_.Ci=function G6d(a){this.a=a;};_.Ib=function J6d(){var a;if((this.Db&64)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (key: ';Nhb(a,this.b);a.a+=', value: ';Nhb(a,this.c);a.a+=')';return a.a};_.a=-1;_.b=null;_.c=null;var C8=sfb(SHe,'EStringToStringMapEntryImpl',561);var Ibb=ufb(ZJe,'FeatureMap/Entry/Internal');feb(576,1,wKe);_.xl=function M6d(a){return this.yl(RD(a,54))};_.yl=function N6d(a){return this.xl(a)};_.Fb=function O6d(a){var b,c;if(this===a){return true}else if(ZD(a,76)){b=RD(a,76);if(b.Lk()==this.c){c=this.md();return c==null?b.md()==null:pb(c,b.md())}else {return false}}else {return false}};_.Lk=function P6d(){return this.c};_.Hb=function Q6d(){var a;a=this.md();return tb(this.c)^(a==null?0:tb(a))};_.Ib=function R6d(){var a,b;a=this.c;b=BXd(a.qk()).yi();a.xe();return (b!=null&&b.length!=0?b+':'+a.xe():a.xe())+'='+this.md()};sfb(SHe,'EStructuralFeatureImpl/BasicFeatureMapEntry',576);feb(791,576,wKe,U6d);_.yl=function V6d(a){return new U6d(this.c,a)};_.md=function W6d(){return this.a};_.zl=function X6d(a,b,c){return S6d(this,a,this.a,b,c)};_.Al=function Y6d(a,b,c){return T6d(this,a,this.a,b,c)};sfb(SHe,'EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry',791);feb(1350,1,{},Z6d);_.yk=function $6d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Yl(this.a).Fk(d)};_.zk=function _6d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Pl(this.a,d,e)};_.Ak=function a7d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Ql(this.a,d,e)};_.Bk=function b7d(a,b,c){var d;d=RD(Evd(a,this.b),220);return d.Yl(this.a).Qj()};_.Ck=function c7d(a,b,c,d){var e;e=RD(Evd(a,this.b),220);e.Yl(this.a).Wb(d);};_.Dk=function d7d(a,b,c){return RD(Evd(a,this.b),220).Yl(this.a)};_.Ek=function e7d(a,b,c){var d;d=RD(Evd(a,this.b),220);d.Yl(this.a).Gk();};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator',1350);feb(91,1,{},g7d,h7d,i7d,j7d);_.yk=function k7d(a,b,c,d,e){var f;f=b.li(c);f==null&&b.mi(c,f=f7d(this,a));if(!e){switch(this.e){case 50:case 41:return RD(f,597).bk();case 40:return RD(f,220).Vl();}}return f};_.zk=function l7d(a,b,c,d,e){var f,g;g=b.li(c);g==null&&b.mi(c,g=f7d(this,a));f=RD(g,71).Wk(d,e);return f};_.Ak=function m7d(a,b,c,d,e){var f;f=b.li(c);f!=null&&(e=RD(f,71).Xk(d,e));return e};_.Bk=function n7d(a,b,c){var d;d=b.li(c);return d!=null&&RD(d,79).Qj()};_.Ck=function o7d(a,b,c,d){var e;e=RD(b.li(c),79);!e&&b.mi(c,e=f7d(this,a));e.Wb(d);};_.Dk=function p7d(a,b,c){var d,e;e=b.li(c);e==null&&b.mi(c,e=f7d(this,a));if(ZD(e,79)){return RD(e,79)}else {d=RD(b.li(c),15);return new I9d(d)}};_.Ek=function q7d(a,b,c){var d;d=RD(b.li(c),79);!d&&b.mi(c,d=f7d(this,a));d.Gk();};_.b=0;_.e=0;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateMany',91);feb(512,1,{});_.zk=function u7d(a,b,c,d,e){throw Adb(new jib)};_.Ak=function v7d(a,b,c,d,e){throw Adb(new jib)};_.Dk=function w7d(a,b,c){return new x7d(this,a,b,c)};var r7d;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingle',512);feb(1367,1,$Je,x7d);_.Fk=function y7d(a){return this.a.yk(this.c,this.d,this.b,a,true)};_.Qj=function z7d(){return this.a.Bk(this.c,this.d,this.b)};_.Wb=function A7d(a){this.a.Ck(this.c,this.d,this.b,a);};_.Gk=function B7d(){this.a.Ek(this.c,this.d,this.b);};_.b=0;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingle/1',1367);feb(784,512,{},C7d);_.yk=function D7d(a,b,c,d,e){return jwd(a,a.Ph(),a.Fh())==this.b?this.bl()&&d?yvd(a):a.Ph():null};_.zk=function E7d(a,b,c,d,e){var f,g;!!a.Ph()&&(e=(f=a.Fh(),f>=0?a.Ah(e):a.Ph().Th(a,-1-f,null,e)));g=BYd(a.Dh(),this.e);return a.Ch(d,g,e)};_.Ak=function F7d(a,b,c,d,e){var f;f=BYd(a.Dh(),this.e);return a.Ch(null,f,e)};_.Bk=function G7d(a,b,c){var d;d=BYd(a.Dh(),this.e);return !!a.Ph()&&a.Fh()==d};_.Ck=function H7d(a,b,c,d){var e,f,g,h,i;if(d!=null&&!FXd(this.a,d)){throw Adb(new Ifb(xKe+(ZD(d,58)?GYd(RD(d,58).Dh()):ofb(rb(d)))+yKe+this.a+"'"))}e=a.Ph();g=BYd(a.Dh(),this.e);if(dE(d)!==dE(e)||a.Fh()!=g&&d!=null){if(Oje(a,RD(d,58)))throw Adb(new agb(UHe+a.Ib()));i=null;!!e&&(i=(f=a.Fh(),f>=0?a.Ah(i):a.Ph().Th(a,-1-f,null,i)));h=RD(d,54);!!h&&(i=h.Rh(a,BYd(h.Dh(),this.b),null,i));i=a.Ch(h,g,i);!!i&&i.oj();}else {a.vh()&&a.wh()&&qvd(a,new N3d(a,1,g,d,d));}};_.Ek=function I7d(a,b,c){var d,e,f,g;d=a.Ph();if(d){g=(e=a.Fh(),e>=0?a.Ah(null):a.Ph().Th(a,-1-e,null,null));f=BYd(a.Dh(),this.e);g=a.Ch(null,f,g);!!g&&g.oj();}else {a.vh()&&a.wh()&&qvd(a,new b4d(a,1,this.e,null,null));}};_.bl=function J7d(){return false};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleContainer',784);feb(1351,784,{},K7d);_.bl=function L7d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving',1351);feb(574,512,{});_.yk=function O7d(a,b,c,d,e){var f;return f=b.li(c),f==null?this.b:dE(f)===dE(r7d)?null:f};_.Bk=function P7d(a,b,c){var d;d=b.li(c);return d!=null&&(dE(d)===dE(r7d)||!pb(d,this.b))};_.Ck=function Q7d(a,b,c,d){var e,f;if(a.vh()&&a.wh()){e=(f=b.li(c),f==null?this.b:dE(f)===dE(r7d)?null:f);if(d==null){if(this.c!=null){b.mi(c,null);d=this.b;}else this.b!=null?b.mi(c,r7d):b.mi(c,null);}else {this.Bl(d);b.mi(c,d);}qvd(a,this.d.Cl(a,1,this.e,e,d));}else {if(d==null){this.c!=null?b.mi(c,null):this.b!=null?b.mi(c,r7d):b.mi(c,null);}else {this.Bl(d);b.mi(c,d);}}};_.Ek=function R7d(a,b,c){var d,e;if(a.vh()&&a.wh()){d=(e=b.li(c),e==null?this.b:dE(e)===dE(r7d)?null:e);b.ni(c);qvd(a,this.d.Cl(a,1,this.e,d,this.b));}else {b.ni(c);}};_.Bl=function S7d(a){throw Adb(new Hfb)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData',574);feb(zKe,1,{},b8d);_.Cl=function c8d(a,b,c,d,e){return new b4d(a,b,c,d,e)};_.Dl=function d8d(a,b,c,d,e,f){return new d4d(a,b,c,d,e,f)};var T7d,U7d,V7d,W7d,X7d,Y7d,Z7d,$7d,_7d;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator',zKe);feb(1368,zKe,{},e8d);_.Cl=function f8d(a,b,c,d,e){return new g4d(a,b,c,Heb(TD(d)),Heb(TD(e)))};_.Dl=function g8d(a,b,c,d,e,f){return new h4d(a,b,c,Heb(TD(d)),Heb(TD(e)),f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1',1368);feb(1369,zKe,{},h8d);_.Cl=function i8d(a,b,c,d,e){return new R3d(a,b,c,RD(d,222).a,RD(e,222).a)};_.Dl=function j8d(a,b,c,d,e,f){return new S3d(a,b,c,RD(d,222).a,RD(e,222).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2',1369);feb(1370,zKe,{},k8d);_.Cl=function l8d(a,b,c,d,e){return new T3d(a,b,c,RD(d,180).a,RD(e,180).a)};_.Dl=function m8d(a,b,c,d,e,f){return new U3d(a,b,c,RD(d,180).a,RD(e,180).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3',1370);feb(1371,zKe,{},n8d);_.Cl=function o8d(a,b,c,d,e){return new V3d(a,b,c,Kfb(UD(d)),Kfb(UD(e)))};_.Dl=function p8d(a,b,c,d,e,f){return new W3d(a,b,c,Kfb(UD(d)),Kfb(UD(e)),f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4',1371);feb(1372,zKe,{},q8d);_.Cl=function r8d(a,b,c,d,e){return new X3d(a,b,c,RD(d,161).a,RD(e,161).a)};_.Dl=function s8d(a,b,c,d,e,f){return new Y3d(a,b,c,RD(d,161).a,RD(e,161).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5',1372);feb(1373,zKe,{},t8d);_.Cl=function u8d(a,b,c,d,e){return new Z3d(a,b,c,RD(d,17).a,RD(e,17).a)};_.Dl=function v8d(a,b,c,d,e,f){return new $3d(a,b,c,RD(d,17).a,RD(e,17).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6',1373);feb(1374,zKe,{},w8d);_.Cl=function x8d(a,b,c,d,e){return new _3d(a,b,c,RD(d,168).a,RD(e,168).a)};_.Dl=function y8d(a,b,c,d,e,f){return new a4d(a,b,c,RD(d,168).a,RD(e,168).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7',1374);feb(1375,zKe,{},z8d);_.Cl=function A8d(a,b,c,d,e){return new e4d(a,b,c,RD(d,191).a,RD(e,191).a)};_.Dl=function B8d(a,b,c,d,e,f){return new f4d(a,b,c,RD(d,191).a,RD(e,191).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8',1375);feb(1353,574,{},C8d);_.Bl=function D8d(a){if(!this.a.fk(a)){throw Adb(new Ifb(xKe+rb(a)+yKe+this.a+"'"))}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic',1353);feb(1354,574,{},E8d);_.Bl=function F8d(a){};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic',1354);feb(785,574,{});_.Bk=function G8d(a,b,c){var d;d=b.li(c);return d!=null};_.Ck=function H8d(a,b,c,d){var e,f;if(a.vh()&&a.wh()){e=true;f=b.li(c);if(f==null){e=false;f=this.b;}else dE(f)===dE(r7d)&&(f=null);if(d==null){if(this.c!=null){b.mi(c,null);d=this.b;}else {b.mi(c,r7d);}}else {this.Bl(d);b.mi(c,d);}qvd(a,this.d.Dl(a,1,this.e,f,d,!e));}else {if(d==null){this.c!=null?b.mi(c,null):b.mi(c,r7d);}else {this.Bl(d);b.mi(c,d);}}};_.Ek=function I8d(a,b,c){var d,e;if(a.vh()&&a.wh()){d=true;e=b.li(c);if(e==null){d=false;e=this.b;}else dE(e)===dE(r7d)&&(e=null);b.ni(c);qvd(a,this.d.Dl(a,2,this.e,e,this.b,d));}else {b.ni(c);}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable',785);feb(1355,785,{},J8d);_.Bl=function K8d(a){if(!this.a.fk(a)){throw Adb(new Ifb(xKe+rb(a)+yKe+this.a+"'"))}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic',1355);feb(1356,785,{},L8d);_.Bl=function M8d(a){};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic',1356);feb(410,512,{},N8d);_.yk=function P8d(a,b,c,d,e){var f,g,h,i,j;j=b.li(c);if(this.tk()&&dE(j)===dE(r7d)){return null}else if(this.bl()&&d&&j!=null){h=RD(j,54);if(h.Vh()){i=Vvd(a,h);if(h!=i){if(!FXd(this.a,i)){throw Adb(new Ifb(xKe+rb(i)+yKe+this.a+"'"))}b.mi(c,j=i);if(this.al()){f=RD(i,54);g=h.Th(a,!this.b?-1-BYd(a.Dh(),this.e):BYd(h.Dh(),this.b),null,null);!f.Ph()&&(g=f.Rh(a,!this.b?-1-BYd(a.Dh(),this.e):BYd(f.Dh(),this.b),null,g));!!g&&g.oj();}a.vh()&&a.wh()&&qvd(a,new b4d(a,9,this.e,h,i));}}return j}else {return j}};_.zk=function Q8d(a,b,c,d,e){var f,g;g=b.li(c);dE(g)===dE(r7d)&&(g=null);b.mi(c,d);if(this.Mj()){if(dE(g)!==dE(d)&&g!=null){f=RD(g,54);e=f.Th(a,BYd(f.Dh(),this.b),null,e);}}else this.al()&&g!=null&&(e=RD(g,54).Th(a,-1-BYd(a.Dh(),this.e),null,e));if(a.vh()&&a.wh()){!e&&(e=new gLd(4));e.nj(new b4d(a,1,this.e,g,d));}return e};_.Ak=function R8d(a,b,c,d,e){var f;f=b.li(c);dE(f)===dE(r7d)&&(f=null);b.ni(c);if(a.vh()&&a.wh()){!e&&(e=new gLd(4));this.tk()?e.nj(new b4d(a,2,this.e,f,null)):e.nj(new b4d(a,1,this.e,f,null));}return e};_.Bk=function S8d(a,b,c){var d;d=b.li(c);return d!=null};_.Ck=function T8d(a,b,c,d){var e,f,g,h,i;if(d!=null&&!FXd(this.a,d)){throw Adb(new Ifb(xKe+(ZD(d,58)?GYd(RD(d,58).Dh()):ofb(rb(d)))+yKe+this.a+"'"))}i=b.li(c);h=i!=null;this.tk()&&dE(i)===dE(r7d)&&(i=null);g=null;if(this.Mj()){if(dE(i)!==dE(d)){if(i!=null){e=RD(i,54);g=e.Th(a,BYd(e.Dh(),this.b),null,g);}if(d!=null){e=RD(d,54);g=e.Rh(a,BYd(e.Dh(),this.b),null,g);}}}else if(this.al()){if(dE(i)!==dE(d)){i!=null&&(g=RD(i,54).Th(a,-1-BYd(a.Dh(),this.e),null,g));d!=null&&(g=RD(d,54).Rh(a,-1-BYd(a.Dh(),this.e),null,g));}}d==null&&this.tk()?b.mi(c,r7d):b.mi(c,d);if(a.vh()&&a.wh()){f=new d4d(a,1,this.e,i,d,this.tk()&&!h);if(!g){qvd(a,f);}else {g.nj(f);g.oj();}}else !!g&&g.oj();};_.Ek=function U8d(a,b,c){var d,e,f,g,h;h=b.li(c);g=h!=null;this.tk()&&dE(h)===dE(r7d)&&(h=null);f=null;if(h!=null){if(this.Mj()){d=RD(h,54);f=d.Th(a,BYd(d.Dh(),this.b),null,f);}else this.al()&&(f=RD(h,54).Th(a,-1-BYd(a.Dh(),this.e),null,f));}b.ni(c);if(a.vh()&&a.wh()){e=new d4d(a,this.tk()?2:1,this.e,h,null,g);if(!f){qvd(a,e);}else {f.nj(e);f.oj();}}else !!f&&f.oj();};_.Mj=function V8d(){return false};_.al=function W8d(){return false};_.bl=function X8d(){return false};_.tk=function Y8d(){return false};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObject',410);feb(575,410,{},Z8d);_.al=function $8d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment',575);feb(1359,575,{},_8d);_.bl=function a9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving',1359);feb(787,575,{},b9d);_.tk=function c9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable',787);feb(1361,787,{},d9d);_.bl=function e9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving',1361);feb(650,575,{},f9d);_.Mj=function g9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse',650);feb(1360,650,{},h9d);_.bl=function i9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving',1360);feb(788,650,{},j9d);_.tk=function k9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable',788);feb(1362,788,{},l9d);_.bl=function m9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving',1362);feb(651,410,{},n9d);_.bl=function o9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving',651);feb(1363,651,{},p9d);_.tk=function q9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable',1363);feb(789,651,{},r9d);_.Mj=function s9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse',789);feb(1364,789,{},t9d);_.tk=function u9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable',1364);feb(1357,410,{},v9d);_.tk=function w9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable',1357);feb(786,410,{},x9d);_.Mj=function y9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse',786);feb(1358,786,{},z9d);_.tk=function A9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable',1358);feb(790,576,wKe,D9d);_.yl=function E9d(a){return new D9d(this.a,this.c,a)};_.md=function F9d(){return this.b};_.zl=function G9d(a,b,c){return B9d(this,a,this.b,c)};_.Al=function H9d(a,b,c){return C9d(this,a,this.b,c)};sfb(SHe,'EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry',790);feb(1365,1,$Je,I9d);_.Fk=function J9d(a){return this.a};_.Qj=function K9d(){return ZD(this.a,97)?RD(this.a,97).Qj():!this.a.dc()};_.Wb=function L9d(a){this.a.$b();this.a.Gc(RD(a,15));};_.Gk=function M9d(){ZD(this.a,97)?RD(this.a,97).Gk():this.a.$b();};sfb(SHe,'EStructuralFeatureImpl/SettingMany',1365);feb(1366,576,wKe,N9d);_.xl=function O9d(a){return new S9d((nme(),mme),this.b.ri(this.a,a))};_.md=function P9d(){return null};_.zl=function Q9d(a,b,c){return c};_.Al=function R9d(a,b,c){return c};sfb(SHe,'EStructuralFeatureImpl/SimpleContentFeatureMapEntry',1366);feb(652,576,wKe,S9d);_.xl=function T9d(a){return new S9d(this.c,a)};_.md=function U9d(){return this.a};_.zl=function V9d(a,b,c){return c};_.Al=function W9d(a,b,c){return c};sfb(SHe,'EStructuralFeatureImpl/SimpleFeatureMapEntry',652);feb(403,506,PIe,X9d);_.aj=function Y9d(a){return $C(h7,rve,29,a,0,1)};_.Yi=function Z9d(){return false};sfb(SHe,'ESuperAdapter/1',403);feb(457,448,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,850:1,54:1,99:1,158:1,457:1,119:1,120:1},_9d);_.Lh=function aae(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return !this.a&&(this.a=new iae(this,o7,this)),this.a;}return zvd(this,a-AYd((JTd(),ITd)),vYd((d=RD(Ywd(this,16),29),!d?ITd:d),a),b,c)};_.Uh=function bae(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 2:return !this.a&&(this.a=new iae(this,o7,this)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ITd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),ITd)),a,c)};_.Wh=function cae(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),ITd)),vYd((b=RD(Ywd(this,16),29),!b?ITd:b),a))};_.bi=function dae(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:!this.a&&(this.a=new iae(this,o7,this));sLd(this.a);!this.a&&(this.a=new iae(this,o7,this));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),ITd)),vYd((c=RD(Ywd(this,16),29),!c?ITd:c),a),b);};_.ii=function eae(){return JTd(),ITd};_.ki=function fae(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:!this.a&&(this.a=new iae(this,o7,this));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),ITd)),vYd((b=RD(Ywd(this,16),29),!b?ITd:b),a));};sfb(SHe,'ETypeParameterImpl',457);feb(458,83,oKe,iae);_.Nj=function jae(a,b){return gae(this,RD(a,89),b)};_.Oj=function kae(a,b){return hae(this,RD(a,89),b)};sfb(SHe,'ETypeParameterImpl/1',458);feb(647,45,Hxe,lae);_.ec=function mae(){return new pae(this)};sfb(SHe,'ETypeParameterImpl/2',647);feb(570,Eve,Fve,pae);_.Fc=function qae(a){return nae(this,RD(a,89))};_.Gc=function rae(a){var b,c,d;d=false;for(c=a.Kc();c.Ob();){b=RD(c.Pb(),89);Zjb(this.a,b,'')==null&&(d=true);}return d};_.$b=function sae(){akb(this.a);};_.Hc=function tae(a){return Ujb(this.a,a)};_.Kc=function uae(){var a;return a=new vkb((new mkb(this.a)).a),new xae(a)};_.Mc=function vae(a){return oae(this,a)};_.gc=function wae(){return bkb(this.a)};sfb(SHe,'ETypeParameterImpl/2/1',570);feb(571,1,Ave,xae);_.Nb=function yae(a){Ztb(this,a);};_.Pb=function Aae(){return RD(tkb(this.a).ld(),89)};_.Ob=function zae(){return this.a.b};_.Qb=function Bae(){ukb(this.a);};sfb(SHe,'ETypeParameterImpl/2/1/1',571);feb(1329,45,Hxe,Cae);_._b=function Dae(a){return bE(a)?Yjb(this,a):!!qtb(this.f,a)};_.xc=function Eae(a){var b,c;b=bE(a)?Xjb(this,a):Wd(qtb(this.f,a));if(ZD(b,851)){c=RD(b,851);b=c.Kk();Zjb(this,RD(a,241),b);return b}else return b!=null?b:a==null?(Gie(),Fie):null};sfb(SHe,'EValidatorRegistryImpl',1329);feb(1349,720,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,2040:1,54:1,99:1,158:1,119:1,120:1},Mae);_.ri=function Nae(a,b){switch(a.hk()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return b==null?null:jeb(b);case 25:return Gae(b);case 27:return Hae(b);case 28:return Iae(b);case 29:return b==null?null:a2d(nAd[0],RD(b,206));case 41:return b==null?'':nfb(RD(b,297));case 42:return jeb(b);case 50:return WD(b);default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function Oae(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;switch(a.G==-1&&(a.G=(m=BXd(a),m?fZd(m.vi(),a):-1)),a.G){case 0:return c=new mXd,c;case 1:return b=new pVd,b;case 2:return d=new HYd,d;case 4:return e=new k1d,e;case 5:return f=new A1d,f;case 6:return g=new R1d,g;case 7:return h=new yAd,h;case 10:return j=new kUd,j;case 11:return k=new q4d,k;case 12:return l=new EBd,l;case 13:return n=new R5d,n;case 14:return o=new d6d,o;case 17:return p=new v6d,p;case 18:return i=new s2d,i;case 19:return q=new _9d,q;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function Pae(a,b){switch(a.hk()){case 20:return b==null?null:new Bib(b);case 21:return b==null?null:new ejb(b);case 23:case 22:return b==null?null:Fae(b);case 26:case 24:return b==null?null:$eb(Oeb(b,-128,127)<<24>>24);case 25:return vAd(b);case 27:return Jae(b);case 28:return Kae(b);case 29:return Lae(b);case 32:case 31:return b==null?null:Neb(b);case 38:case 37:return b==null?null:new Ufb(b);case 40:case 39:return b==null?null:sgb(Oeb(b,qwe,lve));case 41:return null;case 42:return b==null?null:null;case 44:case 43:return b==null?null:Hgb(Peb(b));case 49:case 48:return b==null?null:bhb(Oeb(b,BKe,32767)<<16>>16);case 50:return b;default:throw Adb(new agb(VHe+a.xe()+WHe));}};sfb(SHe,'EcoreFactoryImpl',1349);feb(560,184,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,2038:1,54:1,99:1,158:1,184:1,560:1,119:1,120:1,690:1},$ae);_.gb=false;_.hb=false;var Rae,Sae=false;sfb(SHe,'EcorePackageImpl',560);feb(1234,1,{851:1},cbe);_.Kk=function dbe(){return fke(),eke};sfb(SHe,'EcorePackageImpl/1',1234);feb(1243,1,OKe,ebe);_.fk=function fbe(a){return ZD(a,155)};_.gk=function gbe(a){return $C(p7,rve,155,a,0,1)};sfb(SHe,'EcorePackageImpl/10',1243);feb(1244,1,OKe,hbe);_.fk=function ibe(a){return ZD(a,197)};_.gk=function jbe(a){return $C(q7,rve,197,a,0,1)};sfb(SHe,'EcorePackageImpl/11',1244);feb(1245,1,OKe,kbe);_.fk=function lbe(a){return ZD(a,58)};_.gk=function mbe(a){return $C(r7,rve,58,a,0,1)};sfb(SHe,'EcorePackageImpl/12',1245);feb(1246,1,OKe,nbe);_.fk=function obe(a){return ZD(a,411)};_.gk=function pbe(a){return $C(s7,mKe,62,a,0,1)};sfb(SHe,'EcorePackageImpl/13',1246);feb(1247,1,OKe,qbe);_.fk=function rbe(a){return ZD(a,241)};_.gk=function sbe(a){return $C(t7,rve,241,a,0,1)};sfb(SHe,'EcorePackageImpl/14',1247);feb(1248,1,OKe,tbe);_.fk=function ube(a){return ZD(a,518)};_.gk=function vbe(a){return $C(u7,rve,2116,a,0,1)};sfb(SHe,'EcorePackageImpl/15',1248);feb(1249,1,OKe,wbe);_.fk=function xbe(a){return ZD(a,102)};_.gk=function ybe(a){return $C(v7,lKe,19,a,0,1)};sfb(SHe,'EcorePackageImpl/16',1249);feb(1250,1,OKe,zbe);_.fk=function Abe(a){return ZD(a,179)};_.gk=function Bbe(a){return $C(y7,lKe,179,a,0,1)};sfb(SHe,'EcorePackageImpl/17',1250);feb(1251,1,OKe,Cbe);_.fk=function Dbe(a){return ZD(a,481)};_.gk=function Ebe(a){return $C(A7,rve,481,a,0,1)};sfb(SHe,'EcorePackageImpl/18',1251);feb(1252,1,OKe,Fbe);_.fk=function Gbe(a){return ZD(a,561)};_.gk=function Hbe(a){return $C(C8,LJe,561,a,0,1)};sfb(SHe,'EcorePackageImpl/19',1252);feb(1235,1,OKe,Ibe);_.fk=function Jbe(a){return ZD(a,331)};_.gk=function Kbe(a){return $C(g7,lKe,35,a,0,1)};sfb(SHe,'EcorePackageImpl/2',1235);feb(1253,1,OKe,Lbe);_.fk=function Mbe(a){return ZD(a,248)};_.gk=function Nbe(a){return $C(o7,sKe,89,a,0,1)};sfb(SHe,'EcorePackageImpl/20',1253);feb(1254,1,OKe,Obe);_.fk=function Pbe(a){return ZD(a,457)};_.gk=function Qbe(a){return $C(z7,rve,850,a,0,1)};sfb(SHe,'EcorePackageImpl/21',1254);feb(1255,1,OKe,Rbe);_.fk=function Sbe(a){return $D(a)};_.gk=function Tbe(a){return $C(QI,Nve,485,a,8,1)};sfb(SHe,'EcorePackageImpl/22',1255);feb(1256,1,OKe,Ube);_.fk=function Vbe(a){return ZD(a,195)};_.gk=function Wbe(a){return $C(gE,Nve,195,a,0,2)};sfb(SHe,'EcorePackageImpl/23',1256);feb(1257,1,OKe,Xbe);_.fk=function Ybe(a){return ZD(a,222)};_.gk=function Zbe(a){return $C(RI,Nve,222,a,0,1)};sfb(SHe,'EcorePackageImpl/24',1257);feb(1258,1,OKe,$be);_.fk=function _be(a){return ZD(a,180)};_.gk=function ace(a){return $C(SI,Nve,180,a,0,1)};sfb(SHe,'EcorePackageImpl/25',1258);feb(1259,1,OKe,bce);_.fk=function cce(a){return ZD(a,206)};_.gk=function dce(a){return $C(qK,Nve,206,a,0,1)};sfb(SHe,'EcorePackageImpl/26',1259);feb(1260,1,OKe,ece);_.fk=function fce(a){return false};_.gk=function gce(a){return $C(T6,rve,2215,a,0,1)};sfb(SHe,'EcorePackageImpl/27',1260);feb(1261,1,OKe,hce);_.fk=function ice(a){return _D(a)};_.gk=function jce(a){return $C(VI,Nve,345,a,7,1)};sfb(SHe,'EcorePackageImpl/28',1261);feb(1262,1,OKe,kce);_.fk=function lce(a){return ZD(a,61)};_.gk=function mce(a){return $C(Y6,Ize,61,a,0,1)};sfb(SHe,'EcorePackageImpl/29',1262);feb(1236,1,OKe,nce);_.fk=function oce(a){return ZD(a,519)};_.gk=function pce(a){return $C(f7,{3:1,4:1,5:1,2033:1},598,a,0,1)};sfb(SHe,'EcorePackageImpl/3',1236);feb(1263,1,OKe,qce);_.fk=function rce(a){return ZD(a,582)};_.gk=function sce(a){return $C(Z6,rve,2039,a,0,1)};sfb(SHe,'EcorePackageImpl/30',1263);feb(1264,1,OKe,tce);_.fk=function uce(a){return ZD(a,160)};_.gk=function vce(a){return $C(Tbb,Ize,160,a,0,1)};sfb(SHe,'EcorePackageImpl/31',1264);feb(1265,1,OKe,wce);_.fk=function xce(a){return ZD(a,76)};_.gk=function yce(a){return $C(Jbb,PKe,76,a,0,1)};sfb(SHe,'EcorePackageImpl/32',1265);feb(1266,1,OKe,zce);_.fk=function Ace(a){return ZD(a,161)};_.gk=function Bce(a){return $C(ZI,Nve,161,a,0,1)};sfb(SHe,'EcorePackageImpl/33',1266);feb(1267,1,OKe,Cce);_.fk=function Dce(a){return ZD(a,17)};_.gk=function Ece(a){return $C(bJ,Nve,17,a,0,1)};sfb(SHe,'EcorePackageImpl/34',1267);feb(1268,1,OKe,Fce);_.fk=function Gce(a){return ZD(a,297)};_.gk=function Hce(a){return $C(UI,rve,297,a,0,1)};sfb(SHe,'EcorePackageImpl/35',1268);feb(1269,1,OKe,Ice);_.fk=function Jce(a){return ZD(a,168)};_.gk=function Kce(a){return $C(eJ,Nve,168,a,0,1)};sfb(SHe,'EcorePackageImpl/36',1269);feb(1270,1,OKe,Lce);_.fk=function Mce(a){return ZD(a,85)};_.gk=function Nce(a){return $C(VK,rve,85,a,0,1)};sfb(SHe,'EcorePackageImpl/37',1270);feb(1271,1,OKe,Oce);_.fk=function Pce(a){return ZD(a,599)};_.gk=function Qce(a){return $C(Aab,rve,599,a,0,1)};sfb(SHe,'EcorePackageImpl/38',1271);feb(1272,1,OKe,Rce);_.fk=function Sce(a){return false};_.gk=function Tce(a){return $C(zab,rve,2216,a,0,1)};sfb(SHe,'EcorePackageImpl/39',1272);feb(1237,1,OKe,Uce);_.fk=function Vce(a){return ZD(a,90)};_.gk=function Wce(a){return $C(h7,rve,29,a,0,1)};sfb(SHe,'EcorePackageImpl/4',1237);feb(1273,1,OKe,Xce);_.fk=function Yce(a){return ZD(a,191)};_.gk=function Zce(a){return $C(lJ,Nve,191,a,0,1)};sfb(SHe,'EcorePackageImpl/40',1273);feb(1274,1,OKe,$ce);_.fk=function _ce(a){return bE(a)};_.gk=function ade(a){return $C(qJ,Nve,2,a,6,1)};sfb(SHe,'EcorePackageImpl/41',1274);feb(1275,1,OKe,bde);_.fk=function cde(a){return ZD(a,596)};_.gk=function dde(a){return $C(a7,rve,596,a,0,1)};sfb(SHe,'EcorePackageImpl/42',1275);feb(1276,1,OKe,ede);_.fk=function fde(a){return false};_.gk=function gde(a){return $C($6,Nve,2217,a,0,1)};sfb(SHe,'EcorePackageImpl/43',1276);feb(1277,1,OKe,hde);_.fk=function ide(a){return ZD(a,44)};_.gk=function jde(a){return $C(UK,Zve,44,a,0,1)};sfb(SHe,'EcorePackageImpl/44',1277);feb(1238,1,OKe,kde);_.fk=function lde(a){return ZD(a,142)};_.gk=function mde(a){return $C(i7,rve,142,a,0,1)};sfb(SHe,'EcorePackageImpl/5',1238);feb(1239,1,OKe,nde);_.fk=function ode(a){return ZD(a,156)};_.gk=function pde(a){return $C(k7,rve,156,a,0,1)};sfb(SHe,'EcorePackageImpl/6',1239);feb(1240,1,OKe,qde);_.fk=function rde(a){return ZD(a,469)};_.gk=function sde(a){return $C(m7,rve,685,a,0,1)};sfb(SHe,'EcorePackageImpl/7',1240);feb(1241,1,OKe,tde);_.fk=function ude(a){return ZD(a,582)};_.gk=function vde(a){return $C(l7,rve,694,a,0,1)};sfb(SHe,'EcorePackageImpl/8',1241);feb(1242,1,OKe,wde);_.fk=function xde(a){return ZD(a,480)};_.gk=function yde(a){return $C(n7,rve,480,a,0,1)};sfb(SHe,'EcorePackageImpl/9',1242);feb(1038,2080,JJe,Cde);_.Mi=function Dde(a,b){zde(this,RD(b,424));};_.Qi=function Ede(a,b){Ade(this,a,RD(b,424));};sfb(SHe,'MinimalEObjectImpl/1ArrayDelegatingAdapterList',1038);feb(1039,152,GJe,Fde);_.jj=function Gde(){return this.a.a};sfb(SHe,'MinimalEObjectImpl/1ArrayDelegatingAdapterList/1',1039);feb(1067,1066,{},Ide);sfb('org.eclipse.emf.ecore.plugin','EcorePlugin',1067);var Aab=ufb(QKe,'Resource');feb(799,1524,RKe);_.Hl=function Mde(a){};_.Il=function Nde(a){};_.El=function Ode(){return !this.a&&(this.a=new Zde(this)),this.a};_.Fl=function Pde(a){var b,c,d,e,f;d=a.length;if(d>0){BFb(0,a.length);if(a.charCodeAt(0)==47){f=new cnb(4);e=1;for(b=1;b0&&(a=(AFb(0,c,a.length),a.substr(0,c)));}}}return Kde(this,a)};_.Gl=function Qde(){return this.c};_.Ib=function Rde(){var a;return nfb(this.Rm)+'@'+(a=tb(this)>>>0,a.toString(16))+" uri='"+this.d+"'"};_.b=false;sfb(SKe,'ResourceImpl',799);feb(1525,799,RKe,Sde);sfb(SKe,'BinaryResourceImpl',1525);feb(1190,708,QIe);_.bj=function Vde(a){return ZD(a,58)?Tde(this,RD(a,58)):ZD(a,599)?new dMd(RD(a,599).El()):dE(a)===dE(this.f)?RD(a,16).Kc():(jQd(),iQd.a)};_.Ob=function Wde(){return Ude(this)};_.a=false;sfb(ZJe,'EcoreUtil/ContentTreeIterator',1190);feb(1526,1190,QIe,Xde);_.bj=function Yde(a){return dE(a)===dE(this.f)?RD(a,15).Kc():new _je(RD(a,58))};sfb(SKe,'ResourceImpl/5',1526);feb(658,2092,nKe,Zde);_.Hc=function $de(a){return this.i<=4?PHd(this,a):ZD(a,54)&&RD(a,54).Jh()==this.a};_.Mi=function _de(a,b){a==this.i-1&&(this.a.b||(this.a.b=true,null));};_.Oi=function aee(a,b){a==0?this.a.b||(this.a.b=true,null):$Gd(this,a,b);};_.Qi=function bee(a,b){};_.Ri=function cee(a,b,c){};_.Lj=function dee(){return 2};_.jj=function eee(){return this.a};_.Mj=function fee(){return true};_.Nj=function gee(a,b){var c;c=RD(a,54);b=c.fi(this.a,b);return b};_.Oj=function hee(a,b){var c;c=RD(a,54);return c.fi(null,b)};_.Pj=function iee(){return false};_.Si=function jee(){return true};_.aj=function kee(a){return $C(r7,rve,58,a,0,1)};_.Yi=function lee(){return false};sfb(SKe,'ResourceImpl/ContentsEList',658);feb(970,2062,kwe,mee);_.fd=function nee(a){return this.a.Ki(a)};_.gc=function oee(){return this.a.gc()};sfb(ZJe,'AbstractSequentialInternalEList/1',970);var hke,ike,jke,kke;feb(634,1,{},Yee);var pee,qee;sfb(ZJe,'BasicExtendedMetaData',634);feb(1181,1,{},afe);_.Jl=function bfe(){return null};_.Kl=function cfe(){this.a==-2&&$ee(this,uee(this.d,this.b));return this.a};_.Ll=function dfe(){return null};_.Ml=function efe(){return yob(),yob(),vob};_.xe=function ffe(){this.c==fLe&&_ee(this,zee(this.d,this.b));return this.c};_.Nl=function gfe(){return 0};_.a=-2;_.c=fLe;sfb(ZJe,'BasicExtendedMetaData/EClassExtendedMetaDataImpl',1181);feb(1182,1,{},mfe);_.Jl=function nfe(){this.a==(ree(),pee)&&hfe(this,tee(this.f,this.b));return this.a};_.Kl=function ofe(){return 0};_.Ll=function pfe(){this.c==(ree(),pee)&&ife(this,xee(this.f,this.b));return this.c};_.Ml=function qfe(){!this.d&&jfe(this,yee(this.f,this.b));return this.d};_.xe=function rfe(){this.e==fLe&&kfe(this,zee(this.f,this.b));return this.e};_.Nl=function sfe(){this.g==-2&&lfe(this,Cee(this.f,this.b));return this.g};_.e=fLe;_.g=-2;sfb(ZJe,'BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl',1182);feb(1180,1,{},wfe);_.b=false;_.c=false;sfb(ZJe,'BasicExtendedMetaData/EPackageExtendedMetaDataImpl',1180);feb(1183,1,{},Jfe);_.c=-2;_.e=fLe;_.f=fLe;sfb(ZJe,'BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl',1183);feb(593,632,oKe,Kfe);_.Lj=function Lfe(){return this.c};_.ol=function Mfe(){return false};_.Wi=function Nfe(a,b){return b};_.c=0;sfb(ZJe,'EDataTypeEList',593);var Tbb=ufb(ZJe,'FeatureMap');feb(78,593,{3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,79:1,160:1,220:1,2036:1,71:1,97:1},Uge);_.bd=function Vge(a,b){Ofe(this,a,RD(b,76));};_.Fc=function Wge(a){return Rfe(this,RD(a,76))};_.Hi=function _ge(a){Wfe(this,RD(a,76));};_.Nj=function khe(a,b){return mge(this,RD(a,76),b)};_.Oj=function lhe(a,b){return oge(this,RD(a,76),b)};_.Ti=function nhe(a,b){return uge(this,a,b)};_.Wi=function phe(a,b){return zge(this,a,RD(b,76))};_.hd=function rhe(a,b){return Cge(this,a,RD(b,76))};_.Uj=function vhe(a,b){return Ige(this,RD(a,76),b)};_.Vj=function whe(a,b){return Kge(this,RD(a,76),b)};_.Wj=function xhe(a,b,c){return Lge(this,RD(a,76),RD(b,76),c)};_.Zi=function zhe(a,b){return Tge(this,a,RD(b,76))};_.Ol=function Xge(a,b){return Qfe(this,a,b)};_.cd=function Yge(a,b){var c,d,e,f,g,h,i,j,k;j=new ZHd(b.gc());for(e=b.Kc();e.Ob();){d=RD(e.Pb(),76);f=d.Lk();if(qke(this.e,f)){(!f.Si()||!cge(this,f,d.md())&&!PHd(j,d))&&WGd(j,d);}else {k=pke(this.e.Dh(),f);c=RD(this.g,124);g=true;for(h=0;h=0){b=a[this.c];if(this.k.am(b.Lk())){this.j=this.f?b:b.md();this.i=-2;return true}}this.i=-1;this.g=-1;return false};sfb(ZJe,'BasicFeatureMap/FeatureEIterator',420);feb(676,420,Jve,She);_.ul=function The(){return true};sfb(ZJe,'BasicFeatureMap/ResolvingFeatureEIterator',676);feb(968,496,uKe,Uhe);_.pj=function Vhe(){return this};sfb(ZJe,'EContentsEList/1',968);feb(969,496,uKe,Whe);_.ul=function Xhe(){return false};sfb(ZJe,'EContentsEList/2',969);feb(967,287,vKe,Yhe);_.wl=function Zhe(a){};_.Ob=function $he(){return false};_.Sb=function _he(){return false};sfb(ZJe,'EContentsEList/FeatureIteratorImpl/1',967);feb(840,593,oKe,aie);_.Ni=function bie(){this.a=true;};_.Qj=function cie(){return this.a};_.Gk=function die(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EDataTypeEList/Unsettable',840);feb(1958,593,oKe,eie);_.Si=function fie(){return true};sfb(ZJe,'EDataTypeUniqueEList',1958);feb(1959,840,oKe,gie);_.Si=function hie(){return true};sfb(ZJe,'EDataTypeUniqueEList/Unsettable',1959);feb(147,83,oKe,iie);_.nl=function jie(){return true};_.Wi=function kie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentEList/Resolving',147);feb(1184,555,oKe,lie);_.nl=function mie(){return true};_.Wi=function nie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentEList/Unsettable/Resolving',1184);feb(766,14,oKe,oie);_.Ni=function pie(){this.a=true;};_.Qj=function qie(){return this.a};_.Gk=function rie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectContainmentWithInverseEList/Unsettable',766);feb(1222,766,oKe,sie);_.nl=function tie(){return true};_.Wi=function uie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentWithInverseEList/Unsettable/Resolving',1222);feb(757,505,oKe,vie);_.Ni=function wie(){this.a=true;};_.Qj=function xie(){return this.a};_.Gk=function yie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectEList/Unsettable',757);feb(338,505,oKe,zie);_.nl=function Aie(){return true};_.Wi=function Bie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectResolvingEList',338);feb(1844,757,oKe,Cie);_.nl=function Die(){return true};_.Wi=function Eie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectResolvingEList/Unsettable',1844);feb(1527,1,{},Hie);var Fie;sfb(ZJe,'EObjectValidator',1527);feb(559,505,oKe,Iie);_.il=function Jie(){return this.d};_.jl=function Kie(){return this.b};_.Mj=function Lie(){return true};_.ml=function Mie(){return true};_.b=0;sfb(ZJe,'EObjectWithInverseEList',559);feb(1225,559,oKe,Nie);_.ll=function Oie(){return true};sfb(ZJe,'EObjectWithInverseEList/ManyInverse',1225);feb(635,559,oKe,Pie);_.Ni=function Qie(){this.a=true;};_.Qj=function Rie(){return this.a};_.Gk=function Sie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectWithInverseEList/Unsettable',635);feb(1224,635,oKe,Tie);_.ll=function Uie(){return true};sfb(ZJe,'EObjectWithInverseEList/Unsettable/ManyInverse',1224);feb(767,559,oKe,Vie);_.nl=function Wie(){return true};_.Wi=function Xie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectWithInverseResolvingEList',767);feb(32,767,oKe,Yie);_.ll=function Zie(){return true};sfb(ZJe,'EObjectWithInverseResolvingEList/ManyInverse',32);feb(768,635,oKe,$ie);_.nl=function _ie(){return true};_.Wi=function aje(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectWithInverseResolvingEList/Unsettable',768);feb(1223,768,oKe,bje);_.ll=function cje(){return true};sfb(ZJe,'EObjectWithInverseResolvingEList/Unsettable/ManyInverse',1223);feb(1185,632,oKe);_.Li=function dje(){return (this.b&1792)==0};_.Ni=function eje(){this.b|=1;};_.kl=function fje(){return (this.b&4)!=0};_.Mj=function gje(){return (this.b&40)!=0};_.ll=function hje(){return (this.b&16)!=0};_.ml=function ije(){return (this.b&8)!=0};_.nl=function jje(){return (this.b&cKe)!=0};_.al=function kje(){return (this.b&32)!=0};_.ol=function lje(){return (this.b&gwe)!=0};_.fk=function mje(a){return !this.d?this.Lk().Hk().fk(a):QRd(this.d,a)};_.Qj=function nje(){return (this.b&2)!=0?(this.b&1)!=0:this.i!=0};_.Si=function oje(){return (this.b&128)!=0};_.Gk=function qje(){var a;sLd(this);if((this.b&2)!=0){if(Mvd(this.e)){a=(this.b&1)!=0;this.b&=-2;eZd(this,new Q3d(this.e,2,BYd(this.e.Dh(),this.Lk()),a,false));}else {this.b&=-2;}}};_.Yi=function rje(){return (this.b&1536)==0};_.b=0;sfb(ZJe,'EcoreEList/Generic',1185);feb(1186,1185,oKe,sje);_.Lk=function tje(){return this.a};sfb(ZJe,'EcoreEList/Dynamic',1186);feb(765,66,PIe,uje);_.aj=function vje(a){return IMd(this.a.a,a)};sfb(ZJe,'EcoreEMap/1',765);feb(764,83,oKe,wje);_.Mi=function xje(a,b){UNd(this.b,RD(b,136));};_.Oi=function yje(a,b){TNd(this.b);};_.Pi=function zje(a,b,c){var d;++(d=this.b,RD(b,136),d).e;};_.Qi=function Aje(a,b){VNd(this.b,RD(b,136));};_.Ri=function Bje(a,b,c){VNd(this.b,RD(c,136));dE(c)===dE(b)&&RD(c,136).Ci(aOd(RD(b,136).ld()));UNd(this.b,RD(b,136));};sfb(ZJe,'EcoreEMap/DelegateEObjectContainmentEList',764);feb(1220,141,_Je,Cje);sfb(ZJe,'EcoreEMap/Unsettable',1220);feb(1221,764,oKe,Dje);_.Ni=function Eje(){this.a=true;};_.Qj=function Fje(){return this.a};_.Gk=function Gje(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList',1221);feb(1189,215,Hxe,Zje);_.a=false;_.b=false;sfb(ZJe,'EcoreUtil/Copier',1189);feb(759,1,Ave,_je);_.Nb=function ake(a){Ztb(this,a);};_.Ob=function bke(){return $je(this)};_.Pb=function cke(){var a;$je(this);a=this.b;this.b=null;return a};_.Qb=function dke(){this.a.Qb();};sfb(ZJe,'EcoreUtil/ProperContentIterator',759);feb(1528,1527,{},gke);var eke;sfb(ZJe,'EcoreValidator',1528);var mke;ufb(ZJe,'FeatureMapUtil/Validator');feb(1295,1,{2041:1},rke);_.am=function ske(a){return true};sfb(ZJe,'FeatureMapUtil/1',1295);feb(773,1,{2041:1},wke);_.am=function xke(a){var b;if(this.c==a)return true;b=TD(Wjb(this.a,a));if(b==null){if(vke(this,a)){yke(this.a,a,(Geb(),Feb));return true}else {yke(this.a,a,(Geb(),Eeb));return false}}else {return b==(Geb(),Feb)}};_.e=false;var tke;sfb(ZJe,'FeatureMapUtil/BasicValidator',773);feb(774,45,Hxe,zke);sfb(ZJe,'FeatureMapUtil/BasicValidator/Cache',774);feb(509,56,{20:1,31:1,56:1,16:1,15:1,61:1,79:1,71:1,97:1},Eke);_.bd=function Fke(a,b){Pfe(this.c,this.b,a,b);};_.Fc=function Gke(a){return Qfe(this.c,this.b,a)};_.cd=function Hke(a,b){return Sfe(this.c,this.b,a,b)};_.Gc=function Ike(a){return Ake(this,a)};_.Gi=function Jke(a,b){Ufe(this.c,this.b,a,b);};_.Wk=function Kke(a,b){return Xfe(this.c,this.b,a,b)};_.$i=function Lke(a){return hge(this.c,this.b,a,false)};_.Ii=function Mke(){return Yfe(this.c,this.b)};_.Ji=function Nke(){return Zfe(this.c,this.b)};_.Ki=function Oke(a){return $fe(this.c,this.b,a)};_.Xk=function Pke(a,b){return Bke(this,a,b)};_.$b=function Qke(){Cke(this);};_.Hc=function Rke(a){return cge(this.c,this.b,a)};_.Ic=function Ske(a){return ege(this.c,this.b,a)};_.Xb=function Tke(a){return hge(this.c,this.b,a,true)};_.Fk=function Uke(a){return this};_.dd=function Vke(a){return jge(this.c,this.b,a)};_.dc=function Wke(){return Dke(this)};_.Qj=function Xke(){return !pge(this.c,this.b)};_.Kc=function Yke(){return qge(this.c,this.b)};_.ed=function Zke(){return sge(this.c,this.b)};_.fd=function $ke(a){return tge(this.c,this.b,a)};_.Ti=function _ke(a,b){return vge(this.c,this.b,a,b)};_.Ui=function ale(a,b){wge(this.c,this.b,a,b);};_.gd=function ble(a){return xge(this.c,this.b,a)};_.Mc=function cle(a){return yge(this.c,this.b,a)};_.hd=function dle(a,b){return Ege(this.c,this.b,a,b)};_.Wb=function ele(a){bge(this.c,this.b);Ake(this,RD(a,15));};_.gc=function fle(){return Nge(this.c,this.b)};_.Pc=function gle(){return Oge(this.c,this.b)};_.Qc=function hle(a){return Qge(this.c,this.b,a)};_.Ib=function ile(){var a,b;b=new Qhb;b.a+='[';for(a=Yfe(this.c,this.b);Bhe(a);){Nhb(b,Ghb(Dhe(a)));Bhe(a)&&(b.a+=pve,b);}b.a+=']';return b.a};_.Gk=function jle(){bge(this.c,this.b);};sfb(ZJe,'FeatureMapUtil/FeatureEList',509);feb(644,39,GJe,lle);_.hj=function mle(a){return kle(this,a)};_.mj=function nle(a){var b,c,d,e,f,g,h;switch(this.d){case 1:case 2:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.g=a.ij();a.gj()==1&&(this.d=1);return true}break}case 3:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=5;b=new ZHd(2);WGd(b,this.g);WGd(b,a.ij());this.g=b;return true}break}}break}case 5:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){c=RD(this.g,16);c.Fc(a.ij());return true}break}}break}case 4:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=1;this.g=a.ij();return true}break}case 4:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=6;h=new ZHd(2);WGd(h,this.n);WGd(h,a.kj());this.n=h;g=cD(WC(kE,1),Pwe,28,15,[this.o,a.lj()]);this.g=g;return true}break}}break}case 6:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){c=RD(this.n,16);c.Fc(a.kj());g=RD(this.g,53);d=$C(kE,Pwe,28,g.length+1,15,1);hib(g,0,d,0,g.length);d[g.length]=a.lj();this.g=d;return true}break}}break}}return false};sfb(ZJe,'FeatureMapUtil/FeatureENotificationImpl',644);feb(564,509,{20:1,31:1,56:1,16:1,15:1,61:1,79:1,160:1,220:1,2036:1,71:1,97:1},ole);_.Ol=function ple(a,b){return Qfe(this.c,a,b)};_.Pl=function qle(a,b,c){return Xfe(this.c,a,b,c)};_.Ql=function rle(a,b,c){return age(this.c,a,b,c)};_.Rl=function sle(){return this};_.Sl=function tle(a,b){return ige(this.c,a,b)};_.Tl=function ule(a){return RD(hge(this.c,this.b,a,false),76).Lk()};_.Ul=function vle(a){return RD(hge(this.c,this.b,a,false),76).md()};_.Vl=function wle(){return this.a};_.Wl=function xle(a){return !pge(this.c,a)};_.Xl=function yle(a,b){Fge(this.c,a,b);};_.Yl=function zle(a){return Gge(this.c,a)};_.Zl=function Ale(a){Sge(this.c,a);};sfb(ZJe,'FeatureMapUtil/FeatureFeatureMap',564);feb(1294,1,$Je,Ble);_.Fk=function Cle(a){return hge(this.b,this.a,-1,a)};_.Qj=function Dle(){return !pge(this.b,this.a)};_.Wb=function Ele(a){Fge(this.b,this.a,a);};_.Gk=function Fle(){bge(this.b,this.a);};sfb(ZJe,'FeatureMapUtil/FeatureValue',1294);var Gle,Hle,Ile,Jle,Kle;var Vbb=ufb(hLe,'AnyType');feb(680,63,swe,Mle);sfb(hLe,'InvalidDatatypeValueException',680);var Xbb=ufb(hLe,iLe);var Ybb=ufb(hLe,jLe);var Zbb=ufb(hLe,kLe);var Nle;var Ple;var Rle,Sle,Tle,Ule,Vle,Wle,Xle,Yle,Zle,$le,_le,ame,bme,cme,dme,eme,fme,gme,hme,ime,jme,kme,lme,mme;feb(844,516,{110:1,94:1,93:1,58:1,54:1,99:1,857:1},ome);_.Lh=function pme(a,b,c){switch(a){case 0:if(c)return !this.c&&(this.c=new Uge(this,0)),this.c;return !this.c&&(this.c=new Uge(this,0)),this.c.b;case 1:if(c)return !this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160);return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Vl();case 2:if(c)return !this.b&&(this.b=new Uge(this,2)),this.b;return !this.b&&(this.b=new Uge(this,2)),this.b.b;}return zvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Uh=function qme(a,b,c){var d;switch(b){case 0:return !this.c&&(this.c=new Uge(this,0)),_fe(this.c,a,c);case 1:return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),71)).Xk(a,c);case 2:return !this.b&&(this.b=new Uge(this,2)),_fe(this.b,a,c);}return d=RD(vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),b),69),d.wk().Ak(this,Yvd(this),b-AYd(this.ii()),a,c)};_.Wh=function rme(a){switch(a){case 0:return !!this.c&&this.c.i!=0;case 1:return !(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).dc();case 2:return !!this.b&&this.b.i!=0;}return Avd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function sme(a,b){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));Dge(this.c,b);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Wb(b);return;case 2:!this.b&&(this.b=new Uge(this,2));Dge(this.b,b);return;}Bvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function tme(){return nme(),Rle};_.ki=function ume(a){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));sLd(this.c);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).$b();return;case 2:!this.b&&(this.b=new Uge(this,2));sLd(this.b);return;}Cvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function vme(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (mixed: ';Mhb(a,this.c);a.a+=', anyAttribute: ';Mhb(a,this.b);a.a+=')';return a.a};sfb(lLe,'AnyTypeImpl',844);feb(681,516,{110:1,94:1,93:1,58:1,54:1,99:1,2119:1,681:1},yme);_.Lh=function zme(a,b,c){switch(a){case 0:return this.a;case 1:return this.b;}return zvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Wh=function Ame(a){switch(a){case 0:return this.a!=null;case 1:return this.b!=null;}return Avd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Bme(a,b){switch(a){case 0:wme(this,WD(b));return;case 1:xme(this,WD(b));return;}Bvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Cme(){return nme(),cme};_.ki=function Dme(a){switch(a){case 0:this.a=null;return;case 1:this.b=null;return;}Cvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function Eme(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (data: ';Nhb(a,this.a);a.a+=', target: ';Nhb(a,this.b);a.a+=')';return a.a};_.a=null;_.b=null;sfb(lLe,'ProcessingInstructionImpl',681);feb(682,844,{110:1,94:1,93:1,58:1,54:1,99:1,857:1,2120:1,682:1},Hme);_.Lh=function Ime(a,b,c){switch(a){case 0:if(c)return !this.c&&(this.c=new Uge(this,0)),this.c;return !this.c&&(this.c=new Uge(this,0)),this.c.b;case 1:if(c)return !this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160);return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Vl();case 2:if(c)return !this.b&&(this.b=new Uge(this,2)),this.b;return !this.b&&(this.b=new Uge(this,2)),this.b.b;case 3:return !this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true));case 4:return Ije(this.a,(!this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))));case 5:return this.a;}return zvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Wh=function Jme(a){switch(a){case 0:return !!this.c&&this.c.i!=0;case 1:return !(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).dc();case 2:return !!this.b&&this.b.i!=0;case 3:return !this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))!=null;case 4:return Ije(this.a,(!this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))))!=null;case 5:return !!this.a;}return Avd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Kme(a,b){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));Dge(this.c,b);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Wb(b);return;case 2:!this.b&&(this.b=new Uge(this,2));Dge(this.b,b);return;case 3:Gme(this,WD(b));return;case 4:Gme(this,Hje(this.a,b));return;case 5:Fme(this,RD(b,156));return;}Bvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Lme(){return nme(),eme};_.ki=function Mme(a){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));sLd(this.c);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).$b();return;case 2:!this.b&&(this.b=new Uge(this,2));sLd(this.b);return;case 3:!this.c&&(this.c=new Uge(this,0));Fge(this.c,(nme(),fme),null);return;case 4:Gme(this,Hje(this.a,null));return;case 5:this.a=null;return;}Cvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};sfb(lLe,'SimpleAnyTypeImpl',682);feb(683,516,{110:1,94:1,93:1,58:1,54:1,99:1,2121:1,683:1},Nme);_.Lh=function Ome(a,b,c){switch(a){case 0:if(c)return !this.a&&(this.a=new Uge(this,0)),this.a;return !this.a&&(this.a=new Uge(this,0)),this.a.b;case 1:return c?(!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),this.b):(!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),dOd(this.b));case 2:return c?(!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),this.c):(!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),dOd(this.c));case 3:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),ime));case 4:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),jme));case 5:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),lme));case 6:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),mme));}return zvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Uh=function Pme(a,b,c){var d;switch(b){case 0:return !this.a&&(this.a=new Uge(this,0)),_fe(this.a,a,c);case 1:return !this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),BVd(this.b,a,c);case 2:return !this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),BVd(this.c,a,c);case 5:return !this.a&&(this.a=new Uge(this,0)),Bke(rge(this.a,(nme(),lme)),a,c);}return d=RD(vYd((this.j&2)==0?(nme(),hme):(!this.k&&(this.k=new fUd),this.k).Nk(),b),69),d.wk().Ak(this,Yvd(this),b-AYd((nme(),hme)),a,c)};_.Wh=function Qme(a){switch(a){case 0:return !!this.a&&this.a.i!=0;case 1:return !!this.b&&this.b.f!=0;case 2:return !!this.c&&this.c.f!=0;case 3:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),ime)));case 4:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),jme)));case 5:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),lme)));case 6:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),mme)));}return Avd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Rme(a,b){switch(a){case 0:!this.a&&(this.a=new Uge(this,0));Dge(this.a,b);return;case 1:!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1));CVd(this.b,b);return;case 2:!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2));CVd(this.c,b);return;case 3:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),ime)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,ime),RD(b,16));return;case 4:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),jme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,jme),RD(b,16));return;case 5:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),lme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,lme),RD(b,16));return;case 6:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),mme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,mme),RD(b,16));return;}Bvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Sme(){return nme(),hme};_.ki=function Tme(a){switch(a){case 0:!this.a&&(this.a=new Uge(this,0));sLd(this.a);return;case 1:!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1));this.b.c.$b();return;case 2:!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2));this.c.c.$b();return;case 3:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),ime)));return;case 4:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),jme)));return;case 5:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),lme)));return;case 6:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),mme)));return;}Cvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function Ume(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (mixed: ';Mhb(a,this.a);a.a+=')';return a.a};sfb(lLe,'XMLTypeDocumentRootImpl',683);feb(2028,720,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1,2122:1},rne);_.ri=function sne(a,b){switch(a.hk()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return b==null?null:jeb(b);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return WD(b);case 6:return _me(RD(b,195));case 12:case 47:case 49:case 11:return tAd(this,a,b);case 13:return b==null?null:yib(RD(b,247));case 15:case 14:return b==null?null:ane(Kfb(UD(b)));case 17:return bne((nme(),b));case 18:return bne(b);case 21:case 20:return b==null?null:cne(RD(b,161).a);case 27:return dne(RD(b,195));case 30:return ene((nme(),RD(b,15)));case 31:return ene(RD(b,15));case 40:return hne((nme(),b));case 42:return fne((nme(),b));case 43:return fne(b);case 59:case 48:return gne((nme(),b));default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function tne(a){var b,c,d,e,f;switch(a.G==-1&&(a.G=(c=BXd(a),c?fZd(c.vi(),a):-1)),a.G){case 0:return b=new ome,b;case 1:return d=new yme,d;case 2:return e=new Hme,e;case 3:return f=new Nme,f;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function une(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;switch(a.hk()){case 5:case 52:case 4:return b;case 6:return ine(b);case 8:case 7:return b==null?null:$me(b);case 9:return b==null?null:$eb(Oeb((d=nue(b,true),d.length>0&&(BFb(0,d.length),d.charCodeAt(0)==43)?(BFb(1,d.length+1),d.substr(1)):d),-128,127)<<24>>24);case 10:return b==null?null:$eb(Oeb((e=nue(b,true),e.length>0&&(BFb(0,e.length),e.charCodeAt(0)==43)?(BFb(1,e.length+1),e.substr(1)):e),-128,127)<<24>>24);case 11:return WD(uAd(this,(nme(),Vle),b));case 12:return WD(uAd(this,(nme(),Wle),b));case 13:return b==null?null:new Bib(nue(b,true));case 15:case 14:return jne(b);case 16:return WD(uAd(this,(nme(),Xle),b));case 17:return kne((nme(),b));case 18:return kne(b);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return nue(b,true);case 21:case 20:return lne(b);case 22:return WD(uAd(this,(nme(),Yle),b));case 23:return WD(uAd(this,(nme(),Zle),b));case 24:return WD(uAd(this,(nme(),$le),b));case 25:return WD(uAd(this,(nme(),_le),b));case 26:return WD(uAd(this,(nme(),ame),b));case 27:return mne(b);case 30:return nne((nme(),b));case 31:return nne(b);case 32:return b==null?null:sgb(Oeb((k=nue(b,true),k.length>0&&(BFb(0,k.length),k.charCodeAt(0)==43)?(BFb(1,k.length+1),k.substr(1)):k),qwe,lve));case 33:return b==null?null:new ejb((l=nue(b,true),l.length>0&&(BFb(0,l.length),l.charCodeAt(0)==43)?(BFb(1,l.length+1),l.substr(1)):l));case 34:return b==null?null:sgb(Oeb((m=nue(b,true),m.length>0&&(BFb(0,m.length),m.charCodeAt(0)==43)?(BFb(1,m.length+1),m.substr(1)):m),qwe,lve));case 36:return b==null?null:Hgb(Peb((n=nue(b,true),n.length>0&&(BFb(0,n.length),n.charCodeAt(0)==43)?(BFb(1,n.length+1),n.substr(1)):n)));case 37:return b==null?null:Hgb(Peb((o=nue(b,true),o.length>0&&(BFb(0,o.length),o.charCodeAt(0)==43)?(BFb(1,o.length+1),o.substr(1)):o)));case 40:return qne((nme(),b));case 42:return one((nme(),b));case 43:return one(b);case 44:return b==null?null:new ejb((p=nue(b,true),p.length>0&&(BFb(0,p.length),p.charCodeAt(0)==43)?(BFb(1,p.length+1),p.substr(1)):p));case 45:return b==null?null:new ejb((q=nue(b,true),q.length>0&&(BFb(0,q.length),q.charCodeAt(0)==43)?(BFb(1,q.length+1),q.substr(1)):q));case 46:return nue(b,false);case 47:return WD(uAd(this,(nme(),bme),b));case 59:case 48:return pne((nme(),b));case 49:return WD(uAd(this,(nme(),dme),b));case 50:return b==null?null:bhb(Oeb((r=nue(b,true),r.length>0&&(BFb(0,r.length),r.charCodeAt(0)==43)?(BFb(1,r.length+1),r.substr(1)):r),BKe,32767)<<16>>16);case 51:return b==null?null:bhb(Oeb((f=nue(b,true),f.length>0&&(BFb(0,f.length),f.charCodeAt(0)==43)?(BFb(1,f.length+1),f.substr(1)):f),BKe,32767)<<16>>16);case 53:return WD(uAd(this,(nme(),gme),b));case 55:return b==null?null:bhb(Oeb((g=nue(b,true),g.length>0&&(BFb(0,g.length),g.charCodeAt(0)==43)?(BFb(1,g.length+1),g.substr(1)):g),BKe,32767)<<16>>16);case 56:return b==null?null:bhb(Oeb((h=nue(b,true),h.length>0&&(BFb(0,h.length),h.charCodeAt(0)==43)?(BFb(1,h.length+1),h.substr(1)):h),BKe,32767)<<16>>16);case 57:return b==null?null:Hgb(Peb((i=nue(b,true),i.length>0&&(BFb(0,i.length),i.charCodeAt(0)==43)?(BFb(1,i.length+1),i.substr(1)):i)));case 58:return b==null?null:Hgb(Peb((j=nue(b,true),j.length>0&&(BFb(0,j.length),j.charCodeAt(0)==43)?(BFb(1,j.length+1),j.substr(1)):j)));case 60:return b==null?null:sgb(Oeb((c=nue(b,true),c.length>0&&(BFb(0,c.length),c.charCodeAt(0)==43)?(BFb(1,c.length+1),c.substr(1)):c),qwe,lve));case 61:return b==null?null:sgb(Oeb(nue(b,true),qwe,lve));default:throw Adb(new agb(VHe+a.xe()+WHe));}};var Vme,Wme,Xme,Yme;sfb(lLe,'XMLTypeFactoryImpl',2028);feb(594,184,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1,2044:1,594:1},Bne);_.N=false;_.O=false;var wne=false;sfb(lLe,'XMLTypePackageImpl',594);feb(1961,1,{851:1},Ene);_.Kk=function Fne(){return rue(),que};sfb(lLe,'XMLTypePackageImpl/1',1961);feb(1970,1,OKe,Gne);_.fk=function Hne(a){return bE(a)};_.gk=function Ine(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/10',1970);feb(1971,1,OKe,Jne);_.fk=function Kne(a){return bE(a)};_.gk=function Lne(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/11',1971);feb(1972,1,OKe,Mne);_.fk=function Nne(a){return bE(a)};_.gk=function One(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/12',1972);feb(1973,1,OKe,Pne);_.fk=function Qne(a){return _D(a)};_.gk=function Rne(a){return $C(VI,Nve,345,a,7,1)};sfb(lLe,'XMLTypePackageImpl/13',1973);feb(1974,1,OKe,Sne);_.fk=function Tne(a){return bE(a)};_.gk=function Une(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/14',1974);feb(1975,1,OKe,Vne);_.fk=function Wne(a){return ZD(a,15)};_.gk=function Xne(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/15',1975);feb(1976,1,OKe,Yne);_.fk=function Zne(a){return ZD(a,15)};_.gk=function $ne(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/16',1976);feb(1977,1,OKe,_ne);_.fk=function aoe(a){return bE(a)};_.gk=function boe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/17',1977);feb(1978,1,OKe,coe);_.fk=function doe(a){return ZD(a,161)};_.gk=function eoe(a){return $C(ZI,Nve,161,a,0,1)};sfb(lLe,'XMLTypePackageImpl/18',1978);feb(1979,1,OKe,foe);_.fk=function goe(a){return bE(a)};_.gk=function hoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/19',1979);feb(1962,1,OKe,ioe);_.fk=function joe(a){return ZD(a,857)};_.gk=function koe(a){return $C(Vbb,rve,857,a,0,1)};sfb(lLe,'XMLTypePackageImpl/2',1962);feb(1980,1,OKe,loe);_.fk=function moe(a){return bE(a)};_.gk=function noe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/20',1980);feb(1981,1,OKe,ooe);_.fk=function poe(a){return bE(a)};_.gk=function qoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/21',1981);feb(1982,1,OKe,roe);_.fk=function soe(a){return bE(a)};_.gk=function toe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/22',1982);feb(1983,1,OKe,uoe);_.fk=function voe(a){return bE(a)};_.gk=function woe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/23',1983);feb(1984,1,OKe,xoe);_.fk=function yoe(a){return ZD(a,195)};_.gk=function zoe(a){return $C(gE,Nve,195,a,0,2)};sfb(lLe,'XMLTypePackageImpl/24',1984);feb(1985,1,OKe,Aoe);_.fk=function Boe(a){return bE(a)};_.gk=function Coe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/25',1985);feb(1986,1,OKe,Doe);_.fk=function Eoe(a){return bE(a)};_.gk=function Foe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/26',1986);feb(1987,1,OKe,Goe);_.fk=function Hoe(a){return ZD(a,15)};_.gk=function Ioe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/27',1987);feb(1988,1,OKe,Joe);_.fk=function Koe(a){return ZD(a,15)};_.gk=function Loe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/28',1988);feb(1989,1,OKe,Moe);_.fk=function Noe(a){return bE(a)};_.gk=function Ooe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/29',1989);feb(1963,1,OKe,Poe);_.fk=function Qoe(a){return ZD(a,681)};_.gk=function Roe(a){return $C(Xbb,rve,2119,a,0,1)};sfb(lLe,'XMLTypePackageImpl/3',1963);feb(1990,1,OKe,Soe);_.fk=function Toe(a){return ZD(a,17)};_.gk=function Uoe(a){return $C(bJ,Nve,17,a,0,1)};sfb(lLe,'XMLTypePackageImpl/30',1990);feb(1991,1,OKe,Voe);_.fk=function Woe(a){return bE(a)};_.gk=function Xoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/31',1991);feb(1992,1,OKe,Yoe);_.fk=function Zoe(a){return ZD(a,168)};_.gk=function $oe(a){return $C(eJ,Nve,168,a,0,1)};sfb(lLe,'XMLTypePackageImpl/32',1992);feb(1993,1,OKe,_oe);_.fk=function ape(a){return bE(a)};_.gk=function bpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/33',1993);feb(1994,1,OKe,cpe);_.fk=function dpe(a){return bE(a)};_.gk=function epe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/34',1994);feb(1995,1,OKe,fpe);_.fk=function gpe(a){return bE(a)};_.gk=function hpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/35',1995);feb(1996,1,OKe,ipe);_.fk=function jpe(a){return bE(a)};_.gk=function kpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/36',1996);feb(1997,1,OKe,lpe);_.fk=function mpe(a){return ZD(a,15)};_.gk=function npe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/37',1997);feb(1998,1,OKe,ope);_.fk=function ppe(a){return ZD(a,15)};_.gk=function qpe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/38',1998);feb(1999,1,OKe,rpe);_.fk=function spe(a){return bE(a)};_.gk=function tpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/39',1999);feb(1964,1,OKe,upe);_.fk=function vpe(a){return ZD(a,682)};_.gk=function wpe(a){return $C(Ybb,rve,2120,a,0,1)};sfb(lLe,'XMLTypePackageImpl/4',1964);feb(2000,1,OKe,xpe);_.fk=function ype(a){return bE(a)};_.gk=function zpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/40',2000);feb(2001,1,OKe,Ape);_.fk=function Bpe(a){return bE(a)};_.gk=function Cpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/41',2001);feb(2002,1,OKe,Dpe);_.fk=function Epe(a){return bE(a)};_.gk=function Fpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/42',2002);feb(2003,1,OKe,Gpe);_.fk=function Hpe(a){return bE(a)};_.gk=function Ipe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/43',2003);feb(2004,1,OKe,Jpe);_.fk=function Kpe(a){return bE(a)};_.gk=function Lpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/44',2004);feb(2005,1,OKe,Mpe);_.fk=function Npe(a){return ZD(a,191)};_.gk=function Ope(a){return $C(lJ,Nve,191,a,0,1)};sfb(lLe,'XMLTypePackageImpl/45',2005);feb(2006,1,OKe,Ppe);_.fk=function Qpe(a){return bE(a)};_.gk=function Rpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/46',2006);feb(2007,1,OKe,Spe);_.fk=function Tpe(a){return bE(a)};_.gk=function Upe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/47',2007);feb(2008,1,OKe,Vpe);_.fk=function Wpe(a){return bE(a)};_.gk=function Xpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/48',2008);feb(2009,1,OKe,Ype);_.fk=function Zpe(a){return ZD(a,191)};_.gk=function $pe(a){return $C(lJ,Nve,191,a,0,1)};sfb(lLe,'XMLTypePackageImpl/49',2009);feb(1965,1,OKe,_pe);_.fk=function aqe(a){return ZD(a,683)};_.gk=function bqe(a){return $C(Zbb,rve,2121,a,0,1)};sfb(lLe,'XMLTypePackageImpl/5',1965);feb(2010,1,OKe,cqe);_.fk=function dqe(a){return ZD(a,168)};_.gk=function eqe(a){return $C(eJ,Nve,168,a,0,1)};sfb(lLe,'XMLTypePackageImpl/50',2010);feb(2011,1,OKe,fqe);_.fk=function gqe(a){return bE(a)};_.gk=function hqe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/51',2011);feb(2012,1,OKe,iqe);_.fk=function jqe(a){return ZD(a,17)};_.gk=function kqe(a){return $C(bJ,Nve,17,a,0,1)};sfb(lLe,'XMLTypePackageImpl/52',2012);feb(1966,1,OKe,lqe);_.fk=function mqe(a){return bE(a)};_.gk=function nqe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/6',1966);feb(1967,1,OKe,oqe);_.fk=function pqe(a){return ZD(a,195)};_.gk=function qqe(a){return $C(gE,Nve,195,a,0,2)};sfb(lLe,'XMLTypePackageImpl/7',1967);feb(1968,1,OKe,rqe);_.fk=function sqe(a){return $D(a)};_.gk=function tqe(a){return $C(QI,Nve,485,a,8,1)};sfb(lLe,'XMLTypePackageImpl/8',1968);feb(1969,1,OKe,uqe);_.fk=function vqe(a){return ZD(a,222)};_.gk=function wqe(a){return $C(RI,Nve,222,a,0,1)};sfb(lLe,'XMLTypePackageImpl/9',1969);var xqe,yqe;var Eqe,Fqe;var Jqe;feb(55,63,swe,Lqe);sfb(LLe,'RegEx/ParseException',55);feb(836,1,{},Tqe);_.bm=function Uqe(a){return ac*16)throw Adb(new Lqe(TId((Hde(),tJe))));c=c*16+e;}while(true);if(this.a!=125)throw Adb(new Lqe(TId((Hde(),uJe))));if(c>MLe)throw Adb(new Lqe(TId((Hde(),vJe))));a=c;}else {e=0;if(this.c!=0||(e=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));c=e;Mqe(this);if(this.c!=0||(e=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));c=c*16+e;a=c;}break;case 117:d=0;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;a=b;break;case 118:Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;if(b>MLe)throw Adb(new Lqe(TId((Hde(),'parser.descappe.4'))));a=b;break;case 65:case 90:case 122:throw Adb(new Lqe(TId((Hde(),wJe))));}return a};_.dm=function Wqe(a){var b,c;switch(a){case 100:c=(this.e&32)==32?hte('Nd',true):(Vse(),Bse);break;case 68:c=(this.e&32)==32?hte('Nd',false):(Vse(),Ise);break;case 119:c=(this.e&32)==32?hte('IsWord',true):(Vse(),Rse);break;case 87:c=(this.e&32)==32?hte('IsWord',false):(Vse(),Kse);break;case 115:c=(this.e&32)==32?hte('IsSpace',true):(Vse(),Mse);break;case 83:c=(this.e&32)==32?hte('IsSpace',false):(Vse(),Jse);break;default:throw Adb(new yz((b=a,NLe+b.toString(16))));}return c};_.em=function Yqe(a){var b,c,d,e,f,g,h,i,j,k,l,m;this.b=1;Mqe(this);b=null;if(this.c==0&&this.a==94){Mqe(this);if(a){k=(Vse(),Vse(),new xte(5));}else {b=(Vse(),Vse(),new xte(4));rte(b,0,MLe);k=(new xte(4));}}else {k=(Vse(),Vse(),new xte(4));}e=true;while((m=this.c)!=1){if(m==0&&this.a==93&&!e)break;e=false;c=this.a;d=false;if(m==10){switch(c){case 100:case 68:case 119:case 87:case 115:case 83:ute(k,this.dm(c));d=true;break;case 105:case 73:case 99:case 67:c=this.um(k,c);c<0&&(d=true);break;case 112:case 80:l=Sqe(this,c);if(!l)throw Adb(new Lqe(TId((Hde(),hJe))));ute(k,l);d=true;break;default:c=this.cm();}}else if(m==20){g=phb(this.i,58,this.d);if(g<0)throw Adb(new Lqe(TId((Hde(),iJe))));h=true;if(ihb(this.i,this.d)==94){++this.d;h=false;}f=zhb(this.i,this.d,g);i=ite(f,h,(this.e&512)==512);if(!i)throw Adb(new Lqe(TId((Hde(),kJe))));ute(k,i);d=true;if(g+1>=this.j||ihb(this.i,g+1)!=93)throw Adb(new Lqe(TId((Hde(),iJe))));this.d=g+2;}Mqe(this);if(!d){if(this.c!=0||this.a!=45){rte(k,c,c);}else {Mqe(this);if((m=this.c)==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(m==0&&this.a==93){rte(k,c,c);rte(k,45,45);}else {j=this.a;m==10&&(j=this.cm());Mqe(this);rte(k,c,j);}}}(this.e&gwe)==gwe&&this.c==0&&this.a==44&&Mqe(this);}if(this.c==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(b){wte(b,k);k=b;}vte(k);ste(k);this.b=0;Mqe(this);return k};_.fm=function Zqe(){var a,b,c,d;c=this.em(false);while((d=this.c)!=7){a=this.a;if(d==0&&(a==45||a==38)||d==4){Mqe(this);if(this.c!=9)throw Adb(new Lqe(TId((Hde(),pJe))));b=this.em(false);if(d==4)ute(c,b);else if(a==45)wte(c,b);else if(a==38)tte(c,b);else throw Adb(new yz('ASSERT'))}else {throw Adb(new Lqe(TId((Hde(),qJe))))}}Mqe(this);return c};_.gm=function $qe(){var a,b;a=this.a-48;b=(Vse(),Vse(),new eue(12,null,a));!this.g&&(this.g=new gyb);dyb(this.g,new Bte(a));Mqe(this);return b};_.hm=function _qe(){Mqe(this);return Vse(),Nse};_.im=function are(){Mqe(this);return Vse(),Lse};_.jm=function bre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.km=function cre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.lm=function dre(){Mqe(this);return fte()};_.mm=function ere(){Mqe(this);return Vse(),Pse};_.nm=function fre(){Mqe(this);return Vse(),Sse};_.om=function gre(){var a;if(this.d>=this.j||((a=ihb(this.i,this.d++))&65504)!=64)throw Adb(new Lqe(TId((Hde(),dJe))));Mqe(this);return Vse(),Vse(),new Hte(0,a-64)};_.pm=function hre(){Mqe(this);return gte()};_.qm=function ire(){Mqe(this);return Vse(),Tse};_.rm=function jre(){var a;a=(Vse(),Vse(),new Hte(0,105));Mqe(this);return a};_.sm=function kre(){Mqe(this);return Vse(),Qse};_.tm=function lre(){Mqe(this);return Vse(),Ose};_.um=function mre(a,b){return this.cm()};_.vm=function nre(){Mqe(this);return Vse(),Gse};_.wm=function ore(){var a,b,c,d,e;if(this.d+1>=this.j)throw Adb(new Lqe(TId((Hde(),aJe))));d=-1;b=null;a=ihb(this.i,this.d);if(49<=a&&a<=57){d=a-48;!this.g&&(this.g=new gyb);dyb(this.g,new Bte(d));++this.d;if(ihb(this.i,this.d)!=41)throw Adb(new Lqe(TId((Hde(),ZIe))));++this.d;}else {a==63&&--this.d;Mqe(this);b=Pqe(this);switch(b.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));break;default:throw Adb(new Lqe(TId((Hde(),bJe))));}}Mqe(this);e=Qqe(this);c=null;if(e.e==2){if(e.Pm()!=2)throw Adb(new Lqe(TId((Hde(),cJe))));c=e.Lm(1);e=e.Lm(0);}if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return Vse(),Vse(),new Ute(d,b,e,c)};_.xm=function pre(){Mqe(this);return Vse(),Hse};_.ym=function qre(){var a;Mqe(this);a=_se(24,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.zm=function rre(){var a;Mqe(this);a=_se(20,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Am=function sre(){var a;Mqe(this);a=_se(22,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Bm=function tre(){var a,b,c,d,e;a=0;c=0;b=-1;while(this.d=this.j)throw Adb(new Lqe(TId((Hde(),$Ie))));if(b==45){++this.d;while(this.d=this.j)throw Adb(new Lqe(TId((Hde(),$Ie))))}if(b==58){++this.d;Mqe(this);d=ate(Qqe(this),a,c);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);}else if(b==41){++this.d;Mqe(this);d=ate(Qqe(this),a,c);}else throw Adb(new Lqe(TId((Hde(),_Ie))));return d};_.Cm=function ure(){var a;Mqe(this);a=_se(21,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Dm=function vre(){var a;Mqe(this);a=_se(23,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Em=function wre(){var a,b;Mqe(this);a=this.f++;b=bte(Qqe(this),a);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return b};_.Fm=function xre(){var a;Mqe(this);a=bte(Qqe(this),0);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Gm=function yre(a){Mqe(this);if(this.c==5){Mqe(this);return $se(a,(Vse(),Vse(),new Kte(9,a)))}else return $se(a,(Vse(),Vse(),new Kte(3,a)))};_.Hm=function zre(a){var b;Mqe(this);b=(Vse(),Vse(),new iue(2));if(this.c==5){Mqe(this);hue(b,(Ese));hue(b,a);}else {hue(b,a);hue(b,(Ese));}return b};_.Im=function Are(a){Mqe(this);if(this.c==5){Mqe(this);return Vse(),Vse(),new Kte(9,a)}else return Vse(),Vse(),new Kte(3,a)};_.a=0;_.b=0;_.c=0;_.d=0;_.e=0;_.f=1;_.g=null;_.j=0;sfb(LLe,'RegEx/RegexParser',836);feb(1947,836,{},Gre);_.bm=function Hre(a){return false};_.cm=function Ire(){return Dre(this)};_.dm=function Kre(a){return Ere(a)};_.em=function Lre(a){return Fre(this)};_.fm=function Mre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.gm=function Nre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.hm=function Ore(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.im=function Pre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.jm=function Qre(){Mqe(this);return Ere(67)};_.km=function Rre(){Mqe(this);return Ere(73)};_.lm=function Sre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.mm=function Tre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.nm=function Ure(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.om=function Vre(){Mqe(this);return Ere(99)};_.pm=function Wre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.qm=function Xre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.rm=function Yre(){Mqe(this);return Ere(105)};_.sm=function Zre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.tm=function $re(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.um=function _re(a,b){return ute(a,Ere(b)),-1};_.vm=function ase(){Mqe(this);return Vse(),Vse(),new Hte(0,94)};_.wm=function bse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.xm=function cse(){Mqe(this);return Vse(),Vse(),new Hte(0,36)};_.ym=function dse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.zm=function ese(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Am=function fse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Bm=function gse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Cm=function hse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Dm=function ise(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Em=function jse(){var a;Mqe(this);a=bte(Qqe(this),0);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Fm=function kse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Gm=function lse(a){Mqe(this);return $se(a,(Vse(),Vse(),new Kte(3,a)))};_.Hm=function mse(a){var b;Mqe(this);b=(Vse(),Vse(),new iue(2));hue(b,a);hue(b,(Ese));return b};_.Im=function nse(a){Mqe(this);return Vse(),Vse(),new Kte(3,a)};var Bre=null,Cre=null;sfb(LLe,'RegEx/ParserForXMLSchema',1947);feb(122,1,ZLe,Wse);_.Jm=function Xse(a){throw Adb(new yz('Not supported.'))};_.Km=function dte(){return -1};_.Lm=function ete(a){return null};_.Mm=function jte(){return null};_.Nm=function mte(a){};_.Om=function nte(a){};_.Pm=function ote(){return 0};_.Ib=function pte(){return this.Qm(0)};_.Qm=function qte(a){return this.e==11?'.':''};_.e=0;var vse,wse,xse,yse,zse,Ase=null,Bse,Cse=null,Dse,Ese,Fse=null,Gse,Hse,Ise,Jse,Kse,Lse,Mse,Nse,Ose,Pse,Qse,Rse,Sse,Tse;var qdb=sfb(LLe,'RegEx/Token',122);feb(138,122,{3:1,138:1,122:1},xte);_.Qm=function Ate(a){var b,c,d;if(this.e==4){if(this==Dse)c='.';else if(this==Bse)c='\\d';else if(this==Rse)c='\\w';else if(this==Mse)c='\\s';else {d=new Qhb;d.a+='[';for(b=0;b0&&(d.a+=',',d);if(this.b[b]===this.b[b+1]){Nhb(d,zte(this.b[b]));}else {Nhb(d,zte(this.b[b]));d.a+='-';Nhb(d,zte(this.b[b+1]));}}d.a+=']';c=d.a;}}else {if(this==Ise)c='\\D';else if(this==Kse)c='\\W';else if(this==Jse)c='\\S';else {d=new Qhb;d.a+='[^';for(b=0;b0&&(d.a+=',',d);if(this.b[b]===this.b[b+1]){Nhb(d,zte(this.b[b]));}else {Nhb(d,zte(this.b[b]));d.a+='-';Nhb(d,zte(this.b[b+1]));}}d.a+=']';c=d.a;}}return c};_.a=false;_.c=false;sfb(LLe,'RegEx/RangeToken',138);feb(592,1,{592:1},Bte);_.a=0;sfb(LLe,'RegEx/RegexParser/ReferencePosition',592);feb(591,1,{3:1,591:1},Dte);_.Fb=function Ete(a){var b;if(a==null)return false;if(!ZD(a,591))return false;b=RD(a,591);return lhb(this.b,b.b)&&this.a==b.a};_.Hb=function Fte(){return ohb(this.b+'/'+pse(this.a))};_.Ib=function Gte(){return this.c.Qm(this.a)};_.a=0;sfb(LLe,'RegEx/RegularExpression',591);feb(228,122,ZLe,Hte);_.Km=function Ite(){return this.a};_.Qm=function Jte(a){var b,c,d;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:d='\\'+XD(this.a&Bwe);break;case 12:d='\\f';break;case 10:d='\\n';break;case 13:d='\\r';break;case 9:d='\\t';break;case 27:d='\\e';break;default:if(this.a>=txe){c=(b=this.a>>>0,'0'+b.toString(16));d='\\v'+zhb(c,c.length-6,c.length);}else d=''+XD(this.a&Bwe);}break;case 8:this==Gse||this==Hse?(d=''+XD(this.a&Bwe)):(d='\\'+XD(this.a&Bwe));break;default:d=null;}return d};_.a=0;sfb(LLe,'RegEx/Token/CharToken',228);feb(318,122,ZLe,Kte);_.Lm=function Lte(a){return this.a};_.Nm=function Mte(a){this.b=a;};_.Om=function Nte(a){this.c=a;};_.Pm=function Ote(){return 1};_.Qm=function Pte(a){var b;if(this.e==3){if(this.c<0&&this.b<0){b=this.a.Qm(a)+'*';}else if(this.c==this.b){b=this.a.Qm(a)+'{'+this.c+'}';}else if(this.c>=0&&this.b>=0){b=this.a.Qm(a)+'{'+this.c+','+this.b+'}';}else if(this.c>=0&&this.b<0){b=this.a.Qm(a)+'{'+this.c+',}';}else throw Adb(new yz('Token#toString(): CLOSURE '+this.c+pve+this.b))}else {if(this.c<0&&this.b<0){b=this.a.Qm(a)+'*?';}else if(this.c==this.b){b=this.a.Qm(a)+'{'+this.c+'}?';}else if(this.c>=0&&this.b>=0){b=this.a.Qm(a)+'{'+this.c+','+this.b+'}?';}else if(this.c>=0&&this.b<0){b=this.a.Qm(a)+'{'+this.c+',}?';}else throw Adb(new yz('Token#toString(): NONGREEDYCLOSURE '+this.c+pve+this.b))}return b};_.b=0;_.c=0;sfb(LLe,'RegEx/Token/ClosureToken',318);feb(837,122,ZLe,Qte);_.Lm=function Rte(a){return a==0?this.a:this.b};_.Pm=function Ste(){return 2};_.Qm=function Tte(a){var b;this.b.e==3&&this.b.Lm(0)==this.a?(b=this.a.Qm(a)+'+'):this.b.e==9&&this.b.Lm(0)==this.a?(b=this.a.Qm(a)+'+?'):(b=this.a.Qm(a)+(''+this.b.Qm(a)));return b};sfb(LLe,'RegEx/Token/ConcatToken',837);feb(1945,122,ZLe,Ute);_.Lm=function Vte(a){if(a==0)return this.d;if(a==1)return this.b;throw Adb(new yz('Internal Error: '+a))};_.Pm=function Wte(){return !this.b?1:2};_.Qm=function Xte(a){var b;this.c>0?(b='(?('+this.c+')'):this.a.e==8?(b='(?('+this.a+')'):(b='(?'+this.a);!this.b?(b+=this.d+')'):(b+=this.d+'|'+this.b+')');return b};_.c=0;sfb(LLe,'RegEx/Token/ConditionToken',1945);feb(1946,122,ZLe,Yte);_.Lm=function Zte(a){return this.b};_.Pm=function $te(){return 1};_.Qm=function _te(a){return '(?'+(this.a==0?'':pse(this.a))+(this.c==0?'':pse(this.c))+':'+this.b.Qm(a)+')'};_.a=0;_.c=0;sfb(LLe,'RegEx/Token/ModifierToken',1946);feb(838,122,ZLe,aue);_.Lm=function bue(a){return this.a};_.Pm=function cue(){return 1};_.Qm=function due(a){var b;b=null;switch(this.e){case 6:this.b==0?(b='(?:'+this.a.Qm(a)+')'):(b='('+this.a.Qm(a)+')');break;case 20:b='(?='+this.a.Qm(a)+')';break;case 21:b='(?!'+this.a.Qm(a)+')';break;case 22:b='(?<='+this.a.Qm(a)+')';break;case 23:b='(?'+this.a.Qm(a)+')';}return b};_.b=0;sfb(LLe,'RegEx/Token/ParenToken',838);feb(530,122,{3:1,122:1,530:1},eue);_.Mm=function fue(){return this.b};_.Qm=function gue(a){return this.e==12?'\\'+this.a:tse(this.b)};_.a=0;sfb(LLe,'RegEx/Token/StringToken',530);feb(477,122,ZLe,iue);_.Jm=function jue(a){hue(this,a);};_.Lm=function kue(a){return RD(eyb(this.a,a),122)};_.Pm=function lue(){return !this.a?0:this.a.a.c.length};_.Qm=function mue(a){var b,c,d,e,f;if(this.e==1){if(this.a.a.c.length==2){b=RD(eyb(this.a,0),122);c=RD(eyb(this.a,1),122);c.e==3&&c.Lm(0)==b?(e=b.Qm(a)+'+'):c.e==9&&c.Lm(0)==b?(e=b.Qm(a)+'+?'):(e=b.Qm(a)+(''+c.Qm(a)));}else {f=new Qhb;for(d=0;d=this.c.b:this.a<=this.c.b};_.Sb=function Vue(){return this.b>0};_.Tb=function Xue(){return this.b};_.Vb=function Zue(){return this.b-1};_.Qb=function $ue(){throw Adb(new kib(dMe))};_.a=0;_.b=0;sfb(aMe,'ExclusiveRange/RangeIterator',258);var hE=vfb(eKe,'C');var kE=vfb(hKe,'I');var xdb=vfb(hve,'Z');var lE=vfb(iKe,'J');var gE=vfb(dKe,'B');var iE=vfb(fKe,'D');var jE=vfb(gKe,'F');var wdb=vfb(jKe,'S');var g3=ufb('org.eclipse.elk.core.labels','ILabelManager');var T6=ufb(sIe,'DiagnosticChain');var zab=ufb(QKe,'ResourceSet');var $6=sfb(sIe,'InvocationTargetException',null);var fve=(Qz(),Tz);var gwtOnLoad=gwtOnLoad=ceb;aeb(leb);deb('permProps',[[['locale','default'],[eMe,'gecko1_8']],[['locale','default'],[eMe,'safari']]]); + // -------------- RUN GWT INITIALIZATION CODE -------------- + gwtOnLoad(null, 'elk', null); + + }).call(this);}).call(this,typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}); + },{}],3:[function(require,module,exports){ + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + /******************************************************************************* + * Copyright (c) 2021 Kiel University and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + var ELK = require('./elk-api.js').default; + + var ELKNode = function (_ELK) { + _inherits(ELKNode, _ELK); + + function ELKNode() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, ELKNode); + + var optionsClone = Object.assign({}, options); + + var workerThreadsExist = false; + try { + require.resolve('web-worker'); + workerThreadsExist = true; + } catch (e) {} + + // user requested a worker + if (options.workerUrl) { + if (workerThreadsExist) { + var Worker = require('web-worker'); + optionsClone.workerFactory = function (url) { + return new Worker(url); + }; + } else { + console.warn('Web worker requested but \'web-worker\' package not installed. \nConsider installing the package or pass your own \'workerFactory\' to ELK\'s constructor.\n... Falling back to non-web worker version.'); + } + } + + // unless no other workerFactory is registered, use the fake worker + if (!optionsClone.workerFactory) { + var _require = require('./elk-worker.min.js'), + _Worker = _require.Worker; + + optionsClone.workerFactory = function (url) { + return new _Worker(url); + }; + } + + return _possibleConstructorReturn(this, (ELKNode.__proto__ || Object.getPrototypeOf(ELKNode)).call(this, optionsClone)); + } + + return ELKNode; + }(ELK); + + Object.defineProperty(module.exports, "__esModule", { + value: true + }); + module.exports = ELKNode; + ELKNode.default = ELKNode; + },{"./elk-api.js":1,"./elk-worker.min.js":2,"web-worker":4}],4:[function(require,module,exports){ + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + module.exports = Worker; + },{}]},{},[3])(3) + }); +} (elk_bundled)); + +var elk_bundledExports = elk_bundled.exports; +var ELK = /*@__PURE__*/getDefaultExportFromCjs(elk_bundledExports); + +const findCommonAncestor = (id1, id2, treeData) => { + const { parentById } = treeData; + const visited = /* @__PURE__ */ new Set(); + let currentId = id1; + while (currentId) { + visited.add(currentId); + if (currentId === id2) { + return currentId; + } + currentId = parentById[currentId]; + } + currentId = id2; + while (currentId) { + if (visited.has(currentId)) { + return currentId; + } + currentId = parentById[currentId]; + } + return "root"; +}; +const elk = new ELK(); +let portPos = {}; +const conf = {}; +let nodeDb = {}; +const addVertices = async function(vert, svgId, root, doc, diagObj, parentLookupDb, graph) { + const svg = root.select(`[id="${svgId}"]`); + const nodes = svg.insert("g").attr("class", "nodes"); + const keys = Object.keys(vert); + await Promise.all( + keys.map(async function(id) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + classStr = classStr + " flowchart-label"; + const styles2 = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + const labelData = { width: 0, height: 0 }; + const ports = [ + { + id: vertex.id + "-west", + layoutOptions: { + "port.side": "WEST" + } + }, + { + id: vertex.id + "-east", + layoutOptions: { + "port.side": "EAST" + } + }, + { + id: vertex.id + "-south", + layoutOptions: { + "port.side": "SOUTH" + } + }, + { + id: vertex.id + "-north", + layoutOptions: { + "port.side": "NORTH" + } + } + ]; + let radius = 0; + let _shape = ""; + let layoutOptions = {}; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + layoutOptions = { + portConstraints: "FIXED_SIDE" + }; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + case "doublecircle": + _shape = "doublecircle"; + break; + default: + _shape = "rect"; + } + const node = { + labelStyle: styles2.labelStyle, + shape: _shape, + labelText: vertexText, + labelType: vertex.labelType, + rx: radius, + ry: radius, + class: classStr, + style: styles2.style, + id: vertex.id, + link: vertex.link, + linkTarget: vertex.linkTarget, + tooltip: diagObj.db.getTooltip(vertex.id) || "", + domId: diagObj.db.lookUpDomId(vertex.id), + haveCallback: vertex.haveCallback, + width: vertex.type === "group" ? 500 : void 0, + dir: vertex.dir, + type: vertex.type, + props: vertex.props, + padding: getConfig$1().flowchart.padding + }; + let boundingBox; + let nodeEl; + if (node.type !== "group") { + nodeEl = await insertNode(nodes, node, vertex.dir); + boundingBox = nodeEl.node().getBBox(); + } else { + doc.createElementNS("http://www.w3.org/2000/svg", "text"); + const { shapeSvg, bbox } = await labelHelper(nodes, node, void 0, true); + labelData.width = bbox.width; + labelData.wrappingWidth = getConfig$1().flowchart.wrappingWidth; + labelData.height = bbox.height; + labelData.labelNode = shapeSvg.node(); + node.labelData = labelData; + } + const data = { + id: vertex.id, + ports: vertex.type === "diamond" ? ports : [], + // labelStyle: styles.labelStyle, + // shape: _shape, + layoutOptions, + labelText: vertexText, + labelData, + // labels: [{ text: vertexText }], + // rx: radius, + // ry: radius, + // class: classStr, + // style: styles.style, + // link: vertex.link, + // linkTarget: vertex.linkTarget, + // tooltip: diagObj.db.getTooltip(vertex.id) || '', + domId: diagObj.db.lookUpDomId(vertex.id), + // haveCallback: vertex.haveCallback, + width: boundingBox == null ? void 0 : boundingBox.width, + height: boundingBox == null ? void 0 : boundingBox.height, + // dir: vertex.dir, + type: vertex.type, + // props: vertex.props, + // padding: getConfig().flowchart.padding, + // boundingBox, + el: nodeEl, + parent: parentLookupDb.parentById[vertex.id] + }; + nodeDb[node.id] = data; + }) + ); + return graph; +}; +const getNextPosition = (position, edgeDirection, graphDirection) => { + const portPos2 = { + TB: { + in: { + north: "north" + }, + out: { + south: "west", + west: "east", + east: "south" + } + }, + LR: { + in: { + west: "west" + }, + out: { + east: "south", + south: "north", + north: "east" + } + }, + RL: { + in: { + east: "east" + }, + out: { + west: "north", + north: "south", + south: "west" + } + }, + BT: { + in: { + south: "south" + }, + out: { + north: "east", + east: "west", + west: "north" + } + } + }; + portPos2.TD = portPos2.TB; + return portPos2[graphDirection][edgeDirection][position]; +}; +const getNextPort = (node, edgeDirection, graphDirection) => { + log$1.info("getNextPort", { node, edgeDirection, graphDirection }); + if (!portPos[node]) { + switch (graphDirection) { + case "TB": + case "TD": + portPos[node] = { + inPosition: "north", + outPosition: "south" + }; + break; + case "BT": + portPos[node] = { + inPosition: "south", + outPosition: "north" + }; + break; + case "RL": + portPos[node] = { + inPosition: "east", + outPosition: "west" + }; + break; + case "LR": + portPos[node] = { + inPosition: "west", + outPosition: "east" + }; + break; + } + } + const result = edgeDirection === "in" ? portPos[node].inPosition : portPos[node].outPosition; + if (edgeDirection === "in") { + portPos[node].inPosition = getNextPosition( + portPos[node].inPosition, + edgeDirection, + graphDirection + ); + } else { + portPos[node].outPosition = getNextPosition( + portPos[node].outPosition, + edgeDirection, + graphDirection + ); + } + return result; +}; +const getEdgeStartEndPoint = (edge, dir) => { + let source = edge.start; + let target = edge.end; + const sourceId = source; + const targetId = target; + const startNode = nodeDb[source]; + const endNode = nodeDb[target]; + if (!startNode || !endNode) { + return { source, target }; + } + if (startNode.type === "diamond") { + source = `${source}-${getNextPort(source, "out", dir)}`; + } + if (endNode.type === "diamond") { + target = `${target}-${getNextPort(target, "in", dir)}`; + } + return { source, target, sourceId, targetId }; +}; +const addEdges = function(edges, diagObj, graph, svg) { + log$1.info("abc78 edges = ", edges); + const labelsEl = svg.insert("g").attr("class", "edgeLabels"); + let linkIdCnt = {}; + let dir = diagObj.db.getDirection(); + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + edges.forEach(function(edge) { + const linkIdBase = "L-" + edge.start + "-" + edge.end; + if (linkIdCnt[linkIdBase] === void 0) { + linkIdCnt[linkIdBase] = 0; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } else { + linkIdCnt[linkIdBase]++; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } + let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase]; + log$1.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]); + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = { style: "", labelStyle: "" }; + edgeData.minlen = edge.length || 1; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + edgeData.arrowTypeStart = "arrow_open"; + edgeData.arrowTypeEnd = "arrow_open"; + switch (edge.type) { + case "double_arrow_cross": + edgeData.arrowTypeStart = "arrow_cross"; + case "arrow_cross": + edgeData.arrowTypeEnd = "arrow_cross"; + break; + case "double_arrow_point": + edgeData.arrowTypeStart = "arrow_point"; + case "arrow_point": + edgeData.arrowTypeEnd = "arrow_point"; + break; + case "double_arrow_circle": + edgeData.arrowTypeStart = "arrow_circle"; + case "arrow_circle": + edgeData.arrowTypeEnd = "arrow_circle"; + break; + } + let style = ""; + let labelStyle = ""; + switch (edge.stroke) { + case "normal": + style = "fill:none;"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + edgeData.thickness = "normal"; + edgeData.pattern = "solid"; + break; + case "dotted": + edgeData.thickness = "normal"; + edgeData.pattern = "dotted"; + edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + edgeData.thickness = "thick"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 3.5px;fill:none;"; + break; + } + if (edge.style !== void 0) { + const styles2 = getStylesFromArray(edge.style); + style = styles2.style; + labelStyle = styles2.labelStyle; + } + edgeData.style = edgeData.style += style; + edgeData.labelStyle = edgeData.labelStyle += labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + } + edgeData.labelType = edge.labelType; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + edgeData.id = linkId; + edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd; + const labelEl = insertEdgeLabel(labelsEl, edgeData); + const { source, target, sourceId, targetId } = getEdgeStartEndPoint(edge, dir); + log$1.debug("abc78 source and target", source, target); + graph.edges.push({ + id: "e" + edge.start + edge.end, + sources: [source], + targets: [target], + sourceId, + targetId, + labelEl, + labels: [ + { + width: edgeData.width, + height: edgeData.height, + orgWidth: edgeData.width, + orgHeight: edgeData.height, + text: edgeData.label, + layoutOptions: { + "edgeLabels.inline": "true", + "edgeLabels.placement": "CENTER" + } + } + ], + edgeData + }); + }); + return graph; +}; +const addMarkersToEdge = function(svgPath, edgeData, diagramType, arrowMarkerAbsolute, id) { + let url = ""; + if (arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + addEdgeMarkers(svgPath, edgeData, url, id, diagramType); +}; +const getClasses = function(text, diagObj) { + log$1.info("Extracting classes"); + return diagObj.db.getClasses(); +}; +const addSubGraphs = function(db2) { + const parentLookupDb = { parentById: {}, childrenById: {} }; + const subgraphs = db2.getSubGraphs(); + log$1.info("Subgraphs - ", subgraphs); + subgraphs.forEach(function(subgraph) { + subgraph.nodes.forEach(function(node) { + parentLookupDb.parentById[node] = subgraph.id; + if (parentLookupDb.childrenById[subgraph.id] === void 0) { + parentLookupDb.childrenById[subgraph.id] = []; + } + parentLookupDb.childrenById[subgraph.id].push(node); + }); + }); + subgraphs.forEach(function(subgraph) { + ({ id: subgraph.id }); + if (parentLookupDb.parentById[subgraph.id] !== void 0) { + parentLookupDb.parentById[subgraph.id]; + } + }); + return parentLookupDb; +}; +const calcOffset = function(src, dest, parentLookupDb) { + const ancestor = findCommonAncestor(src, dest, parentLookupDb); + if (ancestor === void 0 || ancestor === "root") { + return { x: 0, y: 0 }; + } + const ancestorOffset = nodeDb[ancestor].offset; + return { x: ancestorOffset.posX, y: ancestorOffset.posY }; +}; +const insertEdge = function(edgesEl, edge, edgeData, diagObj, parentLookupDb, id) { + const offset = calcOffset(edge.sourceId, edge.targetId, parentLookupDb); + const src = edge.sections[0].startPoint; + const dest = edge.sections[0].endPoint; + const segments = edge.sections[0].bendPoints ? edge.sections[0].bendPoints : []; + const segPoints = segments.map((segment) => [segment.x + offset.x, segment.y + offset.y]); + const points = [ + [src.x + offset.x, src.y + offset.y], + ...segPoints, + [dest.x + offset.x, dest.y + offset.y] + ]; + const { x, y } = getLineFunctionsWithOffset(edge.edgeData); + const curve = line().x(x).y(y).curve(curveLinear); + const edgePath = edgesEl.insert("path").attr("d", curve(points)).attr("class", "path " + edgeData.classes).attr("fill", "none"); + const edgeG = edgesEl.insert("g").attr("class", "edgeLabel"); + const edgeWithLabel = select(edgeG.node().appendChild(edge.labelEl)); + const box = edgeWithLabel.node().firstChild.getBoundingClientRect(); + edgeWithLabel.attr("width", box.width); + edgeWithLabel.attr("height", box.height); + edgeG.attr( + "transform", + `translate(${edge.labels[0].x + offset.x}, ${edge.labels[0].y + offset.y})` + ); + addMarkersToEdge(edgePath, edgeData, diagObj.type, diagObj.arrowMarkerAbsolute, id); +}; +const insertChildren = (nodeArray, parentLookupDb) => { + nodeArray.forEach((node) => { + if (!node.children) { + node.children = []; + } + const childIds = parentLookupDb.childrenById[node.id]; + if (childIds) { + childIds.forEach((childId) => { + node.children.push(nodeDb[childId]); + }); + } + insertChildren(node.children, parentLookupDb); + }); +}; +const draw = async function(text, id, _version, diagObj) { + var _a; + diagObj.db.clear(); + nodeDb = {}; + portPos = {}; + diagObj.db.setGen("gen-2"); + diagObj.parser.parse(text); + const renderEl = select("body").append("div").attr("style", "height:400px").attr("id", "cy"); + let graph = { + id: "root", + layoutOptions: { + "elk.hierarchyHandling": "INCLUDE_CHILDREN", + "org.eclipse.elk.padding": "[top=100, left=100, bottom=110, right=110]", + "elk.layered.spacing.edgeNodeBetweenLayers": "30", + // 'elk.layered.mergeEdges': 'true', + "elk.direction": "DOWN" + // 'elk.ports.sameLayerEdges': true, + // 'nodePlacement.strategy': 'SIMPLE', + }, + children: [], + edges: [] + }; + log$1.info("Drawing flowchart using v3 renderer", elk); + let dir = diagObj.db.getDirection(); + switch (dir) { + case "BT": + graph.layoutOptions["elk.direction"] = "UP"; + break; + case "TB": + graph.layoutOptions["elk.direction"] = "DOWN"; + break; + case "LR": + graph.layoutOptions["elk.direction"] = "RIGHT"; + break; + case "RL": + graph.layoutOptions["elk.direction"] = "LEFT"; + break; + } + const { securityLevel, flowchart: conf2 } = getConfig$1(); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const svg = root.select(`[id="${id}"]`); + const markers = ["point", "circle", "cross"]; + insertMarkers$1(svg, markers, diagObj.type, id); + const vert = diagObj.db.getVertices(); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + log$1.info("Subgraphs - ", subGraphs); + for (let i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + diagObj.db.addVertex( + subG.id, + { text: subG.title, type: subG.labelType }, + "group", + void 0, + subG.classes, + subG.dir + ); + } + const subGraphsEl = svg.insert("g").attr("class", "subgraphs"); + const parentLookupDb = addSubGraphs(diagObj.db); + graph = await addVertices(vert, id, root, doc, diagObj, parentLookupDb, graph); + const edgesEl = svg.insert("g").attr("class", "edges edgePath"); + const edges = diagObj.db.getEdges(); + graph = addEdges(edges, diagObj, graph, svg); + const nodes = Object.keys(nodeDb); + nodes.forEach((nodeId) => { + const node = nodeDb[nodeId]; + if (!node.parent) { + graph.children.push(node); + } + if (parentLookupDb.childrenById[nodeId] !== void 0) { + node.labels = [ + { + text: node.labelText, + layoutOptions: { + "nodeLabels.placement": "[H_CENTER, V_TOP, INSIDE]" + }, + width: node.labelData.width, + height: node.labelData.height + // width: 100, + // height: 100, + } + ]; + delete node.x; + delete node.y; + delete node.width; + delete node.height; + } + }); + insertChildren(graph.children, parentLookupDb); + log$1.info("after layout", JSON.stringify(graph, null, 2)); + const g = await elk.layout(graph); + drawNodes(0, 0, g.children, svg, subGraphsEl, diagObj, 0); + log$1.info("after layout", g); + (_a = g.edges) == null ? void 0 : _a.map((edge) => { + insertEdge(edgesEl, edge, edge.edgeData, diagObj, parentLookupDb, id); + }); + setupGraphViewbox$1({}, svg, conf2.diagramPadding, conf2.useMaxWidth); + renderEl.remove(); +}; +const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, diagObj, depth) => { + nodeArray.forEach(function(node) { + if (node) { + nodeDb[node.id].offset = { + posX: node.x + relX, + posY: node.y + relY, + x: relX, + y: relY, + depth, + width: node.width, + height: node.height + }; + if (node.type === "group") { + const subgraphEl = subgraphsEl.insert("g").attr("class", "subgraph"); + subgraphEl.insert("rect").attr("class", "subgraph subgraph-lvl-" + depth % 5 + " node").attr("x", node.x + relX).attr("y", node.y + relY).attr("width", node.width).attr("height", node.height); + const label = subgraphEl.insert("g").attr("class", "label"); + const labelCentering = getConfig$1().flowchart.htmlLabels ? node.labelData.width / 2 : 0; + label.attr( + "transform", + `translate(${node.labels[0].x + relX + node.x + labelCentering}, ${node.labels[0].y + relY + node.y + 3})` + ); + label.node().appendChild(node.labelData.labelNode); + log$1.info("Id (UGH)= ", node.type, node.labels); + } else { + log$1.info("Id (UGH)= ", node.id); + node.el.attr( + "transform", + `translate(${node.x + relX + node.width / 2}, ${node.y + relY + node.height / 2})` + ); + } + } + }); + nodeArray.forEach(function(node) { + if (node && node.type === "group") { + drawNodes(relX + node.x, relY + node.y, node.children, svg, subgraphsEl, diagObj, depth + 1); + } + }); +}; +const renderer = { + getClasses, + draw +}; +const genSections = (options) => { + let sections = ""; + for (let i = 0; i < 5; i++) { + sections += ` + .subgraph-lvl-${i} { + fill: ${options[`surface${i}`]}; + stroke: ${options[`surfacePeer${i}`]}; + } + `; + } + return sections; +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span { + color: ${options.titleColor}; + } + + .label text,span { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.85; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + .cluster rect { + fill: ${options.clusterBkg}; + stroke: ${options.clusterBorder}; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } + .subgraph { + stroke-width:2; + rx:3; + } + // .subgraph-lvl-1 { + // fill:#ccc; + // // stroke:black; + // } + + .flowchart-label text { + text-anchor: middle; + } + + ${genSections(options)} +`; +const styles = getStyles; +const diagram = { + db, + renderer, + parser: parser$1, + styles +}; + +export { diagram }; diff --git a/libs/marked/flowchart-elk-definition-ae0efee6-CWJ9Snv4.js b/libs/marked/flowchart-elk-definition-ae0efee6-CWJ9Snv4.js new file mode 100644 index 0000000..cf93d7d --- /dev/null +++ b/libs/marked/flowchart-elk-definition-ae0efee6-CWJ9Snv4.js @@ -0,0 +1,7505 @@ +import { d as db, p as parser$1 } from './flowDb-c1833063-Df5kDQr4.js'; +import { P as commonjsGlobal, Q as getDefaultExportFromCjs, l as log$1, h as select, _ as getConfig$1, t as setupGraphViewbox$1, o as getStylesFromArray, q as interpolateToCurve, n as curveLinear, j as common$1 } from './index-Bd_FDXSq.js'; +import { i as insertMarkers$1, a as insertNode, l as labelHelper, b as insertEdgeLabel, k as getLineFunctionsWithOffset, m as addEdgeMarkers } from './edges-066a5561-Bqw9g7uz.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './createText-ca0c5216-B9KlDTE8.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var elk_bundled = {exports: {}}; + +(function (module, exports) { + (function(f){{module.exports=f();}})(function(){return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof commonjsRequire&&commonjsRequire;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t);}return n[i].exports}for(var u="function"==typeof commonjsRequire&&commonjsRequire,i=0;i 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$defaultLayoutOpt = _ref.defaultLayoutOptions, + defaultLayoutOptions = _ref$defaultLayoutOpt === undefined ? {} : _ref$defaultLayoutOpt, + _ref$algorithms = _ref.algorithms, + algorithms = _ref$algorithms === undefined ? ['layered', 'stress', 'mrtree', 'radial', 'force', 'disco', 'sporeOverlap', 'sporeCompaction', 'rectpacking'] : _ref$algorithms, + workerFactory = _ref.workerFactory, + workerUrl = _ref.workerUrl; + + _classCallCheck(this, ELK); + + this.defaultLayoutOptions = defaultLayoutOptions; + this.initialized = false; + + // check valid worker construction possible + if (typeof workerUrl === 'undefined' && typeof workerFactory === 'undefined') { + throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'."); + } + var factory = workerFactory; + if (typeof workerUrl !== 'undefined' && typeof workerFactory === 'undefined') { + // use default Web Worker + factory = function factory(url) { + return new Worker(url); + }; + } + + // create the worker + var worker = factory(workerUrl); + if (typeof worker.postMessage !== 'function') { + throw new TypeError("Created worker does not provide" + " the required 'postMessage' function."); + } + + // wrap the worker to return promises + this.worker = new PromisedWorker(worker); + + // initially register algorithms + this.worker.postMessage({ + cmd: 'register', + algorithms: algorithms + }).then(function (r) { + return _this.initialized = true; + }).catch(console.err); + } + + _createClass(ELK, [{ + key: 'layout', + value: function layout(graph) { + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$layoutOptions = _ref2.layoutOptions, + layoutOptions = _ref2$layoutOptions === undefined ? this.defaultLayoutOptions : _ref2$layoutOptions, + _ref2$logging = _ref2.logging, + logging = _ref2$logging === undefined ? false : _ref2$logging, + _ref2$measureExecutio = _ref2.measureExecutionTime, + measureExecutionTime = _ref2$measureExecutio === undefined ? false : _ref2$measureExecutio; + + if (!graph) { + return Promise.reject(new Error("Missing mandatory parameter 'graph'.")); + } + return this.worker.postMessage({ + cmd: 'layout', + graph: graph, + layoutOptions: layoutOptions, + options: { + logging: logging, + measureExecutionTime: measureExecutionTime + } + }); + } + }, { + key: 'knownLayoutAlgorithms', + value: function knownLayoutAlgorithms() { + return this.worker.postMessage({ cmd: 'algorithms' }); + } + }, { + key: 'knownLayoutOptions', + value: function knownLayoutOptions() { + return this.worker.postMessage({ cmd: 'options' }); + } + }, { + key: 'knownLayoutCategories', + value: function knownLayoutCategories() { + return this.worker.postMessage({ cmd: 'categories' }); + } + }, { + key: 'terminateWorker', + value: function terminateWorker() { + if (this.worker) this.worker.terminate(); + } + }]); + + return ELK; + }(); + + exports.default = ELK; + + var PromisedWorker = function () { + function PromisedWorker(worker) { + var _this2 = this; + + _classCallCheck(this, PromisedWorker); + + if (worker === undefined) { + throw new Error("Missing mandatory parameter 'worker'."); + } + this.resolvers = {}; + this.worker = worker; + this.worker.onmessage = function (answer) { + // why is this necessary? + setTimeout(function () { + _this2.receive(_this2, answer); + }, 0); + }; + } + + _createClass(PromisedWorker, [{ + key: 'postMessage', + value: function postMessage(msg) { + var id = this.id || 0; + this.id = id + 1; + msg.id = id; + var self = this; + return new Promise(function (resolve, reject) { + // prepare the resolver + self.resolvers[id] = function (err, res) { + if (err) { + self.convertGwtStyleError(err); + reject(err); + } else { + resolve(res); + } + }; + // post the message + self.worker.postMessage(msg); + }); + } + }, { + key: 'receive', + value: function receive(self, answer) { + var json = answer.data; + var resolver = self.resolvers[json.id]; + if (resolver) { + delete self.resolvers[json.id]; + if (json.error) { + resolver(json.error); + } else { + resolver(null, json.data); + } + } + } + }, { + key: 'terminate', + value: function terminate() { + if (this.worker) { + this.worker.terminate(); + } + } + }, { + key: 'convertGwtStyleError', + value: function convertGwtStyleError(err) { + if (!err) { + return; + } + // Somewhat flatten the way GWT stores nested exception(s) + var javaException = err['__java$exception']; + if (javaException) { + // Note that the property name of the nested exception is different + // in the non-minified ('cause') and the minified (not deterministic) version. + // Hence, the version below only works for the non-minified version. + // However, as the minified stack trace is not of much use anyway, one + // should switch the used version for debugging in such a case. + if (javaException.cause && javaException.cause.backingJsObject) { + err.cause = javaException.cause.backingJsObject; + this.convertGwtStyleError(err.cause); + } + delete err['__java$exception']; + } + } + }]); + + return PromisedWorker; + }(); + },{}],2:[function(require,module,exports){ + (function (global){(function (){ + + // -------------- FAKE ELEMENTS GWT ASSUMES EXIST -------------- + var $wnd; + if (typeof window !== 'undefined') + $wnd = window; + else if (typeof global !== 'undefined') + $wnd = global; // nodejs + else if (typeof self !== 'undefined') + $wnd = self; // web worker + + // -------------- WORKAROUND STRICT MODE, SEE #127 -------------- + var o; + + // -------------- GENERATED CODE -------------- + function nb(){} + function xb(){} + function Fd(){} + function hh(){} + function lq(){} + function Nq(){} + function ir(){} + function Ws(){} + function Zw(){} + function jx(){} + function rx(){} + function sx(){} + function My(){} + function bA(){} + function mA(){} + function tA(){} + function aB(){} + function dB(){} + function jB(){} + function dC(){} + function keb(){} + function geb(){} + function oeb(){} + function iob(){} + function Job(){} + function Rob(){} + function apb(){} + function ipb(){} + function nrb(){} + function wrb(){} + function Brb(){} + function Prb(){} + function ltb(){} + function svb(){} + function xvb(){} + function zvb(){} + function $xb(){} + function Gzb(){} + function NAb(){} + function VAb(){} + function rBb(){} + function RBb(){} + function TBb(){} + function XBb(){} + function ZBb(){} + function _Bb(){} + function bCb(){} + function dCb(){} + function fCb(){} + function jCb(){} + function rCb(){} + function uCb(){} + function wCb(){} + function yCb(){} + function ACb(){} + function ECb(){} + function FEb(){} + function IEb(){} + function KEb(){} + function MEb(){} + function gFb(){} + function FFb(){} + function JFb(){} + function xGb(){} + function AGb(){} + function YGb(){} + function oHb(){} + function tHb(){} + function xHb(){} + function pIb(){} + function BJb(){} + function kLb(){} + function mLb(){} + function oLb(){} + function qLb(){} + function FLb(){} + function JLb(){} + function KMb(){} + function MMb(){} + function OMb(){} + function YMb(){} + function MNb(){} + function ONb(){} + function aOb(){} + function eOb(){} + function xOb(){} + function BOb(){} + function DOb(){} + function FOb(){} + function IOb(){} + function MOb(){} + function POb(){} + function UOb(){} + function ZOb(){} + function cPb(){} + function gPb(){} + function nPb(){} + function qPb(){} + function tPb(){} + function wPb(){} + function CPb(){} + function qQb(){} + function GQb(){} + function bRb(){} + function gRb(){} + function kRb(){} + function pRb(){} + function wRb(){} + function xSb(){} + function TSb(){} + function VSb(){} + function XSb(){} + function ZSb(){} + function _Sb(){} + function tTb(){} + function DTb(){} + function FTb(){} + function FXb(){} + function hXb(){} + function hWb(){} + function mWb(){} + function CVb(){} + function XXb(){} + function $Xb(){} + function bYb(){} + function lYb(){} + function FYb(){} + function XYb(){} + function aZb(){} + function SZb(){} + function ZZb(){} + function Z_b(){} + function j_b(){} + function j$b(){} + function b$b(){} + function f$b(){} + function n$b(){} + function K_b(){} + function V_b(){} + function b0b(){} + function l0b(){} + function X1b(){} + function _1b(){} + function x3b(){} + function r4b(){} + function w4b(){} + function A4b(){} + function E4b(){} + function I4b(){} + function M4b(){} + function o5b(){} + function q5b(){} + function w5b(){} + function A5b(){} + function E5b(){} + function h6b(){} + function j6b(){} + function l6b(){} + function q6b(){} + function v6b(){} + function y6b(){} + function G6b(){} + function K6b(){} + function N6b(){} + function P6b(){} + function R6b(){} + function b7b(){} + function f7b(){} + function j7b(){} + function n7b(){} + function C7b(){} + function H7b(){} + function J7b(){} + function L7b(){} + function N7b(){} + function P7b(){} + function a8b(){} + function c8b(){} + function e8b(){} + function g8b(){} + function i8b(){} + function m8b(){} + function Z8b(){} + function f9b(){} + function i9b(){} + function o9b(){} + function C9b(){} + function F9b(){} + function K9b(){} + function Q9b(){} + function aac(){} + function bac(){} + function eac(){} + function mac(){} + function pac(){} + function rac(){} + function tac(){} + function xac(){} + function Aac(){} + function Dac(){} + function Iac(){} + function Oac(){} + function Uac(){} + function Ucc(){} + function scc(){} + function ycc(){} + function Acc(){} + function Ccc(){} + function Ncc(){} + function Wcc(){} + function ydc(){} + function Adc(){} + function Gdc(){} + function Ldc(){} + function Zdc(){} + function fec(){} + function Dec(){} + function Gec(){} + function Kec(){} + function efc(){} + function jfc(){} + function nfc(){} + function Bfc(){} + function Ifc(){} + function Lfc(){} + function Rfc(){} + function Ufc(){} + function Zfc(){} + function cgc(){} + function egc(){} + function ggc(){} + function igc(){} + function kgc(){} + function Dgc(){} + function Hgc(){} + function Lgc(){} + function Ngc(){} + function Pgc(){} + function Vgc(){} + function Ygc(){} + function chc(){} + function ehc(){} + function ghc(){} + function ihc(){} + function mhc(){} + function rhc(){} + function uhc(){} + function whc(){} + function yhc(){} + function Ahc(){} + function Chc(){} + function Ghc(){} + function Nhc(){} + function Phc(){} + function Rhc(){} + function Thc(){} + function $hc(){} + function aic(){} + function cic(){} + function eic(){} + function jic(){} + function nic(){} + function pic(){} + function ric(){} + function vic(){} + function yic(){} + function Dic(){} + function Ric(){} + function Zic(){} + function bjc(){} + function djc(){} + function jjc(){} + function njc(){} + function rjc(){} + function tjc(){} + function zjc(){} + function Djc(){} + function Fjc(){} + function Ljc(){} + function Pjc(){} + function Rjc(){} + function fkc(){} + function Kkc(){} + function Mkc(){} + function Okc(){} + function Qkc(){} + function Skc(){} + function Ukc(){} + function Wkc(){} + function clc(){} + function elc(){} + function klc(){} + function mlc(){} + function olc(){} + function qlc(){} + function wlc(){} + function ylc(){} + function Alc(){} + function Jlc(){} + function Joc(){} + function poc(){} + function roc(){} + function toc(){} + function voc(){} + function Boc(){} + function Foc(){} + function Hoc(){} + function Loc(){} + function Noc(){} + function Poc(){} + function qnc(){} + function unc(){} + function upc(){} + function kpc(){} + function mpc(){} + function opc(){} + function qpc(){} + function ypc(){} + function Cpc(){} + function Mpc(){} + function Qpc(){} + function dqc(){} + function jqc(){} + function Aqc(){} + function Eqc(){} + function Gqc(){} + function Sqc(){} + function arc(){} + function lrc(){} + function zrc(){} + function Hrc(){} + function bsc(){} + function dsc(){} + function fsc(){} + function ksc(){} + function msc(){} + function Asc(){} + function Csc(){} + function Esc(){} + function Ksc(){} + function Nsc(){} + function Ssc(){} + function CCc(){} + function tGc(){} + function aHc(){} + function gHc(){} + function nIc(){} + function PJc(){} + function XKc(){} + function fLc(){} + function hLc(){} + function lLc(){} + function eNc(){} + function IOc(){} + function MOc(){} + function WOc(){} + function YOc(){} + function $Oc(){} + function cPc(){} + function iPc(){} + function mPc(){} + function oPc(){} + function qPc(){} + function sPc(){} + function wPc(){} + function APc(){} + function FPc(){} + function HPc(){} + function NPc(){} + function PPc(){} + function TPc(){} + function VPc(){} + function ZPc(){} + function _Pc(){} + function bQc(){} + function dQc(){} + function SQc(){} + function hRc(){} + function HRc(){} + function HSc(){} + function pSc(){} + function xSc(){} + function zSc(){} + function BSc(){} + function DSc(){} + function FSc(){} + function CTc(){} + function ITc(){} + function KTc(){} + function MTc(){} + function XTc(){} + function ZTc(){} + function jVc(){} + function lVc(){} + function zVc(){} + function IVc(){} + function KVc(){} + function KWc(){} + function uWc(){} + function xWc(){} + function AWc(){} + function QWc(){} + function UWc(){} + function qXc(){} + function KXc(){} + function OXc(){} + function SXc(){} + function $Xc(){} + function mYc(){} + function rYc(){} + function zYc(){} + function DYc(){} + function FYc(){} + function HYc(){} + function JYc(){} + function cZc(){} + function gZc(){} + function iZc(){} + function pZc(){} + function tZc(){} + function vZc(){} + function AZc(){} + function GZc(){} + function l_c(){} + function l1c(){} + function b1c(){} + function d1c(){} + function h1c(){} + function n1c(){} + function r1c(){} + function v1c(){} + function x1c(){} + function D1c(){} + function H1c(){} + function L1c(){} + function R1c(){} + function V1c(){} + function Z1c(){} + function Z0c(){} + function a0c(){} + function c0c(){} + function e0c(){} + function k0c(){} + function o0c(){} + function b2c(){} + function l2c(){} + function p2c(){} + function Y2c(){} + function _2c(){} + function A3c(){} + function F3c(){} + function I3c(){} + function K3c(){} + function M3c(){} + function Q3c(){} + function U3c(){} + function c5c(){} + function D5c(){} + function G5c(){} + function J5c(){} + function N5c(){} + function V5c(){} + function p6c(){} + function s6c(){} + function H6c(){} + function K6c(){} + function _7c(){} + function h8c(){} + function j8c(){} + function o8c(){} + function r8c(){} + function u8c(){} + function R8c(){} + function X8c(){} + function o9c(){} + function s9c(){} + function x9c(){} + function Qad(){} + function rcd(){} + function Xcd(){} + function vdd(){} + function Tdd(){} + function _dd(){} + function qed(){} + function sed(){} + function ved(){} + function Hed(){} + function Zed(){} + function bfd(){} + function ifd(){} + function Gfd(){} + function Ifd(){} + function Igd(){} + function agd(){} + function dgd(){} + function pgd(){} + function Hgd(){} + function Kgd(){} + function Mgd(){} + function Ogd(){} + function Qgd(){} + function Sgd(){} + function Ugd(){} + function Wgd(){} + function Ygd(){} + function $gd(){} + function ahd(){} + function chd(){} + function ehd(){} + function ghd(){} + function ihd(){} + function khd(){} + function mhd(){} + function ohd(){} + function qhd(){} + function shd(){} + function Shd(){} + function lkd(){} + function znd(){} + function Jpd(){} + function jrd(){} + function Mrd(){} + function Qrd(){} + function Urd(){} + function Yrd(){} + function Yud(){} + function eud(){} + function asd(){} + function Lsd(){} + function btd(){} + function dtd(){} + function jtd(){} + function otd(){} + function ztd(){} + function Xxd(){} + function $yd(){} + function rzd(){} + function Rzd(){} + function KAd(){} + function hCd(){} + function _Cd(){} + function _Sd(){} + function OSd(){} + function BDd(){} + function BId(){} + function JId(){} + function YHd(){} + function fLd(){} + function cPd(){} + function hQd(){} + function AQd(){} + function kUd(){} + function VUd(){} + function pVd(){} + function W$d(){} + function Z$d(){} + function a_d(){} + function i_d(){} + function v_d(){} + function y_d(){} + function f1d(){} + function L5d(){} + function v6d(){} + function b8d(){} + function e8d(){} + function h8d(){} + function k8d(){} + function n8d(){} + function q8d(){} + function t8d(){} + function w8d(){} + function z8d(){} + function X9d(){} + function _9d(){} + function Mae(){} + function cbe(){} + function ebe(){} + function hbe(){} + function kbe(){} + function nbe(){} + function qbe(){} + function tbe(){} + function wbe(){} + function zbe(){} + function Cbe(){} + function Fbe(){} + function Ibe(){} + function Lbe(){} + function Obe(){} + function Rbe(){} + function Ube(){} + function Xbe(){} + function $be(){} + function bce(){} + function ece(){} + function hce(){} + function kce(){} + function nce(){} + function qce(){} + function tce(){} + function wce(){} + function zce(){} + function Cce(){} + function Fce(){} + function Ice(){} + function Lce(){} + function Oce(){} + function Rce(){} + function Uce(){} + function Xce(){} + function $ce(){} + function bde(){} + function ede(){} + function hde(){} + function kde(){} + function nde(){} + function qde(){} + function tde(){} + function wde(){} + function Hie(){} + function rke(){} + function rne(){} + function Ene(){} + function Gne(){} + function Jne(){} + function Mne(){} + function Pne(){} + function Sne(){} + function Vne(){} + function Yne(){} + function _ne(){} + function yme(){} + function coe(){} + function foe(){} + function ioe(){} + function loe(){} + function ooe(){} + function roe(){} + function uoe(){} + function xoe(){} + function Aoe(){} + function Doe(){} + function Goe(){} + function Joe(){} + function Moe(){} + function Poe(){} + function Soe(){} + function Voe(){} + function Yoe(){} + function _oe(){} + function cpe(){} + function fpe(){} + function ipe(){} + function lpe(){} + function ope(){} + function rpe(){} + function upe(){} + function xpe(){} + function Ape(){} + function Dpe(){} + function Gpe(){} + function Jpe(){} + function Mpe(){} + function Ppe(){} + function Spe(){} + function Vpe(){} + function Ype(){} + function _pe(){} + function cqe(){} + function fqe(){} + function iqe(){} + function lqe(){} + function oqe(){} + function rqe(){} + function uqe(){} + function Tqe(){} + function sue(){} + function Cue(){} + function zl(){wb();} + function z7b(){s7b();} + function ZHb(){YHb();} + function fSb(){eSb();} + function vSb(){tSb();} + function PUb(){OUb();} + function AVb(){yVb();} + function RVb(){QVb();} + function fWb(){dWb();} + function N5b(){H5b();} + function $9b(){U9b();} + function Lcc(){Hcc();} + function pdc(){Zcc();} + function pec(){iec();} + function pGc(){nGc();} + function jGc(){gGc();} + function YGc(){SGc();} + function cGc(){_Fc();} + function NFc(){KFc();} + function xgc(){sgc();} + function xHc(){tHc();} + function pHc(){lHc();} + function IHc(){CHc();} + function XHc(){RHc();} + function boc(){Mnc();} + function yqc(){mqc();} + function Pzc(){Ozc();} + function ACc(){yCc();} + function aKc(){YJc();} + function FLc(){DLc();} + function DNc(){ANc();} + function TNc(){JNc();} + function iQc(){gQc();} + function WRc(){TRc();} + function C$c(){B$c();} + function J0c(){B0c();} + function x0c(){r0c();} + function j_c(){h_c();} + function N_c(){H_c();} + function V_c(){R_c();} + function E4c(){D4c();} + function a5c(){$4c();} + function v7c(){u7c();} + function Z7c(){X7c();} + function pcd(){ncd();} + function Lcd(){Kcd();} + function Vcd(){Tcd();} + function fUd(){TTd();} + function Bfd(){Afd();} + function jkd(){hkd();} + function vmd(){umd();} + function xnd(){vnd();} + function Hpd(){Fpd();} + function HYd(){lYd();} + function yAd(){qAd();} + function gke(){rue();} + function Yxb(a){uFb(a);} + function Yb(a){this.a=a;} + function cc(a){this.a=a;} + function df(a){this.a=a;} + function kf(a){this.a=a;} + function kj(a){this.a=a;} + function qj(a){this.a=a;} + function Lj(a){this.a=a;} + function jh(a){this.a=a;} + function th(a){this.a=a;} + function Bh(a){this.a=a;} + function Xh(a){this.a=a;} + function Xn(a){this.a=a;} + function Di(a){this.a=a;} + function Ki(a){this.a=a;} + function Ik(a){this.a=a;} + function Qk(a){this.a=a;} + function mp(a){this.a=a;} + function Lp(a){this.a=a;} + function iq(a){this.a=a;} + function Eq(a){this.a=a;} + function Vq(a){this.a=a;} + function Or(a){this.a=a;} + function $r(a){this.b=a;} + function Aj(a){this.c=a;} + function vu(a){this.a=a;} + function vw(a){this.a=a;} + function gw(a){this.a=a;} + function lw(a){this.a=a;} + function Iw(a){this.a=a;} + function Nw(a){this.a=a;} + function Sw(a){this.a=a;} + function ex(a){this.a=a;} + function fx(a){this.a=a;} + function lx(a){this.a=a;} + function my(a){this.a=a;} + function qy(a){this.a=a;} + function Oy(a){this.a=a;} + function NB(a){this.a=a;} + function XB(a){this.a=a;} + function hC(a){this.a=a;} + function vC(a){this.a=a;} + function MB(){this.a=[];} + function HEb(a,b){a.a=b;} + function E2b(a,b){a.a=b;} + function F2b(a,b){a.b=b;} + function PRb(a,b){a.b=b;} + function RRb(a,b){a.b=b;} + function QJb(a,b){a.j=b;} + function hQb(a,b){a.g=b;} + function iQb(a,b){a.i=b;} + function _Tb(a,b){a.c=b;} + function G2b(a,b){a.c=b;} + function H2b(a,b){a.d=b;} + function aUb(a,b){a.d=b;} + function h3b(a,b){a.k=b;} + function O3b(a,b){a.c=b;} + function Tmc(a,b){a.c=b;} + function Smc(a,b){a.a=b;} + function DJc(a,b){a.a=b;} + function EJc(a,b){a.f=b;} + function NSc(a,b){a.a=b;} + function OSc(a,b){a.b=b;} + function PSc(a,b){a.d=b;} + function QSc(a,b){a.i=b;} + function RSc(a,b){a.o=b;} + function SSc(a,b){a.r=b;} + function yUc(a,b){a.a=b;} + function zUc(a,b){a.b=b;} + function q3c(a,b){a.e=b;} + function r3c(a,b){a.f=b;} + function s3c(a,b){a.g=b;} + function Y9c(a,b){a.e=b;} + function Z9c(a,b){a.f=b;} + function kad(a,b){a.f=b;} + function Ntd(a,b){a.a=b;} + function Otd(a,b){a.b=b;} + function BWd(a,b){a.n=b;} + function $ee(a,b){a.a=b;} + function _ee(a,b){a.c=b;} + function ife(a,b){a.c=b;} + function Efe(a,b){a.c=b;} + function hfe(a,b){a.a=b;} + function Dfe(a,b){a.a=b;} + function jfe(a,b){a.d=b;} + function Ffe(a,b){a.d=b;} + function kfe(a,b){a.e=b;} + function Gfe(a,b){a.e=b;} + function lfe(a,b){a.g=b;} + function Hfe(a,b){a.f=b;} + function Ife(a,b){a.j=b;} + function wme(a,b){a.a=b;} + function Fme(a,b){a.a=b;} + function xme(a,b){a.b=b;} + function gmc(a){a.b=a.a;} + function Lg(a){a.c=a.d.d;} + function fgb(a){this.a=a;} + function zgb(a){this.a=a;} + function Xgb(a){this.a=a;} + function Xkb(a){this.a=a;} + function mkb(a){this.a=a;} + function reb(a){this.a=a;} + function Seb(a){this.a=a;} + function bfb(a){this.a=a;} + function Tfb(a){this.a=a;} + function blb(a){this.a=a;} + function glb(a){this.a=a;} + function llb(a){this.a=a;} + function Ulb(a){this.a=a;} + function _lb(a){this.a=a;} + function Plb(a){this.b=a;} + function Ppb(a){this.b=a;} + function xpb(a){this.b=a;} + function mpb(a){this.a=a;} + function Yqb(a){this.a=a;} + function uqb(a){this.c=a;} + function Anb(a){this.c=a;} + function zwb(a){this.c=a;} + function Dkb(a){this.d=a;} + function brb(a){this.a=a;} + function Frb(a){this.a=a;} + function hsb(a){this.a=a;} + function ctb(a){this.a=a;} + function cxb(a){this.a=a;} + function axb(a){this.a=a;} + function exb(a){this.a=a;} + function gxb(a){this.a=a;} + function wub(a){this.a=a;} + function zAb(a){this.a=a;} + function JAb(a){this.a=a;} + function LAb(a){this.a=a;} + function PAb(a){this.a=a;} + function VBb(a){this.a=a;} + function lCb(a){this.a=a;} + function nCb(a){this.a=a;} + function pCb(a){this.a=a;} + function CCb(a){this.a=a;} + function GCb(a){this.a=a;} + function bDb(a){this.a=a;} + function dDb(a){this.a=a;} + function fDb(a){this.a=a;} + function uDb(a){this.a=a;} + function $Db(a){this.a=a;} + function aEb(a){this.a=a;} + function eEb(a){this.a=a;} + function OEb(a){this.a=a;} + function SEb(a){this.a=a;} + function SFb(a){this.a=a;} + function HFb(a){this.a=a;} + function NFb(a){this.a=a;} + function WGb(a){this.a=a;} + function HJb(a){this.a=a;} + function PJb(a){this.a=a;} + function kNb(a){this.a=a;} + function tOb(a){this.a=a;} + function APb(a){this.a=a;} + function IQb(a){this.a=a;} + function bTb(a){this.a=a;} + function dTb(a){this.a=a;} + function wTb(a){this.a=a;} + function GWb(a){this.a=a;} + function UWb(a){this.a=a;} + function WWb(a){this.a=a;} + function fXb(a){this.a=a;} + function jXb(a){this.a=a;} + function M0b(a){this.a=a;} + function r1b(a){this.a=a;} + function D1b(a){this.e=a;} + function T3b(a){this.a=a;} + function W3b(a){this.a=a;} + function _3b(a){this.a=a;} + function c4b(a){this.a=a;} + function s5b(a){this.a=a;} + function u5b(a){this.a=a;} + function y5b(a){this.a=a;} + function C5b(a){this.a=a;} + function Q5b(a){this.a=a;} + function S5b(a){this.a=a;} + function U5b(a){this.a=a;} + function W5b(a){this.a=a;} + function l7b(a){this.a=a;} + function p7b(a){this.a=a;} + function k8b(a){this.a=a;} + function L8b(a){this.a=a;} + function Rac(a){this.a=a;} + function Xac(a){this.a=a;} + function $ac(a){this.a=a;} + function bbc(a){this.a=a;} + function Cdc(a){this.a=a;} + function Edc(a){this.a=a;} + function Ehc(a){this.a=a;} + function khc(a){this.a=a;} + function Ihc(a){this.a=a;} + function qfc(a){this.a=a;} + function tfc(a){this.a=a;} + function Wfc(a){this.a=a;} + function Fic(a){this.a=a;} + function Vic(a){this.a=a;} + function fjc(a){this.a=a;} + function pjc(a){this.a=a;} + function ckc(a){this.a=a;} + function hkc(a){this.a=a;} + function Ykc(a){this.a=a;} + function $kc(a){this.a=a;} + function alc(a){this.a=a;} + function glc(a){this.a=a;} + function ilc(a){this.a=a;} + function slc(a){this.a=a;} + function Clc(a){this.a=a;} + function xoc(a){this.a=a;} + function zoc(a){this.a=a;} + function spc(a){this.a=a;} + function Vqc(a){this.a=a;} + function Xqc(a){this.a=a;} + function Gsc(a){this.a=a;} + function Isc(a){this.a=a;} + function JGc(a){this.a=a;} + function NGc(a){this.a=a;} + function MHc(a){this.a=a;} + function JIc(a){this.a=a;} + function fJc(a){this.a=a;} + function BJc(a){this.a=a;} + function dJc(a){this.c=a;} + function Trc(a){this.b=a;} + function eKc(a){this.a=a;} + function IKc(a){this.a=a;} + function KKc(a){this.a=a;} + function MKc(a){this.a=a;} + function yLc(a){this.a=a;} + function HMc(a){this.a=a;} + function LMc(a){this.a=a;} + function PMc(a){this.a=a;} + function TMc(a){this.a=a;} + function XMc(a){this.a=a;} + function ZMc(a){this.a=a;} + function aNc(a){this.a=a;} + function jNc(a){this.a=a;} + function aPc(a){this.a=a;} + function gPc(a){this.a=a;} + function kPc(a){this.a=a;} + function yPc(a){this.a=a;} + function CPc(a){this.a=a;} + function JPc(a){this.a=a;} + function RPc(a){this.a=a;} + function XPc(a){this.a=a;} + function mRc(a){this.a=a;} + function xTc(a){this.a=a;} + function CWc(a){this.a=a;} + function EWc(a){this.a=a;} + function IWc(a){this.a=a;} + function OWc(a){this.a=a;} + function dXc(a){this.a=a;} + function gXc(a){this.a=a;} + function EXc(a){this.a=a;} + function WXc(a){this.a=a;} + function YXc(a){this.a=a;} + function aYc(a){this.a=a;} + function cYc(a){this.a=a;} + function eYc(a){this.a=a;} + function iYc(a){this.a=a;} + function i0c(a){this.a=a;} + function g0c(a){this.a=a;} + function P1c(a){this.a=a;} + function Sad(a){this.a=a;} + function Uad(a){this.a=a;} + function Wad(a){this.a=a;} + function Yad(a){this.a=a;} + function cbd(a){this.a=a;} + function ydd(a){this.a=a;} + function Kdd(a){this.a=a;} + function Mdd(a){this.a=a;} + function _ed(a){this.a=a;} + function dfd(a){this.a=a;} + function Kfd(a){this.a=a;} + function prd(a){this.a=a;} + function $rd(a){this.a=a;} + function csd(a){this.a=a;} + function Usd(a){this.a=a;} + function Vtd(a){this.a=a;} + function wud(a){this.a=a;} + function Rud(a){this.f=a;} + function LEd(a){this.a=a;} + function UEd(a){this.a=a;} + function VEd(a){this.a=a;} + function WEd(a){this.a=a;} + function XEd(a){this.a=a;} + function YEd(a){this.a=a;} + function ZEd(a){this.a=a;} + function $Ed(a){this.a=a;} + function _Ed(a){this.a=a;} + function aFd(a){this.a=a;} + function gFd(a){this.a=a;} + function iFd(a){this.a=a;} + function jFd(a){this.a=a;} + function kFd(a){this.a=a;} + function lFd(a){this.a=a;} + function nFd(a){this.a=a;} + function qFd(a){this.a=a;} + function wFd(a){this.a=a;} + function xFd(a){this.a=a;} + function zFd(a){this.a=a;} + function AFd(a){this.a=a;} + function BFd(a){this.a=a;} + function CFd(a){this.a=a;} + function DFd(a){this.a=a;} + function MFd(a){this.a=a;} + function OFd(a){this.a=a;} + function QFd(a){this.a=a;} + function SFd(a){this.a=a;} + function uGd(a){this.a=a;} + function QGd(a){this.a=a;} + function jGd(a){this.b=a;} + function YOd(a){this.a=a;} + function ePd(a){this.a=a;} + function kPd(a){this.a=a;} + function qPd(a){this.a=a;} + function IPd(a){this.a=a;} + function w$d(a){this.a=a;} + function e_d(a){this.a=a;} + function Q_d(a){this.b=a;} + function c1d(a){this.a=a;} + function c2d(a){this.a=a;} + function l5d(a){this.a=a;} + function I9d(a){this.a=a;} + function L6d(a){this.c=a;} + function t7d(a){this.e=a;} + function pae(a){this.a=a;} + function xae(a){this.a=a;} + function Zde(a){this.a=a;} + function Sde(a){this.d=a;} + function mee(a){this.a=a;} + function uje(a){this.a=a;} + function Bte(a){this.a=a;} + function Wse(a){this.e=a;} + function Xsd(){this.a=0;} + function Tsb(){akb(this);} + function bnb(){Pmb(this);} + function cHb(){bHb(this);} + function I2b(){} + function s2d(){this.c=d2d;} + function Prc(a,b){a.b+=b;} + function Uje(a,b){b.Wb(a);} + function UC(a){return a.a} + function nC(a){return a.a} + function BC(a){return a.a} + function TB(a){return a.a} + function _B(a){return a.a} + function Adb(a){return a.e} + function gC(){return null} + function MC(){return null} + function leb(){MId();OId();} + function qMb(a){a.b.Of(a.e);} + function A$b(a){a.b=new Ri;} + function A8b(a,b){a.b=b-a.b;} + function x8b(a,b){a.a=b-a.a;} + function ZEb(a,b){a.push(b);} + function bFb(a,b){a.sort(b);} + function Q5c(a,b){b.jd(a.a);} + function Voc(a,b){Q3b(b,a);} + function tp(a,b,c){a.Yd(c,b);} + function Ss(a,b){a.e=b;b.b=a;} + function im(a){_l();this.a=a;} + function xq(a){_l();this.a=a;} + function Gq(a){_l();this.a=a;} + function Xq(a){tm();this.a=a;} + function gA(a){fA();eA.le(a);} + function vA(){vA=geb;new Tsb;} + function xz(){mz.call(this);} + function Ceb(){mz.call(this);} + function ueb(){xz.call(this);} + function yeb(){xz.call(this);} + function Hfb(){xz.call(this);} + function _fb(){xz.call(this);} + function cgb(){xz.call(this);} + function Ngb(){xz.call(this);} + function jib(){xz.call(this);} + function Jrb(){xz.call(this);} + function Srb(){xz.call(this);} + function Dvb(){xz.call(this);} + function Ied(){xz.call(this);} + function R1d(){this.a=this;} + function k1d(){this.Bb|=256;} + function vWb(){this.b=new Et;} + function aFb(a,b){a.length=b;} + function dyb(a,b){Rmb(a.a,b);} + function jNb(a,b){LKb(a.c,b);} + function qRc(a,b){Ysb(a.b,b);} + function VOd(a,b){UNd(a.a,b);} + function WOd(a,b){VNd(a.a,b);} + function eZd(a,b){qvd(a.e,b);} + function Cke(a){bge(a.c,a.b);} + function uj(a,b){a.kc().Nb(b);} + function Ufb(a){this.a=Zfb(a);} + function _sb(){this.a=new Tsb;} + function $Ab(){this.a=new Tsb;} + function xAb(){this.a=new dzb;} + function gyb(){this.a=new bnb;} + function BIb(){this.a=new bnb;} + function GIb(){this.a=new bnb;} + function wIb(){this.a=new pIb;} + function gJb(){this.a=new DIb;} + function TTb(){this.a=new DTb;} + function jGb(){this.a=new fGb;} + function qGb(){this.a=new kGb;} + function q_b(){this.a=new bnb;} + function E_b(){this.a=new bnb;} + function EZb(){this.a=new bnb;} + function J$b(){this.a=new bnb;} + function YNb(){this.d=new bnb;} + function lXb(){this.a=new RWb;} + function y_b(){this.a=new _sb;} + function k5b(){this.a=new Tsb;} + function E0b(){this.b=new Tsb;} + function jHc(){this.b=new bnb;} + function ZNc(){this.e=new bnb;} + function ahc(){this.a=new boc;} + function UQc(){this.d=new bnb;} + function uRc(){tRc.call(this);} + function BRc(){tRc.call(this);} + function VOc(){bnb.call(this);} + function web(){ueb.call(this);} + function Fyb(){gyb.call(this);} + function fKb(){RJb.call(this);} + function N$b(){J$b.call(this);} + function P2b(){I2b.call(this);} + function T2b(){P2b.call(this);} + function z3b(){I2b.call(this);} + function C3b(){z3b.call(this);} + function cUc(){aUc.call(this);} + function hUc(){aUc.call(this);} + function mUc(){aUc.call(this);} + function Hdd(){Ddd.call(this);} + function ACd(){$yd.call(this);} + function PCd(){$yd.call(this);} + function Ejd(){Yub.call(this);} + function LQd(){wQd.call(this);} + function lRd(){wQd.call(this);} + function MSd(){Tsb.call(this);} + function VSd(){Tsb.call(this);} + function eTd(){Tsb.call(this);} + function mXd(){HWd.call(this);} + function i1d(){_sb.call(this);} + function A1d(){k1d.call(this);} + function q4d(){dWd.call(this);} + function O5d(){Tsb.call(this);} + function R5d(){dWd.call(this);} + function lae(){Tsb.call(this);} + function Cae(){Tsb.call(this);} + function ome(){kUd.call(this);} + function Hme(){ome.call(this);} + function Nme(){kUd.call(this);} + function Gre(){Tqe.call(this);} + function aUc(){this.a=new _sb;} + function nZc(){this.a=new Tsb;} + function DZc(){this.a=new bnb;} + function Ddd(){this.a=new Tsb;} + function Oqd(){this.a=new Yub;} + function Oed(){this.j=new bnb;} + function obd(){this.a=new nbd;} + function wQd(){this.a=new AQd;} + function R5c(){this.a=new V5c;} + function wb(){wb=geb;vb=new xb;} + function Wk(){Wk=geb;Vk=new Xk;} + function kl(){kl=geb;jl=new ll;} + function ll(){Qk.call(this,'');} + function Xk(){Qk.call(this,'');} + function Dd(a){yd.call(this,a);} + function Hd(a){yd.call(this,a);} + function xh(a){th.call(this,a);} + function $h(a){Wc.call(this,a);} + function Qi(a){Wc.call(this,a);} + function wi(a){$h.call(this,a);} + function Sp(a){$h.call(this,a);} + function Js(a){$h.call(this,a);} + function Jp(a){Xo.call(this,a);} + function Qp(a){Xo.call(this,a);} + function dq(a){ho.call(this,a);} + function Fv(a){uv.call(this,a);} + function aw(a){Tr.call(this,a);} + function cw(a){Tr.call(this,a);} + function _w(a){Tr.call(this,a);} + function Mx(a){Gn.call(this,a);} + function Nx(a){Mx.call(this,a);} + function yz(a){nz.call(this,a);} + function aC(a){yz.call(this,a);} + function uC(){vC.call(this,{});} + function cC(){cC=geb;bC=new dC;} + function zs(){zs=geb;ys=new As;} + function Az(){Az=geb;zz=new nb;} + function $z(){$z=geb;Zz=new bA;} + function $A(){$A=geb;ZA=new aB;} + function Ovb(a){Kvb();this.a=a;} + function FKc(a){jKc();this.a=a;} + function zud(a){nud();this.f=a;} + function Bud(a){nud();this.f=a;} + function Cde(a){KMd();this.a=a;} + function Lyb(a){a.b=null;a.c=0;} + function kz(a,b){a.e=b;hz(a,b);} + function NYb(a,b){a.a=b;PYb(a);} + function cLb(a,b,c){a.a[b.g]=c;} + function zsd(a,b,c){Hsd(c,a,b);} + function shc(a,b){Xmc(b.i,a.n);} + function HCc(a,b){ICc(a).Cd(b);} + function yw(a,b){a.a.ec().Mc(b);} + function ns(a,b){return a.g-b.g} + function AUb(a,b){return a*a/b} + function Heb(a){return uFb(a),a} + function Kfb(a){return uFb(a),a} + function Mfb(a){return uFb(a),a} + function JC(a){return new hC(a)} + function LC(a){return new OC(a)} + function shb(a){return uFb(a),a} + function Chb(a){return uFb(a),a} + function teb(a){yz.call(this,a);} + function veb(a){yz.call(this,a);} + function zeb(a){yz.call(this,a);} + function Aeb(a){nz.call(this,a);} + function Ifb(a){yz.call(this,a);} + function agb(a){yz.call(this,a);} + function dgb(a){yz.call(this,a);} + function Mgb(a){yz.call(this,a);} + function Ogb(a){yz.call(this,a);} + function kib(a){yz.call(this,a);} + function Jed(a){yz.call(this,a);} + function Ked(a){yz.call(this,a);} + function CDd(a){yz.call(this,a);} + function Mle(a){yz.call(this,a);} + function Lqe(a){yz.call(this,a);} + function mob(a){uFb(a);this.a=a;} + function yYb(a){sYb(a);return a} + function Nnb(a){Snb(a,a.length);} + function nmb(a){return a.b==a.c} + function Vyb(a){return !!a&&a.b} + function gLb(a){return !!a&&a.k} + function hLb(a){return !!a&&a.j} + function F_b(a,b,c){a.c.Ef(b,c);} + function Ts(a,b){a.be(b);b.ae(a);} + function Fy(a){_l();this.a=Qb(a);} + function Gb(){this.a=WD(Qb(pve));} + function jc(){throw Adb(new jib)} + function jn(){throw Adb(new jib)} + function Hh(){throw Adb(new jib)} + function Xi(){throw Adb(new jib)} + function Xj(){throw Adb(new jib)} + function Yj(){throw Adb(new jib)} + function Qz(){Qz=geb;!!(fA(),eA);} + function Qhb(){reb.call(this,'');} + function Rhb(){reb.call(this,'');} + function bib(){reb.call(this,'');} + function cib(){reb.call(this,'');} + function eib(a){veb.call(this,a);} + function xeb(a){veb.call(this,a);} + function Vgb(a){agb.call(this,a);} + function Lqb(a){xpb.call(this,a);} + function Sqb(a){Lqb.call(this,a);} + function irb(a){Upb.call(this,a);} + function pc(a){qc.call(this,a,0);} + function Ri(){Si.call(this,12,3);} + function WC(a,b){return xfb(a,b)} + function cFb(a,b){return dD(a,b)} + function Reb(a,b){return a.a-b.a} + function afb(a,b){return a.a-b.a} + function Wgb(a,b){return a.a-b.a} + function pC(b,a){return a in b.a} + function Vvb(a){return a.a?a.b:0} + function cwb(a){return a.a?a.b:0} + function Fxb(a,b,c){b.Cd(a.a[c]);} + function Kxb(a,b,c){b.Pe(a.a[c]);} + function uKb(a,b){a.b=new sjd(b);} + function QGb(a,b){a.b=b;return a} + function RGb(a,b){a.c=b;return a} + function SGb(a,b){a.f=b;return a} + function TGb(a,b){a.g=b;return a} + function yJb(a,b){a.a=b;return a} + function zJb(a,b){a.f=b;return a} + function AJb(a,b){a.k=b;return a} + function WNb(a,b){a.a=b;return a} + function XNb(a,b){a.e=b;return a} + function BYb(a,b){a.e=b;return a} + function CYb(a,b){a.f=b;return a} + function BRb(a,b){a.b=true;a.d=b;} + function WNc(a,b){return a.b-b.b} + function KSc(a,b){return a.g-b.g} + function pmc(a,b){return a?0:b-1} + function qKc(a,b){return a?0:b-1} + function pKc(a,b){return a?b-1:0} + function uVc(a,b){return a.s-b.s} + function Xed(a,b){return b.rg(a)} + function Xfd(a,b){a.b=b;return a} + function Wfd(a,b){a.a=b;return a} + function Yfd(a,b){a.c=b;return a} + function Zfd(a,b){a.d=b;return a} + function $fd(a,b){a.e=b;return a} + function _fd(a,b){a.f=b;return a} + function mgd(a,b){a.a=b;return a} + function ngd(a,b){a.b=b;return a} + function ogd(a,b){a.c=b;return a} + function Khd(a,b){a.c=b;return a} + function Jhd(a,b){a.b=b;return a} + function Lhd(a,b){a.d=b;return a} + function Mhd(a,b){a.e=b;return a} + function Nhd(a,b){a.f=b;return a} + function Ohd(a,b){a.g=b;return a} + function Phd(a,b){a.a=b;return a} + function Qhd(a,b){a.i=b;return a} + function Rhd(a,b){a.j=b;return a} + function coc(a,b){Mnc();P3b(b,a);} + function bbd(a,b,c){_ad(a.a,b,c);} + function Fjd(a){Zub.call(this,a);} + function TRb(a){SRb.call(this,a);} + function pLc(a){CIc.call(this,a);} + function ILc(a){CIc.call(this,a);} + function gLd(a){ZHd.call(this,a);} + function DPd(a){xPd.call(this,a);} + function FPd(a){xPd.call(this,a);} + function x2b(){y2b.call(this,'');} + function pjd(){this.a=0;this.b=0;} + function ATc(){this.b=0;this.a=0;} + function lXd(a,b){a.b=0;bWd(a,b);} + function Kqd(a,b){a.k=b;return a} + function Lqd(a,b){a.j=b;return a} + function vfe(a,b){a.c=b;a.b=true;} + function Etb(){Etb=geb;Dtb=Gtb();} + function bvd(){bvd=geb;avd=OAd();} + function dvd(){dvd=geb;cvd=aCd();} + function MId(){MId=geb;LId=ygd();} + function jTd(){jTd=geb;iTd=Qae();} + function Ole(){Ole=geb;Nle=vne();} + function Qle(){Qle=geb;Ple=Cne();} + function mfb(a){return a.e&&a.e()} + function FD(a){return a.l|a.m<<22} + function Oc(a,b){return a.c._b(b)} + function En(a,b){return Wv(a.b,b)} + function Vd(a){return !a?null:a.d} + function Vv(a){return !a?null:a.g} + function $v(a){return !a?null:a.i} + function nfb(a){lfb(a);return a.o} + function Khb(a,b){a.a+=b;return a} + function Lhb(a,b){a.a+=b;return a} + function Ohb(a,b){a.a+=b;return a} + function Uhb(a,b){a.a+=b;return a} + function _wb(a,b){while(a.Bd(b));} + function atb(a){this.a=new Usb(a);} + function $tb(){throw Adb(new jib)} + function qpb(){throw Adb(new jib)} + function rpb(){throw Adb(new jib)} + function spb(){throw Adb(new jib)} + function vpb(){throw Adb(new jib)} + function Opb(){throw Adb(new jib)} + function yAb(a){this.a=new ezb(a);} + function H2c(){this.a=new Wed(s0);} + function TVc(){this.b=new Wed(H$);} + function l6c(){this.a=new Wed(V0);} + function $ad(){this.b=new Wed(I1);} + function nbd(){this.b=new Wed(I1);} + function T2c(a){this.a=0;this.b=a;} + function Bib(a){tib();vib(this,a);} + function QDb(a){LCb(a);return a.a} + function dvb(a){return a.b!=a.d.c} + function AMc(a,b){return a.d[b.p]} + function ued(a,b){return ned(a,b)} + function $Eb(a,b,c){a.splice(b,c);} + function ixb(a,b){while(a.Re(b));} + function NKb(a){a.c?MKb(a):OKb(a);} + function mQd(){throw Adb(new jib)} + function nQd(){throw Adb(new jib)} + function oQd(){throw Adb(new jib)} + function pQd(){throw Adb(new jib)} + function qQd(){throw Adb(new jib)} + function rQd(){throw Adb(new jib)} + function sQd(){throw Adb(new jib)} + function tQd(){throw Adb(new jib)} + function uQd(){throw Adb(new jib)} + function vQd(){throw Adb(new jib)} + function zue(){throw Adb(new Dvb)} + function Aue(){throw Adb(new Dvb)} + function oue(a){this.a=new Dte(a);} + function Dte(a){Cte(this,a,sse());} + function cve(a){return !a||bve(a)} + function Cqe(a){return xqe[a]!=-1} + function Yz(){Nz!=0&&(Nz=0);Pz=-1;} + function beb(){_db==null&&(_db=[]);} + function eg(a,b){zf.call(this,a,b);} + function gg(a,b){eg.call(this,a,b);} + function Nj(a,b){this.a=a;this.b=b;} + function hk(a,b){this.a=a;this.b=b;} + function nk(a,b){this.a=a;this.b=b;} + function pk(a,b){this.a=a;this.b=b;} + function xk(a,b){this.a=a;this.b=b;} + function zk(a,b){this.a=a;this.b=b;} + function Kk(a,b){this.a=a;this.b=b;} + function ne(a,b){this.e=a;this.d=b;} + function Hf(a,b){this.b=a;this.c=b;} + function cp(a,b){this.b=a;this.a=b;} + function Cp(a,b){this.b=a;this.a=b;} + function qr(a,b){this.b=a;this.a=b;} + function Rr(a,b){this.b=a;this.a=b;} + function vr(a,b){this.a=a;this.b=b;} + function su(a,b){this.a=a;this.b=b;} + function Hu(a,b){this.a=a;this.f=b;} + function gp(a,b){this.g=a;this.i=b;} + function qs(a,b){this.f=a;this.g=b;} + function Gv(a,b){this.b=a;this.c=b;} + function Wc(a){Lb(a.dc());this.c=a;} + function Ex(a,b){this.a=a;this.b=b;} + function ey(a,b){this.a=a;this.b=b;} + function pv(a){this.a=RD(Qb(a),15);} + function uv(a){this.a=RD(Qb(a),15);} + function nw(a){this.a=RD(Qb(a),85);} + function rf(a){this.b=RD(Qb(a),85);} + function Tr(a){this.b=RD(Qb(a),51);} + function uB(){this.q=new $wnd.Date;} + function CC(a,b){this.a=a;this.b=b;} + function Bt(a,b){return Ujb(a.b,b)} + function tpb(a,b){return a.b.Hc(b)} + function upb(a,b){return a.b.Ic(b)} + function wpb(a,b){return a.b.Qc(b)} + function Pqb(a,b){return a.b.Hc(b)} + function pqb(a,b){return a.c.uc(b)} + function rqb(a,b){return pb(a.c,b)} + function Zsb(a,b){return a.a._b(b)} + function Xp(a,b){return a>b&&b0} + function Ldb(a,b){return Ddb(a,b)<0} + function Urb(a,b){return Bsb(a.a,b)} + function Beb(a,b){oz.call(this,a,b);} + function Qx(a){Px();ho.call(this,a);} + function Lnb(a,b){Pnb(a,a.length,b);} + function Mnb(a,b){Rnb(a,a.length,b);} + function Ktb(a,b){return a.a.get(b)} + function bub(a,b){return Ujb(a.e,b)} + function Zxb(a){return uFb(a),false} + function zw(a){this.a=RD(Qb(a),229);} + function $wb(a){Swb.call(this,a,21);} + function dAb(a,b){qs.call(this,a,b);} + function yBb(a,b){qs.call(this,a,b);} + function ssb(a,b){this.b=a;this.a=b;} + function xlb(a,b){this.d=a;this.e=b;} + function jEb(a,b){this.a=a;this.b=b;} + function pEb(a,b){this.a=a;this.b=b;} + function vEb(a,b){this.a=a;this.b=b;} + function BEb(a,b){this.a=a;this.b=b;} + function TFb(a,b){this.a=a;this.b=b;} + function QEb(a,b){this.b=a;this.a=b;} + function sHb(a,b){this.b=a;this.a=b;} + function EHb(a,b){qs.call(this,a,b);} + function MHb(a,b){qs.call(this,a,b);} + function jIb(a,b){qs.call(this,a,b);} + function $Jb(a,b){qs.call(this,a,b);} + function FKb(a,b){qs.call(this,a,b);} + function wLb(a,b){qs.call(this,a,b);} + function nOb(a,b){qs.call(this,a,b);} + function kPb(a,b){this.b=a;this.a=b;} + function JPb(a,b){qs.call(this,a,b);} + function fRb(a,b){this.b=a;this.a=b;} + function JRb(a,b){qs.call(this,a,b);} + function OTb(a,b){this.b=a;this.a=b;} + function UUb(a,b){qs.call(this,a,b);} + function BWb(a,b){qs.call(this,a,b);} + function tXb(a,b){qs.call(this,a,b);} + function XEb(a,b,c){a.splice(b,0,c);} + function pr(a,b,c){a.Mb(c)&&b.Cd(c);} + function lEb(a,b,c){b.Pe(a.a.Ye(c));} + function rEb(a,b,c){b.Dd(a.a.Ze(c));} + function xEb(a,b,c){b.Cd(a.a.Kb(c));} + function eYb(a,b){return Csb(a.c,b)} + function cGb(a,b){return Csb(a.e,b)} + function qZb(a,b){qs.call(this,a,b);} + function V$b(a,b){qs.call(this,a,b);} + function s3b(a,b){qs.call(this,a,b);} + function Q8b(a,b){qs.call(this,a,b);} + function icc(a,b){qs.call(this,a,b);} + function xec(a,b){qs.call(this,a,b);} + function gic(a,b){this.a=a;this.b=b;} + function Xic(a,b){this.a=a;this.b=b;} + function h4b(a,b){this.a=a;this.b=b;} + function vjc(a,b){this.a=a;this.b=b;} + function xjc(a,b){this.a=a;this.b=b;} + function Hjc(a,b){this.a=a;this.b=b;} + function hjc(a,b){this.b=a;this.a=b;} + function Jjc(a,b){this.b=a;this.a=b;} + function _Yb(a,b){this.b=a;this.a=b;} + function eZb(a,b){this.c=a;this.d=b;} + function Q1b(a,b){this.e=a;this.d=b;} + function Tjc(a,b){this.a=a;this.b=b;} + function ulc(a,b){this.a=a;this.b=b;} + function Elc(a,b){this.a=a;this.b=b;} + function fqc(a,b){this.b=a;this.a=b;} + function smc(a,b){this.b=b;this.c=a;} + function fnc(a,b){qs.call(this,a,b);} + function Cnc(a,b){qs.call(this,a,b);} + function koc(a,b){qs.call(this,a,b);} + function ktc(a,b){qs.call(this,a,b);} + function ctc(a,b){qs.call(this,a,b);} + function utc(a,b){qs.call(this,a,b);} + function Ftc(a,b){qs.call(this,a,b);} + function Rtc(a,b){qs.call(this,a,b);} + function _tc(a,b){qs.call(this,a,b);} + function iuc(a,b){qs.call(this,a,b);} + function vuc(a,b){qs.call(this,a,b);} + function Duc(a,b){qs.call(this,a,b);} + function Puc(a,b){qs.call(this,a,b);} + function _uc(a,b){qs.call(this,a,b);} + function pvc(a,b){qs.call(this,a,b);} + function yvc(a,b){qs.call(this,a,b);} + function Hvc(a,b){qs.call(this,a,b);} + function Pvc(a,b){qs.call(this,a,b);} + function dxc(a,b){qs.call(this,a,b);} + function bDc(a,b){qs.call(this,a,b);} + function nDc(a,b){qs.call(this,a,b);} + function yDc(a,b){qs.call(this,a,b);} + function LDc(a,b){qs.call(this,a,b);} + function bEc(a,b){qs.call(this,a,b);} + function lEc(a,b){qs.call(this,a,b);} + function tEc(a,b){qs.call(this,a,b);} + function CEc(a,b){qs.call(this,a,b);} + function LEc(a,b){qs.call(this,a,b);} + function UEc(a,b){qs.call(this,a,b);} + function mFc(a,b){qs.call(this,a,b);} + function vFc(a,b){qs.call(this,a,b);} + function EFc(a,b){qs.call(this,a,b);} + function SKc(a,b){qs.call(this,a,b);} + function cNc(a,b){this.b=a;this.a=b;} + function tNc(a,b){qs.call(this,a,b);} + function QOc(a,b){this.a=a;this.b=b;} + function ePc(a,b){this.a=a;this.b=b;} + function LPc(a,b){this.a=a;this.b=b;} + function xQc(a,b){qs.call(this,a,b);} + function FQc(a,b){qs.call(this,a,b);} + function MQc(a,b){this.a=a;this.b=b;} + function FMc(a,b){dMc();return b!=a} + function Uvb(a){sFb(a.a);return a.b} + function qYb(a){rYb(a,a.c);return a} + function Itb(){Etb();return new Dtb} + function _ec(){Rec();this.a=new e6b;} + function lSc(){dSc();this.a=new _sb;} + function aRc(){WQc();this.b=new _sb;} + function xRc(a,b){this.b=a;this.d=b;} + function nVc(a,b){this.a=a;this.b=b;} + function pVc(a,b){this.a=a;this.b=b;} + function GWc(a,b){this.a=a;this.b=b;} + function IXc(a,b){this.b=a;this.a=b;} + function gTc(a,b){qs.call(this,a,b);} + function eVc(a,b){qs.call(this,a,b);} + function $Vc(a,b){qs.call(this,a,b);} + function XYc(a,b){qs.call(this,a,b);} + function MZc(a,b){qs.call(this,a,b);} + function t_c(a,b){qs.call(this,a,b);} + function B_c(a,b){qs.call(this,a,b);} + function z2c(a,b){qs.call(this,a,b);} + function h3c(a,b){qs.call(this,a,b);} + function $3c(a,b){qs.call(this,a,b);} + function i4c(a,b){qs.call(this,a,b);} + function l5c(a,b){qs.call(this,a,b);} + function v5c(a,b){qs.call(this,a,b);} + function g6c(a,b){qs.call(this,a,b);} + function A6c(a,b){qs.call(this,a,b);} + function a7c(a,b){qs.call(this,a,b);} + function B8c(a,b){qs.call(this,a,b);} + function d9c(a,b){qs.call(this,a,b);} + function D9c(a,b){qs.call(this,a,b);} + function tad(a,b){qs.call(this,a,b);} + function hbd(a,b){qs.call(this,a,b);} + function Nbd(a,b){qs.call(this,a,b);} + function Ybd(a,b){qs.call(this,a,b);} + function ndd(a,b){qs.call(this,a,b);} + function z1c(a,b){this.b=a;this.a=b;} + function B1c(a,b){this.b=a;this.a=b;} + function d2c(a,b){this.b=a;this.a=b;} + function f2c(a,b){this.b=a;this.a=b;} + function m9c(a,b){this.a=a;this.b=b;} + function xed(a,b){this.a=a;this.b=b;} + function ffd(a,b){this.a=a;this.b=b;} + function rjd(a,b){this.a=a;this.b=b;} + function Sjd(a,b){qs.call(this,a,b);} + function Zhd(a,b){qs.call(this,a,b);} + function lid(a,b){qs.call(this,a,b);} + function vkd(a,b){qs.call(this,a,b);} + function Gmd(a,b){qs.call(this,a,b);} + function Pmd(a,b){qs.call(this,a,b);} + function Zmd(a,b){qs.call(this,a,b);} + function jnd(a,b){qs.call(this,a,b);} + function Gnd(a,b){qs.call(this,a,b);} + function Rnd(a,b){qs.call(this,a,b);} + function eod(a,b){qs.call(this,a,b);} + function qod(a,b){qs.call(this,a,b);} + function Eod(a,b){qs.call(this,a,b);} + function Qod(a,b){qs.call(this,a,b);} + function upd(a,b){qs.call(this,a,b);} + function Rpd(a,b){qs.call(this,a,b);} + function eqd(a,b){qs.call(this,a,b);} + function nqd(a,b){qs.call(this,a,b);} + function vqd(a,b){qs.call(this,a,b);} + function Hrd(a,b){qs.call(this,a,b);} + function esd(a,b){this.a=a;this.b=b;} + function gsd(a,b){this.a=a;this.b=b;} + function isd(a,b){this.a=a;this.b=b;} + function Osd(a,b){this.a=a;this.b=b;} + function Qsd(a,b){this.a=a;this.b=b;} + function Ssd(a,b){this.a=a;this.b=b;} + function Ptd(a,b){this.a=a;this.b=b;} + function JEd(a,b){this.a=a;this.b=b;} + function KEd(a,b){this.a=a;this.b=b;} + function MEd(a,b){this.a=a;this.b=b;} + function NEd(a,b){this.a=a;this.b=b;} + function QEd(a,b){this.a=a;this.b=b;} + function REd(a,b){this.a=a;this.b=b;} + function SEd(a,b){this.b=a;this.a=b;} + function TEd(a,b){this.b=a;this.a=b;} + function bFd(a,b){this.b=a;this.a=b;} + function dFd(a,b){this.b=a;this.a=b;} + function fFd(a,b){this.a=a;this.b=b;} + function hFd(a,b){this.a=a;this.b=b;} + function utd(a,b){qs.call(this,a,b);} + function sFd(a,b){this.a=a;this.b=b;} + function uFd(a,b){this.a=a;this.b=b;} + function bGd(a,b){qs.call(this,a,b);} + function uId(a,b){this.f=a;this.c=b;} + function Ofd(a,b){return Csb(a.g,b)} + function Tqc(a,b){return Csb(b.b,a)} + function HPd(a,b){return QNd(a.a,b)} + function Idd(a,b){return -a.b.af(b)} + function IId(a,b){!!a&&Zjb(CId,a,b);} + function yWd(a,b){a.i=null;zWd(a,b);} + function kEd(a,b,c){pDd(b,KDd(a,c));} + function lEd(a,b,c){pDd(b,KDd(a,c));} + function mFd(a,b){vEd(a.a,RD(b,58));} + function _Mc(a,b){GMc(a.a,RD(b,12));} + function KTd(a,b){this.a=a;this.b=b;} + function NTd(a,b){this.a=a;this.b=b;} + function B5d(a,b){this.a=a;this.b=b;} + function Z6d(a,b){this.a=a;this.b=b;} + function Ble(a,b){this.a=a;this.b=b;} + function afe(a,b){this.d=a;this.b=b;} + function wfe(a,b){this.e=a;this.a=b;} + function Eke(a,b){this.b=a;this.c=b;} + function zNd(a,b){this.i=a;this.g=b;} + function kZd(a,b){this.d=a;this.e=b;} + function ave(a,b){eve(new dMd(a),b);} + function Dke(a){return pge(a.c,a.b)} + function Wd(a){return !a?null:a.md()} + function dE(a){return a==null?null:a} + function bE(a){return typeof a===jve} + function $D(a){return typeof a===hve} + function _D(a){return typeof a===ive} + function Gdb(a,b){return Ddb(a,b)==0} + function Jdb(a,b){return Ddb(a,b)>=0} + function Pdb(a,b){return Ddb(a,b)!=0} + function ar(a,b){return zr(a.Kc(),b)} + function Qm(a,b){return a.Rd().Xb(b)} + function kg(a){ig(a);return a.d.gc()} + function fE(a){CFb(a==null);return a} + function Mhb(a,b){a.a+=''+b;return a} + function Nhb(a,b){a.a+=''+b;return a} + function Whb(a,b){a.a+=''+b;return a} + function Yhb(a,b){a.a+=''+b;return a} + function Zhb(a,b){a.a+=''+b;return a} + function Vhb(a,b){return a.a+=''+b,a} + function Pfb(a){return ''+(uFb(a),a)} + function Vsb(a){akb(this);Ld(this,a);} + function YFc(){RFc();UFc.call(this);} + function pxb(a,b){kxb.call(this,a,b);} + function txb(a,b){kxb.call(this,a,b);} + function xxb(a,b){kxb.call(this,a,b);} + function Oub(a,b){Pub(a,b,a.c.b,a.c);} + function Nub(a,b){Pub(a,b,a.a,a.a.a);} + function Iob(a){tFb(a,0);return null} + function Xvb(){this.b=0;this.a=false;} + function dwb(){this.b=0;this.a=false;} + function Et(){this.b=new Usb(Sv(12));} + function pMb(){pMb=geb;oMb=ss(nMb());} + function ncc(){ncc=geb;mcc=ss(lcc());} + function aZc(){aZc=geb;_Yc=ss($Yc());} + function WA(){WA=geb;vA();VA=new Tsb;} + function hjd(a){a.a=0;a.b=0;return a} + function qfd(a,b){a.a=b.g+1;return a} + function yNd(a,b){aMd.call(this,a,b);} + function lGd(a,b){kGd.call(this,a,b);} + function N$d(a,b){zNd.call(this,a,b);} + function Whe(a,b){Q2d.call(this,a,b);} + function She(a,b){Phe.call(this,a,b);} + function RRd(a,b){PRd();Zjb(ORd,a,b);} + function sB(a,b){a.q.setTime(Xdb(b));} + function Xz(a){$wnd.clearTimeout(a);} + function cr(a){return Qb(a),new Dl(a)} + function mb(a,b){return dE(a)===dE(b)} + function Mw(a,b){return a.a.a.a.cc(b)} + function qeb(a,b){return zhb(a.a,0,b)} + function SSb(a){return MSb(RD(a,74))} + function Nfb(a){return eE((uFb(a),a))} + function Ofb(a){return eE((uFb(a),a))} + function gD(a){return hD(a.l,a.m,a.h)} + function egb(a,b){return hgb(a.a,b.a)} + function ygb(a,b){return Agb(a.a,b.a)} + function Sfb(a,b){return Qfb(a.a,b.a)} + function qhb(a,b){return a.indexOf(b)} + function nOc(a,b){return a.j[b.p]==2} + function cz(a,b){return a==b?0:a?1:-1} + function AB(a){return a<10?'0'+a:''+a} + function Kdb(a){return typeof a===ive} + function oZb(a){return a==jZb||a==mZb} + function pZb(a){return a==jZb||a==kZb} + function ELb(a,b){return hgb(a.g,b.g)} + function Q4b(a){return Wmb(a.b.b,a,0)} + function Q2b(){J2b.call(this,0,0,0,0);} + function Iub(){ctb.call(this,new gub);} + function Znb(a,b){Wnb(a,0,a.length,b);} + function Eyb(a,b){Rmb(a.a,b);return b} + function Fkc(a,b){lkc();return b.a+=a} + function Hkc(a,b){lkc();return b.a+=a} + function Gkc(a,b){lkc();return b.c+=a} + function ied(a,b){Rmb(a.c,b);return a} + function Ped(a,b){ofd(a.a,b);return a} + function ttb(a){this.a=Itb();this.b=a;} + function Ntb(a){this.a=Itb();this.b=a;} + function sjd(a){this.a=a.a;this.b=a.b;} + function Dl(a){this.a=a;zl.call(this);} + function Gl(a){this.a=a;zl.call(this);} + function Tid(){Uid.call(this,0,0,0,0);} + function vfd(a){return ofd(new ufd,a)} + function Ksd(a){return iyd(RD(a,123))} + function Mvd(a){return a.vh()&&a.wh()} + function Dod(a){return a!=zod&&a!=Aod} + function Dmd(a){return a==ymd||a==zmd} + function Emd(a){return a==Bmd||a==xmd} + function xDc(a){return a==tDc||a==sDc} + function yrc(a,b){return hgb(a.g,b.g)} + function Yfe(a,b){return new Phe(b,a)} + function Zfe(a,b){return new Phe(b,a)} + function lr(a){return Dr(a.b.Kc(),a.a)} + function IXd(a,b){yXd(a,b);zXd(a,a.D);} + function Uxd(a,b,c){Vxd(a,b);Wxd(a,c);} + function zyd(a,b,c){Cyd(a,b);Ayd(a,c);} + function Byd(a,b,c){Dyd(a,b);Eyd(a,c);} + function Gzd(a,b,c){Hzd(a,b);Izd(a,c);} + function Nzd(a,b,c){Ozd(a,b);Pzd(a,c);} + function eh(a,b,c){bh.call(this,a,b,c);} + function zId(a){uId.call(this,a,true);} + function nAb(){dAb.call(this,'Tail',3);} + function iAb(){dAb.call(this,'Head',1);} + function ejb(a){Pib();fjb.call(this,a);} + function A3b(a){J2b.call(this,a,a,a,a);} + function Pmb(a){a.c=$C(jJ,rve,1,0,5,1);} + function yRb(a){a.b&&CRb(a);return a.a} + function zRb(a){a.b&&CRb(a);return a.c} + function mBb(a,b){if(dBb){return}a.b=b;} + function YCb(a,b){return a[a.length]=b} + function _Cb(a,b){return a[a.length]=b} + function l5b(a,b){return NGd(b,MCd(a))} + function m5b(a,b){return NGd(b,MCd(a))} + function DDd(a,b){return lp(Co(a.d),b)} + function EDd(a,b){return lp(Co(a.g),b)} + function FDd(a,b){return lp(Co(a.j),b)} + function mGd(a,b){kGd.call(this,a.b,b);} + function s0d(a,b){WGd(tYd(a.a),v0d(b));} + function B4d(a,b){WGd(o4d(a.a),E4d(b));} + function Asd(a,b,c){Byd(c,c.i+a,c.j+b);} + function eFc(a,b,c){bD(a.c[b.g],b.g,c);} + function zVd(a,b,c){RD(a.c,71).Gi(b,c);} + function LMd(a,b,c){bD(a,b,c);return c} + function DJb(a){Umb(a.Sf(),new HJb(a));} + function Gvb(a){return a!=null?tb(a):0} + function aOd(a){return a==null?0:tb(a)} + function iue(a){Vse();Wse.call(this,a);} + function Ug(a){this.a=a;Og.call(this,a);} + function Zy(){Zy=geb;$wnd.Math.log(2);} + function s7d(){s7d=geb;r7d=($Sd(),ZSd);} + function FRc(){FRc=geb;ERc=new Zrb(u3);} + function Hde(){Hde=geb;new Ide;new bnb;} + function Ide(){new Tsb;new Tsb;new Tsb;} + function yue(){throw Adb(new kib(bMe))} + function Nue(){throw Adb(new kib(bMe))} + function Bue(){throw Adb(new kib(cMe))} + function Que(){throw Adb(new kib(cMe))} + function Gp(a){this.a=a;rf.call(this,a);} + function Np(a){this.a=a;rf.call(this,a);} + function Sq(a,b){tm();this.a=a;this.b=b;} + function Jh(a,b){Qb(b);Ih(a).Jc(new jx);} + function _mb(a,b){Ynb(a.c,a.c.length,b);} + function xnb(a){return a.ab?1:0} + function Kgb(a,b){return Ddb(a,b)>0?a:b} + function hD(a,b,c){return {l:a,m:b,h:c}} + function Mvb(a,b){a.a!=null&&_Mc(b,a.a);} + function Lhc(a){Y0b(a,null);Z0b(a,null);} + function xkc(a,b,c){return Zjb(a.g,c,b)} + function bFc(a,b,c){return _Ec(b,c,a.c)} + function jOc(a,b,c){return Zjb(a.k,c,b)} + function pOc(a,b,c){qOc(a,b,c);return c} + function FOc(a,b){dOc();return b.n.b+=a} + function lUb(a){VTb.call(this);this.b=a;} + function y2b(a){v2b.call(this);this.a=a;} + function kAb(){dAb.call(this,'Range',2);} + function $Fb(a){this.b=a;this.a=new bnb;} + function WQb(a){this.b=new gRb;this.a=a;} + function Lub(a){a.a=new svb;a.c=new svb;} + function nrc(a){a.a=new Tsb;a.d=new Tsb;} + function $Sc(a){_Sc(a,null);aTc(a,null);} + function a2d(a,b){return xA(a.a,b,null)} + function Cdd(a,b){return Zjb(a.a,b.a,b)} + function ajd(a){return new rjd(a.a,a.b)} + function Pid(a){return new rjd(a.c,a.d)} + function Qid(a){return new rjd(a.c,a.d)} + function Ake(a,b){return Tfe(a.c,a.b,b)} + function ZD(a,b){return a!=null&&QD(a,b)} + function br(a,b){return Jr(a.Kc(),b)!=-1} + function Hr(a){return a.Ob()?a.Pb():null} + function _p(a){this.b=(yob(),new uqb(a));} + function zke(a){this.a=a;Tsb.call(this);} + function Uhe(){Q2d.call(this,null,null);} + function Yhe(){p3d.call(this,null,null);} + function As(){qs.call(this,'INSTANCE',0);} + function dXb(){_Wb();this.a=new Wed(UP);} + function Hhb(a){return Ihb(a,0,a.length)} + function Rv(a,b){return new ew(a.Kc(),b)} + function $sb(a,b){return a.a.Bc(b)!=null} + function hZd(a,b){sLd(a);a.Gc(RD(b,15));} + function ONd(a,b,c){a.c.bd(b,RD(c,136));} + function eOd(a,b,c){a.c.Ui(b,RD(c,136));} + function eub(a,b){if(a.c){rub(b);qub(b);}} + function oB(a,b){a.q.setHours(b);mB(a,b);} + function vTb(a,b){Zid(b,a.a.a.a,a.a.a.b);} + function tKb(a,b,c,d){bD(a.a[b.g],c.g,d);} + function oKb(a,b,c){return a.a[b.g][c.g]} + function AIc(a,b){return a.e[b.c.p][b.p]} + function TIc(a,b){return a.c[b.c.p][b.p]} + function pJc(a,b){return a.a[b.c.p][b.p]} + function mOc(a,b){return a.j[b.p]=AOc(b)} + function wAb(a,b){return a.a.Bc(b)!=null} + function wXc(a,b){return Kfb(UD(b.a))<=a} + function xXc(a,b){return Kfb(UD(b.a))>=a} + function vhd(a,b){return jhb(a.f,b.Pg())} + function cjd(a,b){return a.a*b.a+a.b*b.b} + function Wsd(a,b){return a.a0?b/(a*a):b*100} + function FUb(a,b){return a>0?b*b/a:b*b*100} + function $5b(a,b){return RD(cub(a.a,b),34)} + function doc(a,b){Mnc();return Rc(a,b.e,b)} + function NCc(a,b,c){GCc();return c.Mg(a,b)} + function L0c(a){B0c();return a.e.a+a.f.a/2} + function N0c(a,b,c){B0c();return c.e.a-a*b} + function V0c(a){B0c();return a.e.b+a.f.b/2} + function X0c(a,b,c){B0c();return c.e.b-a*b} + function _tb(a){a.d=new tub(a);a.e=new Tsb;} + function x3c(){this.a=new Tp;this.b=new Tp;} + function hmc(a){this.c=a;this.a=1;this.b=1;} + function C$b(a){z$b();A$b(this);this.Ff(a);} + function Efd(a,b,c){Afd();a.pf(b)&&c.Cd(a);} + function Red(a,b,c){return Rmb(b,Ted(a,c))} + function Zid(a,b,c){a.a+=b;a.b+=c;return a} + function jjd(a,b,c){a.a*=b;a.b*=c;return a} + function mjd(a,b){a.a=b.a;a.b=b.b;return a} + function fjd(a){a.a=-a.a;a.b=-a.b;return a} + function njd(a,b,c){a.a-=b;a.b-=c;return a} + function Gjd(a){Yub.call(this);zjd(this,a);} + function Dbd(){qs.call(this,'GROW_TREE',0);} + function WRb(){qs.call(this,'POLYOMINO',0);} + function SVd(a,b,c){DVd.call(this,a,b,c,2);} + function r0d(a,b,c){VGd(tYd(a.a),b,v0d(c));} + function e3d(a,b){N2d();Q2d.call(this,a,b);} + function D3d(a,b){j3d();p3d.call(this,a,b);} + function F3d(a,b){j3d();D3d.call(this,a,b);} + function H3d(a,b){j3d();p3d.call(this,a,b);} + function PNd(a,b){return a.c.Fc(RD(b,136))} + function A4d(a,b,c){VGd(o4d(a.a),b,E4d(c));} + function Ard(a){this.c=a;Dyd(a,0);Eyd(a,0);} + function Z8d(a,b){s7d();N8d.call(this,a,b);} + function _8d(a,b){s7d();Z8d.call(this,a,b);} + function b9d(a,b){s7d();Z8d.call(this,a,b);} + function n9d(a,b){s7d();N8d.call(this,a,b);} + function d9d(a,b){s7d();b9d.call(this,a,b);} + function p9d(a,b){s7d();n9d.call(this,a,b);} + function v9d(a,b){s7d();N8d.call(this,a,b);} + function lge(a,b,c){return b.zl(a.e,a.c,c)} + function nge(a,b,c){return b.Al(a.e,a.c,c)} + function Wee(a,b,c){return tfe(Pee(a,b),c)} + function Age(a,b){return Vvd(a.e,RD(b,54))} + function _me(a){return a==null?null:Bqe(a)} + function dne(a){return a==null?null:Iqe(a)} + function gne(a){return a==null?null:jeb(a)} + function hne(a){return a==null?null:jeb(a)} + function TD(a){CFb(a==null||$D(a));return a} + function UD(a){CFb(a==null||_D(a));return a} + function WD(a){CFb(a==null||bE(a));return a} + function lfb(a){if(a.o!=null){return}Bfb(a);} + function lFb(a){if(!a){throw Adb(new _fb)}} + function pFb(a){if(!a){throw Adb(new yeb)}} + function sFb(a){if(!a){throw Adb(new Dvb)}} + function yFb(a){if(!a){throw Adb(new cgb)}} + function zmb(a){if(!a){throw Adb(new Jrb)}} + function jQd(){jQd=geb;iQd=new LQd;new lRd;} + function u2c(){u2c=geb;t2c=new jGd('root');} + function d6d(){HWd.call(this);this.Bb|=txe;} + function Pg(a,b){this.d=a;Lg(this);this.b=b;} + function WCb(a,b){NCb.call(this,a);this.a=b;} + function oDb(a,b){NCb.call(this,a);this.a=b;} + function bh(a,b,c){lg.call(this,a,b,c,null);} + function fh(a,b,c){lg.call(this,a,b,c,null);} + function Mf(a,b){this.c=a;ne.call(this,a,b);} + function Uf(a,b){this.a=a;Mf.call(this,a,b);} + function wB(a){this.q=new $wnd.Date(Xdb(a));} + function OPb(a){if(a>8){return 0}return a+1} + function iBb(a,b){if(dBb){return}Rmb(a.a,b);} + function P5b(a,b){H5b();return n2b(b.d.i,a)} + function qdc(a,b){Zcc();return new xdc(b,a)} + function HAb(a,b,c){return a.Ne(b,c)<=0?c:b} + function IAb(a,b,c){return a.Ne(b,c)<=0?b:c} + function rgd(a,b){return RD(cub(a.b,b),143)} + function tgd(a,b){return RD(cub(a.c,b),233)} + function amc(a){return RD(Vmb(a.a,a.b),294)} + function Mid(a){return new rjd(a.c,a.d+a.a)} + function Jeb(a){return (uFb(a),a)?1231:1237} + function EPc(a){return dOc(),xDc(RD(a,203))} + function RMb(){RMb=geb;QMb=xsb((Qpd(),Ppd));} + function YQb(a,b){b.a?ZQb(a,b):wAb(a.a,b.b);} + function aJd(a,b,c){++a.j;a.tj();$Gd(a,b,c);} + function $Id(a,b,c){++a.j;a.qj(b,a.Zi(b,c));} + function B2d(a,b,c){var d;d=a.fd(b);d.Rb(c);} + function Bzd(a,b,c){c=xvd(a,b,6,c);return c} + function izd(a,b,c){c=xvd(a,b,3,c);return c} + function KCd(a,b,c){c=xvd(a,b,9,c);return c} + function SKb(a,b){Ivb(b,Pye);a.f=b;return a} + function bOd(a,b){return (b&lve)%a.d.length} + function Bke(a,b,c){return age(a.c,a.b,b,c)} + function ZLd(a,b){this.c=a;ZHd.call(this,b);} + function w0d(a,b){this.a=a;Q_d.call(this,b);} + function F4d(a,b){this.a=a;Q_d.call(this,b);} + function kGd(a,b){jGd.call(this,a);this.a=b;} + function U6d(a,b){L6d.call(this,a);this.a=b;} + function S9d(a,b){L6d.call(this,a);this.a=b;} + function jQb(a){gQb.call(this,0,0);this.f=a;} + function _hb(a,b,c){a.a+=Ihb(b,0,c);return a} + function _A(a){!a.a&&(a.a=new jB);return a.a} + function qlb(a,b){var c;c=a.e;a.e=b;return c} + function Clb(a,b){var c;c=b;return !!a.Fe(c)} + function Keb(a,b){Geb();return a==b?0:a?1:-1} + function Ikb(a,b){a.a.bd(a.b,b);++a.b;a.c=-1;} + function hg(a){a.b?hg(a.b):a.f.c.zc(a.e,a.d);} + function aub(a){akb(a.e);a.d.b=a.d;a.d.a=a.d;} + function VDb(a,b,c){xDb();HEb(a,b.Ve(a.a,c));} + function Xrb(a,b,c){return Wrb(a,RD(b,22),c)} + function WEb(a,b){return cFb(new Array(b),a)} + function Fgb(a){return Ydb(Udb(a,32))^Ydb(a)} + function XD(a){return String.fromCharCode(a)} + function Dz(a){return a==null?null:a.message} + function Rz(a,b,c){return a.apply(b,c);} + function Btb(a,b){var c;c=a[Jxe];c.call(a,b);} + function Ctb(a,b){var c;c=a[Jxe];c.call(a,b);} + function O5b(a,b){H5b();return !n2b(b.d.i,a)} + function R2b(a,b,c,d){J2b.call(this,a,b,c,d);} + function TJb(){RJb.call(this);this.a=new pjd;} + function v2b(){this.n=new pjd;this.o=new pjd;} + function kGb(){this.b=new pjd;this.c=new bnb;} + function cUb(){this.a=new bnb;this.b=new bnb;} + function kWb(){this.a=new DTb;this.b=new vWb;} + function e6b(){this.b=new gub;this.a=new gub;} + function jIc(){this.b=new _sb;this.a=new _sb;} + function vYc(){this.b=new Tsb;this.a=new Tsb;} + function fWc(){this.b=new TVc;this.a=new IVc;} + function Yhc(){this.a=new yqc;this.b=new Sqc;} + function lNc(){this.a=new bnb;this.d=new bnb;} + function RJb(){this.n=new z3b;this.i=new Tid;} + function hq(a){this.a=(dk(a,iwe),new cnb(a));} + function oq(a){this.a=(dk(a,iwe),new cnb(a));} + function tLd(a){return a<100?null:new gLd(a)} + function Lac(a,b){return a.n.a=(uFb(b),b)+10} + function Mac(a,b){return a.n.a=(uFb(b),b)+10} + function DYd(a,b){return b==a||PHd(sYd(b),a)} + function nae(a,b){return Zjb(a.a,b,'')==null} + function Hee(a,b){var c;c=b.qi(a.a);return c} + function $id(a,b){a.a+=b.a;a.b+=b.b;return a} + function ojd(a,b){a.a-=b.a;a.b-=b.b;return a} + function sfd(a){aFb(a.j.c,0);a.a=-1;return a} + function rCd(a,b,c){c=xvd(a,b,11,c);return c} + function SDd(a,b,c){c!=null&&Kzd(b,uEd(a,c));} + function TDd(a,b,c){c!=null&&Lzd(b,uEd(a,c));} + function G5d(a,b,c,d){C5d.call(this,a,b,c,d);} + function oie(a,b,c,d){C5d.call(this,a,b,c,d);} + function sie(a,b,c,d){oie.call(this,a,b,c,d);} + function Nie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Pie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Vie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Tie(a,b,c,d){Pie.call(this,a,b,c,d);} + function $ie(a,b,c,d){Pie.call(this,a,b,c,d);} + function Yie(a,b,c,d){Vie.call(this,a,b,c,d);} + function bje(a,b,c,d){$ie.call(this,a,b,c,d);} + function Dje(a,b,c,d){wje.call(this,a,b,c,d);} + function aMd(a,b){veb.call(this,HJe+a+NIe+b);} + function Hje(a,b){return a.jk().wi().ri(a,b)} + function Ije(a,b){return a.jk().wi().ti(a,b)} + function Lfb(a,b){return uFb(a),dE(a)===dE(b)} + function lhb(a,b){return uFb(a),dE(a)===dE(b)} + function mEb(a,b){return a.b.Bd(new pEb(a,b))} + function sEb(a,b){return a.b.Bd(new vEb(a,b))} + function yEb(a,b){return a.b.Bd(new BEb(a,b))} + function Bk(a,b){return a.e=RD(a.d.Kb(b),159)} + function uhb(a,b,c){return a.lastIndexOf(b,c)} + function wWb(a,b,c){return Qfb(a[b.a],a[c.a])} + function TWb(a,b){return pQb(b,(yCc(),gAc),a)} + function Lpc(a,b){return hgb(b.a.d.p,a.a.d.p)} + function Kpc(a,b){return hgb(a.a.d.p,b.a.d.p)} + function zTc(a,b){return Qfb(a.c-a.s,b.c-b.s)} + function qWc(a,b){return Qfb(a.b.e.a,b.b.e.a)} + function sWc(a,b){return Qfb(a.c.e.a,b.c.e.a)} + function $2b(a){return !a.c?-1:Wmb(a.c.a,a,0)} + function Cod(a){return a==vod||a==xod||a==wod} + function CMd(a,b){this.c=a;nMd.call(this,a,b);} + function fq(a,b,c){this.a=a;qc.call(this,b,c);} + function YDb(a){this.c=a;xxb.call(this,Sve,0);} + function rk(a,b,c){this.c=b;this.b=c;this.a=a;} + function DMc(a){dMc();this.d=a;this.a=new wmb;} + function ho(a){_l();this.a=(yob(),new Lqb(a));} + function Xmc(a,b){Dmd(a.f)?Ymc(a,b):Zmc(a,b);} + function Lxb(a,b){Mxb.call(this,a,a.length,b);} + function nBb(a,b){if(dBb){return}!!b&&(a.d=b);} + function ZNd(a,b){return ZD(b,15)&&_Gd(a.c,b)} + function AVd(a,b,c){return RD(a.c,71).Wk(b,c)} + function BVd(a,b,c){return RD(a.c,71).Xk(b,c)} + function mge(a,b,c){return lge(a,RD(b,343),c)} + function oge(a,b,c){return nge(a,RD(b,343),c)} + function Ige(a,b,c){return Hge(a,RD(b,343),c)} + function Kge(a,b,c){return Jge(a,RD(b,343),c)} + function Fn(a,b){return b==null?null:Xv(a.b,b)} + function Qeb(a){return _D(a)?(uFb(a),a):a.ue()} + function Rfb(a){return !isNaN(a)&&!isFinite(a)} + function Zub(a){Lub(this);Xub(this);ye(this,a);} + function dnb(a){Pmb(this);YEb(this.c,0,a.Pc());} + function Fsb(a,b,c){this.a=a;this.b=b;this.c=c;} + function Vtb(a,b,c){this.a=a;this.b=b;this.c=c;} + function hvb(a,b,c){this.d=a;this.b=c;this.a=b;} + function aBb(a){this.a=a;gib();Hdb(Date.now());} + function wzb(a){Ckb(a.a);Yyb(a.c,a.b);a.b=null;} + function wvb(){wvb=geb;uvb=new xvb;vvb=new zvb;} + function KMd(){KMd=geb;JMd=$C(jJ,rve,1,0,5,1);} + function TTd(){TTd=geb;STd=$C(jJ,rve,1,0,5,1);} + function yUd(){yUd=geb;xUd=$C(jJ,rve,1,0,5,1);} + function _l(){_l=geb;new im((yob(),yob(),vob));} + function gAb(a){cAb();return ws((qAb(),pAb),a)} + function zBb(a){xBb();return ws((CBb(),BBb),a)} + function FHb(a){DHb();return ws((IHb(),HHb),a)} + function NHb(a){LHb();return ws((QHb(),PHb),a)} + function kIb(a){iIb();return ws((nIb(),mIb),a)} + function _Jb(a){ZJb();return ws((cKb(),bKb),a)} + function GKb(a){EKb();return ws((JKb(),IKb),a)} + function xLb(a){vLb();return ws((ALb(),zLb),a)} + function mMb(a){hMb();return ws((pMb(),oMb),a)} + function oOb(a){mOb();return ws((rOb(),qOb),a)} + function KPb(a){IPb();return ws((NPb(),MPb),a)} + function KRb(a){IRb();return ws((NRb(),MRb),a)} + function XRb(a){VRb();return ws(($Rb(),ZRb),a)} + function VUb(a){TUb();return ws((YUb(),XUb),a)} + function CWb(a){AWb();return ws((FWb(),EWb),a)} + function uXb(a){sXb();return ws((xXb(),wXb),a)} + function tZb(a){nZb();return ws((wZb(),vZb),a)} + function W$b(a){U$b();return ws((Z$b(),Y$b),a)} + function Mb(a,b){if(!a){throw Adb(new agb(b))}} + function Vb(a){if(!a){throw Adb(new dgb(tve))}} + function rFb(a,b){if(a!=b){throw Adb(new Jrb)}} + function KQb(a,b,c){this.a=a;this.b=b;this.c=c;} + function lRb(a,b,c){this.a=a;this.b=b;this.c=c;} + function h7b(a,b,c){this.a=a;this.b=b;this.c=c;} + function J0b(a,b,c){this.b=a;this.a=b;this.c=c;} + function dNb(a,b,c){this.b=a;this.c=b;this.a=c;} + function oac(a,b,c){this.a=a;this.b=b;this.c=c;} + function F1b(a,b,c){this.e=b;this.b=a;this.d=c;} + function Ecc(a,b,c){this.b=a;this.a=b;this.c=c;} + function UDb(a,b,c){xDb();a.a.Yd(b,c);return b} + function CJb(a){var b;b=new BJb;b.e=a;return b} + function _Nb(a){var b;b=new YNb;b.b=a;return b} + function U9b(){U9b=geb;S9b=new bac;T9b=new eac;} + function Rec(){Rec=geb;Qec=new efc;Pec=new jfc;} + function lkc(){lkc=geb;jkc=new Mkc;kkc=new Okc;} + function loc(a){joc();return ws((ooc(),noc),a)} + function kcc(a){hcc();return ws((ncc(),mcc),a)} + function yec(a){vec();return ws((Bec(),Aec),a)} + function gnc(a){enc();return ws((jnc(),inc),a)} + function Enc(a){Bnc();return ws((Hnc(),Gnc),a)} + function gpc(a){epc();return ws((jpc(),ipc),a)} + function dtc(a){btc();return ws((gtc(),ftc),a)} + function ltc(a){jtc();return ws((otc(),ntc),a)} + function xtc(a){stc();return ws((Atc(),ztc),a)} + function Gtc(a){Etc();return ws((Jtc(),Itc),a)} + function Utc(a){Ptc();return ws((Xtc(),Wtc),a)} + function auc(a){$tc();return ws((duc(),cuc),a)} + function avc(a){$uc();return ws((dvc(),cvc),a)} + function qvc(a){ovc();return ws((tvc(),svc),a)} + function zvc(a){xvc();return ws((Cvc(),Bvc),a)} + function Ivc(a){Gvc();return ws((Lvc(),Kvc),a)} + function Qvc(a){Ovc();return ws((Tvc(),Svc),a)} + function Quc(a){Ouc();return ws((Tuc(),Suc),a)} + function juc(a){huc();return ws((muc(),luc),a)} + function wuc(a){tuc();return ws((zuc(),yuc),a)} + function Euc(a){Cuc();return ws((Huc(),Guc),a)} + function exc(a){cxc();return ws((hxc(),gxc),a)} + function eDc(a){_Cc();return ws((hDc(),gDc),a)} + function oDc(a){lDc();return ws((rDc(),qDc),a)} + function ADc(a){wDc();return ws((DDc(),CDc),a)} + function ODc(a){JDc();return ws((RDc(),QDc),a)} + function cEc(a){aEc();return ws((fEc(),eEc),a)} + function mEc(a){kEc();return ws((pEc(),oEc),a)} + function uEc(a){sEc();return ws((xEc(),wEc),a)} + function DEc(a){BEc();return ws((GEc(),FEc),a)} + function MEc(a){KEc();return ws((PEc(),OEc),a)} + function VEc(a){TEc();return ws((YEc(),XEc),a)} + function nFc(a){lFc();return ws((qFc(),pFc),a)} + function wFc(a){uFc();return ws((zFc(),yFc),a)} + function FFc(a){DFc();return ws((IFc(),HFc),a)} + function TKc(a){RKc();return ws((WKc(),VKc),a)} + function uNc(a){sNc();return ws((xNc(),wNc),a)} + function yQc(a){wQc();return ws((BQc(),AQc),a)} + function GQc(a){EQc();return ws((JQc(),IQc),a)} + function hTc(a){fTc();return ws((kTc(),jTc),a)} + function fVc(a){dVc();return ws((iVc(),hVc),a)} + function bWc(a){YVc();return ws((eWc(),dWc),a)} + function ZYc(a){WYc();return ws((aZc(),_Yc),a)} + function NZc(a){LZc();return ws((QZc(),PZc),a)} + function u_c(a){s_c();return ws((x_c(),w_c),a)} + function C_c(a){A_c();return ws((F_c(),E_c),a)} + function C2c(a){x2c();return ws((F2c(),E2c),a)} + function j3c(a){g3c();return ws((m3c(),l3c),a)} + function j4c(a){g4c();return ws((m4c(),l4c),a)} + function _3c(a){Y3c();return ws((c4c(),b4c),a)} + function m5c(a){j5c();return ws((p5c(),o5c),a)} + function w5c(a){t5c();return ws((z5c(),y5c),a)} + function h6c(a){f6c();return ws((k6c(),j6c),a)} + function C6c(a){z6c();return ws((F6c(),E6c),a)} + function b7c(a){_6c();return ws((e7c(),d7c),a)} + function E8c(a){z8c();return ws((H8c(),G8c),a)} + function R8b(a){P8b();return ws((U8b(),T8b),a)} + function t3b(a){r3b();return ws((w3b(),v3b),a)} + function g9c(a){b9c();return ws((j9c(),i9c),a)} + function G9c(a){B9c();return ws((J9c(),I9c),a)} + function uad(a){sad();return ws((xad(),wad),a)} + function xbd(a){sbd();return ws((Abd(),zbd),a)} + function ibd(a){gbd();return ws((lbd(),kbd),a)} + function Gbd(a){Cbd();return ws((Jbd(),Ibd),a)} + function Obd(a){Mbd();return ws((Rbd(),Qbd),a)} + function Zbd(a){Xbd();return ws((acd(),_bd),a)} + function fdd(a){_cd();return ws((idd(),hdd),a)} + function qdd(a){ldd();return ws((tdd(),sdd),a)} + function $hd(a){Yhd();return ws((bid(),aid),a)} + function mid(a){kid();return ws((pid(),oid),a)} + function Tjd(a){Rjd();return ws((Wjd(),Vjd),a)} + function wkd(a){ukd();return ws((zkd(),ykd),a)} + function Hmd(a){Cmd();return ws((Kmd(),Jmd),a)} + function Qmd(a){Omd();return ws((Tmd(),Smd),a)} + function $md(a){Ymd();return ws((bnd(),and),a)} + function knd(a){ind();return ws((nnd(),mnd),a)} + function Hnd(a){Fnd();return ws((Knd(),Jnd),a)} + function Snd(a){Pnd();return ws((Vnd(),Und),a)} + function god(a){dod();return ws((jod(),iod),a)} + function rod(a){pod();return ws((uod(),tod),a)} + function Fod(a){Bod();return ws((Iod(),Hod),a)} + function Tod(a){Pod();return ws((Wod(),Vod),a)} + function wpd(a){qpd();return ws((zpd(),ypd),a)} + function Spd(a){Qpd();return ws((Vpd(),Upd),a)} + function fqd(a){dqd();return ws((iqd(),hqd),a)} + function oqd(a){mqd();return ws((rqd(),qqd),a)} + function zsc(a,b){return (uFb(a),a)+(uFb(b),b)} + function wqd(a){uqd();return ws((Eqd(),Dqd),a)} + function Ird(a){Grd();return ws((Lrd(),Krd),a)} + function vtd(a){ttd();return ws((ytd(),xtd),a)} + function dMc(){dMc=geb;bMc=(qpd(),ppd);cMc=Xod;} + function uqd(){uqd=geb;sqd=new zqd;tqd=new Bqd;} + function wJc(a){!a.e&&(a.e=new bnb);return a.e} + function BTc(a,b){this.c=a;this.a=b;this.b=b-a;} + function g8c(a,b,c){this.a=a;this.b=b;this.c=c;} + function gud(a,b,c){this.a=a;this.b=b;this.c=c;} + function Wdd(a,b,c){this.a=a;this.b=b;this.c=c;} + function ced(a,b,c){this.a=a;this.b=b;this.c=c;} + function pFd(a,b,c){this.a=a;this.b=b;this.c=c;} + function ZPd(a,b,c){this.a=a;this.b=b;this.c=c;} + function g7d(a,b,c){this.e=a;this.a=b;this.c=c;} + function K7d(a,b,c){s7d();C7d.call(this,a,b,c);} + function f9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function r9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function x9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function h9d(a,b,c){s7d();f9d.call(this,a,b,c);} + function j9d(a,b,c){s7d();f9d.call(this,a,b,c);} + function l9d(a,b,c){s7d();j9d.call(this,a,b,c);} + function t9d(a,b,c){s7d();r9d.call(this,a,b,c);} + function z9d(a,b,c){s7d();x9d.call(this,a,b,c);} + function S2b(a){J2b.call(this,a.d,a.c,a.a,a.b);} + function B3b(a){J2b.call(this,a.d,a.c,a.a,a.b);} + function Og(a){this.d=a;Lg(this);this.b=ed(a.d);} + function cGd(a){aGd();return ws((fGd(),eGd),a)} + function gk(a,b){Qb(a);Qb(b);return new hk(a,b)} + function dr(a,b){Qb(a);Qb(b);return new mr(a,b)} + function hr(a,b){Qb(a);Qb(b);return new sr(a,b)} + function Dr(a,b){Qb(a);Qb(b);return new Rr(a,b)} + function Uub(a){sFb(a.b!=0);return Wub(a,a.a.a)} + function Vub(a){sFb(a.b!=0);return Wub(a,a.c.b)} + function q$d(a){!a.c&&(a.c=new X9d);return a.c} + function cv(a){var b;b=new bnb;xr(b,a);return b} + function Vx(a){var b;b=new _sb;xr(b,a);return b} + function Yx(a){var b;b=new xAb;_q(b,a);return b} + function gv(a){var b;b=new Yub;_q(b,a);return b} + function RD(a,b){CFb(a==null||QD(a,b));return a} + function Mxb(a,b,c){Axb.call(this,b,c);this.a=a;} + function kB(a,b){this.c=a;this.b=b;this.a=false;} + function hCb(){this.a=';,;';this.b='';this.c='';} + function $Cb(a,b,c){this.b=a;pxb.call(this,b,c);} + function uub(a,b,c){this.c=a;xlb.call(this,b,c);} + function fZb(a,b,c){eZb.call(this,a,b);this.b=c;} + function YEb(a,b,c){VEb(c,0,a,b,c.length,false);} + function JYb(a,b,c,d,e){a.b=b;a.c=c;a.d=d;a.a=e;} + function D2b(a,b,c,d,e){a.d=b;a.c=c;a.a=d;a.b=e;} + function XDb(a,b){if(b){a.b=b;a.a=(LCb(b),b.a);}} + function mFb(a,b){if(!a){throw Adb(new agb(b))}} + function zFb(a,b){if(!a){throw Adb(new dgb(b))}} + function qFb(a,b){if(!a){throw Adb(new zeb(b))}} + function zqc(a,b){mqc();return hgb(a.d.p,b.d.p)} + function T0c(a,b){B0c();return Qfb(a.e.b,b.e.b)} + function U0c(a,b){B0c();return Qfb(a.e.a,b.e.a)} + function Xoc(a,b){return hgb(N3b(a.d),N3b(b.d))} + function Izb(a,b){return !!b&&Jzb(a,b.d)?b:null} + function $lc(a,b){return b==(qpd(),ppd)?a.c:a.d} + function Qdb(a){return Edb(yD(Kdb(a)?Wdb(a):a))} + function Nid(a){return new rjd(a.c+a.b,a.d+a.a)} + function GSd(a){return a!=null&&!mSd(a,aSd,bSd)} + function DSd(a,b){return (JSd(a)<<4|JSd(b))&Bwe} + function Rid(a,b,c,d,e){a.c=b;a.d=c;a.b=d;a.a=e;} + function y8b(a){var b,c;b=a.b;c=a.c;a.b=c;a.c=b;} + function B8b(a){var b,c;c=a.d;b=a.a;a.d=b;a.a=c;} + function u6d(a,b){var c;c=a.c;t6d(a,b);return c} + function Nqd(a,b){b<0?(a.g=-1):(a.g=b);return a} + function kjd(a,b){gjd(a);a.a*=b;a.b*=b;return a} + function hrc(a,b,c){grc.call(this,b,c);this.d=a;} + function PZd(a,b,c){kZd.call(this,a,b);this.c=c;} + function Kfe(a,b,c){kZd.call(this,a,b);this.c=c;} + function zUd(a){yUd();kUd.call(this);this.ci(a);} + function Yee(){ree();Zee.call(this,(YSd(),XSd));} + function Yse(a){Vse();return new Hte(0,a)} + function uke(){uke=geb;tke=(yob(),new mpb(eLe));} + function ux(){ux=geb;new wx((kl(),jl),(Wk(),Vk));} + function ugb(){ugb=geb;tgb=$C(bJ,Nve,17,256,0,1);} + function zUb(){this.b=Kfb(UD(iGd((yVb(),sVb))));} + function Pq(a){this.b=a;this.a=gn(this.b.a).Od();} + function mr(a,b){this.b=a;this.a=b;zl.call(this);} + function sr(a,b){this.a=a;this.b=b;zl.call(this);} + function s_d(a,b,c){this.a=a;N$d.call(this,b,c);} + function n_d(a,b,c){this.a=a;N$d.call(this,b,c);} + function sDd(a,b,c){var d;d=new OC(c);sC(a,b,d);} + function _Eb(a,b,c){var d;d=a[b];a[b]=c;return d} + function UEb(a){var b;b=a.slice();return dD(b,a)} + function SJb(a){var b;b=a.n;return a.a.b+b.d+b.a} + function PKb(a){var b;b=a.n;return a.e.b+b.d+b.a} + function QKb(a){var b;b=a.n;return a.e.a+b.b+b.c} + function rub(a){a.a.b=a.b;a.b.a=a.a;a.a=a.b=null;} + function Mub(a,b){Pub(a,b,a.c.b,a.c);return true} + function w2b(a){if(a.a){return a.a}return R0b(a)} + function NSb(a){HSb();return JGd(a)==vCd(LGd(a))} + function OSb(a){HSb();return LGd(a)==vCd(JGd(a))} + function l_b(a,b){return k_b(a,new eZb(b.a,b.b))} + function xn(a,b){return fn(),ck(a,b),new zy(a,b)} + function fmc(a,b){return a.c=b){throw Adb(new web)}} + function JDb(a,b){return MDb(a,(uFb(b),new JAb(b)))} + function KDb(a,b){return MDb(a,(uFb(b),new LAb(b)))} + function prc(a,b,c){return qrc(a,RD(b,12),RD(c,12))} + function q4b(a){return J3b(),RD(a,12).g.c.length!=0} + function v4b(a){return J3b(),RD(a,12).e.c.length!=0} + function sdc(a,b){Zcc();return Qfb(b.a.o.a,a.a.o.a)} + function d_d(a,b){(b.Bb&QHe)!=0&&!a.a.o&&(a.a.o=b);} + function T3c(a,b){b.Ug("General 'Rotator",1);S3c(a);} + function MCc(a,b,c){b.qf(c,Kfb(UD(Wjb(a.b,c)))*a.a);} + function yid(a,b,c){tid();return xid(a,b)&&xid(a,c)} + function Rod(a){Pod();return !a.Hc(Lod)&&!a.Hc(Nod)} + function Nrc(a){if(a.e){return Src(a.e)}return null} + function Zdb(a){if(Kdb(a)){return ''+a}return GD(a)} + function XNc(a){var b;b=a;while(b.f){b=b.f;}return b} + function HBb(a,b,c){bD(b,0,tCb(b[0],c[0]));return b} + function Gpc(a,b,c,d){var e;e=a.i;e.i=b;e.a=c;e.b=d;} + function C5d(a,b,c,d){XZd.call(this,a,b,c);this.b=d;} + function N3d(a,b,c,d,e){O3d.call(this,a,b,c,d,e,-1);} + function b4d(a,b,c,d,e){c4d.call(this,a,b,c,d,e,-1);} + function Iie(a,b,c,d){PZd.call(this,a,b,c);this.b=d;} + function Xde(a){uId.call(this,a,false);this.a=false;} + function Bqd(){vqd.call(this,'LOOKAHEAD_LAYOUT',1);} + function nNd(a){this.b=a;mMd.call(this,a);mNd(this);} + function vNd(a){this.b=a;BMd.call(this,a);uNd(this);} + function J5d(a,b,c){this.a=a;G5d.call(this,b,c,5,6);} + function wje(a,b,c,d){this.b=a;XZd.call(this,b,c,d);} + function Tj(a,b){this.b=a;Aj.call(this,a.b);this.a=b;} + function NLc(a){this.a=LLc(a.a);this.b=new dnb(a.b);} + function Fx(a,b){tm();Ex.call(this,a,Pm(new mob(b)));} + function _se(a,b){Vse();return new aue(a,b,0)} + function bte(a,b){Vse();return new aue(6,a,b)} + function Ztb(a,b){uFb(b);while(a.Ob()){b.Cd(a.Pb());}} + function Ujb(a,b){return bE(b)?Yjb(a,b):!!qtb(a.f,b)} + function O_d(a,b){return b.Vh()?Vvd(a.b,RD(b,54)):b} + function whb(a,b){return lhb(a.substr(0,b.length),b)} + function Fl(a){return new is(new Il(a.a.length,a.a))} + function Oid(a){return new rjd(a.c+a.b/2,a.d+a.a/2)} + function yD(a){return hD(~a.l&dxe,~a.m&dxe,~a.h&exe)} + function cE(a){return typeof a===gve||typeof a===kve} + function akb(a){a.f=new ttb(a);a.i=new Ntb(a);++a.g;} + function Klb(a){if(!a){throw Adb(new Dvb)}return a.d} + function smb(a){var b;b=omb(a);sFb(b!=null);return b} + function tmb(a){var b;b=pmb(a);sFb(b!=null);return b} + function tv(a,b){var c;c=a.a.gc();Sb(b,c);return c-b} + function Ysb(a,b){var c;c=a.a.zc(b,a);return c==null} + function rAb(a,b){return a.a.zc(b,(Geb(),Eeb))==null} + function _nb(a){return new SDb(null,$nb(a,a.length))} + function yPb(a,b,c){return zPb(a,RD(b,42),RD(c,176))} + function Wrb(a,b,c){zsb(a.a,b);return _Eb(a.b,b.g,c)} + function fyb(a,b,c){lyb(c,a.a.c.length);$mb(a.a,c,b);} + function Knb(a,b,c,d){nFb(b,c,a.length);Onb(a,b,c,d);} + function Onb(a,b,c,d){var e;for(e=b;e0?$wnd.Math.log(a/b):-100} + function Agb(a,b){return Ddb(a,b)<0?-1:Ddb(a,b)>0?1:0} + function Dge(a,b){hZd(a,ZD(b,160)?b:RD(b,2036).Rl());} + function vFb(a,b){if(a==null){throw Adb(new Ogb(b))}} + function $nb(a,b){return jxb(b,a.length),new Gxb(a,b)} + function hsc(a,b){if(!b){return false}return ye(a,b)} + function Gs(){zs();return cD(WC(RG,1),jwe,549,0,[ys])} + function Xib(a){return a.e==0?a:new cjb(-a.e,a.d,a.a)} + function $Nb(a,b){return Qfb(a.c.c+a.c.b,b.c.c+b.c.b)} + function cvb(a,b){Pub(a.d,b,a.b.b,a.b);++a.a;a.c=null;} + function JCb(a,b){!a.c?Rmb(a.b,b):JCb(a.c,b);return a} + function KB(a,b,c){var d;d=JB(a,b);LB(a,b,c);return d} + function Rnb(a,b,c){var d;for(d=0;d=a.g} + function bD(a,b,c){pFb(c==null||VC(a,c));return a[b]=c} + function yhb(a,b){BFb(b,a.length+1);return a.substr(b)} + function yxb(a,b){uFb(b);while(a.c=a){return new rDb}return iDb(a-1)} + function Y2b(a){if(!a.a&&!!a.c){return a.c.b}return a.a} + function Zx(a){if(ZD(a,616)){return a}return new sy(a)} + function LCb(a){if(!a.c){MCb(a);a.d=true;}else {LCb(a.c);}} + function ICb(a){if(!a.c){a.d=true;KCb(a);}else {a.c.$e();}} + function bHb(a){a.b=false;a.c=false;a.d=false;a.a=false;} + function uMc(a){var b,c;b=a.c.i.c;c=a.d.i.c;return b==c} + function _vd(a,b){var c;c=a.Ih(b);c>=0?a.ki(c):Tvd(a,b);} + function mtd(a,b){a.c<0||a.b.b0){a=a<<1|(a<0?1:0);}return a} + function BGc(a,b){var c;c=new R4b(a);ZEb(b.c,c);return c} + function FMb(a,b){a.u.Hc((Pod(),Lod))&&DMb(a,b);HMb(a,b);} + function Fvb(a,b){return dE(a)===dE(b)||a!=null&&pb(a,b)} + function Vrb(a,b){return Bsb(a.a,b)?a.b[RD(b,22).g]:null} + function YRb(){VRb();return cD(WC($O,1),jwe,489,0,[URb])} + function ybd(){sbd();return cD(WC(M1,1),jwe,490,0,[rbd])} + function Hbd(){Cbd();return cD(WC(N1,1),jwe,558,0,[Bbd])} + function gdd(){_cd();return cD(WC(V1,1),jwe,539,0,[$cd])} + function iyd(a){!a.n&&(a.n=new C5d(I4,a,1,7));return a.n} + function wCd(a){!a.c&&(a.c=new C5d(K4,a,9,9));return a.c} + function mzd(a){!a.c&&(a.c=new Yie(E4,a,5,8));return a.c} + function lzd(a){!a.b&&(a.b=new Yie(E4,a,4,7));return a.b} + function Sed(a){a.j.c.length=0;Ae(a.c);sfd(a.a);return a} + function Afe(a){a.e==fLe&&Gfe(a,Aee(a.g,a.b));return a.e} + function Bfe(a){a.f==fLe&&Hfe(a,Bee(a.g,a.b));return a.f} + function xBd(a,b,c,d){wBd(a,b,c,false);j1d(a,d);return a} + function oNd(a,b){this.b=a;nMd.call(this,a,b);mNd(this);} + function wNd(a,b){this.b=a;CMd.call(this,a,b);uNd(this);} + function Kmb(a){this.d=a;this.a=this.d.b;this.b=this.d.c;} + function oy(a,b){this.b=a;this.c=b;this.a=new Osb(this.b);} + function ihb(a,b){BFb(b,a.length);return a.charCodeAt(b)} + function NDd(a,b){CGd(a,Kfb(vDd(b,'x')),Kfb(vDd(b,'y')));} + function $Dd(a,b){CGd(a,Kfb(vDd(b,'x')),Kfb(vDd(b,'y')));} + function CDb(a,b){MCb(a);return new SDb(a,new hEb(b,a.a))} + function GDb(a,b){MCb(a);return new SDb(a,new zEb(b,a.a))} + function HDb(a,b){MCb(a);return new WCb(a,new nEb(b,a.a))} + function IDb(a,b){MCb(a);return new oDb(a,new tEb(b,a.a))} + function Ty(a,b){return new Ry(RD(Qb(a),50),RD(Qb(b),50))} + function nHb(a,b){return Qfb(a.d.c+a.d.b/2,b.d.c+b.d.b/2)} + function gTb(a,b,c){c.a?Eyd(a,b.b-a.f/2):Dyd(a,b.a-a.g/2);} + function WYb(a,b){return Qfb(a.g.c+a.g.b/2,b.g.c+b.g.b/2)} + function RZb(a,b){NZb();return Qfb((uFb(a),a),(uFb(b),b))} + function wSd(a){return a!=null&&tpb(eSd,a.toLowerCase())} + function Ae(a){var b;for(b=a.Kc();b.Ob();){b.Pb();b.Qb();}} + function Ih(a){var b;b=a.b;!b&&(a.b=b=new Xh(a));return b} + function R0b(a){var b;b=Z5b(a);if(b){return b}return null} + function BSb(a,b){var c,d;c=a/b;d=eE(c);c>d&&++d;return d} + function Ck(a,b,c){var d;d=RD(a.d.Kb(c),159);!!d&&d.Nb(b);} + function Vhc(a,b,c){tqc(a.a,c);Jpc(c);Kqc(a.b,c);bqc(b,c);} + function oNc(a,b,c,d){this.a=a;this.c=b;this.b=c;this.d=d;} + function ROc(a,b,c,d){this.c=a;this.b=b;this.a=c;this.d=d;} + function uPc(a,b,c,d){this.c=a;this.b=b;this.d=c;this.a=d;} + function Uid(a,b,c,d){this.c=a;this.d=b;this.b=c;this.a=d;} + function GTc(a,b,c,d){this.a=a;this.d=b;this.c=c;this.b=d;} + function t1b(a,b,c,d){this.a=a;this.e=b;this.d=c;this.c=d;} + function $td(a,b,c,d){this.a=a;this.c=b;this.d=c;this.b=d;} + function ehb(a,b,c){this.a=ywe;this.d=a;this.b=b;this.c=c;} + function fpc(a,b,c,d){qs.call(this,a,b);this.a=c;this.b=d;} + function Uwb(a,b){this.d=(uFb(a),a);this.a=16449;this.c=b;} + function CIc(a){this.a=new bnb;this.e=$C(kE,Nve,53,a,0,2);} + function ELc(a){a.Ug('No crossing minimization',1);a.Vg();} + function Evb(){yz.call(this,'There is no more element.');} + function OEd(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;} + function PEd(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;} + function h7d(a,b,c,d){this.e=a;this.a=b;this.c=c;this.d=d;} + function x7d(a,b,c,d){this.a=a;this.c=b;this.d=c;this.b=d;} + function C8d(a,b,c,d){s7d();M7d.call(this,b,c,d);this.a=a;} + function J8d(a,b,c,d){s7d();M7d.call(this,b,c,d);this.a=a;} + function lwd(a,b,c){var d,e;d=oSd(a);e=b.ti(c,d);return e} + function lBd(a){var b,c;c=(b=new s2d,b);l2d(c,a);return c} + function mBd(a){var b,c;c=(b=new s2d,b);p2d(c,a);return c} + function HDd(a,b){var c;c=Wjb(a.f,b);wEd(b,c);return null} + function uCd(a){!a.b&&(a.b=new C5d(G4,a,12,3));return a.b} + function VD(a){CFb(a==null||cE(a)&&!(a.Tm===keb));return a} + function gz(a){if(a.n){a.e!==rwe&&a.je();a.j=null;}return a} + function Ng(a){ig(a.d);if(a.d.d!=a.c){throw Adb(new Jrb)}} + function Bkb(a){sFb(a.b0&&wPd(this);} + function Vg(a,b){this.a=a;Pg.call(this,a,RD(a.d,15).fd(b));} + function lrd(a,b){return Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function mrd(a,b){return Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function n5b(a){return ozd(a)&&Heb(TD(Gxd(a,(yCc(),OAc))))} + function Sfc(a,b){return Rc(a,RD(mQb(b,(yCc(),tBc)),17),b)} + function lic(a,b){RD(mQb(a,(Ywc(),qwc)),15).Fc(b);return b} + function C2b(a,b){a.b=b.b;a.c=b.c;a.d=b.d;a.a=b.a;return a} + function cEb(a,b,c,d){this.b=a;this.c=d;xxb.call(this,b,c);} + function Ulc(a,b,c){a.i=0;a.e=0;if(b==c){return}Qlc(a,b,c);} + function Vlc(a,b,c){a.i=0;a.e=0;if(b==c){return}Rlc(a,b,c);} + function akc(a,b,c){Wjc();return _Gb(RD(Wjb(a.e,b),529),c)} + function nd(a){var b;return b=a.f,!b?(a.f=new ne(a,a.c)):b} + function nTc(a,b){return VTc(a.j,b.s,b.c)+VTc(b.e,a.s,a.c)} + function Rrc(a,b){if(!!a.e&&!a.e.a){Prc(a.e,b);Rrc(a.e,b);}} + function Qrc(a,b){if(!!a.d&&!a.d.a){Prc(a.d,b);Qrc(a.d,b);}} + function krd(a,b){return -Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function gtd(a){return RD(a.ld(),149).Pg()+':'+jeb(a.md())} + function EBd(){BBd(this,new yAd);this.wb=(lTd(),kTd);jTd();} + function G7b(a){this.b=new bnb;Tmb(this.b,this.b);this.a=a;} + function WWc(a,b){new Yub;this.a=new Ejd;this.b=a;this.c=b;} + function urb(){urb=geb;rrb=new wrb;srb=new wrb;trb=new Brb;} + function yob(){yob=geb;vob=new Job;wob=new apb;xob=new ipb;} + function FGb(){FGb=geb;CGb=new AGb;EGb=new fHb;DGb=new YGb;} + function HSb(){HSb=geb;GSb=new bnb;FSb=new Tsb;ESb=new bnb;} + function Rb(a,b){if(a==null){throw Adb(new Ogb(b))}return a} + function tCd(a){!a.a&&(a.a=new C5d(J4,a,10,11));return a.a} + function uYd(a){!a.q&&(a.q=new C5d(s7,a,11,10));return a.q} + function xYd(a){!a.s&&(a.s=new C5d(y7,a,21,17));return a.s} + function er(a){Qb(a);return Er(new is(Mr(a.a.Kc(),new ir)))} + function hfd(a,b){rb(a);rb(b);return ns(RD(a,22),RD(b,22))} + function qDd(a,b,c){var d,e;d=Qeb(c);e=new hC(d);sC(a,b,e);} + function d4d(a,b,c,d,e,f){c4d.call(this,a,b,c,d,e,f?-2:-1);} + function sje(a,b,c,d){kZd.call(this,b,c);this.b=a;this.a=d;} + function Ry(a,b){wi.call(this,new ezb(a));this.a=a;this.b=b;} + function Gu(a){this.b=a;this.c=a;a.e=null;a.c=null;this.a=1;} + function Dkc(a){lkc();var b;b=RD(a.g,10);b.n.a=a.d.c+b.d.b;} + function fA(){fA=geb;var a,b;b=!lA();a=new tA;eA=b?new mA:a;} + function Hob(a){yob();return ZD(a,59)?new irb(a):new Upb(a)} + function Ux(a){return ZD(a,16)?new btb(RD(a,16)):Vx(a.Kc())} + function Vi(a){return new ij(a,a.e.Rd().gc()*a.c.Rd().gc())} + function fj(a){return new sj(a,a.e.Rd().gc()*a.c.Rd().gc())} + function Iz(a){return !!a&&!!a.hashCode?a.hashCode():kFb(a)} + function Yjb(a,b){return b==null?!!qtb(a.f,null):Jtb(a.i,b)} + function hYb(a,b){var c;c=$sb(a.a,b);c&&(b.d=null);return c} + function MGb(a,b,c){if(a.f){return a.f.ef(b,c)}return false} + function cFc(a,b,c,d){bD(a.c[b.g],c.g,d);bD(a.c[c.g],b.g,d);} + function fFc(a,b,c,d){bD(a.c[b.g],b.g,c);bD(a.b[b.g],b.g,d);} + function sXc(a,b,c){return Kfb(UD(c.a))<=a&&Kfb(UD(c.b))>=b} + function yJc(a,b){this.g=a;this.d=cD(WC(jR,1),WAe,10,0,[b]);} + function lHb(a){this.c=a;this.b=new yAb(RD(Qb(new oHb),50));} + function UYb(a){this.c=a;this.b=new yAb(RD(Qb(new XYb),50));} + function $Qb(a){this.b=a;this.a=new yAb(RD(Qb(new bRb),50));} + function tRc(){this.b=new _sb;this.d=new Yub;this.e=new Fyb;} + function VTb(){this.c=new pjd;this.d=new pjd;this.e=new pjd;} + function a1b(){this.a=new Ejd;this.b=(dk(3,iwe),new cnb(3));} + function i7d(a,b){this.e=a;this.a=jJ;this.b=pje(b);this.c=b;} + function Vid(a){this.c=a.c;this.d=a.d;this.b=a.b;this.a=a.a;} + function VLd(a,b,c,d,e,f){this.a=a;NKd.call(this,b,c,d,e,f);} + function aLd(a,b,c,d,e,f){this.a=a;NKd.call(this,b,c,d,e,f);} + function fge(a,b,c,d,e,f,g){return new lle(a.e,b,c,d,e,f,g)} + function xhb(a,b,c){return c>=0&&lhb(a.substr(c,b.length),b)} + function hGd(a,b){return ZD(b,149)&&lhb(a.b,RD(b,149).Pg())} + function Tde(a,b){return a.a?b.Gh().Kc():RD(b.Gh(),71).Ii()} + function Qqb(a,b){var c;c=a.b.Qc(b);Rqb(c,a.b.gc());return c} + function Ivb(a,b){if(a==null){throw Adb(new Ogb(b))}return a} + function zYd(a){if(!a.u){yYd(a);a.u=new w0d(a,a);}return a.u} + function Kx(a){this.a=(yob(),ZD(a,59)?new irb(a):new Upb(a));} + function Uwd(a){var b;b=RD(Ywd(a,16),29);return !b?a.ii():b} + function lz(a,b){var c;c=nfb(a.Rm);return b==null?c:c+': '+b} + function zhb(a,b,c){AFb(b,c,a.length);return a.substr(b,c-b)} + function VKb(a,b){RJb.call(this);KKb(this);this.a=a;this.c=b;} + function neb(a){!a?vve:lz(a,a.ie());} + function Wz(a){Qz();$wnd.setTimeout(function(){throw a},0);} + function GHb(){DHb();return cD(WC(uN,1),jwe,436,0,[CHb,BHb])} + function OHb(){LHb();return cD(WC(vN,1),jwe,435,0,[JHb,KHb])} + function WUb(){TUb();return cD(WC(BP,1),jwe,432,0,[RUb,SUb])} + function S8b(){P8b();return cD(WC(vS,1),jwe,517,0,[O8b,N8b])} + function Rvc(){Ovc();return cD(WC(lX,1),jwe,429,0,[Mvc,Nvc])} + function buc(){$tc();return cD(WC(cX,1),jwe,428,0,[Ytc,Ztc])} + function mtc(){jtc();return cD(WC($W,1),jwe,431,0,[htc,itc])} + function vEc(){sEc();return cD(WC(xX,1),jwe,430,0,[qEc,rEc])} + function vNc(){sNc();return cD(WC(MY,1),jwe,531,0,[rNc,qNc])} + function D2c(){x2c();return cD(WC(s0,1),jwe,501,0,[v2c,w2c])} + function zQc(){wQc();return cD(WC(FZ,1),jwe,523,0,[vQc,uQc])} + function HQc(){EQc();return cD(WC(GZ,1),jwe,522,0,[CQc,DQc])} + function iTc(){fTc();return cD(WC(b$,1),jwe,528,0,[eTc,dTc])} + function Fuc(){Cuc();return cD(WC(fX,1),jwe,488,0,[Buc,Auc])} + function F8c(){z8c();return cD(WC(l1,1),jwe,491,0,[x8c,y8c])} + function H9c(){B9c();return cD(WC(t1,1),jwe,492,0,[z9c,A9c])} + function D_c(){A_c();return cD(WC(K_,1),jwe,433,0,[z_c,y_c])} + function a4c(){Y3c();return cD(WC(H0,1),jwe,434,0,[W3c,X3c])} + function gVc(){dVc();return cD(WC(w$,1),jwe,465,0,[bVc,cVc])} + function Pbd(){Mbd();return cD(WC(O1,1),jwe,438,0,[Lbd,Kbd])} + function rdd(){ldd();return cD(WC(W1,1),jwe,437,0,[kdd,jdd])} + function xqd(){uqd();return cD(WC(M3,1),jwe,347,0,[sqd,tqd])} + function Jvd(a,b,c,d){return c>=0?a.Uh(b,c,d):a.Ch(null,c,d)} + function ltd(a){if(a.b.b==0){return a.a.sf()}return Uub(a.b)} + function vKd(a){if(a.p!=5)throw Adb(new cgb);return Ydb(a.f)} + function EKd(a){if(a.p!=5)throw Adb(new cgb);return Ydb(a.k)} + function P$d(a){dE(a.a)===dE((lYd(),kYd))&&Q$d(a);return a.a} + function iad(a,b){a.b=b;a.c>0&&a.b>0&&(a.g=Aad(a.c,a.b,a.a));} + function jad(a,b){a.c=b;a.c>0&&a.b>0&&(a.g=Aad(a.c,a.b,a.a));} + function BUc(a,b){yUc(this,new rjd(a.a,a.b));zUc(this,gv(b));} + function Tp(){Sp.call(this,new Usb(Sv(12)));Lb(true);this.a=2;} + function eue(a,b,c){Vse();Wse.call(this,a);this.b=b;this.a=c;} + function C7d(a,b,c){s7d();t7d.call(this,b);this.a=a;this.b=c;} + function qub(a){var b;b=a.c.d.b;a.b=b;a.a=a.c.d;b.a=a.c.d.b=a;} + function Tub(a){return a.b==0?null:(sFb(a.b!=0),Wub(a,a.a.a))} + function Xjb(a,b){return b==null?Wd(qtb(a.f,null)):Ktb(a.i,b)} + function bzb(a,b,c,d,e){return new Kzb(a,(cAb(),aAb),b,c,d,e)} + function Fnb(a,b){oFb(b);return Hnb(a,$C(kE,Pwe,28,b,15,1),b)} + function Tx(a,b){Rb(a,'set1');Rb(b,'set2');return new ey(a,b)} + function Kz(a,b){var c=Jz[a.charCodeAt(0)];return c==null?a:c} + function Xyb(a,b){var c,d;c=b;d=new Gzb;Zyb(a,c,d);return d.d} + function EMb(a,b,c,d){var e;e=new TJb;b.a[c.g]=e;Wrb(a.b,d,e);} + function SXb(a,b){var c;c=BXb(a.f,b);return $id(fjd(c),a.f.d)} + function RFb(a){var b;EJb(a.a);DJb(a.a);b=new PJb(a.a);LJb(b);} + function _Mb(a,b){$Mb(a,true);Umb(a.e.Rf(),new dNb(a,true,b));} + function PSb(a,b){HSb();return a==vCd(JGd(b))||a==vCd(LGd(b))} + function R0c(a,b){B0c();return RD(mQb(b,(h_c(),f_c)),17).a==a} + function eE(a){return Math.max(Math.min(a,lve),-2147483648)|0} + function sy(a){this.a=RD(Qb(a),277);this.b=(yob(),new jrb(a));} + function qbd(a,b,c){this.i=new bnb;this.b=a;this.g=b;this.a=c;} + function had(a,b,c){this.a=new bnb;this.e=a;this.f=b;this.c=c;} + function _9c(a,b,c){this.c=new bnb;this.e=a;this.f=b;this.b=c;} + function TKb(a){RJb.call(this);KKb(this);this.a=a;this.c=true;} + function ieb(a){function b(){} +b.prototype=a||{};return new b} + function zfb(a){if(a.Ae()){return null}var b=a.n;return eeb[b]} + function kzd(a){if(a.Db>>16!=3)return null;return RD(a.Cb,27)} + function MCd(a){if(a.Db>>16!=9)return null;return RD(a.Cb,27)} + function Fzd(a){if(a.Db>>16!=6)return null;return RD(a.Cb,74)} + function dVc(){dVc=geb;bVc=new eVc(Nye,0);cVc=new eVc(Oye,1);} + function wQc(){wQc=geb;vQc=new xQc(Oye,0);uQc=new xQc(Nye,1);} + function EQc(){EQc=geb;CQc=new FQc(Zye,0);DQc=new FQc('UP',1);} + function Is(){Is=geb;Hs=ss((zs(),cD(WC(RG,1),jwe,549,0,[ys])));} + function Wx(a){var b;b=new atb(Sv(a.length));zob(b,a);return b} + function B2b(a,b){a.b+=b.b;a.c+=b.c;a.d+=b.d;a.a+=b.a;return a} + function qmb(a,b){if(kmb(a,b)){Jmb(a);return true}return false} + function qC(a,b){if(b==null){throw Adb(new Ngb)}return rC(a,b)} + function nB(a,b){var c;c=a.q.getHours();a.q.setDate(b);mB(a,c);} + function Xvd(a,b,c){var d;d=a.Ih(b);d>=0?a.bi(d,c):Svd(a,b,c);} + function Lvd(a,b){var c;c=a.Ih(b);return c>=0?a.Wh(c):Rvd(a,b)} + function zo(a,b){var c;Qb(b);for(c=a.a;c;c=c.c){b.Yd(c.g,c.i);}} + function pMc(a,b,c){var d;d=qMc(a,b,c);a.b=new _Lc(d.c.length);} + function HId(a,b,c){EId();!!a&&Zjb(DId,a,b);!!a&&Zjb(CId,a,c);} + function bfc(a,b){Rec();return Geb(),RD(b.a,17).a0} + function sId(a){var b;b=a.d;b=a.bj(a.f);WGd(a,b);return b.Ob()} + function bHd(a,b){var c;c=new Kub(b);Ve(c,a);return new dnb(c)} + function qKd(a){if(a.p!=0)throw Adb(new cgb);return Pdb(a.f,0)} + function zKd(a){if(a.p!=0)throw Adb(new cgb);return Pdb(a.k,0)} + function gBd(a){if(a.Db>>16!=7)return null;return RD(a.Cb,241)} + function xXd(a){if(a.Db>>16!=6)return null;return RD(a.Cb,241)} + function dCd(a){if(a.Db>>16!=7)return null;return RD(a.Cb,167)} + function vCd(a){if(a.Db>>16!=11)return null;return RD(a.Cb,27)} + function uWd(a){if(a.Db>>16!=17)return null;return RD(a.Cb,29)} + function kVd(a){if(a.Db>>16!=3)return null;return RD(a.Cb,155)} + function BDb(a){var b;MCb(a);b=new _sb;return CDb(a,new aEb(b))} + function xfb(a,b){var c=a.a=a.a||[];return c[b]||(c[b]=a.ve(b))} + function qB(a,b){var c;c=a.q.getHours();a.q.setMonth(b);mB(a,c);} + function oz(a,b){ez(this);this.f=b;this.g=a;gz(this);this.je();} + function TQb(a,b){this.a=a;this.c=ajd(this.a);this.b=new Vid(b);} + function aGb(a,b,c){this.a=b;this.c=a;this.b=(Qb(c),new dnb(c));} + function s$b(a,b,c){this.a=b;this.c=a;this.b=(Qb(c),new dnb(c));} + function _Kc(a){this.a=a;this.b=$C(qY,Nve,2043,a.e.length,0,2);} + function fGb(){this.a=new Iub;this.e=new _sb;this.g=0;this.i=0;} + function EId(){EId=geb;DId=new Tsb;CId=new Tsb;IId(zK,new JId);} + function KFc(){KFc=geb;JFc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function RFc(){RFc=geb;QFc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function gGc(){gGc=geb;fGc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function ANc(){ANc=geb;zNc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function dOc(){dOc=geb;cOc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function gQc(){gQc=geb;fQc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function WQc(){WQc=geb;VQc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function dZd(a,b,c,d,e,f){return new P3d(a.e,b,a.Lj(),c,d,e,f)} + function $jb(a,b,c){return b==null?rtb(a.f,null,c):Ltb(a.i,b,c)} + function Y0b(a,b){!!a.c&&Ymb(a.c.g,a);a.c=b;!!a.c&&Rmb(a.c.g,a);} + function g3b(a,b){!!a.c&&Ymb(a.c.a,a);a.c=b;!!a.c&&Rmb(a.c.a,a);} + function P3b(a,b){!!a.i&&Ymb(a.i.j,a);a.i=b;!!a.i&&Rmb(a.i.j,a);} + function Z0b(a,b){!!a.d&&Ymb(a.d.e,a);a.d=b;!!a.d&&Rmb(a.d.e,a);} + function _Sc(a,b){!!a.a&&Ymb(a.a.k,a);a.a=b;!!a.a&&Rmb(a.a.k,a);} + function aTc(a,b){!!a.b&&Ymb(a.b.f,a);a.b=b;!!a.b&&Rmb(a.b.f,a);} + function Odd(a,b){Pdd(a,a.b,a.c);RD(a.b.b,68);!!b&&RD(b.b,68).b;} + function j2c(a,b){return Qfb(RD(a.c,65).c.e.b,RD(b.c,65).c.e.b)} + function k2c(a,b){return Qfb(RD(a.c,65).c.e.a,RD(b.c,65).c.e.a)} + function YXb(a){NXb();return Geb(),RD(a.a,86).d.e!=0?true:false} + function LXd(a,b){ZD(a.Cb,184)&&(RD(a.Cb,184).tb=null);PAd(a,b);} + function CWd(a,b){ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),4);PAd(a,b);} + function _5d(a,b){a6d(a,b);ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),2);} + function JFd(a,b){var c,d;c=b.c;d=c!=null;d&&oDd(a,new OC(b.c));} + function v0d(a){var b,c;c=(jTd(),b=new s2d,b);l2d(c,a);return c} + function E4d(a){var b,c;c=(jTd(),b=new s2d,b);l2d(c,a);return c} + function Fr(a){var b;while(true){b=a.Pb();if(!a.Ob()){return b}}} + function nq(a,b,c){Rmb(a.a,(fn(),ck(b,c),new gp(b,c)));return a} + function rge(a,b){return nke(),wWd(b)?new ole(b,a):new Eke(b,a)} + function ojb(a){Pib();return Ddb(a,0)>=0?jjb(a):Xib(jjb(Odb(a)))} + function Asb(a){var b;b=RD(UEb(a.b),9);return new Fsb(a.a,b,a.c)} + function Qw(a,b){var c;c=RD(Xv(nd(a.a),b),16);return !c?0:c.gc()} + function Zmb(a,b,c){var d;xFb(b,c,a.c.length);d=c-b;$Eb(a.c,b,d);} + function Rkb(a,b,c){xFb(b,c,a.gc());this.c=a;this.a=b;this.b=c-b;} + function fgd(a){this.c=new Yub;this.b=a.b;this.d=a.c;this.a=a.a;} + function qjd(a){this.a=$wnd.Math.cos(a);this.b=$wnd.Math.sin(a);} + function bTc(a,b,c,d){this.c=a;this.d=d;_Sc(this,b);aTc(this,c);} + function Si(a,b){Qi.call(this,new Usb(Sv(a)));dk(b,Mve);this.a=b;} + function Ryb(a,b,c){return new Kzb(a,(cAb(),_zb),null,false,b,c)} + function czb(a,b,c){return new Kzb(a,(cAb(),bAb),b,c,null,false)} + function ABb(){xBb();return cD(WC(QL,1),jwe,108,0,[uBb,vBb,wBb])} + function yLb(){vLb();return cD(WC(TN,1),jwe,472,0,[uLb,tLb,sLb])} + function HKb(){EKb();return cD(WC(MN,1),jwe,471,0,[CKb,BKb,DKb])} + function aKb(){ZJb();return cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])} + function DWb(){AWb();return cD(WC(JP,1),jwe,391,0,[yWb,xWb,zWb])} + function moc(){joc();return cD(WC(UV,1),jwe,372,0,[ioc,hoc,goc])} + function ytc(){stc();return cD(WC(_W,1),jwe,322,0,[qtc,ptc,rtc])} + function Htc(){Etc();return cD(WC(aX,1),jwe,351,0,[Btc,Dtc,Ctc])} + function kuc(){huc();return cD(WC(dX,1),jwe,460,0,[fuc,euc,guc])} + function Avc(){xvc();return cD(WC(jX,1),jwe,299,0,[vvc,wvc,uvc])} + function Jvc(){Gvc();return cD(WC(kX,1),jwe,311,0,[Evc,Fvc,Dvc])} + function pDc(){lDc();return cD(WC(sX,1),jwe,390,0,[iDc,jDc,kDc])} + function EEc(){BEc();return cD(WC(yX,1),jwe,463,0,[AEc,yEc,zEc])} + function NEc(){KEc();return cD(WC(zX,1),jwe,387,0,[HEc,IEc,JEc])} + function WEc(){TEc();return cD(WC(AX,1),jwe,349,0,[SEc,QEc,REc])} + function oFc(){lFc();return cD(WC(CX,1),jwe,350,0,[iFc,jFc,kFc])} + function xFc(){uFc();return cD(WC(DX,1),jwe,352,0,[tFc,rFc,sFc])} + function GFc(){DFc();return cD(WC(EX,1),jwe,388,0,[BFc,CFc,AFc])} + function UKc(){RKc();return cD(WC(nY,1),jwe,464,0,[OKc,PKc,QKc])} + function K3b(a){return xjd(cD(WC(l3,1),Nve,8,0,[a.i.n,a.n,a.a]))} + function OZc(){LZc();return cD(WC(F_,1),jwe,392,0,[KZc,JZc,IZc])} + function H_c(){H_c=geb;G_c=nfd(new ufd,(YVc(),WVc),(WYc(),MYc));} + function A_c(){A_c=geb;z_c=new B_c('DFS',0);y_c=new B_c('BFS',1);} + function TQc(a,b,c){var d;d=new SQc;d.b=b;d.a=c;++b.b;Rmb(a.d,d);} + function NTb(a,b,c){var d;d=new sjd(c.d);$id(d,a);CGd(b,d.a,d.b);} + function Nwb(a,b){Mwb(a,Ydb(Cdb(Tdb(b,24),Pxe)),Ydb(Cdb(b,Pxe)));} + function wFb(a,b){if(a<0||a>b){throw Adb(new veb(cye+a+dye+b))}} + function tFb(a,b){if(a<0||a>=b){throw Adb(new veb(cye+a+dye+b))}} + function BFb(a,b){if(a<0||a>=b){throw Adb(new eib(cye+a+dye+b))}} + function Swb(a,b){this.b=(uFb(a),a);this.a=(b&qxe)==0?b|64|Ove:b;} + function ODb(a){var b;MCb(a);b=(urb(),urb(),srb);return PDb(a,b)} + function R9c(a,b,c){var d;d=S9c(a,b,false);return d.b<=b&&d.a<=c} + function h9c(){b9c();return cD(WC(o1,1),jwe,439,0,[$8c,a9c,_8c])} + function c7c(){_6c();return cD(WC(a1,1),jwe,394,0,[Z6c,$6c,Y6c])} + function i6c(){f6c();return cD(WC(V0,1),jwe,445,0,[c6c,d6c,e6c])} + function D6c(){z6c();return cD(WC(Z0,1),jwe,456,0,[w6c,y6c,x6c])} + function k4c(){g4c();return cD(WC(I0,1),jwe,393,0,[d4c,e4c,f4c])} + function x5c(){t5c();return cD(WC(N0,1),jwe,300,0,[r5c,s5c,q5c])} + function Ind(){Fnd();return cD(WC(y3,1),jwe,346,0,[Dnd,Cnd,End])} + function jbd(){gbd();return cD(WC(I1,1),jwe,444,0,[dbd,ebd,fbd])} + function Rmd(){Omd();return cD(WC(t3,1),jwe,278,0,[Lmd,Mmd,Nmd])} + function pqd(){mqd();return cD(WC(J3,1),jwe,280,0,[kqd,jqd,lqd])} + function bv(a){Qb(a);return ZD(a,16)?new dnb(RD(a,16)):cv(a.Kc())} + function Hz(a,b){return !!a&&!!a.equals?a.equals(b):dE(a)===dE(b)} + function Cdb(a,b){return Edb(tD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function Rdb(a,b){return Edb(zD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function $db(a,b){return Edb(HD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function xs(a,b){var c;c=(uFb(a),a).g;lFb(!!c);uFb(b);return c(b)} + function rv(a,b){var c,d;d=tv(a,b);c=a.a.fd(d);return new Gv(a,c)} + function CXd(a){if(a.Db>>16!=6)return null;return RD(yvd(a),241)} + function sKd(a){if(a.p!=2)throw Adb(new cgb);return Ydb(a.f)&Bwe} + function BKd(a){if(a.p!=2)throw Adb(new cgb);return Ydb(a.k)&Bwe} + function ynb(a){sFb(a.ad?1:0} + function Hmc(a,b){var c,d;c=Gmc(b);d=c;return RD(Wjb(a.c,d),17).a} + function CMc(a,b,c){var d;d=a.d[b.p];a.d[b.p]=a.d[c.p];a.d[c.p]=d;} + function Jqd(a,b,c){var d;if(a.n&&!!b&&!!c){d=new otd;Rmb(a.e,d);}} + function gYb(a,b){Ysb(a.a,b);if(b.d){throw Adb(new yz(jye))}b.d=a;} + function Had(a,b){this.a=new bnb;this.d=new bnb;this.f=a;this.c=b;} + function RWb(){this.c=new dXb;this.a=new I_b;this.b=new E0b;g0b();} + function med(){hed();this.b=new Tsb;this.a=new Tsb;this.c=new bnb;} + function KKd(a,b,c){this.d=a;this.j=b;this.e=c;this.o=-1;this.p=3;} + function LKd(a,b,c){this.d=a;this.k=b;this.f=c;this.o=-1;this.p=5;} + function S3d(a,b,c,d,e,f){R3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function U3d(a,b,c,d,e,f){T3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function W3d(a,b,c,d,e,f){V3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function Y3d(a,b,c,d,e,f){X3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function $3d(a,b,c,d,e,f){Z3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function a4d(a,b,c,d,e,f){_3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function f4d(a,b,c,d,e,f){e4d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function h4d(a,b,c,d,e,f){g4d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function N7d(a,b,c,d){t7d.call(this,c);this.b=a;this.c=b;this.d=d;} + function mfe(a,b){this.f=a;this.a=(ree(),pee);this.c=pee;this.b=b;} + function Jfe(a,b){this.g=a;this.d=(ree(),qee);this.a=qee;this.b=b;} + function Gme(a,b){!a.c&&(a.c=new Uge(a,0));Fge(a.c,(nme(),fme),b);} + function Oge(a,b){return Pge(a,b,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function lB(a,b){return Agb(Hdb(a.q.getTime()),Hdb(b.q.getTime()))} + function gj(a){return fk(a.e.Rd().gc()*a.c.Rd().gc(),16,new qj(a))} + function CYd(a){return !!a.u&&tYd(a.u.a).i!=0&&!(!!a.n&&d$d(a.n))} + function p4d(a){return !!a.a&&o4d(a.a.a).i!=0&&!(!!a.b&&o5d(a.b))} + function Cxd(a,b){if(b==0){return !!a.o&&a.o.f!=0}return Kvd(a,b)} + function Cc(a,b,c){var d;d=RD(a.Zb().xc(b),16);return !!d&&d.Hc(c)} + function Gc(a,b,c){var d;d=RD(a.Zb().xc(b),16);return !!d&&d.Mc(c)} + function _yb(a,b){var c;c=1-b;a.a[c]=azb(a.a[c],c);return azb(a,b)} + function DFb(a,b){var c,d;d=Cdb(a,yxe);c=Sdb(b,32);return Rdb(c,d)} + function bGb(a,b,c){var d;d=(Qb(a),new dnb(a));_Fb(new aGb(d,b,c));} + function t$b(a,b,c){var d;d=(Qb(a),new dnb(a));r$b(new s$b(d,b,c));} + function vBd(a,b,c,d,e,f){wBd(a,b,c,f);EYd(a,d);FYd(a,e);return a} + function Xhb(a,b,c,d){a.a+=''+zhb(b==null?vve:jeb(b),c,d);return a} + function Jkb(a,b){this.a=a;Dkb.call(this,a);wFb(b,a.gc());this.b=b;} + function xmb(a){this.a=$C(jJ,rve,1,mgb($wnd.Math.max(8,a))<<1,5,1);} + function t2b(a){return RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199)} + function s2b(a){return RD(anb(a,$C(WQ,VAe,18,a.c.length,0,1)),483)} + function Iyb(a){return !a.a?a.c:a.e.length==0?a.a.a:a.a.a+(''+a.e)} + function Rib(a){while(a.d>0&&a.a[--a.d]==0);a.a[a.d++]==0&&(a.e=0);} + function fvb(a){sFb(a.b.b!=a.d.a);a.c=a.b=a.b.b;--a.a;return a.c.c} + function sRc(a,b,c){a.a=b;a.c=c;a.b.a.$b();Xub(a.d);aFb(a.e.a.c,0);} + function Z5c(a,b){var c;a.e=new R5c;c=Q2c(b);_mb(c,a.c);$5c(a,c,0);} + function zgd(a,b,c,d){var e;e=new Hgd;e.a=b;e.b=c;e.c=d;Mub(a.a,e);} + function Agd(a,b,c,d){var e;e=new Hgd;e.a=b;e.b=c;e.c=d;Mub(a.b,e);} + function Tb(a,b,c){if(a<0||bc){throw Adb(new veb(Kb(a,b,c)))}} + function Pb(a,b){if(a<0||a>=b){throw Adb(new veb(Ib(a,b)))}return a} + function qz(b){if(!('stack' in b)){try{throw b}catch(a){}}return b} + function Zjc(a){Wjc();if(ZD(a.g,10)){return RD(a.g,10)}return null} + function nx(a){if(Ih(a).dc()){return false}Jh(a,new rx);return true} + function Xdb(a){var b;if(Kdb(a)){b=a;return b==-0.?0:b}return ED(a)} + function lkb(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function gsb(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function vub(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function RCb(a){var b;LCb(a);b=new Prb;ixb(a.a,new fDb(b));return b} + function Vae(){var a,b,c;b=(c=(a=new s2d,a),c);Rmb(Rae,b);return b} + function mDb(a){var b;LCb(a);b=new ltb;ixb(a.a,new uDb(b));return b} + function jDb(a,b){if(a.a<=a.b){b.Dd(a.a++);return true}return false} + function xzb(a){yzb.call(this,a,(cAb(),$zb),null,false,null,false);} + function $Rb(){$Rb=geb;ZRb=ss((VRb(),cD(WC($O,1),jwe,489,0,[URb])));} + function CHc(){CHc=geb;BHc=yx(sgb(1),sgb(4));AHc=yx(sgb(1),sgb(2));} + function yXc(a,b){return new gud(b,njd(ajd(b.e),a,a),(Geb(),true))} + function fv(a){return new cnb((dk(a,lwe),dz(Bdb(Bdb(5,a),a/10|0))))} + function Wi(a){return fk(a.e.Rd().gc()*a.c.Rd().gc(),273,new kj(a))} + function u2b(a){return RD(anb(a,$C(xR,XAe,12,a.c.length,0,1)),2042)} + function COc(a){dOc();return !W0b(a)&&!(!W0b(a)&&a.c.i.c==a.d.i.c)} + function Y_c(a,b){R_c();return RD(mQb(b,(h_c(),W$c)),17).a>=a.gc()} + function q8b(a,b){w8b(b,a);y8b(a.d);y8b(RD(mQb(a,(yCc(),cBc)),214));} + function r8b(a,b){z8b(b,a);B8b(a.d);B8b(RD(mQb(a,(yCc(),cBc)),214));} + function $0b(a,b,c){!!a.d&&Ymb(a.d.e,a);a.d=b;!!a.d&&Qmb(a.d.e,c,a);} + function jPb(a,b,c){return c.f.c.length>0?yPb(a.a,b,c):yPb(a.b,b,c)} + function Uz(a,b,c){var d;d=Sz();try{return Rz(a,b,c)}finally{Vz(d);}} + function wDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=c.pe());return d} + function yDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=c.se());return d} + function xDd(a,b){var c,d;c=JB(a,b);d=null;!!c&&(d=c.se());return d} + function zDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=ADd(c));return d} + function rEd(a,b,c){var d;d=uDd(c);Do(a.g,d,b);Do(a.i,b,c);return b} + function UIc(a,b,c){this.d=new fJc(this);this.e=a;this.i=b;this.f=c;} + function Mk(a,b,c,d){this.e=null;this.c=a;this.d=b;this.a=c;this.b=d;} + function urc(a,b,c,d){nrc(this);this.c=a;this.e=b;this.f=c;this.b=d;} + function MKd(a,b,c,d){this.d=a;this.n=b;this.g=c;this.o=d;this.p=-1;} + function Vc(a,b,c,d){return ZD(c,59)?new Kg(a,b,c,d):new yg(a,b,c,d)} + function gr(a){if(ZD(a,16)){return RD(a,16).dc()}return !a.Kc().Ob()} + function Wo(a){if(a.e.g!=a.b){throw Adb(new Jrb)}return !!a.c&&a.d>0} + function evb(a){sFb(a.b!=a.d.c);a.c=a.b;a.b=a.b.a;++a.a;return a.c.c} + function imb(a,b){uFb(b);bD(a.a,a.c,b);a.c=a.c+1&a.a.length-1;mmb(a);} + function hmb(a,b){uFb(b);a.b=a.b-1&a.a.length-1;bD(a.a,a.b,b);mmb(a);} + function _je(a){var b;b=a.Gh();this.a=ZD(b,71)?RD(b,71).Ii():b.Kc();} + function px(a){return new Swb(Dob(RD(a.a.md(),16).gc(),a.a.ld()),16)} + function Abd(){Abd=geb;zbd=ss((sbd(),cD(WC(M1,1),jwe,490,0,[rbd])));} + function Jbd(){Jbd=geb;Ibd=ss((Cbd(),cD(WC(N1,1),jwe,558,0,[Bbd])));} + function idd(){idd=geb;hdd=ss((_cd(),cD(WC(V1,1),jwe,539,0,[$cd])));} + function X$b(){U$b();return cD(WC(CQ,1),jwe,389,0,[T$b,R$b,Q$b,S$b])} + function hAb(){cAb();return cD(WC(AL,1),jwe,304,0,[$zb,_zb,aAb,bAb])} + function LPb(){IPb();return cD(WC(DO,1),jwe,332,0,[FPb,EPb,GPb,HPb])} + function LRb(){IRb();return cD(WC(WO,1),jwe,406,0,[FRb,ERb,GRb,HRb])} + function pOb(){mOb();return cD(WC(hO,1),jwe,417,0,[lOb,iOb,jOb,kOb])} + function uZb(){nZb();return cD(WC(lQ,1),jwe,416,0,[jZb,mZb,kZb,lZb])} + function hnc(){enc();return cD(WC(LV,1),jwe,421,0,[anc,bnc,cnc,dnc])} + function zec(){vec();return cD(WC(qT,1),jwe,371,0,[uec,sec,tec,rec])} + function BDc(){wDc();return cD(WC(tX,1),jwe,203,0,[uDc,vDc,tDc,sDc])} + function nEc(){kEc();return cD(WC(wX,1),jwe,284,0,[hEc,gEc,iEc,jEc])} + function Unc(a){var b;return a.j==(qpd(),npd)&&(b=Vnc(a),Csb(b,Xod))} + function qhc(a,b){var c;c=b.a;Y0b(c,b.c.d);Z0b(c,b.d.d);Cjd(c.a,a.n);} + function _5b(a,b){var c;c=RD(cub(a.b,b),67);!c&&(c=new Yub);return c} + function $jc(a){Wjc();if(ZD(a.g,154)){return RD(a.g,154)}return null} + function gRc(a){a.a=null;a.e=null;aFb(a.b.c,0);aFb(a.f.c,0);a.c=null;} + function Ovc(){Ovc=geb;Mvc=new Pvc(Kye,0);Nvc=new Pvc('TOP_LEFT',1);} + function sNc(){sNc=geb;rNc=new tNc('UPPER',0);qNc=new tNc('LOWER',1);} + function nWc(a,b){return cjd(new rjd(b.e.a+b.f.a/2,b.e.b+b.f.b/2),a)} + function wqc(a,b){return RD(Lvb(JDb(RD(Qc(a.k,b),15).Oc(),lqc)),113)} + function xqc(a,b){return RD(Lvb(KDb(RD(Qc(a.k,b),15).Oc(),lqc)),113)} + function cWc(){YVc();return cD(WC(H$,1),jwe,405,0,[UVc,VVc,WVc,XVc])} + function v_c(){s_c();return cD(WC(J_,1),jwe,353,0,[r_c,p_c,q_c,o_c])} + function n5c(){j5c();return cD(WC(M0,1),jwe,354,0,[i5c,g5c,h5c,f5c])} + function Tpd(){Qpd();return cD(WC(H3,1),jwe,386,0,[Opd,Ppd,Npd,Mpd])} + function Tnd(){Pnd();return cD(WC(z3,1),jwe,291,0,[Ond,Lnd,Mnd,Nnd])} + function _md(){Ymd();return cD(WC(u3,1),jwe,223,0,[Xmd,Vmd,Umd,Wmd])} + function Jrd(){Grd();return cD(WC(R3,1),jwe,320,0,[Frd,Crd,Erd,Drd])} + function wtd(){ttd();return cD(WC(n4,1),jwe,415,0,[qtd,rtd,ptd,std])} + function GId(a){EId();return Ujb(DId,a)?RD(Wjb(DId,a),341).Qg():null} + function Avd(a,b,c){return b<0?Rvd(a,c):RD(c,69).wk().Bk(a,a.hi(),b)} + function sEd(a,b,c){var d;d=uDd(c);Do(a.j,d,b);Zjb(a.k,b,c);return b} + function qEd(a,b,c){var d;d=uDd(c);Do(a.d,d,b);Zjb(a.e,b,c);return b} + function DGd(a){var b,c;b=(bvd(),c=new rzd,c);!!a&&pzd(b,a);return b} + function WHd(a){var b;b=a.aj(a.i);a.i>0&&hib(a.g,0,b,0,a.i);return b} + function Led(a,b){var c;for(c=a.j.c.length;c>24} + function AKd(a){if(a.p!=1)throw Adb(new cgb);return Ydb(a.k)<<24>>24} + function GKd(a){if(a.p!=7)throw Adb(new cgb);return Ydb(a.k)<<16>>16} + function xKd(a){if(a.p!=7)throw Adb(new cgb);return Ydb(a.f)<<16>>16} + function Wib(a,b){if(b.e==0||a.e==0){return Oib}return Ljb(),Mjb(a,b)} + function Nd(a,b){return dE(b)===dE(a)?'(this Map)':b==null?vve:jeb(b)} + function MFb(a,b,c){return Jfb(UD(Wd(qtb(a.f,b))),UD(Wd(qtb(a.f,c))))} + function wkc(a,b,c){var d;d=RD(Wjb(a.g,c),60);Rmb(a.a.c,new Ptd(b,d));} + function Slc(a,b,c){a.i=0;a.e=0;if(b==c){return}Rlc(a,b,c);Qlc(a,b,c);} + function rTc(a,b,c,d,e){var f;f=mTc(e,c,d);Rmb(b,TSc(e,f));vTc(a,e,b);} + function Jrc(a,b,c,d,e){this.i=a;this.a=b;this.e=c;this.j=d;this.f=e;} + function iUb(a,b){VTb.call(this);this.a=a;this.b=b;Rmb(this.a.b,this);} + function rTb(a){this.b=new Tsb;this.c=new Tsb;this.d=new Tsb;this.a=a;} + function Dx(a,b){var c;c=new cib;a.Gd(c);c.a+='..';b.Hd(c);return c.a} + function Fsd(a,b){var c;c=b;while(c){Zid(a,c.i,c.j);c=vCd(c);}return a} + function pEd(a,b,c){var d;d=uDd(c);Zjb(a.b,d,b);Zjb(a.c,b,c);return b} + function Kr(a){var b;b=0;while(a.Ob()){a.Pb();b=Bdb(b,1);}return dz(b)} + function oke(a,b){nke();var c;c=RD(a,69).vk();K6d(c,b);return c.xl(b)} + function tC(d,a,b){if(b){var c=b.oe();d.a[a]=c(b);}else {delete d.a[a];}} + function tB(a,b){var c;c=a.q.getHours();a.q.setFullYear(b+Owe);mB(a,c);} + function KSd(a,b){return RD(b==null?Wd(qtb(a.f,null)):Ktb(a.i,b),288)} + function hOc(a,b){return a==(r3b(),p3b)&&b==p3b?4:a==p3b||b==p3b?8:32} + function cge(a,b,c){return dge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function jge(a,b,c){return kge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function Qge(a,b,c){return Rge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function jmb(a){if(a.b==a.c){return}a.a=$C(jJ,rve,1,8,5,1);a.b=0;a.c=0;} + function Nsb(a){sFb(a.a=0&&a.a[c]===b[c];c--);return c<0} + function Xx(a){var b;if(a){return new Kub(a)}b=new Iub;_q(b,a);return b} + function nmc(a,b){var c,d;d=false;do{c=qmc(a,b);d=d|c;}while(c);return d} + function Vz(a){a&&aA(($z(),Zz));--Nz;if(a){if(Pz!=-1){Xz(Pz);Pz=-1;}}} + function Pwb(a){Hwb();Mwb(this,Ydb(Cdb(Tdb(a,24),Pxe)),Ydb(Cdb(a,Pxe)));} + function IHb(){IHb=geb;HHb=ss((DHb(),cD(WC(uN,1),jwe,436,0,[CHb,BHb])));} + function QHb(){QHb=geb;PHb=ss((LHb(),cD(WC(vN,1),jwe,435,0,[JHb,KHb])));} + function YUb(){YUb=geb;XUb=ss((TUb(),cD(WC(BP,1),jwe,432,0,[RUb,SUb])));} + function U8b(){U8b=geb;T8b=ss((P8b(),cD(WC(vS,1),jwe,517,0,[O8b,N8b])));} + function Tvc(){Tvc=geb;Svc=ss((Ovc(),cD(WC(lX,1),jwe,429,0,[Mvc,Nvc])));} + function duc(){duc=geb;cuc=ss(($tc(),cD(WC(cX,1),jwe,428,0,[Ytc,Ztc])));} + function Huc(){Huc=geb;Guc=ss((Cuc(),cD(WC(fX,1),jwe,488,0,[Buc,Auc])));} + function xEc(){xEc=geb;wEc=ss((sEc(),cD(WC(xX,1),jwe,430,0,[qEc,rEc])));} + function xNc(){xNc=geb;wNc=ss((sNc(),cD(WC(MY,1),jwe,531,0,[rNc,qNc])));} + function otc(){otc=geb;ntc=ss((jtc(),cD(WC($W,1),jwe,431,0,[htc,itc])));} + function F_c(){F_c=geb;E_c=ss((A_c(),cD(WC(K_,1),jwe,433,0,[z_c,y_c])));} + function F2c(){F2c=geb;E2c=ss((x2c(),cD(WC(s0,1),jwe,501,0,[v2c,w2c])));} + function BQc(){BQc=geb;AQc=ss((wQc(),cD(WC(FZ,1),jwe,523,0,[vQc,uQc])));} + function JQc(){JQc=geb;IQc=ss((EQc(),cD(WC(GZ,1),jwe,522,0,[CQc,DQc])));} + function kTc(){kTc=geb;jTc=ss((fTc(),cD(WC(b$,1),jwe,528,0,[eTc,dTc])));} + function iVc(){iVc=geb;hVc=ss((dVc(),cD(WC(w$,1),jwe,465,0,[bVc,cVc])));} + function c4c(){c4c=geb;b4c=ss((Y3c(),cD(WC(H0,1),jwe,434,0,[W3c,X3c])));} + function H8c(){H8c=geb;G8c=ss((z8c(),cD(WC(l1,1),jwe,491,0,[x8c,y8c])));} + function J9c(){J9c=geb;I9c=ss((B9c(),cD(WC(t1,1),jwe,492,0,[z9c,A9c])));} + function Rbd(){Rbd=geb;Qbd=ss((Mbd(),cD(WC(O1,1),jwe,438,0,[Lbd,Kbd])));} + function tdd(){tdd=geb;sdd=ss((ldd(),cD(WC(W1,1),jwe,437,0,[kdd,jdd])));} + function Eqd(){Eqd=geb;Dqd=ss((uqd(),cD(WC(M3,1),jwe,347,0,[sqd,tqd])));} + function Imd(){Cmd();return cD(WC(s3,1),jwe,88,0,[Amd,zmd,ymd,xmd,Bmd])} + function xpd(){qpd();return cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])} + function LSd(a,b,c){return RD(b==null?rtb(a.f,null,c):Ltb(a.i,b,c),288)} + function L6b(a){return (a.k==(r3b(),p3b)||a.k==m3b)&&nQb(a,(Ywc(),cwc))} + function bUb(a){return !!a.c&&!!a.d?kUb(a.c)+'->'+kUb(a.d):'e_'+kFb(a)} + function xgb(a,b){var c,d;uFb(b);for(d=a.Kc();d.Ob();){c=d.Pb();b.Cd(c);}} + function jEd(a,b){var c;c=new uC;qDd(c,'x',b.a);qDd(c,'y',b.b);oDd(a,c);} + function mEd(a,b){var c;c=new uC;qDd(c,'x',b.a);qDd(c,'y',b.b);oDd(a,c);} + function Gsd(a,b){var c;c=b;while(c){Zid(a,-c.i,-c.j);c=vCd(c);}return a} + function ZLc(a,b){var c,d;c=b;d=0;while(c>0){d+=a.a[c];c-=c&-c;}return d} + function $mb(a,b,c){var d;d=(tFb(b,a.c.length),a.c[b]);a.c[b]=c;return d} + function uIc(a,b,c){a.a.c.length=0;yIc(a,b,c);a.a.c.length==0||rIc(a,b);} + function wo(a){a.i=0;Mnb(a.b,null);Mnb(a.c,null);a.a=null;a.e=null;++a.g;} + function gBb(){gBb=geb;dBb=true;bBb=false;cBb=false;fBb=false;eBb=false;} + function oBb(a){gBb();if(dBb){return}this.c=a;this.e=true;this.a=new bnb;} + function kDb(a,b){this.c=0;this.b=b;txb.call(this,a,17493);this.a=this.c;} + function S_b(a){P_b();A$b(this);this.a=new Yub;Q_b(this,a);Mub(this.a,a);} + function m_b(){Pmb(this);this.b=new rjd(oxe,oxe);this.a=new rjd(pxe,pxe);} + function z8c(){z8c=geb;x8c=new B8c(CBe,0);y8c=new B8c('TARGET_WIDTH',1);} + function yDb(a,b){return (MCb(a),QDb(new SDb(a,new hEb(b,a.a)))).Bd(wDb)} + function vXb(){sXb();return cD(WC(UP,1),jwe,367,0,[nXb,oXb,pXb,qXb,rXb])} + function Fnc(){Bnc();return cD(WC(TV,1),jwe,375,0,[xnc,znc,Anc,ync,wnc])} + function Vtc(){Ptc();return cD(WC(bX,1),jwe,348,0,[Ltc,Ktc,Ntc,Otc,Mtc])} + function PDc(){JDc();return cD(WC(uX,1),jwe,323,0,[IDc,FDc,GDc,EDc,HDc])} + function fxc(){cxc();return cD(WC(mX,1),jwe,171,0,[bxc,Zwc,$wc,_wc,axc])} + function k3c(){g3c();return cD(WC(x0,1),jwe,368,0,[e3c,b3c,f3c,c3c,d3c])} + function vad(){sad();return cD(WC(x1,1),jwe,373,0,[oad,nad,qad,pad,rad])} + function $bd(){Xbd();return cD(WC(P1,1),jwe,324,0,[Sbd,Tbd,Wbd,Ubd,Vbd])} + function _hd(){Yhd();return cD(WC(d3,1),jwe,170,0,[Whd,Vhd,Thd,Xhd,Uhd])} + function sod(){pod();return cD(WC(B3,1),jwe,256,0,[mod,ood,kod,lod,nod])} + function Tz(b){Qz();return function(){return Uz(b,this,arguments);}} + function W0b(a){if(!a.c||!a.d){return false}return !!a.c.i&&a.c.i==a.d.i} + function Nfd(a,b){if(ZD(b,143)){return lhb(a.c,RD(b,143).c)}return false} + function yYd(a){if(!a.t){a.t=new w$d(a);VGd(new Cde(a),0,a.t);}return a.t} + function jNd(a){this.b=a;dMd.call(this,a);this.a=RD(Ywd(this.b.a,4),129);} + function sNd(a){this.b=a;yMd.call(this,a);this.a=RD(Ywd(this.b.a,4),129);} + function Q3d(a,b,c,d,e){OKd.call(this,b,d,e);this.c=a;this.b=c;} + function V3d(a,b,c,d,e){KKd.call(this,b,d,e);this.c=a;this.a=c;} + function Z3d(a,b,c,d,e){LKd.call(this,b,d,e);this.c=a;this.a=c;} + function g4d(a,b,c,d,e){OKd.call(this,b,d,e);this.c=a;this.a=c;} + function ugd(a,b){var c;c=RD(cub(a.d,b),23);return c?c:RD(cub(a.e,b),23)} + function Blb(a,b){var c,d;c=b.ld();d=a.Fe(c);return !!d&&Fvb(d.e,b.md())} + function me(a,b){var c;c=b.ld();return new gp(c,a.e.pc(c,RD(b.md(),16)))} + function ptb(a,b){var c;c=a.a.get(b);return c==null?$C(jJ,rve,1,0,5,1):c} + function khb(a){var b;b=a.length;return lhb(sxe.substr(sxe.length-b,b),a)} + function hs(a){if(gs(a)){a.c=a.a;return a.a.Pb()}else {throw Adb(new Dvb)}} + function $ib(a,b){if(b==0||a.e==0){return a}return b>0?tjb(a,b):qjb(a,-b)} + function Zib(a,b){if(b==0||a.e==0){return a}return b>0?qjb(a,b):tjb(a,-b)} + function Deb(a){Beb.call(this,a==null?vve:jeb(a),ZD(a,82)?RD(a,82):null);} + function Y5d(a){var b;if(!a.c){b=a.r;ZD(b,90)&&(a.c=RD(b,29));}return a.c} + function s0b(a){var b;b=new a1b;kQb(b,a);pQb(b,(yCc(),RAc),null);return b} + function lec(a){var b,c;b=a.c.i;c=a.d.i;return b.k==(r3b(),m3b)&&c.k==m3b} + function fD(a){var b,c,d;b=a&dxe;c=a>>22&dxe;d=a<0?exe:0;return hD(b,c,d)} + function Ky(a){var b,c,d,e;for(c=a,d=0,e=c.length;d=0?a.Lh(d,c,true):Qvd(a,b,c)} + function AXc(a,b,c){return Qfb(cjd(jWc(a),ajd(b.b)),cjd(jWc(a),ajd(c.b)))} + function BXc(a,b,c){return Qfb(cjd(jWc(a),ajd(b.e)),cjd(jWc(a),ajd(c.e)))} + function Kad(a,b){return $wnd.Math.min(bjd(b.a,a.d.d.c),bjd(b.b,a.d.d.c))} + function LHd(a,b){a._i(a.i+1);MHd(a,a.i,a.Zi(a.i,b));a.Mi(a.i++,b);a.Ni();} + function OHd(a){var b,c;++a.j;b=a.g;c=a.i;a.g=null;a.i=0;a.Oi(c,b);a.Ni();} + function yke(a,b,c){var d;d=new zke(a.a);Ld(d,a.a.a);rtb(d.f,b,c);a.a.a=d;} + function mKb(a,b,c,d){var e;for(e=0;eb){throw Adb(new veb(Jb(a,b,'index')))}return a} + function Xmb(a,b){var c;c=(tFb(b,a.c.length),a.c[b]);$Eb(a.c,b,1);return c} + function jhb(a,b){var c,d;c=(uFb(a),a);d=(uFb(b),b);return c==d?0:cb.p){return -1}return 0} + function hXd(a){var b;if(!a.a){b=a.r;ZD(b,156)&&(a.a=RD(b,156));}return a.a} + function iOd(a,b,c){var d;++a.e;--a.f;d=RD(a.d[b].gd(c),136);return d.md()} + function fd(a){var b,c;b=a.ld();c=RD(a.md(),16);return gk(c.Nc(),new jh(b))} + function oae(a,b){if(Ujb(a.a,b)){_jb(a.a,b);return true}else {return false}} + function Ui(a,b,c){Pb(b,a.e.Rd().gc());Pb(c,a.c.Rd().gc());return a.a[b][c]} + function _Uc(a,b,c){this.a=a;this.b=b;this.c=c;Rmb(a.t,this);Rmb(b.i,this);} + function lg(a,b,c,d){this.f=a;this.e=b;this.d=c;this.b=d;this.c=!d?null:d.d;} + function YWc(){this.b=new Yub;this.a=new Yub;this.b=new Yub;this.a=new Yub;} + function ree(){ree=geb;var a,b;pee=(jTd(),b=new k1d,b);qee=(a=new mXd,a);} + function UCb(a){var b;MCb(a);b=new $Cb(a,a.a.e,a.a.d|4);return new WCb(a,b)} + function ADb(a){var b;LCb(a);b=0;while(a.a.Bd(new MEb)){b=Bdb(b,1);}return b} + function zxb(a,b){uFb(b);if(a.c=0,'Initial capacity must not be negative');} + function rid(){rid=geb;qid=new jGd('org.eclipse.elk.labels.labelManager');} + function iec(){iec=geb;hec=new kGd('separateLayerConnections',(vec(),uec));} + function fTc(){fTc=geb;eTc=new gTc('REGULAR',0);dTc=new gTc('CRITICAL',1);} + function Mbd(){Mbd=geb;Lbd=new Nbd('FIXED',0);Kbd=new Nbd('CENTER_NODE',1);} + function jtc(){jtc=geb;htc=new ktc('QUADRATIC',0);itc=new ktc('SCANLINE',1);} + function Atc(){Atc=geb;ztc=ss((stc(),cD(WC(_W,1),jwe,322,0,[qtc,ptc,rtc])));} + function Jtc(){Jtc=geb;Itc=ss((Etc(),cD(WC(aX,1),jwe,351,0,[Btc,Dtc,Ctc])));} + function ooc(){ooc=geb;noc=ss((joc(),cD(WC(UV,1),jwe,372,0,[ioc,hoc,goc])));} + function muc(){muc=geb;luc=ss((huc(),cD(WC(dX,1),jwe,460,0,[fuc,euc,guc])));} + function Cvc(){Cvc=geb;Bvc=ss((xvc(),cD(WC(jX,1),jwe,299,0,[vvc,wvc,uvc])));} + function Lvc(){Lvc=geb;Kvc=ss((Gvc(),cD(WC(kX,1),jwe,311,0,[Evc,Fvc,Dvc])));} + function rDc(){rDc=geb;qDc=ss((lDc(),cD(WC(sX,1),jwe,390,0,[iDc,jDc,kDc])));} + function PEc(){PEc=geb;OEc=ss((KEc(),cD(WC(zX,1),jwe,387,0,[HEc,IEc,JEc])));} + function YEc(){YEc=geb;XEc=ss((TEc(),cD(WC(AX,1),jwe,349,0,[SEc,QEc,REc])));} + function GEc(){GEc=geb;FEc=ss((BEc(),cD(WC(yX,1),jwe,463,0,[AEc,yEc,zEc])));} + function qFc(){qFc=geb;pFc=ss((lFc(),cD(WC(CX,1),jwe,350,0,[iFc,jFc,kFc])));} + function zFc(){zFc=geb;yFc=ss((uFc(),cD(WC(DX,1),jwe,352,0,[tFc,rFc,sFc])));} + function IFc(){IFc=geb;HFc=ss((DFc(),cD(WC(EX,1),jwe,388,0,[BFc,CFc,AFc])));} + function QZc(){QZc=geb;PZc=ss((LZc(),cD(WC(F_,1),jwe,392,0,[KZc,JZc,IZc])));} + function m4c(){m4c=geb;l4c=ss((g4c(),cD(WC(I0,1),jwe,393,0,[d4c,e4c,f4c])));} + function z5c(){z5c=geb;y5c=ss((t5c(),cD(WC(N0,1),jwe,300,0,[r5c,s5c,q5c])));} + function k6c(){k6c=geb;j6c=ss((f6c(),cD(WC(V0,1),jwe,445,0,[c6c,d6c,e6c])));} + function F6c(){F6c=geb;E6c=ss((z6c(),cD(WC(Z0,1),jwe,456,0,[w6c,y6c,x6c])));} + function e7c(){e7c=geb;d7c=ss((_6c(),cD(WC(a1,1),jwe,394,0,[Z6c,$6c,Y6c])));} + function j9c(){j9c=geb;i9c=ss((b9c(),cD(WC(o1,1),jwe,439,0,[$8c,a9c,_8c])));} + function WKc(){WKc=geb;VKc=ss((RKc(),cD(WC(nY,1),jwe,464,0,[OKc,PKc,QKc])));} + function JKb(){JKb=geb;IKb=ss((EKb(),cD(WC(MN,1),jwe,471,0,[CKb,BKb,DKb])));} + function cKb(){cKb=geb;bKb=ss((ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])));} + function ALb(){ALb=geb;zLb=ss((vLb(),cD(WC(TN,1),jwe,472,0,[uLb,tLb,sLb])));} + function CBb(){CBb=geb;BBb=ss((xBb(),cD(WC(QL,1),jwe,108,0,[uBb,vBb,wBb])));} + function FWb(){FWb=geb;EWb=ss((AWb(),cD(WC(JP,1),jwe,391,0,[yWb,xWb,zWb])));} + function Knd(){Knd=geb;Jnd=ss((Fnd(),cD(WC(y3,1),jwe,346,0,[Dnd,Cnd,End])));} + function lbd(){lbd=geb;kbd=ss((gbd(),cD(WC(I1,1),jwe,444,0,[dbd,ebd,fbd])));} + function Tmd(){Tmd=geb;Smd=ss((Omd(),cD(WC(t3,1),jwe,278,0,[Lmd,Mmd,Nmd])));} + function rqd(){rqd=geb;qqd=ss((mqd(),cD(WC(J3,1),jwe,280,0,[kqd,jqd,lqd])));} + function Hxd(a,b){return !a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),QNd(a.o,b)} + function HMb(a,b){var c;if(a.C){c=RD(Vrb(a.b,b),127).n;c.d=a.C.d;c.a=a.C.a;}} + function F8b(a){var b,c,d,e;e=a.d;b=a.a;c=a.b;d=a.c;a.d=c;a.a=d;a.b=e;a.c=b;} + function cOd(a){!a.g&&(a.g=new hQd);!a.g.b&&(a.g.b=new ePd(a));return a.g.b} + function dOd(a){!a.g&&(a.g=new hQd);!a.g.c&&(a.g.c=new IPd(a));return a.g.c} + function lOd(a){!a.g&&(a.g=new hQd);!a.g.d&&(a.g.d=new kPd(a));return a.g.d} + function YNd(a){!a.g&&(a.g=new hQd);!a.g.a&&(a.g.a=new qPd(a));return a.g.a} + function B9d(a,b,c,d){!!c&&(d=c.Rh(b,BYd(c.Dh(),a.c.uk()),null,d));return d} + function C9d(a,b,c,d){!!c&&(d=c.Th(b,BYd(c.Dh(),a.c.uk()),null,d));return d} + function Cjb(a,b,c,d){var e;e=$C(kE,Pwe,28,b+1,15,1);Djb(e,a,b,c,d);return e} + function $C(a,b,c,d,e,f){var g;g=_C(e,d);e!=10&&cD(WC(a,f),b,c,e,g);return g} + function $fe(a,b,c){var d,e;e=new Phe(b,a);for(d=0;dc||b=0?a.Lh(c,true,true):Qvd(a,b,true)} + function gMc(a,b,c){var d;d=qMc(a,b,c);a.b=new _Lc(d.c.length);return iMc(a,d)} + function Pue(a){if(a.b<=0)throw Adb(new Dvb);--a.b;a.a-=a.c.c;return sgb(a.a)} + function PGd(a){var b;if(!a.a){throw Adb(new Evb)}b=a.a;a.a=vCd(a.a);return b} + function WDb(a){while(!a.a){if(!yEb(a.c,new $Db(a))){return false}}return true} + function Nr(a){var b;Qb(a);if(ZD(a,204)){b=RD(a,204);return b}return new Or(a)} + function Cfd(a){Afd();RD(a.of((umd(),Lld)),181).Fc((Pod(),Mod));a.qf(Kld,null);} + function Afd(){Afd=geb;xfd=new Gfd;zfd=new Ifd;yfd=yn((umd(),Kld),xfd,pld,zfd);} + function Y3c(){Y3c=geb;W3c=new $3c('LEAF_NUMBER',0);X3c=new $3c('NODE_SIZE',1);} + function YLc(a){a.a=$C(kE,Pwe,28,a.b+1,15,1);a.c=$C(kE,Pwe,28,a.b,15,1);a.d=0;} + function OZb(a,b){if(a.a.Ne(b.d,a.b)>0){Rmb(a.c,new fZb(b.c,b.d,a.d));a.b=b.d;}} + function NHd(a,b){if(a.g==null||b>=a.i)throw Adb(new yNd(b,a.i));return a.g[b]} + function P_d(a,b,c){gHd(a,c);if(c!=null&&!a.fk(c)){throw Adb(new yeb)}return c} + function dD(a,b){XC(b)!=10&&cD(rb(b),b.Sm,b.__elementTypeId$,XC(b),a);return a} + function Wnb(a,b,c,d){var e;d=(urb(),!d?rrb:d);e=a.slice(b,c);Xnb(e,a,b,c,-b,d);} + function zvd(a,b,c,d,e){return b<0?Qvd(a,c,d):RD(c,69).wk().yk(a,a.hi(),b,d,e)} + function J9b(a,b){return Qfb(Kfb(UD(mQb(a,(Ywc(),Jwc)))),Kfb(UD(mQb(b,Jwc))))} + function qAb(){qAb=geb;pAb=ss((cAb(),cD(WC(AL,1),jwe,304,0,[$zb,_zb,aAb,bAb])));} + function cAb(){cAb=geb;$zb=new dAb('All',0);_zb=new iAb;aAb=new kAb;bAb=new nAb;} + function EKb(){EKb=geb;CKb=new FKb(Nye,0);BKb=new FKb(Kye,1);DKb=new FKb(Oye,2);} + function Zme(){Zme=geb;qAd();Wme=oxe;Vme=pxe;Yme=new Tfb(oxe);Xme=new Tfb(pxe);} + function rOb(){rOb=geb;qOb=ss((mOb(),cD(WC(hO,1),jwe,417,0,[lOb,iOb,jOb,kOb])));} + function NRb(){NRb=geb;MRb=ss((IRb(),cD(WC(WO,1),jwe,406,0,[FRb,ERb,GRb,HRb])));} + function NPb(){NPb=geb;MPb=ss((IPb(),cD(WC(DO,1),jwe,332,0,[FPb,EPb,GPb,HPb])));} + function Z$b(){Z$b=geb;Y$b=ss((U$b(),cD(WC(CQ,1),jwe,389,0,[T$b,R$b,Q$b,S$b])));} + function wZb(){wZb=geb;vZb=ss((nZb(),cD(WC(lQ,1),jwe,416,0,[jZb,mZb,kZb,lZb])));} + function jnc(){jnc=geb;inc=ss((enc(),cD(WC(LV,1),jwe,421,0,[anc,bnc,cnc,dnc])));} + function Bec(){Bec=geb;Aec=ss((vec(),cD(WC(qT,1),jwe,371,0,[uec,sec,tec,rec])));} + function DDc(){DDc=geb;CDc=ss((wDc(),cD(WC(tX,1),jwe,203,0,[uDc,vDc,tDc,sDc])));} + function pEc(){pEc=geb;oEc=ss((kEc(),cD(WC(wX,1),jwe,284,0,[hEc,gEc,iEc,jEc])));} + function Cuc(){Cuc=geb;Buc=new Duc(LAe,0);Auc=new Duc('IMPROVE_STRAIGHTNESS',1);} + function _i(a,b){var c,d;d=b/a.c.Rd().gc()|0;c=b%a.c.Rd().gc();return Ui(a,d,c)} + function iZd(a){var b;if(a.nl()){for(b=a.i-1;b>=0;--b){QHd(a,b);}}return WHd(a)} + function Nyb(a){var b,c;if(!a.b){return null}c=a.b;while(b=c.a[0]){c=b;}return c} + function Oyb(a){var b,c;if(!a.b){return null}c=a.b;while(b=c.a[1]){c=b;}return c} + function Hae(a){if(ZD(a,180)){return ''+RD(a,180).a}return a==null?null:jeb(a)} + function Iae(a){if(ZD(a,180)){return ''+RD(a,180).a}return a==null?null:jeb(a)} + function eGb(a,b){if(b.a){throw Adb(new yz(jye))}Ysb(a.a,b);b.a=a;!a.j&&(a.j=b);} + function hEb(a,b){xxb.call(this,b.zd(),b.yd()&-16449);uFb(a);this.a=a;this.c=b;} + function zXc(a,b){return new gud(b,Zid(ajd(b.e),b.f.a+a,b.f.b+a),(Geb(),false))} + function EMc(a,b){dMc();return Rmb(a,new Ptd(b,sgb(b.e.c.length+b.g.c.length)))} + function GMc(a,b){dMc();return Rmb(a,new Ptd(b,sgb(b.e.c.length+b.g.c.length)))} + function p5c(){p5c=geb;o5c=ss((j5c(),cD(WC(M0,1),jwe,354,0,[i5c,g5c,h5c,f5c])));} + function x_c(){x_c=geb;w_c=ss((s_c(),cD(WC(J_,1),jwe,353,0,[r_c,p_c,q_c,o_c])));} + function eWc(){eWc=geb;dWc=ss((YVc(),cD(WC(H$,1),jwe,405,0,[UVc,VVc,WVc,XVc])));} + function bnd(){bnd=geb;and=ss((Ymd(),cD(WC(u3,1),jwe,223,0,[Xmd,Vmd,Umd,Wmd])));} + function Vnd(){Vnd=geb;Und=ss((Pnd(),cD(WC(z3,1),jwe,291,0,[Ond,Lnd,Mnd,Nnd])));} + function Vpd(){Vpd=geb;Upd=ss((Qpd(),cD(WC(H3,1),jwe,386,0,[Opd,Ppd,Npd,Mpd])));} + function Lrd(){Lrd=geb;Krd=ss((Grd(),cD(WC(R3,1),jwe,320,0,[Frd,Crd,Erd,Drd])));} + function ytd(){ytd=geb;xtd=ss((ttd(),cD(WC(n4,1),jwe,415,0,[qtd,rtd,ptd,std])));} + function b9c(){b9c=geb;$8c=new d9c(iFe,0);a9c=new d9c(mEe,1);_8c=new d9c(LAe,2);} + function sBb(a,b,c,d,e){uFb(a);uFb(b);uFb(c);uFb(d);uFb(e);return new DBb(a,b,d)} + function fub(a,b){var c;c=RD(_jb(a.e,b),400);if(c){rub(c);return c.e}return null} + function Ymb(a,b){var c;c=Wmb(a,b,0);if(c==-1){return false}Xmb(a,c);return true} + function LDb(a,b,c){var d;LCb(a);d=new IEb;d.a=b;a.a.Nb(new QEb(d,c));return d.a} + function VCb(a){var b;LCb(a);b=$C(iE,vxe,28,0,15,1);ixb(a.a,new dDb(b));return b} + function yc(a){var b;if(!xc(a)){throw Adb(new Dvb)}a.e=1;b=a.d;a.d=null;return b} + function Odb(a){var b;if(Kdb(a)){b=0-a;if(!isNaN(b)){return b}}return Edb(xD(a))} + function Wmb(a,b,c){for(;c=0?Dvd(a,c,true,true):Qvd(a,b,true)} + function Vwd(a){var b;b=SD(Ywd(a,32));if(b==null){Wwd(a);b=SD(Ywd(a,32));}return b} + function Yvd(a){var b;if(!a.Oh()){b=AYd(a.Dh())-a.ji();a.$h().Mk(b);}return a.zh()} + function zQb(a,b){yQb=new kRb;wQb=b;xQb=a;RD(xQb.b,68);BQb(xQb,yQb,null);AQb(xQb);} + function AWb(){AWb=geb;yWb=new BWb('XY',0);xWb=new BWb('X',1);zWb=new BWb('Y',2);} + function vLb(){vLb=geb;uLb=new wLb('TOP',0);tLb=new wLb(Kye,1);sLb=new wLb(Qye,2);} + function Gvc(){Gvc=geb;Evc=new Hvc(LAe,0);Fvc=new Hvc('TOP',1);Dvc=new Hvc(Qye,2);} + function sEc(){sEc=geb;qEc=new tEc('INPUT_ORDER',0);rEc=new tEc('PORT_DEGREE',1);} + function MD(){MD=geb;ID=hD(dxe,dxe,524287);JD=hD(0,0,fxe);KD=fD(1);fD(2);LD=fD(0);} + function wWd(a){var b;if(a.d!=a.r){b=WVd(a);a.e=!!b&&b.lk()==aKe;a.d=b;}return a.e} + function UHd(a,b,c){var d;d=a.g[b];MHd(a,b,a.Zi(b,c));a.Ri(b,c,d);a.Ni();return d} + function dHd(a,b){var c;c=a.dd(b);if(c>=0){a.gd(c);return true}else {return false}} + function xr(a,b){var c;Qb(a);Qb(b);c=false;while(b.Ob()){c=c|a.Fc(b.Pb());}return c} + function cub(a,b){var c;c=RD(Wjb(a.e,b),400);if(c){eub(a,c);return c.e}return null} + function iB(a){var b,c;b=a/60|0;c=a%60;if(c==0){return ''+b}return ''+b+':'+(''+c)} + function JB(d,a){var b=d.a[a];var c=(HC(),GC)[typeof b];return c?c(b):NC(typeof b)} + function EDb(a,b){var c,d;MCb(a);d=new zEb(b,a.a);c=new YDb(d);return new SDb(a,c)} + function mwb(a){var b;b=a.b.c.length==0?null:Vmb(a.b,0);b!=null&&owb(a,0);return b} + function ukc(a,b){var c,d,e;e=b.c.i;c=RD(Wjb(a.f,e),60);d=c.d.c-c.e.c;Bjd(b.a,d,0);} + function XLc(a,b){var c;++a.d;++a.c[b];c=b+1;while(c=0){++b[0];}} + function eEd(a,b){Dyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function fEd(a,b){Eyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function gEd(a,b){Cyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function hEd(a,b){Ayd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function oWc(a,b,c){return cjd(new rjd(c.e.a+c.f.a/2,c.e.b+c.f.b/2),a)==(uFb(b),b)} + function qge(a,b){return ZD(b,102)&&(RD(b,19).Bb&txe)!=0?new She(b,a):new Phe(b,a)} + function sge(a,b){return ZD(b,102)&&(RD(b,19).Bb&txe)!=0?new She(b,a):new Phe(b,a)} + function XC(a){return a.__elementTypeCategory$==null?10:a.__elementTypeCategory$} + function Bhb(a,b){return b==(wvb(),wvb(),vvb)?a.toLocaleLowerCase():a.toLowerCase()} + function Mu(a){if(!a.e){throw Adb(new Dvb)}a.c=a.a=a.e;a.e=a.e.e;--a.d;return a.a.f} + function Lu(a){if(!a.c){throw Adb(new Dvb)}a.e=a.a=a.c;a.c=a.c.c;++a.d;return a.a.f} + function Lsb(a){var b;++a.a;for(b=a.c.a.length;a.aa.a[d]&&(d=c);}return d} + function Krc(a){var b;b=RD(mQb(a,(Ywc(),Wvc)),313);if(b){return b.a==a}return false} + function Lrc(a){var b;b=RD(mQb(a,(Ywc(),Wvc)),313);if(b){return b.i==a}return false} + function xXb(){xXb=geb;wXb=ss((sXb(),cD(WC(UP,1),jwe,367,0,[nXb,oXb,pXb,qXb,rXb])));} + function Hnc(){Hnc=geb;Gnc=ss((Bnc(),cD(WC(TV,1),jwe,375,0,[xnc,znc,Anc,ync,wnc])));} + function Xtc(){Xtc=geb;Wtc=ss((Ptc(),cD(WC(bX,1),jwe,348,0,[Ltc,Ktc,Ntc,Otc,Mtc])));} + function RDc(){RDc=geb;QDc=ss((JDc(),cD(WC(uX,1),jwe,323,0,[IDc,FDc,GDc,EDc,HDc])));} + function hxc(){hxc=geb;gxc=ss((cxc(),cD(WC(mX,1),jwe,171,0,[bxc,Zwc,$wc,_wc,axc])));} + function m3c(){m3c=geb;l3c=ss((g3c(),cD(WC(x0,1),jwe,368,0,[e3c,b3c,f3c,c3c,d3c])));} + function xad(){xad=geb;wad=ss((sad(),cD(WC(x1,1),jwe,373,0,[oad,nad,qad,pad,rad])));} + function acd(){acd=geb;_bd=ss((Xbd(),cD(WC(P1,1),jwe,324,0,[Sbd,Tbd,Wbd,Ubd,Vbd])));} + function Kmd(){Kmd=geb;Jmd=ss((Cmd(),cD(WC(s3,1),jwe,88,0,[Amd,zmd,ymd,xmd,Bmd])));} + function bid(){bid=geb;aid=ss((Yhd(),cD(WC(d3,1),jwe,170,0,[Whd,Vhd,Thd,Xhd,Uhd])));} + function uod(){uod=geb;tod=ss((pod(),cD(WC(B3,1),jwe,256,0,[mod,ood,kod,lod,nod])));} + function zpd(){zpd=geb;ypd=ss((qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])));} + function LHb(){LHb=geb;JHb=new MHb('BY_SIZE',0);KHb=new MHb('BY_SIZE_AND_SHAPE',1);} + function TUb(){TUb=geb;RUb=new UUb('EADES',0);SUb=new UUb('FRUCHTERMAN_REINGOLD',1);} + function $tc(){$tc=geb;Ytc=new _tc('READING_DIRECTION',0);Ztc=new _tc('ROTATION',1);} + function CZb(){CZb=geb;zZb=new ZZb;AZb=new b$b;xZb=new f$b;yZb=new j$b;BZb=new n$b;} + function dGb(a){this.b=new bnb;this.a=new bnb;this.c=new bnb;this.d=new bnb;this.e=a;} + function XZb(a){this.g=a;this.f=new bnb;this.a=$wnd.Math.min(this.g.c.c,this.g.d.c);} + function UKb(a,b,c){RJb.call(this);KKb(this);this.a=a;this.c=c;this.b=b.d;this.f=b.e;} + function d6b(a,b,c){var d,e;for(e=new Anb(c);e.a=0&&b0?b-1:b;return Kqd(Lqd(Mqd(Nqd(new Oqd,c),a.n),a.j),a.k)} + function nBd(a){var b,c;c=(b=new q4d,b);WGd((!a.q&&(a.q=new C5d(s7,a,11,10)),a.q),c);} + function ofb(a){return ((a.i&2)!=0?'interface ':(a.i&1)!=0?'':'class ')+(lfb(a),a.o)} + function dz(a){if(Ddb(a,lve)>0){return lve}if(Ddb(a,qwe)<0){return qwe}return Ydb(a)} + function Sv(a){if(a<3){dk(a,fwe);return a+1}if(a=-0.01&&a.a<=Tye&&(a.a=0);a.b>=-0.01&&a.b<=Tye&&(a.b=0);return a} + function Hid(a){tid();var b,c;c=KEe;for(b=0;bc&&(c=a[b]);}return c} + function Zvd(a,b){var c;c=wYd(a.Dh(),b);if(!c){throw Adb(new agb(KHe+b+NHe))}return c} + function NGd(a,b){var c;c=a;while(vCd(c)){c=vCd(c);if(c==b){return true}}return false} + function ix(a,b){var c,d,e;d=b.a.ld();c=RD(b.a.md(),16).gc();for(e=0;ea||a>b){throw Adb(new xeb('fromIndex: 0, toIndex: '+a+Qxe+b))}} + function ZHd(a){if(a<0){throw Adb(new agb('Illegal Capacity: '+a))}this.g=this.aj(a);} + function _y(a,b){Zy();bz(pwe);return $wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)} + function xJc(a,b){var c,d,e,f;for(d=a.d,e=0,f=d.length;e0){a.a/=b;a.b/=b;}return a} + function BXd(a){var b;if(a.w){return a.w}else {b=CXd(a);!!b&&!b.Vh()&&(a.w=b);return b}} + function l2d(a,b){var c,d;d=a.a;c=m2d(a,b,null);d!=b&&!a.e&&(c=o2d(a,b,c));!!c&&c.oj();} + function rQc(a,b,c){var d,e;d=b;do{e=Kfb(a.p[d.p])+c;a.p[d.p]=e;d=a.a[d.p];}while(d!=b)} + function heb(a,b,c){var d=function(){return a.apply(d,arguments)};b.apply(d,c);return d} + function Gae(a){var b;if(a==null){return null}else {b=RD(a,195);return sAd(b,b.length)}} + function QHd(a,b){if(a.g==null||b>=a.i)throw Adb(new yNd(b,a.i));return a.Wi(b,a.g[b])} + function Dob(a,b){yob();var c,d;d=new bnb;for(c=0;c=14&&b<=16)));return a} + function ws(a,b){var c;uFb(b);c=a[':'+b];mFb(!!c,'Enum constant undefined: '+b);return c} + function tfb(a,b,c,d,e,f){var g;g=rfb(a,b);Ffb(c,g);g.i=e?8:0;g.f=d;g.e=e;g.g=f;return g} + function R3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=1;this.c=a;this.a=c;} + function T3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=2;this.c=a;this.a=c;} + function _3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=6;this.c=a;this.a=c;} + function e4d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=7;this.c=a;this.a=c;} + function X3d(a,b,c,d,e){this.d=b;this.j=d;this.e=e;this.o=-1;this.p=4;this.c=a;this.a=c;} + function iGb(a,b){var c,d,e,f;for(d=b,e=0,f=d.length;e=0)){throw Adb(new agb('tolerance ('+a+') must be >= 0'))}return a} + function hOd(a,b){var c;if(ZD(b,44)){return a.c.Mc(b)}else {c=QNd(a,b);jOd(a,b);return c}} + function yBd(a,b,c){YVd(a,b);PAd(a,c);$Vd(a,0);bWd(a,1);aWd(a,true);_Vd(a,true);return a} + function ZGd(a,b){var c;c=a.gc();if(b<0||b>c)throw Adb(new aMd(b,c));return new CMd(a,b)} + function Cad(a,b){a.b=$wnd.Math.max(a.b,b.d);a.e+=b.r+(a.a.c.length==0?0:a.c);Rmb(a.a,b);} + function Jmb(a){yFb(a.c>=0);if(rmb(a.d,a.c)<0){a.a=a.a-1&a.d.a.length-1;a.b=a.d.c;}a.c=-1;} + function Nc(a){var b,c;for(c=a.c.Cc().Kc();c.Ob();){b=RD(c.Pb(),16);b.$b();}a.c.$b();a.d=0;} + function Zi(a){var b,c,d,e;for(c=a.a,d=0,e=c.length;d=0} + function Iqd(a,b){if(a.r>0&&a.c0&&a.g!=0&&Iqd(a.i,b/a.r*a.i.d);}} + function $Cd(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.c));} + function P1d(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,4,c,a.c));} + function jyd(a,b){var c;c=a.k;a.k=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,2,c,a.k));} + function JXd(a,b){var c;c=a.D;a.D=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,2,c,a.D));} + function Kzd(a,b){var c;c=a.f;a.f=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,8,c,a.f));} + function Lzd(a,b){var c;c=a.i;a.i=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,7,c,a.i));} + function fCd(a,b){var c;c=a.a;a.a=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,8,c,a.a));} + function ZCd(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,c,a.b));} + function s6d(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,c,a.b));} + function t6d(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.c));} + function nVd(a,b){var c;c=a.d;a.d=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.d));} + function Cte(a,b,c){var d;a.b=b;a.a=c;d=(a.a&512)==512?new Gre:new Tqe;a.c=Nqe(d,a.b,a.a);} + function Gge(a,b){return qke(a.e,b)?(nke(),wWd(b)?new ole(b,a):new Eke(b,a)):new Ble(b,a)} + function iDb(a){var b,c;if(0>a){return new rDb}b=a+1;c=new kDb(b,a);return new oDb(null,c)} + function Gob(a,b){yob();var c;c=new Usb(1);bE(a)?$jb(c,a,b):rtb(c.f,a,b);return new uqb(c)} + function pQc(a,b){var c,d;c=a.c;d=b.e[a.p];if(d>0){return RD(Vmb(c.a,d-1),10)}return null} + function TOb(a,b){var c,d;c=a.o+a.p;d=b.o+b.p;if(cb){b<<=1;return b>0?b:hwe}return b} + function xc(a){Ub(a.e!=3);switch(a.e){case 2:return false;case 0:return true;}return zc(a)} + function djd(a,b){var c;if(ZD(b,8)){c=RD(b,8);return a.a==c.a&&a.b==c.b}else {return false}} + function Ydd(a,b){var c;c=new kRb;RD(b.b,68);RD(b.b,68);RD(b.b,68);Umb(b.a,new ced(a,c,b));} + function gOd(a,b){var c,d;for(d=b.vc().Kc();d.Ob();){c=RD(d.Pb(),44);fOd(a,c.ld(),c.md());}} + function Jzd(a,b){var c;c=a.d;a.d=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,11,c,a.d));} + function zWd(a,b){var c;c=a.j;a.j=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,13,c,a.j));} + function b6d(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,21,c,a.b));} + function YAb(a,b){((gBb(),dBb)?null:b.c).length==0&&iBb(b,new rBb);$jb(a.a,dBb?null:b.c,b);} + function b9b(a,b){b.Ug('Hierarchical port constraint processing',1);c9b(a);e9b(a);b.Vg();} + function joc(){joc=geb;ioc=new koc('START',0);hoc=new koc('MIDDLE',1);goc=new koc('END',2);} + function x2c(){x2c=geb;v2c=new z2c('P1_NODE_PLACEMENT',0);w2c=new z2c('P2_EDGE_ROUTING',1);} + function JVb(){JVb=geb;HVb=new jGd(rAe);IVb=new jGd(sAe);GVb=new jGd(tAe);FVb=new jGd(uAe);} + function tkb(a){var b;rFb(a.f.g,a.d);sFb(a.b);a.c=a.a;b=RD(a.a.Pb(),44);a.b=skb(a);return b} + function P2d(a){var b;if(a.b==null){return j3d(),j3d(),i3d}b=a.ul()?a.tl():a.sl();return b} + function nwb(a,b){var c;c=b==null?-1:Wmb(a.b,b,0);if(c<0){return false}owb(a,c);return true} + function zsb(a,b){var c;uFb(b);c=b.g;if(!a.b[c]){bD(a.b,c,b);++a.c;return true}return false} + function azb(a,b){var c,d;c=1-b;d=a.a[c];a.a[c]=d.a[b];d.a[b]=a;a.b=true;d.b=false;return d} + function xRb(a,b){var c,d;for(d=b.Kc();d.Ob();){c=RD(d.Pb(),272);a.b=true;Ysb(a.e,c);c.b=a;}} + function kic(a,b){var c,d;c=RD(mQb(a,(yCc(),IBc)),8);d=RD(mQb(b,IBc),8);return Qfb(c.b,d.b)} + function SPb(a,b,c){var d,e,f;f=b>>5;e=b&31;d=Cdb(Udb(a.n[c][f],Ydb(Sdb(e,1))),3);return d} + function lmb(a,b,c){var d,e,f;f=a.a.length-1;for(e=a.b,d=0;d0?1:0}return (!a.c&&(a.c=ojb(Hdb(a.f))),a.c).e} + function GXd(a,b){if(b){if(a.B==null){a.B=a.D;a.D=null;}}else if(a.B!=null){a.D=a.B;a.B=null;}} + function rZb(a,b){nZb();return a==jZb&&b==mZb||a==mZb&&b==jZb||a==lZb&&b==kZb||a==kZb&&b==lZb} + function sZb(a,b){nZb();return a==jZb&&b==kZb||a==jZb&&b==lZb||a==mZb&&b==lZb||a==mZb&&b==kZb} + function zMb(a,b){return Zy(),bz(Tye),$wnd.Math.abs(0-b)<=Tye||0==b||isNaN(0)&&isNaN(b)?0:a/b} + function qsc(a,b){return Kfb(UD(Lvb(MDb(GDb(new SDb(null,new Swb(a.c.b,16)),new Isc(a)),b))))} + function tsc(a,b){return Kfb(UD(Lvb(MDb(GDb(new SDb(null,new Swb(a.c.b,16)),new Gsc(a)),b))))} + function rvc(){ovc();return cD(WC(iX,1),jwe,259,0,[fvc,hvc,ivc,jvc,kvc,lvc,nvc,evc,gvc,mvc])} + function dEc(){aEc();return cD(WC(vX,1),jwe,243,0,[$Dc,VDc,YDc,WDc,XDc,SDc,ZDc,_Dc,TDc,UDc])} + function z3c(a,b){var c;b.Ug('General Compactor',1);c=h4c(RD(Gxd(a,($4c(),I4c)),393));c.Cg(a);} + function T5c(a,b){var c,d;c=RD(Gxd(a,($4c(),P4c)),17);d=RD(Gxd(b,P4c),17);return hgb(c.a,d.a)} + function Bjd(a,b,c){var d,e;for(e=Sub(a,0);e.b!=e.d.c;){d=RD(evb(e),8);d.a+=b;d.b+=c;}return a} + function Go(a,b,c){var d;for(d=a.b[c&a.f];d;d=d.b){if(c==d.a&&Hb(b,d.g)){return d}}return null} + function Ho(a,b,c){var d;for(d=a.c[c&a.f];d;d=d.d){if(c==d.f&&Hb(b,d.i)){return d}}return null} + function sjb(a,b,c){var d,e,f;d=0;for(e=0;e>>31;}d!=0&&(a[c]=d);} + function yzb(a,b,c,d,e,f){var g;this.c=a;g=new bnb;Syb(a,g,b,a.b,c,d,e,f);this.a=new Jkb(g,0);} + function _5c(){this.c=new T2c(0);this.b=new T2c(FEe);this.d=new T2c(EEe);this.a=new T2c(Gze);} + function kMb(a,b,c,d,e,f,g){qs.call(this,a,b);this.d=c;this.e=d;this.c=e;this.b=f;this.a=dv(g);} + function tBd(a,b,c,d,e,f,g,h,i,j,k,l,m){ABd(a,b,c,d,e,f,g,h,i,j,k,l,m);kXd(a,false);return a} + function H0b(a){if(a.b.c.i.k==(r3b(),m3b)){return RD(mQb(a.b.c.i,(Ywc(),Awc)),12)}return a.b.c} + function I0b(a){if(a.b.d.i.k==(r3b(),m3b)){return RD(mQb(a.b.d.i,(Ywc(),Awc)),12)}return a.b.d} + function nDb(a){var b;b=mDb(a);if(Gdb(b.a,0)){return bwb(),bwb(),awb}return bwb(),new ewb(b.b)} + function SCb(a){var b;b=RCb(a);if(Gdb(b.a,0)){return Tvb(),Tvb(),Svb}return Tvb(),new Yvb(b.b)} + function TCb(a){var b;b=RCb(a);if(Gdb(b.a,0)){return Tvb(),Tvb(),Svb}return Tvb(),new Yvb(b.c)} + function o8b(a){switch(a.g){case 2:return qpd(),ppd;case 4:return qpd(),Xod;default:return a;}} + function p8b(a){switch(a.g){case 1:return qpd(),npd;case 3:return qpd(),Yod;default:return a;}} + function C9c(a){switch(a.g){case 0:return new s9c;case 1:return new x9c;default:return null;}} + function Zcc(){Zcc=geb;Ycc=new kGd('edgelabelcenterednessanalysis.includelabel',(Geb(),Eeb));} + function jKc(){jKc=geb;iKc=mfd(qfd(pfd(pfd(new ufd,(sXb(),pXb),(hcc(),Qbc)),qXb,Gbc),rXb),Pbc);} + function DLc(){DLc=geb;CLc=mfd(qfd(pfd(pfd(new ufd,(sXb(),pXb),(hcc(),Qbc)),qXb,Gbc),rXb),Pbc);} + function lYd(){lYd=geb;iYd=new i1d;kYd=cD(WC(y7,1),lKe,179,0,[]);jYd=cD(WC(s7,1),mKe,62,0,[]);} + function P8b(){P8b=geb;O8b=new Q8b('TO_INTERNAL_LTR',0);N8b=new Q8b('TO_INPUT_DIRECTION',1);} + function J3b(){J3b=geb;G3b=new r4b;E3b=new w4b;F3b=new A4b;D3b=new E4b;H3b=new I4b;I3b=new M4b;} + function Cac(a,b){b.Ug(iBe,1);LJb(KJb(new PJb((i1b(),new t1b(a,false,false,new _1b)))));b.Vg();} + function M_c(a,b,c){c.Ug('DFS Treeifying phase',1);L_c(a,b);J_c(a,b);a.a=null;a.b=null;c.Vg();} + function Leb(a,b){Geb();return bE(a)?jhb(a,WD(b)):_D(a)?Jfb(a,UD(b)):$D(a)?Ieb(a,TD(b)):a.Fd(b)} + function Ld(a,b){var c,d;uFb(b);for(d=b.vc().Kc();d.Ob();){c=RD(d.Pb(),44);a.zc(c.ld(),c.md());}} + function ege(a,b,c){var d;for(d=c.Kc();d.Ob();){if(!cge(a,b,d.Pb())){return false}}return true} + function S6d(a,b,c,d,e){var f;if(c){f=BYd(b.Dh(),a.c);e=c.Rh(b,-1-(f==-1?d:f),null,e);}return e} + function T6d(a,b,c,d,e){var f;if(c){f=BYd(b.Dh(),a.c);e=c.Th(b,-1-(f==-1?d:f),null,e);}return e} + function Uib(a){var b;if(a.b==-2){if(a.e==0){b=-1;}else {for(b=0;a.a[b]==0;b++);}a.b=b;}return a.b} + function fjb(a){uFb(a);if(a.length==0){throw Adb(new Vgb('Zero length BigInteger'))}mjb(this,a);} + function $Hd(a){this.i=a.gc();if(this.i>0){this.g=this.aj(this.i+(this.i/8|0)+1);a.Qc(this.g);}} + function dmc(a,b,c){this.g=a;this.d=b;this.e=c;this.a=new bnb;bmc(this);yob();_mb(this.a,null);} + function aad(a,b){b.q=a;a.d=$wnd.Math.max(a.d,b.r);a.b+=b.d+(a.a.c.length==0?0:a.c);Rmb(a.a,b);} + function xid(a,b){var c,d,e,f;e=a.c;c=a.c+a.b;f=a.d;d=a.d+a.a;return b.a>e&&b.af&&b.be?(c=e):BFb(b,c+1);a.a=zhb(a.a,0,b)+(''+d)+yhb(a.a,c);} + function ktb(a,b){a.a=Bdb(a.a,1);a.c=$wnd.Math.min(a.c,b);a.b=$wnd.Math.max(a.b,b);a.d=Bdb(a.d,b);} + function wdc(a,b){return b1||a.Ob()){++a.a;a.g=0;b=a.i;a.Ob();return b}else {throw Adb(new Dvb)}} + function GRc(a){switch(a.a.g){case 1:return new lSc;case 3:return new VUc;default:return new WRc;}} + function fyd(a,b){switch(b){case 1:return !!a.n&&a.n.i!=0;case 2:return a.k!=null;}return Cxd(a,b)} + function Hdb(a){if(jxe>22);e=a.h+b.h+(d>>22);return hD(c&dxe,d&dxe,e&exe)} + function DD(a,b){var c,d,e;c=a.l-b.l;d=a.m-b.m+(c>>22);e=a.h-b.h+(d>>22);return hD(c&dxe,d&dxe,e&exe)} + function Jpc(a){var b,c;Hpc(a);for(c=new Anb(a.d);c.ad)throw Adb(new aMd(b,d));a.Si()&&(c=bHd(a,c));return a.Ei(b,c)} + function eQb(a,b,c,d,e){var f,g;for(g=c;g<=e;g++){for(f=b;f<=d;f++){PPb(a,f,g)||TPb(a,f,g,true,false);}}} + function uid(a){tid();var b,c,d;c=$C(l3,Nve,8,2,0,1);d=0;for(b=0;b<2;b++){d+=0.5;c[b]=Cid(d,a);}return c} + function xD(a){var b,c,d;b=~a.l+1&dxe;c=~a.m+(b==0?1:0)&dxe;d=~a.h+(b==0&&c==0?1:0)&exe;return hD(b,c,d)} + function mgb(a){var b;if(a<0){return qwe}else if(a==0){return 0}else {for(b=hwe;(b&a)==0;b>>=1);return b}} + function zSd(a,b,c){if(a>=128)return false;return a<64?Pdb(Cdb(Sdb(1,a),c),0):Pdb(Cdb(Sdb(1,a-64),b),0)} + function oQb(a,b,c){return c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c)),a} + function pQb(a,b,c){c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c));return a} + function KTb(a){var b,c;c=new gUb;kQb(c,a);pQb(c,(JVb(),HVb),a);b=new Tsb;MTb(a,c,b);LTb(a,c,b);return c} + function cIc(a){var b,c;b=a.t-a.k[a.o.p]*a.d+a.j[a.o.p]>a.f;c=a.u+a.e[a.o.p]*a.d>a.f*a.s*a.d;return b||c} + function qmc(a,b){var c,d,e,f;c=false;d=a.a[b].length;for(f=0;f=0,'Negative initial capacity');mFb(b>=0,'Non-positive load factor');akb(this);} + function iib(a,b,c,d,e){var f,g;g=a.length;f=c.length;if(b<0||d<0||e<0||b+e>g||d+e>f){throw Adb(new ueb)}} + function zob(a,b){yob();var c,d,e,f,g;g=false;for(d=b,e=0,f=d.length;e1||b>=0&&a.b<3} + function nD(a){var b,c,d;b=~a.l+1&dxe;c=~a.m+(b==0?1:0)&dxe;d=~a.h+(b==0&&c==0?1:0)&exe;a.l=b;a.m=c;a.h=d;} + function Cob(a){yob();var b,c,d;d=1;for(c=a.Kc();c.Ob();){b=c.Pb();d=31*d+(b!=null?tb(b):0);d=d|0;}return d} + function kD(a,b,c,d,e){var f;f=BD(a,b);c&&nD(f);if(e){a=mD(a,b);d?(eD=xD(a)):(eD=hD(a.l,a.m,a.h));}return f} + function Qlc(a,b,c){a.g=Wlc(a,b,(qpd(),Xod),a.b);a.d=Wlc(a,c,Xod,a.b);if(a.g.c==0||a.d.c==0){return}Tlc(a);} + function Rlc(a,b,c){a.g=Wlc(a,b,(qpd(),ppd),a.j);a.d=Wlc(a,c,ppd,a.j);if(a.g.c==0||a.d.c==0){return}Tlc(a);} + function Xyd(a,b){switch(b){case 7:return !!a.e&&a.e.i!=0;case 8:return !!a.d&&a.d.i!=0;}return wyd(a,b)} + function STb(a,b){switch(b.g){case 0:ZD(a.b,641)||(a.b=new tUb);break;case 1:ZD(a.b,642)||(a.b=new zUb);}} + function tbd(a){switch(a.g){case 0:return new _dd;default:throw Adb(new agb(eGe+(a.f!=null?a.f:''+a.g)));}} + function bdd(a){switch(a.g){case 0:return new vdd;default:throw Adb(new agb(eGe+(a.f!=null?a.f:''+a.g)));}} + function LCc(a,b,c){return !QDb(CDb(new SDb(null,new Swb(a.c,16)),new PAb(new gsd(b,c)))).Bd((xDb(),wDb))} + function mWc(a,b){return cjd(jWc(RD(mQb(b,(h_c(),H$c)),88)),new rjd(a.c.e.a-a.b.e.a,a.c.e.b-a.b.e.b))<=0} + function dve(a,b){while(a.g==null&&!a.c?sId(a):a.g==null||a.i!=0&&RD(a.g[a.i-1],51).Ob()){mFd(b,tId(a));}} + function sYb(a){var b,c;for(c=new Anb(a.a.b);c.ad?1:0} + function ICc(a){Rmb(a.c,(hed(),fed));if(_y(a.a,Kfb(UD(iGd((QCc(),OCc)))))){return new asd}return new csd(a)} + function fs(a){while(!a.d||!a.d.Ob()){if(!!a.b&&!nmb(a.b)){a.d=RD(smb(a.b),51);}else {return null}}return a.d} + function BVc(a){switch(a.g){case 1:return EEe;default:case 2:return 0;case 3:return Gze;case 4:return FEe;}} + function fte(){Vse();var a;if(Cse)return Cse;a=Zse(hte('M',true));a=$se(hte('M',false),a);Cse=a;return Cse} + function ttd(){ttd=geb;qtd=new utd('ELK',0);rtd=new utd('JSON',1);ptd=new utd('DOT',2);std=new utd('SVG',3);} + function TEc(){TEc=geb;SEc=new UEc('STACKED',0);QEc=new UEc('REVERSE_STACKED',1);REc=new UEc('SEQUENCED',2);} + function LZc(){LZc=geb;KZc=new MZc(LAe,0);JZc=new MZc('MIDDLE_TO_MIDDLE',1);IZc=new MZc('AVOID_OVERLAP',2);} + function sgc(){sgc=geb;qgc=new Lgc;rgc=new Ngc;pgc=new Dgc;ogc=new Pgc;ngc=new Hgc;mgc=(uFb(ngc),new nrb);} + function vnd(){vnd=geb;tnd=new A3b(15);snd=new mGd((umd(),tld),tnd);und=Qld;ond=Ekd;pnd=kld;rnd=nld;qnd=mld;} + function wgd(a,b){var c,d,e,f,g;for(d=b,e=0,f=d.length;e=a.b.c.length){return}jwb(a,2*b+1);c=2*b+2;c0){b.Cd(c);c.i&&zKc(c);}}} + function Ejb(a,b,c){var d;for(d=c-1;d>=0&&a[d]===b[d];d--);return d<0?0:Ldb(Cdb(a[d],yxe),Cdb(b[d],yxe))?-1:1} + function it(a,b,c){var d,e;this.g=a;this.c=b;this.a=this;this.d=this;e=Wp(c);d=$C(UG,ewe,227,e,0,1);this.b=d;} + function fQb(a,b,c,d,e){var f,g;for(g=c;g<=e;g++){for(f=b;f<=d;f++){if(PPb(a,f,g)){return true}}}return false} + function Dc(a,b){var c,d;for(d=a.Zb().Cc().Kc();d.Ob();){c=RD(d.Pb(),16);if(c.Hc(b)){return true}}return false} + function iu(a,b,c){var d,e,f,g;uFb(c);g=false;f=a.fd(b);for(e=c.Kc();e.Ob();){d=e.Pb();f.Rb(d);g=true;}return g} + function NMd(a,b){var c,d;d=RD(Ywd(a.a,4),129);c=$C(d6,IJe,424,b,0,1);d!=null&&hib(d,0,c,0,d.length);return c} + function hSd(a,b){var c;c=new lSd((a.f&256)!=0,a.i,a.a,a.d,(a.f&16)!=0,a.j,a.g,b);a.e!=null||(c.c=a);return c} + function Tv(a,b){var c;if(a===b){return true}else if(ZD(b,85)){c=RD(b,85);return Rx(gn(a),c.vc())}return false} + function Vjb(a,b,c){var d,e;for(e=c.Kc();e.Ob();){d=RD(e.Pb(),44);if(a.Be(b,d.md())){return true}}return false} + function lmc(a,b,c){if(!a.d[b.p][c.p]){kmc(a,b,c);a.d[b.p][c.p]=true;a.d[c.p][b.p]=true;}return a.a[b.p][c.p]} + function vMc(a,b){var c;if(!a||a==b||!nQb(b,(Ywc(),pwc))){return false}c=RD(mQb(b,(Ywc(),pwc)),10);return c!=a} + function Bhe(a){switch(a.i){case 2:{return true}case 1:{return false}case -1:{++a.c;}default:{return a.$l()}}} + function Che(a){switch(a.i){case -2:{return true}case -1:{return false}case 1:{--a.c;}default:{return a._l()}}} + function bgb(a){oz.call(this,'The given string does not match the expected format for individual spacings.',a);} + function J6c(a,b){var c;b.Ug('Min Size Preprocessing',1);c=vsd(a);Ixd(a,(X6c(),U6c),c.a);Ixd(a,R6c,c.b);b.Vg();} + function Djd(a){var b,c,d;b=0;d=$C(l3,Nve,8,a.b,0,1);c=Sub(a,0);while(c.b!=c.d.c){d[b++]=RD(evb(c),8);}return d} + function Ajd(a,b,c){var d,e,f;d=new Yub;for(f=Sub(c,0);f.b!=f.d.c;){e=RD(evb(f),8);Mub(d,new sjd(e));}iu(a,b,d);} + function az(a,b){var c;c=Bdb(a,b);if(Ldb($db(a,b),0)|Jdb($db(a,c),0)){return c}return Bdb(Sve,$db(Udb(c,63),1))} + function le(a,b){var c,d;c=RD(a.d.Bc(b),16);if(!c){return null}d=a.e.hc();d.Gc(c);a.e.d-=c.gc();c.$b();return d} + function Dyb(a){var b;b=a.a.c.length;if(b>0){return lyb(b-1,a.a.c.length),Xmb(a.a,b-1)}else {throw Adb(new Srb)}} + function nFb(a,b,c){if(a>b){throw Adb(new agb(_xe+a+aye+b))}if(a<0||b>c){throw Adb(new xeb(_xe+a+bye+b+Qxe+c))}} + function yXd(a,b){if(a.D==null&&a.B!=null){a.D=a.B;a.B=null;}JXd(a,b==null?null:(uFb(b),b));!!a.C&&a.hl(null);} + function JCc(a,b){var c;c=iGd((QCc(),OCc))!=null&&b.Sg()!=null?Kfb(UD(b.Sg()))/Kfb(UD(iGd(OCc))):1;Zjb(a.b,b,c);} + function $Lc(a,b){var c,d;d=a.c[b];if(d==0){return}a.c[b]=0;a.d-=d;c=b+1;while(cDEe?a-c>DEe:c-a>DEe} + function vjd(a,b){var c;for(c=0;ce){ead(b.q,e);d=c!=b.q.d;}}return d} + function C3c(a,b){var c,d,e,f,g,h,i,j;i=b.i;j=b.j;d=a.f;e=d.i;f=d.j;g=i-e;h=j-f;c=$wnd.Math.sqrt(g*g+h*h);return c} + function pBd(a,b){var c,d;d=Hvd(a);if(!d){c=(gSd(),nSd(b));d=new Sde(c);WGd(d.El(),a);}return d} + function Sc(a,b){var c,d;c=RD(a.c.Bc(b),16);if(!c){return a.jc()}d=a.hc();d.Gc(c);a.d-=c.gc();c.$b();return a.mc(d)} + function tKc(a,b){var c,d;d=Kwb(a.d,1)!=0;c=true;while(c){c=false;c=b.c.mg(b.e,d);c=c|DKc(a,b,d,false);d=!d;}yKc(a);} + function omc(a,b,c,d){var e,f;a.a=b;f=d?0:1;a.f=(e=new mmc(a.c,a.a,c,f),new Pmc(c,a.a,e,a.e,a.b,a.c==(RKc(),PKc)));} + function Imb(a){var b;sFb(a.a!=a.b);b=a.d.a[a.a];zmb(a.b==a.d.c&&b!=null);a.c=a.a;a.a=a.a+1&a.d.a.length-1;return b} + function Vib(a){var b;if(a.c!=0){return a.c}for(b=0;b=a.c.b:a.a<=a.c.b)){throw Adb(new Dvb)}b=a.a;a.a+=a.c.c;++a.b;return sgb(b)} + function h5b(a){var b;b=new y2b(a.a);kQb(b,a);pQb(b,(Ywc(),Awc),a);b.o.a=a.g;b.o.b=a.f;b.n.a=a.i;b.n.b=a.j;return b} + function tVc(a){return (qpd(),hpd).Hc(a.j)?Kfb(UD(mQb(a,(Ywc(),Swc)))):xjd(cD(WC(l3,1),Nve,8,0,[a.i.n,a.n,a.a])).b} + function ZJc(a){var b;b=vfd(XJc);RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),kvc))&&pfd(b,(sXb(),pXb),(hcc(),Ybc));return b} + function M2c(a){var b,c,d,e;e=new _sb;for(d=new Anb(a);d.a=0?b:-b;while(d>0){if(d%2==0){c*=c;d=d/2|0;}else {e*=c;d-=1;}}return b<0?1/e:e} + function Jid(a,b){var c,d,e;e=1;c=a;d=b>=0?b:-b;while(d>0){if(d%2==0){c*=c;d=d/2|0;}else {e*=c;d-=1;}}return b<0?1/e:e} + function Vvd(a,b){var c,d,e,f;f=(e=a?Hvd(a):null,Pje((d=b,e?e.Gl():null,d)));if(f==b){c=Hvd(a);!!c&&c.Gl();}return f} + function g2d(a,b,c){var d,e;e=a.f;a.f=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,0,e,b);!c?(c=d):c.nj(d);}return c} + function e2d(a,b,c){var d,e;e=a.b;a.b=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,3,e,b);!c?(c=d):c.nj(d);}return c} + function rAd(a,b,c){var d,e;e=a.a;a.a=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,1,e,b);!c?(c=d):c.nj(d);}return c} + function SNd(a){var b,c;if(a!=null){for(c=0;c=d||b-129&&a<128){return ugb(),b=a+128,c=tgb[b],!c&&(c=tgb[b]=new fgb(a)),c}return new fgb(a)} + function bhb(a){var b,c;if(a>-129&&a<128){return dhb(),b=a+128,c=chb[b],!c&&(c=chb[b]=new Xgb(a)),c}return new Xgb(a)} + function M$b(a,b){var c;if(a.a.c.length>0){c=RD(Vmb(a.a,a.a.c.length-1),579);if(Q_b(c,b)){return}}Rmb(a.a,new S_b(b));} + function Ekc(a){lkc();var b,c;b=a.d.c-a.e.c;c=RD(a.g,154);Umb(c.b,new Ykc(b));Umb(c.c,new $kc(b));xgb(c.i,new alc(b));} + function Mlc(a){var b;b=new bib;b.a+='VerticalSegment ';Yhb(b,a.e);b.a+=' ';Zhb(b,Eb(new Gb,new Anb(a.k)));return b.a} + function Fmc(a,b){var c,d,e;c=0;for(e=b3b(a,b).Kc();e.Ob();){d=RD(e.Pb(),12);c+=mQb(d,(Ywc(),Iwc))!=null?1:0;}return c} + function VTc(a,b,c){var d,e,f;d=0;for(f=Sub(a,0);f.b!=f.d.c;){e=Kfb(UD(evb(f)));if(e>c){break}else e>=b&&++d;}return d} + function Wv(b,c){Qb(b);try{return b._b(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Nk(b,c){Qb(b);try{return b.Hc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Ok(b,c){Qb(b);try{return b.Mc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Xv(b,c){Qb(b);try{return b.xc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return null}else throw Adb(a)}} + function Yv(b,c){Qb(b);try{return b.Bc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return null}else throw Adb(a)}} + function aMc(a,b){switch(b.g){case 2:case 1:return b3b(a,b);case 3:case 4:return hv(b3b(a,b));}return yob(),yob(),vob} + function QAd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (name: ';Nhb(b,a.zb);b.a+=')';return b.a} + function Fgd(a){var b;b=RD(cub(a.c.c,''),233);if(!b){b=new fgd(ogd(ngd(new pgd,''),'Other'));dub(a.c.c,'',b);}return b} + function hBd(a,b,c){var d,e;e=a.sb;a.sb=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,4,e,b);!c?(c=d):c.nj(d);}return c} + function ZVd(a,b,c){var d,e;e=a.r;a.r=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,8,e,a.r);!c?(c=d):c.nj(d);}return c} + function q5d(a,b,c){var d,e;d=new P3d(a.e,4,13,(e=b.c,e?e:(JTd(),wTd)),null,fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function p5d(a,b,c){var d,e;d=new P3d(a.e,3,13,null,(e=b.c,e?e:(JTd(),wTd)),fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function Oee(a,b){var c,d;c=RD(b,691);d=c.el();!d&&c.fl(d=ZD(b,90)?new afe(a,RD(b,29)):new mfe(a,RD(b,156)));return d} + function KHd(a,b,c){var d;a._i(a.i+1);d=a.Zi(b,c);b!=a.i&&hib(a.g,b,a.g,b+1,a.i-b);bD(a.g,b,d);++a.i;a.Mi(b,c);a.Ni();} + function Hyb(a,b){var c;if(b.a){c=b.a.a.length;!a.a?(a.a=new dib(a.d)):Zhb(a.a,a.b);Xhb(a.a,b.a,b.d.length,c);}return a} + function wib(a,b){var c;a.c=b;a.a=pjb(b);a.a<54&&(a.f=(c=b.d>1?DFb(b.a[0],b.a[1]):DFb(b.a[0],0),Xdb(b.e>0?c:Odb(c))));} + function MDb(a,b){var c;c=new IEb;if(!a.a.Bd(c)){LCb(a);return Kvb(),Kvb(),Jvb}return Kvb(),new Ovb(uFb(LDb(a,c.a,b)))} + function t9b(a,b){var c;if(a.c.length==0){return}c=RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199);Znb(c,new F9b);q9b(c,b);} + function z9b(a,b){var c;if(a.c.length==0){return}c=RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199);Znb(c,new K9b);q9b(c,b);} + function pb(a,b){return bE(a)?lhb(a,b):_D(a)?Lfb(a,b):$D(a)?(uFb(a),dE(a)===dE(b)):YD(a)?a.Fb(b):aD(a)?mb(a,b):Hz(a,b)} + function Cvd(a,b,c){if(b<0){Tvd(a,c);}else {if(!c.rk()){throw Adb(new agb(KHe+c.xe()+LHe))}RD(c,69).wk().Ek(a,a.hi(),b);}} + function xFb(a,b,c){if(a<0||b>c){throw Adb(new veb(_xe+a+bye+b+', size: '+c))}if(a>b){throw Adb(new agb(_xe+a+aye+b))}} + function oVd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (source: ';Nhb(b,a.d);b.a+=')';return b.a} + function JSd(a){if(a>=65&&a<=70){return a-65+10}if(a>=97&&a<=102){return a-97+10}if(a>=48&&a<=57){return a-48}return 0} + function lMb(a){hMb();var b,c,d,e;for(c=nMb(),d=0,e=c.length;d=0?jjb(a):Xib(jjb(Odb(a)))));} + function G0b(a,b,c,d,e,f){this.e=new bnb;this.f=(BEc(),AEc);Rmb(this.e,a);this.d=b;this.a=c;this.b=d;this.f=e;this.c=f;} + function bQb(a,b,c){a.n=YC(lE,[Nve,rxe],[376,28],14,[c,eE($wnd.Math.ceil(b/32))],2);a.o=b;a.p=c;a.j=b-1>>1;a.k=c-1>>1;} + function ggb(a){a-=a>>1&1431655765;a=(a>>2&858993459)+(a&858993459);a=(a>>4)+a&252645135;a+=a>>8;a+=a>>16;return a&63} + function C4d(a,b){var c,d;for(d=new dMd(a);d.e!=d.i.gc();){c=RD(bMd(d),142);if(dE(b)===dE(c)){return true}}return false} + function Iee(a,b,c){var d,e,f;f=(e=N5d(a.b,b),e);if(f){d=RD(tfe(Pee(a,f),''),29);if(d){return Ree(a,d,b,c)}}return null} + function Lee(a,b,c){var d,e,f;f=(e=N5d(a.b,b),e);if(f){d=RD(tfe(Pee(a,f),''),29);if(d){return See(a,d,b,c)}}return null} + function IDd(a,b){var c;c=Ao(a.i,b);if(c==null){throw Adb(new CDd('Node did not exist in input.'))}wEd(b,c);return null} + function wvd(a,b){var c;c=wYd(a,b);if(ZD(c,331)){return RD(c,35)}throw Adb(new agb(KHe+b+"' is not a valid attribute"))} + function VGd(a,b,c){var d;d=a.gc();if(b>d)throw Adb(new aMd(b,d));if(a.Si()&&a.Hc(c)){throw Adb(new agb(LIe))}a.Gi(b,c);} + function w7b(a,b){b.Ug('Sort end labels',1);FDb(CDb(EDb(new SDb(null,new Swb(a.b,16)),new H7b),new J7b),new L7b);b.Vg();} + function Cmd(){Cmd=geb;Amd=new Gmd(Sye,0);zmd=new Gmd(Oye,1);ymd=new Gmd(Nye,2);xmd=new Gmd(Zye,3);Bmd=new Gmd('UP',4);} + function gbd(){gbd=geb;dbd=new hbd('P1_STRUCTURE',0);ebd=new hbd('P2_PROCESSING_ORDER',1);fbd=new hbd('P3_EXECUTION',2);} + function r0c(){r0c=geb;q0c=mfd(mfd(rfd(mfd(mfd(rfd(pfd(new ufd,(YVc(),VVc),(WYc(),VYc)),WVc),RYc),TYc),XVc),NYc),UYc);} + function s8b(a){switch(RD(mQb(a,(Ywc(),owc)),311).g){case 1:pQb(a,owc,(Gvc(),Dvc));break;case 2:pQb(a,owc,(Gvc(),Fvc));}} + function bUc(a){switch(a){case 0:return new mUc;case 1:return new cUc;case 2:return new hUc;default:throw Adb(new _fb);}} + function Fmd(a){switch(a.g){case 2:return zmd;case 1:return ymd;case 4:return xmd;case 3:return Bmd;default:return Amd;}} + function UNb(a,b){switch(a.b.g){case 0:case 1:return b;case 2:case 3:return new Uid(b.d,0,b.a,b.b);default:return null;}} + function rpd(a){switch(a.g){case 1:return ppd;case 2:return Yod;case 3:return Xod;case 4:return npd;default:return opd;}} + function spd(a){switch(a.g){case 1:return npd;case 2:return ppd;case 3:return Yod;case 4:return Xod;default:return opd;}} + function tpd(a){switch(a.g){case 1:return Xod;case 2:return npd;case 3:return ppd;case 4:return Yod;default:return opd;}} + function cyd(a,b,c,d){switch(b){case 1:return !a.n&&(a.n=new C5d(I4,a,1,7)),a.n;case 2:return a.k;}return Axd(a,b,c,d)} + function uLd(a,b,c){var d,e;if(a.Pj()){e=a.Qj();d=SHd(a,b,c);a.Jj(a.Ij(7,sgb(c),d,b,e));return d}else {return SHd(a,b,c)}} + function VNd(a,b){var c,d,e;if(a.d==null){++a.e;--a.f;}else {e=b.ld();c=b.Bi();d=(c&lve)%a.d.length;iOd(a,d,XNd(a,d,c,e));}} + function xWd(a,b){var c;c=(a.Bb&gwe)!=0;b?(a.Bb|=gwe):(a.Bb&=-1025);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,10,c,b));} + function DWd(a,b){var c;c=(a.Bb&qxe)!=0;b?(a.Bb|=qxe):(a.Bb&=-4097);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,12,c,b));} + function EWd(a,b){var c;c=(a.Bb&bKe)!=0;b?(a.Bb|=bKe):(a.Bb&=-8193);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,15,c,b));} + function FWd(a,b){var c;c=(a.Bb&cKe)!=0;b?(a.Bb|=cKe):(a.Bb&=-2049);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,11,c,b));} + function zKc(a){var b;if(a.g){b=a.c.kg()?a.f:a.a;BKc(b.a,a.o,true);BKc(b.a,a.o,false);pQb(a.o,(yCc(),BBc),(Bod(),vod));}} + function Orc(a){var b;if(!a.a){throw Adb(new dgb('Cannot offset an unassigned cut.'))}b=a.c-a.b;a.b+=b;Qrc(a,b);Rrc(a,b);} + function JDd(a,b){var c;c=Wjb(a.k,b);if(c==null){throw Adb(new CDd('Port did not exist in input.'))}wEd(b,c);return null} + function Jje(a){var b,c;for(c=Kje(BXd(a)).Kc();c.Ob();){b=WD(c.Pb());if(bAd(a,b)){return USd((TSd(),SSd),b)}}return null} + function qJb(a){var b,c;for(c=a.p.a.ec().Kc();c.Ob();){b=RD(c.Pb(),218);if(b.f&&a.b[b.c]<-1.0E-10){return b}}return null} + function Lr(a){var b,c;c=Thb(new bib,91);b=true;while(a.Ob()){b||(c.a+=pve,c);b=false;Yhb(c,a.Pb());}return (c.a+=']',c).a} + function o_b(a){var b,c,d;b=new bnb;for(d=new Anb(a.b);d.ab){return 1}if(a==b){return a==0?Qfb(1/a,1/b):0}return isNaN(a)?isNaN(b)?0:1:-1} + function pmb(a){var b;b=a.a[a.c-1&a.a.length-1];if(b==null){return null}a.c=a.c-1&a.a.length-1;bD(a.a,a.c,null);return b} + function Dqe(a){var b,c,d;d=0;c=a.length;for(b=0;b=1?zmd:xmd}return c} + function Xhc(a){switch(RD(mQb(a,(yCc(),yAc)),223).g){case 1:return new jqc;case 3:return new arc;default:return new dqc;}} + function MCb(a){if(a.c){MCb(a.c);}else if(a.d){throw Adb(new dgb("Stream already terminated, can't be modified or used"))}} + function Ltb(a,b,c){var d;d=a.a.get(b);a.a.set(b,c===undefined?null:c);if(d===undefined){++a.c;++a.b.g;}else {++a.d;}return d} + function HHc(a,b,c){var d,e;for(e=a.a.ec().Kc();e.Ob();){d=RD(e.Pb(),10);if(Be(c,RD(Vmb(b,d.p),16))){return d}}return null} + function u0c(a,b,c){var d;d=0;!!b&&(Emd(a.a)?(d+=b.f.a/2):(d+=b.f.b/2));!!c&&(Emd(a.a)?(d+=c.f.a/2):(d+=c.f.b/2));return d} + function LWb(a,b,c){var d;d=c;!d&&(d=Nqd(new Oqd,0));d.Ug(EAe,2);y0b(a.b,b,d.eh(1));NWb(a,b,d.eh(1));h0b(b,d.eh(1));d.Vg();} + function CGd(a,b,c){var d,e;d=(bvd(),e=new Xxd,e);Vxd(d,b);Wxd(d,c);!!a&&WGd((!a.a&&(a.a=new XZd(D4,a,5)),a.a),d);return d} + function kyd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (identifier: ';Nhb(b,a.k);b.a+=')';return b.a} + function kXd(a,b){var c;c=(a.Bb&QHe)!=0;b?(a.Bb|=QHe):(a.Bb&=-32769);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,18,c,b));} + function a6d(a,b){var c;c=(a.Bb&QHe)!=0;b?(a.Bb|=QHe):(a.Bb&=-32769);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,18,c,b));} + function AWd(a,b){var c;c=(a.Bb&Ove)!=0;b?(a.Bb|=Ove):(a.Bb&=-16385);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,16,c,b));} + function c6d(a,b){var c;c=(a.Bb&txe)!=0;b?(a.Bb|=txe):(a.Bb&=-65537);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,20,c,b));} + function qse(a){var b;b=$C(hE,zwe,28,2,15,1);a-=txe;b[0]=(a>>10)+uxe&Bwe;b[1]=(a&1023)+56320&Bwe;return Ihb(b,0,b.length)} + function Zfb(a){var b;b=Neb(a);if(b>3.4028234663852886E38){return oxe}else if(b<-3.4028234663852886E38){return pxe}return b} + function Bdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a+b;if(jxe'+aXc(b.c):'e_'+tb(b),!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))} + function rWc(a,b){return lhb(!!b.b&&!!b.c?aXc(b.b)+'->'+aXc(b.c):'e_'+tb(b),!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))} + function $y(a,b){Zy();return bz(pwe),$wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b))} + function Ymd(){Ymd=geb;Xmd=new Zmd(Sye,0);Vmd=new Zmd('POLYLINE',1);Umd=new Zmd('ORTHOGONAL',2);Wmd=new Zmd('SPLINES',3);} + function _6c(){_6c=geb;Z6c=new a7c('ASPECT_RATIO_DRIVEN',0);$6c=new a7c('MAX_SCALE_DRIVEN',1);Y6c=new a7c('AREA_DRIVEN',2);} + function Db(b,c,d){var e;try{Cb(b,c,d);}catch(a){a=zdb(a);if(ZD(a,606)){e=a;throw Adb(new Deb(e))}else throw Adb(a)}return c} + function Im(a){var b,c,d;for(c=0,d=a.length;cb&&d.Ne(a[f-1],a[f])>0;--f){g=a[f];bD(a,f,a[f-1]);bD(a,f-1,g);}}} + function Egd(a,b){var c,d,e,f,g;c=b.f;dub(a.c.d,c,b);if(b.g!=null){for(e=b.g,f=0,g=e.length;fb){fvb(c);break}}cvb(c,b);} + function Kic(a,b){var c,d,e;d=Zjc(b);e=Kfb(UD(hFc(d,(yCc(),TBc))));c=$wnd.Math.max(0,e/2-0.5);Iic(b,c,1);Rmb(a,new hjc(b,c));} + function L5c(a,b,c){var d;c.Ug('Straight Line Edge Routing',1);c.dh(b,eFe);d=RD(Gxd(b,(u2c(),t2c)),27);M5c(a,d);c.dh(b,gFe);} + function K9c(a,b){a.n.c.length==0&&Rmb(a.n,new _9c(a.s,a.t,a.i));Rmb(a.b,b);W9c(RD(Vmb(a.n,a.n.c.length-1),209),b);M9c(a,b);} + function Zrb(a){var b;this.a=(b=RD(a.e&&a.e(),9),new Fsb(b,RD(WEb(b,b.length),9),0));this.b=$C(jJ,rve,1,this.a.a.length,5,1);} + function jeb(a){var b;if(Array.isArray(a)&&a.Tm===keb){return nfb(rb(a))+'@'+(b=tb(a)>>>0,b.toString(16))}return a.toString()} + function jD(a,b){if(a.h==fxe&&a.m==0&&a.l==0){b&&(eD=hD(0,0,0));return gD((MD(),KD))}b&&(eD=hD(a.l,a.m,a.h));return hD(0,0,0)} + function _Gb(a,b){switch(b.g){case 2:return a.b;case 1:return a.c;case 4:return a.d;case 3:return a.a;default:return false;}} + function IYb(a,b){switch(b.g){case 2:return a.b;case 1:return a.c;case 4:return a.d;case 3:return a.a;default:return false;}} + function vyd(a,b,c,d){switch(b){case 3:return a.f;case 4:return a.g;case 5:return a.i;case 6:return a.j;}return cyd(a,b,c,d)} + function oIb(a,b){if(b==a.d){return a.e}else if(b==a.e){return a.d}else {throw Adb(new agb('Node '+b+' not part of edge '+a))}} + function Uvd(a,b){var c;c=wYd(a.Dh(),b);if(ZD(c,102)){return RD(c,19)}throw Adb(new agb(KHe+b+"' is not a valid reference"))} + function Bvd(a,b,c,d){if(b<0){Svd(a,c,d);}else {if(!c.rk()){throw Adb(new agb(KHe+c.xe()+LHe))}RD(c,69).wk().Ck(a,a.hi(),b,d);}} + function ig(a){var b;if(a.b){ig(a.b);if(a.b.d!=a.c){throw Adb(new Jrb)}}else if(a.d.dc()){b=RD(a.f.c.xc(a.e),16);!!b&&(a.d=b);}} + function VMb(a){RMb();var b,c,d,e;b=a.o.b;for(d=RD(RD(Qc(a.r,(qpd(),npd)),21),87).Kc();d.Ob();){c=RD(d.Pb(),117);e=c.e;e.b+=b;}} + function SRb(a){var b,c,d;this.a=new Iub;for(d=new Anb(a);d.a=e){return b.c+c}}return b.c+b.b.gc()} + function lQd(a,b){jQd();var c,d,e,f;d=iZd(a);e=b;Wnb(d,0,d.length,e);for(c=0;c0){d+=e;++c;}}c>1&&(d+=a.d*(c-1));return d} + function FFd(a){var b,c,d,e,f;f=HFd(a);c=cve(a.c);d=!c;if(d){e=new MB;sC(f,'knownLayouters',e);b=new QFd(e);xgb(a.c,b);}return f} + function fHd(a){var b,c,d;d=new Qhb;d.a+='[';for(b=0,c=a.gc();b0&&(BFb(b-1,a.length),a.charCodeAt(b-1)==58)&&!mSd(a,aSd,bSd)} + function Sib(a,b){var c;if(dE(a)===dE(b)){return true}if(ZD(b,92)){c=RD(b,92);return a.e==c.e&&a.d==c.d&&Tib(a,c.a)}return false} + function vpd(a){qpd();switch(a.g){case 4:return Yod;case 1:return Xod;case 3:return npd;case 2:return ppd;default:return opd;}} + function jBb(a){var b,c;if(a.b){return a.b}c=dBb?null:a.d;while(c){b=dBb?null:c.b;if(b){return b}c=dBb?null:c.d;}return SAb(),RAb} + function LJb(a){var b,c,d;d=Kfb(UD(a.a.of((umd(),cmd))));for(c=new Anb(a.a.Sf());c.a>5;b=a&31;d=$C(kE,Pwe,28,c+1,15,1);d[c]=1<3){e*=10;--f;}a=(a+(e>>1))/e|0;}d.i=a;return true} + function BYd(a,b){var c,d,e;c=(a.i==null&&rYd(a),a.i);d=b.Lj();if(d!=-1){for(e=c.length;d=0;--d){b=c[d];for(e=0;e>1;this.k=b-1>>1;} + function Dfd(a){Afd();if(RD(a.of((umd(),pld)),181).Hc((dqd(),bqd))){RD(a.of(Lld),181).Fc((Pod(),Ood));RD(a.of(pld),181).Mc(bqd);}} + function ndc(a){var b,c;b=a.d==(btc(),Ysc);c=jdc(a);b&&!c||!b&&c?pQb(a.a,(yCc(),Rzc),(Rjd(),Pjd)):pQb(a.a,(yCc(),Rzc),(Rjd(),Ojd));} + function QCc(){QCc=geb;GCc();OCc=(yCc(),bCc);PCc=dv(cD(WC(V5,1),kEe,149,0,[SBc,TBc,VBc,WBc,ZBc,$Bc,_Bc,aCc,dCc,fCc,UBc,XBc,cCc]));} + function RDb(a,b){var c;c=RD(zDb(a,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);return c.Qc(__c(c.gc()))} + function nXc(a,b){var c,d;d=new zAb(a.a.ad(b,true));if(d.a.gc()<=1){throw Adb(new Ngb)}c=d.a.ec().Kc();c.Pb();return RD(c.Pb(),40)} + function lQc(a,b,c){var d,e;d=Kfb(a.p[b.i.p])+Kfb(a.d[b.i.p])+b.n.b+b.a.b;e=Kfb(a.p[c.i.p])+Kfb(a.d[c.i.p])+c.n.b+c.a.b;return e-d} + function XHd(a,b){var c;if(a.i>0){if(b.lengtha.i&&bD(b,a.i,null);return b} + function MXd(a){var b;if((a.Db&64)!=0)return QAd(a);b=new Shb(QAd(a));b.a+=' (instanceClassName: ';Nhb(b,a.D);b.a+=')';return b.a} + function ySd(a){var b,c,d,e;e=0;for(c=0,d=a.length;c0){a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=XNd(a,e,d,b);return c!=-1}else {return false}} + function Nrb(a,b){var c,d;a.a=Bdb(a.a,1);a.c=$wnd.Math.min(a.c,b);a.b=$wnd.Math.max(a.b,b);a.d+=b;c=b-a.f;d=a.e+c;a.f=d-a.e-c;a.e=d;} + function yyd(a,b){switch(b){case 3:Ayd(a,0);return;case 4:Cyd(a,0);return;case 5:Dyd(a,0);return;case 6:Eyd(a,0);return;}hyd(a,b);} + function c3b(a,b){switch(b.g){case 1:return dr(a.j,(J3b(),E3b));case 2:return dr(a.j,(J3b(),G3b));default:return yob(),yob(),vob;}} + function zm(a){tm();var b;b=a.Pc();switch(b.length){case 0:return sm;case 1:return new Dy(Qb(b[0]));default:return new Kx(Im(b));}} + function kMd(b,c){b.Xj();try{b.d.bd(b.e++,c);b.f=b.d.j;b.g=-1;}catch(a){a=zdb(a);if(ZD(a,77)){throw Adb(new Jrb)}else throw Adb(a)}} + function a8d(){a8d=geb;$7d=new b8d;T7d=new e8d;U7d=new h8d;V7d=new k8d;W7d=new n8d;X7d=new q8d;Y7d=new t8d;Z7d=new w8d;_7d=new z8d;} + function YA(a,b){WA();var c,d;c=_A(($A(),$A(),ZA));d=null;b==c&&(d=RD(Xjb(VA,a),624));if(!d){d=new XA(a);b==c&&$jb(VA,a,d);}return d} + function zDc(a){wDc();var b;(!a.q?(yob(),yob(),wob):a.q)._b((yCc(),iBc))?(b=RD(mQb(a,iBc),203)):(b=RD(mQb(Y2b(a),jBc),203));return b} + function hFc(a,b){var c,d;d=null;if(nQb(a,(yCc(),YBc))){c=RD(mQb(a,YBc),96);c.pf(b)&&(d=c.of(b));}d==null&&(d=mQb(Y2b(a),b));return d} + function Ze(a,b){var c,d,e;if(ZD(b,44)){c=RD(b,44);d=c.ld();e=Xv(a.Rc(),d);return Hb(e,c.md())&&(e!=null||a.Rc()._b(d))}return false} + function $Nd(a,b){var c,d,e;if(a.f>0){a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=WNd(a,e,d,b);if(c){return c.md()}}return null} + function qLd(a,b,c){var d,e,f;if(a.Pj()){d=a.i;f=a.Qj();KHd(a,d,b);e=a.Ij(3,null,b,d,f);!c?(c=e):c.nj(e);}else {KHd(a,a.i,b);}return c} + function f$d(a,b,c){var d,e;d=new P3d(a.e,4,10,(e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)),null,fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function e$d(a,b,c){var d,e;d=new P3d(a.e,3,10,null,(e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)),fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function SMb(a){RMb();var b;b=new sjd(RD(a.e.of((umd(),nld)),8));if(a.B.Hc((dqd(),Ypd))){b.a<=0&&(b.a=20);b.b<=0&&(b.b=20);}return b} + function jjb(a){Pib();var b,c;c=Ydb(a);b=Ydb(Udb(a,32));if(b!=0){return new bjb(c,b)}if(c>10||c<0){return new ajb(1,c)}return Lib[c]} + function Mdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a%b;if(jxe=0){f=f.a[1];}else {e=f;f=f.a[0];}}return e} + function Qyb(a,b,c){var d,e,f;e=null;f=a.b;while(f){d=a.a.Ne(b,f.d);if(c&&d==0){return f}if(d<=0){f=f.a[0];}else {e=f;f=f.a[1];}}return e} + function rmc(a,b,c,d){var e,f,g;e=false;if(Lmc(a.f,c,d)){Omc(a.f,a.a[b][c],a.a[b][d]);f=a.a[b];g=f[d];f[d]=f[c];f[c]=g;e=true;}return e} + function Nqc(a,b,c){var d,e,f,g;e=RD(Wjb(a.b,c),183);d=0;for(g=new Anb(b.j);g.a>5;b&=31;e=a.d+c+(b==0?0:1);d=$C(kE,Pwe,28,e,15,1);rjb(d,a.a,c,b);f=new cjb(a.e,e,d);Rib(f);return f} + function zGc(a,b){var c,d,e;for(d=new is(Mr(a3b(a).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);e=c.d.i;if(e.c==b){return false}}return true} + function _Ec(a,b,c){var d,e,f,g,h;g=a.k;h=b.k;d=c[g.g][h.g];e=UD(hFc(a,d));f=UD(hFc(b,d));return $wnd.Math.max((uFb(e),e),(uFb(f),f))} + function lA(){if(Error.stackTraceLimit>0){$wnd.Error.stackTraceLimit=Error.stackTraceLimit=64;return true}return 'stack' in new Error} + function sGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))>0} + function uGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))<0} + function tGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))<=0} + function Efb(a,b){var c=0;while(!b[c]||b[c]==''){c++;}var d=b[c++];for(;c0&&this.b>0&&(this.g=Aad(this.c,this.b,this.a));} + function rC(f,a){var b=f.a;var c;a=String(a);b.hasOwnProperty(a)&&(c=b[a]);var d=(HC(),GC)[typeof c];var e=d?d(c):NC(typeof c);return e} + function uDd(a){var b,c,d;d=null;b=uIe in a.a;c=!b;if(c){throw Adb(new CDd('Every element must have an id.'))}d=tDd(qC(a,uIe));return d} + function Qqe(a){var b,c;c=Rqe(a);b=null;while(a.c==2){Mqe(a);if(!b){b=(Vse(),Vse(),new iue(2));hue(b,c);c=b;}c.Jm(Rqe(a));}return c} + function jOd(a,b){var c,d,e;a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=WNd(a,e,d,b);if(c){hOd(a,c);return c.md()}else {return null}} + function Qib(a,b){if(a.e>b.e){return 1}if(a.eb.d){return a.e}if(a.d=48&&a<48+$wnd.Math.min(10,10)){return a-48}if(a>=97&&a<97){return a-97+10}if(a>=65&&a<65){return a-65+10}return -1} + function UHc(a,b){if(b.c==a){return b.d}else if(b.d==a){return b.c}throw Adb(new agb('Input edge is not connected to the input port.'))} + function Fae(a){if(mhb(FGe,a)){return Geb(),Feb}else if(mhb(GGe,a)){return Geb(),Eeb}else {throw Adb(new agb('Expecting true or false'))}} + function jFb(a){switch(typeof(a)){case jve:return ohb(a);case ive:return Nfb(a);case hve:return Jeb(a);default:return a==null?0:kFb(a);}} + function mfd(a,b){if(a.a<0){throw Adb(new dgb('Did not call before(...) or after(...) before calling add(...).'))}tfd(a,a.a,b);return a} + function FId(a){EId();if(ZD(a,162)){return RD(Wjb(CId,zK),295).Rg(a)}if(Ujb(CId,rb(a))){return RD(Wjb(CId,rb(a)),295).Rg(a)}return null} + function Wwd(a){var b,c;if((a.Db&32)==0){c=(b=RD(Ywd(a,16),29),AYd(!b?a.ii():b)-AYd(a.ii()));c!=0&&$wd(a,32,$C(jJ,rve,1,c,5,1));}return a} + function $wd(a,b,c){var d;if((a.Db&b)!=0){if(c==null){Zwd(a,b);}else {d=Xwd(a,b);d==-1?(a.Eb=c):bD(SD(a.Eb),d,c);}}else c!=null&&Twd(a,b,c);} + function tTc(a,b,c,d){var e,f;if(b.c.length==0){return}e=pTc(c,d);f=oTc(b);FDb(PDb(new SDb(null,new Swb(f,1)),new CTc),new GTc(a,c,e,d));} + function rmb(a,b){var c,d,e,f;d=a.a.length-1;c=b-a.b&d;f=a.c-b&d;e=a.c-a.b&d;zmb(c=f){umb(a,b);return -1}else {vmb(a,b);return 1}} + function Hvd(a){var b,c,d;d=a.Jh();if(!d){b=0;for(c=a.Ph();c;c=c.Ph()){if(++b>wxe){return c.Qh()}d=c.Jh();if(!!d||c==a){break}}}return d} + function Ue(a,b){var c;if(dE(b)===dE(a)){return true}if(!ZD(b,21)){return false}c=RD(b,21);if(c.gc()!=a.gc()){return false}return a.Ic(c)} + function kNc(a,b){if(a.eb.e){return 1}else if(a.fb.f){return 1}return tb(a)-tb(b)} + function mhb(a,b){uFb(a);if(b==null){return false}if(lhb(a,b)){return true}return a.length==b.length&&lhb(a.toLowerCase(),b.toLowerCase())} + function Hgb(a){var b,c;if(Ddb(a,-129)>0&&Ddb(a,128)<0){return Jgb(),b=Ydb(a)+128,c=Igb[b],!c&&(c=Igb[b]=new zgb(a)),c}return new zgb(a)} + function U$b(){U$b=geb;T$b=new V$b(LAe,0);R$b=new V$b('INSIDE_PORT_SIDE_GROUPS',1);Q$b=new V$b('GROUP_MODEL_ORDER',2);S$b=new V$b(MAe,3);} + function ufe(a){var b;a.b||vfe(a,(b=Hee(a.e,a.a),!b||!lhb(GGe,$Nd((!b.b&&(b.b=new SVd((JTd(),FTd),C8,b)),b.b),'qualified'))));return a.c} + function BA(a,b){var c,d;c=(BFb(b,a.length),a.charCodeAt(b));d=b+1;while(d2000){Oz=a;Pz=$wnd.setTimeout(Yz,10);}}if(Nz++==0){_z(($z(),Zz));return true}return false} + function lBb(a,b,c){var d;(bBb?(jBb(a),true):cBb?(SAb(),true):fBb?(SAb(),true):eBb&&(SAb(),false))&&(d=new aBb(b),d.b=c,hBb(a,d),undefined);} + function oNb(a,b){var c;c=!a.A.Hc((Qpd(),Ppd))||a.q==(Bod(),wod);a.u.Hc((Pod(),Lod))?c?mNb(a,b):qNb(a,b):a.u.Hc(Nod)&&(c?nNb(a,b):rNb(a,b));} + function Bed(a){var b;if(dE(Gxd(a,(umd(),Xkd)))===dE((Fnd(),Dnd))){if(!vCd(a)){Ixd(a,Xkd,End);}else {b=RD(Gxd(vCd(a),Xkd),346);Ixd(a,Xkd,b);}}} + function _fc(a){var b,c;if(nQb(a.d.i,(yCc(),tBc))){b=RD(mQb(a.c.i,tBc),17);c=RD(mQb(a.d.i,tBc),17);return hgb(b.a,c.a)>0}else {return false}} + function g_b(a,b,c){return new Uid($wnd.Math.min(a.a,b.a)-c/2,$wnd.Math.min(a.b,b.b)-c/2,$wnd.Math.abs(a.a-b.a)+c,$wnd.Math.abs(a.b-b.b)+c)} + function _mc(a){var b;this.d=new bnb;this.j=new pjd;this.g=new pjd;b=a.g.b;this.f=RD(mQb(Y2b(b),(yCc(),rAc)),88);this.e=Kfb(UD(k2b(b,ZBc)));} + function onc(a){this.d=new bnb;this.e=new gub;this.c=$C(kE,Pwe,28,(qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,15,1);this.b=a;} + function $pc(a,b,c){var d;d=c[a.g][b];switch(a.g){case 1:case 3:return new rjd(0,d);case 2:case 4:return new rjd(d,0);default:return null;}} + function Ced(b,c,d){var e,f;f=RD(ltd(c.f),205);try{f.rf(b,d);mtd(c.f,f);}catch(a){a=zdb(a);if(ZD(a,103)){e=a;throw Adb(e)}else throw Adb(a)}} + function tEd(a,b,c){var d,e,f,g,h,i;d=null;h=vgd(ygd(),b);f=null;if(h){e=null;i=zhd(h,c);g=null;i!=null&&(g=a.qf(h,i));e=g;f=e;}d=f;return d} + function sSd(a,b,c,d){var e;e=a.length;if(b>=e)return e;for(b=b>0?b:0;bd&&bD(b,d,null);return b} + function lob(a,b){var c,d;d=a.a.length;b.lengthd&&bD(b,d,null);return b} + function Bde(a,b){var c,d;++a.j;if(b!=null){c=(d=a.a.Cb,ZD(d,99)?RD(d,99).th():null);if(Jnb(b,c)){$wd(a.a,4,c);return}}$wd(a.a,4,RD(b,129));} + function mne(a){var b;if(a==null)return null;b=Hqe(nue(a,true));if(b==null){throw Adb(new Mle("Invalid hexBinary value: '"+a+"'"))}return b} + function wA(a,b,c){var d;if(b.a.length>0){Rmb(a.b,new kB(b.a,c));d=b.a.length;0d&&(b.a+=Hhb($C(hE,zwe,28,-d,15,1)));}} + function yIb(a,b,c){var d,e,f;if(c[b.d]){return}c[b.d]=true;for(e=new Anb(CIb(b));e.a=a.b>>1){d=a.c;for(c=a.b;c>b;--c){d=d.b;}}else {d=a.a.a;for(c=0;c=0?a.Wh(e):Rvd(a,d)):c<0?Rvd(a,d):RD(d,69).wk().Bk(a,a.hi(),c)} + function Fxd(a){var b,c,d;d=(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),a.o);for(c=d.c.Kc();c.e!=c.i.gc();){b=RD(c.Yj(),44);b.md();}return dOd(d)} + function iGd(a){var b;if(ZD(a.a,4)){b=FId(a.a);if(b==null){throw Adb(new dgb(HGe+a.b+"'. "+DGe+(lfb(b6),b6.k)+EGe))}return b}else {return a.a}} + function iSd(a,b){var c,d;if(a.j.length!=b.j.length)return false;for(c=0,d=a.j.length;c=64&&b<128&&(e=Rdb(e,Sdb(1,b-64)));}return e} + function k2b(a,b){var c,d;d=null;if(nQb(a,(umd(),amd))){c=RD(mQb(a,amd),96);c.pf(b)&&(d=c.of(b));}d==null&&!!Y2b(a)&&(d=mQb(Y2b(a),b));return d} + function i0b(a,b){var c;c=RD(mQb(a,(yCc(),RAc)),75);if(br(b,f0b)){if(!c){c=new Ejd;pQb(a,RAc,c);}else {Xub(c);}}else !!c&&pQb(a,RAc,null);return c} + function tSb(){tSb=geb;sSb=(umd(),Yld);mSb=Ukd;hSb=Dkd;nSb=tld;qSb=(YHb(),UHb);pSb=SHb;rSb=WHb;oSb=RHb;jSb=(eSb(),aSb);iSb=_Rb;kSb=cSb;lSb=dSb;} + function PZb(a){NZb();this.c=new bnb;this.d=a;switch(a.g){case 0:case 2:this.a=Fob(MZb);this.b=oxe;break;case 3:case 1:this.a=MZb;this.b=pxe;}} + function c9b(a){var b;if(!Cod(RD(mQb(a,(yCc(),BBc)),101))){return}b=a.b;d9b((tFb(0,b.c.length),RD(b.c[0],30)));d9b(RD(Vmb(b,b.c.length-1),30));} + function ohc(a,b){b.Ug('Self-Loop post-processing',1);FDb(CDb(CDb(EDb(new SDb(null,new Swb(a.b,16)),new uhc),new whc),new yhc),new Ahc);b.Vg();} + function xrd(a,b,c){var d,e;if(a.c){Dyd(a.c,a.c.i+b);Eyd(a.c,a.c.j+c);}else {for(e=new Anb(a.b);e.a=0&&(c.d=a.t);break;case 3:a.t>=0&&(c.a=a.t);}if(a.C){c.b=a.C.b;c.c=a.C.c;}} + function JDc(){JDc=geb;IDc=new LDc(mEe,0);FDc=new LDc(BBe,1);GDc=new LDc('LINEAR_SEGMENTS',2);EDc=new LDc('BRANDES_KOEPF',3);HDc=new LDc(lEe,4);} + function IRb(){IRb=geb;FRb=new JRb(_ye,0);ERb=new JRb(aze,1);GRb=new JRb(bze,2);HRb=new JRb(cze,3);FRb.a=false;ERb.a=true;GRb.a=false;HRb.a=true;} + function IPb(){IPb=geb;FPb=new JPb(_ye,0);EPb=new JPb(aze,1);GPb=new JPb(bze,2);HPb=new JPb(cze,3);FPb.a=false;EPb.a=true;GPb.a=false;HPb.a=true;} + function Ivd(a,b,c,d){var e;if(c>=0){return a.Sh(b,c,d)}else {!!a.Ph()&&(d=(e=a.Fh(),e>=0?a.Ah(d):a.Ph().Th(a,-1-e,null,d)));return a.Ch(b,c,d)}} + function Zyd(a,b){switch(b){case 7:!a.e&&(a.e=new Yie(G4,a,7,4));sLd(a.e);return;case 8:!a.d&&(a.d=new Yie(G4,a,8,5));sLd(a.d);return;}yyd(a,b);} + function Ixd(a,b,c){c==null?(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),jOd(a.o,b)):(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),fOd(a.o,b,c));return a} + function Aob(a,b){yob();var c,d,e,f;c=a;f=b;if(ZD(a,21)&&!ZD(b,21)){c=b;f=a;}for(e=c.Kc();e.Ob();){d=e.Pb();if(f.Hc(d)){return false}}return true} + function qTc(a,b,c,d){if(b.ac.b){return true}}}return false} + function QD(a,b){if(bE(a)){return !!PD[b]}else if(a.Sm){return !!a.Sm[b]}else if(_D(a)){return !!OD[b]}else if($D(a)){return !!ND[b]}return false} + function udc(a){var b;b=a.a;do{b=RD(hs(new is(Mr(Z2b(b).a.Kc(),new ir))),18).c.i;b.k==(r3b(),o3b)&&a.b.Fc(b);}while(b.k==(r3b(),o3b));a.b=hv(a.b);} + function UGc(a,b){var c,d,e;e=a;for(d=new is(Mr(Z2b(b).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);!!c.c.i.c&&(e=$wnd.Math.max(e,c.c.i.c.p));}return e} + function INb(a,b){var c,d,e;e=0;d=RD(RD(Qc(a.r,b),21),87).Kc();while(d.Ob()){c=RD(d.Pb(),117);e+=c.d.d+c.b.Mf().b+c.d.a;d.Ob()&&(e+=a.w);}return e} + function AMb(a,b){var c,d,e;e=0;d=RD(RD(Qc(a.r,b),21),87).Kc();while(d.Ob()){c=RD(d.Pb(),117);e+=c.d.b+c.b.Mf().a+c.d.c;d.Ob()&&(e+=a.w);}return e} + function O2c(a){var b,c,d,e;d=0;e=Q2c(a);if(e.c.length==0){return 1}else {for(c=new Anb(e);c.a=0?a.Lh(g,c,true):Qvd(a,f,c)):RD(f,69).wk().yk(a,a.hi(),e,c,d)} + function aNb(a,b,c,d){var e,f;f=b.pf((umd(),ild))?RD(b.of(ild),21):a.j;e=lMb(f);if(e==(hMb(),gMb)){return}if(c&&!jMb(e)){return}LKb(cNb(a,e,d),b);} + function Y6b(a){switch(a.g){case 1:return mOb(),lOb;case 3:return mOb(),iOb;case 2:return mOb(),kOb;case 4:return mOb(),jOb;default:return null;}} + function kmc(a,b,c){if(a.e){switch(a.b){case 1:Ulc(a.c,b,c);break;case 0:Vlc(a.c,b,c);}}else {Slc(a.c,b,c);}a.a[b.p][c.p]=a.c.i;a.a[c.p][b.p]=a.c.e;} + function LLc(a){var b,c;if(a==null){return null}c=$C(jR,Nve,199,a.length,0,2);for(b=0;b=0)return e;if(a.ol()){for(d=0;d=e)throw Adb(new aMd(b,e));if(a.Si()){d=a.dd(c);if(d>=0&&d!=b){throw Adb(new agb(LIe))}}return a.Xi(b,c)} + function wx(a,b){this.a=RD(Qb(a),253);this.b=RD(Qb(b),253);if(a.Ed(b)>0||a==(Wk(),Vk)||b==(kl(),jl)){throw Adb(new agb('Invalid range: '+Dx(a,b)))}} + function p_b(a){var b,c;this.b=new bnb;this.c=a;this.a=false;for(c=new Anb(a.a);c.a0);if((b&-b)==b){return eE(b*Kwb(a,31)*4.6566128730773926E-10)}do{c=Kwb(a,31);d=c%b;}while(c-d+(b-1)<0);return eE(d)} + function d2b(a,b,c){switch(c.g){case 1:a.a=b.a/2;a.b=0;break;case 2:a.a=b.a;a.b=b.b/2;break;case 3:a.a=b.a/2;a.b=b.b;break;case 4:a.a=0;a.b=b.b/2;}} + function Onc(a,b,c,d){var e,f;for(e=b;e1&&(f=xIb(a,b));return f} + function yqd(a){var b;b=Kfb(UD(Gxd(a,(umd(),lmd))))*$wnd.Math.sqrt((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a).i);return new rjd(b,b/Kfb(UD(Gxd(a,kmd))))} + function Dzd(a){var b;if(!!a.f&&a.f.Vh()){b=RD(a.f,54);a.f=RD(Vvd(a,b),84);a.f!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,8,b,a.f));}return a.f} + function Ezd(a){var b;if(!!a.i&&a.i.Vh()){b=RD(a.i,54);a.i=RD(Vvd(a,b),84);a.i!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,7,b,a.i));}return a.i} + function Z5d(a){var b;if(!!a.b&&(a.b.Db&64)!=0){b=a.b;a.b=RD(Vvd(a,b),19);a.b!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,21,b,a.b));}return a.b} + function UNd(a,b){var c,d,e;if(a.d==null){++a.e;++a.f;}else {d=b.Bi();_Nd(a,a.f+1);e=(d&lve)%a.d.length;c=a.d[e];!c&&(c=a.d[e]=a.dk());c.Fc(b);++a.f;}} + function Mge(a,b,c){var d;if(b.tk()){return false}else if(b.Ik()!=-2){d=b.ik();return d==null?c==null:pb(d,c)}else return b.qk()==a.e.Dh()&&c==null} + function Io(){var a;dk(16,fwe);a=Wp(16);this.b=$C(XF,ewe,303,a,0,1);this.c=$C(XF,ewe,303,a,0,1);this.a=null;this.e=null;this.i=0;this.f=a-1;this.g=0;} + function j3b(a){v2b.call(this);this.k=(r3b(),p3b);this.j=(dk(6,iwe),new cnb(6));this.b=(dk(2,iwe),new cnb(2));this.d=new T2b;this.f=new C3b;this.a=a;} + function wgc(a){var b,c;if(a.c.length<=1){return}b=tgc(a,(qpd(),npd));vgc(a,RD(b.a,17).a,RD(b.b,17).a);c=tgc(a,ppd);vgc(a,RD(c.a,17).a,RD(c.b,17).a);} + function vHc(a,b,c){var d,e;e=a.a.b;for(d=e.c.length;d102)return -1;if(a<=57)return a-48;if(a<65)return -1;if(a<=70)return a-65+10;if(a<97)return -1;return a-97+10} + function ck(a,b){if(a==null){throw Adb(new Ogb('null key in entry: null='+b))}else if(b==null){throw Adb(new Ogb('null value in entry: '+a+'=null'))}} + function Cr(a,b){var c,d;while(a.Ob()){if(!b.Ob()){return false}c=a.Pb();d=b.Pb();if(!(dE(c)===dE(d)||c!=null&&pb(c,d))){return false}}return !b.Ob()} + function aLb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[gKb(a.a[0],b),gKb(a.a[1],b),gKb(a.a[2],b)]);if(a.d){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function bLb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[hKb(a.a[0],b),hKb(a.a[1],b),hKb(a.a[2],b)]);if(a.d){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function vIc(a,b,c){if(!Cod(RD(mQb(b,(yCc(),BBc)),101))){uIc(a,b,e3b(b,c));uIc(a,b,e3b(b,(qpd(),npd)));uIc(a,b,e3b(b,Yod));yob();_mb(b.j,new JIc(a));}} + function sUc(a){var b,c;a.c||vUc(a);c=new Ejd;b=new Anb(a.a);ynb(b);while(b.a0&&(BFb(0,b.length),b.charCodeAt(0)==43)?(BFb(1,b.length+1),b.substr(1)):b))} + function qne(a){var b;return a==null?null:new ejb((b=nue(a,true),b.length>0&&(BFb(0,b.length),b.charCodeAt(0)==43)?(BFb(1,b.length+1),b.substr(1)):b))} + function Syb(a,b,c,d,e,f,g,h){var i,j;if(!d){return}i=d.a[0];!!i&&Syb(a,b,c,i,e,f,g,h);Tyb(a,c,d.d,e,f,g,h)&&b.Fc(d);j=d.a[1];!!j&&Syb(a,b,c,j,e,f,g,h);} + function PPb(b,c,d){try{return Gdb(SPb(b,c,d),1)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function QPb(b,c,d){try{return Gdb(SPb(b,c,d),0)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function RPb(b,c,d){try{return Gdb(SPb(b,c,d),2)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function lMd(b,c){if(b.g==-1){throw Adb(new cgb)}b.Xj();try{b.d.hd(b.g,c);b.f=b.d.j;}catch(a){a=zdb(a);if(ZD(a,77)){throw Adb(new Jrb)}else throw Adb(a)}} + function Y7b(a){var b,c,d,e,f;for(d=new Anb(a.b);d.af&&bD(b,f,null);return b} + function av(a,b){var c,d;d=a.gc();if(b==null){for(c=0;c0&&(i+=e);j[k]=g;g+=h*(i+d);}} + function vsc(a){var b,c,d;d=a.f;a.n=$C(iE,vxe,28,d,15,1);a.d=$C(iE,vxe,28,d,15,1);for(b=0;b0?a.c:0);++e;}a.b=d;a.d=f;} + function rKb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[qKb(a,(ZJb(),WJb),b),qKb(a,XJb,b),qKb(a,YJb,b)]);if(a.f){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function cQb(b,c,d){var e;try{TPb(b,c+b.j,d+b.k,false,true);}catch(a){a=zdb(a);if(ZD(a,77)){e=a;throw Adb(new veb(e.g+ize+c+pve+d+').'))}else throw Adb(a)}} + function dQb(b,c,d){var e;try{TPb(b,c+b.j,d+b.k,true,false);}catch(a){a=zdb(a);if(ZD(a,77)){e=a;throw Adb(new veb(e.g+ize+c+pve+d+').'))}else throw Adb(a)}} + function u8b(a){var b;if(!nQb(a,(yCc(),dBc))){return}b=RD(mQb(a,dBc),21);if(b.Hc((dod(),Xnd))){b.Mc(Xnd);b.Fc(Znd);}else if(b.Hc(Znd)){b.Mc(Znd);b.Fc(Xnd);}} + function v8b(a){var b;if(!nQb(a,(yCc(),dBc))){return}b=RD(mQb(a,dBc),21);if(b.Hc((dod(),cod))){b.Mc(cod);b.Fc(aod);}else if(b.Hc(aod)){b.Mc(aod);b.Fc(cod);}} + function oqc(a,b,c,d){var e,f,g,h;a.a==null&&rqc(a,b);g=b.b.j.c.length;f=c.d.p;h=d.d.p;e=h-1;e<0&&(e=g-1);return f<=e?a.a[e]-a.a[f]:a.a[g-1]-a.a[f]+a.a[e]} + function Cud(a){var b,c;if(!a.b){a.b=fv(RD(a.f,27).kh().i);for(c=new dMd(RD(a.f,27).kh());c.e!=c.i.gc();){b=RD(bMd(c),135);Rmb(a.b,new Bud(b));}}return a.b} + function Dud(a){var b,c;if(!a.e){a.e=fv(wCd(RD(a.f,27)).i);for(c=new dMd(wCd(RD(a.f,27)));c.e!=c.i.gc();){b=RD(bMd(c),123);Rmb(a.e,new Rud(b));}}return a.e} + function yud(a){var b,c;if(!a.a){a.a=fv(tCd(RD(a.f,27)).i);for(c=new dMd(tCd(RD(a.f,27)));c.e!=c.i.gc();){b=RD(bMd(c),27);Rmb(a.a,new Fud(a,b));}}return a.a} + function DXd(b){var c;if(!b.C&&(b.D!=null||b.B!=null)){c=EXd(b);if(c){b.hl(c);}else {try{b.hl(null);}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}}return b.C} + function xMb(a){switch(a.q.g){case 5:uMb(a,(qpd(),Yod));uMb(a,npd);break;case 4:vMb(a,(qpd(),Yod));vMb(a,npd);break;default:wMb(a,(qpd(),Yod));wMb(a,npd);}} + function GNb(a){switch(a.q.g){case 5:DNb(a,(qpd(),Xod));DNb(a,ppd);break;case 4:ENb(a,(qpd(),Xod));ENb(a,ppd);break;default:FNb(a,(qpd(),Xod));FNb(a,ppd);}} + function G$b(a,b){var c,d,e;e=new pjd;for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);w$b(c,e.a,0);e.a+=c.f.a+b;e.b=$wnd.Math.max(e.b,c.f.b);}e.b>0&&(e.b+=b);return e} + function I$b(a,b){var c,d,e;e=new pjd;for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);w$b(c,0,e.b);e.b+=c.f.b+b;e.a=$wnd.Math.max(e.a,c.f.a);}e.a>0&&(e.a+=b);return e} + function l2b(a){var b,c,d;d=lve;for(c=new Anb(a.a);c.a>16==6){return a.Cb.Th(a,5,t7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?a.ii():c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function kA(a){fA();var b=a.e;if(b&&b.stack){var c=b.stack;var d=b+'\n';c.substring(0,d.length)==d&&(c=c.substring(d.length));return c.split('\n')}return []} + function pgb(a){var b;b=(wgb(),vgb);return b[a>>>28]|b[a>>24&15]<<4|b[a>>20&15]<<8|b[a>>16&15]<<12|b[a>>12&15]<<16|b[a>>8&15]<<20|b[a>>4&15]<<24|b[a&15]<<28} + function mmb(a){var b,c,d;if(a.b!=a.c){return}d=a.a.length;c=mgb($wnd.Math.max(8,d))<<1;if(a.b!=0){b=WEb(a.a,c);lmb(a,b,d);a.a=b;a.b=0;}else {aFb(a.a,c);}a.c=d;} + function uNb(a,b){var c;c=a.b;return c.pf((umd(),Gld))?c.ag()==(qpd(),ppd)?-c.Mf().a-Kfb(UD(c.of(Gld))):b+Kfb(UD(c.of(Gld))):c.ag()==(qpd(),ppd)?-c.Mf().a:b} + function X2b(a){var b;if(a.b.c.length!=0&&!!RD(Vmb(a.b,0),72).a){return RD(Vmb(a.b,0),72).a}b=R0b(a);if(b!=null){return b}return ''+(!a.c?-1:Wmb(a.c.a,a,0))} + function M3b(a){var b;if(a.f.c.length!=0&&!!RD(Vmb(a.f,0),72).a){return RD(Vmb(a.f,0),72).a}b=R0b(a);if(b!=null){return b}return ''+(!a.i?-1:Wmb(a.i.j,a,0))} + function skc(a,b){var c,d;if(b<0||b>=a.gc()){return null}for(c=b;c0?a.c:0);e=$wnd.Math.max(e,b.d);++d;}a.e=f;a.b=e;} + function Qud(a){var b,c;if(!a.b){a.b=fv(RD(a.f,123).kh().i);for(c=new dMd(RD(a.f,123).kh());c.e!=c.i.gc();){b=RD(bMd(c),135);Rmb(a.b,new Bud(b));}}return a.b} + function aHd(a,b){var c,d,e;if(b.dc()){return jQd(),jQd(),iQd}else {c=new ZLd(a,b.gc());for(e=new dMd(a);e.e!=e.i.gc();){d=bMd(e);b.Hc(d)&&WGd(c,d);}return c}} + function Axd(a,b,c,d){if(b==0){return d?(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),a.o):(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),dOd(a.o))}return Dvd(a,b,c,d)} + function rBd(a){var b,c;if(a.rb){for(b=0,c=a.rb.i;b>22);e+=d>>22;if(e<0){return false}a.l=c&dxe;a.m=d&dxe;a.h=e&exe;return true} + function Tyb(a,b,c,d,e,f,g){var h,i;if(b.Te()&&(i=a.a.Ne(c,d),i<0||!e&&i==0)){return false}if(b.Ue()&&(h=a.a.Ne(c,f),h>0||!g&&h==0)){return false}return true} + function Agc(a,b){sgc();var c;c=a.j.g-b.j.g;if(c!=0){return 0}switch(a.j.g){case 2:return Cgc(b,rgc)-Cgc(a,rgc);case 4:return Cgc(a,qgc)-Cgc(b,qgc);}return 0} + function uuc(a){switch(a.g){case 0:return nuc;case 1:return ouc;case 2:return puc;case 3:return quc;case 4:return ruc;case 5:return suc;default:return null;}} + function cBd(a,b,c){var d,e;d=(e=new R5d,YVd(e,b),PAd(e,c),WGd((!a.c&&(a.c=new C5d(u7,a,12,10)),a.c),e),e);$Vd(d,0);bWd(d,1);aWd(d,true);_Vd(d,true);return d} + function THd(a,b){var c,d;if(b>=a.i)throw Adb(new yNd(b,a.i));++a.j;c=a.g[b];d=a.i-b-1;d>0&&hib(a.g,b+1,a.g,b,d);bD(a.g,--a.i,null);a.Qi(b,c);a.Ni();return c} + function sWd(a,b){var c,d;if(a.Db>>16==17){return a.Cb.Th(a,21,h7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?a.ii():c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function _Fb(a){var b,c,d,e;yob();_mb(a.c,a.a);for(e=new Anb(a.c);e.ac.a.c.length)){throw Adb(new agb('index must be >= 0 and <= layer node count'))}!!a.c&&Ymb(a.c.a,a);a.c=c;!!c&&Qmb(c.a,b,a);} + function Gac(a,b){var c,d,e;for(d=new is(Mr(W2b(a).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);e=RD(b.Kb(c),10);return new cc(Qb(e.n.b+e.o.b/2))}return wb(),wb(),vb} + function RQc(a,b){this.c=new Tsb;this.a=a;this.b=b;this.d=RD(mQb(a,(Ywc(),Qwc)),312);dE(mQb(a,(yCc(),eBc)))===dE((Cuc(),Auc))?(this.e=new BRc):(this.e=new uRc);} + function ftd(a,b){var c,d;d=null;if(a.pf((umd(),amd))){c=RD(a.of(amd),96);c.pf(b)&&(d=c.of(b));}d==null&&!!a.Tf()&&(d=a.Tf().of(b));d==null&&(d=iGd(b));return d} + function ku(b,c){var d,e;d=b.fd(c);try{e=d.Pb();d.Qb();return e}catch(a){a=zdb(a);if(ZD(a,112)){throw Adb(new veb("Can't remove element "+c))}else throw Adb(a)}} + function GA(a,b){var c,d,e;d=new uB;e=new vB(d.q.getFullYear()-Owe,d.q.getMonth(),d.q.getDate());c=FA(a,b,e);if(c==0||c0?b:0);++c;}return new rjd(d,e)} + function Czd(a,b){var c,d;if(a.Db>>16==6){return a.Cb.Th(a,6,G4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),hvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function cCd(a,b){var c,d;if(a.Db>>16==7){return a.Cb.Th(a,1,H4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),jvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function LCd(a,b){var c,d;if(a.Db>>16==9){return a.Cb.Th(a,9,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),lvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function M1d(a,b){var c,d;if(a.Db>>16==5){return a.Cb.Th(a,9,m7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),tTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function qBd(a,b){var c,d;if(a.Db>>16==7){return a.Cb.Th(a,6,t7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),CTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function iVd(a,b){var c,d;if(a.Db>>16==3){return a.Cb.Th(a,0,p7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),mTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function IEd(){this.a=new BDd;this.g=new Io;this.j=new Io;this.b=new Tsb;this.d=new Io;this.i=new Io;this.k=new Tsb;this.c=new Tsb;this.e=new Tsb;this.f=new Tsb;} + function kQd(a,b,c){var d,e,f;c<0&&(c=0);f=a.i;for(e=c;ewxe){return Oje(a,d)}if(d==a){return true}}}return false} + function yNb(a){tNb();switch(a.q.g){case 5:vNb(a,(qpd(),Yod));vNb(a,npd);break;case 4:wNb(a,(qpd(),Yod));wNb(a,npd);break;default:xNb(a,(qpd(),Yod));xNb(a,npd);}} + function CNb(a){tNb();switch(a.q.g){case 5:zNb(a,(qpd(),Xod));zNb(a,ppd);break;case 4:ANb(a,(qpd(),Xod));ANb(a,ppd);break;default:BNb(a,(qpd(),Xod));BNb(a,ppd);}} + function RTb(a){var b,c;b=RD(mQb(a,(yVb(),mVb)),17);if(b){c=b.a;c==0?pQb(a,(JVb(),IVb),new Owb):pQb(a,(JVb(),IVb),new Pwb(c));}else {pQb(a,(JVb(),IVb),new Pwb(1));}} + function b2b(a,b){var c;c=a.i;switch(b.g){case 1:return -(a.n.b+a.o.b);case 2:return a.n.a-c.o.a;case 3:return a.n.b-c.o.b;case 4:return -(a.n.a+a.o.a);}return 0} + function wec(a,b){switch(a.g){case 0:return b==(cxc(),$wc)?sec:tec;case 1:return b==(cxc(),$wc)?sec:rec;case 2:return b==(cxc(),$wc)?rec:tec;default:return rec;}} + function Fad(a,b){var c,d,e;Ymb(a.a,b);a.e-=b.r+(a.a.c.length==0?0:a.c);e=fFe;for(d=new Anb(a.a);d.a>16==3){return a.Cb.Th(a,12,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),gvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function sCd(a,b){var c,d;if(a.Db>>16==11){return a.Cb.Th(a,10,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),kvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function n4d(a,b){var c,d;if(a.Db>>16==10){return a.Cb.Th(a,11,h7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),ATd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function Q5d(a,b){var c,d;if(a.Db>>16==10){return a.Cb.Th(a,12,s7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),DTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function WVd(a){var b;if((a.Bb&1)==0&&!!a.r&&a.r.Vh()){b=RD(a.r,54);a.r=RD(Vvd(a,b),142);a.r!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,8,b,a.r));}return a.r} + function pKb(a,b,c){var d;d=cD(WC(iE,1),vxe,28,15,[sKb(a,(ZJb(),WJb),b,c),sKb(a,XJb,b,c),sKb(a,YJb,b,c)]);if(a.f){d[0]=$wnd.Math.max(d[0],d[2]);d[2]=d[0];}return d} + function ddc(a,b){var c,d,e;e=kdc(a,b);if(e.c.length==0){return}_mb(e,new Gdc);c=e.c.length;for(d=0;d>19;j=b.h>>19;if(i!=j){return j-i}e=a.h;h=b.h;if(e!=h){return e-h}d=a.m;g=b.m;if(d!=g){return d-g}c=a.l;f=b.l;return c-f} + function YHb(){YHb=geb;XHb=(iIb(),fIb);WHb=new lGd(Aye,XHb);VHb=(LHb(),KHb);UHb=new lGd(Bye,VHb);THb=(DHb(),CHb);SHb=new lGd(Cye,THb);RHb=new lGd(Dye,(Geb(),true));} + function Iic(a,b,c){var d,e;d=b*c;if(ZD(a.g,154)){e=$jc(a);if(e.f.d){e.f.a||(a.d.a+=d+Tye);}else {a.d.d-=d+Tye;a.d.a+=d+Tye;}}else if(ZD(a.g,10)){a.d.d-=d;a.d.a+=2*d;}} + function _pc(a,b,c){var d,e,f,g,h;e=a[c.g];for(h=new Anb(b.d);h.a0?a.b:0);++c;}b.b=d;b.e=e;} + function Fo(a){var b,c,d;d=a.b;if(Xp(a.i,d.length)){c=d.length*2;a.b=$C(XF,ewe,303,c,0,1);a.c=$C(XF,ewe,303,c,0,1);a.f=c-1;a.i=0;for(b=a.a;b;b=b.c){Bo(a,b,b);}++a.g;}} + function VPb(a,b,c,d){var e,f,g,h;for(e=0;eg&&(h=g/d);e>f&&(i=f/e);ijd(a,$wnd.Math.min(h,i));return a} + function OAd(){qAd();var b,c;try{c=RD(M5d((YSd(),XSd),$He),2113);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new KAd} + function Qae(){qAd();var b,c;try{c=RD(M5d((YSd(),XSd),AKe),2040);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new Mae} + function vne(){Zme();var b,c;try{c=RD(M5d((YSd(),XSd),dLe),2122);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new rne} + function f2d(a,b,c){var d,e;e=a.e;a.e=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,4,e,b);!c?(c=d):c.nj(d);}e!=b&&(b?(c=o2d(a,k2d(a,b),c)):(c=o2d(a,a.a,c)));return c} + function DB(){uB.call(this);this.e=-1;this.a=false;this.p=qwe;this.k=-1;this.c=-1;this.b=-1;this.g=false;this.f=-1;this.j=-1;this.n=-1;this.i=-1;this.d=-1;this.o=qwe;} + function hHb(a,b){var c,d,e;d=a.b.d.d;a.a||(d+=a.b.d.a);e=b.b.d.d;b.a||(e+=b.b.d.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function XQb(a,b){var c,d,e;d=a.b.b.d;a.a||(d+=a.b.b.a);e=b.b.b.d;b.a||(e+=b.b.b.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function RYb(a,b){var c,d,e;d=a.b.g.d;a.a||(d+=a.b.g.a);e=b.b.g.d;b.a||(e+=b.b.g.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function _Wb(){_Wb=geb;YWb=nfd(pfd(pfd(pfd(new ufd,(sXb(),qXb),(hcc(),Dbc)),qXb,Hbc),rXb,Obc),rXb,rbc);$Wb=pfd(pfd(new ufd,qXb,hbc),qXb,sbc);ZWb=nfd(new ufd,rXb,ubc);} + function J6b(a){var b,c,d,e,f;b=RD(mQb(a,(Ywc(),cwc)),85);f=a.n;for(d=b.Cc().Kc();d.Ob();){c=RD(d.Pb(),314);e=c.i;e.c+=f.a;e.d+=f.b;c.c?MKb(c):OKb(c);}pQb(a,cwc,null);} + function Wpc(a,b,c){var d,e;e=a.b;d=e.d;switch(b.g){case 1:return -d.d-c;case 2:return e.o.a+d.c+c;case 3:return e.o.b+d.a+c;case 4:return -d.b-c;default:return -1;}} + function CNc(a,b,c){var d,e;c.Ug('Interactive node placement',1);a.a=RD(mQb(b,(Ywc(),Qwc)),312);for(e=new Anb(b.b);e.a0){g=(f&lve)%a.d.length;e=WNd(a,g,f,b);if(e){h=e.nd(c);return h}}d=a.ck(f,b,c);a.c.Fc(d);return null} + function Tee(a,b){var c,d,e,f;switch(Oee(a,b).Kl()){case 3:case 2:{c=mYd(b);for(e=0,f=c.i;e=0;d--){if(lhb(a[d].d,b)||lhb(a[d].d,c)){a.length>=d+1&&a.splice(0,d+1);break}}return a} + function Fdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a/b;if(jxe0){a.b+=2;a.a+=d;}}else {a.b+=1;a.a+=$wnd.Math.min(d,e);}} + function CVc(a){var b;b=RD(mQb(RD(ju(a.b,0),40),(h_c(),T$c)),107);pQb(a,(q$c(),SZc),new rjd(0,0));FVc(new YWc,a,b.b+b.c-Kfb(UD(mQb(a,ZZc))),b.d+b.a-Kfb(UD(mQb(a,_Zc))));} + function pDd(a,b){var c,d;d=false;if(bE(b)){d=true;oDd(a,new OC(WD(b)));}if(!d){if(ZD(b,242)){d=true;oDd(a,(c=Qeb(RD(b,242)),new hC(c)));}}if(!d){throw Adb(new Aeb(tIe))}} + function g$d(a,b,c,d){var e,f,g;e=new P3d(a.e,1,10,(g=b.c,ZD(g,90)?RD(g,29):(JTd(),zTd)),(f=c.c,ZD(f,90)?RD(f,29):(JTd(),zTd)),fZd(a,b),false);!d?(d=e):d.nj(e);return d} + function _2b(a){var b,c;switch(RD(mQb(Y2b(a),(yCc(),QAc)),429).g){case 0:b=a.n;c=a.o;return new rjd(b.a+c.a/2,b.b+c.b/2);case 1:return new sjd(a.n);default:return null;}} + function Ouc(){Ouc=geb;Luc=new Puc(LAe,0);Kuc=new Puc('LEFTUP',1);Nuc=new Puc('RIGHTUP',2);Juc=new Puc('LEFTDOWN',3);Muc=new Puc('RIGHTDOWN',4);Iuc=new Puc('BALANCED',5);} + function dKc(a,b,c){var d,e,f;d=Qfb(a.a[b.p],a.a[c.p]);if(d==0){e=RD(mQb(b,(Ywc(),qwc)),15);f=RD(mQb(c,qwc),15);if(e.Hc(c)){return -1}else if(f.Hc(b)){return 1}}return d} + function k5c(a){switch(a.g){case 1:return new K3c;case 2:return new M3c;case 3:return new I3c;case 0:return null;default:throw Adb(new agb(mFe+(a.f!=null?a.f:''+a.g)));}} + function gyd(a,b,c){switch(b){case 1:!a.n&&(a.n=new C5d(I4,a,1,7));sLd(a.n);!a.n&&(a.n=new C5d(I4,a,1,7));YGd(a.n,RD(c,16));return;case 2:jyd(a,WD(c));return;}Dxd(a,b,c);} + function xyd(a,b,c){switch(b){case 3:Ayd(a,Kfb(UD(c)));return;case 4:Cyd(a,Kfb(UD(c)));return;case 5:Dyd(a,Kfb(UD(c)));return;case 6:Eyd(a,Kfb(UD(c)));return;}gyd(a,b,c);} + function dBd(a,b,c){var d,e,f;f=(d=new R5d,d);e=XVd(f,b,null);!!e&&e.oj();PAd(f,c);WGd((!a.c&&(a.c=new C5d(u7,a,12,10)),a.c),f);$Vd(f,0);bWd(f,1);aWd(f,true);_Vd(f,true);} + function M5d(a,b){var c,d,e;c=Ktb(a.i,b);if(ZD(c,241)){e=RD(c,241);e.zi()==null&&undefined;return e.wi()}else if(ZD(c,507)){d=RD(c,2037);e=d.b;return e}else {return null}} + function aj(a,b,c,d){var e,f;Qb(b);Qb(c);f=RD(Fn(a.d,b),17);Ob(!!f,'Row %s not in %s',b,a.e);e=RD(Fn(a.b,c),17);Ob(!!e,'Column %s not in %s',c,a.c);return cj(a,f.a,e.a,d)} + function ZC(a,b,c,d,e,f,g){var h,i,j,k,l;k=e[f];j=f==g-1;h=j?d:0;l=_C(h,k);d!=10&&cD(WC(a,g-f),b[f],c[f],h,l);if(!j){++f;for(i=0;i1||h==-1){f=RD(i,15);e.Wb(Sje(a,f));}else {e.Wb(Rje(a,RD(i,58)));}}}} + function ceb(b,c,d,e){beb();var f=_db;function g(){for(var a=0;a0){return false}}return true} + function okc(a){var b,c,d,e,f;for(d=new vkb((new mkb(a.b)).a);d.b;){c=tkb(d);b=RD(c.ld(),10);f=RD(RD(c.md(),42).a,10);e=RD(RD(c.md(),42).b,8);$id(hjd(b.n),$id(ajd(f.n),e));}} + function Roc(a){switch(RD(mQb(a.b,(yCc(),BAc)),387).g){case 1:FDb(GDb(EDb(new SDb(null,new Swb(a.d,16)),new kpc),new mpc),new opc);break;case 2:Toc(a);break;case 0:Soc(a);}} + function SVc(a,b,c){var d,e,f;d=c;!d&&(d=new Oqd);d.Ug('Layout',a.a.c.length);for(f=new Anb(a.a);f.aAEe){return c}else e>-1.0E-6&&++c;}return c} + function n2d(a,b){var c;if(b!=a.b){c=null;!!a.b&&(c=Jvd(a.b,a,-4,c));!!b&&(c=Ivd(b,a,-4,c));c=e2d(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function q2d(a,b){var c;if(b!=a.f){c=null;!!a.f&&(c=Jvd(a.f,a,-1,c));!!b&&(c=Ivd(b,a,-1,c));c=g2d(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,b,b));} + function Lge(a,b,c,d){var e,f,g,h;if(Mvd(a.e)){e=b.Lk();h=b.md();f=c.md();g=fge(a,1,e,h,f,e.Jk()?kge(a,e,f,ZD(e,102)&&(RD(e,19).Bb&txe)!=0):-1,true);d?d.nj(g):(d=g);}return d} + function bne(a){var b,c,d;if(a==null)return null;c=RD(a,15);if(c.dc())return '';d=new Qhb;for(b=c.Kc();b.Ob();){Nhb(d,(nme(),WD(b.Pb())));d.a+=' ';}return qeb(d,d.a.length-1)} + function fne(a){var b,c,d;if(a==null)return null;c=RD(a,15);if(c.dc())return '';d=new Qhb;for(b=c.Kc();b.Ob();){Nhb(d,(nme(),WD(b.Pb())));d.a+=' ';}return qeb(d,d.a.length-1)} + function QIc(a,b,c){var d,e;d=a.c[b.c.p][b.p];e=a.c[c.c.p][c.p];if(d.a!=null&&e.a!=null){return Jfb(d.a,e.a)}else if(d.a!=null){return -1}else if(e.a!=null){return 1}return 0} + function RVc(a,b,c){c.Ug('Tree layout',1);Sed(a.b);Ved(a.b,(YVc(),UVc),UVc);Ved(a.b,VVc,VVc);Ved(a.b,WVc,WVc);Ved(a.b,XVc,XVc);a.a=Qed(a.b,b);SVc(a,b,c.eh(1));c.Vg();return b} + function ZDd(a,b){var c,d,e,f,g,h;if(b){f=b.a.length;c=new vue(f);for(h=(c.b-c.a)*c.c<0?(uue(),tue):new Rue(c);h.Ob();){g=RD(h.Pb(),17);e=xDd(b,g.a);d=new aFd(a);$Dd(d.a,e);}}} + function oEd(a,b){var c,d,e,f,g,h;if(b){f=b.a.length;c=new vue(f);for(h=(c.b-c.a)*c.c<0?(uue(),tue):new Rue(c);h.Ob();){g=RD(h.Pb(),17);e=xDd(b,g.a);d=new LEd(a);NDd(d.a,e);}}} + function ESd(b){var c;if(b!=null&&b.length>0&&ihb(b,b.length-1)==33){try{c=nSd(zhb(b,0,b.length-1));return c.e==null}catch(a){a=zdb(a);if(!ZD(a,33))throw Adb(a)}}return false} + function u0b(a,b,c){var d,e,f;d=Y2b(b);e=i2b(d);f=new R3b;P3b(f,b);switch(c.g){case 1:Q3b(f,spd(vpd(e)));break;case 2:Q3b(f,vpd(e));}pQb(f,(yCc(),ABc),UD(mQb(a,ABc)));return f} + function jdc(a){var b,c;b=RD(hs(new is(Mr(Z2b(a.a).a.Kc(),new ir))),18);c=RD(hs(new is(Mr(a3b(a.a).a.Kc(),new ir))),18);return Heb(TD(mQb(b,(Ywc(),Nwc))))||Heb(TD(mQb(c,Nwc)))} + function Bnc(){Bnc=geb;xnc=new Cnc('ONE_SIDE',0);znc=new Cnc('TWO_SIDES_CORNER',1);Anc=new Cnc('TWO_SIDES_OPPOSING',2);ync=new Cnc('THREE_SIDES',3);wnc=new Cnc('FOUR_SIDES',4);} + function Usc(a,b){var c,d,e,f;f=new bnb;e=0;d=b.Kc();while(d.Ob()){c=sgb(RD(d.Pb(),17).a+e);while(c.a=a.f){break}ZEb(f.c,c);}return f} + function iIc(a,b){var c,d,e,f,g;for(f=new Anb(b.a);f.a0&&Xlc(this,this.c-1,(qpd(),Xod));this.c0&&a[0].length>0&&(this.c=Heb(TD(mQb(Y2b(a[0][0]),(Ywc(),rwc)))));this.a=$C(aY,Nve,2117,a.length,0,2);this.b=$C(dY,Nve,2118,a.length,0,2);this.d=new Ks;} + function TOc(a){if(a.c.length==0){return false}if((tFb(0,a.c.length),RD(a.c[0],18)).c.i.k==(r3b(),o3b)){return true}return yDb(GDb(new SDb(null,new Swb(a,16)),new WOc),new YOc)} + function I5c(a,b){var c,d,e,f,g,h,i;h=Q2c(b);f=b.f;i=b.g;g=$wnd.Math.sqrt(f*f+i*i);e=0;for(d=new Anb(h);d.a=0){c=Fdb(a,ixe);d=Mdb(a,ixe);}else {b=Udb(a,1);c=Fdb(b,500000000);d=Mdb(b,500000000);d=Bdb(Sdb(d,1),Cdb(a,1));}return Rdb(Sdb(d,32),Cdb(c,yxe))} + function fTb(a,b,c){var d,e;d=(sFb(b.b!=0),RD(Wub(b,b.a.a),8));switch(c.g){case 0:d.b=0;break;case 2:d.b=a.f;break;case 3:d.a=0;break;default:d.a=a.g;}e=Sub(b,0);cvb(e,d);return b} + function Vpc(a,b,c,d){var e,f,g,h,i;i=a.b;f=b.d;g=f.j;h=$pc(g,i.d[g.g],c);e=$id(ajd(f.n),f.a);switch(f.j.g){case 1:case 3:h.a+=e.a;break;case 2:case 4:h.b+=e.b;}Pub(d,h,d.c.b,d.c);} + function YNc(a,b,c){var d,e,f,g;g=Wmb(a.e,b,0);f=new ZNc;f.b=c;d=new Jkb(a.e,g);while(d.b1;b>>=1){(b&1)!=0&&(d=Wib(d,c));c.d==1?(c=Wib(c,c)):(c=new djb(Tjb(c.a,c.d,$C(kE,Pwe,28,c.d<<1,15,1))));}d=Wib(d,c);return d} + function Hwb(){Hwb=geb;var a,b,c,d;Ewb=$C(iE,vxe,28,25,15,1);Fwb=$C(iE,vxe,28,33,15,1);d=1.52587890625E-5;for(b=32;b>=0;b--){Fwb[b]=d;d*=0.5;}c=1;for(a=24;a>=0;a--){Ewb[a]=c;c*=0.5;}} + function a5b(a){var b,c;if(Heb(TD(Gxd(a,(yCc(),NAc))))){for(c=new is(Mr(zGd(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),74);if(ozd(b)){if(Heb(TD(Gxd(b,OAc)))){return true}}}}return false} + function Qmc(a,b){var c,d,e;if(Ysb(a.f,b)){b.b=a;d=b.c;Wmb(a.j,d,0)!=-1||Rmb(a.j,d);e=b.d;Wmb(a.j,e,0)!=-1||Rmb(a.j,e);c=b.a.b;if(c.c.length!=0){!a.i&&(a.i=new _mc(a));Wmc(a.i,c);}}} + function Xpc(a){var b,c,d,e,f;c=a.c.d;d=c.j;e=a.d.d;f=e.j;if(d==f){return c.p=0&&lhb(a.substr(b,'GMT'.length),'GMT')){c[0]=b+3;return JA(a,c,d)}if(b>=0&&lhb(a.substr(b,'UTC'.length),'UTC')){c[0]=b+3;return JA(a,c,d)}return JA(a,c,d)} + function Zmc(a,b){var c,d,e,f,g;f=a.g.a;g=a.g.b;for(d=new Anb(a.d);d.ac;f--){a[f]|=b[f-c-1]>>>g;a[f-1]=b[f-c-1]<0&&hib(a.g,b,a.g,b+d,h);g=c.Kc();a.i+=d;for(e=0;e>4&15;f=a[d]&15;g[e++]=oAd[c];g[e++]=oAd[f];}return Ihb(g,0,g.length)}} + function Fhb(a){var b,c;if(a>=txe){b=uxe+(a-txe>>10&1023)&Bwe;c=56320+(a-txe&1023)&Bwe;return String.fromCharCode(b)+(''+String.fromCharCode(c))}else {return String.fromCharCode(a&Bwe)}} + function UMb(a,b){RMb();var c,d,e,f;e=RD(RD(Qc(a.r,b),21),87);if(e.gc()>=2){d=RD(e.Kc().Pb(),117);c=a.u.Hc((Pod(),Kod));f=a.u.Hc(Ood);return !d.a&&!c&&(e.gc()==2||f)}else {return false}} + function v3c(a,b,c,d,e){var f,g,h;f=w3c(a,b,c,d,e);h=false;while(!f){n3c(a,e,true);h=true;f=w3c(a,b,c,d,e);}h&&n3c(a,e,false);g=N2c(e);if(g.c.length!=0){!!a.d&&a.d.Gg(g);v3c(a,e,c,d,g);}} + function ind(){ind=geb;gnd=new jnd(LAe,0);end=new jnd('DIRECTED',1);hnd=new jnd('UNDIRECTED',2);cnd=new jnd('ASSOCIATION',3);fnd=new jnd('GENERALIZATION',4);dnd=new jnd('DEPENDENCY',5);} + function nsd(a,b){var c;if(!MCd(a)){throw Adb(new dgb(sHe))}c=MCd(a);switch(b.g){case 1:return -(a.j+a.f);case 2:return a.i-c.g;case 3:return a.j-c.f;case 4:return -(a.i+a.g);}return 0} + function Jge(a,b,c){var d,e,f;d=b.Lk();f=b.md();e=d.Jk()?fge(a,4,d,f,null,kge(a,d,f,ZD(d,102)&&(RD(d,19).Bb&txe)!=0),true):fge(a,d.tk()?2:1,d,f,d.ik(),-1,true);c?c.nj(e):(c=e);return c} + function lwb(a,b){var c,d;uFb(b);d=a.b.c.length;Rmb(a.b,b);while(d>0){c=d;d=(d-1)/2|0;if(a.a.Ne(Vmb(a.b,d),b)<=0){$mb(a.b,c,b);return true}$mb(a.b,c,Vmb(a.b,d));}$mb(a.b,d,b);return true} + function sKb(a,b,c,d){var e,f;e=0;if(!c){for(f=0;f=h} + function A8c(a){switch(a.g){case 0:return new o8c;case 1:return new u8c;default:throw Adb(new agb('No implementation is available for the width approximator '+(a.f!=null?a.f:''+a.g)));}} + function rDd(a,b,c,d){var e;e=false;if(bE(d)){e=true;sDd(b,c,WD(d));}if(!e){if($D(d)){e=true;rDd(a,b,c,d);}}if(!e){if(ZD(d,242)){e=true;qDd(b,c,RD(d,242));}}if(!e){throw Adb(new Aeb(tIe))}} + function uee(a,b){var c,d,e;c=b.qi(a.a);if(c){e=$Nd((!c.b&&(c.b=new SVd((JTd(),FTd),C8,c)),c.b),rKe);if(e!=null){for(d=1;d<(lke(),hke).length;++d){if(lhb(hke[d],e)){return d}}}}return 0} + function vee(a,b){var c,d,e;c=b.qi(a.a);if(c){e=$Nd((!c.b&&(c.b=new SVd((JTd(),FTd),C8,c)),c.b),rKe);if(e!=null){for(d=1;d<(lke(),ike).length;++d){if(lhb(ike[d],e)){return d}}}}return 0} + function Ve(a,b){var c,d,e,f;uFb(b);f=a.a.gc();if(f0?1:0;while(f.a[e]!=c){f=f.a[e];e=a.a.Ne(c.d,f.d)>0?1:0;}f.a[e]=d;d.b=c.b;d.a[0]=c.a[0];d.a[1]=c.a[1];c.a[0]=null;c.a[1]=null;} + function zIb(a){var b,c,d,e;b=new bnb;c=$C(xdb,Hye,28,a.a.c.length,16,1);Snb(c,c.length);for(e=new Anb(a.a);e.a0&&O9b((tFb(0,c.c.length),RD(c.c[0],30)),a);c.c.length>1&&O9b(RD(Vmb(c,c.c.length-1),30),a);b.Vg();} + function Sod(a){Pod();var b,c;b=ysb(Lod,cD(WC(D3,1),jwe,279,0,[Nod]));if(dy(Tx(b,a))>1){return false}c=ysb(Kod,cD(WC(D3,1),jwe,279,0,[Jod,Ood]));if(dy(Tx(c,a))>1){return false}return true} + function FBd(a,b){var c;c=Xjb((YSd(),XSd),a);ZD(c,507)?$jb(XSd,a,new B5d(this,b)):$jb(XSd,a,this);BBd(this,b);if(b==(jTd(),iTd)){this.wb=RD(this,2038);RD(b,2040);}else {this.wb=(lTd(),kTd);}} + function Lae(b){var c,d,e;if(b==null){return null}c=null;for(d=0;d=Awe?'error':d>=900?'warn':d>=800?'info':'log');eFb(c,a.a);!!a.b&&fFb(b,c,a.b,'Exception: ',true);} + function mQb(a,b){var c,d;d=(!a.q&&(a.q=new Tsb),Wjb(a.q,b));if(d!=null){return d}c=b.Sg();ZD(c,4)&&(c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c)),a);return c} + function sXb(){sXb=geb;nXb=new tXb('P1_CYCLE_BREAKING',0);oXb=new tXb('P2_LAYERING',1);pXb=new tXb('P3_NODE_ORDERING',2);qXb=new tXb('P4_NODE_PLACEMENT',3);rXb=new tXb('P5_EDGE_ROUTING',4);} + function KZb(a,b){CZb();var c;if(a.c==b.c){if(a.b==b.b||rZb(a.b,b.b)){c=oZb(a.b)?1:-1;if(a.a&&!b.a){return c}else if(!a.a&&b.a){return -c}}return hgb(a.b.g,b.b.g)}else {return Qfb(a.c,b.c)}} + function E3c(a,b){var c,d,e;if(p3c(a,b)){return true}for(d=new Anb(b);d.a=e||b<0)throw Adb(new veb(MIe+b+NIe+e));if(c>=e||c<0)throw Adb(new veb(OIe+c+NIe+e));b!=c?(d=(f=a.Cj(c),a.qj(b,f),f)):(d=a.xj(c));return d} + function Lje(a){var b,c,d;d=a;if(a){b=0;for(c=a.Eh();c;c=c.Eh()){if(++b>wxe){return Lje(c)}d=c;if(c==a){throw Adb(new dgb('There is a cycle in the containment hierarchy of '+a))}}}return d} + function Fe(a){var b,c,d;d=new Jyb(pve,'[',']');for(c=a.Kc();c.Ob();){b=c.Pb();Gyb(d,dE(b)===dE(a)?'(this Collection)':b==null?vve:jeb(b));}return !d.a?d.c:d.e.length==0?d.a.a:d.a.a+(''+d.e)} + function p3c(a,b){var c,d;d=false;if(b.gc()<2){return false}for(c=0;c1&&(a.j.b+=a.e);}else {a.j.a+=c.a;a.j.b=$wnd.Math.max(a.j.b,c.b);a.d.c.length>1&&(a.j.a+=a.e);}} + function Mnc(){Mnc=geb;Jnc=cD(WC(E3,1),NAe,64,0,[(qpd(),Yod),Xod,npd]);Inc=cD(WC(E3,1),NAe,64,0,[Xod,npd,ppd]);Knc=cD(WC(E3,1),NAe,64,0,[npd,ppd,Yod]);Lnc=cD(WC(E3,1),NAe,64,0,[ppd,Yod,Xod]);} + function Upc(a,b,c,d){var e,f,g,h,i,j,k;g=a.c.d;h=a.d.d;if(g.j==h.j){return}k=a.b;e=g.j;i=null;while(e!=h.j){i=b==0?tpd(e):rpd(e);f=$pc(e,k.d[e.g],c);j=$pc(i,k.d[i.g],c);Mub(d,$id(f,j));e=i;}} + function OJc(a,b,c,d){var e,f,g,h,i;g=hMc(a.a,b,c);h=RD(g.a,17).a;f=RD(g.b,17).a;if(d){i=RD(mQb(b,(Ywc(),Iwc)),10);e=RD(mQb(c,Iwc),10);if(!!i&&!!e){Slc(a.b,i,e);h+=a.b.i;f+=a.b.e;}}return h>f} + function OLc(a){var b,c,d,e,f,g,h,i,j;this.a=LLc(a);this.b=new bnb;for(c=a,d=0,e=c.length;damc(a.d).c){a.i+=a.g.c;cmc(a.d);}else if(amc(a.d).c>amc(a.g).c){a.e+=a.d.c;cmc(a.g);}else {a.i+=_lc(a.g);a.e+=_lc(a.d);cmc(a.g);cmc(a.d);}}} + function vTc(a,b,c){var d,e,f,g;f=b.q;g=b.r;new bTc((fTc(),dTc),b,f,1);new bTc(dTc,f,g,1);for(e=new Anb(c);e.ah&&(i=h/d);e>f&&(j=f/e);g=$wnd.Math.min(i,j);a.a+=g*(b.a-a.a);a.b+=g*(b.b-a.b);} + function I8c(a,b,c,d,e){var f,g;g=false;f=RD(Vmb(c.b,0),27);while(V8c(a,b,f,d,e)){g=true;T9c(c,f);if(c.b.c.length==0){break}f=RD(Vmb(c.b,0),27);}c.b.c.length==0&&Fad(c.j,c);g&&gad(b.q);return g} + function Eid(a,b){tid();var c,d,e,f;if(b.b<2){return false}f=Sub(b,0);c=RD(evb(f),8);d=c;while(f.b!=f.d.c){e=RD(evb(f),8);if(Did(a,d,e)){return true}d=e;}if(Did(a,d,c)){return true}return false} + function Bxd(a,b,c,d){var e,f;if(c==0){return !a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),BVd(a.o,b,d)}return f=RD(vYd((e=RD(Ywd(a,16),29),!e?a.ii():e),c),69),f.wk().Ak(a,Wwd(a),c-AYd(a.ii()),b,d)} + function BBd(a,b){var c;if(b!=a.sb){c=null;!!a.sb&&(c=RD(a.sb,54).Th(a,1,n7,c));!!b&&(c=RD(b,54).Rh(a,1,n7,c));c=hBd(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,4,b,b));} + function YDd(a,b){var c,d,e,f;if(b){e=vDd(b,'x');c=new ZEd(a);Hzd(c.a,(uFb(e),e));f=vDd(b,'y');d=new $Ed(a);Izd(d.a,(uFb(f),f));}else {throw Adb(new CDd('All edge sections need an end point.'))}} + function WDd(a,b){var c,d,e,f;if(b){e=vDd(b,'x');c=new WEd(a);Ozd(c.a,(uFb(e),e));f=vDd(b,'y');d=new XEd(a);Pzd(d.a,(uFb(f),f));}else {throw Adb(new CDd('All edge sections need a start point.'))}} + function hBb(a,b){var c,d,e,f,g,h,i;for(d=kBb(a),f=0,h=d.length;f>22-b;e=a.h<>22-b;}else if(b<44){c=0;d=a.l<>44-b;}else {c=0;d=0;e=a.l<a){throw Adb(new agb('k must be smaller than n'))}else return b==0||b==a?1:a==0?0:Bid(a)/(Bid(b)*Bid(a-b))} + function msd(a,b){var c,d,e,f;c=new zId(a);while(c.g==null&&!c.c?sId(c):c.g==null||c.i!=0&&RD(c.g[c.i-1],51).Ob()){f=RD(tId(c),58);if(ZD(f,167)){d=RD(f,167);for(e=0;e>4];b[c*2+1]=Fqe[f&15];}return Ihb(b,0,b.length)} + function sn(a){fn();var b,c,d;d=a.c.length;switch(d){case 0:return en;case 1:b=RD(Ir(new Anb(a)),44);return xn(b.ld(),b.md());default:c=RD(anb(a,$C(UK,Zve,44,a.c.length,0,1)),173);return new Mx(c);}} + function KWb(a){var b,c,d,e,f,g;b=new wmb;c=new wmb;hmb(b,a);hmb(c,a);while(c.b!=c.c){e=RD(smb(c),36);for(g=new Anb(e.a);g.a0&&uLc(a,c,b);return e}return rLc(a,b,c)} + function $4c(){$4c=geb;R4c=(umd(),Qld);Y4c=fmd;K4c=kld;L4c=nld;M4c=pld;J4c=ild;N4c=sld;Q4c=Lld;H4c=(D4c(),o4c);I4c=p4c;T4c=v4c;W4c=y4c;U4c=w4c;V4c=x4c;O4c=r4c;P4c=t4c;S4c=u4c;X4c=z4c;Z4c=B4c;G4c=n4c;} + function P9c(a,b){var c,d,e,f,g;if(a.e<=b){return a.g}if(R9c(a,a.g,b)){return a.g}f=a.r;d=a.g;g=a.r;e=(f-d)/2+d;while(d+11&&(a.e.b+=a.a);}else {a.e.a+=c.a;a.e.b=$wnd.Math.max(a.e.b,c.b);a.d.c.length>1&&(a.e.a+=a.a);}} + function Ipc(a){var b,c,d,e;e=a.i;b=e.b;d=e.j;c=e.g;switch(e.a.g){case 0:c.a=(a.g.b.o.a-d.a)/2;break;case 1:c.a=b.d.n.a+b.d.a.a;break;case 2:c.a=b.d.n.a+b.d.a.a-d.a;break;case 3:c.b=b.d.n.b+b.d.a.b;}} + function oOc(a,b,c){var d,e,f;for(e=new is(Mr(W2b(c).a.Kc(),new ir));gs(e);){d=RD(hs(e),18);if(!(!W0b(d)&&!(!W0b(d)&&d.c.i.c==d.d.i.c))){continue}f=gOc(a,d,c,new VOc);f.c.length>1&&(ZEb(b.c,f),true);}} + function _id(a,b,c,d,e){if(dd&&(a.a=d);a.be&&(a.b=e);return a} + function LFd(a){if(ZD(a,143)){return EFd(RD(a,143))}else if(ZD(a,233)){return FFd(RD(a,233))}else if(ZD(a,23)){return GFd(RD(a,23))}else {throw Adb(new agb(wIe+Fe(new mob(cD(WC(jJ,1),rve,1,5,[a])))))}} + function ujb(a,b,c,d,e){var f,g,h;f=true;for(g=0;g>>e|c[g+d+1]<>>e;++g;}return f} + function ZQc(a,b,c,d){var e,f,g;if(b.k==(r3b(),o3b)){for(f=new is(Mr(Z2b(b).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);g=e.c.i.k;if(g==o3b&&a.c.a[e.c.i.c.p]==d&&a.c.a[b.c.p]==c){return true}}}return false} + function CD(a,b){var c,d,e,f;b&=63;c=a.h&exe;if(b<22){f=c>>>b;e=a.m>>b|c<<22-b;d=a.l>>b|a.m<<22-b;}else if(b<44){f=0;e=c>>>b-22;d=a.m>>b-22|a.h<<44-b;}else {f=0;e=0;d=c>>>b-44;}return hD(d&dxe,e&dxe,f&exe)} + function mmc(a,b,c,d){var e;this.b=d;this.e=a==(RKc(),PKc);e=b[c];this.d=YC(xdb,[Nve,Hye],[183,28],16,[e.length,e.length],2);this.a=YC(kE,[Nve,Pwe],[53,28],15,[e.length,e.length],2);this.c=new Ylc(b,c);} + function Rmc(a){var b,c,d;a.k=new Si((qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,a.j.c.length);for(d=new Anb(a.j);d.a=c){_cc(a,b,d.p);return true}}return false} + function EA(a,b,c,d){var e,f,g,h,i,j;g=c.length;f=0;e=-1;j=Bhb((BFb(b,a.length+1),a.substr(b)),(wvb(),uvb));for(h=0;hf&&whb(j,Bhb(c[h],uvb))){e=h;f=i;}}e>=0&&(d[0]=b+f);return e} + function gCd(a){var b;if((a.Db&64)!=0)return Fyd(a);b=new dib(FHe);!a.a||Zhb(Zhb((b.a+=' "',b),a.a),'"');Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function xge(a,b,c){var d,e,f,g,h;h=pke(a.e.Dh(),b);e=RD(a.g,124);d=0;for(g=0;gc){return Jb(a,c,'start index')}if(b<0||b>c){return Jb(b,c,'end index')}return hc('end index (%s) must not be less than start index (%s)',cD(WC(jJ,1),rve,1,5,[sgb(b),sgb(a)]))} + function dA(b,c){var d,e,f,g;for(e=0,f=b.length;e0&&aGc(a,f,c));}}b.p=0;} + function Ahd(a){var b;this.c=new Yub;this.f=a.e;this.e=a.d;this.i=a.g;this.d=a.c;this.b=a.b;this.k=a.j;this.a=a.a;!a.i?(this.j=(b=RD(mfb(d3),9),new Fsb(b,RD(WEb(b,b.length),9),0))):(this.j=a.i);this.g=a.f;} + function Wb(a){var b,c,d,e;b=Thb(Zhb(new dib('Predicates.'),'and'),40);c=true;for(e=new Dkb(a);e.b0?h[g-1]:$C(jR,WAe,10,0,0,1);e=h[g];j=g=0?a.ki(e):Tvd(a,d);}else {throw Adb(new agb(KHe+d.xe()+LHe))}}else {Cvd(a,c,d);}} + function ADd(a){var b,c;c=null;b=false;if(ZD(a,211)){b=true;c=RD(a,211).a;}if(!b){if(ZD(a,263)){b=true;c=''+RD(a,263).a;}}if(!b){if(ZD(a,493)){b=true;c=''+RD(a,493).a;}}if(!b){throw Adb(new Aeb(tIe))}return c} + function gge(a,b,c){var d,e,f,g,h,i;i=pke(a.e.Dh(),b);d=0;h=a.i;e=RD(a.g,124);for(g=0;g=a.d.b.c.length){b=new R4b(a.d);b.p=d.p-1;Rmb(a.d.b,b);c=new R4b(a.d);c.p=d.p;Rmb(a.d.b,c);}g3b(d,RD(Vmb(a.d.b,d.p),30));}} + function DVc(a,b,c){var d,e,f;if(!a.b[b.g]){a.b[b.g]=true;d=c;!d&&(d=new YWc);Mub(d.b,b);for(f=a.a[b.g].Kc();f.Ob();){e=RD(f.Pb(),65);e.b!=b&&DVc(a,e.b,d);e.c!=b&&DVc(a,e.c,d);Mub(d.a,e);}return d}return null} + function iMb(a){switch(a.g){case 0:case 1:case 2:return qpd(),Yod;case 3:case 4:case 5:return qpd(),npd;case 6:case 7:case 8:return qpd(),ppd;case 9:case 10:case 11:return qpd(),Xod;default:return qpd(),opd;}} + function SOc(a,b){var c;if(a.c.length==0){return false}c=zDc((tFb(0,a.c.length),RD(a.c[0],18)).c.i);dOc();if(c==(wDc(),tDc)||c==sDc){return true}return yDb(GDb(new SDb(null,new Swb(a,16)),new $Oc),new aPc(b))} + function KDd(a,b){if(ZD(b,207)){return EDd(a,RD(b,27))}else if(ZD(b,193)){return FDd(a,RD(b,123))}else if(ZD(b,452)){return DDd(a,RD(b,166))}else {throw Adb(new agb(wIe+Fe(new mob(cD(WC(jJ,1),rve,1,5,[b])))))}} + function Ou(a,b,c){var d,e;this.f=a;d=RD(Wjb(a.b,b),260);e=!d?0:d.a;Sb(c,e);if(c>=(e/2|0)){this.e=!d?null:d.c;this.d=e;while(c++0){Lu(this);}}this.b=b;this.a=null;} + function iHb(a,b){var c,d;b.a?jHb(a,b):(c=RD(vAb(a.b,b.b),60),!!c&&c==a.a[b.b.f]&&!!c.a&&c.a!=b.b.a&&c.c.Fc(b.b),d=RD(uAb(a.b,b.b),60),!!d&&a.a[d.f]==b.b&&!!d.a&&d.a!=b.b.a&&b.b.c.Fc(d),wAb(a.b,b.b),undefined);} + function wMb(a,b){var c,d;c=RD(Vrb(a.b,b),127);if(RD(RD(Qc(a.r,b),21),87).dc()){c.n.b=0;c.n.c=0;return}c.n.b=a.C.b;c.n.c=a.C.c;a.A.Hc((Qpd(),Ppd))&&BMb(a,b);d=AMb(a,b);BLb(a,b)==(pod(),mod)&&(d+=2*a.w);c.a.a=d;} + function FNb(a,b){var c,d;c=RD(Vrb(a.b,b),127);if(RD(RD(Qc(a.r,b),21),87).dc()){c.n.d=0;c.n.a=0;return}c.n.d=a.C.d;c.n.a=a.C.a;a.A.Hc((Qpd(),Ppd))&&JNb(a,b);d=INb(a,b);BLb(a,b)==(pod(),mod)&&(d+=2*a.w);c.a.b=d;} + function VQb(a,b){var c,d,e,f;f=new bnb;for(d=new Anb(b);d.ad&&(BFb(b-1,a.length),a.charCodeAt(b-1)<=32)){--b;}return d>0||bc.a&&(d.Hc((ukd(),okd))?(e=(b.a-c.a)/2):d.Hc(qkd)&&(e=b.a-c.a));b.b>c.b&&(d.Hc((ukd(),skd))?(f=(b.b-c.b)/2):d.Hc(rkd)&&(f=b.b-c.b));Isd(a,e,f);} + function ABd(a,b,c,d,e,f,g,h,i,j,k,l,m){ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),4);PAd(a,c);a.f=g;DWd(a,h);FWd(a,i);xWd(a,j);EWd(a,k);aWd(a,l);AWd(a,m);_Vd(a,true);$Vd(a,e);a.Zk(f);YVd(a,b);d!=null&&(a.i=null,zWd(a,d));} + function Jb(a,b,c){if(a<0){return hc(qve,cD(WC(jJ,1),rve,1,5,[c,sgb(a)]))}else if(b<0){throw Adb(new agb(sve+b))}else {return hc('%s (%s) must not be greater than size (%s)',cD(WC(jJ,1),rve,1,5,[c,sgb(a),sgb(b)]))}} + function Xnb(a,b,c,d,e,f){var g,h,i,j;g=d-c;if(g<7){Unb(b,c,d,f);return}i=c+e;h=d+e;j=i+(h-i>>1);Xnb(b,a,i,j,-e,f);Xnb(b,a,j,h,-e,f);if(f.Ne(a[j-1],a[j])<=0){while(c=0?a.bi(f,c):Svd(a,e,c);}else {throw Adb(new agb(KHe+e.xe()+LHe))}}else {Bvd(a,d,e,c);}} + function n3d(a){var b,c;if(a.f){while(a.n>0){b=RD(a.k.Xb(a.n-1),76);c=b.Lk();if(ZD(c,102)&&(RD(c,19).Bb&QHe)!=0&&(!a.e||c.pk()!=C4||c.Lj()!=0)&&b.md()!=null){return true}else {--a.n;}}return false}else {return a.n>0}} + function Pje(b){var c,d,e,f;d=RD(b,54)._h();if(d){try{e=null;c=N5d((YSd(),XSd),jSd(kSd(d)));if(c){f=c.ai();!!f&&(e=f.Fl(Chb(d.e)));}if(!!e&&e!=b){return Pje(e)}}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}return b} + function P3c(a,b,c){var d,e,f;c.Ug('Remove overlaps',1);c.dh(b,eFe);d=RD(Gxd(b,(u2c(),t2c)),27);a.f=d;a.a=u5c(RD(Gxd(b,($4c(),X4c)),300));e=UD(Gxd(b,(umd(),fmd)));s3c(a,(uFb(e),e));f=Q2c(d);O3c(a,b,f,c);c.dh(b,gFe);} + function Ded(a){var b,c,d;if(Heb(TD(Gxd(a,(umd(),$kd))))){d=new bnb;for(c=new is(Mr(zGd(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),74);ozd(b)&&Heb(TD(Gxd(b,_kd)))&&(ZEb(d.c,b),true);}return d}else {return yob(),yob(),vob}} + function KC(a){if(!a){return cC(),bC}var b=a.valueOf?a.valueOf():a;if(b!==a){var c=GC[typeof b];return c?c(b):NC(typeof b)}else if(a instanceof Array||a instanceof $wnd.Array){return new NB(a)}else {return new vC(a)}} + function IMb(a,b,c){var d,e,f;f=a.o;d=RD(Vrb(a.p,c),252);e=d.i;e.b=ZKb(d);e.a=YKb(d);e.b=$wnd.Math.max(e.b,f.a);e.b>f.a&&!b&&(e.b=f.a);e.c=-(e.b-f.a)/2;switch(c.g){case 1:e.d=-e.a;break;case 3:e.d=f.b;}$Kb(d);_Kb(d);} + function JMb(a,b,c){var d,e,f;f=a.o;d=RD(Vrb(a.p,c),252);e=d.i;e.b=ZKb(d);e.a=YKb(d);e.a=$wnd.Math.max(e.a,f.b);e.a>f.b&&!b&&(e.a=f.b);e.d=-(e.a-f.b)/2;switch(c.g){case 4:e.c=-e.b;break;case 2:e.c=f.a;}$Kb(d);_Kb(d);} + function nkc(a,b){var c,d,e,f,g;if(b.dc()){return}e=RD(b.Xb(0),131);if(b.gc()==1){mkc(a,e,e,1,0,b);return}c=1;while(c0){try{f=Oeb(c,qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){e=a;throw Adb(new RSd(e))}else throw Adb(a)}}d=(!b.a&&(b.a=new Zde(b)),b.a);return f=0?RD(QHd(d,f),58):null} + function Ib(a,b){if(a<0){return hc(qve,cD(WC(jJ,1),rve,1,5,['index',sgb(a)]))}else if(b<0){throw Adb(new agb(sve+b))}else {return hc('%s (%s) must be less than size (%s)',cD(WC(jJ,1),rve,1,5,['index',sgb(a),sgb(b)]))}} + function cob(a){var b,c,d,e,f;if(a==null){return vve}f=new Jyb(pve,'[',']');for(c=a,d=0,e=c.length;d=0?a.Lh(c,true,true):Qvd(a,e,true),160));RD(d,220).Zl(b);}else {throw Adb(new agb(KHe+b.xe()+LHe))}} + function Cib(a){var b,c;if(a>-140737488355328&&a<140737488355328){if(a==0){return 0}b=a<0;b&&(a=-a);c=eE($wnd.Math.floor($wnd.Math.log(a)/0.6931471805599453));(!b||a!=$wnd.Math.pow(2,c))&&++c;return c}return Dib(Hdb(a))} + function oTc(a){var b,c,d,e,f,g,h;f=new Iub;for(c=new Anb(a);c.a2&&h.e.b+h.j.b<=2){e=h;d=g;}f.a.zc(e,f);e.q=d;}return f} + function B5c(a,b,c){c.Ug('Eades radial',1);c.dh(b,gFe);a.d=RD(Gxd(b,(u2c(),t2c)),27);a.c=Kfb(UD(Gxd(b,($4c(),S4c))));a.e=u5c(RD(Gxd(b,X4c),300));a.a=Z3c(RD(Gxd(b,Z4c),434));a.b=k5c(RD(Gxd(b,O4c),354));C5c(a);c.dh(b,gFe);} + function t8c(a,b){b.Ug('Target Width Setter',1);if(Hxd(a,(X7c(),W7c))){Ixd(a,(X6c(),W6c),UD(Gxd(a,W7c)));}else {throw Adb(new Jed('A target width has to be set if the TargetWidthWidthApproximator should be used.'))}b.Vg();} + function _8b(a,b){var c,d,e;d=new j3b(a);kQb(d,b);pQb(d,(Ywc(),gwc),b);pQb(d,(yCc(),BBc),(Bod(),wod));pQb(d,Rzc,(Rjd(),Njd));h3b(d,(r3b(),m3b));c=new R3b;P3b(c,d);Q3b(c,(qpd(),ppd));e=new R3b;P3b(e,d);Q3b(e,Xod);return d} + function ttc(a){switch(a.g){case 0:return new FKc((RKc(),OKc));case 1:return new aKc;case 2:return new FLc;default:throw Adb(new agb('No implementation is available for the crossing minimizer '+(a.f!=null?a.f:''+a.g)));}} + function THc(a,b){var c,d,e,f,g;a.c[b.p]=true;Rmb(a.a,b);for(g=new Anb(b.j);g.a=f){g.$b();}else {e=g.Kc();for(d=0;d0?Hh():g<0&&Rw(a,b,-g);return true}else {return false}} + function YKb(a){var b,c,d,e,f,g,h;h=0;if(a.b==0){g=aLb(a,true);b=0;for(d=g,e=0,f=d.length;e0){h+=c;++b;}}b>1&&(h+=a.c*(b-1));}else {h=Vvb(SCb(HDb(CDb(_nb(a.a),new oLb),new qLb)));}return h>0?h+a.n.d+a.n.a:0} + function ZKb(a){var b,c,d,e,f,g,h;h=0;if(a.b==0){h=Vvb(SCb(HDb(CDb(_nb(a.a),new kLb),new mLb)));}else {g=bLb(a,true);b=0;for(d=g,e=0,f=d.length;e0){h+=c;++b;}}b>1&&(h+=a.c*(b-1));}return h>0?h+a.n.b+a.n.c:0} + function UOc(a){var b,c;if(a.c.length!=2){throw Adb(new dgb('Order only allowed for two paths.'))}b=(tFb(0,a.c.length),RD(a.c[0],18));c=(tFb(1,a.c.length),RD(a.c[1],18));if(b.d.i!=c.c.i){a.c.length=0;ZEb(a.c,c);ZEb(a.c,b);}} + function O8c(a,b,c){var d;zyd(c,b.g,b.f);Byd(c,b.i,b.j);for(d=0;d<(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i;d++){O8c(a,RD(QHd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),d),27),RD(QHd((!c.a&&(c.a=new C5d(J4,c,10,11)),c.a),d),27));}} + function DMb(a,b){var c,d,e,f;f=RD(Vrb(a.b,b),127);c=f.a;for(e=RD(RD(Qc(a.r,b),21),87).Kc();e.Ob();){d=RD(e.Pb(),117);!!d.c&&(c.a=$wnd.Math.max(c.a,QKb(d.c)));}if(c.a>0){switch(b.g){case 2:f.n.c=a.s;break;case 4:f.n.b=a.s;}}} + function ETb(a,b){var c,d,e;c=RD(mQb(b,(yVb(),lVb)),17).a-RD(mQb(a,lVb),17).a;if(c==0){d=ojd(ajd(RD(mQb(a,(JVb(),FVb)),8)),RD(mQb(a,GVb),8));e=ojd(ajd(RD(mQb(b,FVb),8)),RD(mQb(b,GVb),8));return Qfb(d.a*d.b,e.a*e.b)}return c} + function JVc(a,b){var c,d,e;c=RD(mQb(b,(h_c(),X$c)),17).a-RD(mQb(a,X$c),17).a;if(c==0){d=ojd(ajd(RD(mQb(a,(q$c(),RZc)),8)),RD(mQb(a,SZc),8));e=ojd(ajd(RD(mQb(b,RZc),8)),RD(mQb(b,SZc),8));return Qfb(d.a*d.b,e.a*e.b)}return c} + function _0b(a){var b,c;c=new bib;c.a+='e_';b=S0b(a);b!=null&&(c.a+=''+b,c);if(!!a.c&&!!a.d){Zhb((c.a+=' ',c),M3b(a.c));Zhb(Yhb((c.a+='[',c),a.c.i),']');Zhb((c.a+=SAe,c),M3b(a.d));Zhb(Yhb((c.a+='[',c),a.d.i),']');}return c.a} + function ZVc(a){switch(a.g){case 0:return new N_c;case 1:return new V_c;case 2:return new x0c;case 3:return new J0c;default:throw Adb(new agb('No implementation is available for the layout phase '+(a.f!=null?a.f:''+a.g)));}} + function qsd(a,b,c,d,e){var f;f=0;switch(e.g){case 1:f=$wnd.Math.max(0,b.b+a.b-(c.b+d));break;case 3:f=$wnd.Math.max(0,-a.b-d);break;case 2:f=$wnd.Math.max(0,-a.a-d);break;case 4:f=$wnd.Math.max(0,b.a+a.a-(c.a+d));}return f} + function MDd(a,b,c){var d,e,f,g,h;if(c){e=c.a.length;d=new vue(e);for(h=(d.b-d.a)*d.c<0?(uue(),tue):new Rue(d);h.Ob();){g=RD(h.Pb(),17);f=xDd(c,g.a);kIe in f.a||lIe in f.a?yEd(a,f,b):EEd(a,f,b);OGd(RD(Wjb(a.b,uDd(f)),74));}}} + function jXd(a){var b,c;switch(a.b){case -1:{return true}case 0:{c=a.t;if(c>1||c==-1){a.b=-1;return true}else {b=WVd(a);if(!!b&&(nke(),b.lk()==aKe)){a.b=-1;return true}else {a.b=1;return false}}}default:case 1:{return false}}} + function Sqe(a,b){var c,d,e,f;Mqe(a);if(a.c!=0||a.a!=123)throw Adb(new Lqe(TId((Hde(),eJe))));f=b==112;d=a.d;c=phb(a.i,125,d);if(c<0)throw Adb(new Lqe(TId((Hde(),fJe))));e=zhb(a.i,d,c);a.d=c+1;return ite(e,f,(a.e&512)==512)} + function YTb(a){var b,c,d,e,f,g,h;d=a.a.c.length;if(d>0){g=a.c.d;h=a.d.d;e=ijd(ojd(new rjd(h.a,h.b),g),1/(d+1));f=new rjd(g.a,g.b);for(c=new Anb(a.a);c.a=0&&f=0?a.Lh(c,true,true):Qvd(a,e,true),160));return RD(d,220).Wl(b)}else {throw Adb(new agb(KHe+b.xe()+NHe))}} + function _ae(){Tae();var a;if(Sae)return RD(N5d((YSd(),XSd),AKe),2038);RRd(UK,new hde);abe();a=RD(ZD(Xjb((YSd(),XSd),AKe),560)?Xjb(XSd,AKe):new $ae,560);Sae=true;Yae(a);Zae(a);Zjb((hTd(),gTd),a,new cbe);$jb(XSd,AKe,a);return a} + function Vfe(a,b){var c,d,e,f;a.j=-1;if(Mvd(a.e)){c=a.i;f=a.i!=0;LHd(a,b);d=new P3d(a.e,3,a.c,null,b,c,f);e=b.zl(a.e,a.c,null);e=Hge(a,b,e);if(!e){qvd(a.e,d);}else {e.nj(d);e.oj();}}else {LHd(a,b);e=b.zl(a.e,a.c,null);!!e&&e.oj();}} + function HA(a,b){var c,d,e;e=0;d=b[0];if(d>=a.length){return -1}c=(BFb(d,a.length),a.charCodeAt(d));while(c>=48&&c<=57){e=e*10+(c-48);++d;if(d>=a.length){break}c=(BFb(d,a.length),a.charCodeAt(d));}d>b[0]?(b[0]=d):(e=-1);return e} + function mPb(a){var b,c,d,e,f;e=RD(a.a,17).a;f=RD(a.b,17).a;c=e;d=f;b=$wnd.Math.max($wnd.Math.abs(e),$wnd.Math.abs(f));if(e<=0&&e==f){c=0;d=f-1;}else {if(e==-b&&f!=b){c=f;d=e;f>=0&&++c;}else {c=-f;d=e;}}return new Ptd(sgb(c),sgb(d))} + function YPb(a,b,c,d){var e,f,g,h,i,j;for(e=0;e=0&&j>=0&&i=a.i)throw Adb(new veb(MIe+b+NIe+a.i));if(c>=a.i)throw Adb(new veb(OIe+c+NIe+a.i));d=a.g[c];if(b!=c){b>16);b=d>>16&16;c=16-b;a=a>>b;d=a-256;b=d>>16&8;c+=b;a<<=b;d=a-qxe;b=d>>16&4;c+=b;a<<=b;d=a-Ove;b=d>>16&2;c+=b;a<<=b;d=a>>14;b=d&~(d>>1);return c+2-b}} + function RSb(a){HSb();var b,c,d,e;GSb=new bnb;FSb=new Tsb;ESb=new bnb;b=(!a.a&&(a.a=new C5d(J4,a,10,11)),a.a);JSb(b);for(e=new dMd(b);e.e!=e.i.gc();){d=RD(bMd(e),27);if(Wmb(GSb,d,0)==-1){c=new bnb;Rmb(ESb,c);KSb(d,c);}}return ESb} + function sTb(a,b,c){var d,e,f,g;a.a=c.b.d;if(ZD(b,326)){e=IGd(RD(b,74),false,false);f=ssd(e);d=new wTb(a);xgb(f,d);lsd(f,e);b.of((umd(),cld))!=null&&xgb(RD(b.of(cld),75),d);}else {g=RD(b,422);g.rh(g.nh()+a.a.a);g.sh(g.oh()+a.a.b);}} + function hWc(a,b){var c,d,e;e=new bnb;for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);c.c.g==a.g&&dE(mQb(c.b,(h_c(),f_c)))!==dE(mQb(c.c,f_c))&&!yDb(new SDb(null,new Swb(e,16)),new IWc(c))&&(ZEb(e.c,c),true);}_mb(e,new KWc);return e} + function fUb(a,b,c){var d,e,f,g;if(ZD(b,153)&&ZD(c,153)){f=RD(b,153);g=RD(c,153);return a.a[f.a][g.a]+a.a[g.a][f.a]}else if(ZD(b,250)&&ZD(c,250)){d=RD(b,250);e=RD(c,250);if(d.a==e.a){return RD(mQb(e.a,(yVb(),lVb)),17).a}}return 0} + function q9b(a,b){var c,d,e,f,g,h,i,j;j=Kfb(UD(mQb(b,(yCc(),fCc))));i=a[0].n.a+a[0].o.a+a[0].d.c+j;for(h=1;h=0){return c}h=ejd(ojd(new rjd(g.c+g.b/2,g.d+g.a/2),new rjd(f.c+f.b/2,f.d+f.a/2)));return -(oRb(f,g)-1)*h} + function ysd(a,b,c){var d;FDb(new SDb(null,(!c.a&&(c.a=new C5d(F4,c,6,6)),new Swb(c.a,16))),new Qsd(a,b));FDb(new SDb(null,(!c.n&&(c.n=new C5d(I4,c,1,7)),new Swb(c.n,16))),new Ssd(a,b));d=RD(Gxd(c,(umd(),cld)),75);!!d&&Bjd(d,a,b);} + function Qvd(a,b,c){var d,e,f;f=Eee((lke(),jke),a.Dh(),b);if(f){nke();RD(f,69).xk()||(f=zfe(Qee(jke,f)));e=(d=a.Ih(f),RD(d>=0?a.Lh(d,true,true):Qvd(a,f,true),160));return RD(e,220).Sl(b,c)}else {throw Adb(new agb(KHe+b.xe()+NHe))}} + function WNd(a,b,c,d){var e,f,g,h,i;e=a.d[b];if(e){f=e.g;i=e.i;if(d!=null){for(h=0;h=c){d=b;j=(i.c+i.a)/2;g=j-c;if(i.c<=j-c){e=new BTc(i.c,g);Qmb(a,d++,e);}h=j+c;if(h<=i.a){f=new BTc(h,i.a);wFb(d,a.c.length);XEb(a.c,d,f);}}} + function mZc(a,b,c){var d,e,f,g,h,i;if(!b.dc()){e=new Yub;for(i=b.Kc();i.Ob();){h=RD(i.Pb(),40);Zjb(a.a,sgb(h.g),sgb(c));for(g=(d=Sub((new dXc(h)).a.d,0),new gXc(d));dvb(g.a);){f=RD(evb(g.a),65).c;Pub(e,f,e.c.b,e.c);}}mZc(a,e,c+1);}} + function Ude(a){var b;if(!a.c&&a.g==null){a.d=a.bj(a.f);WGd(a,a.d);b=a.d;}else {if(a.g==null){return true}else if(a.i==0){return false}else {b=RD(a.g[a.i-1],51);}}if(b==a.b&&null.Vm>=null.Um()){tId(a);return Ude(a)}else {return b.Ob()}} + function t_b(a){this.a=a;if(a.c.i.k==(r3b(),m3b)){this.c=a.c;this.d=RD(mQb(a.c.i,(Ywc(),hwc)),64);}else if(a.d.i.k==m3b){this.c=a.d;this.d=RD(mQb(a.d.i,(Ywc(),hwc)),64);}else {throw Adb(new agb('Edge '+a+' is not an external edge.'))}} + function O1d(a,b){var c,d,e;e=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,e,a.b));if(!b){PAd(a,null);Q1d(a,0);P1d(a,null);}else if(b!=a){PAd(a,b.zb);Q1d(a,b.d);c=(d=b.c,d==null?b.zb:d);P1d(a,c==null||lhb(c,b.zb)?null:c);}} + function hj(a,b){var c;this.e=(tm(),Qb(a),tm(),zm(a));this.c=(Qb(b),zm(b));Lb(this.e.Rd().dc()==this.c.Rd().dc());this.d=Uv(this.e);this.b=Uv(this.c);c=YC(jJ,[Nve,rve],[5,1],5,[this.e.Rd().gc(),this.c.Rd().gc()],2);this.a=c;Zi(this);} + function Lz(b){(!Jz&&(Jz=Mz()),Jz);var d=b.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(a){return Kz(a)});return '"'+d+'"'} + function VEb(a,b,c,d,e,f){var g,h,i,j,k;if(e==0){return}if(dE(a)===dE(c)){a=a.slice(b,b+e);b=0;}i=c;for(h=b,j=b+e;h=g)throw Adb(new aMd(b,g));e=c[b];if(g==1){d=null;}else {d=$C(d6,IJe,424,g-1,0,1);hib(c,0,d,0,b);f=g-b-1;f>0&&hib(c,b+1,d,b,f);}Bde(a,d);Ade(a,b,e);return e} + function l3d(a){var b,c;if(a.f){while(a.n0?(f=vpd(c)):(f=spd(vpd(c)));}Ixd(b,GBc,f);} + function agc(a,b){var c;b.Ug('Partition preprocessing',1);c=RD(zDb(CDb(EDb(CDb(new SDb(null,new Swb(a.a,16)),new egc),new ggc),new igc),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);FDb(c.Oc(),new kgc);b.Vg();} + function Uoc(a,b){var c,d,e,f,g;g=a.j;b.a!=b.b&&_mb(g,new ypc);e=g.c.length/2|0;for(d=0;d0&&uLc(a,c,b);return f}else if(d.a!=null){uLc(a,b,c);return -1}else if(e.a!=null){uLc(a,c,b);return 1}return 0} + function EVc(a,b){var c,d,e,f,g;e=b.b.b;a.a=$C(QK,Ize,15,e,0,1);a.b=$C(xdb,Hye,28,e,16,1);for(g=Sub(b.b,0);g.b!=g.d.c;){f=RD(evb(g),40);a.a[f.g]=new Yub;}for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);a.a[c.b.g].Fc(c);a.a[c.c.g].Fc(c);}} + function SJd(a,b){var c,d,e,f;if(a.Pj()){c=a.Ej();f=a.Qj();++a.j;a.qj(c,a.Zi(c,b));d=a.Ij(3,null,b,c,f);if(a.Mj()){e=a.Nj(b,null);if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Jj(d);}}else {_Id(a,b);if(a.Mj()){e=a.Nj(b,null);!!e&&e.oj();}}} + function oLd(a,b,c){var d,e,f;if(a.Pj()){f=a.Qj();KHd(a,b,c);d=a.Ij(3,null,c,b,f);if(a.Mj()){e=a.Nj(c,null);a.Tj()&&(e=a.Uj(c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Jj(d);}}else {KHd(a,b,c);if(a.Mj()){e=a.Nj(c,null);!!e&&e.oj();}}} + function bge(a,b){var c,d,e,f,g;g=pke(a.e.Dh(),b);e=new YHd;c=RD(a.g,124);for(f=a.i;--f>=0;){d=c[f];g.am(d.Lk())&&WGd(e,d);}!wLd(a,e)&&Mvd(a.e)&&eZd(a,b.Jk()?fge(a,6,b,(yob(),vob),null,-1,false):fge(a,b.tk()?2:1,b,null,null,-1,false));} + function _7b(a,b){var c,d,e,f,g;if(a.a==($uc(),Yuc)){return true}f=b.a.c;c=b.a.c+b.a.b;if(b.j){d=b.A;g=d.c.c.a-d.o.a/2;e=f-(d.n.a+d.o.a);if(e>g){return false}}if(b.q){d=b.C;g=d.c.c.a-d.o.a/2;e=d.n.a-c;if(e>g){return false}}return true} + function bRc(a){WQc();var b,c,d,e,f,g,h;c=new gub;for(e=new Anb(a.e.b);e.a1?(a.e*=Kfb(a.a)):(a.f/=Kfb(a.a));uRb(a);vRb(a);rRb(a);pQb(a.b,(tSb(),lSb),a.g);} + function n9b(a,b,c){var d,e,f,g,h,i;d=0;i=c;if(!b){d=c*(a.c.length-1);i*=-1;}for(f=new Anb(a);f.a=0?a.Ah(null):a.Ph().Th(a,-1-b,null,null));a.Bh(RD(e,54),c);!!d&&d.oj();a.vh()&&a.wh()&&c>-1&&qvd(a,new N3d(a,9,c,f,e));return e}}}return f} + function stb(a,b){var c,d,e,f,g;f=a.b.Ce(b);d=(c=a.a.get(f),c==null?$C(jJ,rve,1,0,5,1):c);for(g=0;g>5;if(e>=a.d){return a.e<0}c=a.a[e];b=1<<(b&31);if(a.e<0){d=Uib(a);if(e>16)),15).dd(f);if(h0){!(Dmd(a.a.c)&&b.n.d)&&!(Emd(a.a.c)&&b.n.b)&&(b.g.d+=$wnd.Math.max(0,d/2-0.5));!(Dmd(a.a.c)&&b.n.a)&&!(Emd(a.a.c)&&b.n.c)&&(b.g.a-=d-1);}}} + function c7b(a){var b,c,d,e,f;e=new bnb;f=d7b(a,e);b=RD(mQb(a,(Ywc(),Iwc)),10);if(b){for(d=new Anb(b.j);d.a>b;f=a.m>>b|c<<22-b;e=a.l>>b|a.m<<22-b;}else if(b<44){g=d?exe:0;f=c>>b-22;e=a.m>>b-22|c<<44-b;}else {g=d?exe:0;f=d?dxe:0;e=c>>b-44;}return hD(e&dxe,f&dxe,g&exe)} + function ORb(a){var b,c,d,e,f,g;this.c=new bnb;this.d=a;d=oxe;e=oxe;b=pxe;c=pxe;for(g=Sub(a,0);g.b!=g.d.c;){f=RD(evb(g),8);d=$wnd.Math.min(d,f.a);e=$wnd.Math.min(e,f.b);b=$wnd.Math.max(b,f.a);c=$wnd.Math.max(c,f.b);}this.a=new Uid(d,e,b-d,c-e);} + function Udc(a,b){var c,d,e,f,g,h;for(f=new Anb(a.b);f.a0&&ZD(b,44)){a.a._j();j=RD(b,44);i=j.ld();f=i==null?0:tb(i);g=bOd(a.a,f);c=a.a.d[g];if(c){d=RD(c.g,379);k=c.i;for(h=0;h=2){c=e.Kc();b=UD(c.Pb());while(c.Ob()){f=b;b=UD(c.Pb());d=$wnd.Math.min(d,(uFb(b),b)-(uFb(f),f));}}return d} + function iWc(a,b){var c,d,e;e=new bnb;for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);c.b.g==a.g&&!lhb(c.b.c,IEe)&&dE(mQb(c.b,(h_c(),f_c)))!==dE(mQb(c.c,f_c))&&!yDb(new SDb(null,new Swb(e,16)),new OWc(c))&&(ZEb(e.c,c),true);}_mb(e,new QWc);return e} + function $u(a,b){var c,d,e;if(dE(b)===dE(Qb(a))){return true}if(!ZD(b,15)){return false}d=RD(b,15);e=a.gc();if(e!=d.gc()){return false}if(ZD(d,59)){for(c=0;c0&&(e=c);for(g=new Anb(a.f.e);g.a0){b-=1;c-=1;}else {if(d>=0&&e<0){b+=1;c+=1;}else {if(d>0&&e>=0){b-=1;c+=1;}else {b+=1;c-=1;}}}}}return new Ptd(sgb(b),sgb(c))} + function nNc(a,b){if(a.cb.c){return 1}else if(a.bb.b){return 1}else if(a.a!=b.a){return tb(a.a)-tb(b.a)}else if(a.d==(sNc(),rNc)&&b.d==qNc){return -1}else if(a.d==qNc&&b.d==rNc){return 1}return 0} + function ARc(a,b){var c,d,e,f,g;f=b.a;f.c.i==b.b?(g=f.d):(g=f.c);f.c.i==b.b?(d=f.c):(d=f.d);e=lQc(a.a,g,d);if(e>0&&e0}else if(e<0&&-e0}return false} + function X9c(a,b,c,d){var e,f,g,h,i,j,k,l;e=(b-a.d)/a.c.c.length;f=0;a.a+=c;a.d=b;for(l=new Anb(a.c);l.a>24;}return g} + function Bfb(a){if(a.ze()){var b=a.c;b.Ae()?(a.o='['+b.n):!b.ze()?(a.o='[L'+b.xe()+';'):(a.o='['+b.xe());a.b=b.we()+'[]';a.k=b.ye()+'[]';return}var c=a.j;var d=a.d;d=d.split('/');a.o=Efb('.',[c,Efb('$',d)]);a.b=Efb('.',[c,Efb('.',d)]);a.k=d[d.length-1];} + function hJb(a,b){var c,d,e,f,g;g=null;for(f=new Anb(a.e.a);f.a=0;b-=2){for(c=0;c<=b;c+=2){if(a.b[c]>a.b[c+2]||a.b[c]===a.b[c+2]&&a.b[c+1]>a.b[c+3]){d=a.b[c+2];a.b[c+2]=a.b[c];a.b[c]=d;d=a.b[c+3];a.b[c+3]=a.b[c+1];a.b[c+1]=d;}}}a.c=true;} + function nKc(a,b){var c,d,e,f,g,h,i,j,k;j=-1;k=0;for(g=a,h=0,i=g.length;h0&&++k;}}++j;}return k} + function awd(a){var b,c;c=new dib(nfb(a.Rm));c.a+='@';Zhb(c,(b=tb(a)>>>0,b.toString(16)));if(a.Vh()){c.a+=' (eProxyURI: ';Yhb(c,a._h());if(a.Kh()){c.a+=' eClass: ';Yhb(c,a.Kh());}c.a+=')';}else if(a.Kh()){c.a+=' (eClass: ';Yhb(c,a.Kh());c.a+=')';}return c.a} + function KGb(a){var b,c,d,e;if(a.e){throw Adb(new dgb((lfb(lN),lye+lN.k+mye)))}a.d==(Cmd(),Amd)&&JGb(a,ymd);for(c=new Anb(a.a.a);c.a>24;}return c} + function cNb(a,b,c){var d,e,f;e=RD(Vrb(a.i,b),314);if(!e){e=new UKb(a.d,b,c);Wrb(a.i,b,e);if(jMb(b)){tKb(a.a,b.c,b.b,e);}else {f=iMb(b);d=RD(Vrb(a.p,f),252);switch(f.g){case 1:case 3:e.j=true;cLb(d,b.b,e);break;case 4:case 2:e.k=true;cLb(d,b.c,e);}}}return e} + function Ndc(a,b){var c,d,e,f,g,h,i,j,k;i=ev(a.c-a.b&a.a.length-1);j=null;k=null;for(f=new Kmb(a);f.a!=f.b;){e=RD(Imb(f),10);c=(h=RD(mQb(e,(Ywc(),vwc)),12),!h?null:h.i);d=(g=RD(mQb(e,wwc),12),!g?null:g.i);if(j!=c||k!=d){Rdc(i,b);j=c;k=d;}ZEb(i.c,e);}Rdc(i,b);} + function Rge(a,b,c,d){var e,f,g,h,i,j;h=new YHd;i=pke(a.e.Dh(),b);e=RD(a.g,124);nke();if(RD(b,69).xk()){for(g=0;g=0){return e}else {f=1;for(h=new Anb(b.j);h.a=0){return e}else {f=1;for(h=new Anb(b.j);h.a0&&b.Ne((tFb(e-1,a.c.length),RD(a.c[e-1],10)),f)>0){$mb(a,e,(tFb(e-1,a.c.length),RD(a.c[e-1],10)));--e;}tFb(e,a.c.length);a.c[e]=f;}c.a=new Tsb;c.b=new Tsb;} + function yhd(a,b,c){var d,e,f,g,h,i,j,k;k=(d=RD(b.e&&b.e(),9),new Fsb(d,RD(WEb(d,d.length),9),0));i=vhb(c,'[\\[\\]\\s,]+');for(f=i,g=0,h=f.length;g=0){if(!b){b=new Rhb;d>0&&Nhb(b,(AFb(0,d,a.length),a.substr(0,d)));}b.a+='\\';Jhb(b,c&Bwe);}else !!b&&Jhb(b,c&Bwe);}return b?b.a:a} + function MYb(a){var b,c,d;for(c=new Anb(a.a.a.b);c.a0){!(Dmd(a.a.c)&&b.n.d)&&!(Emd(a.a.c)&&b.n.b)&&(b.g.d-=$wnd.Math.max(0,d/2-0.5));!(Dmd(a.a.c)&&b.n.a)&&!(Emd(a.a.c)&&b.n.c)&&(b.g.a+=$wnd.Math.max(0,d-1));}}} + function Ydc(a,b,c){var d,e;if((a.c-a.b&a.a.length-1)==2){if(b==(qpd(),Yod)||b==Xod){Odc(RD(omb(a),15),(Pnd(),Lnd));Odc(RD(omb(a),15),Mnd);}else {Odc(RD(omb(a),15),(Pnd(),Mnd));Odc(RD(omb(a),15),Lnd);}}else {for(e=new Kmb(a);e.a!=e.b;){d=RD(Imb(e),15);Odc(d,c);}}} + function HGd(a,b){var c,d,e,f,g,h,i;e=cv(new QGd(a));h=new Jkb(e,e.c.length);f=cv(new QGd(b));i=new Jkb(f,f.c.length);g=null;while(h.b>0&&i.b>0){c=(sFb(h.b>0),RD(h.a.Xb(h.c=--h.b),27));d=(sFb(i.b>0),RD(i.a.Xb(i.c=--i.b),27));if(c==d){g=c;}else {break}}return g} + function Dmc(a,b,c){var d,e,f,g;if(Hmc(a,b)>Hmc(a,c)){d=b3b(c,(qpd(),Xod));a.d=d.dc()?0:L3b(RD(d.Xb(0),12));g=b3b(b,ppd);a.b=g.dc()?0:L3b(RD(g.Xb(0),12));}else {e=b3b(c,(qpd(),ppd));a.d=e.dc()?0:L3b(RD(e.Xb(0),12));f=b3b(b,Xod);a.b=f.dc()?0:L3b(RD(f.Xb(0),12));}} + function wNb(a,b){var c,d,e,f;c=a.o.a;for(f=RD(RD(Qc(a.r,b),21),87).Kc();f.Ob();){e=RD(f.Pb(),117);e.e.a=c*Kfb(UD(e.b.of(sNb)));e.e.b=(d=e.b,d.pf((umd(),Gld))?d.ag()==(qpd(),Yod)?-d.Mf().b-Kfb(UD(d.of(Gld))):Kfb(UD(d.of(Gld))):d.ag()==(qpd(),Yod)?-d.Mf().b:0);}} + function Mhc(a,b){var c,d,e,f;b.Ug('Self-Loop pre-processing',1);for(d=new Anb(a.a);d.aa.c){break}else if(e.a>=a.s){f<0&&(f=g);h=g;}}i=(a.s+a.c)/2;if(f>=0){d=lTc(a,b,f,h);i=yTc((tFb(d,b.c.length),RD(b.c[d],339)));wTc(b,d,c);}return i} + function _Ad(a,b,c){var d,e,f,g,h,i,j;g=(f=new pVd,f);nVd(g,(uFb(b),b));j=(!g.b&&(g.b=new SVd((JTd(),FTd),C8,g)),g.b);for(i=1;i0&&ASb(this,e);}} + function zTb(a,b,c,d,e,f){var g,h,i;if(!e[b.a]){e[b.a]=true;g=d;!g&&(g=new gUb);Rmb(g.e,b);for(i=f[b.a].Kc();i.Ob();){h=RD(i.Pb(),290);if(h.d==c||h.c==c){continue}h.c!=b&&zTb(a,h.c,b,g,e,f);h.d!=b&&zTb(a,h.d,b,g,e,f);Rmb(g.c,h);Tmb(g.d,h.b);}return g}return null} + function v7b(a){var b,c,d,e,f,g,h;b=0;for(e=new Anb(a.e);e.a=2} + function _qc(a,b,c,d,e){var f,g,h,i,j,k;f=a.c.d.j;g=RD(ju(c,0),8);for(k=1;k1){return false}b=ysb(Xnd,cD(WC(A3,1),jwe,95,0,[Wnd,Znd]));if(dy(Tx(b,a))>1){return false}d=ysb(cod,cD(WC(A3,1),jwe,95,0,[bod,aod]));if(dy(Tx(d,a))>1){return false}return true} + function $Uc(a,b,c){var d,e,f;for(f=new Anb(a.t);f.a0){d.b.n-=d.c;d.b.n<=0&&d.b.u>0&&Mub(b,d.b);}}for(e=new Anb(a.i);e.a0){d.a.u-=d.c;d.a.u<=0&&d.a.n>0&&Mub(c,d.a);}}} + function tId(a){var b,c,d,e,f;if(a.g==null){a.d=a.bj(a.f);WGd(a,a.d);if(a.c){f=a.f;return f}}b=RD(a.g[a.i-1],51);e=b.Pb();a.e=b;c=a.bj(e);if(c.Ob()){a.d=c;WGd(a,c);}else {a.d=null;while(!b.Ob()){bD(a.g,--a.i,null);if(a.i==0){break}d=RD(a.g[a.i-1],51);b=d;}}return e} + function Rfe(a,b){var c,d,e,f,g,h;d=b;e=d.Lk();if(qke(a.e,e)){if(e.Si()&&cge(a,e,d.md())){return false}}else {h=pke(a.e.Dh(),e);c=RD(a.g,124);for(f=0;f1||c>1){return 2}}if(b+c==1){return 2}return 0} + function Kwb(a,b){var c,d,e,f,g,h;f=a.a*Mxe+a.b*1502;h=a.b*Mxe+11;c=$wnd.Math.floor(h*Nxe);f+=c;h-=c*Oxe;f%=Oxe;a.a=f;a.b=h;if(b<=24){return $wnd.Math.floor(a.a*Ewb[b])}else {e=a.a*(1<=2147483648&&(d-=4294967296);return d}} + function uSc(a,b,c){var d,e,f,g,h,i,j;f=new bnb;j=new Yub;g=new Yub;vSc(a,j,g,b);tSc(a,j,g,b,c);for(i=new Anb(a);i.ad.b.g&&(ZEb(f.c,d),true);}}return f} + function jed(a,b,c){var d,e,f,g,h,i;h=a.c;for(g=(!c.q?(yob(),yob(),wob):c.q).vc().Kc();g.Ob();){f=RD(g.Pb(),44);d=!QDb(CDb(new SDb(null,new Swb(h,16)),new PAb(new xed(b,f)))).Bd((xDb(),wDb));if(d){i=f.md();if(ZD(i,4)){e=FId(i);e!=null&&(i=e);}b.qf(RD(f.ld(),149),i);}}} + function mbd(a,b,c){var d,e;Sed(a.b);Ved(a.b,(gbd(),dbd),(_cd(),$cd));Ved(a.b,ebd,b.g);Ved(a.b,fbd,b.a);a.a=Qed(a.b,b);c.Ug('Compaction by shrinking a tree',a.a.c.length);if(b.i.c.length>1){for(e=new Anb(a.a);e.a=0?a.Lh(d,true,true):Qvd(a,f,true),160));RD(e,220).Xl(b,c);}else {throw Adb(new agb(KHe+b.xe()+LHe))}} + function k2d(a,b){var c,d,e,f,g;if(!b){return null}else {f=ZD(a.Cb,90)||ZD(a.Cb,102);g=!f&&ZD(a.Cb,331);for(d=new dMd((!b.a&&(b.a=new iae(b,o7,b)),b.a));d.e!=d.i.gc();){c=RD(bMd(d),89);e=i2d(c);if(f?ZD(e,90):g?ZD(e,156):!!e){return e}}return f?(JTd(),zTd):(JTd(),wTd)}} + function W8b(a,b){var c,d,e,f;b.Ug('Resize child graph to fit parent.',1);for(d=new Anb(a.b);d.a=2*b&&Rmb(c,new BTc(g[d-1]+b,g[d]-b));}return c} + function dEd(a,b,c){var d,e,f,g,h,j,k,l;if(c){f=c.a.length;d=new vue(f);for(h=(d.b-d.a)*d.c<0?(uue(),tue):new Rue(d);h.Ob();){g=RD(h.Pb(),17);e=xDd(c,g.a);!!e&&(j=sEd(a,(k=(bvd(),l=new PCd,l),!!b&&NCd(k,b),k),e),jyd(j,zDd(e,uIe)),GEd(e,j),HEd(e,j),CEd(a,e,j));}}} + function sYd(a){var b,c,d,e,f,g;if(!a.j){g=new f1d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(zYd(a));d.e!=d.i.gc();){c=RD(bMd(d),29);e=sYd(c);YGd(g,e);WGd(g,c);}b.a.Bc(a)!=null;}VHd(g);a.j=new N$d((RD(QHd(xYd((lTd(),kTd).o),11),19),g.i),g.g);yYd(a).b&=-33;}return a.j} + function lne(a){var b,c,d,e;if(a==null){return null}else {d=nue(a,true);e=mLe.length;if(lhb(d.substr(d.length-e,e),mLe)){c=d.length;if(c==4){b=(BFb(0,d.length),d.charCodeAt(0));if(b==43){return Yme}else if(b==45){return Xme}}else if(c==3){return Yme}}return new Ufb(d)}} + function pD(a){var b,c,d;c=a.l;if((c&c-1)!=0){return -1}d=a.m;if((d&d-1)!=0){return -1}b=a.h;if((b&b-1)!=0){return -1}if(b==0&&d==0&&c==0){return -1}if(b==0&&d==0&&c!=0){return ogb(c)}if(b==0&&d!=0&&c==0){return ogb(d)+22}if(b!=0&&d==0&&c==0){return ogb(b)+44}return -1} + function yo(a,b){var c,d,e,f,g;e=b.a&a.f;f=null;for(d=a.b[e];true;d=d.b){if(d==b){!f?(a.b[e]=b.b):(f.b=b.b);break}f=d;}g=b.f&a.f;f=null;for(c=a.c[g];true;c=c.d){if(c==b){!f?(a.c[g]=b.d):(f.d=b.d);break}f=c;}!b.e?(a.a=b.c):(b.e.c=b.c);!b.c?(a.e=b.e):(b.c.e=b.e);--a.i;++a.g;} + function Dt(a,b){var c;b.d?(b.d.b=b.b):(a.a=b.b);b.b?(b.b.d=b.d):(a.e=b.d);if(!b.e&&!b.c){c=RD(Hvb(RD(_jb(a.b,b.a),260)),260);c.a=0;++a.c;}else {c=RD(Hvb(RD(Wjb(a.b,b.a),260)),260);--c.a;!b.e?(c.b=RD(Hvb(b.c),511)):(b.e.c=b.c);!b.c?(c.c=RD(Hvb(b.e),511)):(b.c.e=b.e);}--a.d;} + function XPb(a){var b,c,d,e,f,g,h,i,j,k;c=a.o;b=a.p;g=lve;e=qwe;h=lve;f=qwe;for(j=0;j0);f.a.Xb(f.c=--f.b);Ikb(f,e);sFb(f.b3&&UA(a,0,b-3);}} + function eXb(a){var b,c,d,e;if(dE(mQb(a,(yCc(),IAc)))===dE((Fnd(),Cnd))){return !a.e&&dE(mQb(a,gAc))!==dE((xvc(),uvc))}d=RD(mQb(a,hAc),299);e=Heb(TD(mQb(a,nAc)))||dE(mQb(a,oAc))===dE((stc(),ptc));b=RD(mQb(a,fAc),17).a;c=a.a.c.length;return !e&&d!=(xvc(),uvc)&&(b==0||b>c)} + function Rnc(a){var b,c;c=0;for(;c0){break}}if(c>0&&c0){break}}if(b>0&&c>16!=6&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+Qzd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?Czd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,6,d));d=Bzd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,6,b,b));} + function pzd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=3&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+qzd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?jzd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,12,d));d=izd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function NCd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=9&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+OCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?LCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,9,d));d=KCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,9,b,b));} + function tWd(b){var c,d,e,f,g;e=WVd(b);g=b.j;if(g==null&&!!e){return b.Jk()?null:e.ik()}else if(ZD(e,156)){d=e.jk();if(d){f=d.wi();if(f!=b.i){c=RD(e,156);if(c.nk()){try{b.g=f.ti(c,g);}catch(a){a=zdb(a);if(ZD(a,82)){b.g=null;}else throw Adb(a)}}b.i=f;}}return b.g}return null} + function nRb(a){var b;b=new bnb;Rmb(b,new TFb(new rjd(a.c,a.d),new rjd(a.c+a.b,a.d)));Rmb(b,new TFb(new rjd(a.c,a.d),new rjd(a.c,a.d+a.a)));Rmb(b,new TFb(new rjd(a.c+a.b,a.d+a.a),new rjd(a.c+a.b,a.d)));Rmb(b,new TFb(new rjd(a.c+a.b,a.d+a.a),new rjd(a.c,a.d+a.a)));return b} + function ic(b){var c,d,e;if(b==null){return vve}try{return jeb(b)}catch(a){a=zdb(a);if(ZD(a,103)){c=a;e=nfb(rb(b))+'@'+(d=(gib(),jFb(b))>>>0,d.toString(16));lBb(pBb(),(SAb(),'Exception during lenientFormat for '+e),c);return '<'+e+' threw '+nfb(c.Rm)+'>'}else throw Adb(a)}} + function mTb(a,b,c){var d,e,f;for(f=b.a.ec().Kc();f.Ob();){e=RD(f.Pb(),74);d=RD(Wjb(a.b,e),272);!d&&(vCd(JGd(e))==vCd(LGd(e))?lTb(a,e,c):JGd(e)==vCd(LGd(e))?Wjb(a.c,e)==null&&Wjb(a.b,LGd(e))!=null&&oTb(a,e,c,false):Wjb(a.d,e)==null&&Wjb(a.b,JGd(e))!=null&&oTb(a,e,c,true));}} + function Pfc(a,b){var c,d,e,f,g,h,i;for(e=a.Kc();e.Ob();){d=RD(e.Pb(),10);h=new R3b;P3b(h,d);Q3b(h,(qpd(),Xod));pQb(h,(Ywc(),Hwc),(Geb(),true));for(g=b.Kc();g.Ob();){f=RD(g.Pb(),10);i=new R3b;P3b(i,f);Q3b(i,ppd);pQb(i,Hwc,true);c=new a1b;pQb(c,Hwc,true);Y0b(c,h);Z0b(c,i);}}} + function Pqc(a,b,c,d){var e,f,g,h;e=Nqc(a,b,c);f=Nqc(a,c,b);g=RD(Wjb(a.c,b),118);h=RD(Wjb(a.c,c),118);if(e1){b=eJb((c=new gJb,++a.b,c),a.d);for(h=Sub(f,0);h.b!=h.d.c;){g=RD(evb(h),125);rIb(uIb(tIb(vIb(sIb(new wIb,1),0),b),g));}}} + function isc(a,b,c){var d,e,f,g,h;c.Ug('Breaking Point Removing',1);a.a=RD(mQb(b,(yCc(),yAc)),223);for(f=new Anb(b.b);f.a>16!=11&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+zCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?sCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,10,d));d=rCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,11,b,b));} + function C0b(a){var b,c,d,e;for(d=new vkb((new mkb(a.b)).a);d.b;){c=tkb(d);e=RD(c.ld(),12);b=RD(c.md(),10);pQb(b,(Ywc(),Awc),e);pQb(e,Iwc,b);pQb(e,nwc,(Geb(),true));Q3b(e,RD(mQb(b,hwc),64));mQb(b,hwc);pQb(e.i,(yCc(),BBc),(Bod(),yod));RD(mQb(Y2b(e.i),kwc),21).Fc((ovc(),kvc));}} + function X7b(a,b,c){var d,e,f,g,h,i;f=0;g=0;if(a.c){for(i=new Anb(a.d.i.j);i.af.a){return -1}else if(e.ai){k=a.d;a.d=$C(D6,KJe,66,2*i+4,0,1);for(f=0;f=9223372036854775807){return MD(),ID}e=false;if(a<0){e=true;a=-a;}d=0;if(a>=hxe){d=eE(a/hxe);a-=d*hxe;}c=0;if(a>=gxe){c=eE(a/gxe);a-=c*gxe;}b=eE(a);f=hD(b,c,d);e&&nD(f);return f} + function KCb(a){var b,c,d,e,f;f=new bnb;Umb(a.b,new SEb(f));a.b.c.length=0;if(f.c.length!=0){b=(tFb(0,f.c.length),RD(f.c[0],82));for(c=1,d=f.c.length;c=-b&&d==b){return new Ptd(sgb(c-1),sgb(d))}return new Ptd(sgb(c),sgb(d-1))} + function lcc(){hcc();return cD(WC(YS,1),jwe,81,0,[nbc,kbc,obc,Ebc,Xbc,Ibc,bcc,Nbc,Vbc,zbc,Rbc,Mbc,Wbc,vbc,dcc,ebc,Qbc,Zbc,Fbc,Ybc,fcc,Tbc,fbc,Ubc,gcc,_bc,ecc,Gbc,sbc,Hbc,Dbc,ccc,ibc,qbc,Kbc,hbc,Lbc,Bbc,wbc,Obc,ybc,lbc,jbc,Cbc,xbc,Pbc,acc,gbc,Sbc,Abc,Jbc,tbc,rbc,$bc,pbc,ubc,mbc])} + function Cmc(a,b,c){a.d=0;a.b=0;b.k==(r3b(),q3b)&&c.k==q3b&&RD(mQb(b,(Ywc(),Awc)),10)==RD(mQb(c,Awc),10)&&(Gmc(b).j==(qpd(),Yod)?Dmc(a,b,c):Dmc(a,c,b));b.k==q3b&&c.k==o3b?Gmc(b).j==(qpd(),Yod)?(a.d=1):(a.b=1):c.k==q3b&&b.k==o3b&&(Gmc(c).j==(qpd(),Yod)?(a.b=1):(a.d=1));Imc(a,b,c);} + function EFd(a){var b,c,d,e,f,g,h,i,j,k,l;l=HFd(a);b=a.a;i=b!=null;i&&sDd(l,'category',a.a);e=cve(new Xkb(a.d));g=!e;if(g){j=new MB;sC(l,'knownOptions',j);c=new MFd(j);xgb(new Xkb(a.d),c);}f=cve(a.g);h=!f;if(h){k=new MB;sC(l,'supportedFeatures',k);d=new OFd(k);xgb(a.g,d);}return l} + function Ly(a){var b,c,d,e,f,g,h,i,j;d=false;b=336;c=0;f=new hq(a.length);for(h=a,i=0,j=h.length;i>16!=7&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+gCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?cCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=RD(b,54).Rh(a,1,H4,d));d=bCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,7,b,b));} + function lVd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=3&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+oVd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?iVd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=RD(b,54).Rh(a,0,p7,d));d=hVd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function Mjb(a,b){Ljb();var c,d,e,f,g,h,i,j,k;if(b.d>a.d){h=a;a=b;b=h;}if(b.d<63){return Qjb(a,b)}g=(a.d&-2)<<4;j=$ib(a,g);k=$ib(b,g);d=Gjb(a,Zib(j,g));e=Gjb(b,Zib(k,g));i=Mjb(j,k);c=Mjb(d,e);f=Mjb(Gjb(j,d),Gjb(e,k));f=Bjb(Bjb(f,i),c);f=Zib(f,g);i=Zib(i,g<<1);return Bjb(Bjb(i,f),c)} + function _Cc(){_Cc=geb;ZCc=new bDc(lEe,0);WCc=new bDc('LONGEST_PATH',1);XCc=new bDc('LONGEST_PATH_SOURCE',2);TCc=new bDc('COFFMAN_GRAHAM',3);VCc=new bDc(BBe,4);$Cc=new bDc('STRETCH_WIDTH',5);YCc=new bDc('MIN_WIDTH',6);SCc=new bDc('BF_MODEL_ORDER',7);UCc=new bDc('DF_MODEL_ORDER',8);} + function AKc(a,b,c){var d,e,f,g,h;g=aMc(a,c);h=$C(jR,WAe,10,b.length,0,1);d=0;for(f=g.Kc();f.Ob();){e=RD(f.Pb(),12);Heb(TD(mQb(e,(Ywc(),nwc))))&&(h[d++]=RD(mQb(e,Iwc),10));}if(d=0;f+=c?1:-1){g=g|b.c.lg(i,f,c,d&&!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,(Ywc(),Owc)))));g=g|b.q.ug(i,f,c);g=g|CKc(a,i[f],c,d);}Ysb(a.c,b);return g} + function F6b(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(k=u2b(a.j),l=0,m=k.length;l1&&(a.a=true);QQb(RD(c.b,68),$id(ajd(RD(b.b,68).c),ijd(ojd(ajd(RD(c.b,68).a),RD(b.b,68).a),e)));Odd(a,b);Qdd(a,c);}} + function tYb(a){var b,c,d,e,f,g,h;for(f=new Anb(a.a.a);f.a0&&f>0?(g.p=b++):d>0?(g.p=c++):f>0?(g.p=e++):(g.p=c++);}}yob();_mb(a.j,new Lfc);} + function zic(a){var b,c;c=null;b=RD(Vmb(a.g,0),18);do{c=b.d.i;if(nQb(c,(Ywc(),wwc))){return RD(mQb(c,wwc),12).i}if(c.k!=(r3b(),p3b)&&gs(new is(Mr(a3b(c).a.Kc(),new ir)))){b=RD(hs(new is(Mr(a3b(c).a.Kc(),new ir))),18);}else if(c.k!=p3b){return null}}while(!!c&&c.k!=(r3b(),p3b));return c} + function sqc(a,b){var c,d,e,f,g,h,i,j,k;h=b.j;g=b.g;i=RD(Vmb(h,h.c.length-1),113);k=(tFb(0,h.c.length),RD(h.c[0],113));j=oqc(a,g,i,k);for(f=1;fj){i=c;k=e;j=d;}}b.a=k;b.c=i;} + function fMc(a,b,c){var d,e,f,g,h,i,j;j=new yAb(new TMc(a));for(g=cD(WC(xR,1),XAe,12,0,[b,c]),h=0,i=g.length;hi-a.b&&hi-a.a&&h0){if(f.a){h=f.b.Mf().a;if(c>h){e=(c-h)/2;f.d.b=e;f.d.c=e;}}else {f.d.c=a.s+c;}}else if(Rod(a.u)){d=wsd(f.b);d.c<0&&(f.d.b=-d.c);d.c+d.b>f.b.Mf().a&&(f.d.c=d.c+d.b-f.b.Mf().a);}}} + function RUc(a,b){var c,d,e,f,g;g=new bnb;c=b;do{f=RD(Wjb(a.b,c),131);f.B=c.c;f.D=c.d;ZEb(g.c,f);c=RD(Wjb(a.k,c),18);}while(c);d=(tFb(0,g.c.length),RD(g.c[0],131));d.j=true;d.A=RD(d.d.a.ec().Kc().Pb(),18).c.i;e=RD(Vmb(g,g.c.length-1),131);e.q=true;e.C=RD(e.d.a.ec().Kc().Pb(),18).d.i;return g} + function pPb(a){var b,c;b=RD(a.a,17).a;c=RD(a.b,17).a;if(b>=0){if(b==c){return new Ptd(sgb(-b-1),sgb(-b-1))}if(b==-c){return new Ptd(sgb(-b),sgb(c+1))}}if($wnd.Math.abs(b)>$wnd.Math.abs(c)){if(b<0){return new Ptd(sgb(-b),sgb(c))}return new Ptd(sgb(-b),sgb(c+1))}return new Ptd(sgb(b+1),sgb(c))} + function H8b(a){var b,c;c=RD(mQb(a,(yCc(),UAc)),171);b=RD(mQb(a,(Ywc(),owc)),311);if(c==(cxc(),$wc)){pQb(a,UAc,bxc);pQb(a,owc,(Gvc(),Fvc));}else if(c==axc){pQb(a,UAc,bxc);pQb(a,owc,(Gvc(),Dvc));}else if(b==(Gvc(),Fvc)){pQb(a,UAc,$wc);pQb(a,owc,Evc);}else if(b==Dvc){pQb(a,UAc,axc);pQb(a,owc,Evc);}} + function dSc(){dSc=geb;bSc=new pSc;ZRc=pfd(new ufd,(sXb(),pXb),(hcc(),Fbc));aSc=nfd(pfd(new ufd,pXb,Tbc),rXb,Sbc);cSc=mfd(mfd(rfd(nfd(pfd(new ufd,nXb,bcc),rXb,acc),qXb),_bc),ccc);$Rc=nfd(pfd(pfd(pfd(new ufd,oXb,Ibc),qXb,Kbc),qXb,Lbc),rXb,Jbc);_Rc=nfd(pfd(pfd(new ufd,qXb,Lbc),qXb,qbc),rXb,pbc);} + function HUc(){HUc=geb;CUc=pfd(nfd(new ufd,(sXb(),rXb),(hcc(),tbc)),pXb,Fbc);GUc=mfd(mfd(rfd(nfd(pfd(new ufd,nXb,bcc),rXb,acc),qXb),_bc),ccc);DUc=nfd(pfd(pfd(pfd(new ufd,oXb,Ibc),qXb,Kbc),qXb,Lbc),rXb,Jbc);FUc=pfd(pfd(new ufd,pXb,Tbc),rXb,Sbc);EUc=nfd(pfd(pfd(new ufd,qXb,Lbc),qXb,qbc),rXb,pbc);} + function eSc(a,b,c,d,e){var f,g;if((!W0b(b)&&b.c.i.c==b.d.i.c||!djd(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])),c))&&!W0b(b)){b.c==e?hu(b.a,0,new sjd(c)):Mub(b.a,new sjd(c));if(d&&!Zsb(a.a,c)){g=RD(mQb(b,(yCc(),RAc)),75);if(!g){g=new Ejd;pQb(b,RAc,g);}f=new sjd(c);Pub(g,f,g.c.b,g.c);Ysb(a.a,f);}}} + function ht(a,b){var c,d,e,f;f=Ydb(Ndb(cwe,qgb(Ydb(Ndb(b==null?0:tb(b),dwe)),15)));c=f&a.b.length-1;e=null;for(d=a.b[c];d;e=d,d=d.a){if(d.d==f&&Hb(d.i,b)){!e?(a.b[c]=d.a):(e.a=d.a);Ts(RD(Hvb(d.c),604),RD(Hvb(d.f),604));Ss(RD(Hvb(d.b),227),RD(Hvb(d.e),227));--a.f;++a.e;return true}}return false} + function dec(a){var b,c;for(c=new is(Mr(Z2b(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),18);if(b.c.i.k!=(r3b(),n3b)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to FIRST, but has at least one incoming edge that "+' does not come from a FIRST_SEPARATE node. That must not happen.'))}}} + function Twd(a,b,c){var d,e,f,g,h,i,j;e=ggb(a.Db&254);if(e==0){a.Eb=c;}else {if(e==1){h=$C(jJ,rve,1,2,5,1);f=Xwd(a,b);if(f==0){h[0]=c;h[1]=a.Eb;}else {h[0]=a.Eb;h[1]=c;}}else {h=$C(jJ,rve,1,e+1,5,1);g=SD(a.Eb);for(d=2,i=0,j=0;d<=128;d<<=1){d==b?(h[j++]=c):(a.Db&d)!=0&&(h[j++]=g[i++]);}}a.Eb=h;}a.Db|=b;} + function vQb(a,b,c){var d,e,f,g;this.b=new bnb;e=0;d=0;for(g=new Anb(a);g.a0){f=RD(Vmb(this.b,0),176);e+=f.o;d+=f.p;}e*=2;d*=2;b>1?(e=eE($wnd.Math.ceil(e*b))):(d=eE($wnd.Math.ceil(d/b)));this.a=new gQb(e,d);} + function mkc(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r;k=d;if(b.j&&b.o){n=RD(Wjb(a.f,b.A),60);p=n.d.c+n.d.b;--k;}else {p=b.a.c+b.a.b;}l=e;if(c.q&&c.o){n=RD(Wjb(a.f,c.C),60);j=n.d.c;++l;}else {j=c.a.c;}q=j-p;i=$wnd.Math.max(2,l-k);h=q/i;o=p+h;for(m=k;m=0;g+=e?1:-1){h=b[g];i=d==(qpd(),Xod)?e?b3b(h,d):hv(b3b(h,d)):e?hv(b3b(h,d)):b3b(h,d);f&&(a.c[h.p]=i.gc());for(l=i.Kc();l.Ob();){k=RD(l.Pb(),12);a.d[k.p]=j++;}Tmb(c,i);}} + function AUc(a,b,c){var d,e,f,g,h,i,j,k;f=Kfb(UD(a.b.Kc().Pb()));j=Kfb(UD(fr(b.b)));d=ijd(ajd(a.a),j-c);e=ijd(ajd(b.a),c-f);k=$id(d,e);ijd(k,1/(j-f));this.a=k;this.b=new bnb;h=true;g=a.b.Kc();g.Pb();while(g.Ob()){i=Kfb(UD(g.Pb()));if(h&&i-c>AEe){this.b.Fc(c);h=false;}this.b.Fc(i);}h&&this.b.Fc(c);} + function mJb(a){var b,c,d,e;pJb(a,a.n);if(a.d.c.length>0){Nnb(a.c);while(xJb(a,RD(ynb(new Anb(a.e.a)),125))>5;b&=31;if(d>=a.d){return a.e<0?(Pib(),Jib):(Pib(),Oib)}f=a.d-d;e=$C(kE,Pwe,28,f+1,15,1);ujb(e,f,a.a,d,b);if(a.e<0){for(c=0;c0&&a.a[c]<<32-b!=0){for(c=0;c=0){return false}else {c=Eee((lke(),jke),e,b);if(!c){return true}else {d=c.Ik();return (d>1||d==-1)&&yfe(Qee(jke,c))!=3}}}}else {return false}} + function _4b(a,b,c,d){var e,f,g,h,i;h=AGd(RD(QHd((!b.b&&(b.b=new Yie(E4,b,4,7)),b.b),0),84));i=AGd(RD(QHd((!b.c&&(b.c=new Yie(E4,b,5,8)),b.c),0),84));if(vCd(h)==vCd(i)){return null}if(NGd(i,h)){return null}g=kzd(b);if(g==c){return d}else {f=RD(Wjb(a.a,g),10);if(f){e=f.e;if(e){return e}}}return null} + function uHc(a,b,c){var d,e,f,g,h;c.Ug('Longest path to source layering',1);a.a=b;h=a.a.a;a.b=$C(kE,Pwe,28,h.c.length,15,1);d=0;for(g=new Anb(h);g.a0){c[0]+=a.d;g-=c[0];}if(c[2]>0){c[2]+=a.d;g-=c[2];}f=$wnd.Math.max(0,g);c[1]=$wnd.Math.max(c[1],g);mKb(a,XJb,e.c+d.b+c[0]-(c[1]-g)/2,c);if(b==XJb){a.c.b=f;a.c.c=e.c+d.b+(f-g)/2;}} + function D_b(){this.c=$C(iE,vxe,28,(qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,15,1);this.b=$C(iE,vxe,28,cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd]).length,15,1);this.a=$C(iE,vxe,28,cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd]).length,15,1);Lnb(this.c,oxe);Lnb(this.b,pxe);Lnb(this.a,pxe);} + function rte(a,b,c){var d,e,f,g;if(b<=c){e=b;f=c;}else {e=c;f=b;}d=0;if(a.b==null){a.b=$C(kE,Pwe,28,2,15,1);a.b[0]=e;a.b[1]=f;a.c=true;}else {d=a.b.length;if(a.b[d-1]+1==e){a.b[d-1]=f;return}g=$C(kE,Pwe,28,d+2,15,1);hib(a.b,0,g,0,d);a.b=g;a.b[d-1]>=e&&(a.c=false,a.a=false);a.b[d++]=e;a.b[d]=f;a.c||vte(a);}} + function Oqc(a,b,c){var d,e,f,g,h,i,j;j=b.d;a.a=new cnb(j.c.length);a.c=new Tsb;for(h=new Anb(j);h.a=0?a.Lh(j,false,true):Qvd(a,c,false),61));n:for(f=l.Kc();f.Ob();){e=RD(f.Pb(),58);for(k=0;k1){vLd(e,e.i-1);}}return d}} + function Vdc(a,b){var c,d,e,f,g,h,i;c=new wmb;for(f=new Anb(a.b);f.aa.d[g.p]){c+=ZLc(a.b,f);hmb(a.a,sgb(f));}}while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function Uec(a){var b,c,d,e,f,g,h,i,j;a.a=new e6b;j=0;e=0;for(d=new Anb(a.i.b);d.ah.d&&(k=h.d+h.a+j);}}c.c.d=k;b.a.zc(c,b);i=$wnd.Math.max(i,c.c.d+c.c.a);}return i} + function ovc(){ovc=geb;fvc=new pvc('COMMENTS',0);hvc=new pvc('EXTERNAL_PORTS',1);ivc=new pvc('HYPEREDGES',2);jvc=new pvc('HYPERNODES',3);kvc=new pvc('NON_FREE_PORTS',4);lvc=new pvc('NORTH_SOUTH_PORTS',5);nvc=new pvc(FBe,6);evc=new pvc('CENTER_LABELS',7);gvc=new pvc('END_LABELS',8);mvc=new pvc('PARTITIONS',9);} + function PA(a,b,c,d,e){if(d<0){d=EA(a,e,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe]),b);d<0&&(d=EA(a,e,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec']),b));if(d<0){return false}c.k=d;return true}else if(d>0){c.k=d-1;return true}return false} + function RA(a,b,c,d,e){if(d<0){d=EA(a,e,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe]),b);d<0&&(d=EA(a,e,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec']),b));if(d<0){return false}c.k=d;return true}else if(d>0){c.k=d-1;return true}return false} + function TA(a,b,c,d,e,f){var g,h,i,j;h=32;if(d<0){if(b[0]>=a.length){return false}h=ihb(a,b[0]);if(h!=43&&h!=45){return false}++b[0];d=HA(a,b);if(d<0){return false}h==45&&(d=-d);}if(h==32&&b[0]-c==2&&e.b==2){i=new uB;j=i.q.getFullYear()-Owe+Owe-80;g=j%100;f.a=d==g;d+=(j/100|0)*100+(d=0?jjb(a):Xib(jjb(Odb(a))));Kjb[b]=Jdb(Sdb(a,b),0)?jjb(Sdb(a,b)):Xib(jjb(Odb(Sdb(a,b))));a=Ndb(a,5);}for(;b=j&&(i=d);}!!i&&(k=$wnd.Math.max(k,i.a.o.a));if(k>m){l=j;m=k;}}return l} + function SNb(a){var b,c,d,e,f,g,h;f=new yAb(RD(Qb(new eOb),50));h=pxe;for(c=new Anb(a.d);c.aFFe?_mb(i,a.b):d<=FFe&&d>GFe?_mb(i,a.d):d<=GFe&&d>HFe?_mb(i,a.c):d<=HFe&&_mb(i,a.a);f=$5c(a,i,f);}return e} + function sTc(a,b,c,d){var e,f,g,h,i,j;e=(d.c+d.a)/2;Xub(b.j);Mub(b.j,e);Xub(c.e);Mub(c.e,e);j=new ATc;for(h=new Anb(a.f);h.a1;if(h){d=new rjd(e,c.b);Mub(b.a,d);}zjd(b.a,cD(WC(l3,1),Nve,8,0,[m,l]));} + function TGc(a,b,c){var d,e;if(b=48;c--){Eqe[c]=c-48<<24>>24;}for(d=70;d>=65;d--){Eqe[d]=d-65+10<<24>>24;}for(e=102;e>=97;e--){Eqe[e]=e-97+10<<24>>24;}for(f=0;f<10;f++)Fqe[f]=48+f&Bwe;for(a=10;a<=15;a++)Fqe[a]=65+a-10&Bwe;} + function yYc(a,b){b.Ug('Process graph bounds',1);pQb(a,(q$c(),ZZc),Uvb(TCb(HDb(new SDb(null,new Swb(a.b,16)),new DYc))));pQb(a,_Zc,Uvb(TCb(HDb(new SDb(null,new Swb(a.b,16)),new FYc))));pQb(a,YZc,Uvb(SCb(HDb(new SDb(null,new Swb(a.b,16)),new HYc))));pQb(a,$Zc,Uvb(SCb(HDb(new SDb(null,new Swb(a.b,16)),new JYc))));b.Vg();} + function PWb(a){var b,c,d,e,f;e=RD(mQb(a,(yCc(),lBc)),21);f=RD(mQb(a,oBc),21);c=new rjd(a.f.a+a.d.b+a.d.c,a.f.b+a.d.d+a.d.a);b=new sjd(c);if(e.Hc((Qpd(),Mpd))){d=RD(mQb(a,nBc),8);if(f.Hc((dqd(),Ypd))){d.a<=0&&(d.a=20);d.b<=0&&(d.b=20);}b.a=$wnd.Math.max(c.a,d.a);b.b=$wnd.Math.max(c.b,d.b);}Heb(TD(mQb(a,mBc)))||QWb(a,c,b);} + function lOc(a,b){var c,d,e,f;for(f=b3b(b,(qpd(),npd)).Kc();f.Ob();){d=RD(f.Pb(),12);c=RD(mQb(d,(Ywc(),Iwc)),10);!!c&&rIb(uIb(tIb(vIb(sIb(new wIb,0),0.1),a.i[b.p].d),a.i[c.p].a));}for(e=b3b(b,Yod).Kc();e.Ob();){d=RD(e.Pb(),12);c=RD(mQb(d,(Ywc(),Iwc)),10);!!c&&rIb(uIb(tIb(vIb(sIb(new wIb,0),0.1),a.i[c.p].d),a.i[b.p].a));}} + function oYd(a){var b,c,d,e,f,g;if(!a.c){g=new W$d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(tYd(a));d.e!=d.i.gc();){c=RD(bMd(d),89);e=i2d(c);ZD(e,90)&&YGd(g,oYd(RD(e,29)));WGd(g,c);}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}T$d(g);VHd(g);a.c=new N$d((RD(QHd(xYd((lTd(),kTd).o),15),19),g.i),g.g);yYd(a).b&=-33;}return a.c} + function Dre(a){var b;if(a.c!=10)throw Adb(new Lqe(TId((Hde(),VIe))));b=a.a;switch(b){case 110:b=10;break;case 114:b=13;break;case 116:b=9;break;case 92:case 124:case 46:case 94:case 45:case 63:case 42:case 43:case 123:case 125:case 40:case 41:case 91:case 93:break;default:throw Adb(new Lqe(TId((Hde(),xJe))));}return b} + function GD(a){var b,c,d,e,f;if(a.l==0&&a.m==0&&a.h==0){return '0'}if(a.h==fxe&&a.m==0&&a.l==0){return '-9223372036854775808'}if(a.h>>19!=0){return '-'+GD(xD(a))}c=a;d='';while(!(c.l==0&&c.m==0&&c.h==0)){e=fD(ixe);c=iD(c,e,true);b=''+FD(eD);if(!(c.l==0&&c.m==0&&c.h==0)){f=9-b.length;for(;f>0;f--){b='0'+b;}}d=b+d;}return d} + function tkc(a){var b,c,d,e,f,g,h;b=false;c=0;for(e=new Anb(a.d.b);e.a=a.a){return -1}if(!W9b(b,c)){return -1}if(gr(RD(d.Kb(b),20))){return 1}e=0;for(g=RD(d.Kb(b),20).Kc();g.Ob();){f=RD(g.Pb(),18);i=f.c.i==b?f.d.i:f.c.i;h=X9b(a,i,c,d);if(h==-1){return -1}e=$wnd.Math.max(e,h);if(e>a.c-1){return -1}}return e+1} + function _Gd(a,b){var c,d,e,f,g,h;if(dE(b)===dE(a)){return true}if(!ZD(b,15)){return false}d=RD(b,15);h=a.gc();if(d.gc()!=h){return false}g=d.Kc();if(a.Yi()){for(c=0;c0){a._j();if(b!=null){for(f=0;f>24}case 97:case 98:case 99:case 100:case 101:case 102:{return a-97+10<<24>>24}case 65:case 66:case 67:case 68:case 69:case 70:{return a-65+10<<24>>24}default:{throw Adb(new Vgb('Invalid hexadecimal'))}}} + function iIb(){iIb=geb;hIb=new jIb('SPIRAL',0);cIb=new jIb('LINE_BY_LINE',1);dIb=new jIb('MANHATTAN',2);bIb=new jIb('JITTER',3);fIb=new jIb('QUADRANTS_LINE_BY_LINE',4);gIb=new jIb('QUADRANTS_MANHATTAN',5);eIb=new jIb('QUADRANTS_JITTER',6);aIb=new jIb('COMBINE_LINE_BY_LINE_MANHATTAN',7);_Hb=new jIb('COMBINE_JITTER_MANHATTAN',8);} + function Urc(a,b,c,d){var e,f,g,h,i,j;i=Zrc(a,c);j=Zrc(b,c);e=false;while(!!i&&!!j){if(d||Xrc(i,j,c)){g=Zrc(i,c);h=Zrc(j,c);asc(b);asc(a);f=i.c;Hec(i,false);Hec(j,false);if(c){f3b(b,j.p,f);b.p=j.p;f3b(a,i.p+1,f);a.p=i.p;}else {f3b(a,i.p,f);a.p=i.p;f3b(b,j.p+1,f);b.p=j.p;}g3b(i,null);g3b(j,null);i=g;j=h;e=true;}else {break}}return e} + function aDc(a){switch(a.g){case 0:return new XHc;case 1:return new pHc;case 3:return new GGc;case 4:return new gHc;case 5:return new jIc;case 6:return new IHc;case 2:return new xHc;case 7:return new pGc;case 8:return new YGc;default:throw Adb(new agb('No implementation is available for the layerer '+(a.f!=null?a.f:''+a.g)));}} + function tIc(a,b,c,d){var e,f,g,h,i;e=false;f=false;for(h=new Anb(d.j);h.a=b.length){throw Adb(new veb('Greedy SwitchDecider: Free layer not in graph.'))}this.c=b[a];this.e=new DMc(d);rMc(this.e,this.c,(qpd(),ppd));this.i=new DMc(d);rMc(this.i,this.c,Xod);this.f=new Kmc(this.c);this.a=!f&&e.i&&!e.s&&this.c[0].k==(r3b(),m3b);this.a&&Nmc(this,a,b.length);} + function $Mb(a,b){var c,d,e,f,g,h;f=!a.B.Hc((dqd(),Wpd));g=a.B.Hc(Zpd);a.a=new wKb(g,f,a.c);!!a.n&&C2b(a.a.n,a.n);cLb(a.g,(ZJb(),XJb),a.a);if(!b){d=new dLb(1,f,a.c);d.n.a=a.k;Wrb(a.p,(qpd(),Yod),d);e=new dLb(1,f,a.c);e.n.d=a.k;Wrb(a.p,npd,e);h=new dLb(0,f,a.c);h.n.c=a.k;Wrb(a.p,ppd,h);c=new dLb(0,f,a.c);c.n.b=a.k;Wrb(a.p,Xod,c);}} + function zkc(a){var b,c,d;b=RD(mQb(a.d,(yCc(),yAc)),223);switch(b.g){case 2:c=rkc(a);break;case 3:c=(d=new bnb,FDb(CDb(GDb(EDb(EDb(new SDb(null,new Swb(a.d.b,16)),new wlc),new ylc),new Alc),new Kkc),new Clc(d)),d);break;default:throw Adb(new dgb('Compaction not supported for '+b+' edges.'));}ykc(a,c);xgb(new Xkb(a.g),new ilc(a));} + function qYc(a,b){var c,d,e,f,g,h,i;b.Ug('Process directions',1);c=RD(mQb(a,(h_c(),H$c)),88);if(c!=(Cmd(),xmd)){for(e=Sub(a.b,0);e.b!=e.d.c;){d=RD(evb(e),40);h=RD(mQb(d,(q$c(),o$c)),17).a;i=RD(mQb(d,p$c),17).a;switch(c.g){case 4:i*=-1;break;case 1:f=h;h=i;i=f;break;case 2:g=h;h=-i;i=g;}pQb(d,o$c,sgb(h));pQb(d,p$c,sgb(i));}}b.Vg();} + function led(a,b){var c;c=new qQb;!!b&&kQb(c,RD(Wjb(a.a,H4),96));ZD(b,422)&&kQb(c,RD(Wjb(a.a,L4),96));if(ZD(b,366)){kQb(c,RD(Wjb(a.a,I4),96));return c}ZD(b,84)&&kQb(c,RD(Wjb(a.a,E4),96));if(ZD(b,207)){kQb(c,RD(Wjb(a.a,J4),96));return c}if(ZD(b,193)){kQb(c,RD(Wjb(a.a,K4),96));return c}ZD(b,326)&&kQb(c,RD(Wjb(a.a,G4),96));return c} + function a_b(a){var b,c,d,e,f,g,h,i;i=new m_b;for(h=new Anb(a.a);h.a0&&b=0){return false}else {b.p=c.b;Rmb(c.e,b);}if(e==(r3b(),o3b)||e==q3b){for(g=new Anb(b.j);g.aa.d[h.p]){c+=ZLc(a.b,f);hmb(a.a,sgb(f));}}else {++g;}}c+=a.b.d*g;while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function pje(a){var b,c,d,e,f,g;f=0;b=WVd(a);!!b.kk()&&(f|=4);(a.Bb&bKe)!=0&&(f|=2);if(ZD(a,102)){c=RD(a,19);e=Z5d(c);(c.Bb&QHe)!=0&&(f|=32);if(e){AYd(uWd(e));f|=8;g=e.t;(g>1||g==-1)&&(f|=16);(e.Bb&QHe)!=0&&(f|=64);}(c.Bb&txe)!=0&&(f|=cKe);f|=gwe;}else {if(ZD(b,469)){f|=512;}else {d=b.kk();!!d&&(d.i&1)!=0&&(f|=256);}}(a.Bb&512)!=0&&(f|=128);return f} + function vke(a,b){var c;if(a.f==tke){c=yfe(Qee((lke(),jke),b));return a.e?c==4&&b!=(Lle(),Jle)&&b!=(Lle(),Gle)&&b!=(Lle(),Hle)&&b!=(Lle(),Ile):c==2}if(!!a.d&&(a.d.Hc(b)||a.d.Hc(zfe(Qee((lke(),jke),b)))||a.d.Hc(Eee((lke(),jke),a.b,b)))){return true}if(a.f){if(Xee((lke(),a.f),Bfe(Qee(jke,b)))){c=yfe(Qee(jke,b));return a.e?c==4:c==2}}return false} + function oKc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;m=-1;n=0;for(j=a,k=0,l=j.length;k0&&++n;}}}++m;}return n} + function S2c(a,b,c,d){var e,f,g,h,i,j,k,l;g=RD(Gxd(c,(umd(),Qld)),8);i=g.a;k=g.b+a;e=$wnd.Math.atan2(k,i);e<0&&(e+=dFe);e+=b;e>dFe&&(e-=dFe);h=RD(Gxd(d,Qld),8);j=h.a;l=h.b+a;f=$wnd.Math.atan2(l,j);f<0&&(f+=dFe);f+=b;f>dFe&&(f-=dFe);return Zy(),bz(1.0E-10),$wnd.Math.abs(e-f)<=1.0E-10||e==f||isNaN(e)&&isNaN(f)?0:ef?1:cz(isNaN(e),isNaN(f))} + function PGb(a){var b,c,d,e,f,g,h;h=new Tsb;for(d=new Anb(a.a.b);d.a=b.o){throw Adb(new web)}i=c>>5;h=c&31;g=Sdb(1,Ydb(Sdb(h,1)));f?(b.n[d][i]=Rdb(b.n[d][i],g)):(b.n[d][i]=Cdb(b.n[d][i],Qdb(g)));g=Sdb(g,1);e?(b.n[d][i]=Rdb(b.n[d][i],g)):(b.n[d][i]=Cdb(b.n[d][i],Qdb(g)));}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function eMc(a,b,c,d){var e,f,g,h,i,j,k,l,m;m=new yAb(new PMc(a));for(h=cD(WC(jR,1),WAe,10,0,[b,c]),i=0,j=h.length;i0){d=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!d||Zhb(Zhb((b.a+=' "',b),d),'"');}}else {Zhb(Zhb((b.a+=' "',b),c),'"');}Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function OCd(a){var b,c,d;if((a.Db&64)!=0)return Fyd(a);b=new dib(HHe);c=a.k;if(!c){!a.n&&(a.n=new C5d(I4,a,1,7));if(a.n.i>0){d=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!d||Zhb(Zhb((b.a+=' "',b),d),'"');}}else {Zhb(Zhb((b.a+=' "',b),c),'"');}Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function Xnc(a,b){var c,d,e,f,g;b==(TEc(),QEc)&&Eob(RD(Qc(a.a,(Bnc(),xnc)),15));for(e=RD(Qc(a.a,(Bnc(),xnc)),15).Kc();e.Ob();){d=RD(e.Pb(),105);c=RD(Vmb(d.j,0),113).d.j;f=new dnb(d.j);_mb(f,new Boc);switch(b.g){case 2:Pnc(a,f,c,(joc(),hoc),1);break;case 1:case 0:g=Rnc(f);Pnc(a,new Rkb(f,0,g),c,(joc(),hoc),0);Pnc(a,new Rkb(f,g,f.c.length),c,hoc,1);}}} + function sgd(a,b){var c,d,e,f,g,h,i;if(b==null||b.length==0){return null}e=RD(Xjb(a.a,b),143);if(!e){for(d=(h=(new glb(a.b)).a.vc().Kc(),new llb(h));d.a.Ob();){c=(f=RD(d.a.Pb(),44),RD(f.md(),143));g=c.c;i=b.length;if(lhb(g.substr(g.length-i,i),b)&&(b.length==g.length||ihb(g,g.length-b.length-1)==46)){if(e){return null}e=c;}}!!e&&$jb(a.a,b,e);}return e} + function HOb(a,b){var c,d,e,f;c=new MOb;d=RD(zDb(GDb(new SDb(null,new Swb(a.f,16)),c),sBb(new _Bb,new bCb,new yCb,new ACb,cD(WC(QL,1),jwe,108,0,[(xBb(),wBb),vBb]))),21);e=d.gc();d=RD(zDb(GDb(new SDb(null,new Swb(b.f,16)),c),sBb(new _Bb,new bCb,new yCb,new ACb,cD(WC(QL,1),jwe,108,0,[wBb,vBb]))),21);f=d.gc();if(ee.p){Q3b(f,npd);if(f.d){h=f.o.b;b=f.a.b;f.a.b=h-b;}}else if(f.j==npd&&e.p>a.p){Q3b(f,Yod);if(f.d){h=f.o.b;b=f.a.b;f.a.b=-(h-b);}}break}}return e} + function nTb(a,b,c,d,e){var f,g,h,i,j,k,l;if(!(ZD(b,207)||ZD(b,366)||ZD(b,193))){throw Adb(new agb('Method only works for ElkNode-, ElkLabel and ElkPort-objects.'))}g=a.a/2;i=b.i+d-g;k=b.j+e-g;j=i+b.g+a.a;l=k+b.f+a.a;f=new Ejd;Mub(f,new rjd(i,k));Mub(f,new rjd(i,l));Mub(f,new rjd(j,l));Mub(f,new rjd(j,k));h=new ORb(f);kQb(h,b);c&&Zjb(a.b,b,h);return h} + function w$b(a,b,c){var d,e,f,g,h,i,j,k,l,m;f=new rjd(b,c);for(k=new Anb(a.a);k.a1;if(h){d=new rjd(e,c.b);Mub(b.a,d);}zjd(b.a,cD(WC(l3,1),Nve,8,0,[m,l]));} + function aEc(){aEc=geb;$Dc=new bEc(LAe,0);VDc=new bEc('NIKOLOV',1);YDc=new bEc('NIKOLOV_PIXEL',2);WDc=new bEc('NIKOLOV_IMPROVED',3);XDc=new bEc('NIKOLOV_IMPROVED_PIXEL',4);SDc=new bEc('DUMMYNODE_PERCENTAGE',5);ZDc=new bEc('NODECOUNT_PERCENTAGE',6);_Dc=new bEc('NO_BOUNDARY',7);TDc=new bEc('MODEL_ORDER_LEFT_TO_RIGHT',8);UDc=new bEc('MODEL_ORDER_RIGHT_TO_LEFT',9);} + function use(a){var b,c,d,e,f;d=a.length;b=new Rhb;f=0;while(f=40;g&&wJb(a);nJb(a);mJb(a);c=qJb(a);d=0;while(!!c&&d0&&Mub(a.f,f);}else {a.c[g]-=j+1;a.c[g]<=0&&a.a[g]>0&&Mub(a.e,f);}}}}} + function FVc(a,b,c,d){var e,f,g,h,i,j,k;i=new rjd(c,d);ojd(i,RD(mQb(b,(q$c(),SZc)),8));for(k=Sub(b.b,0);k.b!=k.d.c;){j=RD(evb(k),40);$id(j.e,i);Mub(a.b,j);}for(h=RD(zDb(BDb(new SDb(null,new Swb(b.a,16))),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15).Kc();h.Ob();){g=RD(h.Pb(),65);for(f=Sub(g.a,0);f.b!=f.d.c;){e=RD(evb(f),8);e.a+=i.a;e.b+=i.b;}Mub(a.a,g);}} + function kWc(a,b){var c,d,e,f;if(0<(ZD(a,16)?RD(a,16).gc():Kr(a.Kc()))){e=b;if(1=0&&if*2){k=new zrd(l);j=urd(g)/trd(g);i=ird(k,b,new z3b,c,d,e,j);$id(hjd(k.e),i);l.c.length=0;f=0;ZEb(l.c,k);ZEb(l.c,g);f=urd(k)*trd(k)+urd(g)*trd(g);}else {ZEb(l.c,g);f+=urd(g)*trd(g);}}return l} + function O9b(a,b){var c,d,e,f,g,h;h=RD(mQb(b,(yCc(),BBc)),101);if(!(h==(Bod(),xod)||h==wod)){return}e=(new rjd(b.f.a+b.d.b+b.d.c,b.f.b+b.d.d+b.d.a)).b;for(g=new Anb(a.a);g.ac?b:c;j<=l;++j){if(j==c){h=d++;}else {f=e[j];k=o.am(f.Lk());j==b&&(i=j==l&&!k?d-1:d);k&&++d;}}m=RD(uLd(a,b,c),76);h!=i&&eZd(a,new c4d(a.e,7,g,sgb(h),n.md(),i));return m}}}else {return RD(SHd(a,b,c),76)}return RD(uLd(a,b,c),76)} + function ugc(a,b){var c,d,e,f,g,h,i;b.Ug('Port order processing',1);i=RD(mQb(a,(yCc(),HBc)),430);for(d=new Anb(a.b);d.a=0){h=rD(a,g);if(h){j<22?(i.l|=1<>>1;g.m=k>>>1|(l&1)<<21;g.l=m>>>1|(k&1)<<21;--j;}c&&nD(i);if(f){if(d){eD=xD(a);e&&(eD=DD(eD,(MD(),KD)));}else {eD=hD(a.l,a.m,a.h);}}return i} + function rIc(a,b){var c,d,e,f,g,h,i,j,k,l;j=a.e[b.c.p][b.p]+1;i=b.c.a.c.length+1;for(h=new Anb(a.a);h.a0&&(BFb(0,a.length),a.charCodeAt(0)==45||(BFb(0,a.length),a.charCodeAt(0)==43))?1:0;for(d=g;dc){throw Adb(new Vgb(nxe+a+'"'))}return h} + function Jqc(a){var b,c,d,e,f,g,h;g=new Yub;for(f=new Anb(a.a);f.a1)&&b==1&&RD(a.a[a.b],10).k==(r3b(),n3b)){Qdc(RD(a.a[a.b],10),(Pnd(),Lnd));}else if(d&&(!c||(a.c-a.b&a.a.length-1)>1)&&b==1&&RD(a.a[a.c-1&a.a.length-1],10).k==(r3b(),n3b)){Qdc(RD(a.a[a.c-1&a.a.length-1],10),(Pnd(),Mnd));}else if((a.c-a.b&a.a.length-1)==2){Qdc(RD(omb(a),10),(Pnd(),Lnd));Qdc(RD(omb(a),10),Mnd);}else {Ndc(a,e);}jmb(a);} + function QVc(a,b,c){var d,e,f,g,h;f=0;for(e=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));e.e!=e.i.gc();){d=RD(bMd(e),27);g='';(!d.n&&(d.n=new C5d(I4,d,1,7)),d.n).i==0||(g=RD(QHd((!d.n&&(d.n=new C5d(I4,d,1,7)),d.n),0),135).a);h=new bXc(f++,b,g);kQb(h,d);pQb(h,(q$c(),h$c),d);h.e.b=d.j+d.f/2;h.f.a=$wnd.Math.max(d.g,1);h.e.a=d.i+d.g/2;h.f.b=$wnd.Math.max(d.f,1);Mub(b.b,h);rtb(c.f,d,h);}} + function L5b(a){var b,c,d,e,f;d=RD(mQb(a,(Ywc(),Awc)),27);f=RD(Gxd(d,(yCc(),lBc)),181).Hc((Qpd(),Ppd));if(!a.e){e=RD(mQb(a,kwc),21);b=new rjd(a.f.a+a.d.b+a.d.c,a.f.b+a.d.d+a.d.a);if(e.Hc((ovc(),hvc))){Ixd(d,BBc,(Bod(),wod));Esd(d,b.a,b.b,false,true);}else {Heb(TD(Gxd(d,mBc)))||Esd(d,b.a,b.b,true,true);}}f?Ixd(d,lBc,xsb(Ppd)):Ixd(d,lBc,(c=RD(mfb(H3),9),new Fsb(c,RD(WEb(c,c.length),9),0)));} + function JA(a,b,c){var d,e,f,g;if(b[0]>=a.length){c.o=0;return true}switch(ihb(a,b[0])){case 43:e=1;break;case 45:e=-1;break;default:c.o=0;return true;}++b[0];f=b[0];g=HA(a,b);if(g==0&&b[0]==f){return false}if(b[0]h){h=e;k.c.length=0;}e==h&&Rmb(k,new Ptd(c.c.i,c));}yob();_mb(k,a.c);Qmb(a.b,i.p,k);}}} + function kRc(a,b){var c,d,e,f,g,h,i,j,k;for(g=new Anb(b.b);g.ah){h=e;k.c.length=0;}e==h&&Rmb(k,new Ptd(c.d.i,c));}yob();_mb(k,a.c);Qmb(a.f,i.p,k);}}} + function HVc(a,b){var c,d,e,f,g,h,i,j;j=TD(mQb(b,(h_c(),Z$c)));if(j==null||(uFb(j),j)){EVc(a,b);e=new bnb;for(i=Sub(b.b,0);i.b!=i.d.c;){g=RD(evb(i),40);c=DVc(a,g,null);if(c){kQb(c,b);ZEb(e.c,c);}}a.a=null;a.b=null;if(e.c.length>1){for(d=new Anb(e);d.a=0&&h!=c){f=new N3d(a,1,h,g,null);!d?(d=f):d.nj(f);}if(c>=0){f=new N3d(a,1,c,h==c?g:null,b);!d?(d=f):d.nj(f);}}return d} + function jSd(a){var b,c,d;if(a.b==null){d=new Qhb;if(a.i!=null){Nhb(d,a.i);d.a+=':';}if((a.f&256)!=0){if((a.f&256)!=0&&a.a!=null){wSd(a.i)||(d.a+='//',d);Nhb(d,a.a);}if(a.d!=null){d.a+='/';Nhb(d,a.d);}(a.f&16)!=0&&(d.a+='/',d);for(b=0,c=a.j.length;bm){return false}l=(i=S9c(d,m,false),i.a);if(k+h+l<=b.b){Q9c(c,f-c.s);c.c=true;Q9c(d,f-c.s);U9c(d,c.s,c.t+c.d+h);d.k=true;aad(c.q,d);n=true;if(e){Cad(b,d);d.j=b;if(a.c.length>g){Fad((tFb(g,a.c.length),RD(a.c[g],186)),d);(tFb(g,a.c.length),RD(a.c[g],186)).a.c.length==0&&Xmb(a,g);}}}return n} + function Qfc(a,b){var c,d,e,f,g,h;b.Ug('Partition midprocessing',1);e=new Tp;FDb(CDb(new SDb(null,new Swb(a.a,16)),new Ufc),new Wfc(e));if(e.d==0){return}h=RD(zDb(ODb((f=e.i,new SDb(null,(!f?(e.i=new zf(e,e.c)):f).Nc()))),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);d=h.Kc();c=RD(d.Pb(),17);while(d.Ob()){g=RD(d.Pb(),17);Pfc(RD(Qc(e,c),21),RD(Qc(e,g),21));c=g;}b.Vg();} + function G_b(a,b,c){var d,e,f,g,h,i,j,k;if(b.p==0){b.p=1;g=c;if(!g){e=new bnb;f=(d=RD(mfb(E3),9),new Fsb(d,RD(WEb(d,d.length),9),0));g=new Ptd(e,f);}RD(g.a,15).Fc(b);b.k==(r3b(),m3b)&&RD(g.b,21).Fc(RD(mQb(b,(Ywc(),hwc)),64));for(i=new Anb(b.j);i.a0){e=RD(a.Ab.g,2033);if(b==null){for(f=0;fc.s&&hg){return qpd(),Xod}break;case 4:case 3:if(k<0){return qpd(),Yod}else if(k+c>f){return qpd(),npd}}i=(j+h/2)/g;d=(k+c/2)/f;return i+d<=1&&i-d<=0?(qpd(),ppd):i+d>=1&&i-d>=0?(qpd(),Xod):d<0.5?(qpd(),Yod):(qpd(),npd)} + function PNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;c=false;k=Kfb(UD(mQb(b,(yCc(),bCc))));o=pwe*k;for(e=new Anb(b.b);e.ai+o){p=l.g+m.g;m.a=(m.g*m.a+l.g*l.a)/p;m.g=p;l.f=m;c=true;}}f=h;l=m;}}return c} + function MJb(a,b,c,d,e,f,g){var h,i,j,k,l,m;m=new Tid;for(j=b.Kc();j.Ob();){h=RD(j.Pb(),853);for(l=new Anb(h.Rf());l.a0){if(h.a){j=h.b.Mf().b;if(e>j){if(a.v||h.c.d.c.length==1){g=(e-j)/2;h.d.d=g;h.d.a=g;}else {c=RD(Vmb(h.c.d,0),187).Mf().b;d=(c-j)/2;h.d.d=$wnd.Math.max(0,d);h.d.a=e-d-j;}}}else {h.d.a=a.t+e;}}else if(Rod(a.u)){f=wsd(h.b);f.d<0&&(h.d.d=-f.d);f.d+f.a>h.b.Mf().b&&(h.d.a=f.d+f.a-h.b.Mf().b);}}} + function yVb(){yVb=geb;lVb=new mGd((umd(),Rld),sgb(1));rVb=new mGd(fmd,80);qVb=new mGd($ld,5);ZUb=new mGd(Dkd,Yze);mVb=new mGd(Sld,sgb(1));pVb=new mGd(Vld,(Geb(),true));iVb=new A3b(50);hVb=new mGd(tld,iVb);_Ub=ald;jVb=Hld;$Ub=new mGd(Pkd,false);gVb=sld;eVb=mld;fVb=pld;dVb=kld;cVb=ild;kVb=Lld;bVb=(OUb(),HUb);sVb=MUb;aVb=GUb;nVb=JUb;oVb=LUb;vVb=mmd;xVb=qmd;uVb=lmd;tVb=kmd;wVb=(mqd(),jqd);new mGd(nmd,wVb);} + function VC(a,b){var c;switch(XC(a)){case 6:return bE(b);case 7:return _D(b);case 8:return $D(b);case 3:return Array.isArray(b)&&(c=XC(b),!(c>=14&&c<=16));case 11:return b!=null&&typeof b===kve;case 12:return b!=null&&(typeof b===gve||typeof b==kve);case 0:return QD(b,a.__elementTypeId$);case 2:return cE(b)&&!(b.Tm===keb);case 1:return cE(b)&&!(b.Tm===keb)||QD(b,a.__elementTypeId$);default:return true;}} + function gNb(a){var b,c,d,e;d=a.o;RMb();if(a.A.dc()||pb(a.A,QMb)){e=d.a;}else {a.D?(e=$wnd.Math.max(d.a,ZKb(a.f))):(e=ZKb(a.f));if(a.A.Hc((Qpd(),Npd))&&!a.B.Hc((dqd(),_pd))){e=$wnd.Math.max(e,ZKb(RD(Vrb(a.p,(qpd(),Yod)),252)));e=$wnd.Math.max(e,ZKb(RD(Vrb(a.p,npd),252)));}b=TMb(a);!!b&&(e=$wnd.Math.max(e,b.a));}Heb(TD(a.e.Tf().of((umd(),mld))))?(d.a=$wnd.Math.max(d.a,e)):(d.a=e);c=a.f.i;c.c=0;c.b=e;$Kb(a.f);} + function oRb(a,b){var c,d,e,f;d=$wnd.Math.min($wnd.Math.abs(a.c-(b.c+b.b)),$wnd.Math.abs(a.c+a.b-b.c));f=$wnd.Math.min($wnd.Math.abs(a.d-(b.d+b.a)),$wnd.Math.abs(a.d+a.a-b.d));c=$wnd.Math.abs(a.c+a.b/2-(b.c+b.b/2));if(c>a.b/2+b.b/2){return 1}e=$wnd.Math.abs(a.d+a.a/2-(b.d+b.a/2));if(e>a.a/2+b.a/2){return 1}if(c==0&&e==0){return 0}if(c==0){return f/e+1}if(e==0){return d/c+1}return $wnd.Math.min(d/c,f/e)+1} + function oWb(a,b){var c,d,e,f,g,h,i;f=0;h=0;i=0;for(e=new Anb(a.f.e);e.a0&&a.d!=(AWb(),zWb)&&(h+=g*(d.d.a+a.a[b.a][d.a]*(b.d.a-d.d.a)/c));c>0&&a.d!=(AWb(),xWb)&&(i+=g*(d.d.b+a.a[b.a][d.a]*(b.d.b-d.d.b)/c));}switch(a.d.g){case 1:return new rjd(h/f,b.d.b);case 2:return new rjd(b.d.a,i/f);default:return new rjd(h/f,i/f);}} + function xsd(a){var b,c,d,e,f,g;c=(!a.a&&(a.a=new XZd(D4,a,5)),a.a).i+2;g=new cnb(c);Rmb(g,new rjd(a.j,a.k));FDb(new SDb(null,(!a.a&&(a.a=new XZd(D4,a,5)),new Swb(a.a,16))),new Usd(g));Rmb(g,new rjd(a.b,a.c));b=1;while(b0){aHb(i,false,(Cmd(),ymd));aHb(i,true,zmd);}Umb(b.g,new Elc(a,c));Zjb(a.g,b,c);} + function Ugb(){Ugb=geb;var a;Qgb=cD(WC(kE,1),Pwe,28,15,[-1,-1,30,19,15,13,11,11,10,9,9,8,8,8,8,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5]);Rgb=$C(kE,Pwe,28,37,15,1);Sgb=cD(WC(kE,1),Pwe,28,15,[-1,-1,63,40,32,28,25,23,21,20,19,19,18,18,17,17,16,16,16,15,15,15,15,14,14,14,14,14,14,13,13,13,13,13,13,13,13]);Tgb=$C(lE,rxe,28,37,14,1);for(a=2;a<=36;a++){Rgb[a]=eE($wnd.Math.pow(a,Qgb[a]));Tgb[a]=Fdb(Sve,Rgb[a]);}} + function tsd(a){var b;if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i!=1){throw Adb(new agb(tHe+(!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i))}b=new Ejd;!!BGd(RD(QHd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b),0),84))&&ye(b,usd(a,BGd(RD(QHd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b),0),84)),false));!!BGd(RD(QHd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c),0),84))&&ye(b,usd(a,BGd(RD(QHd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c),0),84)),true));return b} + function zRc(a,b){var c,d,e,f,g;b.d?(e=a.a.c==(wQc(),vQc)?Z2b(b.b):a3b(b.b)):(e=a.a.c==(wQc(),uQc)?Z2b(b.b):a3b(b.b));f=false;for(d=new is(Mr(e.a.Kc(),new ir));gs(d);){c=RD(hs(d),18);g=Heb(a.a.f[a.a.g[b.b.p].p]);if(!g&&!W0b(c)&&c.c.i.c==c.d.i.c){continue}if(Heb(a.a.n[a.a.g[b.b.p].p])||Heb(a.a.n[a.a.g[b.b.p].p])){continue}f=true;if(Zsb(a.b,a.a.g[rRc(c,b.b).p])){b.c=true;b.a=c;return b}}b.c=f;b.a=null;return b} + function QJd(a,b,c){var d,e,f,g,h,i,j;d=c.gc();if(d==0){return false}else {if(a.Pj()){i=a.Qj();ZId(a,b,c);g=d==1?a.Ij(3,null,c.Kc().Pb(),b,i):a.Ij(5,null,c,b,i);if(a.Mj()){h=d<100?null:new gLd(d);f=b+d;for(e=b;e0){for(g=0;g>16==-15&&a.Cb.Yh()&&pKd(new O3d(a.Cb,9,13,c,a.c,fZd(o4d(RD(a.Cb,62)),a)));}else if(ZD(a.Cb,90)){if(a.Db>>16==-23&&a.Cb.Yh()){b=a.c;ZD(b,90)||(b=(JTd(),zTd));ZD(c,90)||(c=(JTd(),zTd));pKd(new O3d(a.Cb,9,10,c,b,fZd(tYd(RD(a.Cb,29)),a)));}}}}return a.c} + function lac(a,b,c){var d,e,f,g,h,i,j,k,l;c.Ug('Hyperedge merging',1);jac(a,b);i=new Jkb(b.b,0);while(i.b0;h=oIb(b,f);c?FIb(h.b,b):FIb(h.g,b);CIb(h).c.length==1&&(Pub(d,h,d.c.b,d.c),true);e=new Ptd(f,b);hmb(a.o,e);Ymb(a.e.a,f);}} + function SQb(a,b){var c,d,e,f,g,h,i;d=$wnd.Math.abs(Oid(a.b).a-Oid(b.b).a);h=$wnd.Math.abs(Oid(a.b).b-Oid(b.b).b);e=0;i=0;c=1;g=1;if(d>a.b.b/2+b.b.b/2){e=$wnd.Math.min($wnd.Math.abs(a.b.c-(b.b.c+b.b.b)),$wnd.Math.abs(a.b.c+a.b.b-b.b.c));c=1-e/d;}if(h>a.b.a/2+b.b.a/2){i=$wnd.Math.min($wnd.Math.abs(a.b.d-(b.b.d+b.b.a)),$wnd.Math.abs(a.b.d+a.b.a-b.b.d));g=1-i/h;}f=$wnd.Math.min(c,g);return (1-f)*$wnd.Math.sqrt(d*d+h*h)} + function LUc(a){var b,c,d,e;NUc(a,a.e,a.f,(dVc(),bVc),true,a.c,a.i);NUc(a,a.e,a.f,bVc,false,a.c,a.i);NUc(a,a.e,a.f,cVc,true,a.c,a.i);NUc(a,a.e,a.f,cVc,false,a.c,a.i);MUc(a,a.c,a.e,a.f,a.i);d=new Jkb(a.i,0);while(d.b=65;c--){xqe[c]=c-65<<24>>24;}for(d=122;d>=97;d--){xqe[d]=d-97+26<<24>>24;}for(e=57;e>=48;e--){xqe[e]=e-48+52<<24>>24;}xqe[43]=62;xqe[47]=63;for(f=0;f<=25;f++)yqe[f]=65+f&Bwe;for(g=26,i=0;g<=51;++g,i++)yqe[g]=97+i&Bwe;for(a=52,h=0;a<=61;++a,h++)yqe[a]=48+h&Bwe;yqe[62]=43;yqe[63]=47;} + function uib(a,b){var c,d,e,f,g,h;e=xib(a);h=xib(b);if(e==h){if(a.e==b.e&&a.a<54&&b.a<54){return a.fb.f?1:0}d=a.e-b.e;c=(a.d>0?a.d:$wnd.Math.floor((a.a-1)*xxe)+1)-(b.d>0?b.d:$wnd.Math.floor((b.a-1)*xxe)+1);if(c>d+1){return e}else if(c0&&(g=Wib(g,Sjb(d)));return Qib(f,g)}}else return ej){m=0;n+=i+b;i=0;}w$b(g,m,n);c=$wnd.Math.max(c,m+k.a);i=$wnd.Math.max(i,k.b);m+=k.a+b;}return new rjd(c+b,n+i+b)} + function osd(a,b){var c,d,e,f,g,h,i;if(!MCd(a)){throw Adb(new dgb(sHe))}d=MCd(a);f=d.g;e=d.f;if(f<=0&&e<=0){return qpd(),opd}h=a.i;i=a.j;switch(b.g){case 2:case 1:if(h<0){return qpd(),ppd}else if(h+a.g>f){return qpd(),Xod}break;case 4:case 3:if(i<0){return qpd(),Yod}else if(i+a.f>e){return qpd(),npd}}g=(h+a.g/2)/f;c=(i+a.f/2)/e;return g+c<=1&&g-c<=0?(qpd(),ppd):g+c>=1&&g-c>=0?(qpd(),Xod):c<0.5?(qpd(),Yod):(qpd(),npd)} + function Djb(a,b,c,d,e){var f,g;f=Bdb(Cdb(b[0],yxe),Cdb(d[0],yxe));a[0]=Ydb(f);f=Tdb(f,32);if(c>=e){for(g=1;g0){e.b[g++]=0;e.b[g++]=f.b[0]-1;}for(b=1;b0){PSc(i,i.d-e.d);e.c==(fTc(),dTc)&&NSc(i,i.a-e.d);i.d<=0&&i.i>0&&(Pub(b,i,b.c.b,b.c),true);}}}for(f=new Anb(a.f);f.a0){QSc(h,h.i-e.d);e.c==(fTc(),dTc)&&OSc(h,h.b-e.d);h.i<=0&&h.d>0&&(Pub(c,h,c.c.b,c.c),true);}}}} + function drd(a,b,c,d,e){var f,g,h,i,j,k,l,m,n;yob();_mb(a,new Mrd);g=gv(a);n=new bnb;m=new bnb;h=null;i=0;while(g.b!=0){f=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),163);if(!h||urd(h)*trd(h)/21&&(i>urd(h)*trd(h)/2||g.b==0)){l=new zrd(m);k=urd(h)/trd(h);j=ird(l,b,new z3b,c,d,e,k);$id(hjd(l.e),j);h=l;ZEb(n.c,l);i=0;m.c.length=0;}}}Tmb(n,m);return n} + function hib(a,b,c,d,e){gib();var f,g,h,i,j,k,l;vFb(a,'src');vFb(c,'dest');l=rb(a);i=rb(c);qFb((l.i&4)!=0,'srcType is not an array');qFb((i.i&4)!=0,'destType is not an array');k=l.c;g=i.c;qFb((k.i&1)!=0?k==g:(g.i&1)==0,"Array types don't match");iib(a,b,c,d,e);if((k.i&1)==0&&l!=i){j=SD(a);f=SD(c);if(dE(a)===dE(c)&&bd;){bD(f,h,j[--b]);}}else {for(h=d+e;d0);d.a.Xb(d.c=--d.b);l>m+i&&Ckb(d);}for(g=new Anb(n);g.a0);d.a.Xb(d.c=--d.b);}}}} + function gte(){Vse();var a,b,c,d,e,f;if(Fse)return Fse;a=(new xte(4));ute(a,hte(WLe,true));wte(a,hte('M',true));wte(a,hte('C',true));f=(new xte(4));for(d=0;d<11;d++){rte(f,d,d);}b=(new xte(4));ute(b,hte('M',true));rte(b,4448,4607);rte(b,65438,65439);e=(new iue(2));hue(e,a);hue(e,Ese);c=(new iue(2));c.Jm($se(f,hte('L',true)));c.Jm(b);c=(new Kte(3,c));c=(new Qte(e,c));Fse=c;return Fse} + function vhb(a,b){var c,d,e,f,g,h,i,j;c=new RegExp(b,'g');i=$C(qJ,Nve,2,0,6,1);d=0;j=a;f=null;while(true){h=c.exec(j);if(h==null||j==''){i[d]=j;break}else {g=h.index;i[d]=(AFb(0,g,j.length),j.substr(0,g));j=zhb(j,g+h[0].length,j.length);c.lastIndex=0;if(f==j){i[d]=(AFb(0,1,j.length),j.substr(0,1));j=(BFb(1,j.length+1),j.substr(1));}f=j;++d;}}if(a.length>0){e=i.length;while(e>0&&i[e-1]==''){--e;}e0){l-=d[0]+a.c;d[0]+=a.c;}d[2]>0&&(l-=d[2]+a.c);d[1]=$wnd.Math.max(d[1],l);dKb(a.a[1],c.c+b.b+d[0]-(d[1]-l)/2,d[1]);}for(f=a.a,h=0,j=f.length;h0?(a.n.c.length-1)*a.i:0;for(d=new Anb(a.n);d.a1){for(d=Sub(e,0);d.b!=d.d.c;){c=RD(evb(d),235);f=0;for(i=new Anb(c.e);i.a0){b[0]+=a.c;l-=b[0];}b[2]>0&&(l-=b[2]+a.c);b[1]=$wnd.Math.max(b[1],l);eKb(a.a[1],d.d+c.d+b[0]-(b[1]-l)/2,b[1]);}else {o=d.d+c.d;n=d.a-c.d-c.a;for(g=a.a,i=0,k=g.length;i0||$y(e.b.d,a.b.d+a.b.a)==0&&d.b<0||$y(e.b.d+e.b.a,a.b.d)==0&&d.b>0){h=0;break}}else {h=$wnd.Math.min(h,PQb(a,e,d));}h=$wnd.Math.min(h,FQb(a,f,h,d));}return h} + function lsd(a,b){var c,d,e,f,g,h,i;if(a.b<2){throw Adb(new agb('The vector chain must contain at least a source and a target point.'))}e=(sFb(a.b!=0),RD(a.a.a.c,8));Nzd(b,e.a,e.b);i=new mMd((!b.a&&(b.a=new XZd(D4,b,5)),b.a));g=Sub(a,1);while(g.a=0&&f!=c){throw Adb(new agb(LIe))}}e=0;for(i=0;iKfb(pJc(g.g,g.d[0]).a)){sFb(i.b>0);i.a.Xb(i.c=--i.b);Ikb(i,g);e=true;}else if(!!h.e&&h.e.gc()>0){f=(!h.e&&(h.e=new bnb),h.e).Mc(b);j=(!h.e&&(h.e=new bnb),h.e).Mc(c);if(f||j){(!h.e&&(h.e=new bnb),h.e).Fc(g);++g.c;}}}e||(ZEb(d.c,g),true);} + function H3c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;l=a.a.i+a.a.g/2;m=a.a.i+a.a.g/2;o=b.i+b.g/2;q=b.j+b.f/2;h=new rjd(o,q);j=RD(Gxd(b,(umd(),Qld)),8);j.a=j.a+l;j.b=j.b+m;f=(h.b-j.b)/(h.a-j.a);d=h.b-f*h.a;p=c.i+c.g/2;r=c.j+c.f/2;i=new rjd(p,r);k=RD(Gxd(c,Qld),8);k.a=k.a+l;k.b=k.b+m;g=(i.b-k.b)/(i.a-k.a);e=i.b-g*i.a;n=(d-e)/(g-f);if(j.a>>0,'0'+b.toString(16));d='\\x'+zhb(c,c.length-2,c.length);}else if(a>=txe){c=(b=a>>>0,'0'+b.toString(16));d='\\v'+zhb(c,c.length-6,c.length);}else d=''+String.fromCharCode(a&Bwe);}return d} + function Ugc(a){var b,c,d;if(Dod(RD(mQb(a,(yCc(),BBc)),101))){for(c=new Anb(a.j);c.a=b.o&&c.f<=b.f||b.a*0.5<=c.f&&b.a*1.5>=c.f){g=RD(Vmb(b.n,b.n.c.length-1),209);if(g.e+g.d+c.g+e<=d&&(f=RD(Vmb(b.n,b.n.c.length-1),209),f.f-a.f+c.f<=a.b||a.a.c.length==1)){K9c(b,c);return true}else if(b.s+c.g<=d&&(b.t+b.d+c.f+e<=a.b||a.a.c.length==1)){Rmb(b.b,c);h=RD(Vmb(b.n,b.n.c.length-1),209);Rmb(b.n,new _9c(b.s,h.f+h.a+b.i,b.i));W9c(RD(Vmb(b.n,b.n.c.length-1),209),c);M9c(b,c);return true}}return false} + function xLd(a,b,c){var d,e,f,g;if(a.Pj()){e=null;f=a.Qj();d=a.Ij(1,g=UHd(a,b,c),c,b,f);if(a.Mj()&&!(a.Yi()&&g!=null?pb(g,c):dE(g)===dE(c))){g!=null&&(e=a.Oj(g,e));e=a.Nj(c,e);a.Tj()&&(e=a.Wj(g,c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Tj()&&(e=a.Wj(g,c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}return g}else {g=UHd(a,b,c);if(a.Mj()&&!(a.Yi()&&g!=null?pb(g,c):dE(g)===dE(c))){e=null;g!=null&&(e=a.Oj(g,null));e=a.Nj(c,e);!!e&&e.oj();}return g}} + function Rsc(a,b){var c,d,e,f,g;b.Ug('Path-Like Graph Wrapping',1);if(a.b.c.length==0){b.Vg();return}e=new ysc(a);g=(e.i==null&&(e.i=tsc(e,new Asc)),Kfb(e.i)*e.f);c=g/(e.i==null&&(e.i=tsc(e,new Asc)),Kfb(e.i));if(e.b>c){b.Vg();return}switch(RD(mQb(a,(yCc(),rCc)),351).g){case 2:f=new Ksc;break;case 0:f=new zrc;break;default:f=new Nsc;}d=f.og(a,e);if(!f.pg()){switch(RD(mQb(a,xCc),352).g){case 2:d=Wsc(e,d);break;case 1:d=Usc(e,d);}}Qsc(a,e,d);b.Vg();} + function mB(a,b){var c,d,e,f,g,h,i,j;b%=24;if(a.q.getHours()!=b){d=new $wnd.Date(a.q.getTime());d.setDate(d.getDate()+1);h=a.q.getTimezoneOffset()-d.getTimezoneOffset();if(h>0){i=h/60|0;j=h%60;e=a.q.getDate();c=a.q.getHours();c+i>=24&&++e;f=new $wnd.Date(a.q.getFullYear(),a.q.getMonth(),e,b+i,a.q.getMinutes()+j,a.q.getSeconds(),a.q.getMilliseconds());a.q.setTime(f.getTime());}}g=a.q.getTime();a.q.setTime(g+3600000);a.q.getHours()!=b&&a.q.setTime(g);} + function kKc(a,b){var c,d,e,f;Nwb(a.d,a.e);a.c.a.$b();if(Kfb(UD(mQb(b.j,(yCc(),Zzc))))!=0||Kfb(UD(mQb(b.j,Zzc)))!=0){c=Hze;dE(mQb(b.j,cAc))!==dE((kEc(),hEc))&&pQb(b.j,(Ywc(),jwc),(Geb(),true));f=RD(mQb(b.j,gCc),17).a;for(e=0;ee&&++j;Rmb(g,(tFb(h+j,b.c.length),RD(b.c[h+j],17)));i+=(tFb(h+j,b.c.length),RD(b.c[h+j],17)).a-d;++c;while(c=q&&a.e[i.p]>o*a.b||t>=c*q){ZEb(m.c,h);h=new bnb;ye(g,f);f.a.$b();j-=k;n=$wnd.Math.max(n,j*a.b+p);j+=t;s=t;t=0;k=0;p=0;}}return new Ptd(n,m)} + function pYd(a){var b,c,d,e,f,g,h;if(!a.d){h=new v_d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(zYd(a));d.e!=d.i.gc();){c=RD(bMd(d),29);YGd(h,pYd(c));}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}g=h.i;for(e=(!a.q&&(a.q=new C5d(s7,a,11,10)),new dMd(a.q));e.e!=e.i.gc();++g){RD(bMd(e),411);}YGd(h,(!a.q&&(a.q=new C5d(s7,a,11,10)),a.q));VHd(h);a.d=new N$d((RD(QHd(xYd((lTd(),kTd).o),9),19),h.i),h.g);a.e=RD(h.g,688);a.e==null&&(a.e=jYd);yYd(a).b&=-17;}return a.d} + function kge(a,b,c,d){var e,f,g,h,i,j;j=pke(a.e.Dh(),b);i=0;e=RD(a.g,124);nke();if(RD(b,69).xk()){for(g=0;g1||o==-1){l=RD(p,71);m=RD(k,71);if(l.dc()){m.$b();}else {g=!!Z5d(b);f=0;for(h=a.a?l.Kc():l.Ii();h.Ob();){j=RD(h.Pb(),58);e=RD(cub(a,j),58);if(!e){if(a.b&&!g){m.Gi(f,j);++f;}}else {if(g){i=m.dd(e);i==-1?m.Gi(f,e):f!=i&&m.Ui(f,e);}else {m.Gi(f,e);}++f;}}}}else {if(p==null){k.Wb(null);}else {e=cub(a,p);e==null?a.b&&!Z5d(b)&&k.Wb(p):k.Wb(e);}}}}} + function V9b(a,b){var c,d,e,f,g,h,i,j;c=new aac;for(e=new is(Mr(Z2b(b).a.Kc(),new ir));gs(e);){d=RD(hs(e),18);if(W0b(d)){continue}h=d.c.i;if(W9b(h,T9b)){j=X9b(a,h,T9b,S9b);if(j==-1){continue}c.b=$wnd.Math.max(c.b,j);!c.a&&(c.a=new bnb);Rmb(c.a,h);}}for(g=new is(Mr(a3b(b).a.Kc(),new ir));gs(g);){f=RD(hs(g),18);if(W0b(f)){continue}i=f.d.i;if(W9b(i,S9b)){j=X9b(a,i,S9b,T9b);if(j==-1){continue}c.d=$wnd.Math.max(c.d,j);!c.c&&(c.c=new bnb);Rmb(c.c,i);}}return c} + function pcc(a,b,c,d){var e,f,g,h,i,j,k;if(c.d.i==b.i){return}e=new j3b(a);h3b(e,(r3b(),o3b));pQb(e,(Ywc(),Awc),c);pQb(e,(yCc(),BBc),(Bod(),wod));ZEb(d.c,e);g=new R3b;P3b(g,e);Q3b(g,(qpd(),ppd));h=new R3b;P3b(h,e);Q3b(h,Xod);k=c.d;Z0b(c,g);f=new a1b;kQb(f,c);pQb(f,RAc,null);Y0b(f,h);Z0b(f,k);j=new Jkb(c.b,0);while(j.b1000000){throw Adb(new teb('power of ten too big'))}if(a<=lve){return Zib(Yib(Jjb[1],b),b)}d=Yib(Jjb[1],lve);e=d;c=Hdb(a-lve);b=eE(a%lve);while(Ddb(c,lve)>0){e=Wib(e,d);c=Vdb(c,lve);}e=Wib(e,Yib(Jjb[1],b));e=Zib(e,lve);c=Hdb(a-lve);while(Ddb(c,lve)>0){e=Zib(e,lve);c=Vdb(c,lve);}e=Zib(e,b);return e} + function s9b(a){var b,c,d,e,f,g,h,i,j,k;for(i=new Anb(a.a);i.aj&&d>j){k=h;j=Kfb(b.p[h.p])+Kfb(b.d[h.p])+h.o.b+h.d.a;}else {e=false;c._g()&&c.bh('bk node placement breaks on '+h+' which should have been after '+k);break}}if(!e){break}}c._g()&&c.bh(b+' is feasible: '+e);return e} + function Dfc(a,b,c,d){var e,f,g,h,i,j,k,l,m;f=new j3b(a);h3b(f,(r3b(),q3b));pQb(f,(yCc(),BBc),(Bod(),wod));e=0;if(b){g=new R3b;pQb(g,(Ywc(),Awc),b);pQb(f,Awc,b.i);Q3b(g,(qpd(),ppd));P3b(g,f);m=s2b(b.e);for(j=m,k=0,l=j.length;k0){if(e<0&&k.a){e=i;f=j[0];d=0;}if(e>=0){h=k.b;if(i==e){h-=d++;if(h==0){return 0}}if(!MA(b,j,k,h,g)){i=e-1;j[0]=f;continue}}else {e=-1;if(!MA(b,j,k,0,g)){return 0}}}else {e=-1;if(ihb(k.c,0)==32){l=j[0];KA(b,j);if(j[0]>l){continue}}else if(xhb(b,k.c,j[0])){j[0]+=k.c.length;continue}return 0}}if(!CB(g,c)){return 0}return j[0]} + function qWb(a,b,c){var d,e,f,g,h,i,j,k,l,m;k=new pwb(new GWb(c));h=$C(xdb,Hye,28,a.f.e.c.length,16,1);Snb(h,h.length);c[b.a]=0;for(j=new Anb(a.f.e);j.a=0&&!PPb(a,k,l)){--l;}e[k]=l;}for(n=0;n=0&&!PPb(a,h,o)){--h;}f[o]=h;}for(i=0;ib[m]&&md[i]&&TPb(a,i,m,false,true);}}} + function hUb(a){var b,c,d,e,f,g,h,i;c=Heb(TD(mQb(a,(yVb(),$Ub))));f=a.a.c.d;h=a.a.d.d;if(c){g=ijd(ojd(new rjd(h.a,h.b),f),0.5);i=ijd(ajd(a.e),0.5);b=ojd($id(new rjd(f.a,f.b),g),i);mjd(a.d,b);}else {e=Kfb(UD(mQb(a.a,qVb)));d=a.d;if(f.a>=h.a){if(f.b>=h.b){d.a=h.a+(f.a-h.a)/2+e;d.b=h.b+(f.b-h.b)/2-e-a.e.b;}else {d.a=h.a+(f.a-h.a)/2+e;d.b=f.b+(h.b-f.b)/2+e;}}else {if(f.b>=h.b){d.a=f.a+(h.a-f.a)/2+e;d.b=h.b+(f.b-h.b)/2+e;}else {d.a=f.a+(h.a-f.a)/2+e;d.b=f.b+(h.b-f.b)/2-e-a.e.b;}}}} + function qYd(a){var b,c,d,e,f,g,h,i;if(!a.f){i=new a_d;h=new a_d;b=iYd;g=b.a.zc(a,b);if(g==null){for(f=new dMd(zYd(a));f.e!=f.i.gc();){e=RD(bMd(f),29);YGd(i,qYd(e));}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}for(d=(!a.s&&(a.s=new C5d(y7,a,21,17)),new dMd(a.s));d.e!=d.i.gc();){c=RD(bMd(d),179);ZD(c,102)&&WGd(h,RD(c,19));}VHd(h);a.r=new s_d(a,(RD(QHd(xYd((lTd(),kTd).o),6),19),h.i),h.g);YGd(i,a.r);VHd(i);a.f=new N$d((RD(QHd(xYd(kTd.o),5),19),i.i),i.g);yYd(a).b&=-3;}return a.f} + function uSb(a){Cgd(a,new Pfd($fd(Xfd(Zfd(Yfd(new agd,Aze),'ELK DisCo'),'Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out.'),new xSb)));Agd(a,Aze,Bze,iGd(sSb));Agd(a,Aze,Cze,iGd(mSb));Agd(a,Aze,Dze,iGd(hSb));Agd(a,Aze,Eze,iGd(nSb));Agd(a,Aze,Bye,iGd(qSb));Agd(a,Aze,Cye,iGd(pSb));Agd(a,Aze,Aye,iGd(rSb));Agd(a,Aze,Dye,iGd(oSb));Agd(a,Aze,vze,iGd(jSb));Agd(a,Aze,wze,iGd(iSb));Agd(a,Aze,xze,iGd(kSb));Agd(a,Aze,yze,iGd(lSb));} + function qAd(){qAd=geb;oAd=cD(WC(hE,1),zwe,28,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]);pAd=new RegExp('[ \t\n\r\f]+');try{nAd=cD(WC(h8,1),rve,2114,0,[new c2d((WA(),YA("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",_A(($A(),$A(),ZA))))),new c2d(YA("yyyy-MM-dd'T'HH:mm:ss'.'SSS",_A((null,ZA)))),new c2d(YA("yyyy-MM-dd'T'HH:mm:ss",_A((null,ZA)))),new c2d(YA("yyyy-MM-dd'T'HH:mm",_A((null,ZA)))),new c2d(YA('yyyy-MM-dd',_A((null,ZA))))]);}catch(a){a=zdb(a);if(!ZD(a,82))throw Adb(a)}} + function uKc(a,b){var c,d,e,f;e=Kwb(a.d,1)!=0;d=mKc(a,b);if(d==0&&Heb(TD(mQb(b.j,(Ywc(),jwc))))){return 0}!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,Owc)))||dE(mQb(b.j,(yCc(),cAc)))===dE((kEc(),hEc))?b.c.mg(b.e,e):(e=Heb(TD(mQb(b.j,jwc))));DKc(a,b,e,true);Heb(TD(mQb(b.j,Owc)))&&pQb(b.j,Owc,(Geb(),false));if(Heb(TD(mQb(b.j,jwc)))){pQb(b.j,jwc,(Geb(),false));pQb(b.j,Owc,true);}c=mKc(a,b);do{yKc(a);if(c==0){return 0}e=!e;f=c;DKc(a,b,e,false);c=mKc(a,b);}while(f>c);return f} + function vKc(a,b){var c,d,e,f;e=Kwb(a.d,1)!=0;d=lKc(a,b);if(d==0&&Heb(TD(mQb(b.j,(Ywc(),jwc))))){return 0}!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,Owc)))||dE(mQb(b.j,(yCc(),cAc)))===dE((kEc(),hEc))?b.c.mg(b.e,e):(e=Heb(TD(mQb(b.j,jwc))));DKc(a,b,e,true);Heb(TD(mQb(b.j,Owc)))&&pQb(b.j,Owc,(Geb(),false));if(Heb(TD(mQb(b.j,jwc)))){pQb(b.j,jwc,(Geb(),false));pQb(b.j,Owc,true);}c=lKc(a,b);do{yKc(a);if(c==0){return 0}e=!e;f=c;DKc(a,b,e,false);c=lKc(a,b);}while(f>c);return f} + function Gid(a,b,c,d){var e,f,g,h,i,j,k,l,m;i=ojd(new rjd(c.a,c.b),a);j=i.a*b.b-i.b*b.a;k=b.a*d.b-b.b*d.a;l=(i.a*d.b-i.b*d.a)/k;m=j/k;if(k==0){if(j==0){e=$id(new rjd(c.a,c.b),ijd(new rjd(d.a,d.b),0.5));f=bjd(a,e);g=bjd($id(new rjd(a.a,a.b),b),e);h=$wnd.Math.sqrt(d.a*d.a+d.b*d.b)*0.5;if(f=0&&l<=1&&m>=0&&m<=1?$id(new rjd(a.a,a.b),ijd(new rjd(b.a,b.b),l)):null}} + function QWb(a,b,c){var d,e,f,g,h;d=RD(mQb(a,(yCc(),dAc)),21);c.a>b.a&&(d.Hc((ukd(),okd))?(a.c.a+=(c.a-b.a)/2):d.Hc(qkd)&&(a.c.a+=c.a-b.a));c.b>b.b&&(d.Hc((ukd(),skd))?(a.c.b+=(c.b-b.b)/2):d.Hc(rkd)&&(a.c.b+=c.b-b.b));if(RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),hvc))&&(c.a>b.a||c.b>b.b)){for(h=new Anb(a.a);h.ab.a&&(d.Hc((ukd(),okd))?(a.c.a+=(c.a-b.a)/2):d.Hc(qkd)&&(a.c.a+=c.a-b.a));c.b>b.b&&(d.Hc((ukd(),skd))?(a.c.b+=(c.b-b.b)/2):d.Hc(rkd)&&(a.c.b+=c.b-b.b));if(RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),hvc))&&(c.a>b.a||c.b>b.b)){for(g=new Anb(a.a);g.a0?a.i:0)>b&&i>0){f=0;g+=i+a.i;e=$wnd.Math.max(e,m);d+=i+a.i;i=0;m=0;if(c){++l;Rmb(a.n,new _9c(a.s,g,a.i));}h=0;}m+=j.g+(h>0?a.i:0);i=$wnd.Math.max(i,j.f);c&&W9c(RD(Vmb(a.n,l),209),j);f+=j.g+(h>0?a.i:0);++h;}e=$wnd.Math.max(e,m);d+=i;if(c){a.r=e;a.d=d;Ead(a.j);}return new Uid(a.s,a.t,e,d)} + function CRb(a){var b,c,d,e,f,g,h,i,j,k,l,m;a.b=false;l=oxe;i=pxe;m=oxe;j=pxe;for(d=a.e.a.ec().Kc();d.Ob();){c=RD(d.Pb(),272);e=c.a;l=$wnd.Math.min(l,e.c);i=$wnd.Math.max(i,e.c+e.b);m=$wnd.Math.min(m,e.d);j=$wnd.Math.max(j,e.d+e.a);for(g=new Anb(c.c);g.aa.o.a){k=(i-a.o.a)/2;h.b=$wnd.Math.max(h.b,k);h.c=$wnd.Math.max(h.c,k);}} + function RId(a){var b,c,d,e,f,g,h,i;f=new med;ied(f,(hed(),eed));for(d=(e=oC(a,$C(qJ,Nve,2,0,6,1)),new Dkb(new mob((new CC(a,e)).b)));d.bh?1:-1:Ejb(a.a,b.a,f);if(e==-1){l=-i;k=g==i?Hjb(b.a,h,a.a,f):Cjb(b.a,h,a.a,f);}else {l=g;if(g==i){if(e==0){return Pib(),Oib}k=Hjb(a.a,f,b.a,h);}else {k=Cjb(a.a,f,b.a,h);}}j=new cjb(l,k.length,k);Rib(j);return j} + function c5b(a,b){var c,d,e,f;f=Z4b(b);!b.c&&(b.c=new C5d(K4,b,9,9));FDb(new SDb(null,(!b.c&&(b.c=new C5d(K4,b,9,9)),new Swb(b.c,16))),new s5b(f));e=RD(mQb(f,(Ywc(),kwc)),21);Y4b(b,e);if(e.Hc((ovc(),hvc))){for(d=new dMd((!b.c&&(b.c=new C5d(K4,b,9,9)),b.c));d.e!=d.i.gc();){c=RD(bMd(d),123);g5b(a,b,f,c);}}RD(Gxd(b,(yCc(),lBc)),181).gc()!=0&&V4b(b,f);Heb(TD(mQb(f,sBc)))&&e.Fc(mvc);nQb(f,PBc)&&HCc(new RCc(Kfb(UD(mQb(f,PBc)))),f);dE(Gxd(b,IAc))===dE((Fnd(),Cnd))?d5b(a,b,f):b5b(a,b,f);return f} + function Vrc(a){var b,c,d,e,f,g,h,i;for(e=new Anb(a.b);e.a0?zhb(c.a,0,f-1):''}}else {return !c?a:c.a}} + function xic(a,b){var c,d,e,f,g,h,i;b.Ug('Sort By Input Model '+mQb(a,(yCc(),cAc)),1);e=0;for(d=new Anb(a.b);d.a=a.b.length){f[e++]=g.b[d++];f[e++]=g.b[d++];}else if(d>=g.b.length){f[e++]=a.b[c++];f[e++]=a.b[c++];}else if(g.b[d]0?a.i:0);}++b;}Ce(a.n,i);a.d=c;a.r=d;a.g=0;a.f=0;a.e=0;a.o=oxe;a.p=oxe;for(f=new Anb(a.b);f.a0){e=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!e||Zhb(Zhb((b.a+=' "',b),e),'"');}}else {Zhb(Zhb((b.a+=' "',b),d),'"');}c=(!a.b&&(a.b=new Yie(E4,a,4,7)),!(a.b.i<=1&&(!a.c&&(a.c=new Yie(E4,a,5,8)),a.c.i<=1)));c?(b.a+=' [',b):(b.a+=' ',b);Zhb(b,Eb(new Gb,new dMd(a.b)));c&&(b.a+=']',b);b.a+=SAe;c&&(b.a+='[',b);Zhb(b,Eb(new Gb,new dMd(a.c)));c&&(b.a+=']',b);return b.a} + function odc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;v=a.c;w=b.c;c=Wmb(v.a,a,0);d=Wmb(w.a,b,0);t=RD(c3b(a,(BEc(),yEc)).Kc().Pb(),12);C=RD(c3b(a,zEc).Kc().Pb(),12);u=RD(c3b(b,yEc).Kc().Pb(),12);D=RD(c3b(b,zEc).Kc().Pb(),12);r=s2b(t.e);A=s2b(C.g);s=s2b(u.e);B=s2b(D.g);f3b(a,d,w);for(g=s,k=0,o=g.length;kk){new bTc((fTc(),eTc),c,b,j-k);}else if(j>0&&k>0){new bTc((fTc(),eTc),b,c,0);new bTc(eTc,c,b,0);}}return g} + function pXc(a,b,c){var d,e,f;a.a=new bnb;for(f=Sub(b.b,0);f.b!=f.d.c;){e=RD(evb(f),40);while(RD(mQb(e,(h_c(),f_c)),17).a>a.a.c.length-1){Rmb(a.a,new Ptd(Hze,KEe));}d=RD(mQb(e,f_c),17).a;if(c==(Cmd(),ymd)||c==zmd){e.e.aKfb(UD(RD(Vmb(a.a,d),42).b))&&Otd(RD(Vmb(a.a,d),42),e.e.a+e.f.a);}else {e.e.bKfb(UD(RD(Vmb(a.a,d),42).b))&&Otd(RD(Vmb(a.a,d),42),e.e.b+e.f.b);}}} + function g2b(a,b,c,d){var e,f,g,h,i,j,k;f=i2b(d);h=Heb(TD(mQb(d,(yCc(),aBc))));if((h||Heb(TD(mQb(a,MAc))))&&!Dod(RD(mQb(a,BBc),101))){e=vpd(f);i=q2b(a,c,c==(BEc(),zEc)?e:spd(e));}else {i=new R3b;P3b(i,a);if(b){k=i.n;k.a=b.a-a.n.a;k.b=b.b-a.n.b;_id(k,0,0,a.o.a,a.o.b);Q3b(i,c2b(i,f));}else {e=vpd(f);Q3b(i,c==(BEc(),zEc)?e:spd(e));}g=RD(mQb(d,(Ywc(),kwc)),21);j=i.j;switch(f.g){case 2:case 1:(j==(qpd(),Yod)||j==npd)&&g.Fc((ovc(),lvc));break;case 4:case 3:(j==(qpd(),Xod)||j==ppd)&&g.Fc((ovc(),lvc));}}return i} + function VXb(a,b){var c,d,e,f,g,h;for(g=new vkb((new mkb(a.f.b)).a);g.b;){f=tkb(g);e=RD(f.ld(),602);if(b==1){if(e.Af()!=(Cmd(),Bmd)&&e.Af()!=xmd){continue}}else {if(e.Af()!=(Cmd(),ymd)&&e.Af()!=zmd){continue}}d=RD(RD(f.md(),42).b,86);h=RD(RD(f.md(),42).a,194);c=h.c;switch(e.Af().g){case 2:d.g.c=a.e.a;d.g.b=$wnd.Math.max(1,d.g.b+c);break;case 1:d.g.c=d.g.c+c;d.g.b=$wnd.Math.max(1,d.g.b-c);break;case 4:d.g.d=a.e.b;d.g.a=$wnd.Math.max(1,d.g.a+c);break;case 3:d.g.d=d.g.d+c;d.g.a=$wnd.Math.max(1,d.g.a-c);}}} + function NNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;h=$C(kE,Pwe,28,b.b.c.length,15,1);j=$C(hR,jwe,273,b.b.c.length,0,1);i=$C(jR,WAe,10,b.b.c.length,0,1);for(l=a.a,m=0,n=l.length;m0&&!!i[d]&&(o=bFc(a.b,i[d],e));p=$wnd.Math.max(p,e.c.c.b+o);}for(f=new Anb(k.e);f.a1){throw Adb(new agb(gLe))}if(!i){f=oke(b,d.Kc().Pb());g.Fc(f);}}return XGd(a,gge(a,b,c),g)} + function Fge(a,b,c){var d,e,f,g,h,i,j,k;if(qke(a.e,b)){i=(nke(),RD(b,69).xk()?new ole(b,a):new Eke(b,a));bge(i.c,i.b);Ake(i,RD(c,16));}else {k=pke(a.e.Dh(),b);d=RD(a.g,124);for(g=0;g';}i!=null&&(b.a+=''+i,b);}else if(a.e){h=a.e.zb;h!=null&&(b.a+=''+h,b);}else {b.a+='?';if(a.b){b.a+=' super ';r2d(a.b,b);}else {if(a.f){b.a+=' extends ';r2d(a.f,b);}}}} + function Uae(a){a.b=null;a.a=null;a.o=null;a.q=null;a.v=null;a.w=null;a.B=null;a.p=null;a.Q=null;a.R=null;a.S=null;a.T=null;a.U=null;a.V=null;a.W=null;a.bb=null;a.eb=null;a.ab=null;a.H=null;a.db=null;a.c=null;a.d=null;a.f=null;a.n=null;a.r=null;a.s=null;a.u=null;a.G=null;a.J=null;a.e=null;a.j=null;a.i=null;a.g=null;a.k=null;a.t=null;a.F=null;a.I=null;a.L=null;a.M=null;a.O=null;a.P=null;a.$=null;a.N=null;a.Z=null;a.cb=null;a.K=null;a.D=null;a.A=null;a.C=null;a._=null;a.fb=null;a.X=null;a.Y=null;a.gb=false;a.hb=false;} + function yib(a){var b,c,d,e;d=Ajb((!a.c&&(a.c=ojb(Hdb(a.f))),a.c),0);if(a.e==0||a.a==0&&a.f!=-1&&a.e<0){return d}b=xib(a)<0?1:0;c=a.e;e=(d.length+1+$wnd.Math.abs(eE(a.e)),new cib);b==1&&(e.a+='-',e);if(a.e>0){c-=d.length-b;if(c>=0){e.a+='0.';for(;c>mib.length;c-=mib.length){$hb(e,mib);}_hb(e,mib,eE(c));Zhb(e,(BFb(b,d.length+1),d.substr(b)));}else {c=b-c;Zhb(e,zhb(d,b,eE(c)));e.a+='.';Zhb(e,yhb(d,eE(c)));}}else {Zhb(e,(BFb(b,d.length+1),d.substr(b)));for(;c<-mib.length;c+=mib.length){$hb(e,mib);}_hb(e,mib,eE(-c));}return e.a} + function BOc(a){var b,c,d,e,f,g,h,i,j;if(a.k!=(r3b(),p3b)){return false}if(a.j.c.length<=1){return false}f=RD(mQb(a,(yCc(),BBc)),101);if(f==(Bod(),wod)){return false}e=(wDc(),(!a.q?(yob(),yob(),wob):a.q)._b(iBc)?(d=RD(mQb(a,iBc),203)):(d=RD(mQb(Y2b(a),jBc),203)),d);if(e==uDc){return false}if(!(e==tDc||e==sDc)){g=Kfb(UD(hFc(a,fCc)));b=RD(mQb(a,eCc),140);!b&&(b=new R2b(g,g,g,g));j=b3b(a,(qpd(),ppd));i=b.d+b.a+(j.gc()-1)*g;if(i>a.o.b){return false}c=b3b(a,Xod);h=b.d+b.a+(c.gc()-1)*g;if(h>a.o.b){return false}}return true} + function VRc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;b.Ug('Orthogonal edge routing',1);j=Kfb(UD(mQb(a,(yCc(),cCc))));c=Kfb(UD(mQb(a,UBc)));d=Kfb(UD(mQb(a,XBc)));m=new TTc(0,c);q=0;g=new Jkb(a.b,0);h=null;k=null;i=null;l=null;do{k=g.b0){n=(o-1)*c;!!h&&(n+=d);!!k&&(n+=d);nb||Heb(TD(Gxd(i,(X7c(),D7c))))){e=0;f+=k.b+c;ZEb(l.c,k);k=new Had(f,c);d=new V9c(0,k.f,k,c);Cad(k,d);e=0;}if(d.b.c.length==0||!Heb(TD(Gxd(vCd(i),(X7c(),L7c))))&&(i.f>=d.o&&i.f<=d.f||d.a*0.5<=i.f&&d.a*1.5>=i.f)){K9c(d,i);}else {g=new V9c(d.s+d.r+c,k.f,k,c);Cad(k,g);K9c(g,i);}e=i.i+i.g;}ZEb(l.c,k);return l} + function ste(a){var b,c,d,e;if(a.b==null||a.b.length<=2)return;if(a.a)return;b=0;e=0;while(e=a.b[e+1]){e+=2;}else if(c0){d=new dnb(RD(Qc(a.a,f),21));yob();_mb(d,new M0b(b));e=new Jkb(f.b,0);while(e.b0&&d>=-6){if(d>=0){aib(f,c-eE(a.e),String.fromCharCode(46));}else {peb(f,b-1,b-1,'0.');aib(f,b+1,Ihb(mib,0,-eE(d)-1));}}else {if(c-b>=1){aib(f,b,String.fromCharCode(46));++c;}aib(f,c,String.fromCharCode(69));d>0&&aib(f,++c,String.fromCharCode(43));aib(f,++c,''+Zdb(Hdb(d)));}a.g=f.a;return a.g} + function KNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;d=Kfb(UD(mQb(b,(yCc(),hBc))));v=RD(mQb(b,gCc),17).a;m=4;e=3;w=20/v;n=false;i=0;g=lve;do{f=i!=1;l=i!=0;A=0;for(q=a.a,s=0,u=q.length;sv)){i=2;g=lve;}else if(i==0){i=1;g=A;}else {i=0;g=A;}}else {n=A>=g||g-A0?1:cz(isNaN(d),isNaN(0)))>=0^(bz(vEe),($wnd.Math.abs(h)<=vEe||h==0||isNaN(h)&&isNaN(0)?0:h<0?-1:h>0?1:cz(isNaN(h),isNaN(0)))>=0)){return $wnd.Math.max(h,d)}bz(vEe);if(($wnd.Math.abs(d)<=vEe||d==0||isNaN(d)&&isNaN(0)?0:d<0?-1:d>0?1:cz(isNaN(d),isNaN(0)))>0){return $wnd.Math.sqrt(h*h+d*d)}return -$wnd.Math.sqrt(h*h+d*d)} + function hue(a,b){var c,d,e,f,g,h;if(!b)return;!a.a&&(a.a=new gyb);if(a.e==2){dyb(a.a,b);return}if(b.e==1){for(e=0;e=txe?Nhb(c,qse(d)):Jhb(c,d&Bwe);g=(new eue(10,null,0));fyb(a.a,g,h-1);}else {c=(g.Mm().length+f,new Rhb);Nhb(c,g.Mm());}if(b.e==0){d=b.Km();d>=txe?Nhb(c,qse(d)):Jhb(c,d&Bwe);}else {Nhb(c,b.Mm());}RD(g,530).b=c.a;} + function Qsc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(c.dc()){return}h=0;m=0;d=c.Kc();o=RD(d.Pb(),17).a;while(h1&&(i=j.Hg(i,a.a,h));}if(i.c.length==1){return RD(Vmb(i,i.c.length-1),238)}if(i.c.length==2){return e8c((tFb(0,i.c.length),RD(i.c[0],238)),(tFb(1,i.c.length),RD(i.c[1],238)),g,f)}return null} + function CZc(a,b,c){var d,e,f,g,h,i,j;c.Ug('Find roots',1);a.a.c.length=0;for(e=Sub(b.b,0);e.b!=e.d.c;){d=RD(evb(e),40);if(d.b.b==0){pQb(d,(q$c(),n$c),(Geb(),true));Rmb(a.a,d);}}switch(a.a.c.length){case 0:f=new bXc(0,b,'DUMMY_ROOT');pQb(f,(q$c(),n$c),(Geb(),true));pQb(f,WZc,true);Mub(b.b,f);break;case 1:break;default:g=new bXc(0,b,IEe);for(i=new Anb(a.a);i.a=$wnd.Math.abs(d.b)){d.b=0;f.d+f.a>g.d&&f.dg.c&&f.c0){b=new zNd(a.i,a.g);c=a.i;f=c<100?null:new gLd(c);if(a.Tj()){for(d=0;d0){h=a.g;j=a.i;OHd(a);f=j<100?null:new gLd(j);for(d=0;d>13|(a.m&15)<<9;e=a.m>>4&8191;f=a.m>>17|(a.h&255)<<5;g=(a.h&1048320)>>8;h=b.l&8191;i=b.l>>13|(b.m&15)<<9;j=b.m>>4&8191;k=b.m>>17|(b.h&255)<<5;l=(b.h&1048320)>>8;B=c*h;C=d*h;D=e*h;F=f*h;G=g*h;if(i!=0){C+=c*i;D+=d*i;F+=e*i;G+=f*i;}if(j!=0){D+=c*j;F+=d*j;G+=e*j;}if(k!=0){F+=c*k;G+=d*k;}l!=0&&(G+=c*l);n=B&dxe;o=(C&511)<<13;m=n+o;q=B>>22;r=C>>9;s=(D&262143)<<4;t=(F&31)<<17;p=q+r+s+t;v=D>>18;w=F>>5;A=(G&4095)<<8;u=v+w+A;p+=m>>22;m&=dxe;u+=p>>22;p&=dxe;u&=exe;return hD(m,p,u)} + function Fac(a){var b,c,d,e,f,g,h;h=RD(Vmb(a.j,0),12);if(h.g.c.length!=0&&h.e.c.length!=0){throw Adb(new dgb('Interactive layout does not support NORTH/SOUTH ports with incoming _and_ outgoing edges.'))}if(h.g.c.length!=0){f=oxe;for(c=new Anb(h.g);c.a4){if(a.fk(b)){if(a.al()){e=RD(b,54);d=e.Eh();i=d==a.e&&(a.ml()?e.yh(e.Fh(),a.il())==a.jl():-1-e.Fh()==a.Lj());if(a.nl()&&!i&&!d&&!!e.Jh()){for(f=0;f0&&aGc(a,h,l);}for(e=new Anb(l);e.aa.d[g.p]){c+=ZLc(a.b,f)*RD(i.b,17).a;hmb(a.a,sgb(f));}}while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function x9b(a,b){var c,d,e,f,g,h,i,j,k,l;k=RD(mQb(a,(Ywc(),hwc)),64);d=RD(Vmb(a.j,0),12);k==(qpd(),Yod)?Q3b(d,npd):k==npd&&Q3b(d,Yod);if(RD(mQb(b,(yCc(),lBc)),181).Hc((Qpd(),Ppd))){i=Kfb(UD(mQb(a,_Bc)));j=Kfb(UD(mQb(a,aCc)));g=Kfb(UD(mQb(a,ZBc)));h=RD(mQb(b,EBc),21);if(h.Hc((Pod(),Lod))){c=j;l=a.o.a/2-d.n.a;for(f=new Anb(d.f);f.a0&&(j=a.n.a/f);break;case 2:case 4:e=a.i.o.b;e>0&&(j=a.n.b/e);}pQb(a,(Ywc(),Jwc),j);}i=a.o;g=a.a;if(d){g.a=d.a;g.b=d.b;a.d=true;}else if(b!=zod&&b!=Aod&&h!=opd){switch(h.g){case 1:g.a=i.a/2;break;case 2:g.a=i.a;g.b=i.b/2;break;case 3:g.a=i.a/2;g.b=i.b;break;case 4:g.b=i.b/2;}}else {g.a=i.a/2;g.b=i.b/2;}} + function VJd(a){var b,c,d,e,f,g,h,i,j,k;if(a.Pj()){k=a.Ej();i=a.Qj();if(k>0){b=new $Hd(a.pj());c=k;f=c<100?null:new gLd(c);aJd(a,c,b.g);e=c==1?a.Ij(4,QHd(b,0),null,0,i):a.Ij(6,b,null,-1,i);if(a.Mj()){for(d=new dMd(b);d.e!=d.i.gc();){f=a.Oj(bMd(d),f);}if(!f){a.Jj(e);}else {f.nj(e);f.oj();}}else {if(!f){a.Jj(e);}else {f.nj(e);f.oj();}}}else {aJd(a,a.Ej(),a.Fj());a.Jj(a.Ij(6,(yob(),vob),null,-1,i));}}else if(a.Mj()){k=a.Ej();if(k>0){h=a.Fj();j=k;aJd(a,k,h);f=j<100?null:new gLd(j);for(d=0;d1&&urd(g)*trd(g)/2>h[0]){f=0;while(fh[f]){++f;}o=new Rkb(p,0,f+1);l=new zrd(o);k=urd(g)/trd(g);i=ird(l,b,new z3b,c,d,e,k);$id(hjd(l.e),i);zFb(lwb(m,l),Bxe);n=new Rkb(p,f+1,p.c.length);iwb(m,n);p.c.length=0;j=0;Pnb(h,h.length,0);}else {q=m.b.c.length==0?null:Vmb(m.b,0);q!=null&&owb(m,0);j>0&&(h[j]=h[j-1]);h[j]+=urd(g)*trd(g);++j;ZEb(p.c,g);}}return p} + function _nc(a,b){var c,d,e,f;c=b.b;f=new dnb(c.j);e=0;d=c.j;d.c.length=0;Nnc(RD($i(a.b,(qpd(),Yod),(joc(),ioc)),15),c);e=Onc(f,e,new Hoc,d);Nnc(RD($i(a.b,Yod,hoc),15),c);e=Onc(f,e,new Joc,d);Nnc(RD($i(a.b,Yod,goc),15),c);Nnc(RD($i(a.b,Xod,ioc),15),c);Nnc(RD($i(a.b,Xod,hoc),15),c);e=Onc(f,e,new Loc,d);Nnc(RD($i(a.b,Xod,goc),15),c);Nnc(RD($i(a.b,npd,ioc),15),c);e=Onc(f,e,new Noc,d);Nnc(RD($i(a.b,npd,hoc),15),c);e=Onc(f,e,new Poc,d);Nnc(RD($i(a.b,npd,goc),15),c);Nnc(RD($i(a.b,ppd,ioc),15),c);e=Onc(f,e,new toc,d);Nnc(RD($i(a.b,ppd,hoc),15),c);Nnc(RD($i(a.b,ppd,goc),15),c);} + function jJc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;for(h=new Anb(b);h.a0.5?(r-=g*2*(o-0.5)):o<0.5&&(r+=f*2*(0.5-o));e=h.d.b;rq.a-p-k&&(r=q.a-p-k);h.n.a=b+r;}} + function jec(a){var b,c,d,e,f;d=RD(mQb(a,(yCc(),UAc)),171);if(d==(cxc(),$wc)){for(c=new is(Mr(Z2b(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),18);if(!lec(b)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to FIRST_SEPARATE, but has at least one incoming edge. "+'FIRST_SEPARATE nodes must not have incoming edges.'))}}}else if(d==axc){for(f=new is(Mr(a3b(a).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(!lec(e)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to LAST_SEPARATE, but has at least one outgoing edge. "+'LAST_SEPARATE nodes must not have outgoing edges.'))}}}} + function Qed(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;if(a.e&&a.c.c>19!=0){b=xD(b);i=!i;}g=pD(b);f=false;e=false;d=false;if(a.h==fxe&&a.m==0&&a.l==0){e=true;f=true;if(g==-1){a=gD((MD(),ID));d=true;i=!i;}else {h=BD(a,g);i&&nD(h);c&&(eD=hD(0,0,0));return h}}else if(a.h>>19!=0){f=true;a=xD(a);d=true;i=!i;}if(g!=-1){return kD(a,g,i,f,c)}if(uD(a,b)<0){c&&(f?(eD=xD(a)):(eD=hD(a.l,a.m,a.h)));return hD(0,0,0)}return lD(d?a:hD(a.l,a.m,a.h),b,i,f,e,c)} + function Bjb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;g=a.e;i=b.e;if(g==0){return b}if(i==0){return a}f=a.d;h=b.d;if(f+h==2){c=Cdb(a.a[0],yxe);d=Cdb(b.a[0],yxe);if(g==i){k=Bdb(c,d);o=Ydb(k);n=Ydb(Udb(k,32));return n==0?new ajb(g,o):new cjb(g,2,cD(WC(kE,1),Pwe,28,15,[o,n]))}return Pib(),Jdb(g<0?Vdb(d,c):Vdb(c,d),0)?jjb(g<0?Vdb(d,c):Vdb(c,d)):Xib(jjb(Odb(g<0?Vdb(d,c):Vdb(c,d))))}else if(g==i){m=g;l=f>=h?Cjb(a.a,f,b.a,h):Cjb(b.a,h,a.a,f);}else {e=f!=h?f>h?1:-1:Ejb(a.a,b.a,f);if(e==0){return Pib(),Oib}if(e==1){m=g;l=Hjb(a.a,f,b.a,h);}else {m=i;l=Hjb(b.a,h,a.a,f);}}j=new cjb(m,l.length,l);Rib(j);return j} + function KUc(a,b){var c,d,e,f,g,h,i;if(a.g>b.f||b.g>a.f){return}c=0;d=0;for(g=a.w.a.ec().Kc();g.Ob();){e=RD(g.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,b.g,b.f)&&++c;}for(h=a.r.a.ec().Kc();h.Ob();){e=RD(h.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,b.g,b.f)&&--c;}for(i=b.w.a.ec().Kc();i.Ob();){e=RD(i.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,a.g,a.f)&&++d;}for(f=b.r.a.ec().Kc();f.Ob();){e=RD(f.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,a.g,a.f)&&--d;}if(c=0){return c}switch(yfe(Qee(a,c))){case 2:{if(lhb('',Oee(a,c.qk()).xe())){i=Bfe(Qee(a,c));h=Afe(Qee(a,c));k=Ree(a,b,i,h);if(k){return k}e=Fee(a,b);for(g=0,l=e.gc();g1){throw Adb(new agb(gLe))}k=pke(a.e.Dh(),b);d=RD(a.g,124);for(g=0;g1;for(j=new l4b(m.b);xnb(j.a)||xnb(j.b);){i=RD(xnb(j.a)?ynb(j.a):ynb(j.b),18);l=i.c==m?i.d:i.c;$wnd.Math.abs(xjd(cD(WC(l3,1),Nve,8,0,[l.i.n,l.n,l.a])).b-g.b)>1&&eSc(a,i,g,f,m);}}} + function vUc(a){var b,c,d,e,f,g;e=new Jkb(a.e,0);d=new Jkb(a.a,0);if(a.d){for(c=0;cAEe){f=b;g=0;while($wnd.Math.abs(b-f)0);e.a.Xb(e.c=--e.b);uUc(a,a.b-g,f,d,e);sFb(e.b0);d.a.Xb(d.c=--d.b);}if(!a.d){for(c=0;c0){a.f[k.p]=n/(k.e.c.length+k.g.c.length);a.c=$wnd.Math.min(a.c,a.f[k.p]);a.b=$wnd.Math.max(a.b,a.f[k.p]);}else h&&(a.f[k.p]=n);}} + function xne(a){a.b=null;a.bb=null;a.fb=null;a.qb=null;a.a=null;a.c=null;a.d=null;a.e=null;a.f=null;a.n=null;a.M=null;a.L=null;a.Q=null;a.R=null;a.K=null;a.db=null;a.eb=null;a.g=null;a.i=null;a.j=null;a.k=null;a.gb=null;a.o=null;a.p=null;a.q=null;a.r=null;a.$=null;a.ib=null;a.S=null;a.T=null;a.t=null;a.s=null;a.u=null;a.v=null;a.w=null;a.B=null;a.A=null;a.C=null;a.D=null;a.F=null;a.G=null;a.H=null;a.I=null;a.J=null;a.P=null;a.Z=null;a.U=null;a.V=null;a.W=null;a.X=null;a.Y=null;a._=null;a.ab=null;a.cb=null;a.hb=null;a.nb=null;a.lb=null;a.mb=null;a.ob=null;a.pb=null;a.jb=null;a.kb=null;a.N=false;a.O=false;} + function C8b(a,b,c){var d,e,f,g;c.Ug('Graph transformation ('+a.a+')',1);g=bv(b.a);for(f=new Anb(b.b);f.a=h.b.c)&&(h.b=b);if(!h.c||b.c<=h.c.c){h.d=h.c;h.c=b;}(!h.e||b.d>=h.e.d)&&(h.e=b);(!h.f||b.d<=h.f.d)&&(h.f=b);}d=new PZb((nZb(),jZb));t$b(a,AZb,new mob(cD(WC(wQ,1),rve,382,0,[d])));g=new PZb(mZb);t$b(a,zZb,new mob(cD(WC(wQ,1),rve,382,0,[g])));e=new PZb(kZb);t$b(a,yZb,new mob(cD(WC(wQ,1),rve,382,0,[e])));f=new PZb(lZb);t$b(a,xZb,new mob(cD(WC(wQ,1),rve,382,0,[f])));FZb(d.c,jZb);FZb(e.c,kZb);FZb(f.c,lZb);FZb(g.c,mZb);h.a.c.length=0;Tmb(h.a,d.c);Tmb(h.a,hv(e.c));Tmb(h.a,f.c);Tmb(h.a,hv(g.c));return h} + function n9c(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;b.Ug(bGe,1);n=Kfb(UD(Gxd(a,(X6c(),W6c))));g=Kfb(UD(Gxd(a,(X7c(),Q7c))));h=RD(Gxd(a,N7c),107);Bad((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));k=U8c((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a),n,g);!a.a&&(a.a=new C5d(J4,a,10,11));for(j=new Anb(k);j.a0){a.a=i+(n-1)*f;b.c.b+=a.a;b.f.b+=a.a;}}if(o.a.gc()!=0){m=new TTc(1,f);n=STc(m,b,o,p,b.f.b+i-b.c.b);n>0&&(b.f.b+=i+(n-1)*f);}} + function osc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;k=Kfb(UD(mQb(a,(yCc(),WBc))));d=Kfb(UD(mQb(a,nCc)));m=new dtd;pQb(m,WBc,k+d);j=b;r=j.d;p=j.c.i;s=j.d.i;q=Q4b(p.c);t=Q4b(s.c);e=new bnb;for(l=q;l<=t;l++){h=new j3b(a);h3b(h,(r3b(),o3b));pQb(h,(Ywc(),Awc),j);pQb(h,BBc,(Bod(),wod));pQb(h,YBc,m);n=RD(Vmb(a.b,l),30);l==q?f3b(h,n.a.c.length-c,n):g3b(h,n);u=Kfb(UD(mQb(j,FAc)));if(u<0){u=0;pQb(j,FAc,u);}h.o.b=u;o=$wnd.Math.floor(u/2);g=new R3b;Q3b(g,(qpd(),ppd));P3b(g,h);g.n.b=o;i=new R3b;Q3b(i,Xod);P3b(i,h);i.n.b=o;Z0b(j,g);f=new a1b;kQb(f,j);pQb(f,RAc,null);Y0b(f,i);Z0b(f,r);psc(h,j,f);ZEb(e.c,f);j=f;}return e} + function Hec(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;i=RD(e3b(a,(qpd(),ppd)).Kc().Pb(),12).e;n=RD(e3b(a,Xod).Kc().Pb(),12).g;h=i.c.length;t=K3b(RD(Vmb(a.j,0),12));while(h-->0){p=(tFb(0,i.c.length),RD(i.c[0],18));e=(tFb(0,n.c.length),RD(n.c[0],18));s=e.d.e;f=Wmb(s,e,0);$0b(p,e.d,f);Y0b(e,null);Z0b(e,null);o=p.a;b&&Mub(o,new sjd(t));for(d=Sub(e.a,0);d.b!=d.d.c;){c=RD(evb(d),8);Mub(o,new sjd(c));}r=p.b;for(m=new Anb(e.b);m.ag)&&Ysb(a.b,RD(q.b,18));}}++h;}f=g;}}}} + function zhd(b,c){var d;if(c==null||lhb(c,vve)){return null}if(c.length==0&&b.k!=(kid(),fid)){return null}switch(b.k.g){case 1:return mhb(c,FGe)?(Geb(),Feb):mhb(c,GGe)?(Geb(),Eeb):null;case 2:try{return sgb(Oeb(c,qwe,lve))}catch(a){a=zdb(a);if(ZD(a,130)){return null}else throw Adb(a)}case 4:try{return Neb(c)}catch(a){a=zdb(a);if(ZD(a,130)){return null}else throw Adb(a)}case 3:return c;case 5:uhd(b);return xhd(b,c);case 6:uhd(b);return yhd(b,b.a,c);case 7:try{d=whd(b);d.cg(c);return d}catch(a){a=zdb(a);if(ZD(a,33)){return null}else throw Adb(a)}default:throw Adb(new dgb('Invalid type set for this layout option.'));}} + function JKd(a){var b;switch(a.d){case 1:{if(a.Sj()){return a.o!=-2}break}case 2:{if(a.Sj()){return a.o==-2}break}case 3:case 5:case 4:case 6:case 7:{return a.o>-2}default:{return false}}b=a.Rj();switch(a.p){case 0:return b!=null&&Heb(TD(b))!=Pdb(a.k,0);case 1:return b!=null&&RD(b,222).a!=Ydb(a.k)<<24>>24;case 2:return b!=null&&RD(b,180).a!=(Ydb(a.k)&Bwe);case 6:return b!=null&&Pdb(RD(b,168).a,a.k);case 5:return b!=null&&RD(b,17).a!=Ydb(a.k);case 7:return b!=null&&RD(b,191).a!=Ydb(a.k)<<16>>16;case 3:return b!=null&&Kfb(UD(b))!=a.j;case 4:return b!=null&&RD(b,161).a!=a.j;default:return b==null?a.n!=null:!pb(b,a.n);}} + function N_d(a,b,c){var d,e,f,g;if(a.ol()&&a.nl()){g=O_d(a,RD(c,58));if(dE(g)!==dE(c)){a.xj(b);a.Dj(b,P_d(a,b,g));if(a.al()){f=(e=RD(c,54),a.ml()?a.kl()?e.Th(a.b,Z5d(RD(vYd(Uwd(a.b),a.Lj()),19)).n,RD(vYd(Uwd(a.b),a.Lj()).Hk(),29).kk(),null):e.Th(a.b,BYd(e.Dh(),Z5d(RD(vYd(Uwd(a.b),a.Lj()),19))),null,null):e.Th(a.b,-1-a.Lj(),null,null));!RD(g,54).Ph()&&(f=(d=RD(g,54),a.ml()?a.kl()?d.Rh(a.b,Z5d(RD(vYd(Uwd(a.b),a.Lj()),19)).n,RD(vYd(Uwd(a.b),a.Lj()).Hk(),29).kk(),f):d.Rh(a.b,BYd(d.Dh(),Z5d(RD(vYd(Uwd(a.b),a.Lj()),19))),null,f):d.Rh(a.b,-1-a.Lj(),null,f)));!!f&&f.oj();}Mvd(a.b)&&a.Jj(a.Ij(9,c,g,b,false));return g}}return c} + function iJb(a){var b,c,d,e,f,g,h,i,j,k;d=new bnb;for(g=new Anb(a.e.a);g.a0&&(g=$wnd.Math.max(g,zMb(a.C.b+d.d.b,e)));}else {n=m+k.d.c+a.w+d.d.b;g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(l-e)<=Tye||l==e||isNaN(l)&&isNaN(e)?0:n/(e-l)));}k=d;l=e;m=f;}if(!!a.C&&a.C.c>0){n=m+a.C.c;j&&(n+=k.d.c);g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(l-1)<=Tye||l==1||isNaN(l)&&isNaN(1)?0:n/(1-l)));}c.n.b=0;c.a.a=g;} + function ENb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;c=RD(Vrb(a.b,b),127);i=RD(RD(Qc(a.r,b),21),87);if(i.dc()){c.n.d=0;c.n.a=0;return}j=a.u.Hc((Pod(),Lod));g=0;a.A.Hc((Qpd(),Ppd))&&JNb(a,b);h=i.Kc();k=null;m=0;l=0;while(h.Ob()){d=RD(h.Pb(),117);f=Kfb(UD(d.b.of((tNb(),sNb))));e=d.b.Mf().b;if(!k){!!a.C&&a.C.d>0&&(g=$wnd.Math.max(g,zMb(a.C.d+d.d.d,f)));}else {n=l+k.d.a+a.w+d.d.d;g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(m-f)<=Tye||m==f||isNaN(m)&&isNaN(f)?0:n/(f-m)));}k=d;m=f;l=e;}if(!!a.C&&a.C.a>0){n=l+a.C.a;j&&(n+=k.d.a);g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(m-1)<=Tye||m==1||isNaN(m)&&isNaN(1)?0:n/(1-m)));}c.n.d=0;c.a.b=g;} + function L8c(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r;o=false;j=dad(c.q,b.f+b.b-c.q.f);n=d.f>b.b&&h;r=e-(c.q.e+j-g);l=(i=S9c(d,r,false),i.a);if(n&&l>d.f){return false}if(n){m=0;for(q=new Anb(b.d);q.a=(tFb(f,a.c.length),RD(a.c[f],186)).e;if(!n&&l>b.b&&!k){return false}if(k||n||l<=b.b){if(k&&l>b.b){c.d=l;Q9c(c,P9c(c,l));}else {ead(c.q,j);c.c=true;}Q9c(d,e-(c.s+c.r));U9c(d,c.q.e+c.q.d,b.f);Cad(b,d);if(a.c.length>f){Fad((tFb(f,a.c.length),RD(a.c[f],186)),d);(tFb(f,a.c.length),RD(a.c[f],186)).a.c.length==0&&Xmb(a,f);}o=true;}return o} + function zJc(a,b,c){var d,e,f,g,h,i;this.g=a;h=b.d.length;i=c.d.length;this.d=$C(jR,WAe,10,h+i,0,1);for(g=0;g0?xJc(this,this.f/this.a):pJc(b.g,b.d[0]).a!=null&&pJc(c.g,c.d[0]).a!=null?xJc(this,(Kfb(pJc(b.g,b.d[0]).a)+Kfb(pJc(c.g,c.d[0]).a))/2):pJc(b.g,b.d[0]).a!=null?xJc(this,pJc(b.g,b.d[0]).a):pJc(c.g,c.d[0]).a!=null&&xJc(this,pJc(c.g,c.d[0]).a);} + function DXb(a,b){var c,d,e,f,g,h,i,j,k,l;a.a=new fYb(wsb(s3));for(d=new Anb(b.a);d.a=1){if(q-g>0&&l>=0){i.n.a+=p;i.n.b+=f*g;}else if(q-g<0&&k>=0){i.n.a+=p*q;i.n.b+=f;}}}a.o.a=b.a;a.o.b=b.b;pQb(a,(yCc(),lBc),(Qpd(),d=RD(mfb(H3),9),new Fsb(d,RD(WEb(d,d.length),9),0)));} + function ISd(a,b,c,d,e,f){var g;if(!(b==null||!mSd(b,ZRd,$Rd))){throw Adb(new agb('invalid scheme: '+b))}if(!a&&!(c!=null&&qhb(c,Fhb(35))==-1&&c.length>0&&(BFb(0,c.length),c.charCodeAt(0)!=47))){throw Adb(new agb('invalid opaquePart: '+c))}if(a&&!(b!=null&&tpb(eSd,b.toLowerCase()))&&!(c==null||!mSd(c,aSd,bSd))){throw Adb(new agb(NJe+c))}if(a&&b!=null&&tpb(eSd,b.toLowerCase())&&!ESd(c)){throw Adb(new agb(NJe+c))}if(!FSd(d)){throw Adb(new agb('invalid device: '+d))}if(!HSd(e)){g=e==null?'invalid segments: null':'invalid segment: '+tSd(e);throw Adb(new agb(g))}if(!(f==null||qhb(f,Fhb(35))==-1)){throw Adb(new agb('invalid query: '+f))}} + function WHc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;c.Ug('Network simplex layering',1);a.b=b;r=RD(mQb(b,(yCc(),gCc)),17).a*4;q=a.b.a;if(q.c.length<1){c.Vg();return}f=SHc(a,q);p=null;for(e=Sub(f,0);e.b!=e.d.c;){d=RD(evb(e),15);h=r*eE($wnd.Math.sqrt(d.gc()));g=VHc(d);lJb(yJb(AJb(zJb(CJb(g),h),p),true),c.eh(1));m=a.b.b;for(o=new Anb(g.a);o.a1){p=$C(kE,Pwe,28,a.b.b.c.length,15,1);l=0;for(j=new Anb(a.b.b);j.a0){wA(a,c,0);c.a+=String.fromCharCode(d);e=BA(b,f);wA(a,c,e);f+=e-1;continue}if(d==39){if(f+10&&o.a<=0){i.c.length=0;ZEb(i.c,o);break}n=o.i-o.d;if(n>=h){if(n>h){i.c.length=0;h=n;}ZEb(i.c,o);}}if(i.c.length!=0){g=RD(Vmb(i,Jwb(e,i.c.length)),118);t.a.Bc(g)!=null;g.g=k++;wSc(g,b,c,d);i.c.length=0;}}q=a.c.length+1;for(m=new Anb(a);m.apxe||b.o==CQc&&k=h&&e<=i){if(h<=e&&f<=i){c[k++]=e;c[k++]=f;d+=2;}else if(h<=e){c[k++]=e;c[k++]=i;a.b[d]=i+1;g+=2;}else if(f<=i){c[k++]=h;c[k++]=f;d+=2;}else {c[k++]=h;c[k++]=i;a.b[d]=i+1;}}else if(ipwe)&&h<10);BYb(a.c,new bYb);QXb(a);xYb(a.c);AXb(a.f);} + function B9b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;c=RD(mQb(a,(yCc(),BBc)),101);g=a.f;f=a.d;h=g.a+f.b+f.c;i=0-f.d-a.c.b;k=g.b+f.d+f.a-a.c.b;j=new bnb;l=new bnb;for(e=new Anb(b);e.a=2){i=Sub(c,0);g=RD(evb(i),8);h=RD(evb(i),8);while(h.a0&&aHb(j,true,(Cmd(),zmd));h.k==(r3b(),m3b)&&bHb(j);Zjb(a.f,h,b);}}} + function OVc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;e=RD(mQb(a,(q$c(),h$c)),27);j=lve;k=lve;h=qwe;i=qwe;for(t=Sub(a.b,0);t.b!=t.d.c;){r=RD(evb(t),40);n=r.e;o=r.f;j=$wnd.Math.min(j,n.a-o.a/2);k=$wnd.Math.min(k,n.b-o.b/2);h=$wnd.Math.max(h,n.a+o.a/2);i=$wnd.Math.max(i,n.b+o.b/2);}m=RD(Gxd(e,(h_c(),T$c)),107);for(s=Sub(a.b,0);s.b!=s.d.c;){r=RD(evb(s),40);l=mQb(r,h$c);if(ZD(l,207)){f=RD(l,27);Byd(f,r.e.a,r.e.b);zxd(f,r);}}for(q=Sub(a.a,0);q.b!=q.d.c;){p=RD(evb(q),65);d=RD(mQb(p,h$c),74);if(d){b=p.a;c=IGd(d,true,true);lsd(b,c);}}u=h-j+(m.b+m.c);g=i-k+(m.d+m.a);Heb(TD(Gxd(e,(umd(),mld))))||Esd(e,u,g,false,false);Ixd(e,Ikd,u-(m.b+m.c));Ixd(e,Hkd,g-(m.d+m.a));} + function Wec(a,b){var c,d,e,f,g,h,i,j,k,l;i=true;e=0;j=a.g[b.p];k=b.o.b+a.o;c=a.d[b.p][2];$mb(a.b,j,sgb(RD(Vmb(a.b,j),17).a-1+c));$mb(a.c,j,Kfb(UD(Vmb(a.c,j)))-k+c*a.f);++j;if(j>=a.j){++a.j;Rmb(a.b,sgb(1));Rmb(a.c,k);}else {d=a.d[b.p][1];$mb(a.b,j,sgb(RD(Vmb(a.b,j),17).a+1-d));$mb(a.c,j,Kfb(UD(Vmb(a.c,j)))+k-d*a.f);}(a.r==(aEc(),VDc)&&(RD(Vmb(a.b,j),17).a>a.k||RD(Vmb(a.b,j-1),17).a>a.k)||a.r==YDc&&(Kfb(UD(Vmb(a.c,j)))>a.n||Kfb(UD(Vmb(a.c,j-1)))>a.n))&&(i=false);for(g=new is(Mr(Z2b(b).a.Kc(),new ir));gs(g);){f=RD(hs(g),18);h=f.c.i;if(a.g[h.p]==j){l=Wec(a,h);e=e+RD(l.a,17).a;i=i&&Heb(TD(l.b));}}a.g[b.p]=j;e=e+a.d[b.p][0];return new Ptd(sgb(e),(Geb(),i?true:false))} + function cXb(a,b){var c,d,e,f,g;c=Kfb(UD(mQb(b,(yCc(),TBc))));c<2&&pQb(b,TBc,2);d=RD(mQb(b,rAc),88);d==(Cmd(),Amd)&&pQb(b,rAc,i2b(b));e=RD(mQb(b,NBc),17);e.a==0?pQb(b,(Ywc(),Lwc),new Owb):pQb(b,(Ywc(),Lwc),new Pwb(e.a));f=TD(mQb(b,gBc));f==null&&pQb(b,gBc,(Geb(),dE(mQb(b,yAc))===dE((Ymd(),Umd))?true:false));FDb(new SDb(null,new Swb(b.a,16)),new fXb(a));FDb(EDb(new SDb(null,new Swb(b.b,16)),new hXb),new jXb(a));g=new gFc(b);pQb(b,(Ywc(),Qwc),g);Sed(a.a);Ved(a.a,(sXb(),nXb),RD(mQb(b,pAc),188));Ved(a.a,oXb,RD(mQb(b,$Ac),188));Ved(a.a,pXb,RD(mQb(b,oAc),188));Ved(a.a,qXb,RD(mQb(b,kBc),188));Ved(a.a,rXb,KRc(RD(mQb(b,yAc),223)));Ped(a.a,bXb(b));pQb(b,Kwc,Qed(a.a,b));} + function STc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r;l=new Tsb;g=new bnb;QTc(a,c,a.d.Ag(),g,l);QTc(a,d,a.d.Bg(),g,l);a.b=0.2*(p=RTc(EDb(new SDb(null,new Swb(g,16)),new XTc)),q=RTc(EDb(new SDb(null,new Swb(g,16)),new ZTc)),$wnd.Math.min(p,q));f=0;for(h=0;h=2&&(r=uSc(g,true,m),!a.e&&(a.e=new xTc(a)),tTc(a.e,r,g,a.b),undefined);UTc(g,m);WTc(g);n=-1;for(k=new Anb(g);k.ah} + function Iad(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;j=oxe;k=oxe;h=pxe;i=pxe;for(m=new Anb(b.i);m.a-1){for(e=Sub(h,0);e.b!=e.d.c;){d=RD(evb(e),131);d.v=g;}while(h.b!=0){d=RD(ku(h,0),131);for(c=new Anb(d.i);c.a-1){for(f=new Anb(h);f.a0){continue}RSc(i,$wnd.Math.min(i.o,e.o-1));QSc(i,i.i-1);i.i==0&&(ZEb(h.c,i),true);}}}} + function Lid(a,b,c,d,e){var f,g,h,i;i=oxe;g=false;h=Gid(a,ojd(new rjd(b.a,b.b),a),$id(new rjd(c.a,c.b),e),ojd(new rjd(d.a,d.b),c));f=!!h&&!($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe||$wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe);h=Gid(a,ojd(new rjd(b.a,b.b),a),c,e);!!h&&(($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe)==($wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe)||f?(i=$wnd.Math.min(i,ejd(ojd(h,c)))):(g=true));h=Gid(a,ojd(new rjd(b.a,b.b),a),d,e);!!h&&(g||($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe)==($wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe)||f)&&(i=$wnd.Math.min(i,ejd(ojd(h,d))));return i} + function eWb(a){Cgd(a,new Pfd(Wfd($fd(Xfd(Zfd(Yfd(new agd,AAe),BAe),"Minimizes the stress within a layout using stress majorization. Stress exists if the euclidean distance between a pair of nodes doesn't match their graph theoretic distance, that is, the shortest path between the two nodes. The method allows to specify individual edge lengths."),new hWb),Zze)));Agd(a,AAe,dAe,iGd(XVb));Agd(a,AAe,fAe,(Geb(),true));Agd(a,AAe,jAe,iGd($Vb));Agd(a,AAe,CAe,iGd(_Vb));Agd(a,AAe,iAe,iGd(aWb));Agd(a,AAe,kAe,iGd(ZVb));Agd(a,AAe,gAe,iGd(bWb));Agd(a,AAe,lAe,iGd(cWb));Agd(a,AAe,vAe,iGd(WVb));Agd(a,AAe,xAe,iGd(UVb));Agd(a,AAe,yAe,iGd(VVb));Agd(a,AAe,zAe,iGd(YVb));Agd(a,AAe,wAe,iGd(TVb));} + function kJc(a){var b,c,d,e,f,g,h,i;b=null;for(d=new Anb(a);d.a0&&c.c==0){!b&&(b=new bnb);ZEb(b.c,c);}}if(b){while(b.c.length!=0){c=RD(Xmb(b,0),239);if(!!c.b&&c.b.c.length>0){for(f=(!c.b&&(c.b=new bnb),new Anb(c.b));f.aWmb(a,c,0)){return new Ptd(e,c)}}else if(Kfb(pJc(e.g,e.d[0]).a)>Kfb(pJc(c.g,c.d[0]).a)){return new Ptd(e,c)}}}for(h=(!c.e&&(c.e=new bnb),c.e).Kc();h.Ob();){g=RD(h.Pb(),239);i=(!g.b&&(g.b=new bnb),g.b);wFb(0,i.c.length);XEb(i.c,0,c);g.c==i.c.length&&(ZEb(b.c,g),true);}}}return null} + function _Jc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;b.Ug('Interactive crossing minimization',1);g=0;for(f=new Anb(a.b);f.a0){c+=i.n.a+i.o.a/2;++l;}for(o=new Anb(i.j);o.a0&&(c/=l);r=$C(iE,vxe,28,d.a.c.length,15,1);h=0;for(j=new Anb(d.a);j.a=h&&e<=i){if(h<=e&&f<=i){d+=2;}else if(h<=e){a.b[d]=i+1;g+=2;}else if(f<=i){c[k++]=e;c[k++]=h-1;d+=2;}else {c[k++]=e;c[k++]=h-1;a.b[d]=i+1;g+=2;}}else if(i2){k=new bnb;Tmb(k,new Rkb(r,1,r.b));f=jTb(k,t+a.a);s=new ORb(f);kQb(s,b);ZEb(c.c,s);}else {d?(s=RD(Wjb(a.b,JGd(b)),272)):(s=RD(Wjb(a.b,LGd(b)),272));}i=JGd(b);d&&(i=LGd(b));g=qTb(q,i);j=t+a.a;if(g.a){j+=$wnd.Math.abs(q.b-l.b);p=new rjd(l.a,(l.b+q.b)/2);}else {j+=$wnd.Math.abs(q.a-l.a);p=new rjd((l.a+q.a)/2,l.b);}d?Zjb(a.d,b,new QRb(s,g,p,j)):Zjb(a.c,b,new QRb(s,g,p,j));Zjb(a.b,b,s);o=(!b.n&&(b.n=new C5d(I4,b,1,7)),b.n);for(n=new dMd(o);n.e!=n.i.gc();){m=RD(bMd(n),135);e=nTb(a,m,true,0,0);ZEb(c.c,e);}} + function sMb(a){var b,c,d,e,f,g,h;if(a.A.dc()){return}if(a.A.Hc((Qpd(),Opd))){RD(Vrb(a.b,(qpd(),Yod)),127).k=true;RD(Vrb(a.b,npd),127).k=true;b=a.q!=(Bod(),xod)&&a.q!=wod;QJb(RD(Vrb(a.b,Xod),127),b);QJb(RD(Vrb(a.b,ppd),127),b);QJb(a.g,b);if(a.A.Hc(Ppd)){RD(Vrb(a.b,Yod),127).j=true;RD(Vrb(a.b,npd),127).j=true;RD(Vrb(a.b,Xod),127).k=true;RD(Vrb(a.b,ppd),127).k=true;a.g.k=true;}}if(a.A.Hc(Npd)){a.a.j=true;a.a.k=true;a.g.j=true;a.g.k=true;h=a.B.Hc((dqd(),_pd));for(e=nMb(),f=0,g=e.length;f0),RD(k.a.Xb(k.c=--k.b),18));while(f!=d&&k.b>0){a.a[f.p]=true;a.a[d.p]=true;f=(sFb(k.b>0),RD(k.a.Xb(k.c=--k.b),18));}k.b>0&&Ckb(k);}}}}} + function Zyb(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;if(!a.b){return false}g=null;m=null;i=new Fzb(null,null);e=1;i.a[1]=a.b;l=i;while(l.a[e]){j=e;h=m;m=l;l=l.a[e];d=a.a.Ne(b,l.d);e=d<0?0:1;d==0&&(!c.c||Fvb(l.e,c.d))&&(g=l);if(!(!!l&&l.b)&&!Vyb(l.a[e])){if(Vyb(l.a[1-e])){m=m.a[j]=azb(l,e);}else if(!Vyb(l.a[1-e])){n=m.a[1-j];if(n){if(!Vyb(n.a[1-j])&&!Vyb(n.a[j])){m.b=false;n.b=true;l.b=true;}else {f=h.a[1]==m?1:0;Vyb(n.a[j])?(h.a[f]=_yb(m,j)):Vyb(n.a[1-j])&&(h.a[f]=azb(m,j));l.b=h.a[f].b=true;h.a[f].a[0].b=false;h.a[f].a[1].b=false;}}}}}if(g){c.b=true;c.d=g.e;if(l!=g){k=new Fzb(l.d,l.e);$yb(a,i,g,k);m==g&&(m=k);}m.a[m.a[1]==l?1:0]=l.a[!l.a[0]?1:0];--a.c;}a.b=i.a[1];!!a.b&&(a.b.b=false);return c.b} + function Ilc(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(e=new Anb(a.a.a.b);e.a0?(e-=86400000):(e+=86400000);i=new wB(Bdb(Hdb(b.q.getTime()),e));}k=new cib;j=a.a.length;for(f=0;f=97&&d<=122||d>=65&&d<=90){for(g=f+1;g=j){throw Adb(new agb("Missing trailing '"))}g+1=14&&k<=16))){if(b.a._b(d)){!c.a?(c.a=new dib(c.d)):Zhb(c.a,c.b);Whb(c.a,'[...]');}else {h=SD(d);j=new btb(b);Gyb(c,Inb(h,j));}}else ZD(d,183)?Gyb(c,hob(RD(d,183))):ZD(d,195)?Gyb(c,aob(RD(d,195))):ZD(d,201)?Gyb(c,bob(RD(d,201))):ZD(d,2111)?Gyb(c,gob(RD(d,2111))):ZD(d,53)?Gyb(c,eob(RD(d,53))):ZD(d,376)?Gyb(c,fob(RD(d,376))):ZD(d,846)?Gyb(c,dob(RD(d,846))):ZD(d,109)&&Gyb(c,cob(RD(d,109)));}else {Gyb(c,d==null?vve:jeb(d));}}return !c.a?c.c:c.e.length==0?c.a.a:c.a.a+(''+c.e)} + function KXd(a,b){var c,d,e,f;f=a.F;if(b==null){a.F=null;yXd(a,null);}else {a.F=(uFb(b),b);d=qhb(b,Fhb(60));if(d!=-1){e=(AFb(0,d,b.length),b.substr(0,d));qhb(b,Fhb(46))==-1&&!lhb(e,hve)&&!lhb(e,dKe)&&!lhb(e,eKe)&&!lhb(e,fKe)&&!lhb(e,gKe)&&!lhb(e,hKe)&&!lhb(e,iKe)&&!lhb(e,jKe)&&(e=kKe);c=thb(b,Fhb(62));c!=-1&&(e+=''+(BFb(c+1,b.length+1),b.substr(c+1)));yXd(a,e);}else {e=b;if(qhb(b,Fhb(46))==-1){d=qhb(b,Fhb(91));d!=-1&&(e=(AFb(0,d,b.length),b.substr(0,d)));if(!lhb(e,hve)&&!lhb(e,dKe)&&!lhb(e,eKe)&&!lhb(e,fKe)&&!lhb(e,gKe)&&!lhb(e,hKe)&&!lhb(e,iKe)&&!lhb(e,jKe)){e=kKe;d!=-1&&(e+=''+(BFb(d,b.length+1),b.substr(d)));}else {e=b;}}yXd(a,e);e==b&&(a.F=a.D);}}(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,5,f,b));} + function Pvd(b,c){var d,e,f,g,h,i,j,k,l,m;j=c.length-1;i=(BFb(j,c.length),c.charCodeAt(j));if(i==93){h=qhb(c,Fhb(91));if(h>=0){f=Uvd(b,(AFb(1,h,c.length),c.substr(1,h-1)));l=(AFb(h+1,j,c.length),c.substr(h+1,j-(h+1)));return Nvd(b,l,f)}}else {d=-1;_eb==null&&(_eb=new RegExp('\\d'));if(_eb.test(String.fromCharCode(i))){d=uhb(c,Fhb(46),j-1);if(d>=0){e=RD(Fvd(b,Zvd(b,(AFb(1,d,c.length),c.substr(1,d-1))),false),61);k=0;try{k=Oeb((BFb(d+1,c.length+1),c.substr(d+1)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){g=a;throw Adb(new RSd(g))}else throw Adb(a)}if(k>16==-10){c=RD(a.Cb,292).Yk(b,c);}else if(a.Db>>16==-15){!b&&(b=(JTd(),wTd));!j&&(j=(JTd(),wTd));if(a.Cb.Yh()){i=new P3d(a.Cb,1,13,j,b,fZd(o4d(RD(a.Cb,62)),a),false);!c?(c=i):c.nj(i);}}}else if(ZD(a.Cb,90)){if(a.Db>>16==-23){ZD(b,90)||(b=(JTd(),zTd));ZD(j,90)||(j=(JTd(),zTd));if(a.Cb.Yh()){i=new P3d(a.Cb,1,10,j,b,fZd(tYd(RD(a.Cb,29)),a),false);!c?(c=i):c.nj(i);}}}else if(ZD(a.Cb,457)){h=RD(a.Cb,850);g=(!h.b&&(h.b=new pae(new lae)),h.b);for(f=(d=new vkb((new mkb(g.a)).a),new xae(d));f.a.b;){e=RD(tkb(f.a).ld(),89);c=o2d(e,k2d(e,h),c);}}}return c} + function Y4b(a,b){var c,d,e,f,g,h,i,j,k,l,m;g=Heb(TD(Gxd(a,(yCc(),NAc))));m=RD(Gxd(a,EBc),21);i=false;j=false;l=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));while(l.e!=l.i.gc()&&(!i||!j)){f=RD(bMd(l),123);h=0;for(e=Fl(Al(cD(WC(cJ,1),rve,20,0,[(!f.d&&(f.d=new Yie(G4,f,8,5)),f.d),(!f.e&&(f.e=new Yie(G4,f,7,4)),f.e)])));gs(e);){d=RD(hs(e),74);k=g&&ozd(d)&&Heb(TD(Gxd(d,OAc)));c=cZd((!d.b&&(d.b=new Yie(E4,d,4,7)),d.b),f)?a==vCd(AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))):a==vCd(AGd(RD(QHd((!d.b&&(d.b=new Yie(E4,d,4,7)),d.b),0),84)));if(k||c){++h;if(h>1){break}}}h>0?(i=true):m.Hc((Pod(),Lod))&&(!f.n&&(f.n=new C5d(I4,f,1,7)),f.n).i>0&&(i=true);h>1&&(j=true);}i&&b.Fc((ovc(),hvc));j&&b.Fc((ovc(),ivc));} + function Dsd(a){var b,c,d,e,f,g,h,i,j,k,l,m;m=RD(Gxd(a,(umd(),kld)),21);if(m.dc()){return null}h=0;g=0;if(m.Hc((Qpd(),Opd))){k=RD(Gxd(a,Hld),101);d=2;c=2;e=2;f=2;b=!vCd(a)?RD(Gxd(a,Nkd),88):RD(Gxd(vCd(a),Nkd),88);for(j=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));j.e!=j.i.gc();){i=RD(bMd(j),123);l=RD(Gxd(i,Old),64);if(l==(qpd(),opd)){l=osd(i,b);Ixd(i,Old,l);}if(k==(Bod(),wod)){switch(l.g){case 1:d=$wnd.Math.max(d,i.i+i.g);break;case 2:c=$wnd.Math.max(c,i.j+i.f);break;case 3:e=$wnd.Math.max(e,i.i+i.g);break;case 4:f=$wnd.Math.max(f,i.j+i.f);}}else {switch(l.g){case 1:d+=i.g+2;break;case 2:c+=i.f+2;break;case 3:e+=i.g+2;break;case 4:f+=i.f+2;}}}h=$wnd.Math.max(d,e);g=$wnd.Math.max(c,f);}return Esd(a,h,g,true,true)} + function Rqc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;s=RD(zDb(PDb(CDb(new SDb(null,new Swb(b.d,16)),new Vqc(c)),new Xqc(c)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);l=lve;k=qwe;for(i=new Anb(b.b.j);i.a0;if(j){if(j){m=r.p;g?++m:--m;l=RD(Vmb(r.c.a,m),10);d=Z7b(l);n=!(Did(d,w,c[0])||yid(d,w,c[0]));}}else {n=true;}}o=false;v=b.D.i;if(!!v&&!!v.c&&h.e){k=g&&v.p>0||!g&&v.p=0){i=null;h=new Jkb(k.a,j+1);while(h.bg?1:cz(isNaN(0),isNaN(g)))<0&&(bz(vEe),($wnd.Math.abs(g-1)<=vEe||g==1||isNaN(g)&&isNaN(1)?0:g<1?-1:g>1?1:cz(isNaN(g),isNaN(1)))<0)&&(bz(vEe),($wnd.Math.abs(0-h)<=vEe||0==h||isNaN(0)&&isNaN(h)?0:0h?1:cz(isNaN(0),isNaN(h)))<0)&&(bz(vEe),($wnd.Math.abs(h-1)<=vEe||h==1||isNaN(h)&&isNaN(1)?0:h<1?-1:h>1?1:cz(isNaN(h),isNaN(1)))<0));return f} + function EXd(b){var c,d,e,f;d=b.D!=null?b.D:b.B;c=qhb(d,Fhb(91));if(c!=-1){e=(AFb(0,c,d.length),d.substr(0,c));f=new Qhb;do f.a+='[';while((c=phb(d,91,++c))!=-1);if(lhb(e,hve))f.a+='Z';else if(lhb(e,dKe))f.a+='B';else if(lhb(e,eKe))f.a+='C';else if(lhb(e,fKe))f.a+='D';else if(lhb(e,gKe))f.a+='F';else if(lhb(e,hKe))f.a+='I';else if(lhb(e,iKe))f.a+='J';else if(lhb(e,jKe))f.a+='S';else {f.a+='L';f.a+=''+e;f.a+=';';}try{return null}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}else if(qhb(d,Fhb(46))==-1){if(lhb(d,hve))return xdb;else if(lhb(d,dKe))return gE;else if(lhb(d,eKe))return hE;else if(lhb(d,fKe))return iE;else if(lhb(d,gKe))return jE;else if(lhb(d,hKe))return kE;else if(lhb(d,iKe))return lE;else if(lhb(d,jKe))return wdb}return null} + function pTb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;a.e=b;h=RSb(b);w=new bnb;for(d=new Anb(h);d.a=0&&p=j.c.c.length?(k=hOc((r3b(),p3b),o3b)):(k=hOc((r3b(),o3b),o3b));k*=2;f=c.a.g;c.a.g=$wnd.Math.max(f,f+(k-f));g=c.b.g;c.b.g=$wnd.Math.max(g,g+(k-g));e=b;}}} + function qkc(a){var b,c,d,e;FDb(CDb(new SDb(null,new Swb(a.a.b,16)),new Qkc),new Skc);okc(a);FDb(CDb(new SDb(null,new Swb(a.a.b,16)),new Ukc),new Wkc);if(a.c==(Ymd(),Wmd)){FDb(CDb(EDb(new SDb(null,new Swb(new Xkb(a.f),1)),new clc),new elc),new glc(a));FDb(CDb(GDb(EDb(EDb(new SDb(null,new Swb(a.d.b,16)),new klc),new mlc),new olc),new qlc),new slc(a));}e=new rjd(oxe,oxe);b=new rjd(pxe,pxe);for(d=new Anb(a.a.b);d.a0&&(b.a+=pve,b);Csd(RD(bMd(h),167),b);}b.a+=SAe;i=new mMd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c));while(i.e!=i.i.gc()){i.e>0&&(b.a+=pve,b);Csd(RD(bMd(i),167),b);}b.a+=')';}}} + function LTb(a,b,c){var d,e,f,g,h,i,j,k;for(i=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));i.e!=i.i.gc();){h=RD(bMd(i),27);for(e=new is(Mr(zGd(h).a.Kc(),new ir));gs(e);){d=RD(hs(e),74);!d.b&&(d.b=new Yie(E4,d,4,7));if(!(d.b.i<=1&&(!d.c&&(d.c=new Yie(E4,d,5,8)),d.c.i<=1))){throw Adb(new Ked('Graph must not contain hyperedges.'))}if(!nzd(d)&&h!=AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))){j=new cUb;kQb(j,d);pQb(j,(JVb(),HVb),d);_Tb(j,RD(Wd(qtb(c.f,h)),153));aUb(j,RD(Wjb(c,AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))),153));Rmb(b.c,j);for(g=new dMd((!d.n&&(d.n=new C5d(I4,d,1,7)),d.n));g.e!=g.i.gc();){f=RD(bMd(g),135);k=new iUb(j,f.a);kQb(k,f);pQb(k,HVb,f);k.e.a=$wnd.Math.max(f.g,1);k.e.b=$wnd.Math.max(f.f,1);hUb(k);Rmb(b.d,k);}}}}} + function Vec(a,b,c){var d,e,f,g,h,i,j,k,l,m;c.Ug('Node promotion heuristic',1);a.i=b;a.r=RD(mQb(b,(yCc(),ZAc)),243);a.r!=(aEc(),TDc)&&a.r!=UDc?Tec(a):Uec(a);k=RD(mQb(a.i,YAc),17).a;f=new nfc;switch(a.r.g){case 2:case 1:Yec(a,f);break;case 3:a.r=_Dc;Yec(a,f);i=0;for(h=new Anb(a.b);h.aa.k){a.r=VDc;Yec(a,f);}break;case 4:a.r=_Dc;Yec(a,f);j=0;for(e=new Anb(a.c);e.aa.n){a.r=YDc;Yec(a,f);}break;case 6:m=eE($wnd.Math.ceil(a.g.length*k/100));Yec(a,new qfc(m));break;case 5:l=eE($wnd.Math.ceil(a.e*k/100));Yec(a,new tfc(l));break;case 8:Sec(a,true);break;case 9:Sec(a,false);break;default:Yec(a,f);}a.r!=TDc&&a.r!=UDc?Zec(a,b):$ec(a,b);c.Vg();} + function $rc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;l=a.b;k=new Jkb(l,0);Ikb(k,new R4b(a));s=false;g=1;while(k.b0){m.d+=k.n.d;m.d+=k.d;}if(m.a>0){m.a+=k.n.a;m.a+=k.d;}if(m.b>0){m.b+=k.n.b;m.b+=k.d;}if(m.c>0){m.c+=k.n.c;m.c+=k.d;}return m} + function u9b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;m=c.d;l=c.c;f=new rjd(c.f.a+c.d.b+c.d.c,c.f.b+c.d.d+c.d.a);g=f.b;for(j=new Anb(a.a);j.a0){a.c[b.c.p][b.p].d+=Kwb(a.i,24)*Nxe*0.07000000029802322-0.03500000014901161;a.c[b.c.p][b.p].a=a.c[b.c.p][b.p].d/a.c[b.c.p][b.p].b;}} + function D8b(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(o=new Anb(a);o.ad.d;d.d=$wnd.Math.max(d.d,b);if(h&&c){d.d=$wnd.Math.max(d.d,d.a);d.a=d.d+e;}break;case 3:c=b>d.a;d.a=$wnd.Math.max(d.a,b);if(h&&c){d.a=$wnd.Math.max(d.a,d.d);d.d=d.a+e;}break;case 2:c=b>d.c;d.c=$wnd.Math.max(d.c,b);if(h&&c){d.c=$wnd.Math.max(d.b,d.c);d.b=d.c+e;}break;case 4:c=b>d.b;d.b=$wnd.Math.max(d.b,b);if(h&&c){d.b=$wnd.Math.max(d.b,d.c);d.c=d.b+e;}}}}} + function pA(a,b){var c,d,e,f,g,h,i,j,k;j='';if(b.length==0){return a.ne(ywe,wwe,-1,-1)}k=Dhb(b);lhb(k.substr(0,3),'at ')&&(k=(BFb(3,k.length+1),k.substr(3)));k=k.replace(/\[.*?\]/g,'');g=k.indexOf('(');if(g==-1){g=k.indexOf('@');if(g==-1){j=k;k='';}else {j=Dhb((BFb(g+1,k.length+1),k.substr(g+1)));k=Dhb((AFb(0,g,k.length),k.substr(0,g)));}}else {c=k.indexOf(')',g);j=(AFb(g+1,c,k.length),k.substr(g+1,c-(g+1)));k=Dhb((AFb(0,g,k.length),k.substr(0,g)));}g=qhb(k,Fhb(46));g!=-1&&(k=(BFb(g+1,k.length+1),k.substr(g+1)));(k.length==0||lhb(k,'Anonymous function'))&&(k=wwe);h=thb(j,Fhb(58));e=uhb(j,Fhb(58),h-1);i=-1;d=-1;f=ywe;if(h!=-1&&e!=-1){f=(AFb(0,e,j.length),j.substr(0,e));i=jA((AFb(e+1,h,j.length),j.substr(e+1,h-(e+1))));d=jA((BFb(h+1,j.length+1),j.substr(h+1)));}return a.ne(f,k,i,d)} + function C6b(a){var b,c,d,e,f,g,h,i,j,k,l;for(j=new Anb(a);j.a0||k.j==ppd&&k.e.c.length-k.g.c.length<0)){b=false;break}for(e=new Anb(k.g);e.a=j&&v>=q){m+=o.n.b+p.n.b+p.a.b-u;++h;}}}}if(c){for(g=new Anb(s.e);g.a=j&&v>=q){m+=o.n.b+p.n.b+p.a.b-u;++h;}}}}}if(h>0){w+=m/h;++n;}}if(n>0){b.a=e*w/n;b.g=n;}else {b.a=0;b.g=0;}} + function hTb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;f=a.f.b;m=f.a;k=f.b;o=a.e.g;n=a.e.f;zyd(a.e,f.a,f.b);w=m/o;A=k/n;for(j=new dMd(iyd(a.e));j.e!=j.i.gc();){i=RD(bMd(j),135);Dyd(i,i.i*w);Eyd(i,i.j*A);}for(s=new dMd(wCd(a.e));s.e!=s.i.gc();){r=RD(bMd(s),123);u=r.i;v=r.j;u>0&&Dyd(r,u*w);v>0&&Eyd(r,v*A);}Bvb(a.b,new tTb);b=new bnb;for(h=new vkb((new mkb(a.c)).a);h.b;){g=tkb(h);d=RD(g.ld(),74);c=RD(g.md(),407).a;e=IGd(d,false,false);l=fTb(JGd(d),ssd(e),c);lsd(l,e);t=KGd(d);if(!!t&&Wmb(b,t,0)==-1){ZEb(b.c,t);gTb(t,(sFb(l.b!=0),RD(l.a.a.c,8)),c);}}for(q=new vkb((new mkb(a.d)).a);q.b;){p=tkb(q);d=RD(p.ld(),74);c=RD(p.md(),407).a;e=IGd(d,false,false);l=fTb(LGd(d),Ijd(ssd(e)),c);l=Ijd(l);lsd(l,e);t=MGd(d);if(!!t&&Wmb(b,t,0)==-1){ZEb(b.c,t);gTb(t,(sFb(l.b!=0),RD(l.c.b.c,8)),c);}}} + function GJb(a,b,c,d){var e,f,g,h,i;h=new CLb(b);iNb(h,d);e=true;if(!!a&&a.pf((umd(),Nkd))){f=RD(a.of((umd(),Nkd)),88);e=f==(Cmd(),Amd)||f==ymd||f==zmd;}$Mb(h,false);Umb(h.e.Rf(),new dNb(h,false,e));EMb(h,h.f,(ZJb(),WJb),(qpd(),Yod));EMb(h,h.f,YJb,npd);EMb(h,h.g,WJb,ppd);EMb(h,h.g,YJb,Xod);GMb(h,Yod);GMb(h,npd);FMb(h,Xod);FMb(h,ppd);RMb();g=h.A.Hc((Qpd(),Mpd))&&h.B.Hc((dqd(),$pd))?SMb(h):null;!!g&&uKb(h.a,g);XMb(h);xMb(h);GNb(h);sMb(h);gNb(h);yNb(h);oNb(h,Yod);oNb(h,npd);tMb(h);fNb(h);if(!c){return h.o}VMb(h);CNb(h);oNb(h,Xod);oNb(h,ppd);i=h.B.Hc((dqd(),_pd));IMb(h,i,Yod);IMb(h,i,npd);JMb(h,i,Xod);JMb(h,i,ppd);FDb(new SDb(null,new Swb(new glb(h.i),0)),new KMb);FDb(CDb(new SDb(null,ki(h.r).a.oc()),new MMb),new OMb);WMb(h);h.e.Pf(h.o);FDb(new SDb(null,ki(h.r).a.oc()),new YMb);return h.o} + function LYb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;j=oxe;for(d=new Anb(a.a.b);d.a1){n=new xVc(o,t,d);xgb(t,new nVc(a,n));ZEb(g.c,n);for(l=t.a.ec().Kc();l.Ob();){k=RD(l.Pb(),42);Ymb(f,k.b);}}if(h.a.gc()>1){n=new xVc(o,h,d);xgb(h,new pVc(a,n));ZEb(g.c,n);for(l=h.a.ec().Kc();l.Ob();){k=RD(l.Pb(),42);Ymb(f,k.b);}}}} + function p6b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;p=a.n;q=a.o;m=a.d;l=Kfb(UD(hFc(a,(yCc(),QBc))));if(b){k=l*(b.gc()-1);n=0;for(i=b.Kc();i.Ob();){g=RD(i.Pb(),10);k+=g.o.a;n=$wnd.Math.max(n,g.o.b);}r=p.a-(k-q.a)/2;f=p.b-m.d+n;d=q.a/(b.gc()+1);e=d;for(h=b.Kc();h.Ob();){g=RD(h.Pb(),10);g.n.a=r;g.n.b=f-g.o.b;r+=g.o.a+l;j=n6b(g);j.n.a=g.o.a/2-j.a.a;j.n.b=g.o.b;o=RD(mQb(g,(Ywc(),Xvc)),12);if(o.e.c.length+o.g.c.length==1){o.n.a=e-o.a.a;o.n.b=0;P3b(o,a);}e+=d;}}if(c){k=l*(c.gc()-1);n=0;for(i=c.Kc();i.Ob();){g=RD(i.Pb(),10);k+=g.o.a;n=$wnd.Math.max(n,g.o.b);}r=p.a-(k-q.a)/2;f=p.b+q.b+m.a-n;d=q.a/(c.gc()+1);e=d;for(h=c.Kc();h.Ob();){g=RD(h.Pb(),10);g.n.a=r;g.n.b=f;r+=g.o.a+l;j=n6b(g);j.n.a=g.o.a/2-j.a.a;j.n.b=0;o=RD(mQb(g,(Ywc(),Xvc)),12);if(o.e.c.length+o.g.c.length==1){o.n.a=e-o.a.a;o.n.b=q.b;P3b(o,a);}e+=d;}}} + function Hac(a,b){var c,d,e,f,g,h;if(!RD(mQb(b,(Ywc(),kwc)),21).Hc((ovc(),hvc))){return}for(h=new Anb(b.a);h.a=0&&g0&&(RD(Vrb(a.b,b),127).a.b=c);} + function wcc(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;m=Kfb(UD(mQb(a,(yCc(),_Bc))));n=Kfb(UD(mQb(a,aCc)));l=Kfb(UD(mQb(a,ZBc)));h=a.o;f=RD(Vmb(a.j,0),12);g=f.n;p=ucc(f,l);if(!p){return}if(b.Hc((Pod(),Lod))){switch(RD(mQb(a,(Ywc(),hwc)),64).g){case 1:p.c=(h.a-p.b)/2-g.a;p.d=n;break;case 3:p.c=(h.a-p.b)/2-g.a;p.d=-n-p.a;break;case 2:if(c&&f.e.c.length==0&&f.g.c.length==0){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=h.b+n-g.b;}p.c=-m-p.b;break;case 4:if(c&&f.e.c.length==0&&f.g.c.length==0){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=h.b+n-g.b;}p.c=m;}}else if(b.Hc(Nod)){switch(RD(mQb(a,(Ywc(),hwc)),64).g){case 1:case 3:p.c=g.a+m;break;case 2:case 4:if(c&&!f.c){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=g.b+n;}}}e=p.d;for(j=new Anb(f.f);j.a=b.length)return {done:true};var a=b[d++];return {value:[a,c.get(a)],done:false}}}};if(!Ftb()){e.prototype.createObject=function(){return {}};e.prototype.get=function(a){return this.obj[':'+a]};e.prototype.set=function(a,b){this.obj[':'+a]=b;};e.prototype[Jxe]=function(a){delete this.obj[':'+a];};e.prototype.keys=function(){var a=[];for(var b in this.obj){b.charCodeAt(0)==58&&a.push(b.substring(1));}return a};}return e} + function q$c(){q$c=geb;h$c=new jGd(rAe);new kGd('DEPTH',sgb(0));XZc=new kGd('FAN',sgb(0));VZc=new kGd(QEe,sgb(0));n$c=new kGd('ROOT',(Geb(),false));b$c=new kGd('LEFTNEIGHBOR',null);l$c=new kGd('RIGHTNEIGHBOR',null);c$c=new kGd('LEFTSIBLING',null);m$c=new kGd('RIGHTSIBLING',null);WZc=new kGd('DUMMY',false);new kGd('LEVEL',sgb(0));k$c=new kGd('REMOVABLE_EDGES',new Yub);o$c=new kGd('XCOOR',sgb(0));p$c=new kGd('YCOOR',sgb(0));d$c=new kGd('LEVELHEIGHT',0);f$c=new kGd('LEVELMIN',0);e$c=new kGd('LEVELMAX',0);ZZc=new kGd('GRAPH_XMIN',0);_Zc=new kGd('GRAPH_YMIN',0);YZc=new kGd('GRAPH_XMAX',0);$Zc=new kGd('GRAPH_YMAX',0);UZc=new kGd('COMPACT_LEVEL_ASCENSION',false);TZc=new kGd('COMPACT_CONSTRAINTS',new bnb);a$c=new kGd('ID','');i$c=new kGd('POSITION',sgb(0));j$c=new kGd('PRELIM',0);g$c=new kGd('MODIFIER',0);SZc=new jGd(tAe);RZc=new jGd(uAe);} + function Bqe(a){zqe();var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(a==null)return null;l=a.length*8;if(l==0){return ''}h=l%24;n=l/24|0;m=h!=0?n+1:n;f=null;f=$C(hE,zwe,28,m*4,15,1);j=0;k=0;b=0;c=0;d=0;g=0;e=0;for(i=0;i>24;j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;p=(c&-128)==0?c>>4<<24>>24:(c>>4^240)<<24>>24;q=(d&-128)==0?d>>6<<24>>24:(d>>6^252)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[p|j<<4];f[g++]=yqe[k<<2|q];f[g++]=yqe[d&63];}if(h==8){b=a[e];j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[j<<4];f[g++]=61;f[g++]=61;}else if(h==16){b=a[e];c=a[e+1];k=(c&15)<<24>>24;j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;p=(c&-128)==0?c>>4<<24>>24:(c>>4^240)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[p|j<<4];f[g++]=yqe[k<<2];f[g++]=61;}return Ihb(f,0,f.length)} + function CB(a,b){var c,d,e,f,g,h,i;a.e==0&&a.p>0&&(a.p=-(a.p-1));a.p>qwe&&tB(b,a.p-Owe);g=b.q.getDate();nB(b,1);a.k>=0&&qB(b,a.k);if(a.c>=0){nB(b,a.c);}else if(a.k>=0){i=new vB(b.q.getFullYear()-Owe,b.q.getMonth(),35);d=35-i.q.getDate();nB(b,$wnd.Math.min(d,g));}else {nB(b,g);}a.f<0&&(a.f=b.q.getHours());a.b>0&&a.f<12&&(a.f+=12);oB(b,a.f==24&&a.g?0:a.f);a.j>=0&&pB(b,a.j);a.n>=0&&rB(b,a.n);a.i>=0&&sB(b,Bdb(Ndb(Fdb(Hdb(b.q.getTime()),Awe),Awe),a.i));if(a.a){e=new uB;tB(e,e.q.getFullYear()-Owe-80);Ldb(Hdb(b.q.getTime()),Hdb(e.q.getTime()))&&tB(b,e.q.getFullYear()-Owe+100);}if(a.d>=0){if(a.c==-1){c=(7+a.d-b.q.getDay())%7;c>3&&(c-=7);h=b.q.getMonth();nB(b,b.q.getDate()+c);b.q.getMonth()!=h&&nB(b,b.q.getDate()+(c>0?-7:7));}else {if(b.q.getDay()!=a.d){return false}}}if(a.o>qwe){f=b.q.getTimezoneOffset();sB(b,Bdb(Hdb(b.q.getTime()),(a.o-f)*60*Awe));}return true} + function J5b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;e=mQb(b,(Ywc(),Awc));if(!ZD(e,207)){return}o=RD(e,27);p=b.e;m=new sjd(b.c);f=b.d;m.a+=f.b;m.b+=f.d;u=RD(Gxd(o,(yCc(),oBc)),181);if(Csb(u,(dqd(),Xpd))){n=RD(Gxd(o,qBc),107);E2b(n,f.a);H2b(n,f.d);F2b(n,f.b);G2b(n,f.c);}c=new bnb;for(k=new Anb(b.a);k.ad.c.length-1){Rmb(d,new Ptd(Hze,KEe));}c=RD(mQb(e,f_c),17).a;if(Dmd(RD(mQb(a,H$c),88))){e.e.aKfb(UD((tFb(c,d.c.length),RD(d.c[c],42)).b))&&Otd((tFb(c,d.c.length),RD(d.c[c],42)),e.e.a+e.f.a);}else {e.e.bKfb(UD((tFb(c,d.c.length),RD(d.c[c],42)).b))&&Otd((tFb(c,d.c.length),RD(d.c[c],42)),e.e.b+e.f.b);}}for(f=Sub(a.b,0);f.b!=f.d.c;){e=RD(evb(f),40);c=RD(mQb(e,(h_c(),f_c)),17).a;pQb(e,(q$c(),f$c),UD((tFb(c,d.c.length),RD(d.c[c],42)).a));pQb(e,e$c,UD((tFb(c,d.c.length),RD(d.c[c],42)).b));}b.Vg();} + function Tec(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;a.o=Kfb(UD(mQb(a.i,(yCc(),bCc))));a.f=Kfb(UD(mQb(a.i,XBc)));a.j=a.i.b.c.length;h=a.j-1;m=0;a.k=0;a.n=0;a.b=dv($C(bJ,Nve,17,a.j,0,1));a.c=dv($C(VI,Nve,345,a.j,7,1));for(g=new Anb(a.i.b);g.a0&&Rmb(a.q,k);Rmb(a.p,k);}b-=d;n=i+b;j+=b*a.f;$mb(a.b,h,sgb(n));$mb(a.c,h,j);a.k=$wnd.Math.max(a.k,n);a.n=$wnd.Math.max(a.n,j);a.e+=b;b+=p;}} + function qpd(){qpd=geb;var a;opd=new upd(Sye,0);Yod=new upd(_ye,1);Xod=new upd(aze,2);npd=new upd(bze,3);ppd=new upd(cze,4);bpd=(yob(),new Lqb((a=RD(mfb(E3),9),new Fsb(a,RD(WEb(a,a.length),9),0))));cpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[])));Zod=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[])));kpd=eq(ysb(npd,cD(WC(E3,1),NAe,64,0,[])));mpd=eq(ysb(ppd,cD(WC(E3,1),NAe,64,0,[])));hpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[npd])));apd=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[ppd])));jpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[ppd])));dpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod])));lpd=eq(ysb(npd,cD(WC(E3,1),NAe,64,0,[ppd])));$od=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[npd])));gpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,ppd])));_od=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[npd,ppd])));ipd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[npd,ppd])));epd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,npd])));fpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,npd,ppd])));} + function Gfc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;b.Ug(qBe,1);p=new bnb;w=new bnb;for(j=new Anb(a.b);j.a0&&(t-=n);p2b(g,t);k=0;for(m=new Anb(g.a);m.a0);h.a.Xb(h.c=--h.b);}i=0.4*d*k;!f&&h.b0){j=(BFb(0,c.length),c.charCodeAt(0));if(j!=64){if(j==37){m=c.lastIndexOf('%');k=false;if(m!=0&&(m==n-1||(k=(BFb(m+1,c.length),c.charCodeAt(m+1)==46)))){h=(AFb(1,m,c.length),c.substr(1,m-1));u=lhb('%',h)?null:oSd(h);e=0;if(k){try{e=Oeb((BFb(m+2,c.length+1),c.substr(m+2)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){i=a;throw Adb(new RSd(i))}else throw Adb(a)}}for(r=P2d(b.Gh());r.Ob();){p=k3d(r);if(ZD(p,519)){f=RD(p,598);t=f.d;if((u==null?t==null:lhb(u,t))&&e--==0){return f}}}return null}}l=c.lastIndexOf('.');o=l==-1?c:(AFb(0,l,c.length),c.substr(0,l));d=0;if(l!=-1){try{d=Oeb((BFb(l+1,c.length+1),c.substr(l+1)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){o=c;}else throw Adb(a)}}o=lhb('%',o)?null:oSd(o);for(q=P2d(b.Gh());q.Ob();){p=k3d(q);if(ZD(p,197)){g=RD(p,197);s=g.xe();if((o==null?s==null:lhb(o,s))&&d--==0){return g}}}return null}}return Pvd(b,c)} + function Hlc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;k=new Tsb;i=new Tp;for(d=new Anb(a.a.a.b);d.ab.d.c){n=a.c[b.a.d];q=a.c[l.a.d];if(n==q){continue}rIb(uIb(tIb(vIb(sIb(new wIb,1),100),n),q));}}}}}}} + function mNb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;m=RD(RD(Qc(a.r,b),21),87);if(b==(qpd(),Xod)||b==ppd){qNb(a,b);return}f=b==Yod?(mOb(),iOb):(mOb(),lOb);u=b==Yod?(vLb(),uLb):(vLb(),sLb);c=RD(Vrb(a.b,b),127);d=c.i;e=d.c+Hid(cD(WC(iE,1),vxe,28,15,[c.n.b,a.C.b,a.k]));r=d.c+d.b-Hid(cD(WC(iE,1),vxe,28,15,[c.n.c,a.C.c,a.k]));g=WNb(_Nb(f),a.t);s=b==Yod?pxe:oxe;for(l=m.Kc();l.Ob();){j=RD(l.Pb(),117);if(!j.c||j.c.d.c.length<=0){continue}q=j.b.Mf();p=j.e;n=j.c;o=n.i;o.b=(i=n.n,n.e.a+i.b+i.c);o.a=(h=n.n,n.e.b+h.d+h.a);Ivb(u,Pye);n.f=u;RKb(n,(EKb(),DKb));o.c=p.a-(o.b-q.a)/2;v=$wnd.Math.min(e,p.a);w=$wnd.Math.max(r,p.a+q.a);o.cw&&(o.c=w-o.b);Rmb(g.d,new sOb(o,UNb(g,o)));s=b==Yod?$wnd.Math.max(s,p.b+j.b.Mf().b):$wnd.Math.min(s,p.b);}s+=b==Yod?a.t:-a.t;t=VNb((g.e=s,g));t>0&&(RD(Vrb(a.b,b),127).a.b=t);for(k=m.Kc();k.Ob();){j=RD(k.Pb(),117);if(!j.c||j.c.d.c.length<=0){continue}o=j.c.i;o.c-=j.e.a;o.d-=j.e.b;}} + function JSb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;b=new Tsb;for(i=new dMd(a);i.e!=i.i.gc();){h=RD(bMd(i),27);c=new _sb;Zjb(FSb,h,c);n=new TSb;e=RD(zDb(new SDb(null,new Twb(new is(Mr(yGd(h).a.Kc(),new ir)))),OBb(n,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)])))),85);ISb(c,RD(e.xc((Geb(),true)),16),new VSb);d=RD(zDb(CDb(RD(e.xc(false),15).Lc(),new XSb),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);for(g=d.Kc();g.Ob();){f=RD(g.Pb(),74);m=KGd(f);if(m){j=RD(Wd(qtb(b.f,m)),21);if(!j){j=LSb(m);rtb(b.f,m,j);}ye(c,j);}}e=RD(zDb(new SDb(null,new Twb(new is(Mr(zGd(h).a.Kc(),new ir)))),OBb(n,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb])))),85);ISb(c,RD(e.xc(true),16),new ZSb);d=RD(zDb(CDb(RD(e.xc(false),15).Lc(),new _Sb),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);for(l=d.Kc();l.Ob();){k=RD(l.Pb(),74);m=MGd(k);if(m){j=RD(Wd(qtb(b.f,m)),21);if(!j){j=LSb(m);rtb(b.f,m,j);}ye(c,j);}}}} + function zjb(a,b){xjb();var c,d,e,f,g,h,i,j,k,l,m,n,o,p;i=Ddb(a,0)<0;i&&(a=Odb(a));if(Ddb(a,0)==0){switch(b){case 0:return '0';case 1:return zxe;case 2:return '0.00';case 3:return '0.000';case 4:return '0.0000';case 5:return '0.00000';case 6:return '0.000000';default:n=new bib;b<0?(n.a+='0E+',n):(n.a+='0E',n);n.a+=b==qwe?'2147483648':''+-b;return n.a;}}k=18;l=$C(hE,zwe,28,k+1,15,1);c=k;p=a;do{j=p;p=Fdb(p,10);l[--c]=Ydb(Bdb(48,Vdb(j,Ndb(p,10))))&Bwe;}while(Ddb(p,0)!=0);e=Vdb(Vdb(Vdb(k,c),b),1);if(b==0){i&&(l[--c]=45);return Ihb(l,c,k-c)}if(b>0&&Ddb(e,-6)>=0){if(Ddb(e,0)>=0){f=c+Ydb(e);for(h=k-1;h>=f;h--){l[h+1]=l[h];}l[++f]=46;i&&(l[--c]=45);return Ihb(l,c,k-c+1)}for(g=2;Ldb(g,Bdb(Odb(e),1));g++){l[--c]=48;}l[--c]=46;l[--c]=48;i&&(l[--c]=45);return Ihb(l,c,k-c)}o=c+1;d=k;m=new cib;i&&(m.a+='-',m);if(d-o>=1){Thb(m,l[c]);m.a+='.';m.a+=Ihb(l,c+1,k-c-1);}else {m.a+=Ihb(l,c,k-c);}m.a+='E';Ddb(e,0)>0&&(m.a+='+',m);m.a+=''+Zdb(e);return m.a} + function Esd(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;q=new rjd(a.g,a.f);p=vsd(a);p.a=$wnd.Math.max(p.a,b);p.b=$wnd.Math.max(p.b,c);w=p.a/q.a;k=p.b/q.b;u=p.a-q.a;i=p.b-q.b;if(d){g=!vCd(a)?RD(Gxd(a,(umd(),Nkd)),88):RD(Gxd(vCd(a),(umd(),Nkd)),88);h=dE(Gxd(a,(umd(),Hld)))===dE((Bod(),wod));for(s=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));s.e!=s.i.gc();){r=RD(bMd(s),123);t=RD(Gxd(r,Old),64);if(t==(qpd(),opd)){t=osd(r,g);Ixd(r,Old,t);}switch(t.g){case 1:h||Dyd(r,r.i*w);break;case 2:Dyd(r,r.i+u);h||Eyd(r,r.j*k);break;case 3:h||Dyd(r,r.i*w);Eyd(r,r.j+i);break;case 4:h||Eyd(r,r.j*k);}}}zyd(a,p.a,p.b);if(e){for(m=new dMd((!a.n&&(a.n=new C5d(I4,a,1,7)),a.n));m.e!=m.i.gc();){l=RD(bMd(m),135);n=l.i+l.g/2;o=l.j+l.f/2;v=n/q.a;j=o/q.b;if(v+j>=1){if(v-j>0&&o>=0){Dyd(l,l.i+u);Eyd(l,l.j+i*j);}else if(v-j<0&&n>=0){Dyd(l,l.i+u*v);Eyd(l,l.j+i);}}}}Ixd(a,(umd(),kld),(Qpd(),f=RD(mfb(H3),9),new Fsb(f,RD(WEb(f,f.length),9),0)));return new rjd(w,k)} + function _4c(a){Cgd(a,new Pfd(Wfd($fd(Xfd(Zfd(Yfd(new agd,CFe),'ELK Radial'),'A radial layout provider which is based on the algorithm of Peter Eades published in "Drawing free trees.", published by International Institute for Advanced Study of Social Information Science, Fujitsu Limited in 1991. The radial layouter takes a tree and places the nodes in radial order around the root. The nodes of the same tree level are placed on the same radius.'),new c5c),CFe)));Agd(a,CFe,fEe,iGd(R4c));Agd(a,CFe,_ze,iGd(Y4c));Agd(a,CFe,jAe,iGd(K4c));Agd(a,CFe,CAe,iGd(L4c));Agd(a,CFe,iAe,iGd(M4c));Agd(a,CFe,kAe,iGd(J4c));Agd(a,CFe,gAe,iGd(N4c));Agd(a,CFe,lAe,iGd(Q4c));Agd(a,CFe,tFe,iGd(H4c));Agd(a,CFe,sFe,iGd(I4c));Agd(a,CFe,rFe,iGd(T4c));Agd(a,CFe,xFe,iGd(W4c));Agd(a,CFe,yFe,iGd(U4c));Agd(a,CFe,zFe,iGd(V4c));Agd(a,CFe,wFe,iGd(O4c));Agd(a,CFe,pFe,iGd(P4c));Agd(a,CFe,qFe,iGd(S4c));Agd(a,CFe,uFe,iGd(X4c));Agd(a,CFe,vFe,iGd(Z4c));Agd(a,CFe,oFe,iGd(G4c));} + function Peb(a){var b,c,d,e,f,g,h,i,j,k,l;if(a==null){throw Adb(new Vgb(vve))}j=a;f=a.length;i=false;if(f>0){b=(BFb(0,a.length),a.charCodeAt(0));if(b==45||b==43){a=(BFb(1,a.length+1),a.substr(1));--f;i=b==45;}}if(f==0){throw Adb(new Vgb(nxe+j+'"'))}while(a.length>0&&(BFb(0,a.length),a.charCodeAt(0)==48)){a=(BFb(1,a.length+1),a.substr(1));--f;}if(f>(Ugb(),Sgb)[10]){throw Adb(new Vgb(nxe+j+'"'))}for(e=0;e0){l=-parseInt((AFb(0,d,a.length),a.substr(0,d)),10);a=(BFb(d,a.length+1),a.substr(d));f-=d;c=false;}while(f>=g){d=parseInt((AFb(0,g,a.length),a.substr(0,g)),10);a=(BFb(g,a.length+1),a.substr(g));f-=g;if(c){c=false;}else {if(Ddb(l,h)<0){throw Adb(new Vgb(nxe+j+'"'))}l=Ndb(l,k);}l=Vdb(l,d);}if(Ddb(l,0)>0){throw Adb(new Vgb(nxe+j+'"'))}if(!i){l=Odb(l);if(Ddb(l,0)<0){throw Adb(new Vgb(nxe+j+'"'))}}return l} + function oSd(a){gSd();var b,c,d,e,f,g,h,i;if(a==null)return null;e=qhb(a,Fhb(37));if(e<0){return a}else {i=new dib((AFb(0,e,a.length),a.substr(0,e)));b=$C(gE,YHe,28,4,15,1);h=0;d=0;for(g=a.length;ee+2&&zSd((BFb(e+1,a.length),a.charCodeAt(e+1)),XRd,YRd)&&zSd((BFb(e+2,a.length),a.charCodeAt(e+2)),XRd,YRd)){c=DSd((BFb(e+1,a.length),a.charCodeAt(e+1)),(BFb(e+2,a.length),a.charCodeAt(e+2)));e+=2;if(d>0){(c&192)==128?(b[h++]=c<<24>>24):(d=0);}else if(c>=128){if((c&224)==192){b[h++]=c<<24>>24;d=2;}else if((c&240)==224){b[h++]=c<<24>>24;d=3;}else if((c&248)==240){b[h++]=c<<24>>24;d=4;}}if(d>0){if(h==d){switch(h){case 2:{Thb(i,((b[0]&31)<<6|b[1]&63)&Bwe);break}case 3:{Thb(i,((b[0]&15)<<12|(b[1]&63)<<6|b[2]&63)&Bwe);break}}h=0;d=0;}}else {for(f=0;f=2){if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i==0){c=(bvd(),e=new Rzd,e);WGd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),c);}else if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i>1){m=new mMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));while(m.e!=m.i.gc()){cMd(m);}}lsd(b,RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166));}if(l){for(d=new dMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));d.e!=d.i.gc();){c=RD(bMd(d),166);for(j=new dMd((!c.a&&(c.a=new XZd(D4,c,5)),c.a));j.e!=j.i.gc();){i=RD(bMd(j),377);h.a=$wnd.Math.max(h.a,i.a);h.b=$wnd.Math.max(h.b,i.b);}}}for(g=new dMd((!a.n&&(a.n=new C5d(I4,a,1,7)),a.n));g.e!=g.i.gc();){f=RD(bMd(g),135);k=RD(Gxd(f,und),8);!!k&&Byd(f,k.a,k.b);if(l){h.a=$wnd.Math.max(h.a,f.i+f.g);h.b=$wnd.Math.max(h.b,f.j+f.f);}}return h} + function MA(a,b,c,d,e){var f,g,h;KA(a,b);g=b[0];f=ihb(c.c,0);h=-1;if(DA(c)){if(d>0){if(g+d>a.length){return false}h=HA((AFb(0,g+d,a.length),a.substr(0,g+d)),b);}else {h=HA(a,b);}}switch(f){case 71:h=EA(a,g,cD(WC(qJ,1),Nve,2,6,[Qwe,Rwe]),b);e.e=h;return true;case 77:return PA(a,b,e,h,g);case 76:return RA(a,b,e,h,g);case 69:return NA(a,b,g,e);case 99:return QA(a,b,g,e);case 97:h=EA(a,g,cD(WC(qJ,1),Nve,2,6,['AM','PM']),b);e.b=h;return true;case 121:return TA(a,b,g,h,c,e);case 100:if(h<=0){return false}e.c=h;return true;case 83:if(h<0){return false}return OA(h,g,b[0],e);case 104:h==12&&(h=0);case 75:case 72:if(h<0){return false}e.f=h;e.g=false;return true;case 107:if(h<0){return false}e.f=h;e.g=true;return true;case 109:if(h<0){return false}e.j=h;return true;case 115:if(h<0){return false}e.n=h;return true;case 90:if(gB[i]&&(q=i);for(l=new Anb(a.a.b);l.a1){e=N8c(b);l=f.g;o=RD(Gxd(b,N7c),107);p=Kfb(UD(Gxd(b,x7c)));(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i>1&&Kfb(UD(Gxd(b,(X6c(),T6c))))!=oxe&&(f.c+(o.b+o.c))/(f.b+(o.d+o.a))1&&Kfb(UD(Gxd(b,(X6c(),S6c))))!=oxe&&(f.c+(o.b+o.c))/(f.b+(o.d+o.a))>p&&Ixd(e,(X6c(),W6c),$wnd.Math.max(Kfb(UD(Gxd(b,U6c))),Kfb(UD(Gxd(e,W6c)))-Kfb(UD(Gxd(b,S6c)))));n=new m9c(d,k);i=l9c(n,e,m);j=i.g;if(j>=l&&j==j){for(g=0;g<(!e.a&&(e.a=new C5d(J4,e,10,11)),e.a).i;g++){O8c(a,RD(QHd((!e.a&&(e.a=new C5d(J4,e,10,11)),e.a),g),27),RD(QHd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),g),27));}P8c(b,n);jad(f,i.c);iad(f,i.b);}--h;}Ixd(b,(X6c(),N6c),f.b);Ixd(b,O6c,f.c);c.Vg();} + function fHc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;b.Ug('Interactive node layering',1);c=new bnb;for(m=new Anb(a.a);m.a=h){sFb(s.b>0);s.a.Xb(s.c=--s.b);break}else if(q.a>i){if(!d){Rmb(q.b,k);q.c=$wnd.Math.min(q.c,i);q.a=$wnd.Math.max(q.a,h);d=q;}else {Tmb(d.b,q.b);d.a=$wnd.Math.max(d.a,q.a);Ckb(s);}}}if(!d){d=new jHc;d.c=i;d.a=h;Ikb(s,d);Rmb(d.b,k);}}g=a.b;j=0;for(r=new Anb(c);r.an){if(f){Oub(w,m);Oub(B,sgb(j.b-1));}H=c.b;I+=m+b;m=0;k=$wnd.Math.max(k,c.b+c.c+G);}Dyd(h,H);Eyd(h,I);k=$wnd.Math.max(k,H+G+c.c);m=$wnd.Math.max(m,l);H+=G+b;}k=$wnd.Math.max(k,d);F=I+m+c.a;if(FVze;C=$wnd.Math.abs(m.b-o.b)>Vze;(!c&&B&&C||c&&(B||C))&&Mub(q.a,u);}ye(q.a,d);d.b==0?(m=u):(m=(sFb(d.b!=0),RD(d.c.b.c,8)));j0b(n,l,p);if(I0b(e)==A){if(Y2b(A.i)!=e.a){p=new pjd;e2b(p,Y2b(A.i),s);}pQb(q,Wwc,p);}k0b(n,q,s);k.a.zc(n,k);}Y0b(q,v);Z0b(q,A);}for(j=k.a.ec().Kc();j.Ob();){i=RD(j.Pb(),18);Y0b(i,null);Z0b(i,null);}b.Vg();} + function lXc(a,b){var c,d,e,f,g,h,i,j,k,l,m;e=RD(mQb(a,(h_c(),H$c)),88);k=e==(Cmd(),ymd)||e==zmd?xmd:zmd;c=RD(zDb(CDb(new SDb(null,new Swb(a.b,16)),new $Xc),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);i=RD(zDb(GDb(c.Oc(),new aYc(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);i.Gc(RD(zDb(GDb(c.Oc(),new cYc(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),16));i.jd(new eYc(k));m=new yAb(new iYc(e));d=new Tsb;for(h=i.Kc();h.Ob();){g=RD(h.Pb(),240);j=RD(g.a,40);if(Heb(TD(g.c))){m.a.zc(j,(Geb(),Eeb))==null;(new zAb(m.a.Zc(j,false))).a.gc()>0&&Zjb(d,j,RD((new zAb(m.a.Zc(j,false))).a.Vc(),40));(new zAb(m.a.ad(j,true))).a.gc()>1&&Zjb(d,nXc(m,j),j);}else {if((new zAb(m.a.Zc(j,false))).a.gc()>0){f=RD((new zAb(m.a.Zc(j,false))).a.Vc(),40);dE(f)===dE(Wd(qtb(d.f,j)))&&RD(mQb(j,(q$c(),TZc)),15).Fc(f);}if((new zAb(m.a.ad(j,true))).a.gc()>1){l=nXc(m,j);dE(Wd(qtb(d.f,l)))===dE(j)&&RD(mQb(l,(q$c(),TZc)),15).Fc(j);}m.a.Bc(j)!=null;}}} + function BTb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(a.gc()==1){return RD(a.Xb(0),235)}else if(a.gc()<=0){return new gUb}for(e=a.Kc();e.Ob();){c=RD(e.Pb(),235);o=0;k=lve;l=lve;i=qwe;j=qwe;for(n=new Anb(c.e);n.ah){t=0;u+=g+r;g=0;}ATb(p,c,t,u);b=$wnd.Math.max(b,t+q.a);g=$wnd.Math.max(g,q.b);t+=q.a+r;}return p} + function Aqe(a){zqe();var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(a==null)return null;f=Ahb(a);o=Dqe(f);if(o%4!=0){return null}p=o/4|0;if(p==0)return $C(gE,YHe,28,0,15,1);l=null;b=0;c=0;d=0;e=0;g=0;h=0;i=0;j=0;n=0;m=0;k=0;l=$C(gE,YHe,28,p*3,15,1);for(;n>4)<<24>>24;l[m++]=((c&15)<<4|d>>2&15)<<24>>24;l[m++]=(d<<6|e)<<24>>24;}if(!Cqe(g=f[k++])||!Cqe(h=f[k++])){return null}b=xqe[g];c=xqe[h];i=f[k++];j=f[k++];if(xqe[i]==-1||xqe[j]==-1){if(i==61&&j==61){if((c&15)!=0)return null;q=$C(gE,YHe,28,n*3+1,15,1);hib(l,0,q,0,n*3);q[m]=(b<<2|c>>4)<<24>>24;return q}else if(i!=61&&j==61){d=xqe[i];if((d&3)!=0)return null;q=$C(gE,YHe,28,n*3+2,15,1);hib(l,0,q,0,n*3);q[m++]=(b<<2|c>>4)<<24>>24;q[m]=((c&15)<<4|d>>2&15)<<24>>24;return q}else {return null}}else {d=xqe[i];e=xqe[j];l[m++]=(b<<2|c>>4)<<24>>24;l[m++]=((c&15)<<4|d>>2&15)<<24>>24;l[m++]=(d<<6|e)<<24>>24;}return l} + function wfc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;b.Ug(qBe,1);o=RD(mQb(a,(yCc(),yAc)),223);for(e=new Anb(a.b);e.a=2){p=true;m=new Anb(f.j);c=RD(ynb(m),12);n=null;while(m.a0){d=l.gc();j=eE($wnd.Math.floor((d+1)/2))-1;e=eE($wnd.Math.ceil((d+1)/2))-1;if(b.o==DQc){for(k=e;k>=j;k--){if(b.a[u.p]==u){p=RD(l.Xb(k),42);o=RD(p.a,10);if(!Zsb(c,p.b)&&n>a.b.e[o.p]){b.a[o.p]=u;b.g[u.p]=b.g[o.p];b.a[u.p]=b.g[u.p];b.f[b.g[u.p].p]=(Geb(),Heb(b.f[b.g[u.p].p])&u.k==(r3b(),o3b)?true:false);n=a.b.e[o.p];}}}}else {for(k=j;k<=e;k++){if(b.a[u.p]==u){r=RD(l.Xb(k),42);q=RD(r.a,10);if(!Zsb(c,r.b)&&n0){e=RD(Vmb(q.c.a,w-1),10);g=a.i[e.p];B=$wnd.Math.ceil(bFc(a.n,e,q));f=v.a.e-q.d.d-(g.a.e+e.o.b+e.d.a)-B;}j=oxe;if(w0&&A.a.e.e-A.a.a-(A.b.e.e-A.b.a)<0;o=t.a.e.e-t.a.a-(t.b.e.e-t.b.a)<0&&A.a.e.e-A.a.a-(A.b.e.e-A.b.a)>0;n=t.a.e.e+t.b.aA.b.e.e+A.a.a;u=0;!p&&!o&&(m?f+l>0?(u=l):j-d>0&&(u=d):n&&(f+h>0?(u=h):j-s>0&&(u=s)));v.a.e+=u;v.b&&(v.d.e+=u);return false} + function OJb(a,b,c){var d,e,f,g,h,i,j,k,l,m;d=new Uid(b.Lf().a,b.Lf().b,b.Mf().a,b.Mf().b);e=new Tid;if(a.c){for(g=new Anb(b.Rf());g.aj&&(d.a+=Hhb($C(hE,zwe,28,-j,15,1)));d.a+='Is';if(qhb(i,Fhb(32))>=0){for(e=0;e=d.o.b/2;}else {s=!l;}if(s){r=RD(mQb(d,(Ywc(),Xwc)),15);if(!r){f=new bnb;pQb(d,Xwc,f);}else if(m){f=r;}else {e=RD(mQb(d,Vvc),15);if(!e){f=new bnb;pQb(d,Vvc,f);}else {r.gc()<=e.gc()?(f=r):(f=e);}}}else {e=RD(mQb(d,(Ywc(),Vvc)),15);if(!e){f=new bnb;pQb(d,Vvc,f);}else if(l){f=e;}else {r=RD(mQb(d,Xwc),15);if(!r){f=new bnb;pQb(d,Xwc,f);}else {e.gc()<=r.gc()?(f=e):(f=r);}}}f.Fc(a);pQb(a,(Ywc(),Xvc),c);if(b.d==c){Z0b(b,null);c.e.c.length+c.g.c.length==0&&P3b(c,null);u6b(c);}else {Y0b(b,null);c.e.c.length+c.g.c.length==0&&P3b(c,null);}Xub(b.a);} + function GHc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;c.Ug('MinWidth layering',1);n=b.b;A=b.a;I=RD(mQb(b,(yCc(),WAc)),17).a;h=RD(mQb(b,XAc),17).a;a.b=Kfb(UD(mQb(b,TBc)));a.d=oxe;for(u=new Anb(A);u.a0){j=0;!!q&&(j+=h);j+=(C-1)*g;!!t&&(j+=h);B&&!!t&&(j=$wnd.Math.max(j,JUc(t,g,s,A)));if(j=a.a){d=V9b(a,s);k=$wnd.Math.max(k,d.b);u=$wnd.Math.max(u,d.d);Rmb(h,new Ptd(s,d));}}B=new bnb;for(j=0;j0),q.a.Xb(q.c=--q.b),C=new R4b(a.b),Ikb(q,C),sFb(q.b0){m=k<100?null:new gLd(k);j=new $Hd(b);o=j.g;r=$C(kE,Pwe,28,k,15,1);d=0;u=new ZHd(k);for(e=0;e=0;){if(n!=null?pb(n,o[i]):dE(n)===dE(o[i])){if(r.length<=d){q=r;r=$C(kE,Pwe,28,2*r.length,15,1);hib(q,0,r,0,d);}r[d++]=e;WGd(u,o[i]);break v}}n=n;if(dE(n)===dE(h)){break}}}j=u;o=u.g;k=d;if(d>r.length){q=r;r=$C(kE,Pwe,28,d,15,1);hib(q,0,r,0,d);}if(d>0){t=true;for(f=0;f=0;){THd(a,r[g]);}if(d!=k){for(e=k;--e>=d;){THd(j,e);}q=r;r=$C(kE,Pwe,28,d,15,1);hib(q,0,r,0,d);}b=j;}}}else {b=aHd(a,b);for(e=a.i;--e>=0;){if(b.Hc(a.g[e])){THd(a,e);t=true;}}}if(t){if(r!=null){c=b.gc();l=c==1?dZd(a,4,b.Kc().Pb(),null,r[0],p):dZd(a,6,b,r,r[0],p);m=c<100?null:new gLd(c);for(e=b.Kc();e.Ob();){n=e.Pb();m=oge(a,RD(n,76),m);}if(!m){qvd(a.e,l);}else {m.nj(l);m.oj();}}else {m=tLd(b.gc());for(e=b.Kc();e.Ob();){n=e.Pb();m=oge(a,RD(n,76),m);}!!m&&m.oj();}return true}else {return false}} + function i_b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;c=new p_b(b);c.a||b_b(b);j=a_b(b);i=new Tp;q=new D_b;for(p=new Anb(b.a);p.a0||c.o==DQc&&e=c} + function zEd(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G;t=b;s=new Tp;u=new Tp;k=wDd(t,mIe);d=new OEd(a,c,s,u);QDd(d.a,d.b,d.c,d.d,k);i=(A=s.i,!A?(s.i=new zf(s,s.c)):A);for(C=i.Kc();C.Ob();){B=RD(C.Pb(),166);e=RD(Qc(s,B),21);for(p=e.Kc();p.Ob();){o=p.Pb();v=RD(Ao(a.d,o),166);if(v){h=(!B.e&&(B.e=new Yie(F4,B,10,9)),B.e);WGd(h,v);}else {g=zDd(t,uIe);m=AIe+o+BIe+g;n=m+zIe;throw Adb(new CDd(n))}}}j=(w=u.i,!w?(u.i=new zf(u,u.c)):w);for(F=j.Kc();F.Ob();){D=RD(F.Pb(),166);f=RD(Qc(u,D),21);for(r=f.Kc();r.Ob();){q=r.Pb();v=RD(Ao(a.d,q),166);if(v){l=(!D.g&&(D.g=new Yie(F4,D,9,10)),D.g);WGd(l,v);}else {g=zDd(t,uIe);m=AIe+q+BIe+g;n=m+zIe;throw Adb(new CDd(n))}}}!c.b&&(c.b=new Yie(E4,c,4,7));if(c.b.i!=0&&(!c.c&&(c.c=new Yie(E4,c,5,8)),c.c.i!=0)&&(!c.b&&(c.b=new Yie(E4,c,4,7)),c.b.i<=1&&(!c.c&&(c.c=new Yie(E4,c,5,8)),c.c.i<=1))&&(!c.a&&(c.a=new C5d(F4,c,6,6)),c.a).i==1){G=RD(QHd((!c.a&&(c.a=new C5d(F4,c,6,6)),c.a),0),166);if(!Dzd(G)&&!Ezd(G)){Kzd(G,RD(QHd((!c.b&&(c.b=new Yie(E4,c,4,7)),c.b),0),84));Lzd(G,RD(QHd((!c.c&&(c.c=new Yie(E4,c,5,8)),c.c),0),84));}}} + function QNc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;for(t=a.a,u=0,v=t.length;u0){l=RD(Vmb(m.c.a,g-1),10);B=bFc(a.b,m,l);q=m.n.b-m.d.d-(l.n.b+l.o.b+l.d.a+B);}else {q=m.n.b-m.d.d;}j=$wnd.Math.min(q,j);if(g1&&(g=$wnd.Math.min(g,$wnd.Math.abs(RD(ju(h.a,1),8).b-k.b)));}}}}}else {for(p=new Anb(b.j);p.ae){f=m.a-e;g=lve;d.c.length=0;e=m.a;}if(m.a>=e){ZEb(d.c,h);h.a.b>1&&(g=$wnd.Math.min(g,$wnd.Math.abs(RD(ju(h.a,h.a.b-2),8).b-m.b)));}}}}}if(d.c.length!=0&&f>b.o.a/2&&g>b.o.b/2){n=new R3b;P3b(n,b);Q3b(n,(qpd(),Yod));n.n.a=b.o.a/2;r=new R3b;P3b(r,b);Q3b(r,npd);r.n.a=b.o.a/2;r.n.b=b.o.b;for(i=new Anb(d);i.a=j.b?Y0b(h,r):Y0b(h,n);}else {j=RD(Vub(h.a),8);q=h.a.b==0?K3b(h.c):RD(Rub(h.a),8);q.b>=j.b?Z0b(h,r):Z0b(h,n);}l=RD(mQb(h,(yCc(),RAc)),75);!!l&&ze(l,j,true);}b.n.a=e-b.o.a/2;}} + function E0c(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(h=Sub(a.b,0);h.b!=h.d.c;){g=RD(evb(h),40);if(lhb(g.c,IEe)){continue}j=iWc(g,a);b==(Cmd(),ymd)||b==zmd?_mb(j,new D1c):_mb(j,new H1c);i=j.c.length;for(d=0;d=0?(n=vpd(h)):(n=spd(vpd(h)));a.qf(GBc,n);}j=new pjd;m=false;if(a.pf(zBc)){mjd(j,RD(a.of(zBc),8));m=true;}else {ljd(j,g.a/2,g.b/2);}switch(n.g){case 4:pQb(k,UAc,(cxc(),$wc));pQb(k,bwc,(huc(),guc));k.o.b=g.b;p<0&&(k.o.a=-p);Q3b(l,(qpd(),Xod));m||(j.a=g.a);j.a-=g.a;break;case 2:pQb(k,UAc,(cxc(),axc));pQb(k,bwc,(huc(),euc));k.o.b=g.b;p<0&&(k.o.a=-p);Q3b(l,(qpd(),ppd));m||(j.a=0);break;case 1:pQb(k,owc,(Gvc(),Fvc));k.o.a=g.a;p<0&&(k.o.b=-p);Q3b(l,(qpd(),npd));m||(j.b=g.b);j.b-=g.b;break;case 3:pQb(k,owc,(Gvc(),Dvc));k.o.a=g.a;p<0&&(k.o.b=-p);Q3b(l,(qpd(),Yod));m||(j.b=0);}mjd(l.n,j);pQb(k,zBc,j);if(b==vod||b==xod||b==wod){o=0;if(b==vod&&a.pf(CBc)){switch(n.g){case 1:case 2:o=RD(a.of(CBc),17).a;break;case 3:case 4:o=-RD(a.of(CBc),17).a;}}else {switch(n.g){case 4:case 2:o=f.b;b==xod&&(o/=e.b);break;case 1:case 3:o=f.a;b==xod&&(o/=e.a);}}pQb(k,Jwc,o);}pQb(k,hwc,n);return k} + function OId(){MId();function h(f){var g=this;this.dispatch=function(a){var b=a.data;switch(b.cmd){case 'algorithms':var c=PId((yob(),new xpb(new glb(LId.b))));f.postMessage({id:b.id,data:c});break;case 'categories':var d=PId((yob(),new xpb(new glb(LId.c))));f.postMessage({id:b.id,data:d});break;case 'options':var e=PId((yob(),new xpb(new glb(LId.d))));f.postMessage({id:b.id,data:e});break;case 'register':SId(b.algorithms);f.postMessage({id:b.id});break;case 'layout':QId(b.graph,b.layoutOptions||{},b.options||{});f.postMessage({id:b.id,data:b.graph});break;}};this.saveDispatch=function(b){try{g.dispatch(b);}catch(a){f.postMessage({id:b.data.id,error:a});}};} + function j(b){var c=this;this.dispatcher=new h({postMessage:function(a){c.onmessage({data:a});}});this.postMessage=function(a){setTimeout(function(){c.dispatcher.saveDispatch({data:a});},0);};} + if(typeof document===Yxe&&typeof self!==Yxe){var i=new h(self);self.onmessage=i.saveDispatch;}else if(typeof module!==Yxe&&module.exports){Object.defineProperty(exports,'__esModule',{value:true});module.exports={'default':j,Worker:j};}} + function i5b(a,b,c){var d,e,f,g,h,i,j,k,l,m;k=new j3b(c);kQb(k,b);pQb(k,(Ywc(),Awc),b);k.o.a=b.g;k.o.b=b.f;k.n.a=b.i;k.n.b=b.j;Rmb(c.a,k);Zjb(a.a,b,k);((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i!=0||Heb(TD(Gxd(b,(yCc(),NAc)))))&&pQb(k,Yvc,(Geb(),true));j=RD(mQb(c,kwc),21);l=RD(mQb(k,(yCc(),BBc)),101);l==(Bod(),Aod)?pQb(k,BBc,zod):l!=zod&&j.Fc((ovc(),kvc));m=0;d=RD(mQb(c,rAc),88);for(i=new dMd((!b.c&&(b.c=new C5d(K4,b,9,9)),b.c));i.e!=i.i.gc();){h=RD(bMd(i),123);e=vCd(b);(dE(Gxd(e,cAc))!==dE((kEc(),hEc))||dE(Gxd(e,pAc))===dE((Ptc(),Otc))||dE(Gxd(e,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(e,eAc)))||dE(Gxd(e,Yzc))!==dE((U$b(),T$b))||dE(Gxd(e,ZAc))===dE((aEc(),TDc))||dE(Gxd(e,ZAc))===dE((aEc(),UDc))||dE(Gxd(e,$Ac))===dE((_Cc(),SCc))||dE(Gxd(e,$Ac))===dE((_Cc(),UCc)))&&!Heb(TD(Gxd(b,aAc)))&&Ixd(h,zwc,sgb(m++));Heb(TD(Gxd(h,pBc)))||j5b(a,h,k,j,d,l);}for(g=new dMd((!b.n&&(b.n=new C5d(I4,b,1,7)),b.n));g.e!=g.i.gc();){f=RD(bMd(g),135);!Heb(TD(Gxd(f,pBc)))&&!!f.a&&Rmb(k.b,h5b(f));}Heb(TD(mQb(k,Uzc)))&&j.Fc((ovc(),fvc));if(Heb(TD(mQb(k,MAc)))){j.Fc((ovc(),jvc));j.Fc(ivc);pQb(k,BBc,zod);}return k} + function ird(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;p=0;D=0;for(j=new Anb(a.b);j.ap){if(f){Oub(w,n);Oub(B,sgb(k.b-1));Rmb(a.d,o);h.c.length=0;}H=c.b;I+=n+b;n=0;l=$wnd.Math.max(l,c.b+c.c+G);}ZEb(h.c,i);xrd(i,H,I);l=$wnd.Math.max(l,H+G+c.c);n=$wnd.Math.max(n,m);H+=G+b;o=i;}Tmb(a.a,h);Rmb(a.d,RD(Vmb(h,h.c.length-1),163));l=$wnd.Math.max(l,d);F=I+n+c.a;if(Fe.d.d+e.d.a){k.f.d=true;}else {k.f.d=true;k.f.a=true;}}}d.b!=d.d.c&&(b=c);}if(k){f=RD(Wjb(a.f,g.d.i),60);if(b.bf.d.d+f.d.a){k.f.d=true;}else {k.f.d=true;k.f.a=true;}}}}for(h=new is(Mr(Z2b(n).a.Kc(),new ir));gs(h);){g=RD(hs(h),18);if(g.a.b!=0){b=RD(Rub(g.a),8);if(g.d.j==(qpd(),Yod)){q=new Nlc(b,new rjd(b.a,e.d.d),e,g);q.f.a=true;q.a=g.d;ZEb(p.c,q);}if(g.d.j==npd){q=new Nlc(b,new rjd(b.a,e.d.d+e.d.a),e,g);q.f.d=true;q.a=g.d;ZEb(p.c,q);}}}}}return p} + function Nvd(a,b,c){var d,e,f,g,h,i,j,k,l,m;i=new bnb;l=b.length;g=$5d(c);for(j=0;j=o){if(s>o){n.c.length=0;o=s;}ZEb(n.c,g);}}if(n.c.length!=0){m=RD(Vmb(n,Jwb(b,n.c.length)),131);F.a.Bc(m)!=null;m.s=p++;$Uc(m,C,w);n.c.length=0;}}u=a.c.length+1;for(h=new Anb(a);h.aD.s){Ckb(c);Ymb(D.i,d);if(d.c>0){d.a=D;Rmb(D.t,d);d.b=A;Rmb(A.i,d);}}}}} + function Efc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F;p=new cnb(b.b);u=new cnb(b.b);m=new cnb(b.b);B=new cnb(b.b);q=new cnb(b.b);for(A=Sub(b,0);A.b!=A.d.c;){v=RD(evb(A),12);for(h=new Anb(v.g);h.a0;r=v.g.c.length>0;j&&r?(ZEb(m.c,v),true):j?(ZEb(p.c,v),true):r&&(ZEb(u.c,v),true);}for(o=new Anb(p);o.as.nh()-j.b&&(m=s.nh()-j.b);n>s.oh()-j.d&&(n=s.oh()-j.d);k0){for(t=Sub(a.f,0);t.b!=t.d.c;){s=RD(evb(t),10);s.p+=m-a.e;}WGc(a);Xub(a.f);TGc(a,d,n);}else {Mub(a.f,n);n.p=d;a.e=$wnd.Math.max(a.e,d);for(f=new is(Mr(Z2b(n).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(!e.c.i.c&&e.c.i.k==(r3b(),n3b)){Mub(a.f,e.c.i);e.c.i.p=d-1;}}a.c=d;}}}else {WGc(a);Xub(a.f);d=0;if(gs(new is(Mr(Z2b(n).a.Kc(),new ir)))){m=0;m=UGc(m,n);d=m+2;TGc(a,d,n);}else {Mub(a.f,n);n.p=0;a.e=$wnd.Math.max(a.e,0);a.b=RD(Vmb(a.d.b,0),30);a.c=0;}}}}a.f.b==0||WGc(a);a.d.a.c.length=0;r=new bnb;for(j=new Anb(a.d.b);j.a=48&&b<=57){d=b-48;while(e=48&&b<=57){d=d*10+b-48;if(d<0)throw Adb(new Lqe(TId((Hde(),CJe))))}}else {throw Adb(new Lqe(TId((Hde(),yJe))))}c=d;if(b==44){if(e>=a.j){throw Adb(new Lqe(TId((Hde(),AJe))))}else if((b=ihb(a.i,e++))>=48&&b<=57){c=b-48;while(e=48&&b<=57){c=c*10+b-48;if(c<0)throw Adb(new Lqe(TId((Hde(),CJe))))}if(d>c)throw Adb(new Lqe(TId((Hde(),BJe))))}else {c=-1;}}if(b!=125)throw Adb(new Lqe(TId((Hde(),zJe))));if(a.bm(e)){f=(Vse(),Vse(),new Kte(9,f));a.d=e+1;}else {f=(Vse(),Vse(),new Kte(3,f));a.d=e;}f.Om(d);f.Nm(c);Mqe(a);}}return f} + function bXb(a){var b,c,d,e,f;c=RD(mQb(a,(Ywc(),kwc)),21);b=vfd(YWb);e=RD(mQb(a,(yCc(),IAc)),346);e==(Fnd(),Cnd)&&ofd(b,ZWb);Heb(TD(mQb(a,GAc)))?pfd(b,(sXb(),nXb),(hcc(),Zbc)):pfd(b,(sXb(),pXb),(hcc(),Zbc));mQb(a,(rid(),qid))!=null&&ofd(b,$Wb);(Heb(TD(mQb(a,PAc)))||Heb(TD(mQb(a,HAc))))&&nfd(b,(sXb(),rXb),(hcc(),lbc));switch(RD(mQb(a,rAc),88).g){case 2:case 3:case 4:nfd(pfd(b,(sXb(),nXb),(hcc(),nbc)),rXb,mbc);}c.Hc((ovc(),fvc))&&nfd(pfd(pfd(b,(sXb(),nXb),(hcc(),kbc)),qXb,ibc),rXb,jbc);dE(mQb(a,ZAc))!==dE((aEc(),$Dc))&&pfd(b,(sXb(),pXb),(hcc(),Rbc));if(c.Hc(mvc)){pfd(b,(sXb(),nXb),(hcc(),Xbc));pfd(b,oXb,Vbc);pfd(b,pXb,Wbc);}dE(mQb(a,Xzc))!==dE(($uc(),Yuc))&&dE(mQb(a,yAc))!==dE((Ymd(),Vmd))&&nfd(b,(sXb(),rXb),(hcc(),Abc));Heb(TD(mQb(a,KAc)))&&pfd(b,(sXb(),pXb),(hcc(),zbc));Heb(TD(mQb(a,nAc)))&&pfd(b,(sXb(),pXb),(hcc(),dcc));if(eXb(a)){dE(mQb(a,IAc))===dE(Cnd)?(d=RD(mQb(a,gAc),299)):(d=RD(mQb(a,hAc),299));f=d==(xvc(),vvc)?(hcc(),Ubc):(hcc(),gcc);pfd(b,(sXb(),qXb),f);}switch(RD(mQb(a,vCc),388).g){case 1:pfd(b,(sXb(),qXb),(hcc(),ecc));break;case 2:nfd(pfd(pfd(b,(sXb(),pXb),(hcc(),ebc)),qXb,fbc),rXb,gbc);}dE(mQb(a,cAc))!==dE((kEc(),hEc))&&pfd(b,(sXb(),pXb),(hcc(),fcc));return b} + function crc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;if(Ujb(a.a,b)){if(Zsb(RD(Wjb(a.a,b),49),c)){return 1}}else {Zjb(a.a,b,new _sb);}if(Ujb(a.a,c)){if(Zsb(RD(Wjb(a.a,c),49),b)){return -1}}else {Zjb(a.a,c,new _sb);}if(Ujb(a.e,b)){if(Zsb(RD(Wjb(a.e,b),49),c)){return -1}}else {Zjb(a.e,b,new _sb);}if(Ujb(a.e,c)){if(Zsb(RD(Wjb(a.a,c),49),b)){return 1}}else {Zjb(a.e,c,new _sb);}if(a.c==(kEc(),iEc)||!nQb(b,(Ywc(),zwc))||!nQb(c,(Ywc(),zwc))){l=null;for(j=new Anb(b.j);j.ag?erc(a,b,c):erc(a,c,b);return eg?1:0}}d=RD(mQb(b,(Ywc(),zwc)),17).a;f=RD(mQb(c,zwc),17).a;d>f?erc(a,b,c):erc(a,c,b);return df?1:0} + function uAd(b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(d==null){return null}if(b.a!=c.jk()){throw Adb(new agb(VHe+c.xe()+WHe))}if(ZD(c,469)){r=z1d(RD(c,685),d);if(!r){throw Adb(new agb(XHe+d+"' is not a valid enumerator of '"+c.xe()+"'"))}return r}switch(Oee((lke(),jke),c).Nl()){case 2:{d=nue(d,false);break}case 3:{d=nue(d,true);break}}e=Oee(jke,c).Jl();if(e){return e.jk().wi().ti(e,d)}n=Oee(jke,c).Ll();if(n){r=new bnb;for(k=xAd(d),l=0,m=k.length;l1){o=new mMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));while(o.e!=o.i.gc()){cMd(o);}}g=RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166);q=H;H>v+u?(q=v+u):Hw+p?(r=w+p):Iv-u&&qw-p&&rH+G?(B=H+G):vI+A?(C=I+A):wH-G&&BI-A&&Cc&&(m=c-1);n=N+Kwb(b,24)*Nxe*l-l/2;n<0?(n=1):n>d&&(n=d-1);e=(bvd(),i=new Xxd,i);Vxd(e,m);Wxd(e,n);WGd((!g.a&&(g.a=new XZd(D4,g,5)),g.a),e);}} + function Y7c(a){Cgd(a,new Pfd($fd(Xfd(Zfd(Yfd(new agd,$Fe),'ELK Rectangle Packing'),'Algorithm for packing of unconnected boxes, i.e. graphs without edges. The given order of the boxes is always preserved and the main reading direction of the boxes is left to right. The algorithm is divided into two phases. One phase approximates the width in which the rectangles can be placed. The next phase places the rectangles in rows using the previously calculated width as bounding width and bundles rectangles with a similar height in blocks. A compaction step reduces the size of the drawing. Finally, the rectangles are expanded to fill their bounding box and eliminate empty unused spaces.'),new _7c)));Agd(a,$Fe,Dze,1.3);Agd(a,$Fe,hAe,(Geb(),false));Agd(a,$Fe,Eze,O7c);Agd(a,$Fe,_ze,15);Agd(a,$Fe,YDe,iGd(y7c));Agd(a,$Fe,jAe,iGd(F7c));Agd(a,$Fe,CAe,iGd(H7c));Agd(a,$Fe,iAe,iGd(I7c));Agd(a,$Fe,kAe,iGd(E7c));Agd(a,$Fe,gAe,iGd(J7c));Agd(a,$Fe,lAe,iGd(P7c));Agd(a,$Fe,RFe,iGd(U7c));Agd(a,$Fe,SFe,iGd(T7c));Agd(a,$Fe,QFe,iGd(W7c));Agd(a,$Fe,PFe,iGd(V7c));Agd(a,$Fe,TFe,iGd(M7c));Agd(a,$Fe,UFe,iGd(L7c));Agd(a,$Fe,VFe,iGd(K7c));Agd(a,$Fe,WFe,iGd(S7c));Agd(a,$Fe,dAe,iGd(B7c));Agd(a,$Fe,iEe,iGd(C7c));Agd(a,$Fe,NFe,iGd(A7c));Agd(a,$Fe,MFe,iGd(z7c));Agd(a,$Fe,OFe,iGd(D7c));Agd(a,$Fe,LFe,iGd(R7c));} + function Ajb(a,b){xjb();var c,d,e,h,i,j,l,n,o,p,q,r,s,t,u,w,A,B,D,F,G,H;B=a.e;o=a.d;e=a.a;if(B==0){switch(b){case 0:return '0';case 1:return zxe;case 2:return '0.00';case 3:return '0.000';case 4:return '0.0000';case 5:return '0.00000';case 6:return '0.000000';default:w=new bib;(w.a+='0E',w);w.a+=-b;return w.a;}}t=o*10+1+7;u=$C(hE,zwe,28,t+1,15,1);c=t;if(o==1){h=e[0];if(h<0){H=Cdb(h,yxe);do{p=H;H=Fdb(H,10);u[--c]=48+Ydb(Vdb(p,Ndb(H,10)))&Bwe;}while(Ddb(H,0)!=0)}else {H=h;do{p=H;H=H/10|0;u[--c]=48+(p-H*10)&Bwe;}while(H!=0)}}else {D=$C(kE,Pwe,28,o,15,1);G=o;hib(e,0,D,0,G);I:while(true){A=0;for(j=G-1;j>=0;j--){F=Bdb(Sdb(A,32),Cdb(D[j],yxe));r=yjb(F);D[j]=Ydb(r);A=Ydb(Tdb(r,32));}s=Ydb(A);q=c;do{u[--c]=48+s%10&Bwe;}while((s=s/10|0)!=0&&c!=0);d=9-q+c;for(i=0;i0;i++){u[--c]=48;}l=G-1;for(;D[l]==0;l--){if(l==0){break I}}G=l+1;}while(u[c]==48){++c;}}n=B<0;{n&&(u[--c]=45);return Ihb(u,c,t-c)}} + function Jad(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;a.c=b;a.g=new Tsb;c=(lud(),new zud(a.c));d=new PJb(c);LJb(d);t=WD(Gxd(a.c,(ncd(),gcd)));i=RD(Gxd(a.c,icd),324);v=RD(Gxd(a.c,jcd),437);g=RD(Gxd(a.c,bcd),490);u=RD(Gxd(a.c,hcd),438);a.j=Kfb(UD(Gxd(a.c,kcd)));h=a.a;switch(i.g){case 0:h=a.a;break;case 1:h=a.b;break;case 2:h=a.i;break;case 3:h=a.e;break;case 4:h=a.f;break;default:throw Adb(new agb(eGe+(i.f!=null?i.f:''+i.g)));}a.d=new qbd(h,v,g);pQb(a.d,(OQb(),MQb),TD(Gxd(a.c,dcd)));a.d.c=Heb(TD(Gxd(a.c,ccd)));if(tCd(a.c).i==0){return a.d}for(l=new dMd(tCd(a.c));l.e!=l.i.gc();){k=RD(bMd(l),27);n=k.g/2;m=k.f/2;w=new rjd(k.i+n,k.j+m);while(Ujb(a.g,w)){Zid(w,($wnd.Math.random()-0.5)*Vze,($wnd.Math.random()-0.5)*Vze);}p=RD(Gxd(k,(umd(),eld)),140);q=new TQb(w,new Uid(w.a-n-a.j/2-p.b,w.b-m-a.j/2-p.d,k.g+a.j+(p.b+p.c),k.f+a.j+(p.d+p.a)));Rmb(a.d.i,q);Zjb(a.g,w,new Ptd(q,k));}switch(u.g){case 0:if(t==null){a.d.d=RD(Vmb(a.d.i,0),68);}else {for(s=new Anb(a.d.i);s.a0?G+1:1;}for(g=new Anb(w.g);g.a0?G+1:1;}}a.c[j]==0?Mub(a.e,p):a.a[j]==0&&Mub(a.f,p);++j;}o=-1;n=1;l=new bnb;a.d=RD(mQb(b,(Ywc(),Lwc)),234);while(L>0){while(a.e.b!=0){I=RD(Uub(a.e),10);a.b[I.p]=o--;TFc(a,I);--L;}while(a.f.b!=0){J=RD(Uub(a.f),10);a.b[J.p]=n++;TFc(a,J);--L;}if(L>0){m=qwe;for(s=new Anb(t);s.a=m){if(u>m){l.c.length=0;m=u;}ZEb(l.c,p);}}}k=a.sg(l);a.b[k.p]=n++;TFc(a,k);--L;}}H=t.c.length+1;for(j=0;ja.b[K]){X0b(d,true);pQb(b,awc,(Geb(),true));}}}}a.a=null;a.c=null;a.b=null;Xub(a.f);Xub(a.e);c.Vg();} + function usd(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;v=RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166);k=new Ejd;u=new Tsb;w=xsd(v);rtb(u.f,v,w);m=new Tsb;d=new Yub;for(o=Fl(Al(cD(WC(cJ,1),rve,20,0,[(!b.d&&(b.d=new Yie(G4,b,8,5)),b.d),(!b.e&&(b.e=new Yie(G4,b,7,4)),b.e)])));gs(o);){n=RD(hs(o),74);if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i!=1){throw Adb(new agb(tHe+(!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i))}if(n!=a){q=RD(QHd((!n.a&&(n.a=new C5d(F4,n,6,6)),n.a),0),166);Pub(d,q,d.c.b,d.c);p=RD(Wd(qtb(u.f,q)),13);if(!p){p=xsd(q);rtb(u.f,q,p);}l=c?ojd(new sjd(RD(Vmb(w,w.c.length-1),8)),RD(Vmb(p,p.c.length-1),8)):ojd(new sjd((tFb(0,w.c.length),RD(w.c[0],8))),(tFb(0,p.c.length),RD(p.c[0],8)));rtb(m.f,q,l);}}if(d.b!=0){r=RD(Vmb(w,c?w.c.length-1:0),8);for(j=1;j1&&(Pub(k,r,k.c.b,k.c),true);gvb(e);}}}r=s;}}return k} + function S_c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;c.Ug(_Ee,1);D=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new e0c),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);k=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new g0c(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);o=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new i0c(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);p=$C(Z$,NEe,40,b.gc(),0,1);for(g=0;g=0&&C=0&&!p[n]){p[n]=e;k.gd(h);--h;break}n=C-m;if(n=0&&!p[n]){p[n]=e;k.gd(h);--h;break}}}o.jd(new k0c);for(i=p.length-1;i>=0;i--){if(!p[i]&&!o.dc()){p[i]=RD(o.Xb(0),40);o.gd(0);}}for(j=0;j=0;i--){Mub(c,(tFb(i,g.c.length),RD(g.c[i],8)));}return c} + function l9c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;t=Kfb(UD(Gxd(b,(X6c(),W6c))));n=Kfb(UD(Gxd(b,U6c)));m=Kfb(UD(Gxd(b,R6c)));Bad((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));r=U8c((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),t,a.b);for(q=0;qm&&Fad((tFb(m,b.c.length),RD(b.c[m],186)),k);k=null;while(b.c.length>m&&(tFb(m,b.c.length),RD(b.c[m],186)).a.c.length==0){Ymb(b,(tFb(m,b.c.length),b.c[m]));}}if(!k){--g;continue}if(!Heb(TD(RD(Vmb(k.b,0),27).of((X7c(),D7c))))&&K8c(b,o,f,k,q,c,m,d)){p=true;continue}if(q){n=o.b;l=k.f;if(!Heb(TD(RD(Vmb(k.b,0),27).of(D7c)))&&L8c(b,o,f,k,c,m,d,e)){p=true;if(n=a.j){a.a=-1;a.c=1;return}b=ihb(a.i,a.d++);a.a=b;if(a.b==1){switch(b){case 92:d=10;if(a.d>=a.j)throw Adb(new Lqe(TId((Hde(),VIe))));a.a=ihb(a.i,a.d++);break;case 45:if((a.e&512)==512&&a.d=a.j)break;if(ihb(a.i,a.d)!=63)break;if(++a.d>=a.j)throw Adb(new Lqe(TId((Hde(),WIe))));b=ihb(a.i,a.d++);switch(b){case 58:d=13;break;case 61:d=14;break;case 33:d=15;break;case 91:d=19;break;case 62:d=18;break;case 60:if(a.d>=a.j)throw Adb(new Lqe(TId((Hde(),WIe))));b=ihb(a.i,a.d++);if(b==61){d=16;}else if(b==33){d=17;}else throw Adb(new Lqe(TId((Hde(),XIe))));break;case 35:while(a.d=a.j)throw Adb(new Lqe(TId((Hde(),VIe))));a.a=ihb(a.i,a.d++);break;default:d=0;}a.c=d;} + function oXc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;c.Ug('Process compaction',1);if(!Heb(TD(mQb(b,(h_c(),F$c))))){return}e=RD(mQb(b,H$c),88);n=Kfb(UD(mQb(b,_$c)));pXc(a,b,e);lXc(b,n/2/2);o=b.b;tvb(o,new EXc(e));for(j=Sub(o,0);j.b!=j.d.c;){i=RD(evb(j),40);if(!Heb(TD(mQb(i,(q$c(),n$c))))){d=mXc(i,e);p=lWc(i,b);l=0;m=0;if(d){q=d.e;switch(e.g){case 2:l=q.a-n-i.f.a;p.e.a-n-i.f.al&&(l=p.e.a+p.f.a+n);m=l+i.f.a;break;case 4:l=q.b-n-i.f.b;p.e.b-n-i.f.bl&&(l=p.e.b+p.f.b+n);m=l+i.f.b;}}else if(p){switch(e.g){case 2:l=p.e.a-n-i.f.a;m=l+i.f.a;break;case 1:l=p.e.a+p.f.a+n;m=l+i.f.a;break;case 4:l=p.e.b-n-i.f.b;m=l+i.f.b;break;case 3:l=p.e.b+p.f.b+n;m=l+i.f.b;}}if(dE(mQb(b,K$c))===dE((LZc(),IZc))){f=l;g=m;h=DDb(CDb(new SDb(null,new Swb(a.a,16)),new IXc(f,g)));if(h.a!=null){e==(Cmd(),ymd)||e==zmd?(i.e.a=l):(i.e.b=l);}else {e==(Cmd(),ymd)||e==Bmd?(h=DDb(CDb(NDb(new SDb(null,new Swb(a.a,16))),new WXc(f)))):(h=DDb(CDb(NDb(new SDb(null,new Swb(a.a,16))),new YXc(f))));h.a!=null&&(e==ymd||e==zmd?(i.e.a=Kfb(UD((sFb(h.a!=null),RD(h.a,42)).a))):(i.e.b=Kfb(UD((sFb(h.a!=null),RD(h.a,42)).a))));}if(h.a!=null){k=Wmb(a.a,(sFb(h.a!=null),h.a),0);if(k>0&&k!=RD(mQb(i,f_c),17).a){pQb(i,UZc,(Geb(),true));pQb(i,f_c,sgb(k));}}}else {e==(Cmd(),ymd)||e==zmd?(i.e.a=l):(i.e.b=l);}}}c.Vg();} + function Fre(a){var b,c,d,e,f,g,h,i,j;a.b=1;Mqe(a);b=null;if(a.c==0&&a.a==94){Mqe(a);b=(Vse(),Vse(),new xte(4));rte(b,0,MLe);h=(new xte(4));}else {h=(Vse(),Vse(),new xte(4));}e=true;while((j=a.c)!=1){if(j==0&&a.a==93&&!e){if(b){wte(b,h);h=b;}break}c=a.a;d=false;if(j==10){switch(c){case 100:case 68:case 119:case 87:case 115:case 83:ute(h,Ere(c));d=true;break;case 105:case 73:case 99:case 67:c=(ute(h,Ere(c)),-1);c<0&&(d=true);break;case 112:case 80:i=Sqe(a,c);if(!i)throw Adb(new Lqe(TId((Hde(),hJe))));ute(h,i);d=true;break;default:c=Dre(a);}}else if(j==24&&!e){if(b){wte(b,h);h=b;}f=Fre(a);wte(h,f);if(a.c!=0||a.a!=93)throw Adb(new Lqe(TId((Hde(),lJe))));break}Mqe(a);if(!d){if(j==0){if(c==91)throw Adb(new Lqe(TId((Hde(),mJe))));if(c==93)throw Adb(new Lqe(TId((Hde(),nJe))));if(c==45&&!e&&a.a!=93)throw Adb(new Lqe(TId((Hde(),oJe))))}if(a.c!=0||a.a!=45||c==45&&e){rte(h,c,c);}else {Mqe(a);if((j=a.c)==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(j==0&&a.a==93){rte(h,c,c);rte(h,45,45);}else if(j==0&&a.a==93||j==24){throw Adb(new Lqe(TId((Hde(),oJe))))}else {g=a.a;if(j==0){if(g==91)throw Adb(new Lqe(TId((Hde(),mJe))));if(g==93)throw Adb(new Lqe(TId((Hde(),nJe))));if(g==45)throw Adb(new Lqe(TId((Hde(),oJe))))}else j==10&&(g=Dre(a));Mqe(a);if(c>g)throw Adb(new Lqe(TId((Hde(),rJe))));rte(h,c,g);}}}e=false;}if(a.c==1)throw Adb(new Lqe(TId((Hde(),jJe))));vte(h);ste(h);a.b=0;Mqe(a);return h} + function EGc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;c.Ug('Coffman-Graham Layering',1);if(b.a.c.length==0){c.Vg();return}v=RD(mQb(b,(yCc(),SAc)),17).a;i=0;g=0;for(m=new Anb(b.a);m.a=v||!zGc(r,d))&&(d=BGc(b,k));g3b(r,d);for(f=new is(Mr(Z2b(r).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(a.a[e.p]){continue}p=e.c.i;--a.e[p.p];a.e[p.p]==0&&(zFb(lwb(n,p),Bxe),true);}}for(j=k.c.length-1;j>=0;--j){Rmb(b.b,(tFb(j,k.c.length),RD(k.c[j],30)));}b.a.c.length=0;c.Vg();} + function Sec(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;u=false;do{u=false;for(f=b?(new Xkb(a.a.b)).a.gc()-2:1;b?f>=0:f<(new Xkb(a.a.b)).a.gc();f+=b?-1:1){e=_5b(a.a,sgb(f));for(n=0;nRD(mQb(q,zwc),17).a)&&(t=false);}if(!t){continue}i=b?f+1:f-1;h=_5b(a.a,sgb(i));g=false;s=true;d=false;for(k=Sub(h,0);k.b!=k.d.c;){j=RD(evb(k),10);if(nQb(j,zwc)){if(j.p!=l.p){g=g|(b?RD(mQb(j,zwc),17).aRD(mQb(l,zwc),17).a);s=false;}}else if(!g&&s){if(j.k==(r3b(),n3b)){d=true;b?(m=RD(hs(new is(Mr(Z2b(j).a.Kc(),new ir))),18).c.i):(m=RD(hs(new is(Mr(a3b(j).a.Kc(),new ir))),18).d.i);if(m==l){b?(c=RD(hs(new is(Mr(a3b(j).a.Kc(),new ir))),18).d.i):(c=RD(hs(new is(Mr(Z2b(j).a.Kc(),new ir))),18).c.i);(b?RD($5b(a.a,c),17).a-RD($5b(a.a,m),17).a:RD($5b(a.a,m),17).a-RD($5b(a.a,c),17).a)<=2&&(s=false);}}}}if(d&&s){b?(c=RD(hs(new is(Mr(a3b(l).a.Kc(),new ir))),18).d.i):(c=RD(hs(new is(Mr(Z2b(l).a.Kc(),new ir))),18).c.i);(b?RD($5b(a.a,c),17).a-RD($5b(a.a,l),17).a:RD($5b(a.a,l),17).a-RD($5b(a.a,c),17).a)<=2&&c.k==(r3b(),p3b)&&(s=false);}if(g||s){p=Xec(a,l,b);while(p.a.gc()!=0){o=RD(p.a.ec().Kc().Pb(),10);p.a.Bc(o)!=null;ye(p,Xec(a,o,b));}--n;u=true;}}}}while(u)} + function Xae(a){_Ad(a.c,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#decimal']));_Ad(a.d,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#integer']));_Ad(a.e,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#boolean']));_Ad(a.f,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EBoolean',GIe,'EBoolean:Object']));_Ad(a.i,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#byte']));_Ad(a.g,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#hexBinary']));_Ad(a.j,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EByte',GIe,'EByte:Object']));_Ad(a.n,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EChar',GIe,'EChar:Object']));_Ad(a.t,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#double']));_Ad(a.u,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EDouble',GIe,'EDouble:Object']));_Ad(a.F,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#float']));_Ad(a.G,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EFloat',GIe,'EFloat:Object']));_Ad(a.I,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#int']));_Ad(a.J,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EInt',GIe,'EInt:Object']));_Ad(a.N,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#long']));_Ad(a.O,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'ELong',GIe,'ELong:Object']));_Ad(a.Z,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#short']));_Ad(a.$,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EShort',GIe,'EShort:Object']));_Ad(a._,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#string']));} + function C0c(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o;m=RD(d.a,17).a;n=RD(d.b,17).a;l=a.b;o=a.c;h=0;k=0;if(b==(Cmd(),ymd)||b==zmd){k=Uvb(QCb(HDb(GDb(new SDb(null,new Swb(c.b,16)),new b2c),new b1c)));if(l.e.b+l.f.b/2>k){j=++n;h=Kfb(UD(Lvb(JDb(GDb(new SDb(null,new Swb(c.b,16)),new d2c(e,j)),new d1c))));}else {i=++m;h=Kfb(UD(Lvb(KDb(GDb(new SDb(null,new Swb(c.b,16)),new f2c(e,i)),new h1c))));}}else {k=Uvb(QCb(HDb(GDb(new SDb(null,new Swb(c.b,16)),new x1c),new l1c)));if(l.e.a+l.f.a/2>k){j=++n;h=Kfb(UD(Lvb(JDb(GDb(new SDb(null,new Swb(c.b,16)),new z1c(e,j)),new n1c))));}else {i=++m;h=Kfb(UD(Lvb(KDb(GDb(new SDb(null,new Swb(c.b,16)),new B1c(e,i)),new r1c))));}}if(b==ymd){Oub(a.a,new rjd(Kfb(UD(mQb(l,(q$c(),f$c))))-e,h));Oub(a.a,new rjd(o.e.a+o.f.a+e+f,h));Oub(a.a,new rjd(o.e.a+o.f.a+e+f,o.e.b+o.f.b/2));Oub(a.a,new rjd(o.e.a+o.f.a,o.e.b+o.f.b/2));}else if(b==zmd){Oub(a.a,new rjd(Kfb(UD(mQb(l,(q$c(),e$c))))+e,l.e.b+l.f.b/2));Oub(a.a,new rjd(l.e.a+l.f.a+e,h));Oub(a.a,new rjd(o.e.a-e-f,h));Oub(a.a,new rjd(o.e.a-e-f,o.e.b+o.f.b/2));Oub(a.a,new rjd(o.e.a,o.e.b+o.f.b/2));}else if(b==Bmd){Oub(a.a,new rjd(h,Kfb(UD(mQb(l,(q$c(),f$c))))-e));Oub(a.a,new rjd(h,o.e.b+o.f.b+e+f));Oub(a.a,new rjd(o.e.a+o.f.a/2,o.e.b+o.f.b+e+f));Oub(a.a,new rjd(o.e.a+o.f.a/2,o.e.b+o.f.b+e));}else {a.a.b==0||(RD(Rub(a.a),8).b=Kfb(UD(mQb(l,(q$c(),e$c))))+e*RD(g.b,17).a);Oub(a.a,new rjd(h,Kfb(UD(mQb(l,(q$c(),e$c))))+e*RD(g.b,17).a));Oub(a.a,new rjd(h,o.e.b-e*RD(g.a,17).a-f));}return new Ptd(sgb(m),sgb(n))} + function ASd(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;g=true;l=null;d=null;e=null;b=false;n=_Rd;j=null;f=null;h=0;i=sSd(a,h,ZRd,$Rd);if(i=0&&lhb(a.substr(h,'//'.length),'//')){h+=2;i=sSd(a,h,aSd,bSd);d=(AFb(h,i,a.length),a.substr(h,i-h));h=i;}else if(l!=null&&(h==a.length||(BFb(h,a.length),a.charCodeAt(h)!=47))){g=false;i=rhb(a,Fhb(35),h);i==-1&&(i=a.length);d=(AFb(h,i,a.length),a.substr(h,i-h));h=i;}if(!c&&h0&&ihb(k,k.length-1)==58){e=k;h=i;}}if(hqQc(f))&&(l=f);}}!l&&(l=(tFb(0,q.c.length),RD(q.c[0],185)));for(p=new Anb(b.b);p.al){F=0;G+=k+A;k=0;}FVc(v,g,F,G);b=$wnd.Math.max(b,F+w.a);k=$wnd.Math.max(k,w.b);F+=w.a+A;}u=new Tsb;c=new Tsb;for(C=new Anb(a);C.a=-1900?1:0;c>=4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Qwe,Rwe])[h]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['BC','AD'])[h]);break;case 121:AA(a,c,d);break;case 77:zA(a,c,d);break;case 107:i=e.q.getHours();i==0?UA(a,24,c):UA(a,i,c);break;case 83:yA(a,c,e);break;case 69:k=d.q.getDay();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['S','M','T','W','T','F','S'])[k]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Swe,Twe,Uwe,Vwe,Wwe,Xwe,Ywe])[k]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[k]);break;case 97:e.q.getHours()>=12&&e.q.getHours()<24?Zhb(a,cD(WC(qJ,1),Nve,2,6,['AM','PM'])[1]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['AM','PM'])[0]);break;case 104:l=e.q.getHours()%12;l==0?UA(a,12,c):UA(a,l,c);break;case 75:m=e.q.getHours()%12;UA(a,m,c);break;case 72:n=e.q.getHours();UA(a,n,c);break;case 99:o=d.q.getDay();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['S','M','T','W','T','F','S'])[o]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Swe,Twe,Uwe,Vwe,Wwe,Xwe,Ywe])[o]):c==3?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[o]):UA(a,o,1);break;case 76:p=d.q.getMonth();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['J','F','M','A','M','J','J','A','S','O','N','D'])[p]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe])[p]):c==3?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec'])[p]):UA(a,p+1,c);break;case 81:q=d.q.getMonth()/3|0;c<4?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Q1','Q2','Q3','Q4'])[q]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['1st quarter','2nd quarter','3rd quarter','4th quarter'])[q]);break;case 100:r=d.q.getDate();UA(a,r,c);break;case 109:j=e.q.getMinutes();UA(a,j,c);break;case 115:g=e.q.getSeconds();UA(a,g,c);break;case 122:c<4?Zhb(a,f.c[0]):Zhb(a,f.c[1]);break;case 118:Zhb(a,f.b);break;case 90:c<3?Zhb(a,cB(f)):c==3?Zhb(a,bB(f)):Zhb(a,eB(f.a));break;default:return false;}return true} + function f5b(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H;X4b(b);i=RD(QHd((!b.b&&(b.b=new Yie(E4,b,4,7)),b.b),0),84);k=RD(QHd((!b.c&&(b.c=new Yie(E4,b,5,8)),b.c),0),84);h=AGd(i);j=AGd(k);g=(!b.a&&(b.a=new C5d(F4,b,6,6)),b.a).i==0?null:RD(QHd((!b.a&&(b.a=new C5d(F4,b,6,6)),b.a),0),166);A=RD(Wjb(a.a,h),10);F=RD(Wjb(a.a,j),10);B=null;G=null;if(ZD(i,193)){w=RD(Wjb(a.a,i),305);if(ZD(w,12)){B=RD(w,12);}else if(ZD(w,10)){A=RD(w,10);B=RD(Vmb(A.j,0),12);}}if(ZD(k,193)){D=RD(Wjb(a.a,k),305);if(ZD(D,12)){G=RD(D,12);}else if(ZD(D,10)){F=RD(D,10);G=RD(Vmb(F.j,0),12);}}if(!A||!F){throw Adb(new Ked('The source or the target of edge '+b+' could not be found. '+'This usually happens when an edge connects a node laid out by ELK Layered to a node in '+'another level of hierarchy laid out by either another instance of ELK Layered or another '+'layout algorithm alltogether. The former can be solved by setting the hierarchyHandling '+'option to INCLUDE_CHILDREN.'))}p=new a1b;kQb(p,b);pQb(p,(Ywc(),Awc),b);pQb(p,(yCc(),RAc),null);n=RD(mQb(d,kwc),21);A==F&&n.Fc((ovc(),nvc));if(!B){v=(BEc(),zEc);C=null;if(!!g&&Dod(RD(mQb(A,BBc),101))){C=new rjd(g.j,g.k);Fsd(C,kzd(b));Gsd(C,c);if(NGd(j,h)){v=yEc;$id(C,A.n);}}B=g2b(A,C,v,d);}if(!G){v=(BEc(),yEc);H=null;if(!!g&&Dod(RD(mQb(F,BBc),101))){H=new rjd(g.b,g.c);Fsd(H,kzd(b));Gsd(H,c);}G=g2b(F,H,v,Y2b(F));}Y0b(p,B);Z0b(p,G);(B.e.c.length>1||B.g.c.length>1||G.e.c.length>1||G.g.c.length>1)&&n.Fc((ovc(),ivc));for(m=new dMd((!b.n&&(b.n=new C5d(I4,b,1,7)),b.n));m.e!=m.i.gc();){l=RD(bMd(m),135);if(!Heb(TD(Gxd(l,pBc)))&&!!l.a){q=h5b(l);Rmb(p.b,q);switch(RD(mQb(q,wAc),278).g){case 1:case 2:n.Fc((ovc(),gvc));break;case 0:n.Fc((ovc(),evc));pQb(q,wAc,(Omd(),Lmd));}}}f=RD(mQb(d,oAc),322);r=RD(mQb(d,kBc),323);e=f==(stc(),ptc)||r==(JDc(),FDc);if(!!g&&(!g.a&&(g.a=new XZd(D4,g,5)),g.a).i!=0&&e){s=ssd(g);o=new Ejd;for(u=Sub(s,0);u.b!=u.d.c;){t=RD(evb(u),8);Mub(o,new sjd(t));}pQb(p,Bwc,o);}return p} + function F0c(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;C=0;D=0;A=new Tsb;v=RD(Lvb(JDb(GDb(new SDb(null,new Swb(a.b,16)),new v1c),new Z0c)),17).a+1;B=$C(kE,Pwe,28,v,15,1);q=$C(kE,Pwe,28,v,15,1);for(p=0;p1){for(h=G+1;hj.b.e.b*(1-r)+j.c.e.b*r){break}}if(w.gc()>0){H=j.a.b==0?ajd(j.b.e):RD(Rub(j.a),8);t=$id(ajd(RD(w.Xb(w.gc()-1),40).e),RD(w.Xb(w.gc()-1),40).f);m=$id(ajd(RD(w.Xb(0),40).e),RD(w.Xb(0),40).f);if(o>=w.gc()-1&&H.b>t.b&&j.c.e.b>t.b){continue}if(o<=0&&H.bj.b.e.a*(1-r)+j.c.e.a*r){break}}if(w.gc()>0){H=j.a.b==0?ajd(j.b.e):RD(Rub(j.a),8);t=$id(ajd(RD(w.Xb(w.gc()-1),40).e),RD(w.Xb(w.gc()-1),40).f);m=$id(ajd(RD(w.Xb(0),40).e),RD(w.Xb(0),40).f);if(o>=w.gc()-1&&H.a>t.a&&j.c.e.a>t.a){continue}if(o<=0&&H.a=Kfb(UD(mQb(a,(q$c(),$Zc))))&&++D;}else {n.f&&n.d.e.a<=Kfb(UD(mQb(a,(q$c(),ZZc))))&&++C;n.g&&n.c.e.a+n.c.f.a>=Kfb(UD(mQb(a,(q$c(),YZc))))&&++D;}}}else if(u==0){H0c(j);}else if(u<0){++B[G];++q[I];F=C0c(j,b,a,new Ptd(sgb(C),sgb(D)),c,d,new Ptd(sgb(q[I]),sgb(B[G])));C=RD(F.a,17).a;D=RD(F.b,17).a;}}} + function qrc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;d=b;i=c;if(a.b&&d.j==(qpd(),ppd)&&i.j==(qpd(),ppd)){s=d;d=i;i=s;}if(Ujb(a.a,d)){if(Zsb(RD(Wjb(a.a,d),49),i)){return 1}}else {Zjb(a.a,d,new _sb);}if(Ujb(a.a,i)){if(Zsb(RD(Wjb(a.a,i),49),d)){return -1}}else {Zjb(a.a,i,new _sb);}if(Ujb(a.d,d)){if(Zsb(RD(Wjb(a.d,d),49),i)){return -1}}else {Zjb(a.d,d,new _sb);}if(Ujb(a.d,i)){if(Zsb(RD(Wjb(a.a,i),49),d)){return 1}}else {Zjb(a.d,i,new _sb);}if(d.j!=i.j){r=yrc(d.j,i.j);r==-1?rrc(a,i,d):rrc(a,d,i);return r}if(d.e.c.length!=0&&i.e.c.length!=0){if(a.b){r=orc(d,i);if(r!=0){r==-1?rrc(a,i,d):r==1&&rrc(a,d,i);return r}}f=RD(Vmb(d.e,0),18).c.i;k=RD(Vmb(i.e,0),18).c.i;if(f==k){e=RD(mQb(RD(Vmb(d.e,0),18),(Ywc(),zwc)),17).a;j=RD(mQb(RD(Vmb(i.e,0),18),zwc),17).a;e>j?rrc(a,d,i):rrc(a,i,d);return ej?1:0}for(o=a.c,p=0,q=o.length;pj?rrc(a,d,i):rrc(a,i,d);return ej?1:0}if(a.b){r=orc(d,i);if(r!=0){r==-1?rrc(a,i,d):r==1&&rrc(a,d,i);return r}}g=0;l=0;nQb(RD(Vmb(d.g,0),18),zwc)&&(g=RD(mQb(RD(Vmb(d.g,0),18),zwc),17).a);nQb(RD(Vmb(i.g,0),18),zwc)&&(l=RD(mQb(RD(Vmb(d.g,0),18),zwc),17).a);if(!!h&&h==m){if(Heb(TD(mQb(RD(Vmb(d.g,0),18),Nwc)))&&!Heb(TD(mQb(RD(Vmb(i.g,0),18),Nwc)))){rrc(a,d,i);return 1}else if(!Heb(TD(mQb(RD(Vmb(d.g,0),18),Nwc)))&&Heb(TD(mQb(RD(Vmb(i.g,0),18),Nwc)))){rrc(a,i,d);return -1}g>l?rrc(a,d,i):rrc(a,i,d);return gl?1:0}if(a.f){a.f._b(h)&&(g=RD(a.f.xc(h),17).a);a.f._b(m)&&(l=RD(a.f.xc(m),17).a);}g>l?rrc(a,d,i):rrc(a,i,d);return gl?1:0}if(d.e.c.length!=0&&i.g.c.length!=0){rrc(a,d,i);return 1}else if(d.g.c.length!=0&&i.e.c.length!=0){rrc(a,i,d);return -1}else if(nQb(d,(Ywc(),zwc))&&nQb(i,zwc)){e=RD(mQb(d,zwc),17).a;j=RD(mQb(i,zwc),17).a;e>j?rrc(a,d,i):rrc(a,i,d);return ej?1:0}else {rrc(a,i,d);return -1}} + function Yae(a){if(a.gb)return;a.gb=true;a.b=jBd(a,0);iBd(a.b,18);oBd(a.b,19);a.a=jBd(a,1);iBd(a.a,1);oBd(a.a,2);oBd(a.a,3);oBd(a.a,4);oBd(a.a,5);a.o=jBd(a,2);iBd(a.o,8);iBd(a.o,9);oBd(a.o,10);oBd(a.o,11);oBd(a.o,12);oBd(a.o,13);oBd(a.o,14);oBd(a.o,15);oBd(a.o,16);oBd(a.o,17);oBd(a.o,18);oBd(a.o,19);oBd(a.o,20);oBd(a.o,21);oBd(a.o,22);oBd(a.o,23);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);a.p=jBd(a,3);iBd(a.p,2);iBd(a.p,3);iBd(a.p,4);iBd(a.p,5);oBd(a.p,6);oBd(a.p,7);nBd(a.p);nBd(a.p);a.q=jBd(a,4);iBd(a.q,8);a.v=jBd(a,5);oBd(a.v,9);nBd(a.v);nBd(a.v);nBd(a.v);a.w=jBd(a,6);iBd(a.w,2);iBd(a.w,3);iBd(a.w,4);oBd(a.w,5);a.B=jBd(a,7);oBd(a.B,1);nBd(a.B);nBd(a.B);nBd(a.B);a.Q=jBd(a,8);oBd(a.Q,0);nBd(a.Q);a.R=jBd(a,9);iBd(a.R,1);a.S=jBd(a,10);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);a.T=jBd(a,11);oBd(a.T,10);oBd(a.T,11);oBd(a.T,12);oBd(a.T,13);oBd(a.T,14);nBd(a.T);nBd(a.T);a.U=jBd(a,12);iBd(a.U,2);iBd(a.U,3);oBd(a.U,4);oBd(a.U,5);oBd(a.U,6);oBd(a.U,7);nBd(a.U);a.V=jBd(a,13);oBd(a.V,10);a.W=jBd(a,14);iBd(a.W,18);iBd(a.W,19);iBd(a.W,20);oBd(a.W,21);oBd(a.W,22);oBd(a.W,23);a.bb=jBd(a,15);iBd(a.bb,10);iBd(a.bb,11);iBd(a.bb,12);iBd(a.bb,13);iBd(a.bb,14);iBd(a.bb,15);iBd(a.bb,16);oBd(a.bb,17);nBd(a.bb);nBd(a.bb);a.eb=jBd(a,16);iBd(a.eb,2);iBd(a.eb,3);iBd(a.eb,4);iBd(a.eb,5);iBd(a.eb,6);iBd(a.eb,7);oBd(a.eb,8);oBd(a.eb,9);a.ab=jBd(a,17);iBd(a.ab,0);iBd(a.ab,1);a.H=jBd(a,18);oBd(a.H,0);oBd(a.H,1);oBd(a.H,2);oBd(a.H,3);oBd(a.H,4);oBd(a.H,5);nBd(a.H);a.db=jBd(a,19);oBd(a.db,2);a.c=kBd(a,20);a.d=kBd(a,21);a.e=kBd(a,22);a.f=kBd(a,23);a.i=kBd(a,24);a.g=kBd(a,25);a.j=kBd(a,26);a.k=kBd(a,27);a.n=kBd(a,28);a.r=kBd(a,29);a.s=kBd(a,30);a.t=kBd(a,31);a.u=kBd(a,32);a.fb=kBd(a,33);a.A=kBd(a,34);a.C=kBd(a,35);a.D=kBd(a,36);a.F=kBd(a,37);a.G=kBd(a,38);a.I=kBd(a,39);a.J=kBd(a,40);a.L=kBd(a,41);a.M=kBd(a,42);a.N=kBd(a,43);a.O=kBd(a,44);a.P=kBd(a,45);a.X=kBd(a,46);a.Y=kBd(a,47);a.Z=kBd(a,48);a.$=kBd(a,49);a._=kBd(a,50);a.cb=kBd(a,51);a.K=kBd(a,52);} + function d5b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G;g=new Yub;w=RD(mQb(c,(yCc(),rAc)),88);p=0;ye(g,(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));while(g.b!=0){k=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),27);j=vCd(k);(dE(Gxd(j,cAc))!==dE((kEc(),hEc))||dE(Gxd(j,pAc))===dE((Ptc(),Otc))||dE(Gxd(j,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(j,eAc)))||dE(Gxd(j,Yzc))!==dE((U$b(),T$b))||dE(Gxd(j,ZAc))===dE((aEc(),TDc))||dE(Gxd(j,ZAc))===dE((aEc(),UDc))||dE(Gxd(j,$Ac))===dE((_Cc(),SCc))||dE(Gxd(j,$Ac))===dE((_Cc(),UCc)))&&!Heb(TD(Gxd(k,aAc)))&&Ixd(k,(Ywc(),zwc),sgb(p++));r=!Heb(TD(Gxd(k,pBc)));if(r){m=(!k.a&&(k.a=new C5d(J4,k,10,11)),k.a).i!=0;o=a5b(k);n=dE(Gxd(k,IAc))===dE((Fnd(),Cnd));G=!Hxd(k,(umd(),Akd))||khb(WD(Gxd(k,Akd)));u=null;if(G&&n&&(m||o)){u=Z4b(k);pQb(u,rAc,w);nQb(u,PBc)&&HCc(new RCc(Kfb(UD(mQb(u,PBc)))),u);if(RD(Gxd(k,lBc),181).gc()!=0){l=u;FDb(new SDb(null,(!k.c&&(k.c=new C5d(K4,k,9,9)),new Swb(k.c,16))),new u5b(l));V4b(k,u);}}A=c;B=RD(Wjb(a.a,vCd(k)),10);!!B&&(A=B.e);t=i5b(a,k,A);if(u){t.e=u;u.e=t;ye(g,(!k.a&&(k.a=new C5d(J4,k,10,11)),k.a));}}}p=0;Pub(g,b,g.c.b,g.c);while(g.b!=0){f=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),27);for(i=new dMd((!f.b&&(f.b=new C5d(G4,f,12,3)),f.b));i.e!=i.i.gc();){h=RD(bMd(i),74);X4b(h);(dE(Gxd(b,cAc))!==dE((kEc(),hEc))||dE(Gxd(b,pAc))===dE((Ptc(),Otc))||dE(Gxd(b,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(b,eAc)))||dE(Gxd(b,Yzc))!==dE((U$b(),T$b))||dE(Gxd(b,ZAc))===dE((aEc(),TDc))||dE(Gxd(b,ZAc))===dE((aEc(),UDc))||dE(Gxd(b,$Ac))===dE((_Cc(),SCc))||dE(Gxd(b,$Ac))===dE((_Cc(),UCc)))&&Ixd(h,(Ywc(),zwc),sgb(p++));D=AGd(RD(QHd((!h.b&&(h.b=new Yie(E4,h,4,7)),h.b),0),84));F=AGd(RD(QHd((!h.c&&(h.c=new Yie(E4,h,5,8)),h.c),0),84));if(Heb(TD(Gxd(h,pBc)))||Heb(TD(Gxd(D,pBc)))||Heb(TD(Gxd(F,pBc)))){continue}q=ozd(h)&&Heb(TD(Gxd(D,NAc)))&&Heb(TD(Gxd(h,OAc)));v=f;q||NGd(F,D)?(v=D):NGd(D,F)&&(v=F);A=c;B=RD(Wjb(a.a,v),10);!!B&&(A=B.e);s=f5b(a,h,v,A);pQb(s,(Ywc(),Zvc),_4b(a,h,b,c));}n=dE(Gxd(f,IAc))===dE((Fnd(),Cnd));if(n){for(e=new dMd((!f.a&&(f.a=new C5d(J4,f,10,11)),f.a));e.e!=e.i.gc();){d=RD(bMd(e),27);G=!Hxd(d,(umd(),Akd))||khb(WD(Gxd(d,Akd)));C=dE(Gxd(d,IAc))===dE(Cnd);G&&C&&(Pub(g,d,g.c.b,g.c),true);}}}} + function Ywc(){Ywc=geb;var a,b;Awc=new jGd(rAe);Zvc=new jGd('coordinateOrigin');Kwc=new jGd('processors');Yvc=new kGd('compoundNode',(Geb(),false));nwc=new kGd('insideConnections',false);Bwc=new jGd('originalBendpoints');Cwc=new jGd('originalDummyNodePosition');Dwc=new jGd('originalLabelEdge');Mwc=new jGd('representedLabels');cwc=new jGd('endLabels');dwc=new jGd('endLabel.origin');swc=new kGd('labelSide',(Pnd(),Ond));ywc=new kGd('maxEdgeThickness',0);Nwc=new kGd('reversed',false);Lwc=new jGd(sAe);vwc=new kGd('longEdgeSource',null);wwc=new kGd('longEdgeTarget',null);uwc=new kGd('longEdgeHasLabelDummies',false);twc=new kGd('longEdgeBeforeLabelDummy',false);bwc=new kGd('edgeConstraint',(huc(),fuc));pwc=new jGd('inLayerLayoutUnit');owc=new kGd('inLayerConstraint',(Gvc(),Evc));qwc=new kGd('inLayerSuccessorConstraint',new bnb);rwc=new kGd('inLayerSuccessorConstraintBetweenNonDummies',false);Iwc=new jGd('portDummy');$vc=new kGd('crossingHint',sgb(0));kwc=new kGd('graphProperties',(b=RD(mfb(iX),9),new Fsb(b,RD(WEb(b,b.length),9),0)));hwc=new kGd('externalPortSide',(qpd(),opd));iwc=new kGd('externalPortSize',new pjd);fwc=new jGd('externalPortReplacedDummies');gwc=new jGd('externalPortReplacedDummy');ewc=new kGd('externalPortConnections',(a=RD(mfb(E3),9),new Fsb(a,RD(WEb(a,a.length),9),0)));Jwc=new kGd(Xye,0);Uvc=new jGd('barycenterAssociates');Xwc=new jGd('TopSideComments');Vvc=new jGd('BottomSideComments');Xvc=new jGd('CommentConnectionPort');mwc=new kGd('inputCollect',false);Gwc=new kGd('outputCollect',false);awc=new kGd('cyclic',false);_vc=new jGd('crossHierarchyMap');Wwc=new jGd('targetOffset');new kGd('splineLabelSize',new pjd);Qwc=new jGd('spacings');Hwc=new kGd('partitionConstraint',false);Wvc=new jGd('breakingPoint.info');Uwc=new jGd('splines.survivingEdge');Twc=new jGd('splines.route.start');Rwc=new jGd('splines.edgeChain');Fwc=new jGd('originalPortConstraints');Pwc=new jGd('selfLoopHolder');Swc=new jGd('splines.nsPortY');zwc=new jGd('modelOrder');xwc=new jGd('longEdgeTargetNode');jwc=new kGd(GBe,false);Owc=new kGd(GBe,false);lwc=new jGd('layerConstraints.hiddenNodes');Ewc=new jGd('layerConstraints.opposidePort');Vwc=new jGd('targetNode.modelOrder');} + function D0c(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o;for(l=Sub(a.b,0);l.b!=l.d.c;){k=RD(evb(l),40);if(lhb(k.c,IEe)){continue}f=RD(zDb(new SDb(null,new Swb(hWc(k,a),16)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);b==(Cmd(),ymd)||b==zmd?f.jd(new L1c):f.jd(new R1c);o=f.gc();for(e=0;e0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(i-n)/($wnd.Math.abs(h-m)/40)>50&&(n>i?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a+d/5.3,k.e.b+k.f.b*g-d/2)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a+d/5.3,k.e.b+k.f.b*g+d/2)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a,k.e.b+k.f.b*g));}else if(b==zmd){j=Kfb(UD(mQb(k,(q$c(),f$c))));if(k.e.a-d>j){Oub(RD(f.Xb(e),65).a,new rjd(j-c,k.e.b+k.f.b*g));}else if(RD(f.Xb(e),65).a.b>0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(i-n)/($wnd.Math.abs(h-m)/40)>50&&(n>i?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a-d/5.3,k.e.b+k.f.b*g-d/2)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a-d/5.3,k.e.b+k.f.b*g+d/2)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a,k.e.b+k.f.b*g));}else if(b==Bmd){j=Kfb(UD(mQb(k,(q$c(),e$c))));if(k.e.b+k.f.b+d0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(h-m)/($wnd.Math.abs(i-n)/40)>50&&(m>h?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g-d/2,k.e.b+d/5.3+k.f.b)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g+d/2,k.e.b+d/5.3+k.f.b)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,k.e.b+k.f.b));}else {j=Kfb(UD(mQb(k,(q$c(),f$c))));if(mWc(RD(f.Xb(e),65),a)){Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,RD(Rub(RD(f.Xb(e),65).a),8).b));}else if(k.e.b-d>j){Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,j-c));}else if(RD(f.Xb(e),65).a.b>0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(h-m)/($wnd.Math.abs(i-n)/40)>50&&(m>h?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g-d/2,k.e.b-d/5.3)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g+d/2,k.e.b-d/5.3)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,k.e.b));}}}} + function umd(){umd=geb;var a,b;Akd=new jGd(OGe);Tld=new jGd(PGe);Ckd=(Rjd(),Ljd);Bkd=new lGd(MDe,Ckd);Dkd=new lGd(Dze,null);Ekd=new jGd(QGe);Lkd=(ukd(),ysb(tkd,cD(WC(q3,1),jwe,298,0,[pkd])));Kkd=new lGd(YDe,Lkd);Mkd=new lGd(LDe,(Geb(),false));Okd=(Cmd(),Amd);Nkd=new lGd(PDe,Okd);Tkd=(Ymd(),Xmd);Skd=new lGd(kDe,Tkd);Wkd=new lGd(MGe,false);Ykd=(Fnd(),Dnd);Xkd=new lGd(fDe,Ykd);uld=new A3b(12);tld=new lGd(Eze,uld);ald=new lGd(dAe,false);bld=new lGd(iEe,false);sld=new lGd(gAe,false);Ild=(Bod(),Aod);Hld=new lGd(eAe,Ild);Qld=new jGd(fEe);Rld=new jGd($ze);Sld=new jGd(bAe);Vld=new jGd(cAe);dld=new Ejd;cld=new lGd(ZDe,dld);Jkd=new lGd(aEe,false);Zkd=new lGd(bEe,false);fld=new P2b;eld=new lGd(gEe,fld);rld=new lGd(JDe,false);Uld=new lGd(SGe,1);Ikd=new jGd(TGe);Hkd=new jGd(UGe);mmd=new lGd(mAe,false);new lGd(VGe,true);sgb(0);new lGd(WGe,sgb(100));new lGd(XGe,false);sgb(0);new lGd(YGe,sgb(4000));sgb(0);new lGd(ZGe,sgb(400));new lGd($Ge,false);new lGd(_Ge,false);new lGd(aHe,true);new lGd(bHe,false);Gkd=(Grd(),Frd);Fkd=new lGd(NGe,Gkd);Wld=new lGd(xDe,10);Xld=new lGd(yDe,10);Yld=new lGd(Bze,20);Zld=new lGd(zDe,10);$ld=new lGd(aAe,2);_ld=new lGd(ADe,10);bmd=new lGd(BDe,0);cmd=new lGd(EDe,5);dmd=new lGd(CDe,1);emd=new lGd(DDe,1);fmd=new lGd(_ze,20);gmd=new lGd(FDe,10);jmd=new lGd(GDe,10);amd=new jGd(HDe);imd=new Q2b;hmd=new lGd(hEe,imd);xld=new jGd(eEe);wld=false;vld=new lGd(dEe,wld);hld=new A3b(5);gld=new lGd(QDe,hld);jld=(dod(),b=RD(mfb(A3),9),new Fsb(b,RD(WEb(b,b.length),9),0));ild=new lGd(kAe,jld);Ald=(pod(),mod);zld=new lGd(TDe,Ald);Cld=new jGd(UDe);Dld=new jGd(VDe);Eld=new jGd(WDe);Bld=new jGd(XDe);lld=(a=RD(mfb(H3),9),new Fsb(a,RD(WEb(a,a.length),9),0));kld=new lGd(jAe,lld);qld=xsb((dqd(),Ypd));pld=new lGd(iAe,qld);old=new rjd(0,0);nld=new lGd(CAe,old);mld=new lGd(hAe,false);Rkd=(Omd(),Lmd);Qkd=new lGd($De,Rkd);Pkd=new lGd(fAe,false);sgb(1);new lGd(dHe,null);Fld=new jGd(cEe);Jld=new jGd(_De);Pld=(qpd(),opd);Old=new lGd(KDe,Pld);Gld=new jGd(IDe);Mld=(Pod(),xsb(Nod));Lld=new lGd(lAe,Mld);Kld=new lGd(RDe,false);Nld=new lGd(SDe,true);qmd=new lGd(nAe,1);smd=new lGd(eHe,null);lmd=new lGd(oAe,150);kmd=new lGd(pAe,1.414);nmd=new lGd(qAe,null);omd=new lGd(fHe,1);$kd=new lGd(NDe,false);_kd=new lGd(ODe,false);Ukd=new lGd(Cze,1);Vkd=(ind(),gnd);new lGd(gHe,Vkd);yld=true;rmd=(mqd(),jqd);tmd=jqd;pmd=jqd;} + function hcc(){hcc=geb;nbc=new icc('DIRECTION_PREPROCESSOR',0);kbc=new icc('COMMENT_PREPROCESSOR',1);obc=new icc('EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER',2);Ebc=new icc('INTERACTIVE_EXTERNAL_PORT_POSITIONER',3);Xbc=new icc('PARTITION_PREPROCESSOR',4);Ibc=new icc('LABEL_DUMMY_INSERTER',5);bcc=new icc('SELF_LOOP_PREPROCESSOR',6);Nbc=new icc('LAYER_CONSTRAINT_PREPROCESSOR',7);Vbc=new icc('PARTITION_MIDPROCESSOR',8);zbc=new icc('HIGH_DEGREE_NODE_LAYER_PROCESSOR',9);Rbc=new icc('NODE_PROMOTION',10);Mbc=new icc('LAYER_CONSTRAINT_POSTPROCESSOR',11);Wbc=new icc('PARTITION_POSTPROCESSOR',12);vbc=new icc('HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR',13);dcc=new icc('SEMI_INTERACTIVE_CROSSMIN_PROCESSOR',14);ebc=new icc('BREAKING_POINT_INSERTER',15);Qbc=new icc('LONG_EDGE_SPLITTER',16);Zbc=new icc('PORT_SIDE_PROCESSOR',17);Fbc=new icc('INVERTED_PORT_PROCESSOR',18);Ybc=new icc('PORT_LIST_SORTER',19);fcc=new icc('SORT_BY_INPUT_ORDER_OF_MODEL',20);Tbc=new icc('NORTH_SOUTH_PORT_PREPROCESSOR',21);fbc=new icc('BREAKING_POINT_PROCESSOR',22);Ubc=new icc(jBe,23);gcc=new icc(kBe,24);_bc=new icc('SELF_LOOP_PORT_RESTORER',25);ecc=new icc('SINGLE_EDGE_GRAPH_WRAPPER',26);Gbc=new icc('IN_LAYER_CONSTRAINT_PROCESSOR',27);sbc=new icc('END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR',28);Hbc=new icc('LABEL_AND_NODE_SIZE_PROCESSOR',29);Dbc=new icc('INNERMOST_NODE_MARGIN_CALCULATOR',30);ccc=new icc('SELF_LOOP_ROUTER',31);ibc=new icc('COMMENT_NODE_MARGIN_CALCULATOR',32);qbc=new icc('END_LABEL_PREPROCESSOR',33);Kbc=new icc('LABEL_DUMMY_SWITCHER',34);hbc=new icc('CENTER_LABEL_MANAGEMENT_PROCESSOR',35);Lbc=new icc('LABEL_SIDE_SELECTOR',36);Bbc=new icc('HYPEREDGE_DUMMY_MERGER',37);wbc=new icc('HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR',38);Obc=new icc('LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR',39);ybc=new icc('HIERARCHICAL_PORT_POSITION_PROCESSOR',40);lbc=new icc('CONSTRAINTS_POSTPROCESSOR',41);jbc=new icc('COMMENT_POSTPROCESSOR',42);Cbc=new icc('HYPERNODE_PROCESSOR',43);xbc=new icc('HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER',44);Pbc=new icc('LONG_EDGE_JOINER',45);acc=new icc('SELF_LOOP_POSTPROCESSOR',46);gbc=new icc('BREAKING_POINT_REMOVER',47);Sbc=new icc('NORTH_SOUTH_PORT_POSTPROCESSOR',48);Abc=new icc('HORIZONTAL_COMPACTOR',49);Jbc=new icc('LABEL_DUMMY_REMOVER',50);tbc=new icc('FINAL_SPLINE_BENDPOINTS_CALCULATOR',51);rbc=new icc('END_LABEL_SORTER',52);$bc=new icc('REVERSED_EDGE_RESTORER',53);pbc=new icc('END_LABEL_POSTPROCESSOR',54);ubc=new icc('HIERARCHICAL_NODE_RESIZER',55);mbc=new icc('DIRECTION_POSTPROCESSOR',56);} + function Ozc(){Ozc=geb;Uxc=($tc(),Ytc);Txc=new lGd(HBe,Uxc);jyc=new lGd(IBe,(Geb(),false));pyc=(Ovc(),Mvc);oyc=new lGd(JBe,pyc);Hyc=new lGd(KBe,false);Iyc=new lGd(LBe,true);ixc=new lGd(MBe,false);azc=(sEc(),qEc);_yc=new lGd(NBe,azc);sgb(1);izc=new lGd(OBe,sgb(7));jzc=new lGd(PBe,false);kyc=new lGd(QBe,false);Sxc=(Ptc(),Ltc);Rxc=new lGd(RBe,Sxc);Gyc=(_Cc(),ZCc);Fyc=new lGd(SBe,Gyc);wyc=(cxc(),bxc);vyc=new lGd(TBe,wyc);sgb(-1);uyc=new lGd(UBe,null);sgb(-1);xyc=new lGd(VBe,sgb(-1));sgb(-1);yyc=new lGd(WBe,sgb(4));sgb(-1);Ayc=new lGd(XBe,sgb(2));Eyc=(aEc(),$Dc);Dyc=new lGd(YBe,Eyc);sgb(0);Cyc=new lGd(ZBe,sgb(0));syc=new lGd($Be,sgb(lve));Qxc=(stc(),qtc);Pxc=new lGd(_Be,Qxc);yxc=new lGd(aCe,false);Hxc=new lGd(bCe,0.1);Nxc=new lGd(cCe,false);Jxc=new lGd(dCe,null);Kxc=new lGd(eCe,null);sgb(-1);Lxc=new lGd(fCe,null);sgb(-1);Mxc=new lGd(gCe,sgb(-1));sgb(0);zxc=new lGd(hCe,sgb(40));Fxc=(xvc(),wvc);Exc=new lGd(iCe,Fxc);Bxc=uvc;Axc=new lGd(jCe,Bxc);$yc=(JDc(),EDc);Zyc=new lGd(kCe,$yc);Pyc=new jGd(lCe);Kyc=(Cuc(),Auc);Jyc=new lGd(mCe,Kyc);Nyc=(Ouc(),Luc);Myc=new lGd(nCe,Nyc);Syc=new lGd(oCe,0.3);Uyc=new jGd(pCe);Wyc=(wDc(),uDc);Vyc=new lGd(qCe,Wyc);ayc=(KEc(),IEc);_xc=new lGd(rCe,ayc);cyc=(TEc(),SEc);byc=new lGd(sCe,cyc);eyc=(lFc(),kFc);dyc=new lGd(tCe,eyc);gyc=new lGd(uCe,0.2);Zxc=new lGd(vCe,2);ezc=new lGd(wCe,null);gzc=new lGd(xCe,10);fzc=new lGd(yCe,10);hzc=new lGd(zCe,20);sgb(0);bzc=new lGd(ACe,sgb(0));sgb(0);czc=new lGd(BCe,sgb(0));sgb(0);dzc=new lGd(CCe,sgb(0));jxc=new lGd(DCe,false);nxc=($uc(),Yuc);mxc=new lGd(ECe,nxc);lxc=(jtc(),itc);kxc=new lGd(FCe,lxc);myc=new lGd(GCe,false);sgb(0);lyc=new lGd(HCe,sgb(16));sgb(0);nyc=new lGd(ICe,sgb(5));Gzc=(DFc(),BFc);Fzc=new lGd(JCe,Gzc);kzc=new lGd(KCe,10);nzc=new lGd(LCe,1);wzc=(Etc(),Dtc);vzc=new lGd(MCe,wzc);qzc=new jGd(NCe);tzc=sgb(1);sgb(0);szc=new lGd(OCe,tzc);Lzc=(uFc(),rFc);Kzc=new lGd(PCe,Lzc);Hzc=new jGd(QCe);Bzc=new lGd(RCe,true);zzc=new lGd(SCe,2);Dzc=new lGd(TCe,true);Yxc=(tuc(),ruc);Xxc=new lGd(UCe,Yxc);Wxc=(btc(),Zsc);Vxc=new lGd(VCe,Wxc);xxc=(kEc(),hEc);wxc=new lGd(WCe,xxc);vxc=new lGd(XCe,false);uxc=new lGd(YCe,false);pxc=(U$b(),T$b);oxc=new lGd(ZCe,pxc);txc=(lDc(),iDc);sxc=new lGd($Ce,txc);qxc=new lGd(_Ce,0);rxc=new lGd(aDe,0);ryc=Ntc;qyc=ptc;zyc=YCc;Byc=YCc;tyc=TCc;Ixc=(Fnd(),Cnd);Oxc=qtc;Gxc=qtc;Cxc=qtc;Dxc=Cnd;Qyc=HDc;Ryc=EDc;Lyc=EDc;Oyc=EDc;Tyc=GDc;Yyc=HDc;Xyc=HDc;fyc=(Ymd(),Wmd);hyc=Wmd;iyc=kFc;$xc=Vmd;lzc=CFc;mzc=AFc;ozc=CFc;pzc=AFc;xzc=CFc;yzc=AFc;rzc=Ctc;uzc=Dtc;Mzc=CFc;Nzc=AFc;Izc=CFc;Jzc=AFc;Czc=AFc;Azc=AFc;Ezc=AFc;} + function iNc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,ab,bb,cb,db,eb,fb,gb,hb,ib,jb,kb,lb;cb=0;for(H=b,K=0,N=H.length;K0&&(a.a[U.p]=cb++);}}hb=0;for(I=c,L=0,O=I.length;L0){U=(sFb(Y.b>0),RD(Y.a.Xb(Y.c=--Y.b),12));X=0;for(h=new Anb(U.e);h.a0){if(U.j==(qpd(),Yod)){a.a[U.p]=hb;++hb;}else {a.a[U.p]=hb+P+R;++R;}}}hb+=R;}W=new Tsb;o=new Iub;for(G=b,J=0,M=G.length;Jj.b&&(j.b=Z);}else if(U.i.c==bb){Zj.c&&(j.c=Z);}}}Wnb(p,0,p.length,null);gb=$C(kE,Pwe,28,p.length,15,1);d=$C(kE,Pwe,28,hb+1,15,1);for(r=0;r0){A%2>0&&(e+=kb[A+1]);A=(A-1)/2|0;++kb[A];}}C=$C(NY,rve,374,p.length*2,0,1);for(u=0;u0&&(ltd(J.f),false)){if(RD(Gxd(r,nmd),280)==jqd){throw Adb(new Jed('Topdown Layout Providers should only be used on parallel nodes.'))}fE(ltd(J.f));null.Um();zyd(r,$wnd.Math.max(r.g,null.Vm),$wnd.Math.max(r.f,null.Vm));}else if(Gxd(r,smd)!=null){h=RD(Gxd(r,smd),347);W=h.Tg(r);zyd(r,$wnd.Math.max(r.g,W.a),$wnd.Math.max(r.f,W.b));}}}O=RD(Gxd(b,tld),107);n=b.g-(O.b+O.c);m=b.f-(O.d+O.a);Z.bh('Available Child Area: ('+n+'|'+m+')');Ixd(b,Dkd,n/m);Ced(b,e,d.eh(M));if(RD(Gxd(b,nmd),280)==lqd){psd(b);zyd(b,O.b+Kfb(UD(Gxd(b,Ikd)))+O.c,O.d+Kfb(UD(Gxd(b,Hkd)))+O.a);}Z.bh('Executed layout algorithm: '+WD(Gxd(b,Akd))+' on node '+b.k);if(RD(Gxd(b,nmd),280)==jqd){if(n<0||m<0){throw Adb(new Jed('The size defined by the parent parallel node is too small for the space provided by the paddings of the child hierarchical node. '+b.k))}Hxd(b,Ikd)||Hxd(b,Hkd)||psd(b);p=Kfb(UD(Gxd(b,Ikd)));o=Kfb(UD(Gxd(b,Hkd)));Z.bh('Desired Child Area: ('+p+'|'+o+')');Q=n/p;R=m/o;P=$wnd.Math.min(Q,$wnd.Math.min(R,Kfb(UD(Gxd(b,omd)))));Ixd(b,qmd,P);Z.bh(b.k+' -- Local Scale Factor (X|Y): ('+Q+'|'+R+')');u=RD(Gxd(b,Kkd),21);f=0;g=0;P'?":lhb(XIe,a)?"'(?<' or '(? toIndex: ',bye=', toIndex: ',cye='Index: ',dye=', Size: ',eye='org.eclipse.elk.alg.common',fye={50:1},gye='org.eclipse.elk.alg.common.compaction',hye='Scanline/EventHandler',iye='org.eclipse.elk.alg.common.compaction.oned',jye='CNode belongs to another CGroup.',kye='ISpacingsHandler/1',lye='The ',mye=' instance has been finished already.',nye='The direction ',oye=' is not supported by the CGraph instance.',pye='OneDimensionalCompactor',qye='OneDimensionalCompactor/lambda$0$Type',rye='Quadruplet',sye='ScanlineConstraintCalculator',tye='ScanlineConstraintCalculator/ConstraintsScanlineHandler',uye='ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type',vye='ScanlineConstraintCalculator/Timestamp',wye='ScanlineConstraintCalculator/lambda$0$Type',xye={178:1,46:1},yye='org.eclipse.elk.alg.common.compaction.options',zye='org.eclipse.elk.core.data',Aye='org.eclipse.elk.polyomino.traversalStrategy',Bye='org.eclipse.elk.polyomino.lowLevelSort',Cye='org.eclipse.elk.polyomino.highLevelSort',Dye='org.eclipse.elk.polyomino.fill',Eye={134:1},Fye='polyomino',Gye='org.eclipse.elk.alg.common.networksimplex',Hye={183:1,3:1,4:1},Iye='org.eclipse.elk.alg.common.nodespacing',Jye='org.eclipse.elk.alg.common.nodespacing.cellsystem',Kye='CENTER',Lye={217:1,336:1},Mye={3:1,4:1,5:1,603:1},Nye='LEFT',Oye='RIGHT',Pye='Vertical alignment cannot be null',Qye='BOTTOM',Rye='org.eclipse.elk.alg.common.nodespacing.internal',Sye='UNDEFINED',Tye=0.01,Uye='org.eclipse.elk.alg.common.nodespacing.internal.algorithm',Vye='LabelPlacer/lambda$0$Type',Wye='LabelPlacer/lambda$1$Type',Xye='portRatioOrPosition',Yye='org.eclipse.elk.alg.common.overlaps',Zye='DOWN',$ye='org.eclipse.elk.alg.common.polyomino',_ye='NORTH',aze='EAST',bze='SOUTH',cze='WEST',dze='org.eclipse.elk.alg.common.polyomino.structures',eze='Direction',fze='Grid is only of size ',gze='. Requested point (',hze=') is out of bounds.',ize=' Given center based coordinates were (',jze='org.eclipse.elk.graph.properties',kze='IPropertyHolder',lze={3:1,96:1,137:1},mze='org.eclipse.elk.alg.common.spore',nze='org.eclipse.elk.alg.common.utils',oze={205:1},pze='org.eclipse.elk.core',qze='Connected Components Compaction',rze='org.eclipse.elk.alg.disco',sze='org.eclipse.elk.alg.disco.graph',tze='org.eclipse.elk.alg.disco.options',uze='CompactionStrategy',vze='org.eclipse.elk.disco.componentCompaction.strategy',wze='org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm',xze='org.eclipse.elk.disco.debug.discoGraph',yze='org.eclipse.elk.disco.debug.discoPolys',zze='componentCompaction',Aze='org.eclipse.elk.disco',Bze='org.eclipse.elk.spacing.componentComponent',Cze='org.eclipse.elk.edge.thickness',Dze='org.eclipse.elk.aspectRatio',Eze='org.eclipse.elk.padding',Fze='org.eclipse.elk.alg.disco.transform',Gze=1.5707963267948966,Hze=1.7976931348623157E308,Ize={3:1,4:1,5:1,198:1},Jze={3:1,6:1,4:1,5:1,100:1,115:1},Kze='org.eclipse.elk.alg.force',Lze='ComponentsProcessor',Mze='ComponentsProcessor/1',Nze='ElkGraphImporter/lambda$0$Type',Oze='org.eclipse.elk.alg.force.graph',Pze='Component Layout',Qze='org.eclipse.elk.alg.force.model',Rze='org.eclipse.elk.force.model',Sze='org.eclipse.elk.force.iterations',Tze='org.eclipse.elk.force.repulsivePower',Uze='org.eclipse.elk.force.temperature',Vze=0.001,Wze='org.eclipse.elk.force.repulsion',Xze='org.eclipse.elk.alg.force.options',Yze=1.600000023841858,Zze='org.eclipse.elk.force',$ze='org.eclipse.elk.priority',_ze='org.eclipse.elk.spacing.nodeNode',aAe='org.eclipse.elk.spacing.edgeLabel',bAe='org.eclipse.elk.randomSeed',cAe='org.eclipse.elk.separateConnectedComponents',dAe='org.eclipse.elk.interactive',eAe='org.eclipse.elk.portConstraints',fAe='org.eclipse.elk.edgeLabels.inline',gAe='org.eclipse.elk.omitNodeMicroLayout',hAe='org.eclipse.elk.nodeSize.fixedGraphSize',iAe='org.eclipse.elk.nodeSize.options',jAe='org.eclipse.elk.nodeSize.constraints',kAe='org.eclipse.elk.nodeLabels.placement',lAe='org.eclipse.elk.portLabels.placement',mAe='org.eclipse.elk.topdownLayout',nAe='org.eclipse.elk.topdown.scaleFactor',oAe='org.eclipse.elk.topdown.hierarchicalNodeWidth',pAe='org.eclipse.elk.topdown.hierarchicalNodeAspectRatio',qAe='org.eclipse.elk.topdown.nodeType',rAe='origin',sAe='random',tAe='boundingBox.upLeft',uAe='boundingBox.lowRight',vAe='org.eclipse.elk.stress.fixed',wAe='org.eclipse.elk.stress.desiredEdgeLength',xAe='org.eclipse.elk.stress.dimension',yAe='org.eclipse.elk.stress.epsilon',zAe='org.eclipse.elk.stress.iterationLimit',AAe='org.eclipse.elk.stress',BAe='ELK Stress',CAe='org.eclipse.elk.nodeSize.minimum',DAe='org.eclipse.elk.alg.force.stress',EAe='Layered layout',FAe='org.eclipse.elk.alg.layered',GAe='org.eclipse.elk.alg.layered.compaction.components',HAe='org.eclipse.elk.alg.layered.compaction.oned',IAe='org.eclipse.elk.alg.layered.compaction.oned.algs',JAe='org.eclipse.elk.alg.layered.compaction.recthull',KAe='org.eclipse.elk.alg.layered.components',LAe='NONE',MAe='MODEL_ORDER',NAe={3:1,6:1,4:1,9:1,5:1,126:1},OAe={3:1,6:1,4:1,5:1,150:1,100:1,115:1},PAe='org.eclipse.elk.alg.layered.compound',QAe={47:1},RAe='org.eclipse.elk.alg.layered.graph',SAe=' -> ',TAe='Not supported by LGraph',UAe='Port side is undefined',VAe={3:1,6:1,4:1,5:1,483:1,150:1,100:1,115:1},WAe={3:1,6:1,4:1,5:1,150:1,199:1,210:1,100:1,115:1},XAe={3:1,6:1,4:1,5:1,150:1,2042:1,210:1,100:1,115:1},YAe='([{"\' \t\r\n',ZAe=')]}"\' \t\r\n',$Ae='The given string contains parts that cannot be parsed as numbers.',_Ae='org.eclipse.elk.core.math',aBe={3:1,4:1,140:1,214:1,423:1},bBe={3:1,4:1,107:1,214:1,423:1},cBe='org.eclipse.elk.alg.layered.graph.transform',dBe='ElkGraphImporter',eBe='ElkGraphImporter/lambda$1$Type',fBe='ElkGraphImporter/lambda$2$Type',gBe='ElkGraphImporter/lambda$4$Type',hBe='org.eclipse.elk.alg.layered.intermediate',iBe='Node margin calculation',jBe='ONE_SIDED_GREEDY_SWITCH',kBe='TWO_SIDED_GREEDY_SWITCH',lBe='No implementation is available for the layout processor ',mBe='IntermediateProcessorStrategy',nBe="Node '",oBe='FIRST_SEPARATE',pBe='LAST_SEPARATE',qBe='Odd port side processing',rBe='org.eclipse.elk.alg.layered.intermediate.compaction',sBe='org.eclipse.elk.alg.layered.intermediate.greedyswitch',tBe='org.eclipse.elk.alg.layered.p3order.counting',uBe={230:1},vBe='org.eclipse.elk.alg.layered.intermediate.loops',wBe='org.eclipse.elk.alg.layered.intermediate.loops.ordering',xBe='org.eclipse.elk.alg.layered.intermediate.loops.routing',yBe='org.eclipse.elk.alg.layered.intermediate.preserveorder',zBe='org.eclipse.elk.alg.layered.intermediate.wrapping',ABe='org.eclipse.elk.alg.layered.options',BBe='INTERACTIVE',CBe='GREEDY',DBe='DEPTH_FIRST',EBe='EDGE_LENGTH',FBe='SELF_LOOPS',GBe='firstTryWithInitialOrder',HBe='org.eclipse.elk.layered.directionCongruency',IBe='org.eclipse.elk.layered.feedbackEdges',JBe='org.eclipse.elk.layered.interactiveReferencePoint',KBe='org.eclipse.elk.layered.mergeEdges',LBe='org.eclipse.elk.layered.mergeHierarchyEdges',MBe='org.eclipse.elk.layered.allowNonFlowPortsToSwitchSides',NBe='org.eclipse.elk.layered.portSortingStrategy',OBe='org.eclipse.elk.layered.thoroughness',PBe='org.eclipse.elk.layered.unnecessaryBendpoints',QBe='org.eclipse.elk.layered.generatePositionAndLayerIds',RBe='org.eclipse.elk.layered.cycleBreaking.strategy',SBe='org.eclipse.elk.layered.layering.strategy',TBe='org.eclipse.elk.layered.layering.layerConstraint',UBe='org.eclipse.elk.layered.layering.layerChoiceConstraint',VBe='org.eclipse.elk.layered.layering.layerId',WBe='org.eclipse.elk.layered.layering.minWidth.upperBoundOnWidth',XBe='org.eclipse.elk.layered.layering.minWidth.upperLayerEstimationScalingFactor',YBe='org.eclipse.elk.layered.layering.nodePromotion.strategy',ZBe='org.eclipse.elk.layered.layering.nodePromotion.maxIterations',$Be='org.eclipse.elk.layered.layering.coffmanGraham.layerBound',_Be='org.eclipse.elk.layered.crossingMinimization.strategy',aCe='org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder',bCe='org.eclipse.elk.layered.crossingMinimization.hierarchicalSweepiness',cCe='org.eclipse.elk.layered.crossingMinimization.semiInteractive',dCe='org.eclipse.elk.layered.crossingMinimization.inLayerPredOf',eCe='org.eclipse.elk.layered.crossingMinimization.inLayerSuccOf',fCe='org.eclipse.elk.layered.crossingMinimization.positionChoiceConstraint',gCe='org.eclipse.elk.layered.crossingMinimization.positionId',hCe='org.eclipse.elk.layered.crossingMinimization.greedySwitch.activationThreshold',iCe='org.eclipse.elk.layered.crossingMinimization.greedySwitch.type',jCe='org.eclipse.elk.layered.crossingMinimization.greedySwitchHierarchical.type',kCe='org.eclipse.elk.layered.nodePlacement.strategy',lCe='org.eclipse.elk.layered.nodePlacement.favorStraightEdges',mCe='org.eclipse.elk.layered.nodePlacement.bk.edgeStraightening',nCe='org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment',oCe='org.eclipse.elk.layered.nodePlacement.linearSegments.deflectionDampening',pCe='org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility',qCe='org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default',rCe='org.eclipse.elk.layered.edgeRouting.selfLoopDistribution',sCe='org.eclipse.elk.layered.edgeRouting.selfLoopOrdering',tCe='org.eclipse.elk.layered.edgeRouting.splines.mode',uCe='org.eclipse.elk.layered.edgeRouting.splines.sloppy.layerSpacingFactor',vCe='org.eclipse.elk.layered.edgeRouting.polyline.slopedEdgeZoneWidth',wCe='org.eclipse.elk.layered.spacing.baseValue',xCe='org.eclipse.elk.layered.spacing.edgeNodeBetweenLayers',yCe='org.eclipse.elk.layered.spacing.edgeEdgeBetweenLayers',zCe='org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers',ACe='org.eclipse.elk.layered.priority.direction',BCe='org.eclipse.elk.layered.priority.shortness',CCe='org.eclipse.elk.layered.priority.straightness',DCe='org.eclipse.elk.layered.compaction.connectedComponents',ECe='org.eclipse.elk.layered.compaction.postCompaction.strategy',FCe='org.eclipse.elk.layered.compaction.postCompaction.constraints',GCe='org.eclipse.elk.layered.highDegreeNodes.treatment',HCe='org.eclipse.elk.layered.highDegreeNodes.threshold',ICe='org.eclipse.elk.layered.highDegreeNodes.treeHeight',JCe='org.eclipse.elk.layered.wrapping.strategy',KCe='org.eclipse.elk.layered.wrapping.additionalEdgeSpacing',LCe='org.eclipse.elk.layered.wrapping.correctionFactor',MCe='org.eclipse.elk.layered.wrapping.cutting.strategy',NCe='org.eclipse.elk.layered.wrapping.cutting.cuts',OCe='org.eclipse.elk.layered.wrapping.cutting.msd.freedom',PCe='org.eclipse.elk.layered.wrapping.validify.strategy',QCe='org.eclipse.elk.layered.wrapping.validify.forbiddenIndices',RCe='org.eclipse.elk.layered.wrapping.multiEdge.improveCuts',SCe='org.eclipse.elk.layered.wrapping.multiEdge.distancePenalty',TCe='org.eclipse.elk.layered.wrapping.multiEdge.improveWrappedEdges',UCe='org.eclipse.elk.layered.edgeLabels.sideSelection',VCe='org.eclipse.elk.layered.edgeLabels.centerLabelPlacementStrategy',WCe='org.eclipse.elk.layered.considerModelOrder.strategy',XCe='org.eclipse.elk.layered.considerModelOrder.portModelOrder',YCe='org.eclipse.elk.layered.considerModelOrder.noModelOrder',ZCe='org.eclipse.elk.layered.considerModelOrder.components',$Ce='org.eclipse.elk.layered.considerModelOrder.longEdgeStrategy',_Ce='org.eclipse.elk.layered.considerModelOrder.crossingCounterNodeInfluence',aDe='org.eclipse.elk.layered.considerModelOrder.crossingCounterPortInfluence',bDe='layering',cDe='layering.minWidth',dDe='layering.nodePromotion',eDe='crossingMinimization',fDe='org.eclipse.elk.hierarchyHandling',gDe='crossingMinimization.greedySwitch',hDe='nodePlacement',iDe='nodePlacement.bk',jDe='edgeRouting',kDe='org.eclipse.elk.edgeRouting',lDe='spacing',mDe='priority',nDe='compaction',oDe='compaction.postCompaction',pDe='Specifies whether and how post-process compaction is applied.',qDe='highDegreeNodes',rDe='wrapping',sDe='wrapping.cutting',tDe='wrapping.validify',uDe='wrapping.multiEdge',vDe='edgeLabels',wDe='considerModelOrder',xDe='org.eclipse.elk.spacing.commentComment',yDe='org.eclipse.elk.spacing.commentNode',zDe='org.eclipse.elk.spacing.edgeEdge',ADe='org.eclipse.elk.spacing.edgeNode',BDe='org.eclipse.elk.spacing.labelLabel',CDe='org.eclipse.elk.spacing.labelPortHorizontal',DDe='org.eclipse.elk.spacing.labelPortVertical',EDe='org.eclipse.elk.spacing.labelNode',FDe='org.eclipse.elk.spacing.nodeSelfLoop',GDe='org.eclipse.elk.spacing.portPort',HDe='org.eclipse.elk.spacing.individual',IDe='org.eclipse.elk.port.borderOffset',JDe='org.eclipse.elk.noLayout',KDe='org.eclipse.elk.port.side',LDe='org.eclipse.elk.debugMode',MDe='org.eclipse.elk.alignment',NDe='org.eclipse.elk.insideSelfLoops.activate',ODe='org.eclipse.elk.insideSelfLoops.yo',PDe='org.eclipse.elk.direction',QDe='org.eclipse.elk.nodeLabels.padding',RDe='org.eclipse.elk.portLabels.nextToPortIfPossible',SDe='org.eclipse.elk.portLabels.treatAsGroup',TDe='org.eclipse.elk.portAlignment.default',UDe='org.eclipse.elk.portAlignment.north',VDe='org.eclipse.elk.portAlignment.south',WDe='org.eclipse.elk.portAlignment.west',XDe='org.eclipse.elk.portAlignment.east',YDe='org.eclipse.elk.contentAlignment',ZDe='org.eclipse.elk.junctionPoints',$De='org.eclipse.elk.edgeLabels.placement',_De='org.eclipse.elk.port.index',aEe='org.eclipse.elk.commentBox',bEe='org.eclipse.elk.hypernode',cEe='org.eclipse.elk.port.anchor',dEe='org.eclipse.elk.partitioning.activate',eEe='org.eclipse.elk.partitioning.partition',fEe='org.eclipse.elk.position',gEe='org.eclipse.elk.margins',hEe='org.eclipse.elk.spacing.portsSurrounding',iEe='org.eclipse.elk.interactiveLayout',jEe='org.eclipse.elk.core.util',kEe={3:1,4:1,5:1,601:1},lEe='NETWORK_SIMPLEX',mEe='SIMPLE',nEe={106:1,47:1},oEe='org.eclipse.elk.alg.layered.p1cycles',pEe='org.eclipse.elk.alg.layered.p2layers',qEe={413:1,230:1},rEe={846:1,3:1,4:1},sEe='org.eclipse.elk.alg.layered.p3order',tEe='org.eclipse.elk.alg.layered.p4nodes',uEe={3:1,4:1,5:1,854:1},vEe=1.0E-5,wEe='org.eclipse.elk.alg.layered.p4nodes.bk',xEe='org.eclipse.elk.alg.layered.p5edges',yEe='org.eclipse.elk.alg.layered.p5edges.orthogonal',zEe='org.eclipse.elk.alg.layered.p5edges.orthogonal.direction',AEe=1.0E-6,BEe='org.eclipse.elk.alg.layered.p5edges.splines',CEe=0.09999999999999998,DEe=1.0E-8,EEe=4.71238898038469,FEe=3.141592653589793,GEe='org.eclipse.elk.alg.mrtree',HEe=0.10000000149011612,IEe='SUPER_ROOT',JEe='org.eclipse.elk.alg.mrtree.graph',KEe=-1.7976931348623157E308,LEe='org.eclipse.elk.alg.mrtree.intermediate',MEe='Processor compute fanout',NEe={3:1,6:1,4:1,5:1,534:1,100:1,115:1},OEe='Set neighbors in level',PEe='org.eclipse.elk.alg.mrtree.options',QEe='DESCENDANTS',REe='org.eclipse.elk.mrtree.compaction',SEe='org.eclipse.elk.mrtree.edgeEndTextureLength',TEe='org.eclipse.elk.mrtree.treeLevel',UEe='org.eclipse.elk.mrtree.positionConstraint',VEe='org.eclipse.elk.mrtree.weighting',WEe='org.eclipse.elk.mrtree.edgeRoutingMode',XEe='org.eclipse.elk.mrtree.searchOrder',YEe='Position Constraint',ZEe='org.eclipse.elk.mrtree',$Ee='org.eclipse.elk.tree',_Ee='Processor arrange level',aFe='org.eclipse.elk.alg.mrtree.p2order',bFe='org.eclipse.elk.alg.mrtree.p4route',cFe='org.eclipse.elk.alg.radial',dFe=6.283185307179586,eFe='Before',fFe=4.9E-324,gFe='After',hFe='org.eclipse.elk.alg.radial.intermediate',iFe='COMPACTION',jFe='org.eclipse.elk.alg.radial.intermediate.compaction',kFe={3:1,4:1,5:1,100:1},lFe='org.eclipse.elk.alg.radial.intermediate.optimization',mFe='No implementation is available for the layout option ',nFe='org.eclipse.elk.alg.radial.options',oFe='org.eclipse.elk.radial.centerOnRoot',pFe='org.eclipse.elk.radial.orderId',qFe='org.eclipse.elk.radial.radius',rFe='org.eclipse.elk.radial.rotate',sFe='org.eclipse.elk.radial.compactor',tFe='org.eclipse.elk.radial.compactionStepSize',uFe='org.eclipse.elk.radial.sorter',vFe='org.eclipse.elk.radial.wedgeCriteria',wFe='org.eclipse.elk.radial.optimizationCriteria',xFe='org.eclipse.elk.radial.rotation.targetAngle',yFe='org.eclipse.elk.radial.rotation.computeAdditionalWedgeSpace',zFe='org.eclipse.elk.radial.rotation.outgoingEdgeAngles',AFe='Compaction',BFe='rotation',CFe='org.eclipse.elk.radial',DFe='org.eclipse.elk.alg.radial.p1position.wedge',EFe='org.eclipse.elk.alg.radial.sorting',FFe=5.497787143782138,GFe=3.9269908169872414,HFe=2.356194490192345,IFe='org.eclipse.elk.alg.rectpacking',JFe='org.eclipse.elk.alg.rectpacking.intermediate',KFe='org.eclipse.elk.alg.rectpacking.options',LFe='org.eclipse.elk.rectpacking.trybox',MFe='org.eclipse.elk.rectpacking.currentPosition',NFe='org.eclipse.elk.rectpacking.desiredPosition',OFe='org.eclipse.elk.rectpacking.inNewRow',PFe='org.eclipse.elk.rectpacking.widthApproximation.strategy',QFe='org.eclipse.elk.rectpacking.widthApproximation.targetWidth',RFe='org.eclipse.elk.rectpacking.widthApproximation.optimizationGoal',SFe='org.eclipse.elk.rectpacking.widthApproximation.lastPlaceShift',TFe='org.eclipse.elk.rectpacking.packing.strategy',UFe='org.eclipse.elk.rectpacking.packing.compaction.rowHeightReevaluation',VFe='org.eclipse.elk.rectpacking.packing.compaction.iterations',WFe='org.eclipse.elk.rectpacking.whiteSpaceElimination.strategy',XFe='widthApproximation',YFe='Compaction Strategy',ZFe='packing.compaction',$Fe='org.eclipse.elk.rectpacking',_Fe='org.eclipse.elk.alg.rectpacking.p1widthapproximation',aGe='org.eclipse.elk.alg.rectpacking.p2packing',bGe='No Compaction',cGe='org.eclipse.elk.alg.rectpacking.p3whitespaceelimination',dGe='org.eclipse.elk.alg.rectpacking.util',eGe='No implementation available for ',fGe='org.eclipse.elk.alg.spore',gGe='org.eclipse.elk.alg.spore.options',hGe='org.eclipse.elk.sporeCompaction',iGe='org.eclipse.elk.underlyingLayoutAlgorithm',jGe='org.eclipse.elk.processingOrder.treeConstruction',kGe='org.eclipse.elk.processingOrder.spanningTreeCostFunction',lGe='org.eclipse.elk.processingOrder.preferredRoot',mGe='org.eclipse.elk.processingOrder.rootSelection',nGe='org.eclipse.elk.structure.structureExtractionStrategy',oGe='org.eclipse.elk.compaction.compactionStrategy',pGe='org.eclipse.elk.compaction.orthogonal',qGe='org.eclipse.elk.overlapRemoval.maxIterations',rGe='org.eclipse.elk.overlapRemoval.runScanline',sGe='processingOrder',tGe='overlapRemoval',uGe='org.eclipse.elk.sporeOverlap',vGe='org.eclipse.elk.alg.spore.p1structure',wGe='org.eclipse.elk.alg.spore.p2processingorder',xGe='org.eclipse.elk.alg.spore.p3execution',yGe='Topdown Layout',zGe='Invalid index: ',AGe='org.eclipse.elk.core.alg',BGe={341:1},CGe={295:1},DGe='Make sure its type is registered with the ',EGe=' utility class.',FGe='true',GGe='false',HGe="Couldn't clone property '",IGe=0.05,JGe='org.eclipse.elk.core.options',KGe=1.2999999523162842,LGe='org.eclipse.elk.box',MGe='org.eclipse.elk.expandNodes',NGe='org.eclipse.elk.box.packingMode',OGe='org.eclipse.elk.algorithm',PGe='org.eclipse.elk.resolvedAlgorithm',QGe='org.eclipse.elk.bendPoints',RGe='org.eclipse.elk.labelManager',SGe='org.eclipse.elk.scaleFactor',TGe='org.eclipse.elk.childAreaWidth',UGe='org.eclipse.elk.childAreaHeight',VGe='org.eclipse.elk.animate',WGe='org.eclipse.elk.animTimeFactor',XGe='org.eclipse.elk.layoutAncestors',YGe='org.eclipse.elk.maxAnimTime',ZGe='org.eclipse.elk.minAnimTime',$Ge='org.eclipse.elk.progressBar',_Ge='org.eclipse.elk.validateGraph',aHe='org.eclipse.elk.validateOptions',bHe='org.eclipse.elk.zoomToFit',cHe='org.eclipse.elk.font.name',dHe='org.eclipse.elk.font.size',eHe='org.eclipse.elk.topdown.sizeApproximator',fHe='org.eclipse.elk.topdown.scaleCap',gHe='org.eclipse.elk.edge.type',hHe='partitioning',iHe='nodeLabels',jHe='portAlignment',kHe='nodeSize',lHe='port',mHe='portLabels',nHe='topdown',oHe='insideSelfLoops',pHe='org.eclipse.elk.fixed',qHe='org.eclipse.elk.random',rHe={3:1,34:1,22:1,347:1},sHe='port must have a parent node to calculate the port side',tHe='The edge needs to have exactly one edge section. Found: ',uHe='org.eclipse.elk.core.util.adapters',vHe='org.eclipse.emf.ecore',wHe='org.eclipse.elk.graph',xHe='EMapPropertyHolder',yHe='ElkBendPoint',zHe='ElkGraphElement',AHe='ElkConnectableShape',BHe='ElkEdge',CHe='ElkEdgeSection',DHe='EModelElement',EHe='ENamedElement',FHe='ElkLabel',GHe='ElkNode',HHe='ElkPort',IHe={94:1,93:1},JHe='org.eclipse.emf.common.notify.impl',KHe="The feature '",LHe="' is not a valid changeable feature",MHe='Expecting null',NHe="' is not a valid feature",OHe='The feature ID',PHe=' is not a valid feature ID',QHe=32768,RHe={110:1,94:1,93:1,58:1,54:1,99:1},SHe='org.eclipse.emf.ecore.impl',THe='org.eclipse.elk.graph.impl',UHe='Recursive containment not allowed for ',VHe="The datatype '",WHe="' is not a valid classifier",XHe="The value '",YHe={195:1,3:1,4:1},ZHe="The class '",$He='http://www.eclipse.org/elk/ElkGraph',_He='property',aIe='value',bIe='source',cIe='properties',dIe='identifier',eIe='height',fIe='width',gIe='parent',hIe='text',iIe='children',jIe='hierarchical',kIe='sources',lIe='targets',mIe='sections',nIe='bendPoints',oIe='outgoingShape',pIe='incomingShape',qIe='outgoingSections',rIe='incomingSections',sIe='org.eclipse.emf.common.util',tIe='Severe implementation error in the Json to ElkGraph importer.',uIe='id',vIe='org.eclipse.elk.graph.json',wIe='Unhandled parameter types: ',xIe='startPoint',yIe="An edge must have at least one source and one target (edge id: '",zIe="').",AIe='Referenced edge section does not exist: ',BIe=" (edge id: '",CIe='target',DIe='sourcePoint',EIe='targetPoint',FIe='group',GIe='name',HIe='connectableShape cannot be null',IIe='edge cannot be null',JIe="Passed edge is not 'simple'.",KIe='org.eclipse.elk.graph.util',LIe="The 'no duplicates' constraint is violated",MIe='targetIndex=',NIe=', size=',OIe='sourceIndex=',PIe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1},QIe={3:1,4:1,20:1,31:1,56:1,16:1,51:1,15:1,59:1,70:1,66:1,61:1,596:1},RIe='logging',SIe='measureExecutionTime',TIe='parser.parse.1',UIe='parser.parse.2',VIe='parser.next.1',WIe='parser.next.2',XIe='parser.next.3',YIe='parser.next.4',ZIe='parser.factor.1',$Ie='parser.factor.2',_Ie='parser.factor.3',aJe='parser.factor.4',bJe='parser.factor.5',cJe='parser.factor.6',dJe='parser.atom.1',eJe='parser.atom.2',fJe='parser.atom.3',gJe='parser.atom.4',hJe='parser.atom.5',iJe='parser.cc.1',jJe='parser.cc.2',kJe='parser.cc.3',lJe='parser.cc.5',mJe='parser.cc.6',nJe='parser.cc.7',oJe='parser.cc.8',pJe='parser.ope.1',qJe='parser.ope.2',rJe='parser.ope.3',sJe='parser.descape.1',tJe='parser.descape.2',uJe='parser.descape.3',vJe='parser.descape.4',wJe='parser.descape.5',xJe='parser.process.1',yJe='parser.quantifier.1',zJe='parser.quantifier.2',AJe='parser.quantifier.3',BJe='parser.quantifier.4',CJe='parser.quantifier.5',DJe='org.eclipse.emf.common.notify',EJe={424:1,686:1},FJe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,70:1,61:1},GJe={378:1,152:1},HJe='index=',IJe={3:1,4:1,5:1,129:1},JJe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,61:1},KJe={3:1,6:1,4:1,5:1,198:1},LJe={3:1,4:1,5:1,173:1,379:1},MJe=';/?:@&=+$,',NJe='invalid authority: ',OJe='EAnnotation',PJe='ETypedElement',QJe='EStructuralFeature',RJe='EAttribute',SJe='EClassifier',TJe='EEnumLiteral',UJe='EGenericType',VJe='EOperation',WJe='EParameter',XJe='EReference',YJe='ETypeParameter',ZJe='org.eclipse.emf.ecore.util',$Je={79:1},_Je={3:1,20:1,16:1,15:1,61:1,597:1,79:1,71:1,97:1},aKe='org.eclipse.emf.ecore.util.FeatureMap$Entry',bKe=8192,cKe=2048,dKe='byte',eKe='char',fKe='double',gKe='float',hKe='int',iKe='long',jKe='short',kKe='java.lang.Object',lKe={3:1,4:1,5:1,254:1},mKe={3:1,4:1,5:1,688:1},nKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,71:1},oKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,79:1,71:1,97:1},pKe='mixed',qKe='http:///org/eclipse/emf/ecore/util/ExtendedMetaData',rKe='kind',sKe={3:1,4:1,5:1,689:1},tKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,70:1,61:1,79:1,71:1,97:1},uKe={20:1,31:1,56:1,16:1,15:1,61:1,71:1},vKe={51:1,128:1,287:1},wKe={76:1,343:1},xKe="The value of type '",yKe="' must be of type '",zKe=1352,AKe='http://www.eclipse.org/emf/2002/Ecore',BKe=-32768,CKe='constraints',DKe='baseType',EKe='getEStructuralFeature',FKe='getFeatureID',GKe='feature',HKe='getOperationID',IKe='operation',JKe='defaultValue',KKe='eTypeParameters',LKe='isInstance',MKe='getEEnumLiteral',NKe='eContainingClass',OKe={57:1},PKe={3:1,4:1,5:1,124:1},QKe='org.eclipse.emf.ecore.resource',RKe={94:1,93:1,599:1,2034:1},SKe='org.eclipse.emf.ecore.resource.impl',TKe='unspecified',UKe='simple',VKe='attribute',WKe='attributeWildcard',XKe='element',YKe='elementWildcard',ZKe='collapse',$Ke='itemType',_Ke='namespace',aLe='##targetNamespace',bLe='whiteSpace',cLe='wildcards',dLe='http://www.eclipse.org/emf/2003/XMLType',eLe='##any',fLe='uninitialized',gLe='The multiplicity constraint is violated',hLe='org.eclipse.emf.ecore.xml.type',iLe='ProcessingInstruction',jLe='SimpleAnyType',kLe='XMLTypeDocumentRoot',lLe='org.eclipse.emf.ecore.xml.type.impl',mLe='INF',nLe='processing',oLe='ENTITIES_._base',pLe='minLength',qLe='ENTITY',rLe='NCName',sLe='IDREFS_._base',tLe='integer',uLe='token',vLe='pattern',wLe='[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*',xLe='\\i\\c*',yLe='[\\i-[:]][\\c-[:]]*',zLe='nonPositiveInteger',ALe='maxInclusive',BLe='NMTOKEN',CLe='NMTOKENS_._base',DLe='nonNegativeInteger',ELe='minInclusive',FLe='normalizedString',GLe='unsignedByte',HLe='unsignedInt',ILe='18446744073709551615',JLe='unsignedShort',KLe='processingInstruction',LLe='org.eclipse.emf.ecore.xml.type.internal',MLe=1114111,NLe='Internal Error: shorthands: \\u',OLe='xml:isDigit',PLe='xml:isWord',QLe='xml:isSpace',RLe='xml:isNameChar',SLe='xml:isInitialNameChar',TLe='09\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9\u0F20\u0F29',ULe='AZaz\xC0\xD6\xD8\xF6\xF8\u0131\u0134\u013E\u0141\u0148\u014A\u017E\u0180\u01C3\u01CD\u01F0\u01F4\u01F5\u01FA\u0217\u0250\u02A8\u02BB\u02C1\u0386\u0386\u0388\u038A\u038C\u038C\u038E\u03A1\u03A3\u03CE\u03D0\u03D6\u03DA\u03DA\u03DC\u03DC\u03DE\u03DE\u03E0\u03E0\u03E2\u03F3\u0401\u040C\u040E\u044F\u0451\u045C\u045E\u0481\u0490\u04C4\u04C7\u04C8\u04CB\u04CC\u04D0\u04EB\u04EE\u04F5\u04F8\u04F9\u0531\u0556\u0559\u0559\u0561\u0586\u05D0\u05EA\u05F0\u05F2\u0621\u063A\u0641\u064A\u0671\u06B7\u06BA\u06BE\u06C0\u06CE\u06D0\u06D3\u06D5\u06D5\u06E5\u06E6\u0905\u0939\u093D\u093D\u0958\u0961\u0985\u098C\u098F\u0990\u0993\u09A8\u09AA\u09B0\u09B2\u09B2\u09B6\u09B9\u09DC\u09DD\u09DF\u09E1\u09F0\u09F1\u0A05\u0A0A\u0A0F\u0A10\u0A13\u0A28\u0A2A\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59\u0A5C\u0A5E\u0A5E\u0A72\u0A74\u0A85\u0A8B\u0A8D\u0A8D\u0A8F\u0A91\u0A93\u0AA8\u0AAA\u0AB0\u0AB2\u0AB3\u0AB5\u0AB9\u0ABD\u0ABD\u0AE0\u0AE0\u0B05\u0B0C\u0B0F\u0B10\u0B13\u0B28\u0B2A\u0B30\u0B32\u0B33\u0B36\u0B39\u0B3D\u0B3D\u0B5C\u0B5D\u0B5F\u0B61\u0B85\u0B8A\u0B8E\u0B90\u0B92\u0B95\u0B99\u0B9A\u0B9C\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8\u0BAA\u0BAE\u0BB5\u0BB7\u0BB9\u0C05\u0C0C\u0C0E\u0C10\u0C12\u0C28\u0C2A\u0C33\u0C35\u0C39\u0C60\u0C61\u0C85\u0C8C\u0C8E\u0C90\u0C92\u0CA8\u0CAA\u0CB3\u0CB5\u0CB9\u0CDE\u0CDE\u0CE0\u0CE1\u0D05\u0D0C\u0D0E\u0D10\u0D12\u0D28\u0D2A\u0D39\u0D60\u0D61\u0E01\u0E2E\u0E30\u0E30\u0E32\u0E33\u0E40\u0E45\u0E81\u0E82\u0E84\u0E84\u0E87\u0E88\u0E8A\u0E8A\u0E8D\u0E8D\u0E94\u0E97\u0E99\u0E9F\u0EA1\u0EA3\u0EA5\u0EA5\u0EA7\u0EA7\u0EAA\u0EAB\u0EAD\u0EAE\u0EB0\u0EB0\u0EB2\u0EB3\u0EBD\u0EBD\u0EC0\u0EC4\u0F40\u0F47\u0F49\u0F69\u10A0\u10C5\u10D0\u10F6\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110B\u110C\u110E\u1112\u113C\u113C\u113E\u113E\u1140\u1140\u114C\u114C\u114E\u114E\u1150\u1150\u1154\u1155\u1159\u1159\u115F\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116D\u116E\u1172\u1173\u1175\u1175\u119E\u119E\u11A8\u11A8\u11AB\u11AB\u11AE\u11AF\u11B7\u11B8\u11BA\u11BA\u11BC\u11C2\u11EB\u11EB\u11F0\u11F0\u11F9\u11F9\u1E00\u1E9B\u1EA0\u1EF9\u1F00\u1F15\u1F18\u1F1D\u1F20\u1F45\u1F48\u1F4D\u1F50\u1F57\u1F59\u1F59\u1F5B\u1F5B\u1F5D\u1F5D\u1F5F\u1F7D\u1F80\u1FB4\u1FB6\u1FBC\u1FBE\u1FBE\u1FC2\u1FC4\u1FC6\u1FCC\u1FD0\u1FD3\u1FD6\u1FDB\u1FE0\u1FEC\u1FF2\u1FF4\u1FF6\u1FFC\u2126\u2126\u212A\u212B\u212E\u212E\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30A1\u30FA\u3105\u312C\u4E00\u9FA5\uAC00\uD7A3',VLe='Private Use',WLe='ASSIGNED',XLe='\x00\x7F\x80\xFF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF',YLe='UNASSIGNED',ZLe={3:1,122:1},$Le='org.eclipse.emf.ecore.xml.type.util',_Le={3:1,4:1,5:1,381:1},aMe='org.eclipse.xtext.xbase.lib',bMe='Cannot add elements to a Range',cMe='Cannot set elements in a Range',dMe='Cannot remove elements from a Range',eMe='user.agent';var _,eeb,_db;$wnd.goog=$wnd.goog||{};$wnd.goog.global=$wnd.goog.global||$wnd;eeb={};feb(1,null,{},nb);_.Fb=function ob(a){return mb(this,a)};_.Gb=function qb(){return this.Rm};_.Hb=function sb(){return kFb(this)};_.Ib=function ub(){var a;return nfb(rb(this))+'@'+(a=tb(this)>>>0,a.toString(16))};_.equals=function(a){return this.Fb(a)};_.hashCode=function(){return this.Hb()};_.toString=function(){return this.Ib()};var ND,OD,PD;feb(297,1,{297:1,2124:1},pfb);_.ve=function qfb(a){var b;b=new pfb;b.i=4;a>1?(b.c=xfb(this,a-1)):(b.c=this);return b};_.we=function wfb(){lfb(this);return this.b};_.xe=function yfb(){return nfb(this)};_.ye=function Afb(){return lfb(this),this.k};_.ze=function Cfb(){return (this.i&4)!=0};_.Ae=function Dfb(){return (this.i&1)!=0};_.Ib=function Gfb(){return ofb(this)};_.i=0;var jJ=sfb(mve,'Object',1);var UI=sfb(mve,'Class',297);feb(2096,1,nve);sfb(ove,'Optional',2096);feb(1191,2096,nve,xb);_.Fb=function yb(a){return a===this};_.Hb=function zb(){return 2040732332};_.Ib=function Ab(){return 'Optional.absent()'};_.Jb=function Bb(a){Qb(a);return wb(),vb};var vb;sfb(ove,'Absent',1191);feb(636,1,{},Gb);sfb(ove,'Joiner',636);var pE=ufb(ove,'Predicate');feb(589,1,{178:1,589:1,3:1,46:1},Yb);_.Mb=function ac(a){return Xb(this,a)};_.Lb=function Zb(a){return Xb(this,a)};_.Fb=function $b(a){var b;if(ZD(a,589)){b=RD(a,589);return Rt(this.a,b.a)}return false};_.Hb=function _b(){return Cob(this.a)+306654252};_.Ib=function bc(){return Wb(this.a)};sfb(ove,'Predicates/AndPredicate',589);feb(419,2096,{419:1,3:1},cc);_.Fb=function dc(a){var b;if(ZD(a,419)){b=RD(a,419);return pb(this.a,b.a)}return false};_.Hb=function ec(){return 1502476572+tb(this.a)};_.Ib=function fc(){return uve+this.a+')'};_.Jb=function gc(a){return new cc(Rb(a.Kb(this.a),'the Function passed to Optional.transform() must not return null.'))};sfb(ove,'Present',419);feb(204,1,wve);_.Nb=function kc(a){Ztb(this,a);};_.Qb=function lc(){jc();};sfb(xve,'UnmodifiableIterator',204);feb(2076,204,yve);_.Qb=function nc(){jc();};_.Rb=function mc(a){throw Adb(new jib)};_.Wb=function oc(a){throw Adb(new jib)};sfb(xve,'UnmodifiableListIterator',2076);feb(399,2076,yve);_.Ob=function rc(){return this.c0};_.Pb=function tc(){if(this.c>=this.d){throw Adb(new Dvb)}return this.Xb(this.c++)};_.Tb=function uc(){return this.c};_.Ub=function vc(){if(this.c<=0){throw Adb(new Dvb)}return this.Xb(--this.c)};_.Vb=function wc(){return this.c-1};_.c=0;_.d=0;sfb(xve,'AbstractIndexedListIterator',399);feb(713,204,wve);_.Ob=function Ac(){return xc(this)};_.Pb=function Bc(){return yc(this)};_.e=1;sfb(xve,'AbstractIterator',713);feb(2084,1,{229:1});_.Zb=function Hc(){var a;return a=this.f,!a?(this.f=this.ac()):a};_.Fb=function Ic(a){return xw(this,a)};_.Hb=function Jc(){return tb(this.Zb())};_.dc=function Kc(){return this.gc()==0};_.ec=function Lc(){return Ec(this)};_.Ib=function Mc(){return jeb(this.Zb())};sfb(xve,'AbstractMultimap',2084);feb(742,2084,zve);_.$b=function Xc(){Nc(this);};_._b=function Yc(a){return Oc(this,a)};_.ac=function Zc(){return new ne(this,this.c)};_.ic=function $c(a){return this.hc()};_.bc=function _c(){return new zf(this,this.c)};_.jc=function ad(){return this.mc(this.hc())};_.kc=function bd(){return new Hd(this)};_.lc=function cd(){return ek(this.c.vc().Nc(),new hh,64,this.d)};_.cc=function dd(a){return Qc(this,a)};_.fc=function gd(a){return Sc(this,a)};_.gc=function hd(){return this.d};_.mc=function jd(a){return yob(),new xpb(a)};_.nc=function kd(){return new Dd(this)};_.oc=function ld(){return ek(this.c.Cc().Nc(),new Fd,64,this.d)};_.pc=function md(a,b){return new lg(this,a,b,null)};_.d=0;sfb(xve,'AbstractMapBasedMultimap',742);feb(1696,742,zve);_.hc=function pd(){return new cnb(this.a)};_.jc=function qd(){return yob(),yob(),vob};_.cc=function sd(a){return RD(Qc(this,a),15)};_.fc=function ud(a){return RD(Sc(this,a),15)};_.Zb=function od(){return nd(this)};_.Fb=function rd(a){return xw(this,a)};_.qc=function td(a){return RD(Qc(this,a),15)};_.rc=function vd(a){return RD(Sc(this,a),15)};_.mc=function wd(a){return Hob(RD(a,15))};_.pc=function xd(a,b){return Vc(this,a,RD(b,15),null)};sfb(xve,'AbstractListMultimap',1696);feb(748,1,Ave);_.Nb=function zd(a){Ztb(this,a);};_.Ob=function Ad(){return this.c.Ob()||this.e.Ob()};_.Pb=function Bd(){var a;if(!this.e.Ob()){a=RD(this.c.Pb(),44);this.b=a.ld();this.a=RD(a.md(),16);this.e=this.a.Kc();}return this.sc(this.b,this.e.Pb())};_.Qb=function Cd(){this.e.Qb();RD(Hvb(this.a),16).dc()&&this.c.Qb();--this.d.d;};sfb(xve,'AbstractMapBasedMultimap/Itr',748);feb(1129,748,Ave,Dd);_.sc=function Ed(a,b){return b};sfb(xve,'AbstractMapBasedMultimap/1',1129);feb(1130,1,{},Fd);_.Kb=function Gd(a){return RD(a,16).Nc()};sfb(xve,'AbstractMapBasedMultimap/1methodref$spliterator$Type',1130);feb(1131,748,Ave,Hd);_.sc=function Id(a,b){return new gp(a,b)};sfb(xve,'AbstractMapBasedMultimap/2',1131);var VK=ufb(Bve,'Map');feb(2065,1,Cve);_.wc=function Td(a){Bvb(this,a);};_.yc=function $d(a,b,c){return Cvb(this,a,b,c)};_.$b=function Od(){this.vc().$b();};_.tc=function Pd(a){return Jd(this,a)};_._b=function Qd(a){return !!Kd(this,a,false)};_.uc=function Rd(a){var b,c,d;for(c=this.vc().Kc();c.Ob();){b=RD(c.Pb(),44);d=b.md();if(dE(a)===dE(d)||a!=null&&pb(a,d)){return true}}return false};_.Fb=function Sd(a){var b,c,d;if(a===this){return true}if(!ZD(a,85)){return false}d=RD(a,85);if(this.gc()!=d.gc()){return false}for(c=d.vc().Kc();c.Ob();){b=RD(c.Pb(),44);if(!this.tc(b)){return false}}return true};_.xc=function Ud(a){return Wd(Kd(this,a,false))};_.Hb=function Xd(){return Bob(this.vc())};_.dc=function Yd(){return this.gc()==0};_.ec=function Zd(){return new Xkb(this)};_.zc=function _d(a,b){throw Adb(new kib('Put not supported on this map'))};_.Ac=function ae(a){Ld(this,a);};_.Bc=function be(a){return Wd(Kd(this,a,true))};_.gc=function ce(){return this.vc().gc()};_.Ib=function de(){return Md(this)};_.Cc=function ee(){return new glb(this)};sfb(Bve,'AbstractMap',2065);feb(2085,2065,Cve);_.bc=function ge(){return new rf(this)};_.vc=function he(){return fe(this)};_.ec=function ie(){var a;a=this.g;return !a?(this.g=this.bc()):a};_.Cc=function je(){var a;a=this.i;return !a?(this.i=new nw(this)):a};sfb(xve,'Maps/ViewCachingAbstractMap',2085);feb(402,2085,Cve,ne);_.xc=function se(a){return ke(this,a)};_.Bc=function ve(a){return le(this,a)};_.$b=function oe(){this.d==this.e.c?this.e.$b():Ar(new mf(this));};_._b=function pe(a){return Wv(this.d,a)};_.Ec=function qe(){return new df(this)};_.Dc=function(){return this.Ec()};_.Fb=function re(a){return this===a||pb(this.d,a)};_.Hb=function te(){return tb(this.d)};_.ec=function ue(){return this.e.ec()};_.gc=function we(){return this.d.gc()};_.Ib=function xe(){return jeb(this.d)};sfb(xve,'AbstractMapBasedMultimap/AsMap',402);var cJ=ufb(mve,'Iterable');feb(31,1,Dve);_.Jc=function Le(a){xgb(this,a);};_.Lc=function Ne(){return this.Oc()};_.Nc=function Pe(){return new Swb(this,0)};_.Oc=function Qe(){return new SDb(null,this.Nc())};_.Fc=function Ge(a){throw Adb(new kib('Add not supported on this collection'))};_.Gc=function He(a){return ye(this,a)};_.$b=function Ie(){Ae(this);};_.Hc=function Je(a){return ze(this,a,false)};_.Ic=function Ke(a){return Be(this,a)};_.dc=function Me(){return this.gc()==0};_.Mc=function Oe(a){return ze(this,a,true)};_.Pc=function Re(){return De(this)};_.Qc=function Se(a){return Ee(this,a)};_.Ib=function Te(){return Fe(this)};sfb(Bve,'AbstractCollection',31);var bL=ufb(Bve,'Set');feb(Eve,31,Fve);_.Nc=function Ye(){return new Swb(this,1)};_.Fb=function We(a){return Ue(this,a)};_.Hb=function Xe(){return Bob(this)};sfb(Bve,'AbstractSet',Eve);feb(2068,Eve,Fve);sfb(xve,'Sets/ImprovedAbstractSet',2068);feb(2069,2068,Fve);_.$b=function $e(){this.Rc().$b();};_.Hc=function _e(a){return Ze(this,a)};_.dc=function af(){return this.Rc().dc()};_.Mc=function bf(a){var b;if(this.Hc(a)&&ZD(a,44)){b=RD(a,44);return this.Rc().ec().Mc(b.ld())}return false};_.gc=function cf(){return this.Rc().gc()};sfb(xve,'Maps/EntrySet',2069);feb(1127,2069,Fve,df);_.Hc=function ef(a){return Nk(this.a.d.vc(),a)};_.Kc=function ff(){return new mf(this.a)};_.Rc=function gf(){return this.a};_.Mc=function hf(a){var b;if(!Nk(this.a.d.vc(),a)){return false}b=RD(Hvb(RD(a,44)),44);Tc(this.a.e,b.ld());return true};_.Nc=function jf(){return gk(this.a.d.vc().Nc(),new kf(this.a))};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapEntries',1127);feb(1128,1,{},kf);_.Kb=function lf(a){return me(this.a,RD(a,44))};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type',1128);feb(746,1,Ave,mf);_.Nb=function nf(a){Ztb(this,a);};_.Pb=function pf(){var a;return a=RD(this.b.Pb(),44),this.a=RD(a.md(),16),me(this.c,a)};_.Ob=function of(){return this.b.Ob()};_.Qb=function qf(){Vb(!!this.a);this.b.Qb();this.c.e.d-=this.a.gc();this.a.$b();this.a=null;};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapIterator',746);feb(542,2068,Fve,rf);_.$b=function sf(){this.b.$b();};_.Hc=function tf(a){return this.b._b(a)};_.Jc=function uf(a){Qb(a);this.b.wc(new lw(a));};_.dc=function vf(){return this.b.dc()};_.Kc=function wf(){return new aw(this.b.vc().Kc())};_.Mc=function xf(a){if(this.b._b(a)){this.b.Bc(a);return true}return false};_.gc=function yf(){return this.b.gc()};sfb(xve,'Maps/KeySet',542);feb(327,542,Fve,zf);_.$b=function Af(){var a;Ar((a=this.b.vc().Kc(),new Hf(this,a)));};_.Ic=function Bf(a){return this.b.ec().Ic(a)};_.Fb=function Cf(a){return this===a||pb(this.b.ec(),a)};_.Hb=function Df(){return tb(this.b.ec())};_.Kc=function Ef(){var a;return a=this.b.vc().Kc(),new Hf(this,a)};_.Mc=function Ff(a){var b,c;c=0;b=RD(this.b.Bc(a),16);if(b){c=b.gc();b.$b();this.a.d-=c;}return c>0};_.Nc=function Gf(){return this.b.ec().Nc()};sfb(xve,'AbstractMapBasedMultimap/KeySet',327);feb(747,1,Ave,Hf);_.Nb=function If(a){Ztb(this,a);};_.Ob=function Jf(){return this.c.Ob()};_.Pb=function Kf(){this.a=RD(this.c.Pb(),44);return this.a.ld()};_.Qb=function Lf(){var a;Vb(!!this.a);a=RD(this.a.md(),16);this.c.Qb();this.b.a.d-=a.gc();a.$b();this.a=null;};sfb(xve,'AbstractMapBasedMultimap/KeySet/1',747);feb(503,402,{85:1,133:1},Mf);_.bc=function Nf(){return this.Sc()};_.ec=function Qf(){return this.Uc()};_.Sc=function Of(){return new eg(this.c,this.Wc())};_.Tc=function Pf(){return this.Wc().Tc()};_.Uc=function Rf(){var a;return a=this.b,!a?(this.b=this.Sc()):a};_.Vc=function Sf(){return this.Wc().Vc()};_.Wc=function Tf(){return RD(this.d,133)};sfb(xve,'AbstractMapBasedMultimap/SortedAsMap',503);feb(446,503,Gve,Uf);_.bc=function Wf(){return new gg(this.a,RD(RD(this.d,133),139))};_.Sc=function Xf(){return new gg(this.a,RD(RD(this.d,133),139))};_.ec=function _f(){var a;return a=this.b,RD(!a?(this.b=new gg(this.a,RD(RD(this.d,133),139))):a,277)};_.Uc=function ag(){var a;return a=this.b,RD(!a?(this.b=new gg(this.a,RD(RD(this.d,133),139))):a,277)};_.Wc=function cg(){return RD(RD(this.d,133),139)};_.Xc=function Vf(a){return RD(RD(this.d,133),139).Xc(a)};_.Yc=function Yf(a){return RD(RD(this.d,133),139).Yc(a)};_.Zc=function Zf(a,b){return new Uf(this.a,RD(RD(this.d,133),139).Zc(a,b))};_.$c=function $f(a){return RD(RD(this.d,133),139).$c(a)};_._c=function bg(a){return RD(RD(this.d,133),139)._c(a)};_.ad=function dg(a,b){return new Uf(this.a,RD(RD(this.d,133),139).ad(a,b))};sfb(xve,'AbstractMapBasedMultimap/NavigableAsMap',446);feb(502,327,Hve,eg);_.Nc=function fg(){return this.b.ec().Nc()};sfb(xve,'AbstractMapBasedMultimap/SortedKeySet',502);feb(401,502,Ive,gg);sfb(xve,'AbstractMapBasedMultimap/NavigableKeySet',401);feb(551,31,Dve,lg);_.Fc=function mg(a){var b,c;ig(this);c=this.d.dc();b=this.d.Fc(a);if(b){++this.f.d;c&&hg(this);}return b};_.Gc=function ng(a){var b,c,d;if(a.dc()){return false}d=(ig(this),this.d.gc());b=this.d.Gc(a);if(b){c=this.d.gc();this.f.d+=c-d;d==0&&hg(this);}return b};_.$b=function og(){var a;a=(ig(this),this.d.gc());if(a==0){return}this.d.$b();this.f.d-=a;jg(this);};_.Hc=function pg(a){ig(this);return this.d.Hc(a)};_.Ic=function qg(a){ig(this);return this.d.Ic(a)};_.Fb=function rg(a){if(a===this){return true}ig(this);return pb(this.d,a)};_.Hb=function sg(){ig(this);return tb(this.d)};_.Kc=function tg(){ig(this);return new Og(this)};_.Mc=function ug(a){var b;ig(this);b=this.d.Mc(a);if(b){--this.f.d;jg(this);}return b};_.gc=function vg(){return kg(this)};_.Nc=function wg(){return ig(this),this.d.Nc()};_.Ib=function xg(){ig(this);return jeb(this.d)};sfb(xve,'AbstractMapBasedMultimap/WrappedCollection',551);var QK=ufb(Bve,'List');feb(744,551,{20:1,31:1,16:1,15:1},yg);_.jd=function Hg(a){tvb(this,a);};_.Nc=function Ig(){return ig(this),this.d.Nc()};_.bd=function zg(a,b){var c;ig(this);c=this.d.dc();RD(this.d,15).bd(a,b);++this.a.d;c&&hg(this);};_.cd=function Ag(a,b){var c,d,e;if(b.dc()){return false}e=(ig(this),this.d.gc());c=RD(this.d,15).cd(a,b);if(c){d=this.d.gc();this.a.d+=d-e;e==0&&hg(this);}return c};_.Xb=function Bg(a){ig(this);return RD(this.d,15).Xb(a)};_.dd=function Cg(a){ig(this);return RD(this.d,15).dd(a)};_.ed=function Dg(){ig(this);return new Ug(this)};_.fd=function Eg(a){ig(this);return new Vg(this,a)};_.gd=function Fg(a){var b;ig(this);b=RD(this.d,15).gd(a);--this.a.d;jg(this);return b};_.hd=function Gg(a,b){ig(this);return RD(this.d,15).hd(a,b)};_.kd=function Jg(a,b){ig(this);return Vc(this.a,this.e,RD(this.d,15).kd(a,b),!this.b?this:this.b)};sfb(xve,'AbstractMapBasedMultimap/WrappedList',744);feb(1126,744,{20:1,31:1,16:1,15:1,59:1},Kg);sfb(xve,'AbstractMapBasedMultimap/RandomAccessWrappedList',1126);feb(628,1,Ave,Og);_.Nb=function Qg(a){Ztb(this,a);};_.Ob=function Rg(){Ng(this);return this.b.Ob()};_.Pb=function Sg(){Ng(this);return this.b.Pb()};_.Qb=function Tg(){Mg(this);};sfb(xve,'AbstractMapBasedMultimap/WrappedCollection/WrappedIterator',628);feb(745,628,Jve,Ug,Vg);_.Qb=function _g(){Mg(this);};_.Rb=function Wg(a){var b;b=kg(this.a)==0;(Ng(this),RD(this.b,128)).Rb(a);++this.a.a.d;b&&hg(this.a);};_.Sb=function Xg(){return (Ng(this),RD(this.b,128)).Sb()};_.Tb=function Yg(){return (Ng(this),RD(this.b,128)).Tb()};_.Ub=function Zg(){return (Ng(this),RD(this.b,128)).Ub()};_.Vb=function $g(){return (Ng(this),RD(this.b,128)).Vb()};_.Wb=function ah(a){(Ng(this),RD(this.b,128)).Wb(a);};sfb(xve,'AbstractMapBasedMultimap/WrappedList/WrappedListIterator',745);feb(743,551,Hve,bh);_.Nc=function dh(){return ig(this),this.d.Nc()};sfb(xve,'AbstractMapBasedMultimap/WrappedSortedSet',743);feb(1125,743,Ive,eh);sfb(xve,'AbstractMapBasedMultimap/WrappedNavigableSet',1125);feb(1124,551,Fve,fh);_.Nc=function gh(){return ig(this),this.d.Nc()};sfb(xve,'AbstractMapBasedMultimap/WrappedSet',1124);feb(1133,1,{},hh);_.Kb=function ih(a){return fd(RD(a,44))};sfb(xve,'AbstractMapBasedMultimap/lambda$1$Type',1133);feb(1132,1,{},jh);_.Kb=function kh(a){return new gp(this.a,a)};sfb(xve,'AbstractMapBasedMultimap/lambda$2$Type',1132);var UK=ufb(Bve,'Map/Entry');feb(358,1,Kve);_.Fb=function lh(a){var b;if(ZD(a,44)){b=RD(a,44);return Hb(this.ld(),b.ld())&&Hb(this.md(),b.md())}return false};_.Hb=function mh(){var a,b;a=this.ld();b=this.md();return (a==null?0:tb(a))^(b==null?0:tb(b))};_.nd=function nh(a){throw Adb(new jib)};_.Ib=function oh(){return this.ld()+'='+this.md()};sfb(xve,Lve,358);feb(2086,31,Dve);_.$b=function ph(){this.od().$b();};_.Hc=function qh(a){var b;if(ZD(a,44)){b=RD(a,44);return Cc(this.od(),b.ld(),b.md())}return false};_.Mc=function rh(a){var b;if(ZD(a,44)){b=RD(a,44);return Gc(this.od(),b.ld(),b.md())}return false};_.gc=function sh(){return this.od().d};sfb(xve,'Multimaps/Entries',2086);feb(749,2086,Dve,th);_.Kc=function uh(){return this.a.kc()};_.od=function vh(){return this.a};_.Nc=function wh(){return this.a.lc()};sfb(xve,'AbstractMultimap/Entries',749);feb(750,749,Fve,xh);_.Nc=function Ah(){return this.a.lc()};_.Fb=function yh(a){return Rx(this,a)};_.Hb=function zh(){return Sx(this)};sfb(xve,'AbstractMultimap/EntrySet',750);feb(751,31,Dve,Bh);_.$b=function Ch(){this.a.$b();};_.Hc=function Dh(a){return Dc(this.a,a)};_.Kc=function Eh(){return this.a.nc()};_.gc=function Fh(){return this.a.d};_.Nc=function Gh(){return this.a.oc()};sfb(xve,'AbstractMultimap/Values',751);feb(2087,31,{849:1,20:1,31:1,16:1});_.Jc=function Oh(a){Qb(a);Ih(this).Jc(new lx(a));};_.Nc=function Sh(){var a;return a=Ih(this).Nc(),ek(a,new sx,64|a.yd()&1296,this.a.d)};_.Fc=function Kh(a){Hh();return true};_.Gc=function Lh(a){return Qb(this),Qb(a),ZD(a,552)?nx(RD(a,849)):!a.dc()&&xr(this,a.Kc())};_.Hc=function Mh(a){var b;return b=RD(Xv(nd(this.a),a),16),(!b?0:b.gc())>0};_.Fb=function Nh(a){return ox(this,a)};_.Hb=function Ph(){return tb(Ih(this))};_.dc=function Qh(){return Ih(this).dc()};_.Mc=function Rh(a){return Rw(this,a,1)>0};_.Ib=function Th(){return jeb(Ih(this))};sfb(xve,'AbstractMultiset',2087);feb(2089,2068,Fve);_.$b=function Uh(){Nc(this.a.a);};_.Hc=function Vh(a){var b,c;if(ZD(a,504)){c=RD(a,425);if(RD(c.a.md(),16).gc()<=0){return false}b=Qw(this.a,c.a.ld());return b==RD(c.a.md(),16).gc()}return false};_.Mc=function Wh(a){var b,c,d,e;if(ZD(a,504)){c=RD(a,425);b=c.a.ld();d=RD(c.a.md(),16).gc();if(d!=0){e=this.a;return qx(e,b,d)}}return false};sfb(xve,'Multisets/EntrySet',2089);feb(1139,2089,Fve,Xh);_.Kc=function Yh(){return new _w(fe(nd(this.a.a)).Kc())};_.gc=function Zh(){return nd(this.a.a).gc()};sfb(xve,'AbstractMultiset/EntrySet',1139);feb(627,742,zve);_.hc=function ai(){return this.pd()};_.jc=function bi(){return this.qd()};_.cc=function ei(a){return this.rd(a)};_.fc=function gi(a){return this.sd(a)};_.Zb=function _h(){var a;return a=this.f,!a?(this.f=this.ac()):a};_.qd=function ci(){return yob(),yob(),xob};_.Fb=function di(a){return xw(this,a)};_.rd=function fi(a){return RD(Qc(this,a),21)};_.sd=function hi(a){return RD(Sc(this,a),21)};_.mc=function ii(a){return yob(),new Lqb(RD(a,21))};_.pc=function ji(a,b){return new fh(this,a,RD(b,21))};sfb(xve,'AbstractSetMultimap',627);feb(1723,627,zve);_.hc=function mi(){return new yAb(this.b)};_.pd=function ni(){return new yAb(this.b)};_.jc=function oi(){return Zx(new yAb(this.b))};_.qd=function pi(){return Zx(new yAb(this.b))};_.cc=function qi(a){return RD(RD(Qc(this,a),21),87)};_.rd=function ri(a){return RD(RD(Qc(this,a),21),87)};_.fc=function si(a){return RD(RD(Sc(this,a),21),87)};_.sd=function ti(a){return RD(RD(Sc(this,a),21),87)};_.mc=function ui(a){return ZD(a,277)?Zx(RD(a,277)):(yob(),new jrb(RD(a,87)))};_.Zb=function li(){var a;return a=this.f,!a?(this.f=ZD(this.c,139)?new Uf(this,RD(this.c,139)):ZD(this.c,133)?new Mf(this,RD(this.c,133)):new ne(this,this.c)):a};_.pc=function vi(a,b){return ZD(b,277)?new eh(this,a,RD(b,277)):new bh(this,a,RD(b,87))};sfb(xve,'AbstractSortedSetMultimap',1723);feb(1724,1723,zve);_.Zb=function xi(){var a;return a=this.f,RD(RD(!a?(this.f=ZD(this.c,139)?new Uf(this,RD(this.c,139)):ZD(this.c,133)?new Mf(this,RD(this.c,133)):new ne(this,this.c)):a,133),139)};_.ec=function zi(){var a;return a=this.i,RD(RD(!a?(this.i=ZD(this.c,139)?new gg(this,RD(this.c,139)):ZD(this.c,133)?new eg(this,RD(this.c,133)):new zf(this,this.c)):a,87),277)};_.bc=function yi(){return ZD(this.c,139)?new gg(this,RD(this.c,139)):ZD(this.c,133)?new eg(this,RD(this.c,133)):new zf(this,this.c)};sfb(xve,'AbstractSortedKeySortedSetMultimap',1724);feb(2109,1,{2046:1});_.Fb=function Ai(a){return Qy(this,a)};_.Hb=function Bi(){var a;return Bob((a=this.g,!a?(this.g=new Di(this)):a))};_.Ib=function Ci(){var a;return Md((a=this.f,!a?(this.f=new Zj(this)):a))};sfb(xve,'AbstractTable',2109);feb(679,Eve,Fve,Di);_.$b=function Ei(){Xi();};_.Hc=function Fi(a){var b,c;if(ZD(a,479)){b=RD(a,697);c=RD(Xv(bj(this.a),Qm(b.c.e,b.b)),85);return !!c&&Nk(c.vc(),new gp(Qm(b.c.c,b.a),Ui(b.c,b.b,b.a)))}return false};_.Kc=function Gi(){return Vi(this.a)};_.Mc=function Hi(a){var b,c;if(ZD(a,479)){b=RD(a,697);c=RD(Xv(bj(this.a),Qm(b.c.e,b.b)),85);return !!c&&Ok(c.vc(),new gp(Qm(b.c.c,b.a),Ui(b.c,b.b,b.a)))}return false};_.gc=function Ii(){return dj(this.a)};_.Nc=function Ji(){return Wi(this.a)};sfb(xve,'AbstractTable/CellSet',679);feb(2025,31,Dve,Ki);_.$b=function Li(){Xi();};_.Hc=function Mi(a){return Yi(this.a,a)};_.Kc=function Ni(){return fj(this.a)};_.gc=function Oi(){return dj(this.a)};_.Nc=function Pi(){return gj(this.a)};sfb(xve,'AbstractTable/Values',2025);feb(1697,1696,zve);sfb(xve,'ArrayListMultimapGwtSerializationDependencies',1697);feb(520,1697,zve,Ri,Si);_.hc=function Ti(){return new cnb(this.a)};_.a=0;sfb(xve,'ArrayListMultimap',520);feb(678,2109,{678:1,2046:1,3:1},hj);sfb(xve,'ArrayTable',678);feb(2021,399,yve,ij);_.Xb=function jj(a){return new pj(this.a,a)};sfb(xve,'ArrayTable/1',2021);feb(2022,1,{},kj);_.td=function lj(a){return new pj(this.a,a)};sfb(xve,'ArrayTable/1methodref$getCell$Type',2022);feb(2110,1,{697:1});_.Fb=function mj(a){var b;if(a===this){return true}if(ZD(a,479)){b=RD(a,697);return Hb(Qm(this.c.e,this.b),Qm(b.c.e,b.b))&&Hb(Qm(this.c.c,this.a),Qm(b.c.c,b.a))&&Hb(Ui(this.c,this.b,this.a),Ui(b.c,b.b,b.a))}return false};_.Hb=function nj(){return Tnb(cD(WC(jJ,1),rve,1,5,[Qm(this.c.e,this.b),Qm(this.c.c,this.a),Ui(this.c,this.b,this.a)]))};_.Ib=function oj(){return '('+Qm(this.c.e,this.b)+','+Qm(this.c.c,this.a)+')='+Ui(this.c,this.b,this.a)};sfb(xve,'Tables/AbstractCell',2110);feb(479,2110,{479:1,697:1},pj);_.a=0;_.b=0;_.d=0;sfb(xve,'ArrayTable/2',479);feb(2024,1,{},qj);_.td=function rj(a){return _i(this.a,a)};sfb(xve,'ArrayTable/2methodref$getValue$Type',2024);feb(2023,399,yve,sj);_.Xb=function tj(a){return _i(this.a,a)};sfb(xve,'ArrayTable/3',2023);feb(2077,2065,Cve);_.$b=function vj(){Ar(this.kc());};_.vc=function wj(){return new gw(this)};_.lc=function xj(){return new Uwb(this.kc(),this.gc())};sfb(xve,'Maps/IteratorBasedAbstractMap',2077);feb(842,2077,Cve);_.$b=function Bj(){throw Adb(new jib)};_._b=function Cj(a){return En(this.c,a)};_.kc=function Dj(){return new Rj(this,this.c.b.c.gc())};_.lc=function Ej(){return fk(this.c.b.c.gc(),16,new Lj(this))};_.xc=function Fj(a){var b;b=RD(Fn(this.c,a),17);return !b?null:this.vd(b.a)};_.dc=function Gj(){return this.c.b.c.dc()};_.ec=function Hj(){return hn(this.c)};_.zc=function Ij(a,b){var c;c=RD(Fn(this.c,a),17);if(!c){throw Adb(new agb(this.ud()+' '+a+' not in '+hn(this.c)))}return this.wd(c.a,b)};_.Bc=function Jj(a){throw Adb(new jib)};_.gc=function Kj(){return this.c.b.c.gc()};sfb(xve,'ArrayTable/ArrayMap',842);feb(2020,1,{},Lj);_.td=function Mj(a){return yj(this.a,a)};sfb(xve,'ArrayTable/ArrayMap/0methodref$getEntry$Type',2020);feb(2018,358,Kve,Nj);_.ld=function Oj(){return zj(this.a,this.b)};_.md=function Pj(){return this.a.vd(this.b)};_.nd=function Qj(a){return this.a.wd(this.b,a)};_.b=0;sfb(xve,'ArrayTable/ArrayMap/1',2018);feb(2019,399,yve,Rj);_.Xb=function Sj(a){return yj(this.a,a)};sfb(xve,'ArrayTable/ArrayMap/2',2019);feb(2017,842,Cve,Tj);_.ud=function Uj(){return 'Column'};_.vd=function Vj(a){return Ui(this.b,this.a,a)};_.wd=function Wj(a,b){return cj(this.b,this.a,a,b)};_.a=0;sfb(xve,'ArrayTable/Row',2017);feb(843,842,Cve,Zj);_.vd=function _j(a){return new Tj(this.a,a)};_.zc=function ak(a,b){return RD(b,85),Xj()};_.wd=function bk(a,b){return RD(b,85),Yj()};_.ud=function $j(){return 'Row'};sfb(xve,'ArrayTable/RowMap',843);feb(1157,1,Pve,hk);_.Ad=function lk(a){return (this.a.yd()&-262&a)!=0};_.yd=function ik(){return this.a.yd()&-262};_.zd=function jk(){return this.a.zd()};_.Nb=function kk(a){this.a.Nb(new pk(a,this.b));};_.Bd=function mk(a){return this.a.Bd(new nk(a,this.b))};sfb(xve,'CollectSpliterators/1',1157);feb(1158,1,Qve,nk);_.Cd=function ok(a){this.a.Cd(this.b.Kb(a));};sfb(xve,'CollectSpliterators/1/lambda$0$Type',1158);feb(1159,1,Qve,pk);_.Cd=function qk(a){this.a.Cd(this.b.Kb(a));};sfb(xve,'CollectSpliterators/1/lambda$1$Type',1159);feb(1154,1,Pve,rk);_.Ad=function vk(a){return ((16464|this.b)&a)!=0};_.yd=function sk(){return 16464|this.b};_.zd=function tk(){return this.a.zd()};_.Nb=function uk(a){this.a.Qe(new zk(a,this.c));};_.Bd=function wk(a){return this.a.Re(new xk(a,this.c))};_.b=0;sfb(xve,'CollectSpliterators/1WithCharacteristics',1154);feb(1155,1,Rve,xk);_.Dd=function yk(a){this.a.Cd(this.b.td(a));};sfb(xve,'CollectSpliterators/1WithCharacteristics/lambda$0$Type',1155);feb(1156,1,Rve,zk);_.Dd=function Ak(a){this.a.Cd(this.b.td(a));};sfb(xve,'CollectSpliterators/1WithCharacteristics/lambda$1$Type',1156);feb(1150,1,Pve);_.Ad=function Gk(a){return (this.a&a)!=0};_.yd=function Dk(){return this.a};_.zd=function Ek(){!!this.e&&(this.b=Kgb(this.b,this.e.zd()));return Kgb(this.b,0)};_.Nb=function Fk(a){if(this.e){this.e.Nb(a);this.e=null;}this.c.Nb(new Kk(this,a));this.b=0;};_.Bd=function Hk(a){while(true){if(!!this.e&&this.e.Bd(a)){Pdb(this.b,Sve)&&(this.b=Vdb(this.b,1));return true}else {this.e=null;}if(!this.c.Bd(new Ik(this))){return false}}};_.a=0;_.b=0;sfb(xve,'CollectSpliterators/FlatMapSpliterator',1150);feb(1152,1,Qve,Ik);_.Cd=function Jk(a){Bk(this.a,a);};sfb(xve,'CollectSpliterators/FlatMapSpliterator/lambda$0$Type',1152);feb(1153,1,Qve,Kk);_.Cd=function Lk(a){Ck(this.a,this.b,a);};sfb(xve,'CollectSpliterators/FlatMapSpliterator/lambda$1$Type',1153);feb(1151,1150,Pve,Mk);sfb(xve,'CollectSpliterators/FlatMapSpliteratorOfObject',1151);feb(253,1,Tve);_.Fd=function Sk(a){return this.Ed(RD(a,253))};_.Ed=function Rk(a){var b;if(a==(kl(),jl)){return 1}if(a==(Wk(),Vk)){return -1}b=(ux(),Leb(this.a,a.a));if(b!=0){return b}return ZD(this,526)==ZD(a,526)?0:ZD(this,526)?1:-1};_.Id=function Tk(){return this.a};_.Fb=function Uk(a){return Pk(this,a)};sfb(xve,'Cut',253);feb(1823,253,Tve,Xk);_.Ed=function Yk(a){return a==this?0:1};_.Gd=function Zk(a){throw Adb(new Ceb)};_.Hd=function $k(a){a.a+='+\u221E)';};_.Id=function _k(){throw Adb(new dgb(Uve))};_.Hb=function al(){return gib(),jFb(this)};_.Jd=function bl(a){return false};_.Ib=function cl(){return '+\u221E'};var Vk;sfb(xve,'Cut/AboveAll',1823);feb(526,253,{253:1,526:1,3:1,34:1},dl);_.Gd=function el(a){Yhb((a.a+='(',a),this.a);};_.Hd=function fl(a){Thb(Yhb(a,this.a),93);};_.Hb=function gl(){return ~tb(this.a)};_.Jd=function hl(a){return ux(),Leb(this.a,a)<0};_.Ib=function il(){return '/'+this.a+'\\'};sfb(xve,'Cut/AboveValue',526);feb(1822,253,Tve,ll);_.Ed=function ml(a){return a==this?0:-1};_.Gd=function nl(a){a.a+='(-\u221E';};_.Hd=function ol(a){throw Adb(new Ceb)};_.Id=function pl(){throw Adb(new dgb(Uve))};_.Hb=function ql(){return gib(),jFb(this)};_.Jd=function rl(a){return true};_.Ib=function sl(){return '-\u221E'};var jl;sfb(xve,'Cut/BelowAll',1822);feb(1824,253,Tve,tl);_.Gd=function ul(a){Yhb((a.a+='[',a),this.a);};_.Hd=function vl(a){Thb(Yhb(a,this.a),41);};_.Hb=function wl(){return tb(this.a)};_.Jd=function xl(a){return ux(),Leb(this.a,a)<=0};_.Ib=function yl(){return '\\'+this.a+'/'};sfb(xve,'Cut/BelowValue',1824);feb(547,1,Vve);_.Jc=function Bl(a){xgb(this,a);};_.Ib=function Cl(){return Lr(RD(Rb(this,'use Optional.orNull() instead of Optional.or(null)'),20).Kc())};sfb(xve,'FluentIterable',547);feb(442,547,Vve,Dl);_.Kc=function El(){return new is(Mr(this.a.Kc(),new ir))};sfb(xve,'FluentIterable/2',442);feb(1059,547,Vve,Gl);_.Kc=function Hl(){return Fl(this)};sfb(xve,'FluentIterable/3',1059);feb(724,399,yve,Il);_.Xb=function Jl(a){return this.a[a].Kc()};sfb(xve,'FluentIterable/3/1',724);feb(2070,1,{});_.Ib=function Kl(){return jeb(this.Kd().b)};sfb(xve,'ForwardingObject',2070);feb(2071,2070,Wve);_.Kd=function Ql(){return this.Ld()};_.Jc=function Rl(a){xgb(this,a);};_.Lc=function Ul(){return this.Oc()};_.Nc=function Xl(){return new Swb(this,0)};_.Oc=function Yl(){return new SDb(null,this.Nc())};_.Fc=function Ll(a){return this.Ld(),qpb()};_.Gc=function Ml(a){return this.Ld(),rpb()};_.$b=function Nl(){this.Ld(),spb();};_.Hc=function Ol(a){return this.Ld().Hc(a)};_.Ic=function Pl(a){return this.Ld().Ic(a)};_.dc=function Sl(){return this.Ld().b.dc()};_.Kc=function Tl(){return this.Ld().Kc()};_.Mc=function Vl(a){return this.Ld(),vpb()};_.gc=function Wl(){return this.Ld().b.gc()};_.Pc=function Zl(){return this.Ld().Pc()};_.Qc=function $l(a){return this.Ld().Qc(a)};sfb(xve,'ForwardingCollection',2071);feb(2078,31,Xve);_.Kc=function gm(){return this.Od()};_.Fc=function am(a){throw Adb(new jib)};_.Gc=function bm(a){throw Adb(new jib)};_.Md=function cm(){var a;a=this.c;return !a?(this.c=this.Nd()):a};_.$b=function dm(){throw Adb(new jib)};_.Hc=function em(a){return a!=null&&ze(this,a,false)};_.Nd=function fm(){switch(this.gc()){case 0:return tm(),tm(),sm;case 1:return tm(),new Dy(Qb(this.Od().Pb()));default:return new Fx(this,this.Pc());}};_.Mc=function hm(a){throw Adb(new jib)};sfb(xve,'ImmutableCollection',2078);feb(727,2078,Xve,im);_.Kc=function nm(){return Nr(this.a.Kc())};_.Hc=function jm(a){return a!=null&&this.a.Hc(a)};_.Ic=function km(a){return this.a.Ic(a)};_.dc=function lm(){return this.a.dc()};_.Od=function mm(){return Nr(this.a.Kc())};_.gc=function om(){return this.a.gc()};_.Pc=function pm(){return this.a.Pc()};_.Qc=function qm(a){return this.a.Qc(a)};_.Ib=function rm(){return jeb(this.a)};sfb(xve,'ForwardingImmutableCollection',727);feb(307,2078,Yve);_.Kc=function Em(){return this.Od()};_.ed=function Fm(){return this.Pd(0)};_.fd=function Hm(a){return this.Pd(a)};_.jd=function Lm(a){tvb(this,a);};_.Nc=function Mm(){return new Swb(this,16)};_.kd=function Om(a,b){return this.Qd(a,b)};_.bd=function wm(a,b){throw Adb(new jib)};_.cd=function xm(a,b){throw Adb(new jib)};_.Md=function ym(){return this};_.Fb=function Am(a){return $u(this,a)};_.Hb=function Bm(){return _u(this)};_.dd=function Cm(a){return a==null?-1:av(this,a)};_.Od=function Dm(){return this.Pd(0)};_.Pd=function Gm(a){return um(this,a)};_.gd=function Jm(a){throw Adb(new jib)};_.hd=function Km(a,b){throw Adb(new jib)};_.Qd=function Nm(a,b){var c;return Pm((c=new pv(this),new Rkb(c,a,b)))};var sm;sfb(xve,'ImmutableList',307);feb(2105,307,Yve);_.Kc=function Zm(){return Nr(this.Rd().Kc())};_.kd=function an(a,b){return Pm(this.Rd().kd(a,b))};_.Hc=function Rm(a){return a!=null&&this.Rd().Hc(a)};_.Ic=function Sm(a){return this.Rd().Ic(a)};_.Fb=function Tm(a){return pb(this.Rd(),a)};_.Xb=function Um(a){return Qm(this,a)};_.Hb=function Vm(){return tb(this.Rd())};_.dd=function Wm(a){return this.Rd().dd(a)};_.dc=function Xm(){return this.Rd().dc()};_.Od=function Ym(){return Nr(this.Rd().Kc())};_.gc=function $m(){return this.Rd().gc()};_.Qd=function _m(a,b){return Pm(this.Rd().kd(a,b))};_.Pc=function bn(){return this.Rd().Qc($C(jJ,rve,1,this.Rd().gc(),5,1))};_.Qc=function cn(a){return this.Rd().Qc(a)};_.Ib=function dn(){return jeb(this.Rd())};sfb(xve,'ForwardingImmutableList',2105);feb(729,1,$ve);_.vc=function pn(){return gn(this)};_.wc=function rn(a){Bvb(this,a);};_.ec=function vn(){return hn(this)};_.yc=function wn(a,b,c){return Cvb(this,a,b,c)};_.Cc=function Dn(){return this.Vd()};_.$b=function kn(){throw Adb(new jib)};_._b=function ln(a){return this.xc(a)!=null};_.uc=function mn(a){return this.Vd().Hc(a)};_.Td=function nn(){return new xq(this)};_.Ud=function on(){return new Gq(this)};_.Fb=function qn(a){return Tv(this,a)};_.Hb=function tn(){return gn(this).Hb()};_.dc=function un(){return this.gc()==0};_.zc=function zn(a,b){return jn()};_.Bc=function An(a){throw Adb(new jib)};_.Ib=function Bn(){return Zv(this)};_.Vd=function Cn(){if(this.e){return this.e}return this.e=this.Ud()};_.c=null;_.d=null;_.e=null;var en;sfb(xve,'ImmutableMap',729);feb(730,729,$ve);_._b=function Hn(a){return En(this,a)};_.uc=function In(a){return pqb(this.b,a)};_.Sd=function Jn(){return go(new Xn(this))};_.Td=function Kn(){return go(sqb(this.b))};_.Ud=function Ln(){return _l(),new im(tqb(this.b))};_.Fb=function Mn(a){return rqb(this.b,a)};_.xc=function Nn(a){return Fn(this,a)};_.Hb=function On(){return tb(this.b.c)};_.dc=function Pn(){return this.b.c.dc()};_.gc=function Qn(){return this.b.c.gc()};_.Ib=function Rn(){return jeb(this.b.c)};sfb(xve,'ForwardingImmutableMap',730);feb(2072,2071,_ve);_.Kd=function Sn(){return this.Wd()};_.Ld=function Tn(){return this.Wd()};_.Nc=function Wn(){return new Swb(this,1)};_.Fb=function Un(a){return a===this||this.Wd().Fb(a)};_.Hb=function Vn(){return this.Wd().Hb()};sfb(xve,'ForwardingSet',2072);feb(1085,2072,_ve,Xn);_.Kd=function Zn(){return qqb(this.a.b)};_.Ld=function $n(){return qqb(this.a.b)};_.Hc=function Yn(b){if(ZD(b,44)&&RD(b,44).ld()==null){return false}try{return Pqb(qqb(this.a.b),b)}catch(a){a=zdb(a);if(ZD(a,212)){return false}else throw Adb(a)}};_.Wd=function _n(){return qqb(this.a.b)};_.Qc=function ao(a){var b;b=Qqb(qqb(this.a.b),a);qqb(this.a.b).b.gc()=0?'+':'')+(c/60|0);b=AB($wnd.Math.abs(c)%60);return (Mrb(),Krb)[this.q.getDay()]+' '+Lrb[this.q.getMonth()]+' '+AB(this.q.getDate())+' '+AB(this.q.getHours())+':'+AB(this.q.getMinutes())+':'+AB(this.q.getSeconds())+' GMT'+a+b+' '+this.q.getFullYear()};var qK=sfb(Bve,'Date',206);feb(2015,206,bxe,DB);_.a=false;_.b=0;_.c=0;_.d=0;_.e=0;_.f=0;_.g=false;_.i=0;_.j=0;_.k=0;_.n=0;_.o=0;_.p=0;sfb('com.google.gwt.i18n.shared.impl','DateRecord',2015);feb(2064,1,{});_.pe=function EB(){return null};_.qe=function FB(){return null};_.re=function GB(){return null};_.se=function HB(){return null};_.te=function IB(){return null};sfb(cxe,'JSONValue',2064);feb(221,2064,{221:1},MB,NB);_.Fb=function OB(a){if(!ZD(a,221)){return false}return Hz(this.a,RD(a,221).a)};_.oe=function PB(){return TB};_.Hb=function QB(){return Iz(this.a)};_.pe=function RB(){return this};_.Ib=function SB(){var a,b,c;c=new dib('[');for(b=0,a=this.a.length;b0&&(c.a+=',',c);Yhb(c,JB(this,b));}c.a+=']';return c.a};sfb(cxe,'JSONArray',221);feb(493,2064,{493:1},XB);_.oe=function YB(){return _B};_.qe=function ZB(){return this};_.Ib=function $B(){return Geb(),''+this.a};_.a=false;var UB,VB;sfb(cxe,'JSONBoolean',493);feb(997,63,swe,aC);sfb(cxe,'JSONException',997);feb(1036,2064,{},dC);_.oe=function eC(){return gC};_.Ib=function fC(){return vve};var bC;sfb(cxe,'JSONNull',1036);feb(263,2064,{263:1},hC);_.Fb=function iC(a){if(!ZD(a,263)){return false}return this.a==RD(a,263).a};_.oe=function jC(){return nC};_.Hb=function kC(){return Nfb(this.a)};_.re=function lC(){return this};_.Ib=function mC(){return this.a+''};_.a=0;sfb(cxe,'JSONNumber',263);feb(190,2064,{190:1},uC,vC);_.Fb=function wC(a){if(!ZD(a,190)){return false}return Hz(this.a,RD(a,190).a)};_.oe=function xC(){return BC};_.Hb=function yC(){return Iz(this.a)};_.se=function zC(){return this};_.Ib=function AC(){var a,b,c,d,e,f,g;g=new dib('{');a=true;f=oC(this,$C(qJ,Nve,2,0,6,1));for(c=f,d=0,e=c.length;d=0?':'+this.c:'')+')'};_.c=0;var mJ=sfb(mve,'StackTraceElement',319);PD={3:1,484:1,34:1,2:1};var qJ=sfb(mve,uwe,2);feb(111,427,{484:1},Qhb,Rhb,Shb);sfb(mve,'StringBuffer',111);feb(104,427,{484:1},bib,cib,dib);sfb(mve,'StringBuilder',104);feb(702,77,lxe,eib);sfb(mve,'StringIndexOutOfBoundsException',702);feb(2145,1,{});var fib;feb(48,63,{3:1,103:1,63:1,82:1,48:1},jib,kib);sfb(mve,'UnsupportedOperationException',48);feb(247,242,{3:1,34:1,242:1,247:1},Aib,Bib);_.Fd=function Eib(a){return uib(this,RD(a,247))};_.ue=function Fib(){return Neb(zib(this))};_.Fb=function Gib(a){var b;if(this===a){return true}if(ZD(a,247)){b=RD(a,247);return this.e==b.e&&uib(this,b)==0}return false};_.Hb=function Hib(){var a;if(this.b!=0){return this.b}if(this.a<54){a=Hdb(this.f);this.b=Ydb(Cdb(a,-1));this.b=33*this.b+Ydb(Cdb(Tdb(a,32),-1));this.b=17*this.b+eE(this.e);return this.b}this.b=17*Vib(this.c)+eE(this.e);return this.b};_.Ib=function Iib(){return zib(this)};_.a=0;_.b=0;_.d=0;_.e=0;_.f=0;var lib,mib,nib,oib,pib,qib,rib,sib;var tJ=sfb('java.math','BigDecimal',247);feb(92,242,{3:1,34:1,242:1,92:1},ajb,bjb,cjb,djb,ejb);_.Fd=function gjb(a){return Qib(this,RD(a,92))};_.ue=function hjb(){return Neb(Ajb(this,0))};_.Fb=function ijb(a){return Sib(this,a)};_.Hb=function ljb(){return Vib(this)};_.Ib=function njb(){return Ajb(this,0)};_.b=-2;_.c=0;_.d=0;_.e=0;var Jib,Kib,Lib,Mib,Nib,Oib;var uJ=sfb('java.math','BigInteger',92);var vjb,wjb;var Jjb,Kjb;feb(498,2065,Cve);_.$b=function dkb(){akb(this);};_._b=function ekb(a){return Ujb(this,a)};_.uc=function fkb(a){return Vjb(this,a,this.i)||Vjb(this,a,this.f)};_.vc=function gkb(){return new mkb(this)};_.xc=function hkb(a){return Wjb(this,a)};_.zc=function ikb(a,b){return Zjb(this,a,b)};_.Bc=function jkb(a){return _jb(this,a)};_.gc=function kkb(){return bkb(this)};_.g=0;sfb(Bve,'AbstractHashMap',498);feb(267,Eve,Fve,mkb);_.$b=function nkb(){this.a.$b();};_.Hc=function okb(a){return lkb(this,a)};_.Kc=function pkb(){return new vkb(this.a)};_.Mc=function qkb(a){var b;if(lkb(this,a)){b=RD(a,44).ld();this.a.Bc(b);return true}return false};_.gc=function rkb(){return this.a.gc()};sfb(Bve,'AbstractHashMap/EntrySet',267);feb(268,1,Ave,vkb);_.Nb=function wkb(a){Ztb(this,a);};_.Pb=function ykb(){return tkb(this)};_.Ob=function xkb(){return this.b};_.Qb=function zkb(){ukb(this);};_.b=false;_.d=0;sfb(Bve,'AbstractHashMap/EntrySetIterator',268);feb(426,1,Ave,Dkb);_.Nb=function Ekb(a){Ztb(this,a);};_.Ob=function Fkb(){return Akb(this)};_.Pb=function Gkb(){return Bkb(this)};_.Qb=function Hkb(){Ckb(this);};_.b=0;_.c=-1;sfb(Bve,'AbstractList/IteratorImpl',426);feb(98,426,Jve,Jkb);_.Qb=function Pkb(){Ckb(this);};_.Rb=function Kkb(a){Ikb(this,a);};_.Sb=function Lkb(){return this.b>0};_.Tb=function Mkb(){return this.b};_.Ub=function Nkb(){return sFb(this.b>0),this.a.Xb(this.c=--this.b)};_.Vb=function Okb(){return this.b-1};_.Wb=function Qkb(a){yFb(this.c!=-1);this.a.hd(this.c,a);};sfb(Bve,'AbstractList/ListIteratorImpl',98);feb(244,56,kwe,Rkb);_.bd=function Skb(a,b){wFb(a,this.b);this.c.bd(this.a+a,b);++this.b;};_.Xb=function Tkb(a){tFb(a,this.b);return this.c.Xb(this.a+a)};_.gd=function Ukb(a){var b;tFb(a,this.b);b=this.c.gd(this.a+a);--this.b;return b};_.hd=function Vkb(a,b){tFb(a,this.b);return this.c.hd(this.a+a,b)};_.gc=function Wkb(){return this.b};_.a=0;_.b=0;sfb(Bve,'AbstractList/SubList',244);feb(266,Eve,Fve,Xkb);_.$b=function Ykb(){this.a.$b();};_.Hc=function Zkb(a){return this.a._b(a)};_.Kc=function $kb(){var a;return a=this.a.vc().Kc(),new blb(a)};_.Mc=function _kb(a){if(this.a._b(a)){this.a.Bc(a);return true}return false};_.gc=function alb(){return this.a.gc()};sfb(Bve,'AbstractMap/1',266);feb(541,1,Ave,blb);_.Nb=function clb(a){Ztb(this,a);};_.Ob=function dlb(){return this.a.Ob()};_.Pb=function elb(){var a;return a=RD(this.a.Pb(),44),a.ld()};_.Qb=function flb(){this.a.Qb();};sfb(Bve,'AbstractMap/1/1',541);feb(231,31,Dve,glb);_.$b=function hlb(){this.a.$b();};_.Hc=function ilb(a){return this.a.uc(a)};_.Kc=function jlb(){var a;return a=this.a.vc().Kc(),new llb(a)};_.gc=function klb(){return this.a.gc()};sfb(Bve,'AbstractMap/2',231);feb(301,1,Ave,llb);_.Nb=function mlb(a){Ztb(this,a);};_.Ob=function nlb(){return this.a.Ob()};_.Pb=function olb(){var a;return a=RD(this.a.Pb(),44),a.md()};_.Qb=function plb(){this.a.Qb();};sfb(Bve,'AbstractMap/2/1',301);feb(494,1,{494:1,44:1});_.Fb=function rlb(a){var b;if(!ZD(a,44)){return false}b=RD(a,44);return Fvb(this.d,b.ld())&&Fvb(this.e,b.md())};_.ld=function slb(){return this.d};_.md=function tlb(){return this.e};_.Hb=function ulb(){return Gvb(this.d)^Gvb(this.e)};_.nd=function vlb(a){return qlb(this,a)};_.Ib=function wlb(){return this.d+'='+this.e};sfb(Bve,'AbstractMap/AbstractEntry',494);feb(397,494,{494:1,397:1,44:1},xlb);sfb(Bve,'AbstractMap/SimpleEntry',397);feb(2082,1,Axe);_.Fb=function ylb(a){var b;if(!ZD(a,44)){return false}b=RD(a,44);return Fvb(this.ld(),b.ld())&&Fvb(this.md(),b.md())};_.Hb=function zlb(){return Gvb(this.ld())^Gvb(this.md())};_.Ib=function Alb(){return this.ld()+'='+this.md()};sfb(Bve,Lve,2082);feb(2090,2065,Gve);_.Xc=function Dlb(a){return Vd(this.Ee(a))};_.tc=function Elb(a){return Blb(this,a)};_._b=function Flb(a){return Clb(this,a)};_.vc=function Glb(){return new Plb(this)};_.Tc=function Hlb(){return Klb(this.Ge())};_.Yc=function Ilb(a){return Vd(this.He(a))};_.xc=function Jlb(a){var b;b=a;return Wd(this.Fe(b))};_.$c=function Llb(a){return Vd(this.Ie(a))};_.ec=function Mlb(){return new Ulb(this)};_.Vc=function Nlb(){return Klb(this.Je())};_._c=function Olb(a){return Vd(this.Ke(a))};sfb(Bve,'AbstractNavigableMap',2090);feb(629,Eve,Fve,Plb);_.Hc=function Qlb(a){return ZD(a,44)&&Blb(this.b,RD(a,44))};_.Kc=function Rlb(){return this.b.De()};_.Mc=function Slb(a){var b;if(ZD(a,44)){b=RD(a,44);return this.b.Le(b)}return false};_.gc=function Tlb(){return this.b.gc()};sfb(Bve,'AbstractNavigableMap/EntrySet',629);feb(1146,Eve,Ive,Ulb);_.Nc=function $lb(){return new $wb(this)};_.$b=function Vlb(){this.a.$b();};_.Hc=function Wlb(a){return Clb(this.a,a)};_.Kc=function Xlb(){var a;a=this.a.vc().b.De();return new _lb(a)};_.Mc=function Ylb(a){if(Clb(this.a,a)){this.a.Bc(a);return true}return false};_.gc=function Zlb(){return this.a.gc()};sfb(Bve,'AbstractNavigableMap/NavigableKeySet',1146);feb(1147,1,Ave,_lb);_.Nb=function amb(a){Ztb(this,a);};_.Ob=function bmb(){return Akb(this.a.a)};_.Pb=function cmb(){var a;a=vzb(this.a);return a.ld()};_.Qb=function dmb(){wzb(this.a);};sfb(Bve,'AbstractNavigableMap/NavigableKeySet/1',1147);feb(2103,31,Dve);_.Fc=function emb(a){return zFb(lwb(this,a),Bxe),true};_.Gc=function fmb(a){uFb(a);mFb(a!=this,"Can't add a queue to itself");return ye(this,a)};_.$b=function gmb(){while(mwb(this)!=null);};sfb(Bve,'AbstractQueue',2103);feb(310,31,{4:1,20:1,31:1,16:1},wmb,xmb);_.Fc=function ymb(a){return imb(this,a),true};_.$b=function Amb(){jmb(this);};_.Hc=function Bmb(a){return kmb(new Kmb(this),a)};_.dc=function Cmb(){return nmb(this)};_.Kc=function Dmb(){return new Kmb(this)};_.Mc=function Emb(a){return qmb(new Kmb(this),a)};_.gc=function Fmb(){return this.c-this.b&this.a.length-1};_.Nc=function Gmb(){return new Swb(this,272)};_.Qc=function Hmb(a){var b;b=this.c-this.b&this.a.length-1;a.lengthb&&bD(a,b,null);return a};_.b=0;_.c=0;sfb(Bve,'ArrayDeque',310);feb(459,1,Ave,Kmb);_.Nb=function Lmb(a){Ztb(this,a);};_.Ob=function Mmb(){return this.a!=this.b};_.Pb=function Nmb(){return Imb(this)};_.Qb=function Omb(){Jmb(this);};_.a=0;_.b=0;_.c=-1;sfb(Bve,'ArrayDeque/IteratorImpl',459);feb(13,56,Cxe,bnb,cnb,dnb);_.bd=function enb(a,b){Qmb(this,a,b);};_.Fc=function fnb(a){return Rmb(this,a)};_.cd=function gnb(a,b){return Smb(this,a,b)};_.Gc=function hnb(a){return Tmb(this,a)};_.$b=function inb(){aFb(this.c,0);};_.Hc=function jnb(a){return Wmb(this,a,0)!=-1};_.Jc=function knb(a){Umb(this,a);};_.Xb=function lnb(a){return Vmb(this,a)};_.dd=function mnb(a){return Wmb(this,a,0)};_.dc=function nnb(){return this.c.length==0};_.Kc=function onb(){return new Anb(this)};_.gd=function pnb(a){return Xmb(this,a)};_.Mc=function qnb(a){return Ymb(this,a)};_.ce=function rnb(a,b){Zmb(this,a,b);};_.hd=function snb(a,b){return $mb(this,a,b)};_.gc=function tnb(){return this.c.length};_.jd=function unb(a){_mb(this,a);};_.Pc=function vnb(){return UEb(this.c)};_.Qc=function wnb(a){return anb(this,a)};var VJ=sfb(Bve,'ArrayList',13);feb(7,1,Ave,Anb);_.Nb=function Bnb(a){Ztb(this,a);};_.Ob=function Cnb(){return xnb(this)};_.Pb=function Dnb(){return ynb(this)};_.Qb=function Enb(){znb(this);};_.a=0;_.b=-1;sfb(Bve,'ArrayList/1',7);feb(2112,$wnd.Function,{},iob);_.Me=function job(a,b){return Qfb(a,b)};feb(151,56,Dxe,mob);_.Hc=function nob(a){return St(this,a)!=-1};_.Jc=function oob(a){var b,c,d,e;uFb(a);for(c=this.a,d=0,e=c.length;d0){throw Adb(new agb(Sxe+a+' greater than '+this.e))}return this.f.Te()?bzb(this.c,this.b,this.a,a,b):Ryb(this.c,a,b)};_.zc=function Vzb(a,b){if(!Tyb(this.c,this.f,a,this.b,this.a,this.e,this.d)){throw Adb(new agb(a+' outside the range '+this.b+' to '+this.e))}return Wyb(this.c,a,b)};_.Bc=function Wzb(a){var b;b=a;if(!Tyb(this.c,this.f,b,this.b,this.a,this.e,this.d)){return null}return Xyb(this.c,b)};_.Le=function Xzb(a){return Jzb(this,a.ld())&&Yyb(this.c,a)};_.gc=function Yzb(){var a,b,c;this.f.Te()?this.a?(b=Pyb(this.c,this.b,true)):(b=Pyb(this.c,this.b,false)):(b=Nyb(this.c));if(!(!!b&&Jzb(this,b.d)?b:null)){return 0}a=0;for(c=new yzb(this.c,this.f,this.b,this.a,this.e,this.d);Akb(c.a);c.b=RD(Bkb(c.a),44)){++a;}return a};_.ad=function Zzb(a,b){if(this.f.Te()&&this.c.a.Ne(a,this.b)<0){throw Adb(new agb(Sxe+a+Txe+this.b))}return this.f.Ue()?bzb(this.c,a,b,this.e,this.d):czb(this.c,a,b)};_.a=false;_.d=false;sfb(Bve,'TreeMap/SubMap',631);feb(304,22,Uxe,dAb);_.Te=function eAb(){return false};_.Ue=function fAb(){return false};var $zb,_zb,aAb,bAb;var AL=tfb(Bve,'TreeMap/SubMapType',304,WI,hAb,gAb);feb(1143,304,Uxe,iAb);_.Ue=function jAb(){return true};tfb(Bve,'TreeMap/SubMapType/1',1143,AL,null,null);feb(1144,304,Uxe,kAb);_.Te=function lAb(){return true};_.Ue=function mAb(){return true};tfb(Bve,'TreeMap/SubMapType/2',1144,AL,null,null);feb(1145,304,Uxe,nAb);_.Te=function oAb(){return true};tfb(Bve,'TreeMap/SubMapType/3',1145,AL,null,null);var pAb;feb(157,Eve,{3:1,20:1,31:1,16:1,277:1,21:1,87:1,157:1},xAb,yAb,zAb);_.Nc=function GAb(){return new $wb(this)};_.Fc=function AAb(a){return rAb(this,a)};_.$b=function BAb(){this.a.$b();};_.Hc=function CAb(a){return this.a._b(a)};_.Kc=function DAb(){return this.a.ec().Kc()};_.Mc=function EAb(a){return wAb(this,a)};_.gc=function FAb(){return this.a.gc()};var DL=sfb(Bve,'TreeSet',157);feb(1082,1,{},JAb);_.Ve=function KAb(a,b){return HAb(this.a,a,b)};sfb(Vxe,'BinaryOperator/lambda$0$Type',1082);feb(1083,1,{},LAb);_.Ve=function MAb(a,b){return IAb(this.a,a,b)};sfb(Vxe,'BinaryOperator/lambda$1$Type',1083);feb(952,1,{},NAb);_.Kb=function OAb(a){return a};sfb(Vxe,'Function/lambda$0$Type',952);feb(395,1,nwe,PAb);_.Mb=function QAb(a){return !this.a.Mb(a)};sfb(Vxe,'Predicate/lambda$2$Type',395);feb(581,1,{581:1});var JL=sfb(Wxe,'Handler',581);feb(2107,1,nve);_.xe=function TAb(){return 'DUMMY'};_.Ib=function UAb(){return this.xe()};var RAb;sfb(Wxe,'Level',2107);feb(1706,2107,nve,VAb);_.xe=function WAb(){return 'INFO'};sfb(Wxe,'Level/LevelInfo',1706);feb(1843,1,{},$Ab);var XAb;sfb(Wxe,'LogManager',1843);feb(1896,1,nve,aBb);_.b=null;sfb(Wxe,'LogRecord',1896);feb(525,1,{525:1},oBb);_.e=false;var bBb=false,cBb=false,dBb=false,eBb=false,fBb=false;sfb(Wxe,'Logger',525);feb(835,581,{581:1},rBb);sfb(Wxe,'SimpleConsoleLogHandler',835);feb(108,22,{3:1,34:1,22:1,108:1},yBb);var uBb,vBb,wBb;var QL=tfb(Zxe,'Collector/Characteristics',108,WI,ABb,zBb);var BBb;feb(758,1,{},DBb);sfb(Zxe,'CollectorImpl',758);feb(1074,1,{},RBb);_.Ve=function SBb(a,b){return Hyb(RD(a,213),RD(b,213))};sfb(Zxe,'Collectors/10methodref$merge$Type',1074);feb(1075,1,{},TBb);_.Kb=function UBb(a){return Iyb(RD(a,213))};sfb(Zxe,'Collectors/11methodref$toString$Type',1075);feb(1076,1,{},VBb);_.Kb=function WBb(a){return Geb(),SSb(a)?true:false};sfb(Zxe,'Collectors/12methodref$test$Type',1076);feb(144,1,{},XBb);_.Yd=function YBb(a,b){RD(a,16).Fc(b);};sfb(Zxe,'Collectors/20methodref$add$Type',144);feb(146,1,{},ZBb);_.Xe=function $Bb(){return new bnb};sfb(Zxe,'Collectors/21methodref$ctor$Type',146);feb(359,1,{},_Bb);_.Xe=function aCb(){return new _sb};sfb(Zxe,'Collectors/23methodref$ctor$Type',359);feb(360,1,{},bCb);_.Yd=function cCb(a,b){Ysb(RD(a,49),b);};sfb(Zxe,'Collectors/24methodref$add$Type',360);feb(1069,1,{},dCb);_.Ve=function eCb(a,b){return EBb(RD(a,15),RD(b,16))};sfb(Zxe,'Collectors/4methodref$addAll$Type',1069);feb(1073,1,{},fCb);_.Yd=function gCb(a,b){Gyb(RD(a,213),RD(b,484));};sfb(Zxe,'Collectors/9methodref$add$Type',1073);feb(1072,1,{},hCb);_.Xe=function iCb(){return new Jyb(this.a,this.b,this.c)};sfb(Zxe,'Collectors/lambda$15$Type',1072);feb(1077,1,{},jCb);_.Xe=function kCb(){var a;return a=new gub,dub(a,(Geb(),false),new bnb),dub(a,true,new bnb),a};sfb(Zxe,'Collectors/lambda$22$Type',1077);feb(1078,1,{},lCb);_.Xe=function mCb(){return cD(WC(jJ,1),rve,1,5,[this.a])};sfb(Zxe,'Collectors/lambda$25$Type',1078);feb(1079,1,{},nCb);_.Yd=function oCb(a,b){GBb(this.a,SD(a));};sfb(Zxe,'Collectors/lambda$26$Type',1079);feb(1080,1,{},pCb);_.Ve=function qCb(a,b){return HBb(this.a,SD(a),SD(b))};sfb(Zxe,'Collectors/lambda$27$Type',1080);feb(1081,1,{},rCb);_.Kb=function sCb(a){return SD(a)[0]};sfb(Zxe,'Collectors/lambda$28$Type',1081);feb(728,1,{},uCb);_.Ve=function vCb(a,b){return tCb(a,b)};sfb(Zxe,'Collectors/lambda$4$Type',728);feb(145,1,{},wCb);_.Ve=function xCb(a,b){return JBb(RD(a,16),RD(b,16))};sfb(Zxe,'Collectors/lambda$42$Type',145);feb(361,1,{},yCb);_.Ve=function zCb(a,b){return KBb(RD(a,49),RD(b,49))};sfb(Zxe,'Collectors/lambda$50$Type',361);feb(362,1,{},ACb);_.Kb=function BCb(a){return RD(a,49)};sfb(Zxe,'Collectors/lambda$51$Type',362);feb(1068,1,{},CCb);_.Yd=function DCb(a,b){LBb(this.a,RD(a,85),b);};sfb(Zxe,'Collectors/lambda$7$Type',1068);feb(1070,1,{},ECb);_.Ve=function FCb(a,b){return NBb(RD(a,85),RD(b,85),new dCb)};sfb(Zxe,'Collectors/lambda$8$Type',1070);feb(1071,1,{},GCb);_.Kb=function HCb(a){return MBb(this.a,RD(a,85))};sfb(Zxe,'Collectors/lambda$9$Type',1071);feb(550,1,{});_.$e=function OCb(){ICb(this);};_.d=false;sfb(Zxe,'TerminatableStream',550);feb(827,550,$xe,WCb);_.$e=function XCb(){ICb(this);};sfb(Zxe,'DoubleStreamImpl',827);feb(1847,736,Pve,$Cb);_.Re=function aDb(a){return ZCb(this,RD(a,189))};_.a=null;sfb(Zxe,'DoubleStreamImpl/2',1847);feb(1848,1,Gxe,bDb);_.Pe=function cDb(a){_Cb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/2/lambda$0$Type',1848);feb(1845,1,Gxe,dDb);_.Pe=function eDb(a){YCb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/lambda$0$Type',1845);feb(1846,1,Gxe,fDb);_.Pe=function gDb(a){Nrb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/lambda$2$Type',1846);feb(1397,735,Pve,kDb);_.Re=function lDb(a){return jDb(this,RD(a,202))};_.a=0;_.b=0;_.c=0;sfb(Zxe,'IntStream/5',1397);feb(806,550,$xe,oDb);_.$e=function pDb(){ICb(this);};_._e=function qDb(){return LCb(this),this.a};sfb(Zxe,'IntStreamImpl',806);feb(807,550,$xe,rDb);_.$e=function sDb(){ICb(this);};_._e=function tDb(){return LCb(this),Txb(),Sxb};sfb(Zxe,'IntStreamImpl/Empty',807);feb(1687,1,Rve,uDb);_.Dd=function vDb(a){ktb(this.a,a);};sfb(Zxe,'IntStreamImpl/lambda$4$Type',1687);var RM=ufb(Zxe,'Stream');feb(26,550,{533:1,687:1,848:1},SDb);_.$e=function TDb(){ICb(this);};var wDb;sfb(Zxe,'StreamImpl',26);feb(1102,500,Pve,YDb);_.Bd=function ZDb(a){while(WDb(this)){if(this.a.Bd(a)){return true}else {ICb(this.b);this.b=null;this.a=null;}}return false};sfb(Zxe,'StreamImpl/1',1102);feb(1103,1,Qve,$Db);_.Cd=function _Db(a){XDb(this.a,RD(a,848));};sfb(Zxe,'StreamImpl/1/lambda$0$Type',1103);feb(1104,1,nwe,aEb);_.Mb=function bEb(a){return Ysb(this.a,a)};sfb(Zxe,'StreamImpl/1methodref$add$Type',1104);feb(1105,500,Pve,cEb);_.Bd=function dEb(a){var b;if(!this.a){b=new bnb;this.b.a.Nb(new eEb(b));yob();_mb(b,this.c);this.a=new Swb(b,16);}return Rwb(this.a,a)};_.a=null;sfb(Zxe,'StreamImpl/5',1105);feb(1106,1,Qve,eEb);_.Cd=function fEb(a){Rmb(this.a,a);};sfb(Zxe,'StreamImpl/5/2methodref$add$Type',1106);feb(737,500,Pve,hEb);_.Bd=function iEb(a){this.b=false;while(!this.b&&this.c.Bd(new jEb(this,a)));return this.b};_.b=false;sfb(Zxe,'StreamImpl/FilterSpliterator',737);feb(1096,1,Qve,jEb);_.Cd=function kEb(a){gEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/FilterSpliterator/lambda$0$Type',1096);feb(1091,736,Pve,nEb);_.Re=function oEb(a){return mEb(this,RD(a,189))};sfb(Zxe,'StreamImpl/MapToDoubleSpliterator',1091);feb(1095,1,Qve,pEb);_.Cd=function qEb(a){lEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToDoubleSpliterator/lambda$0$Type',1095);feb(1090,735,Pve,tEb);_.Re=function uEb(a){return sEb(this,RD(a,202))};sfb(Zxe,'StreamImpl/MapToIntSpliterator',1090);feb(1094,1,Qve,vEb);_.Cd=function wEb(a){rEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToIntSpliterator/lambda$0$Type',1094);feb(734,500,Pve,zEb);_.Bd=function AEb(a){return yEb(this,a)};sfb(Zxe,'StreamImpl/MapToObjSpliterator',734);feb(1093,1,Qve,BEb);_.Cd=function CEb(a){xEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToObjSpliterator/lambda$0$Type',1093);feb(1092,500,Pve,DEb);_.Bd=function EEb(a){while(Idb(this.b,0)){if(!this.a.Bd(new FEb)){return false}this.b=Vdb(this.b,1);}return this.a.Bd(a)};_.b=0;sfb(Zxe,'StreamImpl/SkipSpliterator',1092);feb(1097,1,Qve,FEb);_.Cd=function GEb(a){};sfb(Zxe,'StreamImpl/SkipSpliterator/lambda$0$Type',1097);feb(626,1,Qve,IEb);_.Cd=function JEb(a){HEb(this,a);};sfb(Zxe,'StreamImpl/ValueConsumer',626);feb(1098,1,Qve,KEb);_.Cd=function LEb(a){xDb();};sfb(Zxe,'StreamImpl/lambda$0$Type',1098);feb(1099,1,Qve,MEb);_.Cd=function NEb(a){xDb();};sfb(Zxe,'StreamImpl/lambda$1$Type',1099);feb(1100,1,{},OEb);_.Ve=function PEb(a,b){return UDb(this.a,a,b)};sfb(Zxe,'StreamImpl/lambda$4$Type',1100);feb(1101,1,Qve,QEb);_.Cd=function REb(a){VDb(this.b,this.a,a);};sfb(Zxe,'StreamImpl/lambda$5$Type',1101);feb(1107,1,Qve,SEb);_.Cd=function TEb(a){PCb(this.a,RD(a,380));};sfb(Zxe,'TerminatableStream/lambda$0$Type',1107);feb(2142,1,{});feb(2014,1,{},gFb);sfb('javaemul.internal','ConsoleLogger',2014);var iFb=0;feb(2134,1,{});feb(1830,1,Qve,FFb);_.Cd=function GFb(a){RD(a,317);};sfb(eye,'BowyerWatsonTriangulation/lambda$0$Type',1830);feb(1831,1,Qve,HFb);_.Cd=function IFb(a){ye(this.a,RD(a,317).e);};sfb(eye,'BowyerWatsonTriangulation/lambda$1$Type',1831);feb(1832,1,Qve,JFb);_.Cd=function KFb(a){RD(a,177);};sfb(eye,'BowyerWatsonTriangulation/lambda$2$Type',1832);feb(1827,1,fye,NFb);_.Ne=function OFb(a,b){return MFb(this.a,RD(a,177),RD(b,177))};_.Fb=function PFb(a){return this===a};_.Oe=function QFb(){return new Frb(this)};sfb(eye,'NaiveMinST/lambda$0$Type',1827);feb(449,1,{},SFb);sfb(eye,'NodeMicroLayout',449);feb(177,1,{177:1},TFb);_.Fb=function UFb(a){var b;if(ZD(a,177)){b=RD(a,177);return Fvb(this.a,b.a)&&Fvb(this.b,b.b)||Fvb(this.a,b.b)&&Fvb(this.b,b.a)}else {return false}};_.Hb=function VFb(){return Gvb(this.a)+Gvb(this.b)};var $M=sfb(eye,'TEdge',177);feb(317,1,{317:1},XFb);_.Fb=function YFb(a){var b;if(ZD(a,317)){b=RD(a,317);return WFb(this,b.a)&&WFb(this,b.b)&&WFb(this,b.c)}else {return false}};_.Hb=function ZFb(){return Gvb(this.a)+Gvb(this.b)+Gvb(this.c)};sfb(eye,'TTriangle',317);feb(225,1,{225:1},$Fb);sfb(eye,'Tree',225);feb(1218,1,{},aGb);sfb(gye,'Scanline',1218);var bN=ufb(gye,hye);feb(1758,1,{},dGb);sfb(iye,'CGraph',1758);feb(316,1,{316:1},fGb);_.b=0;_.c=0;_.d=0;_.g=0;_.i=0;_.k=pxe;sfb(iye,'CGroup',316);feb(830,1,{},jGb);sfb(iye,'CGroup/CGroupBuilder',830);feb(60,1,{60:1},kGb);_.Ib=function lGb(){var a;if(this.j){return WD(this.j.Kb(this))}return lfb(hN),hN.o+'@'+(a=kFb(this)>>>0,a.toString(16))};_.f=0;_.i=pxe;var hN=sfb(iye,'CNode',60);feb(829,1,{},qGb);sfb(iye,'CNode/CNodeBuilder',829);var vGb;feb(1590,1,{},xGb);_.ff=function yGb(a,b){return 0};_.gf=function zGb(a,b){return 0};sfb(iye,kye,1590);feb(1853,1,{},AGb);_.cf=function BGb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;j=oxe;for(d=new Anb(a.a.b);d.ad.d.c||d.d.c==f.d.c&&d.d.b0?a+this.n.d+this.n.a:0};_.kf=function yKb(){var a,b,c,d,e;e=0;if(this.e){this.b?(e=this.b.a):!!this.a[1][1]&&(e=this.a[1][1].kf());}else if(this.g){e=vKb(this,pKb(this,null,true));}else {for(b=(ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])),c=0,d=b.length;c0?e+this.n.b+this.n.c:0};_.lf=function zKb(){var a,b,c,d,e;if(this.g){a=pKb(this,null,false);for(c=(ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])),d=0,e=c.length;d0){d[0]+=this.d;c-=d[0];}if(d[2]>0){d[2]+=this.d;c-=d[2];}this.c.a=$wnd.Math.max(0,c);this.c.d=b.d+a.d+(this.c.a-c)/2;d[1]=$wnd.Math.max(d[1],c);lKb(this,XJb,b.d+a.d+d[0]-(d[1]-c)/2,d);};_.b=null;_.d=0;_.e=false;_.f=false;_.g=false;var iKb=0,jKb=0;sfb(Jye,'GridContainerCell',1538);feb(471,22,{3:1,34:1,22:1,471:1},FKb);var BKb,CKb,DKb;var MN=tfb(Jye,'HorizontalLabelAlignment',471,WI,HKb,GKb);var IKb;feb(314,217,{217:1,314:1},TKb,UKb,VKb);_.jf=function WKb(){return PKb(this)};_.kf=function XKb(){return QKb(this)};_.a=0;_.c=false;var NN=sfb(Jye,'LabelCell',314);feb(252,336,{217:1,336:1,252:1},dLb);_.jf=function eLb(){return YKb(this)};_.kf=function fLb(){return ZKb(this)};_.lf=function iLb(){$Kb(this);};_.mf=function jLb(){_Kb(this);};_.b=0;_.c=0;_.d=false;sfb(Jye,'StripContainerCell',252);feb(1691,1,nwe,kLb);_.Mb=function lLb(a){return gLb(RD(a,217))};sfb(Jye,'StripContainerCell/lambda$0$Type',1691);feb(1692,1,{},mLb);_.Ye=function nLb(a){return RD(a,217).kf()};sfb(Jye,'StripContainerCell/lambda$1$Type',1692);feb(1693,1,nwe,oLb);_.Mb=function pLb(a){return hLb(RD(a,217))};sfb(Jye,'StripContainerCell/lambda$2$Type',1693);feb(1694,1,{},qLb);_.Ye=function rLb(a){return RD(a,217).jf()};sfb(Jye,'StripContainerCell/lambda$3$Type',1694);feb(472,22,{3:1,34:1,22:1,472:1},wLb);var sLb,tLb,uLb;var TN=tfb(Jye,'VerticalLabelAlignment',472,WI,yLb,xLb);var zLb;feb(800,1,{},CLb);_.c=0;_.d=0;_.k=0;_.s=0;_.t=0;_.v=false;_.w=0;_.D=false;_.F=false;sfb(Rye,'NodeContext',800);feb(1536,1,fye,FLb);_.Ne=function GLb(a,b){return ELb(RD(a,64),RD(b,64))};_.Fb=function HLb(a){return this===a};_.Oe=function ILb(){return new Frb(this)};sfb(Rye,'NodeContext/0methodref$comparePortSides$Type',1536);feb(1537,1,fye,JLb);_.Ne=function KLb(a,b){return DLb(RD(a,117),RD(b,117))};_.Fb=function LLb(a){return this===a};_.Oe=function MLb(){return new Frb(this)};sfb(Rye,'NodeContext/1methodref$comparePortContexts$Type',1537);feb(164,22,{3:1,34:1,22:1,164:1},kMb);var NLb,OLb,PLb,QLb,RLb,SLb,TLb,ULb,VLb,WLb,XLb,YLb,ZLb,$Lb,_Lb,aMb,bMb,cMb,dMb,eMb,fMb,gMb;var XN=tfb(Rye,'NodeLabelLocation',164,WI,nMb,mMb);var oMb;feb(117,1,{117:1},rMb);_.a=false;sfb(Rye,'PortContext',117);feb(1541,1,Qve,KMb);_.Cd=function LMb(a){NKb(RD(a,314));};sfb(Uye,Vye,1541);feb(1542,1,nwe,MMb);_.Mb=function NMb(a){return !!RD(a,117).c};sfb(Uye,Wye,1542);feb(1543,1,Qve,OMb);_.Cd=function PMb(a){NKb(RD(a,117).c);};sfb(Uye,'LabelPlacer/lambda$2$Type',1543);var QMb;feb(1540,1,Qve,YMb);_.Cd=function ZMb(a){RMb();qMb(RD(a,117));};sfb(Uye,'NodeLabelAndSizeUtilities/lambda$0$Type',1540);feb(801,1,Qve,dNb);_.Cd=function eNb(a){bNb(this.b,this.c,this.a,RD(a,187));};_.a=false;_.c=false;sfb(Uye,'NodeLabelCellCreator/lambda$0$Type',801);feb(1539,1,Qve,kNb);_.Cd=function lNb(a){jNb(this.a,RD(a,187));};sfb(Uye,'PortContextCreator/lambda$0$Type',1539);var sNb;feb(1902,1,{},MNb);sfb(Yye,'GreedyRectangleStripOverlapRemover',1902);feb(1903,1,fye,ONb);_.Ne=function PNb(a,b){return NNb(RD(a,226),RD(b,226))};_.Fb=function QNb(a){return this===a};_.Oe=function RNb(){return new Frb(this)};sfb(Yye,'GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type',1903);feb(1849,1,{},YNb);_.a=5;_.e=0;sfb(Yye,'RectangleStripOverlapRemover',1849);feb(1850,1,fye,aOb);_.Ne=function bOb(a,b){return ZNb(RD(a,226),RD(b,226))};_.Fb=function cOb(a){return this===a};_.Oe=function dOb(){return new Frb(this)};sfb(Yye,'RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type',1850);feb(1852,1,fye,eOb);_.Ne=function fOb(a,b){return $Nb(RD(a,226),RD(b,226))};_.Fb=function gOb(a){return this===a};_.Oe=function hOb(){return new Frb(this)};sfb(Yye,'RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type',1852);feb(417,22,{3:1,34:1,22:1,417:1},nOb);var iOb,jOb,kOb,lOb;var hO=tfb(Yye,'RectangleStripOverlapRemover/OverlapRemovalDirection',417,WI,pOb,oOb);var qOb;feb(226,1,{226:1},sOb);sfb(Yye,'RectangleStripOverlapRemover/RectangleNode',226);feb(1851,1,Qve,tOb);_.Cd=function uOb(a){TNb(this.a,RD(a,226));};sfb(Yye,'RectangleStripOverlapRemover/lambda$1$Type',1851);feb(1323,1,fye,xOb);_.Ne=function yOb(a,b){return wOb(RD(a,176),RD(b,176))};_.Fb=function zOb(a){return this===a};_.Oe=function AOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator',1323);feb(1326,1,{},BOb);_.Kb=function COb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$0$Type',1326);feb(1327,1,nwe,DOb);_.Mb=function EOb(a){return RD(a,332).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$1$Type',1327);feb(1328,1,nwe,FOb);_.Mb=function GOb(a){return RD(a,332).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$2$Type',1328);feb(1321,1,fye,IOb);_.Ne=function JOb(a,b){return HOb(RD(a,176),RD(b,176))};_.Fb=function KOb(a){return this===a};_.Oe=function LOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinNumOfExtensionDirectionsComparator',1321);feb(1324,1,{},MOb);_.Kb=function NOb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/MinNumOfExtensionDirectionsComparator/lambda$0$Type',1324);feb(781,1,fye,POb);_.Ne=function QOb(a,b){return OOb(RD(a,176),RD(b,176))};_.Fb=function ROb(a){return this===a};_.Oe=function SOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinNumOfExtensionsComparator',781);feb(1319,1,fye,UOb);_.Ne=function VOb(a,b){return TOb(RD(a,330),RD(b,330))};_.Fb=function WOb(a){return this===a};_.Oe=function XOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinPerimeterComparator',1319);feb(1320,1,fye,ZOb);_.Ne=function $Ob(a,b){return YOb(RD(a,330),RD(b,330))};_.Fb=function _Ob(a){return this===a};_.Oe=function aPb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinPerimeterComparatorWithShape',1320);feb(1322,1,fye,cPb);_.Ne=function dPb(a,b){return bPb(RD(a,176),RD(b,176))};_.Fb=function ePb(a){return this===a};_.Oe=function fPb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/SingleExtensionSideGreaterThanRestComparator',1322);feb(1325,1,{},gPb);_.Kb=function hPb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/SingleExtensionSideGreaterThanRestComparator/lambda$0$Type',1325);feb(782,1,{},kPb);_.Ve=function lPb(a,b){return jPb(this,RD(a,42),RD(b,176))};sfb($ye,'SuccessorCombination',782);feb(649,1,{},nPb);_.Ve=function oPb(a,b){var c;return mPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorJitter',649);feb(648,1,{},qPb);_.Ve=function rPb(a,b){var c;return pPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorLineByLine',648);feb(573,1,{},tPb);_.Ve=function uPb(a,b){var c;return sPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorManhattan',573);feb(1344,1,{},wPb);_.Ve=function xPb(a,b){var c;return vPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorMaxNormWindingInMathPosSense',1344);feb(409,1,{},APb);_.Ve=function BPb(a,b){return yPb(this,a,b)};_.c=false;_.d=false;_.e=false;_.f=false;sfb($ye,'SuccessorQuadrantsGeneric',409);feb(1345,1,{},CPb);_.Kb=function DPb(a){return RD(a,334).a};sfb($ye,'SuccessorQuadrantsGeneric/lambda$0$Type',1345);feb(332,22,{3:1,34:1,22:1,332:1},JPb);_.a=false;var EPb,FPb,GPb,HPb;var DO=tfb(dze,eze,332,WI,LPb,KPb);var MPb;feb(1317,1,{});_.Ib=function UPb(){var a,b,c,d,e,f;c=' ';a=sgb(0);for(e=0;e=0?'b'+a+'['+bUb(this.a)+']':'b['+bUb(this.a)+']'}return 'b_'+kFb(this)};sfb(Oze,'FBendpoint',250);feb(290,137,{3:1,290:1,96:1,137:1},cUb);_.Ib=function dUb(){return bUb(this)};sfb(Oze,'FEdge',290);feb(235,137,{3:1,235:1,96:1,137:1},gUb);var tP=sfb(Oze,'FGraph',235);feb(454,309,{3:1,454:1,309:1,96:1,137:1},iUb);_.Ib=function jUb(){return this.b==null||this.b.length==0?'l['+bUb(this.a)+']':'l_'+this.b};sfb(Oze,'FLabel',454);feb(153,309,{3:1,153:1,309:1,96:1,137:1},lUb);_.Ib=function mUb(){return kUb(this)};_.a=0;sfb(Oze,'FNode',153);feb(2100,1,{});_.vf=function rUb(a){nUb(this,a);};_.wf=function sUb(){oUb(this);};_.d=0;sfb(Qze,'AbstractForceModel',2100);feb(641,2100,{641:1},tUb);_.uf=function vUb(a,b){var c,d,e,f,g;qUb(this.f,a,b);e=ojd(ajd(b.d),a.d);g=$wnd.Math.sqrt(e.a*e.a+e.b*e.b);d=$wnd.Math.max(0,g-ejd(a.e)/2-ejd(b.e)/2);c=fUb(this.e,a,b);c>0?(f=-uUb(d,this.c)*c):(f=yUb(d,this.b)*RD(mQb(a,(yVb(),lVb)),17).a);ijd(e,f/g);return e};_.vf=function wUb(a){nUb(this,a);this.a=RD(mQb(a,(yVb(),aVb)),17).a;this.c=Kfb(UD(mQb(a,rVb)));this.b=Kfb(UD(mQb(a,nVb)));};_.xf=function xUb(a){return a0&&(f-=AUb(d,this.a)*c);ijd(e,f*this.b/g);return e};_.vf=function CUb(a){var b,c,d,e,f,g,h;nUb(this,a);this.b=Kfb(UD(mQb(a,(yVb(),sVb))));this.c=this.b/RD(mQb(a,aVb),17).a;d=a.e.c.length;f=0;e=0;for(h=new Anb(a.e);h.a0};_.a=0;_.b=0;_.c=0;sfb(Qze,'FruchtermanReingoldModel',642);feb(860,1,Eye,PUb);_.hf=function QUb(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Rze),''),'Force Model'),'Determines the model for force calculation.'),IUb),(kid(),eid)),BP),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Sze),''),'Iterations'),'The number of iterations on the force model.'),sgb(300)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Tze),''),'Repulsive Power'),'Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Uze),''),'FR Temperature'),'The temperature is used as a scaling factor for particle displacements.'),Vze),did),VI),xsb(Whd))));zgd(a,Uze,Rze,NUb);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Wze),''),'Eades Repulsion'),"Factor for repulsive forces in Eades' model."),5),did),VI),xsb(Whd))));zgd(a,Wze,Rze,KUb);zVb((new AVb,a));};var GUb,HUb,IUb,JUb,KUb,LUb,MUb,NUb;sfb(Xze,'ForceMetaDataProvider',860);feb(432,22,{3:1,34:1,22:1,432:1},UUb);var RUb,SUb;var BP=tfb(Xze,'ForceModelStrategy',432,WI,WUb,VUb);var XUb;feb(Awe,1,Eye,AVb);_.hf=function BVb(a){zVb(a);};var ZUb,$Ub,_Ub,aVb,bVb,cVb,dVb,eVb,fVb,gVb,hVb,iVb,jVb,kVb,lVb,mVb,nVb,oVb,pVb,qVb,rVb,sVb,tVb,uVb,vVb,wVb,xVb;sfb(Xze,'ForceOptions',Awe);feb(1001,1,{},CVb);_.sf=function DVb(){var a;return a=new TTb,a};_.tf=function EVb(a){};sfb(Xze,'ForceOptions/ForceFactory',1001);var FVb,GVb,HVb,IVb;feb(861,1,Eye,RVb);_.hf=function SVb(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,vAe),''),'Fixed Position'),'Prevent that the node is moved by the layout algorithm.'),(Geb(),false)),(kid(),cid)),QI),xsb((Yhd(),Vhd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,wAe),''),'Desired Edge Length'),'Either specified for parent nodes or for individual edges, where the latter takes higher precedence.'),100),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Thd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xAe),''),'Layout Dimension'),'Dimensions that are permitted to be altered during layout.'),MVb),eid),JP),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yAe),''),'Stress Epsilon'),'Termination criterion for the iterative process.'),Vze),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zAe),''),'Iteration Limit'),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),sgb(lve)),gid),bJ),xsb(Whd))));eWb((new fWb,a));};var KVb,LVb,MVb,NVb,OVb,PVb;sfb(Xze,'StressMetaDataProvider',861);feb(1004,1,Eye,fWb);_.hf=function gWb(a){eWb(a);};var TVb,UVb,VVb,WVb,XVb,YVb,ZVb,$Vb,_Vb,aWb,bWb,cWb;sfb(Xze,'StressOptions',1004);feb(1005,1,{},hWb);_.sf=function iWb(){var a;return a=new kWb,a};_.tf=function jWb(a){};sfb(Xze,'StressOptions/StressFactory',1005);feb(1110,205,oze,kWb);_.rf=function lWb(a,b){var c,d,e,f,g;b.Ug(BAe,1);Heb(TD(Gxd(a,(dWb(),XVb))))?Heb(TD(Gxd(a,bWb)))||RFb((c=new SFb((lud(),new zud(a))),c)):QTb(new TTb,a,b.eh(1));e=KTb(a);d=CTb(this.a,e);for(g=d.Kc();g.Ob();){f=RD(g.Pb(),235);if(f.e.c.length<=1){continue}uWb(this.b,f);sWb(this.b);Umb(f.d,new mWb);}e=BTb(d);JTb(e);b.Vg();};sfb(DAe,'StressLayoutProvider',1110);feb(1111,1,Qve,mWb);_.Cd=function nWb(a){hUb(RD(a,454));};sfb(DAe,'StressLayoutProvider/lambda$0$Type',1111);feb(1002,1,{},vWb);_.c=0;_.e=0;_.g=0;sfb(DAe,'StressMajorization',1002);feb(391,22,{3:1,34:1,22:1,391:1},BWb);var xWb,yWb,zWb;var JP=tfb(DAe,'StressMajorization/Dimension',391,WI,DWb,CWb);var EWb;feb(1003,1,fye,GWb);_.Ne=function HWb(a,b){return wWb(this.a,RD(a,153),RD(b,153))};_.Fb=function IWb(a){return this===a};_.Oe=function JWb(){return new Frb(this)};sfb(DAe,'StressMajorization/lambda$0$Type',1003);feb(1192,1,{},RWb);sfb(FAe,'ElkLayered',1192);feb(1193,1,Qve,UWb);_.Cd=function VWb(a){SWb(this.a,RD(a,36));};sfb(FAe,'ElkLayered/lambda$0$Type',1193);feb(1194,1,Qve,WWb);_.Cd=function XWb(a){TWb(this.a,RD(a,36));};sfb(FAe,'ElkLayered/lambda$1$Type',1194);feb(1281,1,{},dXb);var YWb,ZWb,$Wb;sfb(FAe,'GraphConfigurator',1281);feb(770,1,Qve,fXb);_.Cd=function gXb(a){aXb(this.a,RD(a,10));};sfb(FAe,'GraphConfigurator/lambda$0$Type',770);feb(771,1,{},hXb);_.Kb=function iXb(a){return _Wb(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(FAe,'GraphConfigurator/lambda$1$Type',771);feb(772,1,Qve,jXb);_.Cd=function kXb(a){aXb(this.a,RD(a,10));};sfb(FAe,'GraphConfigurator/lambda$2$Type',772);feb(1109,205,oze,lXb);_.rf=function mXb(a,b){var c;c=c5b(new k5b,a);dE(Gxd(a,(yCc(),IAc)))===dE((Fnd(),Cnd))?LWb(this.a,c,b):MWb(this.a,c,b);b.$g()||J5b(new N5b,c);};sfb(FAe,'LayeredLayoutProvider',1109);feb(367,22,{3:1,34:1,22:1,367:1},tXb);var nXb,oXb,pXb,qXb,rXb;var UP=tfb(FAe,'LayeredPhases',367,WI,vXb,uXb);var wXb;feb(1717,1,{},EXb);_.i=0;var yXb;sfb(GAe,'ComponentsToCGraphTransformer',1717);var jYb;feb(1718,1,{},FXb);_.yf=function GXb(a,b){return $wnd.Math.min(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};_.zf=function HXb(a,b){return $wnd.Math.min(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};sfb(GAe,'ComponentsToCGraphTransformer/1',1718);feb(86,1,{86:1});_.i=0;_.k=true;_.o=pxe;var bQ=sfb(HAe,'CNode',86);feb(470,86,{470:1,86:1},IXb,JXb);_.Ib=function KXb(){return ''};sfb(GAe,'ComponentsToCGraphTransformer/CRectNode',470);feb(1688,1,{},XXb);var LXb,MXb;sfb(GAe,'OneDimensionalComponentsCompaction',1688);feb(1689,1,{},$Xb);_.Kb=function _Xb(a){return YXb(RD(a,42))};_.Fb=function aYb(a){return this===a};sfb(GAe,'OneDimensionalComponentsCompaction/lambda$0$Type',1689);feb(1690,1,{},bYb);_.Kb=function cYb(a){return ZXb(RD(a,42))};_.Fb=function dYb(a){return this===a};sfb(GAe,'OneDimensionalComponentsCompaction/lambda$1$Type',1690);feb(1720,1,{},fYb);sfb(HAe,'CGraph',1720);feb(194,1,{194:1},iYb);_.b=0;_.c=0;_.e=0;_.g=true;_.i=pxe;sfb(HAe,'CGroup',194);feb(1719,1,{},lYb);_.yf=function mYb(a,b){return $wnd.Math.max(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};_.zf=function nYb(a,b){return $wnd.Math.max(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};sfb(HAe,kye,1719);feb(1721,1,{},EYb);_.d=false;var oYb;var eQ=sfb(HAe,pye,1721);feb(1722,1,{},FYb);_.Kb=function GYb(a){return pYb(),Geb(),RD(RD(a,42).a,86).d.e!=0?true:false};_.Fb=function HYb(a){return this===a};sfb(HAe,qye,1722);feb(833,1,{},KYb);_.a=false;_.b=false;_.c=false;_.d=false;sfb(HAe,rye,833);feb(1898,1,{},QYb);sfb(IAe,sye,1898);var wQ=ufb(JAe,hye);feb(1899,1,{382:1},UYb);_.bf=function VYb(a){SYb(this,RD(a,476));};sfb(IAe,tye,1899);feb(Owe,1,fye,XYb);_.Ne=function YYb(a,b){return WYb(RD(a,86),RD(b,86))};_.Fb=function ZYb(a){return this===a};_.Oe=function $Yb(){return new Frb(this)};sfb(IAe,uye,Owe);feb(476,1,{476:1},_Yb);_.a=false;sfb(IAe,vye,476);feb(1901,1,fye,aZb);_.Ne=function bZb(a,b){return RYb(RD(a,476),RD(b,476))};_.Fb=function cZb(a){return this===a};_.Oe=function dZb(){return new Frb(this)};sfb(IAe,wye,1901);feb(148,1,{148:1},eZb,fZb);_.Fb=function gZb(a){var b;if(a==null){return false}if(mQ!=rb(a)){return false}b=RD(a,148);return Fvb(this.c,b.c)&&Fvb(this.d,b.d)};_.Hb=function hZb(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.c,this.d]))};_.Ib=function iZb(){return '('+this.c+pve+this.d+(this.a?'cx':'')+this.b+')'};_.a=true;_.c=0;_.d=0;var mQ=sfb(JAe,'Point',148);feb(416,22,{3:1,34:1,22:1,416:1},qZb);var jZb,kZb,lZb,mZb;var lQ=tfb(JAe,'Point/Quadrant',416,WI,uZb,tZb);var vZb;feb(1708,1,{},EZb);_.b=null;_.c=null;_.d=null;_.e=null;_.f=null;var xZb,yZb,zZb,AZb,BZb;sfb(JAe,'RectilinearConvexHull',1708);feb(583,1,{382:1},PZb);_.bf=function QZb(a){OZb(this,RD(a,148));};_.b=0;var MZb;sfb(JAe,'RectilinearConvexHull/MaximalElementsEventHandler',583);feb(1710,1,fye,SZb);_.Ne=function TZb(a,b){return RZb(UD(a),UD(b))};_.Fb=function UZb(a){return this===a};_.Oe=function VZb(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type',1710);feb(1709,1,{382:1},XZb);_.bf=function YZb(a){WZb(this,RD(a,148));};_.a=0;_.b=null;_.c=null;_.d=null;_.e=null;sfb(JAe,'RectilinearConvexHull/RectangleEventHandler',1709);feb(1711,1,fye,ZZb);_.Ne=function $Zb(a,b){return GZb(RD(a,148),RD(b,148))};_.Fb=function _Zb(a){return this===a};_.Oe=function a$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$0$Type',1711);feb(1712,1,fye,b$b);_.Ne=function c$b(a,b){return HZb(RD(a,148),RD(b,148))};_.Fb=function d$b(a){return this===a};_.Oe=function e$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$1$Type',1712);feb(1713,1,fye,f$b);_.Ne=function g$b(a,b){return IZb(RD(a,148),RD(b,148))};_.Fb=function h$b(a){return this===a};_.Oe=function i$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$2$Type',1713);feb(1714,1,fye,j$b);_.Ne=function k$b(a,b){return JZb(RD(a,148),RD(b,148))};_.Fb=function l$b(a){return this===a};_.Oe=function m$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$3$Type',1714);feb(1715,1,fye,n$b);_.Ne=function o$b(a,b){return KZb(RD(a,148),RD(b,148))};_.Fb=function p$b(a){return this===a};_.Oe=function q$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$4$Type',1715);feb(1716,1,{},s$b);sfb(JAe,'Scanline',1716);feb(2104,1,{});sfb(KAe,'AbstractGraphPlacer',2104);feb(335,1,{335:1},C$b);_.Ff=function D$b(a){if(this.Gf(a)){Rc(this.b,RD(mQb(a,(Ywc(),ewc)),21),a);return true}else {return false}};_.Gf=function E$b(a){var b,c,d,e;b=RD(mQb(a,(Ywc(),ewc)),21);e=RD(Qc(y$b,b),21);for(d=e.Kc();d.Ob();){c=RD(d.Pb(),21);if(!RD(Qc(this.b,c),15).dc()){return false}}return true};var y$b;sfb(KAe,'ComponentGroup',335);feb(779,2104,{},J$b);_.Hf=function K$b(a){var b,c;for(c=new Anb(this.a);c.ac){k=0;l+=h+d;h=0;}i=f.c;w$b(f,k+i.a,l+i.b);hjd(i);e=$wnd.Math.max(e,k+j.a);h=$wnd.Math.max(h,j.b);k+=j.a+d;}b.f.a=e;b.f.b=l+h;};_.Jf=function Y_b(a,b){var c,d,e,f,g;if(dE(mQb(b,(yCc(),Yzc)))===dE((U$b(),T$b))){for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);g=0;for(f=new Anb(c.a);f.ac&&!RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),Yod))||!!i&&RD(mQb(i,(Ywc(),ewc)),21).Hc((qpd(),Xod))||RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),ppd))){m=l;n+=h+d;h=0;}j=f.c;RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),Yod))&&(m=e+d);w$b(f,m+j.a,n+j.b);e=$wnd.Math.max(e,m+k.a);RD(mQb(f,ewc),21).Hc(npd)&&(l=$wnd.Math.max(l,m+k.a+d));hjd(j);h=$wnd.Math.max(h,k.b);m+=k.a+d;i=f;}b.f.a=e;b.f.b=n+h;};_.Jf=function __b(a,b){};sfb(KAe,'ModelOrderRowGraphPlacer',1313);feb(1311,1,fye,b0b);_.Ne=function c0b(a,b){return a0b(RD(a,36),RD(b,36))};_.Fb=function d0b(a){return this===a};_.Oe=function e0b(){return new Frb(this)};sfb(KAe,'SimpleRowGraphPlacer/1',1311);var f0b;feb(1280,1,xye,l0b);_.Lb=function m0b(a){var b;return b=RD(mQb(RD(a,249).b,(yCc(),RAc)),75),!!b&&b.b!=0};_.Fb=function n0b(a){return this===a};_.Mb=function o0b(a){var b;return b=RD(mQb(RD(a,249).b,(yCc(),RAc)),75),!!b&&b.b!=0};sfb(PAe,'CompoundGraphPostprocessor/1',1280);feb(1279,1,QAe,E0b);_.Kf=function F0b(a,b){y0b(this,RD(a,36),b);};sfb(PAe,'CompoundGraphPreprocessor',1279);feb(453,1,{453:1},G0b);_.c=false;sfb(PAe,'CompoundGraphPreprocessor/ExternalPort',453);feb(249,1,{249:1},J0b);_.Ib=function K0b(){return ps(this.c)+':'+_0b(this.b)};sfb(PAe,'CrossHierarchyEdge',249);feb(777,1,fye,M0b);_.Ne=function N0b(a,b){return L0b(this,RD(a,249),RD(b,249))};_.Fb=function O0b(a){return this===a};_.Oe=function Q0b(){return new Frb(this)};sfb(PAe,'CrossHierarchyEdgeComparator',777);feb(305,137,{3:1,305:1,96:1,137:1});_.p=0;sfb(RAe,'LGraphElement',305);feb(18,305,{3:1,18:1,305:1,96:1,137:1},a1b);_.Ib=function b1b(){return _0b(this)};var WQ=sfb(RAe,'LEdge',18);feb(36,305,{3:1,20:1,36:1,305:1,96:1,137:1},d1b);_.Jc=function e1b(a){xgb(this,a);};_.Kc=function f1b(){return new Anb(this.b)};_.Ib=function g1b(){if(this.b.c.length==0){return 'G-unlayered'+Fe(this.a)}else if(this.a.c.length==0){return 'G-layered'+Fe(this.b)}return 'G[layerless'+Fe(this.a)+', layers'+Fe(this.b)+']'};var eR=sfb(RAe,'LGraph',36);var h1b;feb(666,1,{});_.Lf=function j1b(){return this.e.n};_.of=function k1b(a){return mQb(this.e,a)};_.Mf=function l1b(){return this.e.o};_.Nf=function m1b(){return this.e.p};_.pf=function n1b(a){return nQb(this.e,a)};_.Of=function o1b(a){this.e.n.a=a.a;this.e.n.b=a.b;};_.Pf=function p1b(a){this.e.o.a=a.a;this.e.o.b=a.b;};_.Qf=function q1b(a){this.e.p=a;};sfb(RAe,'LGraphAdapters/AbstractLShapeAdapter',666);feb(474,1,{853:1},r1b);_.Rf=function s1b(){var a,b;if(!this.b){this.b=ev(this.a.b.c.length);for(b=new Anb(this.a.b);b.a0&&M2b((BFb(c-1,b.length),b.charCodeAt(c-1)),ZAe)){--c;}if(g> ',a),M3b(c));Zhb(Yhb((a.a+='[',a),c.i),']');}return a.a};_.c=true;_.d=false;var D3b,E3b,F3b,G3b,H3b,I3b;var xR=sfb(RAe,'LPort',12);feb(408,1,Vve,T3b);_.Jc=function U3b(a){xgb(this,a);};_.Kc=function V3b(){var a;a=new Anb(this.a.e);return new W3b(a)};sfb(RAe,'LPort/1',408);feb(1309,1,Ave,W3b);_.Nb=function X3b(a){Ztb(this,a);};_.Pb=function Z3b(){return RD(ynb(this.a),18).c};_.Ob=function Y3b(){return xnb(this.a)};_.Qb=function $3b(){znb(this.a);};sfb(RAe,'LPort/1/1',1309);feb(369,1,Vve,_3b);_.Jc=function a4b(a){xgb(this,a);};_.Kc=function b4b(){var a;return a=new Anb(this.a.g),new c4b(a)};sfb(RAe,'LPort/2',369);feb(776,1,Ave,c4b);_.Nb=function d4b(a){Ztb(this,a);};_.Pb=function f4b(){return RD(ynb(this.a),18).d};_.Ob=function e4b(){return xnb(this.a)};_.Qb=function g4b(){znb(this.a);};sfb(RAe,'LPort/2/1',776);feb(1302,1,Vve,h4b);_.Jc=function i4b(a){xgb(this,a);};_.Kc=function j4b(){return new l4b(this)};sfb(RAe,'LPort/CombineIter',1302);feb(208,1,Ave,l4b);_.Nb=function m4b(a){Ztb(this,a);};_.Qb=function p4b(){$tb();};_.Ob=function n4b(){return k4b(this)};_.Pb=function o4b(){return xnb(this.a)?ynb(this.a):ynb(this.b)};sfb(RAe,'LPort/CombineIter/1',208);feb(1303,1,xye,r4b);_.Lb=function s4b(a){return q4b(a)};_.Fb=function t4b(a){return this===a};_.Mb=function u4b(a){return J3b(),RD(a,12).g.c.length!=0};sfb(RAe,'LPort/lambda$0$Type',1303);feb(1304,1,xye,w4b);_.Lb=function x4b(a){return v4b(a)};_.Fb=function y4b(a){return this===a};_.Mb=function z4b(a){return J3b(),RD(a,12).e.c.length!=0};sfb(RAe,'LPort/lambda$1$Type',1304);feb(1305,1,xye,A4b);_.Lb=function B4b(a){return J3b(),RD(a,12).j==(qpd(),Yod)};_.Fb=function C4b(a){return this===a};_.Mb=function D4b(a){return J3b(),RD(a,12).j==(qpd(),Yod)};sfb(RAe,'LPort/lambda$2$Type',1305);feb(1306,1,xye,E4b);_.Lb=function F4b(a){return J3b(),RD(a,12).j==(qpd(),Xod)};_.Fb=function G4b(a){return this===a};_.Mb=function H4b(a){return J3b(),RD(a,12).j==(qpd(),Xod)};sfb(RAe,'LPort/lambda$3$Type',1306);feb(1307,1,xye,I4b);_.Lb=function J4b(a){return J3b(),RD(a,12).j==(qpd(),npd)};_.Fb=function K4b(a){return this===a};_.Mb=function L4b(a){return J3b(),RD(a,12).j==(qpd(),npd)};sfb(RAe,'LPort/lambda$4$Type',1307);feb(1308,1,xye,M4b);_.Lb=function N4b(a){return J3b(),RD(a,12).j==(qpd(),ppd)};_.Fb=function O4b(a){return this===a};_.Mb=function P4b(a){return J3b(),RD(a,12).j==(qpd(),ppd)};sfb(RAe,'LPort/lambda$5$Type',1308);feb(30,305,{3:1,20:1,305:1,30:1,96:1,137:1},R4b);_.Jc=function S4b(a){xgb(this,a);};_.Kc=function T4b(){return new Anb(this.a)};_.Ib=function U4b(){return 'L_'+Wmb(this.b.b,this,0)+Fe(this.a)};sfb(RAe,'Layer',30);feb(1330,1,{},k5b);sfb(cBe,dBe,1330);feb(1334,1,{},o5b);_.Kb=function p5b(a){return AGd(RD(a,84))};sfb(cBe,'ElkGraphImporter/0methodref$connectableShapeToNode$Type',1334);feb(1337,1,{},q5b);_.Kb=function r5b(a){return AGd(RD(a,84))};sfb(cBe,'ElkGraphImporter/1methodref$connectableShapeToNode$Type',1337);feb(1331,1,Qve,s5b);_.Cd=function t5b(a){$4b(this.a,RD(a,123));};sfb(cBe,Nze,1331);feb(1332,1,Qve,u5b);_.Cd=function v5b(a){$4b(this.a,RD(a,123));};sfb(cBe,eBe,1332);feb(1333,1,{},w5b);_.Kb=function x5b(a){return new SDb(null,new Swb(mzd(RD(a,74)),16))};sfb(cBe,fBe,1333);feb(1335,1,nwe,y5b);_.Mb=function z5b(a){return l5b(this.a,RD(a,27))};sfb(cBe,gBe,1335);feb(1336,1,{},A5b);_.Kb=function B5b(a){return new SDb(null,new Swb(lzd(RD(a,74)),16))};sfb(cBe,'ElkGraphImporter/lambda$5$Type',1336);feb(1338,1,nwe,C5b);_.Mb=function D5b(a){return m5b(this.a,RD(a,27))};sfb(cBe,'ElkGraphImporter/lambda$7$Type',1338);feb(1339,1,nwe,E5b);_.Mb=function F5b(a){return n5b(RD(a,74))};sfb(cBe,'ElkGraphImporter/lambda$8$Type',1339);feb(1297,1,{},N5b);var G5b;sfb(cBe,'ElkGraphLayoutTransferrer',1297);feb(1298,1,nwe,Q5b);_.Mb=function R5b(a){return O5b(this.a,RD(a,18))};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$0$Type',1298);feb(1299,1,Qve,S5b);_.Cd=function T5b(a){H5b();Rmb(this.a,RD(a,18));};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$1$Type',1299);feb(1300,1,nwe,U5b);_.Mb=function V5b(a){return P5b(this.a,RD(a,18))};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$2$Type',1300);feb(1301,1,Qve,W5b);_.Cd=function X5b(a){H5b();Rmb(this.a,RD(a,18));};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$3$Type',1301);feb(819,1,{},e6b);sfb(hBe,'BiLinkedHashMultiMap',819);feb(1550,1,QAe,h6b);_.Kf=function i6b(a,b){f6b(RD(a,36),b);};sfb(hBe,'CommentNodeMarginCalculator',1550);feb(1551,1,{},j6b);_.Kb=function k6b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'CommentNodeMarginCalculator/lambda$0$Type',1551);feb(1552,1,Qve,l6b);_.Cd=function m6b(a){g6b(RD(a,10));};sfb(hBe,'CommentNodeMarginCalculator/lambda$1$Type',1552);feb(1553,1,QAe,q6b);_.Kf=function r6b(a,b){o6b(RD(a,36),b);};sfb(hBe,'CommentPostprocessor',1553);feb(1554,1,QAe,v6b);_.Kf=function w6b(a,b){s6b(RD(a,36),b);};sfb(hBe,'CommentPreprocessor',1554);feb(1555,1,QAe,y6b);_.Kf=function z6b(a,b){x6b(RD(a,36),b);};sfb(hBe,'ConstraintsPostprocessor',1555);feb(1556,1,QAe,G6b);_.Kf=function H6b(a,b){E6b(RD(a,36),b);};sfb(hBe,'EdgeAndLayerConstraintEdgeReverser',1556);feb(1557,1,QAe,K6b);_.Kf=function M6b(a,b){I6b(RD(a,36),b);};sfb(hBe,'EndLabelPostprocessor',1557);feb(1558,1,{},N6b);_.Kb=function O6b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelPostprocessor/lambda$0$Type',1558);feb(1559,1,nwe,P6b);_.Mb=function Q6b(a){return L6b(RD(a,10))};sfb(hBe,'EndLabelPostprocessor/lambda$1$Type',1559);feb(1560,1,Qve,R6b);_.Cd=function S6b(a){J6b(RD(a,10));};sfb(hBe,'EndLabelPostprocessor/lambda$2$Type',1560);feb(1561,1,QAe,b7b);_.Kf=function e7b(a,b){Z6b(RD(a,36),b);};sfb(hBe,'EndLabelPreprocessor',1561);feb(1562,1,{},f7b);_.Kb=function g7b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelPreprocessor/lambda$0$Type',1562);feb(1563,1,Qve,h7b);_.Cd=function i7b(a){V6b(this.a,this.b,this.c,RD(a,10));};_.a=0;_.b=0;_.c=false;sfb(hBe,'EndLabelPreprocessor/lambda$1$Type',1563);feb(1564,1,nwe,j7b);_.Mb=function k7b(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Nmd))};sfb(hBe,'EndLabelPreprocessor/lambda$2$Type',1564);feb(1565,1,Qve,l7b);_.Cd=function m7b(a){Mub(this.a,RD(a,72));};sfb(hBe,'EndLabelPreprocessor/lambda$3$Type',1565);feb(1566,1,nwe,n7b);_.Mb=function o7b(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Mmd))};sfb(hBe,'EndLabelPreprocessor/lambda$4$Type',1566);feb(1567,1,Qve,p7b);_.Cd=function q7b(a){Mub(this.a,RD(a,72));};sfb(hBe,'EndLabelPreprocessor/lambda$5$Type',1567);feb(1615,1,QAe,z7b);_.Kf=function A7b(a,b){w7b(RD(a,36),b);};var r7b;sfb(hBe,'EndLabelSorter',1615);feb(1616,1,fye,C7b);_.Ne=function D7b(a,b){return B7b(RD(a,466),RD(b,466))};_.Fb=function E7b(a){return this===a};_.Oe=function F7b(){return new Frb(this)};sfb(hBe,'EndLabelSorter/1',1616);feb(466,1,{466:1},G7b);sfb(hBe,'EndLabelSorter/LabelGroup',466);feb(1617,1,{},H7b);_.Kb=function I7b(a){return s7b(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelSorter/lambda$0$Type',1617);feb(1618,1,nwe,J7b);_.Mb=function K7b(a){return s7b(),RD(a,10).k==(r3b(),p3b)};sfb(hBe,'EndLabelSorter/lambda$1$Type',1618);feb(1619,1,Qve,L7b);_.Cd=function M7b(a){x7b(RD(a,10));};sfb(hBe,'EndLabelSorter/lambda$2$Type',1619);feb(1620,1,nwe,N7b);_.Mb=function O7b(a){return s7b(),dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Mmd))};sfb(hBe,'EndLabelSorter/lambda$3$Type',1620);feb(1621,1,nwe,P7b);_.Mb=function Q7b(a){return s7b(),dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Nmd))};sfb(hBe,'EndLabelSorter/lambda$4$Type',1621);feb(1568,1,QAe,a8b);_.Kf=function b8b(a,b){$7b(this,RD(a,36));};_.b=0;_.c=0;sfb(hBe,'FinalSplineBendpointsCalculator',1568);feb(1569,1,{},c8b);_.Kb=function d8b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$0$Type',1569);feb(1570,1,{},e8b);_.Kb=function f8b(a){return new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$1$Type',1570);feb(1571,1,nwe,g8b);_.Mb=function h8b(a){return !W0b(RD(a,18))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$2$Type',1571);feb(1572,1,nwe,i8b);_.Mb=function j8b(a){return nQb(RD(a,18),(Ywc(),Twc))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$3$Type',1572);feb(1573,1,Qve,k8b);_.Cd=function l8b(a){T7b(this.a,RD(a,131));};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$4$Type',1573);feb(1574,1,Qve,m8b);_.Cd=function n8b(a){Eob(RD(a,18).a);};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$5$Type',1574);feb(803,1,QAe,L8b);_.Kf=function M8b(a,b){C8b(this,RD(a,36),b);};sfb(hBe,'GraphTransformer',803);feb(517,22,{3:1,34:1,22:1,517:1},Q8b);var N8b,O8b;var vS=tfb(hBe,'GraphTransformer/Mode',517,WI,S8b,R8b);var T8b;feb(1575,1,QAe,Z8b);_.Kf=function $8b(a,b){W8b(RD(a,36),b);};sfb(hBe,'HierarchicalNodeResizingProcessor',1575);feb(1576,1,QAe,f9b);_.Kf=function g9b(a,b){b9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortConstraintProcessor',1576);feb(1577,1,fye,i9b);_.Ne=function j9b(a,b){return h9b(RD(a,10),RD(b,10))};_.Fb=function k9b(a){return this===a};_.Oe=function l9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortConstraintProcessor/NodeComparator',1577);feb(1578,1,QAe,o9b);_.Kf=function p9b(a,b){m9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortDummySizeProcessor',1578);feb(1579,1,QAe,C9b);_.Kf=function D9b(a,b){v9b(this,RD(a,36),b);};_.a=0;sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter',1579);feb(1580,1,fye,F9b);_.Ne=function G9b(a,b){return E9b(RD(a,10),RD(b,10))};_.Fb=function H9b(a){return this===a};_.Oe=function I9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter/1',1580);feb(1581,1,fye,K9b);_.Ne=function L9b(a,b){return J9b(RD(a,10),RD(b,10))};_.Fb=function M9b(a){return this===a};_.Oe=function N9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter/2',1581);feb(1582,1,QAe,Q9b);_.Kf=function R9b(a,b){P9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortPositionProcessor',1582);feb(1583,1,QAe,$9b);_.Kf=function _9b(a,b){Z9b(this,RD(a,36));};_.a=0;_.c=0;var S9b,T9b;sfb(hBe,'HighDegreeNodeLayeringProcessor',1583);feb(580,1,{580:1},aac);_.b=-1;_.d=-1;sfb(hBe,'HighDegreeNodeLayeringProcessor/HighDegreeNodeInformation',580);feb(1584,1,{},bac);_.Kb=function cac(a){return U9b(),Z2b(RD(a,10))};_.Fb=function dac(a){return this===a};sfb(hBe,'HighDegreeNodeLayeringProcessor/lambda$0$Type',1584);feb(1585,1,{},eac);_.Kb=function fac(a){return U9b(),a3b(RD(a,10))};_.Fb=function gac(a){return this===a};sfb(hBe,'HighDegreeNodeLayeringProcessor/lambda$1$Type',1585);feb(1591,1,QAe,mac);_.Kf=function nac(a,b){lac(this,RD(a,36),b);};sfb(hBe,'HyperedgeDummyMerger',1591);feb(804,1,{},oac);_.a=false;_.b=false;_.c=false;sfb(hBe,'HyperedgeDummyMerger/MergeState',804);feb(1592,1,{},pac);_.Kb=function qac(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'HyperedgeDummyMerger/lambda$0$Type',1592);feb(1593,1,{},rac);_.Kb=function sac(a){return new SDb(null,new Swb(RD(a,10).j,16))};sfb(hBe,'HyperedgeDummyMerger/lambda$1$Type',1593);feb(1594,1,Qve,tac);_.Cd=function uac(a){RD(a,12).p=-1;};sfb(hBe,'HyperedgeDummyMerger/lambda$2$Type',1594);feb(1595,1,QAe,xac);_.Kf=function yac(a,b){wac(RD(a,36),b);};sfb(hBe,'HypernodesProcessor',1595);feb(1596,1,QAe,Aac);_.Kf=function Bac(a,b){zac(RD(a,36),b);};sfb(hBe,'InLayerConstraintProcessor',1596);feb(1597,1,QAe,Dac);_.Kf=function Eac(a,b){Cac(RD(a,36),b);};sfb(hBe,'InnermostNodeMarginCalculator',1597);feb(1598,1,QAe,Iac);_.Kf=function Nac(a,b){Hac(this,RD(a,36));};_.a=pxe;_.b=pxe;_.c=oxe;_.d=oxe;var XS=sfb(hBe,'InteractiveExternalPortPositioner',1598);feb(1599,1,{},Oac);_.Kb=function Pac(a){return RD(a,18).d.i};_.Fb=function Qac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$0$Type',1599);feb(1600,1,{},Rac);_.Kb=function Sac(a){return Jac(this.a,UD(a))};_.Fb=function Tac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$1$Type',1600);feb(1601,1,{},Uac);_.Kb=function Vac(a){return RD(a,18).c.i};_.Fb=function Wac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$2$Type',1601);feb(1602,1,{},Xac);_.Kb=function Yac(a){return Kac(this.a,UD(a))};_.Fb=function Zac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$3$Type',1602);feb(1603,1,{},$ac);_.Kb=function _ac(a){return Lac(this.a,UD(a))};_.Fb=function abc(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$4$Type',1603);feb(1604,1,{},bbc);_.Kb=function cbc(a){return Mac(this.a,UD(a))};_.Fb=function dbc(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$5$Type',1604);feb(81,22,{3:1,34:1,22:1,81:1,196:1},icc);_.dg=function jcc(){switch(this.g){case 15:return new Hrc;case 22:return new bsc;case 47:return new ksc;case 28:case 35:return new Ldc;case 32:return new h6b;case 42:return new q6b;case 1:return new v6b;case 41:return new y6b;case 56:return new L8b((P8b(),O8b));case 0:return new L8b((P8b(),N8b));case 2:return new G6b;case 54:return new K6b;case 33:return new b7b;case 51:return new a8b;case 55:return new Z8b;case 13:return new f9b;case 38:return new o9b;case 44:return new C9b;case 40:return new Q9b;case 9:return new $9b;case 49:return new Yjc;case 37:return new mac;case 43:return new xac;case 27:return new Aac;case 30:return new Dac;case 3:return new Iac;case 18:return new scc;case 29:return new ycc;case 5:return new Lcc;case 50:return new Ucc;case 34:return new pdc;case 36:return new Zdc;case 52:return new z7b;case 11:return new fec;case 7:return new pec;case 39:return new Dec;case 45:return new Gec;case 16:return new Kec;case 10:return new _ec;case 48:return new Bfc;case 21:return new Ifc;case 23:return new FKc((RKc(),PKc));case 8:return new Rfc;case 12:return new Zfc;case 4:return new cgc;case 19:return new xgc;case 17:return new Vgc;case 53:return new Ygc;case 6:return new Nhc;case 25:return new ahc;case 46:return new rhc;case 31:return new Yhc;case 14:return new jic;case 26:return new Ssc;case 20:return new yic;case 24:return new FKc((RKc(),QKc));default:throw Adb(new agb(lBe+(this.f!=null?this.f:''+this.g)));}};var ebc,fbc,gbc,hbc,ibc,jbc,kbc,lbc,mbc,nbc,obc,pbc,qbc,rbc,sbc,tbc,ubc,vbc,wbc,xbc,ybc,zbc,Abc,Bbc,Cbc,Dbc,Ebc,Fbc,Gbc,Hbc,Ibc,Jbc,Kbc,Lbc,Mbc,Nbc,Obc,Pbc,Qbc,Rbc,Sbc,Tbc,Ubc,Vbc,Wbc,Xbc,Ybc,Zbc,$bc,_bc,acc,bcc,ccc,dcc,ecc,fcc,gcc;var YS=tfb(hBe,mBe,81,WI,lcc,kcc);var mcc;feb(1605,1,QAe,scc);_.Kf=function tcc(a,b){qcc(RD(a,36),b);};sfb(hBe,'InvertedPortProcessor',1605);feb(1606,1,QAe,ycc);_.Kf=function zcc(a,b){xcc(RD(a,36),b);};sfb(hBe,'LabelAndNodeSizeProcessor',1606);feb(1607,1,nwe,Acc);_.Mb=function Bcc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'LabelAndNodeSizeProcessor/lambda$0$Type',1607);feb(1608,1,nwe,Ccc);_.Mb=function Dcc(a){return RD(a,10).k==(r3b(),m3b)};sfb(hBe,'LabelAndNodeSizeProcessor/lambda$1$Type',1608);feb(1609,1,Qve,Ecc);_.Cd=function Fcc(a){vcc(this.b,this.a,this.c,RD(a,10));};_.a=false;_.c=false;sfb(hBe,'LabelAndNodeSizeProcessor/lambda$2$Type',1609);feb(1610,1,QAe,Lcc);_.Kf=function Mcc(a,b){Jcc(RD(a,36),b);};var Gcc;sfb(hBe,'LabelDummyInserter',1610);feb(1611,1,xye,Ncc);_.Lb=function Occ(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Lmd))};_.Fb=function Pcc(a){return this===a};_.Mb=function Qcc(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Lmd))};sfb(hBe,'LabelDummyInserter/1',1611);feb(1612,1,QAe,Ucc);_.Kf=function Vcc(a,b){Tcc(RD(a,36),b);};sfb(hBe,'LabelDummyRemover',1612);feb(1613,1,nwe,Wcc);_.Mb=function Xcc(a){return Heb(TD(mQb(RD(a,72),(yCc(),vAc))))};sfb(hBe,'LabelDummyRemover/lambda$0$Type',1613);feb(1378,1,QAe,pdc);_.Kf=function tdc(a,b){ldc(this,RD(a,36),b);};_.a=null;var Ycc;sfb(hBe,'LabelDummySwitcher',1378);feb(293,1,{293:1},xdc);_.c=0;_.d=null;_.f=0;sfb(hBe,'LabelDummySwitcher/LabelDummyInfo',293);feb(1379,1,{},ydc);_.Kb=function zdc(a){return Zcc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'LabelDummySwitcher/lambda$0$Type',1379);feb(1380,1,nwe,Adc);_.Mb=function Bdc(a){return Zcc(),RD(a,10).k==(r3b(),n3b)};sfb(hBe,'LabelDummySwitcher/lambda$1$Type',1380);feb(1381,1,{},Cdc);_.Kb=function Ddc(a){return qdc(this.a,RD(a,10))};sfb(hBe,'LabelDummySwitcher/lambda$2$Type',1381);feb(1382,1,Qve,Edc);_.Cd=function Fdc(a){rdc(this.a,RD(a,293));};sfb(hBe,'LabelDummySwitcher/lambda$3$Type',1382);feb(1383,1,fye,Gdc);_.Ne=function Hdc(a,b){return sdc(RD(a,293),RD(b,293))};_.Fb=function Idc(a){return this===a};_.Oe=function Jdc(){return new Frb(this)};sfb(hBe,'LabelDummySwitcher/lambda$4$Type',1383);feb(802,1,QAe,Ldc);_.Kf=function Mdc(a,b){Kdc(RD(a,36),b);};sfb(hBe,'LabelManagementProcessor',802);feb(1614,1,QAe,Zdc);_.Kf=function $dc(a,b){Tdc(RD(a,36),b);};sfb(hBe,'LabelSideSelector',1614);feb(1622,1,QAe,fec);_.Kf=function gec(a,b){bec(RD(a,36),b);};sfb(hBe,'LayerConstraintPostprocessor',1622);feb(1623,1,QAe,pec);_.Kf=function qec(a,b){nec(RD(a,36),b);};var hec;sfb(hBe,'LayerConstraintPreprocessor',1623);feb(371,22,{3:1,34:1,22:1,371:1},xec);var rec,sec,tec,uec;var qT=tfb(hBe,'LayerConstraintPreprocessor/HiddenNodeConnections',371,WI,zec,yec);var Aec;feb(1624,1,QAe,Dec);_.Kf=function Eec(a,b){Cec(RD(a,36),b);};sfb(hBe,'LayerSizeAndGraphHeightCalculator',1624);feb(1625,1,QAe,Gec);_.Kf=function Iec(a,b){Fec(RD(a,36),b);};sfb(hBe,'LongEdgeJoiner',1625);feb(1626,1,QAe,Kec);_.Kf=function Mec(a,b){Jec(RD(a,36),b);};sfb(hBe,'LongEdgeSplitter',1626);feb(1627,1,QAe,_ec);_.Kf=function cfc(a,b){Vec(this,RD(a,36),b);};_.e=0;_.f=0;_.j=0;_.k=0;_.n=0;_.o=0;var Pec,Qec;sfb(hBe,'NodePromotion',1627);feb(1628,1,fye,efc);_.Ne=function ffc(a,b){return dfc(RD(a,10),RD(b,10))};_.Fb=function gfc(a){return this===a};_.Oe=function hfc(){return new Frb(this)};sfb(hBe,'NodePromotion/1',1628);feb(1629,1,fye,jfc);_.Ne=function kfc(a,b){return ifc(RD(a,10),RD(b,10))};_.Fb=function lfc(a){return this===a};_.Oe=function mfc(){return new Frb(this)};sfb(hBe,'NodePromotion/2',1629);feb(1630,1,{},nfc);_.Kb=function ofc(a){return RD(a,42),Rec(),Geb(),true};_.Fb=function pfc(a){return this===a};sfb(hBe,'NodePromotion/lambda$0$Type',1630);feb(1631,1,{},qfc);_.Kb=function rfc(a){return afc(this.a,RD(a,42))};_.Fb=function sfc(a){return this===a};_.a=0;sfb(hBe,'NodePromotion/lambda$1$Type',1631);feb(1632,1,{},tfc);_.Kb=function ufc(a){return bfc(this.a,RD(a,42))};_.Fb=function vfc(a){return this===a};_.a=0;sfb(hBe,'NodePromotion/lambda$2$Type',1632);feb(1633,1,QAe,Bfc);_.Kf=function Cfc(a,b){wfc(RD(a,36),b);};sfb(hBe,'NorthSouthPortPostprocessor',1633);feb(1634,1,QAe,Ifc);_.Kf=function Kfc(a,b){Gfc(RD(a,36),b);};sfb(hBe,'NorthSouthPortPreprocessor',1634);feb(1635,1,fye,Lfc);_.Ne=function Mfc(a,b){return Jfc(RD(a,12),RD(b,12))};_.Fb=function Nfc(a){return this===a};_.Oe=function Ofc(){return new Frb(this)};sfb(hBe,'NorthSouthPortPreprocessor/lambda$0$Type',1635);feb(1636,1,QAe,Rfc);_.Kf=function Tfc(a,b){Qfc(RD(a,36),b);};sfb(hBe,'PartitionMidprocessor',1636);feb(1637,1,nwe,Ufc);_.Mb=function Vfc(a){return nQb(RD(a,10),(yCc(),tBc))};sfb(hBe,'PartitionMidprocessor/lambda$0$Type',1637);feb(1638,1,Qve,Wfc);_.Cd=function Xfc(a){Sfc(this.a,RD(a,10));};sfb(hBe,'PartitionMidprocessor/lambda$1$Type',1638);feb(1639,1,QAe,Zfc);_.Kf=function $fc(a,b){Yfc(RD(a,36),b);};sfb(hBe,'PartitionPostprocessor',1639);feb(1640,1,QAe,cgc);_.Kf=function dgc(a,b){agc(RD(a,36),b);};sfb(hBe,'PartitionPreprocessor',1640);feb(1641,1,nwe,egc);_.Mb=function fgc(a){return nQb(RD(a,10),(yCc(),tBc))};sfb(hBe,'PartitionPreprocessor/lambda$0$Type',1641);feb(1642,1,{},ggc);_.Kb=function hgc(a){return new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(hBe,'PartitionPreprocessor/lambda$1$Type',1642);feb(1643,1,nwe,igc);_.Mb=function jgc(a){return _fc(RD(a,18))};sfb(hBe,'PartitionPreprocessor/lambda$2$Type',1643);feb(1644,1,Qve,kgc);_.Cd=function lgc(a){bgc(RD(a,18));};sfb(hBe,'PartitionPreprocessor/lambda$3$Type',1644);feb(1645,1,QAe,xgc);_.Kf=function Bgc(a,b){ugc(RD(a,36),b);};var mgc,ngc,ogc,pgc,qgc,rgc;sfb(hBe,'PortListSorter',1645);feb(1648,1,fye,Dgc);_.Ne=function Egc(a,b){return ygc(RD(a,12),RD(b,12))};_.Fb=function Fgc(a){return this===a};_.Oe=function Ggc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$0$Type',1648);feb(1650,1,fye,Hgc);_.Ne=function Igc(a,b){return zgc(RD(a,12),RD(b,12))};_.Fb=function Jgc(a){return this===a};_.Oe=function Kgc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$1$Type',1650);feb(1646,1,{},Lgc);_.Kb=function Mgc(a){return sgc(),RD(a,12).e};sfb(hBe,'PortListSorter/lambda$2$Type',1646);feb(1647,1,{},Ngc);_.Kb=function Ogc(a){return sgc(),RD(a,12).g};sfb(hBe,'PortListSorter/lambda$3$Type',1647);feb(1649,1,fye,Pgc);_.Ne=function Qgc(a,b){return Agc(RD(a,12),RD(b,12))};_.Fb=function Rgc(a){return this===a};_.Oe=function Sgc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$4$Type',1649);feb(1651,1,QAe,Vgc);_.Kf=function Wgc(a,b){Tgc(RD(a,36),b);};sfb(hBe,'PortSideProcessor',1651);feb(1652,1,QAe,Ygc);_.Kf=function Zgc(a,b){Xgc(RD(a,36),b);};sfb(hBe,'ReversedEdgeRestorer',1652);feb(1657,1,QAe,ahc);_.Kf=function bhc(a,b){$gc(this,RD(a,36),b);};sfb(hBe,'SelfLoopPortRestorer',1657);feb(1658,1,{},chc);_.Kb=function dhc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopPortRestorer/lambda$0$Type',1658);feb(1659,1,nwe,ehc);_.Mb=function fhc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopPortRestorer/lambda$1$Type',1659);feb(1660,1,nwe,ghc);_.Mb=function hhc(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopPortRestorer/lambda$2$Type',1660);feb(1661,1,{},ihc);_.Kb=function jhc(a){return RD(mQb(RD(a,10),(Ywc(),Pwc)),337)};sfb(hBe,'SelfLoopPortRestorer/lambda$3$Type',1661);feb(1662,1,Qve,khc);_.Cd=function lhc(a){_gc(this.a,RD(a,337));};sfb(hBe,'SelfLoopPortRestorer/lambda$4$Type',1662);feb(805,1,Qve,mhc);_.Cd=function nhc(a){Rmc(RD(a,105));};sfb(hBe,'SelfLoopPortRestorer/lambda$5$Type',805);feb(1663,1,QAe,rhc);_.Kf=function thc(a,b){ohc(RD(a,36),b);};sfb(hBe,'SelfLoopPostProcessor',1663);feb(1664,1,{},uhc);_.Kb=function vhc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopPostProcessor/lambda$0$Type',1664);feb(1665,1,nwe,whc);_.Mb=function xhc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopPostProcessor/lambda$1$Type',1665);feb(1666,1,nwe,yhc);_.Mb=function zhc(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopPostProcessor/lambda$2$Type',1666);feb(1667,1,Qve,Ahc);_.Cd=function Bhc(a){phc(RD(a,10));};sfb(hBe,'SelfLoopPostProcessor/lambda$3$Type',1667);feb(1668,1,{},Chc);_.Kb=function Dhc(a){return new SDb(null,new Swb(RD(a,105).f,1))};sfb(hBe,'SelfLoopPostProcessor/lambda$4$Type',1668);feb(1669,1,Qve,Ehc);_.Cd=function Fhc(a){qhc(this.a,RD(a,340));};sfb(hBe,'SelfLoopPostProcessor/lambda$5$Type',1669);feb(1670,1,nwe,Ghc);_.Mb=function Hhc(a){return !!RD(a,105).i};sfb(hBe,'SelfLoopPostProcessor/lambda$6$Type',1670);feb(1671,1,Qve,Ihc);_.Cd=function Jhc(a){shc(this.a,RD(a,105));};sfb(hBe,'SelfLoopPostProcessor/lambda$7$Type',1671);feb(1653,1,QAe,Nhc);_.Kf=function Ohc(a,b){Mhc(RD(a,36),b);};sfb(hBe,'SelfLoopPreProcessor',1653);feb(1654,1,{},Phc);_.Kb=function Qhc(a){return new SDb(null,new Swb(RD(a,105).f,1))};sfb(hBe,'SelfLoopPreProcessor/lambda$0$Type',1654);feb(1655,1,{},Rhc);_.Kb=function Shc(a){return RD(a,340).a};sfb(hBe,'SelfLoopPreProcessor/lambda$1$Type',1655);feb(1656,1,Qve,Thc);_.Cd=function Uhc(a){Lhc(RD(a,18));};sfb(hBe,'SelfLoopPreProcessor/lambda$2$Type',1656);feb(1672,1,QAe,Yhc);_.Kf=function Zhc(a,b){Whc(this,RD(a,36),b);};sfb(hBe,'SelfLoopRouter',1672);feb(1673,1,{},$hc);_.Kb=function _hc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopRouter/lambda$0$Type',1673);feb(1674,1,nwe,aic);_.Mb=function bic(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopRouter/lambda$1$Type',1674);feb(1675,1,nwe,cic);_.Mb=function dic(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopRouter/lambda$2$Type',1675);feb(1676,1,{},eic);_.Kb=function fic(a){return RD(mQb(RD(a,10),(Ywc(),Pwc)),337)};sfb(hBe,'SelfLoopRouter/lambda$3$Type',1676);feb(1677,1,Qve,gic);_.Cd=function hic(a){Vhc(this.a,this.b,RD(a,337));};sfb(hBe,'SelfLoopRouter/lambda$4$Type',1677);feb(1678,1,QAe,jic);_.Kf=function mic(a,b){iic(RD(a,36),b);};sfb(hBe,'SemiInteractiveCrossMinProcessor',1678);feb(1679,1,nwe,nic);_.Mb=function oic(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$0$Type',1679);feb(1680,1,nwe,pic);_.Mb=function qic(a){return lQb(RD(a,10))._b((yCc(),IBc))};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$1$Type',1680);feb(1681,1,fye,ric);_.Ne=function sic(a,b){return kic(RD(a,10),RD(b,10))};_.Fb=function tic(a){return this===a};_.Oe=function uic(){return new Frb(this)};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$2$Type',1681);feb(1682,1,{},vic);_.Ve=function wic(a,b){return lic(RD(a,10),RD(b,10))};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$3$Type',1682);feb(1684,1,QAe,yic);_.Kf=function Cic(a,b){xic(RD(a,36),b);};sfb(hBe,'SortByInputModelProcessor',1684);feb(1685,1,nwe,Dic);_.Mb=function Eic(a){return RD(a,12).g.c.length!=0};sfb(hBe,'SortByInputModelProcessor/lambda$0$Type',1685);feb(1686,1,Qve,Fic);_.Cd=function Gic(a){Aic(this.a,RD(a,12));};sfb(hBe,'SortByInputModelProcessor/lambda$1$Type',1686);feb(1759,817,{},Pic);_.df=function Qic(a){var b,c,d,e;this.c=a;switch(this.a.g){case 2:b=new bnb;FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new Rjc),new Tjc(this,b));eHb(this,new Zic);Umb(b,new bjc);b.c.length=0;FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new djc),new fjc(b));eHb(this,new jjc);Umb(b,new njc);b.c.length=0;c=Wvb(TCb(HDb(new SDb(null,new Swb(this.c.a.b,16)),new pjc(this))),new rjc);FDb(new SDb(null,new Swb(this.c.a.a,16)),new vjc(c,b));eHb(this,new zjc);Umb(b,new Djc);b.c.length=0;break;case 3:d=new bnb;eHb(this,new Ric);e=Wvb(TCb(HDb(new SDb(null,new Swb(this.c.a.b,16)),new Vic(this))),new tjc);FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new Fjc),new Hjc(e,d));eHb(this,new Ljc);Umb(d,new Pjc);d.c.length=0;break;default:throw Adb(new Ied);}};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation',1759);feb(1760,1,xye,Ric);_.Lb=function Sic(a){return ZD(RD(a,60).g,154)};_.Fb=function Tic(a){return this===a};_.Mb=function Uic(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$0$Type',1760);feb(1761,1,{},Vic);_.Ye=function Wic(a){return Jic(this.a,RD(a,60))};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$1$Type',1761);feb(1769,1,owe,Xic);_.de=function Yic(){Iic(this.a,this.b,-1);};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$10$Type',1769);feb(1771,1,xye,Zic);_.Lb=function $ic(a){return ZD(RD(a,60).g,154)};_.Fb=function _ic(a){return this===a};_.Mb=function ajc(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$11$Type',1771);feb(1772,1,Qve,bjc);_.Cd=function cjc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$12$Type',1772);feb(1773,1,nwe,djc);_.Mb=function ejc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$13$Type',1773);feb(1775,1,Qve,fjc);_.Cd=function gjc(a){Kic(this.a,RD(a,60));};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$14$Type',1775);feb(1774,1,owe,hjc);_.de=function ijc(){Iic(this.b,this.a,-1);};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$15$Type',1774);feb(1776,1,xye,jjc);_.Lb=function kjc(a){return ZD(RD(a,60).g,10)};_.Fb=function ljc(a){return this===a};_.Mb=function mjc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$16$Type',1776);feb(1777,1,Qve,njc);_.Cd=function ojc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$17$Type',1777);feb(1778,1,{},pjc);_.Ye=function qjc(a){return Lic(this.a,RD(a,60))};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$18$Type',1778);feb(1779,1,{},rjc);_.We=function sjc(){return 0};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$19$Type',1779);feb(1762,1,{},tjc);_.We=function ujc(){return 0};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$2$Type',1762);feb(1781,1,Qve,vjc);_.Cd=function wjc(a){Mic(this.a,this.b,RD(a,316));};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$20$Type',1781);feb(1780,1,owe,xjc);_.de=function yjc(){Hic(this.a,this.b,-1);};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$21$Type',1780);feb(1782,1,xye,zjc);_.Lb=function Ajc(a){return RD(a,60),true};_.Fb=function Bjc(a){return this===a};_.Mb=function Cjc(a){return RD(a,60),true};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$22$Type',1782);feb(1783,1,Qve,Djc);_.Cd=function Ejc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$23$Type',1783);feb(1763,1,nwe,Fjc);_.Mb=function Gjc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$3$Type',1763);feb(1765,1,Qve,Hjc);_.Cd=function Ijc(a){Nic(this.a,this.b,RD(a,60));};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$4$Type',1765);feb(1764,1,owe,Jjc);_.de=function Kjc(){Iic(this.b,this.a,-1);};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$5$Type',1764);feb(1766,1,xye,Ljc);_.Lb=function Mjc(a){return RD(a,60),true};_.Fb=function Njc(a){return this===a};_.Mb=function Ojc(a){return RD(a,60),true};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$6$Type',1766);feb(1767,1,Qve,Pjc);_.Cd=function Qjc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$7$Type',1767);feb(1768,1,nwe,Rjc);_.Mb=function Sjc(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$8$Type',1768);feb(1770,1,Qve,Tjc);_.Cd=function Ujc(a){Oic(this.a,this.b,RD(a,60));};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$9$Type',1770);feb(1586,1,QAe,Yjc);_.Kf=function bkc(a,b){Xjc(this,RD(a,36),b);};var Vjc;sfb(rBe,'HorizontalGraphCompactor',1586);feb(1587,1,{},ckc);_.ff=function dkc(a,b){var c,d,e;if(_jc(a,b)){return 0}c=Zjc(a);d=Zjc(b);if(!!c&&c.k==(r3b(),m3b)||!!d&&d.k==(r3b(),m3b)){return 0}e=RD(mQb(this.a.a,(Ywc(),Qwc)),312);return ZEc(e,c?c.k:(r3b(),o3b),d?d.k:(r3b(),o3b))};_.gf=function ekc(a,b){var c,d,e;if(_jc(a,b)){return 1}c=Zjc(a);d=Zjc(b);e=RD(mQb(this.a.a,(Ywc(),Qwc)),312);return aFc(e,c?c.k:(r3b(),o3b),d?d.k:(r3b(),o3b))};sfb(rBe,'HorizontalGraphCompactor/1',1587);feb(1588,1,{},fkc);_.ef=function gkc(a,b){return Wjc(),a.a.i==0};sfb(rBe,'HorizontalGraphCompactor/lambda$0$Type',1588);feb(1589,1,{},hkc);_.ef=function ikc(a,b){return akc(this.a,a,b)};sfb(rBe,'HorizontalGraphCompactor/lambda$1$Type',1589);feb(1730,1,{},Ckc);var jkc,kkc;sfb(rBe,'LGraphToCGraphTransformer',1730);feb(1738,1,nwe,Kkc);_.Mb=function Lkc(a){return a!=null};sfb(rBe,'LGraphToCGraphTransformer/0methodref$nonNull$Type',1738);feb(1731,1,{},Mkc);_.Kb=function Nkc(a){return lkc(),jeb(mQb(RD(RD(a,60).g,10),(Ywc(),Awc)))};sfb(rBe,'LGraphToCGraphTransformer/lambda$0$Type',1731);feb(1732,1,{},Okc);_.Kb=function Pkc(a){return lkc(),Mlc(RD(RD(a,60).g,154))};sfb(rBe,'LGraphToCGraphTransformer/lambda$1$Type',1732);feb(1741,1,nwe,Qkc);_.Mb=function Rkc(a){return lkc(),ZD(RD(a,60).g,10)};sfb(rBe,'LGraphToCGraphTransformer/lambda$10$Type',1741);feb(1742,1,Qve,Skc);_.Cd=function Tkc(a){Dkc(RD(a,60));};sfb(rBe,'LGraphToCGraphTransformer/lambda$11$Type',1742);feb(1743,1,nwe,Ukc);_.Mb=function Vkc(a){return lkc(),ZD(RD(a,60).g,154)};sfb(rBe,'LGraphToCGraphTransformer/lambda$12$Type',1743);feb(1747,1,Qve,Wkc);_.Cd=function Xkc(a){Ekc(RD(a,60));};sfb(rBe,'LGraphToCGraphTransformer/lambda$13$Type',1747);feb(1744,1,Qve,Ykc);_.Cd=function Zkc(a){Fkc(this.a,RD(a,8));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$14$Type',1744);feb(1745,1,Qve,$kc);_.Cd=function _kc(a){Gkc(this.a,RD(a,116));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$15$Type',1745);feb(1746,1,Qve,alc);_.Cd=function blc(a){Hkc(this.a,RD(a,8));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$16$Type',1746);feb(1748,1,{},clc);_.Kb=function dlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$17$Type',1748);feb(1749,1,nwe,elc);_.Mb=function flc(a){return lkc(),W0b(RD(a,18))};sfb(rBe,'LGraphToCGraphTransformer/lambda$18$Type',1749);feb(1750,1,Qve,glc);_.Cd=function hlc(a){ukc(this.a,RD(a,18));};sfb(rBe,'LGraphToCGraphTransformer/lambda$19$Type',1750);feb(1734,1,Qve,ilc);_.Cd=function jlc(a){vkc(this.a,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$2$Type',1734);feb(1751,1,{},klc);_.Kb=function llc(a){return lkc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(rBe,'LGraphToCGraphTransformer/lambda$20$Type',1751);feb(1752,1,{},mlc);_.Kb=function nlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$21$Type',1752);feb(1753,1,{},olc);_.Kb=function plc(a){return lkc(),RD(mQb(RD(a,18),(Ywc(),Twc)),15)};sfb(rBe,'LGraphToCGraphTransformer/lambda$22$Type',1753);feb(1754,1,nwe,qlc);_.Mb=function rlc(a){return Ikc(RD(a,15))};sfb(rBe,'LGraphToCGraphTransformer/lambda$23$Type',1754);feb(1755,1,Qve,slc);_.Cd=function tlc(a){nkc(this.a,RD(a,15));};sfb(rBe,'LGraphToCGraphTransformer/lambda$24$Type',1755);feb(1733,1,Qve,ulc);_.Cd=function vlc(a){wkc(this.a,this.b,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$3$Type',1733);feb(1735,1,{},wlc);_.Kb=function xlc(a){return lkc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(rBe,'LGraphToCGraphTransformer/lambda$4$Type',1735);feb(1736,1,{},ylc);_.Kb=function zlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$5$Type',1736);feb(1737,1,{},Alc);_.Kb=function Blc(a){return lkc(),RD(mQb(RD(a,18),(Ywc(),Twc)),15)};sfb(rBe,'LGraphToCGraphTransformer/lambda$6$Type',1737);feb(1739,1,Qve,Clc);_.Cd=function Dlc(a){Jkc(this.a,RD(a,15));};sfb(rBe,'LGraphToCGraphTransformer/lambda$8$Type',1739);feb(1740,1,Qve,Elc);_.Cd=function Flc(a){xkc(this.a,this.b,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$9$Type',1740);feb(1729,1,{},Jlc);_.cf=function Klc(a){var b,c,d,e,f;this.a=a;this.d=new BIb;this.c=$C(DN,rve,125,this.a.a.a.c.length,0,1);this.b=0;for(c=new Anb(this.a.a.a);c.a=p){Rmb(f,sgb(k));s=$wnd.Math.max(s,t[k-1]-l);h+=o;q+=t[k-1]-q;l=t[k-1];o=i[k];}o=$wnd.Math.max(o,i[k]);++k;}h+=o;}n=$wnd.Math.min(1/s,1/b.b/h);if(n>d){d=n;c=f;}}return c};_.pg=function Psc(){return false};sfb(zBe,'MSDCutIndexHeuristic',816);feb(1683,1,QAe,Ssc);_.Kf=function Tsc(a,b){Rsc(RD(a,36),b);};sfb(zBe,'SingleEdgeGraphWrapper',1683);feb(232,22,{3:1,34:1,22:1,232:1},ctc);var Xsc,Ysc,Zsc,$sc,_sc,atc;var ZW=tfb(ABe,'CenterEdgeLabelPlacementStrategy',232,WI,etc,dtc);var ftc;feb(431,22,{3:1,34:1,22:1,431:1},ktc);var htc,itc;var $W=tfb(ABe,'ConstraintCalculationStrategy',431,WI,mtc,ltc);var ntc;feb(322,22,{3:1,34:1,22:1,322:1,188:1,196:1},utc);_.dg=function wtc(){return ttc(this)};_.qg=function vtc(){return ttc(this)};var ptc,qtc,rtc;var _W=tfb(ABe,'CrossingMinimizationStrategy',322,WI,ytc,xtc);var ztc;feb(351,22,{3:1,34:1,22:1,351:1},Ftc);var Btc,Ctc,Dtc;var aX=tfb(ABe,'CuttingStrategy',351,WI,Htc,Gtc);var Itc;feb(348,22,{3:1,34:1,22:1,348:1,188:1,196:1},Rtc);_.dg=function Ttc(){return Qtc(this)};_.qg=function Stc(){return Qtc(this)};var Ktc,Ltc,Mtc,Ntc,Otc;var bX=tfb(ABe,'CycleBreakingStrategy',348,WI,Vtc,Utc);var Wtc;feb(428,22,{3:1,34:1,22:1,428:1},_tc);var Ytc,Ztc;var cX=tfb(ABe,'DirectionCongruency',428,WI,buc,auc);var cuc;feb(460,22,{3:1,34:1,22:1,460:1},iuc);var euc,fuc,guc;var dX=tfb(ABe,'EdgeConstraint',460,WI,kuc,juc);var luc;feb(283,22,{3:1,34:1,22:1,283:1},vuc);var nuc,ouc,puc,quc,ruc,suc;var eX=tfb(ABe,'EdgeLabelSideSelection',283,WI,xuc,wuc);var yuc;feb(488,22,{3:1,34:1,22:1,488:1},Duc);var Auc,Buc;var fX=tfb(ABe,'EdgeStraighteningStrategy',488,WI,Fuc,Euc);var Guc;feb(281,22,{3:1,34:1,22:1,281:1},Puc);var Iuc,Juc,Kuc,Luc,Muc,Nuc;var gX=tfb(ABe,'FixedAlignment',281,WI,Ruc,Quc);var Suc;feb(282,22,{3:1,34:1,22:1,282:1},_uc);var Uuc,Vuc,Wuc,Xuc,Yuc,Zuc;var hX=tfb(ABe,'GraphCompactionStrategy',282,WI,bvc,avc);var cvc;feb(259,22,{3:1,34:1,22:1,259:1},pvc);var evc,fvc,gvc,hvc,ivc,jvc,kvc,lvc,mvc,nvc;var iX=tfb(ABe,'GraphProperties',259,WI,rvc,qvc);var svc;feb(299,22,{3:1,34:1,22:1,299:1},yvc);var uvc,vvc,wvc;var jX=tfb(ABe,'GreedySwitchType',299,WI,Avc,zvc);var Bvc;feb(311,22,{3:1,34:1,22:1,311:1},Hvc);var Dvc,Evc,Fvc;var kX=tfb(ABe,'InLayerConstraint',311,WI,Jvc,Ivc);var Kvc;feb(429,22,{3:1,34:1,22:1,429:1},Pvc);var Mvc,Nvc;var lX=tfb(ABe,'InteractiveReferencePoint',429,WI,Rvc,Qvc);var Svc;var Uvc,Vvc,Wvc,Xvc,Yvc,Zvc,$vc,_vc,awc,bwc,cwc,dwc,ewc,fwc,gwc,hwc,iwc,jwc,kwc,lwc,mwc,nwc,owc,pwc,qwc,rwc,swc,twc,uwc,vwc,wwc,xwc,ywc,zwc,Awc,Bwc,Cwc,Dwc,Ewc,Fwc,Gwc,Hwc,Iwc,Jwc,Kwc,Lwc,Mwc,Nwc,Owc,Pwc,Qwc,Rwc,Swc,Twc,Uwc,Vwc,Wwc,Xwc;feb(171,22,{3:1,34:1,22:1,171:1},dxc);var Zwc,$wc,_wc,axc,bxc;var mX=tfb(ABe,'LayerConstraint',171,WI,fxc,exc);var gxc;feb(859,1,Eye,Pzc);_.hf=function Qzc(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,HBe),''),'Direction Congruency'),'Specifies how drawings of the same graph with different layout directions compare to each other: either a natural reading direction is preserved or the drawings are rotated versions of each other.'),Uxc),(kid(),eid)),cX),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,IBe),''),'Feedback Edges'),'Whether feedback edges should be highlighted by routing around the nodes.'),(Geb(),false)),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JBe),''),'Interactive Reference Point'),'Determines which point of a node is considered by interactive layout phases.'),pyc),eid),lX),xsb(Whd))));zgd(a,JBe,RBe,ryc);zgd(a,JBe,_Be,qyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KBe),''),'Merge Edges'),'Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LBe),''),'Merge Hierarchy-Crossing Edges'),'If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Nhd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MBe),''),'Allow Non-Flow Ports To Switch Sides'),"Specifies whether non-flow ports may switch sides if their node's port constraints are either FIXED_SIDE or FIXED_ORDER. A non-flow port is a port on a side that is not part of the currently configured layout flow. For instance, given a left-to-right layout direction, north and south ports would be considered non-flow ports. Further note that the underlying criterium whether to switch sides or not solely relies on the minimization of edge crossings. Hence, edge length and other aesthetics criteria are not addressed."),false),cid),QI),xsb(Xhd)),cD(WC(qJ,1),Nve,2,6,['org.eclipse.elk.layered.northOrSouthPort']))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NBe),''),'Port Sorting Strategy'),"Only relevant for nodes with FIXED_SIDE port constraints. Determines the way a node's ports are distributed on the sides of a node if their order is not prescribed. The option is set on parent nodes."),azc),eid),xX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,OBe),''),'Thoroughness'),'How much effort should be spent to produce a nice layout.'),sgb(7)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PBe),''),'Add Unnecessary Bendpoints'),'Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,QBe),''),'Generate Position and Layer IDs'),'If enabled position id and layer id are generated, which are usually only used internally when setting the interactiveLayout option. This option should be specified on the root node.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RBe),'cycleBreaking'),'Cycle Breaking Strategy'),'Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right).'),Sxc),eid),bX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SBe),bDe),'Node Layering Strategy'),'Strategy for node layering.'),Gyc),eid),rX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TBe),bDe),'Layer Constraint'),'Determines a constraint on the placement of the node regarding the layering.'),wyc),eid),mX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UBe),bDe),'Layer Choice Constraint'),"Allows to set a constraint regarding the layer placement of a node. Let i be the value of teh constraint. Assumed the drawing has n layers and i < n. If set to i, it expresses that the node should be placed in i-th layer. Should i>=n be true then the node is placed in the last layer of the drawing. Note that this option is not part of any of ELK Layered's default configurations but is only evaluated as part of the `InteractiveLayeredGraphVisitor`, which must be applied manually or used via the `DiagramLayoutEngine."),null),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VBe),bDe),'Layer ID'),'Layer identifier that was calculated by ELK Layered for a node. This is only generated if interactiveLayot or generatePositionAndLayerIds is set.'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WBe),cDe),'Upper Bound On Width [MinWidth Layerer]'),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),sgb(4)),gid),bJ),xsb(Whd))));zgd(a,WBe,SBe,zyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XBe),cDe),'Upper Layer Estimation Scaling Factor [MinWidth Layerer]'),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),sgb(2)),gid),bJ),xsb(Whd))));zgd(a,XBe,SBe,Byc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YBe),dDe),'Node Promotion Strategy'),'Reduces number of dummy nodes after layering phase (if possible).'),Eyc),eid),vX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZBe),dDe),'Max Node Promotion Iterations'),'Limits the number of iterations for node promotion.'),sgb(0)),gid),bJ),xsb(Whd))));zgd(a,ZBe,YBe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Be),'layering.coffmanGraham'),'Layer Bound'),'The maximum number of nodes allowed per layer.'),sgb(lve)),gid),bJ),xsb(Whd))));zgd(a,$Be,SBe,tyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Be),eDe),'Crossing Minimization Strategy'),'Strategy for crossing minimization.'),Qxc),eid),_W),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aCe),eDe),'Force Node Model Order'),'The node order given by the model does not change to produce a better layout. E.g. if node A is before node B in the model this is not changed during crossing minimization. This assumes that the node model order is already respected before crossing minimization. This can be achieved by setting considerModelOrder.strategy to NODES_AND_EDGES.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bCe),eDe),'Hierarchical Sweepiness'),'How likely it is to use cross-hierarchy (1) vs bottom-up (-1).'),0.1),did),VI),xsb(Whd))));zgd(a,bCe,fDe,Ixc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,cCe),eDe),'Semi-Interactive Crossing Minimization'),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),false),cid),QI),xsb(Whd))));zgd(a,cCe,_Be,Oxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dCe),eDe),'In Layer Predecessor of'),"Allows to set a constraint which specifies of which node the current node is the predecessor. If set to 's' then the node is the predecessor of 's' and is in the same layer"),null),iid),qJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eCe),eDe),'In Layer Successor of'),"Allows to set a constraint which specifies of which node the current node is the successor. If set to 's' then the node is the successor of 's' and is in the same layer"),null),iid),qJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fCe),eDe),'Position Choice Constraint'),"Allows to set a constraint regarding the position placement of a node in a layer. Assumed the layer in which the node placed includes n other nodes and i < n. If set to i, it expresses that the node should be placed at the i-th position. Should i>=n be true then the node is placed at the last position in the layer. Note that this option is not part of any of ELK Layered's default configurations but is only evaluated as part of the `InteractiveLayeredGraphVisitor`, which must be applied manually or used via the `DiagramLayoutEngine."),null),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gCe),eDe),'Position ID'),'Position within a layer that was determined by ELK Layered for a node. This is only generated if interactiveLayot or generatePositionAndLayerIds is set.'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hCe),gDe),'Greedy Switch Activation Threshold'),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),sgb(40)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iCe),gDe),'Greedy Switch Crossing Minimization'),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular crossing minimization as a post-processor. Note that if 'hierarchyHandling' is set to 'INCLUDE_CHILDREN', the 'greedySwitchHierarchical.type' option must be used."),Fxc),eid),jX),xsb(Whd))));zgd(a,iCe,_Be,Gxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,jCe),'crossingMinimization.greedySwitchHierarchical'),'Greedy Switch Crossing Minimization (hierarchical)'),"Activates the greedy switch heuristic in case hierarchical layout is used. The differences to the non-hierarchical case (see 'greedySwitch.type') are: 1) greedy switch is inactive by default, 3) only the option value set on the node at which hierarchical layout starts is relevant, and 2) if it's activated by the user, it properly addresses hierarchy-crossing edges."),Bxc),eid),jX),xsb(Whd))));zgd(a,jCe,_Be,Cxc);zgd(a,jCe,fDe,Dxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kCe),hDe),'Node Placement Strategy'),'Strategy for node placement.'),$yc),eid),uX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,lCe),hDe),'Favor Straight Edges Over Balancing'),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),cid),QI),xsb(Whd))));zgd(a,lCe,kCe,Qyc);zgd(a,lCe,kCe,Ryc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,mCe),iDe),'BK Edge Straightening'),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),Kyc),eid),fX),xsb(Whd))));zgd(a,mCe,kCe,Lyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,nCe),iDe),'BK Fixed Alignment'),'Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four.'),Nyc),eid),gX),xsb(Whd))));zgd(a,nCe,kCe,Oyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,oCe),'nodePlacement.linearSegments'),'Linear Segments Deflection Dampening'),'Dampens the movement of nodes to keep the diagram from getting too large.'),0.3),did),VI),xsb(Whd))));zgd(a,oCe,kCe,Tyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,pCe),'nodePlacement.networkSimplex'),'Node Flexibility'),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),eid),tX),xsb(Vhd))));zgd(a,pCe,kCe,Yyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,qCe),'nodePlacement.networkSimplex.nodeFlexibility'),'Node Flexibility Default'),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),Wyc),eid),tX),xsb(Whd))));zgd(a,qCe,kCe,Xyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,rCe),jDe),'Self-Loop Distribution'),'Alter the distribution of the loops around the node. It only takes effect for PortConstraints.FREE.'),ayc),eid),zX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,sCe),jDe),'Self-Loop Ordering'),'Alter the ordering of the loops they can either be stacked or sequenced. It only takes effect for PortConstraints.FREE.'),cyc),eid),AX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,tCe),'edgeRouting.splines'),'Spline Routing Mode'),'Specifies the way control points are assembled for each individual edge. CONSERVATIVE ensures that edges are properly routed around the nodes but feels rather orthogonal at times. SLOPPY uses fewer control points to obtain curvier edge routes but may result in edges overlapping nodes.'),eyc),eid),CX),xsb(Whd))));zgd(a,tCe,kDe,fyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,uCe),'edgeRouting.splines.sloppy'),'Sloppy Spline Layer Spacing Factor'),'Spacing factor for routing area between layers when using sloppy spline routing.'),0.2),did),VI),xsb(Whd))));zgd(a,uCe,kDe,hyc);zgd(a,uCe,tCe,iyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,vCe),'edgeRouting.polyline'),'Sloped Edge Zone Width'),'Width of the strip to the left and to the right of each layer where the polyline edge router is allowed to refrain from ensuring that edges are routed horizontally. This prevents awkward bend points for nodes that extent almost to the edge of their layer.'),2),did),VI),xsb(Whd))));zgd(a,vCe,kDe,$xc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,wCe),lDe),'Spacing Base Value'),"An optional base value for all other layout options of the 'spacing' group. It can be used to conveniently alter the overall 'spaciousness' of the drawing. Whenever an explicit value is set for the other layout options, this base value will have no effect. The base value is not inherited, i.e. it must be set for each hierarchical node."),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xCe),lDe),'Edge Node Between Layers Spacing'),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yCe),lDe),'Edge Edge Between Layer Spacing'),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zCe),lDe),'Node Node Between Layers Spacing'),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ACe),mDe),'Direction Priority'),'Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,BCe),mDe),'Shortness Priority'),'Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CCe),mDe),'Straightness Priority'),'Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,DCe),nDe),qze),'Tries to further compact components (disconnected sub-graphs).'),false),cid),QI),xsb(Whd))));zgd(a,DCe,cAe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ECe),oDe),'Post Compaction Strategy'),pDe),nxc),eid),hX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,FCe),oDe),'Post Compaction Constraint Calculation'),pDe),lxc),eid),$W),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,GCe),qDe),'High Degree Node Treatment'),'Makes room around high degree nodes to place leafs and trees.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,HCe),qDe),'High Degree Node Threshold'),'Whether a node is considered to have a high degree.'),sgb(16)),gid),bJ),xsb(Whd))));zgd(a,HCe,GCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ICe),qDe),'High Degree Node Maximum Tree Height'),'Maximum height of a subtree connected to a high degree node to be moved to separate layers.'),sgb(5)),gid),bJ),xsb(Whd))));zgd(a,ICe,GCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JCe),rDe),'Graph Wrapping Strategy'),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),Gzc),eid),EX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KCe),rDe),'Additional Wrapped Edges Spacing'),'To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing.'),10),did),VI),xsb(Whd))));zgd(a,KCe,JCe,lzc);zgd(a,KCe,JCe,mzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LCe),rDe),'Correction Factor for Wrapping'),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simply multiplied with the 'aspect ratio' layout option."),1),did),VI),xsb(Whd))));zgd(a,LCe,JCe,ozc);zgd(a,LCe,JCe,pzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MCe),sDe),'Cutting Strategy'),'The strategy by which the layer indexes are determined at which the layering crumbles into chunks.'),wzc),eid),aX),xsb(Whd))));zgd(a,MCe,JCe,xzc);zgd(a,MCe,JCe,yzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,NCe),sDe),'Manually Specified Cuts'),'Allows the user to specify her own cuts for a certain graph.'),hid),QK),xsb(Whd))));zgd(a,NCe,MCe,rzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,OCe),'wrapping.cutting.msd'),'MSD Freedom'),'The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts.'),tzc),gid),bJ),xsb(Whd))));zgd(a,OCe,MCe,uzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PCe),tDe),'Validification Strategy'),'When wrapping graphs, one can specify indices that are not allowed as split points. The validification strategy makes sure every computed split point is allowed.'),Lzc),eid),DX),xsb(Whd))));zgd(a,PCe,JCe,Mzc);zgd(a,PCe,JCe,Nzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,QCe),tDe),'Valid Indices for Wrapping'),null),hid),QK),xsb(Whd))));zgd(a,QCe,JCe,Izc);zgd(a,QCe,JCe,Jzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RCe),uDe),'Improve Cuts'),'For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought.'),true),cid),QI),xsb(Whd))));zgd(a,RCe,JCe,Czc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SCe),uDe),'Distance Penalty When Improving Cuts'),null),2),did),VI),xsb(Whd))));zgd(a,SCe,JCe,Azc);zgd(a,SCe,RCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TCe),uDe),'Improve Wrapped Edges'),'The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges.'),true),cid),QI),xsb(Whd))));zgd(a,TCe,JCe,Ezc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UCe),vDe),'Edge Label Side Selection'),'Method to decide on edge label sides.'),Yxc),eid),eX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VCe),vDe),'Edge Center Label Placement Strategy'),'Determines in which layer center labels of long edges should be placed.'),Wxc),eid),ZW),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WCe),wDe),'Consider Model Order'),'Preserves the order of nodes and edges in the model file if this does not lead to additional edge crossings. Depending on the strategy this is not always possible since the node and edge order might be conflicting.'),xxc),eid),wX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XCe),wDe),'Consider Port Order'),'If disabled the port order of output ports is derived from the edge order and input ports are ordered by their incoming connections. If enabled all ports are ordered by the port model order.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YCe),wDe),'No Model Order'),'Set on a node to not set a model order for this node even though it is a real node.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZCe),wDe),'Consider Model Order for Components'),'If set to NONE the usual ordering strategy (by cumulative node priority and size of nodes) is used. INSIDE_PORT_SIDES orders the components with external ports only inside the groups with the same port side. FORCE_MODEL_ORDER enforces the mode order on components. This option might produce bad alignments and sub optimal drawings in terms of used area since the ordering should be respected.'),pxc),eid),CQ),xsb(Whd))));zgd(a,ZCe,cAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Ce),wDe),'Long Edge Ordering Strategy'),'Indicates whether long edges are sorted under, over, or equal to nodes that have no connection to a previous layer in a left-to-right or right-to-left layout. Under and over changes to right and left in a vertical layout.'),txc),eid),sX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Ce),wDe),'Crossing Counter Node Order Influence'),'Indicates with what percentage (1 for 100%) violations of the node model order are weighted against the crossings e.g. a value of 0.5 means two model order violations are as important as on edge crossing. This allows some edge crossings in favor of preserving the model order. It is advised to set this value to a very small positive value (e.g. 0.001) to have minimal crossing and a optimal node order. Defaults to no influence (0).'),0),did),VI),xsb(Whd))));zgd(a,_Ce,WCe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aDe),wDe),'Crossing Counter Port Order Influence'),'Indicates with what percentage (1 for 100%) violations of the port model order are weighted against the crossings e.g. a value of 0.5 means two model order violations are as important as on edge crossing. This allows some edge crossings in favor of preserving the model order. It is advised to set this value to a very small positive value (e.g. 0.001) to have minimal crossing and a optimal port order. Defaults to no influence (0).'),0),did),VI),xsb(Whd))));zgd(a,aDe,WCe,null);zCc((new ACc,a));};var ixc,jxc,kxc,lxc,mxc,nxc,oxc,pxc,qxc,rxc,sxc,txc,uxc,vxc,wxc,xxc,yxc,zxc,Axc,Bxc,Cxc,Dxc,Exc,Fxc,Gxc,Hxc,Ixc,Jxc,Kxc,Lxc,Mxc,Nxc,Oxc,Pxc,Qxc,Rxc,Sxc,Txc,Uxc,Vxc,Wxc,Xxc,Yxc,Zxc,$xc,_xc,ayc,byc,cyc,dyc,eyc,fyc,gyc,hyc,iyc,jyc,kyc,lyc,myc,nyc,oyc,pyc,qyc,ryc,syc,tyc,uyc,vyc,wyc,xyc,yyc,zyc,Ayc,Byc,Cyc,Dyc,Eyc,Fyc,Gyc,Hyc,Iyc,Jyc,Kyc,Lyc,Myc,Nyc,Oyc,Pyc,Qyc,Ryc,Syc,Tyc,Uyc,Vyc,Wyc,Xyc,Yyc,Zyc,$yc,_yc,azc,bzc,czc,dzc,ezc,fzc,gzc,hzc,izc,jzc,kzc,lzc,mzc,nzc,ozc,pzc,qzc,rzc,szc,tzc,uzc,vzc,wzc,xzc,yzc,zzc,Azc,Bzc,Czc,Dzc,Ezc,Fzc,Gzc,Hzc,Izc,Jzc,Kzc,Lzc,Mzc,Nzc;sfb(ABe,'LayeredMetaDataProvider',859);feb(998,1,Eye,ACc);_.hf=function BCc(a){zCc(a);};var Rzc,Szc,Tzc,Uzc,Vzc,Wzc,Xzc,Yzc,Zzc,$zc,_zc,aAc,bAc,cAc,dAc,eAc,fAc,gAc,hAc,iAc,jAc,kAc,lAc,mAc,nAc,oAc,pAc,qAc,rAc,sAc,tAc,uAc,vAc,wAc,xAc,yAc,zAc,AAc,BAc,CAc,DAc,EAc,FAc,GAc,HAc,IAc,JAc,KAc,LAc,MAc,NAc,OAc,PAc,QAc,RAc,SAc,TAc,UAc,VAc,WAc,XAc,YAc,ZAc,$Ac,_Ac,aBc,bBc,cBc,dBc,eBc,fBc,gBc,hBc,iBc,jBc,kBc,lBc,mBc,nBc,oBc,pBc,qBc,rBc,sBc,tBc,uBc,vBc,wBc,xBc,yBc,zBc,ABc,BBc,CBc,DBc,EBc,FBc,GBc,HBc,IBc,JBc,KBc,LBc,MBc,NBc,OBc,PBc,QBc,RBc,SBc,TBc,UBc,VBc,WBc,XBc,YBc,ZBc,$Bc,_Bc,aCc,bCc,cCc,dCc,eCc,fCc,gCc,hCc,iCc,jCc,kCc,lCc,mCc,nCc,oCc,pCc,qCc,rCc,sCc,tCc,uCc,vCc,wCc,xCc;sfb(ABe,'LayeredOptions',998);feb(999,1,{},CCc);_.sf=function DCc(){var a;return a=new lXb,a};_.tf=function ECc(a){};sfb(ABe,'LayeredOptions/LayeredFactory',999);feb(1391,1,{});_.a=0;var FCc;sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder',1391);feb(792,1391,{},RCc);var OCc,PCc;sfb(ABe,'LayeredSpacings/LayeredSpacingsBuilder',792);feb(265,22,{3:1,34:1,22:1,265:1,188:1,196:1},bDc);_.dg=function dDc(){return aDc(this)};_.qg=function cDc(){return aDc(this)};var SCc,TCc,UCc,VCc,WCc,XCc,YCc,ZCc,$Cc;var rX=tfb(ABe,'LayeringStrategy',265,WI,fDc,eDc);var gDc;feb(390,22,{3:1,34:1,22:1,390:1},nDc);var iDc,jDc,kDc;var sX=tfb(ABe,'LongEdgeOrderingStrategy',390,WI,pDc,oDc);var qDc;feb(203,22,{3:1,34:1,22:1,203:1},yDc);var sDc,tDc,uDc,vDc;var tX=tfb(ABe,'NodeFlexibility',203,WI,BDc,ADc);var CDc;feb(323,22,{3:1,34:1,22:1,323:1,188:1,196:1},LDc);_.dg=function NDc(){return KDc(this)};_.qg=function MDc(){return KDc(this)};var EDc,FDc,GDc,HDc,IDc;var uX=tfb(ABe,'NodePlacementStrategy',323,WI,PDc,ODc);var QDc;feb(243,22,{3:1,34:1,22:1,243:1},bEc);var SDc,TDc,UDc,VDc,WDc,XDc,YDc,ZDc,$Dc,_Dc;var vX=tfb(ABe,'NodePromotionStrategy',243,WI,dEc,cEc);var eEc;feb(284,22,{3:1,34:1,22:1,284:1},lEc);var gEc,hEc,iEc,jEc;var wX=tfb(ABe,'OrderingStrategy',284,WI,nEc,mEc);var oEc;feb(430,22,{3:1,34:1,22:1,430:1},tEc);var qEc,rEc;var xX=tfb(ABe,'PortSortingStrategy',430,WI,vEc,uEc);var wEc;feb(463,22,{3:1,34:1,22:1,463:1},CEc);var yEc,zEc,AEc;var yX=tfb(ABe,'PortType',463,WI,EEc,DEc);var FEc;feb(387,22,{3:1,34:1,22:1,387:1},LEc);var HEc,IEc,JEc;var zX=tfb(ABe,'SelfLoopDistributionStrategy',387,WI,NEc,MEc);var OEc;feb(349,22,{3:1,34:1,22:1,349:1},UEc);var QEc,REc,SEc;var AX=tfb(ABe,'SelfLoopOrderingStrategy',349,WI,WEc,VEc);var XEc;feb(312,1,{312:1},gFc);sfb(ABe,'Spacings',312);feb(350,22,{3:1,34:1,22:1,350:1},mFc);var iFc,jFc,kFc;var CX=tfb(ABe,'SplineRoutingMode',350,WI,oFc,nFc);var pFc;feb(352,22,{3:1,34:1,22:1,352:1},vFc);var rFc,sFc,tFc;var DX=tfb(ABe,'ValidifyStrategy',352,WI,xFc,wFc);var yFc;feb(388,22,{3:1,34:1,22:1,388:1},EFc);var AFc,BFc,CFc;var EX=tfb(ABe,'WrappingStrategy',388,WI,GFc,FFc);var HFc;feb(1398,1,nEe,NFc);_.rg=function OFc(a){return RD(a,36),JFc};_.Kf=function PFc(a,b){MFc(this,RD(a,36),b);};var JFc;sfb(oEe,'DepthFirstCycleBreaker',1398);feb(793,1,nEe,UFc);_.rg=function WFc(a){return RD(a,36),QFc};_.Kf=function XFc(a,b){SFc(this,RD(a,36),b);};_.sg=function VFc(a){return RD(Vmb(a,Jwb(this.d,a.c.length)),10)};var QFc;sfb(oEe,'GreedyCycleBreaker',793);feb(1401,793,nEe,YFc);_.sg=function ZFc(a){var b,c,d,e;e=null;b=lve;for(d=new Anb(a);d.a1){Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),(yCc(),eAc))))?wLc(a,this.d,RD(this,669)):(yob(),_mb(a,this.d));nJc(this.e,a);}};_.lg=function bJc(a,b,c,d){var e,f,g,h,i,j,k;if(b!=SIc(c,a.length)){f=a[b-(c?1:-1)];sIc(this.f,f,c?(BEc(),zEc):(BEc(),yEc));}e=a[b][0];k=!d||e.k==(r3b(),m3b);j=dv(a[b]);this.vg(j,k,false,c);g=0;for(i=new Anb(j);i.a');a0?(pMc(this.a,a[b-1],a[b]),undefined):!c&&b1){Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),(yCc(),eAc))))?wLc(a,this.d,this):(yob(),_mb(a,this.d));Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),eAc)))||nJc(this.e,a);}};sfb(sEe,'ModelOrderBarycenterHeuristic',669);feb(1866,1,fye,yLc);_.Ne=function zLc(a,b){return tLc(this.a,RD(a,10),RD(b,10))};_.Fb=function ALc(a){return this===a};_.Oe=function BLc(){return new Frb(this)};sfb(sEe,'ModelOrderBarycenterHeuristic/lambda$0$Type',1866);feb(1423,1,nEe,FLc);_.rg=function GLc(a){var b;return RD(a,36),b=vfd(CLc),pfd(b,(sXb(),pXb),(hcc(),Ybc)),b};_.Kf=function HLc(a,b){ELc((RD(a,36),b));};var CLc;sfb(sEe,'NoCrossingMinimizer',1423);feb(809,413,qEe,ILc);_.tg=function JLc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;l=this.g;switch(c.g){case 1:{e=0;f=0;for(k=new Anb(a.j);k.a1&&(e.j==(qpd(),Xod)?(this.b[a]=true):e.j==ppd&&a>0&&(this.b[a-1]=true));};_.f=0;sfb(tBe,'AllCrossingsCounter',1861);feb(595,1,{},_Lc);_.b=0;_.d=0;sfb(tBe,'BinaryIndexedTree',595);feb(532,1,{},DMc);var bMc,cMc;sfb(tBe,'CrossingsCounter',532);feb(1950,1,fye,HMc);_.Ne=function IMc(a,b){return wMc(this.a,RD(a,12),RD(b,12))};_.Fb=function JMc(a){return this===a};_.Oe=function KMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$0$Type',1950);feb(1951,1,fye,LMc);_.Ne=function MMc(a,b){return xMc(this.a,RD(a,12),RD(b,12))};_.Fb=function NMc(a){return this===a};_.Oe=function OMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$1$Type',1951);feb(1952,1,fye,PMc);_.Ne=function QMc(a,b){return yMc(this.a,RD(a,12),RD(b,12))};_.Fb=function RMc(a){return this===a};_.Oe=function SMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$2$Type',1952);feb(1953,1,fye,TMc);_.Ne=function UMc(a,b){return zMc(this.a,RD(a,12),RD(b,12))};_.Fb=function VMc(a){return this===a};_.Oe=function WMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$3$Type',1953);feb(1954,1,Qve,XMc);_.Cd=function YMc(a){EMc(this.a,RD(a,12));};sfb(tBe,'CrossingsCounter/lambda$4$Type',1954);feb(1955,1,nwe,ZMc);_.Mb=function $Mc(a){return FMc(this.a,RD(a,12))};sfb(tBe,'CrossingsCounter/lambda$5$Type',1955);feb(1956,1,Qve,aNc);_.Cd=function bNc(a){_Mc(this,a);};sfb(tBe,'CrossingsCounter/lambda$6$Type',1956);feb(1957,1,Qve,cNc);_.Cd=function dNc(a){var b;dMc();hmb(this.b,(b=this.a,RD(a,12),b));};sfb(tBe,'CrossingsCounter/lambda$7$Type',1957);feb(839,1,xye,eNc);_.Lb=function fNc(a){return dMc(),nQb(RD(a,12),(Ywc(),Iwc))};_.Fb=function gNc(a){return this===a};_.Mb=function hNc(a){return dMc(),nQb(RD(a,12),(Ywc(),Iwc))};sfb(tBe,'CrossingsCounter/lambda$8$Type',839);feb(1949,1,{},jNc);sfb(tBe,'HyperedgeCrossingsCounter',1949);feb(478,1,{34:1,478:1},lNc);_.Fd=function mNc(a){return kNc(this,RD(a,478))};_.b=0;_.c=0;_.e=0;_.f=0;var OY=sfb(tBe,'HyperedgeCrossingsCounter/Hyperedge',478);feb(374,1,{34:1,374:1},oNc);_.Fd=function pNc(a){return nNc(this,RD(a,374))};_.b=0;_.c=0;var NY=sfb(tBe,'HyperedgeCrossingsCounter/HyperedgeCorner',374);feb(531,22,{3:1,34:1,22:1,531:1},tNc);var qNc,rNc;var MY=tfb(tBe,'HyperedgeCrossingsCounter/HyperedgeCorner/Type',531,WI,vNc,uNc);var wNc;feb(1425,1,nEe,DNc);_.rg=function ENc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?zNc:null};_.Kf=function FNc(a,b){CNc(this,RD(a,36),b);};var zNc;sfb(tEe,'InteractiveNodePlacer',1425);feb(1426,1,nEe,TNc);_.rg=function UNc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?GNc:null};_.Kf=function VNc(a,b){RNc(this,RD(a,36),b);};var GNc,HNc,INc;sfb(tEe,'LinearSegmentsNodePlacer',1426);feb(261,1,{34:1,261:1},ZNc);_.Fd=function $Nc(a){return WNc(this,RD(a,261))};_.Fb=function _Nc(a){var b;if(ZD(a,261)){b=RD(a,261);return this.b==b.b}return false};_.Hb=function aOc(){return this.b};_.Ib=function bOc(){return 'ls'+Fe(this.e)};_.a=0;_.b=0;_.c=-1;_.d=-1;_.g=0;var SY=sfb(tEe,'LinearSegmentsNodePlacer/LinearSegment',261);feb(1428,1,nEe,yOc);_.rg=function zOc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?cOc:null};_.Kf=function HOc(a,b){uOc(this,RD(a,36),b);};_.b=0;_.g=0;var cOc;sfb(tEe,'NetworkSimplexPlacer',1428);feb(1447,1,fye,IOc);_.Ne=function JOc(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function KOc(a){return this===a};_.Oe=function LOc(){return new Frb(this)};sfb(tEe,'NetworkSimplexPlacer/0methodref$compare$Type',1447);feb(1449,1,fye,MOc);_.Ne=function NOc(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function OOc(a){return this===a};_.Oe=function POc(){return new Frb(this)};sfb(tEe,'NetworkSimplexPlacer/1methodref$compare$Type',1449);feb(655,1,{655:1},QOc);var WY=sfb(tEe,'NetworkSimplexPlacer/EdgeRep',655);feb(412,1,{412:1},ROc);_.b=false;var XY=sfb(tEe,'NetworkSimplexPlacer/NodeRep',412);feb(515,13,{3:1,4:1,20:1,31:1,56:1,13:1,16:1,15:1,59:1,515:1},VOc);sfb(tEe,'NetworkSimplexPlacer/Path',515);feb(1429,1,{},WOc);_.Kb=function XOc(a){return RD(a,18).d.i.k};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$0$Type',1429);feb(1430,1,nwe,YOc);_.Mb=function ZOc(a){return RD(a,273)==(r3b(),o3b)};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$1$Type',1430);feb(1431,1,{},$Oc);_.Kb=function _Oc(a){return RD(a,18).d.i};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$2$Type',1431);feb(1432,1,nwe,aPc);_.Mb=function bPc(a){return EPc(zDc(RD(a,10)))};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$3$Type',1432);feb(1433,1,nwe,cPc);_.Mb=function dPc(a){return DOc(RD(a,12))};sfb(tEe,'NetworkSimplexPlacer/lambda$0$Type',1433);feb(1434,1,Qve,ePc);_.Cd=function fPc(a){jOc(this.a,this.b,RD(a,12));};sfb(tEe,'NetworkSimplexPlacer/lambda$1$Type',1434);feb(1443,1,Qve,gPc);_.Cd=function hPc(a){kOc(this.a,RD(a,18));};sfb(tEe,'NetworkSimplexPlacer/lambda$10$Type',1443);feb(1444,1,{},iPc);_.Kb=function jPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$11$Type',1444);feb(1445,1,Qve,kPc);_.Cd=function lPc(a){lOc(this.a,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$12$Type',1445);feb(1446,1,{},mPc);_.Kb=function nPc(a){return dOc(),sgb(RD(a,125).e)};sfb(tEe,'NetworkSimplexPlacer/lambda$13$Type',1446);feb(1448,1,{},oPc);_.Kb=function pPc(a){return dOc(),sgb(RD(a,125).e)};sfb(tEe,'NetworkSimplexPlacer/lambda$15$Type',1448);feb(1450,1,nwe,qPc);_.Mb=function rPc(a){return dOc(),RD(a,412).c.k==(r3b(),p3b)};sfb(tEe,'NetworkSimplexPlacer/lambda$17$Type',1450);feb(1451,1,nwe,sPc);_.Mb=function tPc(a){return dOc(),RD(a,412).c.j.c.length>1};sfb(tEe,'NetworkSimplexPlacer/lambda$18$Type',1451);feb(1452,1,Qve,uPc);_.Cd=function vPc(a){EOc(this.c,this.b,this.d,this.a,RD(a,412));};_.c=0;_.d=0;sfb(tEe,'NetworkSimplexPlacer/lambda$19$Type',1452);feb(1435,1,{},wPc);_.Kb=function xPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$2$Type',1435);feb(1453,1,Qve,yPc);_.Cd=function zPc(a){FOc(this.a,RD(a,12));};_.a=0;sfb(tEe,'NetworkSimplexPlacer/lambda$20$Type',1453);feb(1454,1,{},APc);_.Kb=function BPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$21$Type',1454);feb(1455,1,Qve,CPc);_.Cd=function DPc(a){mOc(this.a,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$22$Type',1455);feb(1456,1,nwe,FPc);_.Mb=function GPc(a){return EPc(a)};sfb(tEe,'NetworkSimplexPlacer/lambda$23$Type',1456);feb(1457,1,{},HPc);_.Kb=function IPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$24$Type',1457);feb(1458,1,nwe,JPc);_.Mb=function KPc(a){return nOc(this.a,RD(a,10))};sfb(tEe,'NetworkSimplexPlacer/lambda$25$Type',1458);feb(1459,1,Qve,LPc);_.Cd=function MPc(a){oOc(this.a,this.b,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$26$Type',1459);feb(1460,1,nwe,NPc);_.Mb=function OPc(a){return dOc(),!W0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$27$Type',1460);feb(1461,1,nwe,PPc);_.Mb=function QPc(a){return dOc(),!W0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$28$Type',1461);feb(1462,1,{},RPc);_.Ve=function SPc(a,b){return pOc(this.a,RD(a,30),RD(b,30))};sfb(tEe,'NetworkSimplexPlacer/lambda$29$Type',1462);feb(1436,1,{},TPc);_.Kb=function UPc(a){return dOc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(tEe,'NetworkSimplexPlacer/lambda$3$Type',1436);feb(1437,1,nwe,VPc);_.Mb=function WPc(a){return dOc(),COc(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$4$Type',1437);feb(1438,1,Qve,XPc);_.Cd=function YPc(a){vOc(this.a,RD(a,18));};sfb(tEe,'NetworkSimplexPlacer/lambda$5$Type',1438);feb(1439,1,{},ZPc);_.Kb=function $Pc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$6$Type',1439);feb(1440,1,nwe,_Pc);_.Mb=function aQc(a){return dOc(),RD(a,10).k==(r3b(),p3b)};sfb(tEe,'NetworkSimplexPlacer/lambda$7$Type',1440);feb(1441,1,{},bQc);_.Kb=function cQc(a){return dOc(),new SDb(null,new Twb(new is(Mr(W2b(RD(a,10)).a.Kc(),new ir))))};sfb(tEe,'NetworkSimplexPlacer/lambda$8$Type',1441);feb(1442,1,nwe,dQc);_.Mb=function eQc(a){return dOc(),V0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$9$Type',1442);feb(1424,1,nEe,iQc);_.rg=function jQc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?fQc:null};_.Kf=function kQc(a,b){hQc(RD(a,36),b);};var fQc;sfb(tEe,'SimpleNodePlacer',1424);feb(185,1,{185:1},sQc);_.Ib=function tQc(){var a;a='';this.c==(wQc(),vQc)?(a+=Oye):this.c==uQc&&(a+=Nye);this.o==(EQc(),CQc)?(a+=Zye):this.o==DQc?(a+='UP'):(a+='BALANCED');return a};sfb(wEe,'BKAlignedLayout',185);feb(523,22,{3:1,34:1,22:1,523:1},xQc);var uQc,vQc;var FZ=tfb(wEe,'BKAlignedLayout/HDirection',523,WI,zQc,yQc);var AQc;feb(522,22,{3:1,34:1,22:1,522:1},FQc);var CQc,DQc;var GZ=tfb(wEe,'BKAlignedLayout/VDirection',522,WI,HQc,GQc);var IQc;feb(1699,1,{},MQc);sfb(wEe,'BKAligner',1699);feb(1702,1,{},RQc);sfb(wEe,'BKCompactor',1702);feb(663,1,{663:1},SQc);_.a=0;sfb(wEe,'BKCompactor/ClassEdge',663);feb(467,1,{467:1},UQc);_.a=null;_.b=0;sfb(wEe,'BKCompactor/ClassNode',467);feb(1427,1,nEe,aRc);_.rg=function eRc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?VQc:null};_.Kf=function fRc(a,b){_Qc(this,RD(a,36),b);};_.d=false;var VQc;sfb(wEe,'BKNodePlacer',1427);feb(1700,1,{},hRc);_.d=0;sfb(wEe,'NeighborhoodInformation',1700);feb(1701,1,fye,mRc);_.Ne=function nRc(a,b){return lRc(this,RD(a,42),RD(b,42))};_.Fb=function oRc(a){return this===a};_.Oe=function pRc(){return new Frb(this)};sfb(wEe,'NeighborhoodInformation/NeighborComparator',1701);feb(823,1,{});sfb(wEe,'ThresholdStrategy',823);feb(1825,823,{},uRc);_.wg=function vRc(a,b,c){return this.a.o==(EQc(),DQc)?oxe:pxe};_.xg=function wRc(){};sfb(wEe,'ThresholdStrategy/NullThresholdStrategy',1825);feb(587,1,{587:1},xRc);_.c=false;_.d=false;sfb(wEe,'ThresholdStrategy/Postprocessable',587);feb(1826,823,{},BRc);_.wg=function CRc(a,b,c){var d,e,f;e=b==c;d=this.a.a[c.p]==b;if(!(e||d)){return a}f=a;if(this.a.c==(wQc(),vQc)){e&&(f=yRc(this,b,true));!isNaN(f)&&!isFinite(f)&&d&&(f=yRc(this,c,false));}else {e&&(f=yRc(this,b,true));!isNaN(f)&&!isFinite(f)&&d&&(f=yRc(this,c,false));}return f};_.xg=function DRc(){var a,b,c,d,e;while(this.d.b!=0){e=RD(Tub(this.d),587);d=zRc(this,e);if(!d.a){continue}a=d.a;c=Heb(this.a.f[this.a.g[e.b.p].p]);if(!c&&!W0b(a)&&a.c.i.c==a.d.i.c){continue}b=ARc(this,e);b||Eyb(this.e,e);}while(this.e.a.c.length!=0){ARc(this,RD(Dyb(this.e),587));}};sfb(wEe,'ThresholdStrategy/SimpleThresholdStrategy',1826);feb(645,1,{645:1,188:1,196:1},HRc);_.dg=function JRc(){return GRc(this)};_.qg=function IRc(){return GRc(this)};var ERc;sfb(xEe,'EdgeRouterFactory',645);feb(1485,1,nEe,WRc);_.rg=function XRc(a){return URc(RD(a,36))};_.Kf=function YRc(a,b){VRc(RD(a,36),b);};var LRc,MRc,NRc,ORc,PRc,QRc,RRc,SRc;sfb(xEe,'OrthogonalEdgeRouter',1485);feb(1478,1,nEe,lSc);_.rg=function mSc(a){return gSc(RD(a,36))};_.Kf=function nSc(a,b){iSc(this,RD(a,36),b);};var ZRc,$Rc,_Rc,aSc,bSc,cSc;sfb(xEe,'PolylineEdgeRouter',1478);feb(1479,1,xye,pSc);_.Lb=function qSc(a){return oSc(RD(a,10))};_.Fb=function rSc(a){return this===a};_.Mb=function sSc(a){return oSc(RD(a,10))};sfb(xEe,'PolylineEdgeRouter/1',1479);feb(1872,1,nwe,xSc);_.Mb=function ySc(a){return RD(a,132).c==(fTc(),dTc)};sfb(yEe,'HyperEdgeCycleDetector/lambda$0$Type',1872);feb(1873,1,{},zSc);_.Ze=function ASc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$1$Type',1873);feb(1874,1,nwe,BSc);_.Mb=function CSc(a){return RD(a,132).c==(fTc(),dTc)};sfb(yEe,'HyperEdgeCycleDetector/lambda$2$Type',1874);feb(1875,1,{},DSc);_.Ze=function ESc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$3$Type',1875);feb(1876,1,{},FSc);_.Ze=function GSc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$4$Type',1876);feb(1877,1,{},HSc);_.Ze=function ISc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$5$Type',1877);feb(118,1,{34:1,118:1},USc);_.Fd=function VSc(a){return KSc(this,RD(a,118))};_.Fb=function WSc(a){var b;if(ZD(a,118)){b=RD(a,118);return this.g==b.g}return false};_.Hb=function XSc(){return this.g};_.Ib=function ZSc(){var a,b,c,d;a=new dib('{');d=new Anb(this.n);while(d.a'+this.b+' ('+os(this.c)+')'};_.d=0;sfb(yEe,'HyperEdgeSegmentDependency',132);feb(528,22,{3:1,34:1,22:1,528:1},gTc);var dTc,eTc;var b$=tfb(yEe,'HyperEdgeSegmentDependency/DependencyType',528,WI,iTc,hTc);var jTc;feb(1878,1,{},xTc);sfb(yEe,'HyperEdgeSegmentSplitter',1878);feb(1879,1,{},ATc);_.a=0;_.b=0;sfb(yEe,'HyperEdgeSegmentSplitter/AreaRating',1879);feb(339,1,{339:1},BTc);_.a=0;_.b=0;_.c=0;sfb(yEe,'HyperEdgeSegmentSplitter/FreeArea',339);feb(1880,1,fye,CTc);_.Ne=function DTc(a,b){return zTc(RD(a,118),RD(b,118))};_.Fb=function ETc(a){return this===a};_.Oe=function FTc(){return new Frb(this)};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$0$Type',1880);feb(1881,1,Qve,GTc);_.Cd=function HTc(a){rTc(this.a,this.d,this.c,this.b,RD(a,118));};_.b=0;sfb(yEe,'HyperEdgeSegmentSplitter/lambda$1$Type',1881);feb(1882,1,{},ITc);_.Kb=function JTc(a){return new SDb(null,new Swb(RD(a,118).e,16))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$2$Type',1882);feb(1883,1,{},KTc);_.Kb=function LTc(a){return new SDb(null,new Swb(RD(a,118).j,16))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$3$Type',1883);feb(1884,1,{},MTc);_.Ye=function NTc(a){return Kfb(UD(a))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$4$Type',1884);feb(664,1,{},TTc);_.a=0;_.b=0;_.c=0;sfb(yEe,'OrthogonalRoutingGenerator',664);feb(1703,1,{},XTc);_.Kb=function YTc(a){return new SDb(null,new Swb(RD(a,118).e,16))};sfb(yEe,'OrthogonalRoutingGenerator/lambda$0$Type',1703);feb(1704,1,{},ZTc);_.Kb=function $Tc(a){return new SDb(null,new Swb(RD(a,118).j,16))};sfb(yEe,'OrthogonalRoutingGenerator/lambda$1$Type',1704);feb(670,1,{});sfb(zEe,'BaseRoutingDirectionStrategy',670);feb(1870,670,{},cUc);_.yg=function dUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b+a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(l,f);Mub(g.a,d);_Tc(this,g,e,d,false);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);f=b+m.o*c;e=m;d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);}d=new rjd(p,f);Mub(g.a,d);_Tc(this,g,e,d,false);}}}}};_.zg=function eUc(a){return a.i.n.a+a.n.a+a.a.a};_.Ag=function fUc(){return qpd(),npd};_.Bg=function gUc(){return qpd(),Yod};sfb(zEe,'NorthToSouthRoutingStrategy',1870);feb(1871,670,{},hUc);_.yg=function iUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b-a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(l,f);Mub(g.a,d);_Tc(this,g,e,d,false);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);f=b-m.o*c;e=m;d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);}d=new rjd(p,f);Mub(g.a,d);_Tc(this,g,e,d,false);}}}}};_.zg=function jUc(a){return a.i.n.a+a.n.a+a.a.a};_.Ag=function kUc(){return qpd(),Yod};_.Bg=function lUc(){return qpd(),npd};sfb(zEe,'SouthToNorthRoutingStrategy',1871);feb(1869,670,{},mUc);_.yg=function nUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b+a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(f,l);Mub(g.a,d);_Tc(this,g,e,d,true);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(f,n);Mub(g.a,d);_Tc(this,g,e,d,true);f=b+m.o*c;e=m;d=new rjd(f,n);Mub(g.a,d);_Tc(this,g,e,d,true);}d=new rjd(f,p);Mub(g.a,d);_Tc(this,g,e,d,true);}}}}};_.zg=function oUc(a){return a.i.n.b+a.n.b+a.a.b};_.Ag=function pUc(){return qpd(),Xod};_.Bg=function qUc(){return qpd(),ppd};sfb(zEe,'WestToEastRoutingStrategy',1869);feb(828,1,{},wUc);_.Ib=function xUc(){return Fe(this.a)};_.b=0;_.c=false;_.d=false;_.f=0;sfb(BEe,'NubSpline',828);feb(418,1,{418:1},AUc,BUc);sfb(BEe,'NubSpline/PolarCP',418);feb(1480,1,nEe,VUc);_.rg=function XUc(a){return QUc(RD(a,36))};_.Kf=function YUc(a,b){UUc(this,RD(a,36),b);};var CUc,DUc,EUc,FUc,GUc;sfb(BEe,'SplineEdgeRouter',1480);feb(274,1,{274:1},_Uc);_.Ib=function aVc(){return this.a+' ->('+this.c+') '+this.b};_.c=0;sfb(BEe,'SplineEdgeRouter/Dependency',274);feb(465,22,{3:1,34:1,22:1,465:1},eVc);var bVc,cVc;var w$=tfb(BEe,'SplineEdgeRouter/SideToProcess',465,WI,gVc,fVc);var hVc;feb(1481,1,nwe,jVc);_.Mb=function kVc(a){return HUc(),!RD(a,131).o};sfb(BEe,'SplineEdgeRouter/lambda$0$Type',1481);feb(1482,1,{},lVc);_.Ze=function mVc(a){return HUc(),RD(a,131).v+1};sfb(BEe,'SplineEdgeRouter/lambda$1$Type',1482);feb(1483,1,Qve,nVc);_.Cd=function oVc(a){SUc(this.a,this.b,RD(a,42));};sfb(BEe,'SplineEdgeRouter/lambda$2$Type',1483);feb(1484,1,Qve,pVc);_.Cd=function qVc(a){TUc(this.a,this.b,RD(a,42));};sfb(BEe,'SplineEdgeRouter/lambda$3$Type',1484);feb(131,1,{34:1,131:1},wVc,xVc);_.Fd=function yVc(a){return uVc(this,RD(a,131))};_.b=0;_.e=false;_.f=0;_.g=0;_.j=false;_.k=false;_.n=0;_.o=false;_.p=false;_.q=false;_.s=0;_.u=0;_.v=0;_.F=0;sfb(BEe,'SplineSegment',131);feb(468,1,{468:1},zVc);_.a=0;_.b=false;_.c=false;_.d=false;_.e=false;_.f=0;sfb(BEe,'SplineSegment/EdgeInformation',468);feb(1198,1,{},IVc);sfb(GEe,Lze,1198);feb(1199,1,fye,KVc);_.Ne=function LVc(a,b){return JVc(RD(a,121),RD(b,121))};_.Fb=function MVc(a){return this===a};_.Oe=function NVc(){return new Frb(this)};sfb(GEe,Mze,1199);feb(1197,1,{},TVc);sfb(GEe,'MrTree',1197);feb(405,22,{3:1,34:1,22:1,405:1,188:1,196:1},$Vc);_.dg=function aWc(){return ZVc(this)};_.qg=function _Vc(){return ZVc(this)};var UVc,VVc,WVc,XVc;var H$=tfb(GEe,'TreeLayoutPhases',405,WI,cWc,bWc);var dWc;feb(1112,205,oze,fWc);_.rf=function gWc(a,b){var c,d,e,f,g,h,i,j;Heb(TD(Gxd(a,(h_c(),S$c))))||RFb((c=new SFb((lud(),new zud(a))),c));g=b.eh(HEe);g.Ug('build tGraph',1);h=(i=new YWc,kQb(i,a),pQb(i,(q$c(),h$c),a),j=new Tsb,QVc(a,i,j),PVc(a,i,j),i);g.Vg();g=b.eh(HEe);g.Ug('Split graph',1);f=HVc(this.a,h);g.Vg();for(e=new Anb(f);e.a'+aXc(this.c):'e_'+tb(this)};sfb(JEe,'TEdge',65);feb(121,137,{3:1,121:1,96:1,137:1},YWc);_.Ib=function ZWc(){var a,b,c,d,e;e=null;for(d=Sub(this.b,0);d.b!=d.d.c;){c=RD(evb(d),40);e+=(c.c==null||c.c.length==0?'n_'+c.g:'n_'+c.c)+'\n';}for(b=Sub(this.a,0);b.b!=b.d.c;){a=RD(evb(b),65);e+=(!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))+'\n';}return e};var W$=sfb(JEe,'TGraph',121);feb(643,508,{3:1,508:1,643:1,96:1,137:1});sfb(JEe,'TShape',643);feb(40,643,{3:1,508:1,40:1,643:1,96:1,137:1},bXc);_.Ib=function cXc(){return aXc(this)};var Z$=sfb(JEe,'TNode',40);feb(236,1,Vve,dXc);_.Jc=function eXc(a){xgb(this,a);};_.Kc=function fXc(){var a;return a=Sub(this.a.d,0),new gXc(a)};sfb(JEe,'TNode/2',236);feb(329,1,Ave,gXc);_.Nb=function hXc(a){Ztb(this,a);};_.Pb=function jXc(){return RD(evb(this.a),65).c};_.Ob=function iXc(){return dvb(this.a)};_.Qb=function kXc(){gvb(this.a);};sfb(JEe,'TNode/2/1',329);feb(1923,1,QAe,qXc);_.Kf=function DXc(a,b){oXc(this,RD(a,121),b);};sfb(LEe,'CompactionProcessor',1923);feb(1924,1,fye,EXc);_.Ne=function FXc(a,b){return rXc(this.a,RD(a,40),RD(b,40))};_.Fb=function GXc(a){return this===a};_.Oe=function HXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$0$Type',1924);feb(1925,1,nwe,IXc);_.Mb=function JXc(a){return sXc(this.b,this.a,RD(a,42))};_.a=0;_.b=0;sfb(LEe,'CompactionProcessor/lambda$1$Type',1925);feb(1934,1,fye,KXc);_.Ne=function LXc(a,b){return tXc(RD(a,40),RD(b,40))};_.Fb=function MXc(a){return this===a};_.Oe=function NXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$10$Type',1934);feb(1935,1,fye,OXc);_.Ne=function PXc(a,b){return uXc(RD(a,40),RD(b,40))};_.Fb=function QXc(a){return this===a};_.Oe=function RXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$11$Type',1935);feb(1936,1,fye,SXc);_.Ne=function TXc(a,b){return vXc(RD(a,40),RD(b,40))};_.Fb=function UXc(a){return this===a};_.Oe=function VXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$12$Type',1936);feb(1926,1,nwe,WXc);_.Mb=function XXc(a){return wXc(this.a,RD(a,42))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$2$Type',1926);feb(1927,1,nwe,YXc);_.Mb=function ZXc(a){return xXc(this.a,RD(a,42))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$3$Type',1927);feb(1928,1,nwe,$Xc);_.Mb=function _Xc(a){return RD(a,40).c.indexOf(IEe)==-1};sfb(LEe,'CompactionProcessor/lambda$4$Type',1928);feb(1929,1,{},aYc);_.Kb=function bYc(a){return yXc(this.a,RD(a,40))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$5$Type',1929);feb(1930,1,{},cYc);_.Kb=function dYc(a){return zXc(this.a,RD(a,40))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$6$Type',1930);feb(1931,1,fye,eYc);_.Ne=function fYc(a,b){return AXc(this.a,RD(a,240),RD(b,240))};_.Fb=function gYc(a){return this===a};_.Oe=function hYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$7$Type',1931);feb(1932,1,fye,iYc);_.Ne=function jYc(a,b){return BXc(this.a,RD(a,40),RD(b,40))};_.Fb=function kYc(a){return this===a};_.Oe=function lYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$8$Type',1932);feb(1933,1,fye,mYc);_.Ne=function nYc(a,b){return CXc(RD(a,40),RD(b,40))};_.Fb=function oYc(a){return this===a};_.Oe=function pYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$9$Type',1933);feb(1921,1,QAe,rYc);_.Kf=function sYc(a,b){qYc(RD(a,121),b);};sfb(LEe,'DirectionProcessor',1921);feb(1913,1,QAe,vYc);_.Kf=function xYc(a,b){uYc(this,RD(a,121),b);};sfb(LEe,'FanProcessor',1913);feb(1937,1,QAe,zYc);_.Kf=function CYc(a,b){yYc(RD(a,121),b);};sfb(LEe,'GraphBoundsProcessor',1937);feb(1938,1,{},DYc);_.Ye=function EYc(a){return RD(a,40).e.a};sfb(LEe,'GraphBoundsProcessor/lambda$0$Type',1938);feb(1939,1,{},FYc);_.Ye=function GYc(a){return RD(a,40).e.b};sfb(LEe,'GraphBoundsProcessor/lambda$1$Type',1939);feb(1940,1,{},HYc);_.Ye=function IYc(a){return AYc(RD(a,40))};sfb(LEe,'GraphBoundsProcessor/lambda$2$Type',1940);feb(1941,1,{},JYc);_.Ye=function KYc(a){return BYc(RD(a,40))};sfb(LEe,'GraphBoundsProcessor/lambda$3$Type',1941);feb(262,22,{3:1,34:1,22:1,262:1,196:1},XYc);_.dg=function YYc(){switch(this.g){case 0:return new DZc;case 1:return new vYc;case 2:return new nZc;case 3:return new tZc;case 4:return new gZc;case 8:return new cZc;case 5:return new rYc;case 6:return new AZc;case 7:return new qXc;case 9:return new zYc;case 10:return new GZc;default:throw Adb(new agb(lBe+(this.f!=null?this.f:''+this.g)));}};var LYc,MYc,NYc,OYc,PYc,QYc,RYc,SYc,TYc,UYc,VYc;var u_=tfb(LEe,mBe,262,WI,$Yc,ZYc);var _Yc;feb(1920,1,QAe,cZc);_.Kf=function dZc(a,b){bZc(RD(a,121),b);};sfb(LEe,'LevelCoordinatesProcessor',1920);feb(1918,1,QAe,gZc);_.Kf=function hZc(a,b){eZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'LevelHeightProcessor',1918);feb(1919,1,Vve,iZc);_.Jc=function jZc(a){xgb(this,a);};_.Kc=function kZc(){return yob(),Qob(),Pob};sfb(LEe,'LevelHeightProcessor/1',1919);feb(1914,1,QAe,nZc);_.Kf=function oZc(a,b){lZc(this,RD(a,121),b);};sfb(LEe,'LevelProcessor',1914);feb(1915,1,nwe,pZc);_.Mb=function qZc(a){return Heb(TD(mQb(RD(a,40),(q$c(),n$c))))};sfb(LEe,'LevelProcessor/lambda$0$Type',1915);feb(1916,1,QAe,tZc);_.Kf=function uZc(a,b){rZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'NeighborsProcessor',1916);feb(1917,1,Vve,vZc);_.Jc=function wZc(a){xgb(this,a);};_.Kc=function xZc(){return yob(),Qob(),Pob};sfb(LEe,'NeighborsProcessor/1',1917);feb(1922,1,QAe,AZc);_.Kf=function BZc(a,b){yZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'NodePositionProcessor',1922);feb(1912,1,QAe,DZc);_.Kf=function EZc(a,b){CZc(this,RD(a,121),b);};sfb(LEe,'RootProcessor',1912);feb(1942,1,QAe,GZc);_.Kf=function HZc(a,b){FZc(RD(a,121),b);};sfb(LEe,'Untreeifyer',1942);feb(392,22,{3:1,34:1,22:1,392:1},MZc);var IZc,JZc,KZc;var F_=tfb(PEe,'EdgeRoutingMode',392,WI,OZc,NZc);var PZc;var RZc,SZc,TZc,UZc,VZc,WZc,XZc,YZc,ZZc,$Zc,_Zc,a$c,b$c,c$c,d$c,e$c,f$c,g$c,h$c,i$c,j$c,k$c,l$c,m$c,n$c,o$c,p$c;feb(862,1,Eye,C$c);_.hf=function D$c(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,REe),''),YEe),'Turns on Tree compaction which decreases the size of the whole tree by placing nodes of multiple levels in one large level'),(Geb(),false)),(kid(),cid)),QI),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SEe),''),'Edge End Texture Length'),'Should be set to the length of the texture at the end of an edge. This value can be used to improve the Edge Routing.'),7),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TEe),''),'Tree Level'),'The index for the tree level the node is in'),sgb(0)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UEe),''),YEe),'When set to a positive number this option will force the algorithm to place the node to the specified position within the trees layer if weighting is set to constraint'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VEe),''),'Weighting of Nodes'),'Which weighting to use when computing a node order.'),A$c),eid),J_),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WEe),''),'Edge Routing Mode'),'Chooses an Edge Routing algorithm.'),u$c),eid),F_),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XEe),''),'Search Order'),'Which search order to use when computing a spanning tree.'),x$c),eid),K_),xsb(Whd))));i_c((new j_c,a));};var r$c,s$c,t$c,u$c,v$c,w$c,x$c,y$c,z$c,A$c;sfb(PEe,'MrTreeMetaDataProvider',862);feb(1006,1,Eye,j_c);_.hf=function k_c(a){i_c(a);};var E$c,F$c,G$c,H$c,I$c,J$c,K$c,L$c,M$c,N$c,O$c,P$c,Q$c,R$c,S$c,T$c,U$c,V$c,W$c,X$c,Y$c,Z$c,$$c,_$c,a_c,b_c,c_c,d_c,e_c,f_c,g_c;sfb(PEe,'MrTreeOptions',1006);feb(1007,1,{},l_c);_.sf=function m_c(){var a;return a=new fWc,a};_.tf=function n_c(a){};sfb(PEe,'MrTreeOptions/MrtreeFactory',1007);feb(353,22,{3:1,34:1,22:1,353:1},t_c);var o_c,p_c,q_c,r_c;var J_=tfb(PEe,'OrderWeighting',353,WI,v_c,u_c);var w_c;feb(433,22,{3:1,34:1,22:1,433:1},B_c);var y_c,z_c;var K_=tfb(PEe,'TreeifyingOrder',433,WI,D_c,C_c);var E_c;feb(1486,1,nEe,N_c);_.rg=function O_c(a){return RD(a,121),G_c};_.Kf=function P_c(a,b){M_c(this,RD(a,121),b);};var G_c;sfb('org.eclipse.elk.alg.mrtree.p1treeify','DFSTreeifyer',1486);feb(1487,1,nEe,V_c);_.rg=function W_c(a){return RD(a,121),Q_c};_.Kf=function $_c(a,b){U_c(this,RD(a,121),b);};var Q_c;sfb(aFe,'NodeOrderer',1487);feb(1494,1,{},a0c);_.td=function b0c(a){return __c(a)};sfb(aFe,'NodeOrderer/0methodref$lambda$6$Type',1494);feb(1488,1,nwe,c0c);_.Mb=function d0c(a){return R_c(),Heb(TD(mQb(RD(a,40),(q$c(),n$c))))};sfb(aFe,'NodeOrderer/lambda$0$Type',1488);feb(1489,1,nwe,e0c);_.Mb=function f0c(a){return R_c(),RD(mQb(RD(a,40),(h_c(),W$c)),17).a<0};sfb(aFe,'NodeOrderer/lambda$1$Type',1489);feb(1490,1,nwe,g0c);_.Mb=function h0c(a){return X_c(this.a,RD(a,40))};sfb(aFe,'NodeOrderer/lambda$2$Type',1490);feb(1491,1,nwe,i0c);_.Mb=function j0c(a){return Y_c(this.a,RD(a,40))};sfb(aFe,'NodeOrderer/lambda$3$Type',1491);feb(1492,1,fye,k0c);_.Ne=function l0c(a,b){return Z_c(RD(a,40),RD(b,40))};_.Fb=function m0c(a){return this===a};_.Oe=function n0c(){return new Frb(this)};sfb(aFe,'NodeOrderer/lambda$4$Type',1492);feb(1493,1,nwe,o0c);_.Mb=function p0c(a){return R_c(),RD(mQb(RD(a,40),(q$c(),XZc)),17).a!=0};sfb(aFe,'NodeOrderer/lambda$5$Type',1493);feb(1495,1,nEe,x0c);_.rg=function y0c(a){return RD(a,121),q0c};_.Kf=function z0c(a,b){v0c(this,RD(a,121),b);};_.b=0;var q0c;sfb('org.eclipse.elk.alg.mrtree.p3place','NodePlacer',1495);feb(1496,1,nEe,J0c);_.rg=function K0c(a){return RD(a,121),A0c};_.Kf=function Y0c(a,b){I0c(RD(a,121),b);};var A0c;var o0=sfb(bFe,'EdgeRouter',1496);feb(1498,1,fye,Z0c);_.Ne=function $0c(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function _0c(a){return this===a};_.Oe=function a1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/0methodref$compare$Type',1498);feb(1503,1,{},b1c);_.Ye=function c1c(a){return Kfb(UD(a))};sfb(bFe,'EdgeRouter/1methodref$doubleValue$Type',1503);feb(1505,1,fye,d1c);_.Ne=function e1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function f1c(a){return this===a};_.Oe=function g1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/2methodref$compare$Type',1505);feb(1507,1,fye,h1c);_.Ne=function i1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function j1c(a){return this===a};_.Oe=function k1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/3methodref$compare$Type',1507);feb(1509,1,{},l1c);_.Ye=function m1c(a){return Kfb(UD(a))};sfb(bFe,'EdgeRouter/4methodref$doubleValue$Type',1509);feb(1511,1,fye,n1c);_.Ne=function o1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function p1c(a){return this===a};_.Oe=function q1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/5methodref$compare$Type',1511);feb(1513,1,fye,r1c);_.Ne=function s1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function t1c(a){return this===a};_.Oe=function u1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/6methodref$compare$Type',1513);feb(1497,1,{},v1c);_.Kb=function w1c(a){return B0c(),RD(mQb(RD(a,40),(h_c(),f_c)),17)};sfb(bFe,'EdgeRouter/lambda$0$Type',1497);feb(1508,1,{},x1c);_.Kb=function y1c(a){return L0c(RD(a,40))};sfb(bFe,'EdgeRouter/lambda$11$Type',1508);feb(1510,1,{},z1c);_.Kb=function A1c(a){return M0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$13$Type',1510);feb(1512,1,{},B1c);_.Kb=function C1c(a){return N0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$15$Type',1512);feb(1514,1,fye,D1c);_.Ne=function E1c(a,b){return O0c(RD(a,65),RD(b,65))};_.Fb=function F1c(a){return this===a};_.Oe=function G1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$17$Type',1514);feb(1515,1,fye,H1c);_.Ne=function I1c(a,b){return P0c(RD(a,65),RD(b,65))};_.Fb=function J1c(a){return this===a};_.Oe=function K1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$18$Type',1515);feb(1516,1,fye,L1c);_.Ne=function M1c(a,b){return Q0c(RD(a,65),RD(b,65))};_.Fb=function N1c(a){return this===a};_.Oe=function O1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$19$Type',1516);feb(1499,1,nwe,P1c);_.Mb=function Q1c(a){return R0c(this.a,RD(a,40))};_.a=0;sfb(bFe,'EdgeRouter/lambda$2$Type',1499);feb(1517,1,fye,R1c);_.Ne=function S1c(a,b){return S0c(RD(a,65),RD(b,65))};_.Fb=function T1c(a){return this===a};_.Oe=function U1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$20$Type',1517);feb(1500,1,fye,V1c);_.Ne=function W1c(a,b){return T0c(RD(a,40),RD(b,40))};_.Fb=function X1c(a){return this===a};_.Oe=function Y1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$3$Type',1500);feb(1501,1,fye,Z1c);_.Ne=function $1c(a,b){return U0c(RD(a,40),RD(b,40))};_.Fb=function _1c(a){return this===a};_.Oe=function a2c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$4$Type',1501);feb(1502,1,{},b2c);_.Kb=function c2c(a){return V0c(RD(a,40))};sfb(bFe,'EdgeRouter/lambda$5$Type',1502);feb(1504,1,{},d2c);_.Kb=function e2c(a){return W0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$7$Type',1504);feb(1506,1,{},f2c);_.Kb=function g2c(a){return X0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$9$Type',1506);feb(675,1,{675:1},i2c);_.e=0;_.f=false;_.g=false;sfb(bFe,'MultiLevelEdgeNodeNodeGap',675);feb(1943,1,fye,l2c);_.Ne=function m2c(a,b){return j2c(RD(a,240),RD(b,240))};_.Fb=function n2c(a){return this===a};_.Oe=function o2c(){return new Frb(this)};sfb(bFe,'MultiLevelEdgeNodeNodeGap/lambda$0$Type',1943);feb(1944,1,fye,p2c);_.Ne=function q2c(a,b){return k2c(RD(a,240),RD(b,240))};_.Fb=function r2c(a){return this===a};_.Oe=function s2c(){return new Frb(this)};sfb(bFe,'MultiLevelEdgeNodeNodeGap/lambda$1$Type',1944);var t2c;feb(501,22,{3:1,34:1,22:1,501:1,188:1,196:1},z2c);_.dg=function B2c(){return y2c(this)};_.qg=function A2c(){return y2c(this)};var v2c,w2c;var s0=tfb(cFe,'RadialLayoutPhases',501,WI,D2c,C2c);var E2c;feb(1113,205,oze,H2c);_.rf=function I2c(a,b){var c,d,e,f,g,h;c=G2c(this,a);b.Ug('Radial layout',c.c.length);Heb(TD(Gxd(a,($4c(),N4c))))||RFb((d=new SFb((lud(),new zud(a))),d));h=K2c(a);Ixd(a,(u2c(),t2c),h);if(!h){throw Adb(new agb('The given graph is not a tree!'))}e=Kfb(UD(Gxd(a,S4c)));e==0&&(e=J2c(a));Ixd(a,S4c,e);for(g=new Anb(G2c(this,a));g.a=3){v=RD(QHd(t,0),27);w=RD(QHd(t,1),27);f=0;while(f+2=v.f+w.f+k||w.f>=u.f+v.f+k){B=true;break}else {++f;}}}else {B=true;}if(!B){m=t.i;for(h=new dMd(t);h.e!=h.i.gc();){g=RD(bMd(h),27);Ixd(g,(umd(),Rld),sgb(m));--m;}crd(a,new Oqd);b.Vg();return}c=(Sed(this.a),Ved(this.a,(f6c(),c6c),RD(Gxd(a,V7c),188)),Ved(this.a,d6c,RD(Gxd(a,M7c),188)),Ved(this.a,e6c,RD(Gxd(a,S7c),188)),Ped(this.a,(D=new ufd,pfd(D,c6c,(z6c(),y6c)),pfd(D,d6c,x6c),Heb(TD(Gxd(a,B7c)))&&pfd(D,c6c,w6c),D)),Qed(this.a,a));j=1/c.c.length;for(o=new Anb(c);o.a0&&vjd((BFb(c-1,b.length),b.charCodeAt(c-1)),ZAe)){--c;}if(e>=c){throw Adb(new agb('The given string does not contain any numbers.'))}f=vhb((AFb(e,c,b.length),b.substr(e,c-e)),',|;|\r|\n');if(f.length!=2){throw Adb(new agb('Exactly two numbers are expected, '+f.length+' were found.'))}try{this.a=Neb(Dhb(f[0]));this.b=Neb(Dhb(f[1]));}catch(a){a=zdb(a);if(ZD(a,130)){d=a;throw Adb(new agb($Ae+d))}else throw Adb(a)}};_.Ib=function yjd(){return '('+this.a+','+this.b+')'};_.a=0;_.b=0;var l3=sfb(_Ae,'KVector',8);feb(75,67,{3:1,4:1,20:1,31:1,56:1,16:1,67:1,15:1,75:1,423:1},Ejd,Fjd,Gjd);_.Pc=function Jjd(){return Djd(this)};_.cg=function Hjd(b){var c,d,e,f,g,h;e=vhb(b,',|;|\\(|\\)|\\[|\\]|\\{|\\}| |\t|\n');Xub(this);try{d=0;g=0;f=0;h=0;while(d0){g%2==0?(f=Neb(e[d])):(h=Neb(e[d]));g>0&&g%2!=0&&Mub(this,new rjd(f,h));++g;}++d;}}catch(a){a=zdb(a);if(ZD(a,130)){c=a;throw Adb(new agb('The given string does not match the expected format for vectors.'+c))}else throw Adb(a)}};_.Ib=function Kjd(){var a,b,c;a=new dib('(');b=Sub(this,0);while(b.b!=b.d.c){c=RD(evb(b),8);Zhb(a,c.a+','+c.b);b.b!=b.d.c&&(a.a+='; ',a);}return (a.a+=')',a).a};var k3=sfb(_Ae,'KVectorChain',75);feb(255,22,{3:1,34:1,22:1,255:1},Sjd);var Ljd,Mjd,Njd,Ojd,Pjd,Qjd;var n3=tfb(JGe,'Alignment',255,WI,Ujd,Tjd);var Vjd;feb(991,1,Eye,jkd);_.hf=function kkd(a){ikd(a);};var Xjd,Yjd,Zjd,$jd,_jd,akd,bkd,ckd,dkd,ekd,fkd,gkd;sfb(JGe,'BoxLayouterOptions',991);feb(992,1,{},lkd);_.sf=function mkd(){var a;return a=new jrd,a};_.tf=function nkd(a){};sfb(JGe,'BoxLayouterOptions/BoxFactory',992);feb(298,22,{3:1,34:1,22:1,298:1},vkd);var okd,pkd,qkd,rkd,skd,tkd;var q3=tfb(JGe,'ContentAlignment',298,WI,xkd,wkd);var ykd;feb(699,1,Eye,vmd);_.hf=function wmd(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,OGe),''),'Layout Algorithm'),'Select a specific layout algorithm.'),(kid(),iid)),qJ),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,PGe),''),'Resolved Layout Algorithm'),'Meta data associated with the selected algorithm.'),hid),D2),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MDe),''),'Alignment'),'Alignment of the selected node relative to other nodes; the exact meaning depends on the used algorithm.'),Ckd),eid),n3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,Dze),''),'Aspect Ratio'),'The desired aspect ratio of the drawing, that is the quotient of width by height.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,QGe),''),'Bend Points'),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),hid),k3),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YDe),''),'Content Alignment'),'Specifies how the content of a node are aligned. Each node can individually control the alignment of its contents. I.e. if a node should be aligned top left in its parent node, the parent node should specify that option.'),Lkd),fid),q3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LDe),''),'Debug Mode'),'Whether additional debug information shall be generated.'),(Geb(),false)),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PDe),''),eze),'Overall direction of edges: horizontal (right / left) or vertical (down / up).'),Okd),eid),s3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kDe),''),'Edge Routing'),'What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline.'),Tkd),eid),u3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MGe),''),'Expand Nodes'),'If active, nodes are expanded to fill the area of their parent.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fDe),''),'Hierarchy Handling'),"Determines whether separate layout runs are triggered for different compound nodes in a hierarchical graph. Setting a node's hierarchy handling to `INCLUDE_CHILDREN` will lay out that node and all of its descendants in a single layout run, until a descendant is encountered which has its hierarchy handling set to `SEPARATE_CHILDREN`. In general, `SEPARATE_CHILDREN` will ensure that a new layout run is triggered for a node with that setting. Including multiple levels of hierarchy in a single layout run may allow cross-hierarchical edges to be laid out properly. If the root node is set to `INHERIT` (or not set at all), the default behavior is `SEPARATE_CHILDREN`."),Ykd),eid),y3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Eze),''),'Padding'),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),uld),hid),i3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dAe),''),'Interactive'),'Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iEe),''),'interactive Layout'),'Whether the graph should be changeable interactively and by setting constraints'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gAe),''),'Omit Node Micro Layout'),"Node micro layout comprises the computation of node dimensions (if requested), the placement of ports and their labels, and the placement of node labels. The functionality is implemented independent of any specific layout algorithm and shouldn't have any negative impact on the layout algorithm's performance itself. Yet, if any unforeseen behavior occurs, this option allows to deactivate the micro layout."),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eAe),''),'Port Constraints'),'Defines constraints of the position of the ports of a node.'),Ild),eid),C3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,fEe),''),'Position'),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),hid),l3),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,$ze),''),'Priority'),'Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used.'),gid),bJ),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,bAe),''),'Randomization Seed'),'Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time).'),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cAe),''),'Separate Connected Components'),'Whether each connected component should be processed separately.'),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZDe),''),'Junction Points'),'This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order.'),dld),hid),k3),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aEe),''),'Comment Box'),'Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bEe),''),'Hypernode'),'Whether the node should be handled as a hypernode.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,RGe),''),'Label Manager'),"Label managers can shorten labels upon a layout algorithm's request."),hid),g3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gEe),''),'Margins'),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),fld),hid),h3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JDe),''),'No Layout'),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),false),cid),QI),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd,Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SGe),''),'Scale Factor'),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),did),VI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,TGe),''),'Child Area Width'),'The width of the area occupied by the laid out children of a node.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,UGe),''),'Child Area Height'),'The height of the area occupied by the laid out children of a node.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,mAe),''),yGe),"Turns topdown layout on and off. If this option is enabled, hierarchical layout will be computed first for the root node and then for its children recursively. Layouts are then scaled down to fit the area provided by their parents. Graphs must follow a certain structure for topdown layout to work properly. {@link TopdownNodeTypes.PARALLEL_NODE} nodes must have children of type {@link TopdownNodeTypes.HIERARCHICAL_NODE} and must define {@link topdown.hierarchicalNodeWidth} and {@link topdown.hierarchicalNodeAspectRatio} for their children. Furthermore they need to be laid out using an algorithm that is a {@link TopdownLayoutProvider}. Hierarchical nodes can also be parents of other hierarchical nodes and can optionally use a {@link TopdownSizeApproximator} to dynamically set sizes during topdown layout. In this case {@link topdown.hierarchicalNodeWidth} and {@link topdown.hierarchicalNodeAspectRatio} should be set on the node itself rather than the parent. The values are then used by the size approximator as base values. Hierarchical nodes require the layout option {@link nodeSize.fixedGraphSize} to be true to prevent the algorithm used there from resizing the hierarchical node. This option is not supported if 'Hierarchy Handling' is set to 'INCLUDE_CHILDREN'"),false),cid),QI),xsb(Whd))));zgd(a,mAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VGe),''),'Animate'),'Whether the shift from the old layout to the new computed layout shall be animated.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WGe),''),'Animation Time Factor'),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),sgb(100)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XGe),''),'Layout Ancestors'),'Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YGe),''),'Maximal Animation Time'),'The maximal time for animations, in milliseconds.'),sgb(4000)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZGe),''),'Minimal Animation Time'),'The minimal time for animations, in milliseconds.'),sgb(400)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Ge),''),'Progress Bar'),'Whether a progress bar shall be displayed during layout computations.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Ge),''),'Validate Graph'),'Whether the graph shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aHe),''),'Validate Options'),'Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bHe),''),'Zoom to Fit'),'Whether the zoom level shall be set to view the whole diagram after layout.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NGe),'box'),'Box Layout Mode'),'Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better.'),Gkd),eid),R3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xDe),lDe),'Comment Comment Spacing'),'Spacing to be preserved between a comment box and other comment boxes connected to the same node. The space left between comment boxes of different nodes is controlled by the node-node spacing.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yDe),lDe),'Comment Node Spacing'),'Spacing to be preserved between a node and its connected comment boxes. The space left between a node and the comments of another node is controlled by the node-node spacing.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Bze),lDe),'Components Spacing'),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zDe),lDe),'Edge Spacing'),'Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aAe),lDe),'Edge Label Spacing'),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ADe),lDe),'Edge Node Spacing'),'Spacing to be preserved between nodes and edges.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,BDe),lDe),'Label Spacing'),'Determines the amount of space to be left between two labels of the same graph element.'),0),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,EDe),lDe),'Label Node Spacing'),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CDe),lDe),'Horizontal spacing between Label and Port'),"Horizontal spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,DDe),lDe),'Vertical spacing between Label and Port'),"Vertical spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_ze),lDe),'Node Spacing'),'The minimal distance to be preserved between each two nodes.'),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,FDe),lDe),'Node Self Loop Spacing'),'Spacing to be preserved between a node and its self loops.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,GDe),lDe),'Port Spacing'),'Spacing between pairs of ports of the same node.'),10),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,HDe),lDe),'Individual Spacing'),"Allows to specify individual spacing values for graph elements that shall be different from the value specified for the element's parent."),hid),l4),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd,Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hEe),lDe),'Additional Port Space'),'Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border.'),imd),hid),h3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,eEe),hHe),'Layout Partition'),'Partition to which the node belongs. This requires Layout Partitioning to be active. Nodes with lower partition IDs will appear to the left of nodes with higher partition IDs (assuming a left-to-right layout direction).'),gid),bJ),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,eEe,dEe,yld);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dEe),hHe),'Layout Partitioning'),'Whether to activate partitioned layout. This will allow to group nodes through the Layout Partition option. a pair of nodes with different partition indices is then placed such that the node with lower index is placed to the left of the other node (with left-to-right layout direction). Depending on the layout algorithm, this may only be guaranteed to work if all nodes have a layout partition configured, or at least if edges that cross partitions are not part of a partition-crossing cycle.'),wld),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,QDe),iHe),'Node Label Padding'),'Define padding for node labels that are placed inside of a node.'),hld),hid),i3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kAe),iHe),'Node Label Placement'),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),jld),fid),A3),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TDe),jHe),'Port Alignment'),'Defines the default port distribution for a node. May be overridden for each side individually.'),Ald),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,UDe),jHe),'Port Alignment (North)'),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,VDe),jHe),'Port Alignment (South)'),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,WDe),jHe),'Port Alignment (West)'),"Defines how ports on the western side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,XDe),jHe),'Port Alignment (East)'),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,jAe),kHe),'Node Size Constraints'),"What should be taken into account when calculating a node's size. Empty size constraints specify that a node's size is already fixed and should not be changed."),lld),fid),H3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iAe),kHe),'Node Size Options'),'Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications.'),qld),fid),I3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CAe),kHe),'Node Size Minimum'),'The minimal size to which a node can be reduced.'),old),hid),l3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hAe),kHe),'Fixed Graph Size'),"By default, the fixed layout provider will enlarge a graph until it is large enough to contain its children. If this option is set, it won't do so."),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$De),vDe),'Edge Label Placement'),'Gives a hint on where to put edge labels.'),Rkd),eid),t3),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fAe),vDe),'Inline Edge Labels'),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),false),cid),QI),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cHe),'font'),'Font Name'),'Font name used for a label.'),iid),qJ),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,dHe),'font'),'Font Size'),'Font size used for a label.'),gid),bJ),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cEe),lHe),'Port Anchor Offset'),'The offset to the port position where connections shall be attached.'),hid),l3),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,_De),lHe),'Port Index'),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),gid),bJ),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KDe),lHe),'Port Side'),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),Pld),eid),E3),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,IDe),lHe),'Port Border Offset'),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),did),VI),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,lAe),mHe),'Port Label Placement'),"Decides on a placement method for port labels; if empty, the node label's position is not modified."),Mld),fid),D3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RDe),mHe),'Port Labels Next to Port'),"Use 'portLabels.placement': NEXT_TO_PORT_OF_POSSIBLE."),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SDe),mHe),'Treat Port Labels as Group'),'If this option is true (default), the labels of a port will be treated as a group when it comes to centering them next to their port. If this option is false, only the first label will be centered next to the port, with the others being placed below. This only applies to labels of eastern and western ports and will have no effect if labels are not placed next to their port.'),true),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,nAe),nHe),'Topdown Scale Factor'),"The scaling factor to be applied to the nodes laid out within the node in recursive topdown layout. The difference to 'Scale Factor' is that the node itself is not scaled. This value has to be set on hierarchical nodes."),1),did),VI),xsb(Whd))));zgd(a,nAe,qAe,rmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eHe),nHe),'Topdown Size Approximator'),'The size approximator to be used to set sizes of hierarchical nodes during topdown layout. The default value is null, which results in nodes keeping whatever size is defined for them e.g. through parent parallel node or by manually setting the size.'),null),eid),M3),xsb(Vhd))));zgd(a,eHe,qAe,tmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,oAe),nHe),'Topdown Hierarchical Node Width'),'The fixed size of a hierarchical node when using topdown layout. If this value is set on a parallel node it applies to its children, when set on a hierarchical node it applies to the node itself.'),150),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,oAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,pAe),nHe),'Topdown Hierarchical Node Aspect Ratio'),'The fixed aspect ratio of a hierarchical node when using topdown layout. Default is 1/sqrt(2). If this value is set on a parallel node it applies to its children, when set on a hierarchical node it applies to the node itself.'),1.414),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,pAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,qAe),nHe),'Topdown Node Type'),'The different node types used for topdown layout. If the node type is set to {@link TopdownNodeTypes.PARALLEL_NODE} the algorithm must be set to a {@link TopdownLayoutProvider} such as {@link TopdownPacking}. The {@link nodeSize.fixedGraphSize} option is technically only required for hierarchical nodes.'),null),eid),J3),xsb(Vhd))));zgd(a,qAe,hAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fHe),nHe),'Topdown Scale Cap'),'Determines the upper limit for the topdown scale factor. The default value is 1.0 which ensures that nested children never end up appearing larger than their parents in terms of unit sizes such as the font size. If the limit is larger, nodes will fully utilize the available space, but it is counteriniuitive for inner nodes to have a larger scale than outer nodes.'),1),did),VI),xsb(Whd))));zgd(a,fHe,qAe,pmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NDe),oHe),'Activate Inside Self Loops'),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ODe),oHe),'Inside Self Loop'),'Whether a self loop should be routed inside a node instead of around that node.'),false),cid),QI),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Cze),'edge'),'Edge Thickness'),'The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it.'),1),did),VI),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gHe),'edge'),'Edge Type'),'The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations.'),Vkd),eid),v3),xsb(Thd))));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,sxe),'Layered'),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.orthogonal'),'Orthogonal'),'Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia \'86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,Zze),'Force'),'Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.circle'),'Circle'),'Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,$Ee),'Tree'),'Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.planar'),'Planar'),'Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,CFe),'Radial'),'Radial layout algorithms usually position the nodes of the graph on concentric circles.')));wnd((new xnd,a));ikd((new jkd,a));Gpd((new Hpd,a));};var Akd,Bkd,Ckd,Dkd,Ekd,Fkd,Gkd,Hkd,Ikd,Jkd,Kkd,Lkd,Mkd,Nkd,Okd,Pkd,Qkd,Rkd,Skd,Tkd,Ukd,Vkd,Wkd,Xkd,Ykd,Zkd,$kd,_kd,ald,bld,cld,dld,eld,fld,gld,hld,ild,jld,kld,lld,mld,nld,old,pld,qld,rld,sld,tld,uld,vld,wld,xld,yld,zld,Ald,Bld,Cld,Dld,Eld,Fld,Gld,Hld,Ild,Jld,Kld,Lld,Mld,Nld,Old,Pld,Qld,Rld,Sld,Tld,Uld,Vld,Wld,Xld,Yld,Zld,$ld,_ld,amd,bmd,cmd,dmd,emd,fmd,gmd,hmd,imd,jmd,kmd,lmd,mmd,nmd,omd,pmd,qmd,rmd,smd,tmd;sfb(JGe,'CoreOptions',699);feb(88,22,{3:1,34:1,22:1,88:1},Gmd);var xmd,ymd,zmd,Amd,Bmd;var s3=tfb(JGe,eze,88,WI,Imd,Hmd);var Jmd;feb(278,22,{3:1,34:1,22:1,278:1},Pmd);var Lmd,Mmd,Nmd;var t3=tfb(JGe,'EdgeLabelPlacement',278,WI,Rmd,Qmd);var Smd;feb(223,22,{3:1,34:1,22:1,223:1},Zmd);var Umd,Vmd,Wmd,Xmd;var u3=tfb(JGe,'EdgeRouting',223,WI,_md,$md);var and;feb(321,22,{3:1,34:1,22:1,321:1},jnd);var cnd,dnd,end,fnd,gnd,hnd;var v3=tfb(JGe,'EdgeType',321,WI,lnd,knd);var mnd;feb(989,1,Eye,xnd);_.hf=function ynd(a){wnd(a);};var ond,pnd,qnd,rnd,snd,tnd,und;sfb(JGe,'FixedLayouterOptions',989);feb(990,1,{},znd);_.sf=function And(){var a;return a=new btd,a};_.tf=function Bnd(a){};sfb(JGe,'FixedLayouterOptions/FixedFactory',990);feb(346,22,{3:1,34:1,22:1,346:1},Gnd);var Cnd,Dnd,End;var y3=tfb(JGe,'HierarchyHandling',346,WI,Ind,Hnd);var Jnd;feb(291,22,{3:1,34:1,22:1,291:1},Rnd);var Lnd,Mnd,Nnd,Ond;var z3=tfb(JGe,'LabelSide',291,WI,Tnd,Snd);var Und;feb(95,22,{3:1,34:1,22:1,95:1},eod);var Wnd,Xnd,Ynd,Znd,$nd,_nd,aod,bod,cod;var A3=tfb(JGe,'NodeLabelPlacement',95,WI,hod,god);var iod;feb(256,22,{3:1,34:1,22:1,256:1},qod);var kod,lod,mod,nod,ood;var B3=tfb(JGe,'PortAlignment',256,WI,sod,rod);var tod;feb(101,22,{3:1,34:1,22:1,101:1},Eod);var vod,wod,xod,yod,zod,Aod;var C3=tfb(JGe,'PortConstraints',101,WI,God,Fod);var Hod;feb(279,22,{3:1,34:1,22:1,279:1},Qod);var Jod,Kod,Lod,Mod,Nod,Ood;var D3=tfb(JGe,'PortLabelPlacement',279,WI,Uod,Tod);var Vod;feb(64,22,{3:1,34:1,22:1,64:1},upd);var Xod,Yod,Zod,$od,_od,apd,bpd,cpd,dpd,epd,fpd,gpd,hpd,ipd,jpd,kpd,lpd,mpd,npd,opd,ppd;var E3=tfb(JGe,'PortSide',64,WI,xpd,wpd);var ypd;feb(993,1,Eye,Hpd);_.hf=function Ipd(a){Gpd(a);};var Apd,Bpd,Cpd,Dpd,Epd;sfb(JGe,'RandomLayouterOptions',993);feb(994,1,{},Jpd);_.sf=function Kpd(){var a;return a=new eud,a};_.tf=function Lpd(a){};sfb(JGe,'RandomLayouterOptions/RandomFactory',994);feb(386,22,{3:1,34:1,22:1,386:1},Rpd);var Mpd,Npd,Opd,Ppd;var H3=tfb(JGe,'SizeConstraint',386,WI,Tpd,Spd);var Upd;feb(264,22,{3:1,34:1,22:1,264:1},eqd);var Wpd,Xpd,Ypd,Zpd,$pd,_pd,aqd,bqd,cqd;var I3=tfb(JGe,'SizeOptions',264,WI,gqd,fqd);var hqd;feb(280,22,{3:1,34:1,22:1,280:1},nqd);var jqd,kqd,lqd;var J3=tfb(JGe,'TopdownNodeTypes',280,WI,pqd,oqd);var qqd;feb(347,22,rHe);var sqd,tqd;var M3=tfb(JGe,'TopdownSizeApproximator',347,WI,xqd,wqd);feb(987,347,rHe,zqd);_.Tg=function Aqd(a){return yqd(a)};tfb(JGe,'TopdownSizeApproximator/1',987,M3,null,null);feb(988,347,rHe,Bqd);_.Tg=function Cqd(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;c=RD(Gxd(b,(umd(),Tld)),143);A=(bvd(),o=new ACd,o);zxd(A,b);B=new Tsb;for(g=new dMd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));g.e!=g.i.gc();){e=RD(bMd(g),27);t=(n=new ACd,n);yCd(t,A);zxd(t,e);D=yqd(e);zyd(t,$wnd.Math.max(e.g,D.a),$wnd.Math.max(e.f,D.b));rtb(B.f,e,t);}for(f=new dMd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));f.e!=f.i.gc();){e=RD(bMd(f),27);for(l=new dMd((!e.e&&(e.e=new Yie(G4,e,7,4)),e.e));l.e!=l.i.gc();){k=RD(bMd(l),74);v=RD(Wd(qtb(B.f,e)),27);w=RD(Wjb(B,QHd((!k.c&&(k.c=new Yie(E4,k,5,8)),k.c),0)),27);u=(m=new rzd,m);WGd((!u.b&&(u.b=new Yie(E4,u,4,7)),u.b),v);WGd((!u.c&&(u.c=new Yie(E4,u,5,8)),u.c),w);pzd(u,vCd(v));zxd(u,k);}}q=RD(ltd(c.f),205);try{q.rf(A,new ztd);mtd(c.f,q);}catch(a){a=zdb(a);if(ZD(a,103)){p=a;throw Adb(p)}else throw Adb(a)}Hxd(A,Ikd)||Hxd(A,Hkd)||psd(A);j=Kfb(UD(Gxd(A,Ikd)));i=Kfb(UD(Gxd(A,Hkd)));h=j/i;d=Kfb(UD(Gxd(A,lmd)))*$wnd.Math.sqrt((!A.a&&(A.a=new C5d(J4,A,10,11)),A.a).i);C=RD(Gxd(A,tld),107);s=C.b+C.c+1;r=C.d+C.a+1;return new rjd($wnd.Math.max(s,d),$wnd.Math.max(r,d/h))};tfb(JGe,'TopdownSizeApproximator/2',988,M3,null,null);var Dqd;feb(344,1,{871:1},Oqd);_.Ug=function Pqd(a,b){return Fqd(this,a,b)};_.Vg=function Qqd(){Hqd(this);};_.Wg=function Rqd(){return this.q};_.Xg=function Sqd(){return !this.f?null:Hob(this.f)};_.Yg=function Tqd(){return Hob(this.a)};_.Zg=function Uqd(){return this.p};_.$g=function Vqd(){return false};_._g=function Wqd(){return this.n};_.ah=function Xqd(){return this.p!=null&&!this.b};_.bh=function Yqd(a){var b;if(this.n){b=a;Rmb(this.f,b);}};_.dh=function Zqd(a,b){var c,d;this.n&&!!a&&Jqd(this,(c=new Zje,d=Rje(c,a),Yje(c),d),(ttd(),qtd));};_.eh=function $qd(a){var b;if(this.b){return null}else {b=Gqd(this,this.g);Mub(this.a,b);b.i=this;this.d=a;return b}};_.fh=function _qd(a){a>0&&!this.b&&Iqd(this,a);};_.b=false;_.c=0;_.d=-1;_.e=null;_.f=null;_.g=-1;_.j=false;_.k=false;_.n=false;_.o=0;_.q=0;_.r=0;sfb(jEe,'BasicProgressMonitor',344);feb(717,205,oze,jrd);_.rf=function nrd(a,b){crd(a,b);};sfb(jEe,'BoxLayoutProvider',717);feb(983,1,fye,prd);_.Ne=function qrd(a,b){return ord(this,RD(a,27),RD(b,27))};_.Fb=function rrd(a){return this===a};_.Oe=function srd(){return new Frb(this)};_.a=false;sfb(jEe,'BoxLayoutProvider/1',983);feb(163,1,{163:1},zrd,Ard);_.Ib=function Brd(){return this.c?zCd(this.c):Fe(this.b)};sfb(jEe,'BoxLayoutProvider/Group',163);feb(320,22,{3:1,34:1,22:1,320:1},Hrd);var Crd,Drd,Erd,Frd;var R3=tfb(jEe,'BoxLayoutProvider/PackingMode',320,WI,Jrd,Ird);var Krd;feb(984,1,fye,Mrd);_.Ne=function Nrd(a,b){return krd(RD(a,163),RD(b,163))};_.Fb=function Ord(a){return this===a};_.Oe=function Prd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$0$Type',984);feb(985,1,fye,Qrd);_.Ne=function Rrd(a,b){return lrd(RD(a,163),RD(b,163))};_.Fb=function Srd(a){return this===a};_.Oe=function Trd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$1$Type',985);feb(986,1,fye,Urd);_.Ne=function Vrd(a,b){return mrd(RD(a,163),RD(b,163))};_.Fb=function Wrd(a){return this===a};_.Oe=function Xrd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$2$Type',986);feb(1384,1,{845:1},Yrd);_.Mg=function Zrd(a,b){return GCc(),!ZD(b,167)||ued((hed(),RD(a,167)),b)};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$0$Type',1384);feb(1385,1,Qve,$rd);_.Cd=function _rd(a){JCc(this.a,RD(a,149));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$1$Type',1385);feb(1386,1,Qve,asd);_.Cd=function bsd(a){RD(a,96);GCc();};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$2$Type',1386);feb(1390,1,Qve,csd);_.Cd=function dsd(a){KCc(this.a,RD(a,96));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$3$Type',1390);feb(1388,1,nwe,esd);_.Mb=function fsd(a){return LCc(this.a,this.b,RD(a,149))};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$4$Type',1388);feb(1387,1,nwe,gsd);_.Mb=function hsd(a){return NCc(this.a,this.b,RD(a,845))};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$5$Type',1387);feb(1389,1,Qve,isd);_.Cd=function jsd(a){MCc(this.a,this.b,RD(a,149));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$6$Type',1389);feb(947,1,{},Lsd);_.Kb=function Msd(a){return Ksd(a)};_.Fb=function Nsd(a){return this===a};sfb(jEe,'ElkUtil/lambda$0$Type',947);feb(948,1,Qve,Osd);_.Cd=function Psd(a){ysd(this.a,this.b,RD(a,74));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$1$Type',948);feb(949,1,Qve,Qsd);_.Cd=function Rsd(a){zsd(this.a,this.b,RD(a,166));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$2$Type',949);feb(950,1,Qve,Ssd);_.Cd=function Tsd(a){Asd(this.a,this.b,RD(a,135));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$3$Type',950);feb(951,1,Qve,Usd);_.Cd=function Vsd(a){Bsd(this.a,RD(a,377));};sfb(jEe,'ElkUtil/lambda$4$Type',951);feb(325,1,{34:1,325:1},Xsd);_.Fd=function Ysd(a){return Wsd(this,RD(a,242))};_.Fb=function Zsd(a){var b;if(ZD(a,325)){b=RD(a,325);return this.a==b.a}return false};_.Hb=function $sd(){return eE(this.a)};_.Ib=function _sd(){return this.a+' (exclusive)'};_.a=0;sfb(jEe,'ExclusiveBounds/ExclusiveLowerBound',325);feb(1119,205,oze,btd);_.rf=function ctd(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B;b.Ug('Fixed Layout',1);f=RD(Gxd(a,(umd(),Skd)),223);l=0;m=0;for(s=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));s.e!=s.i.gc();){q=RD(bMd(s),27);B=RD(Gxd(q,(vnd(),und)),8);if(B){Byd(q,B.a,B.b);if(RD(Gxd(q,pnd),181).Hc((Qpd(),Mpd))){n=RD(Gxd(q,rnd),8);n.a>0&&n.b>0&&Esd(q,n.a,n.b,true,true);}}l=$wnd.Math.max(l,q.i+q.g);m=$wnd.Math.max(m,q.j+q.f);for(j=new dMd((!q.n&&(q.n=new C5d(I4,q,1,7)),q.n));j.e!=j.i.gc();){h=RD(bMd(j),135);B=RD(Gxd(h,und),8);!!B&&Byd(h,B.a,B.b);l=$wnd.Math.max(l,q.i+h.i+h.g);m=$wnd.Math.max(m,q.j+h.j+h.f);}for(v=new dMd((!q.c&&(q.c=new C5d(K4,q,9,9)),q.c));v.e!=v.i.gc();){u=RD(bMd(v),123);B=RD(Gxd(u,und),8);!!B&&Byd(u,B.a,B.b);w=q.i+u.i;A=q.j+u.j;l=$wnd.Math.max(l,w+u.g);m=$wnd.Math.max(m,A+u.f);for(i=new dMd((!u.n&&(u.n=new C5d(I4,u,1,7)),u.n));i.e!=i.i.gc();){h=RD(bMd(i),135);B=RD(Gxd(h,und),8);!!B&&Byd(h,B.a,B.b);l=$wnd.Math.max(l,w+h.i+h.g);m=$wnd.Math.max(m,A+h.j+h.f);}}for(e=new is(Mr(zGd(q).a.Kc(),new ir));gs(e);){c=RD(hs(e),74);k=atd(c);l=$wnd.Math.max(l,k.a);m=$wnd.Math.max(m,k.b);}for(d=new is(Mr(yGd(q).a.Kc(),new ir));gs(d);){c=RD(hs(d),74);if(vCd(JGd(c))!=a){k=atd(c);l=$wnd.Math.max(l,k.a);m=$wnd.Math.max(m,k.b);}}}if(f==(Ymd(),Umd)){for(r=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));r.e!=r.i.gc();){q=RD(bMd(r),27);for(d=new is(Mr(zGd(q).a.Kc(),new ir));gs(d);){c=RD(hs(d),74);g=tsd(c);g.b==0?Ixd(c,cld,null):Ixd(c,cld,g);}}}if(!Heb(TD(Gxd(a,(vnd(),qnd))))){t=RD(Gxd(a,snd),107);p=l+t.b+t.c;o=m+t.d+t.a;Esd(a,p,o,true,true);}b.Vg();};sfb(jEe,'FixedLayoutProvider',1119);feb(385,137,{3:1,423:1,385:1,96:1,137:1},dtd,etd);_.cg=function htd(b){var c,d,e,f,g,h,i,j,k;if(!b){return}try{j=vhb(b,';,;');for(g=j,h=0,i=g.length;h>16&Bwe|b^d<<16};_.Kc=function Ttd(){return new Vtd(this)};_.Ib=function Utd(){return this.a==null&&this.b==null?'pair(null,null)':this.a==null?'pair(null,'+jeb(this.b)+')':this.b==null?'pair('+jeb(this.a)+',null)':'pair('+jeb(this.a)+','+jeb(this.b)+')'};sfb(jEe,'Pair',42);feb(995,1,Ave,Vtd);_.Nb=function Wtd(a){Ztb(this,a);};_.Ob=function Xtd(){return !this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)};_.Pb=function Ytd(){if(!this.c&&!this.b&&this.a.a!=null){this.b=true;return this.a.a}else if(!this.c&&this.a.b!=null){this.c=true;return this.a.b}throw Adb(new Dvb)};_.Qb=function Ztd(){this.c&&this.a.b!=null?(this.a.b=null):this.b&&this.a.a!=null&&(this.a.a=null);throw Adb(new cgb)};_.b=false;_.c=false;sfb(jEe,'Pair/1',995);feb(455,1,{455:1},$td);_.Fb=function _td(a){return Fvb(this.a,RD(a,455).a)&&Fvb(this.c,RD(a,455).c)&&Fvb(this.d,RD(a,455).d)&&Fvb(this.b,RD(a,455).b)};_.Hb=function aud(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.a,this.c,this.d,this.b]))};_.Ib=function bud(){return '('+this.a+pve+this.c+pve+this.d+pve+this.b+')'};sfb(jEe,'Quadruple',455);feb(1108,205,oze,eud);_.rf=function fud(a,b){var c,d,e,f,g;b.Ug('Random Layout',1);if((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a).i==0){b.Vg();return}f=RD(Gxd(a,(Fpd(),Dpd)),17);!!f&&f.a!=0?(e=new Pwb(f.a)):(e=new Owb);c=Mfb(UD(Gxd(a,Apd)));g=Mfb(UD(Gxd(a,Epd)));d=RD(Gxd(a,Bpd),107);dud(a,e,c,g,d);b.Vg();};sfb(jEe,'RandomLayoutProvider',1108);feb(240,1,{240:1},gud);_.Fb=function hud(a){return Fvb(this.a,RD(a,240).a)&&Fvb(this.b,RD(a,240).b)&&Fvb(this.c,RD(a,240).c)};_.Hb=function iud(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.a,this.b,this.c]))};_.Ib=function jud(){return '('+this.a+pve+this.b+pve+this.c+')'};sfb(jEe,'Triple',240);var kud;feb(562,1,{});_.Lf=function oud(){return new rjd(this.f.i,this.f.j)};_.of=function pud(a){if(hGd(a,(umd(),Gld))){return Gxd(this.f,mud)}return Gxd(this.f,a)};_.Mf=function qud(){return new rjd(this.f.g,this.f.f)};_.Nf=function rud(){return this.g};_.pf=function sud(a){return Hxd(this.f,a)};_.Of=function tud(a){Dyd(this.f,a.a);Eyd(this.f,a.b);};_.Pf=function uud(a){Cyd(this.f,a.a);Ayd(this.f,a.b);};_.Qf=function vud(a){this.g=a;};_.g=0;var mud;sfb(uHe,'ElkGraphAdapters/AbstractElkGraphElementAdapter',562);feb(563,1,{853:1},wud);_.Rf=function xud(){var a,b;if(!this.b){this.b=fv(iyd(this.a).i);for(b=new dMd(iyd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),135);Rmb(this.b,new Bud(a));}}return this.b};_.b=null;sfb(uHe,'ElkGraphAdapters/ElkEdgeAdapter',563);feb(289,562,{},zud);_.Sf=function Aud(){return yud(this)};_.a=null;sfb(uHe,'ElkGraphAdapters/ElkGraphAdapter',289);feb(640,562,{187:1},Bud);sfb(uHe,'ElkGraphAdapters/ElkLabelAdapter',640);feb(639,562,{695:1},Fud);_.Rf=function Iud(){return Cud(this)};_.Vf=function Jud(){var a;return a=RD(Gxd(this.f,(umd(),eld)),140),!a&&(a=new P2b),a};_.Xf=function Lud(){return Dud(this)};_.Zf=function Nud(a){var b;b=new S2b(a);Ixd(this.f,(umd(),eld),b);};_.$f=function Oud(a){Ixd(this.f,(umd(),tld),new B3b(a));};_.Tf=function Gud(){return this.d};_.Uf=function Hud(){var a,b;if(!this.a){this.a=new bnb;for(b=new is(Mr(yGd(RD(this.f,27)).a.Kc(),new ir));gs(b);){a=RD(hs(b),74);Rmb(this.a,new wud(a));}}return this.a};_.Wf=function Kud(){var a,b;if(!this.c){this.c=new bnb;for(b=new is(Mr(zGd(RD(this.f,27)).a.Kc(),new ir));gs(b);){a=RD(hs(b),74);Rmb(this.c,new wud(a));}}return this.c};_.Yf=function Mud(){return tCd(RD(this.f,27)).i!=0||Heb(TD(RD(this.f,27).of((umd(),$kd))))};_._f=function Pud(){Eud(this,(lud(),kud));};_.a=null;_.b=null;_.c=null;_.d=null;_.e=null;sfb(uHe,'ElkGraphAdapters/ElkNodeAdapter',639);feb(1284,562,{852:1},Rud);_.Rf=function Tud(){return Qud(this)};_.Uf=function Sud(){var a,b;if(!this.a){this.a=ev(RD(this.f,123).hh().i);for(b=new dMd(RD(this.f,123).hh());b.e!=b.i.gc();){a=RD(bMd(b),74);Rmb(this.a,new wud(a));}}return this.a};_.Wf=function Uud(){var a,b;if(!this.c){this.c=ev(RD(this.f,123).ih().i);for(b=new dMd(RD(this.f,123).ih());b.e!=b.i.gc();){a=RD(bMd(b),74);Rmb(this.c,new wud(a));}}return this.c};_.ag=function Vud(){return RD(RD(this.f,123).of((umd(),Old)),64)};_.bg=function Wud(){var a,b,c,d,e,f,g,h;d=MCd(RD(this.f,123));for(c=new dMd(RD(this.f,123).ih());c.e!=c.i.gc();){a=RD(bMd(c),74);for(h=new dMd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c));h.e!=h.i.gc();){g=RD(bMd(h),84);if(NGd(AGd(g),d)){return true}else if(AGd(g)==d&&Heb(TD(Gxd(a,(umd(),_kd))))){return true}}}for(b=new dMd(RD(this.f,123).hh());b.e!=b.i.gc();){a=RD(bMd(b),74);for(f=new dMd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b));f.e!=f.i.gc();){e=RD(bMd(f),84);if(NGd(AGd(e),d)){return true}}}return false};_.a=null;_.b=null;_.c=null;sfb(uHe,'ElkGraphAdapters/ElkPortAdapter',1284);feb(1285,1,fye,Yud);_.Ne=function Zud(a,b){return Xud(RD(a,123),RD(b,123))};_.Fb=function $ud(a){return this===a};_.Oe=function _ud(){return new Frb(this)};sfb(uHe,'ElkGraphAdapters/PortComparator',1285);var r7=ufb(vHe,'EObject');var C4=ufb(wHe,xHe);var D4=ufb(wHe,yHe);var H4=ufb(wHe,zHe);var L4=ufb(wHe,'ElkShape');var E4=ufb(wHe,AHe);var G4=ufb(wHe,BHe);var F4=ufb(wHe,CHe);var p7=ufb(vHe,DHe);var n7=ufb(vHe,'EFactory');var avd;var q7=ufb(vHe,EHe);var t7=ufb(vHe,'EPackage');var cvd;var evd,fvd,gvd,hvd,ivd,jvd,kvd,lvd,mvd,nvd,ovd;var I4=ufb(wHe,FHe);var J4=ufb(wHe,GHe);var K4=ufb(wHe,HHe);feb(93,1,IHe);_.th=function rvd(){this.uh();return null};_.uh=function svd(){return null};_.vh=function tvd(){return this.uh(),false};_.wh=function uvd(){return false};_.xh=function vvd(a){qvd(this,a);};sfb(JHe,'BasicNotifierImpl',93);feb(99,93,RHe);_.Yh=function Dwd(){return Mvd(this)};_.yh=function bwd(a,b){return a};_.zh=function cwd(){throw Adb(new jib)};_.Ah=function dwd(a){var b;return b=Z5d(RD(vYd(this.Dh(),this.Fh()),19)),this.Ph().Th(this,b.n,b.f,a)};_.Bh=function ewd(a,b){throw Adb(new jib)};_.Ch=function fwd(a,b,c){return xvd(this,a,b,c)};_.Dh=function gwd(){var a;if(this.zh()){a=this.zh().Nk();if(a){return a}}return this.ii()};_.Eh=function hwd(){return yvd(this)};_.Fh=function iwd(){throw Adb(new jib)};_.Gh=function kwd(){var a,b;b=this.$h().Ok();!b&&this.zh().Tk(b=(N2d(),a=P$d(rYd(this.Dh())),a==null?M2d:new Q2d(this,a)));return b};_.Hh=function mwd(a,b){return a};_.Ih=function nwd(a){var b;b=a.pk();return !b?BYd(this.Dh(),a):a.Lj()};_.Jh=function owd(){var a;a=this.zh();return !a?null:a.Qk()};_.Kh=function pwd(){return !this.zh()?null:this.zh().Nk()};_.Lh=function qwd(a,b,c){return Dvd(this,a,b,c)};_.Mh=function rwd(a){return Evd(this,a)};_.Nh=function swd(a,b){return Fvd(this,a,b)};_.Oh=function twd(){var a;a=this.zh();return !!a&&a.Rk()};_.Ph=function uwd(){throw Adb(new jib)};_.Qh=function vwd(){return Hvd(this)};_.Rh=function wwd(a,b,c,d){return Ivd(this,a,b,d)};_.Sh=function xwd(a,b,c){var d;return d=RD(vYd(this.Dh(),b),69),d.wk().zk(this,this.hi(),b-this.ji(),a,c)};_.Th=function ywd(a,b,c,d){return Jvd(this,a,b,d)};_.Uh=function zwd(a,b,c){var d;return d=RD(vYd(this.Dh(),b),69),d.wk().Ak(this,this.hi(),b-this.ji(),a,c)};_.Vh=function Awd(){return !!this.zh()&&!!this.zh().Pk()};_.Wh=function Bwd(a){return Kvd(this,a)};_.Xh=function Cwd(a){return Lvd(this,a)};_.Zh=function Ewd(a){return Pvd(this,a)};_.$h=function Fwd(){throw Adb(new jib)};_._h=function Gwd(){return !this.zh()?null:this.zh().Pk()};_.ai=function Hwd(){return Hvd(this)};_.bi=function Iwd(a,b){Wvd(this,a,b);};_.ci=function Jwd(a){this.$h().Sk(a);};_.di=function Kwd(a){this.$h().Vk(a);};_.ei=function Lwd(a){this.$h().Uk(a);};_.fi=function Mwd(a,b){var c,d,e,f;f=this.Jh();if(!!f&&!!a){b=rLd(f.El(),this,b);f.Il(this);}d=this.Ph();if(d){if((jwd(this,this.Ph(),this.Fh()).Bb&txe)!=0){e=d.Qh();!!e&&(!a?e.Hl(this):!f&&e.Il(this));}else {b=(c=this.Fh(),c>=0?this.Ah(b):this.Ph().Th(this,-1-c,null,b));b=this.Ch(null,-1,b);}}this.di(a);return b};_.gi=function Nwd(a){var b,c,d,e,f,g,h,i;c=this.Dh();f=BYd(c,a);b=this.ji();if(f>=b){return RD(a,69).wk().Dk(this,this.hi(),f-b)}else if(f<=-1){g=Eee((lke(),jke),c,a);if(g){nke();RD(g,69).xk()||(g=zfe(Qee(jke,g)));e=(d=this.Ih(g),RD(d>=0?this.Lh(d,true,true):Qvd(this,g,true),160));i=g.Ik();if(i>1||i==-1){return RD(RD(e,220).Sl(a,false),79)}}else {throw Adb(new agb(KHe+a.xe()+NHe))}}else if(a.Jk()){return d=this.Ih(a),RD(d>=0?this.Lh(d,false,true):Qvd(this,a,false),79)}h=new NTd(this,a);return h};_.hi=function Owd(){return Yvd(this)};_.ii=function Pwd(){return (lTd(),kTd).S};_.ji=function Qwd(){return AYd(this.ii())};_.ki=function Rwd(a){$vd(this,a);};_.Ib=function Swd(){return awd(this)};sfb(SHe,'BasicEObjectImpl',99);var ZSd;feb(119,99,{110:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1});_.li=function _wd(a){var b;b=Vwd(this);return b[a]};_.mi=function axd(a,b){var c;c=Vwd(this);bD(c,a,b);};_.ni=function bxd(a){var b;b=Vwd(this);bD(b,a,null);};_.th=function cxd(){return RD(Ywd(this,4),129)};_.uh=function dxd(){throw Adb(new jib)};_.vh=function exd(){return (this.Db&4)!=0};_.zh=function fxd(){throw Adb(new jib)};_.oi=function gxd(a){$wd(this,2,a);};_.Bh=function hxd(a,b){this.Db=b<<16|this.Db&255;this.oi(a);};_.Dh=function ixd(){return Uwd(this)};_.Fh=function jxd(){return this.Db>>16};_.Gh=function kxd(){var a,b;return N2d(),b=P$d(rYd((a=RD(Ywd(this,16),29),!a?this.ii():a))),b==null?(M2d):new Q2d(this,b)};_.wh=function lxd(){return (this.Db&1)==0};_.Jh=function mxd(){return RD(Ywd(this,128),2034)};_.Kh=function nxd(){return RD(Ywd(this,16),29)};_.Oh=function oxd(){return (this.Db&32)!=0};_.Ph=function pxd(){return RD(Ywd(this,2),54)};_.Vh=function qxd(){return (this.Db&64)!=0};_.$h=function rxd(){throw Adb(new jib)};_._h=function sxd(){return RD(Ywd(this,64),288)};_.ci=function txd(a){$wd(this,16,a);};_.di=function uxd(a){$wd(this,128,a);};_.ei=function vxd(a){$wd(this,64,a);};_.hi=function wxd(){return Wwd(this)};_.Db=0;sfb(SHe,'MinimalEObjectImpl',119);feb(120,119,{110:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.oi=function xxd(a){this.Cb=a;};_.Ph=function yxd(){return this.Cb};sfb(SHe,'MinimalEObjectImpl/Container',120);feb(2083,120,{110:1,342:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function Jxd(a,b,c){return Axd(this,a,b,c)};_.Uh=function Kxd(a,b,c){return Bxd(this,a,b,c)};_.Wh=function Lxd(a){return Cxd(this,a)};_.bi=function Mxd(a,b){Dxd(this,a,b);};_.ii=function Nxd(){return pvd(),ovd};_.ki=function Oxd(a){Exd(this,a);};_.nf=function Pxd(){return Fxd(this)};_.gh=function Qxd(){return !this.o&&(this.o=new DVd((pvd(),mvd),X4,this,0)),this.o};_.of=function Rxd(a){return Gxd(this,a)};_.pf=function Sxd(a){return Hxd(this,a)};_.qf=function Txd(a,b){return Ixd(this,a,b)};sfb(THe,'EMapPropertyHolderImpl',2083);feb(572,120,{110:1,377:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},Xxd);_.Lh=function Yxd(a,b,c){switch(a){case 0:return this.a;case 1:return this.b;}return Dvd(this,a,b,c)};_.Wh=function Zxd(a){switch(a){case 0:return this.a!=0;case 1:return this.b!=0;}return Kvd(this,a)};_.bi=function $xd(a,b){switch(a){case 0:Vxd(this,Kfb(UD(b)));return;case 1:Wxd(this,Kfb(UD(b)));return;}Wvd(this,a,b);};_.ii=function _xd(){return pvd(),evd};_.ki=function ayd(a){switch(a){case 0:Vxd(this,0);return;case 1:Wxd(this,0);return;}$vd(this,a);};_.Ib=function byd(){var a;if((this.Db&64)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (x: ';Khb(a,this.a);a.a+=', y: ';Khb(a,this.b);a.a+=')';return a.a};_.a=0;_.b=0;sfb(THe,'ElkBendPointImpl',572);feb(739,2083,{110:1,342:1,167:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function lyd(a,b,c){return cyd(this,a,b,c)};_.Sh=function myd(a,b,c){return dyd(this,a,b,c)};_.Uh=function nyd(a,b,c){return eyd(this,a,b,c)};_.Wh=function oyd(a){return fyd(this,a)};_.bi=function pyd(a,b){gyd(this,a,b);};_.ii=function qyd(){return pvd(),ivd};_.ki=function ryd(a){hyd(this,a);};_.jh=function syd(){return this.k};_.kh=function tyd(){return iyd(this)};_.Ib=function uyd(){return kyd(this)};_.k=null;sfb(THe,'ElkGraphElementImpl',739);feb(740,739,{110:1,342:1,167:1,422:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function Gyd(a,b,c){return vyd(this,a,b,c)};_.Wh=function Hyd(a){return wyd(this,a)};_.bi=function Iyd(a,b){xyd(this,a,b);};_.ii=function Jyd(){return pvd(),nvd};_.ki=function Kyd(a){yyd(this,a);};_.lh=function Lyd(){return this.f};_.mh=function Myd(){return this.g};_.nh=function Nyd(){return this.i};_.oh=function Oyd(){return this.j};_.ph=function Pyd(a,b){zyd(this,a,b);};_.qh=function Qyd(a,b){Byd(this,a,b);};_.rh=function Ryd(a){Dyd(this,a);};_.sh=function Syd(a){Eyd(this,a);};_.Ib=function Tyd(){return Fyd(this)};_.f=0;_.g=0;_.i=0;_.j=0;sfb(THe,'ElkShapeImpl',740);feb(741,740,{110:1,342:1,84:1,167:1,422:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function _yd(a,b,c){return Uyd(this,a,b,c)};_.Sh=function azd(a,b,c){return Vyd(this,a,b,c)};_.Uh=function bzd(a,b,c){return Wyd(this,a,b,c)};_.Wh=function czd(a){return Xyd(this,a)};_.bi=function dzd(a,b){Yyd(this,a,b);};_.ii=function ezd(){return pvd(),fvd};_.ki=function fzd(a){Zyd(this,a);};_.hh=function gzd(){return !this.d&&(this.d=new Yie(G4,this,8,5)),this.d};_.ih=function hzd(){return !this.e&&(this.e=new Yie(G4,this,7,4)),this.e};sfb(THe,'ElkConnectableShapeImpl',741);feb(326,739,{110:1,342:1,74:1,167:1,326:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},rzd);_.Ah=function szd(a){return jzd(this,a)};_.Lh=function tzd(a,b,c){switch(a){case 3:return kzd(this);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),this.b;case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),this.c;case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),this.a;case 7:return Geb(),!this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i<=1&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i<=1)?false:true;case 8:return Geb(),nzd(this)?true:false;case 9:return Geb(),ozd(this)?true:false;case 10:return Geb(),!this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i!=0)?true:false;}return cyd(this,a,b,c)};_.Sh=function uzd(a,b,c){var d;switch(b){case 3:!!this.Cb&&(c=(d=this.Db>>16,d>=0?jzd(this,c):this.Cb.Th(this,-1-d,null,c)));return izd(this,RD(a,27),c);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),qLd(this.b,a,c);case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),qLd(this.c,a,c);case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),qLd(this.a,a,c);}return dyd(this,a,b,c)};_.Uh=function vzd(a,b,c){switch(b){case 3:return izd(this,null,c);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),rLd(this.b,a,c);case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),rLd(this.c,a,c);case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),rLd(this.a,a,c);}return eyd(this,a,b,c)};_.Wh=function wzd(a){switch(a){case 3:return !!kzd(this);case 4:return !!this.b&&this.b.i!=0;case 5:return !!this.c&&this.c.i!=0;case 6:return !!this.a&&this.a.i!=0;case 7:return !this.b&&(this.b=new Yie(E4,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i<=1));case 8:return nzd(this);case 9:return ozd(this);case 10:return !this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i!=0);}return fyd(this,a)};_.bi=function xzd(a,b){switch(a){case 3:pzd(this,RD(b,27));return;case 4:!this.b&&(this.b=new Yie(E4,this,4,7));sLd(this.b);!this.b&&(this.b=new Yie(E4,this,4,7));YGd(this.b,RD(b,16));return;case 5:!this.c&&(this.c=new Yie(E4,this,5,8));sLd(this.c);!this.c&&(this.c=new Yie(E4,this,5,8));YGd(this.c,RD(b,16));return;case 6:!this.a&&(this.a=new C5d(F4,this,6,6));sLd(this.a);!this.a&&(this.a=new C5d(F4,this,6,6));YGd(this.a,RD(b,16));return;}gyd(this,a,b);};_.ii=function yzd(){return pvd(),gvd};_.ki=function zzd(a){switch(a){case 3:pzd(this,null);return;case 4:!this.b&&(this.b=new Yie(E4,this,4,7));sLd(this.b);return;case 5:!this.c&&(this.c=new Yie(E4,this,5,8));sLd(this.c);return;case 6:!this.a&&(this.a=new C5d(F4,this,6,6));sLd(this.a);return;}hyd(this,a);};_.Ib=function Azd(){return qzd(this)};sfb(THe,'ElkEdgeImpl',326);feb(452,2083,{110:1,342:1,166:1,452:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},Rzd);_.Ah=function Szd(a){return Czd(this,a)};_.Lh=function Tzd(a,b,c){switch(a){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return !this.a&&(this.a=new XZd(D4,this,5)),this.a;case 6:return Fzd(this);case 7:if(b)return Ezd(this);return this.i;case 8:if(b)return Dzd(this);return this.f;case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),this.g;case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),this.e;case 11:return this.d;}return Axd(this,a,b,c)};_.Sh=function Uzd(a,b,c){var d,e,f;switch(b){case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?Czd(this,c):this.Cb.Th(this,-1-e,null,c)));return Bzd(this,RD(a,74),c);case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),qLd(this.g,a,c);case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),qLd(this.e,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(pvd(),hvd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((pvd(),hvd)),a,c)};_.Uh=function Vzd(a,b,c){switch(b){case 5:return !this.a&&(this.a=new XZd(D4,this,5)),rLd(this.a,a,c);case 6:return Bzd(this,null,c);case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),rLd(this.g,a,c);case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),rLd(this.e,a,c);}return Bxd(this,a,b,c)};_.Wh=function Wzd(a){switch(a){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return !!this.a&&this.a.i!=0;case 6:return !!Fzd(this);case 7:return !!this.i;case 8:return !!this.f;case 9:return !!this.g&&this.g.i!=0;case 10:return !!this.e&&this.e.i!=0;case 11:return this.d!=null;}return Cxd(this,a)};_.bi=function Xzd(a,b){switch(a){case 1:Ozd(this,Kfb(UD(b)));return;case 2:Pzd(this,Kfb(UD(b)));return;case 3:Hzd(this,Kfb(UD(b)));return;case 4:Izd(this,Kfb(UD(b)));return;case 5:!this.a&&(this.a=new XZd(D4,this,5));sLd(this.a);!this.a&&(this.a=new XZd(D4,this,5));YGd(this.a,RD(b,16));return;case 6:Mzd(this,RD(b,74));return;case 7:Lzd(this,RD(b,84));return;case 8:Kzd(this,RD(b,84));return;case 9:!this.g&&(this.g=new Yie(F4,this,9,10));sLd(this.g);!this.g&&(this.g=new Yie(F4,this,9,10));YGd(this.g,RD(b,16));return;case 10:!this.e&&(this.e=new Yie(F4,this,10,9));sLd(this.e);!this.e&&(this.e=new Yie(F4,this,10,9));YGd(this.e,RD(b,16));return;case 11:Jzd(this,WD(b));return;}Dxd(this,a,b);};_.ii=function Yzd(){return pvd(),hvd};_.ki=function Zzd(a){switch(a){case 1:Ozd(this,0);return;case 2:Pzd(this,0);return;case 3:Hzd(this,0);return;case 4:Izd(this,0);return;case 5:!this.a&&(this.a=new XZd(D4,this,5));sLd(this.a);return;case 6:Mzd(this,null);return;case 7:Lzd(this,null);return;case 8:Kzd(this,null);return;case 9:!this.g&&(this.g=new Yie(F4,this,9,10));sLd(this.g);return;case 10:!this.e&&(this.e=new Yie(F4,this,10,9));sLd(this.e);return;case 11:Jzd(this,null);return;}Exd(this,a);};_.Ib=function $zd(){return Qzd(this)};_.b=0;_.c=0;_.d=null;_.j=0;_.k=0;sfb(THe,'ElkEdgeSectionImpl',452);feb(158,120,{110:1,94:1,93:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1});_.Lh=function cAd(a,b,c){var d;if(a==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function dAd(a,b,c){var d,e;if(b==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c)}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function eAd(a,b,c){var d,e;if(b==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c)}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function fAd(a){var b;if(a==0){return !!this.Ab&&this.Ab.i!=0}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.Zh=function gAd(a){return _zd(this,a)};_.bi=function hAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.di=function iAd(a){$wd(this,128,a);};_.ii=function jAd(){return JTd(),xTd};_.ki=function kAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function lAd(){this.Bb|=1;};_.qi=function mAd(a){return bAd(this,a)};_.Bb=0;sfb(SHe,'EModelElementImpl',158);feb(720,158,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1},yAd);_.ri=function zAd(a,b){return tAd(this,a,b)};_.si=function AAd(a){var b,c,d,e,f;if(this.a!=BXd(a)||(a.Bb&256)!=0){throw Adb(new agb(ZHe+a.zb+WHe))}for(d=zYd(a);tYd(d.a).i!=0;){c=RD(N_d(d,0,(b=RD(QHd(tYd(d.a),0),89),f=b.c,ZD(f,90)?RD(f,29):(JTd(),zTd))),29);if(DXd(c)){e=BXd(c).wi().si(c);RD(e,54).ci(a);return e}d=zYd(c);}return (a.D!=null?a.D:a.B)=='java.util.Map$Entry'?new LUd(a):new zUd(a)};_.ti=function BAd(a,b){return uAd(this,a,b)};_.Lh=function CAd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.a;}return zvd(this,a-AYd((JTd(),uTd)),vYd((d=RD(Ywd(this,16),29),!d?uTd:d),a),b,c)};_.Sh=function DAd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 1:!!this.a&&(c=RD(this.a,54).Th(this,4,t7,c));return rAd(this,RD(a,241),c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),uTd):d),b),69),e.wk().zk(this,Wwd(this),b-AYd((JTd(),uTd)),a,c)};_.Uh=function EAd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 1:return rAd(this,null,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),uTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),uTd)),a,c)};_.Wh=function FAd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return !!this.a;}return Avd(this,a-AYd((JTd(),uTd)),vYd((b=RD(Ywd(this,16),29),!b?uTd:b),a))};_.bi=function GAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:wAd(this,RD(b,241));return;}Bvd(this,a-AYd((JTd(),uTd)),vYd((c=RD(Ywd(this,16),29),!c?uTd:c),a),b);};_.ii=function HAd(){return JTd(),uTd};_.ki=function IAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:wAd(this,null);return;}Cvd(this,a-AYd((JTd(),uTd)),vYd((b=RD(Ywd(this,16),29),!b?uTd:b),a));};var nAd,oAd,pAd;sfb(SHe,'EFactoryImpl',720);feb(1037,720,{110:1,2113:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1},KAd);_.ri=function LAd(a,b){switch(a.hk()){case 12:return RD(b,149).Pg();case 13:return jeb(b);default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function MAd(a){var b,c,d,e,f,g,h,i;switch(a.G==-1&&(a.G=(b=BXd(a),b?fZd(b.vi(),a):-1)),a.G){case 4:return f=new hCd,f;case 6:return g=new ACd,g;case 7:return h=new PCd,h;case 8:return d=new rzd,d;case 9:return c=new Xxd,c;case 10:return e=new Rzd,e;case 11:return i=new _Cd,i;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function NAd(a,b){switch(a.hk()){case 13:case 12:return null;default:throw Adb(new agb(VHe+a.xe()+WHe));}};sfb(THe,'ElkGraphFactoryImpl',1037);feb(448,158,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1});_.Gh=function RAd(){var a,b;b=(a=RD(Ywd(this,16),29),P$d(rYd(!a?this.ii():a)));return b==null?(N2d(),N2d(),M2d):new e3d(this,b)};_.Lh=function SAd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.xe();}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Wh=function TAd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function UAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:this.ui(WD(b));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function VAd(){return JTd(),yTd};_.ki=function WAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:this.ui(null);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.xe=function XAd(){return this.zb};_.ui=function YAd(a){PAd(this,a);};_.Ib=function ZAd(){return QAd(this)};_.zb=null;sfb(SHe,'ENamedElementImpl',448);feb(184,448,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1},EBd);_.Ah=function GBd(a){return qBd(this,a)};_.Lh=function HBd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),this.rb;case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),this.vb;case 7:if(b)return this.Db>>16==7?RD(this.Cb,241):null;return gBd(this);}return zvd(this,a-AYd((JTd(),CTd)),vYd((d=RD(Ywd(this,16),29),!d?CTd:d),a),b,c)};_.Sh=function IBd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 4:!!this.sb&&(c=RD(this.sb,54).Th(this,1,n7,c));return hBd(this,RD(a,480),c);case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),qLd(this.rb,a,c);case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),qLd(this.vb,a,c);case 7:!!this.Cb&&(c=(e=this.Db>>16,e>=0?qBd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,7,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),CTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),CTd)),a,c)};_.Uh=function JBd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 4:return hBd(this,null,c);case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),rLd(this.rb,a,c);case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),rLd(this.vb,a,c);case 7:return xvd(this,null,7,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),CTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),CTd)),a,c)};_.Wh=function KBd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return !!this.sb;case 5:return !!this.rb&&this.rb.i!=0;case 6:return !!this.vb&&this.vb.i!=0;case 7:return !!gBd(this);}return Avd(this,a-AYd((JTd(),CTd)),vYd((b=RD(Ywd(this,16),29),!b?CTd:b),a))};_.Zh=function LBd(a){var b;b=sBd(this,a);return b?b:_zd(this,a)};_.bi=function MBd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:DBd(this,WD(b));return;case 3:CBd(this,WD(b));return;case 4:BBd(this,RD(b,480));return;case 5:!this.rb&&(this.rb=new J5d(this,i7,this));sLd(this.rb);!this.rb&&(this.rb=new J5d(this,i7,this));YGd(this.rb,RD(b,16));return;case 6:!this.vb&&(this.vb=new G5d(t7,this,6,7));sLd(this.vb);!this.vb&&(this.vb=new G5d(t7,this,6,7));YGd(this.vb,RD(b,16));return;}Bvd(this,a-AYd((JTd(),CTd)),vYd((c=RD(Ywd(this,16),29),!c?CTd:c),a),b);};_.ei=function NBd(a){var b,c;if(!!a&&!!this.rb){for(c=new dMd(this.rb);c.e!=c.i.gc();){b=bMd(c);ZD(b,364)&&(RD(b,364).w=null);}}$wd(this,64,a);};_.ii=function OBd(){return JTd(),CTd};_.ki=function PBd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:DBd(this,null);return;case 3:CBd(this,null);return;case 4:BBd(this,null);return;case 5:!this.rb&&(this.rb=new J5d(this,i7,this));sLd(this.rb);return;case 6:!this.vb&&(this.vb=new G5d(t7,this,6,7));sLd(this.vb);return;}Cvd(this,a-AYd((JTd(),CTd)),vYd((b=RD(Ywd(this,16),29),!b?CTd:b),a));};_.pi=function QBd(){rBd(this);};_.vi=function RBd(){return !this.rb&&(this.rb=new J5d(this,i7,this)),this.rb};_.wi=function SBd(){return this.sb};_.xi=function TBd(){return this.ub};_.yi=function UBd(){return this.xb};_.zi=function VBd(){return this.yb};_.Ai=function WBd(a){this.ub=a;};_.Ib=function XBd(){var a;if((this.Db&64)!=0)return QAd(this);a=new Shb(QAd(this));a.a+=' (nsURI: ';Nhb(a,this.yb);a.a+=', nsPrefix: ';Nhb(a,this.xb);a.a+=')';return a.a};_.xb=null;_.yb=null;sfb(SHe,'EPackageImpl',184);feb(569,184,{110:1,2115:1,569:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1},_Bd);_.q=false;_.r=false;var YBd=false;sfb(THe,'ElkGraphPackageImpl',569);feb(366,740,{110:1,342:1,167:1,135:1,422:1,366:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},hCd);_.Ah=function iCd(a){return cCd(this,a)};_.Lh=function jCd(a,b,c){switch(a){case 7:return dCd(this);case 8:return this.a;}return vyd(this,a,b,c)};_.Sh=function kCd(a,b,c){var d;switch(b){case 7:!!this.Cb&&(c=(d=this.Db>>16,d>=0?cCd(this,c):this.Cb.Th(this,-1-d,null,c)));return bCd(this,RD(a,167),c);}return dyd(this,a,b,c)};_.Uh=function lCd(a,b,c){if(b==7){return bCd(this,null,c)}return eyd(this,a,b,c)};_.Wh=function mCd(a){switch(a){case 7:return !!dCd(this);case 8:return !lhb('',this.a);}return wyd(this,a)};_.bi=function nCd(a,b){switch(a){case 7:eCd(this,RD(b,167));return;case 8:fCd(this,WD(b));return;}xyd(this,a,b);};_.ii=function oCd(){return pvd(),jvd};_.ki=function pCd(a){switch(a){case 7:eCd(this,null);return;case 8:fCd(this,'');return;}yyd(this,a);};_.Ib=function qCd(){return gCd(this)};_.a='';sfb(THe,'ElkLabelImpl',366);feb(207,741,{110:1,342:1,84:1,167:1,27:1,422:1,207:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},ACd);_.Ah=function BCd(a){return sCd(this,a)};_.Lh=function CCd(a,b,c){switch(a){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),this.c;case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),this.a;case 11:return vCd(this);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),this.b;case 13:return Geb(),!this.a&&(this.a=new C5d(J4,this,10,11)),this.a.i>0?true:false;}return Uyd(this,a,b,c)};_.Sh=function DCd(a,b,c){var d;switch(b){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),qLd(this.c,a,c);case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),qLd(this.a,a,c);case 11:!!this.Cb&&(c=(d=this.Db>>16,d>=0?sCd(this,c):this.Cb.Th(this,-1-d,null,c)));return rCd(this,RD(a,27),c);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),qLd(this.b,a,c);}return Vyd(this,a,b,c)};_.Uh=function ECd(a,b,c){switch(b){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),rLd(this.c,a,c);case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),rLd(this.a,a,c);case 11:return rCd(this,null,c);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),rLd(this.b,a,c);}return Wyd(this,a,b,c)};_.Wh=function FCd(a){switch(a){case 9:return !!this.c&&this.c.i!=0;case 10:return !!this.a&&this.a.i!=0;case 11:return !!vCd(this);case 12:return !!this.b&&this.b.i!=0;case 13:return !this.a&&(this.a=new C5d(J4,this,10,11)),this.a.i>0;}return Xyd(this,a)};_.bi=function GCd(a,b){switch(a){case 9:!this.c&&(this.c=new C5d(K4,this,9,9));sLd(this.c);!this.c&&(this.c=new C5d(K4,this,9,9));YGd(this.c,RD(b,16));return;case 10:!this.a&&(this.a=new C5d(J4,this,10,11));sLd(this.a);!this.a&&(this.a=new C5d(J4,this,10,11));YGd(this.a,RD(b,16));return;case 11:yCd(this,RD(b,27));return;case 12:!this.b&&(this.b=new C5d(G4,this,12,3));sLd(this.b);!this.b&&(this.b=new C5d(G4,this,12,3));YGd(this.b,RD(b,16));return;}Yyd(this,a,b);};_.ii=function HCd(){return pvd(),kvd};_.ki=function ICd(a){switch(a){case 9:!this.c&&(this.c=new C5d(K4,this,9,9));sLd(this.c);return;case 10:!this.a&&(this.a=new C5d(J4,this,10,11));sLd(this.a);return;case 11:yCd(this,null);return;case 12:!this.b&&(this.b=new C5d(G4,this,12,3));sLd(this.b);return;}Zyd(this,a);};_.Ib=function JCd(){return zCd(this)};sfb(THe,'ElkNodeImpl',207);feb(193,741,{110:1,342:1,84:1,167:1,123:1,422:1,193:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},PCd);_.Ah=function QCd(a){return LCd(this,a)};_.Lh=function RCd(a,b,c){if(a==9){return MCd(this)}return Uyd(this,a,b,c)};_.Sh=function SCd(a,b,c){var d;switch(b){case 9:!!this.Cb&&(c=(d=this.Db>>16,d>=0?LCd(this,c):this.Cb.Th(this,-1-d,null,c)));return KCd(this,RD(a,27),c);}return Vyd(this,a,b,c)};_.Uh=function TCd(a,b,c){if(b==9){return KCd(this,null,c)}return Wyd(this,a,b,c)};_.Wh=function UCd(a){if(a==9){return !!MCd(this)}return Xyd(this,a)};_.bi=function VCd(a,b){switch(a){case 9:NCd(this,RD(b,27));return;}Yyd(this,a,b);};_.ii=function WCd(){return pvd(),lvd};_.ki=function XCd(a){switch(a){case 9:NCd(this,null);return;}Zyd(this,a);};_.Ib=function YCd(){return OCd(this)};sfb(THe,'ElkPortImpl',193);var O6=ufb(sIe,'BasicEMap/Entry');feb(1122,120,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1,119:1,120:1},_Cd);_.Fb=function fDd(a){return this===a};_.ld=function hDd(){return this.b};_.Hb=function jDd(){return kFb(this)};_.Di=function lDd(a){ZCd(this,RD(a,149));};_.Lh=function aDd(a,b,c){switch(a){case 0:return this.b;case 1:return this.c;}return Dvd(this,a,b,c)};_.Wh=function bDd(a){switch(a){case 0:return !!this.b;case 1:return this.c!=null;}return Kvd(this,a)};_.bi=function cDd(a,b){switch(a){case 0:ZCd(this,RD(b,149));return;case 1:$Cd(this,b);return;}Wvd(this,a,b);};_.ii=function dDd(){return pvd(),mvd};_.ki=function eDd(a){switch(a){case 0:ZCd(this,null);return;case 1:$Cd(this,null);return;}$vd(this,a);};_.Bi=function gDd(){var a;if(this.a==-1){a=this.b;this.a=!a?0:tb(a);}return this.a};_.md=function iDd(){return this.c};_.Ci=function kDd(a){this.a=a;};_.nd=function mDd(a){var b;b=this.c;$Cd(this,a);return b};_.Ib=function nDd(){var a;if((this.Db&64)!=0)return awd(this);a=new bib;Zhb(Zhb(Zhb(a,this.b?this.b.Pg():vve),SAe),Ghb(this.c));return a.a};_.a=-1;_.c=null;var X4=sfb(THe,'ElkPropertyToValueMapEntryImpl',1122);feb(996,1,{},BDd);sfb(vIe,'JsonAdapter',996);feb(216,63,swe,CDd);sfb(vIe,'JsonImportException',216);feb(868,1,{},IEd);sfb(vIe,'JsonImporter',868);feb(903,1,{},JEd);sfb(vIe,'JsonImporter/lambda$0$Type',903);feb(904,1,{},KEd);sfb(vIe,'JsonImporter/lambda$1$Type',904);feb(912,1,{},LEd);sfb(vIe,'JsonImporter/lambda$10$Type',912);feb(914,1,{},MEd);sfb(vIe,'JsonImporter/lambda$11$Type',914);feb(915,1,{},NEd);sfb(vIe,'JsonImporter/lambda$12$Type',915);feb(921,1,{},OEd);sfb(vIe,'JsonImporter/lambda$13$Type',921);feb(920,1,{},PEd);sfb(vIe,'JsonImporter/lambda$14$Type',920);feb(916,1,{},QEd);sfb(vIe,'JsonImporter/lambda$15$Type',916);feb(917,1,{},REd);sfb(vIe,'JsonImporter/lambda$16$Type',917);feb(918,1,{},SEd);sfb(vIe,'JsonImporter/lambda$17$Type',918);feb(919,1,{},TEd);sfb(vIe,'JsonImporter/lambda$18$Type',919);feb(924,1,{},UEd);sfb(vIe,'JsonImporter/lambda$19$Type',924);feb(905,1,{},VEd);sfb(vIe,'JsonImporter/lambda$2$Type',905);feb(922,1,{},WEd);sfb(vIe,'JsonImporter/lambda$20$Type',922);feb(923,1,{},XEd);sfb(vIe,'JsonImporter/lambda$21$Type',923);feb(927,1,{},YEd);sfb(vIe,'JsonImporter/lambda$22$Type',927);feb(925,1,{},ZEd);sfb(vIe,'JsonImporter/lambda$23$Type',925);feb(926,1,{},$Ed);sfb(vIe,'JsonImporter/lambda$24$Type',926);feb(929,1,{},_Ed);sfb(vIe,'JsonImporter/lambda$25$Type',929);feb(928,1,{},aFd);sfb(vIe,'JsonImporter/lambda$26$Type',928);feb(930,1,Qve,bFd);_.Cd=function cFd(a){_Dd(this.b,this.a,WD(a));};sfb(vIe,'JsonImporter/lambda$27$Type',930);feb(931,1,Qve,dFd);_.Cd=function eFd(a){aEd(this.b,this.a,WD(a));};sfb(vIe,'JsonImporter/lambda$28$Type',931);feb(932,1,{},fFd);sfb(vIe,'JsonImporter/lambda$29$Type',932);feb(908,1,{},gFd);sfb(vIe,'JsonImporter/lambda$3$Type',908);feb(933,1,{},hFd);sfb(vIe,'JsonImporter/lambda$30$Type',933);feb(934,1,{},iFd);sfb(vIe,'JsonImporter/lambda$31$Type',934);feb(935,1,{},jFd);sfb(vIe,'JsonImporter/lambda$32$Type',935);feb(936,1,{},kFd);sfb(vIe,'JsonImporter/lambda$33$Type',936);feb(937,1,{},lFd);sfb(vIe,'JsonImporter/lambda$34$Type',937);feb(870,1,{},nFd);sfb(vIe,'JsonImporter/lambda$35$Type',870);feb(941,1,{},pFd);sfb(vIe,'JsonImporter/lambda$36$Type',941);feb(938,1,Qve,qFd);_.Cd=function rFd(a){jEd(this.a,RD(a,377));};sfb(vIe,'JsonImporter/lambda$37$Type',938);feb(939,1,Qve,sFd);_.Cd=function tFd(a){kEd(this.a,this.b,RD(a,166));};sfb(vIe,'JsonImporter/lambda$38$Type',939);feb(940,1,Qve,uFd);_.Cd=function vFd(a){lEd(this.a,this.b,RD(a,166));};sfb(vIe,'JsonImporter/lambda$39$Type',940);feb(906,1,{},wFd);sfb(vIe,'JsonImporter/lambda$4$Type',906);feb(942,1,Qve,xFd);_.Cd=function yFd(a){mEd(this.a,RD(a,8));};sfb(vIe,'JsonImporter/lambda$40$Type',942);feb(907,1,{},zFd);sfb(vIe,'JsonImporter/lambda$5$Type',907);feb(911,1,{},AFd);sfb(vIe,'JsonImporter/lambda$6$Type',911);feb(909,1,{},BFd);sfb(vIe,'JsonImporter/lambda$7$Type',909);feb(910,1,{},CFd);sfb(vIe,'JsonImporter/lambda$8$Type',910);feb(913,1,{},DFd);sfb(vIe,'JsonImporter/lambda$9$Type',913);feb(961,1,Qve,MFd);_.Cd=function NFd(a){oDd(this.a,new OC(WD(a)));};sfb(vIe,'JsonMetaDataConverter/lambda$0$Type',961);feb(962,1,Qve,OFd);_.Cd=function PFd(a){IFd(this.a,RD(a,245));};sfb(vIe,'JsonMetaDataConverter/lambda$1$Type',962);feb(963,1,Qve,QFd);_.Cd=function RFd(a){JFd(this.a,RD(a,143));};sfb(vIe,'JsonMetaDataConverter/lambda$2$Type',963);feb(964,1,Qve,SFd);_.Cd=function TFd(a){KFd(this.a,RD(a,170));};sfb(vIe,'JsonMetaDataConverter/lambda$3$Type',964);feb(245,22,{3:1,34:1,22:1,245:1},bGd);var UFd,VFd,WFd,XFd,YFd,ZFd,$Fd,_Fd;var T5=tfb(jze,'GraphFeature',245,WI,dGd,cGd);var eGd;feb(11,1,{34:1,149:1},jGd,kGd,lGd,mGd);_.Fd=function nGd(a){return gGd(this,RD(a,149))};_.Fb=function oGd(a){return hGd(this,a)};_.Sg=function pGd(){return iGd(this)};_.Pg=function qGd(){return this.b};_.Hb=function rGd(){return ohb(this.b)};_.Ib=function sGd(){return this.b};sfb(jze,'Property',11);feb(671,1,fye,uGd);_.Ne=function vGd(a,b){return tGd(this,RD(a,96),RD(b,96))};_.Fb=function wGd(a){return this===a};_.Oe=function xGd(){return new Frb(this)};sfb(jze,'PropertyHolderComparator',671);feb(709,1,Ave,QGd);_.Nb=function RGd(a){Ztb(this,a);};_.Pb=function TGd(){return PGd(this)};_.Qb=function UGd(){$tb();};_.Ob=function SGd(){return !!this.a};sfb(KIe,'ElkGraphUtil/AncestorIterator',709);var Y6=ufb(sIe,'EList');feb(70,56,{20:1,31:1,56:1,16:1,15:1,70:1,61:1});_.bd=function hHd(a,b){VGd(this,a,b);};_.Fc=function iHd(a){return WGd(this,a)};_.cd=function jHd(a,b){return XGd(this,a,b)};_.Gc=function kHd(a){return YGd(this,a)};_.Ii=function lHd(){return new yMd(this)};_.Ji=function mHd(){return new BMd(this)};_.Ki=function nHd(a){return ZGd(this,a)};_.Li=function oHd(){return true};_.Mi=function pHd(a,b){};_.Ni=function qHd(){};_.Oi=function rHd(a,b){$Gd(this,a,b);};_.Pi=function sHd(a,b,c){};_.Qi=function tHd(a,b){};_.Ri=function uHd(a,b,c){};_.Fb=function vHd(a){return _Gd(this,a)};_.Hb=function wHd(){return cHd(this)};_.Si=function xHd(){return false};_.Kc=function yHd(){return new dMd(this)};_.ed=function zHd(){return new mMd(this)};_.fd=function AHd(a){var b;b=this.gc();if(a<0||a>b)throw Adb(new aMd(a,b));return new nMd(this,a)};_.Ui=function BHd(a,b){this.Ti(a,this.dd(b));};_.Mc=function CHd(a){return dHd(this,a)};_.Wi=function DHd(a,b){return b};_.hd=function EHd(a,b){return eHd(this,a,b)};_.Ib=function FHd(){return fHd(this)};_.Yi=function GHd(){return true};_.Zi=function HHd(a,b){return gHd(this,b)};sfb(sIe,'AbstractEList',70);feb(66,70,PIe,YHd,ZHd,$Hd);_.Ei=function _Hd(a,b){return IHd(this,a,b)};_.Fi=function aId(a){return JHd(this,a)};_.Gi=function bId(a,b){KHd(this,a,b);};_.Hi=function cId(a){LHd(this,a);};_.$i=function dId(a){return NHd(this,a)};_.$b=function eId(){OHd(this);};_.Hc=function fId(a){return PHd(this,a)};_.Xb=function gId(a){return QHd(this,a)};_._i=function hId(a){var b,c,d;++this.j;c=this.g==null?0:this.g.length;if(a>c){d=this.g;b=c+(c/2|0)+4;b=0){this.gd(b);return true}else {return false}};_.Xi=function LJd(a,b){return this.Dj(a,this.Zi(a,b))};_.gc=function MJd(){return this.Ej()};_.Pc=function NJd(){return this.Fj()};_.Qc=function OJd(a){return this.Gj(a)};_.Ib=function PJd(){return this.Hj()};sfb(sIe,'DelegatingEList',2093);feb(2094,2093,FJe);_.Ei=function XJd(a,b){return QJd(this,a,b)};_.Fi=function YJd(a){return this.Ei(this.Ej(),a)};_.Gi=function ZJd(a,b){RJd(this,a,b);};_.Hi=function $Jd(a){SJd(this,a);};_.Li=function _Jd(){return !this.Mj()};_.$b=function aKd(){VJd(this);};_.Ij=function bKd(a,b,c,d,e){return new aLd(this,a,b,c,d,e)};_.Jj=function cKd(a){qvd(this.jj(),a);};_.Kj=function dKd(){return null};_.Lj=function eKd(){return -1};_.jj=function fKd(){return null};_.Mj=function gKd(){return false};_.Nj=function hKd(a,b){return b};_.Oj=function iKd(a,b){return b};_.Pj=function jKd(){return false};_.Qj=function kKd(){return !this.Aj()};_.Ti=function lKd(a,b){var c,d;if(this.Pj()){d=this.Qj();c=bJd(this,a,b);this.Jj(this.Ij(7,sgb(b),c,a,d));return c}else {return bJd(this,a,b)}};_.gd=function mKd(a){var b,c,d,e;if(this.Pj()){c=null;d=this.Qj();b=this.Ij(4,e=cJd(this,a),null,a,d);if(this.Mj()&&!!e){c=this.Oj(e,c);if(!c){this.Jj(b);}else {c.nj(b);c.oj();}}else {if(!c){this.Jj(b);}else {c.nj(b);c.oj();}}return e}else {e=cJd(this,a);if(this.Mj()&&!!e){c=this.Oj(e,null);!!c&&c.oj();}return e}};_.Xi=function nKd(a,b){return WJd(this,a,b)};sfb(JHe,'DelegatingNotifyingListImpl',2094);feb(152,1,GJe);_.nj=function PKd(a){return oKd(this,a)};_.oj=function QKd(){pKd(this);};_.gj=function RKd(){return this.d};_.Kj=function SKd(){return null};_.Rj=function TKd(){return null};_.hj=function UKd(a){return -1};_.ij=function VKd(){return yKd(this)};_.jj=function WKd(){return null};_.kj=function XKd(){return HKd(this)};_.lj=function YKd(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o};_.Sj=function ZKd(){return false};_.mj=function $Kd(a){var b,c,d,e,f,g,h,i,j,k,l;switch(this.d){case 1:case 2:{e=a.gj();switch(e){case 1:case 2:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){this.g=a.ij();a.gj()==1&&(this.d=1);return true}}}}case 4:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){j=JKd(this);i=this.o<0?this.o<-2?-2-this.o-1:-1:this.o;g=a.lj();this.d=6;l=new ZHd(2);if(i<=g){WGd(l,this.n);WGd(l,a.kj());this.g=cD(WC(kE,1),Pwe,28,15,[this.o=i,g+1]);}else {WGd(l,a.kj());WGd(l,this.n);this.g=cD(WC(kE,1),Pwe,28,15,[this.o=g,i]);}this.n=l;j||(this.o=-2-this.o-1);return true}break}}break}case 6:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){j=JKd(this);g=a.lj();k=RD(this.g,53);d=$C(kE,Pwe,28,k.length+1,15,1);b=0;while(b>>0,b.toString(16)));d.a+=' (eventType: ';switch(this.d){case 1:{d.a+='SET';break}case 2:{d.a+='UNSET';break}case 3:{d.a+='ADD';break}case 5:{d.a+='ADD_MANY';break}case 4:{d.a+='REMOVE';break}case 6:{d.a+='REMOVE_MANY';break}case 7:{d.a+='MOVE';break}case 8:{d.a+='REMOVING_ADAPTER';break}case 9:{d.a+='RESOLVE';break}default:{Lhb(d,this.d);break}}IKd(this)&&(d.a+=', touch: true',d);d.a+=', position: ';Lhb(d,this.o<0?this.o<-2?-2-this.o-1:-1:this.o);d.a+=', notifier: ';Mhb(d,this.jj());d.a+=', feature: ';Mhb(d,this.Kj());d.a+=', oldValue: ';Mhb(d,HKd(this));d.a+=', newValue: ';if(this.d==6&&ZD(this.g,53)){c=RD(this.g,53);d.a+='[';for(a=0;a10){if(!this.b||this.c.j!=this.a){this.b=new btb(this);this.a=this.j;}return Zsb(this.b,a)}else {return PHd(this,a)}};_.Yi=function _Ld(){return true};_.a=0;sfb(sIe,'AbstractEList/1',966);feb(302,77,lxe,aMd);sfb(sIe,'AbstractEList/BasicIndexOutOfBoundsException',302);feb(37,1,Ave,dMd);_.Nb=function gMd(a){Ztb(this,a);};_.Xj=function eMd(){if(this.i.j!=this.f){throw Adb(new Jrb)}};_.Yj=function fMd(){return bMd(this)};_.Ob=function hMd(){return this.e!=this.i.gc()};_.Pb=function iMd(){return this.Yj()};_.Qb=function jMd(){cMd(this);};_.e=0;_.f=0;_.g=-1;sfb(sIe,'AbstractEList/EIterator',37);feb(286,37,Jve,mMd,nMd);_.Qb=function vMd(){cMd(this);};_.Rb=function oMd(a){kMd(this,a);};_.Zj=function pMd(){var b;try{b=this.d.Xb(--this.e);this.Xj();this.g=this.e;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.$j=function qMd(a){lMd(this,a);};_.Sb=function rMd(){return this.e!=0};_.Tb=function sMd(){return this.e};_.Ub=function tMd(){return this.Zj()};_.Vb=function uMd(){return this.e-1};_.Wb=function wMd(a){this.$j(a);};sfb(sIe,'AbstractEList/EListIterator',286);feb(355,37,Ave,yMd);_.Yj=function zMd(){return xMd(this)};_.Qb=function AMd(){throw Adb(new jib)};sfb(sIe,'AbstractEList/NonResolvingEIterator',355);feb(398,286,Jve,BMd,CMd);_.Rb=function DMd(a){throw Adb(new jib)};_.Yj=function EMd(){var b;try{b=this.c.Vi(this.e);this.Xj();this.g=this.e++;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.Zj=function FMd(){var b;try{b=this.c.Vi(--this.e);this.Xj();this.g=this.e;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.Qb=function GMd(){throw Adb(new jib)};_.Wb=function HMd(a){throw Adb(new jib)};sfb(sIe,'AbstractEList/NonResolvingEListIterator',398);feb(2080,70,JJe);_.Ei=function PMd(a,b){var c,d,e,f,g,h,i,j,k,l,m;e=b.gc();if(e!=0){j=RD(Ywd(this.a,4),129);k=j==null?0:j.length;m=k+e;d=NMd(this,m);l=k-a;l>0&&hib(j,a,d,a+e,l);i=b.Kc();for(g=0;gc)throw Adb(new aMd(a,c));return new wNd(this,a)};_.$b=function WMd(){var a,b;++this.j;a=RD(Ywd(this.a,4),129);b=a==null?0:a.length;Bde(this,null);$Gd(this,b,a);};_.Hc=function XMd(a){var b,c,d,e,f;b=RD(Ywd(this.a,4),129);if(b!=null){if(a!=null){for(d=b,e=0,f=d.length;e=c)throw Adb(new aMd(a,c));return b[a]};_.dd=function ZMd(a){var b,c,d;b=RD(Ywd(this.a,4),129);if(b!=null){if(a!=null){for(c=0,d=b.length;cc)throw Adb(new aMd(a,c));return new oNd(this,a)};_.Ti=function cNd(a,b){var c,d,e;c=MMd(this);e=c==null?0:c.length;if(a>=e)throw Adb(new veb(MIe+a+NIe+e));if(b>=e)throw Adb(new veb(OIe+b+NIe+e));d=c[b];if(a!=b){a0&&hib(a,0,b,0,c);return b};_.Qc=function iNd(a){var b,c,d;b=RD(Ywd(this.a,4),129);d=b==null?0:b.length;if(d>0){if(a.lengthd&&bD(a,d,null);return a};var JMd;sfb(sIe,'ArrayDelegatingEList',2080);feb(1051,37,Ave,jNd);_.Xj=function kNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};_.Qb=function lNd(){cMd(this);this.a=RD(Ywd(this.b.a,4),129);};sfb(sIe,'ArrayDelegatingEList/EIterator',1051);feb(722,286,Jve,nNd,oNd);_.Xj=function pNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};_.$j=function qNd(a){lMd(this,a);this.a=RD(Ywd(this.b.a,4),129);};_.Qb=function rNd(){cMd(this);this.a=RD(Ywd(this.b.a,4),129);};sfb(sIe,'ArrayDelegatingEList/EListIterator',722);feb(1052,355,Ave,sNd);_.Xj=function tNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};sfb(sIe,'ArrayDelegatingEList/NonResolvingEIterator',1052);feb(723,398,Jve,vNd,wNd);_.Xj=function xNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};sfb(sIe,'ArrayDelegatingEList/NonResolvingEListIterator',723);feb(615,302,lxe,yNd);sfb(sIe,'BasicEList/BasicIndexOutOfBoundsException',615);feb(710,66,PIe,zNd);_.bd=function ANd(a,b){throw Adb(new jib)};_.Fc=function BNd(a){throw Adb(new jib)};_.cd=function CNd(a,b){throw Adb(new jib)};_.Gc=function DNd(a){throw Adb(new jib)};_.$b=function ENd(){throw Adb(new jib)};_._i=function FNd(a){throw Adb(new jib)};_.Kc=function GNd(){return this.Ii()};_.ed=function HNd(){return this.Ji()};_.fd=function INd(a){return this.Ki(a)};_.Ti=function JNd(a,b){throw Adb(new jib)};_.Ui=function KNd(a,b){throw Adb(new jib)};_.gd=function LNd(a){throw Adb(new jib)};_.Mc=function MNd(a){throw Adb(new jib)};_.hd=function NNd(a,b){throw Adb(new jib)};sfb(sIe,'BasicEList/UnmodifiableEList',710);feb(721,1,{3:1,20:1,16:1,15:1,61:1,597:1});_.bd=function mOd(a,b){ONd(this,a,RD(b,44));};_.Fc=function nOd(a){return PNd(this,RD(a,44))};_.Jc=function vOd(a){xgb(this,a);};_.Xb=function wOd(a){return RD(QHd(this.c,a),136)};_.Ti=function FOd(a,b){return RD(this.c.Ti(a,b),44)};_.Ui=function GOd(a,b){eOd(this,a,RD(b,44));};_.Lc=function JOd(){return new SDb(null,new Swb(this,16))};_.gd=function KOd(a){return RD(this.c.gd(a),44)};_.hd=function MOd(a,b){return kOd(this,a,RD(b,44))};_.jd=function OOd(a){tvb(this,a);};_.Nc=function POd(){return new Swb(this,16)};_.Oc=function QOd(){return new SDb(null,new Swb(this,16))};_.cd=function oOd(a,b){return this.c.cd(a,b)};_.Gc=function pOd(a){return this.c.Gc(a)};_.$b=function qOd(){this.c.$b();};_.Hc=function rOd(a){return this.c.Hc(a)};_.Ic=function sOd(a){return Be(this.c,a)};_._j=function tOd(){var a,b,c;if(this.d==null){this.d=$C(D6,KJe,66,2*this.f+1,0,1);c=this.e;this.f=0;for(b=this.c.Kc();b.e!=b.i.gc();){a=RD(b.Yj(),136);UNd(this,a);}this.e=c;}};_.Fb=function uOd(a){return ZNd(this,a)};_.Hb=function xOd(){return cHd(this.c)};_.dd=function yOd(a){return this.c.dd(a)};_.ak=function zOd(){this.c=new YOd(this);};_.dc=function AOd(){return this.f==0};_.Kc=function BOd(){return this.c.Kc()};_.ed=function COd(){return this.c.ed()};_.fd=function DOd(a){return this.c.fd(a)};_.bk=function EOd(){return dOd(this)};_.ck=function HOd(a,b,c){return new ZPd(a,b,c)};_.dk=function IOd(){return new cPd};_.Mc=function LOd(a){return hOd(this,a)};_.gc=function NOd(){return this.f};_.kd=function ROd(a,b){return new Rkb(this.c,a,b)};_.Pc=function SOd(){return this.c.Pc()};_.Qc=function TOd(a){return this.c.Qc(a)};_.Ib=function UOd(){return fHd(this.c)};_.e=0;_.f=0;sfb(sIe,'BasicEMap',721);feb(1046,66,PIe,YOd);_.Mi=function ZOd(a,b){VOd(this,RD(b,136));};_.Pi=function _Od(a,b,c){var d;++(d=this,RD(b,136),d).a.e;};_.Qi=function aPd(a,b){WOd(this,RD(b,136));};_.Ri=function bPd(a,b,c){XOd(this,RD(b,136),RD(c,136));};_.Oi=function $Od(a,b){TNd(this.a);};sfb(sIe,'BasicEMap/1',1046);feb(1047,66,PIe,cPd);_.aj=function dPd(a){return $C(N6,LJe,621,a,0,1)};sfb(sIe,'BasicEMap/2',1047);feb(1048,Eve,Fve,ePd);_.$b=function fPd(){this.a.c.$b();};_.Hc=function gPd(a){return QNd(this.a,a)};_.Kc=function hPd(){return this.a.f==0?(jQd(),iQd.a):new DPd(this.a)};_.Mc=function iPd(a){var b;b=this.a.f;jOd(this.a,a);return this.a.f!=b};_.gc=function jPd(){return this.a.f};sfb(sIe,'BasicEMap/3',1048);feb(1049,31,Dve,kPd);_.$b=function lPd(){this.a.c.$b();};_.Hc=function mPd(a){return RNd(this.a,a)};_.Kc=function nPd(){return this.a.f==0?(jQd(),iQd.a):new FPd(this.a)};_.gc=function oPd(){return this.a.f};sfb(sIe,'BasicEMap/4',1049);feb(1050,Eve,Fve,qPd);_.$b=function rPd(){this.a.c.$b();};_.Hc=function sPd(a){var b,c,d,e,f,g,h,i,j;if(this.a.f>0&&ZD(a,44)){this.a._j();i=RD(a,44);h=i.ld();e=h==null?0:tb(h);f=bOd(this.a,e);b=this.a.d[f];if(b){c=RD(b.g,379);j=b.i;for(g=0;g'+this.c};_.a=0;var N6=sfb(sIe,'BasicEMap/EntryImpl',621);feb(546,1,{},hQd);sfb(sIe,'BasicEMap/View',546);var iQd;feb(783,1,{});_.Fb=function xQd(a){return Rt((yob(),vob),a)};_.Hb=function yQd(){return Cob((yob(),vob))};_.Ib=function zQd(){return Fe((yob(),vob))};sfb(sIe,'ECollections/BasicEmptyUnmodifiableEList',783);feb(1348,1,Jve,AQd);_.Nb=function CQd(a){Ztb(this,a);};_.Rb=function BQd(a){throw Adb(new jib)};_.Ob=function DQd(){return false};_.Sb=function EQd(){return false};_.Pb=function FQd(){throw Adb(new Dvb)};_.Tb=function GQd(){return 0};_.Ub=function HQd(){throw Adb(new Dvb)};_.Vb=function IQd(){return -1};_.Qb=function JQd(){throw Adb(new jib)};_.Wb=function KQd(a){throw Adb(new jib)};sfb(sIe,'ECollections/BasicEmptyUnmodifiableEList/1',1348);feb(1346,783,{20:1,16:1,15:1,61:1},LQd);_.bd=function MQd(a,b){mQd();};_.Fc=function NQd(a){return nQd()};_.cd=function OQd(a,b){return oQd()};_.Gc=function PQd(a){return pQd()};_.$b=function QQd(){qQd();};_.Hc=function RQd(a){return false};_.Ic=function SQd(a){return false};_.Jc=function TQd(a){xgb(this,a);};_.Xb=function UQd(a){return Iob((yob(),a)),null};_.dd=function VQd(a){return -1};_.dc=function WQd(){return true};_.Kc=function XQd(){return this.a};_.ed=function YQd(){return this.a};_.fd=function ZQd(a){return this.a};_.Ti=function $Qd(a,b){return rQd()};_.Ui=function _Qd(a,b){sQd();};_.Lc=function aRd(){return new SDb(null,new Swb(this,16))};_.gd=function bRd(a){return tQd()};_.Mc=function cRd(a){return uQd()};_.hd=function dRd(a,b){return vQd()};_.gc=function eRd(){return 0};_.jd=function fRd(a){tvb(this,a);};_.Nc=function gRd(){return new Swb(this,16)};_.Oc=function hRd(){return new SDb(null,new Swb(this,16))};_.kd=function iRd(a,b){return yob(),new Rkb(vob,a,b)};_.Pc=function jRd(){return De((yob(),vob))};_.Qc=function kRd(a){return yob(),Ee(vob,a)};sfb(sIe,'ECollections/EmptyUnmodifiableEList',1346);feb(1347,783,{20:1,16:1,15:1,61:1,597:1},lRd);_.bd=function mRd(a,b){mQd();};_.Fc=function nRd(a){return nQd()};_.cd=function oRd(a,b){return oQd()};_.Gc=function pRd(a){return pQd()};_.$b=function qRd(){qQd();};_.Hc=function rRd(a){return false};_.Ic=function sRd(a){return false};_.Jc=function tRd(a){xgb(this,a);};_.Xb=function uRd(a){return Iob((yob(),a)),null};_.dd=function vRd(a){return -1};_.dc=function wRd(){return true};_.Kc=function xRd(){return this.a};_.ed=function yRd(){return this.a};_.fd=function zRd(a){return this.a};_.Ti=function BRd(a,b){return rQd()};_.Ui=function CRd(a,b){sQd();};_.Lc=function DRd(){return new SDb(null,new Swb(this,16))};_.gd=function ERd(a){return tQd()};_.Mc=function FRd(a){return uQd()};_.hd=function GRd(a,b){return vQd()};_.gc=function HRd(){return 0};_.jd=function IRd(a){tvb(this,a);};_.Nc=function JRd(){return new Swb(this,16)};_.Oc=function KRd(){return new SDb(null,new Swb(this,16))};_.kd=function LRd(a,b){return yob(),new Rkb(vob,a,b)};_.Pc=function MRd(){return De((yob(),vob))};_.Qc=function NRd(a){return yob(),Ee(vob,a)};_.bk=function ARd(){return yob(),yob(),wob};sfb(sIe,'ECollections/EmptyUnmodifiableEMap',1347);var Z6=ufb(sIe,'Enumerator');var ORd;feb(288,1,{288:1},lSd);_.Fb=function pSd(a){var b;if(this===a)return true;if(!ZD(a,288))return false;b=RD(a,288);return this.f==b.f&&rSd(this.i,b.i)&&qSd(this.a,(this.f&256)!=0?(b.f&256)!=0?b.a:null:(b.f&256)!=0?null:b.a)&&qSd(this.d,b.d)&&qSd(this.g,b.g)&&qSd(this.e,b.e)&&iSd(this,b)};_.Hb=function uSd(){return this.f};_.Ib=function CSd(){return jSd(this)};_.f=0;var SRd=0,TRd=0,URd=0,VRd=0,WRd=0,XRd=0,YRd=0,ZRd=0,$Rd=0,_Rd,aSd=0,bSd=0,cSd=0,dSd=0,eSd,fSd;sfb(sIe,'URI',288);feb(1121,45,Hxe,MSd);_.zc=function NSd(a,b){return RD($jb(this,WD(a),RD(b,288)),288)};sfb(sIe,'URI/URICache',1121);feb(506,66,PIe,OSd,PSd);_.Si=function QSd(){return true};sfb(sIe,'UniqueEList',506);feb(590,63,swe,RSd);sfb(sIe,'WrappedException',590);var f7=ufb(vHe,OJe);var A7=ufb(vHe,PJe);var y7=ufb(vHe,QJe);var g7=ufb(vHe,RJe);var i7=ufb(vHe,SJe);var h7=ufb(vHe,'EClass');var k7=ufb(vHe,'EDataType');var SSd;feb(1233,45,Hxe,VSd);_.xc=function WSd(a){return bE(a)?Xjb(this,a):Wd(qtb(this.f,a))};sfb(vHe,'EDataType/Internal/ConversionDelegate/Factory/Registry/Impl',1233);var m7=ufb(vHe,'EEnum');var l7=ufb(vHe,TJe);var o7=ufb(vHe,UJe);var s7=ufb(vHe,VJe);var XSd;var u7=ufb(vHe,WJe);var v7=ufb(vHe,XJe);feb(1042,1,{},_Sd);_.Ib=function aTd(){return 'NIL'};sfb(vHe,'EStructuralFeature/Internal/DynamicValueHolder/1',1042);var bTd;feb(1041,45,Hxe,eTd);_.xc=function fTd(a){return bE(a)?Xjb(this,a):Wd(qtb(this.f,a))};sfb(vHe,'EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl',1041);var z7=ufb(vHe,YJe);var B7=ufb(vHe,'EValidator/PatternMatcher');var gTd;var iTd;var kTd;var mTd,nTd,oTd,pTd,qTd,rTd,sTd,tTd,uTd,vTd,wTd,xTd,yTd,zTd,ATd,BTd,CTd,DTd,ETd,FTd,GTd,HTd,ITd;var Jbb=ufb(ZJe,'FeatureMap/Entry');feb(545,1,{76:1},KTd);_.Lk=function LTd(){return this.a};_.md=function MTd(){return this.b};sfb(SHe,'BasicEObjectImpl/1',545);feb(1040,1,$Je,NTd);_.Fk=function OTd(a){return Fvd(this.a,this.b,a)};_.Qj=function PTd(){return Lvd(this.a,this.b)};_.Wb=function QTd(a){Xvd(this.a,this.b,a);};_.Gk=function RTd(){_vd(this.a,this.b);};sfb(SHe,'BasicEObjectImpl/4',1040);feb(2081,1,{114:1});_.Mk=function UTd(a){this.e=a==0?STd:$C(jJ,rve,1,a,5,1);};_.li=function VTd(a){return this.e[a]};_.mi=function WTd(a,b){this.e[a]=b;};_.ni=function XTd(a){this.e[a]=null;};_.Nk=function YTd(){return this.c};_.Ok=function ZTd(){throw Adb(new jib)};_.Pk=function $Td(){throw Adb(new jib)};_.Qk=function _Td(){return this.d};_.Rk=function aUd(){return this.e!=null};_.Sk=function bUd(a){this.c=a;};_.Tk=function cUd(a){throw Adb(new jib)};_.Uk=function dUd(a){throw Adb(new jib)};_.Vk=function eUd(a){this.d=a;};var STd;sfb(SHe,'BasicEObjectImpl/EPropertiesHolderBaseImpl',2081);feb(192,2081,{114:1},fUd);_.Ok=function gUd(){return this.a};_.Pk=function hUd(){return this.b};_.Tk=function iUd(a){this.a=a;};_.Uk=function jUd(a){this.b=a;};sfb(SHe,'BasicEObjectImpl/EPropertiesHolderImpl',192);feb(516,99,RHe,kUd);_.uh=function lUd(){return this.f};_.zh=function mUd(){return this.k};_.Bh=function nUd(a,b){this.g=a;this.i=b;};_.Dh=function oUd(){return (this.j&2)==0?this.ii():this.$h().Nk()};_.Fh=function pUd(){return this.i};_.wh=function qUd(){return (this.j&1)!=0};_.Ph=function rUd(){return this.g};_.Vh=function sUd(){return (this.j&4)!=0};_.$h=function tUd(){return !this.k&&(this.k=new fUd),this.k};_.ci=function uUd(a){this.$h().Sk(a);a?(this.j|=2):(this.j&=-3);};_.ei=function vUd(a){this.$h().Uk(a);a?(this.j|=4):(this.j&=-5);};_.ii=function wUd(){return (lTd(),kTd).S};_.i=0;_.j=1;sfb(SHe,'EObjectImpl',516);feb(798,516,{110:1,94:1,93:1,58:1,114:1,54:1,99:1},zUd);_.li=function AUd(a){return this.e[a]};_.mi=function BUd(a,b){this.e[a]=b;};_.ni=function CUd(a){this.e[a]=null;};_.Dh=function DUd(){return this.d};_.Ih=function EUd(a){return BYd(this.d,a)};_.Kh=function FUd(){return this.d};_.Oh=function GUd(){return this.e!=null};_.$h=function HUd(){!this.k&&(this.k=new VUd);return this.k};_.ci=function IUd(a){this.d=a;};_.hi=function JUd(){var a;if(this.e==null){a=AYd(this.d);this.e=a==0?xUd:$C(jJ,rve,1,a,5,1);}return this};_.ji=function KUd(){return 0};var xUd;sfb(SHe,'DynamicEObjectImpl',798);feb(1522,798,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1},LUd);_.Fb=function NUd(a){return this===a};_.Hb=function RUd(){return kFb(this)};_.ci=function MUd(a){this.d=a;this.b=wYd(a,'key');this.c=wYd(a,aIe);};_.Bi=function OUd(){var a;if(this.a==-1){a=Gvd(this,this.b);this.a=a==null?0:tb(a);}return this.a};_.ld=function PUd(){return Gvd(this,this.b)};_.md=function QUd(){return Gvd(this,this.c)};_.Ci=function SUd(a){this.a=a;};_.Di=function TUd(a){Xvd(this,this.b,a);};_.nd=function UUd(a){var b;b=Gvd(this,this.c);Xvd(this,this.c,a);return b};_.a=0;sfb(SHe,'DynamicEObjectImpl/BasicEMapEntry',1522);feb(1523,1,{114:1},VUd);_.Mk=function WUd(a){throw Adb(new jib)};_.li=function XUd(a){throw Adb(new jib)};_.mi=function YUd(a,b){throw Adb(new jib)};_.ni=function ZUd(a){throw Adb(new jib)};_.Nk=function $Ud(){throw Adb(new jib)};_.Ok=function _Ud(){return this.a};_.Pk=function aVd(){return this.b};_.Qk=function bVd(){return this.c};_.Rk=function cVd(){throw Adb(new jib)};_.Sk=function dVd(a){throw Adb(new jib)};_.Tk=function eVd(a){this.a=a;};_.Uk=function fVd(a){this.b=a;};_.Vk=function gVd(a){this.c=a;};sfb(SHe,'DynamicEObjectImpl/DynamicEPropertiesHolderImpl',1523);feb(519,158,{110:1,94:1,93:1,598:1,155:1,58:1,114:1,54:1,99:1,519:1,158:1,119:1,120:1},pVd);_.Ah=function qVd(a){return iVd(this,a)};_.Lh=function rVd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.d;case 2:return c?(!this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),this.b):(!this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),dOd(this.b));case 3:return kVd(this);case 4:return !this.a&&(this.a=new XZd(r7,this,4)),this.a;case 5:return !this.c&&(this.c=new zie(r7,this,5)),this.c;}return zvd(this,a-AYd((JTd(),mTd)),vYd((d=RD(Ywd(this,16),29),!d?mTd:d),a),b,c)};_.Sh=function sVd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 3:!!this.Cb&&(c=(e=this.Db>>16,e>=0?iVd(this,c):this.Cb.Th(this,-1-e,null,c)));return hVd(this,RD(a,155),c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),mTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),mTd)),a,c)};_.Uh=function tVd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 2:return !this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),BVd(this.b,a,c);case 3:return hVd(this,null,c);case 4:return !this.a&&(this.a=new XZd(r7,this,4)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),mTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),mTd)),a,c)};_.Wh=function uVd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return !!this.b&&this.b.f!=0;case 3:return !!kVd(this);case 4:return !!this.a&&this.a.i!=0;case 5:return !!this.c&&this.c.i!=0;}return Avd(this,a-AYd((JTd(),mTd)),vYd((b=RD(Ywd(this,16),29),!b?mTd:b),a))};_.bi=function vVd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:mVd(this,WD(b));return;case 2:!this.b&&(this.b=new SVd((JTd(),FTd),C8,this));CVd(this.b,b);return;case 3:lVd(this,RD(b,155));return;case 4:!this.a&&(this.a=new XZd(r7,this,4));sLd(this.a);!this.a&&(this.a=new XZd(r7,this,4));YGd(this.a,RD(b,16));return;case 5:!this.c&&(this.c=new zie(r7,this,5));sLd(this.c);!this.c&&(this.c=new zie(r7,this,5));YGd(this.c,RD(b,16));return;}Bvd(this,a-AYd((JTd(),mTd)),vYd((c=RD(Ywd(this,16),29),!c?mTd:c),a),b);};_.ii=function wVd(){return JTd(),mTd};_.ki=function xVd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:nVd(this,null);return;case 2:!this.b&&(this.b=new SVd((JTd(),FTd),C8,this));this.b.c.$b();return;case 3:lVd(this,null);return;case 4:!this.a&&(this.a=new XZd(r7,this,4));sLd(this.a);return;case 5:!this.c&&(this.c=new zie(r7,this,5));sLd(this.c);return;}Cvd(this,a-AYd((JTd(),mTd)),vYd((b=RD(Ywd(this,16),29),!b?mTd:b),a));};_.Ib=function yVd(){return oVd(this)};_.d=null;sfb(SHe,'EAnnotationImpl',519);feb(141,721,_Je,DVd);_.Gi=function EVd(a,b){zVd(this,a,RD(b,44));};_.Wk=function FVd(a,b){return AVd(this,RD(a,44),b)};_.$i=function GVd(a){return RD(RD(this.c,71).$i(a),136)};_.Ii=function HVd(){return RD(this.c,71).Ii()};_.Ji=function IVd(){return RD(this.c,71).Ji()};_.Ki=function JVd(a){return RD(this.c,71).Ki(a)};_.Xk=function KVd(a,b){return BVd(this,a,b)};_.Fk=function LVd(a){return RD(this.c,79).Fk(a)};_.ak=function MVd(){};_.Qj=function NVd(){return RD(this.c,79).Qj()};_.ck=function OVd(a,b,c){var d;d=RD(BXd(this.b).wi().si(this.b),136);d.Ci(a);d.Di(b);d.nd(c);return d};_.dk=function PVd(){return new uje(this)};_.Wb=function QVd(a){CVd(this,a);};_.Gk=function RVd(){RD(this.c,79).Gk();};sfb(ZJe,'EcoreEMap',141);feb(165,141,_Je,SVd);_._j=function TVd(){var a,b,c,d,e,f;if(this.d==null){f=$C(D6,KJe,66,2*this.f+1,0,1);for(c=this.c.Kc();c.e!=c.i.gc();){b=RD(c.Yj(),136);d=b.Bi();e=(d&lve)%f.length;a=f[e];!a&&(a=f[e]=new uje(this));a.Fc(b);}this.d=f;}};sfb(SHe,'EAnnotationImpl/1',165);feb(292,448,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,481:1,54:1,99:1,158:1,292:1,119:1,120:1});_.Lh=function eWd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),this.Jk()?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Uh=function fWd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function gWd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.Jk();case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function hWd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:this.ui(WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:this.Zk(RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function iWd(){return JTd(),HTd};_.ki=function jWd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:this.ui(null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.Zk(1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function kWd(){WVd(this);this.Bb|=1;};_.Hk=function lWd(){return WVd(this)};_.Ik=function mWd(){return this.t};_.Jk=function nWd(){var a;return a=this.t,a>1||a==-1};_.Si=function oWd(){return (this.Bb&512)!=0};_.Yk=function pWd(a,b){return ZVd(this,a,b)};_.Zk=function qWd(a){bWd(this,a);};_.Ib=function rWd(){return cWd(this)};_.s=0;_.t=1;sfb(SHe,'ETypedElementImpl',292);feb(462,292,{110:1,94:1,93:1,155:1,197:1,58:1,179:1,69:1,114:1,481:1,54:1,99:1,158:1,462:1,292:1,119:1,120:1,692:1});_.Ah=function IWd(a){return sWd(this,a)};_.Lh=function JWd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),this.Jk()?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function KWd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 17:!!this.Cb&&(c=(e=this.Db>>16,e>=0?sWd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,17,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),f.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function LWd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 17:return xvd(this,null,17,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function MWd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.Jk();case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function NWd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:this.Zk(RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function OWd(){return JTd(),GTd};_.ki=function PWd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.Zk(1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function QWd(){Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.pk=function RWd(){return this.f};_.ik=function SWd(){return tWd(this)};_.qk=function TWd(){return uWd(this)};_.uk=function UWd(){return null};_.$k=function VWd(){return this.k};_.Lj=function WWd(){return this.n};_.vk=function XWd(){return vWd(this)};_.wk=function YWd(){var a,b,c,d,e,f,g,h,i;if(!this.p){c=uWd(this);(c.i==null&&rYd(c),c.i).length;d=this.uk();!!d&&AYd(uWd(d));e=WVd(this);g=e.kk();a=!g?null:(g.i&1)!=0?g==xdb?QI:g==kE?bJ:g==jE?ZI:g==iE?VI:g==lE?eJ:g==wdb?lJ:g==gE?RI:SI:g;b=tWd(this);h=e.ik();Mje(this);(this.Bb&Ove)!=0&&(!!(f=Tee((lke(),jke),c))&&f!=this||!!(f=zfe(Qee(jke,this))))?(this.p=new Z6d(this,f)):this.Jk()?this.al()?!d?(this.Bb&bKe)!=0?!a?this.bl()?(this.p=new i7d(42,this)):(this.p=new i7d(0,this)):a==UK?(this.p=new g7d(50,O6,this)):this.bl()?(this.p=new g7d(43,a,this)):(this.p=new g7d(1,a,this)):!a?this.bl()?(this.p=new i7d(44,this)):(this.p=new i7d(2,this)):a==UK?(this.p=new g7d(41,O6,this)):this.bl()?(this.p=new g7d(45,a,this)):(this.p=new g7d(3,a,this)):(this.Bb&bKe)!=0?!a?this.bl()?(this.p=new j7d(46,this,d)):(this.p=new j7d(4,this,d)):this.bl()?(this.p=new h7d(47,a,this,d)):(this.p=new h7d(5,a,this,d)):!a?this.bl()?(this.p=new j7d(48,this,d)):(this.p=new j7d(6,this,d)):this.bl()?(this.p=new h7d(49,a,this,d)):(this.p=new h7d(7,a,this,d)):ZD(e,156)?a==Jbb?(this.p=new i7d(40,this)):(this.Bb&512)!=0?(this.Bb&bKe)!=0?!a?(this.p=new i7d(8,this)):(this.p=new g7d(9,a,this)):!a?(this.p=new i7d(10,this)):(this.p=new g7d(11,a,this)):(this.Bb&bKe)!=0?!a?(this.p=new i7d(12,this)):(this.p=new g7d(13,a,this)):!a?(this.p=new i7d(14,this)):(this.p=new g7d(15,a,this)):!d?this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new i7d(16,this)):(this.p=new g7d(17,a,this)):!a?(this.p=new i7d(18,this)):(this.p=new g7d(19,a,this)):(this.Bb&bKe)!=0?!a?(this.p=new i7d(20,this)):(this.p=new g7d(21,a,this)):!a?(this.p=new i7d(22,this)):(this.p=new g7d(23,a,this)):(i=d.t,i>1||i==-1?this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new j7d(24,this,d)):(this.p=new h7d(25,a,this,d)):!a?(this.p=new j7d(26,this,d)):(this.p=new h7d(27,a,this,d)):(this.Bb&bKe)!=0?!a?(this.p=new j7d(28,this,d)):(this.p=new h7d(29,a,this,d)):!a?(this.p=new j7d(30,this,d)):(this.p=new h7d(31,a,this,d)):this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new j7d(32,this,d)):(this.p=new h7d(33,a,this,d)):!a?(this.p=new j7d(34,this,d)):(this.p=new h7d(35,a,this,d)):(this.Bb&bKe)!=0?!a?(this.p=new j7d(36,this,d)):(this.p=new h7d(37,a,this,d)):!a?(this.p=new j7d(38,this,d)):(this.p=new h7d(39,a,this,d))):this._k()?this.bl()?(this.p=new K7d(RD(e,29),this,d)):(this.p=new C7d(RD(e,29),this,d)):ZD(e,156)?a==Jbb?(this.p=new i7d(40,this)):(this.Bb&bKe)!=0?!a?(this.p=new J8d(RD(e,156),b,h,this)):(this.p=new L8d(b,h,this,(a8d(),g==kE?Y7d:g==xdb?T7d:g==lE?Z7d:g==jE?X7d:g==iE?W7d:g==wdb?_7d:g==gE?U7d:g==hE?V7d:$7d))):!a?(this.p=new C8d(RD(e,156),b,h,this)):(this.p=new E8d(b,h,this,(a8d(),g==kE?Y7d:g==xdb?T7d:g==lE?Z7d:g==jE?X7d:g==iE?W7d:g==wdb?_7d:g==gE?U7d:g==hE?V7d:$7d))):this.al()?!d?(this.Bb&bKe)!=0?this.bl()?(this.p=new d9d(RD(e,29),this)):(this.p=new b9d(RD(e,29),this)):this.bl()?(this.p=new _8d(RD(e,29),this)):(this.p=new Z8d(RD(e,29),this)):(this.Bb&bKe)!=0?this.bl()?(this.p=new l9d(RD(e,29),this,d)):(this.p=new j9d(RD(e,29),this,d)):this.bl()?(this.p=new h9d(RD(e,29),this,d)):(this.p=new f9d(RD(e,29),this,d)):this.bl()?!d?(this.Bb&bKe)!=0?(this.p=new p9d(RD(e,29),this)):(this.p=new n9d(RD(e,29),this)):(this.Bb&bKe)!=0?(this.p=new t9d(RD(e,29),this,d)):(this.p=new r9d(RD(e,29),this,d)):!d?(this.Bb&bKe)!=0?(this.p=new v9d(RD(e,29),this)):(this.p=new N8d(RD(e,29),this)):(this.Bb&bKe)!=0?(this.p=new z9d(RD(e,29),this,d)):(this.p=new x9d(RD(e,29),this,d));}return this.p};_.rk=function ZWd(){return (this.Bb&gwe)!=0};_._k=function $Wd(){return false};_.al=function _Wd(){return false};_.sk=function aXd(){return (this.Bb&Ove)!=0};_.xk=function bXd(){return wWd(this)};_.bl=function cXd(){return false};_.tk=function dXd(){return (this.Bb&bKe)!=0};_.cl=function eXd(a){this.k=a;};_.ui=function fXd(a){CWd(this,a);};_.Ib=function gXd(){return GWd(this)};_.e=false;_.n=0;sfb(SHe,'EStructuralFeatureImpl',462);feb(331,462,{110:1,94:1,93:1,35:1,155:1,197:1,58:1,179:1,69:1,114:1,481:1,54:1,99:1,331:1,158:1,462:1,292:1,119:1,120:1,692:1},mXd);_.Lh=function nXd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),jXd(this)?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);case 18:return Geb(),(this.Bb&QHe)!=0?true:false;case 19:if(b)return iXd(this);return hXd(this);}return zvd(this,a-AYd((JTd(),nTd)),vYd((d=RD(Ywd(this,16),29),!d?nTd:d),a),b,c)};_.Wh=function oXd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return jXd(this);case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);case 18:return (this.Bb&QHe)!=0;case 19:return !!hXd(this);}return Avd(this,a-AYd((JTd(),nTd)),vYd((b=RD(Ywd(this,16),29),!b?nTd:b),a))};_.bi=function pXd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:lXd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;case 18:kXd(this,Heb(TD(b)));return;}Bvd(this,a-AYd((JTd(),nTd)),vYd((c=RD(Ywd(this,16),29),!c?nTd:c),a),b);};_.ii=function qXd(){return JTd(),nTd};_.ki=function rXd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.b=0;bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;case 18:kXd(this,false);return;}Cvd(this,a-AYd((JTd(),nTd)),vYd((b=RD(Ywd(this,16),29),!b?nTd:b),a));};_.pi=function sXd(){iXd(this);Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.Jk=function tXd(){return jXd(this)};_.Yk=function uXd(a,b){this.b=0;this.a=null;return ZVd(this,a,b)};_.Zk=function vXd(a){lXd(this,a);};_.Ib=function wXd(){var a;if((this.Db&64)!=0)return GWd(this);a=new Shb(GWd(this));a.a+=' (iD: ';Ohb(a,(this.Bb&QHe)!=0);a.a+=')';return a.a};_.b=0;sfb(SHe,'EAttributeImpl',331);feb(364,448,{110:1,94:1,93:1,142:1,155:1,197:1,58:1,114:1,54:1,99:1,364:1,158:1,119:1,120:1,691:1});_.dl=function NXd(a){return a.Dh()==this};_.Ah=function OXd(a){return AXd(this,a)};_.Bh=function PXd(a,b){this.w=null;this.Db=b<<16|this.Db&255;this.Cb=a;};_.Lh=function QXd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return DXd(this);case 4:return this.ik();case 5:return this.F;case 6:if(b)return BXd(this);return xXd(this);case 7:return !this.A&&(this.A=new iie(z7,this,7)),this.A;}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function RXd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),f.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function SXd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function TXd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return this.ik()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function UXd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function VXd(){return JTd(),pTd};_.ki=function WXd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.hk=function XXd(){var a;return this.G==-1&&(this.G=(a=BXd(this),a?fZd(a.vi(),this):-1)),this.G};_.ik=function YXd(){return null};_.jk=function ZXd(){return BXd(this)};_.el=function $Xd(){return this.v};_.kk=function _Xd(){return DXd(this)};_.lk=function aYd(){return this.D!=null?this.D:this.B};_.mk=function bYd(){return this.F};_.fk=function cYd(a){return FXd(this,a)};_.fl=function dYd(a){this.v=a;};_.gl=function eYd(a){GXd(this,a);};_.hl=function fYd(a){this.C=a;};_.ui=function gYd(a){LXd(this,a);};_.Ib=function hYd(){return MXd(this)};_.C=null;_.D=null;_.G=-1;sfb(SHe,'EClassifierImpl',364);feb(90,364,{110:1,94:1,93:1,29:1,142:1,155:1,197:1,58:1,114:1,54:1,99:1,90:1,364:1,158:1,482:1,119:1,120:1,691:1},HYd);_.dl=function IYd(a){return DYd(this,a.Dh())};_.Lh=function JYd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return DXd(this);case 4:return null;case 5:return this.F;case 6:if(b)return BXd(this);return xXd(this);case 7:return !this.A&&(this.A=new iie(z7,this,7)),this.A;case 8:return Geb(),(this.Bb&256)!=0?true:false;case 9:return Geb(),(this.Bb&512)!=0?true:false;case 10:return zYd(this);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),this.q;case 12:return mYd(this);case 13:return qYd(this);case 14:return qYd(this),this.r;case 15:return mYd(this),this.k;case 16:return nYd(this);case 17:return pYd(this);case 18:return rYd(this);case 19:return sYd(this);case 20:return mYd(this),this.o;case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),this.s;case 22:return tYd(this);case 23:return oYd(this);}return zvd(this,a-AYd((JTd(),oTd)),vYd((d=RD(Ywd(this,16),29),!d?oTd:d),a),b,c)};_.Sh=function KYd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),qLd(this.q,a,c);case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),qLd(this.s,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),oTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),oTd)),a,c)};_.Uh=function LYd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),rLd(this.q,a,c);case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),rLd(this.s,a,c);case 22:return rLd(tYd(this),a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),oTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),oTd)),a,c)};_.Wh=function MYd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return false;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;case 8:return (this.Bb&256)!=0;case 9:return (this.Bb&512)!=0;case 10:return !!this.u&&tYd(this.u.a).i!=0&&!(!!this.n&&d$d(this.n));case 11:return !!this.q&&this.q.i!=0;case 12:return mYd(this).i!=0;case 13:return qYd(this).i!=0;case 14:return qYd(this),this.r.i!=0;case 15:return mYd(this),this.k.i!=0;case 16:return nYd(this).i!=0;case 17:return pYd(this).i!=0;case 18:return rYd(this).i!=0;case 19:return sYd(this).i!=0;case 20:return mYd(this),!!this.o;case 21:return !!this.s&&this.s.i!=0;case 22:return !!this.n&&d$d(this.n);case 23:return oYd(this).i!=0;}return Avd(this,a-AYd((JTd(),oTd)),vYd((b=RD(Ywd(this,16),29),!b?oTd:b),a))};_.Zh=function NYd(a){var b;b=this.i==null||!!this.q&&this.q.i!=0?null:wYd(this,a);return b?b:_zd(this,a)};_.bi=function OYd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;case 8:EYd(this,Heb(TD(b)));return;case 9:FYd(this,Heb(TD(b)));return;case 10:VJd(zYd(this));YGd(zYd(this),RD(b,16));return;case 11:!this.q&&(this.q=new C5d(s7,this,11,10));sLd(this.q);!this.q&&(this.q=new C5d(s7,this,11,10));YGd(this.q,RD(b,16));return;case 21:!this.s&&(this.s=new C5d(y7,this,21,17));sLd(this.s);!this.s&&(this.s=new C5d(y7,this,21,17));YGd(this.s,RD(b,16));return;case 22:sLd(tYd(this));YGd(tYd(this),RD(b,16));return;}Bvd(this,a-AYd((JTd(),oTd)),vYd((c=RD(Ywd(this,16),29),!c?oTd:c),a),b);};_.ii=function PYd(){return JTd(),oTd};_.ki=function QYd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;case 8:EYd(this,false);return;case 9:FYd(this,false);return;case 10:!!this.u&&VJd(this.u);return;case 11:!this.q&&(this.q=new C5d(s7,this,11,10));sLd(this.q);return;case 21:!this.s&&(this.s=new C5d(y7,this,21,17));sLd(this.s);return;case 22:!!this.n&&sLd(this.n);return;}Cvd(this,a-AYd((JTd(),oTd)),vYd((b=RD(Ywd(this,16),29),!b?oTd:b),a));};_.pi=function RYd(){var a,b;mYd(this);qYd(this);nYd(this);pYd(this);rYd(this);sYd(this);oYd(this);OHd(q$d(yYd(this)));if(this.s){for(a=0,b=this.s.i;a=0;--b){QHd(this,b);}}return XHd(this,a)};_.Gk=function NZd(){sLd(this);};_.Zi=function OZd(a,b){return jZd(this,a,b)};sfb(ZJe,'EcoreEList',632);feb(505,632,oKe,PZd);_.Li=function QZd(){return false};_.Lj=function RZd(){return this.c};_.Mj=function SZd(){return false};_.ol=function TZd(){return true};_.Si=function UZd(){return true};_.Wi=function VZd(a,b){return b};_.Yi=function WZd(){return false};_.c=0;sfb(ZJe,'EObjectEList',505);feb(83,505,oKe,XZd);_.Mj=function YZd(){return true};_.ml=function ZZd(){return false};_.al=function $Zd(){return true};sfb(ZJe,'EObjectContainmentEList',83);feb(555,83,oKe,_Zd);_.Ni=function a$d(){this.b=true;};_.Qj=function b$d(){return this.b};_.Gk=function c$d(){var a;sLd(this);if(Mvd(this.e)){a=this.b;this.b=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.b=false;}};_.b=false;sfb(ZJe,'EObjectContainmentEList/Unsettable',555);feb(1161,555,oKe,h$d);_.Ti=function l$d(a,b){var c,d;return c=RD(uLd(this,a,b),89),Mvd(this.e)&&eZd(this,new c4d(this.a,7,(JTd(),qTd),sgb(b),(d=c.c,ZD(d,90)?RD(d,29):zTd),a)),c};_.Uj=function m$d(a,b){return e$d(this,RD(a,89),b)};_.Vj=function n$d(a,b){return f$d(this,RD(a,89),b)};_.Wj=function o$d(a,b,c){return g$d(this,RD(a,89),RD(b,89),c)};_.Ij=function i$d(a,b,c,d,e){switch(a){case 3:{return dZd(this,a,b,c,d,this.i>1)}case 5:{return dZd(this,a,b,c,d,this.i-RD(c,15).gc()>0)}default:{return new P3d(this.e,a,this.c,b,c,d,true)}}};_.Tj=function j$d(){return true};_.Qj=function k$d(){return d$d(this)};_.Gk=function p$d(){sLd(this);};sfb(SHe,'EClassImpl/1',1161);feb(1175,1174,EJe);_.dj=function t$d(a){var b,c,d,e,f,g,h;c=a.gj();if(c!=8){d=s$d(a);if(d==0){switch(c){case 1:case 9:{h=a.kj();if(h!=null){b=yYd(RD(h,482));!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}g=a.ij();if(g!=null){e=RD(g,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}break}case 3:{g=a.ij();if(g!=null){e=RD(g,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}break}case 5:{g=a.ij();if(g!=null){for(f=RD(g,16).Kc();f.Ob();){e=RD(f.Pb(),482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}}break}case 4:{h=a.kj();if(h!=null){e=RD(h,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}}break}case 6:{h=a.kj();if(h!=null){for(f=RD(h,16).Kc();f.Ob();){e=RD(f.Pb(),482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}}}break}}}this.ql(d);}};_.ql=function u$d(a){r$d(this,a);};_.b=63;sfb(SHe,'ESuperAdapter',1175);feb(1176,1175,EJe,w$d);_.ql=function x$d(a){v$d(this,a);};sfb(SHe,'EClassImpl/10',1176);feb(1165,710,oKe);_.Ei=function y$d(a,b){return IHd(this,a,b)};_.Fi=function z$d(a){return JHd(this,a)};_.Gi=function A$d(a,b){KHd(this,a,b);};_.Hi=function B$d(a){LHd(this,a);};_.$i=function D$d(a){return NHd(this,a)};_.Xi=function L$d(a,b){return UHd(this,a,b)};_.Wk=function C$d(a,b){throw Adb(new jib)};_.Ii=function E$d(){return new yMd(this)};_.Ji=function F$d(){return new BMd(this)};_.Ki=function G$d(a){return ZGd(this,a)};_.Xk=function H$d(a,b){throw Adb(new jib)};_.Fk=function I$d(a){return this};_.Qj=function J$d(){return this.i!=0};_.Wb=function K$d(a){throw Adb(new jib)};_.Gk=function M$d(){throw Adb(new jib)};sfb(ZJe,'EcoreEList/UnmodifiableEList',1165);feb(328,1165,oKe,N$d);_.Yi=function O$d(){return false};sfb(ZJe,'EcoreEList/UnmodifiableEList/FastCompare',328);feb(1168,328,oKe,R$d);_.dd=function S$d(a){var b,c,d;if(ZD(a,179)){b=RD(a,179);c=b.Lj();if(c!=-1){for(d=this.i;c4){if(this.fk(a)){if(this.al()){d=RD(a,54);c=d.Eh();h=c==this.b&&(this.ml()?d.yh(d.Fh(),RD(vYd(Uwd(this.b),this.Lj()).Hk(),29).kk())==Z5d(RD(vYd(Uwd(this.b),this.Lj()),19)).n:-1-d.Fh()==this.Lj());if(this.nl()&&!h&&!c&&!!d.Jh()){for(e=0;e1||d==-1)}else {return false}};_.ml=function a0d(){var a,b,c;b=vYd(Uwd(this.b),this.Lj());if(ZD(b,102)){a=RD(b,19);c=Z5d(a);return !!c}else {return false}};_.nl=function b0d(){var a,b;b=vYd(Uwd(this.b),this.Lj());if(ZD(b,102)){a=RD(b,19);return (a.Bb&txe)!=0}else {return false}};_.dd=function c0d(a){var b,c,d,e;d=this.zj(a);if(d>=0)return d;if(this.ol()){for(c=0,e=this.Ej();c=0;--a){N_d(this,a,this.xj(a));}}return this.Fj()};_.Qc=function o0d(a){var b;if(this.nl()){for(b=this.Ej()-1;b>=0;--b){N_d(this,b,this.xj(b));}}return this.Gj(a)};_.Gk=function p0d(){VJd(this);};_.Zi=function q0d(a,b){return P_d(this,a,b)};sfb(ZJe,'DelegatingEcoreEList',756);feb(1171,756,tKe,w0d);_.qj=function z0d(a,b){r0d(this,a,RD(b,29));};_.rj=function A0d(a){s0d(this,RD(a,29));};_.xj=function G0d(a){var b,c;return b=RD(QHd(tYd(this.a),a),89),c=b.c,ZD(c,90)?RD(c,29):(JTd(),zTd)};_.Cj=function L0d(a){var b,c;return b=RD(vLd(tYd(this.a),a),89),c=b.c,ZD(c,90)?RD(c,29):(JTd(),zTd)};_.Dj=function M0d(a,b){return u0d(this,a,RD(b,29))};_.Li=function x0d(){return false};_.Ij=function y0d(a,b,c,d,e){return null};_.sj=function B0d(){return new c1d(this)};_.tj=function C0d(){sLd(tYd(this.a));};_.uj=function D0d(a){return t0d(this,a)};_.vj=function E0d(a){var b,c;for(c=a.Kc();c.Ob();){b=c.Pb();if(!t0d(this,b)){return false}}return true};_.wj=function F0d(a){var b,c,d;if(ZD(a,15)){d=RD(a,15);if(d.gc()==tYd(this.a).i){for(b=d.Kc(),c=new dMd(this);b.Ob();){if(dE(b.Pb())!==dE(bMd(c))){return false}}return true}}return false};_.yj=function H0d(){var a,b,c,d,e;c=1;for(b=new dMd(tYd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),89);d=(e=a.c,ZD(e,90)?RD(e,29):(JTd(),zTd));c=31*c+(!d?0:kFb(d));}return c};_.zj=function I0d(a){var b,c,d,e;d=0;for(c=new dMd(tYd(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);if(dE(a)===dE((e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)))){return d}++d;}return -1};_.Aj=function J0d(){return tYd(this.a).i==0};_.Bj=function K0d(){return null};_.Ej=function N0d(){return tYd(this.a).i};_.Fj=function O0d(){var a,b,c,d,e,f;f=tYd(this.a).i;e=$C(jJ,rve,1,f,5,1);c=0;for(b=new dMd(tYd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),89);e[c++]=(d=a.c,ZD(d,90)?RD(d,29):(JTd(),zTd));}return e};_.Gj=function P0d(a){var b,c,d,e,f,g,h;h=tYd(this.a).i;if(a.lengthh&&bD(a,h,null);d=0;for(c=new dMd(tYd(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);f=(g=b.c,ZD(g,90)?RD(g,29):(JTd(),zTd));bD(a,d++,f);}return a};_.Hj=function Q0d(){var a,b,c,d,e;e=new Qhb;e.a+='[';a=tYd(this.a);for(b=0,d=tYd(this.a).i;b>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);case 9:return !this.a&&(this.a=new C5d(l7,this,9,5)),qLd(this.a,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),sTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),sTd)),a,c)};_.Uh=function D1d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);case 9:return !this.a&&(this.a=new C5d(l7,this,9,5)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),sTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),sTd)),a,c)};_.Wh=function E1d(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return !!y1d(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;case 8:return (this.Bb&256)==0;case 9:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),sTd)),vYd((b=RD(Ywd(this,16),29),!b?sTd:b),a))};_.bi=function F1d(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;case 8:j1d(this,Heb(TD(b)));return;case 9:!this.a&&(this.a=new C5d(l7,this,9,5));sLd(this.a);!this.a&&(this.a=new C5d(l7,this,9,5));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),sTd)),vYd((c=RD(Ywd(this,16),29),!c?sTd:c),a),b);};_.ii=function G1d(){return JTd(),sTd};_.ki=function H1d(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;case 8:j1d(this,true);return;case 9:!this.a&&(this.a=new C5d(l7,this,9,5));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),sTd)),vYd((b=RD(Ywd(this,16),29),!b?sTd:b),a));};_.pi=function I1d(){var a,b;if(this.a){for(a=0,b=this.a.i;a>16==5?RD(this.Cb,685):null;}return zvd(this,a-AYd((JTd(),tTd)),vYd((d=RD(Ywd(this,16),29),!d?tTd:d),a),b,c)};_.Sh=function U1d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 5:!!this.Cb&&(c=(e=this.Db>>16,e>=0?M1d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,5,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),tTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),tTd)),a,c)};_.Uh=function V1d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 5:return xvd(this,null,5,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),tTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),tTd)),a,c)};_.Wh=function W1d(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return !!this.b;case 4:return this.c!=null;case 5:return !!(this.Db>>16==5?RD(this.Cb,685):null);}return Avd(this,a-AYd((JTd(),tTd)),vYd((b=RD(Ywd(this,16),29),!b?tTd:b),a))};_.bi=function X1d(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:Q1d(this,RD(b,17).a);return;case 3:O1d(this,RD(b,2039));return;case 4:P1d(this,WD(b));return;}Bvd(this,a-AYd((JTd(),tTd)),vYd((c=RD(Ywd(this,16),29),!c?tTd:c),a),b);};_.ii=function Y1d(){return JTd(),tTd};_.ki=function Z1d(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:Q1d(this,0);return;case 3:O1d(this,null);return;case 4:P1d(this,null);return;}Cvd(this,a-AYd((JTd(),tTd)),vYd((b=RD(Ywd(this,16),29),!b?tTd:b),a));};_.Ib=function _1d(){var a;return a=this.c,a==null?this.zb:a};_.b=null;_.c=null;_.d=0;sfb(SHe,'EEnumLiteralImpl',582);var h8=ufb(SHe,'EFactoryImpl/InternalEDateTimeFormat');feb(499,1,{2114:1},c2d);sfb(SHe,'EFactoryImpl/1ClientInternalEDateTimeFormat',499);feb(248,120,{110:1,94:1,93:1,89:1,58:1,114:1,54:1,99:1,248:1,119:1,120:1},s2d);_.Ch=function t2d(a,b,c){var d;c=xvd(this,a,b,c);if(!!this.e&&ZD(a,179)){d=k2d(this,this.e);d!=this.c&&(c=o2d(this,d,c));}return c};_.Lh=function u2d(a,b,c){var d;switch(a){case 0:return this.f;case 1:return !this.d&&(this.d=new XZd(o7,this,1)),this.d;case 2:if(b)return i2d(this);return this.c;case 3:return this.b;case 4:return this.e;case 5:if(b)return h2d(this);return this.a;}return zvd(this,a-AYd((JTd(),vTd)),vYd((d=RD(Ywd(this,16),29),!d?vTd:d),a),b,c)};_.Uh=function v2d(a,b,c){var d,e;switch(b){case 0:return g2d(this,null,c);case 1:return !this.d&&(this.d=new XZd(o7,this,1)),rLd(this.d,a,c);case 3:return e2d(this,null,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),vTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),vTd)),a,c)};_.Wh=function w2d(a){var b;switch(a){case 0:return !!this.f;case 1:return !!this.d&&this.d.i!=0;case 2:return !!this.c;case 3:return !!this.b;case 4:return !!this.e;case 5:return !!this.a;}return Avd(this,a-AYd((JTd(),vTd)),vYd((b=RD(Ywd(this,16),29),!b?vTd:b),a))};_.bi=function x2d(a,b){var c;switch(a){case 0:q2d(this,RD(b,89));return;case 1:!this.d&&(this.d=new XZd(o7,this,1));sLd(this.d);!this.d&&(this.d=new XZd(o7,this,1));YGd(this.d,RD(b,16));return;case 3:n2d(this,RD(b,89));return;case 4:p2d(this,RD(b,850));return;case 5:l2d(this,RD(b,142));return;}Bvd(this,a-AYd((JTd(),vTd)),vYd((c=RD(Ywd(this,16),29),!c?vTd:c),a),b);};_.ii=function y2d(){return JTd(),vTd};_.ki=function z2d(a){var b;switch(a){case 0:q2d(this,null);return;case 1:!this.d&&(this.d=new XZd(o7,this,1));sLd(this.d);return;case 3:n2d(this,null);return;case 4:p2d(this,null);return;case 5:l2d(this,null);return;}Cvd(this,a-AYd((JTd(),vTd)),vYd((b=RD(Ywd(this,16),29),!b?vTd:b),a));};_.Ib=function A2d(){var a;a=new dib(awd(this));a.a+=' (expression: ';r2d(this,a);a.a+=')';return a.a};var d2d;sfb(SHe,'EGenericTypeImpl',248);feb(2067,2062,uKe);_.Gi=function C2d(a,b){B2d(this,a,b);};_.Wk=function D2d(a,b){B2d(this,this.gc(),a);return b};_.$i=function E2d(a){return ju(this.pj(),a)};_.Ii=function F2d(){return this.Ji()};_.pj=function G2d(){return new mee(this)};_.Ji=function H2d(){return this.Ki(0)};_.Ki=function I2d(a){return this.pj().fd(a)};_.Xk=function J2d(a,b){ze(this,a,true);return b};_.Ti=function K2d(a,b){var c,d;d=ku(this,b);c=this.fd(a);c.Rb(d);return d};_.Ui=function L2d(a,b){var c;ze(this,b,true);c=this.fd(a);c.Rb(b);};sfb(ZJe,'AbstractSequentialInternalEList',2067);feb(496,2067,uKe,Q2d);_.$i=function R2d(a){return ju(this.pj(),a)};_.Ii=function S2d(){if(this.b==null){return j3d(),j3d(),i3d}return this.sl()};_.pj=function T2d(){return new Whe(this.a,this.b)};_.Ji=function U2d(){if(this.b==null){return j3d(),j3d(),i3d}return this.sl()};_.Ki=function V2d(a){var b,c;if(this.b==null){if(a<0||a>1){throw Adb(new veb(HJe+a+', size=0'))}return j3d(),j3d(),i3d}c=this.sl();for(b=0;b0){b=this.c[--this.d];if((!this.e||b.pk()!=C4||b.Lj()!=0)&&(!this.vl()||this.b.Xh(b))){f=this.b.Nh(b,this.ul());this.f=(nke(),RD(b,69).xk());if(this.f||b.Jk()){if(this.ul()){d=RD(f,15);this.k=d;}else {d=RD(f,71);this.k=this.j=d;}if(ZD(this.k,59)){this.o=this.k.gc();this.n=this.o;}else {this.p=!this.j?this.k.fd(this.k.gc()):this.j.Ki(this.k.gc());}if(!this.p?n3d(this):o3d(this,this.p)){e=!this.p?!this.j?this.k.Xb(--this.n):this.j.$i(--this.n):this.p.Ub();if(this.f){a=RD(e,76);a.Lk();c=a.md();this.i=c;}else {c=e;this.i=c;}this.g=-3;return true}}else if(f!=null){this.k=null;this.p=null;c=f;this.i=c;this.g=-2;return true}}}this.k=null;this.p=null;this.g=-1;return false}else {e=!this.p?!this.j?this.k.Xb(--this.n):this.j.$i(--this.n):this.p.Ub();if(this.f){a=RD(e,76);a.Lk();c=a.md();this.i=c;}else {c=e;this.i=c;}this.g=-3;return true}}}};_.Pb=function v3d(){return k3d(this)};_.Tb=function w3d(){return this.a};_.Ub=function x3d(){var a;if(this.g<-1||this.Sb()){--this.a;this.g=0;a=this.i;this.Sb();return a}else {throw Adb(new Dvb)}};_.Vb=function y3d(){return this.a-1};_.Qb=function z3d(){throw Adb(new jib)};_.ul=function A3d(){return false};_.Wb=function B3d(a){throw Adb(new jib)};_.vl=function C3d(){return true};_.a=0;_.d=0;_.f=false;_.g=0;_.n=0;_.o=0;var i3d;sfb(ZJe,'EContentsEList/FeatureIteratorImpl',287);feb(711,287,vKe,D3d);_.ul=function E3d(){return true};sfb(ZJe,'EContentsEList/ResolvingFeatureIteratorImpl',711);feb(1178,711,vKe,F3d);_.vl=function G3d(){return false};sfb(SHe,'ENamedElementImpl/1/1',1178);feb(1179,287,vKe,H3d);_.vl=function I3d(){return false};sfb(SHe,'ENamedElementImpl/1/2',1179);feb(39,152,GJe,L3d,M3d,N3d,O3d,P3d,Q3d,R3d,S3d,T3d,U3d,V3d,W3d,X3d,Y3d,Z3d,$3d,_3d,a4d,b4d,c4d,d4d,e4d,f4d,g4d,h4d);_.Kj=function i4d(){return K3d(this)};_.Rj=function j4d(){var a;a=K3d(this);if(a){return a.ik()}return null};_.hj=function k4d(a){this.b==-1&&!!this.a&&(this.b=this.c.Hh(this.a.Lj(),this.a.pk()));return this.c.yh(this.b,a)};_.jj=function l4d(){return this.c};_.Sj=function m4d(){var a;a=K3d(this);if(a){return a.tk()}return false};_.b=-1;sfb(SHe,'ENotificationImpl',39);feb(411,292,{110:1,94:1,93:1,155:1,197:1,58:1,62:1,114:1,481:1,54:1,99:1,158:1,411:1,292:1,119:1,120:1},q4d);_.Ah=function r4d(a){return n4d(this,a)};_.Lh=function s4d(a,b,c){var d,e,f;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),f=this.t,f>1||f==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return this.Db>>16==10?RD(this.Cb,29):null;case 11:return !this.d&&(this.d=new iie(z7,this,11)),this.d;case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),this.c;case 13:return !this.a&&(this.a=new F4d(this,this)),this.a;case 14:return o4d(this);}return zvd(this,a-AYd((JTd(),ATd)),vYd((d=RD(Ywd(this,16),29),!d?ATd:d),a),b,c)};_.Sh=function t4d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 10:!!this.Cb&&(c=(e=this.Db>>16,e>=0?n4d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,10,c);case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),qLd(this.c,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ATd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),ATd)),a,c)};_.Uh=function u4d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 10:return xvd(this,null,10,c);case 11:return !this.d&&(this.d=new iie(z7,this,11)),rLd(this.d,a,c);case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),rLd(this.c,a,c);case 14:return rLd(o4d(this),a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ATd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),ATd)),a,c)};_.Wh=function v4d(a){var b,c,d;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return d=this.t,d>1||d==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return !!(this.Db>>16==10?RD(this.Cb,29):null);case 11:return !!this.d&&this.d.i!=0;case 12:return !!this.c&&this.c.i!=0;case 13:return !!this.a&&o4d(this.a.a).i!=0&&!(!!this.b&&o5d(this.b));case 14:return !!this.b&&o5d(this.b);}return Avd(this,a-AYd((JTd(),ATd)),vYd((b=RD(Ywd(this,16),29),!b?ATd:b),a))};_.bi=function w4d(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:bWd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 11:!this.d&&(this.d=new iie(z7,this,11));sLd(this.d);!this.d&&(this.d=new iie(z7,this,11));YGd(this.d,RD(b,16));return;case 12:!this.c&&(this.c=new C5d(u7,this,12,10));sLd(this.c);!this.c&&(this.c=new C5d(u7,this,12,10));YGd(this.c,RD(b,16));return;case 13:!this.a&&(this.a=new F4d(this,this));VJd(this.a);!this.a&&(this.a=new F4d(this,this));YGd(this.a,RD(b,16));return;case 14:sLd(o4d(this));YGd(o4d(this),RD(b,16));return;}Bvd(this,a-AYd((JTd(),ATd)),vYd((c=RD(Ywd(this,16),29),!c?ATd:c),a),b);};_.ii=function x4d(){return JTd(),ATd};_.ki=function y4d(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 11:!this.d&&(this.d=new iie(z7,this,11));sLd(this.d);return;case 12:!this.c&&(this.c=new C5d(u7,this,12,10));sLd(this.c);return;case 13:!!this.a&&VJd(this.a);return;case 14:!!this.b&&sLd(this.b);return;}Cvd(this,a-AYd((JTd(),ATd)),vYd((b=RD(Ywd(this,16),29),!b?ATd:b),a));};_.pi=function z4d(){var a,b;if(this.c){for(a=0,b=this.c.i;ah&&bD(a,h,null);d=0;for(c=new dMd(o4d(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);f=(g=b.c,g?g:(JTd(),wTd));bD(a,d++,f);}return a};_.Hj=function Z4d(){var a,b,c,d,e;e=new Qhb;e.a+='[';a=o4d(this.a);for(b=0,d=o4d(this.a).i;b1)}case 5:{return dZd(this,a,b,c,d,this.i-RD(c,15).gc()>0)}default:{return new P3d(this.e,a,this.c,b,c,d,true)}}};_.Tj=function u5d(){return true};_.Qj=function v5d(){return o5d(this)};_.Gk=function A5d(){sLd(this);};sfb(SHe,'EOperationImpl/2',1377);feb(507,1,{2037:1,507:1},B5d);sfb(SHe,'EPackageImpl/1',507);feb(14,83,oKe,C5d);_.il=function D5d(){return this.d};_.jl=function E5d(){return this.b};_.ml=function F5d(){return true};_.b=0;sfb(ZJe,'EObjectContainmentWithInverseEList',14);feb(365,14,oKe,G5d);_.nl=function H5d(){return true};_.Wi=function I5d(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentWithInverseEList/Resolving',365);feb(308,365,oKe,J5d);_.Ni=function K5d(){this.a.tb=null;};sfb(SHe,'EPackageImpl/2',308);feb(1278,1,{},L5d);sfb(SHe,'EPackageImpl/3',1278);feb(733,45,Hxe,O5d);_._b=function P5d(a){return bE(a)?Yjb(this,a):!!qtb(this.f,a)};sfb(SHe,'EPackageRegistryImpl',733);feb(518,292,{110:1,94:1,93:1,155:1,197:1,58:1,2116:1,114:1,481:1,54:1,99:1,158:1,518:1,292:1,119:1,120:1},R5d);_.Ah=function S5d(a){return Q5d(this,a)};_.Lh=function T5d(a,b,c){var d,e,f;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),f=this.t,f>1||f==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return this.Db>>16==10?RD(this.Cb,62):null;}return zvd(this,a-AYd((JTd(),DTd)),vYd((d=RD(Ywd(this,16),29),!d?DTd:d),a),b,c)};_.Sh=function U5d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 10:!!this.Cb&&(c=(e=this.Db>>16,e>=0?Q5d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,10,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),DTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),DTd)),a,c)};_.Uh=function V5d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 10:return xvd(this,null,10,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),DTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),DTd)),a,c)};_.Wh=function W5d(a){var b,c,d;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return d=this.t,d>1||d==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return !!(this.Db>>16==10?RD(this.Cb,62):null);}return Avd(this,a-AYd((JTd(),DTd)),vYd((b=RD(Ywd(this,16),29),!b?DTd:b),a))};_.ii=function X5d(){return JTd(),DTd};sfb(SHe,'EParameterImpl',518);feb(102,462,{110:1,94:1,93:1,155:1,197:1,58:1,19:1,179:1,69:1,114:1,481:1,54:1,99:1,158:1,102:1,462:1,292:1,119:1,120:1,692:1},d6d);_.Lh=function e6d(a,b,c){var d,e,f,g;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),g=this.t,g>1||g==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);case 18:return Geb(),(this.Bb&QHe)!=0?true:false;case 19:return Geb(),f=Z5d(this),!!f&&(f.Bb&QHe)!=0?true:false;case 20:return Geb(),(this.Bb&txe)!=0?true:false;case 21:if(b)return Z5d(this);return this.b;case 22:if(b)return $5d(this);return Y5d(this);case 23:return !this.a&&(this.a=new zie(g7,this,23)),this.a;}return zvd(this,a-AYd((JTd(),ETd)),vYd((d=RD(Ywd(this,16),29),!d?ETd:d),a),b,c)};_.Wh=function f6d(a){var b,c,d,e;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return e=this.t,e>1||e==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);case 18:return (this.Bb&QHe)!=0;case 19:return d=Z5d(this),!!d&&(d.Bb&QHe)!=0;case 20:return (this.Bb&txe)==0;case 21:return !!this.b;case 22:return !!Y5d(this);case 23:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),ETd)),vYd((b=RD(Ywd(this,16),29),!b?ETd:b),a))};_.bi=function g6d(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:bWd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;case 18:_5d(this,Heb(TD(b)));return;case 20:c6d(this,Heb(TD(b)));return;case 21:b6d(this,RD(b,19));return;case 23:!this.a&&(this.a=new zie(g7,this,23));sLd(this.a);!this.a&&(this.a=new zie(g7,this,23));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),ETd)),vYd((c=RD(Ywd(this,16),29),!c?ETd:c),a),b);};_.ii=function h6d(){return JTd(),ETd};_.ki=function i6d(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;case 18:a6d(this,false);ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),2);return;case 20:c6d(this,true);return;case 21:b6d(this,null);return;case 23:!this.a&&(this.a=new zie(g7,this,23));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),ETd)),vYd((b=RD(Ywd(this,16),29),!b?ETd:b),a));};_.pi=function j6d(){$5d(this);Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.uk=function k6d(){return Z5d(this)};_._k=function l6d(){var a;return a=Z5d(this),!!a&&(a.Bb&QHe)!=0};_.al=function m6d(){return (this.Bb&QHe)!=0};_.bl=function n6d(){return (this.Bb&txe)!=0};_.Yk=function o6d(a,b){this.c=null;return ZVd(this,a,b)};_.Ib=function p6d(){var a;if((this.Db&64)!=0)return GWd(this);a=new Shb(GWd(this));a.a+=' (containment: ';Ohb(a,(this.Bb&QHe)!=0);a.a+=', resolveProxies: ';Ohb(a,(this.Bb&txe)!=0);a.a+=')';return a.a};sfb(SHe,'EReferenceImpl',102);feb(561,120,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1,561:1,119:1,120:1},v6d);_.Fb=function B6d(a){return this===a};_.ld=function D6d(){return this.b};_.md=function E6d(){return this.c};_.Hb=function F6d(){return kFb(this)};_.Di=function H6d(a){q6d(this,WD(a));};_.nd=function I6d(a){return u6d(this,WD(a))};_.Lh=function w6d(a,b,c){var d;switch(a){case 0:return this.b;case 1:return this.c;}return zvd(this,a-AYd((JTd(),FTd)),vYd((d=RD(Ywd(this,16),29),!d?FTd:d),a),b,c)};_.Wh=function x6d(a){var b;switch(a){case 0:return this.b!=null;case 1:return this.c!=null;}return Avd(this,a-AYd((JTd(),FTd)),vYd((b=RD(Ywd(this,16),29),!b?FTd:b),a))};_.bi=function y6d(a,b){var c;switch(a){case 0:r6d(this,WD(b));return;case 1:t6d(this,WD(b));return;}Bvd(this,a-AYd((JTd(),FTd)),vYd((c=RD(Ywd(this,16),29),!c?FTd:c),a),b);};_.ii=function z6d(){return JTd(),FTd};_.ki=function A6d(a){var b;switch(a){case 0:s6d(this,null);return;case 1:t6d(this,null);return;}Cvd(this,a-AYd((JTd(),FTd)),vYd((b=RD(Ywd(this,16),29),!b?FTd:b),a));};_.Bi=function C6d(){var a;if(this.a==-1){a=this.b;this.a=a==null?0:ohb(a);}return this.a};_.Ci=function G6d(a){this.a=a;};_.Ib=function J6d(){var a;if((this.Db&64)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (key: ';Nhb(a,this.b);a.a+=', value: ';Nhb(a,this.c);a.a+=')';return a.a};_.a=-1;_.b=null;_.c=null;var C8=sfb(SHe,'EStringToStringMapEntryImpl',561);var Ibb=ufb(ZJe,'FeatureMap/Entry/Internal');feb(576,1,wKe);_.xl=function M6d(a){return this.yl(RD(a,54))};_.yl=function N6d(a){return this.xl(a)};_.Fb=function O6d(a){var b,c;if(this===a){return true}else if(ZD(a,76)){b=RD(a,76);if(b.Lk()==this.c){c=this.md();return c==null?b.md()==null:pb(c,b.md())}else {return false}}else {return false}};_.Lk=function P6d(){return this.c};_.Hb=function Q6d(){var a;a=this.md();return tb(this.c)^(a==null?0:tb(a))};_.Ib=function R6d(){var a,b;a=this.c;b=BXd(a.qk()).yi();a.xe();return (b!=null&&b.length!=0?b+':'+a.xe():a.xe())+'='+this.md()};sfb(SHe,'EStructuralFeatureImpl/BasicFeatureMapEntry',576);feb(791,576,wKe,U6d);_.yl=function V6d(a){return new U6d(this.c,a)};_.md=function W6d(){return this.a};_.zl=function X6d(a,b,c){return S6d(this,a,this.a,b,c)};_.Al=function Y6d(a,b,c){return T6d(this,a,this.a,b,c)};sfb(SHe,'EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry',791);feb(1350,1,{},Z6d);_.yk=function $6d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Yl(this.a).Fk(d)};_.zk=function _6d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Pl(this.a,d,e)};_.Ak=function a7d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Ql(this.a,d,e)};_.Bk=function b7d(a,b,c){var d;d=RD(Evd(a,this.b),220);return d.Yl(this.a).Qj()};_.Ck=function c7d(a,b,c,d){var e;e=RD(Evd(a,this.b),220);e.Yl(this.a).Wb(d);};_.Dk=function d7d(a,b,c){return RD(Evd(a,this.b),220).Yl(this.a)};_.Ek=function e7d(a,b,c){var d;d=RD(Evd(a,this.b),220);d.Yl(this.a).Gk();};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator',1350);feb(91,1,{},g7d,h7d,i7d,j7d);_.yk=function k7d(a,b,c,d,e){var f;f=b.li(c);f==null&&b.mi(c,f=f7d(this,a));if(!e){switch(this.e){case 50:case 41:return RD(f,597).bk();case 40:return RD(f,220).Vl();}}return f};_.zk=function l7d(a,b,c,d,e){var f,g;g=b.li(c);g==null&&b.mi(c,g=f7d(this,a));f=RD(g,71).Wk(d,e);return f};_.Ak=function m7d(a,b,c,d,e){var f;f=b.li(c);f!=null&&(e=RD(f,71).Xk(d,e));return e};_.Bk=function n7d(a,b,c){var d;d=b.li(c);return d!=null&&RD(d,79).Qj()};_.Ck=function o7d(a,b,c,d){var e;e=RD(b.li(c),79);!e&&b.mi(c,e=f7d(this,a));e.Wb(d);};_.Dk=function p7d(a,b,c){var d,e;e=b.li(c);e==null&&b.mi(c,e=f7d(this,a));if(ZD(e,79)){return RD(e,79)}else {d=RD(b.li(c),15);return new I9d(d)}};_.Ek=function q7d(a,b,c){var d;d=RD(b.li(c),79);!d&&b.mi(c,d=f7d(this,a));d.Gk();};_.b=0;_.e=0;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateMany',91);feb(512,1,{});_.zk=function u7d(a,b,c,d,e){throw Adb(new jib)};_.Ak=function v7d(a,b,c,d,e){throw Adb(new jib)};_.Dk=function w7d(a,b,c){return new x7d(this,a,b,c)};var r7d;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingle',512);feb(1367,1,$Je,x7d);_.Fk=function y7d(a){return this.a.yk(this.c,this.d,this.b,a,true)};_.Qj=function z7d(){return this.a.Bk(this.c,this.d,this.b)};_.Wb=function A7d(a){this.a.Ck(this.c,this.d,this.b,a);};_.Gk=function B7d(){this.a.Ek(this.c,this.d,this.b);};_.b=0;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingle/1',1367);feb(784,512,{},C7d);_.yk=function D7d(a,b,c,d,e){return jwd(a,a.Ph(),a.Fh())==this.b?this.bl()&&d?yvd(a):a.Ph():null};_.zk=function E7d(a,b,c,d,e){var f,g;!!a.Ph()&&(e=(f=a.Fh(),f>=0?a.Ah(e):a.Ph().Th(a,-1-f,null,e)));g=BYd(a.Dh(),this.e);return a.Ch(d,g,e)};_.Ak=function F7d(a,b,c,d,e){var f;f=BYd(a.Dh(),this.e);return a.Ch(null,f,e)};_.Bk=function G7d(a,b,c){var d;d=BYd(a.Dh(),this.e);return !!a.Ph()&&a.Fh()==d};_.Ck=function H7d(a,b,c,d){var e,f,g,h,i;if(d!=null&&!FXd(this.a,d)){throw Adb(new Ifb(xKe+(ZD(d,58)?GYd(RD(d,58).Dh()):ofb(rb(d)))+yKe+this.a+"'"))}e=a.Ph();g=BYd(a.Dh(),this.e);if(dE(d)!==dE(e)||a.Fh()!=g&&d!=null){if(Oje(a,RD(d,58)))throw Adb(new agb(UHe+a.Ib()));i=null;!!e&&(i=(f=a.Fh(),f>=0?a.Ah(i):a.Ph().Th(a,-1-f,null,i)));h=RD(d,54);!!h&&(i=h.Rh(a,BYd(h.Dh(),this.b),null,i));i=a.Ch(h,g,i);!!i&&i.oj();}else {a.vh()&&a.wh()&&qvd(a,new N3d(a,1,g,d,d));}};_.Ek=function I7d(a,b,c){var d,e,f,g;d=a.Ph();if(d){g=(e=a.Fh(),e>=0?a.Ah(null):a.Ph().Th(a,-1-e,null,null));f=BYd(a.Dh(),this.e);g=a.Ch(null,f,g);!!g&&g.oj();}else {a.vh()&&a.wh()&&qvd(a,new b4d(a,1,this.e,null,null));}};_.bl=function J7d(){return false};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleContainer',784);feb(1351,784,{},K7d);_.bl=function L7d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving',1351);feb(574,512,{});_.yk=function O7d(a,b,c,d,e){var f;return f=b.li(c),f==null?this.b:dE(f)===dE(r7d)?null:f};_.Bk=function P7d(a,b,c){var d;d=b.li(c);return d!=null&&(dE(d)===dE(r7d)||!pb(d,this.b))};_.Ck=function Q7d(a,b,c,d){var e,f;if(a.vh()&&a.wh()){e=(f=b.li(c),f==null?this.b:dE(f)===dE(r7d)?null:f);if(d==null){if(this.c!=null){b.mi(c,null);d=this.b;}else this.b!=null?b.mi(c,r7d):b.mi(c,null);}else {this.Bl(d);b.mi(c,d);}qvd(a,this.d.Cl(a,1,this.e,e,d));}else {if(d==null){this.c!=null?b.mi(c,null):this.b!=null?b.mi(c,r7d):b.mi(c,null);}else {this.Bl(d);b.mi(c,d);}}};_.Ek=function R7d(a,b,c){var d,e;if(a.vh()&&a.wh()){d=(e=b.li(c),e==null?this.b:dE(e)===dE(r7d)?null:e);b.ni(c);qvd(a,this.d.Cl(a,1,this.e,d,this.b));}else {b.ni(c);}};_.Bl=function S7d(a){throw Adb(new Hfb)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData',574);feb(zKe,1,{},b8d);_.Cl=function c8d(a,b,c,d,e){return new b4d(a,b,c,d,e)};_.Dl=function d8d(a,b,c,d,e,f){return new d4d(a,b,c,d,e,f)};var T7d,U7d,V7d,W7d,X7d,Y7d,Z7d,$7d,_7d;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator',zKe);feb(1368,zKe,{},e8d);_.Cl=function f8d(a,b,c,d,e){return new g4d(a,b,c,Heb(TD(d)),Heb(TD(e)))};_.Dl=function g8d(a,b,c,d,e,f){return new h4d(a,b,c,Heb(TD(d)),Heb(TD(e)),f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1',1368);feb(1369,zKe,{},h8d);_.Cl=function i8d(a,b,c,d,e){return new R3d(a,b,c,RD(d,222).a,RD(e,222).a)};_.Dl=function j8d(a,b,c,d,e,f){return new S3d(a,b,c,RD(d,222).a,RD(e,222).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2',1369);feb(1370,zKe,{},k8d);_.Cl=function l8d(a,b,c,d,e){return new T3d(a,b,c,RD(d,180).a,RD(e,180).a)};_.Dl=function m8d(a,b,c,d,e,f){return new U3d(a,b,c,RD(d,180).a,RD(e,180).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3',1370);feb(1371,zKe,{},n8d);_.Cl=function o8d(a,b,c,d,e){return new V3d(a,b,c,Kfb(UD(d)),Kfb(UD(e)))};_.Dl=function p8d(a,b,c,d,e,f){return new W3d(a,b,c,Kfb(UD(d)),Kfb(UD(e)),f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4',1371);feb(1372,zKe,{},q8d);_.Cl=function r8d(a,b,c,d,e){return new X3d(a,b,c,RD(d,161).a,RD(e,161).a)};_.Dl=function s8d(a,b,c,d,e,f){return new Y3d(a,b,c,RD(d,161).a,RD(e,161).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5',1372);feb(1373,zKe,{},t8d);_.Cl=function u8d(a,b,c,d,e){return new Z3d(a,b,c,RD(d,17).a,RD(e,17).a)};_.Dl=function v8d(a,b,c,d,e,f){return new $3d(a,b,c,RD(d,17).a,RD(e,17).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6',1373);feb(1374,zKe,{},w8d);_.Cl=function x8d(a,b,c,d,e){return new _3d(a,b,c,RD(d,168).a,RD(e,168).a)};_.Dl=function y8d(a,b,c,d,e,f){return new a4d(a,b,c,RD(d,168).a,RD(e,168).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7',1374);feb(1375,zKe,{},z8d);_.Cl=function A8d(a,b,c,d,e){return new e4d(a,b,c,RD(d,191).a,RD(e,191).a)};_.Dl=function B8d(a,b,c,d,e,f){return new f4d(a,b,c,RD(d,191).a,RD(e,191).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8',1375);feb(1353,574,{},C8d);_.Bl=function D8d(a){if(!this.a.fk(a)){throw Adb(new Ifb(xKe+rb(a)+yKe+this.a+"'"))}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic',1353);feb(1354,574,{},E8d);_.Bl=function F8d(a){};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic',1354);feb(785,574,{});_.Bk=function G8d(a,b,c){var d;d=b.li(c);return d!=null};_.Ck=function H8d(a,b,c,d){var e,f;if(a.vh()&&a.wh()){e=true;f=b.li(c);if(f==null){e=false;f=this.b;}else dE(f)===dE(r7d)&&(f=null);if(d==null){if(this.c!=null){b.mi(c,null);d=this.b;}else {b.mi(c,r7d);}}else {this.Bl(d);b.mi(c,d);}qvd(a,this.d.Dl(a,1,this.e,f,d,!e));}else {if(d==null){this.c!=null?b.mi(c,null):b.mi(c,r7d);}else {this.Bl(d);b.mi(c,d);}}};_.Ek=function I8d(a,b,c){var d,e;if(a.vh()&&a.wh()){d=true;e=b.li(c);if(e==null){d=false;e=this.b;}else dE(e)===dE(r7d)&&(e=null);b.ni(c);qvd(a,this.d.Dl(a,2,this.e,e,this.b,d));}else {b.ni(c);}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable',785);feb(1355,785,{},J8d);_.Bl=function K8d(a){if(!this.a.fk(a)){throw Adb(new Ifb(xKe+rb(a)+yKe+this.a+"'"))}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic',1355);feb(1356,785,{},L8d);_.Bl=function M8d(a){};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic',1356);feb(410,512,{},N8d);_.yk=function P8d(a,b,c,d,e){var f,g,h,i,j;j=b.li(c);if(this.tk()&&dE(j)===dE(r7d)){return null}else if(this.bl()&&d&&j!=null){h=RD(j,54);if(h.Vh()){i=Vvd(a,h);if(h!=i){if(!FXd(this.a,i)){throw Adb(new Ifb(xKe+rb(i)+yKe+this.a+"'"))}b.mi(c,j=i);if(this.al()){f=RD(i,54);g=h.Th(a,!this.b?-1-BYd(a.Dh(),this.e):BYd(h.Dh(),this.b),null,null);!f.Ph()&&(g=f.Rh(a,!this.b?-1-BYd(a.Dh(),this.e):BYd(f.Dh(),this.b),null,g));!!g&&g.oj();}a.vh()&&a.wh()&&qvd(a,new b4d(a,9,this.e,h,i));}}return j}else {return j}};_.zk=function Q8d(a,b,c,d,e){var f,g;g=b.li(c);dE(g)===dE(r7d)&&(g=null);b.mi(c,d);if(this.Mj()){if(dE(g)!==dE(d)&&g!=null){f=RD(g,54);e=f.Th(a,BYd(f.Dh(),this.b),null,e);}}else this.al()&&g!=null&&(e=RD(g,54).Th(a,-1-BYd(a.Dh(),this.e),null,e));if(a.vh()&&a.wh()){!e&&(e=new gLd(4));e.nj(new b4d(a,1,this.e,g,d));}return e};_.Ak=function R8d(a,b,c,d,e){var f;f=b.li(c);dE(f)===dE(r7d)&&(f=null);b.ni(c);if(a.vh()&&a.wh()){!e&&(e=new gLd(4));this.tk()?e.nj(new b4d(a,2,this.e,f,null)):e.nj(new b4d(a,1,this.e,f,null));}return e};_.Bk=function S8d(a,b,c){var d;d=b.li(c);return d!=null};_.Ck=function T8d(a,b,c,d){var e,f,g,h,i;if(d!=null&&!FXd(this.a,d)){throw Adb(new Ifb(xKe+(ZD(d,58)?GYd(RD(d,58).Dh()):ofb(rb(d)))+yKe+this.a+"'"))}i=b.li(c);h=i!=null;this.tk()&&dE(i)===dE(r7d)&&(i=null);g=null;if(this.Mj()){if(dE(i)!==dE(d)){if(i!=null){e=RD(i,54);g=e.Th(a,BYd(e.Dh(),this.b),null,g);}if(d!=null){e=RD(d,54);g=e.Rh(a,BYd(e.Dh(),this.b),null,g);}}}else if(this.al()){if(dE(i)!==dE(d)){i!=null&&(g=RD(i,54).Th(a,-1-BYd(a.Dh(),this.e),null,g));d!=null&&(g=RD(d,54).Rh(a,-1-BYd(a.Dh(),this.e),null,g));}}d==null&&this.tk()?b.mi(c,r7d):b.mi(c,d);if(a.vh()&&a.wh()){f=new d4d(a,1,this.e,i,d,this.tk()&&!h);if(!g){qvd(a,f);}else {g.nj(f);g.oj();}}else !!g&&g.oj();};_.Ek=function U8d(a,b,c){var d,e,f,g,h;h=b.li(c);g=h!=null;this.tk()&&dE(h)===dE(r7d)&&(h=null);f=null;if(h!=null){if(this.Mj()){d=RD(h,54);f=d.Th(a,BYd(d.Dh(),this.b),null,f);}else this.al()&&(f=RD(h,54).Th(a,-1-BYd(a.Dh(),this.e),null,f));}b.ni(c);if(a.vh()&&a.wh()){e=new d4d(a,this.tk()?2:1,this.e,h,null,g);if(!f){qvd(a,e);}else {f.nj(e);f.oj();}}else !!f&&f.oj();};_.Mj=function V8d(){return false};_.al=function W8d(){return false};_.bl=function X8d(){return false};_.tk=function Y8d(){return false};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObject',410);feb(575,410,{},Z8d);_.al=function $8d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment',575);feb(1359,575,{},_8d);_.bl=function a9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving',1359);feb(787,575,{},b9d);_.tk=function c9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable',787);feb(1361,787,{},d9d);_.bl=function e9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving',1361);feb(650,575,{},f9d);_.Mj=function g9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse',650);feb(1360,650,{},h9d);_.bl=function i9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving',1360);feb(788,650,{},j9d);_.tk=function k9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable',788);feb(1362,788,{},l9d);_.bl=function m9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving',1362);feb(651,410,{},n9d);_.bl=function o9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving',651);feb(1363,651,{},p9d);_.tk=function q9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable',1363);feb(789,651,{},r9d);_.Mj=function s9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse',789);feb(1364,789,{},t9d);_.tk=function u9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable',1364);feb(1357,410,{},v9d);_.tk=function w9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable',1357);feb(786,410,{},x9d);_.Mj=function y9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse',786);feb(1358,786,{},z9d);_.tk=function A9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable',1358);feb(790,576,wKe,D9d);_.yl=function E9d(a){return new D9d(this.a,this.c,a)};_.md=function F9d(){return this.b};_.zl=function G9d(a,b,c){return B9d(this,a,this.b,c)};_.Al=function H9d(a,b,c){return C9d(this,a,this.b,c)};sfb(SHe,'EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry',790);feb(1365,1,$Je,I9d);_.Fk=function J9d(a){return this.a};_.Qj=function K9d(){return ZD(this.a,97)?RD(this.a,97).Qj():!this.a.dc()};_.Wb=function L9d(a){this.a.$b();this.a.Gc(RD(a,15));};_.Gk=function M9d(){ZD(this.a,97)?RD(this.a,97).Gk():this.a.$b();};sfb(SHe,'EStructuralFeatureImpl/SettingMany',1365);feb(1366,576,wKe,N9d);_.xl=function O9d(a){return new S9d((nme(),mme),this.b.ri(this.a,a))};_.md=function P9d(){return null};_.zl=function Q9d(a,b,c){return c};_.Al=function R9d(a,b,c){return c};sfb(SHe,'EStructuralFeatureImpl/SimpleContentFeatureMapEntry',1366);feb(652,576,wKe,S9d);_.xl=function T9d(a){return new S9d(this.c,a)};_.md=function U9d(){return this.a};_.zl=function V9d(a,b,c){return c};_.Al=function W9d(a,b,c){return c};sfb(SHe,'EStructuralFeatureImpl/SimpleFeatureMapEntry',652);feb(403,506,PIe,X9d);_.aj=function Y9d(a){return $C(h7,rve,29,a,0,1)};_.Yi=function Z9d(){return false};sfb(SHe,'ESuperAdapter/1',403);feb(457,448,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,850:1,54:1,99:1,158:1,457:1,119:1,120:1},_9d);_.Lh=function aae(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return !this.a&&(this.a=new iae(this,o7,this)),this.a;}return zvd(this,a-AYd((JTd(),ITd)),vYd((d=RD(Ywd(this,16),29),!d?ITd:d),a),b,c)};_.Uh=function bae(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 2:return !this.a&&(this.a=new iae(this,o7,this)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ITd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),ITd)),a,c)};_.Wh=function cae(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),ITd)),vYd((b=RD(Ywd(this,16),29),!b?ITd:b),a))};_.bi=function dae(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:!this.a&&(this.a=new iae(this,o7,this));sLd(this.a);!this.a&&(this.a=new iae(this,o7,this));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),ITd)),vYd((c=RD(Ywd(this,16),29),!c?ITd:c),a),b);};_.ii=function eae(){return JTd(),ITd};_.ki=function fae(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:!this.a&&(this.a=new iae(this,o7,this));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),ITd)),vYd((b=RD(Ywd(this,16),29),!b?ITd:b),a));};sfb(SHe,'ETypeParameterImpl',457);feb(458,83,oKe,iae);_.Nj=function jae(a,b){return gae(this,RD(a,89),b)};_.Oj=function kae(a,b){return hae(this,RD(a,89),b)};sfb(SHe,'ETypeParameterImpl/1',458);feb(647,45,Hxe,lae);_.ec=function mae(){return new pae(this)};sfb(SHe,'ETypeParameterImpl/2',647);feb(570,Eve,Fve,pae);_.Fc=function qae(a){return nae(this,RD(a,89))};_.Gc=function rae(a){var b,c,d;d=false;for(c=a.Kc();c.Ob();){b=RD(c.Pb(),89);Zjb(this.a,b,'')==null&&(d=true);}return d};_.$b=function sae(){akb(this.a);};_.Hc=function tae(a){return Ujb(this.a,a)};_.Kc=function uae(){var a;return a=new vkb((new mkb(this.a)).a),new xae(a)};_.Mc=function vae(a){return oae(this,a)};_.gc=function wae(){return bkb(this.a)};sfb(SHe,'ETypeParameterImpl/2/1',570);feb(571,1,Ave,xae);_.Nb=function yae(a){Ztb(this,a);};_.Pb=function Aae(){return RD(tkb(this.a).ld(),89)};_.Ob=function zae(){return this.a.b};_.Qb=function Bae(){ukb(this.a);};sfb(SHe,'ETypeParameterImpl/2/1/1',571);feb(1329,45,Hxe,Cae);_._b=function Dae(a){return bE(a)?Yjb(this,a):!!qtb(this.f,a)};_.xc=function Eae(a){var b,c;b=bE(a)?Xjb(this,a):Wd(qtb(this.f,a));if(ZD(b,851)){c=RD(b,851);b=c.Kk();Zjb(this,RD(a,241),b);return b}else return b!=null?b:a==null?(Gie(),Fie):null};sfb(SHe,'EValidatorRegistryImpl',1329);feb(1349,720,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,2040:1,54:1,99:1,158:1,119:1,120:1},Mae);_.ri=function Nae(a,b){switch(a.hk()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return b==null?null:jeb(b);case 25:return Gae(b);case 27:return Hae(b);case 28:return Iae(b);case 29:return b==null?null:a2d(nAd[0],RD(b,206));case 41:return b==null?'':nfb(RD(b,297));case 42:return jeb(b);case 50:return WD(b);default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function Oae(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;switch(a.G==-1&&(a.G=(m=BXd(a),m?fZd(m.vi(),a):-1)),a.G){case 0:return c=new mXd,c;case 1:return b=new pVd,b;case 2:return d=new HYd,d;case 4:return e=new k1d,e;case 5:return f=new A1d,f;case 6:return g=new R1d,g;case 7:return h=new yAd,h;case 10:return j=new kUd,j;case 11:return k=new q4d,k;case 12:return l=new EBd,l;case 13:return n=new R5d,n;case 14:return o=new d6d,o;case 17:return p=new v6d,p;case 18:return i=new s2d,i;case 19:return q=new _9d,q;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function Pae(a,b){switch(a.hk()){case 20:return b==null?null:new Bib(b);case 21:return b==null?null:new ejb(b);case 23:case 22:return b==null?null:Fae(b);case 26:case 24:return b==null?null:$eb(Oeb(b,-128,127)<<24>>24);case 25:return vAd(b);case 27:return Jae(b);case 28:return Kae(b);case 29:return Lae(b);case 32:case 31:return b==null?null:Neb(b);case 38:case 37:return b==null?null:new Ufb(b);case 40:case 39:return b==null?null:sgb(Oeb(b,qwe,lve));case 41:return null;case 42:return b==null?null:null;case 44:case 43:return b==null?null:Hgb(Peb(b));case 49:case 48:return b==null?null:bhb(Oeb(b,BKe,32767)<<16>>16);case 50:return b;default:throw Adb(new agb(VHe+a.xe()+WHe));}};sfb(SHe,'EcoreFactoryImpl',1349);feb(560,184,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,2038:1,54:1,99:1,158:1,184:1,560:1,119:1,120:1,690:1},$ae);_.gb=false;_.hb=false;var Rae,Sae=false;sfb(SHe,'EcorePackageImpl',560);feb(1234,1,{851:1},cbe);_.Kk=function dbe(){return fke(),eke};sfb(SHe,'EcorePackageImpl/1',1234);feb(1243,1,OKe,ebe);_.fk=function fbe(a){return ZD(a,155)};_.gk=function gbe(a){return $C(p7,rve,155,a,0,1)};sfb(SHe,'EcorePackageImpl/10',1243);feb(1244,1,OKe,hbe);_.fk=function ibe(a){return ZD(a,197)};_.gk=function jbe(a){return $C(q7,rve,197,a,0,1)};sfb(SHe,'EcorePackageImpl/11',1244);feb(1245,1,OKe,kbe);_.fk=function lbe(a){return ZD(a,58)};_.gk=function mbe(a){return $C(r7,rve,58,a,0,1)};sfb(SHe,'EcorePackageImpl/12',1245);feb(1246,1,OKe,nbe);_.fk=function obe(a){return ZD(a,411)};_.gk=function pbe(a){return $C(s7,mKe,62,a,0,1)};sfb(SHe,'EcorePackageImpl/13',1246);feb(1247,1,OKe,qbe);_.fk=function rbe(a){return ZD(a,241)};_.gk=function sbe(a){return $C(t7,rve,241,a,0,1)};sfb(SHe,'EcorePackageImpl/14',1247);feb(1248,1,OKe,tbe);_.fk=function ube(a){return ZD(a,518)};_.gk=function vbe(a){return $C(u7,rve,2116,a,0,1)};sfb(SHe,'EcorePackageImpl/15',1248);feb(1249,1,OKe,wbe);_.fk=function xbe(a){return ZD(a,102)};_.gk=function ybe(a){return $C(v7,lKe,19,a,0,1)};sfb(SHe,'EcorePackageImpl/16',1249);feb(1250,1,OKe,zbe);_.fk=function Abe(a){return ZD(a,179)};_.gk=function Bbe(a){return $C(y7,lKe,179,a,0,1)};sfb(SHe,'EcorePackageImpl/17',1250);feb(1251,1,OKe,Cbe);_.fk=function Dbe(a){return ZD(a,481)};_.gk=function Ebe(a){return $C(A7,rve,481,a,0,1)};sfb(SHe,'EcorePackageImpl/18',1251);feb(1252,1,OKe,Fbe);_.fk=function Gbe(a){return ZD(a,561)};_.gk=function Hbe(a){return $C(C8,LJe,561,a,0,1)};sfb(SHe,'EcorePackageImpl/19',1252);feb(1235,1,OKe,Ibe);_.fk=function Jbe(a){return ZD(a,331)};_.gk=function Kbe(a){return $C(g7,lKe,35,a,0,1)};sfb(SHe,'EcorePackageImpl/2',1235);feb(1253,1,OKe,Lbe);_.fk=function Mbe(a){return ZD(a,248)};_.gk=function Nbe(a){return $C(o7,sKe,89,a,0,1)};sfb(SHe,'EcorePackageImpl/20',1253);feb(1254,1,OKe,Obe);_.fk=function Pbe(a){return ZD(a,457)};_.gk=function Qbe(a){return $C(z7,rve,850,a,0,1)};sfb(SHe,'EcorePackageImpl/21',1254);feb(1255,1,OKe,Rbe);_.fk=function Sbe(a){return $D(a)};_.gk=function Tbe(a){return $C(QI,Nve,485,a,8,1)};sfb(SHe,'EcorePackageImpl/22',1255);feb(1256,1,OKe,Ube);_.fk=function Vbe(a){return ZD(a,195)};_.gk=function Wbe(a){return $C(gE,Nve,195,a,0,2)};sfb(SHe,'EcorePackageImpl/23',1256);feb(1257,1,OKe,Xbe);_.fk=function Ybe(a){return ZD(a,222)};_.gk=function Zbe(a){return $C(RI,Nve,222,a,0,1)};sfb(SHe,'EcorePackageImpl/24',1257);feb(1258,1,OKe,$be);_.fk=function _be(a){return ZD(a,180)};_.gk=function ace(a){return $C(SI,Nve,180,a,0,1)};sfb(SHe,'EcorePackageImpl/25',1258);feb(1259,1,OKe,bce);_.fk=function cce(a){return ZD(a,206)};_.gk=function dce(a){return $C(qK,Nve,206,a,0,1)};sfb(SHe,'EcorePackageImpl/26',1259);feb(1260,1,OKe,ece);_.fk=function fce(a){return false};_.gk=function gce(a){return $C(T6,rve,2215,a,0,1)};sfb(SHe,'EcorePackageImpl/27',1260);feb(1261,1,OKe,hce);_.fk=function ice(a){return _D(a)};_.gk=function jce(a){return $C(VI,Nve,345,a,7,1)};sfb(SHe,'EcorePackageImpl/28',1261);feb(1262,1,OKe,kce);_.fk=function lce(a){return ZD(a,61)};_.gk=function mce(a){return $C(Y6,Ize,61,a,0,1)};sfb(SHe,'EcorePackageImpl/29',1262);feb(1236,1,OKe,nce);_.fk=function oce(a){return ZD(a,519)};_.gk=function pce(a){return $C(f7,{3:1,4:1,5:1,2033:1},598,a,0,1)};sfb(SHe,'EcorePackageImpl/3',1236);feb(1263,1,OKe,qce);_.fk=function rce(a){return ZD(a,582)};_.gk=function sce(a){return $C(Z6,rve,2039,a,0,1)};sfb(SHe,'EcorePackageImpl/30',1263);feb(1264,1,OKe,tce);_.fk=function uce(a){return ZD(a,160)};_.gk=function vce(a){return $C(Tbb,Ize,160,a,0,1)};sfb(SHe,'EcorePackageImpl/31',1264);feb(1265,1,OKe,wce);_.fk=function xce(a){return ZD(a,76)};_.gk=function yce(a){return $C(Jbb,PKe,76,a,0,1)};sfb(SHe,'EcorePackageImpl/32',1265);feb(1266,1,OKe,zce);_.fk=function Ace(a){return ZD(a,161)};_.gk=function Bce(a){return $C(ZI,Nve,161,a,0,1)};sfb(SHe,'EcorePackageImpl/33',1266);feb(1267,1,OKe,Cce);_.fk=function Dce(a){return ZD(a,17)};_.gk=function Ece(a){return $C(bJ,Nve,17,a,0,1)};sfb(SHe,'EcorePackageImpl/34',1267);feb(1268,1,OKe,Fce);_.fk=function Gce(a){return ZD(a,297)};_.gk=function Hce(a){return $C(UI,rve,297,a,0,1)};sfb(SHe,'EcorePackageImpl/35',1268);feb(1269,1,OKe,Ice);_.fk=function Jce(a){return ZD(a,168)};_.gk=function Kce(a){return $C(eJ,Nve,168,a,0,1)};sfb(SHe,'EcorePackageImpl/36',1269);feb(1270,1,OKe,Lce);_.fk=function Mce(a){return ZD(a,85)};_.gk=function Nce(a){return $C(VK,rve,85,a,0,1)};sfb(SHe,'EcorePackageImpl/37',1270);feb(1271,1,OKe,Oce);_.fk=function Pce(a){return ZD(a,599)};_.gk=function Qce(a){return $C(Aab,rve,599,a,0,1)};sfb(SHe,'EcorePackageImpl/38',1271);feb(1272,1,OKe,Rce);_.fk=function Sce(a){return false};_.gk=function Tce(a){return $C(zab,rve,2216,a,0,1)};sfb(SHe,'EcorePackageImpl/39',1272);feb(1237,1,OKe,Uce);_.fk=function Vce(a){return ZD(a,90)};_.gk=function Wce(a){return $C(h7,rve,29,a,0,1)};sfb(SHe,'EcorePackageImpl/4',1237);feb(1273,1,OKe,Xce);_.fk=function Yce(a){return ZD(a,191)};_.gk=function Zce(a){return $C(lJ,Nve,191,a,0,1)};sfb(SHe,'EcorePackageImpl/40',1273);feb(1274,1,OKe,$ce);_.fk=function _ce(a){return bE(a)};_.gk=function ade(a){return $C(qJ,Nve,2,a,6,1)};sfb(SHe,'EcorePackageImpl/41',1274);feb(1275,1,OKe,bde);_.fk=function cde(a){return ZD(a,596)};_.gk=function dde(a){return $C(a7,rve,596,a,0,1)};sfb(SHe,'EcorePackageImpl/42',1275);feb(1276,1,OKe,ede);_.fk=function fde(a){return false};_.gk=function gde(a){return $C($6,Nve,2217,a,0,1)};sfb(SHe,'EcorePackageImpl/43',1276);feb(1277,1,OKe,hde);_.fk=function ide(a){return ZD(a,44)};_.gk=function jde(a){return $C(UK,Zve,44,a,0,1)};sfb(SHe,'EcorePackageImpl/44',1277);feb(1238,1,OKe,kde);_.fk=function lde(a){return ZD(a,142)};_.gk=function mde(a){return $C(i7,rve,142,a,0,1)};sfb(SHe,'EcorePackageImpl/5',1238);feb(1239,1,OKe,nde);_.fk=function ode(a){return ZD(a,156)};_.gk=function pde(a){return $C(k7,rve,156,a,0,1)};sfb(SHe,'EcorePackageImpl/6',1239);feb(1240,1,OKe,qde);_.fk=function rde(a){return ZD(a,469)};_.gk=function sde(a){return $C(m7,rve,685,a,0,1)};sfb(SHe,'EcorePackageImpl/7',1240);feb(1241,1,OKe,tde);_.fk=function ude(a){return ZD(a,582)};_.gk=function vde(a){return $C(l7,rve,694,a,0,1)};sfb(SHe,'EcorePackageImpl/8',1241);feb(1242,1,OKe,wde);_.fk=function xde(a){return ZD(a,480)};_.gk=function yde(a){return $C(n7,rve,480,a,0,1)};sfb(SHe,'EcorePackageImpl/9',1242);feb(1038,2080,JJe,Cde);_.Mi=function Dde(a,b){zde(this,RD(b,424));};_.Qi=function Ede(a,b){Ade(this,a,RD(b,424));};sfb(SHe,'MinimalEObjectImpl/1ArrayDelegatingAdapterList',1038);feb(1039,152,GJe,Fde);_.jj=function Gde(){return this.a.a};sfb(SHe,'MinimalEObjectImpl/1ArrayDelegatingAdapterList/1',1039);feb(1067,1066,{},Ide);sfb('org.eclipse.emf.ecore.plugin','EcorePlugin',1067);var Aab=ufb(QKe,'Resource');feb(799,1524,RKe);_.Hl=function Mde(a){};_.Il=function Nde(a){};_.El=function Ode(){return !this.a&&(this.a=new Zde(this)),this.a};_.Fl=function Pde(a){var b,c,d,e,f;d=a.length;if(d>0){BFb(0,a.length);if(a.charCodeAt(0)==47){f=new cnb(4);e=1;for(b=1;b0&&(a=(AFb(0,c,a.length),a.substr(0,c)));}}}return Kde(this,a)};_.Gl=function Qde(){return this.c};_.Ib=function Rde(){var a;return nfb(this.Rm)+'@'+(a=tb(this)>>>0,a.toString(16))+" uri='"+this.d+"'"};_.b=false;sfb(SKe,'ResourceImpl',799);feb(1525,799,RKe,Sde);sfb(SKe,'BinaryResourceImpl',1525);feb(1190,708,QIe);_.bj=function Vde(a){return ZD(a,58)?Tde(this,RD(a,58)):ZD(a,599)?new dMd(RD(a,599).El()):dE(a)===dE(this.f)?RD(a,16).Kc():(jQd(),iQd.a)};_.Ob=function Wde(){return Ude(this)};_.a=false;sfb(ZJe,'EcoreUtil/ContentTreeIterator',1190);feb(1526,1190,QIe,Xde);_.bj=function Yde(a){return dE(a)===dE(this.f)?RD(a,15).Kc():new _je(RD(a,58))};sfb(SKe,'ResourceImpl/5',1526);feb(658,2092,nKe,Zde);_.Hc=function $de(a){return this.i<=4?PHd(this,a):ZD(a,54)&&RD(a,54).Jh()==this.a};_.Mi=function _de(a,b){a==this.i-1&&(this.a.b||(this.a.b=true,null));};_.Oi=function aee(a,b){a==0?this.a.b||(this.a.b=true,null):$Gd(this,a,b);};_.Qi=function bee(a,b){};_.Ri=function cee(a,b,c){};_.Lj=function dee(){return 2};_.jj=function eee(){return this.a};_.Mj=function fee(){return true};_.Nj=function gee(a,b){var c;c=RD(a,54);b=c.fi(this.a,b);return b};_.Oj=function hee(a,b){var c;c=RD(a,54);return c.fi(null,b)};_.Pj=function iee(){return false};_.Si=function jee(){return true};_.aj=function kee(a){return $C(r7,rve,58,a,0,1)};_.Yi=function lee(){return false};sfb(SKe,'ResourceImpl/ContentsEList',658);feb(970,2062,kwe,mee);_.fd=function nee(a){return this.a.Ki(a)};_.gc=function oee(){return this.a.gc()};sfb(ZJe,'AbstractSequentialInternalEList/1',970);var hke,ike,jke,kke;feb(634,1,{},Yee);var pee,qee;sfb(ZJe,'BasicExtendedMetaData',634);feb(1181,1,{},afe);_.Jl=function bfe(){return null};_.Kl=function cfe(){this.a==-2&&$ee(this,uee(this.d,this.b));return this.a};_.Ll=function dfe(){return null};_.Ml=function efe(){return yob(),yob(),vob};_.xe=function ffe(){this.c==fLe&&_ee(this,zee(this.d,this.b));return this.c};_.Nl=function gfe(){return 0};_.a=-2;_.c=fLe;sfb(ZJe,'BasicExtendedMetaData/EClassExtendedMetaDataImpl',1181);feb(1182,1,{},mfe);_.Jl=function nfe(){this.a==(ree(),pee)&&hfe(this,tee(this.f,this.b));return this.a};_.Kl=function ofe(){return 0};_.Ll=function pfe(){this.c==(ree(),pee)&&ife(this,xee(this.f,this.b));return this.c};_.Ml=function qfe(){!this.d&&jfe(this,yee(this.f,this.b));return this.d};_.xe=function rfe(){this.e==fLe&&kfe(this,zee(this.f,this.b));return this.e};_.Nl=function sfe(){this.g==-2&&lfe(this,Cee(this.f,this.b));return this.g};_.e=fLe;_.g=-2;sfb(ZJe,'BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl',1182);feb(1180,1,{},wfe);_.b=false;_.c=false;sfb(ZJe,'BasicExtendedMetaData/EPackageExtendedMetaDataImpl',1180);feb(1183,1,{},Jfe);_.c=-2;_.e=fLe;_.f=fLe;sfb(ZJe,'BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl',1183);feb(593,632,oKe,Kfe);_.Lj=function Lfe(){return this.c};_.ol=function Mfe(){return false};_.Wi=function Nfe(a,b){return b};_.c=0;sfb(ZJe,'EDataTypeEList',593);var Tbb=ufb(ZJe,'FeatureMap');feb(78,593,{3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,79:1,160:1,220:1,2036:1,71:1,97:1},Uge);_.bd=function Vge(a,b){Ofe(this,a,RD(b,76));};_.Fc=function Wge(a){return Rfe(this,RD(a,76))};_.Hi=function _ge(a){Wfe(this,RD(a,76));};_.Nj=function khe(a,b){return mge(this,RD(a,76),b)};_.Oj=function lhe(a,b){return oge(this,RD(a,76),b)};_.Ti=function nhe(a,b){return uge(this,a,b)};_.Wi=function phe(a,b){return zge(this,a,RD(b,76))};_.hd=function rhe(a,b){return Cge(this,a,RD(b,76))};_.Uj=function vhe(a,b){return Ige(this,RD(a,76),b)};_.Vj=function whe(a,b){return Kge(this,RD(a,76),b)};_.Wj=function xhe(a,b,c){return Lge(this,RD(a,76),RD(b,76),c)};_.Zi=function zhe(a,b){return Tge(this,a,RD(b,76))};_.Ol=function Xge(a,b){return Qfe(this,a,b)};_.cd=function Yge(a,b){var c,d,e,f,g,h,i,j,k;j=new ZHd(b.gc());for(e=b.Kc();e.Ob();){d=RD(e.Pb(),76);f=d.Lk();if(qke(this.e,f)){(!f.Si()||!cge(this,f,d.md())&&!PHd(j,d))&&WGd(j,d);}else {k=pke(this.e.Dh(),f);c=RD(this.g,124);g=true;for(h=0;h=0){b=a[this.c];if(this.k.am(b.Lk())){this.j=this.f?b:b.md();this.i=-2;return true}}this.i=-1;this.g=-1;return false};sfb(ZJe,'BasicFeatureMap/FeatureEIterator',420);feb(676,420,Jve,She);_.ul=function The(){return true};sfb(ZJe,'BasicFeatureMap/ResolvingFeatureEIterator',676);feb(968,496,uKe,Uhe);_.pj=function Vhe(){return this};sfb(ZJe,'EContentsEList/1',968);feb(969,496,uKe,Whe);_.ul=function Xhe(){return false};sfb(ZJe,'EContentsEList/2',969);feb(967,287,vKe,Yhe);_.wl=function Zhe(a){};_.Ob=function $he(){return false};_.Sb=function _he(){return false};sfb(ZJe,'EContentsEList/FeatureIteratorImpl/1',967);feb(840,593,oKe,aie);_.Ni=function bie(){this.a=true;};_.Qj=function cie(){return this.a};_.Gk=function die(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EDataTypeEList/Unsettable',840);feb(1958,593,oKe,eie);_.Si=function fie(){return true};sfb(ZJe,'EDataTypeUniqueEList',1958);feb(1959,840,oKe,gie);_.Si=function hie(){return true};sfb(ZJe,'EDataTypeUniqueEList/Unsettable',1959);feb(147,83,oKe,iie);_.nl=function jie(){return true};_.Wi=function kie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentEList/Resolving',147);feb(1184,555,oKe,lie);_.nl=function mie(){return true};_.Wi=function nie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentEList/Unsettable/Resolving',1184);feb(766,14,oKe,oie);_.Ni=function pie(){this.a=true;};_.Qj=function qie(){return this.a};_.Gk=function rie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectContainmentWithInverseEList/Unsettable',766);feb(1222,766,oKe,sie);_.nl=function tie(){return true};_.Wi=function uie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentWithInverseEList/Unsettable/Resolving',1222);feb(757,505,oKe,vie);_.Ni=function wie(){this.a=true;};_.Qj=function xie(){return this.a};_.Gk=function yie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectEList/Unsettable',757);feb(338,505,oKe,zie);_.nl=function Aie(){return true};_.Wi=function Bie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectResolvingEList',338);feb(1844,757,oKe,Cie);_.nl=function Die(){return true};_.Wi=function Eie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectResolvingEList/Unsettable',1844);feb(1527,1,{},Hie);var Fie;sfb(ZJe,'EObjectValidator',1527);feb(559,505,oKe,Iie);_.il=function Jie(){return this.d};_.jl=function Kie(){return this.b};_.Mj=function Lie(){return true};_.ml=function Mie(){return true};_.b=0;sfb(ZJe,'EObjectWithInverseEList',559);feb(1225,559,oKe,Nie);_.ll=function Oie(){return true};sfb(ZJe,'EObjectWithInverseEList/ManyInverse',1225);feb(635,559,oKe,Pie);_.Ni=function Qie(){this.a=true;};_.Qj=function Rie(){return this.a};_.Gk=function Sie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectWithInverseEList/Unsettable',635);feb(1224,635,oKe,Tie);_.ll=function Uie(){return true};sfb(ZJe,'EObjectWithInverseEList/Unsettable/ManyInverse',1224);feb(767,559,oKe,Vie);_.nl=function Wie(){return true};_.Wi=function Xie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectWithInverseResolvingEList',767);feb(32,767,oKe,Yie);_.ll=function Zie(){return true};sfb(ZJe,'EObjectWithInverseResolvingEList/ManyInverse',32);feb(768,635,oKe,$ie);_.nl=function _ie(){return true};_.Wi=function aje(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectWithInverseResolvingEList/Unsettable',768);feb(1223,768,oKe,bje);_.ll=function cje(){return true};sfb(ZJe,'EObjectWithInverseResolvingEList/Unsettable/ManyInverse',1223);feb(1185,632,oKe);_.Li=function dje(){return (this.b&1792)==0};_.Ni=function eje(){this.b|=1;};_.kl=function fje(){return (this.b&4)!=0};_.Mj=function gje(){return (this.b&40)!=0};_.ll=function hje(){return (this.b&16)!=0};_.ml=function ije(){return (this.b&8)!=0};_.nl=function jje(){return (this.b&cKe)!=0};_.al=function kje(){return (this.b&32)!=0};_.ol=function lje(){return (this.b&gwe)!=0};_.fk=function mje(a){return !this.d?this.Lk().Hk().fk(a):QRd(this.d,a)};_.Qj=function nje(){return (this.b&2)!=0?(this.b&1)!=0:this.i!=0};_.Si=function oje(){return (this.b&128)!=0};_.Gk=function qje(){var a;sLd(this);if((this.b&2)!=0){if(Mvd(this.e)){a=(this.b&1)!=0;this.b&=-2;eZd(this,new Q3d(this.e,2,BYd(this.e.Dh(),this.Lk()),a,false));}else {this.b&=-2;}}};_.Yi=function rje(){return (this.b&1536)==0};_.b=0;sfb(ZJe,'EcoreEList/Generic',1185);feb(1186,1185,oKe,sje);_.Lk=function tje(){return this.a};sfb(ZJe,'EcoreEList/Dynamic',1186);feb(765,66,PIe,uje);_.aj=function vje(a){return IMd(this.a.a,a)};sfb(ZJe,'EcoreEMap/1',765);feb(764,83,oKe,wje);_.Mi=function xje(a,b){UNd(this.b,RD(b,136));};_.Oi=function yje(a,b){TNd(this.b);};_.Pi=function zje(a,b,c){var d;++(d=this.b,RD(b,136),d).e;};_.Qi=function Aje(a,b){VNd(this.b,RD(b,136));};_.Ri=function Bje(a,b,c){VNd(this.b,RD(c,136));dE(c)===dE(b)&&RD(c,136).Ci(aOd(RD(b,136).ld()));UNd(this.b,RD(b,136));};sfb(ZJe,'EcoreEMap/DelegateEObjectContainmentEList',764);feb(1220,141,_Je,Cje);sfb(ZJe,'EcoreEMap/Unsettable',1220);feb(1221,764,oKe,Dje);_.Ni=function Eje(){this.a=true;};_.Qj=function Fje(){return this.a};_.Gk=function Gje(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList',1221);feb(1189,215,Hxe,Zje);_.a=false;_.b=false;sfb(ZJe,'EcoreUtil/Copier',1189);feb(759,1,Ave,_je);_.Nb=function ake(a){Ztb(this,a);};_.Ob=function bke(){return $je(this)};_.Pb=function cke(){var a;$je(this);a=this.b;this.b=null;return a};_.Qb=function dke(){this.a.Qb();};sfb(ZJe,'EcoreUtil/ProperContentIterator',759);feb(1528,1527,{},gke);var eke;sfb(ZJe,'EcoreValidator',1528);var mke;ufb(ZJe,'FeatureMapUtil/Validator');feb(1295,1,{2041:1},rke);_.am=function ske(a){return true};sfb(ZJe,'FeatureMapUtil/1',1295);feb(773,1,{2041:1},wke);_.am=function xke(a){var b;if(this.c==a)return true;b=TD(Wjb(this.a,a));if(b==null){if(vke(this,a)){yke(this.a,a,(Geb(),Feb));return true}else {yke(this.a,a,(Geb(),Eeb));return false}}else {return b==(Geb(),Feb)}};_.e=false;var tke;sfb(ZJe,'FeatureMapUtil/BasicValidator',773);feb(774,45,Hxe,zke);sfb(ZJe,'FeatureMapUtil/BasicValidator/Cache',774);feb(509,56,{20:1,31:1,56:1,16:1,15:1,61:1,79:1,71:1,97:1},Eke);_.bd=function Fke(a,b){Pfe(this.c,this.b,a,b);};_.Fc=function Gke(a){return Qfe(this.c,this.b,a)};_.cd=function Hke(a,b){return Sfe(this.c,this.b,a,b)};_.Gc=function Ike(a){return Ake(this,a)};_.Gi=function Jke(a,b){Ufe(this.c,this.b,a,b);};_.Wk=function Kke(a,b){return Xfe(this.c,this.b,a,b)};_.$i=function Lke(a){return hge(this.c,this.b,a,false)};_.Ii=function Mke(){return Yfe(this.c,this.b)};_.Ji=function Nke(){return Zfe(this.c,this.b)};_.Ki=function Oke(a){return $fe(this.c,this.b,a)};_.Xk=function Pke(a,b){return Bke(this,a,b)};_.$b=function Qke(){Cke(this);};_.Hc=function Rke(a){return cge(this.c,this.b,a)};_.Ic=function Ske(a){return ege(this.c,this.b,a)};_.Xb=function Tke(a){return hge(this.c,this.b,a,true)};_.Fk=function Uke(a){return this};_.dd=function Vke(a){return jge(this.c,this.b,a)};_.dc=function Wke(){return Dke(this)};_.Qj=function Xke(){return !pge(this.c,this.b)};_.Kc=function Yke(){return qge(this.c,this.b)};_.ed=function Zke(){return sge(this.c,this.b)};_.fd=function $ke(a){return tge(this.c,this.b,a)};_.Ti=function _ke(a,b){return vge(this.c,this.b,a,b)};_.Ui=function ale(a,b){wge(this.c,this.b,a,b);};_.gd=function ble(a){return xge(this.c,this.b,a)};_.Mc=function cle(a){return yge(this.c,this.b,a)};_.hd=function dle(a,b){return Ege(this.c,this.b,a,b)};_.Wb=function ele(a){bge(this.c,this.b);Ake(this,RD(a,15));};_.gc=function fle(){return Nge(this.c,this.b)};_.Pc=function gle(){return Oge(this.c,this.b)};_.Qc=function hle(a){return Qge(this.c,this.b,a)};_.Ib=function ile(){var a,b;b=new Qhb;b.a+='[';for(a=Yfe(this.c,this.b);Bhe(a);){Nhb(b,Ghb(Dhe(a)));Bhe(a)&&(b.a+=pve,b);}b.a+=']';return b.a};_.Gk=function jle(){bge(this.c,this.b);};sfb(ZJe,'FeatureMapUtil/FeatureEList',509);feb(644,39,GJe,lle);_.hj=function mle(a){return kle(this,a)};_.mj=function nle(a){var b,c,d,e,f,g,h;switch(this.d){case 1:case 2:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.g=a.ij();a.gj()==1&&(this.d=1);return true}break}case 3:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=5;b=new ZHd(2);WGd(b,this.g);WGd(b,a.ij());this.g=b;return true}break}}break}case 5:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){c=RD(this.g,16);c.Fc(a.ij());return true}break}}break}case 4:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=1;this.g=a.ij();return true}break}case 4:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=6;h=new ZHd(2);WGd(h,this.n);WGd(h,a.kj());this.n=h;g=cD(WC(kE,1),Pwe,28,15,[this.o,a.lj()]);this.g=g;return true}break}}break}case 6:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){c=RD(this.n,16);c.Fc(a.kj());g=RD(this.g,53);d=$C(kE,Pwe,28,g.length+1,15,1);hib(g,0,d,0,g.length);d[g.length]=a.lj();this.g=d;return true}break}}break}}return false};sfb(ZJe,'FeatureMapUtil/FeatureENotificationImpl',644);feb(564,509,{20:1,31:1,56:1,16:1,15:1,61:1,79:1,160:1,220:1,2036:1,71:1,97:1},ole);_.Ol=function ple(a,b){return Qfe(this.c,a,b)};_.Pl=function qle(a,b,c){return Xfe(this.c,a,b,c)};_.Ql=function rle(a,b,c){return age(this.c,a,b,c)};_.Rl=function sle(){return this};_.Sl=function tle(a,b){return ige(this.c,a,b)};_.Tl=function ule(a){return RD(hge(this.c,this.b,a,false),76).Lk()};_.Ul=function vle(a){return RD(hge(this.c,this.b,a,false),76).md()};_.Vl=function wle(){return this.a};_.Wl=function xle(a){return !pge(this.c,a)};_.Xl=function yle(a,b){Fge(this.c,a,b);};_.Yl=function zle(a){return Gge(this.c,a)};_.Zl=function Ale(a){Sge(this.c,a);};sfb(ZJe,'FeatureMapUtil/FeatureFeatureMap',564);feb(1294,1,$Je,Ble);_.Fk=function Cle(a){return hge(this.b,this.a,-1,a)};_.Qj=function Dle(){return !pge(this.b,this.a)};_.Wb=function Ele(a){Fge(this.b,this.a,a);};_.Gk=function Fle(){bge(this.b,this.a);};sfb(ZJe,'FeatureMapUtil/FeatureValue',1294);var Gle,Hle,Ile,Jle,Kle;var Vbb=ufb(hLe,'AnyType');feb(680,63,swe,Mle);sfb(hLe,'InvalidDatatypeValueException',680);var Xbb=ufb(hLe,iLe);var Ybb=ufb(hLe,jLe);var Zbb=ufb(hLe,kLe);var Nle;var Ple;var Rle,Sle,Tle,Ule,Vle,Wle,Xle,Yle,Zle,$le,_le,ame,bme,cme,dme,eme,fme,gme,hme,ime,jme,kme,lme,mme;feb(844,516,{110:1,94:1,93:1,58:1,54:1,99:1,857:1},ome);_.Lh=function pme(a,b,c){switch(a){case 0:if(c)return !this.c&&(this.c=new Uge(this,0)),this.c;return !this.c&&(this.c=new Uge(this,0)),this.c.b;case 1:if(c)return !this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160);return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Vl();case 2:if(c)return !this.b&&(this.b=new Uge(this,2)),this.b;return !this.b&&(this.b=new Uge(this,2)),this.b.b;}return zvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Uh=function qme(a,b,c){var d;switch(b){case 0:return !this.c&&(this.c=new Uge(this,0)),_fe(this.c,a,c);case 1:return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),71)).Xk(a,c);case 2:return !this.b&&(this.b=new Uge(this,2)),_fe(this.b,a,c);}return d=RD(vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),b),69),d.wk().Ak(this,Yvd(this),b-AYd(this.ii()),a,c)};_.Wh=function rme(a){switch(a){case 0:return !!this.c&&this.c.i!=0;case 1:return !(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).dc();case 2:return !!this.b&&this.b.i!=0;}return Avd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function sme(a,b){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));Dge(this.c,b);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Wb(b);return;case 2:!this.b&&(this.b=new Uge(this,2));Dge(this.b,b);return;}Bvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function tme(){return nme(),Rle};_.ki=function ume(a){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));sLd(this.c);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).$b();return;case 2:!this.b&&(this.b=new Uge(this,2));sLd(this.b);return;}Cvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function vme(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (mixed: ';Mhb(a,this.c);a.a+=', anyAttribute: ';Mhb(a,this.b);a.a+=')';return a.a};sfb(lLe,'AnyTypeImpl',844);feb(681,516,{110:1,94:1,93:1,58:1,54:1,99:1,2119:1,681:1},yme);_.Lh=function zme(a,b,c){switch(a){case 0:return this.a;case 1:return this.b;}return zvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Wh=function Ame(a){switch(a){case 0:return this.a!=null;case 1:return this.b!=null;}return Avd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Bme(a,b){switch(a){case 0:wme(this,WD(b));return;case 1:xme(this,WD(b));return;}Bvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Cme(){return nme(),cme};_.ki=function Dme(a){switch(a){case 0:this.a=null;return;case 1:this.b=null;return;}Cvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function Eme(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (data: ';Nhb(a,this.a);a.a+=', target: ';Nhb(a,this.b);a.a+=')';return a.a};_.a=null;_.b=null;sfb(lLe,'ProcessingInstructionImpl',681);feb(682,844,{110:1,94:1,93:1,58:1,54:1,99:1,857:1,2120:1,682:1},Hme);_.Lh=function Ime(a,b,c){switch(a){case 0:if(c)return !this.c&&(this.c=new Uge(this,0)),this.c;return !this.c&&(this.c=new Uge(this,0)),this.c.b;case 1:if(c)return !this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160);return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Vl();case 2:if(c)return !this.b&&(this.b=new Uge(this,2)),this.b;return !this.b&&(this.b=new Uge(this,2)),this.b.b;case 3:return !this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true));case 4:return Ije(this.a,(!this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))));case 5:return this.a;}return zvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Wh=function Jme(a){switch(a){case 0:return !!this.c&&this.c.i!=0;case 1:return !(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).dc();case 2:return !!this.b&&this.b.i!=0;case 3:return !this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))!=null;case 4:return Ije(this.a,(!this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))))!=null;case 5:return !!this.a;}return Avd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Kme(a,b){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));Dge(this.c,b);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Wb(b);return;case 2:!this.b&&(this.b=new Uge(this,2));Dge(this.b,b);return;case 3:Gme(this,WD(b));return;case 4:Gme(this,Hje(this.a,b));return;case 5:Fme(this,RD(b,156));return;}Bvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Lme(){return nme(),eme};_.ki=function Mme(a){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));sLd(this.c);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).$b();return;case 2:!this.b&&(this.b=new Uge(this,2));sLd(this.b);return;case 3:!this.c&&(this.c=new Uge(this,0));Fge(this.c,(nme(),fme),null);return;case 4:Gme(this,Hje(this.a,null));return;case 5:this.a=null;return;}Cvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};sfb(lLe,'SimpleAnyTypeImpl',682);feb(683,516,{110:1,94:1,93:1,58:1,54:1,99:1,2121:1,683:1},Nme);_.Lh=function Ome(a,b,c){switch(a){case 0:if(c)return !this.a&&(this.a=new Uge(this,0)),this.a;return !this.a&&(this.a=new Uge(this,0)),this.a.b;case 1:return c?(!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),this.b):(!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),dOd(this.b));case 2:return c?(!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),this.c):(!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),dOd(this.c));case 3:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),ime));case 4:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),jme));case 5:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),lme));case 6:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),mme));}return zvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Uh=function Pme(a,b,c){var d;switch(b){case 0:return !this.a&&(this.a=new Uge(this,0)),_fe(this.a,a,c);case 1:return !this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),BVd(this.b,a,c);case 2:return !this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),BVd(this.c,a,c);case 5:return !this.a&&(this.a=new Uge(this,0)),Bke(rge(this.a,(nme(),lme)),a,c);}return d=RD(vYd((this.j&2)==0?(nme(),hme):(!this.k&&(this.k=new fUd),this.k).Nk(),b),69),d.wk().Ak(this,Yvd(this),b-AYd((nme(),hme)),a,c)};_.Wh=function Qme(a){switch(a){case 0:return !!this.a&&this.a.i!=0;case 1:return !!this.b&&this.b.f!=0;case 2:return !!this.c&&this.c.f!=0;case 3:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),ime)));case 4:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),jme)));case 5:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),lme)));case 6:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),mme)));}return Avd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Rme(a,b){switch(a){case 0:!this.a&&(this.a=new Uge(this,0));Dge(this.a,b);return;case 1:!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1));CVd(this.b,b);return;case 2:!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2));CVd(this.c,b);return;case 3:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),ime)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,ime),RD(b,16));return;case 4:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),jme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,jme),RD(b,16));return;case 5:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),lme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,lme),RD(b,16));return;case 6:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),mme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,mme),RD(b,16));return;}Bvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Sme(){return nme(),hme};_.ki=function Tme(a){switch(a){case 0:!this.a&&(this.a=new Uge(this,0));sLd(this.a);return;case 1:!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1));this.b.c.$b();return;case 2:!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2));this.c.c.$b();return;case 3:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),ime)));return;case 4:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),jme)));return;case 5:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),lme)));return;case 6:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),mme)));return;}Cvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function Ume(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (mixed: ';Mhb(a,this.a);a.a+=')';return a.a};sfb(lLe,'XMLTypeDocumentRootImpl',683);feb(2028,720,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1,2122:1},rne);_.ri=function sne(a,b){switch(a.hk()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return b==null?null:jeb(b);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return WD(b);case 6:return _me(RD(b,195));case 12:case 47:case 49:case 11:return tAd(this,a,b);case 13:return b==null?null:yib(RD(b,247));case 15:case 14:return b==null?null:ane(Kfb(UD(b)));case 17:return bne((nme(),b));case 18:return bne(b);case 21:case 20:return b==null?null:cne(RD(b,161).a);case 27:return dne(RD(b,195));case 30:return ene((nme(),RD(b,15)));case 31:return ene(RD(b,15));case 40:return hne((nme(),b));case 42:return fne((nme(),b));case 43:return fne(b);case 59:case 48:return gne((nme(),b));default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function tne(a){var b,c,d,e,f;switch(a.G==-1&&(a.G=(c=BXd(a),c?fZd(c.vi(),a):-1)),a.G){case 0:return b=new ome,b;case 1:return d=new yme,d;case 2:return e=new Hme,e;case 3:return f=new Nme,f;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function une(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;switch(a.hk()){case 5:case 52:case 4:return b;case 6:return ine(b);case 8:case 7:return b==null?null:$me(b);case 9:return b==null?null:$eb(Oeb((d=nue(b,true),d.length>0&&(BFb(0,d.length),d.charCodeAt(0)==43)?(BFb(1,d.length+1),d.substr(1)):d),-128,127)<<24>>24);case 10:return b==null?null:$eb(Oeb((e=nue(b,true),e.length>0&&(BFb(0,e.length),e.charCodeAt(0)==43)?(BFb(1,e.length+1),e.substr(1)):e),-128,127)<<24>>24);case 11:return WD(uAd(this,(nme(),Vle),b));case 12:return WD(uAd(this,(nme(),Wle),b));case 13:return b==null?null:new Bib(nue(b,true));case 15:case 14:return jne(b);case 16:return WD(uAd(this,(nme(),Xle),b));case 17:return kne((nme(),b));case 18:return kne(b);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return nue(b,true);case 21:case 20:return lne(b);case 22:return WD(uAd(this,(nme(),Yle),b));case 23:return WD(uAd(this,(nme(),Zle),b));case 24:return WD(uAd(this,(nme(),$le),b));case 25:return WD(uAd(this,(nme(),_le),b));case 26:return WD(uAd(this,(nme(),ame),b));case 27:return mne(b);case 30:return nne((nme(),b));case 31:return nne(b);case 32:return b==null?null:sgb(Oeb((k=nue(b,true),k.length>0&&(BFb(0,k.length),k.charCodeAt(0)==43)?(BFb(1,k.length+1),k.substr(1)):k),qwe,lve));case 33:return b==null?null:new ejb((l=nue(b,true),l.length>0&&(BFb(0,l.length),l.charCodeAt(0)==43)?(BFb(1,l.length+1),l.substr(1)):l));case 34:return b==null?null:sgb(Oeb((m=nue(b,true),m.length>0&&(BFb(0,m.length),m.charCodeAt(0)==43)?(BFb(1,m.length+1),m.substr(1)):m),qwe,lve));case 36:return b==null?null:Hgb(Peb((n=nue(b,true),n.length>0&&(BFb(0,n.length),n.charCodeAt(0)==43)?(BFb(1,n.length+1),n.substr(1)):n)));case 37:return b==null?null:Hgb(Peb((o=nue(b,true),o.length>0&&(BFb(0,o.length),o.charCodeAt(0)==43)?(BFb(1,o.length+1),o.substr(1)):o)));case 40:return qne((nme(),b));case 42:return one((nme(),b));case 43:return one(b);case 44:return b==null?null:new ejb((p=nue(b,true),p.length>0&&(BFb(0,p.length),p.charCodeAt(0)==43)?(BFb(1,p.length+1),p.substr(1)):p));case 45:return b==null?null:new ejb((q=nue(b,true),q.length>0&&(BFb(0,q.length),q.charCodeAt(0)==43)?(BFb(1,q.length+1),q.substr(1)):q));case 46:return nue(b,false);case 47:return WD(uAd(this,(nme(),bme),b));case 59:case 48:return pne((nme(),b));case 49:return WD(uAd(this,(nme(),dme),b));case 50:return b==null?null:bhb(Oeb((r=nue(b,true),r.length>0&&(BFb(0,r.length),r.charCodeAt(0)==43)?(BFb(1,r.length+1),r.substr(1)):r),BKe,32767)<<16>>16);case 51:return b==null?null:bhb(Oeb((f=nue(b,true),f.length>0&&(BFb(0,f.length),f.charCodeAt(0)==43)?(BFb(1,f.length+1),f.substr(1)):f),BKe,32767)<<16>>16);case 53:return WD(uAd(this,(nme(),gme),b));case 55:return b==null?null:bhb(Oeb((g=nue(b,true),g.length>0&&(BFb(0,g.length),g.charCodeAt(0)==43)?(BFb(1,g.length+1),g.substr(1)):g),BKe,32767)<<16>>16);case 56:return b==null?null:bhb(Oeb((h=nue(b,true),h.length>0&&(BFb(0,h.length),h.charCodeAt(0)==43)?(BFb(1,h.length+1),h.substr(1)):h),BKe,32767)<<16>>16);case 57:return b==null?null:Hgb(Peb((i=nue(b,true),i.length>0&&(BFb(0,i.length),i.charCodeAt(0)==43)?(BFb(1,i.length+1),i.substr(1)):i)));case 58:return b==null?null:Hgb(Peb((j=nue(b,true),j.length>0&&(BFb(0,j.length),j.charCodeAt(0)==43)?(BFb(1,j.length+1),j.substr(1)):j)));case 60:return b==null?null:sgb(Oeb((c=nue(b,true),c.length>0&&(BFb(0,c.length),c.charCodeAt(0)==43)?(BFb(1,c.length+1),c.substr(1)):c),qwe,lve));case 61:return b==null?null:sgb(Oeb(nue(b,true),qwe,lve));default:throw Adb(new agb(VHe+a.xe()+WHe));}};var Vme,Wme,Xme,Yme;sfb(lLe,'XMLTypeFactoryImpl',2028);feb(594,184,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1,2044:1,594:1},Bne);_.N=false;_.O=false;var wne=false;sfb(lLe,'XMLTypePackageImpl',594);feb(1961,1,{851:1},Ene);_.Kk=function Fne(){return rue(),que};sfb(lLe,'XMLTypePackageImpl/1',1961);feb(1970,1,OKe,Gne);_.fk=function Hne(a){return bE(a)};_.gk=function Ine(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/10',1970);feb(1971,1,OKe,Jne);_.fk=function Kne(a){return bE(a)};_.gk=function Lne(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/11',1971);feb(1972,1,OKe,Mne);_.fk=function Nne(a){return bE(a)};_.gk=function One(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/12',1972);feb(1973,1,OKe,Pne);_.fk=function Qne(a){return _D(a)};_.gk=function Rne(a){return $C(VI,Nve,345,a,7,1)};sfb(lLe,'XMLTypePackageImpl/13',1973);feb(1974,1,OKe,Sne);_.fk=function Tne(a){return bE(a)};_.gk=function Une(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/14',1974);feb(1975,1,OKe,Vne);_.fk=function Wne(a){return ZD(a,15)};_.gk=function Xne(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/15',1975);feb(1976,1,OKe,Yne);_.fk=function Zne(a){return ZD(a,15)};_.gk=function $ne(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/16',1976);feb(1977,1,OKe,_ne);_.fk=function aoe(a){return bE(a)};_.gk=function boe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/17',1977);feb(1978,1,OKe,coe);_.fk=function doe(a){return ZD(a,161)};_.gk=function eoe(a){return $C(ZI,Nve,161,a,0,1)};sfb(lLe,'XMLTypePackageImpl/18',1978);feb(1979,1,OKe,foe);_.fk=function goe(a){return bE(a)};_.gk=function hoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/19',1979);feb(1962,1,OKe,ioe);_.fk=function joe(a){return ZD(a,857)};_.gk=function koe(a){return $C(Vbb,rve,857,a,0,1)};sfb(lLe,'XMLTypePackageImpl/2',1962);feb(1980,1,OKe,loe);_.fk=function moe(a){return bE(a)};_.gk=function noe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/20',1980);feb(1981,1,OKe,ooe);_.fk=function poe(a){return bE(a)};_.gk=function qoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/21',1981);feb(1982,1,OKe,roe);_.fk=function soe(a){return bE(a)};_.gk=function toe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/22',1982);feb(1983,1,OKe,uoe);_.fk=function voe(a){return bE(a)};_.gk=function woe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/23',1983);feb(1984,1,OKe,xoe);_.fk=function yoe(a){return ZD(a,195)};_.gk=function zoe(a){return $C(gE,Nve,195,a,0,2)};sfb(lLe,'XMLTypePackageImpl/24',1984);feb(1985,1,OKe,Aoe);_.fk=function Boe(a){return bE(a)};_.gk=function Coe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/25',1985);feb(1986,1,OKe,Doe);_.fk=function Eoe(a){return bE(a)};_.gk=function Foe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/26',1986);feb(1987,1,OKe,Goe);_.fk=function Hoe(a){return ZD(a,15)};_.gk=function Ioe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/27',1987);feb(1988,1,OKe,Joe);_.fk=function Koe(a){return ZD(a,15)};_.gk=function Loe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/28',1988);feb(1989,1,OKe,Moe);_.fk=function Noe(a){return bE(a)};_.gk=function Ooe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/29',1989);feb(1963,1,OKe,Poe);_.fk=function Qoe(a){return ZD(a,681)};_.gk=function Roe(a){return $C(Xbb,rve,2119,a,0,1)};sfb(lLe,'XMLTypePackageImpl/3',1963);feb(1990,1,OKe,Soe);_.fk=function Toe(a){return ZD(a,17)};_.gk=function Uoe(a){return $C(bJ,Nve,17,a,0,1)};sfb(lLe,'XMLTypePackageImpl/30',1990);feb(1991,1,OKe,Voe);_.fk=function Woe(a){return bE(a)};_.gk=function Xoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/31',1991);feb(1992,1,OKe,Yoe);_.fk=function Zoe(a){return ZD(a,168)};_.gk=function $oe(a){return $C(eJ,Nve,168,a,0,1)};sfb(lLe,'XMLTypePackageImpl/32',1992);feb(1993,1,OKe,_oe);_.fk=function ape(a){return bE(a)};_.gk=function bpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/33',1993);feb(1994,1,OKe,cpe);_.fk=function dpe(a){return bE(a)};_.gk=function epe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/34',1994);feb(1995,1,OKe,fpe);_.fk=function gpe(a){return bE(a)};_.gk=function hpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/35',1995);feb(1996,1,OKe,ipe);_.fk=function jpe(a){return bE(a)};_.gk=function kpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/36',1996);feb(1997,1,OKe,lpe);_.fk=function mpe(a){return ZD(a,15)};_.gk=function npe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/37',1997);feb(1998,1,OKe,ope);_.fk=function ppe(a){return ZD(a,15)};_.gk=function qpe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/38',1998);feb(1999,1,OKe,rpe);_.fk=function spe(a){return bE(a)};_.gk=function tpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/39',1999);feb(1964,1,OKe,upe);_.fk=function vpe(a){return ZD(a,682)};_.gk=function wpe(a){return $C(Ybb,rve,2120,a,0,1)};sfb(lLe,'XMLTypePackageImpl/4',1964);feb(2000,1,OKe,xpe);_.fk=function ype(a){return bE(a)};_.gk=function zpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/40',2000);feb(2001,1,OKe,Ape);_.fk=function Bpe(a){return bE(a)};_.gk=function Cpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/41',2001);feb(2002,1,OKe,Dpe);_.fk=function Epe(a){return bE(a)};_.gk=function Fpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/42',2002);feb(2003,1,OKe,Gpe);_.fk=function Hpe(a){return bE(a)};_.gk=function Ipe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/43',2003);feb(2004,1,OKe,Jpe);_.fk=function Kpe(a){return bE(a)};_.gk=function Lpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/44',2004);feb(2005,1,OKe,Mpe);_.fk=function Npe(a){return ZD(a,191)};_.gk=function Ope(a){return $C(lJ,Nve,191,a,0,1)};sfb(lLe,'XMLTypePackageImpl/45',2005);feb(2006,1,OKe,Ppe);_.fk=function Qpe(a){return bE(a)};_.gk=function Rpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/46',2006);feb(2007,1,OKe,Spe);_.fk=function Tpe(a){return bE(a)};_.gk=function Upe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/47',2007);feb(2008,1,OKe,Vpe);_.fk=function Wpe(a){return bE(a)};_.gk=function Xpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/48',2008);feb(2009,1,OKe,Ype);_.fk=function Zpe(a){return ZD(a,191)};_.gk=function $pe(a){return $C(lJ,Nve,191,a,0,1)};sfb(lLe,'XMLTypePackageImpl/49',2009);feb(1965,1,OKe,_pe);_.fk=function aqe(a){return ZD(a,683)};_.gk=function bqe(a){return $C(Zbb,rve,2121,a,0,1)};sfb(lLe,'XMLTypePackageImpl/5',1965);feb(2010,1,OKe,cqe);_.fk=function dqe(a){return ZD(a,168)};_.gk=function eqe(a){return $C(eJ,Nve,168,a,0,1)};sfb(lLe,'XMLTypePackageImpl/50',2010);feb(2011,1,OKe,fqe);_.fk=function gqe(a){return bE(a)};_.gk=function hqe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/51',2011);feb(2012,1,OKe,iqe);_.fk=function jqe(a){return ZD(a,17)};_.gk=function kqe(a){return $C(bJ,Nve,17,a,0,1)};sfb(lLe,'XMLTypePackageImpl/52',2012);feb(1966,1,OKe,lqe);_.fk=function mqe(a){return bE(a)};_.gk=function nqe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/6',1966);feb(1967,1,OKe,oqe);_.fk=function pqe(a){return ZD(a,195)};_.gk=function qqe(a){return $C(gE,Nve,195,a,0,2)};sfb(lLe,'XMLTypePackageImpl/7',1967);feb(1968,1,OKe,rqe);_.fk=function sqe(a){return $D(a)};_.gk=function tqe(a){return $C(QI,Nve,485,a,8,1)};sfb(lLe,'XMLTypePackageImpl/8',1968);feb(1969,1,OKe,uqe);_.fk=function vqe(a){return ZD(a,222)};_.gk=function wqe(a){return $C(RI,Nve,222,a,0,1)};sfb(lLe,'XMLTypePackageImpl/9',1969);var xqe,yqe;var Eqe,Fqe;var Jqe;feb(55,63,swe,Lqe);sfb(LLe,'RegEx/ParseException',55);feb(836,1,{},Tqe);_.bm=function Uqe(a){return ac*16)throw Adb(new Lqe(TId((Hde(),tJe))));c=c*16+e;}while(true);if(this.a!=125)throw Adb(new Lqe(TId((Hde(),uJe))));if(c>MLe)throw Adb(new Lqe(TId((Hde(),vJe))));a=c;}else {e=0;if(this.c!=0||(e=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));c=e;Mqe(this);if(this.c!=0||(e=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));c=c*16+e;a=c;}break;case 117:d=0;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;a=b;break;case 118:Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;if(b>MLe)throw Adb(new Lqe(TId((Hde(),'parser.descappe.4'))));a=b;break;case 65:case 90:case 122:throw Adb(new Lqe(TId((Hde(),wJe))));}return a};_.dm=function Wqe(a){var b,c;switch(a){case 100:c=(this.e&32)==32?hte('Nd',true):(Vse(),Bse);break;case 68:c=(this.e&32)==32?hte('Nd',false):(Vse(),Ise);break;case 119:c=(this.e&32)==32?hte('IsWord',true):(Vse(),Rse);break;case 87:c=(this.e&32)==32?hte('IsWord',false):(Vse(),Kse);break;case 115:c=(this.e&32)==32?hte('IsSpace',true):(Vse(),Mse);break;case 83:c=(this.e&32)==32?hte('IsSpace',false):(Vse(),Jse);break;default:throw Adb(new yz((b=a,NLe+b.toString(16))));}return c};_.em=function Yqe(a){var b,c,d,e,f,g,h,i,j,k,l,m;this.b=1;Mqe(this);b=null;if(this.c==0&&this.a==94){Mqe(this);if(a){k=(Vse(),Vse(),new xte(5));}else {b=(Vse(),Vse(),new xte(4));rte(b,0,MLe);k=(new xte(4));}}else {k=(Vse(),Vse(),new xte(4));}e=true;while((m=this.c)!=1){if(m==0&&this.a==93&&!e)break;e=false;c=this.a;d=false;if(m==10){switch(c){case 100:case 68:case 119:case 87:case 115:case 83:ute(k,this.dm(c));d=true;break;case 105:case 73:case 99:case 67:c=this.um(k,c);c<0&&(d=true);break;case 112:case 80:l=Sqe(this,c);if(!l)throw Adb(new Lqe(TId((Hde(),hJe))));ute(k,l);d=true;break;default:c=this.cm();}}else if(m==20){g=phb(this.i,58,this.d);if(g<0)throw Adb(new Lqe(TId((Hde(),iJe))));h=true;if(ihb(this.i,this.d)==94){++this.d;h=false;}f=zhb(this.i,this.d,g);i=ite(f,h,(this.e&512)==512);if(!i)throw Adb(new Lqe(TId((Hde(),kJe))));ute(k,i);d=true;if(g+1>=this.j||ihb(this.i,g+1)!=93)throw Adb(new Lqe(TId((Hde(),iJe))));this.d=g+2;}Mqe(this);if(!d){if(this.c!=0||this.a!=45){rte(k,c,c);}else {Mqe(this);if((m=this.c)==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(m==0&&this.a==93){rte(k,c,c);rte(k,45,45);}else {j=this.a;m==10&&(j=this.cm());Mqe(this);rte(k,c,j);}}}(this.e&gwe)==gwe&&this.c==0&&this.a==44&&Mqe(this);}if(this.c==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(b){wte(b,k);k=b;}vte(k);ste(k);this.b=0;Mqe(this);return k};_.fm=function Zqe(){var a,b,c,d;c=this.em(false);while((d=this.c)!=7){a=this.a;if(d==0&&(a==45||a==38)||d==4){Mqe(this);if(this.c!=9)throw Adb(new Lqe(TId((Hde(),pJe))));b=this.em(false);if(d==4)ute(c,b);else if(a==45)wte(c,b);else if(a==38)tte(c,b);else throw Adb(new yz('ASSERT'))}else {throw Adb(new Lqe(TId((Hde(),qJe))))}}Mqe(this);return c};_.gm=function $qe(){var a,b;a=this.a-48;b=(Vse(),Vse(),new eue(12,null,a));!this.g&&(this.g=new gyb);dyb(this.g,new Bte(a));Mqe(this);return b};_.hm=function _qe(){Mqe(this);return Vse(),Nse};_.im=function are(){Mqe(this);return Vse(),Lse};_.jm=function bre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.km=function cre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.lm=function dre(){Mqe(this);return fte()};_.mm=function ere(){Mqe(this);return Vse(),Pse};_.nm=function fre(){Mqe(this);return Vse(),Sse};_.om=function gre(){var a;if(this.d>=this.j||((a=ihb(this.i,this.d++))&65504)!=64)throw Adb(new Lqe(TId((Hde(),dJe))));Mqe(this);return Vse(),Vse(),new Hte(0,a-64)};_.pm=function hre(){Mqe(this);return gte()};_.qm=function ire(){Mqe(this);return Vse(),Tse};_.rm=function jre(){var a;a=(Vse(),Vse(),new Hte(0,105));Mqe(this);return a};_.sm=function kre(){Mqe(this);return Vse(),Qse};_.tm=function lre(){Mqe(this);return Vse(),Ose};_.um=function mre(a,b){return this.cm()};_.vm=function nre(){Mqe(this);return Vse(),Gse};_.wm=function ore(){var a,b,c,d,e;if(this.d+1>=this.j)throw Adb(new Lqe(TId((Hde(),aJe))));d=-1;b=null;a=ihb(this.i,this.d);if(49<=a&&a<=57){d=a-48;!this.g&&(this.g=new gyb);dyb(this.g,new Bte(d));++this.d;if(ihb(this.i,this.d)!=41)throw Adb(new Lqe(TId((Hde(),ZIe))));++this.d;}else {a==63&&--this.d;Mqe(this);b=Pqe(this);switch(b.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));break;default:throw Adb(new Lqe(TId((Hde(),bJe))));}}Mqe(this);e=Qqe(this);c=null;if(e.e==2){if(e.Pm()!=2)throw Adb(new Lqe(TId((Hde(),cJe))));c=e.Lm(1);e=e.Lm(0);}if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return Vse(),Vse(),new Ute(d,b,e,c)};_.xm=function pre(){Mqe(this);return Vse(),Hse};_.ym=function qre(){var a;Mqe(this);a=_se(24,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.zm=function rre(){var a;Mqe(this);a=_se(20,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Am=function sre(){var a;Mqe(this);a=_se(22,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Bm=function tre(){var a,b,c,d,e;a=0;c=0;b=-1;while(this.d=this.j)throw Adb(new Lqe(TId((Hde(),$Ie))));if(b==45){++this.d;while(this.d=this.j)throw Adb(new Lqe(TId((Hde(),$Ie))))}if(b==58){++this.d;Mqe(this);d=ate(Qqe(this),a,c);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);}else if(b==41){++this.d;Mqe(this);d=ate(Qqe(this),a,c);}else throw Adb(new Lqe(TId((Hde(),_Ie))));return d};_.Cm=function ure(){var a;Mqe(this);a=_se(21,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Dm=function vre(){var a;Mqe(this);a=_se(23,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Em=function wre(){var a,b;Mqe(this);a=this.f++;b=bte(Qqe(this),a);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return b};_.Fm=function xre(){var a;Mqe(this);a=bte(Qqe(this),0);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Gm=function yre(a){Mqe(this);if(this.c==5){Mqe(this);return $se(a,(Vse(),Vse(),new Kte(9,a)))}else return $se(a,(Vse(),Vse(),new Kte(3,a)))};_.Hm=function zre(a){var b;Mqe(this);b=(Vse(),Vse(),new iue(2));if(this.c==5){Mqe(this);hue(b,(Ese));hue(b,a);}else {hue(b,a);hue(b,(Ese));}return b};_.Im=function Are(a){Mqe(this);if(this.c==5){Mqe(this);return Vse(),Vse(),new Kte(9,a)}else return Vse(),Vse(),new Kte(3,a)};_.a=0;_.b=0;_.c=0;_.d=0;_.e=0;_.f=1;_.g=null;_.j=0;sfb(LLe,'RegEx/RegexParser',836);feb(1947,836,{},Gre);_.bm=function Hre(a){return false};_.cm=function Ire(){return Dre(this)};_.dm=function Kre(a){return Ere(a)};_.em=function Lre(a){return Fre(this)};_.fm=function Mre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.gm=function Nre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.hm=function Ore(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.im=function Pre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.jm=function Qre(){Mqe(this);return Ere(67)};_.km=function Rre(){Mqe(this);return Ere(73)};_.lm=function Sre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.mm=function Tre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.nm=function Ure(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.om=function Vre(){Mqe(this);return Ere(99)};_.pm=function Wre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.qm=function Xre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.rm=function Yre(){Mqe(this);return Ere(105)};_.sm=function Zre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.tm=function $re(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.um=function _re(a,b){return ute(a,Ere(b)),-1};_.vm=function ase(){Mqe(this);return Vse(),Vse(),new Hte(0,94)};_.wm=function bse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.xm=function cse(){Mqe(this);return Vse(),Vse(),new Hte(0,36)};_.ym=function dse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.zm=function ese(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Am=function fse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Bm=function gse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Cm=function hse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Dm=function ise(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Em=function jse(){var a;Mqe(this);a=bte(Qqe(this),0);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Fm=function kse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Gm=function lse(a){Mqe(this);return $se(a,(Vse(),Vse(),new Kte(3,a)))};_.Hm=function mse(a){var b;Mqe(this);b=(Vse(),Vse(),new iue(2));hue(b,a);hue(b,(Ese));return b};_.Im=function nse(a){Mqe(this);return Vse(),Vse(),new Kte(3,a)};var Bre=null,Cre=null;sfb(LLe,'RegEx/ParserForXMLSchema',1947);feb(122,1,ZLe,Wse);_.Jm=function Xse(a){throw Adb(new yz('Not supported.'))};_.Km=function dte(){return -1};_.Lm=function ete(a){return null};_.Mm=function jte(){return null};_.Nm=function mte(a){};_.Om=function nte(a){};_.Pm=function ote(){return 0};_.Ib=function pte(){return this.Qm(0)};_.Qm=function qte(a){return this.e==11?'.':''};_.e=0;var vse,wse,xse,yse,zse,Ase=null,Bse,Cse=null,Dse,Ese,Fse=null,Gse,Hse,Ise,Jse,Kse,Lse,Mse,Nse,Ose,Pse,Qse,Rse,Sse,Tse;var qdb=sfb(LLe,'RegEx/Token',122);feb(138,122,{3:1,138:1,122:1},xte);_.Qm=function Ate(a){var b,c,d;if(this.e==4){if(this==Dse)c='.';else if(this==Bse)c='\\d';else if(this==Rse)c='\\w';else if(this==Mse)c='\\s';else {d=new Qhb;d.a+='[';for(b=0;b0&&(d.a+=',',d);if(this.b[b]===this.b[b+1]){Nhb(d,zte(this.b[b]));}else {Nhb(d,zte(this.b[b]));d.a+='-';Nhb(d,zte(this.b[b+1]));}}d.a+=']';c=d.a;}}else {if(this==Ise)c='\\D';else if(this==Kse)c='\\W';else if(this==Jse)c='\\S';else {d=new Qhb;d.a+='[^';for(b=0;b0&&(d.a+=',',d);if(this.b[b]===this.b[b+1]){Nhb(d,zte(this.b[b]));}else {Nhb(d,zte(this.b[b]));d.a+='-';Nhb(d,zte(this.b[b+1]));}}d.a+=']';c=d.a;}}return c};_.a=false;_.c=false;sfb(LLe,'RegEx/RangeToken',138);feb(592,1,{592:1},Bte);_.a=0;sfb(LLe,'RegEx/RegexParser/ReferencePosition',592);feb(591,1,{3:1,591:1},Dte);_.Fb=function Ete(a){var b;if(a==null)return false;if(!ZD(a,591))return false;b=RD(a,591);return lhb(this.b,b.b)&&this.a==b.a};_.Hb=function Fte(){return ohb(this.b+'/'+pse(this.a))};_.Ib=function Gte(){return this.c.Qm(this.a)};_.a=0;sfb(LLe,'RegEx/RegularExpression',591);feb(228,122,ZLe,Hte);_.Km=function Ite(){return this.a};_.Qm=function Jte(a){var b,c,d;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:d='\\'+XD(this.a&Bwe);break;case 12:d='\\f';break;case 10:d='\\n';break;case 13:d='\\r';break;case 9:d='\\t';break;case 27:d='\\e';break;default:if(this.a>=txe){c=(b=this.a>>>0,'0'+b.toString(16));d='\\v'+zhb(c,c.length-6,c.length);}else d=''+XD(this.a&Bwe);}break;case 8:this==Gse||this==Hse?(d=''+XD(this.a&Bwe)):(d='\\'+XD(this.a&Bwe));break;default:d=null;}return d};_.a=0;sfb(LLe,'RegEx/Token/CharToken',228);feb(318,122,ZLe,Kte);_.Lm=function Lte(a){return this.a};_.Nm=function Mte(a){this.b=a;};_.Om=function Nte(a){this.c=a;};_.Pm=function Ote(){return 1};_.Qm=function Pte(a){var b;if(this.e==3){if(this.c<0&&this.b<0){b=this.a.Qm(a)+'*';}else if(this.c==this.b){b=this.a.Qm(a)+'{'+this.c+'}';}else if(this.c>=0&&this.b>=0){b=this.a.Qm(a)+'{'+this.c+','+this.b+'}';}else if(this.c>=0&&this.b<0){b=this.a.Qm(a)+'{'+this.c+',}';}else throw Adb(new yz('Token#toString(): CLOSURE '+this.c+pve+this.b))}else {if(this.c<0&&this.b<0){b=this.a.Qm(a)+'*?';}else if(this.c==this.b){b=this.a.Qm(a)+'{'+this.c+'}?';}else if(this.c>=0&&this.b>=0){b=this.a.Qm(a)+'{'+this.c+','+this.b+'}?';}else if(this.c>=0&&this.b<0){b=this.a.Qm(a)+'{'+this.c+',}?';}else throw Adb(new yz('Token#toString(): NONGREEDYCLOSURE '+this.c+pve+this.b))}return b};_.b=0;_.c=0;sfb(LLe,'RegEx/Token/ClosureToken',318);feb(837,122,ZLe,Qte);_.Lm=function Rte(a){return a==0?this.a:this.b};_.Pm=function Ste(){return 2};_.Qm=function Tte(a){var b;this.b.e==3&&this.b.Lm(0)==this.a?(b=this.a.Qm(a)+'+'):this.b.e==9&&this.b.Lm(0)==this.a?(b=this.a.Qm(a)+'+?'):(b=this.a.Qm(a)+(''+this.b.Qm(a)));return b};sfb(LLe,'RegEx/Token/ConcatToken',837);feb(1945,122,ZLe,Ute);_.Lm=function Vte(a){if(a==0)return this.d;if(a==1)return this.b;throw Adb(new yz('Internal Error: '+a))};_.Pm=function Wte(){return !this.b?1:2};_.Qm=function Xte(a){var b;this.c>0?(b='(?('+this.c+')'):this.a.e==8?(b='(?('+this.a+')'):(b='(?'+this.a);!this.b?(b+=this.d+')'):(b+=this.d+'|'+this.b+')');return b};_.c=0;sfb(LLe,'RegEx/Token/ConditionToken',1945);feb(1946,122,ZLe,Yte);_.Lm=function Zte(a){return this.b};_.Pm=function $te(){return 1};_.Qm=function _te(a){return '(?'+(this.a==0?'':pse(this.a))+(this.c==0?'':pse(this.c))+':'+this.b.Qm(a)+')'};_.a=0;_.c=0;sfb(LLe,'RegEx/Token/ModifierToken',1946);feb(838,122,ZLe,aue);_.Lm=function bue(a){return this.a};_.Pm=function cue(){return 1};_.Qm=function due(a){var b;b=null;switch(this.e){case 6:this.b==0?(b='(?:'+this.a.Qm(a)+')'):(b='('+this.a.Qm(a)+')');break;case 20:b='(?='+this.a.Qm(a)+')';break;case 21:b='(?!'+this.a.Qm(a)+')';break;case 22:b='(?<='+this.a.Qm(a)+')';break;case 23:b='(?'+this.a.Qm(a)+')';}return b};_.b=0;sfb(LLe,'RegEx/Token/ParenToken',838);feb(530,122,{3:1,122:1,530:1},eue);_.Mm=function fue(){return this.b};_.Qm=function gue(a){return this.e==12?'\\'+this.a:tse(this.b)};_.a=0;sfb(LLe,'RegEx/Token/StringToken',530);feb(477,122,ZLe,iue);_.Jm=function jue(a){hue(this,a);};_.Lm=function kue(a){return RD(eyb(this.a,a),122)};_.Pm=function lue(){return !this.a?0:this.a.a.c.length};_.Qm=function mue(a){var b,c,d,e,f;if(this.e==1){if(this.a.a.c.length==2){b=RD(eyb(this.a,0),122);c=RD(eyb(this.a,1),122);c.e==3&&c.Lm(0)==b?(e=b.Qm(a)+'+'):c.e==9&&c.Lm(0)==b?(e=b.Qm(a)+'+?'):(e=b.Qm(a)+(''+c.Qm(a)));}else {f=new Qhb;for(d=0;d=this.c.b:this.a<=this.c.b};_.Sb=function Vue(){return this.b>0};_.Tb=function Xue(){return this.b};_.Vb=function Zue(){return this.b-1};_.Qb=function $ue(){throw Adb(new kib(dMe))};_.a=0;_.b=0;sfb(aMe,'ExclusiveRange/RangeIterator',258);var hE=vfb(eKe,'C');var kE=vfb(hKe,'I');var xdb=vfb(hve,'Z');var lE=vfb(iKe,'J');var gE=vfb(dKe,'B');var iE=vfb(fKe,'D');var jE=vfb(gKe,'F');var wdb=vfb(jKe,'S');var g3=ufb('org.eclipse.elk.core.labels','ILabelManager');var T6=ufb(sIe,'DiagnosticChain');var zab=ufb(QKe,'ResourceSet');var $6=sfb(sIe,'InvocationTargetException',null);var fve=(Qz(),Tz);var gwtOnLoad=gwtOnLoad=ceb;aeb(leb);deb('permProps',[[['locale','default'],[eMe,'gecko1_8']],[['locale','default'],[eMe,'safari']]]); + // -------------- RUN GWT INITIALIZATION CODE -------------- + gwtOnLoad(null, 'elk', null); + + }).call(this);}).call(this,typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}); + },{}],3:[function(require,module,exports){ + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + /******************************************************************************* + * Copyright (c) 2021 Kiel University and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + var ELK = require('./elk-api.js').default; + + var ELKNode = function (_ELK) { + _inherits(ELKNode, _ELK); + + function ELKNode() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, ELKNode); + + var optionsClone = Object.assign({}, options); + + var workerThreadsExist = false; + try { + require.resolve('web-worker'); + workerThreadsExist = true; + } catch (e) {} + + // user requested a worker + if (options.workerUrl) { + if (workerThreadsExist) { + var Worker = require('web-worker'); + optionsClone.workerFactory = function (url) { + return new Worker(url); + }; + } else { + console.warn('Web worker requested but \'web-worker\' package not installed. \nConsider installing the package or pass your own \'workerFactory\' to ELK\'s constructor.\n... Falling back to non-web worker version.'); + } + } + + // unless no other workerFactory is registered, use the fake worker + if (!optionsClone.workerFactory) { + var _require = require('./elk-worker.min.js'), + _Worker = _require.Worker; + + optionsClone.workerFactory = function (url) { + return new _Worker(url); + }; + } + + return _possibleConstructorReturn(this, (ELKNode.__proto__ || Object.getPrototypeOf(ELKNode)).call(this, optionsClone)); + } + + return ELKNode; + }(ELK); + + Object.defineProperty(module.exports, "__esModule", { + value: true + }); + module.exports = ELKNode; + ELKNode.default = ELKNode; + },{"./elk-api.js":1,"./elk-worker.min.js":2,"web-worker":4}],4:[function(require,module,exports){ + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + module.exports = Worker; + },{}]},{},[3])(3) + }); +} (elk_bundled)); + +var elk_bundledExports = elk_bundled.exports; +var ELK = /*@__PURE__*/getDefaultExportFromCjs(elk_bundledExports); + +const findCommonAncestor = (id1, id2, treeData) => { + const { parentById } = treeData; + const visited = /* @__PURE__ */ new Set(); + let currentId = id1; + while (currentId) { + visited.add(currentId); + if (currentId === id2) { + return currentId; + } + currentId = parentById[currentId]; + } + currentId = id2; + while (currentId) { + if (visited.has(currentId)) { + return currentId; + } + currentId = parentById[currentId]; + } + return "root"; +}; +const elk = new ELK(); +let portPos = {}; +const conf = {}; +let nodeDb = {}; +const addVertices = async function(vert, svgId, root, doc, diagObj, parentLookupDb, graph) { + const svg = root.select(`[id="${svgId}"]`); + const nodes = svg.insert("g").attr("class", "nodes"); + const keys = Object.keys(vert); + await Promise.all( + keys.map(async function(id) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + classStr = classStr + " flowchart-label"; + const styles2 = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + const labelData = { width: 0, height: 0 }; + const ports = [ + { + id: vertex.id + "-west", + layoutOptions: { + "port.side": "WEST" + } + }, + { + id: vertex.id + "-east", + layoutOptions: { + "port.side": "EAST" + } + }, + { + id: vertex.id + "-south", + layoutOptions: { + "port.side": "SOUTH" + } + }, + { + id: vertex.id + "-north", + layoutOptions: { + "port.side": "NORTH" + } + } + ]; + let radius = 0; + let _shape = ""; + let layoutOptions = {}; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + layoutOptions = { + portConstraints: "FIXED_SIDE" + }; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + case "doublecircle": + _shape = "doublecircle"; + break; + default: + _shape = "rect"; + } + const node = { + labelStyle: styles2.labelStyle, + shape: _shape, + labelText: vertexText, + labelType: vertex.labelType, + rx: radius, + ry: radius, + class: classStr, + style: styles2.style, + id: vertex.id, + link: vertex.link, + linkTarget: vertex.linkTarget, + tooltip: diagObj.db.getTooltip(vertex.id) || "", + domId: diagObj.db.lookUpDomId(vertex.id), + haveCallback: vertex.haveCallback, + width: vertex.type === "group" ? 500 : void 0, + dir: vertex.dir, + type: vertex.type, + props: vertex.props, + padding: getConfig$1().flowchart.padding + }; + let boundingBox; + let nodeEl; + if (node.type !== "group") { + nodeEl = await insertNode(nodes, node, vertex.dir); + boundingBox = nodeEl.node().getBBox(); + } else { + doc.createElementNS("http://www.w3.org/2000/svg", "text"); + const { shapeSvg, bbox } = await labelHelper(nodes, node, void 0, true); + labelData.width = bbox.width; + labelData.wrappingWidth = getConfig$1().flowchart.wrappingWidth; + labelData.height = bbox.height; + labelData.labelNode = shapeSvg.node(); + node.labelData = labelData; + } + const data = { + id: vertex.id, + ports: vertex.type === "diamond" ? ports : [], + // labelStyle: styles.labelStyle, + // shape: _shape, + layoutOptions, + labelText: vertexText, + labelData, + // labels: [{ text: vertexText }], + // rx: radius, + // ry: radius, + // class: classStr, + // style: styles.style, + // link: vertex.link, + // linkTarget: vertex.linkTarget, + // tooltip: diagObj.db.getTooltip(vertex.id) || '', + domId: diagObj.db.lookUpDomId(vertex.id), + // haveCallback: vertex.haveCallback, + width: boundingBox == null ? void 0 : boundingBox.width, + height: boundingBox == null ? void 0 : boundingBox.height, + // dir: vertex.dir, + type: vertex.type, + // props: vertex.props, + // padding: getConfig().flowchart.padding, + // boundingBox, + el: nodeEl, + parent: parentLookupDb.parentById[vertex.id] + }; + nodeDb[node.id] = data; + }) + ); + return graph; +}; +const getNextPosition = (position, edgeDirection, graphDirection) => { + const portPos2 = { + TB: { + in: { + north: "north" + }, + out: { + south: "west", + west: "east", + east: "south" + } + }, + LR: { + in: { + west: "west" + }, + out: { + east: "south", + south: "north", + north: "east" + } + }, + RL: { + in: { + east: "east" + }, + out: { + west: "north", + north: "south", + south: "west" + } + }, + BT: { + in: { + south: "south" + }, + out: { + north: "east", + east: "west", + west: "north" + } + } + }; + portPos2.TD = portPos2.TB; + return portPos2[graphDirection][edgeDirection][position]; +}; +const getNextPort = (node, edgeDirection, graphDirection) => { + log$1.info("getNextPort", { node, edgeDirection, graphDirection }); + if (!portPos[node]) { + switch (graphDirection) { + case "TB": + case "TD": + portPos[node] = { + inPosition: "north", + outPosition: "south" + }; + break; + case "BT": + portPos[node] = { + inPosition: "south", + outPosition: "north" + }; + break; + case "RL": + portPos[node] = { + inPosition: "east", + outPosition: "west" + }; + break; + case "LR": + portPos[node] = { + inPosition: "west", + outPosition: "east" + }; + break; + } + } + const result = edgeDirection === "in" ? portPos[node].inPosition : portPos[node].outPosition; + if (edgeDirection === "in") { + portPos[node].inPosition = getNextPosition( + portPos[node].inPosition, + edgeDirection, + graphDirection + ); + } else { + portPos[node].outPosition = getNextPosition( + portPos[node].outPosition, + edgeDirection, + graphDirection + ); + } + return result; +}; +const getEdgeStartEndPoint = (edge, dir) => { + let source = edge.start; + let target = edge.end; + const sourceId = source; + const targetId = target; + const startNode = nodeDb[source]; + const endNode = nodeDb[target]; + if (!startNode || !endNode) { + return { source, target }; + } + if (startNode.type === "diamond") { + source = `${source}-${getNextPort(source, "out", dir)}`; + } + if (endNode.type === "diamond") { + target = `${target}-${getNextPort(target, "in", dir)}`; + } + return { source, target, sourceId, targetId }; +}; +const addEdges = function(edges, diagObj, graph, svg) { + log$1.info("abc78 edges = ", edges); + const labelsEl = svg.insert("g").attr("class", "edgeLabels"); + let linkIdCnt = {}; + let dir = diagObj.db.getDirection(); + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + edges.forEach(function(edge) { + const linkIdBase = "L-" + edge.start + "-" + edge.end; + if (linkIdCnt[linkIdBase] === void 0) { + linkIdCnt[linkIdBase] = 0; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } else { + linkIdCnt[linkIdBase]++; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } + let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase]; + log$1.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]); + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = { style: "", labelStyle: "" }; + edgeData.minlen = edge.length || 1; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + edgeData.arrowTypeStart = "arrow_open"; + edgeData.arrowTypeEnd = "arrow_open"; + switch (edge.type) { + case "double_arrow_cross": + edgeData.arrowTypeStart = "arrow_cross"; + case "arrow_cross": + edgeData.arrowTypeEnd = "arrow_cross"; + break; + case "double_arrow_point": + edgeData.arrowTypeStart = "arrow_point"; + case "arrow_point": + edgeData.arrowTypeEnd = "arrow_point"; + break; + case "double_arrow_circle": + edgeData.arrowTypeStart = "arrow_circle"; + case "arrow_circle": + edgeData.arrowTypeEnd = "arrow_circle"; + break; + } + let style = ""; + let labelStyle = ""; + switch (edge.stroke) { + case "normal": + style = "fill:none;"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + edgeData.thickness = "normal"; + edgeData.pattern = "solid"; + break; + case "dotted": + edgeData.thickness = "normal"; + edgeData.pattern = "dotted"; + edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + edgeData.thickness = "thick"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 3.5px;fill:none;"; + break; + } + if (edge.style !== void 0) { + const styles2 = getStylesFromArray(edge.style); + style = styles2.style; + labelStyle = styles2.labelStyle; + } + edgeData.style = edgeData.style += style; + edgeData.labelStyle = edgeData.labelStyle += labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + } + edgeData.labelType = edge.labelType; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + edgeData.id = linkId; + edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd; + const labelEl = insertEdgeLabel(labelsEl, edgeData); + const { source, target, sourceId, targetId } = getEdgeStartEndPoint(edge, dir); + log$1.debug("abc78 source and target", source, target); + graph.edges.push({ + id: "e" + edge.start + edge.end, + sources: [source], + targets: [target], + sourceId, + targetId, + labelEl, + labels: [ + { + width: edgeData.width, + height: edgeData.height, + orgWidth: edgeData.width, + orgHeight: edgeData.height, + text: edgeData.label, + layoutOptions: { + "edgeLabels.inline": "true", + "edgeLabels.placement": "CENTER" + } + } + ], + edgeData + }); + }); + return graph; +}; +const addMarkersToEdge = function(svgPath, edgeData, diagramType, arrowMarkerAbsolute, id) { + let url = ""; + if (arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + addEdgeMarkers(svgPath, edgeData, url, id, diagramType); +}; +const getClasses = function(text, diagObj) { + log$1.info("Extracting classes"); + return diagObj.db.getClasses(); +}; +const addSubGraphs = function(db2) { + const parentLookupDb = { parentById: {}, childrenById: {} }; + const subgraphs = db2.getSubGraphs(); + log$1.info("Subgraphs - ", subgraphs); + subgraphs.forEach(function(subgraph) { + subgraph.nodes.forEach(function(node) { + parentLookupDb.parentById[node] = subgraph.id; + if (parentLookupDb.childrenById[subgraph.id] === void 0) { + parentLookupDb.childrenById[subgraph.id] = []; + } + parentLookupDb.childrenById[subgraph.id].push(node); + }); + }); + subgraphs.forEach(function(subgraph) { + ({ id: subgraph.id }); + if (parentLookupDb.parentById[subgraph.id] !== void 0) { + parentLookupDb.parentById[subgraph.id]; + } + }); + return parentLookupDb; +}; +const calcOffset = function(src, dest, parentLookupDb) { + const ancestor = findCommonAncestor(src, dest, parentLookupDb); + if (ancestor === void 0 || ancestor === "root") { + return { x: 0, y: 0 }; + } + const ancestorOffset = nodeDb[ancestor].offset; + return { x: ancestorOffset.posX, y: ancestorOffset.posY }; +}; +const insertEdge = function(edgesEl, edge, edgeData, diagObj, parentLookupDb, id) { + const offset = calcOffset(edge.sourceId, edge.targetId, parentLookupDb); + const src = edge.sections[0].startPoint; + const dest = edge.sections[0].endPoint; + const segments = edge.sections[0].bendPoints ? edge.sections[0].bendPoints : []; + const segPoints = segments.map((segment) => [segment.x + offset.x, segment.y + offset.y]); + const points = [ + [src.x + offset.x, src.y + offset.y], + ...segPoints, + [dest.x + offset.x, dest.y + offset.y] + ]; + const { x, y } = getLineFunctionsWithOffset(edge.edgeData); + const curve = line().x(x).y(y).curve(curveLinear); + const edgePath = edgesEl.insert("path").attr("d", curve(points)).attr("class", "path " + edgeData.classes).attr("fill", "none"); + const edgeG = edgesEl.insert("g").attr("class", "edgeLabel"); + const edgeWithLabel = select(edgeG.node().appendChild(edge.labelEl)); + const box = edgeWithLabel.node().firstChild.getBoundingClientRect(); + edgeWithLabel.attr("width", box.width); + edgeWithLabel.attr("height", box.height); + edgeG.attr( + "transform", + `translate(${edge.labels[0].x + offset.x}, ${edge.labels[0].y + offset.y})` + ); + addMarkersToEdge(edgePath, edgeData, diagObj.type, diagObj.arrowMarkerAbsolute, id); +}; +const insertChildren = (nodeArray, parentLookupDb) => { + nodeArray.forEach((node) => { + if (!node.children) { + node.children = []; + } + const childIds = parentLookupDb.childrenById[node.id]; + if (childIds) { + childIds.forEach((childId) => { + node.children.push(nodeDb[childId]); + }); + } + insertChildren(node.children, parentLookupDb); + }); +}; +const draw = async function(text, id, _version, diagObj) { + var _a; + diagObj.db.clear(); + nodeDb = {}; + portPos = {}; + diagObj.db.setGen("gen-2"); + diagObj.parser.parse(text); + const renderEl = select("body").append("div").attr("style", "height:400px").attr("id", "cy"); + let graph = { + id: "root", + layoutOptions: { + "elk.hierarchyHandling": "INCLUDE_CHILDREN", + "org.eclipse.elk.padding": "[top=100, left=100, bottom=110, right=110]", + "elk.layered.spacing.edgeNodeBetweenLayers": "30", + // 'elk.layered.mergeEdges': 'true', + "elk.direction": "DOWN" + // 'elk.ports.sameLayerEdges': true, + // 'nodePlacement.strategy': 'SIMPLE', + }, + children: [], + edges: [] + }; + log$1.info("Drawing flowchart using v3 renderer", elk); + let dir = diagObj.db.getDirection(); + switch (dir) { + case "BT": + graph.layoutOptions["elk.direction"] = "UP"; + break; + case "TB": + graph.layoutOptions["elk.direction"] = "DOWN"; + break; + case "LR": + graph.layoutOptions["elk.direction"] = "RIGHT"; + break; + case "RL": + graph.layoutOptions["elk.direction"] = "LEFT"; + break; + } + const { securityLevel, flowchart: conf2 } = getConfig$1(); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const svg = root.select(`[id="${id}"]`); + const markers = ["point", "circle", "cross"]; + insertMarkers$1(svg, markers, diagObj.type, id); + const vert = diagObj.db.getVertices(); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + log$1.info("Subgraphs - ", subGraphs); + for (let i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + diagObj.db.addVertex( + subG.id, + { text: subG.title, type: subG.labelType }, + "group", + void 0, + subG.classes, + subG.dir + ); + } + const subGraphsEl = svg.insert("g").attr("class", "subgraphs"); + const parentLookupDb = addSubGraphs(diagObj.db); + graph = await addVertices(vert, id, root, doc, diagObj, parentLookupDb, graph); + const edgesEl = svg.insert("g").attr("class", "edges edgePath"); + const edges = diagObj.db.getEdges(); + graph = addEdges(edges, diagObj, graph, svg); + const nodes = Object.keys(nodeDb); + nodes.forEach((nodeId) => { + const node = nodeDb[nodeId]; + if (!node.parent) { + graph.children.push(node); + } + if (parentLookupDb.childrenById[nodeId] !== void 0) { + node.labels = [ + { + text: node.labelText, + layoutOptions: { + "nodeLabels.placement": "[H_CENTER, V_TOP, INSIDE]" + }, + width: node.labelData.width, + height: node.labelData.height + // width: 100, + // height: 100, + } + ]; + delete node.x; + delete node.y; + delete node.width; + delete node.height; + } + }); + insertChildren(graph.children, parentLookupDb); + log$1.info("after layout", JSON.stringify(graph, null, 2)); + const g = await elk.layout(graph); + drawNodes(0, 0, g.children, svg, subGraphsEl, diagObj, 0); + log$1.info("after layout", g); + (_a = g.edges) == null ? void 0 : _a.map((edge) => { + insertEdge(edgesEl, edge, edge.edgeData, diagObj, parentLookupDb, id); + }); + setupGraphViewbox$1({}, svg, conf2.diagramPadding, conf2.useMaxWidth); + renderEl.remove(); +}; +const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, diagObj, depth) => { + nodeArray.forEach(function(node) { + if (node) { + nodeDb[node.id].offset = { + posX: node.x + relX, + posY: node.y + relY, + x: relX, + y: relY, + depth, + width: node.width, + height: node.height + }; + if (node.type === "group") { + const subgraphEl = subgraphsEl.insert("g").attr("class", "subgraph"); + subgraphEl.insert("rect").attr("class", "subgraph subgraph-lvl-" + depth % 5 + " node").attr("x", node.x + relX).attr("y", node.y + relY).attr("width", node.width).attr("height", node.height); + const label = subgraphEl.insert("g").attr("class", "label"); + const labelCentering = getConfig$1().flowchart.htmlLabels ? node.labelData.width / 2 : 0; + label.attr( + "transform", + `translate(${node.labels[0].x + relX + node.x + labelCentering}, ${node.labels[0].y + relY + node.y + 3})` + ); + label.node().appendChild(node.labelData.labelNode); + log$1.info("Id (UGH)= ", node.type, node.labels); + } else { + log$1.info("Id (UGH)= ", node.id); + node.el.attr( + "transform", + `translate(${node.x + relX + node.width / 2}, ${node.y + relY + node.height / 2})` + ); + } + } + }); + nodeArray.forEach(function(node) { + if (node && node.type === "group") { + drawNodes(relX + node.x, relY + node.y, node.children, svg, subgraphsEl, diagObj, depth + 1); + } + }); +}; +const renderer = { + getClasses, + draw +}; +const genSections = (options) => { + let sections = ""; + for (let i = 0; i < 5; i++) { + sections += ` + .subgraph-lvl-${i} { + fill: ${options[`surface${i}`]}; + stroke: ${options[`surfacePeer${i}`]}; + } + `; + } + return sections; +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span { + color: ${options.titleColor}; + } + + .label text,span { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.85; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + .cluster rect { + fill: ${options.clusterBkg}; + stroke: ${options.clusterBorder}; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } + .subgraph { + stroke-width:2; + rx:3; + } + // .subgraph-lvl-1 { + // fill:#ccc; + // // stroke:black; + // } + + .flowchart-label text { + text-anchor: middle; + } + + ${genSections(options)} +`; +const styles = getStyles; +const diagram = { + db, + renderer, + parser: parser$1, + styles +}; + +export { diagram }; diff --git a/libs/marked/ganttDiagram-b62c793e-Bvxu6L6W.js b/libs/marked/ganttDiagram-b62c793e-Bvxu6L6W.js new file mode 100644 index 0000000..ef898c7 --- /dev/null +++ b/libs/marked/ganttDiagram-b62c793e-Bvxu6L6W.js @@ -0,0 +1,3581 @@ +import { J as define, K as extend, R as Rgb, L as Color, M as rgbConvert, N as nogamma, O as hue, P as commonjsGlobal, Q as getDefaultExportFromCjs, T as dayjs, c as getConfig, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, b as setAccDescription, a as getAccDescription, E as clear$1, m as dist, l as log$1, h as select, i as configureSvgSize, j as common$1, A as utils } from './index-Bd_FDXSq.js'; +import { b as bisector, t as tickStep, c as continuous, a as copy, l as linear } from './linear-DNP-QGmo.js'; +import { i as initRange } from './init-zpY4DTin.js'; + +function max(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +function identity(x) { + return x; +} + +var top = 1, + right = 2, + bottom = 3, + left = 4, + epsilon = 1e-6; + +function translateX(x) { + return "translate(" + x + ",0)"; +} + +function translateY(y) { + return "translate(0," + y + ")"; +} + +function number$1(scale) { + return d => +scale(d); +} + +function center(scale, offset) { + offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; + if (scale.round()) offset = Math.round(offset); + return d => +scale(d) + offset; +} + +function entering() { + return !this.__axis; +} + +function axis(orient, scale) { + var tickArguments = [], + tickValues = null, + tickFormat = null, + tickSizeInner = 6, + tickSizeOuter = 6, + tickPadding = 3, + offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, + k = orient === top || orient === left ? -1 : 1, + x = orient === left || orient === right ? "x" : "y", + transform = orient === top || orient === bottom ? translateX : translateY; + + function axis(context) { + var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues, + format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity) : tickFormat, + spacing = Math.max(tickSizeInner, 0) + tickPadding, + range = scale.range(), + range0 = +range[0] + offset, + range1 = +range[range.length - 1] + offset, + position = (scale.bandwidth ? center : number$1)(scale.copy(), offset), + selection = context.selection ? context.selection() : context, + path = selection.selectAll(".domain").data([null]), + tick = selection.selectAll(".tick").data(values, scale).order(), + tickExit = tick.exit(), + tickEnter = tick.enter().append("g").attr("class", "tick"), + line = tick.select("line"), + text = tick.select("text"); + + path = path.merge(path.enter().insert("path", ".tick") + .attr("class", "domain") + .attr("stroke", "currentColor")); + + tick = tick.merge(tickEnter); + + line = line.merge(tickEnter.append("line") + .attr("stroke", "currentColor") + .attr(x + "2", k * tickSizeInner)); + + text = text.merge(tickEnter.append("text") + .attr("fill", "currentColor") + .attr(x, k * spacing) + .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); + + if (context !== selection) { + path = path.transition(context); + tick = tick.transition(context); + line = line.transition(context); + text = text.transition(context); + + tickExit = tickExit.transition(context) + .attr("opacity", epsilon) + .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform"); }); + + tickEnter + .attr("opacity", epsilon) + .attr("transform", function(d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset); }); + } + + tickExit.remove(); + + path + .attr("d", orient === left || orient === right + ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1) + : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1)); + + tick + .attr("opacity", 1) + .attr("transform", function(d) { return transform(position(d) + offset); }); + + line + .attr(x + "2", k * tickSizeInner); + + text + .attr(x, k * spacing) + .text(format); + + selection.filter(entering) + .attr("fill", "none") + .attr("font-size", 10) + .attr("font-family", "sans-serif") + .attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle"); + + selection + .each(function() { this.__axis = position; }); + } + + axis.scale = function(_) { + return arguments.length ? (scale = _, axis) : scale; + }; + + axis.ticks = function() { + return tickArguments = Array.from(arguments), axis; + }; + + axis.tickArguments = function(_) { + return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice(); + }; + + axis.tickValues = function(_) { + return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice(); + }; + + axis.tickFormat = function(_) { + return arguments.length ? (tickFormat = _, axis) : tickFormat; + }; + + axis.tickSize = function(_) { + return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner; + }; + + axis.tickSizeInner = function(_) { + return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner; + }; + + axis.tickSizeOuter = function(_) { + return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter; + }; + + axis.tickPadding = function(_) { + return arguments.length ? (tickPadding = +_, axis) : tickPadding; + }; + + axis.offset = function(_) { + return arguments.length ? (offset = +_, axis) : offset; + }; + + return axis; +} + +function axisTop(scale) { + return axis(top, scale); +} + +function axisBottom(scale) { + return axis(bottom, scale); +} + +const radians = Math.PI / 180; +const degrees = 180 / Math.PI; + +// https://observablehq.com/@mbostock/lab-and-rgb +const K = 18, + Xn = 0.96422, + Yn = 1, + Zn = 0.82521, + t0$1 = 4 / 29, + t1$1 = 6 / 29, + t2 = 3 * t1$1 * t1$1, + t3 = t1$1 * t1$1 * t1$1; + +function labConvert(o) { + if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); + if (o instanceof Hcl) return hcl2lab(o); + if (!(o instanceof Rgb)) o = rgbConvert(o); + var r = rgb2lrgb(o.r), + g = rgb2lrgb(o.g), + b = rgb2lrgb(o.b), + y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } + return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); +} + +function lab(l, a, b, opacity) { + return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); +} + +function Lab(l, a, b, opacity) { + this.l = +l; + this.a = +a; + this.b = +b; + this.opacity = +opacity; +} + +define(Lab, lab, extend(Color, { + brighter(k) { + return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + darker(k) { + return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + rgb() { + var y = (this.l + 16) / 116, + x = isNaN(this.a) ? y : y + this.a / 500, + z = isNaN(this.b) ? y : y - this.b / 200; + x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); + z = Zn * lab2xyz(z); + return new Rgb( + lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), + this.opacity + ); + } +})); + +function xyz2lab(t) { + return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0$1; +} + +function lab2xyz(t) { + return t > t1$1 ? t * t * t : t2 * (t - t0$1); +} + +function lrgb2rgb(x) { + return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); +} + +function rgb2lrgb(x) { + return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); +} + +function hclConvert(o) { + if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); + if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); + var h = Math.atan2(o.b, o.a) * degrees; + return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); +} + +function hcl$1(h, c, l, opacity) { + return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} + +function Hcl(h, c, l, opacity) { + this.h = +h; + this.c = +c; + this.l = +l; + this.opacity = +opacity; +} + +function hcl2lab(o) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); + var h = o.h * radians; + return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); +} + +define(Hcl, hcl$1, extend(Color, { + brighter(k) { + return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); + }, + darker(k) { + return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); + }, + rgb() { + return hcl2lab(this).rgb(); + } +})); + +function hcl(hue) { + return function(start, end) { + var h = hue((start = hcl$1(start)).h, (end = hcl$1(end)).h), + c = nogamma(start.c, end.c), + l = nogamma(start.l, end.l), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.c = c(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + } +} + +var interpolateHcl = hcl(hue); + +function nice(domain, interval) { + domain = domain.slice(); + + var i0 = 0, + i1 = domain.length - 1, + x0 = domain[i0], + x1 = domain[i1], + t; + + if (x1 < x0) { + t = i0, i0 = i1, i1 = t; + t = x0, x0 = x1, x1 = t; + } + + domain[i0] = interval.floor(x0); + domain[i1] = interval.ceil(x1); + return domain; +} + +const t0 = new Date, t1 = new Date; + +function timeInterval(floori, offseti, count, field) { + + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + + interval.floor = (date) => { + return floori(date = new Date(+date)), date; + }; + + interval.ceil = (date) => { + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; + }; + + interval.round = (date) => { + const d0 = interval(date), d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + + interval.offset = (date, step) => { + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + + interval.range = (start, stop, step) => { + const range = []; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + let previous; + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + + interval.filter = (test) => { + return timeInterval((date) => { + if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); + }, (date, step) => { + if (date >= date) { + if (step < 0) while (++step <= 0) { + while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty + } else while (--step >= 0) { + while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty + } + } + }); + }; + + if (count) { + interval.count = (start, end) => { + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + + interval.every = (step) => { + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null + : !(step > 1) ? interval + : interval.filter(field + ? (d) => field(d) % step === 0 + : (d) => interval.count(0, d) % step === 0); + }; + } + + return interval; +} + +const millisecond = timeInterval(() => { + // noop +}, (date, step) => { + date.setTime(+date + step); +}, (start, end) => { + return end - start; +}); + +// An optimized implementation for this simple case. +millisecond.every = (k) => { + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return timeInterval((date) => { + date.setTime(Math.floor(date / k) * k); + }, (date, step) => { + date.setTime(+date + step * k); + }, (start, end) => { + return (end - start) / k; + }); +}; + +millisecond.range; + +const durationSecond = 1000; +const durationMinute = durationSecond * 60; +const durationHour = durationMinute * 60; +const durationDay = durationHour * 24; +const durationWeek = durationDay * 7; +const durationMonth = durationDay * 30; +const durationYear = durationDay * 365; + +const second = timeInterval((date) => { + date.setTime(date - date.getMilliseconds()); +}, (date, step) => { + date.setTime(+date + step * durationSecond); +}, (start, end) => { + return (end - start) / durationSecond; +}, (date) => { + return date.getUTCSeconds(); +}); + +second.range; + +const timeMinute = timeInterval((date) => { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); +}, (date, step) => { + date.setTime(+date + step * durationMinute); +}, (start, end) => { + return (end - start) / durationMinute; +}, (date) => { + return date.getMinutes(); +}); + +timeMinute.range; + +const utcMinute = timeInterval((date) => { + date.setUTCSeconds(0, 0); +}, (date, step) => { + date.setTime(+date + step * durationMinute); +}, (start, end) => { + return (end - start) / durationMinute; +}, (date) => { + return date.getUTCMinutes(); +}); + +utcMinute.range; + +const timeHour = timeInterval((date) => { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); +}, (date, step) => { + date.setTime(+date + step * durationHour); +}, (start, end) => { + return (end - start) / durationHour; +}, (date) => { + return date.getHours(); +}); + +timeHour.range; + +const utcHour = timeInterval((date) => { + date.setUTCMinutes(0, 0, 0); +}, (date, step) => { + date.setTime(+date + step * durationHour); +}, (start, end) => { + return (end - start) / durationHour; +}, (date) => { + return date.getUTCHours(); +}); + +utcHour.range; + +const timeDay = timeInterval( + date => date.setHours(0, 0, 0, 0), + (date, step) => date.setDate(date.getDate() + step), + (start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, + date => date.getDate() - 1 +); + +timeDay.range; + +const utcDay = timeInterval((date) => { + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCDate(date.getUTCDate() + step); +}, (start, end) => { + return (end - start) / durationDay; +}, (date) => { + return date.getUTCDate() - 1; +}); + +utcDay.range; + +const unixDay = timeInterval((date) => { + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCDate(date.getUTCDate() + step); +}, (start, end) => { + return (end - start) / durationDay; +}, (date) => { + return Math.floor(date / durationDay); +}); + +unixDay.range; + +function timeWeekday(i) { + return timeInterval((date) => { + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, (date, step) => { + date.setDate(date.getDate() + step * 7); + }, (start, end) => { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; + }); +} + +const timeSunday = timeWeekday(0); +const timeMonday = timeWeekday(1); +const timeTuesday = timeWeekday(2); +const timeWednesday = timeWeekday(3); +const timeThursday = timeWeekday(4); +const timeFriday = timeWeekday(5); +const timeSaturday = timeWeekday(6); + +timeSunday.range; +timeMonday.range; +timeTuesday.range; +timeWednesday.range; +timeThursday.range; +timeFriday.range; +timeSaturday.range; + +function utcWeekday(i) { + return timeInterval((date) => { + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, (date, step) => { + date.setUTCDate(date.getUTCDate() + step * 7); + }, (start, end) => { + return (end - start) / durationWeek; + }); +} + +const utcSunday = utcWeekday(0); +const utcMonday = utcWeekday(1); +const utcTuesday = utcWeekday(2); +const utcWednesday = utcWeekday(3); +const utcThursday = utcWeekday(4); +const utcFriday = utcWeekday(5); +const utcSaturday = utcWeekday(6); + +utcSunday.range; +utcMonday.range; +utcTuesday.range; +utcWednesday.range; +utcThursday.range; +utcFriday.range; +utcSaturday.range; + +const timeMonth = timeInterval((date) => { + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, (date, step) => { + date.setMonth(date.getMonth() + step); +}, (start, end) => { + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, (date) => { + return date.getMonth(); +}); + +timeMonth.range; + +const utcMonth = timeInterval((date) => { + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCMonth(date.getUTCMonth() + step); +}, (start, end) => { + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, (date) => { + return date.getUTCMonth(); +}); + +utcMonth.range; + +const timeYear = timeInterval((date) => { + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, (date, step) => { + date.setFullYear(date.getFullYear() + step); +}, (start, end) => { + return end.getFullYear() - start.getFullYear(); +}, (date) => { + return date.getFullYear(); +}); + +// An optimized implementation for this simple case. +timeYear.every = (k) => { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, (date, step) => { + date.setFullYear(date.getFullYear() + step * k); + }); +}; + +timeYear.range; + +const utcYear = timeInterval((date) => { + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCFullYear(date.getUTCFullYear() + step); +}, (start, end) => { + return end.getUTCFullYear() - start.getUTCFullYear(); +}, (date) => { + return date.getUTCFullYear(); +}); + +// An optimized implementation for this simple case. +utcYear.every = (k) => { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, (date, step) => { + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; + +utcYear.range; + +function ticker(year, month, week, day, hour, minute) { + + const tickIntervals = [ + [second, 1, durationSecond], + [second, 5, 5 * durationSecond], + [second, 15, 15 * durationSecond], + [second, 30, 30 * durationSecond], + [minute, 1, durationMinute], + [minute, 5, 5 * durationMinute], + [minute, 15, 15 * durationMinute], + [minute, 30, 30 * durationMinute], + [ hour, 1, durationHour ], + [ hour, 3, 3 * durationHour ], + [ hour, 6, 6 * durationHour ], + [ hour, 12, 12 * durationHour ], + [ day, 1, durationDay ], + [ day, 2, 2 * durationDay ], + [ week, 1, durationWeek ], + [ month, 1, durationMonth ], + [ month, 3, 3 * durationMonth ], + [ year, 1, durationYear ] + ]; + + function ticks(start, stop, count) { + const reverse = stop < start; + if (reverse) [start, stop] = [stop, start]; + const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count); + const ticks = interval ? interval.range(start, +stop + 1) : []; // inclusive stop + return reverse ? ticks.reverse() : ticks; + } + + function tickInterval(start, stop, count) { + const target = Math.abs(stop - start) / count; + const i = bisector(([,, step]) => step).right(tickIntervals, target); + if (i === tickIntervals.length) return year.every(tickStep(start / durationYear, stop / durationYear, count)); + if (i === 0) return millisecond.every(Math.max(tickStep(start, stop, count), 1)); + const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; + return t.every(step); + } + + return [ticks, tickInterval]; +} +const [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute); + +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; + } + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); +} + +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; + } + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} + +function newDate(y, m, d) { + return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; +} + +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, + locale_date = locale.date, + locale_time = locale.time, + locale_periods = locale.periods, + locale_weekdays = locale.days, + locale_shortWeekdays = locale.shortDays, + locale_months = locale.months, + locale_shortMonths = locale.shortMonths; + + var periodRe = formatRe(locale_periods), + periodLookup = formatLookup(locale_periods), + weekdayRe = formatRe(locale_weekdays), + weekdayLookup = formatLookup(locale_weekdays), + shortWeekdayRe = formatRe(locale_shortWeekdays), + shortWeekdayLookup = formatLookup(locale_shortWeekdays), + monthRe = formatRe(locale_months), + monthLookup = formatLookup(locale_months), + shortMonthRe = formatRe(locale_shortMonths), + shortMonthLookup = formatLookup(locale_shortMonths); + + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "g": formatYearISO, + "G": formatFullYearISO, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent + }; + + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "g": formatUTCYearISO, + "G": formatUTCFullYearISO, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent + }; + + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "g": parseYear, + "G": parseFullYear, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + + function newFormat(specifier, formats) { + return function(date) { + var string = [], + i = -1, + j = 0, + n = specifier.length, + c, + pad, + format; + + if (!(date instanceof Date)) date = new Date(+date); + + while (++i < n) { + if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; + } + } + + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), + i = parseSpecifier(d, specifier, string += "", 0), + week, day; + if (i != string.length) return null; + + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week); + week = utcDay.offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week); + week = timeDay.offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; + } + + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); + } + + // Otherwise, all fields are in local time. + return localDate(d); + }; + } + + function parseSpecifier(d, specifier, string, j) { + var i = 0, + n = specifier.length, + m = string.length, + c, + parse; + + while (i < n) { + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || ((j = parse(d, string, j)) < 0)) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + + return j; + } + + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { return specifier; }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { return specifier; }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { return specifier; }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { return specifier; }; + return p; + } + }; +} + +var pads = {"-": "", "_": " ", "0": "0"}, + numberRe = /^\s*\d+/, // note: ignores next directive + percentRe = /^%/, + requoteRe = /[\\^$*+?|[\]().{}]/g; + +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", + string = (sign ? -value : value) + "", + length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +} + +function requote(s) { + return s.replace(requoteRe, "\\$&"); +} + +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); +} + +function formatLookup(names) { + return new Map(names.map((name, i) => [name.toLowerCase(), i])); +} + +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; +} + +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; +} + +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; +} + +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} + +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; +} + +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; +} + +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; +} + +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; +} + +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; +} + +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; +} + +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; +} + +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; +} + +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; +} + +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; +} + +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; +} + +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; +} + +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; +} + +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); +} + +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); +} + +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); +} + +function formatDayOfYear(d, p) { + return pad(1 + timeDay.count(timeYear(d), d), p, 3); +} + +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); +} + +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; +} + +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); +} + +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); +} + +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} + +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; +} + +function formatWeekNumberSunday(d, p) { + return pad(timeSunday.count(timeYear(d) - 1, d), p, 2); +} + +function dISO(d) { + var day = d.getDay(); + return (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); +} + +function formatWeekNumberISO(d, p) { + d = dISO(d); + return pad(timeThursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2); +} + +function formatWeekdayNumberSunday(d) { + return d.getDay(); +} + +function formatWeekNumberMonday(d, p) { + return pad(timeMonday.count(timeYear(d) - 1, d), p, 2); +} + +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); +} + +function formatYearISO(d, p) { + d = dISO(d); + return pad(d.getFullYear() % 100, p, 2); +} + +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatFullYearISO(d, p) { + var day = d.getDay(); + d = (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + + pad(z / 60 | 0, "0", 2) + + pad(z % 60, "0", 2); +} + +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); +} + +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); +} + +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); +} + +function formatUTCDayOfYear(d, p) { + return pad(1 + utcDay.count(utcYear(d), d), p, 3); +} + +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); +} + +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; +} + +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); +} + +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); +} + +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); +} + +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; +} + +function formatUTCWeekNumberSunday(d, p) { + return pad(utcSunday.count(utcYear(d) - 1, d), p, 2); +} + +function UTCdISO(d) { + var day = d.getUTCDay(); + return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); +} + +function formatUTCWeekNumberISO(d, p) { + d = UTCdISO(d); + return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2); +} + +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); +} + +function formatUTCWeekNumberMonday(d, p) { + return pad(utcMonday.count(utcYear(d) - 1, d), p, 2); +} + +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCYearISO(d, p) { + d = UTCdISO(d); + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCFullYearISO(d, p) { + var day = d.getUTCDay(); + d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCZone() { + return "+0000"; +} + +function formatLiteralPercent() { + return "%"; +} + +function formatUnixTimestamp(d) { + return +d; +} + +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +var locale; +var timeFormat; + +defaultLocale({ + dateTime: "%x, %X", + date: "%-m/%-d/%Y", + time: "%-I:%M:%S %p", + periods: ["AM", "PM"], + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + timeFormat = locale.format; + locale.parse; + locale.utcFormat; + locale.utcParse; + return locale; +} + +function date(t) { + return new Date(t); +} + +function number(t) { + return t instanceof Date ? +t : +new Date(+t); +} + +function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) { + var scale = continuous(), + invert = scale.invert, + domain = scale.domain; + + var formatMillisecond = format(".%L"), + formatSecond = format(":%S"), + formatMinute = format("%I:%M"), + formatHour = format("%I %p"), + formatDay = format("%a %d"), + formatWeek = format("%b %d"), + formatMonth = format("%B"), + formatYear = format("%Y"); + + function tickFormat(date) { + return (second(date) < date ? formatMillisecond + : minute(date) < date ? formatSecond + : hour(date) < date ? formatMinute + : day(date) < date ? formatHour + : month(date) < date ? (week(date) < date ? formatDay : formatWeek) + : year(date) < date ? formatMonth + : formatYear)(date); + } + + scale.invert = function(y) { + return new Date(invert(y)); + }; + + scale.domain = function(_) { + return arguments.length ? domain(Array.from(_, number)) : domain().map(date); + }; + + scale.ticks = function(interval) { + var d = domain(); + return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval); + }; + + scale.tickFormat = function(count, specifier) { + return specifier == null ? tickFormat : format(specifier); + }; + + scale.nice = function(interval) { + var d = domain(); + if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval); + return interval ? domain(nice(d, interval)) : scale; + }; + + scale.copy = function() { + return copy(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format)); + }; + + return scale; +} + +function time() { + return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments); +} + +var isoWeek = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e="day";return function(t,i,s){var a=function(t){return t.add(4-t.isoWeekday(),e)},d=i.prototype;d.isoWeekYear=function(){return a(this).year()},d.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),e);var i,d,n,o,r=a(this),u=(i=this.isoWeekYear(),d=this.$u,n=(d?s.utc:s)().year(i).startOf("year"),o=4-n.isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,e));return r.diff(u,"week")+1},d.isoWeekday=function(e){return this.$utils().u(e)?this.day()||7:this.day(this.day()%7?e:e-7)};var n=d.startOf;d.startOf=function(e,t){var i=this.$utils(),s=!!i.u(t)||t;return "isoweek"===i.p(e)?s?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):n.bind(this)(e,t)};}})); +} (isoWeek)); + +var isoWeekExports = isoWeek.exports; +var dayjsIsoWeek = /*@__PURE__*/getDefaultExportFromCjs(isoWeekExports); + +var customParseFormat = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}})); +} (customParseFormat)); + +var customParseFormatExports = customParseFormat.exports; +var dayjsCustomParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports); + +var advancedFormat = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){var r=t.prototype,n=r.format;r.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return n.bind(this)(e);var s=this.$utils(),a=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return r.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return r.ordinal(t.week(),"W");case"w":case"ww":return s.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return s.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return s.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return "["+t.offsetName()+"]";case"zzz":return "["+t.offsetName("long")+"]";default:return e}}));return n.bind(this)(a)};}})); +} (advancedFormat)); + +var advancedFormatExports = advancedFormat.exports; +var dayjsAdvancedFormat = /*@__PURE__*/getDefaultExportFromCjs(advancedFormatExports); + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 35, 37], $V1 = [1, 25], $V2 = [1, 26], $V3 = [1, 27], $V4 = [1, 28], $V5 = [1, 29], $V6 = [1, 30], $V7 = [1, 31], $V8 = [1, 9], $V9 = [1, 10], $Va = [1, 11], $Vb = [1, 12], $Vc = [1, 13], $Vd = [1, 14], $Ve = [1, 15], $Vf = [1, 16], $Vg = [1, 18], $Vh = [1, 19], $Vi = [1, 20], $Vj = [1, 21], $Vk = [1, 22], $Vl = [1, 24], $Vm = [1, 32]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "gantt": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NL": 10, "weekday": 11, "weekday_monday": 12, "weekday_tuesday": 13, "weekday_wednesday": 14, "weekday_thursday": 15, "weekday_friday": 16, "weekday_saturday": 17, "weekday_sunday": 18, "dateFormat": 19, "inclusiveEndDates": 20, "topAxis": 21, "axisFormat": 22, "tickInterval": 23, "excludes": 24, "includes": 25, "todayMarker": 26, "title": 27, "acc_title": 28, "acc_title_value": 29, "acc_descr": 30, "acc_descr_value": 31, "acc_descr_multiline_value": 32, "section": 33, "clickStatement": 34, "taskTxt": 35, "taskData": 36, "click": 37, "callbackname": 38, "callbackargs": 39, "href": 40, "clickStatementDebug": 41, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "gantt", 6: "EOF", 8: "SPACE", 10: "NL", 12: "weekday_monday", 13: "weekday_tuesday", 14: "weekday_wednesday", 15: "weekday_thursday", 16: "weekday_friday", 17: "weekday_saturday", 18: "weekday_sunday", 19: "dateFormat", 20: "inclusiveEndDates", 21: "topAxis", 22: "axisFormat", 23: "tickInterval", 24: "excludes", 25: "includes", 26: "todayMarker", 27: "title", 28: "acc_title", 29: "acc_title_value", 30: "acc_descr", 31: "acc_descr_value", 32: "acc_descr_multiline_value", 33: "section", 35: "taskTxt", 36: "taskData", 37: "click", 38: "callbackname", 39: "callbackargs", 40: "href" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [34, 2], [34, 3], [34, 3], [34, 4], [34, 3], [34, 4], [34, 2], [41, 2], [41, 3], [41, 3], [41, 4], [41, 3], [41, 4], [41, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.setWeekday("monday"); + break; + case 9: + yy.setWeekday("tuesday"); + break; + case 10: + yy.setWeekday("wednesday"); + break; + case 11: + yy.setWeekday("thursday"); + break; + case 12: + yy.setWeekday("friday"); + break; + case 13: + yy.setWeekday("saturday"); + break; + case 14: + yy.setWeekday("sunday"); + break; + case 15: + yy.setDateFormat($$[$0].substr(11)); + this.$ = $$[$0].substr(11); + break; + case 16: + yy.enableInclusiveEndDates(); + this.$ = $$[$0].substr(18); + break; + case 17: + yy.TopAxis(); + this.$ = $$[$0].substr(8); + break; + case 18: + yy.setAxisFormat($$[$0].substr(11)); + this.$ = $$[$0].substr(11); + break; + case 19: + yy.setTickInterval($$[$0].substr(13)); + this.$ = $$[$0].substr(13); + break; + case 20: + yy.setExcludes($$[$0].substr(9)); + this.$ = $$[$0].substr(9); + break; + case 21: + yy.setIncludes($$[$0].substr(9)); + this.$ = $$[$0].substr(9); + break; + case 22: + yy.setTodayMarker($$[$0].substr(12)); + this.$ = $$[$0].substr(12); + break; + case 24: + yy.setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 25: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 26: + case 27: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 28: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 30: + yy.addTask($$[$0 - 1], $$[$0]); + this.$ = "task"; + break; + case 31: + this.$ = $$[$0 - 1]; + yy.setClickEvent($$[$0 - 1], $$[$0], null); + break; + case 32: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 33: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], null); + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 34: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]); + yy.setLink($$[$0 - 3], $$[$0]); + break; + case 35: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0], null); + yy.setLink($$[$0 - 2], $$[$0 - 1]); + break; + case 36: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 1], $$[$0]); + yy.setLink($$[$0 - 3], $$[$0 - 2]); + break; + case 37: + this.$ = $$[$0 - 1]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 38: + case 44: + this.$ = $$[$0 - 1] + " " + $$[$0]; + break; + case 39: + case 40: + case 42: + this.$ = $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0]; + break; + case 41: + case 43: + this.$ = $$[$0 - 3] + " " + $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 17, 12: $V1, 13: $V2, 14: $V3, 15: $V4, 16: $V5, 17: $V6, 18: $V7, 19: $V8, 20: $V9, 21: $Va, 22: $Vb, 23: $Vc, 24: $Vd, 25: $Ve, 26: $Vf, 27: $Vg, 28: $Vh, 30: $Vi, 32: $Vj, 33: $Vk, 34: 23, 35: $Vl, 37: $Vm }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 33, 11: 17, 12: $V1, 13: $V2, 14: $V3, 15: $V4, 16: $V5, 17: $V6, 18: $V7, 19: $V8, 20: $V9, 21: $Va, 22: $Vb, 23: $Vc, 24: $Vd, 25: $Ve, 26: $Vf, 27: $Vg, 28: $Vh, 30: $Vi, 32: $Vj, 33: $Vk, 34: 23, 35: $Vl, 37: $Vm }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), o($V0, [2, 18]), o($V0, [2, 19]), o($V0, [2, 20]), o($V0, [2, 21]), o($V0, [2, 22]), o($V0, [2, 23]), o($V0, [2, 24]), { 29: [1, 34] }, { 31: [1, 35] }, o($V0, [2, 27]), o($V0, [2, 28]), o($V0, [2, 29]), { 36: [1, 36] }, o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 10]), o($V0, [2, 11]), o($V0, [2, 12]), o($V0, [2, 13]), o($V0, [2, 14]), { 38: [1, 37], 40: [1, 38] }, o($V0, [2, 4]), o($V0, [2, 25]), o($V0, [2, 26]), o($V0, [2, 30]), o($V0, [2, 31], { 39: [1, 39], 40: [1, 40] }), o($V0, [2, 37], { 38: [1, 41] }), o($V0, [2, 32], { 40: [1, 42] }), o($V0, [2, 33]), o($V0, [2, 35], { 39: [1, 43] }), o($V0, [2, 34]), o($V0, [2, 36])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("open_directive"); + return "open_directive"; + case 1: + this.begin("acc_title"); + return 28; + case 2: + this.popState(); + return "acc_title_value"; + case 3: + this.begin("acc_descr"); + return 30; + case 4: + this.popState(); + return "acc_descr_value"; + case 5: + this.begin("acc_descr_multiline"); + break; + case 6: + this.popState(); + break; + case 7: + return "acc_descr_multiline_value"; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + return 10; + case 12: + break; + case 13: + break; + case 14: + this.begin("href"); + break; + case 15: + this.popState(); + break; + case 16: + return 40; + case 17: + this.begin("callbackname"); + break; + case 18: + this.popState(); + break; + case 19: + this.popState(); + this.begin("callbackargs"); + break; + case 20: + return 38; + case 21: + this.popState(); + break; + case 22: + return 39; + case 23: + this.begin("click"); + break; + case 24: + this.popState(); + break; + case 25: + return 37; + case 26: + return 4; + case 27: + return 19; + case 28: + return 20; + case 29: + return 21; + case 30: + return 22; + case 31: + return 23; + case 32: + return 25; + case 33: + return 24; + case 34: + return 26; + case 35: + return 12; + case 36: + return 13; + case 37: + return 14; + case 38: + return 15; + case 39: + return 16; + case 40: + return 17; + case 41: + return 18; + case 42: + return "date"; + case 43: + return 27; + case 44: + return "accDescription"; + case 45: + return 33; + case 46: + return 35; + case 47: + return 36; + case 48: + return ":"; + case 49: + return 6; + case 50: + return "INVALID"; + } + }, + rules: [/^(?:%%\{)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:%%(?!\{)*[^\n]*)/i, /^(?:[^\}]%%*[^\n]*)/i, /^(?:%%*[^\n]*[\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:%[^\n]*)/i, /^(?:href[\s]+["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:call[\s]+)/i, /^(?:\([\s]*\))/i, /^(?:\()/i, /^(?:[^(]*)/i, /^(?:\))/i, /^(?:[^)]*)/i, /^(?:click[\s]+)/i, /^(?:[\s\n])/i, /^(?:[^\s\n]*)/i, /^(?:gantt\b)/i, /^(?:dateFormat\s[^#\n;]+)/i, /^(?:inclusiveEndDates\b)/i, /^(?:topAxis\b)/i, /^(?:axisFormat\s[^#\n;]+)/i, /^(?:tickInterval\s[^#\n;]+)/i, /^(?:includes\s[^#\n;]+)/i, /^(?:excludes\s[^#\n;]+)/i, /^(?:todayMarker\s[^\n;]+)/i, /^(?:weekday\s+monday\b)/i, /^(?:weekday\s+tuesday\b)/i, /^(?:weekday\s+wednesday\b)/i, /^(?:weekday\s+thursday\b)/i, /^(?:weekday\s+friday\b)/i, /^(?:weekday\s+saturday\b)/i, /^(?:weekday\s+sunday\b)/i, /^(?:\d\d\d\d-\d\d-\d\d\b)/i, /^(?:title\s[^\n]+)/i, /^(?:accDescription\s[^#\n;]+)/i, /^(?:section\s[^\n]+)/i, /^(?:[^:\n]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "callbackargs": { "rules": [21, 22], "inclusive": false }, "callbackname": { "rules": [18, 19, 20], "inclusive": false }, "href": { "rules": [15, 16], "inclusive": false }, "click": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 17, 23, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const ganttParser = parser; +dayjs.extend(dayjsIsoWeek); +dayjs.extend(dayjsCustomParseFormat); +dayjs.extend(dayjsAdvancedFormat); +let dateFormat = ""; +let axisFormat = ""; +let tickInterval = void 0; +let todayMarker = ""; +let includes = []; +let excludes = []; +let links = {}; +let sections = []; +let tasks = []; +let currentSection = ""; +let displayMode = ""; +const tags = ["active", "done", "crit", "milestone"]; +let funs = []; +let inclusiveEndDates = false; +let topAxis = false; +let weekday = "sunday"; +let lastOrder = 0; +const clear = function() { + sections = []; + tasks = []; + currentSection = ""; + funs = []; + taskCnt = 0; + lastTask = void 0; + lastTaskID = void 0; + rawTasks = []; + dateFormat = ""; + axisFormat = ""; + displayMode = ""; + tickInterval = void 0; + todayMarker = ""; + includes = []; + excludes = []; + inclusiveEndDates = false; + topAxis = false; + lastOrder = 0; + links = {}; + clear$1(); + weekday = "sunday"; +}; +const setAxisFormat = function(txt) { + axisFormat = txt; +}; +const getAxisFormat = function() { + return axisFormat; +}; +const setTickInterval = function(txt) { + tickInterval = txt; +}; +const getTickInterval = function() { + return tickInterval; +}; +const setTodayMarker = function(txt) { + todayMarker = txt; +}; +const getTodayMarker = function() { + return todayMarker; +}; +const setDateFormat = function(txt) { + dateFormat = txt; +}; +const enableInclusiveEndDates = function() { + inclusiveEndDates = true; +}; +const endDatesAreInclusive = function() { + return inclusiveEndDates; +}; +const enableTopAxis = function() { + topAxis = true; +}; +const topAxisEnabled = function() { + return topAxis; +}; +const setDisplayMode = function(txt) { + displayMode = txt; +}; +const getDisplayMode = function() { + return displayMode; +}; +const getDateFormat = function() { + return dateFormat; +}; +const setIncludes = function(txt) { + includes = txt.toLowerCase().split(/[\s,]+/); +}; +const getIncludes = function() { + return includes; +}; +const setExcludes = function(txt) { + excludes = txt.toLowerCase().split(/[\s,]+/); +}; +const getExcludes = function() { + return excludes; +}; +const getLinks = function() { + return links; +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 10; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks = rawTasks; + return tasks; +}; +const isInvalidDate = function(date, dateFormat2, excludes2, includes2) { + if (includes2.includes(date.format(dateFormat2.trim()))) { + return false; + } + if (date.isoWeekday() >= 6 && excludes2.includes("weekends")) { + return true; + } + if (excludes2.includes(date.format("dddd").toLowerCase())) { + return true; + } + return excludes2.includes(date.format(dateFormat2.trim())); +}; +const setWeekday = function(txt) { + weekday = txt; +}; +const getWeekday = function() { + return weekday; +}; +const checkTaskDates = function(task, dateFormat2, excludes2, includes2) { + if (!excludes2.length || task.manualEndTime) { + return; + } + let startTime; + if (task.startTime instanceof Date) { + startTime = dayjs(task.startTime); + } else { + startTime = dayjs(task.startTime, dateFormat2, true); + } + startTime = startTime.add(1, "d"); + let originalEndTime; + if (task.endTime instanceof Date) { + originalEndTime = dayjs(task.endTime); + } else { + originalEndTime = dayjs(task.endTime, dateFormat2, true); + } + const [fixedEndTime, renderEndTime] = fixTaskDates( + startTime, + originalEndTime, + dateFormat2, + excludes2, + includes2 + ); + task.endTime = fixedEndTime.toDate(); + task.renderEndTime = renderEndTime; +}; +const fixTaskDates = function(startTime, endTime, dateFormat2, excludes2, includes2) { + let invalid = false; + let renderEndTime = null; + while (startTime <= endTime) { + if (!invalid) { + renderEndTime = endTime.toDate(); + } + invalid = isInvalidDate(startTime, dateFormat2, excludes2, includes2); + if (invalid) { + endTime = endTime.add(1, "d"); + } + startTime = startTime.add(1, "d"); + } + return [endTime, renderEndTime]; +}; +const getStartDate = function(prevTime, dateFormat2, str) { + str = str.trim(); + const afterRePattern = /^after\s+(?[\d\w- ]+)/; + const afterStatement = afterRePattern.exec(str); + if (afterStatement !== null) { + let latestTask = null; + for (const id of afterStatement.groups.ids.split(" ")) { + let task = findTaskById(id); + if (task !== void 0 && (!latestTask || task.endTime > latestTask.endTime)) { + latestTask = task; + } + } + if (latestTask) { + return latestTask.endTime; + } + const today = /* @__PURE__ */ new Date(); + today.setHours(0, 0, 0, 0); + return today; + } + let mDate = dayjs(str, dateFormat2.trim(), true); + if (mDate.isValid()) { + return mDate.toDate(); + } else { + log$1.debug("Invalid date:" + str); + log$1.debug("With date format:" + dateFormat2.trim()); + const d = new Date(str); + if (d === void 0 || isNaN(d.getTime()) || // WebKit browsers can mis-parse invalid dates to be ridiculously + // huge numbers, e.g. new Date('202304') gets parsed as January 1, 202304. + // This can cause virtually infinite loops while rendering, so for the + // purposes of Gantt charts we'll just treat any date beyond 10,000 AD/BC as + // invalid. + d.getFullYear() < -1e4 || d.getFullYear() > 1e4) { + throw new Error("Invalid date:" + str); + } + return d; + } +}; +const parseDuration = function(str) { + const statement = /^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/.exec(str.trim()); + if (statement !== null) { + return [Number.parseFloat(statement[1]), statement[2]]; + } + return [NaN, "ms"]; +}; +const getEndDate = function(prevTime, dateFormat2, str, inclusive = false) { + str = str.trim(); + const untilRePattern = /^until\s+(?[\d\w- ]+)/; + const untilStatement = untilRePattern.exec(str); + if (untilStatement !== null) { + let earliestTask = null; + for (const id of untilStatement.groups.ids.split(" ")) { + let task = findTaskById(id); + if (task !== void 0 && (!earliestTask || task.startTime < earliestTask.startTime)) { + earliestTask = task; + } + } + if (earliestTask) { + return earliestTask.startTime; + } + const today = /* @__PURE__ */ new Date(); + today.setHours(0, 0, 0, 0); + return today; + } + let parsedDate = dayjs(str, dateFormat2.trim(), true); + if (parsedDate.isValid()) { + if (inclusive) { + parsedDate = parsedDate.add(1, "d"); + } + return parsedDate.toDate(); + } + let endTime = dayjs(prevTime); + const [durationValue, durationUnit] = parseDuration(str); + if (!Number.isNaN(durationValue)) { + const newEndTime = endTime.add(durationValue, durationUnit); + if (newEndTime.isValid()) { + endTime = newEndTime; + } + } + return endTime.toDate(); +}; +let taskCnt = 0; +const parseId = function(idStr) { + if (idStr === void 0) { + taskCnt = taskCnt + 1; + return "task" + taskCnt; + } + return idStr; +}; +const compileData = function(prevTask, dataStr) { + let ds; + if (dataStr.substr(0, 1) === ":") { + ds = dataStr.substr(1, dataStr.length); + } else { + ds = dataStr; + } + const data = ds.split(","); + const task = {}; + getTaskTags(data, task, tags); + for (let i = 0; i < data.length; i++) { + data[i] = data[i].trim(); + } + let endTimeData = ""; + switch (data.length) { + case 1: + task.id = parseId(); + task.startTime = prevTask.endTime; + endTimeData = data[0]; + break; + case 2: + task.id = parseId(); + task.startTime = getStartDate(void 0, dateFormat, data[0]); + endTimeData = data[1]; + break; + case 3: + task.id = parseId(data[0]); + task.startTime = getStartDate(void 0, dateFormat, data[1]); + endTimeData = data[2]; + break; + } + if (endTimeData) { + task.endTime = getEndDate(task.startTime, dateFormat, endTimeData, inclusiveEndDates); + task.manualEndTime = dayjs(endTimeData, "YYYY-MM-DD", true).isValid(); + checkTaskDates(task, dateFormat, excludes, includes); + } + return task; +}; +const parseData = function(prevTaskId, dataStr) { + let ds; + if (dataStr.substr(0, 1) === ":") { + ds = dataStr.substr(1, dataStr.length); + } else { + ds = dataStr; + } + const data = ds.split(","); + const task = {}; + getTaskTags(data, task, tags); + for (let i = 0; i < data.length; i++) { + data[i] = data[i].trim(); + } + switch (data.length) { + case 1: + task.id = parseId(); + task.startTime = { + type: "prevTaskEnd", + id: prevTaskId + }; + task.endTime = { + data: data[0] + }; + break; + case 2: + task.id = parseId(); + task.startTime = { + type: "getStartDate", + startData: data[0] + }; + task.endTime = { + data: data[1] + }; + break; + case 3: + task.id = parseId(data[0]); + task.startTime = { + type: "getStartDate", + startData: data[1] + }; + task.endTime = { + data: data[2] + }; + break; + } + return task; +}; +let lastTask; +let lastTaskID; +let rawTasks = []; +const taskDb = {}; +const addTask = function(descr, data) { + const rawTask = { + section: currentSection, + type: currentSection, + processed: false, + manualEndTime: false, + renderEndTime: null, + raw: { data }, + task: descr, + classes: [] + }; + const taskInfo = parseData(lastTaskID, data); + rawTask.raw.startTime = taskInfo.startTime; + rawTask.raw.endTime = taskInfo.endTime; + rawTask.id = taskInfo.id; + rawTask.prevTaskId = lastTaskID; + rawTask.active = taskInfo.active; + rawTask.done = taskInfo.done; + rawTask.crit = taskInfo.crit; + rawTask.milestone = taskInfo.milestone; + rawTask.order = lastOrder; + lastOrder++; + const pos = rawTasks.push(rawTask); + lastTaskID = rawTask.id; + taskDb[rawTask.id] = pos - 1; +}; +const findTaskById = function(id) { + const pos = taskDb[id]; + return rawTasks[pos]; +}; +const addTaskOrg = function(descr, data) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + const taskInfo = compileData(lastTask, data); + newTask.startTime = taskInfo.startTime; + newTask.endTime = taskInfo.endTime; + newTask.id = taskInfo.id; + newTask.active = taskInfo.active; + newTask.done = taskInfo.done; + newTask.crit = taskInfo.crit; + newTask.milestone = taskInfo.milestone; + lastTask = newTask; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + const task = rawTasks[pos]; + let startTime = ""; + switch (rawTasks[pos].raw.startTime.type) { + case "prevTaskEnd": { + const prevTask = findTaskById(task.prevTaskId); + task.startTime = prevTask.endTime; + break; + } + case "getStartDate": + startTime = getStartDate(void 0, dateFormat, rawTasks[pos].raw.startTime.startData); + if (startTime) { + rawTasks[pos].startTime = startTime; + } + break; + } + if (rawTasks[pos].startTime) { + rawTasks[pos].endTime = getEndDate( + rawTasks[pos].startTime, + dateFormat, + rawTasks[pos].raw.endTime.data, + inclusiveEndDates + ); + if (rawTasks[pos].endTime) { + rawTasks[pos].processed = true; + rawTasks[pos].manualEndTime = dayjs( + rawTasks[pos].raw.endTime.data, + "YYYY-MM-DD", + true + ).isValid(); + checkTaskDates(rawTasks[pos], dateFormat, excludes, includes); + } + } + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const setLink = function(ids, _linkStr) { + let linkStr = _linkStr; + if (getConfig().securityLevel !== "loose") { + linkStr = dist.sanitizeUrl(_linkStr); + } + ids.split(",").forEach(function(id) { + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + pushFun(id, () => { + window.open(linkStr, "_self"); + }); + links[id] = linkStr; + } + }); + setClass(ids, "clickable"); +}; +const setClass = function(ids, className) { + ids.split(",").forEach(function(id) { + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + rawTask.classes.push(className); + } + }); +}; +const setClickFun = function(id, functionName, functionArgs) { + if (getConfig().securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(id); + } + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + pushFun(id, () => { + utils.runFunc(functionName, ...argList); + }); + } +}; +const pushFun = function(id, callbackFunction) { + funs.push( + function() { + const elem = document.querySelector(`[id="${id}"]`); + if (elem !== null) { + elem.addEventListener("click", function() { + callbackFunction(); + }); + } + }, + function() { + const elem = document.querySelector(`[id="${id}-text"]`); + if (elem !== null) { + elem.addEventListener("click", function() { + callbackFunction(); + }); + } + } + ); +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFun(id, functionName, functionArgs); + }); + setClass(ids, "clickable"); +}; +const bindFunctions = function(element) { + funs.forEach(function(fun) { + fun(element); + }); +}; +const ganttDb = { + getConfig: () => getConfig().gantt, + clear, + setDateFormat, + getDateFormat, + enableInclusiveEndDates, + endDatesAreInclusive, + enableTopAxis, + topAxisEnabled, + setAxisFormat, + getAxisFormat, + setTickInterval, + getTickInterval, + setTodayMarker, + getTodayMarker, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + setDisplayMode, + getDisplayMode, + setAccDescription, + getAccDescription, + addSection, + getSections, + getTasks, + addTask, + findTaskById, + addTaskOrg, + setIncludes, + getIncludes, + setExcludes, + getExcludes, + setClickEvent, + setLink, + getLinks, + bindFunctions, + parseDuration, + isInvalidDate, + setWeekday, + getWeekday +}; +function getTaskTags(data, task, tags2) { + let matchFound = true; + while (matchFound) { + matchFound = false; + tags2.forEach(function(t) { + const pattern = "^\\s*" + t + "\\s*$"; + const regex = new RegExp(pattern); + if (data[0].match(regex)) { + task[t] = true; + data.shift(1); + matchFound = true; + } + }); + } +} +const setConf = function() { + log$1.debug("Something is calling, setConf, remove the call"); +}; +const mapWeekdayToTimeFunction = { + monday: timeMonday, + tuesday: timeTuesday, + wednesday: timeWednesday, + thursday: timeThursday, + friday: timeFriday, + saturday: timeSaturday, + sunday: timeSunday +}; +const getMaxIntersections = (tasks2, orderOffset) => { + let timeline = [...tasks2].map(() => -Infinity); + let sorted = [...tasks2].sort((a, b) => a.startTime - b.startTime || a.order - b.order); + let maxIntersections = 0; + for (const element of sorted) { + for (let j = 0; j < timeline.length; j++) { + if (element.startTime >= timeline[j]) { + timeline[j] = element.endTime; + element.order = j + orderOffset; + if (j > maxIntersections) { + maxIntersections = j; + } + break; + } + } + } + return maxIntersections; +}; +let w; +const draw = function(text, id, version, diagObj) { + const conf = getConfig().gantt; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const elem = doc.getElementById(id); + w = elem.parentElement.offsetWidth; + if (w === void 0) { + w = 1200; + } + if (conf.useWidth !== void 0) { + w = conf.useWidth; + } + const taskArray = diagObj.db.getTasks(); + let categories = []; + for (const element of taskArray) { + categories.push(element.type); + } + categories = checkUnique(categories); + const categoryHeights = {}; + let h = 2 * conf.topPadding; + if (diagObj.db.getDisplayMode() === "compact" || conf.displayMode === "compact") { + const categoryElements = {}; + for (const element of taskArray) { + if (categoryElements[element.section] === void 0) { + categoryElements[element.section] = [element]; + } else { + categoryElements[element.section].push(element); + } + } + let intersections = 0; + for (const category of Object.keys(categoryElements)) { + const categoryHeight = getMaxIntersections(categoryElements[category], intersections) + 1; + intersections += categoryHeight; + h += categoryHeight * (conf.barHeight + conf.barGap); + categoryHeights[category] = categoryHeight; + } + } else { + h += taskArray.length * (conf.barHeight + conf.barGap); + for (const category of categories) { + categoryHeights[category] = taskArray.filter((task) => task.type === category).length; + } + } + elem.setAttribute("viewBox", "0 0 " + w + " " + h); + const svg = root.select(`[id="${id}"]`); + const timeScale = time().domain([ + min(taskArray, function(d) { + return d.startTime; + }), + max(taskArray, function(d) { + return d.endTime; + }) + ]).rangeRound([0, w - conf.leftPadding - conf.rightPadding]); + function taskCompare(a, b) { + const taskA = a.startTime; + const taskB = b.startTime; + let result = 0; + if (taskA > taskB) { + result = 1; + } else if (taskA < taskB) { + result = -1; + } + return result; + } + taskArray.sort(taskCompare); + makeGantt(taskArray, w, h); + configureSvgSize(svg, h, w, conf.useMaxWidth); + svg.append("text").text(diagObj.db.getDiagramTitle()).attr("x", w / 2).attr("y", conf.titleTopMargin).attr("class", "titleText"); + function makeGantt(tasks2, pageWidth, pageHeight) { + const barHeight = conf.barHeight; + const gap = barHeight + conf.barGap; + const topPadding = conf.topPadding; + const leftPadding = conf.leftPadding; + const colorScale = linear().domain([0, categories.length]).range(["#00B9FA", "#F95002"]).interpolate(interpolateHcl); + drawExcludeDays( + gap, + topPadding, + leftPadding, + pageWidth, + pageHeight, + tasks2, + diagObj.db.getExcludes(), + diagObj.db.getIncludes() + ); + makeGrid(leftPadding, topPadding, pageWidth, pageHeight); + drawRects(tasks2, gap, topPadding, leftPadding, barHeight, colorScale, pageWidth); + vertLabels(gap, topPadding); + drawToday(leftPadding, topPadding, pageWidth, pageHeight); + } + function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w2) { + const uniqueTaskOrderIds = [...new Set(theArray.map((item) => item.order))]; + const uniqueTasks = uniqueTaskOrderIds.map((id2) => theArray.find((item) => item.order === id2)); + svg.append("g").selectAll("rect").data(uniqueTasks).enter().append("rect").attr("x", 0).attr("y", function(d, i) { + i = d.order; + return i * theGap + theTopPad - 2; + }).attr("width", function() { + return w2 - conf.rightPadding / 2; + }).attr("height", theGap).attr("class", function(d) { + for (const [i, category] of categories.entries()) { + if (d.type === category) { + return "section section" + i % conf.numberSectionStyles; + } + } + return "section section0"; + }); + const rectangles = svg.append("g").selectAll("rect").data(theArray).enter(); + const links2 = diagObj.db.getLinks(); + rectangles.append("rect").attr("id", function(d) { + return d.id; + }).attr("rx", 3).attr("ry", 3).attr("x", function(d) { + if (d.milestone) { + return timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight; + } + return timeScale(d.startTime) + theSidePad; + }).attr("y", function(d, i) { + i = d.order; + return i * theGap + theTopPad; + }).attr("width", function(d) { + if (d.milestone) { + return theBarHeight; + } + return timeScale(d.renderEndTime || d.endTime) - timeScale(d.startTime); + }).attr("height", theBarHeight).attr("transform-origin", function(d, i) { + i = d.order; + return (timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime))).toString() + "px " + (i * theGap + theTopPad + 0.5 * theBarHeight).toString() + "px"; + }).attr("class", function(d) { + const res = "task"; + let classStr = ""; + if (d.classes.length > 0) { + classStr = d.classes.join(" "); + } + let secNum = 0; + for (const [i, category] of categories.entries()) { + if (d.type === category) { + secNum = i % conf.numberSectionStyles; + } + } + let taskClass = ""; + if (d.active) { + if (d.crit) { + taskClass += " activeCrit"; + } else { + taskClass = " active"; + } + } else if (d.done) { + if (d.crit) { + taskClass = " doneCrit"; + } else { + taskClass = " done"; + } + } else { + if (d.crit) { + taskClass += " crit"; + } + } + if (taskClass.length === 0) { + taskClass = " task"; + } + if (d.milestone) { + taskClass = " milestone " + taskClass; + } + taskClass += secNum; + taskClass += " " + classStr; + return res + taskClass; + }); + rectangles.append("text").attr("id", function(d) { + return d.id + "-text"; + }).text(function(d) { + return d.task; + }).attr("font-size", conf.fontSize).attr("x", function(d) { + let startX = timeScale(d.startTime); + let endX = timeScale(d.renderEndTime || d.endTime); + if (d.milestone) { + startX += 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight; + } + if (d.milestone) { + endX = startX + theBarHeight; + } + const textWidth = this.getBBox().width; + if (textWidth > endX - startX) { + if (endX + textWidth + 1.5 * conf.leftPadding > w2) { + return startX + theSidePad - 5; + } else { + return endX + theSidePad + 5; + } + } else { + return (endX - startX) / 2 + startX + theSidePad; + } + }).attr("y", function(d, i) { + i = d.order; + return i * theGap + conf.barHeight / 2 + (conf.fontSize / 2 - 2) + theTopPad; + }).attr("text-height", theBarHeight).attr("class", function(d) { + const startX = timeScale(d.startTime); + let endX = timeScale(d.endTime); + if (d.milestone) { + endX = startX + theBarHeight; + } + const textWidth = this.getBBox().width; + let classStr = ""; + if (d.classes.length > 0) { + classStr = d.classes.join(" "); + } + let secNum = 0; + for (const [i, category] of categories.entries()) { + if (d.type === category) { + secNum = i % conf.numberSectionStyles; + } + } + let taskType = ""; + if (d.active) { + if (d.crit) { + taskType = "activeCritText" + secNum; + } else { + taskType = "activeText" + secNum; + } + } + if (d.done) { + if (d.crit) { + taskType = taskType + " doneCritText" + secNum; + } else { + taskType = taskType + " doneText" + secNum; + } + } else { + if (d.crit) { + taskType = taskType + " critText" + secNum; + } + } + if (d.milestone) { + taskType += " milestoneText"; + } + if (textWidth > endX - startX) { + if (endX + textWidth + 1.5 * conf.leftPadding > w2) { + return classStr + " taskTextOutsideLeft taskTextOutside" + secNum + " " + taskType; + } else { + return classStr + " taskTextOutsideRight taskTextOutside" + secNum + " " + taskType + " width-" + textWidth; + } + } else { + return classStr + " taskText taskText" + secNum + " " + taskType + " width-" + textWidth; + } + }); + const securityLevel2 = getConfig().securityLevel; + if (securityLevel2 === "sandbox") { + let sandboxElement2; + sandboxElement2 = select("#i" + id); + const doc2 = sandboxElement2.nodes()[0].contentDocument; + rectangles.filter(function(d) { + return links2[d.id] !== void 0; + }).each(function(o) { + var taskRect = doc2.querySelector("#" + o.id); + var taskText = doc2.querySelector("#" + o.id + "-text"); + const oldParent = taskRect.parentNode; + var Link = doc2.createElement("a"); + Link.setAttribute("xlink:href", links2[o.id]); + Link.setAttribute("target", "_top"); + oldParent.appendChild(Link); + Link.appendChild(taskRect); + Link.appendChild(taskText); + }); + } + } + function drawExcludeDays(theGap, theTopPad, theSidePad, w2, h2, tasks2, excludes2, includes2) { + if (excludes2.length === 0 && includes2.length === 0) { + return; + } + let minTime; + let maxTime; + for (const { startTime, endTime } of tasks2) { + if (minTime === void 0 || startTime < minTime) { + minTime = startTime; + } + if (maxTime === void 0 || endTime > maxTime) { + maxTime = endTime; + } + } + if (!minTime || !maxTime) { + return; + } + if (dayjs(maxTime).diff(dayjs(minTime), "year") > 5) { + log$1.warn( + "The difference between the min and max time is more than 5 years. This will cause performance issues. Skipping drawing exclude days." + ); + return; + } + const dateFormat2 = diagObj.db.getDateFormat(); + const excludeRanges = []; + let range = null; + let d = dayjs(minTime); + while (d.valueOf() <= maxTime) { + if (diagObj.db.isInvalidDate(d, dateFormat2, excludes2, includes2)) { + if (!range) { + range = { + start: d, + end: d + }; + } else { + range.end = d; + } + } else { + if (range) { + excludeRanges.push(range); + range = null; + } + } + d = d.add(1, "d"); + } + const rectangles = svg.append("g").selectAll("rect").data(excludeRanges).enter(); + rectangles.append("rect").attr("id", function(d2) { + return "exclude-" + d2.start.format("YYYY-MM-DD"); + }).attr("x", function(d2) { + return timeScale(d2.start) + theSidePad; + }).attr("y", conf.gridLineStartPadding).attr("width", function(d2) { + const renderEnd = d2.end.add(1, "day"); + return timeScale(renderEnd) - timeScale(d2.start); + }).attr("height", h2 - theTopPad - conf.gridLineStartPadding).attr("transform-origin", function(d2, i) { + return (timeScale(d2.start) + theSidePad + 0.5 * (timeScale(d2.end) - timeScale(d2.start))).toString() + "px " + (i * theGap + 0.5 * h2).toString() + "px"; + }).attr("class", "exclude-range"); + } + function makeGrid(theSidePad, theTopPad, w2, h2) { + let bottomXAxis = axisBottom(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d")); + const reTickInterval = /^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/; + const resultTickInterval = reTickInterval.exec( + diagObj.db.getTickInterval() || conf.tickInterval + ); + if (resultTickInterval !== null) { + const every = resultTickInterval[1]; + const interval = resultTickInterval[2]; + const weekday2 = diagObj.db.getWeekday() || conf.weekday; + switch (interval) { + case "millisecond": + bottomXAxis.ticks(millisecond.every(every)); + break; + case "second": + bottomXAxis.ticks(second.every(every)); + break; + case "minute": + bottomXAxis.ticks(timeMinute.every(every)); + break; + case "hour": + bottomXAxis.ticks(timeHour.every(every)); + break; + case "day": + bottomXAxis.ticks(timeDay.every(every)); + break; + case "week": + bottomXAxis.ticks(mapWeekdayToTimeFunction[weekday2].every(every)); + break; + case "month": + bottomXAxis.ticks(timeMonth.every(every)); + break; + } + } + svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + (h2 - 50) + ")").call(bottomXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10).attr("dy", "1em"); + if (diagObj.db.topAxisEnabled() || conf.topAxis) { + let topXAxis = axisTop(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d")); + if (resultTickInterval !== null) { + const every = resultTickInterval[1]; + const interval = resultTickInterval[2]; + const weekday2 = diagObj.db.getWeekday() || conf.weekday; + switch (interval) { + case "millisecond": + topXAxis.ticks(millisecond.every(every)); + break; + case "second": + topXAxis.ticks(second.every(every)); + break; + case "minute": + topXAxis.ticks(timeMinute.every(every)); + break; + case "hour": + topXAxis.ticks(timeHour.every(every)); + break; + case "day": + topXAxis.ticks(timeDay.every(every)); + break; + case "week": + topXAxis.ticks(mapWeekdayToTimeFunction[weekday2].every(every)); + break; + case "month": + topXAxis.ticks(timeMonth.every(every)); + break; + } + } + svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + theTopPad + ")").call(topXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10); + } + } + function vertLabels(theGap, theTopPad) { + let prevGap = 0; + const numOccurrences = Object.keys(categoryHeights).map((d) => [d, categoryHeights[d]]); + svg.append("g").selectAll("text").data(numOccurrences).enter().append(function(d) { + const rows = d[0].split(common$1.lineBreakRegex); + const dy = -(rows.length - 1) / 2; + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("dy", dy + "em"); + for (const [j, row] of rows.entries()) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttribute("alignment-baseline", "central"); + tspan.setAttribute("x", "10"); + if (j > 0) { + tspan.setAttribute("dy", "1em"); + } + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + return svgLabel; + }).attr("x", 10).attr("y", function(d, i) { + if (i > 0) { + for (let j = 0; j < i; j++) { + prevGap += numOccurrences[i - 1][1]; + return d[1] * theGap / 2 + prevGap * theGap + theTopPad; + } + } else { + return d[1] * theGap / 2 + theTopPad; + } + }).attr("font-size", conf.sectionFontSize).attr("class", function(d) { + for (const [i, category] of categories.entries()) { + if (d[0] === category) { + return "sectionTitle sectionTitle" + i % conf.numberSectionStyles; + } + } + return "sectionTitle"; + }); + } + function drawToday(theSidePad, theTopPad, w2, h2) { + const todayMarker2 = diagObj.db.getTodayMarker(); + if (todayMarker2 === "off") { + return; + } + const todayG = svg.append("g").attr("class", "today"); + const today = /* @__PURE__ */ new Date(); + const todayLine = todayG.append("line"); + todayLine.attr("x1", timeScale(today) + theSidePad).attr("x2", timeScale(today) + theSidePad).attr("y1", conf.titleTopMargin).attr("y2", h2 - conf.titleTopMargin).attr("class", "today"); + if (todayMarker2 !== "") { + todayLine.attr("style", todayMarker2.replace(/,/g, ";")); + } + } + function checkUnique(arr) { + const hash = {}; + const result = []; + for (let i = 0, l = arr.length; i < l; ++i) { + if (!Object.prototype.hasOwnProperty.call(hash, arr[i])) { + hash[arr[i]] = true; + result.push(arr[i]); + } + } + return result; + } +}; +const ganttRenderer = { + setConf, + draw +}; +const getStyles = (options) => ` + .mermaid-main-font { + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .exclude-range { + fill: ${options.excludeBkgColor}; + } + + .section { + stroke: none; + opacity: 0.2; + } + + .section0 { + fill: ${options.sectionBkgColor}; + } + + .section2 { + fill: ${options.sectionBkgColor2}; + } + + .section1, + .section3 { + fill: ${options.altSectionBkgColor}; + opacity: 0.2; + } + + .sectionTitle0 { + fill: ${options.titleColor}; + } + + .sectionTitle1 { + fill: ${options.titleColor}; + } + + .sectionTitle2 { + fill: ${options.titleColor}; + } + + .sectionTitle3 { + fill: ${options.titleColor}; + } + + .sectionTitle { + text-anchor: start; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + + /* Grid and axis */ + + .grid .tick { + stroke: ${options.gridColor}; + opacity: 0.8; + shape-rendering: crispEdges; + } + + .grid .tick text { + font-family: ${options.fontFamily}; + fill: ${options.textColor}; + } + + .grid path { + stroke-width: 0; + } + + + /* Today line */ + + .today { + fill: none; + stroke: ${options.todayLineColor}; + stroke-width: 2px; + } + + + /* Task styling */ + + /* Default task */ + + .task { + stroke-width: 2; + } + + .taskText { + text-anchor: middle; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .taskTextOutsideRight { + fill: ${options.taskTextDarkColor}; + text-anchor: start; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .taskTextOutsideLeft { + fill: ${options.taskTextDarkColor}; + text-anchor: end; + } + + + /* Special case clickable */ + + .task.clickable { + cursor: pointer; + } + + .taskText.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + .taskTextOutsideLeft.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + .taskTextOutsideRight.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + + /* Specific task settings for the sections*/ + + .taskText0, + .taskText1, + .taskText2, + .taskText3 { + fill: ${options.taskTextColor}; + } + + .task0, + .task1, + .task2, + .task3 { + fill: ${options.taskBkgColor}; + stroke: ${options.taskBorderColor}; + } + + .taskTextOutside0, + .taskTextOutside2 + { + fill: ${options.taskTextOutsideColor}; + } + + .taskTextOutside1, + .taskTextOutside3 { + fill: ${options.taskTextOutsideColor}; + } + + + /* Active task */ + + .active0, + .active1, + .active2, + .active3 { + fill: ${options.activeTaskBkgColor}; + stroke: ${options.activeTaskBorderColor}; + } + + .activeText0, + .activeText1, + .activeText2, + .activeText3 { + fill: ${options.taskTextDarkColor} !important; + } + + + /* Completed task */ + + .done0, + .done1, + .done2, + .done3 { + stroke: ${options.doneTaskBorderColor}; + fill: ${options.doneTaskBkgColor}; + stroke-width: 2; + } + + .doneText0, + .doneText1, + .doneText2, + .doneText3 { + fill: ${options.taskTextDarkColor} !important; + } + + + /* Tasks on the critical line */ + + .crit0, + .crit1, + .crit2, + .crit3 { + stroke: ${options.critBorderColor}; + fill: ${options.critBkgColor}; + stroke-width: 2; + } + + .activeCrit0, + .activeCrit1, + .activeCrit2, + .activeCrit3 { + stroke: ${options.critBorderColor}; + fill: ${options.activeTaskBkgColor}; + stroke-width: 2; + } + + .doneCrit0, + .doneCrit1, + .doneCrit2, + .doneCrit3 { + stroke: ${options.critBorderColor}; + fill: ${options.doneTaskBkgColor}; + stroke-width: 2; + cursor: pointer; + shape-rendering: crispEdges; + } + + .milestone { + transform: rotate(45deg) scale(0.8,0.8); + } + + .milestoneText { + font-style: italic; + } + .doneCritText0, + .doneCritText1, + .doneCritText2, + .doneCritText3 { + fill: ${options.taskTextDarkColor} !important; + } + + .activeCritText0, + .activeCritText1, + .activeCritText2, + .activeCritText3 { + fill: ${options.taskTextDarkColor} !important; + } + + .titleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.titleColor || options.textColor}; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } +`; +const ganttStyles = getStyles; +const diagram = { + parser: ganttParser, + db: ganttDb, + renderer: ganttRenderer, + styles: ganttStyles +}; + +export { diagram }; diff --git a/libs/marked/ganttDiagram-b62c793e-CQCA69Wn.js b/libs/marked/ganttDiagram-b62c793e-CQCA69Wn.js new file mode 100644 index 0000000..106cd21 --- /dev/null +++ b/libs/marked/ganttDiagram-b62c793e-CQCA69Wn.js @@ -0,0 +1,3581 @@ +import { J as define, K as extend, R as Rgb, L as Color, M as rgbConvert, N as nogamma, O as hue, P as commonjsGlobal, Q as getDefaultExportFromCjs, T as dayjs, c as getConfig, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, b as setAccDescription, a as getAccDescription, E as clear$1, m as dist, l as log$1, h as select, i as configureSvgSize, j as common$1, A as utils } from './index-CN3YjQ0n.js'; +import { b as bisector, t as tickStep, c as continuous, a as copy, l as linear } from './linear--P89MwVW.js'; +import { i as initRange } from './init-zpY4DTin.js'; + +function max(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +function identity(x) { + return x; +} + +var top = 1, + right = 2, + bottom = 3, + left = 4, + epsilon = 1e-6; + +function translateX(x) { + return "translate(" + x + ",0)"; +} + +function translateY(y) { + return "translate(0," + y + ")"; +} + +function number$1(scale) { + return d => +scale(d); +} + +function center(scale, offset) { + offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; + if (scale.round()) offset = Math.round(offset); + return d => +scale(d) + offset; +} + +function entering() { + return !this.__axis; +} + +function axis(orient, scale) { + var tickArguments = [], + tickValues = null, + tickFormat = null, + tickSizeInner = 6, + tickSizeOuter = 6, + tickPadding = 3, + offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, + k = orient === top || orient === left ? -1 : 1, + x = orient === left || orient === right ? "x" : "y", + transform = orient === top || orient === bottom ? translateX : translateY; + + function axis(context) { + var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues, + format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity) : tickFormat, + spacing = Math.max(tickSizeInner, 0) + tickPadding, + range = scale.range(), + range0 = +range[0] + offset, + range1 = +range[range.length - 1] + offset, + position = (scale.bandwidth ? center : number$1)(scale.copy(), offset), + selection = context.selection ? context.selection() : context, + path = selection.selectAll(".domain").data([null]), + tick = selection.selectAll(".tick").data(values, scale).order(), + tickExit = tick.exit(), + tickEnter = tick.enter().append("g").attr("class", "tick"), + line = tick.select("line"), + text = tick.select("text"); + + path = path.merge(path.enter().insert("path", ".tick") + .attr("class", "domain") + .attr("stroke", "currentColor")); + + tick = tick.merge(tickEnter); + + line = line.merge(tickEnter.append("line") + .attr("stroke", "currentColor") + .attr(x + "2", k * tickSizeInner)); + + text = text.merge(tickEnter.append("text") + .attr("fill", "currentColor") + .attr(x, k * spacing) + .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); + + if (context !== selection) { + path = path.transition(context); + tick = tick.transition(context); + line = line.transition(context); + text = text.transition(context); + + tickExit = tickExit.transition(context) + .attr("opacity", epsilon) + .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform"); }); + + tickEnter + .attr("opacity", epsilon) + .attr("transform", function(d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset); }); + } + + tickExit.remove(); + + path + .attr("d", orient === left || orient === right + ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1) + : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1)); + + tick + .attr("opacity", 1) + .attr("transform", function(d) { return transform(position(d) + offset); }); + + line + .attr(x + "2", k * tickSizeInner); + + text + .attr(x, k * spacing) + .text(format); + + selection.filter(entering) + .attr("fill", "none") + .attr("font-size", 10) + .attr("font-family", "sans-serif") + .attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle"); + + selection + .each(function() { this.__axis = position; }); + } + + axis.scale = function(_) { + return arguments.length ? (scale = _, axis) : scale; + }; + + axis.ticks = function() { + return tickArguments = Array.from(arguments), axis; + }; + + axis.tickArguments = function(_) { + return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice(); + }; + + axis.tickValues = function(_) { + return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice(); + }; + + axis.tickFormat = function(_) { + return arguments.length ? (tickFormat = _, axis) : tickFormat; + }; + + axis.tickSize = function(_) { + return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner; + }; + + axis.tickSizeInner = function(_) { + return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner; + }; + + axis.tickSizeOuter = function(_) { + return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter; + }; + + axis.tickPadding = function(_) { + return arguments.length ? (tickPadding = +_, axis) : tickPadding; + }; + + axis.offset = function(_) { + return arguments.length ? (offset = +_, axis) : offset; + }; + + return axis; +} + +function axisTop(scale) { + return axis(top, scale); +} + +function axisBottom(scale) { + return axis(bottom, scale); +} + +const radians = Math.PI / 180; +const degrees = 180 / Math.PI; + +// https://observablehq.com/@mbostock/lab-and-rgb +const K = 18, + Xn = 0.96422, + Yn = 1, + Zn = 0.82521, + t0$1 = 4 / 29, + t1$1 = 6 / 29, + t2 = 3 * t1$1 * t1$1, + t3 = t1$1 * t1$1 * t1$1; + +function labConvert(o) { + if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); + if (o instanceof Hcl) return hcl2lab(o); + if (!(o instanceof Rgb)) o = rgbConvert(o); + var r = rgb2lrgb(o.r), + g = rgb2lrgb(o.g), + b = rgb2lrgb(o.b), + y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } + return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); +} + +function lab(l, a, b, opacity) { + return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); +} + +function Lab(l, a, b, opacity) { + this.l = +l; + this.a = +a; + this.b = +b; + this.opacity = +opacity; +} + +define(Lab, lab, extend(Color, { + brighter(k) { + return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + darker(k) { + return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + rgb() { + var y = (this.l + 16) / 116, + x = isNaN(this.a) ? y : y + this.a / 500, + z = isNaN(this.b) ? y : y - this.b / 200; + x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); + z = Zn * lab2xyz(z); + return new Rgb( + lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), + this.opacity + ); + } +})); + +function xyz2lab(t) { + return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0$1; +} + +function lab2xyz(t) { + return t > t1$1 ? t * t * t : t2 * (t - t0$1); +} + +function lrgb2rgb(x) { + return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); +} + +function rgb2lrgb(x) { + return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); +} + +function hclConvert(o) { + if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); + if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); + var h = Math.atan2(o.b, o.a) * degrees; + return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); +} + +function hcl$1(h, c, l, opacity) { + return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} + +function Hcl(h, c, l, opacity) { + this.h = +h; + this.c = +c; + this.l = +l; + this.opacity = +opacity; +} + +function hcl2lab(o) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); + var h = o.h * radians; + return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); +} + +define(Hcl, hcl$1, extend(Color, { + brighter(k) { + return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity); + }, + darker(k) { + return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity); + }, + rgb() { + return hcl2lab(this).rgb(); + } +})); + +function hcl(hue) { + return function(start, end) { + var h = hue((start = hcl$1(start)).h, (end = hcl$1(end)).h), + c = nogamma(start.c, end.c), + l = nogamma(start.l, end.l), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.c = c(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + } +} + +var interpolateHcl = hcl(hue); + +function nice(domain, interval) { + domain = domain.slice(); + + var i0 = 0, + i1 = domain.length - 1, + x0 = domain[i0], + x1 = domain[i1], + t; + + if (x1 < x0) { + t = i0, i0 = i1, i1 = t; + t = x0, x0 = x1, x1 = t; + } + + domain[i0] = interval.floor(x0); + domain[i1] = interval.ceil(x1); + return domain; +} + +const t0 = new Date, t1 = new Date; + +function timeInterval(floori, offseti, count, field) { + + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + + interval.floor = (date) => { + return floori(date = new Date(+date)), date; + }; + + interval.ceil = (date) => { + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; + }; + + interval.round = (date) => { + const d0 = interval(date), d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + + interval.offset = (date, step) => { + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + + interval.range = (start, stop, step) => { + const range = []; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + let previous; + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + + interval.filter = (test) => { + return timeInterval((date) => { + if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); + }, (date, step) => { + if (date >= date) { + if (step < 0) while (++step <= 0) { + while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty + } else while (--step >= 0) { + while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty + } + } + }); + }; + + if (count) { + interval.count = (start, end) => { + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + + interval.every = (step) => { + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null + : !(step > 1) ? interval + : interval.filter(field + ? (d) => field(d) % step === 0 + : (d) => interval.count(0, d) % step === 0); + }; + } + + return interval; +} + +const millisecond = timeInterval(() => { + // noop +}, (date, step) => { + date.setTime(+date + step); +}, (start, end) => { + return end - start; +}); + +// An optimized implementation for this simple case. +millisecond.every = (k) => { + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return timeInterval((date) => { + date.setTime(Math.floor(date / k) * k); + }, (date, step) => { + date.setTime(+date + step * k); + }, (start, end) => { + return (end - start) / k; + }); +}; + +millisecond.range; + +const durationSecond = 1000; +const durationMinute = durationSecond * 60; +const durationHour = durationMinute * 60; +const durationDay = durationHour * 24; +const durationWeek = durationDay * 7; +const durationMonth = durationDay * 30; +const durationYear = durationDay * 365; + +const second = timeInterval((date) => { + date.setTime(date - date.getMilliseconds()); +}, (date, step) => { + date.setTime(+date + step * durationSecond); +}, (start, end) => { + return (end - start) / durationSecond; +}, (date) => { + return date.getUTCSeconds(); +}); + +second.range; + +const timeMinute = timeInterval((date) => { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); +}, (date, step) => { + date.setTime(+date + step * durationMinute); +}, (start, end) => { + return (end - start) / durationMinute; +}, (date) => { + return date.getMinutes(); +}); + +timeMinute.range; + +const utcMinute = timeInterval((date) => { + date.setUTCSeconds(0, 0); +}, (date, step) => { + date.setTime(+date + step * durationMinute); +}, (start, end) => { + return (end - start) / durationMinute; +}, (date) => { + return date.getUTCMinutes(); +}); + +utcMinute.range; + +const timeHour = timeInterval((date) => { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); +}, (date, step) => { + date.setTime(+date + step * durationHour); +}, (start, end) => { + return (end - start) / durationHour; +}, (date) => { + return date.getHours(); +}); + +timeHour.range; + +const utcHour = timeInterval((date) => { + date.setUTCMinutes(0, 0, 0); +}, (date, step) => { + date.setTime(+date + step * durationHour); +}, (start, end) => { + return (end - start) / durationHour; +}, (date) => { + return date.getUTCHours(); +}); + +utcHour.range; + +const timeDay = timeInterval( + date => date.setHours(0, 0, 0, 0), + (date, step) => date.setDate(date.getDate() + step), + (start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, + date => date.getDate() - 1 +); + +timeDay.range; + +const utcDay = timeInterval((date) => { + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCDate(date.getUTCDate() + step); +}, (start, end) => { + return (end - start) / durationDay; +}, (date) => { + return date.getUTCDate() - 1; +}); + +utcDay.range; + +const unixDay = timeInterval((date) => { + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCDate(date.getUTCDate() + step); +}, (start, end) => { + return (end - start) / durationDay; +}, (date) => { + return Math.floor(date / durationDay); +}); + +unixDay.range; + +function timeWeekday(i) { + return timeInterval((date) => { + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, (date, step) => { + date.setDate(date.getDate() + step * 7); + }, (start, end) => { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; + }); +} + +const timeSunday = timeWeekday(0); +const timeMonday = timeWeekday(1); +const timeTuesday = timeWeekday(2); +const timeWednesday = timeWeekday(3); +const timeThursday = timeWeekday(4); +const timeFriday = timeWeekday(5); +const timeSaturday = timeWeekday(6); + +timeSunday.range; +timeMonday.range; +timeTuesday.range; +timeWednesday.range; +timeThursday.range; +timeFriday.range; +timeSaturday.range; + +function utcWeekday(i) { + return timeInterval((date) => { + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, (date, step) => { + date.setUTCDate(date.getUTCDate() + step * 7); + }, (start, end) => { + return (end - start) / durationWeek; + }); +} + +const utcSunday = utcWeekday(0); +const utcMonday = utcWeekday(1); +const utcTuesday = utcWeekday(2); +const utcWednesday = utcWeekday(3); +const utcThursday = utcWeekday(4); +const utcFriday = utcWeekday(5); +const utcSaturday = utcWeekday(6); + +utcSunday.range; +utcMonday.range; +utcTuesday.range; +utcWednesday.range; +utcThursday.range; +utcFriday.range; +utcSaturday.range; + +const timeMonth = timeInterval((date) => { + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, (date, step) => { + date.setMonth(date.getMonth() + step); +}, (start, end) => { + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, (date) => { + return date.getMonth(); +}); + +timeMonth.range; + +const utcMonth = timeInterval((date) => { + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCMonth(date.getUTCMonth() + step); +}, (start, end) => { + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, (date) => { + return date.getUTCMonth(); +}); + +utcMonth.range; + +const timeYear = timeInterval((date) => { + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, (date, step) => { + date.setFullYear(date.getFullYear() + step); +}, (start, end) => { + return end.getFullYear() - start.getFullYear(); +}, (date) => { + return date.getFullYear(); +}); + +// An optimized implementation for this simple case. +timeYear.every = (k) => { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, (date, step) => { + date.setFullYear(date.getFullYear() + step * k); + }); +}; + +timeYear.range; + +const utcYear = timeInterval((date) => { + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCFullYear(date.getUTCFullYear() + step); +}, (start, end) => { + return end.getUTCFullYear() - start.getUTCFullYear(); +}, (date) => { + return date.getUTCFullYear(); +}); + +// An optimized implementation for this simple case. +utcYear.every = (k) => { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, (date, step) => { + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; + +utcYear.range; + +function ticker(year, month, week, day, hour, minute) { + + const tickIntervals = [ + [second, 1, durationSecond], + [second, 5, 5 * durationSecond], + [second, 15, 15 * durationSecond], + [second, 30, 30 * durationSecond], + [minute, 1, durationMinute], + [minute, 5, 5 * durationMinute], + [minute, 15, 15 * durationMinute], + [minute, 30, 30 * durationMinute], + [ hour, 1, durationHour ], + [ hour, 3, 3 * durationHour ], + [ hour, 6, 6 * durationHour ], + [ hour, 12, 12 * durationHour ], + [ day, 1, durationDay ], + [ day, 2, 2 * durationDay ], + [ week, 1, durationWeek ], + [ month, 1, durationMonth ], + [ month, 3, 3 * durationMonth ], + [ year, 1, durationYear ] + ]; + + function ticks(start, stop, count) { + const reverse = stop < start; + if (reverse) [start, stop] = [stop, start]; + const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count); + const ticks = interval ? interval.range(start, +stop + 1) : []; // inclusive stop + return reverse ? ticks.reverse() : ticks; + } + + function tickInterval(start, stop, count) { + const target = Math.abs(stop - start) / count; + const i = bisector(([,, step]) => step).right(tickIntervals, target); + if (i === tickIntervals.length) return year.every(tickStep(start / durationYear, stop / durationYear, count)); + if (i === 0) return millisecond.every(Math.max(tickStep(start, stop, count), 1)); + const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; + return t.every(step); + } + + return [ticks, tickInterval]; +} +const [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute); + +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; + } + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); +} + +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; + } + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} + +function newDate(y, m, d) { + return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; +} + +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, + locale_date = locale.date, + locale_time = locale.time, + locale_periods = locale.periods, + locale_weekdays = locale.days, + locale_shortWeekdays = locale.shortDays, + locale_months = locale.months, + locale_shortMonths = locale.shortMonths; + + var periodRe = formatRe(locale_periods), + periodLookup = formatLookup(locale_periods), + weekdayRe = formatRe(locale_weekdays), + weekdayLookup = formatLookup(locale_weekdays), + shortWeekdayRe = formatRe(locale_shortWeekdays), + shortWeekdayLookup = formatLookup(locale_shortWeekdays), + monthRe = formatRe(locale_months), + monthLookup = formatLookup(locale_months), + shortMonthRe = formatRe(locale_shortMonths), + shortMonthLookup = formatLookup(locale_shortMonths); + + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "g": formatYearISO, + "G": formatFullYearISO, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent + }; + + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "g": formatUTCYearISO, + "G": formatUTCFullYearISO, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent + }; + + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "g": parseYear, + "G": parseFullYear, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + + function newFormat(specifier, formats) { + return function(date) { + var string = [], + i = -1, + j = 0, + n = specifier.length, + c, + pad, + format; + + if (!(date instanceof Date)) date = new Date(+date); + + while (++i < n) { + if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; + } + } + + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), + i = parseSpecifier(d, specifier, string += "", 0), + week, day; + if (i != string.length) return null; + + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week); + week = utcDay.offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week); + week = timeDay.offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; + } + + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); + } + + // Otherwise, all fields are in local time. + return localDate(d); + }; + } + + function parseSpecifier(d, specifier, string, j) { + var i = 0, + n = specifier.length, + m = string.length, + c, + parse; + + while (i < n) { + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || ((j = parse(d, string, j)) < 0)) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + + return j; + } + + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { return specifier; }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { return specifier; }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { return specifier; }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { return specifier; }; + return p; + } + }; +} + +var pads = {"-": "", "_": " ", "0": "0"}, + numberRe = /^\s*\d+/, // note: ignores next directive + percentRe = /^%/, + requoteRe = /[\\^$*+?|[\]().{}]/g; + +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", + string = (sign ? -value : value) + "", + length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +} + +function requote(s) { + return s.replace(requoteRe, "\\$&"); +} + +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); +} + +function formatLookup(names) { + return new Map(names.map((name, i) => [name.toLowerCase(), i])); +} + +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; +} + +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; +} + +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; +} + +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} + +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; +} + +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; +} + +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; +} + +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; +} + +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; +} + +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; +} + +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; +} + +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; +} + +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; +} + +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; +} + +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; +} + +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; +} + +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; +} + +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); +} + +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); +} + +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); +} + +function formatDayOfYear(d, p) { + return pad(1 + timeDay.count(timeYear(d), d), p, 3); +} + +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); +} + +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; +} + +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); +} + +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); +} + +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} + +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; +} + +function formatWeekNumberSunday(d, p) { + return pad(timeSunday.count(timeYear(d) - 1, d), p, 2); +} + +function dISO(d) { + var day = d.getDay(); + return (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); +} + +function formatWeekNumberISO(d, p) { + d = dISO(d); + return pad(timeThursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2); +} + +function formatWeekdayNumberSunday(d) { + return d.getDay(); +} + +function formatWeekNumberMonday(d, p) { + return pad(timeMonday.count(timeYear(d) - 1, d), p, 2); +} + +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); +} + +function formatYearISO(d, p) { + d = dISO(d); + return pad(d.getFullYear() % 100, p, 2); +} + +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatFullYearISO(d, p) { + var day = d.getDay(); + d = (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + + pad(z / 60 | 0, "0", 2) + + pad(z % 60, "0", 2); +} + +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); +} + +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); +} + +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); +} + +function formatUTCDayOfYear(d, p) { + return pad(1 + utcDay.count(utcYear(d), d), p, 3); +} + +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); +} + +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; +} + +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); +} + +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); +} + +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); +} + +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; +} + +function formatUTCWeekNumberSunday(d, p) { + return pad(utcSunday.count(utcYear(d) - 1, d), p, 2); +} + +function UTCdISO(d) { + var day = d.getUTCDay(); + return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); +} + +function formatUTCWeekNumberISO(d, p) { + d = UTCdISO(d); + return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2); +} + +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); +} + +function formatUTCWeekNumberMonday(d, p) { + return pad(utcMonday.count(utcYear(d) - 1, d), p, 2); +} + +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCYearISO(d, p) { + d = UTCdISO(d); + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCFullYearISO(d, p) { + var day = d.getUTCDay(); + d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCZone() { + return "+0000"; +} + +function formatLiteralPercent() { + return "%"; +} + +function formatUnixTimestamp(d) { + return +d; +} + +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +var locale; +var timeFormat; + +defaultLocale({ + dateTime: "%x, %X", + date: "%-m/%-d/%Y", + time: "%-I:%M:%S %p", + periods: ["AM", "PM"], + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + timeFormat = locale.format; + locale.parse; + locale.utcFormat; + locale.utcParse; + return locale; +} + +function date(t) { + return new Date(t); +} + +function number(t) { + return t instanceof Date ? +t : +new Date(+t); +} + +function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) { + var scale = continuous(), + invert = scale.invert, + domain = scale.domain; + + var formatMillisecond = format(".%L"), + formatSecond = format(":%S"), + formatMinute = format("%I:%M"), + formatHour = format("%I %p"), + formatDay = format("%a %d"), + formatWeek = format("%b %d"), + formatMonth = format("%B"), + formatYear = format("%Y"); + + function tickFormat(date) { + return (second(date) < date ? formatMillisecond + : minute(date) < date ? formatSecond + : hour(date) < date ? formatMinute + : day(date) < date ? formatHour + : month(date) < date ? (week(date) < date ? formatDay : formatWeek) + : year(date) < date ? formatMonth + : formatYear)(date); + } + + scale.invert = function(y) { + return new Date(invert(y)); + }; + + scale.domain = function(_) { + return arguments.length ? domain(Array.from(_, number)) : domain().map(date); + }; + + scale.ticks = function(interval) { + var d = domain(); + return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval); + }; + + scale.tickFormat = function(count, specifier) { + return specifier == null ? tickFormat : format(specifier); + }; + + scale.nice = function(interval) { + var d = domain(); + if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval); + return interval ? domain(nice(d, interval)) : scale; + }; + + scale.copy = function() { + return copy(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format)); + }; + + return scale; +} + +function time() { + return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments); +} + +var isoWeek = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e="day";return function(t,i,s){var a=function(t){return t.add(4-t.isoWeekday(),e)},d=i.prototype;d.isoWeekYear=function(){return a(this).year()},d.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),e);var i,d,n,o,r=a(this),u=(i=this.isoWeekYear(),d=this.$u,n=(d?s.utc:s)().year(i).startOf("year"),o=4-n.isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,e));return r.diff(u,"week")+1},d.isoWeekday=function(e){return this.$utils().u(e)?this.day()||7:this.day(this.day()%7?e:e-7)};var n=d.startOf;d.startOf=function(e,t){var i=this.$utils(),s=!!i.u(t)||t;return "isoweek"===i.p(e)?s?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):n.bind(this)(e,t)};}})); +} (isoWeek)); + +var isoWeekExports = isoWeek.exports; +var dayjsIsoWeek = /*@__PURE__*/getDefaultExportFromCjs(isoWeekExports); + +var customParseFormat = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}})); +} (customParseFormat)); + +var customParseFormatExports = customParseFormat.exports; +var dayjsCustomParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports); + +var advancedFormat = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal,(function(){return function(e,t){var r=t.prototype,n=r.format;r.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return n.bind(this)(e);var s=this.$utils(),a=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return r.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return r.ordinal(t.week(),"W");case"w":case"ww":return s.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return s.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return s.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return "["+t.offsetName()+"]";case"zzz":return "["+t.offsetName("long")+"]";default:return e}}));return n.bind(this)(a)};}})); +} (advancedFormat)); + +var advancedFormatExports = advancedFormat.exports; +var dayjsAdvancedFormat = /*@__PURE__*/getDefaultExportFromCjs(advancedFormatExports); + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 35, 37], $V1 = [1, 25], $V2 = [1, 26], $V3 = [1, 27], $V4 = [1, 28], $V5 = [1, 29], $V6 = [1, 30], $V7 = [1, 31], $V8 = [1, 9], $V9 = [1, 10], $Va = [1, 11], $Vb = [1, 12], $Vc = [1, 13], $Vd = [1, 14], $Ve = [1, 15], $Vf = [1, 16], $Vg = [1, 18], $Vh = [1, 19], $Vi = [1, 20], $Vj = [1, 21], $Vk = [1, 22], $Vl = [1, 24], $Vm = [1, 32]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "gantt": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NL": 10, "weekday": 11, "weekday_monday": 12, "weekday_tuesday": 13, "weekday_wednesday": 14, "weekday_thursday": 15, "weekday_friday": 16, "weekday_saturday": 17, "weekday_sunday": 18, "dateFormat": 19, "inclusiveEndDates": 20, "topAxis": 21, "axisFormat": 22, "tickInterval": 23, "excludes": 24, "includes": 25, "todayMarker": 26, "title": 27, "acc_title": 28, "acc_title_value": 29, "acc_descr": 30, "acc_descr_value": 31, "acc_descr_multiline_value": 32, "section": 33, "clickStatement": 34, "taskTxt": 35, "taskData": 36, "click": 37, "callbackname": 38, "callbackargs": 39, "href": 40, "clickStatementDebug": 41, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "gantt", 6: "EOF", 8: "SPACE", 10: "NL", 12: "weekday_monday", 13: "weekday_tuesday", 14: "weekday_wednesday", 15: "weekday_thursday", 16: "weekday_friday", 17: "weekday_saturday", 18: "weekday_sunday", 19: "dateFormat", 20: "inclusiveEndDates", 21: "topAxis", 22: "axisFormat", 23: "tickInterval", 24: "excludes", 25: "includes", 26: "todayMarker", 27: "title", 28: "acc_title", 29: "acc_title_value", 30: "acc_descr", 31: "acc_descr_value", 32: "acc_descr_multiline_value", 33: "section", 35: "taskTxt", 36: "taskData", 37: "click", 38: "callbackname", 39: "callbackargs", 40: "href" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [34, 2], [34, 3], [34, 3], [34, 4], [34, 3], [34, 4], [34, 2], [41, 2], [41, 3], [41, 3], [41, 4], [41, 3], [41, 4], [41, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.setWeekday("monday"); + break; + case 9: + yy.setWeekday("tuesday"); + break; + case 10: + yy.setWeekday("wednesday"); + break; + case 11: + yy.setWeekday("thursday"); + break; + case 12: + yy.setWeekday("friday"); + break; + case 13: + yy.setWeekday("saturday"); + break; + case 14: + yy.setWeekday("sunday"); + break; + case 15: + yy.setDateFormat($$[$0].substr(11)); + this.$ = $$[$0].substr(11); + break; + case 16: + yy.enableInclusiveEndDates(); + this.$ = $$[$0].substr(18); + break; + case 17: + yy.TopAxis(); + this.$ = $$[$0].substr(8); + break; + case 18: + yy.setAxisFormat($$[$0].substr(11)); + this.$ = $$[$0].substr(11); + break; + case 19: + yy.setTickInterval($$[$0].substr(13)); + this.$ = $$[$0].substr(13); + break; + case 20: + yy.setExcludes($$[$0].substr(9)); + this.$ = $$[$0].substr(9); + break; + case 21: + yy.setIncludes($$[$0].substr(9)); + this.$ = $$[$0].substr(9); + break; + case 22: + yy.setTodayMarker($$[$0].substr(12)); + this.$ = $$[$0].substr(12); + break; + case 24: + yy.setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 25: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 26: + case 27: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 28: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 30: + yy.addTask($$[$0 - 1], $$[$0]); + this.$ = "task"; + break; + case 31: + this.$ = $$[$0 - 1]; + yy.setClickEvent($$[$0 - 1], $$[$0], null); + break; + case 32: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 33: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], null); + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 34: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]); + yy.setLink($$[$0 - 3], $$[$0]); + break; + case 35: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0], null); + yy.setLink($$[$0 - 2], $$[$0 - 1]); + break; + case 36: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 1], $$[$0]); + yy.setLink($$[$0 - 3], $$[$0 - 2]); + break; + case 37: + this.$ = $$[$0 - 1]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 38: + case 44: + this.$ = $$[$0 - 1] + " " + $$[$0]; + break; + case 39: + case 40: + case 42: + this.$ = $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0]; + break; + case 41: + case 43: + this.$ = $$[$0 - 3] + " " + $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 17, 12: $V1, 13: $V2, 14: $V3, 15: $V4, 16: $V5, 17: $V6, 18: $V7, 19: $V8, 20: $V9, 21: $Va, 22: $Vb, 23: $Vc, 24: $Vd, 25: $Ve, 26: $Vf, 27: $Vg, 28: $Vh, 30: $Vi, 32: $Vj, 33: $Vk, 34: 23, 35: $Vl, 37: $Vm }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 33, 11: 17, 12: $V1, 13: $V2, 14: $V3, 15: $V4, 16: $V5, 17: $V6, 18: $V7, 19: $V8, 20: $V9, 21: $Va, 22: $Vb, 23: $Vc, 24: $Vd, 25: $Ve, 26: $Vf, 27: $Vg, 28: $Vh, 30: $Vi, 32: $Vj, 33: $Vk, 34: 23, 35: $Vl, 37: $Vm }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), o($V0, [2, 18]), o($V0, [2, 19]), o($V0, [2, 20]), o($V0, [2, 21]), o($V0, [2, 22]), o($V0, [2, 23]), o($V0, [2, 24]), { 29: [1, 34] }, { 31: [1, 35] }, o($V0, [2, 27]), o($V0, [2, 28]), o($V0, [2, 29]), { 36: [1, 36] }, o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 10]), o($V0, [2, 11]), o($V0, [2, 12]), o($V0, [2, 13]), o($V0, [2, 14]), { 38: [1, 37], 40: [1, 38] }, o($V0, [2, 4]), o($V0, [2, 25]), o($V0, [2, 26]), o($V0, [2, 30]), o($V0, [2, 31], { 39: [1, 39], 40: [1, 40] }), o($V0, [2, 37], { 38: [1, 41] }), o($V0, [2, 32], { 40: [1, 42] }), o($V0, [2, 33]), o($V0, [2, 35], { 39: [1, 43] }), o($V0, [2, 34]), o($V0, [2, 36])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("open_directive"); + return "open_directive"; + case 1: + this.begin("acc_title"); + return 28; + case 2: + this.popState(); + return "acc_title_value"; + case 3: + this.begin("acc_descr"); + return 30; + case 4: + this.popState(); + return "acc_descr_value"; + case 5: + this.begin("acc_descr_multiline"); + break; + case 6: + this.popState(); + break; + case 7: + return "acc_descr_multiline_value"; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + return 10; + case 12: + break; + case 13: + break; + case 14: + this.begin("href"); + break; + case 15: + this.popState(); + break; + case 16: + return 40; + case 17: + this.begin("callbackname"); + break; + case 18: + this.popState(); + break; + case 19: + this.popState(); + this.begin("callbackargs"); + break; + case 20: + return 38; + case 21: + this.popState(); + break; + case 22: + return 39; + case 23: + this.begin("click"); + break; + case 24: + this.popState(); + break; + case 25: + return 37; + case 26: + return 4; + case 27: + return 19; + case 28: + return 20; + case 29: + return 21; + case 30: + return 22; + case 31: + return 23; + case 32: + return 25; + case 33: + return 24; + case 34: + return 26; + case 35: + return 12; + case 36: + return 13; + case 37: + return 14; + case 38: + return 15; + case 39: + return 16; + case 40: + return 17; + case 41: + return 18; + case 42: + return "date"; + case 43: + return 27; + case 44: + return "accDescription"; + case 45: + return 33; + case 46: + return 35; + case 47: + return 36; + case 48: + return ":"; + case 49: + return 6; + case 50: + return "INVALID"; + } + }, + rules: [/^(?:%%\{)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:%%(?!\{)*[^\n]*)/i, /^(?:[^\}]%%*[^\n]*)/i, /^(?:%%*[^\n]*[\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:%[^\n]*)/i, /^(?:href[\s]+["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:call[\s]+)/i, /^(?:\([\s]*\))/i, /^(?:\()/i, /^(?:[^(]*)/i, /^(?:\))/i, /^(?:[^)]*)/i, /^(?:click[\s]+)/i, /^(?:[\s\n])/i, /^(?:[^\s\n]*)/i, /^(?:gantt\b)/i, /^(?:dateFormat\s[^#\n;]+)/i, /^(?:inclusiveEndDates\b)/i, /^(?:topAxis\b)/i, /^(?:axisFormat\s[^#\n;]+)/i, /^(?:tickInterval\s[^#\n;]+)/i, /^(?:includes\s[^#\n;]+)/i, /^(?:excludes\s[^#\n;]+)/i, /^(?:todayMarker\s[^\n;]+)/i, /^(?:weekday\s+monday\b)/i, /^(?:weekday\s+tuesday\b)/i, /^(?:weekday\s+wednesday\b)/i, /^(?:weekday\s+thursday\b)/i, /^(?:weekday\s+friday\b)/i, /^(?:weekday\s+saturday\b)/i, /^(?:weekday\s+sunday\b)/i, /^(?:\d\d\d\d-\d\d-\d\d\b)/i, /^(?:title\s[^\n]+)/i, /^(?:accDescription\s[^#\n;]+)/i, /^(?:section\s[^\n]+)/i, /^(?:[^:\n]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "callbackargs": { "rules": [21, 22], "inclusive": false }, "callbackname": { "rules": [18, 19, 20], "inclusive": false }, "href": { "rules": [15, 16], "inclusive": false }, "click": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 17, 23, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const ganttParser = parser; +dayjs.extend(dayjsIsoWeek); +dayjs.extend(dayjsCustomParseFormat); +dayjs.extend(dayjsAdvancedFormat); +let dateFormat = ""; +let axisFormat = ""; +let tickInterval = void 0; +let todayMarker = ""; +let includes = []; +let excludes = []; +let links = {}; +let sections = []; +let tasks = []; +let currentSection = ""; +let displayMode = ""; +const tags = ["active", "done", "crit", "milestone"]; +let funs = []; +let inclusiveEndDates = false; +let topAxis = false; +let weekday = "sunday"; +let lastOrder = 0; +const clear = function() { + sections = []; + tasks = []; + currentSection = ""; + funs = []; + taskCnt = 0; + lastTask = void 0; + lastTaskID = void 0; + rawTasks = []; + dateFormat = ""; + axisFormat = ""; + displayMode = ""; + tickInterval = void 0; + todayMarker = ""; + includes = []; + excludes = []; + inclusiveEndDates = false; + topAxis = false; + lastOrder = 0; + links = {}; + clear$1(); + weekday = "sunday"; +}; +const setAxisFormat = function(txt) { + axisFormat = txt; +}; +const getAxisFormat = function() { + return axisFormat; +}; +const setTickInterval = function(txt) { + tickInterval = txt; +}; +const getTickInterval = function() { + return tickInterval; +}; +const setTodayMarker = function(txt) { + todayMarker = txt; +}; +const getTodayMarker = function() { + return todayMarker; +}; +const setDateFormat = function(txt) { + dateFormat = txt; +}; +const enableInclusiveEndDates = function() { + inclusiveEndDates = true; +}; +const endDatesAreInclusive = function() { + return inclusiveEndDates; +}; +const enableTopAxis = function() { + topAxis = true; +}; +const topAxisEnabled = function() { + return topAxis; +}; +const setDisplayMode = function(txt) { + displayMode = txt; +}; +const getDisplayMode = function() { + return displayMode; +}; +const getDateFormat = function() { + return dateFormat; +}; +const setIncludes = function(txt) { + includes = txt.toLowerCase().split(/[\s,]+/); +}; +const getIncludes = function() { + return includes; +}; +const setExcludes = function(txt) { + excludes = txt.toLowerCase().split(/[\s,]+/); +}; +const getExcludes = function() { + return excludes; +}; +const getLinks = function() { + return links; +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 10; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks = rawTasks; + return tasks; +}; +const isInvalidDate = function(date, dateFormat2, excludes2, includes2) { + if (includes2.includes(date.format(dateFormat2.trim()))) { + return false; + } + if (date.isoWeekday() >= 6 && excludes2.includes("weekends")) { + return true; + } + if (excludes2.includes(date.format("dddd").toLowerCase())) { + return true; + } + return excludes2.includes(date.format(dateFormat2.trim())); +}; +const setWeekday = function(txt) { + weekday = txt; +}; +const getWeekday = function() { + return weekday; +}; +const checkTaskDates = function(task, dateFormat2, excludes2, includes2) { + if (!excludes2.length || task.manualEndTime) { + return; + } + let startTime; + if (task.startTime instanceof Date) { + startTime = dayjs(task.startTime); + } else { + startTime = dayjs(task.startTime, dateFormat2, true); + } + startTime = startTime.add(1, "d"); + let originalEndTime; + if (task.endTime instanceof Date) { + originalEndTime = dayjs(task.endTime); + } else { + originalEndTime = dayjs(task.endTime, dateFormat2, true); + } + const [fixedEndTime, renderEndTime] = fixTaskDates( + startTime, + originalEndTime, + dateFormat2, + excludes2, + includes2 + ); + task.endTime = fixedEndTime.toDate(); + task.renderEndTime = renderEndTime; +}; +const fixTaskDates = function(startTime, endTime, dateFormat2, excludes2, includes2) { + let invalid = false; + let renderEndTime = null; + while (startTime <= endTime) { + if (!invalid) { + renderEndTime = endTime.toDate(); + } + invalid = isInvalidDate(startTime, dateFormat2, excludes2, includes2); + if (invalid) { + endTime = endTime.add(1, "d"); + } + startTime = startTime.add(1, "d"); + } + return [endTime, renderEndTime]; +}; +const getStartDate = function(prevTime, dateFormat2, str) { + str = str.trim(); + const afterRePattern = /^after\s+(?[\d\w- ]+)/; + const afterStatement = afterRePattern.exec(str); + if (afterStatement !== null) { + let latestTask = null; + for (const id of afterStatement.groups.ids.split(" ")) { + let task = findTaskById(id); + if (task !== void 0 && (!latestTask || task.endTime > latestTask.endTime)) { + latestTask = task; + } + } + if (latestTask) { + return latestTask.endTime; + } + const today = /* @__PURE__ */ new Date(); + today.setHours(0, 0, 0, 0); + return today; + } + let mDate = dayjs(str, dateFormat2.trim(), true); + if (mDate.isValid()) { + return mDate.toDate(); + } else { + log$1.debug("Invalid date:" + str); + log$1.debug("With date format:" + dateFormat2.trim()); + const d = new Date(str); + if (d === void 0 || isNaN(d.getTime()) || // WebKit browsers can mis-parse invalid dates to be ridiculously + // huge numbers, e.g. new Date('202304') gets parsed as January 1, 202304. + // This can cause virtually infinite loops while rendering, so for the + // purposes of Gantt charts we'll just treat any date beyond 10,000 AD/BC as + // invalid. + d.getFullYear() < -1e4 || d.getFullYear() > 1e4) { + throw new Error("Invalid date:" + str); + } + return d; + } +}; +const parseDuration = function(str) { + const statement = /^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/.exec(str.trim()); + if (statement !== null) { + return [Number.parseFloat(statement[1]), statement[2]]; + } + return [NaN, "ms"]; +}; +const getEndDate = function(prevTime, dateFormat2, str, inclusive = false) { + str = str.trim(); + const untilRePattern = /^until\s+(?[\d\w- ]+)/; + const untilStatement = untilRePattern.exec(str); + if (untilStatement !== null) { + let earliestTask = null; + for (const id of untilStatement.groups.ids.split(" ")) { + let task = findTaskById(id); + if (task !== void 0 && (!earliestTask || task.startTime < earliestTask.startTime)) { + earliestTask = task; + } + } + if (earliestTask) { + return earliestTask.startTime; + } + const today = /* @__PURE__ */ new Date(); + today.setHours(0, 0, 0, 0); + return today; + } + let parsedDate = dayjs(str, dateFormat2.trim(), true); + if (parsedDate.isValid()) { + if (inclusive) { + parsedDate = parsedDate.add(1, "d"); + } + return parsedDate.toDate(); + } + let endTime = dayjs(prevTime); + const [durationValue, durationUnit] = parseDuration(str); + if (!Number.isNaN(durationValue)) { + const newEndTime = endTime.add(durationValue, durationUnit); + if (newEndTime.isValid()) { + endTime = newEndTime; + } + } + return endTime.toDate(); +}; +let taskCnt = 0; +const parseId = function(idStr) { + if (idStr === void 0) { + taskCnt = taskCnt + 1; + return "task" + taskCnt; + } + return idStr; +}; +const compileData = function(prevTask, dataStr) { + let ds; + if (dataStr.substr(0, 1) === ":") { + ds = dataStr.substr(1, dataStr.length); + } else { + ds = dataStr; + } + const data = ds.split(","); + const task = {}; + getTaskTags(data, task, tags); + for (let i = 0; i < data.length; i++) { + data[i] = data[i].trim(); + } + let endTimeData = ""; + switch (data.length) { + case 1: + task.id = parseId(); + task.startTime = prevTask.endTime; + endTimeData = data[0]; + break; + case 2: + task.id = parseId(); + task.startTime = getStartDate(void 0, dateFormat, data[0]); + endTimeData = data[1]; + break; + case 3: + task.id = parseId(data[0]); + task.startTime = getStartDate(void 0, dateFormat, data[1]); + endTimeData = data[2]; + break; + } + if (endTimeData) { + task.endTime = getEndDate(task.startTime, dateFormat, endTimeData, inclusiveEndDates); + task.manualEndTime = dayjs(endTimeData, "YYYY-MM-DD", true).isValid(); + checkTaskDates(task, dateFormat, excludes, includes); + } + return task; +}; +const parseData = function(prevTaskId, dataStr) { + let ds; + if (dataStr.substr(0, 1) === ":") { + ds = dataStr.substr(1, dataStr.length); + } else { + ds = dataStr; + } + const data = ds.split(","); + const task = {}; + getTaskTags(data, task, tags); + for (let i = 0; i < data.length; i++) { + data[i] = data[i].trim(); + } + switch (data.length) { + case 1: + task.id = parseId(); + task.startTime = { + type: "prevTaskEnd", + id: prevTaskId + }; + task.endTime = { + data: data[0] + }; + break; + case 2: + task.id = parseId(); + task.startTime = { + type: "getStartDate", + startData: data[0] + }; + task.endTime = { + data: data[1] + }; + break; + case 3: + task.id = parseId(data[0]); + task.startTime = { + type: "getStartDate", + startData: data[1] + }; + task.endTime = { + data: data[2] + }; + break; + } + return task; +}; +let lastTask; +let lastTaskID; +let rawTasks = []; +const taskDb = {}; +const addTask = function(descr, data) { + const rawTask = { + section: currentSection, + type: currentSection, + processed: false, + manualEndTime: false, + renderEndTime: null, + raw: { data }, + task: descr, + classes: [] + }; + const taskInfo = parseData(lastTaskID, data); + rawTask.raw.startTime = taskInfo.startTime; + rawTask.raw.endTime = taskInfo.endTime; + rawTask.id = taskInfo.id; + rawTask.prevTaskId = lastTaskID; + rawTask.active = taskInfo.active; + rawTask.done = taskInfo.done; + rawTask.crit = taskInfo.crit; + rawTask.milestone = taskInfo.milestone; + rawTask.order = lastOrder; + lastOrder++; + const pos = rawTasks.push(rawTask); + lastTaskID = rawTask.id; + taskDb[rawTask.id] = pos - 1; +}; +const findTaskById = function(id) { + const pos = taskDb[id]; + return rawTasks[pos]; +}; +const addTaskOrg = function(descr, data) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + const taskInfo = compileData(lastTask, data); + newTask.startTime = taskInfo.startTime; + newTask.endTime = taskInfo.endTime; + newTask.id = taskInfo.id; + newTask.active = taskInfo.active; + newTask.done = taskInfo.done; + newTask.crit = taskInfo.crit; + newTask.milestone = taskInfo.milestone; + lastTask = newTask; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + const task = rawTasks[pos]; + let startTime = ""; + switch (rawTasks[pos].raw.startTime.type) { + case "prevTaskEnd": { + const prevTask = findTaskById(task.prevTaskId); + task.startTime = prevTask.endTime; + break; + } + case "getStartDate": + startTime = getStartDate(void 0, dateFormat, rawTasks[pos].raw.startTime.startData); + if (startTime) { + rawTasks[pos].startTime = startTime; + } + break; + } + if (rawTasks[pos].startTime) { + rawTasks[pos].endTime = getEndDate( + rawTasks[pos].startTime, + dateFormat, + rawTasks[pos].raw.endTime.data, + inclusiveEndDates + ); + if (rawTasks[pos].endTime) { + rawTasks[pos].processed = true; + rawTasks[pos].manualEndTime = dayjs( + rawTasks[pos].raw.endTime.data, + "YYYY-MM-DD", + true + ).isValid(); + checkTaskDates(rawTasks[pos], dateFormat, excludes, includes); + } + } + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const setLink = function(ids, _linkStr) { + let linkStr = _linkStr; + if (getConfig().securityLevel !== "loose") { + linkStr = dist.sanitizeUrl(_linkStr); + } + ids.split(",").forEach(function(id) { + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + pushFun(id, () => { + window.open(linkStr, "_self"); + }); + links[id] = linkStr; + } + }); + setClass(ids, "clickable"); +}; +const setClass = function(ids, className) { + ids.split(",").forEach(function(id) { + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + rawTask.classes.push(className); + } + }); +}; +const setClickFun = function(id, functionName, functionArgs) { + if (getConfig().securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(id); + } + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + pushFun(id, () => { + utils.runFunc(functionName, ...argList); + }); + } +}; +const pushFun = function(id, callbackFunction) { + funs.push( + function() { + const elem = document.querySelector(`[id="${id}"]`); + if (elem !== null) { + elem.addEventListener("click", function() { + callbackFunction(); + }); + } + }, + function() { + const elem = document.querySelector(`[id="${id}-text"]`); + if (elem !== null) { + elem.addEventListener("click", function() { + callbackFunction(); + }); + } + } + ); +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFun(id, functionName, functionArgs); + }); + setClass(ids, "clickable"); +}; +const bindFunctions = function(element) { + funs.forEach(function(fun) { + fun(element); + }); +}; +const ganttDb = { + getConfig: () => getConfig().gantt, + clear, + setDateFormat, + getDateFormat, + enableInclusiveEndDates, + endDatesAreInclusive, + enableTopAxis, + topAxisEnabled, + setAxisFormat, + getAxisFormat, + setTickInterval, + getTickInterval, + setTodayMarker, + getTodayMarker, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + setDisplayMode, + getDisplayMode, + setAccDescription, + getAccDescription, + addSection, + getSections, + getTasks, + addTask, + findTaskById, + addTaskOrg, + setIncludes, + getIncludes, + setExcludes, + getExcludes, + setClickEvent, + setLink, + getLinks, + bindFunctions, + parseDuration, + isInvalidDate, + setWeekday, + getWeekday +}; +function getTaskTags(data, task, tags2) { + let matchFound = true; + while (matchFound) { + matchFound = false; + tags2.forEach(function(t) { + const pattern = "^\\s*" + t + "\\s*$"; + const regex = new RegExp(pattern); + if (data[0].match(regex)) { + task[t] = true; + data.shift(1); + matchFound = true; + } + }); + } +} +const setConf = function() { + log$1.debug("Something is calling, setConf, remove the call"); +}; +const mapWeekdayToTimeFunction = { + monday: timeMonday, + tuesday: timeTuesday, + wednesday: timeWednesday, + thursday: timeThursday, + friday: timeFriday, + saturday: timeSaturday, + sunday: timeSunday +}; +const getMaxIntersections = (tasks2, orderOffset) => { + let timeline = [...tasks2].map(() => -Infinity); + let sorted = [...tasks2].sort((a, b) => a.startTime - b.startTime || a.order - b.order); + let maxIntersections = 0; + for (const element of sorted) { + for (let j = 0; j < timeline.length; j++) { + if (element.startTime >= timeline[j]) { + timeline[j] = element.endTime; + element.order = j + orderOffset; + if (j > maxIntersections) { + maxIntersections = j; + } + break; + } + } + } + return maxIntersections; +}; +let w; +const draw = function(text, id, version, diagObj) { + const conf = getConfig().gantt; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const elem = doc.getElementById(id); + w = elem.parentElement.offsetWidth; + if (w === void 0) { + w = 1200; + } + if (conf.useWidth !== void 0) { + w = conf.useWidth; + } + const taskArray = diagObj.db.getTasks(); + let categories = []; + for (const element of taskArray) { + categories.push(element.type); + } + categories = checkUnique(categories); + const categoryHeights = {}; + let h = 2 * conf.topPadding; + if (diagObj.db.getDisplayMode() === "compact" || conf.displayMode === "compact") { + const categoryElements = {}; + for (const element of taskArray) { + if (categoryElements[element.section] === void 0) { + categoryElements[element.section] = [element]; + } else { + categoryElements[element.section].push(element); + } + } + let intersections = 0; + for (const category of Object.keys(categoryElements)) { + const categoryHeight = getMaxIntersections(categoryElements[category], intersections) + 1; + intersections += categoryHeight; + h += categoryHeight * (conf.barHeight + conf.barGap); + categoryHeights[category] = categoryHeight; + } + } else { + h += taskArray.length * (conf.barHeight + conf.barGap); + for (const category of categories) { + categoryHeights[category] = taskArray.filter((task) => task.type === category).length; + } + } + elem.setAttribute("viewBox", "0 0 " + w + " " + h); + const svg = root.select(`[id="${id}"]`); + const timeScale = time().domain([ + min(taskArray, function(d) { + return d.startTime; + }), + max(taskArray, function(d) { + return d.endTime; + }) + ]).rangeRound([0, w - conf.leftPadding - conf.rightPadding]); + function taskCompare(a, b) { + const taskA = a.startTime; + const taskB = b.startTime; + let result = 0; + if (taskA > taskB) { + result = 1; + } else if (taskA < taskB) { + result = -1; + } + return result; + } + taskArray.sort(taskCompare); + makeGantt(taskArray, w, h); + configureSvgSize(svg, h, w, conf.useMaxWidth); + svg.append("text").text(diagObj.db.getDiagramTitle()).attr("x", w / 2).attr("y", conf.titleTopMargin).attr("class", "titleText"); + function makeGantt(tasks2, pageWidth, pageHeight) { + const barHeight = conf.barHeight; + const gap = barHeight + conf.barGap; + const topPadding = conf.topPadding; + const leftPadding = conf.leftPadding; + const colorScale = linear().domain([0, categories.length]).range(["#00B9FA", "#F95002"]).interpolate(interpolateHcl); + drawExcludeDays( + gap, + topPadding, + leftPadding, + pageWidth, + pageHeight, + tasks2, + diagObj.db.getExcludes(), + diagObj.db.getIncludes() + ); + makeGrid(leftPadding, topPadding, pageWidth, pageHeight); + drawRects(tasks2, gap, topPadding, leftPadding, barHeight, colorScale, pageWidth); + vertLabels(gap, topPadding); + drawToday(leftPadding, topPadding, pageWidth, pageHeight); + } + function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w2) { + const uniqueTaskOrderIds = [...new Set(theArray.map((item) => item.order))]; + const uniqueTasks = uniqueTaskOrderIds.map((id2) => theArray.find((item) => item.order === id2)); + svg.append("g").selectAll("rect").data(uniqueTasks).enter().append("rect").attr("x", 0).attr("y", function(d, i) { + i = d.order; + return i * theGap + theTopPad - 2; + }).attr("width", function() { + return w2 - conf.rightPadding / 2; + }).attr("height", theGap).attr("class", function(d) { + for (const [i, category] of categories.entries()) { + if (d.type === category) { + return "section section" + i % conf.numberSectionStyles; + } + } + return "section section0"; + }); + const rectangles = svg.append("g").selectAll("rect").data(theArray).enter(); + const links2 = diagObj.db.getLinks(); + rectangles.append("rect").attr("id", function(d) { + return d.id; + }).attr("rx", 3).attr("ry", 3).attr("x", function(d) { + if (d.milestone) { + return timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight; + } + return timeScale(d.startTime) + theSidePad; + }).attr("y", function(d, i) { + i = d.order; + return i * theGap + theTopPad; + }).attr("width", function(d) { + if (d.milestone) { + return theBarHeight; + } + return timeScale(d.renderEndTime || d.endTime) - timeScale(d.startTime); + }).attr("height", theBarHeight).attr("transform-origin", function(d, i) { + i = d.order; + return (timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime))).toString() + "px " + (i * theGap + theTopPad + 0.5 * theBarHeight).toString() + "px"; + }).attr("class", function(d) { + const res = "task"; + let classStr = ""; + if (d.classes.length > 0) { + classStr = d.classes.join(" "); + } + let secNum = 0; + for (const [i, category] of categories.entries()) { + if (d.type === category) { + secNum = i % conf.numberSectionStyles; + } + } + let taskClass = ""; + if (d.active) { + if (d.crit) { + taskClass += " activeCrit"; + } else { + taskClass = " active"; + } + } else if (d.done) { + if (d.crit) { + taskClass = " doneCrit"; + } else { + taskClass = " done"; + } + } else { + if (d.crit) { + taskClass += " crit"; + } + } + if (taskClass.length === 0) { + taskClass = " task"; + } + if (d.milestone) { + taskClass = " milestone " + taskClass; + } + taskClass += secNum; + taskClass += " " + classStr; + return res + taskClass; + }); + rectangles.append("text").attr("id", function(d) { + return d.id + "-text"; + }).text(function(d) { + return d.task; + }).attr("font-size", conf.fontSize).attr("x", function(d) { + let startX = timeScale(d.startTime); + let endX = timeScale(d.renderEndTime || d.endTime); + if (d.milestone) { + startX += 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight; + } + if (d.milestone) { + endX = startX + theBarHeight; + } + const textWidth = this.getBBox().width; + if (textWidth > endX - startX) { + if (endX + textWidth + 1.5 * conf.leftPadding > w2) { + return startX + theSidePad - 5; + } else { + return endX + theSidePad + 5; + } + } else { + return (endX - startX) / 2 + startX + theSidePad; + } + }).attr("y", function(d, i) { + i = d.order; + return i * theGap + conf.barHeight / 2 + (conf.fontSize / 2 - 2) + theTopPad; + }).attr("text-height", theBarHeight).attr("class", function(d) { + const startX = timeScale(d.startTime); + let endX = timeScale(d.endTime); + if (d.milestone) { + endX = startX + theBarHeight; + } + const textWidth = this.getBBox().width; + let classStr = ""; + if (d.classes.length > 0) { + classStr = d.classes.join(" "); + } + let secNum = 0; + for (const [i, category] of categories.entries()) { + if (d.type === category) { + secNum = i % conf.numberSectionStyles; + } + } + let taskType = ""; + if (d.active) { + if (d.crit) { + taskType = "activeCritText" + secNum; + } else { + taskType = "activeText" + secNum; + } + } + if (d.done) { + if (d.crit) { + taskType = taskType + " doneCritText" + secNum; + } else { + taskType = taskType + " doneText" + secNum; + } + } else { + if (d.crit) { + taskType = taskType + " critText" + secNum; + } + } + if (d.milestone) { + taskType += " milestoneText"; + } + if (textWidth > endX - startX) { + if (endX + textWidth + 1.5 * conf.leftPadding > w2) { + return classStr + " taskTextOutsideLeft taskTextOutside" + secNum + " " + taskType; + } else { + return classStr + " taskTextOutsideRight taskTextOutside" + secNum + " " + taskType + " width-" + textWidth; + } + } else { + return classStr + " taskText taskText" + secNum + " " + taskType + " width-" + textWidth; + } + }); + const securityLevel2 = getConfig().securityLevel; + if (securityLevel2 === "sandbox") { + let sandboxElement2; + sandboxElement2 = select("#i" + id); + const doc2 = sandboxElement2.nodes()[0].contentDocument; + rectangles.filter(function(d) { + return links2[d.id] !== void 0; + }).each(function(o) { + var taskRect = doc2.querySelector("#" + o.id); + var taskText = doc2.querySelector("#" + o.id + "-text"); + const oldParent = taskRect.parentNode; + var Link = doc2.createElement("a"); + Link.setAttribute("xlink:href", links2[o.id]); + Link.setAttribute("target", "_top"); + oldParent.appendChild(Link); + Link.appendChild(taskRect); + Link.appendChild(taskText); + }); + } + } + function drawExcludeDays(theGap, theTopPad, theSidePad, w2, h2, tasks2, excludes2, includes2) { + if (excludes2.length === 0 && includes2.length === 0) { + return; + } + let minTime; + let maxTime; + for (const { startTime, endTime } of tasks2) { + if (minTime === void 0 || startTime < minTime) { + minTime = startTime; + } + if (maxTime === void 0 || endTime > maxTime) { + maxTime = endTime; + } + } + if (!minTime || !maxTime) { + return; + } + if (dayjs(maxTime).diff(dayjs(minTime), "year") > 5) { + log$1.warn( + "The difference between the min and max time is more than 5 years. This will cause performance issues. Skipping drawing exclude days." + ); + return; + } + const dateFormat2 = diagObj.db.getDateFormat(); + const excludeRanges = []; + let range = null; + let d = dayjs(minTime); + while (d.valueOf() <= maxTime) { + if (diagObj.db.isInvalidDate(d, dateFormat2, excludes2, includes2)) { + if (!range) { + range = { + start: d, + end: d + }; + } else { + range.end = d; + } + } else { + if (range) { + excludeRanges.push(range); + range = null; + } + } + d = d.add(1, "d"); + } + const rectangles = svg.append("g").selectAll("rect").data(excludeRanges).enter(); + rectangles.append("rect").attr("id", function(d2) { + return "exclude-" + d2.start.format("YYYY-MM-DD"); + }).attr("x", function(d2) { + return timeScale(d2.start) + theSidePad; + }).attr("y", conf.gridLineStartPadding).attr("width", function(d2) { + const renderEnd = d2.end.add(1, "day"); + return timeScale(renderEnd) - timeScale(d2.start); + }).attr("height", h2 - theTopPad - conf.gridLineStartPadding).attr("transform-origin", function(d2, i) { + return (timeScale(d2.start) + theSidePad + 0.5 * (timeScale(d2.end) - timeScale(d2.start))).toString() + "px " + (i * theGap + 0.5 * h2).toString() + "px"; + }).attr("class", "exclude-range"); + } + function makeGrid(theSidePad, theTopPad, w2, h2) { + let bottomXAxis = axisBottom(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d")); + const reTickInterval = /^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/; + const resultTickInterval = reTickInterval.exec( + diagObj.db.getTickInterval() || conf.tickInterval + ); + if (resultTickInterval !== null) { + const every = resultTickInterval[1]; + const interval = resultTickInterval[2]; + const weekday2 = diagObj.db.getWeekday() || conf.weekday; + switch (interval) { + case "millisecond": + bottomXAxis.ticks(millisecond.every(every)); + break; + case "second": + bottomXAxis.ticks(second.every(every)); + break; + case "minute": + bottomXAxis.ticks(timeMinute.every(every)); + break; + case "hour": + bottomXAxis.ticks(timeHour.every(every)); + break; + case "day": + bottomXAxis.ticks(timeDay.every(every)); + break; + case "week": + bottomXAxis.ticks(mapWeekdayToTimeFunction[weekday2].every(every)); + break; + case "month": + bottomXAxis.ticks(timeMonth.every(every)); + break; + } + } + svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + (h2 - 50) + ")").call(bottomXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10).attr("dy", "1em"); + if (diagObj.db.topAxisEnabled() || conf.topAxis) { + let topXAxis = axisTop(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d")); + if (resultTickInterval !== null) { + const every = resultTickInterval[1]; + const interval = resultTickInterval[2]; + const weekday2 = diagObj.db.getWeekday() || conf.weekday; + switch (interval) { + case "millisecond": + topXAxis.ticks(millisecond.every(every)); + break; + case "second": + topXAxis.ticks(second.every(every)); + break; + case "minute": + topXAxis.ticks(timeMinute.every(every)); + break; + case "hour": + topXAxis.ticks(timeHour.every(every)); + break; + case "day": + topXAxis.ticks(timeDay.every(every)); + break; + case "week": + topXAxis.ticks(mapWeekdayToTimeFunction[weekday2].every(every)); + break; + case "month": + topXAxis.ticks(timeMonth.every(every)); + break; + } + } + svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + theTopPad + ")").call(topXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10); + } + } + function vertLabels(theGap, theTopPad) { + let prevGap = 0; + const numOccurrences = Object.keys(categoryHeights).map((d) => [d, categoryHeights[d]]); + svg.append("g").selectAll("text").data(numOccurrences).enter().append(function(d) { + const rows = d[0].split(common$1.lineBreakRegex); + const dy = -(rows.length - 1) / 2; + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("dy", dy + "em"); + for (const [j, row] of rows.entries()) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttribute("alignment-baseline", "central"); + tspan.setAttribute("x", "10"); + if (j > 0) { + tspan.setAttribute("dy", "1em"); + } + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + return svgLabel; + }).attr("x", 10).attr("y", function(d, i) { + if (i > 0) { + for (let j = 0; j < i; j++) { + prevGap += numOccurrences[i - 1][1]; + return d[1] * theGap / 2 + prevGap * theGap + theTopPad; + } + } else { + return d[1] * theGap / 2 + theTopPad; + } + }).attr("font-size", conf.sectionFontSize).attr("class", function(d) { + for (const [i, category] of categories.entries()) { + if (d[0] === category) { + return "sectionTitle sectionTitle" + i % conf.numberSectionStyles; + } + } + return "sectionTitle"; + }); + } + function drawToday(theSidePad, theTopPad, w2, h2) { + const todayMarker2 = diagObj.db.getTodayMarker(); + if (todayMarker2 === "off") { + return; + } + const todayG = svg.append("g").attr("class", "today"); + const today = /* @__PURE__ */ new Date(); + const todayLine = todayG.append("line"); + todayLine.attr("x1", timeScale(today) + theSidePad).attr("x2", timeScale(today) + theSidePad).attr("y1", conf.titleTopMargin).attr("y2", h2 - conf.titleTopMargin).attr("class", "today"); + if (todayMarker2 !== "") { + todayLine.attr("style", todayMarker2.replace(/,/g, ";")); + } + } + function checkUnique(arr) { + const hash = {}; + const result = []; + for (let i = 0, l = arr.length; i < l; ++i) { + if (!Object.prototype.hasOwnProperty.call(hash, arr[i])) { + hash[arr[i]] = true; + result.push(arr[i]); + } + } + return result; + } +}; +const ganttRenderer = { + setConf, + draw +}; +const getStyles = (options) => ` + .mermaid-main-font { + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .exclude-range { + fill: ${options.excludeBkgColor}; + } + + .section { + stroke: none; + opacity: 0.2; + } + + .section0 { + fill: ${options.sectionBkgColor}; + } + + .section2 { + fill: ${options.sectionBkgColor2}; + } + + .section1, + .section3 { + fill: ${options.altSectionBkgColor}; + opacity: 0.2; + } + + .sectionTitle0 { + fill: ${options.titleColor}; + } + + .sectionTitle1 { + fill: ${options.titleColor}; + } + + .sectionTitle2 { + fill: ${options.titleColor}; + } + + .sectionTitle3 { + fill: ${options.titleColor}; + } + + .sectionTitle { + text-anchor: start; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + + /* Grid and axis */ + + .grid .tick { + stroke: ${options.gridColor}; + opacity: 0.8; + shape-rendering: crispEdges; + } + + .grid .tick text { + font-family: ${options.fontFamily}; + fill: ${options.textColor}; + } + + .grid path { + stroke-width: 0; + } + + + /* Today line */ + + .today { + fill: none; + stroke: ${options.todayLineColor}; + stroke-width: 2px; + } + + + /* Task styling */ + + /* Default task */ + + .task { + stroke-width: 2; + } + + .taskText { + text-anchor: middle; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .taskTextOutsideRight { + fill: ${options.taskTextDarkColor}; + text-anchor: start; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .taskTextOutsideLeft { + fill: ${options.taskTextDarkColor}; + text-anchor: end; + } + + + /* Special case clickable */ + + .task.clickable { + cursor: pointer; + } + + .taskText.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + .taskTextOutsideLeft.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + .taskTextOutsideRight.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + + /* Specific task settings for the sections*/ + + .taskText0, + .taskText1, + .taskText2, + .taskText3 { + fill: ${options.taskTextColor}; + } + + .task0, + .task1, + .task2, + .task3 { + fill: ${options.taskBkgColor}; + stroke: ${options.taskBorderColor}; + } + + .taskTextOutside0, + .taskTextOutside2 + { + fill: ${options.taskTextOutsideColor}; + } + + .taskTextOutside1, + .taskTextOutside3 { + fill: ${options.taskTextOutsideColor}; + } + + + /* Active task */ + + .active0, + .active1, + .active2, + .active3 { + fill: ${options.activeTaskBkgColor}; + stroke: ${options.activeTaskBorderColor}; + } + + .activeText0, + .activeText1, + .activeText2, + .activeText3 { + fill: ${options.taskTextDarkColor} !important; + } + + + /* Completed task */ + + .done0, + .done1, + .done2, + .done3 { + stroke: ${options.doneTaskBorderColor}; + fill: ${options.doneTaskBkgColor}; + stroke-width: 2; + } + + .doneText0, + .doneText1, + .doneText2, + .doneText3 { + fill: ${options.taskTextDarkColor} !important; + } + + + /* Tasks on the critical line */ + + .crit0, + .crit1, + .crit2, + .crit3 { + stroke: ${options.critBorderColor}; + fill: ${options.critBkgColor}; + stroke-width: 2; + } + + .activeCrit0, + .activeCrit1, + .activeCrit2, + .activeCrit3 { + stroke: ${options.critBorderColor}; + fill: ${options.activeTaskBkgColor}; + stroke-width: 2; + } + + .doneCrit0, + .doneCrit1, + .doneCrit2, + .doneCrit3 { + stroke: ${options.critBorderColor}; + fill: ${options.doneTaskBkgColor}; + stroke-width: 2; + cursor: pointer; + shape-rendering: crispEdges; + } + + .milestone { + transform: rotate(45deg) scale(0.8,0.8); + } + + .milestoneText { + font-style: italic; + } + .doneCritText0, + .doneCritText1, + .doneCritText2, + .doneCritText3 { + fill: ${options.taskTextDarkColor} !important; + } + + .activeCritText0, + .activeCritText1, + .activeCritText2, + .activeCritText3 { + fill: ${options.taskTextDarkColor} !important; + } + + .titleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.titleColor || options.textColor}; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } +`; +const ganttStyles = getStyles; +const diagram = { + parser: ganttParser, + db: ganttDb, + renderer: ganttRenderer, + styles: ganttStyles +}; + +export { diagram }; diff --git a/libs/marked/gitGraphDiagram-942e62fe-D_yUENpJ.js b/libs/marked/gitGraphDiagram-942e62fe-D_yUENpJ.js new file mode 100644 index 0000000..046b65b --- /dev/null +++ b/libs/marked/gitGraphDiagram-942e62fe-D_yUENpJ.js @@ -0,0 +1,1790 @@ +import { c as getConfig, s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, j as common$1, E as clear$2, h as select, A as utils, H as setupGraphViewbox, I as random } from './index-CN3YjQ0n.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 6], $V2 = [1, 4], $V3 = [1, 5], $V4 = [2, 5], $V5 = [1, 12], $V6 = [5, 7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40, 47], $V7 = [7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V8 = [7, 12, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V9 = [7, 13, 47], $Va = [1, 42], $Vb = [1, 41], $Vc = [7, 13, 29, 32, 35, 38, 47], $Vd = [1, 55], $Ve = [1, 56], $Vf = [1, 57], $Vg = [7, 13, 32, 35, 42, 47]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "GG": 5, "document": 6, "EOF": 7, ":": 8, "DIR": 9, "options": 10, "body": 11, "OPT": 12, "NL": 13, "line": 14, "statement": 15, "commitStatement": 16, "mergeStatement": 17, "cherryPickStatement": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "section": 24, "branchStatement": 25, "CHECKOUT": 26, "ref": 27, "BRANCH": 28, "ORDER": 29, "NUM": 30, "CHERRY_PICK": 31, "COMMIT_ID": 32, "STR": 33, "PARENT_COMMIT": 34, "COMMIT_TAG": 35, "EMPTYSTR": 36, "MERGE": 37, "COMMIT_TYPE": 38, "commitType": 39, "COMMIT": 40, "commit_arg": 41, "COMMIT_MSG": 42, "NORMAL": 43, "REVERSE": 44, "HIGHLIGHT": 45, "ID": 46, ";": 47, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "GG", 7: "EOF", 8: ":", 9: "DIR", 12: "OPT", 13: "NL", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "section", 26: "CHECKOUT", 28: "BRANCH", 29: "ORDER", 30: "NUM", 31: "CHERRY_PICK", 32: "COMMIT_ID", 33: "STR", 34: "PARENT_COMMIT", 35: "COMMIT_TAG", 36: "EMPTYSTR", 37: "MERGE", 38: "COMMIT_TYPE", 40: "COMMIT", 42: "COMMIT_MSG", 43: "NORMAL", 44: "REVERSE", 45: "HIGHLIGHT", 46: "ID", 47: ";" }, + productions_: [0, [3, 2], [3, 3], [3, 4], [3, 5], [6, 0], [6, 2], [10, 2], [10, 1], [11, 0], [11, 2], [14, 2], [14, 1], [15, 1], [15, 1], [15, 1], [15, 2], [15, 2], [15, 1], [15, 1], [15, 1], [15, 2], [25, 2], [25, 4], [18, 3], [18, 5], [18, 5], [18, 7], [18, 7], [18, 5], [18, 5], [18, 5], [18, 7], [18, 7], [18, 7], [18, 7], [17, 2], [17, 4], [17, 4], [17, 4], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [16, 2], [16, 3], [16, 3], [16, 5], [16, 5], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [41, 0], [41, 1], [39, 1], [39, 1], [39, 1], [27, 1], [27, 1], [4, 1], [4, 1], [4, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 2: + return $$[$0]; + case 3: + return $$[$0 - 1]; + case 4: + yy.setDirection($$[$0 - 3]); + return $$[$0 - 1]; + case 6: + yy.setOptions($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 7: + $$[$0 - 1] += $$[$0]; + this.$ = $$[$0 - 1]; + break; + case 9: + this.$ = []; + break; + case 10: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 11: + this.$ = $$[$0 - 1]; + break; + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 21: + yy.checkout($$[$0]); + break; + case 22: + yy.branch($$[$0]); + break; + case 23: + yy.branch($$[$0 - 2], $$[$0]); + break; + case 24: + yy.cherryPick($$[$0], "", void 0); + break; + case 25: + yy.cherryPick($$[$0 - 2], "", void 0, $$[$0]); + break; + case 26: + yy.cherryPick($$[$0 - 2], "", $$[$0]); + break; + case 27: + yy.cherryPick($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 28: + yy.cherryPick($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 29: + yy.cherryPick($$[$0], "", $$[$0 - 2]); + break; + case 30: + yy.cherryPick($$[$0], "", ""); + break; + case 31: + yy.cherryPick($$[$0 - 2], "", ""); + break; + case 32: + yy.cherryPick($$[$0 - 4], "", "", $$[$0 - 2]); + break; + case 33: + yy.cherryPick($$[$0 - 4], "", "", $$[$0]); + break; + case 34: + yy.cherryPick($$[$0 - 2], "", $$[$0 - 4], $$[$0]); + break; + case 35: + yy.cherryPick($$[$0 - 2], "", "", $$[$0]); + break; + case 36: + yy.merge($$[$0], "", "", ""); + break; + case 37: + yy.merge($$[$0 - 2], $$[$0], "", ""); + break; + case 38: + yy.merge($$[$0 - 2], "", $$[$0], ""); + break; + case 39: + yy.merge($$[$0 - 2], "", "", $$[$0]); + break; + case 40: + yy.merge($$[$0 - 4], $$[$0], "", $$[$0 - 2]); + break; + case 41: + yy.merge($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 42: + yy.merge($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 43: + yy.merge($$[$0 - 4], $$[$0 - 2], $$[$0], ""); + break; + case 44: + yy.merge($$[$0 - 4], $$[$0 - 2], "", $$[$0]); + break; + case 45: + yy.merge($$[$0 - 4], $$[$0], $$[$0 - 2], ""); + break; + case 46: + yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 47: + yy.merge($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 48: + yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 49: + yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 50: + yy.merge($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 51: + yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 52: + yy.commit($$[$0]); + break; + case 53: + yy.commit("", "", yy.commitType.NORMAL, $$[$0]); + break; + case 54: + yy.commit("", "", $$[$0], ""); + break; + case 55: + yy.commit("", "", $$[$0], $$[$0 - 2]); + break; + case 56: + yy.commit("", "", $$[$0 - 2], $$[$0]); + break; + case 57: + yy.commit("", $$[$0], yy.commitType.NORMAL, ""); + break; + case 58: + yy.commit("", $$[$0 - 2], yy.commitType.NORMAL, $$[$0]); + break; + case 59: + yy.commit("", $$[$0], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 60: + yy.commit("", $$[$0 - 2], $$[$0], ""); + break; + case 61: + yy.commit("", $$[$0], $$[$0 - 2], ""); + break; + case 62: + yy.commit("", $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 63: + yy.commit("", $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 64: + yy.commit("", $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 65: + yy.commit("", $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 66: + yy.commit("", $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 67: + yy.commit("", $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 68: + yy.commit($$[$0], "", yy.commitType.NORMAL, ""); + break; + case 69: + yy.commit($$[$0], "", yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 70: + yy.commit($$[$0 - 2], "", yy.commitType.NORMAL, $$[$0]); + break; + case 71: + yy.commit($$[$0 - 2], "", $$[$0], ""); + break; + case 72: + yy.commit($$[$0], "", $$[$0 - 2], ""); + break; + case 73: + yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, ""); + break; + case 74: + yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, ""); + break; + case 75: + yy.commit($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 76: + yy.commit($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 77: + yy.commit($$[$0 - 2], "", $$[$0 - 4], $$[$0]); + break; + case 78: + yy.commit($$[$0], "", $$[$0 - 4], $$[$0 - 2]); + break; + case 79: + yy.commit($$[$0], "", $$[$0 - 2], $$[$0 - 4]); + break; + case 80: + yy.commit($$[$0 - 2], "", $$[$0], $$[$0 - 4]); + break; + case 81: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], ""); + break; + case 82: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], ""); + break; + case 83: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], ""); + break; + case 84: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], ""); + break; + case 85: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], ""); + break; + case 86: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], ""); + break; + case 87: + yy.commit($$[$0 - 4], $$[$0], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 88: + yy.commit($$[$0 - 4], $$[$0 - 2], yy.commitType.NORMAL, $$[$0]); + break; + case 89: + yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, $$[$0 - 4]); + break; + case 90: + yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, $$[$0 - 4]); + break; + case 91: + yy.commit($$[$0], $$[$0 - 4], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 92: + yy.commit($$[$0 - 2], $$[$0 - 4], yy.commitType.NORMAL, $$[$0]); + break; + case 93: + yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 94: + yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 95: + yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 96: + yy.commit($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 97: + yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 98: + yy.commit($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 99: + yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0 - 2], $$[$0]); + break; + case 100: + yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0], $$[$0 - 2]); + break; + case 101: + yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0 - 4], $$[$0]); + break; + case 102: + yy.commit($$[$0], $$[$0 - 6], $$[$0 - 4], $$[$0 - 2]); + break; + case 103: + yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0], $$[$0 - 4]); + break; + case 104: + yy.commit($$[$0], $$[$0 - 6], $$[$0 - 2], $$[$0 - 4]); + break; + case 105: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], $$[$0 - 6]); + break; + case 106: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], $$[$0 - 6]); + break; + case 107: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], $$[$0 - 6]); + break; + case 108: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], $$[$0 - 6]); + break; + case 109: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], $$[$0 - 6]); + break; + case 110: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 6]); + break; + case 111: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0 - 6], $$[$0]); + break; + case 112: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 6], $$[$0 - 2]); + break; + case 113: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 6], $$[$0 - 4]); + break; + case 114: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 6], $$[$0 - 4]); + break; + case 115: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0 - 6], $$[$0]); + break; + case 116: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 6], $$[$0 - 2]); + break; + case 117: + this.$ = ""; + break; + case 118: + this.$ = $$[$0]; + break; + case 119: + this.$ = yy.commitType.NORMAL; + break; + case 120: + this.$ = yy.commitType.REVERSE; + break; + case 121: + this.$ = yy.commitType.HIGHLIGHT; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 6: 8, 7: $V4, 8: [1, 9], 9: [1, 10], 10: 11, 13: $V5 }, o($V6, [2, 124]), o($V6, [2, 125]), o($V6, [2, 126]), { 1: [2, 1] }, { 7: [1, 13] }, { 6: 14, 7: $V4, 10: 11, 13: $V5 }, { 8: [1, 15] }, o($V7, [2, 9], { 11: 16, 12: [1, 17] }), o($V8, [2, 8]), { 1: [2, 2] }, { 7: [1, 18] }, { 6: 19, 7: $V4, 10: 11, 13: $V5 }, { 7: [2, 6], 13: [1, 22], 14: 20, 15: 21, 16: 23, 17: 24, 18: 25, 19: [1, 26], 21: [1, 27], 23: [1, 28], 24: [1, 29], 25: 30, 26: [1, 31], 28: [1, 35], 31: [1, 34], 37: [1, 33], 40: [1, 32] }, o($V8, [2, 7]), { 1: [2, 3] }, { 7: [1, 36] }, o($V7, [2, 10]), { 4: 37, 7: $V1, 13: $V2, 47: $V3 }, o($V7, [2, 12]), o($V9, [2, 13]), o($V9, [2, 14]), o($V9, [2, 15]), { 20: [1, 38] }, { 22: [1, 39] }, o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), { 27: 40, 33: $Va, 46: $Vb }, o($V9, [2, 117], { 41: 43, 32: [1, 46], 33: [1, 48], 35: [1, 44], 38: [1, 45], 42: [1, 47] }), { 27: 49, 33: $Va, 46: $Vb }, { 32: [1, 50], 35: [1, 51] }, { 27: 52, 33: $Va, 46: $Vb }, { 1: [2, 4] }, o($V7, [2, 11]), o($V9, [2, 16]), o($V9, [2, 17]), o($V9, [2, 21]), o($Vc, [2, 122]), o($Vc, [2, 123]), o($V9, [2, 52]), { 33: [1, 53] }, { 39: 54, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 58] }, { 33: [1, 59] }, o($V9, [2, 118]), o($V9, [2, 36], { 32: [1, 60], 35: [1, 62], 38: [1, 61] }), { 33: [1, 63] }, { 33: [1, 64], 36: [1, 65] }, o($V9, [2, 22], { 29: [1, 66] }), o($V9, [2, 53], { 32: [1, 68], 38: [1, 67], 42: [1, 69] }), o($V9, [2, 54], { 32: [1, 71], 35: [1, 70], 42: [1, 72] }), o($Vg, [2, 119]), o($Vg, [2, 120]), o($Vg, [2, 121]), o($V9, [2, 57], { 35: [1, 73], 38: [1, 74], 42: [1, 75] }), o($V9, [2, 68], { 32: [1, 78], 35: [1, 76], 38: [1, 77] }), { 33: [1, 79] }, { 39: 80, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 81] }, o($V9, [2, 24], { 34: [1, 82], 35: [1, 83] }), { 32: [1, 84] }, { 32: [1, 85] }, { 30: [1, 86] }, { 39: 87, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 88] }, { 33: [1, 89] }, { 33: [1, 90] }, { 33: [1, 91] }, { 33: [1, 92] }, { 33: [1, 93] }, { 39: 94, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 95] }, { 33: [1, 96] }, { 39: 97, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 98] }, o($V9, [2, 37], { 35: [1, 100], 38: [1, 99] }), o($V9, [2, 38], { 32: [1, 102], 35: [1, 101] }), o($V9, [2, 39], { 32: [1, 103], 38: [1, 104] }), { 33: [1, 105] }, { 33: [1, 106], 36: [1, 107] }, { 33: [1, 108] }, { 33: [1, 109] }, o($V9, [2, 23]), o($V9, [2, 55], { 32: [1, 110], 42: [1, 111] }), o($V9, [2, 59], { 38: [1, 112], 42: [1, 113] }), o($V9, [2, 69], { 32: [1, 115], 38: [1, 114] }), o($V9, [2, 56], { 32: [1, 116], 42: [1, 117] }), o($V9, [2, 61], { 35: [1, 118], 42: [1, 119] }), o($V9, [2, 72], { 32: [1, 121], 35: [1, 120] }), o($V9, [2, 58], { 38: [1, 122], 42: [1, 123] }), o($V9, [2, 60], { 35: [1, 124], 42: [1, 125] }), o($V9, [2, 73], { 35: [1, 127], 38: [1, 126] }), o($V9, [2, 70], { 32: [1, 129], 38: [1, 128] }), o($V9, [2, 71], { 32: [1, 131], 35: [1, 130] }), o($V9, [2, 74], { 35: [1, 133], 38: [1, 132] }), { 39: 134, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 135] }, { 33: [1, 136] }, { 33: [1, 137] }, { 33: [1, 138] }, { 39: 139, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 25], { 35: [1, 140] }), o($V9, [2, 26], { 34: [1, 141] }), o($V9, [2, 31], { 34: [1, 142] }), o($V9, [2, 29], { 34: [1, 143] }), o($V9, [2, 30], { 34: [1, 144] }), { 33: [1, 145] }, { 33: [1, 146] }, { 39: 147, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 148] }, { 39: 149, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 150] }, { 33: [1, 151] }, { 33: [1, 152] }, { 33: [1, 153] }, { 33: [1, 154] }, { 33: [1, 155] }, { 33: [1, 156] }, { 39: 157, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 158] }, { 33: [1, 159] }, { 33: [1, 160] }, { 39: 161, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 162] }, { 39: 163, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 164] }, { 33: [1, 165] }, { 33: [1, 166] }, { 39: 167, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 168] }, o($V9, [2, 43], { 35: [1, 169] }), o($V9, [2, 44], { 38: [1, 170] }), o($V9, [2, 42], { 32: [1, 171] }), o($V9, [2, 45], { 35: [1, 172] }), o($V9, [2, 40], { 38: [1, 173] }), o($V9, [2, 41], { 32: [1, 174] }), { 33: [1, 175], 36: [1, 176] }, { 33: [1, 177] }, { 33: [1, 178] }, { 33: [1, 179] }, { 33: [1, 180] }, o($V9, [2, 66], { 42: [1, 181] }), o($V9, [2, 79], { 32: [1, 182] }), o($V9, [2, 67], { 42: [1, 183] }), o($V9, [2, 90], { 38: [1, 184] }), o($V9, [2, 80], { 32: [1, 185] }), o($V9, [2, 89], { 38: [1, 186] }), o($V9, [2, 65], { 42: [1, 187] }), o($V9, [2, 78], { 32: [1, 188] }), o($V9, [2, 64], { 42: [1, 189] }), o($V9, [2, 84], { 35: [1, 190] }), o($V9, [2, 77], { 32: [1, 191] }), o($V9, [2, 83], { 35: [1, 192] }), o($V9, [2, 63], { 42: [1, 193] }), o($V9, [2, 91], { 38: [1, 194] }), o($V9, [2, 62], { 42: [1, 195] }), o($V9, [2, 85], { 35: [1, 196] }), o($V9, [2, 86], { 35: [1, 197] }), o($V9, [2, 92], { 38: [1, 198] }), o($V9, [2, 76], { 32: [1, 199] }), o($V9, [2, 87], { 38: [1, 200] }), o($V9, [2, 75], { 32: [1, 201] }), o($V9, [2, 81], { 35: [1, 202] }), o($V9, [2, 82], { 35: [1, 203] }), o($V9, [2, 88], { 38: [1, 204] }), { 33: [1, 205] }, { 39: 206, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 207] }, { 33: [1, 208] }, { 39: 209, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 210] }, o($V9, [2, 27]), o($V9, [2, 32]), o($V9, [2, 28]), o($V9, [2, 33]), o($V9, [2, 34]), o($V9, [2, 35]), { 33: [1, 211] }, { 33: [1, 212] }, { 33: [1, 213] }, { 39: 214, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 215] }, { 39: 216, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 217] }, { 33: [1, 218] }, { 33: [1, 219] }, { 33: [1, 220] }, { 33: [1, 221] }, { 33: [1, 222] }, { 33: [1, 223] }, { 39: 224, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 225] }, { 33: [1, 226] }, { 33: [1, 227] }, { 39: 228, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 229] }, { 39: 230, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 231] }, { 33: [1, 232] }, { 33: [1, 233] }, { 39: 234, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 46]), o($V9, [2, 48]), o($V9, [2, 47]), o($V9, [2, 49]), o($V9, [2, 51]), o($V9, [2, 50]), o($V9, [2, 107]), o($V9, [2, 108]), o($V9, [2, 105]), o($V9, [2, 106]), o($V9, [2, 110]), o($V9, [2, 109]), o($V9, [2, 114]), o($V9, [2, 113]), o($V9, [2, 112]), o($V9, [2, 111]), o($V9, [2, 116]), o($V9, [2, 115]), o($V9, [2, 104]), o($V9, [2, 103]), o($V9, [2, 102]), o($V9, [2, 101]), o($V9, [2, 99]), o($V9, [2, 100]), o($V9, [2, 98]), o($V9, [2, 97]), o($V9, [2, 96]), o($V9, [2, 95]), o($V9, [2, 93]), o($V9, [2, 94])], + defaultActions: { 7: [2, 1], 13: [2, 2], 18: [2, 3], 36: [2, 4] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 19; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 21; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + return 13; + case 8: + break; + case 9: + break; + case 10: + return 5; + case 11: + return 40; + case 12: + return 32; + case 13: + return 38; + case 14: + return 42; + case 15: + return 43; + case 16: + return 44; + case 17: + return 45; + case 18: + return 35; + case 19: + return 28; + case 20: + return 29; + case 21: + return 37; + case 22: + return 31; + case 23: + return 34; + case 24: + return 26; + case 25: + return 9; + case 26: + return 9; + case 27: + return 8; + case 28: + return "CARET"; + case 29: + this.begin("options"); + break; + case 30: + this.popState(); + break; + case 31: + return 12; + case 32: + return 36; + case 33: + this.begin("string"); + break; + case 34: + this.popState(); + break; + case 35: + return 33; + case 36: + return 30; + case 37: + return 46; + case 38: + return 7; + } + }, + rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gitGraph\b)/i, /^(?:commit(?=\s|$))/i, /^(?:id:)/i, /^(?:type:)/i, /^(?:msg:)/i, /^(?:NORMAL\b)/i, /^(?:REVERSE\b)/i, /^(?:HIGHLIGHT\b)/i, /^(?:tag:)/i, /^(?:branch(?=\s|$))/i, /^(?:order:)/i, /^(?:merge(?=\s|$))/i, /^(?:cherry-pick(?=\s|$))/i, /^(?:parent:)/i, /^(?:checkout(?=\s|$))/i, /^(?:LR\b)/i, /^(?:TB\b)/i, /^(?::)/i, /^(?:\^)/i, /^(?:options\r?\n)/i, /^(?:[ \r\n\t]+end\b)/i, /^(?:[\s\S]+(?=[ \r\n\t]+end))/i, /^(?:["]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[0-9]+(?=\s|$))/i, /^(?:\w([-\./\w]*[-\w])?)/i, /^(?:$)/i, /^(?:\s+)/i], + conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "options": { "rules": [30, 31], "inclusive": false }, "string": { "rules": [34, 35], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 36, 37, 38, 39], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const gitGraphParser = parser; +let mainBranchName = getConfig().gitGraph.mainBranchName; +let mainBranchOrder = getConfig().gitGraph.mainBranchOrder; +let commits = {}; +let head = null; +let branchesConfig = {}; +branchesConfig[mainBranchName] = { name: mainBranchName, order: mainBranchOrder }; +let branches = {}; +branches[mainBranchName] = head; +let curBranch = mainBranchName; +let direction = "LR"; +let seq = 0; +function getId() { + return random({ length: 7 }); +} +function uniqBy(list, fn) { + const recordMap = /* @__PURE__ */ Object.create(null); + return list.reduce((out, item) => { + const key = fn(item); + if (!recordMap[key]) { + recordMap[key] = true; + out.push(item); + } + return out; + }, []); +} +const setDirection = function(dir2) { + direction = dir2; +}; +let options = {}; +const setOptions = function(rawOptString) { + log$1.debug("options str", rawOptString); + rawOptString = rawOptString && rawOptString.trim(); + rawOptString = rawOptString || "{}"; + try { + options = JSON.parse(rawOptString); + } catch (e) { + log$1.error("error while parsing gitGraph options", e.message); + } +}; +const getOptions = function() { + return options; +}; +const commit = function(msg, id, type, tag) { + log$1.debug("Entering commit:", msg, id, type, tag); + id = common$1.sanitizeText(id, getConfig()); + msg = common$1.sanitizeText(msg, getConfig()); + tag = common$1.sanitizeText(tag, getConfig()); + const commit2 = { + id: id ? id : seq + "-" + getId(), + message: msg, + seq: seq++, + type: type ? type : commitType$1.NORMAL, + tag: tag ? tag : "", + parents: head == null ? [] : [head.id], + branch: curBranch + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug("in pushCommit " + commit2.id); +}; +const branch = function(name, order) { + name = common$1.sanitizeText(name, getConfig()); + if (branches[name] === void 0) { + branches[name] = head != null ? head.id : null; + branchesConfig[name] = { name, order: order ? parseInt(order, 10) : null }; + checkout(name); + log$1.debug("in createBranch"); + } else { + let error = new Error( + 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ' + name + '")' + ); + error.hash = { + text: "branch " + name, + token: "branch " + name, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"checkout ' + name + '"'] + }; + throw error; + } +}; +const merge = function(otherBranch, custom_id, override_type, custom_tag) { + otherBranch = common$1.sanitizeText(otherBranch, getConfig()); + custom_id = common$1.sanitizeText(custom_id, getConfig()); + const currentCommit = commits[branches[curBranch]]; + const otherCommit = commits[branches[otherBranch]]; + if (curBranch === otherBranch) { + let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch abc"] + }; + throw error; + } else if (currentCommit === void 0 || !currentCommit) { + let error = new Error( + 'Incorrect usage of "merge". Current branch (' + curBranch + ")has no commits" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["commit"] + }; + throw error; + } else if (branches[otherBranch] === void 0) { + let error = new Error( + 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") does not exist" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch " + otherBranch] + }; + throw error; + } else if (otherCommit === void 0 || !otherCommit) { + let error = new Error( + 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") has no commits" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"commit"'] + }; + throw error; + } else if (currentCommit === otherCommit) { + let error = new Error('Incorrect usage of "merge". Both branches have same head'); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch abc"] + }; + throw error; + } else if (custom_id && commits[custom_id] !== void 0) { + let error = new Error( + 'Incorrect usage of "merge". Commit with id:' + custom_id + " already exists, use different custom Id" + ); + error.hash = { + text: "merge " + otherBranch + custom_id + override_type + custom_tag, + token: "merge " + otherBranch + custom_id + override_type + custom_tag, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: [ + "merge " + otherBranch + " " + custom_id + "_UNIQUE " + override_type + " " + custom_tag + ] + }; + throw error; + } + const commit2 = { + id: custom_id ? custom_id : seq + "-" + getId(), + message: "merged branch " + otherBranch + " into " + curBranch, + seq: seq++, + parents: [head == null ? null : head.id, branches[otherBranch]], + branch: curBranch, + type: commitType$1.MERGE, + customType: override_type, + customId: custom_id ? true : false, + tag: custom_tag ? custom_tag : "" + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug(branches); + log$1.debug("in mergeBranch"); +}; +const cherryPick = function(sourceId, targetId, tag, parentCommitId) { + log$1.debug("Entering cherryPick:", sourceId, targetId, tag); + sourceId = common$1.sanitizeText(sourceId, getConfig()); + targetId = common$1.sanitizeText(targetId, getConfig()); + tag = common$1.sanitizeText(tag, getConfig()); + parentCommitId = common$1.sanitizeText(parentCommitId, getConfig()); + if (!sourceId || commits[sourceId] === void 0) { + let error = new Error( + 'Incorrect usage of "cherryPick". Source commit id should exist and provided' + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + let sourceCommit = commits[sourceId]; + let sourceCommitBranch = sourceCommit.branch; + if (parentCommitId && !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) { + let error = new Error( + "Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit." + ); + throw error; + } + if (sourceCommit.type === commitType$1.MERGE && !parentCommitId) { + let error = new Error( + "Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified." + ); + throw error; + } + if (!targetId || commits[targetId] === void 0) { + if (sourceCommitBranch === curBranch) { + let error = new Error( + 'Incorrect usage of "cherryPick". Source commit is already on current branch' + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + const currentCommit = commits[branches[curBranch]]; + if (currentCommit === void 0 || !currentCommit) { + let error = new Error( + 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ")has no commits" + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + const commit2 = { + id: seq + "-" + getId(), + message: "cherry-picked " + sourceCommit + " into " + curBranch, + seq: seq++, + parents: [head == null ? null : head.id, sourceCommit.id], + branch: curBranch, + type: commitType$1.CHERRY_PICK, + tag: tag ?? `cherry-pick:${sourceCommit.id}${sourceCommit.type === commitType$1.MERGE ? `|parent:${parentCommitId}` : ""}` + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug(branches); + log$1.debug("in cherryPick"); + } +}; +const checkout = function(branch2) { + branch2 = common$1.sanitizeText(branch2, getConfig()); + if (branches[branch2] === void 0) { + let error = new Error( + 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch2 + '")' + ); + error.hash = { + text: "checkout " + branch2, + token: "checkout " + branch2, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"branch ' + branch2 + '"'] + }; + throw error; + } else { + curBranch = branch2; + const id = branches[curBranch]; + head = commits[id]; + } +}; +function upsert(arr, key, newVal) { + const index = arr.indexOf(key); + if (index === -1) { + arr.push(newVal); + } else { + arr.splice(index, 1, newVal); + } +} +function prettyPrintCommitHistory(commitArr) { + const commit2 = commitArr.reduce((out, commit3) => { + if (out.seq > commit3.seq) { + return out; + } + return commit3; + }, commitArr[0]); + let line = ""; + commitArr.forEach(function(c) { + if (c === commit2) { + line += " *"; + } else { + line += " |"; + } + }); + const label = [line, commit2.id, commit2.seq]; + for (let branch2 in branches) { + if (branches[branch2] === commit2.id) { + label.push(branch2); + } + } + log$1.debug(label.join(" ")); + if (commit2.parents && commit2.parents.length == 2) { + const newCommit = commits[commit2.parents[0]]; + upsert(commitArr, commit2, newCommit); + commitArr.push(commits[commit2.parents[1]]); + } else if (commit2.parents.length == 0) { + return; + } else { + const nextCommit = commits[commit2.parents]; + upsert(commitArr, commit2, nextCommit); + } + commitArr = uniqBy(commitArr, (c) => c.id); + prettyPrintCommitHistory(commitArr); +} +const prettyPrint = function() { + log$1.debug(commits); + const node = getCommitsArray()[0]; + prettyPrintCommitHistory([node]); +}; +const clear$1 = function() { + commits = {}; + head = null; + let mainBranch = getConfig().gitGraph.mainBranchName; + let mainBranchOrder2 = getConfig().gitGraph.mainBranchOrder; + branches = {}; + branches[mainBranch] = null; + branchesConfig = {}; + branchesConfig[mainBranch] = { name: mainBranch, order: mainBranchOrder2 }; + curBranch = mainBranch; + seq = 0; + clear$2(); +}; +const getBranchesAsObjArray = function() { + const branchesArray = Object.values(branchesConfig).map((branchConfig, i) => { + if (branchConfig.order !== null) { + return branchConfig; + } + return { + ...branchConfig, + order: parseFloat(`0.${i}`, 10) + }; + }).sort((a, b) => a.order - b.order).map(({ name }) => ({ name })); + return branchesArray; +}; +const getBranches = function() { + return branches; +}; +const getCommits = function() { + return commits; +}; +const getCommitsArray = function() { + const commitArr = Object.keys(commits).map(function(key) { + return commits[key]; + }); + commitArr.forEach(function(o) { + log$1.debug(o.id); + }); + commitArr.sort((a, b) => a.seq - b.seq); + return commitArr; +}; +const getCurrentBranch = function() { + return curBranch; +}; +const getDirection = function() { + return direction; +}; +const getHead = function() { + return head; +}; +const commitType$1 = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4 +}; +const gitGraphDb = { + getConfig: () => getConfig().gitGraph, + setDirection, + setOptions, + getOptions, + commit, + branch, + merge, + cherryPick, + checkout, + //reset, + prettyPrint, + clear: clear$1, + getBranchesAsObjArray, + getBranches, + getCommits, + getCommitsArray, + getCurrentBranch, + getDirection, + getHead, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + setDiagramTitle, + getDiagramTitle, + commitType: commitType$1 +}; +let allCommitsDict = {}; +const commitType = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4 +}; +const THEME_COLOR_LIMIT = 8; +let branchPos = {}; +let commitPos = {}; +let lanes = []; +let maxPos = 0; +let dir = "LR"; +const clear = () => { + branchPos = {}; + commitPos = {}; + allCommitsDict = {}; + maxPos = 0; + lanes = []; + dir = "LR"; +}; +const drawText = (txt) => { + const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text"); + let rows = []; + if (typeof txt === "string") { + rows = txt.split(/\\n|\n|/gi); + } else if (Array.isArray(txt)) { + rows = txt; + } else { + rows = []; + } + for (const row of rows) { + const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "0"); + tspan.setAttribute("class", "row"); + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + } + return svgLabel; +}; +const findClosestParent = (parents) => { + let closestParent = ""; + let maxPosition = 0; + parents.forEach((parent) => { + const parentPosition = dir === "TB" ? commitPos[parent].y : commitPos[parent].x; + if (parentPosition >= maxPosition) { + closestParent = parent; + maxPosition = parentPosition; + } + }); + return closestParent || void 0; +}; +const drawCommits = (svg, commits2, modifyGraph) => { + const gitGraphConfig = getConfig().gitGraph; + const gBullets = svg.append("g").attr("class", "commit-bullets"); + const gLabels = svg.append("g").attr("class", "commit-labels"); + let pos = 0; + if (dir === "TB") { + pos = 30; + } + const keys = Object.keys(commits2); + const sortedKeys = keys.sort((a, b) => { + return commits2[a].seq - commits2[b].seq; + }); + const isParallelCommits = gitGraphConfig.parallelCommits; + const layoutOffset = 10; + const commitStep = 40; + sortedKeys.forEach((key) => { + const commit2 = commits2[key]; + if (isParallelCommits) { + if (commit2.parents.length) { + const closestParent = findClosestParent(commit2.parents); + pos = dir === "TB" ? commitPos[closestParent].y + commitStep : commitPos[closestParent].x + commitStep; + } else { + pos = 0; + if (dir === "TB") { + pos = 30; + } + } + } + const posWithOffset = pos + layoutOffset; + const y = dir === "TB" ? posWithOffset : branchPos[commit2.branch].pos; + const x = dir === "TB" ? branchPos[commit2.branch].pos : posWithOffset; + if (modifyGraph) { + let typeClass; + let commitSymbolType = commit2.customType !== void 0 && commit2.customType !== "" ? commit2.customType : commit2.type; + switch (commitSymbolType) { + case commitType.NORMAL: + typeClass = "commit-normal"; + break; + case commitType.REVERSE: + typeClass = "commit-reverse"; + break; + case commitType.HIGHLIGHT: + typeClass = "commit-highlight"; + break; + case commitType.MERGE: + typeClass = "commit-merge"; + break; + case commitType.CHERRY_PICK: + typeClass = "commit-cherry-pick"; + break; + default: + typeClass = "commit-normal"; + } + if (commitSymbolType === commitType.HIGHLIGHT) { + const circle = gBullets.append("rect"); + circle.attr("x", x - 10); + circle.attr("y", y - 10); + circle.attr("height", 20); + circle.attr("width", 20); + circle.attr( + "class", + `commit ${commit2.id} commit-highlight${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-outer` + ); + gBullets.append("rect").attr("x", x - 6).attr("y", y - 6).attr("height", 12).attr("width", 12).attr( + "class", + `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-inner` + ); + } else if (commitSymbolType === commitType.CHERRY_PICK) { + gBullets.append("circle").attr("cx", x).attr("cy", y).attr("r", 10).attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("circle").attr("cx", x - 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("circle").attr("cx", x + 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("line").attr("x1", x + 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("line").attr("x1", x - 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + } else { + const circle = gBullets.append("circle"); + circle.attr("cx", x); + circle.attr("cy", y); + circle.attr("r", commit2.type === commitType.MERGE ? 9 : 10); + circle.attr( + "class", + `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + if (commitSymbolType === commitType.MERGE) { + const circle2 = gBullets.append("circle"); + circle2.attr("cx", x); + circle2.attr("cy", y); + circle2.attr("r", 6); + circle2.attr( + "class", + `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + } + if (commitSymbolType === commitType.REVERSE) { + const cross = gBullets.append("path"); + cross.attr("d", `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`).attr( + "class", + `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + } + } + } + if (dir === "TB") { + commitPos[commit2.id] = { x, y: posWithOffset }; + } else { + commitPos[commit2.id] = { x: posWithOffset, y }; + } + if (modifyGraph) { + const px = 4; + const py = 2; + if (commit2.type !== commitType.CHERRY_PICK && (commit2.customId && commit2.type === commitType.MERGE || commit2.type !== commitType.MERGE) && gitGraphConfig.showCommitLabel) { + const wrapper = gLabels.append("g"); + const labelBkg = wrapper.insert("rect").attr("class", "commit-label-bkg"); + const text = wrapper.append("text").attr("x", pos).attr("y", y + 25).attr("class", "commit-label").text(commit2.id); + let bbox = text.node().getBBox(); + labelBkg.attr("x", posWithOffset - bbox.width / 2 - py).attr("y", y + 13.5).attr("width", bbox.width + 2 * py).attr("height", bbox.height + 2 * py); + if (dir === "TB") { + labelBkg.attr("x", x - (bbox.width + 4 * px + 5)).attr("y", y - 12); + text.attr("x", x - (bbox.width + 4 * px)).attr("y", y + bbox.height - 12); + } + if (dir !== "TB") { + text.attr("x", posWithOffset - bbox.width / 2); + } + if (gitGraphConfig.rotateCommitLabel) { + if (dir === "TB") { + text.attr("transform", "rotate(-45, " + x + ", " + y + ")"); + labelBkg.attr("transform", "rotate(-45, " + x + ", " + y + ")"); + } else { + let r_x = -7.5 - (bbox.width + 10) / 25 * 9.5; + let r_y = 10 + bbox.width / 25 * 8.5; + wrapper.attr( + "transform", + "translate(" + r_x + ", " + r_y + ") rotate(-45, " + pos + ", " + y + ")" + ); + } + } + } + if (commit2.tag) { + const rect = gLabels.insert("polygon"); + const hole = gLabels.append("circle"); + const tag = gLabels.append("text").attr("y", y - 16).attr("class", "tag-label").text(commit2.tag); + let tagBbox = tag.node().getBBox(); + tag.attr("x", posWithOffset - tagBbox.width / 2); + const h2 = tagBbox.height / 2; + const ly = y - 19.2; + rect.attr("class", "tag-label-bkg").attr( + "points", + ` + ${pos - tagBbox.width / 2 - px / 2},${ly + py} + ${pos - tagBbox.width / 2 - px / 2},${ly - py} + ${posWithOffset - tagBbox.width / 2 - px},${ly - h2 - py} + ${posWithOffset + tagBbox.width / 2 + px},${ly - h2 - py} + ${posWithOffset + tagBbox.width / 2 + px},${ly + h2 + py} + ${posWithOffset - tagBbox.width / 2 - px},${ly + h2 + py}` + ); + hole.attr("cx", pos - tagBbox.width / 2 + px / 2).attr("cy", ly).attr("r", 1.5).attr("class", "tag-hole"); + if (dir === "TB") { + rect.attr("class", "tag-label-bkg").attr( + "points", + ` + ${x},${pos + py} + ${x},${pos - py} + ${x + layoutOffset},${pos - h2 - py} + ${x + layoutOffset + tagBbox.width + px},${pos - h2 - py} + ${x + layoutOffset + tagBbox.width + px},${pos + h2 + py} + ${x + layoutOffset},${pos + h2 + py}` + ).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")"); + hole.attr("cx", x + px / 2).attr("cy", pos).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")"); + tag.attr("x", x + 5).attr("y", pos + 3).attr("transform", "translate(14,14) rotate(45, " + x + "," + pos + ")"); + } + } + } + pos += commitStep + layoutOffset; + if (pos > maxPos) { + maxPos = pos; + } + }); +}; +const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => { + const commitBIsFurthest = dir === "TB" ? p1.x < p2.x : p1.y < p2.y; + const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch; + const isOnBranchToGetCurve = (x) => x.branch === branchToGetCurve; + const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq; + return Object.values(allCommits).some((commitX) => { + return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX); + }); +}; +const findLane = (y1, y2, depth = 0) => { + const candidate = y1 + Math.abs(y1 - y2) / 2; + if (depth > 5) { + return candidate; + } + let ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10); + if (ok) { + lanes.push(candidate); + return candidate; + } + const diff = Math.abs(y1 - y2); + return findLane(y1, y2 - diff / 5, depth + 1); +}; +const drawArrow = (svg, commitA, commitB, allCommits) => { + const p1 = commitPos[commitA.id]; + const p2 = commitPos[commitB.id]; + const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits); + let arc = ""; + let arc2 = ""; + let radius = 0; + let offset = 0; + let colorClassNum = branchPos[commitB.branch].index; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + colorClassNum = branchPos[commitA.branch].index; + } + let lineDef; + if (arrowNeedsRerouting) { + arc = "A 10 10, 0, 0, 0,"; + arc2 = "A 10 10, 0, 0, 1,"; + radius = 10; + offset = 10; + const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y); + const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x); + if (dir === "TB") { + if (p1.x < p2.x) { + lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + colorClassNum = branchPos[commitA.branch].index; + lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } else { + if (p1.y < p2.y) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`; + } else { + colorClassNum = branchPos[commitA.branch].index; + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`; + } + } + } else { + arc = "A 20 20, 0, 0, 0,"; + arc2 = "A 20 20, 0, 0, 1,"; + radius = 20; + offset = 20; + if (dir === "TB") { + if (p1.x < p2.x) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } + } + if (p1.x > p2.x) { + arc = "A 20 20, 0, 0, 0,"; + arc2 = "A 20 20, 0, 0, 1,"; + radius = 20; + offset = 20; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } + } + if (p1.x === p2.x) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } else { + if (p1.y < p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } + if (p1.y > p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } + if (p1.y === p2.y) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } + } + svg.append("path").attr("d", lineDef).attr("class", "arrow arrow" + colorClassNum % THEME_COLOR_LIMIT); +}; +const drawArrows = (svg, commits2) => { + const gArrows = svg.append("g").attr("class", "commit-arrows"); + Object.keys(commits2).forEach((key) => { + const commit2 = commits2[key]; + if (commit2.parents && commit2.parents.length > 0) { + commit2.parents.forEach((parent) => { + drawArrow(gArrows, commits2[parent], commit2, commits2); + }); + } + }); +}; +const drawBranches = (svg, branches2) => { + const gitGraphConfig = getConfig().gitGraph; + const g = svg.append("g"); + branches2.forEach((branch2, index) => { + const adjustIndexForTheme = index % THEME_COLOR_LIMIT; + const pos = branchPos[branch2.name].pos; + const line = g.append("line"); + line.attr("x1", 0); + line.attr("y1", pos); + line.attr("x2", maxPos); + line.attr("y2", pos); + line.attr("class", "branch branch" + adjustIndexForTheme); + if (dir === "TB") { + line.attr("y1", 30); + line.attr("x1", pos); + line.attr("y2", maxPos); + line.attr("x2", pos); + } + lanes.push(pos); + let name = branch2.name; + const labelElement = drawText(name); + const bkg = g.insert("rect"); + const branchLabel = g.insert("g").attr("class", "branchLabel"); + const label = branchLabel.insert("g").attr("class", "label branch-label" + adjustIndexForTheme); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + bkg.attr("class", "branchLabelBkg label" + adjustIndexForTheme).attr("rx", 4).attr("ry", 4).attr("x", -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)).attr("y", -bbox.height / 2 + 8).attr("width", bbox.width + 18).attr("height", bbox.height + 4); + label.attr( + "transform", + "translate(" + (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + ", " + (pos - bbox.height / 2 - 1) + ")" + ); + if (dir === "TB") { + bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", 0); + label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", 0)"); + } + if (dir !== "TB") { + bkg.attr("transform", "translate(-19, " + (pos - bbox.height / 2) + ")"); + } + }); +}; +const draw = function(txt, id, ver, diagObj) { + clear(); + const conf = getConfig(); + const gitGraphConfig = conf.gitGraph; + log$1.debug("in gitgraph renderer", txt + "\n", "id:", id, ver); + allCommitsDict = diagObj.db.getCommits(); + const branches2 = diagObj.db.getBranchesAsObjArray(); + dir = diagObj.db.getDirection(); + const diagram2 = select(`[id="${id}"]`); + let pos = 0; + branches2.forEach((branch2, index) => { + const labelElement = drawText(branch2.name); + const g = diagram2.append("g"); + const branchLabel = g.insert("g").attr("class", "branchLabel"); + const label = branchLabel.insert("g").attr("class", "label branch-label"); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + branchPos[branch2.name] = { pos, index }; + pos += 50 + (gitGraphConfig.rotateCommitLabel ? 40 : 0) + (dir === "TB" ? bbox.width / 2 : 0); + label.remove(); + branchLabel.remove(); + g.remove(); + }); + drawCommits(diagram2, allCommitsDict, false); + if (gitGraphConfig.showBranches) { + drawBranches(diagram2, branches2); + } + drawArrows(diagram2, allCommitsDict); + drawCommits(diagram2, allCommitsDict, true); + utils.insertTitle( + diagram2, + "gitTitleText", + gitGraphConfig.titleTopMargin, + diagObj.db.getDiagramTitle() + ); + setupGraphViewbox( + void 0, + diagram2, + gitGraphConfig.diagramPadding, + gitGraphConfig.useMaxWidth ?? conf.useMaxWidth + ); +}; +const gitGraphRenderer = { + draw +}; +const getStyles = (options2) => ` + .commit-id, + .commit-msg, + .branch-label { + fill: lightgrey; + color: lightgrey; + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + } + ${[0, 1, 2, 3, 4, 5, 6, 7].map( + (i) => ` + .branch-label${i} { fill: ${options2["gitBranchLabel" + i]}; } + .commit${i} { stroke: ${options2["git" + i]}; fill: ${options2["git" + i]}; } + .commit-highlight${i} { stroke: ${options2["gitInv" + i]}; fill: ${options2["gitInv" + i]}; } + .label${i} { fill: ${options2["git" + i]}; } + .arrow${i} { stroke: ${options2["git" + i]}; } + ` +).join("\n")} + + .branch { + stroke-width: 1; + stroke: ${options2.lineColor}; + stroke-dasharray: 2; + } + .commit-label { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelColor};} + .commit-label-bkg { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelBackground}; opacity: 0.5; } + .tag-label { font-size: ${options2.tagLabelFontSize}; fill: ${options2.tagLabelColor};} + .tag-label-bkg { fill: ${options2.tagLabelBackground}; stroke: ${options2.tagLabelBorder}; } + .tag-hole { fill: ${options2.textColor}; } + + .commit-merge { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + } + .commit-reverse { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + stroke-width: 3; + } + .commit-highlight-outer { + } + .commit-highlight-inner { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + } + + .arrow { stroke-width: 8; stroke-linecap: round; fill: none} + .gitTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options2.textColor}; + } +`; +const gitGraphStyles = getStyles; +const diagram = { + parser: gitGraphParser, + db: gitGraphDb, + renderer: gitGraphRenderer, + styles: gitGraphStyles +}; + +export { diagram }; diff --git a/libs/marked/gitGraphDiagram-942e62fe-byuJSX1R.js b/libs/marked/gitGraphDiagram-942e62fe-byuJSX1R.js new file mode 100644 index 0000000..d0f9489 --- /dev/null +++ b/libs/marked/gitGraphDiagram-942e62fe-byuJSX1R.js @@ -0,0 +1,1790 @@ +import { c as getConfig, s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, j as common$1, E as clear$2, h as select, A as utils, H as setupGraphViewbox, I as random } from './index-Bd_FDXSq.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 6], $V2 = [1, 4], $V3 = [1, 5], $V4 = [2, 5], $V5 = [1, 12], $V6 = [5, 7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40, 47], $V7 = [7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V8 = [7, 12, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V9 = [7, 13, 47], $Va = [1, 42], $Vb = [1, 41], $Vc = [7, 13, 29, 32, 35, 38, 47], $Vd = [1, 55], $Ve = [1, 56], $Vf = [1, 57], $Vg = [7, 13, 32, 35, 42, 47]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "GG": 5, "document": 6, "EOF": 7, ":": 8, "DIR": 9, "options": 10, "body": 11, "OPT": 12, "NL": 13, "line": 14, "statement": 15, "commitStatement": 16, "mergeStatement": 17, "cherryPickStatement": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "section": 24, "branchStatement": 25, "CHECKOUT": 26, "ref": 27, "BRANCH": 28, "ORDER": 29, "NUM": 30, "CHERRY_PICK": 31, "COMMIT_ID": 32, "STR": 33, "PARENT_COMMIT": 34, "COMMIT_TAG": 35, "EMPTYSTR": 36, "MERGE": 37, "COMMIT_TYPE": 38, "commitType": 39, "COMMIT": 40, "commit_arg": 41, "COMMIT_MSG": 42, "NORMAL": 43, "REVERSE": 44, "HIGHLIGHT": 45, "ID": 46, ";": 47, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "GG", 7: "EOF", 8: ":", 9: "DIR", 12: "OPT", 13: "NL", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "section", 26: "CHECKOUT", 28: "BRANCH", 29: "ORDER", 30: "NUM", 31: "CHERRY_PICK", 32: "COMMIT_ID", 33: "STR", 34: "PARENT_COMMIT", 35: "COMMIT_TAG", 36: "EMPTYSTR", 37: "MERGE", 38: "COMMIT_TYPE", 40: "COMMIT", 42: "COMMIT_MSG", 43: "NORMAL", 44: "REVERSE", 45: "HIGHLIGHT", 46: "ID", 47: ";" }, + productions_: [0, [3, 2], [3, 3], [3, 4], [3, 5], [6, 0], [6, 2], [10, 2], [10, 1], [11, 0], [11, 2], [14, 2], [14, 1], [15, 1], [15, 1], [15, 1], [15, 2], [15, 2], [15, 1], [15, 1], [15, 1], [15, 2], [25, 2], [25, 4], [18, 3], [18, 5], [18, 5], [18, 7], [18, 7], [18, 5], [18, 5], [18, 5], [18, 7], [18, 7], [18, 7], [18, 7], [17, 2], [17, 4], [17, 4], [17, 4], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [16, 2], [16, 3], [16, 3], [16, 5], [16, 5], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [41, 0], [41, 1], [39, 1], [39, 1], [39, 1], [27, 1], [27, 1], [4, 1], [4, 1], [4, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 2: + return $$[$0]; + case 3: + return $$[$0 - 1]; + case 4: + yy.setDirection($$[$0 - 3]); + return $$[$0 - 1]; + case 6: + yy.setOptions($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 7: + $$[$0 - 1] += $$[$0]; + this.$ = $$[$0 - 1]; + break; + case 9: + this.$ = []; + break; + case 10: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 11: + this.$ = $$[$0 - 1]; + break; + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 21: + yy.checkout($$[$0]); + break; + case 22: + yy.branch($$[$0]); + break; + case 23: + yy.branch($$[$0 - 2], $$[$0]); + break; + case 24: + yy.cherryPick($$[$0], "", void 0); + break; + case 25: + yy.cherryPick($$[$0 - 2], "", void 0, $$[$0]); + break; + case 26: + yy.cherryPick($$[$0 - 2], "", $$[$0]); + break; + case 27: + yy.cherryPick($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 28: + yy.cherryPick($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 29: + yy.cherryPick($$[$0], "", $$[$0 - 2]); + break; + case 30: + yy.cherryPick($$[$0], "", ""); + break; + case 31: + yy.cherryPick($$[$0 - 2], "", ""); + break; + case 32: + yy.cherryPick($$[$0 - 4], "", "", $$[$0 - 2]); + break; + case 33: + yy.cherryPick($$[$0 - 4], "", "", $$[$0]); + break; + case 34: + yy.cherryPick($$[$0 - 2], "", $$[$0 - 4], $$[$0]); + break; + case 35: + yy.cherryPick($$[$0 - 2], "", "", $$[$0]); + break; + case 36: + yy.merge($$[$0], "", "", ""); + break; + case 37: + yy.merge($$[$0 - 2], $$[$0], "", ""); + break; + case 38: + yy.merge($$[$0 - 2], "", $$[$0], ""); + break; + case 39: + yy.merge($$[$0 - 2], "", "", $$[$0]); + break; + case 40: + yy.merge($$[$0 - 4], $$[$0], "", $$[$0 - 2]); + break; + case 41: + yy.merge($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 42: + yy.merge($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 43: + yy.merge($$[$0 - 4], $$[$0 - 2], $$[$0], ""); + break; + case 44: + yy.merge($$[$0 - 4], $$[$0 - 2], "", $$[$0]); + break; + case 45: + yy.merge($$[$0 - 4], $$[$0], $$[$0 - 2], ""); + break; + case 46: + yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 47: + yy.merge($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 48: + yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 49: + yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 50: + yy.merge($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 51: + yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 52: + yy.commit($$[$0]); + break; + case 53: + yy.commit("", "", yy.commitType.NORMAL, $$[$0]); + break; + case 54: + yy.commit("", "", $$[$0], ""); + break; + case 55: + yy.commit("", "", $$[$0], $$[$0 - 2]); + break; + case 56: + yy.commit("", "", $$[$0 - 2], $$[$0]); + break; + case 57: + yy.commit("", $$[$0], yy.commitType.NORMAL, ""); + break; + case 58: + yy.commit("", $$[$0 - 2], yy.commitType.NORMAL, $$[$0]); + break; + case 59: + yy.commit("", $$[$0], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 60: + yy.commit("", $$[$0 - 2], $$[$0], ""); + break; + case 61: + yy.commit("", $$[$0], $$[$0 - 2], ""); + break; + case 62: + yy.commit("", $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 63: + yy.commit("", $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 64: + yy.commit("", $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 65: + yy.commit("", $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 66: + yy.commit("", $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 67: + yy.commit("", $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 68: + yy.commit($$[$0], "", yy.commitType.NORMAL, ""); + break; + case 69: + yy.commit($$[$0], "", yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 70: + yy.commit($$[$0 - 2], "", yy.commitType.NORMAL, $$[$0]); + break; + case 71: + yy.commit($$[$0 - 2], "", $$[$0], ""); + break; + case 72: + yy.commit($$[$0], "", $$[$0 - 2], ""); + break; + case 73: + yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, ""); + break; + case 74: + yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, ""); + break; + case 75: + yy.commit($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 76: + yy.commit($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 77: + yy.commit($$[$0 - 2], "", $$[$0 - 4], $$[$0]); + break; + case 78: + yy.commit($$[$0], "", $$[$0 - 4], $$[$0 - 2]); + break; + case 79: + yy.commit($$[$0], "", $$[$0 - 2], $$[$0 - 4]); + break; + case 80: + yy.commit($$[$0 - 2], "", $$[$0], $$[$0 - 4]); + break; + case 81: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], ""); + break; + case 82: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], ""); + break; + case 83: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], ""); + break; + case 84: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], ""); + break; + case 85: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], ""); + break; + case 86: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], ""); + break; + case 87: + yy.commit($$[$0 - 4], $$[$0], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 88: + yy.commit($$[$0 - 4], $$[$0 - 2], yy.commitType.NORMAL, $$[$0]); + break; + case 89: + yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, $$[$0 - 4]); + break; + case 90: + yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, $$[$0 - 4]); + break; + case 91: + yy.commit($$[$0], $$[$0 - 4], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 92: + yy.commit($$[$0 - 2], $$[$0 - 4], yy.commitType.NORMAL, $$[$0]); + break; + case 93: + yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 94: + yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 95: + yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 96: + yy.commit($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 97: + yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 98: + yy.commit($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 99: + yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0 - 2], $$[$0]); + break; + case 100: + yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0], $$[$0 - 2]); + break; + case 101: + yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0 - 4], $$[$0]); + break; + case 102: + yy.commit($$[$0], $$[$0 - 6], $$[$0 - 4], $$[$0 - 2]); + break; + case 103: + yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0], $$[$0 - 4]); + break; + case 104: + yy.commit($$[$0], $$[$0 - 6], $$[$0 - 2], $$[$0 - 4]); + break; + case 105: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], $$[$0 - 6]); + break; + case 106: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], $$[$0 - 6]); + break; + case 107: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], $$[$0 - 6]); + break; + case 108: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], $$[$0 - 6]); + break; + case 109: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], $$[$0 - 6]); + break; + case 110: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 6]); + break; + case 111: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0 - 6], $$[$0]); + break; + case 112: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 6], $$[$0 - 2]); + break; + case 113: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 6], $$[$0 - 4]); + break; + case 114: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 6], $$[$0 - 4]); + break; + case 115: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0 - 6], $$[$0]); + break; + case 116: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 6], $$[$0 - 2]); + break; + case 117: + this.$ = ""; + break; + case 118: + this.$ = $$[$0]; + break; + case 119: + this.$ = yy.commitType.NORMAL; + break; + case 120: + this.$ = yy.commitType.REVERSE; + break; + case 121: + this.$ = yy.commitType.HIGHLIGHT; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 6: 8, 7: $V4, 8: [1, 9], 9: [1, 10], 10: 11, 13: $V5 }, o($V6, [2, 124]), o($V6, [2, 125]), o($V6, [2, 126]), { 1: [2, 1] }, { 7: [1, 13] }, { 6: 14, 7: $V4, 10: 11, 13: $V5 }, { 8: [1, 15] }, o($V7, [2, 9], { 11: 16, 12: [1, 17] }), o($V8, [2, 8]), { 1: [2, 2] }, { 7: [1, 18] }, { 6: 19, 7: $V4, 10: 11, 13: $V5 }, { 7: [2, 6], 13: [1, 22], 14: 20, 15: 21, 16: 23, 17: 24, 18: 25, 19: [1, 26], 21: [1, 27], 23: [1, 28], 24: [1, 29], 25: 30, 26: [1, 31], 28: [1, 35], 31: [1, 34], 37: [1, 33], 40: [1, 32] }, o($V8, [2, 7]), { 1: [2, 3] }, { 7: [1, 36] }, o($V7, [2, 10]), { 4: 37, 7: $V1, 13: $V2, 47: $V3 }, o($V7, [2, 12]), o($V9, [2, 13]), o($V9, [2, 14]), o($V9, [2, 15]), { 20: [1, 38] }, { 22: [1, 39] }, o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), { 27: 40, 33: $Va, 46: $Vb }, o($V9, [2, 117], { 41: 43, 32: [1, 46], 33: [1, 48], 35: [1, 44], 38: [1, 45], 42: [1, 47] }), { 27: 49, 33: $Va, 46: $Vb }, { 32: [1, 50], 35: [1, 51] }, { 27: 52, 33: $Va, 46: $Vb }, { 1: [2, 4] }, o($V7, [2, 11]), o($V9, [2, 16]), o($V9, [2, 17]), o($V9, [2, 21]), o($Vc, [2, 122]), o($Vc, [2, 123]), o($V9, [2, 52]), { 33: [1, 53] }, { 39: 54, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 58] }, { 33: [1, 59] }, o($V9, [2, 118]), o($V9, [2, 36], { 32: [1, 60], 35: [1, 62], 38: [1, 61] }), { 33: [1, 63] }, { 33: [1, 64], 36: [1, 65] }, o($V9, [2, 22], { 29: [1, 66] }), o($V9, [2, 53], { 32: [1, 68], 38: [1, 67], 42: [1, 69] }), o($V9, [2, 54], { 32: [1, 71], 35: [1, 70], 42: [1, 72] }), o($Vg, [2, 119]), o($Vg, [2, 120]), o($Vg, [2, 121]), o($V9, [2, 57], { 35: [1, 73], 38: [1, 74], 42: [1, 75] }), o($V9, [2, 68], { 32: [1, 78], 35: [1, 76], 38: [1, 77] }), { 33: [1, 79] }, { 39: 80, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 81] }, o($V9, [2, 24], { 34: [1, 82], 35: [1, 83] }), { 32: [1, 84] }, { 32: [1, 85] }, { 30: [1, 86] }, { 39: 87, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 88] }, { 33: [1, 89] }, { 33: [1, 90] }, { 33: [1, 91] }, { 33: [1, 92] }, { 33: [1, 93] }, { 39: 94, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 95] }, { 33: [1, 96] }, { 39: 97, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 98] }, o($V9, [2, 37], { 35: [1, 100], 38: [1, 99] }), o($V9, [2, 38], { 32: [1, 102], 35: [1, 101] }), o($V9, [2, 39], { 32: [1, 103], 38: [1, 104] }), { 33: [1, 105] }, { 33: [1, 106], 36: [1, 107] }, { 33: [1, 108] }, { 33: [1, 109] }, o($V9, [2, 23]), o($V9, [2, 55], { 32: [1, 110], 42: [1, 111] }), o($V9, [2, 59], { 38: [1, 112], 42: [1, 113] }), o($V9, [2, 69], { 32: [1, 115], 38: [1, 114] }), o($V9, [2, 56], { 32: [1, 116], 42: [1, 117] }), o($V9, [2, 61], { 35: [1, 118], 42: [1, 119] }), o($V9, [2, 72], { 32: [1, 121], 35: [1, 120] }), o($V9, [2, 58], { 38: [1, 122], 42: [1, 123] }), o($V9, [2, 60], { 35: [1, 124], 42: [1, 125] }), o($V9, [2, 73], { 35: [1, 127], 38: [1, 126] }), o($V9, [2, 70], { 32: [1, 129], 38: [1, 128] }), o($V9, [2, 71], { 32: [1, 131], 35: [1, 130] }), o($V9, [2, 74], { 35: [1, 133], 38: [1, 132] }), { 39: 134, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 135] }, { 33: [1, 136] }, { 33: [1, 137] }, { 33: [1, 138] }, { 39: 139, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 25], { 35: [1, 140] }), o($V9, [2, 26], { 34: [1, 141] }), o($V9, [2, 31], { 34: [1, 142] }), o($V9, [2, 29], { 34: [1, 143] }), o($V9, [2, 30], { 34: [1, 144] }), { 33: [1, 145] }, { 33: [1, 146] }, { 39: 147, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 148] }, { 39: 149, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 150] }, { 33: [1, 151] }, { 33: [1, 152] }, { 33: [1, 153] }, { 33: [1, 154] }, { 33: [1, 155] }, { 33: [1, 156] }, { 39: 157, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 158] }, { 33: [1, 159] }, { 33: [1, 160] }, { 39: 161, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 162] }, { 39: 163, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 164] }, { 33: [1, 165] }, { 33: [1, 166] }, { 39: 167, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 168] }, o($V9, [2, 43], { 35: [1, 169] }), o($V9, [2, 44], { 38: [1, 170] }), o($V9, [2, 42], { 32: [1, 171] }), o($V9, [2, 45], { 35: [1, 172] }), o($V9, [2, 40], { 38: [1, 173] }), o($V9, [2, 41], { 32: [1, 174] }), { 33: [1, 175], 36: [1, 176] }, { 33: [1, 177] }, { 33: [1, 178] }, { 33: [1, 179] }, { 33: [1, 180] }, o($V9, [2, 66], { 42: [1, 181] }), o($V9, [2, 79], { 32: [1, 182] }), o($V9, [2, 67], { 42: [1, 183] }), o($V9, [2, 90], { 38: [1, 184] }), o($V9, [2, 80], { 32: [1, 185] }), o($V9, [2, 89], { 38: [1, 186] }), o($V9, [2, 65], { 42: [1, 187] }), o($V9, [2, 78], { 32: [1, 188] }), o($V9, [2, 64], { 42: [1, 189] }), o($V9, [2, 84], { 35: [1, 190] }), o($V9, [2, 77], { 32: [1, 191] }), o($V9, [2, 83], { 35: [1, 192] }), o($V9, [2, 63], { 42: [1, 193] }), o($V9, [2, 91], { 38: [1, 194] }), o($V9, [2, 62], { 42: [1, 195] }), o($V9, [2, 85], { 35: [1, 196] }), o($V9, [2, 86], { 35: [1, 197] }), o($V9, [2, 92], { 38: [1, 198] }), o($V9, [2, 76], { 32: [1, 199] }), o($V9, [2, 87], { 38: [1, 200] }), o($V9, [2, 75], { 32: [1, 201] }), o($V9, [2, 81], { 35: [1, 202] }), o($V9, [2, 82], { 35: [1, 203] }), o($V9, [2, 88], { 38: [1, 204] }), { 33: [1, 205] }, { 39: 206, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 207] }, { 33: [1, 208] }, { 39: 209, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 210] }, o($V9, [2, 27]), o($V9, [2, 32]), o($V9, [2, 28]), o($V9, [2, 33]), o($V9, [2, 34]), o($V9, [2, 35]), { 33: [1, 211] }, { 33: [1, 212] }, { 33: [1, 213] }, { 39: 214, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 215] }, { 39: 216, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 217] }, { 33: [1, 218] }, { 33: [1, 219] }, { 33: [1, 220] }, { 33: [1, 221] }, { 33: [1, 222] }, { 33: [1, 223] }, { 39: 224, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 225] }, { 33: [1, 226] }, { 33: [1, 227] }, { 39: 228, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 229] }, { 39: 230, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 231] }, { 33: [1, 232] }, { 33: [1, 233] }, { 39: 234, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 46]), o($V9, [2, 48]), o($V9, [2, 47]), o($V9, [2, 49]), o($V9, [2, 51]), o($V9, [2, 50]), o($V9, [2, 107]), o($V9, [2, 108]), o($V9, [2, 105]), o($V9, [2, 106]), o($V9, [2, 110]), o($V9, [2, 109]), o($V9, [2, 114]), o($V9, [2, 113]), o($V9, [2, 112]), o($V9, [2, 111]), o($V9, [2, 116]), o($V9, [2, 115]), o($V9, [2, 104]), o($V9, [2, 103]), o($V9, [2, 102]), o($V9, [2, 101]), o($V9, [2, 99]), o($V9, [2, 100]), o($V9, [2, 98]), o($V9, [2, 97]), o($V9, [2, 96]), o($V9, [2, 95]), o($V9, [2, 93]), o($V9, [2, 94])], + defaultActions: { 7: [2, 1], 13: [2, 2], 18: [2, 3], 36: [2, 4] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 19; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 21; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + return 13; + case 8: + break; + case 9: + break; + case 10: + return 5; + case 11: + return 40; + case 12: + return 32; + case 13: + return 38; + case 14: + return 42; + case 15: + return 43; + case 16: + return 44; + case 17: + return 45; + case 18: + return 35; + case 19: + return 28; + case 20: + return 29; + case 21: + return 37; + case 22: + return 31; + case 23: + return 34; + case 24: + return 26; + case 25: + return 9; + case 26: + return 9; + case 27: + return 8; + case 28: + return "CARET"; + case 29: + this.begin("options"); + break; + case 30: + this.popState(); + break; + case 31: + return 12; + case 32: + return 36; + case 33: + this.begin("string"); + break; + case 34: + this.popState(); + break; + case 35: + return 33; + case 36: + return 30; + case 37: + return 46; + case 38: + return 7; + } + }, + rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gitGraph\b)/i, /^(?:commit(?=\s|$))/i, /^(?:id:)/i, /^(?:type:)/i, /^(?:msg:)/i, /^(?:NORMAL\b)/i, /^(?:REVERSE\b)/i, /^(?:HIGHLIGHT\b)/i, /^(?:tag:)/i, /^(?:branch(?=\s|$))/i, /^(?:order:)/i, /^(?:merge(?=\s|$))/i, /^(?:cherry-pick(?=\s|$))/i, /^(?:parent:)/i, /^(?:checkout(?=\s|$))/i, /^(?:LR\b)/i, /^(?:TB\b)/i, /^(?::)/i, /^(?:\^)/i, /^(?:options\r?\n)/i, /^(?:[ \r\n\t]+end\b)/i, /^(?:[\s\S]+(?=[ \r\n\t]+end))/i, /^(?:["]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[0-9]+(?=\s|$))/i, /^(?:\w([-\./\w]*[-\w])?)/i, /^(?:$)/i, /^(?:\s+)/i], + conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "options": { "rules": [30, 31], "inclusive": false }, "string": { "rules": [34, 35], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 36, 37, 38, 39], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const gitGraphParser = parser; +let mainBranchName = getConfig().gitGraph.mainBranchName; +let mainBranchOrder = getConfig().gitGraph.mainBranchOrder; +let commits = {}; +let head = null; +let branchesConfig = {}; +branchesConfig[mainBranchName] = { name: mainBranchName, order: mainBranchOrder }; +let branches = {}; +branches[mainBranchName] = head; +let curBranch = mainBranchName; +let direction = "LR"; +let seq = 0; +function getId() { + return random({ length: 7 }); +} +function uniqBy(list, fn) { + const recordMap = /* @__PURE__ */ Object.create(null); + return list.reduce((out, item) => { + const key = fn(item); + if (!recordMap[key]) { + recordMap[key] = true; + out.push(item); + } + return out; + }, []); +} +const setDirection = function(dir2) { + direction = dir2; +}; +let options = {}; +const setOptions = function(rawOptString) { + log$1.debug("options str", rawOptString); + rawOptString = rawOptString && rawOptString.trim(); + rawOptString = rawOptString || "{}"; + try { + options = JSON.parse(rawOptString); + } catch (e) { + log$1.error("error while parsing gitGraph options", e.message); + } +}; +const getOptions = function() { + return options; +}; +const commit = function(msg, id, type, tag) { + log$1.debug("Entering commit:", msg, id, type, tag); + id = common$1.sanitizeText(id, getConfig()); + msg = common$1.sanitizeText(msg, getConfig()); + tag = common$1.sanitizeText(tag, getConfig()); + const commit2 = { + id: id ? id : seq + "-" + getId(), + message: msg, + seq: seq++, + type: type ? type : commitType$1.NORMAL, + tag: tag ? tag : "", + parents: head == null ? [] : [head.id], + branch: curBranch + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug("in pushCommit " + commit2.id); +}; +const branch = function(name, order) { + name = common$1.sanitizeText(name, getConfig()); + if (branches[name] === void 0) { + branches[name] = head != null ? head.id : null; + branchesConfig[name] = { name, order: order ? parseInt(order, 10) : null }; + checkout(name); + log$1.debug("in createBranch"); + } else { + let error = new Error( + 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ' + name + '")' + ); + error.hash = { + text: "branch " + name, + token: "branch " + name, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"checkout ' + name + '"'] + }; + throw error; + } +}; +const merge = function(otherBranch, custom_id, override_type, custom_tag) { + otherBranch = common$1.sanitizeText(otherBranch, getConfig()); + custom_id = common$1.sanitizeText(custom_id, getConfig()); + const currentCommit = commits[branches[curBranch]]; + const otherCommit = commits[branches[otherBranch]]; + if (curBranch === otherBranch) { + let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch abc"] + }; + throw error; + } else if (currentCommit === void 0 || !currentCommit) { + let error = new Error( + 'Incorrect usage of "merge". Current branch (' + curBranch + ")has no commits" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["commit"] + }; + throw error; + } else if (branches[otherBranch] === void 0) { + let error = new Error( + 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") does not exist" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch " + otherBranch] + }; + throw error; + } else if (otherCommit === void 0 || !otherCommit) { + let error = new Error( + 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") has no commits" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"commit"'] + }; + throw error; + } else if (currentCommit === otherCommit) { + let error = new Error('Incorrect usage of "merge". Both branches have same head'); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch abc"] + }; + throw error; + } else if (custom_id && commits[custom_id] !== void 0) { + let error = new Error( + 'Incorrect usage of "merge". Commit with id:' + custom_id + " already exists, use different custom Id" + ); + error.hash = { + text: "merge " + otherBranch + custom_id + override_type + custom_tag, + token: "merge " + otherBranch + custom_id + override_type + custom_tag, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: [ + "merge " + otherBranch + " " + custom_id + "_UNIQUE " + override_type + " " + custom_tag + ] + }; + throw error; + } + const commit2 = { + id: custom_id ? custom_id : seq + "-" + getId(), + message: "merged branch " + otherBranch + " into " + curBranch, + seq: seq++, + parents: [head == null ? null : head.id, branches[otherBranch]], + branch: curBranch, + type: commitType$1.MERGE, + customType: override_type, + customId: custom_id ? true : false, + tag: custom_tag ? custom_tag : "" + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug(branches); + log$1.debug("in mergeBranch"); +}; +const cherryPick = function(sourceId, targetId, tag, parentCommitId) { + log$1.debug("Entering cherryPick:", sourceId, targetId, tag); + sourceId = common$1.sanitizeText(sourceId, getConfig()); + targetId = common$1.sanitizeText(targetId, getConfig()); + tag = common$1.sanitizeText(tag, getConfig()); + parentCommitId = common$1.sanitizeText(parentCommitId, getConfig()); + if (!sourceId || commits[sourceId] === void 0) { + let error = new Error( + 'Incorrect usage of "cherryPick". Source commit id should exist and provided' + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + let sourceCommit = commits[sourceId]; + let sourceCommitBranch = sourceCommit.branch; + if (parentCommitId && !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) { + let error = new Error( + "Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit." + ); + throw error; + } + if (sourceCommit.type === commitType$1.MERGE && !parentCommitId) { + let error = new Error( + "Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified." + ); + throw error; + } + if (!targetId || commits[targetId] === void 0) { + if (sourceCommitBranch === curBranch) { + let error = new Error( + 'Incorrect usage of "cherryPick". Source commit is already on current branch' + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + const currentCommit = commits[branches[curBranch]]; + if (currentCommit === void 0 || !currentCommit) { + let error = new Error( + 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ")has no commits" + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + const commit2 = { + id: seq + "-" + getId(), + message: "cherry-picked " + sourceCommit + " into " + curBranch, + seq: seq++, + parents: [head == null ? null : head.id, sourceCommit.id], + branch: curBranch, + type: commitType$1.CHERRY_PICK, + tag: tag ?? `cherry-pick:${sourceCommit.id}${sourceCommit.type === commitType$1.MERGE ? `|parent:${parentCommitId}` : ""}` + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug(branches); + log$1.debug("in cherryPick"); + } +}; +const checkout = function(branch2) { + branch2 = common$1.sanitizeText(branch2, getConfig()); + if (branches[branch2] === void 0) { + let error = new Error( + 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch2 + '")' + ); + error.hash = { + text: "checkout " + branch2, + token: "checkout " + branch2, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"branch ' + branch2 + '"'] + }; + throw error; + } else { + curBranch = branch2; + const id = branches[curBranch]; + head = commits[id]; + } +}; +function upsert(arr, key, newVal) { + const index = arr.indexOf(key); + if (index === -1) { + arr.push(newVal); + } else { + arr.splice(index, 1, newVal); + } +} +function prettyPrintCommitHistory(commitArr) { + const commit2 = commitArr.reduce((out, commit3) => { + if (out.seq > commit3.seq) { + return out; + } + return commit3; + }, commitArr[0]); + let line = ""; + commitArr.forEach(function(c) { + if (c === commit2) { + line += " *"; + } else { + line += " |"; + } + }); + const label = [line, commit2.id, commit2.seq]; + for (let branch2 in branches) { + if (branches[branch2] === commit2.id) { + label.push(branch2); + } + } + log$1.debug(label.join(" ")); + if (commit2.parents && commit2.parents.length == 2) { + const newCommit = commits[commit2.parents[0]]; + upsert(commitArr, commit2, newCommit); + commitArr.push(commits[commit2.parents[1]]); + } else if (commit2.parents.length == 0) { + return; + } else { + const nextCommit = commits[commit2.parents]; + upsert(commitArr, commit2, nextCommit); + } + commitArr = uniqBy(commitArr, (c) => c.id); + prettyPrintCommitHistory(commitArr); +} +const prettyPrint = function() { + log$1.debug(commits); + const node = getCommitsArray()[0]; + prettyPrintCommitHistory([node]); +}; +const clear$1 = function() { + commits = {}; + head = null; + let mainBranch = getConfig().gitGraph.mainBranchName; + let mainBranchOrder2 = getConfig().gitGraph.mainBranchOrder; + branches = {}; + branches[mainBranch] = null; + branchesConfig = {}; + branchesConfig[mainBranch] = { name: mainBranch, order: mainBranchOrder2 }; + curBranch = mainBranch; + seq = 0; + clear$2(); +}; +const getBranchesAsObjArray = function() { + const branchesArray = Object.values(branchesConfig).map((branchConfig, i) => { + if (branchConfig.order !== null) { + return branchConfig; + } + return { + ...branchConfig, + order: parseFloat(`0.${i}`, 10) + }; + }).sort((a, b) => a.order - b.order).map(({ name }) => ({ name })); + return branchesArray; +}; +const getBranches = function() { + return branches; +}; +const getCommits = function() { + return commits; +}; +const getCommitsArray = function() { + const commitArr = Object.keys(commits).map(function(key) { + return commits[key]; + }); + commitArr.forEach(function(o) { + log$1.debug(o.id); + }); + commitArr.sort((a, b) => a.seq - b.seq); + return commitArr; +}; +const getCurrentBranch = function() { + return curBranch; +}; +const getDirection = function() { + return direction; +}; +const getHead = function() { + return head; +}; +const commitType$1 = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4 +}; +const gitGraphDb = { + getConfig: () => getConfig().gitGraph, + setDirection, + setOptions, + getOptions, + commit, + branch, + merge, + cherryPick, + checkout, + //reset, + prettyPrint, + clear: clear$1, + getBranchesAsObjArray, + getBranches, + getCommits, + getCommitsArray, + getCurrentBranch, + getDirection, + getHead, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + setDiagramTitle, + getDiagramTitle, + commitType: commitType$1 +}; +let allCommitsDict = {}; +const commitType = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4 +}; +const THEME_COLOR_LIMIT = 8; +let branchPos = {}; +let commitPos = {}; +let lanes = []; +let maxPos = 0; +let dir = "LR"; +const clear = () => { + branchPos = {}; + commitPos = {}; + allCommitsDict = {}; + maxPos = 0; + lanes = []; + dir = "LR"; +}; +const drawText = (txt) => { + const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text"); + let rows = []; + if (typeof txt === "string") { + rows = txt.split(/\\n|\n|/gi); + } else if (Array.isArray(txt)) { + rows = txt; + } else { + rows = []; + } + for (const row of rows) { + const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "0"); + tspan.setAttribute("class", "row"); + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + } + return svgLabel; +}; +const findClosestParent = (parents) => { + let closestParent = ""; + let maxPosition = 0; + parents.forEach((parent) => { + const parentPosition = dir === "TB" ? commitPos[parent].y : commitPos[parent].x; + if (parentPosition >= maxPosition) { + closestParent = parent; + maxPosition = parentPosition; + } + }); + return closestParent || void 0; +}; +const drawCommits = (svg, commits2, modifyGraph) => { + const gitGraphConfig = getConfig().gitGraph; + const gBullets = svg.append("g").attr("class", "commit-bullets"); + const gLabels = svg.append("g").attr("class", "commit-labels"); + let pos = 0; + if (dir === "TB") { + pos = 30; + } + const keys = Object.keys(commits2); + const sortedKeys = keys.sort((a, b) => { + return commits2[a].seq - commits2[b].seq; + }); + const isParallelCommits = gitGraphConfig.parallelCommits; + const layoutOffset = 10; + const commitStep = 40; + sortedKeys.forEach((key) => { + const commit2 = commits2[key]; + if (isParallelCommits) { + if (commit2.parents.length) { + const closestParent = findClosestParent(commit2.parents); + pos = dir === "TB" ? commitPos[closestParent].y + commitStep : commitPos[closestParent].x + commitStep; + } else { + pos = 0; + if (dir === "TB") { + pos = 30; + } + } + } + const posWithOffset = pos + layoutOffset; + const y = dir === "TB" ? posWithOffset : branchPos[commit2.branch].pos; + const x = dir === "TB" ? branchPos[commit2.branch].pos : posWithOffset; + if (modifyGraph) { + let typeClass; + let commitSymbolType = commit2.customType !== void 0 && commit2.customType !== "" ? commit2.customType : commit2.type; + switch (commitSymbolType) { + case commitType.NORMAL: + typeClass = "commit-normal"; + break; + case commitType.REVERSE: + typeClass = "commit-reverse"; + break; + case commitType.HIGHLIGHT: + typeClass = "commit-highlight"; + break; + case commitType.MERGE: + typeClass = "commit-merge"; + break; + case commitType.CHERRY_PICK: + typeClass = "commit-cherry-pick"; + break; + default: + typeClass = "commit-normal"; + } + if (commitSymbolType === commitType.HIGHLIGHT) { + const circle = gBullets.append("rect"); + circle.attr("x", x - 10); + circle.attr("y", y - 10); + circle.attr("height", 20); + circle.attr("width", 20); + circle.attr( + "class", + `commit ${commit2.id} commit-highlight${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-outer` + ); + gBullets.append("rect").attr("x", x - 6).attr("y", y - 6).attr("height", 12).attr("width", 12).attr( + "class", + `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-inner` + ); + } else if (commitSymbolType === commitType.CHERRY_PICK) { + gBullets.append("circle").attr("cx", x).attr("cy", y).attr("r", 10).attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("circle").attr("cx", x - 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("circle").attr("cx", x + 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("line").attr("x1", x + 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("line").attr("x1", x - 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + } else { + const circle = gBullets.append("circle"); + circle.attr("cx", x); + circle.attr("cy", y); + circle.attr("r", commit2.type === commitType.MERGE ? 9 : 10); + circle.attr( + "class", + `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + if (commitSymbolType === commitType.MERGE) { + const circle2 = gBullets.append("circle"); + circle2.attr("cx", x); + circle2.attr("cy", y); + circle2.attr("r", 6); + circle2.attr( + "class", + `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + } + if (commitSymbolType === commitType.REVERSE) { + const cross = gBullets.append("path"); + cross.attr("d", `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`).attr( + "class", + `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + } + } + } + if (dir === "TB") { + commitPos[commit2.id] = { x, y: posWithOffset }; + } else { + commitPos[commit2.id] = { x: posWithOffset, y }; + } + if (modifyGraph) { + const px = 4; + const py = 2; + if (commit2.type !== commitType.CHERRY_PICK && (commit2.customId && commit2.type === commitType.MERGE || commit2.type !== commitType.MERGE) && gitGraphConfig.showCommitLabel) { + const wrapper = gLabels.append("g"); + const labelBkg = wrapper.insert("rect").attr("class", "commit-label-bkg"); + const text = wrapper.append("text").attr("x", pos).attr("y", y + 25).attr("class", "commit-label").text(commit2.id); + let bbox = text.node().getBBox(); + labelBkg.attr("x", posWithOffset - bbox.width / 2 - py).attr("y", y + 13.5).attr("width", bbox.width + 2 * py).attr("height", bbox.height + 2 * py); + if (dir === "TB") { + labelBkg.attr("x", x - (bbox.width + 4 * px + 5)).attr("y", y - 12); + text.attr("x", x - (bbox.width + 4 * px)).attr("y", y + bbox.height - 12); + } + if (dir !== "TB") { + text.attr("x", posWithOffset - bbox.width / 2); + } + if (gitGraphConfig.rotateCommitLabel) { + if (dir === "TB") { + text.attr("transform", "rotate(-45, " + x + ", " + y + ")"); + labelBkg.attr("transform", "rotate(-45, " + x + ", " + y + ")"); + } else { + let r_x = -7.5 - (bbox.width + 10) / 25 * 9.5; + let r_y = 10 + bbox.width / 25 * 8.5; + wrapper.attr( + "transform", + "translate(" + r_x + ", " + r_y + ") rotate(-45, " + pos + ", " + y + ")" + ); + } + } + } + if (commit2.tag) { + const rect = gLabels.insert("polygon"); + const hole = gLabels.append("circle"); + const tag = gLabels.append("text").attr("y", y - 16).attr("class", "tag-label").text(commit2.tag); + let tagBbox = tag.node().getBBox(); + tag.attr("x", posWithOffset - tagBbox.width / 2); + const h2 = tagBbox.height / 2; + const ly = y - 19.2; + rect.attr("class", "tag-label-bkg").attr( + "points", + ` + ${pos - tagBbox.width / 2 - px / 2},${ly + py} + ${pos - tagBbox.width / 2 - px / 2},${ly - py} + ${posWithOffset - tagBbox.width / 2 - px},${ly - h2 - py} + ${posWithOffset + tagBbox.width / 2 + px},${ly - h2 - py} + ${posWithOffset + tagBbox.width / 2 + px},${ly + h2 + py} + ${posWithOffset - tagBbox.width / 2 - px},${ly + h2 + py}` + ); + hole.attr("cx", pos - tagBbox.width / 2 + px / 2).attr("cy", ly).attr("r", 1.5).attr("class", "tag-hole"); + if (dir === "TB") { + rect.attr("class", "tag-label-bkg").attr( + "points", + ` + ${x},${pos + py} + ${x},${pos - py} + ${x + layoutOffset},${pos - h2 - py} + ${x + layoutOffset + tagBbox.width + px},${pos - h2 - py} + ${x + layoutOffset + tagBbox.width + px},${pos + h2 + py} + ${x + layoutOffset},${pos + h2 + py}` + ).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")"); + hole.attr("cx", x + px / 2).attr("cy", pos).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")"); + tag.attr("x", x + 5).attr("y", pos + 3).attr("transform", "translate(14,14) rotate(45, " + x + "," + pos + ")"); + } + } + } + pos += commitStep + layoutOffset; + if (pos > maxPos) { + maxPos = pos; + } + }); +}; +const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => { + const commitBIsFurthest = dir === "TB" ? p1.x < p2.x : p1.y < p2.y; + const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch; + const isOnBranchToGetCurve = (x) => x.branch === branchToGetCurve; + const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq; + return Object.values(allCommits).some((commitX) => { + return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX); + }); +}; +const findLane = (y1, y2, depth = 0) => { + const candidate = y1 + Math.abs(y1 - y2) / 2; + if (depth > 5) { + return candidate; + } + let ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10); + if (ok) { + lanes.push(candidate); + return candidate; + } + const diff = Math.abs(y1 - y2); + return findLane(y1, y2 - diff / 5, depth + 1); +}; +const drawArrow = (svg, commitA, commitB, allCommits) => { + const p1 = commitPos[commitA.id]; + const p2 = commitPos[commitB.id]; + const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits); + let arc = ""; + let arc2 = ""; + let radius = 0; + let offset = 0; + let colorClassNum = branchPos[commitB.branch].index; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + colorClassNum = branchPos[commitA.branch].index; + } + let lineDef; + if (arrowNeedsRerouting) { + arc = "A 10 10, 0, 0, 0,"; + arc2 = "A 10 10, 0, 0, 1,"; + radius = 10; + offset = 10; + const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y); + const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x); + if (dir === "TB") { + if (p1.x < p2.x) { + lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + colorClassNum = branchPos[commitA.branch].index; + lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } else { + if (p1.y < p2.y) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`; + } else { + colorClassNum = branchPos[commitA.branch].index; + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`; + } + } + } else { + arc = "A 20 20, 0, 0, 0,"; + arc2 = "A 20 20, 0, 0, 1,"; + radius = 20; + offset = 20; + if (dir === "TB") { + if (p1.x < p2.x) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } + } + if (p1.x > p2.x) { + arc = "A 20 20, 0, 0, 0,"; + arc2 = "A 20 20, 0, 0, 1,"; + radius = 20; + offset = 20; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } + } + if (p1.x === p2.x) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } else { + if (p1.y < p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } + if (p1.y > p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } + if (p1.y === p2.y) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } + } + svg.append("path").attr("d", lineDef).attr("class", "arrow arrow" + colorClassNum % THEME_COLOR_LIMIT); +}; +const drawArrows = (svg, commits2) => { + const gArrows = svg.append("g").attr("class", "commit-arrows"); + Object.keys(commits2).forEach((key) => { + const commit2 = commits2[key]; + if (commit2.parents && commit2.parents.length > 0) { + commit2.parents.forEach((parent) => { + drawArrow(gArrows, commits2[parent], commit2, commits2); + }); + } + }); +}; +const drawBranches = (svg, branches2) => { + const gitGraphConfig = getConfig().gitGraph; + const g = svg.append("g"); + branches2.forEach((branch2, index) => { + const adjustIndexForTheme = index % THEME_COLOR_LIMIT; + const pos = branchPos[branch2.name].pos; + const line = g.append("line"); + line.attr("x1", 0); + line.attr("y1", pos); + line.attr("x2", maxPos); + line.attr("y2", pos); + line.attr("class", "branch branch" + adjustIndexForTheme); + if (dir === "TB") { + line.attr("y1", 30); + line.attr("x1", pos); + line.attr("y2", maxPos); + line.attr("x2", pos); + } + lanes.push(pos); + let name = branch2.name; + const labelElement = drawText(name); + const bkg = g.insert("rect"); + const branchLabel = g.insert("g").attr("class", "branchLabel"); + const label = branchLabel.insert("g").attr("class", "label branch-label" + adjustIndexForTheme); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + bkg.attr("class", "branchLabelBkg label" + adjustIndexForTheme).attr("rx", 4).attr("ry", 4).attr("x", -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)).attr("y", -bbox.height / 2 + 8).attr("width", bbox.width + 18).attr("height", bbox.height + 4); + label.attr( + "transform", + "translate(" + (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + ", " + (pos - bbox.height / 2 - 1) + ")" + ); + if (dir === "TB") { + bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", 0); + label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", 0)"); + } + if (dir !== "TB") { + bkg.attr("transform", "translate(-19, " + (pos - bbox.height / 2) + ")"); + } + }); +}; +const draw = function(txt, id, ver, diagObj) { + clear(); + const conf = getConfig(); + const gitGraphConfig = conf.gitGraph; + log$1.debug("in gitgraph renderer", txt + "\n", "id:", id, ver); + allCommitsDict = diagObj.db.getCommits(); + const branches2 = diagObj.db.getBranchesAsObjArray(); + dir = diagObj.db.getDirection(); + const diagram2 = select(`[id="${id}"]`); + let pos = 0; + branches2.forEach((branch2, index) => { + const labelElement = drawText(branch2.name); + const g = diagram2.append("g"); + const branchLabel = g.insert("g").attr("class", "branchLabel"); + const label = branchLabel.insert("g").attr("class", "label branch-label"); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + branchPos[branch2.name] = { pos, index }; + pos += 50 + (gitGraphConfig.rotateCommitLabel ? 40 : 0) + (dir === "TB" ? bbox.width / 2 : 0); + label.remove(); + branchLabel.remove(); + g.remove(); + }); + drawCommits(diagram2, allCommitsDict, false); + if (gitGraphConfig.showBranches) { + drawBranches(diagram2, branches2); + } + drawArrows(diagram2, allCommitsDict); + drawCommits(diagram2, allCommitsDict, true); + utils.insertTitle( + diagram2, + "gitTitleText", + gitGraphConfig.titleTopMargin, + diagObj.db.getDiagramTitle() + ); + setupGraphViewbox( + void 0, + diagram2, + gitGraphConfig.diagramPadding, + gitGraphConfig.useMaxWidth ?? conf.useMaxWidth + ); +}; +const gitGraphRenderer = { + draw +}; +const getStyles = (options2) => ` + .commit-id, + .commit-msg, + .branch-label { + fill: lightgrey; + color: lightgrey; + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + } + ${[0, 1, 2, 3, 4, 5, 6, 7].map( + (i) => ` + .branch-label${i} { fill: ${options2["gitBranchLabel" + i]}; } + .commit${i} { stroke: ${options2["git" + i]}; fill: ${options2["git" + i]}; } + .commit-highlight${i} { stroke: ${options2["gitInv" + i]}; fill: ${options2["gitInv" + i]}; } + .label${i} { fill: ${options2["git" + i]}; } + .arrow${i} { stroke: ${options2["git" + i]}; } + ` +).join("\n")} + + .branch { + stroke-width: 1; + stroke: ${options2.lineColor}; + stroke-dasharray: 2; + } + .commit-label { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelColor};} + .commit-label-bkg { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelBackground}; opacity: 0.5; } + .tag-label { font-size: ${options2.tagLabelFontSize}; fill: ${options2.tagLabelColor};} + .tag-label-bkg { fill: ${options2.tagLabelBackground}; stroke: ${options2.tagLabelBorder}; } + .tag-hole { fill: ${options2.textColor}; } + + .commit-merge { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + } + .commit-reverse { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + stroke-width: 3; + } + .commit-highlight-outer { + } + .commit-highlight-inner { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + } + + .arrow { stroke-width: 8; stroke-linecap: round; fill: none} + .gitTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options2.textColor}; + } +`; +const gitGraphStyles = getStyles; +const diagram = { + parser: gitGraphParser, + db: gitGraphDb, + renderer: gitGraphRenderer, + styles: gitGraphStyles +}; + +export { diagram }; diff --git a/libs/marked/graph-DadsyNmk.js b/libs/marked/graph-DadsyNmk.js new file mode 100644 index 0000000..a79dde5 --- /dev/null +++ b/libs/marked/graph-DadsyNmk.js @@ -0,0 +1,2759 @@ +import { aJ as isObjectLike, aK as baseGetTag, aL as Symbol, ag as isArray, af as isArrayLike, aM as arrayLikeKeys, aN as baseKeys, aO as memoize, aP as isArguments, aQ as copyObject, ad as keysIn, aR as getPrototype, aS as cloneArrayBuffer, aT as cloneTypedArray, aU as getTag, aV as nodeUtil, am as baseUnary, a8 as isObject, aW as copyArray, aX as isBuffer, aY as cloneBuffer, aZ as initCloneObject, a_ as Stack, al as assignValue, a$ as MapCache, ae as eq, b0 as Uint8Array, b1 as isTypedArray, b2 as isLength, ak as isIndex, aj as identity, ah as baseFor, b3 as Set, ab as baseRest, b4 as isArrayLikeObject, an as constant, z as isFunction, b5 as isEmpty } from './index-CN3YjQ0n.js'; + +/** `Object#toString` result references. */ +var symbolTag$3 = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag$3); +} + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +/** Used as references for various `Number` constants. */ +var INFINITY$2 = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$2 = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto$2 ? symbolProto$2.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$2) ? '-0' : result; +} + +/** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ +function noop() { + // No operation performed. +} + +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} + +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (-1); + + while ((++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ +function baseIsNaN(value) { + return value !== value; +} + +/** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); +} + +/** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ +function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; +} + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); +} + +/** Used as references for various `Number` constants. */ +var INFINITY$1 = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result; +} + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; +} + +/** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ +function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; +} + +/** Built-in value references. */ +var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; + +/** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenable(value) { + return isArray(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); +} + +/** + * The base implementation of `_.flatten` with support for restricting flattening. + * + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ +function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (predicate(value)) { + { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; +} + +/** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ +function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; +} + +/** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); +} + +/** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); +} + +/** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; +} + +/** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ +function stubArray() { + return []; +} + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$4.propertyIsEnumerable; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols$1 = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbols = !nativeGetSymbols$1 ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols$1(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); +}; + +/** + * Copies own symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own and inherited enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; +}; + +/** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); +} + +/** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); +} + +/** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); +} + +/** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); +} + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ +function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty$3.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; +} + +/** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ +function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); +} + +/** Used to match `RegExp` flags from their coerced string values. */ +var reFlags = /\w*$/; + +/** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ +function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; +} + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$1 = Symbol ? Symbol.prototype : undefined, + symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : undefined; + +/** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ +function cloneSymbol(symbol) { + return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {}; +} + +/** `Object#toString` result references. */ +var boolTag$2 = '[object Boolean]', + dateTag$2 = '[object Date]', + mapTag$3 = '[object Map]', + numberTag$2 = '[object Number]', + regexpTag$2 = '[object RegExp]', + setTag$3 = '[object Set]', + stringTag$2 = '[object String]', + symbolTag$2 = '[object Symbol]'; + +var arrayBufferTag$2 = '[object ArrayBuffer]', + dataViewTag$2 = '[object DataView]', + float32Tag$1 = '[object Float32Array]', + float64Tag$1 = '[object Float64Array]', + int8Tag$1 = '[object Int8Array]', + int16Tag$1 = '[object Int16Array]', + int32Tag$1 = '[object Int32Array]', + uint8Tag$1 = '[object Uint8Array]', + uint8ClampedTag$1 = '[object Uint8ClampedArray]', + uint16Tag$1 = '[object Uint16Array]', + uint32Tag$1 = '[object Uint32Array]'; + +/** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag$2: + return cloneArrayBuffer(object); + + case boolTag$2: + case dateTag$2: + return new Ctor(+object); + + case dataViewTag$2: + return cloneDataView(object, isDeep); + + case float32Tag$1: case float64Tag$1: + case int8Tag$1: case int16Tag$1: case int32Tag$1: + case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1: + return cloneTypedArray(object, isDeep); + + case mapTag$3: + return new Ctor; + + case numberTag$2: + case stringTag$2: + return new Ctor(object); + + case regexpTag$2: + return cloneRegExp(object); + + case setTag$3: + return new Ctor; + + case symbolTag$2: + return cloneSymbol(object); + } +} + +/** `Object#toString` result references. */ +var mapTag$2 = '[object Map]'; + +/** + * The base implementation of `_.isMap` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + */ +function baseIsMap(value) { + return isObjectLike(value) && getTag(value) == mapTag$2; +} + +/* Node.js helper references. */ +var nodeIsMap = nodeUtil && nodeUtil.isMap; + +/** + * Checks if `value` is classified as a `Map` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + * @example + * + * _.isMap(new Map); + * // => true + * + * _.isMap(new WeakMap); + * // => false + */ +var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; + +/** `Object#toString` result references. */ +var setTag$2 = '[object Set]'; + +/** + * The base implementation of `_.isSet` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ +function baseIsSet(value) { + return isObjectLike(value) && getTag(value) == setTag$2; +} + +/* Node.js helper references. */ +var nodeIsSet = nodeUtil && nodeUtil.isSet; + +/** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ +var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG = 1, + CLONE_FLAT_FLAG = 2, + CLONE_SYMBOLS_FLAG = 4; + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]', + arrayTag$1 = '[object Array]', + boolTag$1 = '[object Boolean]', + dateTag$1 = '[object Date]', + errorTag$1 = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag$1 = '[object Map]', + numberTag$1 = '[object Number]', + objectTag$1 = '[object Object]', + regexpTag$1 = '[object RegExp]', + setTag$1 = '[object Set]', + stringTag$1 = '[object String]', + symbolTag$1 = '[object Symbol]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag$1 = '[object ArrayBuffer]', + dataViewTag$1 = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values supported by `_.clone`. */ +var cloneableTags = {}; +cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = +cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = +cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = +cloneableTags[float32Tag] = cloneableTags[float64Tag] = +cloneableTags[int8Tag] = cloneableTags[int16Tag] = +cloneableTags[int32Tag] = cloneableTags[mapTag$1] = +cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = +cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = +cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = +cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = +cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; +cloneableTags[errorTag$1] = cloneableTags[funcTag] = +cloneableTags[weakMapTag] = false; + +/** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ +function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG; + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag$1 || tag == argsTag$1 || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + } else if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + } + + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; +} + +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} + +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } +} + +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; + +/** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} + +/** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function cacheHas(cache, key) { + return cache.has(key); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$5 = 1, + COMPARE_UNORDERED_FLAG$3 = 2; + +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; +} + +/** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ +function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} + +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$4 = 1, + COMPARE_UNORDERED_FLAG$2 = 2; + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + mapTag = '[object Map]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]'; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG$2; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$3 = 1; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty$2.call(other, key))) { + return false; + } + } + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$2 = 1; + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + objectTag = '[object Object]'; + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) { + var objIsWrapped = objIsObj && hasOwnProperty$1.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty$1.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +} + +/** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$1 = 1, + COMPARE_UNORDERED_FLAG$1 = 2; + +/** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + var result; + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) + : result + )) { + return false; + } + } + } + return true; +} + +/** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ +function isStrictComparable(value) { + return value === value && !isObject(value); +} + +/** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ +function getMatchData(object) { + var result = keys(object), + length = result.length; + + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } + return result; +} + +/** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; +} + +/** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; +} + +/** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHasIn(object, key) { + return object != null && key in Object(object); +} + +/** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ +function hasPath(object, path, hasFunc) { + path = castPath(path, object); + + var index = -1, + length = path.length, + result = false; + + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; + } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); +} + +/** + * Checks if `path` is a direct or inherited property of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false + */ +function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); + } + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; +} + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +/** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; +} + +/** + * Creates a function that returns the value at `path` of a given object. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + * @example + * + * var objects = [ + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } + * ]; + * + * _.map(objects, _.property('a.b')); + * // => [2, 1] + * + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); + * // => [1, 2] + */ +function property(path) { + return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); +} + +/** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ +function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); +} + +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); +} + +/** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = -1, + iterable = Object(collection); + + while ((++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; +} + +/** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ +var baseEach = createBaseEach(baseForOwn); + +/** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ +function castFunction(value) { + return typeof value == 'function' ? value : identity; +} + +/** + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight + * @example + * + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. + * + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +function forEach(collection, iteratee) { + var func = isArray(collection) ? arrayEach : baseEach; + return func(collection, castFunction(iteratee)); +} + +/** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; +} + +/** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.reject + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.filter(users, 'active'); + * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] + */ +function filter(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, baseIteratee(predicate)); +} + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHas(object, key) { + return object != null && hasOwnProperty.call(object, key); +} + +/** + * Checks if `path` is a direct property of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); + * // => false + */ +function has(object, path) { + return object != null && hasPath(object, path, baseHas); +} + +/** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ +function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; + }); +} + +/** + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ +function values(object) { + return object == null ? [] : baseValues(object, keys(object)); +} + +/** + * Checks if `value` is `undefined`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ +function isUndefined(value) { + return value === undefined; +} + +/** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ +function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; +} + +/** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `collection` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduceRight + * @example + * + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }, 0); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * return result; + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + */ +function reduce(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduce : baseReduce, + initAccum = arguments.length < 3; + + return func(collection, baseIteratee(iteratee), accumulator, initAccum, baseEach); +} + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ +var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); +}; + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ +function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (length >= LARGE_ARRAY_SIZE) { + var set = createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = result; + } + outer: + while (++index < length) { + var value = array[index], + computed = value; + + value = (value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; +} + +/** + * Creates an array of unique values, in order, from all given arrays using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([2], [1, 2]); + * // => [2, 1] + */ +var union = baseRest(function(arrays) { + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); +}); + +var DEFAULT_EDGE_NAME = '\x00'; +var GRAPH_NODE = '\x00'; +var EDGE_KEY_DELIM = '\x01'; + +// Implementation notes: +// +// * Node id query functions should return string ids for the nodes +// * Edge id query functions should return an "edgeObj", edge object, that is +// composed of enough information to uniquely identify an edge: {v, w, name}. +// * Internally we use an "edgeId", a stringified form of the edgeObj, to +// reference edges. This is because we need a performant way to look these +// edges up and, object properties, which have string keys, are the closest +// we're going to get to a performant hashtable in JavaScript. + +// Implementation notes: +// +// * Node id query functions should return string ids for the nodes +// * Edge id query functions should return an "edgeObj", edge object, that is +// composed of enough information to uniquely identify an edge: {v, w, name}. +// * Internally we use an "edgeId", a stringified form of the edgeObj, to +// reference edges. This is because we need a performant way to look these +// edges up and, object properties, which have string keys, are the closest +// we're going to get to a performant hashtable in JavaScript. +class Graph { + constructor(opts = {}) { + this._isDirected = has(opts, 'directed') ? opts.directed : true; + this._isMultigraph = has(opts, 'multigraph') ? opts.multigraph : false; + this._isCompound = has(opts, 'compound') ? opts.compound : false; + + // Label for the graph itself + this._label = undefined; + + // Defaults to be set when creating a new node + this._defaultNodeLabelFn = constant(undefined); + + // Defaults to be set when creating a new edge + this._defaultEdgeLabelFn = constant(undefined); + + // v -> label + this._nodes = {}; + + if (this._isCompound) { + // v -> parent + this._parent = {}; + + // v -> children + this._children = {}; + this._children[GRAPH_NODE] = {}; + } + + // v -> edgeObj + this._in = {}; + + // u -> v -> Number + this._preds = {}; + + // v -> edgeObj + this._out = {}; + + // v -> w -> Number + this._sucs = {}; + + // e -> edgeObj + this._edgeObjs = {}; + + // e -> label + this._edgeLabels = {}; + } + /* === Graph functions ========= */ + isDirected() { + return this._isDirected; + } + isMultigraph() { + return this._isMultigraph; + } + isCompound() { + return this._isCompound; + } + setGraph(label) { + this._label = label; + return this; + } + graph() { + return this._label; + } + /* === Node functions ========== */ + setDefaultNodeLabel(newDefault) { + if (!isFunction(newDefault)) { + newDefault = constant(newDefault); + } + this._defaultNodeLabelFn = newDefault; + return this; + } + nodeCount() { + return this._nodeCount; + } + nodes() { + return keys(this._nodes); + } + sources() { + var self = this; + return filter(this.nodes(), function (v) { + return isEmpty(self._in[v]); + }); + } + sinks() { + var self = this; + return filter(this.nodes(), function (v) { + return isEmpty(self._out[v]); + }); + } + setNodes(vs, value) { + var args = arguments; + var self = this; + forEach(vs, function (v) { + if (args.length > 1) { + self.setNode(v, value); + } else { + self.setNode(v); + } + }); + return this; + } + setNode(v, value) { + if (has(this._nodes, v)) { + if (arguments.length > 1) { + this._nodes[v] = value; + } + return this; + } + + // @ts-expect-error + this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v); + if (this._isCompound) { + this._parent[v] = GRAPH_NODE; + this._children[v] = {}; + this._children[GRAPH_NODE][v] = true; + } + this._in[v] = {}; + this._preds[v] = {}; + this._out[v] = {}; + this._sucs[v] = {}; + ++this._nodeCount; + return this; + } + node(v) { + return this._nodes[v]; + } + hasNode(v) { + return has(this._nodes, v); + } + removeNode(v) { + var self = this; + if (has(this._nodes, v)) { + var removeEdge = function (e) { + self.removeEdge(self._edgeObjs[e]); + }; + delete this._nodes[v]; + if (this._isCompound) { + this._removeFromParentsChildList(v); + delete this._parent[v]; + forEach(this.children(v), function (child) { + self.setParent(child); + }); + delete this._children[v]; + } + forEach(keys(this._in[v]), removeEdge); + delete this._in[v]; + delete this._preds[v]; + forEach(keys(this._out[v]), removeEdge); + delete this._out[v]; + delete this._sucs[v]; + --this._nodeCount; + } + return this; + } + setParent(v, parent) { + if (!this._isCompound) { + throw new Error('Cannot set parent in a non-compound graph'); + } + + if (isUndefined(parent)) { + parent = GRAPH_NODE; + } else { + // Coerce parent to string + parent += ''; + for (var ancestor = parent; !isUndefined(ancestor); ancestor = this.parent(ancestor)) { + if (ancestor === v) { + throw new Error('Setting ' + parent + ' as parent of ' + v + ' would create a cycle'); + } + } + + this.setNode(parent); + } + + this.setNode(v); + this._removeFromParentsChildList(v); + this._parent[v] = parent; + this._children[parent][v] = true; + return this; + } + _removeFromParentsChildList(v) { + delete this._children[this._parent[v]][v]; + } + parent(v) { + if (this._isCompound) { + var parent = this._parent[v]; + if (parent !== GRAPH_NODE) { + return parent; + } + } + } + children(v) { + if (isUndefined(v)) { + v = GRAPH_NODE; + } + + if (this._isCompound) { + var children = this._children[v]; + if (children) { + return keys(children); + } + } else if (v === GRAPH_NODE) { + return this.nodes(); + } else if (this.hasNode(v)) { + return []; + } + } + predecessors(v) { + var predsV = this._preds[v]; + if (predsV) { + return keys(predsV); + } + } + successors(v) { + var sucsV = this._sucs[v]; + if (sucsV) { + return keys(sucsV); + } + } + neighbors(v) { + var preds = this.predecessors(v); + if (preds) { + return union(preds, this.successors(v)); + } + } + isLeaf(v) { + var neighbors; + if (this.isDirected()) { + neighbors = this.successors(v); + } else { + neighbors = this.neighbors(v); + } + return neighbors.length === 0; + } + filterNodes(filter) { + // @ts-expect-error + var copy = new this.constructor({ + directed: this._isDirected, + multigraph: this._isMultigraph, + compound: this._isCompound, + }); + + copy.setGraph(this.graph()); + + var self = this; + forEach(this._nodes, function (value, v) { + if (filter(v)) { + copy.setNode(v, value); + } + }); + + forEach(this._edgeObjs, function (e) { + // @ts-expect-error + if (copy.hasNode(e.v) && copy.hasNode(e.w)) { + copy.setEdge(e, self.edge(e)); + } + }); + + var parents = {}; + function findParent(v) { + var parent = self.parent(v); + if (parent === undefined || copy.hasNode(parent)) { + parents[v] = parent; + return parent; + } else if (parent in parents) { + return parents[parent]; + } else { + return findParent(parent); + } + } + + if (this._isCompound) { + forEach(copy.nodes(), function (v) { + copy.setParent(v, findParent(v)); + }); + } + + return copy; + } + /* === Edge functions ========== */ + setDefaultEdgeLabel(newDefault) { + if (!isFunction(newDefault)) { + newDefault = constant(newDefault); + } + this._defaultEdgeLabelFn = newDefault; + return this; + } + edgeCount() { + return this._edgeCount; + } + edges() { + return values(this._edgeObjs); + } + setPath(vs, value) { + var self = this; + var args = arguments; + reduce(vs, function (v, w) { + if (args.length > 1) { + self.setEdge(v, w, value); + } else { + self.setEdge(v, w); + } + return w; + }); + return this; + } + /* + * setEdge(v, w, [value, [name]]) + * setEdge({ v, w, [name] }, [value]) + */ + setEdge() { + var v, w, name, value; + var valueSpecified = false; + var arg0 = arguments[0]; + + if (typeof arg0 === 'object' && arg0 !== null && 'v' in arg0) { + v = arg0.v; + w = arg0.w; + name = arg0.name; + if (arguments.length === 2) { + value = arguments[1]; + valueSpecified = true; + } + } else { + v = arg0; + w = arguments[1]; + name = arguments[3]; + if (arguments.length > 2) { + value = arguments[2]; + valueSpecified = true; + } + } + + v = '' + v; + w = '' + w; + if (!isUndefined(name)) { + name = '' + name; + } + + var e = edgeArgsToId(this._isDirected, v, w, name); + if (has(this._edgeLabels, e)) { + if (valueSpecified) { + this._edgeLabels[e] = value; + } + return this; + } + + if (!isUndefined(name) && !this._isMultigraph) { + throw new Error('Cannot set a named edge when isMultigraph = false'); + } + + // It didn't exist, so we need to create it. + // First ensure the nodes exist. + this.setNode(v); + this.setNode(w); + + // @ts-expect-error + this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name); + + var edgeObj = edgeArgsToObj(this._isDirected, v, w, name); + // Ensure we add undirected edges in a consistent way. + v = edgeObj.v; + w = edgeObj.w; + + Object.freeze(edgeObj); + this._edgeObjs[e] = edgeObj; + incrementOrInitEntry(this._preds[w], v); + incrementOrInitEntry(this._sucs[v], w); + this._in[w][e] = edgeObj; + this._out[v][e] = edgeObj; + this._edgeCount++; + return this; + } + edge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + return this._edgeLabels[e]; + } + hasEdge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + return has(this._edgeLabels, e); + } + removeEdge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + var edge = this._edgeObjs[e]; + if (edge) { + v = edge.v; + w = edge.w; + delete this._edgeLabels[e]; + delete this._edgeObjs[e]; + decrementOrRemoveEntry(this._preds[w], v); + decrementOrRemoveEntry(this._sucs[v], w); + delete this._in[w][e]; + delete this._out[v][e]; + this._edgeCount--; + } + return this; + } + inEdges(v, u) { + var inV = this._in[v]; + if (inV) { + var edges = values(inV); + if (!u) { + return edges; + } + return filter(edges, function (edge) { + return edge.v === u; + }); + } + } + outEdges(v, w) { + var outV = this._out[v]; + if (outV) { + var edges = values(outV); + if (!w) { + return edges; + } + return filter(edges, function (edge) { + return edge.w === w; + }); + } + } + nodeEdges(v, w) { + var inEdges = this.inEdges(v, w); + if (inEdges) { + return inEdges.concat(this.outEdges(v, w)); + } + } +} + +/* Number of nodes in the graph. Should only be changed by the implementation. */ +Graph.prototype._nodeCount = 0; + +/* Number of edges in the graph. Should only be changed by the implementation. */ +Graph.prototype._edgeCount = 0; + +function incrementOrInitEntry(map, k) { + if (map[k]) { + map[k]++; + } else { + map[k] = 1; + } +} + +function decrementOrRemoveEntry(map, k) { + if (!--map[k]) { + delete map[k]; + } +} + +function edgeArgsToId(isDirected, v_, w_, name) { + var v = '' + v_; + var w = '' + w_; + if (!isDirected && v > w) { + var tmp = v; + v = w; + w = tmp; + } + return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM + (isUndefined(name) ? DEFAULT_EDGE_NAME : name); +} + +function edgeArgsToObj(isDirected, v_, w_, name) { + var v = '' + v_; + var w = '' + w_; + if (!isDirected && v > w) { + var tmp = v; + v = w; + w = tmp; + } + var edgeObj = { v: v, w: w }; + if (name) { + edgeObj.name = name; + } + return edgeObj; +} + +function edgeObjToId(isDirected, edgeObj) { + return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name); +} + +export { Graph as G, isSymbol as a, baseFlatten as b, baseClone as c, baseIteratee as d, baseFindIndex as e, forEach as f, baseEach as g, has as h, isUndefined as i, arrayMap as j, keys as k, castFunction as l, baseForOwn as m, castPath as n, baseGet as o, hasIn as p, toString as q, filter as r, reduce as s, toKey as t, values as v }; diff --git a/libs/marked/graph-KZW2Npeo.js b/libs/marked/graph-KZW2Npeo.js new file mode 100644 index 0000000..d76e003 --- /dev/null +++ b/libs/marked/graph-KZW2Npeo.js @@ -0,0 +1,2759 @@ +import { aJ as isObjectLike, aK as baseGetTag, aL as Symbol, ag as isArray, af as isArrayLike, aM as arrayLikeKeys, aN as baseKeys, aO as memoize, aP as isArguments, aQ as copyObject, ad as keysIn, aR as getPrototype, aS as cloneArrayBuffer, aT as cloneTypedArray, aU as getTag, aV as nodeUtil, am as baseUnary, a8 as isObject, aW as copyArray, aX as isBuffer, aY as cloneBuffer, aZ as initCloneObject, a_ as Stack, al as assignValue, a$ as MapCache, ae as eq, b0 as Uint8Array, b1 as isTypedArray, b2 as isLength, ak as isIndex, aj as identity, ah as baseFor, b3 as Set, ab as baseRest, b4 as isArrayLikeObject, an as constant, z as isFunction, b5 as isEmpty } from './index-Bd_FDXSq.js'; + +/** `Object#toString` result references. */ +var symbolTag$3 = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag$3); +} + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +/** Used as references for various `Number` constants. */ +var INFINITY$2 = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$2 = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto$2 ? symbolProto$2.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$2) ? '-0' : result; +} + +/** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ +function noop() { + // No operation performed. +} + +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} + +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (-1); + + while ((++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ +function baseIsNaN(value) { + return value !== value; +} + +/** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); +} + +/** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ +function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; +} + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped(func) { + var result = memoize(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value, object) { + if (isArray(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString(value)); +} + +/** Used as references for various `Number` constants. */ +var INFINITY$1 = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result; +} + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; +} + +/** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ +function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; +} + +/** Built-in value references. */ +var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; + +/** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenable(value) { + return isArray(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); +} + +/** + * The base implementation of `_.flatten` with support for restricting flattening. + * + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ +function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (predicate(value)) { + { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; +} + +/** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ +function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; +} + +/** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); +} + +/** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); +} + +/** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; +} + +/** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ +function stubArray() { + return []; +} + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$4.propertyIsEnumerable; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols$1 = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbols = !nativeGetSymbols$1 ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols$1(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); +}; + +/** + * Copies own symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own and inherited enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; +}; + +/** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); +} + +/** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); +} + +/** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); +} + +/** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); +} + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ +function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty$3.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; +} + +/** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ +function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); +} + +/** Used to match `RegExp` flags from their coerced string values. */ +var reFlags = /\w*$/; + +/** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ +function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; +} + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$1 = Symbol ? Symbol.prototype : undefined, + symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : undefined; + +/** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ +function cloneSymbol(symbol) { + return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {}; +} + +/** `Object#toString` result references. */ +var boolTag$2 = '[object Boolean]', + dateTag$2 = '[object Date]', + mapTag$3 = '[object Map]', + numberTag$2 = '[object Number]', + regexpTag$2 = '[object RegExp]', + setTag$3 = '[object Set]', + stringTag$2 = '[object String]', + symbolTag$2 = '[object Symbol]'; + +var arrayBufferTag$2 = '[object ArrayBuffer]', + dataViewTag$2 = '[object DataView]', + float32Tag$1 = '[object Float32Array]', + float64Tag$1 = '[object Float64Array]', + int8Tag$1 = '[object Int8Array]', + int16Tag$1 = '[object Int16Array]', + int32Tag$1 = '[object Int32Array]', + uint8Tag$1 = '[object Uint8Array]', + uint8ClampedTag$1 = '[object Uint8ClampedArray]', + uint16Tag$1 = '[object Uint16Array]', + uint32Tag$1 = '[object Uint32Array]'; + +/** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag$2: + return cloneArrayBuffer(object); + + case boolTag$2: + case dateTag$2: + return new Ctor(+object); + + case dataViewTag$2: + return cloneDataView(object, isDeep); + + case float32Tag$1: case float64Tag$1: + case int8Tag$1: case int16Tag$1: case int32Tag$1: + case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1: + return cloneTypedArray(object, isDeep); + + case mapTag$3: + return new Ctor; + + case numberTag$2: + case stringTag$2: + return new Ctor(object); + + case regexpTag$2: + return cloneRegExp(object); + + case setTag$3: + return new Ctor; + + case symbolTag$2: + return cloneSymbol(object); + } +} + +/** `Object#toString` result references. */ +var mapTag$2 = '[object Map]'; + +/** + * The base implementation of `_.isMap` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + */ +function baseIsMap(value) { + return isObjectLike(value) && getTag(value) == mapTag$2; +} + +/* Node.js helper references. */ +var nodeIsMap = nodeUtil && nodeUtil.isMap; + +/** + * Checks if `value` is classified as a `Map` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + * @example + * + * _.isMap(new Map); + * // => true + * + * _.isMap(new WeakMap); + * // => false + */ +var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; + +/** `Object#toString` result references. */ +var setTag$2 = '[object Set]'; + +/** + * The base implementation of `_.isSet` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ +function baseIsSet(value) { + return isObjectLike(value) && getTag(value) == setTag$2; +} + +/* Node.js helper references. */ +var nodeIsSet = nodeUtil && nodeUtil.isSet; + +/** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ +var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG = 1, + CLONE_FLAT_FLAG = 2, + CLONE_SYMBOLS_FLAG = 4; + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]', + arrayTag$1 = '[object Array]', + boolTag$1 = '[object Boolean]', + dateTag$1 = '[object Date]', + errorTag$1 = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag$1 = '[object Map]', + numberTag$1 = '[object Number]', + objectTag$1 = '[object Object]', + regexpTag$1 = '[object RegExp]', + setTag$1 = '[object Set]', + stringTag$1 = '[object String]', + symbolTag$1 = '[object Symbol]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag$1 = '[object ArrayBuffer]', + dataViewTag$1 = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values supported by `_.clone`. */ +var cloneableTags = {}; +cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = +cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = +cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = +cloneableTags[float32Tag] = cloneableTags[float64Tag] = +cloneableTags[int8Tag] = cloneableTags[int16Tag] = +cloneableTags[int32Tag] = cloneableTags[mapTag$1] = +cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = +cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = +cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = +cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = +cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; +cloneableTags[errorTag$1] = cloneableTags[funcTag] = +cloneableTags[weakMapTag] = false; + +/** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ +function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG; + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag || tag == genTag; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag$1 || tag == argsTag$1 || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + } else if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + } + + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; +} + +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} + +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); + } +} + +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; + +/** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} + +/** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function cacheHas(cache, key) { + return cache.has(key); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$5 = 1, + COMPARE_UNORDERED_FLAG$3 = 2; + +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; +} + +/** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ +function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} + +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$4 = 1, + COMPARE_UNORDERED_FLAG$2 = 2; + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + mapTag = '[object Map]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]'; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG$2; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$3 = 1; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty$2.call(other, key))) { + return false; + } + } + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$2 = 1; + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + objectTag = '[object Object]'; + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) { + var objIsWrapped = objIsObj && hasOwnProperty$1.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty$1.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +} + +/** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$1 = 1, + COMPARE_UNORDERED_FLAG$1 = 2; + +/** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + var result; + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) + : result + )) { + return false; + } + } + } + return true; +} + +/** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ +function isStrictComparable(value) { + return value === value && !isObject(value); +} + +/** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ +function getMatchData(object) { + var result = keys(object), + length = result.length; + + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } + return result; +} + +/** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; +} + +/** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; +} + +/** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHasIn(object, key) { + return object != null && key in Object(object); +} + +/** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ +function hasPath(object, path, hasFunc) { + path = castPath(path, object); + + var index = -1, + length = path.length, + result = false; + + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; + } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); +} + +/** + * Checks if `path` is a direct or inherited property of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false + */ +function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); + } + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; +} + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +/** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; +} + +/** + * Creates a function that returns the value at `path` of a given object. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + * @example + * + * var objects = [ + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } + * ]; + * + * _.map(objects, _.property('a.b')); + * // => [2, 1] + * + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); + * // => [1, 2] + */ +function property(path) { + return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); +} + +/** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ +function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); +} + +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); +} + +/** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = -1, + iterable = Object(collection); + + while ((++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; +} + +/** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ +var baseEach = createBaseEach(baseForOwn); + +/** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ +function castFunction(value) { + return typeof value == 'function' ? value : identity; +} + +/** + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight + * @example + * + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. + * + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +function forEach(collection, iteratee) { + var func = isArray(collection) ? arrayEach : baseEach; + return func(collection, castFunction(iteratee)); +} + +/** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; +} + +/** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.reject + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.filter(users, 'active'); + * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] + */ +function filter(collection, predicate) { + var func = isArray(collection) ? arrayFilter : baseFilter; + return func(collection, baseIteratee(predicate)); +} + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHas(object, key) { + return object != null && hasOwnProperty.call(object, key); +} + +/** + * Checks if `path` is a direct property of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); + * // => false + */ +function has(object, path) { + return object != null && hasPath(object, path, baseHas); +} + +/** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ +function baseValues(object, props) { + return arrayMap(props, function(key) { + return object[key]; + }); +} + +/** + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ +function values(object) { + return object == null ? [] : baseValues(object, keys(object)); +} + +/** + * Checks if `value` is `undefined`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ +function isUndefined(value) { + return value === undefined; +} + +/** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ +function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; +} + +/** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `collection` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduceRight + * @example + * + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }, 0); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * return result; + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + */ +function reduce(collection, iteratee, accumulator) { + var func = isArray(collection) ? arrayReduce : baseReduce, + initAccum = arguments.length < 3; + + return func(collection, baseIteratee(iteratee), accumulator, initAccum, baseEach); +} + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ +var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { + return new Set(values); +}; + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ +function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (length >= LARGE_ARRAY_SIZE) { + var set = createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = result; + } + outer: + while (++index < length) { + var value = array[index], + computed = value; + + value = (value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; +} + +/** + * Creates an array of unique values, in order, from all given arrays using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([2], [1, 2]); + * // => [2, 1] + */ +var union = baseRest(function(arrays) { + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); +}); + +var DEFAULT_EDGE_NAME = '\x00'; +var GRAPH_NODE = '\x00'; +var EDGE_KEY_DELIM = '\x01'; + +// Implementation notes: +// +// * Node id query functions should return string ids for the nodes +// * Edge id query functions should return an "edgeObj", edge object, that is +// composed of enough information to uniquely identify an edge: {v, w, name}. +// * Internally we use an "edgeId", a stringified form of the edgeObj, to +// reference edges. This is because we need a performant way to look these +// edges up and, object properties, which have string keys, are the closest +// we're going to get to a performant hashtable in JavaScript. + +// Implementation notes: +// +// * Node id query functions should return string ids for the nodes +// * Edge id query functions should return an "edgeObj", edge object, that is +// composed of enough information to uniquely identify an edge: {v, w, name}. +// * Internally we use an "edgeId", a stringified form of the edgeObj, to +// reference edges. This is because we need a performant way to look these +// edges up and, object properties, which have string keys, are the closest +// we're going to get to a performant hashtable in JavaScript. +class Graph { + constructor(opts = {}) { + this._isDirected = has(opts, 'directed') ? opts.directed : true; + this._isMultigraph = has(opts, 'multigraph') ? opts.multigraph : false; + this._isCompound = has(opts, 'compound') ? opts.compound : false; + + // Label for the graph itself + this._label = undefined; + + // Defaults to be set when creating a new node + this._defaultNodeLabelFn = constant(undefined); + + // Defaults to be set when creating a new edge + this._defaultEdgeLabelFn = constant(undefined); + + // v -> label + this._nodes = {}; + + if (this._isCompound) { + // v -> parent + this._parent = {}; + + // v -> children + this._children = {}; + this._children[GRAPH_NODE] = {}; + } + + // v -> edgeObj + this._in = {}; + + // u -> v -> Number + this._preds = {}; + + // v -> edgeObj + this._out = {}; + + // v -> w -> Number + this._sucs = {}; + + // e -> edgeObj + this._edgeObjs = {}; + + // e -> label + this._edgeLabels = {}; + } + /* === Graph functions ========= */ + isDirected() { + return this._isDirected; + } + isMultigraph() { + return this._isMultigraph; + } + isCompound() { + return this._isCompound; + } + setGraph(label) { + this._label = label; + return this; + } + graph() { + return this._label; + } + /* === Node functions ========== */ + setDefaultNodeLabel(newDefault) { + if (!isFunction(newDefault)) { + newDefault = constant(newDefault); + } + this._defaultNodeLabelFn = newDefault; + return this; + } + nodeCount() { + return this._nodeCount; + } + nodes() { + return keys(this._nodes); + } + sources() { + var self = this; + return filter(this.nodes(), function (v) { + return isEmpty(self._in[v]); + }); + } + sinks() { + var self = this; + return filter(this.nodes(), function (v) { + return isEmpty(self._out[v]); + }); + } + setNodes(vs, value) { + var args = arguments; + var self = this; + forEach(vs, function (v) { + if (args.length > 1) { + self.setNode(v, value); + } else { + self.setNode(v); + } + }); + return this; + } + setNode(v, value) { + if (has(this._nodes, v)) { + if (arguments.length > 1) { + this._nodes[v] = value; + } + return this; + } + + // @ts-expect-error + this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v); + if (this._isCompound) { + this._parent[v] = GRAPH_NODE; + this._children[v] = {}; + this._children[GRAPH_NODE][v] = true; + } + this._in[v] = {}; + this._preds[v] = {}; + this._out[v] = {}; + this._sucs[v] = {}; + ++this._nodeCount; + return this; + } + node(v) { + return this._nodes[v]; + } + hasNode(v) { + return has(this._nodes, v); + } + removeNode(v) { + var self = this; + if (has(this._nodes, v)) { + var removeEdge = function (e) { + self.removeEdge(self._edgeObjs[e]); + }; + delete this._nodes[v]; + if (this._isCompound) { + this._removeFromParentsChildList(v); + delete this._parent[v]; + forEach(this.children(v), function (child) { + self.setParent(child); + }); + delete this._children[v]; + } + forEach(keys(this._in[v]), removeEdge); + delete this._in[v]; + delete this._preds[v]; + forEach(keys(this._out[v]), removeEdge); + delete this._out[v]; + delete this._sucs[v]; + --this._nodeCount; + } + return this; + } + setParent(v, parent) { + if (!this._isCompound) { + throw new Error('Cannot set parent in a non-compound graph'); + } + + if (isUndefined(parent)) { + parent = GRAPH_NODE; + } else { + // Coerce parent to string + parent += ''; + for (var ancestor = parent; !isUndefined(ancestor); ancestor = this.parent(ancestor)) { + if (ancestor === v) { + throw new Error('Setting ' + parent + ' as parent of ' + v + ' would create a cycle'); + } + } + + this.setNode(parent); + } + + this.setNode(v); + this._removeFromParentsChildList(v); + this._parent[v] = parent; + this._children[parent][v] = true; + return this; + } + _removeFromParentsChildList(v) { + delete this._children[this._parent[v]][v]; + } + parent(v) { + if (this._isCompound) { + var parent = this._parent[v]; + if (parent !== GRAPH_NODE) { + return parent; + } + } + } + children(v) { + if (isUndefined(v)) { + v = GRAPH_NODE; + } + + if (this._isCompound) { + var children = this._children[v]; + if (children) { + return keys(children); + } + } else if (v === GRAPH_NODE) { + return this.nodes(); + } else if (this.hasNode(v)) { + return []; + } + } + predecessors(v) { + var predsV = this._preds[v]; + if (predsV) { + return keys(predsV); + } + } + successors(v) { + var sucsV = this._sucs[v]; + if (sucsV) { + return keys(sucsV); + } + } + neighbors(v) { + var preds = this.predecessors(v); + if (preds) { + return union(preds, this.successors(v)); + } + } + isLeaf(v) { + var neighbors; + if (this.isDirected()) { + neighbors = this.successors(v); + } else { + neighbors = this.neighbors(v); + } + return neighbors.length === 0; + } + filterNodes(filter) { + // @ts-expect-error + var copy = new this.constructor({ + directed: this._isDirected, + multigraph: this._isMultigraph, + compound: this._isCompound, + }); + + copy.setGraph(this.graph()); + + var self = this; + forEach(this._nodes, function (value, v) { + if (filter(v)) { + copy.setNode(v, value); + } + }); + + forEach(this._edgeObjs, function (e) { + // @ts-expect-error + if (copy.hasNode(e.v) && copy.hasNode(e.w)) { + copy.setEdge(e, self.edge(e)); + } + }); + + var parents = {}; + function findParent(v) { + var parent = self.parent(v); + if (parent === undefined || copy.hasNode(parent)) { + parents[v] = parent; + return parent; + } else if (parent in parents) { + return parents[parent]; + } else { + return findParent(parent); + } + } + + if (this._isCompound) { + forEach(copy.nodes(), function (v) { + copy.setParent(v, findParent(v)); + }); + } + + return copy; + } + /* === Edge functions ========== */ + setDefaultEdgeLabel(newDefault) { + if (!isFunction(newDefault)) { + newDefault = constant(newDefault); + } + this._defaultEdgeLabelFn = newDefault; + return this; + } + edgeCount() { + return this._edgeCount; + } + edges() { + return values(this._edgeObjs); + } + setPath(vs, value) { + var self = this; + var args = arguments; + reduce(vs, function (v, w) { + if (args.length > 1) { + self.setEdge(v, w, value); + } else { + self.setEdge(v, w); + } + return w; + }); + return this; + } + /* + * setEdge(v, w, [value, [name]]) + * setEdge({ v, w, [name] }, [value]) + */ + setEdge() { + var v, w, name, value; + var valueSpecified = false; + var arg0 = arguments[0]; + + if (typeof arg0 === 'object' && arg0 !== null && 'v' in arg0) { + v = arg0.v; + w = arg0.w; + name = arg0.name; + if (arguments.length === 2) { + value = arguments[1]; + valueSpecified = true; + } + } else { + v = arg0; + w = arguments[1]; + name = arguments[3]; + if (arguments.length > 2) { + value = arguments[2]; + valueSpecified = true; + } + } + + v = '' + v; + w = '' + w; + if (!isUndefined(name)) { + name = '' + name; + } + + var e = edgeArgsToId(this._isDirected, v, w, name); + if (has(this._edgeLabels, e)) { + if (valueSpecified) { + this._edgeLabels[e] = value; + } + return this; + } + + if (!isUndefined(name) && !this._isMultigraph) { + throw new Error('Cannot set a named edge when isMultigraph = false'); + } + + // It didn't exist, so we need to create it. + // First ensure the nodes exist. + this.setNode(v); + this.setNode(w); + + // @ts-expect-error + this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name); + + var edgeObj = edgeArgsToObj(this._isDirected, v, w, name); + // Ensure we add undirected edges in a consistent way. + v = edgeObj.v; + w = edgeObj.w; + + Object.freeze(edgeObj); + this._edgeObjs[e] = edgeObj; + incrementOrInitEntry(this._preds[w], v); + incrementOrInitEntry(this._sucs[v], w); + this._in[w][e] = edgeObj; + this._out[v][e] = edgeObj; + this._edgeCount++; + return this; + } + edge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + return this._edgeLabels[e]; + } + hasEdge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + return has(this._edgeLabels, e); + } + removeEdge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + var edge = this._edgeObjs[e]; + if (edge) { + v = edge.v; + w = edge.w; + delete this._edgeLabels[e]; + delete this._edgeObjs[e]; + decrementOrRemoveEntry(this._preds[w], v); + decrementOrRemoveEntry(this._sucs[v], w); + delete this._in[w][e]; + delete this._out[v][e]; + this._edgeCount--; + } + return this; + } + inEdges(v, u) { + var inV = this._in[v]; + if (inV) { + var edges = values(inV); + if (!u) { + return edges; + } + return filter(edges, function (edge) { + return edge.v === u; + }); + } + } + outEdges(v, w) { + var outV = this._out[v]; + if (outV) { + var edges = values(outV); + if (!w) { + return edges; + } + return filter(edges, function (edge) { + return edge.w === w; + }); + } + } + nodeEdges(v, w) { + var inEdges = this.inEdges(v, w); + if (inEdges) { + return inEdges.concat(this.outEdges(v, w)); + } + } +} + +/* Number of nodes in the graph. Should only be changed by the implementation. */ +Graph.prototype._nodeCount = 0; + +/* Number of edges in the graph. Should only be changed by the implementation. */ +Graph.prototype._edgeCount = 0; + +function incrementOrInitEntry(map, k) { + if (map[k]) { + map[k]++; + } else { + map[k] = 1; + } +} + +function decrementOrRemoveEntry(map, k) { + if (!--map[k]) { + delete map[k]; + } +} + +function edgeArgsToId(isDirected, v_, w_, name) { + var v = '' + v_; + var w = '' + w_; + if (!isDirected && v > w) { + var tmp = v; + v = w; + w = tmp; + } + return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM + (isUndefined(name) ? DEFAULT_EDGE_NAME : name); +} + +function edgeArgsToObj(isDirected, v_, w_, name) { + var v = '' + v_; + var w = '' + w_; + if (!isDirected && v > w) { + var tmp = v; + v = w; + w = tmp; + } + var edgeObj = { v: v, w: w }; + if (name) { + edgeObj.name = name; + } + return edgeObj; +} + +function edgeObjToId(isDirected, edgeObj) { + return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name); +} + +export { Graph as G, isSymbol as a, baseFlatten as b, baseClone as c, baseIteratee as d, baseFindIndex as e, forEach as f, baseEach as g, has as h, isUndefined as i, arrayMap as j, keys as k, castFunction as l, baseForOwn as m, castPath as n, baseGet as o, hasIn as p, toString as q, filter as r, reduce as s, toKey as t, values as v }; diff --git a/libs/marked/index-01f381cb-BCBEZMaa.js b/libs/marked/index-01f381cb-BCBEZMaa.js new file mode 100644 index 0000000..fca1f0f --- /dev/null +++ b/libs/marked/index-01f381cb-BCBEZMaa.js @@ -0,0 +1,666 @@ +import { i as isUndefined, G as Graph } from './graph-KZW2Npeo.js'; +import { m as map, l as layout } from './layout-BnytXFfq.js'; +import { c as clone } from './clone-B-QllgkM.js'; +import { i as insertMarkers$1, u as updateNodeBounds, s as setNodeElem, a as insertNode, b as insertEdgeLabel, g as getSubGraphTitleMargins, p as positionNode, c as insertEdge, d as positionEdgeLabel, e as clear$1$1, f as clear$2, h as createLabel$1, j as intersectRect$1 } from './edges-066a5561-Bqw9g7uz.js'; +import { l as log$1, c as getConfig, p as evaluate, h as select } from './index-Bd_FDXSq.js'; +import { a as createText } from './createText-ca0c5216-B9KlDTE8.js'; + +function write(g) { + var json = { + options: { + directed: g.isDirected(), + multigraph: g.isMultigraph(), + compound: g.isCompound(), + }, + nodes: writeNodes(g), + edges: writeEdges(g), + }; + if (!isUndefined(g.graph())) { + json.value = clone(g.graph()); + } + return json; +} + +function writeNodes(g) { + return map(g.nodes(), function (v) { + var nodeValue = g.node(v); + var parent = g.parent(v); + var node = { v: v }; + if (!isUndefined(nodeValue)) { + node.value = nodeValue; + } + if (!isUndefined(parent)) { + node.parent = parent; + } + return node; + }); +} + +function writeEdges(g) { + return map(g.edges(), function (e) { + var edgeValue = g.edge(e); + var edge = { v: e.v, w: e.w }; + if (!isUndefined(e.name)) { + edge.name = e.name; + } + if (!isUndefined(edgeValue)) { + edge.value = edgeValue; + } + return edge; + }); +} + +let clusterDb = {}; +let descendants = {}; +let parents = {}; +const clear$1 = () => { + descendants = {}; + parents = {}; + clusterDb = {}; +}; +const isDescendant = (id, ancestorId) => { + log$1.trace("In isDescendant", ancestorId, " ", id, " = ", descendants[ancestorId].includes(id)); + if (descendants[ancestorId].includes(id)) { + return true; + } + return false; +}; +const edgeInCluster = (edge, clusterId) => { + log$1.info("Descendants of ", clusterId, " is ", descendants[clusterId]); + log$1.info("Edge is ", edge); + if (edge.v === clusterId) { + return false; + } + if (edge.w === clusterId) { + return false; + } + if (!descendants[clusterId]) { + log$1.debug("Tilt, ", clusterId, ",not in descendants"); + return false; + } + return descendants[clusterId].includes(edge.v) || isDescendant(edge.v, clusterId) || isDescendant(edge.w, clusterId) || descendants[clusterId].includes(edge.w); +}; +const copy = (clusterId, graph, newGraph, rootId) => { + log$1.warn( + "Copying children of ", + clusterId, + "root", + rootId, + "data", + graph.node(clusterId), + rootId + ); + const nodes = graph.children(clusterId) || []; + if (clusterId !== rootId) { + nodes.push(clusterId); + } + log$1.warn("Copying (nodes) clusterId", clusterId, "nodes", nodes); + nodes.forEach((node) => { + if (graph.children(node).length > 0) { + copy(node, graph, newGraph, rootId); + } else { + const data = graph.node(node); + log$1.info("cp ", node, " to ", rootId, " with parent ", clusterId); + newGraph.setNode(node, data); + if (rootId !== graph.parent(node)) { + log$1.warn("Setting parent", node, graph.parent(node)); + newGraph.setParent(node, graph.parent(node)); + } + if (clusterId !== rootId && node !== clusterId) { + log$1.debug("Setting parent", node, clusterId); + newGraph.setParent(node, clusterId); + } else { + log$1.info("In copy ", clusterId, "root", rootId, "data", graph.node(clusterId), rootId); + log$1.debug( + "Not Setting parent for node=", + node, + "cluster!==rootId", + clusterId !== rootId, + "node!==clusterId", + node !== clusterId + ); + } + const edges = graph.edges(node); + log$1.debug("Copying Edges", edges); + edges.forEach((edge) => { + log$1.info("Edge", edge); + const data2 = graph.edge(edge.v, edge.w, edge.name); + log$1.info("Edge data", data2, rootId); + try { + if (edgeInCluster(edge, rootId)) { + log$1.info("Copying as ", edge.v, edge.w, data2, edge.name); + newGraph.setEdge(edge.v, edge.w, data2, edge.name); + log$1.info("newGraph edges ", newGraph.edges(), newGraph.edge(newGraph.edges()[0])); + } else { + log$1.info( + "Skipping copy of edge ", + edge.v, + "-->", + edge.w, + " rootId: ", + rootId, + " clusterId:", + clusterId + ); + } + } catch (e) { + log$1.error(e); + } + }); + } + log$1.debug("Removing node", node); + graph.removeNode(node); + }); +}; +const extractDescendants = (id, graph) => { + const children = graph.children(id); + let res = [...children]; + for (const child of children) { + parents[child] = id; + res = [...res, ...extractDescendants(child, graph)]; + } + return res; +}; +const findNonClusterChild = (id, graph) => { + log$1.trace("Searching", id); + const children = graph.children(id); + log$1.trace("Searching children of id ", id, children); + if (children.length < 1) { + log$1.trace("This is a valid node", id); + return id; + } + for (const child of children) { + const _id = findNonClusterChild(child, graph); + if (_id) { + log$1.trace("Found replacement for", id, " => ", _id); + return _id; + } + } +}; +const getAnchorId = (id) => { + if (!clusterDb[id]) { + return id; + } + if (!clusterDb[id].externalConnections) { + return id; + } + if (clusterDb[id]) { + return clusterDb[id].id; + } + return id; +}; +const adjustClustersAndEdges = (graph, depth) => { + if (!graph || depth > 10) { + log$1.debug("Opting out, no graph "); + return; + } else { + log$1.debug("Opting in, graph "); + } + graph.nodes().forEach(function(id) { + const children = graph.children(id); + if (children.length > 0) { + log$1.warn( + "Cluster identified", + id, + " Replacement id in edges: ", + findNonClusterChild(id, graph) + ); + descendants[id] = extractDescendants(id, graph); + clusterDb[id] = { id: findNonClusterChild(id, graph), clusterData: graph.node(id) }; + } + }); + graph.nodes().forEach(function(id) { + const children = graph.children(id); + const edges = graph.edges(); + if (children.length > 0) { + log$1.debug("Cluster identified", id, descendants); + edges.forEach((edge) => { + if (edge.v !== id && edge.w !== id) { + const d1 = isDescendant(edge.v, id); + const d2 = isDescendant(edge.w, id); + if (d1 ^ d2) { + log$1.warn("Edge: ", edge, " leaves cluster ", id); + log$1.warn("Descendants of XXX ", id, ": ", descendants[id]); + clusterDb[id].externalConnections = true; + } + } + }); + } else { + log$1.debug("Not a cluster ", id, descendants); + } + }); + for (let id of Object.keys(clusterDb)) { + const nonClusterChild = clusterDb[id].id; + const parent = graph.parent(nonClusterChild); + if (parent !== id && clusterDb[parent] && !clusterDb[parent].externalConnections) { + clusterDb[id].id = parent; + } + } + graph.edges().forEach(function(e) { + const edge = graph.edge(e); + log$1.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + log$1.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e))); + let v = e.v; + let w = e.w; + log$1.warn( + "Fix XXX", + clusterDb, + "ids:", + e.v, + e.w, + "Translating: ", + clusterDb[e.v], + " --- ", + clusterDb[e.w] + ); + if (clusterDb[e.v] && clusterDb[e.w] && clusterDb[e.v] === clusterDb[e.w]) { + log$1.warn("Fixing and trixing link to self - removing XXX", e.v, e.w, e.name); + log$1.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name); + v = getAnchorId(e.v); + w = getAnchorId(e.w); + graph.removeEdge(e.v, e.w, e.name); + const specialId = e.w + "---" + e.v; + graph.setNode(specialId, { + domId: specialId, + id: specialId, + labelStyle: "", + labelText: edge.label, + padding: 0, + shape: "labelRect", + style: "" + }); + const edge1 = structuredClone(edge); + const edge2 = structuredClone(edge); + edge1.label = ""; + edge1.arrowTypeEnd = "none"; + edge2.label = ""; + edge1.fromCluster = e.v; + edge2.toCluster = e.v; + graph.setEdge(v, specialId, edge1, e.name + "-cyclic-special"); + graph.setEdge(specialId, w, edge2, e.name + "-cyclic-special"); + } else if (clusterDb[e.v] || clusterDb[e.w]) { + log$1.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name); + v = getAnchorId(e.v); + w = getAnchorId(e.w); + graph.removeEdge(e.v, e.w, e.name); + if (v !== e.v) { + const parent = graph.parent(v); + clusterDb[parent].externalConnections = true; + edge.fromCluster = e.v; + } + if (w !== e.w) { + const parent = graph.parent(w); + clusterDb[parent].externalConnections = true; + edge.toCluster = e.w; + } + log$1.warn("Fix Replacing with XXX", v, w, e.name); + graph.setEdge(v, w, edge, e.name); + } + }); + log$1.warn("Adjusted Graph", write(graph)); + extractor(graph, 0); + log$1.trace(clusterDb); +}; +const extractor = (graph, depth) => { + log$1.warn("extractor - ", depth, write(graph), graph.children("D")); + if (depth > 10) { + log$1.error("Bailing out"); + return; + } + let nodes = graph.nodes(); + let hasChildren = false; + for (const node of nodes) { + const children = graph.children(node); + hasChildren = hasChildren || children.length > 0; + } + if (!hasChildren) { + log$1.debug("Done, no node has children", graph.nodes()); + return; + } + log$1.debug("Nodes = ", nodes, depth); + for (const node of nodes) { + log$1.debug( + "Extracting node", + node, + clusterDb, + clusterDb[node] && !clusterDb[node].externalConnections, + !graph.parent(node), + graph.node(node), + graph.children("D"), + " Depth ", + depth + ); + if (!clusterDb[node]) { + log$1.debug("Not a cluster", node, depth); + } else if (!clusterDb[node].externalConnections && // !graph.parent(node) && + graph.children(node) && graph.children(node).length > 0) { + log$1.warn( + "Cluster without external connections, without a parent and with children", + node, + depth + ); + const graphSettings = graph.graph(); + let dir = graphSettings.rankdir === "TB" ? "LR" : "TB"; + if (clusterDb[node] && clusterDb[node].clusterData && clusterDb[node].clusterData.dir) { + dir = clusterDb[node].clusterData.dir; + log$1.warn("Fixing dir", clusterDb[node].clusterData.dir, dir); + } + const clusterGraph = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + // Todo: set proper spacing + nodesep: 50, + ranksep: 50, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + log$1.warn("Old graph before copy", write(graph)); + copy(node, graph, clusterGraph, node); + graph.setNode(node, { + clusterNode: true, + id: node, + clusterData: clusterDb[node].clusterData, + labelText: clusterDb[node].labelText, + graph: clusterGraph + }); + log$1.warn("New graph after copy node: (", node, ")", write(clusterGraph)); + log$1.debug("Old graph after copy", write(graph)); + } else { + log$1.warn( + "Cluster ** ", + node, + " **not meeting the criteria !externalConnections:", + !clusterDb[node].externalConnections, + " no parent: ", + !graph.parent(node), + " children ", + graph.children(node) && graph.children(node).length > 0, + graph.children("D"), + depth + ); + log$1.debug(clusterDb); + } + } + nodes = graph.nodes(); + log$1.warn("New list of nodes", nodes); + for (const node of nodes) { + const data = graph.node(node); + log$1.warn(" Now next level", node, data); + if (data.clusterNode) { + extractor(data.graph, depth + 1); + } + } +}; +const sorter = (graph, nodes) => { + if (nodes.length === 0) { + return []; + } + let result = Object.assign(nodes); + nodes.forEach((node) => { + const children = graph.children(node); + const sorted = sorter(graph, children); + result = [...result, ...sorted]; + }); + return result; +}; +const sortNodesByHierarchy = (graph) => sorter(graph, graph.children()); +const rect = (parent, node) => { + log$1.info("Creating subgraph rect for ", node.id, node); + const siteConfig = getConfig(); + const shapeSvg = parent.insert("g").attr("class", "cluster" + (node.class ? " " + node.class : "")).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const useHtmlLabels = evaluate(siteConfig.flowchart.htmlLabels); + const label = shapeSvg.insert("g").attr("class", "cluster-label"); + const text = node.labelType === "markdown" ? createText(label, node.labelText, { style: node.labelStyle, useHtmlLabels }) : label.node().appendChild(createLabel$1(node.labelText, node.labelStyle, void 0, true)); + let bbox = text.getBBox(); + if (evaluate(siteConfig.flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + const padding = 0 * node.padding; + const halfPadding = padding / 2; + const width = node.width <= bbox.width + padding ? bbox.width + padding : node.width; + if (node.width <= bbox.width + padding) { + node.diff = (bbox.width - node.width) / 2 - node.padding / 2; + } else { + node.diff = -node.padding / 2; + } + log$1.trace("Data ", node, JSON.stringify(node)); + rect2.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", node.x - width / 2).attr("y", node.y - node.height / 2 - halfPadding).attr("width", width).attr("height", node.height + padding); + const { subGraphTitleTopMargin } = getSubGraphTitleMargins(siteConfig); + if (useHtmlLabels) { + label.attr( + "transform", + // This puts the label on top of the box instead of inside it + `translate(${node.x - bbox.width / 2}, ${node.y - node.height / 2 + subGraphTitleTopMargin})` + ); + } else { + label.attr( + "transform", + // This puts the label on top of the box instead of inside it + `translate(${node.x}, ${node.y - node.height / 2 + subGraphTitleTopMargin})` + ); + } + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const noteGroup = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "note-cluster").attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + rect2.attr("rx", node.rx).attr("ry", node.ry).attr("x", node.x - node.width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding).attr("width", node.width + padding).attr("height", node.height + padding).attr("fill", "none"); + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const roundedWithTitle = (parent, node) => { + const siteConfig = getConfig(); + const shapeSvg = parent.insert("g").attr("class", node.classes).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const label = shapeSvg.insert("g").attr("class", "cluster-label"); + const innerRect = shapeSvg.append("rect"); + const text = label.node().appendChild(createLabel$1(node.labelText, node.labelStyle, void 0, true)); + let bbox = text.getBBox(); + if (evaluate(siteConfig.flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + bbox = text.getBBox(); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + const width = node.width <= bbox.width + node.padding ? bbox.width + node.padding : node.width; + if (node.width <= bbox.width + node.padding) { + node.diff = (bbox.width + node.padding * 0 - node.width) / 2; + } else { + node.diff = -node.padding / 2; + } + rect2.attr("class", "outer").attr("x", node.x - width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding).attr("width", width + padding).attr("height", node.height + padding); + innerRect.attr("class", "inner").attr("x", node.x - width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding + bbox.height - 1).attr("width", width + padding).attr("height", node.height + padding - bbox.height - 3); + const { subGraphTitleTopMargin } = getSubGraphTitleMargins(siteConfig); + label.attr( + "transform", + `translate(${node.x - bbox.width / 2}, ${node.y - node.height / 2 - node.padding / 3 + (evaluate(siteConfig.flowchart.htmlLabels) ? 5 : 3) + subGraphTitleTopMargin})` + ); + const rectBox = rect2.node().getBBox(); + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const divider = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", node.classes).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + rect2.attr("class", "divider").attr("x", node.x - node.width / 2 - halfPadding).attr("y", node.y - node.height / 2).attr("width", node.width + padding).attr("height", node.height + padding); + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.diff = -node.padding / 2; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const shapes = { rect, roundedWithTitle, noteGroup, divider }; +let clusterElems = {}; +const insertCluster = (elem, node) => { + log$1.trace("Inserting cluster"); + const shape = node.shape || "rect"; + clusterElems[node.id] = shapes[shape](elem, node); +}; +const clear = () => { + clusterElems = {}; +}; +const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, siteConfig) => { + log$1.info("Graph in recursive render: XXX", write(graph), parentCluster); + const dir = graph.graph().rankdir; + log$1.trace("Dir in recursive render - dir:", dir); + const elem = _elem.insert("g").attr("class", "root"); + if (!graph.nodes()) { + log$1.info("No nodes found for", graph); + } else { + log$1.info("Recursive render XXX", graph.nodes()); + } + if (graph.edges().length > 0) { + log$1.trace("Recursive edges", graph.edge(graph.edges()[0])); + } + const clusters = elem.insert("g").attr("class", "clusters"); + const edgePaths = elem.insert("g").attr("class", "edgePaths"); + const edgeLabels = elem.insert("g").attr("class", "edgeLabels"); + const nodes = elem.insert("g").attr("class", "nodes"); + await Promise.all( + graph.nodes().map(async function(v) { + const node = graph.node(v); + if (parentCluster !== void 0) { + const data = JSON.parse(JSON.stringify(parentCluster.clusterData)); + log$1.info("Setting data for cluster XXX (", v, ") ", data, parentCluster); + graph.setNode(parentCluster.id, data); + if (!graph.parent(v)) { + log$1.trace("Setting parent", v, parentCluster.id); + graph.setParent(v, parentCluster.id, data); + } + } + log$1.info("(Insert) Node XXX" + v + ": " + JSON.stringify(graph.node(v))); + if (node && node.clusterNode) { + log$1.info("Cluster identified", v, node.width, graph.node(v)); + const o = await recursiveRender( + nodes, + node.graph, + diagramType, + id, + graph.node(v), + siteConfig + ); + const newEl = o.elem; + updateNodeBounds(node, newEl); + node.diff = o.diff || 0; + log$1.info("Node bounds (abc123)", v, node, node.width, node.x, node.y); + setNodeElem(newEl, node); + log$1.warn("Recursive render complete ", newEl, node); + } else { + if (graph.children(v).length > 0) { + log$1.info("Cluster - the non recursive path XXX", v, node.id, node, graph); + log$1.info(findNonClusterChild(node.id, graph)); + clusterDb[node.id] = { id: findNonClusterChild(node.id, graph), node }; + } else { + log$1.info("Node - the non recursive path", v, node.id, node); + await insertNode(nodes, graph.node(v), dir); + } + } + }) + ); + graph.edges().forEach(function(e) { + const edge = graph.edge(e.v, e.w, e.name); + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + log$1.info("Edge " + e.v + " -> " + e.w + ": ", e, " ", JSON.stringify(graph.edge(e))); + log$1.info("Fix", clusterDb, "ids:", e.v, e.w, "Translating: ", clusterDb[e.v], clusterDb[e.w]); + insertEdgeLabel(edgeLabels, edge); + }); + graph.edges().forEach(function(e) { + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + }); + log$1.info("#############################################"); + log$1.info("### Layout ###"); + log$1.info("#############################################"); + log$1.info(graph); + layout(graph); + log$1.info("Graph after layout:", write(graph)); + let diff = 0; + const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig); + sortNodesByHierarchy(graph).forEach(function(v) { + const node = graph.node(v); + log$1.info("Position " + v + ": " + JSON.stringify(graph.node(v))); + log$1.info( + "Position " + v + ": (" + node.x, + "," + node.y, + ") width: ", + node.width, + " height: ", + node.height + ); + if (node && node.clusterNode) { + node.y += subGraphTitleTotalMargin; + positionNode(node); + } else { + if (graph.children(v).length > 0) { + node.height += subGraphTitleTotalMargin; + insertCluster(clusters, node); + clusterDb[node.id].node = node; + } else { + node.y += subGraphTitleTotalMargin / 2; + positionNode(node); + } + } + }); + graph.edges().forEach(function(e) { + const edge = graph.edge(e); + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(edge), edge); + edge.points.forEach((point) => point.y += subGraphTitleTotalMargin / 2); + const paths = insertEdge(edgePaths, e, edge, clusterDb, diagramType, graph, id); + positionEdgeLabel(edge, paths); + }); + graph.nodes().forEach(function(v) { + const n = graph.node(v); + log$1.info(v, n.type, n.diff); + if (n.type === "group") { + diff = n.diff; + } + }); + return { elem, diff }; +}; +const render = async (elem, graph, markers, diagramType, id) => { + insertMarkers$1(elem, markers, diagramType, id); + clear$1$1(); + clear$2(); + clear(); + clear$1(); + log$1.warn("Graph at first:", JSON.stringify(write(graph))); + adjustClustersAndEdges(graph); + log$1.warn("Graph after:", JSON.stringify(write(graph))); + const siteConfig = getConfig(); + await recursiveRender(elem, graph, diagramType, id, void 0, siteConfig); +}; + +export { render as r }; diff --git a/libs/marked/index-01f381cb-CDFlKdjO.js b/libs/marked/index-01f381cb-CDFlKdjO.js new file mode 100644 index 0000000..05604aa --- /dev/null +++ b/libs/marked/index-01f381cb-CDFlKdjO.js @@ -0,0 +1,666 @@ +import { i as isUndefined, G as Graph } from './graph-DadsyNmk.js'; +import { m as map, l as layout } from './layout-BOZlZI7g.js'; +import { c as clone } from './clone-B4k62NSz.js'; +import { i as insertMarkers$1, u as updateNodeBounds, s as setNodeElem, a as insertNode, b as insertEdgeLabel, g as getSubGraphTitleMargins, p as positionNode, c as insertEdge, d as positionEdgeLabel, e as clear$1$1, f as clear$2, h as createLabel$1, j as intersectRect$1 } from './edges-066a5561-a6s42o55.js'; +import { l as log$1, c as getConfig, p as evaluate, h as select } from './index-CN3YjQ0n.js'; +import { a as createText } from './createText-ca0c5216-DF05SDfj.js'; + +function write(g) { + var json = { + options: { + directed: g.isDirected(), + multigraph: g.isMultigraph(), + compound: g.isCompound(), + }, + nodes: writeNodes(g), + edges: writeEdges(g), + }; + if (!isUndefined(g.graph())) { + json.value = clone(g.graph()); + } + return json; +} + +function writeNodes(g) { + return map(g.nodes(), function (v) { + var nodeValue = g.node(v); + var parent = g.parent(v); + var node = { v: v }; + if (!isUndefined(nodeValue)) { + node.value = nodeValue; + } + if (!isUndefined(parent)) { + node.parent = parent; + } + return node; + }); +} + +function writeEdges(g) { + return map(g.edges(), function (e) { + var edgeValue = g.edge(e); + var edge = { v: e.v, w: e.w }; + if (!isUndefined(e.name)) { + edge.name = e.name; + } + if (!isUndefined(edgeValue)) { + edge.value = edgeValue; + } + return edge; + }); +} + +let clusterDb = {}; +let descendants = {}; +let parents = {}; +const clear$1 = () => { + descendants = {}; + parents = {}; + clusterDb = {}; +}; +const isDescendant = (id, ancestorId) => { + log$1.trace("In isDescendant", ancestorId, " ", id, " = ", descendants[ancestorId].includes(id)); + if (descendants[ancestorId].includes(id)) { + return true; + } + return false; +}; +const edgeInCluster = (edge, clusterId) => { + log$1.info("Descendants of ", clusterId, " is ", descendants[clusterId]); + log$1.info("Edge is ", edge); + if (edge.v === clusterId) { + return false; + } + if (edge.w === clusterId) { + return false; + } + if (!descendants[clusterId]) { + log$1.debug("Tilt, ", clusterId, ",not in descendants"); + return false; + } + return descendants[clusterId].includes(edge.v) || isDescendant(edge.v, clusterId) || isDescendant(edge.w, clusterId) || descendants[clusterId].includes(edge.w); +}; +const copy = (clusterId, graph, newGraph, rootId) => { + log$1.warn( + "Copying children of ", + clusterId, + "root", + rootId, + "data", + graph.node(clusterId), + rootId + ); + const nodes = graph.children(clusterId) || []; + if (clusterId !== rootId) { + nodes.push(clusterId); + } + log$1.warn("Copying (nodes) clusterId", clusterId, "nodes", nodes); + nodes.forEach((node) => { + if (graph.children(node).length > 0) { + copy(node, graph, newGraph, rootId); + } else { + const data = graph.node(node); + log$1.info("cp ", node, " to ", rootId, " with parent ", clusterId); + newGraph.setNode(node, data); + if (rootId !== graph.parent(node)) { + log$1.warn("Setting parent", node, graph.parent(node)); + newGraph.setParent(node, graph.parent(node)); + } + if (clusterId !== rootId && node !== clusterId) { + log$1.debug("Setting parent", node, clusterId); + newGraph.setParent(node, clusterId); + } else { + log$1.info("In copy ", clusterId, "root", rootId, "data", graph.node(clusterId), rootId); + log$1.debug( + "Not Setting parent for node=", + node, + "cluster!==rootId", + clusterId !== rootId, + "node!==clusterId", + node !== clusterId + ); + } + const edges = graph.edges(node); + log$1.debug("Copying Edges", edges); + edges.forEach((edge) => { + log$1.info("Edge", edge); + const data2 = graph.edge(edge.v, edge.w, edge.name); + log$1.info("Edge data", data2, rootId); + try { + if (edgeInCluster(edge, rootId)) { + log$1.info("Copying as ", edge.v, edge.w, data2, edge.name); + newGraph.setEdge(edge.v, edge.w, data2, edge.name); + log$1.info("newGraph edges ", newGraph.edges(), newGraph.edge(newGraph.edges()[0])); + } else { + log$1.info( + "Skipping copy of edge ", + edge.v, + "-->", + edge.w, + " rootId: ", + rootId, + " clusterId:", + clusterId + ); + } + } catch (e) { + log$1.error(e); + } + }); + } + log$1.debug("Removing node", node); + graph.removeNode(node); + }); +}; +const extractDescendants = (id, graph) => { + const children = graph.children(id); + let res = [...children]; + for (const child of children) { + parents[child] = id; + res = [...res, ...extractDescendants(child, graph)]; + } + return res; +}; +const findNonClusterChild = (id, graph) => { + log$1.trace("Searching", id); + const children = graph.children(id); + log$1.trace("Searching children of id ", id, children); + if (children.length < 1) { + log$1.trace("This is a valid node", id); + return id; + } + for (const child of children) { + const _id = findNonClusterChild(child, graph); + if (_id) { + log$1.trace("Found replacement for", id, " => ", _id); + return _id; + } + } +}; +const getAnchorId = (id) => { + if (!clusterDb[id]) { + return id; + } + if (!clusterDb[id].externalConnections) { + return id; + } + if (clusterDb[id]) { + return clusterDb[id].id; + } + return id; +}; +const adjustClustersAndEdges = (graph, depth) => { + if (!graph || depth > 10) { + log$1.debug("Opting out, no graph "); + return; + } else { + log$1.debug("Opting in, graph "); + } + graph.nodes().forEach(function(id) { + const children = graph.children(id); + if (children.length > 0) { + log$1.warn( + "Cluster identified", + id, + " Replacement id in edges: ", + findNonClusterChild(id, graph) + ); + descendants[id] = extractDescendants(id, graph); + clusterDb[id] = { id: findNonClusterChild(id, graph), clusterData: graph.node(id) }; + } + }); + graph.nodes().forEach(function(id) { + const children = graph.children(id); + const edges = graph.edges(); + if (children.length > 0) { + log$1.debug("Cluster identified", id, descendants); + edges.forEach((edge) => { + if (edge.v !== id && edge.w !== id) { + const d1 = isDescendant(edge.v, id); + const d2 = isDescendant(edge.w, id); + if (d1 ^ d2) { + log$1.warn("Edge: ", edge, " leaves cluster ", id); + log$1.warn("Descendants of XXX ", id, ": ", descendants[id]); + clusterDb[id].externalConnections = true; + } + } + }); + } else { + log$1.debug("Not a cluster ", id, descendants); + } + }); + for (let id of Object.keys(clusterDb)) { + const nonClusterChild = clusterDb[id].id; + const parent = graph.parent(nonClusterChild); + if (parent !== id && clusterDb[parent] && !clusterDb[parent].externalConnections) { + clusterDb[id].id = parent; + } + } + graph.edges().forEach(function(e) { + const edge = graph.edge(e); + log$1.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + log$1.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e))); + let v = e.v; + let w = e.w; + log$1.warn( + "Fix XXX", + clusterDb, + "ids:", + e.v, + e.w, + "Translating: ", + clusterDb[e.v], + " --- ", + clusterDb[e.w] + ); + if (clusterDb[e.v] && clusterDb[e.w] && clusterDb[e.v] === clusterDb[e.w]) { + log$1.warn("Fixing and trixing link to self - removing XXX", e.v, e.w, e.name); + log$1.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name); + v = getAnchorId(e.v); + w = getAnchorId(e.w); + graph.removeEdge(e.v, e.w, e.name); + const specialId = e.w + "---" + e.v; + graph.setNode(specialId, { + domId: specialId, + id: specialId, + labelStyle: "", + labelText: edge.label, + padding: 0, + shape: "labelRect", + style: "" + }); + const edge1 = structuredClone(edge); + const edge2 = structuredClone(edge); + edge1.label = ""; + edge1.arrowTypeEnd = "none"; + edge2.label = ""; + edge1.fromCluster = e.v; + edge2.toCluster = e.v; + graph.setEdge(v, specialId, edge1, e.name + "-cyclic-special"); + graph.setEdge(specialId, w, edge2, e.name + "-cyclic-special"); + } else if (clusterDb[e.v] || clusterDb[e.w]) { + log$1.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name); + v = getAnchorId(e.v); + w = getAnchorId(e.w); + graph.removeEdge(e.v, e.w, e.name); + if (v !== e.v) { + const parent = graph.parent(v); + clusterDb[parent].externalConnections = true; + edge.fromCluster = e.v; + } + if (w !== e.w) { + const parent = graph.parent(w); + clusterDb[parent].externalConnections = true; + edge.toCluster = e.w; + } + log$1.warn("Fix Replacing with XXX", v, w, e.name); + graph.setEdge(v, w, edge, e.name); + } + }); + log$1.warn("Adjusted Graph", write(graph)); + extractor(graph, 0); + log$1.trace(clusterDb); +}; +const extractor = (graph, depth) => { + log$1.warn("extractor - ", depth, write(graph), graph.children("D")); + if (depth > 10) { + log$1.error("Bailing out"); + return; + } + let nodes = graph.nodes(); + let hasChildren = false; + for (const node of nodes) { + const children = graph.children(node); + hasChildren = hasChildren || children.length > 0; + } + if (!hasChildren) { + log$1.debug("Done, no node has children", graph.nodes()); + return; + } + log$1.debug("Nodes = ", nodes, depth); + for (const node of nodes) { + log$1.debug( + "Extracting node", + node, + clusterDb, + clusterDb[node] && !clusterDb[node].externalConnections, + !graph.parent(node), + graph.node(node), + graph.children("D"), + " Depth ", + depth + ); + if (!clusterDb[node]) { + log$1.debug("Not a cluster", node, depth); + } else if (!clusterDb[node].externalConnections && // !graph.parent(node) && + graph.children(node) && graph.children(node).length > 0) { + log$1.warn( + "Cluster without external connections, without a parent and with children", + node, + depth + ); + const graphSettings = graph.graph(); + let dir = graphSettings.rankdir === "TB" ? "LR" : "TB"; + if (clusterDb[node] && clusterDb[node].clusterData && clusterDb[node].clusterData.dir) { + dir = clusterDb[node].clusterData.dir; + log$1.warn("Fixing dir", clusterDb[node].clusterData.dir, dir); + } + const clusterGraph = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + // Todo: set proper spacing + nodesep: 50, + ranksep: 50, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + log$1.warn("Old graph before copy", write(graph)); + copy(node, graph, clusterGraph, node); + graph.setNode(node, { + clusterNode: true, + id: node, + clusterData: clusterDb[node].clusterData, + labelText: clusterDb[node].labelText, + graph: clusterGraph + }); + log$1.warn("New graph after copy node: (", node, ")", write(clusterGraph)); + log$1.debug("Old graph after copy", write(graph)); + } else { + log$1.warn( + "Cluster ** ", + node, + " **not meeting the criteria !externalConnections:", + !clusterDb[node].externalConnections, + " no parent: ", + !graph.parent(node), + " children ", + graph.children(node) && graph.children(node).length > 0, + graph.children("D"), + depth + ); + log$1.debug(clusterDb); + } + } + nodes = graph.nodes(); + log$1.warn("New list of nodes", nodes); + for (const node of nodes) { + const data = graph.node(node); + log$1.warn(" Now next level", node, data); + if (data.clusterNode) { + extractor(data.graph, depth + 1); + } + } +}; +const sorter = (graph, nodes) => { + if (nodes.length === 0) { + return []; + } + let result = Object.assign(nodes); + nodes.forEach((node) => { + const children = graph.children(node); + const sorted = sorter(graph, children); + result = [...result, ...sorted]; + }); + return result; +}; +const sortNodesByHierarchy = (graph) => sorter(graph, graph.children()); +const rect = (parent, node) => { + log$1.info("Creating subgraph rect for ", node.id, node); + const siteConfig = getConfig(); + const shapeSvg = parent.insert("g").attr("class", "cluster" + (node.class ? " " + node.class : "")).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const useHtmlLabels = evaluate(siteConfig.flowchart.htmlLabels); + const label = shapeSvg.insert("g").attr("class", "cluster-label"); + const text = node.labelType === "markdown" ? createText(label, node.labelText, { style: node.labelStyle, useHtmlLabels }) : label.node().appendChild(createLabel$1(node.labelText, node.labelStyle, void 0, true)); + let bbox = text.getBBox(); + if (evaluate(siteConfig.flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + const padding = 0 * node.padding; + const halfPadding = padding / 2; + const width = node.width <= bbox.width + padding ? bbox.width + padding : node.width; + if (node.width <= bbox.width + padding) { + node.diff = (bbox.width - node.width) / 2 - node.padding / 2; + } else { + node.diff = -node.padding / 2; + } + log$1.trace("Data ", node, JSON.stringify(node)); + rect2.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", node.x - width / 2).attr("y", node.y - node.height / 2 - halfPadding).attr("width", width).attr("height", node.height + padding); + const { subGraphTitleTopMargin } = getSubGraphTitleMargins(siteConfig); + if (useHtmlLabels) { + label.attr( + "transform", + // This puts the label on top of the box instead of inside it + `translate(${node.x - bbox.width / 2}, ${node.y - node.height / 2 + subGraphTitleTopMargin})` + ); + } else { + label.attr( + "transform", + // This puts the label on top of the box instead of inside it + `translate(${node.x}, ${node.y - node.height / 2 + subGraphTitleTopMargin})` + ); + } + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const noteGroup = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "note-cluster").attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + rect2.attr("rx", node.rx).attr("ry", node.ry).attr("x", node.x - node.width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding).attr("width", node.width + padding).attr("height", node.height + padding).attr("fill", "none"); + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const roundedWithTitle = (parent, node) => { + const siteConfig = getConfig(); + const shapeSvg = parent.insert("g").attr("class", node.classes).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const label = shapeSvg.insert("g").attr("class", "cluster-label"); + const innerRect = shapeSvg.append("rect"); + const text = label.node().appendChild(createLabel$1(node.labelText, node.labelStyle, void 0, true)); + let bbox = text.getBBox(); + if (evaluate(siteConfig.flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + bbox = text.getBBox(); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + const width = node.width <= bbox.width + node.padding ? bbox.width + node.padding : node.width; + if (node.width <= bbox.width + node.padding) { + node.diff = (bbox.width + node.padding * 0 - node.width) / 2; + } else { + node.diff = -node.padding / 2; + } + rect2.attr("class", "outer").attr("x", node.x - width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding).attr("width", width + padding).attr("height", node.height + padding); + innerRect.attr("class", "inner").attr("x", node.x - width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding + bbox.height - 1).attr("width", width + padding).attr("height", node.height + padding - bbox.height - 3); + const { subGraphTitleTopMargin } = getSubGraphTitleMargins(siteConfig); + label.attr( + "transform", + `translate(${node.x - bbox.width / 2}, ${node.y - node.height / 2 - node.padding / 3 + (evaluate(siteConfig.flowchart.htmlLabels) ? 5 : 3) + subGraphTitleTopMargin})` + ); + const rectBox = rect2.node().getBBox(); + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const divider = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", node.classes).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + rect2.attr("class", "divider").attr("x", node.x - node.width / 2 - halfPadding).attr("y", node.y - node.height / 2).attr("width", node.width + padding).attr("height", node.height + padding); + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.diff = -node.padding / 2; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const shapes = { rect, roundedWithTitle, noteGroup, divider }; +let clusterElems = {}; +const insertCluster = (elem, node) => { + log$1.trace("Inserting cluster"); + const shape = node.shape || "rect"; + clusterElems[node.id] = shapes[shape](elem, node); +}; +const clear = () => { + clusterElems = {}; +}; +const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, siteConfig) => { + log$1.info("Graph in recursive render: XXX", write(graph), parentCluster); + const dir = graph.graph().rankdir; + log$1.trace("Dir in recursive render - dir:", dir); + const elem = _elem.insert("g").attr("class", "root"); + if (!graph.nodes()) { + log$1.info("No nodes found for", graph); + } else { + log$1.info("Recursive render XXX", graph.nodes()); + } + if (graph.edges().length > 0) { + log$1.trace("Recursive edges", graph.edge(graph.edges()[0])); + } + const clusters = elem.insert("g").attr("class", "clusters"); + const edgePaths = elem.insert("g").attr("class", "edgePaths"); + const edgeLabels = elem.insert("g").attr("class", "edgeLabels"); + const nodes = elem.insert("g").attr("class", "nodes"); + await Promise.all( + graph.nodes().map(async function(v) { + const node = graph.node(v); + if (parentCluster !== void 0) { + const data = JSON.parse(JSON.stringify(parentCluster.clusterData)); + log$1.info("Setting data for cluster XXX (", v, ") ", data, parentCluster); + graph.setNode(parentCluster.id, data); + if (!graph.parent(v)) { + log$1.trace("Setting parent", v, parentCluster.id); + graph.setParent(v, parentCluster.id, data); + } + } + log$1.info("(Insert) Node XXX" + v + ": " + JSON.stringify(graph.node(v))); + if (node && node.clusterNode) { + log$1.info("Cluster identified", v, node.width, graph.node(v)); + const o = await recursiveRender( + nodes, + node.graph, + diagramType, + id, + graph.node(v), + siteConfig + ); + const newEl = o.elem; + updateNodeBounds(node, newEl); + node.diff = o.diff || 0; + log$1.info("Node bounds (abc123)", v, node, node.width, node.x, node.y); + setNodeElem(newEl, node); + log$1.warn("Recursive render complete ", newEl, node); + } else { + if (graph.children(v).length > 0) { + log$1.info("Cluster - the non recursive path XXX", v, node.id, node, graph); + log$1.info(findNonClusterChild(node.id, graph)); + clusterDb[node.id] = { id: findNonClusterChild(node.id, graph), node }; + } else { + log$1.info("Node - the non recursive path", v, node.id, node); + await insertNode(nodes, graph.node(v), dir); + } + } + }) + ); + graph.edges().forEach(function(e) { + const edge = graph.edge(e.v, e.w, e.name); + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + log$1.info("Edge " + e.v + " -> " + e.w + ": ", e, " ", JSON.stringify(graph.edge(e))); + log$1.info("Fix", clusterDb, "ids:", e.v, e.w, "Translating: ", clusterDb[e.v], clusterDb[e.w]); + insertEdgeLabel(edgeLabels, edge); + }); + graph.edges().forEach(function(e) { + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + }); + log$1.info("#############################################"); + log$1.info("### Layout ###"); + log$1.info("#############################################"); + log$1.info(graph); + layout(graph); + log$1.info("Graph after layout:", write(graph)); + let diff = 0; + const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig); + sortNodesByHierarchy(graph).forEach(function(v) { + const node = graph.node(v); + log$1.info("Position " + v + ": " + JSON.stringify(graph.node(v))); + log$1.info( + "Position " + v + ": (" + node.x, + "," + node.y, + ") width: ", + node.width, + " height: ", + node.height + ); + if (node && node.clusterNode) { + node.y += subGraphTitleTotalMargin; + positionNode(node); + } else { + if (graph.children(v).length > 0) { + node.height += subGraphTitleTotalMargin; + insertCluster(clusters, node); + clusterDb[node.id].node = node; + } else { + node.y += subGraphTitleTotalMargin / 2; + positionNode(node); + } + } + }); + graph.edges().forEach(function(e) { + const edge = graph.edge(e); + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(edge), edge); + edge.points.forEach((point) => point.y += subGraphTitleTotalMargin / 2); + const paths = insertEdge(edgePaths, e, edge, clusterDb, diagramType, graph, id); + positionEdgeLabel(edge, paths); + }); + graph.nodes().forEach(function(v) { + const n = graph.node(v); + log$1.info(v, n.type, n.diff); + if (n.type === "group") { + diff = n.diff; + } + }); + return { elem, diff }; +}; +const render = async (elem, graph, markers, diagramType, id) => { + insertMarkers$1(elem, markers, diagramType, id); + clear$1$1(); + clear$2(); + clear(); + clear$1(); + log$1.warn("Graph at first:", JSON.stringify(write(graph))); + adjustClustersAndEdges(graph); + log$1.warn("Graph after:", JSON.stringify(write(graph))); + const siteConfig = getConfig(); + await recursiveRender(elem, graph, diagramType, id, void 0, siteConfig); +}; + +export { render as r }; diff --git a/libs/marked/mj-marked.mjs b/libs/marked/index-Bd_FDXSq.js similarity index 57% rename from libs/marked/mj-marked.mjs rename to libs/marked/index-Bd_FDXSq.js index b939470..1374ea8 100644 --- a/libs/marked/mj-marked.mjs +++ b/libs/marked/index-Bd_FDXSq.js @@ -46,7 +46,7 @@ const escapeReplacements = { "'": ''' }; const getEscapeReplacement = (ch) => escapeReplacements[ch]; -function escape$1(html, encode) { +function escape$1$1(html, encode) { if (encode) { if (escapeTest.test(html)) { return html.replace(escapeReplace, getEscapeReplacement); @@ -60,7 +60,7 @@ function escape$1(html, encode) { return html; } const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig; -function unescape(html) { +function unescape$1(html) { // explicitly match decimal, hex, and named HTML entities return html.replace(unescapeTest, (_, n) => { n = n.toLowerCase(); @@ -74,14 +74,14 @@ function unescape(html) { return ''; }); } -const caret = /(^|[^\[])\^/g; +const caret$1 = /(^|[^\[])\^/g; function edit(regex, opt) { let source = typeof regex === 'string' ? regex : regex.source; opt = opt || ''; const obj = { replace: (name, val) => { let valSource = typeof val === 'string' ? val : val.source; - valSource = valSource.replace(caret, '$1'); + valSource = valSource.replace(caret$1, '$1'); source = source.replace(name, valSource); return obj; }, @@ -196,7 +196,7 @@ function findClosingBracket(str, b) { function outputLink(cap, link, raw, lexer) { const href = link.href; - const title = link.title ? escape$1(link.title) : null; + const title = link.title ? escape$1$1(link.title) : null; const text = cap[1].replace(/\\([\[\]])/g, '$1'); if (cap[0].charAt(0) !== '!') { lexer.state.inLink = true; @@ -216,7 +216,7 @@ function outputLink(cap, link, raw, lexer) { raw, href, title, - text: escape$1(text) + text: escape$1$1(text) }; } function indentCodeCompensation(raw, text) { @@ -627,7 +627,7 @@ class _Tokenizer { return { type: 'escape', raw: cap[0], - text: escape$1(cap[1]) + text: escape$1$1(cap[1]) }; } } @@ -797,7 +797,7 @@ class _Tokenizer { if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) { text = text.substring(1, text.length - 1); } - text = escape$1(text, true); + text = escape$1$1(text, true); return { type: 'codespan', raw: cap[0], @@ -830,11 +830,11 @@ class _Tokenizer { if (cap) { let text, href; if (cap[2] === '@') { - text = escape$1(cap[1]); + text = escape$1$1(cap[1]); href = 'mailto:' + text; } else { - text = escape$1(cap[1]); + text = escape$1$1(cap[1]); href = text; } return { @@ -857,7 +857,7 @@ class _Tokenizer { if (cap = this.rules.inline.url.exec(src)) { let text, href; if (cap[2] === '@') { - text = escape$1(cap[0]); + text = escape$1$1(cap[0]); href = 'mailto:' + text; } else { @@ -867,7 +867,7 @@ class _Tokenizer { prevCapZero = cap[0]; cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? ''; } while (prevCapZero !== cap[0]); - text = escape$1(cap[0]); + text = escape$1$1(cap[0]); if (cap[1] === 'www.') { href = 'http://' + cap[0]; } @@ -898,7 +898,7 @@ class _Tokenizer { text = cap[0]; } else { - text = escape$1(cap[0]); + text = escape$1$1(cap[0]); } return { type: 'text', @@ -943,7 +943,7 @@ const _tag = 'address|article|aside|base|basefont|blockquote|body|caption' + '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title' + '|tr|track|ul'; const _comment = /|$))/; -const html = edit('^ {0,3}(?:' // optional indentation +const html$2 = edit('^ {0,3}(?:' // optional indentation + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)' // (1) + '|comment[^\\n]*(\\n+|$)' // (2) + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3) @@ -981,7 +981,7 @@ const blockNormal = { fences, heading, hr, - html, + html: html$2, lheading, list, newline, @@ -1182,7 +1182,7 @@ const inlineBreaks = { /** * exports */ -const block = { +const block$1 = { normal: blockNormal, gfm: blockGfm, pedantic: blockPedantic @@ -1219,15 +1219,15 @@ class _Lexer { top: true }; const rules = { - block: block.normal, + block: block$1.normal, inline: inline.normal }; if (this.options.pedantic) { - rules.block = block.pedantic; + rules.block = block$1.pedantic; rules.inline = inline.pedantic; } else if (this.options.gfm) { - rules.block = block.gfm; + rules.block = block$1.gfm; if (this.options.breaks) { rules.inline = inline.breaks; } @@ -1242,7 +1242,7 @@ class _Lexer { */ static get rules() { return { - block, + block: block$1, inline }; } @@ -1639,13 +1639,13 @@ class _Renderer { code = code.replace(/\n$/, '') + '\n'; if (!lang) { return '
'
-                + (escaped ? code : escape$1(code, true))
+                + (escaped ? code : escape$1$1(code, true))
                 + '
\n'; } return '
'
-            + (escaped ? code : escape$1(code, true))
+            + (escaped ? code : escape$1$1(code, true))
             + '
\n'; } blockquote(quote) { @@ -1835,7 +1835,7 @@ class _Parser { } case 'heading': { const headingToken = token; - out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer))); + out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape$1(this.parseInline(headingToken.tokens, this.textRenderer))); continue; } case 'code': { @@ -2348,7 +2348,7 @@ class Marked { e.message += '\nPlease report this to https://github.com/markedjs/marked.'; if (silent) { const msg = '

An error occurred:

'
-                    + escape$1(e.message + '', true)
+                    + escape$1$1(e.message + '', true)
                     + '
'; if (async) { return Promise.resolve(msg); @@ -2632,7 +2632,7 @@ var ESCAPE_REGEX = /[&><"']/g; * Escapes text to prevent scripting attacks. */ -function escape(text) { +function escape$1(text) { return String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); } /** @@ -2712,10 +2712,10 @@ var protocolFromUrl = function protocolFromUrl(url) { return protocol[1].toLowerCase(); }; -var utils = { +var utils$1 = { contains, deflt, - escape, + escape: escape$1, hyphenate, getBaseElem, isCharacterBox, @@ -2960,7 +2960,7 @@ class Settings { isTrusted(context) { if (context.url && !context.protocol) { - var protocol = utils.protocolFromUrl(context.url); + var protocol = utils$1.protocolFromUrl(context.url); if (protocol == null) { return false; @@ -3472,7 +3472,7 @@ class DocumentFragment { } hasClass(className) { - return utils.contains(this.classes, className); + return utils$1.contains(this.classes, className); } /** Convert the fragment into a node. */ @@ -6379,25 +6379,25 @@ var toMarkup = function toMarkup(tagName) { var markup = "<" + tagName; // Add the class if (this.classes.length) { - markup += " class=\"" + utils.escape(createClass(this.classes)) + "\""; + markup += " class=\"" + utils$1.escape(createClass(this.classes)) + "\""; } var styles = ""; // Add the styles, after hyphenation for (var style in this.style) { if (this.style.hasOwnProperty(style)) { - styles += utils.hyphenate(style) + ":" + this.style[style] + ";"; + styles += utils$1.hyphenate(style) + ":" + this.style[style] + ";"; } } if (styles) { - markup += " style=\"" + utils.escape(styles) + "\""; + markup += " style=\"" + utils$1.escape(styles) + "\""; } // Add the attributes for (var attr in this.attributes) { if (this.attributes.hasOwnProperty(attr)) { - markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; + markup += " " + attr + "=\"" + utils$1.escape(this.attributes[attr]) + "\""; } } @@ -6452,7 +6452,7 @@ class Span { } hasClass(className) { - return utils.contains(this.classes, className); + return utils$1.contains(this.classes, className); } toNode() { @@ -6488,7 +6488,7 @@ class Anchor { } hasClass(className) { - return utils.contains(this.classes, className); + return utils$1.contains(this.classes, className); } toNode() { @@ -6520,7 +6520,7 @@ class Img { } hasClass(className) { - return utils.contains(this.classes, className); + return utils$1.contains(this.classes, className); } toNode() { @@ -6540,18 +6540,18 @@ class Img { } toMarkup() { - var markup = "\"""; + return ""; } else { - return ""; + return ""; } } @@ -6800,7 +6800,7 @@ class LineNode { for (var attr in this.attributes) { if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { - markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\""; + markup += " " + attr + "=\"" + utils$1.escape(this.attributes[attr]) + "\""; } } @@ -6881,7 +6881,7 @@ function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { // modes: var math = "math"; -var text = "text"; // fonts: +var text$2 = "text"; // fonts: var main = "main"; var ams = "ams"; // groups: @@ -6928,9 +6928,9 @@ defineSymbol(math, main, punct, "\u002e", "\\ldotp"); defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols defineSymbol(math, main, textord, "\u0023", "\\#"); -defineSymbol(text, main, textord, "\u0023", "\\#"); +defineSymbol(text$2, main, textord, "\u0023", "\\#"); defineSymbol(math, main, textord, "\u0026", "\\&"); -defineSymbol(text, main, textord, "\u0026", "\\&"); +defineSymbol(text$2, main, textord, "\u0026", "\\&"); defineSymbol(math, main, textord, "\u2135", "\\aleph", true); defineSymbol(math, main, textord, "\u2200", "\\forall", true); defineSymbol(math, main, textord, "\u210f", "\\hbar", true); @@ -6948,16 +6948,16 @@ defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); defineSymbol(math, main, textord, "\u2111", "\\Im", true); defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); defineSymbol(math, main, textord, "\u00a7", "\\S", true); -defineSymbol(text, main, textord, "\u00a7", "\\S"); +defineSymbol(text$2, main, textord, "\u00a7", "\\S"); defineSymbol(math, main, textord, "\u00b6", "\\P", true); -defineSymbol(text, main, textord, "\u00b6", "\\P"); // Math and Text +defineSymbol(text$2, main, textord, "\u00b6", "\\P"); // Math and Text defineSymbol(math, main, textord, "\u2020", "\\dag"); -defineSymbol(text, main, textord, "\u2020", "\\dag"); -defineSymbol(text, main, textord, "\u2020", "\\textdagger"); +defineSymbol(text$2, main, textord, "\u2020", "\\dag"); +defineSymbol(text$2, main, textord, "\u2020", "\\textdagger"); defineSymbol(math, main, textord, "\u2021", "\\ddag"); -defineSymbol(text, main, textord, "\u2021", "\\ddag"); -defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters +defineSymbol(text$2, main, textord, "\u2021", "\\ddag"); +defineSymbol(text$2, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); @@ -7072,7 +7072,7 @@ defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); -defineSymbol(text, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text$2, ams, textord, "\u00ae", "\\circledR"); defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); defineSymbol(math, ams, textord, "\u2204", "\\nexists"); defineSymbol(math, ams, textord, "\u2127", "\\mho"); @@ -7088,7 +7088,7 @@ defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); -defineSymbol(text, main, textord, "\u00f0", "\u00f0"); +defineSymbol(text$2, main, textord, "\u00f0", "\u00f0"); defineSymbol(math, ams, textord, "\u2571", "\\diagup"); defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); defineSymbol(math, ams, textord, "\u25a1", "\\square"); @@ -7096,9 +7096,9 @@ defineSymbol(math, ams, textord, "\u25a1", "\\Box"); defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); -defineSymbol(text, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text$2, ams, textord, "\u00a5", "\\yen", true); defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); -defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew +defineSymbol(text$2, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew defineSymbol(math, ams, textord, "\u2136", "\\beth", true); defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); @@ -7255,13 +7255,13 @@ defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); defineSymbol(math, ams, rel, "\u21be", "\\restriction"); defineSymbol(math, main, textord, "\u2018", "`"); defineSymbol(math, main, textord, "$", "\\$"); -defineSymbol(text, main, textord, "$", "\\$"); -defineSymbol(text, main, textord, "$", "\\textdollar"); +defineSymbol(text$2, main, textord, "$", "\\$"); +defineSymbol(text$2, main, textord, "$", "\\textdollar"); defineSymbol(math, main, textord, "%", "\\%"); -defineSymbol(text, main, textord, "%", "\\%"); +defineSymbol(text$2, main, textord, "%", "\\%"); defineSymbol(math, main, textord, "_", "\\_"); -defineSymbol(text, main, textord, "_", "\\_"); -defineSymbol(text, main, textord, "_", "\\textunderscore"); +defineSymbol(text$2, main, textord, "_", "\\_"); +defineSymbol(text$2, main, textord, "_", "\\textunderscore"); defineSymbol(math, main, textord, "\u2220", "\\angle", true); defineSymbol(math, main, textord, "\u221e", "\\infty", true); defineSymbol(math, main, textord, "\u2032", "\\prime"); @@ -7379,10 +7379,10 @@ defineSymbol(math, main, spacing, "\u00a0", "\\ "); defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); -defineSymbol(text, main, spacing, "\u00a0", "\\ "); -defineSymbol(text, main, spacing, "\u00a0", " "); -defineSymbol(text, main, spacing, "\u00a0", "\\space"); -defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text$2, main, spacing, "\u00a0", "\\ "); +defineSymbol(text$2, main, spacing, "\u00a0", " "); +defineSymbol(text$2, main, spacing, "\u00a0", "\\space"); +defineSymbol(text$2, main, spacing, "\u00a0", "\\nobreakspace"); defineSymbol(math, main, spacing, null, "\\nobreak"); defineSymbol(math, main, spacing, null, "\\allowbreak"); defineSymbol(math, main, punct, ",", ","); @@ -7404,22 +7404,22 @@ defineSymbol(math, main, bin, "\u22c6", "\\star"); defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); defineSymbol(math, main, open, "{", "\\{"); -defineSymbol(text, main, textord, "{", "\\{"); -defineSymbol(text, main, textord, "{", "\\textbraceleft"); +defineSymbol(text$2, main, textord, "{", "\\{"); +defineSymbol(text$2, main, textord, "{", "\\textbraceleft"); defineSymbol(math, main, close, "}", "\\}"); -defineSymbol(text, main, textord, "}", "\\}"); -defineSymbol(text, main, textord, "}", "\\textbraceright"); +defineSymbol(text$2, main, textord, "}", "\\}"); +defineSymbol(text$2, main, textord, "}", "\\textbraceright"); defineSymbol(math, main, open, "{", "\\lbrace"); defineSymbol(math, main, close, "}", "\\rbrace"); defineSymbol(math, main, open, "[", "\\lbrack", true); -defineSymbol(text, main, textord, "[", "\\lbrack", true); +defineSymbol(text$2, main, textord, "[", "\\lbrack", true); defineSymbol(math, main, close, "]", "\\rbrack", true); -defineSymbol(text, main, textord, "]", "\\rbrack", true); +defineSymbol(text$2, main, textord, "]", "\\rbrack", true); defineSymbol(math, main, open, "(", "\\lparen", true); defineSymbol(math, main, close, ")", "\\rparen", true); -defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc +defineSymbol(text$2, main, textord, "<", "\\textless", true); // in T1 fontenc -defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc +defineSymbol(text$2, main, textord, ">", "\\textgreater", true); // in T1 fontenc defineSymbol(math, main, open, "\u230a", "\\lfloor", true); defineSymbol(math, main, close, "\u230b", "\\rfloor", true); @@ -7428,14 +7428,14 @@ defineSymbol(math, main, close, "\u2309", "\\rceil", true); defineSymbol(math, main, textord, "\\", "\\backslash"); defineSymbol(math, main, textord, "\u2223", "|"); defineSymbol(math, main, textord, "\u2223", "\\vert"); -defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc +defineSymbol(text$2, main, textord, "|", "\\textbar", true); // in T1 fontenc defineSymbol(math, main, textord, "\u2225", "\\|"); defineSymbol(math, main, textord, "\u2225", "\\Vert"); -defineSymbol(text, main, textord, "\u2225", "\\textbardbl"); -defineSymbol(text, main, textord, "~", "\\textasciitilde"); -defineSymbol(text, main, textord, "\\", "\\textbackslash"); -defineSymbol(text, main, textord, "^", "\\textasciicircum"); +defineSymbol(text$2, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text$2, main, textord, "~", "\\textasciitilde"); +defineSymbol(text$2, main, textord, "\\", "\\textbackslash"); +defineSymbol(text$2, main, textord, "^", "\\textasciicircum"); defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); @@ -7462,9 +7462,9 @@ defineSymbol(math, main, op, "\u222f", "\\oiint"); defineSymbol(math, main, op, "\u2230", "\\oiiint"); defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); defineSymbol(math, main, op, "\u222b", "\\smallint"); -defineSymbol(text, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(text$2, main, inner, "\u2026", "\\textellipsis"); defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); -defineSymbol(text, main, inner, "\u2026", "\\ldots", true); +defineSymbol(text$2, main, inner, "\u2026", "\\ldots", true); defineSymbol(math, main, inner, "\u2026", "\\ldots", true); defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); @@ -7486,40 +7486,40 @@ defineSymbol(math, main, mathord, "\ue131", "\\@imath"); defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); defineSymbol(math, main, textord, "\u0131", "\u0131"); defineSymbol(math, main, textord, "\u0237", "\u0237"); -defineSymbol(text, main, textord, "\u0131", "\\i", true); -defineSymbol(text, main, textord, "\u0237", "\\j", true); -defineSymbol(text, main, textord, "\u00df", "\\ss", true); -defineSymbol(text, main, textord, "\u00e6", "\\ae", true); -defineSymbol(text, main, textord, "\u0153", "\\oe", true); -defineSymbol(text, main, textord, "\u00f8", "\\o", true); -defineSymbol(text, main, textord, "\u00c6", "\\AE", true); -defineSymbol(text, main, textord, "\u0152", "\\OE", true); -defineSymbol(text, main, textord, "\u00d8", "\\O", true); -defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute +defineSymbol(text$2, main, textord, "\u0131", "\\i", true); +defineSymbol(text$2, main, textord, "\u0237", "\\j", true); +defineSymbol(text$2, main, textord, "\u00df", "\\ss", true); +defineSymbol(text$2, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text$2, main, textord, "\u0153", "\\oe", true); +defineSymbol(text$2, main, textord, "\u00f8", "\\o", true); +defineSymbol(text$2, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text$2, main, textord, "\u0152", "\\OE", true); +defineSymbol(text$2, main, textord, "\u00d8", "\\O", true); +defineSymbol(text$2, main, accent, "\u02ca", "\\'"); // acute -defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave +defineSymbol(text$2, main, accent, "\u02cb", "\\`"); // grave -defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex +defineSymbol(text$2, main, accent, "\u02c6", "\\^"); // circumflex -defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde +defineSymbol(text$2, main, accent, "\u02dc", "\\~"); // tilde -defineSymbol(text, main, accent, "\u02c9", "\\="); // macron +defineSymbol(text$2, main, accent, "\u02c9", "\\="); // macron -defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve +defineSymbol(text$2, main, accent, "\u02d8", "\\u"); // breve -defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above +defineSymbol(text$2, main, accent, "\u02d9", "\\."); // dot above -defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla +defineSymbol(text$2, main, accent, "\u00b8", "\\c"); // cedilla -defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above +defineSymbol(text$2, main, accent, "\u02da", "\\r"); // ring above -defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron +defineSymbol(text$2, main, accent, "\u02c7", "\\v"); // caron -defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis +defineSymbol(text$2, main, accent, "\u00a8", '\\"'); // diaresis -defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute +defineSymbol(text$2, main, accent, "\u02dd", "\\H"); // double acute -defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph +defineSymbol(text$2, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph // These ligatures are detected and created in Parser.js's `formLigatures`. var ligatures = { @@ -7528,37 +7528,37 @@ var ligatures = { "``": true, "''": true }; -defineSymbol(text, main, textord, "\u2013", "--", true); -defineSymbol(text, main, textord, "\u2013", "\\textendash"); -defineSymbol(text, main, textord, "\u2014", "---", true); -defineSymbol(text, main, textord, "\u2014", "\\textemdash"); -defineSymbol(text, main, textord, "\u2018", "`", true); -defineSymbol(text, main, textord, "\u2018", "\\textquoteleft"); -defineSymbol(text, main, textord, "\u2019", "'", true); -defineSymbol(text, main, textord, "\u2019", "\\textquoteright"); -defineSymbol(text, main, textord, "\u201c", "``", true); -defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft"); -defineSymbol(text, main, textord, "\u201d", "''", true); -defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package +defineSymbol(text$2, main, textord, "\u2013", "--", true); +defineSymbol(text$2, main, textord, "\u2013", "\\textendash"); +defineSymbol(text$2, main, textord, "\u2014", "---", true); +defineSymbol(text$2, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text$2, main, textord, "\u2018", "`", true); +defineSymbol(text$2, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text$2, main, textord, "\u2019", "'", true); +defineSymbol(text$2, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text$2, main, textord, "\u201c", "``", true); +defineSymbol(text$2, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text$2, main, textord, "\u201d", "''", true); +defineSymbol(text$2, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package defineSymbol(math, main, textord, "\u00b0", "\\degree", true); -defineSymbol(text, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package +defineSymbol(text$2, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package -defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math +defineSymbol(text$2, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math // mode, but among our fonts, only Main-Regular defines this character "163". defineSymbol(math, main, textord, "\u00a3", "\\pounds"); defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); -defineSymbol(text, main, textord, "\u00a3", "\\pounds"); -defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(text$2, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text$2, main, textord, "\u00a3", "\\textsterling", true); defineSymbol(math, ams, textord, "\u2720", "\\maltese"); -defineSymbol(text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. +defineSymbol(text$2, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. // All of these are textords in math mode var mathTextSymbols = "0123456789/@.\""; -for (var i = 0; i < mathTextSymbols.length; i++) { - var ch = mathTextSymbols.charAt(i); +for (var i$1 = 0; i$1 < mathTextSymbols.length; i$1++) { + var ch = mathTextSymbols.charAt(i$1); defineSymbol(math, main, textord, ch, ch); } // All of these are textords in text mode @@ -7568,7 +7568,7 @@ var textSymbols = "0123456789!@*()-=+\";:?/.,"; for (var _i = 0; _i < textSymbols.length; _i++) { var _ch = textSymbols.charAt(_i); - defineSymbol(text, main, textord, _ch, _ch); + defineSymbol(text$2, main, textord, _ch, _ch); } // All of these are textords in text mode, and mathords in math mode @@ -7578,28 +7578,28 @@ for (var _i2 = 0; _i2 < letters.length; _i2++) { var _ch2 = letters.charAt(_i2); defineSymbol(math, main, mathord, _ch2, _ch2); - defineSymbol(text, main, textord, _ch2, _ch2); + defineSymbol(text$2, main, textord, _ch2, _ch2); } // Blackboard bold and script letters in Unicode range defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold -defineSymbol(text, ams, textord, "C", "\u2102"); +defineSymbol(text$2, ams, textord, "C", "\u2102"); defineSymbol(math, ams, textord, "H", "\u210D"); -defineSymbol(text, ams, textord, "H", "\u210D"); +defineSymbol(text$2, ams, textord, "H", "\u210D"); defineSymbol(math, ams, textord, "N", "\u2115"); -defineSymbol(text, ams, textord, "N", "\u2115"); +defineSymbol(text$2, ams, textord, "N", "\u2115"); defineSymbol(math, ams, textord, "P", "\u2119"); -defineSymbol(text, ams, textord, "P", "\u2119"); +defineSymbol(text$2, ams, textord, "P", "\u2119"); defineSymbol(math, ams, textord, "Q", "\u211A"); -defineSymbol(text, ams, textord, "Q", "\u211A"); +defineSymbol(text$2, ams, textord, "Q", "\u211A"); defineSymbol(math, ams, textord, "R", "\u211D"); -defineSymbol(text, ams, textord, "R", "\u211D"); +defineSymbol(text$2, ams, textord, "R", "\u211D"); defineSymbol(math, ams, textord, "Z", "\u2124"); -defineSymbol(text, ams, textord, "Z", "\u2124"); +defineSymbol(text$2, ams, textord, "Z", "\u2124"); defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant -defineSymbol(text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. +defineSymbol(text$2, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. // We support some letters in the Unicode range U+1D400 to U+1D7FF, // Mathematical Alphanumeric Symbols. // Some editors do not deal well with wide characters. So don't write the @@ -7616,39 +7616,39 @@ for (var _i3 = 0; _i3 < letters.length; _i3++) { wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fractur defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); if (_i3 < 26) { // KaTeX fonts have only capital letters for blackboard bold and script. @@ -7656,11 +7656,11 @@ for (var _i3 = 0; _i3 < letters.length; _i3++) { wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script defineSymbol(math, main, mathord, _ch3, wideChar); - defineSymbol(text, main, textord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); } // TODO: Add bold script when it is supported by a KaTeX font. } // "k" is the only double struck lower case letter in the KaTeX fonts. @@ -7669,7 +7669,7 @@ for (var _i3 = 0; _i3 < letters.length; _i3++) { wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck defineSymbol(math, main, mathord, "k", wideChar); -defineSymbol(text, main, textord, "k", wideChar); // Next, some wide character numerals +defineSymbol(text$2, main, textord, "k", wideChar); // Next, some wide character numerals for (var _i4 = 0; _i4 < 10; _i4++) { var _ch4 = _i4.toString(); @@ -7677,19 +7677,19 @@ for (var _i4 = 0; _i4 < 10; _i4++) { wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(text, main, textord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(text, main, textord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(text, main, textord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace defineSymbol(math, main, mathord, _ch4, wideChar); - defineSymbol(text, main, textord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); } // We add these Latin-1 letters as symbols for backwards-compatibility, // but they are not actually in the font, nor are they supported by the // Unicode accent mechanism, so they fall back to Times font and look ugly. @@ -7702,7 +7702,7 @@ for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { var _ch5 = extraLatin.charAt(_i5); defineSymbol(math, main, mathord, _ch5, _ch5); - defineSymbol(text, main, textord, _ch5, _ch5); + defineSymbol(text$2, main, textord, _ch5, _ch5); } /** @@ -8755,9 +8755,9 @@ var buildExpression$1 = function buildExpression(expression, options, isRealGrou var prevType = prev.classes[0]; var type = node.classes[0]; - if (prevType === "mbin" && utils.contains(binRightCanceller, type)) { + if (prevType === "mbin" && utils$1.contains(binRightCanceller, type)) { prev.classes[0] = "mord"; - } else if (type === "mbin" && utils.contains(binLeftCanceller, prevType)) { + } else if (type === "mbin" && utils$1.contains(binLeftCanceller, prevType)) { node.classes[0] = "mord"; } }, { @@ -9117,13 +9117,13 @@ class MathNode { for (var attr in this.attributes) { if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { markup += " " + attr + "=\""; - markup += utils.escape(this.attributes[attr]); + markup += utils$1.escape(this.attributes[attr]); markup += "\""; } } if (this.classes.length > 0) { - markup += " class =\"" + utils.escape(createClass(this.classes)) + "\""; + markup += " class =\"" + utils$1.escape(createClass(this.classes)) + "\""; } markup += ">"; @@ -9169,7 +9169,7 @@ class TextNode { toMarkup() { - return utils.escape(this.toText()); + return utils$1.escape(this.toText()); } /** * Converts the text node into a string @@ -9353,7 +9353,7 @@ var getVariant = function getVariant(group, options) { var text = group.text; - if (utils.contains(["\\imath", "\\jmath"], text)) { + if (utils$1.contains(["\\imath", "\\jmath"], text)) { return null; } @@ -9478,7 +9478,7 @@ function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) var wrapper; - if (expression.length === 1 && expression[0] instanceof MathNode && utils.contains(["mrow", "mtable"], expression[0].type)) { + if (expression.length === 1 && expression[0] instanceof MathNode && utils$1.contains(["mrow", "mtable"], expression[0].type)) { wrapper = expression[0]; } else { wrapper = new mathMLTree.MathNode("mrow", expression); @@ -9714,7 +9714,7 @@ var svgSpan = function svgSpan(group, options) { var label = group.label.slice(1); - if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { + if (utils$1.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { // Each type in the `if` statement corresponds to one of the ParseNode // types below. This narrowing is required to access `grp.base`. // $FlowFixMe @@ -9977,7 +9977,7 @@ var htmlBuilder$a = (grp, options) => { var body = buildGroup$1(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? - var mustShift = group.isShifty && utils.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the + var mustShift = group.isShifty && utils$1.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the // nucleus is not a single character, let s = 0; otherwise set s to the // kern amount for the nucleus followed by the \skewchar of its font." // Note that our skew metrics are just the kern between each character @@ -9988,7 +9988,7 @@ var htmlBuilder$a = (grp, options) => { if (mustShift) { // If the base is a character box, then we want the skew of the // innermost character. To do that, we find the innermost character: - var baseChar = utils.getBaseElem(base); // Then, we render its group to get the symbol inside it + var baseChar = utils$1.getBaseElem(base); // Then, we render its group to get the symbol inside it var baseGroup = buildGroup$1(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. @@ -10434,7 +10434,7 @@ defineFunction({ mclass: "m" + funcName.slice(5), // TODO(kevinb): don't prefix with 'm' body: ordargument(body), - isCharacterBox: utils.isCharacterBox(body) + isCharacterBox: utils$1.isCharacterBox(body) }; }, @@ -10472,7 +10472,7 @@ defineFunction({ mode: parser.mode, mclass: binrelClass(args[0]), body: ordargument(args[1]), - isCharacterBox: utils.isCharacterBox(args[1]) + isCharacterBox: utils$1.isCharacterBox(args[1]) }; } @@ -10523,7 +10523,7 @@ defineFunction({ mode: parser.mode, mclass, body: [supsub], - isCharacterBox: utils.isCharacterBox(supsub) + isCharacterBox: utils$1.isCharacterBox(supsub) }; }, @@ -11513,11 +11513,11 @@ var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, opt top = "\\Uparrow"; repeat = "\u2016"; bottom = "\\Downarrow"; - } else if (utils.contains(verts, delim)) { + } else if (utils$1.contains(verts, delim)) { repeat = "\u2223"; svgLabel = "vert"; viewBoxWidth = 333; - } else if (utils.contains(doubleVerts, delim)) { + } else if (utils$1.contains(doubleVerts, delim)) { repeat = "\u2225"; svgLabel = "doublevert"; viewBoxWidth = 556; @@ -11824,9 +11824,9 @@ var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes } // Sized delimiters are never centered. - if (utils.contains(stackLargeDelimiters, delim) || utils.contains(stackNeverDelimiters, delim)) { + if (utils$1.contains(stackLargeDelimiters, delim) || utils$1.contains(stackNeverDelimiters, delim)) { return makeLargeDelim(delim, size, false, options, mode, classes); - } else if (utils.contains(stackAlwaysDelimiters, delim)) { + } else if (utils$1.contains(stackAlwaysDelimiters, delim)) { return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); } else { throw new ParseError("Illegal delimiter: '" + delim + "'"); @@ -11976,9 +11976,9 @@ var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, var sequence; - if (utils.contains(stackNeverDelimiters, delim)) { + if (utils$1.contains(stackNeverDelimiters, delim)) { sequence = stackNeverDelimiterSequence; - } else if (utils.contains(stackLargeDelimiters, delim)) { + } else if (utils$1.contains(stackLargeDelimiters, delim)) { sequence = stackLargeDelimiterSequence; } else { sequence = stackAlwaysDelimiterSequence; @@ -12027,7 +12027,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); }; -var delimiter = { +var delimiter$1 = { sqrtImage: makeSqrtImage, sizedDelim: makeSizedDelim, sizeToMaxHeight: sizeToMaxHeight, @@ -12108,7 +12108,7 @@ var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbr function checkDelimiter(delim, context) { var symDelim = checkSymbolNodeType(delim); - if (symDelim && utils.contains(delimiters, symDelim.text)) { + if (symDelim && utils$1.contains(delimiters, symDelim.text)) { return symDelim; } else if (symDelim) { throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); @@ -12142,7 +12142,7 @@ defineFunction({ } // Use delimiter.sizedDelim to generate the delimiter. - return delimiter.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + return delimiter$1.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); }, mathmlBuilder: group => { var children = []; @@ -12164,7 +12164,7 @@ defineFunction({ } node.setAttribute("stretchy", "true"); - var size = makeEm(delimiter.sizeToMaxHeight[group.size]); + var size = makeEm(delimiter$1.sizeToMaxHeight[group.size]); node.setAttribute("minsize", size); node.setAttribute("maxsize", size); return node; @@ -12263,7 +12263,7 @@ defineFunction({ } else { // Otherwise, use leftRightDelim to generate the correct sized // delimiter. - leftDelim = delimiter.leftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + leftDelim = delimiter$1.leftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); } // Add it to the beginning of the expression @@ -12279,7 +12279,7 @@ defineFunction({ if (isMiddle) { // Apply the options that were active when \middle was called - inner[_i] = delimiter.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + inner[_i] = delimiter$1.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); } } } @@ -12290,7 +12290,7 @@ defineFunction({ rightDelim = makeNullDelimiter(options, ["mclose"]); } else { var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; - rightDelim = delimiter.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + rightDelim = delimiter$1.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); } // Add it to the end of the expression. @@ -12347,7 +12347,7 @@ defineFunction({ if (group.delim === ".") { middleDelim = makeNullDelimiter(options, []); } else { - middleDelim = delimiter.sizedDelim(group.delim, 1, options, group.mode, []); + middleDelim = delimiter$1.sizedDelim(group.delim, 1, options, group.mode, []); var isMiddle = { delim: group.delim, options @@ -12392,7 +12392,7 @@ var htmlBuilder$7 = (group, options) => { // the subject is a single character. This captures most of the // subjects that should get the "tall" treatment. - var isSingleChar = utils.isCharacterBox(group.body); + var isSingleChar = utils$1.isCharacterBox(group.body); if (label === "sout") { img = buildCommon.makeSpan(["stretchy", "sout"]); @@ -13195,7 +13195,7 @@ var htmlBuilder$6 = function htmlBuilder(group, options) { var sepwidth = void 0; if (c > 0 || group.hskipBeforeAndAfter) { - sepwidth = utils.deflt(colDescr.pregap, arraycolsep); + sepwidth = utils$1.deflt(colDescr.pregap, arraycolsep); if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); @@ -13233,7 +13233,7 @@ var htmlBuilder$6 = function htmlBuilder(group, options) { cols.push(col); if (c < nc - 1 || group.hskipBeforeAndAfter) { - sepwidth = utils.deflt(colDescr.postgap, arraycolsep); + sepwidth = utils$1.deflt(colDescr.postgap, arraycolsep); if (sepwidth !== 0) { colSep = buildCommon.makeSpan(["arraycolsep"], []); @@ -13801,7 +13801,7 @@ defineEnvironment({ }, handler(context) { - if (utils.contains(["gather", "gather*"], context.envName)) { + if (utils$1.contains(["gather", "gather*"], context.envName)) { validateAmsEnvironmentContext(context); } @@ -14024,7 +14024,7 @@ defineFunction({ parser } = _ref2; var body = args[0]; - var isCharacterBox = utils.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + var isCharacterBox = utils$1.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the // argument's bin|rel|ord status return { @@ -14239,7 +14239,7 @@ var htmlBuilder$4 = (group, options) => { if (group.leftDelim == null) { leftDelim = makeNullDelimiter(options, ["mopen"]); } else { - leftDelim = delimiter.customSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + leftDelim = delimiter$1.customSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); } if (group.continued) { @@ -14247,7 +14247,7 @@ var htmlBuilder$4 = (group, options) => { } else if (group.rightDelim == null) { rightDelim = makeNullDelimiter(options, ["mclose"]); } else { - rightDelim = delimiter.customSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + rightDelim = delimiter$1.customSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); } return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options); @@ -15395,7 +15395,7 @@ defineFunction({ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { base = buildCommon.makeSpan([], [base]); - var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup); + var subIsSingleCharacter = subGroup && utils$1.isCharacterBox(subGroup); var sub; var sup; // We manually have to handle the superscripts and subscripts. This, // aside from the kern calculations, is copied from supsub. @@ -15543,7 +15543,7 @@ var htmlBuilder$2 = (grp, options) => { var style = options.style; var large = false; - if (style.size === Style$1.DISPLAY.size && group.symbol && !utils.contains(noSuccessor, group.name)) { + if (style.size === Style$1.DISPLAY.size && group.symbol && !utils$1.contains(noSuccessor, group.name)) { // Most symbol operators get larger in displaystyle (rule 13) large = true; } @@ -15644,7 +15644,7 @@ var mathmlBuilder$1 = (group, options) => { // This is a symbol. Just add the symbol. node = new MathNode("mo", [makeText(group.name, group.mode)]); - if (utils.contains(noSuccessor, group.name)) { + if (utils$1.contains(noSuccessor, group.name)) { node.setAttribute("largeop", "false"); } } else if (group.body) { @@ -16533,7 +16533,7 @@ defineFunction({ span: img, ruleWidth, advanceWidth - } = delimiter.sqrtImage(minDelimiterHeight, options); + } = delimiter$1.sqrtImage(minDelimiterHeight, options); var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size if (delimDepth > inner.height + inner.depth + lineClearance) { @@ -16684,7 +16684,7 @@ var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { return _delegate ? htmlBuilder$1 : null; } else if (base.type === "accent") { - return utils.isCharacterBox(base.base) ? htmlBuilder$a : null; + return utils$1.isCharacterBox(base.base) ? htmlBuilder$a : null; } else if (base.type === "horizBrace") { var isSup = !group.sub; return isSup === base.isOver ? htmlBuilder$3 : null; @@ -16721,7 +16721,7 @@ defineFunctionBuilders({ var supShift = 0; var subShift = 0; - var isCharacterBox = valueBase && utils.isCharacterBox(valueBase); + var isCharacterBox = valueBase && utils$1.isCharacterBox(valueBase); if (valueSup) { var newOptions = options.havingStyle(options.style.sup()); @@ -18022,7 +18022,7 @@ defineMacro("\\dots", function (context) { } else if (next.slice(0, 4) === '\\not') { thedots = '\\dotsb'; } else if (next in symbols.math) { - if (utils.contains(['bin', 'rel'], symbols.math[next].group)) { + if (utils$1.contains(['bin', 'rel'], symbols.math[next].group)) { thedots = '\\dotsb'; } } @@ -20699,7 +20699,7 @@ var parseTree = function parseTree(toParse, settings) { * Parse and build an expression, and place that expression in the DOM node * given. */ -var render = function render(expression, baseNode, options) { +var render$2 = function render(expression, baseNode, options) { baseNode.textContent = ""; var node = renderToDomTree(expression, options).toNode(); baseNode.appendChild(node); @@ -20711,7 +20711,7 @@ if (typeof document !== "undefined") { if (document.compatMode !== "CSS1Compat") { typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); - render = function render() { + render$2 = function render() { throw new ParseError("KaTeX doesn't work in quirks mode."); }; } @@ -20794,7 +20794,7 @@ var katex = { * Renders the given LaTeX into an HTML+MathML combination, and adds * it as a child to the specified DOM node. */ - render, + render: render$2, /** * Renders the given LaTeX into an HTML+MathML combination string, @@ -20882,6 +20882,11 @@ var katex = { } }; +var katex$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: katex +}); + function extendedTables() { return { extensions: [ @@ -21224,7 +21229,15263 @@ function md2Html(md) { }); } }); + elDiv.querySelectorAll('pre.mermaid').forEach(function (el) { + console.log(el); + el.insertAdjacentHTML('beforebegin', '
'); + }); return elDiv.innerHTML; } -export { md2Html }; +function dedent(templ) { + var values = []; + for (var _i = 1; _i < arguments.length; _i++) { + values[_i - 1] = arguments[_i]; + } + var strings = Array.from(typeof templ === 'string' ? [templ] : templ); + strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, ''); + var indentLengths = strings.reduce(function (arr, str) { + var matches = str.match(/\n([\t ]+|(?!\s).)/g); + if (matches) { + return arr.concat(matches.map(function (match) { var _a, _b; return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0; })); + } + return arr; + }, []); + if (indentLengths.length) { + var pattern_1 = new RegExp("\n[\t ]{" + Math.min.apply(Math, indentLengths) + "}", 'g'); + strings = strings.map(function (str) { return str.replace(pattern_1, '\n'); }); + } + strings[0] = strings[0].replace(/^\r?\n/, ''); + var string = strings[0]; + values.forEach(function (value, i) { + var endentations = string.match(/(?:^|\n)( *)$/); + var endentation = endentations ? endentations[1] : ''; + var indentedValue = value; + if (typeof value === 'string' && value.includes('\n')) { + indentedValue = String(value) + .split('\n') + .map(function (str, i) { + return i === 0 ? str : "" + endentation + str; + }) + .join('\n'); + } + string += indentedValue + strings[i + 1]; + }); + return string; +} + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dayjs_min = {exports: {}}; + +(function (module, exports) { + !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t) -1; + } + // adapted from https://stackoverflow.com/a/29824550/2601552 + function decodeHtmlCharacters(str) { + var removedNullByte = str.replace(ctrlCharactersRegex, ""); + return removedNullByte.replace(htmlEntitiesRegex, function (match, dec) { + return String.fromCharCode(dec); + }); + } + function sanitizeUrl(url) { + if (!url) { + return exports.BLANK_URL; + } + var sanitizedUrl = decodeHtmlCharacters(url) + .replace(htmlCtrlEntityRegex, "") + .replace(ctrlCharactersRegex, "") + .trim(); + if (!sanitizedUrl) { + return exports.BLANK_URL; + } + if (isRelativeUrlWithoutProtocol(sanitizedUrl)) { + return sanitizedUrl; + } + var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex); + if (!urlSchemeParseResults) { + return sanitizedUrl; + } + var urlScheme = urlSchemeParseResults[0]; + if (invalidProtocolRegex.test(urlScheme)) { + return exports.BLANK_URL; + } + return sanitizedUrl; + } + exports.sanitizeUrl = sanitizeUrl; +} (dist)); + +var noop$1 = {value: () => {}}; + +function dispatch() { + for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) { + if (!(t = arguments[i] + "") || (t in _) || /[\s.]/.test(t)) throw new Error("illegal type: " + t); + _[t] = []; + } + return new Dispatch(_); +} + +function Dispatch(_) { + this._ = _; +} + +function parseTypenames$1(typenames, types) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t); + return {type: t, name: name}; + }); +} + +Dispatch.prototype = dispatch.prototype = { + constructor: Dispatch, + on: function(typename, callback) { + var _ = this._, + T = parseTypenames$1(typename + "", _), + t, + i = -1, + n = T.length; + + // If no callback was specified, return the callback of the given type and name. + if (arguments.length < 2) { + while (++i < n) if ((t = (typename = T[i]).type) && (t = get$1(_[t], typename.name))) return t; + return; + } + + // If a type was specified, set the callback for the given type and name. + // Otherwise, if a null callback was specified, remove callbacks of the given name. + if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); + while (++i < n) { + if (t = (typename = T[i]).type) _[t] = set$2(_[t], typename.name, callback); + else if (callback == null) for (t in _) _[t] = set$2(_[t], typename.name, null); + } + + return this; + }, + copy: function() { + var copy = {}, _ = this._; + for (var t in _) copy[t] = _[t].slice(); + return new Dispatch(copy); + }, + call: function(type, that) { + if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2]; + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + }, + apply: function(type, that, args) { + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + } +}; + +function get$1(type, name) { + for (var i = 0, n = type.length, c; i < n; ++i) { + if ((c = type[i]).name === name) { + return c.value; + } + } +} + +function set$2(type, name, callback) { + for (var i = 0, n = type.length; i < n; ++i) { + if (type[i].name === name) { + type[i] = noop$1, type = type.slice(0, i).concat(type.slice(i + 1)); + break; + } + } + if (callback != null) type.push({name: name, value: callback}); + return type; +} + +var xhtml = "http://www.w3.org/1999/xhtml"; + +var namespaces = { + svg: "http://www.w3.org/2000/svg", + xhtml: xhtml, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; + +function namespace(name) { + var prefix = name += "", i = prefix.indexOf(":"); + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name; // eslint-disable-line no-prototype-builtins +} + +function creatorInherit(name) { + return function() { + var document = this.ownerDocument, + uri = this.namespaceURI; + return uri === xhtml && document.documentElement.namespaceURI === xhtml + ? document.createElement(name) + : document.createElementNS(uri, name); + }; +} + +function creatorFixed(fullname) { + return function() { + return this.ownerDocument.createElementNS(fullname.space, fullname.local); + }; +} + +function creator(name) { + var fullname = namespace(name); + return (fullname.local + ? creatorFixed + : creatorInherit)(fullname); +} + +function none() {} + +function selector(selector) { + return selector == null ? none : function() { + return this.querySelector(selector); + }; +} + +function selection_select(select) { + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +// Given something array like (or null), returns something that is strictly an +// array. This is used to ensure that array-like objects passed to d3.selectAll +// or selection.selectAll are converted into proper arrays when creating a +// selection; we don’t ever want to create a selection backed by a live +// HTMLCollection or NodeList. However, note that selection.selectAll will use a +// static NodeList as a group, since it safely derived from querySelectorAll. +function array(x) { + return x == null ? [] : Array.isArray(x) ? x : Array.from(x); +} + +function empty() { + return []; +} + +function selectorAll(selector) { + return selector == null ? empty : function() { + return this.querySelectorAll(selector); + }; +} + +function arrayAll(select) { + return function() { + return array(select.apply(this, arguments)); + }; +} + +function selection_selectAll(select) { + if (typeof select === "function") select = arrayAll(select); + else select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + subgroups.push(select.call(node, node.__data__, i, group)); + parents.push(node); + } + } + } + + return new Selection$1(subgroups, parents); +} + +function matcher(selector) { + return function() { + return this.matches(selector); + }; +} + +function childMatcher(selector) { + return function(node) { + return node.matches(selector); + }; +} + +var find = Array.prototype.find; + +function childFind(match) { + return function() { + return find.call(this.children, match); + }; +} + +function childFirst() { + return this.firstElementChild; +} + +function selection_selectChild(match) { + return this.select(match == null ? childFirst + : childFind(typeof match === "function" ? match : childMatcher(match))); +} + +var filter = Array.prototype.filter; + +function children() { + return Array.from(this.children); +} + +function childrenFilter(match) { + return function() { + return filter.call(this.children, match); + }; +} + +function selection_selectChildren(match) { + return this.selectAll(match == null ? children + : childrenFilter(typeof match === "function" ? match : childMatcher(match))); +} + +function selection_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +function sparse(update) { + return new Array(update.length); +} + +function selection_enter() { + return new Selection$1(this._enter || this._groups.map(sparse), this._parents); +} + +function EnterNode(parent, datum) { + this.ownerDocument = parent.ownerDocument; + this.namespaceURI = parent.namespaceURI; + this._next = null; + this._parent = parent; + this.__data__ = datum; +} + +EnterNode.prototype = { + constructor: EnterNode, + appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, + insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, + querySelector: function(selector) { return this._parent.querySelector(selector); }, + querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } +}; + +function constant$2(x) { + return function() { + return x; + }; +} + +function bindIndex(parent, group, enter, update, exit, data) { + var i = 0, + node, + groupLength = group.length, + dataLength = data.length; + + // Put any non-null nodes that fit into update. + // Put any null nodes into enter. + // Put any remaining data into enter. + for (; i < dataLength; ++i) { + if (node = group[i]) { + node.__data__ = data[i]; + update[i] = node; + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Put any non-null nodes that don’t fit into exit. + for (; i < groupLength; ++i) { + if (node = group[i]) { + exit[i] = node; + } + } +} + +function bindKey(parent, group, enter, update, exit, data, key) { + var i, + node, + nodeByKeyValue = new Map, + groupLength = group.length, + dataLength = data.length, + keyValues = new Array(groupLength), + keyValue; + + // Compute the key for each node. + // If multiple nodes have the same key, the duplicates are added to exit. + for (i = 0; i < groupLength; ++i) { + if (node = group[i]) { + keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + ""; + if (nodeByKeyValue.has(keyValue)) { + exit[i] = node; + } else { + nodeByKeyValue.set(keyValue, node); + } + } + } + + // Compute the key for each datum. + // If there a node associated with this key, join and add it to update. + // If there is not (or the key is a duplicate), add it to enter. + for (i = 0; i < dataLength; ++i) { + keyValue = key.call(parent, data[i], i, data) + ""; + if (node = nodeByKeyValue.get(keyValue)) { + update[i] = node; + node.__data__ = data[i]; + nodeByKeyValue.delete(keyValue); + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Add any remaining nodes that were not bound to data to exit. + for (i = 0; i < groupLength; ++i) { + if ((node = group[i]) && (nodeByKeyValue.get(keyValues[i]) === node)) { + exit[i] = node; + } + } +} + +function datum(node) { + return node.__data__; +} + +function selection_data(value, key) { + if (!arguments.length) return Array.from(this, datum); + + var bind = key ? bindKey : bindIndex, + parents = this._parents, + groups = this._groups; + + if (typeof value !== "function") value = constant$2(value); + + for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { + var parent = parents[j], + group = groups[j], + groupLength = group.length, + data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), + dataLength = data.length, + enterGroup = enter[j] = new Array(dataLength), + updateGroup = update[j] = new Array(dataLength), + exitGroup = exit[j] = new Array(groupLength); + + bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); + + // Now connect the enter nodes to their following update node, such that + // appendChild can insert the materialized enter node before this node, + // rather than at the end of the parent node. + for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { + if (previous = enterGroup[i0]) { + if (i0 >= i1) i1 = i0 + 1; + while (!(next = updateGroup[i1]) && ++i1 < dataLength); + previous._next = next || null; + } + } + } + + update = new Selection$1(update, parents); + update._enter = enter; + update._exit = exit; + return update; +} + +// Given some data, this returns an array-like view of it: an object that +// exposes a length property and allows numeric indexing. Note that unlike +// selectAll, this isn’t worried about “live” collections because the resulting +// array will only be used briefly while data is being bound. (It is possible to +// cause the data to change while iterating by using a key function, but please +// don’t; we’d rather avoid a gratuitous copy.) +function arraylike(data) { + return typeof data === "object" && "length" in data + ? data // Array, TypedArray, NodeList, array-like + : Array.from(data); // Map, Set, iterable, string, or anything else +} + +function selection_exit() { + return new Selection$1(this._exit || this._groups.map(sparse), this._parents); +} + +function selection_join(onenter, onupdate, onexit) { + var enter = this.enter(), update = this, exit = this.exit(); + if (typeof onenter === "function") { + enter = onenter(enter); + if (enter) enter = enter.selection(); + } else { + enter = enter.append(onenter + ""); + } + if (onupdate != null) { + update = onupdate(update); + if (update) update = update.selection(); + } + if (onexit == null) exit.remove(); else onexit(exit); + return enter && update ? enter.merge(update).order() : update; +} + +function selection_merge(context) { + var selection = context.selection ? context.selection() : context; + + for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Selection$1(merges, this._parents); +} + +function selection_order() { + + for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { + for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { + if (node = group[i]) { + if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); + next = node; + } + } + } + + return this; +} + +function selection_sort(compare) { + if (!compare) compare = ascending; + + function compareNode(a, b) { + return a && b ? compare(a.__data__, b.__data__) : !a - !b; + } + + for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group[i]) { + sortgroup[i] = node; + } + } + sortgroup.sort(compareNode); + } + + return new Selection$1(sortgroups, this._parents).order(); +} + +function ascending(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function selection_call() { + var callback = arguments[0]; + arguments[0] = this; + callback.apply(null, arguments); + return this; +} + +function selection_nodes() { + return Array.from(this); +} + +function selection_node() { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { + var node = group[i]; + if (node) return node; + } + } + + return null; +} + +function selection_size() { + let size = 0; + for (const node of this) ++size; // eslint-disable-line no-unused-vars + return size; +} + +function selection_empty() { + return !this.node(); +} + +function selection_each(callback) { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) callback.call(node, node.__data__, i, group); + } + } + + return this; +} + +function attrRemove$1(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS$1(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant$1(name, value) { + return function() { + this.setAttribute(name, value); + }; +} + +function attrConstantNS$1(fullname, value) { + return function() { + this.setAttributeNS(fullname.space, fullname.local, value); + }; +} + +function attrFunction$1(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttribute(name); + else this.setAttribute(name, v); + }; +} + +function attrFunctionNS$1(fullname, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttributeNS(fullname.space, fullname.local); + else this.setAttributeNS(fullname.space, fullname.local, v); + }; +} + +function selection_attr(name, value) { + var fullname = namespace(name); + + if (arguments.length < 2) { + var node = this.node(); + return fullname.local + ? node.getAttributeNS(fullname.space, fullname.local) + : node.getAttribute(fullname); + } + + return this.each((value == null + ? (fullname.local ? attrRemoveNS$1 : attrRemove$1) : (typeof value === "function" + ? (fullname.local ? attrFunctionNS$1 : attrFunction$1) + : (fullname.local ? attrConstantNS$1 : attrConstant$1)))(fullname, value)); +} + +function defaultView(node) { + return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node + || (node.document && node) // node is a Window + || node.defaultView; // node is a Document +} + +function styleRemove$1(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant$1(name, value, priority) { + return function() { + this.style.setProperty(name, value, priority); + }; +} + +function styleFunction$1(name, value, priority) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.style.removeProperty(name); + else this.style.setProperty(name, v, priority); + }; +} + +function selection_style(name, value, priority) { + return arguments.length > 1 + ? this.each((value == null + ? styleRemove$1 : typeof value === "function" + ? styleFunction$1 + : styleConstant$1)(name, value, priority == null ? "" : priority)) + : styleValue(this.node(), name); +} + +function styleValue(node, name) { + return node.style.getPropertyValue(name) + || defaultView(node).getComputedStyle(node, null).getPropertyValue(name); +} + +function propertyRemove(name) { + return function() { + delete this[name]; + }; +} + +function propertyConstant(name, value) { + return function() { + this[name] = value; + }; +} + +function propertyFunction(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) delete this[name]; + else this[name] = v; + }; +} + +function selection_property(name, value) { + return arguments.length > 1 + ? this.each((value == null + ? propertyRemove : typeof value === "function" + ? propertyFunction + : propertyConstant)(name, value)) + : this.node()[name]; +} + +function classArray(string) { + return string.trim().split(/^|\s+/); +} + +function classList(node) { + return node.classList || new ClassList(node); +} + +function ClassList(node) { + this._node = node; + this._names = classArray(node.getAttribute("class") || ""); +} + +ClassList.prototype = { + add: function(name) { + var i = this._names.indexOf(name); + if (i < 0) { + this._names.push(name); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + remove: function(name) { + var i = this._names.indexOf(name); + if (i >= 0) { + this._names.splice(i, 1); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + contains: function(name) { + return this._names.indexOf(name) >= 0; + } +}; + +function classedAdd(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.add(names[i]); +} + +function classedRemove(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.remove(names[i]); +} + +function classedTrue(names) { + return function() { + classedAdd(this, names); + }; +} + +function classedFalse(names) { + return function() { + classedRemove(this, names); + }; +} + +function classedFunction(names, value) { + return function() { + (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); + }; +} + +function selection_classed(name, value) { + var names = classArray(name + ""); + + if (arguments.length < 2) { + var list = classList(this.node()), i = -1, n = names.length; + while (++i < n) if (!list.contains(names[i])) return false; + return true; + } + + return this.each((typeof value === "function" + ? classedFunction : value + ? classedTrue + : classedFalse)(names, value)); +} + +function textRemove() { + this.textContent = ""; +} + +function textConstant$1(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction$1(value) { + return function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + }; +} + +function selection_text(value) { + return arguments.length + ? this.each(value == null + ? textRemove : (typeof value === "function" + ? textFunction$1 + : textConstant$1)(value)) + : this.node().textContent; +} + +function htmlRemove() { + this.innerHTML = ""; +} + +function htmlConstant(value) { + return function() { + this.innerHTML = value; + }; +} + +function htmlFunction(value) { + return function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + }; +} + +function selection_html(value) { + return arguments.length + ? this.each(value == null + ? htmlRemove : (typeof value === "function" + ? htmlFunction + : htmlConstant)(value)) + : this.node().innerHTML; +} + +function raise() { + if (this.nextSibling) this.parentNode.appendChild(this); +} + +function selection_raise() { + return this.each(raise); +} + +function lower() { + if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); +} + +function selection_lower() { + return this.each(lower); +} + +function selection_append(name) { + var create = typeof name === "function" ? name : creator(name); + return this.select(function() { + return this.appendChild(create.apply(this, arguments)); + }); +} + +function constantNull() { + return null; +} + +function selection_insert(name, before) { + var create = typeof name === "function" ? name : creator(name), + select = before == null ? constantNull : typeof before === "function" ? before : selector(before); + return this.select(function() { + return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); + }); +} + +function remove() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); +} + +function selection_remove() { + return this.each(remove); +} + +function selection_cloneShallow() { + var clone = this.cloneNode(false), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_cloneDeep() { + var clone = this.cloneNode(true), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_clone(deep) { + return this.select(deep ? selection_cloneDeep : selection_cloneShallow); +} + +function selection_datum(value) { + return arguments.length + ? this.property("__data__", value) + : this.node().__data__; +} + +function contextListener(listener) { + return function(event) { + listener.call(this, event, this.__data__); + }; +} + +function parseTypenames(typenames) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + return {type: t, name: name}; + }); +} + +function onRemove(typename) { + return function() { + var on = this.__on; + if (!on) return; + for (var j = 0, i = -1, m = on.length, o; j < m; ++j) { + if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + } else { + on[++i] = o; + } + } + if (++i) on.length = i; + else delete this.__on; + }; +} + +function onAdd(typename, value, options) { + return function() { + var on = this.__on, o, listener = contextListener(value); + if (on) for (var j = 0, m = on.length; j < m; ++j) { + if ((o = on[j]).type === typename.type && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + this.addEventListener(o.type, o.listener = listener, o.options = options); + o.value = value; + return; + } + } + this.addEventListener(typename.type, listener, options); + o = {type: typename.type, name: typename.name, value: value, listener: listener, options: options}; + if (!on) this.__on = [o]; + else on.push(o); + }; +} + +function selection_on(typename, value, options) { + var typenames = parseTypenames(typename + ""), i, n = typenames.length, t; + + if (arguments.length < 2) { + var on = this.node().__on; + if (on) for (var j = 0, m = on.length, o; j < m; ++j) { + for (i = 0, o = on[j]; i < n; ++i) { + if ((t = typenames[i]).type === o.type && t.name === o.name) { + return o.value; + } + } + } + return; + } + + on = value ? onAdd : onRemove; + for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options)); + return this; +} + +function dispatchEvent(node, type, params) { + var window = defaultView(node), + event = window.CustomEvent; + + if (typeof event === "function") { + event = new event(type, params); + } else { + event = window.document.createEvent("Event"); + if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; + else event.initEvent(type, false, false); + } + + node.dispatchEvent(event); +} + +function dispatchConstant(type, params) { + return function() { + return dispatchEvent(this, type, params); + }; +} + +function dispatchFunction(type, params) { + return function() { + return dispatchEvent(this, type, params.apply(this, arguments)); + }; +} + +function selection_dispatch(type, params) { + return this.each((typeof params === "function" + ? dispatchFunction + : dispatchConstant)(type, params)); +} + +function* selection_iterator() { + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) yield node; + } + } +} + +var root$1 = [null]; + +function Selection$1(groups, parents) { + this._groups = groups; + this._parents = parents; +} + +function selection() { + return new Selection$1([[document.documentElement]], root$1); +} + +function selection_selection() { + return this; +} + +Selection$1.prototype = selection.prototype = { + constructor: Selection$1, + select: selection_select, + selectAll: selection_selectAll, + selectChild: selection_selectChild, + selectChildren: selection_selectChildren, + filter: selection_filter, + data: selection_data, + enter: selection_enter, + exit: selection_exit, + join: selection_join, + merge: selection_merge, + selection: selection_selection, + order: selection_order, + sort: selection_sort, + call: selection_call, + nodes: selection_nodes, + node: selection_node, + size: selection_size, + empty: selection_empty, + each: selection_each, + attr: selection_attr, + style: selection_style, + property: selection_property, + classed: selection_classed, + text: selection_text, + html: selection_html, + raise: selection_raise, + lower: selection_lower, + append: selection_append, + insert: selection_insert, + remove: selection_remove, + clone: selection_clone, + datum: selection_datum, + on: selection_on, + dispatch: selection_dispatch, + [Symbol.iterator]: selection_iterator +}; + +function select(selector) { + return typeof selector === "string" + ? new Selection$1([[document.querySelector(selector)]], [document.documentElement]) + : new Selection$1([[selector]], root$1); +} + +function define(constructor, factory, prototype) { + constructor.prototype = factory.prototype = prototype; + prototype.constructor = constructor; +} + +function extend$1(parent, definition) { + var prototype = Object.create(parent.prototype); + for (var key in definition) prototype[key] = definition[key]; + return prototype; +} + +function Color$1() {} + +var darker = 0.7; +var brighter = 1 / darker; + +var reI = "\\s*([+-]?\\d+)\\s*", + reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", + reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", + reHex = /^#([0-9a-f]{3,8})$/, + reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), + reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), + reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), + reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), + reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), + reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); + +var named = { + aliceblue: 0xf0f8ff, + antiquewhite: 0xfaebd7, + aqua: 0x00ffff, + aquamarine: 0x7fffd4, + azure: 0xf0ffff, + beige: 0xf5f5dc, + bisque: 0xffe4c4, + black: 0x000000, + blanchedalmond: 0xffebcd, + blue: 0x0000ff, + blueviolet: 0x8a2be2, + brown: 0xa52a2a, + burlywood: 0xdeb887, + cadetblue: 0x5f9ea0, + chartreuse: 0x7fff00, + chocolate: 0xd2691e, + coral: 0xff7f50, + cornflowerblue: 0x6495ed, + cornsilk: 0xfff8dc, + crimson: 0xdc143c, + cyan: 0x00ffff, + darkblue: 0x00008b, + darkcyan: 0x008b8b, + darkgoldenrod: 0xb8860b, + darkgray: 0xa9a9a9, + darkgreen: 0x006400, + darkgrey: 0xa9a9a9, + darkkhaki: 0xbdb76b, + darkmagenta: 0x8b008b, + darkolivegreen: 0x556b2f, + darkorange: 0xff8c00, + darkorchid: 0x9932cc, + darkred: 0x8b0000, + darksalmon: 0xe9967a, + darkseagreen: 0x8fbc8f, + darkslateblue: 0x483d8b, + darkslategray: 0x2f4f4f, + darkslategrey: 0x2f4f4f, + darkturquoise: 0x00ced1, + darkviolet: 0x9400d3, + deeppink: 0xff1493, + deepskyblue: 0x00bfff, + dimgray: 0x696969, + dimgrey: 0x696969, + dodgerblue: 0x1e90ff, + firebrick: 0xb22222, + floralwhite: 0xfffaf0, + forestgreen: 0x228b22, + fuchsia: 0xff00ff, + gainsboro: 0xdcdcdc, + ghostwhite: 0xf8f8ff, + gold: 0xffd700, + goldenrod: 0xdaa520, + gray: 0x808080, + green: 0x008000, + greenyellow: 0xadff2f, + grey: 0x808080, + honeydew: 0xf0fff0, + hotpink: 0xff69b4, + indianred: 0xcd5c5c, + indigo: 0x4b0082, + ivory: 0xfffff0, + khaki: 0xf0e68c, + lavender: 0xe6e6fa, + lavenderblush: 0xfff0f5, + lawngreen: 0x7cfc00, + lemonchiffon: 0xfffacd, + lightblue: 0xadd8e6, + lightcoral: 0xf08080, + lightcyan: 0xe0ffff, + lightgoldenrodyellow: 0xfafad2, + lightgray: 0xd3d3d3, + lightgreen: 0x90ee90, + lightgrey: 0xd3d3d3, + lightpink: 0xffb6c1, + lightsalmon: 0xffa07a, + lightseagreen: 0x20b2aa, + lightskyblue: 0x87cefa, + lightslategray: 0x778899, + lightslategrey: 0x778899, + lightsteelblue: 0xb0c4de, + lightyellow: 0xffffe0, + lime: 0x00ff00, + limegreen: 0x32cd32, + linen: 0xfaf0e6, + magenta: 0xff00ff, + maroon: 0x800000, + mediumaquamarine: 0x66cdaa, + mediumblue: 0x0000cd, + mediumorchid: 0xba55d3, + mediumpurple: 0x9370db, + mediumseagreen: 0x3cb371, + mediumslateblue: 0x7b68ee, + mediumspringgreen: 0x00fa9a, + mediumturquoise: 0x48d1cc, + mediumvioletred: 0xc71585, + midnightblue: 0x191970, + mintcream: 0xf5fffa, + mistyrose: 0xffe4e1, + moccasin: 0xffe4b5, + navajowhite: 0xffdead, + navy: 0x000080, + oldlace: 0xfdf5e6, + olive: 0x808000, + olivedrab: 0x6b8e23, + orange: 0xffa500, + orangered: 0xff4500, + orchid: 0xda70d6, + palegoldenrod: 0xeee8aa, + palegreen: 0x98fb98, + paleturquoise: 0xafeeee, + palevioletred: 0xdb7093, + papayawhip: 0xffefd5, + peachpuff: 0xffdab9, + peru: 0xcd853f, + pink: 0xffc0cb, + plum: 0xdda0dd, + powderblue: 0xb0e0e6, + purple: 0x800080, + rebeccapurple: 0x663399, + red: 0xff0000, + rosybrown: 0xbc8f8f, + royalblue: 0x4169e1, + saddlebrown: 0x8b4513, + salmon: 0xfa8072, + sandybrown: 0xf4a460, + seagreen: 0x2e8b57, + seashell: 0xfff5ee, + sienna: 0xa0522d, + silver: 0xc0c0c0, + skyblue: 0x87ceeb, + slateblue: 0x6a5acd, + slategray: 0x708090, + slategrey: 0x708090, + snow: 0xfffafa, + springgreen: 0x00ff7f, + steelblue: 0x4682b4, + tan: 0xd2b48c, + teal: 0x008080, + thistle: 0xd8bfd8, + tomato: 0xff6347, + turquoise: 0x40e0d0, + violet: 0xee82ee, + wheat: 0xf5deb3, + white: 0xffffff, + whitesmoke: 0xf5f5f5, + yellow: 0xffff00, + yellowgreen: 0x9acd32 +}; + +define(Color$1, color, { + copy(channels) { + return Object.assign(new this.constructor, this, channels); + }, + displayable() { + return this.rgb().displayable(); + }, + hex: color_formatHex, // Deprecated! Use color.formatHex. + formatHex: color_formatHex, + formatHex8: color_formatHex8, + formatHsl: color_formatHsl, + formatRgb: color_formatRgb, + toString: color_formatRgb +}); + +function color_formatHex() { + return this.rgb().formatHex(); +} + +function color_formatHex8() { + return this.rgb().formatHex8(); +} + +function color_formatHsl() { + return hslConvert(this).formatHsl(); +} + +function color_formatRgb() { + return this.rgb().formatRgb(); +} + +function color(format) { + var m, l; + format = (format + "").trim().toLowerCase(); + return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000 + : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00 + : l === 8 ? rgba$1(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000 + : l === 4 ? rgba$1((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000 + : null) // invalid hex + : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) + : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) + : (m = reRgbaInteger.exec(format)) ? rgba$1(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) + : (m = reRgbaPercent.exec(format)) ? rgba$1(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) + : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) + : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) + : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins + : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) + : null; +} + +function rgbn(n) { + return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); +} + +function rgba$1(r, g, b, a) { + if (a <= 0) r = g = b = NaN; + return new Rgb(r, g, b, a); +} + +function rgbConvert(o) { + if (!(o instanceof Color$1)) o = color(o); + if (!o) return new Rgb; + o = o.rgb(); + return new Rgb(o.r, o.g, o.b, o.opacity); +} + +function rgb(r, g, b, opacity) { + return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); +} + +function Rgb(r, g, b, opacity) { + this.r = +r; + this.g = +g; + this.b = +b; + this.opacity = +opacity; +} + +define(Rgb, rgb, extend$1(Color$1, { + brighter(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + darker(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + rgb() { + return this; + }, + clamp() { + return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); + }, + displayable() { + return (-0.5 <= this.r && this.r < 255.5) + && (-0.5 <= this.g && this.g < 255.5) + && (-0.5 <= this.b && this.b < 255.5) + && (0 <= this.opacity && this.opacity <= 1); + }, + hex: rgb_formatHex, // Deprecated! Use color.formatHex. + formatHex: rgb_formatHex, + formatHex8: rgb_formatHex8, + formatRgb: rgb_formatRgb, + toString: rgb_formatRgb +})); + +function rgb_formatHex() { + return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; +} + +function rgb_formatHex8() { + return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; +} + +function rgb_formatRgb() { + const a = clampa(this.opacity); + return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`; +} + +function clampa(opacity) { + return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); +} + +function clampi(value) { + return Math.max(0, Math.min(255, Math.round(value) || 0)); +} + +function hex(value) { + value = clampi(value); + return (value < 16 ? "0" : "") + value.toString(16); +} + +function hsla(h, s, l, a) { + if (a <= 0) h = s = l = NaN; + else if (l <= 0 || l >= 1) h = s = NaN; + else if (s <= 0) h = NaN; + return new Hsl(h, s, l, a); +} + +function hslConvert(o) { + if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); + if (!(o instanceof Color$1)) o = color(o); + if (!o) return new Hsl; + if (o instanceof Hsl) return o; + o = o.rgb(); + var r = o.r / 255, + g = o.g / 255, + b = o.b / 255, + min = Math.min(r, g, b), + max = Math.max(r, g, b), + h = NaN, + s = max - min, + l = (max + min) / 2; + if (s) { + if (r === max) h = (g - b) / s + (g < b) * 6; + else if (g === max) h = (b - r) / s + 2; + else h = (r - g) / s + 4; + s /= l < 0.5 ? max + min : 2 - max - min; + h *= 60; + } else { + s = l > 0 && l < 1 ? 0 : h; + } + return new Hsl(h, s, l, o.opacity); +} + +function hsl(h, s, l, opacity) { + return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); +} + +function Hsl(h, s, l, opacity) { + this.h = +h; + this.s = +s; + this.l = +l; + this.opacity = +opacity; +} + +define(Hsl, hsl, extend$1(Color$1, { + brighter(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + darker(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + rgb() { + var h = this.h % 360 + (this.h < 0) * 360, + s = isNaN(h) || isNaN(this.s) ? 0 : this.s, + l = this.l, + m2 = l + (l < 0.5 ? l : 1 - l) * s, + m1 = 2 * l - m2; + return new Rgb( + hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), + hsl2rgb(h, m1, m2), + hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), + this.opacity + ); + }, + clamp() { + return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); + }, + displayable() { + return (0 <= this.s && this.s <= 1 || isNaN(this.s)) + && (0 <= this.l && this.l <= 1) + && (0 <= this.opacity && this.opacity <= 1); + }, + formatHsl() { + const a = clampa(this.opacity); + return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`; + } +})); + +function clamph(value) { + value = (value || 0) % 360; + return value < 0 ? value + 360 : value; +} + +function clampt(value) { + return Math.max(0, Math.min(1, value || 0)); +} + +/* From FvD 13.37, CSS Color Module Level 3 */ +function hsl2rgb(h, m1, m2) { + return (h < 60 ? m1 + (m2 - m1) * h / 60 + : h < 180 ? m2 + : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 + : m1) * 255; +} + +var constant$1 = x => () => x; + +function linear(a, d) { + return function(t) { + return a + t * d; + }; +} + +function exponential(a, b, y) { + return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { + return Math.pow(a + t * b, y); + }; +} + +function hue(a, b) { + var d = b - a; + return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$1(isNaN(a) ? b : a); +} + +function gamma(y) { + return (y = +y) === 1 ? nogamma : function(a, b) { + return b - a ? exponential(a, b, y) : constant$1(isNaN(a) ? b : a); + }; +} + +function nogamma(a, b) { + var d = b - a; + return d ? linear(a, d) : constant$1(isNaN(a) ? b : a); +} + +var interpolateRgb = (function rgbGamma(y) { + var color = gamma(y); + + function rgb$1(start, end) { + var r = color((start = rgb(start)).r, (end = rgb(end)).r), + g = color(start.g, end.g), + b = color(start.b, end.b), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.r = r(t); + start.g = g(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; + } + + rgb$1.gamma = rgbGamma; + + return rgb$1; +})(1); + +function interpolateNumber(a, b) { + return a = +a, b = +b, function(t) { + return a * (1 - t) + b * t; + }; +} + +var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, + reB = new RegExp(reA.source, "g"); + +function zero(b) { + return function() { + return b; + }; +} + +function one(b) { + return function(t) { + return b(t) + ""; + }; +} + +function interpolateString(a, b) { + var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b + am, // current match in a + bm, // current match in b + bs, // string preceding current number in b, if any + i = -1, // index in s + s = [], // string constants and placeholders + q = []; // number interpolators + + // Coerce inputs to strings. + a = a + "", b = b + ""; + + // Interpolate pairs of numbers in a & b. + while ((am = reA.exec(a)) + && (bm = reB.exec(b))) { + if ((bs = bm.index) > bi) { // a string precedes the next number in b + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match + if (s[i]) s[i] += bm; // coalesce with previous string + else s[++i] = bm; + } else { // interpolate non-matching numbers + s[++i] = null; + q.push({i: i, x: interpolateNumber(am, bm)}); + } + bi = reB.lastIndex; + } + + // Add remains of b. + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + + // Special optimization for only a single match. + // Otherwise, interpolate each of the numbers and rejoin the string. + return s.length < 2 ? (q[0] + ? one(q[0].x) + : zero(b)) + : (b = q.length, function(t) { + for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); +} + +var degrees = 180 / Math.PI; + +var identity$1 = { + translateX: 0, + translateY: 0, + rotate: 0, + skewX: 0, + scaleX: 1, + scaleY: 1 +}; + +function decompose(a, b, c, d, e, f) { + var scaleX, scaleY, skewX; + if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX; + if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX; + if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY; + if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX; + return { + translateX: e, + translateY: f, + rotate: Math.atan2(b, a) * degrees, + skewX: Math.atan(skewX) * degrees, + scaleX: scaleX, + scaleY: scaleY + }; +} + +var svgNode; + +/* eslint-disable no-undef */ +function parseCss(value) { + const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); + return m.isIdentity ? identity$1 : decompose(m.a, m.b, m.c, m.d, m.e, m.f); +} + +function parseSvg(value) { + if (value == null) return identity$1; + if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); + svgNode.setAttribute("transform", value); + if (!(value = svgNode.transform.baseVal.consolidate())) return identity$1; + value = value.matrix; + return decompose(value.a, value.b, value.c, value.d, value.e, value.f); +} + +function interpolateTransform(parse, pxComma, pxParen, degParen) { + + function pop(s) { + return s.length ? s.pop() + " " : ""; + } + + function translate(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push("translate(", null, pxComma, null, pxParen); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb || yb) { + s.push("translate(" + xb + pxComma + yb + pxParen); + } + } + + function rotate(a, b, s, q) { + if (a !== b) { + if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path + q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "rotate(" + b + degParen); + } + } + + function skewX(a, b, s, q) { + if (a !== b) { + q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "skewX(" + b + degParen); + } + } + + function scale(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push(pop(s) + "scale(", null, ",", null, ")"); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb !== 1 || yb !== 1) { + s.push(pop(s) + "scale(" + xb + "," + yb + ")"); + } + } + + return function(a, b) { + var s = [], // string constants and placeholders + q = []; // number interpolators + a = parse(a), b = parse(b); + translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); + rotate(a.rotate, b.rotate, s, q); + skewX(a.skewX, b.skewX, s, q); + scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); + a = b = null; // gc + return function(t) { + var i = -1, n = q.length, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + }; +} + +var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); +var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); + +var frame = 0, // is an animation frame pending? + timeout$1 = 0, // is a timeout pending? + interval = 0, // are any timers active? + pokeDelay = 1000, // how frequently we check for clock skew + taskHead, + taskTail, + clockLast = 0, + clockNow = 0, + clockSkew = 0, + clock = typeof performance === "object" && performance.now ? performance : Date, + setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); }; + +function now() { + return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); +} + +function clearNow() { + clockNow = 0; +} + +function Timer() { + this._call = + this._time = + this._next = null; +} + +Timer.prototype = timer.prototype = { + constructor: Timer, + restart: function(callback, delay, time) { + if (typeof callback !== "function") throw new TypeError("callback is not a function"); + time = (time == null ? now() : +time) + (delay == null ? 0 : +delay); + if (!this._next && taskTail !== this) { + if (taskTail) taskTail._next = this; + else taskHead = this; + taskTail = this; + } + this._call = callback; + this._time = time; + sleep(); + }, + stop: function() { + if (this._call) { + this._call = null; + this._time = Infinity; + sleep(); + } + } +}; + +function timer(callback, delay, time) { + var t = new Timer; + t.restart(callback, delay, time); + return t; +} + +function timerFlush() { + now(); // Get the current time, if not already set. + ++frame; // Pretend we’ve set an alarm, if we haven’t already. + var t = taskHead, e; + while (t) { + if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e); + t = t._next; + } + --frame; +} + +function wake() { + clockNow = (clockLast = clock.now()) + clockSkew; + frame = timeout$1 = 0; + try { + timerFlush(); + } finally { + frame = 0; + nap(); + clockNow = 0; + } +} + +function poke() { + var now = clock.now(), delay = now - clockLast; + if (delay > pokeDelay) clockSkew -= delay, clockLast = now; +} + +function nap() { + var t0, t1 = taskHead, t2, time = Infinity; + while (t1) { + if (t1._call) { + if (time > t1._time) time = t1._time; + t0 = t1, t1 = t1._next; + } else { + t2 = t1._next, t1._next = null; + t1 = t0 ? t0._next = t2 : taskHead = t2; + } + } + taskTail = t0; + sleep(time); +} + +function sleep(time) { + if (frame) return; // Soonest alarm already set, or will be. + if (timeout$1) timeout$1 = clearTimeout(timeout$1); + var delay = time - clockNow; // Strictly less than if we recomputed clockNow. + if (delay > 24) { + if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew); + if (interval) interval = clearInterval(interval); + } else { + if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay); + frame = 1, setFrame(wake); + } +} + +function timeout(callback, delay, time) { + var t = new Timer; + delay = delay == null ? 0 : +delay; + t.restart(elapsed => { + t.stop(); + callback(elapsed + delay); + }, delay, time); + return t; +} + +var emptyOn = dispatch("start", "end", "cancel", "interrupt"); +var emptyTween = []; + +var CREATED = 0; +var SCHEDULED = 1; +var STARTING = 2; +var STARTED = 3; +var RUNNING = 4; +var ENDING = 5; +var ENDED = 6; + +function schedule(node, name, id, index, group, timing) { + var schedules = node.__transition; + if (!schedules) node.__transition = {}; + else if (id in schedules) return; + create$1(node, id, { + name: name, + index: index, // For context during callback. + group: group, // For context during callback. + on: emptyOn, + tween: emptyTween, + time: timing.time, + delay: timing.delay, + duration: timing.duration, + ease: timing.ease, + timer: null, + state: CREATED + }); +} + +function init$1(node, id) { + var schedule = get(node, id); + if (schedule.state > CREATED) throw new Error("too late; already scheduled"); + return schedule; +} + +function set$1(node, id) { + var schedule = get(node, id); + if (schedule.state > STARTED) throw new Error("too late; already running"); + return schedule; +} + +function get(node, id) { + var schedule = node.__transition; + if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found"); + return schedule; +} + +function create$1(node, id, self) { + var schedules = node.__transition, + tween; + + // Initialize the self timer when the transition is created. + // Note the actual delay is not known until the first callback! + schedules[id] = self; + self.timer = timer(schedule, 0, self.time); + + function schedule(elapsed) { + self.state = SCHEDULED; + self.timer.restart(start, self.delay, self.time); + + // If the elapsed delay is less than our first sleep, start immediately. + if (self.delay <= elapsed) start(elapsed - self.delay); + } + + function start(elapsed) { + var i, j, n, o; + + // If the state is not SCHEDULED, then we previously errored on start. + if (self.state !== SCHEDULED) return stop(); + + for (i in schedules) { + o = schedules[i]; + if (o.name !== self.name) continue; + + // While this element already has a starting transition during this frame, + // defer starting an interrupting transition until that transition has a + // chance to tick (and possibly end); see d3/d3-transition#54! + if (o.state === STARTED) return timeout(start); + + // Interrupt the active transition, if any. + if (o.state === RUNNING) { + o.state = ENDED; + o.timer.stop(); + o.on.call("interrupt", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + + // Cancel any pre-empted transitions. + else if (+i < id) { + o.state = ENDED; + o.timer.stop(); + o.on.call("cancel", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + } + + // Defer the first tick to end of the current frame; see d3/d3#1576. + // Note the transition may be canceled after start and before the first tick! + // Note this must be scheduled before the start event; see d3/d3-transition#16! + // Assuming this is successful, subsequent callbacks go straight to tick. + timeout(function() { + if (self.state === STARTED) { + self.state = RUNNING; + self.timer.restart(tick, self.delay, self.time); + tick(elapsed); + } + }); + + // Dispatch the start event. + // Note this must be done before the tween are initialized. + self.state = STARTING; + self.on.call("start", node, node.__data__, self.index, self.group); + if (self.state !== STARTING) return; // interrupted + self.state = STARTED; + + // Initialize the tween, deleting null tween. + tween = new Array(n = self.tween.length); + for (i = 0, j = -1; i < n; ++i) { + if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) { + tween[++j] = o; + } + } + tween.length = j + 1; + } + + function tick(elapsed) { + var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1), + i = -1, + n = tween.length; + + while (++i < n) { + tween[i].call(node, t); + } + + // Dispatch the end event. + if (self.state === ENDING) { + self.on.call("end", node, node.__data__, self.index, self.group); + stop(); + } + } + + function stop() { + self.state = ENDED; + self.timer.stop(); + delete schedules[id]; + for (var i in schedules) return; // eslint-disable-line no-unused-vars + delete node.__transition; + } +} + +function interrupt(node, name) { + var schedules = node.__transition, + schedule, + active, + empty = true, + i; + + if (!schedules) return; + + name = name == null ? null : name + ""; + + for (i in schedules) { + if ((schedule = schedules[i]).name !== name) { empty = false; continue; } + active = schedule.state > STARTING && schedule.state < ENDING; + schedule.state = ENDED; + schedule.timer.stop(); + schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group); + delete schedules[i]; + } + + if (empty) delete node.__transition; +} + +function selection_interrupt(name) { + return this.each(function() { + interrupt(this, name); + }); +} + +function tweenRemove(id, name) { + var tween0, tween1; + return function() { + var schedule = set$1(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = tween0 = tween; + for (var i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1 = tween1.slice(); + tween1.splice(i, 1); + break; + } + } + } + + schedule.tween = tween1; + }; +} + +function tweenFunction(id, name, value) { + var tween0, tween1; + if (typeof value !== "function") throw new Error; + return function() { + var schedule = set$1(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = (tween0 = tween).slice(); + for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1[i] = t; + break; + } + } + if (i === n) tween1.push(t); + } + + schedule.tween = tween1; + }; +} + +function transition_tween(name, value) { + var id = this._id; + + name += ""; + + if (arguments.length < 2) { + var tween = get(this.node(), id).tween; + for (var i = 0, n = tween.length, t; i < n; ++i) { + if ((t = tween[i]).name === name) { + return t.value; + } + } + return null; + } + + return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value)); +} + +function tweenValue(transition, name, value) { + var id = transition._id; + + transition.each(function() { + var schedule = set$1(this, id); + (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments); + }); + + return function(node) { + return get(node, id).value[name]; + }; +} + +function interpolate(a, b) { + var c; + return (typeof b === "number" ? interpolateNumber + : b instanceof color ? interpolateRgb + : (c = color(b)) ? (b = c, interpolateRgb) + : interpolateString)(a, b); +} + +function attrRemove(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttribute(name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrConstantNS(fullname, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttributeNS(fullname.space, fullname.local); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttribute(name); + string0 = this.getAttribute(name); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function attrFunctionNS(fullname, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local); + string0 = this.getAttributeNS(fullname.space, fullname.local); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function transition_attr(name, value) { + var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate; + return this.attrTween(name, typeof value === "function" + ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value)) + : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname) + : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value)); +} + +function attrInterpolate(name, i) { + return function(t) { + this.setAttribute(name, i.call(this, t)); + }; +} + +function attrInterpolateNS(fullname, i) { + return function(t) { + this.setAttributeNS(fullname.space, fullname.local, i.call(this, t)); + }; +} + +function attrTweenNS(fullname, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i); + return t0; + } + tween._value = value; + return tween; +} + +function attrTween(name, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_attrTween(name, value) { + var key = "attr." + name; + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + var fullname = namespace(name); + return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value)); +} + +function delayFunction(id, value) { + return function() { + init$1(this, id).delay = +value.apply(this, arguments); + }; +} + +function delayConstant(id, value) { + return value = +value, function() { + init$1(this, id).delay = value; + }; +} + +function transition_delay(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? delayFunction + : delayConstant)(id, value)) + : get(this.node(), id).delay; +} + +function durationFunction(id, value) { + return function() { + set$1(this, id).duration = +value.apply(this, arguments); + }; +} + +function durationConstant(id, value) { + return value = +value, function() { + set$1(this, id).duration = value; + }; +} + +function transition_duration(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? durationFunction + : durationConstant)(id, value)) + : get(this.node(), id).duration; +} + +function easeConstant(id, value) { + if (typeof value !== "function") throw new Error; + return function() { + set$1(this, id).ease = value; + }; +} + +function transition_ease(value) { + var id = this._id; + + return arguments.length + ? this.each(easeConstant(id, value)) + : get(this.node(), id).ease; +} + +function easeVarying(id, value) { + return function() { + var v = value.apply(this, arguments); + if (typeof v !== "function") throw new Error; + set$1(this, id).ease = v; + }; +} + +function transition_easeVarying(value) { + if (typeof value !== "function") throw new Error; + return this.each(easeVarying(this._id, value)); +} + +function transition_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Transition(subgroups, this._parents, this._name, this._id); +} + +function transition_merge(transition) { + if (transition._id !== this._id) throw new Error; + + for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Transition(merges, this._parents, this._name, this._id); +} + +function start(name) { + return (name + "").trim().split(/^|\s+/).every(function(t) { + var i = t.indexOf("."); + if (i >= 0) t = t.slice(0, i); + return !t || t === "start"; + }); +} + +function onFunction(id, name, listener) { + var on0, on1, sit = start(name) ? init$1 : set$1; + return function() { + var schedule = sit(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener); + + schedule.on = on1; + }; +} + +function transition_on(name, listener) { + var id = this._id; + + return arguments.length < 2 + ? get(this.node(), id).on.on(name) + : this.each(onFunction(id, name, listener)); +} + +function removeFunction(id) { + return function() { + var parent = this.parentNode; + for (var i in this.__transition) if (+i !== id) return; + if (parent) parent.removeChild(this); + }; +} + +function transition_remove() { + return this.on("end.remove", removeFunction(this._id)); +} + +function transition_select(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + schedule(subgroup[i], name, id, i, subgroup, get(node, id)); + } + } + } + + return new Transition(subgroups, this._parents, name, id); +} + +function transition_selectAll(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + for (var children = select.call(node, node.__data__, i, group), child, inherit = get(node, id), k = 0, l = children.length; k < l; ++k) { + if (child = children[k]) { + schedule(child, name, id, k, children, inherit); + } + } + subgroups.push(children); + parents.push(node); + } + } + } + + return new Transition(subgroups, parents, name, id); +} + +var Selection = selection.prototype.constructor; + +function transition_selection() { + return new Selection(this._groups, this._parents); +} + +function styleNull(name, interpolate) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + string1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, string10 = string1); + }; +} + +function styleRemove(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = styleValue(this, name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function styleFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + value1 = value(this), + string1 = value1 + ""; + if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function styleMaybeRemove(id, name) { + var on0, on1, listener0, key = "style." + name, event = "end." + key, remove; + return function() { + var schedule = set$1(this, id), + on = schedule.on, + listener = schedule.value[key] == null ? remove || (remove = styleRemove(name)) : undefined; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener); + + schedule.on = on1; + }; +} + +function transition_style(name, value, priority) { + var i = (name += "") === "transform" ? interpolateTransformCss : interpolate; + return value == null ? this + .styleTween(name, styleNull(name, i)) + .on("end.style." + name, styleRemove(name)) + : typeof value === "function" ? this + .styleTween(name, styleFunction(name, i, tweenValue(this, "style." + name, value))) + .each(styleMaybeRemove(this._id, name)) + : this + .styleTween(name, styleConstant(name, i, value), priority) + .on("end.style." + name, null); +} + +function styleInterpolate(name, i, priority) { + return function(t) { + this.style.setProperty(name, i.call(this, t), priority); + }; +} + +function styleTween(name, value, priority) { + var t, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority); + return t; + } + tween._value = value; + return tween; +} + +function transition_styleTween(name, value, priority) { + var key = "style." + (name += ""); + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, styleTween(name, value, priority == null ? "" : priority)); +} + +function textConstant(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction(value) { + return function() { + var value1 = value(this); + this.textContent = value1 == null ? "" : value1; + }; +} + +function transition_text(value) { + return this.tween("text", typeof value === "function" + ? textFunction(tweenValue(this, "text", value)) + : textConstant(value == null ? "" : value + "")); +} + +function textInterpolate(i) { + return function(t) { + this.textContent = i.call(this, t); + }; +} + +function textTween(value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && textInterpolate(i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_textTween(value) { + var key = "text"; + if (arguments.length < 1) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, textTween(value)); +} + +function transition_transition() { + var name = this._name, + id0 = this._id, + id1 = newId(); + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + var inherit = get(node, id0); + schedule(node, name, id1, i, group, { + time: inherit.time + inherit.delay + inherit.duration, + delay: 0, + duration: inherit.duration, + ease: inherit.ease + }); + } + } + } + + return new Transition(groups, this._parents, name, id1); +} + +function transition_end() { + var on0, on1, that = this, id = that._id, size = that.size(); + return new Promise(function(resolve, reject) { + var cancel = {value: reject}, + end = {value: function() { if (--size === 0) resolve(); }}; + + that.each(function() { + var schedule = set$1(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) { + on1 = (on0 = on).copy(); + on1._.cancel.push(cancel); + on1._.interrupt.push(cancel); + on1._.end.push(end); + } + + schedule.on = on1; + }); + + // The selection was empty, resolve end immediately + if (size === 0) resolve(); + }); +} + +var id$m = 0; + +function Transition(groups, parents, name, id) { + this._groups = groups; + this._parents = parents; + this._name = name; + this._id = id; +} + +function newId() { + return ++id$m; +} + +var selection_prototype = selection.prototype; + +Transition.prototype = { + constructor: Transition, + select: transition_select, + selectAll: transition_selectAll, + selectChild: selection_prototype.selectChild, + selectChildren: selection_prototype.selectChildren, + filter: transition_filter, + merge: transition_merge, + selection: transition_selection, + transition: transition_transition, + call: selection_prototype.call, + nodes: selection_prototype.nodes, + node: selection_prototype.node, + size: selection_prototype.size, + empty: selection_prototype.empty, + each: selection_prototype.each, + on: transition_on, + attr: transition_attr, + attrTween: transition_attrTween, + style: transition_style, + styleTween: transition_styleTween, + text: transition_text, + textTween: transition_textTween, + remove: transition_remove, + tween: transition_tween, + delay: transition_delay, + duration: transition_duration, + ease: transition_ease, + easeVarying: transition_easeVarying, + end: transition_end, + [Symbol.iterator]: selection_prototype[Symbol.iterator] +}; + +function cubicInOut(t) { + return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +} + +var defaultTiming = { + time: null, // Set on use. + delay: 0, + duration: 250, + ease: cubicInOut +}; + +function inherit(node, id) { + var timing; + while (!(timing = node.__transition) || !(timing = timing[id])) { + if (!(node = node.parentNode)) { + throw new Error(`transition ${id} not found`); + } + } + return timing; +} + +function selection_transition(name) { + var id, + timing; + + if (name instanceof Transition) { + id = name._id, name = name._name; + } else { + id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + ""; + } + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + schedule(node, name, id, i, group, timing || inherit(node, id)); + } + } + } + + return new Transition(groups, this._parents, name, id); +} + +selection.prototype.interrupt = selection_interrupt; +selection.prototype.transition = selection_transition; + +const abs$1 = Math.abs; +const atan2 = Math.atan2; +const cos = Math.cos; +const max = Math.max; +const min = Math.min; +const sin = Math.sin; +const sqrt = Math.sqrt; + +const epsilon = 1e-12; +const pi = Math.PI; +const halfPi = pi / 2; +const tau = 2 * pi; + +function acos(x) { + return x > 1 ? 0 : x < -1 ? pi : Math.acos(x); +} + +function asin(x) { + return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x); +} + +function Linear(context) { + this._context = context; +} + +Linear.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: this._context.lineTo(x, y); break; + } + } +}; + +function curveLinear(context) { + return new Linear(context); +} + +class Bump { + constructor(context, x) { + this._context = context; + this._x = x; + } + areaStart() { + this._line = 0; + } + areaEnd() { + this._line = NaN; + } + lineStart() { + this._point = 0; + } + lineEnd() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + } + point(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: { + this._point = 1; + if (this._line) this._context.lineTo(x, y); + else this._context.moveTo(x, y); + break; + } + case 1: this._point = 2; // falls through + default: { + if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y); + else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y); + break; + } + } + this._x0 = x, this._y0 = y; + } +} + +function bumpX(context) { + return new Bump(context, true); +} + +function bumpY(context) { + return new Bump(context, false); +} + +function noop() {} + +function point$3(that, x, y) { + that._context.bezierCurveTo( + (2 * that._x0 + that._x1) / 3, + (2 * that._y0 + that._y1) / 3, + (that._x0 + 2 * that._x1) / 3, + (that._y0 + 2 * that._y1) / 3, + (that._x0 + 4 * that._x1 + x) / 6, + (that._y0 + 4 * that._y1 + y) / 6 + ); +} + +function Basis(context) { + this._context = context; +} + +Basis.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 3: point$3(this, this._x1, this._y1); // falls through + case 2: this._context.lineTo(this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasis(context) { + return new Basis(context); +} + +function BasisClosed(context) { + this._context = context; +} + +BasisClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x2, this._y2); + this._context.closePath(); + break; + } + case 2: { + this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3); + this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x2, this._y2); + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x2 = x, this._y2 = y; break; + case 1: this._point = 2; this._x3 = x, this._y3 = y; break; + case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6); break; + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasisClosed(context) { + return new BasisClosed(context); +} + +function BasisOpen(context) { + this._context = context; +} + +BasisOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = NaN; + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break; + case 3: this._point = 4; // falls through + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasisOpen(context) { + return new BasisOpen(context); +} + +function Bundle(context, beta) { + this._basis = new Basis(context); + this._beta = beta; +} + +Bundle.prototype = { + lineStart: function() { + this._x = []; + this._y = []; + this._basis.lineStart(); + }, + lineEnd: function() { + var x = this._x, + y = this._y, + j = x.length - 1; + + if (j > 0) { + var x0 = x[0], + y0 = y[0], + dx = x[j] - x0, + dy = y[j] - y0, + i = -1, + t; + + while (++i <= j) { + t = i / j; + this._basis.point( + this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), + this._beta * y[i] + (1 - this._beta) * (y0 + t * dy) + ); + } + } + + this._x = this._y = null; + this._basis.lineEnd(); + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +var curveBundle = (function custom(beta) { + + function bundle(context) { + return beta === 1 ? new Basis(context) : new Bundle(context, beta); + } + + bundle.beta = function(beta) { + return custom(+beta); + }; + + return bundle; +})(0.85); + +function point$2(that, x, y) { + that._context.bezierCurveTo( + that._x1 + that._k * (that._x2 - that._x0), + that._y1 + that._k * (that._y2 - that._y0), + that._x2 + that._k * (that._x1 - x), + that._y2 + that._k * (that._y1 - y), + that._x2, + that._y2 + ); +} + +function Cardinal(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +Cardinal.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x2, this._y2); break; + case 3: point$2(this, this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; this._x1 = x, this._y1 = y; break; + case 2: this._point = 3; // falls through + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinal = (function custom(tension) { + + function cardinal(context) { + return new Cardinal(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalClosed(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 2: { + this._context.lineTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + this.point(this._x5, this._y5); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinalClosed = (function custom(tension) { + + function cardinal(context) { + return new CardinalClosed(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalOpen(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; + case 3: this._point = 4; // falls through + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinalOpen = (function custom(tension) { + + function cardinal(context) { + return new CardinalOpen(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function point$1(that, x, y) { + var x1 = that._x1, + y1 = that._y1, + x2 = that._x2, + y2 = that._y2; + + if (that._l01_a > epsilon) { + var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, + n = 3 * that._l01_a * (that._l01_a + that._l12_a); + x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n; + y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n; + } + + if (that._l23_a > epsilon) { + var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, + m = 3 * that._l23_a * (that._l23_a + that._l12_a); + x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m; + y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m; + } + + that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2); +} + +function CatmullRom(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRom.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x2, this._y2); break; + case 3: this.point(this._x2, this._y2); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; // falls through + default: point$1(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRom = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomClosed(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 2: { + this._context.lineTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + this.point(this._x5, this._y5); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$1(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRomClosed = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomOpen(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; + case 3: this._point = 4; // falls through + default: point$1(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRomOpen = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function LinearClosed(context) { + this._context = context; +} + +LinearClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._point) this._context.closePath(); + }, + point: function(x, y) { + x = +x, y = +y; + if (this._point) this._context.lineTo(x, y); + else this._point = 1, this._context.moveTo(x, y); + } +}; + +function curveLinearClosed(context) { + return new LinearClosed(context); +} + +function sign(x) { + return x < 0 ? -1 : 1; +} + +// Calculate the slopes of the tangents (Hermite-type interpolation) based on +// the following paper: Steffen, M. 1990. A Simple Method for Monotonic +// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO. +// NOV(II), P. 443, 1990. +function slope3(that, x2, y2) { + var h0 = that._x1 - that._x0, + h1 = x2 - that._x1, + s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), + s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), + p = (s0 * h1 + s1 * h0) / (h0 + h1); + return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0; +} + +// Calculate a one-sided slope. +function slope2(that, t) { + var h = that._x1 - that._x0; + return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t; +} + +// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations +// "you can express cubic Hermite interpolation in terms of cubic Bézier curves +// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1". +function point(that, t0, t1) { + var x0 = that._x0, + y0 = that._y0, + x1 = that._x1, + y1 = that._y1, + dx = (x1 - x0) / 3; + that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1); +} + +function MonotoneX(context) { + this._context = context; +} + +MonotoneX.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = + this._t0 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x1, this._y1); break; + case 3: point(this, this._t0, slope2(this, this._t0)); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + var t1 = NaN; + + x = +x, y = +y; + if (x === this._x1 && y === this._y1) return; // Ignore coincident points. + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; point(this, slope2(this, t1 = slope3(this, x, y)), t1); break; + default: point(this, this._t0, t1 = slope3(this, x, y)); break; + } + + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + this._t0 = t1; + } +}; + +function MonotoneY(context) { + this._context = new ReflectContext(context); +} + +(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) { + MonotoneX.prototype.point.call(this, y, x); +}; + +function ReflectContext(context) { + this._context = context; +} + +ReflectContext.prototype = { + moveTo: function(x, y) { this._context.moveTo(y, x); }, + closePath: function() { this._context.closePath(); }, + lineTo: function(x, y) { this._context.lineTo(y, x); }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); } +}; + +function monotoneX(context) { + return new MonotoneX(context); +} + +function monotoneY(context) { + return new MonotoneY(context); +} + +function Natural(context) { + this._context = context; +} + +Natural.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = []; + this._y = []; + }, + lineEnd: function() { + var x = this._x, + y = this._y, + n = x.length; + + if (n) { + this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]); + if (n === 2) { + this._context.lineTo(x[1], y[1]); + } else { + var px = controlPoints(x), + py = controlPoints(y); + for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) { + this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]); + } + } + } + + if (this._line || (this._line !== 0 && n === 1)) this._context.closePath(); + this._line = 1 - this._line; + this._x = this._y = null; + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +// See https://www.particleincell.com/2012/bezier-splines/ for derivation. +function controlPoints(x) { + var i, + n = x.length - 1, + m, + a = new Array(n), + b = new Array(n), + r = new Array(n); + a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1]; + for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1]; + a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n]; + for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1]; + a[n - 1] = r[n - 1] / b[n - 1]; + for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i]; + b[n - 1] = (x[n] + a[n - 1]) / 2; + for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1]; + return [a, b]; +} + +function curveNatural(context) { + return new Natural(context); +} + +function Step(context, t) { + this._context = context; + this._t = t; +} + +Step.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = this._y = NaN; + this._point = 0; + }, + lineEnd: function() { + if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y); + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: { + if (this._t <= 0) { + this._context.lineTo(this._x, y); + this._context.lineTo(x, y); + } else { + var x1 = this._x * (1 - this._t) + x * this._t; + this._context.lineTo(x1, this._y); + this._context.lineTo(x1, y); + } + break; + } + } + this._x = x, this._y = y; + } +}; + +function curveStep(context) { + return new Step(context, 0.5); +} + +function stepBefore(context) { + return new Step(context, 0); +} + +function stepAfter(context) { + return new Step(context, 1); +} + +function Transform(k, x, y) { + this.k = k; + this.x = x; + this.y = y; +} + +Transform.prototype = { + constructor: Transform, + scale: function(k) { + return k === 1 ? this : new Transform(this.k * k, this.x, this.y); + }, + translate: function(x, y) { + return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y); + }, + apply: function(point) { + return [point[0] * this.k + this.x, point[1] * this.k + this.y]; + }, + applyX: function(x) { + return x * this.k + this.x; + }, + applyY: function(y) { + return y * this.k + this.y; + }, + invert: function(location) { + return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k]; + }, + invertX: function(x) { + return (x - this.x) / this.k; + }, + invertY: function(y) { + return (y - this.y) / this.k; + }, + rescaleX: function(x) { + return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x)); + }, + rescaleY: function(y) { + return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y)); + }, + toString: function() { + return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; + } +}; + +Transform.prototype; + +/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */ + +const { + entries, + setPrototypeOf, + isFrozen, + getPrototypeOf, + getOwnPropertyDescriptor +} = Object; +let { + freeze, + seal, + create +} = Object; // eslint-disable-line import/no-mutable-exports +let { + apply: apply$1, + construct +} = typeof Reflect !== 'undefined' && Reflect; +if (!freeze) { + freeze = function freeze(x) { + return x; + }; +} +if (!seal) { + seal = function seal(x) { + return x; + }; +} +if (!apply$1) { + apply$1 = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; +} +if (!construct) { + construct = function construct(Func, args) { + return new Func(...args); + }; +} +const arrayForEach = unapply(Array.prototype.forEach); +const arrayPop = unapply(Array.prototype.pop); +const arrayPush = unapply(Array.prototype.push); +const stringToLowerCase = unapply(String.prototype.toLowerCase); +const stringToString = unapply(String.prototype.toString); +const stringMatch = unapply(String.prototype.match); +const stringReplace = unapply(String.prototype.replace); +const stringIndexOf = unapply(String.prototype.indexOf); +const stringTrim = unapply(String.prototype.trim); +const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); +const regExpTest = unapply(RegExp.prototype.test); +const typeErrorCreate = unconstruct(TypeError); + +/** + * Creates a new function that calls the given function with a specified thisArg and arguments. + * + * @param {Function} func - The function to be wrapped and called. + * @returns {Function} A new function that calls the given function with a specified thisArg and arguments. + */ +function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + return apply$1(func, thisArg, args); + }; +} + +/** + * Creates a new function that constructs an instance of the given constructor function with the provided arguments. + * + * @param {Function} func - The constructor function to be wrapped and called. + * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments. + */ +function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + return construct(func, args); + }; +} + +/** + * Add properties to a lookup table + * + * @param {Object} set - The set to which elements will be added. + * @param {Array} array - The array containing elements to be added to the set. + * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set. + * @returns {Object} The modified set with added elements. + */ +function addToSet(set, array) { + let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + let l = array.length; + while (l--) { + let element = array[l]; + if (typeof element === 'string') { + const lcElement = transformCaseFunc(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + element = lcElement; + } + } + set[element] = true; + } + return set; +} + +/** + * Clean up an array to harden against CSPP + * + * @param {Array} array - The array to be cleaned. + * @returns {Array} The cleaned version of the array + */ +function cleanArray(array) { + for (let index = 0; index < array.length; index++) { + const isPropertyExist = objectHasOwnProperty(array, index); + if (!isPropertyExist) { + array[index] = null; + } + } + return array; +} + +/** + * Shallow clone an object + * + * @param {Object} object - The object to be cloned. + * @returns {Object} A new object that copies the original. + */ +function clone(object) { + const newObject = create(null); + for (const [property, value] of entries(object)) { + const isPropertyExist = objectHasOwnProperty(object, property); + if (isPropertyExist) { + if (Array.isArray(value)) { + newObject[property] = cleanArray(value); + } else if (value && typeof value === 'object' && value.constructor === Object) { + newObject[property] = clone(value); + } else { + newObject[property] = value; + } + } + } + return newObject; +} + +/** + * This method automatically checks if the prop is function or getter and behaves accordingly. + * + * @param {Object} object - The object to look up the getter function in its prototype chain. + * @param {String} prop - The property name for which to find the getter function. + * @returns {Function} The getter function found in the prototype chain or a fallback function. + */ +function lookupGetter(object, prop) { + while (object !== null) { + const desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + object = getPrototypeOf(object); + } + function fallbackValue() { + return null; + } + return fallbackValue; +} + +const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + +// SVG +const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); +const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + +// List of SVG elements that are disallowed by default. +// We still need to know them so that we can do namespace +// checks properly in case one wants to add them to +// allow-list. +const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); +const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); + +// Similarly to SVG, we want to know all MathML elements, +// even those that we disallow by default. +const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); +const text = freeze(['#text']); + +const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); +const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); +const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); +const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + +// eslint-disable-next-line unicorn/better-regex +const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode +const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); +const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm); +const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape +const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape +const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape +); + +const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); +const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex +); + +const DOCTYPE_NAME = seal(/^html$/i); +const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); + +var EXPRESSIONS = /*#__PURE__*/Object.freeze({ + __proto__: null, + MUSTACHE_EXPR: MUSTACHE_EXPR, + ERB_EXPR: ERB_EXPR, + TMPLIT_EXPR: TMPLIT_EXPR, + DATA_ATTR: DATA_ATTR, + ARIA_ATTR: ARIA_ATTR, + IS_ALLOWED_URI: IS_ALLOWED_URI, + IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE: ATTR_WHITESPACE, + DOCTYPE_NAME: DOCTYPE_NAME, + CUSTOM_ELEMENT: CUSTOM_ELEMENT +}); + +// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType +const NODE_TYPE = { + element: 1, + attribute: 2, + text: 3, + cdataSection: 4, + entityReference: 5, + // Deprecated + entityNode: 6, + // Deprecated + progressingInstruction: 7, + comment: 8, + document: 9, + documentType: 10, + documentFragment: 11, + notation: 12 // Deprecated +}; + +const getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; +}; + +/** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). + * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported or creating the policy failed). + */ +const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { + if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + let suffix = null; + const ATTR_NAME = 'data-tt-policy-suffix'; + if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { + suffix = purifyHostElement.getAttribute(ATTR_NAME); + } + const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + try { + return trustedTypes.createPolicy(policyName, { + createHTML(html) { + return html; + }, + createScriptURL(scriptUrl) { + return scriptUrl; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } +}; +function createDOMPurify() { + let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + const DOMPurify = root => createDOMPurify(root); + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '3.1.5'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + return DOMPurify; + } + let { + document + } = window; + const originalDocument = document; + const currentScript = originalDocument.currentScript; + const { + DocumentFragment, + HTMLTemplateElement, + Node, + Element, + NodeFilter, + NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, + HTMLFormElement, + DOMParser, + trustedTypes + } = window; + const ElementPrototype = Element.prototype; + const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + const template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + let trustedTypesPolicy; + let emptyHTML = ''; + const { + implementation, + createNodeIterator, + createDocumentFragment, + getElementsByTagName + } = document; + const { + importNode + } = originalDocument; + let hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; + const { + MUSTACHE_EXPR, + ERB_EXPR, + TMPLIT_EXPR, + DATA_ATTR, + ARIA_ATTR, + IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE, + CUSTOM_ELEMENT + } = EXPRESSIONS; + let { + IS_ALLOWED_URI: IS_ALLOWED_URI$1 + } = EXPRESSIONS; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + let ALLOWED_TAGS = null; + const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); + + /* Allowed attribute names */ + let ALLOWED_ATTR = null; + const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); + + /* + * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements. + * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) + * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) + * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. + */ + let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { + tagNameCheck: { + writable: true, + configurable: false, + enumerable: true, + value: null + }, + attributeNameCheck: { + writable: true, + configurable: false, + enumerable: true, + value: null + }, + allowCustomizedBuiltInElements: { + writable: true, + configurable: false, + enumerable: true, + value: false + } + })); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + let FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + let FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + let ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + let ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + let ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Decide if self-closing tags in attributes are allowed. + * Usually removed due to a mXSS issue in jQuery 3.0 */ + let ALLOW_SELF_CLOSE_IN_ATTR = true; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + let SAFE_FOR_TEMPLATES = false; + + /* Output should be safe even for XML used within HTML and alike. + * This means, DOMPurify removes comments when containing risky content. + */ + let SAFE_FOR_XML = true; + + /* Decide if document with ... should be returned */ + let WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + let SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + let FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + let RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + let RETURN_DOM_FRAGMENT = false; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + let RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? + * This sanitizes markups named with colliding, clobberable built-in DOM APIs. + */ + let SANITIZE_DOM = true; + + /* Achieve full DOM Clobbering protection by isolating the namespace of named + * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. + * + * HTML/DOM spec rules that enable DOM Clobbering: + * - Named Access on Window (§7.3.3) + * - DOM Tree Accessors (§3.1.5) + * - Form Element Parent-Child Relations (§4.10.3) + * - Iframe srcdoc / Nested WindowProxies (§4.8.5) + * - HTMLCollection (§4.2.10.2) + * + * Namespace isolation is implemented by prefixing `id` and `name` attributes + * with a constant string, i.e., `user-content-` + */ + let SANITIZE_NAMED_PROPS = false; + const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; + + /* Keep element content when removing element? */ + let KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + let IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + let USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + let FORBID_CONTENTS = null; + const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + let DATA_URI_TAGS = null; + const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + let URI_SAFE_ATTRIBUTES = null; + const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); + const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + /* Document namespace */ + let NAMESPACE = HTML_NAMESPACE; + let IS_EMPTY_INPUT = false; + + /* Allowed XHTML+XML namespaces */ + let ALLOWED_NAMESPACES = null; + const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); + + /* Parsing of strict XHTML documents */ + let PARSER_MEDIA_TYPE = null; + const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; + const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; + let transformCaseFunc = null; + + /* Keep a reference to config to pass to hooks */ + let CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + const formElement = document.createElement('form'); + const isRegexOrFunction = function isRegexOrFunction(testValue) { + return testValue instanceof RegExp || testValue instanceof Function; + }; + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + const _parseConfig = function _parseConfig() { + let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || typeof cfg !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone(cfg); + PARSER_MEDIA_TYPE = + // eslint-disable-next-line unicorn/prefer-includes + SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; + + // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. + transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; + + /* Set configuration parameters */ + ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; + ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; + URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), + // eslint-disable-line indent + cfg.ADD_URI_SAFE_ATTR, + // eslint-disable-line indent + transformCaseFunc // eslint-disable-line indent + ) // eslint-disable-line indent + : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), + // eslint-disable-line indent + cfg.ADD_DATA_URI_TAGS, + // eslint-disable-line indent + transformCaseFunc // eslint-disable-line indent + ) // eslint-disable-line indent + : DEFAULT_DATA_URI_TAGS; + FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; + FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {}; + FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {}; + USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; + NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; + CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; + if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { + CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; + } + if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { + CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; + } + if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { + CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; + } + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, text); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html$1); + addToSet(ALLOWED_ATTR, html); + } + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg$1); + addToSet(ALLOWED_ATTR, svg); + addToSet(ALLOWED_ATTR, xml); + } + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg); + addToSet(ALLOWED_ATTR, xml); + } + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl$1); + addToSet(ALLOWED_ATTR, mathMl); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone(ALLOWED_TAGS); + } + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); + } + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone(ALLOWED_ATTR); + } + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); + } + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); + } + if (cfg.FORBID_CONTENTS) { + if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { + FORBID_CONTENTS = clone(FORBID_CONTENTS); + } + addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + if (cfg.TRUSTED_TYPES_POLICY) { + if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { + throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); + } + if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { + throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); + } + + // Overwrite existing TrustedTypes policy. + trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; + + // Sign local variables required by `sanitize`. + emptyHTML = trustedTypesPolicy.createHTML(''); + } else { + // Uninitialized policy, attempt to initialize the internal dompurify policy. + if (trustedTypesPolicy === undefined) { + trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); + } + + // If creating the internal policy succeeded sign internal variables. + if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { + emptyHTML = trustedTypesPolicy.createHTML(''); + } + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + CONFIG = cfg; + }; + const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']); + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erroneously deleted from + // HTML namespace. + const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); + const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); + + /** + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + const _checkValidNamespace = function _checkValidNamespace(element) { + let parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: NAMESPACE, + tagName: 'template' + }; + } + const tagName = stringToLowerCase(element.tagName); + const parentTagName = stringToLowerCase(parent.tagName); + if (!ALLOWED_NAMESPACES[element.namespaceURI]) { + return false; + } + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via . If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via` + // svg if parent is either or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via . If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // For XHTML and XML documents that support custom namespaces + if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { + return true; + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). + // Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + const _forceRemove = function _forceRemove(node) { + arrayPush(DOMPurify.removed, { + element: node + }); + try { + // eslint-disable-next-line unicorn/prefer-dom-node-remove + node.parentNode.removeChild(node); + } catch (_) { + node.remove(); + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + const _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush(DOMPurify.removed, { + attribute: null, + from: node + }); + } + node.removeAttribute(name); + + // We void attribute values for unremovable "is"" attributes + if (name === 'is' && !ALLOWED_ATTR[name]) { + if (RETURN_DOM || RETURN_DOM_FRAGMENT) { + try { + _forceRemove(node); + } catch (_) {} + } else { + try { + node.setAttribute(name, ''); + } catch (_) {} + } + } + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + const _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + let doc = null; + let leadingWhitespace = null; + if (FORCE_BODY) { + dirty = '' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + const matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { + // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) + dirty = '' + dirty + ''; + } + const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* + * Use the DOMParser API by default, fallback later if needs be + * DOMParser not work for svg when has multiple root element. + */ + if (NAMESPACE === HTML_NAMESPACE) { + try { + doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); + } catch (_) {} + } + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createDocument(NAMESPACE, 'template', null); + try { + doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; + } catch (_) { + // Syntax error if dirtyPayload is invalid xml + } + } + const body = doc.body || doc.documentElement; + if (dirty && leadingWhitespace) { + body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + if (NAMESPACE === HTML_NAMESPACE) { + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + } + return WHOLE_DOCUMENT ? doc.documentElement : body; + }; + + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * + * @param {Node} root The root element or node to start traversing on. + * @return {NodeIterator} The created NodeIterator + */ + const _createNodeIterator = function _createNodeIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, + // eslint-disable-next-line no-bitwise + NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + const _isClobbered = function _isClobbered(elm) { + return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function'); + }; + + /** + * Checks whether the given object is a DOM node. + * + * @param {Node} object object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + const _isNode = function _isNode(object) { + return typeof Node === 'function' && object instanceof Node; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + const _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + arrayForEach(hooks[entryPoint], hook => { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + const _sanitizeElements = function _sanitizeElements(currentNode) { + let content = null; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + const tagName = transformCaseFunc(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove any ocurrence of processing instructions */ + if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { + _forceRemove(currentNode); + return true; + } + + /* Remove any kind of possibly harmful comments */ + if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Check if we have a custom element to handle */ + if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { + if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { + return false; + } + if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { + return false; + } + } + + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + const parentNode = getParentNode(currentNode) || currentNode.parentNode; + const childNodes = getChildNodes(currentNode) || currentNode.childNodes; + if (childNodes && parentNode) { + const childCount = childNodes.length; + for (let i = childCount - 1; i >= 0; --i) { + const childClone = cloneNode(childNodes[i], true); + childClone.__removalCount = (currentNode.__removalCount || 0) + 1; + parentNode.insertBefore(childClone, getNextSibling(currentNode)); + } + } + } + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Make sure that older browsers don't get fallback-tag mXSS */ + if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { + /* Get the element's text content */ + content = currentNode.textContent; + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + content = stringReplace(content, expr, ' '); + }); + if (currentNode.textContent !== content) { + arrayPush(DOMPurify.removed, { + element: currentNode.cloneNode() + }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + if ( + // First condition does a very basic check if a) it's basically a valid custom element tagname AND + // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck + // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck + _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || + // Alternative, second condition checks if it's an `is`-attribute, AND + // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck + lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { + return false; + } + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { + return false; + } else ; + return true; + }; + + /** + * _isBasicCustomElement + * checks if at least one dash is included in tagName, and it's not the first char + * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name + * + * @param {string} tagName name of the tag of the node to sanitize + * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false. + */ + const _isBasicCustomElement = function _isBasicCustomElement(tagName) { + return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + const { + attributes + } = currentNode; + + /* Check if we have attributes; if not we might have a text node */ + if (!attributes) { + return; + } + const hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + let l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + const attr = attributes[l]; + const { + name, + namespaceURI, + value: attrValue + } = attr; + const lcName = transformCaseFunc(name); + let value = name === 'value' ? attrValue : stringTrim(attrValue); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Work around a security issue with comments inside attributes */ + if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + value = stringReplace(value, expr, ' '); + }); + } + + /* Is `value` valid for this attribute? */ + const lcTag = transformCaseFunc(currentNode.nodeName); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Full DOM Clobbering protection via namespace isolation, + * Prefix id and name attributes with `user-content-` + */ + if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { + // Remove the attribute with this value + _removeAttribute(name, currentNode); + + // Prefix the value and later re-create the attribute with the sanitized value + value = SANITIZE_NAMED_PROPS_PREFIX + value; + } + + /* Handle attributes that require Trusted Types */ + if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { + if (namespaceURI) ; else { + switch (trustedTypes.getAttributeType(lcTag, lcName)) { + case 'TrustedHTML': + { + value = trustedTypesPolicy.createHTML(value); + break; + } + case 'TrustedScriptURL': + { + value = trustedTypesPolicy.createScriptURL(value); + break; + } + } + } + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + } else { + arrayPop(DOMPurify.removed); + } + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + let shadowNode = null; + const shadowIterator = _createNodeIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} cfg object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty) { + let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + let body = null; + let importedNode = null; + let currentNode = null; + let returnNode = null; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + IS_EMPTY_INPUT = !dirty; + if (IS_EMPTY_INPUT) { + dirty = ''; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + if (typeof dirty.toString === 'function') { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } else { + throw typeErrorCreate('toString is not a function'); + } + } + + /* Return dirty HTML if DOMPurify cannot run */ + if (!DOMPurify.isSupported) { + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + if (IN_PLACE) { + /* Do some early pre-sanitization to avoid unsafe root nodes */ + if (dirty.nodeName) { + const tagName = transformCaseFunc(dirty.nodeName); + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); + } + } + } else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument(''); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-dom-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + } + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-dom-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + return returnNode; + } + let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Serialize doctype if allowed */ + if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { + serializedHTML = '\n' + serializedHTML; + } + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + serializedHTML = stringReplace(serializedHTML, expr, ' '); + }); + } + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function () { + let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {String} tag Tag name of containing element. + * @param {String} attr Attribute name. + * @param {String} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + const lcTag = transformCaseFunc(tag); + const lcName = transformCaseFunc(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + * @return {Function} removed(popped) hook + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + return arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + return DOMPurify; +} +var purify = createDOMPurify(); + +/* IMPORT */ +/* MAIN */ +const Channel = { + /* CLAMP */ + min: { + r: 0, + g: 0, + b: 0, + s: 0, + l: 0, + a: 0 + }, + max: { + r: 255, + g: 255, + b: 255, + h: 360, + s: 100, + l: 100, + a: 1 + }, + clamp: { + r: (r) => r >= 255 ? 255 : (r < 0 ? 0 : r), + g: (g) => g >= 255 ? 255 : (g < 0 ? 0 : g), + b: (b) => b >= 255 ? 255 : (b < 0 ? 0 : b), + h: (h) => h % 360, + s: (s) => s >= 100 ? 100 : (s < 0 ? 0 : s), + l: (l) => l >= 100 ? 100 : (l < 0 ? 0 : l), + a: (a) => a >= 1 ? 1 : (a < 0 ? 0 : a) + }, + /* CONVERSION */ + //SOURCE: https://planetcalc.com/7779 + toLinear: (c) => { + const n = c / 255; + return c > .03928 ? Math.pow(((n + .055) / 1.055), 2.4) : n / 12.92; + }, + //SOURCE: https://gist.github.com/mjackson/5311256 + hue2rgb: (p, q, t) => { + if (t < 0) + t += 1; + if (t > 1) + t -= 1; + if (t < 1 / 6) + return p + (q - p) * 6 * t; + if (t < 1 / 2) + return q; + if (t < 2 / 3) + return p + (q - p) * (2 / 3 - t) * 6; + return p; + }, + hsl2rgb: ({ h, s, l }, channel) => { + if (!s) + return l * 2.55; // Achromatic + h /= 360; + s /= 100; + l /= 100; + const q = (l < .5) ? l * (1 + s) : (l + s) - (l * s); + const p = 2 * l - q; + switch (channel) { + case 'r': return Channel.hue2rgb(p, q, h + 1 / 3) * 255; + case 'g': return Channel.hue2rgb(p, q, h) * 255; + case 'b': return Channel.hue2rgb(p, q, h - 1 / 3) * 255; + } + }, + rgb2hsl: ({ r, g, b }, channel) => { + r /= 255; + g /= 255; + b /= 255; + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + const l = (max + min) / 2; + if (channel === 'l') + return l * 100; + if (max === min) + return 0; // Achromatic + const d = max - min; + const s = (l > .5) ? d / (2 - max - min) : d / (max + min); + if (channel === 's') + return s * 100; + switch (max) { + case r: return ((g - b) / d + (g < b ? 6 : 0)) * 60; + case g: return ((b - r) / d + 2) * 60; + case b: return ((r - g) / d + 4) * 60; + default: return -1; //TSC: TypeScript is stupid and complains if there isn't this useless default statement + } + } +}; + +/* MAIN */ +const Lang = { + /* API */ + clamp: (number, lower, upper) => { + if (lower > upper) + return Math.min(lower, Math.max(upper, number)); + return Math.min(upper, Math.max(lower, number)); + }, + round: (number) => { + return Math.round(number * 10000000000) / 10000000000; + } +}; + +/* MAIN */ +const Unit = { + /* API */ + dec2hex: (dec) => { + const hex = Math.round(dec).toString(16); + return hex.length > 1 ? hex : `0${hex}`; + } +}; + +/* IMPORT */ +/* MAIN */ +const Utils = { + channel: Channel, + lang: Lang, + unit: Unit +}; + +/* IMPORT */ +/* MAIN */ +const DEC2HEX = {}; +for (let i = 0; i <= 255; i++) + DEC2HEX[i] = Utils.unit.dec2hex(i); // Populating dynamically, striking a balance between code size and performance +const TYPE = { + ALL: 0, + RGB: 1, + HSL: 2 +}; + +/* IMPORT */ +/* MAIN */ +class Type { + constructor() { + /* VARIABLES */ + this.type = TYPE.ALL; + } + /* API */ + get() { + return this.type; + } + set(type) { + if (this.type && this.type !== type) + throw new Error('Cannot change both RGB and HSL channels at the same time'); + this.type = type; + } + reset() { + this.type = TYPE.ALL; + } + is(type) { + return this.type === type; + } +} + +/* IMPORT */ +/* MAIN */ +class Channels { + /* CONSTRUCTOR */ + constructor(data, color) { + this.color = color; + this.changed = false; + this.data = data; //TSC + this.type = new Type(); + } + /* API */ + set(data, color) { + this.color = color; + this.changed = false; + this.data = data; //TSC + this.type.type = TYPE.ALL; + return this; + } + /* HELPERS */ + _ensureHSL() { + const data = this.data; + const { h, s, l } = data; + if (h === undefined) + data.h = Utils.channel.rgb2hsl(data, 'h'); + if (s === undefined) + data.s = Utils.channel.rgb2hsl(data, 's'); + if (l === undefined) + data.l = Utils.channel.rgb2hsl(data, 'l'); + } + _ensureRGB() { + const data = this.data; + const { r, g, b } = data; + if (r === undefined) + data.r = Utils.channel.hsl2rgb(data, 'r'); + if (g === undefined) + data.g = Utils.channel.hsl2rgb(data, 'g'); + if (b === undefined) + data.b = Utils.channel.hsl2rgb(data, 'b'); + } + /* GETTERS */ + get r() { + const data = this.data; + const r = data.r; + if (!this.type.is(TYPE.HSL) && r !== undefined) + return r; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'r'); + } + get g() { + const data = this.data; + const g = data.g; + if (!this.type.is(TYPE.HSL) && g !== undefined) + return g; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'g'); + } + get b() { + const data = this.data; + const b = data.b; + if (!this.type.is(TYPE.HSL) && b !== undefined) + return b; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'b'); + } + get h() { + const data = this.data; + const h = data.h; + if (!this.type.is(TYPE.RGB) && h !== undefined) + return h; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 'h'); + } + get s() { + const data = this.data; + const s = data.s; + if (!this.type.is(TYPE.RGB) && s !== undefined) + return s; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 's'); + } + get l() { + const data = this.data; + const l = data.l; + if (!this.type.is(TYPE.RGB) && l !== undefined) + return l; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 'l'); + } + get a() { + return this.data.a; + } + /* SETTERS */ + set r(r) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.r = r; + } + set g(g) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.g = g; + } + set b(b) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.b = b; + } + set h(h) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.h = h; + } + set s(s) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.s = s; + } + set l(l) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.l = l; + } + set a(a) { + this.changed = true; + this.data.a = a; + } +} + +/* IMPORT */ +/* MAIN */ +const channels = new Channels({ r: 0, g: 0, b: 0, a: 0 }, 'transparent'); + +/* IMPORT */ +/* MAIN */ +const Hex = { + /* VARIABLES */ + re: /^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i, + /* API */ + parse: (color) => { + if (color.charCodeAt(0) !== 35) + return; // '#' + const match = color.match(Hex.re); + if (!match) + return; + const hex = match[1]; + const dec = parseInt(hex, 16); + const length = hex.length; + const hasAlpha = length % 4 === 0; + const isFullLength = length > 4; + const multiplier = isFullLength ? 1 : 17; + const bits = isFullLength ? 8 : 4; + const bitsOffset = hasAlpha ? 0 : -1; + const mask = isFullLength ? 255 : 15; + return channels.set({ + r: ((dec >> (bits * (bitsOffset + 3))) & mask) * multiplier, + g: ((dec >> (bits * (bitsOffset + 2))) & mask) * multiplier, + b: ((dec >> (bits * (bitsOffset + 1))) & mask) * multiplier, + a: hasAlpha ? (dec & mask) * multiplier / 255 : 1 + }, color); + }, + stringify: (channels) => { + const { r, g, b, a } = channels; + if (a < 1) { // #RRGGBBAA + return `#${DEC2HEX[Math.round(r)]}${DEC2HEX[Math.round(g)]}${DEC2HEX[Math.round(b)]}${DEC2HEX[Math.round(a * 255)]}`; + } + else { // #RRGGBB + return `#${DEC2HEX[Math.round(r)]}${DEC2HEX[Math.round(g)]}${DEC2HEX[Math.round(b)]}`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const HSL = { + /* VARIABLES */ + re: /^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i, + hueRe: /^(.+?)(deg|grad|rad|turn)$/i, + /* HELPERS */ + _hue2deg: (hue) => { + const match = hue.match(HSL.hueRe); + if (match) { + const [, number, unit] = match; + switch (unit) { + case 'grad': return Utils.channel.clamp.h(parseFloat(number) * .9); + case 'rad': return Utils.channel.clamp.h(parseFloat(number) * 180 / Math.PI); + case 'turn': return Utils.channel.clamp.h(parseFloat(number) * 360); + } + } + return Utils.channel.clamp.h(parseFloat(hue)); + }, + /* API */ + parse: (color) => { + const charCode = color.charCodeAt(0); + if (charCode !== 104 && charCode !== 72) + return; // 'h'/'H' + const match = color.match(HSL.re); + if (!match) + return; + const [, h, s, l, a, isAlphaPercentage] = match; + return channels.set({ + h: HSL._hue2deg(h), + s: Utils.channel.clamp.s(parseFloat(s)), + l: Utils.channel.clamp.l(parseFloat(l)), + a: a ? Utils.channel.clamp.a(isAlphaPercentage ? parseFloat(a) / 100 : parseFloat(a)) : 1 + }, color); + }, + stringify: (channels) => { + const { h, s, l, a } = channels; + if (a < 1) { // HSLA + return `hsla(${Utils.lang.round(h)}, ${Utils.lang.round(s)}%, ${Utils.lang.round(l)}%, ${a})`; + } + else { // HSL + return `hsl(${Utils.lang.round(h)}, ${Utils.lang.round(s)}%, ${Utils.lang.round(l)}%)`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const Keyword = { + /* VARIABLES */ + colors: { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyanaqua: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkgrey: '#a9a9a9', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', + greenyellow: '#adff2f', + grey: '#808080', + honeydew: '#f0fff0', + hotpink: '#ff69b4', + indianred: '#cd5c5c', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrodyellow: '#fafad2', + lightgray: '#d3d3d3', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#ff0000', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + transparent: '#00000000', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32' + }, + /* API */ + parse: (color) => { + color = color.toLowerCase(); + const hex = Keyword.colors[color]; + if (!hex) + return; + return Hex.parse(hex); + }, + stringify: (channels) => { + const hex = Hex.stringify(channels); + for (const name in Keyword.colors) { + if (Keyword.colors[name] === hex) + return name; + } + return; + } +}; + +/* IMPORT */ +/* MAIN */ +const RGB = { + /* VARIABLES */ + re: /^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i, + /* API */ + parse: (color) => { + const charCode = color.charCodeAt(0); + if (charCode !== 114 && charCode !== 82) + return; // 'r'/'R' + const match = color.match(RGB.re); + if (!match) + return; + const [, r, isRedPercentage, g, isGreenPercentage, b, isBluePercentage, a, isAlphaPercentage] = match; + return channels.set({ + r: Utils.channel.clamp.r(isRedPercentage ? parseFloat(r) * 2.55 : parseFloat(r)), + g: Utils.channel.clamp.g(isGreenPercentage ? parseFloat(g) * 2.55 : parseFloat(g)), + b: Utils.channel.clamp.b(isBluePercentage ? parseFloat(b) * 2.55 : parseFloat(b)), + a: a ? Utils.channel.clamp.a(isAlphaPercentage ? parseFloat(a) / 100 : parseFloat(a)) : 1 + }, color); + }, + stringify: (channels) => { + const { r, g, b, a } = channels; + if (a < 1) { // RGBA + return `rgba(${Utils.lang.round(r)}, ${Utils.lang.round(g)}, ${Utils.lang.round(b)}, ${Utils.lang.round(a)})`; + } + else { // RGB + return `rgb(${Utils.lang.round(r)}, ${Utils.lang.round(g)}, ${Utils.lang.round(b)})`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const Color = { + /* VARIABLES */ + format: { + keyword: Keyword, + hex: Hex, + rgb: RGB, + rgba: RGB, + hsl: HSL, + hsla: HSL + }, + /* API */ + parse: (color) => { + if (typeof color !== 'string') + return color; + const channels = Hex.parse(color) || RGB.parse(color) || HSL.parse(color) || Keyword.parse(color); // Color providers ordered with performance in mind + if (channels) + return channels; + throw new Error(`Unsupported color format: "${color}"`); + }, + stringify: (channels) => { + // SASS returns a keyword if possible, but we avoid doing that as it's slower and doesn't really add any value + if (!channels.changed && channels.color) + return channels.color; + if (channels.type.is(TYPE.HSL) || channels.data.r === undefined) { + return HSL.stringify(channels); + } + else if (channels.a < 1 || !Number.isInteger(channels.r) || !Number.isInteger(channels.g) || !Number.isInteger(channels.b)) { + return RGB.stringify(channels); + } + else { + return Hex.stringify(channels); + } + } +}; + +/* IMPORT */ +/* MAIN */ +const change = (color, channels) => { + const ch = Color.parse(color); + for (const c in channels) { + ch[c] = Utils.channel.clamp[c](channels[c]); + } + return Color.stringify(ch); +}; + +/* IMPORT */ +/* MAIN */ +const rgba = (r, g, b = 0, a = 1) => { + if (typeof r !== 'number') + return change(r, { a: g }); + const channels$1 = channels.set({ + r: Utils.channel.clamp.r(r), + g: Utils.channel.clamp.g(g), + b: Utils.channel.clamp.b(b), + a: Utils.channel.clamp.a(a) + }); + return Color.stringify(channels$1); +}; + +/* IMPORT */ +/* MAIN */ +//SOURCE: https://planetcalc.com/7779 +const luminance = (color) => { + const { r, g, b } = Color.parse(color); + const luminance = .2126 * Utils.channel.toLinear(r) + .7152 * Utils.channel.toLinear(g) + .0722 * Utils.channel.toLinear(b); + return Utils.lang.round(luminance); +}; + +/* IMPORT */ +/* MAIN */ +const isLight = (color) => { + return luminance(color) >= .5; +}; + +/* IMPORT */ +/* MAIN */ +const isDark = (color) => { + return !isLight(color); +}; + +/* IMPORT */ +/* MAIN */ +const adjustChannel = (color, channel, amount) => { + const channels = Color.parse(color); + const amountCurrent = channels[channel]; + const amountNext = Utils.channel.clamp[channel](amountCurrent + amount); + if (amountCurrent !== amountNext) + channels[channel] = amountNext; + return Color.stringify(channels); +}; + +/* IMPORT */ +/* MAIN */ +const lighten = (color, amount) => { + return adjustChannel(color, 'l', amount); +}; + +/* IMPORT */ +/* MAIN */ +const darken = (color, amount) => { + return adjustChannel(color, 'l', -amount); +}; + +/* IMPORT */ +/* MAIN */ +const adjust = (color, channels) => { + const ch = Color.parse(color); + const changes = {}; + for (const c in channels) { + if (!channels[c]) + continue; + changes[c] = ch[c] + channels[c]; + } + return change(color, changes); +}; + +/* IMPORT */ +/* MAIN */ +//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756 +const mix = (color1, color2, weight = 50) => { + const { r: r1, g: g1, b: b1, a: a1 } = Color.parse(color1); + const { r: r2, g: g2, b: b2, a: a2 } = Color.parse(color2); + const weightScale = weight / 100; + const weightNormalized = (weightScale * 2) - 1; + const alphaDelta = a1 - a2; + const weight1combined = ((weightNormalized * alphaDelta) === -1) ? weightNormalized : (weightNormalized + alphaDelta) / (1 + weightNormalized * alphaDelta); + const weight1 = (weight1combined + 1) / 2; + const weight2 = 1 - weight1; + const r = (r1 * weight1) + (r2 * weight2); + const g = (g1 * weight1) + (g2 * weight2); + const b = (b1 * weight1) + (b2 * weight2); + const a = (a1 * weightScale) + (a2 * (1 - weightScale)); + return rgba(r, g, b, a); +}; + +/* IMPORT */ +/* MAIN */ +const invert = (color, weight = 100) => { + const inverse = Color.parse(color); + inverse.r = 255 - inverse.r; + inverse.g = 255 - inverse.g; + inverse.b = 255 - inverse.b; + return mix(inverse, color, weight); +}; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** Built-in value references. */ +var Symbol$1 = root.Symbol; + +/** Used for built-in method references. */ +var objectProto$c = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$a = objectProto$c.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$c.toString; + +/** Built-in value references. */ +var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty$a.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString$1.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$b = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto$b.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject$1(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag$1 = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject$1(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +/** Used for built-in method references. */ +var funcProto$2 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$2 = funcProto$2.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString$2.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto$1 = Function.prototype, + objectProto$a = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$1 = funcProto$1.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$9 = objectProto$a.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString$1.call(hasOwnProperty$9).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject$1(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); +} + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; +} + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; +} + +/* Built-in method references that are verified to be native. */ +var nativeCreate = getNative(Object, 'create'); + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; +} + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$9 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$8 = objectProto$9.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED$1 ? undefined : result; + } + return hasOwnProperty$8.call(data, key) ? data[key] : undefined; +} + +/** Used for built-in method references. */ +var objectProto$8 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$7 = objectProto$8.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$7.call(data, key); +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; +} + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; +} + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +/* Built-in method references that are verified to be native. */ +var Map$1 = getNative(root, 'Map'); + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map$1 || ListCache), + 'string': new Hash + }; +} + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); +} + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = MapCache; + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache; + this.size = 0; +} + +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; +} + +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} + +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); +} + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; +} + +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; +} + +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; + +var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +/** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } +} + +/** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} + +/** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); + +/** Detect free variable `exports`. */ +var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2; + +/** Built-in value references. */ +var Buffer$1 = moduleExports$2 ? root.Buffer : undefined, + allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined; + +/** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ +function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; +} + +/** Built-in value references. */ +var Uint8Array$1 = root.Uint8Array; + +/** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ +function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer)); + return result; +} + +/** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ +function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); +} + +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} + +/** Built-in value references. */ +var objectCreate = Object.create; + +/** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ +var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject$1(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; +}()); + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/** Built-in value references. */ +var getPrototype = overArg(Object.getPrototypeOf, Object); + +/** Used for built-in method references. */ +var objectProto$7 = Object.prototype; + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7; + + return value === proto; +} + +/** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag$1; +} + +/** Used for built-in method references. */ +var objectProto$6 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$6 = objectProto$6.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$6.propertyIsEnumerable; + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1; +} + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} + +/** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ +function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); +} + +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +/** Detect free variable `exports`. */ +var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + +/** Built-in value references. */ +var Buffer = moduleExports$1 ? root.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** `Object#toString` result references. */ +var objectTag$2 = '[object Object]'; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto$5 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$5 = objectProto$5.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString.call(Object); + +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag$2) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; +} + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag$2 = '[object Map]', + numberTag = '[object Number]', + objectTag$1 = '[object Object]', + regexpTag = '[object RegExp]', + setTag$2 = '[object Set]', + stringTag = '[object String]', + weakMapTag$1 = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag$1 = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag] = +typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = +typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] = +typedArrayTags[setTag$2] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag$1] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +/** + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + + if (key == '__proto__') { + return; + } + + return object[key]; +} + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$4 = objectProto$4.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty$4.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } +} + +/** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ +function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; +} + +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty$3.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; +} + +/** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeysIn(object) { + if (!isObject$1(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty$2.call(object, key)))) { + result.push(key); + } + } + return result; +} + +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); +} + +/** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ +function toPlainObject(value) { + return copyObject(value, keysIn(value)); +} + +/** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); + + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject$1(objValue) || isFunction(objValue)) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); +} + +/** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); + if (isObject$1(srcValue)) { + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); +} + +/** + * This method returns the first argument it receives. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'a': 1 }; + * + * console.log(_.identity(object) === object); + * // => true + */ +function identity(value) { + return value; +} + +/** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ +function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ +function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply(func, this, otherArgs); + }; +} + +/** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ +function constant(value) { + return function() { + return value; + }; +} + +/** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); +}; + +/** Used to detect hot functions by number of calls within a span of milliseconds. */ +var HOT_COUNT = 800, + HOT_SPAN = 16; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeNow = Date.now; + +/** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ +function shortOut(func) { + var count = 0, + lastCalled = 0; + + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; +} + +/** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var setToString = shortOut(baseSetToString); + +/** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ +function baseRest(func, start) { + return setToString(overRest(func, start, identity), func + ''); +} + +/** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ +function isIterateeCall(value, index, object) { + if (!isObject$1(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); + } + return false; +} + +/** + * Creates a function like `_.assign`. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ +function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; + + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); +} + +/** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ +var merge$1 = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); +}); + +var COMMENT = 'comm'; +var RULESET = 'rule'; +var DECLARATION = 'decl'; +var IMPORT = '@import'; +var KEYFRAMES = '@keyframes'; +var LAYER = '@layer'; + +/** + * @param {number} + * @return {number} + */ +var abs = Math.abs; + +/** + * @param {number} + * @return {string} + */ +var from = String.fromCharCode; + +/** + * @param {string} value + * @return {string} + */ +function trim (value) { + return value.trim() +} + +/** + * @param {string} value + * @param {(string|RegExp)} pattern + * @param {string} replacement + * @return {string} + */ +function replace (value, pattern, replacement) { + return value.replace(pattern, replacement) +} + +/** + * @param {string} value + * @param {string} search + * @param {number} position + * @return {number} + */ +function indexof (value, search, position) { + return value.indexOf(search, position) +} + +/** + * @param {string} value + * @param {number} index + * @return {number} + */ +function charat (value, index) { + return value.charCodeAt(index) | 0 +} + +/** + * @param {string} value + * @param {number} begin + * @param {number} end + * @return {string} + */ +function substr (value, begin, end) { + return value.slice(begin, end) +} + +/** + * @param {string} value + * @return {number} + */ +function strlen (value) { + return value.length +} + +/** + * @param {any[]} value + * @return {number} + */ +function sizeof (value) { + return value.length +} + +/** + * @param {any} value + * @param {any[]} array + * @return {any} + */ +function append (value, array) { + return array.push(value), value +} + +var line = 1; +var column = 1; +var length = 0; +var position = 0; +var character = 0; +var characters = ''; + +/** + * @param {string} value + * @param {object | null} root + * @param {object | null} parent + * @param {string} type + * @param {string[] | string} props + * @param {object[] | string} children + * @param {object[]} siblings + * @param {number} length + */ +function node (value, root, parent, type, props, children, length, siblings) { + return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings} +} + +/** + * @return {number} + */ +function char () { + return character +} + +/** + * @return {number} + */ +function prev () { + character = position > 0 ? charat(characters, --position) : 0; + + if (column--, character === 10) + column = 1, line--; + + return character +} + +/** + * @return {number} + */ +function next () { + character = position < length ? charat(characters, position++) : 0; + + if (column++, character === 10) + column = 1, line++; + + return character +} + +/** + * @return {number} + */ +function peek () { + return charat(characters, position) +} + +/** + * @return {number} + */ +function caret () { + return position +} + +/** + * @param {number} begin + * @param {number} end + * @return {string} + */ +function slice (begin, end) { + return substr(characters, begin, end) +} + +/** + * @param {number} type + * @return {number} + */ +function token (type) { + switch (type) { + // \0 \t \n \r \s whitespace token + case 0: case 9: case 10: case 13: case 32: + return 5 + // ! + , / > @ ~ isolate token + case 33: case 43: case 44: case 47: case 62: case 64: case 126: + // ; { } breakpoint token + case 59: case 123: case 125: + return 4 + // : accompanied token + case 58: + return 3 + // " ' ( [ opening delimit token + case 34: case 39: case 40: case 91: + return 2 + // ) ] closing delimit token + case 41: case 93: + return 1 + } + + return 0 +} + +/** + * @param {string} value + * @return {any[]} + */ +function alloc (value) { + return line = column = 1, length = strlen(characters = value), position = 0, [] +} + +/** + * @param {any} value + * @return {any} + */ +function dealloc (value) { + return characters = '', value +} + +/** + * @param {number} type + * @return {string} + */ +function delimit (type) { + return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type))) +} + +/** + * @param {number} type + * @return {string} + */ +function whitespace (type) { + while (character = peek()) + if (character < 33) + next(); + else + break + + return token(type) > 2 || token(character) > 3 ? '' : ' ' +} + +/** + * @param {number} index + * @param {number} count + * @return {string} + */ +function escaping (index, count) { + while (--count && next()) + // not 0-9 A-F a-f + if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97)) + break + + return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32)) +} + +/** + * @param {number} type + * @return {number} + */ +function delimiter (type) { + while (next()) + switch (character) { + // ] ) " ' + case type: + return position + // " ' + case 34: case 39: + if (type !== 34 && type !== 39) + delimiter(character); + break + // ( + case 40: + if (type === 41) + delimiter(type); + break + // \ + case 92: + next(); + break + } + + return position +} + +/** + * @param {number} type + * @param {number} index + * @return {number} + */ +function commenter (type, index) { + while (next()) + // // + if (type + character === 47 + 10) + break + // /* + else if (type + character === 42 + 42 && peek() === 47) + break + + return '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next()) +} + +/** + * @param {number} index + * @return {string} + */ +function identifier (index) { + while (!token(peek())) + next(); + + return slice(index, position) +} + +/** + * @param {string} value + * @return {object[]} + */ +function compile (value) { + return dealloc(parse$2('', null, null, null, [''], value = alloc(value), 0, [0], value)) +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {string[]} rule + * @param {string[]} rules + * @param {string[]} rulesets + * @param {number[]} pseudo + * @param {number[]} points + * @param {string[]} declarations + * @return {object} + */ +function parse$2 (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) { + var index = 0; + var offset = 0; + var length = pseudo; + var atrule = 0; + var property = 0; + var previous = 0; + var variable = 1; + var scanning = 1; + var ampersand = 1; + var character = 0; + var type = ''; + var props = rules; + var children = rulesets; + var reference = rule; + var characters = type; + + while (scanning) + switch (previous = character, character = next()) { + // ( + case 40: + if (previous != 108 && charat(characters, length - 1) == 58) { + if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f', abs(index ? points[index - 1] : 0)) != -1) + ampersand = -1; + break + } + // " ' [ + case 34: case 39: case 91: + characters += delimit(character); + break + // \t \n \r \s + case 9: case 10: case 13: case 32: + characters += whitespace(previous); + break + // \ + case 92: + characters += escaping(caret() - 1, 7); + continue + // / + case 47: + switch (peek()) { + case 42: case 47: + append(comment(commenter(next(), caret()), root, parent, declarations), declarations); + break + default: + characters += '/'; + } + break + // { + case 123 * variable: + points[index++] = strlen(characters) * ampersand; + // } ; \0 + case 125 * variable: case 59: case 0: + switch (character) { + // \0 } + case 0: case 125: scanning = 0; + // ; + case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, ''); + if (property > 0 && (strlen(characters) - length)) + append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations); + break + // @ ; + case 59: characters += ';'; + // { rule/at-rule + default: + append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets); + + if (character === 123) + if (offset === 0) + parse$2(characters, root, reference, reference, props, rulesets, length, points, children); + else + switch (atrule === 99 && charat(characters, 3) === 110 ? 100 : atrule) { + // d l m s + case 100: case 108: case 109: case 115: + parse$2(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children); + break + default: + parse$2(characters, reference, reference, reference, [''], children, 0, points, children); + } + } + + index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo; + break + // : + case 58: + length = 1 + strlen(characters), property = previous; + default: + if (variable < 1) + if (character == 123) + --variable; + else if (character == 125 && variable++ == 0 && prev() == 125) + continue + + switch (characters += from(character), character * variable) { + // & + case 38: + ampersand = offset > 0 ? 1 : (characters += '\f', -1); + break + // , + case 44: + points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1; + break + // @ + case 64: + // - + if (peek() === 45) + characters += delimit(next()); + + atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++; + break + // - + case 45: + if (previous === 45 && strlen(characters) == 2) + variable = 0; + } + } + + return rulesets +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {number} index + * @param {number} offset + * @param {string[]} rules + * @param {number[]} points + * @param {string} type + * @param {string[]} props + * @param {string[]} children + * @param {number} length + * @param {object[]} siblings + * @return {object} + */ +function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) { + var post = offset - 1; + var rule = offset === 0 ? rules : ['']; + var size = sizeof(rule); + + for (var i = 0, j = 0, k = 0; i < index; ++i) + for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x) + if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x]))) + props[k++] = z; + + return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings) +} + +/** + * @param {number} value + * @param {object} root + * @param {object?} parent + * @param {object[]} siblings + * @return {object} + */ +function comment (value, root, parent, siblings) { + return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings) +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {number} length + * @param {object[]} siblings + * @return {object} + */ +function declaration (value, root, parent, length, siblings) { + return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings) +} + +/** + * @param {object[]} children + * @param {function} callback + * @return {string} + */ +function serialize (children, callback) { + var output = ''; + + for (var i = 0; i < children.length; i++) + output += callback(children[i], i, children, callback) || ''; + + return output +} + +/** + * @param {object} element + * @param {number} index + * @param {object[]} children + * @param {function} callback + * @return {string} + */ +function stringify (element, index, children, callback) { + switch (element.type) { + case LAYER: if (element.children.length) break + case IMPORT: case DECLARATION: return element.return = element.return || element.value + case COMMENT: return '' + case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}' + case RULESET: if (!strlen(element.value = element.props.join(','))) return '' + } + + return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : '' +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$1.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/* Built-in method references that are verified to be native. */ +var DataView = getNative(root, 'DataView'); + +/* Built-in method references that are verified to be native. */ +var Promise$1 = getNative(root, 'Promise'); + +/* Built-in method references that are verified to be native. */ +var Set$1 = getNative(root, 'Set'); + +/* Built-in method references that are verified to be native. */ +var WeakMap = getNative(root, 'WeakMap'); + +/** `Object#toString` result references. */ +var mapTag$1 = '[object Map]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + setTag$1 = '[object Set]', + weakMapTag = '[object WeakMap]'; + +var dataViewTag = '[object DataView]'; + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map$1), + promiseCtorString = toSource(Promise$1), + setCtorString = toSource(Set$1), + weakMapCtorString = toSource(WeakMap); + +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map$1 && getTag(new Map$1) != mapTag$1) || + (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) || + (Set$1 && getTag(new Set$1) != setTag$1) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag$1; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag$1; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; +} + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + setTag = '[object Set]'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ +function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && + (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || + isBuffer(value) || isTypedArray(value) || isArguments(value))) { + return !value.length; + } + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + if (isPrototype(value)) { + return !baseKeys(value).length; + } + for (var key in value) { + if (hasOwnProperty.call(value, key)) { + return false; + } + } + return true; +} + +const LEVELS = { + trace: 0, + debug: 1, + info: 2, + warn: 3, + error: 4, + fatal: 5 +}; +const log$1 = { + trace: (..._args) => { + }, + debug: (..._args) => { + }, + info: (..._args) => { + }, + warn: (..._args) => { + }, + error: (..._args) => { + }, + fatal: (..._args) => { + } +}; +const setLogLevel$1 = function(level = "fatal") { + let numericLevel = LEVELS.fatal; + if (typeof level === "string") { + level = level.toLowerCase(); + if (level in LEVELS) { + numericLevel = LEVELS[level]; + } + } else if (typeof level === "number") { + numericLevel = level; + } + log$1.trace = () => { + }; + log$1.debug = () => { + }; + log$1.info = () => { + }; + log$1.warn = () => { + }; + log$1.error = () => { + }; + log$1.fatal = () => { + }; + if (numericLevel <= LEVELS.fatal) { + log$1.fatal = console.error ? console.error.bind(console, format("FATAL"), "color: orange") : console.log.bind(console, "\x1B[35m", format("FATAL")); + } + if (numericLevel <= LEVELS.error) { + log$1.error = console.error ? console.error.bind(console, format("ERROR"), "color: orange") : console.log.bind(console, "\x1B[31m", format("ERROR")); + } + if (numericLevel <= LEVELS.warn) { + log$1.warn = console.warn ? console.warn.bind(console, format("WARN"), "color: orange") : console.log.bind(console, `\x1B[33m`, format("WARN")); + } + if (numericLevel <= LEVELS.info) { + log$1.info = console.info ? console.info.bind(console, format("INFO"), "color: lightblue") : console.log.bind(console, "\x1B[34m", format("INFO")); + } + if (numericLevel <= LEVELS.debug) { + log$1.debug = console.debug ? console.debug.bind(console, format("DEBUG"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format("DEBUG")); + } + if (numericLevel <= LEVELS.trace) { + log$1.trace = console.debug ? console.debug.bind(console, format("TRACE"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format("TRACE")); + } +}; +const format = (level) => { + const time = dayjs().format("ss.SSS"); + return `%c${time} : ${level} : `; +}; +const lineBreakRegex = //gi; +const getRows = (s) => { + if (!s) { + return [""]; + } + const str2 = breakToPlaceholder(s).replace(/\\n/g, "#br#"); + return str2.split("#br#"); +}; +const setupDompurifyHooksIfNotSetup = (() => { + let setup = false; + return () => { + if (!setup) { + setupDompurifyHooks(); + setup = true; + } + }; +})(); +function setupDompurifyHooks() { + const TEMPORARY_ATTRIBUTE = "data-temp-href-target"; + purify.addHook("beforeSanitizeAttributes", (node) => { + if (node.tagName === "A" && node.hasAttribute("target")) { + node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute("target") || ""); + } + }); + purify.addHook("afterSanitizeAttributes", (node) => { + if (node.tagName === "A" && node.hasAttribute(TEMPORARY_ATTRIBUTE)) { + node.setAttribute("target", node.getAttribute(TEMPORARY_ATTRIBUTE) || ""); + node.removeAttribute(TEMPORARY_ATTRIBUTE); + if (node.getAttribute("target") === "_blank") { + node.setAttribute("rel", "noopener"); + } + } + }); +} +const removeScript = (txt) => { + setupDompurifyHooksIfNotSetup(); + const sanitizedText = purify.sanitize(txt); + return sanitizedText; +}; +const sanitizeMore = (text, config2) => { + var _a; + if (((_a = config2.flowchart) == null ? void 0 : _a.htmlLabels) !== false) { + const level = config2.securityLevel; + if (level === "antiscript" || level === "strict") { + text = removeScript(text); + } else if (level !== "loose") { + text = breakToPlaceholder(text); + text = text.replace(//g, ">"); + text = text.replace(/=/g, "="); + text = placeholderToBreak(text); + } + } + return text; +}; +const sanitizeText$2 = (text, config2) => { + if (!text) { + return text; + } + if (config2.dompurifyConfig) { + text = purify.sanitize(sanitizeMore(text, config2), config2.dompurifyConfig).toString(); + } else { + text = purify.sanitize(sanitizeMore(text, config2), { + FORBID_TAGS: ["style"] + }).toString(); + } + return text; +}; +const sanitizeTextOrArray = (a, config2) => { + if (typeof a === "string") { + return sanitizeText$2(a, config2); + } + return a.flat().map((x) => sanitizeText$2(x, config2)); +}; +const hasBreaks = (text) => { + return lineBreakRegex.test(text); +}; +const splitBreaks = (text) => { + return text.split(lineBreakRegex); +}; +const placeholderToBreak = (s) => { + return s.replace(/#br#/g, "
"); +}; +const breakToPlaceholder = (s) => { + return s.replace(lineBreakRegex, "#br#"); +}; +const getUrl = (useAbsolute) => { + let url = ""; + if (useAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replaceAll(/\(/g, "\\("); + url = url.replaceAll(/\)/g, "\\)"); + } + return url; +}; +const evaluate = (val) => val === false || ["false", "null", "0"].includes(String(val).trim().toLowerCase()) ? false : true; +const getMax = function(...values) { + const newValues = values.filter((value) => { + return !isNaN(value); + }); + return Math.max(...newValues); +}; +const getMin = function(...values) { + const newValues = values.filter((value) => { + return !isNaN(value); + }); + return Math.min(...newValues); +}; +const parseGenericTypes = function(input) { + const inputSets = input.split(/(,)/); + const output = []; + for (let i = 0; i < inputSets.length; i++) { + let thisSet = inputSets[i]; + if (thisSet === "," && i > 0 && i + 1 < inputSets.length) { + const previousSet = inputSets[i - 1]; + const nextSet = inputSets[i + 1]; + if (shouldCombineSets(previousSet, nextSet)) { + thisSet = previousSet + "," + nextSet; + i++; + output.pop(); + } + } + output.push(processSet(thisSet)); + } + return output.join(""); +}; +const countOccurrence = (string, substring) => { + return Math.max(0, string.split(substring).length - 1); +}; +const shouldCombineSets = (previousSet, nextSet) => { + const prevCount = countOccurrence(previousSet, "~"); + const nextCount = countOccurrence(nextSet, "~"); + return prevCount === 1 && nextCount === 1; +}; +const processSet = (input) => { + const tildeCount = countOccurrence(input, "~"); + let hasStartingTilde = false; + if (tildeCount <= 1) { + return input; + } + if (tildeCount % 2 !== 0 && input.startsWith("~")) { + input = input.substring(1); + hasStartingTilde = true; + } + const chars = [...input]; + let first = chars.indexOf("~"); + let last = chars.lastIndexOf("~"); + while (first !== -1 && last !== -1 && first !== last) { + chars[first] = "<"; + chars[last] = ">"; + first = chars.indexOf("~"); + last = chars.lastIndexOf("~"); + } + if (hasStartingTilde) { + chars.unshift("~"); + } + return chars.join(""); +}; +const isMathMLSupported = () => window.MathMLElement !== void 0; +const katexRegex = /\$\$(.*)\$\$/g; +const hasKatex = (text) => { + var _a; + return (((_a = text.match(katexRegex)) == null ? void 0 : _a.length) ?? 0) > 0; +}; +const calculateMathMLDimensions = async (text, config2) => { + text = await renderKatex(text, config2); + const divElem = document.createElement("div"); + divElem.innerHTML = text; + divElem.id = "katex-temp"; + divElem.style.visibility = "hidden"; + divElem.style.position = "absolute"; + divElem.style.top = "0"; + const body = document.querySelector("body"); + body == null ? void 0 : body.insertAdjacentElement("beforeend", divElem); + const dim = { width: divElem.clientWidth, height: divElem.clientHeight }; + divElem.remove(); + return dim; +}; +const renderKatex = async (text, config2) => { + if (!hasKatex(text)) { + return text; + } + if (!isMathMLSupported() && !config2.legacyMathML) { + return text.replace(katexRegex, "MathML is unsupported in this environment."); + } + const { default: katex } = await Promise.resolve().then(function () { return katex$1; }); + return text.split(lineBreakRegex).map( + (line) => hasKatex(line) ? ` +
+ ${line} +
+ ` : `
${line}
` + ).join("").replace( + katexRegex, + (_, c) => katex.renderToString(c, { + throwOnError: true, + displayMode: true, + output: isMathMLSupported() ? "mathml" : "htmlAndMathml" + }).replace(/\n/g, " ").replace(//g, "") + ); +}; +const common$1 = { + getRows, + sanitizeText: sanitizeText$2, + sanitizeTextOrArray, + hasBreaks, + splitBreaks, + lineBreakRegex, + removeScript, + getUrl, + evaluate, + getMax, + getMin +}; +const mkBorder = (col, darkMode) => darkMode ? adjust(col, { s: -40, l: 10 }) : adjust(col, { s: -40, l: -10 }); +const oldAttributeBackgroundColorOdd = "#ffffff"; +const oldAttributeBackgroundColorEven = "#f2f2f2"; +let Theme$4 = class Theme { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#fff4dd"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "#333"; + this.THEME_COLOR_LIMIT = 12; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.primaryTextColor = this.primaryTextColor || (this.darkMode ? "#eee" : "#333"); + this.secondaryColor = this.secondaryColor || adjust(this.primaryColor, { h: -120 }); + this.tertiaryColor = this.tertiaryColor || adjust(this.primaryColor, { h: 180, l: 5 }); + this.primaryBorderColor = this.primaryBorderColor || mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = this.secondaryBorderColor || mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = this.tertiaryBorderColor || mkBorder(this.tertiaryColor, this.darkMode); + this.noteBorderColor = this.noteBorderColor || mkBorder(this.noteBkgColor, this.darkMode); + this.noteBkgColor = this.noteBkgColor || "#fff5ad"; + this.noteTextColor = this.noteTextColor || "#333"; + this.secondaryTextColor = this.secondaryTextColor || invert(this.secondaryColor); + this.tertiaryTextColor = this.tertiaryTextColor || invert(this.tertiaryColor); + this.lineColor = this.lineColor || invert(this.background); + this.arrowheadColor = this.arrowheadColor || invert(this.background); + this.textColor = this.textColor || this.primaryTextColor; + this.border2 = this.border2 || this.tertiaryBorderColor; + this.nodeBkg = this.nodeBkg || this.primaryColor; + this.mainBkg = this.mainBkg || this.primaryColor; + this.nodeBorder = this.nodeBorder || this.primaryBorderColor; + this.clusterBkg = this.clusterBkg || this.tertiaryColor; + this.clusterBorder = this.clusterBorder || this.tertiaryBorderColor; + this.defaultLinkColor = this.defaultLinkColor || this.lineColor; + this.titleColor = this.titleColor || this.tertiaryTextColor; + this.edgeLabelBackground = this.edgeLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.nodeTextColor = this.nodeTextColor || this.primaryTextColor; + this.actorBorder = this.actorBorder || this.primaryBorderColor; + this.actorBkg = this.actorBkg || this.mainBkg; + this.actorTextColor = this.actorTextColor || this.primaryTextColor; + this.actorLineColor = this.actorLineColor || "grey"; + this.labelBoxBkgColor = this.labelBoxBkgColor || this.actorBkg; + this.signalColor = this.signalColor || this.textColor; + this.signalTextColor = this.signalTextColor || this.textColor; + this.labelBoxBorderColor = this.labelBoxBorderColor || this.actorBorder; + this.labelTextColor = this.labelTextColor || this.actorTextColor; + this.loopTextColor = this.loopTextColor || this.actorTextColor; + this.activationBorderColor = this.activationBorderColor || darken(this.secondaryColor, 10); + this.activationBkgColor = this.activationBkgColor || this.secondaryColor; + this.sequenceNumberColor = this.sequenceNumberColor || invert(this.lineColor); + this.sectionBkgColor = this.sectionBkgColor || this.tertiaryColor; + this.altSectionBkgColor = this.altSectionBkgColor || "white"; + this.sectionBkgColor = this.sectionBkgColor || this.secondaryColor; + this.sectionBkgColor2 = this.sectionBkgColor2 || this.primaryColor; + this.excludeBkgColor = this.excludeBkgColor || "#eeeeee"; + this.taskBorderColor = this.taskBorderColor || this.primaryBorderColor; + this.taskBkgColor = this.taskBkgColor || this.primaryColor; + this.activeTaskBorderColor = this.activeTaskBorderColor || this.primaryColor; + this.activeTaskBkgColor = this.activeTaskBkgColor || lighten(this.primaryColor, 23); + this.gridColor = this.gridColor || "lightgrey"; + this.doneTaskBkgColor = this.doneTaskBkgColor || "lightgrey"; + this.doneTaskBorderColor = this.doneTaskBorderColor || "grey"; + this.critBorderColor = this.critBorderColor || "#ff8888"; + this.critBkgColor = this.critBkgColor || "red"; + this.todayLineColor = this.todayLineColor || "red"; + this.taskTextColor = this.taskTextColor || this.textColor; + this.taskTextOutsideColor = this.taskTextOutsideColor || this.textColor; + this.taskTextLightColor = this.taskTextLightColor || this.textColor; + this.taskTextColor = this.taskTextColor || this.primaryTextColor; + this.taskTextDarkColor = this.taskTextDarkColor || this.textColor; + this.taskTextClickableColor = this.taskTextClickableColor || "#003163"; + this.personBorder = this.personBorder || this.primaryBorderColor; + this.personBkg = this.personBkg || this.mainBkg; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || this.tertiaryColor; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.nodeBorder; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.specialStateColor = this.lineColor; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210, l: 150 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + if (this.darkMode) { + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 75); + } + } else { + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 25); + } + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + if (this.darkMode) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } else { + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 10); + } + } + this.scaleLabelColor = this.scaleLabelColor || this.labelTextColor; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + const multiplier = this.darkMode ? -4 : -1; + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 180, s: -15, l: multiplier * (5 + i * 3) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 180, s: -15, l: multiplier * (8 + i * 3) }); + } + this.classText = this.classText || this.textColor; + this.fillType0 = this.fillType0 || this.primaryColor; + this.fillType1 = this.fillType1 || this.secondaryColor; + this.fillType2 = this.fillType2 || adjust(this.primaryColor, { h: 64 }); + this.fillType3 = this.fillType3 || adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = this.fillType4 || adjust(this.primaryColor, { h: -64 }); + this.fillType5 = this.fillType5 || adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = this.fillType6 || adjust(this.primaryColor, { h: 128 }); + this.fillType7 = this.fillType7 || adjust(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || this.tertiaryColor; + this.pie4 = this.pie4 || adjust(this.primaryColor, { l: -10 }); + this.pie5 = this.pie5 || adjust(this.secondaryColor, { l: -10 }); + this.pie6 = this.pie6 || adjust(this.tertiaryColor, { l: -10 }); + this.pie7 = this.pie7 || adjust(this.primaryColor, { h: 60, l: -10 }); + this.pie8 = this.pie8 || adjust(this.primaryColor, { h: -60, l: -10 }); + this.pie9 = this.pie9 || adjust(this.primaryColor, { h: 120, l: 0 }); + this.pie10 = this.pie10 || adjust(this.primaryColor, { h: 60, l: -20 }); + this.pie11 = this.pie11 || adjust(this.primaryColor, { h: -60, l: -20 }); + this.pie12 = this.pie12 || adjust(this.primaryColor, { h: 120, l: -10 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#FFF4DD,#FFD8B1,#FFA07A,#ECEFF1,#D6DBDF,#C3E0A8,#FFB6A4,#FFD74D,#738FA7,#FFFFF0" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.branchLabelColor = this.branchLabelColor || (this.darkMode ? "black" : this.labelTextColor); + this.gitBranchLabel0 = this.gitBranchLabel0 || this.branchLabelColor; + this.gitBranchLabel1 = this.gitBranchLabel1 || this.branchLabelColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.branchLabelColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || this.branchLabelColor; + this.gitBranchLabel4 = this.gitBranchLabel4 || this.branchLabelColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.branchLabelColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.branchLabelColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.branchLabelColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$4 = (userOverrides) => { + const theme2 = new Theme$4(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$3 = class Theme2 { + constructor() { + this.background = "#333"; + this.primaryColor = "#1f2020"; + this.secondaryColor = lighten(this.primaryColor, 16); + this.tertiaryColor = adjust(this.primaryColor, { h: -160 }); + this.primaryBorderColor = invert(this.background); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.mainBkg = "#1f2020"; + this.secondBkg = "calculated"; + this.mainContrastColor = "lightgrey"; + this.darkTextColor = lighten(invert("#323D47"), 10); + this.lineColor = "calculated"; + this.border1 = "#81B1DB"; + this.border2 = rgba(255, 255, 255, 0.25); + this.arrowheadColor = "calculated"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.labelBackground = "#181818"; + this.textColor = "#ccc"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "#F9FFFE"; + this.edgeLabelBackground = "calculated"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "calculated"; + this.actorLineColor = "calculated"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "calculated"; + this.activationBkgColor = "calculated"; + this.sequenceNumberColor = "black"; + this.sectionBkgColor = darken("#EAE8D9", 30); + this.altSectionBkgColor = "calculated"; + this.sectionBkgColor2 = "#EAE8D9"; + this.excludeBkgColor = darken(this.sectionBkgColor, 10); + this.taskBorderColor = rgba(255, 255, 255, 70); + this.taskBkgColor = "calculated"; + this.taskTextColor = "calculated"; + this.taskTextLightColor = "calculated"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = rgba(255, 255, 255, 50); + this.activeTaskBkgColor = "#81B1DB"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#E83737"; + this.critBkgColor = "#E83737"; + this.taskTextDarkColor = "calculated"; + this.todayLineColor = "#DB5757"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "calculated"; + this.errorBkgColor = "#a44141"; + this.errorTextColor = "#ddd"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.secondBkg = lighten(this.mainBkg, 16); + this.lineColor = this.mainContrastColor; + this.arrowheadColor = this.mainContrastColor; + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.edgeLabelBackground = lighten(this.labelBackground, 25); + this.actorBorder = this.border1; + this.actorBkg = this.mainBkg; + this.actorTextColor = this.mainContrastColor; + this.actorLineColor = this.mainContrastColor; + this.signalColor = this.mainContrastColor; + this.signalTextColor = this.mainContrastColor; + this.labelBoxBkgColor = this.actorBkg; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.mainContrastColor; + this.loopTextColor = this.mainContrastColor; + this.noteBorderColor = this.secondaryBorderColor; + this.noteBkgColor = this.secondBkg; + this.noteTextColor = this.secondaryTextColor; + this.activationBorderColor = this.border1; + this.activationBkgColor = this.secondBkg; + this.altSectionBkgColor = this.background; + this.taskBkgColor = lighten(this.mainBkg, 23); + this.taskTextColor = this.darkTextColor; + this.taskTextLightColor = this.mainContrastColor; + this.taskTextOutsideColor = this.taskTextLightColor; + this.gridColor = this.mainContrastColor; + this.doneTaskBkgColor = this.mainContrastColor; + this.taskTextDarkColor = this.darkTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#555"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = "#f4f4f4"; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + this.cScale1 = this.cScale1 || "#0b0000"; + this.cScale2 = this.cScale2 || "#4d1037"; + this.cScale3 = this.cScale3 || "#3f5258"; + this.cScale4 = this.cScale4 || "#4f2f1b"; + this.cScale5 = this.cScale5 || "#6e0a0a"; + this.cScale6 = this.cScale6 || "#3b0048"; + this.cScale7 = this.cScale7 || "#995a01"; + this.cScale8 = this.cScale8 || "#154706"; + this.cScale9 = this.cScale9 || "#161722"; + this.cScale10 = this.cScale10 || "#00296f"; + this.cScale11 = this.cScale11 || "#01629c"; + this.cScale12 = this.cScale12 || "#010029"; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(-10 + i * 4) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(-7 + i * 4) }); + } + this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? "black" : this.labelTextColor); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["pie" + i] = this["cScale" + i]; + } + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#3498db,#2ecc71,#e74c3c,#f1c40f,#bdc3c7,#ffffff,#34495e,#9b59b6,#1abc9c,#e67e22" + }; + this.classText = this.primaryTextColor; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = lighten(this.secondaryColor, 20); + this.git1 = lighten(this.pie2 || this.secondaryColor, 20); + this.git2 = lighten(this.pie3 || this.tertiaryColor, 20); + this.git3 = lighten(this.pie4 || adjust(this.primaryColor, { h: -30 }), 20); + this.git4 = lighten(this.pie5 || adjust(this.primaryColor, { h: -60 }), 20); + this.git5 = lighten(this.pie6 || adjust(this.primaryColor, { h: -90 }), 10); + this.git6 = lighten(this.pie7 || adjust(this.primaryColor, { h: 60 }), 10); + this.git7 = lighten(this.pie8 || adjust(this.primaryColor, { h: 120 }), 20); + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || lighten(this.background, 12); + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || lighten(this.background, 2); + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$3 = (userOverrides) => { + const theme2 = new Theme$3(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$2 = class Theme3 { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#ECECFF"; + this.secondaryColor = adjust(this.primaryColor, { h: 120 }); + this.secondaryColor = "#ffffde"; + this.tertiaryColor = adjust(this.primaryColor, { h: -160 }); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.background = "white"; + this.mainBkg = "#ECECFF"; + this.secondBkg = "#ffffde"; + this.lineColor = "#333333"; + this.border1 = "#9370DB"; + this.border2 = "#aaaa33"; + this.arrowheadColor = "#333333"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.labelBackground = "#e8e8e8"; + this.textColor = "#333"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "calculated"; + this.edgeLabelBackground = "calculated"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "black"; + this.actorLineColor = "grey"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "calculated"; + this.altSectionBkgColor = "calculated"; + this.sectionBkgColor2 = "calculated"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "calculated"; + this.taskTextLightColor = "calculated"; + this.taskTextColor = this.taskTextLightColor; + this.taskTextDarkColor = "calculated"; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.taskTextClickableColor = "calculated"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "calculated"; + this.critBorderColor = "calculated"; + this.critBkgColor = "calculated"; + this.todayLineColor = "calculated"; + this.sectionBkgColor = rgba(102, 102, 255, 0.49); + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "#fff400"; + this.taskBorderColor = "#534fbc"; + this.taskBkgColor = "#8a90dd"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "black"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "#534fbc"; + this.activeTaskBkgColor = "#bfc7ff"; + this.gridColor = "lightgrey"; + this.doneTaskBkgColor = "lightgrey"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#ff8888"; + this.critBkgColor = "red"; + this.todayLineColor = "red"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + this.updateColors(); + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + this["cScalePeer1"] = this["cScalePeer1"] || darken(this.secondaryColor, 45); + this["cScalePeer2"] = this["cScalePeer2"] || darken(this.tertiaryColor, 40); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 10); + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 25); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || adjust(this["cScale" + i], { h: 180 }); + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 30, l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 30, l: -(7 + i * 5) }); + } + this.scaleLabelColor = this.scaleLabelColor !== "calculated" && this.scaleLabelColor ? this.scaleLabelColor : this.labelTextColor; + if (this.labelTextColor !== "calculated") { + this.cScaleLabel0 = this.cScaleLabel0 || invert(this.labelTextColor); + this.cScaleLabel3 = this.cScaleLabel3 || invert(this.labelTextColor); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.labelTextColor; + } + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.titleColor = this.textColor; + this.edgeLabelBackground = this.labelBackground; + this.actorBorder = lighten(this.border1, 23); + this.actorBkg = this.mainBkg; + this.labelBoxBkgColor = this.actorBkg; + this.signalColor = this.textColor; + this.signalTextColor = this.textColor; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.actorTextColor; + this.loopTextColor = this.actorTextColor; + this.noteBorderColor = this.border2; + this.noteTextColor = this.actorTextColor; + this.taskTextColor = this.taskTextLightColor; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f0f0f0"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.nodeBorder; + this.specialStateColor = this.lineColor; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || adjust(this.tertiaryColor, { l: -40 }); + this.pie4 = this.pie4 || adjust(this.primaryColor, { l: -10 }); + this.pie5 = this.pie5 || adjust(this.secondaryColor, { l: -30 }); + this.pie6 = this.pie6 || adjust(this.tertiaryColor, { l: -20 }); + this.pie7 = this.pie7 || adjust(this.primaryColor, { h: 60, l: -20 }); + this.pie8 = this.pie8 || adjust(this.primaryColor, { h: -60, l: -40 }); + this.pie9 = this.pie9 || adjust(this.primaryColor, { h: 120, l: -40 }); + this.pie10 = this.pie10 || adjust(this.primaryColor, { h: 60, l: -40 }); + this.pie11 = this.pie11 || adjust(this.primaryColor, { h: -90, l: -40 }); + this.pie12 = this.pie12 || adjust(this.primaryColor, { h: 120, l: -30 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#ECECFF,#8493A6,#FFC3A0,#DCDDE1,#B8E994,#D1A36F,#C3CDE6,#FFB6C1,#496078,#F8F3E3" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.labelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || darken(invert(this.git0), 25); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$2 = (userOverrides) => { + const theme2 = new Theme$2(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$1 = class Theme4 { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#cde498"; + this.secondaryColor = "#cdffb2"; + this.background = "white"; + this.mainBkg = "#cde498"; + this.secondBkg = "#cdffb2"; + this.lineColor = "green"; + this.border1 = "#13540c"; + this.border2 = "#6eaa49"; + this.arrowheadColor = "green"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.tertiaryColor = lighten("#cde498", 10); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.primaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "#333"; + this.edgeLabelBackground = "#e8e8e8"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "black"; + this.actorLineColor = "grey"; + this.signalColor = "#333"; + this.signalTextColor = "#333"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "#326932"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "#6eaa49"; + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "#6eaa49"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "#487e3a"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "black"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "lightgrey"; + this.doneTaskBkgColor = "lightgrey"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#ff8888"; + this.critBkgColor = "red"; + this.todayLineColor = "red"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.actorBorder = darken(this.mainBkg, 20); + this.actorBkg = this.mainBkg; + this.labelBoxBkgColor = this.actorBkg; + this.labelTextColor = this.actorTextColor; + this.loopTextColor = this.actorTextColor; + this.noteBorderColor = this.border2; + this.noteTextColor = this.actorTextColor; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + this["cScalePeer1"] = this["cScalePeer1"] || darken(this.secondaryColor, 45); + this["cScalePeer2"] = this["cScalePeer2"] || darken(this.tertiaryColor, 40); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 10); + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 25); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || adjust(this["cScale" + i], { h: 180 }); + } + this.scaleLabelColor = this.scaleLabelColor !== "calculated" && this.scaleLabelColor ? this.scaleLabelColor : this.labelTextColor; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(8 + i * 5) }); + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.taskBorderColor = this.border1; + this.taskTextColor = this.taskTextLightColor; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.activeTaskBorderColor = this.taskBorderColor; + this.activeTaskBkgColor = this.mainBkg; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f0f0f0"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = this.lineColor; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || this.tertiaryColor; + this.pie4 = this.pie4 || adjust(this.primaryColor, { l: -30 }); + this.pie5 = this.pie5 || adjust(this.secondaryColor, { l: -30 }); + this.pie6 = this.pie6 || adjust(this.tertiaryColor, { h: 40, l: -40 }); + this.pie7 = this.pie7 || adjust(this.primaryColor, { h: 60, l: -10 }); + this.pie8 = this.pie8 || adjust(this.primaryColor, { h: -60, l: -10 }); + this.pie9 = this.pie9 || adjust(this.primaryColor, { h: 120, l: 0 }); + this.pie10 = this.pie10 || adjust(this.primaryColor, { h: 60, l: -50 }); + this.pie11 = this.pie11 || adjust(this.primaryColor, { h: -60, l: -50 }); + this.pie12 = this.pie12 || adjust(this.primaryColor, { h: 120, l: -50 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#CDE498,#FF6B6B,#A0D2DB,#D7BDE2,#F0F0F0,#FFC3A0,#7FD8BE,#FF9A8B,#FAF3E0,#FFF176" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.edgeLabelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$1 = (userOverrides) => { + const theme2 = new Theme$1(); + theme2.calculate(userOverrides); + return theme2; +}; +class Theme5 { + constructor() { + this.primaryColor = "#eee"; + this.contrast = "#707070"; + this.secondaryColor = lighten(this.contrast, 55); + this.background = "#ffffff"; + this.tertiaryColor = adjust(this.primaryColor, { h: -160 }); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.mainBkg = "#eee"; + this.secondBkg = "calculated"; + this.lineColor = "#666"; + this.border1 = "#999"; + this.border2 = "calculated"; + this.note = "#ffa"; + this.text = "#333"; + this.critical = "#d42"; + this.done = "#bbb"; + this.arrowheadColor = "#333333"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "calculated"; + this.edgeLabelBackground = "white"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "calculated"; + this.actorLineColor = "calculated"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "calculated"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "calculated"; + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "calculated"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "calculated"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "calculated"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "calculated"; + this.critBkgColor = "calculated"; + this.critBorderColor = "calculated"; + this.todayLineColor = "calculated"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.secondBkg = lighten(this.contrast, 55); + this.border2 = this.contrast; + this.actorBorder = lighten(this.border1, 23); + this.actorBkg = this.mainBkg; + this.actorTextColor = this.text; + this.actorLineColor = this.lineColor; + this.signalColor = this.text; + this.signalTextColor = this.text; + this.labelBoxBkgColor = this.actorBkg; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.text; + this.loopTextColor = this.text; + this.noteBorderColor = "#999"; + this.noteBkgColor = "#666"; + this.noteTextColor = "#fff"; + this.cScale0 = this.cScale0 || "#555"; + this.cScale1 = this.cScale1 || "#F4F4F4"; + this.cScale2 = this.cScale2 || "#555"; + this.cScale3 = this.cScale3 || "#BBB"; + this.cScale4 = this.cScale4 || "#777"; + this.cScale5 = this.cScale5 || "#999"; + this.cScale6 = this.cScale6 || "#DDD"; + this.cScale7 = this.cScale7 || "#FFF"; + this.cScale8 = this.cScale8 || "#DDD"; + this.cScale9 = this.cScale9 || "#BBB"; + this.cScale10 = this.cScale10 || "#999"; + this.cScale11 = this.cScale11 || "#777"; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + if (this.darkMode) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } else { + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 10); + } + } + this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? "black" : this.labelTextColor); + this["cScaleLabel0"] = this["cScaleLabel0"] || this.cScale1; + this["cScaleLabel2"] = this["cScaleLabel2"] || this.cScale1; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { l: -(8 + i * 5) }); + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.titleColor = this.text; + this.sectionBkgColor = lighten(this.contrast, 30); + this.sectionBkgColor2 = lighten(this.contrast, 30); + this.taskBorderColor = darken(this.contrast, 10); + this.taskBkgColor = this.contrast; + this.taskTextColor = this.taskTextLightColor; + this.taskTextDarkColor = this.text; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.activeTaskBorderColor = this.taskBorderColor; + this.activeTaskBkgColor = this.mainBkg; + this.gridColor = lighten(this.border1, 30); + this.doneTaskBkgColor = this.done; + this.doneTaskBorderColor = this.lineColor; + this.critBkgColor = this.critical; + this.critBorderColor = darken(this.critBkgColor, 10); + this.todayLineColor = this.critBkgColor; + this.transitionColor = this.transitionColor || "#000"; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f4f4f4"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.stateBorder = this.stateBorder || "#000"; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = "#222"; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["pie" + i] = this["cScale" + i]; + } + this.pie12 = this.pie0; + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#EEE,#6BB8E4,#8ACB88,#C7ACD6,#E8DCC2,#FFB2A8,#FFF380,#7E8D91,#FFD8B1,#FAF3E0" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.edgeLabelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = darken(this.pie1, 25) || this.primaryColor; + this.git1 = this.pie2 || this.secondaryColor; + this.git2 = this.pie3 || this.tertiaryColor; + this.git3 = this.pie4 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.pie5 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.pie6 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.pie7 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.pie8 || adjust(this.primaryColor, { h: 120 }); + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.branchLabelColor = this.branchLabelColor || this.labelTextColor; + this.gitBranchLabel0 = this.branchLabelColor; + this.gitBranchLabel1 = "white"; + this.gitBranchLabel2 = this.branchLabelColor; + this.gitBranchLabel3 = "white"; + this.gitBranchLabel4 = this.branchLabelColor; + this.gitBranchLabel5 = this.branchLabelColor; + this.gitBranchLabel6 = this.branchLabelColor; + this.gitBranchLabel7 = this.branchLabelColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +} +const getThemeVariables = (userOverrides) => { + const theme2 = new Theme5(); + theme2.calculate(userOverrides); + return theme2; +}; +const theme = { + base: { + getThemeVariables: getThemeVariables$4 + }, + dark: { + getThemeVariables: getThemeVariables$3 + }, + default: { + getThemeVariables: getThemeVariables$2 + }, + forest: { + getThemeVariables: getThemeVariables$1 + }, + neutral: { + getThemeVariables + } +}; +const defaultConfigJson = { + "flowchart": { + "useMaxWidth": true, + "titleTopMargin": 25, + "subGraphTitleMargin": { + "top": 0, + "bottom": 0 + }, + "diagramPadding": 8, + "htmlLabels": true, + "nodeSpacing": 50, + "rankSpacing": 50, + "curve": "basis", + "padding": 15, + "defaultRenderer": "dagre-wrapper", + "wrappingWidth": 200 + }, + "sequence": { + "useMaxWidth": true, + "hideUnusedParticipants": false, + "activationWidth": 10, + "diagramMarginX": 50, + "diagramMarginY": 10, + "actorMargin": 50, + "width": 150, + "height": 65, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "mirrorActors": true, + "forceMenus": false, + "bottomMarginAdj": 1, + "rightAngles": false, + "showSequenceNumbers": false, + "actorFontSize": 14, + "actorFontFamily": '"Open Sans", sans-serif', + "actorFontWeight": 400, + "noteFontSize": 14, + "noteFontFamily": '"trebuchet ms", verdana, arial, sans-serif', + "noteFontWeight": 400, + "noteAlign": "center", + "messageFontSize": 16, + "messageFontFamily": '"trebuchet ms", verdana, arial, sans-serif', + "messageFontWeight": 400, + "wrap": false, + "wrapPadding": 10, + "labelBoxWidth": 50, + "labelBoxHeight": 20 + }, + "gantt": { + "useMaxWidth": true, + "titleTopMargin": 25, + "barHeight": 20, + "barGap": 4, + "topPadding": 50, + "rightPadding": 75, + "leftPadding": 75, + "gridLineStartPadding": 35, + "fontSize": 11, + "sectionFontSize": 11, + "numberSectionStyles": 4, + "axisFormat": "%Y-%m-%d", + "topAxis": false, + "displayMode": "", + "weekday": "sunday" + }, + "journey": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "leftMargin": 150, + "width": 150, + "height": 50, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "bottomMarginAdj": 1, + "rightAngles": false, + "taskFontSize": 14, + "taskFontFamily": '"Open Sans", sans-serif', + "taskMargin": 50, + "activationWidth": 10, + "textPlacement": "fo", + "actorColours": [ + "#8FBC8F", + "#7CFC00", + "#00FFFF", + "#20B2AA", + "#B0E0E6", + "#FFFFE0" + ], + "sectionFills": [ + "#191970", + "#8B008B", + "#4B0082", + "#2F4F4F", + "#800000", + "#8B4513", + "#00008B" + ], + "sectionColours": [ + "#fff" + ] + }, + "class": { + "useMaxWidth": true, + "titleTopMargin": 25, + "arrowMarkerAbsolute": false, + "dividerMargin": 10, + "padding": 5, + "textHeight": 10, + "defaultRenderer": "dagre-wrapper", + "htmlLabels": false + }, + "state": { + "useMaxWidth": true, + "titleTopMargin": 25, + "dividerMargin": 10, + "sizeUnit": 5, + "padding": 8, + "textHeight": 10, + "titleShift": -15, + "noteMargin": 10, + "forkWidth": 70, + "forkHeight": 7, + "miniPadding": 2, + "fontSizeFactor": 5.02, + "fontSize": 24, + "labelHeight": 16, + "edgeLengthFactor": "20", + "compositTitleSize": 35, + "radius": 5, + "defaultRenderer": "dagre-wrapper" + }, + "er": { + "useMaxWidth": true, + "titleTopMargin": 25, + "diagramPadding": 20, + "layoutDirection": "TB", + "minEntityWidth": 100, + "minEntityHeight": 75, + "entityPadding": 15, + "stroke": "gray", + "fill": "honeydew", + "fontSize": 12 + }, + "pie": { + "useMaxWidth": true, + "textPosition": 0.75 + }, + "quadrantChart": { + "useMaxWidth": true, + "chartWidth": 500, + "chartHeight": 500, + "titleFontSize": 20, + "titlePadding": 10, + "quadrantPadding": 5, + "xAxisLabelPadding": 5, + "yAxisLabelPadding": 5, + "xAxisLabelFontSize": 16, + "yAxisLabelFontSize": 16, + "quadrantLabelFontSize": 16, + "quadrantTextTopPadding": 5, + "pointTextPadding": 5, + "pointLabelFontSize": 12, + "pointRadius": 5, + "xAxisPosition": "top", + "yAxisPosition": "left", + "quadrantInternalBorderStrokeWidth": 1, + "quadrantExternalBorderStrokeWidth": 2 + }, + "xyChart": { + "useMaxWidth": true, + "width": 700, + "height": 500, + "titleFontSize": 20, + "titlePadding": 10, + "showTitle": true, + "xAxis": { + "$ref": "#/$defs/XYChartAxisConfig", + "showLabel": true, + "labelFontSize": 14, + "labelPadding": 5, + "showTitle": true, + "titleFontSize": 16, + "titlePadding": 5, + "showTick": true, + "tickLength": 5, + "tickWidth": 2, + "showAxisLine": true, + "axisLineWidth": 2 + }, + "yAxis": { + "$ref": "#/$defs/XYChartAxisConfig", + "showLabel": true, + "labelFontSize": 14, + "labelPadding": 5, + "showTitle": true, + "titleFontSize": 16, + "titlePadding": 5, + "showTick": true, + "tickLength": 5, + "tickWidth": 2, + "showAxisLine": true, + "axisLineWidth": 2 + }, + "chartOrientation": "vertical", + "plotReservedSpacePercent": 50 + }, + "requirement": { + "useMaxWidth": true, + "rect_fill": "#f9f9f9", + "text_color": "#333", + "rect_border_size": "0.5px", + "rect_border_color": "#bbb", + "rect_min_width": 200, + "rect_min_height": 200, + "fontSize": 14, + "rect_padding": 10, + "line_height": 20 + }, + "mindmap": { + "useMaxWidth": true, + "padding": 10, + "maxNodeWidth": 200 + }, + "timeline": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "leftMargin": 150, + "width": 150, + "height": 50, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "bottomMarginAdj": 1, + "rightAngles": false, + "taskFontSize": 14, + "taskFontFamily": '"Open Sans", sans-serif', + "taskMargin": 50, + "activationWidth": 10, + "textPlacement": "fo", + "actorColours": [ + "#8FBC8F", + "#7CFC00", + "#00FFFF", + "#20B2AA", + "#B0E0E6", + "#FFFFE0" + ], + "sectionFills": [ + "#191970", + "#8B008B", + "#4B0082", + "#2F4F4F", + "#800000", + "#8B4513", + "#00008B" + ], + "sectionColours": [ + "#fff" + ], + "disableMulticolor": false + }, + "gitGraph": { + "useMaxWidth": true, + "titleTopMargin": 25, + "diagramPadding": 8, + "nodeLabel": { + "width": 75, + "height": 100, + "x": -25, + "y": 0 + }, + "mainBranchName": "main", + "mainBranchOrder": 0, + "showCommitLabel": true, + "showBranches": true, + "rotateCommitLabel": true, + "parallelCommits": false, + "arrowMarkerAbsolute": false + }, + "c4": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "c4ShapeMargin": 50, + "c4ShapePadding": 20, + "width": 216, + "height": 60, + "boxMargin": 10, + "c4ShapeInRow": 4, + "nextLinePaddingX": 0, + "c4BoundaryInRow": 2, + "personFontSize": 14, + "personFontFamily": '"Open Sans", sans-serif', + "personFontWeight": "normal", + "external_personFontSize": 14, + "external_personFontFamily": '"Open Sans", sans-serif', + "external_personFontWeight": "normal", + "systemFontSize": 14, + "systemFontFamily": '"Open Sans", sans-serif', + "systemFontWeight": "normal", + "external_systemFontSize": 14, + "external_systemFontFamily": '"Open Sans", sans-serif', + "external_systemFontWeight": "normal", + "system_dbFontSize": 14, + "system_dbFontFamily": '"Open Sans", sans-serif', + "system_dbFontWeight": "normal", + "external_system_dbFontSize": 14, + "external_system_dbFontFamily": '"Open Sans", sans-serif', + "external_system_dbFontWeight": "normal", + "system_queueFontSize": 14, + "system_queueFontFamily": '"Open Sans", sans-serif', + "system_queueFontWeight": "normal", + "external_system_queueFontSize": 14, + "external_system_queueFontFamily": '"Open Sans", sans-serif', + "external_system_queueFontWeight": "normal", + "boundaryFontSize": 14, + "boundaryFontFamily": '"Open Sans", sans-serif', + "boundaryFontWeight": "normal", + "messageFontSize": 12, + "messageFontFamily": '"Open Sans", sans-serif', + "messageFontWeight": "normal", + "containerFontSize": 14, + "containerFontFamily": '"Open Sans", sans-serif', + "containerFontWeight": "normal", + "external_containerFontSize": 14, + "external_containerFontFamily": '"Open Sans", sans-serif', + "external_containerFontWeight": "normal", + "container_dbFontSize": 14, + "container_dbFontFamily": '"Open Sans", sans-serif', + "container_dbFontWeight": "normal", + "external_container_dbFontSize": 14, + "external_container_dbFontFamily": '"Open Sans", sans-serif', + "external_container_dbFontWeight": "normal", + "container_queueFontSize": 14, + "container_queueFontFamily": '"Open Sans", sans-serif', + "container_queueFontWeight": "normal", + "external_container_queueFontSize": 14, + "external_container_queueFontFamily": '"Open Sans", sans-serif', + "external_container_queueFontWeight": "normal", + "componentFontSize": 14, + "componentFontFamily": '"Open Sans", sans-serif', + "componentFontWeight": "normal", + "external_componentFontSize": 14, + "external_componentFontFamily": '"Open Sans", sans-serif', + "external_componentFontWeight": "normal", + "component_dbFontSize": 14, + "component_dbFontFamily": '"Open Sans", sans-serif', + "component_dbFontWeight": "normal", + "external_component_dbFontSize": 14, + "external_component_dbFontFamily": '"Open Sans", sans-serif', + "external_component_dbFontWeight": "normal", + "component_queueFontSize": 14, + "component_queueFontFamily": '"Open Sans", sans-serif', + "component_queueFontWeight": "normal", + "external_component_queueFontSize": 14, + "external_component_queueFontFamily": '"Open Sans", sans-serif', + "external_component_queueFontWeight": "normal", + "wrap": true, + "wrapPadding": 10, + "person_bg_color": "#08427B", + "person_border_color": "#073B6F", + "external_person_bg_color": "#686868", + "external_person_border_color": "#8A8A8A", + "system_bg_color": "#1168BD", + "system_border_color": "#3C7FC0", + "system_db_bg_color": "#1168BD", + "system_db_border_color": "#3C7FC0", + "system_queue_bg_color": "#1168BD", + "system_queue_border_color": "#3C7FC0", + "external_system_bg_color": "#999999", + "external_system_border_color": "#8A8A8A", + "external_system_db_bg_color": "#999999", + "external_system_db_border_color": "#8A8A8A", + "external_system_queue_bg_color": "#999999", + "external_system_queue_border_color": "#8A8A8A", + "container_bg_color": "#438DD5", + "container_border_color": "#3C7FC0", + "container_db_bg_color": "#438DD5", + "container_db_border_color": "#3C7FC0", + "container_queue_bg_color": "#438DD5", + "container_queue_border_color": "#3C7FC0", + "external_container_bg_color": "#B3B3B3", + "external_container_border_color": "#A6A6A6", + "external_container_db_bg_color": "#B3B3B3", + "external_container_db_border_color": "#A6A6A6", + "external_container_queue_bg_color": "#B3B3B3", + "external_container_queue_border_color": "#A6A6A6", + "component_bg_color": "#85BBF0", + "component_border_color": "#78A8D8", + "component_db_bg_color": "#85BBF0", + "component_db_border_color": "#78A8D8", + "component_queue_bg_color": "#85BBF0", + "component_queue_border_color": "#78A8D8", + "external_component_bg_color": "#CCCCCC", + "external_component_border_color": "#BFBFBF", + "external_component_db_bg_color": "#CCCCCC", + "external_component_db_border_color": "#BFBFBF", + "external_component_queue_bg_color": "#CCCCCC", + "external_component_queue_border_color": "#BFBFBF" + }, + "sankey": { + "useMaxWidth": true, + "width": 600, + "height": 400, + "linkColor": "gradient", + "nodeAlignment": "justify", + "showValues": true, + "prefix": "", + "suffix": "" + }, + "block": { + "useMaxWidth": true, + "padding": 8 + }, + "theme": "default", + "maxTextSize": 5e4, + "maxEdges": 500, + "darkMode": false, + "fontFamily": '"trebuchet ms", verdana, arial, sans-serif;', + "logLevel": 5, + "securityLevel": "strict", + "startOnLoad": true, + "arrowMarkerAbsolute": false, + "secure": [ + "secure", + "securityLevel", + "startOnLoad", + "maxTextSize", + "maxEdges" + ], + "legacyMathML": false, + "deterministicIds": false, + "fontSize": 16 +}; +const config = { + ...defaultConfigJson, + // Set, even though they're `undefined` so that `configKeys` finds these keys + // TODO: Should we replace these with `null` so that they can go in the JSON Schema? + deterministicIDSeed: void 0, + themeCSS: void 0, + // add non-JSON default config values + themeVariables: theme["default"].getThemeVariables(), + sequence: { + ...defaultConfigJson.sequence, + messageFont: function() { + return { + fontFamily: this.messageFontFamily, + fontSize: this.messageFontSize, + fontWeight: this.messageFontWeight + }; + }, + noteFont: function() { + return { + fontFamily: this.noteFontFamily, + fontSize: this.noteFontSize, + fontWeight: this.noteFontWeight + }; + }, + actorFont: function() { + return { + fontFamily: this.actorFontFamily, + fontSize: this.actorFontSize, + fontWeight: this.actorFontWeight + }; + } + }, + gantt: { + ...defaultConfigJson.gantt, + tickInterval: void 0, + useWidth: void 0 + // can probably be removed since `configKeys` already includes this + }, + c4: { + ...defaultConfigJson.c4, + useWidth: void 0, + personFont: function() { + return { + fontFamily: this.personFontFamily, + fontSize: this.personFontSize, + fontWeight: this.personFontWeight + }; + }, + external_personFont: function() { + return { + fontFamily: this.external_personFontFamily, + fontSize: this.external_personFontSize, + fontWeight: this.external_personFontWeight + }; + }, + systemFont: function() { + return { + fontFamily: this.systemFontFamily, + fontSize: this.systemFontSize, + fontWeight: this.systemFontWeight + }; + }, + external_systemFont: function() { + return { + fontFamily: this.external_systemFontFamily, + fontSize: this.external_systemFontSize, + fontWeight: this.external_systemFontWeight + }; + }, + system_dbFont: function() { + return { + fontFamily: this.system_dbFontFamily, + fontSize: this.system_dbFontSize, + fontWeight: this.system_dbFontWeight + }; + }, + external_system_dbFont: function() { + return { + fontFamily: this.external_system_dbFontFamily, + fontSize: this.external_system_dbFontSize, + fontWeight: this.external_system_dbFontWeight + }; + }, + system_queueFont: function() { + return { + fontFamily: this.system_queueFontFamily, + fontSize: this.system_queueFontSize, + fontWeight: this.system_queueFontWeight + }; + }, + external_system_queueFont: function() { + return { + fontFamily: this.external_system_queueFontFamily, + fontSize: this.external_system_queueFontSize, + fontWeight: this.external_system_queueFontWeight + }; + }, + containerFont: function() { + return { + fontFamily: this.containerFontFamily, + fontSize: this.containerFontSize, + fontWeight: this.containerFontWeight + }; + }, + external_containerFont: function() { + return { + fontFamily: this.external_containerFontFamily, + fontSize: this.external_containerFontSize, + fontWeight: this.external_containerFontWeight + }; + }, + container_dbFont: function() { + return { + fontFamily: this.container_dbFontFamily, + fontSize: this.container_dbFontSize, + fontWeight: this.container_dbFontWeight + }; + }, + external_container_dbFont: function() { + return { + fontFamily: this.external_container_dbFontFamily, + fontSize: this.external_container_dbFontSize, + fontWeight: this.external_container_dbFontWeight + }; + }, + container_queueFont: function() { + return { + fontFamily: this.container_queueFontFamily, + fontSize: this.container_queueFontSize, + fontWeight: this.container_queueFontWeight + }; + }, + external_container_queueFont: function() { + return { + fontFamily: this.external_container_queueFontFamily, + fontSize: this.external_container_queueFontSize, + fontWeight: this.external_container_queueFontWeight + }; + }, + componentFont: function() { + return { + fontFamily: this.componentFontFamily, + fontSize: this.componentFontSize, + fontWeight: this.componentFontWeight + }; + }, + external_componentFont: function() { + return { + fontFamily: this.external_componentFontFamily, + fontSize: this.external_componentFontSize, + fontWeight: this.external_componentFontWeight + }; + }, + component_dbFont: function() { + return { + fontFamily: this.component_dbFontFamily, + fontSize: this.component_dbFontSize, + fontWeight: this.component_dbFontWeight + }; + }, + external_component_dbFont: function() { + return { + fontFamily: this.external_component_dbFontFamily, + fontSize: this.external_component_dbFontSize, + fontWeight: this.external_component_dbFontWeight + }; + }, + component_queueFont: function() { + return { + fontFamily: this.component_queueFontFamily, + fontSize: this.component_queueFontSize, + fontWeight: this.component_queueFontWeight + }; + }, + external_component_queueFont: function() { + return { + fontFamily: this.external_component_queueFontFamily, + fontSize: this.external_component_queueFontSize, + fontWeight: this.external_component_queueFontWeight + }; + }, + boundaryFont: function() { + return { + fontFamily: this.boundaryFontFamily, + fontSize: this.boundaryFontSize, + fontWeight: this.boundaryFontWeight + }; + }, + messageFont: function() { + return { + fontFamily: this.messageFontFamily, + fontSize: this.messageFontSize, + fontWeight: this.messageFontWeight + }; + } + }, + pie: { + ...defaultConfigJson.pie, + useWidth: 984 + }, + xyChart: { + ...defaultConfigJson.xyChart, + useWidth: void 0 + }, + requirement: { + ...defaultConfigJson.requirement, + useWidth: void 0 + }, + gitGraph: { + ...defaultConfigJson.gitGraph, + // TODO: This is a temporary override for `gitGraph`, since every other + // diagram does have `useMaxWidth`, but instead sets it to `true`. + // Should we set this to `true` instead? + useMaxWidth: false + }, + sankey: { + ...defaultConfigJson.sankey, + // this is false, unlike every other diagram (other than gitGraph) + // TODO: can we make this default to `true` instead? + useMaxWidth: false + } +}; +const keyify = (obj, prefix = "") => Object.keys(obj).reduce((res, el) => { + if (Array.isArray(obj[el])) { + return res; + } else if (typeof obj[el] === "object" && obj[el] !== null) { + return [...res, prefix + el, ...keyify(obj[el], "")]; + } + return [...res, prefix + el]; +}, []); +const configKeys = new Set(keyify(config, "")); +const defaultConfig$2 = config; +const sanitizeDirective = (args) => { + log$1.debug("sanitizeDirective called with", args); + if (typeof args !== "object" || args == null) { + return; + } + if (Array.isArray(args)) { + args.forEach((arg) => sanitizeDirective(arg)); + return; + } + for (const key of Object.keys(args)) { + log$1.debug("Checking key", key); + if (key.startsWith("__") || key.includes("proto") || key.includes("constr") || !configKeys.has(key) || args[key] == null) { + log$1.debug("sanitize deleting key: ", key); + delete args[key]; + continue; + } + if (typeof args[key] === "object") { + log$1.debug("sanitizing object", key); + sanitizeDirective(args[key]); + continue; + } + const cssMatchers = ["themeCSS", "fontFamily", "altFontFamily"]; + for (const cssKey of cssMatchers) { + if (key.includes(cssKey)) { + log$1.debug("sanitizing css option", key); + args[key] = sanitizeCss(args[key]); + } + } + } + if (args.themeVariables) { + for (const k of Object.keys(args.themeVariables)) { + const val = args.themeVariables[k]; + if ((val == null ? void 0 : val.match) && !val.match(/^[\d "#%(),.;A-Za-z]+$/)) { + args.themeVariables[k] = ""; + } + } + } + log$1.debug("After sanitization", args); +}; +const sanitizeCss = (str2) => { + let startCnt = 0; + let endCnt = 0; + for (const element of str2) { + if (startCnt < endCnt) { + return "{ /* ERROR: Unbalanced CSS */ }"; + } + if (element === "{") { + startCnt++; + } else if (element === "}") { + endCnt++; + } + } + if (startCnt !== endCnt) { + return "{ /* ERROR: Unbalanced CSS */ }"; + } + return str2; +}; +const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s; +const directiveRegex = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; +const anyCommentRegex = /\s*%%.*\n/gm; +class UnknownDiagramError extends Error { + constructor(message) { + super(message); + this.name = "UnknownDiagramError"; + } +} +const detectors = {}; +const detectType = function(text, config2) { + text = text.replace(frontMatterRegex, "").replace(directiveRegex, "").replace(anyCommentRegex, "\n"); + for (const [key, { detector: detector2 }] of Object.entries(detectors)) { + const diagram2 = detector2(text, config2); + if (diagram2) { + return key; + } + } + throw new UnknownDiagramError( + `No diagram type detected matching given configuration for text: ${text}` + ); +}; +const registerLazyLoadedDiagrams = (...diagrams2) => { + for (const { id: id2, detector: detector2, loader: loader2 } of diagrams2) { + addDetector(id2, detector2, loader2); + } +}; +const addDetector = (key, detector2, loader2) => { + if (detectors[key]) { + log$1.error(`Detector with key ${key} already exists`); + } else { + detectors[key] = { detector: detector2, loader: loader2 }; + } + log$1.debug(`Detector with key ${key} added${loader2 ? " with loader" : ""}`); +}; +const getDiagramLoader = (key) => { + return detectors[key].loader; +}; +const assignWithDepth = (dst, src, { depth = 2, clobber = false } = {}) => { + const config2 = { depth, clobber }; + if (Array.isArray(src) && !Array.isArray(dst)) { + src.forEach((s) => assignWithDepth(dst, s, config2)); + return dst; + } else if (Array.isArray(src) && Array.isArray(dst)) { + src.forEach((s) => { + if (!dst.includes(s)) { + dst.push(s); + } + }); + return dst; + } + if (dst === void 0 || depth <= 0) { + if (dst !== void 0 && dst !== null && typeof dst === "object" && typeof src === "object") { + return Object.assign(dst, src); + } else { + return src; + } + } + if (src !== void 0 && typeof dst === "object" && typeof src === "object") { + Object.keys(src).forEach((key) => { + if (typeof src[key] === "object" && (dst[key] === void 0 || typeof dst[key] === "object")) { + if (dst[key] === void 0) { + dst[key] = Array.isArray(src[key]) ? [] : {}; + } + dst[key] = assignWithDepth(dst[key], src[key], { depth: depth - 1, clobber }); + } else if (clobber || typeof dst[key] !== "object" && typeof src[key] !== "object") { + dst[key] = src[key]; + } + }); + } + return dst; +}; +const assignWithDepth$1 = assignWithDepth; +const ZERO_WIDTH_SPACE = "​"; +const d3CurveTypes = { + curveBasis, + curveBasisClosed, + curveBasisOpen, + curveBumpX: bumpX, + curveBumpY: bumpY, + curveBundle, + curveCardinalClosed, + curveCardinalOpen, + curveCardinal, + curveCatmullRomClosed, + curveCatmullRomOpen, + curveCatmullRom, + curveLinear, + curveLinearClosed, + curveMonotoneX: monotoneX, + curveMonotoneY: monotoneY, + curveNatural, + curveStep, + curveStepAfter: stepAfter, + curveStepBefore: stepBefore +}; +const directiveWithoutOpen = /\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; +const detectInit = function(text, config2) { + const inits = detectDirective(text, /(?:init\b)|(?:initialize\b)/); + let results = {}; + if (Array.isArray(inits)) { + const args = inits.map((init2) => init2.args); + sanitizeDirective(args); + results = assignWithDepth$1(results, [...args]); + } else { + results = inits.args; + } + if (!results) { + return; + } + let type2 = detectType(text, config2); + const prop = "config"; + if (results[prop] !== void 0) { + if (type2 === "flowchart-v2") { + type2 = "flowchart"; + } + results[type2] = results[prop]; + delete results[prop]; + } + return results; +}; +const detectDirective = function(text, type2 = null) { + try { + const commentWithoutDirectives = new RegExp( + `[%]{2}(?![{]${directiveWithoutOpen.source})(?=[}][%]{2}).* +`, + "ig" + ); + text = text.trim().replace(commentWithoutDirectives, "").replace(/'/gm, '"'); + log$1.debug( + `Detecting diagram directive${type2 !== null ? " type:" + type2 : ""} based on the text:${text}` + ); + let match; + const result = []; + while ((match = directiveRegex.exec(text)) !== null) { + if (match.index === directiveRegex.lastIndex) { + directiveRegex.lastIndex++; + } + if (match && !type2 || type2 && match[1] && match[1].match(type2) || type2 && match[2] && match[2].match(type2)) { + const type22 = match[1] ? match[1] : match[2]; + const args = match[3] ? match[3].trim() : match[4] ? JSON.parse(match[4].trim()) : null; + result.push({ type: type22, args }); + } + } + if (result.length === 0) { + return { type: text, args: null }; + } + return result.length === 1 ? result[0] : result; + } catch (error) { + log$1.error( + `ERROR: ${error.message} - Unable to parse directive type: '${type2}' based on the text: '${text}'` + ); + return { type: void 0, args: null }; + } +}; +const removeDirectives = function(text) { + return text.replace(directiveRegex, ""); +}; +const isSubstringInArray = function(str2, arr) { + for (const [i, element] of arr.entries()) { + if (element.match(str2)) { + return i; + } + } + return -1; +}; +function interpolateToCurve(interpolate, defaultCurve) { + if (!interpolate) { + return defaultCurve; + } + const curveName = `curve${interpolate.charAt(0).toUpperCase() + interpolate.slice(1)}`; + return d3CurveTypes[curveName] ?? defaultCurve; +} +function formatUrl(linkStr, config2) { + const url = linkStr.trim(); + if (!url) { + return void 0; + } + if (config2.securityLevel !== "loose") { + return dist.sanitizeUrl(url); + } + return url; +} +const runFunc = (functionName, ...params) => { + const arrPaths = functionName.split("."); + const len = arrPaths.length - 1; + const fnName = arrPaths[len]; + let obj = window; + for (let i = 0; i < len; i++) { + obj = obj[arrPaths[i]]; + if (!obj) { + log$1.error(`Function name: ${functionName} not found in window`); + return; + } + } + obj[fnName](...params); +}; +function distance(p1, p2) { + if (!p1 || !p2) { + return 0; + } + return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); +} +function traverseEdge(points) { + let prevPoint; + let totalDistance = 0; + points.forEach((point) => { + totalDistance += distance(point, prevPoint); + prevPoint = point; + }); + const remainingDistance = totalDistance / 2; + return calculatePoint(points, remainingDistance); +} +function calcLabelPosition(points) { + if (points.length === 1) { + return points[0]; + } + return traverseEdge(points); +} +const roundNumber = (num, precision = 2) => { + const factor = Math.pow(10, precision); + return Math.round(num * factor) / factor; +}; +const calculatePoint = (points, distanceToTraverse) => { + let prevPoint = void 0; + let remainingDistance = distanceToTraverse; + for (const point of points) { + if (prevPoint) { + const vectorDistance = distance(point, prevPoint); + if (vectorDistance < remainingDistance) { + remainingDistance -= vectorDistance; + } else { + const distanceRatio = remainingDistance / vectorDistance; + if (distanceRatio <= 0) { + return prevPoint; + } + if (distanceRatio >= 1) { + return { x: point.x, y: point.y }; + } + if (distanceRatio > 0 && distanceRatio < 1) { + return { + x: roundNumber((1 - distanceRatio) * prevPoint.x + distanceRatio * point.x, 5), + y: roundNumber((1 - distanceRatio) * prevPoint.y + distanceRatio * point.y, 5) + }; + } + } + } + prevPoint = point; + } + throw new Error("Could not find a suitable point for the given distance"); +}; +const calcCardinalityPosition = (isRelationTypePresent, points, initialPosition) => { + log$1.info(`our points ${JSON.stringify(points)}`); + if (points[0] !== initialPosition) { + points = points.reverse(); + } + const distanceToCardinalityPoint = 25; + const center = calculatePoint(points, distanceToCardinalityPoint); + const d = isRelationTypePresent ? 10 : 5; + const angle = Math.atan2(points[0].y - center.y, points[0].x - center.x); + const cardinalityPosition = { x: 0, y: 0 }; + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2; + return cardinalityPosition; +}; +function calcTerminalLabelPosition(terminalMarkerSize, position, _points) { + const points = structuredClone(_points); + log$1.info("our points", points); + if (position !== "start_left" && position !== "start_right") { + points.reverse(); + } + const distanceToCardinalityPoint = 25 + terminalMarkerSize; + const center = calculatePoint(points, distanceToCardinalityPoint); + const d = 10 + terminalMarkerSize * 0.5; + const angle = Math.atan2(points[0].y - center.y, points[0].x - center.x); + const cardinalityPosition = { x: 0, y: 0 }; + if (position === "start_left") { + cardinalityPosition.x = Math.sin(angle + Math.PI) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle + Math.PI) * d + (points[0].y + center.y) / 2; + } else if (position === "end_right") { + cardinalityPosition.x = Math.sin(angle - Math.PI) * d + (points[0].x + center.x) / 2 - 5; + cardinalityPosition.y = -Math.cos(angle - Math.PI) * d + (points[0].y + center.y) / 2 - 5; + } else if (position === "end_left") { + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2 - 5; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2 - 5; + } else { + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2; + } + return cardinalityPosition; +} +function getStylesFromArray(arr) { + let style = ""; + let labelStyle = ""; + for (const element of arr) { + if (element !== void 0) { + if (element.startsWith("color:") || element.startsWith("text-align:")) { + labelStyle = labelStyle + element + ";"; + } else { + style = style + element + ";"; + } + } + } + return { style, labelStyle }; +} +let cnt = 0; +const generateId = () => { + cnt++; + return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt; +}; +function makeRandomHex(length) { + let result = ""; + const characters = "0123456789abcdef"; + const charactersLength = characters.length; + for (let i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +} +const random = (options) => { + return makeRandomHex(options.length); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + anchor: "start", + style: "#666", + width: 100, + height: 100, + textMargin: 0, + rx: 0, + ry: 0, + valign: void 0, + text: "" + }; +}; +const drawSimpleText = function(elem, textData) { + const nText = textData.text.replace(common$1.lineBreakRegex, " "); + const [, _fontSizePx] = parseFontSize(textData.fontSize); + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.style("text-anchor", textData.anchor); + textElem.style("font-family", textData.fontFamily); + textElem.style("font-size", _fontSizePx); + textElem.style("font-weight", textData.fontWeight); + textElem.attr("fill", textData.fill); + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + const span = textElem.append("tspan"); + span.attr("x", textData.x + textData.textMargin * 2); + span.attr("fill", textData.fill); + span.text(nText); + return textElem; +}; +const wrapLabel = memoize( + (label, maxWidth, config2) => { + if (!label) { + return label; + } + config2 = Object.assign( + { fontSize: 12, fontWeight: 400, fontFamily: "Arial", joinWith: "
" }, + config2 + ); + if (common$1.lineBreakRegex.test(label)) { + return label; + } + const words = label.split(" "); + const completedLines = []; + let nextLine = ""; + words.forEach((word, index) => { + const wordLength = calculateTextWidth(`${word} `, config2); + const nextLineLength = calculateTextWidth(nextLine, config2); + if (wordLength > maxWidth) { + const { hyphenatedStrings, remainingWord } = breakString(word, maxWidth, "-", config2); + completedLines.push(nextLine, ...hyphenatedStrings); + nextLine = remainingWord; + } else if (nextLineLength + wordLength >= maxWidth) { + completedLines.push(nextLine); + nextLine = word; + } else { + nextLine = [nextLine, word].filter(Boolean).join(" "); + } + const currentWord = index + 1; + const isLastWord = currentWord === words.length; + if (isLastWord) { + completedLines.push(nextLine); + } + }); + return completedLines.filter((line) => line !== "").join(config2.joinWith); + }, + (label, maxWidth, config2) => `${label}${maxWidth}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}${config2.joinWith}` +); +const breakString = memoize( + (word, maxWidth, hyphenCharacter = "-", config2) => { + config2 = Object.assign( + { fontSize: 12, fontWeight: 400, fontFamily: "Arial", margin: 0 }, + config2 + ); + const characters = [...word]; + const lines = []; + let currentLine = ""; + characters.forEach((character, index) => { + const nextLine = `${currentLine}${character}`; + const lineWidth = calculateTextWidth(nextLine, config2); + if (lineWidth >= maxWidth) { + const currentCharacter = index + 1; + const isLastLine = characters.length === currentCharacter; + const hyphenatedNextLine = `${nextLine}${hyphenCharacter}`; + lines.push(isLastLine ? nextLine : hyphenatedNextLine); + currentLine = ""; + } else { + currentLine = nextLine; + } + }); + return { hyphenatedStrings: lines, remainingWord: currentLine }; + }, + (word, maxWidth, hyphenCharacter = "-", config2) => `${word}${maxWidth}${hyphenCharacter}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}` +); +function calculateTextHeight(text, config2) { + return calculateTextDimensions(text, config2).height; +} +function calculateTextWidth(text, config2) { + return calculateTextDimensions(text, config2).width; +} +const calculateTextDimensions = memoize( + (text, config2) => { + const { fontSize = 12, fontFamily = "Arial", fontWeight = 400 } = config2; + if (!text) { + return { width: 0, height: 0 }; + } + const [, _fontSizePx] = parseFontSize(fontSize); + const fontFamilies = ["sans-serif", fontFamily]; + const lines = text.split(common$1.lineBreakRegex); + const dims = []; + const body = select("body"); + if (!body.remove) { + return { width: 0, height: 0, lineHeight: 0 }; + } + const g = body.append("svg"); + for (const fontFamily2 of fontFamilies) { + let cHeight = 0; + const dim = { width: 0, height: 0, lineHeight: 0 }; + for (const line of lines) { + const textObj = getTextObj(); + textObj.text = line || ZERO_WIDTH_SPACE; + const textElem = drawSimpleText(g, textObj).style("font-size", _fontSizePx).style("font-weight", fontWeight).style("font-family", fontFamily2); + const bBox = (textElem._groups || textElem)[0][0].getBBox(); + if (bBox.width === 0 && bBox.height === 0) { + throw new Error("svg element not in render tree"); + } + dim.width = Math.round(Math.max(dim.width, bBox.width)); + cHeight = Math.round(bBox.height); + dim.height += cHeight; + dim.lineHeight = Math.round(Math.max(dim.lineHeight, cHeight)); + } + dims.push(dim); + } + g.remove(); + const index = isNaN(dims[1].height) || isNaN(dims[1].width) || isNaN(dims[1].lineHeight) || dims[0].height > dims[1].height && dims[0].width > dims[1].width && dims[0].lineHeight > dims[1].lineHeight ? 0 : 1; + return dims[index]; + }, + (text, config2) => `${text}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}` +); +class InitIDGenerator { + constructor(deterministic = false, seed) { + this.count = 0; + this.count = seed ? seed.length : 0; + this.next = deterministic ? () => this.count++ : () => Date.now(); + } +} +let decoder; +const entityDecode = function(html) { + decoder = decoder || document.createElement("div"); + html = escape(html).replace(/%26/g, "&").replace(/%23/g, "#").replace(/%3B/g, ";"); + decoder.innerHTML = html; + return unescape(decoder.textContent); +}; +function isDetailedError(error) { + return "str" in error; +} +const insertTitle = (parent, cssClass, titleTopMargin, title) => { + var _a; + if (!title) { + return; + } + const bounds = (_a = parent.node()) == null ? void 0 : _a.getBBox(); + if (!bounds) { + return; + } + parent.append("text").text(title).attr("x", bounds.x + bounds.width / 2).attr("y", -titleTopMargin).attr("class", cssClass); +}; +const parseFontSize = (fontSize) => { + if (typeof fontSize === "number") { + return [fontSize, fontSize + "px"]; + } + const fontSizeNumber = parseInt(fontSize ?? "", 10); + if (Number.isNaN(fontSizeNumber)) { + return [void 0, void 0]; + } else if (fontSize === String(fontSizeNumber)) { + return [fontSizeNumber, fontSize + "px"]; + } else { + return [fontSizeNumber, fontSize]; + } +}; +function cleanAndMerge(defaultData, data) { + return merge$1({}, defaultData, data); +} +const utils = { + assignWithDepth: assignWithDepth$1, + wrapLabel, + calculateTextHeight, + calculateTextWidth, + calculateTextDimensions, + cleanAndMerge, + detectInit, + detectDirective, + isSubstringInArray, + interpolateToCurve, + calcLabelPosition, + calcCardinalityPosition, + calcTerminalLabelPosition, + formatUrl, + getStylesFromArray, + generateId, + random, + runFunc, + entityDecode, + insertTitle, + parseFontSize, + InitIDGenerator +}; +const encodeEntities = function(text) { + let txt = text; + txt = txt.replace(/style.*:\S*#.*;/g, function(s) { + return s.substring(0, s.length - 1); + }); + txt = txt.replace(/classDef.*:\S*#.*;/g, function(s) { + return s.substring(0, s.length - 1); + }); + txt = txt.replace(/#\w+;/g, function(s) { + const innerTxt = s.substring(1, s.length - 1); + const isInt = /^\+?\d+$/.test(innerTxt); + if (isInt) { + return "fl°°" + innerTxt + "¶ß"; + } else { + return "fl°" + innerTxt + "¶ß"; + } + }); + return txt; +}; +const decodeEntities = function(text) { + return text.replace(/fl°°/g, "&#").replace(/fl°/g, "&").replace(/¶ß/g, ";"); +}; +const version = "10.9.1"; +const defaultConfig$1 = Object.freeze(defaultConfig$2); +let siteConfig = assignWithDepth$1({}, defaultConfig$1); +let configFromInitialize; +let directives = []; +let currentConfig = assignWithDepth$1({}, defaultConfig$1); +const updateCurrentConfig = (siteCfg, _directives) => { + let cfg = assignWithDepth$1({}, siteCfg); + let sumOfDirectives = {}; + for (const d of _directives) { + sanitize(d); + sumOfDirectives = assignWithDepth$1(sumOfDirectives, d); + } + cfg = assignWithDepth$1(cfg, sumOfDirectives); + if (sumOfDirectives.theme && sumOfDirectives.theme in theme) { + const tmpConfigFromInitialize = assignWithDepth$1({}, configFromInitialize); + const themeVariables = assignWithDepth$1( + tmpConfigFromInitialize.themeVariables || {}, + sumOfDirectives.themeVariables + ); + if (cfg.theme && cfg.theme in theme) { + cfg.themeVariables = theme[cfg.theme].getThemeVariables(themeVariables); + } + } + currentConfig = cfg; + checkConfig(currentConfig); + return currentConfig; +}; +const setSiteConfig = (conf) => { + siteConfig = assignWithDepth$1({}, defaultConfig$1); + siteConfig = assignWithDepth$1(siteConfig, conf); + if (conf.theme && theme[conf.theme]) { + siteConfig.themeVariables = theme[conf.theme].getThemeVariables(conf.themeVariables); + } + updateCurrentConfig(siteConfig, directives); + return siteConfig; +}; +const saveConfigFromInitialize = (conf) => { + configFromInitialize = assignWithDepth$1({}, conf); +}; +const updateSiteConfig = (conf) => { + siteConfig = assignWithDepth$1(siteConfig, conf); + updateCurrentConfig(siteConfig, directives); + return siteConfig; +}; +const getSiteConfig = () => { + return assignWithDepth$1({}, siteConfig); +}; +const setConfig$1 = (conf) => { + checkConfig(conf); + assignWithDepth$1(currentConfig, conf); + return getConfig$1(); +}; +const getConfig$1 = () => { + return assignWithDepth$1({}, currentConfig); +}; +const sanitize = (options) => { + if (!options) { + return; + } + ["secure", ...siteConfig.secure ?? []].forEach((key) => { + if (Object.hasOwn(options, key)) { + log$1.debug(`Denied attempt to modify a secure key ${key}`, options[key]); + delete options[key]; + } + }); + Object.keys(options).forEach((key) => { + if (key.startsWith("__")) { + delete options[key]; + } + }); + Object.keys(options).forEach((key) => { + if (typeof options[key] === "string" && (options[key].includes("<") || options[key].includes(">") || options[key].includes("url(data:"))) { + delete options[key]; + } + if (typeof options[key] === "object") { + sanitize(options[key]); + } + }); +}; +const addDirective = (directive) => { + sanitizeDirective(directive); + if (directive.fontFamily && (!directive.themeVariables || !directive.themeVariables.fontFamily)) { + directive.themeVariables = { fontFamily: directive.fontFamily }; + } + directives.push(directive); + updateCurrentConfig(siteConfig, directives); +}; +const reset = (config2 = siteConfig) => { + directives = []; + updateCurrentConfig(config2, directives); +}; +const ConfigWarning = { + LAZY_LOAD_DEPRECATED: "The configuration options lazyLoadedDiagrams and loadExternalDiagramsAtStartup are deprecated. Please use registerExternalDiagrams instead." +}; +const issuedWarnings = {}; +const issueWarning = (warning) => { + if (issuedWarnings[warning]) { + return; + } + log$1.warn(ConfigWarning[warning]); + issuedWarnings[warning] = true; +}; +const checkConfig = (config2) => { + if (!config2) { + return; + } + if (config2.lazyLoadedDiagrams || config2.loadExternalDiagramsAtStartup) { + issueWarning("LAZY_LOAD_DEPRECATED"); + } +}; +const id$l = "c4"; +const detector$l = (txt) => { + return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt); +}; +const loader$m = async () => { + const { diagram: diagram2 } = await import('./c4Diagram-ae766693-jqWCbSFz.js'); + return { id: id$l, diagram: diagram2 }; +}; +const plugin$j = { + id: id$l, + detector: detector$l, + loader: loader$m +}; +const c4 = plugin$j; +const id$k = "flowchart"; +const detector$k = (txt, config2) => { + var _a, _b; + if (((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper" || ((_b = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _b.defaultRenderer) === "elk") { + return false; + } + return /^\s*graph/.test(txt); +}; +const loader$l = async () => { + const { diagram: diagram2 } = await import('./flowDiagram-b222e15a-BK68zTn6.js'); + return { id: id$k, diagram: diagram2 }; +}; +const plugin$i = { + id: id$k, + detector: detector$k, + loader: loader$l +}; +const flowchart = plugin$i; +const id$j = "flowchart-v2"; +const detector$j = (txt, config2) => { + var _a, _b, _c; + if (((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "dagre-d3" || ((_b = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _b.defaultRenderer) === "elk") { + return false; + } + if (/^\s*graph/.test(txt) && ((_c = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _c.defaultRenderer) === "dagre-wrapper") { + return true; + } + return /^\s*flowchart/.test(txt); +}; +const loader$k = async () => { + const { diagram: diagram2 } = await import('./flowDiagram-v2-13329dc7-BhMMoQnO.js'); + return { id: id$j, diagram: diagram2 }; +}; +const plugin$h = { + id: id$j, + detector: detector$j, + loader: loader$k +}; +const flowchartV2 = plugin$h; +const id$i = "er"; +const detector$i = (txt) => { + return /^\s*erDiagram/.test(txt); +}; +const loader$j = async () => { + const { diagram: diagram2 } = await import('./erDiagram-09d1c15f-CNysBsxR.js'); + return { id: id$i, diagram: diagram2 }; +}; +const plugin$g = { + id: id$i, + detector: detector$i, + loader: loader$j +}; +const er = plugin$g; +const id$h = "gitGraph"; +const detector$h = (txt) => { + return /^\s*gitGraph/.test(txt); +}; +const loader$i = async () => { + const { diagram: diagram2 } = await import('./gitGraphDiagram-942e62fe-byuJSX1R.js'); + return { id: id$h, diagram: diagram2 }; +}; +const plugin$f = { + id: id$h, + detector: detector$h, + loader: loader$i +}; +const git = plugin$f; +const id$g = "gantt"; +const detector$g = (txt) => { + return /^\s*gantt/.test(txt); +}; +const loader$h = async () => { + const { diagram: diagram2 } = await import('./ganttDiagram-b62c793e-Bvxu6L6W.js'); + return { id: id$g, diagram: diagram2 }; +}; +const plugin$e = { + id: id$g, + detector: detector$g, + loader: loader$h +}; +const gantt = plugin$e; +const id$f = "info"; +const detector$f = (txt) => { + return /^\s*info/.test(txt); +}; +const loader$g = async () => { + const { diagram: diagram2 } = await import('./infoDiagram-94cd232f-UXAz4oPL.js'); + return { id: id$f, diagram: diagram2 }; +}; +const info = { + id: id$f, + detector: detector$f, + loader: loader$g +}; +const id$e = "pie"; +const detector$e = (txt) => { + return /^\s*pie/.test(txt); +}; +const loader$f = async () => { + const { diagram: diagram2 } = await import('./pieDiagram-bb1d19e5-CDMXSh7k.js'); + return { id: id$e, diagram: diagram2 }; +}; +const pie = { + id: id$e, + detector: detector$e, + loader: loader$f +}; +const id$d = "quadrantChart"; +const detector$d = (txt) => { + return /^\s*quadrantChart/.test(txt); +}; +const loader$e = async () => { + const { diagram: diagram2 } = await import('./quadrantDiagram-c759a472-BdBXdWkW.js'); + return { id: id$d, diagram: diagram2 }; +}; +const plugin$d = { + id: id$d, + detector: detector$d, + loader: loader$e +}; +const quadrantChart = plugin$d; +const id$c = "xychart"; +const detector$c = (txt) => { + return /^\s*xychart-beta/.test(txt); +}; +const loader$d = async () => { + const { diagram: diagram2 } = await import('./xychartDiagram-f11f50a6-fh9SQxEm.js'); + return { id: id$c, diagram: diagram2 }; +}; +const plugin$c = { + id: id$c, + detector: detector$c, + loader: loader$d +}; +const xychart = plugin$c; +const id$b = "requirement"; +const detector$b = (txt) => { + return /^\s*requirement(Diagram)?/.test(txt); +}; +const loader$c = async () => { + const { diagram: diagram2 } = await import('./requirementDiagram-87253d64-kJ-VaOjM.js'); + return { id: id$b, diagram: diagram2 }; +}; +const plugin$b = { + id: id$b, + detector: detector$b, + loader: loader$c +}; +const requirement = plugin$b; +const id$a = "sequence"; +const detector$a = (txt) => { + return /^\s*sequenceDiagram/.test(txt); +}; +const loader$b = async () => { + const { diagram: diagram2 } = await import('./sequenceDiagram-6894f283-C15d_y26.js'); + return { id: id$a, diagram: diagram2 }; +}; +const plugin$a = { + id: id$a, + detector: detector$a, + loader: loader$b +}; +const sequence = plugin$a; +const id$9 = "class"; +const detector$9 = (txt, config2) => { + var _a; + if (((_a = config2 == null ? void 0 : config2.class) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return false; + } + return /^\s*classDiagram/.test(txt); +}; +const loader$a = async () => { + const { diagram: diagram2 } = await import('./classDiagram-fb54d2a0--Qxwqbp1.js'); + return { id: id$9, diagram: diagram2 }; +}; +const plugin$9 = { + id: id$9, + detector: detector$9, + loader: loader$a +}; +const classDiagram = plugin$9; +const id$8 = "classDiagram"; +const detector$8 = (txt, config2) => { + var _a; + if (/^\s*classDiagram/.test(txt) && ((_a = config2 == null ? void 0 : config2.class) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return true; + } + return /^\s*classDiagram-v2/.test(txt); +}; +const loader$9 = async () => { + const { diagram: diagram2 } = await import('./classDiagram-v2-a2b738ad-ZVt6Q8y0.js'); + return { id: id$8, diagram: diagram2 }; +}; +const plugin$8 = { + id: id$8, + detector: detector$8, + loader: loader$9 +}; +const classDiagramV2 = plugin$8; +const id$7 = "state"; +const detector$7 = (txt, config2) => { + var _a; + if (((_a = config2 == null ? void 0 : config2.state) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return false; + } + return /^\s*stateDiagram/.test(txt); +}; +const loader$8 = async () => { + const { diagram: diagram2 } = await import('./stateDiagram-5dee940d-D8Ibqruy.js'); + return { id: id$7, diagram: diagram2 }; +}; +const plugin$7 = { + id: id$7, + detector: detector$7, + loader: loader$8 +}; +const state = plugin$7; +const id$6 = "stateDiagram"; +const detector$6 = (txt, config2) => { + var _a; + if (/^\s*stateDiagram-v2/.test(txt)) { + return true; + } + if (/^\s*stateDiagram/.test(txt) && ((_a = config2 == null ? void 0 : config2.state) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return true; + } + return false; +}; +const loader$7 = async () => { + const { diagram: diagram2 } = await import('./stateDiagram-v2-1992cada-C3cfgmsi.js'); + return { id: id$6, diagram: diagram2 }; +}; +const plugin$6 = { + id: id$6, + detector: detector$6, + loader: loader$7 +}; +const stateV2 = plugin$6; +const id$5 = "journey"; +const detector$5 = (txt) => { + return /^\s*journey/.test(txt); +}; +const loader$6 = async () => { + const { diagram: diagram2 } = await import('./journeyDiagram-6625b456-DuhFx8Fo.js'); + return { id: id$5, diagram: diagram2 }; +}; +const plugin$5 = { + id: id$5, + detector: detector$5, + loader: loader$6 +}; +const journey = plugin$5; +const d3Attrs = function(d3Elem, attrs) { + for (let attr of attrs) { + d3Elem.attr(attr[0], attr[1]); + } +}; +const calculateSvgSizeAttrs = function(height, width, useMaxWidth) { + let attrs = /* @__PURE__ */ new Map(); + if (useMaxWidth) { + attrs.set("width", "100%"); + attrs.set("style", `max-width: ${width}px;`); + } else { + attrs.set("height", height); + attrs.set("width", width); + } + return attrs; +}; +const configureSvgSize = function(svgElem, height, width, useMaxWidth) { + const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth); + d3Attrs(svgElem, attrs); +}; +const setupGraphViewbox$1 = function(graph, svgElem, padding, useMaxWidth) { + const svgBounds = svgElem.node().getBBox(); + const sWidth = svgBounds.width; + const sHeight = svgBounds.height; + log$1.info(`SVG bounds: ${sWidth}x${sHeight}`, svgBounds); + let width = 0; + let height = 0; + log$1.info(`Graph bounds: ${width}x${height}`, graph); + width = sWidth + padding * 2; + height = sHeight + padding * 2; + log$1.info(`Calculated bounds: ${width}x${height}`); + configureSvgSize(svgElem, height, width, useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${svgBounds.width + 2 * padding} ${svgBounds.height + 2 * padding}`; + svgElem.attr("viewBox", vBox); +}; +const themes = {}; +const getStyles = (type2, userStyles, options) => { + let diagramStyles = ""; + if (type2 in themes && themes[type2]) { + diagramStyles = themes[type2](options); + } else { + log$1.warn(`No theme found for ${type2}`); + } + return ` & { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + fill: ${options.textColor} + } + + /* Classes common for multiple diagrams */ + + & .error-icon { + fill: ${options.errorBkgColor}; + } + & .error-text { + fill: ${options.errorTextColor}; + stroke: ${options.errorTextColor}; + } + + & .edge-thickness-normal { + stroke-width: 2px; + } + & .edge-thickness-thick { + stroke-width: 3.5px + } + & .edge-pattern-solid { + stroke-dasharray: 0; + } + + & .edge-pattern-dashed{ + stroke-dasharray: 3; + } + .edge-pattern-dotted { + stroke-dasharray: 2; + } + + & .marker { + fill: ${options.lineColor}; + stroke: ${options.lineColor}; + } + & .marker.cross { + stroke: ${options.lineColor}; + } + + & svg { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + } + + ${diagramStyles} + + ${userStyles} +`; +}; +const addStylesForDiagram = (type2, diagramTheme) => { + if (diagramTheme !== void 0) { + themes[type2] = diagramTheme; + } +}; +const getStyles$1 = getStyles; +let accTitle = ""; +let diagramTitle = ""; +let accDescription = ""; +const sanitizeText$1 = (txt) => sanitizeText$2(txt, getConfig$1()); +const clear = () => { + accTitle = ""; + accDescription = ""; + diagramTitle = ""; +}; +const setAccTitle = (txt) => { + accTitle = sanitizeText$1(txt).replace(/^\s+/g, ""); +}; +const getAccTitle = () => accTitle; +const setAccDescription = (txt) => { + accDescription = sanitizeText$1(txt).replace(/\n\s+/g, "\n"); +}; +const getAccDescription = () => accDescription; +const setDiagramTitle = (txt) => { + diagramTitle = sanitizeText$1(txt); +}; +const getDiagramTitle = () => diagramTitle; +const commonDb = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + clear, + getAccDescription, + getAccTitle, + getDiagramTitle, + setAccDescription, + setAccTitle, + setDiagramTitle +}, Symbol.toStringTag, { value: "Module" })); +const log = log$1; +const setLogLevel = setLogLevel$1; +const getConfig = getConfig$1; +const setConfig = setConfig$1; +const defaultConfig = defaultConfig$1; +const sanitizeText = (text) => sanitizeText$2(text, getConfig()); +const setupGraphViewbox = setupGraphViewbox$1; +const getCommonDb = () => { + return commonDb; +}; +const diagrams = {}; +const registerDiagram = (id2, diagram2, detector2) => { + var _a; + if (diagrams[id2]) { + throw new Error(`Diagram ${id2} already registered.`); + } + diagrams[id2] = diagram2; + if (detector2) { + addDetector(id2, detector2); + } + addStylesForDiagram(id2, diagram2.styles); + (_a = diagram2.injectUtils) == null ? void 0 : _a.call( + diagram2, + log, + setLogLevel, + getConfig, + sanitizeText, + setupGraphViewbox, + getCommonDb(), + () => { + } + ); +}; +const getDiagram = (name) => { + if (name in diagrams) { + return diagrams[name]; + } + throw new DiagramNotFoundError(name); +}; +class DiagramNotFoundError extends Error { + constructor(name) { + super(`Diagram ${name} not found.`); + } +} +const selectSvgElement = (id2) => { + var _a; + const { securityLevel } = getConfig(); + let root = select("body"); + if (securityLevel === "sandbox") { + const sandboxElement = select(`#i${id2}`); + const doc = ((_a = sandboxElement.node()) == null ? void 0 : _a.contentDocument) ?? document; + root = select(doc.body); + } + const svg = root.select(`#${id2}`); + return svg; +}; +const draw = (_text, id2, version2) => { + log$1.debug("rendering svg for syntax error\n"); + const svg = selectSvgElement(id2); + const g = svg.append("g"); + svg.attr("viewBox", "0 0 2412 512"); + configureSvgSize(svg, 100, 512, true); + g.append("path").attr("class", "error-icon").attr( + "d", + "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z" + ); + g.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"); + g.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${version2}`); +}; +const renderer = { draw }; +const errorRenderer = renderer; +const diagram = { + db: {}, + renderer, + parser: { + parser: { yy: {} }, + parse: () => { + return; + } + } +}; +const errorDiagram = diagram; +const id$4 = "flowchart-elk"; +const detector$4 = (txt, config2) => { + var _a; + if ( + // If diagram explicitly states flowchart-elk + /^\s*flowchart-elk/.test(txt) || // If a flowchart/graph diagram has their default renderer set to elk + /^\s*flowchart|graph/.test(txt) && ((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "elk" + ) { + return true; + } + return false; +}; +const loader$5 = async () => { + const { diagram: diagram2 } = await import('./flowchart-elk-definition-ae0efee6-CWJ9Snv4.js'); + return { id: id$4, diagram: diagram2 }; +}; +const plugin$4 = { + id: id$4, + detector: detector$4, + loader: loader$5 +}; +const flowchartElk = plugin$4; +const id$3 = "timeline"; +const detector$3 = (txt) => { + return /^\s*timeline/.test(txt); +}; +const loader$4 = async () => { + const { diagram: diagram2 } = await import('./timeline-definition-bf702344-DseYwjcq.js'); + return { id: id$3, diagram: diagram2 }; +}; +const plugin$3 = { + id: id$3, + detector: detector$3, + loader: loader$4 +}; +const timeline = plugin$3; +const id$2 = "mindmap"; +const detector$2 = (txt) => { + return /^\s*mindmap/.test(txt); +}; +const loader$3 = async () => { + const { diagram: diagram2 } = await import('./mindmap-definition-307c710a-aXOOrvfG.js'); + return { id: id$2, diagram: diagram2 }; +}; +const plugin$2 = { + id: id$2, + detector: detector$2, + loader: loader$3 +}; +const mindmap = plugin$2; +const id$1 = "sankey"; +const detector$1 = (txt) => { + return /^\s*sankey-beta/.test(txt); +}; +const loader$2 = async () => { + const { diagram: diagram2 } = await import('./sankeyDiagram-707fac0f-RRYrH95D.js'); + return { id: id$1, diagram: diagram2 }; +}; +const plugin$1 = { + id: id$1, + detector: detector$1, + loader: loader$2 +}; +const sankey = plugin$1; +const id = "block"; +const detector = (txt) => { + return /^\s*block-beta/.test(txt); +}; +const loader$1 = async () => { + const { diagram: diagram2 } = await import('./blockDiagram-9f4a6865-DpcS6J66.js'); + return { id, diagram: diagram2 }; +}; +const plugin = { + id, + detector, + loader: loader$1 +}; +const block = plugin; +let hasLoadedDiagrams = false; +const addDiagrams = () => { + if (hasLoadedDiagrams) { + return; + } + hasLoadedDiagrams = true; + registerDiagram("error", errorDiagram, (text) => { + return text.toLowerCase().trim() === "error"; + }); + registerDiagram( + "---", + // --- diagram type may appear if YAML front-matter is not parsed correctly + { + db: { + clear: () => { + } + }, + styles: {}, + // should never be used + renderer: { + draw: () => { + } + }, + parser: { + parser: { yy: {} }, + parse: () => { + throw new Error( + "Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks" + ); + } + }, + init: () => null + // no op + }, + (text) => { + return text.toLowerCase().trimStart().startsWith("---"); + } + ); + registerLazyLoadedDiagrams( + c4, + classDiagramV2, + classDiagram, + er, + gantt, + info, + pie, + requirement, + sequence, + flowchartElk, + flowchartV2, + flowchart, + mindmap, + timeline, + git, + stateV2, + state, + journey, + quadrantChart, + sankey, + xychart, + block + ); +}; +class Diagram { + constructor(text, metadata = {}) { + this.text = text; + this.metadata = metadata; + this.type = "graph"; + this.text = encodeEntities(text); + this.text += "\n"; + const cnf = getConfig$1(); + try { + this.type = detectType(text, cnf); + } catch (e) { + this.type = "error"; + this.detectError = e; + } + const diagram2 = getDiagram(this.type); + log$1.debug("Type " + this.type); + this.db = diagram2.db; + this.renderer = diagram2.renderer; + this.parser = diagram2.parser; + this.parser.parser.yy = this.db; + this.init = diagram2.init; + this.parse(); + } + parse() { + var _a, _b, _c, _d, _e; + if (this.detectError) { + throw this.detectError; + } + (_b = (_a = this.db).clear) == null ? void 0 : _b.call(_a); + const config2 = getConfig$1(); + (_c = this.init) == null ? void 0 : _c.call(this, config2); + if (this.metadata.title) { + (_e = (_d = this.db).setDiagramTitle) == null ? void 0 : _e.call(_d, this.metadata.title); + } + this.parser.parse(this.text); + } + async render(id2, version2) { + await this.renderer.draw(this.text, id2, version2, this); + } + getParser() { + return this.parser; + } + getType() { + return this.type; + } +} +const getDiagramFromText$1 = async (text, metadata = {}) => { + const type2 = detectType(text, getConfig$1()); + try { + getDiagram(type2); + } catch (error) { + const loader2 = getDiagramLoader(type2); + if (!loader2) { + throw new UnknownDiagramError(`Diagram ${type2} not found.`); + } + const { id: id2, diagram: diagram2 } = await loader2(); + registerDiagram(id2, diagram2); + } + return new Diagram(text, metadata); +}; +let interactionFunctions = []; +const attachFunctions = () => { + interactionFunctions.forEach((f) => { + f(); + }); + interactionFunctions = []; +}; +const SVG_ROLE = "graphics-document document"; +function setA11yDiagramInfo(svg, diagramType) { + svg.attr("role", SVG_ROLE); + if (diagramType !== "") { + svg.attr("aria-roledescription", diagramType); + } +} +function addSVGa11yTitleDescription(svg, a11yTitle, a11yDesc, baseId) { + if (svg.insert === void 0) { + return; + } + if (a11yDesc) { + const descId = `chart-desc-${baseId}`; + svg.attr("aria-describedby", descId); + svg.insert("desc", ":first-child").attr("id", descId).text(a11yDesc); + } + if (a11yTitle) { + const titleId = `chart-title-${baseId}`; + svg.attr("aria-labelledby", titleId); + svg.insert("title", ":first-child").attr("id", titleId).text(a11yTitle); + } +} +const cleanupComments = (text) => { + return text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(); +}; +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ +function isNothing(subject) { + return typeof subject === "undefined" || subject === null; +} +function isObject(subject) { + return typeof subject === "object" && subject !== null; +} +function toArray(sequence2) { + if (Array.isArray(sequence2)) + return sequence2; + else if (isNothing(sequence2)) + return []; + return [sequence2]; +} +function extend(target, source) { + var index, length, key, sourceKeys; + if (source) { + sourceKeys = Object.keys(source); + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + return target; +} +function repeat(string, count) { + var result = "", cycle; + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + return result; +} +function isNegativeZero(number) { + return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; +} +var isNothing_1 = isNothing; +var isObject_1 = isObject; +var toArray_1 = toArray; +var repeat_1 = repeat; +var isNegativeZero_1 = isNegativeZero; +var extend_1 = extend; +var common = { + isNothing: isNothing_1, + isObject: isObject_1, + toArray: toArray_1, + repeat: repeat_1, + isNegativeZero: isNegativeZero_1, + extend: extend_1 +}; +function formatError(exception2, compact) { + var where = "", message = exception2.reason || "(unknown reason)"; + if (!exception2.mark) + return message; + if (exception2.mark.name) { + where += 'in "' + exception2.mark.name + '" '; + } + where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; + if (!compact && exception2.mark.snippet) { + where += "\n\n" + exception2.mark.snippet; + } + return message + " " + where; +} +function YAMLException$1(reason, mark) { + Error.call(this); + this.name = "YAMLException"; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error().stack || ""; + } +} +YAMLException$1.prototype = Object.create(Error.prototype); +YAMLException$1.prototype.constructor = YAMLException$1; +YAMLException$1.prototype.toString = function toString(compact) { + return this.name + ": " + formatError(this, compact); +}; +var exception = YAMLException$1; +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ""; + var tail = ""; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + if (position - lineStart > maxHalfLength) { + head = " ... "; + lineStart = position - maxHalfLength + head.length; + } + if (lineEnd - position > maxHalfLength) { + tail = " ..."; + lineEnd = position + maxHalfLength - tail.length; + } + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail, + pos: position - lineStart + head.length + // relative position + }; +} +function padStart(string, max) { + return common.repeat(" ", max - string.length) + string; +} +function makeSnippet(mark, options) { + options = Object.create(options || null); + if (!mark.buffer) + return null; + if (!options.maxLength) + options.maxLength = 79; + if (typeof options.indent !== "number") + options.indent = 1; + if (typeof options.linesBefore !== "number") + options.linesBefore = 3; + if (typeof options.linesAfter !== "number") + options.linesAfter = 2; + var re = /\r?\n|\r|\0/g; + var lineStarts = [0]; + var lineEnds = []; + var match; + var foundLineNo = -1; + while (match = re.exec(mark.buffer)) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + if (foundLineNo < 0) + foundLineNo = lineStarts.length - 1; + var result = "", i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) + break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result; + } + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n"; + result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n"; + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) + break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n"; + } + return result.replace(/\n$/, ""); +} +var snippet = makeSnippet; +var TYPE_CONSTRUCTOR_OPTIONS = [ + "kind", + "multi", + "resolve", + "construct", + "instanceOf", + "predicate", + "represent", + "representName", + "defaultStyle", + "styleAliases" +]; +var YAML_NODE_KINDS = [ + "scalar", + "sequence", + "mapping" +]; +function compileStyleAliases(map2) { + var result = {}; + if (map2 !== null) { + Object.keys(map2).forEach(function(style) { + map2[style].forEach(function(alias) { + result[String(alias)] = style; + }); + }); + } + return result; +} +function Type$1(tag, options) { + options = options || {}; + Object.keys(options).forEach(function(name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + this.options = options; + this.tag = tag; + this.kind = options["kind"] || null; + this.resolve = options["resolve"] || function() { + return true; + }; + this.construct = options["construct"] || function(data) { + return data; + }; + this.instanceOf = options["instanceOf"] || null; + this.predicate = options["predicate"] || null; + this.represent = options["represent"] || null; + this.representName = options["representName"] || null; + this.defaultStyle = options["defaultStyle"] || null; + this.multi = options["multi"] || false; + this.styleAliases = compileStyleAliases(options["styleAliases"] || null); + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} +var type = Type$1; +function compileList(schema2, name) { + var result = []; + schema2[name].forEach(function(currentType) { + var newIndex = result.length; + result.forEach(function(previousType, previousIndex) { + if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { + newIndex = previousIndex; + } + }); + result[newIndex] = currentType; + }); + return result; +} +function compileMap() { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + function collectType(type2) { + if (type2.multi) { + result.multi[type2.kind].push(type2); + result.multi["fallback"].push(type2); + } else { + result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; + } + } + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} +function Schema$1(definition) { + return this.extend(definition); +} +Schema$1.prototype.extend = function extend2(definition) { + var implicit = []; + var explicit = []; + if (definition instanceof type) { + explicit.push(definition); + } else if (Array.isArray(definition)) { + explicit = explicit.concat(definition); + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + if (definition.implicit) + implicit = implicit.concat(definition.implicit); + if (definition.explicit) + explicit = explicit.concat(definition.explicit); + } else { + throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); + } + implicit.forEach(function(type$1) { + if (!(type$1 instanceof type)) { + throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); + } + if (type$1.loadKind && type$1.loadKind !== "scalar") { + throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); + } + if (type$1.multi) { + throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); + } + }); + explicit.forEach(function(type$1) { + if (!(type$1 instanceof type)) { + throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); + } + }); + var result = Object.create(Schema$1.prototype); + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + result.compiledImplicit = compileList(result, "implicit"); + result.compiledExplicit = compileList(result, "explicit"); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + return result; +}; +var schema = Schema$1; +var str = new type("tag:yaml.org,2002:str", { + kind: "scalar", + construct: function(data) { + return data !== null ? data : ""; + } +}); +var seq = new type("tag:yaml.org,2002:seq", { + kind: "sequence", + construct: function(data) { + return data !== null ? data : []; + } +}); +var map = new type("tag:yaml.org,2002:map", { + kind: "mapping", + construct: function(data) { + return data !== null ? data : {}; + } +}); +var failsafe = new schema({ + explicit: [ + str, + seq, + map + ] +}); +function resolveYamlNull(data) { + if (data === null) + return true; + var max = data.length; + return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); +} +function constructYamlNull() { + return null; +} +function isNull(object) { + return object === null; +} +var _null = new type("tag:yaml.org,2002:null", { + kind: "scalar", + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function() { + return "~"; + }, + lowercase: function() { + return "null"; + }, + uppercase: function() { + return "NULL"; + }, + camelcase: function() { + return "Null"; + }, + empty: function() { + return ""; + } + }, + defaultStyle: "lowercase" +}); +function resolveYamlBoolean(data) { + if (data === null) + return false; + var max = data.length; + return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); +} +function constructYamlBoolean(data) { + return data === "true" || data === "True" || data === "TRUE"; +} +function isBoolean(object) { + return Object.prototype.toString.call(object) === "[object Boolean]"; +} +var bool = new type("tag:yaml.org,2002:bool", { + kind: "scalar", + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function(object) { + return object ? "true" : "false"; + }, + uppercase: function(object) { + return object ? "TRUE" : "FALSE"; + }, + camelcase: function(object) { + return object ? "True" : "False"; + } + }, + defaultStyle: "lowercase" +}); +function isHexCode(c) { + return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; +} +function isOctCode(c) { + return 48 <= c && c <= 55; +} +function isDecCode(c) { + return 48 <= c && c <= 57; +} +function resolveYamlInteger(data) { + if (data === null) + return false; + var max = data.length, index = 0, hasDigits = false, ch; + if (!max) + return false; + ch = data[index]; + if (ch === "-" || ch === "+") { + ch = data[++index]; + } + if (ch === "0") { + if (index + 1 === max) + return true; + ch = data[++index]; + if (ch === "b") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (ch !== "0" && ch !== "1") + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + if (ch === "x") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isHexCode(data.charCodeAt(index))) + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + if (ch === "o") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isOctCode(data.charCodeAt(index))) + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + } + if (ch === "_") + return false; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + if (!hasDigits || ch === "_") + return false; + return true; +} +function constructYamlInteger(data) { + var value = data, sign = 1, ch; + if (value.indexOf("_") !== -1) { + value = value.replace(/_/g, ""); + } + ch = value[0]; + if (ch === "-" || ch === "+") { + if (ch === "-") + sign = -1; + value = value.slice(1); + ch = value[0]; + } + if (value === "0") + return 0; + if (ch === "0") { + if (value[1] === "b") + return sign * parseInt(value.slice(2), 2); + if (value[1] === "x") + return sign * parseInt(value.slice(2), 16); + if (value[1] === "o") + return sign * parseInt(value.slice(2), 8); + } + return sign * parseInt(value, 10); +} +function isInteger(object) { + return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); +} +var int = new type("tag:yaml.org,2002:int", { + kind: "scalar", + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function(obj) { + return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); + }, + octal: function(obj) { + return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); + }, + decimal: function(obj) { + return obj.toString(10); + }, + /* eslint-disable max-len */ + hexadecimal: function(obj) { + return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); + } + }, + defaultStyle: "decimal", + styleAliases: { + binary: [2, "bin"], + octal: [8, "oct"], + decimal: [10, "dec"], + hexadecimal: [16, "hex"] + } +}); +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" +); +function resolveYamlFloat(data) { + if (data === null) + return false; + if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === "_") { + return false; + } + return true; +} +function constructYamlFloat(data) { + var value, sign; + value = data.replace(/_/g, "").toLowerCase(); + sign = value[0] === "-" ? -1 : 1; + if ("+-".indexOf(value[0]) >= 0) { + value = value.slice(1); + } + if (value === ".inf") { + return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + } else if (value === ".nan") { + return NaN; + } + return sign * parseFloat(value, 10); +} +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; +function representYamlFloat(object, style) { + var res; + if (isNaN(object)) { + switch (style) { + case "lowercase": + return ".nan"; + case "uppercase": + return ".NAN"; + case "camelcase": + return ".NaN"; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case "lowercase": + return ".inf"; + case "uppercase": + return ".INF"; + case "camelcase": + return ".Inf"; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case "lowercase": + return "-.inf"; + case "uppercase": + return "-.INF"; + case "camelcase": + return "-.Inf"; + } + } else if (common.isNegativeZero(object)) { + return "-0.0"; + } + res = object.toString(10); + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; +} +function isFloat(object) { + return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); +} +var float = new type("tag:yaml.org,2002:float", { + kind: "scalar", + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: "lowercase" +}); +var json = failsafe.extend({ + implicit: [ + _null, + bool, + int, + float + ] +}); +var core = json; +var YAML_DATE_REGEXP = new RegExp( + "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$" +); +var YAML_TIMESTAMP_REGEXP = new RegExp( + "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$" +); +function resolveYamlTimestamp(data) { + if (data === null) + return false; + if (YAML_DATE_REGEXP.exec(data) !== null) + return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) + return true; + return false; +} +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; + match = YAML_DATE_REGEXP.exec(data); + if (match === null) + match = YAML_TIMESTAMP_REGEXP.exec(data); + if (match === null) + throw new Error("Date resolve error"); + year = +match[1]; + month = +match[2] - 1; + day = +match[3]; + if (!match[4]) { + return new Date(Date.UTC(year, month, day)); + } + hour = +match[4]; + minute = +match[5]; + second = +match[6]; + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { + fraction += "0"; + } + fraction = +fraction; + } + if (match[9]) { + tz_hour = +match[10]; + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 6e4; + if (match[9] === "-") + delta = -delta; + } + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + if (delta) + date.setTime(date.getTime() - delta); + return date; +} +function representYamlTimestamp(object) { + return object.toISOString(); +} +var timestamp = new type("tag:yaml.org,2002:timestamp", { + kind: "scalar", + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); +function resolveYamlMerge(data) { + return data === "<<" || data === null; +} +var merge = new type("tag:yaml.org,2002:merge", { + kind: "scalar", + resolve: resolveYamlMerge +}); +var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; +function resolveYamlBinary(data) { + if (data === null) + return false; + var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP; + for (idx = 0; idx < max; idx++) { + code = map2.indexOf(data.charAt(idx)); + if (code > 64) + continue; + if (code < 0) + return false; + bitlen += 6; + } + return bitlen % 8 === 0; +} +function constructYamlBinary(data) { + var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = []; + for (idx = 0; idx < max; idx++) { + if (idx % 4 === 0 && idx) { + result.push(bits >> 16 & 255); + result.push(bits >> 8 & 255); + result.push(bits & 255); + } + bits = bits << 6 | map2.indexOf(input.charAt(idx)); + } + tailbits = max % 4 * 6; + if (tailbits === 0) { + result.push(bits >> 16 & 255); + result.push(bits >> 8 & 255); + result.push(bits & 255); + } else if (tailbits === 18) { + result.push(bits >> 10 & 255); + result.push(bits >> 2 & 255); + } else if (tailbits === 12) { + result.push(bits >> 4 & 255); + } + return new Uint8Array(result); +} +function representYamlBinary(object) { + var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP; + for (idx = 0; idx < max; idx++) { + if (idx % 3 === 0 && idx) { + result += map2[bits >> 18 & 63]; + result += map2[bits >> 12 & 63]; + result += map2[bits >> 6 & 63]; + result += map2[bits & 63]; + } + bits = (bits << 8) + object[idx]; + } + tail = max % 3; + if (tail === 0) { + result += map2[bits >> 18 & 63]; + result += map2[bits >> 12 & 63]; + result += map2[bits >> 6 & 63]; + result += map2[bits & 63]; + } else if (tail === 2) { + result += map2[bits >> 10 & 63]; + result += map2[bits >> 4 & 63]; + result += map2[bits << 2 & 63]; + result += map2[64]; + } else if (tail === 1) { + result += map2[bits >> 2 & 63]; + result += map2[bits << 4 & 63]; + result += map2[64]; + result += map2[64]; + } + return result; +} +function isBinary(obj) { + return Object.prototype.toString.call(obj) === "[object Uint8Array]"; +} +var binary = new type("tag:yaml.org,2002:binary", { + kind: "scalar", + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); +var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; +var _toString$2 = Object.prototype.toString; +function resolveYamlOmap(data) { + if (data === null) + return true; + var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data; + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + if (_toString$2.call(pair) !== "[object Object]") + return false; + for (pairKey in pair) { + if (_hasOwnProperty$3.call(pair, pairKey)) { + if (!pairHasKey) + pairHasKey = true; + else + return false; + } + } + if (!pairHasKey) + return false; + if (objectKeys.indexOf(pairKey) === -1) + objectKeys.push(pairKey); + else + return false; + } + return true; +} +function constructYamlOmap(data) { + return data !== null ? data : []; +} +var omap = new type("tag:yaml.org,2002:omap", { + kind: "sequence", + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); +var _toString$1 = Object.prototype.toString; +function resolveYamlPairs(data) { + if (data === null) + return true; + var index, length, pair, keys, result, object = data; + result = new Array(object.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + if (_toString$1.call(pair) !== "[object Object]") + return false; + keys = Object.keys(pair); + if (keys.length !== 1) + return false; + result[index] = [keys[0], pair[keys[0]]]; + } + return true; +} +function constructYamlPairs(data) { + if (data === null) + return []; + var index, length, pair, keys, result, object = data; + result = new Array(object.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + keys = Object.keys(pair); + result[index] = [keys[0], pair[keys[0]]]; + } + return result; +} +var pairs = new type("tag:yaml.org,2002:pairs", { + kind: "sequence", + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); +var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; +function resolveYamlSet(data) { + if (data === null) + return true; + var key, object = data; + for (key in object) { + if (_hasOwnProperty$2.call(object, key)) { + if (object[key] !== null) + return false; + } + } + return true; +} +function constructYamlSet(data) { + return data !== null ? data : {}; +} +var set = new type("tag:yaml.org,2002:set", { + kind: "mapping", + resolve: resolveYamlSet, + construct: constructYamlSet +}); +var _default = core.extend({ + implicit: [ + timestamp, + merge + ], + explicit: [ + binary, + omap, + pairs, + set + ] +}); +var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; +function _class(obj) { + return Object.prototype.toString.call(obj); +} +function is_EOL(c) { + return c === 10 || c === 13; +} +function is_WHITE_SPACE(c) { + return c === 9 || c === 32; +} +function is_WS_OR_EOL(c) { + return c === 9 || c === 32 || c === 10 || c === 13; +} +function is_FLOW_INDICATOR(c) { + return c === 44 || c === 91 || c === 93 || c === 123 || c === 125; +} +function fromHexCode(c) { + var lc; + if (48 <= c && c <= 57) { + return c - 48; + } + lc = c | 32; + if (97 <= lc && lc <= 102) { + return lc - 97 + 10; + } + return -1; +} +function escapedHexLen(c) { + if (c === 120) { + return 2; + } + if (c === 117) { + return 4; + } + if (c === 85) { + return 8; + } + return 0; +} +function fromDecimalCode(c) { + if (48 <= c && c <= 57) { + return c - 48; + } + return -1; +} +function simpleEscapeSequence(c) { + return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "…" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : ""; +} +function charFromCodepoint(c) { + if (c <= 65535) { + return String.fromCharCode(c); + } + return String.fromCharCode( + (c - 65536 >> 10) + 55296, + (c - 65536 & 1023) + 56320 + ); +} +var simpleEscapeCheck = new Array(256); +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} +function State$1(input, options) { + this.input = input; + this.filename = options["filename"] || null; + this.schema = options["schema"] || _default; + this.onWarning = options["onWarning"] || null; + this.legacy = options["legacy"] || false; + this.json = options["json"] || false; + this.listener = options["listener"] || null; + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + this.firstTabInLine = -1; + this.documents = []; +} +function generateError(state2, message) { + var mark = { + name: state2.filename, + buffer: state2.input.slice(0, -1), + // omit trailing \0 + position: state2.position, + line: state2.line, + column: state2.position - state2.lineStart + }; + mark.snippet = snippet(mark); + return new exception(message, mark); +} +function throwError(state2, message) { + throw generateError(state2, message); +} +function throwWarning(state2, message) { + if (state2.onWarning) { + state2.onWarning.call(null, generateError(state2, message)); + } +} +var directiveHandlers = { + YAML: function handleYamlDirective(state2, name, args) { + var match, major, minor; + if (state2.version !== null) { + throwError(state2, "duplication of %YAML directive"); + } + if (args.length !== 1) { + throwError(state2, "YAML directive accepts exactly one argument"); + } + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + if (match === null) { + throwError(state2, "ill-formed argument of the YAML directive"); + } + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + if (major !== 1) { + throwError(state2, "unacceptable YAML version of the document"); + } + state2.version = args[0]; + state2.checkLineBreaks = minor < 2; + if (minor !== 1 && minor !== 2) { + throwWarning(state2, "unsupported YAML version of the document"); + } + }, + TAG: function handleTagDirective(state2, name, args) { + var handle, prefix; + if (args.length !== 2) { + throwError(state2, "TAG directive accepts exactly two arguments"); + } + handle = args[0]; + prefix = args[1]; + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state2, "ill-formed tag handle (first argument) of the TAG directive"); + } + if (_hasOwnProperty$1.call(state2.tagMap, handle)) { + throwError(state2, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state2, "ill-formed tag prefix (second argument) of the TAG directive"); + } + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state2, "tag prefix is malformed: " + prefix); + } + state2.tagMap[handle] = prefix; + } +}; +function captureSegment(state2, start, end, checkJson) { + var _position, _length, _character, _result; + if (start < end) { + _result = state2.input.slice(start, end); + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 9 || 32 <= _character && _character <= 1114111)) { + throwError(state2, "expected valid JSON character"); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state2, "the stream contains non-printable characters"); + } + state2.result += _result; + } +} +function mergeMappings(state2, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + if (!common.isObject(source)) { + throwError(state2, "cannot merge mappings; the provided source object is unacceptable"); + } + sourceKeys = Object.keys(source); + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + if (!_hasOwnProperty$1.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} +function storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { + var index, quantity; + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state2, "nested arrays are not supported inside keys"); + } + if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") { + keyNode[index] = "[object Object]"; + } + } + } + if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") { + keyNode = "[object Object]"; + } + keyNode = String(keyNode); + if (_result === null) { + _result = {}; + } + if (keyTag === "tag:yaml.org,2002:merge") { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state2, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state2, _result, valueNode, overridableKeys); + } + } else { + if (!state2.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) { + state2.line = startLine || state2.line; + state2.lineStart = startLineStart || state2.lineStart; + state2.position = startPos || state2.position; + throwError(state2, "duplicated mapping key"); + } + if (keyNode === "__proto__") { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + return _result; +} +function readLineBreak(state2) { + var ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 10) { + state2.position++; + } else if (ch === 13) { + state2.position++; + if (state2.input.charCodeAt(state2.position) === 10) { + state2.position++; + } + } else { + throwError(state2, "a line break is expected"); + } + state2.line += 1; + state2.lineStart = state2.position; + state2.firstTabInLine = -1; +} +function skipSeparationSpace(state2, allowComments, checkIndent) { + var lineBreaks = 0, ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 9 && state2.firstTabInLine === -1) { + state2.firstTabInLine = state2.position; + } + ch = state2.input.charCodeAt(++state2.position); + } + if (allowComments && ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 10 && ch !== 13 && ch !== 0); + } + if (is_EOL(ch)) { + readLineBreak(state2); + ch = state2.input.charCodeAt(state2.position); + lineBreaks++; + state2.lineIndent = 0; + while (ch === 32) { + state2.lineIndent++; + ch = state2.input.charCodeAt(++state2.position); + } + } else { + break; + } + } + if (checkIndent !== -1 && lineBreaks !== 0 && state2.lineIndent < checkIndent) { + throwWarning(state2, "deficient indentation"); + } + return lineBreaks; +} +function testDocumentSeparator(state2) { + var _position = state2.position, ch; + ch = state2.input.charCodeAt(_position); + if ((ch === 45 || ch === 46) && ch === state2.input.charCodeAt(_position + 1) && ch === state2.input.charCodeAt(_position + 2)) { + _position += 3; + ch = state2.input.charCodeAt(_position); + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + return false; +} +function writeFoldedLines(state2, count) { + if (count === 1) { + state2.result += " "; + } else if (count > 1) { + state2.result += common.repeat("\n", count - 1); + } +} +function readPlainScalar(state2, nodeIndent, withinFlowCollection) { + var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state2.kind, _result = state2.result, ch; + ch = state2.input.charCodeAt(state2.position); + if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) { + return false; + } + if (ch === 63 || ch === 45) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + state2.kind = "scalar"; + state2.result = ""; + captureStart = captureEnd = state2.position; + hasPendingContent = false; + while (ch !== 0) { + if (ch === 58) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + } else if (ch === 35) { + preceding = state2.input.charCodeAt(state2.position - 1); + if (is_WS_OR_EOL(preceding)) { + break; + } + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2) || withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + } else if (is_EOL(ch)) { + _line = state2.line; + _lineStart = state2.lineStart; + _lineIndent = state2.lineIndent; + skipSeparationSpace(state2, false, -1); + if (state2.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state2.input.charCodeAt(state2.position); + continue; + } else { + state2.position = captureEnd; + state2.line = _line; + state2.lineStart = _lineStart; + state2.lineIndent = _lineIndent; + break; + } + } + if (hasPendingContent) { + captureSegment(state2, captureStart, captureEnd, false); + writeFoldedLines(state2, state2.line - _line); + captureStart = captureEnd = state2.position; + hasPendingContent = false; + } + if (!is_WHITE_SPACE(ch)) { + captureEnd = state2.position + 1; + } + ch = state2.input.charCodeAt(++state2.position); + } + captureSegment(state2, captureStart, captureEnd, false); + if (state2.result) { + return true; + } + state2.kind = _kind; + state2.result = _result; + return false; +} +function readSingleQuotedScalar(state2, nodeIndent) { + var ch, captureStart, captureEnd; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 39) { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + state2.position++; + captureStart = captureEnd = state2.position; + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + if (ch === 39) { + captureSegment(state2, captureStart, state2.position, true); + ch = state2.input.charCodeAt(++state2.position); + if (ch === 39) { + captureStart = state2.position; + state2.position++; + captureEnd = state2.position; + } else { + return true; + } + } else if (is_EOL(ch)) { + captureSegment(state2, captureStart, captureEnd, true); + writeFoldedLines(state2, skipSeparationSpace(state2, false, nodeIndent)); + captureStart = captureEnd = state2.position; + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + throwError(state2, "unexpected end of the document within a single quoted scalar"); + } else { + state2.position++; + captureEnd = state2.position; + } + } + throwError(state2, "unexpected end of the stream within a single quoted scalar"); +} +function readDoubleQuotedScalar(state2, nodeIndent) { + var captureStart, captureEnd, hexLength, hexResult, tmp, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 34) { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + state2.position++; + captureStart = captureEnd = state2.position; + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + if (ch === 34) { + captureSegment(state2, captureStart, state2.position, true); + state2.position++; + return true; + } else if (ch === 92) { + captureSegment(state2, captureStart, state2.position, true); + ch = state2.input.charCodeAt(++state2.position); + if (is_EOL(ch)) { + skipSeparationSpace(state2, false, nodeIndent); + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state2.result += simpleEscapeMap[ch]; + state2.position++; + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + for (; hexLength > 0; hexLength--) { + ch = state2.input.charCodeAt(++state2.position); + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + } else { + throwError(state2, "expected hexadecimal character"); + } + } + state2.result += charFromCodepoint(hexResult); + state2.position++; + } else { + throwError(state2, "unknown escape sequence"); + } + captureStart = captureEnd = state2.position; + } else if (is_EOL(ch)) { + captureSegment(state2, captureStart, captureEnd, true); + writeFoldedLines(state2, skipSeparationSpace(state2, false, nodeIndent)); + captureStart = captureEnd = state2.position; + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + throwError(state2, "unexpected end of the document within a double quoted scalar"); + } else { + state2.position++; + captureEnd = state2.position; + } + } + throwError(state2, "unexpected end of the stream within a double quoted scalar"); +} +function readFlowCollection(state2, nodeIndent) { + var readNext = true, _line, _lineStart, _pos, _tag = state2.tag, _result, _anchor = state2.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 91) { + terminator = 93; + isMapping = false; + _result = []; + } else if (ch === 123) { + terminator = 125; + isMapping = true; + _result = {}; + } else { + return false; + } + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(++state2.position); + while (ch !== 0) { + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if (ch === terminator) { + state2.position++; + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = isMapping ? "mapping" : "sequence"; + state2.result = _result; + return true; + } else if (!readNext) { + throwError(state2, "missed comma between flow collection entries"); + } else if (ch === 44) { + throwError(state2, "expected the node content, but found ','"); + } + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + if (ch === 63) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state2.position++; + skipSeparationSpace(state2, true, nodeIndent); + } + } + _line = state2.line; + _lineStart = state2.lineStart; + _pos = state2.position; + composeNode(state2, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state2.tag; + keyNode = state2.result; + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if ((isExplicitPair || state2.line === _line) && ch === 58) { + isPair = true; + ch = state2.input.charCodeAt(++state2.position); + skipSeparationSpace(state2, true, nodeIndent); + composeNode(state2, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state2.result; + } + if (isMapping) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state2, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if (ch === 44) { + readNext = true; + ch = state2.input.charCodeAt(++state2.position); + } else { + readNext = false; + } + } + throwError(state2, "unexpected end of the stream within a flow collection"); +} +function readBlockScalar(state2, nodeIndent) { + var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 124) { + folding = false; + } else if (ch === 62) { + folding = true; + } else { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + while (ch !== 0) { + ch = state2.input.charCodeAt(++state2.position); + if (ch === 43 || ch === 45) { + if (CHOMPING_CLIP === chomping) { + chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state2, "repeat of a chomping mode identifier"); + } + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state2, "bad explicit indentation width of a block scalar; it cannot be less than one"); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state2, "repeat of an indentation width identifier"); + } + } else { + break; + } + } + if (is_WHITE_SPACE(ch)) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (is_WHITE_SPACE(ch)); + if (ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (!is_EOL(ch) && ch !== 0); + } + } + while (ch !== 0) { + readLineBreak(state2); + state2.lineIndent = 0; + ch = state2.input.charCodeAt(state2.position); + while ((!detectedIndent || state2.lineIndent < textIndent) && ch === 32) { + state2.lineIndent++; + ch = state2.input.charCodeAt(++state2.position); + } + if (!detectedIndent && state2.lineIndent > textIndent) { + textIndent = state2.lineIndent; + } + if (is_EOL(ch)) { + emptyLines++; + continue; + } + if (state2.lineIndent < textIndent) { + if (chomping === CHOMPING_KEEP) { + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { + state2.result += "\n"; + } + } + break; + } + if (folding) { + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } else if (atMoreIndented) { + atMoreIndented = false; + state2.result += common.repeat("\n", emptyLines + 1); + } else if (emptyLines === 0) { + if (didReadContent) { + state2.result += " "; + } + } else { + state2.result += common.repeat("\n", emptyLines); + } + } else { + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state2.position; + while (!is_EOL(ch) && ch !== 0) { + ch = state2.input.charCodeAt(++state2.position); + } + captureSegment(state2, captureStart, state2.position, false); + } + return true; +} +function readBlockSequence(state2, nodeIndent) { + var _line, _tag = state2.tag, _anchor = state2.anchor, _result = [], following, detected = false, ch; + if (state2.firstTabInLine !== -1) + return false; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + if (state2.firstTabInLine !== -1) { + state2.position = state2.firstTabInLine; + throwError(state2, "tab characters must not be used in indentation"); + } + if (ch !== 45) { + break; + } + following = state2.input.charCodeAt(state2.position + 1); + if (!is_WS_OR_EOL(following)) { + break; + } + detected = true; + state2.position++; + if (skipSeparationSpace(state2, true, -1)) { + if (state2.lineIndent <= nodeIndent) { + _result.push(null); + ch = state2.input.charCodeAt(state2.position); + continue; + } + } + _line = state2.line; + composeNode(state2, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state2.result); + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + if ((state2.line === _line || state2.lineIndent > nodeIndent) && ch !== 0) { + throwError(state2, "bad indentation of a sequence entry"); + } else if (state2.lineIndent < nodeIndent) { + break; + } + } + if (detected) { + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = "sequence"; + state2.result = _result; + return true; + } + return false; +} +function readBlockMapping(state2, nodeIndent, flowIndent) { + var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state2.tag, _anchor = state2.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch; + if (state2.firstTabInLine !== -1) + return false; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + if (!atExplicitKey && state2.firstTabInLine !== -1) { + state2.position = state2.firstTabInLine; + throwError(state2, "tab characters must not be used in indentation"); + } + following = state2.input.charCodeAt(state2.position + 1); + _line = state2.line; + if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) { + if (ch === 63) { + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + detected = true; + atExplicitKey = true; + allowCompact = true; + } else if (atExplicitKey) { + atExplicitKey = false; + allowCompact = true; + } else { + throwError(state2, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"); + } + state2.position += 1; + ch = following; + } else { + _keyLine = state2.line; + _keyLineStart = state2.lineStart; + _keyPos = state2.position; + if (!composeNode(state2, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + break; + } + if (state2.line === _line) { + ch = state2.input.charCodeAt(state2.position); + while (is_WHITE_SPACE(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (ch === 58) { + ch = state2.input.charCodeAt(++state2.position); + if (!is_WS_OR_EOL(ch)) { + throwError(state2, "a whitespace character is expected after the key-value separator within a block mapping"); + } + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state2.tag; + keyNode = state2.result; + } else if (detected) { + throwError(state2, "can not read an implicit mapping pair; a colon is missed"); + } else { + state2.tag = _tag; + state2.anchor = _anchor; + return true; + } + } else if (detected) { + throwError(state2, "can not read a block mapping entry; a multiline key may not be an implicit key"); + } else { + state2.tag = _tag; + state2.anchor = _anchor; + return true; + } + } + if (state2.line === _line || state2.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state2.line; + _keyLineStart = state2.lineStart; + _keyPos = state2.position; + } + if (composeNode(state2, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state2.result; + } else { + valueNode = state2.result; + } + } + if (!atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + } + if ((state2.line === _line || state2.lineIndent > nodeIndent) && ch !== 0) { + throwError(state2, "bad indentation of a mapping entry"); + } else if (state2.lineIndent < nodeIndent) { + break; + } + } + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + if (detected) { + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = "mapping"; + state2.result = _result; + } + return detected; +} +function readTagProperty(state2) { + var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 33) + return false; + if (state2.tag !== null) { + throwError(state2, "duplication of a tag property"); + } + ch = state2.input.charCodeAt(++state2.position); + if (ch === 60) { + isVerbatim = true; + ch = state2.input.charCodeAt(++state2.position); + } else if (ch === 33) { + isNamed = true; + tagHandle = "!!"; + ch = state2.input.charCodeAt(++state2.position); + } else { + tagHandle = "!"; + } + _position = state2.position; + if (isVerbatim) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 0 && ch !== 62); + if (state2.position < state2.length) { + tagName = state2.input.slice(_position, state2.position); + ch = state2.input.charCodeAt(++state2.position); + } else { + throwError(state2, "unexpected end of the stream within a verbatim tag"); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + if (ch === 33) { + if (!isNamed) { + tagHandle = state2.input.slice(_position - 1, state2.position + 1); + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state2, "named tag handle cannot contain such characters"); + } + isNamed = true; + _position = state2.position + 1; + } else { + throwError(state2, "tag suffix cannot contain exclamation marks"); + } + } + ch = state2.input.charCodeAt(++state2.position); + } + tagName = state2.input.slice(_position, state2.position); + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state2, "tag suffix cannot contain flow indicator characters"); + } + } + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state2, "tag name cannot contain such characters: " + tagName); + } + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state2, "tag name is malformed: " + tagName); + } + if (isVerbatim) { + state2.tag = tagName; + } else if (_hasOwnProperty$1.call(state2.tagMap, tagHandle)) { + state2.tag = state2.tagMap[tagHandle] + tagName; + } else if (tagHandle === "!") { + state2.tag = "!" + tagName; + } else if (tagHandle === "!!") { + state2.tag = "tag:yaml.org,2002:" + tagName; + } else { + throwError(state2, 'undeclared tag handle "' + tagHandle + '"'); + } + return true; +} +function readAnchorProperty(state2) { + var _position, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 38) + return false; + if (state2.anchor !== null) { + throwError(state2, "duplication of an anchor property"); + } + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (state2.position === _position) { + throwError(state2, "name of an anchor node must contain at least one character"); + } + state2.anchor = state2.input.slice(_position, state2.position); + return true; +} +function readAlias(state2) { + var _position, alias, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 42) + return false; + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (state2.position === _position) { + throwError(state2, "name of an alias node must contain at least one character"); + } + alias = state2.input.slice(_position, state2.position); + if (!_hasOwnProperty$1.call(state2.anchorMap, alias)) { + throwError(state2, 'unidentified alias "' + alias + '"'); + } + state2.result = state2.anchorMap[alias]; + skipSeparationSpace(state2, true, -1); + return true; +} +function composeNode(state2, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent; + if (state2.listener !== null) { + state2.listener("open", state2); + } + state2.tag = null; + state2.anchor = null; + state2.kind = null; + state2.result = null; + allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext; + if (allowToSeek) { + if (skipSeparationSpace(state2, true, -1)) { + atNewLine = true; + if (state2.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state2.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state2.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + if (indentStatus === 1) { + while (readTagProperty(state2) || readAnchorProperty(state2)) { + if (skipSeparationSpace(state2, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + if (state2.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state2.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state2.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + blockIndent = state2.position - state2.lineStart; + if (indentStatus === 1) { + if (allowBlockCollections && (readBlockSequence(state2, blockIndent) || readBlockMapping(state2, blockIndent, flowIndent)) || readFlowCollection(state2, flowIndent)) { + hasContent = true; + } else { + if (allowBlockScalars && readBlockScalar(state2, flowIndent) || readSingleQuotedScalar(state2, flowIndent) || readDoubleQuotedScalar(state2, flowIndent)) { + hasContent = true; + } else if (readAlias(state2)) { + hasContent = true; + if (state2.tag !== null || state2.anchor !== null) { + throwError(state2, "alias node should not have any properties"); + } + } else if (readPlainScalar(state2, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + if (state2.tag === null) { + state2.tag = "?"; + } + } + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } + } else if (indentStatus === 0) { + hasContent = allowBlockCollections && readBlockSequence(state2, blockIndent); + } + } + if (state2.tag === null) { + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } else if (state2.tag === "?") { + if (state2.result !== null && state2.kind !== "scalar") { + throwError(state2, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state2.kind + '"'); + } + for (typeIndex = 0, typeQuantity = state2.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type2 = state2.implicitTypes[typeIndex]; + if (type2.resolve(state2.result)) { + state2.result = type2.construct(state2.result); + state2.tag = type2.tag; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + break; + } + } + } else if (state2.tag !== "!") { + if (_hasOwnProperty$1.call(state2.typeMap[state2.kind || "fallback"], state2.tag)) { + type2 = state2.typeMap[state2.kind || "fallback"][state2.tag]; + } else { + type2 = null; + typeList = state2.typeMap.multi[state2.kind || "fallback"]; + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state2.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type2 = typeList[typeIndex]; + break; + } + } + } + if (!type2) { + throwError(state2, "unknown tag !<" + state2.tag + ">"); + } + if (state2.result !== null && type2.kind !== state2.kind) { + throwError(state2, "unacceptable node kind for !<" + state2.tag + '> tag; it should be "' + type2.kind + '", not "' + state2.kind + '"'); + } + if (!type2.resolve(state2.result, state2.tag)) { + throwError(state2, "cannot resolve a node with !<" + state2.tag + "> explicit tag"); + } else { + state2.result = type2.construct(state2.result, state2.tag); + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } + } + if (state2.listener !== null) { + state2.listener("close", state2); + } + return state2.tag !== null || state2.anchor !== null || hasContent; +} +function readDocument(state2) { + var documentStart = state2.position, _position, directiveName, directiveArgs, hasDirectives = false, ch; + state2.version = null; + state2.checkLineBreaks = state2.legacy; + state2.tagMap = /* @__PURE__ */ Object.create(null); + state2.anchorMap = /* @__PURE__ */ Object.create(null); + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + if (state2.lineIndent > 0 || ch !== 37) { + break; + } + hasDirectives = true; + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + directiveName = state2.input.slice(_position, state2.position); + directiveArgs = []; + if (directiveName.length < 1) { + throwError(state2, "directive name must not be less than one character in length"); + } + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 0 && !is_EOL(ch)); + break; + } + if (is_EOL(ch)) + break; + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + directiveArgs.push(state2.input.slice(_position, state2.position)); + } + if (ch !== 0) + readLineBreak(state2); + if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state2, directiveName, directiveArgs); + } else { + throwWarning(state2, 'unknown document directive "' + directiveName + '"'); + } + } + skipSeparationSpace(state2, true, -1); + if (state2.lineIndent === 0 && state2.input.charCodeAt(state2.position) === 45 && state2.input.charCodeAt(state2.position + 1) === 45 && state2.input.charCodeAt(state2.position + 2) === 45) { + state2.position += 3; + skipSeparationSpace(state2, true, -1); + } else if (hasDirectives) { + throwError(state2, "directives end mark is expected"); + } + composeNode(state2, state2.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state2, true, -1); + if (state2.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state2.input.slice(documentStart, state2.position))) { + throwWarning(state2, "non-ASCII line breaks are interpreted as content"); + } + state2.documents.push(state2.result); + if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + if (state2.input.charCodeAt(state2.position) === 46) { + state2.position += 3; + skipSeparationSpace(state2, true, -1); + } + return; + } + if (state2.position < state2.length - 1) { + throwError(state2, "end of the stream or a document separator is expected"); + } else { + return; + } +} +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + if (input.length !== 0) { + if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) { + input += "\n"; + } + if (input.charCodeAt(0) === 65279) { + input = input.slice(1); + } + } + var state2 = new State$1(input, options); + var nullpos = input.indexOf("\0"); + if (nullpos !== -1) { + state2.position = nullpos; + throwError(state2, "null byte is not allowed in input"); + } + state2.input += "\0"; + while (state2.input.charCodeAt(state2.position) === 32) { + state2.lineIndent += 1; + state2.position += 1; + } + while (state2.position < state2.length - 1) { + readDocument(state2); + } + return state2.documents; +} +function loadAll$1(input, iterator, options) { + if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") { + options = iterator; + iterator = null; + } + var documents = loadDocuments(input, options); + if (typeof iterator !== "function") { + return documents; + } + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} +function load$1(input, options) { + var documents = loadDocuments(input, options); + if (documents.length === 0) { + return void 0; + } else if (documents.length === 1) { + return documents[0]; + } + throw new exception("expected a single document in the stream, but found more"); +} +var loadAll_1 = loadAll$1; +var load_1 = load$1; +var loader = { + loadAll: loadAll_1, + load: load_1 +}; +var JSON_SCHEMA = json; +var load = loader.load; +function extractFrontMatter(text) { + const matches = text.match(frontMatterRegex); + if (!matches) { + return { + text, + metadata: {} + }; + } + let parsed = load(matches[1], { + // To support config, we need JSON schema. + // https://www.yaml.org/spec/1.2/spec.html#id2803231 + schema: JSON_SCHEMA + }) ?? {}; + parsed = typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}; + const metadata = {}; + if (parsed.displayMode) { + metadata.displayMode = parsed.displayMode.toString(); + } + if (parsed.title) { + metadata.title = parsed.title.toString(); + } + if (parsed.config) { + metadata.config = parsed.config; + } + return { + text: text.slice(matches[0].length), + metadata + }; +} +const cleanupText = (code) => { + return code.replace(/\r\n?/g, "\n").replace( + /<(\w+)([^>]*)>/g, + (match, tag, attributes) => "<" + tag + attributes.replace(/="([^"]*)"/g, "='$1'") + ">" + ); +}; +const processFrontmatter = (code) => { + const { text, metadata } = extractFrontMatter(code); + const { displayMode, title, config: config2 = {} } = metadata; + if (displayMode) { + if (!config2.gantt) { + config2.gantt = {}; + } + config2.gantt.displayMode = displayMode; + } + return { title, config: config2, text }; +}; +const processDirectives = (code) => { + const initDirective = utils.detectInit(code) ?? {}; + const wrapDirectives = utils.detectDirective(code, "wrap"); + if (Array.isArray(wrapDirectives)) { + initDirective.wrap = wrapDirectives.some(({ type: type2 }) => { + }); + } else if ((wrapDirectives == null ? void 0 : wrapDirectives.type) === "wrap") { + initDirective.wrap = true; + } + return { + text: removeDirectives(code), + directive: initDirective + }; +}; +function preprocessDiagram(code) { + const cleanedCode = cleanupText(code); + const frontMatterResult = processFrontmatter(cleanedCode); + const directiveResult = processDirectives(frontMatterResult.text); + const config2 = cleanAndMerge(frontMatterResult.config, directiveResult.directive); + code = cleanupComments(directiveResult.text); + return { + code, + title: frontMatterResult.title, + config: config2 + }; +} +const MAX_TEXTLENGTH = 5e4; +const MAX_TEXTLENGTH_EXCEEDED_MSG = "graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa"; +const SECURITY_LVL_SANDBOX = "sandbox"; +const SECURITY_LVL_LOOSE = "loose"; +const XMLNS_SVG_STD = "http://www.w3.org/2000/svg"; +const XMLNS_XLINK_STD = "http://www.w3.org/1999/xlink"; +const XMLNS_XHTML_STD = "http://www.w3.org/1999/xhtml"; +const IFRAME_WIDTH = "100%"; +const IFRAME_HEIGHT = "100%"; +const IFRAME_STYLES = "border:0;margin:0;"; +const IFRAME_BODY_STYLE = "margin:0"; +const IFRAME_SANDBOX_OPTS = "allow-top-navigation-by-user-activation allow-popups"; +const IFRAME_NOT_SUPPORTED_MSG = 'The "iframe" tag is not supported by your browser.'; +const DOMPURIFY_TAGS = ["foreignobject"]; +const DOMPURIFY_ATTR = ["dominant-baseline"]; +function processAndSetConfigs(text) { + const processed = preprocessDiagram(text); + reset(); + addDirective(processed.config ?? {}); + return processed; +} +async function parse$1(text, parseOptions) { + addDiagrams(); + text = processAndSetConfigs(text).code; + try { + await getDiagramFromText(text); + } catch (error) { + if (parseOptions == null ? void 0 : parseOptions.suppressErrors) { + return false; + } + throw error; + } + return true; +} +const cssImportantStyles = (cssClass, element, cssClasses = []) => { + return ` +.${cssClass} ${element} { ${cssClasses.join(" !important; ")} !important; }`; +}; +const createCssStyles = (config2, classDefs = {}) => { + var _a; + let cssStyles = ""; + if (config2.themeCSS !== void 0) { + cssStyles += ` +${config2.themeCSS}`; + } + if (config2.fontFamily !== void 0) { + cssStyles += ` +:root { --mermaid-font-family: ${config2.fontFamily}}`; + } + if (config2.altFontFamily !== void 0) { + cssStyles += ` +:root { --mermaid-alt-font-family: ${config2.altFontFamily}}`; + } + if (!isEmpty(classDefs)) { + const htmlLabels = config2.htmlLabels || ((_a = config2.flowchart) == null ? void 0 : _a.htmlLabels); + const cssHtmlElements = ["> *", "span"]; + const cssShapeElements = ["rect", "polygon", "ellipse", "circle", "path"]; + const cssElements = htmlLabels ? cssHtmlElements : cssShapeElements; + for (const classId in classDefs) { + const styleClassDef = classDefs[classId]; + if (!isEmpty(styleClassDef.styles)) { + cssElements.forEach((cssElement) => { + cssStyles += cssImportantStyles(styleClassDef.id, cssElement, styleClassDef.styles); + }); + } + if (!isEmpty(styleClassDef.textStyles)) { + cssStyles += cssImportantStyles(styleClassDef.id, "tspan", styleClassDef.textStyles); + } + } + } + return cssStyles; +}; +const createUserStyles = (config2, graphType, classDefs, svgId) => { + const userCSSstyles = createCssStyles(config2, classDefs); + const allStyles = getStyles$1(graphType, userCSSstyles, config2.themeVariables); + return serialize(compile(`${svgId}{${allStyles}}`), stringify); +}; +const cleanUpSvgCode = (svgCode = "", inSandboxMode, useArrowMarkerUrls) => { + let cleanedUpSvg = svgCode; + if (!useArrowMarkerUrls && !inSandboxMode) { + cleanedUpSvg = cleanedUpSvg.replace( + /marker-end="url\([\d+./:=?A-Za-z-]*?#/g, + 'marker-end="url(#' + ); + } + cleanedUpSvg = decodeEntities(cleanedUpSvg); + cleanedUpSvg = cleanedUpSvg.replace(/
/g, "
"); + return cleanedUpSvg; +}; +const putIntoIFrame = (svgCode = "", svgElement) => { + var _a, _b; + const height = ((_b = (_a = svgElement == null ? void 0 : svgElement.viewBox) == null ? void 0 : _a.baseVal) == null ? void 0 : _b.height) ? svgElement.viewBox.baseVal.height + "px" : IFRAME_HEIGHT; + const base64encodedSrc = btoa('' + svgCode + ""); + return ``; +}; +const appendDivSvgG = (parentRoot, id2, enclosingDivId, divStyle, svgXlink) => { + const enclosingDiv = parentRoot.append("div"); + enclosingDiv.attr("id", enclosingDivId); + if (divStyle) { + enclosingDiv.attr("style", divStyle); + } + const svgNode = enclosingDiv.append("svg").attr("id", id2).attr("width", "100%").attr("xmlns", XMLNS_SVG_STD); + if (svgXlink) { + svgNode.attr("xmlns:xlink", svgXlink); + } + svgNode.append("g"); + return parentRoot; +}; +function sandboxedIframe(parentNode, iFrameId) { + return parentNode.append("iframe").attr("id", iFrameId).attr("style", "width: 100%; height: 100%;").attr("sandbox", ""); +} +const removeExistingElements = (doc, id2, divId, iFrameId) => { + var _a, _b, _c; + (_a = doc.getElementById(id2)) == null ? void 0 : _a.remove(); + (_b = doc.getElementById(divId)) == null ? void 0 : _b.remove(); + (_c = doc.getElementById(iFrameId)) == null ? void 0 : _c.remove(); +}; +const render$1 = async function(id2, text, svgContainingElement) { + var _a, _b, _c, _d, _e, _f; + addDiagrams(); + const processed = processAndSetConfigs(text); + text = processed.code; + const config2 = getConfig$1(); + log$1.debug(config2); + if (text.length > ((config2 == null ? void 0 : config2.maxTextSize) ?? MAX_TEXTLENGTH)) { + text = MAX_TEXTLENGTH_EXCEEDED_MSG; + } + const idSelector = "#" + id2; + const iFrameID = "i" + id2; + const iFrameID_selector = "#" + iFrameID; + const enclosingDivID = "d" + id2; + const enclosingDivID_selector = "#" + enclosingDivID; + let root = select("body"); + const isSandboxed = config2.securityLevel === SECURITY_LVL_SANDBOX; + const isLooseSecurityLevel = config2.securityLevel === SECURITY_LVL_LOOSE; + const fontFamily = config2.fontFamily; + if (svgContainingElement !== void 0) { + if (svgContainingElement) { + svgContainingElement.innerHTML = ""; + } + if (isSandboxed) { + const iframe = sandboxedIframe(select(svgContainingElement), iFrameID); + root = select(iframe.nodes()[0].contentDocument.body); + root.node().style.margin = 0; + } else { + root = select(svgContainingElement); + } + appendDivSvgG(root, id2, enclosingDivID, `font-family: ${fontFamily}`, XMLNS_XLINK_STD); + } else { + removeExistingElements(document, id2, enclosingDivID, iFrameID); + if (isSandboxed) { + const iframe = sandboxedIframe(select("body"), iFrameID); + root = select(iframe.nodes()[0].contentDocument.body); + root.node().style.margin = 0; + } else { + root = select("body"); + } + appendDivSvgG(root, id2, enclosingDivID); + } + let diag; + let parseEncounteredException; + try { + diag = await getDiagramFromText(text, { title: processed.title }); + } catch (error) { + diag = new Diagram("error"); + parseEncounteredException = error; + } + const element = root.select(enclosingDivID_selector).node(); + const diagramType = diag.type; + const svg = element.firstChild; + const firstChild = svg.firstChild; + const diagramClassDefs = (_b = (_a = diag.renderer).getClasses) == null ? void 0 : _b.call(_a, text, diag); + const rules = createUserStyles(config2, diagramType, diagramClassDefs, idSelector); + const style1 = document.createElement("style"); + style1.innerHTML = rules; + svg.insertBefore(style1, firstChild); + try { + await diag.renderer.draw(text, id2, version, diag); + } catch (e) { + errorRenderer.draw(text, id2, version); + throw e; + } + const svgNode = root.select(`${enclosingDivID_selector} svg`); + const a11yTitle = (_d = (_c = diag.db).getAccTitle) == null ? void 0 : _d.call(_c); + const a11yDescr = (_f = (_e = diag.db).getAccDescription) == null ? void 0 : _f.call(_e); + addA11yInfo(diagramType, svgNode, a11yTitle, a11yDescr); + root.select(`[id="${id2}"]`).selectAll("foreignobject > *").attr("xmlns", XMLNS_XHTML_STD); + let svgCode = root.select(enclosingDivID_selector).node().innerHTML; + log$1.debug("config.arrowMarkerAbsolute", config2.arrowMarkerAbsolute); + svgCode = cleanUpSvgCode(svgCode, isSandboxed, evaluate(config2.arrowMarkerAbsolute)); + if (isSandboxed) { + const svgEl = root.select(enclosingDivID_selector + " svg").node(); + svgCode = putIntoIFrame(svgCode, svgEl); + } else if (!isLooseSecurityLevel) { + svgCode = purify.sanitize(svgCode, { + ADD_TAGS: DOMPURIFY_TAGS, + ADD_ATTR: DOMPURIFY_ATTR + }); + } + attachFunctions(); + if (parseEncounteredException) { + throw parseEncounteredException; + } + const tmpElementSelector = isSandboxed ? iFrameID_selector : enclosingDivID_selector; + const node = select(tmpElementSelector).node(); + if (node && "remove" in node) { + node.remove(); + } + return { + svg: svgCode, + bindFunctions: diag.db.bindFunctions + }; +}; +function initialize$1(options = {}) { + var _a; + if ((options == null ? void 0 : options.fontFamily) && !((_a = options.themeVariables) == null ? void 0 : _a.fontFamily)) { + if (!options.themeVariables) { + options.themeVariables = {}; + } + options.themeVariables.fontFamily = options.fontFamily; + } + saveConfigFromInitialize(options); + if ((options == null ? void 0 : options.theme) && options.theme in theme) { + options.themeVariables = theme[options.theme].getThemeVariables( + options.themeVariables + ); + } else if (options) { + options.themeVariables = theme.default.getThemeVariables(options.themeVariables); + } + const config2 = typeof options === "object" ? setSiteConfig(options) : getSiteConfig(); + setLogLevel$1(config2.logLevel); + addDiagrams(); +} +const getDiagramFromText = (text, metadata = {}) => { + const { code } = preprocessDiagram(text); + return getDiagramFromText$1(code, metadata); +}; +function addA11yInfo(diagramType, svgNode, a11yTitle, a11yDescr) { + setA11yDiagramInfo(svgNode, diagramType); + addSVGa11yTitleDescription(svgNode, a11yTitle, a11yDescr, svgNode.attr("id")); +} +const mermaidAPI = Object.freeze({ + render: render$1, + parse: parse$1, + getDiagramFromText, + initialize: initialize$1, + getConfig: getConfig$1, + setConfig: setConfig$1, + getSiteConfig, + updateSiteConfig, + reset: () => { + reset(); + }, + globalReset: () => { + reset(defaultConfig$1); + }, + defaultConfig: defaultConfig$1 +}); +setLogLevel$1(getConfig$1().logLevel); +reset(getConfig$1()); +const loadRegisteredDiagrams = async () => { + log$1.debug(`Loading registered diagrams`); + const results = await Promise.allSettled( + Object.entries(detectors).map(async ([key, { detector: detector2, loader: loader2 }]) => { + if (loader2) { + try { + getDiagram(key); + } catch (error) { + try { + const { diagram: diagram2, id: id2 } = await loader2(); + registerDiagram(id2, diagram2, detector2); + } catch (err) { + log$1.error(`Failed to load external diagram with key ${key}. Removing from detectors.`); + delete detectors[key]; + throw err; + } + } + } + }) + ); + const failed = results.filter((result) => result.status === "rejected"); + if (failed.length > 0) { + log$1.error(`Failed to load ${failed.length} external diagrams`); + for (const res of failed) { + log$1.error(res); + } + throw new Error(`Failed to load ${failed.length} external diagrams`); + } +}; +const handleError = (error, errors, parseError) => { + log$1.warn(error); + if (isDetailedError(error)) { + if (parseError) { + parseError(error.str, error.hash); + } + errors.push({ ...error, message: error.str, error }); + } else { + if (parseError) { + parseError(error); + } + if (error instanceof Error) { + errors.push({ + str: error.message, + message: error.message, + hash: error.name, + error + }); + } + } +}; +const run = async function(options = { + querySelector: ".mermaid" +}) { + try { + await runThrowsErrors(options); + } catch (e) { + if (isDetailedError(e)) { + log$1.error(e.str); + } + if (mermaid.parseError) { + mermaid.parseError(e); + } + if (!options.suppressErrors) { + log$1.error("Use the suppressErrors option to suppress these errors"); + throw e; + } + } +}; +const runThrowsErrors = async function({ postRenderCallback, querySelector, nodes } = { + querySelector: ".mermaid" +}) { + const conf = mermaidAPI.getConfig(); + log$1.debug(`${!postRenderCallback ? "No " : ""}Callback function found`); + let nodesToProcess; + if (nodes) { + nodesToProcess = nodes; + } else if (querySelector) { + nodesToProcess = document.querySelectorAll(querySelector); + } else { + throw new Error("Nodes and querySelector are both undefined"); + } + log$1.debug(`Found ${nodesToProcess.length} diagrams`); + if ((conf == null ? void 0 : conf.startOnLoad) !== void 0) { + log$1.debug("Start On Load: " + (conf == null ? void 0 : conf.startOnLoad)); + mermaidAPI.updateSiteConfig({ startOnLoad: conf == null ? void 0 : conf.startOnLoad }); + } + const idGenerator = new utils.InitIDGenerator(conf.deterministicIds, conf.deterministicIDSeed); + let txt; + const errors = []; + for (const element of Array.from(nodesToProcess)) { + log$1.info("Rendering diagram: " + element.id); + /*! Check if previously processed */ + if (element.getAttribute("data-processed")) { + continue; + } + element.setAttribute("data-processed", "true"); + const id2 = `mermaid-${idGenerator.next()}`; + txt = element.innerHTML; + txt = dedent(utils.entityDecode(txt)).trim().replace(//gi, "
"); + const init2 = utils.detectInit(txt); + if (init2) { + log$1.debug("Detected early reinit: ", init2); + } + try { + const { svg, bindFunctions } = await render(id2, txt, element); + element.innerHTML = svg; + if (postRenderCallback) { + await postRenderCallback(id2); + } + if (bindFunctions) { + bindFunctions(element); + } + } catch (error) { + handleError(error, errors, mermaid.parseError); + } + } + if (errors.length > 0) { + throw errors[0]; + } +}; +const initialize = function(config2) { + mermaidAPI.initialize(config2); +}; +const init = async function(config2, nodes, callback) { + log$1.warn("mermaid.init is deprecated. Please use run instead."); + if (config2) { + initialize(config2); + } + const runOptions = { postRenderCallback: callback, querySelector: ".mermaid" }; + if (typeof nodes === "string") { + runOptions.querySelector = nodes; + } else if (nodes) { + if (nodes instanceof HTMLElement) { + runOptions.nodes = [nodes]; + } else { + runOptions.nodes = nodes; + } + } + await run(runOptions); +}; +const registerExternalDiagrams = async (diagrams2, { + lazyLoad = true +} = {}) => { + registerLazyLoadedDiagrams(...diagrams2); + if (lazyLoad === false) { + await loadRegisteredDiagrams(); + } +}; +const contentLoaded = function() { + if (mermaid.startOnLoad) { + const { startOnLoad } = mermaidAPI.getConfig(); + if (startOnLoad) { + mermaid.run().catch((err) => log$1.error("Mermaid failed to initialize", err)); + } + } +}; +if (typeof document !== "undefined") { + /*! + * Wait for document loaded before starting the execution + */ + window.addEventListener("load", contentLoaded, false); +} +const setParseErrorHandler = function(parseErrorHandler) { + mermaid.parseError = parseErrorHandler; +}; +const executionQueue = []; +let executionQueueRunning = false; +const executeQueue = async () => { + if (executionQueueRunning) { + return; + } + executionQueueRunning = true; + while (executionQueue.length > 0) { + const f = executionQueue.shift(); + if (f) { + try { + await f(); + } catch (e) { + log$1.error("Error executing queue", e); + } + } + } + executionQueueRunning = false; +}; +const parse = async (text, parseOptions) => { + return new Promise((resolve, reject) => { + const performCall = () => new Promise((res, rej) => { + mermaidAPI.parse(text, parseOptions).then( + (r) => { + res(r); + resolve(r); + }, + (e) => { + var _a; + log$1.error("Error parsing", e); + (_a = mermaid.parseError) == null ? void 0 : _a.call(mermaid, e); + rej(e); + reject(e); + } + ); + }); + executionQueue.push(performCall); + executeQueue().catch(reject); + }); +}; +const render = (id2, text, container) => { + return new Promise((resolve, reject) => { + const performCall = () => new Promise((res, rej) => { + mermaidAPI.render(id2, text, container).then( + (r) => { + res(r); + resolve(r); + }, + (e) => { + var _a; + log$1.error("Error parsing", e); + (_a = mermaid.parseError) == null ? void 0 : _a.call(mermaid, e); + rej(e); + reject(e); + } + ); + }); + executionQueue.push(performCall); + executeQueue().catch(reject); + }); +}; +const mermaid = { + startOnLoad: true, + mermaidAPI, + parse, + render, + init, + run, + registerExternalDiagrams, + initialize, + parseError: void 0, + contentLoaded, + setParseErrorHandler, + detectType +}; + +/** + * https://mermaid.js.org/config/usage.html + */ +mermaid.initialize({ startOnLoad: true }); +function parseMermaidHtml(el) { + return new Promise(function (resolve) { + var nodes = el.querySelectorAll('pre.mermaid'); + resolve(mermaid.run({ + nodes: nodes, + })); + }); +} + +export { constant$1 as $, utils as A, rgba as B, setDiagramTitle as C, getDiagramTitle as D, clear as E, curveBasis as F, parseGenericTypes as G, setupGraphViewbox as H, random as I, define as J, extend$1 as K, Color$1 as L, rgbConvert as M, nogamma as N, hue as O, commonjsGlobal as P, getDefaultExportFromCjs as Q, Rgb as R, Selection$1 as S, dayjs as T, selectSvgElement as U, tau as V, defaultConfig$2 as W, cleanAndMerge as X, parseFontSize as Y, getThemeVariables$2 as Z, getConfig$1 as _, getAccDescription as a, MapCache as a$, interpolateNumber as a0, color as a1, interpolateRgb as a2, interpolateString as a3, hasKatex as a4, calculateMathMLDimensions as a5, ZERO_WIDTH_SPACE as a6, generateId as a7, isObject$1 as a8, setToString as a9, sqrt as aA, min as aB, abs$1 as aC, atan2 as aD, asin as aE, acos as aF, max as aG, Utils as aH, Color as aI, isObjectLike as aJ, baseGetTag as aK, Symbol$1 as aL, arrayLikeKeys as aM, baseKeys as aN, memoize as aO, isArguments as aP, copyObject as aQ, getPrototype as aR, cloneArrayBuffer as aS, cloneTypedArray as aT, getTag as aU, nodeUtil as aV, copyArray as aW, isBuffer as aX, cloneBuffer as aY, initCloneObject as aZ, Stack as a_, overRest as aa, baseRest as ab, isIterateeCall as ac, keysIn as ad, eq as ae, isArrayLike as af, isArray as ag, baseFor as ah, baseAssignValue as ai, identity as aj, isIndex as ak, assignValue as al, baseUnary as am, constant as an, merge$1 as ao, lineBreakRegex as ap, defaultConfig as aq, commonDb as ar, isDark as as, lighten as at, darken as au, pi as av, cos as aw, sin as ax, halfPi as ay, epsilon as az, setAccDescription as b, Uint8Array$1 as b0, isTypedArray as b1, isLength as b2, Set$1 as b3, isArrayLikeObject as b4, isEmpty as b5, decodeEntities as b6, dedent as b7, md2Html as b8, parseMermaidHtml as b9, getConfig as c, sanitizeText$2 as d, assignWithDepth$1 as e, calculateTextWidth as f, getAccTitle as g, select as h, configureSvgSize as i, common$1 as j, calculateTextHeight as k, log$1 as l, dist as m, curveLinear as n, getStylesFromArray as o, evaluate as p, interpolateToCurve as q, renderKatex as r, setAccTitle as s, setupGraphViewbox$1 as t, setConfig as u, root$1 as v, wrapLabel as w, array as x, isPlainObject as y, isFunction as z }; diff --git a/libs/marked/index-CN3YjQ0n.js b/libs/marked/index-CN3YjQ0n.js new file mode 100644 index 0000000..f145aee --- /dev/null +++ b/libs/marked/index-CN3YjQ0n.js @@ -0,0 +1,36496 @@ +/** + * marked v12.0.2 - a markdown parser + * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ + +/** + * DO NOT EDIT THIS FILE + * The code in this file is generated from files in ./src/ + */ + +/** + * Gets the original marked default options. + */ +function _getDefaults() { + return { + async: false, + breaks: false, + extensions: null, + gfm: true, + hooks: null, + pedantic: false, + renderer: null, + silent: false, + tokenizer: null, + walkTokens: null + }; +} +let _defaults = _getDefaults(); +function changeDefaults(newDefaults) { + _defaults = newDefaults; +} + +/** + * Helpers + */ +const escapeTest = /[&<>"']/; +const escapeReplace = new RegExp(escapeTest.source, 'g'); +const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/; +const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g'); +const escapeReplacements = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; +const getEscapeReplacement = (ch) => escapeReplacements[ch]; +function escape$1$1(html, encode) { + if (encode) { + if (escapeTest.test(html)) { + return html.replace(escapeReplace, getEscapeReplacement); + } + } + else { + if (escapeTestNoEncode.test(html)) { + return html.replace(escapeReplaceNoEncode, getEscapeReplacement); + } + } + return html; +} +const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig; +function unescape$1(html) { + // explicitly match decimal, hex, and named HTML entities + return html.replace(unescapeTest, (_, n) => { + n = n.toLowerCase(); + if (n === 'colon') + return ':'; + if (n.charAt(0) === '#') { + return n.charAt(1) === 'x' + ? String.fromCharCode(parseInt(n.substring(2), 16)) + : String.fromCharCode(+n.substring(1)); + } + return ''; + }); +} +const caret$1 = /(^|[^\[])\^/g; +function edit(regex, opt) { + let source = typeof regex === 'string' ? regex : regex.source; + opt = opt || ''; + const obj = { + replace: (name, val) => { + let valSource = typeof val === 'string' ? val : val.source; + valSource = valSource.replace(caret$1, '$1'); + source = source.replace(name, valSource); + return obj; + }, + getRegex: () => { + return new RegExp(source, opt); + } + }; + return obj; +} +function cleanUrl(href) { + try { + href = encodeURI(href).replace(/%25/g, '%'); + } + catch (e) { + return null; + } + return href; +} +const noopTest = { exec: () => null }; +function splitCells$1(tableRow, count) { + // ensure that every cell-delimiting pipe has a space + // before it to distinguish it from an escaped pipe + const row = tableRow.replace(/\|/g, (match, offset, str) => { + let escaped = false; + let curr = offset; + while (--curr >= 0 && str[curr] === '\\') + escaped = !escaped; + if (escaped) { + // odd number of slashes means | is escaped + // so we leave it alone + return '|'; + } + else { + // add space before unescaped | + return ' |'; + } + }), cells = row.split(/ \|/); + let i = 0; + // First/last cell in a row cannot be empty if it has no leading/trailing pipe + if (!cells[0].trim()) { + cells.shift(); + } + if (cells.length > 0 && !cells[cells.length - 1].trim()) { + cells.pop(); + } + if (count) { + if (cells.length > count) { + cells.splice(count); + } + else { + while (cells.length < count) + cells.push(''); + } + } + for (; i < cells.length; i++) { + // leading or trailing whitespace is ignored per the gfm spec + cells[i] = cells[i].trim().replace(/\\\|/g, '|'); + } + return cells; +} +/** + * Remove trailing 'c's. Equivalent to str.replace(/c*$/, ''). + * /c*$/ is vulnerable to REDOS. + * + * @param str + * @param c + * @param invert Remove suffix of non-c chars instead. Default falsey. + */ +function rtrim(str, c, invert) { + const l = str.length; + if (l === 0) { + return ''; + } + // Length of suffix matching the invert condition. + let suffLen = 0; + // Step left until we fail to match the invert condition. + while (suffLen < l) { + const currChar = str.charAt(l - suffLen - 1); + if (currChar === c && !invert) { + suffLen++; + } + else if (currChar !== c && invert) { + suffLen++; + } + else { + break; + } + } + return str.slice(0, l - suffLen); +} +function findClosingBracket(str, b) { + if (str.indexOf(b[1]) === -1) { + return -1; + } + let level = 0; + for (let i = 0; i < str.length; i++) { + if (str[i] === '\\') { + i++; + } + else if (str[i] === b[0]) { + level++; + } + else if (str[i] === b[1]) { + level--; + if (level < 0) { + return i; + } + } + } + return -1; +} + +function outputLink(cap, link, raw, lexer) { + const href = link.href; + const title = link.title ? escape$1$1(link.title) : null; + const text = cap[1].replace(/\\([\[\]])/g, '$1'); + if (cap[0].charAt(0) !== '!') { + lexer.state.inLink = true; + const token = { + type: 'link', + raw, + href, + title, + text, + tokens: lexer.inlineTokens(text) + }; + lexer.state.inLink = false; + return token; + } + return { + type: 'image', + raw, + href, + title, + text: escape$1$1(text) + }; +} +function indentCodeCompensation(raw, text) { + const matchIndentToCode = raw.match(/^(\s+)(?:```)/); + if (matchIndentToCode === null) { + return text; + } + const indentToCode = matchIndentToCode[1]; + return text + .split('\n') + .map(node => { + const matchIndentInNode = node.match(/^\s+/); + if (matchIndentInNode === null) { + return node; + } + const [indentInNode] = matchIndentInNode; + if (indentInNode.length >= indentToCode.length) { + return node.slice(indentToCode.length); + } + return node; + }) + .join('\n'); +} +/** + * Tokenizer + */ +class _Tokenizer { + options; + rules; // set by the lexer + lexer; // set by the lexer + constructor(options) { + this.options = options || _defaults; + } + space(src) { + const cap = this.rules.block.newline.exec(src); + if (cap && cap[0].length > 0) { + return { + type: 'space', + raw: cap[0] + }; + } + } + code(src) { + const cap = this.rules.block.code.exec(src); + if (cap) { + const text = cap[0].replace(/^ {1,4}/gm, ''); + return { + type: 'code', + raw: cap[0], + codeBlockStyle: 'indented', + text: !this.options.pedantic + ? rtrim(text, '\n') + : text + }; + } + } + fences(src) { + const cap = this.rules.block.fences.exec(src); + if (cap) { + const raw = cap[0]; + const text = indentCodeCompensation(raw, cap[3] || ''); + return { + type: 'code', + raw, + lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2], + text + }; + } + } + heading(src) { + const cap = this.rules.block.heading.exec(src); + if (cap) { + let text = cap[2].trim(); + // remove trailing #s + if (/#$/.test(text)) { + const trimmed = rtrim(text, '#'); + if (this.options.pedantic) { + text = trimmed.trim(); + } + else if (!trimmed || / $/.test(trimmed)) { + // CommonMark requires space before trailing #s + text = trimmed.trim(); + } + } + return { + type: 'heading', + raw: cap[0], + depth: cap[1].length, + text, + tokens: this.lexer.inline(text) + }; + } + } + hr(src) { + const cap = this.rules.block.hr.exec(src); + if (cap) { + return { + type: 'hr', + raw: cap[0] + }; + } + } + blockquote(src) { + const cap = this.rules.block.blockquote.exec(src); + if (cap) { + // precede setext continuation with 4 spaces so it isn't a setext + let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1'); + text = rtrim(text.replace(/^ *>[ \t]?/gm, ''), '\n'); + const top = this.lexer.state.top; + this.lexer.state.top = true; + const tokens = this.lexer.blockTokens(text); + this.lexer.state.top = top; + return { + type: 'blockquote', + raw: cap[0], + tokens, + text + }; + } + } + list(src) { + let cap = this.rules.block.list.exec(src); + if (cap) { + let bull = cap[1].trim(); + const isordered = bull.length > 1; + const list = { + type: 'list', + raw: '', + ordered: isordered, + start: isordered ? +bull.slice(0, -1) : '', + loose: false, + items: [] + }; + bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`; + if (this.options.pedantic) { + bull = isordered ? bull : '[*+-]'; + } + // Get next list item + const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`); + let raw = ''; + let itemContents = ''; + let endsWithBlankLine = false; + // Check if current bullet point can start a new List Item + while (src) { + let endEarly = false; + if (!(cap = itemRegex.exec(src))) { + break; + } + if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?) + break; + } + raw = cap[0]; + src = src.substring(raw.length); + let line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length)); + let nextLine = src.split('\n', 1)[0]; + let indent = 0; + if (this.options.pedantic) { + indent = 2; + itemContents = line.trimStart(); + } + else { + indent = cap[2].search(/[^ ]/); // Find first non-space char + indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent + itemContents = line.slice(indent); + indent += cap[1].length; + } + let blankLine = false; + if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line + raw += nextLine + '\n'; + src = src.substring(nextLine.length + 1); + endEarly = true; + } + if (!endEarly) { + const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`); + const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`); + const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`); + const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`); + // Check if following lines should be included in List Item + while (src) { + const rawLine = src.split('\n', 1)[0]; + nextLine = rawLine; + // Re-align to follow commonmark nesting rules + if (this.options.pedantic) { + nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' '); + } + // End list item if found code fences + if (fencesBeginRegex.test(nextLine)) { + break; + } + // End list item if found start of new heading + if (headingBeginRegex.test(nextLine)) { + break; + } + // End list item if found start of new bullet + if (nextBulletRegex.test(nextLine)) { + break; + } + // Horizontal rule found + if (hrRegex.test(src)) { + break; + } + if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible + itemContents += '\n' + nextLine.slice(indent); + } + else { + // not enough indentation + if (blankLine) { + break; + } + // paragraph continuation unless last line was a different block level element + if (line.search(/[^ ]/) >= 4) { // indented code block + break; + } + if (fencesBeginRegex.test(line)) { + break; + } + if (headingBeginRegex.test(line)) { + break; + } + if (hrRegex.test(line)) { + break; + } + itemContents += '\n' + nextLine; + } + if (!blankLine && !nextLine.trim()) { // Check if current line is blank + blankLine = true; + } + raw += rawLine + '\n'; + src = src.substring(rawLine.length + 1); + line = nextLine.slice(indent); + } + } + if (!list.loose) { + // If the previous item ended with a blank line, the list is loose + if (endsWithBlankLine) { + list.loose = true; + } + else if (/\n *\n *$/.test(raw)) { + endsWithBlankLine = true; + } + } + let istask = null; + let ischecked; + // Check for task list items + if (this.options.gfm) { + istask = /^\[[ xX]\] /.exec(itemContents); + if (istask) { + ischecked = istask[0] !== '[ ] '; + itemContents = itemContents.replace(/^\[[ xX]\] +/, ''); + } + } + list.items.push({ + type: 'list_item', + raw, + task: !!istask, + checked: ischecked, + loose: false, + text: itemContents, + tokens: [] + }); + list.raw += raw; + } + // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic + list.items[list.items.length - 1].raw = raw.trimEnd(); + (list.items[list.items.length - 1]).text = itemContents.trimEnd(); + list.raw = list.raw.trimEnd(); + // Item child tokens handled here at end because we needed to have the final item to trim it first + for (let i = 0; i < list.items.length; i++) { + this.lexer.state.top = false; + list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []); + if (!list.loose) { + // Check if list should be loose + const spacers = list.items[i].tokens.filter(t => t.type === 'space'); + const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw)); + list.loose = hasMultipleLineBreaks; + } + } + // Set all items to loose if list is loose + if (list.loose) { + for (let i = 0; i < list.items.length; i++) { + list.items[i].loose = true; + } + } + return list; + } + } + html(src) { + const cap = this.rules.block.html.exec(src); + if (cap) { + const token = { + type: 'html', + block: true, + raw: cap[0], + pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style', + text: cap[0] + }; + return token; + } + } + def(src) { + const cap = this.rules.block.def.exec(src); + if (cap) { + const tag = cap[1].toLowerCase().replace(/\s+/g, ' '); + const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline.anyPunctuation, '$1') : ''; + const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1') : cap[3]; + return { + type: 'def', + tag, + raw: cap[0], + href, + title + }; + } + } + table(src) { + const cap = this.rules.block.table.exec(src); + if (!cap) { + return; + } + if (!/[:|]/.test(cap[2])) { + // delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading + return; + } + const headers = splitCells$1(cap[1]); + const aligns = cap[2].replace(/^\||\| *$/g, '').split('|'); + const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []; + const item = { + type: 'table', + raw: cap[0], + header: [], + align: [], + rows: [] + }; + if (headers.length !== aligns.length) { + // header and align columns must be equal, rows can be different. + return; + } + for (const align of aligns) { + if (/^ *-+: *$/.test(align)) { + item.align.push('right'); + } + else if (/^ *:-+: *$/.test(align)) { + item.align.push('center'); + } + else if (/^ *:-+ *$/.test(align)) { + item.align.push('left'); + } + else { + item.align.push(null); + } + } + for (const header of headers) { + item.header.push({ + text: header, + tokens: this.lexer.inline(header) + }); + } + for (const row of rows) { + item.rows.push(splitCells$1(row, item.header.length).map(cell => { + return { + text: cell, + tokens: this.lexer.inline(cell) + }; + })); + } + return item; + } + lheading(src) { + const cap = this.rules.block.lheading.exec(src); + if (cap) { + return { + type: 'heading', + raw: cap[0], + depth: cap[2].charAt(0) === '=' ? 1 : 2, + text: cap[1], + tokens: this.lexer.inline(cap[1]) + }; + } + } + paragraph(src) { + const cap = this.rules.block.paragraph.exec(src); + if (cap) { + const text = cap[1].charAt(cap[1].length - 1) === '\n' + ? cap[1].slice(0, -1) + : cap[1]; + return { + type: 'paragraph', + raw: cap[0], + text, + tokens: this.lexer.inline(text) + }; + } + } + text(src) { + const cap = this.rules.block.text.exec(src); + if (cap) { + return { + type: 'text', + raw: cap[0], + text: cap[0], + tokens: this.lexer.inline(cap[0]) + }; + } + } + escape(src) { + const cap = this.rules.inline.escape.exec(src); + if (cap) { + return { + type: 'escape', + raw: cap[0], + text: escape$1$1(cap[1]) + }; + } + } + tag(src) { + const cap = this.rules.inline.tag.exec(src); + if (cap) { + if (!this.lexer.state.inLink && /^/i.test(cap[0])) { + this.lexer.state.inLink = false; + } + if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.lexer.state.inRawBlock = true; + } + else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.lexer.state.inRawBlock = false; + } + return { + type: 'html', + raw: cap[0], + inLink: this.lexer.state.inLink, + inRawBlock: this.lexer.state.inRawBlock, + block: false, + text: cap[0] + }; + } + } + link(src) { + const cap = this.rules.inline.link.exec(src); + if (cap) { + const trimmedUrl = cap[2].trim(); + if (!this.options.pedantic && /^$/.test(trimmedUrl))) { + return; + } + // ending angle bracket cannot be escaped + const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\'); + if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) { + return; + } + } + else { + // find closing parenthesis + const lastParenIndex = findClosingBracket(cap[2], '()'); + if (lastParenIndex > -1) { + const start = cap[0].indexOf('!') === 0 ? 5 : 4; + const linkLen = start + cap[1].length + lastParenIndex; + cap[2] = cap[2].substring(0, lastParenIndex); + cap[0] = cap[0].substring(0, linkLen).trim(); + cap[3] = ''; + } + } + let href = cap[2]; + let title = ''; + if (this.options.pedantic) { + // split pedantic href and title + const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href); + if (link) { + href = link[1]; + title = link[3]; + } + } + else { + title = cap[3] ? cap[3].slice(1, -1) : ''; + } + href = href.trim(); + if (/^$/.test(trimmedUrl))) { + // pedantic allows starting angle bracket without ending angle bracket + href = href.slice(1); + } + else { + href = href.slice(1, -1); + } + } + return outputLink(cap, { + href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href, + title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title + }, cap[0], this.lexer); + } + } + reflink(src, links) { + let cap; + if ((cap = this.rules.inline.reflink.exec(src)) + || (cap = this.rules.inline.nolink.exec(src))) { + const linkString = (cap[2] || cap[1]).replace(/\s+/g, ' '); + const link = links[linkString.toLowerCase()]; + if (!link) { + const text = cap[0].charAt(0); + return { + type: 'text', + raw: text, + text + }; + } + return outputLink(cap, link, cap[0], this.lexer); + } + } + emStrong(src, maskedSrc, prevChar = '') { + let match = this.rules.inline.emStrongLDelim.exec(src); + if (!match) + return; + // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well + if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) + return; + const nextChar = match[1] || match[2] || ''; + if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) { + // unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below) + const lLength = [...match[0]].length - 1; + let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0; + const endReg = match[0][0] === '*' ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; + endReg.lastIndex = 0; + // Clip maskedSrc to same section of string as src (move to lexer?) + maskedSrc = maskedSrc.slice(-1 * src.length + lLength); + while ((match = endReg.exec(maskedSrc)) != null) { + rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6]; + if (!rDelim) + continue; // skip single * in __abc*abc__ + rLength = [...rDelim].length; + if (match[3] || match[4]) { // found another Left Delim + delimTotal += rLength; + continue; + } + else if (match[5] || match[6]) { // either Left or Right Delim + if (lLength % 3 && !((lLength + rLength) % 3)) { + midDelimTotal += rLength; + continue; // CommonMark Emphasis Rules 9-10 + } + } + delimTotal -= rLength; + if (delimTotal > 0) + continue; // Haven't found enough closing delimiters + // Remove extra characters. *a*** -> *a* + rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal); + // char length can be >1 for unicode characters; + const lastCharLength = [...match[0]][0].length; + const raw = src.slice(0, lLength + match.index + lastCharLength + rLength); + // Create `em` if smallest delimiter has odd char count. *a*** + if (Math.min(lLength, rLength) % 2) { + const text = raw.slice(1, -1); + return { + type: 'em', + raw, + text, + tokens: this.lexer.inlineTokens(text) + }; + } + // Create 'strong' if smallest delimiter has even char count. **a*** + const text = raw.slice(2, -2); + return { + type: 'strong', + raw, + text, + tokens: this.lexer.inlineTokens(text) + }; + } + } + } + codespan(src) { + const cap = this.rules.inline.code.exec(src); + if (cap) { + let text = cap[2].replace(/\n/g, ' '); + const hasNonSpaceChars = /[^ ]/.test(text); + const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text); + if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) { + text = text.substring(1, text.length - 1); + } + text = escape$1$1(text, true); + return { + type: 'codespan', + raw: cap[0], + text + }; + } + } + br(src) { + const cap = this.rules.inline.br.exec(src); + if (cap) { + return { + type: 'br', + raw: cap[0] + }; + } + } + del(src) { + const cap = this.rules.inline.del.exec(src); + if (cap) { + return { + type: 'del', + raw: cap[0], + text: cap[2], + tokens: this.lexer.inlineTokens(cap[2]) + }; + } + } + autolink(src) { + const cap = this.rules.inline.autolink.exec(src); + if (cap) { + let text, href; + if (cap[2] === '@') { + text = escape$1$1(cap[1]); + href = 'mailto:' + text; + } + else { + text = escape$1$1(cap[1]); + href = text; + } + return { + type: 'link', + raw: cap[0], + text, + href, + tokens: [ + { + type: 'text', + raw: text, + text + } + ] + }; + } + } + url(src) { + let cap; + if (cap = this.rules.inline.url.exec(src)) { + let text, href; + if (cap[2] === '@') { + text = escape$1$1(cap[0]); + href = 'mailto:' + text; + } + else { + // do extended autolink path validation + let prevCapZero; + do { + prevCapZero = cap[0]; + cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? ''; + } while (prevCapZero !== cap[0]); + text = escape$1$1(cap[0]); + if (cap[1] === 'www.') { + href = 'http://' + cap[0]; + } + else { + href = cap[0]; + } + } + return { + type: 'link', + raw: cap[0], + text, + href, + tokens: [ + { + type: 'text', + raw: text, + text + } + ] + }; + } + } + inlineText(src) { + const cap = this.rules.inline.text.exec(src); + if (cap) { + let text; + if (this.lexer.state.inRawBlock) { + text = cap[0]; + } + else { + text = escape$1$1(cap[0]); + } + return { + type: 'text', + raw: cap[0], + text + }; + } + } +} + +/** + * Block-Level Grammar + */ +const newline = /^(?: *(?:\n|$))+/; +const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/; +const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; +const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; +const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; +const bullet = /(?:[*+-]|\d{1,9}[.)])/; +const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/) + .replace(/bull/g, bullet) // lists can interrupt + .replace(/blockCode/g, / {4}/) // indented code blocks can interrupt + .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt + .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt + .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt + .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt + .getRegex(); +const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/; +const blockText = /^[^\n]+/; +const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/; +const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/) + .replace('label', _blockLabel) + .replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/) + .getRegex(); +const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/) + .replace(/bull/g, bullet) + .getRegex(); +const _tag = 'address|article|aside|base|basefont|blockquote|body|caption' + + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + + '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title' + + '|tr|track|ul'; +const _comment = /|$))/; +const html$2 = edit('^ {0,3}(?:' // optional indentation + + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)' // (1) + + '|comment[^\\n]*(\\n+|$)' // (2) + + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3) + + '|\\n*|$)' // (4) + + '|\\n*|$)' // (5) + + '|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6) + + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag + + '|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag + + ')', 'i') + .replace('comment', _comment) + .replace('tag', _tag) + .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/) + .getRegex(); +const paragraph = edit(_paragraph) + .replace('hr', hr) + .replace('heading', ' {0,3}#{1,6}(?:\\s|$)') + .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs + .replace('|table', '') + .replace('blockquote', ' {0,3}>') + .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') + .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt + .replace('html', ')|<(?:script|pre|style|textarea|!--)') + .replace('tag', _tag) // pars can be interrupted by type (6) html blocks + .getRegex(); +const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/) + .replace('paragraph', paragraph) + .getRegex(); +/** + * Normal Block Grammar + */ +const blockNormal = { + blockquote, + code: blockCode, + def, + fences, + heading, + hr, + html: html$2, + lheading, + list, + newline, + paragraph, + table: noopTest, + text: blockText +}; +/** + * GFM Block Grammar + */ +const gfmTable = edit('^ *([^\\n ].*)\\n' // Header + + ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align + + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)') // Cells + .replace('hr', hr) + .replace('heading', ' {0,3}#{1,6}(?:\\s|$)') + .replace('blockquote', ' {0,3}>') + .replace('code', ' {4}[^\\n]') + .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') + .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt + .replace('html', ')|<(?:script|pre|style|textarea|!--)') + .replace('tag', _tag) // tables can be interrupted by type (6) html blocks + .getRegex(); +const blockGfm = { + ...blockNormal, + table: gfmTable, + paragraph: edit(_paragraph) + .replace('hr', hr) + .replace('heading', ' {0,3}#{1,6}(?:\\s|$)') + .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs + .replace('table', gfmTable) // interrupt paragraphs with table + .replace('blockquote', ' {0,3}>') + .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') + .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt + .replace('html', ')|<(?:script|pre|style|textarea|!--)') + .replace('tag', _tag) // pars can be interrupted by type (6) html blocks + .getRegex() +}; +/** + * Pedantic grammar (original John Gruber's loose markdown specification) + */ +const blockPedantic = { + ...blockNormal, + html: edit('^ *(?:comment *(?:\\n|\\s*$)' + + '|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)' // closed tag + + '|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))') + .replace('comment', _comment) + .replace(/tag/g, '(?!(?:' + + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b') + .getRegex(), + def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, + heading: /^(#{1,6})(.*)(?:\n+|$)/, + fences: noopTest, // fences not supported + lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, + paragraph: edit(_paragraph) + .replace('hr', hr) + .replace('heading', ' *#{1,6} *[^\n]') + .replace('lheading', lheading) + .replace('|table', '') + .replace('blockquote', ' {0,3}>') + .replace('|fences', '') + .replace('|list', '') + .replace('|html', '') + .replace('|tag', '') + .getRegex() +}; +/** + * Inline-Level Grammar + */ +const escape$2 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/; +const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/; +const br = /^( {2,}|\\)\n(?!\s*$)/; +const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\ +const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g; +const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u') + .replace(/punct/g, _punctuation) + .getRegex(); +const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong + + '|[^*]+(?=[^*])' // Consume to delim + + '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter + + '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter + + '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter + + '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter + + '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter + + '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter + .replace(/punct/g, _punctuation) + .getRegex(); +// (6) Not allowed for _ +const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong + + '|[^_]+(?=[^_])' // Consume to delim + + '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter + + '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter + + '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter + + '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter + + '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter + .replace(/punct/g, _punctuation) + .getRegex(); +const anyPunctuation = edit(/\\([punct])/, 'gu') + .replace(/punct/g, _punctuation) + .getRegex(); +const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/) + .replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/) + .replace('email', /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/) + .getRegex(); +const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex(); +const tag = edit('^comment' + + '|^' // self-closing tag + + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag + + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. + + '|^' // declaration, e.g. + + '|^') // CDATA section + .replace('comment', _inlineComment) + .replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/) + .getRegex(); +const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/; +const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/) + .replace('label', _inlineLabel) + .replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/) + .replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/) + .getRegex(); +const reflink = edit(/^!?\[(label)\]\[(ref)\]/) + .replace('label', _inlineLabel) + .replace('ref', _blockLabel) + .getRegex(); +const nolink = edit(/^!?\[(ref)\](?:\[\])?/) + .replace('ref', _blockLabel) + .getRegex(); +const reflinkSearch = edit('reflink|nolink(?!\\()', 'g') + .replace('reflink', reflink) + .replace('nolink', nolink) + .getRegex(); +/** + * Normal Inline Grammar + */ +const inlineNormal = { + _backpedal: noopTest, // only used for GFM url + anyPunctuation, + autolink, + blockSkip, + br, + code: inlineCode, + del: noopTest, + emStrongLDelim, + emStrongRDelimAst, + emStrongRDelimUnd, + escape: escape$2, + link, + nolink, + punctuation, + reflink, + reflinkSearch, + tag, + text: inlineText, + url: noopTest +}; +/** + * Pedantic Inline Grammar + */ +const inlinePedantic = { + ...inlineNormal, + link: edit(/^!?\[(label)\]\((.*?)\)/) + .replace('label', _inlineLabel) + .getRegex(), + reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/) + .replace('label', _inlineLabel) + .getRegex() +}; +/** + * GFM Inline Grammar + */ +const inlineGfm = { + ...inlineNormal, + escape: edit(escape$2).replace('])', '~|])').getRegex(), + url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i') + .replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/) + .getRegex(), + _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, + del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/, + text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\ { + return leading + ' '.repeat(tabs.length); + }); + } + let token; + let lastToken; + let cutSrc; + let lastParagraphClipped; + while (src) { + if (this.options.extensions + && this.options.extensions.block + && this.options.extensions.block.some((extTokenizer) => { + if (token = extTokenizer.call({ lexer: this }, src, tokens)) { + src = src.substring(token.raw.length); + tokens.push(token); + return true; + } + return false; + })) { + continue; + } + // newline + if (token = this.tokenizer.space(src)) { + src = src.substring(token.raw.length); + if (token.raw.length === 1 && tokens.length > 0) { + // if there's a single \n as a spacer, it's terminating the last line, + // so move it there so that we don't get unnecessary paragraph tags + tokens[tokens.length - 1].raw += '\n'; + } + else { + tokens.push(token); + } + continue; + } + // code + if (token = this.tokenizer.code(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + // An indented code block cannot interrupt a paragraph. + if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.text; + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else { + tokens.push(token); + } + continue; + } + // fences + if (token = this.tokenizer.fences(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // heading + if (token = this.tokenizer.heading(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // hr + if (token = this.tokenizer.hr(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // blockquote + if (token = this.tokenizer.blockquote(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // list + if (token = this.tokenizer.list(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // html + if (token = this.tokenizer.html(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // def + if (token = this.tokenizer.def(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.raw; + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else if (!this.tokens.links[token.tag]) { + this.tokens.links[token.tag] = { + href: token.href, + title: token.title + }; + } + continue; + } + // table (gfm) + if (token = this.tokenizer.table(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // lheading + if (token = this.tokenizer.lheading(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // top-level paragraph + // prevent paragraph consuming extensions by clipping 'src' to extension start + cutSrc = src; + if (this.options.extensions && this.options.extensions.startBlock) { + let startIndex = Infinity; + const tempSrc = src.slice(1); + let tempStart; + this.options.extensions.startBlock.forEach((getStartIndex) => { + tempStart = getStartIndex.call({ lexer: this }, tempSrc); + if (typeof tempStart === 'number' && tempStart >= 0) { + startIndex = Math.min(startIndex, tempStart); + } + }); + if (startIndex < Infinity && startIndex >= 0) { + cutSrc = src.substring(0, startIndex + 1); + } + } + if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) { + lastToken = tokens[tokens.length - 1]; + if (lastParagraphClipped && lastToken.type === 'paragraph') { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.text; + this.inlineQueue.pop(); + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else { + tokens.push(token); + } + lastParagraphClipped = (cutSrc.length !== src.length); + src = src.substring(token.raw.length); + continue; + } + // text + if (token = this.tokenizer.text(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && lastToken.type === 'text') { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.text; + this.inlineQueue.pop(); + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else { + tokens.push(token); + } + continue; + } + if (src) { + const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0); + if (this.options.silent) { + console.error(errMsg); + break; + } + else { + throw new Error(errMsg); + } + } + } + this.state.top = true; + return tokens; + } + inline(src, tokens = []) { + this.inlineQueue.push({ src, tokens }); + return tokens; + } + /** + * Lexing/Compiling + */ + inlineTokens(src, tokens = []) { + let token, lastToken, cutSrc; + // String with links masked to avoid interference with em and strong + let maskedSrc = src; + let match; + let keepPrevChar, prevChar; + // Mask out reflinks + if (this.tokens.links) { + const links = Object.keys(this.tokens.links); + if (links.length > 0) { + while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) { + if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) { + maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex); + } + } + } + } + // Mask out other blocks + while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) { + maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); + } + // Mask out escaped characters + while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) { + maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); + } + while (src) { + if (!keepPrevChar) { + prevChar = ''; + } + keepPrevChar = false; + // extensions + if (this.options.extensions + && this.options.extensions.inline + && this.options.extensions.inline.some((extTokenizer) => { + if (token = extTokenizer.call({ lexer: this }, src, tokens)) { + src = src.substring(token.raw.length); + tokens.push(token); + return true; + } + return false; + })) { + continue; + } + // escape + if (token = this.tokenizer.escape(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // tag + if (token = this.tokenizer.tag(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && token.type === 'text' && lastToken.type === 'text') { + lastToken.raw += token.raw; + lastToken.text += token.text; + } + else { + tokens.push(token); + } + continue; + } + // link + if (token = this.tokenizer.link(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // reflink, nolink + if (token = this.tokenizer.reflink(src, this.tokens.links)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && token.type === 'text' && lastToken.type === 'text') { + lastToken.raw += token.raw; + lastToken.text += token.text; + } + else { + tokens.push(token); + } + continue; + } + // em & strong + if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // code + if (token = this.tokenizer.codespan(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // br + if (token = this.tokenizer.br(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // del (gfm) + if (token = this.tokenizer.del(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // autolink + if (token = this.tokenizer.autolink(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // url (gfm) + if (!this.state.inLink && (token = this.tokenizer.url(src))) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // text + // prevent inlineText consuming extensions by clipping 'src' to extension start + cutSrc = src; + if (this.options.extensions && this.options.extensions.startInline) { + let startIndex = Infinity; + const tempSrc = src.slice(1); + let tempStart; + this.options.extensions.startInline.forEach((getStartIndex) => { + tempStart = getStartIndex.call({ lexer: this }, tempSrc); + if (typeof tempStart === 'number' && tempStart >= 0) { + startIndex = Math.min(startIndex, tempStart); + } + }); + if (startIndex < Infinity && startIndex >= 0) { + cutSrc = src.substring(0, startIndex + 1); + } + } + if (token = this.tokenizer.inlineText(cutSrc)) { + src = src.substring(token.raw.length); + if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started + prevChar = token.raw.slice(-1); + } + keepPrevChar = true; + lastToken = tokens[tokens.length - 1]; + if (lastToken && lastToken.type === 'text') { + lastToken.raw += token.raw; + lastToken.text += token.text; + } + else { + tokens.push(token); + } + continue; + } + if (src) { + const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0); + if (this.options.silent) { + console.error(errMsg); + break; + } + else { + throw new Error(errMsg); + } + } + } + return tokens; + } +} + +/** + * Renderer + */ +class _Renderer { + options; + constructor(options) { + this.options = options || _defaults; + } + code(code, infostring, escaped) { + const lang = (infostring || '').match(/^\S*/)?.[0]; + code = code.replace(/\n$/, '') + '\n'; + if (!lang) { + return '
'
+                + (escaped ? code : escape$1$1(code, true))
+                + '
\n'; + } + return '
'
+            + (escaped ? code : escape$1$1(code, true))
+            + '
\n'; + } + blockquote(quote) { + return `
\n${quote}
\n`; + } + html(html, block) { + return html; + } + heading(text, level, raw) { + // ignore IDs + return `${text}\n`; + } + hr() { + return '
\n'; + } + list(body, ordered, start) { + const type = ordered ? 'ol' : 'ul'; + const startatt = (ordered && start !== 1) ? (' start="' + start + '"') : ''; + return '<' + type + startatt + '>\n' + body + '\n'; + } + listitem(text, task, checked) { + return `
  • ${text}
  • \n`; + } + checkbox(checked) { + return ''; + } + paragraph(text) { + return `

    ${text}

    \n`; + } + table(header, body) { + if (body) + body = `${body}`; + return '\n' + + '\n' + + header + + '\n' + + body + + '
    \n'; + } + tablerow(content) { + return `\n${content}\n`; + } + tablecell(content, flags) { + const type = flags.header ? 'th' : 'td'; + const tag = flags.align + ? `<${type} align="${flags.align}">` + : `<${type}>`; + return tag + content + `\n`; + } + /** + * span level renderer + */ + strong(text) { + return `${text}`; + } + em(text) { + return `${text}`; + } + codespan(text) { + return `${text}`; + } + br() { + return '
    '; + } + del(text) { + return `${text}`; + } + link(href, title, text) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; + } + href = cleanHref; + let out = '
    '; + return out; + } + image(href, title, text) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; + } + href = cleanHref; + let out = `${text} 0 && item.tokens[0].type === 'paragraph') { + item.tokens[0].text = checkbox + ' ' + item.tokens[0].text; + if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') { + item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text; + } + } + else { + item.tokens.unshift({ + type: 'text', + text: checkbox + ' ' + }); + } + } + else { + itemBody += checkbox + ' '; + } + } + itemBody += this.parse(item.tokens, loose); + body += this.renderer.listitem(itemBody, task, !!checked); + } + out += this.renderer.list(body, ordered, start); + continue; + } + case 'html': { + const htmlToken = token; + out += this.renderer.html(htmlToken.text, htmlToken.block); + continue; + } + case 'paragraph': { + const paragraphToken = token; + out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens)); + continue; + } + case 'text': { + let textToken = token; + let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text; + while (i + 1 < tokens.length && tokens[i + 1].type === 'text') { + textToken = tokens[++i]; + body += '\n' + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text); + } + out += top ? this.renderer.paragraph(body) : body; + continue; + } + default: { + const errMsg = 'Token with "' + token.type + '" type was not found.'; + if (this.options.silent) { + console.error(errMsg); + return ''; + } + else { + throw new Error(errMsg); + } + } + } + } + return out; + } + /** + * Parse Inline Tokens + */ + parseInline(tokens, renderer) { + renderer = renderer || this.renderer; + let out = ''; + for (let i = 0; i < tokens.length; i++) { + const token = tokens[i]; + // Run any renderer extensions + if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) { + const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token); + if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) { + out += ret || ''; + continue; + } + } + switch (token.type) { + case 'escape': { + const escapeToken = token; + out += renderer.text(escapeToken.text); + break; + } + case 'html': { + const tagToken = token; + out += renderer.html(tagToken.text); + break; + } + case 'link': { + const linkToken = token; + out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer)); + break; + } + case 'image': { + const imageToken = token; + out += renderer.image(imageToken.href, imageToken.title, imageToken.text); + break; + } + case 'strong': { + const strongToken = token; + out += renderer.strong(this.parseInline(strongToken.tokens, renderer)); + break; + } + case 'em': { + const emToken = token; + out += renderer.em(this.parseInline(emToken.tokens, renderer)); + break; + } + case 'codespan': { + const codespanToken = token; + out += renderer.codespan(codespanToken.text); + break; + } + case 'br': { + out += renderer.br(); + break; + } + case 'del': { + const delToken = token; + out += renderer.del(this.parseInline(delToken.tokens, renderer)); + break; + } + case 'text': { + const textToken = token; + out += renderer.text(textToken.text); + break; + } + default: { + const errMsg = 'Token with "' + token.type + '" type was not found.'; + if (this.options.silent) { + console.error(errMsg); + return ''; + } + else { + throw new Error(errMsg); + } + } + } + } + return out; + } +} + +class _Hooks { + options; + constructor(options) { + this.options = options || _defaults; + } + static passThroughHooks = new Set([ + 'preprocess', + 'postprocess', + 'processAllTokens' + ]); + /** + * Process markdown before marked + */ + preprocess(markdown) { + return markdown; + } + /** + * Process HTML after marked is finished + */ + postprocess(html) { + return html; + } + /** + * Process all tokens before walk tokens + */ + processAllTokens(tokens) { + return tokens; + } +} + +class Marked { + defaults = _getDefaults(); + options = this.setOptions; + parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse); + parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline); + Parser = _Parser; + Renderer = _Renderer; + TextRenderer = _TextRenderer; + Lexer = _Lexer; + Tokenizer = _Tokenizer; + Hooks = _Hooks; + constructor(...args) { + this.use(...args); + } + /** + * Run callback for every token + */ + walkTokens(tokens, callback) { + let values = []; + for (const token of tokens) { + values = values.concat(callback.call(this, token)); + switch (token.type) { + case 'table': { + const tableToken = token; + for (const cell of tableToken.header) { + values = values.concat(this.walkTokens(cell.tokens, callback)); + } + for (const row of tableToken.rows) { + for (const cell of row) { + values = values.concat(this.walkTokens(cell.tokens, callback)); + } + } + break; + } + case 'list': { + const listToken = token; + values = values.concat(this.walkTokens(listToken.items, callback)); + break; + } + default: { + const genericToken = token; + if (this.defaults.extensions?.childTokens?.[genericToken.type]) { + this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => { + const tokens = genericToken[childTokens].flat(Infinity); + values = values.concat(this.walkTokens(tokens, callback)); + }); + } + else if (genericToken.tokens) { + values = values.concat(this.walkTokens(genericToken.tokens, callback)); + } + } + } + } + return values; + } + use(...args) { + const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} }; + args.forEach((pack) => { + // copy options to new object + const opts = { ...pack }; + // set async to true if it was set to true before + opts.async = this.defaults.async || opts.async || false; + // ==-- Parse "addon" extensions --== // + if (pack.extensions) { + pack.extensions.forEach((ext) => { + if (!ext.name) { + throw new Error('extension name required'); + } + if ('renderer' in ext) { // Renderer extensions + const prevRenderer = extensions.renderers[ext.name]; + if (prevRenderer) { + // Replace extension with func to run new extension but fall back if false + extensions.renderers[ext.name] = function (...args) { + let ret = ext.renderer.apply(this, args); + if (ret === false) { + ret = prevRenderer.apply(this, args); + } + return ret; + }; + } + else { + extensions.renderers[ext.name] = ext.renderer; + } + } + if ('tokenizer' in ext) { // Tokenizer Extensions + if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) { + throw new Error("extension level must be 'block' or 'inline'"); + } + const extLevel = extensions[ext.level]; + if (extLevel) { + extLevel.unshift(ext.tokenizer); + } + else { + extensions[ext.level] = [ext.tokenizer]; + } + if (ext.start) { // Function to check for start of token + if (ext.level === 'block') { + if (extensions.startBlock) { + extensions.startBlock.push(ext.start); + } + else { + extensions.startBlock = [ext.start]; + } + } + else if (ext.level === 'inline') { + if (extensions.startInline) { + extensions.startInline.push(ext.start); + } + else { + extensions.startInline = [ext.start]; + } + } + } + } + if ('childTokens' in ext && ext.childTokens) { // Child tokens to be visited by walkTokens + extensions.childTokens[ext.name] = ext.childTokens; + } + }); + opts.extensions = extensions; + } + // ==-- Parse "overwrite" extensions --== // + if (pack.renderer) { + const renderer = this.defaults.renderer || new _Renderer(this.defaults); + for (const prop in pack.renderer) { + if (!(prop in renderer)) { + throw new Error(`renderer '${prop}' does not exist`); + } + if (prop === 'options') { + // ignore options property + continue; + } + const rendererProp = prop; + const rendererFunc = pack.renderer[rendererProp]; + const prevRenderer = renderer[rendererProp]; + // Replace renderer with func to run extension, but fall back if false + renderer[rendererProp] = (...args) => { + let ret = rendererFunc.apply(renderer, args); + if (ret === false) { + ret = prevRenderer.apply(renderer, args); + } + return ret || ''; + }; + } + opts.renderer = renderer; + } + if (pack.tokenizer) { + const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults); + for (const prop in pack.tokenizer) { + if (!(prop in tokenizer)) { + throw new Error(`tokenizer '${prop}' does not exist`); + } + if (['options', 'rules', 'lexer'].includes(prop)) { + // ignore options, rules, and lexer properties + continue; + } + const tokenizerProp = prop; + const tokenizerFunc = pack.tokenizer[tokenizerProp]; + const prevTokenizer = tokenizer[tokenizerProp]; + // Replace tokenizer with func to run extension, but fall back if false + // @ts-expect-error cannot type tokenizer function dynamically + tokenizer[tokenizerProp] = (...args) => { + let ret = tokenizerFunc.apply(tokenizer, args); + if (ret === false) { + ret = prevTokenizer.apply(tokenizer, args); + } + return ret; + }; + } + opts.tokenizer = tokenizer; + } + // ==-- Parse Hooks extensions --== // + if (pack.hooks) { + const hooks = this.defaults.hooks || new _Hooks(); + for (const prop in pack.hooks) { + if (!(prop in hooks)) { + throw new Error(`hook '${prop}' does not exist`); + } + if (prop === 'options') { + // ignore options property + continue; + } + const hooksProp = prop; + const hooksFunc = pack.hooks[hooksProp]; + const prevHook = hooks[hooksProp]; + if (_Hooks.passThroughHooks.has(prop)) { + // @ts-expect-error cannot type hook function dynamically + hooks[hooksProp] = (arg) => { + if (this.defaults.async) { + return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => { + return prevHook.call(hooks, ret); + }); + } + const ret = hooksFunc.call(hooks, arg); + return prevHook.call(hooks, ret); + }; + } + else { + // @ts-expect-error cannot type hook function dynamically + hooks[hooksProp] = (...args) => { + let ret = hooksFunc.apply(hooks, args); + if (ret === false) { + ret = prevHook.apply(hooks, args); + } + return ret; + }; + } + } + opts.hooks = hooks; + } + // ==-- Parse WalkTokens extensions --== // + if (pack.walkTokens) { + const walkTokens = this.defaults.walkTokens; + const packWalktokens = pack.walkTokens; + opts.walkTokens = function (token) { + let values = []; + values.push(packWalktokens.call(this, token)); + if (walkTokens) { + values = values.concat(walkTokens.call(this, token)); + } + return values; + }; + } + this.defaults = { ...this.defaults, ...opts }; + }); + return this; + } + setOptions(opt) { + this.defaults = { ...this.defaults, ...opt }; + return this; + } + lexer(src, options) { + return _Lexer.lex(src, options ?? this.defaults); + } + parser(tokens, options) { + return _Parser.parse(tokens, options ?? this.defaults); + } + #parseMarkdown(lexer, parser) { + return (src, options) => { + const origOpt = { ...options }; + const opt = { ...this.defaults, ...origOpt }; + // Show warning if an extension set async to true but the parse was called with async: false + if (this.defaults.async === true && origOpt.async === false) { + if (!opt.silent) { + console.warn('marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.'); + } + opt.async = true; + } + const throwError = this.#onError(!!opt.silent, !!opt.async); + // throw error in case of non string input + if (typeof src === 'undefined' || src === null) { + return throwError(new Error('marked(): input parameter is undefined or null')); + } + if (typeof src !== 'string') { + return throwError(new Error('marked(): input parameter is of type ' + + Object.prototype.toString.call(src) + ', string expected')); + } + if (opt.hooks) { + opt.hooks.options = opt; + } + if (opt.async) { + return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src) + .then(src => lexer(src, opt)) + .then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens) + .then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens) + .then(tokens => parser(tokens, opt)) + .then(html => opt.hooks ? opt.hooks.postprocess(html) : html) + .catch(throwError); + } + try { + if (opt.hooks) { + src = opt.hooks.preprocess(src); + } + let tokens = lexer(src, opt); + if (opt.hooks) { + tokens = opt.hooks.processAllTokens(tokens); + } + if (opt.walkTokens) { + this.walkTokens(tokens, opt.walkTokens); + } + let html = parser(tokens, opt); + if (opt.hooks) { + html = opt.hooks.postprocess(html); + } + return html; + } + catch (e) { + return throwError(e); + } + }; + } + #onError(silent, async) { + return (e) => { + e.message += '\nPlease report this to https://github.com/markedjs/marked.'; + if (silent) { + const msg = '

    An error occurred:

    '
    +                    + escape$1$1(e.message + '', true)
    +                    + '
    '; + if (async) { + return Promise.resolve(msg); + } + return msg; + } + if (async) { + return Promise.reject(e); + } + throw e; + }; + } +} + +const markedInstance = new Marked(); +function marked(src, opt) { + return markedInstance.parse(src, opt); +} +/** + * Sets the default options. + * + * @param options Hash of options + */ +marked.options = + marked.setOptions = function (options) { + markedInstance.setOptions(options); + marked.defaults = markedInstance.defaults; + changeDefaults(marked.defaults); + return marked; + }; +/** + * Gets the original marked default options. + */ +marked.getDefaults = _getDefaults; +marked.defaults = _defaults; +/** + * Use Extension + */ +marked.use = function (...args) { + markedInstance.use(...args); + marked.defaults = markedInstance.defaults; + changeDefaults(marked.defaults); + return marked; +}; +/** + * Run callback for every token + */ +marked.walkTokens = function (tokens, callback) { + return markedInstance.walkTokens(tokens, callback); +}; +/** + * Compiles markdown to HTML without enclosing `p` tag. + * + * @param src String of markdown source to be compiled + * @param options Hash of options + * @return String of compiled HTML + */ +marked.parseInline = markedInstance.parseInline; +/** + * Expose + */ +marked.Parser = _Parser; +marked.parser = _Parser.parse; +marked.Renderer = _Renderer; +marked.TextRenderer = _TextRenderer; +marked.Lexer = _Lexer; +marked.lexer = _Lexer.lex; +marked.Tokenizer = _Tokenizer; +marked.Hooks = _Hooks; +marked.parse = marked; +marked.options; +marked.setOptions; +marked.use; +marked.walkTokens; +marked.parseInline; +_Parser.parse; +_Lexer.lex; + +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // The + prefix indicates that these fields aren't writeable + // Lexer holding the input string. + // Start offset, zero-based inclusive. + // End offset, zero-based exclusive. + constructor(lexer, start, end) { + this.lexer = void 0; + this.start = void 0; + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + + + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } + +} + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // don't expand the token + // used in \noexpand + constructor(text, // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + + + range(endToken, // last token of the range, inclusive + text // the text of the newly constructed token + ) { + return new Token(text, SourceLocation.range(this, endToken)); + } + +} + +/** + * This is the ParseError class, which is the main error thrown by KaTeX + * functions when something has gone wrong. This is used to distinguish internal + * errors from errors in the expression that the user provided. + * + * If possible, a caller should provide a Token or ParseNode with information + * about where in the source string the problem occurred. + */ +class ParseError { + // Error start position based on passed-in Token or ParseNode. + // Length of affected text based on passed-in Token or ParseNode. + // The underlying error message without any context added. + constructor(message, // The error message + token // An object providing position information + ) { + this.name = void 0; + this.position = void 0; + this.length = void 0; + this.rawMessage = void 0; + var error = "KaTeX parse error: " + message; + var start; + var end; + var loc = token && token.loc; + + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + // Get the input + var input = loc.lexer.input; // Prepend some information + + start = loc.start; + end = loc.end; + + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } // Underline token in question using combining underscores + + + var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error + + var left; + + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + + var right; + + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + + error += left + underlined + right; + } // Some hackery to make ParseError a prototype of Error + // See http://stackoverflow.com/a/8460753 + // $FlowFixMe + + + var self = new Error(error); + self.name = "ParseError"; // $FlowFixMe + + self.__proto__ = ParseError.prototype; + self.position = start; + + if (start != null && end != null) { + self.length = end - start; + } + + self.rawMessage = message; + return self; + } + +} // $FlowFixMe More hackery + + +ParseError.prototype.__proto__ = Error.prototype; + +/** + * This file contains a list of utility functions which are useful in other + * files. + */ + +/** + * Return whether an element is contained in a list + */ +var contains = function contains(list, elem) { + return list.indexOf(elem) !== -1; +}; +/** + * Provide a default value if a setting is undefined + * NOTE: Couldn't use `T` as the output type due to facebook/flow#5022. + */ + + +var deflt = function deflt(setting, defaultIfUndefined) { + return setting === undefined ? defaultIfUndefined : setting; +}; // hyphenate and escape adapted from Facebook's React under Apache 2 license + + +var uppercase = /([A-Z])/g; + +var hyphenate = function hyphenate(str) { + return str.replace(uppercase, "-$1").toLowerCase(); +}; + +var ESCAPE_LOOKUP = { + "&": "&", + ">": ">", + "<": "<", + "\"": """, + "'": "'" +}; +var ESCAPE_REGEX = /[&><"']/g; +/** + * Escapes text to prevent scripting attacks. + */ + +function escape$1(text) { + return String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); +} +/** + * Sometimes we want to pull out the innermost element of a group. In most + * cases, this will just be the group itself, but when ordgroups and colors have + * a single element, we want to pull that out. + */ + + +var getBaseElem = function getBaseElem(group) { + if (group.type === "ordgroup") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "color") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "font") { + return getBaseElem(group.body); + } else { + return group; + } +}; +/** + * TeXbook algorithms often reference "character boxes", which are simply groups + * with a single character in them. To decide if something is a character box, + * we find its innermost group, and see if it is a single character. + */ + + +var isCharacterBox = function isCharacterBox(group) { + var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters + + return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "atom"; +}; + +var assert = function assert(value) { + if (!value) { + throw new Error('Expected non-null, but got ' + String(value)); + } + + return value; +}; +/** + * Return the protocol of a URL, or "_relative" if the URL does not specify a + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). + */ + +var protocolFromUrl = function protocolFromUrl(url) { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + // eslint-disable-next-line no-control-regex + var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + + if (!protocol) { + return "_relative"; + } // Reject weird colons + + + if (protocol[2] !== ":") { + return null; + } // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + + + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } // Lowercase the protocol + + + return protocol[1].toLowerCase(); +}; +var utils$1 = { + contains, + deflt, + escape: escape$1, + hyphenate, + getBaseElem, + isCharacterBox, + protocolFromUrl +}; + +/* eslint no-console:0 */ +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +var SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; + +function getDefaultValue(schema) { + if (schema.default) { + return schema.default; + } + + var type = schema.type; + var defaultType = Array.isArray(type) ? type[0] : type; + + if (typeof defaultType !== 'string') { + return defaultType.enum[0]; + } + + switch (defaultType) { + case 'boolean': + return false; + + case 'string': + return ''; + + case 'number': + return 0; + + case 'object': + return {}; + } +} +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ + + +class Settings { + constructor(options) { + this.displayMode = void 0; + this.output = void 0; + this.leqno = void 0; + this.fleqn = void 0; + this.throwOnError = void 0; + this.errorColor = void 0; + this.macros = void 0; + this.minRuleThickness = void 0; + this.colorIsTextColor = void 0; + this.strict = void 0; + this.trust = void 0; + this.maxSize = void 0; + this.maxExpand = void 0; + this.globalGroup = void 0; + // allow null options + options = options || {}; + + for (var prop in SETTINGS_SCHEMA) { + if (SETTINGS_SCHEMA.hasOwnProperty(prop)) { + // $FlowFixMe + var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options + // $FlowFixMe + + this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema); + } + } + } + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + + + reportNonstrict(errorCode, errorMsg, token) { + var strict = this.strict; + + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + } + } + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + + + useStrictBehavior(errorCode, errorMsg, token) { + var strict = this.strict; + + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + return false; + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + return false; + } + } + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + + + isTrusted(context) { + if (context.url && !context.protocol) { + var protocol = utils$1.protocolFromUrl(context.url); + + if (protocol == null) { + return false; + } + + context.protocol = protocol; + } + + var trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } + +} + +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ + +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +class Style { + constructor(id, size, cramped) { + this.id = void 0; + this.size = void 0; + this.cramped = void 0; + this.id = id; + this.size = size; + this.cramped = cramped; + } + /** + * Get the style of a superscript given a base in the current style. + */ + + + sup() { + return styles[sup[this.id]]; + } + /** + * Get the style of a subscript given a base in the current style. + */ + + + sub() { + return styles[sub[this.id]]; + } + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + + + fracNum() { + return styles[fracNum[this.id]]; + } + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + + + fracDen() { + return styles[fracDen[this.id]]; + } + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + + + cramp() { + return styles[cramp[this.id]]; + } + /** + * Get a text or display version of this style. + */ + + + text() { + return styles[text$1[this.id]]; + } + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + + + isTight() { + return this.size >= 2; + } + +} // Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. + + +// IDs of the different styles +var D = 0; +var Dc = 1; +var T = 2; +var Tc = 3; +var S = 4; +var Sc = 5; +var SS = 6; +var SSc = 7; // Instances of the different styles + +var styles = [new Style(D, 0, false), new Style(Dc, 0, true), new Style(T, 1, false), new Style(Tc, 1, true), new Style(S, 2, false), new Style(Sc, 2, true), new Style(SS, 3, false), new Style(SSc, 3, true)]; // Lookup tables for switching from one style to another + +var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +var text$1 = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. + +var Style$1 = { + DISPLAY: styles[D], + TEXT: styles[T], + SCRIPT: styles[S], + SCRIPTSCRIPT: styles[SS] +}; + +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ + +/** + * Each script or script family has a name and an array of blocks. + * Each block is an array of two numbers which specify the start and + * end points (inclusive) of a block of Unicode codepoints. + */ + +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +var scriptData = [{ + // Latin characters beyond the Latin-1 characters we have metrics for. + // Needed for Czech, Hungarian and Turkish text, for example. + name: 'latin', + blocks: [[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B + [0x0300, 0x036f] // Combining Diacritical marks + ] +}, { + // The Cyrillic script used by Russian and related languages. + // A Cyrillic subset used to be supported as explicitly defined + // symbols in symbols.js + name: 'cyrillic', + blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] +}, { + // The Brahmic scripts of South and Southeast Asia + // Devanagari (0900–097F) + // Bengali (0980–09FF) + // Gurmukhi (0A00–0A7F) + // Gujarati (0A80–0AFF) + // Oriya (0B00–0B7F) + // Tamil (0B80–0BFF) + // Telugu (0C00–0C7F) + // Kannada (0C80–0CFF) + // Malayalam (0D00–0D7F) + // Sinhala (0D80–0DFF) + // Thai (0E00–0E7F) + // Lao (0E80–0EFF) + // Tibetan (0F00–0FFF) + // Myanmar (1000–109F) + name: 'brahmic', + blocks: [[0x0900, 0x109F]] +}, { + name: 'georgian', + blocks: [[0x10A0, 0x10ff]] +}, { + // Chinese and Japanese. + // The "k" in cjk is for Korean, but we've separated Korean out + name: "cjk", + blocks: [[0x3000, 0x30FF], // CJK symbols and punctuation, Hiragana, Katakana + [0x4E00, 0x9FAF], // CJK ideograms + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] +}, { + // Korean + name: 'hangul', + blocks: [[0xAC00, 0xD7AF]] +}]; +/** + * Given a codepoint, return the name of the script or script family + * it is from, or null if it is not part of a known block + */ + +function scriptFromCodepoint(codepoint) { + for (var i = 0; i < scriptData.length; i++) { + var script = scriptData[i]; + + for (var _i = 0; _i < script.blocks.length; _i++) { + var block = script.blocks[_i]; + + if (codepoint >= block[0] && codepoint <= block[1]) { + return script.name; + } + } + } + + return null; +} +/** + * A flattened version of all the supported blocks in a single array. + * This is an optimization to make supportedCodepoint() fast. + */ + +var allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); +/** + * Given a codepoint, return true if it falls within one of the + * scripts or script families defined above and false otherwise. + * + * Micro benchmarks shows that this is faster than + * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test() + * in Firefox, Chrome and Node. + */ + +function supportedCodepoint(codepoint) { + for (var i = 0; i < allBlocks.length; i += 2) { + if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { + return true; + } + } + + return false; +} + +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ +// In all paths below, the viewBox-to-em scale is 1000:1. +var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. + +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ + +var sqrtMain = function sqrtMain(extraVinculum, hLinePad) { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; + +var phasePath = function phasePath(y) { + var x = y / 2; // x coordinate at top of angle + + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; + +var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; +}; + +var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + + var path = ""; + + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + + return path; +}; +var innerPath = function innerPath(name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z"; + + case "\u2223": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z"; + + case "\u2225": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z" + ("M367 0 H410 V" + height + " H367z M367 0 H410 V" + height + " H367z"); + + case "\u239f": + return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z"; + + case "\u23a2": + return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z"; + + case "\u23a5": + return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z"; + + case "\u23aa": + return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z"; + + case "\u23d0": + return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z"; + + case "\u2016": + return "M257 0 H300 V" + height + " H257z M257 0 H300 V" + height + " H257z" + ("M478 0 H521 V" + height + " H478z M478 0 H521 V" + height + " H478z"); + + default: + return ""; + } +}; +var path = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", + // overgroup is from the MnSymbol package (public domain) + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z", + leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z", + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z", + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z", + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", + // ditto tilde2, tilde3, & tilde4 + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", + // vec is from glyph U+20D7 in font KaTeX Main + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", + // ditto widehat2, widehat3, & widehat4 + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + // widecheck paths are all inverted versions of widehat + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + // The next ten paths support reaction arrows from the mhchem package. + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +var tallDelim = function tallDelim(label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z"; + + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; + +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +class DocumentFragment { + // HtmlDomNode + // Never used; needed for satisfying interface. + constructor(children) { + this.children = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + /** Convert the fragment into a node. */ + + + toNode() { + var frag = document.createDocumentFragment(); + + for (var i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + + return frag; + } + /** Convert the fragment into HTML markup. */ + + + toMarkup() { + var markup = ""; // Simply concatenate the markup for the children together. + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + return markup; + } + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + + + toText() { + // To avoid this, we would subclass documentFragment separately for + // MathML, but polyfills for subclassing is expensive per PR 1469. + // $FlowFixMe: Only works for ChildType = MathDomNode. + var toText = child => child.toText(); + + return this.children.map(toText).join(""); + } + +} + +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +var fontMetricsData = { + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778] + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073] + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055] + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028] + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834] + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5] + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5] + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334] + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111] + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75] + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45] + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525] + } +}; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.less; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm + +}; // This map contains a mapping from font name and character code to character +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. + +var extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ + +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + + var ch = character.charCodeAt(0); + var metrics = fontMetricsData[font][ch]; + + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +var fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ + +function getGlobalMetrics(size) { + var sizeIndex; + + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + + return fontMetricsBySizeIndex[sizeIndex]; +} + +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ +var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], // size1: [5, 5, 5] \tiny +[2, 1, 1], // size2: [6, 5, 5] +[3, 1, 1], // size3: [7, 5, 5] \scriptsize +[4, 2, 1], // size4: [8, 6, 5] \footnotesize +[5, 2, 1], // size5: [9, 6, 5] \small +[6, 3, 1], // size6: [10, 7, 5] \normalsize +[7, 4, 2], // size7: [12, 8, 6] \large +[8, 6, 3], // size8: [14.4, 10, 7] \Large +[9, 7, 6], // size9: [17.28, 12, 10] \LARGE +[10, 8, 7], // size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; + +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; // In these types, "" (empty string) means "no change". + + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + + /** + * The base size index. + */ + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ''; + this.fontShape = data.fontShape || ''; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + + + extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + + for (var key in extension) { + if (extension.hasOwnProperty(key)) { + data[key] = extension[key]; + } + } + + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + + + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + + + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + + + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + + + havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + + + havingBaseSizing() { + var size; + + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + + break; + + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + + break; + + default: + size = 6; + // normalsize in textstyle or displaystyle + } + + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + + + withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + + + withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + + + withFont(font) { + return this.extend({ + font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + + + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + + + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + + + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + + + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + + + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } + +} + +Options.BASESIZE = 6; + +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). + +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX + +}; // Dictionary of relative units, for fast validity testing. + +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ + +var calculateSize = function calculateSize(sizeValue, options) { + var scale; + + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions; + + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + + + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ + +var makeEm = function makeEm(n) { + return +n.toFixed(4) + "em"; +}; + +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +var createClass = function createClass(classes) { + return classes.filter(cls => cls).join(" "); +}; + +var initNode = function initNode(classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + + var color = options.getColor(); + + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ + + +var toNode = function toNode(tagName) { + var node = document.createElement(tagName); // Apply the class + + node.className = createClass(this.classes); // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe Flow doesn't seem to understand span.style's type. + node.style[style] = this.style[style]; + } + } // Apply attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } // Append the children, also as HTML nodes + + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; +/** + * Convert into an HTML markup string + */ + + +var toMarkup = function toMarkup(tagName) { + var markup = "<" + tagName; // Add the class + + if (this.classes.length) { + markup += " class=\"" + utils$1.escape(createClass(this.classes)) + "\""; + } + + var styles = ""; // Add the styles, after hyphenation + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils$1.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + utils$1.escape(styles) + "\""; + } // Add the attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + markup += " " + attr + "=\"" + utils$1.escape(this.attributes[attr]) + "\""; + } + } + + markup += ">"; // Add the markup of the children, also as markup + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. + + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "span"); + } + + toMarkup() { + return toMarkup.call(this, "span"); + } + +} +/** + * This node represents an anchor (
    ) element with a hyperlink. See `span` + * for further details. + */ + +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "a"); + } + + toMarkup() { + return toMarkup.call(this, "a"); + } + +} +/** + * This node represents an image embed () element. + */ + +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.style = style; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + + toNode() { + var node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe + node.style[style] = this.style[style]; + } + } + + return node; + } + + toMarkup() { + var markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. + + span.style[style] = this.style[style]; + } + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + + + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + var markup = " 0) { + styles += "margin-right:" + this.italic + "em;"; + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils$1.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + needsSpan = true; + markup += " style=\"" + utils$1.escape(styles) + "\""; + } + + var escaped = utils$1.escape(this.text); + + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } + +} +/** + * SVG nodes are used to render stretchy wide elements. + */ + +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); // Apply attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; + } + + toMarkup() { + var markup = ""; + } else { + return ""; + } + } + +} +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } + + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); // Apply attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + return node; + } + + toMarkup() { + var markup = " but got " + String(group) + "."); + } +} + +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +var ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +var NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +var symbols = { + "math": {}, + "text": {} +}; +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ + +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { + font, + group, + replace + }; + + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} // Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. +// modes: + +var math = "math"; +var text$2 = "text"; // fonts: + +var main = "main"; +var ams = "ams"; // groups: + +var accent = "accent-token"; +var bin = "bin"; +var close = "close"; +var inner = "inner"; +var mathord = "mathord"; +var op = "op-token"; +var open = "open"; +var punct = "punct"; +var rel = "rel"; +var spacing = "spacing"; +var textord = "textord"; // Now comes the symbol table +// Relation Symbols + +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); // Punctuation + +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols + +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(text$2, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(text$2, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text$2, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text$2, main, textord, "\u00b6", "\\P"); // Math and Text + +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text$2, main, textord, "\u2020", "\\dag"); +defineSymbol(text$2, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text$2, main, textord, "\u2021", "\\ddag"); +defineSymbol(text$2, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters + +defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); // Binary Operators + +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath +// Arrow Symbols + +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); // AMS Negated Binary Relations + +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceded by "@" each have a corresponding macro. + +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); // AMS Negated Arrows + +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); // AMS Misc + +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text$2, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth + +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text$2, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen + +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text$2, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text$2, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew + +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek + +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters + +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations + +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. + +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. + +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators + +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); // AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. + +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font + +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font + +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text$2, main, textord, "$", "\\$"); +defineSymbol(text$2, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text$2, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(text$2, main, textord, "_", "\\_"); +defineSymbol(text$2, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, open, "\u27e8", "\\langle", true); +defineSymbol(math, main, open, "\u2223", "\\lvert"); +defineSymbol(math, main, open, "\u2225", "\\lVert"); +defineSymbol(math, main, close, "?", "?"); +defineSymbol(math, main, close, "!", "!"); +defineSymbol(math, main, close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, close, "\u2223", "\\rvert"); +defineSymbol(math, main, close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% + +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text$2, main, spacing, "\u00a0", "\\ "); +defineSymbol(text$2, main, spacing, "\u00a0", " "); +defineSymbol(text$2, main, spacing, "\u00a0", "\\space"); +defineSymbol(text$2, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, null, "\\nobreak"); +defineSymbol(math, main, spacing, null, "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text$2, main, textord, "{", "\\{"); +defineSymbol(text$2, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text$2, main, textord, "}", "\\}"); +defineSymbol(text$2, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, open, "{", "\\lbrace"); +defineSymbol(math, main, close, "}", "\\rbrace"); +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text$2, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text$2, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text$2, main, textord, "<", "\\textless", true); // in T1 fontenc + +defineSymbol(text$2, main, textord, ">", "\\textgreater", true); // in T1 fontenc + +defineSymbol(math, main, open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, open, "\u2308", "\\lceil", true); +defineSymbol(math, main, close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text$2, main, textord, "|", "\\textbar", true); // in T1 fontenc + +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(text$2, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text$2, main, textord, "~", "\\textasciitilde"); +defineSymbol(text$2, main, textord, "\\", "\\textbackslash"); +defineSymbol(text$2, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(text$2, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text$2, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); // \vdots is a macro + +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA + +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text$2, main, textord, "\u0131", "\\i", true); +defineSymbol(text$2, main, textord, "\u0237", "\\j", true); +defineSymbol(text$2, main, textord, "\u00df", "\\ss", true); +defineSymbol(text$2, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text$2, main, textord, "\u0153", "\\oe", true); +defineSymbol(text$2, main, textord, "\u00f8", "\\o", true); +defineSymbol(text$2, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text$2, main, textord, "\u0152", "\\OE", true); +defineSymbol(text$2, main, textord, "\u00d8", "\\O", true); +defineSymbol(text$2, main, accent, "\u02ca", "\\'"); // acute + +defineSymbol(text$2, main, accent, "\u02cb", "\\`"); // grave + +defineSymbol(text$2, main, accent, "\u02c6", "\\^"); // circumflex + +defineSymbol(text$2, main, accent, "\u02dc", "\\~"); // tilde + +defineSymbol(text$2, main, accent, "\u02c9", "\\="); // macron + +defineSymbol(text$2, main, accent, "\u02d8", "\\u"); // breve + +defineSymbol(text$2, main, accent, "\u02d9", "\\."); // dot above + +defineSymbol(text$2, main, accent, "\u00b8", "\\c"); // cedilla + +defineSymbol(text$2, main, accent, "\u02da", "\\r"); // ring above + +defineSymbol(text$2, main, accent, "\u02c7", "\\v"); // caron + +defineSymbol(text$2, main, accent, "\u00a8", '\\"'); // diaresis + +defineSymbol(text$2, main, accent, "\u02dd", "\\H"); // double acute + +defineSymbol(text$2, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph +// These ligatures are detected and created in Parser.js's `formLigatures`. + +var ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(text$2, main, textord, "\u2013", "--", true); +defineSymbol(text$2, main, textord, "\u2013", "\\textendash"); +defineSymbol(text$2, main, textord, "\u2014", "---", true); +defineSymbol(text$2, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text$2, main, textord, "\u2018", "`", true); +defineSymbol(text$2, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text$2, main, textord, "\u2019", "'", true); +defineSymbol(text$2, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text$2, main, textord, "\u201c", "``", true); +defineSymbol(text$2, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text$2, main, textord, "\u201d", "''", true); +defineSymbol(text$2, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package + +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text$2, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package + +defineSymbol(text$2, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". + +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text$2, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text$2, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text$2, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode + +var mathTextSymbols = "0123456789/@.\""; + +for (var i$1 = 0; i$1 < mathTextSymbols.length; i$1++) { + var ch = mathTextSymbols.charAt(i$1); + defineSymbol(math, main, textord, ch, ch); +} // All of these are textords in text mode + + +var textSymbols = "0123456789!@*()-=+\";:?/.,"; + +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); + + defineSymbol(text$2, main, textord, _ch, _ch); +} // All of these are textords in text mode, and mathords in math mode + + +var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); + + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(text$2, main, textord, _ch2, _ch2); +} // Blackboard bold and script letters in Unicode range + + +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold + +defineSymbol(text$2, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text$2, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text$2, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text$2, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text$2, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text$2, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text$2, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant + +defineSymbol(text$2, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. + +var wideChar = ""; + +for (var _i3 = 0; _i3 < letters.length; _i3++) { + var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + + + wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fractur + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + + if (_i3 < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$2, main, textord, _ch3, wideChar); + } // TODO: Add bold script when it is supported by a KaTeX font. + +} // "k" is the only double struck lower case letter in the KaTeX fonts. + + +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck + +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text$2, main, textord, "k", wideChar); // Next, some wide character numerals + +for (var _i4 = 0; _i4 < 10; _i4++) { + var _ch4 = _i4.toString(); + + wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$2, main, textord, _ch4, wideChar); +} // We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. + + +var extraLatin = "\u00d0\u00de\u00fe"; + +for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { + var _ch5 = extraLatin.charAt(_i5); + + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(text$2, main, textord, _ch5, _ch5); +} + +/** + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. + */ +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each subarray consists three elements: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. + */ + +var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright +["mathbf", "textbf", "Main-Bold"], // a-z bold upright +["mathnormal", "textit", "Math-Italic"], // A-Z italic +["mathnormal", "textit", "Math-Italic"], // a-z italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +["mathscr", "textscr", "Script-Regular"], // A-Z script +["", "", ""], // a-z script. No font +["", "", ""], // A-Z bold script. No font +["", "", ""], // a-z bold script. No font +["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur +["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur +["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck +["mathbb", "textbb", "AMS-Regular"], // k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur +["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif +["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif +["", "", ""], // A-Z bold italic sans. No font +["", "", ""], // a-z bold italic sans. No font +["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace +["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace +]; +var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold +["", "", ""], // 0-9 double-struck. No KaTeX font. +["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif +["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace +]; +var wideCharacterFont = function wideCharacterFont(wideChar, mode) { + // IE doesn't support codePointAt(). So work with the surrogate pair. + var H = wideChar.charCodeAt(0); // high surrogate + + var L = wideChar.charCodeAt(1); // low surrogate + + var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + var j = mode === "math" ? 0 : 1; // column index for CSS class. + + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + var i = Math.floor((codePoint - 0x1D400) / 26); + return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + var _i = Math.floor((codePoint - 0x1D7CE) / 10); + + return [wideNumeralData[_i][2], wideNumeralData[_i][j]]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return ["", ""]; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new ParseError("Unsupported character: " + wideChar); + } +}; + +/* eslint no-console:0 */ + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +var lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this. +fontName, mode) { + // Replace the value with its replaced value from symbol.js + if (symbols[mode][value] && symbols[mode][value].replace) { + value = symbols[mode][value].replace; + } + + return { + value: value, + metrics: getCharacterMetrics(value, fontName, mode) + }; +}; +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ + + +var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { + var lookup = lookupSymbol(value, fontName, mode); + var metrics = lookup.metrics; + value = lookup.value; + var symbolNode; + + if (metrics) { + var italic = metrics.italic; + + if (mode === "text" || options && options.font === "mathit") { + italic = 0; + } + + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + + var color = options.getColor(); + + if (color) { + symbolNode.style.color = color; + } + } + + return symbolNode; +}; +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ + + +var mathsym = function mathsym(value, mode, options, classes) { + if (classes === void 0) { + classes = []; + } + + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + } else if (value === "\\" || symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ + + +var boldsymbol = function boldsymbol(value, mode, options, classes, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol" + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf" + }; + } +}; +/** + * Makes either a mathord or textord in the correct font and color. + */ + + +var makeOrd = function makeOrd(group, options, type) { + var mode = group.mode; + var text = group.text; + var classes = ["mord"]; // Math mode or Old font (i.e. \rm) + + var isFont = mode === "math" || mode === "text" && options.font; + var fontOrFamily = isFont ? options.font : options.fontFamily; + var wideFontName = ""; + var wideFontClass = ""; + + if (text.charCodeAt(0) === 0xD835) { + [wideFontName, wideFontClass] = wideCharacterFont(text, mode); + } + + if (wideFontName.length > 0) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + var fontName; + var fontClasses; + + if (fontOrFamily === "boldsymbol") { + var fontData = boldsymbol(text, mode, options, classes, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (isFont) { + fontName = fontMap[fontOrFamily].fontName; + fontClasses = [fontOrFamily]; + } else { + fontName = retrieveTextFontName(fontOrFamily, options.fontWeight, options.fontShape); + fontClasses = [fontOrFamily, options.fontWeight, options.fontShape]; + } + + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + var parts = []; + + for (var i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + } + + return makeFragment(parts); + } + } // Makes a symbol in the default font for mathords and textords. + + + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); + } else if (type === "textord") { + var font = symbols[mode][text] && symbols[mode][text].font; + + if (font === "ams") { + var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape); + + return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape)); + } else if (font === "main" || !font) { + var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape); + + return makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape)); + } else { + // fonts added by plugins + var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class + + + return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. + */ + + +var canCombine = (prev, next) => { + if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize) { + return false; + } // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + + + if (prev.classes.length === 1) { + var cls = prev.classes[0]; + + if (cls === "mbin" || cls === "mord") { + return false; + } + } + + for (var style in prev.style) { + if (prev.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) { + return false; + } + } + + for (var _style in next.style) { + if (next.style.hasOwnProperty(_style) && prev.style[_style] !== next.style[_style]) { + return false; + } + } + + return true; +}; +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ + + +var tryCombineChars = chars => { + for (var i = 0; i < chars.length - 1; i++) { + var prev = chars[i]; + var next = chars[i + 1]; + + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + + return chars; +}; +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ + + +var sizeElementFromChildren = function sizeElementFromChildren(elem) { + var height = 0; + var depth = 0; + var maxFontSize = 0; + + for (var i = 0; i < elem.children.length; i++) { + var child = elem.children[i]; + + if (child.height > height) { + height = child.height; + } + + if (child.depth > depth) { + depth = child.depth; + } + + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ + + +var makeSpan$2 = function makeSpan(classes, children, options, style) { + var span = new Span(classes, children, options, style); + sizeElementFromChildren(span); + return span; +}; // SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. + + +var makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); + +var makeLineSpan = function makeLineSpan(className, options, thickness) { + var line = makeSpan$2([className], [], options); + line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ + + +var makeAnchor = function makeAnchor(href, classes, children, options) { + var anchor = new Anchor(href, classes, children, options); + sizeElementFromChildren(anchor); + return anchor; +}; +/** + * Makes a document fragment with the given list of children. + */ + + +var makeFragment = function makeFragment(children) { + var fragment = new DocumentFragment(children); + sizeElementFromChildren(fragment); + return fragment; +}; +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ + + +var wrapFragment = function wrapFragment(group, options) { + if (group instanceof DocumentFragment) { + return makeSpan$2([], [group], options); + } + + return group; +}; // These are exact object types to catch typos in the names of the optional fields. + + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { + if (params.positionType === "individualShift") { + var oldChildren = params.children; + var children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + + var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + + var currPos = _depth; + + for (var i = 1; i < oldChildren.length; i++) { + var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + currPos = currPos + diff; + children.push({ + type: "kern", + size + }); + children.push(oldChildren[i]); + } + + return { + children, + depth: _depth + }; + } + + var depth; + + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + var bottom = params.positionData; + + for (var _i = 0; _i < params.children.length; _i++) { + var child = params.children[_i]; + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + var firstChild = params.children[0]; + + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } + } + + return { + children: params.children, + depth + }; +}; +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ + + +var makeVList = function makeVList(params, options) { + var { + children, + depth + } = getVListChildrenAndDepth(params); // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + + var pstrutSize = 0; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + if (child.type === "elem") { + var elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + + pstrutSize += 2; + var pstrut = makeSpan$2(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets + + var realChildren = []; + var minPos = depth; + var maxPos = depth; + var currPos = depth; + + for (var _i2 = 0; _i2 < children.length; _i2++) { + var _child = children[_i2]; + + if (_child.type === "kern") { + currPos += _child.size; + } else { + var _elem = _child.elem; + var classes = _child.wrapperClasses || []; + var style = _child.wrapperStyle || {}; + var childWrap = makeSpan$2(classes, [pstrut, _elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth); + + if (_child.marginLeft) { + childWrap.style.marginLeft = _child.marginLeft; + } + + if (_child.marginRight) { + childWrap.style.marginRight = _child.marginRight; + } + + realChildren.push(childWrap); + currPos += _elem.height + _elem.depth; + } + + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + + + var vlist = makeSpan$2(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth. + + var rows; + + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + var emptySpan = makeSpan$2([], []); + var depthStrut = makeSpan$2(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + + var topStrut = makeSpan$2(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan$2(["vlist-r"], [vlist, topStrut]), makeSpan$2(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan$2(["vlist-r"], [vlist])]; + } + + var vtable = makeSpan$2(["vlist-t"], rows); + + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; // Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. + + +var makeGlue = (measurement, options) => { + // Make an empty span for the space + var rule = makeSpan$2(["mspace"], [], options); + var size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; // Takes font options, and returns the appropriate fontLookup name + + +var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) { + var baseFontName = ""; + + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + + case "textrm": + baseFontName = "Main"; + break; + + case "textsf": + baseFontName = "SansSerif"; + break; + + case "texttt": + baseFontName = "Typewriter"; + break; + + default: + baseFontName = fontFamily; + // use fonts added by a plugin + } + + var fontStylesName; + + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontWeight === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + + return baseFontName + "-" + fontStylesName; +}; +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values + + +var fontMap = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold" + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular" + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular" + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular" + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular" + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular" + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular" + } +}; +var svgData = { + // path, width, height + vec: ["vec", 0.471, 0.714], + // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], + // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659] +}; + +var staticSvg = function staticSvg(value, options) { + // Create a span with inline SVG for the element. + var [pathName, width, height] = svgData[value]; + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin" + }); + var span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; + +var buildCommon = { + fontMap, + makeSymbol, + mathsym, + makeSpan: makeSpan$2, + makeSvgSpan, + makeLineSpan, + makeAnchor, + makeFragment, + wrapFragment, + makeVList, + makeOrd, + makeGlue, + staticSvg, + svgData, + tryCombineChars +}; + +/** + * Describes spaces between different classes of atoms. + */ +var thinspace = { + number: 3, + unit: "mu" +}; +var mediumspace = { + number: 4, + unit: "mu" +}; +var thickspace = { + number: 5, + unit: "mu" +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. + +// Spacing relationships for display and text styles +var spacings = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace + } +}; // Spacing relationships for script and scriptscript styles + +var tightSpacings = { + mord: { + mop: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace + }, + mpunct: {}, + minner: { + mop: thinspace + } +}; + +/** Context provided to function handlers for error messages. */ +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. + +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +var _functions = {}; +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + */ + +var _htmlGroupBuilders = {}; +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. + */ + +var _mathmlGroupBuilders = {}; +function defineFunction(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of functions + var data = { + type, + numArgs: props.numArgs, + argTypes: props.argTypes, + allowedInArgument: !!props.allowedInArgument, + allowedInText: !!props.allowedInText, + allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, + numOptionalArgs: props.numOptionalArgs || 0, + infix: !!props.infix, + primitive: !!props.primitive, + handler: handler + }; + + for (var i = 0; i < names.length; ++i) { + _functions[names[i]] = data; + } + + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ + +function defineFunctionBuilders(_ref2) { + var { + type, + htmlBuilder, + mathmlBuilder + } = _ref2; + defineFunction({ + type, + names: [], + props: { + numArgs: 0 + }, + + handler() { + throw new Error('Should never be called.'); + }, + + htmlBuilder, + mathmlBuilder + }); +} +var normalizeArgument = function normalizeArgument(arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; // Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments + +var ordargument = function ordargument(arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; + +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ +var makeSpan$1 = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. + +var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]; +var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"]; +var styleMap$1 = { + "display": Style$1.DISPLAY, + "text": Style$1.TEXT, + "script": Style$1.SCRIPT, + "scriptscript": Style$1.SCRIPTSCRIPT +}; +var DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner" +}; + +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +var buildExpression$1 = function buildExpression(expression, options, isRealGroup, surrounding) { + if (surrounding === void 0) { + surrounding = [null, null]; + } + + // Parse expressions into `groups`. + var groups = []; + + for (var i = 0; i < expression.length; i++) { + var output = buildGroup$1(expression[i], options); + + if (output instanceof DocumentFragment) { + var children = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } // Combine consecutive domTree.symbolNodes into a single symbolNode. + + + buildCommon.tryCombineChars(groups); // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + + if (!isRealGroup) { + return groups; + } + + var glueOptions = options; + + if (expression.length === 1) { + var node = expression[0]; + + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap$1[node.style]); + } + } // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + + + var dummyPrev = makeSpan$1([surrounding[0] || "leftmost"], [], options); + var dummyNext = makeSpan$1([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + + var isRoot = isRealGroup === "root"; + traverseNonSpaceNodes(groups, (node, prev) => { + var prevType = prev.classes[0]; + var type = node.classes[0]; + + if (prevType === "mbin" && utils$1.contains(binRightCanceller, type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && utils$1.contains(binLeftCanceller, prevType)) { + node.classes[0] = "mord"; + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + traverseNonSpaceNodes(groups, (node, prev) => { + var prevType = getTypeOfDomTree(prev); + var type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style. + + var space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null; + + if (space) { + // Insert glue (spacing) after the `prev`. + return buildCommon.makeGlue(space, glueOptions); + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + return groups; +}; // Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. + +var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) { + if (next) { + // temporarily append the right node, if exists + nodes.push(next); + } + + var i = 0; + + for (; i < nodes.length; i++) { + var node = nodes[i]; + var partialGroup = checkPartialGroup(node); + + if (partialGroup) { + // Recursive DFS + // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array + traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); + continue; + } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + + + var nonspace = !node.hasClass("mspace"); + + if (nonspace) { + var result = callback(node, prev.node); + + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } + } + } + + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan$1(["leftmost"]); // treat like beginning of line + } + + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + + if (next) { + nodes.pop(); + } +}; // Check if given node is a partial group, i.e., does not affect spacing around. + + +var checkPartialGroup = function checkPartialGroup(node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { + return node; + } + + return null; +}; // Return the outermost node of a domTree. + + +var getOutermostNode = function getOutermostNode(node, side) { + var partialGroup = checkPartialGroup(node); + + if (partialGroup) { + var children = partialGroup.children; + + if (children.length) { + if (side === "right") { + return getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return getOutermostNode(children[0], "left"); + } + } + } + + return node; +}; // Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. + + +var getTypeOfDomTree = function getTypeOfDomTree(node, side) { + if (!node) { + return null; + } + + if (side) { + node = getOutermostNode(node, side); + } // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + + + return DomEnum[node.classes[0]] || null; +}; +var makeNullDelimiter = function makeNullDelimiter(options, classes) { + var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan$1(classes.concat(moreClasses)); +}; +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ + +var buildGroup$1 = function buildGroup(group, options, baseOptions) { + if (!group) { + return makeSpan$1(); + } + + if (_htmlGroupBuilders[group.type]) { + // Call the groupBuilders function + // $FlowFixMe + var groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account + // for that size difference. + + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan$1(options.sizingClasses(baseOptions), [groupNode], options); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + + return groupNode; + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ + +function buildHTMLUnbreakable(children, options) { + // Compute height and depth of this chunk. + var body = makeSpan$1(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + + var strut = makeSpan$1(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + + body.children.unshift(strut); + return body; +} +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ + + +function buildHTML(tree, options) { + // Strip off outer tag wrapper for processing below. + var tag = null; + + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } // Build the expression contained in the tree + + + var expression = buildExpression$1(tree, options, "root"); + var eqnNum; + + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + + var children = []; // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + + var parts = []; + + for (var i = 0; i < expression.length; i++) { + parts.push(expression[i]); + + if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + var nobreak = false; + + while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } // Don't allow break if \nobreak among the post-operator glue. + + + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } // Put the newline at the top level + + + children.push(expression[i]); + } + } + + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } // Now, if there was a tag, build it too and append it as a final child. + + + var tagChild; + + if (tag) { + tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true)); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + + var htmlNode = makeSpan$1(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + + if (tagChild) { + var strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + + return htmlNode; +} + +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ +function newDocumentFragment(children) { + return new DocumentFragment(children); +} +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ + +class MathNode { + constructor(type, children, classes) { + this.type = void 0; + this.attributes = void 0; + this.children = void 0; + this.classes = void 0; + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + + + setAttribute(name, value) { + this.attributes[name] = value; + } + /** + * Gets an attribute on a MathML node. + */ + + + getAttribute(name) { + return this.attributes[name]; + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + + + toNode() { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; + } + /** + * Converts the math node into an HTML markup string. + */ + + + toMarkup() { + var markup = "<" + this.type; // Add the attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += utils$1.escape(this.attributes[attr]); + markup += "\""; + } + } + + if (this.classes.length > 0) { + markup += " class =\"" + utils$1.escape(createClass(this.classes)) + "\""; + } + + markup += ">"; + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; + } + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + + + toText() { + return this.children.map(child => child.toText()).join(""); + } + +} +/** + * This node represents a piece of text. + */ + +class TextNode { + constructor(text) { + this.text = void 0; + this.text = text; + } + /** + * Converts the text node into a DOM text node. + */ + + + toNode() { + return document.createTextNode(this.text); + } + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + + + toMarkup() { + return utils$1.escape(this.toText()); + } + /** + * Converts the text node into a string + * (representing the text itself). + */ + + + toText() { + return this.text; + } + +} +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ + +class SpaceNode { + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width) { + this.width = void 0; + this.character = void 0; + this.width = width; // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + + + toNode() { + if (this.character) { + return document.createTextNode(this.character); + } else { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + /** + * Converts the math node into an HTML markup string. + */ + + + toMarkup() { + if (this.character) { + return "" + this.character + ""; + } else { + return ""; + } + } + /** + * Converts the math node into a string, similar to innerText. + */ + + + toText() { + if (this.character) { + return this.character; + } else { + return " "; + } + } + +} + +var mathMLTree = { + MathNode, + TextNode, + SpaceNode, + newDocumentFragment +}; + +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +var makeText = function makeText(text, mode, options) { + if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { + text = symbols[mode][text].replace; + } + + return new mathMLTree.TextNode(text); +}; +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ + +var makeRow = function makeRow(body) { + if (body.length === 1) { + return body[0]; + } else { + return new mathMLTree.MathNode("mrow", body); + } +}; +/** + * Returns the math variant as a string or null if none is required. + */ + +var getVariant = function getVariant(group, options) { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + + var font = options.font; + + if (!font || font === "mathnormal") { + return null; + } + + var mode = group.mode; + + if (font === "mathit") { + return "italic"; + } else if (font === "boldsymbol") { + return group.type === "textord" ? "bold" : "bold-italic"; + } else if (font === "mathbf") { + return "bold"; + } else if (font === "mathbb") { + return "double-struck"; + } else if (font === "mathfrak") { + return "fraktur"; + } else if (font === "mathscr" || font === "mathcal") { + // MathML makes no distinction between script and calligraphic + return "script"; + } else if (font === "mathsf") { + return "sans-serif"; + } else if (font === "mathtt") { + return "monospace"; + } + + var text = group.text; + + if (utils$1.contains(["\\imath", "\\jmath"], text)) { + return null; + } + + if (symbols[mode][text] && symbols[mode][text].replace) { + text = symbols[mode][text].replace; + } + + var fontName = buildCommon.fontMap[font].fontName; + + if (getCharacterMetrics(text, fontName, mode)) { + return buildCommon.fontMap[font].variant; + } + + return null; +}; +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ + +var buildExpression = function buildExpression(expression, options, isOrdgroup) { + if (expression.length === 1) { + var group = buildGroup(expression[0], options); + + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + + return [group]; + } + + var groups = []; + var lastGroup; + + for (var i = 0; i < expression.length; i++) { + var _group = buildGroup(expression[i], options); + + if (_group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(..._group.children); + continue; // Concatenate adjacent s + } else if (_group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); + continue; // Concatenate ... followed by . + } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') { + var child = _group.children[0]; + + if (child instanceof TextNode && child.text === '.') { + lastGroup.children.push(..._group.children); + continue; + } + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + var lastChild = lastGroup.children[0]; + + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) { + var _child = _group.children[0]; + + if (_child instanceof TextNode && _child.text.length > 0) { + // Overlay with combining character long solidus + _child.text = _child.text.slice(0, 1) + "\u0338" + _child.text.slice(1); + groups.pop(); + } + } + } + } + + groups.push(_group); + lastGroup = _group; + } + + return groups; +}; +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ + +var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { + return makeRow(buildExpression(expression, options, isOrdgroup)); +}; +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ + +var buildGroup = function buildGroup(group, options) { + if (!group) { + return new mathMLTree.MathNode("mrow"); + } + + if (_mathmlGroupBuilders[group.type]) { + // Call the groupBuilders function + // $FlowFixMe + var result = _mathmlGroupBuilders[group.type](group, options); // $FlowFixMe + + return result; + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ + +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + var expression = buildExpression(tree, options); // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + + var wrapper; + + if (expression.length === 1 && expression[0] instanceof MathNode && utils$1.contains(["mrow", "mtable"], expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new mathMLTree.MathNode("mrow", expression); + } // Build a TeX annotation of the source + + + var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]); + annotation.setAttribute("encoding", "application/x-tex"); + var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]); + var math = new mathMLTree.MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + + if (isDisplayMode) { + math.setAttribute("display", "block"); + } // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + + + var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe + + return buildCommon.makeSpan([wrapperClass], [math]); +} + +var optionsFromSettings = function optionsFromSettings(settings) { + return new Options({ + style: settings.displayMode ? Style$1.DISPLAY : Style$1.TEXT, + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness + }); +}; + +var displayWrap = function displayWrap(node, settings) { + if (settings.displayMode) { + var classes = ["katex-display"]; + + if (settings.leqno) { + classes.push("leqno"); + } + + if (settings.fleqn) { + classes.push("fleqn"); + } + + node = buildCommon.makeSpan(classes, [node]); + } + + return node; +}; + +var buildTree = function buildTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var katexNode; + + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + var htmlNode = buildHTML(tree, options); + katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); + } else { + var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + + var _htmlNode = buildHTML(tree, options); + + katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]); + } + + return displayWrap(katexNode, settings); +}; +var buildHTMLTree = function buildHTMLTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var htmlNode = buildHTML(tree, options); + var katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; + +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ +var stretchyCodePoint = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", + // Not a perfect match. + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" +}; + +var mathMLnode = function mathMLnode(label) { + var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); + node.setAttribute("stretchy", "true"); + return node; +}; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. () +// Copyright (c) 2014-2017 Khan Academy () +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. +// The SVG typically contains a very long (400 em) arrow. +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + + +var katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] +}; + +var groupLength = function groupLength(arg) { + if (arg.type === "ordgroup") { + return arg.body.length; + } else { + return 1; + } +}; + +var svgSpan = function svgSpan(group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + var viewBoxWidth = 400000; // default + + var label = group.label.slice(1); + + if (utils$1.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { + // Each type in the `if` statement corresponds to one of the ParseNode + // types below. This narrowing is required to access `grp.base`. + // $FlowFixMe + var grp = group; // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + + var numChars = groupLength(grp.base); + var viewBoxHeight; + var pathName; + + var _height; + + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + _height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + _height = 0.34; + pathName = "tilde4"; + } + } else { + var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(_height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: buildCommon.makeSvgSpan([], [svgNode], options), + minWidth: 0, + height: _height + }; + } else { + var spans = []; + var data = katexImagesData[label]; + var [paths, _minWidth, _viewBoxHeight] = data; + + var _height2 = _viewBoxHeight / 1000; + + var numSvgChildren = paths.length; + var widthClasses; + var aligns; + + if (numSvgChildren === 1) { + // $FlowFixMe: All these cases must be of the 4-tuple type. + var align1 = data[3]; + widthClasses = ["hide-tail"]; + aligns = [align1]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + + for (var i = 0; i < numSvgChildren; i++) { + var _path = new PathNode(paths[i]); + + var _svgNode = new SvgNode([_path], { + "width": "400em", + "height": makeEm(_height2), + "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + + var _span = buildCommon.makeSvgSpan([widthClasses[i]], [_svgNode], options); + + if (numSvgChildren === 1) { + return { + span: _span, + minWidth: _minWidth, + height: _height2 + }; + } else { + _span.style.height = makeEm(_height2); + spans.push(_span); + } + } + + return { + span: buildCommon.makeSpan(["stretchy"], spans, options), + minWidth: _minWidth, + height: _height2 + }; + } + } // buildSvgSpan_() + + + var { + span, + minWidth, + height + } = buildSvgSpan_(); // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + + span.height = height; + span.style.height = makeEm(height); + + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + + return span; +}; + +var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + var img; + var totalHeight = inner.height + inner.depth + topPad + bottomPad; + + if (/fbox|color|angl/.test(label)) { + img = buildCommon.makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + var color = options.color && options.getColor(); + + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + var lines = []; + + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + + var svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = buildCommon.makeSvgSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; + +var stretchy = { + encloseSpan, + mathMLnode, + svgSpan +}; + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } // $FlowFixMe, >=0.125 + + + return node; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function assertSymbolNodeType(node) { + var typedNode = checkSymbolNodeType(node); + + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + + return typedNode; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + // $FlowFixMe + return node; + } + + return null; +} + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +var htmlBuilder$a = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + var base; + var group; + var supSubGroup; + + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group + + base = group.base; // Stick the character box into the base of the supsub group + + grp.base = base; // Rerender the supsub group with its new base, and store that + // result. + + supSubGroup = assertSpan(buildGroup$1(grp, options)); // reset original base + + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } // Build the base group + + + var body = buildGroup$1(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? + + var mustShift = group.isShifty && utils$1.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + + var skew = 0; + + if (mustShift) { + // If the base is a character box, then we want the skew of the + // innermost character. To do that, we find the innermost character: + var baseChar = utils$1.getBaseElem(base); // Then, we render its group to get the symbol inside it + + var baseGroup = buildGroup$1(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. + + skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we + // removed with getBaseElem might contain things like \color which + // we can't get rid of. + // TODO(emily): Find a better way to get the skew + } + + var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent + + var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent + + var accentBody; + + if (!group.isStretchy) { + var accent; + var width; + + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = buildCommon.staticSvg("vec", options); + width = buildCommon.svgData.vec[1]; + } else { + accent = buildCommon.makeOrd({ + mode: group.mode, + text: group.label + }, options, "textord"); + accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + + accent.italic = 0; + width = accent.width; + + if (accentBelow) { + clearance += accent.depth; + } + } + + accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + + var accentFull = group.label === "\\textcircled"; + + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } // Shift the accent over by the skew. + + + var left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + + if (!accentFull) { + left -= width / 2; + } + + accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }, options); + } else { + accentBody = stretchy.svgSpan(group, options); + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }, options); + } + + var accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options); + + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not. + + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; + +var mathmlBuilder$9 = (group, options) => { + var accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]); + var node = new mathMLTree.MathNode("mover", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; + +var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); // Accents + +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + props: { + numArgs: 1 + }, + handler: (context, args) => { + var base = normalizeArgument(args[0]); + var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); // Text-mode accents + +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"] + }, + handler: (context, args) => { + var base = args[0]; + var mode = context.parser.mode; + + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); + +// Horizontal overlap functions +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + var innerGroup = buildGroup$1(group.base, options); + var accentBody = stretchy.svgSpan(group, options); + var kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns + + var vlist = buildCommon.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + var accentNode = stretchy.mathMLnode(group.label); + var node = new mathMLTree.MathNode("munder", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; + } +}); + +// Helper function +var paddedNode = group => { + var node = new mathMLTree.MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; // Stretchy arrows with an optional argument + + +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + + // Flow is unable to correctly infer the type of `group`, even though it's + // unambiguously determined from the passed-in `type` above. + htmlBuilder(group, options) { + var style = options.style; // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + + var newOptions = options.havingStyle(style.sup()); + var upperGroup = buildCommon.wrapFragment(buildGroup$1(group.body, newOptions, options), options); + var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + var lowerGroup; + + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = buildCommon.wrapFragment(buildGroup$1(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + + var arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + + var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + + var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } // Generate the vlist + + + var vlist; + + if (lowerGroup) { + var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }, options); + } else { + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }] + }, options); + } // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + + + vlist.children[0].children[0].children[1].classes.push("svg-align"); + return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + + mathmlBuilder(group, options) { + var arrowNode = stretchy.mathMLnode(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + var node; + + if (group.body) { + var upperNode = paddedNode(buildGroup(group.body, options)); + + if (group.below) { + var lowerNode = paddedNode(buildGroup(group.below, options)); + node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + var _lowerNode = paddedNode(buildGroup(group.below, options)); + + node = new mathMLTree.MathNode("munder", [arrowNode, _lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new mathMLTree.MathNode("mover", [arrowNode, node]); + } + + return node; + } + +}); + +var makeSpan = buildCommon.makeSpan; + +function htmlBuilder$9(group, options) { + var elements = buildExpression$1(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} + +function mathmlBuilder$8(group, options) { + var node; + var inner = buildExpression(group.body, options); + + if (group.mclass === "minner") { + node = new mathMLTree.MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new mathMLTree.MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new mathMLTree.MathNode("mo", inner); + } // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + + + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + + node.attributes.width = "+0.1111em"; + } // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + + } + + return node; +} // Math class commands except \mathop + + +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + props: { + numArgs: 1, + primitive: true + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: utils$1.isCharacterBox(body) + }; + }, + + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); +var binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; + + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. + +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + props: { + numArgs: 2 + }, + + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: utils$1.isCharacterBox(args[1]) + }; + } + +}); // Build a relation or stacked op by placing one symbol on top of another + +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + props: { + numArgs: 2 + }, + + handler(_ref3, args) { + var { + parser, + funcName + } = _ref3; + var baseArg = args[1]; + var shiftedArg = args[0]; + var mclass; + + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + + var baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + var supsub = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null + }; + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: utils$1.isCharacterBox(supsub) + }; + }, + + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. +defineFunction({ + type: "pmb", + names: ["\\pmb"], + props: { + numArgs: 1, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]) + }; + }, + + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, true); + var node = buildCommon.makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + + mathmlBuilder(group, style) { + var inner = buildExpression(group.body, style); // Wrap with an element. + + var node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + } + +}); + +var cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; + +var newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + // So these values are fixed and flow can do implicit typing. + return { + type: "styling", + body: [], + mode: "math", + style: "display" + }; +}; + +var isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; + +var isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; + +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + var funcName = cdArrowFunctionName[arrowChar]; + + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); + + case "\\uparrow": + case "\\downarrow": + { + var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + var bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + var sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + var arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + + case "\\Vert": + { + var arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} + +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + var parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + + while (true) { + // eslint-disable-line no-constant-condition + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var next = parser.fetch().text; + + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + + var row = []; + var body = [row]; // Loop thru the parse nodes. Collect them into cells and arrows. + + for (var i = 0; i < parsedRows.length; i++) { + // Start a new row. + var rowNodes = parsedRows[i]; // Create the first cell. + + var cell = newCell(); + + for (var j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + + j += 1; + var arrowChar = assertSymbolNodeType(rowNodes[j]).text; // Create two empty label nodes. We may or may not use them. + + var labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; // Process the arrow. + + if ("=|.".indexOf(arrowChar) > -1) ; else if ("<>AV".indexOf(arrowChar) > -1) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (var labelNum = 0; labelNum < 2; labelNum++) { + var inLabel = true; + + for (var k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + + labels[labelNum].body.push(rowNodes[k]); + } + + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } // Now join the arrow to its labels. + + + var arrow = cdArrow(arrowChar, labels, parser); // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + + var wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display" // CD is always displaystyle. + + }; + row.push(wrappedArrow); // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + + cell = newCell(); + } + } + + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + + row = []; + body.push(row); + } // End row group + + + parser.gullet.endGroup(); // End array group defining \\ + + parser.gullet.endGroup(); // define column separation. + + var cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} // The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + + htmlBuilder(group, options) { + var newOptions = options.havingStyle(options.style.sup()); + var label = buildCommon.wrapFragment(buildGroup$1(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + + label.height = 0; + label.depth = 0; + return label; + }, + + mathmlBuilder(group, options) { + var label = new mathMLTree.MathNode("mrow", [buildGroup(group.label, options)]); + label = new mathMLTree.MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + + + label.setAttribute("voffset", "0.7em"); + label = new mathMLTree.MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } + +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1 + }, + + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + var parent = buildCommon.wrapFragment(buildGroup$1(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", [buildGroup(group.fragment, options)]); + } + +}); + +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. + +defineFunction({ + type: "textord", + names: ["\\@char"], + props: { + numArgs: 1, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var arg = assertNodeType(args[0], "ordgroup"); + var group = arg.body; + var number = ""; + + for (var i = 0; i < group.length; i++) { + var node = assertNodeType(group[i], "textord"); + number += node.text; + } + + var code = parseInt(number); + var text; + + if (isNaN(code)) { + throw new ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); + } + + return { + type: "textord", + mode: parser.mode, + text: text + }; + } + +}); + +var htmlBuilder$8 = (group, options) => { + var elements = buildExpression$1(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + + return buildCommon.makeFragment(elements); +}; + +var mathmlBuilder$7 = (group, options) => { + var inner = buildExpression(group.body, options.withColor(group.color)); + var node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("mathcolor", group.color); + return node; +}; + +defineFunction({ + type: "color", + names: ["\\textcolor"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"] + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: ordargument(body) + }; + }, + + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); +defineFunction({ + type: "color", + names: ["\\color"], + props: { + numArgs: 1, + allowedInText: true, + argTypes: ["color"] + }, + + handler(_ref2, args) { + var { + parser, + breakOnTokenText + } = _ref2; + var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + + parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored. + + var body = parser.parseExpression(true, breakOnTokenText); + return { + type: "color", + mode: parser.mode, + color, + body + }; + }, + + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); + +// Row breaks within tabular environments, and line breaks at top level + +defineFunction({ + type: "cr", + names: ["\\\\"], + props: { + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true + }, + + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value + }; + }, + + // The following builders are called only at the top level, + // not within tabular/array environments. + htmlBuilder(group, options) { + var span = buildCommon.makeSpan(["mspace"], [], options); + + if (group.newLine) { + span.classes.push("newline"); + + if (group.size) { + span.style.marginTop = makeEm(calculateSize(group.size, options)); + } + } + + return span; + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mspace"); + + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + + if (group.size) { + node.setAttribute("height", makeEm(calculateSize(group.size, options))); + } + } + + return node; + } + +}); + +var globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; + +var checkControlSequence = tok => { + var name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + return name; +}; + +var getRHS = parser => { + var tok = parser.gullet.popToken(); + + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + + return tok; +}; + +var letCommand = (parser, name, tok, global) => { + var macro = parser.gullet.macros.get(tok.text); + + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + + parser.gullet.macros.set(name, macro, global); +}; // -> | +// -> |\global +// -> | +// -> \global|\long|\outer + + +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + var { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + var token = parser.fetch(); + + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + + return assertNodeType(parser.parseFunction(), "internal"); + } + + throw new ParseError("Invalid token after macro prefix", token); + } + +}); // Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> + +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref2) { + var { + parser, + funcName + } = _ref2; + var tok = parser.gullet.popToken(); + var name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + var numArgs = 0; + var insert; + var delimiters = [[]]; // contains no braces + + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + + + tok = parser.gullet.popToken(); + + if (!/^[1-9]$/.test(tok.text)) { + throw new ParseError("Invalid argument number \"" + tok.text + "\""); + } + + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError("Argument number \"" + tok.text + "\" out of order"); + } + + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } // replacement text, enclosed in '{' and '}' and properly nested + + + var { + tokens + } = parser.gullet.consumeArg(); + + if (insert) { + tokens.unshift(insert); + } + + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } // Final arg is the expansion of the macro + + + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // -> +// -> \futurelet +// | \let +// -> |= + +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + var name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + var tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf + +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + var name = checkControlSequence(parser.gullet.popToken()); + var middle = parser.gullet.popToken(); + var tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } + +}); + +/** + * This file deals with creating delimiters of various sizes. The TeXbook + * discusses these routines on page 441-442, in the "Another subroutine sets box + * x to a specified variable delimiter" paragraph. + * + * There are three main routines here. `makeSmallDelim` makes a delimiter in the + * normal font, but in either text, script, or scriptscript style. + * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1, + * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of + * smaller pieces that are stacked on top of one another. + * + * The functions take a parameter `center`, which determines if the delimiter + * should be centered around the axis. + * + * Then, there are three exposed functions. `sizedDelim` makes a delimiter in + * one of the given sizes. This is used for things like `\bigl`. + * `customSizedDelim` makes a delimiter with a given total height+depth. It is + * called in places like `\sqrt`. `leftRightDelim` makes an appropriate + * delimiter which surrounds an expression of a given height an depth. It is + * used in `\left` and `\right`. + */ + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +var getMetrics = function getMetrics(symbol, font, mode) { + var replace = symbols.math[symbol] && symbols.math[symbol].replace; + var metrics = getCharacterMetrics(replace || symbol, font, mode); + + if (!metrics) { + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); + } + + return metrics; +}; +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ + + +var styleWrap = function styleWrap(delim, toStyle, options, classes) { + var newOptions = options.havingBaseStyle(toStyle); + var span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + return span; +}; + +var centerSpan = function centerSpan(span, options, style) { + var newOptions = options.havingBaseStyle(style); + var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; +/** + * Makes a small delimiter. This is a delimiter that comes in the Main-Regular + * font, but is restyled to either be in textstyle, scriptstyle, or + * scriptscriptstyle. + */ + + +var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { + var text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options); + var span = styleWrap(text, style, options, classes); + + if (center) { + centerSpan(span, options, style); + } + + return span; +}; +/** + * Builds a symbol in the given font size (note size is an integer) + */ + + +var mathrmSize = function mathrmSize(value, size, mode, options) { + return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ + + +var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { + var inner = mathrmSize(delim, size, mode, options); + var span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), Style$1.TEXT, options, classes); + + if (center) { + centerSpan(span, options, Style$1.TEXT); + } + + return span; +}; +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ + + +var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) { + var sizeClass; // Apply the correct CSS class to choose the right font. + + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else + /* if (font === "Size4-Regular") */ + { + sizeClass = "delim-size4"; + } + + var corner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + + return { + type: "elem", + elem: corner + }; +}; + +var makeInner = function makeInner(ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + var span = buildCommon.makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span + }; +}; // Helpers for makeStackedDelim + + +var lapInEms = 0.008; +var lap = { + type: "kern", + size: -1 * lapInEms +}; +var verts = ["|", "\\lvert", "\\rvert", "\\vert"]; +var doubleVerts = ["\\|", "\\lVert", "\\rVert", "\\Vert"]; +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ + +var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + var top; + var middle; + var repeat; + var bottom; + var svgLabel = ""; + var viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; // Also keep track of what font the delimiters are in + + var font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (utils$1.contains(verts, delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (utils$1.contains(doubleVerts, delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } // Get the metrics of the four sections + + + var topMetrics = getMetrics(top, font, mode); + var topHeightTotal = topMetrics.height + topMetrics.depth; + var repeatMetrics = getMetrics(repeat, font, mode); + var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + var bottomMetrics = getMetrics(bottom, font, mode); + var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + var middleHeightTotal = 0; + var middleFactor = 1; + + if (middle !== null) { + var middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + + + var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need + + var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols + + var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + + var axisHeight = options.fontMetrics().axisHeight; + + if (center) { + axisHeight *= options.sizeMultiplier; + } // Calculate the depth + + + var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + + var stack = []; + + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + var viewBoxHeight = Math.round(realHeightTotal * 1000); + var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + var path = new PathNode(svgLabel, pathStr); + var width = (viewBoxWidth / 1000).toFixed(3) + "em"; + var height = (viewBoxHeight / 1000).toFixed(3) + "em"; + var svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + var wrapper = buildCommon.makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + + stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace. + + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, _innerHeight, options)); + } // Add the top symbol + + + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } // Finally, build the vlist + + + var newOptions = options.havingBaseStyle(Style$1.TEXT); + var inner = buildCommon.makeVList({ + positionType: "bottom", + positionData: depth, + children: stack + }, newOptions); + return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1.TEXT, options, classes); +}; // All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. + + +var vbPad = 80; // padding above the surd, measured inside the viewBox. + +var emPad = 0.08; // padding, in ems, measured in the document. + +var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) { + var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + var pathNode = new PathNode(sqrtName, path); + var svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + return buildCommon.makeSvgSpan(["hide-tail"], [svg], options); +}; +/** + * Make a sqrt image of the given height, + */ + + +var makeSqrtImage = function makeSqrtImage(height, options) { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + var newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds. + + var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + var sizeMultiplier = newOptions.sizeMultiplier; // default + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + + var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol. + + var span; + var spanHeight = 0; + var texHeight = 0; + var viewBoxHeight = 0; + var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + + span.height = texHeight; + span.style.height = makeEm(spanHeight); + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier + }; +}; // There are three kinds of delimiters, delimiters that stack when they become +// too large + + +var stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack + +var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]; // and delimiters that never stack + +var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. + +var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ + +var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } // Sized delimiters are never centered. + + + if (utils$1.contains(stackLargeDelimiters, delim) || utils$1.contains(stackNeverDelimiters, delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (utils$1.contains(stackAlwaysDelimiters, delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + } else { + throw new ParseError("Illegal delimiter: '" + delim + "'"); + } +}; +/** + * There are three different sequences of delimiter sizes that the delimiters + * follow depending on the kind of delimiter. This is used when creating custom + * sized delimiters to decide whether to create a small, large, or stacked + * delimiter. + * + * In real TeX, these sequences aren't explicitly defined, but are instead + * defined inside the font metrics. Since there are only three sequences that + * are possible for the delimiters that TeX defines, it is easier to just encode + * them explicitly here. + */ + + +// Delimiters that never stack try small delimiters and large delimiters only +var stackNeverDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}]; // Delimiters that always stack try the small delimiters first, then stack + +var stackAlwaysDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "stack" +}]; // Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards + +var stackLargeDelimiterSequence = [{ + type: "small", + style: Style$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1.SCRIPT +}, { + type: "small", + style: Style$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}, { + type: "stack" +}]; +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ + +var delimTypeToFont = function delimTypeToFont(type) { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + throw new Error("Add support for delim type '" + type.type + "' here."); + } +}; +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ + + +var traverseSequence = function traverseSequence(delim, height, sequence, options) { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + var start = Math.min(2, 3 - options.style.size); + + for (var i = start; i < sequence.length; i++) { + if (sequence[i].type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + + var metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math"); + var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + + if (sequence[i].type === "small") { + var newOptions = options.havingBaseStyle(sequence[i].style); + heightDepth *= newOptions.sizeMultiplier; + } // Check if the delimiter at this size works for the given height. + + + if (heightDepth > height) { + return sequence[i]; + } + } // If we reached the end of the sequence, return the last sequence element. + + + return sequence[sequence.length - 1]; +}; +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ + + +var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } // Decide what sequence to use + + + var sequence; + + if (utils$1.contains(stackNeverDelimiters, delim)) { + sequence = stackNeverDelimiterSequence; + } else if (utils$1.contains(stackLargeDelimiters, delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } // Look through the sequence + + + var delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else + /* if (delimType.type === "stack") */ + { + return makeStackedDelim(delim, height, center, options, mode, classes); + } +}; +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ + + +var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { + // We always center \left/\right delimiters, so the axis is always shifted + var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right + + var delimiterFactor = 901; + var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + var totalHeight = Math.max( // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; + +var delimiter$1 = { + sqrtImage: makeSqrtImage, + sizedDelim: makeSizedDelim, + sizeToMaxHeight: sizeToMaxHeight, + customSizedDelim: makeCustomSizedDelim, + leftRightDelim: makeLeftRightDelim +}; + +// Extra data needed for the delimiter handler down below +var delimiterSizes = { + "\\bigl": { + mclass: "mopen", + size: 1 + }, + "\\Bigl": { + mclass: "mopen", + size: 2 + }, + "\\biggl": { + mclass: "mopen", + size: 3 + }, + "\\Biggl": { + mclass: "mopen", + size: 4 + }, + "\\bigr": { + mclass: "mclose", + size: 1 + }, + "\\Bigr": { + mclass: "mclose", + size: 2 + }, + "\\biggr": { + mclass: "mclose", + size: 3 + }, + "\\Biggr": { + mclass: "mclose", + size: 4 + }, + "\\bigm": { + mclass: "mrel", + size: 1 + }, + "\\Bigm": { + mclass: "mrel", + size: 2 + }, + "\\biggm": { + mclass: "mrel", + size: 3 + }, + "\\Biggm": { + mclass: "mrel", + size: 4 + }, + "\\big": { + mclass: "mord", + size: 1 + }, + "\\Big": { + mclass: "mord", + size: 2 + }, + "\\bigg": { + mclass: "mord", + size: 3 + }, + "\\Bigg": { + mclass: "mord", + size: 4 + } +}; +var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; + +// Delimiter functions +function checkDelimiter(delim, context) { + var symDelim = checkSymbolNodeType(delim); + + if (symDelim && utils$1.contains(delimiters, symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); + } else { + throw new ParseError("Invalid delimiter type '" + delim.type + "'", delim); + } +} + +defineFunction({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + props: { + numArgs: 1, + argTypes: ["primitive"] + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return buildCommon.makeSpan([group.mclass]); + } // Use delimiter.sizedDelim to generate the delimiter. + + + return delimiter$1.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: group => { + var children = []; + + if (group.delim !== ".") { + children.push(makeText(group.delim, group.mode)); + } + + var node = new mathMLTree.MathNode("mo", children); + + if (group.mclass === "mopen" || group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + + node.setAttribute("stretchy", "true"); + var size = makeEm(delimiter$1.sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + return node; + } +}); + +function assertParsed(group) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} + +defineFunction({ + type: "leftright-right", + names: ["\\right"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + var color = context.parser.gullet.macros.get("\\current@color"); + + if (color && typeof color !== "string") { + throw new ParseError("\\current@color set to non-string in \\right"); + } + + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color // undefined if not set via \color + + }; + } +}); +defineFunction({ + type: "leftright", + names: ["\\left"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + var parser = context.parser; // Parse out the implicit body + + ++parser.leftrightDepth; // parseExpression stops before '\\right' + + var body = parser.parseExpression(false); + --parser.leftrightDepth; // Check the next token + + parser.expect("\\right", false); + var right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); // Build the inner expression + + var inner = buildExpression$1(group.body, options, true, ["mopen", "mclose"]); + var innerHeight = 0; + var innerDepth = 0; + var hadMiddle = false; // Calculate its height and depth + + for (var i = 0; i < inner.length; i++) { + // Property `isMiddle` not defined on `span`. See comment in + // "middle"'s htmlBuilder. + // $FlowFixMe + if (inner[i].isMiddle) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + + + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + var leftDelim; + + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = delimiter$1.leftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } // Add it to the beginning of the expression + + + inner.unshift(leftDelim); // Handle middle delimiters + + if (hadMiddle) { + for (var _i = 1; _i < inner.length; _i++) { + var middleDelim = inner[_i]; // Property `isMiddle` not defined on `span`. See comment in + // "middle"'s htmlBuilder. + // $FlowFixMe + + var isMiddle = middleDelim.isMiddle; + + if (isMiddle) { + // Apply the options that were active when \middle was called + inner[_i] = delimiter$1.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + } + } + } + + var rightDelim; // Same for the right delimiter, but using color specified by \color + + if (group.right === ".") { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + rightDelim = delimiter$1.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + } // Add it to the end of the expression. + + + inner.push(rightDelim); + return buildCommon.makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + var inner = buildExpression(group.body, options); + + if (group.left !== ".") { + var leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]); + leftNode.setAttribute("fence", "true"); + inner.unshift(leftNode); + } + + if (group.right !== ".") { + var rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]); + rightNode.setAttribute("fence", "true"); + + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + + inner.push(rightNode); + } + + return makeRow(inner); + } +}); +defineFunction({ + type: "middle", + names: ["\\middle"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + + if (!context.parser.leftrightDepth) { + throw new ParseError("\\middle without preceding \\left", delim); + } + + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + var middleDelim; + + if (group.delim === ".") { + middleDelim = makeNullDelimiter(options, []); + } else { + middleDelim = delimiter$1.sizedDelim(group.delim, 1, options, group.mode, []); + var isMiddle = { + delim: group.delim, + options + }; // Property `isMiddle` not defined on `span`. It is only used in + // this file above. + // TODO: Fix this violation of the `span` type and possibly rename + // things since `isMiddle` sounds like a boolean, but is a struct. + // $FlowFixMe + + middleDelim.isMiddle = isMiddle; + } + + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + var middleNode = new mathMLTree.MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + } +}); + +var htmlBuilder$7 = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + var inner = buildCommon.wrapFragment(buildGroup$1(group.body, options), options); + var label = group.label.slice(1); + var scale = options.sizeMultiplier; + var img; + var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + + var isSingleChar = utils$1.isCharacterBox(group.body); + + if (label === "sout") { + img = buildCommon.makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + var lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + var clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); // Prevent size changes like \Huge from affecting line thickness + + var newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle. + + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG + + var viewBoxHeight = Math.floor(1000 * angleHeight * scale); + var path = phasePath(viewBoxHeight); + var svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); // Wrap it in a span with overflow: hidden. + + img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } // Add vertical padding + + + var topPad = 0; + var bottomPad = 0; + var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2" + + if (/box/.test(label)) { + ruleThickness = Math.max(options.fontMetrics().fboxrule, // default + options.minRuleThickness // User override. + ); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + + img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options); + + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + + imgShift = inner.depth + bottomPad; + + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + + var vlist; + + if (group.backgroundColor) { + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [// Put the color background behind inner; + { + type: "elem", + elem: img, + shift: imgShift + }, { + type: "elem", + elem: inner, + shift: 0 + }] + }, options); + } else { + var classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [// Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0 + }, { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes + }] + }, options); + } + + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return buildCommon.makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return buildCommon.makeSpan(["mord"], [vlist], options); + } +}; + +var mathmlBuilder$6 = (group, options) => { + var fboxsep = 0; + var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildGroup(group.body, options)]); + + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + + case "\\fbox": + node.setAttribute("notation", "box"); + break; + + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // + + node.setAttribute("voffset", fboxsep + "pt"); + + if (group.label === "\\fcolorbox") { + var thk = Math.max(options.fontMetrics().fboxrule, // default + options.minRuleThickness // user override + ); + node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor)); + } + + break; + + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + + return node; +}; + +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "text"] + }, + + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body + }; + }, + + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + props: { + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "text"] + }, + + handler(_ref2, args, optArgs) { + var { + parser, + funcName + } = _ref2; + var borderColor = assertNodeType(args[0], "color-token").color; + var backgroundColor = assertNodeType(args[1], "color-token").color; + var body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body + }; + }, + + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fbox"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true + }, + + handler(_ref3, args) { + var { + parser + } = _ref3; + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0] + }; + } + +}); +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\phase"], + props: { + numArgs: 1 + }, + + handler(_ref4, args) { + var { + parser, + funcName + } = _ref4; + var body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + }, + + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false + }, + + handler(_ref5, args) { + var { + parser + } = _ref5; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } + +}); + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +var _environments = {}; +function defineEnvironment(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of environments. + var data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler + }; + + for (var i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +var _macros = {}; // This function might one day accept an additional argument and do more things. + +function defineMacro(name, body) { + _macros[name] = body; +} + +// Helper functions +function getHLines(parser) { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + var hlineInfo = []; + parser.consumeSpaces(); + var nxt = parser.fetch().text; + + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + + return hlineInfo; +} + +var validateAmsEnvironmentContext = context => { + var settings = context.parser.settings; + + if (!settings.displayMode) { + throw new ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; // autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. + + +function getAutoTag(name) { + if (name.indexOf("ed") === -1) { + return name.indexOf("*") === -1; + } // return undefined; + +} +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ + + +function parseArray(parser, _ref, style) { + var { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; + parser.gullet.beginGroup(); + + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } // Get current arraystretch if it's not set by the environment + + + if (!arraystretch) { + var stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + + if (!arraystretch || arraystretch < 0) { + throw new ParseError("Invalid \\arraystretch: " + stretch); + } + } + } // Start group for first cell + + + parser.gullet.beginGroup(); + var row = []; + var body = [row]; + var rowGaps = []; + var hLinesBeforeRow = []; + var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + + beginRow(); // Test for \hline at the top of the array. + + hLinesBeforeRow.push(getHLines(parser)); + + while (true) { + // eslint-disable-line no-constant-condition + // Parse each cell in its own group (namespace) + var cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + cell = { + type: "ordgroup", + mode: parser.mode, + body: cell + }; + + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + body: [cell] + }; + } + + row.push(cell); + var next = parser.fetch().text; + + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + + parser.consume(); + } else if (next === "\\end") { + endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + + if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + + break; + } else if (next === "\\\\") { + parser.consume(); + var size = void 0; // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + + rowGaps.push(size ? size.value : null); + endRow(); // check for \hline(s) following the row separator + + hLinesBeforeRow.push(getHLines(parser)); + row = []; + body.push(row); + beginRow(); + } else { + throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); + } + } // End cell group + + + parser.gullet.endGroup(); // End array group defining \cr + + parser.gullet.endGroup(); + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno + }; +} // Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. + + +function dCellStyle(envName) { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} + +var htmlBuilder$6 = function htmlBuilder(group, options) { + var r; + var c; + var nr = group.body.length; + var hLinesBeforeRow = group.hLinesBeforeRow; + var nc = 0; + var body = new Array(nr); + var hlines = []; + var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override. + ); // Horizontal spacing + + var pt = 1 / options.fontMetrics().ptPerEm; + var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + var localMultiplier = options.havingStyle(Style$1.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } // Vertical spacing + + + var baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + + var jot = 3 * pt; + var arrayskip = group.arraystretch * baselineskip; + var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + + var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + var totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any. + + function setHLinePos(hlinesInGap) { + for (var i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + + hlines.push({ + pos: totalHeight, + isDashed: hlinesInGap[i] + }); + } + } + + setHLinePos(hLinesBeforeRow[0]); + + for (r = 0; r < group.body.length; ++r) { + var inrow = group.body[r]; + var height = arstrutHeight; // \@array adds an \@arstrut + + var depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; + } + + var outrow = new Array(inrow.length); + + for (c = 0; c < inrow.length; ++c) { + var elt = buildGroup$1(inrow[c], options); + + if (depth < elt.depth) { + depth = elt.depth; + } + + if (height < elt.height) { + height = elt.height; + } + + outrow[c] = elt; + } + + var rowGap = group.rowGaps[r]; + var gap = 0; + + if (rowGap) { + gap = calculateSize(rowGap, options); + + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + + if (depth < gap) { + depth = gap; // \@xargarraycr + } + + gap = 0; + } + } // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added to the + // \baselineskip via \openup. + + + if (group.addJot) { + depth += jot; + } + + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + + body[r] = outrow; // Set a position for \hline(s), if any. + + setHLinePos(hLinesBeforeRow[r + 1]); + } + + var offset = totalHeight / 2 + options.fontMetrics().axisHeight; + var colDescriptions = group.cols || []; + var cols = []; + var colSep; + var colDescrNum; + var tagSpans = []; + + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + var rw = body[r]; + var shift = rw.pos - offset; + var tag = group.tags[r]; + var tagSpan = void 0; + + if (tag === true) { + // automatic numbering + tagSpan = buildCommon.makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = buildCommon.makeSpan([], [], options); + } else { + // manual \tag + tagSpan = buildCommon.makeSpan([], buildExpression$1(tag, options, true), options); + } + + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } + + for (c = 0, colDescrNum = 0; // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + var colDescr = colDescriptions[colDescrNum] || {}; + var firstSeparator = true; + + while (colDescr.type === "separator") { + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = buildCommon.makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + + if (colDescr.separator === "|" || colDescr.separator === ":") { + var lineType = colDescr.separator === "|" ? "solid" : "dashed"; + var separator = buildCommon.makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + + var _shift = totalHeight - offset; + + if (_shift) { + separator.style.verticalAlign = makeEm(-_shift); + } + + cols.push(separator); + } else { + throw new ParseError("Invalid separator type: " + colDescr.separator); + } + + colDescrNum++; + colDescr = colDescriptions[colDescrNum] || {}; + firstSeparator = false; + } + + if (c >= nc) { + continue; + } + + var sepwidth = void 0; + + if (c > 0 || group.hskipBeforeAndAfter) { + sepwidth = utils$1.deflt(colDescr.pregap, arraycolsep); + + if (sepwidth !== 0) { + colSep = buildCommon.makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + + var col = []; + + for (r = 0; r < nr; ++r) { + var row = body[r]; + var elem = row[c]; + + if (!elem) { + continue; + } + + var _shift2 = row.pos - offset; + + elem.depth = row.depth; + elem.height = row.height; + col.push({ + type: "elem", + elem: elem, + shift: _shift2 + }); + } + + col = buildCommon.makeVList({ + positionType: "individualShift", + children: col + }, options); + col = buildCommon.makeSpan(["col-align-" + (colDescr.align || "c")], [col]); + cols.push(col); + + if (c < nc - 1 || group.hskipBeforeAndAfter) { + sepwidth = utils$1.deflt(colDescr.postgap, arraycolsep); + + if (sepwidth !== 0) { + colSep = buildCommon.makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + + body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any. + + if (hlines.length > 0) { + var line = buildCommon.makeLineSpan("hline", options, ruleThickness); + var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness); + var vListElems = [{ + type: "elem", + elem: body, + shift: 0 + }]; + + while (hlines.length > 0) { + var hline = hlines.pop(); + var lineShift = hline.pos - offset; + + if (hline.isDashed) { + vListElems.push({ + type: "elem", + elem: dashes, + shift: lineShift + }); + } else { + vListElems.push({ + type: "elem", + elem: line, + shift: lineShift + }); + } + } + + body = buildCommon.makeVList({ + positionType: "individualShift", + children: vListElems + }, options); + } + + if (tagSpans.length === 0) { + return buildCommon.makeSpan(["mord"], [body], options); + } else { + var eqnNumCol = buildCommon.makeVList({ + positionType: "individualShift", + children: tagSpans + }, options); + eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options); + return buildCommon.makeFragment([body, eqnNumCol]); + } +}; + +var alignMap = { + c: "center ", + l: "left ", + r: "right " +}; + +var mathmlBuilder$5 = function mathmlBuilder(group, options) { + var tbl = []; + var glue = new mathMLTree.MathNode("mtd", [], ["mtr-glue"]); + var tag = new mathMLTree.MathNode("mtd", [], ["mml-eqn-num"]); + + for (var i = 0; i < group.body.length; i++) { + var rw = group.body[i]; + var row = []; + + for (var j = 0; j < rw.length; j++) { + row.push(new mathMLTree.MathNode("mtd", [buildGroup(rw[j], options)])); + } + + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + + tbl.push(new mathMLTree.MathNode("mtr", row)); + } + + var table = new mathMLTree.MathNode("mtable", tbl); // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + + var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + + var menclose = ""; + var align = ""; + + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + var cols = group.cols; + var columnLines = ""; + var prevTypeWasAlign = false; + var iStart = 0; + var iEnd = cols.length; + + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + + for (var _i = iStart; _i < iEnd; _i++) { + if (cols[_i].type === "align") { + align += alignMap[cols[_i].align]; + + if (prevTypeWasAlign) { + columnLines += "none "; + } + + prevTypeWasAlign = true; + } else if (cols[_i].type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += cols[_i].separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + + table.setAttribute("columnalign", align.trim()); + + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } // Set column spacing. + + + if (group.colSeparationType === "align") { + var _cols = group.cols || []; + + var spacing = ""; + + for (var _i2 = 1; _i2 < _cols.length; _i2++) { + spacing += _i2 % 2 ? "0em " : "1em "; + } + + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } // Address \hline and \hdashline + + + var rowLines = ""; + var hlines = group.hLinesBeforeRow; + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + + for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) { + rowLines += hlines[_i3].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element. + : hlines[_i3][0] ? "dashed " : "solid "; + } + + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + + if (menclose !== "") { + table = new mathMLTree.MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new mathMLTree.MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + + return table; +}; // Convenience function for align, align*, aligned, alignat, alignat*, alignedat. + + +var alignedHandler = function alignedHandler(context, args) { + if (context.envName.indexOf("ed") === -1) { + validateAmsEnvironmentContext(context); + } + + var cols = []; + var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align"; + var isSplit = context.envName === "split"; + var res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno + }, "display"); // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + + var numMaths; + var numCols = 0; + var emptyGroup = { + type: "ordgroup", + mode: context.mode, + body: [] + }; + + if (args[0] && args[0].type === "ordgroup") { + var arg0 = ""; + + for (var i = 0; i < args[0].body.length; i++) { + var textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + + numMaths = Number(arg0); + numCols = numMaths * 2; + } + + var isAligned = !numCols; + res.body.forEach(function (row) { + for (var _i4 = 1; _i4 < row.length; _i4 += 2) { + // Modify ordgroup node within styling node + var styling = assertNodeType(row[_i4], "styling"); + var ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + + if (!isAligned) { + // Case 1 + var curMaths = row.length / 2; + + if (numMaths < curMaths) { + throw new ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + + for (var _i5 = 0; _i5 < numCols; ++_i5) { + var align = "r"; + var pregap = 0; + + if (_i5 % 2 === 1) { + align = "l"; + } else if (_i5 > 0 && isAligned) { + // "aligned" mode. + pregap = 1; // add one \quad + } + + cols[_i5] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0 + }; + } + + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; // Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. + + +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; + + if ("lcr".indexOf(ca) !== -1) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":" + }; + } + + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + var res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. + +defineEnvironment({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], + props: { + numArgs: 0 + }, + + handler(context) { + var delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName.replace("*", "")]; // \hskip -\arraycolsep in amsmath + + var colAlign = "c"; + var payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] + }; + + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + var parser = context.parser; + parser.consumeSpaces(); + + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + + if ("lcr".indexOf(colAlign) === -1) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs. + + var numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined // \right uninfluenced by \color in array + + } : res; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0 + }, + + handler(context) { + var payload = { + arraystretch: 0.5 + }; + var res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1 + }, + + handler(context, args) { + // Parsing of {subarray} is similar to {array} + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; // {subarray} only recognizes "l" & "c" + + if ("lc".indexOf(ca) !== -1) { + return { + type: "align", + align: ca + }; + } + + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + + if (cols.length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + + var res = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5 + }; + res = parseArray(context.parser, res, "script"); + + if (res.body.length > 0 && res.body[0].length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + + return res; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. + +defineEnvironment({ + type: "array", + names: ["cases", "dcases", "rcases", "drcases"], + props: { + numArgs: 0 + }, + + handler(context) { + var payload = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 + /* 1em quad */ + + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.indexOf("r") > -1 ? "." : "\\{", + right: context.envName.indexOf("r") > -1 ? "\\}" : ".", + rightColor: undefined + }; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. + +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. + +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0 + }, + + handler(context) { + if (utils$1.contains(["gather", "gather*"], context.envName)) { + validateAmsEnvironmentContext(context); + } + + var res = { + cols: [{ + type: "align", + align: "c" + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. + +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0 + }, + + handler(context) { + validateAmsEnvironmentContext(context); + var res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0 + }, + + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment + +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: true + }, + + handler(context, args) { + throw new ParseError(context.funcName + " valid only within array environment"); + } + +}); + +var environments = _environments; + +// defineEnvironment definitions. + +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + props: { + numArgs: 1, + argTypes: ["text"] + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var nameGroup = args[0]; + + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + + var envName = ""; + + for (var i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError("No such environment: " + envName, nameGroup); + } // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + + + var env = environments[envName]; + var { + args: _args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + var context = { + mode: parser.mode, + envName, + parser + }; + var result = env.handler(context, _args, optArgs); + parser.expect("\\end", false); + var endNameToken = parser.nextToken; + var end = assertNodeType(parser.parseFunction(), "environment"); + + if (end.name !== envName) { + throw new ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } // $FlowFixMe, "environment" handler returns an environment ParseNode + + + return result; + } + + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup + }; + } + +}); + +// TODO(kevinb): implement \\sl and \\sc + +var htmlBuilder$5 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup$1(group.body, newOptions); +}; + +var mathmlBuilder$4 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); +}; + +var fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak", + "\\bm": "\\boldsymbol" +}; +defineFunction({ + type: "font", + names: [// styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak"], + props: { + numArgs: 1, + allowedInArgument: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = normalizeArgument(args[0]); + var func = funcName; + + if (func in fontAliases) { + func = fontAliases[func]; + } + + return { + type: "font", + mode: parser.mode, + font: func.slice(1), + body + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + props: { + numArgs: 1 + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + var isCharacterBox = utils$1.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [{ + type: "font", + mode: parser.mode, + font: "boldsymbol", + body + }], + isCharacterBox: isCharacterBox + }; + } +}); // Old font changing functions + +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref3, args) => { + var { + parser, + funcName, + breakOnTokenText + } = _ref3; + var { + mode + } = parser; + var body = parser.parseExpression(true, breakOnTokenText); + var style = "math" + funcName.slice(1); + return { + type: "font", + mode: mode, + font: style, + body: { + type: "ordgroup", + mode: parser.mode, + body + } + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); + +var adjustStyle = (size, originalStyle) => { + // Figure out what style this fraction should be in based on the + // function used + var style = originalStyle; + + if (size === "display") { + // Get display style as a default. + // If incoming style is sub/sup, use style.text() to get correct size. + style = style.id >= Style$1.SCRIPT.id ? style.text() : Style$1.DISPLAY; + } else if (size === "text" && style.size === Style$1.DISPLAY.size) { + // We're in a \tfrac but incoming style is displaystyle, so: + style = Style$1.TEXT; + } else if (size === "script") { + style = Style$1.SCRIPT; + } else if (size === "scriptscript") { + style = Style$1.SCRIPTSCRIPT; + } + + return style; +}; + +var htmlBuilder$4 = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + var style = adjustStyle(group.size, options.style); + var nstyle = style.fracNum(); + var dstyle = style.fracDen(); + var newOptions; + newOptions = options.havingStyle(nstyle); + var numerm = buildGroup$1(group.numer, newOptions, options); + + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + var hStrut = 8.5 / options.fontMetrics().ptPerEm; + var dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + + newOptions = options.havingStyle(dstyle); + var denomm = buildGroup$1(group.denom, newOptions, options); + var rule; + var ruleWidth; + var ruleSpacing; + + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = buildCommon.makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = buildCommon.makeLineSpan("frac-line", options); + } + + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } // Rule 15b + + + var numShift; + var clearance; + var denomShift; + + if (style.size === Style$1.DISPLAY.size || group.size === "display") { + numShift = options.fontMetrics().num1; + + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + + denomShift = options.fontMetrics().denom2; + } + + var frac; + + if (!rule) { + // Rule 15c + var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + + frac = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } else { + // Rule 15d + var axisHeight = options.fontMetrics().axisHeight; + + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + + var midShift = -(axisHeight - 0.5 * ruleWidth); + frac = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: rule, + shift: midShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + + + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; // Rule 15e + + var delimSize; + + if (style.size === Style$1.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === Style$1.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style$1.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + + var leftDelim; + var rightDelim; + + if (group.leftDelim == null) { + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = delimiter$1.customSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + + if (group.continued) { + rightDelim = buildCommon.makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = delimiter$1.customSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + + return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options); +}; + +var mathmlBuilder$3 = (group, options) => { + var node = new mathMLTree.MathNode("mfrac", [buildGroup(group.numer, options), buildGroup(group.denom, options)]); + + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + var ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + + var style = adjustStyle(group.size, options.style); + + if (style.size !== options.style.size) { + node = new mathMLTree.MathNode("mstyle", [node]); + var isDisplay = style.size === Style$1.DISPLAY.size ? "true" : "false"; + node.setAttribute("displaystyle", isDisplay); + node.setAttribute("scriptlevel", "0"); + } + + if (group.leftDelim != null || group.rightDelim != null) { + var withDelims = []; + + if (group.leftDelim != null) { + var leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]); + leftOp.setAttribute("fence", "true"); + withDelims.push(leftOp); + } + + withDelims.push(node); + + if (group.rightDelim != null) { + var rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]); + rightOp.setAttribute("fence", "true"); + withDelims.push(rightOp); + } + + return makeRow(withDelims); + } + + return node; +}; + +defineFunction({ + type: "genfrac", + names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], + props: { + numArgs: 2, + allowedInArgument: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var numer = args[0]; + var denom = args[1]; + var hasBarLine; + var leftDelim = null; + var rightDelim = null; + var size = "auto"; + + switch (funcName) { + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + + case "\\\\atopfrac": + hasBarLine = false; + break; + + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + + default: + throw new Error("Unrecognized genfrac command"); + } + + switch (funcName) { + case "\\dfrac": + case "\\dbinom": + size = "display"; + break; + + case "\\tfrac": + case "\\tbinom": + size = "text"; + break; + } + + return { + type: "genfrac", + mode: parser.mode, + continued: false, + numer, + denom, + hasBarLine, + leftDelim, + rightDelim, + size, + barSize: null + }; + }, + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); +defineFunction({ + type: "genfrac", + names: ["\\cfrac"], + props: { + numArgs: 2 + }, + handler: (_ref2, args) => { + var { + parser, + funcName + } = _ref2; + var numer = args[0]; + var denom = args[1]; + return { + type: "genfrac", + mode: parser.mode, + continued: true, + numer, + denom, + hasBarLine: true, + leftDelim: null, + rightDelim: null, + size: "display", + barSize: null + }; + } +}); // Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. + +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + props: { + numArgs: 0, + infix: true + }, + + handler(_ref3) { + var { + parser, + funcName, + token + } = _ref3; + var replaceWith; + + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + + case "\\choose": + replaceWith = "\\binom"; + break; + + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + + default: + throw new Error("Unrecognized infix genfrac command"); + } + + return { + type: "infix", + mode: parser.mode, + replaceWith, + token + }; + } + +}); +var stylArray = ["display", "text", "script", "scriptscript"]; + +var delimFromValue = function delimFromValue(delimString) { + var delim = null; + + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + + return delim; +}; + +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + props: { + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"] + }, + + handler(_ref4, args) { + var { + parser + } = _ref4; + var numer = args[4]; + var denom = args[5]; // Look into the parse nodes to get the desired delimiters. + + var leftNode = normalizeArgument(args[0]); + var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + var rightNode = normalizeArgument(args[1]); + var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + var barNode = assertNodeType(args[2], "size"); + var hasBarLine; + var barSize = null; + + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } // Find out if we want displaystyle, textstyle, etc. + + + var size = "auto"; + var styl = args[3]; + + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + var textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)]; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)]; + } + + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim, + size + }; + }, + + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); // \above is an infix fraction that also defines a fraction bar size. + +defineFunction({ + type: "infix", + names: ["\\above"], + props: { + numArgs: 1, + argTypes: ["size"], + infix: true + }, + + handler(_ref5, args) { + var { + parser, + funcName, + token + } = _ref5; + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token + }; + } + +}); +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + props: { + numArgs: 3, + argTypes: ["math", "size", "math"] + }, + handler: (_ref6, args) => { + var { + parser, + funcName + } = _ref6; + var numer = args[0]; + var barSize = assert(assertNodeType(args[1], "infix").size); + var denom = args[2]; + var hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null, + size: "auto" + }; + }, + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +var htmlBuilder$3 = (grp, options) => { + var style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + + var supSubGroup; + var group; + + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? buildGroup$1(grp.sup, options.havingStyle(style.sup()), options) : buildGroup$1(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } // Build the base group + + + var body = buildGroup$1(group.base, options.havingBaseStyle(Style$1.DISPLAY)); // Create the stretchy element + + var braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + + var vlist; + + if (group.isOver) { + vlist = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: braceBody + }] + }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + + vlist.children[0].children[0].children[1].classes.push("svg-align"); + } else { + vlist = buildCommon.makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ + type: "elem", + elem: braceBody + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: body + }] + }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + + vlist.children[0].children[0].children[0].classes.push("svg-align"); + } + + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + var vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); + + if (group.isOver) { + vlist = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: vSpan + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: supSubGroup + }] + }, options); + } else { + vlist = buildCommon.makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth, + children: [{ + type: "elem", + elem: supSubGroup + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: vSpan + }] + }, options); + } + } + + return buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); +}; + +var mathmlBuilder$2 = (group, options) => { + var accentNode = stretchy.mathMLnode(group.label); + return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildGroup(group.base, options), accentNode]); +}; // Horizontal stretchy braces + + +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: /^\\over/.test(funcName), + base: args[0] + }; + }, + + htmlBuilder: htmlBuilder$3, + mathmlBuilder: mathmlBuilder$2 +}); + +defineFunction({ + type: "href", + names: ["\\href"], + props: { + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[1]; + var href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + return buildCommon.makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + var math = buildExpressionRow(group.body, options); + + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + props: { + numArgs: 1, + argTypes: ["url"], + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + + var chars = []; + + for (var i = 0; i < href.length; i++) { + var c = href[i]; + + if (c === "~") { + c = "\\textasciitilde"; + } + + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + + var body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); + +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, false); + return buildCommon.makeFragment(elements); + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", buildExpression(group.body, options)); + } + +}); + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName, + token + } = _ref; + var value = assertNodeType(args[0], "raw").string; + var body = args[1]; + + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + + var trustContext; + var attributes = {}; + + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + + case "\\htmlData": + { + var data = value.split(","); + + for (var i = 0; i < data.length; i++) { + var keyVal = data[i].split("="); + + if (keyVal.length !== 2) { + throw new ParseError("Error parsing key-value for \\htmlData"); + } + + attributes["data-" + keyVal[0].trim()] = keyVal[1].trim(); + } + + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + + default: + throw new Error("Unrecognized html command"); + } + + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + var classes = ["enclosing"]; + + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + + var span = buildCommon.makeSpan(classes, elements, options); + + for (var attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); + } +}); + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + props: { + numArgs: 2, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.html, options, false); + return buildCommon.makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.mathml, options); + } +}); + +var sizeData = function sizeData(str) { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return { + number: +str, + unit: "bp" + }; + } else { + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + + if (!match) { + throw new ParseError("Invalid size: '" + str + "' in \\includegraphics"); + } + + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics."); + } + + return data; + } +}; + +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + props: { + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false + }, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var width = { + number: 0, + unit: "em" + }; + var height = { + number: 0.9, + unit: "em" + }; // sorta character sized. + + var totalheight = { + number: 0, + unit: "em" + }; + var alt = ""; + + if (optArgs[0]) { + var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string. + + var attributes = attributeStr.split(","); + + for (var i = 0; i < attributes.length; i++) { + var keyVal = attributes[i].split("="); + + if (keyVal.length === 2) { + var str = keyVal[1].trim(); + + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + + case "width": + width = sizeData(str); + break; + + case "height": + height = sizeData(str); + break; + + case "totalheight": + totalheight = sizeData(str); + break; + + default: + throw new ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics."); + } + } + } + } + + var src = assertNodeType(args[0], "url").url; + + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src + }; + }, + htmlBuilder: (group, options) => { + var height = calculateSize(group.height, options); + var depth = 0; + + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + + var width = 0; + + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + + var style = { + height: makeEm(height + depth) + }; + + if (width > 0) { + style.width = makeEm(width); + } + + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + + var node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + return node; + }, + mathmlBuilder: (group, options) => { + var node = new mathMLTree.MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + var height = calculateSize(group.height, options); + var depth = 0; + + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + + node.setAttribute("height", makeEm(height + depth)); + + if (group.width.number > 0) { + var width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + + node.setAttribute("src", group.src); + return node; + } +}); + +// Horizontal spacing commands + +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + props: { + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var size = assertNodeType(args[0], "size"); + + if (parser.settings.strict) { + var mathFunction = funcName[1] === 'm'; // \mkern, \mskip + + var muUnit = size.value.unit === 'mu'; + + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); + } + + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); + } + } else { + // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); + } + } + } + + return { + type: "kern", + mode: parser.mode, + dimension: size.value + }; + }, + + htmlBuilder(group, options) { + return buildCommon.makeGlue(group.dimension, options); + }, + + mathmlBuilder(group, options) { + var dimension = calculateSize(group.dimension, options); + return new mathMLTree.SpaceNode(dimension); + } + +}); + +// Horizontal overlap functions +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var inner; + + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = buildCommon.makeSpan([], [buildGroup$1(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span + + inner = buildCommon.makeSpan(["inner"], [inner], options); + } else { + inner = buildCommon.makeSpan(["inner"], [buildGroup$1(group.body, options)]); + } + + var fix = buildCommon.makeSpan(["fix"], []); + var node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + + var strut = buildCommon.makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + + node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + + node = buildCommon.makeSpan(["thinbox"], [node], options); + return buildCommon.makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + + if (group.alignment !== "rlap") { + var offset = group.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + + node.setAttribute("width", "0px"); + return node; + } +}); + +defineFunction({ + type: "styling", + names: ["\\(", "$"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + + handler(_ref, args) { + var { + funcName, + parser + } = _ref; + var outerMode = parser.mode; + parser.switchMode("math"); + var close = funcName === "\\(" ? "\\)" : "$"; + var body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + body + }; + } + +}); // Check for extra closing math delimiters + +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\)", "\\]"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + + handler(context, args) { + throw new ParseError("Mismatched " + context.funcName); + } + +}); + +var chooseMathStyle = (group, options) => { + switch (options.style.size) { + case Style$1.DISPLAY.size: + return group.display; + + case Style$1.TEXT.size: + return group.text; + + case Style$1.SCRIPT.size: + return group.script; + + case Style$1.SCRIPTSCRIPT.size: + return group.scriptscript; + + default: + return group.text; + } +}; + +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + props: { + numArgs: 4, + primitive: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) + }; + }, + htmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + var elements = buildExpression$1(body, options, false); + return buildCommon.makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + return buildExpressionRow(body, options); + } +}); + +var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { + base = buildCommon.makeSpan([], [base]); + var subIsSingleCharacter = subGroup && utils$1.isCharacterBox(subGroup); + var sub; + var sup; // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + + if (supGroup) { + var elem = buildGroup$1(supGroup, options.havingStyle(style.sup()), options); + sup = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + + if (subGroup) { + var _elem = buildGroup$1(subGroup, options.havingStyle(style.sub()), options); + + sub = { + elem: _elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) + }; + } // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + + + var finalGroup; + + if (sup && sub) { + var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + finalGroup = buildCommon.makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else if (sub) { + var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + + finalGroup = buildCommon.makeVList({ + positionType: "top", + positionData: top, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }] + }, options); + } else if (sup) { + var _bottom = base.depth + baseShift; + + finalGroup = buildCommon.makeVList({ + positionType: "bottom", + positionData: _bottom, + children: [{ + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + + var parts = [finalGroup]; + + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + var spacer = buildCommon.makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + + return buildCommon.makeSpan(["mop", "op-limits"], parts, options); +}; + +// Limits, symbols +// Most operators have a large successor symbol, but these don't. +var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. + +var htmlBuilder$2 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + + var style = options.style; + var large = false; + + if (style.size === Style$1.DISPLAY.size && group.symbol && !utils$1.contains(noSuccessor, group.name)) { + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + + var base; + + if (group.symbol) { + // If this is a symbol, create the symbol. + var fontName = large ? "Size2-Regular" : "Size1-Regular"; + var stash = ""; + + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + + base = buildCommon.makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + var italic = base.italic; + var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options); + base = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: base, + shift: 0 + }, { + type: "elem", + elem: oval, + shift: large ? 0.08 : 0 + }] + }, options); + group.name = "\\" + stash; + base.classes.unshift("mop"); // $FlowFixMe + + base.italic = italic; + } + } else if (group.body) { + // If this is a list, compose that list. + var inner = buildExpression$1(group.body, options, true); + + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = buildCommon.makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + var output = []; + + for (var i = 1; i < group.name.length; i++) { + output.push(buildCommon.mathsym(group.name[i], group.mode, options)); + } + + base = buildCommon.makeSpan(["mop"], output, options); + } // If content of op is a single symbol, shift it vertically. + + + var baseShift = 0; + var slant = 0; + + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; // The slant of the symbol is just its italic correction. + // $FlowFixMe + + slant = base.italic; + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + + return base; + } +}; + +var mathmlBuilder$1 = (group, options) => { + var node; + + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode("mo", [makeText(group.name, group.mode)]); + + if (utils$1.contains(noSuccessor, group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode("mo", buildExpression(group.body, options)); + } else { + // This is a text operator. Add all of the characters from the + // operator's name. + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + + var operator = new MathNode("mo", [makeText("\u2061", "text")]); + + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + + return node; +}; + +var singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" +}; +defineFunction({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], + props: { + numArgs: 0 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var fName = funcName; + + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. + +defineFunction({ + type: "op", + names: ["\\mathop"], + props: { + numArgs: 1, + primitive: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body) + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. + +var singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint" +}; // No limits, not symbols + +defineFunction({ + type: "op", + names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], + props: { + numArgs: 0 + }, + + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // Limits, not symbols + +defineFunction({ + type: "op", + names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"], + props: { + numArgs: 0 + }, + + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // No limits, symbols + +defineFunction({ + type: "op", + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], + props: { + numArgs: 0 + }, + + handler(_ref5) { + var { + parser, + funcName + } = _ref5; + var fName = funcName; + + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +var htmlBuilder$1 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + + var base; + + if (group.body.length > 0) { + var body = group.body.map(child => { + // $FlowFixMe: Check if the node has a string `text` property. + var childText = child.text; + + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText + }; + } else { + return child; + } + }); // Consolidate function names into symbol characters. + + var expression = buildExpression$1(body, options.withFont("mathrm"), true); + + for (var i = 0; i < expression.length; i++) { + var child = expression[i]; + + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } + } + + base = buildCommon.makeSpan(["mop"], expression, options); + } else { + base = buildCommon.makeSpan(["mop"], [], options); + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + } else { + return base; + } +}; + +var mathmlBuilder = (group, options) => { + // The steps taken here are similar to the html version. + var expression = buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction? + + var isAllString = true; // default + + for (var i = 0; i < expression.length; i++) { + var node = expression[i]; + + if (node instanceof mathMLTree.SpaceNode) ; else if (node instanceof mathMLTree.MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "ms": + case "mspace": + case "mtext": + break; + // Do nothing yet. + + case "mo": + { + var child = node.children[0]; + + if (node.children.length === 1 && child instanceof mathMLTree.TextNode) { + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } else { + isAllString = false; + } + + break; + } + + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + var word = expression.map(node => node.toText()).join(""); + expression = [new mathMLTree.TextNode(word)]; + } + + var identifier = new mathMLTree.MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + + var operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]); + + if (group.parentIsSupSub) { + return new mathMLTree.MathNode("mrow", [identifier, operator]); + } else { + return mathMLTree.newDocumentFragment([identifier, operator]); + } +}; // \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ + + +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", + limits: false, + parentIsSupSub: false + }; + }, + htmlBuilder: htmlBuilder$1, + mathmlBuilder +}); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); + +defineFunctionBuilders({ + type: "ordgroup", + + htmlBuilder(group, options) { + if (group.semisimple) { + return buildCommon.makeFragment(buildExpression$1(group.body, options, false)); + } + + return buildCommon.makeSpan(["mord"], buildExpression$1(group.body, options, true), options); + }, + + mathmlBuilder(group, options) { + return buildExpressionRow(group.body, options, true); + } + +}); + +defineFunction({ + type: "overline", + names: ["\\overline"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "overline", + mode: parser.mode, + body + }; + }, + + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + // Build the inner group in the cramped style. + var innerGroup = buildGroup$1(group.body, options.havingCrampedStyle()); // Create the line above the body + + var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns + + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: innerGroup + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: defaultRuleThickness + }] + }, options); + return buildCommon.makeSpan(["mord", "overline"], [vlist], options); + }, + + mathmlBuilder(group, options) { + var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new mathMLTree.MathNode("mover", [buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + return node; + } + +}); + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + + return buildCommon.makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(group.body, options); + return new mathMLTree.MathNode("mphantom", inner); + } +}); +defineFunction({ + type: "hphantom", + names: ["\\hphantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "hphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + var node = buildCommon.makeSpan([], [buildGroup$1(group.body, options.withPhantom())]); + node.height = 0; + node.depth = 0; + + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + node.children[i].height = 0; + node.children[i].depth = 0; + } + } // See smash for comment re: use of makeVList + + + node = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }, options); // For spacing, TeX treats \smash as a math group (same spacing as ord). + + return buildCommon.makeSpan(["mord"], [node], options); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(ordargument(group.body), options); + var phantom = new mathMLTree.MathNode("mphantom", inner); + var node = new mathMLTree.MathNode("mpadded", [phantom]); + node.setAttribute("height", "0px"); + node.setAttribute("depth", "0px"); + return node; + } +}); +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref3, args) => { + var { + parser + } = _ref3; + var body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + var inner = buildCommon.makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]); + var fix = buildCommon.makeSpan(["fix"], []); + return buildCommon.makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(ordargument(group.body), options); + var phantom = new mathMLTree.MathNode("mphantom", inner); + var node = new mathMLTree.MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + } +}); + +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + props: { + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var amount = assertNodeType(args[0], "size").value; + var body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body + }; + }, + + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var dy = calculateSize(group.dy, options); + return buildCommon.makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + var dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + } + +}); + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + var { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } + +}); + +defineFunction({ + type: "rule", + names: ["\\rule"], + props: { + numArgs: 2, + numOptionalArgs: 1, + argTypes: ["size", "size", "size"] + }, + + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var shift = optArgs[0]; + var width = assertNodeType(args[0], "size"); + var height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value + }; + }, + + htmlBuilder(group, options) { + // Make an empty span for the rule + var rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units + + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size + + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); // Record the height and width + + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + return rule; + }, + + mathmlBuilder(group, options) { + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + var color = options.color && options.getColor() || "black"; + var rule = new mathMLTree.MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + var wrapper = new mathMLTree.MathNode("mpadded", [rule]); + + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + + wrapper.setAttribute("voffset", makeEm(shift)); + return wrapper; + } + +}); + +function sizingGroup(value, options, baseOptions) { + var inner = buildExpression$1(value, options, false); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + + for (var i = 0; i < inner.length; i++) { + var pos = inner[i].classes.indexOf("sizing"); + + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + + return buildCommon.makeFragment(inner); +} +var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +var htmlBuilder = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + var newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; +defineFunction({ + type: "sizing", + names: sizeFuncs, + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref, args) => { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + var body = parser.parseExpression(false, breakOnTokenText); + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body + }; + }, + htmlBuilder, + mathmlBuilder: (group, options) => { + var newOptions = options.havingSize(group.size); + var inner = buildExpression(group.body, newOptions); + var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + return node; + } +}); + +// smash, with optional [tb], as in AMS +defineFunction({ + type: "smash", + names: ["\\smash"], + props: { + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true + }, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var smashHeight = false; + var smashDepth = false; + var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + var letter = ""; + + for (var i = 0; i < tbArg.body.length; ++i) { + var node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property. + + letter = node.text; + + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + + var body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth + }; + }, + htmlBuilder: (group, options) => { + var node = buildCommon.makeSpan([], [buildGroup$1(group.body, options)]); + + if (!group.smashHeight && !group.smashDepth) { + return node; + } + + if (group.smashHeight) { + node.height = 0; // In order to influence makeVList, we have to reset the children. + + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + node.children[i].height = 0; + } + } + } + + if (group.smashDepth) { + node.depth = 0; + + if (node.children) { + for (var _i = 0; _i < node.children.length; _i++) { + node.children[_i].depth = 0; + } + } + } // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + + var smashedNode = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }, options); // For spacing, TeX treats \hphantom as a math group (same spacing as ord). + + return buildCommon.makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + + return node; + } +}); + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var index = optArgs[0]; + var body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index + }; + }, + + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + // First, we do the same steps as in overline to build the inner group + // and line + var inner = buildGroup$1(group.body, options.havingCrampedStyle()); + + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } // Some groups can return document fragments. Handle those by wrapping + // them in a span. + + + inner = buildCommon.wrapFragment(inner, options); // Calculate the minimum size for the \surd delimiter + + var metrics = options.fontMetrics(); + var theta = metrics.defaultRuleThickness; + var phi = theta; + + if (options.style.id < Style$1.TEXT.id) { + phi = options.fontMetrics().xHeight; + } // Calculate the clearance between the body and line + + + var lineClearance = theta + phi / 4; + var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size + + var { + span: img, + ruleWidth, + advanceWidth + } = delimiter$1.sqrtImage(minDelimiterHeight, options); + var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size + + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } // Shift the sqrt image + + + var imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument. + + var body = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: inner, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: -(inner.height + imgShift) + }, { + type: "elem", + elem: img + }, { + type: "kern", + size: ruleWidth + }] + }, options); + + if (!group.index) { + return buildCommon.makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + // The index is always in scriptscript style + var newOptions = options.havingStyle(Style$1.SCRIPTSCRIPT); + var rootm = buildGroup$1(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + + var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly + + var rootVList = buildCommon.makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ + type: "elem", + elem: rootm + }] + }, options); // Add a class surrounding it so we can add on the appropriate + // kerning + + var rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]); + return buildCommon.makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); + } + }, + + mathmlBuilder(group, options) { + var { + body, + index + } = group; + return index ? new mathMLTree.MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new mathMLTree.MathNode("msqrt", [buildGroup(body, options)]); + } + +}); + +var styleMap = { + "display": Style$1.DISPLAY, + "text": Style$1.TEXT, + "script": Style$1.SCRIPT, + "scriptscript": Style$1.SCRIPTSCRIPT +}; +defineFunction({ + type: "styling", + names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref, args) { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + // parse out the implicit body + var body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + // $FlowFixMe: The names above exactly match the styles. + + var style = funcName.slice(1, funcName.length - 5); + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body + }; + }, + + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle).withFont(''); + return sizingGroup(group.body, newOptions, options); + }, + + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + var inner = buildExpression(group.body, newOptions); + var node = new mathMLTree.MathNode("mstyle", inner); + var styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"] + }; + var attr = styleAttributes[group.style]; + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + return node; + } + +}); + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { + var base = group.base; + + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + var delegate = base.limits && (options.style.size === Style$1.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? htmlBuilder$2 : null; + } else if (base.type === "operatorname") { + var _delegate = base.alwaysHandleSupSub && (options.style.size === Style$1.DISPLAY.size || base.limits); + + return _delegate ? htmlBuilder$1 : null; + } else if (base.type === "accent") { + return utils$1.isCharacterBox(base.base) ? htmlBuilder$a : null; + } else if (base.type === "horizBrace") { + var isSup = !group.sub; + return isSup === base.isOver ? htmlBuilder$3 : null; + } else { + return null; + } +}; // Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. + + +defineFunctionBuilders({ + type: "supsub", + + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + var builderDelegate = htmlBuilderDelegate(group, options); + + if (builderDelegate) { + return builderDelegate(group, options); + } + + var { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + var base = buildGroup$1(valueBase, options); + var supm; + var subm; + var metrics = options.fontMetrics(); // Rule 18a + + var supShift = 0; + var subShift = 0; + var isCharacterBox = valueBase && utils$1.isCharacterBox(valueBase); + + if (valueSup) { + var newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup$1(valueSup, newOptions, options); + + if (!isCharacterBox) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + if (valueSub) { + var _newOptions = options.havingStyle(options.style.sub()); + + subm = buildGroup$1(valueSub, _newOptions, options); + + if (!isCharacterBox) { + subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier; + } + } // Rule 18c + + + var minSupShift; + + if (options.style === Style$1.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + + + var multiplier = options.sizeMultiplier; + var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + var marginLeft = null; + + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + + if (base instanceof SymbolNode || isOiint) { + // $FlowFixMe + marginLeft = makeEm(-base.italic); + } + } + + var supsub; + + if (supm && subm) { + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + var ruleWidth = metrics.defaultRuleThickness; // Rule 18e + + var maxWidth = 4 * ruleWidth; + + if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + + var vlistElem = [{ + type: "elem", + elem: subm, + shift: subShift, + marginRight, + marginLeft + }, { + type: "elem", + elem: supm, + shift: -supShift, + marginRight + }]; + supsub = buildCommon.makeVList({ + positionType: "individualShift", + children: vlistElem + }, options); + } else if (subm) { + // Rule 18b + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + var _vlistElem = [{ + type: "elem", + elem: subm, + marginLeft, + marginRight + }]; + supsub = buildCommon.makeVList({ + positionType: "shift", + positionData: subShift, + children: _vlistElem + }, options); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + supsub = buildCommon.makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ + type: "elem", + elem: supm, + marginRight + }] + }, options); + } else { + throw new Error("supsub must have either sup or sub."); + } // Wrap the supsub vlist in a span.msupsub to reset text-align. + + + var mclass = getTypeOfDomTree(base, "right") || "mord"; + return buildCommon.makeSpan([mclass], [base, buildCommon.makeSpan(["msupsub"], [supsub])], options); + }, + + mathmlBuilder(group, options) { + // Is the inner group a relevant horizonal brace? + var isBrace = false; + var isOver; + var isSup; + + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + + if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + + var children = [buildGroup(group.base, options)]; + + if (group.sub) { + children.push(buildGroup(group.sub, options)); + } + + if (group.sup) { + children.push(buildGroup(group.sup, options)); + } + + var nodeType; + + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.sub) { + var base = group.base; + + if (base && base.type === "op" && base.limits && (options.style === Style$1.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === Style$1.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + var _base = group.base; + + if (_base && _base.type === "op" && _base.limits && (options.style === Style$1.DISPLAY || _base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === Style$1.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + var _base2 = group.base; + + if (_base2 && _base2.type === "op" && _base2.limits && options.style === Style$1.DISPLAY) { + nodeType = "munderover"; + } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === Style$1.DISPLAY || _base2.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + + return new mathMLTree.MathNode(nodeType, children); + } + +}); + +defineFunctionBuilders({ + type: "atom", + + htmlBuilder(group, options) { + return buildCommon.mathsym(group.text, group.mode, options, ["m" + group.family]); + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]); + + if (group.family === "bin") { + var variant = getVariant(group, options); + + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + + return node; + } + +}); + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. +var defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; +defineFunctionBuilders({ + type: "mathord", + + htmlBuilder(group, options) { + return buildCommon.makeOrd(group, options, "mathord"); + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]); + var variant = getVariant(group, options) || "italic"; + + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + + return node; + } + +}); +defineFunctionBuilders({ + type: "textord", + + htmlBuilder(group, options) { + return buildCommon.makeOrd(group, options, "textord"); + }, + + mathmlBuilder(group, options) { + var text = makeText(group.text, group.mode, options); + var variant = getVariant(group, options) || "normal"; + var node; + + if (group.mode === 'text') { + node = new mathMLTree.MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new mathMLTree.MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new mathMLTree.MathNode("mo", [text]); + } else { + node = new mathMLTree.MathNode("mi", [text]); + } + + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + + return node; + } + +}); + +var cssSpace = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak" +}; // A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. + +var regularSpace = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak" + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak" + } +}; // ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. + +defineFunctionBuilders({ + type: "spacing", + + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + var className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + + if (group.mode === "text") { + var ord = buildCommon.makeOrd(group, options, "textord"); + ord.classes.push(className); + return ord; + } else { + return buildCommon.makeSpan(["mspace", className], [buildCommon.mathsym(group.text, group.mode, options)], options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return buildCommon.makeSpan(["mspace", cssSpace[group.text]], [], options); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + }, + + mathmlBuilder(group, options) { + var node; + + if (regularSpace.hasOwnProperty(group.text)) { + node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new mathMLTree.MathNode("mspace"); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + + return node; + } + +}); + +var pad = () => { + var padNode = new mathMLTree.MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; + +defineFunctionBuilders({ + type: "tag", + + mathmlBuilder(group, options) { + var table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + table.setAttribute("width", "100%"); + return table; // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + } + +}); + +var textFontFamilies = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm" +}; +var textFontWeights = { + "\\textbf": "textbf", + "\\textmd": "textmd" +}; +var textFontShapes = { + "\\textit": "textit", + "\\textup": "textup" +}; + +var optionsWithFont = (group, options) => { + var font = group.font; // Checks if the argument is a font family or a font style. + + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else { + return options.withTextFontShape(textFontShapes[font]); + } +}; + +defineFunction({ + type: "text", + names: [// Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", // Font weights + "\\textbf", "\\textmd", // Font Shapes + "\\textit", "\\textup"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName + }; + }, + + htmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + var inner = buildExpression$1(group.body, newOptions, true); + return buildCommon.makeSpan(["mord", "text"], inner, newOptions); + }, + + mathmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + return buildExpressionRow(group.body, newOptions); + } + +}); + +defineFunction({ + type: "underline", + names: ["\\underline"], + props: { + numArgs: 1, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "underline", + mode: parser.mode, + body: args[0] + }; + }, + + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + var innerGroup = buildGroup$1(group.body, options); // Create the line to go below the body + + var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns + + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = buildCommon.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "kern", + size: defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return buildCommon.makeSpan(["mord", "underline"], [vlist], options); + }, + + mathmlBuilder(group, options) { + var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new mathMLTree.MathNode("munder", [buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + return node; + } + +}); + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var axisHeight = options.fontMetrics().axisHeight; + var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return buildCommon.makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + return new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)], ["vcenter"]); + } + +}); + +defineFunction({ + type: "verb", + names: ["\\verb"], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new ParseError("\\verb ended by end of line instead of matching delimiter"); + }, + + htmlBuilder(group, options) { + var text = makeVerb(group); + var body = []; // \verb enters text mode and therefore is sized like \textstyle + + var newOptions = options.havingStyle(options.style.text()); + + for (var i = 0; i < text.length; i++) { + var c = text[i]; + + if (c === '~') { + c = '\\textasciitilde'; + } + + body.push(buildCommon.makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"])); + } + + return buildCommon.makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), buildCommon.tryCombineChars(body), newOptions); + }, + + mathmlBuilder(group, options) { + var text = new mathMLTree.TextNode(makeVerb(group)); + var node = new mathMLTree.MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + } + +}); +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ + +var makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); + +/** Include this to ensure that all functions are defined. */ +var functions = _functions; + +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ + +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +var spaceRegexString = "[ \r\n\t]"; +var controlWordRegexString = "\\\\[a-zA-Z@]+"; +var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +var combiningDiacriticalMarkString = "[\u0300-\u036f]"; +var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +var tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace +controlSpaceRegexString + "|") + // \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint +combiningDiacriticalMarkString + "*") + // ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair +combiningDiacriticalMarkString + "*") + // ...plus accents +"|\\\\verb\\*([^]).*?\\4" + // \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred +"|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. + +/** Main Lexer class */ + +class Lexer { + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + constructor(input, settings) { + this.input = void 0; + this.settings = void 0; + this.tokenRegex = void 0; + this.catcodes = void 0; + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, + // comment character + "~": 13 // active character + + }; + } + + setCatcode(char, code) { + this.catcodes[char] = code; + } + /** + * This function lexes a single token. + */ + + + lex() { + var input = this.input; + var pos = this.tokenRegex.lastIndex; + + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + + var match = this.tokenRegex.exec(input); + + if (match === null || match.index !== pos) { + throw new ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + + var text = match[6] || match[3] || (match[2] ? "\\ " : " "); + + if (this.catcodes[text] === 14) { + // comment character + var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + + this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + + return this.lex(); + } + + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } + +} + +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ +class Namespace { + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins, globalMacros) { + if (builtins === void 0) { + builtins = {}; + } + + if (globalMacros === void 0) { + globalMacros = {}; + } + + this.current = void 0; + this.builtins = void 0; + this.undefStack = void 0; + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + /** + * Start a new nested group, affecting future local `set`s. + */ + + + beginGroup() { + this.undefStack.push({}); + } + /** + * End current nested group, restoring values before the group began. + */ + + + endGroup() { + if (this.undefStack.length === 0) { + throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); + } + + var undefs = this.undefStack.pop(); + + for (var undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + + + has(name) { + return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); + } + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + + + get(name) { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + + + set(name, value, global) { + if (global === void 0) { + global = false; + } + + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (var i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + var top = this.undefStack[this.undefStack.length - 1]; + + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } + +} + +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ +var macros = _macros; +// macro tools + +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + var t = context.popToken(); + + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + var t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + + return { + tokens: [t], + numArgs: 0 + }; +}); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} + +defineMacro("\\@firstoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[0], + numArgs: 0 + }; +}); // LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} + +defineMacro("\\@secondoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[1], + numArgs: 0 + }; +}); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. + +defineMacro("\\@ifnextchar", function (context) { + var args = context.consumeArgs(3); // symbol, if, else + + context.consumeSpaces(); + var nextToken = context.future(); + + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { + tokens: args[1], + numArgs: 0 + }; + } else { + return { + tokens: args[2], + numArgs: 0 + }; + } +}); // LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} + +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode + +defineMacro("\\TextOrMath", function (context) { + var args = context.consumeArgs(2); + + if (context.mode === 'text') { + return { + tokens: args[0], + numArgs: 0 + }; + } else { + return { + tokens: args[1], + numArgs: 0 + }; + } +}); // Lookup table for parsing numbers in base 8 through 16 + +var digitToNumber = { + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "a": 10, + "A": 10, + "b": 11, + "B": 11, + "c": 12, + "C": 12, + "d": 13, + "D": 13, + "e": 14, + "E": 14, + "f": 15, + "F": 15 +}; // TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. + +defineMacro("\\char", function (context) { + var token = context.popToken(); + var base; + var number = ''; + + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + + if (number == null || number >= base) { + throw new ParseError("Invalid base-" + base + " digit " + token.text); + } + + var digit; + + while ((digit = digitToNumber[context.future().text]) != null && digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + + return "\\@char{" + number + "}"; +}); // \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} + +var newcommand = (context, existsOK, nonexistsOK) => { + var arg = context.consumeArg().tokens; + + if (arg.length !== 1) { + throw new ParseError("\\newcommand's first argument must be a macro name"); + } + + var name = arg[0].text; + var exists = context.isDefined(name); + + if (exists && !existsOK) { + throw new ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); + } + + if (!exists && !nonexistsOK) { + throw new ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); + } + + var numArgs = 0; + arg = context.consumeArg().tokens; + + if (arg.length === 1 && arg[0].text === "[") { + var argText = ''; + var token = context.expandNextToken(); + + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new ParseError("Invalid number of arguments: " + argText); + } + + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } // Final arg is the expansion of the macro + + + context.macros.set(name, { + tokens: arg, + numArgs + }); + return ''; +}; + +defineMacro("\\newcommand", context => newcommand(context, false, true)); +defineMacro("\\renewcommand", context => newcommand(context, true, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true)); // terminal (console) tools + +defineMacro("\\message", context => { + var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + var tok = context.popToken(); + var name = tok.text; // eslint-disable-next-line no-console + + console.log(tok, context.macros.get(name), functions[name], symbols.math[name], symbols.text[name]); + return ''; +}); ////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} + +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); // Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} + +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); // Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} + +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); // Characters omitted from Unicode range 1D400–1D7FF + +defineMacro("\u212C", "\\mathscr{B}"); // script + +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur + +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); // Define \Bbbk with a macro that works in both HTML and MathML. + +defineMacro("\\Bbbk", "\\Bbb{k}"); // Unicode middle dot +// The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays +// the dot at U+22C5 and gives it punct spacing. + +defineMacro("\u00b7", "\\cdotp"); // \llap and \rlap render their contents in text mode + +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \mathstrut from the TeXbook, p 360 + +defineMacro("\\mathstrut", "\\vphantom{(}"); // \underbar from TeXbook p 353 + +defineMacro("\\underbar", "\\underline{\\text{#1}}"); // \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. + +defineMacro("\\not", '\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'); // Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} + +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); // Unicode stacked relations + +defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); // Misc Unicode + +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); +defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. + +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); ////////////////////////////////////////////////////////////////////// +// LaTeX_2ε +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. + +defineMacro("\\vdots", "\\mathord{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); ////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. + +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} + +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} + +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} + +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} + +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); // AMSMath's automatic \dots, based on \mdots@@ macro. + +var dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + var thedots = '\\dotso'; + var next = context.expandAfterFuture().text; + + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in symbols.math) { + if (utils$1.contains(['bin', 'rel'], symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + + return thedots; +}); +var spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; +defineMacro("\\dotso", function (context) { + var next = context.future().text; + + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\dotsc", function (context) { + var next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\cdots", function (context) { + var next = context.future().text; + + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); // amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. + +defineMacro("\\dotsx", "\\ldots\\,"); // \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax + +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); // Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} + +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); // \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip + +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); // \let\thinspace\, + +defineMacro("\\thinspace", "\\,"); // \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu + +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); // \let\medspace\: + +defineMacro("\\medspace", "\\:"); // \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu + +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); // \let\thickspace\; + +defineMacro("\\thickspace", "\\;"); // \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip + +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); // \let\negthinspace\! + +defineMacro("\\negthinspace", "\\!"); // \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip + +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); // \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip + +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); // \def\enspace{\kern.5em } + +defineMacro("\\enspace", "\\kern.5em "); // \def\enskip{\hskip.5em\relax} + +defineMacro("\\enskip", "\\hskip.5em\\relax"); // \def\quad{\hskip1em\relax} + +defineMacro("\\quad", "\\hskip1em\\relax"); // \def\qquad{\hskip2em\relax} + +defineMacro("\\qquad", "\\hskip2em\\relax"); // \tag@in@display form of \tag + +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", context => { + if (context.macros.get("\\df@tag")) { + throw new ParseError("Multiple \\tag"); + } + + return "\\gdef\\df@tag{\\text{#1}}"; +}); // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu + +defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); ////////////////////////////////////////////////////////////////////// +// LaTeX source2e +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} + +defineMacro("\\newline", "\\\\\\relax"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. + +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); // \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). + +var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo + +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} + +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); ////////////////////////////////////////////////////////////////////// +// mathtools.sty +//\providecommand\ordinarycolon{:} + +defineMacro("\\ordinarycolon", ":"); //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 + +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} + +defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} + +defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} + +defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} + +defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} + +defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} + +defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} + +defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} + +defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} + +defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} + +defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} + +defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} + +defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} + +defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); // Some Unicode characters are implemented with macros to mathtools functions. + +defineMacro("\u2237", "\\dblcolon"); // :: + +defineMacro("\u2239", "\\eqcolon"); // -: + +defineMacro("\u2254", "\\coloneqq"); // := + +defineMacro("\u2255", "\\eqqcolon"); // =: + +defineMacro("\u2A74", "\\Coloneqq"); // ::= +////////////////////////////////////////////////////////////////////// +// colonequals.sty +// Alternate names for mathtools's macros: + +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); // \colonapprox name is same in mathtools and colonequals. + +defineMacro("\\coloncolonapprox", "\\Colonapprox"); // \colonsim name is same in mathtools and colonequals. + +defineMacro("\\coloncolonsim", "\\Colonsim"); // Additional macros, implemented by analogy with mathtools definitions: + +defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); // Present in newtxmath, pxfonts and txfonts + +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); ////////////////////////////////////////////////////////////////////// +// From amsopn.sty + +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); ////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area + +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); ////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. + +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ + +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] + +defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); +defineMacro("\u2983", "\\lBrace"); // blackboard bold { + +defineMacro("\u2984", "\\rBrace"); // blackboard bold } +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. + +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); ////////////////////////////////////////////////////////////////////// +// texvc.sty +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax +// We also omit texvc's \O, which conflicts with \text{\O} + +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); // TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); + +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); ////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); ////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); + +var braketHelper = one => context => { + var left = context.consumeArg().tokens; + var middle = context.consumeArg().tokens; + var middleDouble = context.consumeArg().tokens; + var right = context.consumeArg().tokens; + var oldMiddle = context.macros.get("|"); + var oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + + var midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + + var doubled = double; + + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + var nextToken = context.future(); + + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + + context.macros.set("|", midMacro(false)); + + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + + var arg = context.consumeArg().tokens; + var expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; + +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); // has no support for special || or \| +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx + +defineMacro("\\angln", "{\\angl n}"); // Custom Khan Academy colors, should be moved to an optional package + +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); + +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +var implicitCommands = { + "^": true, + // Parser.js + "_": true, + // Parser.js + "\\limits": true, + // Parser.js + "\\nolimits": true // Parser.js + +}; +class MacroExpander { + constructor(input, settings, mode) { + this.settings = void 0; + this.expansionCount = void 0; + this.lexer = void 0; + this.macros = void 0; + this.stack = void 0; + this.mode = void 0; + this.settings = settings; + this.expansionCount = 0; + this.feed(input); // Make new global namespace + + this.macros = new Namespace(macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + + + feed(input) { + this.lexer = new Lexer(input, this.settings); + } + /** + * Switches between "text" and "math" modes. + */ + + + switchMode(newMode) { + this.mode = newMode; + } + /** + * Start a new group nesting within all namespaces. + */ + + + beginGroup() { + this.macros.beginGroup(); + } + /** + * End current group nesting within all namespaces. + */ + + + endGroup() { + this.macros.endGroup(); + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + this.macros.endGroups(); + } + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + + + future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + + return this.stack[this.stack.length - 1]; + } + /** + * Remove and return the next unexpanded token. + */ + + + popToken() { + this.future(); // ensure non-empty stack + + return this.stack.pop(); + } + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + + + pushToken(token) { + this.stack.push(token); + } + /** + * Append an array of tokens to the token stack. + */ + + + pushTokens(tokens) { + this.stack.push(...tokens); + } + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + + + scanArgument(isOptional) { + var start; + var end; + var tokens; + + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + + if (this.future().text !== "[") { + return null; + } + + start = this.popToken(); // don't include [ in tokens + + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } // indicate the end of an argument + + + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return start.range(end, ""); + } + /** + * Consume all following space tokens, without expansion. + */ + + + consumeSpaces() { + for (;;) { + var token = this.future(); + + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + + + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + var tokens = []; + var isDelimited = delims && delims.length > 0; + + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + + var start = this.future(); + var tok; + var depth = 0; + var match = 0; + + do { + tok = this.popToken(); + tokens.push(tok); + + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + + + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + + tokens.reverse(); // to fit in with stack order + + return { + tokens, + start, + end: tok + }; + } + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + + + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError("The length of delimiters doesn't match the number of args!"); + } + + var delims = delimiters[0]; + + for (var i = 0; i < delims.length; i++) { + var tok = this.popToken(); + + if (delims[i] !== tok.text) { + throw new ParseError("Use of the macro doesn't match its definition", tok); + } + } + } + + var args = []; + + for (var _i = 0; _i < numArgs; _i++) { + args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens); + } + + return args; + } + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + + + countExpansion(amount) { + this.expansionCount += amount; + + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + + + expandOnce(expandableOnly) { + var topToken = this.popToken(); + var name = topToken.text; + var expansion = !topToken.noexpand ? this._getExpansion(name) : null; + + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } + + this.pushToken(topToken); + return false; + } + + this.countExpansion(1); + var tokens = expansion.tokens; + var args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + + for (var i = tokens.length - 1; i >= 0; --i) { + var tok = tokens[i]; + + if (tok.text === "#") { + if (i === 0) { + throw new ParseError("Incomplete placeholder at end of macro body", tok); + } + + tok = tokens[--i]; // next token on stack + + if (tok.text === "#") { + // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new ParseError("Not a valid argument number", tok); + } + } + } + } // Concatenate expansion onto top of stack. + + + this.pushTokens(tokens); + return tokens.length; + } + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + + + expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + /** + * Recursively expand first token, then return first non-expandable token. + */ + + + expandNextToken() { + for (;;) { + if (this.expandOnce() === false) { + // fully expanded + var token = this.stack.pop(); // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + + if (token.treatAsRelax) { + token.text = "\\relax"; + } + + return token; + } + } // Flow unable to figure out that this pathway is impossible. + // https://github.com/facebook/flow/issues/4808 + + + throw new Error(); // eslint-disable-line no-unreachable + } + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + + + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + + + expandTokens(tokens) { + var output = []; + var oldStackLength = this.stack.length; + this.pushTokens(tokens); + + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + var token = this.stack.pop(); + + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + + output.push(token); + } + } // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + + + this.countExpansion(output.length); + return output; + } + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + + + expandMacroAsText(name) { + var tokens = this.expandMacro(name); + + if (tokens) { + return tokens.map(token => token.text).join(""); + } else { + return tokens; + } + } + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + + + _getExpansion(name) { + var definition = this.macros.get(name); + + if (definition == null) { + // mainly checking for undefined here + return definition; + } // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + + + if (name.length === 1) { + var catcode = this.lexer.catcodes[name]; + + if (catcode != null && catcode !== 13) { + return; + } + } + + var expansion = typeof definition === "function" ? definition(this) : definition; + + if (typeof expansion === "string") { + var numArgs = 0; + + if (expansion.indexOf("#") !== -1) { + var stripped = expansion.replace(/##/g, ""); + + while (stripped.indexOf("#" + (numArgs + 1)) !== -1) { + ++numArgs; + } + } + + var bodyLexer = new Lexer(expansion, this.settings); + var tokens = []; + var tok = bodyLexer.lex(); + + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + + tokens.reverse(); // to fit in with stack using push and pop + + var expanded = { + tokens, + numArgs + }; + return expanded; + } + + return expansion; + } + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + + + isDefined(name) { + return this.macros.has(name) || functions.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + /** + * Determine whether a command is expandable. + */ + + + isExpandable(name) { + var macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions.hasOwnProperty(name) && !functions[name].primitive; + } + +} + +// Helpers for Parser.js handling of Unicode (sub|super)script characters. +var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +var uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); + +/* eslint no-constant-condition:0 */ + +var unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +var unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; + +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ +class Parser { + constructor(input, settings) { + this.mode = void 0; + this.gullet = void 0; + this.settings = void 0; + this.leftrightDepth = void 0; + this.nextToken = void 0; + // Start in math mode + this.mode = "math"; // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + + this.gullet = new MacroExpander(input, settings, this.mode); // Store the settings for use in parsing + + this.settings = settings; // Count leftright depth (for \middle errors) + + this.leftrightDepth = 0; + } + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + + + expect(text, consume) { + if (consume === void 0) { + consume = true; + } + + if (this.fetch().text !== text) { + throw new ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); + } + + if (consume) { + this.consume(); + } + } + /** + * Discards the current lookahead token, considering it consumed. + */ + + + consume() { + this.nextToken = null; + } + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + + + fetch() { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + + return this.nextToken; + } + /** + * Switches between "text" and "math" modes. + */ + + + switchMode(newMode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + /** + * Main parsing function, which parses an entire input. + */ + + + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + + + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + + try { + // Try to parse the input + var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end + + this.expect("EOF"); // End the group namespace for the expression + + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + + return parse; // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + + + subparse(tokens) { + // Save the next token from the current job. + var oldToken = this.nextToken; + this.consume(); // Run the new job, terminating it with an excess '}' + + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + var parse = this.parseExpression(false); + this.expect("}"); // Restore the next token from the current job. + + this.nextToken = oldToken; + return parse; + } + + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence han infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + var body = []; // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + + var lex = this.fetch(); + + if (Parser.endOfExpression.indexOf(lex.text) !== -1) { + break; + } + + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + + if (breakOnInfix && functions[lex.text] && functions[lex.text].infix) { + break; + } + + var atom = this.parseAtom(breakOnTokenText); + + if (!atom) { + break; + } else if (atom.type === "internal") { + continue; + } + + body.push(atom); + } + + if (this.mode === "text") { + this.formLigatures(body); + } + + return this.handleInfixNodes(body); + } + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + + + handleInfixNodes(body) { + var overIndex = -1; + var funcName; + + for (var i = 0; i < body.length; i++) { + if (body[i].type === "infix") { + if (overIndex !== -1) { + throw new ParseError("only one infix operator per group", body[i].token); + } + + overIndex = i; + funcName = body[i].replaceWith; + } + } + + if (overIndex !== -1 && funcName) { + var numerNode; + var denomNode; + var numerBody = body.slice(0, overIndex); + var denomBody = body.slice(overIndex + 1); + + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = { + type: "ordgroup", + mode: this.mode, + body: numerBody + }; + } + + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = { + type: "ordgroup", + mode: this.mode, + body: denomBody + }; + } + + var node; + + if (funcName === "\\\\abovefrac") { + node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + } else { + node = this.callFunction(funcName, [numerNode, denomNode], []); + } + + return [node]; + } else { + return body; + } + } + /** + * Handle a subscript or superscript with nice errors. + */ + + + handleSupSubscript(name // For error reporting. + ) { + var symbolToken = this.fetch(); + var symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + var group = this.parseGroup(name); + + if (!group) { + throw new ParseError("Expected group after '" + symbol + "'", symbolToken); + } + + return group; + } + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + + + formatUnsupportedCmd(text) { + var textordArray = []; + + for (var i = 0; i < text.length; i++) { + textordArray.push({ + type: "textord", + mode: "text", + text: text[i] + }); + } + + var textNode = { + type: "text", + mode: this.mode, + body: textordArray + }; + var colorNode = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode] + }; + return colorNode; + } + /** + * Parses a group with optional super/subscripts. + */ + + + parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + var base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts + + if (this.mode === "text") { + return base; + } // Note that base may be empty (i.e. null) at this point. + + + var superscript; + var subscript; + + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); // Lex the first token + + var lex = this.fetch(); + + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + var limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new ParseError("Limit controls must follow a math operator", lex); + } + + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new ParseError("Double superscript", lex); + } + + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new ParseError("Double subscript", lex); + } + + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new ParseError("Double superscript", lex); + } + + var prime = { + type: "textord", + mode: this.mode, + text: "\\prime" + }; // Many primes can be grouped together, so we handle this here + + var primes = [prime]; + this.consume(); // Keep lexing tokens until we get something that's not a prime + + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } // If there's a superscript following the primes, combine that + // superscript in with the primes. + + + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } // Put everything into an ordgroup as the superscript + + + superscript = { + type: "ordgroup", + mode: this.mode, + body: primes + }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + var isSub = unicodeSubRegEx.test(lex.text); + var subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); // Continue fetching tokens to fill out the string. + + while (true) { + var token = this.fetch().text; + + if (!uSubsAndSups[token]) { + break; + } + + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } // Now create a (sub|super)script. + + + var body = this.subparse(subsupTokens); + + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + + + if (superscript || subscript) { + // If we got either a superscript or subscript, create a supsub + return { + type: "supsub", + mode: this.mode, + base: base, + sup: superscript, + sub: subscript + }; + } else { + // Otherwise return the original body + return base; + } + } + /** + * Parses an entire function, including its base and all of its arguments. + */ + + + parseFunction(breakOnTokenText, name // For determining its context + ) { + var token = this.fetch(); + var func = token.text; + var funcData = functions[func]; + + if (!funcData) { + return null; + } + + this.consume(); // consume command token + + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new ParseError("Can't use function '" + func + "' in text mode", token); + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new ParseError("Can't use function '" + func + "' in math mode", token); + } + + var { + args, + optArgs + } = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + /** + * Call a function handler with a suitable context and arguments. + */ + + + callFunction(name, args, optArgs, token, breakOnTokenText) { + var context = { + funcName: name, + parser: this, + token, + breakOnTokenText + }; + var func = functions[name]; + + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new ParseError("No function handler for " + name); + } + } + /** + * Parses the arguments of a function or environment + */ + + + parseArguments(func, // Should look like "\name" or "\begin{name}". + funcData) { + var totalArgs = funcData.numArgs + funcData.numOptionalArgs; + + if (totalArgs === 0) { + return { + args: [], + optArgs: [] + }; + } + + var args = []; + var optArgs = []; + + for (var i = 0; i < totalArgs; i++) { + var argType = funcData.argTypes && funcData.argTypes[i]; + var isOptional = i < funcData.numOptionalArgs; + + if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; + } + + var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } + } + + return { + args, + optArgs + }; + } + /** + * Parses a group when the mode is changing. + */ + + + parseGroupOfType(name, type, optional) { + switch (type) { + case "color": + return this.parseColorGroup(optional); + + case "size": + return this.parseSizeGroup(optional); + + case "url": + return this.parseUrlGroup(optional); + + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + + case "hbox": + { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size. + var group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text" // simulate \textstyle + + } : null; + } + + case "raw": + { + var token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } + + case "primitive": + { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); + } + + var _group = this.parseGroup(name); + + if (_group == null) { + throw new ParseError("Expected group as " + name, this.fetch()); + } + + return _group; + } + + case "original": + case null: + case undefined: + return this.parseArgumentGroup(optional); + + default: + throw new ParseError("Unknown group type as " + name, this.fetch()); + } + } + /** + * Discard any space tokens, fetching the next non-space token. + */ + + + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + + + parseStringGroup(modeName, // Used to describe the mode in error messages. + optional) { + var argToken = this.gullet.scanArgument(optional); + + if (argToken == null) { + return null; + } + + var str = ""; + var nextToken; + + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + + this.consume(); // consume the end of the argument + + argToken.text = str; + return argToken; + } + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + + + parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { + var firstToken = this.fetch(); + var lastToken = firstToken; + var str = ""; + var nextToken; + + while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + + if (str === "") { + throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + + return firstToken.range(lastToken, str); + } + /** + * Parses a color description. + */ + + + parseColorGroup(optional) { + var res = this.parseStringGroup("color", optional); + + if (res == null) { + return null; + } + + var match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + + if (!match) { + throw new ParseError("Invalid color: '" + res.text + "'", res); + } + + var color = match[0]; + + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + + return { + type: "color-token", + mode: this.mode, + color + }; + } + /** + * Parses a size specification, consisting of magnitude and unit. + */ + + + parseSizeGroup(optional) { + var res; + var isBlank = false; // don't expand before parseStringGroup + + this.gullet.consumeSpaces(); + + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup("size", optional); + } + + if (!res) { + return null; + } + + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + + isBlank = true; // This is here specifically for \genfrac + } + + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + + if (!match) { + throw new ParseError("Invalid size: '" + res.text + "'", res); + } + + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "'", res); + } + + return { + type: "size", + mode: this.mode, + value: data, + isBlank + }; + } + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + + + parseUrlGroup(optional) { + this.gullet.lexer.setCatcode("%", 13); // active character + + this.gullet.lexer.setCatcode("~", 12); // other character + + var res = this.parseStringGroup("url", optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + + this.gullet.lexer.setCatcode("~", 13); // active character + + if (res == null) { + return null; + } // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + + + var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url + }; + } + /** + * Parses an argument with the mode specified. + */ + + + parseArgumentGroup(optional, mode) { + var argToken = this.gullet.scanArgument(optional); + + if (argToken == null) { + return null; + } + + var outerMode = this.mode; + + if (mode) { + // Switch to specified mode + this.switchMode(mode); + } + + this.gullet.beginGroup(); + var expression = this.parseExpression(false, "EOF"); // TODO: find an alternative way to denote the end + + this.expect("EOF"); // expect the end of the argument + + this.gullet.endGroup(); + var result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + + return result; + } + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + + + parseGroup(name, // For error reporting. + breakOnTokenText) { + var firstToken = this.fetch(); + var text = firstToken.text; + var result; // Try to parse an open brace or \begingroup + + if (text === "{" || text === "\\begingroup") { + this.consume(); + var groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); // If we get a brace, parse an expression + + var expression = this.parseExpression(false, groupEnd); + var lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); + + if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new ParseError("Undefined control sequence: " + text, firstToken); + } + + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + + return result; + } + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + + + formLigatures(group) { + var n = group.length - 1; + + for (var i = 0; i < n; ++i) { + var a = group[i]; // $FlowFixMe: Not every node type has a `text` property. + + var v = a.text; + + if (v === "-" && group[i + 1].text === "-") { + if (i + 1 < n && group[i + 2].text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, group[i + 2]), + text: "---" + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, group[i + 1]), + text: "--" + }); + n -= 1; + } + } + + if ((v === "'" || v === "`") && group[i + 1].text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, group[i + 1]), + text: v + v + }); + n -= 1; + } + } + } + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + + + parseSymbol() { + var nucleus = this.fetch(); + var text = nucleus.text; + + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + var arg = text.slice(5); + var star = arg.charAt(0) === "*"; + + if (star) { + arg = arg.slice(1); + } // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + + + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new ParseError("\\verb assertion failed --\n please report what input caused this bug"); + } + + arg = arg.slice(1, -1); // remove first and last char + + return { + type: "verb", + mode: "text", + body: arg, + star + }; + } // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + + + if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + + text = unicodeSymbols[text[0]] + text.slice(1); + } // Strip off any combining characters + + + var match = combiningDiacriticalMarksEndRegex.exec(text); + + if (match) { + text = text.substring(0, match.index); + + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } // Recognize base symbol + + + var symbol; + + if (symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && extraLatin.indexOf(text) >= 0) { + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + + var group = symbols[this.mode][text].group; + var loc = SourceLocation.range(nucleus); + var s; + + if (ATOMS.hasOwnProperty(group)) { + // $FlowFixMe + var family = group; + s = { + type: "atom", + mode: this.mode, + family, + loc, + text + }; + } else { + // $FlowFixMe + s = { + type: group, + mode: this.mode, + loc, + text + }; + } // $FlowFixMe + + + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { + // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); + } + } // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + + + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + + this.consume(); // Transform combining characters into accents + + if (match) { + for (var i = 0; i < match[0].length; i++) { + var accent = match[0][i]; + + if (!unicodeAccents[accent]) { + throw new ParseError("Unknown accent ' " + accent + "'", nucleus); + } + + var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; + + if (!command) { + throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); + } + + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + // $FlowFixMe + base: symbol + }; + } + } // $FlowFixMe + + + return symbol; + } + +} +Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"]; + +/** + * Provides a single function for parsing an expression using a Parser + * TODO(emily): Remove this + */ + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +var parseTree = function parseTree(toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + + var parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + + delete parser.gullet.macros.current["\\df@tag"]; + var tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render(). + + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new ParseError("\\tag works only in display equations"); + } + + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]) + }]; + } + + return tree; +}; + +/* eslint no-console:0 */ + +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +var render$2 = function render(expression, baseNode, options) { + baseNode.textContent = ""; + var node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; // KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. + + +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); + + render$2 = function render() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} +/** + * Parse and build an expression, and return the markup for that. + */ + + +var renderToString = function renderToString(expression, options) { + var markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; +/** + * Parse an expression and return the parse tree. + */ + + +var generateParseTree = function generateParseTree(expression, options) { + var settings = new Settings(options); + return parseTree(expression, settings); +}; +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ + + +var renderError = function renderError(error, expression, options) { + if (options.throwOnError || !(error instanceof ParseError)) { + throw error; + } + + var node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", "color:" + options.errorColor); + return node; +}; +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ + + +var renderToDomTree = function renderToDomTree(expression, options) { + var settings = new Settings(options); + + try { + var tree = parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ + + +var renderToHTMLTree = function renderToHTMLTree(expression, options) { + var settings = new Settings(options); + + try { + var tree = parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +var katex = { + /** + * Current KaTeX version + */ + version: "0.16.10", + + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render: render$2, + + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + + /** + * KaTeX error, usually during parsing. + */ + ParseError, + + /** + * The shema of Settings + */ + SETTINGS_SCHEMA, + + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree: { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode + } +}; + +var katex$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: katex +}); + +function extendedTables() { + return { + extensions: [ + { + name: 'spanTable', + level: 'block', // Is this a block-level or inline-level tokenizer? + start(src) { return src.match(/^\n *([^\n ].*\|.*)\n/)?.index; }, // Hint to Marked.js to stop and check for a match + tokenizer(src, tokens) { + // const regex = this.tokenizer.rules.block.table; + const regex = new RegExp('^ *([^\\n ].*\\|.*\\n(?: *[^\\s].*\\n)*?)' // Header + + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align + + '(?:\\n((?:(?! *\\n| {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})' // Cells + + '(?:\\n+|$)| {0,3}#{1,6} | {0,3}>| {4}[^\\n]| {0,3}(?:`{3,}' + + '(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n| {0,3}(?:[*+-]|1[.)]) |' + + '<\\/?(?:address|article|aside|base|basefont|blockquote|body|' + + 'caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?: +|\\n|\\/?>)|<(?:script|pre|style|textarea|!--)).*(?:\\n|$))*)\\n*|$)'); // Cells + const cap = regex.exec(src); + + if (cap) { + const item = { + type: 'spanTable', + header: cap[1].replace(/\n$/, '').split('\n'), + align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), + rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [] + }; + + // Get first header row to determine how many columns + item.header[0] = splitCells(item.header[0]); + + const colCount = item.header[0].reduce((length, header) => { + return length + header.colspan; + }, 0); + + if (colCount === item.align.length) { + item.raw = cap[0]; + + let i, j, k, row; + + // Get alignment row (:---:) + let l = item.align.length; + + for (i = 0; i < l; i++) { + if (/^ *-+: *$/.test(item.align[i])) { + item.align[i] = 'right'; + } else if (/^ *:-+: *$/.test(item.align[i])) { + item.align[i] = 'center'; + } else if (/^ *:-+ *$/.test(item.align[i])) { + item.align[i] = 'left'; + } else { + item.align[i] = null; + } + } + + // Get any remaining header rows + l = item.header.length; + for (i = 1; i < l; i++) { + item.header[i] = splitCells(item.header[i], colCount, item.header[i - 1]); + } + + // Get main table cells + l = item.rows.length; + for (i = 0; i < l; i++) { + item.rows[i] = splitCells(item.rows[i], colCount, item.rows[i - 1]); + } + + // header child tokens + l = item.header.length; + for (j = 0; j < l; j++) { + row = item.header[j]; + for (k = 0; k < row.length; k++) { + row[k].tokens = []; + this.lexer.inline(row[k].text, row[k].tokens); + } + } + + // cell child tokens + l = item.rows.length; + for (j = 0; j < l; j++) { + row = item.rows[j]; + for (k = 0; k < row.length; k++) { + row[k].tokens = []; + this.lexer.inline(row[k].text, row[k].tokens); + } + } + return item; + } + } + }, + renderer(token) { + let i, j, row, cell, col, text; + let output = ''; + output += ''; + for (i = 0; i < token.header.length; i++) { + row = token.header[i]; + let col = 0; + output += ''; + for (j = 0; j < row.length; j++) { + cell = row[j]; + text = this.parser.parseInline(cell.tokens); + output += getTableCell(text, cell, 'th', token.align[col]); + col += cell.colspan; + } + output += ''; + } + output += ''; + if (token.rows.length) { + output += ''; + for (i = 0; i < token.rows.length; i++) { + row = token.rows[i]; + col = 0; + output += ''; + for (j = 0; j < row.length; j++) { + cell = row[j]; + text = this.parser.parseInline(cell.tokens); + output += getTableCell(text, cell, 'td', token.align[col]); + col += cell.colspan; + } + output += ''; + } + output += ''; + } + output += '
    '; + return output; + } + } + ] + }; +} + +const getTableCell = (text, cell, type, align) => { + if (!cell.rowspan) { + return ''; + } + const tag = `<${type}` + + `${cell.colspan > 1 ? ` colspan=${cell.colspan}` : ''}` + + `${cell.rowspan > 1 ? ` rowspan=${cell.rowspan}` : ''}` + + `${align ? ` align=${align}` : ''}>`; + return `${tag + text}\n`; +}; + +const splitCells = (tableRow, count, prevRow = []) => { + const cells = [...tableRow.matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((x) => x[0]); + + // Remove first/last cell in a row if whitespace only and no leading/trailing pipe + if (!cells[0]?.trim()) { cells.shift(); } + if (!cells[cells.length - 1]?.trim()) { cells.pop(); } + + let numCols = 0; + let i, j, trimmedCell, prevCell, prevCols; + + for (i = 0; i < cells.length; i++) { + trimmedCell = cells[i].split(/\|+$/)[0]; + cells[i] = { + rowspan: 1, + colspan: Math.max(cells[i].length - trimmedCell.length, 1), + text: trimmedCell.trim().replace(/\\\|/g, '|') + // display escaped pipes as normal character + }; + + // Handle Rowspan + if (trimmedCell.slice(-1) === '^' && prevRow.length) { + // Find matching cell in previous row + prevCols = 0; + for (j = 0; j < prevRow.length; j++) { + prevCell = prevRow[j]; + if ((prevCols === numCols) && (prevCell.colspan === cells[i].colspan)) { + // merge into matching cell in previous row (the "target") + cells[i].rowSpanTarget = prevCell.rowSpanTarget ?? prevCell; + cells[i].rowSpanTarget.text += ` ${cells[i].text.slice(0, -1)}`; + cells[i].rowSpanTarget.rowspan += 1; + cells[i].rowspan = 0; + break; + } + prevCols += prevCell.colspan; + if (prevCols > numCols) { break; } + } + } + + numCols += cells[i].colspan; + } + + // Force main cell rows to match header column count + if (numCols > count) { + cells.splice(count); + } else { + while (numCols < count) { + cells.push({ + colspan: 1, + text: '' + }); + numCols += 1; + } + } + return cells; +}; + +const p = [ + { + type: "note", + icon: '' + }, + { + type: "tip", + icon: '' + }, + { + type: "important", + icon: '' + }, + { + type: "warning", + icon: '' + }, + { + type: "caution", + icon: '' + } +]; +function w(e) { + return e.length ? Object.values( + [...p, ...e].reduce( + (i, s) => (i[s.type] = s, i), + {} + ) + ) : p; +} +function d(e) { + return `^(?:\\[\\!${e.toUpperCase()}\\])[s]*? +?`; +} +function f(e) { + return e.slice(0, 1).toUpperCase() + e.slice(1).toLowerCase(); +} +function x(e = {}) { + const { className: i = "markdown-alert", variants: s = [] } = e, u = w(s); + return { + walkTokens(t) { + var a, o, l, h; + if (t.type !== "blockquote") + return; + const c = u.find( + ({ type: n }) => new RegExp(d(n)).test(t.text) + ); + if (c) { + const { + type: n, + icon: g, + title: Z = f(n), + titleClassName: m = `${i}-title` + } = c; + Object.assign(t, { + type: "alert", + meta: { + className: i, + variant: n, + icon: g, + title: Z, + titleClassName: m + } + }); + const r = (a = t.tokens) == null ? void 0 : a[0], v = (o = r.raw) == null ? void 0 : o.replace(new RegExp(d(n)), "").trim(); + v ? (r.tokens = this.Lexer.lexInline( + v + ), (l = t.tokens) == null || l.splice(0, 1, r)) : (h = t.tokens) == null || h.shift(); + } + }, + extensions: [ + { + name: "alert", + level: "block", + renderer({ meta: t, tokens: c = [] }) { + let a = `
    +`; + return a += `

    `, a += t.icon, a += t.title, a += `

    +`, a += this.parser.parse(c), a += `
    +`, a; + } + } + ] + }; +} + +marked.use((extendedTables())); +var optionsAlert = { + variants: [ + { + type: 'danger', + icon: '🚨', + title: 'Oh snap!', // optional + titleClassName: 'text-danger' // optional + }, + { + type: 'note', + icon: '🚨', + title: 'NOTE', // optional + titleClassName: 'text-info' // optional + }, + { + type: 'tip', + icon: '🚨', + title: 'TIP', // optional + titleClassName: 'text-info' // optional + }, + { + type: 'important', + icon: '🚨', + title: 'CAUTION', // optional + titleClassName: 'text-info' // optional + }, + { + type: 'warning', + icon: '🚨', + title: 'WARNING', // optional + titleClassName: 'text-warning' // optional + }, + { + type: 'caution', + icon: '🚨', + title: 'CAUTION', // optional + titleClassName: 'text-danger' // optional + }, + ] +}; +marked.use(x(optionsAlert)); +function md2Html(md) { + var elDiv = document.createElement('div'); + elDiv.id = 'tmpDiv'; + elDiv.innerHTML = marked.parse(md, { + gfm: false, + }); + var regex = /[$]+/g; + elDiv.querySelectorAll('p').forEach(function (el) { + var _a; + var str = el.textContent || ''; + if (((_a = str.match(regex)) === null || _a === void 0 ? void 0 : _a.length) == 2) { + str = str.replace(regex, ''); + katex.render(str, el, { + throwOnError: false, + leqno: true, + }); + } + }); + elDiv.querySelectorAll('pre.mermaid').forEach(function (el) { + console.log(el); + el.insertAdjacentHTML('beforebegin', '
    '); + }); + return elDiv.innerHTML; +} + +function dedent(templ) { + var values = []; + for (var _i = 1; _i < arguments.length; _i++) { + values[_i - 1] = arguments[_i]; + } + var strings = Array.from(typeof templ === 'string' ? [templ] : templ); + strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, ''); + var indentLengths = strings.reduce(function (arr, str) { + var matches = str.match(/\n([\t ]+|(?!\s).)/g); + if (matches) { + return arr.concat(matches.map(function (match) { var _a, _b; return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0; })); + } + return arr; + }, []); + if (indentLengths.length) { + var pattern_1 = new RegExp("\n[\t ]{" + Math.min.apply(Math, indentLengths) + "}", 'g'); + strings = strings.map(function (str) { return str.replace(pattern_1, '\n'); }); + } + strings[0] = strings[0].replace(/^\r?\n/, ''); + var string = strings[0]; + values.forEach(function (value, i) { + var endentations = string.match(/(?:^|\n)( *)$/); + var endentation = endentations ? endentations[1] : ''; + var indentedValue = value; + if (typeof value === 'string' && value.includes('\n')) { + indentedValue = String(value) + .split('\n') + .map(function (str, i) { + return i === 0 ? str : "" + endentation + str; + }) + .join('\n'); + } + string += indentedValue + strings[i + 1]; + }); + return string; +} + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dayjs_min = {exports: {}}; + +(function (module, exports) { + !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t) -1; + } + // adapted from https://stackoverflow.com/a/29824550/2601552 + function decodeHtmlCharacters(str) { + var removedNullByte = str.replace(ctrlCharactersRegex, ""); + return removedNullByte.replace(htmlEntitiesRegex, function (match, dec) { + return String.fromCharCode(dec); + }); + } + function sanitizeUrl(url) { + if (!url) { + return exports.BLANK_URL; + } + var sanitizedUrl = decodeHtmlCharacters(url) + .replace(htmlCtrlEntityRegex, "") + .replace(ctrlCharactersRegex, "") + .trim(); + if (!sanitizedUrl) { + return exports.BLANK_URL; + } + if (isRelativeUrlWithoutProtocol(sanitizedUrl)) { + return sanitizedUrl; + } + var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex); + if (!urlSchemeParseResults) { + return sanitizedUrl; + } + var urlScheme = urlSchemeParseResults[0]; + if (invalidProtocolRegex.test(urlScheme)) { + return exports.BLANK_URL; + } + return sanitizedUrl; + } + exports.sanitizeUrl = sanitizeUrl; +} (dist)); + +var noop$1 = {value: () => {}}; + +function dispatch() { + for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) { + if (!(t = arguments[i] + "") || (t in _) || /[\s.]/.test(t)) throw new Error("illegal type: " + t); + _[t] = []; + } + return new Dispatch(_); +} + +function Dispatch(_) { + this._ = _; +} + +function parseTypenames$1(typenames, types) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t); + return {type: t, name: name}; + }); +} + +Dispatch.prototype = dispatch.prototype = { + constructor: Dispatch, + on: function(typename, callback) { + var _ = this._, + T = parseTypenames$1(typename + "", _), + t, + i = -1, + n = T.length; + + // If no callback was specified, return the callback of the given type and name. + if (arguments.length < 2) { + while (++i < n) if ((t = (typename = T[i]).type) && (t = get$1(_[t], typename.name))) return t; + return; + } + + // If a type was specified, set the callback for the given type and name. + // Otherwise, if a null callback was specified, remove callbacks of the given name. + if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); + while (++i < n) { + if (t = (typename = T[i]).type) _[t] = set$2(_[t], typename.name, callback); + else if (callback == null) for (t in _) _[t] = set$2(_[t], typename.name, null); + } + + return this; + }, + copy: function() { + var copy = {}, _ = this._; + for (var t in _) copy[t] = _[t].slice(); + return new Dispatch(copy); + }, + call: function(type, that) { + if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2]; + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + }, + apply: function(type, that, args) { + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + } +}; + +function get$1(type, name) { + for (var i = 0, n = type.length, c; i < n; ++i) { + if ((c = type[i]).name === name) { + return c.value; + } + } +} + +function set$2(type, name, callback) { + for (var i = 0, n = type.length; i < n; ++i) { + if (type[i].name === name) { + type[i] = noop$1, type = type.slice(0, i).concat(type.slice(i + 1)); + break; + } + } + if (callback != null) type.push({name: name, value: callback}); + return type; +} + +var xhtml = "http://www.w3.org/1999/xhtml"; + +var namespaces = { + svg: "http://www.w3.org/2000/svg", + xhtml: xhtml, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; + +function namespace(name) { + var prefix = name += "", i = prefix.indexOf(":"); + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name; // eslint-disable-line no-prototype-builtins +} + +function creatorInherit(name) { + return function() { + var document = this.ownerDocument, + uri = this.namespaceURI; + return uri === xhtml && document.documentElement.namespaceURI === xhtml + ? document.createElement(name) + : document.createElementNS(uri, name); + }; +} + +function creatorFixed(fullname) { + return function() { + return this.ownerDocument.createElementNS(fullname.space, fullname.local); + }; +} + +function creator(name) { + var fullname = namespace(name); + return (fullname.local + ? creatorFixed + : creatorInherit)(fullname); +} + +function none() {} + +function selector(selector) { + return selector == null ? none : function() { + return this.querySelector(selector); + }; +} + +function selection_select(select) { + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +// Given something array like (or null), returns something that is strictly an +// array. This is used to ensure that array-like objects passed to d3.selectAll +// or selection.selectAll are converted into proper arrays when creating a +// selection; we don’t ever want to create a selection backed by a live +// HTMLCollection or NodeList. However, note that selection.selectAll will use a +// static NodeList as a group, since it safely derived from querySelectorAll. +function array(x) { + return x == null ? [] : Array.isArray(x) ? x : Array.from(x); +} + +function empty() { + return []; +} + +function selectorAll(selector) { + return selector == null ? empty : function() { + return this.querySelectorAll(selector); + }; +} + +function arrayAll(select) { + return function() { + return array(select.apply(this, arguments)); + }; +} + +function selection_selectAll(select) { + if (typeof select === "function") select = arrayAll(select); + else select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + subgroups.push(select.call(node, node.__data__, i, group)); + parents.push(node); + } + } + } + + return new Selection$1(subgroups, parents); +} + +function matcher(selector) { + return function() { + return this.matches(selector); + }; +} + +function childMatcher(selector) { + return function(node) { + return node.matches(selector); + }; +} + +var find = Array.prototype.find; + +function childFind(match) { + return function() { + return find.call(this.children, match); + }; +} + +function childFirst() { + return this.firstElementChild; +} + +function selection_selectChild(match) { + return this.select(match == null ? childFirst + : childFind(typeof match === "function" ? match : childMatcher(match))); +} + +var filter = Array.prototype.filter; + +function children() { + return Array.from(this.children); +} + +function childrenFilter(match) { + return function() { + return filter.call(this.children, match); + }; +} + +function selection_selectChildren(match) { + return this.selectAll(match == null ? children + : childrenFilter(typeof match === "function" ? match : childMatcher(match))); +} + +function selection_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +function sparse(update) { + return new Array(update.length); +} + +function selection_enter() { + return new Selection$1(this._enter || this._groups.map(sparse), this._parents); +} + +function EnterNode(parent, datum) { + this.ownerDocument = parent.ownerDocument; + this.namespaceURI = parent.namespaceURI; + this._next = null; + this._parent = parent; + this.__data__ = datum; +} + +EnterNode.prototype = { + constructor: EnterNode, + appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, + insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, + querySelector: function(selector) { return this._parent.querySelector(selector); }, + querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } +}; + +function constant$2(x) { + return function() { + return x; + }; +} + +function bindIndex(parent, group, enter, update, exit, data) { + var i = 0, + node, + groupLength = group.length, + dataLength = data.length; + + // Put any non-null nodes that fit into update. + // Put any null nodes into enter. + // Put any remaining data into enter. + for (; i < dataLength; ++i) { + if (node = group[i]) { + node.__data__ = data[i]; + update[i] = node; + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Put any non-null nodes that don’t fit into exit. + for (; i < groupLength; ++i) { + if (node = group[i]) { + exit[i] = node; + } + } +} + +function bindKey(parent, group, enter, update, exit, data, key) { + var i, + node, + nodeByKeyValue = new Map, + groupLength = group.length, + dataLength = data.length, + keyValues = new Array(groupLength), + keyValue; + + // Compute the key for each node. + // If multiple nodes have the same key, the duplicates are added to exit. + for (i = 0; i < groupLength; ++i) { + if (node = group[i]) { + keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + ""; + if (nodeByKeyValue.has(keyValue)) { + exit[i] = node; + } else { + nodeByKeyValue.set(keyValue, node); + } + } + } + + // Compute the key for each datum. + // If there a node associated with this key, join and add it to update. + // If there is not (or the key is a duplicate), add it to enter. + for (i = 0; i < dataLength; ++i) { + keyValue = key.call(parent, data[i], i, data) + ""; + if (node = nodeByKeyValue.get(keyValue)) { + update[i] = node; + node.__data__ = data[i]; + nodeByKeyValue.delete(keyValue); + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Add any remaining nodes that were not bound to data to exit. + for (i = 0; i < groupLength; ++i) { + if ((node = group[i]) && (nodeByKeyValue.get(keyValues[i]) === node)) { + exit[i] = node; + } + } +} + +function datum(node) { + return node.__data__; +} + +function selection_data(value, key) { + if (!arguments.length) return Array.from(this, datum); + + var bind = key ? bindKey : bindIndex, + parents = this._parents, + groups = this._groups; + + if (typeof value !== "function") value = constant$2(value); + + for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { + var parent = parents[j], + group = groups[j], + groupLength = group.length, + data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), + dataLength = data.length, + enterGroup = enter[j] = new Array(dataLength), + updateGroup = update[j] = new Array(dataLength), + exitGroup = exit[j] = new Array(groupLength); + + bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); + + // Now connect the enter nodes to their following update node, such that + // appendChild can insert the materialized enter node before this node, + // rather than at the end of the parent node. + for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { + if (previous = enterGroup[i0]) { + if (i0 >= i1) i1 = i0 + 1; + while (!(next = updateGroup[i1]) && ++i1 < dataLength); + previous._next = next || null; + } + } + } + + update = new Selection$1(update, parents); + update._enter = enter; + update._exit = exit; + return update; +} + +// Given some data, this returns an array-like view of it: an object that +// exposes a length property and allows numeric indexing. Note that unlike +// selectAll, this isn’t worried about “live” collections because the resulting +// array will only be used briefly while data is being bound. (It is possible to +// cause the data to change while iterating by using a key function, but please +// don’t; we’d rather avoid a gratuitous copy.) +function arraylike(data) { + return typeof data === "object" && "length" in data + ? data // Array, TypedArray, NodeList, array-like + : Array.from(data); // Map, Set, iterable, string, or anything else +} + +function selection_exit() { + return new Selection$1(this._exit || this._groups.map(sparse), this._parents); +} + +function selection_join(onenter, onupdate, onexit) { + var enter = this.enter(), update = this, exit = this.exit(); + if (typeof onenter === "function") { + enter = onenter(enter); + if (enter) enter = enter.selection(); + } else { + enter = enter.append(onenter + ""); + } + if (onupdate != null) { + update = onupdate(update); + if (update) update = update.selection(); + } + if (onexit == null) exit.remove(); else onexit(exit); + return enter && update ? enter.merge(update).order() : update; +} + +function selection_merge(context) { + var selection = context.selection ? context.selection() : context; + + for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Selection$1(merges, this._parents); +} + +function selection_order() { + + for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { + for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { + if (node = group[i]) { + if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); + next = node; + } + } + } + + return this; +} + +function selection_sort(compare) { + if (!compare) compare = ascending; + + function compareNode(a, b) { + return a && b ? compare(a.__data__, b.__data__) : !a - !b; + } + + for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group[i]) { + sortgroup[i] = node; + } + } + sortgroup.sort(compareNode); + } + + return new Selection$1(sortgroups, this._parents).order(); +} + +function ascending(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function selection_call() { + var callback = arguments[0]; + arguments[0] = this; + callback.apply(null, arguments); + return this; +} + +function selection_nodes() { + return Array.from(this); +} + +function selection_node() { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { + var node = group[i]; + if (node) return node; + } + } + + return null; +} + +function selection_size() { + let size = 0; + for (const node of this) ++size; // eslint-disable-line no-unused-vars + return size; +} + +function selection_empty() { + return !this.node(); +} + +function selection_each(callback) { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) callback.call(node, node.__data__, i, group); + } + } + + return this; +} + +function attrRemove$1(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS$1(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant$1(name, value) { + return function() { + this.setAttribute(name, value); + }; +} + +function attrConstantNS$1(fullname, value) { + return function() { + this.setAttributeNS(fullname.space, fullname.local, value); + }; +} + +function attrFunction$1(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttribute(name); + else this.setAttribute(name, v); + }; +} + +function attrFunctionNS$1(fullname, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttributeNS(fullname.space, fullname.local); + else this.setAttributeNS(fullname.space, fullname.local, v); + }; +} + +function selection_attr(name, value) { + var fullname = namespace(name); + + if (arguments.length < 2) { + var node = this.node(); + return fullname.local + ? node.getAttributeNS(fullname.space, fullname.local) + : node.getAttribute(fullname); + } + + return this.each((value == null + ? (fullname.local ? attrRemoveNS$1 : attrRemove$1) : (typeof value === "function" + ? (fullname.local ? attrFunctionNS$1 : attrFunction$1) + : (fullname.local ? attrConstantNS$1 : attrConstant$1)))(fullname, value)); +} + +function defaultView(node) { + return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node + || (node.document && node) // node is a Window + || node.defaultView; // node is a Document +} + +function styleRemove$1(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant$1(name, value, priority) { + return function() { + this.style.setProperty(name, value, priority); + }; +} + +function styleFunction$1(name, value, priority) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.style.removeProperty(name); + else this.style.setProperty(name, v, priority); + }; +} + +function selection_style(name, value, priority) { + return arguments.length > 1 + ? this.each((value == null + ? styleRemove$1 : typeof value === "function" + ? styleFunction$1 + : styleConstant$1)(name, value, priority == null ? "" : priority)) + : styleValue(this.node(), name); +} + +function styleValue(node, name) { + return node.style.getPropertyValue(name) + || defaultView(node).getComputedStyle(node, null).getPropertyValue(name); +} + +function propertyRemove(name) { + return function() { + delete this[name]; + }; +} + +function propertyConstant(name, value) { + return function() { + this[name] = value; + }; +} + +function propertyFunction(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) delete this[name]; + else this[name] = v; + }; +} + +function selection_property(name, value) { + return arguments.length > 1 + ? this.each((value == null + ? propertyRemove : typeof value === "function" + ? propertyFunction + : propertyConstant)(name, value)) + : this.node()[name]; +} + +function classArray(string) { + return string.trim().split(/^|\s+/); +} + +function classList(node) { + return node.classList || new ClassList(node); +} + +function ClassList(node) { + this._node = node; + this._names = classArray(node.getAttribute("class") || ""); +} + +ClassList.prototype = { + add: function(name) { + var i = this._names.indexOf(name); + if (i < 0) { + this._names.push(name); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + remove: function(name) { + var i = this._names.indexOf(name); + if (i >= 0) { + this._names.splice(i, 1); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + contains: function(name) { + return this._names.indexOf(name) >= 0; + } +}; + +function classedAdd(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.add(names[i]); +} + +function classedRemove(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.remove(names[i]); +} + +function classedTrue(names) { + return function() { + classedAdd(this, names); + }; +} + +function classedFalse(names) { + return function() { + classedRemove(this, names); + }; +} + +function classedFunction(names, value) { + return function() { + (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); + }; +} + +function selection_classed(name, value) { + var names = classArray(name + ""); + + if (arguments.length < 2) { + var list = classList(this.node()), i = -1, n = names.length; + while (++i < n) if (!list.contains(names[i])) return false; + return true; + } + + return this.each((typeof value === "function" + ? classedFunction : value + ? classedTrue + : classedFalse)(names, value)); +} + +function textRemove() { + this.textContent = ""; +} + +function textConstant$1(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction$1(value) { + return function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + }; +} + +function selection_text(value) { + return arguments.length + ? this.each(value == null + ? textRemove : (typeof value === "function" + ? textFunction$1 + : textConstant$1)(value)) + : this.node().textContent; +} + +function htmlRemove() { + this.innerHTML = ""; +} + +function htmlConstant(value) { + return function() { + this.innerHTML = value; + }; +} + +function htmlFunction(value) { + return function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + }; +} + +function selection_html(value) { + return arguments.length + ? this.each(value == null + ? htmlRemove : (typeof value === "function" + ? htmlFunction + : htmlConstant)(value)) + : this.node().innerHTML; +} + +function raise() { + if (this.nextSibling) this.parentNode.appendChild(this); +} + +function selection_raise() { + return this.each(raise); +} + +function lower() { + if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); +} + +function selection_lower() { + return this.each(lower); +} + +function selection_append(name) { + var create = typeof name === "function" ? name : creator(name); + return this.select(function() { + return this.appendChild(create.apply(this, arguments)); + }); +} + +function constantNull() { + return null; +} + +function selection_insert(name, before) { + var create = typeof name === "function" ? name : creator(name), + select = before == null ? constantNull : typeof before === "function" ? before : selector(before); + return this.select(function() { + return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); + }); +} + +function remove() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); +} + +function selection_remove() { + return this.each(remove); +} + +function selection_cloneShallow() { + var clone = this.cloneNode(false), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_cloneDeep() { + var clone = this.cloneNode(true), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_clone(deep) { + return this.select(deep ? selection_cloneDeep : selection_cloneShallow); +} + +function selection_datum(value) { + return arguments.length + ? this.property("__data__", value) + : this.node().__data__; +} + +function contextListener(listener) { + return function(event) { + listener.call(this, event, this.__data__); + }; +} + +function parseTypenames(typenames) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + return {type: t, name: name}; + }); +} + +function onRemove(typename) { + return function() { + var on = this.__on; + if (!on) return; + for (var j = 0, i = -1, m = on.length, o; j < m; ++j) { + if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + } else { + on[++i] = o; + } + } + if (++i) on.length = i; + else delete this.__on; + }; +} + +function onAdd(typename, value, options) { + return function() { + var on = this.__on, o, listener = contextListener(value); + if (on) for (var j = 0, m = on.length; j < m; ++j) { + if ((o = on[j]).type === typename.type && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + this.addEventListener(o.type, o.listener = listener, o.options = options); + o.value = value; + return; + } + } + this.addEventListener(typename.type, listener, options); + o = {type: typename.type, name: typename.name, value: value, listener: listener, options: options}; + if (!on) this.__on = [o]; + else on.push(o); + }; +} + +function selection_on(typename, value, options) { + var typenames = parseTypenames(typename + ""), i, n = typenames.length, t; + + if (arguments.length < 2) { + var on = this.node().__on; + if (on) for (var j = 0, m = on.length, o; j < m; ++j) { + for (i = 0, o = on[j]; i < n; ++i) { + if ((t = typenames[i]).type === o.type && t.name === o.name) { + return o.value; + } + } + } + return; + } + + on = value ? onAdd : onRemove; + for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options)); + return this; +} + +function dispatchEvent(node, type, params) { + var window = defaultView(node), + event = window.CustomEvent; + + if (typeof event === "function") { + event = new event(type, params); + } else { + event = window.document.createEvent("Event"); + if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; + else event.initEvent(type, false, false); + } + + node.dispatchEvent(event); +} + +function dispatchConstant(type, params) { + return function() { + return dispatchEvent(this, type, params); + }; +} + +function dispatchFunction(type, params) { + return function() { + return dispatchEvent(this, type, params.apply(this, arguments)); + }; +} + +function selection_dispatch(type, params) { + return this.each((typeof params === "function" + ? dispatchFunction + : dispatchConstant)(type, params)); +} + +function* selection_iterator() { + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) yield node; + } + } +} + +var root$1 = [null]; + +function Selection$1(groups, parents) { + this._groups = groups; + this._parents = parents; +} + +function selection() { + return new Selection$1([[document.documentElement]], root$1); +} + +function selection_selection() { + return this; +} + +Selection$1.prototype = selection.prototype = { + constructor: Selection$1, + select: selection_select, + selectAll: selection_selectAll, + selectChild: selection_selectChild, + selectChildren: selection_selectChildren, + filter: selection_filter, + data: selection_data, + enter: selection_enter, + exit: selection_exit, + join: selection_join, + merge: selection_merge, + selection: selection_selection, + order: selection_order, + sort: selection_sort, + call: selection_call, + nodes: selection_nodes, + node: selection_node, + size: selection_size, + empty: selection_empty, + each: selection_each, + attr: selection_attr, + style: selection_style, + property: selection_property, + classed: selection_classed, + text: selection_text, + html: selection_html, + raise: selection_raise, + lower: selection_lower, + append: selection_append, + insert: selection_insert, + remove: selection_remove, + clone: selection_clone, + datum: selection_datum, + on: selection_on, + dispatch: selection_dispatch, + [Symbol.iterator]: selection_iterator +}; + +function select(selector) { + return typeof selector === "string" + ? new Selection$1([[document.querySelector(selector)]], [document.documentElement]) + : new Selection$1([[selector]], root$1); +} + +function define(constructor, factory, prototype) { + constructor.prototype = factory.prototype = prototype; + prototype.constructor = constructor; +} + +function extend$1(parent, definition) { + var prototype = Object.create(parent.prototype); + for (var key in definition) prototype[key] = definition[key]; + return prototype; +} + +function Color$1() {} + +var darker = 0.7; +var brighter = 1 / darker; + +var reI = "\\s*([+-]?\\d+)\\s*", + reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", + reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", + reHex = /^#([0-9a-f]{3,8})$/, + reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), + reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), + reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), + reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), + reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), + reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); + +var named = { + aliceblue: 0xf0f8ff, + antiquewhite: 0xfaebd7, + aqua: 0x00ffff, + aquamarine: 0x7fffd4, + azure: 0xf0ffff, + beige: 0xf5f5dc, + bisque: 0xffe4c4, + black: 0x000000, + blanchedalmond: 0xffebcd, + blue: 0x0000ff, + blueviolet: 0x8a2be2, + brown: 0xa52a2a, + burlywood: 0xdeb887, + cadetblue: 0x5f9ea0, + chartreuse: 0x7fff00, + chocolate: 0xd2691e, + coral: 0xff7f50, + cornflowerblue: 0x6495ed, + cornsilk: 0xfff8dc, + crimson: 0xdc143c, + cyan: 0x00ffff, + darkblue: 0x00008b, + darkcyan: 0x008b8b, + darkgoldenrod: 0xb8860b, + darkgray: 0xa9a9a9, + darkgreen: 0x006400, + darkgrey: 0xa9a9a9, + darkkhaki: 0xbdb76b, + darkmagenta: 0x8b008b, + darkolivegreen: 0x556b2f, + darkorange: 0xff8c00, + darkorchid: 0x9932cc, + darkred: 0x8b0000, + darksalmon: 0xe9967a, + darkseagreen: 0x8fbc8f, + darkslateblue: 0x483d8b, + darkslategray: 0x2f4f4f, + darkslategrey: 0x2f4f4f, + darkturquoise: 0x00ced1, + darkviolet: 0x9400d3, + deeppink: 0xff1493, + deepskyblue: 0x00bfff, + dimgray: 0x696969, + dimgrey: 0x696969, + dodgerblue: 0x1e90ff, + firebrick: 0xb22222, + floralwhite: 0xfffaf0, + forestgreen: 0x228b22, + fuchsia: 0xff00ff, + gainsboro: 0xdcdcdc, + ghostwhite: 0xf8f8ff, + gold: 0xffd700, + goldenrod: 0xdaa520, + gray: 0x808080, + green: 0x008000, + greenyellow: 0xadff2f, + grey: 0x808080, + honeydew: 0xf0fff0, + hotpink: 0xff69b4, + indianred: 0xcd5c5c, + indigo: 0x4b0082, + ivory: 0xfffff0, + khaki: 0xf0e68c, + lavender: 0xe6e6fa, + lavenderblush: 0xfff0f5, + lawngreen: 0x7cfc00, + lemonchiffon: 0xfffacd, + lightblue: 0xadd8e6, + lightcoral: 0xf08080, + lightcyan: 0xe0ffff, + lightgoldenrodyellow: 0xfafad2, + lightgray: 0xd3d3d3, + lightgreen: 0x90ee90, + lightgrey: 0xd3d3d3, + lightpink: 0xffb6c1, + lightsalmon: 0xffa07a, + lightseagreen: 0x20b2aa, + lightskyblue: 0x87cefa, + lightslategray: 0x778899, + lightslategrey: 0x778899, + lightsteelblue: 0xb0c4de, + lightyellow: 0xffffe0, + lime: 0x00ff00, + limegreen: 0x32cd32, + linen: 0xfaf0e6, + magenta: 0xff00ff, + maroon: 0x800000, + mediumaquamarine: 0x66cdaa, + mediumblue: 0x0000cd, + mediumorchid: 0xba55d3, + mediumpurple: 0x9370db, + mediumseagreen: 0x3cb371, + mediumslateblue: 0x7b68ee, + mediumspringgreen: 0x00fa9a, + mediumturquoise: 0x48d1cc, + mediumvioletred: 0xc71585, + midnightblue: 0x191970, + mintcream: 0xf5fffa, + mistyrose: 0xffe4e1, + moccasin: 0xffe4b5, + navajowhite: 0xffdead, + navy: 0x000080, + oldlace: 0xfdf5e6, + olive: 0x808000, + olivedrab: 0x6b8e23, + orange: 0xffa500, + orangered: 0xff4500, + orchid: 0xda70d6, + palegoldenrod: 0xeee8aa, + palegreen: 0x98fb98, + paleturquoise: 0xafeeee, + palevioletred: 0xdb7093, + papayawhip: 0xffefd5, + peachpuff: 0xffdab9, + peru: 0xcd853f, + pink: 0xffc0cb, + plum: 0xdda0dd, + powderblue: 0xb0e0e6, + purple: 0x800080, + rebeccapurple: 0x663399, + red: 0xff0000, + rosybrown: 0xbc8f8f, + royalblue: 0x4169e1, + saddlebrown: 0x8b4513, + salmon: 0xfa8072, + sandybrown: 0xf4a460, + seagreen: 0x2e8b57, + seashell: 0xfff5ee, + sienna: 0xa0522d, + silver: 0xc0c0c0, + skyblue: 0x87ceeb, + slateblue: 0x6a5acd, + slategray: 0x708090, + slategrey: 0x708090, + snow: 0xfffafa, + springgreen: 0x00ff7f, + steelblue: 0x4682b4, + tan: 0xd2b48c, + teal: 0x008080, + thistle: 0xd8bfd8, + tomato: 0xff6347, + turquoise: 0x40e0d0, + violet: 0xee82ee, + wheat: 0xf5deb3, + white: 0xffffff, + whitesmoke: 0xf5f5f5, + yellow: 0xffff00, + yellowgreen: 0x9acd32 +}; + +define(Color$1, color, { + copy(channels) { + return Object.assign(new this.constructor, this, channels); + }, + displayable() { + return this.rgb().displayable(); + }, + hex: color_formatHex, // Deprecated! Use color.formatHex. + formatHex: color_formatHex, + formatHex8: color_formatHex8, + formatHsl: color_formatHsl, + formatRgb: color_formatRgb, + toString: color_formatRgb +}); + +function color_formatHex() { + return this.rgb().formatHex(); +} + +function color_formatHex8() { + return this.rgb().formatHex8(); +} + +function color_formatHsl() { + return hslConvert(this).formatHsl(); +} + +function color_formatRgb() { + return this.rgb().formatRgb(); +} + +function color(format) { + var m, l; + format = (format + "").trim().toLowerCase(); + return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000 + : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00 + : l === 8 ? rgba$1(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000 + : l === 4 ? rgba$1((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000 + : null) // invalid hex + : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) + : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) + : (m = reRgbaInteger.exec(format)) ? rgba$1(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) + : (m = reRgbaPercent.exec(format)) ? rgba$1(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) + : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) + : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) + : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins + : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) + : null; +} + +function rgbn(n) { + return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); +} + +function rgba$1(r, g, b, a) { + if (a <= 0) r = g = b = NaN; + return new Rgb(r, g, b, a); +} + +function rgbConvert(o) { + if (!(o instanceof Color$1)) o = color(o); + if (!o) return new Rgb; + o = o.rgb(); + return new Rgb(o.r, o.g, o.b, o.opacity); +} + +function rgb(r, g, b, opacity) { + return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); +} + +function Rgb(r, g, b, opacity) { + this.r = +r; + this.g = +g; + this.b = +b; + this.opacity = +opacity; +} + +define(Rgb, rgb, extend$1(Color$1, { + brighter(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + darker(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + rgb() { + return this; + }, + clamp() { + return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); + }, + displayable() { + return (-0.5 <= this.r && this.r < 255.5) + && (-0.5 <= this.g && this.g < 255.5) + && (-0.5 <= this.b && this.b < 255.5) + && (0 <= this.opacity && this.opacity <= 1); + }, + hex: rgb_formatHex, // Deprecated! Use color.formatHex. + formatHex: rgb_formatHex, + formatHex8: rgb_formatHex8, + formatRgb: rgb_formatRgb, + toString: rgb_formatRgb +})); + +function rgb_formatHex() { + return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; +} + +function rgb_formatHex8() { + return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; +} + +function rgb_formatRgb() { + const a = clampa(this.opacity); + return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`; +} + +function clampa(opacity) { + return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); +} + +function clampi(value) { + return Math.max(0, Math.min(255, Math.round(value) || 0)); +} + +function hex(value) { + value = clampi(value); + return (value < 16 ? "0" : "") + value.toString(16); +} + +function hsla(h, s, l, a) { + if (a <= 0) h = s = l = NaN; + else if (l <= 0 || l >= 1) h = s = NaN; + else if (s <= 0) h = NaN; + return new Hsl(h, s, l, a); +} + +function hslConvert(o) { + if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); + if (!(o instanceof Color$1)) o = color(o); + if (!o) return new Hsl; + if (o instanceof Hsl) return o; + o = o.rgb(); + var r = o.r / 255, + g = o.g / 255, + b = o.b / 255, + min = Math.min(r, g, b), + max = Math.max(r, g, b), + h = NaN, + s = max - min, + l = (max + min) / 2; + if (s) { + if (r === max) h = (g - b) / s + (g < b) * 6; + else if (g === max) h = (b - r) / s + 2; + else h = (r - g) / s + 4; + s /= l < 0.5 ? max + min : 2 - max - min; + h *= 60; + } else { + s = l > 0 && l < 1 ? 0 : h; + } + return new Hsl(h, s, l, o.opacity); +} + +function hsl(h, s, l, opacity) { + return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); +} + +function Hsl(h, s, l, opacity) { + this.h = +h; + this.s = +s; + this.l = +l; + this.opacity = +opacity; +} + +define(Hsl, hsl, extend$1(Color$1, { + brighter(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + darker(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + rgb() { + var h = this.h % 360 + (this.h < 0) * 360, + s = isNaN(h) || isNaN(this.s) ? 0 : this.s, + l = this.l, + m2 = l + (l < 0.5 ? l : 1 - l) * s, + m1 = 2 * l - m2; + return new Rgb( + hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), + hsl2rgb(h, m1, m2), + hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), + this.opacity + ); + }, + clamp() { + return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); + }, + displayable() { + return (0 <= this.s && this.s <= 1 || isNaN(this.s)) + && (0 <= this.l && this.l <= 1) + && (0 <= this.opacity && this.opacity <= 1); + }, + formatHsl() { + const a = clampa(this.opacity); + return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`; + } +})); + +function clamph(value) { + value = (value || 0) % 360; + return value < 0 ? value + 360 : value; +} + +function clampt(value) { + return Math.max(0, Math.min(1, value || 0)); +} + +/* From FvD 13.37, CSS Color Module Level 3 */ +function hsl2rgb(h, m1, m2) { + return (h < 60 ? m1 + (m2 - m1) * h / 60 + : h < 180 ? m2 + : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 + : m1) * 255; +} + +var constant$1 = x => () => x; + +function linear(a, d) { + return function(t) { + return a + t * d; + }; +} + +function exponential(a, b, y) { + return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { + return Math.pow(a + t * b, y); + }; +} + +function hue(a, b) { + var d = b - a; + return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$1(isNaN(a) ? b : a); +} + +function gamma(y) { + return (y = +y) === 1 ? nogamma : function(a, b) { + return b - a ? exponential(a, b, y) : constant$1(isNaN(a) ? b : a); + }; +} + +function nogamma(a, b) { + var d = b - a; + return d ? linear(a, d) : constant$1(isNaN(a) ? b : a); +} + +var interpolateRgb = (function rgbGamma(y) { + var color = gamma(y); + + function rgb$1(start, end) { + var r = color((start = rgb(start)).r, (end = rgb(end)).r), + g = color(start.g, end.g), + b = color(start.b, end.b), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.r = r(t); + start.g = g(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; + } + + rgb$1.gamma = rgbGamma; + + return rgb$1; +})(1); + +function interpolateNumber(a, b) { + return a = +a, b = +b, function(t) { + return a * (1 - t) + b * t; + }; +} + +var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, + reB = new RegExp(reA.source, "g"); + +function zero(b) { + return function() { + return b; + }; +} + +function one(b) { + return function(t) { + return b(t) + ""; + }; +} + +function interpolateString(a, b) { + var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b + am, // current match in a + bm, // current match in b + bs, // string preceding current number in b, if any + i = -1, // index in s + s = [], // string constants and placeholders + q = []; // number interpolators + + // Coerce inputs to strings. + a = a + "", b = b + ""; + + // Interpolate pairs of numbers in a & b. + while ((am = reA.exec(a)) + && (bm = reB.exec(b))) { + if ((bs = bm.index) > bi) { // a string precedes the next number in b + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match + if (s[i]) s[i] += bm; // coalesce with previous string + else s[++i] = bm; + } else { // interpolate non-matching numbers + s[++i] = null; + q.push({i: i, x: interpolateNumber(am, bm)}); + } + bi = reB.lastIndex; + } + + // Add remains of b. + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + + // Special optimization for only a single match. + // Otherwise, interpolate each of the numbers and rejoin the string. + return s.length < 2 ? (q[0] + ? one(q[0].x) + : zero(b)) + : (b = q.length, function(t) { + for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); +} + +var degrees = 180 / Math.PI; + +var identity$1 = { + translateX: 0, + translateY: 0, + rotate: 0, + skewX: 0, + scaleX: 1, + scaleY: 1 +}; + +function decompose(a, b, c, d, e, f) { + var scaleX, scaleY, skewX; + if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX; + if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX; + if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY; + if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX; + return { + translateX: e, + translateY: f, + rotate: Math.atan2(b, a) * degrees, + skewX: Math.atan(skewX) * degrees, + scaleX: scaleX, + scaleY: scaleY + }; +} + +var svgNode; + +/* eslint-disable no-undef */ +function parseCss(value) { + const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); + return m.isIdentity ? identity$1 : decompose(m.a, m.b, m.c, m.d, m.e, m.f); +} + +function parseSvg(value) { + if (value == null) return identity$1; + if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); + svgNode.setAttribute("transform", value); + if (!(value = svgNode.transform.baseVal.consolidate())) return identity$1; + value = value.matrix; + return decompose(value.a, value.b, value.c, value.d, value.e, value.f); +} + +function interpolateTransform(parse, pxComma, pxParen, degParen) { + + function pop(s) { + return s.length ? s.pop() + " " : ""; + } + + function translate(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push("translate(", null, pxComma, null, pxParen); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb || yb) { + s.push("translate(" + xb + pxComma + yb + pxParen); + } + } + + function rotate(a, b, s, q) { + if (a !== b) { + if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path + q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "rotate(" + b + degParen); + } + } + + function skewX(a, b, s, q) { + if (a !== b) { + q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "skewX(" + b + degParen); + } + } + + function scale(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push(pop(s) + "scale(", null, ",", null, ")"); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb !== 1 || yb !== 1) { + s.push(pop(s) + "scale(" + xb + "," + yb + ")"); + } + } + + return function(a, b) { + var s = [], // string constants and placeholders + q = []; // number interpolators + a = parse(a), b = parse(b); + translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); + rotate(a.rotate, b.rotate, s, q); + skewX(a.skewX, b.skewX, s, q); + scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); + a = b = null; // gc + return function(t) { + var i = -1, n = q.length, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + }; +} + +var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); +var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); + +var frame = 0, // is an animation frame pending? + timeout$1 = 0, // is a timeout pending? + interval = 0, // are any timers active? + pokeDelay = 1000, // how frequently we check for clock skew + taskHead, + taskTail, + clockLast = 0, + clockNow = 0, + clockSkew = 0, + clock = typeof performance === "object" && performance.now ? performance : Date, + setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); }; + +function now() { + return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); +} + +function clearNow() { + clockNow = 0; +} + +function Timer() { + this._call = + this._time = + this._next = null; +} + +Timer.prototype = timer.prototype = { + constructor: Timer, + restart: function(callback, delay, time) { + if (typeof callback !== "function") throw new TypeError("callback is not a function"); + time = (time == null ? now() : +time) + (delay == null ? 0 : +delay); + if (!this._next && taskTail !== this) { + if (taskTail) taskTail._next = this; + else taskHead = this; + taskTail = this; + } + this._call = callback; + this._time = time; + sleep(); + }, + stop: function() { + if (this._call) { + this._call = null; + this._time = Infinity; + sleep(); + } + } +}; + +function timer(callback, delay, time) { + var t = new Timer; + t.restart(callback, delay, time); + return t; +} + +function timerFlush() { + now(); // Get the current time, if not already set. + ++frame; // Pretend we’ve set an alarm, if we haven’t already. + var t = taskHead, e; + while (t) { + if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e); + t = t._next; + } + --frame; +} + +function wake() { + clockNow = (clockLast = clock.now()) + clockSkew; + frame = timeout$1 = 0; + try { + timerFlush(); + } finally { + frame = 0; + nap(); + clockNow = 0; + } +} + +function poke() { + var now = clock.now(), delay = now - clockLast; + if (delay > pokeDelay) clockSkew -= delay, clockLast = now; +} + +function nap() { + var t0, t1 = taskHead, t2, time = Infinity; + while (t1) { + if (t1._call) { + if (time > t1._time) time = t1._time; + t0 = t1, t1 = t1._next; + } else { + t2 = t1._next, t1._next = null; + t1 = t0 ? t0._next = t2 : taskHead = t2; + } + } + taskTail = t0; + sleep(time); +} + +function sleep(time) { + if (frame) return; // Soonest alarm already set, or will be. + if (timeout$1) timeout$1 = clearTimeout(timeout$1); + var delay = time - clockNow; // Strictly less than if we recomputed clockNow. + if (delay > 24) { + if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew); + if (interval) interval = clearInterval(interval); + } else { + if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay); + frame = 1, setFrame(wake); + } +} + +function timeout(callback, delay, time) { + var t = new Timer; + delay = delay == null ? 0 : +delay; + t.restart(elapsed => { + t.stop(); + callback(elapsed + delay); + }, delay, time); + return t; +} + +var emptyOn = dispatch("start", "end", "cancel", "interrupt"); +var emptyTween = []; + +var CREATED = 0; +var SCHEDULED = 1; +var STARTING = 2; +var STARTED = 3; +var RUNNING = 4; +var ENDING = 5; +var ENDED = 6; + +function schedule(node, name, id, index, group, timing) { + var schedules = node.__transition; + if (!schedules) node.__transition = {}; + else if (id in schedules) return; + create$1(node, id, { + name: name, + index: index, // For context during callback. + group: group, // For context during callback. + on: emptyOn, + tween: emptyTween, + time: timing.time, + delay: timing.delay, + duration: timing.duration, + ease: timing.ease, + timer: null, + state: CREATED + }); +} + +function init$1(node, id) { + var schedule = get(node, id); + if (schedule.state > CREATED) throw new Error("too late; already scheduled"); + return schedule; +} + +function set$1(node, id) { + var schedule = get(node, id); + if (schedule.state > STARTED) throw new Error("too late; already running"); + return schedule; +} + +function get(node, id) { + var schedule = node.__transition; + if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found"); + return schedule; +} + +function create$1(node, id, self) { + var schedules = node.__transition, + tween; + + // Initialize the self timer when the transition is created. + // Note the actual delay is not known until the first callback! + schedules[id] = self; + self.timer = timer(schedule, 0, self.time); + + function schedule(elapsed) { + self.state = SCHEDULED; + self.timer.restart(start, self.delay, self.time); + + // If the elapsed delay is less than our first sleep, start immediately. + if (self.delay <= elapsed) start(elapsed - self.delay); + } + + function start(elapsed) { + var i, j, n, o; + + // If the state is not SCHEDULED, then we previously errored on start. + if (self.state !== SCHEDULED) return stop(); + + for (i in schedules) { + o = schedules[i]; + if (o.name !== self.name) continue; + + // While this element already has a starting transition during this frame, + // defer starting an interrupting transition until that transition has a + // chance to tick (and possibly end); see d3/d3-transition#54! + if (o.state === STARTED) return timeout(start); + + // Interrupt the active transition, if any. + if (o.state === RUNNING) { + o.state = ENDED; + o.timer.stop(); + o.on.call("interrupt", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + + // Cancel any pre-empted transitions. + else if (+i < id) { + o.state = ENDED; + o.timer.stop(); + o.on.call("cancel", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + } + + // Defer the first tick to end of the current frame; see d3/d3#1576. + // Note the transition may be canceled after start and before the first tick! + // Note this must be scheduled before the start event; see d3/d3-transition#16! + // Assuming this is successful, subsequent callbacks go straight to tick. + timeout(function() { + if (self.state === STARTED) { + self.state = RUNNING; + self.timer.restart(tick, self.delay, self.time); + tick(elapsed); + } + }); + + // Dispatch the start event. + // Note this must be done before the tween are initialized. + self.state = STARTING; + self.on.call("start", node, node.__data__, self.index, self.group); + if (self.state !== STARTING) return; // interrupted + self.state = STARTED; + + // Initialize the tween, deleting null tween. + tween = new Array(n = self.tween.length); + for (i = 0, j = -1; i < n; ++i) { + if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) { + tween[++j] = o; + } + } + tween.length = j + 1; + } + + function tick(elapsed) { + var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1), + i = -1, + n = tween.length; + + while (++i < n) { + tween[i].call(node, t); + } + + // Dispatch the end event. + if (self.state === ENDING) { + self.on.call("end", node, node.__data__, self.index, self.group); + stop(); + } + } + + function stop() { + self.state = ENDED; + self.timer.stop(); + delete schedules[id]; + for (var i in schedules) return; // eslint-disable-line no-unused-vars + delete node.__transition; + } +} + +function interrupt(node, name) { + var schedules = node.__transition, + schedule, + active, + empty = true, + i; + + if (!schedules) return; + + name = name == null ? null : name + ""; + + for (i in schedules) { + if ((schedule = schedules[i]).name !== name) { empty = false; continue; } + active = schedule.state > STARTING && schedule.state < ENDING; + schedule.state = ENDED; + schedule.timer.stop(); + schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group); + delete schedules[i]; + } + + if (empty) delete node.__transition; +} + +function selection_interrupt(name) { + return this.each(function() { + interrupt(this, name); + }); +} + +function tweenRemove(id, name) { + var tween0, tween1; + return function() { + var schedule = set$1(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = tween0 = tween; + for (var i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1 = tween1.slice(); + tween1.splice(i, 1); + break; + } + } + } + + schedule.tween = tween1; + }; +} + +function tweenFunction(id, name, value) { + var tween0, tween1; + if (typeof value !== "function") throw new Error; + return function() { + var schedule = set$1(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = (tween0 = tween).slice(); + for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1[i] = t; + break; + } + } + if (i === n) tween1.push(t); + } + + schedule.tween = tween1; + }; +} + +function transition_tween(name, value) { + var id = this._id; + + name += ""; + + if (arguments.length < 2) { + var tween = get(this.node(), id).tween; + for (var i = 0, n = tween.length, t; i < n; ++i) { + if ((t = tween[i]).name === name) { + return t.value; + } + } + return null; + } + + return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value)); +} + +function tweenValue(transition, name, value) { + var id = transition._id; + + transition.each(function() { + var schedule = set$1(this, id); + (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments); + }); + + return function(node) { + return get(node, id).value[name]; + }; +} + +function interpolate(a, b) { + var c; + return (typeof b === "number" ? interpolateNumber + : b instanceof color ? interpolateRgb + : (c = color(b)) ? (b = c, interpolateRgb) + : interpolateString)(a, b); +} + +function attrRemove(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttribute(name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrConstantNS(fullname, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttributeNS(fullname.space, fullname.local); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttribute(name); + string0 = this.getAttribute(name); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function attrFunctionNS(fullname, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local); + string0 = this.getAttributeNS(fullname.space, fullname.local); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function transition_attr(name, value) { + var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate; + return this.attrTween(name, typeof value === "function" + ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value)) + : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname) + : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value)); +} + +function attrInterpolate(name, i) { + return function(t) { + this.setAttribute(name, i.call(this, t)); + }; +} + +function attrInterpolateNS(fullname, i) { + return function(t) { + this.setAttributeNS(fullname.space, fullname.local, i.call(this, t)); + }; +} + +function attrTweenNS(fullname, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i); + return t0; + } + tween._value = value; + return tween; +} + +function attrTween(name, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_attrTween(name, value) { + var key = "attr." + name; + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + var fullname = namespace(name); + return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value)); +} + +function delayFunction(id, value) { + return function() { + init$1(this, id).delay = +value.apply(this, arguments); + }; +} + +function delayConstant(id, value) { + return value = +value, function() { + init$1(this, id).delay = value; + }; +} + +function transition_delay(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? delayFunction + : delayConstant)(id, value)) + : get(this.node(), id).delay; +} + +function durationFunction(id, value) { + return function() { + set$1(this, id).duration = +value.apply(this, arguments); + }; +} + +function durationConstant(id, value) { + return value = +value, function() { + set$1(this, id).duration = value; + }; +} + +function transition_duration(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? durationFunction + : durationConstant)(id, value)) + : get(this.node(), id).duration; +} + +function easeConstant(id, value) { + if (typeof value !== "function") throw new Error; + return function() { + set$1(this, id).ease = value; + }; +} + +function transition_ease(value) { + var id = this._id; + + return arguments.length + ? this.each(easeConstant(id, value)) + : get(this.node(), id).ease; +} + +function easeVarying(id, value) { + return function() { + var v = value.apply(this, arguments); + if (typeof v !== "function") throw new Error; + set$1(this, id).ease = v; + }; +} + +function transition_easeVarying(value) { + if (typeof value !== "function") throw new Error; + return this.each(easeVarying(this._id, value)); +} + +function transition_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Transition(subgroups, this._parents, this._name, this._id); +} + +function transition_merge(transition) { + if (transition._id !== this._id) throw new Error; + + for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Transition(merges, this._parents, this._name, this._id); +} + +function start(name) { + return (name + "").trim().split(/^|\s+/).every(function(t) { + var i = t.indexOf("."); + if (i >= 0) t = t.slice(0, i); + return !t || t === "start"; + }); +} + +function onFunction(id, name, listener) { + var on0, on1, sit = start(name) ? init$1 : set$1; + return function() { + var schedule = sit(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener); + + schedule.on = on1; + }; +} + +function transition_on(name, listener) { + var id = this._id; + + return arguments.length < 2 + ? get(this.node(), id).on.on(name) + : this.each(onFunction(id, name, listener)); +} + +function removeFunction(id) { + return function() { + var parent = this.parentNode; + for (var i in this.__transition) if (+i !== id) return; + if (parent) parent.removeChild(this); + }; +} + +function transition_remove() { + return this.on("end.remove", removeFunction(this._id)); +} + +function transition_select(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + schedule(subgroup[i], name, id, i, subgroup, get(node, id)); + } + } + } + + return new Transition(subgroups, this._parents, name, id); +} + +function transition_selectAll(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + for (var children = select.call(node, node.__data__, i, group), child, inherit = get(node, id), k = 0, l = children.length; k < l; ++k) { + if (child = children[k]) { + schedule(child, name, id, k, children, inherit); + } + } + subgroups.push(children); + parents.push(node); + } + } + } + + return new Transition(subgroups, parents, name, id); +} + +var Selection = selection.prototype.constructor; + +function transition_selection() { + return new Selection(this._groups, this._parents); +} + +function styleNull(name, interpolate) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + string1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, string10 = string1); + }; +} + +function styleRemove(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = styleValue(this, name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function styleFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + value1 = value(this), + string1 = value1 + ""; + if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function styleMaybeRemove(id, name) { + var on0, on1, listener0, key = "style." + name, event = "end." + key, remove; + return function() { + var schedule = set$1(this, id), + on = schedule.on, + listener = schedule.value[key] == null ? remove || (remove = styleRemove(name)) : undefined; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener); + + schedule.on = on1; + }; +} + +function transition_style(name, value, priority) { + var i = (name += "") === "transform" ? interpolateTransformCss : interpolate; + return value == null ? this + .styleTween(name, styleNull(name, i)) + .on("end.style." + name, styleRemove(name)) + : typeof value === "function" ? this + .styleTween(name, styleFunction(name, i, tweenValue(this, "style." + name, value))) + .each(styleMaybeRemove(this._id, name)) + : this + .styleTween(name, styleConstant(name, i, value), priority) + .on("end.style." + name, null); +} + +function styleInterpolate(name, i, priority) { + return function(t) { + this.style.setProperty(name, i.call(this, t), priority); + }; +} + +function styleTween(name, value, priority) { + var t, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority); + return t; + } + tween._value = value; + return tween; +} + +function transition_styleTween(name, value, priority) { + var key = "style." + (name += ""); + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, styleTween(name, value, priority == null ? "" : priority)); +} + +function textConstant(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction(value) { + return function() { + var value1 = value(this); + this.textContent = value1 == null ? "" : value1; + }; +} + +function transition_text(value) { + return this.tween("text", typeof value === "function" + ? textFunction(tweenValue(this, "text", value)) + : textConstant(value == null ? "" : value + "")); +} + +function textInterpolate(i) { + return function(t) { + this.textContent = i.call(this, t); + }; +} + +function textTween(value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && textInterpolate(i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_textTween(value) { + var key = "text"; + if (arguments.length < 1) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, textTween(value)); +} + +function transition_transition() { + var name = this._name, + id0 = this._id, + id1 = newId(); + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + var inherit = get(node, id0); + schedule(node, name, id1, i, group, { + time: inherit.time + inherit.delay + inherit.duration, + delay: 0, + duration: inherit.duration, + ease: inherit.ease + }); + } + } + } + + return new Transition(groups, this._parents, name, id1); +} + +function transition_end() { + var on0, on1, that = this, id = that._id, size = that.size(); + return new Promise(function(resolve, reject) { + var cancel = {value: reject}, + end = {value: function() { if (--size === 0) resolve(); }}; + + that.each(function() { + var schedule = set$1(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) { + on1 = (on0 = on).copy(); + on1._.cancel.push(cancel); + on1._.interrupt.push(cancel); + on1._.end.push(end); + } + + schedule.on = on1; + }); + + // The selection was empty, resolve end immediately + if (size === 0) resolve(); + }); +} + +var id$m = 0; + +function Transition(groups, parents, name, id) { + this._groups = groups; + this._parents = parents; + this._name = name; + this._id = id; +} + +function newId() { + return ++id$m; +} + +var selection_prototype = selection.prototype; + +Transition.prototype = { + constructor: Transition, + select: transition_select, + selectAll: transition_selectAll, + selectChild: selection_prototype.selectChild, + selectChildren: selection_prototype.selectChildren, + filter: transition_filter, + merge: transition_merge, + selection: transition_selection, + transition: transition_transition, + call: selection_prototype.call, + nodes: selection_prototype.nodes, + node: selection_prototype.node, + size: selection_prototype.size, + empty: selection_prototype.empty, + each: selection_prototype.each, + on: transition_on, + attr: transition_attr, + attrTween: transition_attrTween, + style: transition_style, + styleTween: transition_styleTween, + text: transition_text, + textTween: transition_textTween, + remove: transition_remove, + tween: transition_tween, + delay: transition_delay, + duration: transition_duration, + ease: transition_ease, + easeVarying: transition_easeVarying, + end: transition_end, + [Symbol.iterator]: selection_prototype[Symbol.iterator] +}; + +function cubicInOut(t) { + return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +} + +var defaultTiming = { + time: null, // Set on use. + delay: 0, + duration: 250, + ease: cubicInOut +}; + +function inherit(node, id) { + var timing; + while (!(timing = node.__transition) || !(timing = timing[id])) { + if (!(node = node.parentNode)) { + throw new Error(`transition ${id} not found`); + } + } + return timing; +} + +function selection_transition(name) { + var id, + timing; + + if (name instanceof Transition) { + id = name._id, name = name._name; + } else { + id = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + ""; + } + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + schedule(node, name, id, i, group, timing || inherit(node, id)); + } + } + } + + return new Transition(groups, this._parents, name, id); +} + +selection.prototype.interrupt = selection_interrupt; +selection.prototype.transition = selection_transition; + +const abs$1 = Math.abs; +const atan2 = Math.atan2; +const cos = Math.cos; +const max = Math.max; +const min = Math.min; +const sin = Math.sin; +const sqrt = Math.sqrt; + +const epsilon = 1e-12; +const pi = Math.PI; +const halfPi = pi / 2; +const tau = 2 * pi; + +function acos(x) { + return x > 1 ? 0 : x < -1 ? pi : Math.acos(x); +} + +function asin(x) { + return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x); +} + +function Linear(context) { + this._context = context; +} + +Linear.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: this._context.lineTo(x, y); break; + } + } +}; + +function curveLinear(context) { + return new Linear(context); +} + +class Bump { + constructor(context, x) { + this._context = context; + this._x = x; + } + areaStart() { + this._line = 0; + } + areaEnd() { + this._line = NaN; + } + lineStart() { + this._point = 0; + } + lineEnd() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + } + point(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: { + this._point = 1; + if (this._line) this._context.lineTo(x, y); + else this._context.moveTo(x, y); + break; + } + case 1: this._point = 2; // falls through + default: { + if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y); + else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y); + break; + } + } + this._x0 = x, this._y0 = y; + } +} + +function bumpX(context) { + return new Bump(context, true); +} + +function bumpY(context) { + return new Bump(context, false); +} + +function noop() {} + +function point$3(that, x, y) { + that._context.bezierCurveTo( + (2 * that._x0 + that._x1) / 3, + (2 * that._y0 + that._y1) / 3, + (that._x0 + 2 * that._x1) / 3, + (that._y0 + 2 * that._y1) / 3, + (that._x0 + 4 * that._x1 + x) / 6, + (that._y0 + 4 * that._y1 + y) / 6 + ); +} + +function Basis(context) { + this._context = context; +} + +Basis.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 3: point$3(this, this._x1, this._y1); // falls through + case 2: this._context.lineTo(this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasis(context) { + return new Basis(context); +} + +function BasisClosed(context) { + this._context = context; +} + +BasisClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x2, this._y2); + this._context.closePath(); + break; + } + case 2: { + this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3); + this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x2, this._y2); + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x2 = x, this._y2 = y; break; + case 1: this._point = 2; this._x3 = x, this._y3 = y; break; + case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6); break; + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasisClosed(context) { + return new BasisClosed(context); +} + +function BasisOpen(context) { + this._context = context; +} + +BasisOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = NaN; + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break; + case 3: this._point = 4; // falls through + default: point$3(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasisOpen(context) { + return new BasisOpen(context); +} + +function Bundle(context, beta) { + this._basis = new Basis(context); + this._beta = beta; +} + +Bundle.prototype = { + lineStart: function() { + this._x = []; + this._y = []; + this._basis.lineStart(); + }, + lineEnd: function() { + var x = this._x, + y = this._y, + j = x.length - 1; + + if (j > 0) { + var x0 = x[0], + y0 = y[0], + dx = x[j] - x0, + dy = y[j] - y0, + i = -1, + t; + + while (++i <= j) { + t = i / j; + this._basis.point( + this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), + this._beta * y[i] + (1 - this._beta) * (y0 + t * dy) + ); + } + } + + this._x = this._y = null; + this._basis.lineEnd(); + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +var curveBundle = (function custom(beta) { + + function bundle(context) { + return beta === 1 ? new Basis(context) : new Bundle(context, beta); + } + + bundle.beta = function(beta) { + return custom(+beta); + }; + + return bundle; +})(0.85); + +function point$2(that, x, y) { + that._context.bezierCurveTo( + that._x1 + that._k * (that._x2 - that._x0), + that._y1 + that._k * (that._y2 - that._y0), + that._x2 + that._k * (that._x1 - x), + that._y2 + that._k * (that._y1 - y), + that._x2, + that._y2 + ); +} + +function Cardinal(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +Cardinal.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x2, this._y2); break; + case 3: point$2(this, this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; this._x1 = x, this._y1 = y; break; + case 2: this._point = 3; // falls through + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinal = (function custom(tension) { + + function cardinal(context) { + return new Cardinal(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalClosed(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 2: { + this._context.lineTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + this.point(this._x5, this._y5); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinalClosed = (function custom(tension) { + + function cardinal(context) { + return new CardinalClosed(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalOpen(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; + case 3: this._point = 4; // falls through + default: point$2(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinalOpen = (function custom(tension) { + + function cardinal(context) { + return new CardinalOpen(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function point$1(that, x, y) { + var x1 = that._x1, + y1 = that._y1, + x2 = that._x2, + y2 = that._y2; + + if (that._l01_a > epsilon) { + var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, + n = 3 * that._l01_a * (that._l01_a + that._l12_a); + x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n; + y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n; + } + + if (that._l23_a > epsilon) { + var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, + m = 3 * that._l23_a * (that._l23_a + that._l12_a); + x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m; + y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m; + } + + that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2); +} + +function CatmullRom(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRom.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x2, this._y2); break; + case 3: this.point(this._x2, this._y2); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; // falls through + default: point$1(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRom = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomClosed(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 2: { + this._context.lineTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + this.point(this._x5, this._y5); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$1(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRomClosed = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomOpen(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; + case 3: this._point = 4; // falls through + default: point$1(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRomOpen = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function LinearClosed(context) { + this._context = context; +} + +LinearClosed.prototype = { + areaStart: noop, + areaEnd: noop, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._point) this._context.closePath(); + }, + point: function(x, y) { + x = +x, y = +y; + if (this._point) this._context.lineTo(x, y); + else this._point = 1, this._context.moveTo(x, y); + } +}; + +function curveLinearClosed(context) { + return new LinearClosed(context); +} + +function sign(x) { + return x < 0 ? -1 : 1; +} + +// Calculate the slopes of the tangents (Hermite-type interpolation) based on +// the following paper: Steffen, M. 1990. A Simple Method for Monotonic +// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO. +// NOV(II), P. 443, 1990. +function slope3(that, x2, y2) { + var h0 = that._x1 - that._x0, + h1 = x2 - that._x1, + s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), + s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), + p = (s0 * h1 + s1 * h0) / (h0 + h1); + return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0; +} + +// Calculate a one-sided slope. +function slope2(that, t) { + var h = that._x1 - that._x0; + return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t; +} + +// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations +// "you can express cubic Hermite interpolation in terms of cubic Bézier curves +// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1". +function point(that, t0, t1) { + var x0 = that._x0, + y0 = that._y0, + x1 = that._x1, + y1 = that._y1, + dx = (x1 - x0) / 3; + that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1); +} + +function MonotoneX(context) { + this._context = context; +} + +MonotoneX.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = + this._t0 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x1, this._y1); break; + case 3: point(this, this._t0, slope2(this, this._t0)); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + var t1 = NaN; + + x = +x, y = +y; + if (x === this._x1 && y === this._y1) return; // Ignore coincident points. + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; point(this, slope2(this, t1 = slope3(this, x, y)), t1); break; + default: point(this, this._t0, t1 = slope3(this, x, y)); break; + } + + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + this._t0 = t1; + } +}; + +function MonotoneY(context) { + this._context = new ReflectContext(context); +} + +(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) { + MonotoneX.prototype.point.call(this, y, x); +}; + +function ReflectContext(context) { + this._context = context; +} + +ReflectContext.prototype = { + moveTo: function(x, y) { this._context.moveTo(y, x); }, + closePath: function() { this._context.closePath(); }, + lineTo: function(x, y) { this._context.lineTo(y, x); }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); } +}; + +function monotoneX(context) { + return new MonotoneX(context); +} + +function monotoneY(context) { + return new MonotoneY(context); +} + +function Natural(context) { + this._context = context; +} + +Natural.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = []; + this._y = []; + }, + lineEnd: function() { + var x = this._x, + y = this._y, + n = x.length; + + if (n) { + this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]); + if (n === 2) { + this._context.lineTo(x[1], y[1]); + } else { + var px = controlPoints(x), + py = controlPoints(y); + for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) { + this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]); + } + } + } + + if (this._line || (this._line !== 0 && n === 1)) this._context.closePath(); + this._line = 1 - this._line; + this._x = this._y = null; + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +// See https://www.particleincell.com/2012/bezier-splines/ for derivation. +function controlPoints(x) { + var i, + n = x.length - 1, + m, + a = new Array(n), + b = new Array(n), + r = new Array(n); + a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1]; + for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1]; + a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n]; + for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1]; + a[n - 1] = r[n - 1] / b[n - 1]; + for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i]; + b[n - 1] = (x[n] + a[n - 1]) / 2; + for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1]; + return [a, b]; +} + +function curveNatural(context) { + return new Natural(context); +} + +function Step(context, t) { + this._context = context; + this._t = t; +} + +Step.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = this._y = NaN; + this._point = 0; + }, + lineEnd: function() { + if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y); + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: { + if (this._t <= 0) { + this._context.lineTo(this._x, y); + this._context.lineTo(x, y); + } else { + var x1 = this._x * (1 - this._t) + x * this._t; + this._context.lineTo(x1, this._y); + this._context.lineTo(x1, y); + } + break; + } + } + this._x = x, this._y = y; + } +}; + +function curveStep(context) { + return new Step(context, 0.5); +} + +function stepBefore(context) { + return new Step(context, 0); +} + +function stepAfter(context) { + return new Step(context, 1); +} + +function Transform(k, x, y) { + this.k = k; + this.x = x; + this.y = y; +} + +Transform.prototype = { + constructor: Transform, + scale: function(k) { + return k === 1 ? this : new Transform(this.k * k, this.x, this.y); + }, + translate: function(x, y) { + return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y); + }, + apply: function(point) { + return [point[0] * this.k + this.x, point[1] * this.k + this.y]; + }, + applyX: function(x) { + return x * this.k + this.x; + }, + applyY: function(y) { + return y * this.k + this.y; + }, + invert: function(location) { + return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k]; + }, + invertX: function(x) { + return (x - this.x) / this.k; + }, + invertY: function(y) { + return (y - this.y) / this.k; + }, + rescaleX: function(x) { + return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x)); + }, + rescaleY: function(y) { + return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y)); + }, + toString: function() { + return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; + } +}; + +Transform.prototype; + +/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */ + +const { + entries, + setPrototypeOf, + isFrozen, + getPrototypeOf, + getOwnPropertyDescriptor +} = Object; +let { + freeze, + seal, + create +} = Object; // eslint-disable-line import/no-mutable-exports +let { + apply: apply$1, + construct +} = typeof Reflect !== 'undefined' && Reflect; +if (!freeze) { + freeze = function freeze(x) { + return x; + }; +} +if (!seal) { + seal = function seal(x) { + return x; + }; +} +if (!apply$1) { + apply$1 = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; +} +if (!construct) { + construct = function construct(Func, args) { + return new Func(...args); + }; +} +const arrayForEach = unapply(Array.prototype.forEach); +const arrayPop = unapply(Array.prototype.pop); +const arrayPush = unapply(Array.prototype.push); +const stringToLowerCase = unapply(String.prototype.toLowerCase); +const stringToString = unapply(String.prototype.toString); +const stringMatch = unapply(String.prototype.match); +const stringReplace = unapply(String.prototype.replace); +const stringIndexOf = unapply(String.prototype.indexOf); +const stringTrim = unapply(String.prototype.trim); +const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); +const regExpTest = unapply(RegExp.prototype.test); +const typeErrorCreate = unconstruct(TypeError); + +/** + * Creates a new function that calls the given function with a specified thisArg and arguments. + * + * @param {Function} func - The function to be wrapped and called. + * @returns {Function} A new function that calls the given function with a specified thisArg and arguments. + */ +function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + return apply$1(func, thisArg, args); + }; +} + +/** + * Creates a new function that constructs an instance of the given constructor function with the provided arguments. + * + * @param {Function} func - The constructor function to be wrapped and called. + * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments. + */ +function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + return construct(func, args); + }; +} + +/** + * Add properties to a lookup table + * + * @param {Object} set - The set to which elements will be added. + * @param {Array} array - The array containing elements to be added to the set. + * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set. + * @returns {Object} The modified set with added elements. + */ +function addToSet(set, array) { + let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + let l = array.length; + while (l--) { + let element = array[l]; + if (typeof element === 'string') { + const lcElement = transformCaseFunc(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + element = lcElement; + } + } + set[element] = true; + } + return set; +} + +/** + * Clean up an array to harden against CSPP + * + * @param {Array} array - The array to be cleaned. + * @returns {Array} The cleaned version of the array + */ +function cleanArray(array) { + for (let index = 0; index < array.length; index++) { + const isPropertyExist = objectHasOwnProperty(array, index); + if (!isPropertyExist) { + array[index] = null; + } + } + return array; +} + +/** + * Shallow clone an object + * + * @param {Object} object - The object to be cloned. + * @returns {Object} A new object that copies the original. + */ +function clone(object) { + const newObject = create(null); + for (const [property, value] of entries(object)) { + const isPropertyExist = objectHasOwnProperty(object, property); + if (isPropertyExist) { + if (Array.isArray(value)) { + newObject[property] = cleanArray(value); + } else if (value && typeof value === 'object' && value.constructor === Object) { + newObject[property] = clone(value); + } else { + newObject[property] = value; + } + } + } + return newObject; +} + +/** + * This method automatically checks if the prop is function or getter and behaves accordingly. + * + * @param {Object} object - The object to look up the getter function in its prototype chain. + * @param {String} prop - The property name for which to find the getter function. + * @returns {Function} The getter function found in the prototype chain or a fallback function. + */ +function lookupGetter(object, prop) { + while (object !== null) { + const desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + object = getPrototypeOf(object); + } + function fallbackValue() { + return null; + } + return fallbackValue; +} + +const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + +// SVG +const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); +const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + +// List of SVG elements that are disallowed by default. +// We still need to know them so that we can do namespace +// checks properly in case one wants to add them to +// allow-list. +const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); +const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); + +// Similarly to SVG, we want to know all MathML elements, +// even those that we disallow by default. +const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); +const text = freeze(['#text']); + +const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); +const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); +const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); +const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + +// eslint-disable-next-line unicorn/better-regex +const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode +const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); +const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm); +const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape +const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape +const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape +); + +const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); +const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex +); + +const DOCTYPE_NAME = seal(/^html$/i); +const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); + +var EXPRESSIONS = /*#__PURE__*/Object.freeze({ + __proto__: null, + MUSTACHE_EXPR: MUSTACHE_EXPR, + ERB_EXPR: ERB_EXPR, + TMPLIT_EXPR: TMPLIT_EXPR, + DATA_ATTR: DATA_ATTR, + ARIA_ATTR: ARIA_ATTR, + IS_ALLOWED_URI: IS_ALLOWED_URI, + IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE: ATTR_WHITESPACE, + DOCTYPE_NAME: DOCTYPE_NAME, + CUSTOM_ELEMENT: CUSTOM_ELEMENT +}); + +// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType +const NODE_TYPE = { + element: 1, + attribute: 2, + text: 3, + cdataSection: 4, + entityReference: 5, + // Deprecated + entityNode: 6, + // Deprecated + progressingInstruction: 7, + comment: 8, + document: 9, + documentType: 10, + documentFragment: 11, + notation: 12 // Deprecated +}; + +const getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; +}; + +/** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). + * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported or creating the policy failed). + */ +const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { + if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + let suffix = null; + const ATTR_NAME = 'data-tt-policy-suffix'; + if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { + suffix = purifyHostElement.getAttribute(ATTR_NAME); + } + const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + try { + return trustedTypes.createPolicy(policyName, { + createHTML(html) { + return html; + }, + createScriptURL(scriptUrl) { + return scriptUrl; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } +}; +function createDOMPurify() { + let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + const DOMPurify = root => createDOMPurify(root); + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '3.1.5'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + return DOMPurify; + } + let { + document + } = window; + const originalDocument = document; + const currentScript = originalDocument.currentScript; + const { + DocumentFragment, + HTMLTemplateElement, + Node, + Element, + NodeFilter, + NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, + HTMLFormElement, + DOMParser, + trustedTypes + } = window; + const ElementPrototype = Element.prototype; + const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + const template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + let trustedTypesPolicy; + let emptyHTML = ''; + const { + implementation, + createNodeIterator, + createDocumentFragment, + getElementsByTagName + } = document; + const { + importNode + } = originalDocument; + let hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; + const { + MUSTACHE_EXPR, + ERB_EXPR, + TMPLIT_EXPR, + DATA_ATTR, + ARIA_ATTR, + IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE, + CUSTOM_ELEMENT + } = EXPRESSIONS; + let { + IS_ALLOWED_URI: IS_ALLOWED_URI$1 + } = EXPRESSIONS; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + let ALLOWED_TAGS = null; + const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); + + /* Allowed attribute names */ + let ALLOWED_ATTR = null; + const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); + + /* + * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements. + * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) + * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) + * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. + */ + let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { + tagNameCheck: { + writable: true, + configurable: false, + enumerable: true, + value: null + }, + attributeNameCheck: { + writable: true, + configurable: false, + enumerable: true, + value: null + }, + allowCustomizedBuiltInElements: { + writable: true, + configurable: false, + enumerable: true, + value: false + } + })); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + let FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + let FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + let ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + let ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + let ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Decide if self-closing tags in attributes are allowed. + * Usually removed due to a mXSS issue in jQuery 3.0 */ + let ALLOW_SELF_CLOSE_IN_ATTR = true; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + let SAFE_FOR_TEMPLATES = false; + + /* Output should be safe even for XML used within HTML and alike. + * This means, DOMPurify removes comments when containing risky content. + */ + let SAFE_FOR_XML = true; + + /* Decide if document with ... should be returned */ + let WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + let SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + let FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + let RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + let RETURN_DOM_FRAGMENT = false; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + let RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? + * This sanitizes markups named with colliding, clobberable built-in DOM APIs. + */ + let SANITIZE_DOM = true; + + /* Achieve full DOM Clobbering protection by isolating the namespace of named + * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. + * + * HTML/DOM spec rules that enable DOM Clobbering: + * - Named Access on Window (§7.3.3) + * - DOM Tree Accessors (§3.1.5) + * - Form Element Parent-Child Relations (§4.10.3) + * - Iframe srcdoc / Nested WindowProxies (§4.8.5) + * - HTMLCollection (§4.2.10.2) + * + * Namespace isolation is implemented by prefixing `id` and `name` attributes + * with a constant string, i.e., `user-content-` + */ + let SANITIZE_NAMED_PROPS = false; + const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; + + /* Keep element content when removing element? */ + let KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + let IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + let USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + let FORBID_CONTENTS = null; + const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + let DATA_URI_TAGS = null; + const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + let URI_SAFE_ATTRIBUTES = null; + const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); + const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + /* Document namespace */ + let NAMESPACE = HTML_NAMESPACE; + let IS_EMPTY_INPUT = false; + + /* Allowed XHTML+XML namespaces */ + let ALLOWED_NAMESPACES = null; + const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); + + /* Parsing of strict XHTML documents */ + let PARSER_MEDIA_TYPE = null; + const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; + const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; + let transformCaseFunc = null; + + /* Keep a reference to config to pass to hooks */ + let CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + const formElement = document.createElement('form'); + const isRegexOrFunction = function isRegexOrFunction(testValue) { + return testValue instanceof RegExp || testValue instanceof Function; + }; + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + const _parseConfig = function _parseConfig() { + let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || typeof cfg !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone(cfg); + PARSER_MEDIA_TYPE = + // eslint-disable-next-line unicorn/prefer-includes + SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; + + // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. + transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; + + /* Set configuration parameters */ + ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; + ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; + URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), + // eslint-disable-line indent + cfg.ADD_URI_SAFE_ATTR, + // eslint-disable-line indent + transformCaseFunc // eslint-disable-line indent + ) // eslint-disable-line indent + : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), + // eslint-disable-line indent + cfg.ADD_DATA_URI_TAGS, + // eslint-disable-line indent + transformCaseFunc // eslint-disable-line indent + ) // eslint-disable-line indent + : DEFAULT_DATA_URI_TAGS; + FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; + FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {}; + FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {}; + USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; + NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; + CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; + if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { + CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; + } + if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { + CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; + } + if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { + CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; + } + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, text); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html$1); + addToSet(ALLOWED_ATTR, html); + } + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg$1); + addToSet(ALLOWED_ATTR, svg); + addToSet(ALLOWED_ATTR, xml); + } + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg); + addToSet(ALLOWED_ATTR, xml); + } + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl$1); + addToSet(ALLOWED_ATTR, mathMl); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone(ALLOWED_TAGS); + } + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); + } + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone(ALLOWED_ATTR); + } + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); + } + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); + } + if (cfg.FORBID_CONTENTS) { + if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { + FORBID_CONTENTS = clone(FORBID_CONTENTS); + } + addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + if (cfg.TRUSTED_TYPES_POLICY) { + if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { + throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); + } + if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { + throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); + } + + // Overwrite existing TrustedTypes policy. + trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; + + // Sign local variables required by `sanitize`. + emptyHTML = trustedTypesPolicy.createHTML(''); + } else { + // Uninitialized policy, attempt to initialize the internal dompurify policy. + if (trustedTypesPolicy === undefined) { + trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); + } + + // If creating the internal policy succeeded sign internal variables. + if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { + emptyHTML = trustedTypesPolicy.createHTML(''); + } + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + CONFIG = cfg; + }; + const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']); + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erroneously deleted from + // HTML namespace. + const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); + const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); + + /** + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + const _checkValidNamespace = function _checkValidNamespace(element) { + let parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: NAMESPACE, + tagName: 'template' + }; + } + const tagName = stringToLowerCase(element.tagName); + const parentTagName = stringToLowerCase(parent.tagName); + if (!ALLOWED_NAMESPACES[element.namespaceURI]) { + return false; + } + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via . If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via` + // svg if parent is either or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via . If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // For XHTML and XML documents that support custom namespaces + if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { + return true; + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). + // Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + const _forceRemove = function _forceRemove(node) { + arrayPush(DOMPurify.removed, { + element: node + }); + try { + // eslint-disable-next-line unicorn/prefer-dom-node-remove + node.parentNode.removeChild(node); + } catch (_) { + node.remove(); + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + const _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush(DOMPurify.removed, { + attribute: null, + from: node + }); + } + node.removeAttribute(name); + + // We void attribute values for unremovable "is"" attributes + if (name === 'is' && !ALLOWED_ATTR[name]) { + if (RETURN_DOM || RETURN_DOM_FRAGMENT) { + try { + _forceRemove(node); + } catch (_) {} + } else { + try { + node.setAttribute(name, ''); + } catch (_) {} + } + } + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + const _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + let doc = null; + let leadingWhitespace = null; + if (FORCE_BODY) { + dirty = '' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + const matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { + // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) + dirty = '' + dirty + ''; + } + const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* + * Use the DOMParser API by default, fallback later if needs be + * DOMParser not work for svg when has multiple root element. + */ + if (NAMESPACE === HTML_NAMESPACE) { + try { + doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); + } catch (_) {} + } + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createDocument(NAMESPACE, 'template', null); + try { + doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; + } catch (_) { + // Syntax error if dirtyPayload is invalid xml + } + } + const body = doc.body || doc.documentElement; + if (dirty && leadingWhitespace) { + body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + if (NAMESPACE === HTML_NAMESPACE) { + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + } + return WHOLE_DOCUMENT ? doc.documentElement : body; + }; + + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * + * @param {Node} root The root element or node to start traversing on. + * @return {NodeIterator} The created NodeIterator + */ + const _createNodeIterator = function _createNodeIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, + // eslint-disable-next-line no-bitwise + NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + const _isClobbered = function _isClobbered(elm) { + return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function'); + }; + + /** + * Checks whether the given object is a DOM node. + * + * @param {Node} object object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + const _isNode = function _isNode(object) { + return typeof Node === 'function' && object instanceof Node; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + const _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + arrayForEach(hooks[entryPoint], hook => { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + const _sanitizeElements = function _sanitizeElements(currentNode) { + let content = null; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + const tagName = transformCaseFunc(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove any ocurrence of processing instructions */ + if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { + _forceRemove(currentNode); + return true; + } + + /* Remove any kind of possibly harmful comments */ + if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Check if we have a custom element to handle */ + if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { + if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { + return false; + } + if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { + return false; + } + } + + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + const parentNode = getParentNode(currentNode) || currentNode.parentNode; + const childNodes = getChildNodes(currentNode) || currentNode.childNodes; + if (childNodes && parentNode) { + const childCount = childNodes.length; + for (let i = childCount - 1; i >= 0; --i) { + const childClone = cloneNode(childNodes[i], true); + childClone.__removalCount = (currentNode.__removalCount || 0) + 1; + parentNode.insertBefore(childClone, getNextSibling(currentNode)); + } + } + } + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Make sure that older browsers don't get fallback-tag mXSS */ + if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { + /* Get the element's text content */ + content = currentNode.textContent; + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + content = stringReplace(content, expr, ' '); + }); + if (currentNode.textContent !== content) { + arrayPush(DOMPurify.removed, { + element: currentNode.cloneNode() + }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + if ( + // First condition does a very basic check if a) it's basically a valid custom element tagname AND + // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck + // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck + _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || + // Alternative, second condition checks if it's an `is`-attribute, AND + // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck + lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { + return false; + } + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { + return false; + } else ; + return true; + }; + + /** + * _isBasicCustomElement + * checks if at least one dash is included in tagName, and it's not the first char + * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name + * + * @param {string} tagName name of the tag of the node to sanitize + * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false. + */ + const _isBasicCustomElement = function _isBasicCustomElement(tagName) { + return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + const { + attributes + } = currentNode; + + /* Check if we have attributes; if not we might have a text node */ + if (!attributes) { + return; + } + const hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + let l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + const attr = attributes[l]; + const { + name, + namespaceURI, + value: attrValue + } = attr; + const lcName = transformCaseFunc(name); + let value = name === 'value' ? attrValue : stringTrim(attrValue); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Work around a security issue with comments inside attributes */ + if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + value = stringReplace(value, expr, ' '); + }); + } + + /* Is `value` valid for this attribute? */ + const lcTag = transformCaseFunc(currentNode.nodeName); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Full DOM Clobbering protection via namespace isolation, + * Prefix id and name attributes with `user-content-` + */ + if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { + // Remove the attribute with this value + _removeAttribute(name, currentNode); + + // Prefix the value and later re-create the attribute with the sanitized value + value = SANITIZE_NAMED_PROPS_PREFIX + value; + } + + /* Handle attributes that require Trusted Types */ + if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { + if (namespaceURI) ; else { + switch (trustedTypes.getAttributeType(lcTag, lcName)) { + case 'TrustedHTML': + { + value = trustedTypesPolicy.createHTML(value); + break; + } + case 'TrustedScriptURL': + { + value = trustedTypesPolicy.createScriptURL(value); + break; + } + } + } + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + } else { + arrayPop(DOMPurify.removed); + } + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + let shadowNode = null; + const shadowIterator = _createNodeIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} cfg object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty) { + let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + let body = null; + let importedNode = null; + let currentNode = null; + let returnNode = null; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + IS_EMPTY_INPUT = !dirty; + if (IS_EMPTY_INPUT) { + dirty = ''; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + if (typeof dirty.toString === 'function') { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } else { + throw typeErrorCreate('toString is not a function'); + } + } + + /* Return dirty HTML if DOMPurify cannot run */ + if (!DOMPurify.isSupported) { + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + if (IN_PLACE) { + /* Do some early pre-sanitization to avoid unsafe root nodes */ + if (dirty.nodeName) { + const tagName = transformCaseFunc(dirty.nodeName); + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); + } + } + } else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument(''); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-dom-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + } + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-dom-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + return returnNode; + } + let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Serialize doctype if allowed */ + if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { + serializedHTML = '\n' + serializedHTML; + } + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + serializedHTML = stringReplace(serializedHTML, expr, ' '); + }); + } + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function () { + let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {String} tag Tag name of containing element. + * @param {String} attr Attribute name. + * @param {String} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + const lcTag = transformCaseFunc(tag); + const lcName = transformCaseFunc(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + * @return {Function} removed(popped) hook + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + return arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + return DOMPurify; +} +var purify = createDOMPurify(); + +/* IMPORT */ +/* MAIN */ +const Channel = { + /* CLAMP */ + min: { + r: 0, + g: 0, + b: 0, + s: 0, + l: 0, + a: 0 + }, + max: { + r: 255, + g: 255, + b: 255, + h: 360, + s: 100, + l: 100, + a: 1 + }, + clamp: { + r: (r) => r >= 255 ? 255 : (r < 0 ? 0 : r), + g: (g) => g >= 255 ? 255 : (g < 0 ? 0 : g), + b: (b) => b >= 255 ? 255 : (b < 0 ? 0 : b), + h: (h) => h % 360, + s: (s) => s >= 100 ? 100 : (s < 0 ? 0 : s), + l: (l) => l >= 100 ? 100 : (l < 0 ? 0 : l), + a: (a) => a >= 1 ? 1 : (a < 0 ? 0 : a) + }, + /* CONVERSION */ + //SOURCE: https://planetcalc.com/7779 + toLinear: (c) => { + const n = c / 255; + return c > .03928 ? Math.pow(((n + .055) / 1.055), 2.4) : n / 12.92; + }, + //SOURCE: https://gist.github.com/mjackson/5311256 + hue2rgb: (p, q, t) => { + if (t < 0) + t += 1; + if (t > 1) + t -= 1; + if (t < 1 / 6) + return p + (q - p) * 6 * t; + if (t < 1 / 2) + return q; + if (t < 2 / 3) + return p + (q - p) * (2 / 3 - t) * 6; + return p; + }, + hsl2rgb: ({ h, s, l }, channel) => { + if (!s) + return l * 2.55; // Achromatic + h /= 360; + s /= 100; + l /= 100; + const q = (l < .5) ? l * (1 + s) : (l + s) - (l * s); + const p = 2 * l - q; + switch (channel) { + case 'r': return Channel.hue2rgb(p, q, h + 1 / 3) * 255; + case 'g': return Channel.hue2rgb(p, q, h) * 255; + case 'b': return Channel.hue2rgb(p, q, h - 1 / 3) * 255; + } + }, + rgb2hsl: ({ r, g, b }, channel) => { + r /= 255; + g /= 255; + b /= 255; + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + const l = (max + min) / 2; + if (channel === 'l') + return l * 100; + if (max === min) + return 0; // Achromatic + const d = max - min; + const s = (l > .5) ? d / (2 - max - min) : d / (max + min); + if (channel === 's') + return s * 100; + switch (max) { + case r: return ((g - b) / d + (g < b ? 6 : 0)) * 60; + case g: return ((b - r) / d + 2) * 60; + case b: return ((r - g) / d + 4) * 60; + default: return -1; //TSC: TypeScript is stupid and complains if there isn't this useless default statement + } + } +}; + +/* MAIN */ +const Lang = { + /* API */ + clamp: (number, lower, upper) => { + if (lower > upper) + return Math.min(lower, Math.max(upper, number)); + return Math.min(upper, Math.max(lower, number)); + }, + round: (number) => { + return Math.round(number * 10000000000) / 10000000000; + } +}; + +/* MAIN */ +const Unit = { + /* API */ + dec2hex: (dec) => { + const hex = Math.round(dec).toString(16); + return hex.length > 1 ? hex : `0${hex}`; + } +}; + +/* IMPORT */ +/* MAIN */ +const Utils = { + channel: Channel, + lang: Lang, + unit: Unit +}; + +/* IMPORT */ +/* MAIN */ +const DEC2HEX = {}; +for (let i = 0; i <= 255; i++) + DEC2HEX[i] = Utils.unit.dec2hex(i); // Populating dynamically, striking a balance between code size and performance +const TYPE = { + ALL: 0, + RGB: 1, + HSL: 2 +}; + +/* IMPORT */ +/* MAIN */ +class Type { + constructor() { + /* VARIABLES */ + this.type = TYPE.ALL; + } + /* API */ + get() { + return this.type; + } + set(type) { + if (this.type && this.type !== type) + throw new Error('Cannot change both RGB and HSL channels at the same time'); + this.type = type; + } + reset() { + this.type = TYPE.ALL; + } + is(type) { + return this.type === type; + } +} + +/* IMPORT */ +/* MAIN */ +class Channels { + /* CONSTRUCTOR */ + constructor(data, color) { + this.color = color; + this.changed = false; + this.data = data; //TSC + this.type = new Type(); + } + /* API */ + set(data, color) { + this.color = color; + this.changed = false; + this.data = data; //TSC + this.type.type = TYPE.ALL; + return this; + } + /* HELPERS */ + _ensureHSL() { + const data = this.data; + const { h, s, l } = data; + if (h === undefined) + data.h = Utils.channel.rgb2hsl(data, 'h'); + if (s === undefined) + data.s = Utils.channel.rgb2hsl(data, 's'); + if (l === undefined) + data.l = Utils.channel.rgb2hsl(data, 'l'); + } + _ensureRGB() { + const data = this.data; + const { r, g, b } = data; + if (r === undefined) + data.r = Utils.channel.hsl2rgb(data, 'r'); + if (g === undefined) + data.g = Utils.channel.hsl2rgb(data, 'g'); + if (b === undefined) + data.b = Utils.channel.hsl2rgb(data, 'b'); + } + /* GETTERS */ + get r() { + const data = this.data; + const r = data.r; + if (!this.type.is(TYPE.HSL) && r !== undefined) + return r; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'r'); + } + get g() { + const data = this.data; + const g = data.g; + if (!this.type.is(TYPE.HSL) && g !== undefined) + return g; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'g'); + } + get b() { + const data = this.data; + const b = data.b; + if (!this.type.is(TYPE.HSL) && b !== undefined) + return b; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'b'); + } + get h() { + const data = this.data; + const h = data.h; + if (!this.type.is(TYPE.RGB) && h !== undefined) + return h; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 'h'); + } + get s() { + const data = this.data; + const s = data.s; + if (!this.type.is(TYPE.RGB) && s !== undefined) + return s; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 's'); + } + get l() { + const data = this.data; + const l = data.l; + if (!this.type.is(TYPE.RGB) && l !== undefined) + return l; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 'l'); + } + get a() { + return this.data.a; + } + /* SETTERS */ + set r(r) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.r = r; + } + set g(g) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.g = g; + } + set b(b) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.b = b; + } + set h(h) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.h = h; + } + set s(s) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.s = s; + } + set l(l) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.l = l; + } + set a(a) { + this.changed = true; + this.data.a = a; + } +} + +/* IMPORT */ +/* MAIN */ +const channels = new Channels({ r: 0, g: 0, b: 0, a: 0 }, 'transparent'); + +/* IMPORT */ +/* MAIN */ +const Hex = { + /* VARIABLES */ + re: /^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i, + /* API */ + parse: (color) => { + if (color.charCodeAt(0) !== 35) + return; // '#' + const match = color.match(Hex.re); + if (!match) + return; + const hex = match[1]; + const dec = parseInt(hex, 16); + const length = hex.length; + const hasAlpha = length % 4 === 0; + const isFullLength = length > 4; + const multiplier = isFullLength ? 1 : 17; + const bits = isFullLength ? 8 : 4; + const bitsOffset = hasAlpha ? 0 : -1; + const mask = isFullLength ? 255 : 15; + return channels.set({ + r: ((dec >> (bits * (bitsOffset + 3))) & mask) * multiplier, + g: ((dec >> (bits * (bitsOffset + 2))) & mask) * multiplier, + b: ((dec >> (bits * (bitsOffset + 1))) & mask) * multiplier, + a: hasAlpha ? (dec & mask) * multiplier / 255 : 1 + }, color); + }, + stringify: (channels) => { + const { r, g, b, a } = channels; + if (a < 1) { // #RRGGBBAA + return `#${DEC2HEX[Math.round(r)]}${DEC2HEX[Math.round(g)]}${DEC2HEX[Math.round(b)]}${DEC2HEX[Math.round(a * 255)]}`; + } + else { // #RRGGBB + return `#${DEC2HEX[Math.round(r)]}${DEC2HEX[Math.round(g)]}${DEC2HEX[Math.round(b)]}`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const HSL = { + /* VARIABLES */ + re: /^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i, + hueRe: /^(.+?)(deg|grad|rad|turn)$/i, + /* HELPERS */ + _hue2deg: (hue) => { + const match = hue.match(HSL.hueRe); + if (match) { + const [, number, unit] = match; + switch (unit) { + case 'grad': return Utils.channel.clamp.h(parseFloat(number) * .9); + case 'rad': return Utils.channel.clamp.h(parseFloat(number) * 180 / Math.PI); + case 'turn': return Utils.channel.clamp.h(parseFloat(number) * 360); + } + } + return Utils.channel.clamp.h(parseFloat(hue)); + }, + /* API */ + parse: (color) => { + const charCode = color.charCodeAt(0); + if (charCode !== 104 && charCode !== 72) + return; // 'h'/'H' + const match = color.match(HSL.re); + if (!match) + return; + const [, h, s, l, a, isAlphaPercentage] = match; + return channels.set({ + h: HSL._hue2deg(h), + s: Utils.channel.clamp.s(parseFloat(s)), + l: Utils.channel.clamp.l(parseFloat(l)), + a: a ? Utils.channel.clamp.a(isAlphaPercentage ? parseFloat(a) / 100 : parseFloat(a)) : 1 + }, color); + }, + stringify: (channels) => { + const { h, s, l, a } = channels; + if (a < 1) { // HSLA + return `hsla(${Utils.lang.round(h)}, ${Utils.lang.round(s)}%, ${Utils.lang.round(l)}%, ${a})`; + } + else { // HSL + return `hsl(${Utils.lang.round(h)}, ${Utils.lang.round(s)}%, ${Utils.lang.round(l)}%)`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const Keyword = { + /* VARIABLES */ + colors: { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyanaqua: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkgrey: '#a9a9a9', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', + greenyellow: '#adff2f', + grey: '#808080', + honeydew: '#f0fff0', + hotpink: '#ff69b4', + indianred: '#cd5c5c', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrodyellow: '#fafad2', + lightgray: '#d3d3d3', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#ff0000', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + transparent: '#00000000', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32' + }, + /* API */ + parse: (color) => { + color = color.toLowerCase(); + const hex = Keyword.colors[color]; + if (!hex) + return; + return Hex.parse(hex); + }, + stringify: (channels) => { + const hex = Hex.stringify(channels); + for (const name in Keyword.colors) { + if (Keyword.colors[name] === hex) + return name; + } + return; + } +}; + +/* IMPORT */ +/* MAIN */ +const RGB = { + /* VARIABLES */ + re: /^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i, + /* API */ + parse: (color) => { + const charCode = color.charCodeAt(0); + if (charCode !== 114 && charCode !== 82) + return; // 'r'/'R' + const match = color.match(RGB.re); + if (!match) + return; + const [, r, isRedPercentage, g, isGreenPercentage, b, isBluePercentage, a, isAlphaPercentage] = match; + return channels.set({ + r: Utils.channel.clamp.r(isRedPercentage ? parseFloat(r) * 2.55 : parseFloat(r)), + g: Utils.channel.clamp.g(isGreenPercentage ? parseFloat(g) * 2.55 : parseFloat(g)), + b: Utils.channel.clamp.b(isBluePercentage ? parseFloat(b) * 2.55 : parseFloat(b)), + a: a ? Utils.channel.clamp.a(isAlphaPercentage ? parseFloat(a) / 100 : parseFloat(a)) : 1 + }, color); + }, + stringify: (channels) => { + const { r, g, b, a } = channels; + if (a < 1) { // RGBA + return `rgba(${Utils.lang.round(r)}, ${Utils.lang.round(g)}, ${Utils.lang.round(b)}, ${Utils.lang.round(a)})`; + } + else { // RGB + return `rgb(${Utils.lang.round(r)}, ${Utils.lang.round(g)}, ${Utils.lang.round(b)})`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const Color = { + /* VARIABLES */ + format: { + keyword: Keyword, + hex: Hex, + rgb: RGB, + rgba: RGB, + hsl: HSL, + hsla: HSL + }, + /* API */ + parse: (color) => { + if (typeof color !== 'string') + return color; + const channels = Hex.parse(color) || RGB.parse(color) || HSL.parse(color) || Keyword.parse(color); // Color providers ordered with performance in mind + if (channels) + return channels; + throw new Error(`Unsupported color format: "${color}"`); + }, + stringify: (channels) => { + // SASS returns a keyword if possible, but we avoid doing that as it's slower and doesn't really add any value + if (!channels.changed && channels.color) + return channels.color; + if (channels.type.is(TYPE.HSL) || channels.data.r === undefined) { + return HSL.stringify(channels); + } + else if (channels.a < 1 || !Number.isInteger(channels.r) || !Number.isInteger(channels.g) || !Number.isInteger(channels.b)) { + return RGB.stringify(channels); + } + else { + return Hex.stringify(channels); + } + } +}; + +/* IMPORT */ +/* MAIN */ +const change = (color, channels) => { + const ch = Color.parse(color); + for (const c in channels) { + ch[c] = Utils.channel.clamp[c](channels[c]); + } + return Color.stringify(ch); +}; + +/* IMPORT */ +/* MAIN */ +const rgba = (r, g, b = 0, a = 1) => { + if (typeof r !== 'number') + return change(r, { a: g }); + const channels$1 = channels.set({ + r: Utils.channel.clamp.r(r), + g: Utils.channel.clamp.g(g), + b: Utils.channel.clamp.b(b), + a: Utils.channel.clamp.a(a) + }); + return Color.stringify(channels$1); +}; + +/* IMPORT */ +/* MAIN */ +//SOURCE: https://planetcalc.com/7779 +const luminance = (color) => { + const { r, g, b } = Color.parse(color); + const luminance = .2126 * Utils.channel.toLinear(r) + .7152 * Utils.channel.toLinear(g) + .0722 * Utils.channel.toLinear(b); + return Utils.lang.round(luminance); +}; + +/* IMPORT */ +/* MAIN */ +const isLight = (color) => { + return luminance(color) >= .5; +}; + +/* IMPORT */ +/* MAIN */ +const isDark = (color) => { + return !isLight(color); +}; + +/* IMPORT */ +/* MAIN */ +const adjustChannel = (color, channel, amount) => { + const channels = Color.parse(color); + const amountCurrent = channels[channel]; + const amountNext = Utils.channel.clamp[channel](amountCurrent + amount); + if (amountCurrent !== amountNext) + channels[channel] = amountNext; + return Color.stringify(channels); +}; + +/* IMPORT */ +/* MAIN */ +const lighten = (color, amount) => { + return adjustChannel(color, 'l', amount); +}; + +/* IMPORT */ +/* MAIN */ +const darken = (color, amount) => { + return adjustChannel(color, 'l', -amount); +}; + +/* IMPORT */ +/* MAIN */ +const adjust = (color, channels) => { + const ch = Color.parse(color); + const changes = {}; + for (const c in channels) { + if (!channels[c]) + continue; + changes[c] = ch[c] + channels[c]; + } + return change(color, changes); +}; + +/* IMPORT */ +/* MAIN */ +//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756 +const mix = (color1, color2, weight = 50) => { + const { r: r1, g: g1, b: b1, a: a1 } = Color.parse(color1); + const { r: r2, g: g2, b: b2, a: a2 } = Color.parse(color2); + const weightScale = weight / 100; + const weightNormalized = (weightScale * 2) - 1; + const alphaDelta = a1 - a2; + const weight1combined = ((weightNormalized * alphaDelta) === -1) ? weightNormalized : (weightNormalized + alphaDelta) / (1 + weightNormalized * alphaDelta); + const weight1 = (weight1combined + 1) / 2; + const weight2 = 1 - weight1; + const r = (r1 * weight1) + (r2 * weight2); + const g = (g1 * weight1) + (g2 * weight2); + const b = (b1 * weight1) + (b2 * weight2); + const a = (a1 * weightScale) + (a2 * (1 - weightScale)); + return rgba(r, g, b, a); +}; + +/* IMPORT */ +/* MAIN */ +const invert = (color, weight = 100) => { + const inverse = Color.parse(color); + inverse.r = 255 - inverse.r; + inverse.g = 255 - inverse.g; + inverse.b = 255 - inverse.b; + return mix(inverse, color, weight); +}; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** Built-in value references. */ +var Symbol$1 = root.Symbol; + +/** Used for built-in method references. */ +var objectProto$c = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$a = objectProto$c.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$c.toString; + +/** Built-in value references. */ +var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty$a.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString$1.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$b = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto$b.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject$1(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag$1 = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject$1(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +/** Used for built-in method references. */ +var funcProto$2 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$2 = funcProto$2.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString$2.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto$1 = Function.prototype, + objectProto$a = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$1 = funcProto$1.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$9 = objectProto$a.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString$1.call(hasOwnProperty$9).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject$1(value) || isMasked(value)) { + return false; + } + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); +} + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; +} + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; +} + +/* Built-in method references that are verified to be native. */ +var nativeCreate = getNative(Object, 'create'); + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; +} + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$9 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$8 = objectProto$9.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED$1 ? undefined : result; + } + return hasOwnProperty$8.call(data, key) ? data[key] : undefined; +} + +/** Used for built-in method references. */ +var objectProto$8 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$7 = objectProto$8.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$7.call(data, key); +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; +} + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; +} + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +/* Built-in method references that are verified to be native. */ +var Map$1 = getNative(root, 'Map'); + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash, + 'map': new (Map$1 || ListCache), + 'string': new Hash + }; +} + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); +} + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = MapCache; + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache; + this.size = 0; +} + +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; +} + +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} + +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); +} + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); + } + data.set(key, value); + this.size = data.size; + return this; +} + +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; +} + +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; + +var defineProperty = (function() { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty) { + defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +/** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } +} + +/** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} + +/** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); + +/** Detect free variable `exports`. */ +var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2; + +/** Built-in value references. */ +var Buffer$1 = moduleExports$2 ? root.Buffer : undefined, + allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined; + +/** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ +function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; +} + +/** Built-in value references. */ +var Uint8Array$1 = root.Uint8Array; + +/** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ +function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer)); + return result; +} + +/** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ +function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); +} + +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} + +/** Built-in value references. */ +var objectCreate = Object.create; + +/** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ +var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject$1(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; +}()); + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/** Built-in value references. */ +var getPrototype = overArg(Object.getPrototypeOf, Object); + +/** Used for built-in method references. */ +var objectProto$7 = Object.prototype; + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7; + + return value === proto; +} + +/** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag$1; +} + +/** Used for built-in method references. */ +var objectProto$6 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$6 = objectProto$6.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$6.propertyIsEnumerable; + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1; +} + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} + +/** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ +function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); +} + +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +/** Detect free variable `exports`. */ +var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + +/** Built-in value references. */ +var Buffer = moduleExports$1 ? root.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** `Object#toString` result references. */ +var objectTag$2 = '[object Object]'; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto$5 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$5 = objectProto$5.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString.call(Object); + +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag$2) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString.call(Ctor) == objectCtorString; +} + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag$2 = '[object Map]', + numberTag = '[object Number]', + objectTag$1 = '[object Object]', + regexpTag = '[object RegExp]', + setTag$2 = '[object Set]', + stringTag = '[object String]', + weakMapTag$1 = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag$1 = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag] = +typedArrayTags[mapTag$2] = typedArrayTags[numberTag] = +typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] = +typedArrayTags[setTag$2] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag$1] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +/** + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + + if (key == '__proto__') { + return; + } + + return object[key]; +} + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$4 = objectProto$4.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty$4.call(object, key) && eq(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue(object, key, value); + } +} + +/** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ +function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; +} + +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty$3.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; +} + +/** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeysIn(object) { + if (!isObject$1(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty$2.call(object, key)))) { + result.push(key); + } + } + return result; +} + +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); +} + +/** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ +function toPlainObject(value) { + return copyObject(value, keysIn(value)); +} + +/** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); + + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject$1(objValue) || isFunction(objValue)) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); +} + +/** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); + if (isObject$1(srcValue)) { + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); +} + +/** + * This method returns the first argument it receives. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'a': 1 }; + * + * console.log(_.identity(object) === object); + * // => true + */ +function identity(value) { + return value; +} + +/** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ +function apply(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + +/** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ +function overRest(func, start, transform) { + start = nativeMax(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply(func, this, otherArgs); + }; +} + +/** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ +function constant(value) { + return function() { + return value; + }; +} + +/** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var baseSetToString = !defineProperty ? identity : function(func, string) { + return defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); +}; + +/** Used to detect hot functions by number of calls within a span of milliseconds. */ +var HOT_COUNT = 800, + HOT_SPAN = 16; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeNow = Date.now; + +/** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ +function shortOut(func) { + var count = 0, + lastCalled = 0; + + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; +} + +/** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var setToString = shortOut(baseSetToString); + +/** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ +function baseRest(func, start) { + return setToString(overRest(func, start, identity), func + ''); +} + +/** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ +function isIterateeCall(value, index, object) { + if (!isObject$1(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq(object[index], value); + } + return false; +} + +/** + * Creates a function like `_.assign`. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ +function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; + + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); +} + +/** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ +var merge$1 = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); +}); + +var COMMENT = 'comm'; +var RULESET = 'rule'; +var DECLARATION = 'decl'; +var IMPORT = '@import'; +var KEYFRAMES = '@keyframes'; +var LAYER = '@layer'; + +/** + * @param {number} + * @return {number} + */ +var abs = Math.abs; + +/** + * @param {number} + * @return {string} + */ +var from = String.fromCharCode; + +/** + * @param {string} value + * @return {string} + */ +function trim (value) { + return value.trim() +} + +/** + * @param {string} value + * @param {(string|RegExp)} pattern + * @param {string} replacement + * @return {string} + */ +function replace (value, pattern, replacement) { + return value.replace(pattern, replacement) +} + +/** + * @param {string} value + * @param {string} search + * @param {number} position + * @return {number} + */ +function indexof (value, search, position) { + return value.indexOf(search, position) +} + +/** + * @param {string} value + * @param {number} index + * @return {number} + */ +function charat (value, index) { + return value.charCodeAt(index) | 0 +} + +/** + * @param {string} value + * @param {number} begin + * @param {number} end + * @return {string} + */ +function substr (value, begin, end) { + return value.slice(begin, end) +} + +/** + * @param {string} value + * @return {number} + */ +function strlen (value) { + return value.length +} + +/** + * @param {any[]} value + * @return {number} + */ +function sizeof (value) { + return value.length +} + +/** + * @param {any} value + * @param {any[]} array + * @return {any} + */ +function append (value, array) { + return array.push(value), value +} + +var line = 1; +var column = 1; +var length = 0; +var position = 0; +var character = 0; +var characters = ''; + +/** + * @param {string} value + * @param {object | null} root + * @param {object | null} parent + * @param {string} type + * @param {string[] | string} props + * @param {object[] | string} children + * @param {object[]} siblings + * @param {number} length + */ +function node (value, root, parent, type, props, children, length, siblings) { + return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings} +} + +/** + * @return {number} + */ +function char () { + return character +} + +/** + * @return {number} + */ +function prev () { + character = position > 0 ? charat(characters, --position) : 0; + + if (column--, character === 10) + column = 1, line--; + + return character +} + +/** + * @return {number} + */ +function next () { + character = position < length ? charat(characters, position++) : 0; + + if (column++, character === 10) + column = 1, line++; + + return character +} + +/** + * @return {number} + */ +function peek () { + return charat(characters, position) +} + +/** + * @return {number} + */ +function caret () { + return position +} + +/** + * @param {number} begin + * @param {number} end + * @return {string} + */ +function slice (begin, end) { + return substr(characters, begin, end) +} + +/** + * @param {number} type + * @return {number} + */ +function token (type) { + switch (type) { + // \0 \t \n \r \s whitespace token + case 0: case 9: case 10: case 13: case 32: + return 5 + // ! + , / > @ ~ isolate token + case 33: case 43: case 44: case 47: case 62: case 64: case 126: + // ; { } breakpoint token + case 59: case 123: case 125: + return 4 + // : accompanied token + case 58: + return 3 + // " ' ( [ opening delimit token + case 34: case 39: case 40: case 91: + return 2 + // ) ] closing delimit token + case 41: case 93: + return 1 + } + + return 0 +} + +/** + * @param {string} value + * @return {any[]} + */ +function alloc (value) { + return line = column = 1, length = strlen(characters = value), position = 0, [] +} + +/** + * @param {any} value + * @return {any} + */ +function dealloc (value) { + return characters = '', value +} + +/** + * @param {number} type + * @return {string} + */ +function delimit (type) { + return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type))) +} + +/** + * @param {number} type + * @return {string} + */ +function whitespace (type) { + while (character = peek()) + if (character < 33) + next(); + else + break + + return token(type) > 2 || token(character) > 3 ? '' : ' ' +} + +/** + * @param {number} index + * @param {number} count + * @return {string} + */ +function escaping (index, count) { + while (--count && next()) + // not 0-9 A-F a-f + if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97)) + break + + return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32)) +} + +/** + * @param {number} type + * @return {number} + */ +function delimiter (type) { + while (next()) + switch (character) { + // ] ) " ' + case type: + return position + // " ' + case 34: case 39: + if (type !== 34 && type !== 39) + delimiter(character); + break + // ( + case 40: + if (type === 41) + delimiter(type); + break + // \ + case 92: + next(); + break + } + + return position +} + +/** + * @param {number} type + * @param {number} index + * @return {number} + */ +function commenter (type, index) { + while (next()) + // // + if (type + character === 47 + 10) + break + // /* + else if (type + character === 42 + 42 && peek() === 47) + break + + return '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next()) +} + +/** + * @param {number} index + * @return {string} + */ +function identifier (index) { + while (!token(peek())) + next(); + + return slice(index, position) +} + +/** + * @param {string} value + * @return {object[]} + */ +function compile (value) { + return dealloc(parse$2('', null, null, null, [''], value = alloc(value), 0, [0], value)) +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {string[]} rule + * @param {string[]} rules + * @param {string[]} rulesets + * @param {number[]} pseudo + * @param {number[]} points + * @param {string[]} declarations + * @return {object} + */ +function parse$2 (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) { + var index = 0; + var offset = 0; + var length = pseudo; + var atrule = 0; + var property = 0; + var previous = 0; + var variable = 1; + var scanning = 1; + var ampersand = 1; + var character = 0; + var type = ''; + var props = rules; + var children = rulesets; + var reference = rule; + var characters = type; + + while (scanning) + switch (previous = character, character = next()) { + // ( + case 40: + if (previous != 108 && charat(characters, length - 1) == 58) { + if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f', abs(index ? points[index - 1] : 0)) != -1) + ampersand = -1; + break + } + // " ' [ + case 34: case 39: case 91: + characters += delimit(character); + break + // \t \n \r \s + case 9: case 10: case 13: case 32: + characters += whitespace(previous); + break + // \ + case 92: + characters += escaping(caret() - 1, 7); + continue + // / + case 47: + switch (peek()) { + case 42: case 47: + append(comment(commenter(next(), caret()), root, parent, declarations), declarations); + break + default: + characters += '/'; + } + break + // { + case 123 * variable: + points[index++] = strlen(characters) * ampersand; + // } ; \0 + case 125 * variable: case 59: case 0: + switch (character) { + // \0 } + case 0: case 125: scanning = 0; + // ; + case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, ''); + if (property > 0 && (strlen(characters) - length)) + append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations); + break + // @ ; + case 59: characters += ';'; + // { rule/at-rule + default: + append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets); + + if (character === 123) + if (offset === 0) + parse$2(characters, root, reference, reference, props, rulesets, length, points, children); + else + switch (atrule === 99 && charat(characters, 3) === 110 ? 100 : atrule) { + // d l m s + case 100: case 108: case 109: case 115: + parse$2(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children); + break + default: + parse$2(characters, reference, reference, reference, [''], children, 0, points, children); + } + } + + index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo; + break + // : + case 58: + length = 1 + strlen(characters), property = previous; + default: + if (variable < 1) + if (character == 123) + --variable; + else if (character == 125 && variable++ == 0 && prev() == 125) + continue + + switch (characters += from(character), character * variable) { + // & + case 38: + ampersand = offset > 0 ? 1 : (characters += '\f', -1); + break + // , + case 44: + points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1; + break + // @ + case 64: + // - + if (peek() === 45) + characters += delimit(next()); + + atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++; + break + // - + case 45: + if (previous === 45 && strlen(characters) == 2) + variable = 0; + } + } + + return rulesets +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {number} index + * @param {number} offset + * @param {string[]} rules + * @param {number[]} points + * @param {string} type + * @param {string[]} props + * @param {string[]} children + * @param {number} length + * @param {object[]} siblings + * @return {object} + */ +function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) { + var post = offset - 1; + var rule = offset === 0 ? rules : ['']; + var size = sizeof(rule); + + for (var i = 0, j = 0, k = 0; i < index; ++i) + for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x) + if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x]))) + props[k++] = z; + + return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings) +} + +/** + * @param {number} value + * @param {object} root + * @param {object?} parent + * @param {object[]} siblings + * @return {object} + */ +function comment (value, root, parent, siblings) { + return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings) +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {number} length + * @param {object[]} siblings + * @return {object} + */ +function declaration (value, root, parent, length, siblings) { + return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings) +} + +/** + * @param {object[]} children + * @param {function} callback + * @return {string} + */ +function serialize (children, callback) { + var output = ''; + + for (var i = 0; i < children.length; i++) + output += callback(children[i], i, children, callback) || ''; + + return output +} + +/** + * @param {object} element + * @param {number} index + * @param {object[]} children + * @param {function} callback + * @return {string} + */ +function stringify (element, index, children, callback) { + switch (element.type) { + case LAYER: if (element.children.length) break + case IMPORT: case DECLARATION: return element.return = element.return || element.value + case COMMENT: return '' + case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}' + case RULESET: if (!strlen(element.value = element.props.join(','))) return '' + } + + return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : '' +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$1.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/* Built-in method references that are verified to be native. */ +var DataView = getNative(root, 'DataView'); + +/* Built-in method references that are verified to be native. */ +var Promise$1 = getNative(root, 'Promise'); + +/* Built-in method references that are verified to be native. */ +var Set$1 = getNative(root, 'Set'); + +/* Built-in method references that are verified to be native. */ +var WeakMap = getNative(root, 'WeakMap'); + +/** `Object#toString` result references. */ +var mapTag$1 = '[object Map]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + setTag$1 = '[object Set]', + weakMapTag = '[object WeakMap]'; + +var dataViewTag = '[object DataView]'; + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map$1), + promiseCtorString = toSource(Promise$1), + setCtorString = toSource(Set$1), + weakMapCtorString = toSource(WeakMap); + +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map$1 && getTag(new Map$1) != mapTag$1) || + (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) || + (Set$1 && getTag(new Set$1) != setTag$1) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = baseGetTag(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag$1; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag$1; + case weakMapCtorString: return weakMapTag; + } + } + return result; + }; +} + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + setTag = '[object Set]'; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ +function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && + (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || + isBuffer(value) || isTypedArray(value) || isArguments(value))) { + return !value.length; + } + var tag = getTag(value); + if (tag == mapTag || tag == setTag) { + return !value.size; + } + if (isPrototype(value)) { + return !baseKeys(value).length; + } + for (var key in value) { + if (hasOwnProperty.call(value, key)) { + return false; + } + } + return true; +} + +const LEVELS = { + trace: 0, + debug: 1, + info: 2, + warn: 3, + error: 4, + fatal: 5 +}; +const log$1 = { + trace: (..._args) => { + }, + debug: (..._args) => { + }, + info: (..._args) => { + }, + warn: (..._args) => { + }, + error: (..._args) => { + }, + fatal: (..._args) => { + } +}; +const setLogLevel$1 = function(level = "fatal") { + let numericLevel = LEVELS.fatal; + if (typeof level === "string") { + level = level.toLowerCase(); + if (level in LEVELS) { + numericLevel = LEVELS[level]; + } + } else if (typeof level === "number") { + numericLevel = level; + } + log$1.trace = () => { + }; + log$1.debug = () => { + }; + log$1.info = () => { + }; + log$1.warn = () => { + }; + log$1.error = () => { + }; + log$1.fatal = () => { + }; + if (numericLevel <= LEVELS.fatal) { + log$1.fatal = console.error ? console.error.bind(console, format("FATAL"), "color: orange") : console.log.bind(console, "\x1B[35m", format("FATAL")); + } + if (numericLevel <= LEVELS.error) { + log$1.error = console.error ? console.error.bind(console, format("ERROR"), "color: orange") : console.log.bind(console, "\x1B[31m", format("ERROR")); + } + if (numericLevel <= LEVELS.warn) { + log$1.warn = console.warn ? console.warn.bind(console, format("WARN"), "color: orange") : console.log.bind(console, `\x1B[33m`, format("WARN")); + } + if (numericLevel <= LEVELS.info) { + log$1.info = console.info ? console.info.bind(console, format("INFO"), "color: lightblue") : console.log.bind(console, "\x1B[34m", format("INFO")); + } + if (numericLevel <= LEVELS.debug) { + log$1.debug = console.debug ? console.debug.bind(console, format("DEBUG"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format("DEBUG")); + } + if (numericLevel <= LEVELS.trace) { + log$1.trace = console.debug ? console.debug.bind(console, format("TRACE"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format("TRACE")); + } +}; +const format = (level) => { + const time = dayjs().format("ss.SSS"); + return `%c${time} : ${level} : `; +}; +const lineBreakRegex = //gi; +const getRows = (s) => { + if (!s) { + return [""]; + } + const str2 = breakToPlaceholder(s).replace(/\\n/g, "#br#"); + return str2.split("#br#"); +}; +const setupDompurifyHooksIfNotSetup = (() => { + let setup = false; + return () => { + if (!setup) { + setupDompurifyHooks(); + setup = true; + } + }; +})(); +function setupDompurifyHooks() { + const TEMPORARY_ATTRIBUTE = "data-temp-href-target"; + purify.addHook("beforeSanitizeAttributes", (node) => { + if (node.tagName === "A" && node.hasAttribute("target")) { + node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute("target") || ""); + } + }); + purify.addHook("afterSanitizeAttributes", (node) => { + if (node.tagName === "A" && node.hasAttribute(TEMPORARY_ATTRIBUTE)) { + node.setAttribute("target", node.getAttribute(TEMPORARY_ATTRIBUTE) || ""); + node.removeAttribute(TEMPORARY_ATTRIBUTE); + if (node.getAttribute("target") === "_blank") { + node.setAttribute("rel", "noopener"); + } + } + }); +} +const removeScript = (txt) => { + setupDompurifyHooksIfNotSetup(); + const sanitizedText = purify.sanitize(txt); + return sanitizedText; +}; +const sanitizeMore = (text, config2) => { + var _a; + if (((_a = config2.flowchart) == null ? void 0 : _a.htmlLabels) !== false) { + const level = config2.securityLevel; + if (level === "antiscript" || level === "strict") { + text = removeScript(text); + } else if (level !== "loose") { + text = breakToPlaceholder(text); + text = text.replace(//g, ">"); + text = text.replace(/=/g, "="); + text = placeholderToBreak(text); + } + } + return text; +}; +const sanitizeText$2 = (text, config2) => { + if (!text) { + return text; + } + if (config2.dompurifyConfig) { + text = purify.sanitize(sanitizeMore(text, config2), config2.dompurifyConfig).toString(); + } else { + text = purify.sanitize(sanitizeMore(text, config2), { + FORBID_TAGS: ["style"] + }).toString(); + } + return text; +}; +const sanitizeTextOrArray = (a, config2) => { + if (typeof a === "string") { + return sanitizeText$2(a, config2); + } + return a.flat().map((x) => sanitizeText$2(x, config2)); +}; +const hasBreaks = (text) => { + return lineBreakRegex.test(text); +}; +const splitBreaks = (text) => { + return text.split(lineBreakRegex); +}; +const placeholderToBreak = (s) => { + return s.replace(/#br#/g, "
    "); +}; +const breakToPlaceholder = (s) => { + return s.replace(lineBreakRegex, "#br#"); +}; +const getUrl = (useAbsolute) => { + let url = ""; + if (useAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replaceAll(/\(/g, "\\("); + url = url.replaceAll(/\)/g, "\\)"); + } + return url; +}; +const evaluate = (val) => val === false || ["false", "null", "0"].includes(String(val).trim().toLowerCase()) ? false : true; +const getMax = function(...values) { + const newValues = values.filter((value) => { + return !isNaN(value); + }); + return Math.max(...newValues); +}; +const getMin = function(...values) { + const newValues = values.filter((value) => { + return !isNaN(value); + }); + return Math.min(...newValues); +}; +const parseGenericTypes = function(input) { + const inputSets = input.split(/(,)/); + const output = []; + for (let i = 0; i < inputSets.length; i++) { + let thisSet = inputSets[i]; + if (thisSet === "," && i > 0 && i + 1 < inputSets.length) { + const previousSet = inputSets[i - 1]; + const nextSet = inputSets[i + 1]; + if (shouldCombineSets(previousSet, nextSet)) { + thisSet = previousSet + "," + nextSet; + i++; + output.pop(); + } + } + output.push(processSet(thisSet)); + } + return output.join(""); +}; +const countOccurrence = (string, substring) => { + return Math.max(0, string.split(substring).length - 1); +}; +const shouldCombineSets = (previousSet, nextSet) => { + const prevCount = countOccurrence(previousSet, "~"); + const nextCount = countOccurrence(nextSet, "~"); + return prevCount === 1 && nextCount === 1; +}; +const processSet = (input) => { + const tildeCount = countOccurrence(input, "~"); + let hasStartingTilde = false; + if (tildeCount <= 1) { + return input; + } + if (tildeCount % 2 !== 0 && input.startsWith("~")) { + input = input.substring(1); + hasStartingTilde = true; + } + const chars = [...input]; + let first = chars.indexOf("~"); + let last = chars.lastIndexOf("~"); + while (first !== -1 && last !== -1 && first !== last) { + chars[first] = "<"; + chars[last] = ">"; + first = chars.indexOf("~"); + last = chars.lastIndexOf("~"); + } + if (hasStartingTilde) { + chars.unshift("~"); + } + return chars.join(""); +}; +const isMathMLSupported = () => window.MathMLElement !== void 0; +const katexRegex = /\$\$(.*)\$\$/g; +const hasKatex = (text) => { + var _a; + return (((_a = text.match(katexRegex)) == null ? void 0 : _a.length) ?? 0) > 0; +}; +const calculateMathMLDimensions = async (text, config2) => { + text = await renderKatex(text, config2); + const divElem = document.createElement("div"); + divElem.innerHTML = text; + divElem.id = "katex-temp"; + divElem.style.visibility = "hidden"; + divElem.style.position = "absolute"; + divElem.style.top = "0"; + const body = document.querySelector("body"); + body == null ? void 0 : body.insertAdjacentElement("beforeend", divElem); + const dim = { width: divElem.clientWidth, height: divElem.clientHeight }; + divElem.remove(); + return dim; +}; +const renderKatex = async (text, config2) => { + if (!hasKatex(text)) { + return text; + } + if (!isMathMLSupported() && !config2.legacyMathML) { + return text.replace(katexRegex, "MathML is unsupported in this environment."); + } + const { default: katex } = await Promise.resolve().then(function () { return katex$1; }); + return text.split(lineBreakRegex).map( + (line) => hasKatex(line) ? ` +
    + ${line} +
    + ` : `
    ${line}
    ` + ).join("").replace( + katexRegex, + (_, c) => katex.renderToString(c, { + throwOnError: true, + displayMode: true, + output: isMathMLSupported() ? "mathml" : "htmlAndMathml" + }).replace(/\n/g, " ").replace(//g, "") + ); +}; +const common$1 = { + getRows, + sanitizeText: sanitizeText$2, + sanitizeTextOrArray, + hasBreaks, + splitBreaks, + lineBreakRegex, + removeScript, + getUrl, + evaluate, + getMax, + getMin +}; +const mkBorder = (col, darkMode) => darkMode ? adjust(col, { s: -40, l: 10 }) : adjust(col, { s: -40, l: -10 }); +const oldAttributeBackgroundColorOdd = "#ffffff"; +const oldAttributeBackgroundColorEven = "#f2f2f2"; +let Theme$4 = class Theme { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#fff4dd"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "#333"; + this.THEME_COLOR_LIMIT = 12; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.primaryTextColor = this.primaryTextColor || (this.darkMode ? "#eee" : "#333"); + this.secondaryColor = this.secondaryColor || adjust(this.primaryColor, { h: -120 }); + this.tertiaryColor = this.tertiaryColor || adjust(this.primaryColor, { h: 180, l: 5 }); + this.primaryBorderColor = this.primaryBorderColor || mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = this.secondaryBorderColor || mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = this.tertiaryBorderColor || mkBorder(this.tertiaryColor, this.darkMode); + this.noteBorderColor = this.noteBorderColor || mkBorder(this.noteBkgColor, this.darkMode); + this.noteBkgColor = this.noteBkgColor || "#fff5ad"; + this.noteTextColor = this.noteTextColor || "#333"; + this.secondaryTextColor = this.secondaryTextColor || invert(this.secondaryColor); + this.tertiaryTextColor = this.tertiaryTextColor || invert(this.tertiaryColor); + this.lineColor = this.lineColor || invert(this.background); + this.arrowheadColor = this.arrowheadColor || invert(this.background); + this.textColor = this.textColor || this.primaryTextColor; + this.border2 = this.border2 || this.tertiaryBorderColor; + this.nodeBkg = this.nodeBkg || this.primaryColor; + this.mainBkg = this.mainBkg || this.primaryColor; + this.nodeBorder = this.nodeBorder || this.primaryBorderColor; + this.clusterBkg = this.clusterBkg || this.tertiaryColor; + this.clusterBorder = this.clusterBorder || this.tertiaryBorderColor; + this.defaultLinkColor = this.defaultLinkColor || this.lineColor; + this.titleColor = this.titleColor || this.tertiaryTextColor; + this.edgeLabelBackground = this.edgeLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.nodeTextColor = this.nodeTextColor || this.primaryTextColor; + this.actorBorder = this.actorBorder || this.primaryBorderColor; + this.actorBkg = this.actorBkg || this.mainBkg; + this.actorTextColor = this.actorTextColor || this.primaryTextColor; + this.actorLineColor = this.actorLineColor || "grey"; + this.labelBoxBkgColor = this.labelBoxBkgColor || this.actorBkg; + this.signalColor = this.signalColor || this.textColor; + this.signalTextColor = this.signalTextColor || this.textColor; + this.labelBoxBorderColor = this.labelBoxBorderColor || this.actorBorder; + this.labelTextColor = this.labelTextColor || this.actorTextColor; + this.loopTextColor = this.loopTextColor || this.actorTextColor; + this.activationBorderColor = this.activationBorderColor || darken(this.secondaryColor, 10); + this.activationBkgColor = this.activationBkgColor || this.secondaryColor; + this.sequenceNumberColor = this.sequenceNumberColor || invert(this.lineColor); + this.sectionBkgColor = this.sectionBkgColor || this.tertiaryColor; + this.altSectionBkgColor = this.altSectionBkgColor || "white"; + this.sectionBkgColor = this.sectionBkgColor || this.secondaryColor; + this.sectionBkgColor2 = this.sectionBkgColor2 || this.primaryColor; + this.excludeBkgColor = this.excludeBkgColor || "#eeeeee"; + this.taskBorderColor = this.taskBorderColor || this.primaryBorderColor; + this.taskBkgColor = this.taskBkgColor || this.primaryColor; + this.activeTaskBorderColor = this.activeTaskBorderColor || this.primaryColor; + this.activeTaskBkgColor = this.activeTaskBkgColor || lighten(this.primaryColor, 23); + this.gridColor = this.gridColor || "lightgrey"; + this.doneTaskBkgColor = this.doneTaskBkgColor || "lightgrey"; + this.doneTaskBorderColor = this.doneTaskBorderColor || "grey"; + this.critBorderColor = this.critBorderColor || "#ff8888"; + this.critBkgColor = this.critBkgColor || "red"; + this.todayLineColor = this.todayLineColor || "red"; + this.taskTextColor = this.taskTextColor || this.textColor; + this.taskTextOutsideColor = this.taskTextOutsideColor || this.textColor; + this.taskTextLightColor = this.taskTextLightColor || this.textColor; + this.taskTextColor = this.taskTextColor || this.primaryTextColor; + this.taskTextDarkColor = this.taskTextDarkColor || this.textColor; + this.taskTextClickableColor = this.taskTextClickableColor || "#003163"; + this.personBorder = this.personBorder || this.primaryBorderColor; + this.personBkg = this.personBkg || this.mainBkg; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || this.tertiaryColor; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.nodeBorder; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.specialStateColor = this.lineColor; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210, l: 150 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + if (this.darkMode) { + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 75); + } + } else { + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 25); + } + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + if (this.darkMode) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } else { + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 10); + } + } + this.scaleLabelColor = this.scaleLabelColor || this.labelTextColor; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + const multiplier = this.darkMode ? -4 : -1; + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 180, s: -15, l: multiplier * (5 + i * 3) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 180, s: -15, l: multiplier * (8 + i * 3) }); + } + this.classText = this.classText || this.textColor; + this.fillType0 = this.fillType0 || this.primaryColor; + this.fillType1 = this.fillType1 || this.secondaryColor; + this.fillType2 = this.fillType2 || adjust(this.primaryColor, { h: 64 }); + this.fillType3 = this.fillType3 || adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = this.fillType4 || adjust(this.primaryColor, { h: -64 }); + this.fillType5 = this.fillType5 || adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = this.fillType6 || adjust(this.primaryColor, { h: 128 }); + this.fillType7 = this.fillType7 || adjust(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || this.tertiaryColor; + this.pie4 = this.pie4 || adjust(this.primaryColor, { l: -10 }); + this.pie5 = this.pie5 || adjust(this.secondaryColor, { l: -10 }); + this.pie6 = this.pie6 || adjust(this.tertiaryColor, { l: -10 }); + this.pie7 = this.pie7 || adjust(this.primaryColor, { h: 60, l: -10 }); + this.pie8 = this.pie8 || adjust(this.primaryColor, { h: -60, l: -10 }); + this.pie9 = this.pie9 || adjust(this.primaryColor, { h: 120, l: 0 }); + this.pie10 = this.pie10 || adjust(this.primaryColor, { h: 60, l: -20 }); + this.pie11 = this.pie11 || adjust(this.primaryColor, { h: -60, l: -20 }); + this.pie12 = this.pie12 || adjust(this.primaryColor, { h: 120, l: -10 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#FFF4DD,#FFD8B1,#FFA07A,#ECEFF1,#D6DBDF,#C3E0A8,#FFB6A4,#FFD74D,#738FA7,#FFFFF0" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.branchLabelColor = this.branchLabelColor || (this.darkMode ? "black" : this.labelTextColor); + this.gitBranchLabel0 = this.gitBranchLabel0 || this.branchLabelColor; + this.gitBranchLabel1 = this.gitBranchLabel1 || this.branchLabelColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.branchLabelColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || this.branchLabelColor; + this.gitBranchLabel4 = this.gitBranchLabel4 || this.branchLabelColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.branchLabelColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.branchLabelColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.branchLabelColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$4 = (userOverrides) => { + const theme2 = new Theme$4(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$3 = class Theme2 { + constructor() { + this.background = "#333"; + this.primaryColor = "#1f2020"; + this.secondaryColor = lighten(this.primaryColor, 16); + this.tertiaryColor = adjust(this.primaryColor, { h: -160 }); + this.primaryBorderColor = invert(this.background); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.mainBkg = "#1f2020"; + this.secondBkg = "calculated"; + this.mainContrastColor = "lightgrey"; + this.darkTextColor = lighten(invert("#323D47"), 10); + this.lineColor = "calculated"; + this.border1 = "#81B1DB"; + this.border2 = rgba(255, 255, 255, 0.25); + this.arrowheadColor = "calculated"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.labelBackground = "#181818"; + this.textColor = "#ccc"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "#F9FFFE"; + this.edgeLabelBackground = "calculated"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "calculated"; + this.actorLineColor = "calculated"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "calculated"; + this.activationBkgColor = "calculated"; + this.sequenceNumberColor = "black"; + this.sectionBkgColor = darken("#EAE8D9", 30); + this.altSectionBkgColor = "calculated"; + this.sectionBkgColor2 = "#EAE8D9"; + this.excludeBkgColor = darken(this.sectionBkgColor, 10); + this.taskBorderColor = rgba(255, 255, 255, 70); + this.taskBkgColor = "calculated"; + this.taskTextColor = "calculated"; + this.taskTextLightColor = "calculated"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = rgba(255, 255, 255, 50); + this.activeTaskBkgColor = "#81B1DB"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#E83737"; + this.critBkgColor = "#E83737"; + this.taskTextDarkColor = "calculated"; + this.todayLineColor = "#DB5757"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "calculated"; + this.errorBkgColor = "#a44141"; + this.errorTextColor = "#ddd"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.secondBkg = lighten(this.mainBkg, 16); + this.lineColor = this.mainContrastColor; + this.arrowheadColor = this.mainContrastColor; + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.edgeLabelBackground = lighten(this.labelBackground, 25); + this.actorBorder = this.border1; + this.actorBkg = this.mainBkg; + this.actorTextColor = this.mainContrastColor; + this.actorLineColor = this.mainContrastColor; + this.signalColor = this.mainContrastColor; + this.signalTextColor = this.mainContrastColor; + this.labelBoxBkgColor = this.actorBkg; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.mainContrastColor; + this.loopTextColor = this.mainContrastColor; + this.noteBorderColor = this.secondaryBorderColor; + this.noteBkgColor = this.secondBkg; + this.noteTextColor = this.secondaryTextColor; + this.activationBorderColor = this.border1; + this.activationBkgColor = this.secondBkg; + this.altSectionBkgColor = this.background; + this.taskBkgColor = lighten(this.mainBkg, 23); + this.taskTextColor = this.darkTextColor; + this.taskTextLightColor = this.mainContrastColor; + this.taskTextOutsideColor = this.taskTextLightColor; + this.gridColor = this.mainContrastColor; + this.doneTaskBkgColor = this.mainContrastColor; + this.taskTextDarkColor = this.darkTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#555"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = "#f4f4f4"; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + this.cScale1 = this.cScale1 || "#0b0000"; + this.cScale2 = this.cScale2 || "#4d1037"; + this.cScale3 = this.cScale3 || "#3f5258"; + this.cScale4 = this.cScale4 || "#4f2f1b"; + this.cScale5 = this.cScale5 || "#6e0a0a"; + this.cScale6 = this.cScale6 || "#3b0048"; + this.cScale7 = this.cScale7 || "#995a01"; + this.cScale8 = this.cScale8 || "#154706"; + this.cScale9 = this.cScale9 || "#161722"; + this.cScale10 = this.cScale10 || "#00296f"; + this.cScale11 = this.cScale11 || "#01629c"; + this.cScale12 = this.cScale12 || "#010029"; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(-10 + i * 4) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(-7 + i * 4) }); + } + this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? "black" : this.labelTextColor); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["pie" + i] = this["cScale" + i]; + } + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#3498db,#2ecc71,#e74c3c,#f1c40f,#bdc3c7,#ffffff,#34495e,#9b59b6,#1abc9c,#e67e22" + }; + this.classText = this.primaryTextColor; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = lighten(this.secondaryColor, 20); + this.git1 = lighten(this.pie2 || this.secondaryColor, 20); + this.git2 = lighten(this.pie3 || this.tertiaryColor, 20); + this.git3 = lighten(this.pie4 || adjust(this.primaryColor, { h: -30 }), 20); + this.git4 = lighten(this.pie5 || adjust(this.primaryColor, { h: -60 }), 20); + this.git5 = lighten(this.pie6 || adjust(this.primaryColor, { h: -90 }), 10); + this.git6 = lighten(this.pie7 || adjust(this.primaryColor, { h: 60 }), 10); + this.git7 = lighten(this.pie8 || adjust(this.primaryColor, { h: 120 }), 20); + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || lighten(this.background, 12); + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || lighten(this.background, 2); + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$3 = (userOverrides) => { + const theme2 = new Theme$3(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$2 = class Theme3 { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#ECECFF"; + this.secondaryColor = adjust(this.primaryColor, { h: 120 }); + this.secondaryColor = "#ffffde"; + this.tertiaryColor = adjust(this.primaryColor, { h: -160 }); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.background = "white"; + this.mainBkg = "#ECECFF"; + this.secondBkg = "#ffffde"; + this.lineColor = "#333333"; + this.border1 = "#9370DB"; + this.border2 = "#aaaa33"; + this.arrowheadColor = "#333333"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.labelBackground = "#e8e8e8"; + this.textColor = "#333"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "calculated"; + this.edgeLabelBackground = "calculated"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "black"; + this.actorLineColor = "grey"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "calculated"; + this.altSectionBkgColor = "calculated"; + this.sectionBkgColor2 = "calculated"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "calculated"; + this.taskTextLightColor = "calculated"; + this.taskTextColor = this.taskTextLightColor; + this.taskTextDarkColor = "calculated"; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.taskTextClickableColor = "calculated"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "calculated"; + this.critBorderColor = "calculated"; + this.critBkgColor = "calculated"; + this.todayLineColor = "calculated"; + this.sectionBkgColor = rgba(102, 102, 255, 0.49); + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "#fff400"; + this.taskBorderColor = "#534fbc"; + this.taskBkgColor = "#8a90dd"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "black"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "#534fbc"; + this.activeTaskBkgColor = "#bfc7ff"; + this.gridColor = "lightgrey"; + this.doneTaskBkgColor = "lightgrey"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#ff8888"; + this.critBkgColor = "red"; + this.todayLineColor = "red"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + this.updateColors(); + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + this["cScalePeer1"] = this["cScalePeer1"] || darken(this.secondaryColor, 45); + this["cScalePeer2"] = this["cScalePeer2"] || darken(this.tertiaryColor, 40); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 10); + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 25); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || adjust(this["cScale" + i], { h: 180 }); + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 30, l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 30, l: -(7 + i * 5) }); + } + this.scaleLabelColor = this.scaleLabelColor !== "calculated" && this.scaleLabelColor ? this.scaleLabelColor : this.labelTextColor; + if (this.labelTextColor !== "calculated") { + this.cScaleLabel0 = this.cScaleLabel0 || invert(this.labelTextColor); + this.cScaleLabel3 = this.cScaleLabel3 || invert(this.labelTextColor); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.labelTextColor; + } + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.titleColor = this.textColor; + this.edgeLabelBackground = this.labelBackground; + this.actorBorder = lighten(this.border1, 23); + this.actorBkg = this.mainBkg; + this.labelBoxBkgColor = this.actorBkg; + this.signalColor = this.textColor; + this.signalTextColor = this.textColor; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.actorTextColor; + this.loopTextColor = this.actorTextColor; + this.noteBorderColor = this.border2; + this.noteTextColor = this.actorTextColor; + this.taskTextColor = this.taskTextLightColor; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f0f0f0"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.nodeBorder; + this.specialStateColor = this.lineColor; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || adjust(this.tertiaryColor, { l: -40 }); + this.pie4 = this.pie4 || adjust(this.primaryColor, { l: -10 }); + this.pie5 = this.pie5 || adjust(this.secondaryColor, { l: -30 }); + this.pie6 = this.pie6 || adjust(this.tertiaryColor, { l: -20 }); + this.pie7 = this.pie7 || adjust(this.primaryColor, { h: 60, l: -20 }); + this.pie8 = this.pie8 || adjust(this.primaryColor, { h: -60, l: -40 }); + this.pie9 = this.pie9 || adjust(this.primaryColor, { h: 120, l: -40 }); + this.pie10 = this.pie10 || adjust(this.primaryColor, { h: 60, l: -40 }); + this.pie11 = this.pie11 || adjust(this.primaryColor, { h: -90, l: -40 }); + this.pie12 = this.pie12 || adjust(this.primaryColor, { h: 120, l: -30 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#ECECFF,#8493A6,#FFC3A0,#DCDDE1,#B8E994,#D1A36F,#C3CDE6,#FFB6C1,#496078,#F8F3E3" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.labelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || darken(invert(this.git0), 25); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$2 = (userOverrides) => { + const theme2 = new Theme$2(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$1 = class Theme4 { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#cde498"; + this.secondaryColor = "#cdffb2"; + this.background = "white"; + this.mainBkg = "#cde498"; + this.secondBkg = "#cdffb2"; + this.lineColor = "green"; + this.border1 = "#13540c"; + this.border2 = "#6eaa49"; + this.arrowheadColor = "green"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.tertiaryColor = lighten("#cde498", 10); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.primaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "#333"; + this.edgeLabelBackground = "#e8e8e8"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "black"; + this.actorLineColor = "grey"; + this.signalColor = "#333"; + this.signalTextColor = "#333"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "#326932"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "#6eaa49"; + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "#6eaa49"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "#487e3a"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "black"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "lightgrey"; + this.doneTaskBkgColor = "lightgrey"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#ff8888"; + this.critBkgColor = "red"; + this.todayLineColor = "red"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.actorBorder = darken(this.mainBkg, 20); + this.actorBkg = this.mainBkg; + this.labelBoxBkgColor = this.actorBkg; + this.labelTextColor = this.actorTextColor; + this.loopTextColor = this.actorTextColor; + this.noteBorderColor = this.border2; + this.noteTextColor = this.actorTextColor; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust(this.primaryColor, { h: 330 }); + this["cScalePeer1"] = this["cScalePeer1"] || darken(this.secondaryColor, 45); + this["cScalePeer2"] = this["cScalePeer2"] || darken(this.tertiaryColor, 40); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 10); + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 25); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || adjust(this["cScale" + i], { h: 180 }); + } + this.scaleLabelColor = this.scaleLabelColor !== "calculated" && this.scaleLabelColor ? this.scaleLabelColor : this.labelTextColor; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { h: 30, s: -30, l: -(8 + i * 5) }); + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.taskBorderColor = this.border1; + this.taskTextColor = this.taskTextLightColor; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.activeTaskBorderColor = this.taskBorderColor; + this.activeTaskBkgColor = this.mainBkg; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f0f0f0"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = this.lineColor; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || this.tertiaryColor; + this.pie4 = this.pie4 || adjust(this.primaryColor, { l: -30 }); + this.pie5 = this.pie5 || adjust(this.secondaryColor, { l: -30 }); + this.pie6 = this.pie6 || adjust(this.tertiaryColor, { h: 40, l: -40 }); + this.pie7 = this.pie7 || adjust(this.primaryColor, { h: 60, l: -10 }); + this.pie8 = this.pie8 || adjust(this.primaryColor, { h: -60, l: -10 }); + this.pie9 = this.pie9 || adjust(this.primaryColor, { h: 120, l: 0 }); + this.pie10 = this.pie10 || adjust(this.primaryColor, { h: 60, l: -50 }); + this.pie11 = this.pie11 || adjust(this.primaryColor, { h: -60, l: -50 }); + this.pie12 = this.pie12 || adjust(this.primaryColor, { h: 120, l: -50 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#CDE498,#FF6B6B,#A0D2DB,#D7BDE2,#F0F0F0,#FFC3A0,#7FD8BE,#FF9A8B,#FAF3E0,#FFF176" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.edgeLabelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$1 = (userOverrides) => { + const theme2 = new Theme$1(); + theme2.calculate(userOverrides); + return theme2; +}; +class Theme5 { + constructor() { + this.primaryColor = "#eee"; + this.contrast = "#707070"; + this.secondaryColor = lighten(this.contrast, 55); + this.background = "#ffffff"; + this.tertiaryColor = adjust(this.primaryColor, { h: -160 }); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.mainBkg = "#eee"; + this.secondBkg = "calculated"; + this.lineColor = "#666"; + this.border1 = "#999"; + this.border2 = "calculated"; + this.note = "#ffa"; + this.text = "#333"; + this.critical = "#d42"; + this.done = "#bbb"; + this.arrowheadColor = "#333333"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "calculated"; + this.edgeLabelBackground = "white"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "calculated"; + this.actorLineColor = "calculated"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "calculated"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "calculated"; + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "calculated"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "calculated"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "calculated"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "calculated"; + this.critBkgColor = "calculated"; + this.critBorderColor = "calculated"; + this.todayLineColor = "calculated"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.secondBkg = lighten(this.contrast, 55); + this.border2 = this.contrast; + this.actorBorder = lighten(this.border1, 23); + this.actorBkg = this.mainBkg; + this.actorTextColor = this.text; + this.actorLineColor = this.lineColor; + this.signalColor = this.text; + this.signalTextColor = this.text; + this.labelBoxBkgColor = this.actorBkg; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.text; + this.loopTextColor = this.text; + this.noteBorderColor = "#999"; + this.noteBkgColor = "#666"; + this.noteTextColor = "#fff"; + this.cScale0 = this.cScale0 || "#555"; + this.cScale1 = this.cScale1 || "#F4F4F4"; + this.cScale2 = this.cScale2 || "#555"; + this.cScale3 = this.cScale3 || "#BBB"; + this.cScale4 = this.cScale4 || "#777"; + this.cScale5 = this.cScale5 || "#999"; + this.cScale6 = this.cScale6 || "#DDD"; + this.cScale7 = this.cScale7 || "#FFF"; + this.cScale8 = this.cScale8 || "#DDD"; + this.cScale9 = this.cScale9 || "#BBB"; + this.cScale10 = this.cScale10 || "#999"; + this.cScale11 = this.cScale11 || "#777"; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + if (this.darkMode) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } else { + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 10); + } + } + this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? "black" : this.labelTextColor); + this["cScaleLabel0"] = this["cScaleLabel0"] || this.cScale1; + this["cScaleLabel2"] = this["cScaleLabel2"] || this.cScale1; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust(this.mainBkg, { l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust(this.mainBkg, { l: -(8 + i * 5) }); + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.titleColor = this.text; + this.sectionBkgColor = lighten(this.contrast, 30); + this.sectionBkgColor2 = lighten(this.contrast, 30); + this.taskBorderColor = darken(this.contrast, 10); + this.taskBkgColor = this.contrast; + this.taskTextColor = this.taskTextLightColor; + this.taskTextDarkColor = this.text; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.activeTaskBorderColor = this.taskBorderColor; + this.activeTaskBkgColor = this.mainBkg; + this.gridColor = lighten(this.border1, 30); + this.doneTaskBkgColor = this.done; + this.doneTaskBorderColor = this.lineColor; + this.critBkgColor = this.critical; + this.critBorderColor = darken(this.critBkgColor, 10); + this.todayLineColor = this.critBkgColor; + this.transitionColor = this.transitionColor || "#000"; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f4f4f4"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.stateBorder = this.stateBorder || "#000"; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = "#222"; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust(this.primaryColor, { h: 64 }); + this.fillType3 = adjust(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust(this.primaryColor, { h: -64 }); + this.fillType5 = adjust(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust(this.primaryColor, { h: 128 }); + this.fillType7 = adjust(this.secondaryColor, { h: 128 }); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["pie" + i] = this["cScale" + i]; + } + this.pie12 = this.pie0; + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#EEE,#6BB8E4,#8ACB88,#C7ACD6,#E8DCC2,#FFB2A8,#FFF380,#7E8D91,#FFD8B1,#FAF3E0" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.edgeLabelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = darken(this.pie1, 25) || this.primaryColor; + this.git1 = this.pie2 || this.secondaryColor; + this.git2 = this.pie3 || this.tertiaryColor; + this.git3 = this.pie4 || adjust(this.primaryColor, { h: -30 }); + this.git4 = this.pie5 || adjust(this.primaryColor, { h: -60 }); + this.git5 = this.pie6 || adjust(this.primaryColor, { h: -90 }); + this.git6 = this.pie7 || adjust(this.primaryColor, { h: 60 }); + this.git7 = this.pie8 || adjust(this.primaryColor, { h: 120 }); + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.branchLabelColor = this.branchLabelColor || this.labelTextColor; + this.gitBranchLabel0 = this.branchLabelColor; + this.gitBranchLabel1 = "white"; + this.gitBranchLabel2 = this.branchLabelColor; + this.gitBranchLabel3 = "white"; + this.gitBranchLabel4 = this.branchLabelColor; + this.gitBranchLabel5 = this.branchLabelColor; + this.gitBranchLabel6 = this.branchLabelColor; + this.gitBranchLabel7 = this.branchLabelColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +} +const getThemeVariables = (userOverrides) => { + const theme2 = new Theme5(); + theme2.calculate(userOverrides); + return theme2; +}; +const theme = { + base: { + getThemeVariables: getThemeVariables$4 + }, + dark: { + getThemeVariables: getThemeVariables$3 + }, + default: { + getThemeVariables: getThemeVariables$2 + }, + forest: { + getThemeVariables: getThemeVariables$1 + }, + neutral: { + getThemeVariables + } +}; +const defaultConfigJson = { + "flowchart": { + "useMaxWidth": true, + "titleTopMargin": 25, + "subGraphTitleMargin": { + "top": 0, + "bottom": 0 + }, + "diagramPadding": 8, + "htmlLabels": true, + "nodeSpacing": 50, + "rankSpacing": 50, + "curve": "basis", + "padding": 15, + "defaultRenderer": "dagre-wrapper", + "wrappingWidth": 200 + }, + "sequence": { + "useMaxWidth": true, + "hideUnusedParticipants": false, + "activationWidth": 10, + "diagramMarginX": 50, + "diagramMarginY": 10, + "actorMargin": 50, + "width": 150, + "height": 65, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "mirrorActors": true, + "forceMenus": false, + "bottomMarginAdj": 1, + "rightAngles": false, + "showSequenceNumbers": false, + "actorFontSize": 14, + "actorFontFamily": '"Open Sans", sans-serif', + "actorFontWeight": 400, + "noteFontSize": 14, + "noteFontFamily": '"trebuchet ms", verdana, arial, sans-serif', + "noteFontWeight": 400, + "noteAlign": "center", + "messageFontSize": 16, + "messageFontFamily": '"trebuchet ms", verdana, arial, sans-serif', + "messageFontWeight": 400, + "wrap": false, + "wrapPadding": 10, + "labelBoxWidth": 50, + "labelBoxHeight": 20 + }, + "gantt": { + "useMaxWidth": true, + "titleTopMargin": 25, + "barHeight": 20, + "barGap": 4, + "topPadding": 50, + "rightPadding": 75, + "leftPadding": 75, + "gridLineStartPadding": 35, + "fontSize": 11, + "sectionFontSize": 11, + "numberSectionStyles": 4, + "axisFormat": "%Y-%m-%d", + "topAxis": false, + "displayMode": "", + "weekday": "sunday" + }, + "journey": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "leftMargin": 150, + "width": 150, + "height": 50, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "bottomMarginAdj": 1, + "rightAngles": false, + "taskFontSize": 14, + "taskFontFamily": '"Open Sans", sans-serif', + "taskMargin": 50, + "activationWidth": 10, + "textPlacement": "fo", + "actorColours": [ + "#8FBC8F", + "#7CFC00", + "#00FFFF", + "#20B2AA", + "#B0E0E6", + "#FFFFE0" + ], + "sectionFills": [ + "#191970", + "#8B008B", + "#4B0082", + "#2F4F4F", + "#800000", + "#8B4513", + "#00008B" + ], + "sectionColours": [ + "#fff" + ] + }, + "class": { + "useMaxWidth": true, + "titleTopMargin": 25, + "arrowMarkerAbsolute": false, + "dividerMargin": 10, + "padding": 5, + "textHeight": 10, + "defaultRenderer": "dagre-wrapper", + "htmlLabels": false + }, + "state": { + "useMaxWidth": true, + "titleTopMargin": 25, + "dividerMargin": 10, + "sizeUnit": 5, + "padding": 8, + "textHeight": 10, + "titleShift": -15, + "noteMargin": 10, + "forkWidth": 70, + "forkHeight": 7, + "miniPadding": 2, + "fontSizeFactor": 5.02, + "fontSize": 24, + "labelHeight": 16, + "edgeLengthFactor": "20", + "compositTitleSize": 35, + "radius": 5, + "defaultRenderer": "dagre-wrapper" + }, + "er": { + "useMaxWidth": true, + "titleTopMargin": 25, + "diagramPadding": 20, + "layoutDirection": "TB", + "minEntityWidth": 100, + "minEntityHeight": 75, + "entityPadding": 15, + "stroke": "gray", + "fill": "honeydew", + "fontSize": 12 + }, + "pie": { + "useMaxWidth": true, + "textPosition": 0.75 + }, + "quadrantChart": { + "useMaxWidth": true, + "chartWidth": 500, + "chartHeight": 500, + "titleFontSize": 20, + "titlePadding": 10, + "quadrantPadding": 5, + "xAxisLabelPadding": 5, + "yAxisLabelPadding": 5, + "xAxisLabelFontSize": 16, + "yAxisLabelFontSize": 16, + "quadrantLabelFontSize": 16, + "quadrantTextTopPadding": 5, + "pointTextPadding": 5, + "pointLabelFontSize": 12, + "pointRadius": 5, + "xAxisPosition": "top", + "yAxisPosition": "left", + "quadrantInternalBorderStrokeWidth": 1, + "quadrantExternalBorderStrokeWidth": 2 + }, + "xyChart": { + "useMaxWidth": true, + "width": 700, + "height": 500, + "titleFontSize": 20, + "titlePadding": 10, + "showTitle": true, + "xAxis": { + "$ref": "#/$defs/XYChartAxisConfig", + "showLabel": true, + "labelFontSize": 14, + "labelPadding": 5, + "showTitle": true, + "titleFontSize": 16, + "titlePadding": 5, + "showTick": true, + "tickLength": 5, + "tickWidth": 2, + "showAxisLine": true, + "axisLineWidth": 2 + }, + "yAxis": { + "$ref": "#/$defs/XYChartAxisConfig", + "showLabel": true, + "labelFontSize": 14, + "labelPadding": 5, + "showTitle": true, + "titleFontSize": 16, + "titlePadding": 5, + "showTick": true, + "tickLength": 5, + "tickWidth": 2, + "showAxisLine": true, + "axisLineWidth": 2 + }, + "chartOrientation": "vertical", + "plotReservedSpacePercent": 50 + }, + "requirement": { + "useMaxWidth": true, + "rect_fill": "#f9f9f9", + "text_color": "#333", + "rect_border_size": "0.5px", + "rect_border_color": "#bbb", + "rect_min_width": 200, + "rect_min_height": 200, + "fontSize": 14, + "rect_padding": 10, + "line_height": 20 + }, + "mindmap": { + "useMaxWidth": true, + "padding": 10, + "maxNodeWidth": 200 + }, + "timeline": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "leftMargin": 150, + "width": 150, + "height": 50, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "bottomMarginAdj": 1, + "rightAngles": false, + "taskFontSize": 14, + "taskFontFamily": '"Open Sans", sans-serif', + "taskMargin": 50, + "activationWidth": 10, + "textPlacement": "fo", + "actorColours": [ + "#8FBC8F", + "#7CFC00", + "#00FFFF", + "#20B2AA", + "#B0E0E6", + "#FFFFE0" + ], + "sectionFills": [ + "#191970", + "#8B008B", + "#4B0082", + "#2F4F4F", + "#800000", + "#8B4513", + "#00008B" + ], + "sectionColours": [ + "#fff" + ], + "disableMulticolor": false + }, + "gitGraph": { + "useMaxWidth": true, + "titleTopMargin": 25, + "diagramPadding": 8, + "nodeLabel": { + "width": 75, + "height": 100, + "x": -25, + "y": 0 + }, + "mainBranchName": "main", + "mainBranchOrder": 0, + "showCommitLabel": true, + "showBranches": true, + "rotateCommitLabel": true, + "parallelCommits": false, + "arrowMarkerAbsolute": false + }, + "c4": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "c4ShapeMargin": 50, + "c4ShapePadding": 20, + "width": 216, + "height": 60, + "boxMargin": 10, + "c4ShapeInRow": 4, + "nextLinePaddingX": 0, + "c4BoundaryInRow": 2, + "personFontSize": 14, + "personFontFamily": '"Open Sans", sans-serif', + "personFontWeight": "normal", + "external_personFontSize": 14, + "external_personFontFamily": '"Open Sans", sans-serif', + "external_personFontWeight": "normal", + "systemFontSize": 14, + "systemFontFamily": '"Open Sans", sans-serif', + "systemFontWeight": "normal", + "external_systemFontSize": 14, + "external_systemFontFamily": '"Open Sans", sans-serif', + "external_systemFontWeight": "normal", + "system_dbFontSize": 14, + "system_dbFontFamily": '"Open Sans", sans-serif', + "system_dbFontWeight": "normal", + "external_system_dbFontSize": 14, + "external_system_dbFontFamily": '"Open Sans", sans-serif', + "external_system_dbFontWeight": "normal", + "system_queueFontSize": 14, + "system_queueFontFamily": '"Open Sans", sans-serif', + "system_queueFontWeight": "normal", + "external_system_queueFontSize": 14, + "external_system_queueFontFamily": '"Open Sans", sans-serif', + "external_system_queueFontWeight": "normal", + "boundaryFontSize": 14, + "boundaryFontFamily": '"Open Sans", sans-serif', + "boundaryFontWeight": "normal", + "messageFontSize": 12, + "messageFontFamily": '"Open Sans", sans-serif', + "messageFontWeight": "normal", + "containerFontSize": 14, + "containerFontFamily": '"Open Sans", sans-serif', + "containerFontWeight": "normal", + "external_containerFontSize": 14, + "external_containerFontFamily": '"Open Sans", sans-serif', + "external_containerFontWeight": "normal", + "container_dbFontSize": 14, + "container_dbFontFamily": '"Open Sans", sans-serif', + "container_dbFontWeight": "normal", + "external_container_dbFontSize": 14, + "external_container_dbFontFamily": '"Open Sans", sans-serif', + "external_container_dbFontWeight": "normal", + "container_queueFontSize": 14, + "container_queueFontFamily": '"Open Sans", sans-serif', + "container_queueFontWeight": "normal", + "external_container_queueFontSize": 14, + "external_container_queueFontFamily": '"Open Sans", sans-serif', + "external_container_queueFontWeight": "normal", + "componentFontSize": 14, + "componentFontFamily": '"Open Sans", sans-serif', + "componentFontWeight": "normal", + "external_componentFontSize": 14, + "external_componentFontFamily": '"Open Sans", sans-serif', + "external_componentFontWeight": "normal", + "component_dbFontSize": 14, + "component_dbFontFamily": '"Open Sans", sans-serif', + "component_dbFontWeight": "normal", + "external_component_dbFontSize": 14, + "external_component_dbFontFamily": '"Open Sans", sans-serif', + "external_component_dbFontWeight": "normal", + "component_queueFontSize": 14, + "component_queueFontFamily": '"Open Sans", sans-serif', + "component_queueFontWeight": "normal", + "external_component_queueFontSize": 14, + "external_component_queueFontFamily": '"Open Sans", sans-serif', + "external_component_queueFontWeight": "normal", + "wrap": true, + "wrapPadding": 10, + "person_bg_color": "#08427B", + "person_border_color": "#073B6F", + "external_person_bg_color": "#686868", + "external_person_border_color": "#8A8A8A", + "system_bg_color": "#1168BD", + "system_border_color": "#3C7FC0", + "system_db_bg_color": "#1168BD", + "system_db_border_color": "#3C7FC0", + "system_queue_bg_color": "#1168BD", + "system_queue_border_color": "#3C7FC0", + "external_system_bg_color": "#999999", + "external_system_border_color": "#8A8A8A", + "external_system_db_bg_color": "#999999", + "external_system_db_border_color": "#8A8A8A", + "external_system_queue_bg_color": "#999999", + "external_system_queue_border_color": "#8A8A8A", + "container_bg_color": "#438DD5", + "container_border_color": "#3C7FC0", + "container_db_bg_color": "#438DD5", + "container_db_border_color": "#3C7FC0", + "container_queue_bg_color": "#438DD5", + "container_queue_border_color": "#3C7FC0", + "external_container_bg_color": "#B3B3B3", + "external_container_border_color": "#A6A6A6", + "external_container_db_bg_color": "#B3B3B3", + "external_container_db_border_color": "#A6A6A6", + "external_container_queue_bg_color": "#B3B3B3", + "external_container_queue_border_color": "#A6A6A6", + "component_bg_color": "#85BBF0", + "component_border_color": "#78A8D8", + "component_db_bg_color": "#85BBF0", + "component_db_border_color": "#78A8D8", + "component_queue_bg_color": "#85BBF0", + "component_queue_border_color": "#78A8D8", + "external_component_bg_color": "#CCCCCC", + "external_component_border_color": "#BFBFBF", + "external_component_db_bg_color": "#CCCCCC", + "external_component_db_border_color": "#BFBFBF", + "external_component_queue_bg_color": "#CCCCCC", + "external_component_queue_border_color": "#BFBFBF" + }, + "sankey": { + "useMaxWidth": true, + "width": 600, + "height": 400, + "linkColor": "gradient", + "nodeAlignment": "justify", + "showValues": true, + "prefix": "", + "suffix": "" + }, + "block": { + "useMaxWidth": true, + "padding": 8 + }, + "theme": "default", + "maxTextSize": 5e4, + "maxEdges": 500, + "darkMode": false, + "fontFamily": '"trebuchet ms", verdana, arial, sans-serif;', + "logLevel": 5, + "securityLevel": "strict", + "startOnLoad": true, + "arrowMarkerAbsolute": false, + "secure": [ + "secure", + "securityLevel", + "startOnLoad", + "maxTextSize", + "maxEdges" + ], + "legacyMathML": false, + "deterministicIds": false, + "fontSize": 16 +}; +const config = { + ...defaultConfigJson, + // Set, even though they're `undefined` so that `configKeys` finds these keys + // TODO: Should we replace these with `null` so that they can go in the JSON Schema? + deterministicIDSeed: void 0, + themeCSS: void 0, + // add non-JSON default config values + themeVariables: theme["default"].getThemeVariables(), + sequence: { + ...defaultConfigJson.sequence, + messageFont: function() { + return { + fontFamily: this.messageFontFamily, + fontSize: this.messageFontSize, + fontWeight: this.messageFontWeight + }; + }, + noteFont: function() { + return { + fontFamily: this.noteFontFamily, + fontSize: this.noteFontSize, + fontWeight: this.noteFontWeight + }; + }, + actorFont: function() { + return { + fontFamily: this.actorFontFamily, + fontSize: this.actorFontSize, + fontWeight: this.actorFontWeight + }; + } + }, + gantt: { + ...defaultConfigJson.gantt, + tickInterval: void 0, + useWidth: void 0 + // can probably be removed since `configKeys` already includes this + }, + c4: { + ...defaultConfigJson.c4, + useWidth: void 0, + personFont: function() { + return { + fontFamily: this.personFontFamily, + fontSize: this.personFontSize, + fontWeight: this.personFontWeight + }; + }, + external_personFont: function() { + return { + fontFamily: this.external_personFontFamily, + fontSize: this.external_personFontSize, + fontWeight: this.external_personFontWeight + }; + }, + systemFont: function() { + return { + fontFamily: this.systemFontFamily, + fontSize: this.systemFontSize, + fontWeight: this.systemFontWeight + }; + }, + external_systemFont: function() { + return { + fontFamily: this.external_systemFontFamily, + fontSize: this.external_systemFontSize, + fontWeight: this.external_systemFontWeight + }; + }, + system_dbFont: function() { + return { + fontFamily: this.system_dbFontFamily, + fontSize: this.system_dbFontSize, + fontWeight: this.system_dbFontWeight + }; + }, + external_system_dbFont: function() { + return { + fontFamily: this.external_system_dbFontFamily, + fontSize: this.external_system_dbFontSize, + fontWeight: this.external_system_dbFontWeight + }; + }, + system_queueFont: function() { + return { + fontFamily: this.system_queueFontFamily, + fontSize: this.system_queueFontSize, + fontWeight: this.system_queueFontWeight + }; + }, + external_system_queueFont: function() { + return { + fontFamily: this.external_system_queueFontFamily, + fontSize: this.external_system_queueFontSize, + fontWeight: this.external_system_queueFontWeight + }; + }, + containerFont: function() { + return { + fontFamily: this.containerFontFamily, + fontSize: this.containerFontSize, + fontWeight: this.containerFontWeight + }; + }, + external_containerFont: function() { + return { + fontFamily: this.external_containerFontFamily, + fontSize: this.external_containerFontSize, + fontWeight: this.external_containerFontWeight + }; + }, + container_dbFont: function() { + return { + fontFamily: this.container_dbFontFamily, + fontSize: this.container_dbFontSize, + fontWeight: this.container_dbFontWeight + }; + }, + external_container_dbFont: function() { + return { + fontFamily: this.external_container_dbFontFamily, + fontSize: this.external_container_dbFontSize, + fontWeight: this.external_container_dbFontWeight + }; + }, + container_queueFont: function() { + return { + fontFamily: this.container_queueFontFamily, + fontSize: this.container_queueFontSize, + fontWeight: this.container_queueFontWeight + }; + }, + external_container_queueFont: function() { + return { + fontFamily: this.external_container_queueFontFamily, + fontSize: this.external_container_queueFontSize, + fontWeight: this.external_container_queueFontWeight + }; + }, + componentFont: function() { + return { + fontFamily: this.componentFontFamily, + fontSize: this.componentFontSize, + fontWeight: this.componentFontWeight + }; + }, + external_componentFont: function() { + return { + fontFamily: this.external_componentFontFamily, + fontSize: this.external_componentFontSize, + fontWeight: this.external_componentFontWeight + }; + }, + component_dbFont: function() { + return { + fontFamily: this.component_dbFontFamily, + fontSize: this.component_dbFontSize, + fontWeight: this.component_dbFontWeight + }; + }, + external_component_dbFont: function() { + return { + fontFamily: this.external_component_dbFontFamily, + fontSize: this.external_component_dbFontSize, + fontWeight: this.external_component_dbFontWeight + }; + }, + component_queueFont: function() { + return { + fontFamily: this.component_queueFontFamily, + fontSize: this.component_queueFontSize, + fontWeight: this.component_queueFontWeight + }; + }, + external_component_queueFont: function() { + return { + fontFamily: this.external_component_queueFontFamily, + fontSize: this.external_component_queueFontSize, + fontWeight: this.external_component_queueFontWeight + }; + }, + boundaryFont: function() { + return { + fontFamily: this.boundaryFontFamily, + fontSize: this.boundaryFontSize, + fontWeight: this.boundaryFontWeight + }; + }, + messageFont: function() { + return { + fontFamily: this.messageFontFamily, + fontSize: this.messageFontSize, + fontWeight: this.messageFontWeight + }; + } + }, + pie: { + ...defaultConfigJson.pie, + useWidth: 984 + }, + xyChart: { + ...defaultConfigJson.xyChart, + useWidth: void 0 + }, + requirement: { + ...defaultConfigJson.requirement, + useWidth: void 0 + }, + gitGraph: { + ...defaultConfigJson.gitGraph, + // TODO: This is a temporary override for `gitGraph`, since every other + // diagram does have `useMaxWidth`, but instead sets it to `true`. + // Should we set this to `true` instead? + useMaxWidth: false + }, + sankey: { + ...defaultConfigJson.sankey, + // this is false, unlike every other diagram (other than gitGraph) + // TODO: can we make this default to `true` instead? + useMaxWidth: false + } +}; +const keyify = (obj, prefix = "") => Object.keys(obj).reduce((res, el) => { + if (Array.isArray(obj[el])) { + return res; + } else if (typeof obj[el] === "object" && obj[el] !== null) { + return [...res, prefix + el, ...keyify(obj[el], "")]; + } + return [...res, prefix + el]; +}, []); +const configKeys = new Set(keyify(config, "")); +const defaultConfig$2 = config; +const sanitizeDirective = (args) => { + log$1.debug("sanitizeDirective called with", args); + if (typeof args !== "object" || args == null) { + return; + } + if (Array.isArray(args)) { + args.forEach((arg) => sanitizeDirective(arg)); + return; + } + for (const key of Object.keys(args)) { + log$1.debug("Checking key", key); + if (key.startsWith("__") || key.includes("proto") || key.includes("constr") || !configKeys.has(key) || args[key] == null) { + log$1.debug("sanitize deleting key: ", key); + delete args[key]; + continue; + } + if (typeof args[key] === "object") { + log$1.debug("sanitizing object", key); + sanitizeDirective(args[key]); + continue; + } + const cssMatchers = ["themeCSS", "fontFamily", "altFontFamily"]; + for (const cssKey of cssMatchers) { + if (key.includes(cssKey)) { + log$1.debug("sanitizing css option", key); + args[key] = sanitizeCss(args[key]); + } + } + } + if (args.themeVariables) { + for (const k of Object.keys(args.themeVariables)) { + const val = args.themeVariables[k]; + if ((val == null ? void 0 : val.match) && !val.match(/^[\d "#%(),.;A-Za-z]+$/)) { + args.themeVariables[k] = ""; + } + } + } + log$1.debug("After sanitization", args); +}; +const sanitizeCss = (str2) => { + let startCnt = 0; + let endCnt = 0; + for (const element of str2) { + if (startCnt < endCnt) { + return "{ /* ERROR: Unbalanced CSS */ }"; + } + if (element === "{") { + startCnt++; + } else if (element === "}") { + endCnt++; + } + } + if (startCnt !== endCnt) { + return "{ /* ERROR: Unbalanced CSS */ }"; + } + return str2; +}; +const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s; +const directiveRegex = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; +const anyCommentRegex = /\s*%%.*\n/gm; +class UnknownDiagramError extends Error { + constructor(message) { + super(message); + this.name = "UnknownDiagramError"; + } +} +const detectors = {}; +const detectType = function(text, config2) { + text = text.replace(frontMatterRegex, "").replace(directiveRegex, "").replace(anyCommentRegex, "\n"); + for (const [key, { detector: detector2 }] of Object.entries(detectors)) { + const diagram2 = detector2(text, config2); + if (diagram2) { + return key; + } + } + throw new UnknownDiagramError( + `No diagram type detected matching given configuration for text: ${text}` + ); +}; +const registerLazyLoadedDiagrams = (...diagrams2) => { + for (const { id: id2, detector: detector2, loader: loader2 } of diagrams2) { + addDetector(id2, detector2, loader2); + } +}; +const addDetector = (key, detector2, loader2) => { + if (detectors[key]) { + log$1.error(`Detector with key ${key} already exists`); + } else { + detectors[key] = { detector: detector2, loader: loader2 }; + } + log$1.debug(`Detector with key ${key} added${loader2 ? " with loader" : ""}`); +}; +const getDiagramLoader = (key) => { + return detectors[key].loader; +}; +const assignWithDepth = (dst, src, { depth = 2, clobber = false } = {}) => { + const config2 = { depth, clobber }; + if (Array.isArray(src) && !Array.isArray(dst)) { + src.forEach((s) => assignWithDepth(dst, s, config2)); + return dst; + } else if (Array.isArray(src) && Array.isArray(dst)) { + src.forEach((s) => { + if (!dst.includes(s)) { + dst.push(s); + } + }); + return dst; + } + if (dst === void 0 || depth <= 0) { + if (dst !== void 0 && dst !== null && typeof dst === "object" && typeof src === "object") { + return Object.assign(dst, src); + } else { + return src; + } + } + if (src !== void 0 && typeof dst === "object" && typeof src === "object") { + Object.keys(src).forEach((key) => { + if (typeof src[key] === "object" && (dst[key] === void 0 || typeof dst[key] === "object")) { + if (dst[key] === void 0) { + dst[key] = Array.isArray(src[key]) ? [] : {}; + } + dst[key] = assignWithDepth(dst[key], src[key], { depth: depth - 1, clobber }); + } else if (clobber || typeof dst[key] !== "object" && typeof src[key] !== "object") { + dst[key] = src[key]; + } + }); + } + return dst; +}; +const assignWithDepth$1 = assignWithDepth; +const ZERO_WIDTH_SPACE = "​"; +const d3CurveTypes = { + curveBasis, + curveBasisClosed, + curveBasisOpen, + curveBumpX: bumpX, + curveBumpY: bumpY, + curveBundle, + curveCardinalClosed, + curveCardinalOpen, + curveCardinal, + curveCatmullRomClosed, + curveCatmullRomOpen, + curveCatmullRom, + curveLinear, + curveLinearClosed, + curveMonotoneX: monotoneX, + curveMonotoneY: monotoneY, + curveNatural, + curveStep, + curveStepAfter: stepAfter, + curveStepBefore: stepBefore +}; +const directiveWithoutOpen = /\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; +const detectInit = function(text, config2) { + const inits = detectDirective(text, /(?:init\b)|(?:initialize\b)/); + let results = {}; + if (Array.isArray(inits)) { + const args = inits.map((init2) => init2.args); + sanitizeDirective(args); + results = assignWithDepth$1(results, [...args]); + } else { + results = inits.args; + } + if (!results) { + return; + } + let type2 = detectType(text, config2); + const prop = "config"; + if (results[prop] !== void 0) { + if (type2 === "flowchart-v2") { + type2 = "flowchart"; + } + results[type2] = results[prop]; + delete results[prop]; + } + return results; +}; +const detectDirective = function(text, type2 = null) { + try { + const commentWithoutDirectives = new RegExp( + `[%]{2}(?![{]${directiveWithoutOpen.source})(?=[}][%]{2}).* +`, + "ig" + ); + text = text.trim().replace(commentWithoutDirectives, "").replace(/'/gm, '"'); + log$1.debug( + `Detecting diagram directive${type2 !== null ? " type:" + type2 : ""} based on the text:${text}` + ); + let match; + const result = []; + while ((match = directiveRegex.exec(text)) !== null) { + if (match.index === directiveRegex.lastIndex) { + directiveRegex.lastIndex++; + } + if (match && !type2 || type2 && match[1] && match[1].match(type2) || type2 && match[2] && match[2].match(type2)) { + const type22 = match[1] ? match[1] : match[2]; + const args = match[3] ? match[3].trim() : match[4] ? JSON.parse(match[4].trim()) : null; + result.push({ type: type22, args }); + } + } + if (result.length === 0) { + return { type: text, args: null }; + } + return result.length === 1 ? result[0] : result; + } catch (error) { + log$1.error( + `ERROR: ${error.message} - Unable to parse directive type: '${type2}' based on the text: '${text}'` + ); + return { type: void 0, args: null }; + } +}; +const removeDirectives = function(text) { + return text.replace(directiveRegex, ""); +}; +const isSubstringInArray = function(str2, arr) { + for (const [i, element] of arr.entries()) { + if (element.match(str2)) { + return i; + } + } + return -1; +}; +function interpolateToCurve(interpolate, defaultCurve) { + if (!interpolate) { + return defaultCurve; + } + const curveName = `curve${interpolate.charAt(0).toUpperCase() + interpolate.slice(1)}`; + return d3CurveTypes[curveName] ?? defaultCurve; +} +function formatUrl(linkStr, config2) { + const url = linkStr.trim(); + if (!url) { + return void 0; + } + if (config2.securityLevel !== "loose") { + return dist.sanitizeUrl(url); + } + return url; +} +const runFunc = (functionName, ...params) => { + const arrPaths = functionName.split("."); + const len = arrPaths.length - 1; + const fnName = arrPaths[len]; + let obj = window; + for (let i = 0; i < len; i++) { + obj = obj[arrPaths[i]]; + if (!obj) { + log$1.error(`Function name: ${functionName} not found in window`); + return; + } + } + obj[fnName](...params); +}; +function distance(p1, p2) { + if (!p1 || !p2) { + return 0; + } + return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); +} +function traverseEdge(points) { + let prevPoint; + let totalDistance = 0; + points.forEach((point) => { + totalDistance += distance(point, prevPoint); + prevPoint = point; + }); + const remainingDistance = totalDistance / 2; + return calculatePoint(points, remainingDistance); +} +function calcLabelPosition(points) { + if (points.length === 1) { + return points[0]; + } + return traverseEdge(points); +} +const roundNumber = (num, precision = 2) => { + const factor = Math.pow(10, precision); + return Math.round(num * factor) / factor; +}; +const calculatePoint = (points, distanceToTraverse) => { + let prevPoint = void 0; + let remainingDistance = distanceToTraverse; + for (const point of points) { + if (prevPoint) { + const vectorDistance = distance(point, prevPoint); + if (vectorDistance < remainingDistance) { + remainingDistance -= vectorDistance; + } else { + const distanceRatio = remainingDistance / vectorDistance; + if (distanceRatio <= 0) { + return prevPoint; + } + if (distanceRatio >= 1) { + return { x: point.x, y: point.y }; + } + if (distanceRatio > 0 && distanceRatio < 1) { + return { + x: roundNumber((1 - distanceRatio) * prevPoint.x + distanceRatio * point.x, 5), + y: roundNumber((1 - distanceRatio) * prevPoint.y + distanceRatio * point.y, 5) + }; + } + } + } + prevPoint = point; + } + throw new Error("Could not find a suitable point for the given distance"); +}; +const calcCardinalityPosition = (isRelationTypePresent, points, initialPosition) => { + log$1.info(`our points ${JSON.stringify(points)}`); + if (points[0] !== initialPosition) { + points = points.reverse(); + } + const distanceToCardinalityPoint = 25; + const center = calculatePoint(points, distanceToCardinalityPoint); + const d = isRelationTypePresent ? 10 : 5; + const angle = Math.atan2(points[0].y - center.y, points[0].x - center.x); + const cardinalityPosition = { x: 0, y: 0 }; + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2; + return cardinalityPosition; +}; +function calcTerminalLabelPosition(terminalMarkerSize, position, _points) { + const points = structuredClone(_points); + log$1.info("our points", points); + if (position !== "start_left" && position !== "start_right") { + points.reverse(); + } + const distanceToCardinalityPoint = 25 + terminalMarkerSize; + const center = calculatePoint(points, distanceToCardinalityPoint); + const d = 10 + terminalMarkerSize * 0.5; + const angle = Math.atan2(points[0].y - center.y, points[0].x - center.x); + const cardinalityPosition = { x: 0, y: 0 }; + if (position === "start_left") { + cardinalityPosition.x = Math.sin(angle + Math.PI) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle + Math.PI) * d + (points[0].y + center.y) / 2; + } else if (position === "end_right") { + cardinalityPosition.x = Math.sin(angle - Math.PI) * d + (points[0].x + center.x) / 2 - 5; + cardinalityPosition.y = -Math.cos(angle - Math.PI) * d + (points[0].y + center.y) / 2 - 5; + } else if (position === "end_left") { + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2 - 5; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2 - 5; + } else { + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2; + } + return cardinalityPosition; +} +function getStylesFromArray(arr) { + let style = ""; + let labelStyle = ""; + for (const element of arr) { + if (element !== void 0) { + if (element.startsWith("color:") || element.startsWith("text-align:")) { + labelStyle = labelStyle + element + ";"; + } else { + style = style + element + ";"; + } + } + } + return { style, labelStyle }; +} +let cnt = 0; +const generateId = () => { + cnt++; + return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt; +}; +function makeRandomHex(length) { + let result = ""; + const characters = "0123456789abcdef"; + const charactersLength = characters.length; + for (let i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +} +const random = (options) => { + return makeRandomHex(options.length); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + anchor: "start", + style: "#666", + width: 100, + height: 100, + textMargin: 0, + rx: 0, + ry: 0, + valign: void 0, + text: "" + }; +}; +const drawSimpleText = function(elem, textData) { + const nText = textData.text.replace(common$1.lineBreakRegex, " "); + const [, _fontSizePx] = parseFontSize(textData.fontSize); + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.style("text-anchor", textData.anchor); + textElem.style("font-family", textData.fontFamily); + textElem.style("font-size", _fontSizePx); + textElem.style("font-weight", textData.fontWeight); + textElem.attr("fill", textData.fill); + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + const span = textElem.append("tspan"); + span.attr("x", textData.x + textData.textMargin * 2); + span.attr("fill", textData.fill); + span.text(nText); + return textElem; +}; +const wrapLabel = memoize( + (label, maxWidth, config2) => { + if (!label) { + return label; + } + config2 = Object.assign( + { fontSize: 12, fontWeight: 400, fontFamily: "Arial", joinWith: "
    " }, + config2 + ); + if (common$1.lineBreakRegex.test(label)) { + return label; + } + const words = label.split(" "); + const completedLines = []; + let nextLine = ""; + words.forEach((word, index) => { + const wordLength = calculateTextWidth(`${word} `, config2); + const nextLineLength = calculateTextWidth(nextLine, config2); + if (wordLength > maxWidth) { + const { hyphenatedStrings, remainingWord } = breakString(word, maxWidth, "-", config2); + completedLines.push(nextLine, ...hyphenatedStrings); + nextLine = remainingWord; + } else if (nextLineLength + wordLength >= maxWidth) { + completedLines.push(nextLine); + nextLine = word; + } else { + nextLine = [nextLine, word].filter(Boolean).join(" "); + } + const currentWord = index + 1; + const isLastWord = currentWord === words.length; + if (isLastWord) { + completedLines.push(nextLine); + } + }); + return completedLines.filter((line) => line !== "").join(config2.joinWith); + }, + (label, maxWidth, config2) => `${label}${maxWidth}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}${config2.joinWith}` +); +const breakString = memoize( + (word, maxWidth, hyphenCharacter = "-", config2) => { + config2 = Object.assign( + { fontSize: 12, fontWeight: 400, fontFamily: "Arial", margin: 0 }, + config2 + ); + const characters = [...word]; + const lines = []; + let currentLine = ""; + characters.forEach((character, index) => { + const nextLine = `${currentLine}${character}`; + const lineWidth = calculateTextWidth(nextLine, config2); + if (lineWidth >= maxWidth) { + const currentCharacter = index + 1; + const isLastLine = characters.length === currentCharacter; + const hyphenatedNextLine = `${nextLine}${hyphenCharacter}`; + lines.push(isLastLine ? nextLine : hyphenatedNextLine); + currentLine = ""; + } else { + currentLine = nextLine; + } + }); + return { hyphenatedStrings: lines, remainingWord: currentLine }; + }, + (word, maxWidth, hyphenCharacter = "-", config2) => `${word}${maxWidth}${hyphenCharacter}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}` +); +function calculateTextHeight(text, config2) { + return calculateTextDimensions(text, config2).height; +} +function calculateTextWidth(text, config2) { + return calculateTextDimensions(text, config2).width; +} +const calculateTextDimensions = memoize( + (text, config2) => { + const { fontSize = 12, fontFamily = "Arial", fontWeight = 400 } = config2; + if (!text) { + return { width: 0, height: 0 }; + } + const [, _fontSizePx] = parseFontSize(fontSize); + const fontFamilies = ["sans-serif", fontFamily]; + const lines = text.split(common$1.lineBreakRegex); + const dims = []; + const body = select("body"); + if (!body.remove) { + return { width: 0, height: 0, lineHeight: 0 }; + } + const g = body.append("svg"); + for (const fontFamily2 of fontFamilies) { + let cHeight = 0; + const dim = { width: 0, height: 0, lineHeight: 0 }; + for (const line of lines) { + const textObj = getTextObj(); + textObj.text = line || ZERO_WIDTH_SPACE; + const textElem = drawSimpleText(g, textObj).style("font-size", _fontSizePx).style("font-weight", fontWeight).style("font-family", fontFamily2); + const bBox = (textElem._groups || textElem)[0][0].getBBox(); + if (bBox.width === 0 && bBox.height === 0) { + throw new Error("svg element not in render tree"); + } + dim.width = Math.round(Math.max(dim.width, bBox.width)); + cHeight = Math.round(bBox.height); + dim.height += cHeight; + dim.lineHeight = Math.round(Math.max(dim.lineHeight, cHeight)); + } + dims.push(dim); + } + g.remove(); + const index = isNaN(dims[1].height) || isNaN(dims[1].width) || isNaN(dims[1].lineHeight) || dims[0].height > dims[1].height && dims[0].width > dims[1].width && dims[0].lineHeight > dims[1].lineHeight ? 0 : 1; + return dims[index]; + }, + (text, config2) => `${text}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}` +); +class InitIDGenerator { + constructor(deterministic = false, seed) { + this.count = 0; + this.count = seed ? seed.length : 0; + this.next = deterministic ? () => this.count++ : () => Date.now(); + } +} +let decoder; +const entityDecode = function(html) { + decoder = decoder || document.createElement("div"); + html = escape(html).replace(/%26/g, "&").replace(/%23/g, "#").replace(/%3B/g, ";"); + decoder.innerHTML = html; + return unescape(decoder.textContent); +}; +function isDetailedError(error) { + return "str" in error; +} +const insertTitle = (parent, cssClass, titleTopMargin, title) => { + var _a; + if (!title) { + return; + } + const bounds = (_a = parent.node()) == null ? void 0 : _a.getBBox(); + if (!bounds) { + return; + } + parent.append("text").text(title).attr("x", bounds.x + bounds.width / 2).attr("y", -titleTopMargin).attr("class", cssClass); +}; +const parseFontSize = (fontSize) => { + if (typeof fontSize === "number") { + return [fontSize, fontSize + "px"]; + } + const fontSizeNumber = parseInt(fontSize ?? "", 10); + if (Number.isNaN(fontSizeNumber)) { + return [void 0, void 0]; + } else if (fontSize === String(fontSizeNumber)) { + return [fontSizeNumber, fontSize + "px"]; + } else { + return [fontSizeNumber, fontSize]; + } +}; +function cleanAndMerge(defaultData, data) { + return merge$1({}, defaultData, data); +} +const utils = { + assignWithDepth: assignWithDepth$1, + wrapLabel, + calculateTextHeight, + calculateTextWidth, + calculateTextDimensions, + cleanAndMerge, + detectInit, + detectDirective, + isSubstringInArray, + interpolateToCurve, + calcLabelPosition, + calcCardinalityPosition, + calcTerminalLabelPosition, + formatUrl, + getStylesFromArray, + generateId, + random, + runFunc, + entityDecode, + insertTitle, + parseFontSize, + InitIDGenerator +}; +const encodeEntities = function(text) { + let txt = text; + txt = txt.replace(/style.*:\S*#.*;/g, function(s) { + return s.substring(0, s.length - 1); + }); + txt = txt.replace(/classDef.*:\S*#.*;/g, function(s) { + return s.substring(0, s.length - 1); + }); + txt = txt.replace(/#\w+;/g, function(s) { + const innerTxt = s.substring(1, s.length - 1); + const isInt = /^\+?\d+$/.test(innerTxt); + if (isInt) { + return "fl°°" + innerTxt + "¶ß"; + } else { + return "fl°" + innerTxt + "¶ß"; + } + }); + return txt; +}; +const decodeEntities = function(text) { + return text.replace(/fl°°/g, "&#").replace(/fl°/g, "&").replace(/¶ß/g, ";"); +}; +const version = "10.9.1"; +const defaultConfig$1 = Object.freeze(defaultConfig$2); +let siteConfig = assignWithDepth$1({}, defaultConfig$1); +let configFromInitialize; +let directives = []; +let currentConfig = assignWithDepth$1({}, defaultConfig$1); +const updateCurrentConfig = (siteCfg, _directives) => { + let cfg = assignWithDepth$1({}, siteCfg); + let sumOfDirectives = {}; + for (const d of _directives) { + sanitize(d); + sumOfDirectives = assignWithDepth$1(sumOfDirectives, d); + } + cfg = assignWithDepth$1(cfg, sumOfDirectives); + if (sumOfDirectives.theme && sumOfDirectives.theme in theme) { + const tmpConfigFromInitialize = assignWithDepth$1({}, configFromInitialize); + const themeVariables = assignWithDepth$1( + tmpConfigFromInitialize.themeVariables || {}, + sumOfDirectives.themeVariables + ); + if (cfg.theme && cfg.theme in theme) { + cfg.themeVariables = theme[cfg.theme].getThemeVariables(themeVariables); + } + } + currentConfig = cfg; + checkConfig(currentConfig); + return currentConfig; +}; +const setSiteConfig = (conf) => { + siteConfig = assignWithDepth$1({}, defaultConfig$1); + siteConfig = assignWithDepth$1(siteConfig, conf); + if (conf.theme && theme[conf.theme]) { + siteConfig.themeVariables = theme[conf.theme].getThemeVariables(conf.themeVariables); + } + updateCurrentConfig(siteConfig, directives); + return siteConfig; +}; +const saveConfigFromInitialize = (conf) => { + configFromInitialize = assignWithDepth$1({}, conf); +}; +const updateSiteConfig = (conf) => { + siteConfig = assignWithDepth$1(siteConfig, conf); + updateCurrentConfig(siteConfig, directives); + return siteConfig; +}; +const getSiteConfig = () => { + return assignWithDepth$1({}, siteConfig); +}; +const setConfig$1 = (conf) => { + checkConfig(conf); + assignWithDepth$1(currentConfig, conf); + return getConfig$1(); +}; +const getConfig$1 = () => { + return assignWithDepth$1({}, currentConfig); +}; +const sanitize = (options) => { + if (!options) { + return; + } + ["secure", ...siteConfig.secure ?? []].forEach((key) => { + if (Object.hasOwn(options, key)) { + log$1.debug(`Denied attempt to modify a secure key ${key}`, options[key]); + delete options[key]; + } + }); + Object.keys(options).forEach((key) => { + if (key.startsWith("__")) { + delete options[key]; + } + }); + Object.keys(options).forEach((key) => { + if (typeof options[key] === "string" && (options[key].includes("<") || options[key].includes(">") || options[key].includes("url(data:"))) { + delete options[key]; + } + if (typeof options[key] === "object") { + sanitize(options[key]); + } + }); +}; +const addDirective = (directive) => { + sanitizeDirective(directive); + if (directive.fontFamily && (!directive.themeVariables || !directive.themeVariables.fontFamily)) { + directive.themeVariables = { fontFamily: directive.fontFamily }; + } + directives.push(directive); + updateCurrentConfig(siteConfig, directives); +}; +const reset = (config2 = siteConfig) => { + directives = []; + updateCurrentConfig(config2, directives); +}; +const ConfigWarning = { + LAZY_LOAD_DEPRECATED: "The configuration options lazyLoadedDiagrams and loadExternalDiagramsAtStartup are deprecated. Please use registerExternalDiagrams instead." +}; +const issuedWarnings = {}; +const issueWarning = (warning) => { + if (issuedWarnings[warning]) { + return; + } + log$1.warn(ConfigWarning[warning]); + issuedWarnings[warning] = true; +}; +const checkConfig = (config2) => { + if (!config2) { + return; + } + if (config2.lazyLoadedDiagrams || config2.loadExternalDiagramsAtStartup) { + issueWarning("LAZY_LOAD_DEPRECATED"); + } +}; +const id$l = "c4"; +const detector$l = (txt) => { + return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt); +}; +const loader$m = async () => { + const { diagram: diagram2 } = await import('./c4Diagram-ae766693-R1FJdUX5.js'); + return { id: id$l, diagram: diagram2 }; +}; +const plugin$j = { + id: id$l, + detector: detector$l, + loader: loader$m +}; +const c4 = plugin$j; +const id$k = "flowchart"; +const detector$k = (txt, config2) => { + var _a, _b; + if (((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper" || ((_b = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _b.defaultRenderer) === "elk") { + return false; + } + return /^\s*graph/.test(txt); +}; +const loader$l = async () => { + const { diagram: diagram2 } = await import('./flowDiagram-b222e15a-CZXxO4wD.js'); + return { id: id$k, diagram: diagram2 }; +}; +const plugin$i = { + id: id$k, + detector: detector$k, + loader: loader$l +}; +const flowchart = plugin$i; +const id$j = "flowchart-v2"; +const detector$j = (txt, config2) => { + var _a, _b, _c; + if (((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "dagre-d3" || ((_b = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _b.defaultRenderer) === "elk") { + return false; + } + if (/^\s*graph/.test(txt) && ((_c = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _c.defaultRenderer) === "dagre-wrapper") { + return true; + } + return /^\s*flowchart/.test(txt); +}; +const loader$k = async () => { + const { diagram: diagram2 } = await import('./flowDiagram-v2-13329dc7-BmGiwYxl.js'); + return { id: id$j, diagram: diagram2 }; +}; +const plugin$h = { + id: id$j, + detector: detector$j, + loader: loader$k +}; +const flowchartV2 = plugin$h; +const id$i = "er"; +const detector$i = (txt) => { + return /^\s*erDiagram/.test(txt); +}; +const loader$j = async () => { + const { diagram: diagram2 } = await import('./erDiagram-09d1c15f-DYT5JEfx.js'); + return { id: id$i, diagram: diagram2 }; +}; +const plugin$g = { + id: id$i, + detector: detector$i, + loader: loader$j +}; +const er = plugin$g; +const id$h = "gitGraph"; +const detector$h = (txt) => { + return /^\s*gitGraph/.test(txt); +}; +const loader$i = async () => { + const { diagram: diagram2 } = await import('./gitGraphDiagram-942e62fe-D_yUENpJ.js'); + return { id: id$h, diagram: diagram2 }; +}; +const plugin$f = { + id: id$h, + detector: detector$h, + loader: loader$i +}; +const git = plugin$f; +const id$g = "gantt"; +const detector$g = (txt) => { + return /^\s*gantt/.test(txt); +}; +const loader$h = async () => { + const { diagram: diagram2 } = await import('./ganttDiagram-b62c793e-CQCA69Wn.js'); + return { id: id$g, diagram: diagram2 }; +}; +const plugin$e = { + id: id$g, + detector: detector$g, + loader: loader$h +}; +const gantt = plugin$e; +const id$f = "info"; +const detector$f = (txt) => { + return /^\s*info/.test(txt); +}; +const loader$g = async () => { + const { diagram: diagram2 } = await import('./infoDiagram-94cd232f-BX5-hJJ1.js'); + return { id: id$f, diagram: diagram2 }; +}; +const info = { + id: id$f, + detector: detector$f, + loader: loader$g +}; +const id$e = "pie"; +const detector$e = (txt) => { + return /^\s*pie/.test(txt); +}; +const loader$f = async () => { + const { diagram: diagram2 } = await import('./pieDiagram-bb1d19e5-CL3Vsrzt.js'); + return { id: id$e, diagram: diagram2 }; +}; +const pie = { + id: id$e, + detector: detector$e, + loader: loader$f +}; +const id$d = "quadrantChart"; +const detector$d = (txt) => { + return /^\s*quadrantChart/.test(txt); +}; +const loader$e = async () => { + const { diagram: diagram2 } = await import('./quadrantDiagram-c759a472-BtTVtR58.js'); + return { id: id$d, diagram: diagram2 }; +}; +const plugin$d = { + id: id$d, + detector: detector$d, + loader: loader$e +}; +const quadrantChart = plugin$d; +const id$c = "xychart"; +const detector$c = (txt) => { + return /^\s*xychart-beta/.test(txt); +}; +const loader$d = async () => { + const { diagram: diagram2 } = await import('./xychartDiagram-f11f50a6-CiMOLwkr.js'); + return { id: id$c, diagram: diagram2 }; +}; +const plugin$c = { + id: id$c, + detector: detector$c, + loader: loader$d +}; +const xychart = plugin$c; +const id$b = "requirement"; +const detector$b = (txt) => { + return /^\s*requirement(Diagram)?/.test(txt); +}; +const loader$c = async () => { + const { diagram: diagram2 } = await import('./requirementDiagram-87253d64-HAYNZ486.js'); + return { id: id$b, diagram: diagram2 }; +}; +const plugin$b = { + id: id$b, + detector: detector$b, + loader: loader$c +}; +const requirement = plugin$b; +const id$a = "sequence"; +const detector$a = (txt) => { + return /^\s*sequenceDiagram/.test(txt); +}; +const loader$b = async () => { + const { diagram: diagram2 } = await import('./sequenceDiagram-6894f283-B41gUBOj.js'); + return { id: id$a, diagram: diagram2 }; +}; +const plugin$a = { + id: id$a, + detector: detector$a, + loader: loader$b +}; +const sequence = plugin$a; +const id$9 = "class"; +const detector$9 = (txt, config2) => { + var _a; + if (((_a = config2 == null ? void 0 : config2.class) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return false; + } + return /^\s*classDiagram/.test(txt); +}; +const loader$a = async () => { + const { diagram: diagram2 } = await import('./classDiagram-fb54d2a0-ihSKvW6J.js'); + return { id: id$9, diagram: diagram2 }; +}; +const plugin$9 = { + id: id$9, + detector: detector$9, + loader: loader$a +}; +const classDiagram = plugin$9; +const id$8 = "classDiagram"; +const detector$8 = (txt, config2) => { + var _a; + if (/^\s*classDiagram/.test(txt) && ((_a = config2 == null ? void 0 : config2.class) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return true; + } + return /^\s*classDiagram-v2/.test(txt); +}; +const loader$9 = async () => { + const { diagram: diagram2 } = await import('./classDiagram-v2-a2b738ad-Dl8Cj6T-.js'); + return { id: id$8, diagram: diagram2 }; +}; +const plugin$8 = { + id: id$8, + detector: detector$8, + loader: loader$9 +}; +const classDiagramV2 = plugin$8; +const id$7 = "state"; +const detector$7 = (txt, config2) => { + var _a; + if (((_a = config2 == null ? void 0 : config2.state) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return false; + } + return /^\s*stateDiagram/.test(txt); +}; +const loader$8 = async () => { + const { diagram: diagram2 } = await import('./stateDiagram-5dee940d-CIjdI-3m.js'); + return { id: id$7, diagram: diagram2 }; +}; +const plugin$7 = { + id: id$7, + detector: detector$7, + loader: loader$8 +}; +const state = plugin$7; +const id$6 = "stateDiagram"; +const detector$6 = (txt, config2) => { + var _a; + if (/^\s*stateDiagram-v2/.test(txt)) { + return true; + } + if (/^\s*stateDiagram/.test(txt) && ((_a = config2 == null ? void 0 : config2.state) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return true; + } + return false; +}; +const loader$7 = async () => { + const { diagram: diagram2 } = await import('./stateDiagram-v2-1992cada-BiJohYZs.js'); + return { id: id$6, diagram: diagram2 }; +}; +const plugin$6 = { + id: id$6, + detector: detector$6, + loader: loader$7 +}; +const stateV2 = plugin$6; +const id$5 = "journey"; +const detector$5 = (txt) => { + return /^\s*journey/.test(txt); +}; +const loader$6 = async () => { + const { diagram: diagram2 } = await import('./journeyDiagram-6625b456-DVx0F7XZ.js'); + return { id: id$5, diagram: diagram2 }; +}; +const plugin$5 = { + id: id$5, + detector: detector$5, + loader: loader$6 +}; +const journey = plugin$5; +const d3Attrs = function(d3Elem, attrs) { + for (let attr of attrs) { + d3Elem.attr(attr[0], attr[1]); + } +}; +const calculateSvgSizeAttrs = function(height, width, useMaxWidth) { + let attrs = /* @__PURE__ */ new Map(); + if (useMaxWidth) { + attrs.set("width", "100%"); + attrs.set("style", `max-width: ${width}px;`); + } else { + attrs.set("height", height); + attrs.set("width", width); + } + return attrs; +}; +const configureSvgSize = function(svgElem, height, width, useMaxWidth) { + const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth); + d3Attrs(svgElem, attrs); +}; +const setupGraphViewbox$1 = function(graph, svgElem, padding, useMaxWidth) { + const svgBounds = svgElem.node().getBBox(); + const sWidth = svgBounds.width; + const sHeight = svgBounds.height; + log$1.info(`SVG bounds: ${sWidth}x${sHeight}`, svgBounds); + let width = 0; + let height = 0; + log$1.info(`Graph bounds: ${width}x${height}`, graph); + width = sWidth + padding * 2; + height = sHeight + padding * 2; + log$1.info(`Calculated bounds: ${width}x${height}`); + configureSvgSize(svgElem, height, width, useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${svgBounds.width + 2 * padding} ${svgBounds.height + 2 * padding}`; + svgElem.attr("viewBox", vBox); +}; +const themes = {}; +const getStyles = (type2, userStyles, options) => { + let diagramStyles = ""; + if (type2 in themes && themes[type2]) { + diagramStyles = themes[type2](options); + } else { + log$1.warn(`No theme found for ${type2}`); + } + return ` & { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + fill: ${options.textColor} + } + + /* Classes common for multiple diagrams */ + + & .error-icon { + fill: ${options.errorBkgColor}; + } + & .error-text { + fill: ${options.errorTextColor}; + stroke: ${options.errorTextColor}; + } + + & .edge-thickness-normal { + stroke-width: 2px; + } + & .edge-thickness-thick { + stroke-width: 3.5px + } + & .edge-pattern-solid { + stroke-dasharray: 0; + } + + & .edge-pattern-dashed{ + stroke-dasharray: 3; + } + .edge-pattern-dotted { + stroke-dasharray: 2; + } + + & .marker { + fill: ${options.lineColor}; + stroke: ${options.lineColor}; + } + & .marker.cross { + stroke: ${options.lineColor}; + } + + & svg { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + } + + ${diagramStyles} + + ${userStyles} +`; +}; +const addStylesForDiagram = (type2, diagramTheme) => { + if (diagramTheme !== void 0) { + themes[type2] = diagramTheme; + } +}; +const getStyles$1 = getStyles; +let accTitle = ""; +let diagramTitle = ""; +let accDescription = ""; +const sanitizeText$1 = (txt) => sanitizeText$2(txt, getConfig$1()); +const clear = () => { + accTitle = ""; + accDescription = ""; + diagramTitle = ""; +}; +const setAccTitle = (txt) => { + accTitle = sanitizeText$1(txt).replace(/^\s+/g, ""); +}; +const getAccTitle = () => accTitle; +const setAccDescription = (txt) => { + accDescription = sanitizeText$1(txt).replace(/\n\s+/g, "\n"); +}; +const getAccDescription = () => accDescription; +const setDiagramTitle = (txt) => { + diagramTitle = sanitizeText$1(txt); +}; +const getDiagramTitle = () => diagramTitle; +const commonDb = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + clear, + getAccDescription, + getAccTitle, + getDiagramTitle, + setAccDescription, + setAccTitle, + setDiagramTitle +}, Symbol.toStringTag, { value: "Module" })); +const log = log$1; +const setLogLevel = setLogLevel$1; +const getConfig = getConfig$1; +const setConfig = setConfig$1; +const defaultConfig = defaultConfig$1; +const sanitizeText = (text) => sanitizeText$2(text, getConfig()); +const setupGraphViewbox = setupGraphViewbox$1; +const getCommonDb = () => { + return commonDb; +}; +const diagrams = {}; +const registerDiagram = (id2, diagram2, detector2) => { + var _a; + if (diagrams[id2]) { + throw new Error(`Diagram ${id2} already registered.`); + } + diagrams[id2] = diagram2; + if (detector2) { + addDetector(id2, detector2); + } + addStylesForDiagram(id2, diagram2.styles); + (_a = diagram2.injectUtils) == null ? void 0 : _a.call( + diagram2, + log, + setLogLevel, + getConfig, + sanitizeText, + setupGraphViewbox, + getCommonDb(), + () => { + } + ); +}; +const getDiagram = (name) => { + if (name in diagrams) { + return diagrams[name]; + } + throw new DiagramNotFoundError(name); +}; +class DiagramNotFoundError extends Error { + constructor(name) { + super(`Diagram ${name} not found.`); + } +} +const selectSvgElement = (id2) => { + var _a; + const { securityLevel } = getConfig(); + let root = select("body"); + if (securityLevel === "sandbox") { + const sandboxElement = select(`#i${id2}`); + const doc = ((_a = sandboxElement.node()) == null ? void 0 : _a.contentDocument) ?? document; + root = select(doc.body); + } + const svg = root.select(`#${id2}`); + return svg; +}; +const draw = (_text, id2, version2) => { + log$1.debug("rendering svg for syntax error\n"); + const svg = selectSvgElement(id2); + const g = svg.append("g"); + svg.attr("viewBox", "0 0 2412 512"); + configureSvgSize(svg, 100, 512, true); + g.append("path").attr("class", "error-icon").attr( + "d", + "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z" + ); + g.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"); + g.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${version2}`); +}; +const renderer = { draw }; +const errorRenderer = renderer; +const diagram = { + db: {}, + renderer, + parser: { + parser: { yy: {} }, + parse: () => { + return; + } + } +}; +const errorDiagram = diagram; +const id$4 = "flowchart-elk"; +const detector$4 = (txt, config2) => { + var _a; + if ( + // If diagram explicitly states flowchart-elk + /^\s*flowchart-elk/.test(txt) || // If a flowchart/graph diagram has their default renderer set to elk + /^\s*flowchart|graph/.test(txt) && ((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "elk" + ) { + return true; + } + return false; +}; +const loader$5 = async () => { + const { diagram: diagram2 } = await import('./flowchart-elk-definition-ae0efee6-BGp9zXvL.js'); + return { id: id$4, diagram: diagram2 }; +}; +const plugin$4 = { + id: id$4, + detector: detector$4, + loader: loader$5 +}; +const flowchartElk = plugin$4; +const id$3 = "timeline"; +const detector$3 = (txt) => { + return /^\s*timeline/.test(txt); +}; +const loader$4 = async () => { + const { diagram: diagram2 } = await import('./timeline-definition-bf702344-CKi_og6o.js'); + return { id: id$3, diagram: diagram2 }; +}; +const plugin$3 = { + id: id$3, + detector: detector$3, + loader: loader$4 +}; +const timeline = plugin$3; +const id$2 = "mindmap"; +const detector$2 = (txt) => { + return /^\s*mindmap/.test(txt); +}; +const loader$3 = async () => { + const { diagram: diagram2 } = await import('./mindmap-definition-307c710a-CVAgfJ2r.js'); + return { id: id$2, diagram: diagram2 }; +}; +const plugin$2 = { + id: id$2, + detector: detector$2, + loader: loader$3 +}; +const mindmap = plugin$2; +const id$1 = "sankey"; +const detector$1 = (txt) => { + return /^\s*sankey-beta/.test(txt); +}; +const loader$2 = async () => { + const { diagram: diagram2 } = await import('./sankeyDiagram-707fac0f-Cjcgj_Iu.js'); + return { id: id$1, diagram: diagram2 }; +}; +const plugin$1 = { + id: id$1, + detector: detector$1, + loader: loader$2 +}; +const sankey = plugin$1; +const id = "block"; +const detector = (txt) => { + return /^\s*block-beta/.test(txt); +}; +const loader$1 = async () => { + const { diagram: diagram2 } = await import('./blockDiagram-9f4a6865-Bzsqusn3.js'); + return { id, diagram: diagram2 }; +}; +const plugin = { + id, + detector, + loader: loader$1 +}; +const block = plugin; +let hasLoadedDiagrams = false; +const addDiagrams = () => { + if (hasLoadedDiagrams) { + return; + } + hasLoadedDiagrams = true; + registerDiagram("error", errorDiagram, (text) => { + return text.toLowerCase().trim() === "error"; + }); + registerDiagram( + "---", + // --- diagram type may appear if YAML front-matter is not parsed correctly + { + db: { + clear: () => { + } + }, + styles: {}, + // should never be used + renderer: { + draw: () => { + } + }, + parser: { + parser: { yy: {} }, + parse: () => { + throw new Error( + "Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks" + ); + } + }, + init: () => null + // no op + }, + (text) => { + return text.toLowerCase().trimStart().startsWith("---"); + } + ); + registerLazyLoadedDiagrams( + c4, + classDiagramV2, + classDiagram, + er, + gantt, + info, + pie, + requirement, + sequence, + flowchartElk, + flowchartV2, + flowchart, + mindmap, + timeline, + git, + stateV2, + state, + journey, + quadrantChart, + sankey, + xychart, + block + ); +}; +class Diagram { + constructor(text, metadata = {}) { + this.text = text; + this.metadata = metadata; + this.type = "graph"; + this.text = encodeEntities(text); + this.text += "\n"; + const cnf = getConfig$1(); + try { + this.type = detectType(text, cnf); + } catch (e) { + this.type = "error"; + this.detectError = e; + } + const diagram2 = getDiagram(this.type); + log$1.debug("Type " + this.type); + this.db = diagram2.db; + this.renderer = diagram2.renderer; + this.parser = diagram2.parser; + this.parser.parser.yy = this.db; + this.init = diagram2.init; + this.parse(); + } + parse() { + var _a, _b, _c, _d, _e; + if (this.detectError) { + throw this.detectError; + } + (_b = (_a = this.db).clear) == null ? void 0 : _b.call(_a); + const config2 = getConfig$1(); + (_c = this.init) == null ? void 0 : _c.call(this, config2); + if (this.metadata.title) { + (_e = (_d = this.db).setDiagramTitle) == null ? void 0 : _e.call(_d, this.metadata.title); + } + this.parser.parse(this.text); + } + async render(id2, version2) { + await this.renderer.draw(this.text, id2, version2, this); + } + getParser() { + return this.parser; + } + getType() { + return this.type; + } +} +const getDiagramFromText$1 = async (text, metadata = {}) => { + const type2 = detectType(text, getConfig$1()); + try { + getDiagram(type2); + } catch (error) { + const loader2 = getDiagramLoader(type2); + if (!loader2) { + throw new UnknownDiagramError(`Diagram ${type2} not found.`); + } + const { id: id2, diagram: diagram2 } = await loader2(); + registerDiagram(id2, diagram2); + } + return new Diagram(text, metadata); +}; +let interactionFunctions = []; +const attachFunctions = () => { + interactionFunctions.forEach((f) => { + f(); + }); + interactionFunctions = []; +}; +const SVG_ROLE = "graphics-document document"; +function setA11yDiagramInfo(svg, diagramType) { + svg.attr("role", SVG_ROLE); + if (diagramType !== "") { + svg.attr("aria-roledescription", diagramType); + } +} +function addSVGa11yTitleDescription(svg, a11yTitle, a11yDesc, baseId) { + if (svg.insert === void 0) { + return; + } + if (a11yDesc) { + const descId = `chart-desc-${baseId}`; + svg.attr("aria-describedby", descId); + svg.insert("desc", ":first-child").attr("id", descId).text(a11yDesc); + } + if (a11yTitle) { + const titleId = `chart-title-${baseId}`; + svg.attr("aria-labelledby", titleId); + svg.insert("title", ":first-child").attr("id", titleId).text(a11yTitle); + } +} +const cleanupComments = (text) => { + return text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(); +}; +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ +function isNothing(subject) { + return typeof subject === "undefined" || subject === null; +} +function isObject(subject) { + return typeof subject === "object" && subject !== null; +} +function toArray(sequence2) { + if (Array.isArray(sequence2)) + return sequence2; + else if (isNothing(sequence2)) + return []; + return [sequence2]; +} +function extend(target, source) { + var index, length, key, sourceKeys; + if (source) { + sourceKeys = Object.keys(source); + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + return target; +} +function repeat(string, count) { + var result = "", cycle; + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + return result; +} +function isNegativeZero(number) { + return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; +} +var isNothing_1 = isNothing; +var isObject_1 = isObject; +var toArray_1 = toArray; +var repeat_1 = repeat; +var isNegativeZero_1 = isNegativeZero; +var extend_1 = extend; +var common = { + isNothing: isNothing_1, + isObject: isObject_1, + toArray: toArray_1, + repeat: repeat_1, + isNegativeZero: isNegativeZero_1, + extend: extend_1 +}; +function formatError(exception2, compact) { + var where = "", message = exception2.reason || "(unknown reason)"; + if (!exception2.mark) + return message; + if (exception2.mark.name) { + where += 'in "' + exception2.mark.name + '" '; + } + where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; + if (!compact && exception2.mark.snippet) { + where += "\n\n" + exception2.mark.snippet; + } + return message + " " + where; +} +function YAMLException$1(reason, mark) { + Error.call(this); + this.name = "YAMLException"; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error().stack || ""; + } +} +YAMLException$1.prototype = Object.create(Error.prototype); +YAMLException$1.prototype.constructor = YAMLException$1; +YAMLException$1.prototype.toString = function toString(compact) { + return this.name + ": " + formatError(this, compact); +}; +var exception = YAMLException$1; +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ""; + var tail = ""; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + if (position - lineStart > maxHalfLength) { + head = " ... "; + lineStart = position - maxHalfLength + head.length; + } + if (lineEnd - position > maxHalfLength) { + tail = " ..."; + lineEnd = position + maxHalfLength - tail.length; + } + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail, + pos: position - lineStart + head.length + // relative position + }; +} +function padStart(string, max) { + return common.repeat(" ", max - string.length) + string; +} +function makeSnippet(mark, options) { + options = Object.create(options || null); + if (!mark.buffer) + return null; + if (!options.maxLength) + options.maxLength = 79; + if (typeof options.indent !== "number") + options.indent = 1; + if (typeof options.linesBefore !== "number") + options.linesBefore = 3; + if (typeof options.linesAfter !== "number") + options.linesAfter = 2; + var re = /\r?\n|\r|\0/g; + var lineStarts = [0]; + var lineEnds = []; + var match; + var foundLineNo = -1; + while (match = re.exec(mark.buffer)) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + if (foundLineNo < 0) + foundLineNo = lineStarts.length - 1; + var result = "", i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) + break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result; + } + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n"; + result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n"; + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) + break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n"; + } + return result.replace(/\n$/, ""); +} +var snippet = makeSnippet; +var TYPE_CONSTRUCTOR_OPTIONS = [ + "kind", + "multi", + "resolve", + "construct", + "instanceOf", + "predicate", + "represent", + "representName", + "defaultStyle", + "styleAliases" +]; +var YAML_NODE_KINDS = [ + "scalar", + "sequence", + "mapping" +]; +function compileStyleAliases(map2) { + var result = {}; + if (map2 !== null) { + Object.keys(map2).forEach(function(style) { + map2[style].forEach(function(alias) { + result[String(alias)] = style; + }); + }); + } + return result; +} +function Type$1(tag, options) { + options = options || {}; + Object.keys(options).forEach(function(name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + this.options = options; + this.tag = tag; + this.kind = options["kind"] || null; + this.resolve = options["resolve"] || function() { + return true; + }; + this.construct = options["construct"] || function(data) { + return data; + }; + this.instanceOf = options["instanceOf"] || null; + this.predicate = options["predicate"] || null; + this.represent = options["represent"] || null; + this.representName = options["representName"] || null; + this.defaultStyle = options["defaultStyle"] || null; + this.multi = options["multi"] || false; + this.styleAliases = compileStyleAliases(options["styleAliases"] || null); + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} +var type = Type$1; +function compileList(schema2, name) { + var result = []; + schema2[name].forEach(function(currentType) { + var newIndex = result.length; + result.forEach(function(previousType, previousIndex) { + if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { + newIndex = previousIndex; + } + }); + result[newIndex] = currentType; + }); + return result; +} +function compileMap() { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + function collectType(type2) { + if (type2.multi) { + result.multi[type2.kind].push(type2); + result.multi["fallback"].push(type2); + } else { + result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; + } + } + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} +function Schema$1(definition) { + return this.extend(definition); +} +Schema$1.prototype.extend = function extend2(definition) { + var implicit = []; + var explicit = []; + if (definition instanceof type) { + explicit.push(definition); + } else if (Array.isArray(definition)) { + explicit = explicit.concat(definition); + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + if (definition.implicit) + implicit = implicit.concat(definition.implicit); + if (definition.explicit) + explicit = explicit.concat(definition.explicit); + } else { + throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); + } + implicit.forEach(function(type$1) { + if (!(type$1 instanceof type)) { + throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); + } + if (type$1.loadKind && type$1.loadKind !== "scalar") { + throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); + } + if (type$1.multi) { + throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); + } + }); + explicit.forEach(function(type$1) { + if (!(type$1 instanceof type)) { + throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); + } + }); + var result = Object.create(Schema$1.prototype); + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + result.compiledImplicit = compileList(result, "implicit"); + result.compiledExplicit = compileList(result, "explicit"); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + return result; +}; +var schema = Schema$1; +var str = new type("tag:yaml.org,2002:str", { + kind: "scalar", + construct: function(data) { + return data !== null ? data : ""; + } +}); +var seq = new type("tag:yaml.org,2002:seq", { + kind: "sequence", + construct: function(data) { + return data !== null ? data : []; + } +}); +var map = new type("tag:yaml.org,2002:map", { + kind: "mapping", + construct: function(data) { + return data !== null ? data : {}; + } +}); +var failsafe = new schema({ + explicit: [ + str, + seq, + map + ] +}); +function resolveYamlNull(data) { + if (data === null) + return true; + var max = data.length; + return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); +} +function constructYamlNull() { + return null; +} +function isNull(object) { + return object === null; +} +var _null = new type("tag:yaml.org,2002:null", { + kind: "scalar", + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function() { + return "~"; + }, + lowercase: function() { + return "null"; + }, + uppercase: function() { + return "NULL"; + }, + camelcase: function() { + return "Null"; + }, + empty: function() { + return ""; + } + }, + defaultStyle: "lowercase" +}); +function resolveYamlBoolean(data) { + if (data === null) + return false; + var max = data.length; + return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); +} +function constructYamlBoolean(data) { + return data === "true" || data === "True" || data === "TRUE"; +} +function isBoolean(object) { + return Object.prototype.toString.call(object) === "[object Boolean]"; +} +var bool = new type("tag:yaml.org,2002:bool", { + kind: "scalar", + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function(object) { + return object ? "true" : "false"; + }, + uppercase: function(object) { + return object ? "TRUE" : "FALSE"; + }, + camelcase: function(object) { + return object ? "True" : "False"; + } + }, + defaultStyle: "lowercase" +}); +function isHexCode(c) { + return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; +} +function isOctCode(c) { + return 48 <= c && c <= 55; +} +function isDecCode(c) { + return 48 <= c && c <= 57; +} +function resolveYamlInteger(data) { + if (data === null) + return false; + var max = data.length, index = 0, hasDigits = false, ch; + if (!max) + return false; + ch = data[index]; + if (ch === "-" || ch === "+") { + ch = data[++index]; + } + if (ch === "0") { + if (index + 1 === max) + return true; + ch = data[++index]; + if (ch === "b") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (ch !== "0" && ch !== "1") + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + if (ch === "x") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isHexCode(data.charCodeAt(index))) + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + if (ch === "o") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isOctCode(data.charCodeAt(index))) + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + } + if (ch === "_") + return false; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + if (!hasDigits || ch === "_") + return false; + return true; +} +function constructYamlInteger(data) { + var value = data, sign = 1, ch; + if (value.indexOf("_") !== -1) { + value = value.replace(/_/g, ""); + } + ch = value[0]; + if (ch === "-" || ch === "+") { + if (ch === "-") + sign = -1; + value = value.slice(1); + ch = value[0]; + } + if (value === "0") + return 0; + if (ch === "0") { + if (value[1] === "b") + return sign * parseInt(value.slice(2), 2); + if (value[1] === "x") + return sign * parseInt(value.slice(2), 16); + if (value[1] === "o") + return sign * parseInt(value.slice(2), 8); + } + return sign * parseInt(value, 10); +} +function isInteger(object) { + return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); +} +var int = new type("tag:yaml.org,2002:int", { + kind: "scalar", + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function(obj) { + return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); + }, + octal: function(obj) { + return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); + }, + decimal: function(obj) { + return obj.toString(10); + }, + /* eslint-disable max-len */ + hexadecimal: function(obj) { + return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); + } + }, + defaultStyle: "decimal", + styleAliases: { + binary: [2, "bin"], + octal: [8, "oct"], + decimal: [10, "dec"], + hexadecimal: [16, "hex"] + } +}); +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" +); +function resolveYamlFloat(data) { + if (data === null) + return false; + if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === "_") { + return false; + } + return true; +} +function constructYamlFloat(data) { + var value, sign; + value = data.replace(/_/g, "").toLowerCase(); + sign = value[0] === "-" ? -1 : 1; + if ("+-".indexOf(value[0]) >= 0) { + value = value.slice(1); + } + if (value === ".inf") { + return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + } else if (value === ".nan") { + return NaN; + } + return sign * parseFloat(value, 10); +} +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; +function representYamlFloat(object, style) { + var res; + if (isNaN(object)) { + switch (style) { + case "lowercase": + return ".nan"; + case "uppercase": + return ".NAN"; + case "camelcase": + return ".NaN"; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case "lowercase": + return ".inf"; + case "uppercase": + return ".INF"; + case "camelcase": + return ".Inf"; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case "lowercase": + return "-.inf"; + case "uppercase": + return "-.INF"; + case "camelcase": + return "-.Inf"; + } + } else if (common.isNegativeZero(object)) { + return "-0.0"; + } + res = object.toString(10); + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; +} +function isFloat(object) { + return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); +} +var float = new type("tag:yaml.org,2002:float", { + kind: "scalar", + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: "lowercase" +}); +var json = failsafe.extend({ + implicit: [ + _null, + bool, + int, + float + ] +}); +var core = json; +var YAML_DATE_REGEXP = new RegExp( + "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$" +); +var YAML_TIMESTAMP_REGEXP = new RegExp( + "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$" +); +function resolveYamlTimestamp(data) { + if (data === null) + return false; + if (YAML_DATE_REGEXP.exec(data) !== null) + return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) + return true; + return false; +} +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; + match = YAML_DATE_REGEXP.exec(data); + if (match === null) + match = YAML_TIMESTAMP_REGEXP.exec(data); + if (match === null) + throw new Error("Date resolve error"); + year = +match[1]; + month = +match[2] - 1; + day = +match[3]; + if (!match[4]) { + return new Date(Date.UTC(year, month, day)); + } + hour = +match[4]; + minute = +match[5]; + second = +match[6]; + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { + fraction += "0"; + } + fraction = +fraction; + } + if (match[9]) { + tz_hour = +match[10]; + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 6e4; + if (match[9] === "-") + delta = -delta; + } + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + if (delta) + date.setTime(date.getTime() - delta); + return date; +} +function representYamlTimestamp(object) { + return object.toISOString(); +} +var timestamp = new type("tag:yaml.org,2002:timestamp", { + kind: "scalar", + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); +function resolveYamlMerge(data) { + return data === "<<" || data === null; +} +var merge = new type("tag:yaml.org,2002:merge", { + kind: "scalar", + resolve: resolveYamlMerge +}); +var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; +function resolveYamlBinary(data) { + if (data === null) + return false; + var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP; + for (idx = 0; idx < max; idx++) { + code = map2.indexOf(data.charAt(idx)); + if (code > 64) + continue; + if (code < 0) + return false; + bitlen += 6; + } + return bitlen % 8 === 0; +} +function constructYamlBinary(data) { + var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = []; + for (idx = 0; idx < max; idx++) { + if (idx % 4 === 0 && idx) { + result.push(bits >> 16 & 255); + result.push(bits >> 8 & 255); + result.push(bits & 255); + } + bits = bits << 6 | map2.indexOf(input.charAt(idx)); + } + tailbits = max % 4 * 6; + if (tailbits === 0) { + result.push(bits >> 16 & 255); + result.push(bits >> 8 & 255); + result.push(bits & 255); + } else if (tailbits === 18) { + result.push(bits >> 10 & 255); + result.push(bits >> 2 & 255); + } else if (tailbits === 12) { + result.push(bits >> 4 & 255); + } + return new Uint8Array(result); +} +function representYamlBinary(object) { + var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP; + for (idx = 0; idx < max; idx++) { + if (idx % 3 === 0 && idx) { + result += map2[bits >> 18 & 63]; + result += map2[bits >> 12 & 63]; + result += map2[bits >> 6 & 63]; + result += map2[bits & 63]; + } + bits = (bits << 8) + object[idx]; + } + tail = max % 3; + if (tail === 0) { + result += map2[bits >> 18 & 63]; + result += map2[bits >> 12 & 63]; + result += map2[bits >> 6 & 63]; + result += map2[bits & 63]; + } else if (tail === 2) { + result += map2[bits >> 10 & 63]; + result += map2[bits >> 4 & 63]; + result += map2[bits << 2 & 63]; + result += map2[64]; + } else if (tail === 1) { + result += map2[bits >> 2 & 63]; + result += map2[bits << 4 & 63]; + result += map2[64]; + result += map2[64]; + } + return result; +} +function isBinary(obj) { + return Object.prototype.toString.call(obj) === "[object Uint8Array]"; +} +var binary = new type("tag:yaml.org,2002:binary", { + kind: "scalar", + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); +var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; +var _toString$2 = Object.prototype.toString; +function resolveYamlOmap(data) { + if (data === null) + return true; + var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data; + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + if (_toString$2.call(pair) !== "[object Object]") + return false; + for (pairKey in pair) { + if (_hasOwnProperty$3.call(pair, pairKey)) { + if (!pairHasKey) + pairHasKey = true; + else + return false; + } + } + if (!pairHasKey) + return false; + if (objectKeys.indexOf(pairKey) === -1) + objectKeys.push(pairKey); + else + return false; + } + return true; +} +function constructYamlOmap(data) { + return data !== null ? data : []; +} +var omap = new type("tag:yaml.org,2002:omap", { + kind: "sequence", + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); +var _toString$1 = Object.prototype.toString; +function resolveYamlPairs(data) { + if (data === null) + return true; + var index, length, pair, keys, result, object = data; + result = new Array(object.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + if (_toString$1.call(pair) !== "[object Object]") + return false; + keys = Object.keys(pair); + if (keys.length !== 1) + return false; + result[index] = [keys[0], pair[keys[0]]]; + } + return true; +} +function constructYamlPairs(data) { + if (data === null) + return []; + var index, length, pair, keys, result, object = data; + result = new Array(object.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + keys = Object.keys(pair); + result[index] = [keys[0], pair[keys[0]]]; + } + return result; +} +var pairs = new type("tag:yaml.org,2002:pairs", { + kind: "sequence", + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); +var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; +function resolveYamlSet(data) { + if (data === null) + return true; + var key, object = data; + for (key in object) { + if (_hasOwnProperty$2.call(object, key)) { + if (object[key] !== null) + return false; + } + } + return true; +} +function constructYamlSet(data) { + return data !== null ? data : {}; +} +var set = new type("tag:yaml.org,2002:set", { + kind: "mapping", + resolve: resolveYamlSet, + construct: constructYamlSet +}); +var _default = core.extend({ + implicit: [ + timestamp, + merge + ], + explicit: [ + binary, + omap, + pairs, + set + ] +}); +var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; +function _class(obj) { + return Object.prototype.toString.call(obj); +} +function is_EOL(c) { + return c === 10 || c === 13; +} +function is_WHITE_SPACE(c) { + return c === 9 || c === 32; +} +function is_WS_OR_EOL(c) { + return c === 9 || c === 32 || c === 10 || c === 13; +} +function is_FLOW_INDICATOR(c) { + return c === 44 || c === 91 || c === 93 || c === 123 || c === 125; +} +function fromHexCode(c) { + var lc; + if (48 <= c && c <= 57) { + return c - 48; + } + lc = c | 32; + if (97 <= lc && lc <= 102) { + return lc - 97 + 10; + } + return -1; +} +function escapedHexLen(c) { + if (c === 120) { + return 2; + } + if (c === 117) { + return 4; + } + if (c === 85) { + return 8; + } + return 0; +} +function fromDecimalCode(c) { + if (48 <= c && c <= 57) { + return c - 48; + } + return -1; +} +function simpleEscapeSequence(c) { + return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "…" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : ""; +} +function charFromCodepoint(c) { + if (c <= 65535) { + return String.fromCharCode(c); + } + return String.fromCharCode( + (c - 65536 >> 10) + 55296, + (c - 65536 & 1023) + 56320 + ); +} +var simpleEscapeCheck = new Array(256); +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} +function State$1(input, options) { + this.input = input; + this.filename = options["filename"] || null; + this.schema = options["schema"] || _default; + this.onWarning = options["onWarning"] || null; + this.legacy = options["legacy"] || false; + this.json = options["json"] || false; + this.listener = options["listener"] || null; + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + this.firstTabInLine = -1; + this.documents = []; +} +function generateError(state2, message) { + var mark = { + name: state2.filename, + buffer: state2.input.slice(0, -1), + // omit trailing \0 + position: state2.position, + line: state2.line, + column: state2.position - state2.lineStart + }; + mark.snippet = snippet(mark); + return new exception(message, mark); +} +function throwError(state2, message) { + throw generateError(state2, message); +} +function throwWarning(state2, message) { + if (state2.onWarning) { + state2.onWarning.call(null, generateError(state2, message)); + } +} +var directiveHandlers = { + YAML: function handleYamlDirective(state2, name, args) { + var match, major, minor; + if (state2.version !== null) { + throwError(state2, "duplication of %YAML directive"); + } + if (args.length !== 1) { + throwError(state2, "YAML directive accepts exactly one argument"); + } + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + if (match === null) { + throwError(state2, "ill-formed argument of the YAML directive"); + } + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + if (major !== 1) { + throwError(state2, "unacceptable YAML version of the document"); + } + state2.version = args[0]; + state2.checkLineBreaks = minor < 2; + if (minor !== 1 && minor !== 2) { + throwWarning(state2, "unsupported YAML version of the document"); + } + }, + TAG: function handleTagDirective(state2, name, args) { + var handle, prefix; + if (args.length !== 2) { + throwError(state2, "TAG directive accepts exactly two arguments"); + } + handle = args[0]; + prefix = args[1]; + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state2, "ill-formed tag handle (first argument) of the TAG directive"); + } + if (_hasOwnProperty$1.call(state2.tagMap, handle)) { + throwError(state2, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state2, "ill-formed tag prefix (second argument) of the TAG directive"); + } + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state2, "tag prefix is malformed: " + prefix); + } + state2.tagMap[handle] = prefix; + } +}; +function captureSegment(state2, start, end, checkJson) { + var _position, _length, _character, _result; + if (start < end) { + _result = state2.input.slice(start, end); + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 9 || 32 <= _character && _character <= 1114111)) { + throwError(state2, "expected valid JSON character"); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state2, "the stream contains non-printable characters"); + } + state2.result += _result; + } +} +function mergeMappings(state2, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + if (!common.isObject(source)) { + throwError(state2, "cannot merge mappings; the provided source object is unacceptable"); + } + sourceKeys = Object.keys(source); + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + if (!_hasOwnProperty$1.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} +function storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { + var index, quantity; + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state2, "nested arrays are not supported inside keys"); + } + if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") { + keyNode[index] = "[object Object]"; + } + } + } + if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") { + keyNode = "[object Object]"; + } + keyNode = String(keyNode); + if (_result === null) { + _result = {}; + } + if (keyTag === "tag:yaml.org,2002:merge") { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state2, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state2, _result, valueNode, overridableKeys); + } + } else { + if (!state2.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) { + state2.line = startLine || state2.line; + state2.lineStart = startLineStart || state2.lineStart; + state2.position = startPos || state2.position; + throwError(state2, "duplicated mapping key"); + } + if (keyNode === "__proto__") { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + return _result; +} +function readLineBreak(state2) { + var ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 10) { + state2.position++; + } else if (ch === 13) { + state2.position++; + if (state2.input.charCodeAt(state2.position) === 10) { + state2.position++; + } + } else { + throwError(state2, "a line break is expected"); + } + state2.line += 1; + state2.lineStart = state2.position; + state2.firstTabInLine = -1; +} +function skipSeparationSpace(state2, allowComments, checkIndent) { + var lineBreaks = 0, ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 9 && state2.firstTabInLine === -1) { + state2.firstTabInLine = state2.position; + } + ch = state2.input.charCodeAt(++state2.position); + } + if (allowComments && ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 10 && ch !== 13 && ch !== 0); + } + if (is_EOL(ch)) { + readLineBreak(state2); + ch = state2.input.charCodeAt(state2.position); + lineBreaks++; + state2.lineIndent = 0; + while (ch === 32) { + state2.lineIndent++; + ch = state2.input.charCodeAt(++state2.position); + } + } else { + break; + } + } + if (checkIndent !== -1 && lineBreaks !== 0 && state2.lineIndent < checkIndent) { + throwWarning(state2, "deficient indentation"); + } + return lineBreaks; +} +function testDocumentSeparator(state2) { + var _position = state2.position, ch; + ch = state2.input.charCodeAt(_position); + if ((ch === 45 || ch === 46) && ch === state2.input.charCodeAt(_position + 1) && ch === state2.input.charCodeAt(_position + 2)) { + _position += 3; + ch = state2.input.charCodeAt(_position); + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + return false; +} +function writeFoldedLines(state2, count) { + if (count === 1) { + state2.result += " "; + } else if (count > 1) { + state2.result += common.repeat("\n", count - 1); + } +} +function readPlainScalar(state2, nodeIndent, withinFlowCollection) { + var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state2.kind, _result = state2.result, ch; + ch = state2.input.charCodeAt(state2.position); + if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) { + return false; + } + if (ch === 63 || ch === 45) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + state2.kind = "scalar"; + state2.result = ""; + captureStart = captureEnd = state2.position; + hasPendingContent = false; + while (ch !== 0) { + if (ch === 58) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + } else if (ch === 35) { + preceding = state2.input.charCodeAt(state2.position - 1); + if (is_WS_OR_EOL(preceding)) { + break; + } + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2) || withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + } else if (is_EOL(ch)) { + _line = state2.line; + _lineStart = state2.lineStart; + _lineIndent = state2.lineIndent; + skipSeparationSpace(state2, false, -1); + if (state2.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state2.input.charCodeAt(state2.position); + continue; + } else { + state2.position = captureEnd; + state2.line = _line; + state2.lineStart = _lineStart; + state2.lineIndent = _lineIndent; + break; + } + } + if (hasPendingContent) { + captureSegment(state2, captureStart, captureEnd, false); + writeFoldedLines(state2, state2.line - _line); + captureStart = captureEnd = state2.position; + hasPendingContent = false; + } + if (!is_WHITE_SPACE(ch)) { + captureEnd = state2.position + 1; + } + ch = state2.input.charCodeAt(++state2.position); + } + captureSegment(state2, captureStart, captureEnd, false); + if (state2.result) { + return true; + } + state2.kind = _kind; + state2.result = _result; + return false; +} +function readSingleQuotedScalar(state2, nodeIndent) { + var ch, captureStart, captureEnd; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 39) { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + state2.position++; + captureStart = captureEnd = state2.position; + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + if (ch === 39) { + captureSegment(state2, captureStart, state2.position, true); + ch = state2.input.charCodeAt(++state2.position); + if (ch === 39) { + captureStart = state2.position; + state2.position++; + captureEnd = state2.position; + } else { + return true; + } + } else if (is_EOL(ch)) { + captureSegment(state2, captureStart, captureEnd, true); + writeFoldedLines(state2, skipSeparationSpace(state2, false, nodeIndent)); + captureStart = captureEnd = state2.position; + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + throwError(state2, "unexpected end of the document within a single quoted scalar"); + } else { + state2.position++; + captureEnd = state2.position; + } + } + throwError(state2, "unexpected end of the stream within a single quoted scalar"); +} +function readDoubleQuotedScalar(state2, nodeIndent) { + var captureStart, captureEnd, hexLength, hexResult, tmp, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 34) { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + state2.position++; + captureStart = captureEnd = state2.position; + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + if (ch === 34) { + captureSegment(state2, captureStart, state2.position, true); + state2.position++; + return true; + } else if (ch === 92) { + captureSegment(state2, captureStart, state2.position, true); + ch = state2.input.charCodeAt(++state2.position); + if (is_EOL(ch)) { + skipSeparationSpace(state2, false, nodeIndent); + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state2.result += simpleEscapeMap[ch]; + state2.position++; + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + for (; hexLength > 0; hexLength--) { + ch = state2.input.charCodeAt(++state2.position); + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + } else { + throwError(state2, "expected hexadecimal character"); + } + } + state2.result += charFromCodepoint(hexResult); + state2.position++; + } else { + throwError(state2, "unknown escape sequence"); + } + captureStart = captureEnd = state2.position; + } else if (is_EOL(ch)) { + captureSegment(state2, captureStart, captureEnd, true); + writeFoldedLines(state2, skipSeparationSpace(state2, false, nodeIndent)); + captureStart = captureEnd = state2.position; + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + throwError(state2, "unexpected end of the document within a double quoted scalar"); + } else { + state2.position++; + captureEnd = state2.position; + } + } + throwError(state2, "unexpected end of the stream within a double quoted scalar"); +} +function readFlowCollection(state2, nodeIndent) { + var readNext = true, _line, _lineStart, _pos, _tag = state2.tag, _result, _anchor = state2.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 91) { + terminator = 93; + isMapping = false; + _result = []; + } else if (ch === 123) { + terminator = 125; + isMapping = true; + _result = {}; + } else { + return false; + } + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(++state2.position); + while (ch !== 0) { + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if (ch === terminator) { + state2.position++; + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = isMapping ? "mapping" : "sequence"; + state2.result = _result; + return true; + } else if (!readNext) { + throwError(state2, "missed comma between flow collection entries"); + } else if (ch === 44) { + throwError(state2, "expected the node content, but found ','"); + } + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + if (ch === 63) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state2.position++; + skipSeparationSpace(state2, true, nodeIndent); + } + } + _line = state2.line; + _lineStart = state2.lineStart; + _pos = state2.position; + composeNode(state2, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state2.tag; + keyNode = state2.result; + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if ((isExplicitPair || state2.line === _line) && ch === 58) { + isPair = true; + ch = state2.input.charCodeAt(++state2.position); + skipSeparationSpace(state2, true, nodeIndent); + composeNode(state2, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state2.result; + } + if (isMapping) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state2, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if (ch === 44) { + readNext = true; + ch = state2.input.charCodeAt(++state2.position); + } else { + readNext = false; + } + } + throwError(state2, "unexpected end of the stream within a flow collection"); +} +function readBlockScalar(state2, nodeIndent) { + var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 124) { + folding = false; + } else if (ch === 62) { + folding = true; + } else { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + while (ch !== 0) { + ch = state2.input.charCodeAt(++state2.position); + if (ch === 43 || ch === 45) { + if (CHOMPING_CLIP === chomping) { + chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state2, "repeat of a chomping mode identifier"); + } + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state2, "bad explicit indentation width of a block scalar; it cannot be less than one"); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state2, "repeat of an indentation width identifier"); + } + } else { + break; + } + } + if (is_WHITE_SPACE(ch)) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (is_WHITE_SPACE(ch)); + if (ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (!is_EOL(ch) && ch !== 0); + } + } + while (ch !== 0) { + readLineBreak(state2); + state2.lineIndent = 0; + ch = state2.input.charCodeAt(state2.position); + while ((!detectedIndent || state2.lineIndent < textIndent) && ch === 32) { + state2.lineIndent++; + ch = state2.input.charCodeAt(++state2.position); + } + if (!detectedIndent && state2.lineIndent > textIndent) { + textIndent = state2.lineIndent; + } + if (is_EOL(ch)) { + emptyLines++; + continue; + } + if (state2.lineIndent < textIndent) { + if (chomping === CHOMPING_KEEP) { + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { + state2.result += "\n"; + } + } + break; + } + if (folding) { + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } else if (atMoreIndented) { + atMoreIndented = false; + state2.result += common.repeat("\n", emptyLines + 1); + } else if (emptyLines === 0) { + if (didReadContent) { + state2.result += " "; + } + } else { + state2.result += common.repeat("\n", emptyLines); + } + } else { + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state2.position; + while (!is_EOL(ch) && ch !== 0) { + ch = state2.input.charCodeAt(++state2.position); + } + captureSegment(state2, captureStart, state2.position, false); + } + return true; +} +function readBlockSequence(state2, nodeIndent) { + var _line, _tag = state2.tag, _anchor = state2.anchor, _result = [], following, detected = false, ch; + if (state2.firstTabInLine !== -1) + return false; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + if (state2.firstTabInLine !== -1) { + state2.position = state2.firstTabInLine; + throwError(state2, "tab characters must not be used in indentation"); + } + if (ch !== 45) { + break; + } + following = state2.input.charCodeAt(state2.position + 1); + if (!is_WS_OR_EOL(following)) { + break; + } + detected = true; + state2.position++; + if (skipSeparationSpace(state2, true, -1)) { + if (state2.lineIndent <= nodeIndent) { + _result.push(null); + ch = state2.input.charCodeAt(state2.position); + continue; + } + } + _line = state2.line; + composeNode(state2, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state2.result); + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + if ((state2.line === _line || state2.lineIndent > nodeIndent) && ch !== 0) { + throwError(state2, "bad indentation of a sequence entry"); + } else if (state2.lineIndent < nodeIndent) { + break; + } + } + if (detected) { + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = "sequence"; + state2.result = _result; + return true; + } + return false; +} +function readBlockMapping(state2, nodeIndent, flowIndent) { + var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state2.tag, _anchor = state2.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch; + if (state2.firstTabInLine !== -1) + return false; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + if (!atExplicitKey && state2.firstTabInLine !== -1) { + state2.position = state2.firstTabInLine; + throwError(state2, "tab characters must not be used in indentation"); + } + following = state2.input.charCodeAt(state2.position + 1); + _line = state2.line; + if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) { + if (ch === 63) { + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + detected = true; + atExplicitKey = true; + allowCompact = true; + } else if (atExplicitKey) { + atExplicitKey = false; + allowCompact = true; + } else { + throwError(state2, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"); + } + state2.position += 1; + ch = following; + } else { + _keyLine = state2.line; + _keyLineStart = state2.lineStart; + _keyPos = state2.position; + if (!composeNode(state2, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + break; + } + if (state2.line === _line) { + ch = state2.input.charCodeAt(state2.position); + while (is_WHITE_SPACE(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (ch === 58) { + ch = state2.input.charCodeAt(++state2.position); + if (!is_WS_OR_EOL(ch)) { + throwError(state2, "a whitespace character is expected after the key-value separator within a block mapping"); + } + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state2.tag; + keyNode = state2.result; + } else if (detected) { + throwError(state2, "can not read an implicit mapping pair; a colon is missed"); + } else { + state2.tag = _tag; + state2.anchor = _anchor; + return true; + } + } else if (detected) { + throwError(state2, "can not read a block mapping entry; a multiline key may not be an implicit key"); + } else { + state2.tag = _tag; + state2.anchor = _anchor; + return true; + } + } + if (state2.line === _line || state2.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state2.line; + _keyLineStart = state2.lineStart; + _keyPos = state2.position; + } + if (composeNode(state2, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state2.result; + } else { + valueNode = state2.result; + } + } + if (!atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + } + if ((state2.line === _line || state2.lineIndent > nodeIndent) && ch !== 0) { + throwError(state2, "bad indentation of a mapping entry"); + } else if (state2.lineIndent < nodeIndent) { + break; + } + } + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + if (detected) { + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = "mapping"; + state2.result = _result; + } + return detected; +} +function readTagProperty(state2) { + var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 33) + return false; + if (state2.tag !== null) { + throwError(state2, "duplication of a tag property"); + } + ch = state2.input.charCodeAt(++state2.position); + if (ch === 60) { + isVerbatim = true; + ch = state2.input.charCodeAt(++state2.position); + } else if (ch === 33) { + isNamed = true; + tagHandle = "!!"; + ch = state2.input.charCodeAt(++state2.position); + } else { + tagHandle = "!"; + } + _position = state2.position; + if (isVerbatim) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 0 && ch !== 62); + if (state2.position < state2.length) { + tagName = state2.input.slice(_position, state2.position); + ch = state2.input.charCodeAt(++state2.position); + } else { + throwError(state2, "unexpected end of the stream within a verbatim tag"); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + if (ch === 33) { + if (!isNamed) { + tagHandle = state2.input.slice(_position - 1, state2.position + 1); + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state2, "named tag handle cannot contain such characters"); + } + isNamed = true; + _position = state2.position + 1; + } else { + throwError(state2, "tag suffix cannot contain exclamation marks"); + } + } + ch = state2.input.charCodeAt(++state2.position); + } + tagName = state2.input.slice(_position, state2.position); + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state2, "tag suffix cannot contain flow indicator characters"); + } + } + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state2, "tag name cannot contain such characters: " + tagName); + } + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state2, "tag name is malformed: " + tagName); + } + if (isVerbatim) { + state2.tag = tagName; + } else if (_hasOwnProperty$1.call(state2.tagMap, tagHandle)) { + state2.tag = state2.tagMap[tagHandle] + tagName; + } else if (tagHandle === "!") { + state2.tag = "!" + tagName; + } else if (tagHandle === "!!") { + state2.tag = "tag:yaml.org,2002:" + tagName; + } else { + throwError(state2, 'undeclared tag handle "' + tagHandle + '"'); + } + return true; +} +function readAnchorProperty(state2) { + var _position, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 38) + return false; + if (state2.anchor !== null) { + throwError(state2, "duplication of an anchor property"); + } + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (state2.position === _position) { + throwError(state2, "name of an anchor node must contain at least one character"); + } + state2.anchor = state2.input.slice(_position, state2.position); + return true; +} +function readAlias(state2) { + var _position, alias, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 42) + return false; + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (state2.position === _position) { + throwError(state2, "name of an alias node must contain at least one character"); + } + alias = state2.input.slice(_position, state2.position); + if (!_hasOwnProperty$1.call(state2.anchorMap, alias)) { + throwError(state2, 'unidentified alias "' + alias + '"'); + } + state2.result = state2.anchorMap[alias]; + skipSeparationSpace(state2, true, -1); + return true; +} +function composeNode(state2, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent; + if (state2.listener !== null) { + state2.listener("open", state2); + } + state2.tag = null; + state2.anchor = null; + state2.kind = null; + state2.result = null; + allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext; + if (allowToSeek) { + if (skipSeparationSpace(state2, true, -1)) { + atNewLine = true; + if (state2.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state2.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state2.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + if (indentStatus === 1) { + while (readTagProperty(state2) || readAnchorProperty(state2)) { + if (skipSeparationSpace(state2, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + if (state2.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state2.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state2.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + blockIndent = state2.position - state2.lineStart; + if (indentStatus === 1) { + if (allowBlockCollections && (readBlockSequence(state2, blockIndent) || readBlockMapping(state2, blockIndent, flowIndent)) || readFlowCollection(state2, flowIndent)) { + hasContent = true; + } else { + if (allowBlockScalars && readBlockScalar(state2, flowIndent) || readSingleQuotedScalar(state2, flowIndent) || readDoubleQuotedScalar(state2, flowIndent)) { + hasContent = true; + } else if (readAlias(state2)) { + hasContent = true; + if (state2.tag !== null || state2.anchor !== null) { + throwError(state2, "alias node should not have any properties"); + } + } else if (readPlainScalar(state2, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + if (state2.tag === null) { + state2.tag = "?"; + } + } + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } + } else if (indentStatus === 0) { + hasContent = allowBlockCollections && readBlockSequence(state2, blockIndent); + } + } + if (state2.tag === null) { + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } else if (state2.tag === "?") { + if (state2.result !== null && state2.kind !== "scalar") { + throwError(state2, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state2.kind + '"'); + } + for (typeIndex = 0, typeQuantity = state2.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type2 = state2.implicitTypes[typeIndex]; + if (type2.resolve(state2.result)) { + state2.result = type2.construct(state2.result); + state2.tag = type2.tag; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + break; + } + } + } else if (state2.tag !== "!") { + if (_hasOwnProperty$1.call(state2.typeMap[state2.kind || "fallback"], state2.tag)) { + type2 = state2.typeMap[state2.kind || "fallback"][state2.tag]; + } else { + type2 = null; + typeList = state2.typeMap.multi[state2.kind || "fallback"]; + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state2.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type2 = typeList[typeIndex]; + break; + } + } + } + if (!type2) { + throwError(state2, "unknown tag !<" + state2.tag + ">"); + } + if (state2.result !== null && type2.kind !== state2.kind) { + throwError(state2, "unacceptable node kind for !<" + state2.tag + '> tag; it should be "' + type2.kind + '", not "' + state2.kind + '"'); + } + if (!type2.resolve(state2.result, state2.tag)) { + throwError(state2, "cannot resolve a node with !<" + state2.tag + "> explicit tag"); + } else { + state2.result = type2.construct(state2.result, state2.tag); + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } + } + if (state2.listener !== null) { + state2.listener("close", state2); + } + return state2.tag !== null || state2.anchor !== null || hasContent; +} +function readDocument(state2) { + var documentStart = state2.position, _position, directiveName, directiveArgs, hasDirectives = false, ch; + state2.version = null; + state2.checkLineBreaks = state2.legacy; + state2.tagMap = /* @__PURE__ */ Object.create(null); + state2.anchorMap = /* @__PURE__ */ Object.create(null); + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + if (state2.lineIndent > 0 || ch !== 37) { + break; + } + hasDirectives = true; + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + directiveName = state2.input.slice(_position, state2.position); + directiveArgs = []; + if (directiveName.length < 1) { + throwError(state2, "directive name must not be less than one character in length"); + } + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 0 && !is_EOL(ch)); + break; + } + if (is_EOL(ch)) + break; + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + directiveArgs.push(state2.input.slice(_position, state2.position)); + } + if (ch !== 0) + readLineBreak(state2); + if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state2, directiveName, directiveArgs); + } else { + throwWarning(state2, 'unknown document directive "' + directiveName + '"'); + } + } + skipSeparationSpace(state2, true, -1); + if (state2.lineIndent === 0 && state2.input.charCodeAt(state2.position) === 45 && state2.input.charCodeAt(state2.position + 1) === 45 && state2.input.charCodeAt(state2.position + 2) === 45) { + state2.position += 3; + skipSeparationSpace(state2, true, -1); + } else if (hasDirectives) { + throwError(state2, "directives end mark is expected"); + } + composeNode(state2, state2.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state2, true, -1); + if (state2.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state2.input.slice(documentStart, state2.position))) { + throwWarning(state2, "non-ASCII line breaks are interpreted as content"); + } + state2.documents.push(state2.result); + if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + if (state2.input.charCodeAt(state2.position) === 46) { + state2.position += 3; + skipSeparationSpace(state2, true, -1); + } + return; + } + if (state2.position < state2.length - 1) { + throwError(state2, "end of the stream or a document separator is expected"); + } else { + return; + } +} +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + if (input.length !== 0) { + if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) { + input += "\n"; + } + if (input.charCodeAt(0) === 65279) { + input = input.slice(1); + } + } + var state2 = new State$1(input, options); + var nullpos = input.indexOf("\0"); + if (nullpos !== -1) { + state2.position = nullpos; + throwError(state2, "null byte is not allowed in input"); + } + state2.input += "\0"; + while (state2.input.charCodeAt(state2.position) === 32) { + state2.lineIndent += 1; + state2.position += 1; + } + while (state2.position < state2.length - 1) { + readDocument(state2); + } + return state2.documents; +} +function loadAll$1(input, iterator, options) { + if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") { + options = iterator; + iterator = null; + } + var documents = loadDocuments(input, options); + if (typeof iterator !== "function") { + return documents; + } + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} +function load$1(input, options) { + var documents = loadDocuments(input, options); + if (documents.length === 0) { + return void 0; + } else if (documents.length === 1) { + return documents[0]; + } + throw new exception("expected a single document in the stream, but found more"); +} +var loadAll_1 = loadAll$1; +var load_1 = load$1; +var loader = { + loadAll: loadAll_1, + load: load_1 +}; +var JSON_SCHEMA = json; +var load = loader.load; +function extractFrontMatter(text) { + const matches = text.match(frontMatterRegex); + if (!matches) { + return { + text, + metadata: {} + }; + } + let parsed = load(matches[1], { + // To support config, we need JSON schema. + // https://www.yaml.org/spec/1.2/spec.html#id2803231 + schema: JSON_SCHEMA + }) ?? {}; + parsed = typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}; + const metadata = {}; + if (parsed.displayMode) { + metadata.displayMode = parsed.displayMode.toString(); + } + if (parsed.title) { + metadata.title = parsed.title.toString(); + } + if (parsed.config) { + metadata.config = parsed.config; + } + return { + text: text.slice(matches[0].length), + metadata + }; +} +const cleanupText = (code) => { + return code.replace(/\r\n?/g, "\n").replace( + /<(\w+)([^>]*)>/g, + (match, tag, attributes) => "<" + tag + attributes.replace(/="([^"]*)"/g, "='$1'") + ">" + ); +}; +const processFrontmatter = (code) => { + const { text, metadata } = extractFrontMatter(code); + const { displayMode, title, config: config2 = {} } = metadata; + if (displayMode) { + if (!config2.gantt) { + config2.gantt = {}; + } + config2.gantt.displayMode = displayMode; + } + return { title, config: config2, text }; +}; +const processDirectives = (code) => { + const initDirective = utils.detectInit(code) ?? {}; + const wrapDirectives = utils.detectDirective(code, "wrap"); + if (Array.isArray(wrapDirectives)) { + initDirective.wrap = wrapDirectives.some(({ type: type2 }) => { + }); + } else if ((wrapDirectives == null ? void 0 : wrapDirectives.type) === "wrap") { + initDirective.wrap = true; + } + return { + text: removeDirectives(code), + directive: initDirective + }; +}; +function preprocessDiagram(code) { + const cleanedCode = cleanupText(code); + const frontMatterResult = processFrontmatter(cleanedCode); + const directiveResult = processDirectives(frontMatterResult.text); + const config2 = cleanAndMerge(frontMatterResult.config, directiveResult.directive); + code = cleanupComments(directiveResult.text); + return { + code, + title: frontMatterResult.title, + config: config2 + }; +} +const MAX_TEXTLENGTH = 5e4; +const MAX_TEXTLENGTH_EXCEEDED_MSG = "graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa"; +const SECURITY_LVL_SANDBOX = "sandbox"; +const SECURITY_LVL_LOOSE = "loose"; +const XMLNS_SVG_STD = "http://www.w3.org/2000/svg"; +const XMLNS_XLINK_STD = "http://www.w3.org/1999/xlink"; +const XMLNS_XHTML_STD = "http://www.w3.org/1999/xhtml"; +const IFRAME_WIDTH = "100%"; +const IFRAME_HEIGHT = "100%"; +const IFRAME_STYLES = "border:0;margin:0;"; +const IFRAME_BODY_STYLE = "margin:0"; +const IFRAME_SANDBOX_OPTS = "allow-top-navigation-by-user-activation allow-popups"; +const IFRAME_NOT_SUPPORTED_MSG = 'The "iframe" tag is not supported by your browser.'; +const DOMPURIFY_TAGS = ["foreignobject"]; +const DOMPURIFY_ATTR = ["dominant-baseline"]; +function processAndSetConfigs(text) { + const processed = preprocessDiagram(text); + reset(); + addDirective(processed.config ?? {}); + return processed; +} +async function parse$1(text, parseOptions) { + addDiagrams(); + text = processAndSetConfigs(text).code; + try { + await getDiagramFromText(text); + } catch (error) { + if (parseOptions == null ? void 0 : parseOptions.suppressErrors) { + return false; + } + throw error; + } + return true; +} +const cssImportantStyles = (cssClass, element, cssClasses = []) => { + return ` +.${cssClass} ${element} { ${cssClasses.join(" !important; ")} !important; }`; +}; +const createCssStyles = (config2, classDefs = {}) => { + var _a; + let cssStyles = ""; + if (config2.themeCSS !== void 0) { + cssStyles += ` +${config2.themeCSS}`; + } + if (config2.fontFamily !== void 0) { + cssStyles += ` +:root { --mermaid-font-family: ${config2.fontFamily}}`; + } + if (config2.altFontFamily !== void 0) { + cssStyles += ` +:root { --mermaid-alt-font-family: ${config2.altFontFamily}}`; + } + if (!isEmpty(classDefs)) { + const htmlLabels = config2.htmlLabels || ((_a = config2.flowchart) == null ? void 0 : _a.htmlLabels); + const cssHtmlElements = ["> *", "span"]; + const cssShapeElements = ["rect", "polygon", "ellipse", "circle", "path"]; + const cssElements = htmlLabels ? cssHtmlElements : cssShapeElements; + for (const classId in classDefs) { + const styleClassDef = classDefs[classId]; + if (!isEmpty(styleClassDef.styles)) { + cssElements.forEach((cssElement) => { + cssStyles += cssImportantStyles(styleClassDef.id, cssElement, styleClassDef.styles); + }); + } + if (!isEmpty(styleClassDef.textStyles)) { + cssStyles += cssImportantStyles(styleClassDef.id, "tspan", styleClassDef.textStyles); + } + } + } + return cssStyles; +}; +const createUserStyles = (config2, graphType, classDefs, svgId) => { + const userCSSstyles = createCssStyles(config2, classDefs); + const allStyles = getStyles$1(graphType, userCSSstyles, config2.themeVariables); + return serialize(compile(`${svgId}{${allStyles}}`), stringify); +}; +const cleanUpSvgCode = (svgCode = "", inSandboxMode, useArrowMarkerUrls) => { + let cleanedUpSvg = svgCode; + if (!useArrowMarkerUrls && !inSandboxMode) { + cleanedUpSvg = cleanedUpSvg.replace( + /marker-end="url\([\d+./:=?A-Za-z-]*?#/g, + 'marker-end="url(#' + ); + } + cleanedUpSvg = decodeEntities(cleanedUpSvg); + cleanedUpSvg = cleanedUpSvg.replace(/
    /g, "
    "); + return cleanedUpSvg; +}; +const putIntoIFrame = (svgCode = "", svgElement) => { + var _a, _b; + const height = ((_b = (_a = svgElement == null ? void 0 : svgElement.viewBox) == null ? void 0 : _a.baseVal) == null ? void 0 : _b.height) ? svgElement.viewBox.baseVal.height + "px" : IFRAME_HEIGHT; + const base64encodedSrc = btoa('' + svgCode + ""); + return ``; +}; +const appendDivSvgG = (parentRoot, id2, enclosingDivId, divStyle, svgXlink) => { + const enclosingDiv = parentRoot.append("div"); + enclosingDiv.attr("id", enclosingDivId); + if (divStyle) { + enclosingDiv.attr("style", divStyle); + } + const svgNode = enclosingDiv.append("svg").attr("id", id2).attr("width", "100%").attr("xmlns", XMLNS_SVG_STD); + if (svgXlink) { + svgNode.attr("xmlns:xlink", svgXlink); + } + svgNode.append("g"); + return parentRoot; +}; +function sandboxedIframe(parentNode, iFrameId) { + return parentNode.append("iframe").attr("id", iFrameId).attr("style", "width: 100%; height: 100%;").attr("sandbox", ""); +} +const removeExistingElements = (doc, id2, divId, iFrameId) => { + var _a, _b, _c; + (_a = doc.getElementById(id2)) == null ? void 0 : _a.remove(); + (_b = doc.getElementById(divId)) == null ? void 0 : _b.remove(); + (_c = doc.getElementById(iFrameId)) == null ? void 0 : _c.remove(); +}; +const render$1 = async function(id2, text, svgContainingElement) { + var _a, _b, _c, _d, _e, _f; + addDiagrams(); + const processed = processAndSetConfigs(text); + text = processed.code; + const config2 = getConfig$1(); + log$1.debug(config2); + if (text.length > ((config2 == null ? void 0 : config2.maxTextSize) ?? MAX_TEXTLENGTH)) { + text = MAX_TEXTLENGTH_EXCEEDED_MSG; + } + const idSelector = "#" + id2; + const iFrameID = "i" + id2; + const iFrameID_selector = "#" + iFrameID; + const enclosingDivID = "d" + id2; + const enclosingDivID_selector = "#" + enclosingDivID; + let root = select("body"); + const isSandboxed = config2.securityLevel === SECURITY_LVL_SANDBOX; + const isLooseSecurityLevel = config2.securityLevel === SECURITY_LVL_LOOSE; + const fontFamily = config2.fontFamily; + if (svgContainingElement !== void 0) { + if (svgContainingElement) { + svgContainingElement.innerHTML = ""; + } + if (isSandboxed) { + const iframe = sandboxedIframe(select(svgContainingElement), iFrameID); + root = select(iframe.nodes()[0].contentDocument.body); + root.node().style.margin = 0; + } else { + root = select(svgContainingElement); + } + appendDivSvgG(root, id2, enclosingDivID, `font-family: ${fontFamily}`, XMLNS_XLINK_STD); + } else { + removeExistingElements(document, id2, enclosingDivID, iFrameID); + if (isSandboxed) { + const iframe = sandboxedIframe(select("body"), iFrameID); + root = select(iframe.nodes()[0].contentDocument.body); + root.node().style.margin = 0; + } else { + root = select("body"); + } + appendDivSvgG(root, id2, enclosingDivID); + } + let diag; + let parseEncounteredException; + try { + diag = await getDiagramFromText(text, { title: processed.title }); + } catch (error) { + diag = new Diagram("error"); + parseEncounteredException = error; + } + const element = root.select(enclosingDivID_selector).node(); + const diagramType = diag.type; + const svg = element.firstChild; + const firstChild = svg.firstChild; + const diagramClassDefs = (_b = (_a = diag.renderer).getClasses) == null ? void 0 : _b.call(_a, text, diag); + const rules = createUserStyles(config2, diagramType, diagramClassDefs, idSelector); + const style1 = document.createElement("style"); + style1.innerHTML = rules; + svg.insertBefore(style1, firstChild); + try { + await diag.renderer.draw(text, id2, version, diag); + } catch (e) { + errorRenderer.draw(text, id2, version); + throw e; + } + const svgNode = root.select(`${enclosingDivID_selector} svg`); + const a11yTitle = (_d = (_c = diag.db).getAccTitle) == null ? void 0 : _d.call(_c); + const a11yDescr = (_f = (_e = diag.db).getAccDescription) == null ? void 0 : _f.call(_e); + addA11yInfo(diagramType, svgNode, a11yTitle, a11yDescr); + root.select(`[id="${id2}"]`).selectAll("foreignobject > *").attr("xmlns", XMLNS_XHTML_STD); + let svgCode = root.select(enclosingDivID_selector).node().innerHTML; + log$1.debug("config.arrowMarkerAbsolute", config2.arrowMarkerAbsolute); + svgCode = cleanUpSvgCode(svgCode, isSandboxed, evaluate(config2.arrowMarkerAbsolute)); + if (isSandboxed) { + const svgEl = root.select(enclosingDivID_selector + " svg").node(); + svgCode = putIntoIFrame(svgCode, svgEl); + } else if (!isLooseSecurityLevel) { + svgCode = purify.sanitize(svgCode, { + ADD_TAGS: DOMPURIFY_TAGS, + ADD_ATTR: DOMPURIFY_ATTR + }); + } + attachFunctions(); + if (parseEncounteredException) { + throw parseEncounteredException; + } + const tmpElementSelector = isSandboxed ? iFrameID_selector : enclosingDivID_selector; + const node = select(tmpElementSelector).node(); + if (node && "remove" in node) { + node.remove(); + } + return { + svg: svgCode, + bindFunctions: diag.db.bindFunctions + }; +}; +function initialize$1(options = {}) { + var _a; + if ((options == null ? void 0 : options.fontFamily) && !((_a = options.themeVariables) == null ? void 0 : _a.fontFamily)) { + if (!options.themeVariables) { + options.themeVariables = {}; + } + options.themeVariables.fontFamily = options.fontFamily; + } + saveConfigFromInitialize(options); + if ((options == null ? void 0 : options.theme) && options.theme in theme) { + options.themeVariables = theme[options.theme].getThemeVariables( + options.themeVariables + ); + } else if (options) { + options.themeVariables = theme.default.getThemeVariables(options.themeVariables); + } + const config2 = typeof options === "object" ? setSiteConfig(options) : getSiteConfig(); + setLogLevel$1(config2.logLevel); + addDiagrams(); +} +const getDiagramFromText = (text, metadata = {}) => { + const { code } = preprocessDiagram(text); + return getDiagramFromText$1(code, metadata); +}; +function addA11yInfo(diagramType, svgNode, a11yTitle, a11yDescr) { + setA11yDiagramInfo(svgNode, diagramType); + addSVGa11yTitleDescription(svgNode, a11yTitle, a11yDescr, svgNode.attr("id")); +} +const mermaidAPI = Object.freeze({ + render: render$1, + parse: parse$1, + getDiagramFromText, + initialize: initialize$1, + getConfig: getConfig$1, + setConfig: setConfig$1, + getSiteConfig, + updateSiteConfig, + reset: () => { + reset(); + }, + globalReset: () => { + reset(defaultConfig$1); + }, + defaultConfig: defaultConfig$1 +}); +setLogLevel$1(getConfig$1().logLevel); +reset(getConfig$1()); +const loadRegisteredDiagrams = async () => { + log$1.debug(`Loading registered diagrams`); + const results = await Promise.allSettled( + Object.entries(detectors).map(async ([key, { detector: detector2, loader: loader2 }]) => { + if (loader2) { + try { + getDiagram(key); + } catch (error) { + try { + const { diagram: diagram2, id: id2 } = await loader2(); + registerDiagram(id2, diagram2, detector2); + } catch (err) { + log$1.error(`Failed to load external diagram with key ${key}. Removing from detectors.`); + delete detectors[key]; + throw err; + } + } + } + }) + ); + const failed = results.filter((result) => result.status === "rejected"); + if (failed.length > 0) { + log$1.error(`Failed to load ${failed.length} external diagrams`); + for (const res of failed) { + log$1.error(res); + } + throw new Error(`Failed to load ${failed.length} external diagrams`); + } +}; +const handleError = (error, errors, parseError) => { + log$1.warn(error); + if (isDetailedError(error)) { + if (parseError) { + parseError(error.str, error.hash); + } + errors.push({ ...error, message: error.str, error }); + } else { + if (parseError) { + parseError(error); + } + if (error instanceof Error) { + errors.push({ + str: error.message, + message: error.message, + hash: error.name, + error + }); + } + } +}; +const run = async function(options = { + querySelector: ".mermaid" +}) { + try { + await runThrowsErrors(options); + } catch (e) { + if (isDetailedError(e)) { + log$1.error(e.str); + } + if (mermaid.parseError) { + mermaid.parseError(e); + } + if (!options.suppressErrors) { + log$1.error("Use the suppressErrors option to suppress these errors"); + throw e; + } + } +}; +const runThrowsErrors = async function({ postRenderCallback, querySelector, nodes } = { + querySelector: ".mermaid" +}) { + const conf = mermaidAPI.getConfig(); + log$1.debug(`${!postRenderCallback ? "No " : ""}Callback function found`); + let nodesToProcess; + if (nodes) { + nodesToProcess = nodes; + } else if (querySelector) { + nodesToProcess = document.querySelectorAll(querySelector); + } else { + throw new Error("Nodes and querySelector are both undefined"); + } + log$1.debug(`Found ${nodesToProcess.length} diagrams`); + if ((conf == null ? void 0 : conf.startOnLoad) !== void 0) { + log$1.debug("Start On Load: " + (conf == null ? void 0 : conf.startOnLoad)); + mermaidAPI.updateSiteConfig({ startOnLoad: conf == null ? void 0 : conf.startOnLoad }); + } + const idGenerator = new utils.InitIDGenerator(conf.deterministicIds, conf.deterministicIDSeed); + let txt; + const errors = []; + for (const element of Array.from(nodesToProcess)) { + log$1.info("Rendering diagram: " + element.id); + /*! Check if previously processed */ + if (element.getAttribute("data-processed")) { + continue; + } + element.setAttribute("data-processed", "true"); + const id2 = `mermaid-${idGenerator.next()}`; + txt = element.innerHTML; + txt = dedent(utils.entityDecode(txt)).trim().replace(//gi, "
    "); + const init2 = utils.detectInit(txt); + if (init2) { + log$1.debug("Detected early reinit: ", init2); + } + try { + const { svg, bindFunctions } = await render(id2, txt, element); + element.innerHTML = svg; + if (postRenderCallback) { + await postRenderCallback(id2); + } + if (bindFunctions) { + bindFunctions(element); + } + } catch (error) { + handleError(error, errors, mermaid.parseError); + } + } + if (errors.length > 0) { + throw errors[0]; + } +}; +const initialize = function(config2) { + mermaidAPI.initialize(config2); +}; +const init = async function(config2, nodes, callback) { + log$1.warn("mermaid.init is deprecated. Please use run instead."); + if (config2) { + initialize(config2); + } + const runOptions = { postRenderCallback: callback, querySelector: ".mermaid" }; + if (typeof nodes === "string") { + runOptions.querySelector = nodes; + } else if (nodes) { + if (nodes instanceof HTMLElement) { + runOptions.nodes = [nodes]; + } else { + runOptions.nodes = nodes; + } + } + await run(runOptions); +}; +const registerExternalDiagrams = async (diagrams2, { + lazyLoad = true +} = {}) => { + registerLazyLoadedDiagrams(...diagrams2); + if (lazyLoad === false) { + await loadRegisteredDiagrams(); + } +}; +const contentLoaded = function() { + if (mermaid.startOnLoad) { + const { startOnLoad } = mermaidAPI.getConfig(); + if (startOnLoad) { + mermaid.run().catch((err) => log$1.error("Mermaid failed to initialize", err)); + } + } +}; +if (typeof document !== "undefined") { + /*! + * Wait for document loaded before starting the execution + */ + window.addEventListener("load", contentLoaded, false); +} +const setParseErrorHandler = function(parseErrorHandler) { + mermaid.parseError = parseErrorHandler; +}; +const executionQueue = []; +let executionQueueRunning = false; +const executeQueue = async () => { + if (executionQueueRunning) { + return; + } + executionQueueRunning = true; + while (executionQueue.length > 0) { + const f = executionQueue.shift(); + if (f) { + try { + await f(); + } catch (e) { + log$1.error("Error executing queue", e); + } + } + } + executionQueueRunning = false; +}; +const parse = async (text, parseOptions) => { + return new Promise((resolve, reject) => { + const performCall = () => new Promise((res, rej) => { + mermaidAPI.parse(text, parseOptions).then( + (r) => { + res(r); + resolve(r); + }, + (e) => { + var _a; + log$1.error("Error parsing", e); + (_a = mermaid.parseError) == null ? void 0 : _a.call(mermaid, e); + rej(e); + reject(e); + } + ); + }); + executionQueue.push(performCall); + executeQueue().catch(reject); + }); +}; +const render = (id2, text, container) => { + return new Promise((resolve, reject) => { + const performCall = () => new Promise((res, rej) => { + mermaidAPI.render(id2, text, container).then( + (r) => { + res(r); + resolve(r); + }, + (e) => { + var _a; + log$1.error("Error parsing", e); + (_a = mermaid.parseError) == null ? void 0 : _a.call(mermaid, e); + rej(e); + reject(e); + } + ); + }); + executionQueue.push(performCall); + executeQueue().catch(reject); + }); +}; +const mermaid = { + startOnLoad: true, + mermaidAPI, + parse, + render, + init, + run, + registerExternalDiagrams, + initialize, + parseError: void 0, + contentLoaded, + setParseErrorHandler, + detectType +}; + +/** + * https://mermaid.js.org/config/usage.html + */ +mermaid.initialize({ startOnLoad: true }); +function parseMermaidHtml(el) { + return new Promise(function (resolve) { + var nodes = el.querySelectorAll('pre.mermaid'); + resolve(mermaid.run({ + nodes: nodes, + })); + }); +} + +var index = { + md2Html: md2Html, + parseMermaidHtml: parseMermaidHtml, +}; + +export { constant$1 as $, utils as A, rgba as B, setDiagramTitle as C, getDiagramTitle as D, clear as E, curveBasis as F, parseGenericTypes as G, setupGraphViewbox as H, random as I, define as J, extend$1 as K, Color$1 as L, rgbConvert as M, nogamma as N, hue as O, commonjsGlobal as P, getDefaultExportFromCjs as Q, Rgb as R, Selection$1 as S, dayjs as T, selectSvgElement as U, tau as V, defaultConfig$2 as W, cleanAndMerge as X, parseFontSize as Y, getThemeVariables$2 as Z, getConfig$1 as _, getAccDescription as a, MapCache as a$, interpolateNumber as a0, color as a1, interpolateRgb as a2, interpolateString as a3, hasKatex as a4, calculateMathMLDimensions as a5, ZERO_WIDTH_SPACE as a6, generateId as a7, isObject$1 as a8, setToString as a9, sqrt as aA, min as aB, abs$1 as aC, atan2 as aD, asin as aE, acos as aF, max as aG, Utils as aH, Color as aI, isObjectLike as aJ, baseGetTag as aK, Symbol$1 as aL, arrayLikeKeys as aM, baseKeys as aN, memoize as aO, isArguments as aP, copyObject as aQ, getPrototype as aR, cloneArrayBuffer as aS, cloneTypedArray as aT, getTag as aU, nodeUtil as aV, copyArray as aW, isBuffer as aX, cloneBuffer as aY, initCloneObject as aZ, Stack as a_, overRest as aa, baseRest as ab, isIterateeCall as ac, keysIn as ad, eq as ae, isArrayLike as af, isArray as ag, baseFor as ah, baseAssignValue as ai, identity as aj, isIndex as ak, assignValue as al, baseUnary as am, constant as an, merge$1 as ao, lineBreakRegex as ap, defaultConfig as aq, commonDb as ar, isDark as as, lighten as at, darken as au, pi as av, cos as aw, sin as ax, halfPi as ay, epsilon as az, setAccDescription as b, Uint8Array$1 as b0, isTypedArray as b1, isLength as b2, Set$1 as b3, isArrayLikeObject as b4, isEmpty as b5, decodeEntities as b6, dedent as b7, index as b8, getConfig as c, sanitizeText$2 as d, assignWithDepth$1 as e, calculateTextWidth as f, getAccTitle as g, select as h, configureSvgSize as i, common$1 as j, calculateTextHeight as k, log$1 as l, dist as m, curveLinear as n, getStylesFromArray as o, evaluate as p, interpolateToCurve as q, renderKatex as r, setAccTitle as s, setupGraphViewbox$1 as t, setConfig as u, root$1 as v, wrapLabel as w, array as x, isPlainObject as y, isFunction as z }; diff --git a/libs/marked/index.js b/libs/marked/index.js new file mode 100644 index 0000000..91a3226 --- /dev/null +++ b/libs/marked/index.js @@ -0,0 +1,137382 @@ +/** + * marked v12.0.2 - a markdown parser + * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ + +/** + * DO NOT EDIT THIS FILE + * The code in this file is generated from files in ./src/ + */ + +/** + * Gets the original marked default options. + */ +function _getDefaults() { + return { + async: false, + breaks: false, + extensions: null, + gfm: true, + hooks: null, + pedantic: false, + renderer: null, + silent: false, + tokenizer: null, + walkTokens: null + }; +} +let _defaults = _getDefaults(); +function changeDefaults(newDefaults) { + _defaults = newDefaults; +} + +/** + * Helpers + */ +const escapeTest = /[&<>"']/; +const escapeReplace = new RegExp(escapeTest.source, 'g'); +const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/; +const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g'); +const escapeReplacements = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; +const getEscapeReplacement = (ch) => escapeReplacements[ch]; +function escape$1$1(html, encode) { + if (encode) { + if (escapeTest.test(html)) { + return html.replace(escapeReplace, getEscapeReplacement); + } + } + else { + if (escapeTestNoEncode.test(html)) { + return html.replace(escapeReplaceNoEncode, getEscapeReplacement); + } + } + return html; +} +const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig; +function unescape$1(html) { + // explicitly match decimal, hex, and named HTML entities + return html.replace(unescapeTest, (_, n) => { + n = n.toLowerCase(); + if (n === 'colon') + return ':'; + if (n.charAt(0) === '#') { + return n.charAt(1) === 'x' + ? String.fromCharCode(parseInt(n.substring(2), 16)) + : String.fromCharCode(+n.substring(1)); + } + return ''; + }); +} +const caret$1 = /(^|[^\[])\^/g; +function edit(regex, opt) { + let source = typeof regex === 'string' ? regex : regex.source; + opt = opt || ''; + const obj = { + replace: (name, val) => { + let valSource = typeof val === 'string' ? val : val.source; + valSource = valSource.replace(caret$1, '$1'); + source = source.replace(name, valSource); + return obj; + }, + getRegex: () => { + return new RegExp(source, opt); + } + }; + return obj; +} +function cleanUrl(href) { + try { + href = encodeURI(href).replace(/%25/g, '%'); + } + catch (e) { + return null; + } + return href; +} +const noopTest = { exec: () => null }; +function splitCells$1(tableRow, count) { + // ensure that every cell-delimiting pipe has a space + // before it to distinguish it from an escaped pipe + const row = tableRow.replace(/\|/g, (match, offset, str) => { + let escaped = false; + let curr = offset; + while (--curr >= 0 && str[curr] === '\\') + escaped = !escaped; + if (escaped) { + // odd number of slashes means | is escaped + // so we leave it alone + return '|'; + } + else { + // add space before unescaped | + return ' |'; + } + }), cells = row.split(/ \|/); + let i = 0; + // First/last cell in a row cannot be empty if it has no leading/trailing pipe + if (!cells[0].trim()) { + cells.shift(); + } + if (cells.length > 0 && !cells[cells.length - 1].trim()) { + cells.pop(); + } + if (count) { + if (cells.length > count) { + cells.splice(count); + } + else { + while (cells.length < count) + cells.push(''); + } + } + for (; i < cells.length; i++) { + // leading or trailing whitespace is ignored per the gfm spec + cells[i] = cells[i].trim().replace(/\\\|/g, '|'); + } + return cells; +} +/** + * Remove trailing 'c's. Equivalent to str.replace(/c*$/, ''). + * /c*$/ is vulnerable to REDOS. + * + * @param str + * @param c + * @param invert Remove suffix of non-c chars instead. Default falsey. + */ +function rtrim(str, c, invert) { + const l = str.length; + if (l === 0) { + return ''; + } + // Length of suffix matching the invert condition. + let suffLen = 0; + // Step left until we fail to match the invert condition. + while (suffLen < l) { + const currChar = str.charAt(l - suffLen - 1); + if (currChar === c && !invert) { + suffLen++; + } + else if (currChar !== c && invert) { + suffLen++; + } + else { + break; + } + } + return str.slice(0, l - suffLen); +} +function findClosingBracket(str, b) { + if (str.indexOf(b[1]) === -1) { + return -1; + } + let level = 0; + for (let i = 0; i < str.length; i++) { + if (str[i] === '\\') { + i++; + } + else if (str[i] === b[0]) { + level++; + } + else if (str[i] === b[1]) { + level--; + if (level < 0) { + return i; + } + } + } + return -1; +} + +function outputLink(cap, link, raw, lexer) { + const href = link.href; + const title = link.title ? escape$1$1(link.title) : null; + const text = cap[1].replace(/\\([\[\]])/g, '$1'); + if (cap[0].charAt(0) !== '!') { + lexer.state.inLink = true; + const token = { + type: 'link', + raw, + href, + title, + text, + tokens: lexer.inlineTokens(text) + }; + lexer.state.inLink = false; + return token; + } + return { + type: 'image', + raw, + href, + title, + text: escape$1$1(text) + }; +} +function indentCodeCompensation(raw, text) { + const matchIndentToCode = raw.match(/^(\s+)(?:```)/); + if (matchIndentToCode === null) { + return text; + } + const indentToCode = matchIndentToCode[1]; + return text + .split('\n') + .map(node => { + const matchIndentInNode = node.match(/^\s+/); + if (matchIndentInNode === null) { + return node; + } + const [indentInNode] = matchIndentInNode; + if (indentInNode.length >= indentToCode.length) { + return node.slice(indentToCode.length); + } + return node; + }) + .join('\n'); +} +/** + * Tokenizer + */ +class _Tokenizer { + options; + rules; // set by the lexer + lexer; // set by the lexer + constructor(options) { + this.options = options || _defaults; + } + space(src) { + const cap = this.rules.block.newline.exec(src); + if (cap && cap[0].length > 0) { + return { + type: 'space', + raw: cap[0] + }; + } + } + code(src) { + const cap = this.rules.block.code.exec(src); + if (cap) { + const text = cap[0].replace(/^ {1,4}/gm, ''); + return { + type: 'code', + raw: cap[0], + codeBlockStyle: 'indented', + text: !this.options.pedantic + ? rtrim(text, '\n') + : text + }; + } + } + fences(src) { + const cap = this.rules.block.fences.exec(src); + if (cap) { + const raw = cap[0]; + const text = indentCodeCompensation(raw, cap[3] || ''); + return { + type: 'code', + raw, + lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, '$1') : cap[2], + text + }; + } + } + heading(src) { + const cap = this.rules.block.heading.exec(src); + if (cap) { + let text = cap[2].trim(); + // remove trailing #s + if (/#$/.test(text)) { + const trimmed = rtrim(text, '#'); + if (this.options.pedantic) { + text = trimmed.trim(); + } + else if (!trimmed || / $/.test(trimmed)) { + // CommonMark requires space before trailing #s + text = trimmed.trim(); + } + } + return { + type: 'heading', + raw: cap[0], + depth: cap[1].length, + text, + tokens: this.lexer.inline(text) + }; + } + } + hr(src) { + const cap = this.rules.block.hr.exec(src); + if (cap) { + return { + type: 'hr', + raw: cap[0] + }; + } + } + blockquote(src) { + const cap = this.rules.block.blockquote.exec(src); + if (cap) { + // precede setext continuation with 4 spaces so it isn't a setext + let text = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, '\n $1'); + text = rtrim(text.replace(/^ *>[ \t]?/gm, ''), '\n'); + const top = this.lexer.state.top; + this.lexer.state.top = true; + const tokens = this.lexer.blockTokens(text); + this.lexer.state.top = top; + return { + type: 'blockquote', + raw: cap[0], + tokens, + text + }; + } + } + list(src) { + let cap = this.rules.block.list.exec(src); + if (cap) { + let bull = cap[1].trim(); + const isordered = bull.length > 1; + const list = { + type: 'list', + raw: '', + ordered: isordered, + start: isordered ? +bull.slice(0, -1) : '', + loose: false, + items: [] + }; + bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`; + if (this.options.pedantic) { + bull = isordered ? bull : '[*+-]'; + } + // Get next list item + const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`); + let raw = ''; + let itemContents = ''; + let endsWithBlankLine = false; + // Check if current bullet point can start a new List Item + while (src) { + let endEarly = false; + if (!(cap = itemRegex.exec(src))) { + break; + } + if (this.rules.block.hr.test(src)) { // End list if bullet was actually HR (possibly move into itemRegex?) + break; + } + raw = cap[0]; + src = src.substring(raw.length); + let line = cap[2].split('\n', 1)[0].replace(/^\t+/, (t) => ' '.repeat(3 * t.length)); + let nextLine = src.split('\n', 1)[0]; + let indent = 0; + if (this.options.pedantic) { + indent = 2; + itemContents = line.trimStart(); + } + else { + indent = cap[2].search(/[^ ]/); // Find first non-space char + indent = indent > 4 ? 1 : indent; // Treat indented code blocks (> 4 spaces) as having only 1 indent + itemContents = line.slice(indent); + indent += cap[1].length; + } + let blankLine = false; + if (!line && /^ *$/.test(nextLine)) { // Items begin with at most one blank line + raw += nextLine + '\n'; + src = src.substring(nextLine.length + 1); + endEarly = true; + } + if (!endEarly) { + const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`); + const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`); + const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`); + const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`); + // Check if following lines should be included in List Item + while (src) { + const rawLine = src.split('\n', 1)[0]; + nextLine = rawLine; + // Re-align to follow commonmark nesting rules + if (this.options.pedantic) { + nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' '); + } + // End list item if found code fences + if (fencesBeginRegex.test(nextLine)) { + break; + } + // End list item if found start of new heading + if (headingBeginRegex.test(nextLine)) { + break; + } + // End list item if found start of new bullet + if (nextBulletRegex.test(nextLine)) { + break; + } + // Horizontal rule found + if (hrRegex.test(src)) { + break; + } + if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible + itemContents += '\n' + nextLine.slice(indent); + } + else { + // not enough indentation + if (blankLine) { + break; + } + // paragraph continuation unless last line was a different block level element + if (line.search(/[^ ]/) >= 4) { // indented code block + break; + } + if (fencesBeginRegex.test(line)) { + break; + } + if (headingBeginRegex.test(line)) { + break; + } + if (hrRegex.test(line)) { + break; + } + itemContents += '\n' + nextLine; + } + if (!blankLine && !nextLine.trim()) { // Check if current line is blank + blankLine = true; + } + raw += rawLine + '\n'; + src = src.substring(rawLine.length + 1); + line = nextLine.slice(indent); + } + } + if (!list.loose) { + // If the previous item ended with a blank line, the list is loose + if (endsWithBlankLine) { + list.loose = true; + } + else if (/\n *\n *$/.test(raw)) { + endsWithBlankLine = true; + } + } + let istask = null; + let ischecked; + // Check for task list items + if (this.options.gfm) { + istask = /^\[[ xX]\] /.exec(itemContents); + if (istask) { + ischecked = istask[0] !== '[ ] '; + itemContents = itemContents.replace(/^\[[ xX]\] +/, ''); + } + } + list.items.push({ + type: 'list_item', + raw, + task: !!istask, + checked: ischecked, + loose: false, + text: itemContents, + tokens: [] + }); + list.raw += raw; + } + // Do not consume newlines at end of final item. Alternatively, make itemRegex *start* with any newlines to simplify/speed up endsWithBlankLine logic + list.items[list.items.length - 1].raw = raw.trimEnd(); + (list.items[list.items.length - 1]).text = itemContents.trimEnd(); + list.raw = list.raw.trimEnd(); + // Item child tokens handled here at end because we needed to have the final item to trim it first + for (let i = 0; i < list.items.length; i++) { + this.lexer.state.top = false; + list.items[i].tokens = this.lexer.blockTokens(list.items[i].text, []); + if (!list.loose) { + // Check if list should be loose + const spacers = list.items[i].tokens.filter(t => t.type === 'space'); + const hasMultipleLineBreaks = spacers.length > 0 && spacers.some(t => /\n.*\n/.test(t.raw)); + list.loose = hasMultipleLineBreaks; + } + } + // Set all items to loose if list is loose + if (list.loose) { + for (let i = 0; i < list.items.length; i++) { + list.items[i].loose = true; + } + } + return list; + } + } + html(src) { + const cap = this.rules.block.html.exec(src); + if (cap) { + const token = { + type: 'html', + block: true, + raw: cap[0], + pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style', + text: cap[0] + }; + return token; + } + } + def(src) { + const cap = this.rules.block.def.exec(src); + if (cap) { + const tag = cap[1].toLowerCase().replace(/\s+/g, ' '); + const href = cap[2] ? cap[2].replace(/^<(.*)>$/, '$1').replace(this.rules.inline.anyPunctuation, '$1') : ''; + const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, '$1') : cap[3]; + return { + type: 'def', + tag, + raw: cap[0], + href, + title + }; + } + } + table(src) { + const cap = this.rules.block.table.exec(src); + if (!cap) { + return; + } + if (!/[:|]/.test(cap[2])) { + // delimiter row must have a pipe (|) or colon (:) otherwise it is a setext heading + return; + } + const headers = splitCells$1(cap[1]); + const aligns = cap[2].replace(/^\||\| *$/g, '').split('|'); + const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : []; + const item = { + type: 'table', + raw: cap[0], + header: [], + align: [], + rows: [] + }; + if (headers.length !== aligns.length) { + // header and align columns must be equal, rows can be different. + return; + } + for (const align of aligns) { + if (/^ *-+: *$/.test(align)) { + item.align.push('right'); + } + else if (/^ *:-+: *$/.test(align)) { + item.align.push('center'); + } + else if (/^ *:-+ *$/.test(align)) { + item.align.push('left'); + } + else { + item.align.push(null); + } + } + for (const header of headers) { + item.header.push({ + text: header, + tokens: this.lexer.inline(header) + }); + } + for (const row of rows) { + item.rows.push(splitCells$1(row, item.header.length).map(cell => { + return { + text: cell, + tokens: this.lexer.inline(cell) + }; + })); + } + return item; + } + lheading(src) { + const cap = this.rules.block.lheading.exec(src); + if (cap) { + return { + type: 'heading', + raw: cap[0], + depth: cap[2].charAt(0) === '=' ? 1 : 2, + text: cap[1], + tokens: this.lexer.inline(cap[1]) + }; + } + } + paragraph(src) { + const cap = this.rules.block.paragraph.exec(src); + if (cap) { + const text = cap[1].charAt(cap[1].length - 1) === '\n' + ? cap[1].slice(0, -1) + : cap[1]; + return { + type: 'paragraph', + raw: cap[0], + text, + tokens: this.lexer.inline(text) + }; + } + } + text(src) { + const cap = this.rules.block.text.exec(src); + if (cap) { + return { + type: 'text', + raw: cap[0], + text: cap[0], + tokens: this.lexer.inline(cap[0]) + }; + } + } + escape(src) { + const cap = this.rules.inline.escape.exec(src); + if (cap) { + return { + type: 'escape', + raw: cap[0], + text: escape$1$1(cap[1]) + }; + } + } + tag(src) { + const cap = this.rules.inline.tag.exec(src); + if (cap) { + if (!this.lexer.state.inLink && /^/i.test(cap[0])) { + this.lexer.state.inLink = false; + } + if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.lexer.state.inRawBlock = true; + } + else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { + this.lexer.state.inRawBlock = false; + } + return { + type: 'html', + raw: cap[0], + inLink: this.lexer.state.inLink, + inRawBlock: this.lexer.state.inRawBlock, + block: false, + text: cap[0] + }; + } + } + link(src) { + const cap = this.rules.inline.link.exec(src); + if (cap) { + const trimmedUrl = cap[2].trim(); + if (!this.options.pedantic && /^$/.test(trimmedUrl))) { + return; + } + // ending angle bracket cannot be escaped + const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), '\\'); + if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) { + return; + } + } + else { + // find closing parenthesis + const lastParenIndex = findClosingBracket(cap[2], '()'); + if (lastParenIndex > -1) { + const start = cap[0].indexOf('!') === 0 ? 5 : 4; + const linkLen = start + cap[1].length + lastParenIndex; + cap[2] = cap[2].substring(0, lastParenIndex); + cap[0] = cap[0].substring(0, linkLen).trim(); + cap[3] = ''; + } + } + let href = cap[2]; + let title = ''; + if (this.options.pedantic) { + // split pedantic href and title + const link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href); + if (link) { + href = link[1]; + title = link[3]; + } + } + else { + title = cap[3] ? cap[3].slice(1, -1) : ''; + } + href = href.trim(); + if (/^$/.test(trimmedUrl))) { + // pedantic allows starting angle bracket without ending angle bracket + href = href.slice(1); + } + else { + href = href.slice(1, -1); + } + } + return outputLink(cap, { + href: href ? href.replace(this.rules.inline.anyPunctuation, '$1') : href, + title: title ? title.replace(this.rules.inline.anyPunctuation, '$1') : title + }, cap[0], this.lexer); + } + } + reflink(src, links) { + let cap; + if ((cap = this.rules.inline.reflink.exec(src)) + || (cap = this.rules.inline.nolink.exec(src))) { + const linkString = (cap[2] || cap[1]).replace(/\s+/g, ' '); + const link = links[linkString.toLowerCase()]; + if (!link) { + const text = cap[0].charAt(0); + return { + type: 'text', + raw: text, + text + }; + } + return outputLink(cap, link, cap[0], this.lexer); + } + } + emStrong(src, maskedSrc, prevChar = '') { + let match = this.rules.inline.emStrongLDelim.exec(src); + if (!match) + return; + // _ can't be between two alphanumerics. \p{L}\p{N} includes non-english alphabet/numbers as well + if (match[3] && prevChar.match(/[\p{L}\p{N}]/u)) + return; + const nextChar = match[1] || match[2] || ''; + if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) { + // unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below) + const lLength = [...match[0]].length - 1; + let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0; + const endReg = match[0][0] === '*' ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd; + endReg.lastIndex = 0; + // Clip maskedSrc to same section of string as src (move to lexer?) + maskedSrc = maskedSrc.slice(-1 * src.length + lLength); + while ((match = endReg.exec(maskedSrc)) != null) { + rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6]; + if (!rDelim) + continue; // skip single * in __abc*abc__ + rLength = [...rDelim].length; + if (match[3] || match[4]) { // found another Left Delim + delimTotal += rLength; + continue; + } + else if (match[5] || match[6]) { // either Left or Right Delim + if (lLength % 3 && !((lLength + rLength) % 3)) { + midDelimTotal += rLength; + continue; // CommonMark Emphasis Rules 9-10 + } + } + delimTotal -= rLength; + if (delimTotal > 0) + continue; // Haven't found enough closing delimiters + // Remove extra characters. *a*** -> *a* + rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal); + // char length can be >1 for unicode characters; + const lastCharLength = [...match[0]][0].length; + const raw = src.slice(0, lLength + match.index + lastCharLength + rLength); + // Create `em` if smallest delimiter has odd char count. *a*** + if (Math.min(lLength, rLength) % 2) { + const text = raw.slice(1, -1); + return { + type: 'em', + raw, + text, + tokens: this.lexer.inlineTokens(text) + }; + } + // Create 'strong' if smallest delimiter has even char count. **a*** + const text = raw.slice(2, -2); + return { + type: 'strong', + raw, + text, + tokens: this.lexer.inlineTokens(text) + }; + } + } + } + codespan(src) { + const cap = this.rules.inline.code.exec(src); + if (cap) { + let text = cap[2].replace(/\n/g, ' '); + const hasNonSpaceChars = /[^ ]/.test(text); + const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text); + if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) { + text = text.substring(1, text.length - 1); + } + text = escape$1$1(text, true); + return { + type: 'codespan', + raw: cap[0], + text + }; + } + } + br(src) { + const cap = this.rules.inline.br.exec(src); + if (cap) { + return { + type: 'br', + raw: cap[0] + }; + } + } + del(src) { + const cap = this.rules.inline.del.exec(src); + if (cap) { + return { + type: 'del', + raw: cap[0], + text: cap[2], + tokens: this.lexer.inlineTokens(cap[2]) + }; + } + } + autolink(src) { + const cap = this.rules.inline.autolink.exec(src); + if (cap) { + let text, href; + if (cap[2] === '@') { + text = escape$1$1(cap[1]); + href = 'mailto:' + text; + } + else { + text = escape$1$1(cap[1]); + href = text; + } + return { + type: 'link', + raw: cap[0], + text, + href, + tokens: [ + { + type: 'text', + raw: text, + text + } + ] + }; + } + } + url(src) { + let cap; + if (cap = this.rules.inline.url.exec(src)) { + let text, href; + if (cap[2] === '@') { + text = escape$1$1(cap[0]); + href = 'mailto:' + text; + } + else { + // do extended autolink path validation + let prevCapZero; + do { + prevCapZero = cap[0]; + cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? ''; + } while (prevCapZero !== cap[0]); + text = escape$1$1(cap[0]); + if (cap[1] === 'www.') { + href = 'http://' + cap[0]; + } + else { + href = cap[0]; + } + } + return { + type: 'link', + raw: cap[0], + text, + href, + tokens: [ + { + type: 'text', + raw: text, + text + } + ] + }; + } + } + inlineText(src) { + const cap = this.rules.inline.text.exec(src); + if (cap) { + let text; + if (this.lexer.state.inRawBlock) { + text = cap[0]; + } + else { + text = escape$1$1(cap[0]); + } + return { + type: 'text', + raw: cap[0], + text + }; + } + } +} + +/** + * Block-Level Grammar + */ +const newline = /^(?: *(?:\n|$))+/; +const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/; +const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; +const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; +const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; +const bullet = /(?:[*+-]|\d{1,9}[.)])/; +const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/) + .replace(/bull/g, bullet) // lists can interrupt + .replace(/blockCode/g, / {4}/) // indented code blocks can interrupt + .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt + .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt + .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt + .replace(/html/g, / {0,3}<[^\n>]+>\n/) // block html can interrupt + .getRegex(); +const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/; +const blockText = /^[^\n]+/; +const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/; +const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/) + .replace('label', _blockLabel) + .replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/) + .getRegex(); +const list$1 = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/) + .replace(/bull/g, bullet) + .getRegex(); +const _tag = 'address|article|aside|base|basefont|blockquote|body|caption' + + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' + + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' + + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' + + '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title' + + '|tr|track|ul'; +const _comment = /|$))/; +const html$2 = edit('^ {0,3}(?:' // optional indentation + + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)' // (1) + + '|comment[^\\n]*(\\n+|$)' // (2) + + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3) + + '|\\n*|$)' // (4) + + '|\\n*|$)' // (5) + + '|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6) + + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag + + '|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag + + ')', 'i') + .replace('comment', _comment) + .replace('tag', _tag) + .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/) + .getRegex(); +const paragraph = edit(_paragraph) + .replace('hr', hr) + .replace('heading', ' {0,3}#{1,6}(?:\\s|$)') + .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs + .replace('|table', '') + .replace('blockquote', ' {0,3}>') + .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') + .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt + .replace('html', ')|<(?:script|pre|style|textarea|!--)') + .replace('tag', _tag) // pars can be interrupted by type (6) html blocks + .getRegex(); +const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/) + .replace('paragraph', paragraph) + .getRegex(); +/** + * Normal Block Grammar + */ +const blockNormal = { + blockquote, + code: blockCode, + def, + fences, + heading, + hr, + html: html$2, + lheading, + list: list$1, + newline, + paragraph, + table: noopTest, + text: blockText +}; +/** + * GFM Block Grammar + */ +const gfmTable = edit('^ *([^\\n ].*)\\n' // Header + + ' {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)' // Align + + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)') // Cells + .replace('hr', hr) + .replace('heading', ' {0,3}#{1,6}(?:\\s|$)') + .replace('blockquote', ' {0,3}>') + .replace('code', ' {4}[^\\n]') + .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') + .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt + .replace('html', ')|<(?:script|pre|style|textarea|!--)') + .replace('tag', _tag) // tables can be interrupted by type (6) html blocks + .getRegex(); +const blockGfm = { + ...blockNormal, + table: gfmTable, + paragraph: edit(_paragraph) + .replace('hr', hr) + .replace('heading', ' {0,3}#{1,6}(?:\\s|$)') + .replace('|lheading', '') // setext headings don't interrupt commonmark paragraphs + .replace('table', gfmTable) // interrupt paragraphs with table + .replace('blockquote', ' {0,3}>') + .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') + .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt + .replace('html', ')|<(?:script|pre|style|textarea|!--)') + .replace('tag', _tag) // pars can be interrupted by type (6) html blocks + .getRegex() +}; +/** + * Pedantic grammar (original John Gruber's loose markdown specification) + */ +const blockPedantic = { + ...blockNormal, + html: edit('^ *(?:comment *(?:\\n|\\s*$)' + + '|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)' // closed tag + + '|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))') + .replace('comment', _comment) + .replace(/tag/g, '(?!(?:' + + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub' + + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)' + + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b') + .getRegex(), + def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, + heading: /^(#{1,6})(.*)(?:\n+|$)/, + fences: noopTest, // fences not supported + lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, + paragraph: edit(_paragraph) + .replace('hr', hr) + .replace('heading', ' *#{1,6} *[^\n]') + .replace('lheading', lheading) + .replace('|table', '') + .replace('blockquote', ' {0,3}>') + .replace('|fences', '') + .replace('|list', '') + .replace('|html', '') + .replace('|tag', '') + .getRegex() +}; +/** + * Inline-Level Grammar + */ +const escape$2 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/; +const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/; +const br = /^( {2,}|\\)\n(?!\s*$)/; +const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\ +const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g; +const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u') + .replace(/punct/g, _punctuation) + .getRegex(); +const emStrongRDelimAst = edit('^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)' // Skip orphan inside strong + + '|[^*]+(?=[^*])' // Consume to delim + + '|(?!\\*)[punct](\\*+)(?=[\\s]|$)' // (1) #*** can only be a Right Delimiter + + '|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)' // (2) a***#, a*** can only be a Right Delimiter + + '|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])' // (3) #***a, ***a can only be Left Delimiter + + '|[\\s](\\*+)(?!\\*)(?=[punct])' // (4) ***# can only be Left Delimiter + + '|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])' // (5) #***# can be either Left or Right Delimiter + + '|[^punct\\s](\\*+)(?=[^punct\\s])', 'gu') // (6) a***a can be either Left or Right Delimiter + .replace(/punct/g, _punctuation) + .getRegex(); +// (6) Not allowed for _ +const emStrongRDelimUnd = edit('^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)' // Skip orphan inside strong + + '|[^_]+(?=[^_])' // Consume to delim + + '|(?!_)[punct](_+)(?=[\\s]|$)' // (1) #___ can only be a Right Delimiter + + '|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)' // (2) a___#, a___ can only be a Right Delimiter + + '|(?!_)[punct\\s](_+)(?=[^punct\\s])' // (3) #___a, ___a can only be Left Delimiter + + '|[\\s](_+)(?!_)(?=[punct])' // (4) ___# can only be Left Delimiter + + '|(?!_)[punct](_+)(?!_)(?=[punct])', 'gu') // (5) #___# can be either Left or Right Delimiter + .replace(/punct/g, _punctuation) + .getRegex(); +const anyPunctuation = edit(/\\([punct])/, 'gu') + .replace(/punct/g, _punctuation) + .getRegex(); +const autolink$1 = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/) + .replace('scheme', /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/) + .replace('email', /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/) + .getRegex(); +const _inlineComment = edit(_comment).replace('(?:-->|$)', '-->').getRegex(); +const tag = edit('^comment' + + '|^' // self-closing tag + + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag + + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. + + '|^' // declaration, e.g. + + '|^') // CDATA section + .replace('comment', _inlineComment) + .replace('attribute', /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/) + .getRegex(); +const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/; +const link$1 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/) + .replace('label', _inlineLabel) + .replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/) + .replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/) + .getRegex(); +const reflink = edit(/^!?\[(label)\]\[(ref)\]/) + .replace('label', _inlineLabel) + .replace('ref', _blockLabel) + .getRegex(); +const nolink = edit(/^!?\[(ref)\](?:\[\])?/) + .replace('ref', _blockLabel) + .getRegex(); +const reflinkSearch = edit('reflink|nolink(?!\\()', 'g') + .replace('reflink', reflink) + .replace('nolink', nolink) + .getRegex(); +/** + * Normal Inline Grammar + */ +const inlineNormal = { + _backpedal: noopTest, // only used for GFM url + anyPunctuation, + autolink: autolink$1, + blockSkip, + br, + code: inlineCode, + del: noopTest, + emStrongLDelim, + emStrongRDelimAst, + emStrongRDelimUnd, + escape: escape$2, + link: link$1, + nolink, + punctuation, + reflink, + reflinkSearch, + tag, + text: inlineText, + url: noopTest +}; +/** + * Pedantic Inline Grammar + */ +const inlinePedantic = { + ...inlineNormal, + link: edit(/^!?\[(label)\]\((.*?)\)/) + .replace('label', _inlineLabel) + .getRegex(), + reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/) + .replace('label', _inlineLabel) + .getRegex() +}; +/** + * GFM Inline Grammar + */ +const inlineGfm = { + ...inlineNormal, + escape: edit(escape$2).replace('])', '~|])').getRegex(), + url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, 'i') + .replace('email', /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/) + .getRegex(), + _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, + del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/, + text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\ { + return leading + ' '.repeat(tabs.length); + }); + } + let token; + let lastToken; + let cutSrc; + let lastParagraphClipped; + while (src) { + if (this.options.extensions + && this.options.extensions.block + && this.options.extensions.block.some((extTokenizer) => { + if (token = extTokenizer.call({ lexer: this }, src, tokens)) { + src = src.substring(token.raw.length); + tokens.push(token); + return true; + } + return false; + })) { + continue; + } + // newline + if (token = this.tokenizer.space(src)) { + src = src.substring(token.raw.length); + if (token.raw.length === 1 && tokens.length > 0) { + // if there's a single \n as a spacer, it's terminating the last line, + // so move it there so that we don't get unnecessary paragraph tags + tokens[tokens.length - 1].raw += '\n'; + } + else { + tokens.push(token); + } + continue; + } + // code + if (token = this.tokenizer.code(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + // An indented code block cannot interrupt a paragraph. + if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.text; + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else { + tokens.push(token); + } + continue; + } + // fences + if (token = this.tokenizer.fences(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // heading + if (token = this.tokenizer.heading(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // hr + if (token = this.tokenizer.hr(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // blockquote + if (token = this.tokenizer.blockquote(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // list + if (token = this.tokenizer.list(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // html + if (token = this.tokenizer.html(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // def + if (token = this.tokenizer.def(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.raw; + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else if (!this.tokens.links[token.tag]) { + this.tokens.links[token.tag] = { + href: token.href, + title: token.title + }; + } + continue; + } + // table (gfm) + if (token = this.tokenizer.table(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // lheading + if (token = this.tokenizer.lheading(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // top-level paragraph + // prevent paragraph consuming extensions by clipping 'src' to extension start + cutSrc = src; + if (this.options.extensions && this.options.extensions.startBlock) { + let startIndex = Infinity; + const tempSrc = src.slice(1); + let tempStart; + this.options.extensions.startBlock.forEach((getStartIndex) => { + tempStart = getStartIndex.call({ lexer: this }, tempSrc); + if (typeof tempStart === 'number' && tempStart >= 0) { + startIndex = Math.min(startIndex, tempStart); + } + }); + if (startIndex < Infinity && startIndex >= 0) { + cutSrc = src.substring(0, startIndex + 1); + } + } + if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) { + lastToken = tokens[tokens.length - 1]; + if (lastParagraphClipped && lastToken.type === 'paragraph') { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.text; + this.inlineQueue.pop(); + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else { + tokens.push(token); + } + lastParagraphClipped = (cutSrc.length !== src.length); + src = src.substring(token.raw.length); + continue; + } + // text + if (token = this.tokenizer.text(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && lastToken.type === 'text') { + lastToken.raw += '\n' + token.raw; + lastToken.text += '\n' + token.text; + this.inlineQueue.pop(); + this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text; + } + else { + tokens.push(token); + } + continue; + } + if (src) { + const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0); + if (this.options.silent) { + console.error(errMsg); + break; + } + else { + throw new Error(errMsg); + } + } + } + this.state.top = true; + return tokens; + } + inline(src, tokens = []) { + this.inlineQueue.push({ src, tokens }); + return tokens; + } + /** + * Lexing/Compiling + */ + inlineTokens(src, tokens = []) { + let token, lastToken, cutSrc; + // String with links masked to avoid interference with em and strong + let maskedSrc = src; + let match; + let keepPrevChar, prevChar; + // Mask out reflinks + if (this.tokens.links) { + const links = Object.keys(this.tokens.links); + if (links.length > 0) { + while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) { + if (links.includes(match[0].slice(match[0].lastIndexOf('[') + 1, -1))) { + maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex); + } + } + } + } + // Mask out other blocks + while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) { + maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); + } + // Mask out escaped characters + while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) { + maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex); + } + while (src) { + if (!keepPrevChar) { + prevChar = ''; + } + keepPrevChar = false; + // extensions + if (this.options.extensions + && this.options.extensions.inline + && this.options.extensions.inline.some((extTokenizer) => { + if (token = extTokenizer.call({ lexer: this }, src, tokens)) { + src = src.substring(token.raw.length); + tokens.push(token); + return true; + } + return false; + })) { + continue; + } + // escape + if (token = this.tokenizer.escape(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // tag + if (token = this.tokenizer.tag(src)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && token.type === 'text' && lastToken.type === 'text') { + lastToken.raw += token.raw; + lastToken.text += token.text; + } + else { + tokens.push(token); + } + continue; + } + // link + if (token = this.tokenizer.link(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // reflink, nolink + if (token = this.tokenizer.reflink(src, this.tokens.links)) { + src = src.substring(token.raw.length); + lastToken = tokens[tokens.length - 1]; + if (lastToken && token.type === 'text' && lastToken.type === 'text') { + lastToken.raw += token.raw; + lastToken.text += token.text; + } + else { + tokens.push(token); + } + continue; + } + // em & strong + if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // code + if (token = this.tokenizer.codespan(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // br + if (token = this.tokenizer.br(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // del (gfm) + if (token = this.tokenizer.del(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // autolink + if (token = this.tokenizer.autolink(src)) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // url (gfm) + if (!this.state.inLink && (token = this.tokenizer.url(src))) { + src = src.substring(token.raw.length); + tokens.push(token); + continue; + } + // text + // prevent inlineText consuming extensions by clipping 'src' to extension start + cutSrc = src; + if (this.options.extensions && this.options.extensions.startInline) { + let startIndex = Infinity; + const tempSrc = src.slice(1); + let tempStart; + this.options.extensions.startInline.forEach((getStartIndex) => { + tempStart = getStartIndex.call({ lexer: this }, tempSrc); + if (typeof tempStart === 'number' && tempStart >= 0) { + startIndex = Math.min(startIndex, tempStart); + } + }); + if (startIndex < Infinity && startIndex >= 0) { + cutSrc = src.substring(0, startIndex + 1); + } + } + if (token = this.tokenizer.inlineText(cutSrc)) { + src = src.substring(token.raw.length); + if (token.raw.slice(-1) !== '_') { // Track prevChar before string of ____ started + prevChar = token.raw.slice(-1); + } + keepPrevChar = true; + lastToken = tokens[tokens.length - 1]; + if (lastToken && lastToken.type === 'text') { + lastToken.raw += token.raw; + lastToken.text += token.text; + } + else { + tokens.push(token); + } + continue; + } + if (src) { + const errMsg = 'Infinite loop on byte: ' + src.charCodeAt(0); + if (this.options.silent) { + console.error(errMsg); + break; + } + else { + throw new Error(errMsg); + } + } + } + return tokens; + } +} + +/** + * Renderer + */ +class _Renderer { + options; + constructor(options) { + this.options = options || _defaults; + } + code(code, infostring, escaped) { + const lang = (infostring || '').match(/^\S*/)?.[0]; + code = code.replace(/\n$/, '') + '\n'; + if (!lang) { + return '
    '
    +                + (escaped ? code : escape$1$1(code, true))
    +                + '
    \n'; + } + return '
    '
    +            + (escaped ? code : escape$1$1(code, true))
    +            + '
    \n'; + } + blockquote(quote) { + return `
    \n${quote}
    \n`; + } + html(html, block) { + return html; + } + heading(text, level, raw) { + // ignore IDs + return `${text}\n`; + } + hr() { + return '
    \n'; + } + list(body, ordered, start) { + const type = ordered ? 'ol' : 'ul'; + const startatt = (ordered && start !== 1) ? (' start="' + start + '"') : ''; + return '<' + type + startatt + '>\n' + body + '\n'; + } + listitem(text, task, checked) { + return `
  • ${text}
  • \n`; + } + checkbox(checked) { + return ''; + } + paragraph(text) { + return `

    ${text}

    \n`; + } + table(header, body) { + if (body) + body = `${body}`; + return '\n' + + '\n' + + header + + '\n' + + body + + '
    \n'; + } + tablerow(content) { + return `\n${content}\n`; + } + tablecell(content, flags) { + const type = flags.header ? 'th' : 'td'; + const tag = flags.align + ? `<${type} align="${flags.align}">` + : `<${type}>`; + return tag + content + `\n`; + } + /** + * span level renderer + */ + strong(text) { + return `${text}`; + } + em(text) { + return `${text}`; + } + codespan(text) { + return `${text}`; + } + br() { + return '
    '; + } + del(text) { + return `${text}`; + } + link(href, title, text) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; + } + href = cleanHref; + let out = '
    '; + return out; + } + image(href, title, text) { + const cleanHref = cleanUrl(href); + if (cleanHref === null) { + return text; + } + href = cleanHref; + let out = `${text} 0 && item.tokens[0].type === 'paragraph') { + item.tokens[0].text = checkbox + ' ' + item.tokens[0].text; + if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') { + item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text; + } + } + else { + item.tokens.unshift({ + type: 'text', + text: checkbox + ' ' + }); + } + } + else { + itemBody += checkbox + ' '; + } + } + itemBody += this.parse(item.tokens, loose); + body += this.renderer.listitem(itemBody, task, !!checked); + } + out += this.renderer.list(body, ordered, start); + continue; + } + case 'html': { + const htmlToken = token; + out += this.renderer.html(htmlToken.text, htmlToken.block); + continue; + } + case 'paragraph': { + const paragraphToken = token; + out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens)); + continue; + } + case 'text': { + let textToken = token; + let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text; + while (i + 1 < tokens.length && tokens[i + 1].type === 'text') { + textToken = tokens[++i]; + body += '\n' + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text); + } + out += top ? this.renderer.paragraph(body) : body; + continue; + } + default: { + const errMsg = 'Token with "' + token.type + '" type was not found.'; + if (this.options.silent) { + console.error(errMsg); + return ''; + } + else { + throw new Error(errMsg); + } + } + } + } + return out; + } + /** + * Parse Inline Tokens + */ + parseInline(tokens, renderer) { + renderer = renderer || this.renderer; + let out = ''; + for (let i = 0; i < tokens.length; i++) { + const token = tokens[i]; + // Run any renderer extensions + if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) { + const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token); + if (ret !== false || !['escape', 'html', 'link', 'image', 'strong', 'em', 'codespan', 'br', 'del', 'text'].includes(token.type)) { + out += ret || ''; + continue; + } + } + switch (token.type) { + case 'escape': { + const escapeToken = token; + out += renderer.text(escapeToken.text); + break; + } + case 'html': { + const tagToken = token; + out += renderer.html(tagToken.text); + break; + } + case 'link': { + const linkToken = token; + out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer)); + break; + } + case 'image': { + const imageToken = token; + out += renderer.image(imageToken.href, imageToken.title, imageToken.text); + break; + } + case 'strong': { + const strongToken = token; + out += renderer.strong(this.parseInline(strongToken.tokens, renderer)); + break; + } + case 'em': { + const emToken = token; + out += renderer.em(this.parseInline(emToken.tokens, renderer)); + break; + } + case 'codespan': { + const codespanToken = token; + out += renderer.codespan(codespanToken.text); + break; + } + case 'br': { + out += renderer.br(); + break; + } + case 'del': { + const delToken = token; + out += renderer.del(this.parseInline(delToken.tokens, renderer)); + break; + } + case 'text': { + const textToken = token; + out += renderer.text(textToken.text); + break; + } + default: { + const errMsg = 'Token with "' + token.type + '" type was not found.'; + if (this.options.silent) { + console.error(errMsg); + return ''; + } + else { + throw new Error(errMsg); + } + } + } + } + return out; + } +} + +class _Hooks { + options; + constructor(options) { + this.options = options || _defaults; + } + static passThroughHooks = new Set([ + 'preprocess', + 'postprocess', + 'processAllTokens' + ]); + /** + * Process markdown before marked + */ + preprocess(markdown) { + return markdown; + } + /** + * Process HTML after marked is finished + */ + postprocess(html) { + return html; + } + /** + * Process all tokens before walk tokens + */ + processAllTokens(tokens) { + return tokens; + } +} + +class Marked { + defaults = _getDefaults(); + options = this.setOptions; + parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse); + parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline); + Parser = _Parser; + Renderer = _Renderer; + TextRenderer = _TextRenderer; + Lexer = _Lexer; + Tokenizer = _Tokenizer; + Hooks = _Hooks; + constructor(...args) { + this.use(...args); + } + /** + * Run callback for every token + */ + walkTokens(tokens, callback) { + let values = []; + for (const token of tokens) { + values = values.concat(callback.call(this, token)); + switch (token.type) { + case 'table': { + const tableToken = token; + for (const cell of tableToken.header) { + values = values.concat(this.walkTokens(cell.tokens, callback)); + } + for (const row of tableToken.rows) { + for (const cell of row) { + values = values.concat(this.walkTokens(cell.tokens, callback)); + } + } + break; + } + case 'list': { + const listToken = token; + values = values.concat(this.walkTokens(listToken.items, callback)); + break; + } + default: { + const genericToken = token; + if (this.defaults.extensions?.childTokens?.[genericToken.type]) { + this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => { + const tokens = genericToken[childTokens].flat(Infinity); + values = values.concat(this.walkTokens(tokens, callback)); + }); + } + else if (genericToken.tokens) { + values = values.concat(this.walkTokens(genericToken.tokens, callback)); + } + } + } + } + return values; + } + use(...args) { + const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} }; + args.forEach((pack) => { + // copy options to new object + const opts = { ...pack }; + // set async to true if it was set to true before + opts.async = this.defaults.async || opts.async || false; + // ==-- Parse "addon" extensions --== // + if (pack.extensions) { + pack.extensions.forEach((ext) => { + if (!ext.name) { + throw new Error('extension name required'); + } + if ('renderer' in ext) { // Renderer extensions + const prevRenderer = extensions.renderers[ext.name]; + if (prevRenderer) { + // Replace extension with func to run new extension but fall back if false + extensions.renderers[ext.name] = function (...args) { + let ret = ext.renderer.apply(this, args); + if (ret === false) { + ret = prevRenderer.apply(this, args); + } + return ret; + }; + } + else { + extensions.renderers[ext.name] = ext.renderer; + } + } + if ('tokenizer' in ext) { // Tokenizer Extensions + if (!ext.level || (ext.level !== 'block' && ext.level !== 'inline')) { + throw new Error("extension level must be 'block' or 'inline'"); + } + const extLevel = extensions[ext.level]; + if (extLevel) { + extLevel.unshift(ext.tokenizer); + } + else { + extensions[ext.level] = [ext.tokenizer]; + } + if (ext.start) { // Function to check for start of token + if (ext.level === 'block') { + if (extensions.startBlock) { + extensions.startBlock.push(ext.start); + } + else { + extensions.startBlock = [ext.start]; + } + } + else if (ext.level === 'inline') { + if (extensions.startInline) { + extensions.startInline.push(ext.start); + } + else { + extensions.startInline = [ext.start]; + } + } + } + } + if ('childTokens' in ext && ext.childTokens) { // Child tokens to be visited by walkTokens + extensions.childTokens[ext.name] = ext.childTokens; + } + }); + opts.extensions = extensions; + } + // ==-- Parse "overwrite" extensions --== // + if (pack.renderer) { + const renderer = this.defaults.renderer || new _Renderer(this.defaults); + for (const prop in pack.renderer) { + if (!(prop in renderer)) { + throw new Error(`renderer '${prop}' does not exist`); + } + if (prop === 'options') { + // ignore options property + continue; + } + const rendererProp = prop; + const rendererFunc = pack.renderer[rendererProp]; + const prevRenderer = renderer[rendererProp]; + // Replace renderer with func to run extension, but fall back if false + renderer[rendererProp] = (...args) => { + let ret = rendererFunc.apply(renderer, args); + if (ret === false) { + ret = prevRenderer.apply(renderer, args); + } + return ret || ''; + }; + } + opts.renderer = renderer; + } + if (pack.tokenizer) { + const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults); + for (const prop in pack.tokenizer) { + if (!(prop in tokenizer)) { + throw new Error(`tokenizer '${prop}' does not exist`); + } + if (['options', 'rules', 'lexer'].includes(prop)) { + // ignore options, rules, and lexer properties + continue; + } + const tokenizerProp = prop; + const tokenizerFunc = pack.tokenizer[tokenizerProp]; + const prevTokenizer = tokenizer[tokenizerProp]; + // Replace tokenizer with func to run extension, but fall back if false + // @ts-expect-error cannot type tokenizer function dynamically + tokenizer[tokenizerProp] = (...args) => { + let ret = tokenizerFunc.apply(tokenizer, args); + if (ret === false) { + ret = prevTokenizer.apply(tokenizer, args); + } + return ret; + }; + } + opts.tokenizer = tokenizer; + } + // ==-- Parse Hooks extensions --== // + if (pack.hooks) { + const hooks = this.defaults.hooks || new _Hooks(); + for (const prop in pack.hooks) { + if (!(prop in hooks)) { + throw new Error(`hook '${prop}' does not exist`); + } + if (prop === 'options') { + // ignore options property + continue; + } + const hooksProp = prop; + const hooksFunc = pack.hooks[hooksProp]; + const prevHook = hooks[hooksProp]; + if (_Hooks.passThroughHooks.has(prop)) { + // @ts-expect-error cannot type hook function dynamically + hooks[hooksProp] = (arg) => { + if (this.defaults.async) { + return Promise.resolve(hooksFunc.call(hooks, arg)).then(ret => { + return prevHook.call(hooks, ret); + }); + } + const ret = hooksFunc.call(hooks, arg); + return prevHook.call(hooks, ret); + }; + } + else { + // @ts-expect-error cannot type hook function dynamically + hooks[hooksProp] = (...args) => { + let ret = hooksFunc.apply(hooks, args); + if (ret === false) { + ret = prevHook.apply(hooks, args); + } + return ret; + }; + } + } + opts.hooks = hooks; + } + // ==-- Parse WalkTokens extensions --== // + if (pack.walkTokens) { + const walkTokens = this.defaults.walkTokens; + const packWalktokens = pack.walkTokens; + opts.walkTokens = function (token) { + let values = []; + values.push(packWalktokens.call(this, token)); + if (walkTokens) { + values = values.concat(walkTokens.call(this, token)); + } + return values; + }; + } + this.defaults = { ...this.defaults, ...opts }; + }); + return this; + } + setOptions(opt) { + this.defaults = { ...this.defaults, ...opt }; + return this; + } + lexer(src, options) { + return _Lexer.lex(src, options ?? this.defaults); + } + parser(tokens, options) { + return _Parser.parse(tokens, options ?? this.defaults); + } + #parseMarkdown(lexer, parser) { + return (src, options) => { + const origOpt = { ...options }; + const opt = { ...this.defaults, ...origOpt }; + // Show warning if an extension set async to true but the parse was called with async: false + if (this.defaults.async === true && origOpt.async === false) { + if (!opt.silent) { + console.warn('marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.'); + } + opt.async = true; + } + const throwError = this.#onError(!!opt.silent, !!opt.async); + // throw error in case of non string input + if (typeof src === 'undefined' || src === null) { + return throwError(new Error('marked(): input parameter is undefined or null')); + } + if (typeof src !== 'string') { + return throwError(new Error('marked(): input parameter is of type ' + + Object.prototype.toString.call(src) + ', string expected')); + } + if (opt.hooks) { + opt.hooks.options = opt; + } + if (opt.async) { + return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src) + .then(src => lexer(src, opt)) + .then(tokens => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens) + .then(tokens => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens) + .then(tokens => parser(tokens, opt)) + .then(html => opt.hooks ? opt.hooks.postprocess(html) : html) + .catch(throwError); + } + try { + if (opt.hooks) { + src = opt.hooks.preprocess(src); + } + let tokens = lexer(src, opt); + if (opt.hooks) { + tokens = opt.hooks.processAllTokens(tokens); + } + if (opt.walkTokens) { + this.walkTokens(tokens, opt.walkTokens); + } + let html = parser(tokens, opt); + if (opt.hooks) { + html = opt.hooks.postprocess(html); + } + return html; + } + catch (e) { + return throwError(e); + } + }; + } + #onError(silent, async) { + return (e) => { + e.message += '\nPlease report this to https://github.com/markedjs/marked.'; + if (silent) { + const msg = '

    An error occurred:

    '
    +                    + escape$1$1(e.message + '', true)
    +                    + '
    '; + if (async) { + return Promise.resolve(msg); + } + return msg; + } + if (async) { + return Promise.reject(e); + } + throw e; + }; + } +} + +const markedInstance = new Marked(); +function marked(src, opt) { + return markedInstance.parse(src, opt); +} +/** + * Sets the default options. + * + * @param options Hash of options + */ +marked.options = + marked.setOptions = function (options) { + markedInstance.setOptions(options); + marked.defaults = markedInstance.defaults; + changeDefaults(marked.defaults); + return marked; + }; +/** + * Gets the original marked default options. + */ +marked.getDefaults = _getDefaults; +marked.defaults = _defaults; +/** + * Use Extension + */ +marked.use = function (...args) { + markedInstance.use(...args); + marked.defaults = markedInstance.defaults; + changeDefaults(marked.defaults); + return marked; +}; +/** + * Run callback for every token + */ +marked.walkTokens = function (tokens, callback) { + return markedInstance.walkTokens(tokens, callback); +}; +/** + * Compiles markdown to HTML without enclosing `p` tag. + * + * @param src String of markdown source to be compiled + * @param options Hash of options + * @return String of compiled HTML + */ +marked.parseInline = markedInstance.parseInline; +/** + * Expose + */ +marked.Parser = _Parser; +marked.parser = _Parser.parse; +marked.Renderer = _Renderer; +marked.TextRenderer = _TextRenderer; +marked.Lexer = _Lexer; +marked.lexer = _Lexer.lex; +marked.Tokenizer = _Tokenizer; +marked.Hooks = _Hooks; +marked.parse = marked; +marked.options; +marked.setOptions; +marked.use; +marked.walkTokens; +marked.parseInline; +_Parser.parse; +_Lexer.lex; + +/** + * Lexing or parsing positional information for error reporting. + * This object is immutable. + */ +class SourceLocation { + // The + prefix indicates that these fields aren't writeable + // Lexer holding the input string. + // Start offset, zero-based inclusive. + // End offset, zero-based exclusive. + constructor(lexer, start, end) { + this.lexer = void 0; + this.start = void 0; + this.end = void 0; + this.lexer = lexer; + this.start = start; + this.end = end; + } + /** + * Merges two `SourceLocation`s from location providers, given they are + * provided in order of appearance. + * - Returns the first one's location if only the first is provided. + * - Returns a merged range of the first and the last if both are provided + * and their lexers match. + * - Otherwise, returns null. + */ + + + static range(first, second) { + if (!second) { + return first && first.loc; + } else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) { + return null; + } else { + return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end); + } + } + +} + +/** + * Interface required to break circular dependency between Token, Lexer, and + * ParseError. + */ + +/** + * The resulting token returned from `lex`. + * + * It consists of the token text plus some position information. + * The position information is essentially a range in an input string, + * but instead of referencing the bare input string, we refer to the lexer. + * That way it is possible to attach extra metadata to the input string, + * like for example a file name or similar. + * + * The position information is optional, so it is OK to construct synthetic + * tokens if appropriate. Not providing available position information may + * lead to degraded error reporting, though. + */ +class Token { + // don't expand the token + // used in \noexpand + constructor(text, // the text of this token + loc) { + this.text = void 0; + this.loc = void 0; + this.noexpand = void 0; + this.treatAsRelax = void 0; + this.text = text; + this.loc = loc; + } + /** + * Given a pair of tokens (this and endToken), compute a `Token` encompassing + * the whole input range enclosed by these two. + */ + + + range(endToken, // last token of the range, inclusive + text // the text of the newly constructed token + ) { + return new Token(text, SourceLocation.range(this, endToken)); + } + +} + +/** + * This is the ParseError class, which is the main error thrown by KaTeX + * functions when something has gone wrong. This is used to distinguish internal + * errors from errors in the expression that the user provided. + * + * If possible, a caller should provide a Token or ParseNode with information + * about where in the source string the problem occurred. + */ +class ParseError { + // Error start position based on passed-in Token or ParseNode. + // Length of affected text based on passed-in Token or ParseNode. + // The underlying error message without any context added. + constructor(message, // The error message + token // An object providing position information + ) { + this.name = void 0; + this.position = void 0; + this.length = void 0; + this.rawMessage = void 0; + var error = "KaTeX parse error: " + message; + var start; + var end; + var loc = token && token.loc; + + if (loc && loc.start <= loc.end) { + // If we have the input and a position, make the error a bit fancier + // Get the input + var input = loc.lexer.input; // Prepend some information + + start = loc.start; + end = loc.end; + + if (start === input.length) { + error += " at end of input: "; + } else { + error += " at position " + (start + 1) + ": "; + } // Underline token in question using combining underscores + + + var underlined = input.slice(start, end).replace(/[^]/g, "$&\u0332"); // Extract some context from the input and add it to the error + + var left; + + if (start > 15) { + left = "…" + input.slice(start - 15, start); + } else { + left = input.slice(0, start); + } + + var right; + + if (end + 15 < input.length) { + right = input.slice(end, end + 15) + "…"; + } else { + right = input.slice(end); + } + + error += left + underlined + right; + } // Some hackery to make ParseError a prototype of Error + // See http://stackoverflow.com/a/8460753 + // $FlowFixMe + + + var self = new Error(error); + self.name = "ParseError"; // $FlowFixMe + + self.__proto__ = ParseError.prototype; + self.position = start; + + if (start != null && end != null) { + self.length = end - start; + } + + self.rawMessage = message; + return self; + } + +} // $FlowFixMe More hackery + + +ParseError.prototype.__proto__ = Error.prototype; + +/** + * This file contains a list of utility functions which are useful in other + * files. + */ + +/** + * Return whether an element is contained in a list + */ +var contains = function contains(list, elem) { + return list.indexOf(elem) !== -1; +}; +/** + * Provide a default value if a setting is undefined + * NOTE: Couldn't use `T` as the output type due to facebook/flow#5022. + */ + + +var deflt = function deflt(setting, defaultIfUndefined) { + return setting === undefined ? defaultIfUndefined : setting; +}; // hyphenate and escape adapted from Facebook's React under Apache 2 license + + +var uppercase = /([A-Z])/g; + +var hyphenate = function hyphenate(str) { + return str.replace(uppercase, "-$1").toLowerCase(); +}; + +var ESCAPE_LOOKUP = { + "&": "&", + ">": ">", + "<": "<", + "\"": """, + "'": "'" +}; +var ESCAPE_REGEX = /[&><"']/g; +/** + * Escapes text to prevent scripting attacks. + */ + +function escape$1(text) { + return String(text).replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); +} +/** + * Sometimes we want to pull out the innermost element of a group. In most + * cases, this will just be the group itself, but when ordgroups and colors have + * a single element, we want to pull that out. + */ + + +var getBaseElem = function getBaseElem(group) { + if (group.type === "ordgroup") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "color") { + if (group.body.length === 1) { + return getBaseElem(group.body[0]); + } else { + return group; + } + } else if (group.type === "font") { + return getBaseElem(group.body); + } else { + return group; + } +}; +/** + * TeXbook algorithms often reference "character boxes", which are simply groups + * with a single character in them. To decide if something is a character box, + * we find its innermost group, and see if it is a single character. + */ + + +var isCharacterBox = function isCharacterBox(group) { + var baseElem = getBaseElem(group); // These are all they types of groups which hold single characters + + return baseElem.type === "mathord" || baseElem.type === "textord" || baseElem.type === "atom"; +}; + +var assert = function assert(value) { + if (!value) { + throw new Error('Expected non-null, but got ' + String(value)); + } + + return value; +}; +/** + * Return the protocol of a URL, or "_relative" if the URL does not specify a + * protocol (and thus is relative), or `null` if URL has invalid protocol + * (so should be outright rejected). + */ + +var protocolFromUrl = function protocolFromUrl(url) { + // Check for possible leading protocol. + // https://url.spec.whatwg.org/#url-parsing strips leading whitespace + // (U+20) or C0 control (U+00-U+1F) characters. + // eslint-disable-next-line no-control-regex + var protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(url); + + if (!protocol) { + return "_relative"; + } // Reject weird colons + + + if (protocol[2] !== ":") { + return null; + } // Reject invalid characters in scheme according to + // https://datatracker.ietf.org/doc/html/rfc3986#section-3.1 + + + if (!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(protocol[1])) { + return null; + } // Lowercase the protocol + + + return protocol[1].toLowerCase(); +}; +var utils$1 = { + contains, + deflt, + escape: escape$1, + hyphenate, + getBaseElem, + isCharacterBox, + protocolFromUrl +}; + +/* eslint no-console:0 */ +// TODO: automatically generate documentation +// TODO: check all properties on Settings exist +// TODO: check the type of a property on Settings matches +var SETTINGS_SCHEMA = { + displayMode: { + type: "boolean", + description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.", + cli: "-d, --display-mode" + }, + output: { + type: { + enum: ["htmlAndMathml", "html", "mathml"] + }, + description: "Determines the markup language of the output.", + cli: "-F, --format " + }, + leqno: { + type: "boolean", + description: "Render display math in leqno style (left-justified tags)." + }, + fleqn: { + type: "boolean", + description: "Render display math flush left." + }, + throwOnError: { + type: "boolean", + default: true, + cli: "-t, --no-throw-on-error", + cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error." + }, + errorColor: { + type: "string", + default: "#cc0000", + cli: "-c, --error-color ", + cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.", + cliProcessor: color => "#" + color + }, + macros: { + type: "object", + cli: "-m, --macro ", + cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).", + cliDefault: [], + cliProcessor: (def, defs) => { + defs.push(def); + return defs; + } + }, + minRuleThickness: { + type: "number", + description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.", + processor: t => Math.max(0, t), + cli: "--min-rule-thickness ", + cliProcessor: parseFloat + }, + colorIsTextColor: { + type: "boolean", + description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.", + cli: "-b, --color-is-text-color" + }, + strict: { + type: [{ + enum: ["warn", "ignore", "error"] + }, "boolean", "function"], + description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.", + cli: "-S, --strict", + cliDefault: false + }, + trust: { + type: ["boolean", "function"], + description: "Trust the input, enabling all HTML features such as \\url.", + cli: "-T, --trust" + }, + maxSize: { + type: "number", + default: Infinity, + description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large", + processor: s => Math.max(0, s), + cli: "-s, --max-size ", + cliProcessor: parseInt + }, + maxExpand: { + type: "number", + default: 1000, + description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.", + processor: n => Math.max(0, n), + cli: "-e, --max-expand ", + cliProcessor: n => n === "Infinity" ? Infinity : parseInt(n) + }, + globalGroup: { + type: "boolean", + cli: false + } +}; + +function getDefaultValue(schema) { + if (schema.default) { + return schema.default; + } + + var type = schema.type; + var defaultType = Array.isArray(type) ? type[0] : type; + + if (typeof defaultType !== 'string') { + return defaultType.enum[0]; + } + + switch (defaultType) { + case 'boolean': + return false; + + case 'string': + return ''; + + case 'number': + return 0; + + case 'object': + return {}; + } +} +/** + * The main Settings object + * + * The current options stored are: + * - displayMode: Whether the expression should be typeset as inline math + * (false, the default), meaning that the math starts in + * \textstyle and is placed in an inline-block); or as display + * math (true), meaning that the math starts in \displaystyle + * and is placed in a block with vertical margin. + */ + + +class Settings { + constructor(options) { + this.displayMode = void 0; + this.output = void 0; + this.leqno = void 0; + this.fleqn = void 0; + this.throwOnError = void 0; + this.errorColor = void 0; + this.macros = void 0; + this.minRuleThickness = void 0; + this.colorIsTextColor = void 0; + this.strict = void 0; + this.trust = void 0; + this.maxSize = void 0; + this.maxExpand = void 0; + this.globalGroup = void 0; + // allow null options + options = options || {}; + + for (var prop in SETTINGS_SCHEMA) { + if (SETTINGS_SCHEMA.hasOwnProperty(prop)) { + // $FlowFixMe + var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options + // $FlowFixMe + + this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema); + } + } + } + /** + * Report nonstrict (non-LaTeX-compatible) input. + * Can safely not be called if `this.strict` is false in JavaScript. + */ + + + reportNonstrict(errorCode, errorMsg, token) { + var strict = this.strict; + + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + strict = strict(errorCode, errorMsg, token); + } + + if (!strict || strict === "ignore") { + return; + } else if (strict === true || strict === "error") { + throw new ParseError("LaTeX-incompatible input and strict mode is set to 'error': " + (errorMsg + " [" + errorCode + "]"), token); + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + } + } + /** + * Check whether to apply strict (LaTeX-adhering) behavior for unusual + * input (like `\\`). Unlike `nonstrict`, will not throw an error; + * instead, "error" translates to a return value of `true`, while "ignore" + * translates to a return value of `false`. May still print a warning: + * "warn" prints a warning and returns `false`. + * This is for the second category of `errorCode`s listed in the README. + */ + + + useStrictBehavior(errorCode, errorMsg, token) { + var strict = this.strict; + + if (typeof strict === "function") { + // Allow return value of strict function to be boolean or string + // (or null/undefined, meaning no further processing). + // But catch any exceptions thrown by function, treating them + // like "error". + try { + strict = strict(errorCode, errorMsg, token); + } catch (error) { + strict = "error"; + } + } + + if (!strict || strict === "ignore") { + return false; + } else if (strict === true || strict === "error") { + return true; + } else if (strict === "warn") { + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to 'warn': " + (errorMsg + " [" + errorCode + "]")); + return false; + } else { + // won't happen in type-safe code + typeof console !== "undefined" && console.warn("LaTeX-incompatible input and strict mode is set to " + ("unrecognized '" + strict + "': " + errorMsg + " [" + errorCode + "]")); + return false; + } + } + /** + * Check whether to test potentially dangerous input, and return + * `true` (trusted) or `false` (untrusted). The sole argument `context` + * should be an object with `command` field specifying the relevant LaTeX + * command (as a string starting with `\`), and any other arguments, etc. + * If `context` has a `url` field, a `protocol` field will automatically + * get added by this function (changing the specified object). + */ + + + isTrusted(context) { + if (context.url && !context.protocol) { + var protocol = utils$1.protocolFromUrl(context.url); + + if (protocol == null) { + return false; + } + + context.protocol = protocol; + } + + var trust = typeof this.trust === "function" ? this.trust(context) : this.trust; + return Boolean(trust); + } + +} + +/** + * This file contains information and classes for the various kinds of styles + * used in TeX. It provides a generic `Style` class, which holds information + * about a specific style. It then provides instances of all the different kinds + * of styles possible, and provides functions to move between them and get + * information about them. + */ + +/** + * The main style class. Contains a unique id for the style, a size (which is + * the same for cramped and uncramped version of a style), and a cramped flag. + */ +let Style$1 = class Style { + constructor(id, size, cramped) { + this.id = void 0; + this.size = void 0; + this.cramped = void 0; + this.id = id; + this.size = size; + this.cramped = cramped; + } + /** + * Get the style of a superscript given a base in the current style. + */ + + + sup() { + return styles$a[sup[this.id]]; + } + /** + * Get the style of a subscript given a base in the current style. + */ + + + sub() { + return styles$a[sub[this.id]]; + } + /** + * Get the style of a fraction numerator given the fraction in the current + * style. + */ + + + fracNum() { + return styles$a[fracNum[this.id]]; + } + /** + * Get the style of a fraction denominator given the fraction in the current + * style. + */ + + + fracDen() { + return styles$a[fracDen[this.id]]; + } + /** + * Get the cramped version of a style (in particular, cramping a cramped style + * doesn't change the style). + */ + + + cramp() { + return styles$a[cramp[this.id]]; + } + /** + * Get a text or display version of this style. + */ + + + text() { + return styles$a[text$1$1[this.id]]; + } + /** + * Return true if this style is tightly spaced (scriptstyle/scriptscriptstyle) + */ + + + isTight() { + return this.size >= 2; + } + +}; // Export an interface for type checking, but don't expose the implementation. +// This way, no more styles can be generated. + + +// IDs of the different styles +var D = 0; +var Dc = 1; +var T = 2; +var Tc = 3; +var S = 4; +var Sc = 5; +var SS = 6; +var SSc = 7; // Instances of the different styles + +var styles$a = [new Style$1(D, 0, false), new Style$1(Dc, 0, true), new Style$1(T, 1, false), new Style$1(Tc, 1, true), new Style$1(S, 2, false), new Style$1(Sc, 2, true), new Style$1(SS, 3, false), new Style$1(SSc, 3, true)]; // Lookup tables for switching from one style to another + +var sup = [S, Sc, S, Sc, SS, SSc, SS, SSc]; +var sub = [Sc, Sc, Sc, Sc, SSc, SSc, SSc, SSc]; +var fracNum = [T, Tc, S, Sc, SS, SSc, SS, SSc]; +var fracDen = [Tc, Tc, Sc, Sc, SSc, SSc, SSc, SSc]; +var cramp = [Dc, Dc, Tc, Tc, Sc, Sc, SSc, SSc]; +var text$1$1 = [D, Dc, T, Tc, T, Tc, T, Tc]; // We only export some of the styles. + +var Style$1$1 = { + DISPLAY: styles$a[D], + TEXT: styles$a[T], + SCRIPT: styles$a[S], + SCRIPTSCRIPT: styles$a[SS] +}; + +/* + * This file defines the Unicode scripts and script families that we + * support. To add new scripts or families, just add a new entry to the + * scriptData array below. Adding scripts to the scriptData array allows + * characters from that script to appear in \text{} environments. + */ + +/** + * Each script or script family has a name and an array of blocks. + * Each block is an array of two numbers which specify the start and + * end points (inclusive) of a block of Unicode codepoints. + */ + +/** + * Unicode block data for the families of scripts we support in \text{}. + * Scripts only need to appear here if they do not have font metrics. + */ +var scriptData = [{ + // Latin characters beyond the Latin-1 characters we have metrics for. + // Needed for Czech, Hungarian and Turkish text, for example. + name: 'latin', + blocks: [[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B + [0x0300, 0x036f] // Combining Diacritical marks + ] +}, { + // The Cyrillic script used by Russian and related languages. + // A Cyrillic subset used to be supported as explicitly defined + // symbols in symbols.js + name: 'cyrillic', + blocks: [[0x0400, 0x04ff]] +}, { + // Armenian + name: 'armenian', + blocks: [[0x0530, 0x058F]] +}, { + // The Brahmic scripts of South and Southeast Asia + // Devanagari (0900–097F) + // Bengali (0980–09FF) + // Gurmukhi (0A00–0A7F) + // Gujarati (0A80–0AFF) + // Oriya (0B00–0B7F) + // Tamil (0B80–0BFF) + // Telugu (0C00–0C7F) + // Kannada (0C80–0CFF) + // Malayalam (0D00–0D7F) + // Sinhala (0D80–0DFF) + // Thai (0E00–0E7F) + // Lao (0E80–0EFF) + // Tibetan (0F00–0FFF) + // Myanmar (1000–109F) + name: 'brahmic', + blocks: [[0x0900, 0x109F]] +}, { + name: 'georgian', + blocks: [[0x10A0, 0x10ff]] +}, { + // Chinese and Japanese. + // The "k" in cjk is for Korean, but we've separated Korean out + name: "cjk", + blocks: [[0x3000, 0x30FF], // CJK symbols and punctuation, Hiragana, Katakana + [0x4E00, 0x9FAF], // CJK ideograms + [0xFF00, 0xFF60] // Fullwidth punctuation + // TODO: add halfwidth Katakana and Romanji glyphs + ] +}, { + // Korean + name: 'hangul', + blocks: [[0xAC00, 0xD7AF]] +}]; +/** + * Given a codepoint, return the name of the script or script family + * it is from, or null if it is not part of a known block + */ + +function scriptFromCodepoint(codepoint) { + for (var i = 0; i < scriptData.length; i++) { + var script = scriptData[i]; + + for (var _i = 0; _i < script.blocks.length; _i++) { + var block = script.blocks[_i]; + + if (codepoint >= block[0] && codepoint <= block[1]) { + return script.name; + } + } + } + + return null; +} +/** + * A flattened version of all the supported blocks in a single array. + * This is an optimization to make supportedCodepoint() fast. + */ + +var allBlocks = []; +scriptData.forEach(s => s.blocks.forEach(b => allBlocks.push(...b))); +/** + * Given a codepoint, return true if it falls within one of the + * scripts or script families defined above and false otherwise. + * + * Micro benchmarks shows that this is faster than + * /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test() + * in Firefox, Chrome and Node. + */ + +function supportedCodepoint(codepoint) { + for (var i = 0; i < allBlocks.length; i += 2) { + if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) { + return true; + } + } + + return false; +} + +/** + * This file provides support to domTree.js and delimiter.js. + * It's a storehouse of path geometry for SVG images. + */ +// In all paths below, the viewBox-to-em scale is 1000:1. +var hLinePad = 80; // padding above a sqrt vinculum. Prevents image cropping. +// The vinculum of a \sqrt can be made thicker by a KaTeX rendering option. +// Think of variable extraVinculum as two detours in the SVG path. +// The detour begins at the lower left of the area labeled extraVinculum below. +// The detour proceeds one extraVinculum distance up and slightly to the right, +// displacing the radiused corner between surd and vinculum. The radius is +// traversed as usual, then the detour resumes. It goes right, to the end of +// the very long vinculum, then down one extraVinculum distance, +// after which it resumes regular path geometry for the radical. + +/* vinculum + / + /▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒←extraVinculum + / █████████████████████←0.04em (40 unit) std vinculum thickness + / / + / / + / /\ + / / surd +*/ + +var sqrtMain = function sqrtMain(extraVinculum, hLinePad) { + // sqrtMain path geometry is from glyph U221A in the font KaTeX Main + return "M95," + (622 + extraVinculum + hLinePad) + "\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl" + extraVinculum / 2.075 + " -" + extraVinculum + "\nc5.3,-9.3,12,-14,20,-14\nH400000v" + (40 + extraVinculum) + "H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM" + (834 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize1 = function sqrtSize1(extraVinculum, hLinePad) { + // size1 is from glyph U221A in the font KaTeX_Size1-Regular + return "M263," + (601 + extraVinculum + hLinePad) + "c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl" + extraVinculum / 2.084 + " -" + extraVinculum + "\nc4.7,-7.3,11,-11,19,-11\nH40000v" + (40 + extraVinculum) + "H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize2 = function sqrtSize2(extraVinculum, hLinePad) { + // size2 is from glyph U221A in the font KaTeX_Size2-Regular + return "M983 " + (10 + extraVinculum + hLinePad) + "\nl" + extraVinculum / 3.13 + " -" + extraVinculum + "\nc4,-6.7,10,-10,18,-10 H400000v" + (40 + extraVinculum) + "\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize3 = function sqrtSize3(extraVinculum, hLinePad) { + // size3 is from glyph U221A in the font KaTeX_Size3-Regular + return "M424," + (2398 + extraVinculum + hLinePad) + "\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl" + extraVinculum / 4.223 + " -" + extraVinculum + "c4,-6.7,10,-10,18,-10 H400000\nv" + (40 + extraVinculum) + "H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M" + (1001 + extraVinculum) + " " + hLinePad + "\nh400000v" + (40 + extraVinculum) + "h-400000z"; +}; + +var sqrtSize4 = function sqrtSize4(extraVinculum, hLinePad) { + // size4 is from glyph U221A in the font KaTeX_Size4-Regular + return "M473," + (2713 + extraVinculum + hLinePad) + "\nc339.3,-1799.3,509.3,-2700,510,-2702 l" + extraVinculum / 5.298 + " -" + extraVinculum + "\nc3.3,-7.3,9.3,-11,18,-11 H400000v" + (40 + extraVinculum) + "H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM" + (1001 + extraVinculum) + " " + hLinePad + "h400000v" + (40 + extraVinculum) + "H1017.7z"; +}; + +var phasePath = function phasePath(y) { + var x = y / 2; // x coordinate at top of angle + + return "M400000 " + y + " H0 L" + x + " 0 l65 45 L145 " + (y - 80) + " H400000z"; +}; + +var sqrtTall = function sqrtTall(extraVinculum, hLinePad, viewBoxHeight) { + // sqrtTall is from glyph U23B7 in the font KaTeX_Size4-Regular + // One path edge has a variable length. It runs vertically from the vinculum + // to a point near (14 units) the bottom of the surd. The vinculum + // is normally 40 units thick. So the length of the line in question is: + var vertSegment = viewBoxHeight - 54 - hLinePad - extraVinculum; + return "M702 " + (extraVinculum + hLinePad) + "H400000" + (40 + extraVinculum) + "\nH742v" + vertSegment + "l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 " + hLinePad + "H400000v" + (40 + extraVinculum) + "H742z"; +}; + +var sqrtPath = function sqrtPath(size, extraVinculum, viewBoxHeight) { + extraVinculum = 1000 * extraVinculum; // Convert from document ems to viewBox. + + var path = ""; + + switch (size) { + case "sqrtMain": + path = sqrtMain(extraVinculum, hLinePad); + break; + + case "sqrtSize1": + path = sqrtSize1(extraVinculum, hLinePad); + break; + + case "sqrtSize2": + path = sqrtSize2(extraVinculum, hLinePad); + break; + + case "sqrtSize3": + path = sqrtSize3(extraVinculum, hLinePad); + break; + + case "sqrtSize4": + path = sqrtSize4(extraVinculum, hLinePad); + break; + + case "sqrtTall": + path = sqrtTall(extraVinculum, hLinePad, viewBoxHeight); + } + + return path; +}; +var innerPath = function innerPath(name, height) { + // The inner part of stretchy tall delimiters + switch (name) { + case "\u239c": + return "M291 0 H417 V" + height + " H291z M291 0 H417 V" + height + " H291z"; + + case "\u2223": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z"; + + case "\u2225": + return "M145 0 H188 V" + height + " H145z M145 0 H188 V" + height + " H145z" + ("M367 0 H410 V" + height + " H367z M367 0 H410 V" + height + " H367z"); + + case "\u239f": + return "M457 0 H583 V" + height + " H457z M457 0 H583 V" + height + " H457z"; + + case "\u23a2": + return "M319 0 H403 V" + height + " H319z M319 0 H403 V" + height + " H319z"; + + case "\u23a5": + return "M263 0 H347 V" + height + " H263z M263 0 H347 V" + height + " H263z"; + + case "\u23aa": + return "M384 0 H504 V" + height + " H384z M384 0 H504 V" + height + " H384z"; + + case "\u23d0": + return "M312 0 H355 V" + height + " H312z M312 0 H355 V" + height + " H312z"; + + case "\u2016": + return "M257 0 H300 V" + height + " H257z M257 0 H300 V" + height + " H257z" + ("M478 0 H521 V" + height + " H478z M478 0 H521 V" + height + " H478z"); + + default: + return ""; + } +}; +var path$1 = { + // The doubleleftarrow geometry is from glyph U+21D0 in the font KaTeX Main + doubleleftarrow: "M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z", + // doublerightarrow is from glyph U+21D2 in font KaTeX Main + doublerightarrow: "M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z", + // leftarrow is from glyph U+2190 in font KaTeX Main + leftarrow: "M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z", + // overbrace is from glyphs U+23A9/23A8/23A7 in font KaTeX_Size4-Regular + leftbrace: "M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z", + leftbraceunder: "M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z", + // overgroup is from the MnSymbol package (public domain) + leftgroup: "M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z", + leftgroupunder: "M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z", + // Harpoons are from glyph U+21BD in font KaTeX Main + leftharpoon: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z", + leftharpoonplus: "M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z", + leftharpoondown: "M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z", + leftharpoondownplus: "M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z", + // hook is from glyph U+21A9 in font KaTeX Main + lefthook: "M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z", + leftlinesegment: "M40 281 V428 H0 V94 H40 V241 H400000 v40z\nM40 281 V428 H0 V94 H40 V241 H400000 v40z", + leftmapsto: "M40 281 V448H0V74H40V241H400000v40z\nM40 281 V448H0V74H40V241H400000v40z", + // tofrom is from glyph U+21C4 in font KaTeX AMS Regular + leftToFrom: "M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z", + longequal: "M0 50 h400000 v40H0z m0 194h40000v40H0z\nM0 50 h400000 v40H0z m0 194h40000v40H0z", + midbrace: "M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z", + midbraceunder: "M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z", + oiintSize1: "M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z", + oiintSize2: "M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z", + oiiintSize1: "M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z", + oiiintSize2: "M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z", + rightarrow: "M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z", + rightbrace: "M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z", + rightbraceunder: "M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z", + rightgroup: "M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z", + rightgroupunder: "M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z", + rightharpoon: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z", + rightharpoonplus: "M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z", + rightharpoondown: "M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z", + rightharpoondownplus: "M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z", + righthook: "M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z", + rightlinesegment: "M399960 241 V94 h40 V428 h-40 V281 H0 v-40z\nM399960 241 V94 h40 V428 h-40 V281 H0 v-40z", + rightToFrom: "M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z", + // twoheadleftarrow is from glyph U+219E in font KaTeX AMS Regular + twoheadleftarrow: "M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z", + twoheadrightarrow: "M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z", + // tilde1 is a modified version of a glyph from the MnSymbol package + tilde1: "M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z", + // ditto tilde2, tilde3, & tilde4 + tilde2: "M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z", + tilde3: "M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z", + tilde4: "M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z", + // vec is from glyph U+20D7 in font KaTeX Main + vec: "M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z", + // widehat1 is a modified version of a glyph from the MnSymbol package + widehat1: "M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z", + // ditto widehat2, widehat3, & widehat4 + widehat2: "M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat3: "M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + widehat4: "M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z", + // widecheck paths are all inverted versions of widehat + widecheck1: "M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z", + widecheck2: "M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck3: "M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + widecheck4: "M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z", + // The next ten paths support reaction arrows from the mhchem package. + // Arrows for \ce{<-->} are offset from xAxis by 0.22ex, per mhchem in LaTeX + // baraboveleftarrow is mostly from glyph U+2190 in font KaTeX Main + baraboveleftarrow: "M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z", + // rightarrowabovebar is mostly from glyph U+2192, KaTeX Main + rightarrowabovebar: "M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z", + // The short left harpoon has 0.5em (i.e. 500 units) kern on the left end. + // Ref from mhchem.sty: \rlap{\raisebox{-.22ex}{$\kern0.5em + baraboveshortleftharpoon: "M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z", + rightharpoonaboveshortbar: "M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z", + shortbaraboveleftharpoon: "M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z", + shortrightharpoonabovebar: "M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z" +}; +var tallDelim = function tallDelim(label, midHeight) { + switch (label) { + case "lbrack": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v1759 h347 v-84\nH403z M403 1759 V0 H319 V1759 v" + midHeight + " v1759 h84z"; + + case "rbrack": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v" + midHeight + " v1759 h84z"; + + case "vert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z"; + + case "doublevert": + return "M145 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v" + midHeight + " v585 h43z\nM367 15 v585 v" + midHeight + " v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v" + -midHeight + " v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v" + midHeight + " v585 h43z"; + + case "lfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "rfloor": + return "M319 602 V0 H403 V602 v" + midHeight + " v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v" + midHeight + " v1715 H319z"; + + case "lceil": + return "M403 1759 V84 H666 V0 H319 V1759 v" + midHeight + " v602 h84z\nM403 1759 V0 H319 V1759 v" + midHeight + " v602 h84z"; + + case "rceil": + return "M347 1759 V0 H0 V84 H263 V1759 v" + midHeight + " v602 h84z\nM347 1759 V0 h-84 V1759 v" + midHeight + " v602 h84z"; + + case "lparen": + return "M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0," + (midHeight + 84) + "c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-" + (midHeight + 92) + "c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z"; + + case "rparen": + return "M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0," + (midHeight + 9) + "\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-" + (midHeight + 144) + "c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z"; + + default: + // We should not ever get here. + throw new Error("Unknown stretchy delimiter."); + } +}; + +/** + * This node represents a document fragment, which contains elements, but when + * placed into the DOM doesn't have any representation itself. It only contains + * children and doesn't have any DOM node properties. + */ +class DocumentFragment { + // HtmlDomNode + // Never used; needed for satisfying interface. + constructor(children) { + this.children = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.children = children; + this.classes = []; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = {}; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + /** Convert the fragment into a node. */ + + + toNode() { + var frag = document.createDocumentFragment(); + + for (var i = 0; i < this.children.length; i++) { + frag.appendChild(this.children[i].toNode()); + } + + return frag; + } + /** Convert the fragment into HTML markup. */ + + + toMarkup() { + var markup = ""; // Simply concatenate the markup for the children together. + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + return markup; + } + /** + * Converts the math node into a string, similar to innerText. Applies to + * MathDomNode's only. + */ + + + toText() { + // To avoid this, we would subclass documentFragment separately for + // MathML, but polyfills for subclassing is expensive per PR 1469. + // $FlowFixMe: Only works for ChildType = MathDomNode. + var toText = child => child.toText(); + + return this.children.map(toText).join(""); + } + +} + +// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY. +var fontMetricsData = { + "AMS-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68889, 0, 0, 0.72222], + "66": [0, 0.68889, 0, 0, 0.66667], + "67": [0, 0.68889, 0, 0, 0.72222], + "68": [0, 0.68889, 0, 0, 0.72222], + "69": [0, 0.68889, 0, 0, 0.66667], + "70": [0, 0.68889, 0, 0, 0.61111], + "71": [0, 0.68889, 0, 0, 0.77778], + "72": [0, 0.68889, 0, 0, 0.77778], + "73": [0, 0.68889, 0, 0, 0.38889], + "74": [0.16667, 0.68889, 0, 0, 0.5], + "75": [0, 0.68889, 0, 0, 0.77778], + "76": [0, 0.68889, 0, 0, 0.66667], + "77": [0, 0.68889, 0, 0, 0.94445], + "78": [0, 0.68889, 0, 0, 0.72222], + "79": [0.16667, 0.68889, 0, 0, 0.77778], + "80": [0, 0.68889, 0, 0, 0.61111], + "81": [0.16667, 0.68889, 0, 0, 0.77778], + "82": [0, 0.68889, 0, 0, 0.72222], + "83": [0, 0.68889, 0, 0, 0.55556], + "84": [0, 0.68889, 0, 0, 0.66667], + "85": [0, 0.68889, 0, 0, 0.72222], + "86": [0, 0.68889, 0, 0, 0.72222], + "87": [0, 0.68889, 0, 0, 1.0], + "88": [0, 0.68889, 0, 0, 0.72222], + "89": [0, 0.68889, 0, 0, 0.72222], + "90": [0, 0.68889, 0, 0, 0.66667], + "107": [0, 0.68889, 0, 0, 0.55556], + "160": [0, 0, 0, 0, 0.25], + "165": [0, 0.675, 0.025, 0, 0.75], + "174": [0.15559, 0.69224, 0, 0, 0.94666], + "240": [0, 0.68889, 0, 0, 0.55556], + "295": [0, 0.68889, 0, 0, 0.54028], + "710": [0, 0.825, 0, 0, 2.33334], + "732": [0, 0.9, 0, 0, 2.33334], + "770": [0, 0.825, 0, 0, 2.33334], + "771": [0, 0.9, 0, 0, 2.33334], + "989": [0.08167, 0.58167, 0, 0, 0.77778], + "1008": [0, 0.43056, 0.04028, 0, 0.66667], + "8245": [0, 0.54986, 0, 0, 0.275], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8487": [0, 0.68889, 0, 0, 0.72222], + "8498": [0, 0.68889, 0, 0, 0.55556], + "8502": [0, 0.68889, 0, 0, 0.66667], + "8503": [0, 0.68889, 0, 0, 0.44445], + "8504": [0, 0.68889, 0, 0, 0.66667], + "8513": [0, 0.68889, 0, 0, 0.63889], + "8592": [-0.03598, 0.46402, 0, 0, 0.5], + "8594": [-0.03598, 0.46402, 0, 0, 0.5], + "8602": [-0.13313, 0.36687, 0, 0, 1.0], + "8603": [-0.13313, 0.36687, 0, 0, 1.0], + "8606": [0.01354, 0.52239, 0, 0, 1.0], + "8608": [0.01354, 0.52239, 0, 0, 1.0], + "8610": [0.01354, 0.52239, 0, 0, 1.11111], + "8611": [0.01354, 0.52239, 0, 0, 1.11111], + "8619": [0, 0.54986, 0, 0, 1.0], + "8620": [0, 0.54986, 0, 0, 1.0], + "8621": [-0.13313, 0.37788, 0, 0, 1.38889], + "8622": [-0.13313, 0.36687, 0, 0, 1.0], + "8624": [0, 0.69224, 0, 0, 0.5], + "8625": [0, 0.69224, 0, 0, 0.5], + "8630": [0, 0.43056, 0, 0, 1.0], + "8631": [0, 0.43056, 0, 0, 1.0], + "8634": [0.08198, 0.58198, 0, 0, 0.77778], + "8635": [0.08198, 0.58198, 0, 0, 0.77778], + "8638": [0.19444, 0.69224, 0, 0, 0.41667], + "8639": [0.19444, 0.69224, 0, 0, 0.41667], + "8642": [0.19444, 0.69224, 0, 0, 0.41667], + "8643": [0.19444, 0.69224, 0, 0, 0.41667], + "8644": [0.1808, 0.675, 0, 0, 1.0], + "8646": [0.1808, 0.675, 0, 0, 1.0], + "8647": [0.1808, 0.675, 0, 0, 1.0], + "8648": [0.19444, 0.69224, 0, 0, 0.83334], + "8649": [0.1808, 0.675, 0, 0, 1.0], + "8650": [0.19444, 0.69224, 0, 0, 0.83334], + "8651": [0.01354, 0.52239, 0, 0, 1.0], + "8652": [0.01354, 0.52239, 0, 0, 1.0], + "8653": [-0.13313, 0.36687, 0, 0, 1.0], + "8654": [-0.13313, 0.36687, 0, 0, 1.0], + "8655": [-0.13313, 0.36687, 0, 0, 1.0], + "8666": [0.13667, 0.63667, 0, 0, 1.0], + "8667": [0.13667, 0.63667, 0, 0, 1.0], + "8669": [-0.13313, 0.37788, 0, 0, 1.0], + "8672": [-0.064, 0.437, 0, 0, 1.334], + "8674": [-0.064, 0.437, 0, 0, 1.334], + "8705": [0, 0.825, 0, 0, 0.5], + "8708": [0, 0.68889, 0, 0, 0.55556], + "8709": [0.08167, 0.58167, 0, 0, 0.77778], + "8717": [0, 0.43056, 0, 0, 0.42917], + "8722": [-0.03598, 0.46402, 0, 0, 0.5], + "8724": [0.08198, 0.69224, 0, 0, 0.77778], + "8726": [0.08167, 0.58167, 0, 0, 0.77778], + "8733": [0, 0.69224, 0, 0, 0.77778], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8737": [0, 0.69224, 0, 0, 0.72222], + "8738": [0.03517, 0.52239, 0, 0, 0.72222], + "8739": [0.08167, 0.58167, 0, 0, 0.22222], + "8740": [0.25142, 0.74111, 0, 0, 0.27778], + "8741": [0.08167, 0.58167, 0, 0, 0.38889], + "8742": [0.25142, 0.74111, 0, 0, 0.5], + "8756": [0, 0.69224, 0, 0, 0.66667], + "8757": [0, 0.69224, 0, 0, 0.66667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8765": [-0.13313, 0.37788, 0, 0, 0.77778], + "8769": [-0.13313, 0.36687, 0, 0, 0.77778], + "8770": [-0.03625, 0.46375, 0, 0, 0.77778], + "8774": [0.30274, 0.79383, 0, 0, 0.77778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8778": [0.08167, 0.58167, 0, 0, 0.77778], + "8782": [0.06062, 0.54986, 0, 0, 0.77778], + "8783": [0.06062, 0.54986, 0, 0, 0.77778], + "8785": [0.08198, 0.58198, 0, 0, 0.77778], + "8786": [0.08198, 0.58198, 0, 0, 0.77778], + "8787": [0.08198, 0.58198, 0, 0, 0.77778], + "8790": [0, 0.69224, 0, 0, 0.77778], + "8791": [0.22958, 0.72958, 0, 0, 0.77778], + "8796": [0.08198, 0.91667, 0, 0, 0.77778], + "8806": [0.25583, 0.75583, 0, 0, 0.77778], + "8807": [0.25583, 0.75583, 0, 0, 0.77778], + "8808": [0.25142, 0.75726, 0, 0, 0.77778], + "8809": [0.25142, 0.75726, 0, 0, 0.77778], + "8812": [0.25583, 0.75583, 0, 0, 0.5], + "8814": [0.20576, 0.70576, 0, 0, 0.77778], + "8815": [0.20576, 0.70576, 0, 0, 0.77778], + "8816": [0.30274, 0.79383, 0, 0, 0.77778], + "8817": [0.30274, 0.79383, 0, 0, 0.77778], + "8818": [0.22958, 0.72958, 0, 0, 0.77778], + "8819": [0.22958, 0.72958, 0, 0, 0.77778], + "8822": [0.1808, 0.675, 0, 0, 0.77778], + "8823": [0.1808, 0.675, 0, 0, 0.77778], + "8828": [0.13667, 0.63667, 0, 0, 0.77778], + "8829": [0.13667, 0.63667, 0, 0, 0.77778], + "8830": [0.22958, 0.72958, 0, 0, 0.77778], + "8831": [0.22958, 0.72958, 0, 0, 0.77778], + "8832": [0.20576, 0.70576, 0, 0, 0.77778], + "8833": [0.20576, 0.70576, 0, 0, 0.77778], + "8840": [0.30274, 0.79383, 0, 0, 0.77778], + "8841": [0.30274, 0.79383, 0, 0, 0.77778], + "8842": [0.13597, 0.63597, 0, 0, 0.77778], + "8843": [0.13597, 0.63597, 0, 0, 0.77778], + "8847": [0.03517, 0.54986, 0, 0, 0.77778], + "8848": [0.03517, 0.54986, 0, 0, 0.77778], + "8858": [0.08198, 0.58198, 0, 0, 0.77778], + "8859": [0.08198, 0.58198, 0, 0, 0.77778], + "8861": [0.08198, 0.58198, 0, 0, 0.77778], + "8862": [0, 0.675, 0, 0, 0.77778], + "8863": [0, 0.675, 0, 0, 0.77778], + "8864": [0, 0.675, 0, 0, 0.77778], + "8865": [0, 0.675, 0, 0, 0.77778], + "8872": [0, 0.69224, 0, 0, 0.61111], + "8873": [0, 0.69224, 0, 0, 0.72222], + "8874": [0, 0.69224, 0, 0, 0.88889], + "8876": [0, 0.68889, 0, 0, 0.61111], + "8877": [0, 0.68889, 0, 0, 0.61111], + "8878": [0, 0.68889, 0, 0, 0.72222], + "8879": [0, 0.68889, 0, 0, 0.72222], + "8882": [0.03517, 0.54986, 0, 0, 0.77778], + "8883": [0.03517, 0.54986, 0, 0, 0.77778], + "8884": [0.13667, 0.63667, 0, 0, 0.77778], + "8885": [0.13667, 0.63667, 0, 0, 0.77778], + "8888": [0, 0.54986, 0, 0, 1.11111], + "8890": [0.19444, 0.43056, 0, 0, 0.55556], + "8891": [0.19444, 0.69224, 0, 0, 0.61111], + "8892": [0.19444, 0.69224, 0, 0, 0.61111], + "8901": [0, 0.54986, 0, 0, 0.27778], + "8903": [0.08167, 0.58167, 0, 0, 0.77778], + "8905": [0.08167, 0.58167, 0, 0, 0.77778], + "8906": [0.08167, 0.58167, 0, 0, 0.77778], + "8907": [0, 0.69224, 0, 0, 0.77778], + "8908": [0, 0.69224, 0, 0, 0.77778], + "8909": [-0.03598, 0.46402, 0, 0, 0.77778], + "8910": [0, 0.54986, 0, 0, 0.76042], + "8911": [0, 0.54986, 0, 0, 0.76042], + "8912": [0.03517, 0.54986, 0, 0, 0.77778], + "8913": [0.03517, 0.54986, 0, 0, 0.77778], + "8914": [0, 0.54986, 0, 0, 0.66667], + "8915": [0, 0.54986, 0, 0, 0.66667], + "8916": [0, 0.69224, 0, 0, 0.66667], + "8918": [0.0391, 0.5391, 0, 0, 0.77778], + "8919": [0.0391, 0.5391, 0, 0, 0.77778], + "8920": [0.03517, 0.54986, 0, 0, 1.33334], + "8921": [0.03517, 0.54986, 0, 0, 1.33334], + "8922": [0.38569, 0.88569, 0, 0, 0.77778], + "8923": [0.38569, 0.88569, 0, 0, 0.77778], + "8926": [0.13667, 0.63667, 0, 0, 0.77778], + "8927": [0.13667, 0.63667, 0, 0, 0.77778], + "8928": [0.30274, 0.79383, 0, 0, 0.77778], + "8929": [0.30274, 0.79383, 0, 0, 0.77778], + "8934": [0.23222, 0.74111, 0, 0, 0.77778], + "8935": [0.23222, 0.74111, 0, 0, 0.77778], + "8936": [0.23222, 0.74111, 0, 0, 0.77778], + "8937": [0.23222, 0.74111, 0, 0, 0.77778], + "8938": [0.20576, 0.70576, 0, 0, 0.77778], + "8939": [0.20576, 0.70576, 0, 0, 0.77778], + "8940": [0.30274, 0.79383, 0, 0, 0.77778], + "8941": [0.30274, 0.79383, 0, 0, 0.77778], + "8994": [0.19444, 0.69224, 0, 0, 0.77778], + "8995": [0.19444, 0.69224, 0, 0, 0.77778], + "9416": [0.15559, 0.69224, 0, 0, 0.90222], + "9484": [0, 0.69224, 0, 0, 0.5], + "9488": [0, 0.69224, 0, 0, 0.5], + "9492": [0, 0.37788, 0, 0, 0.5], + "9496": [0, 0.37788, 0, 0, 0.5], + "9585": [0.19444, 0.68889, 0, 0, 0.88889], + "9586": [0.19444, 0.74111, 0, 0, 0.88889], + "9632": [0, 0.675, 0, 0, 0.77778], + "9633": [0, 0.675, 0, 0, 0.77778], + "9650": [0, 0.54986, 0, 0, 0.72222], + "9651": [0, 0.54986, 0, 0, 0.72222], + "9654": [0.03517, 0.54986, 0, 0, 0.77778], + "9660": [0, 0.54986, 0, 0, 0.72222], + "9661": [0, 0.54986, 0, 0, 0.72222], + "9664": [0.03517, 0.54986, 0, 0, 0.77778], + "9674": [0.11111, 0.69224, 0, 0, 0.66667], + "9733": [0.19444, 0.69224, 0, 0, 0.94445], + "10003": [0, 0.69224, 0, 0, 0.83334], + "10016": [0, 0.69224, 0, 0, 0.83334], + "10731": [0.11111, 0.69224, 0, 0, 0.66667], + "10846": [0.19444, 0.75583, 0, 0, 0.61111], + "10877": [0.13667, 0.63667, 0, 0, 0.77778], + "10878": [0.13667, 0.63667, 0, 0, 0.77778], + "10885": [0.25583, 0.75583, 0, 0, 0.77778], + "10886": [0.25583, 0.75583, 0, 0, 0.77778], + "10887": [0.13597, 0.63597, 0, 0, 0.77778], + "10888": [0.13597, 0.63597, 0, 0, 0.77778], + "10889": [0.26167, 0.75726, 0, 0, 0.77778], + "10890": [0.26167, 0.75726, 0, 0, 0.77778], + "10891": [0.48256, 0.98256, 0, 0, 0.77778], + "10892": [0.48256, 0.98256, 0, 0, 0.77778], + "10901": [0.13667, 0.63667, 0, 0, 0.77778], + "10902": [0.13667, 0.63667, 0, 0, 0.77778], + "10933": [0.25142, 0.75726, 0, 0, 0.77778], + "10934": [0.25142, 0.75726, 0, 0, 0.77778], + "10935": [0.26167, 0.75726, 0, 0, 0.77778], + "10936": [0.26167, 0.75726, 0, 0, 0.77778], + "10937": [0.26167, 0.75726, 0, 0, 0.77778], + "10938": [0.26167, 0.75726, 0, 0, 0.77778], + "10949": [0.25583, 0.75583, 0, 0, 0.77778], + "10950": [0.25583, 0.75583, 0, 0, 0.77778], + "10955": [0.28481, 0.79383, 0, 0, 0.77778], + "10956": [0.28481, 0.79383, 0, 0, 0.77778], + "57350": [0.08167, 0.58167, 0, 0, 0.22222], + "57351": [0.08167, 0.58167, 0, 0, 0.38889], + "57352": [0.08167, 0.58167, 0, 0, 0.77778], + "57353": [0, 0.43056, 0.04028, 0, 0.66667], + "57356": [0.25142, 0.75726, 0, 0, 0.77778], + "57357": [0.25142, 0.75726, 0, 0, 0.77778], + "57358": [0.41951, 0.91951, 0, 0, 0.77778], + "57359": [0.30274, 0.79383, 0, 0, 0.77778], + "57360": [0.30274, 0.79383, 0, 0, 0.77778], + "57361": [0.41951, 0.91951, 0, 0, 0.77778], + "57366": [0.25142, 0.75726, 0, 0, 0.77778], + "57367": [0.25142, 0.75726, 0, 0, 0.77778], + "57368": [0.25142, 0.75726, 0, 0, 0.77778], + "57369": [0.25142, 0.75726, 0, 0, 0.77778], + "57370": [0.13597, 0.63597, 0, 0, 0.77778], + "57371": [0.13597, 0.63597, 0, 0, 0.77778] + }, + "Caligraphic-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.68333, 0, 0.19445, 0.79847], + "66": [0, 0.68333, 0.03041, 0.13889, 0.65681], + "67": [0, 0.68333, 0.05834, 0.13889, 0.52653], + "68": [0, 0.68333, 0.02778, 0.08334, 0.77139], + "69": [0, 0.68333, 0.08944, 0.11111, 0.52778], + "70": [0, 0.68333, 0.09931, 0.11111, 0.71875], + "71": [0.09722, 0.68333, 0.0593, 0.11111, 0.59487], + "72": [0, 0.68333, 0.00965, 0.11111, 0.84452], + "73": [0, 0.68333, 0.07382, 0, 0.54452], + "74": [0.09722, 0.68333, 0.18472, 0.16667, 0.67778], + "75": [0, 0.68333, 0.01445, 0.05556, 0.76195], + "76": [0, 0.68333, 0, 0.13889, 0.68972], + "77": [0, 0.68333, 0, 0.13889, 1.2009], + "78": [0, 0.68333, 0.14736, 0.08334, 0.82049], + "79": [0, 0.68333, 0.02778, 0.11111, 0.79611], + "80": [0, 0.68333, 0.08222, 0.08334, 0.69556], + "81": [0.09722, 0.68333, 0, 0.11111, 0.81667], + "82": [0, 0.68333, 0, 0.08334, 0.8475], + "83": [0, 0.68333, 0.075, 0.13889, 0.60556], + "84": [0, 0.68333, 0.25417, 0, 0.54464], + "85": [0, 0.68333, 0.09931, 0.08334, 0.62583], + "86": [0, 0.68333, 0.08222, 0, 0.61278], + "87": [0, 0.68333, 0.08222, 0.08334, 0.98778], + "88": [0, 0.68333, 0.14643, 0.13889, 0.7133], + "89": [0.09722, 0.68333, 0.08222, 0.08334, 0.66834], + "90": [0, 0.68333, 0.07944, 0.13889, 0.72473], + "160": [0, 0, 0, 0, 0.25] + }, + "Fraktur-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69141, 0, 0, 0.29574], + "34": [0, 0.69141, 0, 0, 0.21471], + "38": [0, 0.69141, 0, 0, 0.73786], + "39": [0, 0.69141, 0, 0, 0.21201], + "40": [0.24982, 0.74947, 0, 0, 0.38865], + "41": [0.24982, 0.74947, 0, 0, 0.38865], + "42": [0, 0.62119, 0, 0, 0.27764], + "43": [0.08319, 0.58283, 0, 0, 0.75623], + "44": [0, 0.10803, 0, 0, 0.27764], + "45": [0.08319, 0.58283, 0, 0, 0.75623], + "46": [0, 0.10803, 0, 0, 0.27764], + "47": [0.24982, 0.74947, 0, 0, 0.50181], + "48": [0, 0.47534, 0, 0, 0.50181], + "49": [0, 0.47534, 0, 0, 0.50181], + "50": [0, 0.47534, 0, 0, 0.50181], + "51": [0.18906, 0.47534, 0, 0, 0.50181], + "52": [0.18906, 0.47534, 0, 0, 0.50181], + "53": [0.18906, 0.47534, 0, 0, 0.50181], + "54": [0, 0.69141, 0, 0, 0.50181], + "55": [0.18906, 0.47534, 0, 0, 0.50181], + "56": [0, 0.69141, 0, 0, 0.50181], + "57": [0.18906, 0.47534, 0, 0, 0.50181], + "58": [0, 0.47534, 0, 0, 0.21606], + "59": [0.12604, 0.47534, 0, 0, 0.21606], + "61": [-0.13099, 0.36866, 0, 0, 0.75623], + "63": [0, 0.69141, 0, 0, 0.36245], + "65": [0, 0.69141, 0, 0, 0.7176], + "66": [0, 0.69141, 0, 0, 0.88397], + "67": [0, 0.69141, 0, 0, 0.61254], + "68": [0, 0.69141, 0, 0, 0.83158], + "69": [0, 0.69141, 0, 0, 0.66278], + "70": [0.12604, 0.69141, 0, 0, 0.61119], + "71": [0, 0.69141, 0, 0, 0.78539], + "72": [0.06302, 0.69141, 0, 0, 0.7203], + "73": [0, 0.69141, 0, 0, 0.55448], + "74": [0.12604, 0.69141, 0, 0, 0.55231], + "75": [0, 0.69141, 0, 0, 0.66845], + "76": [0, 0.69141, 0, 0, 0.66602], + "77": [0, 0.69141, 0, 0, 1.04953], + "78": [0, 0.69141, 0, 0, 0.83212], + "79": [0, 0.69141, 0, 0, 0.82699], + "80": [0.18906, 0.69141, 0, 0, 0.82753], + "81": [0.03781, 0.69141, 0, 0, 0.82699], + "82": [0, 0.69141, 0, 0, 0.82807], + "83": [0, 0.69141, 0, 0, 0.82861], + "84": [0, 0.69141, 0, 0, 0.66899], + "85": [0, 0.69141, 0, 0, 0.64576], + "86": [0, 0.69141, 0, 0, 0.83131], + "87": [0, 0.69141, 0, 0, 1.04602], + "88": [0, 0.69141, 0, 0, 0.71922], + "89": [0.18906, 0.69141, 0, 0, 0.83293], + "90": [0.12604, 0.69141, 0, 0, 0.60201], + "91": [0.24982, 0.74947, 0, 0, 0.27764], + "93": [0.24982, 0.74947, 0, 0, 0.27764], + "94": [0, 0.69141, 0, 0, 0.49965], + "97": [0, 0.47534, 0, 0, 0.50046], + "98": [0, 0.69141, 0, 0, 0.51315], + "99": [0, 0.47534, 0, 0, 0.38946], + "100": [0, 0.62119, 0, 0, 0.49857], + "101": [0, 0.47534, 0, 0, 0.40053], + "102": [0.18906, 0.69141, 0, 0, 0.32626], + "103": [0.18906, 0.47534, 0, 0, 0.5037], + "104": [0.18906, 0.69141, 0, 0, 0.52126], + "105": [0, 0.69141, 0, 0, 0.27899], + "106": [0, 0.69141, 0, 0, 0.28088], + "107": [0, 0.69141, 0, 0, 0.38946], + "108": [0, 0.69141, 0, 0, 0.27953], + "109": [0, 0.47534, 0, 0, 0.76676], + "110": [0, 0.47534, 0, 0, 0.52666], + "111": [0, 0.47534, 0, 0, 0.48885], + "112": [0.18906, 0.52396, 0, 0, 0.50046], + "113": [0.18906, 0.47534, 0, 0, 0.48912], + "114": [0, 0.47534, 0, 0, 0.38919], + "115": [0, 0.47534, 0, 0, 0.44266], + "116": [0, 0.62119, 0, 0, 0.33301], + "117": [0, 0.47534, 0, 0, 0.5172], + "118": [0, 0.52396, 0, 0, 0.5118], + "119": [0, 0.52396, 0, 0, 0.77351], + "120": [0.18906, 0.47534, 0, 0, 0.38865], + "121": [0.18906, 0.47534, 0, 0, 0.49884], + "122": [0.18906, 0.47534, 0, 0, 0.39054], + "160": [0, 0, 0, 0, 0.25], + "8216": [0, 0.69141, 0, 0, 0.21471], + "8217": [0, 0.69141, 0, 0, 0.21471], + "58112": [0, 0.62119, 0, 0, 0.49749], + "58113": [0, 0.62119, 0, 0, 0.4983], + "58114": [0.18906, 0.69141, 0, 0, 0.33328], + "58115": [0.18906, 0.69141, 0, 0, 0.32923], + "58116": [0.18906, 0.47534, 0, 0, 0.50343], + "58117": [0, 0.69141, 0, 0, 0.33301], + "58118": [0, 0.62119, 0, 0, 0.33409], + "58119": [0, 0.47534, 0, 0, 0.50073] + }, + "Main-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.35], + "34": [0, 0.69444, 0, 0, 0.60278], + "35": [0.19444, 0.69444, 0, 0, 0.95833], + "36": [0.05556, 0.75, 0, 0, 0.575], + "37": [0.05556, 0.75, 0, 0, 0.95833], + "38": [0, 0.69444, 0, 0, 0.89444], + "39": [0, 0.69444, 0, 0, 0.31944], + "40": [0.25, 0.75, 0, 0, 0.44722], + "41": [0.25, 0.75, 0, 0, 0.44722], + "42": [0, 0.75, 0, 0, 0.575], + "43": [0.13333, 0.63333, 0, 0, 0.89444], + "44": [0.19444, 0.15556, 0, 0, 0.31944], + "45": [0, 0.44444, 0, 0, 0.38333], + "46": [0, 0.15556, 0, 0, 0.31944], + "47": [0.25, 0.75, 0, 0, 0.575], + "48": [0, 0.64444, 0, 0, 0.575], + "49": [0, 0.64444, 0, 0, 0.575], + "50": [0, 0.64444, 0, 0, 0.575], + "51": [0, 0.64444, 0, 0, 0.575], + "52": [0, 0.64444, 0, 0, 0.575], + "53": [0, 0.64444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0, 0.64444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0, 0.64444, 0, 0, 0.575], + "58": [0, 0.44444, 0, 0, 0.31944], + "59": [0.19444, 0.44444, 0, 0, 0.31944], + "60": [0.08556, 0.58556, 0, 0, 0.89444], + "61": [-0.10889, 0.39111, 0, 0, 0.89444], + "62": [0.08556, 0.58556, 0, 0, 0.89444], + "63": [0, 0.69444, 0, 0, 0.54305], + "64": [0, 0.69444, 0, 0, 0.89444], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0, 0, 0.81805], + "67": [0, 0.68611, 0, 0, 0.83055], + "68": [0, 0.68611, 0, 0, 0.88194], + "69": [0, 0.68611, 0, 0, 0.75555], + "70": [0, 0.68611, 0, 0, 0.72361], + "71": [0, 0.68611, 0, 0, 0.90416], + "72": [0, 0.68611, 0, 0, 0.9], + "73": [0, 0.68611, 0, 0, 0.43611], + "74": [0, 0.68611, 0, 0, 0.59444], + "75": [0, 0.68611, 0, 0, 0.90138], + "76": [0, 0.68611, 0, 0, 0.69166], + "77": [0, 0.68611, 0, 0, 1.09166], + "78": [0, 0.68611, 0, 0, 0.9], + "79": [0, 0.68611, 0, 0, 0.86388], + "80": [0, 0.68611, 0, 0, 0.78611], + "81": [0.19444, 0.68611, 0, 0, 0.86388], + "82": [0, 0.68611, 0, 0, 0.8625], + "83": [0, 0.68611, 0, 0, 0.63889], + "84": [0, 0.68611, 0, 0, 0.8], + "85": [0, 0.68611, 0, 0, 0.88472], + "86": [0, 0.68611, 0.01597, 0, 0.86944], + "87": [0, 0.68611, 0.01597, 0, 1.18888], + "88": [0, 0.68611, 0, 0, 0.86944], + "89": [0, 0.68611, 0.02875, 0, 0.86944], + "90": [0, 0.68611, 0, 0, 0.70277], + "91": [0.25, 0.75, 0, 0, 0.31944], + "92": [0.25, 0.75, 0, 0, 0.575], + "93": [0.25, 0.75, 0, 0, 0.31944], + "94": [0, 0.69444, 0, 0, 0.575], + "95": [0.31, 0.13444, 0.03194, 0, 0.575], + "97": [0, 0.44444, 0, 0, 0.55902], + "98": [0, 0.69444, 0, 0, 0.63889], + "99": [0, 0.44444, 0, 0, 0.51111], + "100": [0, 0.69444, 0, 0, 0.63889], + "101": [0, 0.44444, 0, 0, 0.52708], + "102": [0, 0.69444, 0.10903, 0, 0.35139], + "103": [0.19444, 0.44444, 0.01597, 0, 0.575], + "104": [0, 0.69444, 0, 0, 0.63889], + "105": [0, 0.69444, 0, 0, 0.31944], + "106": [0.19444, 0.69444, 0, 0, 0.35139], + "107": [0, 0.69444, 0, 0, 0.60694], + "108": [0, 0.69444, 0, 0, 0.31944], + "109": [0, 0.44444, 0, 0, 0.95833], + "110": [0, 0.44444, 0, 0, 0.63889], + "111": [0, 0.44444, 0, 0, 0.575], + "112": [0.19444, 0.44444, 0, 0, 0.63889], + "113": [0.19444, 0.44444, 0, 0, 0.60694], + "114": [0, 0.44444, 0, 0, 0.47361], + "115": [0, 0.44444, 0, 0, 0.45361], + "116": [0, 0.63492, 0, 0, 0.44722], + "117": [0, 0.44444, 0, 0, 0.63889], + "118": [0, 0.44444, 0.01597, 0, 0.60694], + "119": [0, 0.44444, 0.01597, 0, 0.83055], + "120": [0, 0.44444, 0, 0, 0.60694], + "121": [0.19444, 0.44444, 0.01597, 0, 0.60694], + "122": [0, 0.44444, 0, 0, 0.51111], + "123": [0.25, 0.75, 0, 0, 0.575], + "124": [0.25, 0.75, 0, 0, 0.31944], + "125": [0.25, 0.75, 0, 0, 0.575], + "126": [0.35, 0.34444, 0, 0, 0.575], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.86853], + "168": [0, 0.69444, 0, 0, 0.575], + "172": [0, 0.44444, 0, 0, 0.76666], + "176": [0, 0.69444, 0, 0, 0.86944], + "177": [0.13333, 0.63333, 0, 0, 0.89444], + "184": [0.17014, 0, 0, 0, 0.51111], + "198": [0, 0.68611, 0, 0, 1.04166], + "215": [0.13333, 0.63333, 0, 0, 0.89444], + "216": [0.04861, 0.73472, 0, 0, 0.89444], + "223": [0, 0.69444, 0, 0, 0.59722], + "230": [0, 0.44444, 0, 0, 0.83055], + "247": [0.13333, 0.63333, 0, 0, 0.89444], + "248": [0.09722, 0.54167, 0, 0, 0.575], + "305": [0, 0.44444, 0, 0, 0.31944], + "338": [0, 0.68611, 0, 0, 1.16944], + "339": [0, 0.44444, 0, 0, 0.89444], + "567": [0.19444, 0.44444, 0, 0, 0.35139], + "710": [0, 0.69444, 0, 0, 0.575], + "711": [0, 0.63194, 0, 0, 0.575], + "713": [0, 0.59611, 0, 0, 0.575], + "714": [0, 0.69444, 0, 0, 0.575], + "715": [0, 0.69444, 0, 0, 0.575], + "728": [0, 0.69444, 0, 0, 0.575], + "729": [0, 0.69444, 0, 0, 0.31944], + "730": [0, 0.69444, 0, 0, 0.86944], + "732": [0, 0.69444, 0, 0, 0.575], + "733": [0, 0.69444, 0, 0, 0.575], + "915": [0, 0.68611, 0, 0, 0.69166], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0, 0, 0.89444], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0, 0, 0.76666], + "928": [0, 0.68611, 0, 0, 0.9], + "931": [0, 0.68611, 0, 0, 0.83055], + "933": [0, 0.68611, 0, 0, 0.89444], + "934": [0, 0.68611, 0, 0, 0.83055], + "936": [0, 0.68611, 0, 0, 0.89444], + "937": [0, 0.68611, 0, 0, 0.83055], + "8211": [0, 0.44444, 0.03194, 0, 0.575], + "8212": [0, 0.44444, 0.03194, 0, 1.14999], + "8216": [0, 0.69444, 0, 0, 0.31944], + "8217": [0, 0.69444, 0, 0, 0.31944], + "8220": [0, 0.69444, 0, 0, 0.60278], + "8221": [0, 0.69444, 0, 0, 0.60278], + "8224": [0.19444, 0.69444, 0, 0, 0.51111], + "8225": [0.19444, 0.69444, 0, 0, 0.51111], + "8242": [0, 0.55556, 0, 0, 0.34444], + "8407": [0, 0.72444, 0.15486, 0, 0.575], + "8463": [0, 0.69444, 0, 0, 0.66759], + "8465": [0, 0.69444, 0, 0, 0.83055], + "8467": [0, 0.69444, 0, 0, 0.47361], + "8472": [0.19444, 0.44444, 0, 0, 0.74027], + "8476": [0, 0.69444, 0, 0, 0.83055], + "8501": [0, 0.69444, 0, 0, 0.70277], + "8592": [-0.10889, 0.39111, 0, 0, 1.14999], + "8593": [0.19444, 0.69444, 0, 0, 0.575], + "8594": [-0.10889, 0.39111, 0, 0, 1.14999], + "8595": [0.19444, 0.69444, 0, 0, 0.575], + "8596": [-0.10889, 0.39111, 0, 0, 1.14999], + "8597": [0.25, 0.75, 0, 0, 0.575], + "8598": [0.19444, 0.69444, 0, 0, 1.14999], + "8599": [0.19444, 0.69444, 0, 0, 1.14999], + "8600": [0.19444, 0.69444, 0, 0, 1.14999], + "8601": [0.19444, 0.69444, 0, 0, 1.14999], + "8636": [-0.10889, 0.39111, 0, 0, 1.14999], + "8637": [-0.10889, 0.39111, 0, 0, 1.14999], + "8640": [-0.10889, 0.39111, 0, 0, 1.14999], + "8641": [-0.10889, 0.39111, 0, 0, 1.14999], + "8656": [-0.10889, 0.39111, 0, 0, 1.14999], + "8657": [0.19444, 0.69444, 0, 0, 0.70277], + "8658": [-0.10889, 0.39111, 0, 0, 1.14999], + "8659": [0.19444, 0.69444, 0, 0, 0.70277], + "8660": [-0.10889, 0.39111, 0, 0, 1.14999], + "8661": [0.25, 0.75, 0, 0, 0.70277], + "8704": [0, 0.69444, 0, 0, 0.63889], + "8706": [0, 0.69444, 0.06389, 0, 0.62847], + "8707": [0, 0.69444, 0, 0, 0.63889], + "8709": [0.05556, 0.75, 0, 0, 0.575], + "8711": [0, 0.68611, 0, 0, 0.95833], + "8712": [0.08556, 0.58556, 0, 0, 0.76666], + "8715": [0.08556, 0.58556, 0, 0, 0.76666], + "8722": [0.13333, 0.63333, 0, 0, 0.89444], + "8723": [0.13333, 0.63333, 0, 0, 0.89444], + "8725": [0.25, 0.75, 0, 0, 0.575], + "8726": [0.25, 0.75, 0, 0, 0.575], + "8727": [-0.02778, 0.47222, 0, 0, 0.575], + "8728": [-0.02639, 0.47361, 0, 0, 0.575], + "8729": [-0.02639, 0.47361, 0, 0, 0.575], + "8730": [0.18, 0.82, 0, 0, 0.95833], + "8733": [0, 0.44444, 0, 0, 0.89444], + "8734": [0, 0.44444, 0, 0, 1.14999], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.31944], + "8741": [0.25, 0.75, 0, 0, 0.575], + "8743": [0, 0.55556, 0, 0, 0.76666], + "8744": [0, 0.55556, 0, 0, 0.76666], + "8745": [0, 0.55556, 0, 0, 0.76666], + "8746": [0, 0.55556, 0, 0, 0.76666], + "8747": [0.19444, 0.69444, 0.12778, 0, 0.56875], + "8764": [-0.10889, 0.39111, 0, 0, 0.89444], + "8768": [0.19444, 0.69444, 0, 0, 0.31944], + "8771": [0.00222, 0.50222, 0, 0, 0.89444], + "8773": [0.027, 0.638, 0, 0, 0.894], + "8776": [0.02444, 0.52444, 0, 0, 0.89444], + "8781": [0.00222, 0.50222, 0, 0, 0.89444], + "8801": [0.00222, 0.50222, 0, 0, 0.89444], + "8804": [0.19667, 0.69667, 0, 0, 0.89444], + "8805": [0.19667, 0.69667, 0, 0, 0.89444], + "8810": [0.08556, 0.58556, 0, 0, 1.14999], + "8811": [0.08556, 0.58556, 0, 0, 1.14999], + "8826": [0.08556, 0.58556, 0, 0, 0.89444], + "8827": [0.08556, 0.58556, 0, 0, 0.89444], + "8834": [0.08556, 0.58556, 0, 0, 0.89444], + "8835": [0.08556, 0.58556, 0, 0, 0.89444], + "8838": [0.19667, 0.69667, 0, 0, 0.89444], + "8839": [0.19667, 0.69667, 0, 0, 0.89444], + "8846": [0, 0.55556, 0, 0, 0.76666], + "8849": [0.19667, 0.69667, 0, 0, 0.89444], + "8850": [0.19667, 0.69667, 0, 0, 0.89444], + "8851": [0, 0.55556, 0, 0, 0.76666], + "8852": [0, 0.55556, 0, 0, 0.76666], + "8853": [0.13333, 0.63333, 0, 0, 0.89444], + "8854": [0.13333, 0.63333, 0, 0, 0.89444], + "8855": [0.13333, 0.63333, 0, 0, 0.89444], + "8856": [0.13333, 0.63333, 0, 0, 0.89444], + "8857": [0.13333, 0.63333, 0, 0, 0.89444], + "8866": [0, 0.69444, 0, 0, 0.70277], + "8867": [0, 0.69444, 0, 0, 0.70277], + "8868": [0, 0.69444, 0, 0, 0.89444], + "8869": [0, 0.69444, 0, 0, 0.89444], + "8900": [-0.02639, 0.47361, 0, 0, 0.575], + "8901": [-0.02639, 0.47361, 0, 0, 0.31944], + "8902": [-0.02778, 0.47222, 0, 0, 0.575], + "8968": [0.25, 0.75, 0, 0, 0.51111], + "8969": [0.25, 0.75, 0, 0, 0.51111], + "8970": [0.25, 0.75, 0, 0, 0.51111], + "8971": [0.25, 0.75, 0, 0, 0.51111], + "8994": [-0.13889, 0.36111, 0, 0, 1.14999], + "8995": [-0.13889, 0.36111, 0, 0, 1.14999], + "9651": [0.19444, 0.69444, 0, 0, 1.02222], + "9657": [-0.02778, 0.47222, 0, 0, 0.575], + "9661": [0.19444, 0.69444, 0, 0, 1.02222], + "9667": [-0.02778, 0.47222, 0, 0, 0.575], + "9711": [0.19444, 0.69444, 0, 0, 1.14999], + "9824": [0.12963, 0.69444, 0, 0, 0.89444], + "9825": [0.12963, 0.69444, 0, 0, 0.89444], + "9826": [0.12963, 0.69444, 0, 0, 0.89444], + "9827": [0.12963, 0.69444, 0, 0, 0.89444], + "9837": [0, 0.75, 0, 0, 0.44722], + "9838": [0.19444, 0.69444, 0, 0, 0.44722], + "9839": [0.19444, 0.69444, 0, 0, 0.44722], + "10216": [0.25, 0.75, 0, 0, 0.44722], + "10217": [0.25, 0.75, 0, 0, 0.44722], + "10815": [0, 0.68611, 0, 0, 0.9], + "10927": [0.19667, 0.69667, 0, 0, 0.89444], + "10928": [0.19667, 0.69667, 0, 0, 0.89444], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Main-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.11417, 0, 0.38611], + "34": [0, 0.69444, 0.07939, 0, 0.62055], + "35": [0.19444, 0.69444, 0.06833, 0, 0.94444], + "37": [0.05556, 0.75, 0.12861, 0, 0.94444], + "38": [0, 0.69444, 0.08528, 0, 0.88555], + "39": [0, 0.69444, 0.12945, 0, 0.35555], + "40": [0.25, 0.75, 0.15806, 0, 0.47333], + "41": [0.25, 0.75, 0.03306, 0, 0.47333], + "42": [0, 0.75, 0.14333, 0, 0.59111], + "43": [0.10333, 0.60333, 0.03306, 0, 0.88555], + "44": [0.19444, 0.14722, 0, 0, 0.35555], + "45": [0, 0.44444, 0.02611, 0, 0.41444], + "46": [0, 0.14722, 0, 0, 0.35555], + "47": [0.25, 0.75, 0.15806, 0, 0.59111], + "48": [0, 0.64444, 0.13167, 0, 0.59111], + "49": [0, 0.64444, 0.13167, 0, 0.59111], + "50": [0, 0.64444, 0.13167, 0, 0.59111], + "51": [0, 0.64444, 0.13167, 0, 0.59111], + "52": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "53": [0, 0.64444, 0.13167, 0, 0.59111], + "54": [0, 0.64444, 0.13167, 0, 0.59111], + "55": [0.19444, 0.64444, 0.13167, 0, 0.59111], + "56": [0, 0.64444, 0.13167, 0, 0.59111], + "57": [0, 0.64444, 0.13167, 0, 0.59111], + "58": [0, 0.44444, 0.06695, 0, 0.35555], + "59": [0.19444, 0.44444, 0.06695, 0, 0.35555], + "61": [-0.10889, 0.39111, 0.06833, 0, 0.88555], + "63": [0, 0.69444, 0.11472, 0, 0.59111], + "64": [0, 0.69444, 0.09208, 0, 0.88555], + "65": [0, 0.68611, 0, 0, 0.86555], + "66": [0, 0.68611, 0.0992, 0, 0.81666], + "67": [0, 0.68611, 0.14208, 0, 0.82666], + "68": [0, 0.68611, 0.09062, 0, 0.87555], + "69": [0, 0.68611, 0.11431, 0, 0.75666], + "70": [0, 0.68611, 0.12903, 0, 0.72722], + "71": [0, 0.68611, 0.07347, 0, 0.89527], + "72": [0, 0.68611, 0.17208, 0, 0.8961], + "73": [0, 0.68611, 0.15681, 0, 0.47166], + "74": [0, 0.68611, 0.145, 0, 0.61055], + "75": [0, 0.68611, 0.14208, 0, 0.89499], + "76": [0, 0.68611, 0, 0, 0.69777], + "77": [0, 0.68611, 0.17208, 0, 1.07277], + "78": [0, 0.68611, 0.17208, 0, 0.8961], + "79": [0, 0.68611, 0.09062, 0, 0.85499], + "80": [0, 0.68611, 0.0992, 0, 0.78721], + "81": [0.19444, 0.68611, 0.09062, 0, 0.85499], + "82": [0, 0.68611, 0.02559, 0, 0.85944], + "83": [0, 0.68611, 0.11264, 0, 0.64999], + "84": [0, 0.68611, 0.12903, 0, 0.7961], + "85": [0, 0.68611, 0.17208, 0, 0.88083], + "86": [0, 0.68611, 0.18625, 0, 0.86555], + "87": [0, 0.68611, 0.18625, 0, 1.15999], + "88": [0, 0.68611, 0.15681, 0, 0.86555], + "89": [0, 0.68611, 0.19803, 0, 0.86555], + "90": [0, 0.68611, 0.14208, 0, 0.70888], + "91": [0.25, 0.75, 0.1875, 0, 0.35611], + "93": [0.25, 0.75, 0.09972, 0, 0.35611], + "94": [0, 0.69444, 0.06709, 0, 0.59111], + "95": [0.31, 0.13444, 0.09811, 0, 0.59111], + "97": [0, 0.44444, 0.09426, 0, 0.59111], + "98": [0, 0.69444, 0.07861, 0, 0.53222], + "99": [0, 0.44444, 0.05222, 0, 0.53222], + "100": [0, 0.69444, 0.10861, 0, 0.59111], + "101": [0, 0.44444, 0.085, 0, 0.53222], + "102": [0.19444, 0.69444, 0.21778, 0, 0.4], + "103": [0.19444, 0.44444, 0.105, 0, 0.53222], + "104": [0, 0.69444, 0.09426, 0, 0.59111], + "105": [0, 0.69326, 0.11387, 0, 0.35555], + "106": [0.19444, 0.69326, 0.1672, 0, 0.35555], + "107": [0, 0.69444, 0.11111, 0, 0.53222], + "108": [0, 0.69444, 0.10861, 0, 0.29666], + "109": [0, 0.44444, 0.09426, 0, 0.94444], + "110": [0, 0.44444, 0.09426, 0, 0.64999], + "111": [0, 0.44444, 0.07861, 0, 0.59111], + "112": [0.19444, 0.44444, 0.07861, 0, 0.59111], + "113": [0.19444, 0.44444, 0.105, 0, 0.53222], + "114": [0, 0.44444, 0.11111, 0, 0.50167], + "115": [0, 0.44444, 0.08167, 0, 0.48694], + "116": [0, 0.63492, 0.09639, 0, 0.385], + "117": [0, 0.44444, 0.09426, 0, 0.62055], + "118": [0, 0.44444, 0.11111, 0, 0.53222], + "119": [0, 0.44444, 0.11111, 0, 0.76777], + "120": [0, 0.44444, 0.12583, 0, 0.56055], + "121": [0.19444, 0.44444, 0.105, 0, 0.56166], + "122": [0, 0.44444, 0.13889, 0, 0.49055], + "126": [0.35, 0.34444, 0.11472, 0, 0.59111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0.11473, 0, 0.59111], + "176": [0, 0.69444, 0, 0, 0.94888], + "184": [0.17014, 0, 0, 0, 0.53222], + "198": [0, 0.68611, 0.11431, 0, 1.02277], + "216": [0.04861, 0.73472, 0.09062, 0, 0.88555], + "223": [0.19444, 0.69444, 0.09736, 0, 0.665], + "230": [0, 0.44444, 0.085, 0, 0.82666], + "248": [0.09722, 0.54167, 0.09458, 0, 0.59111], + "305": [0, 0.44444, 0.09426, 0, 0.35555], + "338": [0, 0.68611, 0.11431, 0, 1.14054], + "339": [0, 0.44444, 0.085, 0, 0.82666], + "567": [0.19444, 0.44444, 0.04611, 0, 0.385], + "710": [0, 0.69444, 0.06709, 0, 0.59111], + "711": [0, 0.63194, 0.08271, 0, 0.59111], + "713": [0, 0.59444, 0.10444, 0, 0.59111], + "714": [0, 0.69444, 0.08528, 0, 0.59111], + "715": [0, 0.69444, 0, 0, 0.59111], + "728": [0, 0.69444, 0.10333, 0, 0.59111], + "729": [0, 0.69444, 0.12945, 0, 0.35555], + "730": [0, 0.69444, 0, 0, 0.94888], + "732": [0, 0.69444, 0.11472, 0, 0.59111], + "733": [0, 0.69444, 0.11472, 0, 0.59111], + "915": [0, 0.68611, 0.12903, 0, 0.69777], + "916": [0, 0.68611, 0, 0, 0.94444], + "920": [0, 0.68611, 0.09062, 0, 0.88555], + "923": [0, 0.68611, 0, 0, 0.80666], + "926": [0, 0.68611, 0.15092, 0, 0.76777], + "928": [0, 0.68611, 0.17208, 0, 0.8961], + "931": [0, 0.68611, 0.11431, 0, 0.82666], + "933": [0, 0.68611, 0.10778, 0, 0.88555], + "934": [0, 0.68611, 0.05632, 0, 0.82666], + "936": [0, 0.68611, 0.10778, 0, 0.88555], + "937": [0, 0.68611, 0.0992, 0, 0.82666], + "8211": [0, 0.44444, 0.09811, 0, 0.59111], + "8212": [0, 0.44444, 0.09811, 0, 1.18221], + "8216": [0, 0.69444, 0.12945, 0, 0.35555], + "8217": [0, 0.69444, 0.12945, 0, 0.35555], + "8220": [0, 0.69444, 0.16772, 0, 0.62055], + "8221": [0, 0.69444, 0.07939, 0, 0.62055] + }, + "Main-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.12417, 0, 0.30667], + "34": [0, 0.69444, 0.06961, 0, 0.51444], + "35": [0.19444, 0.69444, 0.06616, 0, 0.81777], + "37": [0.05556, 0.75, 0.13639, 0, 0.81777], + "38": [0, 0.69444, 0.09694, 0, 0.76666], + "39": [0, 0.69444, 0.12417, 0, 0.30667], + "40": [0.25, 0.75, 0.16194, 0, 0.40889], + "41": [0.25, 0.75, 0.03694, 0, 0.40889], + "42": [0, 0.75, 0.14917, 0, 0.51111], + "43": [0.05667, 0.56167, 0.03694, 0, 0.76666], + "44": [0.19444, 0.10556, 0, 0, 0.30667], + "45": [0, 0.43056, 0.02826, 0, 0.35778], + "46": [0, 0.10556, 0, 0, 0.30667], + "47": [0.25, 0.75, 0.16194, 0, 0.51111], + "48": [0, 0.64444, 0.13556, 0, 0.51111], + "49": [0, 0.64444, 0.13556, 0, 0.51111], + "50": [0, 0.64444, 0.13556, 0, 0.51111], + "51": [0, 0.64444, 0.13556, 0, 0.51111], + "52": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "53": [0, 0.64444, 0.13556, 0, 0.51111], + "54": [0, 0.64444, 0.13556, 0, 0.51111], + "55": [0.19444, 0.64444, 0.13556, 0, 0.51111], + "56": [0, 0.64444, 0.13556, 0, 0.51111], + "57": [0, 0.64444, 0.13556, 0, 0.51111], + "58": [0, 0.43056, 0.0582, 0, 0.30667], + "59": [0.19444, 0.43056, 0.0582, 0, 0.30667], + "61": [-0.13313, 0.36687, 0.06616, 0, 0.76666], + "63": [0, 0.69444, 0.1225, 0, 0.51111], + "64": [0, 0.69444, 0.09597, 0, 0.76666], + "65": [0, 0.68333, 0, 0, 0.74333], + "66": [0, 0.68333, 0.10257, 0, 0.70389], + "67": [0, 0.68333, 0.14528, 0, 0.71555], + "68": [0, 0.68333, 0.09403, 0, 0.755], + "69": [0, 0.68333, 0.12028, 0, 0.67833], + "70": [0, 0.68333, 0.13305, 0, 0.65277], + "71": [0, 0.68333, 0.08722, 0, 0.77361], + "72": [0, 0.68333, 0.16389, 0, 0.74333], + "73": [0, 0.68333, 0.15806, 0, 0.38555], + "74": [0, 0.68333, 0.14028, 0, 0.525], + "75": [0, 0.68333, 0.14528, 0, 0.76888], + "76": [0, 0.68333, 0, 0, 0.62722], + "77": [0, 0.68333, 0.16389, 0, 0.89666], + "78": [0, 0.68333, 0.16389, 0, 0.74333], + "79": [0, 0.68333, 0.09403, 0, 0.76666], + "80": [0, 0.68333, 0.10257, 0, 0.67833], + "81": [0.19444, 0.68333, 0.09403, 0, 0.76666], + "82": [0, 0.68333, 0.03868, 0, 0.72944], + "83": [0, 0.68333, 0.11972, 0, 0.56222], + "84": [0, 0.68333, 0.13305, 0, 0.71555], + "85": [0, 0.68333, 0.16389, 0, 0.74333], + "86": [0, 0.68333, 0.18361, 0, 0.74333], + "87": [0, 0.68333, 0.18361, 0, 0.99888], + "88": [0, 0.68333, 0.15806, 0, 0.74333], + "89": [0, 0.68333, 0.19383, 0, 0.74333], + "90": [0, 0.68333, 0.14528, 0, 0.61333], + "91": [0.25, 0.75, 0.1875, 0, 0.30667], + "93": [0.25, 0.75, 0.10528, 0, 0.30667], + "94": [0, 0.69444, 0.06646, 0, 0.51111], + "95": [0.31, 0.12056, 0.09208, 0, 0.51111], + "97": [0, 0.43056, 0.07671, 0, 0.51111], + "98": [0, 0.69444, 0.06312, 0, 0.46], + "99": [0, 0.43056, 0.05653, 0, 0.46], + "100": [0, 0.69444, 0.10333, 0, 0.51111], + "101": [0, 0.43056, 0.07514, 0, 0.46], + "102": [0.19444, 0.69444, 0.21194, 0, 0.30667], + "103": [0.19444, 0.43056, 0.08847, 0, 0.46], + "104": [0, 0.69444, 0.07671, 0, 0.51111], + "105": [0, 0.65536, 0.1019, 0, 0.30667], + "106": [0.19444, 0.65536, 0.14467, 0, 0.30667], + "107": [0, 0.69444, 0.10764, 0, 0.46], + "108": [0, 0.69444, 0.10333, 0, 0.25555], + "109": [0, 0.43056, 0.07671, 0, 0.81777], + "110": [0, 0.43056, 0.07671, 0, 0.56222], + "111": [0, 0.43056, 0.06312, 0, 0.51111], + "112": [0.19444, 0.43056, 0.06312, 0, 0.51111], + "113": [0.19444, 0.43056, 0.08847, 0, 0.46], + "114": [0, 0.43056, 0.10764, 0, 0.42166], + "115": [0, 0.43056, 0.08208, 0, 0.40889], + "116": [0, 0.61508, 0.09486, 0, 0.33222], + "117": [0, 0.43056, 0.07671, 0, 0.53666], + "118": [0, 0.43056, 0.10764, 0, 0.46], + "119": [0, 0.43056, 0.10764, 0, 0.66444], + "120": [0, 0.43056, 0.12042, 0, 0.46389], + "121": [0.19444, 0.43056, 0.08847, 0, 0.48555], + "122": [0, 0.43056, 0.12292, 0, 0.40889], + "126": [0.35, 0.31786, 0.11585, 0, 0.51111], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.66786, 0.10474, 0, 0.51111], + "176": [0, 0.69444, 0, 0, 0.83129], + "184": [0.17014, 0, 0, 0, 0.46], + "198": [0, 0.68333, 0.12028, 0, 0.88277], + "216": [0.04861, 0.73194, 0.09403, 0, 0.76666], + "223": [0.19444, 0.69444, 0.10514, 0, 0.53666], + "230": [0, 0.43056, 0.07514, 0, 0.71555], + "248": [0.09722, 0.52778, 0.09194, 0, 0.51111], + "338": [0, 0.68333, 0.12028, 0, 0.98499], + "339": [0, 0.43056, 0.07514, 0, 0.71555], + "710": [0, 0.69444, 0.06646, 0, 0.51111], + "711": [0, 0.62847, 0.08295, 0, 0.51111], + "713": [0, 0.56167, 0.10333, 0, 0.51111], + "714": [0, 0.69444, 0.09694, 0, 0.51111], + "715": [0, 0.69444, 0, 0, 0.51111], + "728": [0, 0.69444, 0.10806, 0, 0.51111], + "729": [0, 0.66786, 0.11752, 0, 0.30667], + "730": [0, 0.69444, 0, 0, 0.83129], + "732": [0, 0.66786, 0.11585, 0, 0.51111], + "733": [0, 0.69444, 0.1225, 0, 0.51111], + "915": [0, 0.68333, 0.13305, 0, 0.62722], + "916": [0, 0.68333, 0, 0, 0.81777], + "920": [0, 0.68333, 0.09403, 0, 0.76666], + "923": [0, 0.68333, 0, 0, 0.69222], + "926": [0, 0.68333, 0.15294, 0, 0.66444], + "928": [0, 0.68333, 0.16389, 0, 0.74333], + "931": [0, 0.68333, 0.12028, 0, 0.71555], + "933": [0, 0.68333, 0.11111, 0, 0.76666], + "934": [0, 0.68333, 0.05986, 0, 0.71555], + "936": [0, 0.68333, 0.11111, 0, 0.76666], + "937": [0, 0.68333, 0.10257, 0, 0.71555], + "8211": [0, 0.43056, 0.09208, 0, 0.51111], + "8212": [0, 0.43056, 0.09208, 0, 1.02222], + "8216": [0, 0.69444, 0.12417, 0, 0.30667], + "8217": [0, 0.69444, 0.12417, 0, 0.30667], + "8220": [0, 0.69444, 0.1685, 0, 0.51444], + "8221": [0, 0.69444, 0.06961, 0, 0.51444], + "8463": [0, 0.68889, 0, 0, 0.54028] + }, + "Main-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.27778], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.77778], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.19444, 0.10556, 0, 0, 0.27778], + "45": [0, 0.43056, 0, 0, 0.33333], + "46": [0, 0.10556, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.64444, 0, 0, 0.5], + "49": [0, 0.64444, 0, 0, 0.5], + "50": [0, 0.64444, 0, 0, 0.5], + "51": [0, 0.64444, 0, 0, 0.5], + "52": [0, 0.64444, 0, 0, 0.5], + "53": [0, 0.64444, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0, 0.64444, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0, 0.64444, 0, 0, 0.5], + "58": [0, 0.43056, 0, 0, 0.27778], + "59": [0.19444, 0.43056, 0, 0, 0.27778], + "60": [0.0391, 0.5391, 0, 0, 0.77778], + "61": [-0.13313, 0.36687, 0, 0, 0.77778], + "62": [0.0391, 0.5391, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.77778], + "65": [0, 0.68333, 0, 0, 0.75], + "66": [0, 0.68333, 0, 0, 0.70834], + "67": [0, 0.68333, 0, 0, 0.72222], + "68": [0, 0.68333, 0, 0, 0.76389], + "69": [0, 0.68333, 0, 0, 0.68056], + "70": [0, 0.68333, 0, 0, 0.65278], + "71": [0, 0.68333, 0, 0, 0.78472], + "72": [0, 0.68333, 0, 0, 0.75], + "73": [0, 0.68333, 0, 0, 0.36111], + "74": [0, 0.68333, 0, 0, 0.51389], + "75": [0, 0.68333, 0, 0, 0.77778], + "76": [0, 0.68333, 0, 0, 0.625], + "77": [0, 0.68333, 0, 0, 0.91667], + "78": [0, 0.68333, 0, 0, 0.75], + "79": [0, 0.68333, 0, 0, 0.77778], + "80": [0, 0.68333, 0, 0, 0.68056], + "81": [0.19444, 0.68333, 0, 0, 0.77778], + "82": [0, 0.68333, 0, 0, 0.73611], + "83": [0, 0.68333, 0, 0, 0.55556], + "84": [0, 0.68333, 0, 0, 0.72222], + "85": [0, 0.68333, 0, 0, 0.75], + "86": [0, 0.68333, 0.01389, 0, 0.75], + "87": [0, 0.68333, 0.01389, 0, 1.02778], + "88": [0, 0.68333, 0, 0, 0.75], + "89": [0, 0.68333, 0.025, 0, 0.75], + "90": [0, 0.68333, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.27778], + "92": [0.25, 0.75, 0, 0, 0.5], + "93": [0.25, 0.75, 0, 0, 0.27778], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.31, 0.12056, 0.02778, 0, 0.5], + "97": [0, 0.43056, 0, 0, 0.5], + "98": [0, 0.69444, 0, 0, 0.55556], + "99": [0, 0.43056, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.55556], + "101": [0, 0.43056, 0, 0, 0.44445], + "102": [0, 0.69444, 0.07778, 0, 0.30556], + "103": [0.19444, 0.43056, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.55556], + "105": [0, 0.66786, 0, 0, 0.27778], + "106": [0.19444, 0.66786, 0, 0, 0.30556], + "107": [0, 0.69444, 0, 0, 0.52778], + "108": [0, 0.69444, 0, 0, 0.27778], + "109": [0, 0.43056, 0, 0, 0.83334], + "110": [0, 0.43056, 0, 0, 0.55556], + "111": [0, 0.43056, 0, 0, 0.5], + "112": [0.19444, 0.43056, 0, 0, 0.55556], + "113": [0.19444, 0.43056, 0, 0, 0.52778], + "114": [0, 0.43056, 0, 0, 0.39167], + "115": [0, 0.43056, 0, 0, 0.39445], + "116": [0, 0.61508, 0, 0, 0.38889], + "117": [0, 0.43056, 0, 0, 0.55556], + "118": [0, 0.43056, 0.01389, 0, 0.52778], + "119": [0, 0.43056, 0.01389, 0, 0.72222], + "120": [0, 0.43056, 0, 0, 0.52778], + "121": [0.19444, 0.43056, 0.01389, 0, 0.52778], + "122": [0, 0.43056, 0, 0, 0.44445], + "123": [0.25, 0.75, 0, 0, 0.5], + "124": [0.25, 0.75, 0, 0, 0.27778], + "125": [0.25, 0.75, 0, 0, 0.5], + "126": [0.35, 0.31786, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "163": [0, 0.69444, 0, 0, 0.76909], + "167": [0.19444, 0.69444, 0, 0, 0.44445], + "168": [0, 0.66786, 0, 0, 0.5], + "172": [0, 0.43056, 0, 0, 0.66667], + "176": [0, 0.69444, 0, 0, 0.75], + "177": [0.08333, 0.58333, 0, 0, 0.77778], + "182": [0.19444, 0.69444, 0, 0, 0.61111], + "184": [0.17014, 0, 0, 0, 0.44445], + "198": [0, 0.68333, 0, 0, 0.90278], + "215": [0.08333, 0.58333, 0, 0, 0.77778], + "216": [0.04861, 0.73194, 0, 0, 0.77778], + "223": [0, 0.69444, 0, 0, 0.5], + "230": [0, 0.43056, 0, 0, 0.72222], + "247": [0.08333, 0.58333, 0, 0, 0.77778], + "248": [0.09722, 0.52778, 0, 0, 0.5], + "305": [0, 0.43056, 0, 0, 0.27778], + "338": [0, 0.68333, 0, 0, 1.01389], + "339": [0, 0.43056, 0, 0, 0.77778], + "567": [0.19444, 0.43056, 0, 0, 0.30556], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.62847, 0, 0, 0.5], + "713": [0, 0.56778, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.66786, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.75], + "732": [0, 0.66786, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.68333, 0, 0, 0.625], + "916": [0, 0.68333, 0, 0, 0.83334], + "920": [0, 0.68333, 0, 0, 0.77778], + "923": [0, 0.68333, 0, 0, 0.69445], + "926": [0, 0.68333, 0, 0, 0.66667], + "928": [0, 0.68333, 0, 0, 0.75], + "931": [0, 0.68333, 0, 0, 0.72222], + "933": [0, 0.68333, 0, 0, 0.77778], + "934": [0, 0.68333, 0, 0, 0.72222], + "936": [0, 0.68333, 0, 0, 0.77778], + "937": [0, 0.68333, 0, 0, 0.72222], + "8211": [0, 0.43056, 0.02778, 0, 0.5], + "8212": [0, 0.43056, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5], + "8224": [0.19444, 0.69444, 0, 0, 0.44445], + "8225": [0.19444, 0.69444, 0, 0, 0.44445], + "8230": [0, 0.123, 0, 0, 1.172], + "8242": [0, 0.55556, 0, 0, 0.275], + "8407": [0, 0.71444, 0.15382, 0, 0.5], + "8463": [0, 0.68889, 0, 0, 0.54028], + "8465": [0, 0.69444, 0, 0, 0.72222], + "8467": [0, 0.69444, 0, 0.11111, 0.41667], + "8472": [0.19444, 0.43056, 0, 0.11111, 0.63646], + "8476": [0, 0.69444, 0, 0, 0.72222], + "8501": [0, 0.69444, 0, 0, 0.61111], + "8592": [-0.13313, 0.36687, 0, 0, 1.0], + "8593": [0.19444, 0.69444, 0, 0, 0.5], + "8594": [-0.13313, 0.36687, 0, 0, 1.0], + "8595": [0.19444, 0.69444, 0, 0, 0.5], + "8596": [-0.13313, 0.36687, 0, 0, 1.0], + "8597": [0.25, 0.75, 0, 0, 0.5], + "8598": [0.19444, 0.69444, 0, 0, 1.0], + "8599": [0.19444, 0.69444, 0, 0, 1.0], + "8600": [0.19444, 0.69444, 0, 0, 1.0], + "8601": [0.19444, 0.69444, 0, 0, 1.0], + "8614": [0.011, 0.511, 0, 0, 1.0], + "8617": [0.011, 0.511, 0, 0, 1.126], + "8618": [0.011, 0.511, 0, 0, 1.126], + "8636": [-0.13313, 0.36687, 0, 0, 1.0], + "8637": [-0.13313, 0.36687, 0, 0, 1.0], + "8640": [-0.13313, 0.36687, 0, 0, 1.0], + "8641": [-0.13313, 0.36687, 0, 0, 1.0], + "8652": [0.011, 0.671, 0, 0, 1.0], + "8656": [-0.13313, 0.36687, 0, 0, 1.0], + "8657": [0.19444, 0.69444, 0, 0, 0.61111], + "8658": [-0.13313, 0.36687, 0, 0, 1.0], + "8659": [0.19444, 0.69444, 0, 0, 0.61111], + "8660": [-0.13313, 0.36687, 0, 0, 1.0], + "8661": [0.25, 0.75, 0, 0, 0.61111], + "8704": [0, 0.69444, 0, 0, 0.55556], + "8706": [0, 0.69444, 0.05556, 0.08334, 0.5309], + "8707": [0, 0.69444, 0, 0, 0.55556], + "8709": [0.05556, 0.75, 0, 0, 0.5], + "8711": [0, 0.68333, 0, 0, 0.83334], + "8712": [0.0391, 0.5391, 0, 0, 0.66667], + "8715": [0.0391, 0.5391, 0, 0, 0.66667], + "8722": [0.08333, 0.58333, 0, 0, 0.77778], + "8723": [0.08333, 0.58333, 0, 0, 0.77778], + "8725": [0.25, 0.75, 0, 0, 0.5], + "8726": [0.25, 0.75, 0, 0, 0.5], + "8727": [-0.03472, 0.46528, 0, 0, 0.5], + "8728": [-0.05555, 0.44445, 0, 0, 0.5], + "8729": [-0.05555, 0.44445, 0, 0, 0.5], + "8730": [0.2, 0.8, 0, 0, 0.83334], + "8733": [0, 0.43056, 0, 0, 0.77778], + "8734": [0, 0.43056, 0, 0, 1.0], + "8736": [0, 0.69224, 0, 0, 0.72222], + "8739": [0.25, 0.75, 0, 0, 0.27778], + "8741": [0.25, 0.75, 0, 0, 0.5], + "8743": [0, 0.55556, 0, 0, 0.66667], + "8744": [0, 0.55556, 0, 0, 0.66667], + "8745": [0, 0.55556, 0, 0, 0.66667], + "8746": [0, 0.55556, 0, 0, 0.66667], + "8747": [0.19444, 0.69444, 0.11111, 0, 0.41667], + "8764": [-0.13313, 0.36687, 0, 0, 0.77778], + "8768": [0.19444, 0.69444, 0, 0, 0.27778], + "8771": [-0.03625, 0.46375, 0, 0, 0.77778], + "8773": [-0.022, 0.589, 0, 0, 0.778], + "8776": [-0.01688, 0.48312, 0, 0, 0.77778], + "8781": [-0.03625, 0.46375, 0, 0, 0.77778], + "8784": [-0.133, 0.673, 0, 0, 0.778], + "8801": [-0.03625, 0.46375, 0, 0, 0.77778], + "8804": [0.13597, 0.63597, 0, 0, 0.77778], + "8805": [0.13597, 0.63597, 0, 0, 0.77778], + "8810": [0.0391, 0.5391, 0, 0, 1.0], + "8811": [0.0391, 0.5391, 0, 0, 1.0], + "8826": [0.0391, 0.5391, 0, 0, 0.77778], + "8827": [0.0391, 0.5391, 0, 0, 0.77778], + "8834": [0.0391, 0.5391, 0, 0, 0.77778], + "8835": [0.0391, 0.5391, 0, 0, 0.77778], + "8838": [0.13597, 0.63597, 0, 0, 0.77778], + "8839": [0.13597, 0.63597, 0, 0, 0.77778], + "8846": [0, 0.55556, 0, 0, 0.66667], + "8849": [0.13597, 0.63597, 0, 0, 0.77778], + "8850": [0.13597, 0.63597, 0, 0, 0.77778], + "8851": [0, 0.55556, 0, 0, 0.66667], + "8852": [0, 0.55556, 0, 0, 0.66667], + "8853": [0.08333, 0.58333, 0, 0, 0.77778], + "8854": [0.08333, 0.58333, 0, 0, 0.77778], + "8855": [0.08333, 0.58333, 0, 0, 0.77778], + "8856": [0.08333, 0.58333, 0, 0, 0.77778], + "8857": [0.08333, 0.58333, 0, 0, 0.77778], + "8866": [0, 0.69444, 0, 0, 0.61111], + "8867": [0, 0.69444, 0, 0, 0.61111], + "8868": [0, 0.69444, 0, 0, 0.77778], + "8869": [0, 0.69444, 0, 0, 0.77778], + "8872": [0.249, 0.75, 0, 0, 0.867], + "8900": [-0.05555, 0.44445, 0, 0, 0.5], + "8901": [-0.05555, 0.44445, 0, 0, 0.27778], + "8902": [-0.03472, 0.46528, 0, 0, 0.5], + "8904": [0.005, 0.505, 0, 0, 0.9], + "8942": [0.03, 0.903, 0, 0, 0.278], + "8943": [-0.19, 0.313, 0, 0, 1.172], + "8945": [-0.1, 0.823, 0, 0, 1.282], + "8968": [0.25, 0.75, 0, 0, 0.44445], + "8969": [0.25, 0.75, 0, 0, 0.44445], + "8970": [0.25, 0.75, 0, 0, 0.44445], + "8971": [0.25, 0.75, 0, 0, 0.44445], + "8994": [-0.14236, 0.35764, 0, 0, 1.0], + "8995": [-0.14236, 0.35764, 0, 0, 1.0], + "9136": [0.244, 0.744, 0, 0, 0.412], + "9137": [0.244, 0.745, 0, 0, 0.412], + "9651": [0.19444, 0.69444, 0, 0, 0.88889], + "9657": [-0.03472, 0.46528, 0, 0, 0.5], + "9661": [0.19444, 0.69444, 0, 0, 0.88889], + "9667": [-0.03472, 0.46528, 0, 0, 0.5], + "9711": [0.19444, 0.69444, 0, 0, 1.0], + "9824": [0.12963, 0.69444, 0, 0, 0.77778], + "9825": [0.12963, 0.69444, 0, 0, 0.77778], + "9826": [0.12963, 0.69444, 0, 0, 0.77778], + "9827": [0.12963, 0.69444, 0, 0, 0.77778], + "9837": [0, 0.75, 0, 0, 0.38889], + "9838": [0.19444, 0.69444, 0, 0, 0.38889], + "9839": [0.19444, 0.69444, 0, 0, 0.38889], + "10216": [0.25, 0.75, 0, 0, 0.38889], + "10217": [0.25, 0.75, 0, 0, 0.38889], + "10222": [0.244, 0.744, 0, 0, 0.412], + "10223": [0.244, 0.745, 0, 0, 0.412], + "10229": [0.011, 0.511, 0, 0, 1.609], + "10230": [0.011, 0.511, 0, 0, 1.638], + "10231": [0.011, 0.511, 0, 0, 1.859], + "10232": [0.024, 0.525, 0, 0, 1.609], + "10233": [0.024, 0.525, 0, 0, 1.638], + "10234": [0.024, 0.525, 0, 0, 1.858], + "10236": [0.011, 0.511, 0, 0, 1.638], + "10815": [0, 0.68333, 0, 0, 0.75], + "10927": [0.13597, 0.63597, 0, 0, 0.77778], + "10928": [0.13597, 0.63597, 0, 0, 0.77778], + "57376": [0.19444, 0.69444, 0, 0, 0] + }, + "Math-BoldItalic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.44444, 0, 0, 0.575], + "49": [0, 0.44444, 0, 0, 0.575], + "50": [0, 0.44444, 0, 0, 0.575], + "51": [0.19444, 0.44444, 0, 0, 0.575], + "52": [0.19444, 0.44444, 0, 0, 0.575], + "53": [0.19444, 0.44444, 0, 0, 0.575], + "54": [0, 0.64444, 0, 0, 0.575], + "55": [0.19444, 0.44444, 0, 0, 0.575], + "56": [0, 0.64444, 0, 0, 0.575], + "57": [0.19444, 0.44444, 0, 0, 0.575], + "65": [0, 0.68611, 0, 0, 0.86944], + "66": [0, 0.68611, 0.04835, 0, 0.8664], + "67": [0, 0.68611, 0.06979, 0, 0.81694], + "68": [0, 0.68611, 0.03194, 0, 0.93812], + "69": [0, 0.68611, 0.05451, 0, 0.81007], + "70": [0, 0.68611, 0.15972, 0, 0.68889], + "71": [0, 0.68611, 0, 0, 0.88673], + "72": [0, 0.68611, 0.08229, 0, 0.98229], + "73": [0, 0.68611, 0.07778, 0, 0.51111], + "74": [0, 0.68611, 0.10069, 0, 0.63125], + "75": [0, 0.68611, 0.06979, 0, 0.97118], + "76": [0, 0.68611, 0, 0, 0.75555], + "77": [0, 0.68611, 0.11424, 0, 1.14201], + "78": [0, 0.68611, 0.11424, 0, 0.95034], + "79": [0, 0.68611, 0.03194, 0, 0.83666], + "80": [0, 0.68611, 0.15972, 0, 0.72309], + "81": [0.19444, 0.68611, 0, 0, 0.86861], + "82": [0, 0.68611, 0.00421, 0, 0.87235], + "83": [0, 0.68611, 0.05382, 0, 0.69271], + "84": [0, 0.68611, 0.15972, 0, 0.63663], + "85": [0, 0.68611, 0.11424, 0, 0.80027], + "86": [0, 0.68611, 0.25555, 0, 0.67778], + "87": [0, 0.68611, 0.15972, 0, 1.09305], + "88": [0, 0.68611, 0.07778, 0, 0.94722], + "89": [0, 0.68611, 0.25555, 0, 0.67458], + "90": [0, 0.68611, 0.06979, 0, 0.77257], + "97": [0, 0.44444, 0, 0, 0.63287], + "98": [0, 0.69444, 0, 0, 0.52083], + "99": [0, 0.44444, 0, 0, 0.51342], + "100": [0, 0.69444, 0, 0, 0.60972], + "101": [0, 0.44444, 0, 0, 0.55361], + "102": [0.19444, 0.69444, 0.11042, 0, 0.56806], + "103": [0.19444, 0.44444, 0.03704, 0, 0.5449], + "104": [0, 0.69444, 0, 0, 0.66759], + "105": [0, 0.69326, 0, 0, 0.4048], + "106": [0.19444, 0.69326, 0.0622, 0, 0.47083], + "107": [0, 0.69444, 0.01852, 0, 0.6037], + "108": [0, 0.69444, 0.0088, 0, 0.34815], + "109": [0, 0.44444, 0, 0, 1.0324], + "110": [0, 0.44444, 0, 0, 0.71296], + "111": [0, 0.44444, 0, 0, 0.58472], + "112": [0.19444, 0.44444, 0, 0, 0.60092], + "113": [0.19444, 0.44444, 0.03704, 0, 0.54213], + "114": [0, 0.44444, 0.03194, 0, 0.5287], + "115": [0, 0.44444, 0, 0, 0.53125], + "116": [0, 0.63492, 0, 0, 0.41528], + "117": [0, 0.44444, 0, 0, 0.68102], + "118": [0, 0.44444, 0.03704, 0, 0.56666], + "119": [0, 0.44444, 0.02778, 0, 0.83148], + "120": [0, 0.44444, 0, 0, 0.65903], + "121": [0.19444, 0.44444, 0.03704, 0, 0.59028], + "122": [0, 0.44444, 0.04213, 0, 0.55509], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68611, 0.15972, 0, 0.65694], + "916": [0, 0.68611, 0, 0, 0.95833], + "920": [0, 0.68611, 0.03194, 0, 0.86722], + "923": [0, 0.68611, 0, 0, 0.80555], + "926": [0, 0.68611, 0.07458, 0, 0.84125], + "928": [0, 0.68611, 0.08229, 0, 0.98229], + "931": [0, 0.68611, 0.05451, 0, 0.88507], + "933": [0, 0.68611, 0.15972, 0, 0.67083], + "934": [0, 0.68611, 0, 0, 0.76666], + "936": [0, 0.68611, 0.11653, 0, 0.71402], + "937": [0, 0.68611, 0.04835, 0, 0.8789], + "945": [0, 0.44444, 0, 0, 0.76064], + "946": [0.19444, 0.69444, 0.03403, 0, 0.65972], + "947": [0.19444, 0.44444, 0.06389, 0, 0.59003], + "948": [0, 0.69444, 0.03819, 0, 0.52222], + "949": [0, 0.44444, 0, 0, 0.52882], + "950": [0.19444, 0.69444, 0.06215, 0, 0.50833], + "951": [0.19444, 0.44444, 0.03704, 0, 0.6], + "952": [0, 0.69444, 0.03194, 0, 0.5618], + "953": [0, 0.44444, 0, 0, 0.41204], + "954": [0, 0.44444, 0, 0, 0.66759], + "955": [0, 0.69444, 0, 0, 0.67083], + "956": [0.19444, 0.44444, 0, 0, 0.70787], + "957": [0, 0.44444, 0.06898, 0, 0.57685], + "958": [0.19444, 0.69444, 0.03021, 0, 0.50833], + "959": [0, 0.44444, 0, 0, 0.58472], + "960": [0, 0.44444, 0.03704, 0, 0.68241], + "961": [0.19444, 0.44444, 0, 0, 0.6118], + "962": [0.09722, 0.44444, 0.07917, 0, 0.42361], + "963": [0, 0.44444, 0.03704, 0, 0.68588], + "964": [0, 0.44444, 0.13472, 0, 0.52083], + "965": [0, 0.44444, 0.03704, 0, 0.63055], + "966": [0.19444, 0.44444, 0, 0, 0.74722], + "967": [0.19444, 0.44444, 0, 0, 0.71805], + "968": [0.19444, 0.69444, 0.03704, 0, 0.75833], + "969": [0, 0.44444, 0.03704, 0, 0.71782], + "977": [0, 0.69444, 0, 0, 0.69155], + "981": [0.19444, 0.69444, 0, 0, 0.7125], + "982": [0, 0.44444, 0.03194, 0, 0.975], + "1009": [0.19444, 0.44444, 0, 0, 0.6118], + "1013": [0, 0.44444, 0, 0, 0.48333], + "57649": [0, 0.44444, 0, 0, 0.39352], + "57911": [0.19444, 0.44444, 0, 0, 0.43889] + }, + "Math-Italic": { + "32": [0, 0, 0, 0, 0.25], + "48": [0, 0.43056, 0, 0, 0.5], + "49": [0, 0.43056, 0, 0, 0.5], + "50": [0, 0.43056, 0, 0, 0.5], + "51": [0.19444, 0.43056, 0, 0, 0.5], + "52": [0.19444, 0.43056, 0, 0, 0.5], + "53": [0.19444, 0.43056, 0, 0, 0.5], + "54": [0, 0.64444, 0, 0, 0.5], + "55": [0.19444, 0.43056, 0, 0, 0.5], + "56": [0, 0.64444, 0, 0, 0.5], + "57": [0.19444, 0.43056, 0, 0, 0.5], + "65": [0, 0.68333, 0, 0.13889, 0.75], + "66": [0, 0.68333, 0.05017, 0.08334, 0.75851], + "67": [0, 0.68333, 0.07153, 0.08334, 0.71472], + "68": [0, 0.68333, 0.02778, 0.05556, 0.82792], + "69": [0, 0.68333, 0.05764, 0.08334, 0.7382], + "70": [0, 0.68333, 0.13889, 0.08334, 0.64306], + "71": [0, 0.68333, 0, 0.08334, 0.78625], + "72": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "73": [0, 0.68333, 0.07847, 0.11111, 0.43958], + "74": [0, 0.68333, 0.09618, 0.16667, 0.55451], + "75": [0, 0.68333, 0.07153, 0.05556, 0.84931], + "76": [0, 0.68333, 0, 0.02778, 0.68056], + "77": [0, 0.68333, 0.10903, 0.08334, 0.97014], + "78": [0, 0.68333, 0.10903, 0.08334, 0.80347], + "79": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "80": [0, 0.68333, 0.13889, 0.08334, 0.64201], + "81": [0.19444, 0.68333, 0, 0.08334, 0.79056], + "82": [0, 0.68333, 0.00773, 0.08334, 0.75929], + "83": [0, 0.68333, 0.05764, 0.08334, 0.6132], + "84": [0, 0.68333, 0.13889, 0.08334, 0.58438], + "85": [0, 0.68333, 0.10903, 0.02778, 0.68278], + "86": [0, 0.68333, 0.22222, 0, 0.58333], + "87": [0, 0.68333, 0.13889, 0, 0.94445], + "88": [0, 0.68333, 0.07847, 0.08334, 0.82847], + "89": [0, 0.68333, 0.22222, 0, 0.58056], + "90": [0, 0.68333, 0.07153, 0.08334, 0.68264], + "97": [0, 0.43056, 0, 0, 0.52859], + "98": [0, 0.69444, 0, 0, 0.42917], + "99": [0, 0.43056, 0, 0.05556, 0.43276], + "100": [0, 0.69444, 0, 0.16667, 0.52049], + "101": [0, 0.43056, 0, 0.05556, 0.46563], + "102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959], + "103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697], + "104": [0, 0.69444, 0, 0, 0.57616], + "105": [0, 0.65952, 0, 0, 0.34451], + "106": [0.19444, 0.65952, 0.05724, 0, 0.41181], + "107": [0, 0.69444, 0.03148, 0, 0.5206], + "108": [0, 0.69444, 0.01968, 0.08334, 0.29838], + "109": [0, 0.43056, 0, 0, 0.87801], + "110": [0, 0.43056, 0, 0, 0.60023], + "111": [0, 0.43056, 0, 0.05556, 0.48472], + "112": [0.19444, 0.43056, 0, 0.08334, 0.50313], + "113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641], + "114": [0, 0.43056, 0.02778, 0.05556, 0.45116], + "115": [0, 0.43056, 0, 0.05556, 0.46875], + "116": [0, 0.61508, 0, 0.08334, 0.36111], + "117": [0, 0.43056, 0, 0.02778, 0.57246], + "118": [0, 0.43056, 0.03588, 0.02778, 0.48472], + "119": [0, 0.43056, 0.02691, 0.08334, 0.71592], + "120": [0, 0.43056, 0, 0.02778, 0.57153], + "121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028], + "122": [0, 0.43056, 0.04398, 0.05556, 0.46505], + "160": [0, 0, 0, 0, 0.25], + "915": [0, 0.68333, 0.13889, 0.08334, 0.61528], + "916": [0, 0.68333, 0, 0.16667, 0.83334], + "920": [0, 0.68333, 0.02778, 0.08334, 0.76278], + "923": [0, 0.68333, 0, 0.16667, 0.69445], + "926": [0, 0.68333, 0.07569, 0.08334, 0.74236], + "928": [0, 0.68333, 0.08125, 0.05556, 0.83125], + "931": [0, 0.68333, 0.05764, 0.08334, 0.77986], + "933": [0, 0.68333, 0.13889, 0.05556, 0.58333], + "934": [0, 0.68333, 0, 0.08334, 0.66667], + "936": [0, 0.68333, 0.11, 0.05556, 0.61222], + "937": [0, 0.68333, 0.05017, 0.08334, 0.7724], + "945": [0, 0.43056, 0.0037, 0.02778, 0.6397], + "946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563], + "947": [0.19444, 0.43056, 0.05556, 0, 0.51773], + "948": [0, 0.69444, 0.03785, 0.05556, 0.44444], + "949": [0, 0.43056, 0, 0.08334, 0.46632], + "950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375], + "951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653], + "952": [0, 0.69444, 0.02778, 0.08334, 0.46944], + "953": [0, 0.43056, 0, 0.05556, 0.35394], + "954": [0, 0.43056, 0, 0, 0.57616], + "955": [0, 0.69444, 0, 0, 0.58334], + "956": [0.19444, 0.43056, 0, 0.02778, 0.60255], + "957": [0, 0.43056, 0.06366, 0.02778, 0.49398], + "958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375], + "959": [0, 0.43056, 0, 0.05556, 0.48472], + "960": [0, 0.43056, 0.03588, 0, 0.57003], + "961": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285], + "963": [0, 0.43056, 0.03588, 0, 0.57141], + "964": [0, 0.43056, 0.1132, 0.02778, 0.43715], + "965": [0, 0.43056, 0.03588, 0.02778, 0.54028], + "966": [0.19444, 0.43056, 0, 0.08334, 0.65417], + "967": [0.19444, 0.43056, 0, 0.05556, 0.62569], + "968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139], + "969": [0, 0.43056, 0.03588, 0, 0.62245], + "977": [0, 0.69444, 0, 0.08334, 0.59144], + "981": [0.19444, 0.69444, 0, 0.08334, 0.59583], + "982": [0, 0.43056, 0.02778, 0, 0.82813], + "1009": [0.19444, 0.43056, 0, 0.08334, 0.51702], + "1013": [0, 0.43056, 0, 0.05556, 0.4059], + "57649": [0, 0.43056, 0, 0.02778, 0.32246], + "57911": [0.19444, 0.43056, 0, 0.08334, 0.38403] + }, + "SansSerif-Bold": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.36667], + "34": [0, 0.69444, 0, 0, 0.55834], + "35": [0.19444, 0.69444, 0, 0, 0.91667], + "36": [0.05556, 0.75, 0, 0, 0.55], + "37": [0.05556, 0.75, 0, 0, 1.02912], + "38": [0, 0.69444, 0, 0, 0.83056], + "39": [0, 0.69444, 0, 0, 0.30556], + "40": [0.25, 0.75, 0, 0, 0.42778], + "41": [0.25, 0.75, 0, 0, 0.42778], + "42": [0, 0.75, 0, 0, 0.55], + "43": [0.11667, 0.61667, 0, 0, 0.85556], + "44": [0.10556, 0.13056, 0, 0, 0.30556], + "45": [0, 0.45833, 0, 0, 0.36667], + "46": [0, 0.13056, 0, 0, 0.30556], + "47": [0.25, 0.75, 0, 0, 0.55], + "48": [0, 0.69444, 0, 0, 0.55], + "49": [0, 0.69444, 0, 0, 0.55], + "50": [0, 0.69444, 0, 0, 0.55], + "51": [0, 0.69444, 0, 0, 0.55], + "52": [0, 0.69444, 0, 0, 0.55], + "53": [0, 0.69444, 0, 0, 0.55], + "54": [0, 0.69444, 0, 0, 0.55], + "55": [0, 0.69444, 0, 0, 0.55], + "56": [0, 0.69444, 0, 0, 0.55], + "57": [0, 0.69444, 0, 0, 0.55], + "58": [0, 0.45833, 0, 0, 0.30556], + "59": [0.10556, 0.45833, 0, 0, 0.30556], + "61": [-0.09375, 0.40625, 0, 0, 0.85556], + "63": [0, 0.69444, 0, 0, 0.51945], + "64": [0, 0.69444, 0, 0, 0.73334], + "65": [0, 0.69444, 0, 0, 0.73334], + "66": [0, 0.69444, 0, 0, 0.73334], + "67": [0, 0.69444, 0, 0, 0.70278], + "68": [0, 0.69444, 0, 0, 0.79445], + "69": [0, 0.69444, 0, 0, 0.64167], + "70": [0, 0.69444, 0, 0, 0.61111], + "71": [0, 0.69444, 0, 0, 0.73334], + "72": [0, 0.69444, 0, 0, 0.79445], + "73": [0, 0.69444, 0, 0, 0.33056], + "74": [0, 0.69444, 0, 0, 0.51945], + "75": [0, 0.69444, 0, 0, 0.76389], + "76": [0, 0.69444, 0, 0, 0.58056], + "77": [0, 0.69444, 0, 0, 0.97778], + "78": [0, 0.69444, 0, 0, 0.79445], + "79": [0, 0.69444, 0, 0, 0.79445], + "80": [0, 0.69444, 0, 0, 0.70278], + "81": [0.10556, 0.69444, 0, 0, 0.79445], + "82": [0, 0.69444, 0, 0, 0.70278], + "83": [0, 0.69444, 0, 0, 0.61111], + "84": [0, 0.69444, 0, 0, 0.73334], + "85": [0, 0.69444, 0, 0, 0.76389], + "86": [0, 0.69444, 0.01528, 0, 0.73334], + "87": [0, 0.69444, 0.01528, 0, 1.03889], + "88": [0, 0.69444, 0, 0, 0.73334], + "89": [0, 0.69444, 0.0275, 0, 0.73334], + "90": [0, 0.69444, 0, 0, 0.67223], + "91": [0.25, 0.75, 0, 0, 0.34306], + "93": [0.25, 0.75, 0, 0, 0.34306], + "94": [0, 0.69444, 0, 0, 0.55], + "95": [0.35, 0.10833, 0.03056, 0, 0.55], + "97": [0, 0.45833, 0, 0, 0.525], + "98": [0, 0.69444, 0, 0, 0.56111], + "99": [0, 0.45833, 0, 0, 0.48889], + "100": [0, 0.69444, 0, 0, 0.56111], + "101": [0, 0.45833, 0, 0, 0.51111], + "102": [0, 0.69444, 0.07639, 0, 0.33611], + "103": [0.19444, 0.45833, 0.01528, 0, 0.55], + "104": [0, 0.69444, 0, 0, 0.56111], + "105": [0, 0.69444, 0, 0, 0.25556], + "106": [0.19444, 0.69444, 0, 0, 0.28611], + "107": [0, 0.69444, 0, 0, 0.53056], + "108": [0, 0.69444, 0, 0, 0.25556], + "109": [0, 0.45833, 0, 0, 0.86667], + "110": [0, 0.45833, 0, 0, 0.56111], + "111": [0, 0.45833, 0, 0, 0.55], + "112": [0.19444, 0.45833, 0, 0, 0.56111], + "113": [0.19444, 0.45833, 0, 0, 0.56111], + "114": [0, 0.45833, 0.01528, 0, 0.37222], + "115": [0, 0.45833, 0, 0, 0.42167], + "116": [0, 0.58929, 0, 0, 0.40417], + "117": [0, 0.45833, 0, 0, 0.56111], + "118": [0, 0.45833, 0.01528, 0, 0.5], + "119": [0, 0.45833, 0.01528, 0, 0.74445], + "120": [0, 0.45833, 0, 0, 0.5], + "121": [0.19444, 0.45833, 0.01528, 0, 0.5], + "122": [0, 0.45833, 0, 0, 0.47639], + "126": [0.35, 0.34444, 0, 0, 0.55], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.69444, 0, 0, 0.55], + "176": [0, 0.69444, 0, 0, 0.73334], + "180": [0, 0.69444, 0, 0, 0.55], + "184": [0.17014, 0, 0, 0, 0.48889], + "305": [0, 0.45833, 0, 0, 0.25556], + "567": [0.19444, 0.45833, 0, 0, 0.28611], + "710": [0, 0.69444, 0, 0, 0.55], + "711": [0, 0.63542, 0, 0, 0.55], + "713": [0, 0.63778, 0, 0, 0.55], + "728": [0, 0.69444, 0, 0, 0.55], + "729": [0, 0.69444, 0, 0, 0.30556], + "730": [0, 0.69444, 0, 0, 0.73334], + "732": [0, 0.69444, 0, 0, 0.55], + "733": [0, 0.69444, 0, 0, 0.55], + "915": [0, 0.69444, 0, 0, 0.58056], + "916": [0, 0.69444, 0, 0, 0.91667], + "920": [0, 0.69444, 0, 0, 0.85556], + "923": [0, 0.69444, 0, 0, 0.67223], + "926": [0, 0.69444, 0, 0, 0.73334], + "928": [0, 0.69444, 0, 0, 0.79445], + "931": [0, 0.69444, 0, 0, 0.79445], + "933": [0, 0.69444, 0, 0, 0.85556], + "934": [0, 0.69444, 0, 0, 0.79445], + "936": [0, 0.69444, 0, 0, 0.85556], + "937": [0, 0.69444, 0, 0, 0.79445], + "8211": [0, 0.45833, 0.03056, 0, 0.55], + "8212": [0, 0.45833, 0.03056, 0, 1.10001], + "8216": [0, 0.69444, 0, 0, 0.30556], + "8217": [0, 0.69444, 0, 0, 0.30556], + "8220": [0, 0.69444, 0, 0, 0.55834], + "8221": [0, 0.69444, 0, 0, 0.55834] + }, + "SansSerif-Italic": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0.05733, 0, 0.31945], + "34": [0, 0.69444, 0.00316, 0, 0.5], + "35": [0.19444, 0.69444, 0.05087, 0, 0.83334], + "36": [0.05556, 0.75, 0.11156, 0, 0.5], + "37": [0.05556, 0.75, 0.03126, 0, 0.83334], + "38": [0, 0.69444, 0.03058, 0, 0.75834], + "39": [0, 0.69444, 0.07816, 0, 0.27778], + "40": [0.25, 0.75, 0.13164, 0, 0.38889], + "41": [0.25, 0.75, 0.02536, 0, 0.38889], + "42": [0, 0.75, 0.11775, 0, 0.5], + "43": [0.08333, 0.58333, 0.02536, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0.01946, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0.13164, 0, 0.5], + "48": [0, 0.65556, 0.11156, 0, 0.5], + "49": [0, 0.65556, 0.11156, 0, 0.5], + "50": [0, 0.65556, 0.11156, 0, 0.5], + "51": [0, 0.65556, 0.11156, 0, 0.5], + "52": [0, 0.65556, 0.11156, 0, 0.5], + "53": [0, 0.65556, 0.11156, 0, 0.5], + "54": [0, 0.65556, 0.11156, 0, 0.5], + "55": [0, 0.65556, 0.11156, 0, 0.5], + "56": [0, 0.65556, 0.11156, 0, 0.5], + "57": [0, 0.65556, 0.11156, 0, 0.5], + "58": [0, 0.44444, 0.02502, 0, 0.27778], + "59": [0.125, 0.44444, 0.02502, 0, 0.27778], + "61": [-0.13, 0.37, 0.05087, 0, 0.77778], + "63": [0, 0.69444, 0.11809, 0, 0.47222], + "64": [0, 0.69444, 0.07555, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0.08293, 0, 0.66667], + "67": [0, 0.69444, 0.11983, 0, 0.63889], + "68": [0, 0.69444, 0.07555, 0, 0.72223], + "69": [0, 0.69444, 0.11983, 0, 0.59722], + "70": [0, 0.69444, 0.13372, 0, 0.56945], + "71": [0, 0.69444, 0.11983, 0, 0.66667], + "72": [0, 0.69444, 0.08094, 0, 0.70834], + "73": [0, 0.69444, 0.13372, 0, 0.27778], + "74": [0, 0.69444, 0.08094, 0, 0.47222], + "75": [0, 0.69444, 0.11983, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0.08094, 0, 0.875], + "78": [0, 0.69444, 0.08094, 0, 0.70834], + "79": [0, 0.69444, 0.07555, 0, 0.73611], + "80": [0, 0.69444, 0.08293, 0, 0.63889], + "81": [0.125, 0.69444, 0.07555, 0, 0.73611], + "82": [0, 0.69444, 0.08293, 0, 0.64584], + "83": [0, 0.69444, 0.09205, 0, 0.55556], + "84": [0, 0.69444, 0.13372, 0, 0.68056], + "85": [0, 0.69444, 0.08094, 0, 0.6875], + "86": [0, 0.69444, 0.1615, 0, 0.66667], + "87": [0, 0.69444, 0.1615, 0, 0.94445], + "88": [0, 0.69444, 0.13372, 0, 0.66667], + "89": [0, 0.69444, 0.17261, 0, 0.66667], + "90": [0, 0.69444, 0.11983, 0, 0.61111], + "91": [0.25, 0.75, 0.15942, 0, 0.28889], + "93": [0.25, 0.75, 0.08719, 0, 0.28889], + "94": [0, 0.69444, 0.0799, 0, 0.5], + "95": [0.35, 0.09444, 0.08616, 0, 0.5], + "97": [0, 0.44444, 0.00981, 0, 0.48056], + "98": [0, 0.69444, 0.03057, 0, 0.51667], + "99": [0, 0.44444, 0.08336, 0, 0.44445], + "100": [0, 0.69444, 0.09483, 0, 0.51667], + "101": [0, 0.44444, 0.06778, 0, 0.44445], + "102": [0, 0.69444, 0.21705, 0, 0.30556], + "103": [0.19444, 0.44444, 0.10836, 0, 0.5], + "104": [0, 0.69444, 0.01778, 0, 0.51667], + "105": [0, 0.67937, 0.09718, 0, 0.23889], + "106": [0.19444, 0.67937, 0.09162, 0, 0.26667], + "107": [0, 0.69444, 0.08336, 0, 0.48889], + "108": [0, 0.69444, 0.09483, 0, 0.23889], + "109": [0, 0.44444, 0.01778, 0, 0.79445], + "110": [0, 0.44444, 0.01778, 0, 0.51667], + "111": [0, 0.44444, 0.06613, 0, 0.5], + "112": [0.19444, 0.44444, 0.0389, 0, 0.51667], + "113": [0.19444, 0.44444, 0.04169, 0, 0.51667], + "114": [0, 0.44444, 0.10836, 0, 0.34167], + "115": [0, 0.44444, 0.0778, 0, 0.38333], + "116": [0, 0.57143, 0.07225, 0, 0.36111], + "117": [0, 0.44444, 0.04169, 0, 0.51667], + "118": [0, 0.44444, 0.10836, 0, 0.46111], + "119": [0, 0.44444, 0.10836, 0, 0.68334], + "120": [0, 0.44444, 0.09169, 0, 0.46111], + "121": [0.19444, 0.44444, 0.10836, 0, 0.46111], + "122": [0, 0.44444, 0.08752, 0, 0.43472], + "126": [0.35, 0.32659, 0.08826, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0.06385, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.73752], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0.04169, 0, 0.23889], + "567": [0.19444, 0.44444, 0.04169, 0, 0.26667], + "710": [0, 0.69444, 0.0799, 0, 0.5], + "711": [0, 0.63194, 0.08432, 0, 0.5], + "713": [0, 0.60889, 0.08776, 0, 0.5], + "714": [0, 0.69444, 0.09205, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0.09483, 0, 0.5], + "729": [0, 0.67937, 0.07774, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.73752], + "732": [0, 0.67659, 0.08826, 0, 0.5], + "733": [0, 0.69444, 0.09205, 0, 0.5], + "915": [0, 0.69444, 0.13372, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0.07555, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0.12816, 0, 0.66667], + "928": [0, 0.69444, 0.08094, 0, 0.70834], + "931": [0, 0.69444, 0.11983, 0, 0.72222], + "933": [0, 0.69444, 0.09031, 0, 0.77778], + "934": [0, 0.69444, 0.04603, 0, 0.72222], + "936": [0, 0.69444, 0.09031, 0, 0.77778], + "937": [0, 0.69444, 0.08293, 0, 0.72222], + "8211": [0, 0.44444, 0.08616, 0, 0.5], + "8212": [0, 0.44444, 0.08616, 0, 1.0], + "8216": [0, 0.69444, 0.07816, 0, 0.27778], + "8217": [0, 0.69444, 0.07816, 0, 0.27778], + "8220": [0, 0.69444, 0.14205, 0, 0.5], + "8221": [0, 0.69444, 0.00316, 0, 0.5] + }, + "SansSerif-Regular": { + "32": [0, 0, 0, 0, 0.25], + "33": [0, 0.69444, 0, 0, 0.31945], + "34": [0, 0.69444, 0, 0, 0.5], + "35": [0.19444, 0.69444, 0, 0, 0.83334], + "36": [0.05556, 0.75, 0, 0, 0.5], + "37": [0.05556, 0.75, 0, 0, 0.83334], + "38": [0, 0.69444, 0, 0, 0.75834], + "39": [0, 0.69444, 0, 0, 0.27778], + "40": [0.25, 0.75, 0, 0, 0.38889], + "41": [0.25, 0.75, 0, 0, 0.38889], + "42": [0, 0.75, 0, 0, 0.5], + "43": [0.08333, 0.58333, 0, 0, 0.77778], + "44": [0.125, 0.08333, 0, 0, 0.27778], + "45": [0, 0.44444, 0, 0, 0.33333], + "46": [0, 0.08333, 0, 0, 0.27778], + "47": [0.25, 0.75, 0, 0, 0.5], + "48": [0, 0.65556, 0, 0, 0.5], + "49": [0, 0.65556, 0, 0, 0.5], + "50": [0, 0.65556, 0, 0, 0.5], + "51": [0, 0.65556, 0, 0, 0.5], + "52": [0, 0.65556, 0, 0, 0.5], + "53": [0, 0.65556, 0, 0, 0.5], + "54": [0, 0.65556, 0, 0, 0.5], + "55": [0, 0.65556, 0, 0, 0.5], + "56": [0, 0.65556, 0, 0, 0.5], + "57": [0, 0.65556, 0, 0, 0.5], + "58": [0, 0.44444, 0, 0, 0.27778], + "59": [0.125, 0.44444, 0, 0, 0.27778], + "61": [-0.13, 0.37, 0, 0, 0.77778], + "63": [0, 0.69444, 0, 0, 0.47222], + "64": [0, 0.69444, 0, 0, 0.66667], + "65": [0, 0.69444, 0, 0, 0.66667], + "66": [0, 0.69444, 0, 0, 0.66667], + "67": [0, 0.69444, 0, 0, 0.63889], + "68": [0, 0.69444, 0, 0, 0.72223], + "69": [0, 0.69444, 0, 0, 0.59722], + "70": [0, 0.69444, 0, 0, 0.56945], + "71": [0, 0.69444, 0, 0, 0.66667], + "72": [0, 0.69444, 0, 0, 0.70834], + "73": [0, 0.69444, 0, 0, 0.27778], + "74": [0, 0.69444, 0, 0, 0.47222], + "75": [0, 0.69444, 0, 0, 0.69445], + "76": [0, 0.69444, 0, 0, 0.54167], + "77": [0, 0.69444, 0, 0, 0.875], + "78": [0, 0.69444, 0, 0, 0.70834], + "79": [0, 0.69444, 0, 0, 0.73611], + "80": [0, 0.69444, 0, 0, 0.63889], + "81": [0.125, 0.69444, 0, 0, 0.73611], + "82": [0, 0.69444, 0, 0, 0.64584], + "83": [0, 0.69444, 0, 0, 0.55556], + "84": [0, 0.69444, 0, 0, 0.68056], + "85": [0, 0.69444, 0, 0, 0.6875], + "86": [0, 0.69444, 0.01389, 0, 0.66667], + "87": [0, 0.69444, 0.01389, 0, 0.94445], + "88": [0, 0.69444, 0, 0, 0.66667], + "89": [0, 0.69444, 0.025, 0, 0.66667], + "90": [0, 0.69444, 0, 0, 0.61111], + "91": [0.25, 0.75, 0, 0, 0.28889], + "93": [0.25, 0.75, 0, 0, 0.28889], + "94": [0, 0.69444, 0, 0, 0.5], + "95": [0.35, 0.09444, 0.02778, 0, 0.5], + "97": [0, 0.44444, 0, 0, 0.48056], + "98": [0, 0.69444, 0, 0, 0.51667], + "99": [0, 0.44444, 0, 0, 0.44445], + "100": [0, 0.69444, 0, 0, 0.51667], + "101": [0, 0.44444, 0, 0, 0.44445], + "102": [0, 0.69444, 0.06944, 0, 0.30556], + "103": [0.19444, 0.44444, 0.01389, 0, 0.5], + "104": [0, 0.69444, 0, 0, 0.51667], + "105": [0, 0.67937, 0, 0, 0.23889], + "106": [0.19444, 0.67937, 0, 0, 0.26667], + "107": [0, 0.69444, 0, 0, 0.48889], + "108": [0, 0.69444, 0, 0, 0.23889], + "109": [0, 0.44444, 0, 0, 0.79445], + "110": [0, 0.44444, 0, 0, 0.51667], + "111": [0, 0.44444, 0, 0, 0.5], + "112": [0.19444, 0.44444, 0, 0, 0.51667], + "113": [0.19444, 0.44444, 0, 0, 0.51667], + "114": [0, 0.44444, 0.01389, 0, 0.34167], + "115": [0, 0.44444, 0, 0, 0.38333], + "116": [0, 0.57143, 0, 0, 0.36111], + "117": [0, 0.44444, 0, 0, 0.51667], + "118": [0, 0.44444, 0.01389, 0, 0.46111], + "119": [0, 0.44444, 0.01389, 0, 0.68334], + "120": [0, 0.44444, 0, 0, 0.46111], + "121": [0.19444, 0.44444, 0.01389, 0, 0.46111], + "122": [0, 0.44444, 0, 0, 0.43472], + "126": [0.35, 0.32659, 0, 0, 0.5], + "160": [0, 0, 0, 0, 0.25], + "168": [0, 0.67937, 0, 0, 0.5], + "176": [0, 0.69444, 0, 0, 0.66667], + "184": [0.17014, 0, 0, 0, 0.44445], + "305": [0, 0.44444, 0, 0, 0.23889], + "567": [0.19444, 0.44444, 0, 0, 0.26667], + "710": [0, 0.69444, 0, 0, 0.5], + "711": [0, 0.63194, 0, 0, 0.5], + "713": [0, 0.60889, 0, 0, 0.5], + "714": [0, 0.69444, 0, 0, 0.5], + "715": [0, 0.69444, 0, 0, 0.5], + "728": [0, 0.69444, 0, 0, 0.5], + "729": [0, 0.67937, 0, 0, 0.27778], + "730": [0, 0.69444, 0, 0, 0.66667], + "732": [0, 0.67659, 0, 0, 0.5], + "733": [0, 0.69444, 0, 0, 0.5], + "915": [0, 0.69444, 0, 0, 0.54167], + "916": [0, 0.69444, 0, 0, 0.83334], + "920": [0, 0.69444, 0, 0, 0.77778], + "923": [0, 0.69444, 0, 0, 0.61111], + "926": [0, 0.69444, 0, 0, 0.66667], + "928": [0, 0.69444, 0, 0, 0.70834], + "931": [0, 0.69444, 0, 0, 0.72222], + "933": [0, 0.69444, 0, 0, 0.77778], + "934": [0, 0.69444, 0, 0, 0.72222], + "936": [0, 0.69444, 0, 0, 0.77778], + "937": [0, 0.69444, 0, 0, 0.72222], + "8211": [0, 0.44444, 0.02778, 0, 0.5], + "8212": [0, 0.44444, 0.02778, 0, 1.0], + "8216": [0, 0.69444, 0, 0, 0.27778], + "8217": [0, 0.69444, 0, 0, 0.27778], + "8220": [0, 0.69444, 0, 0, 0.5], + "8221": [0, 0.69444, 0, 0, 0.5] + }, + "Script-Regular": { + "32": [0, 0, 0, 0, 0.25], + "65": [0, 0.7, 0.22925, 0, 0.80253], + "66": [0, 0.7, 0.04087, 0, 0.90757], + "67": [0, 0.7, 0.1689, 0, 0.66619], + "68": [0, 0.7, 0.09371, 0, 0.77443], + "69": [0, 0.7, 0.18583, 0, 0.56162], + "70": [0, 0.7, 0.13634, 0, 0.89544], + "71": [0, 0.7, 0.17322, 0, 0.60961], + "72": [0, 0.7, 0.29694, 0, 0.96919], + "73": [0, 0.7, 0.19189, 0, 0.80907], + "74": [0.27778, 0.7, 0.19189, 0, 1.05159], + "75": [0, 0.7, 0.31259, 0, 0.91364], + "76": [0, 0.7, 0.19189, 0, 0.87373], + "77": [0, 0.7, 0.15981, 0, 1.08031], + "78": [0, 0.7, 0.3525, 0, 0.9015], + "79": [0, 0.7, 0.08078, 0, 0.73787], + "80": [0, 0.7, 0.08078, 0, 1.01262], + "81": [0, 0.7, 0.03305, 0, 0.88282], + "82": [0, 0.7, 0.06259, 0, 0.85], + "83": [0, 0.7, 0.19189, 0, 0.86767], + "84": [0, 0.7, 0.29087, 0, 0.74697], + "85": [0, 0.7, 0.25815, 0, 0.79996], + "86": [0, 0.7, 0.27523, 0, 0.62204], + "87": [0, 0.7, 0.27523, 0, 0.80532], + "88": [0, 0.7, 0.26006, 0, 0.94445], + "89": [0, 0.7, 0.2939, 0, 0.70961], + "90": [0, 0.7, 0.24037, 0, 0.8212], + "160": [0, 0, 0, 0, 0.25] + }, + "Size1-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.35001, 0.85, 0, 0, 0.45834], + "41": [0.35001, 0.85, 0, 0, 0.45834], + "47": [0.35001, 0.85, 0, 0, 0.57778], + "91": [0.35001, 0.85, 0, 0, 0.41667], + "92": [0.35001, 0.85, 0, 0, 0.57778], + "93": [0.35001, 0.85, 0, 0, 0.41667], + "123": [0.35001, 0.85, 0, 0, 0.58334], + "125": [0.35001, 0.85, 0, 0, 0.58334], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.72222, 0, 0, 0.55556], + "732": [0, 0.72222, 0, 0, 0.55556], + "770": [0, 0.72222, 0, 0, 0.55556], + "771": [0, 0.72222, 0, 0, 0.55556], + "8214": [-0.00099, 0.601, 0, 0, 0.77778], + "8593": [1e-05, 0.6, 0, 0, 0.66667], + "8595": [1e-05, 0.6, 0, 0, 0.66667], + "8657": [1e-05, 0.6, 0, 0, 0.77778], + "8659": [1e-05, 0.6, 0, 0, 0.77778], + "8719": [0.25001, 0.75, 0, 0, 0.94445], + "8720": [0.25001, 0.75, 0, 0, 0.94445], + "8721": [0.25001, 0.75, 0, 0, 1.05556], + "8730": [0.35001, 0.85, 0, 0, 1.0], + "8739": [-0.00599, 0.606, 0, 0, 0.33333], + "8741": [-0.00599, 0.606, 0, 0, 0.55556], + "8747": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8748": [0.306, 0.805, 0.19445, 0, 0.47222], + "8749": [0.306, 0.805, 0.19445, 0, 0.47222], + "8750": [0.30612, 0.805, 0.19445, 0, 0.47222], + "8896": [0.25001, 0.75, 0, 0, 0.83334], + "8897": [0.25001, 0.75, 0, 0, 0.83334], + "8898": [0.25001, 0.75, 0, 0, 0.83334], + "8899": [0.25001, 0.75, 0, 0, 0.83334], + "8968": [0.35001, 0.85, 0, 0, 0.47222], + "8969": [0.35001, 0.85, 0, 0, 0.47222], + "8970": [0.35001, 0.85, 0, 0, 0.47222], + "8971": [0.35001, 0.85, 0, 0, 0.47222], + "9168": [-0.00099, 0.601, 0, 0, 0.66667], + "10216": [0.35001, 0.85, 0, 0, 0.47222], + "10217": [0.35001, 0.85, 0, 0, 0.47222], + "10752": [0.25001, 0.75, 0, 0, 1.11111], + "10753": [0.25001, 0.75, 0, 0, 1.11111], + "10754": [0.25001, 0.75, 0, 0, 1.11111], + "10756": [0.25001, 0.75, 0, 0, 0.83334], + "10758": [0.25001, 0.75, 0, 0, 0.83334] + }, + "Size2-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.65002, 1.15, 0, 0, 0.59722], + "41": [0.65002, 1.15, 0, 0, 0.59722], + "47": [0.65002, 1.15, 0, 0, 0.81111], + "91": [0.65002, 1.15, 0, 0, 0.47222], + "92": [0.65002, 1.15, 0, 0, 0.81111], + "93": [0.65002, 1.15, 0, 0, 0.47222], + "123": [0.65002, 1.15, 0, 0, 0.66667], + "125": [0.65002, 1.15, 0, 0, 0.66667], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.0], + "732": [0, 0.75, 0, 0, 1.0], + "770": [0, 0.75, 0, 0, 1.0], + "771": [0, 0.75, 0, 0, 1.0], + "8719": [0.55001, 1.05, 0, 0, 1.27778], + "8720": [0.55001, 1.05, 0, 0, 1.27778], + "8721": [0.55001, 1.05, 0, 0, 1.44445], + "8730": [0.65002, 1.15, 0, 0, 1.0], + "8747": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8748": [0.862, 1.36, 0.44445, 0, 0.55556], + "8749": [0.862, 1.36, 0.44445, 0, 0.55556], + "8750": [0.86225, 1.36, 0.44445, 0, 0.55556], + "8896": [0.55001, 1.05, 0, 0, 1.11111], + "8897": [0.55001, 1.05, 0, 0, 1.11111], + "8898": [0.55001, 1.05, 0, 0, 1.11111], + "8899": [0.55001, 1.05, 0, 0, 1.11111], + "8968": [0.65002, 1.15, 0, 0, 0.52778], + "8969": [0.65002, 1.15, 0, 0, 0.52778], + "8970": [0.65002, 1.15, 0, 0, 0.52778], + "8971": [0.65002, 1.15, 0, 0, 0.52778], + "10216": [0.65002, 1.15, 0, 0, 0.61111], + "10217": [0.65002, 1.15, 0, 0, 0.61111], + "10752": [0.55001, 1.05, 0, 0, 1.51112], + "10753": [0.55001, 1.05, 0, 0, 1.51112], + "10754": [0.55001, 1.05, 0, 0, 1.51112], + "10756": [0.55001, 1.05, 0, 0, 1.11111], + "10758": [0.55001, 1.05, 0, 0, 1.11111] + }, + "Size3-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [0.95003, 1.45, 0, 0, 0.73611], + "41": [0.95003, 1.45, 0, 0, 0.73611], + "47": [0.95003, 1.45, 0, 0, 1.04445], + "91": [0.95003, 1.45, 0, 0, 0.52778], + "92": [0.95003, 1.45, 0, 0, 1.04445], + "93": [0.95003, 1.45, 0, 0, 0.52778], + "123": [0.95003, 1.45, 0, 0, 0.75], + "125": [0.95003, 1.45, 0, 0, 0.75], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.75, 0, 0, 1.44445], + "732": [0, 0.75, 0, 0, 1.44445], + "770": [0, 0.75, 0, 0, 1.44445], + "771": [0, 0.75, 0, 0, 1.44445], + "8730": [0.95003, 1.45, 0, 0, 1.0], + "8968": [0.95003, 1.45, 0, 0, 0.58334], + "8969": [0.95003, 1.45, 0, 0, 0.58334], + "8970": [0.95003, 1.45, 0, 0, 0.58334], + "8971": [0.95003, 1.45, 0, 0, 0.58334], + "10216": [0.95003, 1.45, 0, 0, 0.75], + "10217": [0.95003, 1.45, 0, 0, 0.75] + }, + "Size4-Regular": { + "32": [0, 0, 0, 0, 0.25], + "40": [1.25003, 1.75, 0, 0, 0.79167], + "41": [1.25003, 1.75, 0, 0, 0.79167], + "47": [1.25003, 1.75, 0, 0, 1.27778], + "91": [1.25003, 1.75, 0, 0, 0.58334], + "92": [1.25003, 1.75, 0, 0, 1.27778], + "93": [1.25003, 1.75, 0, 0, 0.58334], + "123": [1.25003, 1.75, 0, 0, 0.80556], + "125": [1.25003, 1.75, 0, 0, 0.80556], + "160": [0, 0, 0, 0, 0.25], + "710": [0, 0.825, 0, 0, 1.8889], + "732": [0, 0.825, 0, 0, 1.8889], + "770": [0, 0.825, 0, 0, 1.8889], + "771": [0, 0.825, 0, 0, 1.8889], + "8730": [1.25003, 1.75, 0, 0, 1.0], + "8968": [1.25003, 1.75, 0, 0, 0.63889], + "8969": [1.25003, 1.75, 0, 0, 0.63889], + "8970": [1.25003, 1.75, 0, 0, 0.63889], + "8971": [1.25003, 1.75, 0, 0, 0.63889], + "9115": [0.64502, 1.155, 0, 0, 0.875], + "9116": [1e-05, 0.6, 0, 0, 0.875], + "9117": [0.64502, 1.155, 0, 0, 0.875], + "9118": [0.64502, 1.155, 0, 0, 0.875], + "9119": [1e-05, 0.6, 0, 0, 0.875], + "9120": [0.64502, 1.155, 0, 0, 0.875], + "9121": [0.64502, 1.155, 0, 0, 0.66667], + "9122": [-0.00099, 0.601, 0, 0, 0.66667], + "9123": [0.64502, 1.155, 0, 0, 0.66667], + "9124": [0.64502, 1.155, 0, 0, 0.66667], + "9125": [-0.00099, 0.601, 0, 0, 0.66667], + "9126": [0.64502, 1.155, 0, 0, 0.66667], + "9127": [1e-05, 0.9, 0, 0, 0.88889], + "9128": [0.65002, 1.15, 0, 0, 0.88889], + "9129": [0.90001, 0, 0, 0, 0.88889], + "9130": [0, 0.3, 0, 0, 0.88889], + "9131": [1e-05, 0.9, 0, 0, 0.88889], + "9132": [0.65002, 1.15, 0, 0, 0.88889], + "9133": [0.90001, 0, 0, 0, 0.88889], + "9143": [0.88502, 0.915, 0, 0, 1.05556], + "10216": [1.25003, 1.75, 0, 0, 0.80556], + "10217": [1.25003, 1.75, 0, 0, 0.80556], + "57344": [-0.00499, 0.605, 0, 0, 1.05556], + "57345": [-0.00499, 0.605, 0, 0, 1.05556], + "57680": [0, 0.12, 0, 0, 0.45], + "57681": [0, 0.12, 0, 0, 0.45], + "57682": [0, 0.12, 0, 0, 0.45], + "57683": [0, 0.12, 0, 0, 0.45] + }, + "Typewriter-Regular": { + "32": [0, 0, 0, 0, 0.525], + "33": [0, 0.61111, 0, 0, 0.525], + "34": [0, 0.61111, 0, 0, 0.525], + "35": [0, 0.61111, 0, 0, 0.525], + "36": [0.08333, 0.69444, 0, 0, 0.525], + "37": [0.08333, 0.69444, 0, 0, 0.525], + "38": [0, 0.61111, 0, 0, 0.525], + "39": [0, 0.61111, 0, 0, 0.525], + "40": [0.08333, 0.69444, 0, 0, 0.525], + "41": [0.08333, 0.69444, 0, 0, 0.525], + "42": [0, 0.52083, 0, 0, 0.525], + "43": [-0.08056, 0.53055, 0, 0, 0.525], + "44": [0.13889, 0.125, 0, 0, 0.525], + "45": [-0.08056, 0.53055, 0, 0, 0.525], + "46": [0, 0.125, 0, 0, 0.525], + "47": [0.08333, 0.69444, 0, 0, 0.525], + "48": [0, 0.61111, 0, 0, 0.525], + "49": [0, 0.61111, 0, 0, 0.525], + "50": [0, 0.61111, 0, 0, 0.525], + "51": [0, 0.61111, 0, 0, 0.525], + "52": [0, 0.61111, 0, 0, 0.525], + "53": [0, 0.61111, 0, 0, 0.525], + "54": [0, 0.61111, 0, 0, 0.525], + "55": [0, 0.61111, 0, 0, 0.525], + "56": [0, 0.61111, 0, 0, 0.525], + "57": [0, 0.61111, 0, 0, 0.525], + "58": [0, 0.43056, 0, 0, 0.525], + "59": [0.13889, 0.43056, 0, 0, 0.525], + "60": [-0.05556, 0.55556, 0, 0, 0.525], + "61": [-0.19549, 0.41562, 0, 0, 0.525], + "62": [-0.05556, 0.55556, 0, 0, 0.525], + "63": [0, 0.61111, 0, 0, 0.525], + "64": [0, 0.61111, 0, 0, 0.525], + "65": [0, 0.61111, 0, 0, 0.525], + "66": [0, 0.61111, 0, 0, 0.525], + "67": [0, 0.61111, 0, 0, 0.525], + "68": [0, 0.61111, 0, 0, 0.525], + "69": [0, 0.61111, 0, 0, 0.525], + "70": [0, 0.61111, 0, 0, 0.525], + "71": [0, 0.61111, 0, 0, 0.525], + "72": [0, 0.61111, 0, 0, 0.525], + "73": [0, 0.61111, 0, 0, 0.525], + "74": [0, 0.61111, 0, 0, 0.525], + "75": [0, 0.61111, 0, 0, 0.525], + "76": [0, 0.61111, 0, 0, 0.525], + "77": [0, 0.61111, 0, 0, 0.525], + "78": [0, 0.61111, 0, 0, 0.525], + "79": [0, 0.61111, 0, 0, 0.525], + "80": [0, 0.61111, 0, 0, 0.525], + "81": [0.13889, 0.61111, 0, 0, 0.525], + "82": [0, 0.61111, 0, 0, 0.525], + "83": [0, 0.61111, 0, 0, 0.525], + "84": [0, 0.61111, 0, 0, 0.525], + "85": [0, 0.61111, 0, 0, 0.525], + "86": [0, 0.61111, 0, 0, 0.525], + "87": [0, 0.61111, 0, 0, 0.525], + "88": [0, 0.61111, 0, 0, 0.525], + "89": [0, 0.61111, 0, 0, 0.525], + "90": [0, 0.61111, 0, 0, 0.525], + "91": [0.08333, 0.69444, 0, 0, 0.525], + "92": [0.08333, 0.69444, 0, 0, 0.525], + "93": [0.08333, 0.69444, 0, 0, 0.525], + "94": [0, 0.61111, 0, 0, 0.525], + "95": [0.09514, 0, 0, 0, 0.525], + "96": [0, 0.61111, 0, 0, 0.525], + "97": [0, 0.43056, 0, 0, 0.525], + "98": [0, 0.61111, 0, 0, 0.525], + "99": [0, 0.43056, 0, 0, 0.525], + "100": [0, 0.61111, 0, 0, 0.525], + "101": [0, 0.43056, 0, 0, 0.525], + "102": [0, 0.61111, 0, 0, 0.525], + "103": [0.22222, 0.43056, 0, 0, 0.525], + "104": [0, 0.61111, 0, 0, 0.525], + "105": [0, 0.61111, 0, 0, 0.525], + "106": [0.22222, 0.61111, 0, 0, 0.525], + "107": [0, 0.61111, 0, 0, 0.525], + "108": [0, 0.61111, 0, 0, 0.525], + "109": [0, 0.43056, 0, 0, 0.525], + "110": [0, 0.43056, 0, 0, 0.525], + "111": [0, 0.43056, 0, 0, 0.525], + "112": [0.22222, 0.43056, 0, 0, 0.525], + "113": [0.22222, 0.43056, 0, 0, 0.525], + "114": [0, 0.43056, 0, 0, 0.525], + "115": [0, 0.43056, 0, 0, 0.525], + "116": [0, 0.55358, 0, 0, 0.525], + "117": [0, 0.43056, 0, 0, 0.525], + "118": [0, 0.43056, 0, 0, 0.525], + "119": [0, 0.43056, 0, 0, 0.525], + "120": [0, 0.43056, 0, 0, 0.525], + "121": [0.22222, 0.43056, 0, 0, 0.525], + "122": [0, 0.43056, 0, 0, 0.525], + "123": [0.08333, 0.69444, 0, 0, 0.525], + "124": [0.08333, 0.69444, 0, 0, 0.525], + "125": [0.08333, 0.69444, 0, 0, 0.525], + "126": [0, 0.61111, 0, 0, 0.525], + "127": [0, 0.61111, 0, 0, 0.525], + "160": [0, 0, 0, 0, 0.525], + "176": [0, 0.61111, 0, 0, 0.525], + "184": [0.19445, 0, 0, 0, 0.525], + "305": [0, 0.43056, 0, 0, 0.525], + "567": [0.22222, 0.43056, 0, 0, 0.525], + "711": [0, 0.56597, 0, 0, 0.525], + "713": [0, 0.56555, 0, 0, 0.525], + "714": [0, 0.61111, 0, 0, 0.525], + "715": [0, 0.61111, 0, 0, 0.525], + "728": [0, 0.61111, 0, 0, 0.525], + "730": [0, 0.61111, 0, 0, 0.525], + "770": [0, 0.61111, 0, 0, 0.525], + "771": [0, 0.61111, 0, 0, 0.525], + "776": [0, 0.61111, 0, 0, 0.525], + "915": [0, 0.61111, 0, 0, 0.525], + "916": [0, 0.61111, 0, 0, 0.525], + "920": [0, 0.61111, 0, 0, 0.525], + "923": [0, 0.61111, 0, 0, 0.525], + "926": [0, 0.61111, 0, 0, 0.525], + "928": [0, 0.61111, 0, 0, 0.525], + "931": [0, 0.61111, 0, 0, 0.525], + "933": [0, 0.61111, 0, 0, 0.525], + "934": [0, 0.61111, 0, 0, 0.525], + "936": [0, 0.61111, 0, 0, 0.525], + "937": [0, 0.61111, 0, 0, 0.525], + "8216": [0, 0.61111, 0, 0, 0.525], + "8217": [0, 0.61111, 0, 0, 0.525], + "8242": [0, 0.61111, 0, 0, 0.525], + "9251": [0.11111, 0.21944, 0, 0, 0.525] + } +}; + +/** + * This file contains metrics regarding fonts and individual symbols. The sigma + * and xi variables, as well as the metricMap map contain data extracted from + * TeX, TeX font metrics, and the TTF files. These data are then exposed via the + * `metrics` variable and the getCharacterMetrics function. + */ +// In TeX, there are actually three sets of dimensions, one for each of +// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4: +// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are +// provided in the arrays below, in that order. +// +// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively. +// This was determined by running the following script: +// +// latex -interaction=nonstopmode \ +// '\documentclass{article}\usepackage{amsmath}\begin{document}' \ +// '$a$ \expandafter\show\the\textfont2' \ +// '\expandafter\show\the\scriptfont2' \ +// '\expandafter\show\the\scriptscriptfont2' \ +// '\stop' +// +// The metrics themselves were retrieved using the following commands: +// +// tftopl cmsy10 +// tftopl cmsy7 +// tftopl cmsy5 +// +// The output of each of these commands is quite lengthy. The only part we +// care about is the FONTDIMEN section. Each value is measured in EMs. +var sigmasAndXis = { + slant: [0.250, 0.250, 0.250], + // sigma1 + space: [0.000, 0.000, 0.000], + // sigma2 + stretch: [0.000, 0.000, 0.000], + // sigma3 + shrink: [0.000, 0.000, 0.000], + // sigma4 + xHeight: [0.431, 0.431, 0.431], + // sigma5 + quad: [1.000, 1.171, 1.472], + // sigma6 + extraSpace: [0.000, 0.000, 0.000], + // sigma7 + num1: [0.677, 0.732, 0.925], + // sigma8 + num2: [0.394, 0.384, 0.387], + // sigma9 + num3: [0.444, 0.471, 0.504], + // sigma10 + denom1: [0.686, 0.752, 1.025], + // sigma11 + denom2: [0.345, 0.344, 0.532], + // sigma12 + sup1: [0.413, 0.503, 0.504], + // sigma13 + sup2: [0.363, 0.431, 0.404], + // sigma14 + sup3: [0.289, 0.286, 0.294], + // sigma15 + sub1: [0.150, 0.143, 0.200], + // sigma16 + sub2: [0.247, 0.286, 0.400], + // sigma17 + supDrop: [0.386, 0.353, 0.494], + // sigma18 + subDrop: [0.050, 0.071, 0.100], + // sigma19 + delim1: [2.390, 1.700, 1.980], + // sigma20 + delim2: [1.010, 1.157, 1.420], + // sigma21 + axisHeight: [0.250, 0.250, 0.250], + // sigma22 + // These font metrics are extracted from TeX by using tftopl on cmex10.tfm; + // they correspond to the font parameters of the extension fonts (family 3). + // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to + // match cmex7, we'd use cmex7.tfm values for script and scriptscript + // values. + defaultRuleThickness: [0.04, 0.049, 0.049], + // xi8; cmex7: 0.049 + bigOpSpacing1: [0.111, 0.111, 0.111], + // xi9 + bigOpSpacing2: [0.166, 0.166, 0.166], + // xi10 + bigOpSpacing3: [0.2, 0.2, 0.2], + // xi11 + bigOpSpacing4: [0.6, 0.611, 0.611], + // xi12; cmex7: 0.611 + bigOpSpacing5: [0.1, 0.143, 0.143], + // xi13; cmex7: 0.143 + // The \sqrt rule width is taken from the height of the surd character. + // Since we use the same font at all sizes, this thickness doesn't scale. + sqrtRuleThickness: [0.04, 0.04, 0.04], + // This value determines how large a pt is, for metrics which are defined + // in terms of pts. + // This value is also used in katex.less; if you change it make sure the + // values match. + ptPerEm: [10.0, 10.0, 10.0], + // The space between adjacent `|` columns in an array definition. From + // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm. + doubleRuleSep: [0.2, 0.2, 0.2], + // The width of separator lines in {array} environments. From + // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm. + arrayRuleWidth: [0.04, 0.04, 0.04], + // Two values from LaTeX source2e: + fboxsep: [0.3, 0.3, 0.3], + // 3 pt / ptPerEm + fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm + +}; // This map contains a mapping from font name and character code to character +// should have Latin-1 and Cyrillic characters, but may not depending on the +// operating system. The metrics do not account for extra height from the +// accents. In the case of Cyrillic characters which have both ascenders and +// descenders we prefer approximations with ascenders, primarily to prevent +// the fraction bar or root line from intersecting the glyph. +// TODO(kevinb) allow union of multiple glyph metrics for better accuracy. + +var extraCharacterMap = { + // Latin-1 + 'Å': 'A', + 'Ð': 'D', + 'Þ': 'o', + 'å': 'a', + 'ð': 'd', + 'þ': 'o', + // Cyrillic + 'А': 'A', + 'Б': 'B', + 'В': 'B', + 'Г': 'F', + 'Д': 'A', + 'Е': 'E', + 'Ж': 'K', + 'З': '3', + 'И': 'N', + 'Й': 'N', + 'К': 'K', + 'Л': 'N', + 'М': 'M', + 'Н': 'H', + 'О': 'O', + 'П': 'N', + 'Р': 'P', + 'С': 'C', + 'Т': 'T', + 'У': 'y', + 'Ф': 'O', + 'Х': 'X', + 'Ц': 'U', + 'Ч': 'h', + 'Ш': 'W', + 'Щ': 'W', + 'Ъ': 'B', + 'Ы': 'X', + 'Ь': 'B', + 'Э': '3', + 'Ю': 'X', + 'Я': 'R', + 'а': 'a', + 'б': 'b', + 'в': 'a', + 'г': 'r', + 'д': 'y', + 'е': 'e', + 'ж': 'm', + 'з': 'e', + 'и': 'n', + 'й': 'n', + 'к': 'n', + 'л': 'n', + 'м': 'm', + 'н': 'n', + 'о': 'o', + 'п': 'n', + 'р': 'p', + 'с': 'c', + 'т': 'o', + 'у': 'y', + 'ф': 'b', + 'х': 'x', + 'ц': 'n', + 'ч': 'n', + 'ш': 'w', + 'щ': 'w', + 'ъ': 'a', + 'ы': 'm', + 'ь': 'a', + 'э': 'e', + 'ю': 'm', + 'я': 'r' +}; + +/** + * This function adds new font metrics to default metricMap + * It can also override existing metrics + */ +function setFontMetrics(fontName, metrics) { + fontMetricsData[fontName] = metrics; +} +/** + * This function is a convenience function for looking up information in the + * metricMap table. It takes a character as a string, and a font. + * + * Note: the `width` property may be undefined if fontMetricsData.js wasn't + * built using `Make extended_metrics`. + */ + +function getCharacterMetrics(character, font, mode) { + if (!fontMetricsData[font]) { + throw new Error("Font metrics not found for font: " + font + "."); + } + + var ch = character.charCodeAt(0); + var metrics = fontMetricsData[font][ch]; + + if (!metrics && character[0] in extraCharacterMap) { + ch = extraCharacterMap[character[0]].charCodeAt(0); + metrics = fontMetricsData[font][ch]; + } + + if (!metrics && mode === 'text') { + // We don't typically have font metrics for Asian scripts. + // But since we support them in text mode, we need to return + // some sort of metrics. + // So if the character is in a script we support but we + // don't have metrics for it, just use the metrics for + // the Latin capital letter M. This is close enough because + // we (currently) only care about the height of the glyph + // not its width. + if (supportedCodepoint(ch)) { + metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M' + } + } + + if (metrics) { + return { + depth: metrics[0], + height: metrics[1], + italic: metrics[2], + skew: metrics[3], + width: metrics[4] + }; + } +} +var fontMetricsBySizeIndex = {}; +/** + * Get the font metrics for a given size. + */ + +function getGlobalMetrics(size) { + var sizeIndex; + + if (size >= 5) { + sizeIndex = 0; + } else if (size >= 3) { + sizeIndex = 1; + } else { + sizeIndex = 2; + } + + if (!fontMetricsBySizeIndex[sizeIndex]) { + var metrics = fontMetricsBySizeIndex[sizeIndex] = { + cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18 + }; + + for (var key in sigmasAndXis) { + if (sigmasAndXis.hasOwnProperty(key)) { + metrics[key] = sigmasAndXis[key][sizeIndex]; + } + } + } + + return fontMetricsBySizeIndex[sizeIndex]; +} + +/** + * This file contains information about the options that the Parser carries + * around with it while parsing. Data is held in an `Options` object, and when + * recursing, a new `Options` object can be created with the `.with*` and + * `.reset` functions. + */ +var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize]. +// The size mappings are taken from TeX with \normalsize=10pt. +[1, 1, 1], // size1: [5, 5, 5] \tiny +[2, 1, 1], // size2: [6, 5, 5] +[3, 1, 1], // size3: [7, 5, 5] \scriptsize +[4, 2, 1], // size4: [8, 6, 5] \footnotesize +[5, 2, 1], // size5: [9, 6, 5] \small +[6, 3, 1], // size6: [10, 7, 5] \normalsize +[7, 4, 2], // size7: [12, 8, 6] \large +[8, 6, 3], // size8: [14.4, 10, 7] \Large +[9, 7, 6], // size9: [17.28, 12, 10] \LARGE +[10, 8, 7], // size10: [20.74, 14.4, 12] \huge +[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE +]; +var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if +// you change size indexes, change that function. +0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488]; + +var sizeAtStyle = function sizeAtStyle(size, style) { + return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1]; +}; // In these types, "" (empty string) means "no change". + + +/** + * This is the main options class. It contains the current style, size, color, + * and font. + * + * Options objects should not be modified. To create a new Options with + * different properties, call a `.having*` method. + */ +class Options { + // A font family applies to a group of fonts (i.e. SansSerif), while a font + // represents a specific font (i.e. SansSerif Bold). + // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm + + /** + * The base size index. + */ + constructor(data) { + this.style = void 0; + this.color = void 0; + this.size = void 0; + this.textSize = void 0; + this.phantom = void 0; + this.font = void 0; + this.fontFamily = void 0; + this.fontWeight = void 0; + this.fontShape = void 0; + this.sizeMultiplier = void 0; + this.maxSize = void 0; + this.minRuleThickness = void 0; + this._fontMetrics = void 0; + this.style = data.style; + this.color = data.color; + this.size = data.size || Options.BASESIZE; + this.textSize = data.textSize || this.size; + this.phantom = !!data.phantom; + this.font = data.font || ""; + this.fontFamily = data.fontFamily || ""; + this.fontWeight = data.fontWeight || ''; + this.fontShape = data.fontShape || ''; + this.sizeMultiplier = sizeMultipliers[this.size - 1]; + this.maxSize = data.maxSize; + this.minRuleThickness = data.minRuleThickness; + this._fontMetrics = undefined; + } + /** + * Returns a new options object with the same properties as "this". Properties + * from "extension" will be copied to the new options object. + */ + + + extend(extension) { + var data = { + style: this.style, + size: this.size, + textSize: this.textSize, + color: this.color, + phantom: this.phantom, + font: this.font, + fontFamily: this.fontFamily, + fontWeight: this.fontWeight, + fontShape: this.fontShape, + maxSize: this.maxSize, + minRuleThickness: this.minRuleThickness + }; + + for (var key in extension) { + if (extension.hasOwnProperty(key)) { + data[key] = extension[key]; + } + } + + return new Options(data); + } + /** + * Return an options object with the given style. If `this.style === style`, + * returns `this`. + */ + + + havingStyle(style) { + if (this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: sizeAtStyle(this.textSize, style) + }); + } + } + /** + * Return an options object with a cramped version of the current style. If + * the current style is cramped, returns `this`. + */ + + + havingCrampedStyle() { + return this.havingStyle(this.style.cramp()); + } + /** + * Return an options object with the given size and in at least `\textstyle`. + * Returns `this` if appropriate. + */ + + + havingSize(size) { + if (this.size === size && this.textSize === size) { + return this; + } else { + return this.extend({ + style: this.style.text(), + size: size, + textSize: size, + sizeMultiplier: sizeMultipliers[size - 1] + }); + } + } + /** + * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted, + * changes to at least `\textstyle`. + */ + + + havingBaseStyle(style) { + style = style || this.style.text(); + var wantSize = sizeAtStyle(Options.BASESIZE, style); + + if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) { + return this; + } else { + return this.extend({ + style: style, + size: wantSize + }); + } + } + /** + * Remove the effect of sizing changes such as \Huge. + * Keep the effect of the current style, such as \scriptstyle. + */ + + + havingBaseSizing() { + var size; + + switch (this.style.id) { + case 4: + case 5: + size = 3; // normalsize in scriptstyle + + break; + + case 6: + case 7: + size = 1; // normalsize in scriptscriptstyle + + break; + + default: + size = 6; + // normalsize in textstyle or displaystyle + } + + return this.extend({ + style: this.style.text(), + size: size + }); + } + /** + * Create a new options object with the given color. + */ + + + withColor(color) { + return this.extend({ + color: color + }); + } + /** + * Create a new options object with "phantom" set to true. + */ + + + withPhantom() { + return this.extend({ + phantom: true + }); + } + /** + * Creates a new options object with the given math font or old text font. + * @type {[type]} + */ + + + withFont(font) { + return this.extend({ + font + }); + } + /** + * Create a new options objects with the given fontFamily. + */ + + + withTextFontFamily(fontFamily) { + return this.extend({ + fontFamily, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontWeight(fontWeight) { + return this.extend({ + fontWeight, + font: "" + }); + } + /** + * Creates a new options object with the given font weight + */ + + + withTextFontShape(fontShape) { + return this.extend({ + fontShape, + font: "" + }); + } + /** + * Return the CSS sizing classes required to switch from enclosing options + * `oldOptions` to `this`. Returns an array of classes. + */ + + + sizingClasses(oldOptions) { + if (oldOptions.size !== this.size) { + return ["sizing", "reset-size" + oldOptions.size, "size" + this.size]; + } else { + return []; + } + } + /** + * Return the CSS sizing classes required to switch to the base size. Like + * `this.havingSize(BASESIZE).sizingClasses(this)`. + */ + + + baseSizingClasses() { + if (this.size !== Options.BASESIZE) { + return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE]; + } else { + return []; + } + } + /** + * Return the font metrics for this size. + */ + + + fontMetrics() { + if (!this._fontMetrics) { + this._fontMetrics = getGlobalMetrics(this.size); + } + + return this._fontMetrics; + } + /** + * Gets the CSS color of the current options object + */ + + + getColor() { + if (this.phantom) { + return "transparent"; + } else { + return this.color; + } + } + +} + +Options.BASESIZE = 6; + +/** + * This file does conversion between units. In particular, it provides + * calculateSize to convert other units into ems. + */ +// Thus, multiplying a length by this number converts the length from units +// into pts. Dividing the result by ptPerEm gives the number of ems +// *assuming* a font size of ptPerEm (normal size, normal style). + +var ptPerUnit = { + // https://en.wikibooks.org/wiki/LaTeX/Lengths and + // https://tex.stackexchange.com/a/8263 + "pt": 1, + // TeX point + "mm": 7227 / 2540, + // millimeter + "cm": 7227 / 254, + // centimeter + "in": 72.27, + // inch + "bp": 803 / 800, + // big (PostScript) points + "pc": 12, + // pica + "dd": 1238 / 1157, + // didot + "cc": 14856 / 1157, + // cicero (12 didot) + "nd": 685 / 642, + // new didot + "nc": 1370 / 107, + // new cicero (12 new didot) + "sp": 1 / 65536, + // scaled point (TeX's internal smallest unit) + // https://tex.stackexchange.com/a/41371 + "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX + +}; // Dictionary of relative units, for fast validity testing. + +var relativeUnit = { + "ex": true, + "em": true, + "mu": true +}; + +/** + * Determine whether the specified unit (either a string defining the unit + * or a "size" parse node containing a unit field) is valid. + */ +var validUnit = function validUnit(unit) { + if (typeof unit !== "string") { + unit = unit.unit; + } + + return unit in ptPerUnit || unit in relativeUnit || unit === "ex"; +}; +/* + * Convert a "size" parse node (with numeric "number" and string "unit" fields, + * as parsed by functions.js argType "size") into a CSS em value for the + * current style/scale. `options` gives the current options. + */ + +var calculateSize = function calculateSize(sizeValue, options) { + var scale; + + if (sizeValue.unit in ptPerUnit) { + // Absolute units + scale = ptPerUnit[sizeValue.unit] // Convert unit to pt + / options.fontMetrics().ptPerEm // Convert pt to CSS em + / options.sizeMultiplier; // Unscale to make absolute units + } else if (sizeValue.unit === "mu") { + // `mu` units scale with scriptstyle/scriptscriptstyle. + scale = options.fontMetrics().cssEmPerMu; + } else { + // Other relative units always refer to the *textstyle* font + // in the current size. + var unitOptions; + + if (options.style.isTight()) { + // isTight() means current style is script/scriptscript. + unitOptions = options.havingStyle(options.style.text()); + } else { + unitOptions = options; + } // TODO: In TeX these units are relative to the quad of the current + // *text* font, e.g. cmr10. KaTeX instead uses values from the + // comparably-sized *Computer Modern symbol* font. At 10pt, these + // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641; + // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$. + // TeX \showlists shows a kern of 1.13889 * fontsize; + // KaTeX shows a kern of 1.171 * fontsize. + + + if (sizeValue.unit === "ex") { + scale = unitOptions.fontMetrics().xHeight; + } else if (sizeValue.unit === "em") { + scale = unitOptions.fontMetrics().quad; + } else { + throw new ParseError("Invalid unit: '" + sizeValue.unit + "'"); + } + + if (unitOptions !== options) { + scale *= unitOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + return Math.min(sizeValue.number * scale, options.maxSize); +}; +/** + * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See + * https://github.com/KaTeX/KaTeX/pull/2460. + */ + +var makeEm = function makeEm(n) { + return +n.toFixed(4) + "em"; +}; + +/** + * These objects store the data about the DOM nodes we create, as well as some + * extra data. They can then be transformed into real DOM nodes with the + * `toNode` function or HTML markup using `toMarkup`. They are useful for both + * storing extra properties on the nodes, as well as providing a way to easily + * work with the DOM. + * + * Similar functions for working with MathML nodes exist in mathMLTree.js. + * + * TODO: refactor `span` and `anchor` into common superclass when + * target environments support class inheritance + */ + +/** + * Create an HTML className based on a list of classes. In addition to joining + * with spaces, we also remove empty classes. + */ +var createClass = function createClass(classes) { + return classes.filter(cls => cls).join(" "); +}; + +var initNode = function initNode(classes, options, style) { + this.classes = classes || []; + this.attributes = {}; + this.height = 0; + this.depth = 0; + this.maxFontSize = 0; + this.style = style || {}; + + if (options) { + if (options.style.isTight()) { + this.classes.push("mtight"); + } + + var color = options.getColor(); + + if (color) { + this.style.color = color; + } + } +}; +/** + * Convert into an HTML node + */ + + +var toNode = function toNode(tagName) { + var node = document.createElement(tagName); // Apply the class + + node.className = createClass(this.classes); // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe Flow doesn't seem to understand span.style's type. + node.style[style] = this.style[style]; + } + } // Apply attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } // Append the children, also as HTML nodes + + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; +}; +/** + * Convert into an HTML markup string + */ + + +var toMarkup = function toMarkup(tagName) { + var markup = "<" + tagName; // Add the class + + if (this.classes.length) { + markup += " class=\"" + utils$1.escape(createClass(this.classes)) + "\""; + } + + var styles = ""; // Add the styles, after hyphenation + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils$1.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + markup += " style=\"" + utils$1.escape(styles) + "\""; + } // Add the attributes + + + for (var attr in this.attributes) { + if (this.attributes.hasOwnProperty(attr)) { + markup += " " + attr + "=\"" + utils$1.escape(this.attributes[attr]) + "\""; + } + } + + markup += ">"; // Add the markup of the children, also as markup + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. +// This type does not include all CSS properties. Additional properties should +// be added as needed. + + +/** + * This node represents a span node, with a className, a list of children, and + * an inline style. It also contains information about its height, depth, and + * maxFontSize. + * + * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan + * otherwise. This typesafety is important when HTML builders access a span's + * children. + */ +class Span { + constructor(classes, children, options, style) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.width = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options, style); + this.children = children || []; + } + /** + * Sets an arbitrary attribute on the span. Warning: use this wisely. Not + * all browsers support attributes the same, and having too many custom + * attributes is probably bad. + */ + + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "span"); + } + + toMarkup() { + return toMarkup.call(this, "span"); + } + +} +/** + * This node represents an anchor (
    ) element with a hyperlink. See `span` + * for further details. + */ + +class Anchor { + constructor(href, classes, children, options) { + this.children = void 0; + this.attributes = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + initNode.call(this, classes, options); + this.children = children || []; + this.setAttribute('href', href); + } + + setAttribute(attribute, value) { + this.attributes[attribute] = value; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + + toNode() { + return toNode.call(this, "a"); + } + + toMarkup() { + return toMarkup.call(this, "a"); + } + +} +/** + * This node represents an image embed () element. + */ + +class Img { + constructor(src, alt, style) { + this.src = void 0; + this.alt = void 0; + this.classes = void 0; + this.height = void 0; + this.depth = void 0; + this.maxFontSize = void 0; + this.style = void 0; + this.alt = alt; + this.src = src; + this.classes = ["mord"]; + this.style = style; + } + + hasClass(className) { + return utils$1.contains(this.classes, className); + } + + toNode() { + var node = document.createElement("img"); + node.src = this.src; + node.alt = this.alt; + node.className = "mord"; // Apply inline styles + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + // $FlowFixMe + node.style[style] = this.style[style]; + } + } + + return node; + } + + toMarkup() { + var markup = "\"" 0) { + span = document.createElement("span"); + span.style.marginRight = makeEm(this.italic); + } + + if (this.classes.length > 0) { + span = span || document.createElement("span"); + span.className = createClass(this.classes); + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type. + + span.style[style] = this.style[style]; + } + } + + if (span) { + span.appendChild(node); + return span; + } else { + return node; + } + } + /** + * Creates markup for a symbol node. + */ + + + toMarkup() { + // TODO(alpert): More duplication than I'd like from + // span.prototype.toMarkup and symbolNode.prototype.toNode... + var needsSpan = false; + var markup = " 0) { + styles += "margin-right:" + this.italic + "em;"; + } + + for (var style in this.style) { + if (this.style.hasOwnProperty(style)) { + styles += utils$1.hyphenate(style) + ":" + this.style[style] + ";"; + } + } + + if (styles) { + needsSpan = true; + markup += " style=\"" + utils$1.escape(styles) + "\""; + } + + var escaped = utils$1.escape(this.text); + + if (needsSpan) { + markup += ">"; + markup += escaped; + markup += ""; + return markup; + } else { + return escaped; + } + } + +} +/** + * SVG nodes are used to render stretchy wide elements. + */ + +class SvgNode { + constructor(children, attributes) { + this.children = void 0; + this.attributes = void 0; + this.children = children || []; + this.attributes = attributes || {}; + } + + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "svg"); // Apply attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; + } + + toMarkup() { + var markup = ""; + } else { + return ""; + } + } + +} +class LineNode { + constructor(attributes) { + this.attributes = void 0; + this.attributes = attributes || {}; + } + + toNode() { + var svgNS = "http://www.w3.org/2000/svg"; + var node = document.createElementNS(svgNS, "line"); // Apply attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + return node; + } + + toMarkup() { + var markup = " but got " + String(group) + "."); + } +} + +/** + * This file holds a list of all no-argument functions and single-character + * symbols (like 'a' or ';'). + * + * For each of the symbols, there are three properties they can have: + * - font (required): the font to be used for this symbol. Either "main" (the + normal font), or "ams" (the ams fonts). + * - group (required): the ParseNode group type the symbol should have (i.e. + "textord", "mathord", etc). + See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types + * - replace: the character that this symbol or function should be + * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi + * character in the main font). + * + * The outermost map in the table indicates what mode the symbols should be + * accepted in (e.g. "math" or "text"). + */ +// Some of these have a "-token" suffix since these are also used as `ParseNode` +// types for raw text tokens, and we want to avoid conflicts with higher-level +// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by +// looking up the `symbols` map. +var ATOMS = { + "bin": 1, + "close": 1, + "inner": 1, + "open": 1, + "punct": 1, + "rel": 1 +}; +var NON_ATOMS = { + "accent-token": 1, + "mathord": 1, + "op-token": 1, + "spacing": 1, + "textord": 1 +}; +var symbols = { + "math": {}, + "text": {} +}; +/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */ + +function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) { + symbols[mode][name] = { + font, + group, + replace + }; + + if (acceptUnicodeChar && replace) { + symbols[mode][replace] = symbols[mode][name]; + } +} // Some abbreviations for commonly used strings. +// This helps minify the code, and also spotting typos using jshint. +// modes: + +var math = "math"; +var text$4 = "text"; // fonts: + +var main = "main"; +var ams = "ams"; // groups: + +var accent = "accent-token"; +var bin = "bin"; +var close = "close"; +var inner = "inner"; +var mathord = "mathord"; +var op = "op-token"; +var open = "open"; +var punct = "punct"; +var rel = "rel"; +var spacing = "spacing"; +var textord = "textord"; // Now comes the symbol table +// Relation Symbols + +defineSymbol(math, main, rel, "\u2261", "\\equiv", true); +defineSymbol(math, main, rel, "\u227a", "\\prec", true); +defineSymbol(math, main, rel, "\u227b", "\\succ", true); +defineSymbol(math, main, rel, "\u223c", "\\sim", true); +defineSymbol(math, main, rel, "\u22a5", "\\perp"); +defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true); +defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true); +defineSymbol(math, main, rel, "\u2243", "\\simeq", true); +defineSymbol(math, main, rel, "\u2223", "\\mid", true); +defineSymbol(math, main, rel, "\u226a", "\\ll", true); +defineSymbol(math, main, rel, "\u226b", "\\gg", true); +defineSymbol(math, main, rel, "\u224d", "\\asymp", true); +defineSymbol(math, main, rel, "\u2225", "\\parallel"); +defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true); +defineSymbol(math, main, rel, "\u2323", "\\smile", true); +defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true); +defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true); +defineSymbol(math, main, rel, "\u2250", "\\doteq", true); +defineSymbol(math, main, rel, "\u2322", "\\frown", true); +defineSymbol(math, main, rel, "\u220b", "\\ni", true); +defineSymbol(math, main, rel, "\u221d", "\\propto", true); +defineSymbol(math, main, rel, "\u22a2", "\\vdash", true); +defineSymbol(math, main, rel, "\u22a3", "\\dashv", true); +defineSymbol(math, main, rel, "\u220b", "\\owns"); // Punctuation + +defineSymbol(math, main, punct, "\u002e", "\\ldotp"); +defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols + +defineSymbol(math, main, textord, "\u0023", "\\#"); +defineSymbol(text$4, main, textord, "\u0023", "\\#"); +defineSymbol(math, main, textord, "\u0026", "\\&"); +defineSymbol(text$4, main, textord, "\u0026", "\\&"); +defineSymbol(math, main, textord, "\u2135", "\\aleph", true); +defineSymbol(math, main, textord, "\u2200", "\\forall", true); +defineSymbol(math, main, textord, "\u210f", "\\hbar", true); +defineSymbol(math, main, textord, "\u2203", "\\exists", true); +defineSymbol(math, main, textord, "\u2207", "\\nabla", true); +defineSymbol(math, main, textord, "\u266d", "\\flat", true); +defineSymbol(math, main, textord, "\u2113", "\\ell", true); +defineSymbol(math, main, textord, "\u266e", "\\natural", true); +defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true); +defineSymbol(math, main, textord, "\u2118", "\\wp", true); +defineSymbol(math, main, textord, "\u266f", "\\sharp", true); +defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true); +defineSymbol(math, main, textord, "\u211c", "\\Re", true); +defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true); +defineSymbol(math, main, textord, "\u2111", "\\Im", true); +defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true); +defineSymbol(math, main, textord, "\u00a7", "\\S", true); +defineSymbol(text$4, main, textord, "\u00a7", "\\S"); +defineSymbol(math, main, textord, "\u00b6", "\\P", true); +defineSymbol(text$4, main, textord, "\u00b6", "\\P"); // Math and Text + +defineSymbol(math, main, textord, "\u2020", "\\dag"); +defineSymbol(text$4, main, textord, "\u2020", "\\dag"); +defineSymbol(text$4, main, textord, "\u2020", "\\textdagger"); +defineSymbol(math, main, textord, "\u2021", "\\ddag"); +defineSymbol(text$4, main, textord, "\u2021", "\\ddag"); +defineSymbol(text$4, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters + +defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true); +defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true); +defineSymbol(math, main, close, "\u27ef", "\\rgroup", true); +defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); // Binary Operators + +defineSymbol(math, main, bin, "\u2213", "\\mp", true); +defineSymbol(math, main, bin, "\u2296", "\\ominus", true); +defineSymbol(math, main, bin, "\u228e", "\\uplus", true); +defineSymbol(math, main, bin, "\u2293", "\\sqcap", true); +defineSymbol(math, main, bin, "\u2217", "\\ast"); +defineSymbol(math, main, bin, "\u2294", "\\sqcup", true); +defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true); +defineSymbol(math, main, bin, "\u2219", "\\bullet", true); +defineSymbol(math, main, bin, "\u2021", "\\ddagger"); +defineSymbol(math, main, bin, "\u2240", "\\wr", true); +defineSymbol(math, main, bin, "\u2a3f", "\\amalg"); +defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath +// Arrow Symbols + +defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true); +defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true); +defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true); +defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true); +defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true); +defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true); +defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true); +defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true); +defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true); +defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true); +defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true); +defineSymbol(math, main, rel, "\u2197", "\\nearrow", true); +defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true); +defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true); +defineSymbol(math, main, rel, "\u2198", "\\searrow", true); +defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true); +defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true); +defineSymbol(math, main, rel, "\u2199", "\\swarrow", true); +defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true); +defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true); +defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true); +defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); // AMS Negated Binary Relations + +defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceded by "@" each have a corresponding macro. + +defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant"); +defineSymbol(math, ams, rel, "\ue011", "\\@nleqq"); +defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true); +defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true); +defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq"); +defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true); +defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true); +defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true); +defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true); +defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true); +defineSymbol(math, ams, rel, "\u2241", "\\nsim", true); +defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid"); +defineSymbol(math, ams, rel, "\u2224", "\\nmid", true); +defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true); +defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true); +defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft"); +defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true); +defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true); +defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq"); +defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true); +defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq"); +defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true); +defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant"); +defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq"); +defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true); +defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true); +defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq"); +defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true); +defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true); +defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true); +defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true); +defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u2246", "\\ncong", true); +defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel"); +defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true); +defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true); +defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright"); +defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true); +defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq"); +defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true); +defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq"); +defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true); +defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq"); +defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true); +defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true); +defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true); +defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq"); +defineSymbol(math, ams, bin, "\u22b4", "\\unlhd"); +defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); // AMS Negated Arrows + +defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true); +defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true); +defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true); +defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true); +defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true); +defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); // AMS Misc + +defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle"); +defineSymbol(math, ams, textord, "\u210f", "\\hslash"); +defineSymbol(math, ams, textord, "\u25bd", "\\triangledown"); +defineSymbol(math, ams, textord, "\u25ca", "\\lozenge"); +defineSymbol(math, ams, textord, "\u24c8", "\\circledS"); +defineSymbol(math, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(text$4, ams, textord, "\u00ae", "\\circledR"); +defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true); +defineSymbol(math, ams, textord, "\u2204", "\\nexists"); +defineSymbol(math, ams, textord, "\u2127", "\\mho"); +defineSymbol(math, ams, textord, "\u2132", "\\Finv", true); +defineSymbol(math, ams, textord, "\u2141", "\\Game", true); +defineSymbol(math, ams, textord, "\u2035", "\\backprime"); +defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle"); +defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown"); +defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare"); +defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge"); +defineSymbol(math, ams, textord, "\u2605", "\\bigstar"); +defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true); +defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth + +defineSymbol(math, ams, textord, "\u00f0", "\\eth", true); +defineSymbol(text$4, main, textord, "\u00f0", "\u00f0"); +defineSymbol(math, ams, textord, "\u2571", "\\diagup"); +defineSymbol(math, ams, textord, "\u2572", "\\diagdown"); +defineSymbol(math, ams, textord, "\u25a1", "\\square"); +defineSymbol(math, ams, textord, "\u25a1", "\\Box"); +defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen + +defineSymbol(math, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(text$4, ams, textord, "\u00a5", "\\yen", true); +defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true); +defineSymbol(text$4, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew + +defineSymbol(math, ams, textord, "\u2136", "\\beth", true); +defineSymbol(math, ams, textord, "\u2138", "\\daleth", true); +defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek + +defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true); +defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters + +defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true); +defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true); +defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true); +defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations + +defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); +defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true); +defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true); +defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true); +defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true); +defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true); +defineSymbol(math, ams, bin, "\u22d6", "\\lessdot"); +defineSymbol(math, ams, rel, "\u22d8", "\\lll", true); +defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true); +defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true); +defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true); +defineSymbol(math, ams, rel, "\u2251", "\\doteqdot"); +defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true); +defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true); +defineSymbol(math, ams, rel, "\u223d", "\\backsim", true); +defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true); +defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true); +defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true); +defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true); +defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true); +defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true); +defineSymbol(math, ams, rel, "\u227e", "\\precsim", true); +defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true); +defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft"); +defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq"); +defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true); +defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true); +defineSymbol(math, ams, rel, "\u2323", "\\smallsmile"); +defineSymbol(math, ams, rel, "\u2322", "\\smallfrown"); +defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true); +defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true); +defineSymbol(math, ams, rel, "\u2267", "\\geqq", true); +defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true); +defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true); +defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true); +defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true); +defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot"); +defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true); +defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true); +defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true); +defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true); +defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true); +defineSymbol(math, ams, rel, "\u2257", "\\circeq", true); +defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true); +defineSymbol(math, ams, rel, "\u223c", "\\thicksim"); +defineSymbol(math, ams, rel, "\u2248", "\\thickapprox"); +defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true); +defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true); +defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true); +defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true); +defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true); +defineSymbol(math, ams, rel, "\u227f", "\\succsim", true); +defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true); +defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright"); +defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq"); +defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true); +defineSymbol(math, ams, rel, "\u2223", "\\shortmid"); +defineSymbol(math, ams, rel, "\u2225", "\\shortparallel"); +defineSymbol(math, ams, rel, "\u226c", "\\between", true); +defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true); +defineSymbol(math, ams, rel, "\u221d", "\\varpropto"); +defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom. +// We kept the amssymb atom type, which is rel. + +defineSymbol(math, ams, rel, "\u2234", "\\therefore", true); +defineSymbol(math, ams, rel, "\u220d", "\\backepsilon"); +defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom. +// We kept the amssymb atom type, which is rel. + +defineSymbol(math, ams, rel, "\u2235", "\\because", true); +defineSymbol(math, ams, rel, "\u22d8", "\\llless"); +defineSymbol(math, ams, rel, "\u22d9", "\\gggtr"); +defineSymbol(math, ams, bin, "\u22b2", "\\lhd"); +defineSymbol(math, ams, bin, "\u22b3", "\\rhd"); +defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true); +defineSymbol(math, main, rel, "\u22c8", "\\Join"); +defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators + +defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true); +defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus"); +defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true); +defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true); +defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true); +defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true); +defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true); +defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true); +defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true); +defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true); +defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true); +defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true); +defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true); +defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true); +defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true); +defineSymbol(math, ams, bin, "\u229b", "\\circledast", true); +defineSymbol(math, ams, bin, "\u22c5", "\\centerdot"); +defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true); +defineSymbol(math, ams, bin, "\u22d2", "\\doublecap"); +defineSymbol(math, ams, bin, "\u22d3", "\\doublecup"); +defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); // AMS Arrows +// Note: unicode-math maps \u21e2 to their own function \rightdasharrow. +// We'll map it to AMS function \dashrightarrow. It produces the same atom. + +defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true); +defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true); +defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true); +defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true); +defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true); +defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true); +defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true); +defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true); +defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true); +defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true); +defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true); +defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true); +defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true); +defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font + +defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font + +defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true); +defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true); +defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true); +defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true); +defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true); +defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true); +defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym. + +defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true); +defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true); +defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true); +defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true); +defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true); +defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true); +defineSymbol(math, ams, rel, "\u21dd", "\\leadsto"); +defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true); +defineSymbol(math, ams, rel, "\u21be", "\\restriction"); +defineSymbol(math, main, textord, "\u2018", "`"); +defineSymbol(math, main, textord, "$", "\\$"); +defineSymbol(text$4, main, textord, "$", "\\$"); +defineSymbol(text$4, main, textord, "$", "\\textdollar"); +defineSymbol(math, main, textord, "%", "\\%"); +defineSymbol(text$4, main, textord, "%", "\\%"); +defineSymbol(math, main, textord, "_", "\\_"); +defineSymbol(text$4, main, textord, "_", "\\_"); +defineSymbol(text$4, main, textord, "_", "\\textunderscore"); +defineSymbol(math, main, textord, "\u2220", "\\angle", true); +defineSymbol(math, main, textord, "\u221e", "\\infty", true); +defineSymbol(math, main, textord, "\u2032", "\\prime"); +defineSymbol(math, main, textord, "\u25b3", "\\triangle"); +defineSymbol(math, main, textord, "\u0393", "\\Gamma", true); +defineSymbol(math, main, textord, "\u0394", "\\Delta", true); +defineSymbol(math, main, textord, "\u0398", "\\Theta", true); +defineSymbol(math, main, textord, "\u039b", "\\Lambda", true); +defineSymbol(math, main, textord, "\u039e", "\\Xi", true); +defineSymbol(math, main, textord, "\u03a0", "\\Pi", true); +defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true); +defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true); +defineSymbol(math, main, textord, "\u03a6", "\\Phi", true); +defineSymbol(math, main, textord, "\u03a8", "\\Psi", true); +defineSymbol(math, main, textord, "\u03a9", "\\Omega", true); +defineSymbol(math, main, textord, "A", "\u0391"); +defineSymbol(math, main, textord, "B", "\u0392"); +defineSymbol(math, main, textord, "E", "\u0395"); +defineSymbol(math, main, textord, "Z", "\u0396"); +defineSymbol(math, main, textord, "H", "\u0397"); +defineSymbol(math, main, textord, "I", "\u0399"); +defineSymbol(math, main, textord, "K", "\u039A"); +defineSymbol(math, main, textord, "M", "\u039C"); +defineSymbol(math, main, textord, "N", "\u039D"); +defineSymbol(math, main, textord, "O", "\u039F"); +defineSymbol(math, main, textord, "P", "\u03A1"); +defineSymbol(math, main, textord, "T", "\u03A4"); +defineSymbol(math, main, textord, "X", "\u03A7"); +defineSymbol(math, main, textord, "\u00ac", "\\neg", true); +defineSymbol(math, main, textord, "\u00ac", "\\lnot"); +defineSymbol(math, main, textord, "\u22a4", "\\top"); +defineSymbol(math, main, textord, "\u22a5", "\\bot"); +defineSymbol(math, main, textord, "\u2205", "\\emptyset"); +defineSymbol(math, ams, textord, "\u2205", "\\varnothing"); +defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true); +defineSymbol(math, main, mathord, "\u03b2", "\\beta", true); +defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true); +defineSymbol(math, main, mathord, "\u03b4", "\\delta", true); +defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true); +defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true); +defineSymbol(math, main, mathord, "\u03b7", "\\eta", true); +defineSymbol(math, main, mathord, "\u03b8", "\\theta", true); +defineSymbol(math, main, mathord, "\u03b9", "\\iota", true); +defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true); +defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true); +defineSymbol(math, main, mathord, "\u03bc", "\\mu", true); +defineSymbol(math, main, mathord, "\u03bd", "\\nu", true); +defineSymbol(math, main, mathord, "\u03be", "\\xi", true); +defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true); +defineSymbol(math, main, mathord, "\u03c0", "\\pi", true); +defineSymbol(math, main, mathord, "\u03c1", "\\rho", true); +defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true); +defineSymbol(math, main, mathord, "\u03c4", "\\tau", true); +defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true); +defineSymbol(math, main, mathord, "\u03d5", "\\phi", true); +defineSymbol(math, main, mathord, "\u03c7", "\\chi", true); +defineSymbol(math, main, mathord, "\u03c8", "\\psi", true); +defineSymbol(math, main, mathord, "\u03c9", "\\omega", true); +defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true); +defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true); +defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true); +defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true); +defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true); +defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true); +defineSymbol(math, main, bin, "\u2217", "*", true); +defineSymbol(math, main, bin, "+", "+"); +defineSymbol(math, main, bin, "\u2212", "-", true); +defineSymbol(math, main, bin, "\u22c5", "\\cdot", true); +defineSymbol(math, main, bin, "\u2218", "\\circ", true); +defineSymbol(math, main, bin, "\u00f7", "\\div", true); +defineSymbol(math, main, bin, "\u00b1", "\\pm", true); +defineSymbol(math, main, bin, "\u00d7", "\\times", true); +defineSymbol(math, main, bin, "\u2229", "\\cap", true); +defineSymbol(math, main, bin, "\u222a", "\\cup", true); +defineSymbol(math, main, bin, "\u2216", "\\setminus", true); +defineSymbol(math, main, bin, "\u2227", "\\land"); +defineSymbol(math, main, bin, "\u2228", "\\lor"); +defineSymbol(math, main, bin, "\u2227", "\\wedge", true); +defineSymbol(math, main, bin, "\u2228", "\\vee", true); +defineSymbol(math, main, textord, "\u221a", "\\surd"); +defineSymbol(math, main, open, "\u27e8", "\\langle", true); +defineSymbol(math, main, open, "\u2223", "\\lvert"); +defineSymbol(math, main, open, "\u2225", "\\lVert"); +defineSymbol(math, main, close, "?", "?"); +defineSymbol(math, main, close, "!", "!"); +defineSymbol(math, main, close, "\u27e9", "\\rangle", true); +defineSymbol(math, main, close, "\u2223", "\\rvert"); +defineSymbol(math, main, close, "\u2225", "\\rVert"); +defineSymbol(math, main, rel, "=", "="); +defineSymbol(math, main, rel, ":", ":"); +defineSymbol(math, main, rel, "\u2248", "\\approx", true); +defineSymbol(math, main, rel, "\u2245", "\\cong", true); +defineSymbol(math, main, rel, "\u2265", "\\ge"); +defineSymbol(math, main, rel, "\u2265", "\\geq", true); +defineSymbol(math, main, rel, "\u2190", "\\gets"); +defineSymbol(math, main, rel, ">", "\\gt", true); +defineSymbol(math, main, rel, "\u2208", "\\in", true); +defineSymbol(math, main, rel, "\ue020", "\\@not"); +defineSymbol(math, main, rel, "\u2282", "\\subset", true); +defineSymbol(math, main, rel, "\u2283", "\\supset", true); +defineSymbol(math, main, rel, "\u2286", "\\subseteq", true); +defineSymbol(math, main, rel, "\u2287", "\\supseteq", true); +defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true); +defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true); +defineSymbol(math, main, rel, "\u22a8", "\\models"); +defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true); +defineSymbol(math, main, rel, "\u2264", "\\le"); +defineSymbol(math, main, rel, "\u2264", "\\leq", true); +defineSymbol(math, main, rel, "<", "\\lt", true); +defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true); +defineSymbol(math, main, rel, "\u2192", "\\to"); +defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true); +defineSymbol(math, ams, rel, "\u2270", "\\nleq", true); +defineSymbol(math, main, spacing, "\u00a0", "\\ "); +defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{% + +defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(text$4, main, spacing, "\u00a0", "\\ "); +defineSymbol(text$4, main, spacing, "\u00a0", " "); +defineSymbol(text$4, main, spacing, "\u00a0", "\\space"); +defineSymbol(text$4, main, spacing, "\u00a0", "\\nobreakspace"); +defineSymbol(math, main, spacing, null, "\\nobreak"); +defineSymbol(math, main, spacing, null, "\\allowbreak"); +defineSymbol(math, main, punct, ",", ","); +defineSymbol(math, main, punct, ";", ";"); +defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true); +defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true); +defineSymbol(math, main, bin, "\u2299", "\\odot", true); +defineSymbol(math, main, bin, "\u2295", "\\oplus", true); +defineSymbol(math, main, bin, "\u2297", "\\otimes", true); +defineSymbol(math, main, textord, "\u2202", "\\partial", true); +defineSymbol(math, main, bin, "\u2298", "\\oslash", true); +defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true); +defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true); +defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup"); +defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown"); +defineSymbol(math, main, bin, "\u2020", "\\dagger"); +defineSymbol(math, main, bin, "\u22c4", "\\diamond"); +defineSymbol(math, main, bin, "\u22c6", "\\star"); +defineSymbol(math, main, bin, "\u25c3", "\\triangleleft"); +defineSymbol(math, main, bin, "\u25b9", "\\triangleright"); +defineSymbol(math, main, open, "{", "\\{"); +defineSymbol(text$4, main, textord, "{", "\\{"); +defineSymbol(text$4, main, textord, "{", "\\textbraceleft"); +defineSymbol(math, main, close, "}", "\\}"); +defineSymbol(text$4, main, textord, "}", "\\}"); +defineSymbol(text$4, main, textord, "}", "\\textbraceright"); +defineSymbol(math, main, open, "{", "\\lbrace"); +defineSymbol(math, main, close, "}", "\\rbrace"); +defineSymbol(math, main, open, "[", "\\lbrack", true); +defineSymbol(text$4, main, textord, "[", "\\lbrack", true); +defineSymbol(math, main, close, "]", "\\rbrack", true); +defineSymbol(text$4, main, textord, "]", "\\rbrack", true); +defineSymbol(math, main, open, "(", "\\lparen", true); +defineSymbol(math, main, close, ")", "\\rparen", true); +defineSymbol(text$4, main, textord, "<", "\\textless", true); // in T1 fontenc + +defineSymbol(text$4, main, textord, ">", "\\textgreater", true); // in T1 fontenc + +defineSymbol(math, main, open, "\u230a", "\\lfloor", true); +defineSymbol(math, main, close, "\u230b", "\\rfloor", true); +defineSymbol(math, main, open, "\u2308", "\\lceil", true); +defineSymbol(math, main, close, "\u2309", "\\rceil", true); +defineSymbol(math, main, textord, "\\", "\\backslash"); +defineSymbol(math, main, textord, "\u2223", "|"); +defineSymbol(math, main, textord, "\u2223", "\\vert"); +defineSymbol(text$4, main, textord, "|", "\\textbar", true); // in T1 fontenc + +defineSymbol(math, main, textord, "\u2225", "\\|"); +defineSymbol(math, main, textord, "\u2225", "\\Vert"); +defineSymbol(text$4, main, textord, "\u2225", "\\textbardbl"); +defineSymbol(text$4, main, textord, "~", "\\textasciitilde"); +defineSymbol(text$4, main, textord, "\\", "\\textbackslash"); +defineSymbol(text$4, main, textord, "^", "\\textasciicircum"); +defineSymbol(math, main, rel, "\u2191", "\\uparrow", true); +defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true); +defineSymbol(math, main, rel, "\u2193", "\\downarrow", true); +defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true); +defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true); +defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true); +defineSymbol(math, main, op, "\u2210", "\\coprod"); +defineSymbol(math, main, op, "\u22c1", "\\bigvee"); +defineSymbol(math, main, op, "\u22c0", "\\bigwedge"); +defineSymbol(math, main, op, "\u2a04", "\\biguplus"); +defineSymbol(math, main, op, "\u22c2", "\\bigcap"); +defineSymbol(math, main, op, "\u22c3", "\\bigcup"); +defineSymbol(math, main, op, "\u222b", "\\int"); +defineSymbol(math, main, op, "\u222b", "\\intop"); +defineSymbol(math, main, op, "\u222c", "\\iint"); +defineSymbol(math, main, op, "\u222d", "\\iiint"); +defineSymbol(math, main, op, "\u220f", "\\prod"); +defineSymbol(math, main, op, "\u2211", "\\sum"); +defineSymbol(math, main, op, "\u2a02", "\\bigotimes"); +defineSymbol(math, main, op, "\u2a01", "\\bigoplus"); +defineSymbol(math, main, op, "\u2a00", "\\bigodot"); +defineSymbol(math, main, op, "\u222e", "\\oint"); +defineSymbol(math, main, op, "\u222f", "\\oiint"); +defineSymbol(math, main, op, "\u2230", "\\oiiint"); +defineSymbol(math, main, op, "\u2a06", "\\bigsqcup"); +defineSymbol(math, main, op, "\u222b", "\\smallint"); +defineSymbol(text$4, main, inner, "\u2026", "\\textellipsis"); +defineSymbol(math, main, inner, "\u2026", "\\mathellipsis"); +defineSymbol(text$4, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u2026", "\\ldots", true); +defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true); +defineSymbol(math, main, inner, "\u22f1", "\\ddots", true); +defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); // \vdots is a macro + +defineSymbol(math, main, accent, "\u02ca", "\\acute"); +defineSymbol(math, main, accent, "\u02cb", "\\grave"); +defineSymbol(math, main, accent, "\u00a8", "\\ddot"); +defineSymbol(math, main, accent, "\u007e", "\\tilde"); +defineSymbol(math, main, accent, "\u02c9", "\\bar"); +defineSymbol(math, main, accent, "\u02d8", "\\breve"); +defineSymbol(math, main, accent, "\u02c7", "\\check"); +defineSymbol(math, main, accent, "\u005e", "\\hat"); +defineSymbol(math, main, accent, "\u20d7", "\\vec"); +defineSymbol(math, main, accent, "\u02d9", "\\dot"); +defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA + +defineSymbol(math, main, mathord, "\ue131", "\\@imath"); +defineSymbol(math, main, mathord, "\ue237", "\\@jmath"); +defineSymbol(math, main, textord, "\u0131", "\u0131"); +defineSymbol(math, main, textord, "\u0237", "\u0237"); +defineSymbol(text$4, main, textord, "\u0131", "\\i", true); +defineSymbol(text$4, main, textord, "\u0237", "\\j", true); +defineSymbol(text$4, main, textord, "\u00df", "\\ss", true); +defineSymbol(text$4, main, textord, "\u00e6", "\\ae", true); +defineSymbol(text$4, main, textord, "\u0153", "\\oe", true); +defineSymbol(text$4, main, textord, "\u00f8", "\\o", true); +defineSymbol(text$4, main, textord, "\u00c6", "\\AE", true); +defineSymbol(text$4, main, textord, "\u0152", "\\OE", true); +defineSymbol(text$4, main, textord, "\u00d8", "\\O", true); +defineSymbol(text$4, main, accent, "\u02ca", "\\'"); // acute + +defineSymbol(text$4, main, accent, "\u02cb", "\\`"); // grave + +defineSymbol(text$4, main, accent, "\u02c6", "\\^"); // circumflex + +defineSymbol(text$4, main, accent, "\u02dc", "\\~"); // tilde + +defineSymbol(text$4, main, accent, "\u02c9", "\\="); // macron + +defineSymbol(text$4, main, accent, "\u02d8", "\\u"); // breve + +defineSymbol(text$4, main, accent, "\u02d9", "\\."); // dot above + +defineSymbol(text$4, main, accent, "\u00b8", "\\c"); // cedilla + +defineSymbol(text$4, main, accent, "\u02da", "\\r"); // ring above + +defineSymbol(text$4, main, accent, "\u02c7", "\\v"); // caron + +defineSymbol(text$4, main, accent, "\u00a8", '\\"'); // diaresis + +defineSymbol(text$4, main, accent, "\u02dd", "\\H"); // double acute + +defineSymbol(text$4, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph +// These ligatures are detected and created in Parser.js's `formLigatures`. + +var ligatures = { + "--": true, + "---": true, + "``": true, + "''": true +}; +defineSymbol(text$4, main, textord, "\u2013", "--", true); +defineSymbol(text$4, main, textord, "\u2013", "\\textendash"); +defineSymbol(text$4, main, textord, "\u2014", "---", true); +defineSymbol(text$4, main, textord, "\u2014", "\\textemdash"); +defineSymbol(text$4, main, textord, "\u2018", "`", true); +defineSymbol(text$4, main, textord, "\u2018", "\\textquoteleft"); +defineSymbol(text$4, main, textord, "\u2019", "'", true); +defineSymbol(text$4, main, textord, "\u2019", "\\textquoteright"); +defineSymbol(text$4, main, textord, "\u201c", "``", true); +defineSymbol(text$4, main, textord, "\u201c", "\\textquotedblleft"); +defineSymbol(text$4, main, textord, "\u201d", "''", true); +defineSymbol(text$4, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package + +defineSymbol(math, main, textord, "\u00b0", "\\degree", true); +defineSymbol(text$4, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package + +defineSymbol(text$4, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math +// mode, but among our fonts, only Main-Regular defines this character "163". + +defineSymbol(math, main, textord, "\u00a3", "\\pounds"); +defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true); +defineSymbol(text$4, main, textord, "\u00a3", "\\pounds"); +defineSymbol(text$4, main, textord, "\u00a3", "\\textsterling", true); +defineSymbol(math, ams, textord, "\u2720", "\\maltese"); +defineSymbol(text$4, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards. +// All of these are textords in math mode + +var mathTextSymbols = "0123456789/@.\""; + +for (var i$2 = 0; i$2 < mathTextSymbols.length; i$2++) { + var ch = mathTextSymbols.charAt(i$2); + defineSymbol(math, main, textord, ch, ch); +} // All of these are textords in text mode + + +var textSymbols = "0123456789!@*()-=+\";:?/.,"; + +for (var _i = 0; _i < textSymbols.length; _i++) { + var _ch = textSymbols.charAt(_i); + + defineSymbol(text$4, main, textord, _ch, _ch); +} // All of these are textords in text mode, and mathords in math mode + + +var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + +for (var _i2 = 0; _i2 < letters.length; _i2++) { + var _ch2 = letters.charAt(_i2); + + defineSymbol(math, main, mathord, _ch2, _ch2); + defineSymbol(text$4, main, textord, _ch2, _ch2); +} // Blackboard bold and script letters in Unicode range + + +defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold + +defineSymbol(text$4, ams, textord, "C", "\u2102"); +defineSymbol(math, ams, textord, "H", "\u210D"); +defineSymbol(text$4, ams, textord, "H", "\u210D"); +defineSymbol(math, ams, textord, "N", "\u2115"); +defineSymbol(text$4, ams, textord, "N", "\u2115"); +defineSymbol(math, ams, textord, "P", "\u2119"); +defineSymbol(text$4, ams, textord, "P", "\u2119"); +defineSymbol(math, ams, textord, "Q", "\u211A"); +defineSymbol(text$4, ams, textord, "Q", "\u211A"); +defineSymbol(math, ams, textord, "R", "\u211D"); +defineSymbol(text$4, ams, textord, "R", "\u211D"); +defineSymbol(math, ams, textord, "Z", "\u2124"); +defineSymbol(text$4, ams, textord, "Z", "\u2124"); +defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant + +defineSymbol(text$4, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters. +// We support some letters in the Unicode range U+1D400 to U+1D7FF, +// Mathematical Alphanumeric Symbols. +// Some editors do not deal well with wide characters. So don't write the +// string into this file. Instead, create the string from the surrogate pair. + +var wideChar = ""; + +for (var _i3 = 0; _i3 < letters.length; _i3++) { + var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair. + // 0xD835 is the high surrogate for all letters in the range we support. + // 0xDC00 is the low surrogate for bold A. + + + wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fractur + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + + if (_i3 < 26) { + // KaTeX fonts have only capital letters for blackboard bold and script. + // See exception for k below. + wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script + + defineSymbol(math, main, mathord, _ch3, wideChar); + defineSymbol(text$4, main, textord, _ch3, wideChar); + } // TODO: Add bold script when it is supported by a KaTeX font. + +} // "k" is the only double struck lower case letter in the KaTeX fonts. + + +wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck + +defineSymbol(math, main, mathord, "k", wideChar); +defineSymbol(text$4, main, textord, "k", wideChar); // Next, some wide character numerals + +for (var _i4 = 0; _i4 < 10; _i4++) { + var _ch4 = _i4.toString(); + + wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$4, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$4, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$4, main, textord, _ch4, wideChar); + wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace + + defineSymbol(math, main, mathord, _ch4, wideChar); + defineSymbol(text$4, main, textord, _ch4, wideChar); +} // We add these Latin-1 letters as symbols for backwards-compatibility, +// but they are not actually in the font, nor are they supported by the +// Unicode accent mechanism, so they fall back to Times font and look ugly. +// TODO(edemaine): Fix this. + + +var extraLatin = "\u00d0\u00de\u00fe"; + +for (var _i5 = 0; _i5 < extraLatin.length; _i5++) { + var _ch5 = extraLatin.charAt(_i5); + + defineSymbol(math, main, mathord, _ch5, _ch5); + defineSymbol(text$4, main, textord, _ch5, _ch5); +} + +/** + * This file provides support for Unicode range U+1D400 to U+1D7FF, + * Mathematical Alphanumeric Symbols. + * + * Function wideCharacterFont takes a wide character as input and returns + * the font information necessary to render it properly. + */ +/** + * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf + * That document sorts characters into groups by font type, say bold or italic. + * + * In the arrays below, each subarray consists three elements: + * * The CSS class of that group when in math mode. + * * The CSS class of that group when in text mode. + * * The font name, so that KaTeX can get font metrics. + */ + +var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright +["mathbf", "textbf", "Main-Bold"], // a-z bold upright +["mathnormal", "textit", "Math-Italic"], // A-Z italic +["mathnormal", "textit", "Math-Italic"], // a-z italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic +["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic +// Map fancy A-Z letters to script, not calligraphic. +// This aligns with unicode-math and math fonts (except Cambria Math). +["mathscr", "textscr", "Script-Regular"], // A-Z script +["", "", ""], // a-z script. No font +["", "", ""], // A-Z bold script. No font +["", "", ""], // a-z bold script. No font +["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur +["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur +["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck +["mathbb", "textbb", "AMS-Regular"], // k double-struck +// Note that we are using a bold font, but font metrics for regular Fraktur. +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur +["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur +["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif +["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif +["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif +["", "", ""], // A-Z bold italic sans. No font +["", "", ""], // a-z bold italic sans. No font +["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace +["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace +]; +var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold +["", "", ""], // 0-9 double-struck. No KaTeX font. +["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif +["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif +["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace +]; +var wideCharacterFont = function wideCharacterFont(wideChar, mode) { + // IE doesn't support codePointAt(). So work with the surrogate pair. + var H = wideChar.charCodeAt(0); // high surrogate + + var L = wideChar.charCodeAt(1); // low surrogate + + var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000; + var j = mode === "math" ? 0 : 1; // column index for CSS class. + + if (0x1D400 <= codePoint && codePoint < 0x1D6A4) { + // wideLatinLetterData contains exactly 26 chars on each row. + // So we can calculate the relevant row. No traverse necessary. + var i = Math.floor((codePoint - 0x1D400) / 26); + return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]]; + } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) { + // Numerals, ten per row. + var _i = Math.floor((codePoint - 0x1D7CE) / 10); + + return [wideNumeralData[_i][2], wideNumeralData[_i][j]]; + } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) { + // dotless i or j + return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]]; + } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) { + // Greek letters. Not supported, yet. + return ["", ""]; + } else { + // We don't support any wide characters outside 1D400–1D7FF. + throw new ParseError("Unsupported character: " + wideChar); + } +}; + +/* eslint no-console:0 */ + +/** + * Looks up the given symbol in fontMetrics, after applying any symbol + * replacements defined in symbol.js + */ +var lookupSymbol = function lookupSymbol(value, // TODO(#963): Use a union type for this. +fontName, mode) { + // Replace the value with its replaced value from symbol.js + if (symbols[mode][value] && symbols[mode][value].replace) { + value = symbols[mode][value].replace; + } + + return { + value: value, + metrics: getCharacterMetrics(value, fontName, mode) + }; +}; +/** + * Makes a symbolNode after translation via the list of symbols in symbols.js. + * Correctly pulls out metrics for the character, and optionally takes a list of + * classes to be attached to the node. + * + * TODO: make argument order closer to makeSpan + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + * TODO(#953): Make `options` mandatory and always pass it in. + */ + + +var makeSymbol = function makeSymbol(value, fontName, mode, options, classes) { + var lookup = lookupSymbol(value, fontName, mode); + var metrics = lookup.metrics; + value = lookup.value; + var symbolNode; + + if (metrics) { + var italic = metrics.italic; + + if (mode === "text" || options && options.font === "mathit") { + italic = 0; + } + + symbolNode = new SymbolNode(value, metrics.height, metrics.depth, italic, metrics.skew, metrics.width, classes); + } else { + // TODO(emily): Figure out a good way to only print this in development + typeof console !== "undefined" && console.warn("No character metrics " + ("for '" + value + "' in style '" + fontName + "' and mode '" + mode + "'")); + symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes); + } + + if (options) { + symbolNode.maxFontSize = options.sizeMultiplier; + + if (options.style.isTight()) { + symbolNode.classes.push("mtight"); + } + + var color = options.getColor(); + + if (color) { + symbolNode.style.color = color; + } + } + + return symbolNode; +}; +/** + * Makes a symbol in Main-Regular or AMS-Regular. + * Used for rel, bin, open, close, inner, and punct. + */ + + +var mathsym = function mathsym(value, mode, options, classes) { + if (classes === void 0) { + classes = []; + } + + // Decide what font to render the symbol in by its entry in the symbols + // table. + // Have a special case for when the value = \ because the \ is used as a + // textord in unsupported command errors but cannot be parsed as a regular + // text ordinal and is therefore not present as a symbol in the symbols + // table for text, as well as a special case for boldsymbol because it + // can be used for bold + and - + if (options.font === "boldsymbol" && lookupSymbol(value, "Main-Bold", mode).metrics) { + return makeSymbol(value, "Main-Bold", mode, options, classes.concat(["mathbf"])); + } else if (value === "\\" || symbols[mode][value].font === "main") { + return makeSymbol(value, "Main-Regular", mode, options, classes); + } else { + return makeSymbol(value, "AMS-Regular", mode, options, classes.concat(["amsrm"])); + } +}; +/** + * Determines which of the two font names (Main-Bold and Math-BoldItalic) and + * corresponding style tags (mathbf or boldsymbol) to use for font "boldsymbol", + * depending on the symbol. Use this function instead of fontMap for font + * "boldsymbol". + */ + + +var boldsymbol = function boldsymbol(value, mode, options, classes, type) { + if (type !== "textord" && lookupSymbol(value, "Math-BoldItalic", mode).metrics) { + return { + fontName: "Math-BoldItalic", + fontClass: "boldsymbol" + }; + } else { + // Some glyphs do not exist in Math-BoldItalic so we need to use + // Main-Bold instead. + return { + fontName: "Main-Bold", + fontClass: "mathbf" + }; + } +}; +/** + * Makes either a mathord or textord in the correct font and color. + */ + + +var makeOrd = function makeOrd(group, options, type) { + var mode = group.mode; + var text = group.text; + var classes = ["mord"]; // Math mode or Old font (i.e. \rm) + + var isFont = mode === "math" || mode === "text" && options.font; + var fontOrFamily = isFont ? options.font : options.fontFamily; + var wideFontName = ""; + var wideFontClass = ""; + + if (text.charCodeAt(0) === 0xD835) { + [wideFontName, wideFontClass] = wideCharacterFont(text, mode); + } + + if (wideFontName.length > 0) { + // surrogate pairs get special treatment + return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass)); + } else if (fontOrFamily) { + var fontName; + var fontClasses; + + if (fontOrFamily === "boldsymbol") { + var fontData = boldsymbol(text, mode, options, classes, type); + fontName = fontData.fontName; + fontClasses = [fontData.fontClass]; + } else if (isFont) { + fontName = fontMap[fontOrFamily].fontName; + fontClasses = [fontOrFamily]; + } else { + fontName = retrieveTextFontName(fontOrFamily, options.fontWeight, options.fontShape); + fontClasses = [fontOrFamily, options.fontWeight, options.fontShape]; + } + + if (lookupSymbol(text, fontName, mode).metrics) { + return makeSymbol(text, fontName, mode, options, classes.concat(fontClasses)); + } else if (ligatures.hasOwnProperty(text) && fontName.slice(0, 10) === "Typewriter") { + // Deconstruct ligatures in monospace fonts (\texttt, \tt). + var parts = []; + + for (var i = 0; i < text.length; i++) { + parts.push(makeSymbol(text[i], fontName, mode, options, classes.concat(fontClasses))); + } + + return makeFragment(parts); + } + } // Makes a symbol in the default font for mathords and textords. + + + if (type === "mathord") { + return makeSymbol(text, "Math-Italic", mode, options, classes.concat(["mathnormal"])); + } else if (type === "textord") { + var font = symbols[mode][text] && symbols[mode][text].font; + + if (font === "ams") { + var _fontName = retrieveTextFontName("amsrm", options.fontWeight, options.fontShape); + + return makeSymbol(text, _fontName, mode, options, classes.concat("amsrm", options.fontWeight, options.fontShape)); + } else if (font === "main" || !font) { + var _fontName2 = retrieveTextFontName("textrm", options.fontWeight, options.fontShape); + + return makeSymbol(text, _fontName2, mode, options, classes.concat(options.fontWeight, options.fontShape)); + } else { + // fonts added by plugins + var _fontName3 = retrieveTextFontName(font, options.fontWeight, options.fontShape); // We add font name as a css class + + + return makeSymbol(text, _fontName3, mode, options, classes.concat(_fontName3, options.fontWeight, options.fontShape)); + } + } else { + throw new Error("unexpected type: " + type + " in makeOrd"); + } +}; +/** + * Returns true if subsequent symbolNodes have the same classes, skew, maxFont, + * and styles. + */ + + +var canCombine = (prev, next) => { + if (createClass(prev.classes) !== createClass(next.classes) || prev.skew !== next.skew || prev.maxFontSize !== next.maxFontSize) { + return false; + } // If prev and next both are just "mbin"s or "mord"s we don't combine them + // so that the proper spacing can be preserved. + + + if (prev.classes.length === 1) { + var cls = prev.classes[0]; + + if (cls === "mbin" || cls === "mord") { + return false; + } + } + + for (var style in prev.style) { + if (prev.style.hasOwnProperty(style) && prev.style[style] !== next.style[style]) { + return false; + } + } + + for (var _style in next.style) { + if (next.style.hasOwnProperty(_style) && prev.style[_style] !== next.style[_style]) { + return false; + } + } + + return true; +}; +/** + * Combine consecutive domTree.symbolNodes into a single symbolNode. + * Note: this function mutates the argument. + */ + + +var tryCombineChars = chars => { + for (var i = 0; i < chars.length - 1; i++) { + var prev = chars[i]; + var next = chars[i + 1]; + + if (prev instanceof SymbolNode && next instanceof SymbolNode && canCombine(prev, next)) { + prev.text += next.text; + prev.height = Math.max(prev.height, next.height); + prev.depth = Math.max(prev.depth, next.depth); // Use the last character's italic correction since we use + // it to add padding to the right of the span created from + // the combined characters. + + prev.italic = next.italic; + chars.splice(i + 1, 1); + i--; + } + } + + return chars; +}; +/** + * Calculate the height, depth, and maxFontSize of an element based on its + * children. + */ + + +var sizeElementFromChildren = function sizeElementFromChildren(elem) { + var height = 0; + var depth = 0; + var maxFontSize = 0; + + for (var i = 0; i < elem.children.length; i++) { + var child = elem.children[i]; + + if (child.height > height) { + height = child.height; + } + + if (child.depth > depth) { + depth = child.depth; + } + + if (child.maxFontSize > maxFontSize) { + maxFontSize = child.maxFontSize; + } + } + + elem.height = height; + elem.depth = depth; + elem.maxFontSize = maxFontSize; +}; +/** + * Makes a span with the given list of classes, list of children, and options. + * + * TODO(#953): Ensure that `options` is always provided (currently some call + * sites don't pass it) and make the type below mandatory. + * TODO: add a separate argument for math class (e.g. `mop`, `mbin`), which + * should if present come first in `classes`. + */ + + +var makeSpan$2 = function makeSpan(classes, children, options, style) { + var span = new Span(classes, children, options, style); + sizeElementFromChildren(span); + return span; +}; // SVG one is simpler -- doesn't require height, depth, max-font setting. +// This is also a separate method for typesafety. + + +var makeSvgSpan = (classes, children, options, style) => new Span(classes, children, options, style); + +var makeLineSpan = function makeLineSpan(className, options, thickness) { + var line = makeSpan$2([className], [], options); + line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + line.style.borderBottomWidth = makeEm(line.height); + line.maxFontSize = 1.0; + return line; +}; +/** + * Makes an anchor with the given href, list of classes, list of children, + * and options. + */ + + +var makeAnchor = function makeAnchor(href, classes, children, options) { + var anchor = new Anchor(href, classes, children, options); + sizeElementFromChildren(anchor); + return anchor; +}; +/** + * Makes a document fragment with the given list of children. + */ + + +var makeFragment = function makeFragment(children) { + var fragment = new DocumentFragment(children); + sizeElementFromChildren(fragment); + return fragment; +}; +/** + * Wraps group in a span if it's a document fragment, allowing to apply classes + * and styles + */ + + +var wrapFragment = function wrapFragment(group, options) { + if (group instanceof DocumentFragment) { + return makeSpan$2([], [group], options); + } + + return group; +}; // These are exact object types to catch typos in the names of the optional fields. + + +// Computes the updated `children` list and the overall depth. +// +// This helper function for makeVList makes it easier to enforce type safety by +// allowing early exits (returns) in the logic. +var getVListChildrenAndDepth = function getVListChildrenAndDepth(params) { + if (params.positionType === "individualShift") { + var oldChildren = params.children; + var children = [oldChildren[0]]; // Add in kerns to the list of params.children to get each element to be + // shifted to the correct specified shift + + var _depth = -oldChildren[0].shift - oldChildren[0].elem.depth; + + var currPos = _depth; + + for (var i = 1; i < oldChildren.length; i++) { + var diff = -oldChildren[i].shift - currPos - oldChildren[i].elem.depth; + var size = diff - (oldChildren[i - 1].elem.height + oldChildren[i - 1].elem.depth); + currPos = currPos + diff; + children.push({ + type: "kern", + size + }); + children.push(oldChildren[i]); + } + + return { + children, + depth: _depth + }; + } + + var depth; + + if (params.positionType === "top") { + // We always start at the bottom, so calculate the bottom by adding up + // all the sizes + var bottom = params.positionData; + + for (var _i = 0; _i < params.children.length; _i++) { + var child = params.children[_i]; + bottom -= child.type === "kern" ? child.size : child.elem.height + child.elem.depth; + } + + depth = bottom; + } else if (params.positionType === "bottom") { + depth = -params.positionData; + } else { + var firstChild = params.children[0]; + + if (firstChild.type !== "elem") { + throw new Error('First child must have type "elem".'); + } + + if (params.positionType === "shift") { + depth = -firstChild.elem.depth - params.positionData; + } else if (params.positionType === "firstBaseline") { + depth = -firstChild.elem.depth; + } else { + throw new Error("Invalid positionType " + params.positionType + "."); + } + } + + return { + children: params.children, + depth + }; +}; +/** + * Makes a vertical list by stacking elements and kerns on top of each other. + * Allows for many different ways of specifying the positioning method. + * + * See VListParam documentation above. + */ + + +var makeVList = function makeVList(params, options) { + var { + children, + depth + } = getVListChildrenAndDepth(params); // Create a strut that is taller than any list item. The strut is added to + // each item, where it will determine the item's baseline. Since it has + // `overflow:hidden`, the strut's top edge will sit on the item's line box's + // top edge and the strut's bottom edge will sit on the item's baseline, + // with no additional line-height spacing. This allows the item baseline to + // be positioned precisely without worrying about font ascent and + // line-height. + + var pstrutSize = 0; + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + + if (child.type === "elem") { + var elem = child.elem; + pstrutSize = Math.max(pstrutSize, elem.maxFontSize, elem.height); + } + } + + pstrutSize += 2; + var pstrut = makeSpan$2(["pstrut"], []); + pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets + + var realChildren = []; + var minPos = depth; + var maxPos = depth; + var currPos = depth; + + for (var _i2 = 0; _i2 < children.length; _i2++) { + var _child = children[_i2]; + + if (_child.type === "kern") { + currPos += _child.size; + } else { + var _elem = _child.elem; + var classes = _child.wrapperClasses || []; + var style = _child.wrapperStyle || {}; + var childWrap = makeSpan$2(classes, [pstrut, _elem], undefined, style); + childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth); + + if (_child.marginLeft) { + childWrap.style.marginLeft = _child.marginLeft; + } + + if (_child.marginRight) { + childWrap.style.marginRight = _child.marginRight; + } + + realChildren.push(childWrap); + currPos += _elem.height + _elem.depth; + } + + minPos = Math.min(minPos, currPos); + maxPos = Math.max(maxPos, currPos); + } // The vlist contents go in a table-cell with `vertical-align:bottom`. + // This cell's bottom edge will determine the containing table's baseline + // without overly expanding the containing line-box. + + + var vlist = makeSpan$2(["vlist"], realChildren); + vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth. + + var rows; + + if (minPos < 0) { + // We will define depth in an empty span with display: table-cell. + // It should render with the height that we define. But Chrome, in + // contenteditable mode only, treats that span as if it contains some + // text content. And that min-height over-rides our desired height. + // So we put another empty span inside the depth strut span. + var emptySpan = makeSpan$2([], []); + var depthStrut = makeSpan$2(["vlist"], [emptySpan]); + depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it + // puts the bottom of the *second* row on the baseline. + + var topStrut = makeSpan$2(["vlist-s"], [new SymbolNode("\u200b")]); + rows = [makeSpan$2(["vlist-r"], [vlist, topStrut]), makeSpan$2(["vlist-r"], [depthStrut])]; + } else { + rows = [makeSpan$2(["vlist-r"], [vlist])]; + } + + var vtable = makeSpan$2(["vlist-t"], rows); + + if (rows.length === 2) { + vtable.classes.push("vlist-t2"); + } + + vtable.height = maxPos; + vtable.depth = -minPos; + return vtable; +}; // Glue is a concept from TeX which is a flexible space between elements in +// either a vertical or horizontal list. In KaTeX, at least for now, it's +// static space between elements in a horizontal layout. + + +var makeGlue = (measurement, options) => { + // Make an empty span for the space + var rule = makeSpan$2(["mspace"], [], options); + var size = calculateSize(measurement, options); + rule.style.marginRight = makeEm(size); + return rule; +}; // Takes font options, and returns the appropriate fontLookup name + + +var retrieveTextFontName = function retrieveTextFontName(fontFamily, fontWeight, fontShape) { + var baseFontName = ""; + + switch (fontFamily) { + case "amsrm": + baseFontName = "AMS"; + break; + + case "textrm": + baseFontName = "Main"; + break; + + case "textsf": + baseFontName = "SansSerif"; + break; + + case "texttt": + baseFontName = "Typewriter"; + break; + + default: + baseFontName = fontFamily; + // use fonts added by a plugin + } + + var fontStylesName; + + if (fontWeight === "textbf" && fontShape === "textit") { + fontStylesName = "BoldItalic"; + } else if (fontWeight === "textbf") { + fontStylesName = "Bold"; + } else if (fontWeight === "textit") { + fontStylesName = "Italic"; + } else { + fontStylesName = "Regular"; + } + + return baseFontName + "-" + fontStylesName; +}; +/** + * Maps TeX font commands to objects containing: + * - variant: string used for "mathvariant" attribute in buildMathML.js + * - fontName: the "style" parameter to fontMetrics.getCharacterMetrics + */ +// A map between tex font commands an MathML mathvariant attribute values + + +var fontMap = { + // styles + "mathbf": { + variant: "bold", + fontName: "Main-Bold" + }, + "mathrm": { + variant: "normal", + fontName: "Main-Regular" + }, + "textit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathit": { + variant: "italic", + fontName: "Main-Italic" + }, + "mathnormal": { + variant: "italic", + fontName: "Math-Italic" + }, + // "boldsymbol" is missing because they require the use of multiple fonts: + // Math-BoldItalic and Main-Bold. This is handled by a special case in + // makeOrd which ends up calling boldsymbol. + // families + "mathbb": { + variant: "double-struck", + fontName: "AMS-Regular" + }, + "mathcal": { + variant: "script", + fontName: "Caligraphic-Regular" + }, + "mathfrak": { + variant: "fraktur", + fontName: "Fraktur-Regular" + }, + "mathscr": { + variant: "script", + fontName: "Script-Regular" + }, + "mathsf": { + variant: "sans-serif", + fontName: "SansSerif-Regular" + }, + "mathtt": { + variant: "monospace", + fontName: "Typewriter-Regular" + } +}; +var svgData = { + // path, width, height + vec: ["vec", 0.471, 0.714], + // values from the font glyph + oiintSize1: ["oiintSize1", 0.957, 0.499], + // oval to overlay the integrand + oiintSize2: ["oiintSize2", 1.472, 0.659], + oiiintSize1: ["oiiintSize1", 1.304, 0.499], + oiiintSize2: ["oiiintSize2", 1.98, 0.659] +}; + +var staticSvg = function staticSvg(value, options) { + // Create a span with inline SVG for the element. + var [pathName, width, height] = svgData[value]; + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + 1000 * height, + "preserveAspectRatio": "xMinYMin" + }); + var span = makeSvgSpan(["overlay"], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return span; +}; + +var buildCommon = { + fontMap, + makeSymbol, + mathsym, + makeSpan: makeSpan$2, + makeSvgSpan, + makeLineSpan, + makeAnchor, + makeFragment, + wrapFragment, + makeVList, + makeOrd, + makeGlue, + staticSvg, + svgData, + tryCombineChars +}; + +/** + * Describes spaces between different classes of atoms. + */ +var thinspace = { + number: 3, + unit: "mu" +}; +var mediumspace = { + number: 4, + unit: "mu" +}; +var thickspace = { + number: 5, + unit: "mu" +}; // Making the type below exact with all optional fields doesn't work due to +// - https://github.com/facebook/flow/issues/4582 +// - https://github.com/facebook/flow/issues/5688 +// However, since *all* fields are optional, $Shape<> works as suggested in 5688 +// above. + +// Spacing relationships for display and text styles +var spacings = { + mord: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + minner: thinspace + }, + mbin: { + mord: mediumspace, + mop: mediumspace, + mopen: mediumspace, + minner: mediumspace + }, + mrel: { + mord: thickspace, + mop: thickspace, + mopen: thickspace, + minner: thickspace + }, + mopen: {}, + mclose: { + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + minner: thinspace + }, + mpunct: { + mord: thinspace, + mop: thinspace, + mrel: thickspace, + mopen: thinspace, + mclose: thinspace, + mpunct: thinspace, + minner: thinspace + }, + minner: { + mord: thinspace, + mop: thinspace, + mbin: mediumspace, + mrel: thickspace, + mopen: thinspace, + mpunct: thinspace, + minner: thinspace + } +}; // Spacing relationships for script and scriptscript styles + +var tightSpacings = { + mord: { + mop: thinspace + }, + mop: { + mord: thinspace, + mop: thinspace + }, + mbin: {}, + mrel: {}, + mopen: {}, + mclose: { + mop: thinspace + }, + mpunct: {}, + minner: { + mop: thinspace + } +}; + +/** Context provided to function handlers for error messages. */ +// Note: reverse the order of the return type union will cause a flow error. +// See https://github.com/facebook/flow/issues/3663. +// More general version of `HtmlBuilder` for nodes (e.g. \sum, accent types) +// whose presence impacts super/subscripting. In this case, ParseNode<"supsub"> +// delegates its HTML building to the HtmlBuilder corresponding to these nodes. + +/** + * Final function spec for use at parse time. + * This is almost identical to `FunctionPropSpec`, except it + * 1. includes the function handler, and + * 2. requires all arguments except argTypes. + * It is generated by `defineFunction()` below. + */ + +/** + * All registered functions. + * `functions.js` just exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary. + */ +var _functions = {}; +/** + * All HTML builders. Should be only used in the `define*` and the `build*ML` + * functions. + */ + +var _htmlGroupBuilders = {}; +/** + * All MathML builders. Should be only used in the `define*` and the `build*ML` + * functions. + */ + +var _mathmlGroupBuilders = {}; +function defineFunction(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of functions + var data = { + type, + numArgs: props.numArgs, + argTypes: props.argTypes, + allowedInArgument: !!props.allowedInArgument, + allowedInText: !!props.allowedInText, + allowedInMath: props.allowedInMath === undefined ? true : props.allowedInMath, + numOptionalArgs: props.numOptionalArgs || 0, + infix: !!props.infix, + primitive: !!props.primitive, + handler: handler + }; + + for (var i = 0; i < names.length; ++i) { + _functions[names[i]] = data; + } + + if (type) { + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } + } +} +/** + * Use this to register only the HTML and MathML builders for a function (e.g. + * if the function's ParseNode is generated in Parser.js rather than via a + * stand-alone handler provided to `defineFunction`). + */ + +function defineFunctionBuilders(_ref2) { + var { + type, + htmlBuilder, + mathmlBuilder + } = _ref2; + defineFunction({ + type, + names: [], + props: { + numArgs: 0 + }, + + handler() { + throw new Error('Should never be called.'); + }, + + htmlBuilder, + mathmlBuilder + }); +} +var normalizeArgument = function normalizeArgument(arg) { + return arg.type === "ordgroup" && arg.body.length === 1 ? arg.body[0] : arg; +}; // Since the corresponding buildHTML/buildMathML function expects a +// list of elements, we normalize for different kinds of arguments + +var ordargument = function ordargument(arg) { + return arg.type === "ordgroup" ? arg.body : [arg]; +}; + +/** + * This file does the main work of building a domTree structure from a parse + * tree. The entry point is the `buildHTML` function, which takes a parse tree. + * Then, the buildExpression, buildGroup, and various groupBuilders functions + * are called, to produce a final HTML tree. + */ +var makeSpan$1 = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`) +// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6, +// and the text before Rule 19. + +var binLeftCanceller = ["leftmost", "mbin", "mopen", "mrel", "mop", "mpunct"]; +var binRightCanceller = ["rightmost", "mrel", "mclose", "mpunct"]; +var styleMap$1 = { + "display": Style$1$1.DISPLAY, + "text": Style$1$1.TEXT, + "script": Style$1$1.SCRIPT, + "scriptscript": Style$1$1.SCRIPTSCRIPT +}; +var DomEnum = { + mord: "mord", + mop: "mop", + mbin: "mbin", + mrel: "mrel", + mopen: "mopen", + mclose: "mclose", + mpunct: "mpunct", + minner: "minner" +}; + +/** + * Take a list of nodes, build them in order, and return a list of the built + * nodes. documentFragments are flattened into their contents, so the + * returned list contains no fragments. `isRealGroup` is true if `expression` + * is a real group (no atoms will be added on either side), as opposed to + * a partial group (e.g. one created by \color). `surrounding` is an array + * consisting type of nodes that will be added to the left and right. + */ +var buildExpression$1 = function buildExpression(expression, options, isRealGroup, surrounding) { + if (surrounding === void 0) { + surrounding = [null, null]; + } + + // Parse expressions into `groups`. + var groups = []; + + for (var i = 0; i < expression.length; i++) { + var output = buildGroup$1(expression[i], options); + + if (output instanceof DocumentFragment) { + var children = output.children; + groups.push(...children); + } else { + groups.push(output); + } + } // Combine consecutive domTree.symbolNodes into a single symbolNode. + + + buildCommon.tryCombineChars(groups); // If `expression` is a partial group, let the parent handle spacings + // to avoid processing groups multiple times. + + if (!isRealGroup) { + return groups; + } + + var glueOptions = options; + + if (expression.length === 1) { + var node = expression[0]; + + if (node.type === "sizing") { + glueOptions = options.havingSize(node.size); + } else if (node.type === "styling") { + glueOptions = options.havingStyle(styleMap$1[node.style]); + } + } // Dummy spans for determining spacings between surrounding atoms. + // If `expression` has no atoms on the left or right, class "leftmost" + // or "rightmost", respectively, is used to indicate it. + + + var dummyPrev = makeSpan$1([surrounding[0] || "leftmost"], [], options); + var dummyNext = makeSpan$1([surrounding[1] || "rightmost"], [], options); // TODO: These code assumes that a node's math class is the first element + // of its `classes` array. A later cleanup should ensure this, for + // instance by changing the signature of `makeSpan`. + // Before determining what spaces to insert, perform bin cancellation. + // Binary operators change to ordinary symbols in some contexts. + + var isRoot = isRealGroup === "root"; + traverseNonSpaceNodes(groups, (node, prev) => { + var prevType = prev.classes[0]; + var type = node.classes[0]; + + if (prevType === "mbin" && utils$1.contains(binRightCanceller, type)) { + prev.classes[0] = "mord"; + } else if (type === "mbin" && utils$1.contains(binLeftCanceller, prevType)) { + node.classes[0] = "mord"; + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + traverseNonSpaceNodes(groups, (node, prev) => { + var prevType = getTypeOfDomTree(prev); + var type = getTypeOfDomTree(node); // 'mtight' indicates that the node is script or scriptscript style. + + var space = prevType && type ? node.hasClass("mtight") ? tightSpacings[prevType][type] : spacings[prevType][type] : null; + + if (space) { + // Insert glue (spacing) after the `prev`. + return buildCommon.makeGlue(space, glueOptions); + } + }, { + node: dummyPrev + }, dummyNext, isRoot); + return groups; +}; // Depth-first traverse non-space `nodes`, calling `callback` with the current and +// previous node as arguments, optionally returning a node to insert after the +// previous node. `prev` is an object with the previous node and `insertAfter` +// function to insert after it. `next` is a node that will be added to the right. +// Used for bin cancellation and inserting spacings. + +var traverseNonSpaceNodes = function traverseNonSpaceNodes(nodes, callback, prev, next, isRoot) { + if (next) { + // temporarily append the right node, if exists + nodes.push(next); + } + + var i = 0; + + for (; i < nodes.length; i++) { + var node = nodes[i]; + var partialGroup = checkPartialGroup(node); + + if (partialGroup) { + // Recursive DFS + // $FlowFixMe: make nodes a $ReadOnlyArray by returning a new array + traverseNonSpaceNodes(partialGroup.children, callback, prev, null, isRoot); + continue; + } // Ignore explicit spaces (e.g., \;, \,) when determining what implicit + // spacing should go between atoms of different classes + + + var nonspace = !node.hasClass("mspace"); + + if (nonspace) { + var result = callback(node, prev.node); + + if (result) { + if (prev.insertAfter) { + prev.insertAfter(result); + } else { + // insert at front + nodes.unshift(result); + i++; + } + } + } + + if (nonspace) { + prev.node = node; + } else if (isRoot && node.hasClass("newline")) { + prev.node = makeSpan$1(["leftmost"]); // treat like beginning of line + } + + prev.insertAfter = (index => n => { + nodes.splice(index + 1, 0, n); + i++; + })(i); + } + + if (next) { + nodes.pop(); + } +}; // Check if given node is a partial group, i.e., does not affect spacing around. + + +var checkPartialGroup = function checkPartialGroup(node) { + if (node instanceof DocumentFragment || node instanceof Anchor || node instanceof Span && node.hasClass("enclosing")) { + return node; + } + + return null; +}; // Return the outermost node of a domTree. + + +var getOutermostNode = function getOutermostNode(node, side) { + var partialGroup = checkPartialGroup(node); + + if (partialGroup) { + var children = partialGroup.children; + + if (children.length) { + if (side === "right") { + return getOutermostNode(children[children.length - 1], "right"); + } else if (side === "left") { + return getOutermostNode(children[0], "left"); + } + } + } + + return node; +}; // Return math atom class (mclass) of a domTree. +// If `side` is given, it will get the type of the outermost node at given side. + + +var getTypeOfDomTree = function getTypeOfDomTree(node, side) { + if (!node) { + return null; + } + + if (side) { + node = getOutermostNode(node, side); + } // This makes a lot of assumptions as to where the type of atom + // appears. We should do a better job of enforcing this. + + + return DomEnum[node.classes[0]] || null; +}; +var makeNullDelimiter = function makeNullDelimiter(options, classes) { + var moreClasses = ["nulldelimiter"].concat(options.baseSizingClasses()); + return makeSpan$1(classes.concat(moreClasses)); +}; +/** + * buildGroup is the function that takes a group and calls the correct groupType + * function for it. It also handles the interaction of size and style changes + * between parents and children. + */ + +var buildGroup$1 = function buildGroup(group, options, baseOptions) { + if (!group) { + return makeSpan$1(); + } + + if (_htmlGroupBuilders[group.type]) { + // Call the groupBuilders function + // $FlowFixMe + var groupNode = _htmlGroupBuilders[group.type](group, options); // If the size changed between the parent and the current group, account + // for that size difference. + + if (baseOptions && options.size !== baseOptions.size) { + groupNode = makeSpan$1(options.sizingClasses(baseOptions), [groupNode], options); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; + groupNode.height *= multiplier; + groupNode.depth *= multiplier; + } + + return groupNode; + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) + * into an unbreakable HTML node of class .base, with proper struts to + * guarantee correct vertical extent. `buildHTML` calls this repeatedly to + * make up the entire expression as a sequence of unbreakable units. + */ + +function buildHTMLUnbreakable(children, options) { + // Compute height and depth of this chunk. + var body = makeSpan$1(["base"], children, options); // Add strut, which ensures that the top of the HTML element falls at + // the height of the expression, and the bottom of the HTML element + // falls at the depth of the expression. + + var strut = makeSpan$1(["strut"]); + strut.style.height = makeEm(body.height + body.depth); + + if (body.depth) { + strut.style.verticalAlign = makeEm(-body.depth); + } + + body.children.unshift(strut); + return body; +} +/** + * Take an entire parse tree, and build it into an appropriate set of HTML + * nodes. + */ + + +function buildHTML(tree, options) { + // Strip off outer tag wrapper for processing below. + var tag = null; + + if (tree.length === 1 && tree[0].type === "tag") { + tag = tree[0].tag; + tree = tree[0].body; + } // Build the expression contained in the tree + + + var expression = buildExpression$1(tree, options, "root"); + var eqnNum; + + if (expression.length === 2 && expression[1].hasClass("tag")) { + // An environment with automatic equation numbers, e.g. {gather}. + eqnNum = expression.pop(); + } + + var children = []; // Create one base node for each chunk between potential line breaks. + // The TeXBook [p.173] says "A formula will be broken only after a + // relation symbol like $=$ or $<$ or $\rightarrow$, or after a binary + // operation symbol like $+$ or $-$ or $\times$, where the relation or + // binary operation is on the ``outer level'' of the formula (i.e., not + // enclosed in {...} and not part of an \over construction)." + + var parts = []; + + for (var i = 0; i < expression.length; i++) { + parts.push(expression[i]); + + if (expression[i].hasClass("mbin") || expression[i].hasClass("mrel") || expression[i].hasClass("allowbreak")) { + // Put any post-operator glue on same line as operator. + // Watch for \nobreak along the way, and stop at \newline. + var nobreak = false; + + while (i < expression.length - 1 && expression[i + 1].hasClass("mspace") && !expression[i + 1].hasClass("newline")) { + i++; + parts.push(expression[i]); + + if (expression[i].hasClass("nobreak")) { + nobreak = true; + } + } // Don't allow break if \nobreak among the post-operator glue. + + + if (!nobreak) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } + } else if (expression[i].hasClass("newline")) { + // Write the line except the newline + parts.pop(); + + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + parts = []; + } // Put the newline at the top level + + + children.push(expression[i]); + } + } + + if (parts.length > 0) { + children.push(buildHTMLUnbreakable(parts, options)); + } // Now, if there was a tag, build it too and append it as a final child. + + + var tagChild; + + if (tag) { + tagChild = buildHTMLUnbreakable(buildExpression$1(tag, options, true)); + tagChild.classes = ["tag"]; + children.push(tagChild); + } else if (eqnNum) { + children.push(eqnNum); + } + + var htmlNode = makeSpan$1(["katex-html"], children); + htmlNode.setAttribute("aria-hidden", "true"); // Adjust the strut of the tag to be the maximum height of all children + // (the height of the enclosing htmlNode) for proper vertical alignment. + + if (tagChild) { + var strut = tagChild.children[0]; + strut.style.height = makeEm(htmlNode.height + htmlNode.depth); + + if (htmlNode.depth) { + strut.style.verticalAlign = makeEm(-htmlNode.depth); + } + } + + return htmlNode; +} + +/** + * These objects store data about MathML nodes. This is the MathML equivalent + * of the types in domTree.js. Since MathML handles its own rendering, and + * since we're mainly using MathML to improve accessibility, we don't manage + * any of the styling state that the plain DOM nodes do. + * + * The `toNode` and `toMarkup` functions work similarly to how they do in + * domTree.js, creating namespaced DOM nodes and HTML text markup respectively. + */ +function newDocumentFragment(children) { + return new DocumentFragment(children); +} +/** + * This node represents a general purpose MathML node of any type. The + * constructor requires the type of node to create (for example, `"mo"` or + * `"mspace"`, corresponding to `` and `` tags). + */ + +class MathNode { + constructor(type, children, classes) { + this.type = void 0; + this.attributes = void 0; + this.children = void 0; + this.classes = void 0; + this.type = type; + this.attributes = {}; + this.children = children || []; + this.classes = classes || []; + } + /** + * Sets an attribute on a MathML node. MathML depends on attributes to convey a + * semantic content, so this is used heavily. + */ + + + setAttribute(name, value) { + this.attributes[name] = value; + } + /** + * Gets an attribute on a MathML node. + */ + + + getAttribute(name) { + return this.attributes[name]; + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + + + toNode() { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", this.type); + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + node.setAttribute(attr, this.attributes[attr]); + } + } + + if (this.classes.length > 0) { + node.className = createClass(this.classes); + } + + for (var i = 0; i < this.children.length; i++) { + node.appendChild(this.children[i].toNode()); + } + + return node; + } + /** + * Converts the math node into an HTML markup string. + */ + + + toMarkup() { + var markup = "<" + this.type; // Add the attributes + + for (var attr in this.attributes) { + if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { + markup += " " + attr + "=\""; + markup += utils$1.escape(this.attributes[attr]); + markup += "\""; + } + } + + if (this.classes.length > 0) { + markup += " class =\"" + utils$1.escape(createClass(this.classes)) + "\""; + } + + markup += ">"; + + for (var i = 0; i < this.children.length; i++) { + markup += this.children[i].toMarkup(); + } + + markup += ""; + return markup; + } + /** + * Converts the math node into a string, similar to innerText, but escaped. + */ + + + toText() { + return this.children.map(child => child.toText()).join(""); + } + +} +/** + * This node represents a piece of text. + */ + +class TextNode { + constructor(text) { + this.text = void 0; + this.text = text; + } + /** + * Converts the text node into a DOM text node. + */ + + + toNode() { + return document.createTextNode(this.text); + } + /** + * Converts the text node into escaped HTML markup + * (representing the text itself). + */ + + + toMarkup() { + return utils$1.escape(this.toText()); + } + /** + * Converts the text node into a string + * (representing the text itself). + */ + + + toText() { + return this.text; + } + +} +/** + * This node represents a space, but may render as or as text, + * depending on the width. + */ + +class SpaceNode { + /** + * Create a Space node with width given in CSS ems. + */ + constructor(width) { + this.width = void 0; + this.character = void 0; + this.width = width; // See https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html + // for a table of space-like characters. We use Unicode + // representations instead of &LongNames; as it's not clear how to + // make the latter via document.createTextNode. + + if (width >= 0.05555 && width <= 0.05556) { + this.character = "\u200a"; //   + } else if (width >= 0.1666 && width <= 0.1667) { + this.character = "\u2009"; //   + } else if (width >= 0.2222 && width <= 0.2223) { + this.character = "\u2005"; //   + } else if (width >= 0.2777 && width <= 0.2778) { + this.character = "\u2005\u200a"; //    + } else if (width >= -0.05556 && width <= -0.05555) { + this.character = "\u200a\u2063"; // ​ + } else if (width >= -0.1667 && width <= -0.1666) { + this.character = "\u2009\u2063"; // ​ + } else if (width >= -0.2223 && width <= -0.2222) { + this.character = "\u205f\u2063"; // ​ + } else if (width >= -0.2778 && width <= -0.2777) { + this.character = "\u2005\u2063"; // ​ + } else { + this.character = null; + } + } + /** + * Converts the math node into a MathML-namespaced DOM element. + */ + + + toNode() { + if (this.character) { + return document.createTextNode(this.character); + } else { + var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace"); + node.setAttribute("width", makeEm(this.width)); + return node; + } + } + /** + * Converts the math node into an HTML markup string. + */ + + + toMarkup() { + if (this.character) { + return "" + this.character + ""; + } else { + return ""; + } + } + /** + * Converts the math node into a string, similar to innerText. + */ + + + toText() { + if (this.character) { + return this.character; + } else { + return " "; + } + } + +} + +var mathMLTree = { + MathNode, + TextNode, + SpaceNode, + newDocumentFragment +}; + +/** + * This file converts a parse tree into a corresponding MathML tree. The main + * entry point is the `buildMathML` function, which takes a parse tree from the + * parser. + */ + +/** + * Takes a symbol and converts it into a MathML text node after performing + * optional replacement from symbols.js. + */ +var makeText = function makeText(text, mode, options) { + if (symbols[mode][text] && symbols[mode][text].replace && text.charCodeAt(0) !== 0xD835 && !(ligatures.hasOwnProperty(text) && options && (options.fontFamily && options.fontFamily.slice(4, 6) === "tt" || options.font && options.font.slice(4, 6) === "tt"))) { + text = symbols[mode][text].replace; + } + + return new mathMLTree.TextNode(text); +}; +/** + * Wrap the given array of nodes in an node if needed, i.e., + * unless the array has length 1. Always returns a single node. + */ + +var makeRow = function makeRow(body) { + if (body.length === 1) { + return body[0]; + } else { + return new mathMLTree.MathNode("mrow", body); + } +}; +/** + * Returns the math variant as a string or null if none is required. + */ + +var getVariant = function getVariant(group, options) { + // Handle \text... font specifiers as best we can. + // MathML has a limited list of allowable mathvariant specifiers; see + // https://www.w3.org/TR/MathML3/chapter3.html#presm.commatt + if (options.fontFamily === "texttt") { + return "monospace"; + } else if (options.fontFamily === "textsf") { + if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "sans-serif-bold-italic"; + } else if (options.fontShape === "textit") { + return "sans-serif-italic"; + } else if (options.fontWeight === "textbf") { + return "bold-sans-serif"; + } else { + return "sans-serif"; + } + } else if (options.fontShape === "textit" && options.fontWeight === "textbf") { + return "bold-italic"; + } else if (options.fontShape === "textit") { + return "italic"; + } else if (options.fontWeight === "textbf") { + return "bold"; + } + + var font = options.font; + + if (!font || font === "mathnormal") { + return null; + } + + var mode = group.mode; + + if (font === "mathit") { + return "italic"; + } else if (font === "boldsymbol") { + return group.type === "textord" ? "bold" : "bold-italic"; + } else if (font === "mathbf") { + return "bold"; + } else if (font === "mathbb") { + return "double-struck"; + } else if (font === "mathfrak") { + return "fraktur"; + } else if (font === "mathscr" || font === "mathcal") { + // MathML makes no distinction between script and calligraphic + return "script"; + } else if (font === "mathsf") { + return "sans-serif"; + } else if (font === "mathtt") { + return "monospace"; + } + + var text = group.text; + + if (utils$1.contains(["\\imath", "\\jmath"], text)) { + return null; + } + + if (symbols[mode][text] && symbols[mode][text].replace) { + text = symbols[mode][text].replace; + } + + var fontName = buildCommon.fontMap[font].fontName; + + if (getCharacterMetrics(text, fontName, mode)) { + return buildCommon.fontMap[font].variant; + } + + return null; +}; +/** + * Takes a list of nodes, builds them, and returns a list of the generated + * MathML nodes. Also combine consecutive outputs into a single + * tag. + */ + +var buildExpression = function buildExpression(expression, options, isOrdgroup) { + if (expression.length === 1) { + var group = buildGroup(expression[0], options); + + if (isOrdgroup && group instanceof MathNode && group.type === "mo") { + // When TeX writers want to suppress spacing on an operator, + // they often put the operator by itself inside braces. + group.setAttribute("lspace", "0em"); + group.setAttribute("rspace", "0em"); + } + + return [group]; + } + + var groups = []; + var lastGroup; + + for (var i = 0; i < expression.length; i++) { + var _group = buildGroup(expression[i], options); + + if (_group instanceof MathNode && lastGroup instanceof MathNode) { + // Concatenate adjacent s + if (_group.type === 'mtext' && lastGroup.type === 'mtext' && _group.getAttribute('mathvariant') === lastGroup.getAttribute('mathvariant')) { + lastGroup.children.push(..._group.children); + continue; // Concatenate adjacent s + } else if (_group.type === 'mn' && lastGroup.type === 'mn') { + lastGroup.children.push(..._group.children); + continue; // Concatenate ... followed by . + } else if (_group.type === 'mi' && _group.children.length === 1 && lastGroup.type === 'mn') { + var child = _group.children[0]; + + if (child instanceof TextNode && child.text === '.') { + lastGroup.children.push(..._group.children); + continue; + } + } else if (lastGroup.type === 'mi' && lastGroup.children.length === 1) { + var lastChild = lastGroup.children[0]; + + if (lastChild instanceof TextNode && lastChild.text === '\u0338' && (_group.type === 'mo' || _group.type === 'mi' || _group.type === 'mn')) { + var _child = _group.children[0]; + + if (_child instanceof TextNode && _child.text.length > 0) { + // Overlay with combining character long solidus + _child.text = _child.text.slice(0, 1) + "\u0338" + _child.text.slice(1); + groups.pop(); + } + } + } + } + + groups.push(_group); + lastGroup = _group; + } + + return groups; +}; +/** + * Equivalent to buildExpression, but wraps the elements in an + * if there's more than one. Returns a single node instead of an array. + */ + +var buildExpressionRow = function buildExpressionRow(expression, options, isOrdgroup) { + return makeRow(buildExpression(expression, options, isOrdgroup)); +}; +/** + * Takes a group from the parser and calls the appropriate groupBuilders function + * on it to produce a MathML node. + */ + +var buildGroup = function buildGroup(group, options) { + if (!group) { + return new mathMLTree.MathNode("mrow"); + } + + if (_mathmlGroupBuilders[group.type]) { + // Call the groupBuilders function + // $FlowFixMe + var result = _mathmlGroupBuilders[group.type](group, options); // $FlowFixMe + + return result; + } else { + throw new ParseError("Got group of unknown type: '" + group.type + "'"); + } +}; +/** + * Takes a full parse tree and settings and builds a MathML representation of + * it. In particular, we put the elements from building the parse tree into a + * tag so we can also include that TeX source as an annotation. + * + * Note that we actually return a domTree element with a `` inside it so + * we can do appropriate styling. + */ + +function buildMathML(tree, texExpression, options, isDisplayMode, forMathmlOnly) { + var expression = buildExpression(tree, options); // TODO: Make a pass thru the MathML similar to buildHTML.traverseNonSpaceNodes + // and add spacing nodes. This is necessary only adjacent to math operators + // like \sin or \lim or to subsup elements that contain math operators. + // MathML takes care of the other spacing issues. + // Wrap up the expression in an mrow so it is presented in the semantics + // tag correctly, unless it's a single or . + + var wrapper; + + if (expression.length === 1 && expression[0] instanceof MathNode && utils$1.contains(["mrow", "mtable"], expression[0].type)) { + wrapper = expression[0]; + } else { + wrapper = new mathMLTree.MathNode("mrow", expression); + } // Build a TeX annotation of the source + + + var annotation = new mathMLTree.MathNode("annotation", [new mathMLTree.TextNode(texExpression)]); + annotation.setAttribute("encoding", "application/x-tex"); + var semantics = new mathMLTree.MathNode("semantics", [wrapper, annotation]); + var math = new mathMLTree.MathNode("math", [semantics]); + math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML"); + + if (isDisplayMode) { + math.setAttribute("display", "block"); + } // You can't style nodes, so we wrap the node in a span. + // NOTE: The span class is not typed to have nodes as children, and + // we don't want to make the children type more generic since the children + // of span are expected to have more fields in `buildHtml` contexts. + + + var wrapperClass = forMathmlOnly ? "katex" : "katex-mathml"; // $FlowFixMe + + return buildCommon.makeSpan([wrapperClass], [math]); +} + +var optionsFromSettings = function optionsFromSettings(settings) { + return new Options({ + style: settings.displayMode ? Style$1$1.DISPLAY : Style$1$1.TEXT, + maxSize: settings.maxSize, + minRuleThickness: settings.minRuleThickness + }); +}; + +var displayWrap = function displayWrap(node, settings) { + if (settings.displayMode) { + var classes = ["katex-display"]; + + if (settings.leqno) { + classes.push("leqno"); + } + + if (settings.fleqn) { + classes.push("fleqn"); + } + + node = buildCommon.makeSpan(classes, [node]); + } + + return node; +}; + +var buildTree = function buildTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var katexNode; + + if (settings.output === "mathml") { + return buildMathML(tree, expression, options, settings.displayMode, true); + } else if (settings.output === "html") { + var htmlNode = buildHTML(tree, options); + katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); + } else { + var mathMLNode = buildMathML(tree, expression, options, settings.displayMode, false); + + var _htmlNode = buildHTML(tree, options); + + katexNode = buildCommon.makeSpan(["katex"], [mathMLNode, _htmlNode]); + } + + return displayWrap(katexNode, settings); +}; +var buildHTMLTree = function buildHTMLTree(tree, expression, settings) { + var options = optionsFromSettings(settings); + var htmlNode = buildHTML(tree, options); + var katexNode = buildCommon.makeSpan(["katex"], [htmlNode]); + return displayWrap(katexNode, settings); +}; + +/** + * This file provides support to buildMathML.js and buildHTML.js + * for stretchy wide elements rendered from SVG files + * and other CSS trickery. + */ +var stretchyCodePoint = { + widehat: "^", + widecheck: "ˇ", + widetilde: "~", + utilde: "~", + overleftarrow: "\u2190", + underleftarrow: "\u2190", + xleftarrow: "\u2190", + overrightarrow: "\u2192", + underrightarrow: "\u2192", + xrightarrow: "\u2192", + underbrace: "\u23df", + overbrace: "\u23de", + overgroup: "\u23e0", + undergroup: "\u23e1", + overleftrightarrow: "\u2194", + underleftrightarrow: "\u2194", + xleftrightarrow: "\u2194", + Overrightarrow: "\u21d2", + xRightarrow: "\u21d2", + overleftharpoon: "\u21bc", + xleftharpoonup: "\u21bc", + overrightharpoon: "\u21c0", + xrightharpoonup: "\u21c0", + xLeftarrow: "\u21d0", + xLeftrightarrow: "\u21d4", + xhookleftarrow: "\u21a9", + xhookrightarrow: "\u21aa", + xmapsto: "\u21a6", + xrightharpoondown: "\u21c1", + xleftharpoondown: "\u21bd", + xrightleftharpoons: "\u21cc", + xleftrightharpoons: "\u21cb", + xtwoheadleftarrow: "\u219e", + xtwoheadrightarrow: "\u21a0", + xlongequal: "=", + xtofrom: "\u21c4", + xrightleftarrows: "\u21c4", + xrightequilibrium: "\u21cc", + // Not a perfect match. + xleftequilibrium: "\u21cb", + // None better available. + "\\cdrightarrow": "\u2192", + "\\cdleftarrow": "\u2190", + "\\cdlongequal": "=" +}; + +var mathMLnode = function mathMLnode(label) { + var node = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(stretchyCodePoint[label.replace(/^\\/, '')])]); + node.setAttribute("stretchy", "true"); + return node; +}; // Many of the KaTeX SVG images have been adapted from glyphs in KaTeX fonts. +// Copyright (c) 2009-2010, Design Science, Inc. () +// Copyright (c) 2014-2017 Khan Academy () +// Licensed under the SIL Open Font License, Version 1.1. +// See \nhttp://scripts.sil.org/OFL +// Very Long SVGs +// Many of the KaTeX stretchy wide elements use a long SVG image and an +// overflow: hidden tactic to achieve a stretchy image while avoiding +// distortion of arrowheads or brace corners. +// The SVG typically contains a very long (400 em) arrow. +// The SVG is in a container span that has overflow: hidden, so the span +// acts like a window that exposes only part of the SVG. +// The SVG always has a longer, thinner aspect ratio than the container span. +// After the SVG fills 100% of the height of the container span, +// there is a long arrow shaft left over. That left-over shaft is not shown. +// Instead, it is sliced off because the span's CSS has overflow: hidden. +// Thus, the reader sees an arrow that matches the subject matter width +// without distortion. +// Some functions, such as \cancel, need to vary their aspect ratio. These +// functions do not get the overflow SVG treatment. +// Second Brush Stroke +// Low resolution monitors struggle to display images in fine detail. +// So browsers apply anti-aliasing. A long straight arrow shaft therefore +// will sometimes appear as if it has a blurred edge. +// To mitigate this, these SVG files contain a second "brush-stroke" on the +// arrow shafts. That is, a second long thin rectangular SVG path has been +// written directly on top of each arrow shaft. This reinforcement causes +// some of the screen pixels to display as black instead of the anti-aliased +// gray pixel that a single path would generate. So we get arrow shafts +// whose edges appear to be sharper. +// In the katexImagesData object just below, the dimensions all +// correspond to path geometry inside the relevant SVG. +// For example, \overrightarrow uses the same arrowhead as glyph U+2192 +// from the KaTeX Main font. The scaling factor is 1000. +// That is, inside the font, that arrowhead is 522 units tall, which +// corresponds to 0.522 em inside the document. + + +var katexImagesData = { + // path(s), minWidth, height, align + overrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + overleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + underrightarrow: [["rightarrow"], 0.888, 522, "xMaxYMin"], + underleftarrow: [["leftarrow"], 0.888, 522, "xMinYMin"], + xrightarrow: [["rightarrow"], 1.469, 522, "xMaxYMin"], + "\\cdrightarrow": [["rightarrow"], 3.0, 522, "xMaxYMin"], + // CD minwwidth2.5pc + xleftarrow: [["leftarrow"], 1.469, 522, "xMinYMin"], + "\\cdleftarrow": [["leftarrow"], 3.0, 522, "xMinYMin"], + Overrightarrow: [["doublerightarrow"], 0.888, 560, "xMaxYMin"], + xRightarrow: [["doublerightarrow"], 1.526, 560, "xMaxYMin"], + xLeftarrow: [["doubleleftarrow"], 1.526, 560, "xMinYMin"], + overleftharpoon: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoonup: [["leftharpoon"], 0.888, 522, "xMinYMin"], + xleftharpoondown: [["leftharpoondown"], 0.888, 522, "xMinYMin"], + overrightharpoon: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoonup: [["rightharpoon"], 0.888, 522, "xMaxYMin"], + xrightharpoondown: [["rightharpoondown"], 0.888, 522, "xMaxYMin"], + xlongequal: [["longequal"], 0.888, 334, "xMinYMin"], + "\\cdlongequal": [["longequal"], 3.0, 334, "xMinYMin"], + xtwoheadleftarrow: [["twoheadleftarrow"], 0.888, 334, "xMinYMin"], + xtwoheadrightarrow: [["twoheadrightarrow"], 0.888, 334, "xMaxYMin"], + overleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + overbrace: [["leftbrace", "midbrace", "rightbrace"], 1.6, 548], + underbrace: [["leftbraceunder", "midbraceunder", "rightbraceunder"], 1.6, 548], + underleftrightarrow: [["leftarrow", "rightarrow"], 0.888, 522], + xleftrightarrow: [["leftarrow", "rightarrow"], 1.75, 522], + xLeftrightarrow: [["doubleleftarrow", "doublerightarrow"], 1.75, 560], + xrightleftharpoons: [["leftharpoondownplus", "rightharpoonplus"], 1.75, 716], + xleftrightharpoons: [["leftharpoonplus", "rightharpoondownplus"], 1.75, 716], + xhookleftarrow: [["leftarrow", "righthook"], 1.08, 522], + xhookrightarrow: [["lefthook", "rightarrow"], 1.08, 522], + overlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + underlinesegment: [["leftlinesegment", "rightlinesegment"], 0.888, 522], + overgroup: [["leftgroup", "rightgroup"], 0.888, 342], + undergroup: [["leftgroupunder", "rightgroupunder"], 0.888, 342], + xmapsto: [["leftmapsto", "rightarrow"], 1.5, 522], + xtofrom: [["leftToFrom", "rightToFrom"], 1.75, 528], + // The next three arrows are from the mhchem package. + // In mhchem.sty, min-length is 2.0em. But these arrows might appear in the + // document as \xrightarrow or \xrightleftharpoons. Those have + // min-length = 1.75em, so we set min-length on these next three to match. + xrightleftarrows: [["baraboveleftarrow", "rightarrowabovebar"], 1.75, 901], + xrightequilibrium: [["baraboveshortleftharpoon", "rightharpoonaboveshortbar"], 1.75, 716], + xleftequilibrium: [["shortbaraboveleftharpoon", "shortrightharpoonabovebar"], 1.75, 716] +}; + +var groupLength = function groupLength(arg) { + if (arg.type === "ordgroup") { + return arg.body.length; + } else { + return 1; + } +}; + +var svgSpan = function svgSpan(group, options) { + // Create a span with inline SVG for the element. + function buildSvgSpan_() { + var viewBoxWidth = 400000; // default + + var label = group.label.slice(1); + + if (utils$1.contains(["widehat", "widecheck", "widetilde", "utilde"], label)) { + // Each type in the `if` statement corresponds to one of the ParseNode + // types below. This narrowing is required to access `grp.base`. + // $FlowFixMe + var grp = group; // There are four SVG images available for each function. + // Choose a taller image when there are more characters. + + var numChars = groupLength(grp.base); + var viewBoxHeight; + var pathName; + + var _height; + + if (numChars > 5) { + if (label === "widehat" || label === "widecheck") { + viewBoxHeight = 420; + viewBoxWidth = 2364; + _height = 0.42; + pathName = label + "4"; + } else { + viewBoxHeight = 312; + viewBoxWidth = 2340; + _height = 0.34; + pathName = "tilde4"; + } + } else { + var imgIndex = [1, 1, 2, 2, 3, 3][numChars]; + + if (label === "widehat" || label === "widecheck") { + viewBoxWidth = [0, 1062, 2364, 2364, 2364][imgIndex]; + viewBoxHeight = [0, 239, 300, 360, 420][imgIndex]; + _height = [0, 0.24, 0.3, 0.3, 0.36, 0.42][imgIndex]; + pathName = label + imgIndex; + } else { + viewBoxWidth = [0, 600, 1033, 2339, 2340][imgIndex]; + viewBoxHeight = [0, 260, 286, 306, 312][imgIndex]; + _height = [0, 0.26, 0.286, 0.3, 0.306, 0.34][imgIndex]; + pathName = "tilde" + imgIndex; + } + } + + var path = new PathNode(pathName); + var svgNode = new SvgNode([path], { + "width": "100%", + "height": makeEm(_height), + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight, + "preserveAspectRatio": "none" + }); + return { + span: buildCommon.makeSvgSpan([], [svgNode], options), + minWidth: 0, + height: _height + }; + } else { + var spans = []; + var data = katexImagesData[label]; + var [paths, _minWidth, _viewBoxHeight] = data; + + var _height2 = _viewBoxHeight / 1000; + + var numSvgChildren = paths.length; + var widthClasses; + var aligns; + + if (numSvgChildren === 1) { + // $FlowFixMe: All these cases must be of the 4-tuple type. + var align1 = data[3]; + widthClasses = ["hide-tail"]; + aligns = [align1]; + } else if (numSvgChildren === 2) { + widthClasses = ["halfarrow-left", "halfarrow-right"]; + aligns = ["xMinYMin", "xMaxYMin"]; + } else if (numSvgChildren === 3) { + widthClasses = ["brace-left", "brace-center", "brace-right"]; + aligns = ["xMinYMin", "xMidYMin", "xMaxYMin"]; + } else { + throw new Error("Correct katexImagesData or update code here to support\n " + numSvgChildren + " children."); + } + + for (var i = 0; i < numSvgChildren; i++) { + var _path = new PathNode(paths[i]); + + var _svgNode = new SvgNode([_path], { + "width": "400em", + "height": makeEm(_height2), + "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight, + "preserveAspectRatio": aligns[i] + " slice" + }); + + var _span = buildCommon.makeSvgSpan([widthClasses[i]], [_svgNode], options); + + if (numSvgChildren === 1) { + return { + span: _span, + minWidth: _minWidth, + height: _height2 + }; + } else { + _span.style.height = makeEm(_height2); + spans.push(_span); + } + } + + return { + span: buildCommon.makeSpan(["stretchy"], spans, options), + minWidth: _minWidth, + height: _height2 + }; + } + } // buildSvgSpan_() + + + var { + span, + minWidth, + height + } = buildSvgSpan_(); // Note that we are returning span.depth = 0. + // Any adjustments relative to the baseline must be done in buildHTML. + + span.height = height; + span.style.height = makeEm(height); + + if (minWidth > 0) { + span.style.minWidth = makeEm(minWidth); + } + + return span; +}; + +var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options) { + // Return an image span for \cancel, \bcancel, \xcancel, \fbox, or \angl + var img; + var totalHeight = inner.height + inner.depth + topPad + bottomPad; + + if (/fbox|color|angl/.test(label)) { + img = buildCommon.makeSpan(["stretchy", label], [], options); + + if (label === "fbox") { + var color = options.color && options.getColor(); + + if (color) { + img.style.borderColor = color; + } + } + } else { + // \cancel, \bcancel, or \xcancel + // Since \cancel's SVG is inline and it omits the viewBox attribute, + // its stroke-width will not vary with span area. + var lines = []; + + if (/^[bx]cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "0", + "x2": "100%", + "y2": "100%", + "stroke-width": "0.046em" + })); + } + + if (/^x?cancel$/.test(label)) { + lines.push(new LineNode({ + "x1": "0", + "y1": "100%", + "x2": "100%", + "y2": "0", + "stroke-width": "0.046em" + })); + } + + var svgNode = new SvgNode(lines, { + "width": "100%", + "height": makeEm(totalHeight) + }); + img = buildCommon.makeSvgSpan([], [svgNode], options); + } + + img.height = totalHeight; + img.style.height = makeEm(totalHeight); + return img; +}; + +var stretchy = { + encloseSpan, + mathMLnode, + svgSpan +}; + +/** + * Asserts that the node is of the given type and returns it with stricter + * typing. Throws if the node's type does not match. + */ +function assertNodeType(node, type) { + if (!node || node.type !== type) { + throw new Error("Expected node of type " + type + ", but got " + (node ? "node of type " + node.type : String(node))); + } // $FlowFixMe, >=0.125 + + + return node; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function assertSymbolNodeType(node) { + var typedNode = checkSymbolNodeType(node); + + if (!typedNode) { + throw new Error("Expected node of symbol group type, but got " + (node ? "node of type " + node.type : String(node))); + } + + return typedNode; +} +/** + * Returns the node more strictly typed iff it is of the given type. Otherwise, + * returns null. + */ + +function checkSymbolNodeType(node) { + if (node && (node.type === "atom" || NON_ATOMS.hasOwnProperty(node.type))) { + // $FlowFixMe + return node; + } + + return null; +} + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but +// also "supsub" since an accent can affect super/subscripting. +var htmlBuilder$a = (grp, options) => { + // Accents are handled in the TeXbook pg. 443, rule 12. + var base; + var group; + var supSubGroup; + + if (grp && grp.type === "supsub") { + // If our base is a character box, and we have superscripts and + // subscripts, the supsub will defer to us. In particular, we want + // to attach the superscripts and subscripts to the inner body (so + // that the position of the superscripts and subscripts won't be + // affected by the height of the accent). We accomplish this by + // sticking the base of the accent into the base of the supsub, and + // rendering that, while keeping track of where the accent is. + // The real accent group is the base of the supsub group + group = assertNodeType(grp.base, "accent"); // The character box is the base of the accent group + + base = group.base; // Stick the character box into the base of the supsub group + + grp.base = base; // Rerender the supsub group with its new base, and store that + // result. + + supSubGroup = assertSpan(buildGroup$1(grp, options)); // reset original base + + grp.base = group; + } else { + group = assertNodeType(grp, "accent"); + base = group.base; + } // Build the base group + + + var body = buildGroup$1(base, options.havingCrampedStyle()); // Does the accent need to shift for the skew of a character? + + var mustShift = group.isShifty && utils$1.isCharacterBox(base); // Calculate the skew of the accent. This is based on the line "If the + // nucleus is not a single character, let s = 0; otherwise set s to the + // kern amount for the nucleus followed by the \skewchar of its font." + // Note that our skew metrics are just the kern between each character + // and the skewchar. + + var skew = 0; + + if (mustShift) { + // If the base is a character box, then we want the skew of the + // innermost character. To do that, we find the innermost character: + var baseChar = utils$1.getBaseElem(base); // Then, we render its group to get the symbol inside it + + var baseGroup = buildGroup$1(baseChar, options.havingCrampedStyle()); // Finally, we pull the skew off of the symbol. + + skew = assertSymbolDomNode(baseGroup).skew; // Note that we now throw away baseGroup, because the layers we + // removed with getBaseElem might contain things like \color which + // we can't get rid of. + // TODO(emily): Find a better way to get the skew + } + + var accentBelow = group.label === "\\c"; // calculate the amount of space between the body and the accent + + var clearance = accentBelow ? body.height + body.depth : Math.min(body.height, options.fontMetrics().xHeight); // Build the accent + + var accentBody; + + if (!group.isStretchy) { + var accent; + var width; + + if (group.label === "\\vec") { + // Before version 0.9, \vec used the combining font glyph U+20D7. + // But browsers, especially Safari, are not consistent in how they + // render combining characters when not preceded by a character. + // So now we use an SVG. + // If Safari reforms, we should consider reverting to the glyph. + accent = buildCommon.staticSvg("vec", options); + width = buildCommon.svgData.vec[1]; + } else { + accent = buildCommon.makeOrd({ + mode: group.mode, + text: group.label + }, options, "textord"); + accent = assertSymbolDomNode(accent); // Remove the italic correction of the accent, because it only serves to + // shift the accent over to a place we don't want. + + accent.italic = 0; + width = accent.width; + + if (accentBelow) { + clearance += accent.depth; + } + } + + accentBody = buildCommon.makeSpan(["accent-body"], [accent]); // "Full" accents expand the width of the resulting symbol to be + // at least the width of the accent, and overlap directly onto the + // character without any vertical offset. + + var accentFull = group.label === "\\textcircled"; + + if (accentFull) { + accentBody.classes.push('accent-full'); + clearance = body.height; + } // Shift the accent over by the skew. + + + var left = skew; // CSS defines `.katex .accent .accent-body:not(.accent-full) { width: 0 }` + // so that the accent doesn't contribute to the bounding box. + // We need to shift the character by its width (effectively half + // its width) to compensate. + + if (!accentFull) { + left -= width / 2; + } + + accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some + // vertical adjustment to match LaTeX. + + if (group.label === "\\textcircled") { + accentBody.style.top = ".2em"; + } + + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: -clearance + }, { + type: "elem", + elem: accentBody + }] + }, options); + } else { + accentBody = stretchy.svgSpan(group, options); + accentBody = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"], + wrapperStyle: skew > 0 ? { + width: "calc(100% - " + makeEm(2 * skew) + ")", + marginLeft: makeEm(2 * skew) + } : undefined + }] + }, options); + } + + var accentWrap = buildCommon.makeSpan(["mord", "accent"], [accentBody], options); + + if (supSubGroup) { + // Here, we replace the "base" child of the supsub with our newly + // generated accent. + supSubGroup.children[0] = accentWrap; // Since we don't rerun the height calculation after replacing the + // accent, we manually recalculate height. + + supSubGroup.height = Math.max(accentWrap.height, supSubGroup.height); // Accents should always be ords, even when their innards are not. + + supSubGroup.classes[0] = "mord"; + return supSubGroup; + } else { + return accentWrap; + } +}; + +var mathmlBuilder$9 = (group, options) => { + var accentNode = group.isStretchy ? stretchy.mathMLnode(group.label) : new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]); + var node = new mathMLTree.MathNode("mover", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accent", "true"); + return node; +}; + +var NON_STRETCHY_ACCENT_REGEX = new RegExp(["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring"].map(accent => "\\" + accent).join("|")); // Accents + +defineFunction({ + type: "accent", + names: ["\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve", "\\check", "\\hat", "\\vec", "\\dot", "\\mathring", "\\widecheck", "\\widehat", "\\widetilde", "\\overrightarrow", "\\overleftarrow", "\\Overrightarrow", "\\overleftrightarrow", "\\overgroup", "\\overlinesegment", "\\overleftharpoon", "\\overrightharpoon"], + props: { + numArgs: 1 + }, + handler: (context, args) => { + var base = normalizeArgument(args[0]); + var isStretchy = !NON_STRETCHY_ACCENT_REGEX.test(context.funcName); + var isShifty = !isStretchy || context.funcName === "\\widehat" || context.funcName === "\\widetilde" || context.funcName === "\\widecheck"; + return { + type: "accent", + mode: context.parser.mode, + label: context.funcName, + isStretchy: isStretchy, + isShifty: isShifty, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); // Text-mode accents + +defineFunction({ + type: "accent", + names: ["\\'", "\\`", "\\^", "\\~", "\\=", "\\u", "\\.", '\\"', "\\c", "\\r", "\\H", "\\v", "\\textcircled"], + props: { + numArgs: 1, + allowedInText: true, + allowedInMath: true, + // unless in strict mode + argTypes: ["primitive"] + }, + handler: (context, args) => { + var base = args[0]; + var mode = context.parser.mode; + + if (mode === "math") { + context.parser.settings.reportNonstrict("mathVsTextAccents", "LaTeX's accent " + context.funcName + " works only in text mode"); + mode = "text"; + } + + return { + type: "accent", + mode: mode, + label: context.funcName, + isStretchy: false, + isShifty: true, + base: base + }; + }, + htmlBuilder: htmlBuilder$a, + mathmlBuilder: mathmlBuilder$9 +}); + +// Horizontal overlap functions +defineFunction({ + type: "accentUnder", + names: ["\\underleftarrow", "\\underrightarrow", "\\underleftrightarrow", "\\undergroup", "\\underlinesegment", "\\utilde"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var base = args[0]; + return { + type: "accentUnder", + mode: parser.mode, + label: funcName, + base: base + }; + }, + htmlBuilder: (group, options) => { + // Treat under accents much like underlines. + var innerGroup = buildGroup$1(group.base, options); + var accentBody = stretchy.svgSpan(group, options); + var kern = group.label === "\\utilde" ? 0.12 : 0; // Generate the vlist, with the appropriate kerns + + var vlist = buildCommon.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "elem", + elem: accentBody, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: kern + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return buildCommon.makeSpan(["mord", "accentunder"], [vlist], options); + }, + mathmlBuilder: (group, options) => { + var accentNode = stretchy.mathMLnode(group.label); + var node = new mathMLTree.MathNode("munder", [buildGroup(group.base, options), accentNode]); + node.setAttribute("accentunder", "true"); + return node; + } +}); + +// Helper function +var paddedNode = group => { + var node = new mathMLTree.MathNode("mpadded", group ? [group] : []); + node.setAttribute("width", "+0.6em"); + node.setAttribute("lspace", "0.3em"); + return node; +}; // Stretchy arrows with an optional argument + + +defineFunction({ + type: "xArrow", + names: ["\\xleftarrow", "\\xrightarrow", "\\xLeftarrow", "\\xRightarrow", "\\xleftrightarrow", "\\xLeftrightarrow", "\\xhookleftarrow", "\\xhookrightarrow", "\\xmapsto", "\\xrightharpoondown", "\\xrightharpoonup", "\\xleftharpoondown", "\\xleftharpoonup", "\\xrightleftharpoons", "\\xleftrightharpoons", "\\xlongequal", "\\xtwoheadrightarrow", "\\xtwoheadleftarrow", "\\xtofrom", // The next 3 functions are here to support the mhchem extension. + // Direct use of these functions is discouraged and may break someday. + "\\xrightleftarrows", "\\xrightequilibrium", "\\xleftequilibrium", // The next 3 functions are here only to support the {CD} environment. + "\\\\cdrightarrow", "\\\\cdleftarrow", "\\\\cdlongequal"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + return { + type: "xArrow", + mode: parser.mode, + label: funcName, + body: args[0], + below: optArgs[0] + }; + }, + + // Flow is unable to correctly infer the type of `group`, even though it's + // unambiguously determined from the passed-in `type` above. + htmlBuilder(group, options) { + var style = options.style; // Build the argument groups in the appropriate style. + // Ref: amsmath.dtx: \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}% + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + + var newOptions = options.havingStyle(style.sup()); + var upperGroup = buildCommon.wrapFragment(buildGroup$1(group.body, newOptions, options), options); + var arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd"; + upperGroup.classes.push(arrowPrefix + "-arrow-pad"); + var lowerGroup; + + if (group.below) { + // Build the lower group + newOptions = options.havingStyle(style.sub()); + lowerGroup = buildCommon.wrapFragment(buildGroup$1(group.below, newOptions, options), options); + lowerGroup.classes.push(arrowPrefix + "-arrow-pad"); + } + + var arrowBody = stretchy.svgSpan(group, options); // Re shift: Note that stretchy.svgSpan returned arrowBody.depth = 0. + // The point we want on the math axis is at 0.5 * arrowBody.height. + + var arrowShift = -options.fontMetrics().axisHeight + 0.5 * arrowBody.height; // 2 mu kern. Ref: amsmath.dtx: #7\if0#2\else\mkern#2mu\fi + + var upperShift = -options.fontMetrics().axisHeight - 0.5 * arrowBody.height - 0.111; // 0.111 em = 2 mu + + if (upperGroup.depth > 0.25 || group.label === "\\xleftequilibrium") { + upperShift -= upperGroup.depth; // shift up if depth encroaches + } // Generate the vlist + + + var vlist; + + if (lowerGroup) { + var lowerShift = -options.fontMetrics().axisHeight + lowerGroup.height + 0.5 * arrowBody.height + 0.111; + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }, { + type: "elem", + elem: lowerGroup, + shift: lowerShift + }] + }, options); + } else { + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: upperGroup, + shift: upperShift + }, { + type: "elem", + elem: arrowBody, + shift: arrowShift + }] + }, options); + } // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + + + vlist.children[0].children[0].children[1].classes.push("svg-align"); + return buildCommon.makeSpan(["mrel", "x-arrow"], [vlist], options); + }, + + mathmlBuilder(group, options) { + var arrowNode = stretchy.mathMLnode(group.label); + arrowNode.setAttribute("minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"); + var node; + + if (group.body) { + var upperNode = paddedNode(buildGroup(group.body, options)); + + if (group.below) { + var lowerNode = paddedNode(buildGroup(group.below, options)); + node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]); + } else { + node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]); + } + } else if (group.below) { + var _lowerNode = paddedNode(buildGroup(group.below, options)); + + node = new mathMLTree.MathNode("munder", [arrowNode, _lowerNode]); + } else { + // This should never happen. + // Parser.js throws an error if there is no argument. + node = paddedNode(); + node = new mathMLTree.MathNode("mover", [arrowNode, node]); + } + + return node; + } + +}); + +var makeSpan = buildCommon.makeSpan; + +function htmlBuilder$9(group, options) { + var elements = buildExpression$1(group.body, options, true); + return makeSpan([group.mclass], elements, options); +} + +function mathmlBuilder$8(group, options) { + var node; + var inner = buildExpression(group.body, options); + + if (group.mclass === "minner") { + node = new mathMLTree.MathNode("mpadded", inner); + } else if (group.mclass === "mord") { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mi"; + } else { + node = new mathMLTree.MathNode("mi", inner); + } + } else { + if (group.isCharacterBox) { + node = inner[0]; + node.type = "mo"; + } else { + node = new mathMLTree.MathNode("mo", inner); + } // Set spacing based on what is the most likely adjacent atom type. + // See TeXbook p170. + + + if (group.mclass === "mbin") { + node.attributes.lspace = "0.22em"; // medium space + + node.attributes.rspace = "0.22em"; + } else if (group.mclass === "mpunct") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0.17em"; // thinspace + } else if (group.mclass === "mopen" || group.mclass === "mclose") { + node.attributes.lspace = "0em"; + node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + + node.attributes.width = "+0.1111em"; + } // MathML default space is 5/18 em, so needs no action. + // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo + + } + + return node; +} // Math class commands except \mathop + + +defineFunction({ + type: "mclass", + names: ["\\mathord", "\\mathbin", "\\mathrel", "\\mathopen", "\\mathclose", "\\mathpunct", "\\mathinner"], + props: { + numArgs: 1, + primitive: true + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "mclass", + mode: parser.mode, + mclass: "m" + funcName.slice(5), + // TODO(kevinb): don't prefix with 'm' + body: ordargument(body), + isCharacterBox: utils$1.isCharacterBox(body) + }; + }, + + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); +var binrelClass = arg => { + // \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument. + // (by rendering separately and with {}s before and after, and measuring + // the change in spacing). We'll do roughly the same by detecting the + // atom type directly. + var atom = arg.type === "ordgroup" && arg.body.length ? arg.body[0] : arg; + + if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) { + return "m" + atom.family; + } else { + return "mord"; + } +}; // \@binrel{x}{y} renders like y but as mbin/mrel/mord if x is mbin/mrel/mord. +// This is equivalent to \binrel@{x}\binrel@@{y} in AMSTeX. + +defineFunction({ + type: "mclass", + names: ["\\@binrel"], + props: { + numArgs: 2 + }, + + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[1]), + isCharacterBox: utils$1.isCharacterBox(args[1]) + }; + } + +}); // Build a relation or stacked op by placing one symbol on top of another + +defineFunction({ + type: "mclass", + names: ["\\stackrel", "\\overset", "\\underset"], + props: { + numArgs: 2 + }, + + handler(_ref3, args) { + var { + parser, + funcName + } = _ref3; + var baseArg = args[1]; + var shiftedArg = args[0]; + var mclass; + + if (funcName !== "\\stackrel") { + // LaTeX applies \binrel spacing to \overset and \underset. + mclass = binrelClass(baseArg); + } else { + mclass = "mrel"; // for \stackrel + } + + var baseOp = { + type: "op", + mode: baseArg.mode, + limits: true, + alwaysHandleSupSub: true, + parentIsSupSub: false, + symbol: false, + suppressBaseShift: funcName !== "\\stackrel", + body: ordargument(baseArg) + }; + var supsub = { + type: "supsub", + mode: shiftedArg.mode, + base: baseOp, + sup: funcName === "\\underset" ? null : shiftedArg, + sub: funcName === "\\underset" ? shiftedArg : null + }; + return { + type: "mclass", + mode: parser.mode, + mclass, + body: [supsub], + isCharacterBox: utils$1.isCharacterBox(supsub) + }; + }, + + htmlBuilder: htmlBuilder$9, + mathmlBuilder: mathmlBuilder$8 +}); + +// \pmb is a simulation of bold font. +// The version of \pmb in ambsy.sty works by typesetting three copies +// with small offsets. We use CSS text-shadow. +// It's a hack. Not as good as a real bold font. Better than nothing. +defineFunction({ + type: "pmb", + names: ["\\pmb"], + props: { + numArgs: 1, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "pmb", + mode: parser.mode, + mclass: binrelClass(args[0]), + body: ordargument(args[0]) + }; + }, + + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, true); + var node = buildCommon.makeSpan([group.mclass], elements, options); + node.style.textShadow = "0.02em 0.01em 0.04px"; + return node; + }, + + mathmlBuilder(group, style) { + var inner = buildExpression(group.body, style); // Wrap with an element. + + var node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px"); + return node; + } + +}); + +var cdArrowFunctionName = { + ">": "\\\\cdrightarrow", + "<": "\\\\cdleftarrow", + "=": "\\\\cdlongequal", + "A": "\\uparrow", + "V": "\\downarrow", + "|": "\\Vert", + ".": "no arrow" +}; + +var newCell = () => { + // Create an empty cell, to be filled below with parse nodes. + // The parseTree from this module must be constructed like the + // one created by parseArray(), so an empty CD cell must + // be a ParseNode<"styling">. And CD is always displaystyle. + // So these values are fixed and flow can do implicit typing. + return { + type: "styling", + body: [], + mode: "math", + style: "display" + }; +}; + +var isStartOfArrow = node => { + return node.type === "textord" && node.text === "@"; +}; + +var isLabelEnd = (node, endChar) => { + return (node.type === "mathord" || node.type === "atom") && node.text === endChar; +}; + +function cdArrow(arrowChar, labels, parser) { + // Return a parse tree of an arrow and its labels. + // This acts in a way similar to a macro expansion. + var funcName = cdArrowFunctionName[arrowChar]; + + switch (funcName) { + case "\\\\cdrightarrow": + case "\\\\cdleftarrow": + return parser.callFunction(funcName, [labels[0]], [labels[1]]); + + case "\\uparrow": + case "\\downarrow": + { + var leftLabel = parser.callFunction("\\\\cdleft", [labels[0]], []); + var bareArrow = { + type: "atom", + text: funcName, + mode: "math", + family: "rel" + }; + var sizedArrow = parser.callFunction("\\Big", [bareArrow], []); + var rightLabel = parser.callFunction("\\\\cdright", [labels[1]], []); + var arrowGroup = { + type: "ordgroup", + mode: "math", + body: [leftLabel, sizedArrow, rightLabel] + }; + return parser.callFunction("\\\\cdparent", [arrowGroup], []); + } + + case "\\\\cdlongequal": + return parser.callFunction("\\\\cdlongequal", [], []); + + case "\\Vert": + { + var arrow = { + type: "textord", + text: "\\Vert", + mode: "math" + }; + return parser.callFunction("\\Big", [arrow], []); + } + + default: + return { + type: "textord", + text: " ", + mode: "math" + }; + } +} + +function parseCD(parser) { + // Get the array's parse nodes with \\ temporarily mapped to \cr. + var parsedRows = []; + parser.gullet.beginGroup(); + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + parser.gullet.beginGroup(); + + while (true) { + // eslint-disable-line no-constant-condition + // Get the parse nodes for the next row. + parsedRows.push(parser.parseExpression(false, "\\\\")); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + var next = parser.fetch().text; + + if (next === "&" || next === "\\\\") { + parser.consume(); + } else if (next === "\\end") { + if (parsedRows[parsedRows.length - 1].length === 0) { + parsedRows.pop(); // final row ended in \\ + } + + break; + } else { + throw new ParseError("Expected \\\\ or \\cr or \\end", parser.nextToken); + } + } + + var row = []; + var body = [row]; // Loop thru the parse nodes. Collect them into cells and arrows. + + for (var i = 0; i < parsedRows.length; i++) { + // Start a new row. + var rowNodes = parsedRows[i]; // Create the first cell. + + var cell = newCell(); + + for (var j = 0; j < rowNodes.length; j++) { + if (!isStartOfArrow(rowNodes[j])) { + // If a parseNode is not an arrow, it goes into a cell. + cell.body.push(rowNodes[j]); + } else { + // Parse node j is an "@", the start of an arrow. + // Before starting on the arrow, push the cell into `row`. + row.push(cell); // Now collect parseNodes into an arrow. + // The character after "@" defines the arrow type. + + j += 1; + var arrowChar = assertSymbolNodeType(rowNodes[j]).text; // Create two empty label nodes. We may or may not use them. + + var labels = new Array(2); + labels[0] = { + type: "ordgroup", + mode: "math", + body: [] + }; + labels[1] = { + type: "ordgroup", + mode: "math", + body: [] + }; // Process the arrow. + + if ("=|.".indexOf(arrowChar) > -1) ; else if ("<>AV".indexOf(arrowChar) > -1) { + // Four arrows, `@>>>`, `@<<<`, `@AAA`, and `@VVV`, each take + // two optional labels. E.g. the right-point arrow syntax is + // really: @>{optional label}>{optional label}> + // Collect parseNodes into labels. + for (var labelNum = 0; labelNum < 2; labelNum++) { + var inLabel = true; + + for (var k = j + 1; k < rowNodes.length; k++) { + if (isLabelEnd(rowNodes[k], arrowChar)) { + inLabel = false; + j = k; + break; + } + + if (isStartOfArrow(rowNodes[k])) { + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[k]); + } + + labels[labelNum].body.push(rowNodes[k]); + } + + if (inLabel) { + // isLabelEnd never returned a true. + throw new ParseError("Missing a " + arrowChar + " character to complete a CD arrow.", rowNodes[j]); + } + } + } else { + throw new ParseError("Expected one of \"<>AV=|.\" after @", rowNodes[j]); + } // Now join the arrow to its labels. + + + var arrow = cdArrow(arrowChar, labels, parser); // Wrap the arrow in ParseNode<"styling">. + // This is done to match parseArray() behavior. + + var wrappedArrow = { + type: "styling", + body: [arrow], + mode: "math", + style: "display" // CD is always displaystyle. + + }; + row.push(wrappedArrow); // In CD's syntax, cells are implicit. That is, everything that + // is not an arrow gets collected into a cell. So create an empty + // cell now. It will collect upcoming parseNodes. + + cell = newCell(); + } + } + + if (i % 2 === 0) { + // Even-numbered rows consist of: cell, arrow, cell, arrow, ... cell + // The last cell is not yet pushed into `row`, so: + row.push(cell); + } else { + // Odd-numbered rows consist of: vert arrow, empty cell, ... vert arrow + // Remove the empty cell that was placed at the beginning of `row`. + row.shift(); + } + + row = []; + body.push(row); + } // End row group + + + parser.gullet.endGroup(); // End array group defining \\ + + parser.gullet.endGroup(); // define column separation. + + var cols = new Array(body[0].length).fill({ + type: "align", + align: "c", + pregap: 0.25, + // CD package sets \enskip between columns. + postgap: 0.25 // So pre and post each get half an \enskip, i.e. 0.25em. + + }); + return { + type: "array", + mode: "math", + body, + arraystretch: 1, + addJot: true, + rowGaps: [null], + cols, + colSeparationType: "CD", + hLinesBeforeRow: new Array(body.length + 1).fill([]) + }; +} // The functions below are not available for general use. +// They are here only for internal use by the {CD} environment in placing labels +// next to vertical arrows. +// We don't need any such functions for horizontal arrows because we can reuse +// the functionality that already exists for extensible arrows. + +defineFunction({ + type: "cdlabel", + names: ["\\\\cdleft", "\\\\cdright"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "cdlabel", + mode: parser.mode, + side: funcName.slice(4), + label: args[0] + }; + }, + + htmlBuilder(group, options) { + var newOptions = options.havingStyle(options.style.sup()); + var label = buildCommon.wrapFragment(buildGroup$1(group.label, newOptions, options), options); + label.classes.push("cd-label-" + group.side); + label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set + // by the arrow height, not by the label. + + label.height = 0; + label.depth = 0; + return label; + }, + + mathmlBuilder(group, options) { + var label = new mathMLTree.MathNode("mrow", [buildGroup(group.label, options)]); + label = new mathMLTree.MathNode("mpadded", [label]); + label.setAttribute("width", "0"); + + if (group.side === "left") { + label.setAttribute("lspace", "-1width"); + } // We have to guess at vertical alignment. We know the arrow is 1.8em tall, + // But we don't know the height or depth of the label. + + + label.setAttribute("voffset", "0.7em"); + label = new mathMLTree.MathNode("mstyle", [label]); + label.setAttribute("displaystyle", "false"); + label.setAttribute("scriptlevel", "1"); + return label; + } + +}); +defineFunction({ + type: "cdlabelparent", + names: ["\\\\cdparent"], + props: { + numArgs: 1 + }, + + handler(_ref2, args) { + var { + parser + } = _ref2; + return { + type: "cdlabelparent", + mode: parser.mode, + fragment: args[0] + }; + }, + + htmlBuilder(group, options) { + // Wrap the vertical arrow and its labels. + // The parent gets position: relative. The child gets position: absolute. + // So CSS can locate the label correctly. + var parent = buildCommon.wrapFragment(buildGroup$1(group.fragment, options), options); + parent.classes.push("cd-vert-arrow"); + return parent; + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", [buildGroup(group.fragment, options)]); + } + +}); + +// {123} and converts into symbol with code 123. It is used by the *macro* +// \char defined in macros.js. + +defineFunction({ + type: "textord", + names: ["\\@char"], + props: { + numArgs: 1, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var arg = assertNodeType(args[0], "ordgroup"); + var group = arg.body; + var number = ""; + + for (var i = 0; i < group.length; i++) { + var node = assertNodeType(group[i], "textord"); + number += node.text; + } + + var code = parseInt(number); + var text; + + if (isNaN(code)) { + throw new ParseError("\\@char has non-numeric argument " + number); // If we drop IE support, the following code could be replaced with + // text = String.fromCodePoint(code) + } else if (code < 0 || code >= 0x10ffff) { + throw new ParseError("\\@char with invalid code point " + number); + } else if (code <= 0xffff) { + text = String.fromCharCode(code); + } else { + // Astral code point; split into surrogate halves + code -= 0x10000; + text = String.fromCharCode((code >> 10) + 0xd800, (code & 0x3ff) + 0xdc00); + } + + return { + type: "textord", + mode: parser.mode, + text: text + }; + } + +}); + +var htmlBuilder$8 = (group, options) => { + var elements = buildExpression$1(group.body, options.withColor(group.color), false); // \color isn't supposed to affect the type of the elements it contains. + // To accomplish this, we wrap the results in a fragment, so the inner + // elements will be able to directly interact with their neighbors. For + // example, `\color{red}{2 +} 3` has the same spacing as `2 + 3` + + return buildCommon.makeFragment(elements); +}; + +var mathmlBuilder$7 = (group, options) => { + var inner = buildExpression(group.body, options.withColor(group.color)); + var node = new mathMLTree.MathNode("mstyle", inner); + node.setAttribute("mathcolor", group.color); + return node; +}; + +defineFunction({ + type: "color", + names: ["\\textcolor"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "original"] + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "color", + mode: parser.mode, + color, + body: ordargument(body) + }; + }, + + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); +defineFunction({ + type: "color", + names: ["\\color"], + props: { + numArgs: 1, + allowedInText: true, + argTypes: ["color"] + }, + + handler(_ref2, args) { + var { + parser, + breakOnTokenText + } = _ref2; + var color = assertNodeType(args[0], "color-token").color; // Set macro \current@color in current namespace to store the current + // color, mimicking the behavior of color.sty. + // This is currently used just to correctly color a \right + // that follows a \color command. + + parser.gullet.macros.set("\\current@color", color); // Parse out the implicit body that should be colored. + + var body = parser.parseExpression(true, breakOnTokenText); + return { + type: "color", + mode: parser.mode, + color, + body + }; + }, + + htmlBuilder: htmlBuilder$8, + mathmlBuilder: mathmlBuilder$7 +}); + +// Row breaks within tabular environments, and line breaks at top level + +defineFunction({ + type: "cr", + names: ["\\\\"], + props: { + numArgs: 0, + numOptionalArgs: 0, + allowedInText: true + }, + + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var size = parser.gullet.future().text === "[" ? parser.parseSizeGroup(true) : null; + var newLine = !parser.settings.displayMode || !parser.settings.useStrictBehavior("newLineInDisplayMode", "In LaTeX, \\\\ or \\newline " + "does nothing in display mode"); + return { + type: "cr", + mode: parser.mode, + newLine, + size: size && assertNodeType(size, "size").value + }; + }, + + // The following builders are called only at the top level, + // not within tabular/array environments. + htmlBuilder(group, options) { + var span = buildCommon.makeSpan(["mspace"], [], options); + + if (group.newLine) { + span.classes.push("newline"); + + if (group.size) { + span.style.marginTop = makeEm(calculateSize(group.size, options)); + } + } + + return span; + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mspace"); + + if (group.newLine) { + node.setAttribute("linebreak", "newline"); + + if (group.size) { + node.setAttribute("height", makeEm(calculateSize(group.size, options))); + } + } + + return node; + } + +}); + +var globalMap = { + "\\global": "\\global", + "\\long": "\\\\globallong", + "\\\\globallong": "\\\\globallong", + "\\def": "\\gdef", + "\\gdef": "\\gdef", + "\\edef": "\\xdef", + "\\xdef": "\\xdef", + "\\let": "\\\\globallet", + "\\futurelet": "\\\\globalfuture" +}; + +var checkControlSequence = tok => { + var name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + return name; +}; + +var getRHS = parser => { + var tok = parser.gullet.popToken(); + + if (tok.text === "=") { + // consume optional equals + tok = parser.gullet.popToken(); + + if (tok.text === " ") { + // consume one optional space + tok = parser.gullet.popToken(); + } + } + + return tok; +}; + +var letCommand = (parser, name, tok, global) => { + var macro = parser.gullet.macros.get(tok.text); + + if (macro == null) { + // don't expand it later even if a macro with the same name is defined + // e.g., \let\foo=\frac \def\frac{\relax} \frac12 + tok.noexpand = true; + macro = { + tokens: [tok], + numArgs: 0, + // reproduce the same behavior in expansion + unexpandable: !parser.gullet.isExpandable(tok.text) + }; + } + + parser.gullet.macros.set(name, macro, global); +}; // -> | +// -> |\global +// -> | +// -> \global|\long|\outer + + +defineFunction({ + type: "internal", + names: ["\\global", "\\long", "\\\\globallong" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + var { + parser, + funcName + } = _ref; + parser.consumeSpaces(); + var token = parser.fetch(); + + if (globalMap[token.text]) { + // KaTeX doesn't have \par, so ignore \long + if (funcName === "\\global" || funcName === "\\\\globallong") { + token.text = globalMap[token.text]; + } + + return assertNodeType(parser.parseFunction(), "internal"); + } + + throw new ParseError("Invalid token after macro prefix", token); + } + +}); // Basic support for macro definitions: \def, \gdef, \edef, \xdef +// -> +// -> \def|\gdef|\edef|\xdef +// -> + +defineFunction({ + type: "internal", + names: ["\\def", "\\gdef", "\\edef", "\\xdef"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref2) { + var { + parser, + funcName + } = _ref2; + var tok = parser.gullet.popToken(); + var name = tok.text; + + if (/^(?:[\\{}$&#^_]|EOF)$/.test(name)) { + throw new ParseError("Expected a control sequence", tok); + } + + var numArgs = 0; + var insert; + var delimiters = [[]]; // contains no braces + + while (parser.gullet.future().text !== "{") { + tok = parser.gullet.popToken(); + + if (tok.text === "#") { + // If the very last character of the is #, so that + // this # is immediately followed by {, TeX will behave as if the { + // had been inserted at the right end of both the parameter text + // and the replacement text. + if (parser.gullet.future().text === "{") { + insert = parser.gullet.future(); + delimiters[numArgs].push("{"); + break; + } // A parameter, the first appearance of # must be followed by 1, + // the next by 2, and so on; up to nine #’s are allowed + + + tok = parser.gullet.popToken(); + + if (!/^[1-9]$/.test(tok.text)) { + throw new ParseError("Invalid argument number \"" + tok.text + "\""); + } + + if (parseInt(tok.text) !== numArgs + 1) { + throw new ParseError("Argument number \"" + tok.text + "\" out of order"); + } + + numArgs++; + delimiters.push([]); + } else if (tok.text === "EOF") { + throw new ParseError("Expected a macro definition"); + } else { + delimiters[numArgs].push(tok.text); + } + } // replacement text, enclosed in '{' and '}' and properly nested + + + var { + tokens + } = parser.gullet.consumeArg(); + + if (insert) { + tokens.unshift(insert); + } + + if (funcName === "\\edef" || funcName === "\\xdef") { + tokens = parser.gullet.expandTokens(tokens); + tokens.reverse(); // to fit in with stack order + } // Final arg is the expansion of the macro + + + parser.gullet.macros.set(name, { + tokens, + numArgs, + delimiters + }, funcName === globalMap[funcName]); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // -> +// -> \futurelet +// | \let +// -> |= + +defineFunction({ + type: "internal", + names: ["\\let", "\\\\globallet" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + var name = checkControlSequence(parser.gullet.popToken()); + parser.gullet.consumeSpaces(); + var tok = getRHS(parser); + letCommand(parser, name, tok, funcName === "\\\\globallet"); + return { + type: "internal", + mode: parser.mode + }; + } + +}); // ref: https://www.tug.org/TUGboat/tb09-3/tb22bechtolsheim.pdf + +defineFunction({ + type: "internal", + names: ["\\futurelet", "\\\\globalfuture" // can’t be entered directly + ], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + var name = checkControlSequence(parser.gullet.popToken()); + var middle = parser.gullet.popToken(); + var tok = parser.gullet.popToken(); + letCommand(parser, name, tok, funcName === "\\\\globalfuture"); + parser.gullet.pushToken(tok); + parser.gullet.pushToken(middle); + return { + type: "internal", + mode: parser.mode + }; + } + +}); + +/** + * This file deals with creating delimiters of various sizes. The TeXbook + * discusses these routines on page 441-442, in the "Another subroutine sets box + * x to a specified variable delimiter" paragraph. + * + * There are three main routines here. `makeSmallDelim` makes a delimiter in the + * normal font, but in either text, script, or scriptscript style. + * `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1, + * Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of + * smaller pieces that are stacked on top of one another. + * + * The functions take a parameter `center`, which determines if the delimiter + * should be centered around the axis. + * + * Then, there are three exposed functions. `sizedDelim` makes a delimiter in + * one of the given sizes. This is used for things like `\bigl`. + * `customSizedDelim` makes a delimiter with a given total height+depth. It is + * called in places like `\sqrt`. `leftRightDelim` makes an appropriate + * delimiter which surrounds an expression of a given height an depth. It is + * used in `\left` and `\right`. + */ + +/** + * Get the metrics for a given symbol and font, after transformation (i.e. + * after following replacement from symbols.js) + */ +var getMetrics = function getMetrics(symbol, font, mode) { + var replace = symbols.math[symbol] && symbols.math[symbol].replace; + var metrics = getCharacterMetrics(replace || symbol, font, mode); + + if (!metrics) { + throw new Error("Unsupported symbol " + symbol + " and font size " + font + "."); + } + + return metrics; +}; +/** + * Puts a delimiter span in a given style, and adds appropriate height, depth, + * and maxFontSizes. + */ + + +var styleWrap = function styleWrap(delim, toStyle, options, classes) { + var newOptions = options.havingBaseStyle(toStyle); + var span = buildCommon.makeSpan(classes.concat(newOptions.sizingClasses(options)), [delim], options); + var delimSizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier; + span.height *= delimSizeMultiplier; + span.depth *= delimSizeMultiplier; + span.maxFontSize = newOptions.sizeMultiplier; + return span; +}; + +var centerSpan = function centerSpan(span, options, style) { + var newOptions = options.havingBaseStyle(style); + var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight; + span.classes.push("delimcenter"); + span.style.top = makeEm(shift); + span.height -= shift; + span.depth += shift; +}; +/** + * Makes a small delimiter. This is a delimiter that comes in the Main-Regular + * font, but is restyled to either be in textstyle, scriptstyle, or + * scriptscriptstyle. + */ + + +var makeSmallDelim = function makeSmallDelim(delim, style, center, options, mode, classes) { + var text = buildCommon.makeSymbol(delim, "Main-Regular", mode, options); + var span = styleWrap(text, style, options, classes); + + if (center) { + centerSpan(span, options, style); + } + + return span; +}; +/** + * Builds a symbol in the given font size (note size is an integer) + */ + + +var mathrmSize = function mathrmSize(value, size, mode, options) { + return buildCommon.makeSymbol(value, "Size" + size + "-Regular", mode, options); +}; +/** + * Makes a large delimiter. This is a delimiter that comes in the Size1, Size2, + * Size3, or Size4 fonts. It is always rendered in textstyle. + */ + + +var makeLargeDelim = function makeLargeDelim(delim, size, center, options, mode, classes) { + var inner = mathrmSize(delim, size, mode, options); + var span = styleWrap(buildCommon.makeSpan(["delimsizing", "size" + size], [inner], options), Style$1$1.TEXT, options, classes); + + if (center) { + centerSpan(span, options, Style$1$1.TEXT); + } + + return span; +}; +/** + * Make a span from a font glyph with the given offset and in the given font. + * This is used in makeStackedDelim to make the stacking pieces for the delimiter. + */ + + +var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) { + var sizeClass; // Apply the correct CSS class to choose the right font. + + if (font === "Size1-Regular") { + sizeClass = "delim-size1"; + } else + /* if (font === "Size4-Regular") */ + { + sizeClass = "delim-size4"; + } + + var corner = buildCommon.makeSpan(["delimsizinginner", sizeClass], [buildCommon.makeSpan([], [buildCommon.makeSymbol(symbol, font, mode)])]); // Since this will be passed into `makeVList` in the end, wrap the element + // in the appropriate tag that VList uses. + + return { + type: "elem", + elem: corner + }; +}; + +var makeInner = function makeInner(ch, height, options) { + // Create a span with inline SVG for the inner part of a tall stacked delimiter. + var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]; + var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height))); + var svgNode = new SvgNode([path], { + "width": makeEm(width), + "height": makeEm(height), + // Override CSS rule `.katex svg { width: 100% }` + "style": "width:" + makeEm(width), + "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height), + "preserveAspectRatio": "xMinYMin" + }); + var span = buildCommon.makeSvgSpan([], [svgNode], options); + span.height = height; + span.style.height = makeEm(height); + span.style.width = makeEm(width); + return { + type: "elem", + elem: span + }; +}; // Helpers for makeStackedDelim + + +var lapInEms = 0.008; +var lap = { + type: "kern", + size: -1 * lapInEms +}; +var verts = ["|", "\\lvert", "\\rvert", "\\vert"]; +var doubleVerts = ["\\|", "\\lVert", "\\rVert", "\\Vert"]; +/** + * Make a stacked delimiter out of a given delimiter, with the total height at + * least `heightTotal`. This routine is mentioned on page 442 of the TeXbook. + */ + +var makeStackedDelim = function makeStackedDelim(delim, heightTotal, center, options, mode, classes) { + // There are four parts, the top, an optional middle, a repeated part, and a + // bottom. + var top; + var middle; + var repeat; + var bottom; + var svgLabel = ""; + var viewBoxWidth = 0; + top = repeat = bottom = delim; + middle = null; // Also keep track of what font the delimiters are in + + var font = "Size1-Regular"; // We set the parts and font based on the symbol. Note that we use + // '\u23d0' instead of '|' and '\u2016' instead of '\\|' for the + // repeats of the arrows + + if (delim === "\\uparrow") { + repeat = bottom = "\u23d0"; + } else if (delim === "\\Uparrow") { + repeat = bottom = "\u2016"; + } else if (delim === "\\downarrow") { + top = repeat = "\u23d0"; + } else if (delim === "\\Downarrow") { + top = repeat = "\u2016"; + } else if (delim === "\\updownarrow") { + top = "\\uparrow"; + repeat = "\u23d0"; + bottom = "\\downarrow"; + } else if (delim === "\\Updownarrow") { + top = "\\Uparrow"; + repeat = "\u2016"; + bottom = "\\Downarrow"; + } else if (utils$1.contains(verts, delim)) { + repeat = "\u2223"; + svgLabel = "vert"; + viewBoxWidth = 333; + } else if (utils$1.contains(doubleVerts, delim)) { + repeat = "\u2225"; + svgLabel = "doublevert"; + viewBoxWidth = 556; + } else if (delim === "[" || delim === "\\lbrack") { + top = "\u23a1"; + repeat = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lbrack"; + viewBoxWidth = 667; + } else if (delim === "]" || delim === "\\rbrack") { + top = "\u23a4"; + repeat = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rbrack"; + viewBoxWidth = 667; + } else if (delim === "\\lfloor" || delim === "\u230a") { + repeat = top = "\u23a2"; + bottom = "\u23a3"; + font = "Size4-Regular"; + svgLabel = "lfloor"; + viewBoxWidth = 667; + } else if (delim === "\\lceil" || delim === "\u2308") { + top = "\u23a1"; + repeat = bottom = "\u23a2"; + font = "Size4-Regular"; + svgLabel = "lceil"; + viewBoxWidth = 667; + } else if (delim === "\\rfloor" || delim === "\u230b") { + repeat = top = "\u23a5"; + bottom = "\u23a6"; + font = "Size4-Regular"; + svgLabel = "rfloor"; + viewBoxWidth = 667; + } else if (delim === "\\rceil" || delim === "\u2309") { + top = "\u23a4"; + repeat = bottom = "\u23a5"; + font = "Size4-Regular"; + svgLabel = "rceil"; + viewBoxWidth = 667; + } else if (delim === "(" || delim === "\\lparen") { + top = "\u239b"; + repeat = "\u239c"; + bottom = "\u239d"; + font = "Size4-Regular"; + svgLabel = "lparen"; + viewBoxWidth = 875; + } else if (delim === ")" || delim === "\\rparen") { + top = "\u239e"; + repeat = "\u239f"; + bottom = "\u23a0"; + font = "Size4-Regular"; + svgLabel = "rparen"; + viewBoxWidth = 875; + } else if (delim === "\\{" || delim === "\\lbrace") { + top = "\u23a7"; + middle = "\u23a8"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\}" || delim === "\\rbrace") { + top = "\u23ab"; + middle = "\u23ac"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lgroup" || delim === "\u27ee") { + top = "\u23a7"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rgroup" || delim === "\u27ef") { + top = "\u23ab"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\lmoustache" || delim === "\u23b0") { + top = "\u23a7"; + bottom = "\u23ad"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } else if (delim === "\\rmoustache" || delim === "\u23b1") { + top = "\u23ab"; + bottom = "\u23a9"; + repeat = "\u23aa"; + font = "Size4-Regular"; + } // Get the metrics of the four sections + + + var topMetrics = getMetrics(top, font, mode); + var topHeightTotal = topMetrics.height + topMetrics.depth; + var repeatMetrics = getMetrics(repeat, font, mode); + var repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth; + var bottomMetrics = getMetrics(bottom, font, mode); + var bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth; + var middleHeightTotal = 0; + var middleFactor = 1; + + if (middle !== null) { + var middleMetrics = getMetrics(middle, font, mode); + middleHeightTotal = middleMetrics.height + middleMetrics.depth; + middleFactor = 2; // repeat symmetrically above and below middle + } // Calculate the minimal height that the delimiter can have. + // It is at least the size of the top, bottom, and optional middle combined. + + + var minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal; // Compute the number of copies of the repeat symbol we will need + + var repeatCount = Math.max(0, Math.ceil((heightTotal - minHeight) / (middleFactor * repeatHeightTotal))); // Compute the total height of the delimiter including all the symbols + + var realHeightTotal = minHeight + repeatCount * middleFactor * repeatHeightTotal; // The center of the delimiter is placed at the center of the axis. Note + // that in this context, "center" means that the delimiter should be + // centered around the axis in the current style, while normally it is + // centered around the axis in textstyle. + + var axisHeight = options.fontMetrics().axisHeight; + + if (center) { + axisHeight *= options.sizeMultiplier; + } // Calculate the depth + + + var depth = realHeightTotal / 2 - axisHeight; // Now, we start building the pieces that will go into the vlist + // Keep a list of the pieces of the stacked delimiter + + var stack = []; + + if (svgLabel.length > 0) { + // Instead of stacking glyphs, create a single SVG. + // This evades browser problems with imprecise positioning of spans. + var midHeight = realHeightTotal - topHeightTotal - bottomHeightTotal; + var viewBoxHeight = Math.round(realHeightTotal * 1000); + var pathStr = tallDelim(svgLabel, Math.round(midHeight * 1000)); + var path = new PathNode(svgLabel, pathStr); + var width = (viewBoxWidth / 1000).toFixed(3) + "em"; + var height = (viewBoxHeight / 1000).toFixed(3) + "em"; + var svg = new SvgNode([path], { + "width": width, + "height": height, + "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight + }); + var wrapper = buildCommon.makeSvgSpan([], [svg], options); + wrapper.height = viewBoxHeight / 1000; + wrapper.style.width = width; + wrapper.style.height = height; + stack.push({ + type: "elem", + elem: wrapper + }); + } else { + // Stack glyphs + // Start by adding the bottom symbol + stack.push(makeGlyphSpan(bottom, font, mode)); + stack.push(lap); // overlap + + if (middle === null) { + // The middle section will be an SVG. Make it an extra 0.016em tall. + // We'll overlap by 0.008em at top and bottom. + var innerHeight = realHeightTotal - topHeightTotal - bottomHeightTotal + 2 * lapInEms; + stack.push(makeInner(repeat, innerHeight, options)); + } else { + // When there is a middle bit, we need the middle part and two repeated + // sections + var _innerHeight = (realHeightTotal - topHeightTotal - bottomHeightTotal - middleHeightTotal) / 2 + 2 * lapInEms; + + stack.push(makeInner(repeat, _innerHeight, options)); // Now insert the middle of the brace. + + stack.push(lap); + stack.push(makeGlyphSpan(middle, font, mode)); + stack.push(lap); + stack.push(makeInner(repeat, _innerHeight, options)); + } // Add the top symbol + + + stack.push(lap); + stack.push(makeGlyphSpan(top, font, mode)); + } // Finally, build the vlist + + + var newOptions = options.havingBaseStyle(Style$1$1.TEXT); + var inner = buildCommon.makeVList({ + positionType: "bottom", + positionData: depth, + children: stack + }, newOptions); + return styleWrap(buildCommon.makeSpan(["delimsizing", "mult"], [inner], newOptions), Style$1$1.TEXT, options, classes); +}; // All surds have 0.08em padding above the vinculum inside the SVG. +// That keeps browser span height rounding error from pinching the line. + + +var vbPad = 80; // padding above the surd, measured inside the viewBox. + +var emPad = 0.08; // padding, in ems, measured in the document. + +var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraVinculum, options) { + var path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight); + var pathNode = new PathNode(sqrtName, path); + var svg = new SvgNode([pathNode], { + // Note: 1000:1 ratio of viewBox to document em width. + "width": "400em", + "height": makeEm(height), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); + return buildCommon.makeSvgSpan(["hide-tail"], [svg], options); +}; +/** + * Make a sqrt image of the given height, + */ + + +var makeSqrtImage = function makeSqrtImage(height, options) { + // Define a newOptions that removes the effect of size changes such as \Huge. + // We don't pick different a height surd for \Huge. For it, we scale up. + var newOptions = options.havingBaseSizing(); // Pick the desired surd glyph from a sequence of surds. + + var delim = traverseSequence("\\surd", height * newOptions.sizeMultiplier, stackLargeDelimiterSequence, newOptions); + var sizeMultiplier = newOptions.sizeMultiplier; // default + // The standard sqrt SVGs each have a 0.04em thick vinculum. + // If Settings.minRuleThickness is larger than that, we add extraVinculum. + + var extraVinculum = Math.max(0, options.minRuleThickness - options.fontMetrics().sqrtRuleThickness); // Create a span containing an SVG image of a sqrt symbol. + + var span; + var spanHeight = 0; + var texHeight = 0; + var viewBoxHeight = 0; + var advanceWidth; // We create viewBoxes with 80 units of "padding" above each surd. + // Then browser rounding error on the parent span height will not + // encroach on the ink of the vinculum. But that padding is not + // included in the TeX-like `height` used for calculation of + // vertical alignment. So texHeight = span.height < span.style.height. + + if (delim.type === "small") { + // Get an SVG that is derived from glyph U+221A in font KaTeX-Main. + // 1000 unit normal glyph height. + viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad; + + if (height < 1.0) { + sizeMultiplier = 1.0; // mimic a \textfont radical + } else if (height < 1.4) { + sizeMultiplier = 0.7; // mimic a \scriptfont radical + } + + spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier; + texHeight = (1.00 + extraVinculum) / sizeMultiplier; + span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.853em"; + advanceWidth = 0.833 / sizeMultiplier; // from the font. + } else if (delim.type === "large") { + // These SVGs come from fonts: KaTeX_Size1, _Size2, etc. + viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size]; + texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier; + spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad) / sizeMultiplier; + span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "1.02em"; + advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font. + } else { + // Tall sqrt. In TeX, this would be stacked using multiple glyphs. + // We'll use a single SVG to accomplish the same thing. + spanHeight = height + extraVinculum + emPad; + texHeight = height + extraVinculum; + viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad; + span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum, options); + span.style.minWidth = "0.742em"; + advanceWidth = 1.056; + } + + span.height = texHeight; + span.style.height = makeEm(spanHeight); + return { + span, + advanceWidth, + // Calculate the actual line width. + // This actually should depend on the chosen font -- e.g. \boldmath + // should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and + // have thicker rules. + ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum) * sizeMultiplier + }; +}; // There are three kinds of delimiters, delimiters that stack when they become +// too large + + +var stackLargeDelimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "\\surd"]; // delimiters that always stack + +var stackAlwaysDelimiters = ["\\uparrow", "\\downarrow", "\\updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow", "|", "\\|", "\\vert", "\\Vert", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1"]; // and delimiters that never stack + +var stackNeverDelimiters = ["<", ">", "\\langle", "\\rangle", "/", "\\backslash", "\\lt", "\\gt"]; // Metrics of the different sizes. Found by looking at TeX's output of +// $\bigl| // \Bigl| \biggl| \Biggl| \showlists$ +// Used to create stacked delimiters of appropriate sizes in makeSizedDelim. + +var sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0]; +/** + * Used to create a delimiter of a specific size, where `size` is 1, 2, 3, or 4. + */ + +var makeSizedDelim = function makeSizedDelim(delim, size, options, mode, classes) { + // < and > turn into \langle and \rangle in delimiters + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } // Sized delimiters are never centered. + + + if (utils$1.contains(stackLargeDelimiters, delim) || utils$1.contains(stackNeverDelimiters, delim)) { + return makeLargeDelim(delim, size, false, options, mode, classes); + } else if (utils$1.contains(stackAlwaysDelimiters, delim)) { + return makeStackedDelim(delim, sizeToMaxHeight[size], false, options, mode, classes); + } else { + throw new ParseError("Illegal delimiter: '" + delim + "'"); + } +}; +/** + * There are three different sequences of delimiter sizes that the delimiters + * follow depending on the kind of delimiter. This is used when creating custom + * sized delimiters to decide whether to create a small, large, or stacked + * delimiter. + * + * In real TeX, these sequences aren't explicitly defined, but are instead + * defined inside the font metrics. Since there are only three sequences that + * are possible for the delimiters that TeX defines, it is easier to just encode + * them explicitly here. + */ + + +// Delimiters that never stack try small delimiters and large delimiters only +var stackNeverDelimiterSequence = [{ + type: "small", + style: Style$1$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1$1.SCRIPT +}, { + type: "small", + style: Style$1$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}]; // Delimiters that always stack try the small delimiters first, then stack + +var stackAlwaysDelimiterSequence = [{ + type: "small", + style: Style$1$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1$1.SCRIPT +}, { + type: "small", + style: Style$1$1.TEXT +}, { + type: "stack" +}]; // Delimiters that stack when large try the small and then large delimiters, and +// stack afterwards + +var stackLargeDelimiterSequence = [{ + type: "small", + style: Style$1$1.SCRIPTSCRIPT +}, { + type: "small", + style: Style$1$1.SCRIPT +}, { + type: "small", + style: Style$1$1.TEXT +}, { + type: "large", + size: 1 +}, { + type: "large", + size: 2 +}, { + type: "large", + size: 3 +}, { + type: "large", + size: 4 +}, { + type: "stack" +}]; +/** + * Get the font used in a delimiter based on what kind of delimiter it is. + * TODO(#963) Use more specific font family return type once that is introduced. + */ + +var delimTypeToFont = function delimTypeToFont(type) { + if (type.type === "small") { + return "Main-Regular"; + } else if (type.type === "large") { + return "Size" + type.size + "-Regular"; + } else if (type.type === "stack") { + return "Size4-Regular"; + } else { + throw new Error("Add support for delim type '" + type.type + "' here."); + } +}; +/** + * Traverse a sequence of types of delimiters to decide what kind of delimiter + * should be used to create a delimiter of the given height+depth. + */ + + +var traverseSequence = function traverseSequence(delim, height, sequence, options) { + // Here, we choose the index we should start at in the sequences. In smaller + // sizes (which correspond to larger numbers in style.size) we start earlier + // in the sequence. Thus, scriptscript starts at index 3-3=0, script starts + // at index 3-2=1, text starts at 3-1=2, and display starts at min(2,3-0)=2 + var start = Math.min(2, 3 - options.style.size); + + for (var i = start; i < sequence.length; i++) { + if (sequence[i].type === "stack") { + // This is always the last delimiter, so we just break the loop now. + break; + } + + var metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math"); + var heightDepth = metrics.height + metrics.depth; // Small delimiters are scaled down versions of the same font, so we + // account for the style change size. + + if (sequence[i].type === "small") { + var newOptions = options.havingBaseStyle(sequence[i].style); + heightDepth *= newOptions.sizeMultiplier; + } // Check if the delimiter at this size works for the given height. + + + if (heightDepth > height) { + return sequence[i]; + } + } // If we reached the end of the sequence, return the last sequence element. + + + return sequence[sequence.length - 1]; +}; +/** + * Make a delimiter of a given height+depth, with optional centering. Here, we + * traverse the sequences, and create a delimiter that the sequence tells us to. + */ + + +var makeCustomSizedDelim = function makeCustomSizedDelim(delim, height, center, options, mode, classes) { + if (delim === "<" || delim === "\\lt" || delim === "\u27e8") { + delim = "\\langle"; + } else if (delim === ">" || delim === "\\gt" || delim === "\u27e9") { + delim = "\\rangle"; + } // Decide what sequence to use + + + var sequence; + + if (utils$1.contains(stackNeverDelimiters, delim)) { + sequence = stackNeverDelimiterSequence; + } else if (utils$1.contains(stackLargeDelimiters, delim)) { + sequence = stackLargeDelimiterSequence; + } else { + sequence = stackAlwaysDelimiterSequence; + } // Look through the sequence + + + var delimType = traverseSequence(delim, height, sequence, options); // Get the delimiter from font glyphs. + // Depending on the sequence element we decided on, call the + // appropriate function. + + if (delimType.type === "small") { + return makeSmallDelim(delim, delimType.style, center, options, mode, classes); + } else if (delimType.type === "large") { + return makeLargeDelim(delim, delimType.size, center, options, mode, classes); + } else + /* if (delimType.type === "stack") */ + { + return makeStackedDelim(delim, height, center, options, mode, classes); + } +}; +/** + * Make a delimiter for use with `\left` and `\right`, given a height and depth + * of an expression that the delimiters surround. + */ + + +var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, options, mode, classes) { + // We always center \left/\right delimiters, so the axis is always shifted + var axisHeight = options.fontMetrics().axisHeight * options.sizeMultiplier; // Taken from TeX source, tex.web, function make_left_right + + var delimiterFactor = 901; + var delimiterExtend = 5.0 / options.fontMetrics().ptPerEm; + var maxDistFromAxis = Math.max(height - axisHeight, depth + axisHeight); + var totalHeight = Math.max( // In real TeX, calculations are done using integral values which are + // 65536 per pt, or 655360 per em. So, the division here truncates in + // TeX but doesn't here, producing different results. If we wanted to + // exactly match TeX's calculation, we could do + // Math.floor(655360 * maxDistFromAxis / 500) * + // delimiterFactor / 655360 + // (To see the difference, compare + // x^{x^{\left(\rule{0.1em}{0.68em}\right)}} + // in TeX and KaTeX) + maxDistFromAxis / 500 * delimiterFactor, 2 * maxDistFromAxis - delimiterExtend); // Finally, we defer to `makeCustomSizedDelim` with our calculated total + // height + + return makeCustomSizedDelim(delim, totalHeight, true, options, mode, classes); +}; + +var delimiter$1 = { + sqrtImage: makeSqrtImage, + sizedDelim: makeSizedDelim, + sizeToMaxHeight: sizeToMaxHeight, + customSizedDelim: makeCustomSizedDelim, + leftRightDelim: makeLeftRightDelim +}; + +// Extra data needed for the delimiter handler down below +var delimiterSizes = { + "\\bigl": { + mclass: "mopen", + size: 1 + }, + "\\Bigl": { + mclass: "mopen", + size: 2 + }, + "\\biggl": { + mclass: "mopen", + size: 3 + }, + "\\Biggl": { + mclass: "mopen", + size: 4 + }, + "\\bigr": { + mclass: "mclose", + size: 1 + }, + "\\Bigr": { + mclass: "mclose", + size: 2 + }, + "\\biggr": { + mclass: "mclose", + size: 3 + }, + "\\Biggr": { + mclass: "mclose", + size: 4 + }, + "\\bigm": { + mclass: "mrel", + size: 1 + }, + "\\Bigm": { + mclass: "mrel", + size: 2 + }, + "\\biggm": { + mclass: "mrel", + size: 3 + }, + "\\Biggm": { + mclass: "mrel", + size: 4 + }, + "\\big": { + mclass: "mord", + size: 1 + }, + "\\Big": { + mclass: "mord", + size: 2 + }, + "\\bigg": { + mclass: "mord", + size: 3 + }, + "\\Bigg": { + mclass: "mord", + size: 4 + } +}; +var delimiters = ["(", "\\lparen", ")", "\\rparen", "[", "\\lbrack", "]", "\\rbrack", "\\{", "\\lbrace", "\\}", "\\rbrace", "\\lfloor", "\\rfloor", "\u230a", "\u230b", "\\lceil", "\\rceil", "\u2308", "\u2309", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef", "\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1", "/", "\\backslash", "|", "\\vert", "\\|", "\\Vert", "\\uparrow", "\\Uparrow", "\\downarrow", "\\Downarrow", "\\updownarrow", "\\Updownarrow", "."]; + +// Delimiter functions +function checkDelimiter(delim, context) { + var symDelim = checkSymbolNodeType(delim); + + if (symDelim && utils$1.contains(delimiters, symDelim.text)) { + return symDelim; + } else if (symDelim) { + throw new ParseError("Invalid delimiter '" + symDelim.text + "' after '" + context.funcName + "'", delim); + } else { + throw new ParseError("Invalid delimiter type '" + delim.type + "'", delim); + } +} + +defineFunction({ + type: "delimsizing", + names: ["\\bigl", "\\Bigl", "\\biggl", "\\Biggl", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr", "\\bigm", "\\Bigm", "\\biggm", "\\Biggm", "\\big", "\\Big", "\\bigg", "\\Bigg"], + props: { + numArgs: 1, + argTypes: ["primitive"] + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + return { + type: "delimsizing", + mode: context.parser.mode, + size: delimiterSizes[context.funcName].size, + mclass: delimiterSizes[context.funcName].mclass, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + if (group.delim === ".") { + // Empty delimiters still count as elements, even though they don't + // show anything. + return buildCommon.makeSpan([group.mclass]); + } // Use delimiter.sizedDelim to generate the delimiter. + + + return delimiter$1.sizedDelim(group.delim, group.size, options, group.mode, [group.mclass]); + }, + mathmlBuilder: group => { + var children = []; + + if (group.delim !== ".") { + children.push(makeText(group.delim, group.mode)); + } + + var node = new mathMLTree.MathNode("mo", children); + + if (group.mclass === "mopen" || group.mclass === "mclose") { + // Only some of the delimsizing functions act as fences, and they + // return "mopen" or "mclose" mclass. + node.setAttribute("fence", "true"); + } else { + // Explicitly disable fencing if it's not a fence, to override the + // defaults. + node.setAttribute("fence", "false"); + } + + node.setAttribute("stretchy", "true"); + var size = makeEm(delimiter$1.sizeToMaxHeight[group.size]); + node.setAttribute("minsize", size); + node.setAttribute("maxsize", size); + return node; + } +}); + +function assertParsed(group) { + if (!group.body) { + throw new Error("Bug: The leftright ParseNode wasn't fully parsed."); + } +} + +defineFunction({ + type: "leftright-right", + names: ["\\right"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + // \left case below triggers parsing of \right in + // `const right = parser.parseFunction();` + // uses this return value. + var color = context.parser.gullet.macros.get("\\current@color"); + + if (color && typeof color !== "string") { + throw new ParseError("\\current@color set to non-string in \\right"); + } + + return { + type: "leftright-right", + mode: context.parser.mode, + delim: checkDelimiter(args[0], context).text, + color // undefined if not set via \color + + }; + } +}); +defineFunction({ + type: "leftright", + names: ["\\left"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + var parser = context.parser; // Parse out the implicit body + + ++parser.leftrightDepth; // parseExpression stops before '\\right' + + var body = parser.parseExpression(false); + --parser.leftrightDepth; // Check the next token + + parser.expect("\\right", false); + var right = assertNodeType(parser.parseFunction(), "leftright-right"); + return { + type: "leftright", + mode: parser.mode, + body, + left: delim.text, + right: right.delim, + rightColor: right.color + }; + }, + htmlBuilder: (group, options) => { + assertParsed(group); // Build the inner expression + + var inner = buildExpression$1(group.body, options, true, ["mopen", "mclose"]); + var innerHeight = 0; + var innerDepth = 0; + var hadMiddle = false; // Calculate its height and depth + + for (var i = 0; i < inner.length; i++) { + // Property `isMiddle` not defined on `span`. See comment in + // "middle"'s htmlBuilder. + // $FlowFixMe + if (inner[i].isMiddle) { + hadMiddle = true; + } else { + innerHeight = Math.max(inner[i].height, innerHeight); + innerDepth = Math.max(inner[i].depth, innerDepth); + } + } // The size of delimiters is the same, regardless of what style we are + // in. Thus, to correctly calculate the size of delimiter we need around + // a group, we scale down the inner size based on the size. + + + innerHeight *= options.sizeMultiplier; + innerDepth *= options.sizeMultiplier; + var leftDelim; + + if (group.left === ".") { + // Empty delimiters in \left and \right make null delimiter spaces. + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + // Otherwise, use leftRightDelim to generate the correct sized + // delimiter. + leftDelim = delimiter$1.leftRightDelim(group.left, innerHeight, innerDepth, options, group.mode, ["mopen"]); + } // Add it to the beginning of the expression + + + inner.unshift(leftDelim); // Handle middle delimiters + + if (hadMiddle) { + for (var _i = 1; _i < inner.length; _i++) { + var middleDelim = inner[_i]; // Property `isMiddle` not defined on `span`. See comment in + // "middle"'s htmlBuilder. + // $FlowFixMe + + var isMiddle = middleDelim.isMiddle; + + if (isMiddle) { + // Apply the options that were active when \middle was called + inner[_i] = delimiter$1.leftRightDelim(isMiddle.delim, innerHeight, innerDepth, isMiddle.options, group.mode, []); + } + } + } + + var rightDelim; // Same for the right delimiter, but using color specified by \color + + if (group.right === ".") { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + var colorOptions = group.rightColor ? options.withColor(group.rightColor) : options; + rightDelim = delimiter$1.leftRightDelim(group.right, innerHeight, innerDepth, colorOptions, group.mode, ["mclose"]); + } // Add it to the end of the expression. + + + inner.push(rightDelim); + return buildCommon.makeSpan(["minner"], inner, options); + }, + mathmlBuilder: (group, options) => { + assertParsed(group); + var inner = buildExpression(group.body, options); + + if (group.left !== ".") { + var leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]); + leftNode.setAttribute("fence", "true"); + inner.unshift(leftNode); + } + + if (group.right !== ".") { + var rightNode = new mathMLTree.MathNode("mo", [makeText(group.right, group.mode)]); + rightNode.setAttribute("fence", "true"); + + if (group.rightColor) { + rightNode.setAttribute("mathcolor", group.rightColor); + } + + inner.push(rightNode); + } + + return makeRow(inner); + } +}); +defineFunction({ + type: "middle", + names: ["\\middle"], + props: { + numArgs: 1, + primitive: true + }, + handler: (context, args) => { + var delim = checkDelimiter(args[0], context); + + if (!context.parser.leftrightDepth) { + throw new ParseError("\\middle without preceding \\left", delim); + } + + return { + type: "middle", + mode: context.parser.mode, + delim: delim.text + }; + }, + htmlBuilder: (group, options) => { + var middleDelim; + + if (group.delim === ".") { + middleDelim = makeNullDelimiter(options, []); + } else { + middleDelim = delimiter$1.sizedDelim(group.delim, 1, options, group.mode, []); + var isMiddle = { + delim: group.delim, + options + }; // Property `isMiddle` not defined on `span`. It is only used in + // this file above. + // TODO: Fix this violation of the `span` type and possibly rename + // things since `isMiddle` sounds like a boolean, but is a struct. + // $FlowFixMe + + middleDelim.isMiddle = isMiddle; + } + + return middleDelim; + }, + mathmlBuilder: (group, options) => { + // A Firefox \middle will stretch a character vertically only if it + // is in the fence part of the operator dictionary at: + // https://www.w3.org/TR/MathML3/appendixc.html. + // So we need to avoid U+2223 and use plain "|" instead. + var textNode = group.delim === "\\vert" || group.delim === "|" ? makeText("|", "text") : makeText(group.delim, group.mode); + var middleNode = new mathMLTree.MathNode("mo", [textNode]); + middleNode.setAttribute("fence", "true"); // MathML gives 5/18em spacing to each element. + // \middle should get delimiter spacing instead. + + middleNode.setAttribute("lspace", "0.05em"); + middleNode.setAttribute("rspace", "0.05em"); + return middleNode; + } +}); + +var htmlBuilder$7 = (group, options) => { + // \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase + // Some groups can return document fragments. Handle those by wrapping + // them in a span. + var inner = buildCommon.wrapFragment(buildGroup$1(group.body, options), options); + var label = group.label.slice(1); + var scale = options.sizeMultiplier; + var img; + var imgShift = 0; // In the LaTeX cancel package, line geometry is slightly different + // depending on whether the subject is wider than it is tall, or vice versa. + // We don't know the width of a group, so as a proxy, we test if + // the subject is a single character. This captures most of the + // subjects that should get the "tall" treatment. + + var isSingleChar = utils$1.isCharacterBox(group.body); + + if (label === "sout") { + img = buildCommon.makeSpan(["stretchy", "sout"]); + img.height = options.fontMetrics().defaultRuleThickness / scale; + imgShift = -0.5 * options.fontMetrics().xHeight; + } else if (label === "phase") { + // Set a couple of dimensions from the steinmetz package. + var lineWeight = calculateSize({ + number: 0.6, + unit: "pt" + }, options); + var clearance = calculateSize({ + number: 0.35, + unit: "ex" + }, options); // Prevent size changes like \Huge from affecting line thickness + + var newOptions = options.havingBaseSizing(); + scale = scale / newOptions.sizeMultiplier; + var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle. + + inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG + + var viewBoxHeight = Math.floor(1000 * angleHeight * scale); + var path = phasePath(viewBoxHeight); + var svgNode = new SvgNode([new PathNode("phase", path)], { + "width": "400em", + "height": makeEm(viewBoxHeight / 1000), + "viewBox": "0 0 400000 " + viewBoxHeight, + "preserveAspectRatio": "xMinYMin slice" + }); // Wrap it in a span with overflow: hidden. + + img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options); + img.style.height = makeEm(angleHeight); + imgShift = inner.depth + lineWeight + clearance; + } else { + // Add horizontal padding + if (/cancel/.test(label)) { + if (!isSingleChar) { + inner.classes.push("cancel-pad"); + } + } else if (label === "angl") { + inner.classes.push("anglpad"); + } else { + inner.classes.push("boxpad"); + } // Add vertical padding + + + var topPad = 0; + var bottomPad = 0; + var ruleThickness = 0; // ref: cancel package: \advance\totalheight2\p@ % "+2" + + if (/box/.test(label)) { + ruleThickness = Math.max(options.fontMetrics().fboxrule, // default + options.minRuleThickness // User override. + ); + topPad = options.fontMetrics().fboxsep + (label === "colorbox" ? 0 : ruleThickness); + bottomPad = topPad; + } else if (label === "angl") { + ruleThickness = Math.max(options.fontMetrics().defaultRuleThickness, options.minRuleThickness); + topPad = 4 * ruleThickness; // gap = 3 × line, plus the line itself. + + bottomPad = Math.max(0, 0.25 - inner.depth); + } else { + topPad = isSingleChar ? 0.2 : 0; + bottomPad = topPad; + } + + img = stretchy.encloseSpan(inner, label, topPad, bottomPad, options); + + if (/fbox|boxed|fcolorbox/.test(label)) { + img.style.borderStyle = "solid"; + img.style.borderWidth = makeEm(ruleThickness); + } else if (label === "angl" && ruleThickness !== 0.049) { + img.style.borderTopWidth = makeEm(ruleThickness); + img.style.borderRightWidth = makeEm(ruleThickness); + } + + imgShift = inner.depth + bottomPad; + + if (group.backgroundColor) { + img.style.backgroundColor = group.backgroundColor; + + if (group.borderColor) { + img.style.borderColor = group.borderColor; + } + } + } + + var vlist; + + if (group.backgroundColor) { + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [// Put the color background behind inner; + { + type: "elem", + elem: img, + shift: imgShift + }, { + type: "elem", + elem: inner, + shift: 0 + }] + }, options); + } else { + var classes = /cancel|phase/.test(label) ? ["svg-align"] : []; + vlist = buildCommon.makeVList({ + positionType: "individualShift", + children: [// Write the \cancel stroke on top of inner. + { + type: "elem", + elem: inner, + shift: 0 + }, { + type: "elem", + elem: img, + shift: imgShift, + wrapperClasses: classes + }] + }, options); + } + + if (/cancel/.test(label)) { + // The cancel package documentation says that cancel lines add their height + // to the expression, but tests show that isn't how it actually works. + vlist.height = inner.height; + vlist.depth = inner.depth; + } + + if (/cancel/.test(label) && !isSingleChar) { + // cancel does not create horiz space for its line extension. + return buildCommon.makeSpan(["mord", "cancel-lap"], [vlist], options); + } else { + return buildCommon.makeSpan(["mord"], [vlist], options); + } +}; + +var mathmlBuilder$6 = (group, options) => { + var fboxsep = 0; + var node = new mathMLTree.MathNode(group.label.indexOf("colorbox") > -1 ? "mpadded" : "menclose", [buildGroup(group.body, options)]); + + switch (group.label) { + case "\\cancel": + node.setAttribute("notation", "updiagonalstrike"); + break; + + case "\\bcancel": + node.setAttribute("notation", "downdiagonalstrike"); + break; + + case "\\phase": + node.setAttribute("notation", "phasorangle"); + break; + + case "\\sout": + node.setAttribute("notation", "horizontalstrike"); + break; + + case "\\fbox": + node.setAttribute("notation", "box"); + break; + + case "\\angl": + node.setAttribute("notation", "actuarial"); + break; + + case "\\fcolorbox": + case "\\colorbox": + // doesn't have a good notation option. So use + // instead. Set some attributes that come included with . + fboxsep = options.fontMetrics().fboxsep * options.fontMetrics().ptPerEm; + node.setAttribute("width", "+" + 2 * fboxsep + "pt"); + node.setAttribute("height", "+" + 2 * fboxsep + "pt"); + node.setAttribute("lspace", fboxsep + "pt"); // + + node.setAttribute("voffset", fboxsep + "pt"); + + if (group.label === "\\fcolorbox") { + var thk = Math.max(options.fontMetrics().fboxrule, // default + options.minRuleThickness // user override + ); + node.setAttribute("style", "border: " + thk + "em solid " + String(group.borderColor)); + } + + break; + + case "\\xcancel": + node.setAttribute("notation", "updiagonalstrike downdiagonalstrike"); + break; + } + + if (group.backgroundColor) { + node.setAttribute("mathbackground", group.backgroundColor); + } + + return node; +}; + +defineFunction({ + type: "enclose", + names: ["\\colorbox"], + props: { + numArgs: 2, + allowedInText: true, + argTypes: ["color", "text"] + }, + + handler(_ref, args, optArgs) { + var { + parser, + funcName + } = _ref; + var color = assertNodeType(args[0], "color-token").color; + var body = args[1]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor: color, + body + }; + }, + + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fcolorbox"], + props: { + numArgs: 3, + allowedInText: true, + argTypes: ["color", "color", "text"] + }, + + handler(_ref2, args, optArgs) { + var { + parser, + funcName + } = _ref2; + var borderColor = assertNodeType(args[0], "color-token").color; + var backgroundColor = assertNodeType(args[1], "color-token").color; + var body = args[2]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + backgroundColor, + borderColor, + body + }; + }, + + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\fbox"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: true + }, + + handler(_ref3, args) { + var { + parser + } = _ref3; + return { + type: "enclose", + mode: parser.mode, + label: "\\fbox", + body: args[0] + }; + } + +}); +defineFunction({ + type: "enclose", + names: ["\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\phase"], + props: { + numArgs: 1 + }, + + handler(_ref4, args) { + var { + parser, + funcName + } = _ref4; + var body = args[0]; + return { + type: "enclose", + mode: parser.mode, + label: funcName, + body + }; + }, + + htmlBuilder: htmlBuilder$7, + mathmlBuilder: mathmlBuilder$6 +}); +defineFunction({ + type: "enclose", + names: ["\\angl"], + props: { + numArgs: 1, + argTypes: ["hbox"], + allowedInText: false + }, + + handler(_ref5, args) { + var { + parser + } = _ref5; + return { + type: "enclose", + mode: parser.mode, + label: "\\angl", + body: args[0] + }; + } + +}); + +/** + * All registered environments. + * `environments.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `environments.js`. + */ +var _environments = {}; +function defineEnvironment(_ref) { + var { + type, + names, + props, + handler, + htmlBuilder, + mathmlBuilder + } = _ref; + // Set default values of environments. + var data = { + type, + numArgs: props.numArgs || 0, + allowedInText: false, + numOptionalArgs: 0, + handler + }; + + for (var i = 0; i < names.length; ++i) { + // TODO: The value type of _environments should be a type union of all + // possible `EnvSpec<>` possibilities instead of `EnvSpec<*>`, which is + // an existential type. + _environments[names[i]] = data; + } + + if (htmlBuilder) { + _htmlGroupBuilders[type] = htmlBuilder; + } + + if (mathmlBuilder) { + _mathmlGroupBuilders[type] = mathmlBuilder; + } +} + +/** + * All registered global/built-in macros. + * `macros.js` exports this same dictionary again and makes it public. + * `Parser.js` requires this dictionary via `macros.js`. + */ +var _macros = {}; // This function might one day accept an additional argument and do more things. + +function defineMacro(name, body) { + _macros[name] = body; +} + +// Helper functions +function getHLines(parser) { + // Return an array. The array length = number of hlines. + // Each element in the array tells if the line is dashed. + var hlineInfo = []; + parser.consumeSpaces(); + var nxt = parser.fetch().text; + + if (nxt === "\\relax") { + // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + + while (nxt === "\\hline" || nxt === "\\hdashline") { + parser.consume(); + hlineInfo.push(nxt === "\\hdashline"); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } + + return hlineInfo; +} + +var validateAmsEnvironmentContext = context => { + var settings = context.parser.settings; + + if (!settings.displayMode) { + throw new ParseError("{" + context.envName + "} can be used only in" + " display mode."); + } +}; // autoTag (an argument to parseArray) can be one of three values: +// * undefined: Regular (not-top-level) array; no tags on each row +// * true: Automatic equation numbering, overridable by \tag +// * false: Tags allowed on each row, but no automatic numbering +// This function *doesn't* work with the "split" environment name. + + +function getAutoTag(name) { + if (name.indexOf("ed") === -1) { + return name.indexOf("*") === -1; + } // return undefined; + +} +/** + * Parse the body of the environment, with rows delimited by \\ and + * columns delimited by &, and create a nested list in row-major order + * with one group per cell. If given an optional argument style + * ("text", "display", etc.), then each cell is cast into that style. + */ + + +function parseArray(parser, _ref, style) { + var { + hskipBeforeAndAfter, + addJot, + cols, + arraystretch, + colSeparationType, + autoTag, + singleRow, + emptySingleRow, + maxNumCols, + leqno + } = _ref; + parser.gullet.beginGroup(); + + if (!singleRow) { + // \cr is equivalent to \\ without the optional size argument (see below) + // TODO: provide helpful error when \cr is used outside array environment + parser.gullet.macros.set("\\cr", "\\\\\\relax"); + } // Get current arraystretch if it's not set by the environment + + + if (!arraystretch) { + var stretch = parser.gullet.expandMacroAsText("\\arraystretch"); + + if (stretch == null) { + // Default \arraystretch from lttab.dtx + arraystretch = 1; + } else { + arraystretch = parseFloat(stretch); + + if (!arraystretch || arraystretch < 0) { + throw new ParseError("Invalid \\arraystretch: " + stretch); + } + } + } // Start group for first cell + + + parser.gullet.beginGroup(); + var row = []; + var body = [row]; + var rowGaps = []; + var hLinesBeforeRow = []; + var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent + // whether this row should have an equation number. Simulate this with + // a \@eqnsw macro set to 1 or 0. + + function beginRow() { + if (autoTag) { + parser.gullet.macros.set("\\@eqnsw", "1", true); + } + } + + function endRow() { + if (tags) { + if (parser.gullet.macros.get("\\df@tag")) { + tags.push(parser.subparse([new Token("\\df@tag")])); + parser.gullet.macros.set("\\df@tag", undefined, true); + } else { + tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1"); + } + } + } + + beginRow(); // Test for \hline at the top of the array. + + hLinesBeforeRow.push(getHLines(parser)); + + while (true) { + // eslint-disable-line no-constant-condition + // Parse each cell in its own group (namespace) + var cell = parser.parseExpression(false, singleRow ? "\\end" : "\\\\"); + parser.gullet.endGroup(); + parser.gullet.beginGroup(); + cell = { + type: "ordgroup", + mode: parser.mode, + body: cell + }; + + if (style) { + cell = { + type: "styling", + mode: parser.mode, + style, + body: [cell] + }; + } + + row.push(cell); + var next = parser.fetch().text; + + if (next === "&") { + if (maxNumCols && row.length === maxNumCols) { + if (singleRow || colSeparationType) { + // {equation} or {split} + throw new ParseError("Too many tab characters: &", parser.nextToken); + } else { + // {array} environment + parser.settings.reportNonstrict("textEnv", "Too few columns " + "specified in the {array} column argument."); + } + } + + parser.consume(); + } else if (next === "\\end") { + endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if + // the last line is empty. However, AMS environments keep the + // empty row if it's the only one. + // NOTE: Currently, `cell` is the last item added into `row`. + + if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) { + body.pop(); + } + + if (hLinesBeforeRow.length < body.length + 1) { + hLinesBeforeRow.push([]); + } + + break; + } else if (next === "\\\\") { + parser.consume(); + var size = void 0; // \def\Let@{\let\\\math@cr} + // \def\math@cr{...\math@cr@} + // \def\math@cr@{\new@ifnextchar[\math@cr@@{\math@cr@@[\z@]}} + // \def\math@cr@@[#1]{...\math@cr@@@...} + // \def\math@cr@@@{\cr} + + if (parser.gullet.future().text !== " ") { + size = parser.parseSizeGroup(true); + } + + rowGaps.push(size ? size.value : null); + endRow(); // check for \hline(s) following the row separator + + hLinesBeforeRow.push(getHLines(parser)); + row = []; + body.push(row); + beginRow(); + } else { + throw new ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken); + } + } // End cell group + + + parser.gullet.endGroup(); // End array group defining \cr + + parser.gullet.endGroup(); + return { + type: "array", + mode: parser.mode, + addJot, + arraystretch, + body, + cols, + rowGaps, + hskipBeforeAndAfter, + hLinesBeforeRow, + colSeparationType, + tags, + leqno + }; +} // Decides on a style for cells in an array according to whether the given +// environment name starts with the letter 'd'. + + +function dCellStyle(envName) { + if (envName.slice(0, 1) === "d") { + return "display"; + } else { + return "text"; + } +} + +var htmlBuilder$6 = function htmlBuilder(group, options) { + var r; + var c; + var nr = group.body.length; + var hLinesBeforeRow = group.hLinesBeforeRow; + var nc = 0; + var body = new Array(nr); + var hlines = []; + var ruleThickness = Math.max( // From LaTeX \showthe\arrayrulewidth. Equals 0.04 em. + options.fontMetrics().arrayRuleWidth, options.minRuleThickness // User override. + ); // Horizontal spacing + + var pt = 1 / options.fontMetrics().ptPerEm; + var arraycolsep = 5 * pt; // default value, i.e. \arraycolsep in article.cls + + if (group.colSeparationType && group.colSeparationType === "small") { + // We're in a {smallmatrix}. Default column space is \thickspace, + // i.e. 5/18em = 0.2778em, per amsmath.dtx for {smallmatrix}. + // But that needs adjustment because LaTeX applies \scriptstyle to the + // entire array, including the colspace, but this function applies + // \scriptstyle only inside each element. + var localMultiplier = options.havingStyle(Style$1$1.SCRIPT).sizeMultiplier; + arraycolsep = 0.2778 * (localMultiplier / options.sizeMultiplier); + } // Vertical spacing + + + var baselineskip = group.colSeparationType === "CD" ? calculateSize({ + number: 3, + unit: "ex" + }, options) : 12 * pt; // see size10.clo + // Default \jot from ltmath.dtx + // TODO(edemaine): allow overriding \jot via \setlength (#687) + + var jot = 3 * pt; + var arrayskip = group.arraystretch * baselineskip; + var arstrutHeight = 0.7 * arrayskip; // \strutbox in ltfsstrc.dtx and + + var arstrutDepth = 0.3 * arrayskip; // \@arstrutbox in lttab.dtx + + var totalHeight = 0; // Set a position for \hline(s) at the top of the array, if any. + + function setHLinePos(hlinesInGap) { + for (var i = 0; i < hlinesInGap.length; ++i) { + if (i > 0) { + totalHeight += 0.25; + } + + hlines.push({ + pos: totalHeight, + isDashed: hlinesInGap[i] + }); + } + } + + setHLinePos(hLinesBeforeRow[0]); + + for (r = 0; r < group.body.length; ++r) { + var inrow = group.body[r]; + var height = arstrutHeight; // \@array adds an \@arstrut + + var depth = arstrutDepth; // to each tow (via the template) + + if (nc < inrow.length) { + nc = inrow.length; + } + + var outrow = new Array(inrow.length); + + for (c = 0; c < inrow.length; ++c) { + var elt = buildGroup$1(inrow[c], options); + + if (depth < elt.depth) { + depth = elt.depth; + } + + if (height < elt.height) { + height = elt.height; + } + + outrow[c] = elt; + } + + var rowGap = group.rowGaps[r]; + var gap = 0; + + if (rowGap) { + gap = calculateSize(rowGap, options); + + if (gap > 0) { + // \@argarraycr + gap += arstrutDepth; + + if (depth < gap) { + depth = gap; // \@xargarraycr + } + + gap = 0; + } + } // In AMS multiline environments such as aligned and gathered, rows + // correspond to lines that have additional \jot added to the + // \baselineskip via \openup. + + + if (group.addJot) { + depth += jot; + } + + outrow.height = height; + outrow.depth = depth; + totalHeight += height; + outrow.pos = totalHeight; + totalHeight += depth + gap; // \@yargarraycr + + body[r] = outrow; // Set a position for \hline(s), if any. + + setHLinePos(hLinesBeforeRow[r + 1]); + } + + var offset = totalHeight / 2 + options.fontMetrics().axisHeight; + var colDescriptions = group.cols || []; + var cols = []; + var colSep; + var colDescrNum; + var tagSpans = []; + + if (group.tags && group.tags.some(tag => tag)) { + // An environment with manual tags and/or automatic equation numbers. + // Create node(s), the latter of which trigger CSS counter increment. + for (r = 0; r < nr; ++r) { + var rw = body[r]; + var shift = rw.pos - offset; + var tag = group.tags[r]; + var tagSpan = void 0; + + if (tag === true) { + // automatic numbering + tagSpan = buildCommon.makeSpan(["eqn-num"], [], options); + } else if (tag === false) { + // \nonumber/\notag or starred environment + tagSpan = buildCommon.makeSpan([], [], options); + } else { + // manual \tag + tagSpan = buildCommon.makeSpan([], buildExpression$1(tag, options, true), options); + } + + tagSpan.depth = rw.depth; + tagSpan.height = rw.height; + tagSpans.push({ + type: "elem", + elem: tagSpan, + shift + }); + } + } + + for (c = 0, colDescrNum = 0; // Continue while either there are more columns or more column + // descriptions, so trailing separators don't get lost. + c < nc || colDescrNum < colDescriptions.length; ++c, ++colDescrNum) { + var colDescr = colDescriptions[colDescrNum] || {}; + var firstSeparator = true; + + while (colDescr.type === "separator") { + // If there is more than one separator in a row, add a space + // between them. + if (!firstSeparator) { + colSep = buildCommon.makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep); + cols.push(colSep); + } + + if (colDescr.separator === "|" || colDescr.separator === ":") { + var lineType = colDescr.separator === "|" ? "solid" : "dashed"; + var separator = buildCommon.makeSpan(["vertical-separator"], [], options); + separator.style.height = makeEm(totalHeight); + separator.style.borderRightWidth = makeEm(ruleThickness); + separator.style.borderRightStyle = lineType; + separator.style.margin = "0 " + makeEm(-ruleThickness / 2); + + var _shift = totalHeight - offset; + + if (_shift) { + separator.style.verticalAlign = makeEm(-_shift); + } + + cols.push(separator); + } else { + throw new ParseError("Invalid separator type: " + colDescr.separator); + } + + colDescrNum++; + colDescr = colDescriptions[colDescrNum] || {}; + firstSeparator = false; + } + + if (c >= nc) { + continue; + } + + var sepwidth = void 0; + + if (c > 0 || group.hskipBeforeAndAfter) { + sepwidth = utils$1.deflt(colDescr.pregap, arraycolsep); + + if (sepwidth !== 0) { + colSep = buildCommon.makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + + var col = []; + + for (r = 0; r < nr; ++r) { + var row = body[r]; + var elem = row[c]; + + if (!elem) { + continue; + } + + var _shift2 = row.pos - offset; + + elem.depth = row.depth; + elem.height = row.height; + col.push({ + type: "elem", + elem: elem, + shift: _shift2 + }); + } + + col = buildCommon.makeVList({ + positionType: "individualShift", + children: col + }, options); + col = buildCommon.makeSpan(["col-align-" + (colDescr.align || "c")], [col]); + cols.push(col); + + if (c < nc - 1 || group.hskipBeforeAndAfter) { + sepwidth = utils$1.deflt(colDescr.postgap, arraycolsep); + + if (sepwidth !== 0) { + colSep = buildCommon.makeSpan(["arraycolsep"], []); + colSep.style.width = makeEm(sepwidth); + cols.push(colSep); + } + } + } + + body = buildCommon.makeSpan(["mtable"], cols); // Add \hline(s), if any. + + if (hlines.length > 0) { + var line = buildCommon.makeLineSpan("hline", options, ruleThickness); + var dashes = buildCommon.makeLineSpan("hdashline", options, ruleThickness); + var vListElems = [{ + type: "elem", + elem: body, + shift: 0 + }]; + + while (hlines.length > 0) { + var hline = hlines.pop(); + var lineShift = hline.pos - offset; + + if (hline.isDashed) { + vListElems.push({ + type: "elem", + elem: dashes, + shift: lineShift + }); + } else { + vListElems.push({ + type: "elem", + elem: line, + shift: lineShift + }); + } + } + + body = buildCommon.makeVList({ + positionType: "individualShift", + children: vListElems + }, options); + } + + if (tagSpans.length === 0) { + return buildCommon.makeSpan(["mord"], [body], options); + } else { + var eqnNumCol = buildCommon.makeVList({ + positionType: "individualShift", + children: tagSpans + }, options); + eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options); + return buildCommon.makeFragment([body, eqnNumCol]); + } +}; + +var alignMap = { + c: "center ", + l: "left ", + r: "right " +}; + +var mathmlBuilder$5 = function mathmlBuilder(group, options) { + var tbl = []; + var glue = new mathMLTree.MathNode("mtd", [], ["mtr-glue"]); + var tag = new mathMLTree.MathNode("mtd", [], ["mml-eqn-num"]); + + for (var i = 0; i < group.body.length; i++) { + var rw = group.body[i]; + var row = []; + + for (var j = 0; j < rw.length; j++) { + row.push(new mathMLTree.MathNode("mtd", [buildGroup(rw[j], options)])); + } + + if (group.tags && group.tags[i]) { + row.unshift(glue); + row.push(glue); + + if (group.leqno) { + row.unshift(tag); + } else { + row.push(tag); + } + } + + tbl.push(new mathMLTree.MathNode("mtr", row)); + } + + var table = new mathMLTree.MathNode("mtable", tbl); // Set column alignment, row spacing, column spacing, and + // array lines by setting attributes on the table element. + // Set the row spacing. In MathML, we specify a gap distance. + // We do not use rowGap[] because MathML automatically increases + // cell height with the height/depth of the element content. + // LaTeX \arraystretch multiplies the row baseline-to-baseline distance. + // We simulate this by adding (arraystretch - 1)em to the gap. This + // does a reasonable job of adjusting arrays containing 1 em tall content. + // The 0.16 and 0.09 values are found empirically. They produce an array + // similar to LaTeX and in which content does not interfere with \hlines. + + var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray} + : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0); + table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells. + // To place a line on an edge we'll use , if necessary. + + var menclose = ""; + var align = ""; + + if (group.cols && group.cols.length > 0) { + // Find column alignment, column spacing, and vertical lines. + var cols = group.cols; + var columnLines = ""; + var prevTypeWasAlign = false; + var iStart = 0; + var iEnd = cols.length; + + if (cols[0].type === "separator") { + menclose += "top "; + iStart = 1; + } + + if (cols[cols.length - 1].type === "separator") { + menclose += "bottom "; + iEnd -= 1; + } + + for (var _i = iStart; _i < iEnd; _i++) { + if (cols[_i].type === "align") { + align += alignMap[cols[_i].align]; + + if (prevTypeWasAlign) { + columnLines += "none "; + } + + prevTypeWasAlign = true; + } else if (cols[_i].type === "separator") { + // MathML accepts only single lines between cells. + // So we read only the first of consecutive separators. + if (prevTypeWasAlign) { + columnLines += cols[_i].separator === "|" ? "solid " : "dashed "; + prevTypeWasAlign = false; + } + } + } + + table.setAttribute("columnalign", align.trim()); + + if (/[sd]/.test(columnLines)) { + table.setAttribute("columnlines", columnLines.trim()); + } + } // Set column spacing. + + + if (group.colSeparationType === "align") { + var _cols = group.cols || []; + + var spacing = ""; + + for (var _i2 = 1; _i2 < _cols.length; _i2++) { + spacing += _i2 % 2 ? "0em " : "1em "; + } + + table.setAttribute("columnspacing", spacing.trim()); + } else if (group.colSeparationType === "alignat" || group.colSeparationType === "gather") { + table.setAttribute("columnspacing", "0em"); + } else if (group.colSeparationType === "small") { + table.setAttribute("columnspacing", "0.2778em"); + } else if (group.colSeparationType === "CD") { + table.setAttribute("columnspacing", "0.5em"); + } else { + table.setAttribute("columnspacing", "1em"); + } // Address \hline and \hdashline + + + var rowLines = ""; + var hlines = group.hLinesBeforeRow; + menclose += hlines[0].length > 0 ? "left " : ""; + menclose += hlines[hlines.length - 1].length > 0 ? "right " : ""; + + for (var _i3 = 1; _i3 < hlines.length - 1; _i3++) { + rowLines += hlines[_i3].length === 0 ? "none " // MathML accepts only a single line between rows. Read one element. + : hlines[_i3][0] ? "dashed " : "solid "; + } + + if (/[sd]/.test(rowLines)) { + table.setAttribute("rowlines", rowLines.trim()); + } + + if (menclose !== "") { + table = new mathMLTree.MathNode("menclose", [table]); + table.setAttribute("notation", menclose.trim()); + } + + if (group.arraystretch && group.arraystretch < 1) { + // A small array. Wrap in scriptstyle so row gap is not too large. + table = new mathMLTree.MathNode("mstyle", [table]); + table.setAttribute("scriptlevel", "1"); + } + + return table; +}; // Convenience function for align, align*, aligned, alignat, alignat*, alignedat. + + +var alignedHandler = function alignedHandler(context, args) { + if (context.envName.indexOf("ed") === -1) { + validateAmsEnvironmentContext(context); + } + + var cols = []; + var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align"; + var isSplit = context.envName === "split"; + var res = parseArray(context.parser, { + cols, + addJot: true, + autoTag: isSplit ? undefined : getAutoTag(context.envName), + emptySingleRow: true, + colSeparationType: separationType, + maxNumCols: isSplit ? 2 : undefined, + leqno: context.parser.settings.leqno + }, "display"); // Determining number of columns. + // 1. If the first argument is given, we use it as a number of columns, + // and makes sure that each row doesn't exceed that number. + // 2. Otherwise, just count number of columns = maximum number + // of cells in each row ("aligned" mode -- isAligned will be true). + // + // At the same time, prepend empty group {} at beginning of every second + // cell in each row (starting with second cell) so that operators become + // binary. This behavior is implemented in amsmath's \start@aligned. + + var numMaths; + var numCols = 0; + var emptyGroup = { + type: "ordgroup", + mode: context.mode, + body: [] + }; + + if (args[0] && args[0].type === "ordgroup") { + var arg0 = ""; + + for (var i = 0; i < args[0].body.length; i++) { + var textord = assertNodeType(args[0].body[i], "textord"); + arg0 += textord.text; + } + + numMaths = Number(arg0); + numCols = numMaths * 2; + } + + var isAligned = !numCols; + res.body.forEach(function (row) { + for (var _i4 = 1; _i4 < row.length; _i4 += 2) { + // Modify ordgroup node within styling node + var styling = assertNodeType(row[_i4], "styling"); + var ordgroup = assertNodeType(styling.body[0], "ordgroup"); + ordgroup.body.unshift(emptyGroup); + } + + if (!isAligned) { + // Case 1 + var curMaths = row.length / 2; + + if (numMaths < curMaths) { + throw new ParseError("Too many math in a row: " + ("expected " + numMaths + ", but got " + curMaths), row[0]); + } + } else if (numCols < row.length) { + // Case 2 + numCols = row.length; + } + }); // Adjusting alignment. + // In aligned mode, we add one \qquad between columns; + // otherwise we add nothing. + + for (var _i5 = 0; _i5 < numCols; ++_i5) { + var align = "r"; + var pregap = 0; + + if (_i5 % 2 === 1) { + align = "l"; + } else if (_i5 > 0 && isAligned) { + // "aligned" mode. + pregap = 1; // add one \quad + } + + cols[_i5] = { + type: "align", + align: align, + pregap: pregap, + postgap: 0 + }; + } + + res.colSeparationType = isAligned ? "align" : "alignat"; + return res; +}; // Arrays are part of LaTeX, defined in lttab.dtx so its documentation +// is part of the source2e.pdf file of LaTeX2e source documentation. +// {darray} is an {array} environment where cells are set in \displaystyle, +// as defined in nccmath.sty. + + +defineEnvironment({ + type: "array", + names: ["array", "darray"], + props: { + numArgs: 1 + }, + + handler(context, args) { + // Since no types are specified above, the two possibilities are + // - The argument is wrapped in {} or [], in which case Parser's + // parseGroup() returns an "ordgroup" wrapping some symbol node. + // - The argument is a bare symbol node. + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; + + if ("lcr".indexOf(ca) !== -1) { + return { + type: "align", + align: ca + }; + } else if (ca === "|") { + return { + type: "separator", + separator: "|" + }; + } else if (ca === ":") { + return { + type: "separator", + separator: ":" + }; + } + + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + var res = { + cols, + hskipBeforeAndAfter: true, + // \@preamble in lttab.dtx + maxNumCols: cols.length + }; + return parseArray(context.parser, res, dCellStyle(context.envName)); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // The matrix environments of amsmath builds on the array environment +// of LaTeX, which is discussed above. +// The mathtools package adds starred versions of the same environments. +// These have an optional argument to choose left|center|right justification. + +defineEnvironment({ + type: "array", + names: ["matrix", "pmatrix", "bmatrix", "Bmatrix", "vmatrix", "Vmatrix", "matrix*", "pmatrix*", "bmatrix*", "Bmatrix*", "vmatrix*", "Vmatrix*"], + props: { + numArgs: 0 + }, + + handler(context) { + var delimiters = { + "matrix": null, + "pmatrix": ["(", ")"], + "bmatrix": ["[", "]"], + "Bmatrix": ["\\{", "\\}"], + "vmatrix": ["|", "|"], + "Vmatrix": ["\\Vert", "\\Vert"] + }[context.envName.replace("*", "")]; // \hskip -\arraycolsep in amsmath + + var colAlign = "c"; + var payload = { + hskipBeforeAndAfter: false, + cols: [{ + type: "align", + align: colAlign + }] + }; + + if (context.envName.charAt(context.envName.length - 1) === "*") { + // It's one of the mathtools starred functions. + // Parse the optional alignment argument. + var parser = context.parser; + parser.consumeSpaces(); + + if (parser.fetch().text === "[") { + parser.consume(); + parser.consumeSpaces(); + colAlign = parser.fetch().text; + + if ("lcr".indexOf(colAlign) === -1) { + throw new ParseError("Expected l or c or r", parser.nextToken); + } + + parser.consume(); + parser.consumeSpaces(); + parser.expect("]"); + parser.consume(); + payload.cols = [{ + type: "align", + align: colAlign + }]; + } + } + + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); // Populate cols with the correct number of column alignment specs. + + var numCols = Math.max(0, ...res.body.map(row => row.length)); + res.cols = new Array(numCols).fill({ + type: "align", + align: colAlign + }); + return delimiters ? { + type: "leftright", + mode: context.mode, + body: [res], + left: delimiters[0], + right: delimiters[1], + rightColor: undefined // \right uninfluenced by \color in array + + } : res; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["smallmatrix"], + props: { + numArgs: 0 + }, + + handler(context) { + var payload = { + arraystretch: 0.5 + }; + var res = parseArray(context.parser, payload, "script"); + res.colSeparationType = "small"; + return res; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["subarray"], + props: { + numArgs: 1 + }, + + handler(context, args) { + // Parsing of {subarray} is similar to {array} + var symNode = checkSymbolNodeType(args[0]); + var colalign = symNode ? [args[0]] : assertNodeType(args[0], "ordgroup").body; + var cols = colalign.map(function (nde) { + var node = assertSymbolNodeType(nde); + var ca = node.text; // {subarray} only recognizes "l" & "c" + + if ("lc".indexOf(ca) !== -1) { + return { + type: "align", + align: ca + }; + } + + throw new ParseError("Unknown column alignment: " + ca, nde); + }); + + if (cols.length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + + var res = { + cols, + hskipBeforeAndAfter: false, + arraystretch: 0.5 + }; + res = parseArray(context.parser, res, "script"); + + if (res.body.length > 0 && res.body[0].length > 1) { + throw new ParseError("{subarray} can contain only one column"); + } + + return res; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // A cases environment (in amsmath.sty) is almost equivalent to +// \def\arraystretch{1.2}% +// \left\{\begin{array}{@{}l@{\quad}l@{}} … \end{array}\right. +// {dcases} is a {cases} environment where cells are set in \displaystyle, +// as defined in mathtools.sty. +// {rcases} is another mathtools environment. It's brace is on the right side. + +defineEnvironment({ + type: "array", + names: ["cases", "dcases", "rcases", "drcases"], + props: { + numArgs: 0 + }, + + handler(context) { + var payload = { + arraystretch: 1.2, + cols: [{ + type: "align", + align: "l", + pregap: 0, + // TODO(kevinb) get the current style. + // For now we use the metrics for TEXT style which is what we were + // doing before. Before attempting to get the current style we + // should look at TeX's behavior especially for \over and matrices. + postgap: 1.0 + /* 1em quad */ + + }, { + type: "align", + align: "l", + pregap: 0, + postgap: 0 + }] + }; + var res = parseArray(context.parser, payload, dCellStyle(context.envName)); + return { + type: "leftright", + mode: context.mode, + body: [res], + left: context.envName.indexOf("r") > -1 ? "." : "\\{", + right: context.envName.indexOf("r") > -1 ? "\\}" : ".", + rightColor: undefined + }; + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // In the align environment, one uses ampersands, &, to specify number of +// columns in each row, and to locate spacing between each column. +// align gets automatic numbering. align* and aligned do not. +// The alignedat environment can be used in math mode. +// Note that we assume \nomallineskiplimit to be zero, +// so that \strut@ is the same as \strut. + +defineEnvironment({ + type: "array", + names: ["align", "align*", "aligned", "split"], + props: { + numArgs: 0 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // A gathered environment is like an array environment with one centered +// column, but where rows are considered lines so get \jot line spacing +// and contents are set in \displaystyle. + +defineEnvironment({ + type: "array", + names: ["gathered", "gather", "gather*"], + props: { + numArgs: 0 + }, + + handler(context) { + if (utils$1.contains(["gather", "gather*"], context.envName)) { + validateAmsEnvironmentContext(context); + } + + var res = { + cols: [{ + type: "align", + align: "c" + }], + addJot: true, + colSeparationType: "gather", + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); // alignat environment is like an align environment, but one must explicitly +// specify maximum number of columns in each row, and can adjust spacing between +// each columns. + +defineEnvironment({ + type: "array", + names: ["alignat", "alignat*", "alignedat"], + props: { + numArgs: 1 + }, + handler: alignedHandler, + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["equation", "equation*"], + props: { + numArgs: 0 + }, + + handler(context) { + validateAmsEnvironmentContext(context); + var res = { + autoTag: getAutoTag(context.envName), + emptySingleRow: true, + singleRow: true, + maxNumCols: 1, + leqno: context.parser.settings.leqno + }; + return parseArray(context.parser, res, "display"); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineEnvironment({ + type: "array", + names: ["CD"], + props: { + numArgs: 0 + }, + + handler(context) { + validateAmsEnvironmentContext(context); + return parseCD(context.parser); + }, + + htmlBuilder: htmlBuilder$6, + mathmlBuilder: mathmlBuilder$5 +}); +defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}"); +defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment + +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\hline", "\\hdashline"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: true + }, + + handler(context, args) { + throw new ParseError(context.funcName + " valid only within array environment"); + } + +}); + +var environments = _environments; + +// defineEnvironment definitions. + +defineFunction({ + type: "environment", + names: ["\\begin", "\\end"], + props: { + numArgs: 1, + argTypes: ["text"] + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var nameGroup = args[0]; + + if (nameGroup.type !== "ordgroup") { + throw new ParseError("Invalid environment name", nameGroup); + } + + var envName = ""; + + for (var i = 0; i < nameGroup.body.length; ++i) { + envName += assertNodeType(nameGroup.body[i], "textord").text; + } + + if (funcName === "\\begin") { + // begin...end is similar to left...right + if (!environments.hasOwnProperty(envName)) { + throw new ParseError("No such environment: " + envName, nameGroup); + } // Build the environment object. Arguments and other information will + // be made available to the begin and end methods using properties. + + + var env = environments[envName]; + var { + args: _args, + optArgs + } = parser.parseArguments("\\begin{" + envName + "}", env); + var context = { + mode: parser.mode, + envName, + parser + }; + var result = env.handler(context, _args, optArgs); + parser.expect("\\end", false); + var endNameToken = parser.nextToken; + var end = assertNodeType(parser.parseFunction(), "environment"); + + if (end.name !== envName) { + throw new ParseError("Mismatch: \\begin{" + envName + "} matched by \\end{" + end.name + "}", endNameToken); + } // $FlowFixMe, "environment" handler returns an environment ParseNode + + + return result; + } + + return { + type: "environment", + mode: parser.mode, + name: envName, + nameGroup + }; + } + +}); + +// TODO(kevinb): implement \\sl and \\sc + +var htmlBuilder$5 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup$1(group.body, newOptions); +}; + +var mathmlBuilder$4 = (group, options) => { + var font = group.font; + var newOptions = options.withFont(font); + return buildGroup(group.body, newOptions); +}; + +var fontAliases = { + "\\Bbb": "\\mathbb", + "\\bold": "\\mathbf", + "\\frak": "\\mathfrak", + "\\bm": "\\boldsymbol" +}; +defineFunction({ + type: "font", + names: [// styles, except \boldsymbol defined below + "\\mathrm", "\\mathit", "\\mathbf", "\\mathnormal", // families + "\\mathbb", "\\mathcal", "\\mathfrak", "\\mathscr", "\\mathsf", "\\mathtt", // aliases, except \bm defined below + "\\Bbb", "\\bold", "\\frak"], + props: { + numArgs: 1, + allowedInArgument: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = normalizeArgument(args[0]); + var func = funcName; + + if (func in fontAliases) { + func = fontAliases[func]; + } + + return { + type: "font", + mode: parser.mode, + font: func.slice(1), + body + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); +defineFunction({ + type: "mclass", + names: ["\\boldsymbol", "\\bm"], + props: { + numArgs: 1 + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + var isCharacterBox = utils$1.isCharacterBox(body); // amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the + // argument's bin|rel|ord status + + return { + type: "mclass", + mode: parser.mode, + mclass: binrelClass(body), + body: [{ + type: "font", + mode: parser.mode, + font: "boldsymbol", + body + }], + isCharacterBox: isCharacterBox + }; + } +}); // Old font changing functions + +defineFunction({ + type: "font", + names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"], + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref3, args) => { + var { + parser, + funcName, + breakOnTokenText + } = _ref3; + var { + mode + } = parser; + var body = parser.parseExpression(true, breakOnTokenText); + var style = "math" + funcName.slice(1); + return { + type: "font", + mode: mode, + font: style, + body: { + type: "ordgroup", + mode: parser.mode, + body + } + }; + }, + htmlBuilder: htmlBuilder$5, + mathmlBuilder: mathmlBuilder$4 +}); + +var adjustStyle = (size, originalStyle) => { + // Figure out what style this fraction should be in based on the + // function used + var style = originalStyle; + + if (size === "display") { + // Get display style as a default. + // If incoming style is sub/sup, use style.text() to get correct size. + style = style.id >= Style$1$1.SCRIPT.id ? style.text() : Style$1$1.DISPLAY; + } else if (size === "text" && style.size === Style$1$1.DISPLAY.size) { + // We're in a \tfrac but incoming style is displaystyle, so: + style = Style$1$1.TEXT; + } else if (size === "script") { + style = Style$1$1.SCRIPT; + } else if (size === "scriptscript") { + style = Style$1$1.SCRIPTSCRIPT; + } + + return style; +}; + +var htmlBuilder$4 = (group, options) => { + // Fractions are handled in the TeXbook on pages 444-445, rules 15(a-e). + var style = adjustStyle(group.size, options.style); + var nstyle = style.fracNum(); + var dstyle = style.fracDen(); + var newOptions; + newOptions = options.havingStyle(nstyle); + var numerm = buildGroup$1(group.numer, newOptions, options); + + if (group.continued) { + // \cfrac inserts a \strut into the numerator. + // Get \strut dimensions from TeXbook page 353. + var hStrut = 8.5 / options.fontMetrics().ptPerEm; + var dStrut = 3.5 / options.fontMetrics().ptPerEm; + numerm.height = numerm.height < hStrut ? hStrut : numerm.height; + numerm.depth = numerm.depth < dStrut ? dStrut : numerm.depth; + } + + newOptions = options.havingStyle(dstyle); + var denomm = buildGroup$1(group.denom, newOptions, options); + var rule; + var ruleWidth; + var ruleSpacing; + + if (group.hasBarLine) { + if (group.barSize) { + ruleWidth = calculateSize(group.barSize, options); + rule = buildCommon.makeLineSpan("frac-line", options, ruleWidth); + } else { + rule = buildCommon.makeLineSpan("frac-line", options); + } + + ruleWidth = rule.height; + ruleSpacing = rule.height; + } else { + rule = null; + ruleWidth = 0; + ruleSpacing = options.fontMetrics().defaultRuleThickness; + } // Rule 15b + + + var numShift; + var clearance; + var denomShift; + + if (style.size === Style$1$1.DISPLAY.size || group.size === "display") { + numShift = options.fontMetrics().num1; + + if (ruleWidth > 0) { + clearance = 3 * ruleSpacing; + } else { + clearance = 7 * ruleSpacing; + } + + denomShift = options.fontMetrics().denom1; + } else { + if (ruleWidth > 0) { + numShift = options.fontMetrics().num2; + clearance = ruleSpacing; + } else { + numShift = options.fontMetrics().num3; + clearance = 3 * ruleSpacing; + } + + denomShift = options.fontMetrics().denom2; + } + + var frac; + + if (!rule) { + // Rule 15c + var candidateClearance = numShift - numerm.depth - (denomm.height - denomShift); + + if (candidateClearance < clearance) { + numShift += 0.5 * (clearance - candidateClearance); + denomShift += 0.5 * (clearance - candidateClearance); + } + + frac = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } else { + // Rule 15d + var axisHeight = options.fontMetrics().axisHeight; + + if (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth) < clearance) { + numShift += clearance - (numShift - numerm.depth - (axisHeight + 0.5 * ruleWidth)); + } + + if (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift) < clearance) { + denomShift += clearance - (axisHeight - 0.5 * ruleWidth - (denomm.height - denomShift)); + } + + var midShift = -(axisHeight - 0.5 * ruleWidth); + frac = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: denomm, + shift: denomShift + }, { + type: "elem", + elem: rule, + shift: midShift + }, { + type: "elem", + elem: numerm, + shift: -numShift + }] + }, options); + } // Since we manually change the style sometimes (with \dfrac or \tfrac), + // account for the possible size change here. + + + newOptions = options.havingStyle(style); + frac.height *= newOptions.sizeMultiplier / options.sizeMultiplier; + frac.depth *= newOptions.sizeMultiplier / options.sizeMultiplier; // Rule 15e + + var delimSize; + + if (style.size === Style$1$1.DISPLAY.size) { + delimSize = options.fontMetrics().delim1; + } else if (style.size === Style$1$1.SCRIPTSCRIPT.size) { + delimSize = options.havingStyle(Style$1$1.SCRIPT).fontMetrics().delim2; + } else { + delimSize = options.fontMetrics().delim2; + } + + var leftDelim; + var rightDelim; + + if (group.leftDelim == null) { + leftDelim = makeNullDelimiter(options, ["mopen"]); + } else { + leftDelim = delimiter$1.customSizedDelim(group.leftDelim, delimSize, true, options.havingStyle(style), group.mode, ["mopen"]); + } + + if (group.continued) { + rightDelim = buildCommon.makeSpan([]); // zero width for \cfrac + } else if (group.rightDelim == null) { + rightDelim = makeNullDelimiter(options, ["mclose"]); + } else { + rightDelim = delimiter$1.customSizedDelim(group.rightDelim, delimSize, true, options.havingStyle(style), group.mode, ["mclose"]); + } + + return buildCommon.makeSpan(["mord"].concat(newOptions.sizingClasses(options)), [leftDelim, buildCommon.makeSpan(["mfrac"], [frac]), rightDelim], options); +}; + +var mathmlBuilder$3 = (group, options) => { + var node = new mathMLTree.MathNode("mfrac", [buildGroup(group.numer, options), buildGroup(group.denom, options)]); + + if (!group.hasBarLine) { + node.setAttribute("linethickness", "0px"); + } else if (group.barSize) { + var ruleWidth = calculateSize(group.barSize, options); + node.setAttribute("linethickness", makeEm(ruleWidth)); + } + + var style = adjustStyle(group.size, options.style); + + if (style.size !== options.style.size) { + node = new mathMLTree.MathNode("mstyle", [node]); + var isDisplay = style.size === Style$1$1.DISPLAY.size ? "true" : "false"; + node.setAttribute("displaystyle", isDisplay); + node.setAttribute("scriptlevel", "0"); + } + + if (group.leftDelim != null || group.rightDelim != null) { + var withDelims = []; + + if (group.leftDelim != null) { + var leftOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.leftDelim.replace("\\", ""))]); + leftOp.setAttribute("fence", "true"); + withDelims.push(leftOp); + } + + withDelims.push(node); + + if (group.rightDelim != null) { + var rightOp = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode(group.rightDelim.replace("\\", ""))]); + rightOp.setAttribute("fence", "true"); + withDelims.push(rightOp); + } + + return makeRow(withDelims); + } + + return node; +}; + +defineFunction({ + type: "genfrac", + names: ["\\dfrac", "\\frac", "\\tfrac", "\\dbinom", "\\binom", "\\tbinom", "\\\\atopfrac", // can’t be entered directly + "\\\\bracefrac", "\\\\brackfrac" // ditto + ], + props: { + numArgs: 2, + allowedInArgument: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var numer = args[0]; + var denom = args[1]; + var hasBarLine; + var leftDelim = null; + var rightDelim = null; + var size = "auto"; + + switch (funcName) { + case "\\dfrac": + case "\\frac": + case "\\tfrac": + hasBarLine = true; + break; + + case "\\\\atopfrac": + hasBarLine = false; + break; + + case "\\dbinom": + case "\\binom": + case "\\tbinom": + hasBarLine = false; + leftDelim = "("; + rightDelim = ")"; + break; + + case "\\\\bracefrac": + hasBarLine = false; + leftDelim = "\\{"; + rightDelim = "\\}"; + break; + + case "\\\\brackfrac": + hasBarLine = false; + leftDelim = "["; + rightDelim = "]"; + break; + + default: + throw new Error("Unrecognized genfrac command"); + } + + switch (funcName) { + case "\\dfrac": + case "\\dbinom": + size = "display"; + break; + + case "\\tfrac": + case "\\tbinom": + size = "text"; + break; + } + + return { + type: "genfrac", + mode: parser.mode, + continued: false, + numer, + denom, + hasBarLine, + leftDelim, + rightDelim, + size, + barSize: null + }; + }, + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); +defineFunction({ + type: "genfrac", + names: ["\\cfrac"], + props: { + numArgs: 2 + }, + handler: (_ref2, args) => { + var { + parser, + funcName + } = _ref2; + var numer = args[0]; + var denom = args[1]; + return { + type: "genfrac", + mode: parser.mode, + continued: true, + numer, + denom, + hasBarLine: true, + leftDelim: null, + rightDelim: null, + size: "display", + barSize: null + }; + } +}); // Infix generalized fractions -- these are not rendered directly, but replaced +// immediately by one of the variants above. + +defineFunction({ + type: "infix", + names: ["\\over", "\\choose", "\\atop", "\\brace", "\\brack"], + props: { + numArgs: 0, + infix: true + }, + + handler(_ref3) { + var { + parser, + funcName, + token + } = _ref3; + var replaceWith; + + switch (funcName) { + case "\\over": + replaceWith = "\\frac"; + break; + + case "\\choose": + replaceWith = "\\binom"; + break; + + case "\\atop": + replaceWith = "\\\\atopfrac"; + break; + + case "\\brace": + replaceWith = "\\\\bracefrac"; + break; + + case "\\brack": + replaceWith = "\\\\brackfrac"; + break; + + default: + throw new Error("Unrecognized infix genfrac command"); + } + + return { + type: "infix", + mode: parser.mode, + replaceWith, + token + }; + } + +}); +var stylArray = ["display", "text", "script", "scriptscript"]; + +var delimFromValue = function delimFromValue(delimString) { + var delim = null; + + if (delimString.length > 0) { + delim = delimString; + delim = delim === "." ? null : delim; + } + + return delim; +}; + +defineFunction({ + type: "genfrac", + names: ["\\genfrac"], + props: { + numArgs: 6, + allowedInArgument: true, + argTypes: ["math", "math", "size", "text", "math", "math"] + }, + + handler(_ref4, args) { + var { + parser + } = _ref4; + var numer = args[4]; + var denom = args[5]; // Look into the parse nodes to get the desired delimiters. + + var leftNode = normalizeArgument(args[0]); + var leftDelim = leftNode.type === "atom" && leftNode.family === "open" ? delimFromValue(leftNode.text) : null; + var rightNode = normalizeArgument(args[1]); + var rightDelim = rightNode.type === "atom" && rightNode.family === "close" ? delimFromValue(rightNode.text) : null; + var barNode = assertNodeType(args[2], "size"); + var hasBarLine; + var barSize = null; + + if (barNode.isBlank) { + // \genfrac acts differently than \above. + // \genfrac treats an empty size group as a signal to use a + // standard bar size. \above would see size = 0 and omit the bar. + hasBarLine = true; + } else { + barSize = barNode.value; + hasBarLine = barSize.number > 0; + } // Find out if we want displaystyle, textstyle, etc. + + + var size = "auto"; + var styl = args[3]; + + if (styl.type === "ordgroup") { + if (styl.body.length > 0) { + var textOrd = assertNodeType(styl.body[0], "textord"); + size = stylArray[Number(textOrd.text)]; + } + } else { + styl = assertNodeType(styl, "textord"); + size = stylArray[Number(styl.text)]; + } + + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim, + rightDelim, + size + }; + }, + + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); // \above is an infix fraction that also defines a fraction bar size. + +defineFunction({ + type: "infix", + names: ["\\above"], + props: { + numArgs: 1, + argTypes: ["size"], + infix: true + }, + + handler(_ref5, args) { + var { + parser, + funcName, + token + } = _ref5; + return { + type: "infix", + mode: parser.mode, + replaceWith: "\\\\abovefrac", + size: assertNodeType(args[0], "size").value, + token + }; + } + +}); +defineFunction({ + type: "genfrac", + names: ["\\\\abovefrac"], + props: { + numArgs: 3, + argTypes: ["math", "size", "math"] + }, + handler: (_ref6, args) => { + var { + parser, + funcName + } = _ref6; + var numer = args[0]; + var barSize = assert(assertNodeType(args[1], "infix").size); + var denom = args[2]; + var hasBarLine = barSize.number > 0; + return { + type: "genfrac", + mode: parser.mode, + numer, + denom, + continued: false, + hasBarLine, + barSize, + leftDelim: null, + rightDelim: null, + size: "auto" + }; + }, + htmlBuilder: htmlBuilder$4, + mathmlBuilder: mathmlBuilder$3 +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only "horizBrace", but +// also "supsub" since an over/underbrace can affect super/subscripting. +var htmlBuilder$3 = (grp, options) => { + var style = options.style; // Pull out the `ParseNode<"horizBrace">` if `grp` is a "supsub" node. + + var supSubGroup; + var group; + + if (grp.type === "supsub") { + // Ref: LaTeX source2e: }}}}\limits} + // i.e. LaTeX treats the brace similar to an op and passes it + // with \limits, so we need to assign supsub style. + supSubGroup = grp.sup ? buildGroup$1(grp.sup, options.havingStyle(style.sup()), options) : buildGroup$1(grp.sub, options.havingStyle(style.sub()), options); + group = assertNodeType(grp.base, "horizBrace"); + } else { + group = assertNodeType(grp, "horizBrace"); + } // Build the base group + + + var body = buildGroup$1(group.base, options.havingBaseStyle(Style$1$1.DISPLAY)); // Create the stretchy element + + var braceBody = stretchy.svgSpan(group, options); // Generate the vlist, with the appropriate kerns ┏━━━━━━━━┓ + // This first vlist contains the content and the brace: equation + + var vlist; + + if (group.isOver) { + vlist = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: body + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: braceBody + }] + }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + + vlist.children[0].children[0].children[1].classes.push("svg-align"); + } else { + vlist = buildCommon.makeVList({ + positionType: "bottom", + positionData: body.depth + 0.1 + braceBody.height, + children: [{ + type: "elem", + elem: braceBody + }, { + type: "kern", + size: 0.1 + }, { + type: "elem", + elem: body + }] + }, options); // $FlowFixMe: Replace this with passing "svg-align" into makeVList. + + vlist.children[0].children[0].children[0].classes.push("svg-align"); + } + + if (supSubGroup) { + // To write the supsub, wrap the first vlist in another vlist: + // They can't all go in the same vlist, because the note might be + // wider than the equation. We want the equation to control the + // brace width. + // note long note long note + // ┏━━━━━━━━┓ or ┏━━━┓ not ┏━━━━━━━━━┓ + // equation eqn eqn + var vSpan = buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); + + if (group.isOver) { + vlist = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: vSpan + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: supSubGroup + }] + }, options); + } else { + vlist = buildCommon.makeVList({ + positionType: "bottom", + positionData: vSpan.depth + 0.2 + supSubGroup.height + supSubGroup.depth, + children: [{ + type: "elem", + elem: supSubGroup + }, { + type: "kern", + size: 0.2 + }, { + type: "elem", + elem: vSpan + }] + }, options); + } + } + + return buildCommon.makeSpan(["mord", group.isOver ? "mover" : "munder"], [vlist], options); +}; + +var mathmlBuilder$2 = (group, options) => { + var accentNode = stretchy.mathMLnode(group.label); + return new mathMLTree.MathNode(group.isOver ? "mover" : "munder", [buildGroup(group.base, options), accentNode]); +}; // Horizontal stretchy braces + + +defineFunction({ + type: "horizBrace", + names: ["\\overbrace", "\\underbrace"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + return { + type: "horizBrace", + mode: parser.mode, + label: funcName, + isOver: /^\\over/.test(funcName), + base: args[0] + }; + }, + + htmlBuilder: htmlBuilder$3, + mathmlBuilder: mathmlBuilder$2 +}); + +defineFunction({ + type: "href", + names: ["\\href"], + props: { + numArgs: 2, + argTypes: ["url", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[1]; + var href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\href", + url: href + })) { + return parser.formatUnsupportedCmd("\\href"); + } + + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + return buildCommon.makeAnchor(group.href, [], elements, options); + }, + mathmlBuilder: (group, options) => { + var math = buildExpressionRow(group.body, options); + + if (!(math instanceof MathNode)) { + math = new MathNode("mrow", [math]); + } + + math.setAttribute("href", group.href); + return math; + } +}); +defineFunction({ + type: "href", + names: ["\\url"], + props: { + numArgs: 1, + argTypes: ["url"], + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var href = assertNodeType(args[0], "url").url; + + if (!parser.settings.isTrusted({ + command: "\\url", + url: href + })) { + return parser.formatUnsupportedCmd("\\url"); + } + + var chars = []; + + for (var i = 0; i < href.length; i++) { + var c = href[i]; + + if (c === "~") { + c = "\\textasciitilde"; + } + + chars.push({ + type: "textord", + mode: "text", + text: c + }); + } + + var body = { + type: "text", + mode: parser.mode, + font: "\\texttt", + body: chars + }; + return { + type: "href", + mode: parser.mode, + href, + body: ordargument(body) + }; + } +}); + +// In LaTeX, \vcenter can act only on a box, as in +// \vcenter{\hbox{$\frac{a+b}{\dfrac{c}{d}}$}} +// This function by itself doesn't do anything but prevent a soft line break. + +defineFunction({ + type: "hbox", + names: ["\\hbox"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInText: true, + primitive: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "hbox", + mode: parser.mode, + body: ordargument(args[0]) + }; + }, + + htmlBuilder(group, options) { + var elements = buildExpression$1(group.body, options, false); + return buildCommon.makeFragment(elements); + }, + + mathmlBuilder(group, options) { + return new mathMLTree.MathNode("mrow", buildExpression(group.body, options)); + } + +}); + +defineFunction({ + type: "html", + names: ["\\htmlClass", "\\htmlId", "\\htmlStyle", "\\htmlData"], + props: { + numArgs: 2, + argTypes: ["raw", "original"], + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName, + token + } = _ref; + var value = assertNodeType(args[0], "raw").string; + var body = args[1]; + + if (parser.settings.strict) { + parser.settings.reportNonstrict("htmlExtension", "HTML extension is disabled on strict mode"); + } + + var trustContext; + var attributes = {}; + + switch (funcName) { + case "\\htmlClass": + attributes.class = value; + trustContext = { + command: "\\htmlClass", + class: value + }; + break; + + case "\\htmlId": + attributes.id = value; + trustContext = { + command: "\\htmlId", + id: value + }; + break; + + case "\\htmlStyle": + attributes.style = value; + trustContext = { + command: "\\htmlStyle", + style: value + }; + break; + + case "\\htmlData": + { + var data = value.split(","); + + for (var i = 0; i < data.length; i++) { + var keyVal = data[i].split("="); + + if (keyVal.length !== 2) { + throw new ParseError("Error parsing key-value for \\htmlData"); + } + + attributes["data-" + keyVal[0].trim()] = keyVal[1].trim(); + } + + trustContext = { + command: "\\htmlData", + attributes + }; + break; + } + + default: + throw new Error("Unrecognized html command"); + } + + if (!parser.settings.isTrusted(trustContext)) { + return parser.formatUnsupportedCmd(funcName); + } + + return { + type: "html", + mode: parser.mode, + attributes, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options, false); + var classes = ["enclosing"]; + + if (group.attributes.class) { + classes.push(...group.attributes.class.trim().split(/\s+/)); + } + + var span = buildCommon.makeSpan(classes, elements, options); + + for (var attr in group.attributes) { + if (attr !== "class" && group.attributes.hasOwnProperty(attr)) { + span.setAttribute(attr, group.attributes[attr]); + } + } + + return span; + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.body, options); + } +}); + +defineFunction({ + type: "htmlmathml", + names: ["\\html@mathml"], + props: { + numArgs: 2, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "htmlmathml", + mode: parser.mode, + html: ordargument(args[0]), + mathml: ordargument(args[1]) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.html, options, false); + return buildCommon.makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + return buildExpressionRow(group.mathml, options); + } +}); + +var sizeData = function sizeData(str) { + if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) { + // str is a number with no unit specified. + // default unit is bp, per graphix package. + return { + number: +str, + unit: "bp" + }; + } else { + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(str); + + if (!match) { + throw new ParseError("Invalid size: '" + str + "' in \\includegraphics"); + } + + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "' in \\includegraphics."); + } + + return data; + } +}; + +defineFunction({ + type: "includegraphics", + names: ["\\includegraphics"], + props: { + numArgs: 1, + numOptionalArgs: 1, + argTypes: ["raw", "url"], + allowedInText: false + }, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var width = { + number: 0, + unit: "em" + }; + var height = { + number: 0.9, + unit: "em" + }; // sorta character sized. + + var totalheight = { + number: 0, + unit: "em" + }; + var alt = ""; + + if (optArgs[0]) { + var attributeStr = assertNodeType(optArgs[0], "raw").string; // Parser.js does not parse key/value pairs. We get a string. + + var attributes = attributeStr.split(","); + + for (var i = 0; i < attributes.length; i++) { + var keyVal = attributes[i].split("="); + + if (keyVal.length === 2) { + var str = keyVal[1].trim(); + + switch (keyVal[0].trim()) { + case "alt": + alt = str; + break; + + case "width": + width = sizeData(str); + break; + + case "height": + height = sizeData(str); + break; + + case "totalheight": + totalheight = sizeData(str); + break; + + default: + throw new ParseError("Invalid key: '" + keyVal[0] + "' in \\includegraphics."); + } + } + } + } + + var src = assertNodeType(args[0], "url").url; + + if (alt === "") { + // No alt given. Use the file name. Strip away the path. + alt = src; + alt = alt.replace(/^.*[\\/]/, ''); + alt = alt.substring(0, alt.lastIndexOf('.')); + } + + if (!parser.settings.isTrusted({ + command: "\\includegraphics", + url: src + })) { + return parser.formatUnsupportedCmd("\\includegraphics"); + } + + return { + type: "includegraphics", + mode: parser.mode, + alt: alt, + width: width, + height: height, + totalheight: totalheight, + src: src + }; + }, + htmlBuilder: (group, options) => { + var height = calculateSize(group.height, options); + var depth = 0; + + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + } + + var width = 0; + + if (group.width.number > 0) { + width = calculateSize(group.width, options); + } + + var style = { + height: makeEm(height + depth) + }; + + if (width > 0) { + style.width = makeEm(width); + } + + if (depth > 0) { + style.verticalAlign = makeEm(-depth); + } + + var node = new Img(group.src, group.alt, style); + node.height = height; + node.depth = depth; + return node; + }, + mathmlBuilder: (group, options) => { + var node = new mathMLTree.MathNode("mglyph", []); + node.setAttribute("alt", group.alt); + var height = calculateSize(group.height, options); + var depth = 0; + + if (group.totalheight.number > 0) { + depth = calculateSize(group.totalheight, options) - height; + node.setAttribute("valign", makeEm(-depth)); + } + + node.setAttribute("height", makeEm(height + depth)); + + if (group.width.number > 0) { + var width = calculateSize(group.width, options); + node.setAttribute("width", makeEm(width)); + } + + node.setAttribute("src", group.src); + return node; + } +}); + +// Horizontal spacing commands + +defineFunction({ + type: "kern", + names: ["\\kern", "\\mkern", "\\hskip", "\\mskip"], + props: { + numArgs: 1, + argTypes: ["size"], + primitive: true, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var size = assertNodeType(args[0], "size"); + + if (parser.settings.strict) { + var mathFunction = funcName[1] === 'm'; // \mkern, \mskip + + var muUnit = size.value.unit === 'mu'; + + if (mathFunction) { + if (!muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " supports only mu units, " + ("not " + size.value.unit + " units")); + } + + if (parser.mode !== "math") { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " works only in math mode"); + } + } else { + // !mathFunction + if (muUnit) { + parser.settings.reportNonstrict("mathVsTextUnits", "LaTeX's " + funcName + " doesn't support mu units"); + } + } + } + + return { + type: "kern", + mode: parser.mode, + dimension: size.value + }; + }, + + htmlBuilder(group, options) { + return buildCommon.makeGlue(group.dimension, options); + }, + + mathmlBuilder(group, options) { + var dimension = calculateSize(group.dimension, options); + return new mathMLTree.SpaceNode(dimension); + } + +}); + +// Horizontal overlap functions +defineFunction({ + type: "lap", + names: ["\\mathllap", "\\mathrlap", "\\mathclap"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "lap", + mode: parser.mode, + alignment: funcName.slice(5), + body + }; + }, + htmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var inner; + + if (group.alignment === "clap") { + // ref: https://www.math.lsu.edu/~aperlis/publications/mathclap/ + inner = buildCommon.makeSpan([], [buildGroup$1(group.body, options)]); // wrap, since CSS will center a .clap > .inner > span + + inner = buildCommon.makeSpan(["inner"], [inner], options); + } else { + inner = buildCommon.makeSpan(["inner"], [buildGroup$1(group.body, options)]); + } + + var fix = buildCommon.makeSpan(["fix"], []); + var node = buildCommon.makeSpan([group.alignment], [inner, fix], options); // At this point, we have correctly set horizontal alignment of the + // two items involved in the lap. + // Next, use a strut to set the height of the HTML bounding box. + // Otherwise, a tall argument may be misplaced. + // This code resolved issue #1153 + + var strut = buildCommon.makeSpan(["strut"]); + strut.style.height = makeEm(node.height + node.depth); + + if (node.depth) { + strut.style.verticalAlign = makeEm(-node.depth); + } + + node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall. + // This code resolves issue #1234 + + node = buildCommon.makeSpan(["thinbox"], [node], options); + return buildCommon.makeSpan(["mord", "vbox"], [node], options); + }, + mathmlBuilder: (group, options) => { + // mathllap, mathrlap, mathclap + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + + if (group.alignment !== "rlap") { + var offset = group.alignment === "llap" ? "-1" : "-0.5"; + node.setAttribute("lspace", offset + "width"); + } + + node.setAttribute("width", "0px"); + return node; + } +}); + +defineFunction({ + type: "styling", + names: ["\\(", "$"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + + handler(_ref, args) { + var { + funcName, + parser + } = _ref; + var outerMode = parser.mode; + parser.switchMode("math"); + var close = funcName === "\\(" ? "\\)" : "$"; + var body = parser.parseExpression(false, close); + parser.expect(close); + parser.switchMode(outerMode); + return { + type: "styling", + mode: parser.mode, + style: "text", + body + }; + } + +}); // Check for extra closing math delimiters + +defineFunction({ + type: "text", + // Doesn't matter what this is. + names: ["\\)", "\\]"], + props: { + numArgs: 0, + allowedInText: true, + allowedInMath: false + }, + + handler(context, args) { + throw new ParseError("Mismatched " + context.funcName); + } + +}); + +var chooseMathStyle = (group, options) => { + switch (options.style.size) { + case Style$1$1.DISPLAY.size: + return group.display; + + case Style$1$1.TEXT.size: + return group.text; + + case Style$1$1.SCRIPT.size: + return group.script; + + case Style$1$1.SCRIPTSCRIPT.size: + return group.scriptscript; + + default: + return group.text; + } +}; + +defineFunction({ + type: "mathchoice", + names: ["\\mathchoice"], + props: { + numArgs: 4, + primitive: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + return { + type: "mathchoice", + mode: parser.mode, + display: ordargument(args[0]), + text: ordargument(args[1]), + script: ordargument(args[2]), + scriptscript: ordargument(args[3]) + }; + }, + htmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + var elements = buildExpression$1(body, options, false); + return buildCommon.makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var body = chooseMathStyle(group, options); + return buildExpressionRow(body, options); + } +}); + +var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => { + base = buildCommon.makeSpan([], [base]); + var subIsSingleCharacter = subGroup && utils$1.isCharacterBox(subGroup); + var sub; + var sup; // We manually have to handle the superscripts and subscripts. This, + // aside from the kern calculations, is copied from supsub. + + if (supGroup) { + var elem = buildGroup$1(supGroup, options.havingStyle(style.sup()), options); + sup = { + elem, + kern: Math.max(options.fontMetrics().bigOpSpacing1, options.fontMetrics().bigOpSpacing3 - elem.depth) + }; + } + + if (subGroup) { + var _elem = buildGroup$1(subGroup, options.havingStyle(style.sub()), options); + + sub = { + elem: _elem, + kern: Math.max(options.fontMetrics().bigOpSpacing2, options.fontMetrics().bigOpSpacing4 - _elem.height) + }; + } // Build the final group as a vlist of the possible subscript, base, + // and possible superscript. + + + var finalGroup; + + if (sup && sub) { + var bottom = options.fontMetrics().bigOpSpacing5 + sub.elem.height + sub.elem.depth + sub.kern + base.depth + baseShift; + finalGroup = buildCommon.makeVList({ + positionType: "bottom", + positionData: bottom, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else if (sub) { + var top = base.height - baseShift; // Shift the limits by the slant of the symbol. Note + // that we are supposed to shift the limits by 1/2 of the slant, + // but since we are centering the limits adding a full slant of + // margin will shift by 1/2 that. + + finalGroup = buildCommon.makeVList({ + positionType: "top", + positionData: top, + children: [{ + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }, { + type: "elem", + elem: sub.elem, + marginLeft: makeEm(-slant) + }, { + type: "kern", + size: sub.kern + }, { + type: "elem", + elem: base + }] + }, options); + } else if (sup) { + var _bottom = base.depth + baseShift; + + finalGroup = buildCommon.makeVList({ + positionType: "bottom", + positionData: _bottom, + children: [{ + type: "elem", + elem: base + }, { + type: "kern", + size: sup.kern + }, { + type: "elem", + elem: sup.elem, + marginLeft: makeEm(slant) + }, { + type: "kern", + size: options.fontMetrics().bigOpSpacing5 + }] + }, options); + } else { + // This case probably shouldn't occur (this would mean the + // supsub was sending us a group with no superscript or + // subscript) but be safe. + return base; + } + + var parts = [finalGroup]; + + if (sub && slant !== 0 && !subIsSingleCharacter) { + // A negative margin-left was applied to the lower limit. + // Avoid an overlap by placing a spacer on the left on the group. + var spacer = buildCommon.makeSpan(["mspace"], [], options); + spacer.style.marginRight = makeEm(slant); + parts.unshift(spacer); + } + + return buildCommon.makeSpan(["mop", "op-limits"], parts, options); +}; + +// Limits, symbols +// Most operators have a large successor symbol, but these don't. +var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also +// "supsub" since some of them (like \int) can affect super/subscripting. + +var htmlBuilder$2 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "op"); + hasLimits = true; + } else { + group = assertNodeType(grp, "op"); + } + + var style = options.style; + var large = false; + + if (style.size === Style$1$1.DISPLAY.size && group.symbol && !utils$1.contains(noSuccessor, group.name)) { + // Most symbol operators get larger in displaystyle (rule 13) + large = true; + } + + var base; + + if (group.symbol) { + // If this is a symbol, create the symbol. + var fontName = large ? "Size2-Regular" : "Size1-Regular"; + var stash = ""; + + if (group.name === "\\oiint" || group.name === "\\oiiint") { + // No font glyphs yet, so use a glyph w/o the oval. + // TODO: When font glyphs are available, delete this code. + stash = group.name.slice(1); + group.name = stash === "oiint" ? "\\iint" : "\\iiint"; + } + + base = buildCommon.makeSymbol(group.name, fontName, "math", options, ["mop", "op-symbol", large ? "large-op" : "small-op"]); + + if (stash.length > 0) { + // We're in \oiint or \oiiint. Overlay the oval. + // TODO: When font glyphs are available, delete this code. + var italic = base.italic; + var oval = buildCommon.staticSvg(stash + "Size" + (large ? "2" : "1"), options); + base = buildCommon.makeVList({ + positionType: "individualShift", + children: [{ + type: "elem", + elem: base, + shift: 0 + }, { + type: "elem", + elem: oval, + shift: large ? 0.08 : 0 + }] + }, options); + group.name = "\\" + stash; + base.classes.unshift("mop"); // $FlowFixMe + + base.italic = italic; + } + } else if (group.body) { + // If this is a list, compose that list. + var inner = buildExpression$1(group.body, options, true); + + if (inner.length === 1 && inner[0] instanceof SymbolNode) { + base = inner[0]; + base.classes[0] = "mop"; // replace old mclass + } else { + base = buildCommon.makeSpan(["mop"], inner, options); + } + } else { + // Otherwise, this is a text operator. Build the text from the + // operator's name. + var output = []; + + for (var i = 1; i < group.name.length; i++) { + output.push(buildCommon.mathsym(group.name[i], group.mode, options)); + } + + base = buildCommon.makeSpan(["mop"], output, options); + } // If content of op is a single symbol, shift it vertically. + + + var baseShift = 0; + var slant = 0; + + if ((base instanceof SymbolNode || group.name === "\\oiint" || group.name === "\\oiiint") && !group.suppressBaseShift) { + // We suppress the shift of the base of \overset and \underset. Otherwise, + // shift the symbol so its center lies on the axis (rule 13). It + // appears that our fonts have the centers of the symbols already + // almost on the axis, so these numbers are very small. Note we + // don't actually apply this here, but instead it is used either in + // the vlist creation or separately when there are no limits. + baseShift = (base.height - base.depth) / 2 - options.fontMetrics().axisHeight; // The slant of the symbol is just its italic correction. + // $FlowFixMe + + slant = base.italic; + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift); + } else { + if (baseShift) { + base.style.position = "relative"; + base.style.top = makeEm(baseShift); + } + + return base; + } +}; + +var mathmlBuilder$1 = (group, options) => { + var node; + + if (group.symbol) { + // This is a symbol. Just add the symbol. + node = new MathNode("mo", [makeText(group.name, group.mode)]); + + if (utils$1.contains(noSuccessor, group.name)) { + node.setAttribute("largeop", "false"); + } + } else if (group.body) { + // This is an operator with children. Add them. + node = new MathNode("mo", buildExpression(group.body, options)); + } else { + // This is a text operator. Add all of the characters from the + // operator's name. + node = new MathNode("mi", [new TextNode(group.name.slice(1))]); // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + + var operator = new MathNode("mo", [makeText("\u2061", "text")]); + + if (group.parentIsSupSub) { + node = new MathNode("mrow", [node, operator]); + } else { + node = newDocumentFragment([node, operator]); + } + } + + return node; +}; + +var singleCharBigOps = { + "\u220F": "\\prod", + "\u2210": "\\coprod", + "\u2211": "\\sum", + "\u22c0": "\\bigwedge", + "\u22c1": "\\bigvee", + "\u22c2": "\\bigcap", + "\u22c3": "\\bigcup", + "\u2a00": "\\bigodot", + "\u2a01": "\\bigoplus", + "\u2a02": "\\bigotimes", + "\u2a04": "\\biguplus", + "\u2a06": "\\bigsqcup" +}; +defineFunction({ + type: "op", + names: ["\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap", "\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes", "\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F", "\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00", "\u2a01", "\u2a02", "\u2a04", "\u2a06"], + props: { + numArgs: 0 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var fName = funcName; + + if (fName.length === 1) { + fName = singleCharBigOps[fName]; + } + + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // Note: calling defineFunction with a type that's already been defined only +// works because the same htmlBuilder and mathmlBuilder are being used. + +defineFunction({ + type: "op", + names: ["\\mathop"], + props: { + numArgs: 1, + primitive: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + body: ordargument(body) + }; + }, + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // There are 2 flags for operators; whether they produce limits in +// displaystyle, and whether they are symbols and should grow in +// displaystyle. These four groups cover the four possible choices. + +var singleCharIntegrals = { + "\u222b": "\\int", + "\u222c": "\\iint", + "\u222d": "\\iiint", + "\u222e": "\\oint", + "\u222f": "\\oiint", + "\u2230": "\\oiiint" +}; // No limits, not symbols + +defineFunction({ + type: "op", + names: ["\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg", "\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg", "\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp", "\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th"], + props: { + numArgs: 0 + }, + + handler(_ref3) { + var { + parser, + funcName + } = _ref3; + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // Limits, not symbols + +defineFunction({ + type: "op", + names: ["\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup"], + props: { + numArgs: 0 + }, + + handler(_ref4) { + var { + parser, + funcName + } = _ref4; + return { + type: "op", + mode: parser.mode, + limits: true, + parentIsSupSub: false, + symbol: false, + name: funcName + }; + }, + + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); // No limits, symbols + +defineFunction({ + type: "op", + names: ["\\int", "\\iint", "\\iiint", "\\oint", "\\oiint", "\\oiiint", "\u222b", "\u222c", "\u222d", "\u222e", "\u222f", "\u2230"], + props: { + numArgs: 0 + }, + + handler(_ref5) { + var { + parser, + funcName + } = _ref5; + var fName = funcName; + + if (fName.length === 1) { + fName = singleCharIntegrals[fName]; + } + + return { + type: "op", + mode: parser.mode, + limits: false, + parentIsSupSub: false, + symbol: true, + name: fName + }; + }, + + htmlBuilder: htmlBuilder$2, + mathmlBuilder: mathmlBuilder$1 +}); + +// NOTE: Unlike most `htmlBuilder`s, this one handles not only +// "operatorname", but also "supsub" since \operatorname* can +// affect super/subscripting. +var htmlBuilder$1 = (grp, options) => { + // Operators are handled in the TeXbook pg. 443-444, rule 13(a). + var supGroup; + var subGroup; + var hasLimits = false; + var group; + + if (grp.type === "supsub") { + // If we have limits, supsub will pass us its group to handle. Pull + // out the superscript and subscript and set the group to the op in + // its base. + supGroup = grp.sup; + subGroup = grp.sub; + group = assertNodeType(grp.base, "operatorname"); + hasLimits = true; + } else { + group = assertNodeType(grp, "operatorname"); + } + + var base; + + if (group.body.length > 0) { + var body = group.body.map(child => { + // $FlowFixMe: Check if the node has a string `text` property. + var childText = child.text; + + if (typeof childText === "string") { + return { + type: "textord", + mode: child.mode, + text: childText + }; + } else { + return child; + } + }); // Consolidate function names into symbol characters. + + var expression = buildExpression$1(body, options.withFont("mathrm"), true); + + for (var i = 0; i < expression.length; i++) { + var child = expression[i]; + + if (child instanceof SymbolNode) { + // Per amsopn package, + // change minus to hyphen and \ast to asterisk + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } + } + + base = buildCommon.makeSpan(["mop"], expression, options); + } else { + base = buildCommon.makeSpan(["mop"], [], options); + } + + if (hasLimits) { + return assembleSupSub(base, supGroup, subGroup, options, options.style, 0, 0); + } else { + return base; + } +}; + +var mathmlBuilder = (group, options) => { + // The steps taken here are similar to the html version. + var expression = buildExpression(group.body, options.withFont("mathrm")); // Is expression a string or has it something like a fraction? + + var isAllString = true; // default + + for (var i = 0; i < expression.length; i++) { + var node = expression[i]; + + if (node instanceof mathMLTree.SpaceNode) ; else if (node instanceof mathMLTree.MathNode) { + switch (node.type) { + case "mi": + case "mn": + case "ms": + case "mspace": + case "mtext": + break; + // Do nothing yet. + + case "mo": + { + var child = node.children[0]; + + if (node.children.length === 1 && child instanceof mathMLTree.TextNode) { + child.text = child.text.replace(/\u2212/, "-").replace(/\u2217/, "*"); + } else { + isAllString = false; + } + + break; + } + + default: + isAllString = false; + } + } else { + isAllString = false; + } + } + + if (isAllString) { + // Write a single TextNode instead of multiple nested tags. + var word = expression.map(node => node.toText()).join(""); + expression = [new mathMLTree.TextNode(word)]; + } + + var identifier = new mathMLTree.MathNode("mi", expression); + identifier.setAttribute("mathvariant", "normal"); // \u2061 is the same as ⁡ + // ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp + + var operator = new mathMLTree.MathNode("mo", [makeText("\u2061", "text")]); + + if (group.parentIsSupSub) { + return new mathMLTree.MathNode("mrow", [identifier, operator]); + } else { + return mathMLTree.newDocumentFragment([identifier, operator]); + } +}; // \operatorname +// amsopn.dtx: \mathop{#1\kern\z@\operator@font#3}\newmcodes@ + + +defineFunction({ + type: "operatorname", + names: ["\\operatorname@", "\\operatornamewithlimits"], + props: { + numArgs: 1 + }, + handler: (_ref, args) => { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "operatorname", + mode: parser.mode, + body: ordargument(body), + alwaysHandleSupSub: funcName === "\\operatornamewithlimits", + limits: false, + parentIsSupSub: false + }; + }, + htmlBuilder: htmlBuilder$1, + mathmlBuilder +}); +defineMacro("\\operatorname", "\\@ifstar\\operatornamewithlimits\\operatorname@"); + +defineFunctionBuilders({ + type: "ordgroup", + + htmlBuilder(group, options) { + if (group.semisimple) { + return buildCommon.makeFragment(buildExpression$1(group.body, options, false)); + } + + return buildCommon.makeSpan(["mord"], buildExpression$1(group.body, options, true), options); + }, + + mathmlBuilder(group, options) { + return buildExpressionRow(group.body, options, true); + } + +}); + +defineFunction({ + type: "overline", + names: ["\\overline"], + props: { + numArgs: 1 + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "overline", + mode: parser.mode, + body + }; + }, + + htmlBuilder(group, options) { + // Overlines are handled in the TeXbook pg 443, Rule 9. + // Build the inner group in the cramped style. + var innerGroup = buildGroup$1(group.body, options.havingCrampedStyle()); // Create the line above the body + + var line = buildCommon.makeLineSpan("overline-line", options); // Generate the vlist, with the appropriate kerns + + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: innerGroup + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: defaultRuleThickness + }] + }, options); + return buildCommon.makeSpan(["mord", "overline"], [vlist], options); + }, + + mathmlBuilder(group, options) { + var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new mathMLTree.MathNode("mover", [buildGroup(group.body, options), operator]); + node.setAttribute("accent", "true"); + return node; + } + +}); + +defineFunction({ + type: "phantom", + names: ["\\phantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref, args) => { + var { + parser + } = _ref; + var body = args[0]; + return { + type: "phantom", + mode: parser.mode, + body: ordargument(body) + }; + }, + htmlBuilder: (group, options) => { + var elements = buildExpression$1(group.body, options.withPhantom(), false); // \phantom isn't supposed to affect the elements it contains. + // See "color" for more details. + + return buildCommon.makeFragment(elements); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(group.body, options); + return new mathMLTree.MathNode("mphantom", inner); + } +}); +defineFunction({ + type: "hphantom", + names: ["\\hphantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref2, args) => { + var { + parser + } = _ref2; + var body = args[0]; + return { + type: "hphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + var node = buildCommon.makeSpan([], [buildGroup$1(group.body, options.withPhantom())]); + node.height = 0; + node.depth = 0; + + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + node.children[i].height = 0; + node.children[i].depth = 0; + } + } // See smash for comment re: use of makeVList + + + node = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }, options); // For spacing, TeX treats \smash as a math group (same spacing as ord). + + return buildCommon.makeSpan(["mord"], [node], options); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(ordargument(group.body), options); + var phantom = new mathMLTree.MathNode("mphantom", inner); + var node = new mathMLTree.MathNode("mpadded", [phantom]); + node.setAttribute("height", "0px"); + node.setAttribute("depth", "0px"); + return node; + } +}); +defineFunction({ + type: "vphantom", + names: ["\\vphantom"], + props: { + numArgs: 1, + allowedInText: true + }, + handler: (_ref3, args) => { + var { + parser + } = _ref3; + var body = args[0]; + return { + type: "vphantom", + mode: parser.mode, + body + }; + }, + htmlBuilder: (group, options) => { + var inner = buildCommon.makeSpan(["inner"], [buildGroup$1(group.body, options.withPhantom())]); + var fix = buildCommon.makeSpan(["fix"], []); + return buildCommon.makeSpan(["mord", "rlap"], [inner, fix], options); + }, + mathmlBuilder: (group, options) => { + var inner = buildExpression(ordargument(group.body), options); + var phantom = new mathMLTree.MathNode("mphantom", inner); + var node = new mathMLTree.MathNode("mpadded", [phantom]); + node.setAttribute("width", "0px"); + return node; + } +}); + +defineFunction({ + type: "raisebox", + names: ["\\raisebox"], + props: { + numArgs: 2, + argTypes: ["size", "hbox"], + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + var amount = assertNodeType(args[0], "size").value; + var body = args[1]; + return { + type: "raisebox", + mode: parser.mode, + dy: amount, + body + }; + }, + + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var dy = calculateSize(group.dy, options); + return buildCommon.makeVList({ + positionType: "shift", + positionData: -dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + var dy = group.dy.number + group.dy.unit; + node.setAttribute("voffset", dy); + return node; + } + +}); + +defineFunction({ + type: "internal", + names: ["\\relax"], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(_ref) { + var { + parser + } = _ref; + return { + type: "internal", + mode: parser.mode + }; + } + +}); + +defineFunction({ + type: "rule", + names: ["\\rule"], + props: { + numArgs: 2, + numOptionalArgs: 1, + argTypes: ["size", "size", "size"] + }, + + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var shift = optArgs[0]; + var width = assertNodeType(args[0], "size"); + var height = assertNodeType(args[1], "size"); + return { + type: "rule", + mode: parser.mode, + shift: shift && assertNodeType(shift, "size").value, + width: width.value, + height: height.value + }; + }, + + htmlBuilder(group, options) { + // Make an empty span for the rule + var rule = buildCommon.makeSpan(["mord", "rule"], [], options); // Calculate the shift, width, and height of the rule, and account for units + + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size + + rule.style.borderRightWidth = makeEm(width); + rule.style.borderTopWidth = makeEm(height); + rule.style.bottom = makeEm(shift); // Record the height and width + + rule.width = width; + rule.height = height + shift; + rule.depth = -shift; // Font size is the number large enough that the browser will + // reserve at least `absHeight` space above the baseline. + // The 1.125 factor was empirically determined + + rule.maxFontSize = height * 1.125 * options.sizeMultiplier; + return rule; + }, + + mathmlBuilder(group, options) { + var width = calculateSize(group.width, options); + var height = calculateSize(group.height, options); + var shift = group.shift ? calculateSize(group.shift, options) : 0; + var color = options.color && options.getColor() || "black"; + var rule = new mathMLTree.MathNode("mspace"); + rule.setAttribute("mathbackground", color); + rule.setAttribute("width", makeEm(width)); + rule.setAttribute("height", makeEm(height)); + var wrapper = new mathMLTree.MathNode("mpadded", [rule]); + + if (shift >= 0) { + wrapper.setAttribute("height", makeEm(shift)); + } else { + wrapper.setAttribute("height", makeEm(shift)); + wrapper.setAttribute("depth", makeEm(-shift)); + } + + wrapper.setAttribute("voffset", makeEm(shift)); + return wrapper; + } + +}); + +function sizingGroup(value, options, baseOptions) { + var inner = buildExpression$1(value, options, false); + var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize + // manually. Handle nested size changes. + + for (var i = 0; i < inner.length; i++) { + var pos = inner[i].classes.indexOf("sizing"); + + if (pos < 0) { + Array.prototype.push.apply(inner[i].classes, options.sizingClasses(baseOptions)); + } else if (inner[i].classes[pos + 1] === "reset-size" + options.size) { + // This is a nested size change: e.g., inner[i] is the "b" in + // `\Huge a \small b`. Override the old size (the `reset-` class) + // but not the new size. + inner[i].classes[pos + 1] = "reset-size" + baseOptions.size; + } + + inner[i].height *= multiplier; + inner[i].depth *= multiplier; + } + + return buildCommon.makeFragment(inner); +} +var sizeFuncs = ["\\tiny", "\\sixptsize", "\\scriptsize", "\\footnotesize", "\\small", "\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"]; +var htmlBuilder = (group, options) => { + // Handle sizing operators like \Huge. Real TeX doesn't actually allow + // these functions inside of math expressions, so we do some special + // handling. + var newOptions = options.havingSize(group.size); + return sizingGroup(group.body, newOptions, options); +}; +defineFunction({ + type: "sizing", + names: sizeFuncs, + props: { + numArgs: 0, + allowedInText: true + }, + handler: (_ref, args) => { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + var body = parser.parseExpression(false, breakOnTokenText); + return { + type: "sizing", + mode: parser.mode, + // Figure out what size to use based on the list of functions above + size: sizeFuncs.indexOf(funcName) + 1, + body + }; + }, + htmlBuilder, + mathmlBuilder: (group, options) => { + var newOptions = options.havingSize(group.size); + var inner = buildExpression(group.body, newOptions); + var node = new mathMLTree.MathNode("mstyle", inner); // TODO(emily): This doesn't produce the correct size for nested size + // changes, because we don't keep state of what style we're currently + // in, so we can't reset the size to normal before changing it. Now + // that we're passing an options parameter we should be able to fix + // this. + + node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier)); + return node; + } +}); + +// smash, with optional [tb], as in AMS +defineFunction({ + type: "smash", + names: ["\\smash"], + props: { + numArgs: 1, + numOptionalArgs: 1, + allowedInText: true + }, + handler: (_ref, args, optArgs) => { + var { + parser + } = _ref; + var smashHeight = false; + var smashDepth = false; + var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup"); + + if (tbArg) { + // Optional [tb] argument is engaged. + // ref: amsmath: \renewcommand{\smash}[1][tb]{% + // def\mb@t{\ht}\def\mb@b{\dp}\def\mb@tb{\ht\z@\z@\dp}% + var letter = ""; + + for (var i = 0; i < tbArg.body.length; ++i) { + var node = tbArg.body[i]; // $FlowFixMe: Not every node type has a `text` property. + + letter = node.text; + + if (letter === "t") { + smashHeight = true; + } else if (letter === "b") { + smashDepth = true; + } else { + smashHeight = false; + smashDepth = false; + break; + } + } + } else { + smashHeight = true; + smashDepth = true; + } + + var body = args[0]; + return { + type: "smash", + mode: parser.mode, + body, + smashHeight, + smashDepth + }; + }, + htmlBuilder: (group, options) => { + var node = buildCommon.makeSpan([], [buildGroup$1(group.body, options)]); + + if (!group.smashHeight && !group.smashDepth) { + return node; + } + + if (group.smashHeight) { + node.height = 0; // In order to influence makeVList, we have to reset the children. + + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + node.children[i].height = 0; + } + } + } + + if (group.smashDepth) { + node.depth = 0; + + if (node.children) { + for (var _i = 0; _i < node.children.length; _i++) { + node.children[_i].depth = 0; + } + } + } // At this point, we've reset the TeX-like height and depth values. + // But the span still has an HTML line height. + // makeVList applies "display: table-cell", which prevents the browser + // from acting on that line height. So we'll call makeVList now. + + + var smashedNode = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: node + }] + }, options); // For spacing, TeX treats \hphantom as a math group (same spacing as ord). + + return buildCommon.makeSpan(["mord"], [smashedNode], options); + }, + mathmlBuilder: (group, options) => { + var node = new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)]); + + if (group.smashHeight) { + node.setAttribute("height", "0px"); + } + + if (group.smashDepth) { + node.setAttribute("depth", "0px"); + } + + return node; + } +}); + +defineFunction({ + type: "sqrt", + names: ["\\sqrt"], + props: { + numArgs: 1, + numOptionalArgs: 1 + }, + + handler(_ref, args, optArgs) { + var { + parser + } = _ref; + var index = optArgs[0]; + var body = args[0]; + return { + type: "sqrt", + mode: parser.mode, + body, + index + }; + }, + + htmlBuilder(group, options) { + // Square roots are handled in the TeXbook pg. 443, Rule 11. + // First, we do the same steps as in overline to build the inner group + // and line + var inner = buildGroup$1(group.body, options.havingCrampedStyle()); + + if (inner.height === 0) { + // Render a small surd. + inner.height = options.fontMetrics().xHeight; + } // Some groups can return document fragments. Handle those by wrapping + // them in a span. + + + inner = buildCommon.wrapFragment(inner, options); // Calculate the minimum size for the \surd delimiter + + var metrics = options.fontMetrics(); + var theta = metrics.defaultRuleThickness; + var phi = theta; + + if (options.style.id < Style$1$1.TEXT.id) { + phi = options.fontMetrics().xHeight; + } // Calculate the clearance between the body and line + + + var lineClearance = theta + phi / 4; + var minDelimiterHeight = inner.height + inner.depth + lineClearance + theta; // Create a sqrt SVG of the required minimum size + + var { + span: img, + ruleWidth, + advanceWidth + } = delimiter$1.sqrtImage(minDelimiterHeight, options); + var delimDepth = img.height - ruleWidth; // Adjust the clearance based on the delimiter size + + if (delimDepth > inner.height + inner.depth + lineClearance) { + lineClearance = (lineClearance + delimDepth - inner.height - inner.depth) / 2; + } // Shift the sqrt image + + + var imgShift = img.height - inner.height - lineClearance - ruleWidth; + inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument. + + var body = buildCommon.makeVList({ + positionType: "firstBaseline", + children: [{ + type: "elem", + elem: inner, + wrapperClasses: ["svg-align"] + }, { + type: "kern", + size: -(inner.height + imgShift) + }, { + type: "elem", + elem: img + }, { + type: "kern", + size: ruleWidth + }] + }, options); + + if (!group.index) { + return buildCommon.makeSpan(["mord", "sqrt"], [body], options); + } else { + // Handle the optional root index + // The index is always in scriptscript style + var newOptions = options.havingStyle(Style$1$1.SCRIPTSCRIPT); + var rootm = buildGroup$1(group.index, newOptions, options); // The amount the index is shifted by. This is taken from the TeX + // source, in the definition of `\r@@t`. + + var toShift = 0.6 * (body.height - body.depth); // Build a VList with the superscript shifted up correctly + + var rootVList = buildCommon.makeVList({ + positionType: "shift", + positionData: -toShift, + children: [{ + type: "elem", + elem: rootm + }] + }, options); // Add a class surrounding it so we can add on the appropriate + // kerning + + var rootVListWrap = buildCommon.makeSpan(["root"], [rootVList]); + return buildCommon.makeSpan(["mord", "sqrt"], [rootVListWrap, body], options); + } + }, + + mathmlBuilder(group, options) { + var { + body, + index + } = group; + return index ? new mathMLTree.MathNode("mroot", [buildGroup(body, options), buildGroup(index, options)]) : new mathMLTree.MathNode("msqrt", [buildGroup(body, options)]); + } + +}); + +var styleMap = { + "display": Style$1$1.DISPLAY, + "text": Style$1$1.TEXT, + "script": Style$1$1.SCRIPT, + "scriptscript": Style$1$1.SCRIPTSCRIPT +}; +defineFunction({ + type: "styling", + names: ["\\displaystyle", "\\textstyle", "\\scriptstyle", "\\scriptscriptstyle"], + props: { + numArgs: 0, + allowedInText: true, + primitive: true + }, + + handler(_ref, args) { + var { + breakOnTokenText, + funcName, + parser + } = _ref; + // parse out the implicit body + var body = parser.parseExpression(true, breakOnTokenText); // TODO: Refactor to avoid duplicating styleMap in multiple places (e.g. + // here and in buildHTML and de-dupe the enumeration of all the styles). + // $FlowFixMe: The names above exactly match the styles. + + var style = funcName.slice(1, funcName.length - 5); + return { + type: "styling", + mode: parser.mode, + // Figure out what style to use by pulling out the style from + // the function name + style, + body + }; + }, + + htmlBuilder(group, options) { + // Style changes are handled in the TeXbook on pg. 442, Rule 3. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle).withFont(''); + return sizingGroup(group.body, newOptions, options); + }, + + mathmlBuilder(group, options) { + // Figure out what style we're changing to. + var newStyle = styleMap[group.style]; + var newOptions = options.havingStyle(newStyle); + var inner = buildExpression(group.body, newOptions); + var node = new mathMLTree.MathNode("mstyle", inner); + var styleAttributes = { + "display": ["0", "true"], + "text": ["0", "false"], + "script": ["1", "false"], + "scriptscript": ["2", "false"] + }; + var attr = styleAttributes[group.style]; + node.setAttribute("scriptlevel", attr[0]); + node.setAttribute("displaystyle", attr[1]); + return node; + } + +}); + +/** + * Sometimes, groups perform special rules when they have superscripts or + * subscripts attached to them. This function lets the `supsub` group know that + * Sometimes, groups perform special rules when they have superscripts or + * its inner element should handle the superscripts and subscripts instead of + * handling them itself. + */ +var htmlBuilderDelegate = function htmlBuilderDelegate(group, options) { + var base = group.base; + + if (!base) { + return null; + } else if (base.type === "op") { + // Operators handle supsubs differently when they have limits + // (e.g. `\displaystyle\sum_2^3`) + var delegate = base.limits && (options.style.size === Style$1$1.DISPLAY.size || base.alwaysHandleSupSub); + return delegate ? htmlBuilder$2 : null; + } else if (base.type === "operatorname") { + var _delegate = base.alwaysHandleSupSub && (options.style.size === Style$1$1.DISPLAY.size || base.limits); + + return _delegate ? htmlBuilder$1 : null; + } else if (base.type === "accent") { + return utils$1.isCharacterBox(base.base) ? htmlBuilder$a : null; + } else if (base.type === "horizBrace") { + var isSup = !group.sub; + return isSup === base.isOver ? htmlBuilder$3 : null; + } else { + return null; + } +}; // Super scripts and subscripts, whose precise placement can depend on other +// functions that precede them. + + +defineFunctionBuilders({ + type: "supsub", + + htmlBuilder(group, options) { + // Superscript and subscripts are handled in the TeXbook on page + // 445-446, rules 18(a-f). + // Here is where we defer to the inner group if it should handle + // superscripts and subscripts itself. + var builderDelegate = htmlBuilderDelegate(group, options); + + if (builderDelegate) { + return builderDelegate(group, options); + } + + var { + base: valueBase, + sup: valueSup, + sub: valueSub + } = group; + var base = buildGroup$1(valueBase, options); + var supm; + var subm; + var metrics = options.fontMetrics(); // Rule 18a + + var supShift = 0; + var subShift = 0; + var isCharacterBox = valueBase && utils$1.isCharacterBox(valueBase); + + if (valueSup) { + var newOptions = options.havingStyle(options.style.sup()); + supm = buildGroup$1(valueSup, newOptions, options); + + if (!isCharacterBox) { + supShift = base.height - newOptions.fontMetrics().supDrop * newOptions.sizeMultiplier / options.sizeMultiplier; + } + } + + if (valueSub) { + var _newOptions = options.havingStyle(options.style.sub()); + + subm = buildGroup$1(valueSub, _newOptions, options); + + if (!isCharacterBox) { + subShift = base.depth + _newOptions.fontMetrics().subDrop * _newOptions.sizeMultiplier / options.sizeMultiplier; + } + } // Rule 18c + + + var minSupShift; + + if (options.style === Style$1$1.DISPLAY) { + minSupShift = metrics.sup1; + } else if (options.style.cramped) { + minSupShift = metrics.sup3; + } else { + minSupShift = metrics.sup2; + } // scriptspace is a font-size-independent size, so scale it + // appropriately for use as the marginRight. + + + var multiplier = options.sizeMultiplier; + var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier); + var marginLeft = null; + + if (subm) { + // Subscripts shouldn't be shifted by the base's italic correction. + // Account for that by shifting the subscript back the appropriate + // amount. Note we only do this when the base is a single symbol. + var isOiint = group.base && group.base.type === "op" && group.base.name && (group.base.name === "\\oiint" || group.base.name === "\\oiiint"); + + if (base instanceof SymbolNode || isOiint) { + // $FlowFixMe + marginLeft = makeEm(-base.italic); + } + } + + var supsub; + + if (supm && subm) { + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + subShift = Math.max(subShift, metrics.sub2); + var ruleWidth = metrics.defaultRuleThickness; // Rule 18e + + var maxWidth = 4 * ruleWidth; + + if (supShift - supm.depth - (subm.height - subShift) < maxWidth) { + subShift = maxWidth - (supShift - supm.depth) + subm.height; + var psi = 0.8 * metrics.xHeight - (supShift - supm.depth); + + if (psi > 0) { + supShift += psi; + subShift -= psi; + } + } + + var vlistElem = [{ + type: "elem", + elem: subm, + shift: subShift, + marginRight, + marginLeft + }, { + type: "elem", + elem: supm, + shift: -supShift, + marginRight + }]; + supsub = buildCommon.makeVList({ + positionType: "individualShift", + children: vlistElem + }, options); + } else if (subm) { + // Rule 18b + subShift = Math.max(subShift, metrics.sub1, subm.height - 0.8 * metrics.xHeight); + var _vlistElem = [{ + type: "elem", + elem: subm, + marginLeft, + marginRight + }]; + supsub = buildCommon.makeVList({ + positionType: "shift", + positionData: subShift, + children: _vlistElem + }, options); + } else if (supm) { + // Rule 18c, d + supShift = Math.max(supShift, minSupShift, supm.depth + 0.25 * metrics.xHeight); + supsub = buildCommon.makeVList({ + positionType: "shift", + positionData: -supShift, + children: [{ + type: "elem", + elem: supm, + marginRight + }] + }, options); + } else { + throw new Error("supsub must have either sup or sub."); + } // Wrap the supsub vlist in a span.msupsub to reset text-align. + + + var mclass = getTypeOfDomTree(base, "right") || "mord"; + return buildCommon.makeSpan([mclass], [base, buildCommon.makeSpan(["msupsub"], [supsub])], options); + }, + + mathmlBuilder(group, options) { + // Is the inner group a relevant horizonal brace? + var isBrace = false; + var isOver; + var isSup; + + if (group.base && group.base.type === "horizBrace") { + isSup = !!group.sup; + + if (isSup === group.base.isOver) { + isBrace = true; + isOver = group.base.isOver; + } + } + + if (group.base && (group.base.type === "op" || group.base.type === "operatorname")) { + group.base.parentIsSupSub = true; + } + + var children = [buildGroup(group.base, options)]; + + if (group.sub) { + children.push(buildGroup(group.sub, options)); + } + + if (group.sup) { + children.push(buildGroup(group.sup, options)); + } + + var nodeType; + + if (isBrace) { + nodeType = isOver ? "mover" : "munder"; + } else if (!group.sub) { + var base = group.base; + + if (base && base.type === "op" && base.limits && (options.style === Style$1$1.DISPLAY || base.alwaysHandleSupSub)) { + nodeType = "mover"; + } else if (base && base.type === "operatorname" && base.alwaysHandleSupSub && (base.limits || options.style === Style$1$1.DISPLAY)) { + nodeType = "mover"; + } else { + nodeType = "msup"; + } + } else if (!group.sup) { + var _base = group.base; + + if (_base && _base.type === "op" && _base.limits && (options.style === Style$1$1.DISPLAY || _base.alwaysHandleSupSub)) { + nodeType = "munder"; + } else if (_base && _base.type === "operatorname" && _base.alwaysHandleSupSub && (_base.limits || options.style === Style$1$1.DISPLAY)) { + nodeType = "munder"; + } else { + nodeType = "msub"; + } + } else { + var _base2 = group.base; + + if (_base2 && _base2.type === "op" && _base2.limits && options.style === Style$1$1.DISPLAY) { + nodeType = "munderover"; + } else if (_base2 && _base2.type === "operatorname" && _base2.alwaysHandleSupSub && (options.style === Style$1$1.DISPLAY || _base2.limits)) { + nodeType = "munderover"; + } else { + nodeType = "msubsup"; + } + } + + return new mathMLTree.MathNode(nodeType, children); + } + +}); + +defineFunctionBuilders({ + type: "atom", + + htmlBuilder(group, options) { + return buildCommon.mathsym(group.text, group.mode, options, ["m" + group.family]); + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mo", [makeText(group.text, group.mode)]); + + if (group.family === "bin") { + var variant = getVariant(group, options); + + if (variant === "bold-italic") { + node.setAttribute("mathvariant", variant); + } + } else if (group.family === "punct") { + node.setAttribute("separator", "true"); + } else if (group.family === "open" || group.family === "close") { + // Delims built here should not stretch vertically. + // See delimsizing.js for stretchy delims. + node.setAttribute("stretchy", "false"); + } + + return node; + } + +}); + +// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in +// src/symbols.js. +var defaultVariant = { + "mi": "italic", + "mn": "normal", + "mtext": "normal" +}; +defineFunctionBuilders({ + type: "mathord", + + htmlBuilder(group, options) { + return buildCommon.makeOrd(group, options, "mathord"); + }, + + mathmlBuilder(group, options) { + var node = new mathMLTree.MathNode("mi", [makeText(group.text, group.mode, options)]); + var variant = getVariant(group, options) || "italic"; + + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + + return node; + } + +}); +defineFunctionBuilders({ + type: "textord", + + htmlBuilder(group, options) { + return buildCommon.makeOrd(group, options, "textord"); + }, + + mathmlBuilder(group, options) { + var text = makeText(group.text, group.mode, options); + var variant = getVariant(group, options) || "normal"; + var node; + + if (group.mode === 'text') { + node = new mathMLTree.MathNode("mtext", [text]); + } else if (/[0-9]/.test(group.text)) { + node = new mathMLTree.MathNode("mn", [text]); + } else if (group.text === "\\prime") { + node = new mathMLTree.MathNode("mo", [text]); + } else { + node = new mathMLTree.MathNode("mi", [text]); + } + + if (variant !== defaultVariant[node.type]) { + node.setAttribute("mathvariant", variant); + } + + return node; + } + +}); + +var cssSpace = { + "\\nobreak": "nobreak", + "\\allowbreak": "allowbreak" +}; // A lookup table to determine whether a spacing function/symbol should be +// treated like a regular space character. If a symbol or command is a key +// in this table, then it should be a regular space character. Furthermore, +// the associated value may have a `className` specifying an extra CSS class +// to add to the created `span`. + +var regularSpace = { + " ": {}, + "\\ ": {}, + "~": { + className: "nobreak" + }, + "\\space": {}, + "\\nobreakspace": { + className: "nobreak" + } +}; // ParseNode<"spacing"> created in Parser.js from the "spacing" symbol Groups in +// src/symbols.js. + +defineFunctionBuilders({ + type: "spacing", + + htmlBuilder(group, options) { + if (regularSpace.hasOwnProperty(group.text)) { + var className = regularSpace[group.text].className || ""; // Spaces are generated by adding an actual space. Each of these + // things has an entry in the symbols table, so these will be turned + // into appropriate outputs. + + if (group.mode === "text") { + var ord = buildCommon.makeOrd(group, options, "textord"); + ord.classes.push(className); + return ord; + } else { + return buildCommon.makeSpan(["mspace", className], [buildCommon.mathsym(group.text, group.mode, options)], options); + } + } else if (cssSpace.hasOwnProperty(group.text)) { + // Spaces based on just a CSS class. + return buildCommon.makeSpan(["mspace", cssSpace[group.text]], [], options); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + }, + + mathmlBuilder(group, options) { + var node; + + if (regularSpace.hasOwnProperty(group.text)) { + node = new mathMLTree.MathNode("mtext", [new mathMLTree.TextNode("\u00a0")]); + } else if (cssSpace.hasOwnProperty(group.text)) { + // CSS-based MathML spaces (\nobreak, \allowbreak) are ignored + return new mathMLTree.MathNode("mspace"); + } else { + throw new ParseError("Unknown type of space \"" + group.text + "\""); + } + + return node; + } + +}); + +var pad$1 = () => { + var padNode = new mathMLTree.MathNode("mtd", []); + padNode.setAttribute("width", "50%"); + return padNode; +}; + +defineFunctionBuilders({ + type: "tag", + + mathmlBuilder(group, options) { + var table = new mathMLTree.MathNode("mtable", [new mathMLTree.MathNode("mtr", [pad$1(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.body, options)]), pad$1(), new mathMLTree.MathNode("mtd", [buildExpressionRow(group.tag, options)])])]); + table.setAttribute("width", "100%"); + return table; // TODO: Left-aligned tags. + // Currently, the group and options passed here do not contain + // enough info to set tag alignment. `leqno` is in Settings but it is + // not passed to Options. On the HTML side, leqno is + // set by a CSS class applied in buildTree.js. That would have worked + // in MathML if browsers supported . Since they don't, we + // need to rewrite the way this function is called. + } + +}); + +var textFontFamilies = { + "\\text": undefined, + "\\textrm": "textrm", + "\\textsf": "textsf", + "\\texttt": "texttt", + "\\textnormal": "textrm" +}; +var textFontWeights = { + "\\textbf": "textbf", + "\\textmd": "textmd" +}; +var textFontShapes = { + "\\textit": "textit", + "\\textup": "textup" +}; + +var optionsWithFont = (group, options) => { + var font = group.font; // Checks if the argument is a font family or a font style. + + if (!font) { + return options; + } else if (textFontFamilies[font]) { + return options.withTextFontFamily(textFontFamilies[font]); + } else if (textFontWeights[font]) { + return options.withTextFontWeight(textFontWeights[font]); + } else { + return options.withTextFontShape(textFontShapes[font]); + } +}; + +defineFunction({ + type: "text", + names: [// Font families + "\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal", // Font weights + "\\textbf", "\\textmd", // Font Shapes + "\\textit", "\\textup"], + props: { + numArgs: 1, + argTypes: ["text"], + allowedInArgument: true, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser, + funcName + } = _ref; + var body = args[0]; + return { + type: "text", + mode: parser.mode, + body: ordargument(body), + font: funcName + }; + }, + + htmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + var inner = buildExpression$1(group.body, newOptions, true); + return buildCommon.makeSpan(["mord", "text"], inner, newOptions); + }, + + mathmlBuilder(group, options) { + var newOptions = optionsWithFont(group, options); + return buildExpressionRow(group.body, newOptions); + } + +}); + +defineFunction({ + type: "underline", + names: ["\\underline"], + props: { + numArgs: 1, + allowedInText: true + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "underline", + mode: parser.mode, + body: args[0] + }; + }, + + htmlBuilder(group, options) { + // Underlines are handled in the TeXbook pg 443, Rule 10. + // Build the inner group. + var innerGroup = buildGroup$1(group.body, options); // Create the line to go below the body + + var line = buildCommon.makeLineSpan("underline-line", options); // Generate the vlist, with the appropriate kerns + + var defaultRuleThickness = options.fontMetrics().defaultRuleThickness; + var vlist = buildCommon.makeVList({ + positionType: "top", + positionData: innerGroup.height, + children: [{ + type: "kern", + size: defaultRuleThickness + }, { + type: "elem", + elem: line + }, { + type: "kern", + size: 3 * defaultRuleThickness + }, { + type: "elem", + elem: innerGroup + }] + }, options); + return buildCommon.makeSpan(["mord", "underline"], [vlist], options); + }, + + mathmlBuilder(group, options) { + var operator = new mathMLTree.MathNode("mo", [new mathMLTree.TextNode("\u203e")]); + operator.setAttribute("stretchy", "true"); + var node = new mathMLTree.MathNode("munder", [buildGroup(group.body, options), operator]); + node.setAttribute("accentunder", "true"); + return node; + } + +}); + +defineFunction({ + type: "vcenter", + names: ["\\vcenter"], + props: { + numArgs: 1, + argTypes: ["original"], + // In LaTeX, \vcenter can act only on a box. + allowedInText: false + }, + + handler(_ref, args) { + var { + parser + } = _ref; + return { + type: "vcenter", + mode: parser.mode, + body: args[0] + }; + }, + + htmlBuilder(group, options) { + var body = buildGroup$1(group.body, options); + var axisHeight = options.fontMetrics().axisHeight; + var dy = 0.5 * (body.height - axisHeight - (body.depth + axisHeight)); + return buildCommon.makeVList({ + positionType: "shift", + positionData: dy, + children: [{ + type: "elem", + elem: body + }] + }, options); + }, + + mathmlBuilder(group, options) { + // There is no way to do this in MathML. + // Write a class as a breadcrumb in case some post-processor wants + // to perform a vcenter adjustment. + return new mathMLTree.MathNode("mpadded", [buildGroup(group.body, options)], ["vcenter"]); + } + +}); + +defineFunction({ + type: "verb", + names: ["\\verb"], + props: { + numArgs: 0, + allowedInText: true + }, + + handler(context, args, optArgs) { + // \verb and \verb* are dealt with directly in Parser.js. + // If we end up here, it's because of a failure to match the two delimiters + // in the regex in Lexer.js. LaTeX raises the following error when \verb is + // terminated by end of line (or file). + throw new ParseError("\\verb ended by end of line instead of matching delimiter"); + }, + + htmlBuilder(group, options) { + var text = makeVerb(group); + var body = []; // \verb enters text mode and therefore is sized like \textstyle + + var newOptions = options.havingStyle(options.style.text()); + + for (var i = 0; i < text.length; i++) { + var c = text[i]; + + if (c === '~') { + c = '\\textasciitilde'; + } + + body.push(buildCommon.makeSymbol(c, "Typewriter-Regular", group.mode, newOptions, ["mord", "texttt"])); + } + + return buildCommon.makeSpan(["mord", "text"].concat(newOptions.sizingClasses(options)), buildCommon.tryCombineChars(body), newOptions); + }, + + mathmlBuilder(group, options) { + var text = new mathMLTree.TextNode(makeVerb(group)); + var node = new mathMLTree.MathNode("mtext", [text]); + node.setAttribute("mathvariant", "monospace"); + return node; + } + +}); +/** + * Converts verb group into body string. + * + * \verb* replaces each space with an open box \u2423 + * \verb replaces each space with a no-break space \xA0 + */ + +var makeVerb = group => group.body.replace(/ /g, group.star ? '\u2423' : '\xA0'); + +/** Include this to ensure that all functions are defined. */ +var functions$1 = _functions; + +/** + * The Lexer class handles tokenizing the input in various ways. Since our + * parser expects us to be able to backtrack, the lexer allows lexing from any + * given starting point. + * + * Its main exposed function is the `lex` function, which takes a position to + * lex from and a type of token to lex. It defers to the appropriate `_innerLex` + * function. + * + * The various `_innerLex` functions perform the actual lexing of different + * kinds. + */ + +/* The following tokenRegex + * - matches typical whitespace (but not NBSP etc.) using its first group + * - does not match any control character \x00-\x1f except whitespace + * - does not match a bare backslash + * - matches any ASCII character except those just mentioned + * - does not match the BMP private use area \uE000-\uF8FF + * - does not match bare surrogate code units + * - matches any BMP character except for those just described + * - matches any valid Unicode surrogate pair + * - matches a backslash followed by one or more whitespace characters + * - matches a backslash followed by one or more letters then whitespace + * - matches a backslash followed by any BMP character + * Capturing groups: + * [1] regular whitespace + * [2] backslash followed by whitespace + * [3] anything else, which may include: + * [4] left character of \verb* + * [5] left character of \verb + * [6] backslash followed by word, excluding any trailing whitespace + * Just because the Lexer matches something doesn't mean it's valid input: + * If there is no matching function or symbol definition, the Parser will + * still reject the input. + */ +var spaceRegexString = "[ \r\n\t]"; +var controlWordRegexString = "\\\\[a-zA-Z@]+"; +var controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]"; +var controlWordWhitespaceRegexString = "(" + controlWordRegexString + ")" + spaceRegexString + "*"; +var controlSpaceRegexString = "\\\\(\n|[ \r\t]+\n?)[ \r\t]*"; +var combiningDiacriticalMarkString = "[\u0300-\u036f]"; +var combiningDiacriticalMarksEndRegex = new RegExp(combiningDiacriticalMarkString + "+$"); +var tokenRegexString = "(" + spaceRegexString + "+)|" + ( // whitespace +controlSpaceRegexString + "|") + // \whitespace +"([!-\\[\\]-\u2027\u202A-\uD7FF\uF900-\uFFFF]" + ( // single codepoint +combiningDiacriticalMarkString + "*") + // ...plus accents +"|[\uD800-\uDBFF][\uDC00-\uDFFF]" + ( // surrogate pair +combiningDiacriticalMarkString + "*") + // ...plus accents +"|\\\\verb\\*([^]).*?\\4" + // \verb* +"|\\\\verb([^*a-zA-Z]).*?\\5" + ( // \verb unstarred +"|" + controlWordWhitespaceRegexString) + ( // \macroName + spaces +"|" + controlSymbolRegexString + ")"); // \\, \', etc. + +/** Main Lexer class */ + +class Lexer { + // Category codes. The lexer only supports comment characters (14) for now. + // MacroExpander additionally distinguishes active (13). + constructor(input, settings) { + this.input = void 0; + this.settings = void 0; + this.tokenRegex = void 0; + this.catcodes = void 0; + // Separate accents from characters + this.input = input; + this.settings = settings; + this.tokenRegex = new RegExp(tokenRegexString, 'g'); + this.catcodes = { + "%": 14, + // comment character + "~": 13 // active character + + }; + } + + setCatcode(char, code) { + this.catcodes[char] = code; + } + /** + * This function lexes a single token. + */ + + + lex() { + var input = this.input; + var pos = this.tokenRegex.lastIndex; + + if (pos === input.length) { + return new Token("EOF", new SourceLocation(this, pos, pos)); + } + + var match = this.tokenRegex.exec(input); + + if (match === null || match.index !== pos) { + throw new ParseError("Unexpected character: '" + input[pos] + "'", new Token(input[pos], new SourceLocation(this, pos, pos + 1))); + } + + var text = match[6] || match[3] || (match[2] ? "\\ " : " "); + + if (this.catcodes[text] === 14) { + // comment character + var nlIndex = input.indexOf('\n', this.tokenRegex.lastIndex); + + if (nlIndex === -1) { + this.tokenRegex.lastIndex = input.length; // EOF + + this.settings.reportNonstrict("commentAtEnd", "% comment has no terminating newline; LaTeX would " + "fail because of commenting the end of math mode (e.g. $)"); + } else { + this.tokenRegex.lastIndex = nlIndex + 1; + } + + return this.lex(); + } + + return new Token(text, new SourceLocation(this, pos, this.tokenRegex.lastIndex)); + } + +} + +/** + * A `Namespace` refers to a space of nameable things like macros or lengths, + * which can be `set` either globally or local to a nested group, using an + * undo stack similar to how TeX implements this functionality. + * Performance-wise, `get` and local `set` take constant time, while global + * `set` takes time proportional to the depth of group nesting. + */ +class Namespace { + /** + * Both arguments are optional. The first argument is an object of + * built-in mappings which never change. The second argument is an object + * of initial (global-level) mappings, which will constantly change + * according to any global/top-level `set`s done. + */ + constructor(builtins, globalMacros) { + if (builtins === void 0) { + builtins = {}; + } + + if (globalMacros === void 0) { + globalMacros = {}; + } + + this.current = void 0; + this.builtins = void 0; + this.undefStack = void 0; + this.current = globalMacros; + this.builtins = builtins; + this.undefStack = []; + } + /** + * Start a new nested group, affecting future local `set`s. + */ + + + beginGroup() { + this.undefStack.push({}); + } + /** + * End current nested group, restoring values before the group began. + */ + + + endGroup() { + if (this.undefStack.length === 0) { + throw new ParseError("Unbalanced namespace destruction: attempt " + "to pop global namespace; please report this as a bug"); + } + + var undefs = this.undefStack.pop(); + + for (var undef in undefs) { + if (undefs.hasOwnProperty(undef)) { + if (undefs[undef] == null) { + delete this.current[undef]; + } else { + this.current[undef] = undefs[undef]; + } + } + } + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + while (this.undefStack.length > 0) { + this.endGroup(); + } + } + /** + * Detect whether `name` has a definition. Equivalent to + * `get(name) != null`. + */ + + + has(name) { + return this.current.hasOwnProperty(name) || this.builtins.hasOwnProperty(name); + } + /** + * Get the current value of a name, or `undefined` if there is no value. + * + * Note: Do not use `if (namespace.get(...))` to detect whether a macro + * is defined, as the definition may be the empty string which evaluates + * to `false` in JavaScript. Use `if (namespace.get(...) != null)` or + * `if (namespace.has(...))`. + */ + + + get(name) { + if (this.current.hasOwnProperty(name)) { + return this.current[name]; + } else { + return this.builtins[name]; + } + } + /** + * Set the current value of a name, and optionally set it globally too. + * Local set() sets the current value and (when appropriate) adds an undo + * operation to the undo stack. Global set() may change the undo + * operation at every level, so takes time linear in their number. + * A value of undefined means to delete existing definitions. + */ + + + set(name, value, global) { + if (global === void 0) { + global = false; + } + + if (global) { + // Global set is equivalent to setting in all groups. Simulate this + // by destroying any undos currently scheduled for this name, + // and adding an undo with the *new* value (in case it later gets + // locally reset within this environment). + for (var i = 0; i < this.undefStack.length; i++) { + delete this.undefStack[i][name]; + } + + if (this.undefStack.length > 0) { + this.undefStack[this.undefStack.length - 1][name] = value; + } + } else { + // Undo this set at end of this group (possibly to `undefined`), + // unless an undo is already in place, in which case that older + // value is the correct one. + var top = this.undefStack[this.undefStack.length - 1]; + + if (top && !top.hasOwnProperty(name)) { + top[name] = this.current[name]; + } + } + + if (value == null) { + delete this.current[name]; + } else { + this.current[name] = value; + } + } + +} + +/** + * Predefined macros for KaTeX. + * This can be used to define some commands in terms of others. + */ +var macros = _macros; +// macro tools + +defineMacro("\\noexpand", function (context) { + // The expansion is the token itself; but that token is interpreted + // as if its meaning were ‘\relax’ if it is a control sequence that + // would ordinarily be expanded by TeX’s expansion rules. + var t = context.popToken(); + + if (context.isExpandable(t.text)) { + t.noexpand = true; + t.treatAsRelax = true; + } + + return { + tokens: [t], + numArgs: 0 + }; +}); +defineMacro("\\expandafter", function (context) { + // TeX first reads the token that comes immediately after \expandafter, + // without expanding it; let’s call this token t. Then TeX reads the + // token that comes after t (and possibly more tokens, if that token + // has an argument), replacing it by its expansion. Finally TeX puts + // t back in front of that expansion. + var t = context.popToken(); + context.expandOnce(true); // expand only an expandable token + + return { + tokens: [t], + numArgs: 0 + }; +}); // LaTeX's \@firstoftwo{#1}{#2} expands to #1, skipping #2 +// TeX source: \long\def\@firstoftwo#1#2{#1} + +defineMacro("\\@firstoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[0], + numArgs: 0 + }; +}); // LaTeX's \@secondoftwo{#1}{#2} expands to #2, skipping #1 +// TeX source: \long\def\@secondoftwo#1#2{#2} + +defineMacro("\\@secondoftwo", function (context) { + var args = context.consumeArgs(2); + return { + tokens: args[1], + numArgs: 0 + }; +}); // LaTeX's \@ifnextchar{#1}{#2}{#3} looks ahead to the next (unexpanded) +// symbol that isn't a space, consuming any spaces but not consuming the +// first nonspace character. If that nonspace character matches #1, then +// the macro expands to #2; otherwise, it expands to #3. + +defineMacro("\\@ifnextchar", function (context) { + var args = context.consumeArgs(3); // symbol, if, else + + context.consumeSpaces(); + var nextToken = context.future(); + + if (args[0].length === 1 && args[0][0].text === nextToken.text) { + return { + tokens: args[1], + numArgs: 0 + }; + } else { + return { + tokens: args[2], + numArgs: 0 + }; + } +}); // LaTeX's \@ifstar{#1}{#2} looks ahead to the next (unexpanded) symbol. +// If it is `*`, then it consumes the symbol, and the macro expands to #1; +// otherwise, the macro expands to #2 (without consuming the symbol). +// TeX source: \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} + +defineMacro("\\@ifstar", "\\@ifnextchar *{\\@firstoftwo{#1}}"); // LaTeX's \TextOrMath{#1}{#2} expands to #1 in text mode, #2 in math mode + +defineMacro("\\TextOrMath", function (context) { + var args = context.consumeArgs(2); + + if (context.mode === 'text') { + return { + tokens: args[0], + numArgs: 0 + }; + } else { + return { + tokens: args[1], + numArgs: 0 + }; + } +}); // Lookup table for parsing numbers in base 8 through 16 + +var digitToNumber = { + "0": 0, + "1": 1, + "2": 2, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7, + "8": 8, + "9": 9, + "a": 10, + "A": 10, + "b": 11, + "B": 11, + "c": 12, + "C": 12, + "d": 13, + "D": 13, + "e": 14, + "E": 14, + "f": 15, + "F": 15 +}; // TeX \char makes a literal character (catcode 12) using the following forms: +// (see The TeXBook, p. 43) +// \char123 -- decimal +// \char'123 -- octal +// \char"123 -- hex +// \char`x -- character that can be written (i.e. isn't active) +// \char`\x -- character that cannot be written (e.g. %) +// These all refer to characters from the font, so we turn them into special +// calls to a function \@char dealt with in the Parser. + +defineMacro("\\char", function (context) { + var token = context.popToken(); + var base; + var number = ''; + + if (token.text === "'") { + base = 8; + token = context.popToken(); + } else if (token.text === '"') { + base = 16; + token = context.popToken(); + } else if (token.text === "`") { + token = context.popToken(); + + if (token.text[0] === "\\") { + number = token.text.charCodeAt(1); + } else if (token.text === "EOF") { + throw new ParseError("\\char` missing argument"); + } else { + number = token.text.charCodeAt(0); + } + } else { + base = 10; + } + + if (base) { + // Parse a number in the given base, starting with first `token`. + number = digitToNumber[token.text]; + + if (number == null || number >= base) { + throw new ParseError("Invalid base-" + base + " digit " + token.text); + } + + var digit; + + while ((digit = digitToNumber[context.future().text]) != null && digit < base) { + number *= base; + number += digit; + context.popToken(); + } + } + + return "\\@char{" + number + "}"; +}); // \newcommand{\macro}[args]{definition} +// \renewcommand{\macro}[args]{definition} +// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition} + +var newcommand = (context, existsOK, nonexistsOK) => { + var arg = context.consumeArg().tokens; + + if (arg.length !== 1) { + throw new ParseError("\\newcommand's first argument must be a macro name"); + } + + var name = arg[0].text; + var exists = context.isDefined(name); + + if (exists && !existsOK) { + throw new ParseError("\\newcommand{" + name + "} attempting to redefine " + (name + "; use \\renewcommand")); + } + + if (!exists && !nonexistsOK) { + throw new ParseError("\\renewcommand{" + name + "} when command " + name + " " + "does not yet exist; use \\newcommand"); + } + + var numArgs = 0; + arg = context.consumeArg().tokens; + + if (arg.length === 1 && arg[0].text === "[") { + var argText = ''; + var token = context.expandNextToken(); + + while (token.text !== "]" && token.text !== "EOF") { + // TODO: Should properly expand arg, e.g., ignore {}s + argText += token.text; + token = context.expandNextToken(); + } + + if (!argText.match(/^\s*[0-9]+\s*$/)) { + throw new ParseError("Invalid number of arguments: " + argText); + } + + numArgs = parseInt(argText); + arg = context.consumeArg().tokens; + } // Final arg is the expansion of the macro + + + context.macros.set(name, { + tokens: arg, + numArgs + }); + return ''; +}; + +defineMacro("\\newcommand", context => newcommand(context, false, true)); +defineMacro("\\renewcommand", context => newcommand(context, true, false)); +defineMacro("\\providecommand", context => newcommand(context, true, true)); // terminal (console) tools + +defineMacro("\\message", context => { + var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.log(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\errmessage", context => { + var arg = context.consumeArgs(1)[0]; // eslint-disable-next-line no-console + + console.error(arg.reverse().map(token => token.text).join("")); + return ''; +}); +defineMacro("\\show", context => { + var tok = context.popToken(); + var name = tok.text; // eslint-disable-next-line no-console + + console.log(tok, context.macros.get(name), functions$1[name], symbols.math[name], symbols.text[name]); + return ''; +}); ////////////////////////////////////////////////////////////////////// +// Grouping +// \let\bgroup={ \let\egroup=} + +defineMacro("\\bgroup", "{"); +defineMacro("\\egroup", "}"); // Symbols from latex.ltx: +// \def~{\nobreakspace{}} +// \def\lq{`} +// \def\rq{'} +// \def \aa {\r a} +// \def \AA {\r A} + +defineMacro("~", "\\nobreakspace"); +defineMacro("\\lq", "`"); +defineMacro("\\rq", "'"); +defineMacro("\\aa", "\\r a"); +defineMacro("\\AA", "\\r A"); // Copyright (C) and registered (R) symbols. Use raw symbol in MathML. +// \DeclareTextCommandDefault{\textcopyright}{\textcircled{c}} +// \DeclareTextCommandDefault{\textregistered}{\textcircled{% +// \check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont R}} +// \DeclareRobustCommand{\copyright}{% +// \ifmmode{\nfss@text{\textcopyright}}\else\textcopyright\fi} + +defineMacro("\\textcopyright", "\\html@mathml{\\textcircled{c}}{\\char`©}"); +defineMacro("\\copyright", "\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"); +defineMacro("\\textregistered", "\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"); // Characters omitted from Unicode range 1D400–1D7FF + +defineMacro("\u212C", "\\mathscr{B}"); // script + +defineMacro("\u2130", "\\mathscr{E}"); +defineMacro("\u2131", "\\mathscr{F}"); +defineMacro("\u210B", "\\mathscr{H}"); +defineMacro("\u2110", "\\mathscr{I}"); +defineMacro("\u2112", "\\mathscr{L}"); +defineMacro("\u2133", "\\mathscr{M}"); +defineMacro("\u211B", "\\mathscr{R}"); +defineMacro("\u212D", "\\mathfrak{C}"); // Fraktur + +defineMacro("\u210C", "\\mathfrak{H}"); +defineMacro("\u2128", "\\mathfrak{Z}"); // Define \Bbbk with a macro that works in both HTML and MathML. + +defineMacro("\\Bbbk", "\\Bbb{k}"); // Unicode middle dot +// The KaTeX fonts do not contain U+00B7. Instead, \cdotp displays +// the dot at U+22C5 and gives it punct spacing. + +defineMacro("\u00b7", "\\cdotp"); // \llap and \rlap render their contents in text mode + +defineMacro("\\llap", "\\mathllap{\\textrm{#1}}"); +defineMacro("\\rlap", "\\mathrlap{\\textrm{#1}}"); +defineMacro("\\clap", "\\mathclap{\\textrm{#1}}"); // \mathstrut from the TeXbook, p 360 + +defineMacro("\\mathstrut", "\\vphantom{(}"); // \underbar from TeXbook p 353 + +defineMacro("\\underbar", "\\underline{\\text{#1}}"); // \not is defined by base/fontmath.ltx via +// \DeclareMathSymbol{\not}{\mathrel}{symbols}{"36} +// It's thus treated like a \mathrel, but defined by a symbol that has zero +// width but extends to the right. We use \rlap to get that spacing. +// For MathML we write U+0338 here. buildMathML.js will then do the overlay. + +defineMacro("\\not", '\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'); // Negated symbols from base/fontmath.ltx: +// \def\neq{\not=} \let\ne=\neq +// \DeclareRobustCommand +// \notin{\mathrel{\m@th\mathpalette\c@ncel\in}} +// \def\c@ncel#1#2{\m@th\ooalign{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}} + +defineMacro("\\neq", "\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"); +defineMacro("\\ne", "\\neq"); +defineMacro("\u2260", "\\neq"); +defineMacro("\\notin", "\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}" + "{\\mathrel{\\char`∉}}"); +defineMacro("\u2209", "\\notin"); // Unicode stacked relations + +defineMacro("\u2258", "\\html@mathml{" + "\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}" + "}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u2259", "\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"); +defineMacro("\u225A", "\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225A}}"); +defineMacro("\u225B", "\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}" + "{\\mathrel{\\char`\u225B}}"); +defineMacro("\u225D", "\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}" + "{\\mathrel{\\char`\u225D}}"); +defineMacro("\u225E", "\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}" + "{\\mathrel{\\char`\u225E}}"); +defineMacro("\u225F", "\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225F}}"); // Misc Unicode + +defineMacro("\u27C2", "\\perp"); +defineMacro("\u203C", "\\mathclose{!\\mkern-0.8mu!}"); +defineMacro("\u220C", "\\notni"); +defineMacro("\u231C", "\\ulcorner"); +defineMacro("\u231D", "\\urcorner"); +defineMacro("\u231E", "\\llcorner"); +defineMacro("\u231F", "\\lrcorner"); +defineMacro("\u00A9", "\\copyright"); +defineMacro("\u00AE", "\\textregistered"); +defineMacro("\uFE0F", "\\textregistered"); // The KaTeX fonts have corners at codepoints that don't match Unicode. +// For MathML purposes, use the Unicode code point. + +defineMacro("\\ulcorner", "\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"); +defineMacro("\\urcorner", "\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"); +defineMacro("\\llcorner", "\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"); +defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"); ////////////////////////////////////////////////////////////////////// +// LaTeX_2ε +// \vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ +// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}} +// We'll call \varvdots, which gets a glyph from symbols.js. +// The zero-width rule gets us an equivalent to the vertical 6pt kern. + +defineMacro("\\vdots", "\\mathord{\\varvdots\\rule{0pt}{15pt}}"); +defineMacro("\u22ee", "\\vdots"); ////////////////////////////////////////////////////////////////////// +// amsmath.sty +// http://mirrors.concertpass.com/tex-archive/macros/latex/required/amsmath/amsmath.pdf +// Italic Greek capital letters. AMS defines these with \DeclareMathSymbol, +// but they are equivalent to \mathit{\Letter}. + +defineMacro("\\varGamma", "\\mathit{\\Gamma}"); +defineMacro("\\varDelta", "\\mathit{\\Delta}"); +defineMacro("\\varTheta", "\\mathit{\\Theta}"); +defineMacro("\\varLambda", "\\mathit{\\Lambda}"); +defineMacro("\\varXi", "\\mathit{\\Xi}"); +defineMacro("\\varPi", "\\mathit{\\Pi}"); +defineMacro("\\varSigma", "\\mathit{\\Sigma}"); +defineMacro("\\varUpsilon", "\\mathit{\\Upsilon}"); +defineMacro("\\varPhi", "\\mathit{\\Phi}"); +defineMacro("\\varPsi", "\\mathit{\\Psi}"); +defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray} + +defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript +// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax} + +defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} + +defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;} +// \def\implies{\DOTSB\;\Longrightarrow\;} +// \def\impliedby{\DOTSB\;\Longleftarrow\;} + +defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;"); +defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;"); +defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;"); // AMSMath's automatic \dots, based on \mdots@@ macro. + +var dotsByToken = { + ',': '\\dotsc', + '\\not': '\\dotsb', + // \keybin@ checks for the following: + '+': '\\dotsb', + '=': '\\dotsb', + '<': '\\dotsb', + '>': '\\dotsb', + '-': '\\dotsb', + '*': '\\dotsb', + ':': '\\dotsb', + // Symbols whose definition starts with \DOTSB: + '\\DOTSB': '\\dotsb', + '\\coprod': '\\dotsb', + '\\bigvee': '\\dotsb', + '\\bigwedge': '\\dotsb', + '\\biguplus': '\\dotsb', + '\\bigcap': '\\dotsb', + '\\bigcup': '\\dotsb', + '\\prod': '\\dotsb', + '\\sum': '\\dotsb', + '\\bigotimes': '\\dotsb', + '\\bigoplus': '\\dotsb', + '\\bigodot': '\\dotsb', + '\\bigsqcup': '\\dotsb', + '\\And': '\\dotsb', + '\\longrightarrow': '\\dotsb', + '\\Longrightarrow': '\\dotsb', + '\\longleftarrow': '\\dotsb', + '\\Longleftarrow': '\\dotsb', + '\\longleftrightarrow': '\\dotsb', + '\\Longleftrightarrow': '\\dotsb', + '\\mapsto': '\\dotsb', + '\\longmapsto': '\\dotsb', + '\\hookrightarrow': '\\dotsb', + '\\doteq': '\\dotsb', + // Symbols whose definition starts with \mathbin: + '\\mathbin': '\\dotsb', + // Symbols whose definition starts with \mathrel: + '\\mathrel': '\\dotsb', + '\\relbar': '\\dotsb', + '\\Relbar': '\\dotsb', + '\\xrightarrow': '\\dotsb', + '\\xleftarrow': '\\dotsb', + // Symbols whose definition starts with \DOTSI: + '\\DOTSI': '\\dotsi', + '\\int': '\\dotsi', + '\\oint': '\\dotsi', + '\\iint': '\\dotsi', + '\\iiint': '\\dotsi', + '\\iiiint': '\\dotsi', + '\\idotsint': '\\dotsi', + // Symbols whose definition starts with \DOTSX: + '\\DOTSX': '\\dotsx' +}; +defineMacro("\\dots", function (context) { + // TODO: If used in text mode, should expand to \textellipsis. + // However, in KaTeX, \textellipsis and \ldots behave the same + // (in text mode), and it's unlikely we'd see any of the math commands + // that affect the behavior of \dots when in text mode. So fine for now + // (until we support \ifmmode ... \else ... \fi). + var thedots = '\\dotso'; + var next = context.expandAfterFuture().text; + + if (next in dotsByToken) { + thedots = dotsByToken[next]; + } else if (next.slice(0, 4) === '\\not') { + thedots = '\\dotsb'; + } else if (next in symbols.math) { + if (utils$1.contains(['bin', 'rel'], symbols.math[next].group)) { + thedots = '\\dotsb'; + } + } + + return thedots; +}); +var spaceAfterDots = { + // \rightdelim@ checks for the following: + ')': true, + ']': true, + '\\rbrack': true, + '\\}': true, + '\\rbrace': true, + '\\rangle': true, + '\\rceil': true, + '\\rfloor': true, + '\\rgroup': true, + '\\rmoustache': true, + '\\right': true, + '\\bigr': true, + '\\biggr': true, + '\\Bigr': true, + '\\Biggr': true, + // \extra@ also tests for the following: + '$': true, + // \extrap@ checks for the following: + ';': true, + '.': true, + ',': true +}; +defineMacro("\\dotso", function (context) { + var next = context.future().text; + + if (next in spaceAfterDots) { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\dotsc", function (context) { + var next = context.future().text; // \dotsc uses \extra@ but not \extrap@, instead specially checking for + // ';' and '.', but doesn't check for ','. + + if (next in spaceAfterDots && next !== ',') { + return "\\ldots\\,"; + } else { + return "\\ldots"; + } +}); +defineMacro("\\cdots", function (context) { + var next = context.future().text; + + if (next in spaceAfterDots) { + return "\\@cdots\\,"; + } else { + return "\\@cdots"; + } +}); +defineMacro("\\dotsb", "\\cdots"); +defineMacro("\\dotsm", "\\cdots"); +defineMacro("\\dotsi", "\\!\\cdots"); // amsmath doesn't actually define \dotsx, but \dots followed by a macro +// starting with \DOTSX implies \dotso, and then \extra@ detects this case +// and forces the added `\,`. + +defineMacro("\\dotsx", "\\ldots\\,"); // \let\DOTSI\relax +// \let\DOTSB\relax +// \let\DOTSX\relax + +defineMacro("\\DOTSI", "\\relax"); +defineMacro("\\DOTSB", "\\relax"); +defineMacro("\\DOTSX", "\\relax"); // Spacing, based on amsmath.sty's override of LaTeX defaults +// \DeclareRobustCommand{\tmspace}[3]{% +// \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} + +defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); // \renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip + +defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); // \let\thinspace\, + +defineMacro("\\thinspace", "\\,"); // \def\>{\mskip\medmuskip} +// \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu + +defineMacro("\\>", "\\mskip{4mu}"); +defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); // \let\medspace\: + +defineMacro("\\medspace", "\\:"); // \renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip = 5mu plus 5mu + +defineMacro("\\;", "\\tmspace+{5mu}{.2777em}"); // \let\thickspace\; + +defineMacro("\\thickspace", "\\;"); // \renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +// TODO: math mode should use \thinmuskip + +defineMacro("\\!", "\\tmspace-{3mu}{.1667em}"); // \let\negthinspace\! + +defineMacro("\\negthinspace", "\\!"); // \newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +// TODO: math mode should use \medmuskip + +defineMacro("\\negmedspace", "\\tmspace-{4mu}{.2222em}"); // \newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +// TODO: math mode should use \thickmuskip + +defineMacro("\\negthickspace", "\\tmspace-{5mu}{.277em}"); // \def\enspace{\kern.5em } + +defineMacro("\\enspace", "\\kern.5em "); // \def\enskip{\hskip.5em\relax} + +defineMacro("\\enskip", "\\hskip.5em\\relax"); // \def\quad{\hskip1em\relax} + +defineMacro("\\quad", "\\hskip1em\\relax"); // \def\qquad{\hskip2em\relax} + +defineMacro("\\qquad", "\\hskip2em\\relax"); // \tag@in@display form of \tag + +defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren"); +defineMacro("\\tag@paren", "\\tag@literal{({#1})}"); +defineMacro("\\tag@literal", context => { + if (context.macros.get("\\df@tag")) { + throw new ParseError("Multiple \\tag"); + } + + return "\\gdef\\df@tag{\\text{#1}}"; +}); // \renewcommand{\bmod}{\nonscript\mskip-\medmuskip\mkern5mu\mathbin +// {\operator@font mod}\penalty900 +// \mkern5mu\nonscript\mskip-\medmuskip} +// \newcommand{\pod}[1]{\allowbreak +// \if@display\mkern18mu\else\mkern8mu\fi(#1)} +// \renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}} +// \newcommand{\mod}[1]{\allowbreak\if@display\mkern18mu +// \else\mkern12mu\fi{\operator@font mod}\,\,#1} +// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu + +defineMacro("\\bmod", "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}" + "\\mathbin{\\rm mod}" + "\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"); +defineMacro("\\pod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"); +defineMacro("\\pmod", "\\pod{{\\rm mod}\\mkern6mu#1}"); +defineMacro("\\mod", "\\allowbreak" + "\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}" + "{\\rm mod}\\,\\,#1"); ////////////////////////////////////////////////////////////////////// +// LaTeX source2e +// \expandafter\let\expandafter\@normalcr +// \csname\expandafter\@gobble\string\\ \endcsname +// \DeclareRobustCommand\newline{\@normalcr\relax} + +defineMacro("\\newline", "\\\\\\relax"); // \def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX\@} +// TODO: Doesn't normally work in math mode because \@ fails. KaTeX doesn't +// support \@ yet, so that's omitted, and we add \text so that the result +// doesn't look funny in math mode. + +defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX" + "}{TeX}}"); // \DeclareRobustCommand{\LaTeX}{L\kern-.36em% +// {\sbox\z@ T% +// \vbox to\ht\z@{\hbox{\check@mathfonts +// \fontsize\sf@size\z@ +// \math@fontsfalse\selectfont +// A}% +// \vss}% +// }% +// \kern-.15em% +// \TeX} +// This code aligns the top of the A with the T (from the perspective of TeX's +// boxes, though visually the A appears to extend above slightly). +// We compute the corresponding \raisebox when A is rendered in \normalsize +// \scriptstyle, which has a scale factor of 0.7 (see Options.js). + +var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]); +defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo + +defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace} +// \def\@hspace#1{\hskip #1\relax} +// \def\@hspacer#1{\vrule \@width\z@\nobreak +// \hskip #1\hskip \z@skip} + +defineMacro("\\hspace", "\\@ifstar\\@hspacer\\@hspace"); +defineMacro("\\@hspace", "\\hskip #1\\relax"); +defineMacro("\\@hspacer", "\\rule{0pt}{0pt}\\hskip #1\\relax"); ////////////////////////////////////////////////////////////////////// +// mathtools.sty +//\providecommand\ordinarycolon{:} + +defineMacro("\\ordinarycolon", ":"); //\def\vcentcolon{\mathrel{\mathop\ordinarycolon}} +//TODO(edemaine): Not yet centered. Fix via \raisebox or #726 + +defineMacro("\\vcentcolon", "\\mathrel{\\mathop\\ordinarycolon}"); // \providecommand*\dblcolon{\vcentcolon\mathrel{\mkern-.9mu}\vcentcolon} + +defineMacro("\\dblcolon", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}" + "{\\mathop{\\char\"2237}}"); // \providecommand*\coloneqq{\vcentcolon\mathrel{\mkern-1.2mu}=} + +defineMacro("\\coloneqq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2254}}"); // ≔ +// \providecommand*\Coloneqq{\dblcolon\mathrel{\mkern-1.2mu}=} + +defineMacro("\\Coloneqq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}" + "{\\mathop{\\char\"2237\\char\"3d}}"); // \providecommand*\coloneq{\vcentcolon\mathrel{\mkern-1.2mu}\mathrel{-}} + +defineMacro("\\coloneq", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"3a\\char\"2212}}"); // \providecommand*\Coloneq{\dblcolon\mathrel{\mkern-1.2mu}\mathrel{-}} + +defineMacro("\\Coloneq", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}" + "{\\mathop{\\char\"2237\\char\"2212}}"); // \providecommand*\eqqcolon{=\mathrel{\mkern-1.2mu}\vcentcolon} + +defineMacro("\\eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2255}}"); // ≕ +// \providecommand*\Eqqcolon{=\mathrel{\mkern-1.2mu}\dblcolon} + +defineMacro("\\Eqqcolon", "\\html@mathml{" + "\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"3d\\char\"2237}}"); // \providecommand*\eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\vcentcolon} + +defineMacro("\\eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}" + "{\\mathop{\\char\"2239}}"); // \providecommand*\Eqcolon{\mathrel{-}\mathrel{\mkern-1.2mu}\dblcolon} + +defineMacro("\\Eqcolon", "\\html@mathml{" + "\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}" + "{\\mathop{\\char\"2212\\char\"2237}}"); // \providecommand*\colonapprox{\vcentcolon\mathrel{\mkern-1.2mu}\approx} + +defineMacro("\\colonapprox", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"3a\\char\"2248}}"); // \providecommand*\Colonapprox{\dblcolon\mathrel{\mkern-1.2mu}\approx} + +defineMacro("\\Colonapprox", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}" + "{\\mathop{\\char\"2237\\char\"2248}}"); // \providecommand*\colonsim{\vcentcolon\mathrel{\mkern-1.2mu}\sim} + +defineMacro("\\colonsim", "\\html@mathml{" + "\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"3a\\char\"223c}}"); // \providecommand*\Colonsim{\dblcolon\mathrel{\mkern-1.2mu}\sim} + +defineMacro("\\Colonsim", "\\html@mathml{" + "\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}" + "{\\mathop{\\char\"2237\\char\"223c}}"); // Some Unicode characters are implemented with macros to mathtools functions. + +defineMacro("\u2237", "\\dblcolon"); // :: + +defineMacro("\u2239", "\\eqcolon"); // -: + +defineMacro("\u2254", "\\coloneqq"); // := + +defineMacro("\u2255", "\\eqqcolon"); // =: + +defineMacro("\u2A74", "\\Coloneqq"); // ::= +////////////////////////////////////////////////////////////////////// +// colonequals.sty +// Alternate names for mathtools's macros: + +defineMacro("\\ratio", "\\vcentcolon"); +defineMacro("\\coloncolon", "\\dblcolon"); +defineMacro("\\colonequals", "\\coloneqq"); +defineMacro("\\coloncolonequals", "\\Coloneqq"); +defineMacro("\\equalscolon", "\\eqqcolon"); +defineMacro("\\equalscoloncolon", "\\Eqqcolon"); +defineMacro("\\colonminus", "\\coloneq"); +defineMacro("\\coloncolonminus", "\\Coloneq"); +defineMacro("\\minuscolon", "\\eqcolon"); +defineMacro("\\minuscoloncolon", "\\Eqcolon"); // \colonapprox name is same in mathtools and colonequals. + +defineMacro("\\coloncolonapprox", "\\Colonapprox"); // \colonsim name is same in mathtools and colonequals. + +defineMacro("\\coloncolonsim", "\\Colonsim"); // Additional macros, implemented by analogy with mathtools definitions: + +defineMacro("\\simcolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\simcoloncolon", "\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"); +defineMacro("\\approxcolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"); +defineMacro("\\approxcoloncolon", "\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"); // Present in newtxmath, pxfonts and txfonts + +defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}"); +defineMacro("\\limsup", "\\DOTSB\\operatorname*{lim\\,sup}"); +defineMacro("\\liminf", "\\DOTSB\\operatorname*{lim\\,inf}"); ////////////////////////////////////////////////////////////////////// +// From amsopn.sty + +defineMacro("\\injlim", "\\DOTSB\\operatorname*{inj\\,lim}"); +defineMacro("\\projlim", "\\DOTSB\\operatorname*{proj\\,lim}"); +defineMacro("\\varlimsup", "\\DOTSB\\operatorname*{\\overline{lim}}"); +defineMacro("\\varliminf", "\\DOTSB\\operatorname*{\\underline{lim}}"); +defineMacro("\\varinjlim", "\\DOTSB\\operatorname*{\\underrightarrow{lim}}"); +defineMacro("\\varprojlim", "\\DOTSB\\operatorname*{\\underleftarrow{lim}}"); ////////////////////////////////////////////////////////////////////// +// MathML alternates for KaTeX glyphs in the Unicode private area + +defineMacro("\\gvertneqq", "\\html@mathml{\\@gvertneqq}{\u2269}"); +defineMacro("\\lvertneqq", "\\html@mathml{\\@lvertneqq}{\u2268}"); +defineMacro("\\ngeqq", "\\html@mathml{\\@ngeqq}{\u2271}"); +defineMacro("\\ngeqslant", "\\html@mathml{\\@ngeqslant}{\u2271}"); +defineMacro("\\nleqq", "\\html@mathml{\\@nleqq}{\u2270}"); +defineMacro("\\nleqslant", "\\html@mathml{\\@nleqslant}{\u2270}"); +defineMacro("\\nshortmid", "\\html@mathml{\\@nshortmid}{∤}"); +defineMacro("\\nshortparallel", "\\html@mathml{\\@nshortparallel}{∦}"); +defineMacro("\\nsubseteqq", "\\html@mathml{\\@nsubseteqq}{\u2288}"); +defineMacro("\\nsupseteqq", "\\html@mathml{\\@nsupseteqq}{\u2289}"); +defineMacro("\\varsubsetneq", "\\html@mathml{\\@varsubsetneq}{⊊}"); +defineMacro("\\varsubsetneqq", "\\html@mathml{\\@varsubsetneqq}{⫋}"); +defineMacro("\\varsupsetneq", "\\html@mathml{\\@varsupsetneq}{⊋}"); +defineMacro("\\varsupsetneqq", "\\html@mathml{\\@varsupsetneqq}{⫌}"); +defineMacro("\\imath", "\\html@mathml{\\@imath}{\u0131}"); +defineMacro("\\jmath", "\\html@mathml{\\@jmath}{\u0237}"); ////////////////////////////////////////////////////////////////////// +// stmaryrd and semantic +// The stmaryrd and semantic packages render the next four items by calling a +// glyph. Those glyphs do not exist in the KaTeX fonts. Hence the macros. + +defineMacro("\\llbracket", "\\html@mathml{" + "\\mathopen{[\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u27e6}}"); +defineMacro("\\rrbracket", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu]}}" + "{\\mathclose{\\char`\u27e7}}"); +defineMacro("\u27e6", "\\llbracket"); // blackboard bold [ + +defineMacro("\u27e7", "\\rrbracket"); // blackboard bold ] + +defineMacro("\\lBrace", "\\html@mathml{" + "\\mathopen{\\{\\mkern-3.2mu[}}" + "{\\mathopen{\\char`\u2983}}"); +defineMacro("\\rBrace", "\\html@mathml{" + "\\mathclose{]\\mkern-3.2mu\\}}}" + "{\\mathclose{\\char`\u2984}}"); +defineMacro("\u2983", "\\lBrace"); // blackboard bold { + +defineMacro("\u2984", "\\rBrace"); // blackboard bold } +// TODO: Create variable sized versions of the last two items. I believe that +// will require new font glyphs. +// The stmaryrd function `\minuso` provides a "Plimsoll" symbol that +// superimposes the characters \circ and \mathminus. Used in chemistry. + +defineMacro("\\minuso", "\\mathbin{\\html@mathml{" + "{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}" + "{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}" + "{\\char`⦵}}"); +defineMacro("⦵", "\\minuso"); ////////////////////////////////////////////////////////////////////// +// texvc.sty +// The texvc package contains macros available in mediawiki pages. +// We omit the functions deprecated at +// https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax +// We also omit texvc's \O, which conflicts with \text{\O} + +defineMacro("\\darr", "\\downarrow"); +defineMacro("\\dArr", "\\Downarrow"); +defineMacro("\\Darr", "\\Downarrow"); +defineMacro("\\lang", "\\langle"); +defineMacro("\\rang", "\\rangle"); +defineMacro("\\uarr", "\\uparrow"); +defineMacro("\\uArr", "\\Uparrow"); +defineMacro("\\Uarr", "\\Uparrow"); +defineMacro("\\N", "\\mathbb{N}"); +defineMacro("\\R", "\\mathbb{R}"); +defineMacro("\\Z", "\\mathbb{Z}"); +defineMacro("\\alef", "\\aleph"); +defineMacro("\\alefsym", "\\aleph"); +defineMacro("\\Alpha", "\\mathrm{A}"); +defineMacro("\\Beta", "\\mathrm{B}"); +defineMacro("\\bull", "\\bullet"); +defineMacro("\\Chi", "\\mathrm{X}"); +defineMacro("\\clubs", "\\clubsuit"); +defineMacro("\\cnums", "\\mathbb{C}"); +defineMacro("\\Complex", "\\mathbb{C}"); +defineMacro("\\Dagger", "\\ddagger"); +defineMacro("\\diamonds", "\\diamondsuit"); +defineMacro("\\empty", "\\emptyset"); +defineMacro("\\Epsilon", "\\mathrm{E}"); +defineMacro("\\Eta", "\\mathrm{H}"); +defineMacro("\\exist", "\\exists"); +defineMacro("\\harr", "\\leftrightarrow"); +defineMacro("\\hArr", "\\Leftrightarrow"); +defineMacro("\\Harr", "\\Leftrightarrow"); +defineMacro("\\hearts", "\\heartsuit"); +defineMacro("\\image", "\\Im"); +defineMacro("\\infin", "\\infty"); +defineMacro("\\Iota", "\\mathrm{I}"); +defineMacro("\\isin", "\\in"); +defineMacro("\\Kappa", "\\mathrm{K}"); +defineMacro("\\larr", "\\leftarrow"); +defineMacro("\\lArr", "\\Leftarrow"); +defineMacro("\\Larr", "\\Leftarrow"); +defineMacro("\\lrarr", "\\leftrightarrow"); +defineMacro("\\lrArr", "\\Leftrightarrow"); +defineMacro("\\Lrarr", "\\Leftrightarrow"); +defineMacro("\\Mu", "\\mathrm{M}"); +defineMacro("\\natnums", "\\mathbb{N}"); +defineMacro("\\Nu", "\\mathrm{N}"); +defineMacro("\\Omicron", "\\mathrm{O}"); +defineMacro("\\plusmn", "\\pm"); +defineMacro("\\rarr", "\\rightarrow"); +defineMacro("\\rArr", "\\Rightarrow"); +defineMacro("\\Rarr", "\\Rightarrow"); +defineMacro("\\real", "\\Re"); +defineMacro("\\reals", "\\mathbb{R}"); +defineMacro("\\Reals", "\\mathbb{R}"); +defineMacro("\\Rho", "\\mathrm{P}"); +defineMacro("\\sdot", "\\cdot"); +defineMacro("\\sect", "\\S"); +defineMacro("\\spades", "\\spadesuit"); +defineMacro("\\sub", "\\subset"); +defineMacro("\\sube", "\\subseteq"); +defineMacro("\\supe", "\\supseteq"); +defineMacro("\\Tau", "\\mathrm{T}"); +defineMacro("\\thetasym", "\\vartheta"); // TODO: defineMacro("\\varcoppa", "\\\mbox{\\coppa}"); + +defineMacro("\\weierp", "\\wp"); +defineMacro("\\Zeta", "\\mathrm{Z}"); ////////////////////////////////////////////////////////////////////// +// statmath.sty +// https://ctan.math.illinois.edu/macros/latex/contrib/statmath/statmath.pdf + +defineMacro("\\argmin", "\\DOTSB\\operatorname*{arg\\,min}"); +defineMacro("\\argmax", "\\DOTSB\\operatorname*{arg\\,max}"); +defineMacro("\\plim", "\\DOTSB\\mathop{\\operatorname{plim}}\\limits"); ////////////////////////////////////////////////////////////////////// +// braket.sty +// http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/braket/braket.pdf + +defineMacro("\\bra", "\\mathinner{\\langle{#1}|}"); +defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}"); +defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}"); +defineMacro("\\Bra", "\\left\\langle#1\\right|"); +defineMacro("\\Ket", "\\left|#1\\right\\rangle"); + +var braketHelper = one => context => { + var left = context.consumeArg().tokens; + var middle = context.consumeArg().tokens; + var middleDouble = context.consumeArg().tokens; + var right = context.consumeArg().tokens; + var oldMiddle = context.macros.get("|"); + var oldMiddleDouble = context.macros.get("\\|"); + context.macros.beginGroup(); + + var midMacro = double => context => { + if (one) { + // Only modify the first instance of | or \| + context.macros.set("|", oldMiddle); + + if (middleDouble.length) { + context.macros.set("\\|", oldMiddleDouble); + } + } + + var doubled = double; + + if (!double && middleDouble.length) { + // Mimic \@ifnextchar + var nextToken = context.future(); + + if (nextToken.text === "|") { + context.popToken(); + doubled = true; + } + } + + return { + tokens: doubled ? middleDouble : middle, + numArgs: 0 + }; + }; + + context.macros.set("|", midMacro(false)); + + if (middleDouble.length) { + context.macros.set("\\|", midMacro(true)); + } + + var arg = context.consumeArg().tokens; + var expanded = context.expandTokens([...right, ...arg, ...left // reversed + ]); + context.macros.endGroup(); + return { + tokens: expanded.reverse(), + numArgs: 0 + }; +}; + +defineMacro("\\bra@ket", braketHelper(false)); +defineMacro("\\bra@set", braketHelper(true)); +defineMacro("\\Braket", "\\bra@ket{\\left\\langle}" + "{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"); +defineMacro("\\Set", "\\bra@set{\\left\\{\\:}" + "{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"); +defineMacro("\\set", "\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"); // has no support for special || or \| +////////////////////////////////////////////////////////////////////// +// actuarialangle.dtx + +defineMacro("\\angln", "{\\angl n}"); // Custom Khan Academy colors, should be moved to an optional package + +defineMacro("\\blue", "\\textcolor{##6495ed}{#1}"); +defineMacro("\\orange", "\\textcolor{##ffa500}{#1}"); +defineMacro("\\pink", "\\textcolor{##ff00af}{#1}"); +defineMacro("\\red", "\\textcolor{##df0030}{#1}"); +defineMacro("\\green", "\\textcolor{##28ae7b}{#1}"); +defineMacro("\\gray", "\\textcolor{gray}{#1}"); +defineMacro("\\purple", "\\textcolor{##9d38bd}{#1}"); +defineMacro("\\blueA", "\\textcolor{##ccfaff}{#1}"); +defineMacro("\\blueB", "\\textcolor{##80f6ff}{#1}"); +defineMacro("\\blueC", "\\textcolor{##63d9ea}{#1}"); +defineMacro("\\blueD", "\\textcolor{##11accd}{#1}"); +defineMacro("\\blueE", "\\textcolor{##0c7f99}{#1}"); +defineMacro("\\tealA", "\\textcolor{##94fff5}{#1}"); +defineMacro("\\tealB", "\\textcolor{##26edd5}{#1}"); +defineMacro("\\tealC", "\\textcolor{##01d1c1}{#1}"); +defineMacro("\\tealD", "\\textcolor{##01a995}{#1}"); +defineMacro("\\tealE", "\\textcolor{##208170}{#1}"); +defineMacro("\\greenA", "\\textcolor{##b6ffb0}{#1}"); +defineMacro("\\greenB", "\\textcolor{##8af281}{#1}"); +defineMacro("\\greenC", "\\textcolor{##74cf70}{#1}"); +defineMacro("\\greenD", "\\textcolor{##1fab54}{#1}"); +defineMacro("\\greenE", "\\textcolor{##0d923f}{#1}"); +defineMacro("\\goldA", "\\textcolor{##ffd0a9}{#1}"); +defineMacro("\\goldB", "\\textcolor{##ffbb71}{#1}"); +defineMacro("\\goldC", "\\textcolor{##ff9c39}{#1}"); +defineMacro("\\goldD", "\\textcolor{##e07d10}{#1}"); +defineMacro("\\goldE", "\\textcolor{##a75a05}{#1}"); +defineMacro("\\redA", "\\textcolor{##fca9a9}{#1}"); +defineMacro("\\redB", "\\textcolor{##ff8482}{#1}"); +defineMacro("\\redC", "\\textcolor{##f9685d}{#1}"); +defineMacro("\\redD", "\\textcolor{##e84d39}{#1}"); +defineMacro("\\redE", "\\textcolor{##bc2612}{#1}"); +defineMacro("\\maroonA", "\\textcolor{##ffbde0}{#1}"); +defineMacro("\\maroonB", "\\textcolor{##ff92c6}{#1}"); +defineMacro("\\maroonC", "\\textcolor{##ed5fa6}{#1}"); +defineMacro("\\maroonD", "\\textcolor{##ca337c}{#1}"); +defineMacro("\\maroonE", "\\textcolor{##9e034e}{#1}"); +defineMacro("\\purpleA", "\\textcolor{##ddd7ff}{#1}"); +defineMacro("\\purpleB", "\\textcolor{##c6b9fc}{#1}"); +defineMacro("\\purpleC", "\\textcolor{##aa87ff}{#1}"); +defineMacro("\\purpleD", "\\textcolor{##7854ab}{#1}"); +defineMacro("\\purpleE", "\\textcolor{##543b78}{#1}"); +defineMacro("\\mintA", "\\textcolor{##f5f9e8}{#1}"); +defineMacro("\\mintB", "\\textcolor{##edf2df}{#1}"); +defineMacro("\\mintC", "\\textcolor{##e0e5cc}{#1}"); +defineMacro("\\grayA", "\\textcolor{##f6f7f7}{#1}"); +defineMacro("\\grayB", "\\textcolor{##f0f1f2}{#1}"); +defineMacro("\\grayC", "\\textcolor{##e3e5e6}{#1}"); +defineMacro("\\grayD", "\\textcolor{##d6d8da}{#1}"); +defineMacro("\\grayE", "\\textcolor{##babec2}{#1}"); +defineMacro("\\grayF", "\\textcolor{##888d93}{#1}"); +defineMacro("\\grayG", "\\textcolor{##626569}{#1}"); +defineMacro("\\grayH", "\\textcolor{##3b3e40}{#1}"); +defineMacro("\\grayI", "\\textcolor{##21242c}{#1}"); +defineMacro("\\kaBlue", "\\textcolor{##314453}{#1}"); +defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}"); + +/** + * This file contains the “gullet” where macros are expanded + * until only non-macro tokens remain. + */ +// List of commands that act like macros but aren't defined as a macro, +// function, or symbol. Used in `isDefined`. +var implicitCommands = { + "^": true, + // Parser.js + "_": true, + // Parser.js + "\\limits": true, + // Parser.js + "\\nolimits": true // Parser.js + +}; +class MacroExpander { + constructor(input, settings, mode) { + this.settings = void 0; + this.expansionCount = void 0; + this.lexer = void 0; + this.macros = void 0; + this.stack = void 0; + this.mode = void 0; + this.settings = settings; + this.expansionCount = 0; + this.feed(input); // Make new global namespace + + this.macros = new Namespace(macros, settings.macros); + this.mode = mode; + this.stack = []; // contains tokens in REVERSE order + } + /** + * Feed a new input string to the same MacroExpander + * (with existing macros etc.). + */ + + + feed(input) { + this.lexer = new Lexer(input, this.settings); + } + /** + * Switches between "text" and "math" modes. + */ + + + switchMode(newMode) { + this.mode = newMode; + } + /** + * Start a new group nesting within all namespaces. + */ + + + beginGroup() { + this.macros.beginGroup(); + } + /** + * End current group nesting within all namespaces. + */ + + + endGroup() { + this.macros.endGroup(); + } + /** + * Ends all currently nested groups (if any), restoring values before the + * groups began. Useful in case of an error in the middle of parsing. + */ + + + endGroups() { + this.macros.endGroups(); + } + /** + * Returns the topmost token on the stack, without expanding it. + * Similar in behavior to TeX's `\futurelet`. + */ + + + future() { + if (this.stack.length === 0) { + this.pushToken(this.lexer.lex()); + } + + return this.stack[this.stack.length - 1]; + } + /** + * Remove and return the next unexpanded token. + */ + + + popToken() { + this.future(); // ensure non-empty stack + + return this.stack.pop(); + } + /** + * Add a given token to the token stack. In particular, this get be used + * to put back a token returned from one of the other methods. + */ + + + pushToken(token) { + this.stack.push(token); + } + /** + * Append an array of tokens to the token stack. + */ + + + pushTokens(tokens) { + this.stack.push(...tokens); + } + /** + * Find an macro argument without expanding tokens and append the array of + * tokens to the token stack. Uses Token as a container for the result. + */ + + + scanArgument(isOptional) { + var start; + var end; + var tokens; + + if (isOptional) { + this.consumeSpaces(); // \@ifnextchar gobbles any space following it + + if (this.future().text !== "[") { + return null; + } + + start = this.popToken(); // don't include [ in tokens + + ({ + tokens, + end + } = this.consumeArg(["]"])); + } else { + ({ + tokens, + start, + end + } = this.consumeArg()); + } // indicate the end of an argument + + + this.pushToken(new Token("EOF", end.loc)); + this.pushTokens(tokens); + return start.range(end, ""); + } + /** + * Consume all following space tokens, without expansion. + */ + + + consumeSpaces() { + for (;;) { + var token = this.future(); + + if (token.text === " ") { + this.stack.pop(); + } else { + break; + } + } + } + /** + * Consume an argument from the token stream, and return the resulting array + * of tokens and start/end token. + */ + + + consumeArg(delims) { + // The argument for a delimited parameter is the shortest (possibly + // empty) sequence of tokens with properly nested {...} groups that is + // followed ... by this particular list of non-parameter tokens. + // The argument for an undelimited parameter is the next nonblank + // token, unless that token is ‘{’, when the argument will be the + // entire {...} group that follows. + var tokens = []; + var isDelimited = delims && delims.length > 0; + + if (!isDelimited) { + // Ignore spaces between arguments. As the TeXbook says: + // "After you have said ‘\def\row#1#2{...}’, you are allowed to + // put spaces between the arguments (e.g., ‘\row x n’), because + // TeX doesn’t use single spaces as undelimited arguments." + this.consumeSpaces(); + } + + var start = this.future(); + var tok; + var depth = 0; + var match = 0; + + do { + tok = this.popToken(); + tokens.push(tok); + + if (tok.text === "{") { + ++depth; + } else if (tok.text === "}") { + --depth; + + if (depth === -1) { + throw new ParseError("Extra }", tok); + } + } else if (tok.text === "EOF") { + throw new ParseError("Unexpected end of input in a macro argument" + ", expected '" + (delims && isDelimited ? delims[match] : "}") + "'", tok); + } + + if (delims && isDelimited) { + if ((depth === 0 || depth === 1 && delims[match] === "{") && tok.text === delims[match]) { + ++match; + + if (match === delims.length) { + // don't include delims in tokens + tokens.splice(-match, match); + break; + } + } else { + match = 0; + } + } + } while (depth !== 0 || isDelimited); // If the argument found ... has the form ‘{}’, + // ... the outermost braces enclosing the argument are removed + + + if (start.text === "{" && tokens[tokens.length - 1].text === "}") { + tokens.pop(); + tokens.shift(); + } + + tokens.reverse(); // to fit in with stack order + + return { + tokens, + start, + end: tok + }; + } + /** + * Consume the specified number of (delimited) arguments from the token + * stream and return the resulting array of arguments. + */ + + + consumeArgs(numArgs, delimiters) { + if (delimiters) { + if (delimiters.length !== numArgs + 1) { + throw new ParseError("The length of delimiters doesn't match the number of args!"); + } + + var delims = delimiters[0]; + + for (var i = 0; i < delims.length; i++) { + var tok = this.popToken(); + + if (delims[i] !== tok.text) { + throw new ParseError("Use of the macro doesn't match its definition", tok); + } + } + } + + var args = []; + + for (var _i = 0; _i < numArgs; _i++) { + args.push(this.consumeArg(delimiters && delimiters[_i + 1]).tokens); + } + + return args; + } + /** + * Increment `expansionCount` by the specified amount. + * Throw an error if it exceeds `maxExpand`. + */ + + + countExpansion(amount) { + this.expansionCount += amount; + + if (this.expansionCount > this.settings.maxExpand) { + throw new ParseError("Too many expansions: infinite loop or " + "need to increase maxExpand setting"); + } + } + /** + * Expand the next token only once if possible. + * + * If the token is expanded, the resulting tokens will be pushed onto + * the stack in reverse order, and the number of such tokens will be + * returned. This number might be zero or positive. + * + * If not, the return value is `false`, and the next token remains at the + * top of the stack. + * + * In either case, the next token will be on the top of the stack, + * or the stack will be empty (in case of empty expansion + * and no other tokens). + * + * Used to implement `expandAfterFuture` and `expandNextToken`. + * + * If expandableOnly, only expandable tokens are expanded and + * an undefined control sequence results in an error. + */ + + + expandOnce(expandableOnly) { + var topToken = this.popToken(); + var name = topToken.text; + var expansion = !topToken.noexpand ? this._getExpansion(name) : null; + + if (expansion == null || expandableOnly && expansion.unexpandable) { + if (expandableOnly && expansion == null && name[0] === "\\" && !this.isDefined(name)) { + throw new ParseError("Undefined control sequence: " + name); + } + + this.pushToken(topToken); + return false; + } + + this.countExpansion(1); + var tokens = expansion.tokens; + var args = this.consumeArgs(expansion.numArgs, expansion.delimiters); + + if (expansion.numArgs) { + // paste arguments in place of the placeholders + tokens = tokens.slice(); // make a shallow copy + + for (var i = tokens.length - 1; i >= 0; --i) { + var tok = tokens[i]; + + if (tok.text === "#") { + if (i === 0) { + throw new ParseError("Incomplete placeholder at end of macro body", tok); + } + + tok = tokens[--i]; // next token on stack + + if (tok.text === "#") { + // ## → # + tokens.splice(i + 1, 1); // drop first # + } else if (/^[1-9]$/.test(tok.text)) { + // replace the placeholder with the indicated argument + tokens.splice(i, 2, ...args[+tok.text - 1]); + } else { + throw new ParseError("Not a valid argument number", tok); + } + } + } + } // Concatenate expansion onto top of stack. + + + this.pushTokens(tokens); + return tokens.length; + } + /** + * Expand the next token only once (if possible), and return the resulting + * top token on the stack (without removing anything from the stack). + * Similar in behavior to TeX's `\expandafter\futurelet`. + * Equivalent to expandOnce() followed by future(). + */ + + + expandAfterFuture() { + this.expandOnce(); + return this.future(); + } + /** + * Recursively expand first token, then return first non-expandable token. + */ + + + expandNextToken() { + for (;;) { + if (this.expandOnce() === false) { + // fully expanded + var token = this.stack.pop(); // the token after \noexpand is interpreted as if its meaning + // were ‘\relax’ + + if (token.treatAsRelax) { + token.text = "\\relax"; + } + + return token; + } + } // Flow unable to figure out that this pathway is impossible. + // https://github.com/facebook/flow/issues/4808 + + + throw new Error(); // eslint-disable-line no-unreachable + } + /** + * Fully expand the given macro name and return the resulting list of + * tokens, or return `undefined` if no such macro is defined. + */ + + + expandMacro(name) { + return this.macros.has(name) ? this.expandTokens([new Token(name)]) : undefined; + } + /** + * Fully expand the given token stream and return the resulting list of + * tokens. Note that the input tokens are in reverse order, but the + * output tokens are in forward order. + */ + + + expandTokens(tokens) { + var output = []; + var oldStackLength = this.stack.length; + this.pushTokens(tokens); + + while (this.stack.length > oldStackLength) { + // Expand only expandable tokens + if (this.expandOnce(true) === false) { + // fully expanded + var token = this.stack.pop(); + + if (token.treatAsRelax) { + // the expansion of \noexpand is the token itself + token.noexpand = false; + token.treatAsRelax = false; + } + + output.push(token); + } + } // Count all of these tokens as additional expansions, to prevent + // exponential blowup from linearly many \edef's. + + + this.countExpansion(output.length); + return output; + } + /** + * Fully expand the given macro name and return the result as a string, + * or return `undefined` if no such macro is defined. + */ + + + expandMacroAsText(name) { + var tokens = this.expandMacro(name); + + if (tokens) { + return tokens.map(token => token.text).join(""); + } else { + return tokens; + } + } + /** + * Returns the expanded macro as a reversed array of tokens and a macro + * argument count. Or returns `null` if no such macro. + */ + + + _getExpansion(name) { + var definition = this.macros.get(name); + + if (definition == null) { + // mainly checking for undefined here + return definition; + } // If a single character has an associated catcode other than 13 + // (active character), then don't expand it. + + + if (name.length === 1) { + var catcode = this.lexer.catcodes[name]; + + if (catcode != null && catcode !== 13) { + return; + } + } + + var expansion = typeof definition === "function" ? definition(this) : definition; + + if (typeof expansion === "string") { + var numArgs = 0; + + if (expansion.indexOf("#") !== -1) { + var stripped = expansion.replace(/##/g, ""); + + while (stripped.indexOf("#" + (numArgs + 1)) !== -1) { + ++numArgs; + } + } + + var bodyLexer = new Lexer(expansion, this.settings); + var tokens = []; + var tok = bodyLexer.lex(); + + while (tok.text !== "EOF") { + tokens.push(tok); + tok = bodyLexer.lex(); + } + + tokens.reverse(); // to fit in with stack using push and pop + + var expanded = { + tokens, + numArgs + }; + return expanded; + } + + return expansion; + } + /** + * Determine whether a command is currently "defined" (has some + * functionality), meaning that it's a macro (in the current group), + * a function, a symbol, or one of the special commands listed in + * `implicitCommands`. + */ + + + isDefined(name) { + return this.macros.has(name) || functions$1.hasOwnProperty(name) || symbols.math.hasOwnProperty(name) || symbols.text.hasOwnProperty(name) || implicitCommands.hasOwnProperty(name); + } + /** + * Determine whether a command is expandable. + */ + + + isExpandable(name) { + var macro = this.macros.get(name); + return macro != null ? typeof macro === "string" || typeof macro === "function" || !macro.unexpandable : functions$1.hasOwnProperty(name) && !functions$1[name].primitive; + } + +} + +// Helpers for Parser.js handling of Unicode (sub|super)script characters. +var unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/; +var uSubsAndSups = Object.freeze({ + '₊': '+', + '₋': '-', + '₌': '=', + '₍': '(', + '₎': ')', + '₀': '0', + '₁': '1', + '₂': '2', + '₃': '3', + '₄': '4', + '₅': '5', + '₆': '6', + '₇': '7', + '₈': '8', + '₉': '9', + '\u2090': 'a', + '\u2091': 'e', + '\u2095': 'h', + '\u1D62': 'i', + '\u2C7C': 'j', + '\u2096': 'k', + '\u2097': 'l', + '\u2098': 'm', + '\u2099': 'n', + '\u2092': 'o', + '\u209A': 'p', + '\u1D63': 'r', + '\u209B': 's', + '\u209C': 't', + '\u1D64': 'u', + '\u1D65': 'v', + '\u2093': 'x', + '\u1D66': 'β', + '\u1D67': 'γ', + '\u1D68': 'ρ', + '\u1D69': '\u03d5', + '\u1D6A': 'χ', + '⁺': '+', + '⁻': '-', + '⁼': '=', + '⁽': '(', + '⁾': ')', + '⁰': '0', + '¹': '1', + '²': '2', + '³': '3', + '⁴': '4', + '⁵': '5', + '⁶': '6', + '⁷': '7', + '⁸': '8', + '⁹': '9', + '\u1D2C': 'A', + '\u1D2E': 'B', + '\u1D30': 'D', + '\u1D31': 'E', + '\u1D33': 'G', + '\u1D34': 'H', + '\u1D35': 'I', + '\u1D36': 'J', + '\u1D37': 'K', + '\u1D38': 'L', + '\u1D39': 'M', + '\u1D3A': 'N', + '\u1D3C': 'O', + '\u1D3E': 'P', + '\u1D3F': 'R', + '\u1D40': 'T', + '\u1D41': 'U', + '\u2C7D': 'V', + '\u1D42': 'W', + '\u1D43': 'a', + '\u1D47': 'b', + '\u1D9C': 'c', + '\u1D48': 'd', + '\u1D49': 'e', + '\u1DA0': 'f', + '\u1D4D': 'g', + '\u02B0': 'h', + '\u2071': 'i', + '\u02B2': 'j', + '\u1D4F': 'k', + '\u02E1': 'l', + '\u1D50': 'm', + '\u207F': 'n', + '\u1D52': 'o', + '\u1D56': 'p', + '\u02B3': 'r', + '\u02E2': 's', + '\u1D57': 't', + '\u1D58': 'u', + '\u1D5B': 'v', + '\u02B7': 'w', + '\u02E3': 'x', + '\u02B8': 'y', + '\u1DBB': 'z', + '\u1D5D': 'β', + '\u1D5E': 'γ', + '\u1D5F': 'δ', + '\u1D60': '\u03d5', + '\u1D61': 'χ', + '\u1DBF': 'θ' +}); + +/* eslint no-constant-condition:0 */ + +var unicodeAccents = { + "́": { + "text": "\\'", + "math": "\\acute" + }, + "̀": { + "text": "\\`", + "math": "\\grave" + }, + "̈": { + "text": "\\\"", + "math": "\\ddot" + }, + "̃": { + "text": "\\~", + "math": "\\tilde" + }, + "̄": { + "text": "\\=", + "math": "\\bar" + }, + "̆": { + "text": "\\u", + "math": "\\breve" + }, + "̌": { + "text": "\\v", + "math": "\\check" + }, + "̂": { + "text": "\\^", + "math": "\\hat" + }, + "̇": { + "text": "\\.", + "math": "\\dot" + }, + "̊": { + "text": "\\r", + "math": "\\mathring" + }, + "̋": { + "text": "\\H" + }, + "̧": { + "text": "\\c" + } +}; +var unicodeSymbols = { + "á": "á", + "à": "à", + "ä": "ä", + "ǟ": "ǟ", + "ã": "ã", + "ā": "ā", + "ă": "ă", + "ắ": "ắ", + "ằ": "ằ", + "ẵ": "ẵ", + "ǎ": "ǎ", + "â": "â", + "ấ": "ấ", + "ầ": "ầ", + "ẫ": "ẫ", + "ȧ": "ȧ", + "ǡ": "ǡ", + "å": "å", + "ǻ": "ǻ", + "ḃ": "ḃ", + "ć": "ć", + "ḉ": "ḉ", + "č": "č", + "ĉ": "ĉ", + "ċ": "ċ", + "ç": "ç", + "ď": "ď", + "ḋ": "ḋ", + "ḑ": "ḑ", + "é": "é", + "è": "è", + "ë": "ë", + "ẽ": "ẽ", + "ē": "ē", + "ḗ": "ḗ", + "ḕ": "ḕ", + "ĕ": "ĕ", + "ḝ": "ḝ", + "ě": "ě", + "ê": "ê", + "ế": "ế", + "ề": "ề", + "ễ": "ễ", + "ė": "ė", + "ȩ": "ȩ", + "ḟ": "ḟ", + "ǵ": "ǵ", + "ḡ": "ḡ", + "ğ": "ğ", + "ǧ": "ǧ", + "ĝ": "ĝ", + "ġ": "ġ", + "ģ": "ģ", + "ḧ": "ḧ", + "ȟ": "ȟ", + "ĥ": "ĥ", + "ḣ": "ḣ", + "ḩ": "ḩ", + "í": "í", + "ì": "ì", + "ï": "ï", + "ḯ": "ḯ", + "ĩ": "ĩ", + "ī": "ī", + "ĭ": "ĭ", + "ǐ": "ǐ", + "î": "î", + "ǰ": "ǰ", + "ĵ": "ĵ", + "ḱ": "ḱ", + "ǩ": "ǩ", + "ķ": "ķ", + "ĺ": "ĺ", + "ľ": "ľ", + "ļ": "ļ", + "ḿ": "ḿ", + "ṁ": "ṁ", + "ń": "ń", + "ǹ": "ǹ", + "ñ": "ñ", + "ň": "ň", + "ṅ": "ṅ", + "ņ": "ņ", + "ó": "ó", + "ò": "ò", + "ö": "ö", + "ȫ": "ȫ", + "õ": "õ", + "ṍ": "ṍ", + "ṏ": "ṏ", + "ȭ": "ȭ", + "ō": "ō", + "ṓ": "ṓ", + "ṑ": "ṑ", + "ŏ": "ŏ", + "ǒ": "ǒ", + "ô": "ô", + "ố": "ố", + "ồ": "ồ", + "ỗ": "ỗ", + "ȯ": "ȯ", + "ȱ": "ȱ", + "ő": "ő", + "ṕ": "ṕ", + "ṗ": "ṗ", + "ŕ": "ŕ", + "ř": "ř", + "ṙ": "ṙ", + "ŗ": "ŗ", + "ś": "ś", + "ṥ": "ṥ", + "š": "š", + "ṧ": "ṧ", + "ŝ": "ŝ", + "ṡ": "ṡ", + "ş": "ş", + "ẗ": "ẗ", + "ť": "ť", + "ṫ": "ṫ", + "ţ": "ţ", + "ú": "ú", + "ù": "ù", + "ü": "ü", + "ǘ": "ǘ", + "ǜ": "ǜ", + "ǖ": "ǖ", + "ǚ": "ǚ", + "ũ": "ũ", + "ṹ": "ṹ", + "ū": "ū", + "ṻ": "ṻ", + "ŭ": "ŭ", + "ǔ": "ǔ", + "û": "û", + "ů": "ů", + "ű": "ű", + "ṽ": "ṽ", + "ẃ": "ẃ", + "ẁ": "ẁ", + "ẅ": "ẅ", + "ŵ": "ŵ", + "ẇ": "ẇ", + "ẘ": "ẘ", + "ẍ": "ẍ", + "ẋ": "ẋ", + "ý": "ý", + "ỳ": "ỳ", + "ÿ": "ÿ", + "ỹ": "ỹ", + "ȳ": "ȳ", + "ŷ": "ŷ", + "ẏ": "ẏ", + "ẙ": "ẙ", + "ź": "ź", + "ž": "ž", + "ẑ": "ẑ", + "ż": "ż", + "Á": "Á", + "À": "À", + "Ä": "Ä", + "Ǟ": "Ǟ", + "Ã": "Ã", + "Ā": "Ā", + "Ă": "Ă", + "Ắ": "Ắ", + "Ằ": "Ằ", + "Ẵ": "Ẵ", + "Ǎ": "Ǎ", + "Â": "Â", + "Ấ": "Ấ", + "Ầ": "Ầ", + "Ẫ": "Ẫ", + "Ȧ": "Ȧ", + "Ǡ": "Ǡ", + "Å": "Å", + "Ǻ": "Ǻ", + "Ḃ": "Ḃ", + "Ć": "Ć", + "Ḉ": "Ḉ", + "Č": "Č", + "Ĉ": "Ĉ", + "Ċ": "Ċ", + "Ç": "Ç", + "Ď": "Ď", + "Ḋ": "Ḋ", + "Ḑ": "Ḑ", + "É": "É", + "È": "È", + "Ë": "Ë", + "Ẽ": "Ẽ", + "Ē": "Ē", + "Ḗ": "Ḗ", + "Ḕ": "Ḕ", + "Ĕ": "Ĕ", + "Ḝ": "Ḝ", + "Ě": "Ě", + "Ê": "Ê", + "Ế": "Ế", + "Ề": "Ề", + "Ễ": "Ễ", + "Ė": "Ė", + "Ȩ": "Ȩ", + "Ḟ": "Ḟ", + "Ǵ": "Ǵ", + "Ḡ": "Ḡ", + "Ğ": "Ğ", + "Ǧ": "Ǧ", + "Ĝ": "Ĝ", + "Ġ": "Ġ", + "Ģ": "Ģ", + "Ḧ": "Ḧ", + "Ȟ": "Ȟ", + "Ĥ": "Ĥ", + "Ḣ": "Ḣ", + "Ḩ": "Ḩ", + "Í": "Í", + "Ì": "Ì", + "Ï": "Ï", + "Ḯ": "Ḯ", + "Ĩ": "Ĩ", + "Ī": "Ī", + "Ĭ": "Ĭ", + "Ǐ": "Ǐ", + "Î": "Î", + "İ": "İ", + "Ĵ": "Ĵ", + "Ḱ": "Ḱ", + "Ǩ": "Ǩ", + "Ķ": "Ķ", + "Ĺ": "Ĺ", + "Ľ": "Ľ", + "Ļ": "Ļ", + "Ḿ": "Ḿ", + "Ṁ": "Ṁ", + "Ń": "Ń", + "Ǹ": "Ǹ", + "Ñ": "Ñ", + "Ň": "Ň", + "Ṅ": "Ṅ", + "Ņ": "Ņ", + "Ó": "Ó", + "Ò": "Ò", + "Ö": "Ö", + "Ȫ": "Ȫ", + "Õ": "Õ", + "Ṍ": "Ṍ", + "Ṏ": "Ṏ", + "Ȭ": "Ȭ", + "Ō": "Ō", + "Ṓ": "Ṓ", + "Ṑ": "Ṑ", + "Ŏ": "Ŏ", + "Ǒ": "Ǒ", + "Ô": "Ô", + "Ố": "Ố", + "Ồ": "Ồ", + "Ỗ": "Ỗ", + "Ȯ": "Ȯ", + "Ȱ": "Ȱ", + "Ő": "Ő", + "Ṕ": "Ṕ", + "Ṗ": "Ṗ", + "Ŕ": "Ŕ", + "Ř": "Ř", + "Ṙ": "Ṙ", + "Ŗ": "Ŗ", + "Ś": "Ś", + "Ṥ": "Ṥ", + "Š": "Š", + "Ṧ": "Ṧ", + "Ŝ": "Ŝ", + "Ṡ": "Ṡ", + "Ş": "Ş", + "Ť": "Ť", + "Ṫ": "Ṫ", + "Ţ": "Ţ", + "Ú": "Ú", + "Ù": "Ù", + "Ü": "Ü", + "Ǘ": "Ǘ", + "Ǜ": "Ǜ", + "Ǖ": "Ǖ", + "Ǚ": "Ǚ", + "Ũ": "Ũ", + "Ṹ": "Ṹ", + "Ū": "Ū", + "Ṻ": "Ṻ", + "Ŭ": "Ŭ", + "Ǔ": "Ǔ", + "Û": "Û", + "Ů": "Ů", + "Ű": "Ű", + "Ṽ": "Ṽ", + "Ẃ": "Ẃ", + "Ẁ": "Ẁ", + "Ẅ": "Ẅ", + "Ŵ": "Ŵ", + "Ẇ": "Ẇ", + "Ẍ": "Ẍ", + "Ẋ": "Ẋ", + "Ý": "Ý", + "Ỳ": "Ỳ", + "Ÿ": "Ÿ", + "Ỹ": "Ỹ", + "Ȳ": "Ȳ", + "Ŷ": "Ŷ", + "Ẏ": "Ẏ", + "Ź": "Ź", + "Ž": "Ž", + "Ẑ": "Ẑ", + "Ż": "Ż", + "ά": "ά", + "ὰ": "ὰ", + "ᾱ": "ᾱ", + "ᾰ": "ᾰ", + "έ": "έ", + "ὲ": "ὲ", + "ή": "ή", + "ὴ": "ὴ", + "ί": "ί", + "ὶ": "ὶ", + "ϊ": "ϊ", + "ΐ": "ΐ", + "ῒ": "ῒ", + "ῑ": "ῑ", + "ῐ": "ῐ", + "ό": "ό", + "ὸ": "ὸ", + "ύ": "ύ", + "ὺ": "ὺ", + "ϋ": "ϋ", + "ΰ": "ΰ", + "ῢ": "ῢ", + "ῡ": "ῡ", + "ῠ": "ῠ", + "ώ": "ώ", + "ὼ": "ὼ", + "Ύ": "Ύ", + "Ὺ": "Ὺ", + "Ϋ": "Ϋ", + "Ῡ": "Ῡ", + "Ῠ": "Ῠ", + "Ώ": "Ώ", + "Ὼ": "Ὼ" +}; + +/** + * This file contains the parser used to parse out a TeX expression from the + * input. Since TeX isn't context-free, standard parsers don't work particularly + * well. + * + * The strategy of this parser is as such: + * + * The main functions (the `.parse...` ones) take a position in the current + * parse string to parse tokens from. The lexer (found in Lexer.js, stored at + * this.gullet.lexer) also supports pulling out tokens at arbitrary places. When + * individual tokens are needed at a position, the lexer is called to pull out a + * token, which is then used. + * + * The parser has a property called "mode" indicating the mode that + * the parser is currently in. Currently it has to be one of "math" or + * "text", which denotes whether the current environment is a math-y + * one or a text-y one (e.g. inside \text). Currently, this serves to + * limit the functions which can be used in text mode. + * + * The main functions then return an object which contains the useful data that + * was parsed at its given point, and a new position at the end of the parsed + * data. The main functions can call each other and continue the parsing by + * using the returned position as a new starting point. + * + * There are also extra `.handle...` functions, which pull out some reused + * functionality into self-contained functions. + * + * The functions return ParseNodes. + */ +class Parser { + constructor(input, settings) { + this.mode = void 0; + this.gullet = void 0; + this.settings = void 0; + this.leftrightDepth = void 0; + this.nextToken = void 0; + // Start in math mode + this.mode = "math"; // Create a new macro expander (gullet) and (indirectly via that) also a + // new lexer (mouth) for this parser (stomach, in the language of TeX) + + this.gullet = new MacroExpander(input, settings, this.mode); // Store the settings for use in parsing + + this.settings = settings; // Count leftright depth (for \middle errors) + + this.leftrightDepth = 0; + } + /** + * Checks a result to make sure it has the right type, and throws an + * appropriate error otherwise. + */ + + + expect(text, consume) { + if (consume === void 0) { + consume = true; + } + + if (this.fetch().text !== text) { + throw new ParseError("Expected '" + text + "', got '" + this.fetch().text + "'", this.fetch()); + } + + if (consume) { + this.consume(); + } + } + /** + * Discards the current lookahead token, considering it consumed. + */ + + + consume() { + this.nextToken = null; + } + /** + * Return the current lookahead token, or if there isn't one (at the + * beginning, or if the previous lookahead token was consume()d), + * fetch the next token as the new lookahead token and return it. + */ + + + fetch() { + if (this.nextToken == null) { + this.nextToken = this.gullet.expandNextToken(); + } + + return this.nextToken; + } + /** + * Switches between "text" and "math" modes. + */ + + + switchMode(newMode) { + this.mode = newMode; + this.gullet.switchMode(newMode); + } + /** + * Main parsing function, which parses an entire input. + */ + + + parse() { + if (!this.settings.globalGroup) { + // Create a group namespace for the math expression. + // (LaTeX creates a new group for every $...$, $$...$$, \[...\].) + this.gullet.beginGroup(); + } // Use old \color behavior (same as LaTeX's \textcolor) if requested. + // We do this within the group for the math expression, so it doesn't + // pollute settings.macros. + + + if (this.settings.colorIsTextColor) { + this.gullet.macros.set("\\color", "\\textcolor"); + } + + try { + // Try to parse the input + var parse = this.parseExpression(false); // If we succeeded, make sure there's an EOF at the end + + this.expect("EOF"); // End the group namespace for the expression + + if (!this.settings.globalGroup) { + this.gullet.endGroup(); + } + + return parse; // Close any leftover groups in case of a parse error. + } finally { + this.gullet.endGroups(); + } + } + /** + * Fully parse a separate sequence of tokens as a separate job. + * Tokens should be specified in reverse order, as in a MacroDefinition. + */ + + + subparse(tokens) { + // Save the next token from the current job. + var oldToken = this.nextToken; + this.consume(); // Run the new job, terminating it with an excess '}' + + this.gullet.pushToken(new Token("}")); + this.gullet.pushTokens(tokens); + var parse = this.parseExpression(false); + this.expect("}"); // Restore the next token from the current job. + + this.nextToken = oldToken; + return parse; + } + + /** + * Parses an "expression", which is a list of atoms. + * + * `breakOnInfix`: Should the parsing stop when we hit infix nodes? This + * happens when functions have higher precedence han infix + * nodes in implicit parses. + * + * `breakOnTokenText`: The text of the token that the expression should end + * with, or `null` if something else should end the + * expression. + */ + parseExpression(breakOnInfix, breakOnTokenText) { + var body = []; // Keep adding atoms to the body until we can't parse any more atoms (either + // we reached the end, a }, or a \right) + + while (true) { + // Ignore spaces in math mode + if (this.mode === "math") { + this.consumeSpaces(); + } + + var lex = this.fetch(); + + if (Parser.endOfExpression.indexOf(lex.text) !== -1) { + break; + } + + if (breakOnTokenText && lex.text === breakOnTokenText) { + break; + } + + if (breakOnInfix && functions$1[lex.text] && functions$1[lex.text].infix) { + break; + } + + var atom = this.parseAtom(breakOnTokenText); + + if (!atom) { + break; + } else if (atom.type === "internal") { + continue; + } + + body.push(atom); + } + + if (this.mode === "text") { + this.formLigatures(body); + } + + return this.handleInfixNodes(body); + } + /** + * Rewrites infix operators such as \over with corresponding commands such + * as \frac. + * + * There can only be one infix operator per group. If there's more than one + * then the expression is ambiguous. This can be resolved by adding {}. + */ + + + handleInfixNodes(body) { + var overIndex = -1; + var funcName; + + for (var i = 0; i < body.length; i++) { + if (body[i].type === "infix") { + if (overIndex !== -1) { + throw new ParseError("only one infix operator per group", body[i].token); + } + + overIndex = i; + funcName = body[i].replaceWith; + } + } + + if (overIndex !== -1 && funcName) { + var numerNode; + var denomNode; + var numerBody = body.slice(0, overIndex); + var denomBody = body.slice(overIndex + 1); + + if (numerBody.length === 1 && numerBody[0].type === "ordgroup") { + numerNode = numerBody[0]; + } else { + numerNode = { + type: "ordgroup", + mode: this.mode, + body: numerBody + }; + } + + if (denomBody.length === 1 && denomBody[0].type === "ordgroup") { + denomNode = denomBody[0]; + } else { + denomNode = { + type: "ordgroup", + mode: this.mode, + body: denomBody + }; + } + + var node; + + if (funcName === "\\\\abovefrac") { + node = this.callFunction(funcName, [numerNode, body[overIndex], denomNode], []); + } else { + node = this.callFunction(funcName, [numerNode, denomNode], []); + } + + return [node]; + } else { + return body; + } + } + /** + * Handle a subscript or superscript with nice errors. + */ + + + handleSupSubscript(name // For error reporting. + ) { + var symbolToken = this.fetch(); + var symbol = symbolToken.text; + this.consume(); + this.consumeSpaces(); // ignore spaces before sup/subscript argument + + var group = this.parseGroup(name); + + if (!group) { + throw new ParseError("Expected group after '" + symbol + "'", symbolToken); + } + + return group; + } + /** + * Converts the textual input of an unsupported command into a text node + * contained within a color node whose color is determined by errorColor + */ + + + formatUnsupportedCmd(text) { + var textordArray = []; + + for (var i = 0; i < text.length; i++) { + textordArray.push({ + type: "textord", + mode: "text", + text: text[i] + }); + } + + var textNode = { + type: "text", + mode: this.mode, + body: textordArray + }; + var colorNode = { + type: "color", + mode: this.mode, + color: this.settings.errorColor, + body: [textNode] + }; + return colorNode; + } + /** + * Parses a group with optional super/subscripts. + */ + + + parseAtom(breakOnTokenText) { + // The body of an atom is an implicit group, so that things like + // \left(x\right)^2 work correctly. + var base = this.parseGroup("atom", breakOnTokenText); // In text mode, we don't have superscripts or subscripts + + if (this.mode === "text") { + return base; + } // Note that base may be empty (i.e. null) at this point. + + + var superscript; + var subscript; + + while (true) { + // Guaranteed in math mode, so eat any spaces first. + this.consumeSpaces(); // Lex the first token + + var lex = this.fetch(); + + if (lex.text === "\\limits" || lex.text === "\\nolimits") { + // We got a limit control + if (base && base.type === "op") { + var limits = lex.text === "\\limits"; + base.limits = limits; + base.alwaysHandleSupSub = true; + } else if (base && base.type === "operatorname") { + if (base.alwaysHandleSupSub) { + base.limits = lex.text === "\\limits"; + } + } else { + throw new ParseError("Limit controls must follow a math operator", lex); + } + + this.consume(); + } else if (lex.text === "^") { + // We got a superscript start + if (superscript) { + throw new ParseError("Double superscript", lex); + } + + superscript = this.handleSupSubscript("superscript"); + } else if (lex.text === "_") { + // We got a subscript start + if (subscript) { + throw new ParseError("Double subscript", lex); + } + + subscript = this.handleSupSubscript("subscript"); + } else if (lex.text === "'") { + // We got a prime + if (superscript) { + throw new ParseError("Double superscript", lex); + } + + var prime = { + type: "textord", + mode: this.mode, + text: "\\prime" + }; // Many primes can be grouped together, so we handle this here + + var primes = [prime]; + this.consume(); // Keep lexing tokens until we get something that's not a prime + + while (this.fetch().text === "'") { + // For each one, add another prime to the list + primes.push(prime); + this.consume(); + } // If there's a superscript following the primes, combine that + // superscript in with the primes. + + + if (this.fetch().text === "^") { + primes.push(this.handleSupSubscript("superscript")); + } // Put everything into an ordgroup as the superscript + + + superscript = { + type: "ordgroup", + mode: this.mode, + body: primes + }; + } else if (uSubsAndSups[lex.text]) { + // A Unicode subscript or superscript character. + // We treat these similarly to the unicode-math package. + // So we render a string of Unicode (sub|super)scripts the + // same as a (sub|super)script of regular characters. + var isSub = unicodeSubRegEx.test(lex.text); + var subsupTokens = []; + subsupTokens.push(new Token(uSubsAndSups[lex.text])); + this.consume(); // Continue fetching tokens to fill out the string. + + while (true) { + var token = this.fetch().text; + + if (!uSubsAndSups[token]) { + break; + } + + if (unicodeSubRegEx.test(token) !== isSub) { + break; + } + + subsupTokens.unshift(new Token(uSubsAndSups[token])); + this.consume(); + } // Now create a (sub|super)script. + + + var body = this.subparse(subsupTokens); + + if (isSub) { + subscript = { + type: "ordgroup", + mode: "math", + body + }; + } else { + superscript = { + type: "ordgroup", + mode: "math", + body + }; + } + } else { + // If it wasn't ^, _, or ', stop parsing super/subscripts + break; + } + } // Base must be set if superscript or subscript are set per logic above, + // but need to check here for type check to pass. + + + if (superscript || subscript) { + // If we got either a superscript or subscript, create a supsub + return { + type: "supsub", + mode: this.mode, + base: base, + sup: superscript, + sub: subscript + }; + } else { + // Otherwise return the original body + return base; + } + } + /** + * Parses an entire function, including its base and all of its arguments. + */ + + + parseFunction(breakOnTokenText, name // For determining its context + ) { + var token = this.fetch(); + var func = token.text; + var funcData = functions$1[func]; + + if (!funcData) { + return null; + } + + this.consume(); // consume command token + + if (name && name !== "atom" && !funcData.allowedInArgument) { + throw new ParseError("Got function '" + func + "' with no arguments" + (name ? " as " + name : ""), token); + } else if (this.mode === "text" && !funcData.allowedInText) { + throw new ParseError("Can't use function '" + func + "' in text mode", token); + } else if (this.mode === "math" && funcData.allowedInMath === false) { + throw new ParseError("Can't use function '" + func + "' in math mode", token); + } + + var { + args, + optArgs + } = this.parseArguments(func, funcData); + return this.callFunction(func, args, optArgs, token, breakOnTokenText); + } + /** + * Call a function handler with a suitable context and arguments. + */ + + + callFunction(name, args, optArgs, token, breakOnTokenText) { + var context = { + funcName: name, + parser: this, + token, + breakOnTokenText + }; + var func = functions$1[name]; + + if (func && func.handler) { + return func.handler(context, args, optArgs); + } else { + throw new ParseError("No function handler for " + name); + } + } + /** + * Parses the arguments of a function or environment + */ + + + parseArguments(func, // Should look like "\name" or "\begin{name}". + funcData) { + var totalArgs = funcData.numArgs + funcData.numOptionalArgs; + + if (totalArgs === 0) { + return { + args: [], + optArgs: [] + }; + } + + var args = []; + var optArgs = []; + + for (var i = 0; i < totalArgs; i++) { + var argType = funcData.argTypes && funcData.argTypes[i]; + var isOptional = i < funcData.numOptionalArgs; + + if (funcData.primitive && argType == null || // \sqrt expands into primitive if optional argument doesn't exist + funcData.type === "sqrt" && i === 1 && optArgs[0] == null) { + argType = "primitive"; + } + + var arg = this.parseGroupOfType("argument to '" + func + "'", argType, isOptional); + + if (isOptional) { + optArgs.push(arg); + } else if (arg != null) { + args.push(arg); + } else { + // should be unreachable + throw new ParseError("Null argument, please report this as a bug"); + } + } + + return { + args, + optArgs + }; + } + /** + * Parses a group when the mode is changing. + */ + + + parseGroupOfType(name, type, optional) { + switch (type) { + case "color": + return this.parseColorGroup(optional); + + case "size": + return this.parseSizeGroup(optional); + + case "url": + return this.parseUrlGroup(optional); + + case "math": + case "text": + return this.parseArgumentGroup(optional, type); + + case "hbox": + { + // hbox argument type wraps the argument in the equivalent of + // \hbox, which is like \text but switching to \textstyle size. + var group = this.parseArgumentGroup(optional, "text"); + return group != null ? { + type: "styling", + mode: group.mode, + body: [group], + style: "text" // simulate \textstyle + + } : null; + } + + case "raw": + { + var token = this.parseStringGroup("raw", optional); + return token != null ? { + type: "raw", + mode: "text", + string: token.text + } : null; + } + + case "primitive": + { + if (optional) { + throw new ParseError("A primitive argument cannot be optional"); + } + + var _group = this.parseGroup(name); + + if (_group == null) { + throw new ParseError("Expected group as " + name, this.fetch()); + } + + return _group; + } + + case "original": + case null: + case undefined: + return this.parseArgumentGroup(optional); + + default: + throw new ParseError("Unknown group type as " + name, this.fetch()); + } + } + /** + * Discard any space tokens, fetching the next non-space token. + */ + + + consumeSpaces() { + while (this.fetch().text === " ") { + this.consume(); + } + } + /** + * Parses a group, essentially returning the string formed by the + * brace-enclosed tokens plus some position information. + */ + + + parseStringGroup(modeName, // Used to describe the mode in error messages. + optional) { + var argToken = this.gullet.scanArgument(optional); + + if (argToken == null) { + return null; + } + + var str = ""; + var nextToken; + + while ((nextToken = this.fetch()).text !== "EOF") { + str += nextToken.text; + this.consume(); + } + + this.consume(); // consume the end of the argument + + argToken.text = str; + return argToken; + } + /** + * Parses a regex-delimited group: the largest sequence of tokens + * whose concatenated strings match `regex`. Returns the string + * formed by the tokens plus some position information. + */ + + + parseRegexGroup(regex, modeName // Used to describe the mode in error messages. + ) { + var firstToken = this.fetch(); + var lastToken = firstToken; + var str = ""; + var nextToken; + + while ((nextToken = this.fetch()).text !== "EOF" && regex.test(str + nextToken.text)) { + lastToken = nextToken; + str += lastToken.text; + this.consume(); + } + + if (str === "") { + throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); + } + + return firstToken.range(lastToken, str); + } + /** + * Parses a color description. + */ + + + parseColorGroup(optional) { + var res = this.parseStringGroup("color", optional); + + if (res == null) { + return null; + } + + var match = /^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(res.text); + + if (!match) { + throw new ParseError("Invalid color: '" + res.text + "'", res); + } + + var color = match[0]; + + if (/^[0-9a-f]{6}$/i.test(color)) { + // We allow a 6-digit HTML color spec without a leading "#". + // This follows the xcolor package's HTML color model. + // Predefined color names are all missed by this RegEx pattern. + color = "#" + color; + } + + return { + type: "color-token", + mode: this.mode, + color + }; + } + /** + * Parses a size specification, consisting of magnitude and unit. + */ + + + parseSizeGroup(optional) { + var res; + var isBlank = false; // don't expand before parseStringGroup + + this.gullet.consumeSpaces(); + + if (!optional && this.gullet.future().text !== "{") { + res = this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/, "size"); + } else { + res = this.parseStringGroup("size", optional); + } + + if (!res) { + return null; + } + + if (!optional && res.text.length === 0) { + // Because we've tested for what is !optional, this block won't + // affect \kern, \hspace, etc. It will capture the mandatory arguments + // to \genfrac and \above. + res.text = "0pt"; // Enable \above{} + + isBlank = true; // This is here specifically for \genfrac + } + + var match = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(res.text); + + if (!match) { + throw new ParseError("Invalid size: '" + res.text + "'", res); + } + + var data = { + number: +(match[1] + match[2]), + // sign + magnitude, cast to number + unit: match[3] + }; + + if (!validUnit(data)) { + throw new ParseError("Invalid unit: '" + data.unit + "'", res); + } + + return { + type: "size", + mode: this.mode, + value: data, + isBlank + }; + } + /** + * Parses an URL, checking escaped letters and allowed protocols, + * and setting the catcode of % as an active character (as in \hyperref). + */ + + + parseUrlGroup(optional) { + this.gullet.lexer.setCatcode("%", 13); // active character + + this.gullet.lexer.setCatcode("~", 12); // other character + + var res = this.parseStringGroup("url", optional); + this.gullet.lexer.setCatcode("%", 14); // comment character + + this.gullet.lexer.setCatcode("~", 13); // active character + + if (res == null) { + return null; + } // hyperref package allows backslashes alone in href, but doesn't + // generate valid links in such cases; we interpret this as + // "undefined" behaviour, and keep them as-is. Some browser will + // replace backslashes with forward slashes. + + + var url = res.text.replace(/\\([#$%&~_^{}])/g, '$1'); + return { + type: "url", + mode: this.mode, + url + }; + } + /** + * Parses an argument with the mode specified. + */ + + + parseArgumentGroup(optional, mode) { + var argToken = this.gullet.scanArgument(optional); + + if (argToken == null) { + return null; + } + + var outerMode = this.mode; + + if (mode) { + // Switch to specified mode + this.switchMode(mode); + } + + this.gullet.beginGroup(); + var expression = this.parseExpression(false, "EOF"); // TODO: find an alternative way to denote the end + + this.expect("EOF"); // expect the end of the argument + + this.gullet.endGroup(); + var result = { + type: "ordgroup", + mode: this.mode, + loc: argToken.loc, + body: expression + }; + + if (mode) { + // Switch mode back + this.switchMode(outerMode); + } + + return result; + } + /** + * Parses an ordinary group, which is either a single nucleus (like "x") + * or an expression in braces (like "{x+y}") or an implicit group, a group + * that starts at the current position, and ends right before a higher explicit + * group ends, or at EOF. + */ + + + parseGroup(name, // For error reporting. + breakOnTokenText) { + var firstToken = this.fetch(); + var text = firstToken.text; + var result; // Try to parse an open brace or \begingroup + + if (text === "{" || text === "\\begingroup") { + this.consume(); + var groupEnd = text === "{" ? "}" : "\\endgroup"; + this.gullet.beginGroup(); // If we get a brace, parse an expression + + var expression = this.parseExpression(false, groupEnd); + var lastToken = this.fetch(); + this.expect(groupEnd); // Check that we got a matching closing brace + + this.gullet.endGroup(); + result = { + type: "ordgroup", + mode: this.mode, + loc: SourceLocation.range(firstToken, lastToken), + body: expression, + // A group formed by \begingroup...\endgroup is a semi-simple group + // which doesn't affect spacing in math mode, i.e., is transparent. + // https://tex.stackexchange.com/questions/1930/when-should-one- + // use-begingroup-instead-of-bgroup + semisimple: text === "\\begingroup" || undefined + }; + } else { + // If there exists a function with this name, parse the function. + // Otherwise, just return a nucleus + result = this.parseFunction(breakOnTokenText, name) || this.parseSymbol(); + + if (result == null && text[0] === "\\" && !implicitCommands.hasOwnProperty(text)) { + if (this.settings.throwOnError) { + throw new ParseError("Undefined control sequence: " + text, firstToken); + } + + result = this.formatUnsupportedCmd(text); + this.consume(); + } + } + + return result; + } + /** + * Form ligature-like combinations of characters for text mode. + * This includes inputs like "--", "---", "``" and "''". + * The result will simply replace multiple textord nodes with a single + * character in each value by a single textord node having multiple + * characters in its value. The representation is still ASCII source. + * The group will be modified in place. + */ + + + formLigatures(group) { + var n = group.length - 1; + + for (var i = 0; i < n; ++i) { + var a = group[i]; // $FlowFixMe: Not every node type has a `text` property. + + var v = a.text; + + if (v === "-" && group[i + 1].text === "-") { + if (i + 1 < n && group[i + 2].text === "-") { + group.splice(i, 3, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, group[i + 2]), + text: "---" + }); + n -= 2; + } else { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, group[i + 1]), + text: "--" + }); + n -= 1; + } + } + + if ((v === "'" || v === "`") && group[i + 1].text === v) { + group.splice(i, 2, { + type: "textord", + mode: "text", + loc: SourceLocation.range(a, group[i + 1]), + text: v + v + }); + n -= 1; + } + } + } + /** + * Parse a single symbol out of the string. Here, we handle single character + * symbols and special functions like \verb. + */ + + + parseSymbol() { + var nucleus = this.fetch(); + var text = nucleus.text; + + if (/^\\verb[^a-zA-Z]/.test(text)) { + this.consume(); + var arg = text.slice(5); + var star = arg.charAt(0) === "*"; + + if (star) { + arg = arg.slice(1); + } // Lexer's tokenRegex is constructed to always have matching + // first/last characters. + + + if (arg.length < 2 || arg.charAt(0) !== arg.slice(-1)) { + throw new ParseError("\\verb assertion failed --\n please report what input caused this bug"); + } + + arg = arg.slice(1, -1); // remove first and last char + + return { + type: "verb", + mode: "text", + body: arg, + star + }; + } // At this point, we should have a symbol, possibly with accents. + // First expand any accented base symbol according to unicodeSymbols. + + + if (unicodeSymbols.hasOwnProperty(text[0]) && !symbols[this.mode][text[0]]) { + // This behavior is not strict (XeTeX-compatible) in math mode. + if (this.settings.strict && this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Accented Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + + text = unicodeSymbols[text[0]] + text.slice(1); + } // Strip off any combining characters + + + var match = combiningDiacriticalMarksEndRegex.exec(text); + + if (match) { + text = text.substring(0, match.index); + + if (text === 'i') { + text = '\u0131'; // dotless i, in math and text mode + } else if (text === 'j') { + text = '\u0237'; // dotless j, in math and text mode + } + } // Recognize base symbol + + + var symbol; + + if (symbols[this.mode][text]) { + if (this.settings.strict && this.mode === 'math' && extraLatin.indexOf(text) >= 0) { + this.settings.reportNonstrict("unicodeTextInMathMode", "Latin-1/Unicode text character \"" + text[0] + "\" used in " + "math mode", nucleus); + } + + var group = symbols[this.mode][text].group; + var loc = SourceLocation.range(nucleus); + var s; + + if (ATOMS.hasOwnProperty(group)) { + // $FlowFixMe + var family = group; + s = { + type: "atom", + mode: this.mode, + family, + loc, + text + }; + } else { + // $FlowFixMe + s = { + type: group, + mode: this.mode, + loc, + text + }; + } // $FlowFixMe + + + symbol = s; + } else if (text.charCodeAt(0) >= 0x80) { + // no symbol for e.g. ^ + if (this.settings.strict) { + if (!supportedCodepoint(text.charCodeAt(0))) { + this.settings.reportNonstrict("unknownSymbol", "Unrecognized Unicode character \"" + text[0] + "\"" + (" (" + text.charCodeAt(0) + ")"), nucleus); + } else if (this.mode === "math") { + this.settings.reportNonstrict("unicodeTextInMathMode", "Unicode text character \"" + text[0] + "\" used in math mode", nucleus); + } + } // All nonmathematical Unicode characters are rendered as if they + // are in text mode (wrapped in \text) because that's what it + // takes to render them in LaTeX. Setting `mode: this.mode` is + // another natural choice (the user requested math mode), but + // this makes it more difficult for getCharacterMetrics() to + // distinguish Unicode characters without metrics and those for + // which we want to simulate the letter M. + + + symbol = { + type: "textord", + mode: "text", + loc: SourceLocation.range(nucleus), + text + }; + } else { + return null; // EOF, ^, _, {, }, etc. + } + + this.consume(); // Transform combining characters into accents + + if (match) { + for (var i = 0; i < match[0].length; i++) { + var accent = match[0][i]; + + if (!unicodeAccents[accent]) { + throw new ParseError("Unknown accent ' " + accent + "'", nucleus); + } + + var command = unicodeAccents[accent][this.mode] || unicodeAccents[accent].text; + + if (!command) { + throw new ParseError("Accent " + accent + " unsupported in " + this.mode + " mode", nucleus); + } + + symbol = { + type: "accent", + mode: this.mode, + loc: SourceLocation.range(nucleus), + label: command, + isStretchy: false, + isShifty: true, + // $FlowFixMe + base: symbol + }; + } + } // $FlowFixMe + + + return symbol; + } + +} +Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"]; + +/** + * Provides a single function for parsing an expression using a Parser + * TODO(emily): Remove this + */ + +/** + * Parses an expression using a Parser, then returns the parsed result. + */ +var parseTree = function parseTree(toParse, settings) { + if (!(typeof toParse === 'string' || toParse instanceof String)) { + throw new TypeError('KaTeX can only parse string typed expression'); + } + + var parser = new Parser(toParse, settings); // Blank out any \df@tag to avoid spurious "Duplicate \tag" errors + + delete parser.gullet.macros.current["\\df@tag"]; + var tree = parser.parse(); // Prevent a color definition from persisting between calls to katex.render(). + + delete parser.gullet.macros.current["\\current@color"]; + delete parser.gullet.macros.current["\\color"]; // If the input used \tag, it will set the \df@tag macro to the tag. + // In this case, we separately parse the tag and wrap the tree. + + if (parser.gullet.macros.get("\\df@tag")) { + if (!settings.displayMode) { + throw new ParseError("\\tag works only in display equations"); + } + + tree = [{ + type: "tag", + mode: "text", + body: tree, + tag: parser.subparse([new Token("\\df@tag")]) + }]; + } + + return tree; +}; + +/* eslint no-console:0 */ + +/** + * Parse and build an expression, and place that expression in the DOM node + * given. + */ +var render$3 = function render(expression, baseNode, options) { + baseNode.textContent = ""; + var node = renderToDomTree(expression, options).toNode(); + baseNode.appendChild(node); +}; // KaTeX's styles don't work properly in quirks mode. Print out an error, and +// disable rendering. + + +if (typeof document !== "undefined") { + if (document.compatMode !== "CSS1Compat") { + typeof console !== "undefined" && console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your " + "website has a suitable doctype."); + + render$3 = function render() { + throw new ParseError("KaTeX doesn't work in quirks mode."); + }; + } +} +/** + * Parse and build an expression, and return the markup for that. + */ + + +var renderToString = function renderToString(expression, options) { + var markup = renderToDomTree(expression, options).toMarkup(); + return markup; +}; +/** + * Parse an expression and return the parse tree. + */ + + +var generateParseTree = function generateParseTree(expression, options) { + var settings = new Settings(options); + return parseTree(expression, settings); +}; +/** + * If the given error is a KaTeX ParseError and options.throwOnError is false, + * renders the invalid LaTeX as a span with hover title giving the KaTeX + * error message. Otherwise, simply throws the error. + */ + + +var renderError = function renderError(error, expression, options) { + if (options.throwOnError || !(error instanceof ParseError)) { + throw error; + } + + var node = buildCommon.makeSpan(["katex-error"], [new SymbolNode(expression)]); + node.setAttribute("title", error.toString()); + node.setAttribute("style", "color:" + options.errorColor); + return node; +}; +/** + * Generates and returns the katex build tree. This is used for advanced + * use cases (like rendering to custom output). + */ + + +var renderToDomTree = function renderToDomTree(expression, options) { + var settings = new Settings(options); + + try { + var tree = parseTree(expression, settings); + return buildTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; +/** + * Generates and returns the katex build tree, with just HTML (no MathML). + * This is used for advanced use cases (like rendering to custom output). + */ + + +var renderToHTMLTree = function renderToHTMLTree(expression, options) { + var settings = new Settings(options); + + try { + var tree = parseTree(expression, settings); + return buildHTMLTree(tree, expression, settings); + } catch (error) { + return renderError(error, expression, settings); + } +}; + +var katex = { + /** + * Current KaTeX version + */ + version: "0.16.10", + + /** + * Renders the given LaTeX into an HTML+MathML combination, and adds + * it as a child to the specified DOM node. + */ + render: render$3, + + /** + * Renders the given LaTeX into an HTML+MathML combination string, + * for sending to the client. + */ + renderToString, + + /** + * KaTeX error, usually during parsing. + */ + ParseError, + + /** + * The shema of Settings + */ + SETTINGS_SCHEMA, + + /** + * Parses the given LaTeX into KaTeX's internal parse tree structure, + * without rendering to HTML or MathML. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __parse: generateParseTree, + + /** + * Renders the given LaTeX into an HTML+MathML internal DOM tree + * representation, without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToDomTree: renderToDomTree, + + /** + * Renders the given LaTeX into an HTML internal DOM tree representation, + * without MathML and without flattening that representation to a string. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __renderToHTMLTree: renderToHTMLTree, + + /** + * extends internal font metrics object with a new object + * each key in the new object represents a font name + */ + __setFontMetrics: setFontMetrics, + + /** + * adds a new symbol to builtin symbols table + */ + __defineSymbol: defineSymbol, + + /** + * adds a new function to builtin function list, + * which directly produce parse tree elements + * and have their own html/mathml builders + */ + __defineFunction: defineFunction, + + /** + * adds a new macro to builtin macro list + */ + __defineMacro: defineMacro, + + /** + * Expose the dom tree node types, which can be useful for type checking nodes. + * + * NOTE: This method is not currently recommended for public use. + * The internal tree representation is unstable and is very likely + * to change. Use at your own risk. + */ + __domTree: { + Span, + Anchor, + SymbolNode, + SvgNode, + PathNode, + LineNode + } +}; + +var katex$1 = /*#__PURE__*/Object.freeze({ + __proto__: null, + default: katex +}); + +function extendedTables() { + return { + extensions: [ + { + name: 'spanTable', + level: 'block', // Is this a block-level or inline-level tokenizer? + start(src) { return src.match(/^\n *([^\n ].*\|.*)\n/)?.index; }, // Hint to Marked.js to stop and check for a match + tokenizer(src, tokens) { + // const regex = this.tokenizer.rules.block.table; + const regex = new RegExp('^ *([^\\n ].*\\|.*\\n(?: *[^\\s].*\\n)*?)' // Header + + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align + + '(?:\\n((?:(?! *\\n| {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})' // Cells + + '(?:\\n+|$)| {0,3}#{1,6} | {0,3}>| {4}[^\\n]| {0,3}(?:`{3,}' + + '(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n| {0,3}(?:[*+-]|1[.)]) |' + + '<\\/?(?:address|article|aside|base|basefont|blockquote|body|' + + 'caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?: +|\\n|\\/?>)|<(?:script|pre|style|textarea|!--)).*(?:\\n|$))*)\\n*|$)'); // Cells + const cap = regex.exec(src); + + if (cap) { + const item = { + type: 'spanTable', + header: cap[1].replace(/\n$/, '').split('\n'), + align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), + rows: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [] + }; + + // Get first header row to determine how many columns + item.header[0] = splitCells(item.header[0]); + + const colCount = item.header[0].reduce((length, header) => { + return length + header.colspan; + }, 0); + + if (colCount === item.align.length) { + item.raw = cap[0]; + + let i, j, k, row; + + // Get alignment row (:---:) + let l = item.align.length; + + for (i = 0; i < l; i++) { + if (/^ *-+: *$/.test(item.align[i])) { + item.align[i] = 'right'; + } else if (/^ *:-+: *$/.test(item.align[i])) { + item.align[i] = 'center'; + } else if (/^ *:-+ *$/.test(item.align[i])) { + item.align[i] = 'left'; + } else { + item.align[i] = null; + } + } + + // Get any remaining header rows + l = item.header.length; + for (i = 1; i < l; i++) { + item.header[i] = splitCells(item.header[i], colCount, item.header[i - 1]); + } + + // Get main table cells + l = item.rows.length; + for (i = 0; i < l; i++) { + item.rows[i] = splitCells(item.rows[i], colCount, item.rows[i - 1]); + } + + // header child tokens + l = item.header.length; + for (j = 0; j < l; j++) { + row = item.header[j]; + for (k = 0; k < row.length; k++) { + row[k].tokens = []; + this.lexer.inline(row[k].text, row[k].tokens); + } + } + + // cell child tokens + l = item.rows.length; + for (j = 0; j < l; j++) { + row = item.rows[j]; + for (k = 0; k < row.length; k++) { + row[k].tokens = []; + this.lexer.inline(row[k].text, row[k].tokens); + } + } + return item; + } + } + }, + renderer(token) { + let i, j, row, cell, col, text; + let output = ''; + output += ''; + for (i = 0; i < token.header.length; i++) { + row = token.header[i]; + let col = 0; + output += ''; + for (j = 0; j < row.length; j++) { + cell = row[j]; + text = this.parser.parseInline(cell.tokens); + output += getTableCell(text, cell, 'th', token.align[col]); + col += cell.colspan; + } + output += ''; + } + output += ''; + if (token.rows.length) { + output += ''; + for (i = 0; i < token.rows.length; i++) { + row = token.rows[i]; + col = 0; + output += ''; + for (j = 0; j < row.length; j++) { + cell = row[j]; + text = this.parser.parseInline(cell.tokens); + output += getTableCell(text, cell, 'td', token.align[col]); + col += cell.colspan; + } + output += ''; + } + output += ''; + } + output += '
    '; + return output; + } + } + ] + }; +} + +const getTableCell = (text, cell, type, align) => { + if (!cell.rowspan) { + return ''; + } + const tag = `<${type}` + + `${cell.colspan > 1 ? ` colspan=${cell.colspan}` : ''}` + + `${cell.rowspan > 1 ? ` rowspan=${cell.rowspan}` : ''}` + + `${align ? ` align=${align}` : ''}>`; + return `${tag + text}\n`; +}; + +const splitCells = (tableRow, count, prevRow = []) => { + const cells = [...tableRow.matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((x) => x[0]); + + // Remove first/last cell in a row if whitespace only and no leading/trailing pipe + if (!cells[0]?.trim()) { cells.shift(); } + if (!cells[cells.length - 1]?.trim()) { cells.pop(); } + + let numCols = 0; + let i, j, trimmedCell, prevCell, prevCols; + + for (i = 0; i < cells.length; i++) { + trimmedCell = cells[i].split(/\|+$/)[0]; + cells[i] = { + rowspan: 1, + colspan: Math.max(cells[i].length - trimmedCell.length, 1), + text: trimmedCell.trim().replace(/\\\|/g, '|') + // display escaped pipes as normal character + }; + + // Handle Rowspan + if (trimmedCell.slice(-1) === '^' && prevRow.length) { + // Find matching cell in previous row + prevCols = 0; + for (j = 0; j < prevRow.length; j++) { + prevCell = prevRow[j]; + if ((prevCols === numCols) && (prevCell.colspan === cells[i].colspan)) { + // merge into matching cell in previous row (the "target") + cells[i].rowSpanTarget = prevCell.rowSpanTarget ?? prevCell; + cells[i].rowSpanTarget.text += ` ${cells[i].text.slice(0, -1)}`; + cells[i].rowSpanTarget.rowspan += 1; + cells[i].rowspan = 0; + break; + } + prevCols += prevCell.colspan; + if (prevCols > numCols) { break; } + } + } + + numCols += cells[i].colspan; + } + + // Force main cell rows to match header column count + if (numCols > count) { + cells.splice(count); + } else { + while (numCols < count) { + cells.push({ + colspan: 1, + text: '' + }); + numCols += 1; + } + } + return cells; +}; + +const p$1 = [ + { + type: "note", + icon: '' + }, + { + type: "tip", + icon: '' + }, + { + type: "important", + icon: '' + }, + { + type: "warning", + icon: '' + }, + { + type: "caution", + icon: '' + } +]; +function w$1(e) { + return e.length ? Object.values( + [...p$1, ...e].reduce( + (i, s) => (i[s.type] = s, i), + {} + ) + ) : p$1; +} +function d(e) { + return `^(?:\\[\\!${e.toUpperCase()}\\])[s]*? +?`; +} +function f$1(e) { + return e.slice(0, 1).toUpperCase() + e.slice(1).toLowerCase(); +} +function x$3(e = {}) { + const { className: i = "markdown-alert", variants: s = [] } = e, u = w$1(s); + return { + walkTokens(t) { + var a, o, l, h; + if (t.type !== "blockquote") + return; + const c = u.find( + ({ type: n }) => new RegExp(d(n)).test(t.text) + ); + if (c) { + const { + type: n, + icon: g, + title: Z = f$1(n), + titleClassName: m = `${i}-title` + } = c; + Object.assign(t, { + type: "alert", + meta: { + className: i, + variant: n, + icon: g, + title: Z, + titleClassName: m + } + }); + const r = (a = t.tokens) == null ? void 0 : a[0], v = (o = r.raw) == null ? void 0 : o.replace(new RegExp(d(n)), "").trim(); + v ? (r.tokens = this.Lexer.lexInline( + v + ), (l = t.tokens) == null || l.splice(0, 1, r)) : (h = t.tokens) == null || h.shift(); + } + }, + extensions: [ + { + name: "alert", + level: "block", + renderer({ meta: t, tokens: c = [] }) { + let a = `
    +`; + return a += `

    `, a += t.icon, a += t.title, a += `

    +`, a += this.parser.parse(c), a += `
    +`, a; + } + } + ] + }; +} + +marked.use((extendedTables())); +var optionsAlert = { + variants: [ + { + type: 'danger', + icon: '🚨', + title: 'Oh snap!', // optional + titleClassName: 'text-danger' // optional + }, + { + type: 'note', + icon: '🚨', + title: 'NOTE', // optional + titleClassName: 'text-info' // optional + }, + { + type: 'tip', + icon: '🚨', + title: 'TIP', // optional + titleClassName: 'text-info' // optional + }, + { + type: 'important', + icon: '🚨', + title: 'CAUTION', // optional + titleClassName: 'text-info' // optional + }, + { + type: 'warning', + icon: '🚨', + title: 'WARNING', // optional + titleClassName: 'text-warning' // optional + }, + { + type: 'caution', + icon: '🚨', + title: 'CAUTION', // optional + titleClassName: 'text-danger' // optional + }, + ] +}; +marked.use(x$3(optionsAlert)); +function md2Html(md) { + var elDiv = document.createElement('div'); + elDiv.id = 'tmpDiv'; + elDiv.innerHTML = marked.parse(md, { + gfm: false, + }); + var regex = /[$]+/g; + elDiv.querySelectorAll('p').forEach(function (el) { + var _a; + var str = el.textContent || ''; + if (((_a = str.match(regex)) === null || _a === void 0 ? void 0 : _a.length) == 2) { + str = str.replace(regex, ''); + katex.render(str, el, { + throwOnError: false, + leqno: true, + }); + } + }); + return elDiv.innerHTML; +} + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function dedent(templ) { + var values = []; + for (var _i = 1; _i < arguments.length; _i++) { + values[_i - 1] = arguments[_i]; + } + var strings = Array.from(typeof templ === 'string' ? [templ] : templ); + strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, ''); + var indentLengths = strings.reduce(function (arr, str) { + var matches = str.match(/\n([\t ]+|(?!\s).)/g); + if (matches) { + return arr.concat(matches.map(function (match) { var _a, _b; return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0; })); + } + return arr; + }, []); + if (indentLengths.length) { + var pattern_1 = new RegExp("\n[\t ]{" + Math.min.apply(Math, indentLengths) + "}", 'g'); + strings = strings.map(function (str) { return str.replace(pattern_1, '\n'); }); + } + strings[0] = strings[0].replace(/^\r?\n/, ''); + var string = strings[0]; + values.forEach(function (value, i) { + var endentations = string.match(/(?:^|\n)( *)$/); + var endentation = endentations ? endentations[1] : ''; + var indentedValue = value; + if (typeof value === 'string' && value.includes('\n')) { + indentedValue = String(value) + .split('\n') + .map(function (str, i) { + return i === 0 ? str : "" + endentation + str; + }) + .join('\n'); + } + string += indentedValue + strings[i + 1]; + }); + return string; +} + +var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var dayjs_min = {exports: {}}; + +(function (module, exports) { + !function(t,e){module.exports=e();}(commonjsGlobal$1,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t) -1; + } + // adapted from https://stackoverflow.com/a/29824550/2601552 + function decodeHtmlCharacters(str) { + var removedNullByte = str.replace(ctrlCharactersRegex, ""); + return removedNullByte.replace(htmlEntitiesRegex, function (match, dec) { + return String.fromCharCode(dec); + }); + } + function sanitizeUrl(url) { + if (!url) { + return exports.BLANK_URL; + } + var sanitizedUrl = decodeHtmlCharacters(url) + .replace(htmlCtrlEntityRegex, "") + .replace(ctrlCharactersRegex, "") + .trim(); + if (!sanitizedUrl) { + return exports.BLANK_URL; + } + if (isRelativeUrlWithoutProtocol(sanitizedUrl)) { + return sanitizedUrl; + } + var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex); + if (!urlSchemeParseResults) { + return sanitizedUrl; + } + var urlScheme = urlSchemeParseResults[0]; + if (invalidProtocolRegex.test(urlScheme)) { + return exports.BLANK_URL; + } + return sanitizedUrl; + } + exports.sanitizeUrl = sanitizeUrl; +} (dist$1)); + +function ascending$2(a, b) { + return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function descending$2(a, b) { + return a == null || b == null ? NaN + : b < a ? -1 + : b > a ? 1 + : b >= a ? 0 + : NaN; +} + +function bisector(f) { + let compare1, compare2, delta; + + // If an accessor is specified, promote it to a comparator. In this case we + // can test whether the search value is (self-) comparable. We can’t do this + // for a comparator (except for specific, known comparators) because we can’t + // tell if the comparator is symmetric, and an asymmetric comparator can’t be + // used to test whether a single value is comparable. + if (f.length !== 2) { + compare1 = ascending$2; + compare2 = (d, x) => ascending$2(f(d), x); + delta = (d, x) => f(d) - x; + } else { + compare1 = f === ascending$2 || f === descending$2 ? f : zero$1; + compare2 = f; + delta = f; + } + + function left(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) < 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function right(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) <= 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function center(a, x, lo = 0, hi = a.length) { + const i = left(a, x, lo, hi - 1); + return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; + } + + return {left, center, right}; +} + +function zero$1() { + return 0; +} + +function number$5(x) { + return x === null ? NaN : +x; +} + +const ascendingBisect = bisector(ascending$2); +const bisectRight = ascendingBisect.right; +bisector(number$5).center; + +class InternMap extends Map { + constructor(entries, key = keyof) { + super(); + Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}}); + if (entries != null) for (const [key, value] of entries) this.set(key, value); + } + get(key) { + return super.get(intern_get(this, key)); + } + has(key) { + return super.has(intern_get(this, key)); + } + set(key, value) { + return super.set(intern_set(this, key), value); + } + delete(key) { + return super.delete(intern_delete(this, key)); + } +} + +function intern_get({_intern, _key}, value) { + const key = _key(value); + return _intern.has(key) ? _intern.get(key) : value; +} + +function intern_set({_intern, _key}, value) { + const key = _key(value); + if (_intern.has(key)) return _intern.get(key); + _intern.set(key, value); + return value; +} + +function intern_delete({_intern, _key}, value) { + const key = _key(value); + if (_intern.has(key)) { + value = _intern.get(key); + _intern.delete(key); + } + return value; +} + +function keyof(value) { + return value !== null && typeof value === "object" ? value.valueOf() : value; +} + +const e10 = Math.sqrt(50), + e5 = Math.sqrt(10), + e2 = Math.sqrt(2); + +function tickSpec(start, stop, count) { + const step = (stop - start) / Math.max(0, count), + power = Math.floor(Math.log10(step)), + error = step / Math.pow(10, power), + factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; + let i1, i2, inc; + if (power < 0) { + inc = Math.pow(10, -power) / factor; + i1 = Math.round(start * inc); + i2 = Math.round(stop * inc); + if (i1 / inc < start) ++i1; + if (i2 / inc > stop) --i2; + inc = -inc; + } else { + inc = Math.pow(10, power) * factor; + i1 = Math.round(start / inc); + i2 = Math.round(stop / inc); + if (i1 * inc < start) ++i1; + if (i2 * inc > stop) --i2; + } + if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); + return [i1, i2, inc]; +} + +function ticks(start, stop, count) { + stop = +stop, start = +start, count = +count; + if (!(count > 0)) return []; + if (start === stop) return [start]; + const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count); + if (!(i2 >= i1)) return []; + const n = i2 - i1 + 1, ticks = new Array(n); + if (reverse) { + if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) / -inc; + else for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) * inc; + } else { + if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) / -inc; + else for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) * inc; + } + return ticks; +} + +function tickIncrement(start, stop, count) { + stop = +stop, start = +start, count = +count; + return tickSpec(start, stop, count)[2]; +} + +function tickStep(start, stop, count) { + stop = +stop, start = +start, count = +count; + const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count); + return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); +} + +function max$4(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min$4(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +function range$1(start, stop, step) { + start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; + + var i = -1, + n = Math.max(0, Math.ceil((stop - start) / step)) | 0, + range = new Array(n); + + while (++i < n) { + range[i] = start + i * step; + } + + return range; +} + +function identity$6(x) { + return x; +} + +var top = 1, + right$1 = 2, + bottom = 3, + left$1 = 4, + epsilon$3 = 1e-6; + +function translateX(x) { + return "translate(" + x + ",0)"; +} + +function translateY(y) { + return "translate(0," + y + ")"; +} + +function number$4(scale) { + return d => +scale(d); +} + +function center$1(scale, offset) { + offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; + if (scale.round()) offset = Math.round(offset); + return d => +scale(d) + offset; +} + +function entering() { + return !this.__axis; +} + +function axis(orient, scale) { + var tickArguments = [], + tickValues = null, + tickFormat = null, + tickSizeInner = 6, + tickSizeOuter = 6, + tickPadding = 3, + offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, + k = orient === top || orient === left$1 ? -1 : 1, + x = orient === left$1 || orient === right$1 ? "x" : "y", + transform = orient === top || orient === bottom ? translateX : translateY; + + function axis(context) { + var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues, + format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$6) : tickFormat, + spacing = Math.max(tickSizeInner, 0) + tickPadding, + range = scale.range(), + range0 = +range[0] + offset, + range1 = +range[range.length - 1] + offset, + position = (scale.bandwidth ? center$1 : number$4)(scale.copy(), offset), + selection = context.selection ? context.selection() : context, + path = selection.selectAll(".domain").data([null]), + tick = selection.selectAll(".tick").data(values, scale).order(), + tickExit = tick.exit(), + tickEnter = tick.enter().append("g").attr("class", "tick"), + line = tick.select("line"), + text = tick.select("text"); + + path = path.merge(path.enter().insert("path", ".tick") + .attr("class", "domain") + .attr("stroke", "currentColor")); + + tick = tick.merge(tickEnter); + + line = line.merge(tickEnter.append("line") + .attr("stroke", "currentColor") + .attr(x + "2", k * tickSizeInner)); + + text = text.merge(tickEnter.append("text") + .attr("fill", "currentColor") + .attr(x, k * spacing) + .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); + + if (context !== selection) { + path = path.transition(context); + tick = tick.transition(context); + line = line.transition(context); + text = text.transition(context); + + tickExit = tickExit.transition(context) + .attr("opacity", epsilon$3) + .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform"); }); + + tickEnter + .attr("opacity", epsilon$3) + .attr("transform", function(d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset); }); + } + + tickExit.remove(); + + path + .attr("d", orient === left$1 || orient === right$1 + ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1) + : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1)); + + tick + .attr("opacity", 1) + .attr("transform", function(d) { return transform(position(d) + offset); }); + + line + .attr(x + "2", k * tickSizeInner); + + text + .attr(x, k * spacing) + .text(format); + + selection.filter(entering) + .attr("fill", "none") + .attr("font-size", 10) + .attr("font-family", "sans-serif") + .attr("text-anchor", orient === right$1 ? "start" : orient === left$1 ? "end" : "middle"); + + selection + .each(function() { this.__axis = position; }); + } + + axis.scale = function(_) { + return arguments.length ? (scale = _, axis) : scale; + }; + + axis.ticks = function() { + return tickArguments = Array.from(arguments), axis; + }; + + axis.tickArguments = function(_) { + return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice(); + }; + + axis.tickValues = function(_) { + return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice(); + }; + + axis.tickFormat = function(_) { + return arguments.length ? (tickFormat = _, axis) : tickFormat; + }; + + axis.tickSize = function(_) { + return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner; + }; + + axis.tickSizeInner = function(_) { + return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner; + }; + + axis.tickSizeOuter = function(_) { + return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter; + }; + + axis.tickPadding = function(_) { + return arguments.length ? (tickPadding = +_, axis) : tickPadding; + }; + + axis.offset = function(_) { + return arguments.length ? (offset = +_, axis) : offset; + }; + + return axis; +} + +function axisTop(scale) { + return axis(top, scale); +} + +function axisBottom(scale) { + return axis(bottom, scale); +} + +var noop$4 = {value: () => {}}; + +function dispatch() { + for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) { + if (!(t = arguments[i] + "") || (t in _) || /[\s.]/.test(t)) throw new Error("illegal type: " + t); + _[t] = []; + } + return new Dispatch(_); +} + +function Dispatch(_) { + this._ = _; +} + +function parseTypenames$1(typenames, types) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t); + return {type: t, name: name}; + }); +} + +Dispatch.prototype = dispatch.prototype = { + constructor: Dispatch, + on: function(typename, callback) { + var _ = this._, + T = parseTypenames$1(typename + "", _), + t, + i = -1, + n = T.length; + + // If no callback was specified, return the callback of the given type and name. + if (arguments.length < 2) { + while (++i < n) if ((t = (typename = T[i]).type) && (t = get$3(_[t], typename.name))) return t; + return; + } + + // If a type was specified, set the callback for the given type and name. + // Otherwise, if a null callback was specified, remove callbacks of the given name. + if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback); + while (++i < n) { + if (t = (typename = T[i]).type) _[t] = set$3(_[t], typename.name, callback); + else if (callback == null) for (t in _) _[t] = set$3(_[t], typename.name, null); + } + + return this; + }, + copy: function() { + var copy = {}, _ = this._; + for (var t in _) copy[t] = _[t].slice(); + return new Dispatch(copy); + }, + call: function(type, that) { + if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2]; + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + }, + apply: function(type, that, args) { + if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type); + for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args); + } +}; + +function get$3(type, name) { + for (var i = 0, n = type.length, c; i < n; ++i) { + if ((c = type[i]).name === name) { + return c.value; + } + } +} + +function set$3(type, name, callback) { + for (var i = 0, n = type.length; i < n; ++i) { + if (type[i].name === name) { + type[i] = noop$4, type = type.slice(0, i).concat(type.slice(i + 1)); + break; + } + } + if (callback != null) type.push({name: name, value: callback}); + return type; +} + +var xhtml = "http://www.w3.org/1999/xhtml"; + +var namespaces$1 = { + svg: "http://www.w3.org/2000/svg", + xhtml: xhtml, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; + +function namespace(name) { + var prefix = name += "", i = prefix.indexOf(":"); + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return namespaces$1.hasOwnProperty(prefix) ? {space: namespaces$1[prefix], local: name} : name; // eslint-disable-line no-prototype-builtins +} + +function creatorInherit(name) { + return function() { + var document = this.ownerDocument, + uri = this.namespaceURI; + return uri === xhtml && document.documentElement.namespaceURI === xhtml + ? document.createElement(name) + : document.createElementNS(uri, name); + }; +} + +function creatorFixed(fullname) { + return function() { + return this.ownerDocument.createElementNS(fullname.space, fullname.local); + }; +} + +function creator(name) { + var fullname = namespace(name); + return (fullname.local + ? creatorFixed + : creatorInherit)(fullname); +} + +function none() {} + +function selector(selector) { + return selector == null ? none : function() { + return this.querySelector(selector); + }; +} + +function selection_select(select) { + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +// Given something array like (or null), returns something that is strictly an +// array. This is used to ensure that array-like objects passed to d3.selectAll +// or selection.selectAll are converted into proper arrays when creating a +// selection; we don’t ever want to create a selection backed by a live +// HTMLCollection or NodeList. However, note that selection.selectAll will use a +// static NodeList as a group, since it safely derived from querySelectorAll. +function array$2(x) { + return x == null ? [] : Array.isArray(x) ? x : Array.from(x); +} + +function empty() { + return []; +} + +function selectorAll(selector) { + return selector == null ? empty : function() { + return this.querySelectorAll(selector); + }; +} + +function arrayAll(select) { + return function() { + return array$2(select.apply(this, arguments)); + }; +} + +function selection_selectAll(select) { + if (typeof select === "function") select = arrayAll(select); + else select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + subgroups.push(select.call(node, node.__data__, i, group)); + parents.push(node); + } + } + } + + return new Selection$1(subgroups, parents); +} + +function matcher(selector) { + return function() { + return this.matches(selector); + }; +} + +function childMatcher(selector) { + return function(node) { + return node.matches(selector); + }; +} + +var find$2 = Array.prototype.find; + +function childFind(match) { + return function() { + return find$2.call(this.children, match); + }; +} + +function childFirst() { + return this.firstElementChild; +} + +function selection_selectChild(match) { + return this.select(match == null ? childFirst + : childFind(typeof match === "function" ? match : childMatcher(match))); +} + +var filter$2 = Array.prototype.filter; + +function children() { + return Array.from(this.children); +} + +function childrenFilter(match) { + return function() { + return filter$2.call(this.children, match); + }; +} + +function selection_selectChildren(match) { + return this.selectAll(match == null ? children + : childrenFilter(typeof match === "function" ? match : childMatcher(match))); +} + +function selection_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Selection$1(subgroups, this._parents); +} + +function sparse(update) { + return new Array(update.length); +} + +function selection_enter() { + return new Selection$1(this._enter || this._groups.map(sparse), this._parents); +} + +function EnterNode(parent, datum) { + this.ownerDocument = parent.ownerDocument; + this.namespaceURI = parent.namespaceURI; + this._next = null; + this._parent = parent; + this.__data__ = datum; +} + +EnterNode.prototype = { + constructor: EnterNode, + appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, + insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, + querySelector: function(selector) { return this._parent.querySelector(selector); }, + querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } +}; + +function constant$5(x) { + return function() { + return x; + }; +} + +function bindIndex(parent, group, enter, update, exit, data) { + var i = 0, + node, + groupLength = group.length, + dataLength = data.length; + + // Put any non-null nodes that fit into update. + // Put any null nodes into enter. + // Put any remaining data into enter. + for (; i < dataLength; ++i) { + if (node = group[i]) { + node.__data__ = data[i]; + update[i] = node; + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Put any non-null nodes that don’t fit into exit. + for (; i < groupLength; ++i) { + if (node = group[i]) { + exit[i] = node; + } + } +} + +function bindKey(parent, group, enter, update, exit, data, key) { + var i, + node, + nodeByKeyValue = new Map, + groupLength = group.length, + dataLength = data.length, + keyValues = new Array(groupLength), + keyValue; + + // Compute the key for each node. + // If multiple nodes have the same key, the duplicates are added to exit. + for (i = 0; i < groupLength; ++i) { + if (node = group[i]) { + keyValues[i] = keyValue = key.call(node, node.__data__, i, group) + ""; + if (nodeByKeyValue.has(keyValue)) { + exit[i] = node; + } else { + nodeByKeyValue.set(keyValue, node); + } + } + } + + // Compute the key for each datum. + // If there a node associated with this key, join and add it to update. + // If there is not (or the key is a duplicate), add it to enter. + for (i = 0; i < dataLength; ++i) { + keyValue = key.call(parent, data[i], i, data) + ""; + if (node = nodeByKeyValue.get(keyValue)) { + update[i] = node; + node.__data__ = data[i]; + nodeByKeyValue.delete(keyValue); + } else { + enter[i] = new EnterNode(parent, data[i]); + } + } + + // Add any remaining nodes that were not bound to data to exit. + for (i = 0; i < groupLength; ++i) { + if ((node = group[i]) && (nodeByKeyValue.get(keyValues[i]) === node)) { + exit[i] = node; + } + } +} + +function datum(node) { + return node.__data__; +} + +function selection_data(value, key) { + if (!arguments.length) return Array.from(this, datum); + + var bind = key ? bindKey : bindIndex, + parents = this._parents, + groups = this._groups; + + if (typeof value !== "function") value = constant$5(value); + + for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { + var parent = parents[j], + group = groups[j], + groupLength = group.length, + data = arraylike(value.call(parent, parent && parent.__data__, j, parents)), + dataLength = data.length, + enterGroup = enter[j] = new Array(dataLength), + updateGroup = update[j] = new Array(dataLength), + exitGroup = exit[j] = new Array(groupLength); + + bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); + + // Now connect the enter nodes to their following update node, such that + // appendChild can insert the materialized enter node before this node, + // rather than at the end of the parent node. + for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { + if (previous = enterGroup[i0]) { + if (i0 >= i1) i1 = i0 + 1; + while (!(next = updateGroup[i1]) && ++i1 < dataLength); + previous._next = next || null; + } + } + } + + update = new Selection$1(update, parents); + update._enter = enter; + update._exit = exit; + return update; +} + +// Given some data, this returns an array-like view of it: an object that +// exposes a length property and allows numeric indexing. Note that unlike +// selectAll, this isn’t worried about “live” collections because the resulting +// array will only be used briefly while data is being bound. (It is possible to +// cause the data to change while iterating by using a key function, but please +// don’t; we’d rather avoid a gratuitous copy.) +function arraylike(data) { + return typeof data === "object" && "length" in data + ? data // Array, TypedArray, NodeList, array-like + : Array.from(data); // Map, Set, iterable, string, or anything else +} + +function selection_exit() { + return new Selection$1(this._exit || this._groups.map(sparse), this._parents); +} + +function selection_join(onenter, onupdate, onexit) { + var enter = this.enter(), update = this, exit = this.exit(); + if (typeof onenter === "function") { + enter = onenter(enter); + if (enter) enter = enter.selection(); + } else { + enter = enter.append(onenter + ""); + } + if (onupdate != null) { + update = onupdate(update); + if (update) update = update.selection(); + } + if (onexit == null) exit.remove(); else onexit(exit); + return enter && update ? enter.merge(update).order() : update; +} + +function selection_merge(context) { + var selection = context.selection ? context.selection() : context; + + for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Selection$1(merges, this._parents); +} + +function selection_order() { + + for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { + for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) { + if (node = group[i]) { + if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next); + next = node; + } + } + } + + return this; +} + +function selection_sort(compare) { + if (!compare) compare = ascending$1; + + function compareNode(a, b) { + return a && b ? compare(a.__data__, b.__data__) : !a - !b; + } + + for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group[i]) { + sortgroup[i] = node; + } + } + sortgroup.sort(compareNode); + } + + return new Selection$1(sortgroups, this._parents).order(); +} + +function ascending$1(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function selection_call() { + var callback = arguments[0]; + arguments[0] = this; + callback.apply(null, arguments); + return this; +} + +function selection_nodes() { + return Array.from(this); +} + +function selection_node() { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { + var node = group[i]; + if (node) return node; + } + } + + return null; +} + +function selection_size() { + let size = 0; + for (const node of this) ++size; // eslint-disable-line no-unused-vars + return size; +} + +function selection_empty() { + return !this.node(); +} + +function selection_each(callback) { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) callback.call(node, node.__data__, i, group); + } + } + + return this; +} + +function attrRemove$1(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS$1(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant$1(name, value) { + return function() { + this.setAttribute(name, value); + }; +} + +function attrConstantNS$1(fullname, value) { + return function() { + this.setAttributeNS(fullname.space, fullname.local, value); + }; +} + +function attrFunction$1(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttribute(name); + else this.setAttribute(name, v); + }; +} + +function attrFunctionNS$1(fullname, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttributeNS(fullname.space, fullname.local); + else this.setAttributeNS(fullname.space, fullname.local, v); + }; +} + +function selection_attr(name, value) { + var fullname = namespace(name); + + if (arguments.length < 2) { + var node = this.node(); + return fullname.local + ? node.getAttributeNS(fullname.space, fullname.local) + : node.getAttribute(fullname); + } + + return this.each((value == null + ? (fullname.local ? attrRemoveNS$1 : attrRemove$1) : (typeof value === "function" + ? (fullname.local ? attrFunctionNS$1 : attrFunction$1) + : (fullname.local ? attrConstantNS$1 : attrConstant$1)))(fullname, value)); +} + +function defaultView(node) { + return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node + || (node.document && node) // node is a Window + || node.defaultView; // node is a Document +} + +function styleRemove$1(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant$1(name, value, priority) { + return function() { + this.style.setProperty(name, value, priority); + }; +} + +function styleFunction$1(name, value, priority) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.style.removeProperty(name); + else this.style.setProperty(name, v, priority); + }; +} + +function selection_style(name, value, priority) { + return arguments.length > 1 + ? this.each((value == null + ? styleRemove$1 : typeof value === "function" + ? styleFunction$1 + : styleConstant$1)(name, value, priority == null ? "" : priority)) + : styleValue(this.node(), name); +} + +function styleValue(node, name) { + return node.style.getPropertyValue(name) + || defaultView(node).getComputedStyle(node, null).getPropertyValue(name); +} + +function propertyRemove(name) { + return function() { + delete this[name]; + }; +} + +function propertyConstant(name, value) { + return function() { + this[name] = value; + }; +} + +function propertyFunction(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) delete this[name]; + else this[name] = v; + }; +} + +function selection_property(name, value) { + return arguments.length > 1 + ? this.each((value == null + ? propertyRemove : typeof value === "function" + ? propertyFunction + : propertyConstant)(name, value)) + : this.node()[name]; +} + +function classArray(string) { + return string.trim().split(/^|\s+/); +} + +function classList(node) { + return node.classList || new ClassList(node); +} + +function ClassList(node) { + this._node = node; + this._names = classArray(node.getAttribute("class") || ""); +} + +ClassList.prototype = { + add: function(name) { + var i = this._names.indexOf(name); + if (i < 0) { + this._names.push(name); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + remove: function(name) { + var i = this._names.indexOf(name); + if (i >= 0) { + this._names.splice(i, 1); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + contains: function(name) { + return this._names.indexOf(name) >= 0; + } +}; + +function classedAdd(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.add(names[i]); +} + +function classedRemove(node, names) { + var list = classList(node), i = -1, n = names.length; + while (++i < n) list.remove(names[i]); +} + +function classedTrue(names) { + return function() { + classedAdd(this, names); + }; +} + +function classedFalse(names) { + return function() { + classedRemove(this, names); + }; +} + +function classedFunction(names, value) { + return function() { + (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); + }; +} + +function selection_classed(name, value) { + var names = classArray(name + ""); + + if (arguments.length < 2) { + var list = classList(this.node()), i = -1, n = names.length; + while (++i < n) if (!list.contains(names[i])) return false; + return true; + } + + return this.each((typeof value === "function" + ? classedFunction : value + ? classedTrue + : classedFalse)(names, value)); +} + +function textRemove() { + this.textContent = ""; +} + +function textConstant$1(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction$1(value) { + return function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + }; +} + +function selection_text(value) { + return arguments.length + ? this.each(value == null + ? textRemove : (typeof value === "function" + ? textFunction$1 + : textConstant$1)(value)) + : this.node().textContent; +} + +function htmlRemove() { + this.innerHTML = ""; +} + +function htmlConstant(value) { + return function() { + this.innerHTML = value; + }; +} + +function htmlFunction(value) { + return function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + }; +} + +function selection_html(value) { + return arguments.length + ? this.each(value == null + ? htmlRemove : (typeof value === "function" + ? htmlFunction + : htmlConstant)(value)) + : this.node().innerHTML; +} + +function raise() { + if (this.nextSibling) this.parentNode.appendChild(this); +} + +function selection_raise() { + return this.each(raise); +} + +function lower() { + if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); +} + +function selection_lower() { + return this.each(lower); +} + +function selection_append(name) { + var create = typeof name === "function" ? name : creator(name); + return this.select(function() { + return this.appendChild(create.apply(this, arguments)); + }); +} + +function constantNull() { + return null; +} + +function selection_insert(name, before) { + var create = typeof name === "function" ? name : creator(name), + select = before == null ? constantNull : typeof before === "function" ? before : selector(before); + return this.select(function() { + return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); + }); +} + +function remove() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); +} + +function selection_remove() { + return this.each(remove); +} + +function selection_cloneShallow() { + var clone = this.cloneNode(false), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_cloneDeep() { + var clone = this.cloneNode(true), parent = this.parentNode; + return parent ? parent.insertBefore(clone, this.nextSibling) : clone; +} + +function selection_clone(deep) { + return this.select(deep ? selection_cloneDeep : selection_cloneShallow); +} + +function selection_datum(value) { + return arguments.length + ? this.property("__data__", value) + : this.node().__data__; +} + +function contextListener(listener) { + return function(event) { + listener.call(this, event, this.__data__); + }; +} + +function parseTypenames(typenames) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + return {type: t, name: name}; + }); +} + +function onRemove(typename) { + return function() { + var on = this.__on; + if (!on) return; + for (var j = 0, i = -1, m = on.length, o; j < m; ++j) { + if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + } else { + on[++i] = o; + } + } + if (++i) on.length = i; + else delete this.__on; + }; +} + +function onAdd(typename, value, options) { + return function() { + var on = this.__on, o, listener = contextListener(value); + if (on) for (var j = 0, m = on.length; j < m; ++j) { + if ((o = on[j]).type === typename.type && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.options); + this.addEventListener(o.type, o.listener = listener, o.options = options); + o.value = value; + return; + } + } + this.addEventListener(typename.type, listener, options); + o = {type: typename.type, name: typename.name, value: value, listener: listener, options: options}; + if (!on) this.__on = [o]; + else on.push(o); + }; +} + +function selection_on(typename, value, options) { + var typenames = parseTypenames(typename + ""), i, n = typenames.length, t; + + if (arguments.length < 2) { + var on = this.node().__on; + if (on) for (var j = 0, m = on.length, o; j < m; ++j) { + for (i = 0, o = on[j]; i < n; ++i) { + if ((t = typenames[i]).type === o.type && t.name === o.name) { + return o.value; + } + } + } + return; + } + + on = value ? onAdd : onRemove; + for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options)); + return this; +} + +function dispatchEvent(node, type, params) { + var window = defaultView(node), + event = window.CustomEvent; + + if (typeof event === "function") { + event = new event(type, params); + } else { + event = window.document.createEvent("Event"); + if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; + else event.initEvent(type, false, false); + } + + node.dispatchEvent(event); +} + +function dispatchConstant(type, params) { + return function() { + return dispatchEvent(this, type, params); + }; +} + +function dispatchFunction(type, params) { + return function() { + return dispatchEvent(this, type, params.apply(this, arguments)); + }; +} + +function selection_dispatch(type, params) { + return this.each((typeof params === "function" + ? dispatchFunction + : dispatchConstant)(type, params)); +} + +function* selection_iterator() { + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) { + if (node = group[i]) yield node; + } + } +} + +var root$2 = [null]; + +function Selection$1(groups, parents) { + this._groups = groups; + this._parents = parents; +} + +function selection() { + return new Selection$1([[document.documentElement]], root$2); +} + +function selection_selection() { + return this; +} + +Selection$1.prototype = selection.prototype = { + constructor: Selection$1, + select: selection_select, + selectAll: selection_selectAll, + selectChild: selection_selectChild, + selectChildren: selection_selectChildren, + filter: selection_filter, + data: selection_data, + enter: selection_enter, + exit: selection_exit, + join: selection_join, + merge: selection_merge, + selection: selection_selection, + order: selection_order, + sort: selection_sort, + call: selection_call, + nodes: selection_nodes, + node: selection_node, + size: selection_size, + empty: selection_empty, + each: selection_each, + attr: selection_attr, + style: selection_style, + property: selection_property, + classed: selection_classed, + text: selection_text, + html: selection_html, + raise: selection_raise, + lower: selection_lower, + append: selection_append, + insert: selection_insert, + remove: selection_remove, + clone: selection_clone, + datum: selection_datum, + on: selection_on, + dispatch: selection_dispatch, + [Symbol.iterator]: selection_iterator +}; + +function select(selector) { + return typeof selector === "string" + ? new Selection$1([[document.querySelector(selector)]], [document.documentElement]) + : new Selection$1([[selector]], root$2); +} + +function selectAll(selector) { + return typeof selector === "string" + ? new Selection$1([document.querySelectorAll(selector)], [document.documentElement]) + : new Selection$1([array$2(selector)], root$2); +} + +function define$4(constructor, factory, prototype) { + constructor.prototype = factory.prototype = prototype; + prototype.constructor = constructor; +} + +function extend$2(parent, definition) { + var prototype = Object.create(parent.prototype); + for (var key in definition) prototype[key] = definition[key]; + return prototype; +} + +function Color$1() {} + +var darker = 0.7; +var brighter = 1 / darker; + +var reI = "\\s*([+-]?\\d+)\\s*", + reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", + reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", + reHex = /^#([0-9a-f]{3,8})$/, + reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), + reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), + reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), + reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), + reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), + reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); + +var named = { + aliceblue: 0xf0f8ff, + antiquewhite: 0xfaebd7, + aqua: 0x00ffff, + aquamarine: 0x7fffd4, + azure: 0xf0ffff, + beige: 0xf5f5dc, + bisque: 0xffe4c4, + black: 0x000000, + blanchedalmond: 0xffebcd, + blue: 0x0000ff, + blueviolet: 0x8a2be2, + brown: 0xa52a2a, + burlywood: 0xdeb887, + cadetblue: 0x5f9ea0, + chartreuse: 0x7fff00, + chocolate: 0xd2691e, + coral: 0xff7f50, + cornflowerblue: 0x6495ed, + cornsilk: 0xfff8dc, + crimson: 0xdc143c, + cyan: 0x00ffff, + darkblue: 0x00008b, + darkcyan: 0x008b8b, + darkgoldenrod: 0xb8860b, + darkgray: 0xa9a9a9, + darkgreen: 0x006400, + darkgrey: 0xa9a9a9, + darkkhaki: 0xbdb76b, + darkmagenta: 0x8b008b, + darkolivegreen: 0x556b2f, + darkorange: 0xff8c00, + darkorchid: 0x9932cc, + darkred: 0x8b0000, + darksalmon: 0xe9967a, + darkseagreen: 0x8fbc8f, + darkslateblue: 0x483d8b, + darkslategray: 0x2f4f4f, + darkslategrey: 0x2f4f4f, + darkturquoise: 0x00ced1, + darkviolet: 0x9400d3, + deeppink: 0xff1493, + deepskyblue: 0x00bfff, + dimgray: 0x696969, + dimgrey: 0x696969, + dodgerblue: 0x1e90ff, + firebrick: 0xb22222, + floralwhite: 0xfffaf0, + forestgreen: 0x228b22, + fuchsia: 0xff00ff, + gainsboro: 0xdcdcdc, + ghostwhite: 0xf8f8ff, + gold: 0xffd700, + goldenrod: 0xdaa520, + gray: 0x808080, + green: 0x008000, + greenyellow: 0xadff2f, + grey: 0x808080, + honeydew: 0xf0fff0, + hotpink: 0xff69b4, + indianred: 0xcd5c5c, + indigo: 0x4b0082, + ivory: 0xfffff0, + khaki: 0xf0e68c, + lavender: 0xe6e6fa, + lavenderblush: 0xfff0f5, + lawngreen: 0x7cfc00, + lemonchiffon: 0xfffacd, + lightblue: 0xadd8e6, + lightcoral: 0xf08080, + lightcyan: 0xe0ffff, + lightgoldenrodyellow: 0xfafad2, + lightgray: 0xd3d3d3, + lightgreen: 0x90ee90, + lightgrey: 0xd3d3d3, + lightpink: 0xffb6c1, + lightsalmon: 0xffa07a, + lightseagreen: 0x20b2aa, + lightskyblue: 0x87cefa, + lightslategray: 0x778899, + lightslategrey: 0x778899, + lightsteelblue: 0xb0c4de, + lightyellow: 0xffffe0, + lime: 0x00ff00, + limegreen: 0x32cd32, + linen: 0xfaf0e6, + magenta: 0xff00ff, + maroon: 0x800000, + mediumaquamarine: 0x66cdaa, + mediumblue: 0x0000cd, + mediumorchid: 0xba55d3, + mediumpurple: 0x9370db, + mediumseagreen: 0x3cb371, + mediumslateblue: 0x7b68ee, + mediumspringgreen: 0x00fa9a, + mediumturquoise: 0x48d1cc, + mediumvioletred: 0xc71585, + midnightblue: 0x191970, + mintcream: 0xf5fffa, + mistyrose: 0xffe4e1, + moccasin: 0xffe4b5, + navajowhite: 0xffdead, + navy: 0x000080, + oldlace: 0xfdf5e6, + olive: 0x808000, + olivedrab: 0x6b8e23, + orange: 0xffa500, + orangered: 0xff4500, + orchid: 0xda70d6, + palegoldenrod: 0xeee8aa, + palegreen: 0x98fb98, + paleturquoise: 0xafeeee, + palevioletred: 0xdb7093, + papayawhip: 0xffefd5, + peachpuff: 0xffdab9, + peru: 0xcd853f, + pink: 0xffc0cb, + plum: 0xdda0dd, + powderblue: 0xb0e0e6, + purple: 0x800080, + rebeccapurple: 0x663399, + red: 0xff0000, + rosybrown: 0xbc8f8f, + royalblue: 0x4169e1, + saddlebrown: 0x8b4513, + salmon: 0xfa8072, + sandybrown: 0xf4a460, + seagreen: 0x2e8b57, + seashell: 0xfff5ee, + sienna: 0xa0522d, + silver: 0xc0c0c0, + skyblue: 0x87ceeb, + slateblue: 0x6a5acd, + slategray: 0x708090, + slategrey: 0x708090, + snow: 0xfffafa, + springgreen: 0x00ff7f, + steelblue: 0x4682b4, + tan: 0xd2b48c, + teal: 0x008080, + thistle: 0xd8bfd8, + tomato: 0xff6347, + turquoise: 0x40e0d0, + violet: 0xee82ee, + wheat: 0xf5deb3, + white: 0xffffff, + whitesmoke: 0xf5f5f5, + yellow: 0xffff00, + yellowgreen: 0x9acd32 +}; + +define$4(Color$1, color, { + copy(channels) { + return Object.assign(new this.constructor, this, channels); + }, + displayable() { + return this.rgb().displayable(); + }, + hex: color_formatHex, // Deprecated! Use color.formatHex. + formatHex: color_formatHex, + formatHex8: color_formatHex8, + formatHsl: color_formatHsl, + formatRgb: color_formatRgb, + toString: color_formatRgb +}); + +function color_formatHex() { + return this.rgb().formatHex(); +} + +function color_formatHex8() { + return this.rgb().formatHex8(); +} + +function color_formatHsl() { + return hslConvert(this).formatHsl(); +} + +function color_formatRgb() { + return this.rgb().formatRgb(); +} + +function color(format) { + var m, l; + format = (format + "").trim().toLowerCase(); + return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000 + : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00 + : l === 8 ? rgba$2(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000 + : l === 4 ? rgba$2((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000 + : null) // invalid hex + : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) + : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) + : (m = reRgbaInteger.exec(format)) ? rgba$2(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) + : (m = reRgbaPercent.exec(format)) ? rgba$2(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) + : (m = reHslPercent.exec(format)) ? hsla$1(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) + : (m = reHslaPercent.exec(format)) ? hsla$1(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) + : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins + : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) + : null; +} + +function rgbn(n) { + return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); +} + +function rgba$2(r, g, b, a) { + if (a <= 0) r = g = b = NaN; + return new Rgb(r, g, b, a); +} + +function rgbConvert(o) { + if (!(o instanceof Color$1)) o = color(o); + if (!o) return new Rgb; + o = o.rgb(); + return new Rgb(o.r, o.g, o.b, o.opacity); +} + +function rgb(r, g, b, opacity) { + return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); +} + +function Rgb(r, g, b, opacity) { + this.r = +r; + this.g = +g; + this.b = +b; + this.opacity = +opacity; +} + +define$4(Rgb, rgb, extend$2(Color$1, { + brighter(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + darker(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); + }, + rgb() { + return this; + }, + clamp() { + return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); + }, + displayable() { + return (-0.5 <= this.r && this.r < 255.5) + && (-0.5 <= this.g && this.g < 255.5) + && (-0.5 <= this.b && this.b < 255.5) + && (0 <= this.opacity && this.opacity <= 1); + }, + hex: rgb_formatHex, // Deprecated! Use color.formatHex. + formatHex: rgb_formatHex, + formatHex8: rgb_formatHex8, + formatRgb: rgb_formatRgb, + toString: rgb_formatRgb +})); + +function rgb_formatHex() { + return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; +} + +function rgb_formatHex8() { + return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; +} + +function rgb_formatRgb() { + const a = clampa(this.opacity); + return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`; +} + +function clampa(opacity) { + return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); +} + +function clampi(value) { + return Math.max(0, Math.min(255, Math.round(value) || 0)); +} + +function hex(value) { + value = clampi(value); + return (value < 16 ? "0" : "") + value.toString(16); +} + +function hsla$1(h, s, l, a) { + if (a <= 0) h = s = l = NaN; + else if (l <= 0 || l >= 1) h = s = NaN; + else if (s <= 0) h = NaN; + return new Hsl(h, s, l, a); +} + +function hslConvert(o) { + if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); + if (!(o instanceof Color$1)) o = color(o); + if (!o) return new Hsl; + if (o instanceof Hsl) return o; + o = o.rgb(); + var r = o.r / 255, + g = o.g / 255, + b = o.b / 255, + min = Math.min(r, g, b), + max = Math.max(r, g, b), + h = NaN, + s = max - min, + l = (max + min) / 2; + if (s) { + if (r === max) h = (g - b) / s + (g < b) * 6; + else if (g === max) h = (b - r) / s + 2; + else h = (r - g) / s + 4; + s /= l < 0.5 ? max + min : 2 - max - min; + h *= 60; + } else { + s = l > 0 && l < 1 ? 0 : h; + } + return new Hsl(h, s, l, o.opacity); +} + +function hsl(h, s, l, opacity) { + return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); +} + +function Hsl(h, s, l, opacity) { + this.h = +h; + this.s = +s; + this.l = +l; + this.opacity = +opacity; +} + +define$4(Hsl, hsl, extend$2(Color$1, { + brighter(k) { + k = k == null ? brighter : Math.pow(brighter, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + darker(k) { + k = k == null ? darker : Math.pow(darker, k); + return new Hsl(this.h, this.s, this.l * k, this.opacity); + }, + rgb() { + var h = this.h % 360 + (this.h < 0) * 360, + s = isNaN(h) || isNaN(this.s) ? 0 : this.s, + l = this.l, + m2 = l + (l < 0.5 ? l : 1 - l) * s, + m1 = 2 * l - m2; + return new Rgb( + hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), + hsl2rgb(h, m1, m2), + hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), + this.opacity + ); + }, + clamp() { + return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); + }, + displayable() { + return (0 <= this.s && this.s <= 1 || isNaN(this.s)) + && (0 <= this.l && this.l <= 1) + && (0 <= this.opacity && this.opacity <= 1); + }, + formatHsl() { + const a = clampa(this.opacity); + return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`; + } +})); + +function clamph(value) { + value = (value || 0) % 360; + return value < 0 ? value + 360 : value; +} + +function clampt(value) { + return Math.max(0, Math.min(1, value || 0)); +} + +/* From FvD 13.37, CSS Color Module Level 3 */ +function hsl2rgb(h, m1, m2) { + return (h < 60 ? m1 + (m2 - m1) * h / 60 + : h < 180 ? m2 + : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 + : m1) * 255; +} + +const radians = Math.PI / 180; +const degrees$1 = 180 / Math.PI; + +// https://observablehq.com/@mbostock/lab-and-rgb +const K$1 = 18, + Xn = 0.96422, + Yn = 1, + Zn = 0.82521, + t0$1 = 4 / 29, + t1$1 = 6 / 29, + t2 = 3 * t1$1 * t1$1, + t3 = t1$1 * t1$1 * t1$1; + +function labConvert(o) { + if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); + if (o instanceof Hcl) return hcl2lab(o); + if (!(o instanceof Rgb)) o = rgbConvert(o); + var r = rgb2lrgb(o.r), + g = rgb2lrgb(o.g), + b = rgb2lrgb(o.b), + y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z; + if (r === g && g === b) x = z = y; else { + x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); + z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); + } + return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); +} + +function lab(l, a, b, opacity) { + return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); +} + +function Lab(l, a, b, opacity) { + this.l = +l; + this.a = +a; + this.b = +b; + this.opacity = +opacity; +} + +define$4(Lab, lab, extend$2(Color$1, { + brighter(k) { + return new Lab(this.l + K$1 * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + darker(k) { + return new Lab(this.l - K$1 * (k == null ? 1 : k), this.a, this.b, this.opacity); + }, + rgb() { + var y = (this.l + 16) / 116, + x = isNaN(this.a) ? y : y + this.a / 500, + z = isNaN(this.b) ? y : y - this.b / 200; + x = Xn * lab2xyz(x); + y = Yn * lab2xyz(y); + z = Zn * lab2xyz(z); + return new Rgb( + lrgb2rgb( 3.1338561 * x - 1.6168667 * y - 0.4906146 * z), + lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), + lrgb2rgb( 0.0719453 * x - 0.2289914 * y + 1.4052427 * z), + this.opacity + ); + } +})); + +function xyz2lab(t) { + return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0$1; +} + +function lab2xyz(t) { + return t > t1$1 ? t * t * t : t2 * (t - t0$1); +} + +function lrgb2rgb(x) { + return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); +} + +function rgb2lrgb(x) { + return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); +} + +function hclConvert(o) { + if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); + if (!(o instanceof Lab)) o = labConvert(o); + if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); + var h = Math.atan2(o.b, o.a) * degrees$1; + return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); +} + +function hcl$1(h, c, l, opacity) { + return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); +} + +function Hcl(h, c, l, opacity) { + this.h = +h; + this.c = +c; + this.l = +l; + this.opacity = +opacity; +} + +function hcl2lab(o) { + if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity); + var h = o.h * radians; + return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); +} + +define$4(Hcl, hcl$1, extend$2(Color$1, { + brighter(k) { + return new Hcl(this.h, this.c, this.l + K$1 * (k == null ? 1 : k), this.opacity); + }, + darker(k) { + return new Hcl(this.h, this.c, this.l - K$1 * (k == null ? 1 : k), this.opacity); + }, + rgb() { + return hcl2lab(this).rgb(); + } +})); + +var constant$4 = x => () => x; + +function linear$1(a, d) { + return function(t) { + return a + t * d; + }; +} + +function exponential(a, b, y) { + return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function(t) { + return Math.pow(a + t * b, y); + }; +} + +function hue(a, b) { + var d = b - a; + return d ? linear$1(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$4(isNaN(a) ? b : a); +} + +function gamma(y) { + return (y = +y) === 1 ? nogamma : function(a, b) { + return b - a ? exponential(a, b, y) : constant$4(isNaN(a) ? b : a); + }; +} + +function nogamma(a, b) { + var d = b - a; + return d ? linear$1(a, d) : constant$4(isNaN(a) ? b : a); +} + +var interpolateRgb = (function rgbGamma(y) { + var color = gamma(y); + + function rgb$1(start, end) { + var r = color((start = rgb(start)).r, (end = rgb(end)).r), + g = color(start.g, end.g), + b = color(start.b, end.b), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.r = r(t); + start.g = g(t); + start.b = b(t); + start.opacity = opacity(t); + return start + ""; + }; + } + + rgb$1.gamma = rgbGamma; + + return rgb$1; +})(1); + +function numberArray(a, b) { + if (!b) b = []; + var n = a ? Math.min(b.length, a.length) : 0, + c = b.slice(), + i; + return function(t) { + for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t; + return c; + }; +} + +function isNumberArray(x) { + return ArrayBuffer.isView(x) && !(x instanceof DataView); +} + +function genericArray(a, b) { + var nb = b ? b.length : 0, + na = a ? Math.min(nb, a.length) : 0, + x = new Array(na), + c = new Array(nb), + i; + + for (i = 0; i < na; ++i) x[i] = interpolate$1(a[i], b[i]); + for (; i < nb; ++i) c[i] = b[i]; + + return function(t) { + for (i = 0; i < na; ++i) c[i] = x[i](t); + return c; + }; +} + +function date$1(a, b) { + var d = new Date; + return a = +a, b = +b, function(t) { + return d.setTime(a * (1 - t) + b * t), d; + }; +} + +function interpolateNumber(a, b) { + return a = +a, b = +b, function(t) { + return a * (1 - t) + b * t; + }; +} + +function object$1(a, b) { + var i = {}, + c = {}, + k; + + if (a === null || typeof a !== "object") a = {}; + if (b === null || typeof b !== "object") b = {}; + + for (k in b) { + if (k in a) { + i[k] = interpolate$1(a[k], b[k]); + } else { + c[k] = b[k]; + } + } + + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; +} + +var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, + reB = new RegExp(reA.source, "g"); + +function zero(b) { + return function() { + return b; + }; +} + +function one$1(b) { + return function(t) { + return b(t) + ""; + }; +} + +function interpolateString(a, b) { + var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b + am, // current match in a + bm, // current match in b + bs, // string preceding current number in b, if any + i = -1, // index in s + s = [], // string constants and placeholders + q = []; // number interpolators + + // Coerce inputs to strings. + a = a + "", b = b + ""; + + // Interpolate pairs of numbers in a & b. + while ((am = reA.exec(a)) + && (bm = reB.exec(b))) { + if ((bs = bm.index) > bi) { // a string precedes the next number in b + bs = b.slice(bi, bs); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match + if (s[i]) s[i] += bm; // coalesce with previous string + else s[++i] = bm; + } else { // interpolate non-matching numbers + s[++i] = null; + q.push({i: i, x: interpolateNumber(am, bm)}); + } + bi = reB.lastIndex; + } + + // Add remains of b. + if (bi < b.length) { + bs = b.slice(bi); + if (s[i]) s[i] += bs; // coalesce with previous string + else s[++i] = bs; + } + + // Special optimization for only a single match. + // Otherwise, interpolate each of the numbers and rejoin the string. + return s.length < 2 ? (q[0] + ? one$1(q[0].x) + : zero(b)) + : (b = q.length, function(t) { + for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }); +} + +function interpolate$1(a, b) { + var t = typeof b, c; + return b == null || t === "boolean" ? constant$4(b) + : (t === "number" ? interpolateNumber + : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString) + : b instanceof color ? interpolateRgb + : b instanceof Date ? date$1 + : isNumberArray(b) ? numberArray + : Array.isArray(b) ? genericArray + : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object$1 + : interpolateNumber)(a, b); +} + +function interpolateRound(a, b) { + return a = +a, b = +b, function(t) { + return Math.round(a * (1 - t) + b * t); + }; +} + +var degrees = 180 / Math.PI; + +var identity$5 = { + translateX: 0, + translateY: 0, + rotate: 0, + skewX: 0, + scaleX: 1, + scaleY: 1 +}; + +function decompose(a, b, c, d, e, f) { + var scaleX, scaleY, skewX; + if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX; + if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX; + if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY; + if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX; + return { + translateX: e, + translateY: f, + rotate: Math.atan2(b, a) * degrees, + skewX: Math.atan(skewX) * degrees, + scaleX: scaleX, + scaleY: scaleY + }; +} + +var svgNode; + +/* eslint-disable no-undef */ +function parseCss(value) { + const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); + return m.isIdentity ? identity$5 : decompose(m.a, m.b, m.c, m.d, m.e, m.f); +} + +function parseSvg(value) { + if (value == null) return identity$5; + if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); + svgNode.setAttribute("transform", value); + if (!(value = svgNode.transform.baseVal.consolidate())) return identity$5; + value = value.matrix; + return decompose(value.a, value.b, value.c, value.d, value.e, value.f); +} + +function interpolateTransform(parse, pxComma, pxParen, degParen) { + + function pop(s) { + return s.length ? s.pop() + " " : ""; + } + + function translate(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push("translate(", null, pxComma, null, pxParen); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb || yb) { + s.push("translate(" + xb + pxComma + yb + pxParen); + } + } + + function rotate(a, b, s, q) { + if (a !== b) { + if (a - b > 180) b += 360; else if (b - a > 180) a += 360; // shortest path + q.push({i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "rotate(" + b + degParen); + } + } + + function skewX(a, b, s, q) { + if (a !== b) { + q.push({i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: interpolateNumber(a, b)}); + } else if (b) { + s.push(pop(s) + "skewX(" + b + degParen); + } + } + + function scale(xa, ya, xb, yb, s, q) { + if (xa !== xb || ya !== yb) { + var i = s.push(pop(s) + "scale(", null, ",", null, ")"); + q.push({i: i - 4, x: interpolateNumber(xa, xb)}, {i: i - 2, x: interpolateNumber(ya, yb)}); + } else if (xb !== 1 || yb !== 1) { + s.push(pop(s) + "scale(" + xb + "," + yb + ")"); + } + } + + return function(a, b) { + var s = [], // string constants and placeholders + q = []; // number interpolators + a = parse(a), b = parse(b); + translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); + rotate(a.rotate, b.rotate, s, q); + skewX(a.skewX, b.skewX, s, q); + scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); + a = b = null; // gc + return function(t) { + var i = -1, n = q.length, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + }; +} + +var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); +var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); + +function hcl(hue) { + return function(start, end) { + var h = hue((start = hcl$1(start)).h, (end = hcl$1(end)).h), + c = nogamma(start.c, end.c), + l = nogamma(start.l, end.l), + opacity = nogamma(start.opacity, end.opacity); + return function(t) { + start.h = h(t); + start.c = c(t); + start.l = l(t); + start.opacity = opacity(t); + return start + ""; + }; + } +} + +var interpolateHcl = hcl(hue); + +var frame = 0, // is an animation frame pending? + timeout$1 = 0, // is a timeout pending? + interval = 0, // are any timers active? + pokeDelay = 1000, // how frequently we check for clock skew + taskHead, + taskTail, + clockLast = 0, + clockNow = 0, + clockSkew = 0, + clock = typeof performance === "object" && performance.now ? performance : Date, + setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); }; + +function now$1() { + return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); +} + +function clearNow() { + clockNow = 0; +} + +function Timer() { + this._call = + this._time = + this._next = null; +} + +Timer.prototype = timer.prototype = { + constructor: Timer, + restart: function(callback, delay, time) { + if (typeof callback !== "function") throw new TypeError("callback is not a function"); + time = (time == null ? now$1() : +time) + (delay == null ? 0 : +delay); + if (!this._next && taskTail !== this) { + if (taskTail) taskTail._next = this; + else taskHead = this; + taskTail = this; + } + this._call = callback; + this._time = time; + sleep(); + }, + stop: function() { + if (this._call) { + this._call = null; + this._time = Infinity; + sleep(); + } + } +}; + +function timer(callback, delay, time) { + var t = new Timer; + t.restart(callback, delay, time); + return t; +} + +function timerFlush() { + now$1(); // Get the current time, if not already set. + ++frame; // Pretend we’ve set an alarm, if we haven’t already. + var t = taskHead, e; + while (t) { + if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e); + t = t._next; + } + --frame; +} + +function wake() { + clockNow = (clockLast = clock.now()) + clockSkew; + frame = timeout$1 = 0; + try { + timerFlush(); + } finally { + frame = 0; + nap(); + clockNow = 0; + } +} + +function poke() { + var now = clock.now(), delay = now - clockLast; + if (delay > pokeDelay) clockSkew -= delay, clockLast = now; +} + +function nap() { + var t0, t1 = taskHead, t2, time = Infinity; + while (t1) { + if (t1._call) { + if (time > t1._time) time = t1._time; + t0 = t1, t1 = t1._next; + } else { + t2 = t1._next, t1._next = null; + t1 = t0 ? t0._next = t2 : taskHead = t2; + } + } + taskTail = t0; + sleep(time); +} + +function sleep(time) { + if (frame) return; // Soonest alarm already set, or will be. + if (timeout$1) timeout$1 = clearTimeout(timeout$1); + var delay = time - clockNow; // Strictly less than if we recomputed clockNow. + if (delay > 24) { + if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew); + if (interval) interval = clearInterval(interval); + } else { + if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay); + frame = 1, setFrame(wake); + } +} + +function timeout(callback, delay, time) { + var t = new Timer; + delay = delay == null ? 0 : +delay; + t.restart(elapsed => { + t.stop(); + callback(elapsed + delay); + }, delay, time); + return t; +} + +var emptyOn = dispatch("start", "end", "cancel", "interrupt"); +var emptyTween = []; + +var CREATED = 0; +var SCHEDULED = 1; +var STARTING = 2; +var STARTED = 3; +var RUNNING = 4; +var ENDING = 5; +var ENDED = 6; + +function schedule(node, name, id, index, group, timing) { + var schedules = node.__transition; + if (!schedules) node.__transition = {}; + else if (id in schedules) return; + create$1(node, id, { + name: name, + index: index, // For context during callback. + group: group, // For context during callback. + on: emptyOn, + tween: emptyTween, + time: timing.time, + delay: timing.delay, + duration: timing.duration, + ease: timing.ease, + timer: null, + state: CREATED + }); +} + +function init$1(node, id) { + var schedule = get$2(node, id); + if (schedule.state > CREATED) throw new Error("too late; already scheduled"); + return schedule; +} + +function set$2(node, id) { + var schedule = get$2(node, id); + if (schedule.state > STARTED) throw new Error("too late; already running"); + return schedule; +} + +function get$2(node, id) { + var schedule = node.__transition; + if (!schedule || !(schedule = schedule[id])) throw new Error("transition not found"); + return schedule; +} + +function create$1(node, id, self) { + var schedules = node.__transition, + tween; + + // Initialize the self timer when the transition is created. + // Note the actual delay is not known until the first callback! + schedules[id] = self; + self.timer = timer(schedule, 0, self.time); + + function schedule(elapsed) { + self.state = SCHEDULED; + self.timer.restart(start, self.delay, self.time); + + // If the elapsed delay is less than our first sleep, start immediately. + if (self.delay <= elapsed) start(elapsed - self.delay); + } + + function start(elapsed) { + var i, j, n, o; + + // If the state is not SCHEDULED, then we previously errored on start. + if (self.state !== SCHEDULED) return stop(); + + for (i in schedules) { + o = schedules[i]; + if (o.name !== self.name) continue; + + // While this element already has a starting transition during this frame, + // defer starting an interrupting transition until that transition has a + // chance to tick (and possibly end); see d3/d3-transition#54! + if (o.state === STARTED) return timeout(start); + + // Interrupt the active transition, if any. + if (o.state === RUNNING) { + o.state = ENDED; + o.timer.stop(); + o.on.call("interrupt", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + + // Cancel any pre-empted transitions. + else if (+i < id) { + o.state = ENDED; + o.timer.stop(); + o.on.call("cancel", node, node.__data__, o.index, o.group); + delete schedules[i]; + } + } + + // Defer the first tick to end of the current frame; see d3/d3#1576. + // Note the transition may be canceled after start and before the first tick! + // Note this must be scheduled before the start event; see d3/d3-transition#16! + // Assuming this is successful, subsequent callbacks go straight to tick. + timeout(function() { + if (self.state === STARTED) { + self.state = RUNNING; + self.timer.restart(tick, self.delay, self.time); + tick(elapsed); + } + }); + + // Dispatch the start event. + // Note this must be done before the tween are initialized. + self.state = STARTING; + self.on.call("start", node, node.__data__, self.index, self.group); + if (self.state !== STARTING) return; // interrupted + self.state = STARTED; + + // Initialize the tween, deleting null tween. + tween = new Array(n = self.tween.length); + for (i = 0, j = -1; i < n; ++i) { + if (o = self.tween[i].value.call(node, node.__data__, self.index, self.group)) { + tween[++j] = o; + } + } + tween.length = j + 1; + } + + function tick(elapsed) { + var t = elapsed < self.duration ? self.ease.call(null, elapsed / self.duration) : (self.timer.restart(stop), self.state = ENDING, 1), + i = -1, + n = tween.length; + + while (++i < n) { + tween[i].call(node, t); + } + + // Dispatch the end event. + if (self.state === ENDING) { + self.on.call("end", node, node.__data__, self.index, self.group); + stop(); + } + } + + function stop() { + self.state = ENDED; + self.timer.stop(); + delete schedules[id]; + for (var i in schedules) return; // eslint-disable-line no-unused-vars + delete node.__transition; + } +} + +function interrupt(node, name) { + var schedules = node.__transition, + schedule, + active, + empty = true, + i; + + if (!schedules) return; + + name = name == null ? null : name + ""; + + for (i in schedules) { + if ((schedule = schedules[i]).name !== name) { empty = false; continue; } + active = schedule.state > STARTING && schedule.state < ENDING; + schedule.state = ENDED; + schedule.timer.stop(); + schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group); + delete schedules[i]; + } + + if (empty) delete node.__transition; +} + +function selection_interrupt(name) { + return this.each(function() { + interrupt(this, name); + }); +} + +function tweenRemove(id, name) { + var tween0, tween1; + return function() { + var schedule = set$2(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = tween0 = tween; + for (var i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1 = tween1.slice(); + tween1.splice(i, 1); + break; + } + } + } + + schedule.tween = tween1; + }; +} + +function tweenFunction(id, name, value) { + var tween0, tween1; + if (typeof value !== "function") throw new Error; + return function() { + var schedule = set$2(this, id), + tween = schedule.tween; + + // If this node shared tween with the previous node, + // just assign the updated shared tween and we’re done! + // Otherwise, copy-on-write. + if (tween !== tween0) { + tween1 = (tween0 = tween).slice(); + for (var t = {name: name, value: value}, i = 0, n = tween1.length; i < n; ++i) { + if (tween1[i].name === name) { + tween1[i] = t; + break; + } + } + if (i === n) tween1.push(t); + } + + schedule.tween = tween1; + }; +} + +function transition_tween(name, value) { + var id = this._id; + + name += ""; + + if (arguments.length < 2) { + var tween = get$2(this.node(), id).tween; + for (var i = 0, n = tween.length, t; i < n; ++i) { + if ((t = tween[i]).name === name) { + return t.value; + } + } + return null; + } + + return this.each((value == null ? tweenRemove : tweenFunction)(id, name, value)); +} + +function tweenValue(transition, name, value) { + var id = transition._id; + + transition.each(function() { + var schedule = set$2(this, id); + (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments); + }); + + return function(node) { + return get$2(node, id).value[name]; + }; +} + +function interpolate(a, b) { + var c; + return (typeof b === "number" ? interpolateNumber + : b instanceof color ? interpolateRgb + : (c = color(b)) ? (b = c, interpolateRgb) + : interpolateString)(a, b); +} + +function attrRemove(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttribute(name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrConstantNS(fullname, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = this.getAttributeNS(fullname.space, fullname.local); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function attrFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttribute(name); + string0 = this.getAttribute(name); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function attrFunctionNS(fullname, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0, value1 = value(this), string1; + if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local); + string0 = this.getAttributeNS(fullname.space, fullname.local); + string1 = value1 + ""; + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function transition_attr(name, value) { + var fullname = namespace(name), i = fullname === "transform" ? interpolateTransformSvg : interpolate; + return this.attrTween(name, typeof value === "function" + ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name, value)) + : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname) + : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value)); +} + +function attrInterpolate(name, i) { + return function(t) { + this.setAttribute(name, i.call(this, t)); + }; +} + +function attrInterpolateNS(fullname, i) { + return function(t) { + this.setAttributeNS(fullname.space, fullname.local, i.call(this, t)); + }; +} + +function attrTweenNS(fullname, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolateNS(fullname, i); + return t0; + } + tween._value = value; + return tween; +} + +function attrTween(name, value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && attrInterpolate(name, i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_attrTween(name, value) { + var key = "attr." + name; + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + var fullname = namespace(name); + return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value)); +} + +function delayFunction(id, value) { + return function() { + init$1(this, id).delay = +value.apply(this, arguments); + }; +} + +function delayConstant(id, value) { + return value = +value, function() { + init$1(this, id).delay = value; + }; +} + +function transition_delay(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? delayFunction + : delayConstant)(id, value)) + : get$2(this.node(), id).delay; +} + +function durationFunction(id, value) { + return function() { + set$2(this, id).duration = +value.apply(this, arguments); + }; +} + +function durationConstant(id, value) { + return value = +value, function() { + set$2(this, id).duration = value; + }; +} + +function transition_duration(value) { + var id = this._id; + + return arguments.length + ? this.each((typeof value === "function" + ? durationFunction + : durationConstant)(id, value)) + : get$2(this.node(), id).duration; +} + +function easeConstant(id, value) { + if (typeof value !== "function") throw new Error; + return function() { + set$2(this, id).ease = value; + }; +} + +function transition_ease(value) { + var id = this._id; + + return arguments.length + ? this.each(easeConstant(id, value)) + : get$2(this.node(), id).ease; +} + +function easeVarying(id, value) { + return function() { + var v = value.apply(this, arguments); + if (typeof v !== "function") throw new Error; + set$2(this, id).ease = v; + }; +} + +function transition_easeVarying(value) { + if (typeof value !== "function") throw new Error; + return this.each(easeVarying(this._id, value)); +} + +function transition_filter(match) { + if (typeof match !== "function") match = matcher(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Transition(subgroups, this._parents, this._name, this._id); +} + +function transition_merge(transition) { + if (transition._id !== this._id) throw new Error; + + for (var groups0 = this._groups, groups1 = transition._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Transition(merges, this._parents, this._name, this._id); +} + +function start$1(name) { + return (name + "").trim().split(/^|\s+/).every(function(t) { + var i = t.indexOf("."); + if (i >= 0) t = t.slice(0, i); + return !t || t === "start"; + }); +} + +function onFunction(id, name, listener) { + var on0, on1, sit = start$1(name) ? init$1 : set$2; + return function() { + var schedule = sit(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener); + + schedule.on = on1; + }; +} + +function transition_on(name, listener) { + var id = this._id; + + return arguments.length < 2 + ? get$2(this.node(), id).on.on(name) + : this.each(onFunction(id, name, listener)); +} + +function removeFunction(id) { + return function() { + var parent = this.parentNode; + for (var i in this.__transition) if (+i !== id) return; + if (parent) parent.removeChild(this); + }; +} + +function transition_remove() { + return this.on("end.remove", removeFunction(this._id)); +} + +function transition_select(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selector(select); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + schedule(subgroup[i], name, id, i, subgroup, get$2(node, id)); + } + } + } + + return new Transition(subgroups, this._parents, name, id); +} + +function transition_selectAll(select) { + var name = this._name, + id = this._id; + + if (typeof select !== "function") select = selectorAll(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + for (var children = select.call(node, node.__data__, i, group), child, inherit = get$2(node, id), k = 0, l = children.length; k < l; ++k) { + if (child = children[k]) { + schedule(child, name, id, k, children, inherit); + } + } + subgroups.push(children); + parents.push(node); + } + } + } + + return new Transition(subgroups, parents, name, id); +} + +var Selection = selection.prototype.constructor; + +function transition_selection() { + return new Selection(this._groups, this._parents); +} + +function styleNull(name, interpolate) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + string1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, string10 = string1); + }; +} + +function styleRemove(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant(name, interpolate, value1) { + var string00, + string1 = value1 + "", + interpolate0; + return function() { + var string0 = styleValue(this, name); + return string0 === string1 ? null + : string0 === string00 ? interpolate0 + : interpolate0 = interpolate(string00 = string0, value1); + }; +} + +function styleFunction(name, interpolate, value) { + var string00, + string10, + interpolate0; + return function() { + var string0 = styleValue(this, name), + value1 = value(this), + string1 = value1 + ""; + if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name)); + return string0 === string1 ? null + : string0 === string00 && string1 === string10 ? interpolate0 + : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1)); + }; +} + +function styleMaybeRemove(id, name) { + var on0, on1, listener0, key = "style." + name, event = "end." + key, remove; + return function() { + var schedule = set$2(this, id), + on = schedule.on, + listener = schedule.value[key] == null ? remove || (remove = styleRemove(name)) : undefined; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener); + + schedule.on = on1; + }; +} + +function transition_style(name, value, priority) { + var i = (name += "") === "transform" ? interpolateTransformCss : interpolate; + return value == null ? this + .styleTween(name, styleNull(name, i)) + .on("end.style." + name, styleRemove(name)) + : typeof value === "function" ? this + .styleTween(name, styleFunction(name, i, tweenValue(this, "style." + name, value))) + .each(styleMaybeRemove(this._id, name)) + : this + .styleTween(name, styleConstant(name, i, value), priority) + .on("end.style." + name, null); +} + +function styleInterpolate(name, i, priority) { + return function(t) { + this.style.setProperty(name, i.call(this, t), priority); + }; +} + +function styleTween(name, value, priority) { + var t, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t = (i0 = i) && styleInterpolate(name, i, priority); + return t; + } + tween._value = value; + return tween; +} + +function transition_styleTween(name, value, priority) { + var key = "style." + (name += ""); + if (arguments.length < 2) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, styleTween(name, value, priority == null ? "" : priority)); +} + +function textConstant(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction(value) { + return function() { + var value1 = value(this); + this.textContent = value1 == null ? "" : value1; + }; +} + +function transition_text(value) { + return this.tween("text", typeof value === "function" + ? textFunction(tweenValue(this, "text", value)) + : textConstant(value == null ? "" : value + "")); +} + +function textInterpolate(i) { + return function(t) { + this.textContent = i.call(this, t); + }; +} + +function textTween(value) { + var t0, i0; + function tween() { + var i = value.apply(this, arguments); + if (i !== i0) t0 = (i0 = i) && textInterpolate(i); + return t0; + } + tween._value = value; + return tween; +} + +function transition_textTween(value) { + var key = "text"; + if (arguments.length < 1) return (key = this.tween(key)) && key._value; + if (value == null) return this.tween(key, null); + if (typeof value !== "function") throw new Error; + return this.tween(key, textTween(value)); +} + +function transition_transition() { + var name = this._name, + id0 = this._id, + id1 = newId(); + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + var inherit = get$2(node, id0); + schedule(node, name, id1, i, group, { + time: inherit.time + inherit.delay + inherit.duration, + delay: 0, + duration: inherit.duration, + ease: inherit.ease + }); + } + } + } + + return new Transition(groups, this._parents, name, id1); +} + +function transition_end() { + var on0, on1, that = this, id = that._id, size = that.size(); + return new Promise(function(resolve, reject) { + var cancel = {value: reject}, + end = {value: function() { if (--size === 0) resolve(); }}; + + that.each(function() { + var schedule = set$2(this, id), + on = schedule.on; + + // If this node shared a dispatch with the previous node, + // just assign the updated shared dispatch and we’re done! + // Otherwise, copy-on-write. + if (on !== on0) { + on1 = (on0 = on).copy(); + on1._.cancel.push(cancel); + on1._.interrupt.push(cancel); + on1._.end.push(end); + } + + schedule.on = on1; + }); + + // The selection was empty, resolve end immediately + if (size === 0) resolve(); + }); +} + +var id$m = 0; + +function Transition(groups, parents, name, id) { + this._groups = groups; + this._parents = parents; + this._name = name; + this._id = id; +} + +function newId() { + return ++id$m; +} + +var selection_prototype = selection.prototype; + +Transition.prototype = { + constructor: Transition, + select: transition_select, + selectAll: transition_selectAll, + selectChild: selection_prototype.selectChild, + selectChildren: selection_prototype.selectChildren, + filter: transition_filter, + merge: transition_merge, + selection: transition_selection, + transition: transition_transition, + call: selection_prototype.call, + nodes: selection_prototype.nodes, + node: selection_prototype.node, + size: selection_prototype.size, + empty: selection_prototype.empty, + each: selection_prototype.each, + on: transition_on, + attr: transition_attr, + attrTween: transition_attrTween, + style: transition_style, + styleTween: transition_styleTween, + text: transition_text, + textTween: transition_textTween, + remove: transition_remove, + tween: transition_tween, + delay: transition_delay, + duration: transition_duration, + ease: transition_ease, + easeVarying: transition_easeVarying, + end: transition_end, + [Symbol.iterator]: selection_prototype[Symbol.iterator] +}; + +function cubicInOut(t) { + return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; +} + +var defaultTiming = { + time: null, // Set on use. + delay: 0, + duration: 250, + ease: cubicInOut +}; + +function inherit(node, id) { + var timing; + while (!(timing = node.__transition) || !(timing = timing[id])) { + if (!(node = node.parentNode)) { + throw new Error(`transition ${id} not found`); + } + } + return timing; +} + +function selection_transition(name) { + var id, + timing; + + if (name instanceof Transition) { + id = name._id, name = name._name; + } else { + id = newId(), (timing = defaultTiming).time = now$1(), name = name == null ? null : name + ""; + } + + for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + schedule(node, name, id, i, group, timing || inherit(node, id)); + } + } + } + + return new Transition(groups, this._parents, name, id); +} + +selection.prototype.interrupt = selection_interrupt; +selection.prototype.transition = selection_transition; + +const pi$2 = Math.PI, + tau$2 = 2 * pi$2, + epsilon$2 = 1e-6, + tauEpsilon$1 = tau$2 - epsilon$2; + +function append$1(strings) { + this._ += strings[0]; + for (let i = 1, n = strings.length; i < n; ++i) { + this._ += arguments[i] + strings[i]; + } +} + +function appendRound(digits) { + let d = Math.floor(digits); + if (!(d >= 0)) throw new Error(`invalid digits: ${digits}`); + if (d > 15) return append$1; + const k = 10 ** d; + return function(strings) { + this._ += strings[0]; + for (let i = 1, n = strings.length; i < n; ++i) { + this._ += Math.round(arguments[i] * k) / k + strings[i]; + } + }; +} + +let Path$1 = class Path { + constructor(digits) { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; + this._append = digits == null ? append$1 : appendRound(digits); + } + moveTo(x, y) { + this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`; + } + closePath() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._append`Z`; + } + } + lineTo(x, y) { + this._append`L${this._x1 = +x},${this._y1 = +y}`; + } + quadraticCurveTo(x1, y1, x, y) { + this._append`Q${+x1},${+y1},${this._x1 = +x},${this._y1 = +y}`; + } + bezierCurveTo(x1, y1, x2, y2, x, y) { + this._append`C${+x1},${+y1},${+x2},${+y2},${this._x1 = +x},${this._y1 = +y}`; + } + arcTo(x1, y1, x2, y2, r) { + x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; + + // Is the radius negative? Error. + if (r < 0) throw new Error(`negative radius: ${r}`); + + let x0 = this._x1, + y0 = this._y1, + x21 = x2 - x1, + y21 = y2 - y1, + x01 = x0 - x1, + y01 = y0 - y1, + l01_2 = x01 * x01 + y01 * y01; + + // Is this path empty? Move to (x1,y1). + if (this._x1 === null) { + this._append`M${this._x1 = x1},${this._y1 = y1}`; + } + + // Or, is (x1,y1) coincident with (x0,y0)? Do nothing. + else if (!(l01_2 > epsilon$2)); + + // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear? + // Equivalently, is (x1,y1) coincident with (x2,y2)? + // Or, is the radius zero? Line to (x1,y1). + else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$2) || !r) { + this._append`L${this._x1 = x1},${this._y1 = y1}`; + } + + // Otherwise, draw an arc! + else { + let x20 = x2 - x0, + y20 = y2 - y0, + l21_2 = x21 * x21 + y21 * y21, + l20_2 = x20 * x20 + y20 * y20, + l21 = Math.sqrt(l21_2), + l01 = Math.sqrt(l01_2), + l = r * Math.tan((pi$2 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), + t01 = l / l01, + t21 = l / l21; + + // If the start tangent is not coincident with (x0,y0), line to. + if (Math.abs(t01 - 1) > epsilon$2) { + this._append`L${x1 + t01 * x01},${y1 + t01 * y01}`; + } + + this._append`A${r},${r},0,0,${+(y01 * x20 > x01 * y20)},${this._x1 = x1 + t21 * x21},${this._y1 = y1 + t21 * y21}`; + } + } + arc(x, y, r, a0, a1, ccw) { + x = +x, y = +y, r = +r, ccw = !!ccw; + + // Is the radius negative? Error. + if (r < 0) throw new Error(`negative radius: ${r}`); + + let dx = r * Math.cos(a0), + dy = r * Math.sin(a0), + x0 = x + dx, + y0 = y + dy, + cw = 1 ^ ccw, + da = ccw ? a0 - a1 : a1 - a0; + + // Is this path empty? Move to (x0,y0). + if (this._x1 === null) { + this._append`M${x0},${y0}`; + } + + // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). + else if (Math.abs(this._x1 - x0) > epsilon$2 || Math.abs(this._y1 - y0) > epsilon$2) { + this._append`L${x0},${y0}`; + } + + // Is this arc empty? We’re done. + if (!r) return; + + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau$2 + tau$2; + + // Is this a complete circle? Draw two arcs to complete the circle. + if (da > tauEpsilon$1) { + this._append`A${r},${r},0,1,${cw},${x - dx},${y - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`; + } + + // Is this arc non-empty? Draw an arc! + else if (da > epsilon$2) { + this._append`A${r},${r},0,${+(da >= pi$2)},${cw},${this._x1 = x + r * Math.cos(a1)},${this._y1 = y + r * Math.sin(a1)}`; + } + } + rect(x, y, w, h) { + this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${w = +w}v${+h}h${-w}Z`; + } + toString() { + return this._; + } +}; + +function responseText(response) { + if (!response.ok) throw new Error(response.status + " " + response.statusText); + return response.text(); +} + +function text$3(input, init) { + return fetch(input, init).then(responseText); +} + +function parser$j(type) { + return (input, init) => text$3(input, init) + .then(text => (new DOMParser).parseFromString(text, type)); +} + +var svg$2 = parser$j("image/svg+xml"); + +function formatDecimal(x) { + return Math.abs(x = Math.round(x)) >= 1e21 + ? x.toLocaleString("en").replace(/,/g, "") + : x.toString(10); +} + +// Computes the decimal coefficient and exponent of the specified number x with +// significant digits p, where x is positive and p is in [1, 21] or undefined. +// For example, formatDecimalParts(1.23) returns ["123", 0]. +function formatDecimalParts(x, p) { + if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity + var i, coefficient = x.slice(0, i); + + // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ + // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). + return [ + coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, + +x.slice(i + 1) + ]; +} + +function exponent(x) { + return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN; +} + +function formatGroup(grouping, thousands) { + return function(value, width) { + var i = value.length, + t = [], + j = 0, + g = grouping[0], + length = 0; + + while (i > 0 && g > 0) { + if (length + g + 1 > width) g = Math.max(1, width - length); + t.push(value.substring(i -= g, i + g)); + if ((length += g + 1) > width) break; + g = grouping[j = (j + 1) % grouping.length]; + } + + return t.reverse().join(thousands); + }; +} + +function formatNumerals(numerals) { + return function(value) { + return value.replace(/[0-9]/g, function(i) { + return numerals[+i]; + }); + }; +} + +// [[fill]align][sign][symbol][0][width][,][.precision][~][type] +var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; + +function formatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + return new FormatSpecifier({ + fill: match[1], + align: match[2], + sign: match[3], + symbol: match[4], + zero: match[5], + width: match[6], + comma: match[7], + precision: match[8] && match[8].slice(1), + trim: match[9], + type: match[10] + }); +} + +formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof + +function FormatSpecifier(specifier) { + this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; + this.align = specifier.align === undefined ? ">" : specifier.align + ""; + this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; + this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; + this.zero = !!specifier.zero; + this.width = specifier.width === undefined ? undefined : +specifier.width; + this.comma = !!specifier.comma; + this.precision = specifier.precision === undefined ? undefined : +specifier.precision; + this.trim = !!specifier.trim; + this.type = specifier.type === undefined ? "" : specifier.type + ""; +} + +FormatSpecifier.prototype.toString = function() { + return this.fill + + this.align + + this.sign + + this.symbol + + (this.zero ? "0" : "") + + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + + (this.comma ? "," : "") + + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + + (this.trim ? "~" : "") + + this.type; +}; + +// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. +function formatTrim(s) { + out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { + switch (s[i]) { + case ".": i0 = i1 = i; break; + case "0": if (i0 === 0) i0 = i; i1 = i; break; + default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break; + } + } + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; +} + +var prefixExponent; + +function formatPrefixAuto(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1], + i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, + n = coefficient.length; + return i === n ? coefficient + : i > n ? coefficient + new Array(i - n + 1).join("0") + : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) + : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y! +} + +function formatRounded(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1]; + return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient + : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) + : coefficient + new Array(exponent - coefficient.length + 2).join("0"); +} + +var formatTypes = { + "%": (x, p) => (x * 100).toFixed(p), + "b": (x) => Math.round(x).toString(2), + "c": (x) => x + "", + "d": formatDecimal, + "e": (x, p) => x.toExponential(p), + "f": (x, p) => x.toFixed(p), + "g": (x, p) => x.toPrecision(p), + "o": (x) => Math.round(x).toString(8), + "p": (x, p) => formatRounded(x * 100, p), + "r": formatRounded, + "s": formatPrefixAuto, + "X": (x) => Math.round(x).toString(16).toUpperCase(), + "x": (x) => Math.round(x).toString(16) +}; + +function identity$4(x) { + return x; +} + +var map$2 = Array.prototype.map, + prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; + +function formatLocale$1(locale) { + var group = locale.grouping === undefined || locale.thousands === undefined ? identity$4 : formatGroup(map$2.call(locale.grouping, Number), locale.thousands + ""), + currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", + currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", + decimal = locale.decimal === undefined ? "." : locale.decimal + "", + numerals = locale.numerals === undefined ? identity$4 : formatNumerals(map$2.call(locale.numerals, String)), + percent = locale.percent === undefined ? "%" : locale.percent + "", + minus = locale.minus === undefined ? "−" : locale.minus + "", + nan = locale.nan === undefined ? "NaN" : locale.nan + ""; + + function newFormat(specifier) { + specifier = formatSpecifier(specifier); + + var fill = specifier.fill, + align = specifier.align, + sign = specifier.sign, + symbol = specifier.symbol, + zero = specifier.zero, + width = specifier.width, + comma = specifier.comma, + precision = specifier.precision, + trim = specifier.trim, + type = specifier.type; + + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + + // The "" type, and any invalid type, is an alias for ".12~g". + else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g"; + + // If zero fill is specified, padding goes after sign and before digits. + if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; + + // Compute the prefix and suffix. + // For SI-prefix, the suffix is lazily computed. + var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", + suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; + + // What format function should we use? + // Is this an integer type? + // Can this type generate exponential notation? + var formatType = formatTypes[type], + maybeSuffix = /[defgprs%]/.test(type); + + // Set the default precision if not specified, + // or clamp the specified precision to the supported range. + // For significant precision, it must be in [1, 21]. + // For fixed precision, it must be in [0, 20]. + precision = precision === undefined ? 6 + : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) + : Math.max(0, Math.min(20, precision)); + + function format(value) { + var valuePrefix = prefix, + valueSuffix = suffix, + i, n, c; + + if (type === "c") { + valueSuffix = formatType(value) + valueSuffix; + value = ""; + } else { + value = +value; + + // Determine the sign. -0 is not less than 0, but 1 / -0 is! + var valueNegative = value < 0 || 1 / value < 0; + + // Perform the initial formatting. + value = isNaN(value) ? nan : formatType(Math.abs(value), precision); + + // Trim insignificant zeros. + if (trim) value = formatTrim(value); + + // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. + if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; + + // Compute the prefix and suffix. + valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; + valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); + + // Break the formatted value into the integer “value” part that can be + // grouped, and fractional or exponential “suffix” part that is not. + if (maybeSuffix) { + i = -1, n = value.length; + while (++i < n) { + if (c = value.charCodeAt(i), 48 > c || c > 57) { + valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; + value = value.slice(0, i); + break; + } + } + } + } + + // If the fill character is not "0", grouping is applied before padding. + if (comma && !zero) value = group(value, Infinity); + + // Compute the padding. + var length = valuePrefix.length + value.length + valueSuffix.length, + padding = length < width ? new Array(width - length + 1).join(fill) : ""; + + // If the fill character is "0", grouping is applied after padding. + if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; + + // Reconstruct the final output based on the desired alignment. + switch (align) { + case "<": value = valuePrefix + value + valueSuffix + padding; break; + case "=": value = valuePrefix + padding + value + valueSuffix; break; + case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; + default: value = padding + valuePrefix + value + valueSuffix; break; + } + + return numerals(value); + } + + format.toString = function() { + return specifier + ""; + }; + + return format; + } + + function formatPrefix(specifier, value) { + var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), + e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, + k = Math.pow(10, -e), + prefix = prefixes[8 + e / 3]; + return function(value) { + return f(k * value) + prefix; + }; + } + + return { + format: newFormat, + formatPrefix: formatPrefix + }; +} + +var locale$1; +var format$1; +var formatPrefix; + +defaultLocale$1({ + thousands: ",", + grouping: [3], + currency: ["$", ""] +}); + +function defaultLocale$1(definition) { + locale$1 = formatLocale$1(definition); + format$1 = locale$1.format; + formatPrefix = locale$1.formatPrefix; + return locale$1; +} + +function precisionFixed(step) { + return Math.max(0, -exponent(Math.abs(step))); +} + +function precisionPrefix(step, value) { + return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step))); +} + +function precisionRound(step, max) { + step = Math.abs(step), max = Math.abs(max) - step; + return Math.max(0, exponent(max) - exponent(step)) + 1; +} + +function initRange(domain, range) { + switch (arguments.length) { + case 0: break; + case 1: this.range(domain); break; + default: this.range(range).domain(domain); break; + } + return this; +} + +const implicit = Symbol("implicit"); + +function ordinal() { + var index = new InternMap(), + domain = [], + range = [], + unknown = implicit; + + function scale(d) { + let i = index.get(d); + if (i === undefined) { + if (unknown !== implicit) return unknown; + index.set(d, i = domain.push(d) - 1); + } + return range[i % range.length]; + } + + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = [], index = new InternMap(); + for (const value of _) { + if (index.has(value)) continue; + index.set(value, domain.push(value) - 1); + } + return scale; + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), scale) : range.slice(); + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.copy = function() { + return ordinal(domain, range).unknown(unknown); + }; + + initRange.apply(scale, arguments); + + return scale; +} + +function band() { + var scale = ordinal().unknown(undefined), + domain = scale.domain, + ordinalRange = scale.range, + r0 = 0, + r1 = 1, + step, + bandwidth, + round = false, + paddingInner = 0, + paddingOuter = 0, + align = 0.5; + + delete scale.unknown; + + function rescale() { + var n = domain().length, + reverse = r1 < r0, + start = reverse ? r1 : r0, + stop = reverse ? r0 : r1; + step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2); + if (round) step = Math.floor(step); + start += (stop - start - step * (n - paddingInner)) * align; + bandwidth = step * (1 - paddingInner); + if (round) start = Math.round(start), bandwidth = Math.round(bandwidth); + var values = range$1(n).map(function(i) { return start + step * i; }); + return ordinalRange(reverse ? values.reverse() : values); + } + + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); + }; + + scale.range = function(_) { + return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1]; + }; + + scale.rangeRound = function(_) { + return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale(); + }; + + scale.bandwidth = function() { + return bandwidth; + }; + + scale.step = function() { + return step; + }; + + scale.round = function(_) { + return arguments.length ? (round = !!_, rescale()) : round; + }; + + scale.padding = function(_) { + return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner; + }; + + scale.paddingInner = function(_) { + return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner; + }; + + scale.paddingOuter = function(_) { + return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter; + }; + + scale.align = function(_) { + return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align; + }; + + scale.copy = function() { + return band(domain(), [r0, r1]) + .round(round) + .paddingInner(paddingInner) + .paddingOuter(paddingOuter) + .align(align); + }; + + return initRange.apply(rescale(), arguments); +} + +function constants(x) { + return function() { + return x; + }; +} + +function number$3(x) { + return +x; +} + +var unit = [0, 1]; + +function identity$3(x) { + return x; +} + +function normalize$1(a, b) { + return (b -= (a = +a)) + ? function(x) { return (x - a) / b; } + : constants(isNaN(b) ? NaN : 0.5); +} + +function clamper(a, b) { + var t; + if (a > b) t = a, a = b, b = t; + return function(x) { return Math.max(a, Math.min(b, x)); }; +} + +// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. +// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b]. +function bimap(domain, range, interpolate) { + var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; + if (d1 < d0) d0 = normalize$1(d1, d0), r0 = interpolate(r1, r0); + else d0 = normalize$1(d0, d1), r0 = interpolate(r0, r1); + return function(x) { return r0(d0(x)); }; +} + +function polymap(domain, range, interpolate) { + var j = Math.min(domain.length, range.length) - 1, + d = new Array(j), + r = new Array(j), + i = -1; + + // Reverse descending domains. + if (domain[j] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + + while (++i < j) { + d[i] = normalize$1(domain[i], domain[i + 1]); + r[i] = interpolate(range[i], range[i + 1]); + } + + return function(x) { + var i = bisectRight(domain, x, 1, j) - 1; + return r[i](d[i](x)); + }; +} + +function copy$2(source, target) { + return target + .domain(source.domain()) + .range(source.range()) + .interpolate(source.interpolate()) + .clamp(source.clamp()) + .unknown(source.unknown()); +} + +function transformer() { + var domain = unit, + range = unit, + interpolate = interpolate$1, + transform, + untransform, + unknown, + clamp = identity$3, + piecewise, + output, + input; + + function rescale() { + var n = Math.min(domain.length, range.length); + if (clamp !== identity$3) clamp = clamper(domain[0], domain[n - 1]); + piecewise = n > 2 ? polymap : bimap; + output = input = null; + return scale; + } + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate)))(transform(clamp(x))); + } + + scale.invert = function(y) { + return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y))); + }; + + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_, number$3), rescale()) : domain.slice(); + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + + scale.rangeRound = function(_) { + return range = Array.from(_), interpolate = interpolateRound, rescale(); + }; + + scale.clamp = function(_) { + return arguments.length ? (clamp = _ ? true : identity$3, rescale()) : clamp !== identity$3; + }; + + scale.interpolate = function(_) { + return arguments.length ? (interpolate = _, rescale()) : interpolate; + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + return function(t, u) { + transform = t, untransform = u; + return rescale(); + }; +} + +function continuous() { + return transformer()(identity$3, identity$3); +} + +function tickFormat(start, stop, count, specifier) { + var step = tickStep(start, stop, count), + precision; + specifier = formatSpecifier(specifier == null ? ",f" : specifier); + switch (specifier.type) { + case "s": { + var value = Math.max(Math.abs(start), Math.abs(stop)); + if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision; + return formatPrefix(specifier, value); + } + case "": + case "e": + case "g": + case "p": + case "r": { + if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); + break; + } + case "f": + case "%": { + if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2; + break; + } + } + return format$1(specifier); +} + +function linearish(scale) { + var domain = scale.domain; + + scale.ticks = function(count) { + var d = domain(); + return ticks(d[0], d[d.length - 1], count == null ? 10 : count); + }; + + scale.tickFormat = function(count, specifier) { + var d = domain(); + return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier); + }; + + scale.nice = function(count) { + if (count == null) count = 10; + + var d = domain(); + var i0 = 0; + var i1 = d.length - 1; + var start = d[i0]; + var stop = d[i1]; + var prestep; + var step; + var maxIter = 10; + + if (stop < start) { + step = start, start = stop, stop = step; + step = i0, i0 = i1, i1 = step; + } + + while (maxIter-- > 0) { + step = tickIncrement(start, stop, count); + if (step === prestep) { + d[i0] = start; + d[i1] = stop; + return domain(d); + } else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; + } else { + break; + } + prestep = step; + } + + return scale; + }; + + return scale; +} + +function linear() { + var scale = continuous(); + + scale.copy = function() { + return copy$2(scale, linear()); + }; + + initRange.apply(scale, arguments); + + return linearish(scale); +} + +function nice(domain, interval) { + domain = domain.slice(); + + var i0 = 0, + i1 = domain.length - 1, + x0 = domain[i0], + x1 = domain[i1], + t; + + if (x1 < x0) { + t = i0, i0 = i1, i1 = t; + t = x0, x0 = x1, x1 = t; + } + + domain[i0] = interval.floor(x0); + domain[i1] = interval.ceil(x1); + return domain; +} + +const t0 = new Date, t1 = new Date; + +function timeInterval(floori, offseti, count, field) { + + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + + interval.floor = (date) => { + return floori(date = new Date(+date)), date; + }; + + interval.ceil = (date) => { + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; + }; + + interval.round = (date) => { + const d0 = interval(date), d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + + interval.offset = (date, step) => { + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + + interval.range = (start, stop, step) => { + const range = []; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + let previous; + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + + interval.filter = (test) => { + return timeInterval((date) => { + if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); + }, (date, step) => { + if (date >= date) { + if (step < 0) while (++step <= 0) { + while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty + } else while (--step >= 0) { + while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty + } + } + }); + }; + + if (count) { + interval.count = (start, end) => { + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + + interval.every = (step) => { + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null + : !(step > 1) ? interval + : interval.filter(field + ? (d) => field(d) % step === 0 + : (d) => interval.count(0, d) % step === 0); + }; + } + + return interval; +} + +const millisecond = timeInterval(() => { + // noop +}, (date, step) => { + date.setTime(+date + step); +}, (start, end) => { + return end - start; +}); + +// An optimized implementation for this simple case. +millisecond.every = (k) => { + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return timeInterval((date) => { + date.setTime(Math.floor(date / k) * k); + }, (date, step) => { + date.setTime(+date + step * k); + }, (start, end) => { + return (end - start) / k; + }); +}; + +millisecond.range; + +const durationSecond = 1000; +const durationMinute = durationSecond * 60; +const durationHour = durationMinute * 60; +const durationDay = durationHour * 24; +const durationWeek = durationDay * 7; +const durationMonth = durationDay * 30; +const durationYear = durationDay * 365; + +const second = timeInterval((date) => { + date.setTime(date - date.getMilliseconds()); +}, (date, step) => { + date.setTime(+date + step * durationSecond); +}, (start, end) => { + return (end - start) / durationSecond; +}, (date) => { + return date.getUTCSeconds(); +}); + +second.range; + +const timeMinute = timeInterval((date) => { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); +}, (date, step) => { + date.setTime(+date + step * durationMinute); +}, (start, end) => { + return (end - start) / durationMinute; +}, (date) => { + return date.getMinutes(); +}); + +timeMinute.range; + +const utcMinute = timeInterval((date) => { + date.setUTCSeconds(0, 0); +}, (date, step) => { + date.setTime(+date + step * durationMinute); +}, (start, end) => { + return (end - start) / durationMinute; +}, (date) => { + return date.getUTCMinutes(); +}); + +utcMinute.range; + +const timeHour = timeInterval((date) => { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); +}, (date, step) => { + date.setTime(+date + step * durationHour); +}, (start, end) => { + return (end - start) / durationHour; +}, (date) => { + return date.getHours(); +}); + +timeHour.range; + +const utcHour = timeInterval((date) => { + date.setUTCMinutes(0, 0, 0); +}, (date, step) => { + date.setTime(+date + step * durationHour); +}, (start, end) => { + return (end - start) / durationHour; +}, (date) => { + return date.getUTCHours(); +}); + +utcHour.range; + +const timeDay = timeInterval( + date => date.setHours(0, 0, 0, 0), + (date, step) => date.setDate(date.getDate() + step), + (start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, + date => date.getDate() - 1 +); + +timeDay.range; + +const utcDay = timeInterval((date) => { + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCDate(date.getUTCDate() + step); +}, (start, end) => { + return (end - start) / durationDay; +}, (date) => { + return date.getUTCDate() - 1; +}); + +utcDay.range; + +const unixDay = timeInterval((date) => { + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCDate(date.getUTCDate() + step); +}, (start, end) => { + return (end - start) / durationDay; +}, (date) => { + return Math.floor(date / durationDay); +}); + +unixDay.range; + +function timeWeekday(i) { + return timeInterval((date) => { + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, (date, step) => { + date.setDate(date.getDate() + step * 7); + }, (start, end) => { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; + }); +} + +const timeSunday = timeWeekday(0); +const timeMonday = timeWeekday(1); +const timeTuesday = timeWeekday(2); +const timeWednesday = timeWeekday(3); +const timeThursday = timeWeekday(4); +const timeFriday = timeWeekday(5); +const timeSaturday = timeWeekday(6); + +timeSunday.range; +timeMonday.range; +timeTuesday.range; +timeWednesday.range; +timeThursday.range; +timeFriday.range; +timeSaturday.range; + +function utcWeekday(i) { + return timeInterval((date) => { + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, (date, step) => { + date.setUTCDate(date.getUTCDate() + step * 7); + }, (start, end) => { + return (end - start) / durationWeek; + }); +} + +const utcSunday = utcWeekday(0); +const utcMonday = utcWeekday(1); +const utcTuesday = utcWeekday(2); +const utcWednesday = utcWeekday(3); +const utcThursday = utcWeekday(4); +const utcFriday = utcWeekday(5); +const utcSaturday = utcWeekday(6); + +utcSunday.range; +utcMonday.range; +utcTuesday.range; +utcWednesday.range; +utcThursday.range; +utcFriday.range; +utcSaturday.range; + +const timeMonth = timeInterval((date) => { + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, (date, step) => { + date.setMonth(date.getMonth() + step); +}, (start, end) => { + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, (date) => { + return date.getMonth(); +}); + +timeMonth.range; + +const utcMonth = timeInterval((date) => { + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCMonth(date.getUTCMonth() + step); +}, (start, end) => { + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, (date) => { + return date.getUTCMonth(); +}); + +utcMonth.range; + +const timeYear = timeInterval((date) => { + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, (date, step) => { + date.setFullYear(date.getFullYear() + step); +}, (start, end) => { + return end.getFullYear() - start.getFullYear(); +}, (date) => { + return date.getFullYear(); +}); + +// An optimized implementation for this simple case. +timeYear.every = (k) => { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, (date, step) => { + date.setFullYear(date.getFullYear() + step * k); + }); +}; + +timeYear.range; + +const utcYear = timeInterval((date) => { + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, (date, step) => { + date.setUTCFullYear(date.getUTCFullYear() + step); +}, (start, end) => { + return end.getUTCFullYear() - start.getUTCFullYear(); +}, (date) => { + return date.getUTCFullYear(); +}); + +// An optimized implementation for this simple case. +utcYear.every = (k) => { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, (date, step) => { + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; + +utcYear.range; + +function ticker(year, month, week, day, hour, minute) { + + const tickIntervals = [ + [second, 1, durationSecond], + [second, 5, 5 * durationSecond], + [second, 15, 15 * durationSecond], + [second, 30, 30 * durationSecond], + [minute, 1, durationMinute], + [minute, 5, 5 * durationMinute], + [minute, 15, 15 * durationMinute], + [minute, 30, 30 * durationMinute], + [ hour, 1, durationHour ], + [ hour, 3, 3 * durationHour ], + [ hour, 6, 6 * durationHour ], + [ hour, 12, 12 * durationHour ], + [ day, 1, durationDay ], + [ day, 2, 2 * durationDay ], + [ week, 1, durationWeek ], + [ month, 1, durationMonth ], + [ month, 3, 3 * durationMonth ], + [ year, 1, durationYear ] + ]; + + function ticks(start, stop, count) { + const reverse = stop < start; + if (reverse) [start, stop] = [stop, start]; + const interval = count && typeof count.range === "function" ? count : tickInterval(start, stop, count); + const ticks = interval ? interval.range(start, +stop + 1) : []; // inclusive stop + return reverse ? ticks.reverse() : ticks; + } + + function tickInterval(start, stop, count) { + const target = Math.abs(stop - start) / count; + const i = bisector(([,, step]) => step).right(tickIntervals, target); + if (i === tickIntervals.length) return year.every(tickStep(start / durationYear, stop / durationYear, count)); + if (i === 0) return millisecond.every(Math.max(tickStep(start, stop, count), 1)); + const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; + return t.every(step); + } + + return [ticks, tickInterval]; +} +const [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute); + +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; + } + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); +} + +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; + } + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} + +function newDate(y, m, d) { + return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; +} + +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, + locale_date = locale.date, + locale_time = locale.time, + locale_periods = locale.periods, + locale_weekdays = locale.days, + locale_shortWeekdays = locale.shortDays, + locale_months = locale.months, + locale_shortMonths = locale.shortMonths; + + var periodRe = formatRe(locale_periods), + periodLookup = formatLookup(locale_periods), + weekdayRe = formatRe(locale_weekdays), + weekdayLookup = formatLookup(locale_weekdays), + shortWeekdayRe = formatRe(locale_shortWeekdays), + shortWeekdayLookup = formatLookup(locale_shortWeekdays), + monthRe = formatRe(locale_months), + monthLookup = formatLookup(locale_months), + shortMonthRe = formatRe(locale_shortMonths), + shortMonthLookup = formatLookup(locale_shortMonths); + + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "g": formatYearISO, + "G": formatFullYearISO, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent + }; + + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "g": formatUTCYearISO, + "G": formatUTCFullYearISO, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent + }; + + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "g": parseYear, + "G": parseFullYear, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + + function newFormat(specifier, formats) { + return function(date) { + var string = [], + i = -1, + j = 0, + n = specifier.length, + c, + pad, + format; + + if (!(date instanceof Date)) date = new Date(+date); + + while (++i < n) { + if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; + } + } + + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), + i = parseSpecifier(d, specifier, string += "", 0), + week, day; + if (i != string.length) return null; + + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week); + week = utcDay.offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week); + week = timeDay.offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; + } + + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); + } + + // Otherwise, all fields are in local time. + return localDate(d); + }; + } + + function parseSpecifier(d, specifier, string, j) { + var i = 0, + n = specifier.length, + m = string.length, + c, + parse; + + while (i < n) { + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || ((j = parse(d, string, j)) < 0)) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + + return j; + } + + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { return specifier; }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { return specifier; }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { return specifier; }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { return specifier; }; + return p; + } + }; +} + +var pads = {"-": "", "_": " ", "0": "0"}, + numberRe = /^\s*\d+/, // note: ignores next directive + percentRe = /^%/, + requoteRe = /[\\^$*+?|[\]().{}]/g; + +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", + string = (sign ? -value : value) + "", + length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +} + +function requote(s) { + return s.replace(requoteRe, "\\$&"); +} + +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); +} + +function formatLookup(names) { + return new Map(names.map((name, i) => [name.toLowerCase(), i])); +} + +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; +} + +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; +} + +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; +} + +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} + +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; +} + +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; +} + +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; +} + +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; +} + +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; +} + +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; +} + +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; +} + +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; +} + +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; +} + +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; +} + +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; +} + +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; +} + +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; +} + +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); +} + +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); +} + +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); +} + +function formatDayOfYear(d, p) { + return pad(1 + timeDay.count(timeYear(d), d), p, 3); +} + +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); +} + +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; +} + +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); +} + +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); +} + +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} + +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; +} + +function formatWeekNumberSunday(d, p) { + return pad(timeSunday.count(timeYear(d) - 1, d), p, 2); +} + +function dISO(d) { + var day = d.getDay(); + return (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); +} + +function formatWeekNumberISO(d, p) { + d = dISO(d); + return pad(timeThursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2); +} + +function formatWeekdayNumberSunday(d) { + return d.getDay(); +} + +function formatWeekNumberMonday(d, p) { + return pad(timeMonday.count(timeYear(d) - 1, d), p, 2); +} + +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); +} + +function formatYearISO(d, p) { + d = dISO(d); + return pad(d.getFullYear() % 100, p, 2); +} + +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatFullYearISO(d, p) { + var day = d.getDay(); + d = (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + + pad(z / 60 | 0, "0", 2) + + pad(z % 60, "0", 2); +} + +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); +} + +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); +} + +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); +} + +function formatUTCDayOfYear(d, p) { + return pad(1 + utcDay.count(utcYear(d), d), p, 3); +} + +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); +} + +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; +} + +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); +} + +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); +} + +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); +} + +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; +} + +function formatUTCWeekNumberSunday(d, p) { + return pad(utcSunday.count(utcYear(d) - 1, d), p, 2); +} + +function UTCdISO(d) { + var day = d.getUTCDay(); + return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); +} + +function formatUTCWeekNumberISO(d, p) { + d = UTCdISO(d); + return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2); +} + +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); +} + +function formatUTCWeekNumberMonday(d, p) { + return pad(utcMonday.count(utcYear(d) - 1, d), p, 2); +} + +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCYearISO(d, p) { + d = UTCdISO(d); + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCFullYearISO(d, p) { + var day = d.getUTCDay(); + d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCZone() { + return "+0000"; +} + +function formatLiteralPercent() { + return "%"; +} + +function formatUnixTimestamp(d) { + return +d; +} + +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +var locale; +var timeFormat; + +defaultLocale({ + dateTime: "%x, %X", + date: "%-m/%-d/%Y", + time: "%-I:%M:%S %p", + periods: ["AM", "PM"], + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + timeFormat = locale.format; + locale.parse; + locale.utcFormat; + locale.utcParse; + return locale; +} + +function date(t) { + return new Date(t); +} + +function number$2(t) { + return t instanceof Date ? +t : +new Date(+t); +} + +function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) { + var scale = continuous(), + invert = scale.invert, + domain = scale.domain; + + var formatMillisecond = format(".%L"), + formatSecond = format(":%S"), + formatMinute = format("%I:%M"), + formatHour = format("%I %p"), + formatDay = format("%a %d"), + formatWeek = format("%b %d"), + formatMonth = format("%B"), + formatYear = format("%Y"); + + function tickFormat(date) { + return (second(date) < date ? formatMillisecond + : minute(date) < date ? formatSecond + : hour(date) < date ? formatMinute + : day(date) < date ? formatHour + : month(date) < date ? (week(date) < date ? formatDay : formatWeek) + : year(date) < date ? formatMonth + : formatYear)(date); + } + + scale.invert = function(y) { + return new Date(invert(y)); + }; + + scale.domain = function(_) { + return arguments.length ? domain(Array.from(_, number$2)) : domain().map(date); + }; + + scale.ticks = function(interval) { + var d = domain(); + return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval); + }; + + scale.tickFormat = function(count, specifier) { + return specifier == null ? tickFormat : format(specifier); + }; + + scale.nice = function(interval) { + var d = domain(); + if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval); + return interval ? domain(nice(d, interval)) : scale; + }; + + scale.copy = function() { + return copy$2(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format)); + }; + + return scale; +} + +function time() { + return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute, second, timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments); +} + +function colors$1(specifier) { + var n = specifier.length / 6 | 0, colors = new Array(n), i = 0; + while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6); + return colors; +} + +var schemeTableau10 = colors$1("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"); + +function constant$3(x) { + return function constant() { + return x; + }; +} + +const abs$1 = Math.abs; +const atan2 = Math.atan2; +const cos$1 = Math.cos; +const max$3 = Math.max; +const min$3 = Math.min; +const sin$1 = Math.sin; +const sqrt$1 = Math.sqrt; + +const epsilon$1 = 1e-12; +const pi$1 = Math.PI; +const halfPi = pi$1 / 2; +const tau$1 = 2 * pi$1; + +function acos(x) { + return x > 1 ? 0 : x < -1 ? pi$1 : Math.acos(x); +} + +function asin(x) { + return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x); +} + +function withPath(shape) { + let digits = 3; + + shape.digits = function(_) { + if (!arguments.length) return digits; + if (_ == null) { + digits = null; + } else { + const d = Math.floor(_); + if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`); + digits = d; + } + return shape; + }; + + return () => new Path$1(digits); +} + +function arcInnerRadius(d) { + return d.innerRadius; +} + +function arcOuterRadius(d) { + return d.outerRadius; +} + +function arcStartAngle(d) { + return d.startAngle; +} + +function arcEndAngle(d) { + return d.endAngle; +} + +function arcPadAngle(d) { + return d && d.padAngle; // Note: optional! +} + +function intersect$1(x0, y0, x1, y1, x2, y2, x3, y3) { + var x10 = x1 - x0, y10 = y1 - y0, + x32 = x3 - x2, y32 = y3 - y2, + t = y32 * x10 - x32 * y10; + if (t * t < epsilon$1) return; + t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t; + return [x0 + t * x10, y0 + t * y10]; +} + +// Compute perpendicular offset line of length rc. +// http://mathworld.wolfram.com/Circle-LineIntersection.html +function cornerTangents(x0, y0, x1, y1, r1, rc, cw) { + var x01 = x0 - x1, + y01 = y0 - y1, + lo = (cw ? rc : -rc) / sqrt$1(x01 * x01 + y01 * y01), + ox = lo * y01, + oy = -lo * x01, + x11 = x0 + ox, + y11 = y0 + oy, + x10 = x1 + ox, + y10 = y1 + oy, + x00 = (x11 + x10) / 2, + y00 = (y11 + y10) / 2, + dx = x10 - x11, + dy = y10 - y11, + d2 = dx * dx + dy * dy, + r = r1 - rc, + D = x11 * y10 - x10 * y11, + d = (dy < 0 ? -1 : 1) * sqrt$1(max$3(0, r * r * d2 - D * D)), + cx0 = (D * dy - dx * d) / d2, + cy0 = (-D * dx - dy * d) / d2, + cx1 = (D * dy + dx * d) / d2, + cy1 = (-D * dx + dy * d) / d2, + dx0 = cx0 - x00, + dy0 = cy0 - y00, + dx1 = cx1 - x00, + dy1 = cy1 - y00; + + // Pick the closer of the two intersection points. + // TODO Is there a faster way to determine which intersection to use? + if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; + + return { + cx: cx0, + cy: cy0, + x01: -ox, + y01: -oy, + x11: cx0 * (r1 / r - 1), + y11: cy0 * (r1 / r - 1) + }; +} + +function arc() { + var innerRadius = arcInnerRadius, + outerRadius = arcOuterRadius, + cornerRadius = constant$3(0), + padRadius = null, + startAngle = arcStartAngle, + endAngle = arcEndAngle, + padAngle = arcPadAngle, + context = null, + path = withPath(arc); + + function arc() { + var buffer, + r, + r0 = +innerRadius.apply(this, arguments), + r1 = +outerRadius.apply(this, arguments), + a0 = startAngle.apply(this, arguments) - halfPi, + a1 = endAngle.apply(this, arguments) - halfPi, + da = abs$1(a1 - a0), + cw = a1 > a0; + + if (!context) context = buffer = path(); + + // Ensure that the outer radius is always larger than the inner radius. + if (r1 < r0) r = r1, r1 = r0, r0 = r; + + // Is it a point? + if (!(r1 > epsilon$1)) context.moveTo(0, 0); + + // Or is it a circle or annulus? + else if (da > tau$1 - epsilon$1) { + context.moveTo(r1 * cos$1(a0), r1 * sin$1(a0)); + context.arc(0, 0, r1, a0, a1, !cw); + if (r0 > epsilon$1) { + context.moveTo(r0 * cos$1(a1), r0 * sin$1(a1)); + context.arc(0, 0, r0, a1, a0, cw); + } + } + + // Or is it a circular or annular sector? + else { + var a01 = a0, + a11 = a1, + a00 = a0, + a10 = a1, + da0 = da, + da1 = da, + ap = padAngle.apply(this, arguments) / 2, + rp = (ap > epsilon$1) && (padRadius ? +padRadius.apply(this, arguments) : sqrt$1(r0 * r0 + r1 * r1)), + rc = min$3(abs$1(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), + rc0 = rc, + rc1 = rc, + t0, + t1; + + // Apply padding? Note that since r1 ≥ r0, da1 ≥ da0. + if (rp > epsilon$1) { + var p0 = asin(rp / r0 * sin$1(ap)), + p1 = asin(rp / r1 * sin$1(ap)); + if ((da0 -= p0 * 2) > epsilon$1) p0 *= (cw ? 1 : -1), a00 += p0, a10 -= p0; + else da0 = 0, a00 = a10 = (a0 + a1) / 2; + if ((da1 -= p1 * 2) > epsilon$1) p1 *= (cw ? 1 : -1), a01 += p1, a11 -= p1; + else da1 = 0, a01 = a11 = (a0 + a1) / 2; + } + + var x01 = r1 * cos$1(a01), + y01 = r1 * sin$1(a01), + x10 = r0 * cos$1(a10), + y10 = r0 * sin$1(a10); + + // Apply rounded corners? + if (rc > epsilon$1) { + var x11 = r1 * cos$1(a11), + y11 = r1 * sin$1(a11), + x00 = r0 * cos$1(a00), + y00 = r0 * sin$1(a00), + oc; + + // Restrict the corner radius according to the sector angle. If this + // intersection fails, it’s probably because the arc is too small, so + // disable the corner radius entirely. + if (da < pi$1) { + if (oc = intersect$1(x01, y01, x00, y00, x11, y11, x10, y10)) { + var ax = x01 - oc[0], + ay = y01 - oc[1], + bx = x11 - oc[0], + by = y11 - oc[1], + kc = 1 / sin$1(acos((ax * bx + ay * by) / (sqrt$1(ax * ax + ay * ay) * sqrt$1(bx * bx + by * by))) / 2), + lc = sqrt$1(oc[0] * oc[0] + oc[1] * oc[1]); + rc0 = min$3(rc, (r0 - lc) / (kc - 1)); + rc1 = min$3(rc, (r1 - lc) / (kc + 1)); + } else { + rc0 = rc1 = 0; + } + } + } + + // Is the sector collapsed to a line? + if (!(da1 > epsilon$1)) context.moveTo(x01, y01); + + // Does the sector’s outer ring have rounded corners? + else if (rc1 > epsilon$1) { + t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw); + t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw); + + context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw); + context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the outer ring just a circular arc? + else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw); + + // Is there no inner ring, and it’s a circular sector? + // Or perhaps it’s an annular sector collapsed due to padding? + if (!(r0 > epsilon$1) || !(da0 > epsilon$1)) context.lineTo(x10, y10); + + // Does the sector’s inner ring (or point) have rounded corners? + else if (rc0 > epsilon$1) { + t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw); + t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw); + + context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01); + + // Have the corners merged? + if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw); + + // Otherwise, draw the two corners and the ring. + else { + context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw); + context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw); + context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw); + } + } + + // Or is the inner ring just a circular arc? + else context.arc(0, 0, r0, a10, a00, cw); + } + + context.closePath(); + + if (buffer) return context = null, buffer + "" || null; + } + + arc.centroid = function() { + var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, + a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi$1 / 2; + return [cos$1(a) * r, sin$1(a) * r]; + }; + + arc.innerRadius = function(_) { + return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant$3(+_), arc) : innerRadius; + }; + + arc.outerRadius = function(_) { + return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant$3(+_), arc) : outerRadius; + }; + + arc.cornerRadius = function(_) { + return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant$3(+_), arc) : cornerRadius; + }; + + arc.padRadius = function(_) { + return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant$3(+_), arc) : padRadius; + }; + + arc.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$3(+_), arc) : startAngle; + }; + + arc.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$3(+_), arc) : endAngle; + }; + + arc.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$3(+_), arc) : padAngle; + }; + + arc.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), arc) : context; + }; + + return arc; +} + +function array$1(x) { + return typeof x === "object" && "length" in x + ? x // Array, TypedArray, NodeList, array-like + : Array.from(x); // Map, Set, iterable, string, or anything else +} + +function Linear(context) { + this._context = context; +} + +Linear.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: this._context.lineTo(x, y); break; + } + } +}; + +function curveLinear(context) { + return new Linear(context); +} + +function x$2(p) { + return p[0]; +} + +function y$2(p) { + return p[1]; +} + +function line$1(x, y) { + var defined = constant$3(true), + context = null, + curve = curveLinear, + output = null, + path = withPath(line); + + x = typeof x === "function" ? x : (x === undefined) ? x$2 : constant$3(x); + y = typeof y === "function" ? y : (y === undefined) ? y$2 : constant$3(y); + + function line(data) { + var i, + n = (data = array$1(data)).length, + d, + defined0 = false, + buffer; + + if (context == null) output = curve(buffer = path()); + + for (i = 0; i <= n; ++i) { + if (!(i < n && defined(d = data[i], i, data)) === defined0) { + if (defined0 = !defined0) output.lineStart(); + else output.lineEnd(); + } + if (defined0) output.point(+x(d, i, data), +y(d, i, data)); + } + + if (buffer) return output = null, buffer + "" || null; + } + + line.x = function(_) { + return arguments.length ? (x = typeof _ === "function" ? _ : constant$3(+_), line) : x; + }; + + line.y = function(_) { + return arguments.length ? (y = typeof _ === "function" ? _ : constant$3(+_), line) : y; + }; + + line.defined = function(_) { + return arguments.length ? (defined = typeof _ === "function" ? _ : constant$3(!!_), line) : defined; + }; + + line.curve = function(_) { + return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve; + }; + + line.context = function(_) { + return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context; + }; + + return line; +} + +function descending$1(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +} + +function identity$2(d) { + return d; +} + +function pie$1() { + var value = identity$2, + sortValues = descending$1, + sort = null, + startAngle = constant$3(0), + endAngle = constant$3(tau$1), + padAngle = constant$3(0); + + function pie(data) { + var i, + n = (data = array$1(data)).length, + j, + k, + sum = 0, + index = new Array(n), + arcs = new Array(n), + a0 = +startAngle.apply(this, arguments), + da = Math.min(tau$1, Math.max(-tau$1, endAngle.apply(this, arguments) - a0)), + a1, + p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), + pa = p * (da < 0 ? -1 : 1), + v; + + for (i = 0; i < n; ++i) { + if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) { + sum += v; + } + } + + // Optionally sort the arcs by previously-computed values or by data. + if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); }); + else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); }); + + // Compute the arcs! They are stored in the original data's order. + for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) { + j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = { + data: data[j], + index: i, + value: v, + startAngle: a0, + endAngle: a1, + padAngle: p + }; + } + + return arcs; + } + + pie.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : constant$3(+_), pie) : value; + }; + + pie.sortValues = function(_) { + return arguments.length ? (sortValues = _, sort = null, pie) : sortValues; + }; + + pie.sort = function(_) { + return arguments.length ? (sort = _, sortValues = null, pie) : sort; + }; + + pie.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant$3(+_), pie) : startAngle; + }; + + pie.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant$3(+_), pie) : endAngle; + }; + + pie.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant$3(+_), pie) : padAngle; + }; + + return pie; +} + +class Bump { + constructor(context, x) { + this._context = context; + this._x = x; + } + areaStart() { + this._line = 0; + } + areaEnd() { + this._line = NaN; + } + lineStart() { + this._point = 0; + } + lineEnd() { + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + } + point(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: { + this._point = 1; + if (this._line) this._context.lineTo(x, y); + else this._context.moveTo(x, y); + break; + } + case 1: this._point = 2; // falls through + default: { + if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x) / 2, this._y0, this._x0, y, x, y); + else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y) / 2, x, this._y0, x, y); + break; + } + } + this._x0 = x, this._y0 = y; + } +} + +function bumpX(context) { + return new Bump(context, true); +} + +function bumpY(context) { + return new Bump(context, false); +} + +function noop$3() {} + +function point$6(that, x, y) { + that._context.bezierCurveTo( + (2 * that._x0 + that._x1) / 3, + (2 * that._y0 + that._y1) / 3, + (that._x0 + 2 * that._x1) / 3, + (that._y0 + 2 * that._y1) / 3, + (that._x0 + 4 * that._x1 + x) / 6, + (that._y0 + 4 * that._y1 + y) / 6 + ); +} + +function Basis(context) { + this._context = context; +} + +Basis.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 3: point$6(this, this._x1, this._y1); // falls through + case 2: this._context.lineTo(this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through + default: point$6(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasis(context) { + return new Basis(context); +} + +function BasisClosed(context) { + this._context = context; +} + +BasisClosed.prototype = { + areaStart: noop$3, + areaEnd: noop$3, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x2, this._y2); + this._context.closePath(); + break; + } + case 2: { + this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3); + this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x2, this._y2); + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x2 = x, this._y2 = y; break; + case 1: this._point = 2; this._x3 = x, this._y3 = y; break; + case 2: this._point = 3; this._x4 = x, this._y4 = y; this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6); break; + default: point$6(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasisClosed(context) { + return new BasisClosed(context); +} + +function BasisOpen(context) { + this._context = context; +} + +BasisOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = NaN; + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6; this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0); break; + case 3: this._point = 4; // falls through + default: point$6(this, x, y); break; + } + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + } +}; + +function curveBasisOpen(context) { + return new BasisOpen(context); +} + +function Bundle(context, beta) { + this._basis = new Basis(context); + this._beta = beta; +} + +Bundle.prototype = { + lineStart: function() { + this._x = []; + this._y = []; + this._basis.lineStart(); + }, + lineEnd: function() { + var x = this._x, + y = this._y, + j = x.length - 1; + + if (j > 0) { + var x0 = x[0], + y0 = y[0], + dx = x[j] - x0, + dy = y[j] - y0, + i = -1, + t; + + while (++i <= j) { + t = i / j; + this._basis.point( + this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), + this._beta * y[i] + (1 - this._beta) * (y0 + t * dy) + ); + } + } + + this._x = this._y = null; + this._basis.lineEnd(); + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +var curveBundle = (function custom(beta) { + + function bundle(context) { + return beta === 1 ? new Basis(context) : new Bundle(context, beta); + } + + bundle.beta = function(beta) { + return custom(+beta); + }; + + return bundle; +})(0.85); + +function point$5(that, x, y) { + that._context.bezierCurveTo( + that._x1 + that._k * (that._x2 - that._x0), + that._y1 + that._k * (that._y2 - that._y0), + that._x2 + that._k * (that._x1 - x), + that._y2 + that._k * (that._y1 - y), + that._x2, + that._y2 + ); +} + +function Cardinal(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +Cardinal.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x2, this._y2); break; + case 3: point$5(this, this._x1, this._y1); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; this._x1 = x, this._y1 = y; break; + case 2: this._point = 3; // falls through + default: point$5(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinal = (function custom(tension) { + + function cardinal(context) { + return new Cardinal(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalClosed(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalClosed.prototype = { + areaStart: noop$3, + areaEnd: noop$3, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 2: { + this._context.lineTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + this.point(this._x5, this._y5); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$5(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinalClosed = (function custom(tension) { + + function cardinal(context) { + return new CardinalClosed(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function CardinalOpen(context, tension) { + this._context = context; + this._k = (1 - tension) / 6; +} + +CardinalOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; + case 3: this._point = 4; // falls through + default: point$5(this, x, y); break; + } + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCardinalOpen = (function custom(tension) { + + function cardinal(context) { + return new CardinalOpen(context, tension); + } + + cardinal.tension = function(tension) { + return custom(+tension); + }; + + return cardinal; +})(0); + +function point$4(that, x, y) { + var x1 = that._x1, + y1 = that._y1, + x2 = that._x2, + y2 = that._y2; + + if (that._l01_a > epsilon$1) { + var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, + n = 3 * that._l01_a * (that._l01_a + that._l12_a); + x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n; + y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n; + } + + if (that._l23_a > epsilon$1) { + var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, + m = 3 * that._l23_a * (that._l23_a + that._l12_a); + x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m; + y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m; + } + + that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2); +} + +function CatmullRom(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRom.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x2, this._y2); break; + case 3: this.point(this._x2, this._y2); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; // falls through + default: point$4(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRom = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomClosed(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomClosed.prototype = { + areaStart: noop$3, + areaEnd: noop$3, + lineStart: function() { + this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = + this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 1: { + this._context.moveTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 2: { + this._context.lineTo(this._x3, this._y3); + this._context.closePath(); + break; + } + case 3: { + this.point(this._x3, this._y3); + this.point(this._x4, this._y4); + this.point(this._x5, this._y5); + break; + } + } + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; this._x3 = x, this._y3 = y; break; + case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; + case 2: this._point = 3; this._x5 = x, this._y5 = y; break; + default: point$4(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRomClosed = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function CatmullRomOpen(context, alpha) { + this._context = context; + this._alpha = alpha; +} + +CatmullRomOpen.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = this._x2 = + this._y0 = this._y1 = this._y2 = NaN; + this._l01_a = this._l12_a = this._l23_a = + this._l01_2a = this._l12_2a = this._l23_2a = + this._point = 0; + }, + lineEnd: function() { + if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + + if (this._point) { + var x23 = this._x2 - x, + y23 = this._y2 - y; + this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); + } + + switch (this._point) { + case 0: this._point = 1; break; + case 1: this._point = 2; break; + case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; + case 3: this._point = 4; // falls through + default: point$4(this, x, y); break; + } + + this._l01_a = this._l12_a, this._l12_a = this._l23_a; + this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; + this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; + this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; + } +}; + +var curveCatmullRomOpen = (function custom(alpha) { + + function catmullRom(context) { + return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0); + } + + catmullRom.alpha = function(alpha) { + return custom(+alpha); + }; + + return catmullRom; +})(0.5); + +function LinearClosed(context) { + this._context = context; +} + +LinearClosed.prototype = { + areaStart: noop$3, + areaEnd: noop$3, + lineStart: function() { + this._point = 0; + }, + lineEnd: function() { + if (this._point) this._context.closePath(); + }, + point: function(x, y) { + x = +x, y = +y; + if (this._point) this._context.lineTo(x, y); + else this._point = 1, this._context.moveTo(x, y); + } +}; + +function curveLinearClosed(context) { + return new LinearClosed(context); +} + +function sign(x) { + return x < 0 ? -1 : 1; +} + +// Calculate the slopes of the tangents (Hermite-type interpolation) based on +// the following paper: Steffen, M. 1990. A Simple Method for Monotonic +// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO. +// NOV(II), P. 443, 1990. +function slope3(that, x2, y2) { + var h0 = that._x1 - that._x0, + h1 = x2 - that._x1, + s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), + s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), + p = (s0 * h1 + s1 * h0) / (h0 + h1); + return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0; +} + +// Calculate a one-sided slope. +function slope2(that, t) { + var h = that._x1 - that._x0; + return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t; +} + +// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations +// "you can express cubic Hermite interpolation in terms of cubic Bézier curves +// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1". +function point$3(that, t0, t1) { + var x0 = that._x0, + y0 = that._y0, + x1 = that._x1, + y1 = that._y1, + dx = (x1 - x0) / 3; + that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1); +} + +function MonotoneX(context) { + this._context = context; +} + +MonotoneX.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x0 = this._x1 = + this._y0 = this._y1 = + this._t0 = NaN; + this._point = 0; + }, + lineEnd: function() { + switch (this._point) { + case 2: this._context.lineTo(this._x1, this._y1); break; + case 3: point$3(this, this._t0, slope2(this, this._t0)); break; + } + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + this._line = 1 - this._line; + }, + point: function(x, y) { + var t1 = NaN; + + x = +x, y = +y; + if (x === this._x1 && y === this._y1) return; // Ignore coincident points. + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; break; + case 2: this._point = 3; point$3(this, slope2(this, t1 = slope3(this, x, y)), t1); break; + default: point$3(this, this._t0, t1 = slope3(this, x, y)); break; + } + + this._x0 = this._x1, this._x1 = x; + this._y0 = this._y1, this._y1 = y; + this._t0 = t1; + } +}; + +function MonotoneY(context) { + this._context = new ReflectContext(context); +} + +(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) { + MonotoneX.prototype.point.call(this, y, x); +}; + +function ReflectContext(context) { + this._context = context; +} + +ReflectContext.prototype = { + moveTo: function(x, y) { this._context.moveTo(y, x); }, + closePath: function() { this._context.closePath(); }, + lineTo: function(x, y) { this._context.lineTo(y, x); }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); } +}; + +function monotoneX(context) { + return new MonotoneX(context); +} + +function monotoneY(context) { + return new MonotoneY(context); +} + +function Natural(context) { + this._context = context; +} + +Natural.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = []; + this._y = []; + }, + lineEnd: function() { + var x = this._x, + y = this._y, + n = x.length; + + if (n) { + this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]); + if (n === 2) { + this._context.lineTo(x[1], y[1]); + } else { + var px = controlPoints$1(x), + py = controlPoints$1(y); + for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) { + this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]); + } + } + } + + if (this._line || (this._line !== 0 && n === 1)) this._context.closePath(); + this._line = 1 - this._line; + this._x = this._y = null; + }, + point: function(x, y) { + this._x.push(+x); + this._y.push(+y); + } +}; + +// See https://www.particleincell.com/2012/bezier-splines/ for derivation. +function controlPoints$1(x) { + var i, + n = x.length - 1, + m, + a = new Array(n), + b = new Array(n), + r = new Array(n); + a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1]; + for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1]; + a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n]; + for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1]; + a[n - 1] = r[n - 1] / b[n - 1]; + for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i]; + b[n - 1] = (x[n] + a[n - 1]) / 2; + for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1]; + return [a, b]; +} + +function curveNatural(context) { + return new Natural(context); +} + +function Step(context, t) { + this._context = context; + this._t = t; +} + +Step.prototype = { + areaStart: function() { + this._line = 0; + }, + areaEnd: function() { + this._line = NaN; + }, + lineStart: function() { + this._x = this._y = NaN; + this._point = 0; + }, + lineEnd: function() { + if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y); + if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); + if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line; + }, + point: function(x, y) { + x = +x, y = +y; + switch (this._point) { + case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; + case 1: this._point = 2; // falls through + default: { + if (this._t <= 0) { + this._context.lineTo(this._x, y); + this._context.lineTo(x, y); + } else { + var x1 = this._x * (1 - this._t) + x * this._t; + this._context.lineTo(x1, this._y); + this._context.lineTo(x1, y); + } + break; + } + } + this._x = x, this._y = y; + } +}; + +function curveStep(context) { + return new Step(context, 0.5); +} + +function stepBefore(context) { + return new Step(context, 0); +} + +function stepAfter(context) { + return new Step(context, 1); +} + +function Transform(k, x, y) { + this.k = k; + this.x = x; + this.y = y; +} + +Transform.prototype = { + constructor: Transform, + scale: function(k) { + return k === 1 ? this : new Transform(this.k * k, this.x, this.y); + }, + translate: function(x, y) { + return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y); + }, + apply: function(point) { + return [point[0] * this.k + this.x, point[1] * this.k + this.y]; + }, + applyX: function(x) { + return x * this.k + this.x; + }, + applyY: function(y) { + return y * this.k + this.y; + }, + invert: function(location) { + return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k]; + }, + invertX: function(x) { + return (x - this.x) / this.k; + }, + invertY: function(y) { + return (y - this.y) / this.k; + }, + rescaleX: function(x) { + return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x)); + }, + rescaleY: function(y) { + return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y)); + }, + toString: function() { + return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; + } +}; + +Transform.prototype; + +/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */ + +const { + entries, + setPrototypeOf, + isFrozen, + getPrototypeOf, + getOwnPropertyDescriptor +} = Object; +let { + freeze, + seal, + create +} = Object; // eslint-disable-line import/no-mutable-exports +let { + apply: apply$2, + construct +} = typeof Reflect !== 'undefined' && Reflect; +if (!freeze) { + freeze = function freeze(x) { + return x; + }; +} +if (!seal) { + seal = function seal(x) { + return x; + }; +} +if (!apply$2) { + apply$2 = function apply(fun, thisValue, args) { + return fun.apply(thisValue, args); + }; +} +if (!construct) { + construct = function construct(Func, args) { + return new Func(...args); + }; +} +const arrayForEach = unapply(Array.prototype.forEach); +const arrayPop = unapply(Array.prototype.pop); +const arrayPush$1 = unapply(Array.prototype.push); +const stringToLowerCase = unapply(String.prototype.toLowerCase); +const stringToString = unapply(String.prototype.toString); +const stringMatch = unapply(String.prototype.match); +const stringReplace = unapply(String.prototype.replace); +const stringIndexOf = unapply(String.prototype.indexOf); +const stringTrim = unapply(String.prototype.trim); +const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); +const regExpTest = unapply(RegExp.prototype.test); +const typeErrorCreate = unconstruct(TypeError); + +/** + * Creates a new function that calls the given function with a specified thisArg and arguments. + * + * @param {Function} func - The function to be wrapped and called. + * @returns {Function} A new function that calls the given function with a specified thisArg and arguments. + */ +function unapply(func) { + return function (thisArg) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + return apply$2(func, thisArg, args); + }; +} + +/** + * Creates a new function that constructs an instance of the given constructor function with the provided arguments. + * + * @param {Function} func - The constructor function to be wrapped and called. + * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments. + */ +function unconstruct(func) { + return function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + return construct(func, args); + }; +} + +/** + * Add properties to a lookup table + * + * @param {Object} set - The set to which elements will be added. + * @param {Array} array - The array containing elements to be added to the set. + * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set. + * @returns {Object} The modified set with added elements. + */ +function addToSet(set, array) { + let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; + if (setPrototypeOf) { + // Make 'in' and truthy checks like Boolean(set.constructor) + // independent of any properties defined on Object.prototype. + // Prevent prototype setters from intercepting set as a this value. + setPrototypeOf(set, null); + } + let l = array.length; + while (l--) { + let element = array[l]; + if (typeof element === 'string') { + const lcElement = transformCaseFunc(element); + if (lcElement !== element) { + // Config presets (e.g. tags.js, attrs.js) are immutable. + if (!isFrozen(array)) { + array[l] = lcElement; + } + element = lcElement; + } + } + set[element] = true; + } + return set; +} + +/** + * Clean up an array to harden against CSPP + * + * @param {Array} array - The array to be cleaned. + * @returns {Array} The cleaned version of the array + */ +function cleanArray(array) { + for (let index = 0; index < array.length; index++) { + const isPropertyExist = objectHasOwnProperty(array, index); + if (!isPropertyExist) { + array[index] = null; + } + } + return array; +} + +/** + * Shallow clone an object + * + * @param {Object} object - The object to be cloned. + * @returns {Object} A new object that copies the original. + */ +function clone$3(object) { + const newObject = create(null); + for (const [property, value] of entries(object)) { + const isPropertyExist = objectHasOwnProperty(object, property); + if (isPropertyExist) { + if (Array.isArray(value)) { + newObject[property] = cleanArray(value); + } else if (value && typeof value === 'object' && value.constructor === Object) { + newObject[property] = clone$3(value); + } else { + newObject[property] = value; + } + } + } + return newObject; +} + +/** + * This method automatically checks if the prop is function or getter and behaves accordingly. + * + * @param {Object} object - The object to look up the getter function in its prototype chain. + * @param {String} prop - The property name for which to find the getter function. + * @returns {Function} The getter function found in the prototype chain or a fallback function. + */ +function lookupGetter(object, prop) { + while (object !== null) { + const desc = getOwnPropertyDescriptor(object, prop); + if (desc) { + if (desc.get) { + return unapply(desc.get); + } + if (typeof desc.value === 'function') { + return unapply(desc.value); + } + } + object = getPrototypeOf(object); + } + function fallbackValue() { + return null; + } + return fallbackValue; +} + +const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); + +// SVG +const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); +const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); + +// List of SVG elements that are disallowed by default. +// We still need to know them so that we can do namespace +// checks properly in case one wants to add them to +// allow-list. +const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); +const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); + +// Similarly to SVG, we want to know all MathML elements, +// even those that we disallow by default. +const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); +const text$2 = freeze(['#text']); + +const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); +const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); +const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); +const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); + +// eslint-disable-next-line unicorn/better-regex +const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode +const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); +const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm); +const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape +const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape +const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape +); + +const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); +const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex +); + +const DOCTYPE_NAME = seal(/^html$/i); +const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); + +var EXPRESSIONS = /*#__PURE__*/Object.freeze({ + __proto__: null, + MUSTACHE_EXPR: MUSTACHE_EXPR, + ERB_EXPR: ERB_EXPR, + TMPLIT_EXPR: TMPLIT_EXPR, + DATA_ATTR: DATA_ATTR, + ARIA_ATTR: ARIA_ATTR, + IS_ALLOWED_URI: IS_ALLOWED_URI, + IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE: ATTR_WHITESPACE, + DOCTYPE_NAME: DOCTYPE_NAME, + CUSTOM_ELEMENT: CUSTOM_ELEMENT +}); + +// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType +const NODE_TYPE = { + element: 1, + attribute: 2, + text: 3, + cdataSection: 4, + entityReference: 5, + // Deprecated + entityNode: 6, + // Deprecated + progressingInstruction: 7, + comment: 8, + document: 9, + documentType: 10, + documentFragment: 11, + notation: 12 // Deprecated +}; + +const getGlobal = function getGlobal() { + return typeof window === 'undefined' ? null : window; +}; + +/** + * Creates a no-op policy for internal use only. + * Don't export this function outside this module! + * @param {TrustedTypePolicyFactory} trustedTypes The policy factory. + * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). + * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types + * are not supported or creating the policy failed). + */ +const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { + if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { + return null; + } + + // Allow the callers to control the unique policy name + // by adding a data-tt-policy-suffix to the script element with the DOMPurify. + // Policy creation with duplicate names throws in Trusted Types. + let suffix = null; + const ATTR_NAME = 'data-tt-policy-suffix'; + if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { + suffix = purifyHostElement.getAttribute(ATTR_NAME); + } + const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); + try { + return trustedTypes.createPolicy(policyName, { + createHTML(html) { + return html; + }, + createScriptURL(scriptUrl) { + return scriptUrl; + } + }); + } catch (_) { + // Policy creation failed (most likely another DOMPurify script has + // already run). Skip creating the policy, as this will only cause errors + // if TT are enforced. + console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); + return null; + } +}; +function createDOMPurify() { + let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); + const DOMPurify = root => createDOMPurify(root); + + /** + * Version label, exposed for easier checks + * if DOMPurify is up to date or not + */ + DOMPurify.version = '3.1.5'; + + /** + * Array of elements that DOMPurify removed during sanitation. + * Empty if nothing was removed. + */ + DOMPurify.removed = []; + if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) { + // Not running in a browser, provide a factory function + // so that you can pass your own Window + DOMPurify.isSupported = false; + return DOMPurify; + } + let { + document + } = window; + const originalDocument = document; + const currentScript = originalDocument.currentScript; + const { + DocumentFragment, + HTMLTemplateElement, + Node, + Element, + NodeFilter, + NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, + HTMLFormElement, + DOMParser, + trustedTypes + } = window; + const ElementPrototype = Element.prototype; + const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); + const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); + const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); + + // As per issue #47, the web-components registry is inherited by a + // new document created via createHTMLDocument. As per the spec + // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) + // a new empty registry is used when creating a template contents owner + // document, so we use that as our parent document to ensure nothing + // is inherited. + if (typeof HTMLTemplateElement === 'function') { + const template = document.createElement('template'); + if (template.content && template.content.ownerDocument) { + document = template.content.ownerDocument; + } + } + let trustedTypesPolicy; + let emptyHTML = ''; + const { + implementation, + createNodeIterator, + createDocumentFragment, + getElementsByTagName + } = document; + const { + importNode + } = originalDocument; + let hooks = {}; + + /** + * Expose whether this browser supports running the full DOMPurify. + */ + DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; + const { + MUSTACHE_EXPR, + ERB_EXPR, + TMPLIT_EXPR, + DATA_ATTR, + ARIA_ATTR, + IS_SCRIPT_OR_DATA, + ATTR_WHITESPACE, + CUSTOM_ELEMENT + } = EXPRESSIONS; + let { + IS_ALLOWED_URI: IS_ALLOWED_URI$1 + } = EXPRESSIONS; + + /** + * We consider the elements and attributes below to be safe. Ideally + * don't add any new ones but feel free to remove unwanted ones. + */ + + /* allowed element names */ + let ALLOWED_TAGS = null; + const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]); + + /* Allowed attribute names */ + let ALLOWED_ATTR = null; + const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); + + /* + * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements. + * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) + * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) + * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. + */ + let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { + tagNameCheck: { + writable: true, + configurable: false, + enumerable: true, + value: null + }, + attributeNameCheck: { + writable: true, + configurable: false, + enumerable: true, + value: null + }, + allowCustomizedBuiltInElements: { + writable: true, + configurable: false, + enumerable: true, + value: false + } + })); + + /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ + let FORBID_TAGS = null; + + /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ + let FORBID_ATTR = null; + + /* Decide if ARIA attributes are okay */ + let ALLOW_ARIA_ATTR = true; + + /* Decide if custom data attributes are okay */ + let ALLOW_DATA_ATTR = true; + + /* Decide if unknown protocols are okay */ + let ALLOW_UNKNOWN_PROTOCOLS = false; + + /* Decide if self-closing tags in attributes are allowed. + * Usually removed due to a mXSS issue in jQuery 3.0 */ + let ALLOW_SELF_CLOSE_IN_ATTR = true; + + /* Output should be safe for common template engines. + * This means, DOMPurify removes data attributes, mustaches and ERB + */ + let SAFE_FOR_TEMPLATES = false; + + /* Output should be safe even for XML used within HTML and alike. + * This means, DOMPurify removes comments when containing risky content. + */ + let SAFE_FOR_XML = true; + + /* Decide if document with ... should be returned */ + let WHOLE_DOCUMENT = false; + + /* Track whether config is already set on this instance of DOMPurify. */ + let SET_CONFIG = false; + + /* Decide if all elements (e.g. style, script) must be children of + * document.body. By default, browsers might move them to document.head */ + let FORCE_BODY = false; + + /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported). + * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead + */ + let RETURN_DOM = false; + + /* Decide if a DOM `DocumentFragment` should be returned, instead of a html + * string (or a TrustedHTML object if Trusted Types are supported) */ + let RETURN_DOM_FRAGMENT = false; + + /* Try to return a Trusted Type object instead of a string, return a string in + * case Trusted Types are not supported */ + let RETURN_TRUSTED_TYPE = false; + + /* Output should be free from DOM clobbering attacks? + * This sanitizes markups named with colliding, clobberable built-in DOM APIs. + */ + let SANITIZE_DOM = true; + + /* Achieve full DOM Clobbering protection by isolating the namespace of named + * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. + * + * HTML/DOM spec rules that enable DOM Clobbering: + * - Named Access on Window (§7.3.3) + * - DOM Tree Accessors (§3.1.5) + * - Form Element Parent-Child Relations (§4.10.3) + * - Iframe srcdoc / Nested WindowProxies (§4.8.5) + * - HTMLCollection (§4.2.10.2) + * + * Namespace isolation is implemented by prefixing `id` and `name` attributes + * with a constant string, i.e., `user-content-` + */ + let SANITIZE_NAMED_PROPS = false; + const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; + + /* Keep element content when removing element? */ + let KEEP_CONTENT = true; + + /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead + * of importing it into a new Document and returning a sanitized copy */ + let IN_PLACE = false; + + /* Allow usage of profiles like html, svg and mathMl */ + let USE_PROFILES = {}; + + /* Tags to ignore content of when KEEP_CONTENT is true */ + let FORBID_CONTENTS = null; + const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); + + /* Tags that are safe for data: URIs */ + let DATA_URI_TAGS = null; + const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); + + /* Attributes safe for values like "javascript:" */ + let URI_SAFE_ATTRIBUTES = null; + const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); + const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; + const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; + const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; + /* Document namespace */ + let NAMESPACE = HTML_NAMESPACE; + let IS_EMPTY_INPUT = false; + + /* Allowed XHTML+XML namespaces */ + let ALLOWED_NAMESPACES = null; + const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); + + /* Parsing of strict XHTML documents */ + let PARSER_MEDIA_TYPE = null; + const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; + const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; + let transformCaseFunc = null; + + /* Keep a reference to config to pass to hooks */ + let CONFIG = null; + + /* Ideally, do not touch anything below this line */ + /* ______________________________________________ */ + + const formElement = document.createElement('form'); + const isRegexOrFunction = function isRegexOrFunction(testValue) { + return testValue instanceof RegExp || testValue instanceof Function; + }; + + /** + * _parseConfig + * + * @param {Object} cfg optional config literal + */ + // eslint-disable-next-line complexity + const _parseConfig = function _parseConfig() { + let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + if (CONFIG && CONFIG === cfg) { + return; + } + + /* Shield configuration object from tampering */ + if (!cfg || typeof cfg !== 'object') { + cfg = {}; + } + + /* Shield configuration object from prototype pollution */ + cfg = clone$3(cfg); + PARSER_MEDIA_TYPE = + // eslint-disable-next-line unicorn/prefer-includes + SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; + + // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. + transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; + + /* Set configuration parameters */ + ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; + ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; + ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; + URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone$3(DEFAULT_URI_SAFE_ATTRIBUTES), + // eslint-disable-line indent + cfg.ADD_URI_SAFE_ATTR, + // eslint-disable-line indent + transformCaseFunc // eslint-disable-line indent + ) // eslint-disable-line indent + : DEFAULT_URI_SAFE_ATTRIBUTES; + DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone$3(DEFAULT_DATA_URI_TAGS), + // eslint-disable-line indent + cfg.ADD_DATA_URI_TAGS, + // eslint-disable-line indent + transformCaseFunc // eslint-disable-line indent + ) // eslint-disable-line indent + : DEFAULT_DATA_URI_TAGS; + FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; + FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {}; + FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {}; + USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; + ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true + ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true + ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false + ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true + SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false + SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true + WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false + RETURN_DOM = cfg.RETURN_DOM || false; // Default false + RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false + RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false + FORCE_BODY = cfg.FORCE_BODY || false; // Default false + SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true + SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false + KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true + IN_PLACE = cfg.IN_PLACE || false; // Default false + IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; + NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; + CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; + if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { + CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; + } + if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { + CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; + } + if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { + CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; + } + if (SAFE_FOR_TEMPLATES) { + ALLOW_DATA_ATTR = false; + } + if (RETURN_DOM_FRAGMENT) { + RETURN_DOM = true; + } + + /* Parse profile info */ + if (USE_PROFILES) { + ALLOWED_TAGS = addToSet({}, text$2); + ALLOWED_ATTR = []; + if (USE_PROFILES.html === true) { + addToSet(ALLOWED_TAGS, html$1); + addToSet(ALLOWED_ATTR, html); + } + if (USE_PROFILES.svg === true) { + addToSet(ALLOWED_TAGS, svg$1); + addToSet(ALLOWED_ATTR, svg); + addToSet(ALLOWED_ATTR, xml); + } + if (USE_PROFILES.svgFilters === true) { + addToSet(ALLOWED_TAGS, svgFilters); + addToSet(ALLOWED_ATTR, svg); + addToSet(ALLOWED_ATTR, xml); + } + if (USE_PROFILES.mathMl === true) { + addToSet(ALLOWED_TAGS, mathMl$1); + addToSet(ALLOWED_ATTR, mathMl); + addToSet(ALLOWED_ATTR, xml); + } + } + + /* Merge configuration parameters */ + if (cfg.ADD_TAGS) { + if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { + ALLOWED_TAGS = clone$3(ALLOWED_TAGS); + } + addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); + } + if (cfg.ADD_ATTR) { + if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { + ALLOWED_ATTR = clone$3(ALLOWED_ATTR); + } + addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); + } + if (cfg.ADD_URI_SAFE_ATTR) { + addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); + } + if (cfg.FORBID_CONTENTS) { + if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { + FORBID_CONTENTS = clone$3(FORBID_CONTENTS); + } + addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); + } + + /* Add #text in case KEEP_CONTENT is set to true */ + if (KEEP_CONTENT) { + ALLOWED_TAGS['#text'] = true; + } + + /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ + if (WHOLE_DOCUMENT) { + addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); + } + + /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ + if (ALLOWED_TAGS.table) { + addToSet(ALLOWED_TAGS, ['tbody']); + delete FORBID_TAGS.tbody; + } + if (cfg.TRUSTED_TYPES_POLICY) { + if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { + throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); + } + if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { + throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); + } + + // Overwrite existing TrustedTypes policy. + trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; + + // Sign local variables required by `sanitize`. + emptyHTML = trustedTypesPolicy.createHTML(''); + } else { + // Uninitialized policy, attempt to initialize the internal dompurify policy. + if (trustedTypesPolicy === undefined) { + trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); + } + + // If creating the internal policy succeeded sign internal variables. + if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { + emptyHTML = trustedTypesPolicy.createHTML(''); + } + } + + // Prevent further manipulation of configuration. + // Not available in IE8, Safari 5, etc. + if (freeze) { + freeze(cfg); + } + CONFIG = cfg; + }; + const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); + const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']); + + // Certain elements are allowed in both SVG and HTML + // namespace. We need to specify them explicitly + // so that they don't get erroneously deleted from + // HTML namespace. + const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); + + /* Keep track of all possible SVG and MathML tags + * so that we can perform the namespace checks + * correctly. */ + const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); + const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); + + /** + * @param {Element} element a DOM element whose namespace is being checked + * @returns {boolean} Return false if the element has a + * namespace that a spec-compliant parser would never + * return. Return true otherwise. + */ + const _checkValidNamespace = function _checkValidNamespace(element) { + let parent = getParentNode(element); + + // In JSDOM, if we're inside shadow DOM, then parentNode + // can be null. We just simulate parent in this case. + if (!parent || !parent.tagName) { + parent = { + namespaceURI: NAMESPACE, + tagName: 'template' + }; + } + const tagName = stringToLowerCase(element.tagName); + const parentTagName = stringToLowerCase(parent.tagName); + if (!ALLOWED_NAMESPACES[element.namespaceURI]) { + return false; + } + if (element.namespaceURI === SVG_NAMESPACE) { + // The only way to switch from HTML namespace to SVG + // is via . If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'svg'; + } + + // The only way to switch from MathML to SVG is via` + // svg if parent is either or MathML + // text integration points. + if (parent.namespaceURI === MATHML_NAMESPACE) { + return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); + } + + // We only allow elements that are defined in SVG + // spec. All others are disallowed in SVG namespace. + return Boolean(ALL_SVG_TAGS[tagName]); + } + if (element.namespaceURI === MATHML_NAMESPACE) { + // The only way to switch from HTML namespace to MathML + // is via . If it happens via any other tag, then + // it should be killed. + if (parent.namespaceURI === HTML_NAMESPACE) { + return tagName === 'math'; + } + + // The only way to switch from SVG to MathML is via + // and HTML integration points + if (parent.namespaceURI === SVG_NAMESPACE) { + return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; + } + + // We only allow elements that are defined in MathML + // spec. All others are disallowed in MathML namespace. + return Boolean(ALL_MATHML_TAGS[tagName]); + } + if (element.namespaceURI === HTML_NAMESPACE) { + // The only way to switch from SVG to HTML is via + // HTML integration points, and from MathML to HTML + // is via MathML text integration points + if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { + return false; + } + if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { + return false; + } + + // We disallow tags that are specific for MathML + // or SVG and should never appear in HTML namespace + return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); + } + + // For XHTML and XML documents that support custom namespaces + if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { + return true; + } + + // The code should never reach this place (this means + // that the element somehow got namespace that is not + // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). + // Return false just in case. + return false; + }; + + /** + * _forceRemove + * + * @param {Node} node a DOM node + */ + const _forceRemove = function _forceRemove(node) { + arrayPush$1(DOMPurify.removed, { + element: node + }); + try { + // eslint-disable-next-line unicorn/prefer-dom-node-remove + node.parentNode.removeChild(node); + } catch (_) { + node.remove(); + } + }; + + /** + * _removeAttribute + * + * @param {String} name an Attribute name + * @param {Node} node a DOM node + */ + const _removeAttribute = function _removeAttribute(name, node) { + try { + arrayPush$1(DOMPurify.removed, { + attribute: node.getAttributeNode(name), + from: node + }); + } catch (_) { + arrayPush$1(DOMPurify.removed, { + attribute: null, + from: node + }); + } + node.removeAttribute(name); + + // We void attribute values for unremovable "is"" attributes + if (name === 'is' && !ALLOWED_ATTR[name]) { + if (RETURN_DOM || RETURN_DOM_FRAGMENT) { + try { + _forceRemove(node); + } catch (_) {} + } else { + try { + node.setAttribute(name, ''); + } catch (_) {} + } + } + }; + + /** + * _initDocument + * + * @param {String} dirty a string of dirty markup + * @return {Document} a DOM, filled with the dirty markup + */ + const _initDocument = function _initDocument(dirty) { + /* Create a HTML document */ + let doc = null; + let leadingWhitespace = null; + if (FORCE_BODY) { + dirty = '' + dirty; + } else { + /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ + const matches = stringMatch(dirty, /^[\r\n\t ]+/); + leadingWhitespace = matches && matches[0]; + } + if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { + // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) + dirty = '' + dirty + ''; + } + const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; + /* + * Use the DOMParser API by default, fallback later if needs be + * DOMParser not work for svg when has multiple root element. + */ + if (NAMESPACE === HTML_NAMESPACE) { + try { + doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); + } catch (_) {} + } + + /* Use createHTMLDocument in case DOMParser is not available */ + if (!doc || !doc.documentElement) { + doc = implementation.createDocument(NAMESPACE, 'template', null); + try { + doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; + } catch (_) { + // Syntax error if dirtyPayload is invalid xml + } + } + const body = doc.body || doc.documentElement; + if (dirty && leadingWhitespace) { + body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); + } + + /* Work on whole document or just its body */ + if (NAMESPACE === HTML_NAMESPACE) { + return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; + } + return WHOLE_DOCUMENT ? doc.documentElement : body; + }; + + /** + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * + * @param {Node} root The root element or node to start traversing on. + * @return {NodeIterator} The created NodeIterator + */ + const _createNodeIterator = function _createNodeIterator(root) { + return createNodeIterator.call(root.ownerDocument || root, root, + // eslint-disable-next-line no-bitwise + NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); + }; + + /** + * _isClobbered + * + * @param {Node} elm element to check for clobbering attacks + * @return {Boolean} true if clobbered, false if safe + */ + const _isClobbered = function _isClobbered(elm) { + return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function'); + }; + + /** + * Checks whether the given object is a DOM node. + * + * @param {Node} object object to check whether it's a DOM node + * @return {Boolean} true is object is a DOM node + */ + const _isNode = function _isNode(object) { + return typeof Node === 'function' && object instanceof Node; + }; + + /** + * _executeHook + * Execute user configurable hooks + * + * @param {String} entryPoint Name of the hook's entry point + * @param {Node} currentNode node to work on with the hook + * @param {Object} data additional hook parameters + */ + const _executeHook = function _executeHook(entryPoint, currentNode, data) { + if (!hooks[entryPoint]) { + return; + } + arrayForEach(hooks[entryPoint], hook => { + hook.call(DOMPurify, currentNode, data, CONFIG); + }); + }; + + /** + * _sanitizeElements + * + * @protect nodeName + * @protect textContent + * @protect removeChild + * + * @param {Node} currentNode to check for permission to exist + * @return {Boolean} true if node was killed, false if left alive + */ + const _sanitizeElements = function _sanitizeElements(currentNode) { + let content = null; + + /* Execute a hook if present */ + _executeHook('beforeSanitizeElements', currentNode, null); + + /* Check if element is clobbered or can clobber */ + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Now let's check the element's type and name */ + const tagName = transformCaseFunc(currentNode.nodeName); + + /* Execute a hook if present */ + _executeHook('uponSanitizeElement', currentNode, { + tagName, + allowedTags: ALLOWED_TAGS + }); + + /* Detect mXSS attempts abusing namespace confusion */ + if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { + _forceRemove(currentNode); + return true; + } + + /* Remove any ocurrence of processing instructions */ + if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { + _forceRemove(currentNode); + return true; + } + + /* Remove any kind of possibly harmful comments */ + if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { + _forceRemove(currentNode); + return true; + } + + /* Remove element if anything forbids its presence */ + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + /* Check if we have a custom element to handle */ + if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { + if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { + return false; + } + if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { + return false; + } + } + + /* Keep content except for bad-listed elements */ + if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { + const parentNode = getParentNode(currentNode) || currentNode.parentNode; + const childNodes = getChildNodes(currentNode) || currentNode.childNodes; + if (childNodes && parentNode) { + const childCount = childNodes.length; + for (let i = childCount - 1; i >= 0; --i) { + const childClone = cloneNode(childNodes[i], true); + childClone.__removalCount = (currentNode.__removalCount || 0) + 1; + parentNode.insertBefore(childClone, getNextSibling(currentNode)); + } + } + } + _forceRemove(currentNode); + return true; + } + + /* Check whether element has a valid namespace */ + if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { + _forceRemove(currentNode); + return true; + } + + /* Make sure that older browsers don't get fallback-tag mXSS */ + if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { + _forceRemove(currentNode); + return true; + } + + /* Sanitize element content to be template-safe */ + if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { + /* Get the element's text content */ + content = currentNode.textContent; + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + content = stringReplace(content, expr, ' '); + }); + if (currentNode.textContent !== content) { + arrayPush$1(DOMPurify.removed, { + element: currentNode.cloneNode() + }); + currentNode.textContent = content; + } + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeElements', currentNode, null); + return false; + }; + + /** + * _isValidAttribute + * + * @param {string} lcTag Lowercase tag name of containing element. + * @param {string} lcName Lowercase attribute name. + * @param {string} value Attribute value. + * @return {Boolean} Returns true if `value` is valid, otherwise false. + */ + // eslint-disable-next-line complexity + const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { + /* Make sure attribute cannot clobber */ + if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { + return false; + } + + /* Allow valid data-* attributes: At least one character after "-" + (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) + XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) + We don't need to check the value; it's always URI safe. */ + if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { + if ( + // First condition does a very basic check if a) it's basically a valid custom element tagname AND + // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck + // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck + _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || + // Alternative, second condition checks if it's an `is`-attribute, AND + // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck + lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { + return false; + } + /* Check value is safe. First, is attr inert? If so, is safe */ + } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { + return false; + } else ; + return true; + }; + + /** + * _isBasicCustomElement + * checks if at least one dash is included in tagName, and it's not the first char + * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name + * + * @param {string} tagName name of the tag of the node to sanitize + * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false. + */ + const _isBasicCustomElement = function _isBasicCustomElement(tagName) { + return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); + }; + + /** + * _sanitizeAttributes + * + * @protect attributes + * @protect nodeName + * @protect removeAttribute + * @protect setAttribute + * + * @param {Node} currentNode to sanitize + */ + const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { + /* Execute a hook if present */ + _executeHook('beforeSanitizeAttributes', currentNode, null); + const { + attributes + } = currentNode; + + /* Check if we have attributes; if not we might have a text node */ + if (!attributes) { + return; + } + const hookEvent = { + attrName: '', + attrValue: '', + keepAttr: true, + allowedAttributes: ALLOWED_ATTR + }; + let l = attributes.length; + + /* Go backwards over all attributes; safely remove bad ones */ + while (l--) { + const attr = attributes[l]; + const { + name, + namespaceURI, + value: attrValue + } = attr; + const lcName = transformCaseFunc(name); + let value = name === 'value' ? attrValue : stringTrim(attrValue); + + /* Execute a hook if present */ + hookEvent.attrName = lcName; + hookEvent.attrValue = value; + hookEvent.keepAttr = true; + hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set + _executeHook('uponSanitizeAttribute', currentNode, hookEvent); + value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ + if (hookEvent.forceKeepAttr) { + continue; + } + + /* Remove attribute */ + _removeAttribute(name, currentNode); + + /* Did the hooks approve of the attribute? */ + if (!hookEvent.keepAttr) { + continue; + } + + /* Work around a security issue in jQuery 3.0 */ + if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Work around a security issue with comments inside attributes */ + if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + + /* Sanitize attribute content to be template-safe */ + if (SAFE_FOR_TEMPLATES) { + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + value = stringReplace(value, expr, ' '); + }); + } + + /* Is `value` valid for this attribute? */ + const lcTag = transformCaseFunc(currentNode.nodeName); + if (!_isValidAttribute(lcTag, lcName, value)) { + continue; + } + + /* Full DOM Clobbering protection via namespace isolation, + * Prefix id and name attributes with `user-content-` + */ + if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { + // Remove the attribute with this value + _removeAttribute(name, currentNode); + + // Prefix the value and later re-create the attribute with the sanitized value + value = SANITIZE_NAMED_PROPS_PREFIX + value; + } + + /* Handle attributes that require Trusted Types */ + if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { + if (namespaceURI) ; else { + switch (trustedTypes.getAttributeType(lcTag, lcName)) { + case 'TrustedHTML': + { + value = trustedTypesPolicy.createHTML(value); + break; + } + case 'TrustedScriptURL': + { + value = trustedTypesPolicy.createScriptURL(value); + break; + } + } + } + } + + /* Handle invalid data-* attribute set by try-catching it */ + try { + if (namespaceURI) { + currentNode.setAttributeNS(namespaceURI, name, value); + } else { + /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ + currentNode.setAttribute(name, value); + } + if (_isClobbered(currentNode)) { + _forceRemove(currentNode); + } else { + arrayPop(DOMPurify.removed); + } + } catch (_) {} + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeAttributes', currentNode, null); + }; + + /** + * _sanitizeShadowDOM + * + * @param {DocumentFragment} fragment to iterate over recursively + */ + const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { + let shadowNode = null; + const shadowIterator = _createNodeIterator(fragment); + + /* Execute a hook if present */ + _executeHook('beforeSanitizeShadowDOM', fragment, null); + while (shadowNode = shadowIterator.nextNode()) { + /* Execute a hook if present */ + _executeHook('uponSanitizeShadowNode', shadowNode, null); + + /* Sanitize tags and elements */ + if (_sanitizeElements(shadowNode)) { + continue; + } + + /* Deep shadow DOM detected */ + if (shadowNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(shadowNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(shadowNode); + } + + /* Execute a hook if present */ + _executeHook('afterSanitizeShadowDOM', fragment, null); + }; + + /** + * Sanitize + * Public method providing core sanitation functionality + * + * @param {String|Node} dirty string or DOM node + * @param {Object} cfg object + */ + // eslint-disable-next-line complexity + DOMPurify.sanitize = function (dirty) { + let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + let body = null; + let importedNode = null; + let currentNode = null; + let returnNode = null; + /* Make sure we have a string to sanitize. + DO NOT return early, as this will return the wrong type if + the user has requested a DOM object rather than a string */ + IS_EMPTY_INPUT = !dirty; + if (IS_EMPTY_INPUT) { + dirty = ''; + } + + /* Stringify, in case dirty is an object */ + if (typeof dirty !== 'string' && !_isNode(dirty)) { + if (typeof dirty.toString === 'function') { + dirty = dirty.toString(); + if (typeof dirty !== 'string') { + throw typeErrorCreate('dirty is not a string, aborting'); + } + } else { + throw typeErrorCreate('toString is not a function'); + } + } + + /* Return dirty HTML if DOMPurify cannot run */ + if (!DOMPurify.isSupported) { + return dirty; + } + + /* Assign config vars */ + if (!SET_CONFIG) { + _parseConfig(cfg); + } + + /* Clean up removed elements */ + DOMPurify.removed = []; + + /* Check if dirty is correctly typed for IN_PLACE */ + if (typeof dirty === 'string') { + IN_PLACE = false; + } + if (IN_PLACE) { + /* Do some early pre-sanitization to avoid unsafe root nodes */ + if (dirty.nodeName) { + const tagName = transformCaseFunc(dirty.nodeName); + if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { + throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); + } + } + } else if (dirty instanceof Node) { + /* If dirty is a DOM element, append to an empty document to avoid + elements being stripped by the parser */ + body = _initDocument(''); + importedNode = body.ownerDocument.importNode(dirty, true); + if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { + /* Node is already a body, use as is */ + body = importedNode; + } else if (importedNode.nodeName === 'HTML') { + body = importedNode; + } else { + // eslint-disable-next-line unicorn/prefer-dom-node-append + body.appendChild(importedNode); + } + } else { + /* Exit directly if we have nothing to do */ + if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && + // eslint-disable-next-line unicorn/prefer-includes + dirty.indexOf('<') === -1) { + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; + } + + /* Initialize the document to work on */ + body = _initDocument(dirty); + + /* Check we have a DOM node from the data */ + if (!body) { + return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; + } + } + + /* Remove first element node (ours) if FORCE_BODY is set */ + if (body && FORCE_BODY) { + _forceRemove(body.firstChild); + } + + /* Get node iterator */ + const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); + + /* Now start iterating over the created document */ + while (currentNode = nodeIterator.nextNode()) { + /* Sanitize tags and elements */ + if (_sanitizeElements(currentNode)) { + continue; + } + + /* Shadow DOM detected, sanitize it */ + if (currentNode.content instanceof DocumentFragment) { + _sanitizeShadowDOM(currentNode.content); + } + + /* Check attributes, sanitize if necessary */ + _sanitizeAttributes(currentNode); + } + + /* If we sanitized `dirty` in-place, return it. */ + if (IN_PLACE) { + return dirty; + } + + /* Return sanitized string or DOM */ + if (RETURN_DOM) { + if (RETURN_DOM_FRAGMENT) { + returnNode = createDocumentFragment.call(body.ownerDocument); + while (body.firstChild) { + // eslint-disable-next-line unicorn/prefer-dom-node-append + returnNode.appendChild(body.firstChild); + } + } else { + returnNode = body; + } + if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { + /* + AdoptNode() is not used because internal state is not reset + (e.g. the past names map of a HTMLFormElement), this is safe + in theory but we would rather not risk another attack vector. + The state that is cloned by importNode() is explicitly defined + by the specs. + */ + returnNode = importNode.call(originalDocument, returnNode, true); + } + return returnNode; + } + let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; + + /* Serialize doctype if allowed */ + if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { + serializedHTML = '\n' + serializedHTML; + } + + /* Sanitize final string template-safe */ + if (SAFE_FOR_TEMPLATES) { + arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { + serializedHTML = stringReplace(serializedHTML, expr, ' '); + }); + } + return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; + }; + + /** + * Public method to set the configuration once + * setConfig + * + * @param {Object} cfg configuration object + */ + DOMPurify.setConfig = function () { + let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + _parseConfig(cfg); + SET_CONFIG = true; + }; + + /** + * Public method to remove the configuration + * clearConfig + * + */ + DOMPurify.clearConfig = function () { + CONFIG = null; + SET_CONFIG = false; + }; + + /** + * Public method to check if an attribute value is valid. + * Uses last set config, if any. Otherwise, uses config defaults. + * isValidAttribute + * + * @param {String} tag Tag name of containing element. + * @param {String} attr Attribute name. + * @param {String} value Attribute value. + * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false. + */ + DOMPurify.isValidAttribute = function (tag, attr, value) { + /* Initialize shared config vars if necessary. */ + if (!CONFIG) { + _parseConfig({}); + } + const lcTag = transformCaseFunc(tag); + const lcName = transformCaseFunc(attr); + return _isValidAttribute(lcTag, lcName, value); + }; + + /** + * AddHook + * Public method to add DOMPurify hooks + * + * @param {String} entryPoint entry point for the hook to add + * @param {Function} hookFunction function to execute + */ + DOMPurify.addHook = function (entryPoint, hookFunction) { + if (typeof hookFunction !== 'function') { + return; + } + hooks[entryPoint] = hooks[entryPoint] || []; + arrayPush$1(hooks[entryPoint], hookFunction); + }; + + /** + * RemoveHook + * Public method to remove a DOMPurify hook at a given entryPoint + * (pops it from the stack of hooks if more are present) + * + * @param {String} entryPoint entry point for the hook to remove + * @return {Function} removed(popped) hook + */ + DOMPurify.removeHook = function (entryPoint) { + if (hooks[entryPoint]) { + return arrayPop(hooks[entryPoint]); + } + }; + + /** + * RemoveHooks + * Public method to remove all DOMPurify hooks at a given entryPoint + * + * @param {String} entryPoint entry point for the hooks to remove + */ + DOMPurify.removeHooks = function (entryPoint) { + if (hooks[entryPoint]) { + hooks[entryPoint] = []; + } + }; + + /** + * RemoveAllHooks + * Public method to remove all DOMPurify hooks + */ + DOMPurify.removeAllHooks = function () { + hooks = {}; + }; + return DOMPurify; +} +var purify = createDOMPurify(); + +/* IMPORT */ +/* MAIN */ +const Channel = { + /* CLAMP */ + min: { + r: 0, + g: 0, + b: 0, + s: 0, + l: 0, + a: 0 + }, + max: { + r: 255, + g: 255, + b: 255, + h: 360, + s: 100, + l: 100, + a: 1 + }, + clamp: { + r: (r) => r >= 255 ? 255 : (r < 0 ? 0 : r), + g: (g) => g >= 255 ? 255 : (g < 0 ? 0 : g), + b: (b) => b >= 255 ? 255 : (b < 0 ? 0 : b), + h: (h) => h % 360, + s: (s) => s >= 100 ? 100 : (s < 0 ? 0 : s), + l: (l) => l >= 100 ? 100 : (l < 0 ? 0 : l), + a: (a) => a >= 1 ? 1 : (a < 0 ? 0 : a) + }, + /* CONVERSION */ + //SOURCE: https://planetcalc.com/7779 + toLinear: (c) => { + const n = c / 255; + return c > .03928 ? Math.pow(((n + .055) / 1.055), 2.4) : n / 12.92; + }, + //SOURCE: https://gist.github.com/mjackson/5311256 + hue2rgb: (p, q, t) => { + if (t < 0) + t += 1; + if (t > 1) + t -= 1; + if (t < 1 / 6) + return p + (q - p) * 6 * t; + if (t < 1 / 2) + return q; + if (t < 2 / 3) + return p + (q - p) * (2 / 3 - t) * 6; + return p; + }, + hsl2rgb: ({ h, s, l }, channel) => { + if (!s) + return l * 2.55; // Achromatic + h /= 360; + s /= 100; + l /= 100; + const q = (l < .5) ? l * (1 + s) : (l + s) - (l * s); + const p = 2 * l - q; + switch (channel) { + case 'r': return Channel.hue2rgb(p, q, h + 1 / 3) * 255; + case 'g': return Channel.hue2rgb(p, q, h) * 255; + case 'b': return Channel.hue2rgb(p, q, h - 1 / 3) * 255; + } + }, + rgb2hsl: ({ r, g, b }, channel) => { + r /= 255; + g /= 255; + b /= 255; + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + const l = (max + min) / 2; + if (channel === 'l') + return l * 100; + if (max === min) + return 0; // Achromatic + const d = max - min; + const s = (l > .5) ? d / (2 - max - min) : d / (max + min); + if (channel === 's') + return s * 100; + switch (max) { + case r: return ((g - b) / d + (g < b ? 6 : 0)) * 60; + case g: return ((b - r) / d + 2) * 60; + case b: return ((r - g) / d + 4) * 60; + default: return -1; //TSC: TypeScript is stupid and complains if there isn't this useless default statement + } + } +}; + +/* MAIN */ +const Lang = { + /* API */ + clamp: (number, lower, upper) => { + if (lower > upper) + return Math.min(lower, Math.max(upper, number)); + return Math.min(upper, Math.max(lower, number)); + }, + round: (number) => { + return Math.round(number * 10000000000) / 10000000000; + } +}; + +/* MAIN */ +const Unit = { + /* API */ + dec2hex: (dec) => { + const hex = Math.round(dec).toString(16); + return hex.length > 1 ? hex : `0${hex}`; + } +}; + +/* IMPORT */ +/* MAIN */ +const Utils = { + channel: Channel, + lang: Lang, + unit: Unit +}; + +/* IMPORT */ +/* MAIN */ +const DEC2HEX = {}; +for (let i = 0; i <= 255; i++) + DEC2HEX[i] = Utils.unit.dec2hex(i); // Populating dynamically, striking a balance between code size and performance +const TYPE = { + ALL: 0, + RGB: 1, + HSL: 2 +}; + +/* IMPORT */ +/* MAIN */ +let Type$2 = class Type { + constructor() { + /* VARIABLES */ + this.type = TYPE.ALL; + } + /* API */ + get() { + return this.type; + } + set(type) { + if (this.type && this.type !== type) + throw new Error('Cannot change both RGB and HSL channels at the same time'); + this.type = type; + } + reset() { + this.type = TYPE.ALL; + } + is(type) { + return this.type === type; + } +}; + +/* IMPORT */ +/* MAIN */ +class Channels { + /* CONSTRUCTOR */ + constructor(data, color) { + this.color = color; + this.changed = false; + this.data = data; //TSC + this.type = new Type$2(); + } + /* API */ + set(data, color) { + this.color = color; + this.changed = false; + this.data = data; //TSC + this.type.type = TYPE.ALL; + return this; + } + /* HELPERS */ + _ensureHSL() { + const data = this.data; + const { h, s, l } = data; + if (h === undefined) + data.h = Utils.channel.rgb2hsl(data, 'h'); + if (s === undefined) + data.s = Utils.channel.rgb2hsl(data, 's'); + if (l === undefined) + data.l = Utils.channel.rgb2hsl(data, 'l'); + } + _ensureRGB() { + const data = this.data; + const { r, g, b } = data; + if (r === undefined) + data.r = Utils.channel.hsl2rgb(data, 'r'); + if (g === undefined) + data.g = Utils.channel.hsl2rgb(data, 'g'); + if (b === undefined) + data.b = Utils.channel.hsl2rgb(data, 'b'); + } + /* GETTERS */ + get r() { + const data = this.data; + const r = data.r; + if (!this.type.is(TYPE.HSL) && r !== undefined) + return r; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'r'); + } + get g() { + const data = this.data; + const g = data.g; + if (!this.type.is(TYPE.HSL) && g !== undefined) + return g; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'g'); + } + get b() { + const data = this.data; + const b = data.b; + if (!this.type.is(TYPE.HSL) && b !== undefined) + return b; + this._ensureHSL(); + return Utils.channel.hsl2rgb(data, 'b'); + } + get h() { + const data = this.data; + const h = data.h; + if (!this.type.is(TYPE.RGB) && h !== undefined) + return h; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 'h'); + } + get s() { + const data = this.data; + const s = data.s; + if (!this.type.is(TYPE.RGB) && s !== undefined) + return s; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 's'); + } + get l() { + const data = this.data; + const l = data.l; + if (!this.type.is(TYPE.RGB) && l !== undefined) + return l; + this._ensureRGB(); + return Utils.channel.rgb2hsl(data, 'l'); + } + get a() { + return this.data.a; + } + /* SETTERS */ + set r(r) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.r = r; + } + set g(g) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.g = g; + } + set b(b) { + this.type.set(TYPE.RGB); + this.changed = true; + this.data.b = b; + } + set h(h) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.h = h; + } + set s(s) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.s = s; + } + set l(l) { + this.type.set(TYPE.HSL); + this.changed = true; + this.data.l = l; + } + set a(a) { + this.changed = true; + this.data.a = a; + } +} + +/* IMPORT */ +/* MAIN */ +const channels = new Channels({ r: 0, g: 0, b: 0, a: 0 }, 'transparent'); + +/* IMPORT */ +/* MAIN */ +const Hex = { + /* VARIABLES */ + re: /^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i, + /* API */ + parse: (color) => { + if (color.charCodeAt(0) !== 35) + return; // '#' + const match = color.match(Hex.re); + if (!match) + return; + const hex = match[1]; + const dec = parseInt(hex, 16); + const length = hex.length; + const hasAlpha = length % 4 === 0; + const isFullLength = length > 4; + const multiplier = isFullLength ? 1 : 17; + const bits = isFullLength ? 8 : 4; + const bitsOffset = hasAlpha ? 0 : -1; + const mask = isFullLength ? 255 : 15; + return channels.set({ + r: ((dec >> (bits * (bitsOffset + 3))) & mask) * multiplier, + g: ((dec >> (bits * (bitsOffset + 2))) & mask) * multiplier, + b: ((dec >> (bits * (bitsOffset + 1))) & mask) * multiplier, + a: hasAlpha ? (dec & mask) * multiplier / 255 : 1 + }, color); + }, + stringify: (channels) => { + const { r, g, b, a } = channels; + if (a < 1) { // #RRGGBBAA + return `#${DEC2HEX[Math.round(r)]}${DEC2HEX[Math.round(g)]}${DEC2HEX[Math.round(b)]}${DEC2HEX[Math.round(a * 255)]}`; + } + else { // #RRGGBB + return `#${DEC2HEX[Math.round(r)]}${DEC2HEX[Math.round(g)]}${DEC2HEX[Math.round(b)]}`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const HSL = { + /* VARIABLES */ + re: /^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i, + hueRe: /^(.+?)(deg|grad|rad|turn)$/i, + /* HELPERS */ + _hue2deg: (hue) => { + const match = hue.match(HSL.hueRe); + if (match) { + const [, number, unit] = match; + switch (unit) { + case 'grad': return Utils.channel.clamp.h(parseFloat(number) * .9); + case 'rad': return Utils.channel.clamp.h(parseFloat(number) * 180 / Math.PI); + case 'turn': return Utils.channel.clamp.h(parseFloat(number) * 360); + } + } + return Utils.channel.clamp.h(parseFloat(hue)); + }, + /* API */ + parse: (color) => { + const charCode = color.charCodeAt(0); + if (charCode !== 104 && charCode !== 72) + return; // 'h'/'H' + const match = color.match(HSL.re); + if (!match) + return; + const [, h, s, l, a, isAlphaPercentage] = match; + return channels.set({ + h: HSL._hue2deg(h), + s: Utils.channel.clamp.s(parseFloat(s)), + l: Utils.channel.clamp.l(parseFloat(l)), + a: a ? Utils.channel.clamp.a(isAlphaPercentage ? parseFloat(a) / 100 : parseFloat(a)) : 1 + }, color); + }, + stringify: (channels) => { + const { h, s, l, a } = channels; + if (a < 1) { // HSLA + return `hsla(${Utils.lang.round(h)}, ${Utils.lang.round(s)}%, ${Utils.lang.round(l)}%, ${a})`; + } + else { // HSL + return `hsl(${Utils.lang.round(h)}, ${Utils.lang.round(s)}%, ${Utils.lang.round(l)}%)`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const Keyword = { + /* VARIABLES */ + colors: { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#00ffff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000000', + blanchedalmond: '#ffebcd', + blue: '#0000ff', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyanaqua: '#00ffff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkgrey: '#a9a9a9', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#ff00ff', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', + greenyellow: '#adff2f', + grey: '#808080', + honeydew: '#f0fff0', + hotpink: '#ff69b4', + indianred: '#cd5c5c', + indigo: '#4b0082', + ivory: '#fffff0', + khaki: '#f0e68c', + lavender: '#e6e6fa', + lavenderblush: '#fff0f5', + lawngreen: '#7cfc00', + lemonchiffon: '#fffacd', + lightblue: '#add8e6', + lightcoral: '#f08080', + lightcyan: '#e0ffff', + lightgoldenrodyellow: '#fafad2', + lightgray: '#d3d3d3', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#00ff00', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + mediumseagreen: '#3cb371', + mediumslateblue: '#7b68ee', + mediumspringgreen: '#00fa9a', + mediumturquoise: '#48d1cc', + mediumvioletred: '#c71585', + midnightblue: '#191970', + mintcream: '#f5fffa', + mistyrose: '#ffe4e1', + moccasin: '#ffe4b5', + navajowhite: '#ffdead', + navy: '#000080', + oldlace: '#fdf5e6', + olive: '#808000', + olivedrab: '#6b8e23', + orange: '#ffa500', + orangered: '#ff4500', + orchid: '#da70d6', + palegoldenrod: '#eee8aa', + palegreen: '#98fb98', + paleturquoise: '#afeeee', + palevioletred: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#ff0000', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + transparent: '#00000000', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#ffffff', + whitesmoke: '#f5f5f5', + yellow: '#ffff00', + yellowgreen: '#9acd32' + }, + /* API */ + parse: (color) => { + color = color.toLowerCase(); + const hex = Keyword.colors[color]; + if (!hex) + return; + return Hex.parse(hex); + }, + stringify: (channels) => { + const hex = Hex.stringify(channels); + for (const name in Keyword.colors) { + if (Keyword.colors[name] === hex) + return name; + } + return; + } +}; + +/* IMPORT */ +/* MAIN */ +const RGB = { + /* VARIABLES */ + re: /^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i, + /* API */ + parse: (color) => { + const charCode = color.charCodeAt(0); + if (charCode !== 114 && charCode !== 82) + return; // 'r'/'R' + const match = color.match(RGB.re); + if (!match) + return; + const [, r, isRedPercentage, g, isGreenPercentage, b, isBluePercentage, a, isAlphaPercentage] = match; + return channels.set({ + r: Utils.channel.clamp.r(isRedPercentage ? parseFloat(r) * 2.55 : parseFloat(r)), + g: Utils.channel.clamp.g(isGreenPercentage ? parseFloat(g) * 2.55 : parseFloat(g)), + b: Utils.channel.clamp.b(isBluePercentage ? parseFloat(b) * 2.55 : parseFloat(b)), + a: a ? Utils.channel.clamp.a(isAlphaPercentage ? parseFloat(a) / 100 : parseFloat(a)) : 1 + }, color); + }, + stringify: (channels) => { + const { r, g, b, a } = channels; + if (a < 1) { // RGBA + return `rgba(${Utils.lang.round(r)}, ${Utils.lang.round(g)}, ${Utils.lang.round(b)}, ${Utils.lang.round(a)})`; + } + else { // RGB + return `rgb(${Utils.lang.round(r)}, ${Utils.lang.round(g)}, ${Utils.lang.round(b)})`; + } + } +}; + +/* IMPORT */ +/* MAIN */ +const Color = { + /* VARIABLES */ + format: { + keyword: Keyword, + hex: Hex, + rgb: RGB, + rgba: RGB, + hsl: HSL, + hsla: HSL + }, + /* API */ + parse: (color) => { + if (typeof color !== 'string') + return color; + const channels = Hex.parse(color) || RGB.parse(color) || HSL.parse(color) || Keyword.parse(color); // Color providers ordered with performance in mind + if (channels) + return channels; + throw new Error(`Unsupported color format: "${color}"`); + }, + stringify: (channels) => { + // SASS returns a keyword if possible, but we avoid doing that as it's slower and doesn't really add any value + if (!channels.changed && channels.color) + return channels.color; + if (channels.type.is(TYPE.HSL) || channels.data.r === undefined) { + return HSL.stringify(channels); + } + else if (channels.a < 1 || !Number.isInteger(channels.r) || !Number.isInteger(channels.g) || !Number.isInteger(channels.b)) { + return RGB.stringify(channels); + } + else { + return Hex.stringify(channels); + } + } +}; + +/* IMPORT */ +/* MAIN */ +const change = (color, channels) => { + const ch = Color.parse(color); + for (const c in channels) { + ch[c] = Utils.channel.clamp[c](channels[c]); + } + return Color.stringify(ch); +}; + +/* IMPORT */ +/* MAIN */ +const rgba$1 = (r, g, b = 0, a = 1) => { + if (typeof r !== 'number') + return change(r, { a: g }); + const channels$1 = channels.set({ + r: Utils.channel.clamp.r(r), + g: Utils.channel.clamp.g(g), + b: Utils.channel.clamp.b(b), + a: Utils.channel.clamp.a(a) + }); + return Color.stringify(channels$1); +}; + +/* IMPORT */ +/* MAIN */ +const channel = (color, channel) => { + return Utils.lang.round(Color.parse(color)[channel]); +}; + +/* IMPORT */ +/* MAIN */ +//SOURCE: https://planetcalc.com/7779 +const luminance = (color) => { + const { r, g, b } = Color.parse(color); + const luminance = .2126 * Utils.channel.toLinear(r) + .7152 * Utils.channel.toLinear(g) + .0722 * Utils.channel.toLinear(b); + return Utils.lang.round(luminance); +}; + +/* IMPORT */ +/* MAIN */ +const isLight = (color) => { + return luminance(color) >= .5; +}; + +/* IMPORT */ +/* MAIN */ +const isDark = (color) => { + return !isLight(color); +}; + +/* IMPORT */ +/* MAIN */ +const adjustChannel = (color, channel, amount) => { + const channels = Color.parse(color); + const amountCurrent = channels[channel]; + const amountNext = Utils.channel.clamp[channel](amountCurrent + amount); + if (amountCurrent !== amountNext) + channels[channel] = amountNext; + return Color.stringify(channels); +}; + +/* IMPORT */ +/* MAIN */ +const lighten = (color, amount) => { + return adjustChannel(color, 'l', amount); +}; + +/* IMPORT */ +/* MAIN */ +const darken = (color, amount) => { + return adjustChannel(color, 'l', -amount); +}; + +/* IMPORT */ +/* MAIN */ +const adjust$1 = (color, channels) => { + const ch = Color.parse(color); + const changes = {}; + for (const c in channels) { + if (!channels[c]) + continue; + changes[c] = ch[c] + channels[c]; + } + return change(color, changes); +}; + +/* IMPORT */ +/* MAIN */ +//SOURCE: https://github.com/sass/dart-sass/blob/7457d2e9e7e623d9844ffd037a070cf32d39c348/lib/src/functions/color.dart#L718-L756 +const mix = (color1, color2, weight = 50) => { + const { r: r1, g: g1, b: b1, a: a1 } = Color.parse(color1); + const { r: r2, g: g2, b: b2, a: a2 } = Color.parse(color2); + const weightScale = weight / 100; + const weightNormalized = (weightScale * 2) - 1; + const alphaDelta = a1 - a2; + const weight1combined = ((weightNormalized * alphaDelta) === -1) ? weightNormalized : (weightNormalized + alphaDelta) / (1 + weightNormalized * alphaDelta); + const weight1 = (weight1combined + 1) / 2; + const weight2 = 1 - weight1; + const r = (r1 * weight1) + (r2 * weight2); + const g = (g1 * weight1) + (g2 * weight2); + const b = (b1 * weight1) + (b2 * weight2); + const a = (a1 * weightScale) + (a2 * (1 - weightScale)); + return rgba$1(r, g, b, a); +}; + +/* IMPORT */ +/* MAIN */ +const invert = (color, weight = 100) => { + const inverse = Color.parse(color); + inverse.r = 255 - inverse.r; + inverse.g = 255 - inverse.g; + inverse.b = 255 - inverse.b; + return mix(inverse, color, weight); +}; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal$1 = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf$1 = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root$1 = freeGlobal$1 || freeSelf$1 || Function('return this')(); + +/** Built-in value references. */ +var Symbol$2 = root$1.Symbol; + +/** Used for built-in method references. */ +var objectProto$o = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$l = objectProto$o.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$3 = objectProto$o.toString; + +/** Built-in value references. */ +var symToStringTag$3 = Symbol$2 ? Symbol$2.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag$1(value) { + var isOwn = hasOwnProperty$l.call(value, symToStringTag$3), + tag = value[symToStringTag$3]; + + try { + value[symToStringTag$3] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString$3.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$3] = tag; + } else { + delete value[symToStringTag$3]; + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$n = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$2 = objectProto$n.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString$1(value) { + return nativeObjectToString$2.call(value); +} + +/** `Object#toString` result references. */ +var nullTag$1 = '[object Null]', + undefinedTag$1 = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag$2 = Symbol$2 ? Symbol$2.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag$1(value) { + if (value == null) { + return value === undefined ? undefinedTag$1 : nullTag$1; + } + return (symToStringTag$2 && symToStringTag$2 in Object(value)) + ? getRawTag$1(value) + : objectToString$1(value); +} + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject$2(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +/** `Object#toString` result references. */ +var asyncTag$1 = '[object AsyncFunction]', + funcTag$3 = '[object Function]', + genTag$2 = '[object GeneratorFunction]', + proxyTag$1 = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction$1(value) { + if (!isObject$2(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag$1(value); + return tag == funcTag$3 || tag == genTag$2 || tag == asyncTag$1 || tag == proxyTag$1; +} + +/** Used to detect overreaching core-js shims. */ +var coreJsData$1 = root$1['__core-js_shared__']; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey$1 = (function() { + var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked$1(func) { + return !!maskSrcKey$1 && (maskSrcKey$1 in func); +} + +/** Used for built-in method references. */ +var funcProto$4 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$4 = funcProto$4.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource$1(func) { + if (func != null) { + try { + return funcToString$4.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar$1 = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor$1 = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto$3 = Function.prototype, + objectProto$m = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$3 = funcProto$3.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$k = objectProto$m.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative$1 = RegExp('^' + + funcToString$3.call(hasOwnProperty$k).replace(reRegExpChar$1, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative$1(value) { + if (!isObject$2(value) || isMasked$1(value)) { + return false; + } + var pattern = isFunction$1(value) ? reIsNative$1 : reIsHostCtor$1; + return pattern.test(toSource$1(value)); +} + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue$2(object, key) { + return object == null ? undefined : object[key]; +} + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative$1(object, key) { + var value = getValue$2(object, key); + return baseIsNative$1(value) ? value : undefined; +} + +/* Built-in method references that are verified to be native. */ +var nativeCreate$1 = getNative$1(Object, 'create'); + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear$1() { + this.__data__ = nativeCreate$1 ? nativeCreate$1(null) : {}; + this.size = 0; +} + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete$1(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$4 = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$l = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$j = objectProto$l.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet$1(key) { + var data = this.__data__; + if (nativeCreate$1) { + var result = data[key]; + return result === HASH_UNDEFINED$4 ? undefined : result; + } + return hasOwnProperty$j.call(data, key) ? data[key] : undefined; +} + +/** Used for built-in method references. */ +var objectProto$k = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$i = objectProto$k.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas$1(key) { + var data = this.__data__; + return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty$i.call(data, key); +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$3 = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet$1(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (nativeCreate$1 && value === undefined) ? HASH_UNDEFINED$3 : value; + return this; +} + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash$1(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash$1.prototype.clear = hashClear$1; +Hash$1.prototype['delete'] = hashDelete$1; +Hash$1.prototype.get = hashGet$1; +Hash$1.prototype.has = hashHas$1; +Hash$1.prototype.set = hashSet$1; + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear$1() { + this.__data__ = []; + this.size = 0; +} + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq$1(value, other) { + return value === other || (value !== value && other !== other); +} + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf$1(array, key) { + var length = array.length; + while (length--) { + if (eq$1(array[length][0], key)) { + return length; + } + } + return -1; +} + +/** Used for built-in method references. */ +var arrayProto$1 = Array.prototype; + +/** Built-in value references. */ +var splice$2 = arrayProto$1.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete$1(key) { + var data = this.__data__, + index = assocIndexOf$1(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice$2.call(data, index, 1); + } + --this.size; + return true; +} + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet$1(key) { + var data = this.__data__, + index = assocIndexOf$1(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas$1(key) { + return assocIndexOf$1(this.__data__, key) > -1; +} + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet$1(key, value) { + var data = this.__data__, + index = assocIndexOf$1(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache$1(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache$1.prototype.clear = listCacheClear$1; +ListCache$1.prototype['delete'] = listCacheDelete$1; +ListCache$1.prototype.get = listCacheGet$1; +ListCache$1.prototype.has = listCacheHas$1; +ListCache$1.prototype.set = listCacheSet$1; + +/* Built-in method references that are verified to be native. */ +var Map$3 = getNative$1(root$1, 'Map'); + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear$1() { + this.size = 0; + this.__data__ = { + 'hash': new Hash$1, + 'map': new (Map$3 || ListCache$1), + 'string': new Hash$1 + }; +} + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable$1(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData$1(map, key) { + var data = map.__data__; + return isKeyable$1(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete$1(key) { + var result = getMapData$1(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet$1(key) { + return getMapData$1(this, key).get(key); +} + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas$1(key) { + return getMapData$1(this, key).has(key); +} + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet$1(key, value) { + var data = getMapData$1(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache$1(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache$1.prototype.clear = mapCacheClear$1; +MapCache$1.prototype['delete'] = mapCacheDelete$1; +MapCache$1.prototype.get = mapCacheGet$1; +MapCache$1.prototype.has = mapCacheHas$1; +MapCache$1.prototype.set = mapCacheSet$1; + +/** Error message constants. */ +var FUNC_ERROR_TEXT$2 = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize$2(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT$2); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize$2.Cache || MapCache$1); + return memoized; +} + +// Expose `MapCache`. +memoize$2.Cache = MapCache$1; + +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache$1; + this.size = 0; +} + +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; +} + +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} + +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); +} + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE$1 = 200; + +/** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache$1) { + var pairs = data.__data__; + if (!Map$3 || (pairs.length < LARGE_ARRAY_SIZE$1 - 1)) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache$1(pairs); + } + data.set(key, value); + this.size = data.size; + return this; +} + +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + var data = this.__data__ = new ListCache$1(entries); + this.size = data.size; +} + +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; + +var defineProperty$1 = (function() { + try { + var func = getNative$1(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue$1(object, key, value) { + if (key == '__proto__' && defineProperty$1) { + defineProperty$1(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +/** + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignMergeValue(object, key, value) { + if ((value !== undefined && !eq$1(object[key], value)) || + (value === undefined && !(key in object))) { + baseAssignValue$1(object, key, value); + } +} + +/** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} + +/** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); + +/** Detect free variable `exports`. */ +var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2; + +/** Built-in value references. */ +var Buffer$1 = moduleExports$2 ? root$1.Buffer : undefined, + allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined; + +/** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ +function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); + } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); + return result; +} + +/** Built-in value references. */ +var Uint8Array$1 = root$1.Uint8Array; + +/** + * Creates a clone of `arrayBuffer`. + * + * @private + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ +function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer)); + return result; +} + +/** + * Creates a clone of `typedArray`. + * + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. + */ +function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); +} + +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function copyArray$2(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} + +/** Built-in value references. */ +var objectCreate = Object.create; + +/** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. + */ +var baseCreate = (function() { + function object() {} + return function(proto) { + if (!isObject$2(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object; + object.prototype = undefined; + return result; + }; +}()); + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/** Built-in value references. */ +var getPrototype = overArg(Object.getPrototypeOf, Object); + +/** Used for built-in method references. */ +var objectProto$j = Object.prototype; + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$j; + + return value === proto; +} + +/** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneObject(object) { + return (typeof object.constructor == 'function' && !isPrototype(object)) + ? baseCreate(getPrototype(object)) + : {}; +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike$1(value) { + return value != null && typeof value == 'object'; +} + +/** `Object#toString` result references. */ +var argsTag$3 = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike$1(value) && baseGetTag$1(value) == argsTag$3; +} + +/** Used for built-in method references. */ +var objectProto$i = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$h = objectProto$i.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable$1 = objectProto$i.propertyIsEnumerable; + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike$1(value) && hasOwnProperty$h.call(value, 'callee') && + !propertyIsEnumerable$1.call(value, 'callee'); +}; + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray$1 = Array.isArray; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$2 = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$2; +} + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction$1(value); +} + +/** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false + */ +function isArrayLikeObject(value) { + return isObjectLike$1(value) && isArrayLike(value); +} + +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +/** Detect free variable `exports`. */ +var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + +/** Built-in value references. */ +var Buffer = moduleExports$1 ? root$1.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** `Object#toString` result references. */ +var objectTag$4 = '[object Object]'; + +/** Used for built-in method references. */ +var funcProto$2 = Function.prototype, + objectProto$h = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$2 = funcProto$2.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$g = objectProto$h.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString$2.call(Object); + +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * @static + * @memberOf _ + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + if (!isObjectLike$1(value) || baseGetTag$1(value) != objectTag$4) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty$g.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && + funcToString$2.call(Ctor) == objectCtorString; +} + +/** `Object#toString` result references. */ +var argsTag$2 = '[object Arguments]', + arrayTag$2 = '[object Array]', + boolTag$3 = '[object Boolean]', + dateTag$3 = '[object Date]', + errorTag$2 = '[object Error]', + funcTag$2 = '[object Function]', + mapTag$6 = '[object Map]', + numberTag$3 = '[object Number]', + objectTag$3 = '[object Object]', + regexpTag$3 = '[object RegExp]', + setTag$6 = '[object Set]', + stringTag$3 = '[object String]', + weakMapTag$2 = '[object WeakMap]'; + +var arrayBufferTag$3 = '[object ArrayBuffer]', + dataViewTag$4 = '[object DataView]', + float32Tag$2 = '[object Float32Array]', + float64Tag$2 = '[object Float64Array]', + int8Tag$2 = '[object Int8Array]', + int16Tag$2 = '[object Int16Array]', + int32Tag$2 = '[object Int32Array]', + uint8Tag$2 = '[object Uint8Array]', + uint8ClampedTag$2 = '[object Uint8ClampedArray]', + uint16Tag$2 = '[object Uint16Array]', + uint32Tag$2 = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = +typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = +typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = +typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = +typedArrayTags[uint32Tag$2] = true; +typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] = +typedArrayTags[arrayBufferTag$3] = typedArrayTags[boolTag$3] = +typedArrayTags[dataViewTag$4] = typedArrayTags[dateTag$3] = +typedArrayTags[errorTag$2] = typedArrayTags[funcTag$2] = +typedArrayTags[mapTag$6] = typedArrayTags[numberTag$3] = +typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$3] = +typedArrayTags[setTag$6] = typedArrayTags[stringTag$3] = +typedArrayTags[weakMapTag$2] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike$1(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag$1(value)]; +} + +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal$1.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule && freeModule.require && freeModule.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +/** + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + + if (key == '__proto__') { + return; + } + + return object[key]; +} + +/** Used for built-in method references. */ +var objectProto$g = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$f = objectProto$g.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue$1(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty$f.call(object, key) && eq$1(objValue, value)) || + (value === undefined && !(key in object))) { + baseAssignValue$1(object, key, value); + } +} + +/** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ +function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue$1(object, key, newValue); + } else { + assignValue$1(object, key, newValue); + } + } + return object; +} + +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint$1 = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex$1(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER$1 : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint$1.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** Used for built-in method references. */ +var objectProto$f = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$e = objectProto$f.hasOwnProperty; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray$1(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty$e.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex$1(key, length) + ))) { + result.push(key); + } + } + return result; +} + +/** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$e = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$d = objectProto$e.hasOwnProperty; + +/** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeysIn(object) { + if (!isObject$2(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; + + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty$d.call(object, key)))) { + result.push(key); + } + } + return result; +} + +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); +} + +/** + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } + */ +function toPlainObject(value) { + return copyObject(value, keysIn(value)); +} + +/** + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = safeGet(object, key), + srcValue = safeGet(source, key), + stacked = stack.get(srcValue); + + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer + ? customizer(objValue, srcValue, (key + ''), object, source, stack) + : undefined; + + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray$1(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray$1(objValue)) { + newValue = objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray$2(objValue); + } + else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } + else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } + else { + newValue = []; + } + } + else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject$2(objValue) || isFunction$1(objValue)) { + newValue = initCloneObject(srcValue); + } + } + else { + isCommon = false; + } + } + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); +} + +/** + * The base implementation of `_.merge` without support for multiple sources. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + */ +function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); + if (isObject$2(srcValue)) { + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } + else { + var newValue = customizer + ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) + : undefined; + + if (newValue === undefined) { + newValue = srcValue; + } + assignMergeValue(object, key, newValue); + } + }, keysIn); +} + +/** + * This method returns the first argument it receives. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'a': 1 }; + * + * console.log(_.identity(object) === object); + * // => true + */ +function identity$1(value) { + return value; +} + +/** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ +function apply$1(func, thisArg, args) { + switch (args.length) { + case 0: return func.call(thisArg); + case 1: return func.call(thisArg, args[0]); + case 2: return func.call(thisArg, args[0], args[1]); + case 3: return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$3 = Math.max; + +/** + * A specialized version of `baseRest` which transforms the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. + */ +function overRest(func, start, transform) { + start = nativeMax$3(start === undefined ? (func.length - 1) : start, 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax$3(args.length - start, 0), + array = Array(length); + + while (++index < length) { + array[index] = args[start + index]; + } + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply$1(func, this, otherArgs); + }; +} + +/** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ +function constant$2(value) { + return function() { + return value; + }; +} + +/** + * The base implementation of `setToString` without support for hot loop shorting. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var baseSetToString = !defineProperty$1 ? identity$1 : function(func, string) { + return defineProperty$1(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant$2(string), + 'writable': true + }); +}; + +/** Used to detect hot functions by number of calls within a span of milliseconds. */ +var HOT_COUNT = 800, + HOT_SPAN = 16; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeNow = Date.now; + +/** + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. + * + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. + */ +function shortOut(func) { + var count = 0, + lastCalled = 0; + + return function() { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; +} + +/** + * Sets the `toString` method of `func` to return `string`. + * + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var setToString = shortOut(baseSetToString); + +/** + * The base implementation of `_.rest` which doesn't validate or coerce arguments. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + */ +function baseRest(func, start) { + return setToString(overRest(func, start, identity$1), func + ''); +} + +/** + * Checks if the given arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. + */ +function isIterateeCall(value, index, object) { + if (!isObject$2(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex$1(index, object.length)) + : (type == 'string' && index in object) + ) { + return eq$1(object[index], value); + } + return false; +} + +/** + * Creates a function like `_.assign`. + * + * @private + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. + */ +function createAssigner(assigner) { + return baseRest(function(object, sources) { + var index = -1, + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; + + customizer = (assigner.length > 3 && typeof customizer == 'function') + ? (length--, customizer) + : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); + } + } + return object; + }); +} + +/** + * This method is like `_.assign` except that it recursively merges own and + * inherited enumerable string keyed properties of source objects into the + * destination object. Source properties that resolve to `undefined` are + * skipped if a destination value exists. Array and plain object properties + * are merged recursively. Other objects and value types are overridden by + * assignment. Source objects are applied from left to right. Subsequent + * sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 0.5.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @example + * + * var object = { + * 'a': [{ 'b': 2 }, { 'd': 4 }] + * }; + * + * var other = { + * 'a': [{ 'c': 3 }, { 'e': 5 }] + * }; + * + * _.merge(object, other); + * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + */ +var merge$2 = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); +}); + +var COMMENT = 'comm'; +var RULESET = 'rule'; +var DECLARATION = 'decl'; +var IMPORT = '@import'; +var KEYFRAMES = '@keyframes'; +var LAYER = '@layer'; + +/** + * @param {number} + * @return {number} + */ +var abs = Math.abs; + +/** + * @param {number} + * @return {string} + */ +var from = String.fromCharCode; + +/** + * @param {string} value + * @return {string} + */ +function trim (value) { + return value.trim() +} + +/** + * @param {string} value + * @param {(string|RegExp)} pattern + * @param {string} replacement + * @return {string} + */ +function replace (value, pattern, replacement) { + return value.replace(pattern, replacement) +} + +/** + * @param {string} value + * @param {string} search + * @param {number} position + * @return {number} + */ +function indexof (value, search, position) { + return value.indexOf(search, position) +} + +/** + * @param {string} value + * @param {number} index + * @return {number} + */ +function charat (value, index) { + return value.charCodeAt(index) | 0 +} + +/** + * @param {string} value + * @param {number} begin + * @param {number} end + * @return {string} + */ +function substr (value, begin, end) { + return value.slice(begin, end) +} + +/** + * @param {string} value + * @return {number} + */ +function strlen (value) { + return value.length +} + +/** + * @param {any[]} value + * @return {number} + */ +function sizeof (value) { + return value.length +} + +/** + * @param {any} value + * @param {any[]} array + * @return {any} + */ +function append (value, array) { + return array.push(value), value +} + +var line = 1; +var column = 1; +var length = 0; +var position$3 = 0; +var character = 0; +var characters = ''; + +/** + * @param {string} value + * @param {object | null} root + * @param {object | null} parent + * @param {string} type + * @param {string[] | string} props + * @param {object[] | string} children + * @param {object[]} siblings + * @param {number} length + */ +function node$1 (value, root, parent, type, props, children, length, siblings) { + return {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings} +} + +/** + * @return {number} + */ +function char () { + return character +} + +/** + * @return {number} + */ +function prev () { + character = position$3 > 0 ? charat(characters, --position$3) : 0; + + if (column--, character === 10) + column = 1, line--; + + return character +} + +/** + * @return {number} + */ +function next$1 () { + character = position$3 < length ? charat(characters, position$3++) : 0; + + if (column++, character === 10) + column = 1, line++; + + return character +} + +/** + * @return {number} + */ +function peek () { + return charat(characters, position$3) +} + +/** + * @return {number} + */ +function caret () { + return position$3 +} + +/** + * @param {number} begin + * @param {number} end + * @return {string} + */ +function slice$1 (begin, end) { + return substr(characters, begin, end) +} + +/** + * @param {number} type + * @return {number} + */ +function token (type) { + switch (type) { + // \0 \t \n \r \s whitespace token + case 0: case 9: case 10: case 13: case 32: + return 5 + // ! + , / > @ ~ isolate token + case 33: case 43: case 44: case 47: case 62: case 64: case 126: + // ; { } breakpoint token + case 59: case 123: case 125: + return 4 + // : accompanied token + case 58: + return 3 + // " ' ( [ opening delimit token + case 34: case 39: case 40: case 91: + return 2 + // ) ] closing delimit token + case 41: case 93: + return 1 + } + + return 0 +} + +/** + * @param {string} value + * @return {any[]} + */ +function alloc (value) { + return line = column = 1, length = strlen(characters = value), position$3 = 0, [] +} + +/** + * @param {any} value + * @return {any} + */ +function dealloc (value) { + return characters = '', value +} + +/** + * @param {number} type + * @return {string} + */ +function delimit (type) { + return trim(slice$1(position$3 - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type))) +} + +/** + * @param {number} type + * @return {string} + */ +function whitespace (type) { + while (character = peek()) + if (character < 33) + next$1(); + else + break + + return token(type) > 2 || token(character) > 3 ? '' : ' ' +} + +/** + * @param {number} index + * @param {number} count + * @return {string} + */ +function escaping (index, count) { + while (--count && next$1()) + // not 0-9 A-F a-f + if (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97)) + break + + return slice$1(index, caret() + (count < 6 && peek() == 32 && next$1() == 32)) +} + +/** + * @param {number} type + * @return {number} + */ +function delimiter (type) { + while (next$1()) + switch (character) { + // ] ) " ' + case type: + return position$3 + // " ' + case 34: case 39: + if (type !== 34 && type !== 39) + delimiter(character); + break + // ( + case 40: + if (type === 41) + delimiter(type); + break + // \ + case 92: + next$1(); + break + } + + return position$3 +} + +/** + * @param {number} type + * @param {number} index + * @return {number} + */ +function commenter (type, index) { + while (next$1()) + // // + if (type + character === 47 + 10) + break + // /* + else if (type + character === 42 + 42 && peek() === 47) + break + + return '/*' + slice$1(index, position$3 - 1) + '*' + from(type === 47 ? type : next$1()) +} + +/** + * @param {number} index + * @return {string} + */ +function identifier (index) { + while (!token(peek())) + next$1(); + + return slice$1(index, position$3) +} + +/** + * @param {string} value + * @return {object[]} + */ +function compile (value) { + return dealloc(parse$5('', null, null, null, [''], value = alloc(value), 0, [0], value)) +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {string[]} rule + * @param {string[]} rules + * @param {string[]} rulesets + * @param {number[]} pseudo + * @param {number[]} points + * @param {string[]} declarations + * @return {object} + */ +function parse$5 (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) { + var index = 0; + var offset = 0; + var length = pseudo; + var atrule = 0; + var property = 0; + var previous = 0; + var variable = 1; + var scanning = 1; + var ampersand = 1; + var character = 0; + var type = ''; + var props = rules; + var children = rulesets; + var reference = rule; + var characters = type; + + while (scanning) + switch (previous = character, character = next$1()) { + // ( + case 40: + if (previous != 108 && charat(characters, length - 1) == 58) { + if (indexof(characters += replace(delimit(character), '&', '&\f'), '&\f', abs(index ? points[index - 1] : 0)) != -1) + ampersand = -1; + break + } + // " ' [ + case 34: case 39: case 91: + characters += delimit(character); + break + // \t \n \r \s + case 9: case 10: case 13: case 32: + characters += whitespace(previous); + break + // \ + case 92: + characters += escaping(caret() - 1, 7); + continue + // / + case 47: + switch (peek()) { + case 42: case 47: + append(comment(commenter(next$1(), caret()), root, parent, declarations), declarations); + break + default: + characters += '/'; + } + break + // { + case 123 * variable: + points[index++] = strlen(characters) * ampersand; + // } ; \0 + case 125 * variable: case 59: case 0: + switch (character) { + // \0 } + case 0: case 125: scanning = 0; + // ; + case 59 + offset: if (ampersand == -1) characters = replace(characters, /\f/g, ''); + if (property > 0 && (strlen(characters) - length)) + append(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations); + break + // @ ; + case 59: characters += ';'; + // { rule/at-rule + default: + append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets); + + if (character === 123) + if (offset === 0) + parse$5(characters, root, reference, reference, props, rulesets, length, points, children); + else + switch (atrule === 99 && charat(characters, 3) === 110 ? 100 : atrule) { + // d l m s + case 100: case 108: case 109: case 115: + parse$5(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children); + break + default: + parse$5(characters, reference, reference, reference, [''], children, 0, points, children); + } + } + + index = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo; + break + // : + case 58: + length = 1 + strlen(characters), property = previous; + default: + if (variable < 1) + if (character == 123) + --variable; + else if (character == 125 && variable++ == 0 && prev() == 125) + continue + + switch (characters += from(character), character * variable) { + // & + case 38: + ampersand = offset > 0 ? 1 : (characters += '\f', -1); + break + // , + case 44: + points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1; + break + // @ + case 64: + // - + if (peek() === 45) + characters += delimit(next$1()); + + atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++; + break + // - + case 45: + if (previous === 45 && strlen(characters) == 2) + variable = 0; + } + } + + return rulesets +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {number} index + * @param {number} offset + * @param {string[]} rules + * @param {number[]} points + * @param {string} type + * @param {string[]} props + * @param {string[]} children + * @param {number} length + * @param {object[]} siblings + * @return {object} + */ +function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) { + var post = offset - 1; + var rule = offset === 0 ? rules : ['']; + var size = sizeof(rule); + + for (var i = 0, j = 0, k = 0; i < index; ++i) + for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x) + if (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\f/g, rule[x]))) + props[k++] = z; + + return node$1(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings) +} + +/** + * @param {number} value + * @param {object} root + * @param {object?} parent + * @param {object[]} siblings + * @return {object} + */ +function comment (value, root, parent, siblings) { + return node$1(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings) +} + +/** + * @param {string} value + * @param {object} root + * @param {object?} parent + * @param {number} length + * @param {object[]} siblings + * @return {object} + */ +function declaration (value, root, parent, length, siblings) { + return node$1(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings) +} + +/** + * @param {object[]} children + * @param {function} callback + * @return {string} + */ +function serialize (children, callback) { + var output = ''; + + for (var i = 0; i < children.length; i++) + output += callback(children[i], i, children, callback) || ''; + + return output +} + +/** + * @param {object} element + * @param {number} index + * @param {object[]} children + * @param {function} callback + * @return {string} + */ +function stringify (element, index, children, callback) { + switch (element.type) { + case LAYER: if (element.children.length) break + case IMPORT: case DECLARATION: return element.return = element.return || element.value + case COMMENT: return '' + case KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}' + case RULESET: if (!strlen(element.value = element.props.join(','))) return '' + } + + return strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : '' +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); + +/** Used for built-in method references. */ +var objectProto$d = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$c = objectProto$d.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$c.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/* Built-in method references that are verified to be native. */ +var DataView$1 = getNative$1(root$1, 'DataView'); + +/* Built-in method references that are verified to be native. */ +var Promise$2 = getNative$1(root$1, 'Promise'); + +/* Built-in method references that are verified to be native. */ +var Set$2 = getNative$1(root$1, 'Set'); + +/* Built-in method references that are verified to be native. */ +var WeakMap = getNative$1(root$1, 'WeakMap'); + +/** `Object#toString` result references. */ +var mapTag$5 = '[object Map]', + objectTag$2 = '[object Object]', + promiseTag = '[object Promise]', + setTag$5 = '[object Set]', + weakMapTag$1 = '[object WeakMap]'; + +var dataViewTag$3 = '[object DataView]'; + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource$1(DataView$1), + mapCtorString = toSource$1(Map$3), + promiseCtorString = toSource$1(Promise$2), + setCtorString = toSource$1(Set$2), + weakMapCtorString = toSource$1(WeakMap); + +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag$1; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$3) || + (Map$3 && getTag(new Map$3) != mapTag$5) || + (Promise$2 && getTag(Promise$2.resolve()) != promiseTag) || + (Set$2 && getTag(new Set$2) != setTag$5) || + (WeakMap && getTag(new WeakMap) != weakMapTag$1)) { + getTag = function(value) { + var result = baseGetTag$1(value), + Ctor = result == objectTag$2 ? value.constructor : undefined, + ctorString = Ctor ? toSource$1(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag$3; + case mapCtorString: return mapTag$5; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag$5; + case weakMapCtorString: return weakMapTag$1; + } + } + return result; + }; +} + +/** `Object#toString` result references. */ +var mapTag$4 = '[object Map]', + setTag$4 = '[object Set]'; + +/** Used for built-in method references. */ +var objectProto$c = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$b = objectProto$c.hasOwnProperty; + +/** + * Checks if `value` is an empty object, collection, map, or set. + * + * Objects are considered empty if they have no own enumerable string keyed + * properties. + * + * Array-like values such as `arguments` objects, arrays, buffers, strings, or + * jQuery-like collections are considered empty if they have a `length` of `0`. + * Similarly, maps and sets are considered empty if they have a `size` of `0`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ +function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && + (isArray$1(value) || typeof value == 'string' || typeof value.splice == 'function' || + isBuffer(value) || isTypedArray(value) || isArguments(value))) { + return !value.length; + } + var tag = getTag(value); + if (tag == mapTag$4 || tag == setTag$4) { + return !value.size; + } + if (isPrototype(value)) { + return !baseKeys(value).length; + } + for (var key in value) { + if (hasOwnProperty$b.call(value, key)) { + return false; + } + } + return true; +} + +const LEVELS = { + trace: 0, + debug: 1, + info: 2, + warn: 3, + error: 4, + fatal: 5 +}; +const log$1 = { + trace: (..._args) => { + }, + debug: (..._args) => { + }, + info: (..._args) => { + }, + warn: (..._args) => { + }, + error: (..._args) => { + }, + fatal: (..._args) => { + } +}; +const setLogLevel$1 = function(level = "fatal") { + let numericLevel = LEVELS.fatal; + if (typeof level === "string") { + level = level.toLowerCase(); + if (level in LEVELS) { + numericLevel = LEVELS[level]; + } + } else if (typeof level === "number") { + numericLevel = level; + } + log$1.trace = () => { + }; + log$1.debug = () => { + }; + log$1.info = () => { + }; + log$1.warn = () => { + }; + log$1.error = () => { + }; + log$1.fatal = () => { + }; + if (numericLevel <= LEVELS.fatal) { + log$1.fatal = console.error ? console.error.bind(console, format("FATAL"), "color: orange") : console.log.bind(console, "\x1B[35m", format("FATAL")); + } + if (numericLevel <= LEVELS.error) { + log$1.error = console.error ? console.error.bind(console, format("ERROR"), "color: orange") : console.log.bind(console, "\x1B[31m", format("ERROR")); + } + if (numericLevel <= LEVELS.warn) { + log$1.warn = console.warn ? console.warn.bind(console, format("WARN"), "color: orange") : console.log.bind(console, `\x1B[33m`, format("WARN")); + } + if (numericLevel <= LEVELS.info) { + log$1.info = console.info ? console.info.bind(console, format("INFO"), "color: lightblue") : console.log.bind(console, "\x1B[34m", format("INFO")); + } + if (numericLevel <= LEVELS.debug) { + log$1.debug = console.debug ? console.debug.bind(console, format("DEBUG"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format("DEBUG")); + } + if (numericLevel <= LEVELS.trace) { + log$1.trace = console.debug ? console.debug.bind(console, format("TRACE"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format("TRACE")); + } +}; +const format = (level) => { + const time = dayjs().format("ss.SSS"); + return `%c${time} : ${level} : `; +}; +const lineBreakRegex = //gi; +const getRows = (s) => { + if (!s) { + return [""]; + } + const str2 = breakToPlaceholder(s).replace(/\\n/g, "#br#"); + return str2.split("#br#"); +}; +const setupDompurifyHooksIfNotSetup = (() => { + let setup = false; + return () => { + if (!setup) { + setupDompurifyHooks(); + setup = true; + } + }; +})(); +function setupDompurifyHooks() { + const TEMPORARY_ATTRIBUTE = "data-temp-href-target"; + purify.addHook("beforeSanitizeAttributes", (node) => { + if (node.tagName === "A" && node.hasAttribute("target")) { + node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute("target") || ""); + } + }); + purify.addHook("afterSanitizeAttributes", (node) => { + if (node.tagName === "A" && node.hasAttribute(TEMPORARY_ATTRIBUTE)) { + node.setAttribute("target", node.getAttribute(TEMPORARY_ATTRIBUTE) || ""); + node.removeAttribute(TEMPORARY_ATTRIBUTE); + if (node.getAttribute("target") === "_blank") { + node.setAttribute("rel", "noopener"); + } + } + }); +} +const removeScript = (txt) => { + setupDompurifyHooksIfNotSetup(); + const sanitizedText = purify.sanitize(txt); + return sanitizedText; +}; +const sanitizeMore = (text, config2) => { + var _a; + if (((_a = config2.flowchart) == null ? void 0 : _a.htmlLabels) !== false) { + const level = config2.securityLevel; + if (level === "antiscript" || level === "strict") { + text = removeScript(text); + } else if (level !== "loose") { + text = breakToPlaceholder(text); + text = text.replace(//g, ">"); + text = text.replace(/=/g, "="); + text = placeholderToBreak(text); + } + } + return text; +}; +const sanitizeText$2$1 = (text, config2) => { + if (!text) { + return text; + } + if (config2.dompurifyConfig) { + text = purify.sanitize(sanitizeMore(text, config2), config2.dompurifyConfig).toString(); + } else { + text = purify.sanitize(sanitizeMore(text, config2), { + FORBID_TAGS: ["style"] + }).toString(); + } + return text; +}; +const sanitizeTextOrArray = (a, config2) => { + if (typeof a === "string") { + return sanitizeText$2$1(a, config2); + } + return a.flat().map((x) => sanitizeText$2$1(x, config2)); +}; +const hasBreaks = (text) => { + return lineBreakRegex.test(text); +}; +const splitBreaks = (text) => { + return text.split(lineBreakRegex); +}; +const placeholderToBreak = (s) => { + return s.replace(/#br#/g, "
    "); +}; +const breakToPlaceholder = (s) => { + return s.replace(lineBreakRegex, "#br#"); +}; +const getUrl = (useAbsolute) => { + let url = ""; + if (useAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replaceAll(/\(/g, "\\("); + url = url.replaceAll(/\)/g, "\\)"); + } + return url; +}; +const evaluate = (val) => val === false || ["false", "null", "0"].includes(String(val).trim().toLowerCase()) ? false : true; +const getMax = function(...values) { + const newValues = values.filter((value) => { + return !isNaN(value); + }); + return Math.max(...newValues); +}; +const getMin = function(...values) { + const newValues = values.filter((value) => { + return !isNaN(value); + }); + return Math.min(...newValues); +}; +const parseGenericTypes = function(input) { + const inputSets = input.split(/(,)/); + const output = []; + for (let i = 0; i < inputSets.length; i++) { + let thisSet = inputSets[i]; + if (thisSet === "," && i > 0 && i + 1 < inputSets.length) { + const previousSet = inputSets[i - 1]; + const nextSet = inputSets[i + 1]; + if (shouldCombineSets(previousSet, nextSet)) { + thisSet = previousSet + "," + nextSet; + i++; + output.pop(); + } + } + output.push(processSet(thisSet)); + } + return output.join(""); +}; +const countOccurrence = (string, substring) => { + return Math.max(0, string.split(substring).length - 1); +}; +const shouldCombineSets = (previousSet, nextSet) => { + const prevCount = countOccurrence(previousSet, "~"); + const nextCount = countOccurrence(nextSet, "~"); + return prevCount === 1 && nextCount === 1; +}; +const processSet = (input) => { + const tildeCount = countOccurrence(input, "~"); + let hasStartingTilde = false; + if (tildeCount <= 1) { + return input; + } + if (tildeCount % 2 !== 0 && input.startsWith("~")) { + input = input.substring(1); + hasStartingTilde = true; + } + const chars = [...input]; + let first = chars.indexOf("~"); + let last = chars.lastIndexOf("~"); + while (first !== -1 && last !== -1 && first !== last) { + chars[first] = "<"; + chars[last] = ">"; + first = chars.indexOf("~"); + last = chars.lastIndexOf("~"); + } + if (hasStartingTilde) { + chars.unshift("~"); + } + return chars.join(""); +}; +const isMathMLSupported = () => window.MathMLElement !== void 0; +const katexRegex = /\$\$(.*)\$\$/g; +const hasKatex = (text) => { + var _a; + return (((_a = text.match(katexRegex)) == null ? void 0 : _a.length) ?? 0) > 0; +}; +const calculateMathMLDimensions = async (text, config2) => { + text = await renderKatex(text, config2); + const divElem = document.createElement("div"); + divElem.innerHTML = text; + divElem.id = "katex-temp"; + divElem.style.visibility = "hidden"; + divElem.style.position = "absolute"; + divElem.style.top = "0"; + const body = document.querySelector("body"); + body == null ? void 0 : body.insertAdjacentElement("beforeend", divElem); + const dim = { width: divElem.clientWidth, height: divElem.clientHeight }; + divElem.remove(); + return dim; +}; +const renderKatex = async (text, config2) => { + if (!hasKatex(text)) { + return text; + } + if (!isMathMLSupported() && !config2.legacyMathML) { + return text.replace(katexRegex, "MathML is unsupported in this environment."); + } + const { default: katex } = await Promise.resolve().then(function () { return katex$1; }); + return text.split(lineBreakRegex).map( + (line) => hasKatex(line) ? ` +
    + ${line} +
    + ` : `
    ${line}
    ` + ).join("").replace( + katexRegex, + (_, c) => katex.renderToString(c, { + throwOnError: true, + displayMode: true, + output: isMathMLSupported() ? "mathml" : "htmlAndMathml" + }).replace(/\n/g, " ").replace(//g, "") + ); +}; +const common$1 = { + getRows, + sanitizeText: sanitizeText$2$1, + sanitizeTextOrArray, + hasBreaks, + splitBreaks, + lineBreakRegex, + removeScript, + getUrl, + evaluate, + getMax, + getMin +}; +const mkBorder = (col, darkMode) => darkMode ? adjust$1(col, { s: -40, l: 10 }) : adjust$1(col, { s: -40, l: -10 }); +const oldAttributeBackgroundColorOdd = "#ffffff"; +const oldAttributeBackgroundColorEven = "#f2f2f2"; +let Theme$4 = class Theme { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#fff4dd"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "#333"; + this.THEME_COLOR_LIMIT = 12; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.primaryTextColor = this.primaryTextColor || (this.darkMode ? "#eee" : "#333"); + this.secondaryColor = this.secondaryColor || adjust$1(this.primaryColor, { h: -120 }); + this.tertiaryColor = this.tertiaryColor || adjust$1(this.primaryColor, { h: 180, l: 5 }); + this.primaryBorderColor = this.primaryBorderColor || mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = this.secondaryBorderColor || mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = this.tertiaryBorderColor || mkBorder(this.tertiaryColor, this.darkMode); + this.noteBorderColor = this.noteBorderColor || mkBorder(this.noteBkgColor, this.darkMode); + this.noteBkgColor = this.noteBkgColor || "#fff5ad"; + this.noteTextColor = this.noteTextColor || "#333"; + this.secondaryTextColor = this.secondaryTextColor || invert(this.secondaryColor); + this.tertiaryTextColor = this.tertiaryTextColor || invert(this.tertiaryColor); + this.lineColor = this.lineColor || invert(this.background); + this.arrowheadColor = this.arrowheadColor || invert(this.background); + this.textColor = this.textColor || this.primaryTextColor; + this.border2 = this.border2 || this.tertiaryBorderColor; + this.nodeBkg = this.nodeBkg || this.primaryColor; + this.mainBkg = this.mainBkg || this.primaryColor; + this.nodeBorder = this.nodeBorder || this.primaryBorderColor; + this.clusterBkg = this.clusterBkg || this.tertiaryColor; + this.clusterBorder = this.clusterBorder || this.tertiaryBorderColor; + this.defaultLinkColor = this.defaultLinkColor || this.lineColor; + this.titleColor = this.titleColor || this.tertiaryTextColor; + this.edgeLabelBackground = this.edgeLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.nodeTextColor = this.nodeTextColor || this.primaryTextColor; + this.actorBorder = this.actorBorder || this.primaryBorderColor; + this.actorBkg = this.actorBkg || this.mainBkg; + this.actorTextColor = this.actorTextColor || this.primaryTextColor; + this.actorLineColor = this.actorLineColor || "grey"; + this.labelBoxBkgColor = this.labelBoxBkgColor || this.actorBkg; + this.signalColor = this.signalColor || this.textColor; + this.signalTextColor = this.signalTextColor || this.textColor; + this.labelBoxBorderColor = this.labelBoxBorderColor || this.actorBorder; + this.labelTextColor = this.labelTextColor || this.actorTextColor; + this.loopTextColor = this.loopTextColor || this.actorTextColor; + this.activationBorderColor = this.activationBorderColor || darken(this.secondaryColor, 10); + this.activationBkgColor = this.activationBkgColor || this.secondaryColor; + this.sequenceNumberColor = this.sequenceNumberColor || invert(this.lineColor); + this.sectionBkgColor = this.sectionBkgColor || this.tertiaryColor; + this.altSectionBkgColor = this.altSectionBkgColor || "white"; + this.sectionBkgColor = this.sectionBkgColor || this.secondaryColor; + this.sectionBkgColor2 = this.sectionBkgColor2 || this.primaryColor; + this.excludeBkgColor = this.excludeBkgColor || "#eeeeee"; + this.taskBorderColor = this.taskBorderColor || this.primaryBorderColor; + this.taskBkgColor = this.taskBkgColor || this.primaryColor; + this.activeTaskBorderColor = this.activeTaskBorderColor || this.primaryColor; + this.activeTaskBkgColor = this.activeTaskBkgColor || lighten(this.primaryColor, 23); + this.gridColor = this.gridColor || "lightgrey"; + this.doneTaskBkgColor = this.doneTaskBkgColor || "lightgrey"; + this.doneTaskBorderColor = this.doneTaskBorderColor || "grey"; + this.critBorderColor = this.critBorderColor || "#ff8888"; + this.critBkgColor = this.critBkgColor || "red"; + this.todayLineColor = this.todayLineColor || "red"; + this.taskTextColor = this.taskTextColor || this.textColor; + this.taskTextOutsideColor = this.taskTextOutsideColor || this.textColor; + this.taskTextLightColor = this.taskTextLightColor || this.textColor; + this.taskTextColor = this.taskTextColor || this.primaryTextColor; + this.taskTextDarkColor = this.taskTextDarkColor || this.textColor; + this.taskTextClickableColor = this.taskTextClickableColor || "#003163"; + this.personBorder = this.personBorder || this.primaryBorderColor; + this.personBkg = this.personBkg || this.mainBkg; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || this.tertiaryColor; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.nodeBorder; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.specialStateColor = this.lineColor; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust$1(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust$1(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust$1(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust$1(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust$1(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust$1(this.primaryColor, { h: 210, l: 150 }); + this.cScale9 = this.cScale9 || adjust$1(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust$1(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust$1(this.primaryColor, { h: 330 }); + if (this.darkMode) { + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 75); + } + } else { + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 25); + } + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + if (this.darkMode) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } else { + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 10); + } + } + this.scaleLabelColor = this.scaleLabelColor || this.labelTextColor; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + const multiplier = this.darkMode ? -4 : -1; + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust$1(this.mainBkg, { h: 180, s: -15, l: multiplier * (5 + i * 3) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust$1(this.mainBkg, { h: 180, s: -15, l: multiplier * (8 + i * 3) }); + } + this.classText = this.classText || this.textColor; + this.fillType0 = this.fillType0 || this.primaryColor; + this.fillType1 = this.fillType1 || this.secondaryColor; + this.fillType2 = this.fillType2 || adjust$1(this.primaryColor, { h: 64 }); + this.fillType3 = this.fillType3 || adjust$1(this.secondaryColor, { h: 64 }); + this.fillType4 = this.fillType4 || adjust$1(this.primaryColor, { h: -64 }); + this.fillType5 = this.fillType5 || adjust$1(this.secondaryColor, { h: -64 }); + this.fillType6 = this.fillType6 || adjust$1(this.primaryColor, { h: 128 }); + this.fillType7 = this.fillType7 || adjust$1(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || this.tertiaryColor; + this.pie4 = this.pie4 || adjust$1(this.primaryColor, { l: -10 }); + this.pie5 = this.pie5 || adjust$1(this.secondaryColor, { l: -10 }); + this.pie6 = this.pie6 || adjust$1(this.tertiaryColor, { l: -10 }); + this.pie7 = this.pie7 || adjust$1(this.primaryColor, { h: 60, l: -10 }); + this.pie8 = this.pie8 || adjust$1(this.primaryColor, { h: -60, l: -10 }); + this.pie9 = this.pie9 || adjust$1(this.primaryColor, { h: 120, l: 0 }); + this.pie10 = this.pie10 || adjust$1(this.primaryColor, { h: 60, l: -20 }); + this.pie11 = this.pie11 || adjust$1(this.primaryColor, { h: -60, l: -20 }); + this.pie12 = this.pie12 || adjust$1(this.primaryColor, { h: 120, l: -10 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust$1(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust$1(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust$1(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust$1(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust$1(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust$1(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#FFF4DD,#FFD8B1,#FFA07A,#ECEFF1,#D6DBDF,#C3E0A8,#FFB6A4,#FFD74D,#738FA7,#FFFFF0" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust$1(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust$1(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust$1(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust$1(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust$1(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.branchLabelColor = this.branchLabelColor || (this.darkMode ? "black" : this.labelTextColor); + this.gitBranchLabel0 = this.gitBranchLabel0 || this.branchLabelColor; + this.gitBranchLabel1 = this.gitBranchLabel1 || this.branchLabelColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.branchLabelColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || this.branchLabelColor; + this.gitBranchLabel4 = this.gitBranchLabel4 || this.branchLabelColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.branchLabelColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.branchLabelColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.branchLabelColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$4 = (userOverrides) => { + const theme2 = new Theme$4(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$3 = class Theme2 { + constructor() { + this.background = "#333"; + this.primaryColor = "#1f2020"; + this.secondaryColor = lighten(this.primaryColor, 16); + this.tertiaryColor = adjust$1(this.primaryColor, { h: -160 }); + this.primaryBorderColor = invert(this.background); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.mainBkg = "#1f2020"; + this.secondBkg = "calculated"; + this.mainContrastColor = "lightgrey"; + this.darkTextColor = lighten(invert("#323D47"), 10); + this.lineColor = "calculated"; + this.border1 = "#81B1DB"; + this.border2 = rgba$1(255, 255, 255, 0.25); + this.arrowheadColor = "calculated"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.labelBackground = "#181818"; + this.textColor = "#ccc"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "#F9FFFE"; + this.edgeLabelBackground = "calculated"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "calculated"; + this.actorLineColor = "calculated"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "calculated"; + this.activationBkgColor = "calculated"; + this.sequenceNumberColor = "black"; + this.sectionBkgColor = darken("#EAE8D9", 30); + this.altSectionBkgColor = "calculated"; + this.sectionBkgColor2 = "#EAE8D9"; + this.excludeBkgColor = darken(this.sectionBkgColor, 10); + this.taskBorderColor = rgba$1(255, 255, 255, 70); + this.taskBkgColor = "calculated"; + this.taskTextColor = "calculated"; + this.taskTextLightColor = "calculated"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = rgba$1(255, 255, 255, 50); + this.activeTaskBkgColor = "#81B1DB"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#E83737"; + this.critBkgColor = "#E83737"; + this.taskTextDarkColor = "calculated"; + this.todayLineColor = "#DB5757"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "calculated"; + this.errorBkgColor = "#a44141"; + this.errorTextColor = "#ddd"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.secondBkg = lighten(this.mainBkg, 16); + this.lineColor = this.mainContrastColor; + this.arrowheadColor = this.mainContrastColor; + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.edgeLabelBackground = lighten(this.labelBackground, 25); + this.actorBorder = this.border1; + this.actorBkg = this.mainBkg; + this.actorTextColor = this.mainContrastColor; + this.actorLineColor = this.mainContrastColor; + this.signalColor = this.mainContrastColor; + this.signalTextColor = this.mainContrastColor; + this.labelBoxBkgColor = this.actorBkg; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.mainContrastColor; + this.loopTextColor = this.mainContrastColor; + this.noteBorderColor = this.secondaryBorderColor; + this.noteBkgColor = this.secondBkg; + this.noteTextColor = this.secondaryTextColor; + this.activationBorderColor = this.border1; + this.activationBkgColor = this.secondBkg; + this.altSectionBkgColor = this.background; + this.taskBkgColor = lighten(this.mainBkg, 23); + this.taskTextColor = this.darkTextColor; + this.taskTextLightColor = this.mainContrastColor; + this.taskTextOutsideColor = this.taskTextLightColor; + this.gridColor = this.mainContrastColor; + this.doneTaskBkgColor = this.mainContrastColor; + this.taskTextDarkColor = this.darkTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#555"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = "#f4f4f4"; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust$1(this.primaryColor, { h: 64 }); + this.fillType3 = adjust$1(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust$1(this.primaryColor, { h: -64 }); + this.fillType5 = adjust$1(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust$1(this.primaryColor, { h: 128 }); + this.fillType7 = adjust$1(this.secondaryColor, { h: 128 }); + this.cScale1 = this.cScale1 || "#0b0000"; + this.cScale2 = this.cScale2 || "#4d1037"; + this.cScale3 = this.cScale3 || "#3f5258"; + this.cScale4 = this.cScale4 || "#4f2f1b"; + this.cScale5 = this.cScale5 || "#6e0a0a"; + this.cScale6 = this.cScale6 || "#3b0048"; + this.cScale7 = this.cScale7 || "#995a01"; + this.cScale8 = this.cScale8 || "#154706"; + this.cScale9 = this.cScale9 || "#161722"; + this.cScale10 = this.cScale10 || "#00296f"; + this.cScale11 = this.cScale11 || "#01629c"; + this.cScale12 = this.cScale12 || "#010029"; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust$1(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust$1(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust$1(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust$1(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust$1(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust$1(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust$1(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust$1(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust$1(this.primaryColor, { h: 330 }); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust$1(this.mainBkg, { h: 30, s: -30, l: -(-10 + i * 4) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust$1(this.mainBkg, { h: 30, s: -30, l: -(-7 + i * 4) }); + } + this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? "black" : this.labelTextColor); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["pie" + i] = this["cScale" + i]; + } + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust$1(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust$1(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust$1(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust$1(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust$1(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust$1(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#3498db,#2ecc71,#e74c3c,#f1c40f,#bdc3c7,#ffffff,#34495e,#9b59b6,#1abc9c,#e67e22" + }; + this.classText = this.primaryTextColor; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || (this.darkMode ? darken(this.secondaryColor, 30) : this.secondaryColor); + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = lighten(this.secondaryColor, 20); + this.git1 = lighten(this.pie2 || this.secondaryColor, 20); + this.git2 = lighten(this.pie3 || this.tertiaryColor, 20); + this.git3 = lighten(this.pie4 || adjust$1(this.primaryColor, { h: -30 }), 20); + this.git4 = lighten(this.pie5 || adjust$1(this.primaryColor, { h: -60 }), 20); + this.git5 = lighten(this.pie6 || adjust$1(this.primaryColor, { h: -90 }), 10); + this.git6 = lighten(this.pie7 || adjust$1(this.primaryColor, { h: 60 }), 10); + this.git7 = lighten(this.pie8 || adjust$1(this.primaryColor, { h: 120 }), 20); + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || lighten(this.background, 12); + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || lighten(this.background, 2); + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$3 = (userOverrides) => { + const theme2 = new Theme$3(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$2 = class Theme3 { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#ECECFF"; + this.secondaryColor = adjust$1(this.primaryColor, { h: 120 }); + this.secondaryColor = "#ffffde"; + this.tertiaryColor = adjust$1(this.primaryColor, { h: -160 }); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.background = "white"; + this.mainBkg = "#ECECFF"; + this.secondBkg = "#ffffde"; + this.lineColor = "#333333"; + this.border1 = "#9370DB"; + this.border2 = "#aaaa33"; + this.arrowheadColor = "#333333"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.labelBackground = "#e8e8e8"; + this.textColor = "#333"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "calculated"; + this.edgeLabelBackground = "calculated"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "black"; + this.actorLineColor = "grey"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "calculated"; + this.altSectionBkgColor = "calculated"; + this.sectionBkgColor2 = "calculated"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "calculated"; + this.taskTextLightColor = "calculated"; + this.taskTextColor = this.taskTextLightColor; + this.taskTextDarkColor = "calculated"; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.taskTextClickableColor = "calculated"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "calculated"; + this.critBorderColor = "calculated"; + this.critBkgColor = "calculated"; + this.todayLineColor = "calculated"; + this.sectionBkgColor = rgba$1(102, 102, 255, 0.49); + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "#fff400"; + this.taskBorderColor = "#534fbc"; + this.taskBkgColor = "#8a90dd"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "black"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "#534fbc"; + this.activeTaskBkgColor = "#bfc7ff"; + this.gridColor = "lightgrey"; + this.doneTaskBkgColor = "lightgrey"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#ff8888"; + this.critBkgColor = "red"; + this.todayLineColor = "red"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + this.updateColors(); + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust$1(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust$1(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust$1(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust$1(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust$1(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust$1(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust$1(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust$1(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust$1(this.primaryColor, { h: 330 }); + this["cScalePeer1"] = this["cScalePeer1"] || darken(this.secondaryColor, 45); + this["cScalePeer2"] = this["cScalePeer2"] || darken(this.tertiaryColor, 40); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 10); + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 25); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || adjust$1(this["cScale" + i], { h: 180 }); + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust$1(this.mainBkg, { h: 30, l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust$1(this.mainBkg, { h: 30, l: -(7 + i * 5) }); + } + this.scaleLabelColor = this.scaleLabelColor !== "calculated" && this.scaleLabelColor ? this.scaleLabelColor : this.labelTextColor; + if (this.labelTextColor !== "calculated") { + this.cScaleLabel0 = this.cScaleLabel0 || invert(this.labelTextColor); + this.cScaleLabel3 = this.cScaleLabel3 || invert(this.labelTextColor); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.labelTextColor; + } + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.titleColor = this.textColor; + this.edgeLabelBackground = this.labelBackground; + this.actorBorder = lighten(this.border1, 23); + this.actorBkg = this.mainBkg; + this.labelBoxBkgColor = this.actorBkg; + this.signalColor = this.textColor; + this.signalTextColor = this.textColor; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.actorTextColor; + this.loopTextColor = this.actorTextColor; + this.noteBorderColor = this.border2; + this.noteTextColor = this.actorTextColor; + this.taskTextColor = this.taskTextLightColor; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f0f0f0"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.nodeBorder; + this.specialStateColor = this.lineColor; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust$1(this.primaryColor, { h: 64 }); + this.fillType3 = adjust$1(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust$1(this.primaryColor, { h: -64 }); + this.fillType5 = adjust$1(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust$1(this.primaryColor, { h: 128 }); + this.fillType7 = adjust$1(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || adjust$1(this.tertiaryColor, { l: -40 }); + this.pie4 = this.pie4 || adjust$1(this.primaryColor, { l: -10 }); + this.pie5 = this.pie5 || adjust$1(this.secondaryColor, { l: -30 }); + this.pie6 = this.pie6 || adjust$1(this.tertiaryColor, { l: -20 }); + this.pie7 = this.pie7 || adjust$1(this.primaryColor, { h: 60, l: -20 }); + this.pie8 = this.pie8 || adjust$1(this.primaryColor, { h: -60, l: -40 }); + this.pie9 = this.pie9 || adjust$1(this.primaryColor, { h: 120, l: -40 }); + this.pie10 = this.pie10 || adjust$1(this.primaryColor, { h: 60, l: -40 }); + this.pie11 = this.pie11 || adjust$1(this.primaryColor, { h: -90, l: -40 }); + this.pie12 = this.pie12 || adjust$1(this.primaryColor, { h: 120, l: -30 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust$1(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust$1(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust$1(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust$1(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust$1(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust$1(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#ECECFF,#8493A6,#FFC3A0,#DCDDE1,#B8E994,#D1A36F,#C3CDE6,#FFB6C1,#496078,#F8F3E3" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.labelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust$1(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust$1(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust$1(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust$1(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust$1(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || darken(invert(this.git0), 25); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$2 = (userOverrides) => { + const theme2 = new Theme$2(); + theme2.calculate(userOverrides); + return theme2; +}; +let Theme$1 = class Theme4 { + constructor() { + this.background = "#f4f4f4"; + this.primaryColor = "#cde498"; + this.secondaryColor = "#cdffb2"; + this.background = "white"; + this.mainBkg = "#cde498"; + this.secondBkg = "#cdffb2"; + this.lineColor = "green"; + this.border1 = "#13540c"; + this.border2 = "#6eaa49"; + this.arrowheadColor = "green"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.tertiaryColor = lighten("#cde498", 10); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.primaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "#333"; + this.edgeLabelBackground = "#e8e8e8"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "black"; + this.actorLineColor = "grey"; + this.signalColor = "#333"; + this.signalTextColor = "#333"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "#326932"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "#fff5ad"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "#6eaa49"; + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "#6eaa49"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "#487e3a"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "black"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "lightgrey"; + this.doneTaskBkgColor = "lightgrey"; + this.doneTaskBorderColor = "grey"; + this.critBorderColor = "#ff8888"; + this.critBkgColor = "red"; + this.todayLineColor = "red"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.actorBorder = darken(this.mainBkg, 20); + this.actorBkg = this.mainBkg; + this.labelBoxBkgColor = this.actorBkg; + this.labelTextColor = this.actorTextColor; + this.loopTextColor = this.actorTextColor; + this.noteBorderColor = this.border2; + this.noteTextColor = this.actorTextColor; + this.cScale0 = this.cScale0 || this.primaryColor; + this.cScale1 = this.cScale1 || this.secondaryColor; + this.cScale2 = this.cScale2 || this.tertiaryColor; + this.cScale3 = this.cScale3 || adjust$1(this.primaryColor, { h: 30 }); + this.cScale4 = this.cScale4 || adjust$1(this.primaryColor, { h: 60 }); + this.cScale5 = this.cScale5 || adjust$1(this.primaryColor, { h: 90 }); + this.cScale6 = this.cScale6 || adjust$1(this.primaryColor, { h: 120 }); + this.cScale7 = this.cScale7 || adjust$1(this.primaryColor, { h: 150 }); + this.cScale8 = this.cScale8 || adjust$1(this.primaryColor, { h: 210 }); + this.cScale9 = this.cScale9 || adjust$1(this.primaryColor, { h: 270 }); + this.cScale10 = this.cScale10 || adjust$1(this.primaryColor, { h: 300 }); + this.cScale11 = this.cScale11 || adjust$1(this.primaryColor, { h: 330 }); + this["cScalePeer1"] = this["cScalePeer1"] || darken(this.secondaryColor, 45); + this["cScalePeer2"] = this["cScalePeer2"] || darken(this.tertiaryColor, 40); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScale" + i] = darken(this["cScale" + i], 10); + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 25); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || adjust$1(this["cScale" + i], { h: 180 }); + } + this.scaleLabelColor = this.scaleLabelColor !== "calculated" && this.scaleLabelColor ? this.scaleLabelColor : this.labelTextColor; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust$1(this.mainBkg, { h: 30, s: -30, l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust$1(this.mainBkg, { h: 30, s: -30, l: -(8 + i * 5) }); + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.taskBorderColor = this.border1; + this.taskTextColor = this.taskTextLightColor; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.activeTaskBorderColor = this.taskBorderColor; + this.activeTaskBkgColor = this.mainBkg; + this.transitionColor = this.transitionColor || this.lineColor; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f0f0f0"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.compositeBorder = this.compositeBorder || this.nodeBorder; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = this.lineColor; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.transitionColor = this.transitionColor || this.lineColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust$1(this.primaryColor, { h: 64 }); + this.fillType3 = adjust$1(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust$1(this.primaryColor, { h: -64 }); + this.fillType5 = adjust$1(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust$1(this.primaryColor, { h: 128 }); + this.fillType7 = adjust$1(this.secondaryColor, { h: 128 }); + this.pie1 = this.pie1 || this.primaryColor; + this.pie2 = this.pie2 || this.secondaryColor; + this.pie3 = this.pie3 || this.tertiaryColor; + this.pie4 = this.pie4 || adjust$1(this.primaryColor, { l: -30 }); + this.pie5 = this.pie5 || adjust$1(this.secondaryColor, { l: -30 }); + this.pie6 = this.pie6 || adjust$1(this.tertiaryColor, { h: 40, l: -40 }); + this.pie7 = this.pie7 || adjust$1(this.primaryColor, { h: 60, l: -10 }); + this.pie8 = this.pie8 || adjust$1(this.primaryColor, { h: -60, l: -10 }); + this.pie9 = this.pie9 || adjust$1(this.primaryColor, { h: 120, l: 0 }); + this.pie10 = this.pie10 || adjust$1(this.primaryColor, { h: 60, l: -50 }); + this.pie11 = this.pie11 || adjust$1(this.primaryColor, { h: -60, l: -50 }); + this.pie12 = this.pie12 || adjust$1(this.primaryColor, { h: 120, l: -50 }); + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust$1(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust$1(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust$1(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust$1(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust$1(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust$1(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#CDE498,#FF6B6B,#A0D2DB,#D7BDE2,#F0F0F0,#FFC3A0,#7FD8BE,#FF9A8B,#FAF3E0,#FFF176" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.edgeLabelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = this.git0 || this.primaryColor; + this.git1 = this.git1 || this.secondaryColor; + this.git2 = this.git2 || this.tertiaryColor; + this.git3 = this.git3 || adjust$1(this.primaryColor, { h: -30 }); + this.git4 = this.git4 || adjust$1(this.primaryColor, { h: -60 }); + this.git5 = this.git5 || adjust$1(this.primaryColor, { h: -90 }); + this.git6 = this.git6 || adjust$1(this.primaryColor, { h: 60 }); + this.git7 = this.git7 || adjust$1(this.primaryColor, { h: 120 }); + if (this.darkMode) { + this.git0 = lighten(this.git0, 25); + this.git1 = lighten(this.git1, 25); + this.git2 = lighten(this.git2, 25); + this.git3 = lighten(this.git3, 25); + this.git4 = lighten(this.git4, 25); + this.git5 = lighten(this.git5, 25); + this.git6 = lighten(this.git6, 25); + this.git7 = lighten(this.git7, 25); + } else { + this.git0 = darken(this.git0, 25); + this.git1 = darken(this.git1, 25); + this.git2 = darken(this.git2, 25); + this.git3 = darken(this.git3, 25); + this.git4 = darken(this.git4, 25); + this.git5 = darken(this.git5, 25); + this.git6 = darken(this.git6, 25); + this.git7 = darken(this.git7, 25); + } + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor); + this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor; + this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor; + this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor); + this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor; + this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor; + this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor; + this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +}; +const getThemeVariables$1 = (userOverrides) => { + const theme2 = new Theme$1(); + theme2.calculate(userOverrides); + return theme2; +}; +class Theme5 { + constructor() { + this.primaryColor = "#eee"; + this.contrast = "#707070"; + this.secondaryColor = lighten(this.contrast, 55); + this.background = "#ffffff"; + this.tertiaryColor = adjust$1(this.primaryColor, { h: -160 }); + this.primaryBorderColor = mkBorder(this.primaryColor, this.darkMode); + this.secondaryBorderColor = mkBorder(this.secondaryColor, this.darkMode); + this.tertiaryBorderColor = mkBorder(this.tertiaryColor, this.darkMode); + this.primaryTextColor = invert(this.primaryColor); + this.secondaryTextColor = invert(this.secondaryColor); + this.tertiaryTextColor = invert(this.tertiaryColor); + this.lineColor = invert(this.background); + this.textColor = invert(this.background); + this.mainBkg = "#eee"; + this.secondBkg = "calculated"; + this.lineColor = "#666"; + this.border1 = "#999"; + this.border2 = "calculated"; + this.note = "#ffa"; + this.text = "#333"; + this.critical = "#d42"; + this.done = "#bbb"; + this.arrowheadColor = "#333333"; + this.fontFamily = '"trebuchet ms", verdana, arial, sans-serif'; + this.fontSize = "16px"; + this.THEME_COLOR_LIMIT = 12; + this.nodeBkg = "calculated"; + this.nodeBorder = "calculated"; + this.clusterBkg = "calculated"; + this.clusterBorder = "calculated"; + this.defaultLinkColor = "calculated"; + this.titleColor = "calculated"; + this.edgeLabelBackground = "white"; + this.actorBorder = "calculated"; + this.actorBkg = "calculated"; + this.actorTextColor = "calculated"; + this.actorLineColor = "calculated"; + this.signalColor = "calculated"; + this.signalTextColor = "calculated"; + this.labelBoxBkgColor = "calculated"; + this.labelBoxBorderColor = "calculated"; + this.labelTextColor = "calculated"; + this.loopTextColor = "calculated"; + this.noteBorderColor = "calculated"; + this.noteBkgColor = "calculated"; + this.noteTextColor = "calculated"; + this.activationBorderColor = "#666"; + this.activationBkgColor = "#f4f4f4"; + this.sequenceNumberColor = "white"; + this.sectionBkgColor = "calculated"; + this.altSectionBkgColor = "white"; + this.sectionBkgColor2 = "calculated"; + this.excludeBkgColor = "#eeeeee"; + this.taskBorderColor = "calculated"; + this.taskBkgColor = "calculated"; + this.taskTextLightColor = "white"; + this.taskTextColor = "calculated"; + this.taskTextDarkColor = "calculated"; + this.taskTextOutsideColor = "calculated"; + this.taskTextClickableColor = "#003163"; + this.activeTaskBorderColor = "calculated"; + this.activeTaskBkgColor = "calculated"; + this.gridColor = "calculated"; + this.doneTaskBkgColor = "calculated"; + this.doneTaskBorderColor = "calculated"; + this.critBkgColor = "calculated"; + this.critBorderColor = "calculated"; + this.todayLineColor = "calculated"; + this.personBorder = this.primaryBorderColor; + this.personBkg = this.mainBkg; + this.labelColor = "black"; + this.errorBkgColor = "#552222"; + this.errorTextColor = "#552222"; + } + updateColors() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k; + this.secondBkg = lighten(this.contrast, 55); + this.border2 = this.contrast; + this.actorBorder = lighten(this.border1, 23); + this.actorBkg = this.mainBkg; + this.actorTextColor = this.text; + this.actorLineColor = this.lineColor; + this.signalColor = this.text; + this.signalTextColor = this.text; + this.labelBoxBkgColor = this.actorBkg; + this.labelBoxBorderColor = this.actorBorder; + this.labelTextColor = this.text; + this.loopTextColor = this.text; + this.noteBorderColor = "#999"; + this.noteBkgColor = "#666"; + this.noteTextColor = "#fff"; + this.cScale0 = this.cScale0 || "#555"; + this.cScale1 = this.cScale1 || "#F4F4F4"; + this.cScale2 = this.cScale2 || "#555"; + this.cScale3 = this.cScale3 || "#BBB"; + this.cScale4 = this.cScale4 || "#777"; + this.cScale5 = this.cScale5 || "#999"; + this.cScale6 = this.cScale6 || "#DDD"; + this.cScale7 = this.cScale7 || "#FFF"; + this.cScale8 = this.cScale8 || "#DDD"; + this.cScale9 = this.cScale9 || "#BBB"; + this.cScale10 = this.cScale10 || "#999"; + this.cScale11 = this.cScale11 || "#777"; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleInv" + i] = this["cScaleInv" + i] || invert(this["cScale" + i]); + } + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + if (this.darkMode) { + this["cScalePeer" + i] = this["cScalePeer" + i] || lighten(this["cScale" + i], 10); + } else { + this["cScalePeer" + i] = this["cScalePeer" + i] || darken(this["cScale" + i], 10); + } + } + this.scaleLabelColor = this.scaleLabelColor || (this.darkMode ? "black" : this.labelTextColor); + this["cScaleLabel0"] = this["cScaleLabel0"] || this.cScale1; + this["cScaleLabel2"] = this["cScaleLabel2"] || this.cScale1; + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["cScaleLabel" + i] = this["cScaleLabel" + i] || this.scaleLabelColor; + } + for (let i = 0; i < 5; i++) { + this["surface" + i] = this["surface" + i] || adjust$1(this.mainBkg, { l: -(5 + i * 5) }); + this["surfacePeer" + i] = this["surfacePeer" + i] || adjust$1(this.mainBkg, { l: -(8 + i * 5) }); + } + this.nodeBkg = this.mainBkg; + this.nodeBorder = this.border1; + this.clusterBkg = this.secondBkg; + this.clusterBorder = this.border2; + this.defaultLinkColor = this.lineColor; + this.titleColor = this.text; + this.sectionBkgColor = lighten(this.contrast, 30); + this.sectionBkgColor2 = lighten(this.contrast, 30); + this.taskBorderColor = darken(this.contrast, 10); + this.taskBkgColor = this.contrast; + this.taskTextColor = this.taskTextLightColor; + this.taskTextDarkColor = this.text; + this.taskTextOutsideColor = this.taskTextDarkColor; + this.activeTaskBorderColor = this.taskBorderColor; + this.activeTaskBkgColor = this.mainBkg; + this.gridColor = lighten(this.border1, 30); + this.doneTaskBkgColor = this.done; + this.doneTaskBorderColor = this.lineColor; + this.critBkgColor = this.critical; + this.critBorderColor = darken(this.critBkgColor, 10); + this.todayLineColor = this.critBkgColor; + this.transitionColor = this.transitionColor || "#000"; + this.transitionLabelColor = this.transitionLabelColor || this.textColor; + this.stateLabelColor = this.stateLabelColor || this.stateBkg || this.primaryTextColor; + this.stateBkg = this.stateBkg || this.mainBkg; + this.labelBackgroundColor = this.labelBackgroundColor || this.stateBkg; + this.compositeBackground = this.compositeBackground || this.background || this.tertiaryColor; + this.altBackground = this.altBackground || "#f4f4f4"; + this.compositeTitleBackground = this.compositeTitleBackground || this.mainBkg; + this.stateBorder = this.stateBorder || "#000"; + this.innerEndBackground = this.primaryBorderColor; + this.specialStateColor = "#222"; + this.errorBkgColor = this.errorBkgColor || this.tertiaryColor; + this.errorTextColor = this.errorTextColor || this.tertiaryTextColor; + this.classText = this.primaryTextColor; + this.fillType0 = this.primaryColor; + this.fillType1 = this.secondaryColor; + this.fillType2 = adjust$1(this.primaryColor, { h: 64 }); + this.fillType3 = adjust$1(this.secondaryColor, { h: 64 }); + this.fillType4 = adjust$1(this.primaryColor, { h: -64 }); + this.fillType5 = adjust$1(this.secondaryColor, { h: -64 }); + this.fillType6 = adjust$1(this.primaryColor, { h: 128 }); + this.fillType7 = adjust$1(this.secondaryColor, { h: 128 }); + for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) { + this["pie" + i] = this["cScale" + i]; + } + this.pie12 = this.pie0; + this.pieTitleTextSize = this.pieTitleTextSize || "25px"; + this.pieTitleTextColor = this.pieTitleTextColor || this.taskTextDarkColor; + this.pieSectionTextSize = this.pieSectionTextSize || "17px"; + this.pieSectionTextColor = this.pieSectionTextColor || this.textColor; + this.pieLegendTextSize = this.pieLegendTextSize || "17px"; + this.pieLegendTextColor = this.pieLegendTextColor || this.taskTextDarkColor; + this.pieStrokeColor = this.pieStrokeColor || "black"; + this.pieStrokeWidth = this.pieStrokeWidth || "2px"; + this.pieOuterStrokeWidth = this.pieOuterStrokeWidth || "2px"; + this.pieOuterStrokeColor = this.pieOuterStrokeColor || "black"; + this.pieOpacity = this.pieOpacity || "0.7"; + this.quadrant1Fill = this.quadrant1Fill || this.primaryColor; + this.quadrant2Fill = this.quadrant2Fill || adjust$1(this.primaryColor, { r: 5, g: 5, b: 5 }); + this.quadrant3Fill = this.quadrant3Fill || adjust$1(this.primaryColor, { r: 10, g: 10, b: 10 }); + this.quadrant4Fill = this.quadrant4Fill || adjust$1(this.primaryColor, { r: 15, g: 15, b: 15 }); + this.quadrant1TextFill = this.quadrant1TextFill || this.primaryTextColor; + this.quadrant2TextFill = this.quadrant2TextFill || adjust$1(this.primaryTextColor, { r: -5, g: -5, b: -5 }); + this.quadrant3TextFill = this.quadrant3TextFill || adjust$1(this.primaryTextColor, { r: -10, g: -10, b: -10 }); + this.quadrant4TextFill = this.quadrant4TextFill || adjust$1(this.primaryTextColor, { r: -15, g: -15, b: -15 }); + this.quadrantPointFill = this.quadrantPointFill || isDark(this.quadrant1Fill) ? lighten(this.quadrant1Fill) : darken(this.quadrant1Fill); + this.quadrantPointTextFill = this.quadrantPointTextFill || this.primaryTextColor; + this.quadrantXAxisTextFill = this.quadrantXAxisTextFill || this.primaryTextColor; + this.quadrantYAxisTextFill = this.quadrantYAxisTextFill || this.primaryTextColor; + this.quadrantInternalBorderStrokeFill = this.quadrantInternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantExternalBorderStrokeFill = this.quadrantExternalBorderStrokeFill || this.primaryBorderColor; + this.quadrantTitleFill = this.quadrantTitleFill || this.primaryTextColor; + this.xyChart = { + backgroundColor: ((_a = this.xyChart) == null ? void 0 : _a.backgroundColor) || this.background, + titleColor: ((_b = this.xyChart) == null ? void 0 : _b.titleColor) || this.primaryTextColor, + xAxisTitleColor: ((_c = this.xyChart) == null ? void 0 : _c.xAxisTitleColor) || this.primaryTextColor, + xAxisLabelColor: ((_d = this.xyChart) == null ? void 0 : _d.xAxisLabelColor) || this.primaryTextColor, + xAxisTickColor: ((_e = this.xyChart) == null ? void 0 : _e.xAxisTickColor) || this.primaryTextColor, + xAxisLineColor: ((_f = this.xyChart) == null ? void 0 : _f.xAxisLineColor) || this.primaryTextColor, + yAxisTitleColor: ((_g = this.xyChart) == null ? void 0 : _g.yAxisTitleColor) || this.primaryTextColor, + yAxisLabelColor: ((_h = this.xyChart) == null ? void 0 : _h.yAxisLabelColor) || this.primaryTextColor, + yAxisTickColor: ((_i = this.xyChart) == null ? void 0 : _i.yAxisTickColor) || this.primaryTextColor, + yAxisLineColor: ((_j = this.xyChart) == null ? void 0 : _j.yAxisLineColor) || this.primaryTextColor, + plotColorPalette: ((_k = this.xyChart) == null ? void 0 : _k.plotColorPalette) || "#EEE,#6BB8E4,#8ACB88,#C7ACD6,#E8DCC2,#FFB2A8,#FFF380,#7E8D91,#FFD8B1,#FAF3E0" + }; + this.requirementBackground = this.requirementBackground || this.primaryColor; + this.requirementBorderColor = this.requirementBorderColor || this.primaryBorderColor; + this.requirementBorderSize = this.requirementBorderSize || "1"; + this.requirementTextColor = this.requirementTextColor || this.primaryTextColor; + this.relationColor = this.relationColor || this.lineColor; + this.relationLabelBackground = this.relationLabelBackground || this.edgeLabelBackground; + this.relationLabelColor = this.relationLabelColor || this.actorTextColor; + this.git0 = darken(this.pie1, 25) || this.primaryColor; + this.git1 = this.pie2 || this.secondaryColor; + this.git2 = this.pie3 || this.tertiaryColor; + this.git3 = this.pie4 || adjust$1(this.primaryColor, { h: -30 }); + this.git4 = this.pie5 || adjust$1(this.primaryColor, { h: -60 }); + this.git5 = this.pie6 || adjust$1(this.primaryColor, { h: -90 }); + this.git6 = this.pie7 || adjust$1(this.primaryColor, { h: 60 }); + this.git7 = this.pie8 || adjust$1(this.primaryColor, { h: 120 }); + this.gitInv0 = this.gitInv0 || invert(this.git0); + this.gitInv1 = this.gitInv1 || invert(this.git1); + this.gitInv2 = this.gitInv2 || invert(this.git2); + this.gitInv3 = this.gitInv3 || invert(this.git3); + this.gitInv4 = this.gitInv4 || invert(this.git4); + this.gitInv5 = this.gitInv5 || invert(this.git5); + this.gitInv6 = this.gitInv6 || invert(this.git6); + this.gitInv7 = this.gitInv7 || invert(this.git7); + this.branchLabelColor = this.branchLabelColor || this.labelTextColor; + this.gitBranchLabel0 = this.branchLabelColor; + this.gitBranchLabel1 = "white"; + this.gitBranchLabel2 = this.branchLabelColor; + this.gitBranchLabel3 = "white"; + this.gitBranchLabel4 = this.branchLabelColor; + this.gitBranchLabel5 = this.branchLabelColor; + this.gitBranchLabel6 = this.branchLabelColor; + this.gitBranchLabel7 = this.branchLabelColor; + this.tagLabelColor = this.tagLabelColor || this.primaryTextColor; + this.tagLabelBackground = this.tagLabelBackground || this.primaryColor; + this.tagLabelBorder = this.tagBorder || this.primaryBorderColor; + this.tagLabelFontSize = this.tagLabelFontSize || "10px"; + this.commitLabelColor = this.commitLabelColor || this.secondaryTextColor; + this.commitLabelBackground = this.commitLabelBackground || this.secondaryColor; + this.commitLabelFontSize = this.commitLabelFontSize || "10px"; + this.attributeBackgroundColorOdd = this.attributeBackgroundColorOdd || oldAttributeBackgroundColorOdd; + this.attributeBackgroundColorEven = this.attributeBackgroundColorEven || oldAttributeBackgroundColorEven; + } + calculate(overrides) { + if (typeof overrides !== "object") { + this.updateColors(); + return; + } + const keys = Object.keys(overrides); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + this.updateColors(); + keys.forEach((k) => { + this[k] = overrides[k]; + }); + } +} +const getThemeVariables = (userOverrides) => { + const theme2 = new Theme5(); + theme2.calculate(userOverrides); + return theme2; +}; +const theme = { + base: { + getThemeVariables: getThemeVariables$4 + }, + dark: { + getThemeVariables: getThemeVariables$3 + }, + default: { + getThemeVariables: getThemeVariables$2 + }, + forest: { + getThemeVariables: getThemeVariables$1 + }, + neutral: { + getThemeVariables + } +}; +const defaultConfigJson = { + "flowchart": { + "useMaxWidth": true, + "titleTopMargin": 25, + "subGraphTitleMargin": { + "top": 0, + "bottom": 0 + }, + "diagramPadding": 8, + "htmlLabels": true, + "nodeSpacing": 50, + "rankSpacing": 50, + "curve": "basis", + "padding": 15, + "defaultRenderer": "dagre-wrapper", + "wrappingWidth": 200 + }, + "sequence": { + "useMaxWidth": true, + "hideUnusedParticipants": false, + "activationWidth": 10, + "diagramMarginX": 50, + "diagramMarginY": 10, + "actorMargin": 50, + "width": 150, + "height": 65, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "mirrorActors": true, + "forceMenus": false, + "bottomMarginAdj": 1, + "rightAngles": false, + "showSequenceNumbers": false, + "actorFontSize": 14, + "actorFontFamily": '"Open Sans", sans-serif', + "actorFontWeight": 400, + "noteFontSize": 14, + "noteFontFamily": '"trebuchet ms", verdana, arial, sans-serif', + "noteFontWeight": 400, + "noteAlign": "center", + "messageFontSize": 16, + "messageFontFamily": '"trebuchet ms", verdana, arial, sans-serif', + "messageFontWeight": 400, + "wrap": false, + "wrapPadding": 10, + "labelBoxWidth": 50, + "labelBoxHeight": 20 + }, + "gantt": { + "useMaxWidth": true, + "titleTopMargin": 25, + "barHeight": 20, + "barGap": 4, + "topPadding": 50, + "rightPadding": 75, + "leftPadding": 75, + "gridLineStartPadding": 35, + "fontSize": 11, + "sectionFontSize": 11, + "numberSectionStyles": 4, + "axisFormat": "%Y-%m-%d", + "topAxis": false, + "displayMode": "", + "weekday": "sunday" + }, + "journey": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "leftMargin": 150, + "width": 150, + "height": 50, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "bottomMarginAdj": 1, + "rightAngles": false, + "taskFontSize": 14, + "taskFontFamily": '"Open Sans", sans-serif', + "taskMargin": 50, + "activationWidth": 10, + "textPlacement": "fo", + "actorColours": [ + "#8FBC8F", + "#7CFC00", + "#00FFFF", + "#20B2AA", + "#B0E0E6", + "#FFFFE0" + ], + "sectionFills": [ + "#191970", + "#8B008B", + "#4B0082", + "#2F4F4F", + "#800000", + "#8B4513", + "#00008B" + ], + "sectionColours": [ + "#fff" + ] + }, + "class": { + "useMaxWidth": true, + "titleTopMargin": 25, + "arrowMarkerAbsolute": false, + "dividerMargin": 10, + "padding": 5, + "textHeight": 10, + "defaultRenderer": "dagre-wrapper", + "htmlLabels": false + }, + "state": { + "useMaxWidth": true, + "titleTopMargin": 25, + "dividerMargin": 10, + "sizeUnit": 5, + "padding": 8, + "textHeight": 10, + "titleShift": -15, + "noteMargin": 10, + "forkWidth": 70, + "forkHeight": 7, + "miniPadding": 2, + "fontSizeFactor": 5.02, + "fontSize": 24, + "labelHeight": 16, + "edgeLengthFactor": "20", + "compositTitleSize": 35, + "radius": 5, + "defaultRenderer": "dagre-wrapper" + }, + "er": { + "useMaxWidth": true, + "titleTopMargin": 25, + "diagramPadding": 20, + "layoutDirection": "TB", + "minEntityWidth": 100, + "minEntityHeight": 75, + "entityPadding": 15, + "stroke": "gray", + "fill": "honeydew", + "fontSize": 12 + }, + "pie": { + "useMaxWidth": true, + "textPosition": 0.75 + }, + "quadrantChart": { + "useMaxWidth": true, + "chartWidth": 500, + "chartHeight": 500, + "titleFontSize": 20, + "titlePadding": 10, + "quadrantPadding": 5, + "xAxisLabelPadding": 5, + "yAxisLabelPadding": 5, + "xAxisLabelFontSize": 16, + "yAxisLabelFontSize": 16, + "quadrantLabelFontSize": 16, + "quadrantTextTopPadding": 5, + "pointTextPadding": 5, + "pointLabelFontSize": 12, + "pointRadius": 5, + "xAxisPosition": "top", + "yAxisPosition": "left", + "quadrantInternalBorderStrokeWidth": 1, + "quadrantExternalBorderStrokeWidth": 2 + }, + "xyChart": { + "useMaxWidth": true, + "width": 700, + "height": 500, + "titleFontSize": 20, + "titlePadding": 10, + "showTitle": true, + "xAxis": { + "$ref": "#/$defs/XYChartAxisConfig", + "showLabel": true, + "labelFontSize": 14, + "labelPadding": 5, + "showTitle": true, + "titleFontSize": 16, + "titlePadding": 5, + "showTick": true, + "tickLength": 5, + "tickWidth": 2, + "showAxisLine": true, + "axisLineWidth": 2 + }, + "yAxis": { + "$ref": "#/$defs/XYChartAxisConfig", + "showLabel": true, + "labelFontSize": 14, + "labelPadding": 5, + "showTitle": true, + "titleFontSize": 16, + "titlePadding": 5, + "showTick": true, + "tickLength": 5, + "tickWidth": 2, + "showAxisLine": true, + "axisLineWidth": 2 + }, + "chartOrientation": "vertical", + "plotReservedSpacePercent": 50 + }, + "requirement": { + "useMaxWidth": true, + "rect_fill": "#f9f9f9", + "text_color": "#333", + "rect_border_size": "0.5px", + "rect_border_color": "#bbb", + "rect_min_width": 200, + "rect_min_height": 200, + "fontSize": 14, + "rect_padding": 10, + "line_height": 20 + }, + "mindmap": { + "useMaxWidth": true, + "padding": 10, + "maxNodeWidth": 200 + }, + "timeline": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "leftMargin": 150, + "width": 150, + "height": 50, + "boxMargin": 10, + "boxTextMargin": 5, + "noteMargin": 10, + "messageMargin": 35, + "messageAlign": "center", + "bottomMarginAdj": 1, + "rightAngles": false, + "taskFontSize": 14, + "taskFontFamily": '"Open Sans", sans-serif', + "taskMargin": 50, + "activationWidth": 10, + "textPlacement": "fo", + "actorColours": [ + "#8FBC8F", + "#7CFC00", + "#00FFFF", + "#20B2AA", + "#B0E0E6", + "#FFFFE0" + ], + "sectionFills": [ + "#191970", + "#8B008B", + "#4B0082", + "#2F4F4F", + "#800000", + "#8B4513", + "#00008B" + ], + "sectionColours": [ + "#fff" + ], + "disableMulticolor": false + }, + "gitGraph": { + "useMaxWidth": true, + "titleTopMargin": 25, + "diagramPadding": 8, + "nodeLabel": { + "width": 75, + "height": 100, + "x": -25, + "y": 0 + }, + "mainBranchName": "main", + "mainBranchOrder": 0, + "showCommitLabel": true, + "showBranches": true, + "rotateCommitLabel": true, + "parallelCommits": false, + "arrowMarkerAbsolute": false + }, + "c4": { + "useMaxWidth": true, + "diagramMarginX": 50, + "diagramMarginY": 10, + "c4ShapeMargin": 50, + "c4ShapePadding": 20, + "width": 216, + "height": 60, + "boxMargin": 10, + "c4ShapeInRow": 4, + "nextLinePaddingX": 0, + "c4BoundaryInRow": 2, + "personFontSize": 14, + "personFontFamily": '"Open Sans", sans-serif', + "personFontWeight": "normal", + "external_personFontSize": 14, + "external_personFontFamily": '"Open Sans", sans-serif', + "external_personFontWeight": "normal", + "systemFontSize": 14, + "systemFontFamily": '"Open Sans", sans-serif', + "systemFontWeight": "normal", + "external_systemFontSize": 14, + "external_systemFontFamily": '"Open Sans", sans-serif', + "external_systemFontWeight": "normal", + "system_dbFontSize": 14, + "system_dbFontFamily": '"Open Sans", sans-serif', + "system_dbFontWeight": "normal", + "external_system_dbFontSize": 14, + "external_system_dbFontFamily": '"Open Sans", sans-serif', + "external_system_dbFontWeight": "normal", + "system_queueFontSize": 14, + "system_queueFontFamily": '"Open Sans", sans-serif', + "system_queueFontWeight": "normal", + "external_system_queueFontSize": 14, + "external_system_queueFontFamily": '"Open Sans", sans-serif', + "external_system_queueFontWeight": "normal", + "boundaryFontSize": 14, + "boundaryFontFamily": '"Open Sans", sans-serif', + "boundaryFontWeight": "normal", + "messageFontSize": 12, + "messageFontFamily": '"Open Sans", sans-serif', + "messageFontWeight": "normal", + "containerFontSize": 14, + "containerFontFamily": '"Open Sans", sans-serif', + "containerFontWeight": "normal", + "external_containerFontSize": 14, + "external_containerFontFamily": '"Open Sans", sans-serif', + "external_containerFontWeight": "normal", + "container_dbFontSize": 14, + "container_dbFontFamily": '"Open Sans", sans-serif', + "container_dbFontWeight": "normal", + "external_container_dbFontSize": 14, + "external_container_dbFontFamily": '"Open Sans", sans-serif', + "external_container_dbFontWeight": "normal", + "container_queueFontSize": 14, + "container_queueFontFamily": '"Open Sans", sans-serif', + "container_queueFontWeight": "normal", + "external_container_queueFontSize": 14, + "external_container_queueFontFamily": '"Open Sans", sans-serif', + "external_container_queueFontWeight": "normal", + "componentFontSize": 14, + "componentFontFamily": '"Open Sans", sans-serif', + "componentFontWeight": "normal", + "external_componentFontSize": 14, + "external_componentFontFamily": '"Open Sans", sans-serif', + "external_componentFontWeight": "normal", + "component_dbFontSize": 14, + "component_dbFontFamily": '"Open Sans", sans-serif', + "component_dbFontWeight": "normal", + "external_component_dbFontSize": 14, + "external_component_dbFontFamily": '"Open Sans", sans-serif', + "external_component_dbFontWeight": "normal", + "component_queueFontSize": 14, + "component_queueFontFamily": '"Open Sans", sans-serif', + "component_queueFontWeight": "normal", + "external_component_queueFontSize": 14, + "external_component_queueFontFamily": '"Open Sans", sans-serif', + "external_component_queueFontWeight": "normal", + "wrap": true, + "wrapPadding": 10, + "person_bg_color": "#08427B", + "person_border_color": "#073B6F", + "external_person_bg_color": "#686868", + "external_person_border_color": "#8A8A8A", + "system_bg_color": "#1168BD", + "system_border_color": "#3C7FC0", + "system_db_bg_color": "#1168BD", + "system_db_border_color": "#3C7FC0", + "system_queue_bg_color": "#1168BD", + "system_queue_border_color": "#3C7FC0", + "external_system_bg_color": "#999999", + "external_system_border_color": "#8A8A8A", + "external_system_db_bg_color": "#999999", + "external_system_db_border_color": "#8A8A8A", + "external_system_queue_bg_color": "#999999", + "external_system_queue_border_color": "#8A8A8A", + "container_bg_color": "#438DD5", + "container_border_color": "#3C7FC0", + "container_db_bg_color": "#438DD5", + "container_db_border_color": "#3C7FC0", + "container_queue_bg_color": "#438DD5", + "container_queue_border_color": "#3C7FC0", + "external_container_bg_color": "#B3B3B3", + "external_container_border_color": "#A6A6A6", + "external_container_db_bg_color": "#B3B3B3", + "external_container_db_border_color": "#A6A6A6", + "external_container_queue_bg_color": "#B3B3B3", + "external_container_queue_border_color": "#A6A6A6", + "component_bg_color": "#85BBF0", + "component_border_color": "#78A8D8", + "component_db_bg_color": "#85BBF0", + "component_db_border_color": "#78A8D8", + "component_queue_bg_color": "#85BBF0", + "component_queue_border_color": "#78A8D8", + "external_component_bg_color": "#CCCCCC", + "external_component_border_color": "#BFBFBF", + "external_component_db_bg_color": "#CCCCCC", + "external_component_db_border_color": "#BFBFBF", + "external_component_queue_bg_color": "#CCCCCC", + "external_component_queue_border_color": "#BFBFBF" + }, + "sankey": { + "useMaxWidth": true, + "width": 600, + "height": 400, + "linkColor": "gradient", + "nodeAlignment": "justify", + "showValues": true, + "prefix": "", + "suffix": "" + }, + "block": { + "useMaxWidth": true, + "padding": 8 + }, + "theme": "default", + "maxTextSize": 5e4, + "maxEdges": 500, + "darkMode": false, + "fontFamily": '"trebuchet ms", verdana, arial, sans-serif;', + "logLevel": 5, + "securityLevel": "strict", + "startOnLoad": true, + "arrowMarkerAbsolute": false, + "secure": [ + "secure", + "securityLevel", + "startOnLoad", + "maxTextSize", + "maxEdges" + ], + "legacyMathML": false, + "deterministicIds": false, + "fontSize": 16 +}; +const config$4 = { + ...defaultConfigJson, + // Set, even though they're `undefined` so that `configKeys` finds these keys + // TODO: Should we replace these with `null` so that they can go in the JSON Schema? + deterministicIDSeed: void 0, + themeCSS: void 0, + // add non-JSON default config values + themeVariables: theme["default"].getThemeVariables(), + sequence: { + ...defaultConfigJson.sequence, + messageFont: function() { + return { + fontFamily: this.messageFontFamily, + fontSize: this.messageFontSize, + fontWeight: this.messageFontWeight + }; + }, + noteFont: function() { + return { + fontFamily: this.noteFontFamily, + fontSize: this.noteFontSize, + fontWeight: this.noteFontWeight + }; + }, + actorFont: function() { + return { + fontFamily: this.actorFontFamily, + fontSize: this.actorFontSize, + fontWeight: this.actorFontWeight + }; + } + }, + gantt: { + ...defaultConfigJson.gantt, + tickInterval: void 0, + useWidth: void 0 + // can probably be removed since `configKeys` already includes this + }, + c4: { + ...defaultConfigJson.c4, + useWidth: void 0, + personFont: function() { + return { + fontFamily: this.personFontFamily, + fontSize: this.personFontSize, + fontWeight: this.personFontWeight + }; + }, + external_personFont: function() { + return { + fontFamily: this.external_personFontFamily, + fontSize: this.external_personFontSize, + fontWeight: this.external_personFontWeight + }; + }, + systemFont: function() { + return { + fontFamily: this.systemFontFamily, + fontSize: this.systemFontSize, + fontWeight: this.systemFontWeight + }; + }, + external_systemFont: function() { + return { + fontFamily: this.external_systemFontFamily, + fontSize: this.external_systemFontSize, + fontWeight: this.external_systemFontWeight + }; + }, + system_dbFont: function() { + return { + fontFamily: this.system_dbFontFamily, + fontSize: this.system_dbFontSize, + fontWeight: this.system_dbFontWeight + }; + }, + external_system_dbFont: function() { + return { + fontFamily: this.external_system_dbFontFamily, + fontSize: this.external_system_dbFontSize, + fontWeight: this.external_system_dbFontWeight + }; + }, + system_queueFont: function() { + return { + fontFamily: this.system_queueFontFamily, + fontSize: this.system_queueFontSize, + fontWeight: this.system_queueFontWeight + }; + }, + external_system_queueFont: function() { + return { + fontFamily: this.external_system_queueFontFamily, + fontSize: this.external_system_queueFontSize, + fontWeight: this.external_system_queueFontWeight + }; + }, + containerFont: function() { + return { + fontFamily: this.containerFontFamily, + fontSize: this.containerFontSize, + fontWeight: this.containerFontWeight + }; + }, + external_containerFont: function() { + return { + fontFamily: this.external_containerFontFamily, + fontSize: this.external_containerFontSize, + fontWeight: this.external_containerFontWeight + }; + }, + container_dbFont: function() { + return { + fontFamily: this.container_dbFontFamily, + fontSize: this.container_dbFontSize, + fontWeight: this.container_dbFontWeight + }; + }, + external_container_dbFont: function() { + return { + fontFamily: this.external_container_dbFontFamily, + fontSize: this.external_container_dbFontSize, + fontWeight: this.external_container_dbFontWeight + }; + }, + container_queueFont: function() { + return { + fontFamily: this.container_queueFontFamily, + fontSize: this.container_queueFontSize, + fontWeight: this.container_queueFontWeight + }; + }, + external_container_queueFont: function() { + return { + fontFamily: this.external_container_queueFontFamily, + fontSize: this.external_container_queueFontSize, + fontWeight: this.external_container_queueFontWeight + }; + }, + componentFont: function() { + return { + fontFamily: this.componentFontFamily, + fontSize: this.componentFontSize, + fontWeight: this.componentFontWeight + }; + }, + external_componentFont: function() { + return { + fontFamily: this.external_componentFontFamily, + fontSize: this.external_componentFontSize, + fontWeight: this.external_componentFontWeight + }; + }, + component_dbFont: function() { + return { + fontFamily: this.component_dbFontFamily, + fontSize: this.component_dbFontSize, + fontWeight: this.component_dbFontWeight + }; + }, + external_component_dbFont: function() { + return { + fontFamily: this.external_component_dbFontFamily, + fontSize: this.external_component_dbFontSize, + fontWeight: this.external_component_dbFontWeight + }; + }, + component_queueFont: function() { + return { + fontFamily: this.component_queueFontFamily, + fontSize: this.component_queueFontSize, + fontWeight: this.component_queueFontWeight + }; + }, + external_component_queueFont: function() { + return { + fontFamily: this.external_component_queueFontFamily, + fontSize: this.external_component_queueFontSize, + fontWeight: this.external_component_queueFontWeight + }; + }, + boundaryFont: function() { + return { + fontFamily: this.boundaryFontFamily, + fontSize: this.boundaryFontSize, + fontWeight: this.boundaryFontWeight + }; + }, + messageFont: function() { + return { + fontFamily: this.messageFontFamily, + fontSize: this.messageFontSize, + fontWeight: this.messageFontWeight + }; + } + }, + pie: { + ...defaultConfigJson.pie, + useWidth: 984 + }, + xyChart: { + ...defaultConfigJson.xyChart, + useWidth: void 0 + }, + requirement: { + ...defaultConfigJson.requirement, + useWidth: void 0 + }, + gitGraph: { + ...defaultConfigJson.gitGraph, + // TODO: This is a temporary override for `gitGraph`, since every other + // diagram does have `useMaxWidth`, but instead sets it to `true`. + // Should we set this to `true` instead? + useMaxWidth: false + }, + sankey: { + ...defaultConfigJson.sankey, + // this is false, unlike every other diagram (other than gitGraph) + // TODO: can we make this default to `true` instead? + useMaxWidth: false + } +}; +const keyify = (obj, prefix = "") => Object.keys(obj).reduce((res, el) => { + if (Array.isArray(obj[el])) { + return res; + } else if (typeof obj[el] === "object" && obj[el] !== null) { + return [...res, prefix + el, ...keyify(obj[el], "")]; + } + return [...res, prefix + el]; +}, []); +const configKeys = new Set(keyify(config$4, "")); +const defaultConfig$2 = config$4; +const sanitizeDirective = (args) => { + log$1.debug("sanitizeDirective called with", args); + if (typeof args !== "object" || args == null) { + return; + } + if (Array.isArray(args)) { + args.forEach((arg) => sanitizeDirective(arg)); + return; + } + for (const key of Object.keys(args)) { + log$1.debug("Checking key", key); + if (key.startsWith("__") || key.includes("proto") || key.includes("constr") || !configKeys.has(key) || args[key] == null) { + log$1.debug("sanitize deleting key: ", key); + delete args[key]; + continue; + } + if (typeof args[key] === "object") { + log$1.debug("sanitizing object", key); + sanitizeDirective(args[key]); + continue; + } + const cssMatchers = ["themeCSS", "fontFamily", "altFontFamily"]; + for (const cssKey of cssMatchers) { + if (key.includes(cssKey)) { + log$1.debug("sanitizing css option", key); + args[key] = sanitizeCss(args[key]); + } + } + } + if (args.themeVariables) { + for (const k of Object.keys(args.themeVariables)) { + const val = args.themeVariables[k]; + if ((val == null ? void 0 : val.match) && !val.match(/^[\d "#%(),.;A-Za-z]+$/)) { + args.themeVariables[k] = ""; + } + } + } + log$1.debug("After sanitization", args); +}; +const sanitizeCss = (str2) => { + let startCnt = 0; + let endCnt = 0; + for (const element of str2) { + if (startCnt < endCnt) { + return "{ /* ERROR: Unbalanced CSS */ }"; + } + if (element === "{") { + startCnt++; + } else if (element === "}") { + endCnt++; + } + } + if (startCnt !== endCnt) { + return "{ /* ERROR: Unbalanced CSS */ }"; + } + return str2; +}; +const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s; +const directiveRegex = /%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; +const anyCommentRegex = /\s*%%.*\n/gm; +class UnknownDiagramError extends Error { + constructor(message) { + super(message); + this.name = "UnknownDiagramError"; + } +} +const detectors = {}; +const detectType = function(text, config2) { + text = text.replace(frontMatterRegex, "").replace(directiveRegex, "").replace(anyCommentRegex, "\n"); + for (const [key, { detector: detector2 }] of Object.entries(detectors)) { + const diagram2 = detector2(text, config2); + if (diagram2) { + return key; + } + } + throw new UnknownDiagramError( + `No diagram type detected matching given configuration for text: ${text}` + ); +}; +const registerLazyLoadedDiagrams = (...diagrams2) => { + for (const { id: id2, detector: detector2, loader: loader2 } of diagrams2) { + addDetector(id2, detector2, loader2); + } +}; +const addDetector = (key, detector2, loader2) => { + if (detectors[key]) { + log$1.error(`Detector with key ${key} already exists`); + } else { + detectors[key] = { detector: detector2, loader: loader2 }; + } + log$1.debug(`Detector with key ${key} added${loader2 ? " with loader" : ""}`); +}; +const getDiagramLoader = (key) => { + return detectors[key].loader; +}; +const assignWithDepth = (dst, src, { depth = 2, clobber = false } = {}) => { + const config2 = { depth, clobber }; + if (Array.isArray(src) && !Array.isArray(dst)) { + src.forEach((s) => assignWithDepth(dst, s, config2)); + return dst; + } else if (Array.isArray(src) && Array.isArray(dst)) { + src.forEach((s) => { + if (!dst.includes(s)) { + dst.push(s); + } + }); + return dst; + } + if (dst === void 0 || depth <= 0) { + if (dst !== void 0 && dst !== null && typeof dst === "object" && typeof src === "object") { + return Object.assign(dst, src); + } else { + return src; + } + } + if (src !== void 0 && typeof dst === "object" && typeof src === "object") { + Object.keys(src).forEach((key) => { + if (typeof src[key] === "object" && (dst[key] === void 0 || typeof dst[key] === "object")) { + if (dst[key] === void 0) { + dst[key] = Array.isArray(src[key]) ? [] : {}; + } + dst[key] = assignWithDepth(dst[key], src[key], { depth: depth - 1, clobber }); + } else if (clobber || typeof dst[key] !== "object" && typeof src[key] !== "object") { + dst[key] = src[key]; + } + }); + } + return dst; +}; +const assignWithDepth$1 = assignWithDepth; +const ZERO_WIDTH_SPACE = "​"; +const d3CurveTypes = { + curveBasis, + curveBasisClosed, + curveBasisOpen, + curveBumpX: bumpX, + curveBumpY: bumpY, + curveBundle, + curveCardinalClosed, + curveCardinalOpen, + curveCardinal, + curveCatmullRomClosed, + curveCatmullRomOpen, + curveCatmullRom, + curveLinear, + curveLinearClosed, + curveMonotoneX: monotoneX, + curveMonotoneY: monotoneY, + curveNatural, + curveStep, + curveStepAfter: stepAfter, + curveStepBefore: stepBefore +}; +const directiveWithoutOpen = /\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; +const detectInit = function(text, config2) { + const inits = detectDirective(text, /(?:init\b)|(?:initialize\b)/); + let results = {}; + if (Array.isArray(inits)) { + const args = inits.map((init2) => init2.args); + sanitizeDirective(args); + results = assignWithDepth$1(results, [...args]); + } else { + results = inits.args; + } + if (!results) { + return; + } + let type2 = detectType(text, config2); + const prop = "config"; + if (results[prop] !== void 0) { + if (type2 === "flowchart-v2") { + type2 = "flowchart"; + } + results[type2] = results[prop]; + delete results[prop]; + } + return results; +}; +const detectDirective = function(text, type2 = null) { + try { + const commentWithoutDirectives = new RegExp( + `[%]{2}(?![{]${directiveWithoutOpen.source})(?=[}][%]{2}).* +`, + "ig" + ); + text = text.trim().replace(commentWithoutDirectives, "").replace(/'/gm, '"'); + log$1.debug( + `Detecting diagram directive${type2 !== null ? " type:" + type2 : ""} based on the text:${text}` + ); + let match; + const result = []; + while ((match = directiveRegex.exec(text)) !== null) { + if (match.index === directiveRegex.lastIndex) { + directiveRegex.lastIndex++; + } + if (match && !type2 || type2 && match[1] && match[1].match(type2) || type2 && match[2] && match[2].match(type2)) { + const type22 = match[1] ? match[1] : match[2]; + const args = match[3] ? match[3].trim() : match[4] ? JSON.parse(match[4].trim()) : null; + result.push({ type: type22, args }); + } + } + if (result.length === 0) { + return { type: text, args: null }; + } + return result.length === 1 ? result[0] : result; + } catch (error) { + log$1.error( + `ERROR: ${error.message} - Unable to parse directive type: '${type2}' based on the text: '${text}'` + ); + return { type: void 0, args: null }; + } +}; +const removeDirectives = function(text) { + return text.replace(directiveRegex, ""); +}; +const isSubstringInArray = function(str2, arr) { + for (const [i, element] of arr.entries()) { + if (element.match(str2)) { + return i; + } + } + return -1; +}; +function interpolateToCurve(interpolate, defaultCurve) { + if (!interpolate) { + return defaultCurve; + } + const curveName = `curve${interpolate.charAt(0).toUpperCase() + interpolate.slice(1)}`; + return d3CurveTypes[curveName] ?? defaultCurve; +} +function formatUrl(linkStr, config2) { + const url = linkStr.trim(); + if (!url) { + return void 0; + } + if (config2.securityLevel !== "loose") { + return dist$1.sanitizeUrl(url); + } + return url; +} +const runFunc = (functionName, ...params) => { + const arrPaths = functionName.split("."); + const len = arrPaths.length - 1; + const fnName = arrPaths[len]; + let obj = window; + for (let i = 0; i < len; i++) { + obj = obj[arrPaths[i]]; + if (!obj) { + log$1.error(`Function name: ${functionName} not found in window`); + return; + } + } + obj[fnName](...params); +}; +function distance(p1, p2) { + if (!p1 || !p2) { + return 0; + } + return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); +} +function traverseEdge(points) { + let prevPoint; + let totalDistance = 0; + points.forEach((point) => { + totalDistance += distance(point, prevPoint); + prevPoint = point; + }); + const remainingDistance = totalDistance / 2; + return calculatePoint(points, remainingDistance); +} +function calcLabelPosition(points) { + if (points.length === 1) { + return points[0]; + } + return traverseEdge(points); +} +const roundNumber = (num, precision = 2) => { + const factor = Math.pow(10, precision); + return Math.round(num * factor) / factor; +}; +const calculatePoint = (points, distanceToTraverse) => { + let prevPoint = void 0; + let remainingDistance = distanceToTraverse; + for (const point of points) { + if (prevPoint) { + const vectorDistance = distance(point, prevPoint); + if (vectorDistance < remainingDistance) { + remainingDistance -= vectorDistance; + } else { + const distanceRatio = remainingDistance / vectorDistance; + if (distanceRatio <= 0) { + return prevPoint; + } + if (distanceRatio >= 1) { + return { x: point.x, y: point.y }; + } + if (distanceRatio > 0 && distanceRatio < 1) { + return { + x: roundNumber((1 - distanceRatio) * prevPoint.x + distanceRatio * point.x, 5), + y: roundNumber((1 - distanceRatio) * prevPoint.y + distanceRatio * point.y, 5) + }; + } + } + } + prevPoint = point; + } + throw new Error("Could not find a suitable point for the given distance"); +}; +const calcCardinalityPosition = (isRelationTypePresent, points, initialPosition) => { + log$1.info(`our points ${JSON.stringify(points)}`); + if (points[0] !== initialPosition) { + points = points.reverse(); + } + const distanceToCardinalityPoint = 25; + const center = calculatePoint(points, distanceToCardinalityPoint); + const d = isRelationTypePresent ? 10 : 5; + const angle = Math.atan2(points[0].y - center.y, points[0].x - center.x); + const cardinalityPosition = { x: 0, y: 0 }; + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2; + return cardinalityPosition; +}; +function calcTerminalLabelPosition(terminalMarkerSize, position, _points) { + const points = structuredClone(_points); + log$1.info("our points", points); + if (position !== "start_left" && position !== "start_right") { + points.reverse(); + } + const distanceToCardinalityPoint = 25 + terminalMarkerSize; + const center = calculatePoint(points, distanceToCardinalityPoint); + const d = 10 + terminalMarkerSize * 0.5; + const angle = Math.atan2(points[0].y - center.y, points[0].x - center.x); + const cardinalityPosition = { x: 0, y: 0 }; + if (position === "start_left") { + cardinalityPosition.x = Math.sin(angle + Math.PI) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle + Math.PI) * d + (points[0].y + center.y) / 2; + } else if (position === "end_right") { + cardinalityPosition.x = Math.sin(angle - Math.PI) * d + (points[0].x + center.x) / 2 - 5; + cardinalityPosition.y = -Math.cos(angle - Math.PI) * d + (points[0].y + center.y) / 2 - 5; + } else if (position === "end_left") { + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2 - 5; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2 - 5; + } else { + cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2; + cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2; + } + return cardinalityPosition; +} +function getStylesFromArray(arr) { + let style = ""; + let labelStyle = ""; + for (const element of arr) { + if (element !== void 0) { + if (element.startsWith("color:") || element.startsWith("text-align:")) { + labelStyle = labelStyle + element + ";"; + } else { + style = style + element + ";"; + } + } + } + return { style, labelStyle }; +} +let cnt$2 = 0; +const generateId$2 = () => { + cnt$2++; + return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt$2; +}; +function makeRandomHex(length) { + let result = ""; + const characters = "0123456789abcdef"; + const charactersLength = characters.length; + for (let i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +} +const random = (options) => { + return makeRandomHex(options.length); +}; +const getTextObj$3 = function() { + return { + x: 0, + y: 0, + fill: void 0, + anchor: "start", + style: "#666", + width: 100, + height: 100, + textMargin: 0, + rx: 0, + ry: 0, + valign: void 0, + text: "" + }; +}; +const drawSimpleText = function(elem, textData) { + const nText = textData.text.replace(common$1.lineBreakRegex, " "); + const [, _fontSizePx] = parseFontSize(textData.fontSize); + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.style("text-anchor", textData.anchor); + textElem.style("font-family", textData.fontFamily); + textElem.style("font-size", _fontSizePx); + textElem.style("font-weight", textData.fontWeight); + textElem.attr("fill", textData.fill); + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + const span = textElem.append("tspan"); + span.attr("x", textData.x + textData.textMargin * 2); + span.attr("fill", textData.fill); + span.text(nText); + return textElem; +}; +const wrapLabel = memoize$2( + (label, maxWidth, config2) => { + if (!label) { + return label; + } + config2 = Object.assign( + { fontSize: 12, fontWeight: 400, fontFamily: "Arial", joinWith: "
    " }, + config2 + ); + if (common$1.lineBreakRegex.test(label)) { + return label; + } + const words = label.split(" "); + const completedLines = []; + let nextLine = ""; + words.forEach((word, index) => { + const wordLength = calculateTextWidth(`${word} `, config2); + const nextLineLength = calculateTextWidth(nextLine, config2); + if (wordLength > maxWidth) { + const { hyphenatedStrings, remainingWord } = breakString(word, maxWidth, "-", config2); + completedLines.push(nextLine, ...hyphenatedStrings); + nextLine = remainingWord; + } else if (nextLineLength + wordLength >= maxWidth) { + completedLines.push(nextLine); + nextLine = word; + } else { + nextLine = [nextLine, word].filter(Boolean).join(" "); + } + const currentWord = index + 1; + const isLastWord = currentWord === words.length; + if (isLastWord) { + completedLines.push(nextLine); + } + }); + return completedLines.filter((line) => line !== "").join(config2.joinWith); + }, + (label, maxWidth, config2) => `${label}${maxWidth}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}${config2.joinWith}` +); +const breakString = memoize$2( + (word, maxWidth, hyphenCharacter = "-", config2) => { + config2 = Object.assign( + { fontSize: 12, fontWeight: 400, fontFamily: "Arial", margin: 0 }, + config2 + ); + const characters = [...word]; + const lines = []; + let currentLine = ""; + characters.forEach((character, index) => { + const nextLine = `${currentLine}${character}`; + const lineWidth = calculateTextWidth(nextLine, config2); + if (lineWidth >= maxWidth) { + const currentCharacter = index + 1; + const isLastLine = characters.length === currentCharacter; + const hyphenatedNextLine = `${nextLine}${hyphenCharacter}`; + lines.push(isLastLine ? nextLine : hyphenatedNextLine); + currentLine = ""; + } else { + currentLine = nextLine; + } + }); + return { hyphenatedStrings: lines, remainingWord: currentLine }; + }, + (word, maxWidth, hyphenCharacter = "-", config2) => `${word}${maxWidth}${hyphenCharacter}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}` +); +function calculateTextHeight(text, config2) { + return calculateTextDimensions(text, config2).height; +} +function calculateTextWidth(text, config2) { + return calculateTextDimensions(text, config2).width; +} +const calculateTextDimensions = memoize$2( + (text, config2) => { + const { fontSize = 12, fontFamily = "Arial", fontWeight = 400 } = config2; + if (!text) { + return { width: 0, height: 0 }; + } + const [, _fontSizePx] = parseFontSize(fontSize); + const fontFamilies = ["sans-serif", fontFamily]; + const lines = text.split(common$1.lineBreakRegex); + const dims = []; + const body = select("body"); + if (!body.remove) { + return { width: 0, height: 0, lineHeight: 0 }; + } + const g = body.append("svg"); + for (const fontFamily2 of fontFamilies) { + let cHeight = 0; + const dim = { width: 0, height: 0, lineHeight: 0 }; + for (const line of lines) { + const textObj = getTextObj$3(); + textObj.text = line || ZERO_WIDTH_SPACE; + const textElem = drawSimpleText(g, textObj).style("font-size", _fontSizePx).style("font-weight", fontWeight).style("font-family", fontFamily2); + const bBox = (textElem._groups || textElem)[0][0].getBBox(); + if (bBox.width === 0 && bBox.height === 0) { + throw new Error("svg element not in render tree"); + } + dim.width = Math.round(Math.max(dim.width, bBox.width)); + cHeight = Math.round(bBox.height); + dim.height += cHeight; + dim.lineHeight = Math.round(Math.max(dim.lineHeight, cHeight)); + } + dims.push(dim); + } + g.remove(); + const index = isNaN(dims[1].height) || isNaN(dims[1].width) || isNaN(dims[1].lineHeight) || dims[0].height > dims[1].height && dims[0].width > dims[1].width && dims[0].lineHeight > dims[1].lineHeight ? 0 : 1; + return dims[index]; + }, + (text, config2) => `${text}${config2.fontSize}${config2.fontWeight}${config2.fontFamily}` +); +class InitIDGenerator { + constructor(deterministic = false, seed) { + this.count = 0; + this.count = seed ? seed.length : 0; + this.next = deterministic ? () => this.count++ : () => Date.now(); + } +} +let decoder; +const entityDecode = function(html) { + decoder = decoder || document.createElement("div"); + html = escape(html).replace(/%26/g, "&").replace(/%23/g, "#").replace(/%3B/g, ";"); + decoder.innerHTML = html; + return unescape(decoder.textContent); +}; +function isDetailedError(error) { + return "str" in error; +} +const insertTitle = (parent, cssClass, titleTopMargin, title) => { + var _a; + if (!title) { + return; + } + const bounds = (_a = parent.node()) == null ? void 0 : _a.getBBox(); + if (!bounds) { + return; + } + parent.append("text").text(title).attr("x", bounds.x + bounds.width / 2).attr("y", -titleTopMargin).attr("class", cssClass); +}; +const parseFontSize = (fontSize) => { + if (typeof fontSize === "number") { + return [fontSize, fontSize + "px"]; + } + const fontSizeNumber = parseInt(fontSize ?? "", 10); + if (Number.isNaN(fontSizeNumber)) { + return [void 0, void 0]; + } else if (fontSize === String(fontSizeNumber)) { + return [fontSizeNumber, fontSize + "px"]; + } else { + return [fontSizeNumber, fontSize]; + } +}; +function cleanAndMerge(defaultData, data) { + return merge$2({}, defaultData, data); +} +const utils = { + assignWithDepth: assignWithDepth$1, + wrapLabel, + calculateTextHeight, + calculateTextWidth, + calculateTextDimensions, + cleanAndMerge, + detectInit, + detectDirective, + isSubstringInArray, + interpolateToCurve, + calcLabelPosition, + calcCardinalityPosition, + calcTerminalLabelPosition, + formatUrl, + getStylesFromArray, + generateId: generateId$2, + random, + runFunc, + entityDecode, + insertTitle, + parseFontSize, + InitIDGenerator +}; +const encodeEntities = function(text) { + let txt = text; + txt = txt.replace(/style.*:\S*#.*;/g, function(s) { + return s.substring(0, s.length - 1); + }); + txt = txt.replace(/classDef.*:\S*#.*;/g, function(s) { + return s.substring(0, s.length - 1); + }); + txt = txt.replace(/#\w+;/g, function(s) { + const innerTxt = s.substring(1, s.length - 1); + const isInt = /^\+?\d+$/.test(innerTxt); + if (isInt) { + return "fl°°" + innerTxt + "¶ß"; + } else { + return "fl°" + innerTxt + "¶ß"; + } + }); + return txt; +}; +const decodeEntities = function(text) { + return text.replace(/fl°°/g, "&#").replace(/fl°/g, "&").replace(/¶ß/g, ";"); +}; +const version$2 = "10.9.1"; +const defaultConfig$1 = Object.freeze(defaultConfig$2); +let siteConfig = assignWithDepth$1({}, defaultConfig$1); +let configFromInitialize; +let directives = []; +let currentConfig = assignWithDepth$1({}, defaultConfig$1); +const updateCurrentConfig = (siteCfg, _directives) => { + let cfg = assignWithDepth$1({}, siteCfg); + let sumOfDirectives = {}; + for (const d of _directives) { + sanitize(d); + sumOfDirectives = assignWithDepth$1(sumOfDirectives, d); + } + cfg = assignWithDepth$1(cfg, sumOfDirectives); + if (sumOfDirectives.theme && sumOfDirectives.theme in theme) { + const tmpConfigFromInitialize = assignWithDepth$1({}, configFromInitialize); + const themeVariables = assignWithDepth$1( + tmpConfigFromInitialize.themeVariables || {}, + sumOfDirectives.themeVariables + ); + if (cfg.theme && cfg.theme in theme) { + cfg.themeVariables = theme[cfg.theme].getThemeVariables(themeVariables); + } + } + currentConfig = cfg; + checkConfig(currentConfig); + return currentConfig; +}; +const setSiteConfig = (conf) => { + siteConfig = assignWithDepth$1({}, defaultConfig$1); + siteConfig = assignWithDepth$1(siteConfig, conf); + if (conf.theme && theme[conf.theme]) { + siteConfig.themeVariables = theme[conf.theme].getThemeVariables(conf.themeVariables); + } + updateCurrentConfig(siteConfig, directives); + return siteConfig; +}; +const saveConfigFromInitialize = (conf) => { + configFromInitialize = assignWithDepth$1({}, conf); +}; +const updateSiteConfig = (conf) => { + siteConfig = assignWithDepth$1(siteConfig, conf); + updateCurrentConfig(siteConfig, directives); + return siteConfig; +}; +const getSiteConfig = () => { + return assignWithDepth$1({}, siteConfig); +}; +const setConfig$1 = (conf) => { + checkConfig(conf); + assignWithDepth$1(currentConfig, conf); + return getConfig$1(); +}; +const getConfig$1 = () => { + return assignWithDepth$1({}, currentConfig); +}; +const sanitize = (options) => { + if (!options) { + return; + } + ["secure", ...siteConfig.secure ?? []].forEach((key) => { + if (Object.hasOwn(options, key)) { + log$1.debug(`Denied attempt to modify a secure key ${key}`, options[key]); + delete options[key]; + } + }); + Object.keys(options).forEach((key) => { + if (key.startsWith("__")) { + delete options[key]; + } + }); + Object.keys(options).forEach((key) => { + if (typeof options[key] === "string" && (options[key].includes("<") || options[key].includes(">") || options[key].includes("url(data:"))) { + delete options[key]; + } + if (typeof options[key] === "object") { + sanitize(options[key]); + } + }); +}; +const addDirective = (directive) => { + sanitizeDirective(directive); + if (directive.fontFamily && (!directive.themeVariables || !directive.themeVariables.fontFamily)) { + directive.themeVariables = { fontFamily: directive.fontFamily }; + } + directives.push(directive); + updateCurrentConfig(siteConfig, directives); +}; +const reset = (config2 = siteConfig) => { + directives = []; + updateCurrentConfig(config2, directives); +}; +const ConfigWarning = { + LAZY_LOAD_DEPRECATED: "The configuration options lazyLoadedDiagrams and loadExternalDiagramsAtStartup are deprecated. Please use registerExternalDiagrams instead." +}; +const issuedWarnings = {}; +const issueWarning = (warning) => { + if (issuedWarnings[warning]) { + return; + } + log$1.warn(ConfigWarning[warning]); + issuedWarnings[warning] = true; +}; +const checkConfig = (config2) => { + if (!config2) { + return; + } + if (config2.lazyLoadedDiagrams || config2.loadExternalDiagramsAtStartup) { + issueWarning("LAZY_LOAD_DEPRECATED"); + } +}; +const id$l = "c4"; +const detector$l = (txt) => { + return /^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(txt); +}; +const loader$m = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return c4DiagramAe766693; }); + return { id: id$l, diagram: diagram2 }; +}; +const plugin$j = { + id: id$l, + detector: detector$l, + loader: loader$m +}; +const c4 = plugin$j; +const id$k = "flowchart"; +const detector$k = (txt, config2) => { + var _a, _b; + if (((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper" || ((_b = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _b.defaultRenderer) === "elk") { + return false; + } + return /^\s*graph/.test(txt); +}; +const loader$l = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return flowDiagramB222e15a; }); + return { id: id$k, diagram: diagram2 }; +}; +const plugin$i = { + id: id$k, + detector: detector$k, + loader: loader$l +}; +const flowchart = plugin$i; +const id$j = "flowchart-v2"; +const detector$j = (txt, config2) => { + var _a, _b, _c; + if (((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "dagre-d3" || ((_b = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _b.defaultRenderer) === "elk") { + return false; + } + if (/^\s*graph/.test(txt) && ((_c = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _c.defaultRenderer) === "dagre-wrapper") { + return true; + } + return /^\s*flowchart/.test(txt); +}; +const loader$k = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return flowDiagramV213329dc7; }); + return { id: id$j, diagram: diagram2 }; +}; +const plugin$h = { + id: id$j, + detector: detector$j, + loader: loader$k +}; +const flowchartV2 = plugin$h; +const id$i = "er"; +const detector$i = (txt) => { + return /^\s*erDiagram/.test(txt); +}; +const loader$j = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return erDiagram09d1c15f; }); + return { id: id$i, diagram: diagram2 }; +}; +const plugin$g = { + id: id$i, + detector: detector$i, + loader: loader$j +}; +const er = plugin$g; +const id$h = "gitGraph"; +const detector$h = (txt) => { + return /^\s*gitGraph/.test(txt); +}; +const loader$i = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return gitGraphDiagram942e62fe; }); + return { id: id$h, diagram: diagram2 }; +}; +const plugin$f = { + id: id$h, + detector: detector$h, + loader: loader$i +}; +const git = plugin$f; +const id$g = "gantt"; +const detector$g = (txt) => { + return /^\s*gantt/.test(txt); +}; +const loader$h = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return ganttDiagramB62c793e; }); + return { id: id$g, diagram: diagram2 }; +}; +const plugin$e = { + id: id$g, + detector: detector$g, + loader: loader$h +}; +const gantt = plugin$e; +const id$f = "info"; +const detector$f = (txt) => { + return /^\s*info/.test(txt); +}; +const loader$g = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return infoDiagram94cd232f; }); + return { id: id$f, diagram: diagram2 }; +}; +const info$1 = { + id: id$f, + detector: detector$f, + loader: loader$g +}; +const id$e = "pie"; +const detector$e = (txt) => { + return /^\s*pie/.test(txt); +}; +const loader$f = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return pieDiagramBb1d19e5; }); + return { id: id$e, diagram: diagram2 }; +}; +const pie = { + id: id$e, + detector: detector$e, + loader: loader$f +}; +const id$d = "quadrantChart"; +const detector$d = (txt) => { + return /^\s*quadrantChart/.test(txt); +}; +const loader$e = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return quadrantDiagramC759a472; }); + return { id: id$d, diagram: diagram2 }; +}; +const plugin$d = { + id: id$d, + detector: detector$d, + loader: loader$e +}; +const quadrantChart = plugin$d; +const id$c = "xychart"; +const detector$c = (txt) => { + return /^\s*xychart-beta/.test(txt); +}; +const loader$d = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return xychartDiagramF11f50a6; }); + return { id: id$c, diagram: diagram2 }; +}; +const plugin$c = { + id: id$c, + detector: detector$c, + loader: loader$d +}; +const xychart = plugin$c; +const id$b = "requirement"; +const detector$b = (txt) => { + return /^\s*requirement(Diagram)?/.test(txt); +}; +const loader$c = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return requirementDiagram87253d64; }); + return { id: id$b, diagram: diagram2 }; +}; +const plugin$b = { + id: id$b, + detector: detector$b, + loader: loader$c +}; +const requirement = plugin$b; +const id$a = "sequence"; +const detector$a = (txt) => { + return /^\s*sequenceDiagram/.test(txt); +}; +const loader$b = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return sequenceDiagram6894f283; }); + return { id: id$a, diagram: diagram2 }; +}; +const plugin$a = { + id: id$a, + detector: detector$a, + loader: loader$b +}; +const sequence = plugin$a; +const id$9 = "class"; +const detector$9 = (txt, config2) => { + var _a; + if (((_a = config2 == null ? void 0 : config2.class) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return false; + } + return /^\s*classDiagram/.test(txt); +}; +const loader$a = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return classDiagramFb54d2a0; }); + return { id: id$9, diagram: diagram2 }; +}; +const plugin$9 = { + id: id$9, + detector: detector$9, + loader: loader$a +}; +const classDiagram = plugin$9; +const id$8 = "classDiagram"; +const detector$8 = (txt, config2) => { + var _a; + if (/^\s*classDiagram/.test(txt) && ((_a = config2 == null ? void 0 : config2.class) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return true; + } + return /^\s*classDiagram-v2/.test(txt); +}; +const loader$9 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return classDiagramV2A2b738ad; }); + return { id: id$8, diagram: diagram2 }; +}; +const plugin$8 = { + id: id$8, + detector: detector$8, + loader: loader$9 +}; +const classDiagramV2 = plugin$8; +const id$7 = "state"; +const detector$7 = (txt, config2) => { + var _a; + if (((_a = config2 == null ? void 0 : config2.state) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return false; + } + return /^\s*stateDiagram/.test(txt); +}; +const loader$8 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return stateDiagram5dee940d; }); + return { id: id$7, diagram: diagram2 }; +}; +const plugin$7 = { + id: id$7, + detector: detector$7, + loader: loader$8 +}; +const state$1 = plugin$7; +const id$6 = "stateDiagram"; +const detector$6 = (txt, config2) => { + var _a; + if (/^\s*stateDiagram-v2/.test(txt)) { + return true; + } + if (/^\s*stateDiagram/.test(txt) && ((_a = config2 == null ? void 0 : config2.state) == null ? void 0 : _a.defaultRenderer) === "dagre-wrapper") { + return true; + } + return false; +}; +const loader$7 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return stateDiagramV21992cada; }); + return { id: id$6, diagram: diagram2 }; +}; +const plugin$6 = { + id: id$6, + detector: detector$6, + loader: loader$7 +}; +const stateV2 = plugin$6; +const id$5 = "journey"; +const detector$5 = (txt) => { + return /^\s*journey/.test(txt); +}; +const loader$6 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return journeyDiagram6625b456; }); + return { id: id$5, diagram: diagram2 }; +}; +const plugin$5 = { + id: id$5, + detector: detector$5, + loader: loader$6 +}; +const journey = plugin$5; +const d3Attrs = function(d3Elem, attrs) { + for (let attr of attrs) { + d3Elem.attr(attr[0], attr[1]); + } +}; +const calculateSvgSizeAttrs = function(height, width, useMaxWidth) { + let attrs = /* @__PURE__ */ new Map(); + if (useMaxWidth) { + attrs.set("width", "100%"); + attrs.set("style", `max-width: ${width}px;`); + } else { + attrs.set("height", height); + attrs.set("width", width); + } + return attrs; +}; +const configureSvgSize = function(svgElem, height, width, useMaxWidth) { + const attrs = calculateSvgSizeAttrs(height, width, useMaxWidth); + d3Attrs(svgElem, attrs); +}; +const setupGraphViewbox$1 = function(graph, svgElem, padding, useMaxWidth) { + const svgBounds = svgElem.node().getBBox(); + const sWidth = svgBounds.width; + const sHeight = svgBounds.height; + log$1.info(`SVG bounds: ${sWidth}x${sHeight}`, svgBounds); + let width = 0; + let height = 0; + log$1.info(`Graph bounds: ${width}x${height}`, graph); + width = sWidth + padding * 2; + height = sHeight + padding * 2; + log$1.info(`Calculated bounds: ${width}x${height}`); + configureSvgSize(svgElem, height, width, useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${svgBounds.width + 2 * padding} ${svgBounds.height + 2 * padding}`; + svgElem.attr("viewBox", vBox); +}; +const themes = {}; +const getStyles$f = (type2, userStyles, options) => { + let diagramStyles = ""; + if (type2 in themes && themes[type2]) { + diagramStyles = themes[type2](options); + } else { + log$1.warn(`No theme found for ${type2}`); + } + return ` & { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + fill: ${options.textColor} + } + + /* Classes common for multiple diagrams */ + + & .error-icon { + fill: ${options.errorBkgColor}; + } + & .error-text { + fill: ${options.errorTextColor}; + stroke: ${options.errorTextColor}; + } + + & .edge-thickness-normal { + stroke-width: 2px; + } + & .edge-thickness-thick { + stroke-width: 3.5px + } + & .edge-pattern-solid { + stroke-dasharray: 0; + } + + & .edge-pattern-dashed{ + stroke-dasharray: 3; + } + .edge-pattern-dotted { + stroke-dasharray: 2; + } + + & .marker { + fill: ${options.lineColor}; + stroke: ${options.lineColor}; + } + & .marker.cross { + stroke: ${options.lineColor}; + } + + & svg { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + } + + ${diagramStyles} + + ${userStyles} +`; +}; +const addStylesForDiagram = (type2, diagramTheme) => { + if (diagramTheme !== void 0) { + themes[type2] = diagramTheme; + } +}; +const getStyles$1$1 = getStyles$f; +let accTitle = ""; +let diagramTitle = ""; +let accDescription = ""; +const sanitizeText$1$1 = (txt) => sanitizeText$2$1(txt, getConfig$1()); +const clear$k = () => { + accTitle = ""; + accDescription = ""; + diagramTitle = ""; +}; +const setAccTitle = (txt) => { + accTitle = sanitizeText$1$1(txt).replace(/^\s+/g, ""); +}; +const getAccTitle = () => accTitle; +const setAccDescription = (txt) => { + accDescription = sanitizeText$1$1(txt).replace(/\n\s+/g, "\n"); +}; +const getAccDescription = () => accDescription; +const setDiagramTitle = (txt) => { + diagramTitle = sanitizeText$1$1(txt); +}; +const getDiagramTitle = () => diagramTitle; +const commonDb = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + clear: clear$k, + getAccDescription, + getAccTitle, + getDiagramTitle, + setAccDescription, + setAccTitle, + setDiagramTitle +}, Symbol.toStringTag, { value: "Module" })); +const log = log$1; +const setLogLevel = setLogLevel$1; +const getConfig$2 = getConfig$1; +const setConfig = setConfig$1; +const defaultConfig = defaultConfig$1; +const sanitizeText$4 = (text) => sanitizeText$2$1(text, getConfig$2()); +const setupGraphViewbox = setupGraphViewbox$1; +const getCommonDb$1 = () => { + return commonDb; +}; +const diagrams = {}; +const registerDiagram = (id2, diagram2, detector2) => { + var _a; + if (diagrams[id2]) { + throw new Error(`Diagram ${id2} already registered.`); + } + diagrams[id2] = diagram2; + if (detector2) { + addDetector(id2, detector2); + } + addStylesForDiagram(id2, diagram2.styles); + (_a = diagram2.injectUtils) == null ? void 0 : _a.call( + diagram2, + log, + setLogLevel, + getConfig$2, + sanitizeText$4, + setupGraphViewbox, + getCommonDb$1(), + () => { + } + ); +}; +const getDiagram = (name) => { + if (name in diagrams) { + return diagrams[name]; + } + throw new DiagramNotFoundError(name); +}; +class DiagramNotFoundError extends Error { + constructor(name) { + super(`Diagram ${name} not found.`); + } +} +const selectSvgElement = (id2) => { + var _a; + const { securityLevel } = getConfig$2(); + let root = select("body"); + if (securityLevel === "sandbox") { + const sandboxElement = select(`#i${id2}`); + const doc = ((_a = sandboxElement.node()) == null ? void 0 : _a.contentDocument) ?? document; + root = select(doc.body); + } + const svg = root.select(`#${id2}`); + return svg; +}; +const draw$m = (_text, id2, version2) => { + log$1.debug("rendering svg for syntax error\n"); + const svg = selectSvgElement(id2); + const g = svg.append("g"); + svg.attr("viewBox", "0 0 2412 512"); + configureSvgSize(svg, 100, 512, true); + g.append("path").attr("class", "error-icon").attr( + "d", + "m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z" + ); + g.append("path").attr("class", "error-icon").attr( + "d", + "m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z" + ); + g.append("text").attr("class", "error-text").attr("x", 1440).attr("y", 250).attr("font-size", "150px").style("text-anchor", "middle").text("Syntax error in text"); + g.append("text").attr("class", "error-text").attr("x", 1250).attr("y", 400).attr("font-size", "100px").style("text-anchor", "middle").text(`mermaid version ${version2}`); +}; +const renderer$i = { draw: draw$m }; +const errorRenderer = renderer$i; +const diagram$m = { + db: {}, + renderer: renderer$i, + parser: { + parser: { yy: {} }, + parse: () => { + return; + } + } +}; +const errorDiagram = diagram$m; +const id$4 = "flowchart-elk"; +const detector$4 = (txt, config2) => { + var _a; + if ( + // If diagram explicitly states flowchart-elk + /^\s*flowchart-elk/.test(txt) || // If a flowchart/graph diagram has their default renderer set to elk + /^\s*flowchart|graph/.test(txt) && ((_a = config2 == null ? void 0 : config2.flowchart) == null ? void 0 : _a.defaultRenderer) === "elk" + ) { + return true; + } + return false; +}; +const loader$5 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return flowchartElkDefinitionAe0efee6; }); + return { id: id$4, diagram: diagram2 }; +}; +const plugin$4 = { + id: id$4, + detector: detector$4, + loader: loader$5 +}; +const flowchartElk = plugin$4; +const id$3 = "timeline"; +const detector$3 = (txt) => { + return /^\s*timeline/.test(txt); +}; +const loader$4 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return timelineDefinitionBf702344; }); + return { id: id$3, diagram: diagram2 }; +}; +const plugin$3 = { + id: id$3, + detector: detector$3, + loader: loader$4 +}; +const timeline = plugin$3; +const id$2 = "mindmap"; +const detector$2 = (txt) => { + return /^\s*mindmap/.test(txt); +}; +const loader$3 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return mindmapDefinition307c710a; }); + return { id: id$2, diagram: diagram2 }; +}; +const plugin$2 = { + id: id$2, + detector: detector$2, + loader: loader$3 +}; +const mindmap = plugin$2; +const id$1 = "sankey"; +const detector$1 = (txt) => { + return /^\s*sankey-beta/.test(txt); +}; +const loader$2 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return sankeyDiagram707fac0f; }); + return { id: id$1, diagram: diagram2 }; +}; +const plugin$1 = { + id: id$1, + detector: detector$1, + loader: loader$2 +}; +const sankey = plugin$1; +const id = "block"; +const detector = (txt) => { + return /^\s*block-beta/.test(txt); +}; +const loader$1 = async () => { + const { diagram: diagram2 } = await Promise.resolve().then(function () { return blockDiagram9f4a6865; }); + return { id, diagram: diagram2 }; +}; +const plugin = { + id, + detector, + loader: loader$1 +}; +const block = plugin; +let hasLoadedDiagrams = false; +const addDiagrams = () => { + if (hasLoadedDiagrams) { + return; + } + hasLoadedDiagrams = true; + registerDiagram("error", errorDiagram, (text) => { + return text.toLowerCase().trim() === "error"; + }); + registerDiagram( + "---", + // --- diagram type may appear if YAML front-matter is not parsed correctly + { + db: { + clear: () => { + } + }, + styles: {}, + // should never be used + renderer: { + draw: () => { + } + }, + parser: { + parser: { yy: {} }, + parse: () => { + throw new Error( + "Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks" + ); + } + }, + init: () => null + // no op + }, + (text) => { + return text.toLowerCase().trimStart().startsWith("---"); + } + ); + registerLazyLoadedDiagrams( + c4, + classDiagramV2, + classDiagram, + er, + gantt, + info$1, + pie, + requirement, + sequence, + flowchartElk, + flowchartV2, + flowchart, + mindmap, + timeline, + git, + stateV2, + state$1, + journey, + quadrantChart, + sankey, + xychart, + block + ); +}; +class Diagram { + constructor(text, metadata = {}) { + this.text = text; + this.metadata = metadata; + this.type = "graph"; + this.text = encodeEntities(text); + this.text += "\n"; + const cnf = getConfig$1(); + try { + this.type = detectType(text, cnf); + } catch (e) { + this.type = "error"; + this.detectError = e; + } + const diagram2 = getDiagram(this.type); + log$1.debug("Type " + this.type); + this.db = diagram2.db; + this.renderer = diagram2.renderer; + this.parser = diagram2.parser; + this.parser.parser.yy = this.db; + this.init = diagram2.init; + this.parse(); + } + parse() { + var _a, _b, _c, _d, _e; + if (this.detectError) { + throw this.detectError; + } + (_b = (_a = this.db).clear) == null ? void 0 : _b.call(_a); + const config2 = getConfig$1(); + (_c = this.init) == null ? void 0 : _c.call(this, config2); + if (this.metadata.title) { + (_e = (_d = this.db).setDiagramTitle) == null ? void 0 : _e.call(_d, this.metadata.title); + } + this.parser.parse(this.text); + } + async render(id2, version2) { + await this.renderer.draw(this.text, id2, version2, this); + } + getParser() { + return this.parser; + } + getType() { + return this.type; + } +} +const getDiagramFromText$1 = async (text, metadata = {}) => { + const type2 = detectType(text, getConfig$1()); + try { + getDiagram(type2); + } catch (error) { + const loader2 = getDiagramLoader(type2); + if (!loader2) { + throw new UnknownDiagramError(`Diagram ${type2} not found.`); + } + const { id: id2, diagram: diagram2 } = await loader2(); + registerDiagram(id2, diagram2); + } + return new Diagram(text, metadata); +}; +let interactionFunctions = []; +const attachFunctions = () => { + interactionFunctions.forEach((f) => { + f(); + }); + interactionFunctions = []; +}; +const SVG_ROLE = "graphics-document document"; +function setA11yDiagramInfo(svg, diagramType) { + svg.attr("role", SVG_ROLE); + if (diagramType !== "") { + svg.attr("aria-roledescription", diagramType); + } +} +function addSVGa11yTitleDescription(svg, a11yTitle, a11yDesc, baseId) { + if (svg.insert === void 0) { + return; + } + if (a11yDesc) { + const descId = `chart-desc-${baseId}`; + svg.attr("aria-describedby", descId); + svg.insert("desc", ":first-child").attr("id", descId).text(a11yDesc); + } + if (a11yTitle) { + const titleId = `chart-title-${baseId}`; + svg.attr("aria-labelledby", titleId); + svg.insert("title", ":first-child").attr("id", titleId).text(a11yTitle); + } +} +const cleanupComments = (text) => { + return text.replace(/^\s*%%(?!{)[^\n]+\n?/gm, "").trimStart(); +}; +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ +function isNothing(subject) { + return typeof subject === "undefined" || subject === null; +} +function isObject$1(subject) { + return typeof subject === "object" && subject !== null; +} +function toArray(sequence2) { + if (Array.isArray(sequence2)) + return sequence2; + else if (isNothing(sequence2)) + return []; + return [sequence2]; +} +function extend$1(target, source) { + var index, length, key, sourceKeys; + if (source) { + sourceKeys = Object.keys(source); + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + return target; +} +function repeat(string, count) { + var result = "", cycle; + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + return result; +} +function isNegativeZero(number) { + return number === 0 && Number.NEGATIVE_INFINITY === 1 / number; +} +var isNothing_1 = isNothing; +var isObject_1$1 = isObject$1; +var toArray_1 = toArray; +var repeat_1 = repeat; +var isNegativeZero_1 = isNegativeZero; +var extend_1 = extend$1; +var common = { + isNothing: isNothing_1, + isObject: isObject_1$1, + toArray: toArray_1, + repeat: repeat_1, + isNegativeZero: isNegativeZero_1, + extend: extend_1 +}; +function formatError(exception2, compact) { + var where = "", message = exception2.reason || "(unknown reason)"; + if (!exception2.mark) + return message; + if (exception2.mark.name) { + where += 'in "' + exception2.mark.name + '" '; + } + where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")"; + if (!compact && exception2.mark.snippet) { + where += "\n\n" + exception2.mark.snippet; + } + return message + " " + where; +} +function YAMLException$1(reason, mark) { + Error.call(this); + this.name = "YAMLException"; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error().stack || ""; + } +} +YAMLException$1.prototype = Object.create(Error.prototype); +YAMLException$1.prototype.constructor = YAMLException$1; +YAMLException$1.prototype.toString = function toString(compact) { + return this.name + ": " + formatError(this, compact); +}; +var exception = YAMLException$1; +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ""; + var tail = ""; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + if (position - lineStart > maxHalfLength) { + head = " ... "; + lineStart = position - maxHalfLength + head.length; + } + if (lineEnd - position > maxHalfLength) { + tail = " ..."; + lineEnd = position + maxHalfLength - tail.length; + } + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail, + pos: position - lineStart + head.length + // relative position + }; +} +function padStart(string, max) { + return common.repeat(" ", max - string.length) + string; +} +function makeSnippet(mark, options) { + options = Object.create(options || null); + if (!mark.buffer) + return null; + if (!options.maxLength) + options.maxLength = 79; + if (typeof options.indent !== "number") + options.indent = 1; + if (typeof options.linesBefore !== "number") + options.linesBefore = 3; + if (typeof options.linesAfter !== "number") + options.linesAfter = 2; + var re = /\r?\n|\r|\0/g; + var lineStarts = [0]; + var lineEnds = []; + var match; + var foundLineNo = -1; + while (match = re.exec(mark.buffer)) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + if (foundLineNo < 0) + foundLineNo = lineStarts.length - 1; + var result = "", i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) + break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result; + } + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n"; + result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n"; + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) + break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n"; + } + return result.replace(/\n$/, ""); +} +var snippet = makeSnippet; +var TYPE_CONSTRUCTOR_OPTIONS = [ + "kind", + "multi", + "resolve", + "construct", + "instanceOf", + "predicate", + "represent", + "representName", + "defaultStyle", + "styleAliases" +]; +var YAML_NODE_KINDS = [ + "scalar", + "sequence", + "mapping" +]; +function compileStyleAliases(map2) { + var result = {}; + if (map2 !== null) { + Object.keys(map2).forEach(function(style) { + map2[style].forEach(function(alias) { + result[String(alias)] = style; + }); + }); + } + return result; +} +function Type$1(tag, options) { + options = options || {}; + Object.keys(options).forEach(function(name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + this.options = options; + this.tag = tag; + this.kind = options["kind"] || null; + this.resolve = options["resolve"] || function() { + return true; + }; + this.construct = options["construct"] || function(data) { + return data; + }; + this.instanceOf = options["instanceOf"] || null; + this.predicate = options["predicate"] || null; + this.represent = options["represent"] || null; + this.representName = options["representName"] || null; + this.defaultStyle = options["defaultStyle"] || null; + this.multi = options["multi"] || false; + this.styleAliases = compileStyleAliases(options["styleAliases"] || null); + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} +var type = Type$1; +function compileList(schema2, name) { + var result = []; + schema2[name].forEach(function(currentType) { + var newIndex = result.length; + result.forEach(function(previousType, previousIndex) { + if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) { + newIndex = previousIndex; + } + }); + result[newIndex] = currentType; + }); + return result; +} +function compileMap() { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + function collectType(type2) { + if (type2.multi) { + result.multi[type2.kind].push(type2); + result.multi["fallback"].push(type2); + } else { + result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2; + } + } + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} +function Schema$1(definition) { + return this.extend(definition); +} +Schema$1.prototype.extend = function extend2(definition) { + var implicit = []; + var explicit = []; + if (definition instanceof type) { + explicit.push(definition); + } else if (Array.isArray(definition)) { + explicit = explicit.concat(definition); + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + if (definition.implicit) + implicit = implicit.concat(definition.implicit); + if (definition.explicit) + explicit = explicit.concat(definition.explicit); + } else { + throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })"); + } + implicit.forEach(function(type$1) { + if (!(type$1 instanceof type)) { + throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); + } + if (type$1.loadKind && type$1.loadKind !== "scalar") { + throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."); + } + if (type$1.multi) { + throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit."); + } + }); + explicit.forEach(function(type$1) { + if (!(type$1 instanceof type)) { + throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object."); + } + }); + var result = Object.create(Schema$1.prototype); + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + result.compiledImplicit = compileList(result, "implicit"); + result.compiledExplicit = compileList(result, "explicit"); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + return result; +}; +var schema = Schema$1; +var str = new type("tag:yaml.org,2002:str", { + kind: "scalar", + construct: function(data) { + return data !== null ? data : ""; + } +}); +var seq$1 = new type("tag:yaml.org,2002:seq", { + kind: "sequence", + construct: function(data) { + return data !== null ? data : []; + } +}); +var map$1 = new type("tag:yaml.org,2002:map", { + kind: "mapping", + construct: function(data) { + return data !== null ? data : {}; + } +}); +var failsafe = new schema({ + explicit: [ + str, + seq$1, + map$1 + ] +}); +function resolveYamlNull(data) { + if (data === null) + return true; + var max = data.length; + return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL"); +} +function constructYamlNull() { + return null; +} +function isNull(object) { + return object === null; +} +var _null = new type("tag:yaml.org,2002:null", { + kind: "scalar", + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function() { + return "~"; + }, + lowercase: function() { + return "null"; + }, + uppercase: function() { + return "NULL"; + }, + camelcase: function() { + return "Null"; + }, + empty: function() { + return ""; + } + }, + defaultStyle: "lowercase" +}); +function resolveYamlBoolean(data) { + if (data === null) + return false; + var max = data.length; + return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE"); +} +function constructYamlBoolean(data) { + return data === "true" || data === "True" || data === "TRUE"; +} +function isBoolean(object) { + return Object.prototype.toString.call(object) === "[object Boolean]"; +} +var bool = new type("tag:yaml.org,2002:bool", { + kind: "scalar", + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function(object) { + return object ? "true" : "false"; + }, + uppercase: function(object) { + return object ? "TRUE" : "FALSE"; + }, + camelcase: function(object) { + return object ? "True" : "False"; + } + }, + defaultStyle: "lowercase" +}); +function isHexCode(c) { + return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102; +} +function isOctCode(c) { + return 48 <= c && c <= 55; +} +function isDecCode(c) { + return 48 <= c && c <= 57; +} +function resolveYamlInteger(data) { + if (data === null) + return false; + var max = data.length, index = 0, hasDigits = false, ch; + if (!max) + return false; + ch = data[index]; + if (ch === "-" || ch === "+") { + ch = data[++index]; + } + if (ch === "0") { + if (index + 1 === max) + return true; + ch = data[++index]; + if (ch === "b") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (ch !== "0" && ch !== "1") + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + if (ch === "x") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isHexCode(data.charCodeAt(index))) + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + if (ch === "o") { + index++; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isOctCode(data.charCodeAt(index))) + return false; + hasDigits = true; + } + return hasDigits && ch !== "_"; + } + } + if (ch === "_") + return false; + for (; index < max; index++) { + ch = data[index]; + if (ch === "_") + continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + if (!hasDigits || ch === "_") + return false; + return true; +} +function constructYamlInteger(data) { + var value = data, sign = 1, ch; + if (value.indexOf("_") !== -1) { + value = value.replace(/_/g, ""); + } + ch = value[0]; + if (ch === "-" || ch === "+") { + if (ch === "-") + sign = -1; + value = value.slice(1); + ch = value[0]; + } + if (value === "0") + return 0; + if (ch === "0") { + if (value[1] === "b") + return sign * parseInt(value.slice(2), 2); + if (value[1] === "x") + return sign * parseInt(value.slice(2), 16); + if (value[1] === "o") + return sign * parseInt(value.slice(2), 8); + } + return sign * parseInt(value, 10); +} +function isInteger(object) { + return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object)); +} +var int = new type("tag:yaml.org,2002:int", { + kind: "scalar", + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function(obj) { + return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1); + }, + octal: function(obj) { + return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1); + }, + decimal: function(obj) { + return obj.toString(10); + }, + /* eslint-disable max-len */ + hexadecimal: function(obj) { + return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); + } + }, + defaultStyle: "decimal", + styleAliases: { + binary: [2, "bin"], + octal: [8, "oct"], + decimal: [10, "dec"], + hexadecimal: [16, "hex"] + } +}); +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" +); +function resolveYamlFloat(data) { + if (data === null) + return false; + if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === "_") { + return false; + } + return true; +} +function constructYamlFloat(data) { + var value, sign; + value = data.replace(/_/g, "").toLowerCase(); + sign = value[0] === "-" ? -1 : 1; + if ("+-".indexOf(value[0]) >= 0) { + value = value.slice(1); + } + if (value === ".inf") { + return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + } else if (value === ".nan") { + return NaN; + } + return sign * parseFloat(value, 10); +} +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; +function representYamlFloat(object, style) { + var res; + if (isNaN(object)) { + switch (style) { + case "lowercase": + return ".nan"; + case "uppercase": + return ".NAN"; + case "camelcase": + return ".NaN"; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case "lowercase": + return ".inf"; + case "uppercase": + return ".INF"; + case "camelcase": + return ".Inf"; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case "lowercase": + return "-.inf"; + case "uppercase": + return "-.INF"; + case "camelcase": + return "-.Inf"; + } + } else if (common.isNegativeZero(object)) { + return "-0.0"; + } + res = object.toString(10); + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; +} +function isFloat(object) { + return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object)); +} +var float = new type("tag:yaml.org,2002:float", { + kind: "scalar", + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: "lowercase" +}); +var json = failsafe.extend({ + implicit: [ + _null, + bool, + int, + float + ] +}); +var core$1 = json; +var YAML_DATE_REGEXP = new RegExp( + "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$" +); +var YAML_TIMESTAMP_REGEXP = new RegExp( + "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$" +); +function resolveYamlTimestamp(data) { + if (data === null) + return false; + if (YAML_DATE_REGEXP.exec(data) !== null) + return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) + return true; + return false; +} +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date; + match = YAML_DATE_REGEXP.exec(data); + if (match === null) + match = YAML_TIMESTAMP_REGEXP.exec(data); + if (match === null) + throw new Error("Date resolve error"); + year = +match[1]; + month = +match[2] - 1; + day = +match[3]; + if (!match[4]) { + return new Date(Date.UTC(year, month, day)); + } + hour = +match[4]; + minute = +match[5]; + second = +match[6]; + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { + fraction += "0"; + } + fraction = +fraction; + } + if (match[9]) { + tz_hour = +match[10]; + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 6e4; + if (match[9] === "-") + delta = -delta; + } + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + if (delta) + date.setTime(date.getTime() - delta); + return date; +} +function representYamlTimestamp(object) { + return object.toISOString(); +} +var timestamp = new type("tag:yaml.org,2002:timestamp", { + kind: "scalar", + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); +function resolveYamlMerge(data) { + return data === "<<" || data === null; +} +var merge$1 = new type("tag:yaml.org,2002:merge", { + kind: "scalar", + resolve: resolveYamlMerge +}); +var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; +function resolveYamlBinary(data) { + if (data === null) + return false; + var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP; + for (idx = 0; idx < max; idx++) { + code = map2.indexOf(data.charAt(idx)); + if (code > 64) + continue; + if (code < 0) + return false; + bitlen += 6; + } + return bitlen % 8 === 0; +} +function constructYamlBinary(data) { + var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = []; + for (idx = 0; idx < max; idx++) { + if (idx % 4 === 0 && idx) { + result.push(bits >> 16 & 255); + result.push(bits >> 8 & 255); + result.push(bits & 255); + } + bits = bits << 6 | map2.indexOf(input.charAt(idx)); + } + tailbits = max % 4 * 6; + if (tailbits === 0) { + result.push(bits >> 16 & 255); + result.push(bits >> 8 & 255); + result.push(bits & 255); + } else if (tailbits === 18) { + result.push(bits >> 10 & 255); + result.push(bits >> 2 & 255); + } else if (tailbits === 12) { + result.push(bits >> 4 & 255); + } + return new Uint8Array(result); +} +function representYamlBinary(object) { + var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP; + for (idx = 0; idx < max; idx++) { + if (idx % 3 === 0 && idx) { + result += map2[bits >> 18 & 63]; + result += map2[bits >> 12 & 63]; + result += map2[bits >> 6 & 63]; + result += map2[bits & 63]; + } + bits = (bits << 8) + object[idx]; + } + tail = max % 3; + if (tail === 0) { + result += map2[bits >> 18 & 63]; + result += map2[bits >> 12 & 63]; + result += map2[bits >> 6 & 63]; + result += map2[bits & 63]; + } else if (tail === 2) { + result += map2[bits >> 10 & 63]; + result += map2[bits >> 4 & 63]; + result += map2[bits << 2 & 63]; + result += map2[64]; + } else if (tail === 1) { + result += map2[bits >> 2 & 63]; + result += map2[bits << 4 & 63]; + result += map2[64]; + result += map2[64]; + } + return result; +} +function isBinary(obj) { + return Object.prototype.toString.call(obj) === "[object Uint8Array]"; +} +var binary = new type("tag:yaml.org,2002:binary", { + kind: "scalar", + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); +var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; +var _toString$2 = Object.prototype.toString; +function resolveYamlOmap(data) { + if (data === null) + return true; + var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data; + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + if (_toString$2.call(pair) !== "[object Object]") + return false; + for (pairKey in pair) { + if (_hasOwnProperty$3.call(pair, pairKey)) { + if (!pairHasKey) + pairHasKey = true; + else + return false; + } + } + if (!pairHasKey) + return false; + if (objectKeys.indexOf(pairKey) === -1) + objectKeys.push(pairKey); + else + return false; + } + return true; +} +function constructYamlOmap(data) { + return data !== null ? data : []; +} +var omap = new type("tag:yaml.org,2002:omap", { + kind: "sequence", + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); +var _toString$1 = Object.prototype.toString; +function resolveYamlPairs(data) { + if (data === null) + return true; + var index, length, pair, keys, result, object = data; + result = new Array(object.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + if (_toString$1.call(pair) !== "[object Object]") + return false; + keys = Object.keys(pair); + if (keys.length !== 1) + return false; + result[index] = [keys[0], pair[keys[0]]]; + } + return true; +} +function constructYamlPairs(data) { + if (data === null) + return []; + var index, length, pair, keys, result, object = data; + result = new Array(object.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + keys = Object.keys(pair); + result[index] = [keys[0], pair[keys[0]]]; + } + return result; +} +var pairs = new type("tag:yaml.org,2002:pairs", { + kind: "sequence", + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); +var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; +function resolveYamlSet(data) { + if (data === null) + return true; + var key, object = data; + for (key in object) { + if (_hasOwnProperty$2.call(object, key)) { + if (object[key] !== null) + return false; + } + } + return true; +} +function constructYamlSet(data) { + return data !== null ? data : {}; +} +var set$1 = new type("tag:yaml.org,2002:set", { + kind: "mapping", + resolve: resolveYamlSet, + construct: constructYamlSet +}); +var _default = core$1.extend({ + implicit: [ + timestamp, + merge$1 + ], + explicit: [ + binary, + omap, + pairs, + set$1 + ] +}); +var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; +function _class(obj) { + return Object.prototype.toString.call(obj); +} +function is_EOL(c) { + return c === 10 || c === 13; +} +function is_WHITE_SPACE(c) { + return c === 9 || c === 32; +} +function is_WS_OR_EOL(c) { + return c === 9 || c === 32 || c === 10 || c === 13; +} +function is_FLOW_INDICATOR(c) { + return c === 44 || c === 91 || c === 93 || c === 123 || c === 125; +} +function fromHexCode(c) { + var lc; + if (48 <= c && c <= 57) { + return c - 48; + } + lc = c | 32; + if (97 <= lc && lc <= 102) { + return lc - 97 + 10; + } + return -1; +} +function escapedHexLen(c) { + if (c === 120) { + return 2; + } + if (c === 117) { + return 4; + } + if (c === 85) { + return 8; + } + return 0; +} +function fromDecimalCode(c) { + if (48 <= c && c <= 57) { + return c - 48; + } + return -1; +} +function simpleEscapeSequence(c) { + return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "…" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : ""; +} +function charFromCodepoint(c) { + if (c <= 65535) { + return String.fromCharCode(c); + } + return String.fromCharCode( + (c - 65536 >> 10) + 55296, + (c - 65536 & 1023) + 56320 + ); +} +var simpleEscapeCheck = new Array(256); +var simpleEscapeMap = new Array(256); +for (var i$1 = 0; i$1 < 256; i$1++) { + simpleEscapeCheck[i$1] = simpleEscapeSequence(i$1) ? 1 : 0; + simpleEscapeMap[i$1] = simpleEscapeSequence(i$1); +} +function State$1(input, options) { + this.input = input; + this.filename = options["filename"] || null; + this.schema = options["schema"] || _default; + this.onWarning = options["onWarning"] || null; + this.legacy = options["legacy"] || false; + this.json = options["json"] || false; + this.listener = options["listener"] || null; + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + this.firstTabInLine = -1; + this.documents = []; +} +function generateError(state2, message) { + var mark = { + name: state2.filename, + buffer: state2.input.slice(0, -1), + // omit trailing \0 + position: state2.position, + line: state2.line, + column: state2.position - state2.lineStart + }; + mark.snippet = snippet(mark); + return new exception(message, mark); +} +function throwError(state2, message) { + throw generateError(state2, message); +} +function throwWarning(state2, message) { + if (state2.onWarning) { + state2.onWarning.call(null, generateError(state2, message)); + } +} +var directiveHandlers = { + YAML: function handleYamlDirective(state2, name, args) { + var match, major, minor; + if (state2.version !== null) { + throwError(state2, "duplication of %YAML directive"); + } + if (args.length !== 1) { + throwError(state2, "YAML directive accepts exactly one argument"); + } + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + if (match === null) { + throwError(state2, "ill-formed argument of the YAML directive"); + } + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + if (major !== 1) { + throwError(state2, "unacceptable YAML version of the document"); + } + state2.version = args[0]; + state2.checkLineBreaks = minor < 2; + if (minor !== 1 && minor !== 2) { + throwWarning(state2, "unsupported YAML version of the document"); + } + }, + TAG: function handleTagDirective(state2, name, args) { + var handle, prefix; + if (args.length !== 2) { + throwError(state2, "TAG directive accepts exactly two arguments"); + } + handle = args[0]; + prefix = args[1]; + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state2, "ill-formed tag handle (first argument) of the TAG directive"); + } + if (_hasOwnProperty$1.call(state2.tagMap, handle)) { + throwError(state2, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state2, "ill-formed tag prefix (second argument) of the TAG directive"); + } + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state2, "tag prefix is malformed: " + prefix); + } + state2.tagMap[handle] = prefix; + } +}; +function captureSegment(state2, start, end, checkJson) { + var _position, _length, _character, _result; + if (start < end) { + _result = state2.input.slice(start, end); + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 9 || 32 <= _character && _character <= 1114111)) { + throwError(state2, "expected valid JSON character"); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state2, "the stream contains non-printable characters"); + } + state2.result += _result; + } +} +function mergeMappings(state2, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + if (!common.isObject(source)) { + throwError(state2, "cannot merge mappings; the provided source object is unacceptable"); + } + sourceKeys = Object.keys(source); + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + if (!_hasOwnProperty$1.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} +function storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) { + var index, quantity; + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state2, "nested arrays are not supported inside keys"); + } + if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") { + keyNode[index] = "[object Object]"; + } + } + } + if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") { + keyNode = "[object Object]"; + } + keyNode = String(keyNode); + if (_result === null) { + _result = {}; + } + if (keyTag === "tag:yaml.org,2002:merge") { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state2, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state2, _result, valueNode, overridableKeys); + } + } else { + if (!state2.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) { + state2.line = startLine || state2.line; + state2.lineStart = startLineStart || state2.lineStart; + state2.position = startPos || state2.position; + throwError(state2, "duplicated mapping key"); + } + if (keyNode === "__proto__") { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + return _result; +} +function readLineBreak(state2) { + var ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 10) { + state2.position++; + } else if (ch === 13) { + state2.position++; + if (state2.input.charCodeAt(state2.position) === 10) { + state2.position++; + } + } else { + throwError(state2, "a line break is expected"); + } + state2.line += 1; + state2.lineStart = state2.position; + state2.firstTabInLine = -1; +} +function skipSeparationSpace(state2, allowComments, checkIndent) { + var lineBreaks = 0, ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 9 && state2.firstTabInLine === -1) { + state2.firstTabInLine = state2.position; + } + ch = state2.input.charCodeAt(++state2.position); + } + if (allowComments && ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 10 && ch !== 13 && ch !== 0); + } + if (is_EOL(ch)) { + readLineBreak(state2); + ch = state2.input.charCodeAt(state2.position); + lineBreaks++; + state2.lineIndent = 0; + while (ch === 32) { + state2.lineIndent++; + ch = state2.input.charCodeAt(++state2.position); + } + } else { + break; + } + } + if (checkIndent !== -1 && lineBreaks !== 0 && state2.lineIndent < checkIndent) { + throwWarning(state2, "deficient indentation"); + } + return lineBreaks; +} +function testDocumentSeparator(state2) { + var _position = state2.position, ch; + ch = state2.input.charCodeAt(_position); + if ((ch === 45 || ch === 46) && ch === state2.input.charCodeAt(_position + 1) && ch === state2.input.charCodeAt(_position + 2)) { + _position += 3; + ch = state2.input.charCodeAt(_position); + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + return false; +} +function writeFoldedLines(state2, count) { + if (count === 1) { + state2.result += " "; + } else if (count > 1) { + state2.result += common.repeat("\n", count - 1); + } +} +function readPlainScalar(state2, nodeIndent, withinFlowCollection) { + var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state2.kind, _result = state2.result, ch; + ch = state2.input.charCodeAt(state2.position); + if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) { + return false; + } + if (ch === 63 || ch === 45) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + state2.kind = "scalar"; + state2.result = ""; + captureStart = captureEnd = state2.position; + hasPendingContent = false; + while (ch !== 0) { + if (ch === 58) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + } else if (ch === 35) { + preceding = state2.input.charCodeAt(state2.position - 1); + if (is_WS_OR_EOL(preceding)) { + break; + } + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2) || withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + } else if (is_EOL(ch)) { + _line = state2.line; + _lineStart = state2.lineStart; + _lineIndent = state2.lineIndent; + skipSeparationSpace(state2, false, -1); + if (state2.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state2.input.charCodeAt(state2.position); + continue; + } else { + state2.position = captureEnd; + state2.line = _line; + state2.lineStart = _lineStart; + state2.lineIndent = _lineIndent; + break; + } + } + if (hasPendingContent) { + captureSegment(state2, captureStart, captureEnd, false); + writeFoldedLines(state2, state2.line - _line); + captureStart = captureEnd = state2.position; + hasPendingContent = false; + } + if (!is_WHITE_SPACE(ch)) { + captureEnd = state2.position + 1; + } + ch = state2.input.charCodeAt(++state2.position); + } + captureSegment(state2, captureStart, captureEnd, false); + if (state2.result) { + return true; + } + state2.kind = _kind; + state2.result = _result; + return false; +} +function readSingleQuotedScalar(state2, nodeIndent) { + var ch, captureStart, captureEnd; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 39) { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + state2.position++; + captureStart = captureEnd = state2.position; + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + if (ch === 39) { + captureSegment(state2, captureStart, state2.position, true); + ch = state2.input.charCodeAt(++state2.position); + if (ch === 39) { + captureStart = state2.position; + state2.position++; + captureEnd = state2.position; + } else { + return true; + } + } else if (is_EOL(ch)) { + captureSegment(state2, captureStart, captureEnd, true); + writeFoldedLines(state2, skipSeparationSpace(state2, false, nodeIndent)); + captureStart = captureEnd = state2.position; + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + throwError(state2, "unexpected end of the document within a single quoted scalar"); + } else { + state2.position++; + captureEnd = state2.position; + } + } + throwError(state2, "unexpected end of the stream within a single quoted scalar"); +} +function readDoubleQuotedScalar(state2, nodeIndent) { + var captureStart, captureEnd, hexLength, hexResult, tmp, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 34) { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + state2.position++; + captureStart = captureEnd = state2.position; + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + if (ch === 34) { + captureSegment(state2, captureStart, state2.position, true); + state2.position++; + return true; + } else if (ch === 92) { + captureSegment(state2, captureStart, state2.position, true); + ch = state2.input.charCodeAt(++state2.position); + if (is_EOL(ch)) { + skipSeparationSpace(state2, false, nodeIndent); + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state2.result += simpleEscapeMap[ch]; + state2.position++; + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + for (; hexLength > 0; hexLength--) { + ch = state2.input.charCodeAt(++state2.position); + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + } else { + throwError(state2, "expected hexadecimal character"); + } + } + state2.result += charFromCodepoint(hexResult); + state2.position++; + } else { + throwError(state2, "unknown escape sequence"); + } + captureStart = captureEnd = state2.position; + } else if (is_EOL(ch)) { + captureSegment(state2, captureStart, captureEnd, true); + writeFoldedLines(state2, skipSeparationSpace(state2, false, nodeIndent)); + captureStart = captureEnd = state2.position; + } else if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + throwError(state2, "unexpected end of the document within a double quoted scalar"); + } else { + state2.position++; + captureEnd = state2.position; + } + } + throwError(state2, "unexpected end of the stream within a double quoted scalar"); +} +function readFlowCollection(state2, nodeIndent) { + var readNext = true, _line, _lineStart, _pos, _tag = state2.tag, _result, _anchor = state2.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 91) { + terminator = 93; + isMapping = false; + _result = []; + } else if (ch === 123) { + terminator = 125; + isMapping = true; + _result = {}; + } else { + return false; + } + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(++state2.position); + while (ch !== 0) { + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if (ch === terminator) { + state2.position++; + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = isMapping ? "mapping" : "sequence"; + state2.result = _result; + return true; + } else if (!readNext) { + throwError(state2, "missed comma between flow collection entries"); + } else if (ch === 44) { + throwError(state2, "expected the node content, but found ','"); + } + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + if (ch === 63) { + following = state2.input.charCodeAt(state2.position + 1); + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state2.position++; + skipSeparationSpace(state2, true, nodeIndent); + } + } + _line = state2.line; + _lineStart = state2.lineStart; + _pos = state2.position; + composeNode(state2, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state2.tag; + keyNode = state2.result; + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if ((isExplicitPair || state2.line === _line) && ch === 58) { + isPair = true; + ch = state2.input.charCodeAt(++state2.position); + skipSeparationSpace(state2, true, nodeIndent); + composeNode(state2, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state2.result; + } + if (isMapping) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state2, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + skipSeparationSpace(state2, true, nodeIndent); + ch = state2.input.charCodeAt(state2.position); + if (ch === 44) { + readNext = true; + ch = state2.input.charCodeAt(++state2.position); + } else { + readNext = false; + } + } + throwError(state2, "unexpected end of the stream within a flow collection"); +} +function readBlockScalar(state2, nodeIndent) { + var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch === 124) { + folding = false; + } else if (ch === 62) { + folding = true; + } else { + return false; + } + state2.kind = "scalar"; + state2.result = ""; + while (ch !== 0) { + ch = state2.input.charCodeAt(++state2.position); + if (ch === 43 || ch === 45) { + if (CHOMPING_CLIP === chomping) { + chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state2, "repeat of a chomping mode identifier"); + } + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state2, "bad explicit indentation width of a block scalar; it cannot be less than one"); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state2, "repeat of an indentation width identifier"); + } + } else { + break; + } + } + if (is_WHITE_SPACE(ch)) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (is_WHITE_SPACE(ch)); + if (ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (!is_EOL(ch) && ch !== 0); + } + } + while (ch !== 0) { + readLineBreak(state2); + state2.lineIndent = 0; + ch = state2.input.charCodeAt(state2.position); + while ((!detectedIndent || state2.lineIndent < textIndent) && ch === 32) { + state2.lineIndent++; + ch = state2.input.charCodeAt(++state2.position); + } + if (!detectedIndent && state2.lineIndent > textIndent) { + textIndent = state2.lineIndent; + } + if (is_EOL(ch)) { + emptyLines++; + continue; + } + if (state2.lineIndent < textIndent) { + if (chomping === CHOMPING_KEEP) { + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { + state2.result += "\n"; + } + } + break; + } + if (folding) { + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } else if (atMoreIndented) { + atMoreIndented = false; + state2.result += common.repeat("\n", emptyLines + 1); + } else if (emptyLines === 0) { + if (didReadContent) { + state2.result += " "; + } + } else { + state2.result += common.repeat("\n", emptyLines); + } + } else { + state2.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines); + } + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state2.position; + while (!is_EOL(ch) && ch !== 0) { + ch = state2.input.charCodeAt(++state2.position); + } + captureSegment(state2, captureStart, state2.position, false); + } + return true; +} +function readBlockSequence(state2, nodeIndent) { + var _line, _tag = state2.tag, _anchor = state2.anchor, _result = [], following, detected = false, ch; + if (state2.firstTabInLine !== -1) + return false; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + if (state2.firstTabInLine !== -1) { + state2.position = state2.firstTabInLine; + throwError(state2, "tab characters must not be used in indentation"); + } + if (ch !== 45) { + break; + } + following = state2.input.charCodeAt(state2.position + 1); + if (!is_WS_OR_EOL(following)) { + break; + } + detected = true; + state2.position++; + if (skipSeparationSpace(state2, true, -1)) { + if (state2.lineIndent <= nodeIndent) { + _result.push(null); + ch = state2.input.charCodeAt(state2.position); + continue; + } + } + _line = state2.line; + composeNode(state2, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state2.result); + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + if ((state2.line === _line || state2.lineIndent > nodeIndent) && ch !== 0) { + throwError(state2, "bad indentation of a sequence entry"); + } else if (state2.lineIndent < nodeIndent) { + break; + } + } + if (detected) { + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = "sequence"; + state2.result = _result; + return true; + } + return false; +} +function readBlockMapping(state2, nodeIndent, flowIndent) { + var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state2.tag, _anchor = state2.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch; + if (state2.firstTabInLine !== -1) + return false; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = _result; + } + ch = state2.input.charCodeAt(state2.position); + while (ch !== 0) { + if (!atExplicitKey && state2.firstTabInLine !== -1) { + state2.position = state2.firstTabInLine; + throwError(state2, "tab characters must not be used in indentation"); + } + following = state2.input.charCodeAt(state2.position + 1); + _line = state2.line; + if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) { + if (ch === 63) { + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + detected = true; + atExplicitKey = true; + allowCompact = true; + } else if (atExplicitKey) { + atExplicitKey = false; + allowCompact = true; + } else { + throwError(state2, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"); + } + state2.position += 1; + ch = following; + } else { + _keyLine = state2.line; + _keyLineStart = state2.lineStart; + _keyPos = state2.position; + if (!composeNode(state2, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + break; + } + if (state2.line === _line) { + ch = state2.input.charCodeAt(state2.position); + while (is_WHITE_SPACE(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (ch === 58) { + ch = state2.input.charCodeAt(++state2.position); + if (!is_WS_OR_EOL(ch)) { + throwError(state2, "a whitespace character is expected after the key-value separator within a block mapping"); + } + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state2.tag; + keyNode = state2.result; + } else if (detected) { + throwError(state2, "can not read an implicit mapping pair; a colon is missed"); + } else { + state2.tag = _tag; + state2.anchor = _anchor; + return true; + } + } else if (detected) { + throwError(state2, "can not read a block mapping entry; a multiline key may not be an implicit key"); + } else { + state2.tag = _tag; + state2.anchor = _anchor; + return true; + } + } + if (state2.line === _line || state2.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state2.line; + _keyLineStart = state2.lineStart; + _keyPos = state2.position; + } + if (composeNode(state2, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state2.result; + } else { + valueNode = state2.result; + } + } + if (!atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + } + if ((state2.line === _line || state2.lineIndent > nodeIndent) && ch !== 0) { + throwError(state2, "bad indentation of a mapping entry"); + } else if (state2.lineIndent < nodeIndent) { + break; + } + } + if (atExplicitKey) { + storeMappingPair(state2, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + if (detected) { + state2.tag = _tag; + state2.anchor = _anchor; + state2.kind = "mapping"; + state2.result = _result; + } + return detected; +} +function readTagProperty(state2) { + var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 33) + return false; + if (state2.tag !== null) { + throwError(state2, "duplication of a tag property"); + } + ch = state2.input.charCodeAt(++state2.position); + if (ch === 60) { + isVerbatim = true; + ch = state2.input.charCodeAt(++state2.position); + } else if (ch === 33) { + isNamed = true; + tagHandle = "!!"; + ch = state2.input.charCodeAt(++state2.position); + } else { + tagHandle = "!"; + } + _position = state2.position; + if (isVerbatim) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 0 && ch !== 62); + if (state2.position < state2.length) { + tagName = state2.input.slice(_position, state2.position); + ch = state2.input.charCodeAt(++state2.position); + } else { + throwError(state2, "unexpected end of the stream within a verbatim tag"); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + if (ch === 33) { + if (!isNamed) { + tagHandle = state2.input.slice(_position - 1, state2.position + 1); + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state2, "named tag handle cannot contain such characters"); + } + isNamed = true; + _position = state2.position + 1; + } else { + throwError(state2, "tag suffix cannot contain exclamation marks"); + } + } + ch = state2.input.charCodeAt(++state2.position); + } + tagName = state2.input.slice(_position, state2.position); + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state2, "tag suffix cannot contain flow indicator characters"); + } + } + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state2, "tag name cannot contain such characters: " + tagName); + } + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state2, "tag name is malformed: " + tagName); + } + if (isVerbatim) { + state2.tag = tagName; + } else if (_hasOwnProperty$1.call(state2.tagMap, tagHandle)) { + state2.tag = state2.tagMap[tagHandle] + tagName; + } else if (tagHandle === "!") { + state2.tag = "!" + tagName; + } else if (tagHandle === "!!") { + state2.tag = "tag:yaml.org,2002:" + tagName; + } else { + throwError(state2, 'undeclared tag handle "' + tagHandle + '"'); + } + return true; +} +function readAnchorProperty(state2) { + var _position, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 38) + return false; + if (state2.anchor !== null) { + throwError(state2, "duplication of an anchor property"); + } + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (state2.position === _position) { + throwError(state2, "name of an anchor node must contain at least one character"); + } + state2.anchor = state2.input.slice(_position, state2.position); + return true; +} +function readAlias(state2) { + var _position, alias, ch; + ch = state2.input.charCodeAt(state2.position); + if (ch !== 42) + return false; + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (state2.position === _position) { + throwError(state2, "name of an alias node must contain at least one character"); + } + alias = state2.input.slice(_position, state2.position); + if (!_hasOwnProperty$1.call(state2.anchorMap, alias)) { + throwError(state2, 'unidentified alias "' + alias + '"'); + } + state2.result = state2.anchorMap[alias]; + skipSeparationSpace(state2, true, -1); + return true; +} +function composeNode(state2, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent; + if (state2.listener !== null) { + state2.listener("open", state2); + } + state2.tag = null; + state2.anchor = null; + state2.kind = null; + state2.result = null; + allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext; + if (allowToSeek) { + if (skipSeparationSpace(state2, true, -1)) { + atNewLine = true; + if (state2.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state2.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state2.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + if (indentStatus === 1) { + while (readTagProperty(state2) || readAnchorProperty(state2)) { + if (skipSeparationSpace(state2, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + if (state2.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state2.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state2.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + blockIndent = state2.position - state2.lineStart; + if (indentStatus === 1) { + if (allowBlockCollections && (readBlockSequence(state2, blockIndent) || readBlockMapping(state2, blockIndent, flowIndent)) || readFlowCollection(state2, flowIndent)) { + hasContent = true; + } else { + if (allowBlockScalars && readBlockScalar(state2, flowIndent) || readSingleQuotedScalar(state2, flowIndent) || readDoubleQuotedScalar(state2, flowIndent)) { + hasContent = true; + } else if (readAlias(state2)) { + hasContent = true; + if (state2.tag !== null || state2.anchor !== null) { + throwError(state2, "alias node should not have any properties"); + } + } else if (readPlainScalar(state2, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + if (state2.tag === null) { + state2.tag = "?"; + } + } + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } + } else if (indentStatus === 0) { + hasContent = allowBlockCollections && readBlockSequence(state2, blockIndent); + } + } + if (state2.tag === null) { + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } else if (state2.tag === "?") { + if (state2.result !== null && state2.kind !== "scalar") { + throwError(state2, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state2.kind + '"'); + } + for (typeIndex = 0, typeQuantity = state2.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type2 = state2.implicitTypes[typeIndex]; + if (type2.resolve(state2.result)) { + state2.result = type2.construct(state2.result); + state2.tag = type2.tag; + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + break; + } + } + } else if (state2.tag !== "!") { + if (_hasOwnProperty$1.call(state2.typeMap[state2.kind || "fallback"], state2.tag)) { + type2 = state2.typeMap[state2.kind || "fallback"][state2.tag]; + } else { + type2 = null; + typeList = state2.typeMap.multi[state2.kind || "fallback"]; + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state2.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type2 = typeList[typeIndex]; + break; + } + } + } + if (!type2) { + throwError(state2, "unknown tag !<" + state2.tag + ">"); + } + if (state2.result !== null && type2.kind !== state2.kind) { + throwError(state2, "unacceptable node kind for !<" + state2.tag + '> tag; it should be "' + type2.kind + '", not "' + state2.kind + '"'); + } + if (!type2.resolve(state2.result, state2.tag)) { + throwError(state2, "cannot resolve a node with !<" + state2.tag + "> explicit tag"); + } else { + state2.result = type2.construct(state2.result, state2.tag); + if (state2.anchor !== null) { + state2.anchorMap[state2.anchor] = state2.result; + } + } + } + if (state2.listener !== null) { + state2.listener("close", state2); + } + return state2.tag !== null || state2.anchor !== null || hasContent; +} +function readDocument(state2) { + var documentStart = state2.position, _position, directiveName, directiveArgs, hasDirectives = false, ch; + state2.version = null; + state2.checkLineBreaks = state2.legacy; + state2.tagMap = /* @__PURE__ */ Object.create(null); + state2.anchorMap = /* @__PURE__ */ Object.create(null); + while ((ch = state2.input.charCodeAt(state2.position)) !== 0) { + skipSeparationSpace(state2, true, -1); + ch = state2.input.charCodeAt(state2.position); + if (state2.lineIndent > 0 || ch !== 37) { + break; + } + hasDirectives = true; + ch = state2.input.charCodeAt(++state2.position); + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + directiveName = state2.input.slice(_position, state2.position); + directiveArgs = []; + if (directiveName.length < 1) { + throwError(state2, "directive name must not be less than one character in length"); + } + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + if (ch === 35) { + do { + ch = state2.input.charCodeAt(++state2.position); + } while (ch !== 0 && !is_EOL(ch)); + break; + } + if (is_EOL(ch)) + break; + _position = state2.position; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state2.input.charCodeAt(++state2.position); + } + directiveArgs.push(state2.input.slice(_position, state2.position)); + } + if (ch !== 0) + readLineBreak(state2); + if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state2, directiveName, directiveArgs); + } else { + throwWarning(state2, 'unknown document directive "' + directiveName + '"'); + } + } + skipSeparationSpace(state2, true, -1); + if (state2.lineIndent === 0 && state2.input.charCodeAt(state2.position) === 45 && state2.input.charCodeAt(state2.position + 1) === 45 && state2.input.charCodeAt(state2.position + 2) === 45) { + state2.position += 3; + skipSeparationSpace(state2, true, -1); + } else if (hasDirectives) { + throwError(state2, "directives end mark is expected"); + } + composeNode(state2, state2.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state2, true, -1); + if (state2.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state2.input.slice(documentStart, state2.position))) { + throwWarning(state2, "non-ASCII line breaks are interpreted as content"); + } + state2.documents.push(state2.result); + if (state2.position === state2.lineStart && testDocumentSeparator(state2)) { + if (state2.input.charCodeAt(state2.position) === 46) { + state2.position += 3; + skipSeparationSpace(state2, true, -1); + } + return; + } + if (state2.position < state2.length - 1) { + throwError(state2, "end of the stream or a document separator is expected"); + } else { + return; + } +} +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + if (input.length !== 0) { + if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) { + input += "\n"; + } + if (input.charCodeAt(0) === 65279) { + input = input.slice(1); + } + } + var state2 = new State$1(input, options); + var nullpos = input.indexOf("\0"); + if (nullpos !== -1) { + state2.position = nullpos; + throwError(state2, "null byte is not allowed in input"); + } + state2.input += "\0"; + while (state2.input.charCodeAt(state2.position) === 32) { + state2.lineIndent += 1; + state2.position += 1; + } + while (state2.position < state2.length - 1) { + readDocument(state2); + } + return state2.documents; +} +function loadAll$1(input, iterator, options) { + if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") { + options = iterator; + iterator = null; + } + var documents = loadDocuments(input, options); + if (typeof iterator !== "function") { + return documents; + } + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} +function load$1(input, options) { + var documents = loadDocuments(input, options); + if (documents.length === 0) { + return void 0; + } else if (documents.length === 1) { + return documents[0]; + } + throw new exception("expected a single document in the stream, but found more"); +} +var loadAll_1 = loadAll$1; +var load_1 = load$1; +var loader = { + loadAll: loadAll_1, + load: load_1 +}; +var JSON_SCHEMA = json; +var load = loader.load; +function extractFrontMatter(text) { + const matches = text.match(frontMatterRegex); + if (!matches) { + return { + text, + metadata: {} + }; + } + let parsed = load(matches[1], { + // To support config, we need JSON schema. + // https://www.yaml.org/spec/1.2/spec.html#id2803231 + schema: JSON_SCHEMA + }) ?? {}; + parsed = typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {}; + const metadata = {}; + if (parsed.displayMode) { + metadata.displayMode = parsed.displayMode.toString(); + } + if (parsed.title) { + metadata.title = parsed.title.toString(); + } + if (parsed.config) { + metadata.config = parsed.config; + } + return { + text: text.slice(matches[0].length), + metadata + }; +} +const cleanupText = (code) => { + return code.replace(/\r\n?/g, "\n").replace( + /<(\w+)([^>]*)>/g, + (match, tag, attributes) => "<" + tag + attributes.replace(/="([^"]*)"/g, "='$1'") + ">" + ); +}; +const processFrontmatter = (code) => { + const { text, metadata } = extractFrontMatter(code); + const { displayMode, title, config: config2 = {} } = metadata; + if (displayMode) { + if (!config2.gantt) { + config2.gantt = {}; + } + config2.gantt.displayMode = displayMode; + } + return { title, config: config2, text }; +}; +const processDirectives = (code) => { + const initDirective = utils.detectInit(code) ?? {}; + const wrapDirectives = utils.detectDirective(code, "wrap"); + if (Array.isArray(wrapDirectives)) { + initDirective.wrap = wrapDirectives.some(({ type: type2 }) => { + }); + } else if ((wrapDirectives == null ? void 0 : wrapDirectives.type) === "wrap") { + initDirective.wrap = true; + } + return { + text: removeDirectives(code), + directive: initDirective + }; +}; +function preprocessDiagram(code) { + const cleanedCode = cleanupText(code); + const frontMatterResult = processFrontmatter(cleanedCode); + const directiveResult = processDirectives(frontMatterResult.text); + const config2 = cleanAndMerge(frontMatterResult.config, directiveResult.directive); + code = cleanupComments(directiveResult.text); + return { + code, + title: frontMatterResult.title, + config: config2 + }; +} +const MAX_TEXTLENGTH = 5e4; +const MAX_TEXTLENGTH_EXCEEDED_MSG = "graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa"; +const SECURITY_LVL_SANDBOX = "sandbox"; +const SECURITY_LVL_LOOSE = "loose"; +const XMLNS_SVG_STD = "http://www.w3.org/2000/svg"; +const XMLNS_XLINK_STD = "http://www.w3.org/1999/xlink"; +const XMLNS_XHTML_STD = "http://www.w3.org/1999/xhtml"; +const IFRAME_WIDTH = "100%"; +const IFRAME_HEIGHT = "100%"; +const IFRAME_STYLES = "border:0;margin:0;"; +const IFRAME_BODY_STYLE = "margin:0"; +const IFRAME_SANDBOX_OPTS = "allow-top-navigation-by-user-activation allow-popups"; +const IFRAME_NOT_SUPPORTED_MSG = 'The "iframe" tag is not supported by your browser.'; +const DOMPURIFY_TAGS = ["foreignobject"]; +const DOMPURIFY_ATTR = ["dominant-baseline"]; +function processAndSetConfigs(text) { + const processed = preprocessDiagram(text); + reset(); + addDirective(processed.config ?? {}); + return processed; +} +async function parse$1$1(text, parseOptions) { + addDiagrams(); + text = processAndSetConfigs(text).code; + try { + await getDiagramFromText(text); + } catch (error) { + if (parseOptions == null ? void 0 : parseOptions.suppressErrors) { + return false; + } + throw error; + } + return true; +} +const cssImportantStyles = (cssClass, element, cssClasses = []) => { + return ` +.${cssClass} ${element} { ${cssClasses.join(" !important; ")} !important; }`; +}; +const createCssStyles = (config2, classDefs = {}) => { + var _a; + let cssStyles = ""; + if (config2.themeCSS !== void 0) { + cssStyles += ` +${config2.themeCSS}`; + } + if (config2.fontFamily !== void 0) { + cssStyles += ` +:root { --mermaid-font-family: ${config2.fontFamily}}`; + } + if (config2.altFontFamily !== void 0) { + cssStyles += ` +:root { --mermaid-alt-font-family: ${config2.altFontFamily}}`; + } + if (!isEmpty(classDefs)) { + const htmlLabels = config2.htmlLabels || ((_a = config2.flowchart) == null ? void 0 : _a.htmlLabels); + const cssHtmlElements = ["> *", "span"]; + const cssShapeElements = ["rect", "polygon", "ellipse", "circle", "path"]; + const cssElements = htmlLabels ? cssHtmlElements : cssShapeElements; + for (const classId in classDefs) { + const styleClassDef = classDefs[classId]; + if (!isEmpty(styleClassDef.styles)) { + cssElements.forEach((cssElement) => { + cssStyles += cssImportantStyles(styleClassDef.id, cssElement, styleClassDef.styles); + }); + } + if (!isEmpty(styleClassDef.textStyles)) { + cssStyles += cssImportantStyles(styleClassDef.id, "tspan", styleClassDef.textStyles); + } + } + } + return cssStyles; +}; +const createUserStyles = (config2, graphType, classDefs, svgId) => { + const userCSSstyles = createCssStyles(config2, classDefs); + const allStyles = getStyles$1$1(graphType, userCSSstyles, config2.themeVariables); + return serialize(compile(`${svgId}{${allStyles}}`), stringify); +}; +const cleanUpSvgCode = (svgCode = "", inSandboxMode, useArrowMarkerUrls) => { + let cleanedUpSvg = svgCode; + if (!useArrowMarkerUrls && !inSandboxMode) { + cleanedUpSvg = cleanedUpSvg.replace( + /marker-end="url\([\d+./:=?A-Za-z-]*?#/g, + 'marker-end="url(#' + ); + } + cleanedUpSvg = decodeEntities(cleanedUpSvg); + cleanedUpSvg = cleanedUpSvg.replace(/
    /g, "
    "); + return cleanedUpSvg; +}; +const putIntoIFrame = (svgCode = "", svgElement) => { + var _a, _b; + const height = ((_b = (_a = svgElement == null ? void 0 : svgElement.viewBox) == null ? void 0 : _a.baseVal) == null ? void 0 : _b.height) ? svgElement.viewBox.baseVal.height + "px" : IFRAME_HEIGHT; + const base64encodedSrc = btoa('' + svgCode + ""); + return ``; +}; +const appendDivSvgG = (parentRoot, id2, enclosingDivId, divStyle, svgXlink) => { + const enclosingDiv = parentRoot.append("div"); + enclosingDiv.attr("id", enclosingDivId); + if (divStyle) { + enclosingDiv.attr("style", divStyle); + } + const svgNode = enclosingDiv.append("svg").attr("id", id2).attr("width", "100%").attr("xmlns", XMLNS_SVG_STD); + if (svgXlink) { + svgNode.attr("xmlns:xlink", svgXlink); + } + svgNode.append("g"); + return parentRoot; +}; +function sandboxedIframe(parentNode, iFrameId) { + return parentNode.append("iframe").attr("id", iFrameId).attr("style", "width: 100%; height: 100%;").attr("sandbox", ""); +} +const removeExistingElements = (doc, id2, divId, iFrameId) => { + var _a, _b, _c; + (_a = doc.getElementById(id2)) == null ? void 0 : _a.remove(); + (_b = doc.getElementById(divId)) == null ? void 0 : _b.remove(); + (_c = doc.getElementById(iFrameId)) == null ? void 0 : _c.remove(); +}; +const render$1$1 = async function(id2, text, svgContainingElement) { + var _a, _b, _c, _d, _e, _f; + addDiagrams(); + const processed = processAndSetConfigs(text); + text = processed.code; + const config2 = getConfig$1(); + log$1.debug(config2); + if (text.length > ((config2 == null ? void 0 : config2.maxTextSize) ?? MAX_TEXTLENGTH)) { + text = MAX_TEXTLENGTH_EXCEEDED_MSG; + } + const idSelector = "#" + id2; + const iFrameID = "i" + id2; + const iFrameID_selector = "#" + iFrameID; + const enclosingDivID = "d" + id2; + const enclosingDivID_selector = "#" + enclosingDivID; + let root = select("body"); + const isSandboxed = config2.securityLevel === SECURITY_LVL_SANDBOX; + const isLooseSecurityLevel = config2.securityLevel === SECURITY_LVL_LOOSE; + const fontFamily = config2.fontFamily; + if (svgContainingElement !== void 0) { + if (svgContainingElement) { + svgContainingElement.innerHTML = ""; + } + if (isSandboxed) { + const iframe = sandboxedIframe(select(svgContainingElement), iFrameID); + root = select(iframe.nodes()[0].contentDocument.body); + root.node().style.margin = 0; + } else { + root = select(svgContainingElement); + } + appendDivSvgG(root, id2, enclosingDivID, `font-family: ${fontFamily}`, XMLNS_XLINK_STD); + } else { + removeExistingElements(document, id2, enclosingDivID, iFrameID); + if (isSandboxed) { + const iframe = sandboxedIframe(select("body"), iFrameID); + root = select(iframe.nodes()[0].contentDocument.body); + root.node().style.margin = 0; + } else { + root = select("body"); + } + appendDivSvgG(root, id2, enclosingDivID); + } + let diag; + let parseEncounteredException; + try { + diag = await getDiagramFromText(text, { title: processed.title }); + } catch (error) { + diag = new Diagram("error"); + parseEncounteredException = error; + } + const element = root.select(enclosingDivID_selector).node(); + const diagramType = diag.type; + const svg = element.firstChild; + const firstChild = svg.firstChild; + const diagramClassDefs = (_b = (_a = diag.renderer).getClasses) == null ? void 0 : _b.call(_a, text, diag); + const rules = createUserStyles(config2, diagramType, diagramClassDefs, idSelector); + const style1 = document.createElement("style"); + style1.innerHTML = rules; + svg.insertBefore(style1, firstChild); + try { + await diag.renderer.draw(text, id2, version$2, diag); + } catch (e) { + errorRenderer.draw(text, id2, version$2); + throw e; + } + const svgNode = root.select(`${enclosingDivID_selector} svg`); + const a11yTitle = (_d = (_c = diag.db).getAccTitle) == null ? void 0 : _d.call(_c); + const a11yDescr = (_f = (_e = diag.db).getAccDescription) == null ? void 0 : _f.call(_e); + addA11yInfo(diagramType, svgNode, a11yTitle, a11yDescr); + root.select(`[id="${id2}"]`).selectAll("foreignobject > *").attr("xmlns", XMLNS_XHTML_STD); + let svgCode = root.select(enclosingDivID_selector).node().innerHTML; + log$1.debug("config.arrowMarkerAbsolute", config2.arrowMarkerAbsolute); + svgCode = cleanUpSvgCode(svgCode, isSandboxed, evaluate(config2.arrowMarkerAbsolute)); + if (isSandboxed) { + const svgEl = root.select(enclosingDivID_selector + " svg").node(); + svgCode = putIntoIFrame(svgCode, svgEl); + } else if (!isLooseSecurityLevel) { + svgCode = purify.sanitize(svgCode, { + ADD_TAGS: DOMPURIFY_TAGS, + ADD_ATTR: DOMPURIFY_ATTR + }); + } + attachFunctions(); + if (parseEncounteredException) { + throw parseEncounteredException; + } + const tmpElementSelector = isSandboxed ? iFrameID_selector : enclosingDivID_selector; + const node = select(tmpElementSelector).node(); + if (node && "remove" in node) { + node.remove(); + } + return { + svg: svgCode, + bindFunctions: diag.db.bindFunctions + }; +}; +function initialize$1(options = {}) { + var _a; + if ((options == null ? void 0 : options.fontFamily) && !((_a = options.themeVariables) == null ? void 0 : _a.fontFamily)) { + if (!options.themeVariables) { + options.themeVariables = {}; + } + options.themeVariables.fontFamily = options.fontFamily; + } + saveConfigFromInitialize(options); + if ((options == null ? void 0 : options.theme) && options.theme in theme) { + options.themeVariables = theme[options.theme].getThemeVariables( + options.themeVariables + ); + } else if (options) { + options.themeVariables = theme.default.getThemeVariables(options.themeVariables); + } + const config2 = typeof options === "object" ? setSiteConfig(options) : getSiteConfig(); + setLogLevel$1(config2.logLevel); + addDiagrams(); +} +const getDiagramFromText = (text, metadata = {}) => { + const { code } = preprocessDiagram(text); + return getDiagramFromText$1(code, metadata); +}; +function addA11yInfo(diagramType, svgNode, a11yTitle, a11yDescr) { + setA11yDiagramInfo(svgNode, diagramType); + addSVGa11yTitleDescription(svgNode, a11yTitle, a11yDescr, svgNode.attr("id")); +} +const mermaidAPI = Object.freeze({ + render: render$1$1, + parse: parse$1$1, + getDiagramFromText, + initialize: initialize$1, + getConfig: getConfig$1, + setConfig: setConfig$1, + getSiteConfig, + updateSiteConfig, + reset: () => { + reset(); + }, + globalReset: () => { + reset(defaultConfig$1); + }, + defaultConfig: defaultConfig$1 +}); +setLogLevel$1(getConfig$1().logLevel); +reset(getConfig$1()); +const loadRegisteredDiagrams = async () => { + log$1.debug(`Loading registered diagrams`); + const results = await Promise.allSettled( + Object.entries(detectors).map(async ([key, { detector: detector2, loader: loader2 }]) => { + if (loader2) { + try { + getDiagram(key); + } catch (error) { + try { + const { diagram: diagram2, id: id2 } = await loader2(); + registerDiagram(id2, diagram2, detector2); + } catch (err) { + log$1.error(`Failed to load external diagram with key ${key}. Removing from detectors.`); + delete detectors[key]; + throw err; + } + } + } + }) + ); + const failed = results.filter((result) => result.status === "rejected"); + if (failed.length > 0) { + log$1.error(`Failed to load ${failed.length} external diagrams`); + for (const res of failed) { + log$1.error(res); + } + throw new Error(`Failed to load ${failed.length} external diagrams`); + } +}; +const handleError = (error, errors, parseError) => { + log$1.warn(error); + if (isDetailedError(error)) { + if (parseError) { + parseError(error.str, error.hash); + } + errors.push({ ...error, message: error.str, error }); + } else { + if (parseError) { + parseError(error); + } + if (error instanceof Error) { + errors.push({ + str: error.message, + message: error.message, + hash: error.name, + error + }); + } + } +}; +const run$3 = async function(options = { + querySelector: ".mermaid" +}) { + try { + await runThrowsErrors(options); + } catch (e) { + if (isDetailedError(e)) { + log$1.error(e.str); + } + if (mermaid.parseError) { + mermaid.parseError(e); + } + if (!options.suppressErrors) { + log$1.error("Use the suppressErrors option to suppress these errors"); + throw e; + } + } +}; +const runThrowsErrors = async function({ postRenderCallback, querySelector, nodes } = { + querySelector: ".mermaid" +}) { + const conf = mermaidAPI.getConfig(); + log$1.debug(`${!postRenderCallback ? "No " : ""}Callback function found`); + let nodesToProcess; + if (nodes) { + nodesToProcess = nodes; + } else if (querySelector) { + nodesToProcess = document.querySelectorAll(querySelector); + } else { + throw new Error("Nodes and querySelector are both undefined"); + } + log$1.debug(`Found ${nodesToProcess.length} diagrams`); + if ((conf == null ? void 0 : conf.startOnLoad) !== void 0) { + log$1.debug("Start On Load: " + (conf == null ? void 0 : conf.startOnLoad)); + mermaidAPI.updateSiteConfig({ startOnLoad: conf == null ? void 0 : conf.startOnLoad }); + } + const idGenerator = new utils.InitIDGenerator(conf.deterministicIds, conf.deterministicIDSeed); + let txt; + const errors = []; + for (const element of Array.from(nodesToProcess)) { + log$1.info("Rendering diagram: " + element.id); + /*! Check if previously processed */ + if (element.getAttribute("data-processed")) { + continue; + } + element.setAttribute("data-processed", "true"); + const id2 = `mermaid-${idGenerator.next()}`; + txt = element.innerHTML; + txt = dedent(utils.entityDecode(txt)).trim().replace(//gi, "
    "); + const init2 = utils.detectInit(txt); + if (init2) { + log$1.debug("Detected early reinit: ", init2); + } + try { + const { svg, bindFunctions } = await render$2(id2, txt, element); + element.innerHTML = svg; + if (postRenderCallback) { + await postRenderCallback(id2); + } + if (bindFunctions) { + bindFunctions(element); + } + } catch (error) { + handleError(error, errors, mermaid.parseError); + } + } + if (errors.length > 0) { + throw errors[0]; + } +}; +const initialize = function(config2) { + mermaidAPI.initialize(config2); +}; +const init = async function(config2, nodes, callback) { + log$1.warn("mermaid.init is deprecated. Please use run instead."); + if (config2) { + initialize(config2); + } + const runOptions = { postRenderCallback: callback, querySelector: ".mermaid" }; + if (typeof nodes === "string") { + runOptions.querySelector = nodes; + } else if (nodes) { + if (nodes instanceof HTMLElement) { + runOptions.nodes = [nodes]; + } else { + runOptions.nodes = nodes; + } + } + await run$3(runOptions); +}; +const registerExternalDiagrams = async (diagrams2, { + lazyLoad = true +} = {}) => { + registerLazyLoadedDiagrams(...diagrams2); + if (lazyLoad === false) { + await loadRegisteredDiagrams(); + } +}; +const contentLoaded = function() { + if (mermaid.startOnLoad) { + const { startOnLoad } = mermaidAPI.getConfig(); + if (startOnLoad) { + mermaid.run().catch((err) => log$1.error("Mermaid failed to initialize", err)); + } + } +}; +if (typeof document !== "undefined") { + /*! + * Wait for document loaded before starting the execution + */ + window.addEventListener("load", contentLoaded, false); +} +const setParseErrorHandler = function(parseErrorHandler) { + mermaid.parseError = parseErrorHandler; +}; +const executionQueue = []; +let executionQueueRunning = false; +const executeQueue = async () => { + if (executionQueueRunning) { + return; + } + executionQueueRunning = true; + while (executionQueue.length > 0) { + const f = executionQueue.shift(); + if (f) { + try { + await f(); + } catch (e) { + log$1.error("Error executing queue", e); + } + } + } + executionQueueRunning = false; +}; +const parse$4 = async (text, parseOptions) => { + return new Promise((resolve, reject) => { + const performCall = () => new Promise((res, rej) => { + mermaidAPI.parse(text, parseOptions).then( + (r) => { + res(r); + resolve(r); + }, + (e) => { + var _a; + log$1.error("Error parsing", e); + (_a = mermaid.parseError) == null ? void 0 : _a.call(mermaid, e); + rej(e); + reject(e); + } + ); + }); + executionQueue.push(performCall); + executeQueue().catch(reject); + }); +}; +const render$2 = (id2, text, container) => { + return new Promise((resolve, reject) => { + const performCall = () => new Promise((res, rej) => { + mermaidAPI.render(id2, text, container).then( + (r) => { + res(r); + resolve(r); + }, + (e) => { + var _a; + log$1.error("Error parsing", e); + (_a = mermaid.parseError) == null ? void 0 : _a.call(mermaid, e); + rej(e); + reject(e); + } + ); + }); + executionQueue.push(performCall); + executeQueue().catch(reject); + }); +}; +const mermaid = { + startOnLoad: true, + mermaidAPI, + parse: parse$4, + render: render$2, + init, + run: run$3, + registerExternalDiagrams, + initialize, + parseError: void 0, + contentLoaded, + setParseErrorHandler, + detectType +}; + +/** + * https://mermaid.js.org/config/usage.html + */ +mermaid.initialize({ startOnLoad: true }); +function parseMermaidHtml(el) { + return __awaiter(this, void 0, void 0, function () { + var nodes; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + nodes = el.querySelectorAll('pre.mermaid'); + // console.log('html ', nodes); + return [4 /*yield*/, mermaid.run({ + nodes: nodes, + })]; + case 1: + // console.log('html ', nodes); + _a.sent(); + return [2 /*return*/]; + } + }); + }); +} + +const drawRect$4 = (element, rectData) => { + const rectElement = element.append("rect"); + rectElement.attr("x", rectData.x); + rectElement.attr("y", rectData.y); + rectElement.attr("fill", rectData.fill); + rectElement.attr("stroke", rectData.stroke); + rectElement.attr("width", rectData.width); + rectElement.attr("height", rectData.height); + if (rectData.name) { + rectElement.attr("name", rectData.name); + } + rectData.rx !== void 0 && rectElement.attr("rx", rectData.rx); + rectData.ry !== void 0 && rectElement.attr("ry", rectData.ry); + if (rectData.attrs !== void 0) { + for (const attrKey in rectData.attrs) { + rectElement.attr(attrKey, rectData.attrs[attrKey]); + } + } + rectData.class !== void 0 && rectElement.attr("class", rectData.class); + return rectElement; +}; +const drawBackgroundRect$3 = (element, bounds) => { + const rectData = { + x: bounds.startx, + y: bounds.starty, + width: bounds.stopx - bounds.startx, + height: bounds.stopy - bounds.starty, + fill: bounds.fill, + stroke: bounds.stroke, + class: "rect" + }; + const rectElement = drawRect$4(element, rectData); + rectElement.lower(); +}; +const drawText$4 = (element, textData) => { + const nText = textData.text.replace(lineBreakRegex, " "); + const textElem = element.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.attr("class", "legend"); + textElem.style("text-anchor", textData.anchor); + textData.class !== void 0 && textElem.attr("class", textData.class); + const tspan = textElem.append("tspan"); + tspan.attr("x", textData.x + textData.textMargin * 2); + tspan.text(nText); + return textElem; +}; +const drawImage$1 = (elem, x, y, link) => { + const imageElement = elem.append("image"); + imageElement.attr("x", x); + imageElement.attr("y", y); + const sanitizedLink = dist$1.sanitizeUrl(link); + imageElement.attr("xlink:href", sanitizedLink); +}; +const drawEmbeddedImage = (element, x, y, link) => { + const imageElement = element.append("use"); + imageElement.attr("x", x); + imageElement.attr("y", y); + const sanitizedLink = dist$1.sanitizeUrl(link); + imageElement.attr("xlink:href", `#${sanitizedLink}`); +}; +const getNoteRect$2 = () => { + const noteRectData = { + x: 0, + y: 0, + width: 100, + height: 100, + fill: "#EDF2AE", + stroke: "#666", + anchor: "start", + rx: 0, + ry: 0 + }; + return noteRectData; +}; +const getTextObj$2 = () => { + const testObject = { + x: 0, + y: 0, + width: 100, + height: 100, + "text-anchor": "start", + style: "#666", + textMargin: 0, + rx: 0, + ry: 0, + tspan: true + }; + return testObject; +}; + +var parser$i = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 24], $V1 = [1, 25], $V2 = [1, 26], $V3 = [1, 27], $V4 = [1, 28], $V5 = [1, 63], $V6 = [1, 64], $V7 = [1, 65], $V8 = [1, 66], $V9 = [1, 67], $Va = [1, 68], $Vb = [1, 69], $Vc = [1, 29], $Vd = [1, 30], $Ve = [1, 31], $Vf = [1, 32], $Vg = [1, 33], $Vh = [1, 34], $Vi = [1, 35], $Vj = [1, 36], $Vk = [1, 37], $Vl = [1, 38], $Vm = [1, 39], $Vn = [1, 40], $Vo = [1, 41], $Vp = [1, 42], $Vq = [1, 43], $Vr = [1, 44], $Vs = [1, 45], $Vt = [1, 46], $Vu = [1, 47], $Vv = [1, 48], $Vw = [1, 50], $Vx = [1, 51], $Vy = [1, 52], $Vz = [1, 53], $VA = [1, 54], $VB = [1, 55], $VC = [1, 56], $VD = [1, 57], $VE = [1, 58], $VF = [1, 59], $VG = [1, 60], $VH = [14, 42], $VI = [14, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74], $VJ = [12, 14, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74], $VK = [1, 82], $VL = [1, 83], $VM = [1, 84], $VN = [1, 85], $VO = [12, 14, 42], $VP = [12, 14, 33, 42], $VQ = [12, 14, 33, 42, 76, 77, 79, 80], $VR = [12, 33], $VS = [34, 36, 37, 38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mermaidDoc": 4, "direction": 5, "direction_tb": 6, "direction_bt": 7, "direction_rl": 8, "direction_lr": 9, "graphConfig": 10, "C4_CONTEXT": 11, "NEWLINE": 12, "statements": 13, "EOF": 14, "C4_CONTAINER": 15, "C4_COMPONENT": 16, "C4_DYNAMIC": 17, "C4_DEPLOYMENT": 18, "otherStatements": 19, "diagramStatements": 20, "otherStatement": 21, "title": 22, "accDescription": 23, "acc_title": 24, "acc_title_value": 25, "acc_descr": 26, "acc_descr_value": 27, "acc_descr_multiline_value": 28, "boundaryStatement": 29, "boundaryStartStatement": 30, "boundaryStopStatement": 31, "boundaryStart": 32, "LBRACE": 33, "ENTERPRISE_BOUNDARY": 34, "attributes": 35, "SYSTEM_BOUNDARY": 36, "BOUNDARY": 37, "CONTAINER_BOUNDARY": 38, "NODE": 39, "NODE_L": 40, "NODE_R": 41, "RBRACE": 42, "diagramStatement": 43, "PERSON": 44, "PERSON_EXT": 45, "SYSTEM": 46, "SYSTEM_DB": 47, "SYSTEM_QUEUE": 48, "SYSTEM_EXT": 49, "SYSTEM_EXT_DB": 50, "SYSTEM_EXT_QUEUE": 51, "CONTAINER": 52, "CONTAINER_DB": 53, "CONTAINER_QUEUE": 54, "CONTAINER_EXT": 55, "CONTAINER_EXT_DB": 56, "CONTAINER_EXT_QUEUE": 57, "COMPONENT": 58, "COMPONENT_DB": 59, "COMPONENT_QUEUE": 60, "COMPONENT_EXT": 61, "COMPONENT_EXT_DB": 62, "COMPONENT_EXT_QUEUE": 63, "REL": 64, "BIREL": 65, "REL_U": 66, "REL_D": 67, "REL_L": 68, "REL_R": 69, "REL_B": 70, "REL_INDEX": 71, "UPDATE_EL_STYLE": 72, "UPDATE_REL_STYLE": 73, "UPDATE_LAYOUT_CONFIG": 74, "attribute": 75, "STR": 76, "STR_KEY": 77, "STR_VALUE": 78, "ATTRIBUTE": 79, "ATTRIBUTE_EMPTY": 80, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 6: "direction_tb", 7: "direction_bt", 8: "direction_rl", 9: "direction_lr", 11: "C4_CONTEXT", 12: "NEWLINE", 14: "EOF", 15: "C4_CONTAINER", 16: "C4_COMPONENT", 17: "C4_DYNAMIC", 18: "C4_DEPLOYMENT", 22: "title", 23: "accDescription", 24: "acc_title", 25: "acc_title_value", 26: "acc_descr", 27: "acc_descr_value", 28: "acc_descr_multiline_value", 33: "LBRACE", 34: "ENTERPRISE_BOUNDARY", 36: "SYSTEM_BOUNDARY", 37: "BOUNDARY", 38: "CONTAINER_BOUNDARY", 39: "NODE", 40: "NODE_L", 41: "NODE_R", 42: "RBRACE", 44: "PERSON", 45: "PERSON_EXT", 46: "SYSTEM", 47: "SYSTEM_DB", 48: "SYSTEM_QUEUE", 49: "SYSTEM_EXT", 50: "SYSTEM_EXT_DB", 51: "SYSTEM_EXT_QUEUE", 52: "CONTAINER", 53: "CONTAINER_DB", 54: "CONTAINER_QUEUE", 55: "CONTAINER_EXT", 56: "CONTAINER_EXT_DB", 57: "CONTAINER_EXT_QUEUE", 58: "COMPONENT", 59: "COMPONENT_DB", 60: "COMPONENT_QUEUE", 61: "COMPONENT_EXT", 62: "COMPONENT_EXT_DB", 63: "COMPONENT_EXT_QUEUE", 64: "REL", 65: "BIREL", 66: "REL_U", 67: "REL_D", 68: "REL_L", 69: "REL_R", 70: "REL_B", 71: "REL_INDEX", 72: "UPDATE_EL_STYLE", 73: "UPDATE_REL_STYLE", 74: "UPDATE_LAYOUT_CONFIG", 76: "STR", 77: "STR_KEY", 78: "STR_VALUE", 79: "ATTRIBUTE", 80: "ATTRIBUTE_EMPTY" }, + productions_: [0, [3, 1], [3, 1], [5, 1], [5, 1], [5, 1], [5, 1], [4, 1], [10, 4], [10, 4], [10, 4], [10, 4], [10, 4], [13, 1], [13, 1], [13, 2], [19, 1], [19, 2], [19, 3], [21, 1], [21, 1], [21, 2], [21, 2], [21, 1], [29, 3], [30, 3], [30, 3], [30, 4], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [32, 2], [31, 1], [20, 1], [20, 2], [20, 3], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 1], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [43, 2], [35, 1], [35, 2], [75, 1], [75, 2], [75, 1], [75, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setDirection("TB"); + break; + case 4: + yy.setDirection("BT"); + break; + case 5: + yy.setDirection("RL"); + break; + case 6: + yy.setDirection("LR"); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + yy.setC4Type($$[$0 - 3]); + break; + case 19: + yy.setTitle($$[$0].substring(6)); + this.$ = $$[$0].substring(6); + break; + case 20: + yy.setAccDescription($$[$0].substring(15)); + this.$ = $$[$0].substring(15); + break; + case 21: + this.$ = $$[$0].trim(); + yy.setTitle(this.$); + break; + case 22: + case 23: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 28: + case 29: + $$[$0].splice(2, 0, "ENTERPRISE"); + yy.addPersonOrSystemBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 30: + yy.addPersonOrSystemBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 31: + $$[$0].splice(2, 0, "CONTAINER"); + yy.addContainerBoundary(...$$[$0]); + this.$ = $$[$0]; + break; + case 32: + yy.addDeploymentNode("node", ...$$[$0]); + this.$ = $$[$0]; + break; + case 33: + yy.addDeploymentNode("nodeL", ...$$[$0]); + this.$ = $$[$0]; + break; + case 34: + yy.addDeploymentNode("nodeR", ...$$[$0]); + this.$ = $$[$0]; + break; + case 35: + yy.popBoundaryParseStack(); + break; + case 39: + yy.addPersonOrSystem("person", ...$$[$0]); + this.$ = $$[$0]; + break; + case 40: + yy.addPersonOrSystem("external_person", ...$$[$0]); + this.$ = $$[$0]; + break; + case 41: + yy.addPersonOrSystem("system", ...$$[$0]); + this.$ = $$[$0]; + break; + case 42: + yy.addPersonOrSystem("system_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 43: + yy.addPersonOrSystem("system_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 44: + yy.addPersonOrSystem("external_system", ...$$[$0]); + this.$ = $$[$0]; + break; + case 45: + yy.addPersonOrSystem("external_system_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 46: + yy.addPersonOrSystem("external_system_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 47: + yy.addContainer("container", ...$$[$0]); + this.$ = $$[$0]; + break; + case 48: + yy.addContainer("container_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 49: + yy.addContainer("container_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 50: + yy.addContainer("external_container", ...$$[$0]); + this.$ = $$[$0]; + break; + case 51: + yy.addContainer("external_container_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 52: + yy.addContainer("external_container_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 53: + yy.addComponent("component", ...$$[$0]); + this.$ = $$[$0]; + break; + case 54: + yy.addComponent("component_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 55: + yy.addComponent("component_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 56: + yy.addComponent("external_component", ...$$[$0]); + this.$ = $$[$0]; + break; + case 57: + yy.addComponent("external_component_db", ...$$[$0]); + this.$ = $$[$0]; + break; + case 58: + yy.addComponent("external_component_queue", ...$$[$0]); + this.$ = $$[$0]; + break; + case 60: + yy.addRel("rel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 61: + yy.addRel("birel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 62: + yy.addRel("rel_u", ...$$[$0]); + this.$ = $$[$0]; + break; + case 63: + yy.addRel("rel_d", ...$$[$0]); + this.$ = $$[$0]; + break; + case 64: + yy.addRel("rel_l", ...$$[$0]); + this.$ = $$[$0]; + break; + case 65: + yy.addRel("rel_r", ...$$[$0]); + this.$ = $$[$0]; + break; + case 66: + yy.addRel("rel_b", ...$$[$0]); + this.$ = $$[$0]; + break; + case 67: + $$[$0].splice(0, 1); + yy.addRel("rel", ...$$[$0]); + this.$ = $$[$0]; + break; + case 68: + yy.updateElStyle("update_el_style", ...$$[$0]); + this.$ = $$[$0]; + break; + case 69: + yy.updateRelStyle("update_rel_style", ...$$[$0]); + this.$ = $$[$0]; + break; + case 70: + yy.updateLayoutConfig("update_layout_config", ...$$[$0]); + this.$ = $$[$0]; + break; + case 71: + this.$ = [$$[$0]]; + break; + case 72: + $$[$0].unshift($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 73: + case 75: + this.$ = $$[$0].trim(); + break; + case 74: + let kv = {}; + kv[$$[$0 - 1].trim()] = $$[$0].trim(); + this.$ = kv; + break; + case 76: + this.$ = ""; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 7: [1, 6], 8: [1, 7], 9: [1, 8], 10: 4, 11: [1, 9], 15: [1, 10], 16: [1, 11], 17: [1, 12], 18: [1, 13] }, { 1: [3] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 7] }, { 1: [2, 3] }, { 1: [2, 4] }, { 1: [2, 5] }, { 1: [2, 6] }, { 12: [1, 14] }, { 12: [1, 15] }, { 12: [1, 16] }, { 12: [1, 17] }, { 12: [1, 18] }, { 13: 19, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 70, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 71, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 72, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 13: 73, 19: 20, 20: 21, 21: 22, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 14: [1, 74] }, o($VH, [2, 13], { 43: 23, 29: 49, 30: 61, 32: 62, 20: 75, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }), o($VH, [2, 14]), o($VI, [2, 16], { 12: [1, 76] }), o($VH, [2, 36], { 12: [1, 77] }), o($VJ, [2, 19]), o($VJ, [2, 20]), { 25: [1, 78] }, { 27: [1, 79] }, o($VJ, [2, 23]), { 35: 80, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 86, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 87, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 88, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 89, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 90, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 91, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 92, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 93, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 94, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 95, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 96, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 97, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 98, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 99, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 100, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 101, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 102, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 103, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 104, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, o($VO, [2, 59]), { 35: 105, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 106, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 107, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 108, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 109, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 110, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 111, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 112, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 113, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 114, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 115, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 20: 116, 29: 49, 30: 61, 32: 62, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 43: 23, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }, { 12: [1, 118], 33: [1, 117] }, { 35: 119, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 120, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 121, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 122, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 123, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 124, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 35: 125, 75: 81, 76: $VK, 77: $VL, 79: $VM, 80: $VN }, { 14: [1, 126] }, { 14: [1, 127] }, { 14: [1, 128] }, { 14: [1, 129] }, { 1: [2, 8] }, o($VH, [2, 15]), o($VI, [2, 17], { 21: 22, 19: 130, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4 }), o($VH, [2, 37], { 19: 20, 20: 21, 21: 22, 43: 23, 29: 49, 30: 61, 32: 62, 13: 131, 22: $V0, 23: $V1, 24: $V2, 26: $V3, 28: $V4, 34: $V5, 36: $V6, 37: $V7, 38: $V8, 39: $V9, 40: $Va, 41: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi, 51: $Vj, 52: $Vk, 53: $Vl, 54: $Vm, 55: $Vn, 56: $Vo, 57: $Vp, 58: $Vq, 59: $Vr, 60: $Vs, 61: $Vt, 62: $Vu, 63: $Vv, 64: $Vw, 65: $Vx, 66: $Vy, 67: $Vz, 68: $VA, 69: $VB, 70: $VC, 71: $VD, 72: $VE, 73: $VF, 74: $VG }), o($VJ, [2, 21]), o($VJ, [2, 22]), o($VO, [2, 39]), o($VP, [2, 71], { 75: 81, 35: 132, 76: $VK, 77: $VL, 79: $VM, 80: $VN }), o($VQ, [2, 73]), { 78: [1, 133] }, o($VQ, [2, 75]), o($VQ, [2, 76]), o($VO, [2, 40]), o($VO, [2, 41]), o($VO, [2, 42]), o($VO, [2, 43]), o($VO, [2, 44]), o($VO, [2, 45]), o($VO, [2, 46]), o($VO, [2, 47]), o($VO, [2, 48]), o($VO, [2, 49]), o($VO, [2, 50]), o($VO, [2, 51]), o($VO, [2, 52]), o($VO, [2, 53]), o($VO, [2, 54]), o($VO, [2, 55]), o($VO, [2, 56]), o($VO, [2, 57]), o($VO, [2, 58]), o($VO, [2, 60]), o($VO, [2, 61]), o($VO, [2, 62]), o($VO, [2, 63]), o($VO, [2, 64]), o($VO, [2, 65]), o($VO, [2, 66]), o($VO, [2, 67]), o($VO, [2, 68]), o($VO, [2, 69]), o($VO, [2, 70]), { 31: 134, 42: [1, 135] }, { 12: [1, 136] }, { 33: [1, 137] }, o($VR, [2, 28]), o($VR, [2, 29]), o($VR, [2, 30]), o($VR, [2, 31]), o($VR, [2, 32]), o($VR, [2, 33]), o($VR, [2, 34]), { 1: [2, 9] }, { 1: [2, 10] }, { 1: [2, 11] }, { 1: [2, 12] }, o($VI, [2, 18]), o($VH, [2, 38]), o($VP, [2, 72]), o($VQ, [2, 74]), o($VO, [2, 24]), o($VO, [2, 35]), o($VS, [2, 25]), o($VS, [2, 26], { 12: [1, 138] }), o($VS, [2, 27])], + defaultActions: { 2: [2, 1], 3: [2, 2], 4: [2, 7], 5: [2, 3], 6: [2, 4], 7: [2, 5], 8: [2, 6], 74: [2, 8], 126: [2, 9], 127: [2, 10], 128: [2, 11], 129: [2, 12] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c2 = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c2 + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 6; + case 1: + return 7; + case 2: + return 8; + case 3: + return 9; + case 4: + return 22; + case 5: + return 23; + case 6: + this.begin("acc_title"); + return 24; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 26; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + break; + case 14: + c; + break; + case 15: + return 12; + case 16: + break; + case 17: + return 11; + case 18: + return 15; + case 19: + return 16; + case 20: + return 17; + case 21: + return 18; + case 22: + this.begin("person_ext"); + return 45; + case 23: + this.begin("person"); + return 44; + case 24: + this.begin("system_ext_queue"); + return 51; + case 25: + this.begin("system_ext_db"); + return 50; + case 26: + this.begin("system_ext"); + return 49; + case 27: + this.begin("system_queue"); + return 48; + case 28: + this.begin("system_db"); + return 47; + case 29: + this.begin("system"); + return 46; + case 30: + this.begin("boundary"); + return 37; + case 31: + this.begin("enterprise_boundary"); + return 34; + case 32: + this.begin("system_boundary"); + return 36; + case 33: + this.begin("container_ext_queue"); + return 57; + case 34: + this.begin("container_ext_db"); + return 56; + case 35: + this.begin("container_ext"); + return 55; + case 36: + this.begin("container_queue"); + return 54; + case 37: + this.begin("container_db"); + return 53; + case 38: + this.begin("container"); + return 52; + case 39: + this.begin("container_boundary"); + return 38; + case 40: + this.begin("component_ext_queue"); + return 63; + case 41: + this.begin("component_ext_db"); + return 62; + case 42: + this.begin("component_ext"); + return 61; + case 43: + this.begin("component_queue"); + return 60; + case 44: + this.begin("component_db"); + return 59; + case 45: + this.begin("component"); + return 58; + case 46: + this.begin("node"); + return 39; + case 47: + this.begin("node"); + return 39; + case 48: + this.begin("node_l"); + return 40; + case 49: + this.begin("node_r"); + return 41; + case 50: + this.begin("rel"); + return 64; + case 51: + this.begin("birel"); + return 65; + case 52: + this.begin("rel_u"); + return 66; + case 53: + this.begin("rel_u"); + return 66; + case 54: + this.begin("rel_d"); + return 67; + case 55: + this.begin("rel_d"); + return 67; + case 56: + this.begin("rel_l"); + return 68; + case 57: + this.begin("rel_l"); + return 68; + case 58: + this.begin("rel_r"); + return 69; + case 59: + this.begin("rel_r"); + return 69; + case 60: + this.begin("rel_b"); + return 70; + case 61: + this.begin("rel_index"); + return 71; + case 62: + this.begin("update_el_style"); + return 72; + case 63: + this.begin("update_rel_style"); + return 73; + case 64: + this.begin("update_layout_config"); + return 74; + case 65: + return "EOF_IN_STRUCT"; + case 66: + this.begin("attribute"); + return "ATTRIBUTE_EMPTY"; + case 67: + this.begin("attribute"); + break; + case 68: + this.popState(); + this.popState(); + break; + case 69: + return 80; + case 70: + break; + case 71: + return 80; + case 72: + this.begin("string"); + break; + case 73: + this.popState(); + break; + case 74: + return "STR"; + case 75: + this.begin("string_kv"); + break; + case 76: + this.begin("string_kv_key"); + return "STR_KEY"; + case 77: + this.popState(); + this.begin("string_kv_value"); + break; + case 78: + return "STR_VALUE"; + case 79: + this.popState(); + this.popState(); + break; + case 80: + return "STR"; + case 81: + return "LBRACE"; + case 82: + return "RBRACE"; + case 83: + return "SPACE"; + case 84: + return "EOL"; + case 85: + return 14; + } + }, + rules: [/^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:title\s[^#\n;]+)/, /^(?:accDescription\s[^#\n;]+)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/, /^(?:%%[^\n]*(\r?\n)*)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:C4Context\b)/, /^(?:C4Container\b)/, /^(?:C4Component\b)/, /^(?:C4Dynamic\b)/, /^(?:C4Deployment\b)/, /^(?:Person_Ext\b)/, /^(?:Person\b)/, /^(?:SystemQueue_Ext\b)/, /^(?:SystemDb_Ext\b)/, /^(?:System_Ext\b)/, /^(?:SystemQueue\b)/, /^(?:SystemDb\b)/, /^(?:System\b)/, /^(?:Boundary\b)/, /^(?:Enterprise_Boundary\b)/, /^(?:System_Boundary\b)/, /^(?:ContainerQueue_Ext\b)/, /^(?:ContainerDb_Ext\b)/, /^(?:Container_Ext\b)/, /^(?:ContainerQueue\b)/, /^(?:ContainerDb\b)/, /^(?:Container\b)/, /^(?:Container_Boundary\b)/, /^(?:ComponentQueue_Ext\b)/, /^(?:ComponentDb_Ext\b)/, /^(?:Component_Ext\b)/, /^(?:ComponentQueue\b)/, /^(?:ComponentDb\b)/, /^(?:Component\b)/, /^(?:Deployment_Node\b)/, /^(?:Node\b)/, /^(?:Node_L\b)/, /^(?:Node_R\b)/, /^(?:Rel\b)/, /^(?:BiRel\b)/, /^(?:Rel_Up\b)/, /^(?:Rel_U\b)/, /^(?:Rel_Down\b)/, /^(?:Rel_D\b)/, /^(?:Rel_Left\b)/, /^(?:Rel_L\b)/, /^(?:Rel_Right\b)/, /^(?:Rel_R\b)/, /^(?:Rel_Back\b)/, /^(?:RelIndex\b)/, /^(?:UpdateElementStyle\b)/, /^(?:UpdateRelStyle\b)/, /^(?:UpdateLayoutConfig\b)/, /^(?:$)/, /^(?:[(][ ]*[,])/, /^(?:[(])/, /^(?:[)])/, /^(?:,,)/, /^(?:,)/, /^(?:[ ]*["]["])/, /^(?:[ ]*["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:[ ]*[\$])/, /^(?:[^=]*)/, /^(?:[=][ ]*["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:[^,]+)/, /^(?:\{)/, /^(?:\})/, /^(?:[\s]+)/, /^(?:[\n\r]+)/, /^(?:$)/], + conditions: { "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "string_kv_value": { "rules": [78, 79], "inclusive": false }, "string_kv_key": { "rules": [77], "inclusive": false }, "string_kv": { "rules": [76], "inclusive": false }, "string": { "rules": [73, 74], "inclusive": false }, "attribute": { "rules": [68, 69, 70, 71, 72, 75, 80], "inclusive": false }, "update_layout_config": { "rules": [65, 66, 67, 68], "inclusive": false }, "update_rel_style": { "rules": [65, 66, 67, 68], "inclusive": false }, "update_el_style": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_b": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_r": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_l": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_d": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_u": { "rules": [65, 66, 67, 68], "inclusive": false }, "rel_bi": { "rules": [], "inclusive": false }, "rel": { "rules": [65, 66, 67, 68], "inclusive": false }, "node_r": { "rules": [65, 66, 67, 68], "inclusive": false }, "node_l": { "rules": [65, 66, 67, 68], "inclusive": false }, "node": { "rules": [65, 66, 67, 68], "inclusive": false }, "index": { "rules": [], "inclusive": false }, "rel_index": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_ext_queue": { "rules": [], "inclusive": false }, "component_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "component_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "component": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "container_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "container": { "rules": [65, 66, 67, 68], "inclusive": false }, "birel": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "enterprise_boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "boundary": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_queue": { "rules": [65, 66, 67, 68], "inclusive": false }, "system_db": { "rules": [65, 66, 67, 68], "inclusive": false }, "system": { "rules": [65, 66, 67, 68], "inclusive": false }, "person_ext": { "rules": [65, 66, 67, 68], "inclusive": false }, "person": { "rules": [65, 66, 67, 68], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 81, 82, 83, 84, 85], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$i.parser = parser$i; +const parser$1$e = parser$i; +let c4ShapeArray = []; +let boundaryParseStack = [""]; +let currentBoundaryParse = "global"; +let parentBoundaryParse = ""; +let boundaries = [ + { + alias: "global", + label: { text: "global" }, + type: { text: "global" }, + tags: null, + link: null, + parentBoundary: "" + } +]; +let rels = []; +let title = ""; +let wrapEnabled = false; +let c4ShapeInRow$1 = 4; +let c4BoundaryInRow$1 = 2; +var c4Type; +const getC4Type = function() { + return c4Type; +}; +const setC4Type = function(c4TypeParam) { + let sanitizedText = sanitizeText$2$1(c4TypeParam, getConfig$2()); + c4Type = sanitizedText; +}; +const addRel = function(type, from, to, label, techn, descr, sprite, tags, link) { + if (type === void 0 || type === null || from === void 0 || from === null || to === void 0 || to === null || label === void 0 || label === null) { + return; + } + let rel = {}; + const old = rels.find((rel2) => rel2.from === from && rel2.to === to); + if (old) { + rel = old; + } else { + rels.push(rel); + } + rel.type = type; + rel.from = from; + rel.to = to; + rel.label = { text: label }; + if (techn === void 0 || techn === null) { + rel.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + rel[key] = { text: value }; + } else { + rel.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + rel.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + rel[key] = { text: value }; + } else { + rel.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + rel[key] = value; + } else { + rel.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + rel[key] = value; + } else { + rel.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + rel[key] = value; + } else { + rel.link = link; + } + rel.wrap = autoWrap$1(); +}; +const addPersonOrSystem = function(typeC4Shape, alias, label, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let personOrSystem = {}; + const old = c4ShapeArray.find((personOrSystem2) => personOrSystem2.alias === alias); + if (old && alias === old.alias) { + personOrSystem = old; + } else { + personOrSystem.alias = alias; + c4ShapeArray.push(personOrSystem); + } + if (label === void 0 || label === null) { + personOrSystem.label = { text: "" }; + } else { + personOrSystem.label = { text: label }; + } + if (descr === void 0 || descr === null) { + personOrSystem.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + personOrSystem[key] = { text: value }; + } else { + personOrSystem.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + personOrSystem[key] = value; + } else { + personOrSystem.link = link; + } + personOrSystem.typeC4Shape = { text: typeC4Shape }; + personOrSystem.parentBoundary = currentBoundaryParse; + personOrSystem.wrap = autoWrap$1(); +}; +const addContainer = function(typeC4Shape, alias, label, techn, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let container = {}; + const old = c4ShapeArray.find((container2) => container2.alias === alias); + if (old && alias === old.alias) { + container = old; + } else { + container.alias = alias; + c4ShapeArray.push(container); + } + if (label === void 0 || label === null) { + container.label = { text: "" }; + } else { + container.label = { text: label }; + } + if (techn === void 0 || techn === null) { + container.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + container[key] = { text: value }; + } else { + container.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + container.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + container[key] = { text: value }; + } else { + container.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + container[key] = value; + } else { + container.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + container[key] = value; + } else { + container.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + container[key] = value; + } else { + container.link = link; + } + container.wrap = autoWrap$1(); + container.typeC4Shape = { text: typeC4Shape }; + container.parentBoundary = currentBoundaryParse; +}; +const addComponent = function(typeC4Shape, alias, label, techn, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let component = {}; + const old = c4ShapeArray.find((component2) => component2.alias === alias); + if (old && alias === old.alias) { + component = old; + } else { + component.alias = alias; + c4ShapeArray.push(component); + } + if (label === void 0 || label === null) { + component.label = { text: "" }; + } else { + component.label = { text: label }; + } + if (techn === void 0 || techn === null) { + component.techn = { text: "" }; + } else { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + component[key] = { text: value }; + } else { + component.techn = { text: techn }; + } + } + if (descr === void 0 || descr === null) { + component.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + component[key] = { text: value }; + } else { + component.descr = { text: descr }; + } + } + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + component[key] = value; + } else { + component.sprite = sprite; + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + component[key] = value; + } else { + component.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + component[key] = value; + } else { + component.link = link; + } + component.wrap = autoWrap$1(); + component.typeC4Shape = { text: typeC4Shape }; + component.parentBoundary = currentBoundaryParse; +}; +const addPersonOrSystemBoundary = function(alias, label, type, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "system" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap$1(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const addContainerBoundary = function(alias, label, type, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "container" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap$1(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const addDeploymentNode = function(nodeType, alias, label, type, descr, sprite, tags, link) { + if (alias === null || label === null) { + return; + } + let boundary = {}; + const old = boundaries.find((boundary2) => boundary2.alias === alias); + if (old && alias === old.alias) { + boundary = old; + } else { + boundary.alias = alias; + boundaries.push(boundary); + } + if (label === void 0 || label === null) { + boundary.label = { text: "" }; + } else { + boundary.label = { text: label }; + } + if (type === void 0 || type === null) { + boundary.type = { text: "node" }; + } else { + if (typeof type === "object") { + let [key, value] = Object.entries(type)[0]; + boundary[key] = { text: value }; + } else { + boundary.type = { text: type }; + } + } + if (descr === void 0 || descr === null) { + boundary.descr = { text: "" }; + } else { + if (typeof descr === "object") { + let [key, value] = Object.entries(descr)[0]; + boundary[key] = { text: value }; + } else { + boundary.descr = { text: descr }; + } + } + if (typeof tags === "object") { + let [key, value] = Object.entries(tags)[0]; + boundary[key] = value; + } else { + boundary.tags = tags; + } + if (typeof link === "object") { + let [key, value] = Object.entries(link)[0]; + boundary[key] = value; + } else { + boundary.link = link; + } + boundary.nodeType = nodeType; + boundary.parentBoundary = currentBoundaryParse; + boundary.wrap = autoWrap$1(); + parentBoundaryParse = currentBoundaryParse; + currentBoundaryParse = alias; + boundaryParseStack.push(parentBoundaryParse); +}; +const popBoundaryParseStack = function() { + currentBoundaryParse = parentBoundaryParse; + boundaryParseStack.pop(); + parentBoundaryParse = boundaryParseStack.pop(); + boundaryParseStack.push(parentBoundaryParse); +}; +const updateElStyle = function(typeC4Shape, elementName, bgColor, fontColor, borderColor, shadowing, shape, sprite, techn, legendText, legendSprite) { + let old = c4ShapeArray.find((element) => element.alias === elementName); + if (old === void 0) { + old = boundaries.find((element) => element.alias === elementName); + if (old === void 0) { + return; + } + } + if (bgColor !== void 0 && bgColor !== null) { + if (typeof bgColor === "object") { + let [key, value] = Object.entries(bgColor)[0]; + old[key] = value; + } else { + old.bgColor = bgColor; + } + } + if (fontColor !== void 0 && fontColor !== null) { + if (typeof fontColor === "object") { + let [key, value] = Object.entries(fontColor)[0]; + old[key] = value; + } else { + old.fontColor = fontColor; + } + } + if (borderColor !== void 0 && borderColor !== null) { + if (typeof borderColor === "object") { + let [key, value] = Object.entries(borderColor)[0]; + old[key] = value; + } else { + old.borderColor = borderColor; + } + } + if (shadowing !== void 0 && shadowing !== null) { + if (typeof shadowing === "object") { + let [key, value] = Object.entries(shadowing)[0]; + old[key] = value; + } else { + old.shadowing = shadowing; + } + } + if (shape !== void 0 && shape !== null) { + if (typeof shape === "object") { + let [key, value] = Object.entries(shape)[0]; + old[key] = value; + } else { + old.shape = shape; + } + } + if (sprite !== void 0 && sprite !== null) { + if (typeof sprite === "object") { + let [key, value] = Object.entries(sprite)[0]; + old[key] = value; + } else { + old.sprite = sprite; + } + } + if (techn !== void 0 && techn !== null) { + if (typeof techn === "object") { + let [key, value] = Object.entries(techn)[0]; + old[key] = value; + } else { + old.techn = techn; + } + } + if (legendText !== void 0 && legendText !== null) { + if (typeof legendText === "object") { + let [key, value] = Object.entries(legendText)[0]; + old[key] = value; + } else { + old.legendText = legendText; + } + } + if (legendSprite !== void 0 && legendSprite !== null) { + if (typeof legendSprite === "object") { + let [key, value] = Object.entries(legendSprite)[0]; + old[key] = value; + } else { + old.legendSprite = legendSprite; + } + } +}; +const updateRelStyle = function(typeC4Shape, from, to, textColor, lineColor, offsetX, offsetY) { + const old = rels.find((rel) => rel.from === from && rel.to === to); + if (old === void 0) { + return; + } + if (textColor !== void 0 && textColor !== null) { + if (typeof textColor === "object") { + let [key, value] = Object.entries(textColor)[0]; + old[key] = value; + } else { + old.textColor = textColor; + } + } + if (lineColor !== void 0 && lineColor !== null) { + if (typeof lineColor === "object") { + let [key, value] = Object.entries(lineColor)[0]; + old[key] = value; + } else { + old.lineColor = lineColor; + } + } + if (offsetX !== void 0 && offsetX !== null) { + if (typeof offsetX === "object") { + let [key, value] = Object.entries(offsetX)[0]; + old[key] = parseInt(value); + } else { + old.offsetX = parseInt(offsetX); + } + } + if (offsetY !== void 0 && offsetY !== null) { + if (typeof offsetY === "object") { + let [key, value] = Object.entries(offsetY)[0]; + old[key] = parseInt(value); + } else { + old.offsetY = parseInt(offsetY); + } + } +}; +const updateLayoutConfig = function(typeC4Shape, c4ShapeInRowParam, c4BoundaryInRowParam) { + let c4ShapeInRowValue = c4ShapeInRow$1; + let c4BoundaryInRowValue = c4BoundaryInRow$1; + if (typeof c4ShapeInRowParam === "object") { + const value = Object.values(c4ShapeInRowParam)[0]; + c4ShapeInRowValue = parseInt(value); + } else { + c4ShapeInRowValue = parseInt(c4ShapeInRowParam); + } + if (typeof c4BoundaryInRowParam === "object") { + const value = Object.values(c4BoundaryInRowParam)[0]; + c4BoundaryInRowValue = parseInt(value); + } else { + c4BoundaryInRowValue = parseInt(c4BoundaryInRowParam); + } + if (c4ShapeInRowValue >= 1) { + c4ShapeInRow$1 = c4ShapeInRowValue; + } + if (c4BoundaryInRowValue >= 1) { + c4BoundaryInRow$1 = c4BoundaryInRowValue; + } +}; +const getC4ShapeInRow = function() { + return c4ShapeInRow$1; +}; +const getC4BoundaryInRow = function() { + return c4BoundaryInRow$1; +}; +const getCurrentBoundaryParse = function() { + return currentBoundaryParse; +}; +const getParentBoundaryParse = function() { + return parentBoundaryParse; +}; +const getC4ShapeArray = function(parentBoundary) { + if (parentBoundary === void 0 || parentBoundary === null) { + return c4ShapeArray; + } else { + return c4ShapeArray.filter((personOrSystem) => { + return personOrSystem.parentBoundary === parentBoundary; + }); + } +}; +const getC4Shape = function(alias) { + return c4ShapeArray.find((personOrSystem) => personOrSystem.alias === alias); +}; +const getC4ShapeKeys = function(parentBoundary) { + return Object.keys(getC4ShapeArray(parentBoundary)); +}; +const getBoundaries = function(parentBoundary) { + if (parentBoundary === void 0 || parentBoundary === null) { + return boundaries; + } else { + return boundaries.filter((boundary) => boundary.parentBoundary === parentBoundary); + } +}; +const getBoundarys = getBoundaries; +const getRels = function() { + return rels; +}; +const getTitle = function() { + return title; +}; +const setWrap$1 = function(wrapSetting) { + wrapEnabled = wrapSetting; +}; +const autoWrap$1 = function() { + return wrapEnabled; +}; +const clear$j = function() { + c4ShapeArray = []; + boundaries = [ + { + alias: "global", + label: { text: "global" }, + type: { text: "global" }, + tags: null, + link: null, + parentBoundary: "" + } + ]; + parentBoundaryParse = ""; + currentBoundaryParse = "global"; + boundaryParseStack = [""]; + rels = []; + boundaryParseStack = [""]; + title = ""; + wrapEnabled = false; + c4ShapeInRow$1 = 4; + c4BoundaryInRow$1 = 2; +}; +const LINETYPE$1 = { + SOLID: 0, + DOTTED: 1, + NOTE: 2, + SOLID_CROSS: 3, + DOTTED_CROSS: 4, + SOLID_OPEN: 5, + DOTTED_OPEN: 6, + LOOP_START: 10, + LOOP_END: 11, + ALT_START: 12, + ALT_ELSE: 13, + ALT_END: 14, + OPT_START: 15, + OPT_END: 16, + ACTIVE_START: 17, + ACTIVE_END: 18, + PAR_START: 19, + PAR_AND: 20, + PAR_END: 21, + RECT_START: 22, + RECT_END: 23, + SOLID_POINT: 24, + DOTTED_POINT: 25 +}; +const ARROWTYPE$1 = { + FILLED: 0, + OPEN: 1 +}; +const PLACEMENT$1 = { + LEFTOF: 0, + RIGHTOF: 1, + OVER: 2 +}; +const setTitle = function(txt) { + let sanitizedText = sanitizeText$2$1(txt, getConfig$2()); + title = sanitizedText; +}; +const db$f = { + addPersonOrSystem, + addPersonOrSystemBoundary, + addContainer, + addContainerBoundary, + addComponent, + addDeploymentNode, + popBoundaryParseStack, + addRel, + updateElStyle, + updateRelStyle, + updateLayoutConfig, + autoWrap: autoWrap$1, + setWrap: setWrap$1, + getC4ShapeArray, + getC4Shape, + getC4ShapeKeys, + getBoundaries, + getBoundarys, + getCurrentBoundaryParse, + getParentBoundaryParse, + getRels, + getTitle, + getC4Type, + getC4ShapeInRow, + getC4BoundaryInRow, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + getConfig: () => getConfig$2().c4, + clear: clear$j, + LINETYPE: LINETYPE$1, + ARROWTYPE: ARROWTYPE$1, + PLACEMENT: PLACEMENT$1, + setTitle, + setC4Type + // apply, +}; +const drawRect$3 = function(elem, rectData) { + return drawRect$4(elem, rectData); +}; +const drawImage = function(elem, width, height, x, y, link) { + const imageElem = elem.append("image"); + imageElem.attr("width", width); + imageElem.attr("height", height); + imageElem.attr("x", x); + imageElem.attr("y", y); + let sanitizedLink = link.startsWith("data:image/png;base64") ? link : dist$1.sanitizeUrl(link); + imageElem.attr("xlink:href", sanitizedLink); +}; +const drawRels$1 = (elem, rels2, conf2) => { + const relsElem = elem.append("g"); + let i = 0; + for (let rel of rels2) { + let textColor = rel.textColor ? rel.textColor : "#444444"; + let strokeColor = rel.lineColor ? rel.lineColor : "#444444"; + let offsetX = rel.offsetX ? parseInt(rel.offsetX) : 0; + let offsetY = rel.offsetY ? parseInt(rel.offsetY) : 0; + let url = ""; + if (i === 0) { + let line = relsElem.append("line"); + line.attr("x1", rel.startPoint.x); + line.attr("y1", rel.startPoint.y); + line.attr("x2", rel.endPoint.x); + line.attr("y2", rel.endPoint.y); + line.attr("stroke-width", "1"); + line.attr("stroke", strokeColor); + line.style("fill", "none"); + if (rel.type !== "rel_b") { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (rel.type === "birel" || rel.type === "rel_b") { + line.attr("marker-start", "url(" + url + "#arrowend)"); + } + i = -1; + } else { + let line = relsElem.append("path"); + line.attr("fill", "none").attr("stroke-width", "1").attr("stroke", strokeColor).attr( + "d", + "Mstartx,starty Qcontrolx,controly stopx,stopy ".replaceAll("startx", rel.startPoint.x).replaceAll("starty", rel.startPoint.y).replaceAll( + "controlx", + rel.startPoint.x + (rel.endPoint.x - rel.startPoint.x) / 2 - (rel.endPoint.x - rel.startPoint.x) / 4 + ).replaceAll("controly", rel.startPoint.y + (rel.endPoint.y - rel.startPoint.y) / 2).replaceAll("stopx", rel.endPoint.x).replaceAll("stopy", rel.endPoint.y) + ); + if (rel.type !== "rel_b") { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (rel.type === "birel" || rel.type === "rel_b") { + line.attr("marker-start", "url(" + url + "#arrowend)"); + } + } + let messageConf = conf2.messageFont(); + _drawTextCandidateFunc$3(conf2)( + rel.label.text, + relsElem, + Math.min(rel.startPoint.x, rel.endPoint.x) + Math.abs(rel.endPoint.x - rel.startPoint.x) / 2 + offsetX, + Math.min(rel.startPoint.y, rel.endPoint.y) + Math.abs(rel.endPoint.y - rel.startPoint.y) / 2 + offsetY, + rel.label.width, + rel.label.height, + { fill: textColor }, + messageConf + ); + if (rel.techn && rel.techn.text !== "") { + messageConf = conf2.messageFont(); + _drawTextCandidateFunc$3(conf2)( + "[" + rel.techn.text + "]", + relsElem, + Math.min(rel.startPoint.x, rel.endPoint.x) + Math.abs(rel.endPoint.x - rel.startPoint.x) / 2 + offsetX, + Math.min(rel.startPoint.y, rel.endPoint.y) + Math.abs(rel.endPoint.y - rel.startPoint.y) / 2 + conf2.messageFontSize + 5 + offsetY, + Math.max(rel.label.width, rel.techn.width), + rel.techn.height, + { fill: textColor, "font-style": "italic" }, + messageConf + ); + } + } +}; +const drawBoundary$1 = function(elem, boundary, conf2) { + const boundaryElem = elem.append("g"); + let fillColor = boundary.bgColor ? boundary.bgColor : "none"; + let strokeColor = boundary.borderColor ? boundary.borderColor : "#444444"; + let fontColor = boundary.fontColor ? boundary.fontColor : "black"; + let attrsValue = { "stroke-width": 1, "stroke-dasharray": "7.0,7.0" }; + if (boundary.nodeType) { + attrsValue = { "stroke-width": 1 }; + } + let rectData = { + x: boundary.x, + y: boundary.y, + fill: fillColor, + stroke: strokeColor, + width: boundary.width, + height: boundary.height, + rx: 2.5, + ry: 2.5, + attrs: attrsValue + }; + drawRect$3(boundaryElem, rectData); + let boundaryConf = conf2.boundaryFont(); + boundaryConf.fontWeight = "bold"; + boundaryConf.fontSize = boundaryConf.fontSize + 2; + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc$3(conf2)( + boundary.label.text, + boundaryElem, + boundary.x, + boundary.y + boundary.label.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + if (boundary.type && boundary.type.text !== "") { + boundaryConf = conf2.boundaryFont(); + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc$3(conf2)( + boundary.type.text, + boundaryElem, + boundary.x, + boundary.y + boundary.type.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + } + if (boundary.descr && boundary.descr.text !== "") { + boundaryConf = conf2.boundaryFont(); + boundaryConf.fontSize = boundaryConf.fontSize - 2; + boundaryConf.fontColor = fontColor; + _drawTextCandidateFunc$3(conf2)( + boundary.descr.text, + boundaryElem, + boundary.x, + boundary.y + boundary.descr.Y, + boundary.width, + boundary.height, + { fill: "#444444" }, + boundaryConf + ); + } +}; +const drawC4Shape = function(elem, c4Shape, conf2) { + var _a; + let fillColor = c4Shape.bgColor ? c4Shape.bgColor : conf2[c4Shape.typeC4Shape.text + "_bg_color"]; + let strokeColor = c4Shape.borderColor ? c4Shape.borderColor : conf2[c4Shape.typeC4Shape.text + "_border_color"]; + let fontColor = c4Shape.fontColor ? c4Shape.fontColor : "#FFFFFF"; + let personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII="; + switch (c4Shape.typeC4Shape.text) { + case "person": + personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACD0lEQVR4Xu2YoU4EMRCGT+4j8Ai8AhaH4QHgAUjQuFMECUgMIUgwJAgMhgQsAYUiJCiQIBBY+EITsjfTdme6V24v4c8vyGbb+ZjOtN0bNcvjQXmkH83WvYBWto6PLm6v7p7uH1/w2fXD+PBycX1Pv2l3IdDm/vn7x+dXQiAubRzoURa7gRZWd0iGRIiJbOnhnfYBQZNJjNbuyY2eJG8fkDE3bbG4ep6MHUAsgYxmE3nVs6VsBWJSGccsOlFPmLIViMzLOB7pCVO2AtHJMohH7Fh6zqitQK7m0rJvAVYgGcEpe//PLdDz65sM4pF9N7ICcXDKIB5Nv6j7tD0NoSdM2QrU9Gg0ewE1LqBhHR3BBdvj2vapnidjHxD/q6vd7Pvhr31AwcY8eXMTXAKECZZJFXuEq27aLgQK5uLMohCenGGuGewOxSjBvYBqeG6B+Nqiblggdjnc+ZXDy+FNFpFzw76O3UBAROuXh6FoiAcf5g9eTvUgzy0nWg6I8cXHRUpg5bOVBCo+KDpFajOf23GgPme7RSQ+lacIENUgJ6gg1k6HjgOlqnLqip4tEuhv0hNEMXUD0clyXE3p6pZA0S2nnvTlXwLJEZWlb7cTQH1+USgTN4VhAenm/wea1OCAOmqo6fE1WCb9WSKBah+rbUWPWAmE2Rvk0ApiB45eOyNAzU8xcTvj8KvkKEoOaIYeHNA3ZuygAvFMUO0AAAAASUVORK5CYII="; + break; + case "external_person": + personImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAB6ElEQVR4Xu2YLY+EMBCG9+dWr0aj0Wg0Go1Go0+j8Xdv2uTCvv1gpt0ebHKPuhDaeW4605Z9mJvx4AdXUyTUdd08z+u6flmWZRnHsWkafk9DptAwDPu+f0eAYtu2PEaGWuj5fCIZrBAC2eLBAnRCsEkkxmeaJp7iDJ2QMDdHsLg8SxKFEJaAo8lAXnmuOFIhTMpxxKATebo4UiFknuNo4OniSIXQyRxEA3YsnjGCVEjVXD7yLUAqxBGUyPv/Y4W2beMgGuS7kVQIBycH0fD+oi5pezQETxdHKmQKGk1eQEYldK+jw5GxPfZ9z7Mk0Qnhf1W1m3w//EUn5BDmSZsbR44QQLBEqrBHqOrmSKaQAxdnLArCrxZcM7A7ZKs4ioRq8LFC+NpC3WCBJsvpVw5edm9iEXFuyNfxXAgSwfrFQ1c0iNda8AdejvUgnktOtJQQxmcfFzGglc5WVCj7oDgFqU18boeFSs52CUh8LE8BIVQDT1ABrB0HtgSEYlX5doJnCwv9TXocKCaKbnwhdDKPq4lf3SwU3HLq4V/+WYhHVMa/3b4IlfyikAduCkcBc7mQ3/z/Qq/cTuikhkzB12Ae/mcJC9U+Vo8Ej1gWAtgbeGgFsAMHr50BIWOLCbezvhpBFUdY6EJuJ/QDW0XoMX60zZ0AAAAASUVORK5CYII="; + break; + } + const c4ShapeElem = elem.append("g"); + c4ShapeElem.attr("class", "person-man"); + const rect = getNoteRect$2(); + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + case "system": + case "external_system": + case "container": + case "external_container": + case "component": + case "external_component": + rect.x = c4Shape.x; + rect.y = c4Shape.y; + rect.fill = fillColor; + rect.width = c4Shape.width; + rect.height = c4Shape.height; + rect.stroke = strokeColor; + rect.rx = 2.5; + rect.ry = 2.5; + rect.attrs = { "stroke-width": 0.5 }; + drawRect$3(c4ShapeElem, rect); + break; + case "system_db": + case "external_system_db": + case "container_db": + case "external_container_db": + case "component_db": + case "external_component_db": + c4ShapeElem.append("path").attr("fill", fillColor).attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc0,-10 half,-10 half,-10c0,0 half,0 half,10l0,heightc0,10 -half,10 -half,10c0,0 -half,0 -half,-10l0,-height".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.width / 2).replaceAll("height", c4Shape.height) + ); + c4ShapeElem.append("path").attr("fill", "none").attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc0,10 half,10 half,10c0,0 half,0 half,-10".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.width / 2) + ); + break; + case "system_queue": + case "external_system_queue": + case "container_queue": + case "external_container_queue": + case "component_queue": + case "external_component_queue": + c4ShapeElem.append("path").attr("fill", fillColor).attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startylwidth,0c5,0 5,half 5,halfc0,0 0,half -5,halfl-width,0c-5,0 -5,-half -5,-halfc0,0 0,-half 5,-half".replaceAll("startx", c4Shape.x).replaceAll("starty", c4Shape.y).replaceAll("width", c4Shape.width).replaceAll("half", c4Shape.height / 2) + ); + c4ShapeElem.append("path").attr("fill", "none").attr("stroke-width", "0.5").attr("stroke", strokeColor).attr( + "d", + "Mstartx,startyc-5,0 -5,half -5,halfc0,half 5,half 5,half".replaceAll("startx", c4Shape.x + c4Shape.width).replaceAll("starty", c4Shape.y).replaceAll("half", c4Shape.height / 2) + ); + break; + } + let c4ShapeFontConf = getC4ShapeFont(conf2, c4Shape.typeC4Shape.text); + c4ShapeElem.append("text").attr("fill", fontColor).attr("font-family", c4ShapeFontConf.fontFamily).attr("font-size", c4ShapeFontConf.fontSize - 2).attr("font-style", "italic").attr("lengthAdjust", "spacing").attr("textLength", c4Shape.typeC4Shape.width).attr("x", c4Shape.x + c4Shape.width / 2 - c4Shape.typeC4Shape.width / 2).attr("y", c4Shape.y + c4Shape.typeC4Shape.Y).text("<<" + c4Shape.typeC4Shape.text + ">>"); + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + drawImage( + c4ShapeElem, + 48, + 48, + c4Shape.x + c4Shape.width / 2 - 24, + c4Shape.y + c4Shape.image.Y, + personImg + ); + break; + } + let textFontConf = conf2[c4Shape.typeC4Shape.text + "Font"](); + textFontConf.fontWeight = "bold"; + textFontConf.fontSize = textFontConf.fontSize + 2; + textFontConf.fontColor = fontColor; + _drawTextCandidateFunc$3(conf2)( + c4Shape.label.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.label.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor }, + textFontConf + ); + textFontConf = conf2[c4Shape.typeC4Shape.text + "Font"](); + textFontConf.fontColor = fontColor; + if (c4Shape.techn && ((_a = c4Shape.techn) == null ? void 0 : _a.text) !== "") { + _drawTextCandidateFunc$3(conf2)( + c4Shape.techn.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.techn.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor, "font-style": "italic" }, + textFontConf + ); + } else if (c4Shape.type && c4Shape.type.text !== "") { + _drawTextCandidateFunc$3(conf2)( + c4Shape.type.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.type.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor, "font-style": "italic" }, + textFontConf + ); + } + if (c4Shape.descr && c4Shape.descr.text !== "") { + textFontConf = conf2.personFont(); + textFontConf.fontColor = fontColor; + _drawTextCandidateFunc$3(conf2)( + c4Shape.descr.text, + c4ShapeElem, + c4Shape.x, + c4Shape.y + c4Shape.descr.Y, + c4Shape.width, + c4Shape.height, + { fill: fontColor }, + textFontConf + ); + } + return c4Shape.height; +}; +const insertDatabaseIcon$1 = function(elem) { + elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z" + ); +}; +const insertComputerIcon$1 = function(elem) { + elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z" + ); +}; +const insertClockIcon$1 = function(elem) { + elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z" + ); +}; +const insertArrowHead$1 = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +}; +const insertArrowEnd = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowend").attr("refX", 1).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z"); +}; +const insertArrowFilledHead$1 = function(elem) { + elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 18).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const insertDynamicNumber = function(elem) { + elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6); +}; +const insertArrowCrossHead$1 = function(elem) { + const defs = elem.append("defs"); + const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 16).attr("refY", 4); + marker.append("path").attr("fill", "black").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1px").attr("d", "M 9,2 V 6 L16,4 Z"); + marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1px").attr("d", "M 0,1 L 6,7 M 6,1 L 0,7"); +}; +const getC4ShapeFont = (cnf, typeC4Shape) => { + return { + fontFamily: cnf[typeC4Shape + "FontFamily"], + fontSize: cnf[typeC4Shape + "FontSize"], + fontWeight: cnf[typeC4Shape + "FontWeight"] + }; +}; +const _drawTextCandidateFunc$3 = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { fontSize, fontFamily, fontWeight } = conf2; + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * fontSize - fontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").attr("dominant-baseline", "middle").style("font-size", fontSize).style("font-weight", fontWeight).style("font-family", fontFamily); + text.append("tspan").attr("dy", dy).text(lines[i]).attr("alignment-baseline", "mathematical"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const svgDraw$4 = { + drawRect: drawRect$3, + drawBoundary: drawBoundary$1, + drawC4Shape, + drawRels: drawRels$1, + drawImage, + insertArrowHead: insertArrowHead$1, + insertArrowEnd, + insertArrowFilledHead: insertArrowFilledHead$1, + insertDynamicNumber, + insertArrowCrossHead: insertArrowCrossHead$1, + insertDatabaseIcon: insertDatabaseIcon$1, + insertComputerIcon: insertComputerIcon$1, + insertClockIcon: insertClockIcon$1 +}; +let globalBoundaryMaxX = 0, globalBoundaryMaxY = 0; +let c4ShapeInRow = 4; +let c4BoundaryInRow = 2; +parser$i.yy = db$f; +let conf$9 = {}; +class Bounds { + constructor(diagObj) { + this.name = ""; + this.data = {}; + this.data.startx = void 0; + this.data.stopx = void 0; + this.data.starty = void 0; + this.data.stopy = void 0; + this.data.widthLimit = void 0; + this.nextData = {}; + this.nextData.startx = void 0; + this.nextData.stopx = void 0; + this.nextData.starty = void 0; + this.nextData.stopy = void 0; + this.nextData.cnt = 0; + setConf$9(diagObj.db.getConfig()); + } + setData(startx, stopx, starty, stopy) { + this.nextData.startx = this.data.startx = startx; + this.nextData.stopx = this.data.stopx = stopx; + this.nextData.starty = this.data.starty = starty; + this.nextData.stopy = this.data.stopy = stopy; + } + updateVal(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + } + insert(c4Shape) { + this.nextData.cnt = this.nextData.cnt + 1; + let _startx = this.nextData.startx === this.nextData.stopx ? this.nextData.stopx + c4Shape.margin : this.nextData.stopx + c4Shape.margin * 2; + let _stopx = _startx + c4Shape.width; + let _starty = this.nextData.starty + c4Shape.margin * 2; + let _stopy = _starty + c4Shape.height; + if (_startx >= this.data.widthLimit || _stopx >= this.data.widthLimit || this.nextData.cnt > c4ShapeInRow) { + _startx = this.nextData.startx + c4Shape.margin + conf$9.nextLinePaddingX; + _starty = this.nextData.stopy + c4Shape.margin * 2; + this.nextData.stopx = _stopx = _startx + c4Shape.width; + this.nextData.starty = this.nextData.stopy; + this.nextData.stopy = _stopy = _starty + c4Shape.height; + this.nextData.cnt = 1; + } + c4Shape.x = _startx; + c4Shape.y = _starty; + this.updateVal(this.data, "startx", _startx, Math.min); + this.updateVal(this.data, "starty", _starty, Math.min); + this.updateVal(this.data, "stopx", _stopx, Math.max); + this.updateVal(this.data, "stopy", _stopy, Math.max); + this.updateVal(this.nextData, "startx", _startx, Math.min); + this.updateVal(this.nextData, "starty", _starty, Math.min); + this.updateVal(this.nextData, "stopx", _stopx, Math.max); + this.updateVal(this.nextData, "stopy", _stopy, Math.max); + } + init(diagObj) { + this.name = ""; + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0, + widthLimit: void 0 + }; + this.nextData = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0, + cnt: 0 + }; + setConf$9(diagObj.db.getConfig()); + } + bumpLastMargin(margin) { + this.data.stopx += margin; + this.data.stopy += margin; + } +} +const setConf$9 = function(cnf) { + assignWithDepth$1(conf$9, cnf); + if (cnf.fontFamily) { + conf$9.personFontFamily = conf$9.systemFontFamily = conf$9.messageFontFamily = cnf.fontFamily; + } + if (cnf.fontSize) { + conf$9.personFontSize = conf$9.systemFontSize = conf$9.messageFontSize = cnf.fontSize; + } + if (cnf.fontWeight) { + conf$9.personFontWeight = conf$9.systemFontWeight = conf$9.messageFontWeight = cnf.fontWeight; + } +}; +const c4ShapeFont = (cnf, typeC4Shape) => { + return { + fontFamily: cnf[typeC4Shape + "FontFamily"], + fontSize: cnf[typeC4Shape + "FontSize"], + fontWeight: cnf[typeC4Shape + "FontWeight"] + }; +}; +const boundaryFont = (cnf) => { + return { + fontFamily: cnf.boundaryFontFamily, + fontSize: cnf.boundaryFontSize, + fontWeight: cnf.boundaryFontWeight + }; +}; +const messageFont$1 = (cnf) => { + return { + fontFamily: cnf.messageFontFamily, + fontSize: cnf.messageFontSize, + fontWeight: cnf.messageFontWeight + }; +}; +function calcC4ShapeTextWH(textType, c4Shape, c4ShapeTextWrap, textConf, textLimitWidth) { + if (!c4Shape[textType].width) { + if (c4ShapeTextWrap) { + c4Shape[textType].text = wrapLabel(c4Shape[textType].text, textLimitWidth, textConf); + c4Shape[textType].textLines = c4Shape[textType].text.split(common$1.lineBreakRegex).length; + c4Shape[textType].width = textLimitWidth; + c4Shape[textType].height = calculateTextHeight(c4Shape[textType].text, textConf); + } else { + let lines = c4Shape[textType].text.split(common$1.lineBreakRegex); + c4Shape[textType].textLines = lines.length; + let lineHeight = 0; + c4Shape[textType].height = 0; + c4Shape[textType].width = 0; + for (const line of lines) { + c4Shape[textType].width = Math.max( + calculateTextWidth(line, textConf), + c4Shape[textType].width + ); + lineHeight = calculateTextHeight(line, textConf); + c4Shape[textType].height = c4Shape[textType].height + lineHeight; + } + } + } +} +const drawBoundary = function(diagram2, boundary, bounds) { + boundary.x = bounds.data.startx; + boundary.y = bounds.data.starty; + boundary.width = bounds.data.stopx - bounds.data.startx; + boundary.height = bounds.data.stopy - bounds.data.starty; + boundary.label.y = conf$9.c4ShapeMargin - 35; + let boundaryTextWrap = boundary.wrap && conf$9.wrap; + let boundaryLabelConf = boundaryFont(conf$9); + boundaryLabelConf.fontSize = boundaryLabelConf.fontSize + 2; + boundaryLabelConf.fontWeight = "bold"; + let textLimitWidth = calculateTextWidth(boundary.label.text, boundaryLabelConf); + calcC4ShapeTextWH("label", boundary, boundaryTextWrap, boundaryLabelConf, textLimitWidth); + svgDraw$4.drawBoundary(diagram2, boundary, conf$9); +}; +const drawC4ShapeArray = function(currentBounds, diagram2, c4ShapeArray2, c4ShapeKeys) { + let Y = 0; + for (const c4ShapeKey of c4ShapeKeys) { + Y = 0; + const c4Shape = c4ShapeArray2[c4ShapeKey]; + let c4ShapeTypeConf = c4ShapeFont(conf$9, c4Shape.typeC4Shape.text); + c4ShapeTypeConf.fontSize = c4ShapeTypeConf.fontSize - 2; + c4Shape.typeC4Shape.width = calculateTextWidth( + "«" + c4Shape.typeC4Shape.text + "»", + c4ShapeTypeConf + ); + c4Shape.typeC4Shape.height = c4ShapeTypeConf.fontSize + 2; + c4Shape.typeC4Shape.Y = conf$9.c4ShapePadding; + Y = c4Shape.typeC4Shape.Y + c4Shape.typeC4Shape.height - 4; + c4Shape.image = { width: 0, height: 0, Y: 0 }; + switch (c4Shape.typeC4Shape.text) { + case "person": + case "external_person": + c4Shape.image.width = 48; + c4Shape.image.height = 48; + c4Shape.image.Y = Y; + Y = c4Shape.image.Y + c4Shape.image.height; + break; + } + if (c4Shape.sprite) { + c4Shape.image.width = 48; + c4Shape.image.height = 48; + c4Shape.image.Y = Y; + Y = c4Shape.image.Y + c4Shape.image.height; + } + let c4ShapeTextWrap = c4Shape.wrap && conf$9.wrap; + let textLimitWidth = conf$9.width - conf$9.c4ShapePadding * 2; + let c4ShapeLabelConf = c4ShapeFont(conf$9, c4Shape.typeC4Shape.text); + c4ShapeLabelConf.fontSize = c4ShapeLabelConf.fontSize + 2; + c4ShapeLabelConf.fontWeight = "bold"; + calcC4ShapeTextWH("label", c4Shape, c4ShapeTextWrap, c4ShapeLabelConf, textLimitWidth); + c4Shape["label"].Y = Y + 8; + Y = c4Shape["label"].Y + c4Shape["label"].height; + if (c4Shape.type && c4Shape.type.text !== "") { + c4Shape.type.text = "[" + c4Shape.type.text + "]"; + let c4ShapeTypeConf2 = c4ShapeFont(conf$9, c4Shape.typeC4Shape.text); + calcC4ShapeTextWH("type", c4Shape, c4ShapeTextWrap, c4ShapeTypeConf2, textLimitWidth); + c4Shape["type"].Y = Y + 5; + Y = c4Shape["type"].Y + c4Shape["type"].height; + } else if (c4Shape.techn && c4Shape.techn.text !== "") { + c4Shape.techn.text = "[" + c4Shape.techn.text + "]"; + let c4ShapeTechnConf = c4ShapeFont(conf$9, c4Shape.techn.text); + calcC4ShapeTextWH("techn", c4Shape, c4ShapeTextWrap, c4ShapeTechnConf, textLimitWidth); + c4Shape["techn"].Y = Y + 5; + Y = c4Shape["techn"].Y + c4Shape["techn"].height; + } + let rectHeight = Y; + let rectWidth = c4Shape.label.width; + if (c4Shape.descr && c4Shape.descr.text !== "") { + let c4ShapeDescrConf = c4ShapeFont(conf$9, c4Shape.typeC4Shape.text); + calcC4ShapeTextWH("descr", c4Shape, c4ShapeTextWrap, c4ShapeDescrConf, textLimitWidth); + c4Shape["descr"].Y = Y + 20; + Y = c4Shape["descr"].Y + c4Shape["descr"].height; + rectWidth = Math.max(c4Shape.label.width, c4Shape.descr.width); + rectHeight = Y - c4Shape["descr"].textLines * 5; + } + rectWidth = rectWidth + conf$9.c4ShapePadding; + c4Shape.width = Math.max(c4Shape.width || conf$9.width, rectWidth, conf$9.width); + c4Shape.height = Math.max(c4Shape.height || conf$9.height, rectHeight, conf$9.height); + c4Shape.margin = c4Shape.margin || conf$9.c4ShapeMargin; + currentBounds.insert(c4Shape); + svgDraw$4.drawC4Shape(diagram2, c4Shape, conf$9); + } + currentBounds.bumpLastMargin(conf$9.c4ShapeMargin); +}; +let Point$1 = class Point { + constructor(x, y) { + this.x = x; + this.y = y; + } +}; +let getIntersectPoint = function(fromNode, endPoint) { + let x1 = fromNode.x; + let y1 = fromNode.y; + let x2 = endPoint.x; + let y2 = endPoint.y; + let fromCenterX = x1 + fromNode.width / 2; + let fromCenterY = y1 + fromNode.height / 2; + let dx = Math.abs(x1 - x2); + let dy = Math.abs(y1 - y2); + let tanDYX = dy / dx; + let fromDYX = fromNode.height / fromNode.width; + let returnPoint = null; + if (y1 == y2 && x1 < x2) { + returnPoint = new Point$1(x1 + fromNode.width, fromCenterY); + } else if (y1 == y2 && x1 > x2) { + returnPoint = new Point$1(x1, fromCenterY); + } else if (x1 == x2 && y1 < y2) { + returnPoint = new Point$1(fromCenterX, y1 + fromNode.height); + } else if (x1 == x2 && y1 > y2) { + returnPoint = new Point$1(fromCenterX, y1); + } + if (x1 > x2 && y1 < y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point$1(x1, fromCenterY + tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point$1( + fromCenterX - dx / dy * fromNode.height / 2, + y1 + fromNode.height + ); + } + } else if (x1 < x2 && y1 < y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point$1(x1 + fromNode.width, fromCenterY + tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point$1( + fromCenterX + dx / dy * fromNode.height / 2, + y1 + fromNode.height + ); + } + } else if (x1 < x2 && y1 > y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point$1(x1 + fromNode.width, fromCenterY - tanDYX * fromNode.width / 2); + } else { + returnPoint = new Point$1(fromCenterX + fromNode.height / 2 * dx / dy, y1); + } + } else if (x1 > x2 && y1 > y2) { + if (fromDYX >= tanDYX) { + returnPoint = new Point$1(x1, fromCenterY - fromNode.width / 2 * tanDYX); + } else { + returnPoint = new Point$1(fromCenterX - fromNode.height / 2 * dx / dy, y1); + } + } + return returnPoint; +}; +let getIntersectPoints = function(fromNode, endNode) { + let endIntersectPoint = { x: 0, y: 0 }; + endIntersectPoint.x = endNode.x + endNode.width / 2; + endIntersectPoint.y = endNode.y + endNode.height / 2; + let startPoint = getIntersectPoint(fromNode, endIntersectPoint); + endIntersectPoint.x = fromNode.x + fromNode.width / 2; + endIntersectPoint.y = fromNode.y + fromNode.height / 2; + let endPoint = getIntersectPoint(endNode, endIntersectPoint); + return { startPoint, endPoint }; +}; +const drawRels = function(diagram2, rels2, getC4ShapeObj, diagObj) { + let i = 0; + for (let rel of rels2) { + i = i + 1; + let relTextWrap = rel.wrap && conf$9.wrap; + let relConf = messageFont$1(conf$9); + let diagramType = diagObj.db.getC4Type(); + if (diagramType === "C4Dynamic") { + rel.label.text = i + ": " + rel.label.text; + } + let textLimitWidth = calculateTextWidth(rel.label.text, relConf); + calcC4ShapeTextWH("label", rel, relTextWrap, relConf, textLimitWidth); + if (rel.techn && rel.techn.text !== "") { + textLimitWidth = calculateTextWidth(rel.techn.text, relConf); + calcC4ShapeTextWH("techn", rel, relTextWrap, relConf, textLimitWidth); + } + if (rel.descr && rel.descr.text !== "") { + textLimitWidth = calculateTextWidth(rel.descr.text, relConf); + calcC4ShapeTextWH("descr", rel, relTextWrap, relConf, textLimitWidth); + } + let fromNode = getC4ShapeObj(rel.from); + let endNode = getC4ShapeObj(rel.to); + let points = getIntersectPoints(fromNode, endNode); + rel.startPoint = points.startPoint; + rel.endPoint = points.endPoint; + } + svgDraw$4.drawRels(diagram2, rels2, conf$9); +}; +function drawInsideBoundary(diagram2, parentBoundaryAlias, parentBounds, currentBoundaries, diagObj) { + let currentBounds = new Bounds(diagObj); + currentBounds.data.widthLimit = parentBounds.data.widthLimit / Math.min(c4BoundaryInRow, currentBoundaries.length); + for (let [i, currentBoundary] of currentBoundaries.entries()) { + let Y = 0; + currentBoundary.image = { width: 0, height: 0, Y: 0 }; + if (currentBoundary.sprite) { + currentBoundary.image.width = 48; + currentBoundary.image.height = 48; + currentBoundary.image.Y = Y; + Y = currentBoundary.image.Y + currentBoundary.image.height; + } + let currentBoundaryTextWrap = currentBoundary.wrap && conf$9.wrap; + let currentBoundaryLabelConf = boundaryFont(conf$9); + currentBoundaryLabelConf.fontSize = currentBoundaryLabelConf.fontSize + 2; + currentBoundaryLabelConf.fontWeight = "bold"; + calcC4ShapeTextWH( + "label", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryLabelConf, + currentBounds.data.widthLimit + ); + currentBoundary["label"].Y = Y + 8; + Y = currentBoundary["label"].Y + currentBoundary["label"].height; + if (currentBoundary.type && currentBoundary.type.text !== "") { + currentBoundary.type.text = "[" + currentBoundary.type.text + "]"; + let currentBoundaryTypeConf = boundaryFont(conf$9); + calcC4ShapeTextWH( + "type", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryTypeConf, + currentBounds.data.widthLimit + ); + currentBoundary["type"].Y = Y + 5; + Y = currentBoundary["type"].Y + currentBoundary["type"].height; + } + if (currentBoundary.descr && currentBoundary.descr.text !== "") { + let currentBoundaryDescrConf = boundaryFont(conf$9); + currentBoundaryDescrConf.fontSize = currentBoundaryDescrConf.fontSize - 2; + calcC4ShapeTextWH( + "descr", + currentBoundary, + currentBoundaryTextWrap, + currentBoundaryDescrConf, + currentBounds.data.widthLimit + ); + currentBoundary["descr"].Y = Y + 20; + Y = currentBoundary["descr"].Y + currentBoundary["descr"].height; + } + if (i == 0 || i % c4BoundaryInRow === 0) { + let _x = parentBounds.data.startx + conf$9.diagramMarginX; + let _y = parentBounds.data.stopy + conf$9.diagramMarginY + Y; + currentBounds.setData(_x, _x, _y, _y); + } else { + let _x = currentBounds.data.stopx !== currentBounds.data.startx ? currentBounds.data.stopx + conf$9.diagramMarginX : currentBounds.data.startx; + let _y = currentBounds.data.starty; + currentBounds.setData(_x, _x, _y, _y); + } + currentBounds.name = currentBoundary.alias; + let currentPersonOrSystemArray = diagObj.db.getC4ShapeArray(currentBoundary.alias); + let currentPersonOrSystemKeys = diagObj.db.getC4ShapeKeys(currentBoundary.alias); + if (currentPersonOrSystemKeys.length > 0) { + drawC4ShapeArray( + currentBounds, + diagram2, + currentPersonOrSystemArray, + currentPersonOrSystemKeys + ); + } + parentBoundaryAlias = currentBoundary.alias; + let nextCurrentBoundaries = diagObj.db.getBoundarys(parentBoundaryAlias); + if (nextCurrentBoundaries.length > 0) { + drawInsideBoundary( + diagram2, + parentBoundaryAlias, + currentBounds, + nextCurrentBoundaries, + diagObj + ); + } + if (currentBoundary.alias !== "global") { + drawBoundary(diagram2, currentBoundary, currentBounds); + } + parentBounds.data.stopy = Math.max( + currentBounds.data.stopy + conf$9.c4ShapeMargin, + parentBounds.data.stopy + ); + parentBounds.data.stopx = Math.max( + currentBounds.data.stopx + conf$9.c4ShapeMargin, + parentBounds.data.stopx + ); + globalBoundaryMaxX = Math.max(globalBoundaryMaxX, parentBounds.data.stopx); + globalBoundaryMaxY = Math.max(globalBoundaryMaxY, parentBounds.data.stopy); + } +} +const draw$l = function(_text, id, _version, diagObj) { + conf$9 = getConfig$2().c4; + const securityLevel = getConfig$2().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + let db2 = diagObj.db; + diagObj.db.setWrap(conf$9.wrap); + c4ShapeInRow = db2.getC4ShapeInRow(); + c4BoundaryInRow = db2.getC4BoundaryInRow(); + log$1.debug(`C:${JSON.stringify(conf$9, null, 2)}`); + const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + svgDraw$4.insertComputerIcon(diagram2); + svgDraw$4.insertDatabaseIcon(diagram2); + svgDraw$4.insertClockIcon(diagram2); + let screenBounds = new Bounds(diagObj); + screenBounds.setData( + conf$9.diagramMarginX, + conf$9.diagramMarginX, + conf$9.diagramMarginY, + conf$9.diagramMarginY + ); + screenBounds.data.widthLimit = screen.availWidth; + globalBoundaryMaxX = conf$9.diagramMarginX; + globalBoundaryMaxY = conf$9.diagramMarginY; + const title2 = diagObj.db.getTitle(); + let currentBoundaries = diagObj.db.getBoundarys(""); + drawInsideBoundary(diagram2, "", screenBounds, currentBoundaries, diagObj); + svgDraw$4.insertArrowHead(diagram2); + svgDraw$4.insertArrowEnd(diagram2); + svgDraw$4.insertArrowCrossHead(diagram2); + svgDraw$4.insertArrowFilledHead(diagram2); + drawRels(diagram2, diagObj.db.getRels(), diagObj.db.getC4Shape, diagObj); + screenBounds.data.stopx = globalBoundaryMaxX; + screenBounds.data.stopy = globalBoundaryMaxY; + const box = screenBounds.data; + let boxHeight = box.stopy - box.starty; + let height = boxHeight + 2 * conf$9.diagramMarginY; + let boxWidth = box.stopx - box.startx; + const width = boxWidth + 2 * conf$9.diagramMarginX; + if (title2) { + diagram2.append("text").text(title2).attr("x", (box.stopx - box.startx) / 2 - 4 * conf$9.diagramMarginX).attr("y", box.starty + conf$9.diagramMarginY); + } + configureSvgSize(diagram2, height, width, conf$9.useMaxWidth); + const extraVertForTitle = title2 ? 60 : 0; + diagram2.attr( + "viewBox", + box.startx - conf$9.diagramMarginX + " -" + (conf$9.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle) + ); + log$1.debug(`models:`, box); +}; +const renderer$h = { + drawPersonOrSystemArray: drawC4ShapeArray, + drawBoundary, + setConf: setConf$9, + draw: draw$l +}; +const getStyles$e = (options) => `.person { + stroke: ${options.personBorder}; + fill: ${options.personBkg}; + } +`; +const styles$9 = getStyles$e; +const diagram$l = { + parser: parser$1$e, + db: db$f, + renderer: renderer$h, + styles: styles$9, + init: ({ c4, wrap }) => { + renderer$h.setConf(c4); + db$f.setWrap(wrap); + } +}; + +var c4DiagramAe766693 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$l +}); + +var parser$h = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 4], $V1 = [1, 3], $V2 = [1, 5], $V3 = [1, 8, 9, 10, 11, 27, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $V4 = [2, 2], $V5 = [1, 13], $V6 = [1, 14], $V7 = [1, 15], $V8 = [1, 16], $V9 = [1, 23], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 49], $Ve = [1, 48], $Vf = [1, 29], $Vg = [1, 30], $Vh = [1, 31], $Vi = [1, 32], $Vj = [1, 33], $Vk = [1, 44], $Vl = [1, 46], $Vm = [1, 42], $Vn = [1, 47], $Vo = [1, 43], $Vp = [1, 50], $Vq = [1, 45], $Vr = [1, 51], $Vs = [1, 52], $Vt = [1, 34], $Vu = [1, 35], $Vv = [1, 36], $Vw = [1, 37], $Vx = [1, 57], $Vy = [1, 8, 9, 10, 11, 27, 32, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $Vz = [1, 61], $VA = [1, 60], $VB = [1, 62], $VC = [8, 9, 11, 73, 75], $VD = [1, 88], $VE = [1, 93], $VF = [1, 92], $VG = [1, 89], $VH = [1, 85], $VI = [1, 91], $VJ = [1, 87], $VK = [1, 94], $VL = [1, 90], $VM = [1, 95], $VN = [1, 86], $VO = [8, 9, 10, 11, 73, 75], $VP = [8, 9, 10, 11, 44, 73, 75], $VQ = [8, 9, 10, 11, 29, 42, 44, 46, 48, 50, 52, 54, 56, 58, 61, 63, 65, 66, 68, 73, 75, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VR = [8, 9, 11, 42, 58, 73, 75, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VS = [42, 58, 86, 99, 102, 103, 106, 108, 111, 112, 113], $VT = [1, 121], $VU = [1, 120], $VV = [1, 128], $VW = [1, 142], $VX = [1, 143], $VY = [1, 144], $VZ = [1, 145], $V_ = [1, 130], $V$ = [1, 132], $V01 = [1, 136], $V11 = [1, 137], $V21 = [1, 138], $V31 = [1, 139], $V41 = [1, 140], $V51 = [1, 141], $V61 = [1, 146], $V71 = [1, 147], $V81 = [1, 126], $V91 = [1, 127], $Va1 = [1, 134], $Vb1 = [1, 129], $Vc1 = [1, 133], $Vd1 = [1, 131], $Ve1 = [8, 9, 10, 11, 27, 32, 34, 36, 38, 42, 58, 81, 82, 83, 84, 85, 86, 99, 102, 103, 106, 108, 111, 112, 113, 118, 119, 120, 121], $Vf1 = [1, 149], $Vg1 = [8, 9, 11], $Vh1 = [8, 9, 10, 11, 14, 42, 58, 86, 102, 103, 106, 108, 111, 112, 113], $Vi1 = [1, 169], $Vj1 = [1, 165], $Vk1 = [1, 166], $Vl1 = [1, 170], $Vm1 = [1, 167], $Vn1 = [1, 168], $Vo1 = [75, 113, 116], $Vp1 = [8, 9, 10, 11, 12, 14, 27, 29, 32, 42, 58, 73, 81, 82, 83, 84, 85, 86, 87, 102, 106, 108, 111, 112, 113], $Vq1 = [10, 103], $Vr1 = [31, 47, 49, 51, 53, 55, 60, 62, 64, 65, 67, 69, 113, 114, 115], $Vs1 = [1, 235], $Vt1 = [1, 233], $Vu1 = [1, 237], $Vv1 = [1, 231], $Vw1 = [1, 232], $Vx1 = [1, 234], $Vy1 = [1, 236], $Vz1 = [1, 238], $VA1 = [1, 255], $VB1 = [8, 9, 11, 103], $VC1 = [8, 9, 10, 11, 58, 81, 102, 103, 106, 107, 108, 109]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "graphConfig": 4, "document": 5, "line": 6, "statement": 7, "SEMI": 8, "NEWLINE": 9, "SPACE": 10, "EOF": 11, "GRAPH": 12, "NODIR": 13, "DIR": 14, "FirstStmtSeparator": 15, "ending": 16, "endToken": 17, "spaceList": 18, "spaceListNewline": 19, "vertexStatement": 20, "separator": 21, "styleStatement": 22, "linkStyleStatement": 23, "classDefStatement": 24, "classStatement": 25, "clickStatement": 26, "subgraph": 27, "textNoTags": 28, "SQS": 29, "text": 30, "SQE": 31, "end": 32, "direction": 33, "acc_title": 34, "acc_title_value": 35, "acc_descr": 36, "acc_descr_value": 37, "acc_descr_multiline_value": 38, "link": 39, "node": 40, "styledVertex": 41, "AMP": 42, "vertex": 43, "STYLE_SEPARATOR": 44, "idString": 45, "DOUBLECIRCLESTART": 46, "DOUBLECIRCLEEND": 47, "PS": 48, "PE": 49, "(-": 50, "-)": 51, "STADIUMSTART": 52, "STADIUMEND": 53, "SUBROUTINESTART": 54, "SUBROUTINEEND": 55, "VERTEX_WITH_PROPS_START": 56, "NODE_STRING[field]": 57, "COLON": 58, "NODE_STRING[value]": 59, "PIPE": 60, "CYLINDERSTART": 61, "CYLINDEREND": 62, "DIAMOND_START": 63, "DIAMOND_STOP": 64, "TAGEND": 65, "TRAPSTART": 66, "TRAPEND": 67, "INVTRAPSTART": 68, "INVTRAPEND": 69, "linkStatement": 70, "arrowText": 71, "TESTSTR": 72, "START_LINK": 73, "edgeText": 74, "LINK": 75, "edgeTextToken": 76, "STR": 77, "MD_STR": 78, "textToken": 79, "keywords": 80, "STYLE": 81, "LINKSTYLE": 82, "CLASSDEF": 83, "CLASS": 84, "CLICK": 85, "DOWN": 86, "UP": 87, "textNoTagsToken": 88, "stylesOpt": 89, "idString[vertex]": 90, "idString[class]": 91, "CALLBACKNAME": 92, "CALLBACKARGS": 93, "HREF": 94, "LINK_TARGET": 95, "STR[link]": 96, "STR[tooltip]": 97, "alphaNum": 98, "DEFAULT": 99, "numList": 100, "INTERPOLATE": 101, "NUM": 102, "COMMA": 103, "style": 104, "styleComponent": 105, "NODE_STRING": 106, "UNIT": 107, "BRKT": 108, "PCT": 109, "idStringToken": 110, "MINUS": 111, "MULT": 112, "UNICODE_TEXT": 113, "TEXT": 114, "TAGSTART": 115, "EDGE_TEXT": 116, "alphaNumToken": 117, "direction_tb": 118, "direction_bt": 119, "direction_rl": 120, "direction_lr": 121, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 8: "SEMI", 9: "NEWLINE", 10: "SPACE", 11: "EOF", 12: "GRAPH", 13: "NODIR", 14: "DIR", 27: "subgraph", 29: "SQS", 31: "SQE", 32: "end", 34: "acc_title", 35: "acc_title_value", 36: "acc_descr", 37: "acc_descr_value", 38: "acc_descr_multiline_value", 42: "AMP", 44: "STYLE_SEPARATOR", 46: "DOUBLECIRCLESTART", 47: "DOUBLECIRCLEEND", 48: "PS", 49: "PE", 50: "(-", 51: "-)", 52: "STADIUMSTART", 53: "STADIUMEND", 54: "SUBROUTINESTART", 55: "SUBROUTINEEND", 56: "VERTEX_WITH_PROPS_START", 57: "NODE_STRING[field]", 58: "COLON", 59: "NODE_STRING[value]", 60: "PIPE", 61: "CYLINDERSTART", 62: "CYLINDEREND", 63: "DIAMOND_START", 64: "DIAMOND_STOP", 65: "TAGEND", 66: "TRAPSTART", 67: "TRAPEND", 68: "INVTRAPSTART", 69: "INVTRAPEND", 72: "TESTSTR", 73: "START_LINK", 75: "LINK", 77: "STR", 78: "MD_STR", 81: "STYLE", 82: "LINKSTYLE", 83: "CLASSDEF", 84: "CLASS", 85: "CLICK", 86: "DOWN", 87: "UP", 90: "idString[vertex]", 91: "idString[class]", 92: "CALLBACKNAME", 93: "CALLBACKARGS", 94: "HREF", 95: "LINK_TARGET", 96: "STR[link]", 97: "STR[tooltip]", 99: "DEFAULT", 101: "INTERPOLATE", 102: "NUM", 103: "COMMA", 106: "NODE_STRING", 107: "UNIT", 108: "BRKT", 109: "PCT", 111: "MINUS", 112: "MULT", 113: "UNICODE_TEXT", 114: "TEXT", 115: "TAGSTART", 116: "EDGE_TEXT", 118: "direction_tb", 119: "direction_bt", 120: "direction_rl", 121: "direction_lr" }, + productions_: [0, [3, 2], [5, 0], [5, 2], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [4, 2], [4, 2], [4, 2], [4, 3], [16, 2], [16, 1], [17, 1], [17, 1], [17, 1], [15, 1], [15, 1], [15, 2], [19, 2], [19, 2], [19, 1], [19, 1], [18, 2], [18, 1], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [7, 9], [7, 6], [7, 4], [7, 1], [7, 2], [7, 2], [7, 1], [21, 1], [21, 1], [21, 1], [20, 3], [20, 4], [20, 2], [20, 1], [40, 1], [40, 5], [41, 1], [41, 3], [43, 4], [43, 4], [43, 6], [43, 4], [43, 4], [43, 4], [43, 8], [43, 4], [43, 4], [43, 4], [43, 6], [43, 4], [43, 4], [43, 4], [43, 4], [43, 4], [43, 1], [39, 2], [39, 3], [39, 3], [39, 1], [39, 3], [74, 1], [74, 2], [74, 1], [74, 1], [70, 1], [71, 3], [30, 1], [30, 2], [30, 1], [30, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [80, 1], [28, 1], [28, 2], [28, 1], [28, 1], [24, 5], [25, 5], [26, 2], [26, 4], [26, 3], [26, 5], [26, 3], [26, 5], [26, 5], [26, 7], [26, 2], [26, 4], [26, 2], [26, 4], [26, 4], [26, 6], [22, 5], [23, 5], [23, 5], [23, 9], [23, 9], [23, 7], [23, 7], [100, 1], [100, 3], [89, 1], [89, 3], [104, 1], [104, 2], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [105, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [110, 1], [79, 1], [79, 1], [79, 1], [79, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [88, 1], [76, 1], [76, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [117, 1], [45, 1], [45, 2], [98, 1], [98, 2], [33, 1], [33, 1], [33, 1], [33, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 2: + this.$ = []; + break; + case 3: + if (!Array.isArray($$[$0]) || $$[$0].length > 0) { + $$[$0 - 1].push($$[$0]); + } + this.$ = $$[$0 - 1]; + break; + case 4: + case 176: + this.$ = $$[$0]; + break; + case 11: + yy.setDirection("TB"); + this.$ = "TB"; + break; + case 12: + yy.setDirection($$[$0 - 1]); + this.$ = $$[$0 - 1]; + break; + case 27: + this.$ = $$[$0 - 1].nodes; + break; + case 28: + case 29: + case 30: + case 31: + case 32: + this.$ = []; + break; + case 33: + this.$ = yy.addSubGraph($$[$0 - 6], $$[$0 - 1], $$[$0 - 4]); + break; + case 34: + this.$ = yy.addSubGraph($$[$0 - 3], $$[$0 - 1], $$[$0 - 3]); + break; + case 35: + this.$ = yy.addSubGraph(void 0, $$[$0 - 1], void 0); + break; + case 37: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 38: + case 39: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 43: + yy.addLink($$[$0 - 2].stmt, $$[$0], $$[$0 - 1]); + this.$ = { stmt: $$[$0], nodes: $$[$0].concat($$[$0 - 2].nodes) }; + break; + case 44: + yy.addLink($$[$0 - 3].stmt, $$[$0 - 1], $$[$0 - 2]); + this.$ = { stmt: $$[$0 - 1], nodes: $$[$0 - 1].concat($$[$0 - 3].nodes) }; + break; + case 45: + this.$ = { stmt: $$[$0 - 1], nodes: $$[$0 - 1] }; + break; + case 46: + this.$ = { stmt: $$[$0], nodes: $$[$0] }; + break; + case 47: + this.$ = [$$[$0]]; + break; + case 48: + this.$ = $$[$0 - 4].concat($$[$0]); + break; + case 49: + this.$ = $$[$0]; + break; + case 50: + this.$ = $$[$0 - 2]; + yy.setClass($$[$0 - 2], $$[$0]); + break; + case 51: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "square"); + break; + case 52: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "doublecircle"); + break; + case 53: + this.$ = $$[$0 - 5]; + yy.addVertex($$[$0 - 5], $$[$0 - 2], "circle"); + break; + case 54: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "ellipse"); + break; + case 55: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "stadium"); + break; + case 56: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "subroutine"); + break; + case 57: + this.$ = $$[$0 - 7]; + yy.addVertex($$[$0 - 7], $$[$0 - 1], "rect", void 0, void 0, void 0, Object.fromEntries([[$$[$0 - 5], $$[$0 - 3]]])); + break; + case 58: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "cylinder"); + break; + case 59: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "round"); + break; + case 60: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "diamond"); + break; + case 61: + this.$ = $$[$0 - 5]; + yy.addVertex($$[$0 - 5], $$[$0 - 2], "hexagon"); + break; + case 62: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "odd"); + break; + case 63: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "trapezoid"); + break; + case 64: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "inv_trapezoid"); + break; + case 65: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "lean_right"); + break; + case 66: + this.$ = $$[$0 - 3]; + yy.addVertex($$[$0 - 3], $$[$0 - 1], "lean_left"); + break; + case 67: + this.$ = $$[$0]; + yy.addVertex($$[$0]); + break; + case 68: + $$[$0 - 1].text = $$[$0]; + this.$ = $$[$0 - 1]; + break; + case 69: + case 70: + $$[$0 - 2].text = $$[$0 - 1]; + this.$ = $$[$0 - 2]; + break; + case 71: + this.$ = $$[$0]; + break; + case 72: + var inf = yy.destructLink($$[$0], $$[$0 - 2]); + this.$ = { "type": inf.type, "stroke": inf.stroke, "length": inf.length, "text": $$[$0 - 1] }; + break; + case 73: + this.$ = { text: $$[$0], type: "text" }; + break; + case 74: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 75: + this.$ = { text: $$[$0], type: "string" }; + break; + case 76: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 77: + var inf = yy.destructLink($$[$0]); + this.$ = { "type": inf.type, "stroke": inf.stroke, "length": inf.length }; + break; + case 78: + this.$ = $$[$0 - 1]; + break; + case 79: + this.$ = { text: $$[$0], type: "text" }; + break; + case 80: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 81: + this.$ = { text: $$[$0], type: "string" }; + break; + case 82: + case 97: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 94: + this.$ = { text: $$[$0], type: "text" }; + break; + case 95: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 96: + this.$ = { text: $$[$0], type: "text" }; + break; + case 98: + this.$ = $$[$0 - 4]; + yy.addClass($$[$0 - 2], $$[$0]); + break; + case 99: + this.$ = $$[$0 - 4]; + yy.setClass($$[$0 - 2], $$[$0]); + break; + case 100: + case 108: + this.$ = $$[$0 - 1]; + yy.setClickEvent($$[$0 - 1], $$[$0]); + break; + case 101: + case 109: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 102: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 103: + this.$ = $$[$0 - 4]; + yy.setClickEvent($$[$0 - 4], $$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 4], $$[$0]); + break; + case 104: + this.$ = $$[$0 - 2]; + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 105: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 4], $$[$0 - 2]); + yy.setTooltip($$[$0 - 4], $$[$0]); + break; + case 106: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 107: + this.$ = $$[$0 - 6]; + yy.setLink($$[$0 - 6], $$[$0 - 4], $$[$0]); + yy.setTooltip($$[$0 - 6], $$[$0 - 2]); + break; + case 110: + this.$ = $$[$0 - 1]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 111: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 3], $$[$0 - 2]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 112: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 3], $$[$0 - 2], $$[$0]); + break; + case 113: + this.$ = $$[$0 - 5]; + yy.setLink($$[$0 - 5], $$[$0 - 4], $$[$0]); + yy.setTooltip($$[$0 - 5], $$[$0 - 2]); + break; + case 114: + this.$ = $$[$0 - 4]; + yy.addVertex($$[$0 - 2], void 0, void 0, $$[$0]); + break; + case 115: + this.$ = $$[$0 - 4]; + yy.updateLink([$$[$0 - 2]], $$[$0]); + break; + case 116: + this.$ = $$[$0 - 4]; + yy.updateLink($$[$0 - 2], $$[$0]); + break; + case 117: + this.$ = $$[$0 - 8]; + yy.updateLinkInterpolate([$$[$0 - 6]], $$[$0 - 2]); + yy.updateLink([$$[$0 - 6]], $$[$0]); + break; + case 118: + this.$ = $$[$0 - 8]; + yy.updateLinkInterpolate($$[$0 - 6], $$[$0 - 2]); + yy.updateLink($$[$0 - 6], $$[$0]); + break; + case 119: + this.$ = $$[$0 - 6]; + yy.updateLinkInterpolate([$$[$0 - 4]], $$[$0]); + break; + case 120: + this.$ = $$[$0 - 6]; + yy.updateLinkInterpolate($$[$0 - 4], $$[$0]); + break; + case 121: + case 123: + this.$ = [$$[$0]]; + break; + case 122: + case 124: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 126: + this.$ = $$[$0 - 1] + $$[$0]; + break; + case 174: + this.$ = $$[$0]; + break; + case 175: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + case 177: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + case 178: + this.$ = { stmt: "dir", value: "TB" }; + break; + case 179: + this.$ = { stmt: "dir", value: "BT" }; + break; + case 180: + this.$ = { stmt: "dir", value: "RL" }; + break; + case 181: + this.$ = { stmt: "dir", value: "LR" }; + break; + } + }, + table: [{ 3: 1, 4: 2, 9: $V0, 10: $V1, 12: $V2 }, { 1: [3] }, o($V3, $V4, { 5: 6 }), { 4: 7, 9: $V0, 10: $V1, 12: $V2 }, { 4: 8, 9: $V0, 10: $V1, 12: $V2 }, { 13: [1, 9], 14: [1, 10] }, { 1: [2, 1], 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, o($V3, [2, 9]), o($V3, [2, 10]), o($V3, [2, 11]), { 8: [1, 54], 9: [1, 55], 10: $Vx, 15: 53, 18: 56 }, o($Vy, [2, 3]), o($Vy, [2, 4]), o($Vy, [2, 5]), o($Vy, [2, 6]), o($Vy, [2, 7]), o($Vy, [2, 8]), { 8: $Vz, 9: $VA, 11: $VB, 21: 58, 39: 59, 70: 63, 73: [1, 64], 75: [1, 65] }, { 8: $Vz, 9: $VA, 11: $VB, 21: 66 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 67 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 68 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 69 }, { 8: $Vz, 9: $VA, 11: $VB, 21: 70 }, { 8: $Vz, 9: $VA, 10: [1, 71], 11: $VB, 21: 72 }, o($Vy, [2, 36]), { 35: [1, 73] }, { 37: [1, 74] }, o($Vy, [2, 39]), o($VC, [2, 46], { 18: 75, 10: $Vx }), { 10: [1, 76] }, { 10: [1, 77] }, { 10: [1, 78] }, { 10: [1, 79] }, { 14: $VD, 42: $VE, 58: $VF, 77: [1, 83], 86: $VG, 92: [1, 80], 94: [1, 81], 98: 82, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, o($Vy, [2, 178]), o($Vy, [2, 179]), o($Vy, [2, 180]), o($Vy, [2, 181]), o($VO, [2, 47]), o($VO, [2, 49], { 44: [1, 96] }), o($VP, [2, 67], { 110: 109, 29: [1, 97], 42: $Vd, 46: [1, 98], 48: [1, 99], 50: [1, 100], 52: [1, 101], 54: [1, 102], 56: [1, 103], 58: $Ve, 61: [1, 104], 63: [1, 105], 65: [1, 106], 66: [1, 107], 68: [1, 108], 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), o($VQ, [2, 174]), o($VQ, [2, 135]), o($VQ, [2, 136]), o($VQ, [2, 137]), o($VQ, [2, 138]), o($VQ, [2, 139]), o($VQ, [2, 140]), o($VQ, [2, 141]), o($VQ, [2, 142]), o($VQ, [2, 143]), o($VQ, [2, 144]), o($VQ, [2, 145]), o($V3, [2, 12]), o($V3, [2, 18]), o($V3, [2, 19]), { 9: [1, 110] }, o($VR, [2, 26], { 18: 111, 10: $Vx }), o($Vy, [2, 27]), { 40: 112, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vy, [2, 40]), o($Vy, [2, 41]), o($Vy, [2, 42]), o($VS, [2, 71], { 71: 113, 60: [1, 115], 72: [1, 114] }), { 74: 116, 76: 117, 77: [1, 118], 78: [1, 119], 113: $VT, 116: $VU }, o([42, 58, 60, 72, 86, 99, 102, 103, 106, 108, 111, 112, 113], [2, 77]), o($Vy, [2, 28]), o($Vy, [2, 29]), o($Vy, [2, 30]), o($Vy, [2, 31]), o($Vy, [2, 32]), { 10: $VV, 12: $VW, 14: $VX, 27: $VY, 28: 122, 32: $VZ, 42: $V_, 58: $V$, 73: $V01, 77: [1, 124], 78: [1, 125], 80: 135, 81: $V11, 82: $V21, 83: $V31, 84: $V41, 85: $V51, 86: $V61, 87: $V71, 88: 123, 102: $V81, 106: $V91, 108: $Va1, 111: $Vb1, 112: $Vc1, 113: $Vd1 }, o($Ve1, $V4, { 5: 148 }), o($Vy, [2, 37]), o($Vy, [2, 38]), o($VC, [2, 45], { 42: $Vf1 }), { 42: $Vd, 45: 150, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 99: [1, 151], 100: 152, 102: [1, 153] }, { 42: $Vd, 45: 154, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 42: $Vd, 45: 155, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vg1, [2, 100], { 10: [1, 156], 93: [1, 157] }), { 77: [1, 158] }, o($Vg1, [2, 108], { 117: 160, 10: [1, 159], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 110], { 10: [1, 161] }), o($Vh1, [2, 176]), o($Vh1, [2, 163]), o($Vh1, [2, 164]), o($Vh1, [2, 165]), o($Vh1, [2, 166]), o($Vh1, [2, 167]), o($Vh1, [2, 168]), o($Vh1, [2, 169]), o($Vh1, [2, 170]), o($Vh1, [2, 171]), o($Vh1, [2, 172]), o($Vh1, [2, 173]), { 42: $Vd, 45: 162, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 30: 163, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 171, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 173, 48: [1, 172], 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 174, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 175, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 176, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 106: [1, 177] }, { 30: 178, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 179, 63: [1, 180], 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 181, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 182, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 183, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VQ, [2, 175]), o($V3, [2, 20]), o($VR, [2, 25]), o($VC, [2, 43], { 18: 184, 10: $Vx }), o($VS, [2, 68], { 10: [1, 185] }), { 10: [1, 186] }, { 30: 187, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 75: [1, 188], 76: 189, 113: $VT, 116: $VU }, o($Vo1, [2, 73]), o($Vo1, [2, 75]), o($Vo1, [2, 76]), o($Vo1, [2, 161]), o($Vo1, [2, 162]), { 8: $Vz, 9: $VA, 10: $VV, 11: $VB, 12: $VW, 14: $VX, 21: 191, 27: $VY, 29: [1, 190], 32: $VZ, 42: $V_, 58: $V$, 73: $V01, 80: 135, 81: $V11, 82: $V21, 83: $V31, 84: $V41, 85: $V51, 86: $V61, 87: $V71, 88: 192, 102: $V81, 106: $V91, 108: $Va1, 111: $Vb1, 112: $Vc1, 113: $Vd1 }, o($Vp1, [2, 94]), o($Vp1, [2, 96]), o($Vp1, [2, 97]), o($Vp1, [2, 150]), o($Vp1, [2, 151]), o($Vp1, [2, 152]), o($Vp1, [2, 153]), o($Vp1, [2, 154]), o($Vp1, [2, 155]), o($Vp1, [2, 156]), o($Vp1, [2, 157]), o($Vp1, [2, 158]), o($Vp1, [2, 159]), o($Vp1, [2, 160]), o($Vp1, [2, 83]), o($Vp1, [2, 84]), o($Vp1, [2, 85]), o($Vp1, [2, 86]), o($Vp1, [2, 87]), o($Vp1, [2, 88]), o($Vp1, [2, 89]), o($Vp1, [2, 90]), o($Vp1, [2, 91]), o($Vp1, [2, 92]), o($Vp1, [2, 93]), { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 193], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, { 10: $Vx, 18: 194 }, { 10: [1, 195], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: [1, 196] }, { 10: [1, 197], 103: [1, 198] }, o($Vq1, [2, 121]), { 10: [1, 199], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: [1, 200], 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 109, 111: $Vq, 112: $Vr, 113: $Vs }, { 77: [1, 201] }, o($Vg1, [2, 102], { 10: [1, 202] }), o($Vg1, [2, 104], { 10: [1, 203] }), { 77: [1, 204] }, o($Vh1, [2, 177]), { 77: [1, 205], 95: [1, 206] }, o($VO, [2, 50], { 110: 109, 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), { 31: [1, 207], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($Vr1, [2, 79]), o($Vr1, [2, 81]), o($Vr1, [2, 82]), o($Vr1, [2, 146]), o($Vr1, [2, 147]), o($Vr1, [2, 148]), o($Vr1, [2, 149]), { 47: [1, 209], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 210, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 49: [1, 211], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 51: [1, 212], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 53: [1, 213], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 55: [1, 214], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 58: [1, 215] }, { 62: [1, 216], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 64: [1, 217], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 30: 218, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 31: [1, 219], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 65: $Vi1, 67: [1, 220], 69: [1, 221], 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 65: $Vi1, 67: [1, 223], 69: [1, 222], 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VC, [2, 44], { 42: $Vf1 }), o($VS, [2, 70]), o($VS, [2, 69]), { 60: [1, 224], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VS, [2, 72]), o($Vo1, [2, 74]), { 30: 225, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($Ve1, $V4, { 5: 226 }), o($Vp1, [2, 95]), o($Vy, [2, 35]), { 41: 227, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 228, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 239, 101: [1, 240], 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 241, 101: [1, 242], 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 102: [1, 243] }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 244, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 42: $Vd, 45: 245, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs }, o($Vg1, [2, 101]), { 77: [1, 246] }, { 77: [1, 247], 95: [1, 248] }, o($Vg1, [2, 109]), o($Vg1, [2, 111], { 10: [1, 249] }), o($Vg1, [2, 112]), o($VP, [2, 51]), o($Vr1, [2, 80]), o($VP, [2, 52]), { 49: [1, 250], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 59]), o($VP, [2, 54]), o($VP, [2, 55]), o($VP, [2, 56]), { 106: [1, 251] }, o($VP, [2, 58]), o($VP, [2, 60]), { 64: [1, 252], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 62]), o($VP, [2, 63]), o($VP, [2, 65]), o($VP, [2, 64]), o($VP, [2, 66]), o([10, 42, 58, 86, 99, 102, 103, 106, 108, 111, 112, 113], [2, 78]), { 31: [1, 253], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 254], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, o($VO, [2, 48]), o($Vg1, [2, 114], { 103: $VA1 }), o($VB1, [2, 123], { 105: 256, 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }), o($VC1, [2, 125]), o($VC1, [2, 127]), o($VC1, [2, 128]), o($VC1, [2, 129]), o($VC1, [2, 130]), o($VC1, [2, 131]), o($VC1, [2, 132]), o($VC1, [2, 133]), o($VC1, [2, 134]), o($Vg1, [2, 115], { 103: $VA1 }), { 10: [1, 257] }, o($Vg1, [2, 116], { 103: $VA1 }), { 10: [1, 258] }, o($Vq1, [2, 122]), o($Vg1, [2, 98], { 103: $VA1 }), o($Vg1, [2, 99], { 110: 109, 42: $Vd, 58: $Ve, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 111: $Vq, 112: $Vr, 113: $Vs }), o($Vg1, [2, 103]), o($Vg1, [2, 105], { 10: [1, 259] }), o($Vg1, [2, 106]), { 95: [1, 260] }, { 49: [1, 261] }, { 60: [1, 262] }, { 64: [1, 263] }, { 8: $Vz, 9: $VA, 11: $VB, 21: 264 }, o($Vy, [2, 34]), { 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 104: 265, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, o($VC1, [2, 126]), { 14: $VD, 42: $VE, 58: $VF, 86: $VG, 98: 266, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, { 14: $VD, 42: $VE, 58: $VF, 86: $VG, 98: 267, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN, 117: 84 }, { 95: [1, 268] }, o($Vg1, [2, 113]), o($VP, [2, 53]), { 30: 269, 65: $Vi1, 77: $Vj1, 78: $Vk1, 79: 164, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, o($VP, [2, 61]), o($Ve1, $V4, { 5: 270 }), o($VB1, [2, 124], { 105: 256, 10: $Vs1, 58: $Vt1, 81: $Vu1, 102: $Vv1, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }), o($Vg1, [2, 119], { 117: 160, 10: [1, 271], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 120], { 117: 160, 10: [1, 272], 14: $VD, 42: $VE, 58: $VF, 86: $VG, 102: $VH, 103: $VI, 106: $VJ, 108: $VK, 111: $VL, 112: $VM, 113: $VN }), o($Vg1, [2, 107]), { 31: [1, 273], 65: $Vi1, 79: 208, 113: $Vl1, 114: $Vm1, 115: $Vn1 }, { 6: 11, 7: 12, 8: $V5, 9: $V6, 10: $V7, 11: $V8, 20: 17, 22: 18, 23: 19, 24: 20, 25: 21, 26: 22, 27: $V9, 32: [1, 274], 33: 24, 34: $Va, 36: $Vb, 38: $Vc, 40: 28, 41: 38, 42: $Vd, 43: 39, 45: 40, 58: $Ve, 81: $Vf, 82: $Vg, 83: $Vh, 84: $Vi, 85: $Vj, 86: $Vk, 99: $Vl, 102: $Vm, 103: $Vn, 106: $Vo, 108: $Vp, 110: 41, 111: $Vq, 112: $Vr, 113: $Vs, 118: $Vt, 119: $Vu, 120: $Vv, 121: $Vw }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 275, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, { 10: $Vs1, 58: $Vt1, 81: $Vu1, 89: 276, 102: $Vv1, 104: 229, 105: 230, 106: $Vw1, 107: $Vx1, 108: $Vy1, 109: $Vz1 }, o($VP, [2, 57]), o($Vy, [2, 33]), o($Vg1, [2, 117], { 103: $VA1 }), o($Vg1, [2, 118], { 103: $VA1 })], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex2() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex2(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex2() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 34; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 36; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + this.begin("callbackname"); + break; + case 8: + this.popState(); + break; + case 9: + this.popState(); + this.begin("callbackargs"); + break; + case 10: + return 92; + case 11: + this.popState(); + break; + case 12: + return 93; + case 13: + return "MD_STR"; + case 14: + this.popState(); + break; + case 15: + this.begin("md_string"); + break; + case 16: + return "STR"; + case 17: + this.popState(); + break; + case 18: + this.pushState("string"); + break; + case 19: + return 81; + case 20: + return 99; + case 21: + return 82; + case 22: + return 101; + case 23: + return 83; + case 24: + return 84; + case 25: + return 94; + case 26: + this.begin("click"); + break; + case 27: + this.popState(); + break; + case 28: + return 85; + case 29: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 30: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 31: + if (yy.lex.firstGraph()) { + this.begin("dir"); + } + return 12; + case 32: + return 27; + case 33: + return 32; + case 34: + return 95; + case 35: + return 95; + case 36: + return 95; + case 37: + return 95; + case 38: + this.popState(); + return 13; + case 39: + this.popState(); + return 14; + case 40: + this.popState(); + return 14; + case 41: + this.popState(); + return 14; + case 42: + this.popState(); + return 14; + case 43: + this.popState(); + return 14; + case 44: + this.popState(); + return 14; + case 45: + this.popState(); + return 14; + case 46: + this.popState(); + return 14; + case 47: + this.popState(); + return 14; + case 48: + this.popState(); + return 14; + case 49: + return 118; + case 50: + return 119; + case 51: + return 120; + case 52: + return 121; + case 53: + return 102; + case 54: + return 108; + case 55: + return 44; + case 56: + return 58; + case 57: + return 42; + case 58: + return 8; + case 59: + return 103; + case 60: + return 112; + case 61: + this.popState(); + return 75; + case 62: + this.pushState("edgeText"); + return 73; + case 63: + return 116; + case 64: + this.popState(); + return 75; + case 65: + this.pushState("thickEdgeText"); + return 73; + case 66: + return 116; + case 67: + this.popState(); + return 75; + case 68: + this.pushState("dottedEdgeText"); + return 73; + case 69: + return 116; + case 70: + return 75; + case 71: + this.popState(); + return 51; + case 72: + return "TEXT"; + case 73: + this.pushState("ellipseText"); + return 50; + case 74: + this.popState(); + return 53; + case 75: + this.pushState("text"); + return 52; + case 76: + this.popState(); + return 55; + case 77: + this.pushState("text"); + return 54; + case 78: + return 56; + case 79: + this.pushState("text"); + return 65; + case 80: + this.popState(); + return 62; + case 81: + this.pushState("text"); + return 61; + case 82: + this.popState(); + return 47; + case 83: + this.pushState("text"); + return 46; + case 84: + this.popState(); + return 67; + case 85: + this.popState(); + return 69; + case 86: + return 114; + case 87: + this.pushState("trapText"); + return 66; + case 88: + this.pushState("trapText"); + return 68; + case 89: + return 115; + case 90: + return 65; + case 91: + return 87; + case 92: + return "SEP"; + case 93: + return 86; + case 94: + return 112; + case 95: + return 108; + case 96: + return 42; + case 97: + return 106; + case 98: + return 111; + case 99: + return 113; + case 100: + this.popState(); + return 60; + case 101: + this.pushState("text"); + return 60; + case 102: + this.popState(); + return 49; + case 103: + this.pushState("text"); + return 48; + case 104: + this.popState(); + return 31; + case 105: + this.pushState("text"); + return 29; + case 106: + this.popState(); + return 64; + case 107: + this.pushState("text"); + return 63; + case 108: + return "TEXT"; + case 109: + return "QUOTE"; + case 110: + return 9; + case 111: + return 10; + case 112: + return 11; + } + }, + rules: [/^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:call[\s]+)/, /^(?:\([\s]*\))/, /^(?:\()/, /^(?:[^(]*)/, /^(?:\))/, /^(?:[^)]*)/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["][`])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:["])/, /^(?:style\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\b)/, /^(?:class\b)/, /^(?:href[\s])/, /^(?:click[\s]+)/, /^(?:[\s\n])/, /^(?:[^\s\n]*)/, /^(?:flowchart-elk\b)/, /^(?:graph\b)/, /^(?:flowchart\b)/, /^(?:subgraph\b)/, /^(?:end\b\s*)/, /^(?:_self\b)/, /^(?:_blank\b)/, /^(?:_parent\b)/, /^(?:_top\b)/, /^(?:(\r?\n)*\s*\n)/, /^(?:\s*LR\b)/, /^(?:\s*RL\b)/, /^(?:\s*TB\b)/, /^(?:\s*BT\b)/, /^(?:\s*TD\b)/, /^(?:\s*BR\b)/, /^(?:\s*<)/, /^(?:\s*>)/, /^(?:\s*\^)/, /^(?:\s*v\b)/, /^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:[0-9]+)/, /^(?:#)/, /^(?::::)/, /^(?::)/, /^(?:&)/, /^(?:;)/, /^(?:,)/, /^(?:\*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:[^-]|-(?!-)+)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:[^=]|=(?!))/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:[^\.]|\.(?!))/, /^(?:\s*~~[\~]+\s*)/, /^(?:[-/\)][\)])/, /^(?:[^\(\)\[\]\{\}]|!\)+)/, /^(?:\(-)/, /^(?:\]\))/, /^(?:\(\[)/, /^(?:\]\])/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:>)/, /^(?:\)\])/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\(\(\()/, /^(?:[\\(?=\])][\]])/, /^(?:\/(?=\])\])/, /^(?:\/(?!\])|\\(?!\])|[^\\\[\]\(\)\{\}\/]+)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:<)/, /^(?:>)/, /^(?:\^)/, /^(?:\\\|)/, /^(?:v\b)/, /^(?:\*)/, /^(?:#)/, /^(?:&)/, /^(?:([A-Za-z0-9!"\#$%&'*+\.`?\\_\/]|-(?=[^\>\-\.])|(?!))+)/, /^(?:-)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\|)/, /^(?:\|)/, /^(?:\))/, /^(?:\()/, /^(?:\])/, /^(?:\[)/, /^(?:(\}))/, /^(?:\{)/, /^(?:[^\[\]\(\)\{\}\|\"]+)/, /^(?:")/, /^(?:(\r?\n)+)/, /^(?:\s)/, /^(?:$)/], + conditions: { "callbackargs": { "rules": [11, 12, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "callbackname": { "rules": [8, 9, 10, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "href": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "click": { "rules": [15, 18, 27, 28, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "dottedEdgeText": { "rules": [15, 18, 67, 69, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "thickEdgeText": { "rules": [15, 18, 64, 66, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "edgeText": { "rules": [15, 18, 61, 63, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "trapText": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 84, 85, 86, 87, 88, 101, 103, 105, 107], "inclusive": false }, "ellipseText": { "rules": [15, 18, 70, 71, 72, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "text": { "rules": [15, 18, 70, 73, 74, 75, 76, 77, 80, 81, 82, 83, 87, 88, 100, 101, 102, 103, 104, 105, 106, 107, 108], "inclusive": false }, "vertex": { "rules": [15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "dir": { "rules": [15, 18, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_descr_multiline": { "rules": [5, 6, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_descr": { "rules": [3, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "acc_title": { "rules": [1, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "md_string": { "rules": [13, 14, 15, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "string": { "rules": [15, 16, 17, 18, 70, 73, 75, 77, 81, 83, 87, 88, 101, 103, 105, 107], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 15, 18, 19, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65, 67, 68, 70, 73, 75, 77, 78, 79, 81, 83, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 103, 105, 107, 109, 110, 111, 112], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$h.parser = parser$h; +const parser$1$d = parser$h; +const MERMAID_DOM_ID_PREFIX$1 = "flowchart-"; +let vertexCounter = 0; +let config$3 = getConfig$2(); +let vertices = {}; +let edges = []; +let classes$3 = {}; +let subGraphs = []; +let subGraphLookup = {}; +let tooltips = {}; +let subCount = 0; +let firstGraphFlag = true; +let direction$3; +let version$1; +let funs$1 = []; +const sanitizeText$3 = (txt) => common$1.sanitizeText(txt, config$3); +const lookUpDomId$1 = function(id) { + const vertexKeys = Object.keys(vertices); + for (const vertexKey of vertexKeys) { + if (vertices[vertexKey].id === id) { + return vertices[vertexKey].domId; + } + } + return id; +}; +const addVertex = function(_id, textObj, type, style, classes2, dir, props = {}) { + let txt; + let id = _id; + if (id === void 0) { + return; + } + if (id.trim().length === 0) { + return; + } + if (vertices[id] === void 0) { + vertices[id] = { + id, + labelType: "text", + domId: MERMAID_DOM_ID_PREFIX$1 + id + "-" + vertexCounter, + styles: [], + classes: [] + }; + } + vertexCounter++; + if (textObj !== void 0) { + config$3 = getConfig$2(); + txt = sanitizeText$3(textObj.text.trim()); + vertices[id].labelType = textObj.type; + if (txt[0] === '"' && txt[txt.length - 1] === '"') { + txt = txt.substring(1, txt.length - 1); + } + vertices[id].text = txt; + } else { + if (vertices[id].text === void 0) { + vertices[id].text = _id; + } + } + if (type !== void 0) { + vertices[id].type = type; + } + if (style !== void 0 && style !== null) { + style.forEach(function(s) { + vertices[id].styles.push(s); + }); + } + if (classes2 !== void 0 && classes2 !== null) { + classes2.forEach(function(s) { + vertices[id].classes.push(s); + }); + } + if (dir !== void 0) { + vertices[id].dir = dir; + } + if (vertices[id].props === void 0) { + vertices[id].props = props; + } else if (props !== void 0) { + Object.assign(vertices[id].props, props); + } +}; +const addSingleLink = function(_start, _end, type) { + let start = _start; + let end = _end; + const edge = { start, end, type: void 0, text: "", labelType: "text" }; + log$1.info("abc78 Got edge...", edge); + const linkTextObj = type.text; + if (linkTextObj !== void 0) { + edge.text = sanitizeText$3(linkTextObj.text.trim()); + if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') { + edge.text = edge.text.substring(1, edge.text.length - 1); + } + edge.labelType = linkTextObj.type; + } + if (type !== void 0) { + edge.type = type.type; + edge.stroke = type.stroke; + edge.length = type.length; + } + if ((edge == null ? void 0 : edge.length) > 10) { + edge.length = 10; + } + if (edges.length < (config$3.maxEdges ?? 500)) { + log$1.info("abc78 pushing edge..."); + edges.push(edge); + } else { + throw new Error( + `Edge limit exceeded. ${edges.length} edges found, but the limit is ${config$3.maxEdges}. + +Initialize mermaid with maxEdges set to a higher number to allow more edges. +You cannot set this config via configuration inside the diagram as it is a secure config. +You have to call mermaid.initialize.` + ); + } +}; +const addLink$1 = function(_start, _end, type) { + log$1.info("addLink (abc78)", _start, _end, type); + let i, j; + for (i = 0; i < _start.length; i++) { + for (j = 0; j < _end.length; j++) { + addSingleLink(_start[i], _end[j], type); + } + } +}; +const updateLinkInterpolate = function(positions, interp) { + positions.forEach(function(pos) { + if (pos === "default") { + edges.defaultInterpolate = interp; + } else { + edges[pos].interpolate = interp; + } + }); +}; +const updateLink = function(positions, style) { + positions.forEach(function(pos) { + if (pos >= edges.length) { + throw new Error( + `The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${edges.length - 1}. (Help: Ensure that the index is within the range of existing edges.)` + ); + } + if (pos === "default") { + edges.defaultStyle = style; + } else { + if (utils.isSubstringInArray("fill", style) === -1) { + style.push("fill:none"); + } + edges[pos].style = style; + } + }); +}; +const addClass$1 = function(ids, style) { + ids.split(",").forEach(function(id) { + if (classes$3[id] === void 0) { + classes$3[id] = { id, styles: [], textStyles: [] }; + } + if (style !== void 0 && style !== null) { + style.forEach(function(s) { + if (s.match("color")) { + const newStyle = s.replace("fill", "bgFill").replace("color", "fill"); + classes$3[id].textStyles.push(newStyle); + } + classes$3[id].styles.push(s); + }); + } + }); +}; +const setDirection$3 = function(dir) { + direction$3 = dir; + if (direction$3.match(/.*/)) { + direction$3 = "LR"; + } + if (direction$3.match(/.*v/)) { + direction$3 = "TB"; + } + if (direction$3 === "TD") { + direction$3 = "TB"; + } +}; +const setClass$1 = function(ids, className) { + ids.split(",").forEach(function(_id) { + let id = _id; + if (vertices[id] !== void 0) { + vertices[id].classes.push(className); + } + if (subGraphLookup[id] !== void 0) { + subGraphLookup[id].classes.push(className); + } + }); +}; +const setTooltip$1 = function(ids, tooltip) { + ids.split(",").forEach(function(id) { + if (tooltip !== void 0) { + tooltips[version$1 === "gen-1" ? lookUpDomId$1(id) : id] = sanitizeText$3(tooltip); + } + }); +}; +const setClickFun$1 = function(id, functionName, functionArgs) { + let domId = lookUpDomId$1(id); + if (getConfig$2().securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(id); + } + if (vertices[id] !== void 0) { + vertices[id].haveCallback = true; + funs$1.push(function() { + const elem = document.querySelector(`[id="${domId}"]`); + if (elem !== null) { + elem.addEventListener( + "click", + function() { + utils.runFunc(functionName, ...argList); + }, + false + ); + } + }); + } +}; +const setLink$2 = function(ids, linkStr, target) { + ids.split(",").forEach(function(id) { + if (vertices[id] !== void 0) { + vertices[id].link = utils.formatUrl(linkStr, config$3); + vertices[id].linkTarget = target; + } + }); + setClass$1(ids, "clickable"); +}; +const getTooltip$1 = function(id) { + if (tooltips.hasOwnProperty(id)) { + return tooltips[id]; + } + return void 0; +}; +const setClickEvent$2 = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFun$1(id, functionName, functionArgs); + }); + setClass$1(ids, "clickable"); +}; +const bindFunctions$2 = function(element) { + funs$1.forEach(function(fun) { + fun(element); + }); +}; +const getDirection$3 = function() { + return direction$3.trim(); +}; +const getVertices = function() { + return vertices; +}; +const getEdges$1 = function() { + return edges; +}; +const getClasses$8 = function() { + return classes$3; +}; +const setupToolTips$1 = function(element) { + let tooltipElem = select(".mermaidTooltip"); + if ((tooltipElem._groups || tooltipElem)[0][0] === null) { + tooltipElem = select("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0); + } + const svg = select(element).select("svg"); + const nodes = svg.selectAll("g.node"); + nodes.on("mouseover", function() { + const el = select(this); + const title = el.attr("title"); + if (title === null) { + return; + } + const rect = this.getBoundingClientRect(); + tooltipElem.transition().duration(200).style("opacity", ".9"); + tooltipElem.text(el.attr("title")).style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.bottom + "px"); + tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, "
    ")); + el.classed("hover", true); + }).on("mouseout", function() { + tooltipElem.transition().duration(500).style("opacity", 0); + const el = select(this); + el.classed("hover", false); + }); +}; +funs$1.push(setupToolTips$1); +const clear$i = function(ver = "gen-1") { + vertices = {}; + classes$3 = {}; + edges = []; + funs$1 = [setupToolTips$1]; + subGraphs = []; + subGraphLookup = {}; + subCount = 0; + tooltips = {}; + firstGraphFlag = true; + version$1 = ver; + config$3 = getConfig$2(); + clear$k(); +}; +const setGen = (ver) => { + version$1 = ver || "gen-2"; +}; +const defaultStyle = function() { + return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; +}; +const addSubGraph = function(_id, list, _title) { + let id = _id.text.trim(); + let title = _title.text; + if (_id === _title && _title.text.match(/\s/)) { + id = void 0; + } + function uniq(a) { + const prims = { boolean: {}, number: {}, string: {} }; + const objs = []; + let dir2; + const nodeList2 = a.filter(function(item) { + const type = typeof item; + if (item.stmt && item.stmt === "dir") { + dir2 = item.value; + return false; + } + if (item.trim() === "") { + return false; + } + if (type in prims) { + return prims[type].hasOwnProperty(item) ? false : prims[type][item] = true; + } else { + return objs.includes(item) ? false : objs.push(item); + } + }); + return { nodeList: nodeList2, dir: dir2 }; + } + let nodeList = []; + const { nodeList: nl, dir } = uniq(nodeList.concat.apply(nodeList, list)); + nodeList = nl; + if (version$1 === "gen-1") { + for (let i = 0; i < nodeList.length; i++) { + nodeList[i] = lookUpDomId$1(nodeList[i]); + } + } + id = id || "subGraph" + subCount; + title = title || ""; + title = sanitizeText$3(title); + subCount = subCount + 1; + const subGraph = { + id, + nodes: nodeList, + title: title.trim(), + classes: [], + dir, + labelType: _title.type + }; + log$1.info("Adding", subGraph.id, subGraph.nodes, subGraph.dir); + subGraph.nodes = makeUniq(subGraph, subGraphs).nodes; + subGraphs.push(subGraph); + subGraphLookup[id] = subGraph; + return id; +}; +const getPosForId = function(id) { + for (const [i, subGraph] of subGraphs.entries()) { + if (subGraph.id === id) { + return i; + } + } + return -1; +}; +let secCount = -1; +const posCrossRef = []; +const indexNodes2 = function(id, pos) { + const nodes = subGraphs[pos].nodes; + secCount = secCount + 1; + if (secCount > 2e3) { + return; + } + posCrossRef[secCount] = pos; + if (subGraphs[pos].id === id) { + return { + result: true, + count: 0 + }; + } + let count = 0; + let posCount = 1; + while (count < nodes.length) { + const childPos = getPosForId(nodes[count]); + if (childPos >= 0) { + const res = indexNodes2(id, childPos); + if (res.result) { + return { + result: true, + count: posCount + res.count + }; + } else { + posCount = posCount + res.count; + } + } + count = count + 1; + } + return { + result: false, + count: posCount + }; +}; +const getDepthFirstPos = function(pos) { + return posCrossRef[pos]; +}; +const indexNodes = function() { + secCount = -1; + if (subGraphs.length > 0) { + indexNodes2("none", subGraphs.length - 1); + } +}; +const getSubGraphs = function() { + return subGraphs; +}; +const firstGraph = () => { + if (firstGraphFlag) { + firstGraphFlag = false; + return true; + } + return false; +}; +const destructStartLink = (_str) => { + let str = _str.trim(); + let type = "arrow_open"; + switch (str[0]) { + case "<": + type = "arrow_point"; + str = str.slice(1); + break; + case "x": + type = "arrow_cross"; + str = str.slice(1); + break; + case "o": + type = "arrow_circle"; + str = str.slice(1); + break; + } + let stroke = "normal"; + if (str.includes("=")) { + stroke = "thick"; + } + if (str.includes(".")) { + stroke = "dotted"; + } + return { type, stroke }; +}; +const countChar = (char, str) => { + const length = str.length; + let count = 0; + for (let i = 0; i < length; ++i) { + if (str[i] === char) { + ++count; + } + } + return count; +}; +const destructEndLink = (_str) => { + const str = _str.trim(); + let line = str.slice(0, -1); + let type = "arrow_open"; + switch (str.slice(-1)) { + case "x": + type = "arrow_cross"; + if (str[0] === "x") { + type = "double_" + type; + line = line.slice(1); + } + break; + case ">": + type = "arrow_point"; + if (str[0] === "<") { + type = "double_" + type; + line = line.slice(1); + } + break; + case "o": + type = "arrow_circle"; + if (str[0] === "o") { + type = "double_" + type; + line = line.slice(1); + } + break; + } + let stroke = "normal"; + let length = line.length - 1; + if (line[0] === "=") { + stroke = "thick"; + } + if (line[0] === "~") { + stroke = "invisible"; + } + let dots = countChar(".", line); + if (dots) { + stroke = "dotted"; + length = dots; + } + return { type, stroke, length }; +}; +const destructLink = (_str, _startStr) => { + const info = destructEndLink(_str); + let startInfo; + if (_startStr) { + startInfo = destructStartLink(_startStr); + if (startInfo.stroke !== info.stroke) { + return { type: "INVALID", stroke: "INVALID" }; + } + if (startInfo.type === "arrow_open") { + startInfo.type = info.type; + } else { + if (startInfo.type !== info.type) { + return { type: "INVALID", stroke: "INVALID" }; + } + startInfo.type = "double_" + startInfo.type; + } + if (startInfo.type === "double_arrow") { + startInfo.type = "double_arrow_point"; + } + startInfo.length = info.length; + return startInfo; + } + return info; +}; +const exists = (allSgs, _id) => { + let res = false; + allSgs.forEach((sg) => { + const pos = sg.nodes.indexOf(_id); + if (pos >= 0) { + res = true; + } + }); + return res; +}; +const makeUniq = (sg, allSubgraphs) => { + const res = []; + sg.nodes.forEach((_id, pos) => { + if (!exists(allSubgraphs, _id)) { + res.push(sg.nodes[pos]); + } + }); + return { nodes: res }; +}; +const lex = { + firstGraph +}; +const flowDb = { + defaultConfig: () => defaultConfig.flowchart, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + addVertex, + lookUpDomId: lookUpDomId$1, + addLink: addLink$1, + updateLinkInterpolate, + updateLink, + addClass: addClass$1, + setDirection: setDirection$3, + setClass: setClass$1, + setTooltip: setTooltip$1, + getTooltip: getTooltip$1, + setClickEvent: setClickEvent$2, + setLink: setLink$2, + bindFunctions: bindFunctions$2, + getDirection: getDirection$3, + getVertices, + getEdges: getEdges$1, + getClasses: getClasses$8, + clear: clear$i, + setGen, + defaultStyle, + addSubGraph, + getDepthFirstPos, + indexNodes, + getSubGraphs, + destructLink, + lex, + exists, + makeUniq, + setDiagramTitle, + getDiagramTitle +}; +const db$e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + addClass: addClass$1, + addLink: addLink$1, + addSingleLink, + addSubGraph, + addVertex, + bindFunctions: bindFunctions$2, + clear: clear$i, + default: flowDb, + defaultStyle, + destructLink, + firstGraph, + getClasses: getClasses$8, + getDepthFirstPos, + getDirection: getDirection$3, + getEdges: getEdges$1, + getSubGraphs, + getTooltip: getTooltip$1, + getVertices, + indexNodes, + lex, + lookUpDomId: lookUpDomId$1, + setClass: setClass$1, + setClickEvent: setClickEvent$2, + setDirection: setDirection$3, + setGen, + setLink: setLink$2, + updateLink, + updateLinkInterpolate +}, Symbol.toStringTag, { value: "Module" })); + +/** `Object#toString` result references. */ +var symbolTag$4 = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol$1(value) { + return typeof value == 'symbol' || + (isObjectLike$1(value) && baseGetTag$1(value) == symbolTag$4); +} + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap$1(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +/** Used as references for various `Number` constants. */ +var INFINITY$5 = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$3 = Symbol$2 ? Symbol$2.prototype : undefined, + symbolToString$1 = symbolProto$3 ? symbolProto$3.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString$1(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray$1(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap$1(value, baseToString$1) + ''; + } + if (isSymbol$1(value)) { + return symbolToString$1 ? symbolToString$1.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$5) ? '-0' : result; +} + +/** Used to match a single whitespace character. */ +var reWhitespace$1 = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex$1(string) { + var index = string.length; + + while (index-- && reWhitespace$1.test(string.charAt(index))) {} + return index; +} + +/** Used to match leading whitespace. */ +var reTrimStart$1 = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim$1(string) { + return string + ? string.slice(0, trimmedEndIndex$1(string) + 1).replace(reTrimStart$1, '') + : string; +} + +/** Used as references for various `Number` constants. */ +var NAN$1 = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary$1 = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal$1 = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt$1 = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber$1(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol$1(value)) { + return NAN$1; + } + if (isObject$2(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject$2(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = baseTrim$1(value); + var isBinary = reIsBinary$1.test(value); + return (isBinary || reIsOctal$1.test(value)) + ? freeParseInt$1(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex$1.test(value) ? NAN$1 : +value); +} + +/** Used as references for various `Number` constants. */ +var INFINITY$4 = 1 / 0, + MAX_INTEGER = 1.7976931348623157e+308; + +/** + * Converts `value` to a finite number. + * + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 + */ +function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber$1(value); + if (value === INFINITY$4 || value === -INFINITY$4) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; + } + return value === value ? value : 0; +} + +/** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ +function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + + return result === result ? (remainder ? result - remainder : result) : 0; +} + +/** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ +function noop$2() { + // No operation performed. +} + +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} + +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (-1); + + while ((++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ +function baseIsNaN(value) { + return value !== value; +} + +/** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); +} + +/** + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. + * + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. + */ +function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; +} + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +/** Used to match property names within property paths. */ +var reIsDeepProp$1 = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp$1 = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey$1(value, object) { + if (isArray$1(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol$1(value)) { + return true; + } + return reIsPlainProp$1.test(value) || !reIsDeepProp$1.test(value) || + (object != null && value in Object(object)); +} + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE$1 = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped$1(func) { + var result = memoize$2(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE$1) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +/** Used to match property names within property paths. */ +var rePropName$1 = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar$1 = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath$1 = memoizeCapped$1(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName$1, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar$1, '$1') : (number || match)); + }); + return result; +}); + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString$3(value) { + return value == null ? '' : baseToString$1(value); +} + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath$1(value, object) { + if (isArray$1(value)) { + return value; + } + return isKey$1(value, object) ? [value] : stringToPath$1(toString$3(value)); +} + +/** Used as references for various `Number` constants. */ +var INFINITY$3 = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey$1(value) { + if (typeof value == 'string' || isSymbol$1(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$3) ? '-0' : result; +} + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet$1(object, path) { + path = castPath$1(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey$1(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get$1(object, path, defaultValue) { + var result = object == null ? undefined : baseGet$1(object, path); + return result === undefined ? defaultValue : result; +} + +/** + * Appends the elements of `values` to `array`. + * + * @private + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. + */ +function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; +} + +/** Built-in value references. */ +var spreadableSymbol = Symbol$2 ? Symbol$2.isConcatSpreadable : undefined; + +/** + * Checks if `value` is a flattenable `arguments` object or array. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenable(value) { + return isArray$1(value) || isArguments(value) || + !!(spreadableSymbol && value && value[spreadableSymbol]); +} + +/** + * The base implementation of `_.flatten` with support for restricting flattening. + * + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. + */ +function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (predicate(value)) { + { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } + } + return result; +} + +/** + * Flattens `array` a single level deep. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] + */ +function flatten(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array) : []; +} + +/** + * A specialized version of `baseRest` which flattens the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ +function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); +} + +/** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ +function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; +} + +/** + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssign(object, source) { + return object && copyObject(source, keys(source), object); +} + +/** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssignIn(object, source) { + return object && copyObject(source, keysIn(source), object); +} + +/** + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; +} + +/** + * This method returns a new empty array. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. + * @example + * + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false + */ +function stubArray() { + return []; +} + +/** Used for built-in method references. */ +var objectProto$b = Object.prototype; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$b.propertyIsEnumerable; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols$1 = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbols = !nativeGetSymbols$1 ? stubArray : function(object) { + if (object == null) { + return []; + } + object = Object(object); + return arrayFilter(nativeGetSymbols$1(object), function(symbol) { + return propertyIsEnumerable.call(object, symbol); + }); +}; + +/** + * Copies own symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols; + +/** + * Creates an array of the own and inherited enumerable symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. + */ +var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; +}; + +/** + * Copies own and inherited symbols of `source` to `object`. + * + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. + */ +function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); +} + +/** + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object)); +} + +/** + * Creates an array of own enumerable property names and symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys, getSymbols); +} + +/** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn, getSymbolsIn); +} + +/** Used for built-in method references. */ +var objectProto$a = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$a = objectProto$a.hasOwnProperty; + +/** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ +function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; +} + +/** + * Creates a clone of `dataView`. + * + * @private + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. + */ +function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); +} + +/** Used to match `RegExp` flags from their coerced string values. */ +var reFlags = /\w*$/; + +/** + * Creates a clone of `regexp`. + * + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. + */ +function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; +} + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$2 = Symbol$2 ? Symbol$2.prototype : undefined, + symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : undefined; + +/** + * Creates a clone of the `symbol` object. + * + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. + */ +function cloneSymbol(symbol) { + return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {}; +} + +/** `Object#toString` result references. */ +var boolTag$2 = '[object Boolean]', + dateTag$2 = '[object Date]', + mapTag$3 = '[object Map]', + numberTag$2 = '[object Number]', + regexpTag$2 = '[object RegExp]', + setTag$3 = '[object Set]', + stringTag$2 = '[object String]', + symbolTag$3 = '[object Symbol]'; + +var arrayBufferTag$2 = '[object ArrayBuffer]', + dataViewTag$2 = '[object DataView]', + float32Tag$1 = '[object Float32Array]', + float64Tag$1 = '[object Float64Array]', + int8Tag$1 = '[object Int8Array]', + int16Tag$1 = '[object Int16Array]', + int32Tag$1 = '[object Int32Array]', + uint8Tag$1 = '[object Uint8Array]', + uint8ClampedTag$1 = '[object Uint8ClampedArray]', + uint16Tag$1 = '[object Uint16Array]', + uint32Tag$1 = '[object Uint32Array]'; + +/** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag$2: + return cloneArrayBuffer(object); + + case boolTag$2: + case dateTag$2: + return new Ctor(+object); + + case dataViewTag$2: + return cloneDataView(object, isDeep); + + case float32Tag$1: case float64Tag$1: + case int8Tag$1: case int16Tag$1: case int32Tag$1: + case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1: + return cloneTypedArray(object, isDeep); + + case mapTag$3: + return new Ctor; + + case numberTag$2: + case stringTag$2: + return new Ctor(object); + + case regexpTag$2: + return cloneRegExp(object); + + case setTag$3: + return new Ctor; + + case symbolTag$3: + return cloneSymbol(object); + } +} + +/** `Object#toString` result references. */ +var mapTag$2 = '[object Map]'; + +/** + * The base implementation of `_.isMap` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + */ +function baseIsMap(value) { + return isObjectLike$1(value) && getTag(value) == mapTag$2; +} + +/* Node.js helper references. */ +var nodeIsMap = nodeUtil && nodeUtil.isMap; + +/** + * Checks if `value` is classified as a `Map` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a map, else `false`. + * @example + * + * _.isMap(new Map); + * // => true + * + * _.isMap(new WeakMap); + * // => false + */ +var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; + +/** `Object#toString` result references. */ +var setTag$2 = '[object Set]'; + +/** + * The base implementation of `_.isSet` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + */ +function baseIsSet(value) { + return isObjectLike$1(value) && getTag(value) == setTag$2; +} + +/* Node.js helper references. */ +var nodeIsSet = nodeUtil && nodeUtil.isSet; + +/** + * Checks if `value` is classified as a `Set` object. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @example + * + * _.isSet(new Set); + * // => true + * + * _.isSet(new WeakSet); + * // => false + */ +var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG$1 = 1, + CLONE_FLAT_FLAG = 2, + CLONE_SYMBOLS_FLAG$2 = 4; + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]', + arrayTag$1 = '[object Array]', + boolTag$1 = '[object Boolean]', + dateTag$1 = '[object Date]', + errorTag$1 = '[object Error]', + funcTag$1 = '[object Function]', + genTag$1 = '[object GeneratorFunction]', + mapTag$1 = '[object Map]', + numberTag$1 = '[object Number]', + objectTag$1 = '[object Object]', + regexpTag$1 = '[object RegExp]', + setTag$1 = '[object Set]', + stringTag$1 = '[object String]', + symbolTag$2 = '[object Symbol]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag$1 = '[object ArrayBuffer]', + dataViewTag$1 = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values supported by `_.clone`. */ +var cloneableTags = {}; +cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = +cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = +cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = +cloneableTags[float32Tag] = cloneableTags[float64Tag] = +cloneableTags[int8Tag] = cloneableTags[int16Tag] = +cloneableTags[int32Tag] = cloneableTags[mapTag$1] = +cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = +cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = +cloneableTags[stringTag$1] = cloneableTags[symbolTag$2] = +cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = +cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; +cloneableTags[errorTag$1] = cloneableTags[funcTag$1] = +cloneableTags[weakMapTag] = false; + +/** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. + */ +function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG$1, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG$2; + if (result !== undefined) { + return result; + } + if (!isObject$2(value)) { + return value; + } + var isArr = isArray$1(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray$2(value, result); + } + } else { + var tag = getTag(value), + isFunc = tag == funcTag$1 || tag == genTag$1; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag$1 || tag == argsTag$1 || (isFunc && !object)) { + result = (isFlat || isFunc) ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat + ? copySymbolsIn(value, baseAssignIn(result, value)) + : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + if (isSet(value)) { + value.forEach(function(subValue) { + result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); + }); + } else if (isMap(value)) { + value.forEach(function(subValue, key) { + result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + } + + var keysFunc = isFull + ? (isFlat ? getAllKeysIn : getAllKeys) + : (isFlat ? keysIn : keys); + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function(subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue$1(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; +} + +/** Used to compose bitmasks for cloning. */ +var CLONE_SYMBOLS_FLAG$1 = 4; + +/** + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); + * // => true + */ +function clone$2(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG$1); +} + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG = 1, + CLONE_SYMBOLS_FLAG = 4; + +/** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ +function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); +} + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$2 = '__lodash_hash_undefined__'; + +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED$2); + return this; +} + +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} + +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache$1; + while (++index < length) { + this.add(values[index]); + } +} + +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; + +/** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} + +/** + * Checks if a `cache` value for `key` exists. + * + * @private + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function cacheHas(cache, key) { + return cache.has(key); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$5 = 1, + COMPARE_UNORDERED_FLAG$3 = 2; + +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; + } + var index = -1, + result = true, + seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined; + + stack.set(array, other); + stack.set(other, array); + + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!cacheHas(seen, othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, bitmask, customizer, stack) + )) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; +} + +/** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ +function mapToArray(map) { + var index = -1, + result = Array(map.size); + + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} + +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$4 = 1, + COMPARE_UNORDERED_FLAG$2 = 2; + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + mapTag = '[object Map]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag$1 = '[object Symbol]'; + +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]'; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : undefined, + symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined; + +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) { + return false; + } + return true; + + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq$1(+object, +other); + + case errorTag: + return object.name == other.name && object.message == other.message; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); + + case mapTag: + var convert = mapToArray; + + case setTag: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG$2; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag$1: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } + } + return false; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$3 = 1; + +/** Used for built-in method references. */ +var objectProto$9 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$9 = objectProto$9.hasOwnProperty; + +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; + + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty$9.call(other, key))) { + return false; + } + } + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; + } + var result = true; + stack.set(object, other); + stack.set(other, object); + + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; + + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) + : compared + )) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } + } + stack['delete'](object); + stack['delete'](other); + return result; +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$2 = 1; + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + objectTag = '[object Object]'; + +/** Used for built-in method references. */ +var objectProto$8 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$8 = objectProto$8.hasOwnProperty; + +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray$1(object), + othIsArr = isArray$1(other), + objTag = objIsArr ? arrayTag : getTag(object), + othTag = othIsArr ? arrayTag : getTag(other); + + objTag = objTag == argsTag ? objectTag : objTag; + othTag = othTag == argsTag ? objectTag : othTag; + + var objIsObj = objTag == objectTag, + othIsObj = othTag == objectTag, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) + : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) { + var objIsWrapped = objIsObj && hasOwnProperty$8.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty$8.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); +} + +/** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObjectLike$1(value) && !isObjectLike$1(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$1 = 1, + COMPARE_UNORDERED_FLAG$1 = 2; + +/** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack; + var result; + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) + : result + )) { + return false; + } + } + } + return true; +} + +/** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ +function isStrictComparable(value) { + return value === value && !isObject$2(value); +} + +/** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ +function getMatchData(object) { + var result = keys(object), + length = result.length; + + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } + return result; +} + +/** + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. + * + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; +} + +/** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; +} + +/** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHasIn(object, key) { + return object != null && key in Object(object); +} + +/** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ +function hasPath(object, path, hasFunc) { + path = castPath$1(path, object); + + var index = -1, + length = path.length, + result = false; + + while (++index < length) { + var key = toKey$1(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; + } + object = object[key]; + } + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex$1(key, length) && + (isArray$1(object) || isArguments(object)); +} + +/** + * Checks if `path` is a direct or inherited property of `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false + */ +function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1, + COMPARE_UNORDERED_FLAG = 2; + +/** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatchesProperty(path, srcValue) { + if (isKey$1(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey$1(path), srcValue); + } + return function(object) { + var objValue = get$1(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); + }; +} + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +/** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function basePropertyDeep(path) { + return function(object) { + return baseGet$1(object, path); + }; +} + +/** + * Creates a function that returns the value at `path` of a given object. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + * @example + * + * var objects = [ + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } + * ]; + * + * _.map(objects, _.property('a.b')); + * // => [2, 1] + * + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); + * // => [1, 2] + */ +function property(path) { + return isKey$1(path) ? baseProperty(toKey$1(path)) : basePropertyDeep(path); +} + +/** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ +function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity$1; + } + if (typeof value == 'object') { + return isArray$1(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); + } + return property(value); +} + +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); +} + +/** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + if (collection == null) { + return collection; + } + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = -1, + iterable = Object(collection); + + while ((++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; +} + +/** + * The base implementation of `_.forEach` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + */ +var baseEach = createBaseEach(baseForOwn); + +/** Used for built-in method references. */ +var objectProto$7 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$7 = objectProto$7.hasOwnProperty; + +/** + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep + * @example + * + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ +var defaults$h = baseRest(function(object, sources) { + object = Object(object); + + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq$1(value, objectProto$7[key]) && !hasOwnProperty$7.call(object, key))) { + object[key] = source[key]; + } + } + } + + return object; +}); + +/** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ +function last(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; +} + +/** + * Casts `value` to `identity` if it's not a function. + * + * @private + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. + */ +function castFunction(value) { + return typeof value == 'function' ? value : identity$1; +} + +/** + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight + * @example + * + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. + * + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +function forEach(collection, iteratee) { + var func = isArray$1(collection) ? arrayEach : baseEach; + return func(collection, castFunction(iteratee)); +} + +/** + * The base implementation of `_.filter` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + */ +function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function(value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; +} + +/** + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new filtered array. + * @see _.reject + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; + * + * _.filter(users, function(o) { return !o.active; }); + * // => objects for ['fred'] + * + * // The `_.matches` iteratee shorthand. + * _.filter(users, { 'age': 36, 'active': true }); + * // => objects for ['barney'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.filter(users, ['active', false]); + * // => objects for ['fred'] + * + * // The `_.property` iteratee shorthand. + * _.filter(users, 'active'); + * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] + */ +function filter$1(collection, predicate) { + var func = isArray$1(collection) ? arrayFilter : baseFilter; + return func(collection, baseIteratee(predicate)); +} + +/** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ +function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = baseIteratee(predicate); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$2 = Math.max; + +/** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 + */ +function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax$2(length + index, 0); + } + return baseFindIndex(array, baseIteratee(predicate), index); +} + +/** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' + * + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' + */ +var find$1 = createFind(findIndex); + +/** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; +} + +/** + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + * @example + * + * function square(n) { + * return n * n; + * } + * + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ +function map(collection, iteratee) { + var func = isArray$1(collection) ? arrayMap$1 : baseMap; + return func(collection, baseIteratee(iteratee)); +} + +/** + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + */ +function forIn(object, iteratee) { + return object == null + ? object + : baseFor(object, castFunction(iteratee), keysIn); +} + +/** + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +function forOwn(object, iteratee) { + return object && baseForOwn(object, castFunction(iteratee)); +} + +/** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ +function baseGt(value, other) { + return value > other; +} + +/** Used for built-in method references. */ +var objectProto$6 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$6 = objectProto$6.hasOwnProperty; + +/** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHas(object, key) { + return object != null && hasOwnProperty$6.call(object, key); +} + +/** + * Checks if `path` is a direct property of `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.has(object, 'a'); + * // => true + * + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); + * // => false + */ +function has(object, path) { + return object != null && hasPath(object, path, baseHas); +} + +/** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ +function baseValues(object, props) { + return arrayMap$1(props, function(key) { + return object[key]; + }); +} + +/** + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ +function values(object) { + return object == null ? [] : baseValues(object, keys(object)); +} + +/** + * Checks if `value` is `undefined`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ +function isUndefined(value) { + return value === undefined; +} + +/** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ +function baseLt(value, other) { + return value < other; +} + +/** + * Creates an object with the same keys as `object` and values generated + * by running each own enumerable string keyed property of `object` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapKeys + * @example + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * _.mapValues(users, function(o) { return o.age; }); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * + * // The `_.property` iteratee shorthand. + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ +function mapValues(object, iteratee) { + var result = {}; + iteratee = baseIteratee(iteratee); + + baseForOwn(object, function(value, key, object) { + baseAssignValue$1(result, key, iteratee(value, key, object)); + }); + return result; +} + +/** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ +function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index], + current = iteratee(value); + + if (current != null && (computed === undefined + ? (current === current && !isSymbol$1(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; +} + +/** + * Computes the maximum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * _.max([]); + * // => undefined + */ +function max$2(array) { + return (array && array.length) + ? baseExtremum(array, identity$1, baseGt) + : undefined; +} + +/** + * Computes the minimum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * _.min([]); + * // => undefined + */ +function min$2(array) { + return (array && array.length) + ? baseExtremum(array, identity$1, baseLt) + : undefined; +} + +/** + * This method is like `_.min` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * the value is ranked. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {*} Returns the minimum value. + * @example + * + * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * + * _.minBy(objects, function(o) { return o.n; }); + * // => { 'n': 1 } + * + * // The `_.property` iteratee shorthand. + * _.minBy(objects, 'n'); + * // => { 'n': 1 } + */ +function minBy(array, iteratee) { + return (array && array.length) + ? baseExtremum(array, baseIteratee(iteratee), baseLt) + : undefined; +} + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet$1(object, path, value, customizer) { + if (!isObject$2(object)) { + return object; + } + path = castPath$1(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey$1(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = undefined; + if (newValue === undefined) { + newValue = isObject$2(objValue) + ? objValue + : (isIndex$1(path[index + 1]) ? [] : {}); + } + } + assignValue$1(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +/** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ +function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; + + while (++index < length) { + var path = paths[index], + value = baseGet$1(object, path); + + if (predicate(value, path)) { + baseSet$1(result, castPath$1(path, object), value); + } + } + return result; +} + +/** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ +function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; +} + +/** + * Compares values to sort them in ascending order. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ +function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol$1(value); + + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol$1(other); + + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; + } + } + return 0; +} + +/** + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ +function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; +} + +/** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ +function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap$1(iteratees, function(iteratee) { + if (isArray$1(iteratee)) { + return function(value) { + return baseGet$1(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity$1]; + } + + var index = -1; + iteratees = arrayMap$1(iteratees, baseUnary(baseIteratee)); + + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap$1(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); +} + +/** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ +function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); +} + +/** + * Creates an object composed of the picked `object` properties. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } + */ +var pick = flatRest(function(object, paths) { + return object == null ? {} : basePick(object, paths); +}); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil, + nativeMax$1 = Math.max; + +/** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ +function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[++index] = start; + start += step; + } + return result; +} + +/** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ +function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step); + }; +} + +/** + * Creates an array of numbers (positive and/or negative) progressing from + * `start` up to, but not including, `end`. A step of `-1` is used if a negative + * `start` is specified without an `end` or `step`. If `end` is not specified, + * it's set to `start` with `start` then set to `0`. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the range of numbers. + * @see _.inRange, _.rangeRight + * @example + * + * _.range(4); + * // => [0, 1, 2, 3] + * + * _.range(-4); + * // => [0, -1, -2, -3] + * + * _.range(1, 5); + * // => [1, 2, 3, 4] + * + * _.range(0, 20, 5); + * // => [0, 5, 10, 15] + * + * _.range(0, -4, -1); + * // => [0, -1, -2, -3] + * + * _.range(1, 4, 0); + * // => [1, 1, 1] + * + * _.range(0); + * // => [] + */ +var range = createRange(); + +/** + * The base implementation of `_.reduce` and `_.reduceRight`, without support + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} accumulator The initial value. + * @param {boolean} initAccum Specify using the first or last element of + * `collection` as the initial value. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the accumulated value. + */ +function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { + eachFunc(collection, function(value, index, collection) { + accumulator = initAccum + ? (initAccum = false, value) + : iteratee(accumulator, value, index, collection); + }); + return accumulator; +} + +/** + * Reduces `collection` to a value which is the accumulated result of running + * each element in `collection` thru `iteratee`, where each successive + * invocation is supplied the return value of the previous. If `accumulator` + * is not given, the first element of `collection` is used as the initial + * value. The iteratee is invoked with four arguments: + * (accumulator, value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.reduce`, `_.reduceRight`, and `_.transform`. + * + * The guarded methods are: + * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, + * and `sortBy` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @returns {*} Returns the accumulated value. + * @see _.reduceRight + * @example + * + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }, 0); + * // => 3 + * + * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * return result; + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) + */ +function reduce(collection, iteratee, accumulator) { + var func = isArray$1(collection) ? arrayReduce : baseReduce, + initAccum = arguments.length < 3; + + return func(collection, baseIteratee(iteratee), accumulator, initAccum, baseEach); +} + +/** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection thru each iteratee. This method + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The iteratees are invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to sort by. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 30 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.sortBy(users, [function(o) { return o.user; }]); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] + * + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] + */ +var sortBy = baseRest(function(collection, iteratees) { + if (collection == null) { + return []; + } + var length = iteratees.length; + if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + iteratees = []; + } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + iteratees = [iteratees[0]]; + } + return baseOrderBy(collection, baseFlatten(iteratees), []); +}); + +/** Used as references for various `Number` constants. */ +var INFINITY$2 = 1 / 0; + +/** + * Creates a set object of `values`. + * + * @private + * @param {Array} values The values to add to the set. + * @returns {Object} Returns the new set. + */ +var createSet = !(Set$2 && (1 / setToArray(new Set$2([,-0]))[1]) == INFINITY$2) ? noop$2 : function(values) { + return new Set$2(values); +}; + +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; + +/** + * The base implementation of `_.uniqBy` without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new duplicate free array. + */ +function baseUniq(array, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + length = array.length, + isCommon = true, + result = [], + seen = result; + + if (length >= LARGE_ARRAY_SIZE) { + var set = createSet(array); + if (set) { + return setToArray(set); + } + isCommon = false; + includes = cacheHas; + seen = new SetCache; + } + else { + seen = result; + } + outer: + while (++index < length) { + var value = array[index], + computed = value; + + value = (value !== 0) ? value : 0; + if (isCommon && computed === computed) { + var seenIndex = seen.length; + while (seenIndex--) { + if (seen[seenIndex] === computed) { + continue outer; + } + } + result.push(value); + } + else if (!includes(seen, computed, comparator)) { + if (seen !== result) { + seen.push(computed); + } + result.push(value); + } + } + return result; +} + +/** + * Creates an array of unique values, in order, from all given arrays using + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of combined values. + * @example + * + * _.union([2], [1, 2]); + * // => [2, 1] + */ +var union = baseRest(function(arrays) { + return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); +}); + +/** Used to generate unique IDs. */ +var idCounter = 0; + +/** + * Generates a unique ID. If `prefix` is given, the ID is appended to it. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {string} [prefix=''] The value to prefix the ID with. + * @returns {string} Returns the unique ID. + * @example + * + * _.uniqueId('contact_'); + * // => 'contact_104' + * + * _.uniqueId(); + * // => '105' + */ +function uniqueId(prefix) { + var id = ++idCounter; + return toString$3(prefix) + id; +} + +/** + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. + * + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. + */ +function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; +} + +/** + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property identifiers and one of corresponding values. + * + * @static + * @memberOf _ + * @since 0.4.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject(['a', 'b'], [1, 2]); + * // => { 'a': 1, 'b': 2 } + */ +function zipObject(props, values) { + return baseZipObject(props || [], values || [], assignValue$1); +} + +var DEFAULT_EDGE_NAME = '\x00'; +var GRAPH_NODE = '\x00'; +var EDGE_KEY_DELIM = '\x01'; + +// Implementation notes: +// +// * Node id query functions should return string ids for the nodes +// * Edge id query functions should return an "edgeObj", edge object, that is +// composed of enough information to uniquely identify an edge: {v, w, name}. +// * Internally we use an "edgeId", a stringified form of the edgeObj, to +// reference edges. This is because we need a performant way to look these +// edges up and, object properties, which have string keys, are the closest +// we're going to get to a performant hashtable in JavaScript. + +// Implementation notes: +// +// * Node id query functions should return string ids for the nodes +// * Edge id query functions should return an "edgeObj", edge object, that is +// composed of enough information to uniquely identify an edge: {v, w, name}. +// * Internally we use an "edgeId", a stringified form of the edgeObj, to +// reference edges. This is because we need a performant way to look these +// edges up and, object properties, which have string keys, are the closest +// we're going to get to a performant hashtable in JavaScript. +class Graph { + constructor(opts = {}) { + this._isDirected = has(opts, 'directed') ? opts.directed : true; + this._isMultigraph = has(opts, 'multigraph') ? opts.multigraph : false; + this._isCompound = has(opts, 'compound') ? opts.compound : false; + + // Label for the graph itself + this._label = undefined; + + // Defaults to be set when creating a new node + this._defaultNodeLabelFn = constant$2(undefined); + + // Defaults to be set when creating a new edge + this._defaultEdgeLabelFn = constant$2(undefined); + + // v -> label + this._nodes = {}; + + if (this._isCompound) { + // v -> parent + this._parent = {}; + + // v -> children + this._children = {}; + this._children[GRAPH_NODE] = {}; + } + + // v -> edgeObj + this._in = {}; + + // u -> v -> Number + this._preds = {}; + + // v -> edgeObj + this._out = {}; + + // v -> w -> Number + this._sucs = {}; + + // e -> edgeObj + this._edgeObjs = {}; + + // e -> label + this._edgeLabels = {}; + } + /* === Graph functions ========= */ + isDirected() { + return this._isDirected; + } + isMultigraph() { + return this._isMultigraph; + } + isCompound() { + return this._isCompound; + } + setGraph(label) { + this._label = label; + return this; + } + graph() { + return this._label; + } + /* === Node functions ========== */ + setDefaultNodeLabel(newDefault) { + if (!isFunction$1(newDefault)) { + newDefault = constant$2(newDefault); + } + this._defaultNodeLabelFn = newDefault; + return this; + } + nodeCount() { + return this._nodeCount; + } + nodes() { + return keys(this._nodes); + } + sources() { + var self = this; + return filter$1(this.nodes(), function (v) { + return isEmpty(self._in[v]); + }); + } + sinks() { + var self = this; + return filter$1(this.nodes(), function (v) { + return isEmpty(self._out[v]); + }); + } + setNodes(vs, value) { + var args = arguments; + var self = this; + forEach(vs, function (v) { + if (args.length > 1) { + self.setNode(v, value); + } else { + self.setNode(v); + } + }); + return this; + } + setNode(v, value) { + if (has(this._nodes, v)) { + if (arguments.length > 1) { + this._nodes[v] = value; + } + return this; + } + + // @ts-expect-error + this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v); + if (this._isCompound) { + this._parent[v] = GRAPH_NODE; + this._children[v] = {}; + this._children[GRAPH_NODE][v] = true; + } + this._in[v] = {}; + this._preds[v] = {}; + this._out[v] = {}; + this._sucs[v] = {}; + ++this._nodeCount; + return this; + } + node(v) { + return this._nodes[v]; + } + hasNode(v) { + return has(this._nodes, v); + } + removeNode(v) { + var self = this; + if (has(this._nodes, v)) { + var removeEdge = function (e) { + self.removeEdge(self._edgeObjs[e]); + }; + delete this._nodes[v]; + if (this._isCompound) { + this._removeFromParentsChildList(v); + delete this._parent[v]; + forEach(this.children(v), function (child) { + self.setParent(child); + }); + delete this._children[v]; + } + forEach(keys(this._in[v]), removeEdge); + delete this._in[v]; + delete this._preds[v]; + forEach(keys(this._out[v]), removeEdge); + delete this._out[v]; + delete this._sucs[v]; + --this._nodeCount; + } + return this; + } + setParent(v, parent) { + if (!this._isCompound) { + throw new Error('Cannot set parent in a non-compound graph'); + } + + if (isUndefined(parent)) { + parent = GRAPH_NODE; + } else { + // Coerce parent to string + parent += ''; + for (var ancestor = parent; !isUndefined(ancestor); ancestor = this.parent(ancestor)) { + if (ancestor === v) { + throw new Error('Setting ' + parent + ' as parent of ' + v + ' would create a cycle'); + } + } + + this.setNode(parent); + } + + this.setNode(v); + this._removeFromParentsChildList(v); + this._parent[v] = parent; + this._children[parent][v] = true; + return this; + } + _removeFromParentsChildList(v) { + delete this._children[this._parent[v]][v]; + } + parent(v) { + if (this._isCompound) { + var parent = this._parent[v]; + if (parent !== GRAPH_NODE) { + return parent; + } + } + } + children(v) { + if (isUndefined(v)) { + v = GRAPH_NODE; + } + + if (this._isCompound) { + var children = this._children[v]; + if (children) { + return keys(children); + } + } else if (v === GRAPH_NODE) { + return this.nodes(); + } else if (this.hasNode(v)) { + return []; + } + } + predecessors(v) { + var predsV = this._preds[v]; + if (predsV) { + return keys(predsV); + } + } + successors(v) { + var sucsV = this._sucs[v]; + if (sucsV) { + return keys(sucsV); + } + } + neighbors(v) { + var preds = this.predecessors(v); + if (preds) { + return union(preds, this.successors(v)); + } + } + isLeaf(v) { + var neighbors; + if (this.isDirected()) { + neighbors = this.successors(v); + } else { + neighbors = this.neighbors(v); + } + return neighbors.length === 0; + } + filterNodes(filter) { + // @ts-expect-error + var copy = new this.constructor({ + directed: this._isDirected, + multigraph: this._isMultigraph, + compound: this._isCompound, + }); + + copy.setGraph(this.graph()); + + var self = this; + forEach(this._nodes, function (value, v) { + if (filter(v)) { + copy.setNode(v, value); + } + }); + + forEach(this._edgeObjs, function (e) { + // @ts-expect-error + if (copy.hasNode(e.v) && copy.hasNode(e.w)) { + copy.setEdge(e, self.edge(e)); + } + }); + + var parents = {}; + function findParent(v) { + var parent = self.parent(v); + if (parent === undefined || copy.hasNode(parent)) { + parents[v] = parent; + return parent; + } else if (parent in parents) { + return parents[parent]; + } else { + return findParent(parent); + } + } + + if (this._isCompound) { + forEach(copy.nodes(), function (v) { + copy.setParent(v, findParent(v)); + }); + } + + return copy; + } + /* === Edge functions ========== */ + setDefaultEdgeLabel(newDefault) { + if (!isFunction$1(newDefault)) { + newDefault = constant$2(newDefault); + } + this._defaultEdgeLabelFn = newDefault; + return this; + } + edgeCount() { + return this._edgeCount; + } + edges() { + return values(this._edgeObjs); + } + setPath(vs, value) { + var self = this; + var args = arguments; + reduce(vs, function (v, w) { + if (args.length > 1) { + self.setEdge(v, w, value); + } else { + self.setEdge(v, w); + } + return w; + }); + return this; + } + /* + * setEdge(v, w, [value, [name]]) + * setEdge({ v, w, [name] }, [value]) + */ + setEdge() { + var v, w, name, value; + var valueSpecified = false; + var arg0 = arguments[0]; + + if (typeof arg0 === 'object' && arg0 !== null && 'v' in arg0) { + v = arg0.v; + w = arg0.w; + name = arg0.name; + if (arguments.length === 2) { + value = arguments[1]; + valueSpecified = true; + } + } else { + v = arg0; + w = arguments[1]; + name = arguments[3]; + if (arguments.length > 2) { + value = arguments[2]; + valueSpecified = true; + } + } + + v = '' + v; + w = '' + w; + if (!isUndefined(name)) { + name = '' + name; + } + + var e = edgeArgsToId(this._isDirected, v, w, name); + if (has(this._edgeLabels, e)) { + if (valueSpecified) { + this._edgeLabels[e] = value; + } + return this; + } + + if (!isUndefined(name) && !this._isMultigraph) { + throw new Error('Cannot set a named edge when isMultigraph = false'); + } + + // It didn't exist, so we need to create it. + // First ensure the nodes exist. + this.setNode(v); + this.setNode(w); + + // @ts-expect-error + this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name); + + var edgeObj = edgeArgsToObj(this._isDirected, v, w, name); + // Ensure we add undirected edges in a consistent way. + v = edgeObj.v; + w = edgeObj.w; + + Object.freeze(edgeObj); + this._edgeObjs[e] = edgeObj; + incrementOrInitEntry(this._preds[w], v); + incrementOrInitEntry(this._sucs[v], w); + this._in[w][e] = edgeObj; + this._out[v][e] = edgeObj; + this._edgeCount++; + return this; + } + edge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + return this._edgeLabels[e]; + } + hasEdge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + return has(this._edgeLabels, e); + } + removeEdge(v, w, name) { + var e = + arguments.length === 1 + ? edgeObjToId(this._isDirected, arguments[0]) + : edgeArgsToId(this._isDirected, v, w, name); + var edge = this._edgeObjs[e]; + if (edge) { + v = edge.v; + w = edge.w; + delete this._edgeLabels[e]; + delete this._edgeObjs[e]; + decrementOrRemoveEntry(this._preds[w], v); + decrementOrRemoveEntry(this._sucs[v], w); + delete this._in[w][e]; + delete this._out[v][e]; + this._edgeCount--; + } + return this; + } + inEdges(v, u) { + var inV = this._in[v]; + if (inV) { + var edges = values(inV); + if (!u) { + return edges; + } + return filter$1(edges, function (edge) { + return edge.v === u; + }); + } + } + outEdges(v, w) { + var outV = this._out[v]; + if (outV) { + var edges = values(outV); + if (!w) { + return edges; + } + return filter$1(edges, function (edge) { + return edge.w === w; + }); + } + } + nodeEdges(v, w) { + var inEdges = this.inEdges(v, w); + if (inEdges) { + return inEdges.concat(this.outEdges(v, w)); + } + } +} + +/* Number of nodes in the graph. Should only be changed by the implementation. */ +Graph.prototype._nodeCount = 0; + +/* Number of edges in the graph. Should only be changed by the implementation. */ +Graph.prototype._edgeCount = 0; + +function incrementOrInitEntry(map, k) { + if (map[k]) { + map[k]++; + } else { + map[k] = 1; + } +} + +function decrementOrRemoveEntry(map, k) { + if (!--map[k]) { + delete map[k]; + } +} + +function edgeArgsToId(isDirected, v_, w_, name) { + var v = '' + v_; + var w = '' + w_; + if (!isDirected && v > w) { + var tmp = v; + v = w; + w = tmp; + } + return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM + (isUndefined(name) ? DEFAULT_EDGE_NAME : name); +} + +function edgeArgsToObj(isDirected, v_, w_, name) { + var v = '' + v_; + var w = '' + w_; + if (!isDirected && v > w) { + var tmp = v; + v = w; + w = tmp; + } + var edgeObj = { v: v, w: w }; + if (name) { + edgeObj.name = name; + } + return edgeObj; +} + +function edgeObjToId(isDirected, edgeObj) { + return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name); +} + +/* + * Simple doubly linked list implementation derived from Cormen, et al., + * "Introduction to Algorithms". + */ + + +class List { + constructor() { + var sentinel = {}; + sentinel._next = sentinel._prev = sentinel; + this._sentinel = sentinel; + } + dequeue() { + var sentinel = this._sentinel; + var entry = sentinel._prev; + if (entry !== sentinel) { + unlink(entry); + return entry; + } + } + enqueue(entry) { + var sentinel = this._sentinel; + if (entry._prev && entry._next) { + unlink(entry); + } + entry._next = sentinel._next; + sentinel._next._prev = entry; + sentinel._next = entry; + entry._prev = sentinel; + } + toString() { + var strs = []; + var sentinel = this._sentinel; + var curr = sentinel._prev; + while (curr !== sentinel) { + strs.push(JSON.stringify(curr, filterOutLinks)); + curr = curr._prev; + } + return '[' + strs.join(', ') + ']'; + } +} + +function unlink(entry) { + entry._prev._next = entry._next; + entry._next._prev = entry._prev; + delete entry._next; + delete entry._prev; +} + +function filterOutLinks(k, v) { + if (k !== '_next' && k !== '_prev') { + return v; + } +} + +var DEFAULT_WEIGHT_FN = constant$2(1); + +function greedyFAS(g, weightFn) { + if (g.nodeCount() <= 1) { + return []; + } + var state = buildState(g, weightFn || DEFAULT_WEIGHT_FN); + var results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx); + + // Expand multi-edges + return flatten( + map(results, function (e) { + return g.outEdges(e.v, e.w); + }) + ); +} + +function doGreedyFAS(g, buckets, zeroIdx) { + var results = []; + var sources = buckets[buckets.length - 1]; + var sinks = buckets[0]; + + var entry; + while (g.nodeCount()) { + while ((entry = sinks.dequeue())) { + removeNode(g, buckets, zeroIdx, entry); + } + while ((entry = sources.dequeue())) { + removeNode(g, buckets, zeroIdx, entry); + } + if (g.nodeCount()) { + for (var i = buckets.length - 2; i > 0; --i) { + entry = buckets[i].dequeue(); + if (entry) { + results = results.concat(removeNode(g, buckets, zeroIdx, entry, true)); + break; + } + } + } + } + + return results; +} + +function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) { + var results = collectPredecessors ? [] : undefined; + + forEach(g.inEdges(entry.v), function (edge) { + var weight = g.edge(edge); + var uEntry = g.node(edge.v); + + if (collectPredecessors) { + results.push({ v: edge.v, w: edge.w }); + } + + uEntry.out -= weight; + assignBucket(buckets, zeroIdx, uEntry); + }); + + forEach(g.outEdges(entry.v), function (edge) { + var weight = g.edge(edge); + var w = edge.w; + var wEntry = g.node(w); + wEntry['in'] -= weight; + assignBucket(buckets, zeroIdx, wEntry); + }); + + g.removeNode(entry.v); + + return results; +} + +function buildState(g, weightFn) { + var fasGraph = new Graph(); + var maxIn = 0; + var maxOut = 0; + + forEach(g.nodes(), function (v) { + fasGraph.setNode(v, { v: v, in: 0, out: 0 }); + }); + + // Aggregate weights on nodes, but also sum the weights across multi-edges + // into a single edge for the fasGraph. + forEach(g.edges(), function (e) { + var prevWeight = fasGraph.edge(e.v, e.w) || 0; + var weight = weightFn(e); + var edgeWeight = prevWeight + weight; + fasGraph.setEdge(e.v, e.w, edgeWeight); + maxOut = Math.max(maxOut, (fasGraph.node(e.v).out += weight)); + maxIn = Math.max(maxIn, (fasGraph.node(e.w)['in'] += weight)); + }); + + var buckets = range(maxOut + maxIn + 3).map(function () { + return new List(); + }); + var zeroIdx = maxIn + 1; + + forEach(fasGraph.nodes(), function (v) { + assignBucket(buckets, zeroIdx, fasGraph.node(v)); + }); + + return { graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx }; +} + +function assignBucket(buckets, zeroIdx, entry) { + if (!entry.out) { + buckets[0].enqueue(entry); + } else if (!entry['in']) { + buckets[buckets.length - 1].enqueue(entry); + } else { + buckets[entry.out - entry['in'] + zeroIdx].enqueue(entry); + } +} + +function run$2(g) { + var fas = g.graph().acyclicer === 'greedy' ? greedyFAS(g, weightFn(g)) : dfsFAS(g); + forEach(fas, function (e) { + var label = g.edge(e); + g.removeEdge(e); + label.forwardName = e.name; + label.reversed = true; + g.setEdge(e.w, e.v, label, uniqueId('rev')); + }); + + function weightFn(g) { + return function (e) { + return g.edge(e).weight; + }; + } +} + +function dfsFAS(g) { + var fas = []; + var stack = {}; + var visited = {}; + + function dfs(v) { + if (has(visited, v)) { + return; + } + visited[v] = true; + stack[v] = true; + forEach(g.outEdges(v), function (e) { + if (has(stack, e.w)) { + fas.push(e); + } else { + dfs(e.w); + } + }); + delete stack[v]; + } + + forEach(g.nodes(), dfs); + return fas; +} + +function undo$2(g) { + forEach(g.edges(), function (e) { + var label = g.edge(e); + if (label.reversed) { + g.removeEdge(e); + + var forwardName = label.forwardName; + delete label.reversed; + delete label.forwardName; + g.setEdge(e.w, e.v, label, forwardName); + } + }); +} + +/* + * Adds a dummy node to the graph and return v. + */ +function addDummyNode(g, type, attrs, name) { + var v; + do { + v = uniqueId(name); + } while (g.hasNode(v)); + + attrs.dummy = type; + g.setNode(v, attrs); + return v; +} + +/* + * Returns a new graph with only simple edges. Handles aggregation of data + * associated with multi-edges. + */ +function simplify(g) { + var simplified = new Graph().setGraph(g.graph()); + forEach(g.nodes(), function (v) { + simplified.setNode(v, g.node(v)); + }); + forEach(g.edges(), function (e) { + var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 }; + var label = g.edge(e); + simplified.setEdge(e.v, e.w, { + weight: simpleLabel.weight + label.weight, + minlen: Math.max(simpleLabel.minlen, label.minlen), + }); + }); + return simplified; +} + +function asNonCompoundGraph(g) { + var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph()); + forEach(g.nodes(), function (v) { + if (!g.children(v).length) { + simplified.setNode(v, g.node(v)); + } + }); + forEach(g.edges(), function (e) { + simplified.setEdge(e, g.edge(e)); + }); + return simplified; +} + +/* + * Finds where a line starting at point ({x, y}) would intersect a rectangle + * ({x, y, width, height}) if it were pointing at the rectangle's center. + */ +function intersectRect$3(rect, point) { + var x = rect.x; + var y = rect.y; + + // Rectangle intersection algorithm from: + // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes + var dx = point.x - x; + var dy = point.y - y; + var w = rect.width / 2; + var h = rect.height / 2; + + if (!dx && !dy) { + throw new Error('Not possible to find intersection inside of the rectangle'); + } + + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + // Intersection is top or bottom of rect. + if (dy < 0) { + h = -h; + } + sx = (h * dx) / dy; + sy = h; + } else { + // Intersection is left or right of rect. + if (dx < 0) { + w = -w; + } + sx = w; + sy = (w * dy) / dx; + } + + return { x: x + sx, y: y + sy }; +} + +/* + * Given a DAG with each node assigned "rank" and "order" properties, this + * function will produce a matrix with the ids of each node. + */ +function buildLayerMatrix(g) { + var layering = map(range(maxRank(g) + 1), function () { + return []; + }); + forEach(g.nodes(), function (v) { + var node = g.node(v); + var rank = node.rank; + if (!isUndefined(rank)) { + layering[rank][node.order] = v; + } + }); + return layering; +} + +/* + * Adjusts the ranks for all nodes in the graph such that all nodes v have + * rank(v) >= 0 and at least one node w has rank(w) = 0. + */ +function normalizeRanks(g) { + var min = min$2( + map(g.nodes(), function (v) { + return g.node(v).rank; + }) + ); + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (has(node, 'rank')) { + node.rank -= min; + } + }); +} + +function removeEmptyRanks(g) { + // Ranks may not start at 0, so we need to offset them + var offset = min$2( + map(g.nodes(), function (v) { + return g.node(v).rank; + }) + ); + + var layers = []; + forEach(g.nodes(), function (v) { + var rank = g.node(v).rank - offset; + if (!layers[rank]) { + layers[rank] = []; + } + layers[rank].push(v); + }); + + var delta = 0; + var nodeRankFactor = g.graph().nodeRankFactor; + forEach(layers, function (vs, i) { + if (isUndefined(vs) && i % nodeRankFactor !== 0) { + --delta; + } else if (delta) { + forEach(vs, function (v) { + g.node(v).rank += delta; + }); + } + }); +} + +function addBorderNode$1(g, prefix, rank, order) { + var node = { + width: 0, + height: 0, + }; + if (arguments.length >= 4) { + node.rank = rank; + node.order = order; + } + return addDummyNode(g, 'border', node, prefix); +} + +function maxRank(g) { + return max$2( + map(g.nodes(), function (v) { + var rank = g.node(v).rank; + if (!isUndefined(rank)) { + return rank; + } + }) + ); +} + +/* + * Partition a collection into two groups: `lhs` and `rhs`. If the supplied + * function returns true for an entry it goes into `lhs`. Otherwise it goes + * into `rhs. + */ +function partition(collection, fn) { + var result = { lhs: [], rhs: [] }; + forEach(collection, function (value) { + if (fn(value)) { + result.lhs.push(value); + } else { + result.rhs.push(value); + } + }); + return result; +} + +function notime(name, fn) { + return fn(); +} + +function addBorderSegments(g) { + function dfs(v) { + var children = g.children(v); + var node = g.node(v); + if (children.length) { + forEach(children, dfs); + } + + if (has(node, 'minRank')) { + node.borderLeft = []; + node.borderRight = []; + for (var rank = node.minRank, maxRank = node.maxRank + 1; rank < maxRank; ++rank) { + addBorderNode(g, 'borderLeft', '_bl', v, node, rank); + addBorderNode(g, 'borderRight', '_br', v, node, rank); + } + } + } + + forEach(g.children(), dfs); +} + +function addBorderNode(g, prop, prefix, sg, sgNode, rank) { + var label = { width: 0, height: 0, rank: rank, borderType: prop }; + var prev = sgNode[prop][rank - 1]; + var curr = addDummyNode(g, 'border', label, prefix); + sgNode[prop][rank] = curr; + g.setParent(curr, sg); + if (prev) { + g.setEdge(prev, curr, { weight: 1 }); + } +} + +function adjust(g) { + var rankDir = g.graph().rankdir.toLowerCase(); + if (rankDir === 'lr' || rankDir === 'rl') { + swapWidthHeight(g); + } +} + +function undo$1(g) { + var rankDir = g.graph().rankdir.toLowerCase(); + if (rankDir === 'bt' || rankDir === 'rl') { + reverseY(g); + } + + if (rankDir === 'lr' || rankDir === 'rl') { + swapXY(g); + swapWidthHeight(g); + } +} + +function swapWidthHeight(g) { + forEach(g.nodes(), function (v) { + swapWidthHeightOne(g.node(v)); + }); + forEach(g.edges(), function (e) { + swapWidthHeightOne(g.edge(e)); + }); +} + +function swapWidthHeightOne(attrs) { + var w = attrs.width; + attrs.width = attrs.height; + attrs.height = w; +} + +function reverseY(g) { + forEach(g.nodes(), function (v) { + reverseYOne(g.node(v)); + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, reverseYOne); + if (has(edge, 'y')) { + reverseYOne(edge); + } + }); +} + +function reverseYOne(attrs) { + attrs.y = -attrs.y; +} + +function swapXY(g) { + forEach(g.nodes(), function (v) { + swapXYOne(g.node(v)); + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, swapXYOne); + if (has(edge, 'x')) { + swapXYOne(edge); + } + }); +} + +function swapXYOne(attrs) { + var x = attrs.x; + attrs.x = attrs.y; + attrs.y = x; +} + +/* + * Breaks any long edges in the graph into short segments that span 1 layer + * each. This operation is undoable with the denormalize function. + * + * Pre-conditions: + * + * 1. The input graph is a DAG. + * 2. Each node in the graph has a "rank" property. + * + * Post-condition: + * + * 1. All edges in the graph have a length of 1. + * 2. Dummy nodes are added where edges have been split into segments. + * 3. The graph is augmented with a "dummyChains" attribute which contains + * the first dummy in each chain of dummy nodes produced. + */ +function run$1(g) { + g.graph().dummyChains = []; + forEach(g.edges(), function (edge) { + normalizeEdge(g, edge); + }); +} + +function normalizeEdge(g, e) { + var v = e.v; + var vRank = g.node(v).rank; + var w = e.w; + var wRank = g.node(w).rank; + var name = e.name; + var edgeLabel = g.edge(e); + var labelRank = edgeLabel.labelRank; + + if (wRank === vRank + 1) return; + + g.removeEdge(e); + + var dummy, attrs, i; + for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) { + edgeLabel.points = []; + attrs = { + width: 0, + height: 0, + edgeLabel: edgeLabel, + edgeObj: e, + rank: vRank, + }; + dummy = addDummyNode(g, 'edge', attrs, '_d'); + if (vRank === labelRank) { + attrs.width = edgeLabel.width; + attrs.height = edgeLabel.height; + // @ts-expect-error + attrs.dummy = 'edge-label'; + // @ts-expect-error + attrs.labelpos = edgeLabel.labelpos; + } + g.setEdge(v, dummy, { weight: edgeLabel.weight }, name); + if (i === 0) { + g.graph().dummyChains.push(dummy); + } + v = dummy; + } + + g.setEdge(v, w, { weight: edgeLabel.weight }, name); +} + +function undo(g) { + forEach(g.graph().dummyChains, function (v) { + var node = g.node(v); + var origLabel = node.edgeLabel; + var w; + g.setEdge(node.edgeObj, origLabel); + while (node.dummy) { + w = g.successors(v)[0]; + g.removeNode(v); + origLabel.points.push({ x: node.x, y: node.y }); + if (node.dummy === 'edge-label') { + origLabel.x = node.x; + origLabel.y = node.y; + origLabel.width = node.width; + origLabel.height = node.height; + } + v = w; + node = g.node(v); + } + }); +} + +/* + * Initializes ranks for the input graph using the longest path algorithm. This + * algorithm scales well and is fast in practice, it yields rather poor + * solutions. Nodes are pushed to the lowest layer possible, leaving the bottom + * ranks wide and leaving edges longer than necessary. However, due to its + * speed, this algorithm is good for getting an initial ranking that can be fed + * into other algorithms. + * + * This algorithm does not normalize layers because it will be used by other + * algorithms in most cases. If using this algorithm directly, be sure to + * run normalize at the end. + * + * Pre-conditions: + * + * 1. Input graph is a DAG. + * 2. Input graph node labels can be assigned properties. + * + * Post-conditions: + * + * 1. Each node will be assign an (unnormalized) "rank" property. + */ +function longestPath(g) { + var visited = {}; + + function dfs(v) { + var label = g.node(v); + if (has(visited, v)) { + return label.rank; + } + visited[v] = true; + + var rank = min$2( + map(g.outEdges(v), function (e) { + return dfs(e.w) - g.edge(e).minlen; + }) + ); + + if ( + rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3 + rank === undefined || // return value of _.map([]) for Lodash 4 + rank === null + ) { + // return value of _.map([null]) + rank = 0; + } + + return (label.rank = rank); + } + + forEach(g.sources(), dfs); +} + +/* + * Returns the amount of slack for the given edge. The slack is defined as the + * difference between the length of the edge and its minimum length. + */ +function slack(g, e) { + return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen; +} + +/* + * Constructs a spanning tree with tight edges and adjusted the input node's + * ranks to achieve this. A tight edge is one that is has a length that matches + * its "minlen" attribute. + * + * The basic structure for this function is derived from Gansner, et al., "A + * Technique for Drawing Directed Graphs." + * + * Pre-conditions: + * + * 1. Graph must be a DAG. + * 2. Graph must be connected. + * 3. Graph must have at least one node. + * 5. Graph nodes must have been previously assigned a "rank" property that + * respects the "minlen" property of incident edges. + * 6. Graph edges must have a "minlen" property. + * + * Post-conditions: + * + * - Graph nodes will have their rank adjusted to ensure that all edges are + * tight. + * + * Returns a tree (undirected graph) that is constructed using only "tight" + * edges. + */ +function feasibleTree(g) { + var t = new Graph({ directed: false }); + + // Choose arbitrary node from which to start our tree + var start = g.nodes()[0]; + var size = g.nodeCount(); + t.setNode(start, {}); + + var edge, delta; + while (tightTree(t, g) < size) { + edge = findMinSlackEdge(t, g); + delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); + shiftRanks(t, g, delta); + } + + return t; +} + +/* + * Finds a maximal tree of tight edges and returns the number of nodes in the + * tree. + */ +function tightTree(t, g) { + function dfs(v) { + forEach(g.nodeEdges(v), function (e) { + var edgeV = e.v, + w = v === edgeV ? e.w : edgeV; + if (!t.hasNode(w) && !slack(g, e)) { + t.setNode(w, {}); + t.setEdge(v, w, {}); + dfs(w); + } + }); + } + + forEach(t.nodes(), dfs); + return t.nodeCount(); +} + +/* + * Finds the edge with the smallest slack that is incident on tree and returns + * it. + */ +function findMinSlackEdge(t, g) { + return minBy(g.edges(), function (e) { + if (t.hasNode(e.v) !== t.hasNode(e.w)) { + return slack(g, e); + } + }); +} + +function shiftRanks(t, g, delta) { + forEach(t.nodes(), function (v) { + g.node(v).rank += delta; + }); +} + +function CycleException() {} +CycleException.prototype = new Error(); // must be an instance of Error to pass testing + +/* + * A helper that preforms a pre- or post-order traversal on the input graph + * and returns the nodes in the order they were visited. If the graph is + * undirected then this algorithm will navigate using neighbors. If the graph + * is directed then this algorithm will navigate using successors. + * + * Order must be one of "pre" or "post". + */ +function dfs$1(g, vs, order) { + if (!isArray$1(vs)) { + vs = [vs]; + } + + var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g); + + var acc = []; + var visited = {}; + forEach(vs, function (v) { + if (!g.hasNode(v)) { + throw new Error('Graph does not have node: ' + v); + } + + doDfs(g, v, order === 'post', visited, navigation, acc); + }); + return acc; +} + +function doDfs(g, v, postorder, visited, navigation, acc) { + if (!has(visited, v)) { + visited[v] = true; + + if (!postorder) { + acc.push(v); + } + forEach(navigation(v), function (w) { + doDfs(g, w, postorder, visited, navigation, acc); + }); + if (postorder) { + acc.push(v); + } + } +} + +function postorder$1(g, vs) { + return dfs$1(g, vs, 'post'); +} + +function preorder(g, vs) { + return dfs$1(g, vs, 'pre'); +} + +// Expose some internals for testing purposes +networkSimplex.initLowLimValues = initLowLimValues; +networkSimplex.initCutValues = initCutValues; +networkSimplex.calcCutValue = calcCutValue; +networkSimplex.leaveEdge = leaveEdge; +networkSimplex.enterEdge = enterEdge; +networkSimplex.exchangeEdges = exchangeEdges; + +/* + * The network simplex algorithm assigns ranks to each node in the input graph + * and iteratively improves the ranking to reduce the length of edges. + * + * Preconditions: + * + * 1. The input graph must be a DAG. + * 2. All nodes in the graph must have an object value. + * 3. All edges in the graph must have "minlen" and "weight" attributes. + * + * Postconditions: + * + * 1. All nodes in the graph will have an assigned "rank" attribute that has + * been optimized by the network simplex algorithm. Ranks start at 0. + * + * + * A rough sketch of the algorithm is as follows: + * + * 1. Assign initial ranks to each node. We use the longest path algorithm, + * which assigns ranks to the lowest position possible. In general this + * leads to very wide bottom ranks and unnecessarily long edges. + * 2. Construct a feasible tight tree. A tight tree is one such that all + * edges in the tree have no slack (difference between length of edge + * and minlen for the edge). This by itself greatly improves the assigned + * rankings by shorting edges. + * 3. Iteratively find edges that have negative cut values. Generally a + * negative cut value indicates that the edge could be removed and a new + * tree edge could be added to produce a more compact graph. + * + * Much of the algorithms here are derived from Gansner, et al., "A Technique + * for Drawing Directed Graphs." The structure of the file roughly follows the + * structure of the overall algorithm. + */ +function networkSimplex(g) { + g = simplify(g); + longestPath(g); + var t = feasibleTree(g); + initLowLimValues(t); + initCutValues(t, g); + + var e, f; + while ((e = leaveEdge(t))) { + f = enterEdge(t, g, e); + exchangeEdges(t, g, e, f); + } +} + +/* + * Initializes cut values for all edges in the tree. + */ +function initCutValues(t, g) { + var vs = postorder$1(t, t.nodes()); + vs = vs.slice(0, vs.length - 1); + forEach(vs, function (v) { + assignCutValue(t, g, v); + }); +} + +function assignCutValue(t, g, child) { + var childLab = t.node(child); + var parent = childLab.parent; + t.edge(child, parent).cutvalue = calcCutValue(t, g, child); +} + +/* + * Given the tight tree, its graph, and a child in the graph calculate and + * return the cut value for the edge between the child and its parent. + */ +function calcCutValue(t, g, child) { + var childLab = t.node(child); + var parent = childLab.parent; + // True if the child is on the tail end of the edge in the directed graph + var childIsTail = true; + // The graph's view of the tree edge we're inspecting + var graphEdge = g.edge(child, parent); + // The accumulated cut value for the edge between this node and its parent + var cutValue = 0; + + if (!graphEdge) { + childIsTail = false; + graphEdge = g.edge(parent, child); + } + + cutValue = graphEdge.weight; + + forEach(g.nodeEdges(child), function (e) { + var isOutEdge = e.v === child, + other = isOutEdge ? e.w : e.v; + + if (other !== parent) { + var pointsToHead = isOutEdge === childIsTail, + otherWeight = g.edge(e).weight; + + cutValue += pointsToHead ? otherWeight : -otherWeight; + if (isTreeEdge(t, child, other)) { + var otherCutValue = t.edge(child, other).cutvalue; + cutValue += pointsToHead ? -otherCutValue : otherCutValue; + } + } + }); + + return cutValue; +} + +function initLowLimValues(tree, root) { + if (arguments.length < 2) { + root = tree.nodes()[0]; + } + dfsAssignLowLim(tree, {}, 1, root); +} + +function dfsAssignLowLim(tree, visited, nextLim, v, parent) { + var low = nextLim; + var label = tree.node(v); + + visited[v] = true; + forEach(tree.neighbors(v), function (w) { + if (!has(visited, w)) { + nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v); + } + }); + + label.low = low; + label.lim = nextLim++; + if (parent) { + label.parent = parent; + } else { + // TODO should be able to remove this when we incrementally update low lim + delete label.parent; + } + + return nextLim; +} + +function leaveEdge(tree) { + return find$1(tree.edges(), function (e) { + return tree.edge(e).cutvalue < 0; + }); +} + +function enterEdge(t, g, edge) { + var v = edge.v; + var w = edge.w; + + // For the rest of this function we assume that v is the tail and w is the + // head, so if we don't have this edge in the graph we should flip it to + // match the correct orientation. + if (!g.hasEdge(v, w)) { + v = edge.w; + w = edge.v; + } + + var vLabel = t.node(v); + var wLabel = t.node(w); + var tailLabel = vLabel; + var flip = false; + + // If the root is in the tail of the edge then we need to flip the logic that + // checks for the head and tail nodes in the candidates function below. + if (vLabel.lim > wLabel.lim) { + tailLabel = wLabel; + flip = true; + } + + var candidates = filter$1(g.edges(), function (edge) { + return ( + flip === isDescendant$1(t, t.node(edge.v), tailLabel) && + flip !== isDescendant$1(t, t.node(edge.w), tailLabel) + ); + }); + + return minBy(candidates, function (edge) { + return slack(g, edge); + }); +} + +function exchangeEdges(t, g, e, f) { + var v = e.v; + var w = e.w; + t.removeEdge(v, w); + t.setEdge(f.v, f.w, {}); + initLowLimValues(t); + initCutValues(t, g); + updateRanks(t, g); +} + +function updateRanks(t, g) { + var root = find$1(t.nodes(), function (v) { + return !g.node(v).parent; + }); + var vs = preorder(t, root); + vs = vs.slice(1); + forEach(vs, function (v) { + var parent = t.node(v).parent, + edge = g.edge(v, parent), + flipped = false; + + if (!edge) { + edge = g.edge(parent, v); + flipped = true; + } + + g.node(v).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen); + }); +} + +/* + * Returns true if the edge is in the tree. + */ +function isTreeEdge(tree, u, v) { + return tree.hasEdge(u, v); +} + +/* + * Returns true if the specified node is descendant of the root node per the + * assigned low and lim attributes in the tree. + */ +function isDescendant$1(tree, vLabel, rootLabel) { + return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim; +} + +/* + * Assigns a rank to each node in the input graph that respects the "minlen" + * constraint specified on edges between nodes. + * + * This basic structure is derived from Gansner, et al., "A Technique for + * Drawing Directed Graphs." + * + * Pre-conditions: + * + * 1. Graph must be a connected DAG + * 2. Graph nodes must be objects + * 3. Graph edges must have "weight" and "minlen" attributes + * + * Post-conditions: + * + * 1. Graph nodes will have a "rank" attribute based on the results of the + * algorithm. Ranks can start at any index (including negative), we'll + * fix them up later. + */ +function rank(g) { + switch (g.graph().ranker) { + case 'network-simplex': + networkSimplexRanker(g); + break; + case 'tight-tree': + tightTreeRanker(g); + break; + case 'longest-path': + longestPathRanker(g); + break; + default: + networkSimplexRanker(g); + } +} + +// A fast and simple ranker, but results are far from optimal. +var longestPathRanker = longestPath; + +function tightTreeRanker(g) { + longestPath(g); + feasibleTree(g); +} + +function networkSimplexRanker(g) { + networkSimplex(g); +} + +/* + * A nesting graph creates dummy nodes for the tops and bottoms of subgraphs, + * adds appropriate edges to ensure that all cluster nodes are placed between + * these boundries, and ensures that the graph is connected. + * + * In addition we ensure, through the use of the minlen property, that nodes + * and subgraph border nodes to not end up on the same rank. + * + * Preconditions: + * + * 1. Input graph is a DAG + * 2. Nodes in the input graph has a minlen attribute + * + * Postconditions: + * + * 1. Input graph is connected. + * 2. Dummy nodes are added for the tops and bottoms of subgraphs. + * 3. The minlen attribute for nodes is adjusted to ensure nodes do not + * get placed on the same rank as subgraph border nodes. + * + * The nesting graph idea comes from Sander, "Layout of Compound Directed + * Graphs." + */ +function run(g) { + var root = addDummyNode(g, 'root', {}, '_root'); + var depths = treeDepths(g); + var height = max$2(values(depths)) - 1; // Note: depths is an Object not an array + var nodeSep = 2 * height + 1; + + g.graph().nestingRoot = root; + + // Multiply minlen by nodeSep to align nodes on non-border ranks. + forEach(g.edges(), function (e) { + g.edge(e).minlen *= nodeSep; + }); + + // Calculate a weight that is sufficient to keep subgraphs vertically compact + var weight = sumWeights(g) + 1; + + // Create border nodes and link them up + forEach(g.children(), function (child) { + dfs(g, root, nodeSep, weight, height, depths, child); + }); + + // Save the multiplier for node layers for later removal of empty border + // layers. + g.graph().nodeRankFactor = nodeSep; +} + +function dfs(g, root, nodeSep, weight, height, depths, v) { + var children = g.children(v); + if (!children.length) { + if (v !== root) { + g.setEdge(root, v, { weight: 0, minlen: nodeSep }); + } + return; + } + + var top = addBorderNode$1(g, '_bt'); + var bottom = addBorderNode$1(g, '_bb'); + var label = g.node(v); + + g.setParent(top, v); + label.borderTop = top; + g.setParent(bottom, v); + label.borderBottom = bottom; + + forEach(children, function (child) { + dfs(g, root, nodeSep, weight, height, depths, child); + + var childNode = g.node(child); + var childTop = childNode.borderTop ? childNode.borderTop : child; + var childBottom = childNode.borderBottom ? childNode.borderBottom : child; + var thisWeight = childNode.borderTop ? weight : 2 * weight; + var minlen = childTop !== childBottom ? 1 : height - depths[v] + 1; + + g.setEdge(top, childTop, { + weight: thisWeight, + minlen: minlen, + nestingEdge: true, + }); + + g.setEdge(childBottom, bottom, { + weight: thisWeight, + minlen: minlen, + nestingEdge: true, + }); + }); + + if (!g.parent(v)) { + g.setEdge(root, top, { weight: 0, minlen: height + depths[v] }); + } +} + +function treeDepths(g) { + var depths = {}; + function dfs(v, depth) { + var children = g.children(v); + if (children && children.length) { + forEach(children, function (child) { + dfs(child, depth + 1); + }); + } + depths[v] = depth; + } + forEach(g.children(), function (v) { + dfs(v, 1); + }); + return depths; +} + +function sumWeights(g) { + return reduce( + g.edges(), + function (acc, e) { + return acc + g.edge(e).weight; + }, + 0 + ); +} + +function cleanup(g) { + var graphLabel = g.graph(); + g.removeNode(graphLabel.nestingRoot); + delete graphLabel.nestingRoot; + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.nestingEdge) { + g.removeEdge(e); + } + }); +} + +function addSubgraphConstraints(g, cg, vs) { + var prev = {}, + rootPrev; + + forEach(vs, function (v) { + var child = g.parent(v), + parent, + prevChild; + while (child) { + parent = g.parent(child); + if (parent) { + prevChild = prev[parent]; + prev[parent] = child; + } else { + prevChild = rootPrev; + rootPrev = child; + } + if (prevChild && prevChild !== child) { + cg.setEdge(prevChild, child); + return; + } + child = parent; + } + }); + + /* + function dfs(v) { + var children = v ? g.children(v) : g.children(); + if (children.length) { + var min = Number.POSITIVE_INFINITY, + subgraphs = []; + _.each(children, function(child) { + var childMin = dfs(child); + if (g.children(child).length) { + subgraphs.push({ v: child, order: childMin }); + } + min = Math.min(min, childMin); + }); + _.reduce(_.sortBy(subgraphs, "order"), function(prev, curr) { + cg.setEdge(prev.v, curr.v); + return curr; + }); + return min; + } + return g.node(v).order; + } + dfs(undefined); + */ +} + +/* + * Constructs a graph that can be used to sort a layer of nodes. The graph will + * contain all base and subgraph nodes from the request layer in their original + * hierarchy and any edges that are incident on these nodes and are of the type + * requested by the "relationship" parameter. + * + * Nodes from the requested rank that do not have parents are assigned a root + * node in the output graph, which is set in the root graph attribute. This + * makes it easy to walk the hierarchy of movable nodes during ordering. + * + * Pre-conditions: + * + * 1. Input graph is a DAG + * 2. Base nodes in the input graph have a rank attribute + * 3. Subgraph nodes in the input graph has minRank and maxRank attributes + * 4. Edges have an assigned weight + * + * Post-conditions: + * + * 1. Output graph has all nodes in the movable rank with preserved + * hierarchy. + * 2. Root nodes in the movable layer are made children of the node + * indicated by the root attribute of the graph. + * 3. Non-movable nodes incident on movable nodes, selected by the + * relationship parameter, are included in the graph (without hierarchy). + * 4. Edges incident on movable nodes, selected by the relationship + * parameter, are added to the output graph. + * 5. The weights for copied edges are aggregated as need, since the output + * graph is not a multi-graph. + */ +function buildLayerGraph(g, rank, relationship) { + var root = createRootNode(g), + result = new Graph({ compound: true }) + .setGraph({ root: root }) + .setDefaultNodeLabel(function (v) { + return g.node(v); + }); + + forEach(g.nodes(), function (v) { + var node = g.node(v), + parent = g.parent(v); + + if (node.rank === rank || (node.minRank <= rank && rank <= node.maxRank)) { + result.setNode(v); + result.setParent(v, parent || root); + + // This assumes we have only short edges! + forEach(g[relationship](v), function (e) { + var u = e.v === v ? e.w : e.v, + edge = result.edge(u, v), + weight = !isUndefined(edge) ? edge.weight : 0; + result.setEdge(u, v, { weight: g.edge(e).weight + weight }); + }); + + if (has(node, 'minRank')) { + result.setNode(v, { + borderLeft: node.borderLeft[rank], + borderRight: node.borderRight[rank], + }); + } + } + }); + + return result; +} + +function createRootNode(g) { + var v; + while (g.hasNode((v = uniqueId('_root')))); + return v; +} + +/* + * A function that takes a layering (an array of layers, each with an array of + * ordererd nodes) and a graph and returns a weighted crossing count. + * + * Pre-conditions: + * + * 1. Input graph must be simple (not a multigraph), directed, and include + * only simple edges. + * 2. Edges in the input graph must have assigned weights. + * + * Post-conditions: + * + * 1. The graph and layering matrix are left unchanged. + * + * This algorithm is derived from Barth, et al., "Bilayer Cross Counting." + */ +function crossCount(g, layering) { + var cc = 0; + for (var i = 1; i < layering.length; ++i) { + cc += twoLayerCrossCount(g, layering[i - 1], layering[i]); + } + return cc; +} + +function twoLayerCrossCount(g, northLayer, southLayer) { + // Sort all of the edges between the north and south layers by their position + // in the north layer and then the south. Map these edges to the position of + // their head in the south layer. + var southPos = zipObject( + southLayer, + map(southLayer, function (v, i) { + return i; + }) + ); + var southEntries = flatten( + map(northLayer, function (v) { + return sortBy( + map(g.outEdges(v), function (e) { + return { pos: southPos[e.w], weight: g.edge(e).weight }; + }), + 'pos' + ); + }) + ); + + // Build the accumulator tree + var firstIndex = 1; + while (firstIndex < southLayer.length) firstIndex <<= 1; + var treeSize = 2 * firstIndex - 1; + firstIndex -= 1; + var tree = map(new Array(treeSize), function () { + return 0; + }); + + // Calculate the weighted crossings + var cc = 0; + forEach( + // @ts-expect-error + southEntries.forEach(function (entry) { + var index = entry.pos + firstIndex; + tree[index] += entry.weight; + var weightSum = 0; + // @ts-expect-error + while (index > 0) { + // @ts-expect-error + if (index % 2) { + weightSum += tree[index + 1]; + } + // @ts-expect-error + index = (index - 1) >> 1; + tree[index] += entry.weight; + } + cc += entry.weight * weightSum; + }) + ); + + return cc; +} + +/* + * Assigns an initial order value for each node by performing a DFS search + * starting from nodes in the first rank. Nodes are assigned an order in their + * rank as they are first visited. + * + * This approach comes from Gansner, et al., "A Technique for Drawing Directed + * Graphs." + * + * Returns a layering matrix with an array per layer and each layer sorted by + * the order of its nodes. + */ +function initOrder(g) { + var visited = {}; + var simpleNodes = filter$1(g.nodes(), function (v) { + return !g.children(v).length; + }); + var maxRank = max$2( + map(simpleNodes, function (v) { + return g.node(v).rank; + }) + ); + var layers = map(range(maxRank + 1), function () { + return []; + }); + + function dfs(v) { + if (has(visited, v)) return; + visited[v] = true; + var node = g.node(v); + layers[node.rank].push(v); + forEach(g.successors(v), dfs); + } + + var orderedVs = sortBy(simpleNodes, function (v) { + return g.node(v).rank; + }); + forEach(orderedVs, dfs); + + return layers; +} + +function barycenter(g, movable) { + return map(movable, function (v) { + var inV = g.inEdges(v); + if (!inV.length) { + return { v: v }; + } else { + var result = reduce( + inV, + function (acc, e) { + var edge = g.edge(e), + nodeU = g.node(e.v); + return { + sum: acc.sum + edge.weight * nodeU.order, + weight: acc.weight + edge.weight, + }; + }, + { sum: 0, weight: 0 } + ); + + return { + v: v, + barycenter: result.sum / result.weight, + weight: result.weight, + }; + } + }); +} + +/* + * Given a list of entries of the form {v, barycenter, weight} and a + * constraint graph this function will resolve any conflicts between the + * constraint graph and the barycenters for the entries. If the barycenters for + * an entry would violate a constraint in the constraint graph then we coalesce + * the nodes in the conflict into a new node that respects the contraint and + * aggregates barycenter and weight information. + * + * This implementation is based on the description in Forster, "A Fast and + * Simple Hueristic for Constrained Two-Level Crossing Reduction," thought it + * differs in some specific details. + * + * Pre-conditions: + * + * 1. Each entry has the form {v, barycenter, weight}, or if the node has + * no barycenter, then {v}. + * + * Returns: + * + * A new list of entries of the form {vs, i, barycenter, weight}. The list + * `vs` may either be a singleton or it may be an aggregation of nodes + * ordered such that they do not violate constraints from the constraint + * graph. The property `i` is the lowest original index of any of the + * elements in `vs`. + */ +function resolveConflicts(entries, cg) { + var mappedEntries = {}; + forEach(entries, function (entry, i) { + var tmp = (mappedEntries[entry.v] = { + indegree: 0, + in: [], + out: [], + vs: [entry.v], + i: i, + }); + if (!isUndefined(entry.barycenter)) { + // @ts-expect-error + tmp.barycenter = entry.barycenter; + // @ts-expect-error + tmp.weight = entry.weight; + } + }); + + forEach(cg.edges(), function (e) { + var entryV = mappedEntries[e.v]; + var entryW = mappedEntries[e.w]; + if (!isUndefined(entryV) && !isUndefined(entryW)) { + entryW.indegree++; + entryV.out.push(mappedEntries[e.w]); + } + }); + + var sourceSet = filter$1(mappedEntries, function (entry) { + // @ts-expect-error + return !entry.indegree; + }); + + return doResolveConflicts(sourceSet); +} + +function doResolveConflicts(sourceSet) { + var entries = []; + + function handleIn(vEntry) { + return function (uEntry) { + if (uEntry.merged) { + return; + } + if ( + isUndefined(uEntry.barycenter) || + isUndefined(vEntry.barycenter) || + uEntry.barycenter >= vEntry.barycenter + ) { + mergeEntries(vEntry, uEntry); + } + }; + } + + function handleOut(vEntry) { + return function (wEntry) { + wEntry['in'].push(vEntry); + if (--wEntry.indegree === 0) { + sourceSet.push(wEntry); + } + }; + } + + while (sourceSet.length) { + var entry = sourceSet.pop(); + entries.push(entry); + forEach(entry['in'].reverse(), handleIn(entry)); + forEach(entry.out, handleOut(entry)); + } + + return map( + filter$1(entries, function (entry) { + return !entry.merged; + }), + function (entry) { + return pick(entry, ['vs', 'i', 'barycenter', 'weight']); + } + ); +} + +function mergeEntries(target, source) { + var sum = 0; + var weight = 0; + + if (target.weight) { + sum += target.barycenter * target.weight; + weight += target.weight; + } + + if (source.weight) { + sum += source.barycenter * source.weight; + weight += source.weight; + } + + target.vs = source.vs.concat(target.vs); + target.barycenter = sum / weight; + target.weight = weight; + target.i = Math.min(source.i, target.i); + source.merged = true; +} + +function sort(entries, biasRight) { + var parts = partition(entries, function (entry) { + return has(entry, 'barycenter'); + }); + var sortable = parts.lhs, + unsortable = sortBy(parts.rhs, function (entry) { + return -entry.i; + }), + vs = [], + sum = 0, + weight = 0, + vsIndex = 0; + + sortable.sort(compareWithBias(!!biasRight)); + + vsIndex = consumeUnsortable(vs, unsortable, vsIndex); + + forEach(sortable, function (entry) { + vsIndex += entry.vs.length; + vs.push(entry.vs); + sum += entry.barycenter * entry.weight; + weight += entry.weight; + vsIndex = consumeUnsortable(vs, unsortable, vsIndex); + }); + + var result = { vs: flatten(vs) }; + if (weight) { + result.barycenter = sum / weight; + result.weight = weight; + } + return result; +} + +function consumeUnsortable(vs, unsortable, index) { + var last$1; + while (unsortable.length && (last$1 = last(unsortable)).i <= index) { + unsortable.pop(); + vs.push(last$1.vs); + index++; + } + return index; +} + +function compareWithBias(bias) { + return function (entryV, entryW) { + if (entryV.barycenter < entryW.barycenter) { + return -1; + } else if (entryV.barycenter > entryW.barycenter) { + return 1; + } + + return !bias ? entryV.i - entryW.i : entryW.i - entryV.i; + }; +} + +function sortSubgraph(g, v, cg, biasRight) { + var movable = g.children(v); + var node = g.node(v); + var bl = node ? node.borderLeft : undefined; + var br = node ? node.borderRight : undefined; + var subgraphs = {}; + + if (bl) { + movable = filter$1(movable, function (w) { + return w !== bl && w !== br; + }); + } + + var barycenters = barycenter(g, movable); + forEach(barycenters, function (entry) { + if (g.children(entry.v).length) { + var subgraphResult = sortSubgraph(g, entry.v, cg, biasRight); + subgraphs[entry.v] = subgraphResult; + if (has(subgraphResult, 'barycenter')) { + mergeBarycenters(entry, subgraphResult); + } + } + }); + + var entries = resolveConflicts(barycenters, cg); + expandSubgraphs(entries, subgraphs); + + var result = sort(entries, biasRight); + + if (bl) { + result.vs = flatten([bl, result.vs, br]); + if (g.predecessors(bl).length) { + var blPred = g.node(g.predecessors(bl)[0]), + brPred = g.node(g.predecessors(br)[0]); + if (!has(result, 'barycenter')) { + result.barycenter = 0; + result.weight = 0; + } + result.barycenter = + (result.barycenter * result.weight + blPred.order + brPred.order) / (result.weight + 2); + result.weight += 2; + } + } + + return result; +} + +function expandSubgraphs(entries, subgraphs) { + forEach(entries, function (entry) { + entry.vs = flatten( + entry.vs.map(function (v) { + if (subgraphs[v]) { + return subgraphs[v].vs; + } + return v; + }) + ); + }); +} + +function mergeBarycenters(target, other) { + if (!isUndefined(target.barycenter)) { + target.barycenter = + (target.barycenter * target.weight + other.barycenter * other.weight) / + (target.weight + other.weight); + target.weight += other.weight; + } else { + target.barycenter = other.barycenter; + target.weight = other.weight; + } +} + +/* + * Applies heuristics to minimize edge crossings in the graph and sets the best + * order solution as an order attribute on each node. + * + * Pre-conditions: + * + * 1. Graph must be DAG + * 2. Graph nodes must be objects with a "rank" attribute + * 3. Graph edges must have the "weight" attribute + * + * Post-conditions: + * + * 1. Graph nodes will have an "order" attribute based on the results of the + * algorithm. + */ +function order(g) { + var maxRank$1 = maxRank(g), + downLayerGraphs = buildLayerGraphs(g, range(1, maxRank$1 + 1), 'inEdges'), + upLayerGraphs = buildLayerGraphs(g, range(maxRank$1 - 1, -1, -1), 'outEdges'); + + var layering = initOrder(g); + assignOrder(g, layering); + + var bestCC = Number.POSITIVE_INFINITY, + best; + + for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) { + sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2); + + layering = buildLayerMatrix(g); + var cc = crossCount(g, layering); + if (cc < bestCC) { + lastBest = 0; + best = cloneDeep(layering); + bestCC = cc; + } + } + + assignOrder(g, best); +} + +function buildLayerGraphs(g, ranks, relationship) { + return map(ranks, function (rank) { + return buildLayerGraph(g, rank, relationship); + }); +} + +function sweepLayerGraphs(layerGraphs, biasRight) { + var cg = new Graph(); + forEach(layerGraphs, function (lg) { + var root = lg.graph().root; + var sorted = sortSubgraph(lg, root, cg, biasRight); + forEach(sorted.vs, function (v, i) { + lg.node(v).order = i; + }); + addSubgraphConstraints(lg, cg, sorted.vs); + }); +} + +function assignOrder(g, layering) { + forEach(layering, function (layer) { + forEach(layer, function (v, i) { + g.node(v).order = i; + }); + }); +} + +function parentDummyChains(g) { + var postorderNums = postorder(g); + + forEach(g.graph().dummyChains, function (v) { + var node = g.node(v); + var edgeObj = node.edgeObj; + var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w); + var path = pathData.path; + var lca = pathData.lca; + var pathIdx = 0; + var pathV = path[pathIdx]; + var ascending = true; + + while (v !== edgeObj.w) { + node = g.node(v); + + if (ascending) { + while ((pathV = path[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) { + pathIdx++; + } + + if (pathV === lca) { + ascending = false; + } + } + + if (!ascending) { + while ( + pathIdx < path.length - 1 && + g.node((pathV = path[pathIdx + 1])).minRank <= node.rank + ) { + pathIdx++; + } + pathV = path[pathIdx]; + } + + g.setParent(v, pathV); + v = g.successors(v)[0]; + } + }); +} + +// Find a path from v to w through the lowest common ancestor (LCA). Return the +// full path and the LCA. +function findPath(g, postorderNums, v, w) { + var vPath = []; + var wPath = []; + var low = Math.min(postorderNums[v].low, postorderNums[w].low); + var lim = Math.max(postorderNums[v].lim, postorderNums[w].lim); + var parent; + var lca; + + // Traverse up from v to find the LCA + parent = v; + do { + parent = g.parent(parent); + vPath.push(parent); + } while (parent && (postorderNums[parent].low > low || lim > postorderNums[parent].lim)); + lca = parent; + + // Traverse from w to LCA + parent = w; + while ((parent = g.parent(parent)) !== lca) { + wPath.push(parent); + } + + return { path: vPath.concat(wPath.reverse()), lca: lca }; +} + +function postorder(g) { + var result = {}; + var lim = 0; + + function dfs(v) { + var low = lim; + forEach(g.children(v), dfs); + result[v] = { low: low, lim: lim++ }; + } + forEach(g.children(), dfs); + + return result; +} + +/* + * Marks all edges in the graph with a type-1 conflict with the "type1Conflict" + * property. A type-1 conflict is one where a non-inner segment crosses an + * inner segment. An inner segment is an edge with both incident nodes marked + * with the "dummy" property. + * + * This algorithm scans layer by layer, starting with the second, for type-1 + * conflicts between the current layer and the previous layer. For each layer + * it scans the nodes from left to right until it reaches one that is incident + * on an inner segment. It then scans predecessors to determine if they have + * edges that cross that inner segment. At the end a final scan is done for all + * nodes on the current rank to see if they cross the last visited inner + * segment. + * + * This algorithm (safely) assumes that a dummy node will only be incident on a + * single node in the layers being scanned. + */ +function findType1Conflicts(g, layering) { + var conflicts = {}; + + function visitLayer(prevLayer, layer) { + var // last visited node in the previous layer that is incident on an inner + // segment. + k0 = 0, + // Tracks the last node in this layer scanned for crossings with a type-1 + // segment. + scanPos = 0, + prevLayerLength = prevLayer.length, + lastNode = last(layer); + + forEach(layer, function (v, i) { + var w = findOtherInnerSegmentNode(g, v), + k1 = w ? g.node(w).order : prevLayerLength; + + if (w || v === lastNode) { + forEach(layer.slice(scanPos, i + 1), function (scanNode) { + forEach(g.predecessors(scanNode), function (u) { + var uLabel = g.node(u), + uPos = uLabel.order; + if ((uPos < k0 || k1 < uPos) && !(uLabel.dummy && g.node(scanNode).dummy)) { + addConflict(conflicts, u, scanNode); + } + }); + }); + // @ts-expect-error + scanPos = i + 1; + k0 = k1; + } + }); + + return layer; + } + + reduce(layering, visitLayer); + return conflicts; +} + +function findType2Conflicts(g, layering) { + var conflicts = {}; + + function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) { + var v; + forEach(range(southPos, southEnd), function (i) { + v = south[i]; + if (g.node(v).dummy) { + forEach(g.predecessors(v), function (u) { + var uNode = g.node(u); + if (uNode.dummy && (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) { + addConflict(conflicts, u, v); + } + }); + } + }); + } + + function visitLayer(north, south) { + var prevNorthPos = -1, + nextNorthPos, + southPos = 0; + + forEach(south, function (v, southLookahead) { + if (g.node(v).dummy === 'border') { + var predecessors = g.predecessors(v); + if (predecessors.length) { + nextNorthPos = g.node(predecessors[0]).order; + scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos); + // @ts-expect-error + southPos = southLookahead; + prevNorthPos = nextNorthPos; + } + } + scan(south, southPos, south.length, nextNorthPos, north.length); + }); + + return south; + } + + reduce(layering, visitLayer); + return conflicts; +} + +function findOtherInnerSegmentNode(g, v) { + if (g.node(v).dummy) { + return find$1(g.predecessors(v), function (u) { + return g.node(u).dummy; + }); + } +} + +function addConflict(conflicts, v, w) { + if (v > w) { + var tmp = v; + v = w; + w = tmp; + } + + var conflictsV = conflicts[v]; + if (!conflictsV) { + conflicts[v] = conflictsV = {}; + } + conflictsV[w] = true; +} + +function hasConflict(conflicts, v, w) { + if (v > w) { + var tmp = v; + v = w; + w = tmp; + } + return has(conflicts[v], w); +} + +/* + * Try to align nodes into vertical "blocks" where possible. This algorithm + * attempts to align a node with one of its median neighbors. If the edge + * connecting a neighbor is a type-1 conflict then we ignore that possibility. + * If a previous node has already formed a block with a node after the node + * we're trying to form a block with, we also ignore that possibility - our + * blocks would be split in that scenario. + */ +function verticalAlignment(g, layering, conflicts, neighborFn) { + var root = {}, + align = {}, + pos = {}; + + // We cache the position here based on the layering because the graph and + // layering may be out of sync. The layering matrix is manipulated to + // generate different extreme alignments. + forEach(layering, function (layer) { + forEach(layer, function (v, order) { + root[v] = v; + align[v] = v; + pos[v] = order; + }); + }); + + forEach(layering, function (layer) { + var prevIdx = -1; + forEach(layer, function (v) { + var ws = neighborFn(v); + if (ws.length) { + ws = sortBy(ws, function (w) { + return pos[w]; + }); + var mp = (ws.length - 1) / 2; + for (var i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) { + var w = ws[i]; + if (align[v] === v && prevIdx < pos[w] && !hasConflict(conflicts, v, w)) { + align[w] = v; + align[v] = root[v] = root[w]; + prevIdx = pos[w]; + } + } + } + }); + }); + + return { root: root, align: align }; +} + +function horizontalCompaction(g, layering, root, align, reverseSep) { + // This portion of the algorithm differs from BK due to a number of problems. + // Instead of their algorithm we construct a new block graph and do two + // sweeps. The first sweep places blocks with the smallest possible + // coordinates. The second sweep removes unused space by moving blocks to the + // greatest coordinates without violating separation. + var xs = {}, + blockG = buildBlockGraph(g, layering, root, reverseSep), + borderType = reverseSep ? 'borderLeft' : 'borderRight'; + + function iterate(setXsFunc, nextNodesFunc) { + var stack = blockG.nodes(); + var elem = stack.pop(); + var visited = {}; + while (elem) { + if (visited[elem]) { + setXsFunc(elem); + } else { + visited[elem] = true; + stack.push(elem); + stack = stack.concat(nextNodesFunc(elem)); + } + + elem = stack.pop(); + } + } + + // First pass, assign smallest coordinates + function pass1(elem) { + xs[elem] = blockG.inEdges(elem).reduce(function (acc, e) { + return Math.max(acc, xs[e.v] + blockG.edge(e)); + }, 0); + } + + // Second pass, assign greatest coordinates + function pass2(elem) { + var min = blockG.outEdges(elem).reduce(function (acc, e) { + return Math.min(acc, xs[e.w] - blockG.edge(e)); + }, Number.POSITIVE_INFINITY); + + var node = g.node(elem); + if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) { + xs[elem] = Math.max(xs[elem], min); + } + } + + iterate(pass1, blockG.predecessors.bind(blockG)); + iterate(pass2, blockG.successors.bind(blockG)); + + // Assign x coordinates to all nodes + forEach(align, function (v) { + xs[v] = xs[root[v]]; + }); + + return xs; +} + +function buildBlockGraph(g, layering, root, reverseSep) { + var blockGraph = new Graph(), + graphLabel = g.graph(), + sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep); + + forEach(layering, function (layer) { + var u; + forEach(layer, function (v) { + var vRoot = root[v]; + blockGraph.setNode(vRoot); + if (u) { + var uRoot = root[u], + prevMax = blockGraph.edge(uRoot, vRoot); + blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0)); + } + u = v; + }); + }); + + return blockGraph; +} + +/* + * Returns the alignment that has the smallest width of the given alignments. + */ +function findSmallestWidthAlignment(g, xss) { + return minBy(values(xss), function (xs) { + var max = Number.NEGATIVE_INFINITY; + var min = Number.POSITIVE_INFINITY; + + forIn(xs, function (x, v) { + var halfWidth = width(g, v) / 2; + + max = Math.max(x + halfWidth, max); + min = Math.min(x - halfWidth, min); + }); + + return max - min; + }); +} + +/* + * Align the coordinates of each of the layout alignments such that + * left-biased alignments have their minimum coordinate at the same point as + * the minimum coordinate of the smallest width alignment and right-biased + * alignments have their maximum coordinate at the same point as the maximum + * coordinate of the smallest width alignment. + */ +function alignCoordinates(xss, alignTo) { + var alignToVals = values(alignTo), + alignToMin = min$2(alignToVals), + alignToMax = max$2(alignToVals); + + forEach(['u', 'd'], function (vert) { + forEach(['l', 'r'], function (horiz) { + var alignment = vert + horiz, + xs = xss[alignment], + delta; + if (xs === alignTo) return; + + var xsVals = values(xs); + delta = horiz === 'l' ? alignToMin - min$2(xsVals) : alignToMax - max$2(xsVals); + + if (delta) { + xss[alignment] = mapValues(xs, function (x) { + return x + delta; + }); + } + }); + }); +} + +function balance(xss, align) { + return mapValues(xss.ul, function (ignore, v) { + if (align) { + return xss[align.toLowerCase()][v]; + } else { + var xs = sortBy(map(xss, v)); + return (xs[1] + xs[2]) / 2; + } + }); +} + +function positionX(g) { + var layering = buildLayerMatrix(g); + var conflicts = merge$2(findType1Conflicts(g, layering), findType2Conflicts(g, layering)); + + var xss = {}; + var adjustedLayering; + forEach(['u', 'd'], function (vert) { + adjustedLayering = vert === 'u' ? layering : values(layering).reverse(); + forEach(['l', 'r'], function (horiz) { + if (horiz === 'r') { + adjustedLayering = map(adjustedLayering, function (inner) { + return values(inner).reverse(); + }); + } + + var neighborFn = (vert === 'u' ? g.predecessors : g.successors).bind(g); + var align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn); + var xs = horizontalCompaction(g, adjustedLayering, align.root, align.align, horiz === 'r'); + if (horiz === 'r') { + xs = mapValues(xs, function (x) { + return -x; + }); + } + xss[vert + horiz] = xs; + }); + }); + + var smallestWidth = findSmallestWidthAlignment(g, xss); + alignCoordinates(xss, smallestWidth); + return balance(xss, g.graph().align); +} + +function sep(nodeSep, edgeSep, reverseSep) { + return function (g, v, w) { + var vLabel = g.node(v); + var wLabel = g.node(w); + var sum = 0; + var delta; + + sum += vLabel.width / 2; + if (has(vLabel, 'labelpos')) { + switch (vLabel.labelpos.toLowerCase()) { + case 'l': + delta = -vLabel.width / 2; + break; + case 'r': + delta = vLabel.width / 2; + break; + } + } + if (delta) { + sum += reverseSep ? delta : -delta; + } + delta = 0; + + sum += (vLabel.dummy ? edgeSep : nodeSep) / 2; + sum += (wLabel.dummy ? edgeSep : nodeSep) / 2; + + sum += wLabel.width / 2; + if (has(wLabel, 'labelpos')) { + switch (wLabel.labelpos.toLowerCase()) { + case 'l': + delta = wLabel.width / 2; + break; + case 'r': + delta = -wLabel.width / 2; + break; + } + } + if (delta) { + sum += reverseSep ? delta : -delta; + } + delta = 0; + + return sum; + }; +} + +function width(g, v) { + return g.node(v).width; +} + +function position$2(g) { + g = asNonCompoundGraph(g); + + positionY(g); + forOwn(positionX(g), function (x, v) { + g.node(v).x = x; + }); +} + +function positionY(g) { + var layering = buildLayerMatrix(g); + var rankSep = g.graph().ranksep; + var prevY = 0; + forEach(layering, function (layer) { + var maxHeight = max$2( + map(layer, function (v) { + return g.node(v).height; + }) + ); + forEach(layer, function (v) { + g.node(v).y = prevY + maxHeight / 2; + }); + prevY += maxHeight + rankSep; + }); +} + +function layout$2(g, opts) { + var time = notime; + time('layout', function () { + var layoutGraph = time(' buildLayoutGraph', function () { + return buildLayoutGraph(g); + }); + time(' runLayout', function () { + runLayout(layoutGraph, time); + }); + time(' updateInputGraph', function () { + updateInputGraph(g, layoutGraph); + }); + }); +} + +function runLayout(g, time) { + time(' makeSpaceForEdgeLabels', function () { + makeSpaceForEdgeLabels(g); + }); + time(' removeSelfEdges', function () { + removeSelfEdges(g); + }); + time(' acyclic', function () { + run$2(g); + }); + time(' nestingGraph.run', function () { + run(g); + }); + time(' rank', function () { + rank(asNonCompoundGraph(g)); + }); + time(' injectEdgeLabelProxies', function () { + injectEdgeLabelProxies(g); + }); + time(' removeEmptyRanks', function () { + removeEmptyRanks(g); + }); + time(' nestingGraph.cleanup', function () { + cleanup(g); + }); + time(' normalizeRanks', function () { + normalizeRanks(g); + }); + time(' assignRankMinMax', function () { + assignRankMinMax(g); + }); + time(' removeEdgeLabelProxies', function () { + removeEdgeLabelProxies(g); + }); + time(' normalize.run', function () { + run$1(g); + }); + time(' parentDummyChains', function () { + parentDummyChains(g); + }); + time(' addBorderSegments', function () { + addBorderSegments(g); + }); + time(' order', function () { + order(g); + }); + time(' insertSelfEdges', function () { + insertSelfEdges(g); + }); + time(' adjustCoordinateSystem', function () { + adjust(g); + }); + time(' position', function () { + position$2(g); + }); + time(' positionSelfEdges', function () { + positionSelfEdges(g); + }); + time(' removeBorderNodes', function () { + removeBorderNodes(g); + }); + time(' normalize.undo', function () { + undo(g); + }); + time(' fixupEdgeLabelCoords', function () { + fixupEdgeLabelCoords(g); + }); + time(' undoCoordinateSystem', function () { + undo$1(g); + }); + time(' translateGraph', function () { + translateGraph(g); + }); + time(' assignNodeIntersects', function () { + assignNodeIntersects(g); + }); + time(' reversePoints', function () { + reversePointsForReversedEdges(g); + }); + time(' acyclic.undo', function () { + undo$2(g); + }); +} + +/* + * Copies final layout information from the layout graph back to the input + * graph. This process only copies whitelisted attributes from the layout graph + * to the input graph, so it serves as a good place to determine what + * attributes can influence layout. + */ +function updateInputGraph(inputGraph, layoutGraph) { + forEach(inputGraph.nodes(), function (v) { + var inputLabel = inputGraph.node(v); + var layoutLabel = layoutGraph.node(v); + + if (inputLabel) { + inputLabel.x = layoutLabel.x; + inputLabel.y = layoutLabel.y; + + if (layoutGraph.children(v).length) { + inputLabel.width = layoutLabel.width; + inputLabel.height = layoutLabel.height; + } + } + }); + + forEach(inputGraph.edges(), function (e) { + var inputLabel = inputGraph.edge(e); + var layoutLabel = layoutGraph.edge(e); + + inputLabel.points = layoutLabel.points; + if (has(layoutLabel, 'x')) { + inputLabel.x = layoutLabel.x; + inputLabel.y = layoutLabel.y; + } + }); + + inputGraph.graph().width = layoutGraph.graph().width; + inputGraph.graph().height = layoutGraph.graph().height; +} + +var graphNumAttrs = ['nodesep', 'edgesep', 'ranksep', 'marginx', 'marginy']; +var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: 'tb' }; +var graphAttrs = ['acyclicer', 'ranker', 'rankdir', 'align']; +var nodeNumAttrs = ['width', 'height']; +var nodeDefaults = { width: 0, height: 0 }; +var edgeNumAttrs = ['minlen', 'weight', 'width', 'height', 'labeloffset']; +var edgeDefaults = { + minlen: 1, + weight: 1, + width: 0, + height: 0, + labeloffset: 10, + labelpos: 'r', +}; +var edgeAttrs = ['labelpos']; + +/* + * Constructs a new graph from the input graph, which can be used for layout. + * This process copies only whitelisted attributes from the input graph to the + * layout graph. Thus this function serves as a good place to determine what + * attributes can influence layout. + */ +function buildLayoutGraph(inputGraph) { + var g = new Graph({ multigraph: true, compound: true }); + var graph = canonicalize(inputGraph.graph()); + + g.setGraph( + merge$2({}, graphDefaults, selectNumberAttrs(graph, graphNumAttrs), pick(graph, graphAttrs)) + ); + + forEach(inputGraph.nodes(), function (v) { + var node = canonicalize(inputGraph.node(v)); + g.setNode(v, defaults$h(selectNumberAttrs(node, nodeNumAttrs), nodeDefaults)); + g.setParent(v, inputGraph.parent(v)); + }); + + forEach(inputGraph.edges(), function (e) { + var edge = canonicalize(inputGraph.edge(e)); + g.setEdge( + e, + merge$2({}, edgeDefaults, selectNumberAttrs(edge, edgeNumAttrs), pick(edge, edgeAttrs)) + ); + }); + + return g; +} + +/* + * This idea comes from the Gansner paper: to account for edge labels in our + * layout we split each rank in half by doubling minlen and halving ranksep. + * Then we can place labels at these mid-points between nodes. + * + * We also add some minimal padding to the width to push the label for the edge + * away from the edge itself a bit. + */ +function makeSpaceForEdgeLabels(g) { + var graph = g.graph(); + graph.ranksep /= 2; + forEach(g.edges(), function (e) { + var edge = g.edge(e); + edge.minlen *= 2; + if (edge.labelpos.toLowerCase() !== 'c') { + if (graph.rankdir === 'TB' || graph.rankdir === 'BT') { + edge.width += edge.labeloffset; + } else { + edge.height += edge.labeloffset; + } + } + }); +} + +/* + * Creates temporary dummy nodes that capture the rank in which each edge's + * label is going to, if it has one of non-zero width and height. We do this + * so that we can safely remove empty ranks while preserving balance for the + * label's position. + */ +function injectEdgeLabelProxies(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.width && edge.height) { + var v = g.node(e.v); + var w = g.node(e.w); + var label = { rank: (w.rank - v.rank) / 2 + v.rank, e: e }; + addDummyNode(g, 'edge-proxy', label, '_ep'); + } + }); +} + +function assignRankMinMax(g) { + var maxRank = 0; + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.borderTop) { + node.minRank = g.node(node.borderTop).rank; + node.maxRank = g.node(node.borderBottom).rank; + // @ts-expect-error + maxRank = max$2(maxRank, node.maxRank); + } + }); + g.graph().maxRank = maxRank; +} + +function removeEdgeLabelProxies(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.dummy === 'edge-proxy') { + g.edge(node.e).labelRank = node.rank; + g.removeNode(v); + } + }); +} + +function translateGraph(g) { + var minX = Number.POSITIVE_INFINITY; + var maxX = 0; + var minY = Number.POSITIVE_INFINITY; + var maxY = 0; + var graphLabel = g.graph(); + var marginX = graphLabel.marginx || 0; + var marginY = graphLabel.marginy || 0; + + function getExtremes(attrs) { + var x = attrs.x; + var y = attrs.y; + var w = attrs.width; + var h = attrs.height; + minX = Math.min(minX, x - w / 2); + maxX = Math.max(maxX, x + w / 2); + minY = Math.min(minY, y - h / 2); + maxY = Math.max(maxY, y + h / 2); + } + + forEach(g.nodes(), function (v) { + getExtremes(g.node(v)); + }); + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (has(edge, 'x')) { + getExtremes(edge); + } + }); + + minX -= marginX; + minY -= marginY; + + forEach(g.nodes(), function (v) { + var node = g.node(v); + node.x -= minX; + node.y -= minY; + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, function (p) { + p.x -= minX; + p.y -= minY; + }); + if (has(edge, 'x')) { + edge.x -= minX; + } + if (has(edge, 'y')) { + edge.y -= minY; + } + }); + + graphLabel.width = maxX - minX + marginX; + graphLabel.height = maxY - minY + marginY; +} + +function assignNodeIntersects(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + var nodeV = g.node(e.v); + var nodeW = g.node(e.w); + var p1, p2; + if (!edge.points) { + edge.points = []; + p1 = nodeW; + p2 = nodeV; + } else { + p1 = edge.points[0]; + p2 = edge.points[edge.points.length - 1]; + } + edge.points.unshift(intersectRect$3(nodeV, p1)); + edge.points.push(intersectRect$3(nodeW, p2)); + }); +} + +function fixupEdgeLabelCoords(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (has(edge, 'x')) { + if (edge.labelpos === 'l' || edge.labelpos === 'r') { + edge.width -= edge.labeloffset; + } + switch (edge.labelpos) { + case 'l': + edge.x -= edge.width / 2 + edge.labeloffset; + break; + case 'r': + edge.x += edge.width / 2 + edge.labeloffset; + break; + } + } + }); +} + +function reversePointsForReversedEdges(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.reversed) { + edge.points.reverse(); + } + }); +} + +function removeBorderNodes(g) { + forEach(g.nodes(), function (v) { + if (g.children(v).length) { + var node = g.node(v); + var t = g.node(node.borderTop); + var b = g.node(node.borderBottom); + var l = g.node(last(node.borderLeft)); + var r = g.node(last(node.borderRight)); + + node.width = Math.abs(r.x - l.x); + node.height = Math.abs(b.y - t.y); + node.x = l.x + node.width / 2; + node.y = t.y + node.height / 2; + } + }); + + forEach(g.nodes(), function (v) { + if (g.node(v).dummy === 'border') { + g.removeNode(v); + } + }); +} + +function removeSelfEdges(g) { + forEach(g.edges(), function (e) { + if (e.v === e.w) { + var node = g.node(e.v); + if (!node.selfEdges) { + node.selfEdges = []; + } + node.selfEdges.push({ e: e, label: g.edge(e) }); + g.removeEdge(e); + } + }); +} + +function insertSelfEdges(g) { + var layers = buildLayerMatrix(g); + forEach(layers, function (layer) { + var orderShift = 0; + forEach(layer, function (v, i) { + var node = g.node(v); + node.order = i + orderShift; + forEach(node.selfEdges, function (selfEdge) { + addDummyNode( + g, + 'selfedge', + { + width: selfEdge.label.width, + height: selfEdge.label.height, + rank: node.rank, + order: i + ++orderShift, + e: selfEdge.e, + label: selfEdge.label, + }, + '_se' + ); + }); + delete node.selfEdges; + }); + }); +} + +function positionSelfEdges(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.dummy === 'selfedge') { + var selfNode = g.node(node.e.v); + var x = selfNode.x + selfNode.width / 2; + var y = selfNode.y; + var dx = node.x - x; + var dy = selfNode.height / 2; + g.setEdge(node.e, node.label); + g.removeNode(v); + node.label.points = [ + { x: x + (2 * dx) / 3, y: y - dy }, + { x: x + (5 * dx) / 6, y: y - dy }, + { x: x + dx, y: y }, + { x: x + (5 * dx) / 6, y: y + dy }, + { x: x + (2 * dx) / 3, y: y + dy }, + ]; + node.label.x = node.x; + node.label.y = node.y; + } + }); +} + +function selectNumberAttrs(obj, attrs) { + return mapValues(pick(obj, attrs), Number); +} + +function canonicalize(attrs) { + var newAttrs = {}; + forEach(attrs, function (v, k) { + newAttrs[k.toLowerCase()] = v; + }); + return newAttrs; +} + +/* + * Returns true if the specified node in the graph is a subgraph node. A + * subgraph node is one that contains other nodes. + */ +function isSubgraph(g, v) { + return !!g.children(v).length; +} + +function edgeToId(e) { + return escapeId(e.v) + ':' + escapeId(e.w) + ':' + escapeId(e.name); +} + +var ID_DELIM = /:/g; +function escapeId(str) { + return str ? String(str).replace(ID_DELIM, '\\:') : ''; +} + +function applyStyle$2(dom, styleFn) { + if (styleFn) { + dom.attr('style', styleFn); + } +} + +function applyClass(dom, classFn, otherClasses) { + if (classFn) { + dom.attr('class', classFn).attr('class', otherClasses + ' ' + dom.attr('class')); + } +} + +function applyTransition(selection, g) { + var graph = g.graph(); + + if (isPlainObject(graph)) { + var transition = graph.transition; + if (isFunction$1(transition)) { + return transition(selection); + } + } + + return selection; +} + +var arrows = { + normal, + vee, + undirected, +}; + +function setArrows(value) { + arrows = value; +} + +function normal(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 0 L 10 5 L 0 10 z') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle$2(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function vee(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 0 L 10 5 L 0 10 L 4 5 z') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle$2(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function undirected(parent, id, edge, type) { + var marker = parent + .append('marker') + .attr('id', id) + .attr('viewBox', '0 0 10 10') + .attr('refX', 9) + .attr('refY', 5) + .attr('markerUnits', 'strokeWidth') + .attr('markerWidth', 8) + .attr('markerHeight', 6) + .attr('orient', 'auto'); + + var path = marker + .append('path') + .attr('d', 'M 0 5 L 10 5') + .style('stroke-width', 1) + .style('stroke-dasharray', '1,0'); + applyStyle$2(path, edge[type + 'Style']); + if (edge[type + 'Class']) { + path.attr('class', edge[type + 'Class']); + } +} + +function addHtmlLabel$1(root, node) { + var fo = root.append('foreignObject').attr('width', '100000'); + + var div = fo.append('xhtml:div'); + div.attr('xmlns', 'http://www.w3.org/1999/xhtml'); + + var label = node.label; + switch (typeof label) { + case 'function': + div.insert(label); + break; + case 'object': + // Currently we assume this is a DOM object. + div.insert(function () { + return label; + }); + break; + default: + div.html(label); + } + + applyStyle$2(div, node.labelStyle); + div.style('display', 'inline-block'); + // Fix for firefox + div.style('white-space', 'nowrap'); + + var client = div.node().getBoundingClientRect(); + fo.attr('width', client.width).attr('height', client.height); + + return fo; +} + +function addSVGLabel(root, node) { + var domNode = root; + + domNode.node().appendChild(node.label); + + applyStyle$2(domNode, node.labelStyle); + + return domNode; +} + +/* + * Attaches a text label to the specified root. Handles escape sequences. + */ +function addTextLabel(root, node) { + var domNode = root.append('text'); + + var lines = processEscapeSequences(node.label).split('\n'); + for (var i = 0; i < lines.length; i++) { + domNode + .append('tspan') + .attr('xml:space', 'preserve') + .attr('dy', '1em') + .attr('x', '1') + .text(lines[i]); + } + + applyStyle$2(domNode, node.labelStyle); + + return domNode; +} + +function processEscapeSequences(text) { + var newText = ''; + var escaped = false; + var ch; + for (var i = 0; i < text.length; ++i) { + ch = text[i]; + if (escaped) { + switch (ch) { + case 'n': + newText += '\n'; + break; + default: + newText += ch; + } + escaped = false; + } else if (ch === '\\') { + escaped = true; + } else { + newText += ch; + } + } + return newText; +} + +function addLabel(root, node, location) { + var label = node.label; + var labelSvg = root.append('g'); + + // Allow the label to be a string, a function that returns a DOM element, or + // a DOM element itself. + if (node.labelType === 'svg') { + addSVGLabel(labelSvg, node); + } else if (typeof label !== 'string' || node.labelType === 'html') { + addHtmlLabel$1(labelSvg, node); + } else { + addTextLabel(labelSvg, node); + } + + var labelBBox = labelSvg.node().getBBox(); + var y; + switch (location) { + case 'top': + y = -node.height / 2; + break; + case 'bottom': + y = node.height / 2 - labelBBox.height; + break; + default: + y = -labelBBox.height / 2; + } + labelSvg.attr('transform', 'translate(' + -labelBBox.width / 2 + ',' + y + ')'); + + return labelSvg; +} + +var createClusters = function (selection, g) { + var clusters = g.nodes().filter(function (v) { + return isSubgraph(g, v); + }); + var svgClusters = selection.selectAll('g.cluster').data(clusters, function (v) { + return v; + }); + + applyTransition(svgClusters.exit(), g).style('opacity', 0).remove(); + + var enterSelection = svgClusters + .enter() + .append('g') + .attr('class', 'cluster') + .attr('id', function (v) { + var node = g.node(v); + return node.id; + }) + .style('opacity', 0) + .each(function (v) { + var node = g.node(v); + var thisGroup = select(this); + select(this).append('rect'); + var labelGroup = thisGroup.append('g').attr('class', 'label'); + addLabel(labelGroup, node, node.clusterLabelPos); + }); + + svgClusters = svgClusters.merge(enterSelection); + + svgClusters = applyTransition(svgClusters, g).style('opacity', 1); + + svgClusters.selectAll('rect').each(function (c) { + var node = g.node(c); + var domCluster = select(this); + applyStyle$2(domCluster, node.style); + }); + + return svgClusters; +}; + +function setCreateClusters(value) { + createClusters = value; +} + +let createEdgeLabels = function (selection, g) { + var svgEdgeLabels = selection + .selectAll('g.edgeLabel') + .data(g.edges(), function (e) { + return edgeToId(e); + }) + .classed('update', true); + + svgEdgeLabels.exit().remove(); + svgEdgeLabels.enter().append('g').classed('edgeLabel', true).style('opacity', 0); + + svgEdgeLabels = selection.selectAll('g.edgeLabel'); + + svgEdgeLabels.each(function (e) { + var root = select(this); + root.select('.label').remove(); + var edge = g.edge(e); + var label = addLabel(root, g.edge(e), 0).classed('label', true); + var bbox = label.node().getBBox(); + + if (edge.labelId) { + label.attr('id', edge.labelId); + } + if (!has(edge, 'width')) { + edge.width = bbox.width; + } + if (!has(edge, 'height')) { + edge.height = bbox.height; + } + }); + + var exitSelection; + + if (svgEdgeLabels.exit) { + exitSelection = svgEdgeLabels.exit(); + } else { + exitSelection = svgEdgeLabels.selectAll(null); // empty selection + } + + applyTransition(exitSelection, g).style('opacity', 0).remove(); + + return svgEdgeLabels; +}; + +function setCreateEdgeLabels(value) { + createEdgeLabels = value; +} + +function intersectNode$1(node, point) { + return node.intersect(point); +} + +var createEdgePaths = function (selection, g, arrows) { + var previousPaths = selection + .selectAll('g.edgePath') + .data(g.edges(), function (e) { + return edgeToId(e); + }) + .classed('update', true); + + var newPaths = enter(previousPaths, g); + exit$1(previousPaths, g); + + var svgPaths = previousPaths.merge !== undefined ? previousPaths.merge(newPaths) : previousPaths; + applyTransition(svgPaths, g).style('opacity', 1); + + // Save DOM element in the path group, and set ID and class + svgPaths.each(function (e) { + var domEdge = select(this); + var edge = g.edge(e); + edge.elem = this; + + if (edge.id) { + domEdge.attr('id', edge.id); + } + + applyClass( + domEdge, + edge['class'], + (domEdge.classed('update') ? 'update ' : '') + 'edgePath' + ); + }); + + svgPaths.selectAll('path.path').each(function (e) { + var edge = g.edge(e); + edge.arrowheadId = uniqueId('arrowhead'); + + var domEdge = select(this) + .attr('marker-end', function () { + return 'url(' + makeFragmentRef(location.href, edge.arrowheadId) + ')'; + }) + .style('fill', 'none'); + + applyTransition(domEdge, g).attr('d', function (e) { + return calcPoints(g, e); + }); + + applyStyle$2(domEdge, edge.style); + }); + + svgPaths.selectAll('defs *').remove(); + svgPaths.selectAll('defs').each(function (e) { + var edge = g.edge(e); + var arrowhead = arrows[edge.arrowhead]; + arrowhead(select(this), edge.arrowheadId, edge, 'arrowhead'); + }); + + return svgPaths; +}; + +function setCreateEdgePaths(value) { + createEdgePaths = value; +} + +function makeFragmentRef(url, fragmentId) { + var baseUrl = url.split('#')[0]; + return baseUrl + '#' + fragmentId; +} + +function calcPoints(g, e) { + var edge = g.edge(e); + var tail = g.node(e.v); + var head = g.node(e.w); + var points = edge.points.slice(1, edge.points.length - 1); + points.unshift(intersectNode$1(tail, points[0])); + points.push(intersectNode$1(head, points[points.length - 1])); + + return createLine(edge, points); +} + +function createLine(edge, points) { + // @ts-expect-error + var line = (line$1 || svg$2.line)() + .x(function (d) { + return d.x; + }) + .y(function (d) { + return d.y; + }); + + (line.curve || line.interpolate)(edge.curve); + + return line(points); +} + +function getCoords(elem) { + var bbox = elem.getBBox(); + var matrix = elem.ownerSVGElement + .getScreenCTM() + .inverse() + .multiply(elem.getScreenCTM()) + .translate(bbox.width / 2, bbox.height / 2); + return { x: matrix.e, y: matrix.f }; +} + +function enter(svgPaths, g) { + var svgPathsEnter = svgPaths.enter().append('g').attr('class', 'edgePath').style('opacity', 0); + svgPathsEnter + .append('path') + .attr('class', 'path') + .attr('d', function (e) { + var edge = g.edge(e); + var sourceElem = g.node(e.v).elem; + var points = range(edge.points.length).map(function () { + return getCoords(sourceElem); + }); + return createLine(edge, points); + }); + svgPathsEnter.append('defs'); + return svgPathsEnter; +} + +function exit$1(svgPaths, g) { + var svgPathExit = svgPaths.exit(); + applyTransition(svgPathExit, g).style('opacity', 0).remove(); +} + +var createNodes = function (selection, g, shapes) { + var simpleNodes = g.nodes().filter(function (v) { + return !isSubgraph(g, v); + }); + var svgNodes = selection + .selectAll('g.node') + .data(simpleNodes, function (v) { + return v; + }) + .classed('update', true); + + svgNodes.exit().remove(); + + svgNodes.enter().append('g').attr('class', 'node').style('opacity', 0); + + svgNodes = selection.selectAll('g.node'); + + svgNodes.each(function (v) { + var node = g.node(v); + var thisGroup = select(this); + applyClass( + thisGroup, + node['class'], + (thisGroup.classed('update') ? 'update ' : '') + 'node' + ); + + thisGroup.select('g.label').remove(); + var labelGroup = thisGroup.append('g').attr('class', 'label'); + var labelDom = addLabel(labelGroup, node); + var shape = shapes[node.shape]; + var bbox = pick(labelDom.node().getBBox(), 'width', 'height'); + + node.elem = this; + + if (node.id) { + thisGroup.attr('id', node.id); + } + if (node.labelId) { + labelGroup.attr('id', node.labelId); + } + + if (has(node, 'width')) { + bbox.width = node.width; + } + if (has(node, 'height')) { + bbox.height = node.height; + } + + bbox.width += node.paddingLeft + node.paddingRight; + bbox.height += node.paddingTop + node.paddingBottom; + labelGroup.attr( + 'transform', + 'translate(' + + (node.paddingLeft - node.paddingRight) / 2 + + ',' + + (node.paddingTop - node.paddingBottom) / 2 + + ')' + ); + + var root = select(this); + root.select('.label-container').remove(); + var shapeSvg = shape(root, bbox, node).classed('label-container', true); + applyStyle$2(shapeSvg, node.style); + + var shapeBBox = shapeSvg.node().getBBox(); + node.width = shapeBBox.width; + node.height = shapeBBox.height; + }); + + var exitSelection; + + if (svgNodes.exit) { + exitSelection = svgNodes.exit(); + } else { + exitSelection = svgNodes.selectAll(null); // empty selection + } + + applyTransition(exitSelection, g).style('opacity', 0).remove(); + + return svgNodes; +}; + +function setCreateNodes(value) { + createNodes = value; +} + +function positionClusters(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(v) { + var node = g.node(v); + return 'translate(' + node.x + ',' + node.y + ')'; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); + + applyTransition(created.selectAll('rect'), g) + .attr('width', function (v) { + return g.node(v).width; + }) + .attr('height', function (v) { + return g.node(v).height; + }) + .attr('x', function (v) { + var node = g.node(v); + return -node.width / 2; + }) + .attr('y', function (v) { + var node = g.node(v); + return -node.height / 2; + }); +} + +function positionEdgeLabels(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(e) { + var edge = g.edge(e); + return has(edge, 'x') ? 'translate(' + edge.x + ',' + edge.y + ')' : ''; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); +} + +function positionNodes$1(selection, g) { + var created = selection.filter(function () { + return !select(this).classed('update'); + }); + + function translate(v) { + var node = g.node(v); + return 'translate(' + node.x + ',' + node.y + ')'; + } + + created.attr('transform', translate); + + applyTransition(selection, g).style('opacity', 1).attr('transform', translate); +} + +function intersectEllipse$1(node, rx, ry, point) { + // Formulae from: http://mathworld.wolfram.com/Ellipse-LineIntersection.html + + var cx = node.x; + var cy = node.y; + + var px = cx - point.x; + var py = cy - point.y; + + var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px); + + var dx = Math.abs((rx * ry * px) / det); + if (point.x < cx) { + dx = -dx; + } + var dy = Math.abs((rx * ry * py) / det); + if (point.y < cy) { + dy = -dy; + } + + return { x: cx + dx, y: cy + dy }; +} + +function intersectCircle$1(node, rx, point) { + return intersectEllipse$1(node, rx, rx, point); +} + +/* + * Returns the point at which two lines, p and q, intersect or returns + * undefined if they do not intersect. + */ +function intersectLine$1(p1, p2, q1, q2) { + // Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994, + // p7 and p473. + + var a1, a2, b1, b2, c1, c2; + var r1, r2, r3, r4; + var denom, offset, num; + var x, y; + + // Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x + + // b1 y + c1 = 0. + a1 = p2.y - p1.y; + b1 = p1.x - p2.x; + c1 = p2.x * p1.y - p1.x * p2.y; + + // Compute r3 and r4. + r3 = a1 * q1.x + b1 * q1.y + c1; + r4 = a1 * q2.x + b1 * q2.y + c1; + + // Check signs of r3 and r4. If both point 3 and point 4 lie on + // same side of line 1, the line segments do not intersect. + if (r3 !== 0 && r4 !== 0 && sameSign$1(r3, r4)) { + return /*DONT_INTERSECT*/; + } + + // Compute a2, b2, c2 where line joining points 3 and 4 is G(x,y) = a2 x + b2 y + c2 = 0 + a2 = q2.y - q1.y; + b2 = q1.x - q2.x; + c2 = q2.x * q1.y - q1.x * q2.y; + + // Compute r1 and r2 + r1 = a2 * p1.x + b2 * p1.y + c2; + r2 = a2 * p2.x + b2 * p2.y + c2; + + // Check signs of r1 and r2. If both point 1 and point 2 lie + // on same side of second line segment, the line segments do + // not intersect. + if (r1 !== 0 && r2 !== 0 && sameSign$1(r1, r2)) { + return /*DONT_INTERSECT*/; + } + + // Line segments intersect: compute intersection point. + denom = a1 * b2 - a2 * b1; + if (denom === 0) { + return /*COLLINEAR*/; + } + + offset = Math.abs(denom / 2); + + // The denom/2 is to get rounding instead of truncating. It + // is added or subtracted to the numerator, depending upon the + // sign of the numerator. + num = b1 * c2 - b2 * c1; + x = num < 0 ? (num - offset) / denom : (num + offset) / denom; + + num = a2 * c1 - a1 * c2; + y = num < 0 ? (num - offset) / denom : (num + offset) / denom; + + return { x: x, y: y }; +} + +function sameSign$1(r1, r2) { + return r1 * r2 > 0; +} + +/* + * Returns the point ({x, y}) at which the point argument intersects with the + * node argument assuming that it has the shape specified by polygon. + */ +function intersectPolygon$1(node, polyPoints, point) { + var x1 = node.x; + var y1 = node.y; + + var intersections = []; + + var minX = Number.POSITIVE_INFINITY; + var minY = Number.POSITIVE_INFINITY; + polyPoints.forEach(function (entry) { + minX = Math.min(minX, entry.x); + minY = Math.min(minY, entry.y); + }); + + var left = x1 - node.width / 2 - minX; + var top = y1 - node.height / 2 - minY; + + for (var i = 0; i < polyPoints.length; i++) { + var p1 = polyPoints[i]; + var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0]; + var intersect = intersectLine$1( + node, + point, + { x: left + p1.x, y: top + p1.y }, + { x: left + p2.x, y: top + p2.y } + ); + if (intersect) { + intersections.push(intersect); + } + } + + if (!intersections.length) { + console.log('NO INTERSECTION FOUND, RETURN NODE CENTER', node); + return node; + } + + if (intersections.length > 1) { + // More intersections, find the one nearest to edge end point + intersections.sort(function (p, q) { + var pdx = p.x - point.x; + var pdy = p.y - point.y; + var distp = Math.sqrt(pdx * pdx + pdy * pdy); + + var qdx = q.x - point.x; + var qdy = q.y - point.y; + var distq = Math.sqrt(qdx * qdx + qdy * qdy); + + return distp < distq ? -1 : distp === distq ? 0 : 1; + }); + } + return intersections[0]; +} + +function intersectRect$2(node, point) { + var x = node.x; + var y = node.y; + + // Rectangle intersection algorithm from: + // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes + var dx = point.x - x; + var dy = point.y - y; + var w = node.width / 2; + var h = node.height / 2; + + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + // Intersection is top or bottom of rect. + if (dy < 0) { + h = -h; + } + sx = dy === 0 ? 0 : (h * dx) / dy; + sy = h; + } else { + // Intersection is left or right of rect. + if (dx < 0) { + w = -w; + } + sx = w; + sy = dx === 0 ? 0 : (w * dy) / dx; + } + + return { x: x + sx, y: y + sy }; +} + +var shapes$2 = { + rect: rect$2, + ellipse, + circle: circle$3, + diamond, +}; + +function setShapes(value) { + shapes$2 = value; +} + +function rect$2(parent, bbox, node) { + var shapeSvg = parent + .insert('rect', ':first-child') + .attr('rx', node.rx) + .attr('ry', node.ry) + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('width', bbox.width) + .attr('height', bbox.height); + + node.intersect = function (point) { + return intersectRect$2(node, point); + }; + + return shapeSvg; +} + +function ellipse(parent, bbox, node) { + var rx = bbox.width / 2; + var ry = bbox.height / 2; + var shapeSvg = parent + .insert('ellipse', ':first-child') + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('rx', rx) + .attr('ry', ry); + + node.intersect = function (point) { + return intersectEllipse$1(node, rx, ry, point); + }; + + return shapeSvg; +} + +function circle$3(parent, bbox, node) { + var r = Math.max(bbox.width, bbox.height) / 2; + var shapeSvg = parent + .insert('circle', ':first-child') + .attr('x', -bbox.width / 2) + .attr('y', -bbox.height / 2) + .attr('r', r); + + node.intersect = function (point) { + return intersectCircle$1(node, r, point); + }; + + return shapeSvg; +} + +// Circumscribe an ellipse for the bounding box with a diamond shape. I derived +// the function to calculate the diamond shape from: +// http://mathforum.org/kb/message.jspa?messageID=3750236 +function diamond(parent, bbox, node) { + var w = (bbox.width * Math.SQRT2) / 2; + var h = (bbox.height * Math.SQRT2) / 2; + var points = [ + { x: 0, y: -h }, + { x: -w, y: 0 }, + { x: 0, y: h }, + { x: w, y: 0 }, + ]; + var shapeSvg = parent.insert('polygon', ':first-child').attr( + 'points', + points + .map(function (p) { + return p.x + ',' + p.y; + }) + .join(' ') + ); + + node.intersect = function (p) { + return intersectPolygon$1(node, points, p); + }; + + return shapeSvg; +} + +// This design is based on http://bost.ocks.org/mike/chart/. +function render$1() { + var fn = function (svg, g) { + preProcessGraph(g); + + var outputGroup = createOrSelectGroup(svg, 'output'); + var clustersGroup = createOrSelectGroup(outputGroup, 'clusters'); + var edgePathsGroup = createOrSelectGroup(outputGroup, 'edgePaths'); + var edgeLabels = createEdgeLabels(createOrSelectGroup(outputGroup, 'edgeLabels'), g); + var nodes = createNodes(createOrSelectGroup(outputGroup, 'nodes'), g, shapes$2); + + layout$2(g); + + positionNodes$1(nodes, g); + positionEdgeLabels(edgeLabels, g); + createEdgePaths(edgePathsGroup, g, arrows); + + var clusters = createClusters(clustersGroup, g); + positionClusters(clusters, g); + + postProcessGraph(g); + }; + + fn.createNodes = function (value) { + if (!arguments.length) return createNodes; + setCreateNodes(value); + return fn; + }; + + fn.createClusters = function (value) { + if (!arguments.length) return createClusters; + setCreateClusters(value); + return fn; + }; + + fn.createEdgeLabels = function (value) { + if (!arguments.length) return createEdgeLabels; + setCreateEdgeLabels(value); + return fn; + }; + + fn.createEdgePaths = function (value) { + if (!arguments.length) return createEdgePaths; + setCreateEdgePaths(value); + return fn; + }; + + fn.shapes = function (value) { + if (!arguments.length) return shapes$2; + setShapes(value); + return fn; + }; + + fn.arrows = function (value) { + if (!arguments.length) return arrows; + setArrows(value); + return fn; + }; + + return fn; +} + +var NODE_DEFAULT_ATTRS = { + paddingLeft: 10, + paddingRight: 10, + paddingTop: 10, + paddingBottom: 10, + rx: 0, + ry: 0, + shape: 'rect', +}; + +var EDGE_DEFAULT_ATTRS = { + arrowhead: 'normal', + curve: curveLinear, +}; + +function preProcessGraph(g) { + g.nodes().forEach(function (v) { + var node = g.node(v); + if (!has(node, 'label') && !g.children(v).length) { + node.label = v; + } + + if (has(node, 'paddingX')) { + defaults$h(node, { + paddingLeft: node.paddingX, + paddingRight: node.paddingX, + }); + } + + if (has(node, 'paddingY')) { + defaults$h(node, { + paddingTop: node.paddingY, + paddingBottom: node.paddingY, + }); + } + + if (has(node, 'padding')) { + defaults$h(node, { + paddingLeft: node.padding, + paddingRight: node.padding, + paddingTop: node.padding, + paddingBottom: node.padding, + }); + } + + defaults$h(node, NODE_DEFAULT_ATTRS); + + forEach(['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'], function (k) { + node[k] = Number(node[k]); + }); + + // Save dimensions for restore during post-processing + if (has(node, 'width')) { + node._prevWidth = node.width; + } + if (has(node, 'height')) { + node._prevHeight = node.height; + } + }); + + g.edges().forEach(function (e) { + var edge = g.edge(e); + if (!has(edge, 'label')) { + edge.label = ''; + } + defaults$h(edge, EDGE_DEFAULT_ATTRS); + }); +} + +function postProcessGraph(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + + // Restore original dimensions + if (has(node, '_prevWidth')) { + node.width = node._prevWidth; + } else { + delete node.width; + } + + if (has(node, '_prevHeight')) { + node.height = node._prevHeight; + } else { + delete node.height; + } + + delete node._prevWidth; + delete node._prevHeight; + }); +} + +function createOrSelectGroup(root, name) { + var selection = root.select('g.' + name); + if (selection.empty()) { + selection = root.append('g').attr('class', name); + } + return selection; +} + +function write(g) { + var json = { + options: { + directed: g.isDirected(), + multigraph: g.isMultigraph(), + compound: g.isCompound(), + }, + nodes: writeNodes(g), + edges: writeEdges(g), + }; + if (!isUndefined(g.graph())) { + json.value = clone$2(g.graph()); + } + return json; +} + +function writeNodes(g) { + return map(g.nodes(), function (v) { + var nodeValue = g.node(v); + var parent = g.parent(v); + var node = { v: v }; + if (!isUndefined(nodeValue)) { + node.value = nodeValue; + } + if (!isUndefined(parent)) { + node.parent = parent; + } + return node; + }); +} + +function writeEdges(g) { + return map(g.edges(), function (e) { + var edgeValue = g.edge(e); + var edge = { v: e.v, w: e.w }; + if (!isUndefined(e.name)) { + edge.name = e.name; + } + if (!isUndefined(edgeValue)) { + edge.value = edgeValue; + } + return edge; + }); +} + +/** + * @typedef {import('mdast').Root|import('mdast').Content} Node + * + * @typedef Options + * Configuration (optional). + * @property {boolean | null | undefined} [includeImageAlt=true] + * Whether to use `alt` for `image`s. + * @property {boolean | null | undefined} [includeHtml=true] + * Whether to use `value` of HTML. + */ + +/** @type {Options} */ +const emptyOptions = {}; + +/** + * Get the text content of a node or list of nodes. + * + * Prefers the node’s plain-text fields, otherwise serializes its children, + * and if the given value is an array, serialize the nodes in it. + * + * @param {unknown} value + * Thing to serialize, typically `Node`. + * @param {Options | null | undefined} [options] + * Configuration (optional). + * @returns {string} + * Serialized `value`. + */ +function toString$2(value, options) { + const settings = emptyOptions; + const includeImageAlt = + typeof settings.includeImageAlt === 'boolean' + ? settings.includeImageAlt + : true; + const includeHtml = + typeof settings.includeHtml === 'boolean' ? settings.includeHtml : true; + + return one(value, includeImageAlt, includeHtml) +} + +/** + * One node or several nodes. + * + * @param {unknown} value + * Thing to serialize. + * @param {boolean} includeImageAlt + * Include image `alt`s. + * @param {boolean} includeHtml + * Include HTML. + * @returns {string} + * Serialized node. + */ +function one(value, includeImageAlt, includeHtml) { + if (node(value)) { + if ('value' in value) { + return value.type === 'html' && !includeHtml ? '' : value.value + } + + if (includeImageAlt && 'alt' in value && value.alt) { + return value.alt + } + + if ('children' in value) { + return all(value.children, includeImageAlt, includeHtml) + } + } + + if (Array.isArray(value)) { + return all(value, includeImageAlt, includeHtml) + } + + return '' +} + +/** + * Serialize a list of nodes. + * + * @param {Array} values + * Thing to serialize. + * @param {boolean} includeImageAlt + * Include image `alt`s. + * @param {boolean} includeHtml + * Include HTML. + * @returns {string} + * Serialized nodes. + */ +function all(values, includeImageAlt, includeHtml) { + /** @type {Array} */ + const result = []; + let index = -1; + + while (++index < values.length) { + result[index] = one(values[index], includeImageAlt, includeHtml); + } + + return result.join('') +} + +/** + * Check if `value` looks like a node. + * + * @param {unknown} value + * Thing. + * @returns {value is Node} + * Whether `value` is a node. + */ +function node(value) { + return Boolean(value && typeof value === 'object') +} + +/** + * Like `Array#splice`, but smarter for giant arrays. + * + * `Array#splice` takes all items to be inserted as individual argument which + * causes a stack overflow in V8 when trying to insert 100k items for instance. + * + * Otherwise, this does not return the removed items, and takes `items` as an + * array instead of rest parameters. + * + * @template {unknown} T + * Item type. + * @param {Array} list + * List to operate on. + * @param {number} start + * Index to remove/insert at (can be negative). + * @param {number} remove + * Number of items to remove. + * @param {Array} items + * Items to inject into `list`. + * @returns {void} + * Nothing. + */ +function splice$1(list, start, remove, items) { + const end = list.length; + let chunkStart = 0; + /** @type {Array} */ + let parameters; + + // Make start between zero and `end` (included). + if (start < 0) { + start = -start > end ? 0 : end + start; + } else { + start = start > end ? end : start; + } + remove = remove > 0 ? remove : 0; + + // No need to chunk the items if there’s only a couple (10k) items. + if (items.length < 10000) { + parameters = Array.from(items); + parameters.unshift(start, remove); + // @ts-expect-error Hush, it’s fine. + list.splice(...parameters); + } else { + // Delete `remove` items starting from `start` + if (remove) list.splice(start, remove); + + // Insert the items in chunks to not cause stack overflows. + while (chunkStart < items.length) { + parameters = items.slice(chunkStart, chunkStart + 10000); + parameters.unshift(start, 0); + // @ts-expect-error Hush, it’s fine. + list.splice(...parameters); + chunkStart += 10000; + start += 10000; + } + } +} + +/** + * Append `items` (an array) at the end of `list` (another array). + * When `list` was empty, returns `items` instead. + * + * This prevents a potentially expensive operation when `list` is empty, + * and adds items in batches to prevent V8 from hanging. + * + * @template {unknown} T + * Item type. + * @param {Array} list + * List to operate on. + * @param {Array} items + * Items to add to `list`. + * @returns {Array} + * Either `list` or `items`. + */ +function push$1(list, items) { + if (list.length > 0) { + splice$1(list, list.length, 0, items); + return list + } + return items +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + * @typedef {import('micromark-util-types').Handles} Handles + * @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension + * @typedef {import('micromark-util-types').NormalizedExtension} NormalizedExtension + */ + + +const hasOwnProperty$5 = {}.hasOwnProperty; + +/** + * Combine multiple syntax extensions into one. + * + * @param {Array} extensions + * List of syntax extensions. + * @returns {NormalizedExtension} + * A single combined extension. + */ +function combineExtensions(extensions) { + /** @type {NormalizedExtension} */ + const all = {}; + let index = -1; + + while (++index < extensions.length) { + syntaxExtension(all, extensions[index]); + } + + return all +} + +/** + * Merge `extension` into `all`. + * + * @param {NormalizedExtension} all + * Extension to merge into. + * @param {Extension} extension + * Extension to merge. + * @returns {void} + */ +function syntaxExtension(all, extension) { + /** @type {keyof Extension} */ + let hook; + + for (hook in extension) { + const maybe = hasOwnProperty$5.call(all, hook) ? all[hook] : undefined; + /** @type {Record} */ + const left = maybe || (all[hook] = {}); + /** @type {Record | undefined} */ + const right = extension[hook]; + /** @type {string} */ + let code; + + if (right) { + for (code in right) { + if (!hasOwnProperty$5.call(left, code)) left[code] = []; + const value = right[code]; + constructs( + // @ts-expect-error Looks like a list. + left[code], + Array.isArray(value) ? value : value ? [value] : [] + ); + } + } + } +} + +/** + * Merge `list` into `existing` (both lists of constructs). + * Mutates `existing`. + * + * @param {Array} existing + * @param {Array} list + * @returns {void} + */ +function constructs(existing, list) { + let index = -1; + /** @type {Array} */ + const before = []; + + while (++index < list.length) { +(list[index].add === 'after' ? existing : before).push(list[index]); + } + + splice$1(existing, 0, 0, before); +} + +// This module is generated by `script/`. +// +// CommonMark handles attention (emphasis, strong) markers based on what comes +// before or after them. +// One such difference is if those characters are Unicode punctuation. +// This script is generated from the Unicode data. + +/** + * Regular expression that matches a unicode punctuation character. + */ +const unicodePunctuationRegex = + /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/; + +/** + * @typedef {import('micromark-util-types').Code} Code + */ + + +/** + * Check whether the character code represents an ASCII alpha (`a` through `z`, + * case insensitive). + * + * An **ASCII alpha** is an ASCII upper alpha or ASCII lower alpha. + * + * An **ASCII upper alpha** is a character in the inclusive range U+0041 (`A`) + * to U+005A (`Z`). + * + * An **ASCII lower alpha** is a character in the inclusive range U+0061 (`a`) + * to U+007A (`z`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAlpha = regexCheck(/[A-Za-z]/); + +/** + * Check whether the character code represents an ASCII alphanumeric (`a` + * through `z`, case insensitive, or `0` through `9`). + * + * An **ASCII alphanumeric** is an ASCII digit (see `asciiDigit`) or ASCII alpha + * (see `asciiAlpha`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAlphanumeric = regexCheck(/[\dA-Za-z]/); + +/** + * Check whether the character code represents an ASCII atext. + * + * atext is an ASCII alphanumeric (see `asciiAlphanumeric`), or a character in + * the inclusive ranges U+0023 NUMBER SIGN (`#`) to U+0027 APOSTROPHE (`'`), + * U+002A ASTERISK (`*`), U+002B PLUS SIGN (`+`), U+002D DASH (`-`), U+002F + * SLASH (`/`), U+003D EQUALS TO (`=`), U+003F QUESTION MARK (`?`), U+005E + * CARET (`^`) to U+0060 GRAVE ACCENT (`` ` ``), or U+007B LEFT CURLY BRACE + * (`{`) to U+007E TILDE (`~`). + * + * See: + * **\[RFC5322]**: + * [Internet Message Format](https://tools.ietf.org/html/rfc5322). + * P. Resnick. + * IETF. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/); + +/** + * Check whether a character code is an ASCII control character. + * + * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL) + * to U+001F (US), or U+007F (DEL). + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function asciiControl(code) { + return ( + // Special whitespace codes (which have negative values), C0 and Control + // character DEL + code !== null && (code < 32 || code === 127) + ) +} + +/** + * Check whether the character code represents an ASCII digit (`0` through `9`). + * + * An **ASCII digit** is a character in the inclusive range U+0030 (`0`) to + * U+0039 (`9`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiDigit = regexCheck(/\d/); + +/** + * Check whether the character code represents an ASCII hex digit (`a` through + * `f`, case insensitive, or `0` through `9`). + * + * An **ASCII hex digit** is an ASCII digit (see `asciiDigit`), ASCII upper hex + * digit, or an ASCII lower hex digit. + * + * An **ASCII upper hex digit** is a character in the inclusive range U+0041 + * (`A`) to U+0046 (`F`). + * + * An **ASCII lower hex digit** is a character in the inclusive range U+0061 + * (`a`) to U+0066 (`f`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiHexDigit = regexCheck(/[\dA-Fa-f]/); + +/** + * Check whether the character code represents ASCII punctuation. + * + * An **ASCII punctuation** is a character in the inclusive ranges U+0021 + * EXCLAMATION MARK (`!`) to U+002F SLASH (`/`), U+003A COLON (`:`) to U+0040 AT + * SIGN (`@`), U+005B LEFT SQUARE BRACKET (`[`) to U+0060 GRAVE ACCENT + * (`` ` ``), or U+007B LEFT CURLY BRACE (`{`) to U+007E TILDE (`~`). + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/); + +/** + * Check whether a character code is a markdown line ending. + * + * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN + * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR). + * + * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE + * RETURN (CR) are replaced by these virtual characters depending on whether + * they occurred together. + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownLineEnding(code) { + return code !== null && code < -2 +} + +/** + * Check whether a character code is a markdown line ending (see + * `markdownLineEnding`) or markdown space (see `markdownSpace`). + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownLineEndingOrSpace(code) { + return code !== null && (code < 0 || code === 32) +} + +/** + * Check whether a character code is a markdown space. + * + * A **markdown space** is the concrete character U+0020 SPACE (SP) and the + * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT). + * + * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is + * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL + * SPACE (VS) characters, depending on the column at which the tab occurred. + * + * @param {Code} code + * Code. + * @returns {boolean} + * Whether it matches. + */ +function markdownSpace(code) { + return code === -2 || code === -1 || code === 32 +} + +// Size note: removing ASCII from the regex and using `asciiPunctuation` here +// In fact adds to the bundle size. +/** + * Check whether the character code represents Unicode punctuation. + * + * A **Unicode punctuation** is a character in the Unicode `Pc` (Punctuation, + * Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf` + * (Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po` + * (Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an ASCII + * punctuation (see `asciiPunctuation`). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const unicodePunctuation = regexCheck(unicodePunctuationRegex); + +/** + * Check whether the character code represents Unicode whitespace. + * + * Note that this does handle micromark specific markdown whitespace characters. + * See `markdownLineEndingOrSpace` to check that. + * + * A **Unicode whitespace** is a character in the Unicode `Zs` (Separator, + * Space) category, or U+0009 CHARACTER TABULATION (HT), U+000A LINE FEED (LF), + * U+000C (FF), or U+000D CARRIAGE RETURN (CR) (**\[UNICODE]**). + * + * See: + * **\[UNICODE]**: + * [The Unicode Standard](https://www.unicode.org/versions/). + * Unicode Consortium. + * + * @param code + * Code. + * @returns + * Whether it matches. + */ +const unicodeWhitespace = regexCheck(/\s/); + +/** + * Create a code check from a regex. + * + * @param {RegExp} regex + * @returns {(code: Code) => boolean} + */ +function regexCheck(regex) { + return check + + /** + * Check whether a code matches the bound regex. + * + * @param {Code} code + * Character code. + * @returns {boolean} + * Whether the character code matches the bound regex. + */ + function check(code) { + return code !== null && regex.test(String.fromCharCode(code)) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + + +// To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`. + +/** + * Parse spaces and tabs. + * + * There is no `nok` parameter: + * + * * spaces in markdown are often optional, in which case this factory can be + * used and `ok` will be switched to whether spaces were found or not + * * one line ending or space can be detected with `markdownSpace(code)` right + * before using `factorySpace` + * + * ###### Examples + * + * Where `␉` represents a tab (plus how much it expands) and `␠` represents a + * single space. + * + * ```markdown + * ␉ + * ␠␠␠␠ + * ␉␠ + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {TokenType} type + * Type (`' \t'`). + * @param {number | undefined} [max=Infinity] + * Max (exclusive). + * @returns + * Start state. + */ +function factorySpace(effects, ok, type, max) { + const limit = max ? max - 1 : Number.POSITIVE_INFINITY; + let size = 0; + return start + + /** @type {State} */ + function start(code) { + if (markdownSpace(code)) { + effects.enter(type); + return prefix(code) + } + return ok(code) + } + + /** @type {State} */ + function prefix(code) { + if (markdownSpace(code) && size++ < limit) { + effects.consume(code); + return prefix + } + effects.exit(type); + return ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** @type {InitialConstruct} */ +const content$1 = { + tokenize: initializeContent +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeContent(effects) { + const contentStart = effects.attempt( + this.parser.constructs.contentInitial, + afterContentStartConstruct, + paragraphInitial + ); + /** @type {Token} */ + let previous; + return contentStart + + /** @type {State} */ + function afterContentStartConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, contentStart, 'linePrefix') + } + + /** @type {State} */ + function paragraphInitial(code) { + effects.enter('paragraph'); + return lineStart(code) + } + + /** @type {State} */ + function lineStart(code) { + const token = effects.enter('chunkText', { + contentType: 'text', + previous + }); + if (previous) { + previous.next = token; + } + previous = token; + return data(code) + } + + /** @type {State} */ + function data(code) { + if (code === null) { + effects.exit('chunkText'); + effects.exit('paragraph'); + effects.consume(code); + return + } + if (markdownLineEnding(code)) { + effects.consume(code); + effects.exit('chunkText'); + return lineStart + } + + // Data. + effects.consume(code); + return data + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ContainerState} ContainerState + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {InitialConstruct} */ +const document$2 = { + tokenize: initializeDocument +}; + +/** @type {Construct} */ +const containerConstruct = { + tokenize: tokenizeContainer +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeDocument(effects) { + const self = this; + /** @type {Array} */ + const stack = []; + let continued = 0; + /** @type {TokenizeContext | undefined} */ + let childFlow; + /** @type {Token | undefined} */ + let childToken; + /** @type {number} */ + let lineStartOffset; + return start + + /** @type {State} */ + function start(code) { + // First we iterate through the open blocks, starting with the root + // document, and descending through last children down to the last open + // block. + // Each block imposes a condition that the line must satisfy if the block is + // to remain open. + // For example, a block quote requires a `>` character. + // A paragraph requires a non-blank line. + // In this phase we may match all or just some of the open blocks. + // But we cannot close unmatched blocks yet, because we may have a lazy + // continuation line. + if (continued < stack.length) { + const item = stack[continued]; + self.containerState = item[1]; + return effects.attempt( + item[0].continuation, + documentContinue, + checkNewContainers + )(code) + } + + // Done. + return checkNewContainers(code) + } + + /** @type {State} */ + function documentContinue(code) { + continued++; + + // Note: this field is called `_closeFlow` but it also closes containers. + // Perhaps a good idea to rename it but it’s already used in the wild by + // extensions. + if (self.containerState._closeFlow) { + self.containerState._closeFlow = undefined; + if (childFlow) { + closeFlow(); + } + + // Note: this algorithm for moving events around is similar to the + // algorithm when dealing with lazy lines in `writeToChild`. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {Point | undefined} */ + let point; + + // Find the flow chunk. + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + point = self.events[indexBeforeFlow][1].end; + break + } + } + exitContainers(continued); + + // Fix positions. + let index = indexBeforeExits; + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } + + // Inject the exits earlier (they’re still also at the end). + splice$1( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); + + // Discard the duplicate exits. + self.events.length = index; + return checkNewContainers(code) + } + return start(code) + } + + /** @type {State} */ + function checkNewContainers(code) { + // Next, after consuming the continuation markers for existing blocks, we + // look for new block starts (e.g. `>` for a block quote). + // If we encounter a new block start, we close any blocks unmatched in + // step 1 before creating the new block as a child of the last matched + // block. + if (continued === stack.length) { + // No need to `check` whether there’s a container, of `exitContainers` + // would be moot. + // We can instead immediately `attempt` to parse one. + if (!childFlow) { + return documentContinued(code) + } + + // If we have concrete content, such as block HTML or fenced code, + // we can’t have containers “pierce” into them, so we can immediately + // start. + if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) { + return flowStart(code) + } + + // If we do have flow, it could still be a blank line, + // but we’d be interrupting it w/ a new container if there’s a current + // construct. + // To do: next major: remove `_gfmTableDynamicInterruptHack` (no longer + // needed in micromark-extension-gfm-table@1.0.6). + self.interrupt = Boolean( + childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack + ); + } + + // Check if there is a new container. + self.containerState = {}; + return effects.check( + containerConstruct, + thereIsANewContainer, + thereIsNoNewContainer + )(code) + } + + /** @type {State} */ + function thereIsANewContainer(code) { + if (childFlow) closeFlow(); + exitContainers(continued); + return documentContinued(code) + } + + /** @type {State} */ + function thereIsNoNewContainer(code) { + self.parser.lazy[self.now().line] = continued !== stack.length; + lineStartOffset = self.now().offset; + return flowStart(code) + } + + /** @type {State} */ + function documentContinued(code) { + // Try new containers. + self.containerState = {}; + return effects.attempt( + containerConstruct, + containerContinue, + flowStart + )(code) + } + + /** @type {State} */ + function containerContinue(code) { + continued++; + stack.push([self.currentConstruct, self.containerState]); + // Try another. + return documentContinued(code) + } + + /** @type {State} */ + function flowStart(code) { + if (code === null) { + if (childFlow) closeFlow(); + exitContainers(0); + effects.consume(code); + return + } + childFlow = childFlow || self.parser.flow(self.now()); + effects.enter('chunkFlow', { + contentType: 'flow', + previous: childToken, + _tokenizer: childFlow + }); + return flowContinue(code) + } + + /** @type {State} */ + function flowContinue(code) { + if (code === null) { + writeToChild(effects.exit('chunkFlow'), true); + exitContainers(0); + effects.consume(code); + return + } + if (markdownLineEnding(code)) { + effects.consume(code); + writeToChild(effects.exit('chunkFlow')); + // Get ready for the next line. + continued = 0; + self.interrupt = undefined; + return start + } + effects.consume(code); + return flowContinue + } + + /** + * @param {Token} token + * @param {boolean | undefined} [eof] + * @returns {void} + */ + function writeToChild(token, eof) { + const stream = self.sliceStream(token); + if (eof) stream.push(null); + token.previous = childToken; + if (childToken) childToken.next = token; + childToken = token; + childFlow.defineSkip(token.start); + childFlow.write(stream); + + // Alright, so we just added a lazy line: + // + // ```markdown + // > a + // b. + // + // Or: + // + // > ~~~c + // d + // + // Or: + // + // > | e | + // f + // ``` + // + // The construct in the second example (fenced code) does not accept lazy + // lines, so it marked itself as done at the end of its first line, and + // then the content construct parses `d`. + // Most constructs in markdown match on the first line: if the first line + // forms a construct, a non-lazy line can’t “unmake” it. + // + // The construct in the third example is potentially a GFM table, and + // those are *weird*. + // It *could* be a table, from the first line, if the following line + // matches a condition. + // In this case, that second line is lazy, which “unmakes” the first line + // and turns the whole into one content block. + // + // We’ve now parsed the non-lazy and the lazy line, and can figure out + // whether the lazy line started a new flow block. + // If it did, we exit the current containers between the two flow blocks. + if (self.parser.lazy[token.start.line]) { + let index = childFlow.events.length; + while (index--) { + if ( + // The token starts before the line ending… + childFlow.events[index][1].start.offset < lineStartOffset && + // …and either is not ended yet… + (!childFlow.events[index][1].end || + // …or ends after it. + childFlow.events[index][1].end.offset > lineStartOffset) + ) { + // Exit: there’s still something open, which means it’s a lazy line + // part of something. + return + } + } + + // Note: this algorithm for moving events around is similar to the + // algorithm when closing flow in `documentContinue`. + const indexBeforeExits = self.events.length; + let indexBeforeFlow = indexBeforeExits; + /** @type {boolean | undefined} */ + let seen; + /** @type {Point | undefined} */ + let point; + + // Find the previous chunk (the one before the lazy line). + while (indexBeforeFlow--) { + if ( + self.events[indexBeforeFlow][0] === 'exit' && + self.events[indexBeforeFlow][1].type === 'chunkFlow' + ) { + if (seen) { + point = self.events[indexBeforeFlow][1].end; + break + } + seen = true; + } + } + exitContainers(continued); + + // Fix positions. + index = indexBeforeExits; + while (index < self.events.length) { + self.events[index][1].end = Object.assign({}, point); + index++; + } + + // Inject the exits earlier (they’re still also at the end). + splice$1( + self.events, + indexBeforeFlow + 1, + 0, + self.events.slice(indexBeforeExits) + ); + + // Discard the duplicate exits. + self.events.length = index; + } + } + + /** + * @param {number} size + * @returns {void} + */ + function exitContainers(size) { + let index = stack.length; + + // Exit open containers. + while (index-- > size) { + const entry = stack[index]; + self.containerState = entry[1]; + entry[0].exit.call(self, effects); + } + stack.length = size; + } + function closeFlow() { + childFlow.write([null]); + childToken = undefined; + childFlow = undefined; + self.containerState._closeFlow = undefined; + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContainer(effects, ok, nok) { + // Always populated by defaults. + + return factorySpace( + effects, + effects.attempt(this.parser.constructs.document, ok, nok), + 'linePrefix', + this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4 + ) +} + +/** + * @typedef {import('micromark-util-types').Code} Code + */ + +/** + * Classify whether a code represents whitespace, punctuation, or something + * else. + * + * Used for attention (emphasis, strong), whose sequences can open or close + * based on the class of surrounding characters. + * + * > 👉 **Note**: eof (`null`) is seen as whitespace. + * + * @param {Code} code + * Code. + * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined} + * Group. + */ +function classifyCharacter(code) { + if ( + code === null || + markdownLineEndingOrSpace(code) || + unicodeWhitespace(code) + ) { + return 1 + } + if (unicodePunctuation(code)) { + return 2 + } +} + +/** + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** + * Call all `resolveAll`s. + * + * @param {Array<{resolveAll?: Resolver | undefined}>} constructs + * List of constructs, optionally with `resolveAll`s. + * @param {Array} events + * List of events. + * @param {TokenizeContext} context + * Context used by `tokenize`. + * @returns {Array} + * Changed events. + */ +function resolveAll(constructs, events, context) { + /** @type {Array} */ + const called = []; + let index = -1; + + while (++index < constructs.length) { + const resolve = constructs[index].resolveAll; + + if (resolve && !called.includes(resolve)) { + events = resolve(events, context); + called.push(resolve); + } + } + + return events +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const attention = { + name: 'attention', + tokenize: tokenizeAttention, + resolveAll: resolveAllAttention +}; + +/** + * Take all events and resolve attention to emphasis or strong. + * + * @type {Resolver} + */ +function resolveAllAttention(events, context) { + let index = -1; + /** @type {number} */ + let open; + /** @type {Token} */ + let group; + /** @type {Token} */ + let text; + /** @type {Token} */ + let openingSequence; + /** @type {Token} */ + let closingSequence; + /** @type {number} */ + let use; + /** @type {Array} */ + let nextEvents; + /** @type {number} */ + let offset; + + // Walk through all events. + // + // Note: performance of this is fine on an mb of normal markdown, but it’s + // a bottleneck for malicious stuff. + while (++index < events.length) { + // Find a token that can close. + if ( + events[index][0] === 'enter' && + events[index][1].type === 'attentionSequence' && + events[index][1]._close + ) { + open = index; + + // Now walk back to find an opener. + while (open--) { + // Find a token that can open the closer. + if ( + events[open][0] === 'exit' && + events[open][1].type === 'attentionSequence' && + events[open][1]._open && + // If the markers are the same: + context.sliceSerialize(events[open][1]).charCodeAt(0) === + context.sliceSerialize(events[index][1]).charCodeAt(0) + ) { + // If the opening can close or the closing can open, + // and the close size *is not* a multiple of three, + // but the sum of the opening and closing size *is* multiple of three, + // then don’t match. + if ( + (events[open][1]._close || events[index][1]._open) && + (events[index][1].end.offset - events[index][1].start.offset) % 3 && + !( + (events[open][1].end.offset - + events[open][1].start.offset + + events[index][1].end.offset - + events[index][1].start.offset) % + 3 + ) + ) { + continue + } + + // Number of markers to use from the sequence. + use = + events[open][1].end.offset - events[open][1].start.offset > 1 && + events[index][1].end.offset - events[index][1].start.offset > 1 + ? 2 + : 1; + const start = Object.assign({}, events[open][1].end); + const end = Object.assign({}, events[index][1].start); + movePoint(start, -use); + movePoint(end, use); + openingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start, + end: Object.assign({}, events[open][1].end) + }; + closingSequence = { + type: use > 1 ? 'strongSequence' : 'emphasisSequence', + start: Object.assign({}, events[index][1].start), + end + }; + text = { + type: use > 1 ? 'strongText' : 'emphasisText', + start: Object.assign({}, events[open][1].end), + end: Object.assign({}, events[index][1].start) + }; + group = { + type: use > 1 ? 'strong' : 'emphasis', + start: Object.assign({}, openingSequence.start), + end: Object.assign({}, closingSequence.end) + }; + events[open][1].end = Object.assign({}, openingSequence.start); + events[index][1].start = Object.assign({}, closingSequence.end); + nextEvents = []; + + // If there are more markers in the opening, add them before. + if (events[open][1].end.offset - events[open][1].start.offset) { + nextEvents = push$1(nextEvents, [ + ['enter', events[open][1], context], + ['exit', events[open][1], context] + ]); + } + + // Opening. + nextEvents = push$1(nextEvents, [ + ['enter', group, context], + ['enter', openingSequence, context], + ['exit', openingSequence, context], + ['enter', text, context] + ]); + + // Always populated by defaults. + + // Between. + nextEvents = push$1( + nextEvents, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + 1, index), + context + ) + ); + + // Closing. + nextEvents = push$1(nextEvents, [ + ['exit', text, context], + ['enter', closingSequence, context], + ['exit', closingSequence, context], + ['exit', group, context] + ]); + + // If there are more markers in the closing, add them after. + if (events[index][1].end.offset - events[index][1].start.offset) { + offset = 2; + nextEvents = push$1(nextEvents, [ + ['enter', events[index][1], context], + ['exit', events[index][1], context] + ]); + } else { + offset = 0; + } + splice$1(events, open - 1, index - open + 3, nextEvents); + index = open + nextEvents.length - offset - 2; + break + } + } + } + } + + // Remove remaining sequences. + index = -1; + while (++index < events.length) { + if (events[index][1].type === 'attentionSequence') { + events[index][1].type = 'data'; + } + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeAttention(effects, ok) { + const attentionMarkers = this.parser.constructs.attentionMarkers.null; + const previous = this.previous; + const before = classifyCharacter(previous); + + /** @type {NonNullable} */ + let marker; + return start + + /** + * Before a sequence. + * + * ```markdown + * > | ** + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + marker = code; + effects.enter('attentionSequence'); + return inside(code) + } + + /** + * In a sequence. + * + * ```markdown + * > | ** + * ^^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === marker) { + effects.consume(code); + return inside + } + const token = effects.exit('attentionSequence'); + + // To do: next major: move this to resolver, just like `markdown-rs`. + const after = classifyCharacter(code); + + // Always populated by defaults. + + const open = + !after || (after === 2 && before) || attentionMarkers.includes(code); + const close = + !before || (before === 2 && after) || attentionMarkers.includes(previous); + token._open = Boolean(marker === 42 ? open : open && (before || !close)); + token._close = Boolean(marker === 42 ? close : close && (after || !open)); + return ok(code) + } +} + +/** + * Move a point a bit. + * + * Note: `move` only works inside lines! It’s not possible to move past other + * chunks (replacement characters, tabs, or line endings). + * + * @param {Point} point + * @param {number} offset + * @returns {void} + */ +function movePoint(point, offset) { + point.column += offset; + point.offset += offset; + point._bufferIndex += offset; +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const autolink = { + name: 'autolink', + tokenize: tokenizeAutolink +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeAutolink(effects, ok, nok) { + let size = 0; + return start + + /** + * Start of an autolink. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('autolink'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.enter('autolinkProtocol'); + return open + } + + /** + * After `<`, at protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (asciiAlpha(code)) { + effects.consume(code); + return schemeOrEmailAtext + } + return emailAtext(code) + } + + /** + * At second byte of protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function schemeOrEmailAtext(code) { + // ASCII alphanumeric and `+`, `-`, and `.`. + if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) { + // Count the previous alphabetical from `open` too. + size = 1; + return schemeInsideOrEmailAtext(code) + } + return emailAtext(code) + } + + /** + * In ambiguous protocol or atext. + * + * ```markdown + * > | ab + * ^ + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function schemeInsideOrEmailAtext(code) { + if (code === 58) { + effects.consume(code); + size = 0; + return urlInside + } + + // ASCII alphanumeric and `+`, `-`, and `.`. + if ( + (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && + size++ < 32 + ) { + effects.consume(code); + return schemeInsideOrEmailAtext + } + size = 0; + return emailAtext(code) + } + + /** + * After protocol, in URL. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function urlInside(code) { + if (code === 62) { + effects.exit('autolinkProtocol'); + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok + } + + // ASCII control, space, or `<`. + if (code === null || code === 32 || code === 60 || asciiControl(code)) { + return nok(code) + } + effects.consume(code); + return urlInside + } + + /** + * In email atext. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailAtext(code) { + if (code === 64) { + effects.consume(code); + return emailAtSignOrDot + } + if (asciiAtext(code)) { + effects.consume(code); + return emailAtext + } + return nok(code) + } + + /** + * In label, after at-sign or dot. + * + * ```markdown + * > | ab + * ^ ^ + * ``` + * + * @type {State} + */ + function emailAtSignOrDot(code) { + return asciiAlphanumeric(code) ? emailLabel(code) : nok(code) + } + + /** + * In label, where `.` and `>` are allowed. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailLabel(code) { + if (code === 46) { + effects.consume(code); + size = 0; + return emailAtSignOrDot + } + if (code === 62) { + // Exit, then change the token type. + effects.exit('autolinkProtocol').type = 'autolinkEmail'; + effects.enter('autolinkMarker'); + effects.consume(code); + effects.exit('autolinkMarker'); + effects.exit('autolink'); + return ok + } + return emailValue(code) + } + + /** + * In label, where `.` and `>` are *not* allowed. + * + * Though, this is also used in `emailLabel` to parse other values. + * + * ```markdown + * > | ab + * ^ + * ``` + * + * @type {State} + */ + function emailValue(code) { + // ASCII alphanumeric or `-`. + if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) { + const next = code === 45 ? emailValue : emailLabel; + effects.consume(code); + return next + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const blankLine = { + tokenize: tokenizeBlankLine, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlankLine(effects, ok, nok) { + return start + + /** + * Start of blank line. + * + * > 👉 **Note**: `␠` represents a space character. + * + * ```markdown + * > | ␠␠␊ + * ^ + * > | ␊ + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + return markdownSpace(code) + ? factorySpace(effects, after, 'linePrefix')(code) + : after(code) + } + + /** + * At eof/eol, after optional whitespace. + * + * > 👉 **Note**: `␠` represents a space character. + * + * ```markdown + * > | ␠␠␊ + * ^ + * > | ␊ + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const blockQuote = { + name: 'blockQuote', + tokenize: tokenizeBlockQuoteStart, + continuation: { + tokenize: tokenizeBlockQuoteContinuation + }, + exit +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlockQuoteStart(effects, ok, nok) { + const self = this; + return start + + /** + * Start of block quote. + * + * ```markdown + * > | > a + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 62) { + const state = self.containerState; + if (!state.open) { + effects.enter('blockQuote', { + _container: true + }); + state.open = true; + } + effects.enter('blockQuotePrefix'); + effects.enter('blockQuoteMarker'); + effects.consume(code); + effects.exit('blockQuoteMarker'); + return after + } + return nok(code) + } + + /** + * After `>`, before optional whitespace. + * + * ```markdown + * > | > a + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + if (markdownSpace(code)) { + effects.enter('blockQuotePrefixWhitespace'); + effects.consume(code); + effects.exit('blockQuotePrefixWhitespace'); + effects.exit('blockQuotePrefix'); + return ok + } + effects.exit('blockQuotePrefix'); + return ok(code) + } +} + +/** + * Start of block quote continuation. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlockQuoteContinuation(effects, ok, nok) { + const self = this; + return contStart + + /** + * Start of block quote continuation. + * + * Also used to parse the first block quote opening. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @type {State} + */ + function contStart(code) { + if (markdownSpace(code)) { + // Always populated by defaults. + + return factorySpace( + effects, + contBefore, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } + return contBefore(code) + } + + /** + * At `>`, after optional whitespace. + * + * Also used to parse the first block quote opening. + * + * ```markdown + * | > a + * > | > b + * ^ + * ``` + * + * @type {State} + */ + function contBefore(code) { + return effects.attempt(blockQuote, ok, nok)(code) + } +} + +/** @type {Exiter} */ +function exit(effects) { + effects.exit('blockQuote'); +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const characterEscape = { + name: 'characterEscape', + tokenize: tokenizeCharacterEscape +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCharacterEscape(effects, ok, nok) { + return start + + /** + * Start of character escape. + * + * ```markdown + * > | a\*b + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('characterEscape'); + effects.enter('escapeMarker'); + effects.consume(code); + effects.exit('escapeMarker'); + return inside + } + + /** + * After `\`, at punctuation. + * + * ```markdown + * > | a\*b + * ^ + * ``` + * + * @type {State} + */ + function inside(code) { + // ASCII punctuation. + if (asciiPunctuation(code)) { + effects.enter('characterEscapeValue'); + effects.consume(code); + effects.exit('characterEscapeValue'); + effects.exit('characterEscape'); + return ok + } + return nok(code) + } +} + +/** + * Map of named character references. + * + * @type {Record} + */ +const characterEntities = { + AElig: 'Æ', + AMP: '&', + Aacute: 'Á', + Abreve: 'Ă', + Acirc: 'Â', + Acy: 'А', + Afr: '𝔄', + Agrave: 'À', + Alpha: 'Α', + Amacr: 'Ā', + And: '⩓', + Aogon: 'Ą', + Aopf: '𝔸', + ApplyFunction: '⁡', + Aring: 'Å', + Ascr: '𝒜', + Assign: '≔', + Atilde: 'Ã', + Auml: 'Ä', + Backslash: '∖', + Barv: '⫧', + Barwed: '⌆', + Bcy: 'Б', + Because: '∵', + Bernoullis: 'ℬ', + Beta: 'Β', + Bfr: '𝔅', + Bopf: '𝔹', + Breve: '˘', + Bscr: 'ℬ', + Bumpeq: '≎', + CHcy: 'Ч', + COPY: '©', + Cacute: 'Ć', + Cap: '⋒', + CapitalDifferentialD: 'ⅅ', + Cayleys: 'ℭ', + Ccaron: 'Č', + Ccedil: 'Ç', + Ccirc: 'Ĉ', + Cconint: '∰', + Cdot: 'Ċ', + Cedilla: '¸', + CenterDot: '·', + Cfr: 'ℭ', + Chi: 'Χ', + CircleDot: '⊙', + CircleMinus: '⊖', + CirclePlus: '⊕', + CircleTimes: '⊗', + ClockwiseContourIntegral: '∲', + CloseCurlyDoubleQuote: '”', + CloseCurlyQuote: '’', + Colon: '∷', + Colone: '⩴', + Congruent: '≡', + Conint: '∯', + ContourIntegral: '∮', + Copf: 'ℂ', + Coproduct: '∐', + CounterClockwiseContourIntegral: '∳', + Cross: '⨯', + Cscr: '𝒞', + Cup: '⋓', + CupCap: '≍', + DD: 'ⅅ', + DDotrahd: '⤑', + DJcy: 'Ђ', + DScy: 'Ѕ', + DZcy: 'Џ', + Dagger: '‡', + Darr: '↡', + Dashv: '⫤', + Dcaron: 'Ď', + Dcy: 'Д', + Del: '∇', + Delta: 'Δ', + Dfr: '𝔇', + DiacriticalAcute: '´', + DiacriticalDot: '˙', + DiacriticalDoubleAcute: '˝', + DiacriticalGrave: '`', + DiacriticalTilde: '˜', + Diamond: '⋄', + DifferentialD: 'ⅆ', + Dopf: '𝔻', + Dot: '¨', + DotDot: '⃜', + DotEqual: '≐', + DoubleContourIntegral: '∯', + DoubleDot: '¨', + DoubleDownArrow: '⇓', + DoubleLeftArrow: '⇐', + DoubleLeftRightArrow: '⇔', + DoubleLeftTee: '⫤', + DoubleLongLeftArrow: '⟸', + DoubleLongLeftRightArrow: '⟺', + DoubleLongRightArrow: '⟹', + DoubleRightArrow: '⇒', + DoubleRightTee: '⊨', + DoubleUpArrow: '⇑', + DoubleUpDownArrow: '⇕', + DoubleVerticalBar: '∥', + DownArrow: '↓', + DownArrowBar: '⤓', + DownArrowUpArrow: '⇵', + DownBreve: '̑', + DownLeftRightVector: '⥐', + DownLeftTeeVector: '⥞', + DownLeftVector: '↽', + DownLeftVectorBar: '⥖', + DownRightTeeVector: '⥟', + DownRightVector: '⇁', + DownRightVectorBar: '⥗', + DownTee: '⊤', + DownTeeArrow: '↧', + Downarrow: '⇓', + Dscr: '𝒟', + Dstrok: 'Đ', + ENG: 'Ŋ', + ETH: 'Ð', + Eacute: 'É', + Ecaron: 'Ě', + Ecirc: 'Ê', + Ecy: 'Э', + Edot: 'Ė', + Efr: '𝔈', + Egrave: 'È', + Element: '∈', + Emacr: 'Ē', + EmptySmallSquare: '◻', + EmptyVerySmallSquare: '▫', + Eogon: 'Ę', + Eopf: '𝔼', + Epsilon: 'Ε', + Equal: '⩵', + EqualTilde: '≂', + Equilibrium: '⇌', + Escr: 'ℰ', + Esim: '⩳', + Eta: 'Η', + Euml: 'Ë', + Exists: '∃', + ExponentialE: 'ⅇ', + Fcy: 'Ф', + Ffr: '𝔉', + FilledSmallSquare: '◼', + FilledVerySmallSquare: '▪', + Fopf: '𝔽', + ForAll: '∀', + Fouriertrf: 'ℱ', + Fscr: 'ℱ', + GJcy: 'Ѓ', + GT: '>', + Gamma: 'Γ', + Gammad: 'Ϝ', + Gbreve: 'Ğ', + Gcedil: 'Ģ', + Gcirc: 'Ĝ', + Gcy: 'Г', + Gdot: 'Ġ', + Gfr: '𝔊', + Gg: '⋙', + Gopf: '𝔾', + GreaterEqual: '≥', + GreaterEqualLess: '⋛', + GreaterFullEqual: '≧', + GreaterGreater: '⪢', + GreaterLess: '≷', + GreaterSlantEqual: '⩾', + GreaterTilde: '≳', + Gscr: '𝒢', + Gt: '≫', + HARDcy: 'Ъ', + Hacek: 'ˇ', + Hat: '^', + Hcirc: 'Ĥ', + Hfr: 'ℌ', + HilbertSpace: 'ℋ', + Hopf: 'ℍ', + HorizontalLine: '─', + Hscr: 'ℋ', + Hstrok: 'Ħ', + HumpDownHump: '≎', + HumpEqual: '≏', + IEcy: 'Е', + IJlig: 'IJ', + IOcy: 'Ё', + Iacute: 'Í', + Icirc: 'Î', + Icy: 'И', + Idot: 'İ', + Ifr: 'ℑ', + Igrave: 'Ì', + Im: 'ℑ', + Imacr: 'Ī', + ImaginaryI: 'ⅈ', + Implies: '⇒', + Int: '∬', + Integral: '∫', + Intersection: '⋂', + InvisibleComma: '⁣', + InvisibleTimes: '⁢', + Iogon: 'Į', + Iopf: '𝕀', + Iota: 'Ι', + Iscr: 'ℐ', + Itilde: 'Ĩ', + Iukcy: 'І', + Iuml: 'Ï', + Jcirc: 'Ĵ', + Jcy: 'Й', + Jfr: '𝔍', + Jopf: '𝕁', + Jscr: '𝒥', + Jsercy: 'Ј', + Jukcy: 'Є', + KHcy: 'Х', + KJcy: 'Ќ', + Kappa: 'Κ', + Kcedil: 'Ķ', + Kcy: 'К', + Kfr: '𝔎', + Kopf: '𝕂', + Kscr: '𝒦', + LJcy: 'Љ', + LT: '<', + Lacute: 'Ĺ', + Lambda: 'Λ', + Lang: '⟪', + Laplacetrf: 'ℒ', + Larr: '↞', + Lcaron: 'Ľ', + Lcedil: 'Ļ', + Lcy: 'Л', + LeftAngleBracket: '⟨', + LeftArrow: '←', + LeftArrowBar: '⇤', + LeftArrowRightArrow: '⇆', + LeftCeiling: '⌈', + LeftDoubleBracket: '⟦', + LeftDownTeeVector: '⥡', + LeftDownVector: '⇃', + LeftDownVectorBar: '⥙', + LeftFloor: '⌊', + LeftRightArrow: '↔', + LeftRightVector: '⥎', + LeftTee: '⊣', + LeftTeeArrow: '↤', + LeftTeeVector: '⥚', + LeftTriangle: '⊲', + LeftTriangleBar: '⧏', + LeftTriangleEqual: '⊴', + LeftUpDownVector: '⥑', + LeftUpTeeVector: '⥠', + LeftUpVector: '↿', + LeftUpVectorBar: '⥘', + LeftVector: '↼', + LeftVectorBar: '⥒', + Leftarrow: '⇐', + Leftrightarrow: '⇔', + LessEqualGreater: '⋚', + LessFullEqual: '≦', + LessGreater: '≶', + LessLess: '⪡', + LessSlantEqual: '⩽', + LessTilde: '≲', + Lfr: '𝔏', + Ll: '⋘', + Lleftarrow: '⇚', + Lmidot: 'Ŀ', + LongLeftArrow: '⟵', + LongLeftRightArrow: '⟷', + LongRightArrow: '⟶', + Longleftarrow: '⟸', + Longleftrightarrow: '⟺', + Longrightarrow: '⟹', + Lopf: '𝕃', + LowerLeftArrow: '↙', + LowerRightArrow: '↘', + Lscr: 'ℒ', + Lsh: '↰', + Lstrok: 'Ł', + Lt: '≪', + Map: '⤅', + Mcy: 'М', + MediumSpace: ' ', + Mellintrf: 'ℳ', + Mfr: '𝔐', + MinusPlus: '∓', + Mopf: '𝕄', + Mscr: 'ℳ', + Mu: 'Μ', + NJcy: 'Њ', + Nacute: 'Ń', + Ncaron: 'Ň', + Ncedil: 'Ņ', + Ncy: 'Н', + NegativeMediumSpace: '​', + NegativeThickSpace: '​', + NegativeThinSpace: '​', + NegativeVeryThinSpace: '​', + NestedGreaterGreater: '≫', + NestedLessLess: '≪', + NewLine: '\n', + Nfr: '𝔑', + NoBreak: '⁠', + NonBreakingSpace: ' ', + Nopf: 'ℕ', + Not: '⫬', + NotCongruent: '≢', + NotCupCap: '≭', + NotDoubleVerticalBar: '∦', + NotElement: '∉', + NotEqual: '≠', + NotEqualTilde: '≂̸', + NotExists: '∄', + NotGreater: '≯', + NotGreaterEqual: '≱', + NotGreaterFullEqual: '≧̸', + NotGreaterGreater: '≫̸', + NotGreaterLess: '≹', + NotGreaterSlantEqual: '⩾̸', + NotGreaterTilde: '≵', + NotHumpDownHump: '≎̸', + NotHumpEqual: '≏̸', + NotLeftTriangle: '⋪', + NotLeftTriangleBar: '⧏̸', + NotLeftTriangleEqual: '⋬', + NotLess: '≮', + NotLessEqual: '≰', + NotLessGreater: '≸', + NotLessLess: '≪̸', + NotLessSlantEqual: '⩽̸', + NotLessTilde: '≴', + NotNestedGreaterGreater: '⪢̸', + NotNestedLessLess: '⪡̸', + NotPrecedes: '⊀', + NotPrecedesEqual: '⪯̸', + NotPrecedesSlantEqual: '⋠', + NotReverseElement: '∌', + NotRightTriangle: '⋫', + NotRightTriangleBar: '⧐̸', + NotRightTriangleEqual: '⋭', + NotSquareSubset: '⊏̸', + NotSquareSubsetEqual: '⋢', + NotSquareSuperset: '⊐̸', + NotSquareSupersetEqual: '⋣', + NotSubset: '⊂⃒', + NotSubsetEqual: '⊈', + NotSucceeds: '⊁', + NotSucceedsEqual: '⪰̸', + NotSucceedsSlantEqual: '⋡', + NotSucceedsTilde: '≿̸', + NotSuperset: '⊃⃒', + NotSupersetEqual: '⊉', + NotTilde: '≁', + NotTildeEqual: '≄', + NotTildeFullEqual: '≇', + NotTildeTilde: '≉', + NotVerticalBar: '∤', + Nscr: '𝒩', + Ntilde: 'Ñ', + Nu: 'Ν', + OElig: 'Œ', + Oacute: 'Ó', + Ocirc: 'Ô', + Ocy: 'О', + Odblac: 'Ő', + Ofr: '𝔒', + Ograve: 'Ò', + Omacr: 'Ō', + Omega: 'Ω', + Omicron: 'Ο', + Oopf: '𝕆', + OpenCurlyDoubleQuote: '“', + OpenCurlyQuote: '‘', + Or: '⩔', + Oscr: '𝒪', + Oslash: 'Ø', + Otilde: 'Õ', + Otimes: '⨷', + Ouml: 'Ö', + OverBar: '‾', + OverBrace: '⏞', + OverBracket: '⎴', + OverParenthesis: '⏜', + PartialD: '∂', + Pcy: 'П', + Pfr: '𝔓', + Phi: 'Φ', + Pi: 'Π', + PlusMinus: '±', + Poincareplane: 'ℌ', + Popf: 'ℙ', + Pr: '⪻', + Precedes: '≺', + PrecedesEqual: '⪯', + PrecedesSlantEqual: '≼', + PrecedesTilde: '≾', + Prime: '″', + Product: '∏', + Proportion: '∷', + Proportional: '∝', + Pscr: '𝒫', + Psi: 'Ψ', + QUOT: '"', + Qfr: '𝔔', + Qopf: 'ℚ', + Qscr: '𝒬', + RBarr: '⤐', + REG: '®', + Racute: 'Ŕ', + Rang: '⟫', + Rarr: '↠', + Rarrtl: '⤖', + Rcaron: 'Ř', + Rcedil: 'Ŗ', + Rcy: 'Р', + Re: 'ℜ', + ReverseElement: '∋', + ReverseEquilibrium: '⇋', + ReverseUpEquilibrium: '⥯', + Rfr: 'ℜ', + Rho: 'Ρ', + RightAngleBracket: '⟩', + RightArrow: '→', + RightArrowBar: '⇥', + RightArrowLeftArrow: '⇄', + RightCeiling: '⌉', + RightDoubleBracket: '⟧', + RightDownTeeVector: '⥝', + RightDownVector: '⇂', + RightDownVectorBar: '⥕', + RightFloor: '⌋', + RightTee: '⊢', + RightTeeArrow: '↦', + RightTeeVector: '⥛', + RightTriangle: '⊳', + RightTriangleBar: '⧐', + RightTriangleEqual: '⊵', + RightUpDownVector: '⥏', + RightUpTeeVector: '⥜', + RightUpVector: '↾', + RightUpVectorBar: '⥔', + RightVector: '⇀', + RightVectorBar: '⥓', + Rightarrow: '⇒', + Ropf: 'ℝ', + RoundImplies: '⥰', + Rrightarrow: '⇛', + Rscr: 'ℛ', + Rsh: '↱', + RuleDelayed: '⧴', + SHCHcy: 'Щ', + SHcy: 'Ш', + SOFTcy: 'Ь', + Sacute: 'Ś', + Sc: '⪼', + Scaron: 'Š', + Scedil: 'Ş', + Scirc: 'Ŝ', + Scy: 'С', + Sfr: '𝔖', + ShortDownArrow: '↓', + ShortLeftArrow: '←', + ShortRightArrow: '→', + ShortUpArrow: '↑', + Sigma: 'Σ', + SmallCircle: '∘', + Sopf: '𝕊', + Sqrt: '√', + Square: '□', + SquareIntersection: '⊓', + SquareSubset: '⊏', + SquareSubsetEqual: '⊑', + SquareSuperset: '⊐', + SquareSupersetEqual: '⊒', + SquareUnion: '⊔', + Sscr: '𝒮', + Star: '⋆', + Sub: '⋐', + Subset: '⋐', + SubsetEqual: '⊆', + Succeeds: '≻', + SucceedsEqual: '⪰', + SucceedsSlantEqual: '≽', + SucceedsTilde: '≿', + SuchThat: '∋', + Sum: '∑', + Sup: '⋑', + Superset: '⊃', + SupersetEqual: '⊇', + Supset: '⋑', + THORN: 'Þ', + TRADE: '™', + TSHcy: 'Ћ', + TScy: 'Ц', + Tab: '\t', + Tau: 'Τ', + Tcaron: 'Ť', + Tcedil: 'Ţ', + Tcy: 'Т', + Tfr: '𝔗', + Therefore: '∴', + Theta: 'Θ', + ThickSpace: '  ', + ThinSpace: ' ', + Tilde: '∼', + TildeEqual: '≃', + TildeFullEqual: '≅', + TildeTilde: '≈', + Topf: '𝕋', + TripleDot: '⃛', + Tscr: '𝒯', + Tstrok: 'Ŧ', + Uacute: 'Ú', + Uarr: '↟', + Uarrocir: '⥉', + Ubrcy: 'Ў', + Ubreve: 'Ŭ', + Ucirc: 'Û', + Ucy: 'У', + Udblac: 'Ű', + Ufr: '𝔘', + Ugrave: 'Ù', + Umacr: 'Ū', + UnderBar: '_', + UnderBrace: '⏟', + UnderBracket: '⎵', + UnderParenthesis: '⏝', + Union: '⋃', + UnionPlus: '⊎', + Uogon: 'Ų', + Uopf: '𝕌', + UpArrow: '↑', + UpArrowBar: '⤒', + UpArrowDownArrow: '⇅', + UpDownArrow: '↕', + UpEquilibrium: '⥮', + UpTee: '⊥', + UpTeeArrow: '↥', + Uparrow: '⇑', + Updownarrow: '⇕', + UpperLeftArrow: '↖', + UpperRightArrow: '↗', + Upsi: 'ϒ', + Upsilon: 'Υ', + Uring: 'Ů', + Uscr: '𝒰', + Utilde: 'Ũ', + Uuml: 'Ü', + VDash: '⊫', + Vbar: '⫫', + Vcy: 'В', + Vdash: '⊩', + Vdashl: '⫦', + Vee: '⋁', + Verbar: '‖', + Vert: '‖', + VerticalBar: '∣', + VerticalLine: '|', + VerticalSeparator: '❘', + VerticalTilde: '≀', + VeryThinSpace: ' ', + Vfr: '𝔙', + Vopf: '𝕍', + Vscr: '𝒱', + Vvdash: '⊪', + Wcirc: 'Ŵ', + Wedge: '⋀', + Wfr: '𝔚', + Wopf: '𝕎', + Wscr: '𝒲', + Xfr: '𝔛', + Xi: 'Ξ', + Xopf: '𝕏', + Xscr: '𝒳', + YAcy: 'Я', + YIcy: 'Ї', + YUcy: 'Ю', + Yacute: 'Ý', + Ycirc: 'Ŷ', + Ycy: 'Ы', + Yfr: '𝔜', + Yopf: '𝕐', + Yscr: '𝒴', + Yuml: 'Ÿ', + ZHcy: 'Ж', + Zacute: 'Ź', + Zcaron: 'Ž', + Zcy: 'З', + Zdot: 'Ż', + ZeroWidthSpace: '​', + Zeta: 'Ζ', + Zfr: 'ℨ', + Zopf: 'ℤ', + Zscr: '𝒵', + aacute: 'á', + abreve: 'ă', + ac: '∾', + acE: '∾̳', + acd: '∿', + acirc: 'â', + acute: '´', + acy: 'а', + aelig: 'æ', + af: '⁡', + afr: '𝔞', + agrave: 'à', + alefsym: 'ℵ', + aleph: 'ℵ', + alpha: 'α', + amacr: 'ā', + amalg: '⨿', + amp: '&', + and: '∧', + andand: '⩕', + andd: '⩜', + andslope: '⩘', + andv: '⩚', + ang: '∠', + ange: '⦤', + angle: '∠', + angmsd: '∡', + angmsdaa: '⦨', + angmsdab: '⦩', + angmsdac: '⦪', + angmsdad: '⦫', + angmsdae: '⦬', + angmsdaf: '⦭', + angmsdag: '⦮', + angmsdah: '⦯', + angrt: '∟', + angrtvb: '⊾', + angrtvbd: '⦝', + angsph: '∢', + angst: 'Å', + angzarr: '⍼', + aogon: 'ą', + aopf: '𝕒', + ap: '≈', + apE: '⩰', + apacir: '⩯', + ape: '≊', + apid: '≋', + apos: "'", + approx: '≈', + approxeq: '≊', + aring: 'å', + ascr: '𝒶', + ast: '*', + asymp: '≈', + asympeq: '≍', + atilde: 'ã', + auml: 'ä', + awconint: '∳', + awint: '⨑', + bNot: '⫭', + backcong: '≌', + backepsilon: '϶', + backprime: '‵', + backsim: '∽', + backsimeq: '⋍', + barvee: '⊽', + barwed: '⌅', + barwedge: '⌅', + bbrk: '⎵', + bbrktbrk: '⎶', + bcong: '≌', + bcy: 'б', + bdquo: '„', + becaus: '∵', + because: '∵', + bemptyv: '⦰', + bepsi: '϶', + bernou: 'ℬ', + beta: 'β', + beth: 'ℶ', + between: '≬', + bfr: '𝔟', + bigcap: '⋂', + bigcirc: '◯', + bigcup: '⋃', + bigodot: '⨀', + bigoplus: '⨁', + bigotimes: '⨂', + bigsqcup: '⨆', + bigstar: '★', + bigtriangledown: '▽', + bigtriangleup: '△', + biguplus: '⨄', + bigvee: '⋁', + bigwedge: '⋀', + bkarow: '⤍', + blacklozenge: '⧫', + blacksquare: '▪', + blacktriangle: '▴', + blacktriangledown: '▾', + blacktriangleleft: '◂', + blacktriangleright: '▸', + blank: '␣', + blk12: '▒', + blk14: '░', + blk34: '▓', + block: '█', + bne: '=⃥', + bnequiv: '≡⃥', + bnot: '⌐', + bopf: '𝕓', + bot: '⊥', + bottom: '⊥', + bowtie: '⋈', + boxDL: '╗', + boxDR: '╔', + boxDl: '╖', + boxDr: '╓', + boxH: '═', + boxHD: '╦', + boxHU: '╩', + boxHd: '╤', + boxHu: '╧', + boxUL: '╝', + boxUR: '╚', + boxUl: '╜', + boxUr: '╙', + boxV: '║', + boxVH: '╬', + boxVL: '╣', + boxVR: '╠', + boxVh: '╫', + boxVl: '╢', + boxVr: '╟', + boxbox: '⧉', + boxdL: '╕', + boxdR: '╒', + boxdl: '┐', + boxdr: '┌', + boxh: '─', + boxhD: '╥', + boxhU: '╨', + boxhd: '┬', + boxhu: '┴', + boxminus: '⊟', + boxplus: '⊞', + boxtimes: '⊠', + boxuL: '╛', + boxuR: '╘', + boxul: '┘', + boxur: '└', + boxv: '│', + boxvH: '╪', + boxvL: '╡', + boxvR: '╞', + boxvh: '┼', + boxvl: '┤', + boxvr: '├', + bprime: '‵', + breve: '˘', + brvbar: '¦', + bscr: '𝒷', + bsemi: '⁏', + bsim: '∽', + bsime: '⋍', + bsol: '\\', + bsolb: '⧅', + bsolhsub: '⟈', + bull: '•', + bullet: '•', + bump: '≎', + bumpE: '⪮', + bumpe: '≏', + bumpeq: '≏', + cacute: 'ć', + cap: '∩', + capand: '⩄', + capbrcup: '⩉', + capcap: '⩋', + capcup: '⩇', + capdot: '⩀', + caps: '∩︀', + caret: '⁁', + caron: 'ˇ', + ccaps: '⩍', + ccaron: 'č', + ccedil: 'ç', + ccirc: 'ĉ', + ccups: '⩌', + ccupssm: '⩐', + cdot: 'ċ', + cedil: '¸', + cemptyv: '⦲', + cent: '¢', + centerdot: '·', + cfr: '𝔠', + chcy: 'ч', + check: '✓', + checkmark: '✓', + chi: 'χ', + cir: '○', + cirE: '⧃', + circ: 'ˆ', + circeq: '≗', + circlearrowleft: '↺', + circlearrowright: '↻', + circledR: '®', + circledS: 'Ⓢ', + circledast: '⊛', + circledcirc: '⊚', + circleddash: '⊝', + cire: '≗', + cirfnint: '⨐', + cirmid: '⫯', + cirscir: '⧂', + clubs: '♣', + clubsuit: '♣', + colon: ':', + colone: '≔', + coloneq: '≔', + comma: ',', + commat: '@', + comp: '∁', + compfn: '∘', + complement: '∁', + complexes: 'ℂ', + cong: '≅', + congdot: '⩭', + conint: '∮', + copf: '𝕔', + coprod: '∐', + copy: '©', + copysr: '℗', + crarr: '↵', + cross: '✗', + cscr: '𝒸', + csub: '⫏', + csube: '⫑', + csup: '⫐', + csupe: '⫒', + ctdot: '⋯', + cudarrl: '⤸', + cudarrr: '⤵', + cuepr: '⋞', + cuesc: '⋟', + cularr: '↶', + cularrp: '⤽', + cup: '∪', + cupbrcap: '⩈', + cupcap: '⩆', + cupcup: '⩊', + cupdot: '⊍', + cupor: '⩅', + cups: '∪︀', + curarr: '↷', + curarrm: '⤼', + curlyeqprec: '⋞', + curlyeqsucc: '⋟', + curlyvee: '⋎', + curlywedge: '⋏', + curren: '¤', + curvearrowleft: '↶', + curvearrowright: '↷', + cuvee: '⋎', + cuwed: '⋏', + cwconint: '∲', + cwint: '∱', + cylcty: '⌭', + dArr: '⇓', + dHar: '⥥', + dagger: '†', + daleth: 'ℸ', + darr: '↓', + dash: '‐', + dashv: '⊣', + dbkarow: '⤏', + dblac: '˝', + dcaron: 'ď', + dcy: 'д', + dd: 'ⅆ', + ddagger: '‡', + ddarr: '⇊', + ddotseq: '⩷', + deg: '°', + delta: 'δ', + demptyv: '⦱', + dfisht: '⥿', + dfr: '𝔡', + dharl: '⇃', + dharr: '⇂', + diam: '⋄', + diamond: '⋄', + diamondsuit: '♦', + diams: '♦', + die: '¨', + digamma: 'ϝ', + disin: '⋲', + div: '÷', + divide: '÷', + divideontimes: '⋇', + divonx: '⋇', + djcy: 'ђ', + dlcorn: '⌞', + dlcrop: '⌍', + dollar: '$', + dopf: '𝕕', + dot: '˙', + doteq: '≐', + doteqdot: '≑', + dotminus: '∸', + dotplus: '∔', + dotsquare: '⊡', + doublebarwedge: '⌆', + downarrow: '↓', + downdownarrows: '⇊', + downharpoonleft: '⇃', + downharpoonright: '⇂', + drbkarow: '⤐', + drcorn: '⌟', + drcrop: '⌌', + dscr: '𝒹', + dscy: 'ѕ', + dsol: '⧶', + dstrok: 'đ', + dtdot: '⋱', + dtri: '▿', + dtrif: '▾', + duarr: '⇵', + duhar: '⥯', + dwangle: '⦦', + dzcy: 'џ', + dzigrarr: '⟿', + eDDot: '⩷', + eDot: '≑', + eacute: 'é', + easter: '⩮', + ecaron: 'ě', + ecir: '≖', + ecirc: 'ê', + ecolon: '≕', + ecy: 'э', + edot: 'ė', + ee: 'ⅇ', + efDot: '≒', + efr: '𝔢', + eg: '⪚', + egrave: 'è', + egs: '⪖', + egsdot: '⪘', + el: '⪙', + elinters: '⏧', + ell: 'ℓ', + els: '⪕', + elsdot: '⪗', + emacr: 'ē', + empty: '∅', + emptyset: '∅', + emptyv: '∅', + emsp13: ' ', + emsp14: ' ', + emsp: ' ', + eng: 'ŋ', + ensp: ' ', + eogon: 'ę', + eopf: '𝕖', + epar: '⋕', + eparsl: '⧣', + eplus: '⩱', + epsi: 'ε', + epsilon: 'ε', + epsiv: 'ϵ', + eqcirc: '≖', + eqcolon: '≕', + eqsim: '≂', + eqslantgtr: '⪖', + eqslantless: '⪕', + equals: '=', + equest: '≟', + equiv: '≡', + equivDD: '⩸', + eqvparsl: '⧥', + erDot: '≓', + erarr: '⥱', + escr: 'ℯ', + esdot: '≐', + esim: '≂', + eta: 'η', + eth: 'ð', + euml: 'ë', + euro: '€', + excl: '!', + exist: '∃', + expectation: 'ℰ', + exponentiale: 'ⅇ', + fallingdotseq: '≒', + fcy: 'ф', + female: '♀', + ffilig: 'ffi', + fflig: 'ff', + ffllig: 'ffl', + ffr: '𝔣', + filig: 'fi', + fjlig: 'fj', + flat: '♭', + fllig: 'fl', + fltns: '▱', + fnof: 'ƒ', + fopf: '𝕗', + forall: '∀', + fork: '⋔', + forkv: '⫙', + fpartint: '⨍', + frac12: '½', + frac13: '⅓', + frac14: '¼', + frac15: '⅕', + frac16: '⅙', + frac18: '⅛', + frac23: '⅔', + frac25: '⅖', + frac34: '¾', + frac35: '⅗', + frac38: '⅜', + frac45: '⅘', + frac56: '⅚', + frac58: '⅝', + frac78: '⅞', + frasl: '⁄', + frown: '⌢', + fscr: '𝒻', + gE: '≧', + gEl: '⪌', + gacute: 'ǵ', + gamma: 'γ', + gammad: 'ϝ', + gap: '⪆', + gbreve: 'ğ', + gcirc: 'ĝ', + gcy: 'г', + gdot: 'ġ', + ge: '≥', + gel: '⋛', + geq: '≥', + geqq: '≧', + geqslant: '⩾', + ges: '⩾', + gescc: '⪩', + gesdot: '⪀', + gesdoto: '⪂', + gesdotol: '⪄', + gesl: '⋛︀', + gesles: '⪔', + gfr: '𝔤', + gg: '≫', + ggg: '⋙', + gimel: 'ℷ', + gjcy: 'ѓ', + gl: '≷', + glE: '⪒', + gla: '⪥', + glj: '⪤', + gnE: '≩', + gnap: '⪊', + gnapprox: '⪊', + gne: '⪈', + gneq: '⪈', + gneqq: '≩', + gnsim: '⋧', + gopf: '𝕘', + grave: '`', + gscr: 'ℊ', + gsim: '≳', + gsime: '⪎', + gsiml: '⪐', + gt: '>', + gtcc: '⪧', + gtcir: '⩺', + gtdot: '⋗', + gtlPar: '⦕', + gtquest: '⩼', + gtrapprox: '⪆', + gtrarr: '⥸', + gtrdot: '⋗', + gtreqless: '⋛', + gtreqqless: '⪌', + gtrless: '≷', + gtrsim: '≳', + gvertneqq: '≩︀', + gvnE: '≩︀', + hArr: '⇔', + hairsp: ' ', + half: '½', + hamilt: 'ℋ', + hardcy: 'ъ', + harr: '↔', + harrcir: '⥈', + harrw: '↭', + hbar: 'ℏ', + hcirc: 'ĥ', + hearts: '♥', + heartsuit: '♥', + hellip: '…', + hercon: '⊹', + hfr: '𝔥', + hksearow: '⤥', + hkswarow: '⤦', + hoarr: '⇿', + homtht: '∻', + hookleftarrow: '↩', + hookrightarrow: '↪', + hopf: '𝕙', + horbar: '―', + hscr: '𝒽', + hslash: 'ℏ', + hstrok: 'ħ', + hybull: '⁃', + hyphen: '‐', + iacute: 'í', + ic: '⁣', + icirc: 'î', + icy: 'и', + iecy: 'е', + iexcl: '¡', + iff: '⇔', + ifr: '𝔦', + igrave: 'ì', + ii: 'ⅈ', + iiiint: '⨌', + iiint: '∭', + iinfin: '⧜', + iiota: '℩', + ijlig: 'ij', + imacr: 'ī', + image: 'ℑ', + imagline: 'ℐ', + imagpart: 'ℑ', + imath: 'ı', + imof: '⊷', + imped: 'Ƶ', + in: '∈', + incare: '℅', + infin: '∞', + infintie: '⧝', + inodot: 'ı', + int: '∫', + intcal: '⊺', + integers: 'ℤ', + intercal: '⊺', + intlarhk: '⨗', + intprod: '⨼', + iocy: 'ё', + iogon: 'į', + iopf: '𝕚', + iota: 'ι', + iprod: '⨼', + iquest: '¿', + iscr: '𝒾', + isin: '∈', + isinE: '⋹', + isindot: '⋵', + isins: '⋴', + isinsv: '⋳', + isinv: '∈', + it: '⁢', + itilde: 'ĩ', + iukcy: 'і', + iuml: 'ï', + jcirc: 'ĵ', + jcy: 'й', + jfr: '𝔧', + jmath: 'ȷ', + jopf: '𝕛', + jscr: '𝒿', + jsercy: 'ј', + jukcy: 'є', + kappa: 'κ', + kappav: 'ϰ', + kcedil: 'ķ', + kcy: 'к', + kfr: '𝔨', + kgreen: 'ĸ', + khcy: 'х', + kjcy: 'ќ', + kopf: '𝕜', + kscr: '𝓀', + lAarr: '⇚', + lArr: '⇐', + lAtail: '⤛', + lBarr: '⤎', + lE: '≦', + lEg: '⪋', + lHar: '⥢', + lacute: 'ĺ', + laemptyv: '⦴', + lagran: 'ℒ', + lambda: 'λ', + lang: '⟨', + langd: '⦑', + langle: '⟨', + lap: '⪅', + laquo: '«', + larr: '←', + larrb: '⇤', + larrbfs: '⤟', + larrfs: '⤝', + larrhk: '↩', + larrlp: '↫', + larrpl: '⤹', + larrsim: '⥳', + larrtl: '↢', + lat: '⪫', + latail: '⤙', + late: '⪭', + lates: '⪭︀', + lbarr: '⤌', + lbbrk: '❲', + lbrace: '{', + lbrack: '[', + lbrke: '⦋', + lbrksld: '⦏', + lbrkslu: '⦍', + lcaron: 'ľ', + lcedil: 'ļ', + lceil: '⌈', + lcub: '{', + lcy: 'л', + ldca: '⤶', + ldquo: '“', + ldquor: '„', + ldrdhar: '⥧', + ldrushar: '⥋', + ldsh: '↲', + le: '≤', + leftarrow: '←', + leftarrowtail: '↢', + leftharpoondown: '↽', + leftharpoonup: '↼', + leftleftarrows: '⇇', + leftrightarrow: '↔', + leftrightarrows: '⇆', + leftrightharpoons: '⇋', + leftrightsquigarrow: '↭', + leftthreetimes: '⋋', + leg: '⋚', + leq: '≤', + leqq: '≦', + leqslant: '⩽', + les: '⩽', + lescc: '⪨', + lesdot: '⩿', + lesdoto: '⪁', + lesdotor: '⪃', + lesg: '⋚︀', + lesges: '⪓', + lessapprox: '⪅', + lessdot: '⋖', + lesseqgtr: '⋚', + lesseqqgtr: '⪋', + lessgtr: '≶', + lesssim: '≲', + lfisht: '⥼', + lfloor: '⌊', + lfr: '𝔩', + lg: '≶', + lgE: '⪑', + lhard: '↽', + lharu: '↼', + lharul: '⥪', + lhblk: '▄', + ljcy: 'љ', + ll: '≪', + llarr: '⇇', + llcorner: '⌞', + llhard: '⥫', + lltri: '◺', + lmidot: 'ŀ', + lmoust: '⎰', + lmoustache: '⎰', + lnE: '≨', + lnap: '⪉', + lnapprox: '⪉', + lne: '⪇', + lneq: '⪇', + lneqq: '≨', + lnsim: '⋦', + loang: '⟬', + loarr: '⇽', + lobrk: '⟦', + longleftarrow: '⟵', + longleftrightarrow: '⟷', + longmapsto: '⟼', + longrightarrow: '⟶', + looparrowleft: '↫', + looparrowright: '↬', + lopar: '⦅', + lopf: '𝕝', + loplus: '⨭', + lotimes: '⨴', + lowast: '∗', + lowbar: '_', + loz: '◊', + lozenge: '◊', + lozf: '⧫', + lpar: '(', + lparlt: '⦓', + lrarr: '⇆', + lrcorner: '⌟', + lrhar: '⇋', + lrhard: '⥭', + lrm: '‎', + lrtri: '⊿', + lsaquo: '‹', + lscr: '𝓁', + lsh: '↰', + lsim: '≲', + lsime: '⪍', + lsimg: '⪏', + lsqb: '[', + lsquo: '‘', + lsquor: '‚', + lstrok: 'ł', + lt: '<', + ltcc: '⪦', + ltcir: '⩹', + ltdot: '⋖', + lthree: '⋋', + ltimes: '⋉', + ltlarr: '⥶', + ltquest: '⩻', + ltrPar: '⦖', + ltri: '◃', + ltrie: '⊴', + ltrif: '◂', + lurdshar: '⥊', + luruhar: '⥦', + lvertneqq: '≨︀', + lvnE: '≨︀', + mDDot: '∺', + macr: '¯', + male: '♂', + malt: '✠', + maltese: '✠', + map: '↦', + mapsto: '↦', + mapstodown: '↧', + mapstoleft: '↤', + mapstoup: '↥', + marker: '▮', + mcomma: '⨩', + mcy: 'м', + mdash: '—', + measuredangle: '∡', + mfr: '𝔪', + mho: '℧', + micro: 'µ', + mid: '∣', + midast: '*', + midcir: '⫰', + middot: '·', + minus: '−', + minusb: '⊟', + minusd: '∸', + minusdu: '⨪', + mlcp: '⫛', + mldr: '…', + mnplus: '∓', + models: '⊧', + mopf: '𝕞', + mp: '∓', + mscr: '𝓂', + mstpos: '∾', + mu: 'μ', + multimap: '⊸', + mumap: '⊸', + nGg: '⋙̸', + nGt: '≫⃒', + nGtv: '≫̸', + nLeftarrow: '⇍', + nLeftrightarrow: '⇎', + nLl: '⋘̸', + nLt: '≪⃒', + nLtv: '≪̸', + nRightarrow: '⇏', + nVDash: '⊯', + nVdash: '⊮', + nabla: '∇', + nacute: 'ń', + nang: '∠⃒', + nap: '≉', + napE: '⩰̸', + napid: '≋̸', + napos: 'ʼn', + napprox: '≉', + natur: '♮', + natural: '♮', + naturals: 'ℕ', + nbsp: ' ', + nbump: '≎̸', + nbumpe: '≏̸', + ncap: '⩃', + ncaron: 'ň', + ncedil: 'ņ', + ncong: '≇', + ncongdot: '⩭̸', + ncup: '⩂', + ncy: 'н', + ndash: '–', + ne: '≠', + neArr: '⇗', + nearhk: '⤤', + nearr: '↗', + nearrow: '↗', + nedot: '≐̸', + nequiv: '≢', + nesear: '⤨', + nesim: '≂̸', + nexist: '∄', + nexists: '∄', + nfr: '𝔫', + ngE: '≧̸', + nge: '≱', + ngeq: '≱', + ngeqq: '≧̸', + ngeqslant: '⩾̸', + nges: '⩾̸', + ngsim: '≵', + ngt: '≯', + ngtr: '≯', + nhArr: '⇎', + nharr: '↮', + nhpar: '⫲', + ni: '∋', + nis: '⋼', + nisd: '⋺', + niv: '∋', + njcy: 'њ', + nlArr: '⇍', + nlE: '≦̸', + nlarr: '↚', + nldr: '‥', + nle: '≰', + nleftarrow: '↚', + nleftrightarrow: '↮', + nleq: '≰', + nleqq: '≦̸', + nleqslant: '⩽̸', + nles: '⩽̸', + nless: '≮', + nlsim: '≴', + nlt: '≮', + nltri: '⋪', + nltrie: '⋬', + nmid: '∤', + nopf: '𝕟', + not: '¬', + notin: '∉', + notinE: '⋹̸', + notindot: '⋵̸', + notinva: '∉', + notinvb: '⋷', + notinvc: '⋶', + notni: '∌', + notniva: '∌', + notnivb: '⋾', + notnivc: '⋽', + npar: '∦', + nparallel: '∦', + nparsl: '⫽⃥', + npart: '∂̸', + npolint: '⨔', + npr: '⊀', + nprcue: '⋠', + npre: '⪯̸', + nprec: '⊀', + npreceq: '⪯̸', + nrArr: '⇏', + nrarr: '↛', + nrarrc: '⤳̸', + nrarrw: '↝̸', + nrightarrow: '↛', + nrtri: '⋫', + nrtrie: '⋭', + nsc: '⊁', + nsccue: '⋡', + nsce: '⪰̸', + nscr: '𝓃', + nshortmid: '∤', + nshortparallel: '∦', + nsim: '≁', + nsime: '≄', + nsimeq: '≄', + nsmid: '∤', + nspar: '∦', + nsqsube: '⋢', + nsqsupe: '⋣', + nsub: '⊄', + nsubE: '⫅̸', + nsube: '⊈', + nsubset: '⊂⃒', + nsubseteq: '⊈', + nsubseteqq: '⫅̸', + nsucc: '⊁', + nsucceq: '⪰̸', + nsup: '⊅', + nsupE: '⫆̸', + nsupe: '⊉', + nsupset: '⊃⃒', + nsupseteq: '⊉', + nsupseteqq: '⫆̸', + ntgl: '≹', + ntilde: 'ñ', + ntlg: '≸', + ntriangleleft: '⋪', + ntrianglelefteq: '⋬', + ntriangleright: '⋫', + ntrianglerighteq: '⋭', + nu: 'ν', + num: '#', + numero: '№', + numsp: ' ', + nvDash: '⊭', + nvHarr: '⤄', + nvap: '≍⃒', + nvdash: '⊬', + nvge: '≥⃒', + nvgt: '>⃒', + nvinfin: '⧞', + nvlArr: '⤂', + nvle: '≤⃒', + nvlt: '<⃒', + nvltrie: '⊴⃒', + nvrArr: '⤃', + nvrtrie: '⊵⃒', + nvsim: '∼⃒', + nwArr: '⇖', + nwarhk: '⤣', + nwarr: '↖', + nwarrow: '↖', + nwnear: '⤧', + oS: 'Ⓢ', + oacute: 'ó', + oast: '⊛', + ocir: '⊚', + ocirc: 'ô', + ocy: 'о', + odash: '⊝', + odblac: 'ő', + odiv: '⨸', + odot: '⊙', + odsold: '⦼', + oelig: 'œ', + ofcir: '⦿', + ofr: '𝔬', + ogon: '˛', + ograve: 'ò', + ogt: '⧁', + ohbar: '⦵', + ohm: 'Ω', + oint: '∮', + olarr: '↺', + olcir: '⦾', + olcross: '⦻', + oline: '‾', + olt: '⧀', + omacr: 'ō', + omega: 'ω', + omicron: 'ο', + omid: '⦶', + ominus: '⊖', + oopf: '𝕠', + opar: '⦷', + operp: '⦹', + oplus: '⊕', + or: '∨', + orarr: '↻', + ord: '⩝', + order: 'ℴ', + orderof: 'ℴ', + ordf: 'ª', + ordm: 'º', + origof: '⊶', + oror: '⩖', + orslope: '⩗', + orv: '⩛', + oscr: 'ℴ', + oslash: 'ø', + osol: '⊘', + otilde: 'õ', + otimes: '⊗', + otimesas: '⨶', + ouml: 'ö', + ovbar: '⌽', + par: '∥', + para: '¶', + parallel: '∥', + parsim: '⫳', + parsl: '⫽', + part: '∂', + pcy: 'п', + percnt: '%', + period: '.', + permil: '‰', + perp: '⊥', + pertenk: '‱', + pfr: '𝔭', + phi: 'φ', + phiv: 'ϕ', + phmmat: 'ℳ', + phone: '☎', + pi: 'π', + pitchfork: '⋔', + piv: 'ϖ', + planck: 'ℏ', + planckh: 'ℎ', + plankv: 'ℏ', + plus: '+', + plusacir: '⨣', + plusb: '⊞', + pluscir: '⨢', + plusdo: '∔', + plusdu: '⨥', + pluse: '⩲', + plusmn: '±', + plussim: '⨦', + plustwo: '⨧', + pm: '±', + pointint: '⨕', + popf: '𝕡', + pound: '£', + pr: '≺', + prE: '⪳', + prap: '⪷', + prcue: '≼', + pre: '⪯', + prec: '≺', + precapprox: '⪷', + preccurlyeq: '≼', + preceq: '⪯', + precnapprox: '⪹', + precneqq: '⪵', + precnsim: '⋨', + precsim: '≾', + prime: '′', + primes: 'ℙ', + prnE: '⪵', + prnap: '⪹', + prnsim: '⋨', + prod: '∏', + profalar: '⌮', + profline: '⌒', + profsurf: '⌓', + prop: '∝', + propto: '∝', + prsim: '≾', + prurel: '⊰', + pscr: '𝓅', + psi: 'ψ', + puncsp: ' ', + qfr: '𝔮', + qint: '⨌', + qopf: '𝕢', + qprime: '⁗', + qscr: '𝓆', + quaternions: 'ℍ', + quatint: '⨖', + quest: '?', + questeq: '≟', + quot: '"', + rAarr: '⇛', + rArr: '⇒', + rAtail: '⤜', + rBarr: '⤏', + rHar: '⥤', + race: '∽̱', + racute: 'ŕ', + radic: '√', + raemptyv: '⦳', + rang: '⟩', + rangd: '⦒', + range: '⦥', + rangle: '⟩', + raquo: '»', + rarr: '→', + rarrap: '⥵', + rarrb: '⇥', + rarrbfs: '⤠', + rarrc: '⤳', + rarrfs: '⤞', + rarrhk: '↪', + rarrlp: '↬', + rarrpl: '⥅', + rarrsim: '⥴', + rarrtl: '↣', + rarrw: '↝', + ratail: '⤚', + ratio: '∶', + rationals: 'ℚ', + rbarr: '⤍', + rbbrk: '❳', + rbrace: '}', + rbrack: ']', + rbrke: '⦌', + rbrksld: '⦎', + rbrkslu: '⦐', + rcaron: 'ř', + rcedil: 'ŗ', + rceil: '⌉', + rcub: '}', + rcy: 'р', + rdca: '⤷', + rdldhar: '⥩', + rdquo: '”', + rdquor: '”', + rdsh: '↳', + real: 'ℜ', + realine: 'ℛ', + realpart: 'ℜ', + reals: 'ℝ', + rect: '▭', + reg: '®', + rfisht: '⥽', + rfloor: '⌋', + rfr: '𝔯', + rhard: '⇁', + rharu: '⇀', + rharul: '⥬', + rho: 'ρ', + rhov: 'ϱ', + rightarrow: '→', + rightarrowtail: '↣', + rightharpoondown: '⇁', + rightharpoonup: '⇀', + rightleftarrows: '⇄', + rightleftharpoons: '⇌', + rightrightarrows: '⇉', + rightsquigarrow: '↝', + rightthreetimes: '⋌', + ring: '˚', + risingdotseq: '≓', + rlarr: '⇄', + rlhar: '⇌', + rlm: '‏', + rmoust: '⎱', + rmoustache: '⎱', + rnmid: '⫮', + roang: '⟭', + roarr: '⇾', + robrk: '⟧', + ropar: '⦆', + ropf: '𝕣', + roplus: '⨮', + rotimes: '⨵', + rpar: ')', + rpargt: '⦔', + rppolint: '⨒', + rrarr: '⇉', + rsaquo: '›', + rscr: '𝓇', + rsh: '↱', + rsqb: ']', + rsquo: '’', + rsquor: '’', + rthree: '⋌', + rtimes: '⋊', + rtri: '▹', + rtrie: '⊵', + rtrif: '▸', + rtriltri: '⧎', + ruluhar: '⥨', + rx: '℞', + sacute: 'ś', + sbquo: '‚', + sc: '≻', + scE: '⪴', + scap: '⪸', + scaron: 'š', + sccue: '≽', + sce: '⪰', + scedil: 'ş', + scirc: 'ŝ', + scnE: '⪶', + scnap: '⪺', + scnsim: '⋩', + scpolint: '⨓', + scsim: '≿', + scy: 'с', + sdot: '⋅', + sdotb: '⊡', + sdote: '⩦', + seArr: '⇘', + searhk: '⤥', + searr: '↘', + searrow: '↘', + sect: '§', + semi: ';', + seswar: '⤩', + setminus: '∖', + setmn: '∖', + sext: '✶', + sfr: '𝔰', + sfrown: '⌢', + sharp: '♯', + shchcy: 'щ', + shcy: 'ш', + shortmid: '∣', + shortparallel: '∥', + shy: '­', + sigma: 'σ', + sigmaf: 'ς', + sigmav: 'ς', + sim: '∼', + simdot: '⩪', + sime: '≃', + simeq: '≃', + simg: '⪞', + simgE: '⪠', + siml: '⪝', + simlE: '⪟', + simne: '≆', + simplus: '⨤', + simrarr: '⥲', + slarr: '←', + smallsetminus: '∖', + smashp: '⨳', + smeparsl: '⧤', + smid: '∣', + smile: '⌣', + smt: '⪪', + smte: '⪬', + smtes: '⪬︀', + softcy: 'ь', + sol: '/', + solb: '⧄', + solbar: '⌿', + sopf: '𝕤', + spades: '♠', + spadesuit: '♠', + spar: '∥', + sqcap: '⊓', + sqcaps: '⊓︀', + sqcup: '⊔', + sqcups: '⊔︀', + sqsub: '⊏', + sqsube: '⊑', + sqsubset: '⊏', + sqsubseteq: '⊑', + sqsup: '⊐', + sqsupe: '⊒', + sqsupset: '⊐', + sqsupseteq: '⊒', + squ: '□', + square: '□', + squarf: '▪', + squf: '▪', + srarr: '→', + sscr: '𝓈', + ssetmn: '∖', + ssmile: '⌣', + sstarf: '⋆', + star: '☆', + starf: '★', + straightepsilon: 'ϵ', + straightphi: 'ϕ', + strns: '¯', + sub: '⊂', + subE: '⫅', + subdot: '⪽', + sube: '⊆', + subedot: '⫃', + submult: '⫁', + subnE: '⫋', + subne: '⊊', + subplus: '⪿', + subrarr: '⥹', + subset: '⊂', + subseteq: '⊆', + subseteqq: '⫅', + subsetneq: '⊊', + subsetneqq: '⫋', + subsim: '⫇', + subsub: '⫕', + subsup: '⫓', + succ: '≻', + succapprox: '⪸', + succcurlyeq: '≽', + succeq: '⪰', + succnapprox: '⪺', + succneqq: '⪶', + succnsim: '⋩', + succsim: '≿', + sum: '∑', + sung: '♪', + sup1: '¹', + sup2: '²', + sup3: '³', + sup: '⊃', + supE: '⫆', + supdot: '⪾', + supdsub: '⫘', + supe: '⊇', + supedot: '⫄', + suphsol: '⟉', + suphsub: '⫗', + suplarr: '⥻', + supmult: '⫂', + supnE: '⫌', + supne: '⊋', + supplus: '⫀', + supset: '⊃', + supseteq: '⊇', + supseteqq: '⫆', + supsetneq: '⊋', + supsetneqq: '⫌', + supsim: '⫈', + supsub: '⫔', + supsup: '⫖', + swArr: '⇙', + swarhk: '⤦', + swarr: '↙', + swarrow: '↙', + swnwar: '⤪', + szlig: 'ß', + target: '⌖', + tau: 'τ', + tbrk: '⎴', + tcaron: 'ť', + tcedil: 'ţ', + tcy: 'т', + tdot: '⃛', + telrec: '⌕', + tfr: '𝔱', + there4: '∴', + therefore: '∴', + theta: 'θ', + thetasym: 'ϑ', + thetav: 'ϑ', + thickapprox: '≈', + thicksim: '∼', + thinsp: ' ', + thkap: '≈', + thksim: '∼', + thorn: 'þ', + tilde: '˜', + times: '×', + timesb: '⊠', + timesbar: '⨱', + timesd: '⨰', + tint: '∭', + toea: '⤨', + top: '⊤', + topbot: '⌶', + topcir: '⫱', + topf: '𝕥', + topfork: '⫚', + tosa: '⤩', + tprime: '‴', + trade: '™', + triangle: '▵', + triangledown: '▿', + triangleleft: '◃', + trianglelefteq: '⊴', + triangleq: '≜', + triangleright: '▹', + trianglerighteq: '⊵', + tridot: '◬', + trie: '≜', + triminus: '⨺', + triplus: '⨹', + trisb: '⧍', + tritime: '⨻', + trpezium: '⏢', + tscr: '𝓉', + tscy: 'ц', + tshcy: 'ћ', + tstrok: 'ŧ', + twixt: '≬', + twoheadleftarrow: '↞', + twoheadrightarrow: '↠', + uArr: '⇑', + uHar: '⥣', + uacute: 'ú', + uarr: '↑', + ubrcy: 'ў', + ubreve: 'ŭ', + ucirc: 'û', + ucy: 'у', + udarr: '⇅', + udblac: 'ű', + udhar: '⥮', + ufisht: '⥾', + ufr: '𝔲', + ugrave: 'ù', + uharl: '↿', + uharr: '↾', + uhblk: '▀', + ulcorn: '⌜', + ulcorner: '⌜', + ulcrop: '⌏', + ultri: '◸', + umacr: 'ū', + uml: '¨', + uogon: 'ų', + uopf: '𝕦', + uparrow: '↑', + updownarrow: '↕', + upharpoonleft: '↿', + upharpoonright: '↾', + uplus: '⊎', + upsi: 'υ', + upsih: 'ϒ', + upsilon: 'υ', + upuparrows: '⇈', + urcorn: '⌝', + urcorner: '⌝', + urcrop: '⌎', + uring: 'ů', + urtri: '◹', + uscr: '𝓊', + utdot: '⋰', + utilde: 'ũ', + utri: '▵', + utrif: '▴', + uuarr: '⇈', + uuml: 'ü', + uwangle: '⦧', + vArr: '⇕', + vBar: '⫨', + vBarv: '⫩', + vDash: '⊨', + vangrt: '⦜', + varepsilon: 'ϵ', + varkappa: 'ϰ', + varnothing: '∅', + varphi: 'ϕ', + varpi: 'ϖ', + varpropto: '∝', + varr: '↕', + varrho: 'ϱ', + varsigma: 'ς', + varsubsetneq: '⊊︀', + varsubsetneqq: '⫋︀', + varsupsetneq: '⊋︀', + varsupsetneqq: '⫌︀', + vartheta: 'ϑ', + vartriangleleft: '⊲', + vartriangleright: '⊳', + vcy: 'в', + vdash: '⊢', + vee: '∨', + veebar: '⊻', + veeeq: '≚', + vellip: '⋮', + verbar: '|', + vert: '|', + vfr: '𝔳', + vltri: '⊲', + vnsub: '⊂⃒', + vnsup: '⊃⃒', + vopf: '𝕧', + vprop: '∝', + vrtri: '⊳', + vscr: '𝓋', + vsubnE: '⫋︀', + vsubne: '⊊︀', + vsupnE: '⫌︀', + vsupne: '⊋︀', + vzigzag: '⦚', + wcirc: 'ŵ', + wedbar: '⩟', + wedge: '∧', + wedgeq: '≙', + weierp: '℘', + wfr: '𝔴', + wopf: '𝕨', + wp: '℘', + wr: '≀', + wreath: '≀', + wscr: '𝓌', + xcap: '⋂', + xcirc: '◯', + xcup: '⋃', + xdtri: '▽', + xfr: '𝔵', + xhArr: '⟺', + xharr: '⟷', + xi: 'ξ', + xlArr: '⟸', + xlarr: '⟵', + xmap: '⟼', + xnis: '⋻', + xodot: '⨀', + xopf: '𝕩', + xoplus: '⨁', + xotime: '⨂', + xrArr: '⟹', + xrarr: '⟶', + xscr: '𝓍', + xsqcup: '⨆', + xuplus: '⨄', + xutri: '△', + xvee: '⋁', + xwedge: '⋀', + yacute: 'ý', + yacy: 'я', + ycirc: 'ŷ', + ycy: 'ы', + yen: '¥', + yfr: '𝔶', + yicy: 'ї', + yopf: '𝕪', + yscr: '𝓎', + yucy: 'ю', + yuml: 'ÿ', + zacute: 'ź', + zcaron: 'ž', + zcy: 'з', + zdot: 'ż', + zeetrf: 'ℨ', + zeta: 'ζ', + zfr: '𝔷', + zhcy: 'ж', + zigrarr: '⇝', + zopf: '𝕫', + zscr: '𝓏', + zwj: '‍', + zwnj: '‌' +}; + +const own$1 = {}.hasOwnProperty; + +/** + * Decode a single character reference (without the `&` or `;`). + * You probably only need this when you’re building parsers yourself that follow + * different rules compared to HTML. + * This is optimized to be tiny in browsers. + * + * @param {string} value + * `notin` (named), `#123` (deci), `#x123` (hexa). + * @returns {string|false} + * Decoded reference. + */ +function decodeNamedCharacterReference(value) { + return own$1.call(characterEntities, value) ? characterEntities[value] : false +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const characterReference = { + name: 'characterReference', + tokenize: tokenizeCharacterReference +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCharacterReference(effects, ok, nok) { + const self = this; + let size = 0; + /** @type {number} */ + let max; + /** @type {(code: Code) => boolean} */ + let test; + return start + + /** + * Start of character reference. + * + * ```markdown + * > | a&b + * ^ + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('characterReference'); + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + return open + } + + /** + * After `&`, at `#` for numeric references or alphanumeric for named + * references. + * + * ```markdown + * > | a&b + * ^ + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 35) { + effects.enter('characterReferenceMarkerNumeric'); + effects.consume(code); + effects.exit('characterReferenceMarkerNumeric'); + return numeric + } + effects.enter('characterReferenceValue'); + max = 31; + test = asciiAlphanumeric; + return value(code) + } + + /** + * After `#`, at `x` for hexadecimals or digit for decimals. + * + * ```markdown + * > | a{b + * ^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function numeric(code) { + if (code === 88 || code === 120) { + effects.enter('characterReferenceMarkerHexadecimal'); + effects.consume(code); + effects.exit('characterReferenceMarkerHexadecimal'); + effects.enter('characterReferenceValue'); + max = 6; + test = asciiHexDigit; + return value + } + effects.enter('characterReferenceValue'); + max = 7; + test = asciiDigit; + return value(code) + } + + /** + * After markers (`&#x`, `&#`, or `&`), in value, before `;`. + * + * The character reference kind defines what and how many characters are + * allowed. + * + * ```markdown + * > | a&b + * ^^^ + * > | a{b + * ^^^ + * > | a b + * ^ + * ``` + * + * @type {State} + */ + function value(code) { + if (code === 59 && size) { + const token = effects.exit('characterReferenceValue'); + if ( + test === asciiAlphanumeric && + !decodeNamedCharacterReference(self.sliceSerialize(token)) + ) { + return nok(code) + } + + // To do: `markdown-rs` uses a different name: + // `CharacterReferenceMarkerSemi`. + effects.enter('characterReferenceMarker'); + effects.consume(code); + effects.exit('characterReferenceMarker'); + effects.exit('characterReference'); + return ok + } + if (test(code) && size++ < max) { + effects.consume(code); + return value + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const nonLazyContinuation = { + tokenize: tokenizeNonLazyContinuation, + partial: true +}; + +/** @type {Construct} */ +const codeFenced = { + name: 'codeFenced', + tokenize: tokenizeCodeFenced, + concrete: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeFenced(effects, ok, nok) { + const self = this; + /** @type {Construct} */ + const closeStart = { + tokenize: tokenizeCloseStart, + partial: true + }; + let initialPrefix = 0; + let sizeOpen = 0; + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of code. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse whitespace like `markdown-rs`. + return beforeSequenceOpen(code) + } + + /** + * In opening fence, after prefix, at sequence. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function beforeSequenceOpen(code) { + const tail = self.events[self.events.length - 1]; + initialPrefix = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + marker = code; + effects.enter('codeFenced'); + effects.enter('codeFencedFence'); + effects.enter('codeFencedFenceSequence'); + return sequenceOpen(code) + } + + /** + * In opening fence sequence. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === marker) { + sizeOpen++; + effects.consume(code); + return sequenceOpen + } + if (sizeOpen < 3) { + return nok(code) + } + effects.exit('codeFencedFenceSequence'); + return markdownSpace(code) + ? factorySpace(effects, infoBefore, 'whitespace')(code) + : infoBefore(code) + } + + /** + * In opening fence, after the sequence (and optional whitespace), before info. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function infoBefore(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return self.interrupt + ? ok(code) + : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) + } + effects.enter('codeFencedFenceInfo'); + effects.enter('chunkString', { + contentType: 'string' + }); + return info(code) + } + + /** + * In info. + * + * ```markdown + * > | ~~~js + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function info(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return infoBefore(code) + } + if (markdownSpace(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceInfo'); + return factorySpace(effects, metaBefore, 'whitespace')(code) + } + if (code === 96 && code === marker) { + return nok(code) + } + effects.consume(code); + return info + } + + /** + * In opening fence, after info and whitespace, before meta. + * + * ```markdown + * > | ~~~js eval + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function metaBefore(code) { + if (code === null || markdownLineEnding(code)) { + return infoBefore(code) + } + effects.enter('codeFencedFenceMeta'); + effects.enter('chunkString', { + contentType: 'string' + }); + return meta(code) + } + + /** + * In meta. + * + * ```markdown + * > | ~~~js eval + * ^ + * | alert(1) + * | ~~~ + * ``` + * + * @type {State} + */ + function meta(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + effects.exit('codeFencedFenceMeta'); + return infoBefore(code) + } + if (code === 96 && code === marker) { + return nok(code) + } + effects.consume(code); + return meta + } + + /** + * At eol/eof in code, before a non-lazy closing fence or content. + * + * ```markdown + * > | ~~~js + * ^ + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function atNonLazyBreak(code) { + return effects.attempt(closeStart, after, contentBefore)(code) + } + + /** + * Before code content, not a closing fence, at eol. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentBefore(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return contentStart + } + + /** + * Before code content, not a closing fence. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentStart(code) { + return initialPrefix > 0 && markdownSpace(code) + ? factorySpace( + effects, + beforeContentChunk, + 'linePrefix', + initialPrefix + 1 + )(code) + : beforeContentChunk(code) + } + + /** + * Before code content, after optional prefix. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^ + * | ~~~ + * ``` + * + * @type {State} + */ + function beforeContentChunk(code) { + if (code === null || markdownLineEnding(code)) { + return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code) + } + effects.enter('codeFlowValue'); + return contentChunk(code) + } + + /** + * In code content. + * + * ```markdown + * | ~~~js + * > | alert(1) + * ^^^^^^^^ + * | ~~~ + * ``` + * + * @type {State} + */ + function contentChunk(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return beforeContentChunk(code) + } + effects.consume(code); + return contentChunk + } + + /** + * After code. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + effects.exit('codeFenced'); + return ok(code) + } + + /** + * @this {TokenizeContext} + * @type {Tokenizer} + */ + function tokenizeCloseStart(effects, ok, nok) { + let size = 0; + return startBefore + + /** + * + * + * @type {State} + */ + function startBefore(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return start + } + + /** + * Before closing fence, at optional whitespace. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // Always populated by defaults. + + // To do: `enter` here or in next state? + effects.enter('codeFencedFence'); + return markdownSpace(code) + ? factorySpace( + effects, + beforeSequenceClose, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + : beforeSequenceClose(code) + } + + /** + * In closing fence, after optional whitespace, at sequence. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function beforeSequenceClose(code) { + if (code === marker) { + effects.enter('codeFencedFenceSequence'); + return sequenceClose(code) + } + return nok(code) + } + + /** + * In closing fence sequence. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function sequenceClose(code) { + if (code === marker) { + size++; + effects.consume(code); + return sequenceClose + } + if (size >= sizeOpen) { + effects.exit('codeFencedFenceSequence'); + return markdownSpace(code) + ? factorySpace(effects, sequenceCloseAfter, 'whitespace')(code) + : sequenceCloseAfter(code) + } + return nok(code) + } + + /** + * After closing fence sequence, after optional whitespace. + * + * ```markdown + * | ~~~js + * | alert(1) + * > | ~~~ + * ^ + * ``` + * + * @type {State} + */ + function sequenceCloseAfter(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFencedFence'); + return ok(code) + } + return nok(code) + } + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeNonLazyContinuation(effects, ok, nok) { + const self = this; + return start + + /** + * + * + * @type {State} + */ + function start(code) { + if (code === null) { + return nok(code) + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineStart + } + + /** + * + * + * @type {State} + */ + function lineStart(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const codeIndented = { + name: 'codeIndented', + tokenize: tokenizeCodeIndented +}; + +/** @type {Construct} */ +const furtherStart = { + tokenize: tokenizeFurtherStart, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeIndented(effects, ok, nok) { + const self = this; + return start + + /** + * Start of code (indented). + * + * > **Parsing note**: it is not needed to check if this first line is a + * > filled line (that it has a non-whitespace character), because blank lines + * > are parsed already, so we never run into that. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: manually check if interrupting like `markdown-rs`. + + effects.enter('codeIndented'); + // To do: use an improved `space_or_tab` function like `markdown-rs`, + // so that we can drop the next state. + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + + /** + * At start, after 1 or 4 spaces. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? atBreak(code) + : nok(code) + } + + /** + * At a break. + * + * ```markdown + * > | aaa + * ^ ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === null) { + return after(code) + } + if (markdownLineEnding(code)) { + return effects.attempt(furtherStart, atBreak, after)(code) + } + effects.enter('codeFlowValue'); + return inside(code) + } + + /** + * In code content. + * + * ```markdown + * > | aaa + * ^^^^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('codeFlowValue'); + return atBreak(code) + } + effects.consume(code); + return inside + } + + /** @type {State} */ + function after(code) { + effects.exit('codeIndented'); + // To do: allow interrupting like `markdown-rs`. + // Feel free to interrupt. + // tokenizer.interrupt = false + return ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeFurtherStart(effects, ok, nok) { + const self = this; + return furtherStart + + /** + * At eol, trying to parse another indent. + * + * ```markdown + * > | aaa + * ^ + * | bbb + * ``` + * + * @type {State} + */ + function furtherStart(code) { + // To do: improve `lazy` / `pierce` handling. + // If this is a lazy line, it can’t be code. + if (self.parser.lazy[self.now().line]) { + return nok(code) + } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return furtherStart + } + + // To do: the code here in `micromark-js` is a bit different from + // `markdown-rs` because there it can attempt spaces. + // We can’t yet. + // + // To do: use an improved `space_or_tab` function like `markdown-rs`, + // so that we can drop the next state. + return factorySpace(effects, afterPrefix, 'linePrefix', 4 + 1)(code) + } + + /** + * At start, after 1 or 4 spaces. + * + * ```markdown + * > | aaa + * ^ + * ``` + * + * @type {State} + */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ? ok(code) + : markdownLineEnding(code) + ? furtherStart(code) + : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Previous} Previous + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const codeText = { + name: 'codeText', + tokenize: tokenizeCodeText, + resolve: resolveCodeText, + previous +}; + +// To do: next major: don’t resolve, like `markdown-rs`. +/** @type {Resolver} */ +function resolveCodeText(events) { + let tailExitIndex = events.length - 4; + let headEnterIndex = 3; + /** @type {number} */ + let index; + /** @type {number | undefined} */ + let enter; + + // If we start and end with an EOL or a space. + if ( + (events[headEnterIndex][1].type === 'lineEnding' || + events[headEnterIndex][1].type === 'space') && + (events[tailExitIndex][1].type === 'lineEnding' || + events[tailExitIndex][1].type === 'space') + ) { + index = headEnterIndex; + + // And we have data. + while (++index < tailExitIndex) { + if (events[index][1].type === 'codeTextData') { + // Then we have padding. + events[headEnterIndex][1].type = 'codeTextPadding'; + events[tailExitIndex][1].type = 'codeTextPadding'; + headEnterIndex += 2; + tailExitIndex -= 2; + break + } + } + } + + // Merge adjacent spaces and data. + index = headEnterIndex - 1; + tailExitIndex++; + while (++index <= tailExitIndex) { + if (enter === undefined) { + if (index !== tailExitIndex && events[index][1].type !== 'lineEnding') { + enter = index; + } + } else if ( + index === tailExitIndex || + events[index][1].type === 'lineEnding' + ) { + events[enter][1].type = 'codeTextData'; + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + tailExitIndex -= index - enter - 2; + index = enter + 2; + } + enter = undefined; + } + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Previous} + */ +function previous(code) { + // If there is a previous code, there will always be a tail. + return ( + code !== 96 || + this.events[this.events.length - 1][1].type === 'characterEscape' + ) +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeCodeText(effects, ok, nok) { + let sizeOpen = 0; + /** @type {number} */ + let size; + /** @type {Token} */ + let token; + return start + + /** + * Start of code (text). + * + * ```markdown + * > | `a` + * ^ + * > | \`a` + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('codeText'); + effects.enter('codeTextSequence'); + return sequenceOpen(code) + } + + /** + * In opening sequence. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === 96) { + effects.consume(code); + sizeOpen++; + return sequenceOpen + } + effects.exit('codeTextSequence'); + return between(code) + } + + /** + * Between something and something else. + * + * ```markdown + * > | `a` + * ^^ + * ``` + * + * @type {State} + */ + function between(code) { + // EOF. + if (code === null) { + return nok(code) + } + + // To do: next major: don’t do spaces in resolve, but when compiling, + // like `markdown-rs`. + // Tabs don’t work, and virtual spaces don’t make sense. + if (code === 32) { + effects.enter('space'); + effects.consume(code); + effects.exit('space'); + return between + } + + // Closing fence? Could also be data. + if (code === 96) { + token = effects.enter('codeTextSequence'); + size = 0; + return sequenceClose(code) + } + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return between + } + + // Data. + effects.enter('codeTextData'); + return data(code) + } + + /** + * In data. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function data(code) { + if ( + code === null || + code === 32 || + code === 96 || + markdownLineEnding(code) + ) { + effects.exit('codeTextData'); + return between(code) + } + effects.consume(code); + return data + } + + /** + * In closing sequence. + * + * ```markdown + * > | `a` + * ^ + * ``` + * + * @type {State} + */ + function sequenceClose(code) { + // More. + if (code === 96) { + effects.consume(code); + size++; + return sequenceClose + } + + // Done! + if (size === sizeOpen) { + effects.exit('codeTextSequence'); + effects.exit('codeText'); + return ok(code) + } + + // More or less accents: mark as data. + token.type = 'codeTextData'; + return data(code) + } +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Token} Token + */ + +/** + * Tokenize subcontent. + * + * @param {Array} events + * List of events. + * @returns {boolean} + * Whether subtokens were found. + */ +function subtokenize(events) { + /** @type {Record} */ + const jumps = {}; + let index = -1; + /** @type {Event} */ + let event; + /** @type {number | undefined} */ + let lineIndex; + /** @type {number} */ + let otherIndex; + /** @type {Event} */ + let otherEvent; + /** @type {Array} */ + let parameters; + /** @type {Array} */ + let subevents; + /** @type {boolean | undefined} */ + let more; + while (++index < events.length) { + while (index in jumps) { + index = jumps[index]; + } + event = events[index]; + + // Add a hook for the GFM tasklist extension, which needs to know if text + // is in the first content of a list item. + if ( + index && + event[1].type === 'chunkFlow' && + events[index - 1][1].type === 'listItemPrefix' + ) { + subevents = event[1]._tokenizer.events; + otherIndex = 0; + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'lineEndingBlank' + ) { + otherIndex += 2; + } + if ( + otherIndex < subevents.length && + subevents[otherIndex][1].type === 'content' + ) { + while (++otherIndex < subevents.length) { + if (subevents[otherIndex][1].type === 'content') { + break + } + if (subevents[otherIndex][1].type === 'chunkText') { + subevents[otherIndex][1]._isInFirstContentOfListItem = true; + otherIndex++; + } + } + } + } + + // Enter. + if (event[0] === 'enter') { + if (event[1].contentType) { + Object.assign(jumps, subcontent(events, index)); + index = jumps[index]; + more = true; + } + } + // Exit. + else if (event[1]._container) { + otherIndex = index; + lineIndex = undefined; + while (otherIndex--) { + otherEvent = events[otherIndex]; + if ( + otherEvent[1].type === 'lineEnding' || + otherEvent[1].type === 'lineEndingBlank' + ) { + if (otherEvent[0] === 'enter') { + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + } + otherEvent[1].type = 'lineEnding'; + lineIndex = otherIndex; + } + } else { + break + } + } + if (lineIndex) { + // Fix position. + event[1].end = Object.assign({}, events[lineIndex][1].start); + + // Switch container exit w/ line endings. + parameters = events.slice(lineIndex, index); + parameters.unshift(event); + splice$1(events, lineIndex, index - lineIndex + 1, parameters); + } + } + } + return !more +} + +/** + * Tokenize embedded tokens. + * + * @param {Array} events + * @param {number} eventIndex + * @returns {Record} + */ +function subcontent(events, eventIndex) { + const token = events[eventIndex][1]; + const context = events[eventIndex][2]; + let startPosition = eventIndex - 1; + /** @type {Array} */ + const startPositions = []; + const tokenizer = + token._tokenizer || context.parser[token.contentType](token.start); + const childEvents = tokenizer.events; + /** @type {Array<[number, number]>} */ + const jumps = []; + /** @type {Record} */ + const gaps = {}; + /** @type {Array} */ + let stream; + /** @type {Token | undefined} */ + let previous; + let index = -1; + /** @type {Token | undefined} */ + let current = token; + let adjust = 0; + let start = 0; + const breaks = [start]; + + // Loop forward through the linked tokens to pass them in order to the + // subtokenizer. + while (current) { + // Find the position of the event for this token. + while (events[++startPosition][1] !== current) { + // Empty. + } + startPositions.push(startPosition); + if (!current._tokenizer) { + stream = context.sliceStream(current); + if (!current.next) { + stream.push(null); + } + if (previous) { + tokenizer.defineSkip(current.start); + } + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = true; + } + tokenizer.write(stream); + if (current._isInFirstContentOfListItem) { + tokenizer._gfmTasklistFirstContentOfListItem = undefined; + } + } + + // Unravel the next token. + previous = current; + current = current.next; + } + + // Now, loop back through all events (and linked tokens), to figure out which + // parts belong where. + current = token; + while (++index < childEvents.length) { + if ( + // Find a void token that includes a break. + childEvents[index][0] === 'exit' && + childEvents[index - 1][0] === 'enter' && + childEvents[index][1].type === childEvents[index - 1][1].type && + childEvents[index][1].start.line !== childEvents[index][1].end.line + ) { + start = index + 1; + breaks.push(start); + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + current = current.next; + } + } + + // Help GC. + tokenizer.events = []; + + // If there’s one more token (which is the cases for lines that end in an + // EOF), that’s perfect: the last point we found starts it. + // If there isn’t then make sure any remaining content is added to it. + if (current) { + // Help GC. + current._tokenizer = undefined; + current.previous = undefined; + } else { + breaks.pop(); + } + + // Now splice the events from the subtokenizer into the current events, + // moving back to front so that splice indices aren’t affected. + index = breaks.length; + while (index--) { + const slice = childEvents.slice(breaks[index], breaks[index + 1]); + const start = startPositions.pop(); + jumps.unshift([start, start + slice.length - 1]); + splice$1(events, start, 2, slice); + } + index = -1; + while (++index < jumps.length) { + gaps[adjust + jumps[index][0]] = adjust + jumps[index][1]; + adjust += jumps[index][1] - jumps[index][0] - 1; + } + return gaps +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** + * No name because it must not be turned off. + * @type {Construct} + */ +const content = { + tokenize: tokenizeContent, + resolve: resolveContent +}; + +/** @type {Construct} */ +const continuationConstruct = { + tokenize: tokenizeContinuation, + partial: true +}; + +/** + * Content is transparent: it’s parsed right now. That way, definitions are also + * parsed right now: before text in paragraphs (specifically, media) are parsed. + * + * @type {Resolver} + */ +function resolveContent(events) { + subtokenize(events); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContent(effects, ok) { + /** @type {Token | undefined} */ + let previous; + return chunkStart + + /** + * Before a content chunk. + * + * ```markdown + * > | abc + * ^ + * ``` + * + * @type {State} + */ + function chunkStart(code) { + effects.enter('content'); + previous = effects.enter('chunkContent', { + contentType: 'content' + }); + return chunkInside(code) + } + + /** + * In a content chunk. + * + * ```markdown + * > | abc + * ^^^ + * ``` + * + * @type {State} + */ + function chunkInside(code) { + if (code === null) { + return contentEnd(code) + } + + // To do: in `markdown-rs`, each line is parsed on its own, and everything + // is stitched together resolving. + if (markdownLineEnding(code)) { + return effects.check( + continuationConstruct, + contentContinue, + contentEnd + )(code) + } + + // Data. + effects.consume(code); + return chunkInside + } + + /** + * + * + * @type {State} + */ + function contentEnd(code) { + effects.exit('chunkContent'); + effects.exit('content'); + return ok(code) + } + + /** + * + * + * @type {State} + */ + function contentContinue(code) { + effects.consume(code); + effects.exit('chunkContent'); + previous.next = effects.enter('chunkContent', { + contentType: 'content', + previous + }); + previous = previous.next; + return chunkInside + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeContinuation(effects, ok, nok) { + const self = this; + return startLookahead + + /** + * + * + * @type {State} + */ + function startLookahead(code) { + effects.exit('chunkContent'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, prefixed, 'linePrefix') + } + + /** + * + * + * @type {State} + */ + function prefixed(code) { + if (code === null || markdownLineEnding(code)) { + return nok(code) + } + + // Always populated by defaults. + + const tail = self.events[self.events.length - 1]; + if ( + !self.parser.constructs.disable.null.includes('codeIndented') && + tail && + tail[1].type === 'linePrefix' && + tail[2].sliceSerialize(tail[1], true).length >= 4 + ) { + return ok(code) + } + return effects.interrupt(self.parser.constructs.flow, nok, ok)(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse destinations. + * + * ###### Examples + * + * ```markdown + * + * b> + * + * + * a + * a\)b + * a(b)c + * a(b) + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type for whole (`` or `b`). + * @param {TokenType} literalType + * Type when enclosed (``). + * @param {TokenType} literalMarkerType + * Type for enclosing (`<` and `>`). + * @param {TokenType} rawType + * Type when not enclosed (`b`). + * @param {TokenType} stringType + * Type for the value (`a` or `b`). + * @param {number | undefined} [max=Infinity] + * Depth of nested parens (inclusive). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryDestination( + effects, + ok, + nok, + type, + literalType, + literalMarkerType, + rawType, + stringType, + max +) { + const limit = max || Number.POSITIVE_INFINITY; + let balance = 0; + return start + + /** + * Start of destination. + * + * ```markdown + * > | + * ^ + * > | aa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 60) { + effects.enter(type); + effects.enter(literalType); + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + return enclosedBefore + } + + // ASCII control, space, closing paren. + if (code === null || code === 32 || code === 41 || asciiControl(code)) { + return nok(code) + } + effects.enter(type); + effects.enter(rawType); + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return raw(code) + } + + /** + * After `<`, at an enclosed destination. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosedBefore(code) { + if (code === 62) { + effects.enter(literalMarkerType); + effects.consume(code); + effects.exit(literalMarkerType); + effects.exit(literalType); + effects.exit(type); + return ok + } + effects.enter(stringType); + effects.enter('chunkString', { + contentType: 'string' + }); + return enclosed(code) + } + + /** + * In enclosed destination. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosed(code) { + if (code === 62) { + effects.exit('chunkString'); + effects.exit(stringType); + return enclosedBefore(code) + } + if (code === null || code === 60 || markdownLineEnding(code)) { + return nok(code) + } + effects.consume(code); + return code === 92 ? enclosedEscape : enclosed + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function enclosedEscape(code) { + if (code === 60 || code === 62 || code === 92) { + effects.consume(code); + return enclosed + } + return enclosed(code) + } + + /** + * In raw destination. + * + * ```markdown + * > | aa + * ^ + * ``` + * + * @type {State} + */ + function raw(code) { + if ( + !balance && + (code === null || code === 41 || markdownLineEndingOrSpace(code)) + ) { + effects.exit('chunkString'); + effects.exit(stringType); + effects.exit(rawType); + effects.exit(type); + return ok(code) + } + if (balance < limit && code === 40) { + effects.consume(code); + balance++; + return raw + } + if (code === 41) { + effects.consume(code); + balance--; + return raw + } + + // ASCII control (but *not* `\0`) and space and `(`. + // Note: in `markdown-rs`, `\0` exists in codes, in `micromark-js` it + // doesn’t. + if (code === null || code === 32 || code === 40 || asciiControl(code)) { + return nok(code) + } + effects.consume(code); + return code === 92 ? rawEscape : raw + } + + /** + * After `\`, at special character. + * + * ```markdown + * > | a\*a + * ^ + * ``` + * + * @type {State} + */ + function rawEscape(code) { + if (code === 40 || code === 41 || code === 92) { + effects.consume(code); + return raw + } + return raw(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse labels. + * + * > 👉 **Note**: labels in markdown are capped at 999 characters in the string. + * + * ###### Examples + * + * ```markdown + * [a] + * [a + * b] + * [a\]b] + * ``` + * + * @this {TokenizeContext} + * Tokenize context. + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type of the whole label (`[a]`). + * @param {TokenType} markerType + * Type for the markers (`[` and `]`). + * @param {TokenType} stringType + * Type for the identifier (`a`). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryLabel(effects, ok, nok, type, markerType, stringType) { + const self = this; + let size = 0; + /** @type {boolean} */ + let seen; + return start + + /** + * Start of label. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.enter(stringType); + return atBreak + } + + /** + * In label, at something, before something else. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if ( + size > 999 || + code === null || + code === 91 || + (code === 93 && !seen) || + // To do: remove in the future once we’ve switched from + // `micromark-extension-footnote` to `micromark-extension-gfm-footnote`, + // which doesn’t need this. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + (code === 94 && + !size && + '_hiddenFootnoteSupport' in self.parser.constructs) + ) { + return nok(code) + } + if (code === 93) { + effects.exit(stringType); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } + + // To do: indent? Link chunks and EOLs together? + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return atBreak + } + effects.enter('chunkString', { + contentType: 'string' + }); + return labelInside(code) + } + + /** + * In label, in text. + * + * ```markdown + * > | [a] + * ^ + * ``` + * + * @type {State} + */ + function labelInside(code) { + if ( + code === null || + code === 91 || + code === 93 || + markdownLineEnding(code) || + size++ > 999 + ) { + effects.exit('chunkString'); + return atBreak(code) + } + effects.consume(code); + if (!seen) seen = !markdownSpace(code); + return code === 92 ? labelEscape : labelInside + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | [a\*a] + * ^ + * ``` + * + * @type {State} + */ + function labelEscape(code) { + if (code === 91 || code === 92 || code === 93) { + effects.consume(code); + size++; + return labelInside + } + return labelInside(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenType} TokenType + */ + +/** + * Parse titles. + * + * ###### Examples + * + * ```markdown + * "a" + * 'b' + * (c) + * "a + * b" + * 'a + * b' + * (a\)b) + * ``` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @param {State} nok + * State switched to when unsuccessful. + * @param {TokenType} type + * Type of the whole title (`"a"`, `'b'`, `(c)`). + * @param {TokenType} markerType + * Type for the markers (`"`, `'`, `(`, and `)`). + * @param {TokenType} stringType + * Type for the value (`a`). + * @returns {State} + * Start state. + */ // eslint-disable-next-line max-params +function factoryTitle(effects, ok, nok, type, markerType, stringType) { + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of title. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + if (code === 34 || code === 39 || code === 40) { + effects.enter(type); + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + marker = code === 40 ? 41 : code; + return begin + } + return nok(code) + } + + /** + * After opening marker. + * + * This is also used at the closing marker. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function begin(code) { + if (code === marker) { + effects.enter(markerType); + effects.consume(code); + effects.exit(markerType); + effects.exit(type); + return ok + } + effects.enter(stringType); + return atBreak(code) + } + + /** + * At something, before something else. + * + * ```markdown + * > | "a" + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === marker) { + effects.exit(stringType); + return begin(marker) + } + if (code === null) { + return nok(code) + } + + // Note: blank lines can’t exist in content. + if (markdownLineEnding(code)) { + // To do: use `space_or_tab_eol_with_options`, connect. + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, atBreak, 'linePrefix') + } + effects.enter('chunkString', { + contentType: 'string' + }); + return inside(code) + } + + /** + * + * + * @type {State} + */ + function inside(code) { + if (code === marker || code === null || markdownLineEnding(code)) { + effects.exit('chunkString'); + return atBreak(code) + } + effects.consume(code); + return code === 92 ? escape : inside + } + + /** + * After `\`, at a special character. + * + * ```markdown + * > | "a\*b" + * ^ + * ``` + * + * @type {State} + */ + function escape(code) { + if (code === marker || code === 92) { + effects.consume(code); + return inside + } + return inside(code) + } +} + +/** + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').State} State + */ + +/** + * Parse spaces and tabs. + * + * There is no `nok` parameter: + * + * * line endings or spaces in markdown are often optional, in which case this + * factory can be used and `ok` will be switched to whether spaces were found + * or not + * * one line ending or space can be detected with + * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace` + * + * @param {Effects} effects + * Context. + * @param {State} ok + * State switched to when successful. + * @returns + * Start state. + */ +function factoryWhitespace(effects, ok) { + /** @type {boolean} */ + let seen; + return start + + /** @type {State} */ + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + seen = true; + return start + } + if (markdownSpace(code)) { + return factorySpace( + effects, + start, + seen ? 'linePrefix' : 'lineSuffix' + )(code) + } + return ok(code) + } +} + +/** + * Normalize an identifier (as found in references, definitions). + * + * Collapses markdown whitespace, trim, and then lower- and uppercase. + * + * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their + * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different + * uppercase character (U+0398 (`Θ`)). + * So, to get a canonical form, we perform both lower- and uppercase. + * + * Using uppercase last makes sure keys will never interact with default + * prototypal values (such as `constructor`): nothing in the prototype of + * `Object` is uppercase. + * + * @param {string} value + * Identifier to normalize. + * @returns {string} + * Normalized identifier. + */ +function normalizeIdentifier(value) { + return ( + value + // Collapse markdown whitespace. + .replace(/[\t\n\r ]+/g, ' ') + // Trim. + .replace(/^ | $/g, '') + // Some characters are considered “uppercase”, but if their lowercase + // counterpart is uppercased will result in a different uppercase + // character. + // Hence, to get that form, we perform both lower- and uppercase. + // Upper case makes sure keys will not interact with default prototypal + // methods: no method is uppercase. + .toLowerCase() + .toUpperCase() + ) +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const definition = { + name: 'definition', + tokenize: tokenizeDefinition +}; + +/** @type {Construct} */ +const titleBefore = { + tokenize: tokenizeTitleBefore, + partial: true +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeDefinition(effects, ok, nok) { + const self = this; + /** @type {string} */ + let identifier; + return start + + /** + * At start of a definition. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // Do not interrupt paragraphs (but do follow definitions). + // To do: do `interrupt` the way `markdown-rs` does. + // To do: parse whitespace the way `markdown-rs` does. + effects.enter('definition'); + return before(code) + } + + /** + * After optional whitespace, at `[`. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + // To do: parse whitespace the way `markdown-rs` does. + + return factoryLabel.call( + self, + effects, + labelAfter, + // Note: we don’t need to reset the way `markdown-rs` does. + nok, + 'definitionLabel', + 'definitionLabelMarker', + 'definitionLabelString' + )(code) + } + + /** + * After label. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function labelAfter(code) { + identifier = normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ); + if (code === 58) { + effects.enter('definitionMarker'); + effects.consume(code); + effects.exit('definitionMarker'); + return markerAfter + } + return nok(code) + } + + /** + * After marker. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function markerAfter(code) { + // Note: whitespace is optional. + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, destinationBefore)(code) + : destinationBefore(code) + } + + /** + * Before destination. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function destinationBefore(code) { + return factoryDestination( + effects, + destinationAfter, + // Note: we don’t need to reset the way `markdown-rs` does. + nok, + 'definitionDestination', + 'definitionDestinationLiteral', + 'definitionDestinationLiteralMarker', + 'definitionDestinationRaw', + 'definitionDestinationString' + )(code) + } + + /** + * After destination. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function destinationAfter(code) { + return effects.attempt(titleBefore, after, after)(code) + } + + /** + * After definition. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return markdownSpace(code) + ? factorySpace(effects, afterWhitespace, 'whitespace')(code) + : afterWhitespace(code) + } + + /** + * After definition, after optional whitespace. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function afterWhitespace(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('definition'); + + // Note: we don’t care about uniqueness. + // It’s likely that that doesn’t happen very frequently. + // It is more likely that it wastes precious time. + self.parser.defined.push(identifier); + + // To do: `markdown-rs` interrupt. + // // You’d be interrupting. + // tokenizer.interrupt = true + return ok(code) + } + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeTitleBefore(effects, ok, nok) { + return titleBefore + + /** + * After destination, at whitespace. + * + * ```markdown + * > | [a]: b + * ^ + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleBefore(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, beforeMarker)(code) + : nok(code) + } + + /** + * At title. + * + * ```markdown + * | [a]: b + * > | "c" + * ^ + * ``` + * + * @type {State} + */ + function beforeMarker(code) { + return factoryTitle( + effects, + titleAfter, + nok, + 'definitionTitle', + 'definitionTitleMarker', + 'definitionTitleString' + )(code) + } + + /** + * After title. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleAfter(code) { + return markdownSpace(code) + ? factorySpace(effects, titleAfterOptionalWhitespace, 'whitespace')(code) + : titleAfterOptionalWhitespace(code) + } + + /** + * After title, after optional whitespace. + * + * ```markdown + * > | [a]: b "c" + * ^ + * ``` + * + * @type {State} + */ + function titleAfterOptionalWhitespace(code) { + return code === null || markdownLineEnding(code) ? ok(code) : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const hardBreakEscape = { + name: 'hardBreakEscape', + tokenize: tokenizeHardBreakEscape +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHardBreakEscape(effects, ok, nok) { + return start + + /** + * Start of a hard break (escape). + * + * ```markdown + * > | a\ + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('hardBreakEscape'); + effects.consume(code); + return after + } + + /** + * After `\`, at eol. + * + * ```markdown + * > | a\ + * ^ + * | b + * ``` + * + * @type {State} + */ + function after(code) { + if (markdownLineEnding(code)) { + effects.exit('hardBreakEscape'); + return ok(code) + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const headingAtx = { + name: 'headingAtx', + tokenize: tokenizeHeadingAtx, + resolve: resolveHeadingAtx +}; + +/** @type {Resolver} */ +function resolveHeadingAtx(events, context) { + let contentEnd = events.length - 2; + let contentStart = 3; + /** @type {Token} */ + let content; + /** @type {Token} */ + let text; + + // Prefix whitespace, part of the opening. + if (events[contentStart][1].type === 'whitespace') { + contentStart += 2; + } + + // Suffix whitespace, part of the closing. + if ( + contentEnd - 2 > contentStart && + events[contentEnd][1].type === 'whitespace' + ) { + contentEnd -= 2; + } + if ( + events[contentEnd][1].type === 'atxHeadingSequence' && + (contentStart === contentEnd - 1 || + (contentEnd - 4 > contentStart && + events[contentEnd - 2][1].type === 'whitespace')) + ) { + contentEnd -= contentStart + 1 === contentEnd ? 2 : 4; + } + if (contentEnd > contentStart) { + content = { + type: 'atxHeadingText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end + }; + text = { + type: 'chunkText', + start: events[contentStart][1].start, + end: events[contentEnd][1].end, + contentType: 'text' + }; + splice$1(events, contentStart, contentEnd - contentStart + 1, [ + ['enter', content, context], + ['enter', text, context], + ['exit', text, context], + ['exit', content, context] + ]); + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHeadingAtx(effects, ok, nok) { + let size = 0; + return start + + /** + * Start of a heading (atx). + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse indent like `markdown-rs`. + effects.enter('atxHeading'); + return before(code) + } + + /** + * After optional whitespace, at `#`. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('atxHeadingSequence'); + return sequenceOpen(code) + } + + /** + * In opening sequence. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function sequenceOpen(code) { + if (code === 35 && size++ < 6) { + effects.consume(code); + return sequenceOpen + } + + // Always at least one `#`. + if (code === null || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingSequence'); + return atBreak(code) + } + return nok(code) + } + + /** + * After something, before something else. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === 35) { + effects.enter('atxHeadingSequence'); + return sequenceFurther(code) + } + if (code === null || markdownLineEnding(code)) { + effects.exit('atxHeading'); + // To do: interrupt like `markdown-rs`. + // // Feel free to interrupt. + // tokenizer.interrupt = false + return ok(code) + } + if (markdownSpace(code)) { + return factorySpace(effects, atBreak, 'whitespace')(code) + } + + // To do: generate `data` tokens, add the `text` token later. + // Needs edit map, see: `markdown.rs`. + effects.enter('atxHeadingText'); + return data(code) + } + + /** + * In further sequence (after whitespace). + * + * Could be normal “visible” hashes in the heading or a final sequence. + * + * ```markdown + * > | ## aa ## + * ^ + * ``` + * + * @type {State} + */ + function sequenceFurther(code) { + if (code === 35) { + effects.consume(code); + return sequenceFurther + } + effects.exit('atxHeadingSequence'); + return atBreak(code) + } + + /** + * In text. + * + * ```markdown + * > | ## aa + * ^ + * ``` + * + * @type {State} + */ + function data(code) { + if (code === null || code === 35 || markdownLineEndingOrSpace(code)) { + effects.exit('atxHeadingText'); + return atBreak(code) + } + effects.consume(code); + return data + } +} + +/** + * List of lowercase HTML “block” tag names. + * + * The list, when parsing HTML (flow), results in more relaxed rules (condition + * 6). + * Because they are known blocks, the HTML-like syntax doesn’t have to be + * strictly parsed. + * For tag names not in this list, a more strict algorithm (condition 7) is used + * to detect whether the HTML-like syntax is seen as HTML (flow) or not. + * + * This is copied from: + * . + * + * > 👉 **Note**: `search` was added in `CommonMark@0.31`. + */ +const htmlBlockNames = [ + 'address', + 'article', + 'aside', + 'base', + 'basefont', + 'blockquote', + 'body', + 'caption', + 'center', + 'col', + 'colgroup', + 'dd', + 'details', + 'dialog', + 'dir', + 'div', + 'dl', + 'dt', + 'fieldset', + 'figcaption', + 'figure', + 'footer', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'header', + 'hr', + 'html', + 'iframe', + 'legend', + 'li', + 'link', + 'main', + 'menu', + 'menuitem', + 'nav', + 'noframes', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'search', + 'section', + 'summary', + 'table', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'title', + 'tr', + 'track', + 'ul' +]; + +/** + * List of lowercase HTML “raw” tag names. + * + * The list, when parsing HTML (flow), results in HTML that can include lines + * without exiting, until a closing tag also in this list is found (condition + * 1). + * + * This module is copied from: + * . + * + * > 👉 **Note**: `textarea` was added in `CommonMark@0.30`. + */ +const htmlRawNames = ['pre', 'script', 'style', 'textarea']; + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const htmlFlow = { + name: 'htmlFlow', + tokenize: tokenizeHtmlFlow, + resolveTo: resolveToHtmlFlow, + concrete: true +}; + +/** @type {Construct} */ +const blankLineBefore = { + tokenize: tokenizeBlankLineBefore, + partial: true +}; +const nonLazyContinuationStart = { + tokenize: tokenizeNonLazyContinuationStart, + partial: true +}; + +/** @type {Resolver} */ +function resolveToHtmlFlow(events) { + let index = events.length; + while (index--) { + if (events[index][0] === 'enter' && events[index][1].type === 'htmlFlow') { + break + } + } + if (index > 1 && events[index - 2][1].type === 'linePrefix') { + // Add the prefix start to the HTML token. + events[index][1].start = events[index - 2][1].start; + // Add the prefix start to the HTML line token. + events[index + 1][1].start = events[index - 2][1].start; + // Remove the line prefix. + events.splice(index - 2, 2); + } + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHtmlFlow(effects, ok, nok) { + const self = this; + /** @type {number} */ + let marker; + /** @type {boolean} */ + let closingTag; + /** @type {string} */ + let buffer; + /** @type {number} */ + let index; + /** @type {Code} */ + let markerB; + return start + + /** + * Start of HTML (flow). + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + // To do: parse indent like `markdown-rs`. + return before(code) + } + + /** + * At `<`, after optional whitespace. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('htmlFlow'); + effects.enter('htmlFlowData'); + effects.consume(code); + return open + } + + /** + * After `<`, at tag name or other stuff. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } + if (code === 47) { + effects.consume(code); + closingTag = true; + return tagCloseStart + } + if (code === 63) { + effects.consume(code); + marker = 3; + // To do: + // tokenizer.concrete = true + // To do: use `markdown-rs` style interrupt. + // While we’re in an instruction instead of a declaration, we’re on a `?` + // right now, so we do need to search for `>`, similar to declarations. + return self.interrupt ? ok : continuationDeclarationInside + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + // @ts-expect-error: not null. + buffer = String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * After ` | + * ^ + * > | + * ^ + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + marker = 2; + return commentOpenInside + } + if (code === 91) { + effects.consume(code); + marker = 5; + index = 0; + return cdataOpenInside + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + marker = 4; + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuationDeclarationInside + } + return nok(code) + } + + /** + * After ` | + * ^ + * ``` + * + * @type {State} + */ + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuationDeclarationInside + } + return nok(code) + } + + /** + * After ` | &<]]> + * ^^^^^^ + * ``` + * + * @type {State} + */ + function cdataOpenInside(code) { + const value = 'CDATA['; + if (code === value.charCodeAt(index++)) { + effects.consume(code); + if (index === value.length) { + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuation + } + return cdataOpenInside + } + return nok(code) + } + + /** + * After ` | + * ^ + * ``` + * + * @type {State} + */ + function tagCloseStart(code) { + if (asciiAlpha(code)) { + effects.consume(code); + // @ts-expect-error: not null. + buffer = String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * In tag name. + * + * ```markdown + * > | + * ^^ + * > | + * ^^ + * ``` + * + * @type {State} + */ + function tagName(code) { + if ( + code === null || + code === 47 || + code === 62 || + markdownLineEndingOrSpace(code) + ) { + const slash = code === 47; + const name = buffer.toLowerCase(); + if (!slash && !closingTag && htmlRawNames.includes(name)) { + marker = 1; + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok(code) : continuation(code) + } + if (htmlBlockNames.includes(buffer.toLowerCase())) { + marker = 6; + if (slash) { + effects.consume(code); + return basicSelfClosing + } + + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok(code) : continuation(code) + } + marker = 7; + // Do not support complete HTML when interrupting. + return self.interrupt && !self.parser.lazy[self.now().line] + ? nok(code) + : closingTag + ? completeClosingTagAfter(code) + : completeAttributeNameBefore(code) + } + + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + buffer += String.fromCharCode(code); + return tagName + } + return nok(code) + } + + /** + * After closing slash of a basic tag name. + * + * ```markdown + * > |
    + * ^ + * ``` + * + * @type {State} + */ + function basicSelfClosing(code) { + if (code === 62) { + effects.consume(code); + // // Do not form containers. + // tokenizer.concrete = true + return self.interrupt ? ok : continuation + } + return nok(code) + } + + /** + * After closing slash of a complete tag name. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeClosingTagAfter(code) { + if (markdownSpace(code)) { + effects.consume(code); + return completeClosingTagAfter + } + return completeEnd(code) + } + + /** + * At an attribute name. + * + * At first, this state is used after a complete tag name, after whitespace, + * where it expects optional attributes or the end of the tag. + * It is also reused after attributes, when expecting more optional + * attributes. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeNameBefore(code) { + if (code === 47) { + effects.consume(code); + return completeEnd + } + + // ASCII alphanumerical and `:` and `_`. + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return completeAttributeName + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameBefore + } + return completeEnd(code) + } + + /** + * In attribute name. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeName(code) { + // ASCII alphanumerical and `-`, `.`, `:`, and `_`. + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return completeAttributeName + } + return completeAttributeNameAfter(code) + } + + /** + * After attribute name, at an optional initializer, the end of the tag, or + * whitespace. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return completeAttributeValueBefore + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeNameAfter + } + return completeAttributeNameBefore(code) + } + + /** + * Before unquoted, double quoted, or single quoted attribute value, allowing + * whitespace. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } + if (code === 34 || code === 39) { + effects.consume(code); + markerB = code; + return completeAttributeValueQuoted + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAttributeValueBefore + } + return completeAttributeValueUnquoted(code) + } + + /** + * In double or single quoted attribute value. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueQuoted(code) { + if (code === markerB) { + effects.consume(code); + markerB = null; + return completeAttributeValueQuotedAfter + } + if (code === null || markdownLineEnding(code)) { + return nok(code) + } + effects.consume(code); + return completeAttributeValueQuoted + } + + /** + * In unquoted attribute value. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 47 || + code === 60 || + code === 61 || + code === 62 || + code === 96 || + markdownLineEndingOrSpace(code) + ) { + return completeAttributeNameAfter(code) + } + effects.consume(code); + return completeAttributeValueUnquoted + } + + /** + * After double or single quoted attribute value, before whitespace or the + * end of the tag. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownSpace(code)) { + return completeAttributeNameBefore(code) + } + return nok(code) + } + + /** + * In certain circumstances of a complete tag where only an `>` is allowed. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeEnd(code) { + if (code === 62) { + effects.consume(code); + return completeAfter + } + return nok(code) + } + + /** + * After `>` in a complete tag. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function completeAfter(code) { + if (code === null || markdownLineEnding(code)) { + // // Do not form containers. + // tokenizer.concrete = true + return continuation(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return completeAfter + } + return nok(code) + } + + /** + * In continuation of any HTML kind. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuation(code) { + if (code === 45 && marker === 2) { + effects.consume(code); + return continuationCommentInside + } + if (code === 60 && marker === 1) { + effects.consume(code); + return continuationRawTagOpen + } + if (code === 62 && marker === 4) { + effects.consume(code); + return continuationClose + } + if (code === 63 && marker === 3) { + effects.consume(code); + return continuationDeclarationInside + } + if (code === 93 && marker === 5) { + effects.consume(code); + return continuationCdataInside + } + if (markdownLineEnding(code) && (marker === 6 || marker === 7)) { + effects.exit('htmlFlowData'); + return effects.check( + blankLineBefore, + continuationAfter, + continuationStart + )(code) + } + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return continuationStart(code) + } + effects.consume(code); + return continuation + } + + /** + * In continuation, at eol. + * + * ```markdown + * > | + * ^ + * | asd + * ``` + * + * @type {State} + */ + function continuationStart(code) { + return effects.check( + nonLazyContinuationStart, + continuationStartNonLazy, + continuationAfter + )(code) + } + + /** + * In continuation, at eol, before non-lazy content. + * + * ```markdown + * > | + * ^ + * | asd + * ``` + * + * @type {State} + */ + function continuationStartNonLazy(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return continuationBefore + } + + /** + * In continuation, before non-lazy content. + * + * ```markdown + * | + * > | asd + * ^ + * ``` + * + * @type {State} + */ + function continuationBefore(code) { + if (code === null || markdownLineEnding(code)) { + return continuationStart(code) + } + effects.enter('htmlFlowData'); + return continuation(code) + } + + /** + * In comment continuation, after one `-`, expecting another. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationCommentInside(code) { + if (code === 45) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In raw continuation, after `<`, at `/`. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationRawTagOpen(code) { + if (code === 47) { + effects.consume(code); + buffer = ''; + return continuationRawEndTag + } + return continuation(code) + } + + /** + * In raw continuation, after ` | + * ^^^^^^ + * ``` + * + * @type {State} + */ + function continuationRawEndTag(code) { + if (code === 62) { + const name = buffer.toLowerCase(); + if (htmlRawNames.includes(name)) { + effects.consume(code); + return continuationClose + } + return continuation(code) + } + if (asciiAlpha(code) && buffer.length < 8) { + effects.consume(code); + // @ts-expect-error: not null. + buffer += String.fromCharCode(code); + return continuationRawEndTag + } + return continuation(code) + } + + /** + * In cdata continuation, after `]`, expecting `]>`. + * + * ```markdown + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function continuationCdataInside(code) { + if (code === 93) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In declaration or instruction continuation, at `>`. + * + * ```markdown + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | + * ^ + * > | &<]]> + * ^ + * ``` + * + * @type {State} + */ + function continuationDeclarationInside(code) { + if (code === 62) { + effects.consume(code); + return continuationClose + } + + // More dashes. + if (code === 45 && marker === 2) { + effects.consume(code); + return continuationDeclarationInside + } + return continuation(code) + } + + /** + * In closed continuation: everything we get until the eol/eof is part of it. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationClose(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('htmlFlowData'); + return continuationAfter(code) + } + effects.consume(code); + return continuationClose + } + + /** + * Done. + * + * ```markdown + * > | + * ^ + * ``` + * + * @type {State} + */ + function continuationAfter(code) { + effects.exit('htmlFlow'); + // // Feel free to interrupt. + // tokenizer.interrupt = false + // // No longer concrete. + // tokenizer.concrete = false + return ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeNonLazyContinuationStart(effects, ok, nok) { + const self = this; + return start + + /** + * At eol, before continuation. + * + * ```markdown + * > | * ```js + * ^ + * | b + * ``` + * + * @type {State} + */ + function start(code) { + if (markdownLineEnding(code)) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return after + } + return nok(code) + } + + /** + * A continuation. + * + * ```markdown + * | * ```js + * > | b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + return self.parser.lazy[self.now().line] ? nok(code) : ok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeBlankLineBefore(effects, ok, nok) { + return start + + /** + * Before eol, expecting blank line. + * + * ```markdown + * > |
    + * ^ + * | + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return effects.attempt(blankLine, ok, nok) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const htmlText = { + name: 'htmlText', + tokenize: tokenizeHtmlText +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeHtmlText(effects, ok, nok) { + const self = this; + /** @type {NonNullable | undefined} */ + let marker; + /** @type {number} */ + let index; + /** @type {State} */ + let returnState; + return start + + /** + * Start of HTML (text). + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('htmlText'); + effects.enter('htmlTextData'); + effects.consume(code); + return open + } + + /** + * After `<`, at tag name or other stuff. + * + * ```markdown + * > | a c + * ^ + * > | a c + * ^ + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 33) { + effects.consume(code); + return declarationOpen + } + if (code === 47) { + effects.consume(code); + return tagCloseStart + } + if (code === 63) { + effects.consume(code); + return instruction + } + + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + return tagOpen + } + return nok(code) + } + + /** + * After ` | a c + * ^ + * > | a c + * ^ + * > | a &<]]> c + * ^ + * ``` + * + * @type {State} + */ + function declarationOpen(code) { + if (code === 45) { + effects.consume(code); + return commentOpenInside + } + if (code === 91) { + effects.consume(code); + index = 0; + return cdataOpenInside + } + if (asciiAlpha(code)) { + effects.consume(code); + return declaration + } + return nok(code) + } + + /** + * In a comment, after ` | a c + * ^ + * ``` + * + * @type {State} + */ + function commentOpenInside(code) { + if (code === 45) { + effects.consume(code); + return commentEnd + } + return nok(code) + } + + /** + * In comment. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function comment(code) { + if (code === null) { + return nok(code) + } + if (code === 45) { + effects.consume(code); + return commentClose + } + if (markdownLineEnding(code)) { + returnState = comment; + return lineEndingBefore(code) + } + effects.consume(code); + return comment + } + + /** + * In comment, after `-`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function commentClose(code) { + if (code === 45) { + effects.consume(code); + return commentEnd + } + return comment(code) + } + + /** + * In comment, after `--`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function commentEnd(code) { + return code === 62 + ? end(code) + : code === 45 + ? commentClose(code) + : comment(code) + } + + /** + * After ` | a &<]]> b + * ^^^^^^ + * ``` + * + * @type {State} + */ + function cdataOpenInside(code) { + const value = 'CDATA['; + if (code === value.charCodeAt(index++)) { + effects.consume(code); + return index === value.length ? cdata : cdataOpenInside + } + return nok(code) + } + + /** + * In CDATA. + * + * ```markdown + * > | a &<]]> b + * ^^^ + * ``` + * + * @type {State} + */ + function cdata(code) { + if (code === null) { + return nok(code) + } + if (code === 93) { + effects.consume(code); + return cdataClose + } + if (markdownLineEnding(code)) { + returnState = cdata; + return lineEndingBefore(code) + } + effects.consume(code); + return cdata + } + + /** + * In CDATA, after `]`, at another `]`. + * + * ```markdown + * > | a &<]]> b + * ^ + * ``` + * + * @type {State} + */ + function cdataClose(code) { + if (code === 93) { + effects.consume(code); + return cdataEnd + } + return cdata(code) + } + + /** + * In CDATA, after `]]`, at `>`. + * + * ```markdown + * > | a &<]]> b + * ^ + * ``` + * + * @type {State} + */ + function cdataEnd(code) { + if (code === 62) { + return end(code) + } + if (code === 93) { + effects.consume(code); + return cdataEnd + } + return cdata(code) + } + + /** + * In declaration. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function declaration(code) { + if (code === null || code === 62) { + return end(code) + } + if (markdownLineEnding(code)) { + returnState = declaration; + return lineEndingBefore(code) + } + effects.consume(code); + return declaration + } + + /** + * In instruction. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function instruction(code) { + if (code === null) { + return nok(code) + } + if (code === 63) { + effects.consume(code); + return instructionClose + } + if (markdownLineEnding(code)) { + returnState = instruction; + return lineEndingBefore(code) + } + effects.consume(code); + return instruction + } + + /** + * In instruction, after `?`, at `>`. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function instructionClose(code) { + return code === 62 ? end(code) : instruction(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagCloseStart(code) { + // ASCII alphabetical. + if (asciiAlpha(code)) { + effects.consume(code); + return tagClose + } + return nok(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagClose(code) { + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagClose + } + return tagCloseBetween(code) + } + + /** + * In closing tag, after tag name. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function tagCloseBetween(code) { + if (markdownLineEnding(code)) { + returnState = tagCloseBetween; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagCloseBetween + } + return end(code) + } + + /** + * After ` | a c + * ^ + * ``` + * + * @type {State} + */ + function tagOpen(code) { + // ASCII alphanumerical and `-`. + if (code === 45 || asciiAlphanumeric(code)) { + effects.consume(code); + return tagOpen + } + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + return nok(code) + } + + /** + * In opening tag, after tag name. + * + * ```markdown + * > | a c + * ^ + * ``` + * + * @type {State} + */ + function tagOpenBetween(code) { + if (code === 47) { + effects.consume(code); + return end + } + + // ASCII alphabetical and `:` and `_`. + if (code === 58 || code === 95 || asciiAlpha(code)) { + effects.consume(code); + return tagOpenAttributeName + } + if (markdownLineEnding(code)) { + returnState = tagOpenBetween; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenBetween + } + return end(code) + } + + /** + * In attribute name. + * + * ```markdown + * > | a d + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeName(code) { + // ASCII alphabetical and `-`, `.`, `:`, and `_`. + if ( + code === 45 || + code === 46 || + code === 58 || + code === 95 || + asciiAlphanumeric(code) + ) { + effects.consume(code); + return tagOpenAttributeName + } + return tagOpenAttributeNameAfter(code) + } + + /** + * After attribute name, before initializer, the end of the tag, or + * whitespace. + * + * ```markdown + * > | a d + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeNameAfter(code) { + if (code === 61) { + effects.consume(code); + return tagOpenAttributeValueBefore + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeNameAfter; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeNameAfter + } + return tagOpenBetween(code) + } + + /** + * Before unquoted, double quoted, or single quoted attribute value, allowing + * whitespace. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueBefore(code) { + if ( + code === null || + code === 60 || + code === 61 || + code === 62 || + code === 96 + ) { + return nok(code) + } + if (code === 34 || code === 39) { + effects.consume(code); + marker = code; + return tagOpenAttributeValueQuoted + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueBefore; + return lineEndingBefore(code) + } + if (markdownSpace(code)) { + effects.consume(code); + return tagOpenAttributeValueBefore + } + effects.consume(code); + return tagOpenAttributeValueUnquoted + } + + /** + * In double or single quoted attribute value. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueQuoted(code) { + if (code === marker) { + effects.consume(code); + marker = undefined; + return tagOpenAttributeValueQuotedAfter + } + if (code === null) { + return nok(code) + } + if (markdownLineEnding(code)) { + returnState = tagOpenAttributeValueQuoted; + return lineEndingBefore(code) + } + effects.consume(code); + return tagOpenAttributeValueQuoted + } + + /** + * In unquoted attribute value. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueUnquoted(code) { + if ( + code === null || + code === 34 || + code === 39 || + code === 60 || + code === 61 || + code === 96 + ) { + return nok(code) + } + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + effects.consume(code); + return tagOpenAttributeValueUnquoted + } + + /** + * After double or single quoted attribute value, before whitespace or the end + * of the tag. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function tagOpenAttributeValueQuotedAfter(code) { + if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) { + return tagOpenBetween(code) + } + return nok(code) + } + + /** + * In certain circumstances of a tag where only an `>` is allowed. + * + * ```markdown + * > | a e + * ^ + * ``` + * + * @type {State} + */ + function end(code) { + if (code === 62) { + effects.consume(code); + effects.exit('htmlTextData'); + effects.exit('htmlText'); + return ok + } + return nok(code) + } + + /** + * At eol. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * > | a + * ``` + * + * @type {State} + */ + function lineEndingBefore(code) { + effects.exit('htmlTextData'); + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return lineEndingAfter + } + + /** + * After eol, at optional whitespace. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * | a + * ^ + * ``` + * + * @type {State} + */ + function lineEndingAfter(code) { + // Always populated by defaults. + + return markdownSpace(code) + ? factorySpace( + effects, + lineEndingAfterPrefix, + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + : lineEndingAfterPrefix(code) + } + + /** + * After eol, after optional whitespace. + * + * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about + * > empty tokens. + * + * ```markdown + * | a + * ^ + * ``` + * + * @type {State} + */ + function lineEndingAfterPrefix(code) { + effects.enter('htmlTextData'); + return returnState(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const labelEnd = { + name: 'labelEnd', + tokenize: tokenizeLabelEnd, + resolveTo: resolveToLabelEnd, + resolveAll: resolveAllLabelEnd +}; + +/** @type {Construct} */ +const resourceConstruct = { + tokenize: tokenizeResource +}; +/** @type {Construct} */ +const referenceFullConstruct = { + tokenize: tokenizeReferenceFull +}; +/** @type {Construct} */ +const referenceCollapsedConstruct = { + tokenize: tokenizeReferenceCollapsed +}; + +/** @type {Resolver} */ +function resolveAllLabelEnd(events) { + let index = -1; + while (++index < events.length) { + const token = events[index][1]; + if ( + token.type === 'labelImage' || + token.type === 'labelLink' || + token.type === 'labelEnd' + ) { + // Remove the marker. + events.splice(index + 1, token.type === 'labelImage' ? 4 : 2); + token.type = 'data'; + index++; + } + } + return events +} + +/** @type {Resolver} */ +function resolveToLabelEnd(events, context) { + let index = events.length; + let offset = 0; + /** @type {Token} */ + let token; + /** @type {number | undefined} */ + let open; + /** @type {number | undefined} */ + let close; + /** @type {Array} */ + let media; + + // Find an opening. + while (index--) { + token = events[index][1]; + if (open) { + // If we see another link, or inactive link label, we’ve been here before. + if ( + token.type === 'link' || + (token.type === 'labelLink' && token._inactive) + ) { + break + } + + // Mark other link openings as inactive, as we can’t have links in + // links. + if (events[index][0] === 'enter' && token.type === 'labelLink') { + token._inactive = true; + } + } else if (close) { + if ( + events[index][0] === 'enter' && + (token.type === 'labelImage' || token.type === 'labelLink') && + !token._balanced + ) { + open = index; + if (token.type !== 'labelLink') { + offset = 2; + break + } + } + } else if (token.type === 'labelEnd') { + close = index; + } + } + const group = { + type: events[open][1].type === 'labelLink' ? 'link' : 'image', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + const label = { + type: 'label', + start: Object.assign({}, events[open][1].start), + end: Object.assign({}, events[close][1].end) + }; + const text = { + type: 'labelText', + start: Object.assign({}, events[open + offset + 2][1].end), + end: Object.assign({}, events[close - 2][1].start) + }; + media = [ + ['enter', group, context], + ['enter', label, context] + ]; + + // Opening marker. + media = push$1(media, events.slice(open + 1, open + offset + 3)); + + // Text open. + media = push$1(media, [['enter', text, context]]); + + // Always populated by defaults. + + // Between. + media = push$1( + media, + resolveAll( + context.parser.constructs.insideSpan.null, + events.slice(open + offset + 4, close - 3), + context + ) + ); + + // Text close, marker close, label close. + media = push$1(media, [ + ['exit', text, context], + events[close - 2], + events[close - 1], + ['exit', label, context] + ]); + + // Reference, resource, or so. + media = push$1(media, events.slice(close + 1)); + + // Media close. + media = push$1(media, [['exit', group, context]]); + splice$1(events, open, events.length, media); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelEnd(effects, ok, nok) { + const self = this; + let index = self.events.length; + /** @type {Token} */ + let labelStart; + /** @type {boolean} */ + let defined; + + // Find an opening. + while (index--) { + if ( + (self.events[index][1].type === 'labelImage' || + self.events[index][1].type === 'labelLink') && + !self.events[index][1]._balanced + ) { + labelStart = self.events[index][1]; + break + } + } + return start + + /** + * Start of label end. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ``` + * + * @type {State} + */ + function start(code) { + // If there is not an okay opening. + if (!labelStart) { + return nok(code) + } + + // If the corresponding label (link) start is marked as inactive, + // it means we’d be wrapping a link, like this: + // + // ```markdown + // > | a [b [c](d) e](f) g. + // ^ + // ``` + // + // We can’t have that, so it’s just balanced brackets. + if (labelStart._inactive) { + return labelEndNok(code) + } + defined = self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize({ + start: labelStart.end, + end: self.now() + }) + ) + ); + effects.enter('labelEnd'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelEnd'); + return after + } + + /** + * After `]`. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + // Note: `markdown-rs` also parses GFM footnotes here, which for us is in + // an extension. + + // Resource (`[asd](fgh)`)? + if (code === 40) { + return effects.attempt( + resourceConstruct, + labelEndOk, + defined ? labelEndOk : labelEndNok + )(code) + } + + // Full (`[asd][fgh]`) or collapsed (`[asd][]`) reference? + if (code === 91) { + return effects.attempt( + referenceFullConstruct, + labelEndOk, + defined ? referenceNotFull : labelEndNok + )(code) + } + + // Shortcut (`[asd]`) reference? + return defined ? labelEndOk(code) : labelEndNok(code) + } + + /** + * After `]`, at `[`, but not at a full reference. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function referenceNotFull(code) { + return effects.attempt( + referenceCollapsedConstruct, + labelEndOk, + labelEndNok + )(code) + } + + /** + * Done, we found something. + * + * ```markdown + * > | [a](b) c + * ^ + * > | [a][b] c + * ^ + * > | [a][] b + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function labelEndOk(code) { + // Note: `markdown-rs` does a bunch of stuff here. + return ok(code) + } + + /** + * Done, it’s nothing. + * + * There was an okay opening, but we didn’t match anything. + * + * ```markdown + * > | [a](b c + * ^ + * > | [a][b c + * ^ + * > | [a] b + * ^ + * ``` + * + * @type {State} + */ + function labelEndNok(code) { + labelStart._balanced = true; + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeResource(effects, ok, nok) { + return resourceStart + + /** + * At a resource. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceStart(code) { + effects.enter('resource'); + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + return resourceBefore + } + + /** + * In resource, after `(`, at optional whitespace. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceBefore(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceOpen)(code) + : resourceOpen(code) + } + + /** + * In resource, after optional whitespace, at `)` or a destination. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceOpen(code) { + if (code === 41) { + return resourceEnd(code) + } + return factoryDestination( + effects, + resourceDestinationAfter, + resourceDestinationMissing, + 'resourceDestination', + 'resourceDestinationLiteral', + 'resourceDestinationLiteralMarker', + 'resourceDestinationRaw', + 'resourceDestinationString', + 32 + )(code) + } + + /** + * In resource, after destination, at optional whitespace. + * + * ```markdown + * > | [a](b) c + * ^ + * ``` + * + * @type {State} + */ + function resourceDestinationAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceBetween)(code) + : resourceEnd(code) + } + + /** + * At invalid destination. + * + * ```markdown + * > | [a](<<) b + * ^ + * ``` + * + * @type {State} + */ + function resourceDestinationMissing(code) { + return nok(code) + } + + /** + * In resource, after destination and whitespace, at `(` or title. + * + * ```markdown + * > | [a](b ) c + * ^ + * ``` + * + * @type {State} + */ + function resourceBetween(code) { + if (code === 34 || code === 39 || code === 40) { + return factoryTitle( + effects, + resourceTitleAfter, + nok, + 'resourceTitle', + 'resourceTitleMarker', + 'resourceTitleString' + )(code) + } + return resourceEnd(code) + } + + /** + * In resource, after title, at optional whitespace. + * + * ```markdown + * > | [a](b "c") d + * ^ + * ``` + * + * @type {State} + */ + function resourceTitleAfter(code) { + return markdownLineEndingOrSpace(code) + ? factoryWhitespace(effects, resourceEnd)(code) + : resourceEnd(code) + } + + /** + * In resource, at `)`. + * + * ```markdown + * > | [a](b) d + * ^ + * ``` + * + * @type {State} + */ + function resourceEnd(code) { + if (code === 41) { + effects.enter('resourceMarker'); + effects.consume(code); + effects.exit('resourceMarker'); + effects.exit('resource'); + return ok + } + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeReferenceFull(effects, ok, nok) { + const self = this; + return referenceFull + + /** + * In a reference (full), at the `[`. + * + * ```markdown + * > | [a][b] d + * ^ + * ``` + * + * @type {State} + */ + function referenceFull(code) { + return factoryLabel.call( + self, + effects, + referenceFullAfter, + referenceFullMissing, + 'reference', + 'referenceMarker', + 'referenceString' + )(code) + } + + /** + * In a reference (full), after `]`. + * + * ```markdown + * > | [a][b] d + * ^ + * ``` + * + * @type {State} + */ + function referenceFullAfter(code) { + return self.parser.defined.includes( + normalizeIdentifier( + self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1) + ) + ) + ? ok(code) + : nok(code) + } + + /** + * In reference (full) that was missing. + * + * ```markdown + * > | [a][b d + * ^ + * ``` + * + * @type {State} + */ + function referenceFullMissing(code) { + return nok(code) + } +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeReferenceCollapsed(effects, ok, nok) { + return referenceCollapsedStart + + /** + * In reference (collapsed), at `[`. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] d + * ^ + * ``` + * + * @type {State} + */ + function referenceCollapsedStart(code) { + // We only attempt a collapsed label if there’s a `[`. + + effects.enter('reference'); + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + return referenceCollapsedOpen + } + + /** + * In reference (collapsed), at `]`. + * + * > 👉 **Note**: we only get here if the label is defined. + * + * ```markdown + * > | [a][] d + * ^ + * ``` + * + * @type {State} + */ + function referenceCollapsedOpen(code) { + if (code === 93) { + effects.enter('referenceMarker'); + effects.consume(code); + effects.exit('referenceMarker'); + effects.exit('reference'); + return ok + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const labelStartImage = { + name: 'labelStartImage', + tokenize: tokenizeLabelStartImage, + resolveAll: labelEnd.resolveAll +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelStartImage(effects, ok, nok) { + const self = this; + return start + + /** + * Start of label (image) start. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('labelImage'); + effects.enter('labelImageMarker'); + effects.consume(code); + effects.exit('labelImageMarker'); + return open + } + + /** + * After `!`, at `[`. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * @type {State} + */ + function open(code) { + if (code === 91) { + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelImage'); + return after + } + return nok(code) + } + + /** + * After `![`. + * + * ```markdown + * > | a ![b] c + * ^ + * ``` + * + * This is needed in because, when GFM footnotes are enabled, images never + * form when started with a `^`. + * Instead, links form: + * + * ```markdown + * ![^a](b) + * + * ![^a][b] + * + * [b]: c + * ``` + * + * ```html + *

    !^a

    + *

    !^a

    + * ``` + * + * @type {State} + */ + function after(code) { + // To do: use a new field to do this, this is still needed for + // `micromark-extension-gfm-footnote`, but the `label-start-link` + // behavior isn’t. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const labelStartLink = { + name: 'labelStartLink', + tokenize: tokenizeLabelStartLink, + resolveAll: labelEnd.resolveAll +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLabelStartLink(effects, ok, nok) { + const self = this; + return start + + /** + * Start of label (link) start. + * + * ```markdown + * > | a [b] c + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('labelLink'); + effects.enter('labelMarker'); + effects.consume(code); + effects.exit('labelMarker'); + effects.exit('labelLink'); + return after + } + + /** @type {State} */ + function after(code) { + // To do: this isn’t needed in `micromark-extension-gfm-footnote`, + // remove. + // Hidden footnotes hook. + /* c8 ignore next 3 */ + return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs + ? nok(code) + : ok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const lineEnding = { + name: 'lineEnding', + tokenize: tokenizeLineEnding +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeLineEnding(effects, ok) { + return start + + /** @type {State} */ + function start(code) { + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + return factorySpace(effects, ok, 'linePrefix') + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const thematicBreak = { + name: 'thematicBreak', + tokenize: tokenizeThematicBreak +}; + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeThematicBreak(effects, ok, nok) { + let size = 0; + /** @type {NonNullable} */ + let marker; + return start + + /** + * Start of thematic break. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + effects.enter('thematicBreak'); + // To do: parse indent like `markdown-rs`. + return before(code) + } + + /** + * After optional whitespace, at marker. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + marker = code; + return atBreak(code) + } + + /** + * After something, before something else. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function atBreak(code) { + if (code === marker) { + effects.enter('thematicBreakSequence'); + return sequence(code) + } + if (size >= 3 && (code === null || markdownLineEnding(code))) { + effects.exit('thematicBreak'); + return ok(code) + } + return nok(code) + } + + /** + * In sequence. + * + * ```markdown + * > | *** + * ^ + * ``` + * + * @type {State} + */ + function sequence(code) { + if (code === marker) { + effects.consume(code); + size++; + return sequence + } + effects.exit('thematicBreakSequence'); + return markdownSpace(code) + ? factorySpace(effects, atBreak, 'whitespace')(code) + : atBreak(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ContainerState} ContainerState + * @typedef {import('micromark-util-types').Exiter} Exiter + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + + +/** @type {Construct} */ +const list = { + name: 'list', + tokenize: tokenizeListStart, + continuation: { + tokenize: tokenizeListContinuation + }, + exit: tokenizeListEnd +}; + +/** @type {Construct} */ +const listItemPrefixWhitespaceConstruct = { + tokenize: tokenizeListItemPrefixWhitespace, + partial: true +}; + +/** @type {Construct} */ +const indentConstruct = { + tokenize: tokenizeIndent, + partial: true +}; + +// To do: `markdown-rs` parses list items on their own and later stitches them +// together. + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListStart(effects, ok, nok) { + const self = this; + const tail = self.events[self.events.length - 1]; + let initialSize = + tail && tail[1].type === 'linePrefix' + ? tail[2].sliceSerialize(tail[1], true).length + : 0; + let size = 0; + return start + + /** @type {State} */ + function start(code) { + const kind = + self.containerState.type || + (code === 42 || code === 43 || code === 45 + ? 'listUnordered' + : 'listOrdered'); + if ( + kind === 'listUnordered' + ? !self.containerState.marker || code === self.containerState.marker + : asciiDigit(code) + ) { + if (!self.containerState.type) { + self.containerState.type = kind; + effects.enter(kind, { + _container: true + }); + } + if (kind === 'listUnordered') { + effects.enter('listItemPrefix'); + return code === 42 || code === 45 + ? effects.check(thematicBreak, nok, atMarker)(code) + : atMarker(code) + } + if (!self.interrupt || code === 49) { + effects.enter('listItemPrefix'); + effects.enter('listItemValue'); + return inside(code) + } + } + return nok(code) + } + + /** @type {State} */ + function inside(code) { + if (asciiDigit(code) && ++size < 10) { + effects.consume(code); + return inside + } + if ( + (!self.interrupt || size < 2) && + (self.containerState.marker + ? code === self.containerState.marker + : code === 41 || code === 46) + ) { + effects.exit('listItemValue'); + return atMarker(code) + } + return nok(code) + } + + /** + * @type {State} + **/ + function atMarker(code) { + effects.enter('listItemMarker'); + effects.consume(code); + effects.exit('listItemMarker'); + self.containerState.marker = self.containerState.marker || code; + return effects.check( + blankLine, + // Can’t be empty when interrupting. + self.interrupt ? nok : onBlank, + effects.attempt( + listItemPrefixWhitespaceConstruct, + endOfPrefix, + otherPrefix + ) + ) + } + + /** @type {State} */ + function onBlank(code) { + self.containerState.initialBlankLine = true; + initialSize++; + return endOfPrefix(code) + } + + /** @type {State} */ + function otherPrefix(code) { + if (markdownSpace(code)) { + effects.enter('listItemPrefixWhitespace'); + effects.consume(code); + effects.exit('listItemPrefixWhitespace'); + return endOfPrefix + } + return nok(code) + } + + /** @type {State} */ + function endOfPrefix(code) { + self.containerState.size = + initialSize + + self.sliceSerialize(effects.exit('listItemPrefix'), true).length; + return ok(code) + } +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListContinuation(effects, ok, nok) { + const self = this; + self.containerState._closeFlow = undefined; + return effects.check(blankLine, onBlank, notBlank) + + /** @type {State} */ + function onBlank(code) { + self.containerState.furtherBlankLines = + self.containerState.furtherBlankLines || + self.containerState.initialBlankLine; + + // We have a blank line. + // Still, try to consume at most the items size. + return factorySpace( + effects, + ok, + 'listItemIndent', + self.containerState.size + 1 + )(code) + } + + /** @type {State} */ + function notBlank(code) { + if (self.containerState.furtherBlankLines || !markdownSpace(code)) { + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return notInCurrentItem(code) + } + self.containerState.furtherBlankLines = undefined; + self.containerState.initialBlankLine = undefined; + return effects.attempt(indentConstruct, ok, notInCurrentItem)(code) + } + + /** @type {State} */ + function notInCurrentItem(code) { + // While we do continue, we signal that the flow should be closed. + self.containerState._closeFlow = true; + // As we’re closing flow, we’re no longer interrupting. + self.interrupt = undefined; + // Always populated by defaults. + + return factorySpace( + effects, + effects.attempt(list, ok, nok), + 'linePrefix', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + )(code) + } +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeIndent(effects, ok, nok) { + const self = this; + return factorySpace( + effects, + afterPrefix, + 'listItemIndent', + self.containerState.size + 1 + ) + + /** @type {State} */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return tail && + tail[1].type === 'listItemIndent' && + tail[2].sliceSerialize(tail[1], true).length === self.containerState.size + ? ok(code) + : nok(code) + } +} + +/** + * @type {Exiter} + * @this {TokenizeContext} + */ +function tokenizeListEnd(effects) { + effects.exit(this.containerState.type); +} + +/** + * @type {Tokenizer} + * @this {TokenizeContext} + */ +function tokenizeListItemPrefixWhitespace(effects, ok, nok) { + const self = this; + + // Always populated by defaults. + + return factorySpace( + effects, + afterPrefix, + 'listItemPrefixWhitespace', + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : 4 + 1 + ) + + /** @type {State} */ + function afterPrefix(code) { + const tail = self.events[self.events.length - 1]; + return !markdownSpace(code) && + tail && + tail[1].type === 'listItemPrefixWhitespace' + ? ok(code) + : nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Tokenizer} Tokenizer + */ + +/** @type {Construct} */ +const setextUnderline = { + name: 'setextUnderline', + tokenize: tokenizeSetextUnderline, + resolveTo: resolveToSetextUnderline +}; + +/** @type {Resolver} */ +function resolveToSetextUnderline(events, context) { + // To do: resolve like `markdown-rs`. + let index = events.length; + /** @type {number | undefined} */ + let content; + /** @type {number | undefined} */ + let text; + /** @type {number | undefined} */ + let definition; + + // Find the opening of the content. + // It’ll always exist: we don’t tokenize if it isn’t there. + while (index--) { + if (events[index][0] === 'enter') { + if (events[index][1].type === 'content') { + content = index; + break + } + if (events[index][1].type === 'paragraph') { + text = index; + } + } + // Exit + else { + if (events[index][1].type === 'content') { + // Remove the content end (if needed we’ll add it later) + events.splice(index, 1); + } + if (!definition && events[index][1].type === 'definition') { + definition = index; + } + } + } + const heading = { + type: 'setextHeading', + start: Object.assign({}, events[text][1].start), + end: Object.assign({}, events[events.length - 1][1].end) + }; + + // Change the paragraph to setext heading text. + events[text][1].type = 'setextHeadingText'; + + // If we have definitions in the content, we’ll keep on having content, + // but we need move it. + if (definition) { + events.splice(text, 0, ['enter', heading, context]); + events.splice(definition + 1, 0, ['exit', events[content][1], context]); + events[content][1].end = Object.assign({}, events[definition][1].end); + } else { + events[content][1] = heading; + } + + // Add the heading exit at the end. + events.push(['exit', heading, context]); + return events +} + +/** + * @this {TokenizeContext} + * @type {Tokenizer} + */ +function tokenizeSetextUnderline(effects, ok, nok) { + const self = this; + /** @type {NonNullable} */ + let marker; + return start + + /** + * At start of heading (setext) underline. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function start(code) { + let index = self.events.length; + /** @type {boolean | undefined} */ + let paragraph; + // Find an opening. + while (index--) { + // Skip enter/exit of line ending, line prefix, and content. + // We can now either have a definition or a paragraph. + if ( + self.events[index][1].type !== 'lineEnding' && + self.events[index][1].type !== 'linePrefix' && + self.events[index][1].type !== 'content' + ) { + paragraph = self.events[index][1].type === 'paragraph'; + break + } + } + + // To do: handle lazy/pierce like `markdown-rs`. + // To do: parse indent like `markdown-rs`. + if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) { + effects.enter('setextHeadingLine'); + marker = code; + return before(code) + } + return nok(code) + } + + /** + * After optional whitespace, at `-` or `=`. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function before(code) { + effects.enter('setextHeadingLineSequence'); + return inside(code) + } + + /** + * In sequence. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function inside(code) { + if (code === marker) { + effects.consume(code); + return inside + } + effects.exit('setextHeadingLineSequence'); + return markdownSpace(code) + ? factorySpace(effects, after, 'lineSuffix')(code) + : after(code) + } + + /** + * After sequence, after optional whitespace. + * + * ```markdown + * | aa + * > | == + * ^ + * ``` + * + * @type {State} + */ + function after(code) { + if (code === null || markdownLineEnding(code)) { + effects.exit('setextHeadingLine'); + return ok(code) + } + return nok(code) + } +} + +/** + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** @type {InitialConstruct} */ +const flow$1 = { + tokenize: initializeFlow +}; + +/** + * @this {TokenizeContext} + * @type {Initializer} + */ +function initializeFlow(effects) { + const self = this; + const initial = effects.attempt( + // Try to parse a blank line. + blankLine, + atBlankEnding, + // Try to parse initial flow (essentially, only code). + effects.attempt( + this.parser.constructs.flowInitial, + afterConstruct, + factorySpace( + effects, + effects.attempt( + this.parser.constructs.flow, + afterConstruct, + effects.attempt(content, afterConstruct) + ), + 'linePrefix' + ) + ) + ); + return initial + + /** @type {State} */ + function atBlankEnding(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEndingBlank'); + effects.consume(code); + effects.exit('lineEndingBlank'); + self.currentConstruct = undefined; + return initial + } + + /** @type {State} */ + function afterConstruct(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('lineEnding'); + effects.consume(code); + effects.exit('lineEnding'); + self.currentConstruct = undefined; + return initial + } +} + +/** + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').Initializer} Initializer + * @typedef {import('micromark-util-types').Resolver} Resolver + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +const resolver$1 = { + resolveAll: createResolver() +}; +const string$2 = initializeFactory('string'); +const text$1 = initializeFactory('text'); + +/** + * @param {'string' | 'text'} field + * @returns {InitialConstruct} + */ +function initializeFactory(field) { + return { + tokenize: initializeText, + resolveAll: createResolver( + field === 'text' ? resolveAllLineSuffixes : undefined + ) + } + + /** + * @this {TokenizeContext} + * @type {Initializer} + */ + function initializeText(effects) { + const self = this; + const constructs = this.parser.constructs[field]; + const text = effects.attempt(constructs, start, notText); + return start + + /** @type {State} */ + function start(code) { + return atBreak(code) ? text(code) : notText(code) + } + + /** @type {State} */ + function notText(code) { + if (code === null) { + effects.consume(code); + return + } + effects.enter('data'); + effects.consume(code); + return data + } + + /** @type {State} */ + function data(code) { + if (atBreak(code)) { + effects.exit('data'); + return text(code) + } + + // Data. + effects.consume(code); + return data + } + + /** + * @param {Code} code + * @returns {boolean} + */ + function atBreak(code) { + if (code === null) { + return true + } + const list = constructs[code]; + let index = -1; + if (list) { + // Always populated by defaults. + + while (++index < list.length) { + const item = list[index]; + if (!item.previous || item.previous.call(self, self.previous)) { + return true + } + } + } + return false + } + } +} + +/** + * @param {Resolver | undefined} [extraResolver] + * @returns {Resolver} + */ +function createResolver(extraResolver) { + return resolveAllText + + /** @type {Resolver} */ + function resolveAllText(events, context) { + let index = -1; + /** @type {number | undefined} */ + let enter; + + // A rather boring computation (to merge adjacent `data` events) which + // improves mm performance by 29%. + while (++index <= events.length) { + if (enter === undefined) { + if (events[index] && events[index][1].type === 'data') { + enter = index; + index++; + } + } else if (!events[index] || events[index][1].type !== 'data') { + // Don’t do anything if there is one data token. + if (index !== enter + 2) { + events[enter][1].end = events[index - 1][1].end; + events.splice(enter + 2, index - enter - 2); + index = enter + 2; + } + enter = undefined; + } + } + return extraResolver ? extraResolver(events, context) : events + } +} + +/** + * A rather ugly set of instructions which again looks at chunks in the input + * stream. + * The reason to do this here is that it is *much* faster to parse in reverse. + * And that we can’t hook into `null` to split the line suffix before an EOF. + * To do: figure out if we can make this into a clean utility, or even in core. + * As it will be useful for GFMs literal autolink extension (and maybe even + * tables?) + * + * @type {Resolver} + */ +function resolveAllLineSuffixes(events, context) { + let eventIndex = 0; // Skip first. + + while (++eventIndex <= events.length) { + if ( + (eventIndex === events.length || + events[eventIndex][1].type === 'lineEnding') && + events[eventIndex - 1][1].type === 'data' + ) { + const data = events[eventIndex - 1][1]; + const chunks = context.sliceStream(data); + let index = chunks.length; + let bufferIndex = -1; + let size = 0; + /** @type {boolean | undefined} */ + let tabs; + while (index--) { + const chunk = chunks[index]; + if (typeof chunk === 'string') { + bufferIndex = chunk.length; + while (chunk.charCodeAt(bufferIndex - 1) === 32) { + size++; + bufferIndex--; + } + if (bufferIndex) break + bufferIndex = -1; + } + // Number + else if (chunk === -2) { + tabs = true; + size++; + } else if (chunk === -1) ; else { + // Replacement character, exit. + index++; + break + } + } + if (size) { + const token = { + type: + eventIndex === events.length || tabs || size < 2 + ? 'lineSuffix' + : 'hardBreakTrailing', + start: { + line: data.end.line, + column: data.end.column - size, + offset: data.end.offset - size, + _index: data.start._index + index, + _bufferIndex: index + ? bufferIndex + : data.start._bufferIndex + bufferIndex + }, + end: Object.assign({}, data.end) + }; + data.end = Object.assign({}, token.start); + if (data.start.offset === data.end.offset) { + Object.assign(data, token); + } else { + events.splice( + eventIndex, + 0, + ['enter', token, context], + ['exit', token, context] + ); + eventIndex += 2; + } + } + eventIndex++; + } + } + return events +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Construct} Construct + * @typedef {import('micromark-util-types').ConstructRecord} ConstructRecord + * @typedef {import('micromark-util-types').Effects} Effects + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').Point} Point + * @typedef {import('micromark-util-types').State} State + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenType} TokenType + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + */ + +/** + * Create a tokenizer. + * Tokenizers deal with one type of data (e.g., containers, flow, text). + * The parser is the object dealing with it all. + * `initialize` works like other constructs, except that only its `tokenize` + * function is used, in which case it doesn’t receive an `ok` or `nok`. + * `from` can be given to set the point before the first character, although + * when further lines are indented, they must be set with `defineSkip`. + * + * @param {ParseContext} parser + * @param {InitialConstruct} initialize + * @param {Omit | undefined} [from] + * @returns {TokenizeContext} + */ +function createTokenizer(parser, initialize, from) { + /** @type {Point} */ + let point = Object.assign( + from + ? Object.assign({}, from) + : { + line: 1, + column: 1, + offset: 0 + }, + { + _index: 0, + _bufferIndex: -1 + } + ); + /** @type {Record} */ + const columnStart = {}; + /** @type {Array} */ + const resolveAllConstructs = []; + /** @type {Array} */ + let chunks = []; + /** @type {Array} */ + let stack = []; + + /** + * Tools used for tokenizing. + * + * @type {Effects} + */ + const effects = { + consume, + enter, + exit, + attempt: constructFactory(onsuccessfulconstruct), + check: constructFactory(onsuccessfulcheck), + interrupt: constructFactory(onsuccessfulcheck, { + interrupt: true + }) + }; + + /** + * State and tools for resolving and serializing. + * + * @type {TokenizeContext} + */ + const context = { + previous: null, + code: null, + containerState: {}, + events: [], + parser, + sliceStream, + sliceSerialize, + now, + defineSkip, + write + }; + + /** + * The state function. + * + * @type {State | void} + */ + let state = initialize.tokenize.call(context, effects); + if (initialize.resolveAll) { + resolveAllConstructs.push(initialize); + } + return context + + /** @type {TokenizeContext['write']} */ + function write(slice) { + chunks = push$1(chunks, slice); + main(); + + // Exit if we’re not done, resolve might change stuff. + if (chunks[chunks.length - 1] !== null) { + return [] + } + addResult(initialize, 0); + + // Otherwise, resolve, and exit. + context.events = resolveAll(resolveAllConstructs, context.events, context); + return context.events + } + + // + // Tools. + // + + /** @type {TokenizeContext['sliceSerialize']} */ + function sliceSerialize(token, expandTabs) { + return serializeChunks(sliceStream(token), expandTabs) + } + + /** @type {TokenizeContext['sliceStream']} */ + function sliceStream(token) { + return sliceChunks(chunks, token) + } + + /** @type {TokenizeContext['now']} */ + function now() { + // This is a hot path, so we clone manually instead of `Object.assign({}, point)` + const {line, column, offset, _index, _bufferIndex} = point; + return { + line, + column, + offset, + _index, + _bufferIndex + } + } + + /** @type {TokenizeContext['defineSkip']} */ + function defineSkip(value) { + columnStart[value.line] = value.column; + accountForPotentialSkip(); + } + + // + // State management. + // + + /** + * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by + * `consume`). + * Here is where we walk through the chunks, which either include strings of + * several characters, or numerical character codes. + * The reason to do this in a loop instead of a call is so the stack can + * drain. + * + * @returns {void} + */ + function main() { + /** @type {number} */ + let chunkIndex; + while (point._index < chunks.length) { + const chunk = chunks[point._index]; + + // If we’re in a buffer chunk, loop through it. + if (typeof chunk === 'string') { + chunkIndex = point._index; + if (point._bufferIndex < 0) { + point._bufferIndex = 0; + } + while ( + point._index === chunkIndex && + point._bufferIndex < chunk.length + ) { + go(chunk.charCodeAt(point._bufferIndex)); + } + } else { + go(chunk); + } + } + } + + /** + * Deal with one code. + * + * @param {Code} code + * @returns {void} + */ + function go(code) { + state = state(code); + } + + /** @type {Effects['consume']} */ + function consume(code) { + if (markdownLineEnding(code)) { + point.line++; + point.column = 1; + point.offset += code === -3 ? 2 : 1; + accountForPotentialSkip(); + } else if (code !== -1) { + point.column++; + point.offset++; + } + + // Not in a string chunk. + if (point._bufferIndex < 0) { + point._index++; + } else { + point._bufferIndex++; + + // At end of string chunk. + // @ts-expect-error Points w/ non-negative `_bufferIndex` reference + // strings. + if (point._bufferIndex === chunks[point._index].length) { + point._bufferIndex = -1; + point._index++; + } + } + + // Expose the previous character. + context.previous = code; + } + + /** @type {Effects['enter']} */ + function enter(type, fields) { + /** @type {Token} */ + // @ts-expect-error Patch instead of assign required fields to help GC. + const token = fields || {}; + token.type = type; + token.start = now(); + context.events.push(['enter', token, context]); + stack.push(token); + return token + } + + /** @type {Effects['exit']} */ + function exit(type) { + const token = stack.pop(); + token.end = now(); + context.events.push(['exit', token, context]); + return token + } + + /** + * Use results. + * + * @type {ReturnHandle} + */ + function onsuccessfulconstruct(construct, info) { + addResult(construct, info.from); + } + + /** + * Discard results. + * + * @type {ReturnHandle} + */ + function onsuccessfulcheck(_, info) { + info.restore(); + } + + /** + * Factory to attempt/check/interrupt. + * + * @param {ReturnHandle} onreturn + * @param {{interrupt?: boolean | undefined} | undefined} [fields] + */ + function constructFactory(onreturn, fields) { + return hook + + /** + * Handle either an object mapping codes to constructs, a list of + * constructs, or a single construct. + * + * @param {Array | Construct | ConstructRecord} constructs + * @param {State} returnState + * @param {State | undefined} [bogusState] + * @returns {State} + */ + function hook(constructs, returnState, bogusState) { + /** @type {Array} */ + let listOfConstructs; + /** @type {number} */ + let constructIndex; + /** @type {Construct} */ + let currentConstruct; + /** @type {Info} */ + let info; + return Array.isArray(constructs) /* c8 ignore next 1 */ + ? handleListOfConstructs(constructs) + : 'tokenize' in constructs + ? // @ts-expect-error Looks like a construct. + handleListOfConstructs([constructs]) + : handleMapOfConstructs(constructs) + + /** + * Handle a list of construct. + * + * @param {ConstructRecord} map + * @returns {State} + */ + function handleMapOfConstructs(map) { + return start + + /** @type {State} */ + function start(code) { + const def = code !== null && map[code]; + const all = code !== null && map.null; + const list = [ + // To do: add more extension tests. + /* c8 ignore next 2 */ + ...(Array.isArray(def) ? def : def ? [def] : []), + ...(Array.isArray(all) ? all : all ? [all] : []) + ]; + return handleListOfConstructs(list)(code) + } + } + + /** + * Handle a list of construct. + * + * @param {Array} list + * @returns {State} + */ + function handleListOfConstructs(list) { + listOfConstructs = list; + constructIndex = 0; + if (list.length === 0) { + return bogusState + } + return handleConstruct(list[constructIndex]) + } + + /** + * Handle a single construct. + * + * @param {Construct} construct + * @returns {State} + */ + function handleConstruct(construct) { + return start + + /** @type {State} */ + function start(code) { + // To do: not needed to store if there is no bogus state, probably? + // Currently doesn’t work because `inspect` in document does a check + // w/o a bogus, which doesn’t make sense. But it does seem to help perf + // by not storing. + info = store(); + currentConstruct = construct; + if (!construct.partial) { + context.currentConstruct = construct; + } + + // Always populated by defaults. + + if ( + construct.name && + context.parser.constructs.disable.null.includes(construct.name) + ) { + return nok() + } + return construct.tokenize.call( + // If we do have fields, create an object w/ `context` as its + // prototype. + // This allows a “live binding”, which is needed for `interrupt`. + fields ? Object.assign(Object.create(context), fields) : context, + effects, + ok, + nok + )(code) + } + } + + /** @type {State} */ + function ok(code) { + onreturn(currentConstruct, info); + return returnState + } + + /** @type {State} */ + function nok(code) { + info.restore(); + if (++constructIndex < listOfConstructs.length) { + return handleConstruct(listOfConstructs[constructIndex]) + } + return bogusState + } + } + } + + /** + * @param {Construct} construct + * @param {number} from + * @returns {void} + */ + function addResult(construct, from) { + if (construct.resolveAll && !resolveAllConstructs.includes(construct)) { + resolveAllConstructs.push(construct); + } + if (construct.resolve) { + splice$1( + context.events, + from, + context.events.length - from, + construct.resolve(context.events.slice(from), context) + ); + } + if (construct.resolveTo) { + context.events = construct.resolveTo(context.events, context); + } + } + + /** + * Store state. + * + * @returns {Info} + */ + function store() { + const startPoint = now(); + const startPrevious = context.previous; + const startCurrentConstruct = context.currentConstruct; + const startEventsIndex = context.events.length; + const startStack = Array.from(stack); + return { + restore, + from: startEventsIndex + } + + /** + * Restore state. + * + * @returns {void} + */ + function restore() { + point = startPoint; + context.previous = startPrevious; + context.currentConstruct = startCurrentConstruct; + context.events.length = startEventsIndex; + stack = startStack; + accountForPotentialSkip(); + } + } + + /** + * Move the current point a bit forward in the line when it’s on a column + * skip. + * + * @returns {void} + */ + function accountForPotentialSkip() { + if (point.line in columnStart && point.column < 2) { + point.column = columnStart[point.line]; + point.offset += columnStart[point.line] - 1; + } + } +} + +/** + * Get the chunks from a slice of chunks in the range of a token. + * + * @param {Array} chunks + * @param {Pick} token + * @returns {Array} + */ +function sliceChunks(chunks, token) { + const startIndex = token.start._index; + const startBufferIndex = token.start._bufferIndex; + const endIndex = token.end._index; + const endBufferIndex = token.end._bufferIndex; + /** @type {Array} */ + let view; + if (startIndex === endIndex) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)]; + } else { + view = chunks.slice(startIndex, endIndex); + if (startBufferIndex > -1) { + const head = view[0]; + if (typeof head === 'string') { + view[0] = head.slice(startBufferIndex); + } else { + view.shift(); + } + } + if (endBufferIndex > 0) { + // @ts-expect-error `_bufferIndex` is used on string chunks. + view.push(chunks[endIndex].slice(0, endBufferIndex)); + } + } + return view +} + +/** + * Get the string value of a slice of chunks. + * + * @param {Array} chunks + * @param {boolean | undefined} [expandTabs=false] + * @returns {string} + */ +function serializeChunks(chunks, expandTabs) { + let index = -1; + /** @type {Array} */ + const result = []; + /** @type {boolean | undefined} */ + let atTab; + while (++index < chunks.length) { + const chunk = chunks[index]; + /** @type {string} */ + let value; + if (typeof chunk === 'string') { + value = chunk; + } else + switch (chunk) { + case -5: { + value = '\r'; + break + } + case -4: { + value = '\n'; + break + } + case -3: { + value = '\r' + '\n'; + break + } + case -2: { + value = expandTabs ? ' ' : '\t'; + break + } + case -1: { + if (!expandTabs && atTab) continue + value = ' '; + break + } + default: { + // Currently only replacement character. + value = String.fromCharCode(chunk); + } + } + atTab = chunk === -2; + result.push(value); + } + return result.join('') +} + +/** + * @typedef {import('micromark-util-types').Extension} Extension + */ + + +/** @satisfies {Extension['document']} */ +const document$1 = { + [42]: list, + [43]: list, + [45]: list, + [48]: list, + [49]: list, + [50]: list, + [51]: list, + [52]: list, + [53]: list, + [54]: list, + [55]: list, + [56]: list, + [57]: list, + [62]: blockQuote +}; + +/** @satisfies {Extension['contentInitial']} */ +const contentInitial = { + [91]: definition +}; + +/** @satisfies {Extension['flowInitial']} */ +const flowInitial = { + [-2]: codeIndented, + [-1]: codeIndented, + [32]: codeIndented +}; + +/** @satisfies {Extension['flow']} */ +const flow = { + [35]: headingAtx, + [42]: thematicBreak, + [45]: [setextUnderline, thematicBreak], + [60]: htmlFlow, + [61]: setextUnderline, + [95]: thematicBreak, + [96]: codeFenced, + [126]: codeFenced +}; + +/** @satisfies {Extension['string']} */ +const string$1 = { + [38]: characterReference, + [92]: characterEscape +}; + +/** @satisfies {Extension['text']} */ +const text = { + [-5]: lineEnding, + [-4]: lineEnding, + [-3]: lineEnding, + [33]: labelStartImage, + [38]: characterReference, + [42]: attention, + [60]: [autolink, htmlText], + [91]: labelStartLink, + [92]: [hardBreakEscape, characterEscape], + [93]: labelEnd, + [95]: attention, + [96]: codeText +}; + +/** @satisfies {Extension['insideSpan']} */ +const insideSpan = { + null: [attention, resolver$1] +}; + +/** @satisfies {Extension['attentionMarkers']} */ +const attentionMarkers = { + null: [42, 95] +}; + +/** @satisfies {Extension['disable']} */ +const disable = { + null: [] +}; + +var defaultConstructs = /*#__PURE__*/Object.freeze({ + __proto__: null, + attentionMarkers: attentionMarkers, + contentInitial: contentInitial, + disable: disable, + document: document$1, + flow: flow, + flowInitial: flowInitial, + insideSpan: insideSpan, + string: string$1, + text: text +}); + +/** + * @typedef {import('micromark-util-types').Create} Create + * @typedef {import('micromark-util-types').FullNormalizedExtension} FullNormalizedExtension + * @typedef {import('micromark-util-types').InitialConstruct} InitialConstruct + * @typedef {import('micromark-util-types').ParseContext} ParseContext + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + */ + + +/** + * @param {ParseOptions | null | undefined} [options] + * @returns {ParseContext} + */ +function parse$3(options) { + const settings = options || {}; + const constructs = + /** @type {FullNormalizedExtension} */ + combineExtensions([defaultConstructs, ...(settings.extensions || [])]); + + /** @type {ParseContext} */ + const parser = { + defined: [], + lazy: {}, + constructs, + content: create(content$1), + document: create(document$2), + flow: create(flow$1), + string: create(string$2), + text: create(text$1) + }; + return parser + + /** + * @param {InitialConstruct} initial + */ + function create(initial) { + return creator + /** @type {Create} */ + function creator(from) { + return createTokenizer(parser, initial, from) + } + } +} + +/** + * @typedef {import('micromark-util-types').Chunk} Chunk + * @typedef {import('micromark-util-types').Code} Code + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Value} Value + */ + +/** + * @callback Preprocessor + * @param {Value} value + * @param {Encoding | null | undefined} [encoding] + * @param {boolean | null | undefined} [end=false] + * @returns {Array} + */ + +const search = /[\0\t\n\r]/g; + +/** + * @returns {Preprocessor} + */ +function preprocess() { + let column = 1; + let buffer = ''; + /** @type {boolean | undefined} */ + let start = true; + /** @type {boolean | undefined} */ + let atCarriageReturn; + return preprocessor + + /** @type {Preprocessor} */ + function preprocessor(value, encoding, end) { + /** @type {Array} */ + const chunks = []; + /** @type {RegExpMatchArray | null} */ + let match; + /** @type {number} */ + let next; + /** @type {number} */ + let startPosition; + /** @type {number} */ + let endPosition; + /** @type {Code} */ + let code; + + // @ts-expect-error `Buffer` does allow an encoding. + value = buffer + value.toString(encoding); + startPosition = 0; + buffer = ''; + if (start) { + // To do: `markdown-rs` actually parses BOMs (byte order mark). + if (value.charCodeAt(0) === 65279) { + startPosition++; + } + start = undefined; + } + while (startPosition < value.length) { + search.lastIndex = startPosition; + match = search.exec(value); + endPosition = + match && match.index !== undefined ? match.index : value.length; + code = value.charCodeAt(endPosition); + if (!match) { + buffer = value.slice(startPosition); + break + } + if (code === 10 && startPosition === endPosition && atCarriageReturn) { + chunks.push(-3); + atCarriageReturn = undefined; + } else { + if (atCarriageReturn) { + chunks.push(-5); + atCarriageReturn = undefined; + } + if (startPosition < endPosition) { + chunks.push(value.slice(startPosition, endPosition)); + column += endPosition - startPosition; + } + switch (code) { + case 0: { + chunks.push(65533); + column++; + break + } + case 9: { + next = Math.ceil(column / 4) * 4; + chunks.push(-2); + while (column++ < next) chunks.push(-1); + break + } + case 10: { + chunks.push(-4); + column = 1; + break + } + default: { + atCarriageReturn = true; + column = 1; + } + } + } + startPosition = endPosition + 1; + } + if (end) { + if (atCarriageReturn) chunks.push(-5); + if (buffer) chunks.push(buffer); + chunks.push(null); + } + return chunks + } +} + +/** + * @typedef {import('micromark-util-types').Event} Event + */ + + +/** + * @param {Array} events + * @returns {Array} + */ +function postprocess(events) { + while (!subtokenize(events)) { + // Empty + } + return events +} + +/** + * Turn the number (in string form as either hexa- or plain decimal) coming from + * a numeric character reference into a character. + * + * Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes + * non-characters and control characters safe. + * + * @param {string} value + * Value to decode. + * @param {number} base + * Numeric base. + * @returns {string} + * Character. + */ +function decodeNumericCharacterReference(value, base) { + const code = Number.parseInt(value, base); + if ( + // C0 except for HT, LF, FF, CR, space. + code < 9 || + code === 11 || + (code > 13 && code < 32) || + // Control character (DEL) of C0, and C1 controls. + (code > 126 && code < 160) || + // Lone high surrogates and low surrogates. + (code > 55295 && code < 57344) || + // Noncharacters. + (code > 64975 && code < 65008) /* eslint-disable no-bitwise */ || + (code & 65535) === 65535 || + (code & 65535) === 65534 /* eslint-enable no-bitwise */ || + // Out of range + code > 1114111 + ) { + return '\uFFFD' + } + return String.fromCharCode(code) +} + +const characterEscapeOrReference = + /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi; + +/** + * Decode markdown strings (which occur in places such as fenced code info + * strings, destinations, labels, and titles). + * + * The “string” content type allows character escapes and -references. + * This decodes those. + * + * @param {string} value + * Value to decode. + * @returns {string} + * Decoded value. + */ +function decodeString(value) { + return value.replace(characterEscapeOrReference, decode) +} + +/** + * @param {string} $0 + * @param {string} $1 + * @param {string} $2 + * @returns {string} + */ +function decode($0, $1, $2) { + if ($1) { + // Escape. + return $1 + } + + // Reference. + const head = $2.charCodeAt(0); + if (head === 35) { + const head = $2.charCodeAt(1); + const hex = head === 120 || head === 88; + return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10) + } + return decodeNamedCharacterReference($2) || $0 +} + +/** + * @typedef {import('unist').Node} Node + * @typedef {import('unist').Point} Point + * @typedef {import('unist').Position} Position + */ + +/** + * @typedef NodeLike + * @property {string} type + * @property {PositionLike | null | undefined} [position] + * + * @typedef PositionLike + * @property {PointLike | null | undefined} [start] + * @property {PointLike | null | undefined} [end] + * + * @typedef PointLike + * @property {number | null | undefined} [line] + * @property {number | null | undefined} [column] + * @property {number | null | undefined} [offset] + */ + +/** + * Serialize the positional info of a point, position (start and end points), + * or node. + * + * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value] + * Node, position, or point. + * @returns {string} + * Pretty printed positional info of a node (`string`). + * + * In the format of a range `ls:cs-le:ce` (when given `node` or `position`) + * or a point `l:c` (when given `point`), where `l` stands for line, `c` for + * column, `s` for `start`, and `e` for end. + * An empty string (`''`) is returned if the given value is neither `node`, + * `position`, nor `point`. + */ +function stringifyPosition(value) { + // Nothing. + if (!value || typeof value !== 'object') { + return '' + } + + // Node. + if ('position' in value || 'type' in value) { + return position$1(value.position) + } + + // Position. + if ('start' in value || 'end' in value) { + return position$1(value) + } + + // Point. + if ('line' in value || 'column' in value) { + return point$2(value) + } + + // ? + return '' +} + +/** + * @param {Point | PointLike | null | undefined} point + * @returns {string} + */ +function point$2(point) { + return index(point && point.line) + ':' + index(point && point.column) +} + +/** + * @param {Position | PositionLike | null | undefined} pos + * @returns {string} + */ +function position$1(pos) { + return point$2(pos && pos.start) + '-' + point$2(pos && pos.end) +} + +/** + * @param {number | null | undefined} value + * @returns {number} + */ +function index(value) { + return value && typeof value === 'number' ? value : 1 +} + +/** + * @typedef {import('micromark-util-types').Encoding} Encoding + * @typedef {import('micromark-util-types').Event} Event + * @typedef {import('micromark-util-types').ParseOptions} ParseOptions + * @typedef {import('micromark-util-types').Token} Token + * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext + * @typedef {import('micromark-util-types').Value} Value + * + * @typedef {import('unist').Parent} UnistParent + * @typedef {import('unist').Point} Point + * + * @typedef {import('mdast').PhrasingContent} PhrasingContent + * @typedef {import('mdast').StaticPhrasingContent} StaticPhrasingContent + * @typedef {import('mdast').Content} Content + * @typedef {import('mdast').Break} Break + * @typedef {import('mdast').Blockquote} Blockquote + * @typedef {import('mdast').Code} Code + * @typedef {import('mdast').Definition} Definition + * @typedef {import('mdast').Emphasis} Emphasis + * @typedef {import('mdast').Heading} Heading + * @typedef {import('mdast').HTML} HTML + * @typedef {import('mdast').Image} Image + * @typedef {import('mdast').ImageReference} ImageReference + * @typedef {import('mdast').InlineCode} InlineCode + * @typedef {import('mdast').Link} Link + * @typedef {import('mdast').LinkReference} LinkReference + * @typedef {import('mdast').List} List + * @typedef {import('mdast').ListItem} ListItem + * @typedef {import('mdast').Paragraph} Paragraph + * @typedef {import('mdast').Root} Root + * @typedef {import('mdast').Strong} Strong + * @typedef {import('mdast').Text} Text + * @typedef {import('mdast').ThematicBreak} ThematicBreak + * @typedef {import('mdast').ReferenceType} ReferenceType + * @typedef {import('../index.js').CompileData} CompileData + */ + +const own = {}.hasOwnProperty; + +/** + * @param value + * Markdown to parse. + * @param encoding + * Character encoding for when `value` is `Buffer`. + * @param options + * Configuration. + * @returns + * mdast tree. + */ +const fromMarkdown = + /** + * @type {( + * ((value: Value, encoding: Encoding, options?: Options | null | undefined) => Root) & + * ((value: Value, options?: Options | null | undefined) => Root) + * )} + */ + + /** + * @param {Value} value + * @param {Encoding | Options | null | undefined} [encoding] + * @param {Options | null | undefined} [options] + * @returns {Root} + */ + function (value, encoding, options) { + if (typeof encoding !== 'string') { + options = encoding; + encoding = undefined; + } + return compiler(options)( + postprocess( + parse$3(options).document().write(preprocess()(value, encoding, true)) + ) + ) + }; + +/** + * Note this compiler only understand complete buffering, not streaming. + * + * @param {Options | null | undefined} [options] + */ +function compiler(options) { + /** @type {Config} */ + const config = { + transforms: [], + canContainEols: ['emphasis', 'fragment', 'heading', 'paragraph', 'strong'], + enter: { + autolink: opener(link), + autolinkProtocol: onenterdata, + autolinkEmail: onenterdata, + atxHeading: opener(heading), + blockQuote: opener(blockQuote), + characterEscape: onenterdata, + characterReference: onenterdata, + codeFenced: opener(codeFlow), + codeFencedFenceInfo: buffer, + codeFencedFenceMeta: buffer, + codeIndented: opener(codeFlow, buffer), + codeText: opener(codeText, buffer), + codeTextData: onenterdata, + data: onenterdata, + codeFlowValue: onenterdata, + definition: opener(definition), + definitionDestinationString: buffer, + definitionLabelString: buffer, + definitionTitleString: buffer, + emphasis: opener(emphasis), + hardBreakEscape: opener(hardBreak), + hardBreakTrailing: opener(hardBreak), + htmlFlow: opener(html, buffer), + htmlFlowData: onenterdata, + htmlText: opener(html, buffer), + htmlTextData: onenterdata, + image: opener(image), + label: buffer, + link: opener(link), + listItem: opener(listItem), + listItemValue: onenterlistitemvalue, + listOrdered: opener(list, onenterlistordered), + listUnordered: opener(list), + paragraph: opener(paragraph), + reference: onenterreference, + referenceString: buffer, + resourceDestinationString: buffer, + resourceTitleString: buffer, + setextHeading: opener(heading), + strong: opener(strong), + thematicBreak: opener(thematicBreak) + }, + exit: { + atxHeading: closer(), + atxHeadingSequence: onexitatxheadingsequence, + autolink: closer(), + autolinkEmail: onexitautolinkemail, + autolinkProtocol: onexitautolinkprotocol, + blockQuote: closer(), + characterEscapeValue: onexitdata, + characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker, + characterReferenceMarkerNumeric: onexitcharacterreferencemarker, + characterReferenceValue: onexitcharacterreferencevalue, + codeFenced: closer(onexitcodefenced), + codeFencedFence: onexitcodefencedfence, + codeFencedFenceInfo: onexitcodefencedfenceinfo, + codeFencedFenceMeta: onexitcodefencedfencemeta, + codeFlowValue: onexitdata, + codeIndented: closer(onexitcodeindented), + codeText: closer(onexitcodetext), + codeTextData: onexitdata, + data: onexitdata, + definition: closer(), + definitionDestinationString: onexitdefinitiondestinationstring, + definitionLabelString: onexitdefinitionlabelstring, + definitionTitleString: onexitdefinitiontitlestring, + emphasis: closer(), + hardBreakEscape: closer(onexithardbreak), + hardBreakTrailing: closer(onexithardbreak), + htmlFlow: closer(onexithtmlflow), + htmlFlowData: onexitdata, + htmlText: closer(onexithtmltext), + htmlTextData: onexitdata, + image: closer(onexitimage), + label: onexitlabel, + labelText: onexitlabeltext, + lineEnding: onexitlineending, + link: closer(onexitlink), + listItem: closer(), + listOrdered: closer(), + listUnordered: closer(), + paragraph: closer(), + referenceString: onexitreferencestring, + resourceDestinationString: onexitresourcedestinationstring, + resourceTitleString: onexitresourcetitlestring, + resource: onexitresource, + setextHeading: closer(onexitsetextheading), + setextHeadingLineSequence: onexitsetextheadinglinesequence, + setextHeadingText: onexitsetextheadingtext, + strong: closer(), + thematicBreak: closer() + } + }; + configure(config, (options || {}).mdastExtensions || []); + + /** @type {CompileData} */ + const data = {}; + return compile + + /** + * Turn micromark events into an mdast tree. + * + * @param {Array} events + * Events. + * @returns {Root} + * mdast tree. + */ + function compile(events) { + /** @type {Root} */ + let tree = { + type: 'root', + children: [] + }; + /** @type {Omit} */ + const context = { + stack: [tree], + tokenStack: [], + config, + enter, + exit, + buffer, + resume, + setData, + getData + }; + /** @type {Array} */ + const listStack = []; + let index = -1; + while (++index < events.length) { + // We preprocess lists to add `listItem` tokens, and to infer whether + // items the list itself are spread out. + if ( + events[index][1].type === 'listOrdered' || + events[index][1].type === 'listUnordered' + ) { + if (events[index][0] === 'enter') { + listStack.push(index); + } else { + const tail = listStack.pop(); + index = prepareList(events, tail, index); + } + } + } + index = -1; + while (++index < events.length) { + const handler = config[events[index][0]]; + if (own.call(handler, events[index][1].type)) { + handler[events[index][1].type].call( + Object.assign( + { + sliceSerialize: events[index][2].sliceSerialize + }, + context + ), + events[index][1] + ); + } + } + + // Handle tokens still being open. + if (context.tokenStack.length > 0) { + const tail = context.tokenStack[context.tokenStack.length - 1]; + const handler = tail[1] || defaultOnError; + handler.call(context, undefined, tail[0]); + } + + // Figure out `root` position. + tree.position = { + start: point$1( + events.length > 0 + ? events[0][1].start + : { + line: 1, + column: 1, + offset: 0 + } + ), + end: point$1( + events.length > 0 + ? events[events.length - 2][1].end + : { + line: 1, + column: 1, + offset: 0 + } + ) + }; + + // Call transforms. + index = -1; + while (++index < config.transforms.length) { + tree = config.transforms[index](tree) || tree; + } + return tree + } + + /** + * @param {Array} events + * @param {number} start + * @param {number} length + * @returns {number} + */ + function prepareList(events, start, length) { + let index = start - 1; + let containerBalance = -1; + let listSpread = false; + /** @type {Token | undefined} */ + let listItem; + /** @type {number | undefined} */ + let lineIndex; + /** @type {number | undefined} */ + let firstBlankLineIndex; + /** @type {boolean | undefined} */ + let atMarker; + while (++index <= length) { + const event = events[index]; + if ( + event[1].type === 'listUnordered' || + event[1].type === 'listOrdered' || + event[1].type === 'blockQuote' + ) { + if (event[0] === 'enter') { + containerBalance++; + } else { + containerBalance--; + } + atMarker = undefined; + } else if (event[1].type === 'lineEndingBlank') { + if (event[0] === 'enter') { + if ( + listItem && + !atMarker && + !containerBalance && + !firstBlankLineIndex + ) { + firstBlankLineIndex = index; + } + atMarker = undefined; + } + } else if ( + event[1].type === 'linePrefix' || + event[1].type === 'listItemValue' || + event[1].type === 'listItemMarker' || + event[1].type === 'listItemPrefix' || + event[1].type === 'listItemPrefixWhitespace' + ) ; else { + atMarker = undefined; + } + if ( + (!containerBalance && + event[0] === 'enter' && + event[1].type === 'listItemPrefix') || + (containerBalance === -1 && + event[0] === 'exit' && + (event[1].type === 'listUnordered' || + event[1].type === 'listOrdered')) + ) { + if (listItem) { + let tailIndex = index; + lineIndex = undefined; + while (tailIndex--) { + const tailEvent = events[tailIndex]; + if ( + tailEvent[1].type === 'lineEnding' || + tailEvent[1].type === 'lineEndingBlank' + ) { + if (tailEvent[0] === 'exit') continue + if (lineIndex) { + events[lineIndex][1].type = 'lineEndingBlank'; + listSpread = true; + } + tailEvent[1].type = 'lineEnding'; + lineIndex = tailIndex; + } else if ( + tailEvent[1].type === 'linePrefix' || + tailEvent[1].type === 'blockQuotePrefix' || + tailEvent[1].type === 'blockQuotePrefixWhitespace' || + tailEvent[1].type === 'blockQuoteMarker' || + tailEvent[1].type === 'listItemIndent' + ) ; else { + break + } + } + if ( + firstBlankLineIndex && + (!lineIndex || firstBlankLineIndex < lineIndex) + ) { + listItem._spread = true; + } + + // Fix position. + listItem.end = Object.assign( + {}, + lineIndex ? events[lineIndex][1].start : event[1].end + ); + events.splice(lineIndex || index, 0, ['exit', listItem, event[2]]); + index++; + length++; + } + + // Create a new list item. + if (event[1].type === 'listItemPrefix') { + listItem = { + type: 'listItem', + _spread: false, + start: Object.assign({}, event[1].start), + // @ts-expect-error: we’ll add `end` in a second. + end: undefined + }; + // @ts-expect-error: `listItem` is most definitely defined, TS... + events.splice(index, 0, ['enter', listItem, event[2]]); + index++; + length++; + firstBlankLineIndex = undefined; + atMarker = true; + } + } + } + events[start][1]._spread = listSpread; + return length + } + + /** + * Set data. + * + * @template {keyof CompileData} Key + * Field type. + * @param {Key} key + * Key of field. + * @param {CompileData[Key]} [value] + * New value. + * @returns {void} + * Nothing. + */ + function setData(key, value) { + data[key] = value; + } + + /** + * Get data. + * + * @template {keyof CompileData} Key + * Field type. + * @param {Key} key + * Key of field. + * @returns {CompileData[Key]} + * Value. + */ + function getData(key) { + return data[key] + } + + /** + * Create an opener handle. + * + * @param {(token: Token) => Node} create + * Create a node. + * @param {Handle} [and] + * Optional function to also run. + * @returns {Handle} + * Handle. + */ + function opener(create, and) { + return open + + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + function open(token) { + enter.call(this, create(token), token); + if (and) and.call(this, token); + } + } + + /** + * @this {CompileContext} + * @returns {void} + */ + function buffer() { + this.stack.push({ + type: 'fragment', + children: [] + }); + } + + /** + * @template {Node} Kind + * Node type. + * @this {CompileContext} + * Context. + * @param {Kind} node + * Node to enter. + * @param {Token} token + * Corresponding token. + * @param {OnEnterError | undefined} [errorHandler] + * Handle the case where this token is open, but it is closed by something else. + * @returns {Kind} + * The given node. + */ + function enter(node, token, errorHandler) { + const parent = this.stack[this.stack.length - 1]; + // @ts-expect-error: Assume `Node` can exist as a child of `parent`. + parent.children.push(node); + this.stack.push(node); + this.tokenStack.push([token, errorHandler]); + // @ts-expect-error: `end` will be patched later. + node.position = { + start: point$1(token.start) + }; + return node + } + + /** + * Create a closer handle. + * + * @param {Handle} [and] + * Optional function to also run. + * @returns {Handle} + * Handle. + */ + function closer(and) { + return close + + /** + * @this {CompileContext} + * @param {Token} token + * @returns {void} + */ + function close(token) { + if (and) and.call(this, token); + exit.call(this, token); + } + } + + /** + * @this {CompileContext} + * Context. + * @param {Token} token + * Corresponding token. + * @param {OnExitError | undefined} [onExitError] + * Handle the case where another token is open. + * @returns {Node} + * The closed node. + */ + function exit(token, onExitError) { + const node = this.stack.pop(); + const open = this.tokenStack.pop(); + if (!open) { + throw new Error( + 'Cannot close `' + + token.type + + '` (' + + stringifyPosition({ + start: token.start, + end: token.end + }) + + '): it’s not open' + ) + } else if (open[0].type !== token.type) { + if (onExitError) { + onExitError.call(this, token, open[0]); + } else { + const handler = open[1] || defaultOnError; + handler.call(this, token, open[0]); + } + } + node.position.end = point$1(token.end); + return node + } + + /** + * @this {CompileContext} + * @returns {string} + */ + function resume() { + return toString$2(this.stack.pop()) + } + + // + // Handlers. + // + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onenterlistordered() { + setData('expectingFirstListItemValue', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onenterlistitemvalue(token) { + if (getData('expectingFirstListItemValue')) { + const ancestor = this.stack[this.stack.length - 2]; + ancestor.start = Number.parseInt(this.sliceSerialize(token), 10); + setData('expectingFirstListItemValue'); + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfenceinfo() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.lang = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfencemeta() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.meta = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefencedfence() { + // Exit if this is the closing fence. + if (getData('flowCodeInside')) return + this.buffer(); + setData('flowCodeInside', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodefenced() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ''); + setData('flowCodeInside'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcodeindented() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data.replace(/(\r?\n|\r)$/g, ''); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitionlabelstring(token) { + const label = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.label = label; + node.identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitiontitlestring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.title = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitdefinitiondestinationstring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.url = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitatxheadingsequence(token) { + const node = this.stack[this.stack.length - 1]; + if (!node.depth) { + const depth = this.sliceSerialize(token).length; + node.depth = depth; + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheadingtext() { + setData('setextHeadingSlurpLineEnding', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheadinglinesequence(token) { + const node = this.stack[this.stack.length - 1]; + node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitsetextheading() { + setData('setextHeadingSlurpLineEnding'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onenterdata(token) { + const node = this.stack[this.stack.length - 1]; + let tail = node.children[node.children.length - 1]; + if (!tail || tail.type !== 'text') { + // Add a new text node. + tail = text(); + // @ts-expect-error: we’ll add `end` later. + tail.position = { + start: point$1(token.start) + }; + // @ts-expect-error: Assume `parent` accepts `text`. + node.children.push(tail); + } + this.stack.push(tail); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitdata(token) { + const tail = this.stack.pop(); + tail.value += this.sliceSerialize(token); + tail.position.end = point$1(token.end); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlineending(token) { + const context = this.stack[this.stack.length - 1]; + // If we’re at a hard break, include the line ending in there. + if (getData('atHardBreak')) { + const tail = context.children[context.children.length - 1]; + tail.position.end = point$1(token.end); + setData('atHardBreak'); + return + } + if ( + !getData('setextHeadingSlurpLineEnding') && + config.canContainEols.includes(context.type) + ) { + onenterdata.call(this, token); + onexitdata.call(this, token); + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithardbreak() { + setData('atHardBreak', true); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithtmlflow() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexithtmltext() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitcodetext() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.value = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlink() { + const node = this.stack[this.stack.length - 1]; + // Note: there are also `identifier` and `label` fields on this link node! + // These are used / cleaned here. + // To do: clean. + if (getData('inReference')) { + /** @type {ReferenceType} */ + const referenceType = getData('referenceType') || 'shortcut'; + node.type += 'Reference'; + // @ts-expect-error: mutate. + node.referenceType = referenceType; + // @ts-expect-error: mutate. + delete node.url; + delete node.title; + } else { + // @ts-expect-error: mutate. + delete node.identifier; + // @ts-expect-error: mutate. + delete node.label; + } + setData('referenceType'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitimage() { + const node = this.stack[this.stack.length - 1]; + // Note: there are also `identifier` and `label` fields on this link node! + // These are used / cleaned here. + // To do: clean. + if (getData('inReference')) { + /** @type {ReferenceType} */ + const referenceType = getData('referenceType') || 'shortcut'; + node.type += 'Reference'; + // @ts-expect-error: mutate. + node.referenceType = referenceType; + // @ts-expect-error: mutate. + delete node.url; + delete node.title; + } else { + // @ts-expect-error: mutate. + delete node.identifier; + // @ts-expect-error: mutate. + delete node.label; + } + setData('referenceType'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlabeltext(token) { + const string = this.sliceSerialize(token); + const ancestor = this.stack[this.stack.length - 2]; + // @ts-expect-error: stash this on the node, as it might become a reference + // later. + ancestor.label = decodeString(string); + // @ts-expect-error: same as above. + ancestor.identifier = normalizeIdentifier(string).toLowerCase(); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitlabel() { + const fragment = this.stack[this.stack.length - 1]; + const value = this.resume(); + const node = this.stack[this.stack.length - 1]; + // Assume a reference. + setData('inReference', true); + if (node.type === 'link') { + /** @type {Array} */ + // @ts-expect-error: Assume static phrasing content. + const children = fragment.children; + node.children = children; + } else { + node.alt = value; + } + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresourcedestinationstring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.url = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresourcetitlestring() { + const data = this.resume(); + const node = this.stack[this.stack.length - 1]; + node.title = data; + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitresource() { + setData('inReference'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onenterreference() { + setData('referenceType', 'collapsed'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitreferencestring(token) { + const label = this.resume(); + const node = this.stack[this.stack.length - 1]; + // @ts-expect-error: stash this on the node, as it might become a reference + // later. + node.label = label; + // @ts-expect-error: same as above. + node.identifier = normalizeIdentifier( + this.sliceSerialize(token) + ).toLowerCase(); + setData('referenceType', 'full'); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + + function onexitcharacterreferencemarker(token) { + setData('characterReferenceType', token.type); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitcharacterreferencevalue(token) { + const data = this.sliceSerialize(token); + const type = getData('characterReferenceType'); + /** @type {string} */ + let value; + if (type) { + value = decodeNumericCharacterReference( + data, + type === 'characterReferenceMarkerNumeric' ? 10 : 16 + ); + setData('characterReferenceType'); + } else { + const result = decodeNamedCharacterReference(data); + value = result; + } + const tail = this.stack.pop(); + tail.value += value; + tail.position.end = point$1(token.end); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitautolinkprotocol(token) { + onexitdata.call(this, token); + const node = this.stack[this.stack.length - 1]; + node.url = this.sliceSerialize(token); + } + + /** + * @this {CompileContext} + * @type {Handle} + */ + function onexitautolinkemail(token) { + onexitdata.call(this, token); + const node = this.stack[this.stack.length - 1]; + node.url = 'mailto:' + this.sliceSerialize(token); + } + + // + // Creaters. + // + + /** @returns {Blockquote} */ + function blockQuote() { + return { + type: 'blockquote', + children: [] + } + } + + /** @returns {Code} */ + function codeFlow() { + return { + type: 'code', + lang: null, + meta: null, + value: '' + } + } + + /** @returns {InlineCode} */ + function codeText() { + return { + type: 'inlineCode', + value: '' + } + } + + /** @returns {Definition} */ + function definition() { + return { + type: 'definition', + identifier: '', + label: null, + title: null, + url: '' + } + } + + /** @returns {Emphasis} */ + function emphasis() { + return { + type: 'emphasis', + children: [] + } + } + + /** @returns {Heading} */ + function heading() { + // @ts-expect-error `depth` will be set later. + return { + type: 'heading', + depth: undefined, + children: [] + } + } + + /** @returns {Break} */ + function hardBreak() { + return { + type: 'break' + } + } + + /** @returns {HTML} */ + function html() { + return { + type: 'html', + value: '' + } + } + + /** @returns {Image} */ + function image() { + return { + type: 'image', + title: null, + url: '', + alt: null + } + } + + /** @returns {Link} */ + function link() { + return { + type: 'link', + title: null, + url: '', + children: [] + } + } + + /** + * @param {Token} token + * @returns {List} + */ + function list(token) { + return { + type: 'list', + ordered: token.type === 'listOrdered', + start: null, + spread: token._spread, + children: [] + } + } + + /** + * @param {Token} token + * @returns {ListItem} + */ + function listItem(token) { + return { + type: 'listItem', + spread: token._spread, + checked: null, + children: [] + } + } + + /** @returns {Paragraph} */ + function paragraph() { + return { + type: 'paragraph', + children: [] + } + } + + /** @returns {Strong} */ + function strong() { + return { + type: 'strong', + children: [] + } + } + + /** @returns {Text} */ + function text() { + return { + type: 'text', + value: '' + } + } + + /** @returns {ThematicBreak} */ + function thematicBreak() { + return { + type: 'thematicBreak' + } + } +} + +/** + * Copy a point-like value. + * + * @param {Point} d + * Point-like value. + * @returns {Point} + * unist point. + */ +function point$1(d) { + return { + line: d.line, + column: d.column, + offset: d.offset + } +} + +/** + * @param {Config} combined + * @param {Array>} extensions + * @returns {void} + */ +function configure(combined, extensions) { + let index = -1; + while (++index < extensions.length) { + const value = extensions[index]; + if (Array.isArray(value)) { + configure(combined, value); + } else { + extension$2(combined, value); + } + } +} + +/** + * @param {Config} combined + * @param {Extension} extension + * @returns {void} + */ +function extension$2(combined, extension) { + /** @type {keyof Extension} */ + let key; + for (key in extension) { + if (own.call(extension, key)) { + if (key === 'canContainEols') { + const right = extension[key]; + if (right) { + combined[key].push(...right); + } + } else if (key === 'transforms') { + const right = extension[key]; + if (right) { + combined[key].push(...right); + } + } else if (key === 'enter' || key === 'exit') { + const right = extension[key]; + if (right) { + Object.assign(combined[key], right); + } + } + } + } +} + +/** @type {OnEnterError} */ +function defaultOnError(left, right) { + if (left) { + throw new Error( + 'Cannot close `' + + left.type + + '` (' + + stringifyPosition({ + start: left.start, + end: left.end + }) + + '): a different token (`' + + right.type + + '`, ' + + stringifyPosition({ + start: right.start, + end: right.end + }) + + ') is open' + ) + } else { + throw new Error( + 'Cannot close document, a token (`' + + right.type + + '`, ' + + stringifyPosition({ + start: right.start, + end: right.end + }) + + ') is still open' + ) + } +} + +function preprocessMarkdown(markdown) { + const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, "\n"); + const withoutExtraSpaces = dedent(withoutMultipleNewlines); + return withoutExtraSpaces; +} +function markdownToLines(markdown) { + const preprocessedMarkdown = preprocessMarkdown(markdown); + const { children } = fromMarkdown(preprocessedMarkdown); + const lines = [[]]; + let currentLine = 0; + function processNode(node, parentType = "normal") { + if (node.type === "text") { + const textLines = node.value.split("\n"); + textLines.forEach((textLine, index) => { + if (index !== 0) { + currentLine++; + lines.push([]); + } + textLine.split(" ").forEach((word) => { + if (word) { + lines[currentLine].push({ content: word, type: parentType }); + } + }); + }); + } else if (node.type === "strong" || node.type === "emphasis") { + node.children.forEach((contentNode) => { + processNode(contentNode, node.type); + }); + } + } + children.forEach((treeNode) => { + if (treeNode.type === "paragraph") { + treeNode.children.forEach((contentNode) => { + processNode(contentNode); + }); + } + }); + return lines; +} +function markdownToHTML(markdown) { + const { children } = fromMarkdown(markdown); + function output(node) { + if (node.type === "text") { + return node.value.replace(/\n/g, "
    "); + } else if (node.type === "strong") { + return `${node.children.map(output).join("")}`; + } else if (node.type === "emphasis") { + return `${node.children.map(output).join("")}`; + } else if (node.type === "paragraph") { + return `

    ${node.children.map(output).join("")}

    `; + } + return `Unsupported markdown: ${node.type}`; + } + return children.map(output).join(""); +} +function splitTextToChars(text) { + if (Intl.Segmenter) { + return [...new Intl.Segmenter().segment(text)].map((s) => s.segment); + } + return [...text]; +} +function splitWordToFitWidth(checkFit, word) { + const characters = splitTextToChars(word.content); + return splitWordToFitWidthRecursion(checkFit, [], characters, word.type); +} +function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) { + if (remainingChars.length === 0) { + return [ + { content: usedChars.join(""), type }, + { content: "", type } + ]; + } + const [nextChar, ...rest] = remainingChars; + const newWord = [...usedChars, nextChar]; + if (checkFit([{ content: newWord.join(""), type }])) { + return splitWordToFitWidthRecursion(checkFit, newWord, rest, type); + } + if (usedChars.length === 0 && nextChar) { + usedChars.push(nextChar); + remainingChars.shift(); + } + return [ + { content: usedChars.join(""), type }, + { content: remainingChars.join(""), type } + ]; +} +function splitLineToFitWidth(line, checkFit) { + if (line.some(({ content }) => content.includes("\n"))) { + throw new Error("splitLineToFitWidth does not support newlines in the line"); + } + return splitLineToFitWidthRecursion(line, checkFit); +} +function splitLineToFitWidthRecursion(words, checkFit, lines = [], newLine = []) { + if (words.length === 0) { + if (newLine.length > 0) { + lines.push(newLine); + } + return lines.length > 0 ? lines : []; + } + let joiner = ""; + if (words[0].content === " ") { + joiner = " "; + words.shift(); + } + const nextWord = words.shift() ?? { content: " ", type: "normal" }; + const lineWithNextWord = [...newLine]; + if (joiner !== "") { + lineWithNextWord.push({ content: joiner, type: "normal" }); + } + lineWithNextWord.push(nextWord); + if (checkFit(lineWithNextWord)) { + return splitLineToFitWidthRecursion(words, checkFit, lines, lineWithNextWord); + } + if (newLine.length > 0) { + lines.push(newLine); + words.unshift(nextWord); + } else if (nextWord.content) { + const [line, rest] = splitWordToFitWidth(checkFit, nextWord); + lines.push([line]); + if (rest.content) { + words.unshift(rest); + } + } + return splitLineToFitWidthRecursion(words, checkFit, lines); +} +function applyStyle$1(dom, styleFn) { + if (styleFn) { + dom.attr("style", styleFn); + } +} +function addHtmlSpan(element, node, width, classes, addBackground = false) { + const fo = element.append("foreignObject"); + const div = fo.append("xhtml:div"); + const label = node.label; + const labelClass = node.isNode ? "nodeLabel" : "edgeLabel"; + div.html( + ` + " + label + "" + ); + applyStyle$1(div, node.labelStyle); + div.style("display", "table-cell"); + div.style("white-space", "nowrap"); + div.style("max-width", width + "px"); + div.attr("xmlns", "http://www.w3.org/1999/xhtml"); + if (addBackground) { + div.attr("class", "labelBkg"); + } + let bbox = div.node().getBoundingClientRect(); + if (bbox.width === width) { + div.style("display", "table"); + div.style("white-space", "break-spaces"); + div.style("width", width + "px"); + bbox = div.node().getBoundingClientRect(); + } + fo.style("width", bbox.width); + fo.style("height", bbox.height); + return fo.node(); +} +function createTspan(textElement, lineIndex, lineHeight) { + return textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em"); +} +function computeWidthOfText(parentNode, lineHeight, line) { + const testElement = parentNode.append("text"); + const testSpan = createTspan(testElement, 1, lineHeight); + updateTextContentAndStyles(testSpan, line); + const textLength = testSpan.node().getComputedTextLength(); + testElement.remove(); + return textLength; +} +function computeDimensionOfText(parentNode, lineHeight, text) { + var _a; + const testElement = parentNode.append("text"); + const testSpan = createTspan(testElement, 1, lineHeight); + updateTextContentAndStyles(testSpan, [{ content: text, type: "normal" }]); + const textDimension = (_a = testSpan.node()) == null ? void 0 : _a.getBoundingClientRect(); + if (textDimension) { + testElement.remove(); + } + return textDimension; +} +function createFormattedText(width, g, structuredText, addBackground = false) { + const lineHeight = 1.1; + const labelGroup = g.append("g"); + const bkg = labelGroup.insert("rect").attr("class", "background"); + const textElement = labelGroup.append("text").attr("y", "-10.1"); + let lineIndex = 0; + for (const line of structuredText) { + const checkWidth = (line2) => computeWidthOfText(labelGroup, lineHeight, line2) <= width; + const linesUnderWidth = checkWidth(line) ? [line] : splitLineToFitWidth(line, checkWidth); + for (const preparedLine of linesUnderWidth) { + const tspan = createTspan(textElement, lineIndex, lineHeight); + updateTextContentAndStyles(tspan, preparedLine); + lineIndex++; + } + } + if (addBackground) { + const bbox = textElement.node().getBBox(); + const padding = 2; + bkg.attr("x", -padding).attr("y", -padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding); + return labelGroup.node(); + } else { + return textElement.node(); + } +} +function updateTextContentAndStyles(tspan, wrappedLine) { + tspan.text(""); + wrappedLine.forEach((word, index) => { + const innerTspan = tspan.append("tspan").attr("font-style", word.type === "emphasis" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", word.type === "strong" ? "bold" : "normal"); + if (index === 0) { + innerTspan.text(word.content); + } else { + innerTspan.text(" " + word.content); + } + }); +} +const createText = (el, text = "", { + style = "", + isTitle = false, + classes = "", + useHtmlLabels = true, + isNode = true, + width = 200, + addSvgBackground = false +} = {}) => { + log$1.info("createText", text, style, isTitle, classes, useHtmlLabels, isNode, addSvgBackground); + if (useHtmlLabels) { + const htmlText = markdownToHTML(text); + const node = { + isNode, + label: decodeEntities(htmlText).replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell: disable-line + (s) => `` + ), + labelStyle: style.replace("fill:", "color:") + }; + const vertexNode = addHtmlSpan(el, node, width, classes, addSvgBackground); + return vertexNode; + } else { + const structuredText = markdownToLines(text); + const svgLabel = createFormattedText(width, el, structuredText, addSvgBackground); + return svgLabel; + } +}; + +const insertMarkers$3 = (elem, markerArray, type, id) => { + markerArray.forEach((markerName) => { + markers$1[markerName](elem, type, id); + }); +}; +const extension$1 = (elem, type, id) => { + log$1.trace("Making markers for ", id); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-extensionStart").attr("class", "marker extension " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-extensionEnd").attr("class", "marker extension " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"); +}; +const composition = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-compositionStart").attr("class", "marker composition " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-compositionEnd").attr("class", "marker composition " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); +}; +const aggregation = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-aggregationStart").attr("class", "marker aggregation " + type).attr("refX", 18).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-aggregationEnd").attr("class", "marker aggregation " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); +}; +const dependency = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-dependencyStart").attr("class", "marker dependency " + type).attr("refX", 6).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-dependencyEnd").attr("class", "marker dependency " + type).attr("refX", 13).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const lollipop = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-lollipopStart").attr("class", "marker lollipop " + type).attr("refX", 13).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("circle").attr("stroke", "black").attr("fill", "transparent").attr("cx", 7).attr("cy", 7).attr("r", 6); + elem.append("defs").append("marker").attr("id", id + "_" + type + "-lollipopEnd").attr("class", "marker lollipop " + type).attr("refX", 1).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("circle").attr("stroke", "black").attr("fill", "transparent").attr("cx", 7).attr("cy", 7).attr("r", 6); +}; +const point = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-pointEnd").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 6).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-pointStart").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 4.5).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 5 L 10 10 L 10 0 z").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); +}; +const circle$1 = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-circleEnd").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", 11).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("circle").attr("cx", "5").attr("cy", "5").attr("r", "5").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-circleStart").attr("class", "marker " + type).attr("viewBox", "0 0 10 10").attr("refX", -1).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("circle").attr("cx", "5").attr("cy", "5").attr("r", "5").attr("class", "arrowMarkerPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); +}; +const cross = (elem, type, id) => { + elem.append("marker").attr("id", id + "_" + type + "-crossEnd").attr("class", "marker cross " + type).attr("viewBox", "0 0 11 11").attr("refX", 12).attr("refY", 5.2).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("path").attr("d", "M 1,1 l 9,9 M 10,1 l -9,9").attr("class", "arrowMarkerPath").style("stroke-width", 2).style("stroke-dasharray", "1,0"); + elem.append("marker").attr("id", id + "_" + type + "-crossStart").attr("class", "marker cross " + type).attr("viewBox", "0 0 11 11").attr("refX", -1).attr("refY", 5.2).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 11).attr("markerHeight", 11).attr("orient", "auto").append("path").attr("d", "M 1,1 l 9,9 M 10,1 l -9,9").attr("class", "arrowMarkerPath").style("stroke-width", 2).style("stroke-dasharray", "1,0"); +}; +const barb = (elem, type, id) => { + elem.append("defs").append("marker").attr("id", id + "_" + type + "-barbEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 14).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z"); +}; +const markers$1 = { + extension: extension$1, + composition, + aggregation, + dependency, + lollipop, + point, + circle: circle$1, + cross, + barb +}; +const insertMarkers$1$1 = insertMarkers$3; +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr("style", styleFn); + } +} +function addHtmlLabel(node) { + const fo = select(document.createElementNS("http://www.w3.org/2000/svg", "foreignObject")); + const div = fo.append("xhtml:div"); + const label = node.label; + const labelClass = node.isNode ? "nodeLabel" : "edgeLabel"; + div.html( + '" + label + "" + ); + applyStyle(div, node.labelStyle); + div.style("display", "inline-block"); + div.style("white-space", "nowrap"); + div.attr("xmlns", "http://www.w3.org/1999/xhtml"); + return fo.node(); +} +const createLabel = (_vertexText, style, isTitle, isNode) => { + let vertexText = _vertexText || ""; + if (typeof vertexText === "object") { + vertexText = vertexText[0]; + } + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + vertexText = vertexText.replace(/\\n|\n/g, "
    "); + log$1.debug("vertexText" + vertexText); + const node = { + isNode, + label: decodeEntities(vertexText).replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell: disable-line + (s) => `` + ), + labelStyle: style.replace("fill:", "color:") + }; + let vertexNode = addHtmlLabel(node); + return vertexNode; + } else { + const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", style.replace("color:", "fill:")); + let rows = []; + if (typeof vertexText === "string") { + rows = vertexText.split(/\\n|\n|/gi); + } else if (Array.isArray(vertexText)) { + rows = vertexText; + } else { + rows = []; + } + for (const row of rows) { + const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "0"); + if (isTitle) { + tspan.setAttribute("class", "title-row"); + } else { + tspan.setAttribute("class", "row"); + } + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + } + return svgLabel; + } +}; +const createLabel$1 = createLabel; +const labelHelper = async (parent, node, _classes, isNode) => { + let classes; + const useHtmlLabels = node.useHtmlLabels || evaluate(getConfig$2().flowchart.htmlLabels); + if (!_classes) { + classes = "node default"; + } else { + classes = _classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const label = shapeSvg.insert("g").attr("class", "label").attr("style", node.labelStyle); + let labelText; + if (node.labelText === void 0) { + labelText = ""; + } else { + labelText = typeof node.labelText === "string" ? node.labelText : node.labelText[0]; + } + const textNode = label.node(); + let text; + if (node.labelType === "markdown") { + text = createText(label, sanitizeText$2$1(decodeEntities(labelText), getConfig$2()), { + useHtmlLabels, + width: node.width || getConfig$2().flowchart.wrappingWidth, + classes: "markdown-node-label" + }); + } else { + text = textNode.appendChild( + createLabel$1( + sanitizeText$2$1(decodeEntities(labelText), getConfig$2()), + node.labelStyle, + false, + isNode + ) + ); + } + let bbox = text.getBBox(); + const halfPadding = node.padding / 2; + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + const images = div.getElementsByTagName("img"); + if (images) { + const noImgText = labelText.replace(/]*>/g, "").trim() === ""; + await Promise.all( + [...images].map( + (img) => new Promise((res) => { + function setupImage() { + img.style.display = "flex"; + img.style.flexDirection = "column"; + if (noImgText) { + const bodyFontSize = getConfig$2().fontSize ? getConfig$2().fontSize : window.getComputedStyle(document.body).fontSize; + const enlargingFactor = 5; + const width = parseInt(bodyFontSize, 10) * enlargingFactor + "px"; + img.style.minWidth = width; + img.style.maxWidth = width; + } else { + img.style.width = "100%"; + } + res(img); + } + setTimeout(() => { + if (img.complete) { + setupImage(); + } + }); + img.addEventListener("error", setupImage); + img.addEventListener("load", setupImage); + }) + ) + ); + } + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (useHtmlLabels) { + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + } else { + label.attr("transform", "translate(0, " + -bbox.height / 2 + ")"); + } + if (node.centerLabel) { + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + } + label.insert("rect", ":first-child"); + return { shapeSvg, bbox, halfPadding, label }; +}; +const updateNodeBounds = (node, element) => { + const bbox = element.node().getBBox(); + node.width = bbox.width; + node.height = bbox.height; +}; +function insertPolygonShape$2(parent, w, h, points) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("class", "label-container").attr("transform", "translate(" + -w / 2 + "," + h / 2 + ")"); +} +function intersectNode(node, point2) { + return node.intersect(point2); +} +function intersectEllipse(node, rx, ry, point2) { + var cx = node.x; + var cy = node.y; + var px = cx - point2.x; + var py = cy - point2.y; + var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px); + var dx = Math.abs(rx * ry * px / det); + if (point2.x < cx) { + dx = -dx; + } + var dy = Math.abs(rx * ry * py / det); + if (point2.y < cy) { + dy = -dy; + } + return { x: cx + dx, y: cy + dy }; +} +function intersectCircle(node, rx, point2) { + return intersectEllipse(node, rx, rx, point2); +} +function intersectLine(p1, p2, q1, q2) { + var a1, a2, b1, b2, c1, c2; + var r1, r2, r3, r4; + var denom, offset, num; + var x, y; + a1 = p2.y - p1.y; + b1 = p1.x - p2.x; + c1 = p2.x * p1.y - p1.x * p2.y; + r3 = a1 * q1.x + b1 * q1.y + c1; + r4 = a1 * q2.x + b1 * q2.y + c1; + if (r3 !== 0 && r4 !== 0 && sameSign(r3, r4)) { + return; + } + a2 = q2.y - q1.y; + b2 = q1.x - q2.x; + c2 = q2.x * q1.y - q1.x * q2.y; + r1 = a2 * p1.x + b2 * p1.y + c2; + r2 = a2 * p2.x + b2 * p2.y + c2; + if (r1 !== 0 && r2 !== 0 && sameSign(r1, r2)) { + return; + } + denom = a1 * b2 - a2 * b1; + if (denom === 0) { + return; + } + offset = Math.abs(denom / 2); + num = b1 * c2 - b2 * c1; + x = num < 0 ? (num - offset) / denom : (num + offset) / denom; + num = a2 * c1 - a1 * c2; + y = num < 0 ? (num - offset) / denom : (num + offset) / denom; + return { x, y }; +} +function sameSign(r1, r2) { + return r1 * r2 > 0; +} +function intersectPolygon(node, polyPoints, point2) { + var x1 = node.x; + var y1 = node.y; + var intersections = []; + var minX = Number.POSITIVE_INFINITY; + var minY = Number.POSITIVE_INFINITY; + if (typeof polyPoints.forEach === "function") { + polyPoints.forEach(function(entry) { + minX = Math.min(minX, entry.x); + minY = Math.min(minY, entry.y); + }); + } else { + minX = Math.min(minX, polyPoints.x); + minY = Math.min(minY, polyPoints.y); + } + var left = x1 - node.width / 2 - minX; + var top = y1 - node.height / 2 - minY; + for (var i = 0; i < polyPoints.length; i++) { + var p1 = polyPoints[i]; + var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0]; + var intersect2 = intersectLine( + node, + point2, + { x: left + p1.x, y: top + p1.y }, + { x: left + p2.x, y: top + p2.y } + ); + if (intersect2) { + intersections.push(intersect2); + } + } + if (!intersections.length) { + return node; + } + if (intersections.length > 1) { + intersections.sort(function(p, q) { + var pdx = p.x - point2.x; + var pdy = p.y - point2.y; + var distp = Math.sqrt(pdx * pdx + pdy * pdy); + var qdx = q.x - point2.x; + var qdy = q.y - point2.y; + var distq = Math.sqrt(qdx * qdx + qdy * qdy); + return distp < distq ? -1 : distp === distq ? 0 : 1; + }); + } + return intersections[0]; +} +const intersectRect = (node, point2) => { + var x = node.x; + var y = node.y; + var dx = point2.x - x; + var dy = point2.y - y; + var w = node.width / 2; + var h = node.height / 2; + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + if (dy < 0) { + h = -h; + } + sx = dy === 0 ? 0 : h * dx / dy; + sy = h; + } else { + if (dx < 0) { + w = -w; + } + sx = w; + sy = dx === 0 ? 0 : w * dy / dx; + } + return { x: x + sx, y: y + sy }; +}; +const intersectRect$1 = intersectRect; +const intersect = { + node: intersectNode, + circle: intersectCircle, + ellipse: intersectEllipse, + polygon: intersectPolygon, + rect: intersectRect$1 +}; +const note = async (parent, node) => { + const useHtmlLabels = node.useHtmlLabels || getConfig$2().flowchart.htmlLabels; + if (!useHtmlLabels) { + node.centerLabel = true; + } + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes, + true + ); + log$1.info("Classes = ", node.classes); + const rect2 = shapeSvg.insert("rect", ":first-child"); + rect2.attr("rx", node.rx).attr("ry", node.ry).attr("x", -bbox.width / 2 - halfPadding).attr("y", -bbox.height / 2 - halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const note$1 = note; +const expandAndDeduplicateDirections = (directions) => { + const uniqueDirections = /* @__PURE__ */ new Set(); + for (const direction of directions) { + switch (direction) { + case "x": + uniqueDirections.add("right"); + uniqueDirections.add("left"); + break; + case "y": + uniqueDirections.add("up"); + uniqueDirections.add("down"); + break; + default: + uniqueDirections.add(direction); + break; + } + } + return uniqueDirections; +}; +const getArrowPoints = (duplicatedDirections, bbox, node) => { + const directions = expandAndDeduplicateDirections(duplicatedDirections); + const f = 2; + const height = bbox.height + 2 * node.padding; + const midpoint = height / f; + const width = bbox.width + 2 * midpoint + node.padding; + const padding = node.padding / 2; + if (directions.has("right") && directions.has("left") && directions.has("up") && directions.has("down")) { + return [ + // Bottom + { x: 0, y: 0 }, + { x: midpoint, y: 0 }, + { x: width / 2, y: 2 * padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: 0 }, + // Right + { x: width, y: -height / 3 }, + { x: width + 2 * padding, y: -height / 2 }, + { x: width, y: -2 * height / 3 }, + { x: width, y: -height }, + // Top + { x: width - midpoint, y: -height }, + { x: width / 2, y: -height - 2 * padding }, + { x: midpoint, y: -height }, + // Left + { x: 0, y: -height }, + { x: 0, y: -2 * height / 3 }, + { x: -2 * padding, y: -height / 2 }, + { x: 0, y: -height / 3 } + ]; + } + if (directions.has("right") && directions.has("left") && directions.has("up")) { + return [ + { x: midpoint, y: 0 }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("right") && directions.has("left") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: midpoint, y: -height }, + { x: width - midpoint, y: -height }, + { x: width, y: 0 } + ]; + } + if (directions.has("right") && directions.has("up") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: width, y: -midpoint }, + { x: width, y: -height + midpoint }, + { x: 0, y: -height } + ]; + } + if (directions.has("left") && directions.has("up") && directions.has("down")) { + return [ + { x: width, y: 0 }, + { x: 0, y: -midpoint }, + { x: 0, y: -height + midpoint }, + { x: width, y: -height } + ]; + } + if (directions.has("right") && directions.has("left")) { + return [ + { x: midpoint, y: 0 }, + { x: midpoint, y: -padding }, + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: width - midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("up") && directions.has("down")) { + return [ + // Bottom center + { x: width / 2, y: 0 }, + // Left pont of bottom arrow + { x: 0, y: -padding }, + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: 0, y: -height + padding }, + // Top of arrow + { x: width / 2, y: -height }, + { x: width, y: -height + padding }, + // Top of right vertical bar + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding }, + { x: width, y: -padding } + ]; + } + if (directions.has("right") && directions.has("up")) { + return [ + { x: 0, y: 0 }, + { x: width, y: -midpoint }, + { x: 0, y: -height } + ]; + } + if (directions.has("right") && directions.has("down")) { + return [ + { x: 0, y: 0 }, + { x: width, y: 0 }, + { x: 0, y: -height } + ]; + } + if (directions.has("left") && directions.has("up")) { + return [ + { x: width, y: 0 }, + { x: 0, y: -midpoint }, + { x: width, y: -height } + ]; + } + if (directions.has("left") && directions.has("down")) { + return [ + { x: width, y: 0 }, + { x: 0, y: 0 }, + { x: width, y: -height } + ]; + } + if (directions.has("right")) { + return [ + { x: midpoint, y: -padding }, + { x: midpoint, y: -padding }, + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: 0 }, + { x: width, y: -height / 2 }, + { x: width - midpoint, y: -height }, + { x: width - midpoint, y: -height + padding }, + // top left corner of arrow + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding } + ]; + } + if (directions.has("left")) { + return [ + { x: midpoint, y: 0 }, + { x: midpoint, y: -padding }, + // Two points, the right corners + { x: width - midpoint, y: -padding }, + { x: width - midpoint, y: -height + padding }, + { x: midpoint, y: -height + padding }, + { x: midpoint, y: -height }, + { x: 0, y: -height / 2 } + ]; + } + if (directions.has("up")) { + return [ + // Bottom center + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: 0, y: -height + padding }, + // Top of arrow + { x: width / 2, y: -height }, + { x: width, y: -height + padding }, + // Top of right vertical bar + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding } + ]; + } + if (directions.has("down")) { + return [ + // Bottom center + { x: width / 2, y: 0 }, + // Left pont of bottom arrow + { x: 0, y: -padding }, + { x: midpoint, y: -padding }, + // Left top over vertical section + { x: midpoint, y: -height + padding }, + { x: width - midpoint, y: -height + padding }, + { x: width - midpoint, y: -padding }, + { x: width, y: -padding } + ]; + } + return [{ x: 0, y: 0 }]; +}; +const formatClass = (str) => { + if (str) { + return " " + str; + } + return ""; +}; +const getClassesFromNode = (node, otherClasses) => { + return `${"node default"}${formatClass(node.classes)} ${formatClass( + node.class + )}`; +}; +const question$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const s = w + h; + const points = [ + { x: s / 2, y: 0 }, + { x: s, y: -s / 2 }, + { x: s / 2, y: -s }, + { x: 0, y: -s / 2 } + ]; + log$1.info("Question main (Circle)"); + const questionElem = insertPolygonShape$2(shapeSvg, s, s, points); + questionElem.attr("style", node.style); + updateNodeBounds(node, questionElem); + node.intersect = function(point2) { + log$1.warn("Intersect called"); + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const choice = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const s = 28; + const points = [ + { x: 0, y: s / 2 }, + { x: s / 2, y: 0 }, + { x: 0, y: -s / 2 }, + { x: -s / 2, y: 0 } + ]; + const choice2 = shapeSvg.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ); + choice2.attr("class", "state-start").attr("r", 7).attr("width", 28).attr("height", 28); + node.width = 28; + node.height = 28; + node.intersect = function(point2) { + return intersect.circle(node, 14, point2); + }; + return shapeSvg; +}; +const hexagon$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const f = 4; + const h = bbox.height + node.padding; + const m = h / f; + const w = bbox.width + 2 * m + node.padding; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + const hex = insertPolygonShape$2(shapeSvg, w, h, points); + hex.attr("style", node.style); + updateNodeBounds(node, hex); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const block_arrow = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper(parent, node, void 0, true); + const f = 2; + const h = bbox.height + 2 * node.padding; + const m = h / f; + const w = bbox.width + 2 * m + node.padding; + const points = getArrowPoints(node.directions, bbox, node); + const blockArrow = insertPolygonShape$2(shapeSvg, w, h, points); + blockArrow.attr("style", node.style); + updateNodeBounds(node, blockArrow); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const rect_left_inv_arrow$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -h / 2, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: -h / 2, y: -h }, + { x: 0, y: -h / 2 } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + node.width = w + h; + node.height = h; + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const lean_right$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper(parent, node, getClassesFromNode(node), true); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const lean_left$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 2 * h / 6, y: 0 }, + { x: w + h / 6, y: 0 }, + { x: w - 2 * h / 6, y: -h }, + { x: -h / 6, y: -h } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const trapezoid$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w + 2 * h / 6, y: 0 }, + { x: w - h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const inv_trapezoid$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: -2 * h / 6, y: -h } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const rect_right_inv_arrow$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 0, y: 0 }, + { x: w + h / 2, y: 0 }, + { x: w, y: -h / 2 }, + { x: w + h / 2, y: -h }, + { x: 0, y: -h } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const cylinder$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const rx = w / 2; + const ry = rx / (2.5 + w / 50); + const h = bbox.height + ry + node.padding; + const shape = "M 0," + ry + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 a " + rx + "," + ry + " 0,0,0 " + -w + " 0 l 0," + h + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 l 0," + -h; + const el = shapeSvg.attr("label-offset-y", ry).insert("path", ":first-child").attr("style", node.style).attr("d", shape).attr("transform", "translate(" + -w / 2 + "," + -(h / 2 + ry) + ")"); + updateNodeBounds(node, el); + node.intersect = function(point2) { + const pos = intersect.rect(node, point2); + const x = pos.x - node.x; + if (rx != 0 && (Math.abs(x) < node.width / 2 || Math.abs(x) == node.width / 2 && Math.abs(pos.y - node.y) > node.height / 2 - ry)) { + let y = ry * ry * (1 - x * x / (rx * rx)); + if (y != 0) { + y = Math.sqrt(y); + } + y = ry - y; + if (point2.y - node.y > 0) { + y = -y; + } + pos.y += y; + } + return pos; + }; + return shapeSvg; +}; +const rect$1 = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes + " " + node.class, + true + ); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = node.positioned ? node.width : bbox.width + node.padding; + const totalHeight = node.positioned ? node.height : bbox.height + node.padding; + const x = node.positioned ? -totalWidth / 2 : -bbox.width / 2 - halfPadding; + const y = node.positioned ? -totalHeight / 2 : -bbox.height / 2 - halfPadding; + rect2.attr("class", "basic label-container").attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", x).attr("y", y).attr("width", totalWidth).attr("height", totalHeight); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const composite = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + "node " + node.classes, + true + ); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = node.positioned ? node.width : bbox.width + node.padding; + const totalHeight = node.positioned ? node.height : bbox.height + node.padding; + const x = node.positioned ? -totalWidth / 2 : -bbox.width / 2 - halfPadding; + const y = node.positioned ? -totalHeight / 2 : -bbox.height / 2 - halfPadding; + rect2.attr("class", "basic cluster composite label-container").attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", x).attr("y", y).attr("width", totalWidth).attr("height", totalHeight); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const labelRect = async (parent, node) => { + const { shapeSvg } = await labelHelper(parent, node, "label", true); + log$1.trace("Classes = ", node.class); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const totalWidth = 0; + const totalHeight = 0; + rect2.attr("width", totalWidth).attr("height", totalHeight); + shapeSvg.attr("class", "label edgeLabel"); + if (node.props) { + const propKeys = new Set(Object.keys(node.props)); + if (node.props.borders) { + applyNodePropertyBorders(rect2, node.props.borders, totalWidth, totalHeight); + propKeys.delete("borders"); + } + propKeys.forEach((propKey) => { + log$1.warn(`Unknown node property ${propKey}`); + }); + } + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +function applyNodePropertyBorders(rect2, borders, totalWidth, totalHeight) { + const strokeDashArray = []; + const addBorder = (length) => { + strokeDashArray.push(length, 0); + }; + const skipBorder = (length) => { + strokeDashArray.push(0, length); + }; + if (borders.includes("t")) { + log$1.debug("add top border"); + addBorder(totalWidth); + } else { + skipBorder(totalWidth); + } + if (borders.includes("r")) { + log$1.debug("add right border"); + addBorder(totalHeight); + } else { + skipBorder(totalHeight); + } + if (borders.includes("b")) { + log$1.debug("add bottom border"); + addBorder(totalWidth); + } else { + skipBorder(totalWidth); + } + if (borders.includes("l")) { + log$1.debug("add left border"); + addBorder(totalHeight); + } else { + skipBorder(totalHeight); + } + rect2.attr("stroke-dasharray", strokeDashArray.join(" ")); +} +const rectWithTitle = (parent, node) => { + let classes; + if (!node.classes) { + classes = "node default"; + } else { + classes = "node " + node.classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const innerLine = shapeSvg.insert("line"); + const label = shapeSvg.insert("g").attr("class", "label"); + const text2 = node.labelText.flat ? node.labelText.flat() : node.labelText; + let title = ""; + if (typeof text2 === "object") { + title = text2[0]; + } else { + title = text2; + } + log$1.info("Label text abc79", title, text2, typeof text2 === "object"); + const text = label.node().appendChild(createLabel$1(title, node.labelStyle, true, true)); + let bbox = { width: 0, height: 0 }; + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + log$1.info("Text 2", text2); + const textRows = text2.slice(1, text2.length); + let titleBox = text.getBBox(); + const descr = label.node().appendChild( + createLabel$1(textRows.join ? textRows.join("
    ") : textRows, node.labelStyle, true, true) + ); + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = descr.children[0]; + const dv = select(descr); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + const halfPadding = node.padding / 2; + select(descr).attr( + "transform", + "translate( " + // (titleBox.width - bbox.width) / 2 + + (bbox.width > titleBox.width ? 0 : (titleBox.width - bbox.width) / 2) + ", " + (titleBox.height + halfPadding + 5) + ")" + ); + select(text).attr( + "transform", + "translate( " + // (titleBox.width - bbox.width) / 2 + + (bbox.width < titleBox.width ? 0 : -(titleBox.width - bbox.width) / 2) + ", 0)" + ); + bbox = label.node().getBBox(); + label.attr( + "transform", + "translate(" + -bbox.width / 2 + ", " + (-bbox.height / 2 - halfPadding + 3) + ")" + ); + rect2.attr("class", "outer title-state").attr("x", -bbox.width / 2 - halfPadding).attr("y", -bbox.height / 2 - halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + innerLine.attr("class", "divider").attr("x1", -bbox.width / 2 - halfPadding).attr("x2", bbox.width / 2 + halfPadding).attr("y1", -bbox.height / 2 - halfPadding + titleBox.height + halfPadding).attr("y2", -bbox.height / 2 - halfPadding + titleBox.height + halfPadding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const stadium$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const h = bbox.height + node.padding; + const w = bbox.width + h / 4 + node.padding; + const rect2 = shapeSvg.insert("rect", ":first-child").attr("style", node.style).attr("rx", h / 2).attr("ry", h / 2).attr("x", -w / 2).attr("y", -h / 2).attr("width", w).attr("height", h); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const circle$2 = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + log$1.info("Circle main"); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + log$1.info("Circle intersect", node, bbox.width / 2 + halfPadding, point2); + return intersect.circle(node, bbox.width / 2 + halfPadding, point2); + }; + return shapeSvg; +}; +const doublecircle = async (parent, node) => { + const { shapeSvg, bbox, halfPadding } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const gap = 5; + const circleGroup = shapeSvg.insert("g", ":first-child"); + const outerCircle = circleGroup.insert("circle"); + const innerCircle = circleGroup.insert("circle"); + circleGroup.attr("class", node.class); + outerCircle.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding + gap).attr("width", bbox.width + node.padding + gap * 2).attr("height", bbox.height + node.padding + gap * 2); + innerCircle.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("r", bbox.width / 2 + halfPadding).attr("width", bbox.width + node.padding).attr("height", bbox.height + node.padding); + log$1.info("DoubleCircle main"); + updateNodeBounds(node, outerCircle); + node.intersect = function(point2) { + log$1.info("DoubleCircle intersect", node, bbox.width / 2 + halfPadding + gap, point2); + return intersect.circle(node, bbox.width / 2 + halfPadding + gap, point2); + }; + return shapeSvg; +}; +const subroutine$1 = async (parent, node) => { + const { shapeSvg, bbox } = await labelHelper( + parent, + node, + getClassesFromNode(node), + true + ); + const w = bbox.width + node.padding; + const h = bbox.height + node.padding; + const points = [ + { x: 0, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: 0, y: -h }, + { x: 0, y: 0 }, + { x: -8, y: 0 }, + { x: w + 8, y: 0 }, + { x: w + 8, y: -h }, + { x: -8, y: -h }, + { x: -8, y: 0 } + ]; + const el = insertPolygonShape$2(shapeSvg, w, h, points); + el.attr("style", node.style); + updateNodeBounds(node, el); + node.intersect = function(point2) { + return intersect.polygon(node, points, point2); + }; + return shapeSvg; +}; +const start = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("class", "state-start").attr("r", 7).attr("width", 14).attr("height", 14); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + return intersect.circle(node, 7, point2); + }; + return shapeSvg; +}; +const forkJoin = (parent, node, dir) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + let width = 70; + let height = 10; + if (dir === "LR") { + width = 10; + height = 70; + } + const shape = shapeSvg.append("rect").attr("x", -1 * width / 2).attr("y", -1 * height / 2).attr("width", width).attr("height", height).attr("class", "fork-join"); + updateNodeBounds(node, shape); + node.height = node.height + node.padding / 2; + node.width = node.width + node.padding / 2; + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const end = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "node default").attr("id", node.domId || node.id); + const innerCircle = shapeSvg.insert("circle", ":first-child"); + const circle2 = shapeSvg.insert("circle", ":first-child"); + circle2.attr("class", "state-start").attr("r", 7).attr("width", 14).attr("height", 14); + innerCircle.attr("class", "state-end").attr("r", 5).attr("width", 10).attr("height", 10); + updateNodeBounds(node, circle2); + node.intersect = function(point2) { + return intersect.circle(node, 7, point2); + }; + return shapeSvg; +}; +const class_box = (parent, node) => { + const halfPadding = node.padding / 2; + const rowPadding = 4; + const lineHeight = 8; + let classes; + if (!node.classes) { + classes = "node default"; + } else { + classes = "node " + node.classes; + } + const shapeSvg = parent.insert("g").attr("class", classes).attr("id", node.domId || node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const topLine = shapeSvg.insert("line"); + const bottomLine = shapeSvg.insert("line"); + let maxWidth = 0; + let maxHeight = rowPadding; + const labelContainer = shapeSvg.insert("g").attr("class", "label"); + let verticalPos = 0; + const hasInterface = node.classData.annotations && node.classData.annotations[0]; + const interfaceLabelText = node.classData.annotations[0] ? "«" + node.classData.annotations[0] + "»" : ""; + const interfaceLabel = labelContainer.node().appendChild(createLabel$1(interfaceLabelText, node.labelStyle, true, true)); + let interfaceBBox = interfaceLabel.getBBox(); + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = interfaceLabel.children[0]; + const dv = select(interfaceLabel); + interfaceBBox = div.getBoundingClientRect(); + dv.attr("width", interfaceBBox.width); + dv.attr("height", interfaceBBox.height); + } + if (node.classData.annotations[0]) { + maxHeight += interfaceBBox.height + rowPadding; + maxWidth += interfaceBBox.width; + } + let classTitleString = node.classData.label; + if (node.classData.type !== void 0 && node.classData.type !== "") { + if (getConfig$2().flowchart.htmlLabels) { + classTitleString += "<" + node.classData.type + ">"; + } else { + classTitleString += "<" + node.classData.type + ">"; + } + } + const classTitleLabel = labelContainer.node().appendChild(createLabel$1(classTitleString, node.labelStyle, true, true)); + select(classTitleLabel).attr("class", "classTitle"); + let classTitleBBox = classTitleLabel.getBBox(); + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = classTitleLabel.children[0]; + const dv = select(classTitleLabel); + classTitleBBox = div.getBoundingClientRect(); + dv.attr("width", classTitleBBox.width); + dv.attr("height", classTitleBBox.height); + } + maxHeight += classTitleBBox.height + rowPadding; + if (classTitleBBox.width > maxWidth) { + maxWidth = classTitleBBox.width; + } + const classAttributes = []; + node.classData.members.forEach((member) => { + const parsedInfo = member.getDisplayDetails(); + let parsedText = parsedInfo.displayText; + if (getConfig$2().flowchart.htmlLabels) { + parsedText = parsedText.replace(//g, ">"); + } + const lbl = labelContainer.node().appendChild( + createLabel$1( + parsedText, + parsedInfo.cssStyle ? parsedInfo.cssStyle : node.labelStyle, + true, + true + ) + ); + let bbox = lbl.getBBox(); + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = lbl.children[0]; + const dv = select(lbl); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (bbox.width > maxWidth) { + maxWidth = bbox.width; + } + maxHeight += bbox.height + rowPadding; + classAttributes.push(lbl); + }); + maxHeight += lineHeight; + const classMethods = []; + node.classData.methods.forEach((member) => { + const parsedInfo = member.getDisplayDetails(); + let displayText = parsedInfo.displayText; + if (getConfig$2().flowchart.htmlLabels) { + displayText = displayText.replace(//g, ">"); + } + const lbl = labelContainer.node().appendChild( + createLabel$1( + displayText, + parsedInfo.cssStyle ? parsedInfo.cssStyle : node.labelStyle, + true, + true + ) + ); + let bbox = lbl.getBBox(); + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const div = lbl.children[0]; + const dv = select(lbl); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + if (bbox.width > maxWidth) { + maxWidth = bbox.width; + } + maxHeight += bbox.height + rowPadding; + classMethods.push(lbl); + }); + maxHeight += lineHeight; + if (hasInterface) { + let diffX2 = (maxWidth - interfaceBBox.width) / 2; + select(interfaceLabel).attr( + "transform", + "translate( " + (-1 * maxWidth / 2 + diffX2) + ", " + -1 * maxHeight / 2 + ")" + ); + verticalPos = interfaceBBox.height + rowPadding; + } + let diffX = (maxWidth - classTitleBBox.width) / 2; + select(classTitleLabel).attr( + "transform", + "translate( " + (-1 * maxWidth / 2 + diffX) + ", " + (-1 * maxHeight / 2 + verticalPos) + ")" + ); + verticalPos += classTitleBBox.height + rowPadding; + topLine.attr("class", "divider").attr("x1", -maxWidth / 2 - halfPadding).attr("x2", maxWidth / 2 + halfPadding).attr("y1", -maxHeight / 2 - halfPadding + lineHeight + verticalPos).attr("y2", -maxHeight / 2 - halfPadding + lineHeight + verticalPos); + verticalPos += lineHeight; + classAttributes.forEach((lbl) => { + select(lbl).attr( + "transform", + "translate( " + -maxWidth / 2 + ", " + (-1 * maxHeight / 2 + verticalPos + lineHeight / 2) + ")" + ); + const memberBBox = lbl == null ? void 0 : lbl.getBBox(); + verticalPos += ((memberBBox == null ? void 0 : memberBBox.height) ?? 0) + rowPadding; + }); + verticalPos += lineHeight; + bottomLine.attr("class", "divider").attr("x1", -maxWidth / 2 - halfPadding).attr("x2", maxWidth / 2 + halfPadding).attr("y1", -maxHeight / 2 - halfPadding + lineHeight + verticalPos).attr("y2", -maxHeight / 2 - halfPadding + lineHeight + verticalPos); + verticalPos += lineHeight; + classMethods.forEach((lbl) => { + select(lbl).attr( + "transform", + "translate( " + -maxWidth / 2 + ", " + (-1 * maxHeight / 2 + verticalPos) + ")" + ); + const memberBBox = lbl == null ? void 0 : lbl.getBBox(); + verticalPos += ((memberBBox == null ? void 0 : memberBBox.height) ?? 0) + rowPadding; + }); + rect2.attr("style", node.style).attr("class", "outer title-state").attr("x", -maxWidth / 2 - halfPadding).attr("y", -(maxHeight / 2) - halfPadding).attr("width", maxWidth + node.padding).attr("height", maxHeight + node.padding); + updateNodeBounds(node, rect2); + node.intersect = function(point2) { + return intersect.rect(node, point2); + }; + return shapeSvg; +}; +const shapes$1 = { + rhombus: question$1, + composite, + question: question$1, + rect: rect$1, + labelRect, + rectWithTitle, + choice, + circle: circle$2, + doublecircle, + stadium: stadium$1, + hexagon: hexagon$1, + block_arrow, + rect_left_inv_arrow: rect_left_inv_arrow$1, + lean_right: lean_right$1, + lean_left: lean_left$1, + trapezoid: trapezoid$1, + inv_trapezoid: inv_trapezoid$1, + rect_right_inv_arrow: rect_right_inv_arrow$1, + cylinder: cylinder$1, + start, + end, + note: note$1, + subroutine: subroutine$1, + fork: forkJoin, + join: forkJoin, + class_box +}; +let nodeElems = {}; +const insertNode = async (elem, node, dir) => { + let newEl; + let el; + if (node.link) { + let target; + if (getConfig$2().securityLevel === "sandbox") { + target = "_top"; + } else if (node.linkTarget) { + target = node.linkTarget || "_blank"; + } + newEl = elem.insert("svg:a").attr("xlink:href", node.link).attr("target", target); + el = await shapes$1[node.shape](newEl, node, dir); + } else { + el = await shapes$1[node.shape](elem, node, dir); + newEl = el; + } + if (node.tooltip) { + el.attr("title", node.tooltip); + } + if (node.class) { + el.attr("class", "node default " + node.class); + } + newEl.attr("data-node", "true"); + newEl.attr("data-id", node.id); + nodeElems[node.id] = newEl; + if (node.haveCallback) { + nodeElems[node.id].attr("class", nodeElems[node.id].attr("class") + " clickable"); + } + return newEl; +}; +const setNodeElem = (elem, node) => { + nodeElems[node.id] = elem; +}; +const clear$1$3 = () => { + nodeElems = {}; +}; +const positionNode$1 = (node) => { + const el = nodeElems[node.id]; + log$1.trace( + "Transforming node", + node.diff, + node, + "translate(" + (node.x - node.width / 2 - 5) + ", " + node.width / 2 + ")" + ); + const padding = 8; + const diff = node.diff || 0; + if (node.clusterNode) { + el.attr( + "transform", + "translate(" + (node.x + diff - node.width / 2) + ", " + (node.y - node.height / 2 - padding) + ")" + ); + } else { + el.attr("transform", "translate(" + node.x + ", " + node.y + ")"); + } + return diff; +}; +const getSubGraphTitleMargins = ({ + flowchart +}) => { + var _a, _b; + const subGraphTitleTopMargin = ((_a = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _a.top) ?? 0; + const subGraphTitleBottomMargin = ((_b = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _b.bottom) ?? 0; + const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin; + return { + subGraphTitleTopMargin, + subGraphTitleBottomMargin, + subGraphTitleTotalMargin + }; +}; +const markerOffsets = { + aggregation: 18, + extension: 18, + composition: 18, + dependency: 6, + lollipop: 13.5, + arrow_point: 5.3 +}; +function calculateDeltaAndAngle(point1, point2) { + if (point1 === void 0 || point2 === void 0) { + return { angle: 0, deltaX: 0, deltaY: 0 }; + } + point1 = pointTransformer(point1); + point2 = pointTransformer(point2); + const [x1, y1] = [point1.x, point1.y]; + const [x2, y2] = [point2.x, point2.y]; + const deltaX = x2 - x1; + const deltaY = y2 - y1; + return { angle: Math.atan(deltaY / deltaX), deltaX, deltaY }; +} +const pointTransformer = (data) => { + if (Array.isArray(data)) { + return { x: data[0], y: data[1] }; + } + return data; +}; +const getLineFunctionsWithOffset = (edge) => { + return { + x: function(d, i, data) { + let offset = 0; + if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { + const { angle, deltaX } = calculateDeltaAndAngle(data[0], data[1]); + offset = markerOffsets[edge.arrowTypeStart] * Math.cos(angle) * (deltaX >= 0 ? 1 : -1); + } else if (i === data.length - 1 && Object.hasOwn(markerOffsets, edge.arrowTypeEnd)) { + const { angle, deltaX } = calculateDeltaAndAngle( + data[data.length - 1], + data[data.length - 2] + ); + offset = markerOffsets[edge.arrowTypeEnd] * Math.cos(angle) * (deltaX >= 0 ? 1 : -1); + } + return pointTransformer(d).x + offset; + }, + y: function(d, i, data) { + let offset = 0; + if (i === 0 && Object.hasOwn(markerOffsets, edge.arrowTypeStart)) { + const { angle, deltaY } = calculateDeltaAndAngle(data[0], data[1]); + offset = markerOffsets[edge.arrowTypeStart] * Math.abs(Math.sin(angle)) * (deltaY >= 0 ? 1 : -1); + } else if (i === data.length - 1 && Object.hasOwn(markerOffsets, edge.arrowTypeEnd)) { + const { angle, deltaY } = calculateDeltaAndAngle( + data[data.length - 1], + data[data.length - 2] + ); + offset = markerOffsets[edge.arrowTypeEnd] * Math.abs(Math.sin(angle)) * (deltaY >= 0 ? 1 : -1); + } + return pointTransformer(d).y + offset; + } + }; +}; +const addEdgeMarkers = (svgPath, edge, url, id, diagramType) => { + if (edge.arrowTypeStart) { + addEdgeMarker(svgPath, "start", edge.arrowTypeStart, url, id, diagramType); + } + if (edge.arrowTypeEnd) { + addEdgeMarker(svgPath, "end", edge.arrowTypeEnd, url, id, diagramType); + } +}; +const arrowTypesMap = { + arrow_cross: "cross", + arrow_point: "point", + arrow_barb: "barb", + arrow_circle: "circle", + aggregation: "aggregation", + extension: "extension", + composition: "composition", + dependency: "dependency", + lollipop: "lollipop" +}; +const addEdgeMarker = (svgPath, position, arrowType, url, id, diagramType) => { + const endMarkerType = arrowTypesMap[arrowType]; + if (!endMarkerType) { + log$1.warn(`Unknown arrow type: ${arrowType}`); + return; + } + const suffix = position === "start" ? "Start" : "End"; + svgPath.attr(`marker-${position}`, `url(${url}#${id}_${diagramType}-${endMarkerType}${suffix})`); +}; +let edgeLabels = {}; +let terminalLabels = {}; +const clear$h = () => { + edgeLabels = {}; + terminalLabels = {}; +}; +const insertEdgeLabel = (elem, edge) => { + const useHtmlLabels = evaluate(getConfig$2().flowchart.htmlLabels); + const labelElement = edge.labelType === "markdown" ? createText(elem, edge.label, { + style: edge.labelStyle, + useHtmlLabels, + addSvgBackground: true + }) : createLabel$1(edge.label, edge.labelStyle); + const edgeLabel = elem.insert("g").attr("class", "edgeLabel"); + const label = edgeLabel.insert("g").attr("class", "label"); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + if (useHtmlLabels) { + const div = labelElement.children[0]; + const dv = select(labelElement); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + label.attr("transform", "translate(" + -bbox.width / 2 + ", " + -bbox.height / 2 + ")"); + edgeLabels[edge.id] = edgeLabel; + edge.width = bbox.width; + edge.height = bbox.height; + let fo; + if (edge.startLabelLeft) { + const startLabelElement = createLabel$1(edge.startLabelLeft, edge.labelStyle); + const startEdgeLabelLeft = elem.insert("g").attr("class", "edgeTerminals"); + const inner = startEdgeLabelLeft.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(startLabelElement); + const slBox = startLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].startLeft = startEdgeLabelLeft; + setTerminalWidth(fo, edge.startLabelLeft); + } + if (edge.startLabelRight) { + const startLabelElement = createLabel$1(edge.startLabelRight, edge.labelStyle); + const startEdgeLabelRight = elem.insert("g").attr("class", "edgeTerminals"); + const inner = startEdgeLabelRight.insert("g").attr("class", "inner"); + fo = startEdgeLabelRight.node().appendChild(startLabelElement); + inner.node().appendChild(startLabelElement); + const slBox = startLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].startRight = startEdgeLabelRight; + setTerminalWidth(fo, edge.startLabelRight); + } + if (edge.endLabelLeft) { + const endLabelElement = createLabel$1(edge.endLabelLeft, edge.labelStyle); + const endEdgeLabelLeft = elem.insert("g").attr("class", "edgeTerminals"); + const inner = endEdgeLabelLeft.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(endLabelElement); + const slBox = endLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + endEdgeLabelLeft.node().appendChild(endLabelElement); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].endLeft = endEdgeLabelLeft; + setTerminalWidth(fo, edge.endLabelLeft); + } + if (edge.endLabelRight) { + const endLabelElement = createLabel$1(edge.endLabelRight, edge.labelStyle); + const endEdgeLabelRight = elem.insert("g").attr("class", "edgeTerminals"); + const inner = endEdgeLabelRight.insert("g").attr("class", "inner"); + fo = inner.node().appendChild(endLabelElement); + const slBox = endLabelElement.getBBox(); + inner.attr("transform", "translate(" + -slBox.width / 2 + ", " + -slBox.height / 2 + ")"); + endEdgeLabelRight.node().appendChild(endLabelElement); + if (!terminalLabels[edge.id]) { + terminalLabels[edge.id] = {}; + } + terminalLabels[edge.id].endRight = endEdgeLabelRight; + setTerminalWidth(fo, edge.endLabelRight); + } + return labelElement; +}; +function setTerminalWidth(fo, value) { + if (getConfig$2().flowchart.htmlLabels && fo) { + fo.style.width = value.length * 9 + "px"; + fo.style.height = "12px"; + } +} +const positionEdgeLabel = (edge, paths) => { + log$1.debug("Moving label abc88 ", edge.id, edge.label, edgeLabels[edge.id], paths); + let path = paths.updatedPath ? paths.updatedPath : paths.originalPath; + const siteConfig = getConfig$2(); + const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig); + if (edge.label) { + const el = edgeLabels[edge.id]; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcLabelPosition(path); + log$1.debug( + "Moving label " + edge.label + " from (", + x, + ",", + y, + ") to (", + pos.x, + ",", + pos.y, + ") abc88" + ); + if (paths.updatedPath) { + x = pos.x; + y = pos.y; + } + } + el.attr("transform", `translate(${x}, ${y + subGraphTitleTotalMargin / 2})`); + } + if (edge.startLabelLeft) { + const el = terminalLabels[edge.id].startLeft; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeStart ? 10 : 0, "start_left", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.startLabelRight) { + const el = terminalLabels[edge.id].startRight; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition( + edge.arrowTypeStart ? 10 : 0, + "start_right", + path + ); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.endLabelLeft) { + const el = terminalLabels[edge.id].endLeft; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_left", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } + if (edge.endLabelRight) { + const el = terminalLabels[edge.id].endRight; + let x = edge.x; + let y = edge.y; + if (path) { + const pos = utils.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_right", path); + x = pos.x; + y = pos.y; + } + el.attr("transform", `translate(${x}, ${y})`); + } +}; +const outsideNode = (node, point2) => { + const x = node.x; + const y = node.y; + const dx = Math.abs(point2.x - x); + const dy = Math.abs(point2.y - y); + const w = node.width / 2; + const h = node.height / 2; + if (dx >= w || dy >= h) { + return true; + } + return false; +}; +const intersection = (node, outsidePoint, insidePoint) => { + log$1.debug(`intersection calc abc89: + outsidePoint: ${JSON.stringify(outsidePoint)} + insidePoint : ${JSON.stringify(insidePoint)} + node : x:${node.x} y:${node.y} w:${node.width} h:${node.height}`); + const x = node.x; + const y = node.y; + const dx = Math.abs(x - insidePoint.x); + const w = node.width / 2; + let r = insidePoint.x < outsidePoint.x ? w - dx : w + dx; + const h = node.height / 2; + const Q = Math.abs(outsidePoint.y - insidePoint.y); + const R = Math.abs(outsidePoint.x - insidePoint.x); + if (Math.abs(y - outsidePoint.y) * w > Math.abs(x - outsidePoint.x) * h) { + let q = insidePoint.y < outsidePoint.y ? outsidePoint.y - h - y : y - h - outsidePoint.y; + r = R * q / Q; + const res = { + x: insidePoint.x < outsidePoint.x ? insidePoint.x + r : insidePoint.x - R + r, + y: insidePoint.y < outsidePoint.y ? insidePoint.y + Q - q : insidePoint.y - Q + q + }; + if (r === 0) { + res.x = outsidePoint.x; + res.y = outsidePoint.y; + } + if (R === 0) { + res.x = outsidePoint.x; + } + if (Q === 0) { + res.y = outsidePoint.y; + } + log$1.debug(`abc89 topp/bott calc, Q ${Q}, q ${q}, R ${R}, r ${r}`, res); + return res; + } else { + if (insidePoint.x < outsidePoint.x) { + r = outsidePoint.x - w - x; + } else { + r = x - w - outsidePoint.x; + } + let q = Q * r / R; + let _x = insidePoint.x < outsidePoint.x ? insidePoint.x + R - r : insidePoint.x - R + r; + let _y = insidePoint.y < outsidePoint.y ? insidePoint.y + q : insidePoint.y - q; + log$1.debug(`sides calc abc89, Q ${Q}, q ${q}, R ${R}, r ${r}`, { _x, _y }); + if (r === 0) { + _x = outsidePoint.x; + _y = outsidePoint.y; + } + if (R === 0) { + _x = outsidePoint.x; + } + if (Q === 0) { + _y = outsidePoint.y; + } + return { x: _x, y: _y }; + } +}; +const cutPathAtIntersect = (_points, boundaryNode) => { + log$1.debug("abc88 cutPathAtIntersect", _points, boundaryNode); + let points = []; + let lastPointOutside = _points[0]; + let isInside = false; + _points.forEach((point2) => { + if (!outsideNode(boundaryNode, point2) && !isInside) { + const inter = intersection(boundaryNode, lastPointOutside, point2); + let pointPresent = false; + points.forEach((p) => { + pointPresent = pointPresent || p.x === inter.x && p.y === inter.y; + }); + if (!points.some((e) => e.x === inter.x && e.y === inter.y)) { + points.push(inter); + } + isInside = true; + } else { + lastPointOutside = point2; + if (!isInside) { + points.push(point2); + } + } + }); + return points; +}; +const insertEdge$1 = function(elem, e, edge, clusterDb, diagramType, graph, id) { + let points = edge.points; + log$1.debug("abc88 InsertEdge: edge=", edge, "e=", e); + let pointsHasChanged = false; + const tail = graph.node(e.v); + var head = graph.node(e.w); + if ((head == null ? void 0 : head.intersect) && (tail == null ? void 0 : tail.intersect)) { + points = points.slice(1, edge.points.length - 1); + points.unshift(tail.intersect(points[0])); + points.push(head.intersect(points[points.length - 1])); + } + if (edge.toCluster) { + log$1.debug("to cluster abc88", clusterDb[edge.toCluster]); + points = cutPathAtIntersect(edge.points, clusterDb[edge.toCluster].node); + pointsHasChanged = true; + } + if (edge.fromCluster) { + log$1.debug("from cluster abc88", clusterDb[edge.fromCluster]); + points = cutPathAtIntersect(points.reverse(), clusterDb[edge.fromCluster].node).reverse(); + pointsHasChanged = true; + } + const lineData = points.filter((p) => !Number.isNaN(p.y)); + let curve = curveBasis; + if (edge.curve && (diagramType === "graph" || diagramType === "flowchart")) { + curve = edge.curve; + } + const { x, y } = getLineFunctionsWithOffset(edge); + const lineFunction = line$1().x(x).y(y).curve(curve); + let strokeClasses; + switch (edge.thickness) { + case "normal": + strokeClasses = "edge-thickness-normal"; + break; + case "thick": + strokeClasses = "edge-thickness-thick"; + break; + case "invisible": + strokeClasses = "edge-thickness-thick"; + break; + default: + strokeClasses = ""; + } + switch (edge.pattern) { + case "solid": + strokeClasses += " edge-pattern-solid"; + break; + case "dotted": + strokeClasses += " edge-pattern-dotted"; + break; + case "dashed": + strokeClasses += " edge-pattern-dashed"; + break; + } + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", edge.id).attr("class", " " + strokeClasses + (edge.classes ? " " + edge.classes : "")).attr("style", edge.style); + let url = ""; + if (getConfig$2().flowchart.arrowMarkerAbsolute || getConfig$2().state.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + addEdgeMarkers(svgPath, edge, url, id, diagramType); + let paths = {}; + if (pointsHasChanged) { + paths.updatedPath = points; + } + paths.originalPath = edge.points; + return paths; +}; + +let clusterDb = {}; +let descendants = {}; +let parents = {}; +const clear$1$2 = () => { + descendants = {}; + parents = {}; + clusterDb = {}; +}; +const isDescendant = (id, ancestorId) => { + log$1.trace("In isDescendant", ancestorId, " ", id, " = ", descendants[ancestorId].includes(id)); + if (descendants[ancestorId].includes(id)) { + return true; + } + return false; +}; +const edgeInCluster = (edge, clusterId) => { + log$1.info("Descendants of ", clusterId, " is ", descendants[clusterId]); + log$1.info("Edge is ", edge); + if (edge.v === clusterId) { + return false; + } + if (edge.w === clusterId) { + return false; + } + if (!descendants[clusterId]) { + log$1.debug("Tilt, ", clusterId, ",not in descendants"); + return false; + } + return descendants[clusterId].includes(edge.v) || isDescendant(edge.v, clusterId) || isDescendant(edge.w, clusterId) || descendants[clusterId].includes(edge.w); +}; +const copy$1 = (clusterId, graph, newGraph, rootId) => { + log$1.warn( + "Copying children of ", + clusterId, + "root", + rootId, + "data", + graph.node(clusterId), + rootId + ); + const nodes = graph.children(clusterId) || []; + if (clusterId !== rootId) { + nodes.push(clusterId); + } + log$1.warn("Copying (nodes) clusterId", clusterId, "nodes", nodes); + nodes.forEach((node) => { + if (graph.children(node).length > 0) { + copy$1(node, graph, newGraph, rootId); + } else { + const data = graph.node(node); + log$1.info("cp ", node, " to ", rootId, " with parent ", clusterId); + newGraph.setNode(node, data); + if (rootId !== graph.parent(node)) { + log$1.warn("Setting parent", node, graph.parent(node)); + newGraph.setParent(node, graph.parent(node)); + } + if (clusterId !== rootId && node !== clusterId) { + log$1.debug("Setting parent", node, clusterId); + newGraph.setParent(node, clusterId); + } else { + log$1.info("In copy ", clusterId, "root", rootId, "data", graph.node(clusterId), rootId); + log$1.debug( + "Not Setting parent for node=", + node, + "cluster!==rootId", + clusterId !== rootId, + "node!==clusterId", + node !== clusterId + ); + } + const edges = graph.edges(node); + log$1.debug("Copying Edges", edges); + edges.forEach((edge) => { + log$1.info("Edge", edge); + const data2 = graph.edge(edge.v, edge.w, edge.name); + log$1.info("Edge data", data2, rootId); + try { + if (edgeInCluster(edge, rootId)) { + log$1.info("Copying as ", edge.v, edge.w, data2, edge.name); + newGraph.setEdge(edge.v, edge.w, data2, edge.name); + log$1.info("newGraph edges ", newGraph.edges(), newGraph.edge(newGraph.edges()[0])); + } else { + log$1.info( + "Skipping copy of edge ", + edge.v, + "-->", + edge.w, + " rootId: ", + rootId, + " clusterId:", + clusterId + ); + } + } catch (e) { + log$1.error(e); + } + }); + } + log$1.debug("Removing node", node); + graph.removeNode(node); + }); +}; +const extractDescendants = (id, graph) => { + const children = graph.children(id); + let res = [...children]; + for (const child of children) { + parents[child] = id; + res = [...res, ...extractDescendants(child, graph)]; + } + return res; +}; +const findNonClusterChild = (id, graph) => { + log$1.trace("Searching", id); + const children = graph.children(id); + log$1.trace("Searching children of id ", id, children); + if (children.length < 1) { + log$1.trace("This is a valid node", id); + return id; + } + for (const child of children) { + const _id = findNonClusterChild(child, graph); + if (_id) { + log$1.trace("Found replacement for", id, " => ", _id); + return _id; + } + } +}; +const getAnchorId = (id) => { + if (!clusterDb[id]) { + return id; + } + if (!clusterDb[id].externalConnections) { + return id; + } + if (clusterDb[id]) { + return clusterDb[id].id; + } + return id; +}; +const adjustClustersAndEdges = (graph, depth) => { + if (!graph || depth > 10) { + log$1.debug("Opting out, no graph "); + return; + } else { + log$1.debug("Opting in, graph "); + } + graph.nodes().forEach(function(id) { + const children = graph.children(id); + if (children.length > 0) { + log$1.warn( + "Cluster identified", + id, + " Replacement id in edges: ", + findNonClusterChild(id, graph) + ); + descendants[id] = extractDescendants(id, graph); + clusterDb[id] = { id: findNonClusterChild(id, graph), clusterData: graph.node(id) }; + } + }); + graph.nodes().forEach(function(id) { + const children = graph.children(id); + const edges = graph.edges(); + if (children.length > 0) { + log$1.debug("Cluster identified", id, descendants); + edges.forEach((edge) => { + if (edge.v !== id && edge.w !== id) { + const d1 = isDescendant(edge.v, id); + const d2 = isDescendant(edge.w, id); + if (d1 ^ d2) { + log$1.warn("Edge: ", edge, " leaves cluster ", id); + log$1.warn("Descendants of XXX ", id, ": ", descendants[id]); + clusterDb[id].externalConnections = true; + } + } + }); + } else { + log$1.debug("Not a cluster ", id, descendants); + } + }); + for (let id of Object.keys(clusterDb)) { + const nonClusterChild = clusterDb[id].id; + const parent = graph.parent(nonClusterChild); + if (parent !== id && clusterDb[parent] && !clusterDb[parent].externalConnections) { + clusterDb[id].id = parent; + } + } + graph.edges().forEach(function(e) { + const edge = graph.edge(e); + log$1.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + log$1.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e))); + let v = e.v; + let w = e.w; + log$1.warn( + "Fix XXX", + clusterDb, + "ids:", + e.v, + e.w, + "Translating: ", + clusterDb[e.v], + " --- ", + clusterDb[e.w] + ); + if (clusterDb[e.v] && clusterDb[e.w] && clusterDb[e.v] === clusterDb[e.w]) { + log$1.warn("Fixing and trixing link to self - removing XXX", e.v, e.w, e.name); + log$1.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name); + v = getAnchorId(e.v); + w = getAnchorId(e.w); + graph.removeEdge(e.v, e.w, e.name); + const specialId = e.w + "---" + e.v; + graph.setNode(specialId, { + domId: specialId, + id: specialId, + labelStyle: "", + labelText: edge.label, + padding: 0, + shape: "labelRect", + style: "" + }); + const edge1 = structuredClone(edge); + const edge2 = structuredClone(edge); + edge1.label = ""; + edge1.arrowTypeEnd = "none"; + edge2.label = ""; + edge1.fromCluster = e.v; + edge2.toCluster = e.v; + graph.setEdge(v, specialId, edge1, e.name + "-cyclic-special"); + graph.setEdge(specialId, w, edge2, e.name + "-cyclic-special"); + } else if (clusterDb[e.v] || clusterDb[e.w]) { + log$1.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name); + v = getAnchorId(e.v); + w = getAnchorId(e.w); + graph.removeEdge(e.v, e.w, e.name); + if (v !== e.v) { + const parent = graph.parent(v); + clusterDb[parent].externalConnections = true; + edge.fromCluster = e.v; + } + if (w !== e.w) { + const parent = graph.parent(w); + clusterDb[parent].externalConnections = true; + edge.toCluster = e.w; + } + log$1.warn("Fix Replacing with XXX", v, w, e.name); + graph.setEdge(v, w, edge, e.name); + } + }); + log$1.warn("Adjusted Graph", write(graph)); + extractor(graph, 0); + log$1.trace(clusterDb); +}; +const extractor = (graph, depth) => { + log$1.warn("extractor - ", depth, write(graph), graph.children("D")); + if (depth > 10) { + log$1.error("Bailing out"); + return; + } + let nodes = graph.nodes(); + let hasChildren = false; + for (const node of nodes) { + const children = graph.children(node); + hasChildren = hasChildren || children.length > 0; + } + if (!hasChildren) { + log$1.debug("Done, no node has children", graph.nodes()); + return; + } + log$1.debug("Nodes = ", nodes, depth); + for (const node of nodes) { + log$1.debug( + "Extracting node", + node, + clusterDb, + clusterDb[node] && !clusterDb[node].externalConnections, + !graph.parent(node), + graph.node(node), + graph.children("D"), + " Depth ", + depth + ); + if (!clusterDb[node]) { + log$1.debug("Not a cluster", node, depth); + } else if (!clusterDb[node].externalConnections && // !graph.parent(node) && + graph.children(node) && graph.children(node).length > 0) { + log$1.warn( + "Cluster without external connections, without a parent and with children", + node, + depth + ); + const graphSettings = graph.graph(); + let dir = graphSettings.rankdir === "TB" ? "LR" : "TB"; + if (clusterDb[node] && clusterDb[node].clusterData && clusterDb[node].clusterData.dir) { + dir = clusterDb[node].clusterData.dir; + log$1.warn("Fixing dir", clusterDb[node].clusterData.dir, dir); + } + const clusterGraph = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + // Todo: set proper spacing + nodesep: 50, + ranksep: 50, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + log$1.warn("Old graph before copy", write(graph)); + copy$1(node, graph, clusterGraph, node); + graph.setNode(node, { + clusterNode: true, + id: node, + clusterData: clusterDb[node].clusterData, + labelText: clusterDb[node].labelText, + graph: clusterGraph + }); + log$1.warn("New graph after copy node: (", node, ")", write(clusterGraph)); + log$1.debug("Old graph after copy", write(graph)); + } else { + log$1.warn( + "Cluster ** ", + node, + " **not meeting the criteria !externalConnections:", + !clusterDb[node].externalConnections, + " no parent: ", + !graph.parent(node), + " children ", + graph.children(node) && graph.children(node).length > 0, + graph.children("D"), + depth + ); + log$1.debug(clusterDb); + } + } + nodes = graph.nodes(); + log$1.warn("New list of nodes", nodes); + for (const node of nodes) { + const data = graph.node(node); + log$1.warn(" Now next level", node, data); + if (data.clusterNode) { + extractor(data.graph, depth + 1); + } + } +}; +const sorter = (graph, nodes) => { + if (nodes.length === 0) { + return []; + } + let result = Object.assign(nodes); + nodes.forEach((node) => { + const children = graph.children(node); + const sorted = sorter(graph, children); + result = [...result, ...sorted]; + }); + return result; +}; +const sortNodesByHierarchy = (graph) => sorter(graph, graph.children()); +const rect = (parent, node) => { + log$1.info("Creating subgraph rect for ", node.id, node); + const siteConfig = getConfig$2(); + const shapeSvg = parent.insert("g").attr("class", "cluster" + (node.class ? " " + node.class : "")).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const useHtmlLabels = evaluate(siteConfig.flowchart.htmlLabels); + const label = shapeSvg.insert("g").attr("class", "cluster-label"); + const text = node.labelType === "markdown" ? createText(label, node.labelText, { style: node.labelStyle, useHtmlLabels }) : label.node().appendChild(createLabel$1(node.labelText, node.labelStyle, void 0, true)); + let bbox = text.getBBox(); + if (evaluate(siteConfig.flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + const padding = 0 * node.padding; + const halfPadding = padding / 2; + const width = node.width <= bbox.width + padding ? bbox.width + padding : node.width; + if (node.width <= bbox.width + padding) { + node.diff = (bbox.width - node.width) / 2 - node.padding / 2; + } else { + node.diff = -node.padding / 2; + } + log$1.trace("Data ", node, JSON.stringify(node)); + rect2.attr("style", node.style).attr("rx", node.rx).attr("ry", node.ry).attr("x", node.x - width / 2).attr("y", node.y - node.height / 2 - halfPadding).attr("width", width).attr("height", node.height + padding); + const { subGraphTitleTopMargin } = getSubGraphTitleMargins(siteConfig); + if (useHtmlLabels) { + label.attr( + "transform", + // This puts the label on top of the box instead of inside it + `translate(${node.x - bbox.width / 2}, ${node.y - node.height / 2 + subGraphTitleTopMargin})` + ); + } else { + label.attr( + "transform", + // This puts the label on top of the box instead of inside it + `translate(${node.x}, ${node.y - node.height / 2 + subGraphTitleTopMargin})` + ); + } + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const noteGroup = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", "note-cluster").attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + rect2.attr("rx", node.rx).attr("ry", node.ry).attr("x", node.x - node.width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding).attr("width", node.width + padding).attr("height", node.height + padding).attr("fill", "none"); + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const roundedWithTitle = (parent, node) => { + const siteConfig = getConfig$2(); + const shapeSvg = parent.insert("g").attr("class", node.classes).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const label = shapeSvg.insert("g").attr("class", "cluster-label"); + const innerRect = shapeSvg.append("rect"); + const text = label.node().appendChild(createLabel$1(node.labelText, node.labelStyle, void 0, true)); + let bbox = text.getBBox(); + if (evaluate(siteConfig.flowchart.htmlLabels)) { + const div = text.children[0]; + const dv = select(text); + bbox = div.getBoundingClientRect(); + dv.attr("width", bbox.width); + dv.attr("height", bbox.height); + } + bbox = text.getBBox(); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + const width = node.width <= bbox.width + node.padding ? bbox.width + node.padding : node.width; + if (node.width <= bbox.width + node.padding) { + node.diff = (bbox.width + node.padding * 0 - node.width) / 2; + } else { + node.diff = -node.padding / 2; + } + rect2.attr("class", "outer").attr("x", node.x - width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding).attr("width", width + padding).attr("height", node.height + padding); + innerRect.attr("class", "inner").attr("x", node.x - width / 2 - halfPadding).attr("y", node.y - node.height / 2 - halfPadding + bbox.height - 1).attr("width", width + padding).attr("height", node.height + padding - bbox.height - 3); + const { subGraphTitleTopMargin } = getSubGraphTitleMargins(siteConfig); + label.attr( + "transform", + `translate(${node.x - bbox.width / 2}, ${node.y - node.height / 2 - node.padding / 3 + (evaluate(siteConfig.flowchart.htmlLabels) ? 5 : 3) + subGraphTitleTopMargin})` + ); + const rectBox = rect2.node().getBBox(); + node.height = rectBox.height; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const divider = (parent, node) => { + const shapeSvg = parent.insert("g").attr("class", node.classes).attr("id", node.id); + const rect2 = shapeSvg.insert("rect", ":first-child"); + const padding = 0 * node.padding; + const halfPadding = padding / 2; + rect2.attr("class", "divider").attr("x", node.x - node.width / 2 - halfPadding).attr("y", node.y - node.height / 2).attr("width", node.width + padding).attr("height", node.height + padding); + const rectBox = rect2.node().getBBox(); + node.width = rectBox.width; + node.height = rectBox.height; + node.diff = -node.padding / 2; + node.intersect = function(point) { + return intersectRect$1(node, point); + }; + return shapeSvg; +}; +const shapes = { rect, roundedWithTitle, noteGroup, divider }; +let clusterElems = {}; +const insertCluster = (elem, node) => { + log$1.trace("Inserting cluster"); + const shape = node.shape || "rect"; + clusterElems[node.id] = shapes[shape](elem, node); +}; +const clear$g = () => { + clusterElems = {}; +}; +const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, siteConfig) => { + log$1.info("Graph in recursive render: XXX", write(graph), parentCluster); + const dir = graph.graph().rankdir; + log$1.trace("Dir in recursive render - dir:", dir); + const elem = _elem.insert("g").attr("class", "root"); + if (!graph.nodes()) { + log$1.info("No nodes found for", graph); + } else { + log$1.info("Recursive render XXX", graph.nodes()); + } + if (graph.edges().length > 0) { + log$1.trace("Recursive edges", graph.edge(graph.edges()[0])); + } + const clusters = elem.insert("g").attr("class", "clusters"); + const edgePaths = elem.insert("g").attr("class", "edgePaths"); + const edgeLabels = elem.insert("g").attr("class", "edgeLabels"); + const nodes = elem.insert("g").attr("class", "nodes"); + await Promise.all( + graph.nodes().map(async function(v) { + const node = graph.node(v); + if (parentCluster !== void 0) { + const data = JSON.parse(JSON.stringify(parentCluster.clusterData)); + log$1.info("Setting data for cluster XXX (", v, ") ", data, parentCluster); + graph.setNode(parentCluster.id, data); + if (!graph.parent(v)) { + log$1.trace("Setting parent", v, parentCluster.id); + graph.setParent(v, parentCluster.id, data); + } + } + log$1.info("(Insert) Node XXX" + v + ": " + JSON.stringify(graph.node(v))); + if (node && node.clusterNode) { + log$1.info("Cluster identified", v, node.width, graph.node(v)); + const o = await recursiveRender( + nodes, + node.graph, + diagramType, + id, + graph.node(v), + siteConfig + ); + const newEl = o.elem; + updateNodeBounds(node, newEl); + node.diff = o.diff || 0; + log$1.info("Node bounds (abc123)", v, node, node.width, node.x, node.y); + setNodeElem(newEl, node); + log$1.warn("Recursive render complete ", newEl, node); + } else { + if (graph.children(v).length > 0) { + log$1.info("Cluster - the non recursive path XXX", v, node.id, node, graph); + log$1.info(findNonClusterChild(node.id, graph)); + clusterDb[node.id] = { id: findNonClusterChild(node.id, graph), node }; + } else { + log$1.info("Node - the non recursive path", v, node.id, node); + await insertNode(nodes, graph.node(v), dir); + } + } + }) + ); + graph.edges().forEach(function(e) { + const edge = graph.edge(e.v, e.w, e.name); + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + log$1.info("Edge " + e.v + " -> " + e.w + ": ", e, " ", JSON.stringify(graph.edge(e))); + log$1.info("Fix", clusterDb, "ids:", e.v, e.w, "Translating: ", clusterDb[e.v], clusterDb[e.w]); + insertEdgeLabel(edgeLabels, edge); + }); + graph.edges().forEach(function(e) { + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)); + }); + log$1.info("#############################################"); + log$1.info("### Layout ###"); + log$1.info("#############################################"); + log$1.info(graph); + layout$2(graph); + log$1.info("Graph after layout:", write(graph)); + let diff = 0; + const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig); + sortNodesByHierarchy(graph).forEach(function(v) { + const node = graph.node(v); + log$1.info("Position " + v + ": " + JSON.stringify(graph.node(v))); + log$1.info( + "Position " + v + ": (" + node.x, + "," + node.y, + ") width: ", + node.width, + " height: ", + node.height + ); + if (node && node.clusterNode) { + node.y += subGraphTitleTotalMargin; + positionNode$1(node); + } else { + if (graph.children(v).length > 0) { + node.height += subGraphTitleTotalMargin; + insertCluster(clusters, node); + clusterDb[node.id].node = node; + } else { + node.y += subGraphTitleTotalMargin / 2; + positionNode$1(node); + } + } + }); + graph.edges().forEach(function(e) { + const edge = graph.edge(e); + log$1.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(edge), edge); + edge.points.forEach((point) => point.y += subGraphTitleTotalMargin / 2); + const paths = insertEdge$1(edgePaths, e, edge, clusterDb, diagramType, graph, id); + positionEdgeLabel(edge, paths); + }); + graph.nodes().forEach(function(v) { + const n = graph.node(v); + log$1.info(v, n.type, n.diff); + if (n.type === "group") { + diff = n.diff; + } + }); + return { elem, diff }; +}; +const render = async (elem, graph, markers, diagramType, id) => { + insertMarkers$1$1(elem, markers, diagramType, id); + clear$1$3(); + clear$h(); + clear$g(); + clear$1$2(); + log$1.warn("Graph at first:", JSON.stringify(write(graph))); + adjustClustersAndEdges(graph); + log$1.warn("Graph after:", JSON.stringify(write(graph))); + const siteConfig = getConfig$2(); + await recursiveRender(elem, graph, diagramType, id, void 0, siteConfig); +}; + +const conf$8 = {}; +const setConf$8 = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf$8[key] = cnf[key]; + } +}; +const addVertices$2 = async function(vert, g, svgId, root, doc, diagObj) { + const svg = root.select(`[id="${svgId}"]`); + const keys = Object.keys(vert); + for (const id of keys) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + classStr = classStr + " flowchart-label"; + const styles = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + let vertexNode; + log$1.info("vertex", vertex, vertex.labelType); + if (vertex.labelType === "markdown") { + log$1.info("vertex", vertex, vertex.labelType); + } else { + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const node = { + label: vertexText + }; + vertexNode = addHtmlLabel$1(svg, node).node(); + vertexNode.parentNode.removeChild(vertexNode); + } else { + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", styles.labelStyle.replace("color:", "fill:")); + const rows = vertexText.split(common$1.lineBreakRegex); + for (const row of rows) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "1"); + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + vertexNode = svgLabel; + } + } + let radius = 0; + let _shape = ""; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + case "doublecircle": + _shape = "doublecircle"; + break; + default: + _shape = "rect"; + } + const labelText = await renderKatex(vertexText, getConfig$2()); + g.setNode(vertex.id, { + labelStyle: styles.labelStyle, + shape: _shape, + labelText, + labelType: vertex.labelType, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + link: vertex.link, + linkTarget: vertex.linkTarget, + tooltip: diagObj.db.getTooltip(vertex.id) || "", + domId: diagObj.db.lookUpDomId(vertex.id), + haveCallback: vertex.haveCallback, + width: vertex.type === "group" ? 500 : void 0, + dir: vertex.dir, + type: vertex.type, + props: vertex.props, + padding: getConfig$2().flowchart.padding + }); + log$1.info("setNode", { + labelStyle: styles.labelStyle, + labelType: vertex.labelType, + shape: _shape, + labelText, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + domId: diagObj.db.lookUpDomId(vertex.id), + width: vertex.type === "group" ? 500 : void 0, + type: vertex.type, + dir: vertex.dir, + props: vertex.props, + padding: getConfig$2().flowchart.padding + }); + } +}; +const addEdges$2 = async function(edges, g, diagObj) { + log$1.info("abc78 edges = ", edges); + let cnt = 0; + let linkIdCnt = {}; + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + for (const edge of edges) { + cnt++; + const linkIdBase = "L-" + edge.start + "-" + edge.end; + if (linkIdCnt[linkIdBase] === void 0) { + linkIdCnt[linkIdBase] = 0; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } else { + linkIdCnt[linkIdBase]++; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } + let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase]; + log$1.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]); + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = { style: "", labelStyle: "" }; + edgeData.minlen = edge.length || 1; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + edgeData.arrowTypeStart = "arrow_open"; + edgeData.arrowTypeEnd = "arrow_open"; + switch (edge.type) { + case "double_arrow_cross": + edgeData.arrowTypeStart = "arrow_cross"; + case "arrow_cross": + edgeData.arrowTypeEnd = "arrow_cross"; + break; + case "double_arrow_point": + edgeData.arrowTypeStart = "arrow_point"; + case "arrow_point": + edgeData.arrowTypeEnd = "arrow_point"; + break; + case "double_arrow_circle": + edgeData.arrowTypeStart = "arrow_circle"; + case "arrow_circle": + edgeData.arrowTypeEnd = "arrow_circle"; + break; + } + let style = ""; + let labelStyle = ""; + switch (edge.stroke) { + case "normal": + style = "fill:none;"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + edgeData.thickness = "normal"; + edgeData.pattern = "solid"; + break; + case "dotted": + edgeData.thickness = "normal"; + edgeData.pattern = "dotted"; + edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + edgeData.thickness = "thick"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 3.5px;fill:none;"; + break; + case "invisible": + edgeData.thickness = "invisible"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 0;fill:none;"; + break; + } + if (edge.style !== void 0) { + const styles = getStylesFromArray(edge.style); + style = styles.style; + labelStyle = styles.labelStyle; + } + edgeData.style = edgeData.style += style; + edgeData.labelStyle = edgeData.labelStyle += labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf$8.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + } + edgeData.labelType = edge.labelType; + edgeData.label = await renderKatex(edge.text.replace(common$1.lineBreakRegex, "\n"), getConfig$2()); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + edgeData.id = linkId; + edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd; + g.setEdge(edge.start, edge.end, edgeData, cnt); + } +}; +const getClasses$7 = function(text, diagObj) { + return diagObj.db.getClasses(); +}; +const draw$k = async function(text, id, _version, diagObj) { + log$1.info("Drawing flowchart"); + let dir = diagObj.db.getDirection(); + if (dir === void 0) { + dir = "TD"; + } + const { securityLevel, flowchart: conf2 } = getConfig$2(); + const nodeSpacing = conf2.nodeSpacing || 50; + const rankSpacing = conf2.rankSpacing || 50; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 0, + marginy: 0 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + log$1.info("Subgraphs - ", subGraphs); + for (let i2 = subGraphs.length - 1; i2 >= 0; i2--) { + subG = subGraphs[i2]; + log$1.info("Subgraph - ", subG); + diagObj.db.addVertex( + subG.id, + { text: subG.title, type: subG.labelType }, + "group", + void 0, + subG.classes, + subG.dir + ); + } + const vert = diagObj.db.getVertices(); + const edges = diagObj.db.getEdges(); + log$1.info("Edges", edges); + let i = 0; + for (i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + selectAll("cluster").append("text"); + for (let j = 0; j < subG.nodes.length; j++) { + log$1.info("Setting up subgraphs", subG.nodes[j], subG.id); + g.setParent(subG.nodes[j], subG.id); + } + } + await addVertices$2(vert, g, id, root, doc, diagObj); + await addEdges$2(edges, g); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render(element, g, ["point", "circle", "cross"], "flowchart", id); + utils.insertTitle(svg, "flowchartTitleText", conf2.titleTopMargin, diagObj.db.getDiagramTitle()); + setupGraphViewbox$1(g, svg, conf2.diagramPadding, conf2.useMaxWidth); + diagObj.db.indexNodes("subGraph" + i); + if (!conf2.htmlLabels) { + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } + const keys = Object.keys(vert); + keys.forEach(function(key) { + const vertex = vert[key]; + if (vertex.link) { + const node = select("#" + id + ' [id="' + key + '"]'); + if (node) { + const link = doc.createElementNS("http://www.w3.org/2000/svg", "a"); + link.setAttributeNS("http://www.w3.org/2000/svg", "class", vertex.classes.join(" ")); + link.setAttributeNS("http://www.w3.org/2000/svg", "href", vertex.link); + link.setAttributeNS("http://www.w3.org/2000/svg", "rel", "noopener"); + if (securityLevel === "sandbox") { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", "_top"); + } else if (vertex.linkTarget) { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", vertex.linkTarget); + } + const linkNode = node.insert(function() { + return link; + }, ":first-child"); + const shape = node.select(".label-container"); + if (shape) { + linkNode.append(function() { + return shape.node(); + }); + } + const label = node.select(".label"); + if (label) { + linkNode.append(function() { + return label.node(); + }); + } + } + } + }); +}; +const flowRendererV2 = { + setConf: setConf$8, + addVertices: addVertices$2, + addEdges: addEdges$2, + getClasses: getClasses$7, + draw: draw$k +}; +const fade$1 = (color, opacity) => { + const channel$1 = channel; + const r = channel$1(color, "r"); + const g = channel$1(color, "g"); + const b = channel$1(color, "b"); + return rgba$1(r, g, b, opacity); +}; +const getStyles$d = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span,p { + color: ${options.titleColor}; + } + + .label text,span,p { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + .flowchart-label text { + text-anchor: middle; + } + // .flowchart-label .text-outer-tspan { + // text-anchor: middle; + // } + // .flowchart-label .text-inner-tspan { + // text-anchor: start; + // } + + .node .katex path { + fill: #000; + stroke: #000; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + /* For html labels only */ + .labelBkg { + background-color: ${fade$1(options.edgeLabelBackground, 0.5)}; + // background-color: + } + + .cluster rect { + fill: ${options.clusterBkg}; + stroke: ${options.clusterBorder}; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span,p { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } +`; +const flowStyles$1 = getStyles$d; + +function question(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const s = (w + h) * 0.9; + const points = [ + { x: s / 2, y: 0 }, + { x: s, y: -s / 2 }, + { x: s / 2, y: -s }, + { x: 0, y: -s / 2 } + ]; + const shapeSvg = insertPolygonShape$1(parent, s, s, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function hexagon(parent, bbox, node) { + const f = 4; + const h = bbox.height; + const m = h / f; + const w = bbox.width + 2 * m; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function rect_left_inv_arrow(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -h / 2, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: -h / 2, y: -h }, + { x: 0, y: -h / 2 } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function lean_right(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function lean_left(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 2 * h / 6, y: 0 }, + { x: w + h / 6, y: 0 }, + { x: w - 2 * h / 6, y: -h }, + { x: -h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function trapezoid(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: -2 * h / 6, y: 0 }, + { x: w + 2 * h / 6, y: 0 }, + { x: w - h / 6, y: -h }, + { x: h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function inv_trapezoid(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: h / 6, y: 0 }, + { x: w - h / 6, y: 0 }, + { x: w + 2 * h / 6, y: -h }, + { x: -2 * h / 6, y: -h } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function rect_right_inv_arrow(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 0, y: 0 }, + { x: w + h / 2, y: 0 }, + { x: w, y: -h / 2 }, + { x: w + h / 2, y: -h }, + { x: 0, y: -h } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function stadium(parent, bbox, node) { + const h = bbox.height; + const w = bbox.width + h / 4; + const shapeSvg = parent.insert("rect", ":first-child").attr("rx", h / 2).attr("ry", h / 2).attr("x", -w / 2).attr("y", -h / 2).attr("width", w).attr("height", h); + node.intersect = function(point) { + return intersectRect$2(node, point); + }; + return shapeSvg; +} +function subroutine(parent, bbox, node) { + const w = bbox.width; + const h = bbox.height; + const points = [ + { x: 0, y: 0 }, + { x: w, y: 0 }, + { x: w, y: -h }, + { x: 0, y: -h }, + { x: 0, y: 0 }, + { x: -8, y: 0 }, + { x: w + 8, y: 0 }, + { x: w + 8, y: -h }, + { x: -8, y: -h }, + { x: -8, y: 0 } + ]; + const shapeSvg = insertPolygonShape$1(parent, w, h, points); + node.intersect = function(point) { + return intersectPolygon$1(node, points, point); + }; + return shapeSvg; +} +function cylinder(parent, bbox, node) { + const w = bbox.width; + const rx = w / 2; + const ry = rx / (2.5 + w / 50); + const h = bbox.height + ry; + const shape = "M 0," + ry + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 a " + rx + "," + ry + " 0,0,0 " + -w + " 0 l 0," + h + " a " + rx + "," + ry + " 0,0,0 " + w + " 0 l 0," + -h; + const shapeSvg = parent.attr("label-offset-y", ry).insert("path", ":first-child").attr("d", shape).attr("transform", "translate(" + -w / 2 + "," + -(h / 2 + ry) + ")"); + node.intersect = function(point) { + const pos = intersectRect$2(node, point); + const x = pos.x - node.x; + if (rx != 0 && (Math.abs(x) < node.width / 2 || Math.abs(x) == node.width / 2 && Math.abs(pos.y - node.y) > node.height / 2 - ry)) { + let y = ry * ry * (1 - x * x / (rx * rx)); + if (y != 0) { + y = Math.sqrt(y); + } + y = ry - y; + if (point.y - node.y > 0) { + y = -y; + } + pos.y += y; + } + return pos; + }; + return shapeSvg; +} +function addToRender(render2) { + render2.shapes().question = question; + render2.shapes().hexagon = hexagon; + render2.shapes().stadium = stadium; + render2.shapes().subroutine = subroutine; + render2.shapes().cylinder = cylinder; + render2.shapes().rect_left_inv_arrow = rect_left_inv_arrow; + render2.shapes().lean_right = lean_right; + render2.shapes().lean_left = lean_left; + render2.shapes().trapezoid = trapezoid; + render2.shapes().inv_trapezoid = inv_trapezoid; + render2.shapes().rect_right_inv_arrow = rect_right_inv_arrow; +} +function addToRenderV2(addShape) { + addShape({ question }); + addShape({ hexagon }); + addShape({ stadium }); + addShape({ subroutine }); + addShape({ cylinder }); + addShape({ rect_left_inv_arrow }); + addShape({ lean_right }); + addShape({ lean_left }); + addShape({ trapezoid }); + addShape({ inv_trapezoid }); + addShape({ rect_right_inv_arrow }); +} +function insertPolygonShape$1(parent, w, h, points) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("transform", "translate(" + -w / 2 + "," + h / 2 + ")"); +} +const flowChartShapes = { + addToRender, + addToRenderV2 +}; +const conf$7 = {}; +const setConf$7 = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf$7[key] = cnf[key]; + } +}; +const addVertices$1 = async function(vert, g, svgId, root, _doc, diagObj) { + const svg = !root ? select(`[id="${svgId}"]`) : root.select(`[id="${svgId}"]`); + const doc = !_doc ? document : _doc; + const keys = Object.keys(vert); + for (const id of keys) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + const styles = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + let vertexNode; + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + const node = { + label: await renderKatex( + vertexText.replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell:disable-line + (s) => `` + ), + getConfig$2() + ) + }; + vertexNode = addHtmlLabel$1(svg, node).node(); + vertexNode.parentNode.removeChild(vertexNode); + } else { + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", styles.labelStyle.replace("color:", "fill:")); + const rows = vertexText.split(common$1.lineBreakRegex); + for (const row of rows) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "1"); + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + vertexNode = svgLabel; + } + let radius = 0; + let _shape = ""; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + default: + _shape = "rect"; + } + log$1.warn("Adding node", vertex.id, vertex.domId); + g.setNode(diagObj.db.lookUpDomId(vertex.id), { + labelType: "svg", + labelStyle: styles.labelStyle, + shape: _shape, + label: vertexNode, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: diagObj.db.lookUpDomId(vertex.id) + }); + } +}; +const addEdges$1 = async function(edges, g, diagObj) { + let cnt = 0; + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + for (const edge of edges) { + cnt++; + const linkId = "L-" + edge.start + "-" + edge.end; + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = {}; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + let style = ""; + let labelStyle = ""; + if (edge.style !== void 0) { + const styles = getStylesFromArray(edge.style); + style = styles.style; + labelStyle = styles.labelStyle; + } else { + switch (edge.stroke) { + case "normal": + style = "fill:none"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + break; + case "dotted": + style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + style = " stroke-width: 3.5px;fill:none"; + break; + } + } + edgeData.style = style; + edgeData.labelStyle = labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf$7.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + if (evaluate(getConfig$2().flowchart.htmlLabels)) { + edgeData.labelType = "html"; + edgeData.label = `${await renderKatex( + edge.text.replace( + /fa[blrs]?:fa-[\w-]+/g, + // cspell:disable-line + (s) => `` + ), + getConfig$2() + )}`; + } else { + edgeData.labelType = "text"; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + } + } + edgeData.id = linkId; + edgeData.class = linkNameStart + " " + linkNameEnd; + edgeData.minlen = edge.length || 1; + g.setEdge(diagObj.db.lookUpDomId(edge.start), diagObj.db.lookUpDomId(edge.end), edgeData, cnt); + } +}; +const getClasses$6 = function(text, diagObj) { + log$1.info("Extracting classes"); + return diagObj.db.getClasses(); +}; +const draw$j = async function(text, id, _version, diagObj) { + log$1.info("Drawing flowchart"); + const { securityLevel, flowchart: conf2 } = getConfig$2(); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + let dir = diagObj.db.getDirection(); + if (dir === void 0) { + dir = "TD"; + } + const nodeSpacing = conf2.nodeSpacing || 50; + const rankSpacing = conf2.rankSpacing || 50; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + for (let i2 = subGraphs.length - 1; i2 >= 0; i2--) { + subG = subGraphs[i2]; + diagObj.db.addVertex(subG.id, subG.title, "group", void 0, subG.classes); + } + const vert = diagObj.db.getVertices(); + log$1.warn("Get vertices", vert); + const edges = diagObj.db.getEdges(); + let i = 0; + for (i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + selectAll("cluster").append("text"); + for (let j = 0; j < subG.nodes.length; j++) { + log$1.warn( + "Setting subgraph", + subG.nodes[j], + diagObj.db.lookUpDomId(subG.nodes[j]), + diagObj.db.lookUpDomId(subG.id) + ); + g.setParent(diagObj.db.lookUpDomId(subG.nodes[j]), diagObj.db.lookUpDomId(subG.id)); + } + } + await addVertices$1(vert, g, id, root, doc, diagObj); + await addEdges$1(edges, g, diagObj); + const render$1$1 = new render$1(); + flowChartShapes.addToRender(render$1$1); + render$1$1.arrows().none = function normal(parent, id2, edge, type) { + const marker = parent.append("marker").attr("id", id2).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 6).attr("orient", "auto"); + const path = marker.append("path").attr("d", "M 0 0 L 0 0 L 0 0 z"); + applyStyle$2(path, edge[type + "Style"]); + }; + render$1$1.arrows().normal = function normal(parent, id2) { + const marker = parent.append("marker").attr("id", id2).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerUnits", "strokeWidth").attr("markerWidth", 8).attr("markerHeight", 6).attr("orient", "auto"); + marker.append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("class", "arrowheadPath").style("stroke-width", 1).style("stroke-dasharray", "1,0"); + }; + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + render$1$1(element, g); + element.selectAll("g.node").attr("title", function() { + return diagObj.db.getTooltip(this.id); + }); + diagObj.db.indexNodes("subGraph" + i); + for (i = 0; i < subGraphs.length; i++) { + subG = subGraphs[i]; + if (subG.title !== "undefined") { + const clusterRects = doc.querySelectorAll( + "#" + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"] rect' + ); + const clusterEl = doc.querySelectorAll( + "#" + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"]' + ); + const xPos = clusterRects[0].x.baseVal.value; + const yPos = clusterRects[0].y.baseVal.value; + const _width = clusterRects[0].width.baseVal.value; + const cluster = select(clusterEl[0]); + const te = cluster.select(".label"); + te.attr("transform", `translate(${xPos + _width / 2}, ${yPos + 14})`); + te.attr("id", id + "Text"); + for (let j = 0; j < subG.classes.length; j++) { + clusterEl[0].classList.add(subG.classes[j]); + } + } + } + if (!conf2.htmlLabels) { + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } + setupGraphViewbox$1(g, svg, conf2.diagramPadding, conf2.useMaxWidth); + const keys = Object.keys(vert); + keys.forEach(function(key) { + const vertex = vert[key]; + if (vertex.link) { + const node = root.select("#" + id + ' [id="' + diagObj.db.lookUpDomId(key) + '"]'); + if (node) { + const link = doc.createElementNS("http://www.w3.org/2000/svg", "a"); + link.setAttributeNS("http://www.w3.org/2000/svg", "class", vertex.classes.join(" ")); + link.setAttributeNS("http://www.w3.org/2000/svg", "href", vertex.link); + link.setAttributeNS("http://www.w3.org/2000/svg", "rel", "noopener"); + if (securityLevel === "sandbox") { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", "_top"); + } else if (vertex.linkTarget) { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", vertex.linkTarget); + } + const linkNode = node.insert(function() { + return link; + }, ":first-child"); + const shape = node.select(".label-container"); + if (shape) { + linkNode.append(function() { + return shape.node(); + }); + } + const label = node.select(".label"); + if (label) { + linkNode.append(function() { + return label.node(); + }); + } + } + } + }); +}; +const flowRenderer = { + setConf: setConf$7, + addVertices: addVertices$1, + addEdges: addEdges$1, + getClasses: getClasses$6, + draw: draw$j +}; +const diagram$k = { + parser: parser$1$d, + db: flowDb, + renderer: flowRendererV2, + styles: flowStyles$1, + init: (cnf) => { + if (!cnf.flowchart) { + cnf.flowchart = {}; + } + cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + flowRenderer.setConf(cnf.flowchart); + flowDb.clear(); + flowDb.setGen("gen-1"); + } +}; + +var flowDiagramB222e15a = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$k +}); + +const diagram$j = { + parser: parser$1$d, + db: flowDb, + renderer: flowRendererV2, + styles: flowStyles$1, + init: (cnf) => { + if (!cnf.flowchart) { + cnf.flowchart = {}; + } + cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + setConfig({ flowchart: { arrowMarkerAbsolute: cnf.arrowMarkerAbsolute } }); + flowRendererV2.setConf(cnf.flowchart); + flowDb.clear(); + flowDb.setGen("gen-2"); + } +}; + +var flowDiagramV213329dc7 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$j +}); + +var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; + +function validate(uuid) { + return typeof uuid === 'string' && REGEX.test(uuid); +} + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ + +const byteToHex = []; + +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).slice(1)); +} + +function unsafeStringify(arr, offset = 0) { + // Note: Be careful editing this code! It's been tuned for performance + // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 + return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; +} + +function parse$2(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + + let v; + const arr = new Uint8Array(16); // Parse ########-....-....-....-............ + + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 0xff; + arr[2] = v >>> 8 & 0xff; + arr[3] = v & 0xff; // Parse ........-####-....-....-............ + + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 0xff; // Parse ........-....-####-....-............ + + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 0xff; // Parse ........-....-....-####-............ + + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 0xff; // Parse ........-....-....-....-############ + // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) + + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; + arr[11] = v / 0x100000000 & 0xff; + arr[12] = v >>> 24 & 0xff; + arr[13] = v >>> 16 & 0xff; + arr[14] = v >>> 8 & 0xff; + arr[15] = v & 0xff; + return arr; +} + +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); // UTF8 escape + + const bytes = []; + + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + + return bytes; +} + +const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +function v35(name, version, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + var _namespace; + + if (typeof value === 'string') { + value = stringToBytes(value); + } + + if (typeof namespace === 'string') { + namespace = parse$2(namespace); + } + + if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } // Compute hash of namespace and value, Per 4.3 + // Future: Use spread syntax when supported on all platforms, e.g. `bytes = + // hashfunc([...namespace, ... value])` + + + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 0x0f | version; + bytes[8] = bytes[8] & 0x3f | 0x80; + + if (buf) { + offset = offset || 0; + + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + + return buf; + } + + return unsafeStringify(bytes); + } // Function#name is not settable on some platforms (#270) + + + try { + generateUUID.name = name; // eslint-disable-next-line no-empty + } catch (err) {} // For CommonJS default export support + + + generateUUID.DNS = DNS; + generateUUID.URL = URL; + return generateUUID; +} + +// Adapted from Chris Veness' SHA1 code at +// http://www.movable-type.co.uk/scripts/sha1.html +function f(s, x, y, z) { + switch (s) { + case 0: + return x & y ^ ~x & z; + + case 1: + return x ^ y ^ z; + + case 2: + return x & y ^ x & z ^ y & z; + + case 3: + return x ^ y ^ z; + } +} + +function ROTL(x, n) { + return x << n | x >>> 32 - n; +} + +function sha1(bytes) { + const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; + const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0]; + + if (typeof bytes === 'string') { + const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape + + bytes = []; + + for (let i = 0; i < msg.length; ++i) { + bytes.push(msg.charCodeAt(i)); + } + } else if (!Array.isArray(bytes)) { + // Convert Array-like to Array + bytes = Array.prototype.slice.call(bytes); + } + + bytes.push(0x80); + const l = bytes.length / 4 + 2; + const N = Math.ceil(l / 16); + const M = new Array(N); + + for (let i = 0; i < N; ++i) { + const arr = new Uint32Array(16); + + for (let j = 0; j < 16; ++j) { + arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3]; + } + + M[i] = arr; + } + + M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32); + M[N - 1][14] = Math.floor(M[N - 1][14]); + M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff; + + for (let i = 0; i < N; ++i) { + const W = new Uint32Array(80); + + for (let t = 0; t < 16; ++t) { + W[t] = M[i][t]; + } + + for (let t = 16; t < 80; ++t) { + W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); + } + + let a = H[0]; + let b = H[1]; + let c = H[2]; + let d = H[3]; + let e = H[4]; + + for (let t = 0; t < 80; ++t) { + const s = Math.floor(t / 20); + const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0; + e = d; + d = c; + c = ROTL(b, 30) >>> 0; + b = a; + a = T; + } + + H[0] = H[0] + a >>> 0; + H[1] = H[1] + b >>> 0; + H[2] = H[2] + c >>> 0; + H[3] = H[3] + d >>> 0; + H[4] = H[4] + e >>> 0; + } + + return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff]; +} + +const v5 = v35('v5', 0x50, sha1); + +var parser$g = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 20, 22, 24, 26, 27, 28], $V1 = [1, 10], $V2 = [1, 11], $V3 = [1, 12], $V4 = [1, 13], $V5 = [1, 14], $V6 = [1, 15], $V7 = [1, 21], $V8 = [1, 22], $V9 = [1, 23], $Va = [1, 24], $Vb = [1, 25], $Vc = [6, 8, 10, 13, 15, 18, 19, 20, 22, 24, 26, 27, 28, 41, 42, 43, 44, 45], $Vd = [1, 34], $Ve = [27, 28, 46, 47], $Vf = [41, 42, 43, 44, 45], $Vg = [17, 34], $Vh = [1, 54], $Vi = [1, 53], $Vj = [17, 34, 36, 38]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "ER_DIAGRAM": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "entityName": 11, "relSpec": 12, ":": 13, "role": 14, "BLOCK_START": 15, "attributes": 16, "BLOCK_STOP": 17, "SQS": 18, "SQE": 19, "title": 20, "title_value": 21, "acc_title": 22, "acc_title_value": 23, "acc_descr": 24, "acc_descr_value": 25, "acc_descr_multiline_value": 26, "ALPHANUM": 27, "ENTITY_NAME": 28, "attribute": 29, "attributeType": 30, "attributeName": 31, "attributeKeyTypeList": 32, "attributeComment": 33, "ATTRIBUTE_WORD": 34, "attributeKeyType": 35, "COMMA": 36, "ATTRIBUTE_KEY": 37, "COMMENT": 38, "cardinality": 39, "relType": 40, "ZERO_OR_ONE": 41, "ZERO_OR_MORE": 42, "ONE_OR_MORE": 43, "ONLY_ONE": 44, "MD_PARENT": 45, "NON_IDENTIFYING": 46, "IDENTIFYING": 47, "WORD": 48, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "ER_DIAGRAM", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 13: ":", 15: "BLOCK_START", 17: "BLOCK_STOP", 18: "SQS", 19: "SQE", 20: "title", 21: "title_value", 22: "acc_title", 23: "acc_title_value", 24: "acc_descr", 25: "acc_descr_value", 26: "acc_descr_multiline_value", 27: "ALPHANUM", 28: "ENTITY_NAME", 34: "ATTRIBUTE_WORD", 36: "COMMA", 37: "ATTRIBUTE_KEY", 38: "COMMENT", 41: "ZERO_OR_ONE", 42: "ZERO_OR_MORE", 43: "ONE_OR_MORE", 44: "ONLY_ONE", 45: "MD_PARENT", 46: "NON_IDENTIFYING", 47: "IDENTIFYING", 48: "WORD" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 4], [9, 3], [9, 1], [9, 7], [9, 6], [9, 4], [9, 2], [9, 2], [9, 2], [9, 1], [11, 1], [11, 1], [16, 1], [16, 2], [29, 2], [29, 3], [29, 3], [29, 4], [30, 1], [31, 1], [32, 1], [32, 3], [35, 1], [33, 1], [12, 3], [39, 1], [39, 1], [39, 1], [39, 1], [39, 1], [40, 1], [40, 1], [14, 1], [14, 1], [14, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + break; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.addEntity($$[$0 - 4]); + yy.addEntity($$[$0 - 2]); + yy.addRelationship($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 3]); + break; + case 9: + yy.addEntity($$[$0 - 3]); + yy.addAttributes($$[$0 - 3], $$[$0 - 1]); + break; + case 10: + yy.addEntity($$[$0 - 2]); + break; + case 11: + yy.addEntity($$[$0]); + break; + case 12: + yy.addEntity($$[$0 - 6], $$[$0 - 4]); + yy.addAttributes($$[$0 - 6], $$[$0 - 1]); + break; + case 13: + yy.addEntity($$[$0 - 5], $$[$0 - 3]); + break; + case 14: + yy.addEntity($$[$0 - 3], $$[$0 - 1]); + break; + case 15: + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + case 43: + this.$ = $$[$0]; + break; + case 20: + case 41: + case 42: + this.$ = $$[$0].replace(/"/g, ""); + break; + case 21: + case 29: + this.$ = [$$[$0]]; + break; + case 22: + $$[$0].push($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 23: + this.$ = { attributeType: $$[$0 - 1], attributeName: $$[$0] }; + break; + case 24: + this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeKeyTypeList: $$[$0] }; + break; + case 25: + this.$ = { attributeType: $$[$0 - 2], attributeName: $$[$0 - 1], attributeComment: $$[$0] }; + break; + case 26: + this.$ = { attributeType: $$[$0 - 3], attributeName: $$[$0 - 2], attributeKeyTypeList: $$[$0 - 1], attributeComment: $$[$0] }; + break; + case 27: + case 28: + case 31: + this.$ = $$[$0]; + break; + case 30: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 32: + this.$ = $$[$0].replace(/"/g, ""); + break; + case 33: + this.$ = { cardA: $$[$0], relType: $$[$0 - 1], cardB: $$[$0 - 2] }; + break; + case 34: + this.$ = yy.Cardinality.ZERO_OR_ONE; + break; + case 35: + this.$ = yy.Cardinality.ZERO_OR_MORE; + break; + case 36: + this.$ = yy.Cardinality.ONE_OR_MORE; + break; + case 37: + this.$ = yy.Cardinality.ONLY_ONE; + break; + case 38: + this.$ = yy.Cardinality.MD_PARENT; + break; + case 39: + this.$ = yy.Identification.NON_IDENTIFYING; + break; + case 40: + this.$ = yy.Identification.IDENTIFYING; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 16, 11: 9, 20: $V1, 22: $V2, 24: $V3, 26: $V4, 27: $V5, 28: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 11], { 12: 17, 39: 20, 15: [1, 18], 18: [1, 19], 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }), { 21: [1, 26] }, { 23: [1, 27] }, { 25: [1, 28] }, o($V0, [2, 18]), o($Vc, [2, 19]), o($Vc, [2, 20]), o($V0, [2, 4]), { 11: 29, 27: $V5, 28: $V6 }, { 16: 30, 17: [1, 31], 29: 32, 30: 33, 34: $Vd }, { 11: 35, 27: $V5, 28: $V6 }, { 40: 36, 46: [1, 37], 47: [1, 38] }, o($Ve, [2, 34]), o($Ve, [2, 35]), o($Ve, [2, 36]), o($Ve, [2, 37]), o($Ve, [2, 38]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), { 13: [1, 39] }, { 17: [1, 40] }, o($V0, [2, 10]), { 16: 41, 17: [2, 21], 29: 32, 30: 33, 34: $Vd }, { 31: 42, 34: [1, 43] }, { 34: [2, 27] }, { 19: [1, 44] }, { 39: 45, 41: $V7, 42: $V8, 43: $V9, 44: $Va, 45: $Vb }, o($Vf, [2, 39]), o($Vf, [2, 40]), { 14: 46, 27: [1, 49], 28: [1, 48], 48: [1, 47] }, o($V0, [2, 9]), { 17: [2, 22] }, o($Vg, [2, 23], { 32: 50, 33: 51, 35: 52, 37: $Vh, 38: $Vi }), o([17, 34, 37, 38], [2, 28]), o($V0, [2, 14], { 15: [1, 55] }), o([27, 28], [2, 33]), o($V0, [2, 8]), o($V0, [2, 41]), o($V0, [2, 42]), o($V0, [2, 43]), o($Vg, [2, 24], { 33: 56, 36: [1, 57], 38: $Vi }), o($Vg, [2, 25]), o($Vj, [2, 29]), o($Vg, [2, 32]), o($Vj, [2, 31]), { 16: 58, 17: [1, 59], 29: 32, 30: 33, 34: $Vd }, o($Vg, [2, 26]), { 35: 60, 37: $Vh }, { 17: [1, 61] }, o($V0, [2, 13]), o($Vj, [2, 30]), o($V0, [2, 12])], + defaultActions: { 34: [2, 27], 41: [2, 22] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 22; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 24; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + return 10; + case 8: + break; + case 9: + return 8; + case 10: + return 28; + case 11: + return 48; + case 12: + return 4; + case 13: + this.begin("block"); + return 15; + case 14: + return 36; + case 15: + break; + case 16: + return 37; + case 17: + return 34; + case 18: + return 34; + case 19: + return 38; + case 20: + break; + case 21: + this.popState(); + return 17; + case 22: + return yy_.yytext[0]; + case 23: + return 18; + case 24: + return 19; + case 25: + return 41; + case 26: + return 43; + case 27: + return 43; + case 28: + return 43; + case 29: + return 41; + case 30: + return 41; + case 31: + return 42; + case 32: + return 42; + case 33: + return 42; + case 34: + return 42; + case 35: + return 42; + case 36: + return 43; + case 37: + return 42; + case 38: + return 43; + case 39: + return 44; + case 40: + return 44; + case 41: + return 44; + case 42: + return 44; + case 43: + return 41; + case 44: + return 42; + case 45: + return 43; + case 46: + return 45; + case 47: + return 46; + case 48: + return 47; + case 49: + return 47; + case 50: + return 46; + case 51: + return 46; + case 52: + return 46; + case 53: + return 27; + case 54: + return yy_.yytext[0]; + case 55: + return 6; + } + }, + rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:[\s]+)/i, /^(?:"[^"%\r\n\v\b\\]+")/i, /^(?:"[^"]*")/i, /^(?:erDiagram\b)/i, /^(?:\{)/i, /^(?:,)/i, /^(?:\s+)/i, /^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i, /^(?:(.*?)[~](.*?)*[~])/i, /^(?:[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]*)/i, /^(?:"[^"]*")/i, /^(?:[\n]+)/i, /^(?:\})/i, /^(?:.)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:one or zero\b)/i, /^(?:one or more\b)/i, /^(?:one or many\b)/i, /^(?:1\+)/i, /^(?:\|o\b)/i, /^(?:zero or one\b)/i, /^(?:zero or more\b)/i, /^(?:zero or many\b)/i, /^(?:0\+)/i, /^(?:\}o\b)/i, /^(?:many\(0\))/i, /^(?:many\(1\))/i, /^(?:many\b)/i, /^(?:\}\|)/i, /^(?:one\b)/i, /^(?:only one\b)/i, /^(?:1\b)/i, /^(?:\|\|)/i, /^(?:o\|)/i, /^(?:o\{)/i, /^(?:\|\{)/i, /^(?:\s*u\b)/i, /^(?:\.\.)/i, /^(?:--)/i, /^(?:to\b)/i, /^(?:optionally to\b)/i, /^(?:\.-)/i, /^(?:-\.)/i, /^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i, /^(?:.)/i, /^(?:$)/i], + conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "block": { "rules": [14, 15, 16, 17, 18, 19, 20, 21, 22], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$g.parser = parser$g; +const erParser = parser$g; +let entities = {}; +let relationships = []; +const Cardinality = { + ZERO_OR_ONE: "ZERO_OR_ONE", + ZERO_OR_MORE: "ZERO_OR_MORE", + ONE_OR_MORE: "ONE_OR_MORE", + ONLY_ONE: "ONLY_ONE", + MD_PARENT: "MD_PARENT" +}; +const Identification = { + NON_IDENTIFYING: "NON_IDENTIFYING", + IDENTIFYING: "IDENTIFYING" +}; +const addEntity = function(name, alias = void 0) { + if (entities[name] === void 0) { + entities[name] = { attributes: [], alias }; + log$1.info("Added new entity :", name); + } else if (entities[name] && !entities[name].alias && alias) { + entities[name].alias = alias; + log$1.info(`Add alias '${alias}' to entity '${name}'`); + } + return entities[name]; +}; +const getEntities = () => entities; +const addAttributes = function(entityName, attribs) { + let entity = addEntity(entityName); + let i; + for (i = attribs.length - 1; i >= 0; i--) { + entity.attributes.push(attribs[i]); + log$1.debug("Added attribute ", attribs[i].attributeName); + } +}; +const addRelationship$1 = function(entA, rolA, entB, rSpec) { + let rel = { + entityA: entA, + roleA: rolA, + entityB: entB, + relSpec: rSpec + }; + relationships.push(rel); + log$1.debug("Added new relationship :", rel); +}; +const getRelationships$1 = () => relationships; +const clear$f = function() { + entities = {}; + relationships = []; + clear$k(); +}; +const erDb = { + Cardinality, + Identification, + getConfig: () => getConfig$2().er, + addEntity, + addAttributes, + getEntities, + addRelationship: addRelationship$1, + getRelationships: getRelationships$1, + clear: clear$f, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + setDiagramTitle, + getDiagramTitle +}; +const ERMarkers = { + ONLY_ONE_START: "ONLY_ONE_START", + ONLY_ONE_END: "ONLY_ONE_END", + ZERO_OR_ONE_START: "ZERO_OR_ONE_START", + ZERO_OR_ONE_END: "ZERO_OR_ONE_END", + ONE_OR_MORE_START: "ONE_OR_MORE_START", + ONE_OR_MORE_END: "ONE_OR_MORE_END", + ZERO_OR_MORE_START: "ZERO_OR_MORE_START", + ZERO_OR_MORE_END: "ZERO_OR_MORE_END", + MD_PARENT_END: "MD_PARENT_END", + MD_PARENT_START: "MD_PARENT_START" +}; +const insertMarkers$2 = function(elem, conf2) { + let marker; + elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_START).attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", ERMarkers.MD_PARENT_END).attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18 M15,0 L15,18"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONLY_ONE_END).attr("refX", 18).attr("refY", 9).attr("markerWidth", 18).attr("markerHeight", 18).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,0 L3,18 M9,0 L9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_START).attr("refX", 0).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 21).attr("cy", 9).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M9,0 L9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_ONE_END).attr("refX", 30).attr("refY", 9).attr("markerWidth", 30).attr("markerHeight", 18).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 9).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,0 L21,18"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"); + elem.append("defs").append("marker").attr("id", ERMarkers.ONE_OR_MORE_END).attr("refX", 27).attr("refY", 18).attr("markerWidth", 45).attr("markerHeight", 36).attr("orient", "auto").append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_START).attr("refX", 18).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 48).attr("cy", 18).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M0,18 Q18,0 36,18 Q18,36 0,18"); + marker = elem.append("defs").append("marker").attr("id", ERMarkers.ZERO_OR_MORE_END).attr("refX", 39).attr("refY", 18).attr("markerWidth", 57).attr("markerHeight", 36).attr("orient", "auto"); + marker.append("circle").attr("stroke", conf2.stroke).attr("fill", "white").attr("cx", 9).attr("cy", 18).attr("r", 6); + marker.append("path").attr("stroke", conf2.stroke).attr("fill", "none").attr("d", "M21,18 Q39,0 57,18 Q39,36 21,18"); + return; +}; +const erMarkers = { + ERMarkers, + insertMarkers: insertMarkers$2 +}; +const BAD_ID_CHARS_REGEXP = /[^\dA-Za-z](\W)*/g; +let conf$6 = {}; +let entityNameIds = /* @__PURE__ */ new Map(); +const setConf$6 = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf$6[key] = cnf[key]; + } +}; +const drawAttributes = (groupNode, entityTextNode, attributes) => { + const heightPadding = conf$6.entityPadding / 3; + const widthPadding = conf$6.entityPadding / 3; + const attrFontSize = conf$6.fontSize * 0.85; + const labelBBox = entityTextNode.node().getBBox(); + const attributeNodes = []; + let hasKeyType = false; + let hasComment = false; + let maxTypeWidth = 0; + let maxNameWidth = 0; + let maxKeyWidth = 0; + let maxCommentWidth = 0; + let cumulativeHeight = labelBBox.height + heightPadding * 2; + let attrNum = 1; + attributes.forEach((item) => { + if (item.attributeKeyTypeList !== void 0 && item.attributeKeyTypeList.length > 0) { + hasKeyType = true; + } + if (item.attributeComment !== void 0) { + hasComment = true; + } + }); + attributes.forEach((item) => { + const attrPrefix = `${entityTextNode.node().id}-attr-${attrNum}`; + let nodeHeight = 0; + const attributeType = parseGenericTypes(item.attributeType); + const typeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-type`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig$2().fontFamily).style("font-size", attrFontSize + "px").text(attributeType); + const nameNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-name`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig$2().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeName); + const attributeNode = {}; + attributeNode.tn = typeNode; + attributeNode.nn = nameNode; + const typeBBox = typeNode.node().getBBox(); + const nameBBox = nameNode.node().getBBox(); + maxTypeWidth = Math.max(maxTypeWidth, typeBBox.width); + maxNameWidth = Math.max(maxNameWidth, nameBBox.width); + nodeHeight = Math.max(typeBBox.height, nameBBox.height); + if (hasKeyType) { + const keyTypeNodeText = item.attributeKeyTypeList !== void 0 ? item.attributeKeyTypeList.join(",") : ""; + const keyTypeNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-key`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig$2().fontFamily).style("font-size", attrFontSize + "px").text(keyTypeNodeText); + attributeNode.kn = keyTypeNode; + const keyTypeBBox = keyTypeNode.node().getBBox(); + maxKeyWidth = Math.max(maxKeyWidth, keyTypeBBox.width); + nodeHeight = Math.max(nodeHeight, keyTypeBBox.height); + } + if (hasComment) { + const commentNode = groupNode.append("text").classed("er entityLabel", true).attr("id", `${attrPrefix}-comment`).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "left").style("font-family", getConfig$2().fontFamily).style("font-size", attrFontSize + "px").text(item.attributeComment || ""); + attributeNode.cn = commentNode; + const commentNodeBBox = commentNode.node().getBBox(); + maxCommentWidth = Math.max(maxCommentWidth, commentNodeBBox.width); + nodeHeight = Math.max(nodeHeight, commentNodeBBox.height); + } + attributeNode.height = nodeHeight; + attributeNodes.push(attributeNode); + cumulativeHeight += nodeHeight + heightPadding * 2; + attrNum += 1; + }); + let widthPaddingFactor = 4; + if (hasKeyType) { + widthPaddingFactor += 2; + } + if (hasComment) { + widthPaddingFactor += 2; + } + const maxWidth = maxTypeWidth + maxNameWidth + maxKeyWidth + maxCommentWidth; + const bBox = { + width: Math.max( + conf$6.minEntityWidth, + Math.max( + labelBBox.width + conf$6.entityPadding * 2, + maxWidth + widthPadding * widthPaddingFactor + ) + ), + height: attributes.length > 0 ? cumulativeHeight : Math.max(conf$6.minEntityHeight, labelBBox.height + conf$6.entityPadding * 2) + }; + if (attributes.length > 0) { + const spareColumnWidth = Math.max( + 0, + (bBox.width - maxWidth - widthPadding * widthPaddingFactor) / (widthPaddingFactor / 2) + ); + entityTextNode.attr( + "transform", + "translate(" + bBox.width / 2 + "," + (heightPadding + labelBBox.height / 2) + ")" + ); + let heightOffset = labelBBox.height + heightPadding * 2; + let attribStyle = "attributeBoxOdd"; + attributeNodes.forEach((attributeNode) => { + const alignY = heightOffset + heightPadding + attributeNode.height / 2; + attributeNode.tn.attr("transform", "translate(" + widthPadding + "," + alignY + ")"); + const typeRect = groupNode.insert("rect", "#" + attributeNode.tn.node().id).classed(`er ${attribStyle}`, true).attr("x", 0).attr("y", heightOffset).attr("width", maxTypeWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + const nameXOffset = parseFloat(typeRect.attr("x")) + parseFloat(typeRect.attr("width")); + attributeNode.nn.attr( + "transform", + "translate(" + (nameXOffset + widthPadding) + "," + alignY + ")" + ); + const nameRect = groupNode.insert("rect", "#" + attributeNode.nn.node().id).classed(`er ${attribStyle}`, true).attr("x", nameXOffset).attr("y", heightOffset).attr("width", maxNameWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + let keyTypeAndCommentXOffset = parseFloat(nameRect.attr("x")) + parseFloat(nameRect.attr("width")); + if (hasKeyType) { + attributeNode.kn.attr( + "transform", + "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")" + ); + const keyTypeRect = groupNode.insert("rect", "#" + attributeNode.kn.node().id).classed(`er ${attribStyle}`, true).attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxKeyWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + keyTypeAndCommentXOffset = parseFloat(keyTypeRect.attr("x")) + parseFloat(keyTypeRect.attr("width")); + } + if (hasComment) { + attributeNode.cn.attr( + "transform", + "translate(" + (keyTypeAndCommentXOffset + widthPadding) + "," + alignY + ")" + ); + groupNode.insert("rect", "#" + attributeNode.cn.node().id).classed(`er ${attribStyle}`, "true").attr("x", keyTypeAndCommentXOffset).attr("y", heightOffset).attr("width", maxCommentWidth + widthPadding * 2 + spareColumnWidth).attr("height", attributeNode.height + heightPadding * 2); + } + heightOffset += attributeNode.height + heightPadding * 2; + attribStyle = attribStyle === "attributeBoxOdd" ? "attributeBoxEven" : "attributeBoxOdd"; + }); + } else { + bBox.height = Math.max(conf$6.minEntityHeight, cumulativeHeight); + entityTextNode.attr("transform", "translate(" + bBox.width / 2 + "," + bBox.height / 2 + ")"); + } + return bBox; +}; +const drawEntities = function(svgNode, entities2, graph) { + const keys = Object.keys(entities2); + let firstOne; + keys.forEach(function(entityName) { + const entityId = generateId$1(entityName, "entity"); + entityNameIds.set(entityName, entityId); + const groupNode = svgNode.append("g").attr("id", entityId); + firstOne = firstOne === void 0 ? entityId : firstOne; + const textId = "text-" + entityId; + const textNode = groupNode.append("text").classed("er entityLabel", true).attr("id", textId).attr("x", 0).attr("y", 0).style("dominant-baseline", "middle").style("text-anchor", "middle").style("font-family", getConfig$2().fontFamily).style("font-size", conf$6.fontSize + "px").text(entities2[entityName].alias ?? entityName); + const { width: entityWidth, height: entityHeight } = drawAttributes( + groupNode, + textNode, + entities2[entityName].attributes + ); + const rectNode = groupNode.insert("rect", "#" + textId).classed("er entityBox", true).attr("x", 0).attr("y", 0).attr("width", entityWidth).attr("height", entityHeight); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(entityId, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id: entityId + }); + }); + return firstOne; +}; +const adjustEntities$1 = function(svgNode, graph) { + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + svgNode.select("#" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )" + ); + } + }); +}; +const getEdgeName = function(rel) { + return (rel.entityA + rel.roleA + rel.entityB).replace(/\s/g, ""); +}; +const addRelationships$1 = function(relationships2, g) { + relationships2.forEach(function(r) { + g.setEdge( + entityNameIds.get(r.entityA), + entityNameIds.get(r.entityB), + { relationship: r }, + getEdgeName(r) + ); + }); + return relationships2; +}; +let relCnt$1 = 0; +const drawRelationshipFromLayout$1 = function(svg, rel, g, insert, diagObj) { + relCnt$1++; + const edge = g.edge( + entityNameIds.get(rel.entityA), + entityNameIds.get(rel.entityB), + getEdgeName(rel) + ); + const lineFunction = line$1().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = svg.insert("path", "#" + insert).classed("er relationshipLine", true).attr("d", lineFunction(edge.points)).style("stroke", conf$6.stroke).style("fill", "none"); + if (rel.relSpec.relType === diagObj.db.Identification.NON_IDENTIFYING) { + svgPath.attr("stroke-dasharray", "8,8"); + } + let url = ""; + if (conf$6.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + switch (rel.relSpec.cardA) { + case diagObj.db.Cardinality.ZERO_OR_ONE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_END + ")"); + break; + case diagObj.db.Cardinality.ZERO_OR_MORE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_END + ")"); + break; + case diagObj.db.Cardinality.ONE_OR_MORE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_END + ")"); + break; + case diagObj.db.Cardinality.ONLY_ONE: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_END + ")"); + break; + case diagObj.db.Cardinality.MD_PARENT: + svgPath.attr("marker-end", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_END + ")"); + break; + } + switch (rel.relSpec.cardB) { + case diagObj.db.Cardinality.ZERO_OR_ONE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_ONE_START + ")" + ); + break; + case diagObj.db.Cardinality.ZERO_OR_MORE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ZERO_OR_MORE_START + ")" + ); + break; + case diagObj.db.Cardinality.ONE_OR_MORE: + svgPath.attr( + "marker-start", + "url(" + url + "#" + erMarkers.ERMarkers.ONE_OR_MORE_START + ")" + ); + break; + case diagObj.db.Cardinality.ONLY_ONE: + svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.ONLY_ONE_START + ")"); + break; + case diagObj.db.Cardinality.MD_PARENT: + svgPath.attr("marker-start", "url(" + url + "#" + erMarkers.ERMarkers.MD_PARENT_START + ")"); + break; + } + const len = svgPath.node().getTotalLength(); + const labelPoint = svgPath.node().getPointAtLength(len * 0.5); + const labelId = "rel" + relCnt$1; + const labelNode = svg.append("text").classed("er relationshipLabel", true).attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).style("text-anchor", "middle").style("dominant-baseline", "middle").style("font-family", getConfig$2().fontFamily).style("font-size", conf$6.fontSize + "px").text(rel.roleA); + const labelBBox = labelNode.node().getBBox(); + svg.insert("rect", "#" + labelId).classed("er relationshipLabelBox", true).attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height); +}; +const draw$i = function(text, id, _version, diagObj) { + conf$6 = getConfig$2().er; + log$1.info("Drawing ER diagram"); + const securityLevel = getConfig$2().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id='${id}']`); + erMarkers.insertMarkers(svg, conf$6); + let g; + g = new Graph({ + multigraph: true, + directed: true, + compound: false + }).setGraph({ + rankdir: conf$6.layoutDirection, + marginx: 20, + marginy: 20, + nodesep: 100, + edgesep: 100, + ranksep: 100 + }).setDefaultEdgeLabel(function() { + return {}; + }); + const firstEntity = drawEntities(svg, diagObj.db.getEntities(), g); + const relationships2 = addRelationships$1(diagObj.db.getRelationships(), g); + layout$2(g); + adjustEntities$1(svg, g); + relationships2.forEach(function(rel) { + drawRelationshipFromLayout$1(svg, rel, g, firstEntity, diagObj); + }); + const padding = conf$6.diagramPadding; + utils.insertTitle(svg, "entityTitleText", conf$6.titleTopMargin, diagObj.db.getDiagramTitle()); + const svgBounds = svg.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(svg, height, width, conf$6.useMaxWidth); + svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); +}; +const MERMAID_ERDIAGRAM_UUID = "28e9f9db-3c8d-5aa5-9faf-44286ae5937c"; +function generateId$1(str = "", prefix = "") { + const simplifiedStr = str.replace(BAD_ID_CHARS_REGEXP, ""); + return `${strWithHyphen(prefix)}${strWithHyphen(simplifiedStr)}${v5( + str, + MERMAID_ERDIAGRAM_UUID + )}`; +} +function strWithHyphen(str = "") { + return str.length > 0 ? `${str}-` : ""; +} +const erRenderer = { + setConf: setConf$6, + draw: draw$i +}; +const getStyles$c = (options) => ` + .entityBox { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + } + + .attributeBoxOdd { + fill: ${options.attributeBackgroundColorOdd}; + stroke: ${options.nodeBorder}; + } + + .attributeBoxEven { + fill: ${options.attributeBackgroundColorEven}; + stroke: ${options.nodeBorder}; + } + + .relationshipLabelBox { + fill: ${options.tertiaryColor}; + opacity: 0.7; + background-color: ${options.tertiaryColor}; + rect { + opacity: 0.5; + } + } + + .relationshipLine { + stroke: ${options.lineColor}; + } + + .entityTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } + #MD_PARENT_START { + fill: #f5f5f5 !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; + } + #MD_PARENT_END { + fill: #f5f5f5 !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; + } + +`; +const erStyles = getStyles$c; +const diagram$i = { + parser: erParser, + db: erDb, + renderer: erRenderer, + styles: erStyles +}; + +var erDiagram09d1c15f = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$i +}); + +var parser$f = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 6], $V2 = [1, 4], $V3 = [1, 5], $V4 = [2, 5], $V5 = [1, 12], $V6 = [5, 7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40, 47], $V7 = [7, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V8 = [7, 12, 13, 19, 21, 23, 24, 26, 28, 31, 37, 40], $V9 = [7, 13, 47], $Va = [1, 42], $Vb = [1, 41], $Vc = [7, 13, 29, 32, 35, 38, 47], $Vd = [1, 55], $Ve = [1, 56], $Vf = [1, 57], $Vg = [7, 13, 32, 35, 42, 47]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "GG": 5, "document": 6, "EOF": 7, ":": 8, "DIR": 9, "options": 10, "body": 11, "OPT": 12, "NL": 13, "line": 14, "statement": 15, "commitStatement": 16, "mergeStatement": 17, "cherryPickStatement": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "section": 24, "branchStatement": 25, "CHECKOUT": 26, "ref": 27, "BRANCH": 28, "ORDER": 29, "NUM": 30, "CHERRY_PICK": 31, "COMMIT_ID": 32, "STR": 33, "PARENT_COMMIT": 34, "COMMIT_TAG": 35, "EMPTYSTR": 36, "MERGE": 37, "COMMIT_TYPE": 38, "commitType": 39, "COMMIT": 40, "commit_arg": 41, "COMMIT_MSG": 42, "NORMAL": 43, "REVERSE": 44, "HIGHLIGHT": 45, "ID": 46, ";": 47, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "GG", 7: "EOF", 8: ":", 9: "DIR", 12: "OPT", 13: "NL", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "section", 26: "CHECKOUT", 28: "BRANCH", 29: "ORDER", 30: "NUM", 31: "CHERRY_PICK", 32: "COMMIT_ID", 33: "STR", 34: "PARENT_COMMIT", 35: "COMMIT_TAG", 36: "EMPTYSTR", 37: "MERGE", 38: "COMMIT_TYPE", 40: "COMMIT", 42: "COMMIT_MSG", 43: "NORMAL", 44: "REVERSE", 45: "HIGHLIGHT", 46: "ID", 47: ";" }, + productions_: [0, [3, 2], [3, 3], [3, 4], [3, 5], [6, 0], [6, 2], [10, 2], [10, 1], [11, 0], [11, 2], [14, 2], [14, 1], [15, 1], [15, 1], [15, 1], [15, 2], [15, 2], [15, 1], [15, 1], [15, 1], [15, 2], [25, 2], [25, 4], [18, 3], [18, 5], [18, 5], [18, 7], [18, 7], [18, 5], [18, 5], [18, 5], [18, 7], [18, 7], [18, 7], [18, 7], [17, 2], [17, 4], [17, 4], [17, 4], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 6], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [17, 8], [16, 2], [16, 3], [16, 3], [16, 5], [16, 5], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 3], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 5], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 7], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [16, 9], [41, 0], [41, 1], [39, 1], [39, 1], [39, 1], [27, 1], [27, 1], [4, 1], [4, 1], [4, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 2: + return $$[$0]; + case 3: + return $$[$0 - 1]; + case 4: + yy.setDirection($$[$0 - 3]); + return $$[$0 - 1]; + case 6: + yy.setOptions($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 7: + $$[$0 - 1] += $$[$0]; + this.$ = $$[$0 - 1]; + break; + case 9: + this.$ = []; + break; + case 10: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 11: + this.$ = $$[$0 - 1]; + break; + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 21: + yy.checkout($$[$0]); + break; + case 22: + yy.branch($$[$0]); + break; + case 23: + yy.branch($$[$0 - 2], $$[$0]); + break; + case 24: + yy.cherryPick($$[$0], "", void 0); + break; + case 25: + yy.cherryPick($$[$0 - 2], "", void 0, $$[$0]); + break; + case 26: + yy.cherryPick($$[$0 - 2], "", $$[$0]); + break; + case 27: + yy.cherryPick($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 28: + yy.cherryPick($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 29: + yy.cherryPick($$[$0], "", $$[$0 - 2]); + break; + case 30: + yy.cherryPick($$[$0], "", ""); + break; + case 31: + yy.cherryPick($$[$0 - 2], "", ""); + break; + case 32: + yy.cherryPick($$[$0 - 4], "", "", $$[$0 - 2]); + break; + case 33: + yy.cherryPick($$[$0 - 4], "", "", $$[$0]); + break; + case 34: + yy.cherryPick($$[$0 - 2], "", $$[$0 - 4], $$[$0]); + break; + case 35: + yy.cherryPick($$[$0 - 2], "", "", $$[$0]); + break; + case 36: + yy.merge($$[$0], "", "", ""); + break; + case 37: + yy.merge($$[$0 - 2], $$[$0], "", ""); + break; + case 38: + yy.merge($$[$0 - 2], "", $$[$0], ""); + break; + case 39: + yy.merge($$[$0 - 2], "", "", $$[$0]); + break; + case 40: + yy.merge($$[$0 - 4], $$[$0], "", $$[$0 - 2]); + break; + case 41: + yy.merge($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 42: + yy.merge($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 43: + yy.merge($$[$0 - 4], $$[$0 - 2], $$[$0], ""); + break; + case 44: + yy.merge($$[$0 - 4], $$[$0 - 2], "", $$[$0]); + break; + case 45: + yy.merge($$[$0 - 4], $$[$0], $$[$0 - 2], ""); + break; + case 46: + yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 47: + yy.merge($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 48: + yy.merge($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 49: + yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 50: + yy.merge($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 51: + yy.merge($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 52: + yy.commit($$[$0]); + break; + case 53: + yy.commit("", "", yy.commitType.NORMAL, $$[$0]); + break; + case 54: + yy.commit("", "", $$[$0], ""); + break; + case 55: + yy.commit("", "", $$[$0], $$[$0 - 2]); + break; + case 56: + yy.commit("", "", $$[$0 - 2], $$[$0]); + break; + case 57: + yy.commit("", $$[$0], yy.commitType.NORMAL, ""); + break; + case 58: + yy.commit("", $$[$0 - 2], yy.commitType.NORMAL, $$[$0]); + break; + case 59: + yy.commit("", $$[$0], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 60: + yy.commit("", $$[$0 - 2], $$[$0], ""); + break; + case 61: + yy.commit("", $$[$0], $$[$0 - 2], ""); + break; + case 62: + yy.commit("", $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 63: + yy.commit("", $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 64: + yy.commit("", $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 65: + yy.commit("", $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 66: + yy.commit("", $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 67: + yy.commit("", $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 68: + yy.commit($$[$0], "", yy.commitType.NORMAL, ""); + break; + case 69: + yy.commit($$[$0], "", yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 70: + yy.commit($$[$0 - 2], "", yy.commitType.NORMAL, $$[$0]); + break; + case 71: + yy.commit($$[$0 - 2], "", $$[$0], ""); + break; + case 72: + yy.commit($$[$0], "", $$[$0 - 2], ""); + break; + case 73: + yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, ""); + break; + case 74: + yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, ""); + break; + case 75: + yy.commit($$[$0 - 4], "", $$[$0 - 2], $$[$0]); + break; + case 76: + yy.commit($$[$0 - 4], "", $$[$0], $$[$0 - 2]); + break; + case 77: + yy.commit($$[$0 - 2], "", $$[$0 - 4], $$[$0]); + break; + case 78: + yy.commit($$[$0], "", $$[$0 - 4], $$[$0 - 2]); + break; + case 79: + yy.commit($$[$0], "", $$[$0 - 2], $$[$0 - 4]); + break; + case 80: + yy.commit($$[$0 - 2], "", $$[$0], $$[$0 - 4]); + break; + case 81: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], ""); + break; + case 82: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], ""); + break; + case 83: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], ""); + break; + case 84: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], ""); + break; + case 85: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], ""); + break; + case 86: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], ""); + break; + case 87: + yy.commit($$[$0 - 4], $$[$0], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 88: + yy.commit($$[$0 - 4], $$[$0 - 2], yy.commitType.NORMAL, $$[$0]); + break; + case 89: + yy.commit($$[$0 - 2], $$[$0], yy.commitType.NORMAL, $$[$0 - 4]); + break; + case 90: + yy.commit($$[$0], $$[$0 - 2], yy.commitType.NORMAL, $$[$0 - 4]); + break; + case 91: + yy.commit($$[$0], $$[$0 - 4], yy.commitType.NORMAL, $$[$0 - 2]); + break; + case 92: + yy.commit($$[$0 - 2], $$[$0 - 4], yy.commitType.NORMAL, $$[$0]); + break; + case 93: + yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0 - 2], $$[$0]); + break; + case 94: + yy.commit($$[$0 - 6], $$[$0 - 4], $$[$0], $$[$0 - 2]); + break; + case 95: + yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 96: + yy.commit($$[$0 - 6], $$[$0], $$[$0 - 4], $$[$0 - 2]); + break; + case 97: + yy.commit($$[$0 - 6], $$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 98: + yy.commit($$[$0 - 6], $$[$0], $$[$0 - 2], $$[$0 - 4]); + break; + case 99: + yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0 - 2], $$[$0]); + break; + case 100: + yy.commit($$[$0 - 4], $$[$0 - 6], $$[$0], $$[$0 - 2]); + break; + case 101: + yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0 - 4], $$[$0]); + break; + case 102: + yy.commit($$[$0], $$[$0 - 6], $$[$0 - 4], $$[$0 - 2]); + break; + case 103: + yy.commit($$[$0 - 2], $$[$0 - 6], $$[$0], $$[$0 - 4]); + break; + case 104: + yy.commit($$[$0], $$[$0 - 6], $$[$0 - 2], $$[$0 - 4]); + break; + case 105: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 2], $$[$0 - 6]); + break; + case 106: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0], $$[$0 - 6]); + break; + case 107: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 4], $$[$0 - 6]); + break; + case 108: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 4], $$[$0 - 6]); + break; + case 109: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0], $$[$0 - 6]); + break; + case 110: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 2], $$[$0 - 6]); + break; + case 111: + yy.commit($$[$0 - 2], $$[$0 - 4], $$[$0 - 6], $$[$0]); + break; + case 112: + yy.commit($$[$0], $$[$0 - 4], $$[$0 - 6], $$[$0 - 2]); + break; + case 113: + yy.commit($$[$0 - 2], $$[$0], $$[$0 - 6], $$[$0 - 4]); + break; + case 114: + yy.commit($$[$0], $$[$0 - 2], $$[$0 - 6], $$[$0 - 4]); + break; + case 115: + yy.commit($$[$0 - 4], $$[$0 - 2], $$[$0 - 6], $$[$0]); + break; + case 116: + yy.commit($$[$0 - 4], $$[$0], $$[$0 - 6], $$[$0 - 2]); + break; + case 117: + this.$ = ""; + break; + case 118: + this.$ = $$[$0]; + break; + case 119: + this.$ = yy.commitType.NORMAL; + break; + case 120: + this.$ = yy.commitType.REVERSE; + break; + case 121: + this.$ = yy.commitType.HIGHLIGHT; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 7: $V1, 13: $V2, 47: $V3 }, { 6: 8, 7: $V4, 8: [1, 9], 9: [1, 10], 10: 11, 13: $V5 }, o($V6, [2, 124]), o($V6, [2, 125]), o($V6, [2, 126]), { 1: [2, 1] }, { 7: [1, 13] }, { 6: 14, 7: $V4, 10: 11, 13: $V5 }, { 8: [1, 15] }, o($V7, [2, 9], { 11: 16, 12: [1, 17] }), o($V8, [2, 8]), { 1: [2, 2] }, { 7: [1, 18] }, { 6: 19, 7: $V4, 10: 11, 13: $V5 }, { 7: [2, 6], 13: [1, 22], 14: 20, 15: 21, 16: 23, 17: 24, 18: 25, 19: [1, 26], 21: [1, 27], 23: [1, 28], 24: [1, 29], 25: 30, 26: [1, 31], 28: [1, 35], 31: [1, 34], 37: [1, 33], 40: [1, 32] }, o($V8, [2, 7]), { 1: [2, 3] }, { 7: [1, 36] }, o($V7, [2, 10]), { 4: 37, 7: $V1, 13: $V2, 47: $V3 }, o($V7, [2, 12]), o($V9, [2, 13]), o($V9, [2, 14]), o($V9, [2, 15]), { 20: [1, 38] }, { 22: [1, 39] }, o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), { 27: 40, 33: $Va, 46: $Vb }, o($V9, [2, 117], { 41: 43, 32: [1, 46], 33: [1, 48], 35: [1, 44], 38: [1, 45], 42: [1, 47] }), { 27: 49, 33: $Va, 46: $Vb }, { 32: [1, 50], 35: [1, 51] }, { 27: 52, 33: $Va, 46: $Vb }, { 1: [2, 4] }, o($V7, [2, 11]), o($V9, [2, 16]), o($V9, [2, 17]), o($V9, [2, 21]), o($Vc, [2, 122]), o($Vc, [2, 123]), o($V9, [2, 52]), { 33: [1, 53] }, { 39: 54, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 58] }, { 33: [1, 59] }, o($V9, [2, 118]), o($V9, [2, 36], { 32: [1, 60], 35: [1, 62], 38: [1, 61] }), { 33: [1, 63] }, { 33: [1, 64], 36: [1, 65] }, o($V9, [2, 22], { 29: [1, 66] }), o($V9, [2, 53], { 32: [1, 68], 38: [1, 67], 42: [1, 69] }), o($V9, [2, 54], { 32: [1, 71], 35: [1, 70], 42: [1, 72] }), o($Vg, [2, 119]), o($Vg, [2, 120]), o($Vg, [2, 121]), o($V9, [2, 57], { 35: [1, 73], 38: [1, 74], 42: [1, 75] }), o($V9, [2, 68], { 32: [1, 78], 35: [1, 76], 38: [1, 77] }), { 33: [1, 79] }, { 39: 80, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 81] }, o($V9, [2, 24], { 34: [1, 82], 35: [1, 83] }), { 32: [1, 84] }, { 32: [1, 85] }, { 30: [1, 86] }, { 39: 87, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 88] }, { 33: [1, 89] }, { 33: [1, 90] }, { 33: [1, 91] }, { 33: [1, 92] }, { 33: [1, 93] }, { 39: 94, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 95] }, { 33: [1, 96] }, { 39: 97, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 98] }, o($V9, [2, 37], { 35: [1, 100], 38: [1, 99] }), o($V9, [2, 38], { 32: [1, 102], 35: [1, 101] }), o($V9, [2, 39], { 32: [1, 103], 38: [1, 104] }), { 33: [1, 105] }, { 33: [1, 106], 36: [1, 107] }, { 33: [1, 108] }, { 33: [1, 109] }, o($V9, [2, 23]), o($V9, [2, 55], { 32: [1, 110], 42: [1, 111] }), o($V9, [2, 59], { 38: [1, 112], 42: [1, 113] }), o($V9, [2, 69], { 32: [1, 115], 38: [1, 114] }), o($V9, [2, 56], { 32: [1, 116], 42: [1, 117] }), o($V9, [2, 61], { 35: [1, 118], 42: [1, 119] }), o($V9, [2, 72], { 32: [1, 121], 35: [1, 120] }), o($V9, [2, 58], { 38: [1, 122], 42: [1, 123] }), o($V9, [2, 60], { 35: [1, 124], 42: [1, 125] }), o($V9, [2, 73], { 35: [1, 127], 38: [1, 126] }), o($V9, [2, 70], { 32: [1, 129], 38: [1, 128] }), o($V9, [2, 71], { 32: [1, 131], 35: [1, 130] }), o($V9, [2, 74], { 35: [1, 133], 38: [1, 132] }), { 39: 134, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 135] }, { 33: [1, 136] }, { 33: [1, 137] }, { 33: [1, 138] }, { 39: 139, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 25], { 35: [1, 140] }), o($V9, [2, 26], { 34: [1, 141] }), o($V9, [2, 31], { 34: [1, 142] }), o($V9, [2, 29], { 34: [1, 143] }), o($V9, [2, 30], { 34: [1, 144] }), { 33: [1, 145] }, { 33: [1, 146] }, { 39: 147, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 148] }, { 39: 149, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 150] }, { 33: [1, 151] }, { 33: [1, 152] }, { 33: [1, 153] }, { 33: [1, 154] }, { 33: [1, 155] }, { 33: [1, 156] }, { 39: 157, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 158] }, { 33: [1, 159] }, { 33: [1, 160] }, { 39: 161, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 162] }, { 39: 163, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 164] }, { 33: [1, 165] }, { 33: [1, 166] }, { 39: 167, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 168] }, o($V9, [2, 43], { 35: [1, 169] }), o($V9, [2, 44], { 38: [1, 170] }), o($V9, [2, 42], { 32: [1, 171] }), o($V9, [2, 45], { 35: [1, 172] }), o($V9, [2, 40], { 38: [1, 173] }), o($V9, [2, 41], { 32: [1, 174] }), { 33: [1, 175], 36: [1, 176] }, { 33: [1, 177] }, { 33: [1, 178] }, { 33: [1, 179] }, { 33: [1, 180] }, o($V9, [2, 66], { 42: [1, 181] }), o($V9, [2, 79], { 32: [1, 182] }), o($V9, [2, 67], { 42: [1, 183] }), o($V9, [2, 90], { 38: [1, 184] }), o($V9, [2, 80], { 32: [1, 185] }), o($V9, [2, 89], { 38: [1, 186] }), o($V9, [2, 65], { 42: [1, 187] }), o($V9, [2, 78], { 32: [1, 188] }), o($V9, [2, 64], { 42: [1, 189] }), o($V9, [2, 84], { 35: [1, 190] }), o($V9, [2, 77], { 32: [1, 191] }), o($V9, [2, 83], { 35: [1, 192] }), o($V9, [2, 63], { 42: [1, 193] }), o($V9, [2, 91], { 38: [1, 194] }), o($V9, [2, 62], { 42: [1, 195] }), o($V9, [2, 85], { 35: [1, 196] }), o($V9, [2, 86], { 35: [1, 197] }), o($V9, [2, 92], { 38: [1, 198] }), o($V9, [2, 76], { 32: [1, 199] }), o($V9, [2, 87], { 38: [1, 200] }), o($V9, [2, 75], { 32: [1, 201] }), o($V9, [2, 81], { 35: [1, 202] }), o($V9, [2, 82], { 35: [1, 203] }), o($V9, [2, 88], { 38: [1, 204] }), { 33: [1, 205] }, { 39: 206, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 207] }, { 33: [1, 208] }, { 39: 209, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 210] }, o($V9, [2, 27]), o($V9, [2, 32]), o($V9, [2, 28]), o($V9, [2, 33]), o($V9, [2, 34]), o($V9, [2, 35]), { 33: [1, 211] }, { 33: [1, 212] }, { 33: [1, 213] }, { 39: 214, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 215] }, { 39: 216, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 217] }, { 33: [1, 218] }, { 33: [1, 219] }, { 33: [1, 220] }, { 33: [1, 221] }, { 33: [1, 222] }, { 33: [1, 223] }, { 39: 224, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 225] }, { 33: [1, 226] }, { 33: [1, 227] }, { 39: 228, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 229] }, { 39: 230, 43: $Vd, 44: $Ve, 45: $Vf }, { 33: [1, 231] }, { 33: [1, 232] }, { 33: [1, 233] }, { 39: 234, 43: $Vd, 44: $Ve, 45: $Vf }, o($V9, [2, 46]), o($V9, [2, 48]), o($V9, [2, 47]), o($V9, [2, 49]), o($V9, [2, 51]), o($V9, [2, 50]), o($V9, [2, 107]), o($V9, [2, 108]), o($V9, [2, 105]), o($V9, [2, 106]), o($V9, [2, 110]), o($V9, [2, 109]), o($V9, [2, 114]), o($V9, [2, 113]), o($V9, [2, 112]), o($V9, [2, 111]), o($V9, [2, 116]), o($V9, [2, 115]), o($V9, [2, 104]), o($V9, [2, 103]), o($V9, [2, 102]), o($V9, [2, 101]), o($V9, [2, 99]), o($V9, [2, 100]), o($V9, [2, 98]), o($V9, [2, 97]), o($V9, [2, 96]), o($V9, [2, 95]), o($V9, [2, 93]), o($V9, [2, 94])], + defaultActions: { 7: [2, 1], 13: [2, 2], 18: [2, 3], 36: [2, 4] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("acc_title"); + return 19; + case 1: + this.popState(); + return "acc_title_value"; + case 2: + this.begin("acc_descr"); + return 21; + case 3: + this.popState(); + return "acc_descr_value"; + case 4: + this.begin("acc_descr_multiline"); + break; + case 5: + this.popState(); + break; + case 6: + return "acc_descr_multiline_value"; + case 7: + return 13; + case 8: + break; + case 9: + break; + case 10: + return 5; + case 11: + return 40; + case 12: + return 32; + case 13: + return 38; + case 14: + return 42; + case 15: + return 43; + case 16: + return 44; + case 17: + return 45; + case 18: + return 35; + case 19: + return 28; + case 20: + return 29; + case 21: + return 37; + case 22: + return 31; + case 23: + return 34; + case 24: + return 26; + case 25: + return 9; + case 26: + return 9; + case 27: + return 8; + case 28: + return "CARET"; + case 29: + this.begin("options"); + break; + case 30: + this.popState(); + break; + case 31: + return 12; + case 32: + return 36; + case 33: + this.begin("string"); + break; + case 34: + this.popState(); + break; + case 35: + return 33; + case 36: + return 30; + case 37: + return 46; + case 38: + return 7; + } + }, + rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:gitGraph\b)/i, /^(?:commit(?=\s|$))/i, /^(?:id:)/i, /^(?:type:)/i, /^(?:msg:)/i, /^(?:NORMAL\b)/i, /^(?:REVERSE\b)/i, /^(?:HIGHLIGHT\b)/i, /^(?:tag:)/i, /^(?:branch(?=\s|$))/i, /^(?:order:)/i, /^(?:merge(?=\s|$))/i, /^(?:cherry-pick(?=\s|$))/i, /^(?:parent:)/i, /^(?:checkout(?=\s|$))/i, /^(?:LR\b)/i, /^(?:TB\b)/i, /^(?::)/i, /^(?:\^)/i, /^(?:options\r?\n)/i, /^(?:[ \r\n\t]+end\b)/i, /^(?:[\s\S]+(?=[ \r\n\t]+end))/i, /^(?:["]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[0-9]+(?=\s|$))/i, /^(?:\w([-\./\w]*[-\w])?)/i, /^(?:$)/i, /^(?:\s+)/i], + conditions: { "acc_descr_multiline": { "rules": [5, 6], "inclusive": false }, "acc_descr": { "rules": [3], "inclusive": false }, "acc_title": { "rules": [1], "inclusive": false }, "options": { "rules": [30, 31], "inclusive": false }, "string": { "rules": [34, 35], "inclusive": false }, "INITIAL": { "rules": [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33, 36, 37, 38, 39], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$f.parser = parser$f; +const gitGraphParser = parser$f; +let mainBranchName = getConfig$2().gitGraph.mainBranchName; +let mainBranchOrder = getConfig$2().gitGraph.mainBranchOrder; +let commits = {}; +let head = null; +let branchesConfig = {}; +branchesConfig[mainBranchName] = { name: mainBranchName, order: mainBranchOrder }; +let branches = {}; +branches[mainBranchName] = head; +let curBranch = mainBranchName; +let direction$2 = "LR"; +let seq = 0; +function getId() { + return random({ length: 7 }); +} +function uniqBy(list, fn) { + const recordMap = /* @__PURE__ */ Object.create(null); + return list.reduce((out, item) => { + const key = fn(item); + if (!recordMap[key]) { + recordMap[key] = true; + out.push(item); + } + return out; + }, []); +} +const setDirection$2 = function(dir2) { + direction$2 = dir2; +}; +let options = {}; +const setOptions$4 = function(rawOptString) { + log$1.debug("options str", rawOptString); + rawOptString = rawOptString && rawOptString.trim(); + rawOptString = rawOptString || "{}"; + try { + options = JSON.parse(rawOptString); + } catch (e) { + log$1.error("error while parsing gitGraph options", e.message); + } +}; +const getOptions = function() { + return options; +}; +const commit = function(msg, id, type, tag) { + log$1.debug("Entering commit:", msg, id, type, tag); + id = common$1.sanitizeText(id, getConfig$2()); + msg = common$1.sanitizeText(msg, getConfig$2()); + tag = common$1.sanitizeText(tag, getConfig$2()); + const commit2 = { + id: id ? id : seq + "-" + getId(), + message: msg, + seq: seq++, + type: type ? type : commitType$1.NORMAL, + tag: tag ? tag : "", + parents: head == null ? [] : [head.id], + branch: curBranch + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug("in pushCommit " + commit2.id); +}; +const branch = function(name, order) { + name = common$1.sanitizeText(name, getConfig$2()); + if (branches[name] === void 0) { + branches[name] = head != null ? head.id : null; + branchesConfig[name] = { name, order: order ? parseInt(order, 10) : null }; + checkout(name); + log$1.debug("in createBranch"); + } else { + let error = new Error( + 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ' + name + '")' + ); + error.hash = { + text: "branch " + name, + token: "branch " + name, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"checkout ' + name + '"'] + }; + throw error; + } +}; +const merge = function(otherBranch, custom_id, override_type, custom_tag) { + otherBranch = common$1.sanitizeText(otherBranch, getConfig$2()); + custom_id = common$1.sanitizeText(custom_id, getConfig$2()); + const currentCommit = commits[branches[curBranch]]; + const otherCommit = commits[branches[otherBranch]]; + if (curBranch === otherBranch) { + let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch abc"] + }; + throw error; + } else if (currentCommit === void 0 || !currentCommit) { + let error = new Error( + 'Incorrect usage of "merge". Current branch (' + curBranch + ")has no commits" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["commit"] + }; + throw error; + } else if (branches[otherBranch] === void 0) { + let error = new Error( + 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") does not exist" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch " + otherBranch] + }; + throw error; + } else if (otherCommit === void 0 || !otherCommit) { + let error = new Error( + 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") has no commits" + ); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"commit"'] + }; + throw error; + } else if (currentCommit === otherCommit) { + let error = new Error('Incorrect usage of "merge". Both branches have same head'); + error.hash = { + text: "merge " + otherBranch, + token: "merge " + otherBranch, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["branch abc"] + }; + throw error; + } else if (custom_id && commits[custom_id] !== void 0) { + let error = new Error( + 'Incorrect usage of "merge". Commit with id:' + custom_id + " already exists, use different custom Id" + ); + error.hash = { + text: "merge " + otherBranch + custom_id + override_type + custom_tag, + token: "merge " + otherBranch + custom_id + override_type + custom_tag, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: [ + "merge " + otherBranch + " " + custom_id + "_UNIQUE " + override_type + " " + custom_tag + ] + }; + throw error; + } + const commit2 = { + id: custom_id ? custom_id : seq + "-" + getId(), + message: "merged branch " + otherBranch + " into " + curBranch, + seq: seq++, + parents: [head == null ? null : head.id, branches[otherBranch]], + branch: curBranch, + type: commitType$1.MERGE, + customType: override_type, + customId: custom_id ? true : false, + tag: custom_tag ? custom_tag : "" + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug(branches); + log$1.debug("in mergeBranch"); +}; +const cherryPick = function(sourceId, targetId, tag, parentCommitId) { + log$1.debug("Entering cherryPick:", sourceId, targetId, tag); + sourceId = common$1.sanitizeText(sourceId, getConfig$2()); + targetId = common$1.sanitizeText(targetId, getConfig$2()); + tag = common$1.sanitizeText(tag, getConfig$2()); + parentCommitId = common$1.sanitizeText(parentCommitId, getConfig$2()); + if (!sourceId || commits[sourceId] === void 0) { + let error = new Error( + 'Incorrect usage of "cherryPick". Source commit id should exist and provided' + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + let sourceCommit = commits[sourceId]; + let sourceCommitBranch = sourceCommit.branch; + if (parentCommitId && !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) { + let error = new Error( + "Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit." + ); + throw error; + } + if (sourceCommit.type === commitType$1.MERGE && !parentCommitId) { + let error = new Error( + "Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified." + ); + throw error; + } + if (!targetId || commits[targetId] === void 0) { + if (sourceCommitBranch === curBranch) { + let error = new Error( + 'Incorrect usage of "cherryPick". Source commit is already on current branch' + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + const currentCommit = commits[branches[curBranch]]; + if (currentCommit === void 0 || !currentCommit) { + let error = new Error( + 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ")has no commits" + ); + error.hash = { + text: "cherryPick " + sourceId + " " + targetId, + token: "cherryPick " + sourceId + " " + targetId, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["cherry-pick abc"] + }; + throw error; + } + const commit2 = { + id: seq + "-" + getId(), + message: "cherry-picked " + sourceCommit + " into " + curBranch, + seq: seq++, + parents: [head == null ? null : head.id, sourceCommit.id], + branch: curBranch, + type: commitType$1.CHERRY_PICK, + tag: tag ?? `cherry-pick:${sourceCommit.id}${sourceCommit.type === commitType$1.MERGE ? `|parent:${parentCommitId}` : ""}` + }; + head = commit2; + commits[commit2.id] = commit2; + branches[curBranch] = commit2.id; + log$1.debug(branches); + log$1.debug("in cherryPick"); + } +}; +const checkout = function(branch2) { + branch2 = common$1.sanitizeText(branch2, getConfig$2()); + if (branches[branch2] === void 0) { + let error = new Error( + 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch2 + '")' + ); + error.hash = { + text: "checkout " + branch2, + token: "checkout " + branch2, + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['"branch ' + branch2 + '"'] + }; + throw error; + } else { + curBranch = branch2; + const id = branches[curBranch]; + head = commits[id]; + } +}; +function upsert(arr, key, newVal) { + const index = arr.indexOf(key); + if (index === -1) { + arr.push(newVal); + } else { + arr.splice(index, 1, newVal); + } +} +function prettyPrintCommitHistory(commitArr) { + const commit2 = commitArr.reduce((out, commit3) => { + if (out.seq > commit3.seq) { + return out; + } + return commit3; + }, commitArr[0]); + let line = ""; + commitArr.forEach(function(c) { + if (c === commit2) { + line += " *"; + } else { + line += " |"; + } + }); + const label = [line, commit2.id, commit2.seq]; + for (let branch2 in branches) { + if (branches[branch2] === commit2.id) { + label.push(branch2); + } + } + log$1.debug(label.join(" ")); + if (commit2.parents && commit2.parents.length == 2) { + const newCommit = commits[commit2.parents[0]]; + upsert(commitArr, commit2, newCommit); + commitArr.push(commits[commit2.parents[1]]); + } else if (commit2.parents.length == 0) { + return; + } else { + const nextCommit = commits[commit2.parents]; + upsert(commitArr, commit2, nextCommit); + } + commitArr = uniqBy(commitArr, (c) => c.id); + prettyPrintCommitHistory(commitArr); +} +const prettyPrint = function() { + log$1.debug(commits); + const node = getCommitsArray()[0]; + prettyPrintCommitHistory([node]); +}; +const clear$1$1 = function() { + commits = {}; + head = null; + let mainBranch = getConfig$2().gitGraph.mainBranchName; + let mainBranchOrder2 = getConfig$2().gitGraph.mainBranchOrder; + branches = {}; + branches[mainBranch] = null; + branchesConfig = {}; + branchesConfig[mainBranch] = { name: mainBranch, order: mainBranchOrder2 }; + curBranch = mainBranch; + seq = 0; + clear$k(); +}; +const getBranchesAsObjArray = function() { + const branchesArray = Object.values(branchesConfig).map((branchConfig, i) => { + if (branchConfig.order !== null) { + return branchConfig; + } + return { + ...branchConfig, + order: parseFloat(`0.${i}`, 10) + }; + }).sort((a, b) => a.order - b.order).map(({ name }) => ({ name })); + return branchesArray; +}; +const getBranches = function() { + return branches; +}; +const getCommits = function() { + return commits; +}; +const getCommitsArray = function() { + const commitArr = Object.keys(commits).map(function(key) { + return commits[key]; + }); + commitArr.forEach(function(o) { + log$1.debug(o.id); + }); + commitArr.sort((a, b) => a.seq - b.seq); + return commitArr; +}; +const getCurrentBranch = function() { + return curBranch; +}; +const getDirection$2 = function() { + return direction$2; +}; +const getHead = function() { + return head; +}; +const commitType$1 = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4 +}; +const gitGraphDb = { + getConfig: () => getConfig$2().gitGraph, + setDirection: setDirection$2, + setOptions: setOptions$4, + getOptions, + commit, + branch, + merge, + cherryPick, + checkout, + //reset, + prettyPrint, + clear: clear$1$1, + getBranchesAsObjArray, + getBranches, + getCommits, + getCommitsArray, + getCurrentBranch, + getDirection: getDirection$2, + getHead, + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + setDiagramTitle, + getDiagramTitle, + commitType: commitType$1 +}; +let allCommitsDict = {}; +const commitType = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4 +}; +const THEME_COLOR_LIMIT = 8; +let branchPos = {}; +let commitPos = {}; +let lanes = []; +let maxPos = 0; +let dir = "LR"; +const clear$e = () => { + branchPos = {}; + commitPos = {}; + allCommitsDict = {}; + maxPos = 0; + lanes = []; + dir = "LR"; +}; +const drawText$3 = (txt) => { + const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text"); + let rows = []; + if (typeof txt === "string") { + rows = txt.split(/\\n|\n|/gi); + } else if (Array.isArray(txt)) { + rows = txt; + } else { + rows = []; + } + for (const row of rows) { + const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "0"); + tspan.setAttribute("class", "row"); + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + } + return svgLabel; +}; +const findClosestParent = (parents) => { + let closestParent = ""; + let maxPosition = 0; + parents.forEach((parent) => { + const parentPosition = dir === "TB" ? commitPos[parent].y : commitPos[parent].x; + if (parentPosition >= maxPosition) { + closestParent = parent; + maxPosition = parentPosition; + } + }); + return closestParent || void 0; +}; +const drawCommits = (svg, commits2, modifyGraph) => { + const gitGraphConfig = getConfig$2().gitGraph; + const gBullets = svg.append("g").attr("class", "commit-bullets"); + const gLabels = svg.append("g").attr("class", "commit-labels"); + let pos = 0; + if (dir === "TB") { + pos = 30; + } + const keys = Object.keys(commits2); + const sortedKeys = keys.sort((a, b) => { + return commits2[a].seq - commits2[b].seq; + }); + const isParallelCommits = gitGraphConfig.parallelCommits; + const layoutOffset = 10; + const commitStep = 40; + sortedKeys.forEach((key) => { + const commit2 = commits2[key]; + if (isParallelCommits) { + if (commit2.parents.length) { + const closestParent = findClosestParent(commit2.parents); + pos = dir === "TB" ? commitPos[closestParent].y + commitStep : commitPos[closestParent].x + commitStep; + } else { + pos = 0; + if (dir === "TB") { + pos = 30; + } + } + } + const posWithOffset = pos + layoutOffset; + const y = dir === "TB" ? posWithOffset : branchPos[commit2.branch].pos; + const x = dir === "TB" ? branchPos[commit2.branch].pos : posWithOffset; + if (modifyGraph) { + let typeClass; + let commitSymbolType = commit2.customType !== void 0 && commit2.customType !== "" ? commit2.customType : commit2.type; + switch (commitSymbolType) { + case commitType.NORMAL: + typeClass = "commit-normal"; + break; + case commitType.REVERSE: + typeClass = "commit-reverse"; + break; + case commitType.HIGHLIGHT: + typeClass = "commit-highlight"; + break; + case commitType.MERGE: + typeClass = "commit-merge"; + break; + case commitType.CHERRY_PICK: + typeClass = "commit-cherry-pick"; + break; + default: + typeClass = "commit-normal"; + } + if (commitSymbolType === commitType.HIGHLIGHT) { + const circle = gBullets.append("rect"); + circle.attr("x", x - 10); + circle.attr("y", y - 10); + circle.attr("height", 20); + circle.attr("width", 20); + circle.attr( + "class", + `commit ${commit2.id} commit-highlight${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-outer` + ); + gBullets.append("rect").attr("x", x - 6).attr("y", y - 6).attr("height", 12).attr("width", 12).attr( + "class", + `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT} ${typeClass}-inner` + ); + } else if (commitSymbolType === commitType.CHERRY_PICK) { + gBullets.append("circle").attr("cx", x).attr("cy", y).attr("r", 10).attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("circle").attr("cx", x - 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("circle").attr("cx", x + 3).attr("cy", y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("line").attr("x1", x + 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + gBullets.append("line").attr("x1", x - 3).attr("y1", y + 1).attr("x2", x).attr("y2", y - 5).attr("stroke", "#fff").attr("class", `commit ${commit2.id} ${typeClass}`); + } else { + const circle = gBullets.append("circle"); + circle.attr("cx", x); + circle.attr("cy", y); + circle.attr("r", commit2.type === commitType.MERGE ? 9 : 10); + circle.attr( + "class", + `commit ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + if (commitSymbolType === commitType.MERGE) { + const circle2 = gBullets.append("circle"); + circle2.attr("cx", x); + circle2.attr("cy", y); + circle2.attr("r", 6); + circle2.attr( + "class", + `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + } + if (commitSymbolType === commitType.REVERSE) { + const cross = gBullets.append("path"); + cross.attr("d", `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`).attr( + "class", + `commit ${typeClass} ${commit2.id} commit${branchPos[commit2.branch].index % THEME_COLOR_LIMIT}` + ); + } + } + } + if (dir === "TB") { + commitPos[commit2.id] = { x, y: posWithOffset }; + } else { + commitPos[commit2.id] = { x: posWithOffset, y }; + } + if (modifyGraph) { + const px = 4; + const py = 2; + if (commit2.type !== commitType.CHERRY_PICK && (commit2.customId && commit2.type === commitType.MERGE || commit2.type !== commitType.MERGE) && gitGraphConfig.showCommitLabel) { + const wrapper = gLabels.append("g"); + const labelBkg = wrapper.insert("rect").attr("class", "commit-label-bkg"); + const text = wrapper.append("text").attr("x", pos).attr("y", y + 25).attr("class", "commit-label").text(commit2.id); + let bbox = text.node().getBBox(); + labelBkg.attr("x", posWithOffset - bbox.width / 2 - py).attr("y", y + 13.5).attr("width", bbox.width + 2 * py).attr("height", bbox.height + 2 * py); + if (dir === "TB") { + labelBkg.attr("x", x - (bbox.width + 4 * px + 5)).attr("y", y - 12); + text.attr("x", x - (bbox.width + 4 * px)).attr("y", y + bbox.height - 12); + } + if (dir !== "TB") { + text.attr("x", posWithOffset - bbox.width / 2); + } + if (gitGraphConfig.rotateCommitLabel) { + if (dir === "TB") { + text.attr("transform", "rotate(-45, " + x + ", " + y + ")"); + labelBkg.attr("transform", "rotate(-45, " + x + ", " + y + ")"); + } else { + let r_x = -7.5 - (bbox.width + 10) / 25 * 9.5; + let r_y = 10 + bbox.width / 25 * 8.5; + wrapper.attr( + "transform", + "translate(" + r_x + ", " + r_y + ") rotate(-45, " + pos + ", " + y + ")" + ); + } + } + } + if (commit2.tag) { + const rect = gLabels.insert("polygon"); + const hole = gLabels.append("circle"); + const tag = gLabels.append("text").attr("y", y - 16).attr("class", "tag-label").text(commit2.tag); + let tagBbox = tag.node().getBBox(); + tag.attr("x", posWithOffset - tagBbox.width / 2); + const h2 = tagBbox.height / 2; + const ly = y - 19.2; + rect.attr("class", "tag-label-bkg").attr( + "points", + ` + ${pos - tagBbox.width / 2 - px / 2},${ly + py} + ${pos - tagBbox.width / 2 - px / 2},${ly - py} + ${posWithOffset - tagBbox.width / 2 - px},${ly - h2 - py} + ${posWithOffset + tagBbox.width / 2 + px},${ly - h2 - py} + ${posWithOffset + tagBbox.width / 2 + px},${ly + h2 + py} + ${posWithOffset - tagBbox.width / 2 - px},${ly + h2 + py}` + ); + hole.attr("cx", pos - tagBbox.width / 2 + px / 2).attr("cy", ly).attr("r", 1.5).attr("class", "tag-hole"); + if (dir === "TB") { + rect.attr("class", "tag-label-bkg").attr( + "points", + ` + ${x},${pos + py} + ${x},${pos - py} + ${x + layoutOffset},${pos - h2 - py} + ${x + layoutOffset + tagBbox.width + px},${pos - h2 - py} + ${x + layoutOffset + tagBbox.width + px},${pos + h2 + py} + ${x + layoutOffset},${pos + h2 + py}` + ).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")"); + hole.attr("cx", x + px / 2).attr("cy", pos).attr("transform", "translate(12,12) rotate(45, " + x + "," + pos + ")"); + tag.attr("x", x + 5).attr("y", pos + 3).attr("transform", "translate(14,14) rotate(45, " + x + "," + pos + ")"); + } + } + } + pos += commitStep + layoutOffset; + if (pos > maxPos) { + maxPos = pos; + } + }); +}; +const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => { + const commitBIsFurthest = dir === "TB" ? p1.x < p2.x : p1.y < p2.y; + const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch; + const isOnBranchToGetCurve = (x) => x.branch === branchToGetCurve; + const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq; + return Object.values(allCommits).some((commitX) => { + return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX); + }); +}; +const findLane = (y1, y2, depth = 0) => { + const candidate = y1 + Math.abs(y1 - y2) / 2; + if (depth > 5) { + return candidate; + } + let ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10); + if (ok) { + lanes.push(candidate); + return candidate; + } + const diff = Math.abs(y1 - y2); + return findLane(y1, y2 - diff / 5, depth + 1); +}; +const drawArrow = (svg, commitA, commitB, allCommits) => { + const p1 = commitPos[commitA.id]; + const p2 = commitPos[commitB.id]; + const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits); + let arc = ""; + let arc2 = ""; + let radius = 0; + let offset = 0; + let colorClassNum = branchPos[commitB.branch].index; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + colorClassNum = branchPos[commitA.branch].index; + } + let lineDef; + if (arrowNeedsRerouting) { + arc = "A 10 10, 0, 0, 0,"; + arc2 = "A 10 10, 0, 0, 1,"; + radius = 10; + offset = 10; + const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y); + const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x); + if (dir === "TB") { + if (p1.x < p2.x) { + lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + colorClassNum = branchPos[commitA.branch].index; + lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } else { + if (p1.y < p2.y) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`; + } else { + colorClassNum = branchPos[commitA.branch].index; + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`; + } + } + } else { + arc = "A 20 20, 0, 0, 0,"; + arc2 = "A 20 20, 0, 0, 1,"; + radius = 20; + offset = 20; + if (dir === "TB") { + if (p1.x < p2.x) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } + } + if (p1.x > p2.x) { + arc = "A 20 20, 0, 0, 0,"; + arc2 = "A 20 20, 0, 0, 1,"; + radius = 20; + offset = 20; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } + } + if (p1.x === p2.x) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } else { + if (p1.y < p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } + if (p1.y > p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } + } + if (p1.y === p2.y) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } + } + svg.append("path").attr("d", lineDef).attr("class", "arrow arrow" + colorClassNum % THEME_COLOR_LIMIT); +}; +const drawArrows = (svg, commits2) => { + const gArrows = svg.append("g").attr("class", "commit-arrows"); + Object.keys(commits2).forEach((key) => { + const commit2 = commits2[key]; + if (commit2.parents && commit2.parents.length > 0) { + commit2.parents.forEach((parent) => { + drawArrow(gArrows, commits2[parent], commit2, commits2); + }); + } + }); +}; +const drawBranches = (svg, branches2) => { + const gitGraphConfig = getConfig$2().gitGraph; + const g = svg.append("g"); + branches2.forEach((branch2, index) => { + const adjustIndexForTheme = index % THEME_COLOR_LIMIT; + const pos = branchPos[branch2.name].pos; + const line = g.append("line"); + line.attr("x1", 0); + line.attr("y1", pos); + line.attr("x2", maxPos); + line.attr("y2", pos); + line.attr("class", "branch branch" + adjustIndexForTheme); + if (dir === "TB") { + line.attr("y1", 30); + line.attr("x1", pos); + line.attr("y2", maxPos); + line.attr("x2", pos); + } + lanes.push(pos); + let name = branch2.name; + const labelElement = drawText$3(name); + const bkg = g.insert("rect"); + const branchLabel = g.insert("g").attr("class", "branchLabel"); + const label = branchLabel.insert("g").attr("class", "label branch-label" + adjustIndexForTheme); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + bkg.attr("class", "branchLabelBkg label" + adjustIndexForTheme).attr("rx", 4).attr("ry", 4).attr("x", -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)).attr("y", -bbox.height / 2 + 8).attr("width", bbox.width + 18).attr("height", bbox.height + 4); + label.attr( + "transform", + "translate(" + (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + ", " + (pos - bbox.height / 2 - 1) + ")" + ); + if (dir === "TB") { + bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", 0); + label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", 0)"); + } + if (dir !== "TB") { + bkg.attr("transform", "translate(-19, " + (pos - bbox.height / 2) + ")"); + } + }); +}; +const draw$h = function(txt, id, ver, diagObj) { + clear$e(); + const conf = getConfig$2(); + const gitGraphConfig = conf.gitGraph; + log$1.debug("in gitgraph renderer", txt + "\n", "id:", id, ver); + allCommitsDict = diagObj.db.getCommits(); + const branches2 = diagObj.db.getBranchesAsObjArray(); + dir = diagObj.db.getDirection(); + const diagram2 = select(`[id="${id}"]`); + let pos = 0; + branches2.forEach((branch2, index) => { + const labelElement = drawText$3(branch2.name); + const g = diagram2.append("g"); + const branchLabel = g.insert("g").attr("class", "branchLabel"); + const label = branchLabel.insert("g").attr("class", "label branch-label"); + label.node().appendChild(labelElement); + let bbox = labelElement.getBBox(); + branchPos[branch2.name] = { pos, index }; + pos += 50 + (gitGraphConfig.rotateCommitLabel ? 40 : 0) + (dir === "TB" ? bbox.width / 2 : 0); + label.remove(); + branchLabel.remove(); + g.remove(); + }); + drawCommits(diagram2, allCommitsDict, false); + if (gitGraphConfig.showBranches) { + drawBranches(diagram2, branches2); + } + drawArrows(diagram2, allCommitsDict); + drawCommits(diagram2, allCommitsDict, true); + utils.insertTitle( + diagram2, + "gitTitleText", + gitGraphConfig.titleTopMargin, + diagObj.db.getDiagramTitle() + ); + setupGraphViewbox( + void 0, + diagram2, + gitGraphConfig.diagramPadding, + gitGraphConfig.useMaxWidth ?? conf.useMaxWidth + ); +}; +const gitGraphRenderer = { + draw: draw$h +}; +const getStyles$b = (options2) => ` + .commit-id, + .commit-msg, + .branch-label { + fill: lightgrey; + color: lightgrey; + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + } + ${[0, 1, 2, 3, 4, 5, 6, 7].map( + (i) => ` + .branch-label${i} { fill: ${options2["gitBranchLabel" + i]}; } + .commit${i} { stroke: ${options2["git" + i]}; fill: ${options2["git" + i]}; } + .commit-highlight${i} { stroke: ${options2["gitInv" + i]}; fill: ${options2["gitInv" + i]}; } + .label${i} { fill: ${options2["git" + i]}; } + .arrow${i} { stroke: ${options2["git" + i]}; } + ` +).join("\n")} + + .branch { + stroke-width: 1; + stroke: ${options2.lineColor}; + stroke-dasharray: 2; + } + .commit-label { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelColor};} + .commit-label-bkg { font-size: ${options2.commitLabelFontSize}; fill: ${options2.commitLabelBackground}; opacity: 0.5; } + .tag-label { font-size: ${options2.tagLabelFontSize}; fill: ${options2.tagLabelColor};} + .tag-label-bkg { fill: ${options2.tagLabelBackground}; stroke: ${options2.tagLabelBorder}; } + .tag-hole { fill: ${options2.textColor}; } + + .commit-merge { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + } + .commit-reverse { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + stroke-width: 3; + } + .commit-highlight-outer { + } + .commit-highlight-inner { + stroke: ${options2.primaryColor}; + fill: ${options2.primaryColor}; + } + + .arrow { stroke-width: 8; stroke-linecap: round; fill: none} + .gitTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options2.textColor}; + } +`; +const gitGraphStyles = getStyles$b; +const diagram$h = { + parser: gitGraphParser, + db: gitGraphDb, + renderer: gitGraphRenderer, + styles: gitGraphStyles +}; + +var gitGraphDiagram942e62fe = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$h +}); + +var isoWeek = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal$1,(function(){var e="day";return function(t,i,s){var a=function(t){return t.add(4-t.isoWeekday(),e)},d=i.prototype;d.isoWeekYear=function(){return a(this).year()},d.isoWeek=function(t){if(!this.$utils().u(t))return this.add(7*(t-this.isoWeek()),e);var i,d,n,o,r=a(this),u=(i=this.isoWeekYear(),d=this.$u,n=(d?s.utc:s)().year(i).startOf("year"),o=4-n.isoWeekday(),n.isoWeekday()>4&&(o+=7),n.add(o,e));return r.diff(u,"week")+1},d.isoWeekday=function(e){return this.$utils().u(e)?this.day()||7:this.day(this.day()%7?e:e-7)};var n=d.startOf;d.startOf=function(e,t){var i=this.$utils(),s=!!i.u(t)||t;return "isoweek"===i.p(e)?s?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):n.bind(this)(e,t)};}})); +} (isoWeek)); + +var isoWeekExports = isoWeek.exports; +var dayjsIsoWeek = /*@__PURE__*/getDefaultExportFromCjs(isoWeekExports); + +var customParseFormat = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal$1,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}})); +} (customParseFormat)); + +var customParseFormatExports = customParseFormat.exports; +var dayjsCustomParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports); + +var advancedFormat = {exports: {}}; + +(function (module, exports) { + !function(e,t){module.exports=t();}(commonjsGlobal$1,(function(){return function(e,t){var r=t.prototype,n=r.format;r.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return n.bind(this)(e);var s=this.$utils(),a=(e||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(e){switch(e){case"Q":return Math.ceil((t.$M+1)/3);case"Do":return r.ordinal(t.$D);case"gggg":return t.weekYear();case"GGGG":return t.isoWeekYear();case"wo":return r.ordinal(t.week(),"W");case"w":case"ww":return s.s(t.week(),"w"===e?1:2,"0");case"W":case"WW":return s.s(t.isoWeek(),"W"===e?1:2,"0");case"k":case"kk":return s.s(String(0===t.$H?24:t.$H),"k"===e?1:2,"0");case"X":return Math.floor(t.$d.getTime()/1e3);case"x":return t.$d.getTime();case"z":return "["+t.offsetName()+"]";case"zzz":return "["+t.offsetName("long")+"]";default:return e}}));return n.bind(this)(a)};}})); +} (advancedFormat)); + +var advancedFormatExports = advancedFormat.exports; +var dayjsAdvancedFormat = /*@__PURE__*/getDefaultExportFromCjs(advancedFormatExports); + +var parser$e = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 35, 37], $V1 = [1, 25], $V2 = [1, 26], $V3 = [1, 27], $V4 = [1, 28], $V5 = [1, 29], $V6 = [1, 30], $V7 = [1, 31], $V8 = [1, 9], $V9 = [1, 10], $Va = [1, 11], $Vb = [1, 12], $Vc = [1, 13], $Vd = [1, 14], $Ve = [1, 15], $Vf = [1, 16], $Vg = [1, 18], $Vh = [1, 19], $Vi = [1, 20], $Vj = [1, 21], $Vk = [1, 22], $Vl = [1, 24], $Vm = [1, 32]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "gantt": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NL": 10, "weekday": 11, "weekday_monday": 12, "weekday_tuesday": 13, "weekday_wednesday": 14, "weekday_thursday": 15, "weekday_friday": 16, "weekday_saturday": 17, "weekday_sunday": 18, "dateFormat": 19, "inclusiveEndDates": 20, "topAxis": 21, "axisFormat": 22, "tickInterval": 23, "excludes": 24, "includes": 25, "todayMarker": 26, "title": 27, "acc_title": 28, "acc_title_value": 29, "acc_descr": 30, "acc_descr_value": 31, "acc_descr_multiline_value": 32, "section": 33, "clickStatement": 34, "taskTxt": 35, "taskData": 36, "click": 37, "callbackname": 38, "callbackargs": 39, "href": 40, "clickStatementDebug": 41, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "gantt", 6: "EOF", 8: "SPACE", 10: "NL", 12: "weekday_monday", 13: "weekday_tuesday", 14: "weekday_wednesday", 15: "weekday_thursday", 16: "weekday_friday", 17: "weekday_saturday", 18: "weekday_sunday", 19: "dateFormat", 20: "inclusiveEndDates", 21: "topAxis", 22: "axisFormat", 23: "tickInterval", 24: "excludes", 25: "includes", 26: "todayMarker", 27: "title", 28: "acc_title", 29: "acc_title_value", 30: "acc_descr", 31: "acc_descr_value", 32: "acc_descr_multiline_value", 33: "section", 35: "taskTxt", 36: "taskData", 37: "click", 38: "callbackname", 39: "callbackargs", 40: "href" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [34, 2], [34, 3], [34, 3], [34, 4], [34, 3], [34, 4], [34, 2], [41, 2], [41, 3], [41, 3], [41, 4], [41, 3], [41, 4], [41, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.setWeekday("monday"); + break; + case 9: + yy.setWeekday("tuesday"); + break; + case 10: + yy.setWeekday("wednesday"); + break; + case 11: + yy.setWeekday("thursday"); + break; + case 12: + yy.setWeekday("friday"); + break; + case 13: + yy.setWeekday("saturday"); + break; + case 14: + yy.setWeekday("sunday"); + break; + case 15: + yy.setDateFormat($$[$0].substr(11)); + this.$ = $$[$0].substr(11); + break; + case 16: + yy.enableInclusiveEndDates(); + this.$ = $$[$0].substr(18); + break; + case 17: + yy.TopAxis(); + this.$ = $$[$0].substr(8); + break; + case 18: + yy.setAxisFormat($$[$0].substr(11)); + this.$ = $$[$0].substr(11); + break; + case 19: + yy.setTickInterval($$[$0].substr(13)); + this.$ = $$[$0].substr(13); + break; + case 20: + yy.setExcludes($$[$0].substr(9)); + this.$ = $$[$0].substr(9); + break; + case 21: + yy.setIncludes($$[$0].substr(9)); + this.$ = $$[$0].substr(9); + break; + case 22: + yy.setTodayMarker($$[$0].substr(12)); + this.$ = $$[$0].substr(12); + break; + case 24: + yy.setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 25: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 26: + case 27: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 28: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 30: + yy.addTask($$[$0 - 1], $$[$0]); + this.$ = "task"; + break; + case 31: + this.$ = $$[$0 - 1]; + yy.setClickEvent($$[$0 - 1], $$[$0], null); + break; + case 32: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 33: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], null); + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 34: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]); + yy.setLink($$[$0 - 3], $$[$0]); + break; + case 35: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 2], $$[$0], null); + yy.setLink($$[$0 - 2], $$[$0 - 1]); + break; + case 36: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 1], $$[$0]); + yy.setLink($$[$0 - 3], $$[$0 - 2]); + break; + case 37: + this.$ = $$[$0 - 1]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 38: + case 44: + this.$ = $$[$0 - 1] + " " + $$[$0]; + break; + case 39: + case 40: + case 42: + this.$ = $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0]; + break; + case 41: + case 43: + this.$ = $$[$0 - 3] + " " + $$[$0 - 2] + " " + $$[$0 - 1] + " " + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 17, 12: $V1, 13: $V2, 14: $V3, 15: $V4, 16: $V5, 17: $V6, 18: $V7, 19: $V8, 20: $V9, 21: $Va, 22: $Vb, 23: $Vc, 24: $Vd, 25: $Ve, 26: $Vf, 27: $Vg, 28: $Vh, 30: $Vi, 32: $Vj, 33: $Vk, 34: 23, 35: $Vl, 37: $Vm }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 33, 11: 17, 12: $V1, 13: $V2, 14: $V3, 15: $V4, 16: $V5, 17: $V6, 18: $V7, 19: $V8, 20: $V9, 21: $Va, 22: $Vb, 23: $Vc, 24: $Vd, 25: $Ve, 26: $Vf, 27: $Vg, 28: $Vh, 30: $Vi, 32: $Vj, 33: $Vk, 34: 23, 35: $Vl, 37: $Vm }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 17]), o($V0, [2, 18]), o($V0, [2, 19]), o($V0, [2, 20]), o($V0, [2, 21]), o($V0, [2, 22]), o($V0, [2, 23]), o($V0, [2, 24]), { 29: [1, 34] }, { 31: [1, 35] }, o($V0, [2, 27]), o($V0, [2, 28]), o($V0, [2, 29]), { 36: [1, 36] }, o($V0, [2, 8]), o($V0, [2, 9]), o($V0, [2, 10]), o($V0, [2, 11]), o($V0, [2, 12]), o($V0, [2, 13]), o($V0, [2, 14]), { 38: [1, 37], 40: [1, 38] }, o($V0, [2, 4]), o($V0, [2, 25]), o($V0, [2, 26]), o($V0, [2, 30]), o($V0, [2, 31], { 39: [1, 39], 40: [1, 40] }), o($V0, [2, 37], { 38: [1, 41] }), o($V0, [2, 32], { 40: [1, 42] }), o($V0, [2, 33]), o($V0, [2, 35], { 39: [1, 43] }), o($V0, [2, 34]), o($V0, [2, 36])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.begin("open_directive"); + return "open_directive"; + case 1: + this.begin("acc_title"); + return 28; + case 2: + this.popState(); + return "acc_title_value"; + case 3: + this.begin("acc_descr"); + return 30; + case 4: + this.popState(); + return "acc_descr_value"; + case 5: + this.begin("acc_descr_multiline"); + break; + case 6: + this.popState(); + break; + case 7: + return "acc_descr_multiline_value"; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + return 10; + case 12: + break; + case 13: + break; + case 14: + this.begin("href"); + break; + case 15: + this.popState(); + break; + case 16: + return 40; + case 17: + this.begin("callbackname"); + break; + case 18: + this.popState(); + break; + case 19: + this.popState(); + this.begin("callbackargs"); + break; + case 20: + return 38; + case 21: + this.popState(); + break; + case 22: + return 39; + case 23: + this.begin("click"); + break; + case 24: + this.popState(); + break; + case 25: + return 37; + case 26: + return 4; + case 27: + return 19; + case 28: + return 20; + case 29: + return 21; + case 30: + return 22; + case 31: + return 23; + case 32: + return 25; + case 33: + return 24; + case 34: + return 26; + case 35: + return 12; + case 36: + return 13; + case 37: + return 14; + case 38: + return 15; + case 39: + return 16; + case 40: + return 17; + case 41: + return 18; + case 42: + return "date"; + case 43: + return 27; + case 44: + return "accDescription"; + case 45: + return 33; + case 46: + return 35; + case 47: + return 36; + case 48: + return ":"; + case 49: + return 6; + case 50: + return "INVALID"; + } + }, + rules: [/^(?:%%\{)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:%%(?!\{)*[^\n]*)/i, /^(?:[^\}]%%*[^\n]*)/i, /^(?:%%*[^\n]*[\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:%[^\n]*)/i, /^(?:href[\s]+["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:call[\s]+)/i, /^(?:\([\s]*\))/i, /^(?:\()/i, /^(?:[^(]*)/i, /^(?:\))/i, /^(?:[^)]*)/i, /^(?:click[\s]+)/i, /^(?:[\s\n])/i, /^(?:[^\s\n]*)/i, /^(?:gantt\b)/i, /^(?:dateFormat\s[^#\n;]+)/i, /^(?:inclusiveEndDates\b)/i, /^(?:topAxis\b)/i, /^(?:axisFormat\s[^#\n;]+)/i, /^(?:tickInterval\s[^#\n;]+)/i, /^(?:includes\s[^#\n;]+)/i, /^(?:excludes\s[^#\n;]+)/i, /^(?:todayMarker\s[^\n;]+)/i, /^(?:weekday\s+monday\b)/i, /^(?:weekday\s+tuesday\b)/i, /^(?:weekday\s+wednesday\b)/i, /^(?:weekday\s+thursday\b)/i, /^(?:weekday\s+friday\b)/i, /^(?:weekday\s+saturday\b)/i, /^(?:weekday\s+sunday\b)/i, /^(?:\d\d\d\d-\d\d-\d\d\b)/i, /^(?:title\s[^\n]+)/i, /^(?:accDescription\s[^#\n;]+)/i, /^(?:section\s[^\n]+)/i, /^(?:[^:\n]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "callbackargs": { "rules": [21, 22], "inclusive": false }, "callbackname": { "rules": [18, 19, 20], "inclusive": false }, "href": { "rules": [15, 16], "inclusive": false }, "click": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 17, 23, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$e.parser = parser$e; +const ganttParser = parser$e; +dayjs.extend(dayjsIsoWeek); +dayjs.extend(dayjsCustomParseFormat); +dayjs.extend(dayjsAdvancedFormat); +let dateFormat = ""; +let axisFormat = ""; +let tickInterval = void 0; +let todayMarker = ""; +let includes = []; +let excludes = []; +let links$1 = {}; +let sections$3 = []; +let tasks$2 = []; +let currentSection$2 = ""; +let displayMode = ""; +const tags = ["active", "done", "crit", "milestone"]; +let funs = []; +let inclusiveEndDates = false; +let topAxis = false; +let weekday = "sunday"; +let lastOrder = 0; +const clear$d = function() { + sections$3 = []; + tasks$2 = []; + currentSection$2 = ""; + funs = []; + taskCnt = 0; + lastTask = void 0; + lastTaskID = void 0; + rawTasks$2 = []; + dateFormat = ""; + axisFormat = ""; + displayMode = ""; + tickInterval = void 0; + todayMarker = ""; + includes = []; + excludes = []; + inclusiveEndDates = false; + topAxis = false; + lastOrder = 0; + links$1 = {}; + clear$k(); + weekday = "sunday"; +}; +const setAxisFormat = function(txt) { + axisFormat = txt; +}; +const getAxisFormat = function() { + return axisFormat; +}; +const setTickInterval = function(txt) { + tickInterval = txt; +}; +const getTickInterval = function() { + return tickInterval; +}; +const setTodayMarker = function(txt) { + todayMarker = txt; +}; +const getTodayMarker = function() { + return todayMarker; +}; +const setDateFormat = function(txt) { + dateFormat = txt; +}; +const enableInclusiveEndDates = function() { + inclusiveEndDates = true; +}; +const endDatesAreInclusive = function() { + return inclusiveEndDates; +}; +const enableTopAxis = function() { + topAxis = true; +}; +const topAxisEnabled = function() { + return topAxis; +}; +const setDisplayMode = function(txt) { + displayMode = txt; +}; +const getDisplayMode = function() { + return displayMode; +}; +const getDateFormat = function() { + return dateFormat; +}; +const setIncludes = function(txt) { + includes = txt.toLowerCase().split(/[\s,]+/); +}; +const getIncludes = function() { + return includes; +}; +const setExcludes = function(txt) { + excludes = txt.toLowerCase().split(/[\s,]+/); +}; +const getExcludes = function() { + return excludes; +}; +const getLinks$1 = function() { + return links$1; +}; +const addSection$3 = function(txt) { + currentSection$2 = txt; + sections$3.push(txt); +}; +const getSections$3 = function() { + return sections$3; +}; +const getTasks$2 = function() { + let allItemsProcessed = compileTasks$2(); + const maxDepth = 10; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks$2(); + iterationCount++; + } + tasks$2 = rawTasks$2; + return tasks$2; +}; +const isInvalidDate = function(date, dateFormat2, excludes2, includes2) { + if (includes2.includes(date.format(dateFormat2.trim()))) { + return false; + } + if (date.isoWeekday() >= 6 && excludes2.includes("weekends")) { + return true; + } + if (excludes2.includes(date.format("dddd").toLowerCase())) { + return true; + } + return excludes2.includes(date.format(dateFormat2.trim())); +}; +const setWeekday = function(txt) { + weekday = txt; +}; +const getWeekday = function() { + return weekday; +}; +const checkTaskDates = function(task, dateFormat2, excludes2, includes2) { + if (!excludes2.length || task.manualEndTime) { + return; + } + let startTime; + if (task.startTime instanceof Date) { + startTime = dayjs(task.startTime); + } else { + startTime = dayjs(task.startTime, dateFormat2, true); + } + startTime = startTime.add(1, "d"); + let originalEndTime; + if (task.endTime instanceof Date) { + originalEndTime = dayjs(task.endTime); + } else { + originalEndTime = dayjs(task.endTime, dateFormat2, true); + } + const [fixedEndTime, renderEndTime] = fixTaskDates( + startTime, + originalEndTime, + dateFormat2, + excludes2, + includes2 + ); + task.endTime = fixedEndTime.toDate(); + task.renderEndTime = renderEndTime; +}; +const fixTaskDates = function(startTime, endTime, dateFormat2, excludes2, includes2) { + let invalid = false; + let renderEndTime = null; + while (startTime <= endTime) { + if (!invalid) { + renderEndTime = endTime.toDate(); + } + invalid = isInvalidDate(startTime, dateFormat2, excludes2, includes2); + if (invalid) { + endTime = endTime.add(1, "d"); + } + startTime = startTime.add(1, "d"); + } + return [endTime, renderEndTime]; +}; +const getStartDate = function(prevTime, dateFormat2, str) { + str = str.trim(); + const afterRePattern = /^after\s+(?[\d\w- ]+)/; + const afterStatement = afterRePattern.exec(str); + if (afterStatement !== null) { + let latestTask = null; + for (const id of afterStatement.groups.ids.split(" ")) { + let task = findTaskById(id); + if (task !== void 0 && (!latestTask || task.endTime > latestTask.endTime)) { + latestTask = task; + } + } + if (latestTask) { + return latestTask.endTime; + } + const today = /* @__PURE__ */ new Date(); + today.setHours(0, 0, 0, 0); + return today; + } + let mDate = dayjs(str, dateFormat2.trim(), true); + if (mDate.isValid()) { + return mDate.toDate(); + } else { + log$1.debug("Invalid date:" + str); + log$1.debug("With date format:" + dateFormat2.trim()); + const d = new Date(str); + if (d === void 0 || isNaN(d.getTime()) || // WebKit browsers can mis-parse invalid dates to be ridiculously + // huge numbers, e.g. new Date('202304') gets parsed as January 1, 202304. + // This can cause virtually infinite loops while rendering, so for the + // purposes of Gantt charts we'll just treat any date beyond 10,000 AD/BC as + // invalid. + d.getFullYear() < -1e4 || d.getFullYear() > 1e4) { + throw new Error("Invalid date:" + str); + } + return d; + } +}; +const parseDuration = function(str) { + const statement = /^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/.exec(str.trim()); + if (statement !== null) { + return [Number.parseFloat(statement[1]), statement[2]]; + } + return [NaN, "ms"]; +}; +const getEndDate = function(prevTime, dateFormat2, str, inclusive = false) { + str = str.trim(); + const untilRePattern = /^until\s+(?[\d\w- ]+)/; + const untilStatement = untilRePattern.exec(str); + if (untilStatement !== null) { + let earliestTask = null; + for (const id of untilStatement.groups.ids.split(" ")) { + let task = findTaskById(id); + if (task !== void 0 && (!earliestTask || task.startTime < earliestTask.startTime)) { + earliestTask = task; + } + } + if (earliestTask) { + return earliestTask.startTime; + } + const today = /* @__PURE__ */ new Date(); + today.setHours(0, 0, 0, 0); + return today; + } + let parsedDate = dayjs(str, dateFormat2.trim(), true); + if (parsedDate.isValid()) { + if (inclusive) { + parsedDate = parsedDate.add(1, "d"); + } + return parsedDate.toDate(); + } + let endTime = dayjs(prevTime); + const [durationValue, durationUnit] = parseDuration(str); + if (!Number.isNaN(durationValue)) { + const newEndTime = endTime.add(durationValue, durationUnit); + if (newEndTime.isValid()) { + endTime = newEndTime; + } + } + return endTime.toDate(); +}; +let taskCnt = 0; +const parseId = function(idStr) { + if (idStr === void 0) { + taskCnt = taskCnt + 1; + return "task" + taskCnt; + } + return idStr; +}; +const compileData = function(prevTask, dataStr) { + let ds; + if (dataStr.substr(0, 1) === ":") { + ds = dataStr.substr(1, dataStr.length); + } else { + ds = dataStr; + } + const data = ds.split(","); + const task = {}; + getTaskTags(data, task, tags); + for (let i = 0; i < data.length; i++) { + data[i] = data[i].trim(); + } + let endTimeData = ""; + switch (data.length) { + case 1: + task.id = parseId(); + task.startTime = prevTask.endTime; + endTimeData = data[0]; + break; + case 2: + task.id = parseId(); + task.startTime = getStartDate(void 0, dateFormat, data[0]); + endTimeData = data[1]; + break; + case 3: + task.id = parseId(data[0]); + task.startTime = getStartDate(void 0, dateFormat, data[1]); + endTimeData = data[2]; + break; + } + if (endTimeData) { + task.endTime = getEndDate(task.startTime, dateFormat, endTimeData, inclusiveEndDates); + task.manualEndTime = dayjs(endTimeData, "YYYY-MM-DD", true).isValid(); + checkTaskDates(task, dateFormat, excludes, includes); + } + return task; +}; +const parseData = function(prevTaskId, dataStr) { + let ds; + if (dataStr.substr(0, 1) === ":") { + ds = dataStr.substr(1, dataStr.length); + } else { + ds = dataStr; + } + const data = ds.split(","); + const task = {}; + getTaskTags(data, task, tags); + for (let i = 0; i < data.length; i++) { + data[i] = data[i].trim(); + } + switch (data.length) { + case 1: + task.id = parseId(); + task.startTime = { + type: "prevTaskEnd", + id: prevTaskId + }; + task.endTime = { + data: data[0] + }; + break; + case 2: + task.id = parseId(); + task.startTime = { + type: "getStartDate", + startData: data[0] + }; + task.endTime = { + data: data[1] + }; + break; + case 3: + task.id = parseId(data[0]); + task.startTime = { + type: "getStartDate", + startData: data[1] + }; + task.endTime = { + data: data[2] + }; + break; + } + return task; +}; +let lastTask; +let lastTaskID; +let rawTasks$2 = []; +const taskDb = {}; +const addTask$2 = function(descr, data) { + const rawTask = { + section: currentSection$2, + type: currentSection$2, + processed: false, + manualEndTime: false, + renderEndTime: null, + raw: { data }, + task: descr, + classes: [] + }; + const taskInfo = parseData(lastTaskID, data); + rawTask.raw.startTime = taskInfo.startTime; + rawTask.raw.endTime = taskInfo.endTime; + rawTask.id = taskInfo.id; + rawTask.prevTaskId = lastTaskID; + rawTask.active = taskInfo.active; + rawTask.done = taskInfo.done; + rawTask.crit = taskInfo.crit; + rawTask.milestone = taskInfo.milestone; + rawTask.order = lastOrder; + lastOrder++; + const pos = rawTasks$2.push(rawTask); + lastTaskID = rawTask.id; + taskDb[rawTask.id] = pos - 1; +}; +const findTaskById = function(id) { + const pos = taskDb[id]; + return rawTasks$2[pos]; +}; +const addTaskOrg$2 = function(descr, data) { + const newTask = { + section: currentSection$2, + type: currentSection$2, + description: descr, + task: descr, + classes: [] + }; + const taskInfo = compileData(lastTask, data); + newTask.startTime = taskInfo.startTime; + newTask.endTime = taskInfo.endTime; + newTask.id = taskInfo.id; + newTask.active = taskInfo.active; + newTask.done = taskInfo.done; + newTask.crit = taskInfo.crit; + newTask.milestone = taskInfo.milestone; + lastTask = newTask; + tasks$2.push(newTask); +}; +const compileTasks$2 = function() { + const compileTask = function(pos) { + const task = rawTasks$2[pos]; + let startTime = ""; + switch (rawTasks$2[pos].raw.startTime.type) { + case "prevTaskEnd": { + const prevTask = findTaskById(task.prevTaskId); + task.startTime = prevTask.endTime; + break; + } + case "getStartDate": + startTime = getStartDate(void 0, dateFormat, rawTasks$2[pos].raw.startTime.startData); + if (startTime) { + rawTasks$2[pos].startTime = startTime; + } + break; + } + if (rawTasks$2[pos].startTime) { + rawTasks$2[pos].endTime = getEndDate( + rawTasks$2[pos].startTime, + dateFormat, + rawTasks$2[pos].raw.endTime.data, + inclusiveEndDates + ); + if (rawTasks$2[pos].endTime) { + rawTasks$2[pos].processed = true; + rawTasks$2[pos].manualEndTime = dayjs( + rawTasks$2[pos].raw.endTime.data, + "YYYY-MM-DD", + true + ).isValid(); + checkTaskDates(rawTasks$2[pos], dateFormat, excludes, includes); + } + } + return rawTasks$2[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks$2.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const setLink$1 = function(ids, _linkStr) { + let linkStr = _linkStr; + if (getConfig$2().securityLevel !== "loose") { + linkStr = dist$1.sanitizeUrl(_linkStr); + } + ids.split(",").forEach(function(id) { + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + pushFun(id, () => { + window.open(linkStr, "_self"); + }); + links$1[id] = linkStr; + } + }); + setClass(ids, "clickable"); +}; +const setClass = function(ids, className) { + ids.split(",").forEach(function(id) { + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + rawTask.classes.push(className); + } + }); +}; +const setClickFun = function(id, functionName, functionArgs) { + if (getConfig$2().securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(id); + } + let rawTask = findTaskById(id); + if (rawTask !== void 0) { + pushFun(id, () => { + utils.runFunc(functionName, ...argList); + }); + } +}; +const pushFun = function(id, callbackFunction) { + funs.push( + function() { + const elem = document.querySelector(`[id="${id}"]`); + if (elem !== null) { + elem.addEventListener("click", function() { + callbackFunction(); + }); + } + }, + function() { + const elem = document.querySelector(`[id="${id}-text"]`); + if (elem !== null) { + elem.addEventListener("click", function() { + callbackFunction(); + }); + } + } + ); +}; +const setClickEvent$1 = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFun(id, functionName, functionArgs); + }); + setClass(ids, "clickable"); +}; +const bindFunctions$1 = function(element) { + funs.forEach(function(fun) { + fun(element); + }); +}; +const ganttDb = { + getConfig: () => getConfig$2().gantt, + clear: clear$d, + setDateFormat, + getDateFormat, + enableInclusiveEndDates, + endDatesAreInclusive, + enableTopAxis, + topAxisEnabled, + setAxisFormat, + getAxisFormat, + setTickInterval, + getTickInterval, + setTodayMarker, + getTodayMarker, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + setDisplayMode, + getDisplayMode, + setAccDescription, + getAccDescription, + addSection: addSection$3, + getSections: getSections$3, + getTasks: getTasks$2, + addTask: addTask$2, + findTaskById, + addTaskOrg: addTaskOrg$2, + setIncludes, + getIncludes, + setExcludes, + getExcludes, + setClickEvent: setClickEvent$1, + setLink: setLink$1, + getLinks: getLinks$1, + bindFunctions: bindFunctions$1, + parseDuration, + isInvalidDate, + setWeekday, + getWeekday +}; +function getTaskTags(data, task, tags2) { + let matchFound = true; + while (matchFound) { + matchFound = false; + tags2.forEach(function(t) { + const pattern = "^\\s*" + t + "\\s*$"; + const regex = new RegExp(pattern); + if (data[0].match(regex)) { + task[t] = true; + data.shift(1); + matchFound = true; + } + }); + } +} +const setConf$5 = function() { + log$1.debug("Something is calling, setConf, remove the call"); +}; +const mapWeekdayToTimeFunction = { + monday: timeMonday, + tuesday: timeTuesday, + wednesday: timeWednesday, + thursday: timeThursday, + friday: timeFriday, + saturday: timeSaturday, + sunday: timeSunday +}; +const getMaxIntersections = (tasks2, orderOffset) => { + let timeline = [...tasks2].map(() => -Infinity); + let sorted = [...tasks2].sort((a, b) => a.startTime - b.startTime || a.order - b.order); + let maxIntersections = 0; + for (const element of sorted) { + for (let j = 0; j < timeline.length; j++) { + if (element.startTime >= timeline[j]) { + timeline[j] = element.endTime; + element.order = j + orderOffset; + if (j > maxIntersections) { + maxIntersections = j; + } + break; + } + } + } + return maxIntersections; +}; +let w; +const draw$g = function(text, id, version, diagObj) { + const conf = getConfig$2().gantt; + const securityLevel = getConfig$2().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const elem = doc.getElementById(id); + w = elem.parentElement.offsetWidth; + if (w === void 0) { + w = 1200; + } + if (conf.useWidth !== void 0) { + w = conf.useWidth; + } + const taskArray = diagObj.db.getTasks(); + let categories = []; + for (const element of taskArray) { + categories.push(element.type); + } + categories = checkUnique(categories); + const categoryHeights = {}; + let h = 2 * conf.topPadding; + if (diagObj.db.getDisplayMode() === "compact" || conf.displayMode === "compact") { + const categoryElements = {}; + for (const element of taskArray) { + if (categoryElements[element.section] === void 0) { + categoryElements[element.section] = [element]; + } else { + categoryElements[element.section].push(element); + } + } + let intersections = 0; + for (const category of Object.keys(categoryElements)) { + const categoryHeight = getMaxIntersections(categoryElements[category], intersections) + 1; + intersections += categoryHeight; + h += categoryHeight * (conf.barHeight + conf.barGap); + categoryHeights[category] = categoryHeight; + } + } else { + h += taskArray.length * (conf.barHeight + conf.barGap); + for (const category of categories) { + categoryHeights[category] = taskArray.filter((task) => task.type === category).length; + } + } + elem.setAttribute("viewBox", "0 0 " + w + " " + h); + const svg = root.select(`[id="${id}"]`); + const timeScale = time().domain([ + min$4(taskArray, function(d) { + return d.startTime; + }), + max$4(taskArray, function(d) { + return d.endTime; + }) + ]).rangeRound([0, w - conf.leftPadding - conf.rightPadding]); + function taskCompare(a, b) { + const taskA = a.startTime; + const taskB = b.startTime; + let result = 0; + if (taskA > taskB) { + result = 1; + } else if (taskA < taskB) { + result = -1; + } + return result; + } + taskArray.sort(taskCompare); + makeGantt(taskArray, w, h); + configureSvgSize(svg, h, w, conf.useMaxWidth); + svg.append("text").text(diagObj.db.getDiagramTitle()).attr("x", w / 2).attr("y", conf.titleTopMargin).attr("class", "titleText"); + function makeGantt(tasks2, pageWidth, pageHeight) { + const barHeight = conf.barHeight; + const gap = barHeight + conf.barGap; + const topPadding = conf.topPadding; + const leftPadding = conf.leftPadding; + const colorScale = linear().domain([0, categories.length]).range(["#00B9FA", "#F95002"]).interpolate(interpolateHcl); + drawExcludeDays( + gap, + topPadding, + leftPadding, + pageWidth, + pageHeight, + tasks2, + diagObj.db.getExcludes(), + diagObj.db.getIncludes() + ); + makeGrid(leftPadding, topPadding, pageWidth, pageHeight); + drawRects(tasks2, gap, topPadding, leftPadding, barHeight, colorScale, pageWidth); + vertLabels(gap, topPadding); + drawToday(leftPadding, topPadding, pageWidth, pageHeight); + } + function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w2) { + const uniqueTaskOrderIds = [...new Set(theArray.map((item) => item.order))]; + const uniqueTasks = uniqueTaskOrderIds.map((id2) => theArray.find((item) => item.order === id2)); + svg.append("g").selectAll("rect").data(uniqueTasks).enter().append("rect").attr("x", 0).attr("y", function(d, i) { + i = d.order; + return i * theGap + theTopPad - 2; + }).attr("width", function() { + return w2 - conf.rightPadding / 2; + }).attr("height", theGap).attr("class", function(d) { + for (const [i, category] of categories.entries()) { + if (d.type === category) { + return "section section" + i % conf.numberSectionStyles; + } + } + return "section section0"; + }); + const rectangles = svg.append("g").selectAll("rect").data(theArray).enter(); + const links2 = diagObj.db.getLinks(); + rectangles.append("rect").attr("id", function(d) { + return d.id; + }).attr("rx", 3).attr("ry", 3).attr("x", function(d) { + if (d.milestone) { + return timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight; + } + return timeScale(d.startTime) + theSidePad; + }).attr("y", function(d, i) { + i = d.order; + return i * theGap + theTopPad; + }).attr("width", function(d) { + if (d.milestone) { + return theBarHeight; + } + return timeScale(d.renderEndTime || d.endTime) - timeScale(d.startTime); + }).attr("height", theBarHeight).attr("transform-origin", function(d, i) { + i = d.order; + return (timeScale(d.startTime) + theSidePad + 0.5 * (timeScale(d.endTime) - timeScale(d.startTime))).toString() + "px " + (i * theGap + theTopPad + 0.5 * theBarHeight).toString() + "px"; + }).attr("class", function(d) { + const res = "task"; + let classStr = ""; + if (d.classes.length > 0) { + classStr = d.classes.join(" "); + } + let secNum = 0; + for (const [i, category] of categories.entries()) { + if (d.type === category) { + secNum = i % conf.numberSectionStyles; + } + } + let taskClass = ""; + if (d.active) { + if (d.crit) { + taskClass += " activeCrit"; + } else { + taskClass = " active"; + } + } else if (d.done) { + if (d.crit) { + taskClass = " doneCrit"; + } else { + taskClass = " done"; + } + } else { + if (d.crit) { + taskClass += " crit"; + } + } + if (taskClass.length === 0) { + taskClass = " task"; + } + if (d.milestone) { + taskClass = " milestone " + taskClass; + } + taskClass += secNum; + taskClass += " " + classStr; + return res + taskClass; + }); + rectangles.append("text").attr("id", function(d) { + return d.id + "-text"; + }).text(function(d) { + return d.task; + }).attr("font-size", conf.fontSize).attr("x", function(d) { + let startX = timeScale(d.startTime); + let endX = timeScale(d.renderEndTime || d.endTime); + if (d.milestone) { + startX += 0.5 * (timeScale(d.endTime) - timeScale(d.startTime)) - 0.5 * theBarHeight; + } + if (d.milestone) { + endX = startX + theBarHeight; + } + const textWidth = this.getBBox().width; + if (textWidth > endX - startX) { + if (endX + textWidth + 1.5 * conf.leftPadding > w2) { + return startX + theSidePad - 5; + } else { + return endX + theSidePad + 5; + } + } else { + return (endX - startX) / 2 + startX + theSidePad; + } + }).attr("y", function(d, i) { + i = d.order; + return i * theGap + conf.barHeight / 2 + (conf.fontSize / 2 - 2) + theTopPad; + }).attr("text-height", theBarHeight).attr("class", function(d) { + const startX = timeScale(d.startTime); + let endX = timeScale(d.endTime); + if (d.milestone) { + endX = startX + theBarHeight; + } + const textWidth = this.getBBox().width; + let classStr = ""; + if (d.classes.length > 0) { + classStr = d.classes.join(" "); + } + let secNum = 0; + for (const [i, category] of categories.entries()) { + if (d.type === category) { + secNum = i % conf.numberSectionStyles; + } + } + let taskType = ""; + if (d.active) { + if (d.crit) { + taskType = "activeCritText" + secNum; + } else { + taskType = "activeText" + secNum; + } + } + if (d.done) { + if (d.crit) { + taskType = taskType + " doneCritText" + secNum; + } else { + taskType = taskType + " doneText" + secNum; + } + } else { + if (d.crit) { + taskType = taskType + " critText" + secNum; + } + } + if (d.milestone) { + taskType += " milestoneText"; + } + if (textWidth > endX - startX) { + if (endX + textWidth + 1.5 * conf.leftPadding > w2) { + return classStr + " taskTextOutsideLeft taskTextOutside" + secNum + " " + taskType; + } else { + return classStr + " taskTextOutsideRight taskTextOutside" + secNum + " " + taskType + " width-" + textWidth; + } + } else { + return classStr + " taskText taskText" + secNum + " " + taskType + " width-" + textWidth; + } + }); + const securityLevel2 = getConfig$2().securityLevel; + if (securityLevel2 === "sandbox") { + let sandboxElement2; + sandboxElement2 = select("#i" + id); + const doc2 = sandboxElement2.nodes()[0].contentDocument; + rectangles.filter(function(d) { + return links2[d.id] !== void 0; + }).each(function(o) { + var taskRect = doc2.querySelector("#" + o.id); + var taskText = doc2.querySelector("#" + o.id + "-text"); + const oldParent = taskRect.parentNode; + var Link = doc2.createElement("a"); + Link.setAttribute("xlink:href", links2[o.id]); + Link.setAttribute("target", "_top"); + oldParent.appendChild(Link); + Link.appendChild(taskRect); + Link.appendChild(taskText); + }); + } + } + function drawExcludeDays(theGap, theTopPad, theSidePad, w2, h2, tasks2, excludes2, includes2) { + if (excludes2.length === 0 && includes2.length === 0) { + return; + } + let minTime; + let maxTime; + for (const { startTime, endTime } of tasks2) { + if (minTime === void 0 || startTime < minTime) { + minTime = startTime; + } + if (maxTime === void 0 || endTime > maxTime) { + maxTime = endTime; + } + } + if (!minTime || !maxTime) { + return; + } + if (dayjs(maxTime).diff(dayjs(minTime), "year") > 5) { + log$1.warn( + "The difference between the min and max time is more than 5 years. This will cause performance issues. Skipping drawing exclude days." + ); + return; + } + const dateFormat2 = diagObj.db.getDateFormat(); + const excludeRanges = []; + let range = null; + let d = dayjs(minTime); + while (d.valueOf() <= maxTime) { + if (diagObj.db.isInvalidDate(d, dateFormat2, excludes2, includes2)) { + if (!range) { + range = { + start: d, + end: d + }; + } else { + range.end = d; + } + } else { + if (range) { + excludeRanges.push(range); + range = null; + } + } + d = d.add(1, "d"); + } + const rectangles = svg.append("g").selectAll("rect").data(excludeRanges).enter(); + rectangles.append("rect").attr("id", function(d2) { + return "exclude-" + d2.start.format("YYYY-MM-DD"); + }).attr("x", function(d2) { + return timeScale(d2.start) + theSidePad; + }).attr("y", conf.gridLineStartPadding).attr("width", function(d2) { + const renderEnd = d2.end.add(1, "day"); + return timeScale(renderEnd) - timeScale(d2.start); + }).attr("height", h2 - theTopPad - conf.gridLineStartPadding).attr("transform-origin", function(d2, i) { + return (timeScale(d2.start) + theSidePad + 0.5 * (timeScale(d2.end) - timeScale(d2.start))).toString() + "px " + (i * theGap + 0.5 * h2).toString() + "px"; + }).attr("class", "exclude-range"); + } + function makeGrid(theSidePad, theTopPad, w2, h2) { + let bottomXAxis = axisBottom(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d")); + const reTickInterval = /^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/; + const resultTickInterval = reTickInterval.exec( + diagObj.db.getTickInterval() || conf.tickInterval + ); + if (resultTickInterval !== null) { + const every = resultTickInterval[1]; + const interval = resultTickInterval[2]; + const weekday2 = diagObj.db.getWeekday() || conf.weekday; + switch (interval) { + case "millisecond": + bottomXAxis.ticks(millisecond.every(every)); + break; + case "second": + bottomXAxis.ticks(second.every(every)); + break; + case "minute": + bottomXAxis.ticks(timeMinute.every(every)); + break; + case "hour": + bottomXAxis.ticks(timeHour.every(every)); + break; + case "day": + bottomXAxis.ticks(timeDay.every(every)); + break; + case "week": + bottomXAxis.ticks(mapWeekdayToTimeFunction[weekday2].every(every)); + break; + case "month": + bottomXAxis.ticks(timeMonth.every(every)); + break; + } + } + svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + (h2 - 50) + ")").call(bottomXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10).attr("dy", "1em"); + if (diagObj.db.topAxisEnabled() || conf.topAxis) { + let topXAxis = axisTop(timeScale).tickSize(-h2 + theTopPad + conf.gridLineStartPadding).tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || "%Y-%m-%d")); + if (resultTickInterval !== null) { + const every = resultTickInterval[1]; + const interval = resultTickInterval[2]; + const weekday2 = diagObj.db.getWeekday() || conf.weekday; + switch (interval) { + case "millisecond": + topXAxis.ticks(millisecond.every(every)); + break; + case "second": + topXAxis.ticks(second.every(every)); + break; + case "minute": + topXAxis.ticks(timeMinute.every(every)); + break; + case "hour": + topXAxis.ticks(timeHour.every(every)); + break; + case "day": + topXAxis.ticks(timeDay.every(every)); + break; + case "week": + topXAxis.ticks(mapWeekdayToTimeFunction[weekday2].every(every)); + break; + case "month": + topXAxis.ticks(timeMonth.every(every)); + break; + } + } + svg.append("g").attr("class", "grid").attr("transform", "translate(" + theSidePad + ", " + theTopPad + ")").call(topXAxis).selectAll("text").style("text-anchor", "middle").attr("fill", "#000").attr("stroke", "none").attr("font-size", 10); + } + } + function vertLabels(theGap, theTopPad) { + let prevGap = 0; + const numOccurrences = Object.keys(categoryHeights).map((d) => [d, categoryHeights[d]]); + svg.append("g").selectAll("text").data(numOccurrences).enter().append(function(d) { + const rows = d[0].split(common$1.lineBreakRegex); + const dy = -(rows.length - 1) / 2; + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("dy", dy + "em"); + for (const [j, row] of rows.entries()) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttribute("alignment-baseline", "central"); + tspan.setAttribute("x", "10"); + if (j > 0) { + tspan.setAttribute("dy", "1em"); + } + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + return svgLabel; + }).attr("x", 10).attr("y", function(d, i) { + if (i > 0) { + for (let j = 0; j < i; j++) { + prevGap += numOccurrences[i - 1][1]; + return d[1] * theGap / 2 + prevGap * theGap + theTopPad; + } + } else { + return d[1] * theGap / 2 + theTopPad; + } + }).attr("font-size", conf.sectionFontSize).attr("class", function(d) { + for (const [i, category] of categories.entries()) { + if (d[0] === category) { + return "sectionTitle sectionTitle" + i % conf.numberSectionStyles; + } + } + return "sectionTitle"; + }); + } + function drawToday(theSidePad, theTopPad, w2, h2) { + const todayMarker2 = diagObj.db.getTodayMarker(); + if (todayMarker2 === "off") { + return; + } + const todayG = svg.append("g").attr("class", "today"); + const today = /* @__PURE__ */ new Date(); + const todayLine = todayG.append("line"); + todayLine.attr("x1", timeScale(today) + theSidePad).attr("x2", timeScale(today) + theSidePad).attr("y1", conf.titleTopMargin).attr("y2", h2 - conf.titleTopMargin).attr("class", "today"); + if (todayMarker2 !== "") { + todayLine.attr("style", todayMarker2.replace(/,/g, ";")); + } + } + function checkUnique(arr) { + const hash = {}; + const result = []; + for (let i = 0, l = arr.length; i < l; ++i) { + if (!Object.prototype.hasOwnProperty.call(hash, arr[i])) { + hash[arr[i]] = true; + result.push(arr[i]); + } + } + return result; + } +}; +const ganttRenderer = { + setConf: setConf$5, + draw: draw$g +}; +const getStyles$a = (options) => ` + .mermaid-main-font { + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .exclude-range { + fill: ${options.excludeBkgColor}; + } + + .section { + stroke: none; + opacity: 0.2; + } + + .section0 { + fill: ${options.sectionBkgColor}; + } + + .section2 { + fill: ${options.sectionBkgColor2}; + } + + .section1, + .section3 { + fill: ${options.altSectionBkgColor}; + opacity: 0.2; + } + + .sectionTitle0 { + fill: ${options.titleColor}; + } + + .sectionTitle1 { + fill: ${options.titleColor}; + } + + .sectionTitle2 { + fill: ${options.titleColor}; + } + + .sectionTitle3 { + fill: ${options.titleColor}; + } + + .sectionTitle { + text-anchor: start; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + + /* Grid and axis */ + + .grid .tick { + stroke: ${options.gridColor}; + opacity: 0.8; + shape-rendering: crispEdges; + } + + .grid .tick text { + font-family: ${options.fontFamily}; + fill: ${options.textColor}; + } + + .grid path { + stroke-width: 0; + } + + + /* Today line */ + + .today { + fill: none; + stroke: ${options.todayLineColor}; + stroke-width: 2px; + } + + + /* Task styling */ + + /* Default task */ + + .task { + stroke-width: 2; + } + + .taskText { + text-anchor: middle; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .taskTextOutsideRight { + fill: ${options.taskTextDarkColor}; + text-anchor: start; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } + + .taskTextOutsideLeft { + fill: ${options.taskTextDarkColor}; + text-anchor: end; + } + + + /* Special case clickable */ + + .task.clickable { + cursor: pointer; + } + + .taskText.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + .taskTextOutsideLeft.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + .taskTextOutsideRight.clickable { + cursor: pointer; + fill: ${options.taskTextClickableColor} !important; + font-weight: bold; + } + + + /* Specific task settings for the sections*/ + + .taskText0, + .taskText1, + .taskText2, + .taskText3 { + fill: ${options.taskTextColor}; + } + + .task0, + .task1, + .task2, + .task3 { + fill: ${options.taskBkgColor}; + stroke: ${options.taskBorderColor}; + } + + .taskTextOutside0, + .taskTextOutside2 + { + fill: ${options.taskTextOutsideColor}; + } + + .taskTextOutside1, + .taskTextOutside3 { + fill: ${options.taskTextOutsideColor}; + } + + + /* Active task */ + + .active0, + .active1, + .active2, + .active3 { + fill: ${options.activeTaskBkgColor}; + stroke: ${options.activeTaskBorderColor}; + } + + .activeText0, + .activeText1, + .activeText2, + .activeText3 { + fill: ${options.taskTextDarkColor} !important; + } + + + /* Completed task */ + + .done0, + .done1, + .done2, + .done3 { + stroke: ${options.doneTaskBorderColor}; + fill: ${options.doneTaskBkgColor}; + stroke-width: 2; + } + + .doneText0, + .doneText1, + .doneText2, + .doneText3 { + fill: ${options.taskTextDarkColor} !important; + } + + + /* Tasks on the critical line */ + + .crit0, + .crit1, + .crit2, + .crit3 { + stroke: ${options.critBorderColor}; + fill: ${options.critBkgColor}; + stroke-width: 2; + } + + .activeCrit0, + .activeCrit1, + .activeCrit2, + .activeCrit3 { + stroke: ${options.critBorderColor}; + fill: ${options.activeTaskBkgColor}; + stroke-width: 2; + } + + .doneCrit0, + .doneCrit1, + .doneCrit2, + .doneCrit3 { + stroke: ${options.critBorderColor}; + fill: ${options.doneTaskBkgColor}; + stroke-width: 2; + cursor: pointer; + shape-rendering: crispEdges; + } + + .milestone { + transform: rotate(45deg) scale(0.8,0.8); + } + + .milestoneText { + font-style: italic; + } + .doneCritText0, + .doneCritText1, + .doneCritText2, + .doneCritText3 { + fill: ${options.taskTextDarkColor} !important; + } + + .activeCritText0, + .activeCritText1, + .activeCritText2, + .activeCritText3 { + fill: ${options.taskTextDarkColor} !important; + } + + .titleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.titleColor || options.textColor}; + font-family: var(--mermaid-font-family, "trebuchet ms", verdana, arial, sans-serif); + } +`; +const ganttStyles = getStyles$a; +const diagram$g = { + parser: ganttParser, + db: ganttDb, + renderer: ganttRenderer, + styles: ganttStyles +}; + +var ganttDiagramB62c793e = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$g +}); + +var parser$d = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 9, 10]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "info": 4, "document": 5, "EOF": 6, "line": 7, "statement": 8, "NL": 9, "showInfo": 10, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "info", 6: "EOF", 9: "NL", 10: "showInfo" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 1], [7, 1], [8, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + $$.length - 1; + switch (yystate) { + case 1: + return yy; + case 4: + break; + case 6: + yy.setInfo(true); + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: 6, 9: [1, 7], 10: [1, 8] }, { 1: [2, 1] }, o($V0, [2, 3]), o($V0, [2, 4]), o($V0, [2, 5]), o($V0, [2, 6])], + defaultActions: { 4: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 4; + case 1: + return 9; + case 2: + return "space"; + case 3: + return 10; + case 4: + return 6; + case 5: + return "TXT"; + } + }, + rules: [/^(?:info\b)/i, /^(?:[\s\n\r]+)/i, /^(?:[\s]+)/i, /^(?:showInfo\b)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$d.parser = parser$d; +const parser$1$c = parser$d; +const DEFAULT_INFO_DB = { + info: false +}; +let info = DEFAULT_INFO_DB.info; +const setInfo$1 = (toggle) => { + info = toggle; +}; +const getInfo$1 = () => info; +const clear$c = () => { + info = DEFAULT_INFO_DB.info; +}; +const db$d = { + clear: clear$c, + setInfo: setInfo$1, + getInfo: getInfo$1 +}; +const draw$f = (text, id, version) => { + log$1.debug("rendering info diagram\n" + text); + const svg = selectSvgElement(id); + configureSvgSize(svg, 100, 400, true); + const group = svg.append("g"); + group.append("text").attr("x", 100).attr("y", 40).attr("class", "version").attr("font-size", 32).style("text-anchor", "middle").text(`v${version}`); +}; +const renderer$g = { draw: draw$f }; +const diagram$f = { + parser: parser$1$c, + db: db$d, + renderer: renderer$g +}; + +var infoDiagram94cd232f = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$f +}); + +var parser$c = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 10, 12, 14, 16, 18, 19, 20, 21, 22], $V5 = [2, 4], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 20, 21, 22], $V7 = [20, 21, 22], $V8 = [2, 7], $V9 = [1, 12], $Va = [1, 13], $Vb = [1, 14], $Vc = [1, 15], $Vd = [1, 16], $Ve = [1, 17]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "PIE": 5, "document": 6, "showData": 7, "line": 8, "statement": 9, "txt": 10, "value": 11, "title": 12, "title_value": 13, "acc_title": 14, "acc_title_value": 15, "acc_descr": 16, "acc_descr_value": 17, "acc_descr_multiline_value": 18, "section": 19, "NEWLINE": 20, ";": 21, "EOF": 22, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "PIE", 7: "showData", 10: "txt", 11: "value", 12: "title", 13: "title_value", 14: "acc_title", 15: "acc_title_value", 16: "acc_descr", 17: "acc_descr_value", 18: "acc_descr_multiline_value", 19: "section", 20: "NEWLINE", 21: ";", 22: "EOF" }, + productions_: [0, [3, 2], [3, 2], [3, 3], [6, 0], [6, 2], [8, 2], [9, 0], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [4, 1], [4, 1], [4, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setShowData(true); + break; + case 6: + this.$ = $$[$0 - 1]; + break; + case 8: + yy.addSection($$[$0 - 1], yy.cleanupValue($$[$0])); + break; + case 9: + this.$ = $$[$0].trim(); + yy.setDiagramTitle(this.$); + break; + case 10: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 11: + case 12: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 13: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 20: $V1, 21: $V2, 22: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 20: $V1, 21: $V2, 22: $V3 }, o($V4, $V5, { 6: 8, 7: [1, 9] }), o($V6, [2, 14]), o($V6, [2, 15]), o($V6, [2, 16]), { 1: [2, 1] }, o($V7, $V8, { 8: 10, 9: 11, 1: [2, 2], 10: $V9, 12: $Va, 14: $Vb, 16: $Vc, 18: $Vd, 19: $Ve }), o($V4, $V5, { 6: 18 }), o($V4, [2, 5]), { 4: 19, 20: $V1, 21: $V2, 22: $V3 }, { 11: [1, 20] }, { 13: [1, 21] }, { 15: [1, 22] }, { 17: [1, 23] }, o($V7, [2, 12]), o($V7, [2, 13]), o($V7, $V8, { 8: 10, 9: 11, 1: [2, 3], 10: $V9, 12: $Va, 14: $Vb, 16: $Vc, 18: $Vd, 19: $Ve }), o($V4, [2, 6]), o($V7, [2, 8]), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11])], + defaultActions: { 7: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 20; + case 3: + break; + case 4: + break; + case 5: + this.begin("title"); + return 12; + case 6: + this.popState(); + return "title_value"; + case 7: + this.begin("acc_title"); + return 14; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 16; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + this.begin("string"); + break; + case 15: + this.popState(); + break; + case 16: + return "txt"; + case 17: + return 5; + case 18: + return 7; + case 19: + return "value"; + case 20: + return 22; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:[\s]+)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:pie\b)/i, /^(?:showData\b)/i, /^(?::[\s]*[\d]+(?:\.[\d]+)?)/i, /^(?:$)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [6], "inclusive": false }, "string": { "rules": [15, 16], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 7, 9, 11, 14, 17, 18, 19, 20], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$c.parser = parser$c; +const parser$1$b = parser$c; +const DEFAULT_PIE_CONFIG = defaultConfig$2.pie; +const DEFAULT_PIE_DB = { + sections: {}, + showData: false, + config: DEFAULT_PIE_CONFIG +}; +let sections$2 = DEFAULT_PIE_DB.sections; +let showData = DEFAULT_PIE_DB.showData; +const config$2 = structuredClone(DEFAULT_PIE_CONFIG); +const getConfig = () => structuredClone(config$2); +const clear$b = () => { + sections$2 = structuredClone(DEFAULT_PIE_DB.sections); + showData = DEFAULT_PIE_DB.showData; + clear$k(); +}; +const addSection$2 = (label, value) => { + label = sanitizeText$2$1(label, getConfig$2()); + if (sections$2[label] === void 0) { + sections$2[label] = value; + log$1.debug(`added new section: ${label}, with value: ${value}`); + } +}; +const getSections$2 = () => sections$2; +const cleanupValue = (value) => { + if (value.substring(0, 1) === ":") { + value = value.substring(1).trim(); + } + return Number(value.trim()); +}; +const setShowData = (toggle) => { + showData = toggle; +}; +const getShowData = () => showData; +const db$c = { + getConfig, + clear: clear$b, + setDiagramTitle, + getDiagramTitle, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addSection: addSection$2, + getSections: getSections$2, + cleanupValue, + setShowData, + getShowData +}; +const getStyles$9 = (options) => ` + .pieCircle{ + stroke: ${options.pieStrokeColor}; + stroke-width : ${options.pieStrokeWidth}; + opacity : ${options.pieOpacity}; + } + .pieOuterCircle{ + stroke: ${options.pieOuterStrokeColor}; + stroke-width: ${options.pieOuterStrokeWidth}; + fill: none; + } + .pieTitleText { + text-anchor: middle; + font-size: ${options.pieTitleTextSize}; + fill: ${options.pieTitleTextColor}; + font-family: ${options.fontFamily}; + } + .slice { + font-family: ${options.fontFamily}; + fill: ${options.pieSectionTextColor}; + font-size:${options.pieSectionTextSize}; + // fill: white; + } + .legend text { + fill: ${options.pieLegendTextColor}; + font-family: ${options.fontFamily}; + font-size: ${options.pieLegendTextSize}; + } +`; +const styles$8 = getStyles$9; +const createPieArcs = (sections2) => { + const pieData = Object.entries(sections2).map((element) => { + return { + label: element[0], + value: element[1] + }; + }).sort((a, b) => { + return b.value - a.value; + }); + const pie$1$1 = pie$1().value( + (d3Section) => d3Section.value + ); + return pie$1$1(pieData); +}; +const draw$e = (text, id, _version, diagObj) => { + log$1.debug("rendering pie chart\n" + text); + const db2 = diagObj.db; + const globalConfig = getConfig$2(); + const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie); + const MARGIN = 40; + const LEGEND_RECT_SIZE = 18; + const LEGEND_SPACING = 4; + const height = 450; + const pieWidth = height; + const svg = selectSvgElement(id); + const group = svg.append("g"); + const sections2 = db2.getSections(); + group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")"); + const { themeVariables } = globalConfig; + let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth); + outerStrokeWidth ?? (outerStrokeWidth = 2); + const textPosition = pieConfig.textPosition; + const radius = Math.min(pieWidth, height) / 2 - MARGIN; + const arcGenerator = arc().innerRadius(0).outerRadius(radius); + const labelArcGenerator = arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition); + group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle"); + const arcs = createPieArcs(sections2); + const myGeneratedColors = [ + themeVariables.pie1, + themeVariables.pie2, + themeVariables.pie3, + themeVariables.pie4, + themeVariables.pie5, + themeVariables.pie6, + themeVariables.pie7, + themeVariables.pie8, + themeVariables.pie9, + themeVariables.pie10, + themeVariables.pie11, + themeVariables.pie12 + ]; + const color = ordinal(myGeneratedColors); + group.selectAll("mySlices").data(arcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => { + return color(datum.data.label); + }).attr("class", "pieCircle"); + let sum = 0; + Object.keys(sections2).forEach((key) => { + sum += sections2[key]; + }); + group.selectAll("mySlices").data(arcs).enter().append("text").text((datum) => { + return (datum.data.value / sum * 100).toFixed(0) + "%"; + }).attr("transform", (datum) => { + return "translate(" + labelArcGenerator.centroid(datum) + ")"; + }).style("text-anchor", "middle").attr("class", "slice"); + group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText"); + const legend = group.selectAll(".legend").data(color.domain()).enter().append("g").attr("class", "legend").attr("transform", (_datum, index) => { + const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING; + const offset = height2 * color.domain().length / 2; + const horizontal = 12 * LEGEND_RECT_SIZE; + const vertical = index * height2 - offset; + return "translate(" + horizontal + "," + vertical + ")"; + }); + legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", color).style("stroke", color); + legend.data(arcs).append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((datum) => { + const { label, value } = datum.data; + if (db2.getShowData()) { + return `${label} [${value}]`; + } + return label; + }); + const longestTextWidth = Math.max( + ...legend.selectAll("text").nodes().map((node) => (node == null ? void 0 : node.getBoundingClientRect().width) ?? 0) + ); + const totalWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth; + svg.attr("viewBox", `0 0 ${totalWidth} ${height}`); + configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth); +}; +const renderer$f = { draw: draw$e }; +const diagram$e = { + parser: parser$1$b, + db: db$c, + renderer: renderer$f, + styles: styles$8 +}; + +var pieDiagramBb1d19e5 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$e +}); + +var parser$b = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 7], $V5 = [1, 5, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V6 = [1, 5, 6, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V7 = [32, 33, 34], $V8 = [2, 7], $V9 = [1, 13], $Va = [1, 17], $Vb = [1, 18], $Vc = [1, 19], $Vd = [1, 20], $Ve = [1, 21], $Vf = [1, 22], $Vg = [1, 23], $Vh = [1, 24], $Vi = [1, 25], $Vj = [1, 26], $Vk = [1, 27], $Vl = [1, 30], $Vm = [1, 31], $Vn = [1, 32], $Vo = [1, 33], $Vp = [1, 34], $Vq = [1, 35], $Vr = [1, 36], $Vs = [1, 37], $Vt = [1, 38], $Vu = [1, 39], $Vv = [1, 40], $Vw = [1, 41], $Vx = [1, 42], $Vy = [1, 57], $Vz = [1, 58], $VA = [5, 22, 26, 32, 33, 34, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "SPACE": 5, "QUADRANT": 6, "document": 7, "line": 8, "statement": 9, "axisDetails": 10, "quadrantDetails": 11, "points": 12, "title": 13, "title_value": 14, "acc_title": 15, "acc_title_value": 16, "acc_descr": 17, "acc_descr_value": 18, "acc_descr_multiline_value": 19, "section": 20, "text": 21, "point_start": 22, "point_x": 23, "point_y": 24, "X-AXIS": 25, "AXIS-TEXT-DELIMITER": 26, "Y-AXIS": 27, "QUADRANT_1": 28, "QUADRANT_2": 29, "QUADRANT_3": 30, "QUADRANT_4": 31, "NEWLINE": 32, "SEMI": 33, "EOF": 34, "alphaNumToken": 35, "textNoTagsToken": 36, "STR": 37, "MD_STR": 38, "alphaNum": 39, "PUNCTUATION": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "COMMA": 44, "PLUS": 45, "EQUALS": 46, "MULT": 47, "DOT": 48, "BRKT": 49, "UNDERSCORE": 50, "MINUS": 51, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "SPACE", 6: "QUADRANT", 13: "title", 14: "title_value", 15: "acc_title", 16: "acc_title_value", 17: "acc_descr", 18: "acc_descr_value", 19: "acc_descr_multiline_value", 20: "section", 22: "point_start", 23: "point_x", 24: "point_y", 25: "X-AXIS", 26: "AXIS-TEXT-DELIMITER", 27: "Y-AXIS", 28: "QUADRANT_1", 29: "QUADRANT_2", 30: "QUADRANT_3", 31: "QUADRANT_4", 32: "NEWLINE", 33: "SEMI", 34: "EOF", 37: "STR", 38: "MD_STR", 40: "PUNCTUATION", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "COMMA", 45: "PLUS", 46: "EQUALS", 47: "MULT", 48: "DOT", 49: "BRKT", 50: "UNDERSCORE", 51: "MINUS" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [9, 0], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [12, 4], [10, 4], [10, 3], [10, 2], [10, 4], [10, 3], [10, 2], [11, 2], [11, 2], [11, 2], [11, 2], [4, 1], [4, 1], [4, 1], [21, 1], [21, 2], [21, 1], [21, 1], [39, 1], [39, 2], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [36, 1], [36, 1], [36, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 12: + this.$ = $$[$0].trim(); + yy.setDiagramTitle(this.$); + break; + case 13: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 14: + case 15: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 16: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 17: + yy.addPoint($$[$0 - 3], $$[$0 - 1], $$[$0]); + break; + case 18: + yy.setXAxisLeftText($$[$0 - 2]); + yy.setXAxisRightText($$[$0]); + break; + case 19: + $$[$0 - 1].text += " ⟶ "; + yy.setXAxisLeftText($$[$0 - 1]); + break; + case 20: + yy.setXAxisLeftText($$[$0]); + break; + case 21: + yy.setYAxisBottomText($$[$0 - 2]); + yy.setYAxisTopText($$[$0]); + break; + case 22: + $$[$0 - 1].text += " ⟶ "; + yy.setYAxisBottomText($$[$0 - 1]); + break; + case 23: + yy.setYAxisBottomText($$[$0]); + break; + case 24: + yy.setQuadrant1Text($$[$0]); + break; + case 25: + yy.setQuadrant2Text($$[$0]); + break; + case 26: + yy.setQuadrant3Text($$[$0]); + break; + case 27: + yy.setQuadrant4Text($$[$0]); + break; + case 31: + this.$ = { text: $$[$0], type: "text" }; + break; + case 32: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 33: + this.$ = { text: $$[$0], type: "text" }; + break; + case 34: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 35: + this.$ = $$[$0]; + break; + case 36: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 1: [3] }, { 3: 8, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 3: 9, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, o($V5, [2, 4], { 7: 10 }), o($V6, [2, 28]), o($V6, [2, 29]), o($V6, [2, 30]), { 1: [2, 1] }, { 1: [2, 2] }, o($V7, $V8, { 8: 11, 9: 12, 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 1: [2, 3], 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V5, [2, 5]), { 4: 43, 32: $V2, 33: $V3, 34: $V4 }, o($V7, $V8, { 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 9: 44, 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11]), { 14: [1, 45] }, { 16: [1, 46] }, { 18: [1, 47] }, o($V7, [2, 15]), o($V7, [2, 16]), { 21: 48, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 49, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 50, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 51, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 52, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 53, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 5: $Vy, 22: [1, 54], 35: 56, 36: 55, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }, o($VA, [2, 31]), o($VA, [2, 33]), o($VA, [2, 34]), o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), o($VA, [2, 40]), o($VA, [2, 41]), o($VA, [2, 42]), o($VA, [2, 43]), o($VA, [2, 44]), o($VA, [2, 45]), o($VA, [2, 46]), o($VA, [2, 47]), o($V5, [2, 6]), o($V7, [2, 8]), o($V7, [2, 12]), o($V7, [2, 13]), o($V7, [2, 14]), o($V7, [2, 20], { 36: 55, 35: 56, 5: $Vy, 26: [1, 59], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 23], { 36: 55, 35: 56, 5: $Vy, 26: [1, 60], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 24], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 25], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 26], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 27], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), { 23: [1, 61] }, o($VA, [2, 32]), o($VA, [2, 48]), o($VA, [2, 49]), o($VA, [2, 50]), o($V7, [2, 19], { 35: 29, 21: 62, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 22], { 35: 29, 21: 63, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), { 24: [1, 64] }, o($V7, [2, 18], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 21], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 17])], + defaultActions: { 8: [2, 1], 9: [2, 2] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 32; + case 3: + break; + case 4: + this.begin("title"); + return 13; + case 5: + this.popState(); + return "title_value"; + case 6: + this.begin("acc_title"); + return 15; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 17; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + return 25; + case 14: + return 27; + case 15: + return 26; + case 16: + return 28; + case 17: + return 29; + case 18: + return 30; + case 19: + return 31; + case 20: + this.begin("md_string"); + break; + case 21: + return "MD_STR"; + case 22: + this.popState(); + break; + case 23: + this.begin("string"); + break; + case 24: + this.popState(); + break; + case 25: + return "STR"; + case 26: + this.begin("point_start"); + return 22; + case 27: + this.begin("point_x"); + return 23; + case 28: + this.popState(); + break; + case 29: + this.popState(); + this.begin("point_y"); + break; + case 30: + this.popState(); + return 24; + case 31: + return 6; + case 32: + return 43; + case 33: + return "COLON"; + case 34: + return 45; + case 35: + return 44; + case 36: + return 46; + case 37: + return 46; + case 38: + return 47; + case 39: + return 49; + case 40: + return 50; + case 41: + return 48; + case 42: + return 41; + case 43: + return 51; + case 44: + return 42; + case 45: + return 5; + case 46: + return 33; + case 47: + return 40; + case 48: + return 34; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?: *x-axis *)/i, /^(?: *y-axis *)/i, /^(?: *--+> *)/i, /^(?: *quadrant-1 *)/i, /^(?: *quadrant-2 *)/i, /^(?: *quadrant-3 *)/i, /^(?: *quadrant-4 *)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\s*:\s*\[\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?:\s*\] *)/i, /^(?:\s*,\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?: *quadrantChart *)/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s)/i, /^(?:;)/i, /^(?:[!"#$%&'*+,-.`?\\_/])/i, /^(?:$)/i], + conditions: { "point_y": { "rules": [30], "inclusive": false }, "point_x": { "rules": [29], "inclusive": false }, "point_start": { "rules": [27, 28], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "title": { "rules": [5], "inclusive": false }, "md_string": { "rules": [21, 22], "inclusive": false }, "string": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 23, 26, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$b.parser = parser$b; +const parser$1$a = parser$b; +const defaultThemeVariables = getThemeVariables$2(); +class QuadrantBuilder { + constructor() { + this.config = this.getDefaultConfig(); + this.themeConfig = this.getDefaultThemeConfig(); + this.data = this.getDefaultData(); + } + getDefaultData() { + return { + titleText: "", + quadrant1Text: "", + quadrant2Text: "", + quadrant3Text: "", + quadrant4Text: "", + xAxisLeftText: "", + xAxisRightText: "", + yAxisBottomText: "", + yAxisTopText: "", + points: [] + }; + } + getDefaultConfig() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r; + return { + showXAxis: true, + showYAxis: true, + showTitle: true, + chartHeight: ((_a = defaultConfig$2.quadrantChart) == null ? void 0 : _a.chartWidth) || 500, + chartWidth: ((_b = defaultConfig$2.quadrantChart) == null ? void 0 : _b.chartHeight) || 500, + titlePadding: ((_c = defaultConfig$2.quadrantChart) == null ? void 0 : _c.titlePadding) || 10, + titleFontSize: ((_d = defaultConfig$2.quadrantChart) == null ? void 0 : _d.titleFontSize) || 20, + quadrantPadding: ((_e = defaultConfig$2.quadrantChart) == null ? void 0 : _e.quadrantPadding) || 5, + xAxisLabelPadding: ((_f = defaultConfig$2.quadrantChart) == null ? void 0 : _f.xAxisLabelPadding) || 5, + yAxisLabelPadding: ((_g = defaultConfig$2.quadrantChart) == null ? void 0 : _g.yAxisLabelPadding) || 5, + xAxisLabelFontSize: ((_h = defaultConfig$2.quadrantChart) == null ? void 0 : _h.xAxisLabelFontSize) || 16, + yAxisLabelFontSize: ((_i = defaultConfig$2.quadrantChart) == null ? void 0 : _i.yAxisLabelFontSize) || 16, + quadrantLabelFontSize: ((_j = defaultConfig$2.quadrantChart) == null ? void 0 : _j.quadrantLabelFontSize) || 16, + quadrantTextTopPadding: ((_k = defaultConfig$2.quadrantChart) == null ? void 0 : _k.quadrantTextTopPadding) || 5, + pointTextPadding: ((_l = defaultConfig$2.quadrantChart) == null ? void 0 : _l.pointTextPadding) || 5, + pointLabelFontSize: ((_m = defaultConfig$2.quadrantChart) == null ? void 0 : _m.pointLabelFontSize) || 12, + pointRadius: ((_n = defaultConfig$2.quadrantChart) == null ? void 0 : _n.pointRadius) || 5, + xAxisPosition: ((_o = defaultConfig$2.quadrantChart) == null ? void 0 : _o.xAxisPosition) || "top", + yAxisPosition: ((_p = defaultConfig$2.quadrantChart) == null ? void 0 : _p.yAxisPosition) || "left", + quadrantInternalBorderStrokeWidth: ((_q = defaultConfig$2.quadrantChart) == null ? void 0 : _q.quadrantInternalBorderStrokeWidth) || 1, + quadrantExternalBorderStrokeWidth: ((_r = defaultConfig$2.quadrantChart) == null ? void 0 : _r.quadrantExternalBorderStrokeWidth) || 2 + }; + } + getDefaultThemeConfig() { + return { + quadrant1Fill: defaultThemeVariables.quadrant1Fill, + quadrant2Fill: defaultThemeVariables.quadrant2Fill, + quadrant3Fill: defaultThemeVariables.quadrant3Fill, + quadrant4Fill: defaultThemeVariables.quadrant4Fill, + quadrant1TextFill: defaultThemeVariables.quadrant1TextFill, + quadrant2TextFill: defaultThemeVariables.quadrant2TextFill, + quadrant3TextFill: defaultThemeVariables.quadrant3TextFill, + quadrant4TextFill: defaultThemeVariables.quadrant4TextFill, + quadrantPointFill: defaultThemeVariables.quadrantPointFill, + quadrantPointTextFill: defaultThemeVariables.quadrantPointTextFill, + quadrantXAxisTextFill: defaultThemeVariables.quadrantXAxisTextFill, + quadrantYAxisTextFill: defaultThemeVariables.quadrantYAxisTextFill, + quadrantTitleFill: defaultThemeVariables.quadrantTitleFill, + quadrantInternalBorderStrokeFill: defaultThemeVariables.quadrantInternalBorderStrokeFill, + quadrantExternalBorderStrokeFill: defaultThemeVariables.quadrantExternalBorderStrokeFill + }; + } + clear() { + this.config = this.getDefaultConfig(); + this.themeConfig = this.getDefaultThemeConfig(); + this.data = this.getDefaultData(); + log$1.info("clear called"); + } + setData(data) { + this.data = { ...this.data, ...data }; + } + addPoints(points) { + this.data.points = [...points, ...this.data.points]; + } + setConfig(config2) { + log$1.trace("setConfig called with: ", config2); + this.config = { ...this.config, ...config2 }; + } + setThemeConfig(themeConfig) { + log$1.trace("setThemeConfig called with: ", themeConfig); + this.themeConfig = { ...this.themeConfig, ...themeConfig }; + } + calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle) { + const xAxisSpaceCalculation = this.config.xAxisLabelPadding * 2 + this.config.xAxisLabelFontSize; + const xAxisSpace = { + top: xAxisPosition === "top" && showXAxis ? xAxisSpaceCalculation : 0, + bottom: xAxisPosition === "bottom" && showXAxis ? xAxisSpaceCalculation : 0 + }; + const yAxisSpaceCalculation = this.config.yAxisLabelPadding * 2 + this.config.yAxisLabelFontSize; + const yAxisSpace = { + left: this.config.yAxisPosition === "left" && showYAxis ? yAxisSpaceCalculation : 0, + right: this.config.yAxisPosition === "right" && showYAxis ? yAxisSpaceCalculation : 0 + }; + const titleSpaceCalculation = this.config.titleFontSize + this.config.titlePadding * 2; + const titleSpace = { + top: showTitle ? titleSpaceCalculation : 0 + }; + const quadrantLeft = this.config.quadrantPadding + yAxisSpace.left; + const quadrantTop = this.config.quadrantPadding + xAxisSpace.top + titleSpace.top; + const quadrantWidth = this.config.chartWidth - this.config.quadrantPadding * 2 - yAxisSpace.left - yAxisSpace.right; + const quadrantHeight = this.config.chartHeight - this.config.quadrantPadding * 2 - xAxisSpace.top - xAxisSpace.bottom - titleSpace.top; + const quadrantHalfWidth = quadrantWidth / 2; + const quadrantHalfHeight = quadrantHeight / 2; + const quadrantSpace = { + quadrantLeft, + quadrantTop, + quadrantWidth, + quadrantHalfWidth, + quadrantHeight, + quadrantHalfHeight + }; + return { + xAxisSpace, + yAxisSpace, + titleSpace, + quadrantSpace + }; + } + getAxisLabels(xAxisPosition, showXAxis, showYAxis, spaceData) { + const { quadrantSpace, titleSpace } = spaceData; + const { + quadrantHalfHeight, + quadrantHeight, + quadrantLeft, + quadrantHalfWidth, + quadrantTop, + quadrantWidth + } = quadrantSpace; + const drawXAxisLabelsInMiddle = Boolean(this.data.xAxisRightText); + const drawYAxisLabelsInMiddle = Boolean(this.data.yAxisTopText); + const axisLabels = []; + if (this.data.xAxisLeftText && showXAxis) { + axisLabels.push({ + text: this.data.xAxisLeftText, + fill: this.themeConfig.quadrantXAxisTextFill, + x: quadrantLeft + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0), + y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding, + fontSize: this.config.xAxisLabelFontSize, + verticalPos: drawXAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: 0 + }); + } + if (this.data.xAxisRightText && showXAxis) { + axisLabels.push({ + text: this.data.xAxisRightText, + fill: this.themeConfig.quadrantXAxisTextFill, + x: quadrantLeft + quadrantHalfWidth + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0), + y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding, + fontSize: this.config.xAxisLabelFontSize, + verticalPos: drawXAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: 0 + }); + } + if (this.data.yAxisBottomText && showYAxis) { + axisLabels.push({ + text: this.data.yAxisBottomText, + fill: this.themeConfig.quadrantYAxisTextFill, + x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding, + y: quadrantTop + quadrantHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0), + fontSize: this.config.yAxisLabelFontSize, + verticalPos: drawYAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: -90 + }); + } + if (this.data.yAxisTopText && showYAxis) { + axisLabels.push({ + text: this.data.yAxisTopText, + fill: this.themeConfig.quadrantYAxisTextFill, + x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding, + y: quadrantTop + quadrantHalfHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0), + fontSize: this.config.yAxisLabelFontSize, + verticalPos: drawYAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: -90 + }); + } + return axisLabels; + } + getQuadrants(spaceData) { + const { quadrantSpace } = spaceData; + const { quadrantHalfHeight, quadrantLeft, quadrantHalfWidth, quadrantTop } = quadrantSpace; + const quadrants = [ + { + text: { + text: this.data.quadrant1Text, + fill: this.themeConfig.quadrant1TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft + quadrantHalfWidth, + y: quadrantTop, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant1Fill + }, + { + text: { + text: this.data.quadrant2Text, + fill: this.themeConfig.quadrant2TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft, + y: quadrantTop, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant2Fill + }, + { + text: { + text: this.data.quadrant3Text, + fill: this.themeConfig.quadrant3TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft, + y: quadrantTop + quadrantHalfHeight, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant3Fill + }, + { + text: { + text: this.data.quadrant4Text, + fill: this.themeConfig.quadrant4TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft + quadrantHalfWidth, + y: quadrantTop + quadrantHalfHeight, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant4Fill + } + ]; + for (const quadrant of quadrants) { + quadrant.text.x = quadrant.x + quadrant.width / 2; + if (this.data.points.length === 0) { + quadrant.text.y = quadrant.y + quadrant.height / 2; + quadrant.text.horizontalPos = "middle"; + } else { + quadrant.text.y = quadrant.y + this.config.quadrantTextTopPadding; + quadrant.text.horizontalPos = "top"; + } + } + return quadrants; + } + getQuadrantPoints(spaceData) { + const { quadrantSpace } = spaceData; + const { quadrantHeight, quadrantLeft, quadrantTop, quadrantWidth } = quadrantSpace; + const xAxis = linear().domain([0, 1]).range([quadrantLeft, quadrantWidth + quadrantLeft]); + const yAxis = linear().domain([0, 1]).range([quadrantHeight + quadrantTop, quadrantTop]); + const points = this.data.points.map((point) => { + const props = { + x: xAxis(point.x), + y: yAxis(point.y), + fill: this.themeConfig.quadrantPointFill, + radius: this.config.pointRadius, + text: { + text: point.text, + fill: this.themeConfig.quadrantPointTextFill, + x: xAxis(point.x), + y: yAxis(point.y) + this.config.pointTextPadding, + verticalPos: "center", + horizontalPos: "top", + fontSize: this.config.pointLabelFontSize, + rotation: 0 + } + }; + return props; + }); + return points; + } + getBorders(spaceData) { + const halfExternalBorderWidth = this.config.quadrantExternalBorderStrokeWidth / 2; + const { quadrantSpace } = spaceData; + const { + quadrantHalfHeight, + quadrantHeight, + quadrantLeft, + quadrantHalfWidth, + quadrantTop, + quadrantWidth + } = quadrantSpace; + const borderLines = [ + // top border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft - halfExternalBorderWidth, + y1: quadrantTop, + x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth, + y2: quadrantTop + }, + // right border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft + quadrantWidth, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft + quadrantWidth, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // bottom border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft - halfExternalBorderWidth, + y1: quadrantTop + quadrantHeight, + x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth, + y2: quadrantTop + quadrantHeight + }, + // left border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // vertical inner border + { + strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill, + strokeWidth: this.config.quadrantInternalBorderStrokeWidth, + x1: quadrantLeft + quadrantHalfWidth, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft + quadrantHalfWidth, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // horizontal inner border + { + strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill, + strokeWidth: this.config.quadrantInternalBorderStrokeWidth, + x1: quadrantLeft + halfExternalBorderWidth, + y1: quadrantTop + quadrantHalfHeight, + x2: quadrantLeft + quadrantWidth - halfExternalBorderWidth, + y2: quadrantTop + quadrantHalfHeight + } + ]; + return borderLines; + } + getTitle(showTitle) { + if (showTitle) { + return { + text: this.data.titleText, + fill: this.themeConfig.quadrantTitleFill, + fontSize: this.config.titleFontSize, + horizontalPos: "top", + verticalPos: "center", + rotation: 0, + y: this.config.titlePadding, + x: this.config.chartWidth / 2 + }; + } + return; + } + build() { + const showXAxis = this.config.showXAxis && !!(this.data.xAxisLeftText || this.data.xAxisRightText); + const showYAxis = this.config.showYAxis && !!(this.data.yAxisTopText || this.data.yAxisBottomText); + const showTitle = this.config.showTitle && !!this.data.titleText; + const xAxisPosition = this.data.points.length > 0 ? "bottom" : this.config.xAxisPosition; + const calculatedSpace = this.calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle); + return { + points: this.getQuadrantPoints(calculatedSpace), + quadrants: this.getQuadrants(calculatedSpace), + axisLabels: this.getAxisLabels(xAxisPosition, showXAxis, showYAxis, calculatedSpace), + borderLines: this.getBorders(calculatedSpace), + title: this.getTitle(showTitle) + }; + } +} +const config$1 = getConfig$2(); +function textSanitizer$1(text) { + return sanitizeText$2$1(text.trim(), config$1); +} +const quadrantBuilder = new QuadrantBuilder(); +function setQuadrant1Text(textObj) { + quadrantBuilder.setData({ quadrant1Text: textSanitizer$1(textObj.text) }); +} +function setQuadrant2Text(textObj) { + quadrantBuilder.setData({ quadrant2Text: textSanitizer$1(textObj.text) }); +} +function setQuadrant3Text(textObj) { + quadrantBuilder.setData({ quadrant3Text: textSanitizer$1(textObj.text) }); +} +function setQuadrant4Text(textObj) { + quadrantBuilder.setData({ quadrant4Text: textSanitizer$1(textObj.text) }); +} +function setXAxisLeftText(textObj) { + quadrantBuilder.setData({ xAxisLeftText: textSanitizer$1(textObj.text) }); +} +function setXAxisRightText(textObj) { + quadrantBuilder.setData({ xAxisRightText: textSanitizer$1(textObj.text) }); +} +function setYAxisTopText(textObj) { + quadrantBuilder.setData({ yAxisTopText: textSanitizer$1(textObj.text) }); +} +function setYAxisBottomText(textObj) { + quadrantBuilder.setData({ yAxisBottomText: textSanitizer$1(textObj.text) }); +} +function addPoint(textObj, x, y) { + quadrantBuilder.addPoints([{ x, y, text: textSanitizer$1(textObj.text) }]); +} +function setWidth(width) { + quadrantBuilder.setConfig({ chartWidth: width }); +} +function setHeight(height) { + quadrantBuilder.setConfig({ chartHeight: height }); +} +function getQuadrantData() { + const config2 = getConfig$2(); + const { themeVariables, quadrantChart: quadrantChartConfig } = config2; + if (quadrantChartConfig) { + quadrantBuilder.setConfig(quadrantChartConfig); + } + quadrantBuilder.setThemeConfig({ + quadrant1Fill: themeVariables.quadrant1Fill, + quadrant2Fill: themeVariables.quadrant2Fill, + quadrant3Fill: themeVariables.quadrant3Fill, + quadrant4Fill: themeVariables.quadrant4Fill, + quadrant1TextFill: themeVariables.quadrant1TextFill, + quadrant2TextFill: themeVariables.quadrant2TextFill, + quadrant3TextFill: themeVariables.quadrant3TextFill, + quadrant4TextFill: themeVariables.quadrant4TextFill, + quadrantPointFill: themeVariables.quadrantPointFill, + quadrantPointTextFill: themeVariables.quadrantPointTextFill, + quadrantXAxisTextFill: themeVariables.quadrantXAxisTextFill, + quadrantYAxisTextFill: themeVariables.quadrantYAxisTextFill, + quadrantExternalBorderStrokeFill: themeVariables.quadrantExternalBorderStrokeFill, + quadrantInternalBorderStrokeFill: themeVariables.quadrantInternalBorderStrokeFill, + quadrantTitleFill: themeVariables.quadrantTitleFill + }); + quadrantBuilder.setData({ titleText: getDiagramTitle() }); + return quadrantBuilder.build(); +} +const clear$a = function() { + quadrantBuilder.clear(); + clear$k(); +}; +const db$b = { + setWidth, + setHeight, + setQuadrant1Text, + setQuadrant2Text, + setQuadrant3Text, + setQuadrant4Text, + setXAxisLeftText, + setXAxisRightText, + setYAxisTopText, + setYAxisBottomText, + addPoint, + getQuadrantData, + clear: clear$a, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + getAccDescription, + setAccDescription +}; +const draw$d = (txt, id, _version, diagObj) => { + var _a, _b, _c; + function getDominantBaseLine(horizontalPos) { + return horizontalPos === "top" ? "hanging" : "middle"; + } + function getTextAnchor(verticalPos) { + return verticalPos === "left" ? "start" : "middle"; + } + function getTransformation(data) { + return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`; + } + const conf = getConfig$2(); + log$1.debug("Rendering quadrant chart\n" + txt); + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const group = svg.append("g").attr("class", "main"); + const width = ((_a = conf.quadrantChart) == null ? void 0 : _a.chartWidth) || 500; + const height = ((_b = conf.quadrantChart) == null ? void 0 : _b.chartHeight) || 500; + configureSvgSize(svg, height, width, ((_c = conf.quadrantChart) == null ? void 0 : _c.useMaxWidth) || true); + svg.attr("viewBox", "0 0 " + width + " " + height); + diagObj.db.setHeight(height); + diagObj.db.setWidth(width); + const quadrantData = diagObj.db.getQuadrantData(); + const quadrantsGroup = group.append("g").attr("class", "quadrants"); + const borderGroup = group.append("g").attr("class", "border"); + const dataPointGroup = group.append("g").attr("class", "data-points"); + const labelGroup = group.append("g").attr("class", "labels"); + const titleGroup = group.append("g").attr("class", "title"); + if (quadrantData.title) { + titleGroup.append("text").attr("x", 0).attr("y", 0).attr("fill", quadrantData.title.fill).attr("font-size", quadrantData.title.fontSize).attr("dominant-baseline", getDominantBaseLine(quadrantData.title.horizontalPos)).attr("text-anchor", getTextAnchor(quadrantData.title.verticalPos)).attr("transform", getTransformation(quadrantData.title)).text(quadrantData.title.text); + } + if (quadrantData.borderLines) { + borderGroup.selectAll("line").data(quadrantData.borderLines).enter().append("line").attr("x1", (data) => data.x1).attr("y1", (data) => data.y1).attr("x2", (data) => data.x2).attr("y2", (data) => data.y2).style("stroke", (data) => data.strokeFill).style("stroke-width", (data) => data.strokeWidth); + } + const quadrants = quadrantsGroup.selectAll("g.quadrant").data(quadrantData.quadrants).enter().append("g").attr("class", "quadrant"); + quadrants.append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill); + quadrants.append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr( + "dominant-baseline", + (data) => getDominantBaseLine(data.text.horizontalPos) + ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)).text((data) => data.text.text); + const labels = labelGroup.selectAll("g.label").data(quadrantData.axisLabels).enter().append("g").attr("class", "label"); + labels.append("text").attr("x", 0).attr("y", 0).text((data) => data.text).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.horizontalPos)).attr("text-anchor", (data) => getTextAnchor(data.verticalPos)).attr("transform", (data) => getTransformation(data)); + const dataPoints = dataPointGroup.selectAll("g.data-point").data(quadrantData.points).enter().append("g").attr("class", "data-point"); + dataPoints.append("circle").attr("cx", (data) => data.x).attr("cy", (data) => data.y).attr("r", (data) => data.radius).attr("fill", (data) => data.fill); + dataPoints.append("text").attr("x", 0).attr("y", 0).text((data) => data.text.text).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr( + "dominant-baseline", + (data) => getDominantBaseLine(data.text.horizontalPos) + ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)); +}; +const renderer$e = { + draw: draw$d +}; +const diagram$d = { + parser: parser$1$a, + db: db$b, + renderer: renderer$e, + styles: () => "" +}; + +var quadrantDiagramC759a472 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$d +}); + +var parser$a = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 10, 12, 14, 16, 18, 19, 21, 23], $V1 = [2, 6], $V2 = [1, 3], $V3 = [1, 5], $V4 = [1, 6], $V5 = [1, 7], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $V7 = [1, 25], $V8 = [1, 26], $V9 = [1, 28], $Va = [1, 29], $Vb = [1, 30], $Vc = [1, 31], $Vd = [1, 32], $Ve = [1, 33], $Vf = [1, 34], $Vg = [1, 35], $Vh = [1, 36], $Vi = [1, 37], $Vj = [1, 43], $Vk = [1, 42], $Vl = [1, 47], $Vm = [1, 50], $Vn = [1, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $Vo = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36], $Vp = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $Vq = [1, 64]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "XYCHART": 5, "chartConfig": 6, "document": 7, "CHART_ORIENTATION": 8, "statement": 9, "title": 10, "text": 11, "X_AXIS": 12, "parseXAxis": 13, "Y_AXIS": 14, "parseYAxis": 15, "LINE": 16, "plotData": 17, "BAR": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "SQUARE_BRACES_START": 24, "commaSeparatedNumbers": 25, "SQUARE_BRACES_END": 26, "NUMBER_WITH_DECIMAL": 27, "COMMA": 28, "xAxisData": 29, "bandData": 30, "ARROW_DELIMITER": 31, "commaSeparatedTexts": 32, "yAxisData": 33, "NEWLINE": 34, "SEMI": 35, "EOF": 36, "alphaNum": 37, "STR": 38, "MD_STR": 39, "alphaNumToken": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "PLUS": 44, "EQUALS": 45, "MULT": 46, "DOT": 47, "BRKT": 48, "MINUS": 49, "UNDERSCORE": 50, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "XYCHART", 8: "CHART_ORIENTATION", 10: "title", 12: "X_AXIS", 14: "Y_AXIS", 16: "LINE", 18: "BAR", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "SQUARE_BRACES_START", 26: "SQUARE_BRACES_END", 27: "NUMBER_WITH_DECIMAL", 28: "COMMA", 31: "ARROW_DELIMITER", 34: "NEWLINE", 35: "SEMI", 36: "EOF", 38: "STR", 39: "MD_STR", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "PLUS", 45: "EQUALS", 46: "MULT", 47: "DOT", 48: "BRKT", 49: "MINUS", 50: "UNDERSCORE" }, + productions_: [0, [3, 2], [3, 3], [3, 2], [3, 1], [6, 1], [7, 0], [7, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 3], [9, 2], [9, 3], [9, 2], [9, 2], [9, 1], [17, 3], [25, 3], [25, 1], [13, 1], [13, 2], [13, 1], [29, 1], [29, 3], [30, 3], [32, 3], [32, 1], [15, 1], [15, 2], [15, 1], [33, 3], [4, 1], [4, 1], [4, 1], [11, 1], [11, 1], [11, 1], [37, 1], [37, 2], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 5: + yy.setOrientation($$[$0]); + break; + case 9: + yy.setDiagramTitle($$[$0].text.trim()); + break; + case 12: + yy.setLineData({ text: "", type: "text" }, $$[$0]); + break; + case 13: + yy.setLineData($$[$0 - 1], $$[$0]); + break; + case 14: + yy.setBarData({ text: "", type: "text" }, $$[$0]); + break; + case 15: + yy.setBarData($$[$0 - 1], $$[$0]); + break; + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + this.$ = $$[$0 - 1]; + break; + case 20: + this.$ = [Number($$[$0 - 2]), ...$$[$0]]; + break; + case 21: + this.$ = [Number($$[$0])]; + break; + case 22: + yy.setXAxisTitle($$[$0]); + break; + case 23: + yy.setXAxisTitle($$[$0 - 1]); + break; + case 24: + yy.setXAxisTitle({ type: "text", text: "" }); + break; + case 25: + yy.setXAxisBand($$[$0]); + break; + case 26: + yy.setXAxisRangeData(Number($$[$0 - 2]), Number($$[$0])); + break; + case 27: + this.$ = $$[$0 - 1]; + break; + case 28: + this.$ = [$$[$0 - 2], ...$$[$0]]; + break; + case 29: + this.$ = [$$[$0]]; + break; + case 30: + yy.setYAxisTitle($$[$0]); + break; + case 31: + yy.setYAxisTitle($$[$0 - 1]); + break; + case 32: + yy.setYAxisTitle({ type: "text", text: "" }); + break; + case 33: + yy.setYAxisRangeData(Number($$[$0 - 2]), Number($$[$0])); + break; + case 37: + this.$ = { text: $$[$0], type: "text" }; + break; + case 38: + this.$ = { text: $$[$0], type: "text" }; + break; + case 39: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 40: + this.$ = $$[$0]; + break; + case 41: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + } + }, + table: [o($V0, $V1, { 3: 1, 4: 2, 7: 4, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [3] }, o($V0, $V1, { 4: 2, 7: 4, 3: 8, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), o($V0, $V1, { 4: 2, 7: 4, 6: 9, 3: 10, 5: $V2, 8: [1, 11], 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 4], 9: 12, 10: [1, 13], 12: [1, 14], 14: [1, 15], 16: [1, 16], 18: [1, 17], 19: [1, 18], 21: [1, 19], 23: [1, 20] }, o($V6, [2, 34]), o($V6, [2, 35]), o($V6, [2, 36]), { 1: [2, 1] }, o($V0, $V1, { 4: 2, 7: 4, 3: 21, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 3] }, o($V6, [2, 5]), o($V0, [2, 7], { 4: 22, 34: $V3, 35: $V4, 36: $V5 }), { 11: 23, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 39, 13: 38, 24: $Vj, 27: $Vk, 29: 40, 30: 41, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 45, 15: 44, 27: $Vl, 33: 46, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 49, 17: 48, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 52, 17: 51, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 20: [1, 53] }, { 22: [1, 54] }, o($Vn, [2, 18]), { 1: [2, 2] }, o($Vn, [2, 8]), o($Vn, [2, 9]), o($Vo, [2, 37], { 40: 55, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }), o($Vo, [2, 38]), o($Vo, [2, 39]), o($Vp, [2, 40]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), o($Vp, [2, 47]), o($Vp, [2, 48]), o($Vp, [2, 49]), o($Vp, [2, 50]), o($Vp, [2, 51]), o($Vn, [2, 10]), o($Vn, [2, 22], { 30: 41, 29: 56, 24: $Vj, 27: $Vk }), o($Vn, [2, 24]), o($Vn, [2, 25]), { 31: [1, 57] }, { 11: 59, 32: 58, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 11]), o($Vn, [2, 30], { 33: 60, 27: $Vl }), o($Vn, [2, 32]), { 31: [1, 61] }, o($Vn, [2, 12]), { 17: 62, 24: $Vm }, { 25: 63, 27: $Vq }, o($Vn, [2, 14]), { 17: 65, 24: $Vm }, o($Vn, [2, 16]), o($Vn, [2, 17]), o($Vp, [2, 41]), o($Vn, [2, 23]), { 27: [1, 66] }, { 26: [1, 67] }, { 26: [2, 29], 28: [1, 68] }, o($Vn, [2, 31]), { 27: [1, 69] }, o($Vn, [2, 13]), { 26: [1, 70] }, { 26: [2, 21], 28: [1, 71] }, o($Vn, [2, 15]), o($Vn, [2, 26]), o($Vn, [2, 27]), { 11: 59, 32: 72, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 33]), o($Vn, [2, 19]), { 25: 73, 27: $Vq }, { 26: [2, 28] }, { 26: [2, 20] }], + defaultActions: { 8: [2, 1], 10: [2, 3], 21: [2, 2], 72: [2, 28], 73: [2, 20] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + this.popState(); + return 34; + case 3: + this.popState(); + return 34; + case 4: + return 34; + case 5: + break; + case 6: + return 10; + case 7: + this.pushState("acc_title"); + return 19; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.pushState("acc_descr"); + return 21; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.pushState("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 5; + case 15: + return 8; + case 16: + this.pushState("axis_data"); + return "X_AXIS"; + case 17: + this.pushState("axis_data"); + return "Y_AXIS"; + case 18: + this.pushState("axis_band_data"); + return 24; + case 19: + return 31; + case 20: + this.pushState("data"); + return 16; + case 21: + this.pushState("data"); + return 18; + case 22: + this.pushState("data_inner"); + return 24; + case 23: + return 27; + case 24: + this.popState(); + return 26; + case 25: + this.popState(); + break; + case 26: + this.pushState("string"); + break; + case 27: + this.popState(); + break; + case 28: + return "STR"; + case 29: + return 24; + case 30: + return 26; + case 31: + return 43; + case 32: + return "COLON"; + case 33: + return 44; + case 34: + return 28; + case 35: + return 45; + case 36: + return 46; + case 37: + return 48; + case 38: + return 50; + case 39: + return 47; + case 40: + return 41; + case 41: + return 49; + case 42: + return 42; + case 43: + break; + case 44: + return 35; + case 45: + return 36; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:(\r?\n))/i, /^(?:(\r?\n))/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:\{)/i, /^(?:[^\}]*)/i, /^(?:xychart-beta\b)/i, /^(?:(?:vertical|horizontal))/i, /^(?:x-axis\b)/i, /^(?:y-axis\b)/i, /^(?:\[)/i, /^(?:-->)/i, /^(?:line\b)/i, /^(?:bar\b)/i, /^(?:\[)/i, /^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i, /^(?:\])/i, /^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n\(\?:`))/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s+)/i, /^(?:;)/i, /^(?:$)/i], + conditions: { "data_inner": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "data": { "rules": [0, 1, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 22, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "axis_band_data": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "axis_data": { "rules": [0, 1, 2, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [], "inclusive": false }, "md_string": { "rules": [], "inclusive": false }, "string": { "rules": [27, 28], "inclusive": false }, "INITIAL": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$a.parser = parser$a; +const parser$1$9 = parser$a; +function isBarPlot(data) { + return data.type === "bar"; +} +function isBandAxisData(data) { + return data.type === "band"; +} +function isLinearAxisData(data) { + return data.type === "linear"; +} +class TextDimensionCalculatorWithFont { + constructor(parentGroup) { + this.parentGroup = parentGroup; + } + getMaxDimension(texts, fontSize) { + if (!this.parentGroup) { + return { + width: texts.reduce((acc, cur) => Math.max(cur.length, acc), 0) * fontSize, + height: fontSize + }; + } + const dimension = { + width: 0, + height: 0 + }; + const elem = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", fontSize); + for (const t of texts) { + const bbox = computeDimensionOfText(elem, 1, t); + const width = bbox ? bbox.width : t.length * fontSize; + const height = bbox ? bbox.height : fontSize; + dimension.width = Math.max(dimension.width, width); + dimension.height = Math.max(dimension.height, height); + } + elem.remove(); + return dimension; + } +} +const BAR_WIDTH_TO_TICK_WIDTH_RATIO = 0.7; +const MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL = 0.2; +class BaseAxis { + constructor(axisConfig, title, textDimensionCalculator, axisThemeConfig) { + this.axisConfig = axisConfig; + this.title = title; + this.textDimensionCalculator = textDimensionCalculator; + this.axisThemeConfig = axisThemeConfig; + this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }; + this.axisPosition = "left"; + this.showTitle = false; + this.showLabel = false; + this.showTick = false; + this.showAxisLine = false; + this.outerPadding = 0; + this.titleTextHeight = 0; + this.labelTextHeight = 0; + this.range = [0, 10]; + this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }; + this.axisPosition = "left"; + } + setRange(range) { + this.range = range; + if (this.axisPosition === "left" || this.axisPosition === "right") { + this.boundingRect.height = range[1] - range[0]; + } else { + this.boundingRect.width = range[1] - range[0]; + } + this.recalculateScale(); + } + getRange() { + return [this.range[0] + this.outerPadding, this.range[1] - this.outerPadding]; + } + setAxisPosition(axisPosition) { + this.axisPosition = axisPosition; + this.setRange(this.range); + } + getTickDistance() { + const range = this.getRange(); + return Math.abs(range[0] - range[1]) / this.getTickValues().length; + } + getAxisOuterPadding() { + return this.outerPadding; + } + getLabelDimension() { + return this.textDimensionCalculator.getMaxDimension( + this.getTickValues().map((tick) => tick.toString()), + this.axisConfig.labelFontSize + ); + } + recalculateOuterPaddingToDrawBar() { + if (BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() > this.outerPadding * 2) { + this.outerPadding = Math.floor(BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() / 2); + } + this.recalculateScale(); + } + calculateSpaceIfDrawnHorizontally(availableSpace) { + let availableHeight = availableSpace.height; + if (this.axisConfig.showAxisLine && availableHeight > this.axisConfig.axisLineWidth) { + availableHeight -= this.axisConfig.axisLineWidth; + this.showAxisLine = true; + } + if (this.axisConfig.showLabel) { + const spaceRequired = this.getLabelDimension(); + const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.width; + this.outerPadding = Math.min(spaceRequired.width / 2, maxPadding); + const heightRequired = spaceRequired.height + this.axisConfig.labelPadding * 2; + this.labelTextHeight = spaceRequired.height; + if (heightRequired <= availableHeight) { + availableHeight -= heightRequired; + this.showLabel = true; + } + } + if (this.axisConfig.showTick && availableHeight >= this.axisConfig.tickLength) { + this.showTick = true; + availableHeight -= this.axisConfig.tickLength; + } + if (this.axisConfig.showTitle && this.title) { + const spaceRequired = this.textDimensionCalculator.getMaxDimension( + [this.title], + this.axisConfig.titleFontSize + ); + const heightRequired = spaceRequired.height + this.axisConfig.titlePadding * 2; + this.titleTextHeight = spaceRequired.height; + if (heightRequired <= availableHeight) { + availableHeight -= heightRequired; + this.showTitle = true; + } + } + this.boundingRect.width = availableSpace.width; + this.boundingRect.height = availableSpace.height - availableHeight; + } + calculateSpaceIfDrawnVertical(availableSpace) { + let availableWidth = availableSpace.width; + if (this.axisConfig.showAxisLine && availableWidth > this.axisConfig.axisLineWidth) { + availableWidth -= this.axisConfig.axisLineWidth; + this.showAxisLine = true; + } + if (this.axisConfig.showLabel) { + const spaceRequired = this.getLabelDimension(); + const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.height; + this.outerPadding = Math.min(spaceRequired.height / 2, maxPadding); + const widthRequired = spaceRequired.width + this.axisConfig.labelPadding * 2; + if (widthRequired <= availableWidth) { + availableWidth -= widthRequired; + this.showLabel = true; + } + } + if (this.axisConfig.showTick && availableWidth >= this.axisConfig.tickLength) { + this.showTick = true; + availableWidth -= this.axisConfig.tickLength; + } + if (this.axisConfig.showTitle && this.title) { + const spaceRequired = this.textDimensionCalculator.getMaxDimension( + [this.title], + this.axisConfig.titleFontSize + ); + const widthRequired = spaceRequired.height + this.axisConfig.titlePadding * 2; + this.titleTextHeight = spaceRequired.height; + if (widthRequired <= availableWidth) { + availableWidth -= widthRequired; + this.showTitle = true; + } + } + this.boundingRect.width = availableSpace.width - availableWidth; + this.boundingRect.height = availableSpace.height; + } + calculateSpace(availableSpace) { + if (this.axisPosition === "left" || this.axisPosition === "right") { + this.calculateSpaceIfDrawnVertical(availableSpace); + } else { + this.calculateSpaceIfDrawnHorizontally(availableSpace); + } + this.recalculateScale(); + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + getDrawableElementsForLeftAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["left-axis", "axisl-line"], + data: [ + { + path: `M ${x},${this.boundingRect.y} L ${x},${this.boundingRect.y + this.boundingRect.height} `, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["left-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.boundingRect.x + this.boundingRect.width - (this.showLabel ? this.axisConfig.labelPadding : 0) - (this.showTick ? this.axisConfig.tickLength : 0) - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0), + y: this.getScaleValue(tick), + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "middle", + horizontalPos: "right" + })) + }); + } + if (this.showTick) { + const x = this.boundingRect.x + this.boundingRect.width - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0); + drawableElement.push({ + type: "path", + groupTexts: ["left-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${x},${this.getScaleValue(tick)} L ${x - this.axisConfig.tickLength},${this.getScaleValue(tick)}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["left-axis", "title"], + data: [ + { + text: this.title, + x: this.boundingRect.x + this.axisConfig.titlePadding, + y: this.boundingRect.y + this.boundingRect.height / 2, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 270, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElementsForBottomAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["bottom-axis", "axis-line"], + data: [ + { + path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["bottom-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.getScaleValue(tick), + y: this.boundingRect.y + this.axisConfig.labelPadding + (this.showTick ? this.axisConfig.tickLength : 0) + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0), + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + })) + }); + } + if (this.showTick) { + const y = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0); + drawableElement.push({ + type: "path", + groupTexts: ["bottom-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${this.getScaleValue(tick)},${y} L ${this.getScaleValue(tick)},${y + this.axisConfig.tickLength}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["bottom-axis", "title"], + data: [ + { + text: this.title, + x: this.range[0] + (this.range[1] - this.range[0]) / 2, + y: this.boundingRect.y + this.boundingRect.height - this.axisConfig.titlePadding - this.titleTextHeight, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElementsForTopAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["top-axis", "axis-line"], + data: [ + { + path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["top-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.getScaleValue(tick), + y: this.boundingRect.y + (this.showTitle ? this.titleTextHeight + this.axisConfig.titlePadding * 2 : 0) + this.axisConfig.labelPadding, + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + })) + }); + } + if (this.showTick) { + const y = this.boundingRect.y; + drawableElement.push({ + type: "path", + groupTexts: ["top-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${this.getScaleValue(tick)},${y + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(tick)},${y + this.boundingRect.height - this.axisConfig.tickLength - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["top-axis", "title"], + data: [ + { + text: this.title, + x: this.boundingRect.x + this.boundingRect.width / 2, + y: this.boundingRect.y + this.axisConfig.titlePadding, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElements() { + if (this.axisPosition === "left") { + return this.getDrawableElementsForLeftAxis(); + } + if (this.axisPosition === "right") { + throw Error("Drawing of right axis is not implemented"); + } + if (this.axisPosition === "bottom") { + return this.getDrawableElementsForBottomAxis(); + } + if (this.axisPosition === "top") { + return this.getDrawableElementsForTopAxis(); + } + return []; + } +} +class BandAxis extends BaseAxis { + constructor(axisConfig, axisThemeConfig, categories, title, textDimensionCalculator) { + super(axisConfig, title, textDimensionCalculator, axisThemeConfig); + this.categories = categories; + this.scale = band().domain(this.categories).range(this.getRange()); + } + setRange(range) { + super.setRange(range); + } + recalculateScale() { + this.scale = band().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5); + log$1.trace("BandAxis axis final categories, range: ", this.categories, this.getRange()); + } + getTickValues() { + return this.categories; + } + getScaleValue(value) { + return this.scale(value) || this.getRange()[0]; + } +} +class LinearAxis extends BaseAxis { + constructor(axisConfig, axisThemeConfig, domain, title, textDimensionCalculator) { + super(axisConfig, title, textDimensionCalculator, axisThemeConfig); + this.domain = domain; + this.scale = linear().domain(this.domain).range(this.getRange()); + } + getTickValues() { + return this.scale.ticks(); + } + recalculateScale() { + const domain = [...this.domain]; + if (this.axisPosition === "left") { + domain.reverse(); + } + this.scale = linear().domain(domain).range(this.getRange()); + } + getScaleValue(value) { + return this.scale(value); + } +} +function getAxis(data, axisConfig, axisThemeConfig, tmpSVGGroup2) { + const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2); + if (isBandAxisData(data)) { + return new BandAxis( + axisConfig, + axisThemeConfig, + data.categories, + data.title, + textDimensionCalculator + ); + } + return new LinearAxis( + axisConfig, + axisThemeConfig, + [data.min, data.max], + data.title, + textDimensionCalculator + ); +} +class ChartTitle { + constructor(textDimensionCalculator, chartConfig, chartData, chartThemeConfig) { + this.textDimensionCalculator = textDimensionCalculator; + this.chartConfig = chartConfig; + this.chartData = chartData; + this.chartThemeConfig = chartThemeConfig; + this.boundingRect = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + this.showChartTitle = false; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + calculateSpace(availableSpace) { + const titleDimension = this.textDimensionCalculator.getMaxDimension( + [this.chartData.title], + this.chartConfig.titleFontSize + ); + const widthRequired = Math.max(titleDimension.width, availableSpace.width); + const heightRequired = titleDimension.height + 2 * this.chartConfig.titlePadding; + if (titleDimension.width <= widthRequired && titleDimension.height <= heightRequired && this.chartConfig.showTitle && this.chartData.title) { + this.boundingRect.width = widthRequired; + this.boundingRect.height = heightRequired; + this.showChartTitle = true; + } + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + getDrawableElements() { + const drawableElem = []; + if (this.showChartTitle) { + drawableElem.push({ + groupTexts: ["chart-title"], + type: "text", + data: [ + { + fontSize: this.chartConfig.titleFontSize, + text: this.chartData.title, + verticalPos: "middle", + horizontalPos: "center", + x: this.boundingRect.x + this.boundingRect.width / 2, + y: this.boundingRect.y + this.boundingRect.height / 2, + fill: this.chartThemeConfig.titleColor, + rotation: 0 + } + ] + }); + } + return drawableElem; + } +} +function getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) { + const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2); + return new ChartTitle(textDimensionCalculator, chartConfig, chartData, chartThemeConfig); +} +class LinePlot { + constructor(plotData, xAxis, yAxis, orientation, plotIndex2) { + this.plotData = plotData; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.orientation = orientation; + this.plotIndex = plotIndex2; + } + getDrawableElement() { + const finalData = this.plotData.data.map((d) => [ + this.xAxis.getScaleValue(d[0]), + this.yAxis.getScaleValue(d[1]) + ]); + let path; + if (this.orientation === "horizontal") { + path = line$1().y((d) => d[0]).x((d) => d[1])(finalData); + } else { + path = line$1().x((d) => d[0]).y((d) => d[1])(finalData); + } + if (!path) { + return []; + } + return [ + { + groupTexts: ["plot", `line-plot-${this.plotIndex}`], + type: "path", + data: [ + { + path, + strokeFill: this.plotData.strokeFill, + strokeWidth: this.plotData.strokeWidth + } + ] + } + ]; + } +} +class BarPlot { + constructor(barData, boundingRect, xAxis, yAxis, orientation, plotIndex2) { + this.barData = barData; + this.boundingRect = boundingRect; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.orientation = orientation; + this.plotIndex = plotIndex2; + } + getDrawableElement() { + const finalData = this.barData.data.map((d) => [ + this.xAxis.getScaleValue(d[0]), + this.yAxis.getScaleValue(d[1]) + ]); + const barPaddingPercent = 0.05; + const barWidth = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * (1 - barPaddingPercent); + const barWidthHalf = barWidth / 2; + if (this.orientation === "horizontal") { + return [ + { + groupTexts: ["plot", `bar-plot-${this.plotIndex}`], + type: "rect", + data: finalData.map((data) => ({ + x: this.boundingRect.x, + y: data[0] - barWidthHalf, + height: barWidth, + width: data[1] - this.boundingRect.x, + fill: this.barData.fill, + strokeWidth: 0, + strokeFill: this.barData.fill + })) + } + ]; + } + return [ + { + groupTexts: ["plot", `bar-plot-${this.plotIndex}`], + type: "rect", + data: finalData.map((data) => ({ + x: data[0] - barWidthHalf, + y: data[1], + width: barWidth, + height: this.boundingRect.y + this.boundingRect.height - data[1], + fill: this.barData.fill, + strokeWidth: 0, + strokeFill: this.barData.fill + })) + } + ]; + } +} +class BasePlot { + constructor(chartConfig, chartData, chartThemeConfig) { + this.chartConfig = chartConfig; + this.chartData = chartData; + this.chartThemeConfig = chartThemeConfig; + this.boundingRect = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + } + setAxes(xAxis, yAxis) { + this.xAxis = xAxis; + this.yAxis = yAxis; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + calculateSpace(availableSpace) { + this.boundingRect.width = availableSpace.width; + this.boundingRect.height = availableSpace.height; + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + getDrawableElements() { + if (!(this.xAxis && this.yAxis)) { + throw Error("Axes must be passed to render Plots"); + } + const drawableElem = []; + for (const [i, plot] of this.chartData.plots.entries()) { + switch (plot.type) { + case "line": + { + const linePlot = new LinePlot( + plot, + this.xAxis, + this.yAxis, + this.chartConfig.chartOrientation, + i + ); + drawableElem.push(...linePlot.getDrawableElement()); + } + break; + case "bar": + { + const barPlot = new BarPlot( + plot, + this.boundingRect, + this.xAxis, + this.yAxis, + this.chartConfig.chartOrientation, + i + ); + drawableElem.push(...barPlot.getDrawableElement()); + } + break; + } + } + return drawableElem; + } +} +function getPlotComponent(chartConfig, chartData, chartThemeConfig) { + return new BasePlot(chartConfig, chartData, chartThemeConfig); +} +class Orchestrator { + constructor(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) { + this.chartConfig = chartConfig; + this.chartData = chartData; + this.componentStore = { + title: getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2), + plot: getPlotComponent(chartConfig, chartData, chartThemeConfig), + xAxis: getAxis( + chartData.xAxis, + chartConfig.xAxis, + { + titleColor: chartThemeConfig.xAxisTitleColor, + labelColor: chartThemeConfig.xAxisLabelColor, + tickColor: chartThemeConfig.xAxisTickColor, + axisLineColor: chartThemeConfig.xAxisLineColor + }, + tmpSVGGroup2 + ), + yAxis: getAxis( + chartData.yAxis, + chartConfig.yAxis, + { + titleColor: chartThemeConfig.yAxisTitleColor, + labelColor: chartThemeConfig.yAxisLabelColor, + tickColor: chartThemeConfig.yAxisTickColor, + axisLineColor: chartThemeConfig.yAxisLineColor + }, + tmpSVGGroup2 + ) + }; + } + calculateVerticalSpace() { + let availableWidth = this.chartConfig.width; + let availableHeight = this.chartConfig.height; + let plotX = 0; + let plotY = 0; + let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100); + let chartHeight = Math.floor( + availableHeight * this.chartConfig.plotReservedSpacePercent / 100 + ); + let spaceUsed = this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + availableWidth -= spaceUsed.width; + availableHeight -= spaceUsed.height; + spaceUsed = this.componentStore.title.calculateSpace({ + width: this.chartConfig.width, + height: availableHeight + }); + plotY = spaceUsed.height; + availableHeight -= spaceUsed.height; + this.componentStore.xAxis.setAxisPosition("bottom"); + spaceUsed = this.componentStore.xAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableHeight -= spaceUsed.height; + this.componentStore.yAxis.setAxisPosition("left"); + spaceUsed = this.componentStore.yAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + plotX = spaceUsed.width; + availableWidth -= spaceUsed.width; + if (availableWidth > 0) { + chartWidth += availableWidth; + availableWidth = 0; + } + if (availableHeight > 0) { + chartHeight += availableHeight; + availableHeight = 0; + } + this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY }); + this.componentStore.xAxis.setRange([plotX, plotX + chartWidth]); + this.componentStore.xAxis.setBoundingBoxXY({ x: plotX, y: plotY + chartHeight }); + this.componentStore.yAxis.setRange([plotY, plotY + chartHeight]); + this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: plotY }); + if (this.chartData.plots.some((p) => isBarPlot(p))) { + this.componentStore.xAxis.recalculateOuterPaddingToDrawBar(); + } + } + calculateHorizontalSpace() { + let availableWidth = this.chartConfig.width; + let availableHeight = this.chartConfig.height; + let titleYEnd = 0; + let plotX = 0; + let plotY = 0; + let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100); + let chartHeight = Math.floor( + availableHeight * this.chartConfig.plotReservedSpacePercent / 100 + ); + let spaceUsed = this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + availableWidth -= spaceUsed.width; + availableHeight -= spaceUsed.height; + spaceUsed = this.componentStore.title.calculateSpace({ + width: this.chartConfig.width, + height: availableHeight + }); + titleYEnd = spaceUsed.height; + availableHeight -= spaceUsed.height; + this.componentStore.xAxis.setAxisPosition("left"); + spaceUsed = this.componentStore.xAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableWidth -= spaceUsed.width; + plotX = spaceUsed.width; + this.componentStore.yAxis.setAxisPosition("top"); + spaceUsed = this.componentStore.yAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableHeight -= spaceUsed.height; + plotY = titleYEnd + spaceUsed.height; + if (availableWidth > 0) { + chartWidth += availableWidth; + availableWidth = 0; + } + if (availableHeight > 0) { + chartHeight += availableHeight; + availableHeight = 0; + } + this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY }); + this.componentStore.yAxis.setRange([plotX, plotX + chartWidth]); + this.componentStore.yAxis.setBoundingBoxXY({ x: plotX, y: titleYEnd }); + this.componentStore.xAxis.setRange([plotY, plotY + chartHeight]); + this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: plotY }); + if (this.chartData.plots.some((p) => isBarPlot(p))) { + this.componentStore.xAxis.recalculateOuterPaddingToDrawBar(); + } + } + calculateSpace() { + if (this.chartConfig.chartOrientation === "horizontal") { + this.calculateHorizontalSpace(); + } else { + this.calculateVerticalSpace(); + } + } + getDrawableElement() { + this.calculateSpace(); + const drawableElem = []; + this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis); + for (const component of Object.values(this.componentStore)) { + drawableElem.push(...component.getDrawableElements()); + } + return drawableElem; + } +} +class XYChartBuilder { + static build(config, chartData, chartThemeConfig, tmpSVGGroup2) { + const orchestrator = new Orchestrator(config, chartData, chartThemeConfig, tmpSVGGroup2); + return orchestrator.getDrawableElement(); + } +} +let plotIndex = 0; +let tmpSVGGroup; +let xyChartConfig = getChartDefaultConfig(); +let xyChartThemeConfig = getChartDefaultThemeConfig(); +let xyChartData = getChartDefaultData(); +let plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim()); +let hasSetXAxis = false; +let hasSetYAxis = false; +function getChartDefaultThemeConfig() { + const defaultThemeVariables = getThemeVariables$2(); + const config = getConfig$1(); + return cleanAndMerge(defaultThemeVariables.xyChart, config.themeVariables.xyChart); +} +function getChartDefaultConfig() { + const config = getConfig$1(); + return cleanAndMerge( + defaultConfig$2.xyChart, + config.xyChart + ); +} +function getChartDefaultData() { + return { + yAxis: { + type: "linear", + title: "", + min: Infinity, + max: -Infinity + }, + xAxis: { + type: "band", + title: "", + categories: [] + }, + title: "", + plots: [] + }; +} +function textSanitizer(text) { + const config = getConfig$1(); + return sanitizeText$2$1(text.trim(), config); +} +function setTmpSVGG(SVGG) { + tmpSVGGroup = SVGG; +} +function setOrientation(orientation) { + if (orientation === "horizontal") { + xyChartConfig.chartOrientation = "horizontal"; + } else { + xyChartConfig.chartOrientation = "vertical"; + } +} +function setXAxisTitle(title) { + xyChartData.xAxis.title = textSanitizer(title.text); +} +function setXAxisRangeData(min, max) { + xyChartData.xAxis = { type: "linear", title: xyChartData.xAxis.title, min, max }; + hasSetXAxis = true; +} +function setXAxisBand(categories) { + xyChartData.xAxis = { + type: "band", + title: xyChartData.xAxis.title, + categories: categories.map((c) => textSanitizer(c.text)) + }; + hasSetXAxis = true; +} +function setYAxisTitle(title) { + xyChartData.yAxis.title = textSanitizer(title.text); +} +function setYAxisRangeData(min, max) { + xyChartData.yAxis = { type: "linear", title: xyChartData.yAxis.title, min, max }; + hasSetYAxis = true; +} +function setYAxisRangeFromPlotData(data) { + const minValue = Math.min(...data); + const maxValue = Math.max(...data); + const prevMinValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Infinity; + const prevMaxValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.max : -Infinity; + xyChartData.yAxis = { + type: "linear", + title: xyChartData.yAxis.title, + min: Math.min(prevMinValue, minValue), + max: Math.max(prevMaxValue, maxValue) + }; +} +function transformDataWithoutCategory(data) { + let retData = []; + if (data.length === 0) { + return retData; + } + if (!hasSetXAxis) { + const prevMinValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.min : Infinity; + const prevMaxValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.max : -Infinity; + setXAxisRangeData(Math.min(prevMinValue, 1), Math.max(prevMaxValue, data.length)); + } + if (!hasSetYAxis) { + setYAxisRangeFromPlotData(data); + } + if (isBandAxisData(xyChartData.xAxis)) { + retData = xyChartData.xAxis.categories.map((c, i) => [c, data[i]]); + } + if (isLinearAxisData(xyChartData.xAxis)) { + const min = xyChartData.xAxis.min; + const max = xyChartData.xAxis.max; + const step = (max - min + 1) / data.length; + const categories = []; + for (let i = min; i <= max; i += step) { + categories.push(`${i}`); + } + retData = categories.map((c, i) => [c, data[i]]); + } + return retData; +} +function getPlotColorFromPalette(plotIndex2) { + return plotColorPalette[plotIndex2 === 0 ? 0 : plotIndex2 % plotColorPalette.length]; +} +function setLineData(title, data) { + const plotData = transformDataWithoutCategory(data); + xyChartData.plots.push({ + type: "line", + strokeFill: getPlotColorFromPalette(plotIndex), + strokeWidth: 2, + data: plotData + }); + plotIndex++; +} +function setBarData(title, data) { + const plotData = transformDataWithoutCategory(data); + xyChartData.plots.push({ + type: "bar", + fill: getPlotColorFromPalette(plotIndex), + data: plotData + }); + plotIndex++; +} +function getDrawableElem() { + if (xyChartData.plots.length === 0) { + throw Error("No Plot to render, please provide a plot with some data"); + } + xyChartData.title = getDiagramTitle(); + return XYChartBuilder.build(xyChartConfig, xyChartData, xyChartThemeConfig, tmpSVGGroup); +} +function getChartThemeConfig() { + return xyChartThemeConfig; +} +function getChartConfig() { + return xyChartConfig; +} +const clear$9 = function() { + clear$k(); + plotIndex = 0; + xyChartConfig = getChartDefaultConfig(); + xyChartData = getChartDefaultData(); + xyChartThemeConfig = getChartDefaultThemeConfig(); + plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim()); + hasSetXAxis = false; + hasSetYAxis = false; +}; +const db$a = { + getDrawableElem, + clear: clear$9, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + getAccDescription, + setAccDescription, + setOrientation, + setXAxisTitle, + setXAxisRangeData, + setXAxisBand, + setYAxisTitle, + setYAxisRangeData, + setLineData, + setBarData, + setTmpSVGG, + getChartThemeConfig, + getChartConfig +}; +const draw$c = (txt, id, _version, diagObj) => { + const db2 = diagObj.db; + const themeConfig = db2.getChartThemeConfig(); + const chartConfig = db2.getChartConfig(); + function getDominantBaseLine(horizontalPos) { + return horizontalPos === "top" ? "text-before-edge" : "middle"; + } + function getTextAnchor(verticalPos) { + return verticalPos === "left" ? "start" : verticalPos === "right" ? "end" : "middle"; + } + function getTextTransformation(data) { + return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`; + } + log$1.debug("Rendering xychart chart\n" + txt); + const svg = selectSvgElement(id); + const group = svg.append("g").attr("class", "main"); + const background = group.append("rect").attr("width", chartConfig.width).attr("height", chartConfig.height).attr("class", "background"); + configureSvgSize(svg, chartConfig.height, chartConfig.width, true); + svg.attr("viewBox", `0 0 ${chartConfig.width} ${chartConfig.height}`); + background.attr("fill", themeConfig.backgroundColor); + db2.setTmpSVGG(svg.append("g").attr("class", "mermaid-tmp-group")); + const shapes = db2.getDrawableElem(); + const groups = {}; + function getGroup(gList) { + let elem = group; + let prefix = ""; + for (const [i] of gList.entries()) { + let parent = group; + if (i > 0 && groups[prefix]) { + parent = groups[prefix]; + } + prefix += gList[i]; + elem = groups[prefix]; + if (!elem) { + elem = groups[prefix] = parent.append("g").attr("class", gList[i]); + } + } + return elem; + } + for (const shape of shapes) { + if (shape.data.length === 0) { + continue; + } + const shapeGroup = getGroup(shape.groupTexts); + switch (shape.type) { + case "rect": + shapeGroup.selectAll("rect").data(shape.data).enter().append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill).attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth); + break; + case "text": + shapeGroup.selectAll("text").data(shape.data).enter().append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.verticalPos)).attr("text-anchor", (data) => getTextAnchor(data.horizontalPos)).attr("transform", (data) => getTextTransformation(data)).text((data) => data.text); + break; + case "path": + shapeGroup.selectAll("path").data(shape.data).enter().append("path").attr("d", (data) => data.path).attr("fill", (data) => data.fill ? data.fill : "none").attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth); + break; + } + } +}; +const renderer$d = { + draw: draw$c +}; +const diagram$c = { + parser: parser$1$9, + db: db$a, + renderer: renderer$d +}; + +var xychartDiagramF11f50a6 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$c +}); + +var parser$9 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [5, 6, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63], $V5 = [1, 18], $V6 = [2, 7], $V7 = [1, 22], $V8 = [1, 23], $V9 = [1, 24], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 20], $Ve = [1, 28], $Vf = [1, 29], $Vg = [62, 63], $Vh = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 51, 53, 62, 63], $Vi = [1, 47], $Vj = [1, 48], $Vk = [1, 49], $Vl = [1, 50], $Vm = [1, 51], $Vn = [1, 52], $Vo = [1, 53], $Vp = [53, 54], $Vq = [1, 64], $Vr = [1, 60], $Vs = [1, 61], $Vt = [1, 62], $Vu = [1, 63], $Vv = [1, 65], $Vw = [1, 69], $Vx = [1, 70], $Vy = [1, 67], $Vz = [1, 68], $VA = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "directive": 4, "NEWLINE": 5, "RD": 6, "diagram": 7, "EOF": 8, "acc_title": 9, "acc_title_value": 10, "acc_descr": 11, "acc_descr_value": 12, "acc_descr_multiline_value": 13, "requirementDef": 14, "elementDef": 15, "relationshipDef": 16, "requirementType": 17, "requirementName": 18, "STRUCT_START": 19, "requirementBody": 20, "ID": 21, "COLONSEP": 22, "id": 23, "TEXT": 24, "text": 25, "RISK": 26, "riskLevel": 27, "VERIFYMTHD": 28, "verifyType": 29, "STRUCT_STOP": 30, "REQUIREMENT": 31, "FUNCTIONAL_REQUIREMENT": 32, "INTERFACE_REQUIREMENT": 33, "PERFORMANCE_REQUIREMENT": 34, "PHYSICAL_REQUIREMENT": 35, "DESIGN_CONSTRAINT": 36, "LOW_RISK": 37, "MED_RISK": 38, "HIGH_RISK": 39, "VERIFY_ANALYSIS": 40, "VERIFY_DEMONSTRATION": 41, "VERIFY_INSPECTION": 42, "VERIFY_TEST": 43, "ELEMENT": 44, "elementName": 45, "elementBody": 46, "TYPE": 47, "type": 48, "DOCREF": 49, "ref": 50, "END_ARROW_L": 51, "relationship": 52, "LINE": 53, "END_ARROW_R": 54, "CONTAINS": 55, "COPIES": 56, "DERIVES": 57, "SATISFIES": 58, "VERIFIES": 59, "REFINES": 60, "TRACES": 61, "unqString": 62, "qString": 63, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "NEWLINE", 6: "RD", 8: "EOF", 9: "acc_title", 10: "acc_title_value", 11: "acc_descr", 12: "acc_descr_value", 13: "acc_descr_multiline_value", 19: "STRUCT_START", 21: "ID", 22: "COLONSEP", 24: "TEXT", 26: "RISK", 28: "VERIFYMTHD", 30: "STRUCT_STOP", 31: "REQUIREMENT", 32: "FUNCTIONAL_REQUIREMENT", 33: "INTERFACE_REQUIREMENT", 34: "PERFORMANCE_REQUIREMENT", 35: "PHYSICAL_REQUIREMENT", 36: "DESIGN_CONSTRAINT", 37: "LOW_RISK", 38: "MED_RISK", 39: "HIGH_RISK", 40: "VERIFY_ANALYSIS", 41: "VERIFY_DEMONSTRATION", 42: "VERIFY_INSPECTION", 43: "VERIFY_TEST", 44: "ELEMENT", 47: "TYPE", 49: "DOCREF", 51: "END_ARROW_L", 53: "LINE", 54: "END_ARROW_R", 55: "CONTAINS", 56: "COPIES", 57: "DERIVES", 58: "SATISFIES", 59: "VERIFIES", 60: "REFINES", 61: "TRACES", 62: "unqString", 63: "qString" }, + productions_: [0, [3, 3], [3, 2], [3, 4], [4, 2], [4, 2], [4, 1], [7, 0], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [14, 5], [20, 5], [20, 5], [20, 5], [20, 5], [20, 2], [20, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [27, 1], [27, 1], [27, 1], [29, 1], [29, 1], [29, 1], [29, 1], [15, 5], [46, 5], [46, 5], [46, 2], [46, 1], [16, 5], [16, 5], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [18, 1], [18, 1], [23, 1], [23, 1], [25, 1], [25, 1], [45, 1], [45, 1], [48, 1], [48, 1], [50, 1], [50, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 4: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 5: + case 6: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 7: + this.$ = []; + break; + case 13: + yy.addRequirement($$[$0 - 3], $$[$0 - 4]); + break; + case 14: + yy.setNewReqId($$[$0 - 2]); + break; + case 15: + yy.setNewReqText($$[$0 - 2]); + break; + case 16: + yy.setNewReqRisk($$[$0 - 2]); + break; + case 17: + yy.setNewReqVerifyMethod($$[$0 - 2]); + break; + case 20: + this.$ = yy.RequirementType.REQUIREMENT; + break; + case 21: + this.$ = yy.RequirementType.FUNCTIONAL_REQUIREMENT; + break; + case 22: + this.$ = yy.RequirementType.INTERFACE_REQUIREMENT; + break; + case 23: + this.$ = yy.RequirementType.PERFORMANCE_REQUIREMENT; + break; + case 24: + this.$ = yy.RequirementType.PHYSICAL_REQUIREMENT; + break; + case 25: + this.$ = yy.RequirementType.DESIGN_CONSTRAINT; + break; + case 26: + this.$ = yy.RiskLevel.LOW_RISK; + break; + case 27: + this.$ = yy.RiskLevel.MED_RISK; + break; + case 28: + this.$ = yy.RiskLevel.HIGH_RISK; + break; + case 29: + this.$ = yy.VerifyType.VERIFY_ANALYSIS; + break; + case 30: + this.$ = yy.VerifyType.VERIFY_DEMONSTRATION; + break; + case 31: + this.$ = yy.VerifyType.VERIFY_INSPECTION; + break; + case 32: + this.$ = yy.VerifyType.VERIFY_TEST; + break; + case 33: + yy.addElement($$[$0 - 3]); + break; + case 34: + yy.setNewElementType($$[$0 - 2]); + break; + case 35: + yy.setNewElementDocRef($$[$0 - 2]); + break; + case 38: + yy.addRelationship($$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 39: + yy.addRelationship($$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 40: + this.$ = yy.Relationships.CONTAINS; + break; + case 41: + this.$ = yy.Relationships.COPIES; + break; + case 42: + this.$ = yy.Relationships.DERIVES; + break; + case 43: + this.$ = yy.Relationships.SATISFIES; + break; + case 44: + this.$ = yy.Relationships.VERIFIES; + break; + case 45: + this.$ = yy.Relationships.REFINES; + break; + case 46: + this.$ = yy.Relationships.TRACES; + break; + } + }, + table: [{ 3: 1, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [3] }, { 3: 8, 4: 2, 5: [1, 7], 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 5: [1, 9] }, { 10: [1, 10] }, { 12: [1, 11] }, o($V4, [2, 6]), { 3: 12, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [2, 2] }, { 4: 17, 5: $V5, 7: 13, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 1] }, { 8: [1, 30] }, { 4: 17, 5: $V5, 7: 31, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 32, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 33, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 34, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 35, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 18: 36, 62: [1, 37], 63: [1, 38] }, { 45: 39, 62: [1, 40], 63: [1, 41] }, { 51: [1, 42], 53: [1, 43] }, o($Vg, [2, 20]), o($Vg, [2, 21]), o($Vg, [2, 22]), o($Vg, [2, 23]), o($Vg, [2, 24]), o($Vg, [2, 25]), o($Vh, [2, 49]), o($Vh, [2, 50]), { 1: [2, 3] }, { 8: [2, 8] }, { 8: [2, 9] }, { 8: [2, 10] }, { 8: [2, 11] }, { 8: [2, 12] }, { 19: [1, 44] }, { 19: [2, 47] }, { 19: [2, 48] }, { 19: [1, 45] }, { 19: [2, 53] }, { 19: [2, 54] }, { 52: 46, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 52: 54, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 5: [1, 55] }, { 5: [1, 56] }, { 53: [1, 57] }, o($Vp, [2, 40]), o($Vp, [2, 41]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), { 54: [1, 58] }, { 5: $Vq, 20: 59, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 66, 47: $Vy, 49: $Vz }, { 23: 71, 62: $Ve, 63: $Vf }, { 23: 72, 62: $Ve, 63: $Vf }, o($VA, [2, 13]), { 22: [1, 73] }, { 22: [1, 74] }, { 22: [1, 75] }, { 22: [1, 76] }, { 5: $Vq, 20: 77, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, o($VA, [2, 19]), o($VA, [2, 33]), { 22: [1, 78] }, { 22: [1, 79] }, { 5: $Vw, 30: $Vx, 46: 80, 47: $Vy, 49: $Vz }, o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), { 23: 81, 62: $Ve, 63: $Vf }, { 25: 82, 62: [1, 83], 63: [1, 84] }, { 27: 85, 37: [1, 86], 38: [1, 87], 39: [1, 88] }, { 29: 89, 40: [1, 90], 41: [1, 91], 42: [1, 92], 43: [1, 93] }, o($VA, [2, 18]), { 48: 94, 62: [1, 95], 63: [1, 96] }, { 50: 97, 62: [1, 98], 63: [1, 99] }, o($VA, [2, 36]), { 5: [1, 100] }, { 5: [1, 101] }, { 5: [2, 51] }, { 5: [2, 52] }, { 5: [1, 102] }, { 5: [2, 26] }, { 5: [2, 27] }, { 5: [2, 28] }, { 5: [1, 103] }, { 5: [2, 29] }, { 5: [2, 30] }, { 5: [2, 31] }, { 5: [2, 32] }, { 5: [1, 104] }, { 5: [2, 55] }, { 5: [2, 56] }, { 5: [1, 105] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: $Vq, 20: 106, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 107, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 108, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 109, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 110, 47: $Vy, 49: $Vz }, { 5: $Vw, 30: $Vx, 46: 111, 47: $Vy, 49: $Vz }, o($VA, [2, 14]), o($VA, [2, 15]), o($VA, [2, 16]), o($VA, [2, 17]), o($VA, [2, 34]), o($VA, [2, 35])], + defaultActions: { 8: [2, 2], 12: [2, 1], 30: [2, 3], 31: [2, 8], 32: [2, 9], 33: [2, 10], 34: [2, 11], 35: [2, 12], 37: [2, 47], 38: [2, 48], 40: [2, 53], 41: [2, 54], 83: [2, 51], 84: [2, 52], 86: [2, 26], 87: [2, 27], 88: [2, 28], 90: [2, 29], 91: [2, 30], 92: [2, 31], 93: [2, 32], 95: [2, 55], 96: [2, 56], 98: [2, 57], 99: [2, 58] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return "title"; + case 1: + this.begin("acc_title"); + return 9; + case 2: + this.popState(); + return "acc_title_value"; + case 3: + this.begin("acc_descr"); + return 11; + case 4: + this.popState(); + return "acc_descr_value"; + case 5: + this.begin("acc_descr_multiline"); + break; + case 6: + this.popState(); + break; + case 7: + return "acc_descr_multiline_value"; + case 8: + return 5; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + return 8; + case 13: + return 6; + case 14: + return 19; + case 15: + return 30; + case 16: + return 22; + case 17: + return 21; + case 18: + return 24; + case 19: + return 26; + case 20: + return 28; + case 21: + return 31; + case 22: + return 32; + case 23: + return 33; + case 24: + return 34; + case 25: + return 35; + case 26: + return 36; + case 27: + return 37; + case 28: + return 38; + case 29: + return 39; + case 30: + return 40; + case 31: + return 41; + case 32: + return 42; + case 33: + return 43; + case 34: + return 44; + case 35: + return 55; + case 36: + return 56; + case 37: + return 57; + case 38: + return 58; + case 39: + return 59; + case 40: + return 60; + case 41: + return 61; + case 42: + return 47; + case 43: + return 49; + case 44: + return 51; + case 45: + return 54; + case 46: + return 53; + case 47: + this.begin("string"); + break; + case 48: + this.popState(); + break; + case 49: + return "qString"; + case 50: + yy_.yytext = yy_.yytext.trim(); + return 62; + } + }, + rules: [/^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:$)/i, /^(?:requirementDiagram\b)/i, /^(?:\{)/i, /^(?:\})/i, /^(?::)/i, /^(?:id\b)/i, /^(?:text\b)/i, /^(?:risk\b)/i, /^(?:verifyMethod\b)/i, /^(?:requirement\b)/i, /^(?:functionalRequirement\b)/i, /^(?:interfaceRequirement\b)/i, /^(?:performanceRequirement\b)/i, /^(?:physicalRequirement\b)/i, /^(?:designConstraint\b)/i, /^(?:low\b)/i, /^(?:medium\b)/i, /^(?:high\b)/i, /^(?:analysis\b)/i, /^(?:demonstration\b)/i, /^(?:inspection\b)/i, /^(?:test\b)/i, /^(?:element\b)/i, /^(?:contains\b)/i, /^(?:copies\b)/i, /^(?:derives\b)/i, /^(?:satisfies\b)/i, /^(?:verifies\b)/i, /^(?:refines\b)/i, /^(?:traces\b)/i, /^(?:type\b)/i, /^(?:docref\b)/i, /^(?:<-)/i, /^(?:->)/i, /^(?:-)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[\w][^\r\n\{\<\>\-\=]*)/i], + conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "unqString": { "rules": [], "inclusive": false }, "token": { "rules": [], "inclusive": false }, "string": { "rules": [48, 49], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 50], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$9.parser = parser$9; +const parser$1$8 = parser$9; +let relations$1 = []; +let latestRequirement = {}; +let requirements = {}; +let latestElement = {}; +let elements$1 = {}; +const RequirementType = { + REQUIREMENT: "Requirement", + FUNCTIONAL_REQUIREMENT: "Functional Requirement", + INTERFACE_REQUIREMENT: "Interface Requirement", + PERFORMANCE_REQUIREMENT: "Performance Requirement", + PHYSICAL_REQUIREMENT: "Physical Requirement", + DESIGN_CONSTRAINT: "Design Constraint" +}; +const RiskLevel = { + LOW_RISK: "Low", + MED_RISK: "Medium", + HIGH_RISK: "High" +}; +const VerifyType = { + VERIFY_ANALYSIS: "Analysis", + VERIFY_DEMONSTRATION: "Demonstration", + VERIFY_INSPECTION: "Inspection", + VERIFY_TEST: "Test" +}; +const Relationships = { + CONTAINS: "contains", + COPIES: "copies", + DERIVES: "derives", + SATISFIES: "satisfies", + VERIFIES: "verifies", + REFINES: "refines", + TRACES: "traces" +}; +const addRequirement = (name, type) => { + if (requirements[name] === void 0) { + requirements[name] = { + name, + type, + id: latestRequirement.id, + text: latestRequirement.text, + risk: latestRequirement.risk, + verifyMethod: latestRequirement.verifyMethod + }; + } + latestRequirement = {}; + return requirements[name]; +}; +const getRequirements = () => requirements; +const setNewReqId = (id) => { + if (latestRequirement !== void 0) { + latestRequirement.id = id; + } +}; +const setNewReqText = (text) => { + if (latestRequirement !== void 0) { + latestRequirement.text = text; + } +}; +const setNewReqRisk = (risk) => { + if (latestRequirement !== void 0) { + latestRequirement.risk = risk; + } +}; +const setNewReqVerifyMethod = (verifyMethod) => { + if (latestRequirement !== void 0) { + latestRequirement.verifyMethod = verifyMethod; + } +}; +const addElement = (name) => { + if (elements$1[name] === void 0) { + elements$1[name] = { + name, + type: latestElement.type, + docRef: latestElement.docRef + }; + log$1.info("Added new requirement: ", name); + } + latestElement = {}; + return elements$1[name]; +}; +const getElements = () => elements$1; +const setNewElementType = (type) => { + if (latestElement !== void 0) { + latestElement.type = type; + } +}; +const setNewElementDocRef = (docRef) => { + if (latestElement !== void 0) { + latestElement.docRef = docRef; + } +}; +const addRelationship = (type, src, dst) => { + relations$1.push({ + type, + src, + dst + }); +}; +const getRelationships = () => relations$1; +const clear$8 = () => { + relations$1 = []; + latestRequirement = {}; + requirements = {}; + latestElement = {}; + elements$1 = {}; + clear$k(); +}; +const db$9 = { + RequirementType, + RiskLevel, + VerifyType, + Relationships, + getConfig: () => getConfig$2().req, + addRequirement, + getRequirements, + setNewReqId, + setNewReqText, + setNewReqRisk, + setNewReqVerifyMethod, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addElement, + getElements, + setNewElementType, + setNewElementDocRef, + addRelationship, + getRelationships, + clear: clear$8 +}; +const getStyles$8 = (options) => ` + + marker { + fill: ${options.relationColor}; + stroke: ${options.relationColor}; + } + + marker.cross { + stroke: ${options.lineColor}; + } + + svg { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + } + + .reqBox { + fill: ${options.requirementBackground}; + fill-opacity: 1.0; + stroke: ${options.requirementBorderColor}; + stroke-width: ${options.requirementBorderSize}; + } + + .reqTitle, .reqLabel{ + fill: ${options.requirementTextColor}; + } + .reqLabelBox { + fill: ${options.relationLabelBackground}; + fill-opacity: 1.0; + } + + .req-title-line { + stroke: ${options.requirementBorderColor}; + stroke-width: ${options.requirementBorderSize}; + } + .relationshipLine { + stroke: ${options.relationColor}; + stroke-width: 1; + } + .relationshipLabel { + fill: ${options.relationLabelColor}; + } + +`; +const styles$7 = getStyles$8; +const ReqMarkers = { + CONTAINS: "contains", + ARROW: "arrow" +}; +const insertLineEndings = (parentNode, conf2) => { + let containsNode = parentNode.append("defs").append("marker").attr("id", ReqMarkers.CONTAINS + "_line_ending").attr("refX", 0).attr("refY", conf2.line_height / 2).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("g"); + containsNode.append("circle").attr("cx", conf2.line_height / 2).attr("cy", conf2.line_height / 2).attr("r", conf2.line_height / 2).attr("fill", "none"); + containsNode.append("line").attr("x1", 0).attr("x2", conf2.line_height).attr("y1", conf2.line_height / 2).attr("y2", conf2.line_height / 2).attr("stroke-width", 1); + containsNode.append("line").attr("y1", 0).attr("y2", conf2.line_height).attr("x1", conf2.line_height / 2).attr("x2", conf2.line_height / 2).attr("stroke-width", 1); + parentNode.append("defs").append("marker").attr("id", ReqMarkers.ARROW + "_line_ending").attr("refX", conf2.line_height).attr("refY", 0.5 * conf2.line_height).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("path").attr( + "d", + `M0,0 + L${conf2.line_height},${conf2.line_height / 2} + M${conf2.line_height},${conf2.line_height / 2} + L0,${conf2.line_height}` + ).attr("stroke-width", 1); +}; +const markers = { + ReqMarkers, + insertLineEndings +}; +let conf$5 = {}; +let relCnt = 0; +const newRectNode = (parentNode, id) => { + return parentNode.insert("rect", "#" + id).attr("class", "req reqBox").attr("x", 0).attr("y", 0).attr("width", conf$5.rect_min_width + "px").attr("height", conf$5.rect_min_height + "px"); +}; +const newTitleNode = (parentNode, id, txts) => { + let x = conf$5.rect_min_width / 2; + let title = parentNode.append("text").attr("class", "req reqLabel reqTitle").attr("id", id).attr("x", x).attr("y", conf$5.rect_padding).attr("dominant-baseline", "hanging"); + let i = 0; + txts.forEach((textStr) => { + if (i == 0) { + title.append("tspan").attr("text-anchor", "middle").attr("x", conf$5.rect_min_width / 2).attr("dy", 0).text(textStr); + } else { + title.append("tspan").attr("text-anchor", "middle").attr("x", conf$5.rect_min_width / 2).attr("dy", conf$5.line_height * 0.75).text(textStr); + } + i++; + }); + let yPadding = 1.5 * conf$5.rect_padding; + let linePadding = i * conf$5.line_height * 0.75; + let totalY = yPadding + linePadding; + parentNode.append("line").attr("class", "req-title-line").attr("x1", "0").attr("x2", conf$5.rect_min_width).attr("y1", totalY).attr("y2", totalY); + return { + titleNode: title, + y: totalY + }; +}; +const newBodyNode = (parentNode, id, txts, yStart) => { + let body = parentNode.append("text").attr("class", "req reqLabel").attr("id", id).attr("x", conf$5.rect_padding).attr("y", yStart).attr("dominant-baseline", "hanging"); + let currentRow = 0; + const charLimit = 30; + let wrappedTxts = []; + txts.forEach((textStr) => { + let currentTextLen = textStr.length; + while (currentTextLen > charLimit && currentRow < 3) { + let firstPart = textStr.substring(0, charLimit); + textStr = textStr.substring(charLimit, textStr.length); + currentTextLen = textStr.length; + wrappedTxts[wrappedTxts.length] = firstPart; + currentRow++; + } + if (currentRow == 3) { + let lastStr = wrappedTxts[wrappedTxts.length - 1]; + wrappedTxts[wrappedTxts.length - 1] = lastStr.substring(0, lastStr.length - 4) + "..."; + } else { + wrappedTxts[wrappedTxts.length] = textStr; + } + currentRow = 0; + }); + wrappedTxts.forEach((textStr) => { + body.append("tspan").attr("x", conf$5.rect_padding).attr("dy", conf$5.line_height).text(textStr); + }); + return body; +}; +const addEdgeLabel = (parentNode, svgPath, conf2, txt) => { + const len = svgPath.node().getTotalLength(); + const labelPoint = svgPath.node().getPointAtLength(len * 0.5); + const labelId = "rel" + relCnt; + relCnt++; + const labelNode = parentNode.append("text").attr("class", "req relationshipLabel").attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(txt); + const labelBBox = labelNode.node().getBBox(); + parentNode.insert("rect", "#" + labelId).attr("class", "req reqLabelBox").attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height).attr("fill", "white").attr("fill-opacity", "85%"); +}; +const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) { + const edge = g.edge(elementString(rel.src), elementString(rel.dst)); + const lineFunction = line$1().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }); + const svgPath = svg.insert("path", "#" + insert).attr("class", "er relationshipLine").attr("d", lineFunction(edge.points)).attr("fill", "none"); + if (rel.type == diagObj.db.Relationships.CONTAINS) { + svgPath.attr( + "marker-start", + "url(" + common$1.getUrl(conf$5.arrowMarkerAbsolute) + "#" + rel.type + "_line_ending)" + ); + } else { + svgPath.attr("stroke-dasharray", "10,7"); + svgPath.attr( + "marker-end", + "url(" + common$1.getUrl(conf$5.arrowMarkerAbsolute) + "#" + markers.ReqMarkers.ARROW + "_line_ending)" + ); + } + addEdgeLabel(svg, svgPath, conf$5, `<<${rel.type}>>`); + return; +}; +const drawReqs = (reqs, graph, svgNode) => { + Object.keys(reqs).forEach((reqName) => { + let req = reqs[reqName]; + reqName = elementString(reqName); + log$1.info("Added new requirement: ", reqName); + const groupNode = svgNode.append("g").attr("id", reqName); + const textId = "req-" + reqName; + const rectNode = newRectNode(groupNode, textId); + let titleNodeInfo = newTitleNode(groupNode, reqName + "_title", [ + `<<${req.type}>>`, + `${req.name}` + ]); + newBodyNode( + groupNode, + reqName + "_body", + [ + `Id: ${req.id}`, + `Text: ${req.text}`, + `Risk: ${req.risk}`, + `Verification: ${req.verifyMethod}` + ], + titleNodeInfo.y + ); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(reqName, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id: reqName + }); + }); +}; +const drawElements = (els, graph, svgNode) => { + Object.keys(els).forEach((elName) => { + let el = els[elName]; + const id = elementString(elName); + const groupNode = svgNode.append("g").attr("id", id); + const textId = "element-" + id; + const rectNode = newRectNode(groupNode, textId); + let titleNodeInfo = newTitleNode(groupNode, textId + "_title", [`<>`, `${elName}`]); + newBodyNode( + groupNode, + textId + "_body", + [`Type: ${el.type || "Not Specified"}`, `Doc Ref: ${el.docRef || "None"}`], + titleNodeInfo.y + ); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(id, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id + }); + }); +}; +const addRelationships = (relationships, g) => { + relationships.forEach(function(r) { + let src = elementString(r.src); + let dst = elementString(r.dst); + g.setEdge(src, dst, { relationship: r }); + }); + return relationships; +}; +const adjustEntities = function(svgNode, graph) { + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + svgNode.select("#" + v); + svgNode.select("#" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )" + ); + } + }); + return; +}; +const elementString = (str) => { + return str.replace(/\s/g, "").replace(/\./g, "_"); +}; +const draw$b = (text, id, _version, diagObj) => { + conf$5 = getConfig$2().requirement; + const securityLevel = conf$5.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id='${id}']`); + markers.insertLineEndings(svg, conf$5); + const g = new Graph({ + multigraph: false, + compound: false, + directed: true + }).setGraph({ + rankdir: conf$5.layoutDirection, + marginx: 20, + marginy: 20, + nodesep: 100, + edgesep: 100, + ranksep: 100 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let requirements2 = diagObj.db.getRequirements(); + let elements2 = diagObj.db.getElements(); + let relationships = diagObj.db.getRelationships(); + drawReqs(requirements2, g, svg); + drawElements(elements2, g, svg); + addRelationships(relationships, g); + layout$2(g); + adjustEntities(svg, g); + relationships.forEach(function(rel) { + drawRelationshipFromLayout(svg, rel, g, id, diagObj); + }); + const padding = conf$5.rect_padding; + const svgBounds = svg.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(svg, height, width, conf$5.useMaxWidth); + svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); +}; +const renderer$c = { + draw: draw$b +}; +const diagram$b = { + parser: parser$1$8, + db: db$9, + renderer: renderer$c, + styles: styles$7 +}; + +var requirementDiagram87253d64 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$b +}); + +var parser$8 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 13], $V7 = [1, 14], $V8 = [1, 16], $V9 = [1, 17], $Va = [1, 18], $Vb = [1, 24], $Vc = [1, 25], $Vd = [1, 26], $Ve = [1, 27], $Vf = [1, 28], $Vg = [1, 29], $Vh = [1, 30], $Vi = [1, 31], $Vj = [1, 32], $Vk = [1, 33], $Vl = [1, 34], $Vm = [1, 35], $Vn = [1, 36], $Vo = [1, 37], $Vp = [1, 38], $Vq = [1, 39], $Vr = [1, 41], $Vs = [1, 42], $Vt = [1, 43], $Vu = [1, 44], $Vv = [1, 45], $Vw = [1, 46], $Vx = [1, 4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], $Vy = [4, 5, 16, 50, 52, 53], $Vz = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VA = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VB = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 48, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VC = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VD = [68, 69, 70], $VE = [1, 120]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SPACE": 4, "NEWLINE": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "box_section": 10, "box_line": 11, "participant_statement": 12, "create": 13, "box": 14, "restOfLine": 15, "end": 16, "signal": 17, "autonumber": 18, "NUM": 19, "off": 20, "activate": 21, "actor": 22, "deactivate": 23, "note_statement": 24, "links_statement": 25, "link_statement": 26, "properties_statement": 27, "details_statement": 28, "title": 29, "legacy_title": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "loop": 36, "rect": 37, "opt": 38, "alt": 39, "else_sections": 40, "par": 41, "par_sections": 42, "par_over": 43, "critical": 44, "option_sections": 45, "break": 46, "option": 47, "and": 48, "else": 49, "participant": 50, "AS": 51, "participant_actor": 52, "destroy": 53, "note": 54, "placement": 55, "text2": 56, "over": 57, "actor_pair": 58, "links": 59, "link": 60, "properties": 61, "details": 62, "spaceList": 63, ",": 64, "left_of": 65, "right_of": 66, "signaltype": 67, "+": 68, "-": 69, "ACTOR": 70, "SOLID_OPEN_ARROW": 71, "DOTTED_OPEN_ARROW": 72, "SOLID_ARROW": 73, "DOTTED_ARROW": 74, "SOLID_CROSS": 75, "DOTTED_CROSS": 76, "SOLID_POINT": 77, "DOTTED_POINT": 78, "TXT": 79, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 6: "SD", 13: "create", 14: "box", 15: "restOfLine", 16: "end", 18: "autonumber", 19: "NUM", 20: "off", 21: "activate", 23: "deactivate", 29: "title", 30: "legacy_title", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 36: "loop", 37: "rect", 38: "opt", 39: "alt", 41: "par", 43: "par_over", 44: "critical", 46: "break", 47: "option", 48: "and", 49: "else", 50: "participant", 51: "AS", 52: "participant_actor", 53: "destroy", 54: "note", 57: "over", 59: "links", 60: "link", 61: "properties", 62: "details", 64: ",", 65: "left_of", 66: "right_of", 68: "+", 69: "-", 70: "ACTOR", 71: "SOLID_OPEN_ARROW", 72: "DOTTED_OPEN_ARROW", 73: "SOLID_ARROW", 74: "DOTTED_ARROW", 75: "SOLID_CROSS", 76: "DOTTED_CROSS", 77: "SOLID_POINT", 78: "DOTTED_POINT", 79: "TXT" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [10, 0], [10, 2], [11, 2], [11, 1], [11, 1], [9, 1], [9, 2], [9, 4], [9, 2], [9, 4], [9, 3], [9, 3], [9, 2], [9, 3], [9, 3], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [45, 1], [45, 4], [42, 1], [42, 4], [40, 1], [40, 4], [12, 5], [12, 3], [12, 5], [12, 3], [12, 3], [24, 4], [24, 4], [25, 3], [26, 3], [27, 3], [28, 3], [63, 2], [63, 1], [58, 3], [58, 1], [55, 1], [55, 1], [17, 5], [17, 5], [17, 4], [22, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [56, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.apply($$[$0]); + return $$[$0]; + case 4: + case 9: + this.$ = []; + break; + case 5: + case 10: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 6: + case 7: + case 11: + case 12: + this.$ = $$[$0]; + break; + case 8: + case 13: + this.$ = []; + break; + case 15: + $$[$0].type = "createParticipant"; + this.$ = $$[$0]; + break; + case 16: + $$[$0 - 1].unshift({ type: "boxStart", boxData: yy.parseBoxData($$[$0 - 2]) }); + $$[$0 - 1].push({ type: "boxEnd", boxText: $$[$0 - 2] }); + this.$ = $$[$0 - 1]; + break; + case 18: + this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 2]), sequenceIndexStep: Number($$[$0 - 1]), sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 19: + this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 1]), sequenceIndexStep: 1, sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 20: + this.$ = { type: "sequenceIndex", sequenceVisible: false, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 21: + this.$ = { type: "sequenceIndex", sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 22: + this.$ = { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] }; + break; + case 23: + this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1] }; + break; + case 29: + yy.setDiagramTitle($$[$0].substring(6)); + this.$ = $$[$0].substring(6); + break; + case 30: + yy.setDiagramTitle($$[$0].substring(7)); + this.$ = $$[$0].substring(7); + break; + case 31: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 32: + case 33: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 34: + $$[$0 - 1].unshift({ type: "loopStart", loopText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.LOOP_START }); + $$[$0 - 1].push({ type: "loopEnd", loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END }); + this.$ = $$[$0 - 1]; + break; + case 35: + $$[$0 - 1].unshift({ type: "rectStart", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_START }); + $$[$0 - 1].push({ type: "rectEnd", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_END }); + this.$ = $$[$0 - 1]; + break; + case 36: + $$[$0 - 1].unshift({ type: "optStart", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_START }); + $$[$0 - 1].push({ type: "optEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_END }); + this.$ = $$[$0 - 1]; + break; + case 37: + $$[$0 - 1].unshift({ type: "altStart", altText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.ALT_START }); + $$[$0 - 1].push({ type: "altEnd", signalType: yy.LINETYPE.ALT_END }); + this.$ = $$[$0 - 1]; + break; + case 38: + $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_START }); + $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END }); + this.$ = $$[$0 - 1]; + break; + case 39: + $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_OVER_START }); + $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END }); + this.$ = $$[$0 - 1]; + break; + case 40: + $$[$0 - 1].unshift({ type: "criticalStart", criticalText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.CRITICAL_START }); + $$[$0 - 1].push({ type: "criticalEnd", signalType: yy.LINETYPE.CRITICAL_END }); + this.$ = $$[$0 - 1]; + break; + case 41: + $$[$0 - 1].unshift({ type: "breakStart", breakText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_START }); + $$[$0 - 1].push({ type: "breakEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_END }); + this.$ = $$[$0 - 1]; + break; + case 43: + this.$ = $$[$0 - 3].concat([{ type: "option", optionText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.CRITICAL_OPTION }, $$[$0]]); + break; + case 45: + this.$ = $$[$0 - 3].concat([{ type: "and", parText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.PAR_AND }, $$[$0]]); + break; + case 47: + this.$ = $$[$0 - 3].concat([{ type: "else", altText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.ALT_ELSE }, $$[$0]]); + break; + case 48: + $$[$0 - 3].draw = "participant"; + $$[$0 - 3].type = "addParticipant"; + $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]); + this.$ = $$[$0 - 3]; + break; + case 49: + $$[$0 - 1].draw = "participant"; + $$[$0 - 1].type = "addParticipant"; + this.$ = $$[$0 - 1]; + break; + case 50: + $$[$0 - 3].draw = "actor"; + $$[$0 - 3].type = "addParticipant"; + $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]); + this.$ = $$[$0 - 3]; + break; + case 51: + $$[$0 - 1].draw = "actor"; + $$[$0 - 1].type = "addParticipant"; + this.$ = $$[$0 - 1]; + break; + case 52: + $$[$0 - 1].type = "destroyParticipant"; + this.$ = $$[$0 - 1]; + break; + case 53: + this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 54: + $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2); + $$[$0 - 2][0] = $$[$0 - 2][0].actor; + $$[$0 - 2][1] = $$[$0 - 2][1].actor; + this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }]; + break; + case 55: + this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 56: + this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 57: + this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 58: + this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 61: + this.$ = [$$[$0 - 2], $$[$0]]; + break; + case 62: + this.$ = $$[$0]; + break; + case 63: + this.$ = yy.PLACEMENT.LEFTOF; + break; + case 64: + this.$ = yy.PLACEMENT.RIGHTOF; + break; + case 65: + this.$ = [ + $$[$0 - 4], + $$[$0 - 1], + { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0], activate: true }, + { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] } + ]; + break; + case 66: + this.$ = [ + $$[$0 - 4], + $$[$0 - 1], + { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] }, + { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4] } + ]; + break; + case 67: + this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }]; + break; + case 68: + this.$ = { type: "addParticipant", actor: $$[$0] }; + break; + case 69: + this.$ = yy.LINETYPE.SOLID_OPEN; + break; + case 70: + this.$ = yy.LINETYPE.DOTTED_OPEN; + break; + case 71: + this.$ = yy.LINETYPE.SOLID; + break; + case 72: + this.$ = yy.LINETYPE.DOTTED; + break; + case 73: + this.$ = yy.LINETYPE.SOLID_CROSS; + break; + case 74: + this.$ = yy.LINETYPE.DOTTED_CROSS; + break; + case 75: + this.$ = yy.LINETYPE.SOLID_POINT; + break; + case 76: + this.$ = yy.LINETYPE.DOTTED_POINT; + break; + case 77: + this.$ = yy.parseMessage($$[$0].trim().substring(1)); + break; + } + }, + table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 13, 14, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, o($Vx, [2, 5]), { 9: 47, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, o($Vx, [2, 7]), o($Vx, [2, 8]), o($Vx, [2, 14]), { 12: 48, 50: $Vo, 52: $Vp, 53: $Vq }, { 15: [1, 49] }, { 5: [1, 50] }, { 5: [1, 53], 19: [1, 51], 20: [1, 52] }, { 22: 54, 70: $Vw }, { 22: 55, 70: $Vw }, { 5: [1, 56] }, { 5: [1, 57] }, { 5: [1, 58] }, { 5: [1, 59] }, { 5: [1, 60] }, o($Vx, [2, 29]), o($Vx, [2, 30]), { 32: [1, 61] }, { 34: [1, 62] }, o($Vx, [2, 33]), { 15: [1, 63] }, { 15: [1, 64] }, { 15: [1, 65] }, { 15: [1, 66] }, { 15: [1, 67] }, { 15: [1, 68] }, { 15: [1, 69] }, { 15: [1, 70] }, { 22: 71, 70: $Vw }, { 22: 72, 70: $Vw }, { 22: 73, 70: $Vw }, { 67: 74, 71: [1, 75], 72: [1, 76], 73: [1, 77], 74: [1, 78], 75: [1, 79], 76: [1, 80], 77: [1, 81], 78: [1, 82] }, { 55: 83, 57: [1, 84], 65: [1, 85], 66: [1, 86] }, { 22: 87, 70: $Vw }, { 22: 88, 70: $Vw }, { 22: 89, 70: $Vw }, { 22: 90, 70: $Vw }, o([5, 51, 64, 71, 72, 73, 74, 75, 76, 77, 78, 79], [2, 68]), o($Vx, [2, 6]), o($Vx, [2, 15]), o($Vy, [2, 9], { 10: 91 }), o($Vx, [2, 17]), { 5: [1, 93], 19: [1, 92] }, { 5: [1, 94] }, o($Vx, [2, 21]), { 5: [1, 95] }, { 5: [1, 96] }, o($Vx, [2, 24]), o($Vx, [2, 25]), o($Vx, [2, 26]), o($Vx, [2, 27]), o($Vx, [2, 28]), o($Vx, [2, 31]), o($Vx, [2, 32]), o($Vz, $V3, { 7: 97 }), o($Vz, $V3, { 7: 98 }), o($Vz, $V3, { 7: 99 }), o($VA, $V3, { 40: 100, 7: 101 }), o($VB, $V3, { 42: 102, 7: 103 }), o($VB, $V3, { 7: 103, 42: 104 }), o($VC, $V3, { 45: 105, 7: 106 }), o($Vz, $V3, { 7: 107 }), { 5: [1, 109], 51: [1, 108] }, { 5: [1, 111], 51: [1, 110] }, { 5: [1, 112] }, { 22: 115, 68: [1, 113], 69: [1, 114], 70: $Vw }, o($VD, [2, 69]), o($VD, [2, 70]), o($VD, [2, 71]), o($VD, [2, 72]), o($VD, [2, 73]), o($VD, [2, 74]), o($VD, [2, 75]), o($VD, [2, 76]), { 22: 116, 70: $Vw }, { 22: 118, 58: 117, 70: $Vw }, { 70: [2, 63] }, { 70: [2, 64] }, { 56: 119, 79: $VE }, { 56: 121, 79: $VE }, { 56: 122, 79: $VE }, { 56: 123, 79: $VE }, { 4: [1, 126], 5: [1, 128], 11: 125, 12: 127, 16: [1, 124], 50: $Vo, 52: $Vp, 53: $Vq }, { 5: [1, 129] }, o($Vx, [2, 19]), o($Vx, [2, 20]), o($Vx, [2, 22]), o($Vx, [2, 23]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 130], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 131], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 132], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 133] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 46], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 49: [1, 134], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 135] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 44], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 48: [1, 136], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 137] }, { 16: [1, 138] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 42], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 47: [1, 139], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 140], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 15: [1, 141] }, o($Vx, [2, 49]), { 15: [1, 142] }, o($Vx, [2, 51]), o($Vx, [2, 52]), { 22: 143, 70: $Vw }, { 22: 144, 70: $Vw }, { 56: 145, 79: $VE }, { 56: 146, 79: $VE }, { 56: 147, 79: $VE }, { 64: [1, 148], 79: [2, 62] }, { 5: [2, 55] }, { 5: [2, 77] }, { 5: [2, 56] }, { 5: [2, 57] }, { 5: [2, 58] }, o($Vx, [2, 16]), o($Vy, [2, 10]), { 12: 149, 50: $Vo, 52: $Vp, 53: $Vq }, o($Vy, [2, 12]), o($Vy, [2, 13]), o($Vx, [2, 18]), o($Vx, [2, 34]), o($Vx, [2, 35]), o($Vx, [2, 36]), o($Vx, [2, 37]), { 15: [1, 150] }, o($Vx, [2, 38]), { 15: [1, 151] }, o($Vx, [2, 39]), o($Vx, [2, 40]), { 15: [1, 152] }, o($Vx, [2, 41]), { 5: [1, 153] }, { 5: [1, 154] }, { 56: 155, 79: $VE }, { 56: 156, 79: $VE }, { 5: [2, 67] }, { 5: [2, 53] }, { 5: [2, 54] }, { 22: 157, 70: $Vw }, o($Vy, [2, 11]), o($VA, $V3, { 7: 101, 40: 158 }), o($VB, $V3, { 7: 103, 42: 159 }), o($VC, $V3, { 7: 106, 45: 160 }), o($Vx, [2, 48]), o($Vx, [2, 50]), { 5: [2, 65] }, { 5: [2, 66] }, { 79: [2, 61] }, { 16: [2, 47] }, { 16: [2, 45] }, { 16: [2, 43] }], + defaultActions: { 5: [2, 1], 6: [2, 2], 85: [2, 63], 86: [2, 64], 119: [2, 55], 120: [2, 77], 121: [2, 56], 122: [2, 57], 123: [2, 58], 145: [2, 67], 146: [2, 53], 147: [2, 54], 155: [2, 65], 156: [2, 66], 157: [2, 61], 158: [2, 47], 159: [2, 45], 160: [2, 43] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state2, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state2 = stack[stack.length - 1]; + if (this.defaultActions[state2]) { + action = this.defaultActions[state2]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state2] && table[state2][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state2]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state2 + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 5; + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + return 19; + case 7: + this.begin("LINE"); + return 14; + case 8: + this.begin("ID"); + return 50; + case 9: + this.begin("ID"); + return 52; + case 10: + return 13; + case 11: + this.begin("ID"); + return 53; + case 12: + yy_.yytext = yy_.yytext.trim(); + this.begin("ALIAS"); + return 70; + case 13: + this.popState(); + this.popState(); + this.begin("LINE"); + return 51; + case 14: + this.popState(); + this.popState(); + return 5; + case 15: + this.begin("LINE"); + return 36; + case 16: + this.begin("LINE"); + return 37; + case 17: + this.begin("LINE"); + return 38; + case 18: + this.begin("LINE"); + return 39; + case 19: + this.begin("LINE"); + return 49; + case 20: + this.begin("LINE"); + return 41; + case 21: + this.begin("LINE"); + return 43; + case 22: + this.begin("LINE"); + return 48; + case 23: + this.begin("LINE"); + return 44; + case 24: + this.begin("LINE"); + return 47; + case 25: + this.begin("LINE"); + return 46; + case 26: + this.popState(); + return 15; + case 27: + return 16; + case 28: + return 65; + case 29: + return 66; + case 30: + return 59; + case 31: + return 60; + case 32: + return 61; + case 33: + return 62; + case 34: + return 57; + case 35: + return 54; + case 36: + this.begin("ID"); + return 21; + case 37: + this.begin("ID"); + return 23; + case 38: + return 29; + case 39: + return 30; + case 40: + this.begin("acc_title"); + return 31; + case 41: + this.popState(); + return "acc_title_value"; + case 42: + this.begin("acc_descr"); + return 33; + case 43: + this.popState(); + return "acc_descr_value"; + case 44: + this.begin("acc_descr_multiline"); + break; + case 45: + this.popState(); + break; + case 46: + return "acc_descr_multiline_value"; + case 47: + return 6; + case 48: + return 18; + case 49: + return 20; + case 50: + return 64; + case 51: + return 5; + case 52: + yy_.yytext = yy_.yytext.trim(); + return 70; + case 53: + return 73; + case 54: + return 74; + case 55: + return 71; + case 56: + return 72; + case 57: + return 75; + case 58: + return 76; + case 59: + return 77; + case 60: + return 78; + case 61: + return 79; + case 62: + return 68; + case 63: + return 69; + case 64: + return 5; + case 65: + return "INVALID"; + } + }, + rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \n]+))/i, /^(?:box\b)/i, /^(?:participant\b)/i, /^(?:actor\b)/i, /^(?:create\b)/i, /^(?:destroy\b)/i, /^(?:[^\->:\n,;]+?([\-]*[^\->:\n,;]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:rect\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:par_over\b)/i, /^(?:and\b)/i, /^(?:critical\b)/i, /^(?:option\b)/i, /^(?:break\b)/i, /^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:links\b)/i, /^(?:link\b)/i, /^(?:properties\b)/i, /^(?:details\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:title:\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:sequenceDiagram\b)/i, /^(?:autonumber\b)/i, /^(?:off\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^\+\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+\->:\n,;]+)*)/i, /^(?:->>)/i, /^(?:-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [45, 46], "inclusive": false }, "acc_descr": { "rules": [43], "inclusive": false }, "acc_title": { "rules": [41], "inclusive": false }, "ID": { "rules": [2, 3, 12], "inclusive": false }, "ALIAS": { "rules": [2, 3, 13, 14], "inclusive": false }, "LINE": { "rules": [2, 3, 26], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$8.parser = parser$8; +const parser$1$7 = parser$8; +class ImperativeState { + /** + * @param init - Function that creates the default state. + */ + constructor(init) { + this.init = init; + this.records = this.init(); + } + reset() { + this.records = this.init(); + } +} +const state = new ImperativeState(() => ({ + prevActor: void 0, + actors: {}, + createdActors: {}, + destroyedActors: {}, + boxes: [], + messages: [], + notes: [], + sequenceNumbersEnabled: false, + wrapEnabled: void 0, + currentBox: void 0, + lastCreated: void 0, + lastDestroyed: void 0 +})); +const addBox = function(data) { + state.records.boxes.push({ + name: data.text, + wrap: data.wrap === void 0 && autoWrap() || !!data.wrap, + fill: data.color, + actorKeys: [] + }); + state.records.currentBox = state.records.boxes.slice(-1)[0]; +}; +const addActor = function(id, name, description, type) { + let assignedBox = state.records.currentBox; + const old = state.records.actors[id]; + if (old) { + if (state.records.currentBox && old.box && state.records.currentBox !== old.box) { + throw new Error( + "A same participant should only be defined in one Box: " + old.name + " can't be in '" + old.box.name + "' and in '" + state.records.currentBox.name + "' at the same time." + ); + } + assignedBox = old.box ? old.box : state.records.currentBox; + old.box = assignedBox; + if (old && name === old.name && description == null) { + return; + } + } + if (description == null || description.text == null) { + description = { text: name, wrap: null, type }; + } + if (type == null || description.text == null) { + description = { text: name, wrap: null, type }; + } + state.records.actors[id] = { + box: assignedBox, + name, + description: description.text, + wrap: description.wrap === void 0 && autoWrap() || !!description.wrap, + prevActor: state.records.prevActor, + links: {}, + properties: {}, + actorCnt: null, + rectData: null, + type: type || "participant" + }; + if (state.records.prevActor && state.records.actors[state.records.prevActor]) { + state.records.actors[state.records.prevActor].nextActor = id; + } + if (state.records.currentBox) { + state.records.currentBox.actorKeys.push(id); + } + state.records.prevActor = id; +}; +const activationCount = (part) => { + let i; + let count = 0; + for (i = 0; i < state.records.messages.length; i++) { + if (state.records.messages[i].type === LINETYPE.ACTIVE_START && state.records.messages[i].from.actor === part) { + count++; + } + if (state.records.messages[i].type === LINETYPE.ACTIVE_END && state.records.messages[i].from.actor === part) { + count--; + } + } + return count; +}; +const addMessage = function(idFrom, idTo, message, answer) { + state.records.messages.push({ + from: idFrom, + to: idTo, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + answer + }); +}; +const addSignal = function(idFrom, idTo, message = { text: void 0, wrap: void 0 }, messageType, activate = false) { + if (messageType === LINETYPE.ACTIVE_END) { + const cnt = activationCount(idFrom.actor); + if (cnt < 1) { + let error = new Error("Trying to inactivate an inactive participant (" + idFrom.actor + ")"); + error.hash = { + text: "->>-", + token: "->>-", + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["'ACTIVE_PARTICIPANT'"] + }; + throw error; + } + } + state.records.messages.push({ + from: idFrom, + to: idTo, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + type: messageType, + activate + }); + return true; +}; +const hasAtLeastOneBox = function() { + return state.records.boxes.length > 0; +}; +const hasAtLeastOneBoxWithTitle = function() { + return state.records.boxes.some((b) => b.name); +}; +const getMessages = function() { + return state.records.messages; +}; +const getBoxes = function() { + return state.records.boxes; +}; +const getActors$1 = function() { + return state.records.actors; +}; +const getCreatedActors = function() { + return state.records.createdActors; +}; +const getDestroyedActors = function() { + return state.records.destroyedActors; +}; +const getActor = function(id) { + return state.records.actors[id]; +}; +const getActorKeys = function() { + return Object.keys(state.records.actors); +}; +const enableSequenceNumbers = function() { + state.records.sequenceNumbersEnabled = true; +}; +const disableSequenceNumbers = function() { + state.records.sequenceNumbersEnabled = false; +}; +const showSequenceNumbers = () => state.records.sequenceNumbersEnabled; +const setWrap = function(wrapSetting) { + state.records.wrapEnabled = wrapSetting; +}; +const autoWrap = () => { + if (state.records.wrapEnabled !== void 0) { + return state.records.wrapEnabled; + } + return getConfig$2().sequence.wrap; +}; +const clear$7 = function() { + state.reset(); + clear$k(); +}; +const parseMessage = function(str) { + const _str = str.trim(); + const message = { + text: _str.replace(/^:?(?:no)?wrap:/, "").trim(), + wrap: _str.match(/^:?wrap:/) !== null ? true : _str.match(/^:?nowrap:/) !== null ? false : void 0 + }; + log$1.debug("parseMessage:", message); + return message; +}; +const parseBoxData = function(str) { + const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/); + let color = match != null && match[1] ? match[1].trim() : "transparent"; + let title = match != null && match[2] ? match[2].trim() : void 0; + if (window && window.CSS) { + if (!window.CSS.supports("color", color)) { + color = "transparent"; + title = str.trim(); + } + } else { + const style = new Option().style; + style.color = color; + if (style.color !== color) { + color = "transparent"; + title = str.trim(); + } + } + return { + color, + text: title !== void 0 ? sanitizeText$2$1(title.replace(/^:?(?:no)?wrap:/, ""), getConfig$2()) : void 0, + wrap: title !== void 0 ? title.match(/^:?wrap:/) !== null ? true : title.match(/^:?nowrap:/) !== null ? false : void 0 : void 0 + }; +}; +const LINETYPE = { + SOLID: 0, + DOTTED: 1, + NOTE: 2, + SOLID_CROSS: 3, + DOTTED_CROSS: 4, + SOLID_OPEN: 5, + DOTTED_OPEN: 6, + LOOP_START: 10, + LOOP_END: 11, + ALT_START: 12, + ALT_ELSE: 13, + ALT_END: 14, + OPT_START: 15, + OPT_END: 16, + ACTIVE_START: 17, + ACTIVE_END: 18, + PAR_START: 19, + PAR_AND: 20, + PAR_END: 21, + RECT_START: 22, + RECT_END: 23, + SOLID_POINT: 24, + DOTTED_POINT: 25, + AUTONUMBER: 26, + CRITICAL_START: 27, + CRITICAL_OPTION: 28, + CRITICAL_END: 29, + BREAK_START: 30, + BREAK_END: 31, + PAR_OVER_START: 32 +}; +const ARROWTYPE = { + FILLED: 0, + OPEN: 1 +}; +const PLACEMENT = { + LEFTOF: 0, + RIGHTOF: 1, + OVER: 2 +}; +const addNote$1 = function(actor, placement, message) { + const note = { + actor, + placement, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap + }; + const actors = [].concat(actor, actor); + state.records.notes.push(note); + state.records.messages.push({ + from: actors[0], + to: actors[1], + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + type: LINETYPE.NOTE, + placement + }); +}; +const addLinks = function(actorId, text) { + const actor = getActor(actorId); + try { + let sanitizedText = sanitizeText$2$1(text.text, getConfig$2()); + sanitizedText = sanitizedText.replace(/&/g, "&"); + sanitizedText = sanitizedText.replace(/=/g, "="); + const links = JSON.parse(sanitizedText); + insertLinks(actor, links); + } catch (e) { + log$1.error("error while parsing actor link text", e); + } +}; +const addALink = function(actorId, text) { + const actor = getActor(actorId); + try { + const links = {}; + let sanitizedText = sanitizeText$2$1(text.text, getConfig$2()); + var sep = sanitizedText.indexOf("@"); + sanitizedText = sanitizedText.replace(/&/g, "&"); + sanitizedText = sanitizedText.replace(/=/g, "="); + var label = sanitizedText.slice(0, sep - 1).trim(); + var link = sanitizedText.slice(sep + 1).trim(); + links[label] = link; + insertLinks(actor, links); + } catch (e) { + log$1.error("error while parsing actor link text", e); + } +}; +function insertLinks(actor, links) { + if (actor.links == null) { + actor.links = links; + } else { + for (let key in links) { + actor.links[key] = links[key]; + } + } +} +const addProperties = function(actorId, text) { + const actor = getActor(actorId); + try { + let sanitizedText = sanitizeText$2$1(text.text, getConfig$2()); + const properties = JSON.parse(sanitizedText); + insertProperties(actor, properties); + } catch (e) { + log$1.error("error while parsing actor properties text", e); + } +}; +function insertProperties(actor, properties) { + if (actor.properties == null) { + actor.properties = properties; + } else { + for (let key in properties) { + actor.properties[key] = properties[key]; + } + } +} +function boxEnd() { + state.records.currentBox = void 0; +} +const addDetails = function(actorId, text) { + const actor = getActor(actorId); + const elem = document.getElementById(text.text); + try { + const text2 = elem.innerHTML; + const details = JSON.parse(text2); + if (details["properties"]) { + insertProperties(actor, details["properties"]); + } + if (details["links"]) { + insertLinks(actor, details["links"]); + } + } catch (e) { + log$1.error("error while parsing actor details text", e); + } +}; +const getActorProperty = function(actor, key) { + if (actor !== void 0 && actor.properties !== void 0) { + return actor.properties[key]; + } + return void 0; +}; +const apply = function(param) { + if (Array.isArray(param)) { + param.forEach(function(item) { + apply(item); + }); + } else { + switch (param.type) { + case "sequenceIndex": + state.records.messages.push({ + from: void 0, + to: void 0, + message: { + start: param.sequenceIndex, + step: param.sequenceIndexStep, + visible: param.sequenceVisible + }, + wrap: false, + type: param.signalType + }); + break; + case "addParticipant": + addActor(param.actor, param.actor, param.description, param.draw); + break; + case "createParticipant": + if (state.records.actors[param.actor]) { + throw new Error( + "It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior" + ); + } + state.records.lastCreated = param.actor; + addActor(param.actor, param.actor, param.description, param.draw); + state.records.createdActors[param.actor] = state.records.messages.length; + break; + case "destroyParticipant": + state.records.lastDestroyed = param.actor; + state.records.destroyedActors[param.actor] = state.records.messages.length; + break; + case "activeStart": + addSignal(param.actor, void 0, void 0, param.signalType); + break; + case "activeEnd": + addSignal(param.actor, void 0, void 0, param.signalType); + break; + case "addNote": + addNote$1(param.actor, param.placement, param.text); + break; + case "addLinks": + addLinks(param.actor, param.text); + break; + case "addALink": + addALink(param.actor, param.text); + break; + case "addProperties": + addProperties(param.actor, param.text); + break; + case "addDetails": + addDetails(param.actor, param.text); + break; + case "addMessage": + if (state.records.lastCreated) { + if (param.to !== state.records.lastCreated) { + throw new Error( + "The created participant " + state.records.lastCreated + " does not have an associated creating message after its declaration. Please check the sequence diagram." + ); + } else { + state.records.lastCreated = void 0; + } + } else if (state.records.lastDestroyed) { + if (param.to !== state.records.lastDestroyed && param.from !== state.records.lastDestroyed) { + throw new Error( + "The destroyed participant " + state.records.lastDestroyed + " does not have an associated destroying message after its declaration. Please check the sequence diagram." + ); + } else { + state.records.lastDestroyed = void 0; + } + } + addSignal(param.from, param.to, param.msg, param.signalType, param.activate); + break; + case "boxStart": + addBox(param.boxData); + break; + case "boxEnd": + boxEnd(); + break; + case "loopStart": + addSignal(void 0, void 0, param.loopText, param.signalType); + break; + case "loopEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "rectStart": + addSignal(void 0, void 0, param.color, param.signalType); + break; + case "rectEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "optStart": + addSignal(void 0, void 0, param.optText, param.signalType); + break; + case "optEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "altStart": + addSignal(void 0, void 0, param.altText, param.signalType); + break; + case "else": + addSignal(void 0, void 0, param.altText, param.signalType); + break; + case "altEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "setAccTitle": + setAccTitle(param.text); + break; + case "parStart": + addSignal(void 0, void 0, param.parText, param.signalType); + break; + case "and": + addSignal(void 0, void 0, param.parText, param.signalType); + break; + case "parEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "criticalStart": + addSignal(void 0, void 0, param.criticalText, param.signalType); + break; + case "option": + addSignal(void 0, void 0, param.optionText, param.signalType); + break; + case "criticalEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "breakStart": + addSignal(void 0, void 0, param.breakText, param.signalType); + break; + case "breakEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + } + } +}; +const db$8 = { + addActor, + addMessage, + addSignal, + addLinks, + addDetails, + addProperties, + autoWrap, + setWrap, + enableSequenceNumbers, + disableSequenceNumbers, + showSequenceNumbers, + getMessages, + getActors: getActors$1, + getCreatedActors, + getDestroyedActors, + getActor, + getActorKeys, + getActorProperty, + getAccTitle, + getBoxes, + getDiagramTitle, + setDiagramTitle, + getConfig: () => getConfig$2().sequence, + clear: clear$7, + parseMessage, + parseBoxData, + LINETYPE, + ARROWTYPE, + PLACEMENT, + addNote: addNote$1, + setAccTitle, + apply, + setAccDescription, + getAccDescription, + hasAtLeastOneBox, + hasAtLeastOneBoxWithTitle +}; +const getStyles$7 = (options) => `.actor { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + } + + text.actor > tspan { + fill: ${options.actorTextColor}; + stroke: none; + } + + .actor-line { + stroke: ${options.actorLineColor}; + } + + .messageLine0 { + stroke-width: 1.5; + stroke-dasharray: none; + stroke: ${options.signalColor}; + } + + .messageLine1 { + stroke-width: 1.5; + stroke-dasharray: 2, 2; + stroke: ${options.signalColor}; + } + + #arrowhead path { + fill: ${options.signalColor}; + stroke: ${options.signalColor}; + } + + .sequenceNumber { + fill: ${options.sequenceNumberColor}; + } + + #sequencenumber { + fill: ${options.signalColor}; + } + + #crosshead path { + fill: ${options.signalColor}; + stroke: ${options.signalColor}; + } + + .messageText { + fill: ${options.signalTextColor}; + stroke: none; + } + + .labelBox { + stroke: ${options.labelBoxBorderColor}; + fill: ${options.labelBoxBkgColor}; + } + + .labelText, .labelText > tspan { + fill: ${options.labelTextColor}; + stroke: none; + } + + .loopText, .loopText > tspan { + fill: ${options.loopTextColor}; + stroke: none; + } + + .loopLine { + stroke-width: 2px; + stroke-dasharray: 2, 2; + stroke: ${options.labelBoxBorderColor}; + fill: ${options.labelBoxBorderColor}; + } + + .note { + //stroke: #decc93; + stroke: ${options.noteBorderColor}; + fill: ${options.noteBkgColor}; + } + + .noteText, .noteText > tspan { + fill: ${options.noteTextColor}; + stroke: none; + } + + .activation0 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .activation1 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .activation2 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .actorPopupMenu { + position: absolute; + } + + .actorPopupMenuPanel { + position: absolute; + fill: ${options.actorBkg}; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4)); +} + .actor-man line { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + } + .actor-man circle, line { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + stroke-width: 2px; + } +`; +const styles$6 = getStyles$7; +const ACTOR_TYPE_WIDTH = 18 * 2; +const TOP_ACTOR_CLASS = "actor-top"; +const BOTTOM_ACTOR_CLASS = "actor-bottom"; +const drawRect$2 = function(elem, rectData) { + return drawRect$4(elem, rectData); +}; +const drawPopup = function(elem, actor, minMenuWidth, textAttrs, forceMenus) { + if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) { + return { height: 0, width: 0 }; + } + const links = actor.links; + const actorCnt2 = actor.actorCnt; + const rectData = actor.rectData; + var displayValue = "none"; + if (forceMenus) { + displayValue = "block !important"; + } + const g = elem.append("g"); + g.attr("id", "actor" + actorCnt2 + "_popup"); + g.attr("class", "actorPopupMenu"); + g.attr("display", displayValue); + var actorClass = ""; + if (rectData.class !== void 0) { + actorClass = " " + rectData.class; + } + let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth; + const rectElem = g.append("rect"); + rectElem.attr("class", "actorPopupMenuPanel" + actorClass); + rectElem.attr("x", rectData.x); + rectElem.attr("y", rectData.height); + rectElem.attr("fill", rectData.fill); + rectElem.attr("stroke", rectData.stroke); + rectElem.attr("width", menuWidth); + rectElem.attr("height", rectData.height); + rectElem.attr("rx", rectData.rx); + rectElem.attr("ry", rectData.ry); + if (links != null) { + var linkY = 20; + for (let key in links) { + var linkElem = g.append("a"); + var sanitizedLink = dist$1.sanitizeUrl(links[key]); + linkElem.attr("xlink:href", sanitizedLink); + linkElem.attr("target", "_blank"); + _drawMenuItemTextCandidateFunc(textAttrs)( + key, + linkElem, + rectData.x + 10, + rectData.height + linkY, + menuWidth, + 20, + { class: "actor" }, + textAttrs + ); + linkY += 30; + } + } + rectElem.attr("height", linkY); + return { height: rectData.height + linkY, width: menuWidth }; +}; +const popupMenuToggle = function(popId) { + return "var pu = document.getElementById('" + popId + "'); if (pu != null) { pu.style.display = pu.style.display == 'block' ? 'none' : 'block'; }"; +}; +const drawKatex = async function(elem, textData, msgModel = null) { + let textElem = elem.append("foreignObject"); + const lines = await renderKatex(textData.text, getConfig$1()); + const divElem = textElem.append("xhtml:div").attr("style", "width: fit-content;").attr("xmlns", "http://www.w3.org/1999/xhtml").html(lines); + const dim = divElem.node().getBoundingClientRect(); + textElem.attr("height", Math.round(dim.height)).attr("width", Math.round(dim.width)); + if (textData.class === "noteText") { + const rectElem = elem.node().firstChild; + rectElem.setAttribute("height", dim.height + 2 * textData.textMargin); + const rectDim = rectElem.getBBox(); + textElem.attr("x", Math.round(rectDim.x + rectDim.width / 2 - dim.width / 2)).attr("y", Math.round(rectDim.y + rectDim.height / 2 - dim.height / 2)); + } else if (msgModel) { + let { startx, stopx, starty } = msgModel; + if (startx > stopx) { + const temp = startx; + startx = stopx; + stopx = temp; + } + textElem.attr("x", Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2)); + if (textData.class === "loopText") { + textElem.attr("y", Math.round(starty)); + } else { + textElem.attr("y", Math.round(starty - dim.height)); + } + } + return [textElem]; +}; +const drawText$2 = function(elem, textData) { + let prevTextHeight = 0; + let textHeight = 0; + const lines = textData.text.split(common$1.lineBreakRegex); + const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize); + let textElems = []; + let dy = 0; + let yfunc = () => textData.y; + if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) { + switch (textData.valign) { + case "top": + case "start": + yfunc = () => Math.round(textData.y + textData.textMargin); + break; + case "middle": + case "center": + yfunc = () => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2); + break; + case "bottom": + case "end": + yfunc = () => Math.round( + textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin + ); + break; + } + } + if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) { + switch (textData.anchor) { + case "left": + case "start": + textData.x = Math.round(textData.x + textData.textMargin); + textData.anchor = "start"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + case "middle": + case "center": + textData.x = Math.round(textData.x + textData.width / 2); + textData.anchor = "middle"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + case "right": + case "end": + textData.x = Math.round(textData.x + textData.width - textData.textMargin); + textData.anchor = "end"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + } + } + for (let [i, line] of lines.entries()) { + if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) { + dy = i * _textFontSize; + } + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", yfunc()); + if (textData.anchor !== void 0) { + textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline); + } + if (textData.fontFamily !== void 0) { + textElem.style("font-family", textData.fontFamily); + } + if (_textFontSizePx !== void 0) { + textElem.style("font-size", _textFontSizePx); + } + if (textData.fontWeight !== void 0) { + textElem.style("font-weight", textData.fontWeight); + } + if (textData.fill !== void 0) { + textElem.attr("fill", textData.fill); + } + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + if (textData.dy !== void 0) { + textElem.attr("dy", textData.dy); + } else if (dy !== 0) { + textElem.attr("dy", dy); + } + const text = line || ZERO_WIDTH_SPACE; + if (textData.tspan) { + const span = textElem.append("tspan"); + span.attr("x", textData.x); + if (textData.fill !== void 0) { + span.attr("fill", textData.fill); + } + span.text(text); + } else { + textElem.text(text); + } + if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) { + textHeight += (textElem._groups || textElem)[0][0].getBBox().height; + prevTextHeight = textHeight; + } + textElems.push(textElem); + } + return textElems; +}; +const drawLabel$2 = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.height / 2; + drawText$2(elem, txtObject); + return polygon; +}; +let actorCnt = -1; +const fixLifeLineHeights = (diagram2, actors, actorKeys, conf2) => { + if (!diagram2.select) { + return; + } + actorKeys.forEach((actorKey) => { + const actor = actors[actorKey]; + const actorDOM = diagram2.select("#actor" + actor.actorCnt); + if (!conf2.mirrorActors && actor.stopy) { + actorDOM.attr("y2", actor.stopy + actor.height / 2); + } else if (conf2.mirrorActors) { + actorDOM.attr("y2", actor.stopy); + } + }); +}; +const drawActorTypeParticipant = async function(elem, actor, conf2, isFooter) { + const actorY = isFooter ? actor.stopy : actor.starty; + const center = actor.x + actor.width / 2; + const centerY = actorY + 5; + const boxplusLineGroup = elem.append("g").lower(); + var g = boxplusLineGroup; + if (!isFooter) { + actorCnt++; + if (Object.keys(actor.links || {}).length && !conf2.forceMenus) { + g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer"); + } + g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"); + g = boxplusLineGroup.append("g"); + actor.actorCnt = actorCnt; + if (actor.links != null) { + g.attr("id", "root-" + actorCnt); + } + } + const rect = getNoteRect$2(); + var cssclass = "actor"; + if (actor.properties != null && actor.properties["class"]) { + cssclass = actor.properties["class"]; + } else { + rect.fill = "#eaeaea"; + } + if (isFooter) { + cssclass += ` ${BOTTOM_ACTOR_CLASS}`; + } else { + cssclass += ` ${TOP_ACTOR_CLASS}`; + } + rect.x = actor.x; + rect.y = actorY; + rect.width = actor.width; + rect.height = actor.height; + rect.class = cssclass; + rect.rx = 3; + rect.ry = 3; + rect.name = actor.name; + const rectElem = drawRect$2(g, rect); + actor.rectData = rect; + if (actor.properties != null && actor.properties["icon"]) { + const iconSrc = actor.properties["icon"].trim(); + if (iconSrc.charAt(0) === "@") { + drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1)); + } else { + drawImage$1(g, rect.x + rect.width - 20, rect.y + 10, iconSrc); + } + } + await _drawTextCandidateFunc$2(conf2, hasKatex(actor.description))( + actor.description, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "actor" }, + conf2 + ); + let height = actor.height; + if (rectElem.node) { + const bounds2 = rectElem.node().getBBox(); + actor.height = bounds2.height; + height = bounds2.height; + } + return height; +}; +const drawActorTypeActor = async function(elem, actor, conf2, isFooter) { + const actorY = isFooter ? actor.stopy : actor.starty; + const center = actor.x + actor.width / 2; + const centerY = actorY + 80; + elem.lower(); + if (!isFooter) { + actorCnt++; + elem.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"); + actor.actorCnt = actorCnt; + } + const actElem = elem.append("g"); + let cssClass = "actor-man"; + if (isFooter) { + cssClass += ` ${BOTTOM_ACTOR_CLASS}`; + } else { + cssClass += ` ${TOP_ACTOR_CLASS}`; + } + actElem.attr("class", cssClass); + actElem.attr("name", actor.name); + const rect = getNoteRect$2(); + rect.x = actor.x; + rect.y = actorY; + rect.fill = "#eaeaea"; + rect.width = actor.width; + rect.height = actor.height; + rect.class = "actor"; + rect.rx = 3; + rect.ry = 3; + actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actorY + 25).attr("x2", center).attr("y2", actorY + 45); + actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 33).attr("x2", center + ACTOR_TYPE_WIDTH / 2).attr("y2", actorY + 33); + actElem.append("line").attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 60).attr("x2", center).attr("y2", actorY + 45); + actElem.append("line").attr("x1", center).attr("y1", actorY + 45).attr("x2", center + ACTOR_TYPE_WIDTH / 2 - 2).attr("y2", actorY + 60); + const circle = actElem.append("circle"); + circle.attr("cx", actor.x + actor.width / 2); + circle.attr("cy", actorY + 10); + circle.attr("r", 15); + circle.attr("width", actor.width); + circle.attr("height", actor.height); + const bounds2 = actElem.node().getBBox(); + actor.height = bounds2.height; + await _drawTextCandidateFunc$2(conf2, hasKatex(actor.description))( + actor.description, + actElem, + rect.x, + rect.y + 35, + rect.width, + rect.height, + { class: "actor" }, + conf2 + ); + return actor.height; +}; +const drawActor = async function(elem, actor, conf2, isFooter) { + switch (actor.type) { + case "actor": + return await drawActorTypeActor(elem, actor, conf2, isFooter); + case "participant": + return await drawActorTypeParticipant(elem, actor, conf2, isFooter); + } +}; +const drawBox = async function(elem, box, conf2) { + const boxplusTextGroup = elem.append("g"); + const g = boxplusTextGroup; + drawBackgroundRect$2(g, box); + if (box.name) { + await _drawTextCandidateFunc$2(conf2)( + box.name, + g, + box.x, + box.y + (box.textMaxHeight || 0) / 2, + box.width, + 0, + { class: "text" }, + conf2 + ); + } + g.lower(); +}; +const anchorElement = function(elem) { + return elem.append("g"); +}; +const drawActivation = function(elem, bounds2, verticalPos, conf2, actorActivations2) { + const rect = getNoteRect$2(); + const g = bounds2.anchored; + rect.x = bounds2.startx; + rect.y = bounds2.starty; + rect.class = "activation" + actorActivations2 % 3; + rect.width = bounds2.stopx - bounds2.startx; + rect.height = verticalPos - bounds2.starty; + drawRect$2(g, rect); +}; +const drawLoop = async function(elem, loopModel, labelText, conf2) { + const { + boxMargin, + boxTextMargin, + labelBoxHeight, + labelBoxWidth, + messageFontFamily: fontFamily, + messageFontSize: fontSize, + messageFontWeight: fontWeight + } = conf2; + const g = elem.append("g"); + const drawLoopLine = function(startx, starty, stopx, stopy) { + return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine"); + }; + drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty); + drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy); + drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy); + drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy); + if (loopModel.sections !== void 0) { + loopModel.sections.forEach(function(item) { + drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style( + "stroke-dasharray", + "3, 3" + ); + }); + } + let txt = getTextObj$2(); + txt.text = labelText; + txt.x = loopModel.startx; + txt.y = loopModel.starty; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.tspan = false; + txt.width = labelBoxWidth || 50; + txt.height = labelBoxHeight || 20; + txt.textMargin = boxTextMargin; + txt.class = "labelText"; + drawLabel$2(g, txt); + txt = getTextObj$1(); + txt.text = loopModel.title; + txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2; + txt.y = loopModel.starty + boxMargin + boxTextMargin; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.textMargin = boxTextMargin; + txt.class = "loopText"; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.wrap = true; + let textElem = hasKatex(txt.text) ? await drawKatex(g, txt, loopModel) : drawText$2(g, txt); + if (loopModel.sectionTitles !== void 0) { + for (const [idx, item] of Object.entries(loopModel.sectionTitles)) { + if (item.message) { + txt.text = item.message; + txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2; + txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin; + txt.class = "loopText"; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.tspan = false; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.wrap = loopModel.wrap; + if (hasKatex(txt.text)) { + loopModel.starty = loopModel.sections[idx].y; + await drawKatex(g, txt, loopModel); + } else { + drawText$2(g, txt); + } + let sectionHeight = Math.round( + textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr) + ); + loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin); + } + } + } + loopModel.height = Math.round(loopModel.stopy - loopModel.starty); + return g; +}; +const drawBackgroundRect$2 = function(elem, bounds2) { + drawBackgroundRect$3(elem, bounds2); +}; +const insertDatabaseIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z" + ); +}; +const insertComputerIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z" + ); +}; +const insertClockIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z" + ); +}; +const insertArrowHead = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 7.9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +}; +const insertArrowFilledHead = function(elem) { + elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 15.5).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const insertSequenceNumber = function(elem) { + elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6); +}; +const insertArrowCrossHead = function(elem) { + const defs = elem.append("defs"); + const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 4.5); + marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1pt").attr("d", "M 1,2 L 6,7 M 6,2 L 1,7"); +}; +const getTextObj$1 = function() { + return { + x: 0, + y: 0, + fill: void 0, + anchor: void 0, + style: "#666", + width: void 0, + height: void 0, + textMargin: 0, + rx: 0, + ry: 0, + tspan: true, + valign: void 0 + }; +}; +const getNoteRect$1 = function() { + return { + x: 0, + y: 0, + fill: "#EDF2AE", + stroke: "#666", + width: 100, + anchor: "start", + height: 100, + rx: 0, + ry: 0 + }; +}; +const _drawTextCandidateFunc$2 = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { actorFontSize, actorFontFamily, actorFontWeight } = conf2; + const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize); + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").style("font-size", _actorFontSizePx).style("font-weight", actorFontWeight).style("font-family", actorFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + async function byKatex(content, g, x, y, width, height, textAttrs, conf2) { + const dim = await calculateMathMLDimensions(content, getConfig$1()); + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x + width / 2 - dim.width / 2).attr("y", y + height / 2 - dim.height / 2).attr("width", dim.width).attr("height", dim.height); + const text = f.append("xhtml:div").style("height", "100%").style("width", "100%"); + text.append("div").style("text-align", "center").style("vertical-align", "middle").html(await renderKatex(content, getConfig$1())); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2, hasKatex2 = false) { + if (hasKatex2) { + return byKatex; + } + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const _drawMenuItemTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { actorFontSize, actorFontFamily, actorFontWeight } = conf2; + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").style("font-size", actorFontSize).style("font-weight", actorFontWeight).style("font-family", actorFontFamily); + text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const svgDraw$3 = { + drawRect: drawRect$2, + drawText: drawText$2, + drawLabel: drawLabel$2, + drawActor, + drawBox, + drawPopup, + anchorElement, + drawActivation, + drawLoop, + drawBackgroundRect: drawBackgroundRect$2, + insertArrowHead, + insertArrowFilledHead, + insertSequenceNumber, + insertArrowCrossHead, + insertDatabaseIcon, + insertComputerIcon, + insertClockIcon, + getTextObj: getTextObj$1, + getNoteRect: getNoteRect$1, + fixLifeLineHeights, + sanitizeUrl: dist$1.sanitizeUrl +}; +let conf$4 = {}; +const bounds$2 = { + data: { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }, + verticalPos: 0, + sequenceItems: [], + activations: [], + models: { + getHeight: function() { + return Math.max.apply( + null, + this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0) + ) + (this.loops.length === 0 ? 0 : this.loops.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.messages.length === 0 ? 0 : this.messages.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.notes.length === 0 ? 0 : this.notes.map((it) => it.height || 0).reduce((acc, h) => acc + h)); + }, + clear: function() { + this.actors = []; + this.boxes = []; + this.loops = []; + this.messages = []; + this.notes = []; + }, + addBox: function(boxModel) { + this.boxes.push(boxModel); + }, + addActor: function(actorModel) { + this.actors.push(actorModel); + }, + addLoop: function(loopModel) { + this.loops.push(loopModel); + }, + addMessage: function(msgModel) { + this.messages.push(msgModel); + }, + addNote: function(noteModel) { + this.notes.push(noteModel); + }, + lastActor: function() { + return this.actors[this.actors.length - 1]; + }, + lastLoop: function() { + return this.loops[this.loops.length - 1]; + }, + lastMessage: function() { + return this.messages[this.messages.length - 1]; + }, + lastNote: function() { + return this.notes[this.notes.length - 1]; + }, + actors: [], + boxes: [], + loops: [], + messages: [], + notes: [] + }, + init: function() { + this.sequenceItems = []; + this.activations = []; + this.models.clear(); + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }; + this.verticalPos = 0; + setConf$4(getConfig$2()); + }, + updateVal: function(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + }, + updateBounds: function(startx, starty, stopx, stopy) { + const _self = this; + let cnt = 0; + function updateFn(type) { + return function updateItemBounds(item) { + cnt++; + const n = _self.sequenceItems.length - cnt + 1; + _self.updateVal(item, "starty", starty - n * conf$4.boxMargin, Math.min); + _self.updateVal(item, "stopy", stopy + n * conf$4.boxMargin, Math.max); + _self.updateVal(bounds$2.data, "startx", startx - n * conf$4.boxMargin, Math.min); + _self.updateVal(bounds$2.data, "stopx", stopx + n * conf$4.boxMargin, Math.max); + if (!(type === "activation")) { + _self.updateVal(item, "startx", startx - n * conf$4.boxMargin, Math.min); + _self.updateVal(item, "stopx", stopx + n * conf$4.boxMargin, Math.max); + _self.updateVal(bounds$2.data, "starty", starty - n * conf$4.boxMargin, Math.min); + _self.updateVal(bounds$2.data, "stopy", stopy + n * conf$4.boxMargin, Math.max); + } + }; + } + this.sequenceItems.forEach(updateFn()); + this.activations.forEach(updateFn("activation")); + }, + insert: function(startx, starty, stopx, stopy) { + const _startx = common$1.getMin(startx, stopx); + const _stopx = common$1.getMax(startx, stopx); + const _starty = common$1.getMin(starty, stopy); + const _stopy = common$1.getMax(starty, stopy); + this.updateVal(bounds$2.data, "startx", _startx, Math.min); + this.updateVal(bounds$2.data, "starty", _starty, Math.min); + this.updateVal(bounds$2.data, "stopx", _stopx, Math.max); + this.updateVal(bounds$2.data, "stopy", _stopy, Math.max); + this.updateBounds(_startx, _starty, _stopx, _stopy); + }, + newActivation: function(message, diagram2, actors) { + const actorRect = actors[message.from.actor]; + const stackedSize = actorActivations(message.from.actor).length || 0; + const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf$4.activationWidth / 2; + this.activations.push({ + startx: x, + starty: this.verticalPos + 2, + stopx: x + conf$4.activationWidth, + stopy: void 0, + actor: message.from.actor, + anchored: svgDraw$3.anchorElement(diagram2) + }); + }, + endActivation: function(message) { + const lastActorActivationIdx = this.activations.map(function(activation) { + return activation.actor; + }).lastIndexOf(message.from.actor); + return this.activations.splice(lastActorActivationIdx, 1)[0]; + }, + createLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) { + return { + startx: void 0, + starty: this.verticalPos, + stopx: void 0, + stopy: void 0, + title: title.message, + wrap: title.wrap, + width: title.width, + height: 0, + fill + }; + }, + newLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) { + this.sequenceItems.push(this.createLoop(title, fill)); + }, + endLoop: function() { + return this.sequenceItems.pop(); + }, + isLoopOverlap: function() { + return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false; + }, + addSectionToLoop: function(message) { + const loop = this.sequenceItems.pop(); + loop.sections = loop.sections || []; + loop.sectionTitles = loop.sectionTitles || []; + loop.sections.push({ y: bounds$2.getVerticalPos(), height: 0 }); + loop.sectionTitles.push(message); + this.sequenceItems.push(loop); + }, + saveVerticalPos: function() { + if (this.isLoopOverlap()) { + this.savedVerticalPos = this.verticalPos; + } + }, + resetVerticalPos: function() { + if (this.isLoopOverlap()) { + this.verticalPos = this.savedVerticalPos; + } + }, + bumpVerticalPos: function(bump) { + this.verticalPos = this.verticalPos + bump; + this.data.stopy = common$1.getMax(this.data.stopy, this.verticalPos); + }, + getVerticalPos: function() { + return this.verticalPos; + }, + getBounds: function() { + return { bounds: this.data, models: this.models }; + } +}; +const drawNote$2 = async function(elem, noteModel) { + bounds$2.bumpVerticalPos(conf$4.boxMargin); + noteModel.height = conf$4.boxMargin; + noteModel.starty = bounds$2.getVerticalPos(); + const rect = getNoteRect$2(); + rect.x = noteModel.startx; + rect.y = noteModel.starty; + rect.width = noteModel.width || conf$4.width; + rect.class = "note"; + const g = elem.append("g"); + const rectElem = svgDraw$3.drawRect(g, rect); + const textObj = getTextObj$2(); + textObj.x = noteModel.startx; + textObj.y = noteModel.starty; + textObj.width = rect.width; + textObj.dy = "1em"; + textObj.text = noteModel.message; + textObj.class = "noteText"; + textObj.fontFamily = conf$4.noteFontFamily; + textObj.fontSize = conf$4.noteFontSize; + textObj.fontWeight = conf$4.noteFontWeight; + textObj.anchor = conf$4.noteAlign; + textObj.textMargin = conf$4.noteMargin; + textObj.valign = "center"; + const textElem = hasKatex(textObj.text) ? await drawKatex(g, textObj) : drawText$2(g, textObj); + const textHeight = Math.round( + textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr) + ); + rectElem.attr("height", textHeight + 2 * conf$4.noteMargin); + noteModel.height += textHeight + 2 * conf$4.noteMargin; + bounds$2.bumpVerticalPos(textHeight + 2 * conf$4.noteMargin); + noteModel.stopy = noteModel.starty + textHeight + 2 * conf$4.noteMargin; + noteModel.stopx = noteModel.startx + rect.width; + bounds$2.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy); + bounds$2.models.addNote(noteModel); +}; +const messageFont = (cnf) => { + return { + fontFamily: cnf.messageFontFamily, + fontSize: cnf.messageFontSize, + fontWeight: cnf.messageFontWeight + }; +}; +const noteFont = (cnf) => { + return { + fontFamily: cnf.noteFontFamily, + fontSize: cnf.noteFontSize, + fontWeight: cnf.noteFontWeight + }; +}; +const actorFont = (cnf) => { + return { + fontFamily: cnf.actorFontFamily, + fontSize: cnf.actorFontSize, + fontWeight: cnf.actorFontWeight + }; +}; +async function boundMessage(_diagram, msgModel) { + bounds$2.bumpVerticalPos(10); + const { startx, stopx, message } = msgModel; + const lines = common$1.splitBreaks(message).length; + const isKatexMsg = hasKatex(message); + const textDims = isKatexMsg ? await calculateMathMLDimensions(message, getConfig$2()) : utils.calculateTextDimensions(message, messageFont(conf$4)); + if (!isKatexMsg) { + const lineHeight = textDims.height / lines; + msgModel.height += lineHeight; + bounds$2.bumpVerticalPos(lineHeight); + } + let lineStartY; + let totalOffset = textDims.height - 10; + const textWidth = textDims.width; + if (startx === stopx) { + lineStartY = bounds$2.getVerticalPos() + totalOffset; + if (!conf$4.rightAngles) { + totalOffset += conf$4.boxMargin; + lineStartY = bounds$2.getVerticalPos() + totalOffset; + } + totalOffset += 30; + const dx = common$1.getMax(textWidth / 2, conf$4.width / 2); + bounds$2.insert( + startx - dx, + bounds$2.getVerticalPos() - 10 + totalOffset, + stopx + dx, + bounds$2.getVerticalPos() + 30 + totalOffset + ); + } else { + totalOffset += conf$4.boxMargin; + lineStartY = bounds$2.getVerticalPos() + totalOffset; + bounds$2.insert(startx, lineStartY - 10, stopx, lineStartY); + } + bounds$2.bumpVerticalPos(totalOffset); + msgModel.height += totalOffset; + msgModel.stopy = msgModel.starty + msgModel.height; + bounds$2.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy); + return lineStartY; +} +const drawMessage = async function(diagram2, msgModel, lineStartY, diagObj) { + const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel; + const textDims = utils.calculateTextDimensions(message, messageFont(conf$4)); + const textObj = getTextObj$2(); + textObj.x = startx; + textObj.y = starty + 10; + textObj.width = stopx - startx; + textObj.class = "messageText"; + textObj.dy = "1em"; + textObj.text = message; + textObj.fontFamily = conf$4.messageFontFamily; + textObj.fontSize = conf$4.messageFontSize; + textObj.fontWeight = conf$4.messageFontWeight; + textObj.anchor = conf$4.messageAlign; + textObj.valign = "center"; + textObj.textMargin = conf$4.wrapPadding; + textObj.tspan = false; + hasKatex(textObj.text) ? await drawKatex(diagram2, textObj, { startx, stopx, starty: lineStartY }) : drawText$2(diagram2, textObj); + const textWidth = textDims.width; + let line; + if (startx === stopx) { + if (conf$4.rightAngles) { + line = diagram2.append("path").attr( + "d", + `M ${startx},${lineStartY} H ${startx + common$1.getMax(conf$4.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}` + ); + } else { + line = diagram2.append("path").attr( + "d", + "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20) + ); + } + } else { + line = diagram2.append("line"); + line.attr("x1", startx); + line.attr("y1", lineStartY); + line.attr("x2", stopx); + line.attr("y2", lineStartY); + } + if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN) { + line.style("stroke-dasharray", "3, 3"); + line.attr("class", "messageLine1"); + } else { + line.attr("class", "messageLine0"); + } + let url = ""; + if (conf$4.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + line.attr("stroke-width", 2); + line.attr("stroke", "none"); + line.style("fill", "none"); + if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) { + line.attr("marker-end", "url(" + url + "#filled-head)"); + } + if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) { + line.attr("marker-end", "url(" + url + "#crosshead)"); + } + if (sequenceVisible || conf$4.showSequenceNumbers) { + line.attr("marker-start", "url(" + url + "#sequencenumber)"); + diagram2.append("text").attr("x", startx).attr("y", lineStartY + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(sequenceIndex); + } +}; +const addActorRenderingData = async function(diagram2, actors, createdActors, actorKeys, verticalPos, messages, isFooter) { + let prevWidth = 0; + let prevMargin = 0; + let prevBox = void 0; + let maxHeight = 0; + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + const box = actor.box; + if (prevBox && prevBox != box) { + { + bounds$2.models.addBox(prevBox); + } + prevMargin += conf$4.boxMargin + prevBox.margin; + } + if (box && box != prevBox) { + { + box.x = prevWidth + prevMargin; + box.y = verticalPos; + } + prevMargin += box.margin; + } + actor.width = actor.width || conf$4.width; + actor.height = common$1.getMax(actor.height || conf$4.height, conf$4.height); + actor.margin = actor.margin || conf$4.actorMargin; + maxHeight = common$1.getMax(maxHeight, actor.height); + if (createdActors[actor.name]) { + prevMargin += actor.width / 2; + } + actor.x = prevWidth + prevMargin; + actor.starty = bounds$2.getVerticalPos(); + bounds$2.insert(actor.x, verticalPos, actor.x + actor.width, actor.height); + prevWidth += actor.width + prevMargin; + if (actor.box) { + actor.box.width = prevWidth + box.margin - actor.box.x; + } + prevMargin = actor.margin; + prevBox = actor.box; + bounds$2.models.addActor(actor); + } + if (prevBox && !isFooter) { + bounds$2.models.addBox(prevBox); + } + bounds$2.bumpVerticalPos(maxHeight); +}; +const drawActors = async function(diagram2, actors, actorKeys, isFooter) { + if (!isFooter) { + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + await svgDraw$3.drawActor(diagram2, actor, conf$4, false); + } + } else { + let maxHeight = 0; + bounds$2.bumpVerticalPos(conf$4.boxMargin * 2); + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + if (!actor.stopy) { + actor.stopy = bounds$2.getVerticalPos(); + } + const height = await svgDraw$3.drawActor(diagram2, actor, conf$4, true); + maxHeight = common$1.getMax(maxHeight, height); + } + bounds$2.bumpVerticalPos(maxHeight + conf$4.boxMargin); + } +}; +const drawActorsPopup = function(diagram2, actors, actorKeys, doc) { + let maxHeight = 0; + let maxWidth = 0; + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + const minMenuWidth = getRequiredPopupWidth(actor); + const menuDimensions = svgDraw$3.drawPopup( + diagram2, + actor, + minMenuWidth, + conf$4, + conf$4.forceMenus, + doc + ); + if (menuDimensions.height > maxHeight) { + maxHeight = menuDimensions.height; + } + if (menuDimensions.width + actor.x > maxWidth) { + maxWidth = menuDimensions.width + actor.x; + } + } + return { maxHeight, maxWidth }; +}; +const setConf$4 = function(cnf) { + assignWithDepth$1(conf$4, cnf); + if (cnf.fontFamily) { + conf$4.actorFontFamily = conf$4.noteFontFamily = conf$4.messageFontFamily = cnf.fontFamily; + } + if (cnf.fontSize) { + conf$4.actorFontSize = conf$4.noteFontSize = conf$4.messageFontSize = cnf.fontSize; + } + if (cnf.fontWeight) { + conf$4.actorFontWeight = conf$4.noteFontWeight = conf$4.messageFontWeight = cnf.fontWeight; + } +}; +const actorActivations = function(actor) { + return bounds$2.activations.filter(function(activation) { + return activation.actor === actor; + }); +}; +const activationBounds = function(actor, actors) { + const actorObj = actors[actor]; + const activations = actorActivations(actor); + const left = activations.reduce(function(acc, activation) { + return common$1.getMin(acc, activation.startx); + }, actorObj.x + actorObj.width / 2 - 1); + const right = activations.reduce(function(acc, activation) { + return common$1.getMax(acc, activation.stopx); + }, actorObj.x + actorObj.width / 2 + 1); + return [left, right]; +}; +function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) { + bounds$2.bumpVerticalPos(preMargin); + let heightAdjust = postMargin; + if (msg.id && msg.message && loopWidths[msg.id]) { + const loopWidth = loopWidths[msg.id].width; + const textConf = messageFont(conf$4); + msg.message = utils.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf$4.wrapPadding, textConf); + msg.width = loopWidth; + msg.wrap = true; + const textDims = utils.calculateTextDimensions(msg.message, textConf); + const totalOffset = common$1.getMax(textDims.height, conf$4.labelBoxHeight); + heightAdjust = postMargin + totalOffset; + log$1.debug(`${totalOffset} - ${msg.message}`); + } + addLoopFn(msg); + bounds$2.bumpVerticalPos(heightAdjust); +} +function adjustCreatedDestroyedData(msg, msgModel, lineStartY, index, actors, createdActors, destroyedActors) { + function receiverAdjustment(actor, adjustment) { + if (actor.x < actors[msg.from].x) { + bounds$2.insert( + msgModel.stopx - adjustment, + msgModel.starty, + msgModel.startx, + msgModel.stopy + actor.height / 2 + conf$4.noteMargin + ); + msgModel.stopx = msgModel.stopx + adjustment; + } else { + bounds$2.insert( + msgModel.startx, + msgModel.starty, + msgModel.stopx + adjustment, + msgModel.stopy + actor.height / 2 + conf$4.noteMargin + ); + msgModel.stopx = msgModel.stopx - adjustment; + } + } + function senderAdjustment(actor, adjustment) { + if (actor.x < actors[msg.to].x) { + bounds$2.insert( + msgModel.startx - adjustment, + msgModel.starty, + msgModel.stopx, + msgModel.stopy + actor.height / 2 + conf$4.noteMargin + ); + msgModel.startx = msgModel.startx + adjustment; + } else { + bounds$2.insert( + msgModel.stopx, + msgModel.starty, + msgModel.startx + adjustment, + msgModel.stopy + actor.height / 2 + conf$4.noteMargin + ); + msgModel.startx = msgModel.startx - adjustment; + } + } + if (createdActors[msg.to] == index) { + const actor = actors[msg.to]; + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; + receiverAdjustment(actor, adjustment); + actor.starty = lineStartY - actor.height / 2; + bounds$2.bumpVerticalPos(actor.height / 2); + } else if (destroyedActors[msg.from] == index) { + const actor = actors[msg.from]; + if (conf$4.mirrorActors) { + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 : actor.width / 2; + senderAdjustment(actor, adjustment); + } + actor.stopy = lineStartY - actor.height / 2; + bounds$2.bumpVerticalPos(actor.height / 2); + } else if (destroyedActors[msg.to] == index) { + const actor = actors[msg.to]; + if (conf$4.mirrorActors) { + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; + receiverAdjustment(actor, adjustment); + } + actor.stopy = lineStartY - actor.height / 2; + bounds$2.bumpVerticalPos(actor.height / 2); + } +} +const draw$a = async function(_text, id, _version, diagObj) { + const { securityLevel, sequence } = getConfig$2(); + conf$4 = sequence; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + bounds$2.init(); + log$1.debug(diagObj.db); + const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const actors = diagObj.db.getActors(); + const createdActors = diagObj.db.getCreatedActors(); + const destroyedActors = diagObj.db.getDestroyedActors(); + const boxes = diagObj.db.getBoxes(); + let actorKeys = diagObj.db.getActorKeys(); + const messages = diagObj.db.getMessages(); + const title = diagObj.db.getDiagramTitle(); + const hasBoxes = diagObj.db.hasAtLeastOneBox(); + const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle(); + const maxMessageWidthPerActor = await getMaxMessageWidthPerActor(actors, messages, diagObj); + conf$4.height = await calculateActorMargins(actors, maxMessageWidthPerActor, boxes); + svgDraw$3.insertComputerIcon(diagram2); + svgDraw$3.insertDatabaseIcon(diagram2); + svgDraw$3.insertClockIcon(diagram2); + if (hasBoxes) { + bounds$2.bumpVerticalPos(conf$4.boxMargin); + if (hasBoxTitles) { + bounds$2.bumpVerticalPos(boxes[0].textMaxHeight); + } + } + if (conf$4.hideUnusedParticipants === true) { + const newActors = /* @__PURE__ */ new Set(); + messages.forEach((message) => { + newActors.add(message.from); + newActors.add(message.to); + }); + actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey)); + } + await addActorRenderingData(diagram2, actors, createdActors, actorKeys, 0, messages, false); + const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj); + svgDraw$3.insertArrowHead(diagram2); + svgDraw$3.insertArrowCrossHead(diagram2); + svgDraw$3.insertArrowFilledHead(diagram2); + svgDraw$3.insertSequenceNumber(diagram2); + function activeEnd(msg, verticalPos) { + const activationData = bounds$2.endActivation(msg); + if (activationData.starty + 18 > verticalPos) { + activationData.starty = verticalPos - 6; + verticalPos += 12; + } + svgDraw$3.drawActivation( + diagram2, + activationData, + verticalPos, + conf$4, + actorActivations(msg.from.actor).length + ); + bounds$2.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos); + } + let sequenceIndex = 1; + let sequenceIndexStep = 1; + const messagesToDraw = []; + const backgrounds = []; + let index = 0; + for (const msg of messages) { + let loopModel, noteModel, msgModel; + switch (msg.type) { + case diagObj.db.LINETYPE.NOTE: + bounds$2.resetVerticalPos(); + noteModel = msg.noteModel; + await drawNote$2(diagram2, noteModel); + break; + case diagObj.db.LINETYPE.ACTIVE_START: + bounds$2.newActivation(msg, diagram2, actors); + break; + case diagObj.db.LINETYPE.ACTIVE_END: + activeEnd(msg, bounds$2.getVerticalPos()); + break; + case diagObj.db.LINETYPE.LOOP_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin + conf$4.boxTextMargin, + (message) => bounds$2.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.LOOP_END: + loopModel = bounds$2.endLoop(); + await svgDraw$3.drawLoop(diagram2, loopModel, "loop", conf$4); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + bounds$2.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.RECT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin, + (message) => bounds$2.newLoop(void 0, message.message) + ); + break; + case diagObj.db.LINETYPE.RECT_END: + loopModel = bounds$2.endLoop(); + backgrounds.push(loopModel); + bounds$2.models.addLoop(loopModel); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + break; + case diagObj.db.LINETYPE.OPT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin + conf$4.boxTextMargin, + (message) => bounds$2.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.OPT_END: + loopModel = bounds$2.endLoop(); + await svgDraw$3.drawLoop(diagram2, loopModel, "opt", conf$4); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + bounds$2.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.ALT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin + conf$4.boxTextMargin, + (message) => bounds$2.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.ALT_ELSE: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin + conf$4.boxTextMargin, + conf$4.boxMargin, + (message) => bounds$2.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.ALT_END: + loopModel = bounds$2.endLoop(); + await svgDraw$3.drawLoop(diagram2, loopModel, "alt", conf$4); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + bounds$2.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.PAR_START: + case diagObj.db.LINETYPE.PAR_OVER_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin + conf$4.boxTextMargin, + (message) => bounds$2.newLoop(message) + ); + bounds$2.saveVerticalPos(); + break; + case diagObj.db.LINETYPE.PAR_AND: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin + conf$4.boxTextMargin, + conf$4.boxMargin, + (message) => bounds$2.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.PAR_END: + loopModel = bounds$2.endLoop(); + await svgDraw$3.drawLoop(diagram2, loopModel, "par", conf$4); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + bounds$2.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.AUTONUMBER: + sequenceIndex = msg.message.start || sequenceIndex; + sequenceIndexStep = msg.message.step || sequenceIndexStep; + if (msg.message.visible) { + diagObj.db.enableSequenceNumbers(); + } else { + diagObj.db.disableSequenceNumbers(); + } + break; + case diagObj.db.LINETYPE.CRITICAL_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin + conf$4.boxTextMargin, + (message) => bounds$2.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.CRITICAL_OPTION: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin + conf$4.boxTextMargin, + conf$4.boxMargin, + (message) => bounds$2.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.CRITICAL_END: + loopModel = bounds$2.endLoop(); + await svgDraw$3.drawLoop(diagram2, loopModel, "critical", conf$4); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + bounds$2.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.BREAK_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf$4.boxMargin, + conf$4.boxMargin + conf$4.boxTextMargin, + (message) => bounds$2.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.BREAK_END: + loopModel = bounds$2.endLoop(); + await svgDraw$3.drawLoop(diagram2, loopModel, "break", conf$4); + bounds$2.bumpVerticalPos(loopModel.stopy - bounds$2.getVerticalPos()); + bounds$2.models.addLoop(loopModel); + break; + default: + try { + msgModel = msg.msgModel; + msgModel.starty = bounds$2.getVerticalPos(); + msgModel.sequenceIndex = sequenceIndex; + msgModel.sequenceVisible = diagObj.db.showSequenceNumbers(); + const lineStartY = await boundMessage(diagram2, msgModel); + adjustCreatedDestroyedData( + msg, + msgModel, + lineStartY, + index, + actors, + createdActors, + destroyedActors + ); + messagesToDraw.push({ messageModel: msgModel, lineStartY }); + bounds$2.models.addMessage(msgModel); + } catch (e) { + log$1.error("error while drawing message", e); + } + } + if ([ + diagObj.db.LINETYPE.SOLID_OPEN, + diagObj.db.LINETYPE.DOTTED_OPEN, + diagObj.db.LINETYPE.SOLID, + diagObj.db.LINETYPE.DOTTED, + diagObj.db.LINETYPE.SOLID_CROSS, + diagObj.db.LINETYPE.DOTTED_CROSS, + diagObj.db.LINETYPE.SOLID_POINT, + diagObj.db.LINETYPE.DOTTED_POINT + ].includes(msg.type)) { + sequenceIndex = sequenceIndex + sequenceIndexStep; + } + index++; + } + log$1.debug("createdActors", createdActors); + log$1.debug("destroyedActors", destroyedActors); + await drawActors(diagram2, actors, actorKeys, false); + for (const e of messagesToDraw) { + await drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj); + } + if (conf$4.mirrorActors) { + await drawActors(diagram2, actors, actorKeys, true); + } + backgrounds.forEach((e) => svgDraw$3.drawBackgroundRect(diagram2, e)); + fixLifeLineHeights(diagram2, actors, actorKeys, conf$4); + for (const box2 of bounds$2.models.boxes) { + box2.height = bounds$2.getVerticalPos() - box2.y; + bounds$2.insert(box2.x, box2.y, box2.x + box2.width, box2.height); + box2.startx = box2.x; + box2.starty = box2.y; + box2.stopx = box2.startx + box2.width; + box2.stopy = box2.starty + box2.height; + box2.stroke = "rgb(0,0,0, 0.5)"; + await svgDraw$3.drawBox(diagram2, box2, conf$4); + } + if (hasBoxes) { + bounds$2.bumpVerticalPos(conf$4.boxMargin); + } + const requiredBoxSize = drawActorsPopup(diagram2, actors, actorKeys, doc); + const { bounds: box } = bounds$2.getBounds(); + let boxHeight = box.stopy - box.starty; + if (boxHeight < requiredBoxSize.maxHeight) { + boxHeight = requiredBoxSize.maxHeight; + } + let height = boxHeight + 2 * conf$4.diagramMarginY; + if (conf$4.mirrorActors) { + height = height - conf$4.boxMargin + conf$4.bottomMarginAdj; + } + let boxWidth = box.stopx - box.startx; + if (boxWidth < requiredBoxSize.maxWidth) { + boxWidth = requiredBoxSize.maxWidth; + } + const width = boxWidth + 2 * conf$4.diagramMarginX; + if (title) { + diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf$4.diagramMarginX).attr("y", -25); + } + configureSvgSize(diagram2, height, width, conf$4.useMaxWidth); + const extraVertForTitle = title ? 40 : 0; + diagram2.attr( + "viewBox", + box.startx - conf$4.diagramMarginX + " -" + (conf$4.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle) + ); + log$1.debug(`models:`, bounds$2.models); +}; +async function getMaxMessageWidthPerActor(actors, messages, diagObj) { + const maxMessageWidthPerActor = {}; + for (const msg of messages) { + if (actors[msg.to] && actors[msg.from]) { + const actor = actors[msg.to]; + if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) { + continue; + } + if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) { + continue; + } + const isNote = msg.placement !== void 0; + const isMessage = !isNote; + const textFont = isNote ? noteFont(conf$4) : messageFont(conf$4); + const wrappedMessage = msg.wrap ? utils.wrapLabel(msg.message, conf$4.width - 2 * conf$4.wrapPadding, textFont) : msg.message; + const messageDimensions = hasKatex(wrappedMessage) ? await calculateMathMLDimensions(msg.message, getConfig$2()) : utils.calculateTextDimensions(wrappedMessage, textFont); + const messageWidth = messageDimensions.width + 2 * conf$4.wrapPadding; + if (isMessage && msg.from === actor.nextActor) { + maxMessageWidthPerActor[msg.to] = common$1.getMax( + maxMessageWidthPerActor[msg.to] || 0, + messageWidth + ); + } else if (isMessage && msg.from === actor.prevActor) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth + ); + } else if (isMessage && msg.from === msg.to) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth / 2 + ); + maxMessageWidthPerActor[msg.to] = common$1.getMax( + maxMessageWidthPerActor[msg.to] || 0, + messageWidth / 2 + ); + } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth + ); + } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { + maxMessageWidthPerActor[actor.prevActor] = common$1.getMax( + maxMessageWidthPerActor[actor.prevActor] || 0, + messageWidth + ); + } else if (msg.placement === diagObj.db.PLACEMENT.OVER) { + if (actor.prevActor) { + maxMessageWidthPerActor[actor.prevActor] = common$1.getMax( + maxMessageWidthPerActor[actor.prevActor] || 0, + messageWidth / 2 + ); + } + if (actor.nextActor) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth / 2 + ); + } + } + } + } + log$1.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor); + return maxMessageWidthPerActor; +} +const getRequiredPopupWidth = function(actor) { + let requiredPopupWidth = 0; + const textFont = actorFont(conf$4); + for (const key in actor.links) { + const labelDimensions = utils.calculateTextDimensions(key, textFont); + const labelWidth = labelDimensions.width + 2 * conf$4.wrapPadding + 2 * conf$4.boxMargin; + if (requiredPopupWidth < labelWidth) { + requiredPopupWidth = labelWidth; + } + } + return requiredPopupWidth; +}; +async function calculateActorMargins(actors, actorToMessageWidth, boxes) { + let maxHeight = 0; + for (const prop of Object.keys(actors)) { + const actor = actors[prop]; + if (actor.wrap) { + actor.description = utils.wrapLabel( + actor.description, + conf$4.width - 2 * conf$4.wrapPadding, + actorFont(conf$4) + ); + } + const actDims = hasKatex(actor.description) ? await calculateMathMLDimensions(actor.description, getConfig$2()) : utils.calculateTextDimensions(actor.description, actorFont(conf$4)); + actor.width = actor.wrap ? conf$4.width : common$1.getMax(conf$4.width, actDims.width + 2 * conf$4.wrapPadding); + actor.height = actor.wrap ? common$1.getMax(actDims.height, conf$4.height) : conf$4.height; + maxHeight = common$1.getMax(maxHeight, actor.height); + } + for (const actorKey in actorToMessageWidth) { + const actor = actors[actorKey]; + if (!actor) { + continue; + } + const nextActor = actors[actor.nextActor]; + if (!nextActor) { + const messageWidth2 = actorToMessageWidth[actorKey]; + const actorWidth2 = messageWidth2 + conf$4.actorMargin - actor.width / 2; + actor.margin = common$1.getMax(actorWidth2, conf$4.actorMargin); + continue; + } + const messageWidth = actorToMessageWidth[actorKey]; + const actorWidth = messageWidth + conf$4.actorMargin - actor.width / 2 - nextActor.width / 2; + actor.margin = common$1.getMax(actorWidth, conf$4.actorMargin); + } + let maxBoxHeight = 0; + boxes.forEach((box) => { + const textFont = messageFont(conf$4); + let totalWidth = box.actorKeys.reduce((total, aKey) => { + return total += actors[aKey].width + (actors[aKey].margin || 0); + }, 0); + totalWidth -= 2 * conf$4.boxTextMargin; + if (box.wrap) { + box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf$4.wrapPadding, textFont); + } + const boxMsgDimensions = utils.calculateTextDimensions(box.name, textFont); + maxBoxHeight = common$1.getMax(boxMsgDimensions.height, maxBoxHeight); + const minWidth = common$1.getMax(totalWidth, boxMsgDimensions.width + 2 * conf$4.wrapPadding); + box.margin = conf$4.boxTextMargin; + if (totalWidth < minWidth) { + const missing = (minWidth - totalWidth) / 2; + box.margin += missing; + } + }); + boxes.forEach((box) => box.textMaxHeight = maxBoxHeight); + return common$1.getMax(maxHeight, conf$4.height); +} +const buildNoteModel = async function(msg, actors, diagObj) { + const startx = actors[msg.from].x; + const stopx = actors[msg.to].x; + const shouldWrap = msg.wrap && msg.message; + let textDimensions = hasKatex(msg.message) ? await calculateMathMLDimensions(msg.message, getConfig$2()) : utils.calculateTextDimensions( + shouldWrap ? utils.wrapLabel(msg.message, conf$4.width, noteFont(conf$4)) : msg.message, + noteFont(conf$4) + ); + const noteModel = { + width: shouldWrap ? conf$4.width : common$1.getMax(conf$4.width, textDimensions.width + 2 * conf$4.noteMargin), + height: 0, + startx: actors[msg.from].x, + stopx: 0, + starty: 0, + stopy: 0, + message: msg.message + }; + if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) { + noteModel.width = shouldWrap ? common$1.getMax(conf$4.width, textDimensions.width) : common$1.getMax( + actors[msg.from].width / 2 + actors[msg.to].width / 2, + textDimensions.width + 2 * conf$4.noteMargin + ); + noteModel.startx = startx + (actors[msg.from].width + conf$4.actorMargin) / 2; + } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { + noteModel.width = shouldWrap ? common$1.getMax(conf$4.width, textDimensions.width + 2 * conf$4.noteMargin) : common$1.getMax( + actors[msg.from].width / 2 + actors[msg.to].width / 2, + textDimensions.width + 2 * conf$4.noteMargin + ); + noteModel.startx = startx - noteModel.width + (actors[msg.from].width - conf$4.actorMargin) / 2; + } else if (msg.to === msg.from) { + textDimensions = utils.calculateTextDimensions( + shouldWrap ? utils.wrapLabel( + msg.message, + common$1.getMax(conf$4.width, actors[msg.from].width), + noteFont(conf$4) + ) : msg.message, + noteFont(conf$4) + ); + noteModel.width = shouldWrap ? common$1.getMax(conf$4.width, actors[msg.from].width) : common$1.getMax( + actors[msg.from].width, + conf$4.width, + textDimensions.width + 2 * conf$4.noteMargin + ); + noteModel.startx = startx + (actors[msg.from].width - noteModel.width) / 2; + } else { + noteModel.width = Math.abs(startx + actors[msg.from].width / 2 - (stopx + actors[msg.to].width / 2)) + conf$4.actorMargin; + noteModel.startx = startx < stopx ? startx + actors[msg.from].width / 2 - conf$4.actorMargin / 2 : stopx + actors[msg.to].width / 2 - conf$4.actorMargin / 2; + } + if (shouldWrap) { + noteModel.message = utils.wrapLabel( + msg.message, + noteModel.width - 2 * conf$4.wrapPadding, + noteFont(conf$4) + ); + } + log$1.debug( + `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]` + ); + return noteModel; +}; +const buildMessageModel = function(msg, actors, diagObj) { + if (![ + diagObj.db.LINETYPE.SOLID_OPEN, + diagObj.db.LINETYPE.DOTTED_OPEN, + diagObj.db.LINETYPE.SOLID, + diagObj.db.LINETYPE.DOTTED, + diagObj.db.LINETYPE.SOLID_CROSS, + diagObj.db.LINETYPE.DOTTED_CROSS, + diagObj.db.LINETYPE.SOLID_POINT, + diagObj.db.LINETYPE.DOTTED_POINT + ].includes(msg.type)) { + return {}; + } + const [fromLeft, fromRight] = activationBounds(msg.from, actors); + const [toLeft, toRight] = activationBounds(msg.to, actors); + const isArrowToRight = fromLeft <= toLeft; + const startx = isArrowToRight ? fromRight : fromLeft; + let stopx = isArrowToRight ? toLeft : toRight; + const isArrowToActivation = Math.abs(toLeft - toRight) > 2; + const adjustValue = (value) => { + return isArrowToRight ? -value : value; + }; + if (msg.from === msg.to) { + stopx = startx; + } else { + if (msg.activate && !isArrowToActivation) { + stopx += adjustValue(conf$4.activationWidth / 2 - 1); + } + if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) { + stopx += adjustValue(3); + } + } + const allBounds = [fromLeft, fromRight, toLeft, toRight]; + const boundedWidth = Math.abs(startx - stopx); + if (msg.wrap && msg.message) { + msg.message = utils.wrapLabel( + msg.message, + common$1.getMax(boundedWidth + 2 * conf$4.wrapPadding, conf$4.width), + messageFont(conf$4) + ); + } + const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf$4)); + return { + width: common$1.getMax( + msg.wrap ? 0 : msgDims.width + 2 * conf$4.wrapPadding, + boundedWidth + 2 * conf$4.wrapPadding, + conf$4.width + ), + height: 0, + startx, + stopx, + starty: 0, + stopy: 0, + message: msg.message, + type: msg.type, + wrap: msg.wrap, + fromBounds: Math.min.apply(null, allBounds), + toBounds: Math.max.apply(null, allBounds) + }; +}; +const calculateLoopBounds = async function(messages, actors, _maxWidthPerActor, diagObj) { + const loops = {}; + const stack = []; + let current, noteModel, msgModel; + for (const msg of messages) { + msg.id = utils.random({ length: 10 }); + switch (msg.type) { + case diagObj.db.LINETYPE.LOOP_START: + case diagObj.db.LINETYPE.ALT_START: + case diagObj.db.LINETYPE.OPT_START: + case diagObj.db.LINETYPE.PAR_START: + case diagObj.db.LINETYPE.PAR_OVER_START: + case diagObj.db.LINETYPE.CRITICAL_START: + case diagObj.db.LINETYPE.BREAK_START: + stack.push({ + id: msg.id, + msg: msg.message, + from: Number.MAX_SAFE_INTEGER, + to: Number.MIN_SAFE_INTEGER, + width: 0 + }); + break; + case diagObj.db.LINETYPE.ALT_ELSE: + case diagObj.db.LINETYPE.PAR_AND: + case diagObj.db.LINETYPE.CRITICAL_OPTION: + if (msg.message) { + current = stack.pop(); + loops[current.id] = current; + loops[msg.id] = current; + stack.push(current); + } + break; + case diagObj.db.LINETYPE.LOOP_END: + case diagObj.db.LINETYPE.ALT_END: + case diagObj.db.LINETYPE.OPT_END: + case diagObj.db.LINETYPE.PAR_END: + case diagObj.db.LINETYPE.CRITICAL_END: + case diagObj.db.LINETYPE.BREAK_END: + current = stack.pop(); + loops[current.id] = current; + break; + case diagObj.db.LINETYPE.ACTIVE_START: + { + const actorRect = actors[msg.from ? msg.from.actor : msg.to.actor]; + const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length; + const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf$4.activationWidth / 2; + const toAdd = { + startx: x, + stopx: x + conf$4.activationWidth, + actor: msg.from.actor, + enabled: true + }; + bounds$2.activations.push(toAdd); + } + break; + case diagObj.db.LINETYPE.ACTIVE_END: + { + const lastActorActivationIdx = bounds$2.activations.map((a) => a.actor).lastIndexOf(msg.from.actor); + delete bounds$2.activations.splice(lastActorActivationIdx, 1)[0]; + } + break; + } + const isNote = msg.placement !== void 0; + if (isNote) { + noteModel = await buildNoteModel(msg, actors, diagObj); + msg.noteModel = noteModel; + stack.forEach((stk) => { + current = stk; + current.from = common$1.getMin(current.from, noteModel.startx); + current.to = common$1.getMax(current.to, noteModel.startx + noteModel.width); + current.width = common$1.getMax(current.width, Math.abs(current.from - current.to)) - conf$4.labelBoxWidth; + }); + } else { + msgModel = buildMessageModel(msg, actors, diagObj); + msg.msgModel = msgModel; + if (msgModel.startx && msgModel.stopx && stack.length > 0) { + stack.forEach((stk) => { + current = stk; + if (msgModel.startx === msgModel.stopx) { + const from = actors[msg.from]; + const to = actors[msg.to]; + current.from = common$1.getMin( + from.x - msgModel.width / 2, + from.x - from.width / 2, + current.from + ); + current.to = common$1.getMax( + to.x + msgModel.width / 2, + to.x + from.width / 2, + current.to + ); + current.width = common$1.getMax(current.width, Math.abs(current.to - current.from)) - conf$4.labelBoxWidth; + } else { + current.from = common$1.getMin(msgModel.startx, current.from); + current.to = common$1.getMax(msgModel.stopx, current.to); + current.width = common$1.getMax(current.width, msgModel.width) - conf$4.labelBoxWidth; + } + }); + } + } + } + bounds$2.activations = []; + log$1.debug("Loop type widths:", loops); + return loops; +}; +const renderer$b = { + bounds: bounds$2, + drawActors, + drawActorsPopup, + setConf: setConf$4, + draw: draw$a +}; +const diagram$a = { + parser: parser$1$7, + db: db$8, + renderer: renderer$b, + styles: styles$6, + init: ({ wrap }) => { + db$8.setWrap(wrap); + } +}; + +var sequenceDiagram6894f283 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$a +}); + +var parser$7 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 17], $V1 = [1, 18], $V2 = [1, 19], $V3 = [1, 39], $V4 = [1, 40], $V5 = [1, 25], $V6 = [1, 23], $V7 = [1, 24], $V8 = [1, 31], $V9 = [1, 32], $Va = [1, 33], $Vb = [1, 34], $Vc = [1, 35], $Vd = [1, 36], $Ve = [1, 26], $Vf = [1, 27], $Vg = [1, 28], $Vh = [1, 29], $Vi = [1, 43], $Vj = [1, 30], $Vk = [1, 42], $Vl = [1, 44], $Vm = [1, 41], $Vn = [1, 45], $Vo = [1, 9], $Vp = [1, 8, 9], $Vq = [1, 56], $Vr = [1, 57], $Vs = [1, 58], $Vt = [1, 59], $Vu = [1, 60], $Vv = [1, 61], $Vw = [1, 62], $Vx = [1, 8, 9, 39], $Vy = [1, 74], $Vz = [1, 8, 9, 12, 13, 21, 37, 39, 42, 59, 60, 61, 62, 63, 64, 65, 70, 72], $VA = [1, 8, 9, 12, 13, 19, 21, 37, 39, 42, 46, 59, 60, 61, 62, 63, 64, 65, 70, 72, 74, 80, 95, 97, 98], $VB = [13, 74, 80, 95, 97, 98], $VC = [13, 64, 65, 74, 80, 95, 97, 98], $VD = [13, 59, 60, 61, 62, 63, 74, 80, 95, 97, 98], $VE = [1, 93], $VF = [1, 110], $VG = [1, 108], $VH = [1, 102], $VI = [1, 103], $VJ = [1, 104], $VK = [1, 105], $VL = [1, 106], $VM = [1, 107], $VN = [1, 109], $VO = [1, 8, 9, 37, 39, 42], $VP = [1, 8, 9, 21], $VQ = [1, 8, 9, 78], $VR = [1, 8, 9, 21, 73, 74, 78, 80, 81, 82, 83, 84, 85]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mermaidDoc": 4, "statements": 5, "graphConfig": 6, "CLASS_DIAGRAM": 7, "NEWLINE": 8, "EOF": 9, "statement": 10, "classLabel": 11, "SQS": 12, "STR": 13, "SQE": 14, "namespaceName": 15, "alphaNumToken": 16, "className": 17, "classLiteralName": 18, "GENERICTYPE": 19, "relationStatement": 20, "LABEL": 21, "namespaceStatement": 22, "classStatement": 23, "memberStatement": 24, "annotationStatement": 25, "clickStatement": 26, "styleStatement": 27, "cssClassStatement": 28, "noteStatement": 29, "direction": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "namespaceIdentifier": 36, "STRUCT_START": 37, "classStatements": 38, "STRUCT_STOP": 39, "NAMESPACE": 40, "classIdentifier": 41, "STYLE_SEPARATOR": 42, "members": 43, "CLASS": 44, "ANNOTATION_START": 45, "ANNOTATION_END": 46, "MEMBER": 47, "SEPARATOR": 48, "relation": 49, "NOTE_FOR": 50, "noteText": 51, "NOTE": 52, "direction_tb": 53, "direction_bt": 54, "direction_rl": 55, "direction_lr": 56, "relationType": 57, "lineType": 58, "AGGREGATION": 59, "EXTENSION": 60, "COMPOSITION": 61, "DEPENDENCY": 62, "LOLLIPOP": 63, "LINE": 64, "DOTTED_LINE": 65, "CALLBACK": 66, "LINK": 67, "LINK_TARGET": 68, "CLICK": 69, "CALLBACK_NAME": 70, "CALLBACK_ARGS": 71, "HREF": 72, "STYLE": 73, "ALPHA": 74, "stylesOpt": 75, "CSSCLASS": 76, "style": 77, "COMMA": 78, "styleComponent": 79, "NUM": 80, "COLON": 81, "UNIT": 82, "SPACE": 83, "BRKT": 84, "PCT": 85, "commentToken": 86, "textToken": 87, "graphCodeTokens": 88, "textNoTagsToken": 89, "TAGSTART": 90, "TAGEND": 91, "==": 92, "--": 93, "DEFAULT": 94, "MINUS": 95, "keywords": 96, "UNICODE_TEXT": 97, "BQUOTE_STR": 98, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 7: "CLASS_DIAGRAM", 8: "NEWLINE", 9: "EOF", 12: "SQS", 13: "STR", 14: "SQE", 19: "GENERICTYPE", 21: "LABEL", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 37: "STRUCT_START", 39: "STRUCT_STOP", 40: "NAMESPACE", 42: "STYLE_SEPARATOR", 44: "CLASS", 45: "ANNOTATION_START", 46: "ANNOTATION_END", 47: "MEMBER", 48: "SEPARATOR", 50: "NOTE_FOR", 52: "NOTE", 53: "direction_tb", 54: "direction_bt", 55: "direction_rl", 56: "direction_lr", 59: "AGGREGATION", 60: "EXTENSION", 61: "COMPOSITION", 62: "DEPENDENCY", 63: "LOLLIPOP", 64: "LINE", 65: "DOTTED_LINE", 66: "CALLBACK", 67: "LINK", 68: "LINK_TARGET", 69: "CLICK", 70: "CALLBACK_NAME", 71: "CALLBACK_ARGS", 72: "HREF", 73: "STYLE", 74: "ALPHA", 76: "CSSCLASS", 78: "COMMA", 80: "NUM", 81: "COLON", 82: "UNIT", 83: "SPACE", 84: "BRKT", 85: "PCT", 88: "graphCodeTokens", 90: "TAGSTART", 91: "TAGEND", 92: "==", 93: "--", 94: "DEFAULT", 95: "MINUS", 96: "keywords", 97: "UNICODE_TEXT", 98: "BQUOTE_STR" }, + productions_: [0, [3, 1], [3, 1], [4, 1], [6, 4], [5, 1], [5, 2], [5, 3], [11, 3], [15, 1], [15, 2], [17, 1], [17, 1], [17, 2], [17, 2], [17, 2], [10, 1], [10, 2], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [22, 4], [22, 5], [36, 2], [38, 1], [38, 2], [38, 3], [23, 1], [23, 3], [23, 4], [23, 6], [41, 2], [41, 3], [25, 4], [43, 1], [43, 2], [24, 1], [24, 2], [24, 1], [24, 1], [20, 3], [20, 4], [20, 4], [20, 5], [29, 3], [29, 2], [30, 1], [30, 1], [30, 1], [30, 1], [49, 3], [49, 2], [49, 2], [49, 1], [57, 1], [57, 1], [57, 1], [57, 1], [57, 1], [58, 1], [58, 1], [26, 3], [26, 4], [26, 3], [26, 4], [26, 4], [26, 5], [26, 3], [26, 4], [26, 4], [26, 5], [26, 4], [26, 5], [26, 5], [26, 6], [27, 3], [28, 3], [75, 1], [75, 3], [77, 1], [77, 2], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [86, 1], [86, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [89, 1], [89, 1], [89, 1], [89, 1], [16, 1], [16, 1], [16, 1], [16, 1], [18, 1], [51, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 8: + this.$ = $$[$0 - 1]; + break; + case 9: + case 11: + case 12: + this.$ = $$[$0]; + break; + case 10: + case 13: + this.$ = $$[$0 - 1] + $$[$0]; + break; + case 14: + case 15: + this.$ = $$[$0 - 1] + "~" + $$[$0] + "~"; + break; + case 16: + yy.addRelation($$[$0]); + break; + case 17: + $$[$0 - 1].title = yy.cleanupLabel($$[$0]); + yy.addRelation($$[$0 - 1]); + break; + case 27: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 28: + case 29: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 30: + yy.addClassesToNamespace($$[$0 - 3], $$[$0 - 1]); + break; + case 31: + yy.addClassesToNamespace($$[$0 - 4], $$[$0 - 1]); + break; + case 32: + this.$ = $$[$0]; + yy.addNamespace($$[$0]); + break; + case 33: + this.$ = [$$[$0]]; + break; + case 34: + this.$ = [$$[$0 - 1]]; + break; + case 35: + $$[$0].unshift($$[$0 - 2]); + this.$ = $$[$0]; + break; + case 37: + yy.setCssClass($$[$0 - 2], $$[$0]); + break; + case 38: + yy.addMembers($$[$0 - 3], $$[$0 - 1]); + break; + case 39: + yy.setCssClass($$[$0 - 5], $$[$0 - 3]); + yy.addMembers($$[$0 - 5], $$[$0 - 1]); + break; + case 40: + this.$ = $$[$0]; + yy.addClass($$[$0]); + break; + case 41: + this.$ = $$[$0 - 1]; + yy.addClass($$[$0 - 1]); + yy.setClassLabel($$[$0 - 1], $$[$0]); + break; + case 42: + yy.addAnnotation($$[$0], $$[$0 - 2]); + break; + case 43: + this.$ = [$$[$0]]; + break; + case 44: + $$[$0].push($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 45: + break; + case 46: + yy.addMember($$[$0 - 1], yy.cleanupLabel($$[$0])); + break; + case 47: + break; + case 48: + break; + case 49: + this.$ = { "id1": $$[$0 - 2], "id2": $$[$0], relation: $$[$0 - 1], relationTitle1: "none", relationTitle2: "none" }; + break; + case 50: + this.$ = { id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 1], relationTitle1: $$[$0 - 2], relationTitle2: "none" }; + break; + case 51: + this.$ = { id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: "none", relationTitle2: $$[$0 - 1] }; + break; + case 52: + this.$ = { id1: $$[$0 - 4], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: $$[$0 - 3], relationTitle2: $$[$0 - 1] }; + break; + case 53: + yy.addNote($$[$0], $$[$0 - 1]); + break; + case 54: + yy.addNote($$[$0]); + break; + case 55: + yy.setDirection("TB"); + break; + case 56: + yy.setDirection("BT"); + break; + case 57: + yy.setDirection("RL"); + break; + case 58: + yy.setDirection("LR"); + break; + case 59: + this.$ = { type1: $$[$0 - 2], type2: $$[$0], lineType: $$[$0 - 1] }; + break; + case 60: + this.$ = { type1: "none", type2: $$[$0], lineType: $$[$0 - 1] }; + break; + case 61: + this.$ = { type1: $$[$0 - 1], type2: "none", lineType: $$[$0] }; + break; + case 62: + this.$ = { type1: "none", type2: "none", lineType: $$[$0] }; + break; + case 63: + this.$ = yy.relationType.AGGREGATION; + break; + case 64: + this.$ = yy.relationType.EXTENSION; + break; + case 65: + this.$ = yy.relationType.COMPOSITION; + break; + case 66: + this.$ = yy.relationType.DEPENDENCY; + break; + case 67: + this.$ = yy.relationType.LOLLIPOP; + break; + case 68: + this.$ = yy.lineType.LINE; + break; + case 69: + this.$ = yy.lineType.DOTTED_LINE; + break; + case 70: + case 76: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 1], $$[$0]); + break; + case 71: + case 77: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 2], $$[$0]); + break; + case 72: + this.$ = $$[$0 - 2]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 73: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 74: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 2], $$[$0]); + break; + case 75: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 2], $$[$0]); + yy.setTooltip($$[$0 - 3], $$[$0 - 1]); + break; + case 78: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 79: + this.$ = $$[$0 - 4]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 80: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 81: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 1], $$[$0]); + break; + case 82: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 1]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 83: + this.$ = $$[$0 - 5]; + yy.setLink($$[$0 - 4], $$[$0 - 2], $$[$0]); + yy.setTooltip($$[$0 - 4], $$[$0 - 1]); + break; + case 84: + this.$ = $$[$0 - 2]; + yy.setCssStyle($$[$0 - 1], $$[$0]); + break; + case 85: + yy.setCssClass($$[$0 - 1], $$[$0]); + break; + case 86: + this.$ = [$$[$0]]; + break; + case 87: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 89: + this.$ = $$[$0 - 1] + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: 4, 7: [1, 6], 10: 5, 16: 37, 17: 20, 18: 38, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 31: $V0, 33: $V1, 35: $V2, 36: 21, 40: $V3, 41: 22, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 1: [3] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3] }, o($Vo, [2, 5], { 8: [1, 46] }), { 8: [1, 47] }, o($Vp, [2, 16], { 21: [1, 48] }), o($Vp, [2, 18]), o($Vp, [2, 19]), o($Vp, [2, 20]), o($Vp, [2, 21]), o($Vp, [2, 22]), o($Vp, [2, 23]), o($Vp, [2, 24]), o($Vp, [2, 25]), o($Vp, [2, 26]), { 32: [1, 49] }, { 34: [1, 50] }, o($Vp, [2, 29]), o($Vp, [2, 45], { 49: 51, 57: 54, 58: 55, 13: [1, 52], 21: [1, 53], 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu, 64: $Vv, 65: $Vw }), { 37: [1, 63] }, o($Vx, [2, 36], { 37: [1, 65], 42: [1, 64] }), o($Vp, [2, 47]), o($Vp, [2, 48]), { 16: 66, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 16: 37, 17: 67, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 16: 37, 17: 68, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 16: 37, 17: 69, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 74: [1, 70] }, { 13: [1, 71] }, { 16: 37, 17: 72, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 13: $Vy, 51: 73 }, o($Vp, [2, 55]), o($Vp, [2, 56]), o($Vp, [2, 57]), o($Vp, [2, 58]), o($Vz, [2, 11], { 16: 37, 18: 38, 17: 75, 19: [1, 76], 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }), o($Vz, [2, 12], { 19: [1, 77] }), { 15: 78, 16: 79, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 16: 37, 17: 80, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VA, [2, 112]), o($VA, [2, 113]), o($VA, [2, 114]), o($VA, [2, 115]), o([1, 8, 9, 12, 13, 19, 21, 37, 39, 42, 59, 60, 61, 62, 63, 64, 65, 70, 72], [2, 116]), o($Vo, [2, 6], { 10: 5, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 17: 20, 36: 21, 41: 22, 16: 37, 18: 38, 5: 81, 31: $V0, 33: $V1, 35: $V2, 40: $V3, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }), { 5: 82, 10: 5, 16: 37, 17: 20, 18: 38, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 31: $V0, 33: $V1, 35: $V2, 36: 21, 40: $V3, 41: 22, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($Vp, [2, 17]), o($Vp, [2, 27]), o($Vp, [2, 28]), { 13: [1, 84], 16: 37, 17: 83, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 49: 85, 57: 54, 58: 55, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu, 64: $Vv, 65: $Vw }, o($Vp, [2, 46]), { 58: 86, 64: $Vv, 65: $Vw }, o($VB, [2, 62], { 57: 87, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu }), o($VC, [2, 63]), o($VC, [2, 64]), o($VC, [2, 65]), o($VC, [2, 66]), o($VC, [2, 67]), o($VD, [2, 68]), o($VD, [2, 69]), { 8: [1, 89], 23: 90, 38: 88, 41: 22, 44: $V4 }, { 16: 91, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 43: 92, 47: $VE }, { 46: [1, 94] }, { 13: [1, 95] }, { 13: [1, 96] }, { 70: [1, 97], 72: [1, 98] }, { 21: $VF, 73: $VG, 74: $VH, 75: 99, 77: 100, 79: 101, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }, { 74: [1, 111] }, { 13: $Vy, 51: 112 }, o($Vp, [2, 54]), o($Vp, [2, 117]), o($Vz, [2, 13]), o($Vz, [2, 14]), o($Vz, [2, 15]), { 37: [2, 32] }, { 15: 113, 16: 79, 37: [2, 9], 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, o($VO, [2, 40], { 11: 114, 12: [1, 115] }), o($Vo, [2, 7]), { 9: [1, 116] }, o($VP, [2, 49]), { 16: 37, 17: 117, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 13: [1, 119], 16: 37, 17: 118, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VB, [2, 61], { 57: 120, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu }), o($VB, [2, 60]), { 39: [1, 121] }, { 23: 90, 38: 122, 41: 22, 44: $V4 }, { 8: [1, 123], 39: [2, 33] }, o($Vx, [2, 37], { 37: [1, 124] }), { 39: [1, 125] }, { 39: [2, 43], 43: 126, 47: $VE }, { 16: 37, 17: 127, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($Vp, [2, 70], { 13: [1, 128] }), o($Vp, [2, 72], { 13: [1, 130], 68: [1, 129] }), o($Vp, [2, 76], { 13: [1, 131], 71: [1, 132] }), { 13: [1, 133] }, o($Vp, [2, 84], { 78: [1, 134] }), o($VQ, [2, 86], { 79: 135, 21: $VF, 73: $VG, 74: $VH, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }), o($VR, [2, 88]), o($VR, [2, 90]), o($VR, [2, 91]), o($VR, [2, 92]), o($VR, [2, 93]), o($VR, [2, 94]), o($VR, [2, 95]), o($VR, [2, 96]), o($VR, [2, 97]), o($VR, [2, 98]), o($Vp, [2, 85]), o($Vp, [2, 53]), { 37: [2, 10] }, o($VO, [2, 41]), { 13: [1, 136] }, { 1: [2, 4] }, o($VP, [2, 51]), o($VP, [2, 50]), { 16: 37, 17: 137, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VB, [2, 59]), o($Vp, [2, 30]), { 39: [1, 138] }, { 23: 90, 38: 139, 39: [2, 34], 41: 22, 44: $V4 }, { 43: 140, 47: $VE }, o($Vx, [2, 38]), { 39: [2, 44] }, o($Vp, [2, 42]), o($Vp, [2, 71]), o($Vp, [2, 73]), o($Vp, [2, 74], { 68: [1, 141] }), o($Vp, [2, 77]), o($Vp, [2, 78], { 13: [1, 142] }), o($Vp, [2, 80], { 13: [1, 144], 68: [1, 143] }), { 21: $VF, 73: $VG, 74: $VH, 77: 145, 79: 101, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }, o($VR, [2, 89]), { 14: [1, 146] }, o($VP, [2, 52]), o($Vp, [2, 31]), { 39: [2, 35] }, { 39: [1, 147] }, o($Vp, [2, 75]), o($Vp, [2, 79]), o($Vp, [2, 81]), o($Vp, [2, 82], { 68: [1, 148] }), o($VQ, [2, 87], { 79: 135, 21: $VF, 73: $VG, 74: $VH, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }), o($VO, [2, 8]), o($Vx, [2, 39]), o($Vp, [2, 83])], + defaultActions: { 2: [2, 1], 3: [2, 2], 4: [2, 3], 78: [2, 32], 113: [2, 10], 116: [2, 4], 126: [2, 44], 139: [2, 35] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 53; + case 1: + return 54; + case 2: + return 55; + case 3: + return 56; + case 4: + break; + case 5: + break; + case 6: + this.begin("acc_title"); + return 31; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 33; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + return 8; + case 14: + break; + case 15: + return 7; + case 16: + return 7; + case 17: + return "EDGE_STATE"; + case 18: + this.begin("callback_name"); + break; + case 19: + this.popState(); + break; + case 20: + this.popState(); + this.begin("callback_args"); + break; + case 21: + return 70; + case 22: + this.popState(); + break; + case 23: + return 71; + case 24: + this.popState(); + break; + case 25: + return "STR"; + case 26: + this.begin("string"); + break; + case 27: + return 73; + case 28: + this.begin("namespace"); + return 40; + case 29: + this.popState(); + return 8; + case 30: + break; + case 31: + this.begin("namespace-body"); + return 37; + case 32: + this.popState(); + return 39; + case 33: + return "EOF_IN_STRUCT"; + case 34: + return 8; + case 35: + break; + case 36: + return "EDGE_STATE"; + case 37: + this.begin("class"); + return 44; + case 38: + this.popState(); + return 8; + case 39: + break; + case 40: + this.popState(); + this.popState(); + return 39; + case 41: + this.begin("class-body"); + return 37; + case 42: + this.popState(); + return 39; + case 43: + return "EOF_IN_STRUCT"; + case 44: + return "EDGE_STATE"; + case 45: + return "OPEN_IN_STRUCT"; + case 46: + break; + case 47: + return "MEMBER"; + case 48: + return 76; + case 49: + return 66; + case 50: + return 67; + case 51: + return 69; + case 52: + return 50; + case 53: + return 52; + case 54: + return 45; + case 55: + return 46; + case 56: + return 72; + case 57: + this.popState(); + break; + case 58: + return "GENERICTYPE"; + case 59: + this.begin("generic"); + break; + case 60: + this.popState(); + break; + case 61: + return "BQUOTE_STR"; + case 62: + this.begin("bqstring"); + break; + case 63: + return 68; + case 64: + return 68; + case 65: + return 68; + case 66: + return 68; + case 67: + return 60; + case 68: + return 60; + case 69: + return 62; + case 70: + return 62; + case 71: + return 61; + case 72: + return 59; + case 73: + return 63; + case 74: + return 64; + case 75: + return 65; + case 76: + return 21; + case 77: + return 42; + case 78: + return 95; + case 79: + return "DOT"; + case 80: + return "PLUS"; + case 81: + return 81; + case 82: + return 78; + case 83: + return 84; + case 84: + return 84; + case 85: + return 85; + case 86: + return "EQUALS"; + case 87: + return "EQUALS"; + case 88: + return 74; + case 89: + return 12; + case 90: + return 14; + case 91: + return "PUNCTUATION"; + case 92: + return 80; + case 93: + return 97; + case 94: + return 83; + case 95: + return 83; + case 96: + return 9; + } + }, + rules: [/^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/, /^(?:%%[^\n]*(\r?\n)*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:classDiagram-v2\b)/, /^(?:classDiagram\b)/, /^(?:\[\*\])/, /^(?:call[\s]+)/, /^(?:\([\s]*\))/, /^(?:\()/, /^(?:[^(]*)/, /^(?:\))/, /^(?:[^)]*)/, /^(?:["])/, /^(?:[^"]*)/, /^(?:["])/, /^(?:style\b)/, /^(?:namespace\b)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:[{])/, /^(?:[}])/, /^(?:$)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:\[\*\])/, /^(?:class\b)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:[}])/, /^(?:[{])/, /^(?:[}])/, /^(?:$)/, /^(?:\[\*\])/, /^(?:[{])/, /^(?:[\n])/, /^(?:[^{}\n]*)/, /^(?:cssClass\b)/, /^(?:callback\b)/, /^(?:link\b)/, /^(?:click\b)/, /^(?:note for\b)/, /^(?:note\b)/, /^(?:<<)/, /^(?:>>)/, /^(?:href\b)/, /^(?:[~])/, /^(?:[^~]*)/, /^(?:~)/, /^(?:[`])/, /^(?:[^`]+)/, /^(?:[`])/, /^(?:_self\b)/, /^(?:_blank\b)/, /^(?:_parent\b)/, /^(?:_top\b)/, /^(?:\s*<\|)/, /^(?:\s*\|>)/, /^(?:\s*>)/, /^(?:\s*<)/, /^(?:\s*\*)/, /^(?:\s*o\b)/, /^(?:\s*\(\))/, /^(?:--)/, /^(?:\.\.)/, /^(?::{1}[^:\n;]+)/, /^(?::{3})/, /^(?:-)/, /^(?:\.)/, /^(?:\+)/, /^(?::)/, /^(?:,)/, /^(?:#)/, /^(?:#)/, /^(?:%)/, /^(?:=)/, /^(?:=)/, /^(?:\w+)/, /^(?:\[)/, /^(?:\])/, /^(?:[!"#$%&'*+,-.`?\\/])/, /^(?:[0-9]+)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\s)/, /^(?:\s)/, /^(?:$)/], + conditions: { "namespace-body": { "rules": [26, 32, 33, 34, 35, 36, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "namespace": { "rules": [26, 28, 29, 30, 31, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "class-body": { "rules": [26, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "class": { "rules": [26, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_descr": { "rules": [9, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_title": { "rules": [7, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "callback_args": { "rules": [22, 23, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "callback_name": { "rules": [19, 20, 21, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "href": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "struct": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "generic": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "bqstring": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "string": { "rules": [24, 25, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 26, 27, 28, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$7.parser = parser$7; +const parser$1$6 = parser$7; +const visibilityValues = ["#", "+", "~", "-", ""]; +class ClassMember { + constructor(input, memberType) { + this.memberType = memberType; + this.visibility = ""; + this.classifier = ""; + const sanitizedInput = sanitizeText$2$1(input, getConfig$2()); + this.parseMember(sanitizedInput); + } + getDisplayDetails() { + let displayText = this.visibility + parseGenericTypes(this.id); + if (this.memberType === "method") { + displayText += `(${parseGenericTypes(this.parameters.trim())})`; + if (this.returnType) { + displayText += " : " + parseGenericTypes(this.returnType); + } + } + displayText = displayText.trim(); + const cssStyle = this.parseClassifier(); + return { + displayText, + cssStyle + }; + } + parseMember(input) { + let potentialClassifier = ""; + if (this.memberType === "method") { + const methodRegEx = /([#+~-])?(.+)\((.*)\)([\s$*])?(.*)([$*])?/; + const match = input.match(methodRegEx); + if (match) { + const detectedVisibility = match[1] ? match[1].trim() : ""; + if (visibilityValues.includes(detectedVisibility)) { + this.visibility = detectedVisibility; + } + this.id = match[2].trim(); + this.parameters = match[3] ? match[3].trim() : ""; + potentialClassifier = match[4] ? match[4].trim() : ""; + this.returnType = match[5] ? match[5].trim() : ""; + if (potentialClassifier === "") { + const lastChar = this.returnType.substring(this.returnType.length - 1); + if (lastChar.match(/[$*]/)) { + potentialClassifier = lastChar; + this.returnType = this.returnType.substring(0, this.returnType.length - 1); + } + } + } + } else { + const length = input.length; + const firstChar = input.substring(0, 1); + const lastChar = input.substring(length - 1); + if (visibilityValues.includes(firstChar)) { + this.visibility = firstChar; + } + if (lastChar.match(/[$*]/)) { + potentialClassifier = lastChar; + } + this.id = input.substring( + this.visibility === "" ? 0 : 1, + potentialClassifier === "" ? length : length - 1 + ); + } + this.classifier = potentialClassifier; + } + parseClassifier() { + switch (this.classifier) { + case "*": + return "font-style:italic;"; + case "$": + return "text-decoration:underline;"; + default: + return ""; + } + } +} +const MERMAID_DOM_ID_PREFIX = "classId-"; +let relations = []; +let classes$2 = {}; +let notes = []; +let classCounter = 0; +let namespaces = {}; +let namespaceCounter = 0; +let functions = []; +const sanitizeText$2 = (txt) => common$1.sanitizeText(txt, getConfig$2()); +const splitClassNameAndType = function(_id) { + const id = common$1.sanitizeText(_id, getConfig$2()); + let genericType = ""; + let className = id; + if (id.indexOf("~") > 0) { + const split = id.split("~"); + className = sanitizeText$2(split[0]); + genericType = sanitizeText$2(split[1]); + } + return { className, type: genericType }; +}; +const setClassLabel = function(_id, label) { + const id = common$1.sanitizeText(_id, getConfig$2()); + if (label) { + label = sanitizeText$2(label); + } + const { className } = splitClassNameAndType(id); + classes$2[className].label = label; +}; +const addClass = function(_id) { + const id = common$1.sanitizeText(_id, getConfig$2()); + const { className, type } = splitClassNameAndType(id); + if (Object.hasOwn(classes$2, className)) { + return; + } + const name = common$1.sanitizeText(className, getConfig$2()); + classes$2[name] = { + id: name, + type, + label: name, + cssClasses: [], + methods: [], + members: [], + annotations: [], + styles: [], + domId: MERMAID_DOM_ID_PREFIX + name + "-" + classCounter + }; + classCounter++; +}; +const lookUpDomId = function(_id) { + const id = common$1.sanitizeText(_id, getConfig$2()); + if (id in classes$2) { + return classes$2[id].domId; + } + throw new Error("Class not found: " + id); +}; +const clear$6 = function() { + relations = []; + classes$2 = {}; + notes = []; + functions = []; + functions.push(setupToolTips); + namespaces = {}; + namespaceCounter = 0; + clear$k(); +}; +const getClass = function(id) { + return classes$2[id]; +}; +const getClasses$5 = function() { + return classes$2; +}; +const getRelations$1 = function() { + return relations; +}; +const getNotes = function() { + return notes; +}; +const addRelation$1 = function(relation) { + log$1.debug("Adding relation: " + JSON.stringify(relation)); + addClass(relation.id1); + addClass(relation.id2); + relation.id1 = splitClassNameAndType(relation.id1).className; + relation.id2 = splitClassNameAndType(relation.id2).className; + relation.relationTitle1 = common$1.sanitizeText(relation.relationTitle1.trim(), getConfig$2()); + relation.relationTitle2 = common$1.sanitizeText(relation.relationTitle2.trim(), getConfig$2()); + relations.push(relation); +}; +const addAnnotation = function(className, annotation) { + const validatedClassName = splitClassNameAndType(className).className; + classes$2[validatedClassName].annotations.push(annotation); +}; +const addMember = function(className, member) { + addClass(className); + const validatedClassName = splitClassNameAndType(className).className; + const theClass = classes$2[validatedClassName]; + if (typeof member === "string") { + const memberString = member.trim(); + if (memberString.startsWith("<<") && memberString.endsWith(">>")) { + theClass.annotations.push(sanitizeText$2(memberString.substring(2, memberString.length - 2))); + } else if (memberString.indexOf(")") > 0) { + theClass.methods.push(new ClassMember(memberString, "method")); + } else if (memberString) { + theClass.members.push(new ClassMember(memberString, "attribute")); + } + } +}; +const addMembers = function(className, members) { + if (Array.isArray(members)) { + members.reverse(); + members.forEach((member) => addMember(className, member)); + } +}; +const addNote = function(text, className) { + const note = { + id: `note${notes.length}`, + class: className, + text + }; + notes.push(note); +}; +const cleanupLabel$1 = function(label) { + if (label.startsWith(":")) { + label = label.substring(1); + } + return sanitizeText$2(label.trim()); +}; +const setCssClass$2 = function(ids, className) { + ids.split(",").forEach(function(_id) { + let id = _id; + if (_id[0].match(/\d/)) { + id = MERMAID_DOM_ID_PREFIX + id; + } + if (classes$2[id] !== void 0) { + classes$2[id].cssClasses.push(className); + } + }); +}; +const setTooltip = function(ids, tooltip) { + ids.split(",").forEach(function(id) { + if (tooltip !== void 0) { + classes$2[id].tooltip = sanitizeText$2(tooltip); + } + }); +}; +const getTooltip = function(id, namespace) { + if (namespace) { + return namespaces[namespace].classes[id].tooltip; + } + return classes$2[id].tooltip; +}; +const setLink = function(ids, linkStr, target) { + const config = getConfig$2(); + ids.split(",").forEach(function(_id) { + let id = _id; + if (_id[0].match(/\d/)) { + id = MERMAID_DOM_ID_PREFIX + id; + } + if (classes$2[id] !== void 0) { + classes$2[id].link = utils.formatUrl(linkStr, config); + if (config.securityLevel === "sandbox") { + classes$2[id].linkTarget = "_top"; + } else if (typeof target === "string") { + classes$2[id].linkTarget = sanitizeText$2(target); + } else { + classes$2[id].linkTarget = "_blank"; + } + } + }); + setCssClass$2(ids, "clickable"); +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFunc(id, functionName, functionArgs); + classes$2[id].haveCallback = true; + }); + setCssClass$2(ids, "clickable"); +}; +const setClickFunc = function(_domId, functionName, functionArgs) { + const domId = common$1.sanitizeText(_domId, getConfig$2()); + const config = getConfig$2(); + if (config.securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + const id = domId; + if (classes$2[id] !== void 0) { + const elemId = lookUpDomId(id); + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(elemId); + } + functions.push(function() { + const elem = document.querySelector(`[id="${elemId}"]`); + if (elem !== null) { + elem.addEventListener( + "click", + function() { + utils.runFunc(functionName, ...argList); + }, + false + ); + } + }); + } +}; +const bindFunctions = function(element) { + functions.forEach(function(fun) { + fun(element); + }); +}; +const lineType$1 = { + LINE: 0, + DOTTED_LINE: 1 +}; +const relationType$1 = { + AGGREGATION: 0, + EXTENSION: 1, + COMPOSITION: 2, + DEPENDENCY: 3, + LOLLIPOP: 4 +}; +const setupToolTips = function(element) { + let tooltipElem = select(".mermaidTooltip"); + if ((tooltipElem._groups || tooltipElem)[0][0] === null) { + tooltipElem = select("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0); + } + const svg = select(element).select("svg"); + const nodes = svg.selectAll("g.node"); + nodes.on("mouseover", function() { + const el = select(this); + const title = el.attr("title"); + if (title === null) { + return; + } + const rect = this.getBoundingClientRect(); + tooltipElem.transition().duration(200).style("opacity", ".9"); + tooltipElem.text(el.attr("title")).style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.top - 14 + document.body.scrollTop + "px"); + tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, "
    ")); + el.classed("hover", true); + }).on("mouseout", function() { + tooltipElem.transition().duration(500).style("opacity", 0); + const el = select(this); + el.classed("hover", false); + }); +}; +functions.push(setupToolTips); +let direction$1 = "TB"; +const getDirection$1 = () => direction$1; +const setDirection$1 = (dir) => { + direction$1 = dir; +}; +const addNamespace = function(id) { + if (namespaces[id] !== void 0) { + return; + } + namespaces[id] = { + id, + classes: {}, + children: {}, + domId: MERMAID_DOM_ID_PREFIX + id + "-" + namespaceCounter + }; + namespaceCounter++; +}; +const getNamespace = function(name) { + return namespaces[name]; +}; +const getNamespaces = function() { + return namespaces; +}; +const addClassesToNamespace = function(id, classNames) { + if (namespaces[id] === void 0) { + return; + } + for (const name of classNames) { + const { className } = splitClassNameAndType(name); + classes$2[className].parent = id; + namespaces[id].classes[className] = classes$2[className]; + } +}; +const setCssStyle = function(id, styles2) { + const thisClass = classes$2[id]; + if (!styles2 || !thisClass) { + return; + } + for (const s of styles2) { + if (s.includes(",")) { + thisClass.styles.push(...s.split(",")); + } else { + thisClass.styles.push(s); + } + } +}; +const db$7 = { + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + getConfig: () => getConfig$2().class, + addClass, + bindFunctions, + clear: clear$6, + getClass, + getClasses: getClasses$5, + getNotes, + addAnnotation, + addNote, + getRelations: getRelations$1, + addRelation: addRelation$1, + getDirection: getDirection$1, + setDirection: setDirection$1, + addMember, + addMembers, + cleanupLabel: cleanupLabel$1, + lineType: lineType$1, + relationType: relationType$1, + setClickEvent, + setCssClass: setCssClass$2, + setLink, + getTooltip, + setTooltip, + lookUpDomId, + setDiagramTitle, + getDiagramTitle, + setClassLabel, + addNamespace, + addClassesToNamespace, + getNamespace, + getNamespaces, + setCssStyle +}; +const getStyles$6 = (options) => `g.classGroup text { + fill: ${options.nodeBorder || options.classText}; + stroke: none; + font-family: ${options.fontFamily}; + font-size: 10px; + + .title { + font-weight: bolder; + } + +} + +.nodeLabel, .edgeLabel { + color: ${options.classText}; +} +.edgeLabel .label rect { + fill: ${options.mainBkg}; +} +.label text { + fill: ${options.classText}; +} +.edgeLabel .label span { + background: ${options.mainBkg}; +} + +.classTitle { + font-weight: bolder; +} +.node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + +.divider { + stroke: ${options.nodeBorder}; + stroke-width: 1; +} + +g.clickable { + cursor: pointer; +} + +g.classGroup rect { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; +} + +g.classGroup line { + stroke: ${options.nodeBorder}; + stroke-width: 1; +} + +.classLabel .box { + stroke: none; + stroke-width: 0; + fill: ${options.mainBkg}; + opacity: 0.5; +} + +.classLabel .label { + fill: ${options.nodeBorder}; + font-size: 10px; +} + +.relation { + stroke: ${options.lineColor}; + stroke-width: 1; + fill: none; +} + +.dashed-line{ + stroke-dasharray: 3; +} + +.dotted-line{ + stroke-dasharray: 1 2; +} + +#compositionStart, .composition { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#compositionEnd, .composition { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#dependencyStart, .dependency { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#dependencyStart, .dependency { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#extensionStart, .extension { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#extensionEnd, .extension { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#aggregationStart, .aggregation { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#aggregationEnd, .aggregation { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#lollipopStart, .lollipop { + fill: ${options.mainBkg} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#lollipopEnd, .lollipop { + fill: ${options.mainBkg} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +.edgeTerminals { + font-size: 11px; + line-height: initial; +} + +.classTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; +} +`; +const styles$5 = getStyles$6; + +let edgeCount$2 = 0; +const drawEdge$1 = function(elem, path, relation, conf, diagObj) { + const getRelationType = function(type) { + switch (type) { + case diagObj.db.relationType.AGGREGATION: + return "aggregation"; + case diagObj.db.relationType.EXTENSION: + return "extension"; + case diagObj.db.relationType.COMPOSITION: + return "composition"; + case diagObj.db.relationType.DEPENDENCY: + return "dependency"; + case diagObj.db.relationType.LOLLIPOP: + return "lollipop"; + } + }; + path.points = path.points.filter((p) => !Number.isNaN(p.y)); + const lineData = path.points; + const lineFunction = line$1().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount$2).attr("class", "relation"); + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + if (relation.relation.lineType == 1) { + svgPath.attr("class", "relation dashed-line"); + } + if (relation.relation.lineType == 10) { + svgPath.attr("class", "relation dotted-line"); + } + if (relation.relation.type1 !== "none") { + svgPath.attr( + "marker-start", + "url(" + url + "#" + getRelationType(relation.relation.type1) + "Start)" + ); + } + if (relation.relation.type2 !== "none") { + svgPath.attr( + "marker-end", + "url(" + url + "#" + getRelationType(relation.relation.type2) + "End)" + ); + } + let x, y; + const l = path.points.length; + let labelPosition = utils.calcLabelPosition(path.points); + x = labelPosition.x; + y = labelPosition.y; + let p1_card_x, p1_card_y; + let p2_card_x, p2_card_y; + if (l % 2 !== 0 && l > 1) { + let cardinality_1_point = utils.calcCardinalityPosition( + relation.relation.type1 !== "none", + path.points, + path.points[0] + ); + let cardinality_2_point = utils.calcCardinalityPosition( + relation.relation.type2 !== "none", + path.points, + path.points[l - 1] + ); + log$1.debug("cardinality_1_point " + JSON.stringify(cardinality_1_point)); + log$1.debug("cardinality_2_point " + JSON.stringify(cardinality_2_point)); + p1_card_x = cardinality_1_point.x; + p1_card_y = cardinality_1_point.y; + p2_card_x = cardinality_2_point.x; + p2_card_y = cardinality_2_point.y; + } + if (relation.title !== void 0) { + const g = elem.append("g").attr("class", "classLabel"); + const label = g.append("text").attr("class", "label").attr("x", x).attr("y", y).attr("fill", "red").attr("text-anchor", "middle").text(relation.title); + window.label = label; + const bounds = label.node().getBBox(); + g.insert("rect", ":first-child").attr("class", "box").attr("x", bounds.x - conf.padding / 2).attr("y", bounds.y - conf.padding / 2).attr("width", bounds.width + conf.padding).attr("height", bounds.height + conf.padding); + } + log$1.info("Rendering relation " + JSON.stringify(relation)); + if (relation.relationTitle1 !== void 0 && relation.relationTitle1 !== "none") { + const g = elem.append("g").attr("class", "cardinality"); + g.append("text").attr("class", "type1").attr("x", p1_card_x).attr("y", p1_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle1); + } + if (relation.relationTitle2 !== void 0 && relation.relationTitle2 !== "none") { + const g = elem.append("g").attr("class", "cardinality"); + g.append("text").attr("class", "type2").attr("x", p2_card_x).attr("y", p2_card_y).attr("fill", "black").attr("font-size", "6").text(relation.relationTitle2); + } + edgeCount$2++; +}; +const drawClass = function(elem, classDef, conf, diagObj) { + log$1.debug("Rendering class ", classDef, conf); + const id = classDef.id; + const classInfo = { + id, + label: classDef.id, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", diagObj.db.lookUpDomId(id)).attr("class", "classGroup"); + let title; + if (classDef.link) { + title = g.append("svg:a").attr("xlink:href", classDef.link).attr("target", classDef.linkTarget).append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + } else { + title = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + } + let isFirst = true; + classDef.annotations.forEach(function(member) { + const titleText2 = title.append("tspan").text("«" + member + "»"); + if (!isFirst) { + titleText2.attr("dy", conf.textHeight); + } + isFirst = false; + }); + let classTitleString = getClassTitleString(classDef); + const classTitle = title.append("tspan").text(classTitleString).attr("class", "title"); + if (!isFirst) { + classTitle.attr("dy", conf.textHeight); + } + const titleHeight = title.node().getBBox().height; + let membersLine; + let membersBox; + let methodsLine; + if (classDef.members.length > 0) { + membersLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin / 2).attr("y2", conf.padding + titleHeight + conf.dividerMargin / 2); + const members = g.append("text").attr("x", conf.padding).attr("y", titleHeight + conf.dividerMargin + conf.textHeight).attr("fill", "white").attr("class", "classText"); + isFirst = true; + classDef.members.forEach(function(member) { + addTspan(members, member, isFirst, conf); + isFirst = false; + }); + membersBox = members.node().getBBox(); + } + if (classDef.methods.length > 0) { + methodsLine = g.append("line").attr("x1", 0).attr("y1", conf.padding + titleHeight + conf.dividerMargin + membersBox.height).attr("y2", conf.padding + titleHeight + conf.dividerMargin + membersBox.height); + const methods = g.append("text").attr("x", conf.padding).attr("y", titleHeight + 2 * conf.dividerMargin + membersBox.height + conf.textHeight).attr("fill", "white").attr("class", "classText"); + isFirst = true; + classDef.methods.forEach(function(method) { + addTspan(methods, method, isFirst, conf); + isFirst = false; + }); + } + const classBox = g.node().getBBox(); + var cssClassStr = " "; + if (classDef.cssClasses.length > 0) { + cssClassStr = cssClassStr + classDef.cssClasses.join(" "); + } + const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", classBox.width + 2 * conf.padding).attr("height", classBox.height + conf.padding + 0.5 * conf.dividerMargin).attr("class", cssClassStr); + const rectWidth = rect.node().getBBox().width; + title.node().childNodes.forEach(function(x) { + x.setAttribute("x", (rectWidth - x.getBBox().width) / 2); + }); + if (classDef.tooltip) { + title.insert("title").text(classDef.tooltip); + } + if (membersLine) { + membersLine.attr("x2", rectWidth); + } + if (methodsLine) { + methodsLine.attr("x2", rectWidth); + } + classInfo.width = rectWidth; + classInfo.height = classBox.height + conf.padding + 0.5 * conf.dividerMargin; + return classInfo; +}; +const getClassTitleString = function(classDef) { + let classTitleString = classDef.id; + if (classDef.type) { + classTitleString += "<" + parseGenericTypes(classDef.type) + ">"; + } + return classTitleString; +}; +const drawNote$1 = function(elem, note, conf, diagObj) { + log$1.debug("Rendering note ", note, conf); + const id = note.id; + const noteInfo = { + id, + text: note.text, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", id).attr("class", "classGroup"); + let text = g.append("text").attr("y", conf.textHeight + conf.padding).attr("x", 0); + const lines = JSON.parse(`"${note.text}"`).split("\n"); + lines.forEach(function(line2) { + log$1.debug(`Adding line: ${line2}`); + text.append("tspan").text(line2).attr("class", "title").attr("dy", conf.textHeight); + }); + const noteBox = g.node().getBBox(); + const rect = g.insert("rect", ":first-child").attr("x", 0).attr("y", 0).attr("width", noteBox.width + 2 * conf.padding).attr( + "height", + noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin + ); + const rectWidth = rect.node().getBBox().width; + text.node().childNodes.forEach(function(x) { + x.setAttribute("x", (rectWidth - x.getBBox().width) / 2); + }); + noteInfo.width = rectWidth; + noteInfo.height = noteBox.height + lines.length * conf.textHeight + conf.padding + 0.5 * conf.dividerMargin; + return noteInfo; +}; +const addTspan = function(textEl, member, isFirst, conf) { + const { displayText, cssStyle } = member.getDisplayDetails(); + const tSpan = textEl.append("tspan").attr("x", conf.padding).text(displayText); + if (cssStyle !== "") { + tSpan.attr("style", member.cssStyle); + } + if (!isFirst) { + tSpan.attr("dy", conf.textHeight); + } +}; +const svgDraw$2 = { + getClassTitleString, + drawClass, + drawEdge: drawEdge$1, + drawNote: drawNote$1 +}; +let idCache = {}; +const padding$1 = 20; +const getGraphId = function(label) { + const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label); + if (foundEntry) { + return foundEntry[0]; + } +}; +const insertMarkers$1 = function(elem) { + elem.append("defs").append("marker").attr("id", "extensionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 1,7 L18,13 V 1 Z"); + elem.append("defs").append("marker").attr("id", "extensionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 1,1 V 13 L18,7 Z"); + elem.append("defs").append("marker").attr("id", "compositionStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "compositionEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "aggregationStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "aggregationEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "dependencyStart").attr("class", "extension").attr("refX", 0).attr("refY", 7).attr("markerWidth", 190).attr("markerHeight", 240).attr("orient", "auto").append("path").attr("d", "M 5,7 L9,13 L1,7 L9,1 Z"); + elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const draw$9 = function(text, id, _version, diagObj) { + const conf = getConfig$2().class; + idCache = {}; + log$1.info("Rendering diagram " + text); + const securityLevel = getConfig$2().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const diagram2 = root.select(`[id='${id}']`); + insertMarkers$1(diagram2); + const g = new Graph({ + multigraph: true + }); + g.setGraph({ + isMultiGraph: true + }); + g.setDefaultEdgeLabel(function() { + return {}; + }); + const classes = diagObj.db.getClasses(); + const keys = Object.keys(classes); + for (const key of keys) { + const classDef = classes[key]; + const node = svgDraw$2.drawClass(diagram2, classDef, conf, diagObj); + idCache[node.id] = node; + g.setNode(node.id, node); + log$1.info("Org height: " + node.height); + } + const relations = diagObj.db.getRelations(); + relations.forEach(function(relation) { + log$1.info( + // cspell:ignore tjoho + "tjoho" + getGraphId(relation.id1) + getGraphId(relation.id2) + JSON.stringify(relation) + ); + g.setEdge( + getGraphId(relation.id1), + getGraphId(relation.id2), + { + relation + }, + relation.title || "DEFAULT" + ); + }); + const notes = diagObj.db.getNotes(); + notes.forEach(function(note) { + log$1.debug(`Adding note: ${JSON.stringify(note)}`); + const node = svgDraw$2.drawNote(diagram2, note, conf, diagObj); + idCache[node.id] = node; + g.setNode(node.id, node); + if (note.class && note.class in classes) { + g.setEdge( + note.id, + getGraphId(note.class), + { + relation: { + id1: note.id, + id2: note.class, + relation: { + type1: "none", + type2: "none", + lineType: 10 + } + } + }, + "DEFAULT" + ); + } + }); + layout$2(g); + g.nodes().forEach(function(v) { + if (v !== void 0 && g.node(v) !== void 0) { + log$1.debug("Node " + v + ": " + JSON.stringify(g.node(v))); + root.select("#" + (diagObj.db.lookUpDomId(v) || v)).attr( + "transform", + "translate(" + (g.node(v).x - g.node(v).width / 2) + "," + (g.node(v).y - g.node(v).height / 2) + " )" + ); + } + }); + g.edges().forEach(function(e) { + if (e !== void 0 && g.edge(e) !== void 0) { + log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(g.edge(e))); + svgDraw$2.drawEdge(diagram2, g.edge(e), g.edge(e).relation, conf, diagObj); + } + }); + const svgBounds = diagram2.node().getBBox(); + const width = svgBounds.width + padding$1 * 2; + const height = svgBounds.height + padding$1 * 2; + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const vBox = `${svgBounds.x - padding$1} ${svgBounds.y - padding$1} ${width} ${height}`; + log$1.debug(`viewBox ${vBox}`); + diagram2.attr("viewBox", vBox); +}; +const renderer$a = { + draw: draw$9 +}; +const diagram$9 = { + parser: parser$1$6, + db: db$7, + renderer: renderer$a, + styles: styles$5, + init: (cnf) => { + if (!cnf.class) { + cnf.class = {}; + } + cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db$7.clear(); + } +}; + +var classDiagramFb54d2a0 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$9 +}); + +const sanitizeText$1 = (txt) => common$1.sanitizeText(txt, getConfig$2()); +let conf$3 = { + dividerMargin: 10, + padding: 5, + textHeight: 10, + curve: void 0 +}; +const addNamespaces = function(namespaces, g, _id, diagObj) { + const keys = Object.keys(namespaces); + log$1.info("keys:", keys); + log$1.info(namespaces); + keys.forEach(function(id) { + var _a, _b; + const vertex = namespaces[id]; + const shape = "rect"; + const node = { + shape, + id: vertex.id, + domId: vertex.domId, + labelText: sanitizeText$1(vertex.id), + labelStyle: "", + style: "fill: none; stroke: black", + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig$2().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig$2().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + addClasses(vertex.classes, g, _id, diagObj, vertex.id); + log$1.info("setNode", node); + }); +}; +const addClasses = function(classes, g, _id, diagObj, parent) { + const keys = Object.keys(classes); + log$1.info("keys:", keys); + log$1.info(classes); + keys.filter((id) => classes[id].parent == parent).forEach(function(id) { + var _a, _b; + const vertex = classes[id]; + const cssClassStr = vertex.cssClasses.join(" "); + const styles2 = getStylesFromArray(vertex.styles); + const vertexText = vertex.label ?? vertex.id; + const radius = 0; + const shape = "class_box"; + const node = { + labelStyle: styles2.labelStyle, + shape, + labelText: sanitizeText$1(vertexText), + classData: vertex, + rx: radius, + ry: radius, + class: cssClassStr, + style: styles2.style, + id: vertex.id, + domId: vertex.domId, + tooltip: diagObj.db.getTooltip(vertex.id, parent) || "", + haveCallback: vertex.haveCallback, + link: vertex.link, + width: vertex.type === "group" ? 500 : void 0, + type: vertex.type, + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig$2().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig$2().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + if (parent) { + g.setParent(vertex.id, parent); + } + log$1.info("setNode", node); + }); +}; +const addNotes = function(notes, g, startEdgeId, classes) { + log$1.info(notes); + notes.forEach(function(note, i) { + var _a, _b; + const vertex = note; + const cssNoteStr = ""; + const styles2 = { labelStyle: "", style: "" }; + const vertexText = vertex.text; + const radius = 0; + const shape = "note"; + const node = { + labelStyle: styles2.labelStyle, + shape, + labelText: sanitizeText$1(vertexText), + noteData: vertex, + rx: radius, + ry: radius, + class: cssNoteStr, + style: styles2.style, + id: vertex.id, + domId: vertex.id, + tooltip: "", + type: "note", + // TODO V10: Flowchart ? Keeping flowchart for backwards compatibility. Remove in next major release + padding: ((_a = getConfig$2().flowchart) == null ? void 0 : _a.padding) ?? ((_b = getConfig$2().class) == null ? void 0 : _b.padding) + }; + g.setNode(vertex.id, node); + log$1.info("setNode", node); + if (!vertex.class || !(vertex.class in classes)) { + return; + } + const edgeId = startEdgeId + i; + const edgeData = { + id: `edgeNote${edgeId}`, + //Set relationship style and line type + classes: "relation", + pattern: "dotted", + // Set link type for rendering + arrowhead: "none", + //Set edge extra labels + startLabelRight: "", + endLabelLeft: "", + //Set relation arrow types + arrowTypeStart: "none", + arrowTypeEnd: "none", + style: "fill:none", + labelStyle: "", + curve: interpolateToCurve(conf$3.curve, curveLinear) + }; + g.setEdge(vertex.id, vertex.class, edgeData, edgeId); + }); +}; +const addRelations = function(relations, g) { + const conf2 = getConfig$2().flowchart; + let cnt = 0; + relations.forEach(function(edge) { + var _a; + cnt++; + const edgeData = { + //Set relationship style and line type + classes: "relation", + pattern: edge.relation.lineType == 1 ? "dashed" : "solid", + id: `id_${edge.id1}_${edge.id2}_${cnt}`, + // Set link type for rendering + arrowhead: edge.type === "arrow_open" ? "none" : "normal", + //Set edge extra labels + startLabelRight: edge.relationTitle1 === "none" ? "" : edge.relationTitle1, + endLabelLeft: edge.relationTitle2 === "none" ? "" : edge.relationTitle2, + //Set relation arrow types + arrowTypeStart: getArrowMarker(edge.relation.type1), + arrowTypeEnd: getArrowMarker(edge.relation.type2), + style: "fill:none", + labelStyle: "", + curve: interpolateToCurve(conf2 == null ? void 0 : conf2.curve, curveLinear) + }; + log$1.info(edgeData, edge); + if (edge.style !== void 0) { + const styles2 = getStylesFromArray(edge.style); + edgeData.style = styles2.style; + edgeData.labelStyle = styles2.labelStyle; + } + edge.text = edge.title; + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + if (((_a = getConfig$2().flowchart) == null ? void 0 : _a.htmlLabels) ?? getConfig$2().htmlLabels) { + edgeData.labelType = "html"; + edgeData.label = '' + edge.text + ""; + } else { + edgeData.labelType = "text"; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + } + } + g.setEdge(edge.id1, edge.id2, edgeData, cnt); + }); +}; +const setConf$3 = function(cnf) { + conf$3 = { + ...conf$3, + ...cnf + }; +}; +const draw$8 = async function(text, id, _version, diagObj) { + log$1.info("Drawing class - ", id); + const conf2 = getConfig$2().flowchart ?? getConfig$2().class; + const securityLevel = getConfig$2().securityLevel; + log$1.info("config:", conf2); + const nodeSpacing = (conf2 == null ? void 0 : conf2.nodeSpacing) ?? 50; + const rankSpacing = (conf2 == null ? void 0 : conf2.rankSpacing) ?? 50; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: diagObj.db.getDirection(), + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + const namespaces = diagObj.db.getNamespaces(); + const classes = diagObj.db.getClasses(); + const relations = diagObj.db.getRelations(); + const notes = diagObj.db.getNotes(); + log$1.info(relations); + addNamespaces(namespaces, g, id, diagObj); + addClasses(classes, g, id, diagObj); + addRelations(relations, g); + addNotes(notes, g, relations.length + 1, classes); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render( + element, + g, + ["aggregation", "extension", "composition", "dependency", "lollipop"], + "classDiagram", + id + ); + utils.insertTitle(svg, "classTitleText", (conf2 == null ? void 0 : conf2.titleTopMargin) ?? 5, diagObj.db.getDiagramTitle()); + setupGraphViewbox$1(g, svg, conf2 == null ? void 0 : conf2.diagramPadding, conf2 == null ? void 0 : conf2.useMaxWidth); + if (!(conf2 == null ? void 0 : conf2.htmlLabels)) { + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } +}; +function getArrowMarker(type) { + let marker; + switch (type) { + case 0: + marker = "aggregation"; + break; + case 1: + marker = "extension"; + break; + case 2: + marker = "composition"; + break; + case 3: + marker = "dependency"; + break; + case 4: + marker = "lollipop"; + break; + default: + marker = "none"; + } + return marker; +} +const renderer$9 = { + setConf: setConf$3, + draw: draw$8 +}; +const diagram$8 = { + parser: parser$1$6, + db: db$7, + renderer: renderer$9, + styles: styles$5, + init: (cnf) => { + if (!cnf.class) { + cnf.class = {}; + } + cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db$7.clear(); + } +}; + +var classDiagramV2A2b738ad = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$8 +}); + +var parser$6 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 15], $V7 = [1, 16], $V8 = [1, 17], $V9 = [1, 18], $Va = [1, 30], $Vb = [1, 19], $Vc = [1, 20], $Vd = [1, 21], $Ve = [1, 22], $Vf = [1, 23], $Vg = [1, 25], $Vh = [1, 26], $Vi = [1, 27], $Vj = [1, 28], $Vk = [1, 29], $Vl = [1, 32], $Vm = [1, 33], $Vn = [1, 34], $Vo = [1, 35], $Vp = [1, 31], $Vq = [1, 4, 5, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $Vr = [1, 4, 5, 13, 14, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $Vs = [4, 5, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SPACE": 4, "NL": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "classDefStatement": 10, "cssClassStatement": 11, "idStatement": 12, "DESCR": 13, "-->": 14, "HIDE_EMPTY": 15, "scale": 16, "WIDTH": 17, "COMPOSIT_STATE": 18, "STRUCT_START": 19, "STRUCT_STOP": 20, "STATE_DESCR": 21, "AS": 22, "ID": 23, "FORK": 24, "JOIN": 25, "CHOICE": 26, "CONCURRENT": 27, "note": 28, "notePosition": 29, "NOTE_TEXT": 30, "direction": 31, "acc_title": 32, "acc_title_value": 33, "acc_descr": 34, "acc_descr_value": 35, "acc_descr_multiline_value": 36, "classDef": 37, "CLASSDEF_ID": 38, "CLASSDEF_STYLEOPTS": 39, "DEFAULT": 40, "class": 41, "CLASSENTITY_IDS": 42, "STYLECLASS": 43, "direction_tb": 44, "direction_bt": 45, "direction_rl": 46, "direction_lr": 47, "eol": 48, ";": 49, "EDGE_STATE": 50, "STYLE_SEPARATOR": 51, "left_of": 52, "right_of": 53, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACE", 5: "NL", 6: "SD", 13: "DESCR", 14: "-->", 15: "HIDE_EMPTY", 16: "scale", 17: "WIDTH", 18: "COMPOSIT_STATE", 19: "STRUCT_START", 20: "STRUCT_STOP", 21: "STATE_DESCR", 22: "AS", 23: "ID", 24: "FORK", 25: "JOIN", 26: "CHOICE", 27: "CONCURRENT", 28: "note", 30: "NOTE_TEXT", 32: "acc_title", 33: "acc_title_value", 34: "acc_descr", 35: "acc_descr_value", 36: "acc_descr_multiline_value", 37: "classDef", 38: "CLASSDEF_ID", 39: "CLASSDEF_STYLEOPTS", 40: "DEFAULT", 41: "class", 42: "CLASSENTITY_IDS", 43: "STYLECLASS", 44: "direction_tb", 45: "direction_bt", 46: "direction_rl", 47: "direction_lr", 49: ";", 50: "EDGE_STATE", 51: "STYLE_SEPARATOR", 52: "left_of", 53: "right_of" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 3], [9, 4], [9, 1], [9, 2], [9, 1], [9, 4], [9, 3], [9, 6], [9, 1], [9, 1], [9, 1], [9, 1], [9, 4], [9, 4], [9, 1], [9, 2], [9, 2], [9, 1], [10, 3], [10, 3], [11, 3], [31, 1], [31, 1], [31, 1], [31, 1], [48, 1], [48, 1], [12, 1], [12, 1], [12, 3], [12, 3], [29, 1], [29, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setRootDoc($$[$0]); + return $$[$0]; + case 4: + this.$ = []; + break; + case 5: + if ($$[$0] != "nl") { + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + } + break; + case 6: + case 7: + this.$ = $$[$0]; + break; + case 8: + this.$ = "nl"; + break; + case 11: + this.$ = $$[$0]; + break; + case 12: + const stateStmt = $$[$0 - 1]; + stateStmt.description = yy.trimColon($$[$0]); + this.$ = stateStmt; + break; + case 13: + this.$ = { stmt: "relation", state1: $$[$0 - 2], state2: $$[$0] }; + break; + case 14: + const relDescription = yy.trimColon($$[$0]); + this.$ = { stmt: "relation", state1: $$[$0 - 3], state2: $$[$0 - 1], description: relDescription }; + break; + case 18: + this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: "", doc: $$[$0 - 1] }; + break; + case 19: + var id = $$[$0]; + var description = $$[$0 - 2].trim(); + if ($$[$0].match(":")) { + var parts = $$[$0].split(":"); + id = parts[0]; + description = [description, parts[1]]; + } + this.$ = { stmt: "state", id, type: "default", description }; + break; + case 20: + this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: $$[$0 - 5], doc: $$[$0 - 1] }; + break; + case 21: + this.$ = { stmt: "state", id: $$[$0], type: "fork" }; + break; + case 22: + this.$ = { stmt: "state", id: $$[$0], type: "join" }; + break; + case 23: + this.$ = { stmt: "state", id: $$[$0], type: "choice" }; + break; + case 24: + this.$ = { stmt: "state", id: yy.getDividerId(), type: "divider" }; + break; + case 25: + this.$ = { stmt: "state", id: $$[$0 - 1].trim(), note: { position: $$[$0 - 2].trim(), text: $$[$0].trim() } }; + break; + case 28: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 29: + case 30: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 31: + case 32: + this.$ = { stmt: "classDef", id: $$[$0 - 1].trim(), classes: $$[$0].trim() }; + break; + case 33: + this.$ = { stmt: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; + break; + case 34: + yy.setDirection("TB"); + this.$ = { stmt: "dir", value: "TB" }; + break; + case 35: + yy.setDirection("BT"); + this.$ = { stmt: "dir", value: "BT" }; + break; + case 36: + yy.setDirection("RL"); + this.$ = { stmt: "dir", value: "RL" }; + break; + case 37: + yy.setDirection("LR"); + this.$ = { stmt: "dir", value: "LR" }; + break; + case 40: + case 41: + this.$ = { stmt: "state", id: $$[$0].trim(), type: "default", description: "" }; + break; + case 42: + this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" }; + break; + case 43: + this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" }; + break; + } + }, + table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 15, 16, 18, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 5]), { 9: 36, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 7]), o($Vq, [2, 8]), o($Vq, [2, 9]), o($Vq, [2, 10]), o($Vq, [2, 11], { 13: [1, 37], 14: [1, 38] }), o($Vq, [2, 15]), { 17: [1, 39] }, o($Vq, [2, 17], { 19: [1, 40] }), { 22: [1, 41] }, o($Vq, [2, 21]), o($Vq, [2, 22]), o($Vq, [2, 23]), o($Vq, [2, 24]), { 29: 42, 30: [1, 43], 52: [1, 44], 53: [1, 45] }, o($Vq, [2, 27]), { 33: [1, 46] }, { 35: [1, 47] }, o($Vq, [2, 30]), { 38: [1, 48], 40: [1, 49] }, { 42: [1, 50] }, o($Vr, [2, 40], { 51: [1, 51] }), o($Vr, [2, 41], { 51: [1, 52] }), o($Vq, [2, 34]), o($Vq, [2, 35]), o($Vq, [2, 36]), o($Vq, [2, 37]), o($Vq, [2, 6]), o($Vq, [2, 12]), { 12: 53, 23: $Va, 50: $Vp }, o($Vq, [2, 16]), o($Vs, $V3, { 7: 54 }), { 23: [1, 55] }, { 23: [1, 56] }, { 22: [1, 57] }, { 23: [2, 44] }, { 23: [2, 45] }, o($Vq, [2, 28]), o($Vq, [2, 29]), { 39: [1, 58] }, { 39: [1, 59] }, { 43: [1, 60] }, { 23: [1, 61] }, { 23: [1, 62] }, o($Vq, [2, 13], { 13: [1, 63] }), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 20: [1, 64], 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 19], { 19: [1, 65] }), { 30: [1, 66] }, { 23: [1, 67] }, o($Vq, [2, 31]), o($Vq, [2, 32]), o($Vq, [2, 33]), o($Vr, [2, 42]), o($Vr, [2, 43]), o($Vq, [2, 14]), o($Vq, [2, 18]), o($Vs, $V3, { 7: 68 }), o($Vq, [2, 25]), o($Vq, [2, 26]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 20: [1, 69], 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 20])], + defaultActions: { 5: [2, 1], 6: [2, 2], 44: [2, 44], 45: [2, 45] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 40; + case 1: + return 44; + case 2: + return 45; + case 3: + return 46; + case 4: + return 47; + case 5: + break; + case 6: + break; + case 7: + return 5; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + this.pushState("SCALE"); + return 16; + case 13: + return 17; + case 14: + this.popState(); + break; + case 15: + this.begin("acc_title"); + return 32; + case 16: + this.popState(); + return "acc_title_value"; + case 17: + this.begin("acc_descr"); + return 34; + case 18: + this.popState(); + return "acc_descr_value"; + case 19: + this.begin("acc_descr_multiline"); + break; + case 20: + this.popState(); + break; + case 21: + return "acc_descr_multiline_value"; + case 22: + this.pushState("CLASSDEF"); + return 37; + case 23: + this.popState(); + this.pushState("CLASSDEFID"); + return "DEFAULT_CLASSDEF_ID"; + case 24: + this.popState(); + this.pushState("CLASSDEFID"); + return 38; + case 25: + this.popState(); + return 39; + case 26: + this.pushState("CLASS"); + return 41; + case 27: + this.popState(); + this.pushState("CLASS_STYLE"); + return 42; + case 28: + this.popState(); + return 43; + case 29: + this.pushState("SCALE"); + return 16; + case 30: + return 17; + case 31: + this.popState(); + break; + case 32: + this.pushState("STATE"); + break; + case 33: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 24; + case 34: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 25; + case 35: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -10).trim(); + return 26; + case 36: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 24; + case 37: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 25; + case 38: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -10).trim(); + return 26; + case 39: + return 44; + case 40: + return 45; + case 41: + return 46; + case 42: + return 47; + case 43: + this.pushState("STATE_STRING"); + break; + case 44: + this.pushState("STATE_ID"); + return "AS"; + case 45: + this.popState(); + return "ID"; + case 46: + this.popState(); + break; + case 47: + return "STATE_DESCR"; + case 48: + return 18; + case 49: + this.popState(); + break; + case 50: + this.popState(); + this.pushState("struct"); + return 19; + case 51: + break; + case 52: + this.popState(); + return 20; + case 53: + break; + case 54: + this.begin("NOTE"); + return 28; + case 55: + this.popState(); + this.pushState("NOTE_ID"); + return 52; + case 56: + this.popState(); + this.pushState("NOTE_ID"); + return 53; + case 57: + this.popState(); + this.pushState("FLOATING_NOTE"); + break; + case 58: + this.popState(); + this.pushState("FLOATING_NOTE_ID"); + return "AS"; + case 59: + break; + case 60: + return "NOTE_TEXT"; + case 61: + this.popState(); + return "ID"; + case 62: + this.popState(); + this.pushState("NOTE_TEXT"); + return 23; + case 63: + this.popState(); + yy_.yytext = yy_.yytext.substr(2).trim(); + return 30; + case 64: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 30; + case 65: + return 6; + case 66: + return 6; + case 67: + return 15; + case 68: + return 50; + case 69: + return 23; + case 70: + yy_.yytext = yy_.yytext.trim(); + return 13; + case 71: + return 14; + case 72: + return 27; + case 73: + return 51; + case 74: + return 5; + case 75: + return "INVALID"; + } + }, + rules: [/^(?:default\b)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:classDef\s+)/i, /^(?:DEFAULT\s+)/i, /^(?:\w+\s+)/i, /^(?:[^\n]*)/i, /^(?:class\s+)/i, /^(?:(\w+)+((,\s*\w+)*))/i, /^(?:[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:state\s+)/i, /^(?:.*<>)/i, /^(?:.*<>)/i, /^(?:.*<>)/i, /^(?:.*\[\[fork\]\])/i, /^(?:.*\[\[join\]\])/i, /^(?:.*\[\[choice\]\])/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:["])/i, /^(?:\s*as\s+)/i, /^(?:[^\n\{]*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n\s\{]+)/i, /^(?:\n)/i, /^(?:\{)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:\})/i, /^(?:[\n])/i, /^(?:note\s+)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:")/i, /^(?:\s*as\s*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n]*)/i, /^(?:\s*[^:\n\s\-]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:[\s\S]*?end note\b)/i, /^(?:stateDiagram\s+)/i, /^(?:stateDiagram-v2\s+)/i, /^(?:hide empty description\b)/i, /^(?:\[\*\])/i, /^(?:[^:\n\s\-\{]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:-->)/i, /^(?:--)/i, /^(?::::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "LINE": { "rules": [9, 10], "inclusive": false }, "struct": { "rules": [9, 10, 22, 26, 32, 39, 40, 41, 42, 51, 52, 53, 54, 68, 69, 70, 71, 72], "inclusive": false }, "FLOATING_NOTE_ID": { "rules": [61], "inclusive": false }, "FLOATING_NOTE": { "rules": [58, 59, 60], "inclusive": false }, "NOTE_TEXT": { "rules": [63, 64], "inclusive": false }, "NOTE_ID": { "rules": [62], "inclusive": false }, "NOTE": { "rules": [55, 56, 57], "inclusive": false }, "CLASS_STYLE": { "rules": [28], "inclusive": false }, "CLASS": { "rules": [27], "inclusive": false }, "CLASSDEFID": { "rules": [25], "inclusive": false }, "CLASSDEF": { "rules": [23, 24], "inclusive": false }, "acc_descr_multiline": { "rules": [20, 21], "inclusive": false }, "acc_descr": { "rules": [18], "inclusive": false }, "acc_title": { "rules": [16], "inclusive": false }, "SCALE": { "rules": [13, 14, 30, 31], "inclusive": false }, "ALIAS": { "rules": [], "inclusive": false }, "STATE_ID": { "rules": [45], "inclusive": false }, "STATE_STRING": { "rules": [46, 47], "inclusive": false }, "FORK_STATE": { "rules": [], "inclusive": false }, "STATE": { "rules": [9, 10, 33, 34, 35, 36, 37, 38, 43, 44, 48, 49, 50], "inclusive": false }, "ID": { "rules": [9, 10], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 15, 17, 19, 22, 26, 29, 32, 50, 54, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$6.parser = parser$6; +const parser$1$5 = parser$6; +const DEFAULT_DIAGRAM_DIRECTION = "LR"; +const DEFAULT_NESTED_DOC_DIR = "TB"; +const STMT_STATE = "state"; +const STMT_RELATION = "relation"; +const STMT_CLASSDEF = "classDef"; +const STMT_APPLYCLASS = "applyClass"; +const DEFAULT_STATE_TYPE = "default"; +const DIVIDER_TYPE = "divider"; +const START_NODE = "[*]"; +const START_TYPE = "start"; +const END_NODE = START_NODE; +const END_TYPE = "end"; +const COLOR_KEYWORD$1 = "color"; +const FILL_KEYWORD$1 = "fill"; +const BG_FILL$1 = "bgFill"; +const STYLECLASS_SEP$1 = ","; +function newClassesList() { + return {}; +} +let direction = DEFAULT_DIAGRAM_DIRECTION; +let rootDoc = []; +let classes$1 = newClassesList(); +const newDoc = () => { + return { + relations: [], + states: {}, + documents: {} + }; +}; +let documents = { + root: newDoc() +}; +let currentDocument = documents.root; +let startEndCount = 0; +let dividerCnt = 0; +const lineType = { + LINE: 0, + DOTTED_LINE: 1 +}; +const relationType = { + AGGREGATION: 0, + EXTENSION: 1, + COMPOSITION: 2, + DEPENDENCY: 3 +}; +const clone$1 = (o) => JSON.parse(JSON.stringify(o)); +const setRootDoc = (o) => { + log$1.info("Setting root doc", o); + rootDoc = o; +}; +const getRootDoc = () => rootDoc; +const docTranslator = (parent, node, first) => { + if (node.stmt === STMT_RELATION) { + docTranslator(parent, node.state1, true); + docTranslator(parent, node.state2, false); + } else { + if (node.stmt === STMT_STATE) { + if (node.id === "[*]") { + node.id = first ? parent.id + "_start" : parent.id + "_end"; + node.start = first; + } else { + node.id = node.id.trim(); + } + } + if (node.doc) { + const doc = []; + let currentDoc = []; + let i; + for (i = 0; i < node.doc.length; i++) { + if (node.doc[i].type === DIVIDER_TYPE) { + const newNode = clone$1(node.doc[i]); + newNode.doc = clone$1(currentDoc); + doc.push(newNode); + currentDoc = []; + } else { + currentDoc.push(node.doc[i]); + } + } + if (doc.length > 0 && currentDoc.length > 0) { + const newNode = { + stmt: STMT_STATE, + id: generateId$2(), + type: "divider", + doc: clone$1(currentDoc) + }; + doc.push(clone$1(newNode)); + node.doc = doc; + } + node.doc.forEach((docNode) => docTranslator(node, docNode, true)); + } + } +}; +const getRootDocV2 = () => { + docTranslator({ id: "root" }, { id: "root", doc: rootDoc }, true); + return { id: "root", doc: rootDoc }; +}; +const extract = (_doc) => { + let doc; + if (_doc.doc) { + doc = _doc.doc; + } else { + doc = _doc; + } + log$1.info(doc); + clear$5(true); + log$1.info("Extract", doc); + doc.forEach((item) => { + switch (item.stmt) { + case STMT_STATE: + addState( + item.id.trim(), + item.type, + item.doc, + item.description, + item.note, + item.classes, + item.styles, + item.textStyles + ); + break; + case STMT_RELATION: + addRelation(item.state1, item.state2, item.description); + break; + case STMT_CLASSDEF: + addStyleClass$1(item.id.trim(), item.classes); + break; + case STMT_APPLYCLASS: + setCssClass$1(item.id.trim(), item.styleClass); + break; + } + }); +}; +const addState = function(id, type = DEFAULT_STATE_TYPE, doc = null, descr = null, note = null, classes2 = null, styles2 = null, textStyles = null) { + const trimmedId = id == null ? void 0 : id.trim(); + if (currentDocument.states[trimmedId] === void 0) { + log$1.info("Adding state ", trimmedId, descr); + currentDocument.states[trimmedId] = { + id: trimmedId, + descriptions: [], + type, + doc, + note, + classes: [], + styles: [], + textStyles: [] + }; + } else { + if (!currentDocument.states[trimmedId].doc) { + currentDocument.states[trimmedId].doc = doc; + } + if (!currentDocument.states[trimmedId].type) { + currentDocument.states[trimmedId].type = type; + } + } + if (descr) { + log$1.info("Setting state description", trimmedId, descr); + if (typeof descr === "string") { + addDescription(trimmedId, descr.trim()); + } + if (typeof descr === "object") { + descr.forEach((des) => addDescription(trimmedId, des.trim())); + } + } + if (note) { + currentDocument.states[trimmedId].note = note; + currentDocument.states[trimmedId].note.text = common$1.sanitizeText( + currentDocument.states[trimmedId].note.text, + getConfig$2() + ); + } + if (classes2) { + log$1.info("Setting state classes", trimmedId, classes2); + const classesList = typeof classes2 === "string" ? [classes2] : classes2; + classesList.forEach((cssClass) => setCssClass$1(trimmedId, cssClass.trim())); + } + if (styles2) { + log$1.info("Setting state styles", trimmedId, styles2); + const stylesList = typeof styles2 === "string" ? [styles2] : styles2; + stylesList.forEach((style) => setStyle(trimmedId, style.trim())); + } + if (textStyles) { + log$1.info("Setting state styles", trimmedId, styles2); + const textStylesList = typeof textStyles === "string" ? [textStyles] : textStyles; + textStylesList.forEach((textStyle) => setTextStyle(trimmedId, textStyle.trim())); + } +}; +const clear$5 = function(saveCommon) { + documents = { + root: newDoc() + }; + currentDocument = documents.root; + startEndCount = 0; + classes$1 = newClassesList(); + if (!saveCommon) { + clear$k(); + } +}; +const getState = function(id) { + return currentDocument.states[id]; +}; +const getStates = function() { + return currentDocument.states; +}; +const logDocuments = function() { + log$1.info("Documents = ", documents); +}; +const getRelations = function() { + return currentDocument.relations; +}; +function startIdIfNeeded(id = "") { + let fixedId = id; + if (id === START_NODE) { + startEndCount++; + fixedId = `${START_TYPE}${startEndCount}`; + } + return fixedId; +} +function startTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) { + return id === START_NODE ? START_TYPE : type; +} +function endIdIfNeeded(id = "") { + let fixedId = id; + if (id === END_NODE) { + startEndCount++; + fixedId = `${END_TYPE}${startEndCount}`; + } + return fixedId; +} +function endTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) { + return id === END_NODE ? END_TYPE : type; +} +function addRelationObjs(item1, item2, relationTitle) { + let id1 = startIdIfNeeded(item1.id.trim()); + let type1 = startTypeIfNeeded(item1.id.trim(), item1.type); + let id2 = startIdIfNeeded(item2.id.trim()); + let type2 = startTypeIfNeeded(item2.id.trim(), item2.type); + addState( + id1, + type1, + item1.doc, + item1.description, + item1.note, + item1.classes, + item1.styles, + item1.textStyles + ); + addState( + id2, + type2, + item2.doc, + item2.description, + item2.note, + item2.classes, + item2.styles, + item2.textStyles + ); + currentDocument.relations.push({ + id1, + id2, + relationTitle: common$1.sanitizeText(relationTitle, getConfig$2()) + }); +} +const addRelation = function(item1, item2, title) { + if (typeof item1 === "object") { + addRelationObjs(item1, item2, title); + } else { + const id1 = startIdIfNeeded(item1.trim()); + const type1 = startTypeIfNeeded(item1); + const id2 = endIdIfNeeded(item2.trim()); + const type2 = endTypeIfNeeded(item2); + addState(id1, type1); + addState(id2, type2); + currentDocument.relations.push({ + id1, + id2, + title: common$1.sanitizeText(title, getConfig$2()) + }); + } +}; +const addDescription = function(id, descr) { + const theState = currentDocument.states[id]; + const _descr = descr.startsWith(":") ? descr.replace(":", "").trim() : descr; + theState.descriptions.push(common$1.sanitizeText(_descr, getConfig$2())); +}; +const cleanupLabel = function(label) { + if (label.substring(0, 1) === ":") { + return label.substr(2).trim(); + } else { + return label.trim(); + } +}; +const getDividerId = () => { + dividerCnt++; + return "divider-id-" + dividerCnt; +}; +const addStyleClass$1 = function(id, styleAttributes = "") { + if (classes$1[id] === void 0) { + classes$1[id] = { id, styles: [], textStyles: [] }; + } + const foundClass = classes$1[id]; + if (styleAttributes !== void 0 && styleAttributes !== null) { + styleAttributes.split(STYLECLASS_SEP$1).forEach((attrib) => { + const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); + if (attrib.match(COLOR_KEYWORD$1)) { + const newStyle1 = fixedAttrib.replace(FILL_KEYWORD$1, BG_FILL$1); + const newStyle2 = newStyle1.replace(COLOR_KEYWORD$1, FILL_KEYWORD$1); + foundClass.textStyles.push(newStyle2); + } + foundClass.styles.push(fixedAttrib); + }); + } +}; +const getClasses$4 = function() { + return classes$1; +}; +const setCssClass$1 = function(itemIds, cssClassName) { + itemIds.split(",").forEach(function(id) { + let foundState = getState(id); + if (foundState === void 0) { + const trimmedId = id.trim(); + addState(trimmedId); + foundState = getState(trimmedId); + } + foundState.classes.push(cssClassName); + }); +}; +const setStyle = function(itemId, styleText) { + const item = getState(itemId); + if (item !== void 0) { + item.textStyles.push(styleText); + } +}; +const setTextStyle = function(itemId, cssClassName) { + const item = getState(itemId); + if (item !== void 0) { + item.textStyles.push(cssClassName); + } +}; +const getDirection = () => direction; +const setDirection = (dir) => { + direction = dir; +}; +const trimColon = (str) => str && str[0] === ":" ? str.substr(1).trim() : str.trim(); +const db$6 = { + getConfig: () => getConfig$2().state, + addState, + clear: clear$5, + getState, + getStates, + getRelations, + getClasses: getClasses$4, + getDirection, + addRelation, + getDividerId, + setDirection, + cleanupLabel, + lineType, + relationType, + logDocuments, + getRootDoc, + setRootDoc, + getRootDocV2, + extract, + trimColon, + getAccTitle, + setAccTitle, + getAccDescription, + setAccDescription, + addStyleClass: addStyleClass$1, + setCssClass: setCssClass$1, + addDescription, + setDiagramTitle, + getDiagramTitle +}; +const getStyles$5 = (options) => ` +defs #statediagram-barbEnd { + fill: ${options.transitionColor}; + stroke: ${options.transitionColor}; + } +g.stateGroup text { + fill: ${options.nodeBorder}; + stroke: none; + font-size: 10px; +} +g.stateGroup text { + fill: ${options.textColor}; + stroke: none; + font-size: 10px; + +} +g.stateGroup .state-title { + font-weight: bolder; + fill: ${options.stateLabelColor}; +} + +g.stateGroup rect { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; +} + +g.stateGroup line { + stroke: ${options.lineColor}; + stroke-width: 1; +} + +.transition { + stroke: ${options.transitionColor}; + stroke-width: 1; + fill: none; +} + +.stateGroup .composit { + fill: ${options.background}; + border-bottom: 1px +} + +.stateGroup .alt-composit { + fill: #e0e0e0; + border-bottom: 1px +} + +.state-note { + stroke: ${options.noteBorderColor}; + fill: ${options.noteBkgColor}; + + text { + fill: ${options.noteTextColor}; + stroke: none; + font-size: 10px; + } +} + +.stateLabel .box { + stroke: none; + stroke-width: 0; + fill: ${options.mainBkg}; + opacity: 0.5; +} + +.edgeLabel .label rect { + fill: ${options.labelBackgroundColor}; + opacity: 0.5; +} +.edgeLabel .label text { + fill: ${options.transitionLabelColor || options.tertiaryTextColor}; +} +.label div .edgeLabel { + color: ${options.transitionLabelColor || options.tertiaryTextColor}; +} + +.stateLabel text { + fill: ${options.stateLabelColor}; + font-size: 10px; + font-weight: bold; +} + +.node circle.state-start { + fill: ${options.specialStateColor}; + stroke: ${options.specialStateColor}; +} + +.node .fork-join { + fill: ${options.specialStateColor}; + stroke: ${options.specialStateColor}; +} + +.node circle.state-end { + fill: ${options.innerEndBackground}; + stroke: ${options.background}; + stroke-width: 1.5 +} +.end-state-inner { + fill: ${options.compositeBackground || options.background}; + // stroke: ${options.background}; + stroke-width: 1.5 +} + +.node rect { + fill: ${options.stateBkg || options.mainBkg}; + stroke: ${options.stateBorder || options.nodeBorder}; + stroke-width: 1px; +} +.node polygon { + fill: ${options.mainBkg}; + stroke: ${options.stateBorder || options.nodeBorder};; + stroke-width: 1px; +} +#statediagram-barbEnd { + fill: ${options.lineColor}; +} + +.statediagram-cluster rect { + fill: ${options.compositeTitleBackground}; + stroke: ${options.stateBorder || options.nodeBorder}; + stroke-width: 1px; +} + +.cluster-label, .nodeLabel { + color: ${options.stateLabelColor}; +} + +.statediagram-cluster rect.outer { + rx: 5px; + ry: 5px; +} +.statediagram-state .divider { + stroke: ${options.stateBorder || options.nodeBorder}; +} + +.statediagram-state .title-state { + rx: 5px; + ry: 5px; +} +.statediagram-cluster.statediagram-cluster .inner { + fill: ${options.compositeBackground || options.background}; +} +.statediagram-cluster.statediagram-cluster-alt .inner { + fill: ${options.altBackground ? options.altBackground : "#efefef"}; +} + +.statediagram-cluster .inner { + rx:0; + ry:0; +} + +.statediagram-state rect.basic { + rx: 5px; + ry: 5px; +} +.statediagram-state rect.divider { + stroke-dasharray: 10,10; + fill: ${options.altBackground ? options.altBackground : "#efefef"}; +} + +.note-edge { + stroke-dasharray: 5; +} + +.statediagram-note rect { + fill: ${options.noteBkgColor}; + stroke: ${options.noteBorderColor}; + stroke-width: 1px; + rx: 0; + ry: 0; +} +.statediagram-note rect { + fill: ${options.noteBkgColor}; + stroke: ${options.noteBorderColor}; + stroke-width: 1px; + rx: 0; + ry: 0; +} + +.statediagram-note text { + fill: ${options.noteTextColor}; +} + +.statediagram-note .nodeLabel { + color: ${options.noteTextColor}; +} +.statediagram .edgeLabel { + color: red; // ${options.noteTextColor}; +} + +#dependencyStart, #dependencyEnd { + fill: ${options.lineColor}; + stroke: ${options.lineColor}; + stroke-width: 1; +} + +.statediagramTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; +} +`; +const styles$4 = getStyles$5; + +const drawStartState = (g) => g.append("circle").attr("class", "start-state").attr("r", getConfig$2().state.sizeUnit).attr("cx", getConfig$2().state.padding + getConfig$2().state.sizeUnit).attr("cy", getConfig$2().state.padding + getConfig$2().state.sizeUnit); +const drawDivider = (g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig$2().state.textHeight).attr("class", "divider").attr("x2", getConfig$2().state.textHeight * 2).attr("y1", 0).attr("y2", 0); +const drawSimpleState = (g, stateDef) => { + const state = g.append("text").attr("x", 2 * getConfig$2().state.padding).attr("y", getConfig$2().state.textHeight + 2 * getConfig$2().state.padding).attr("font-size", getConfig$2().state.fontSize).attr("class", "state-title").text(stateDef.id); + const classBox = state.node().getBBox(); + g.insert("rect", ":first-child").attr("x", getConfig$2().state.padding).attr("y", getConfig$2().state.padding).attr("width", classBox.width + 2 * getConfig$2().state.padding).attr("height", classBox.height + 2 * getConfig$2().state.padding).attr("rx", getConfig$2().state.radius); + return state; +}; +const drawDescrState = (g, stateDef) => { + const addTspan = function(textEl, txt, isFirst2) { + const tSpan = textEl.append("tspan").attr("x", 2 * getConfig$2().state.padding).text(txt); + if (!isFirst2) { + tSpan.attr("dy", getConfig$2().state.textHeight); + } + }; + const title = g.append("text").attr("x", 2 * getConfig$2().state.padding).attr("y", getConfig$2().state.textHeight + 1.3 * getConfig$2().state.padding).attr("font-size", getConfig$2().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]); + const titleBox = title.node().getBBox(); + const titleHeight = titleBox.height; + const description = g.append("text").attr("x", getConfig$2().state.padding).attr( + "y", + titleHeight + getConfig$2().state.padding * 0.4 + getConfig$2().state.dividerMargin + getConfig$2().state.textHeight + ).attr("class", "state-description"); + let isFirst = true; + let isSecond = true; + stateDef.descriptions.forEach(function(descr) { + if (!isFirst) { + addTspan(description, descr, isSecond); + isSecond = false; + } + isFirst = false; + }); + const descrLine = g.append("line").attr("x1", getConfig$2().state.padding).attr("y1", getConfig$2().state.padding + titleHeight + getConfig$2().state.dividerMargin / 2).attr("y2", getConfig$2().state.padding + titleHeight + getConfig$2().state.dividerMargin / 2).attr("class", "descr-divider"); + const descrBox = description.node().getBBox(); + const width = Math.max(descrBox.width, titleBox.width); + descrLine.attr("x2", width + 3 * getConfig$2().state.padding); + g.insert("rect", ":first-child").attr("x", getConfig$2().state.padding).attr("y", getConfig$2().state.padding).attr("width", width + 2 * getConfig$2().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig$2().state.padding).attr("rx", getConfig$2().state.radius); + return g; +}; +const addTitleAndBox = (g, stateDef, altBkg) => { + const pad = getConfig$2().state.padding; + const dblPad = 2 * getConfig$2().state.padding; + const orgBox = g.node().getBBox(); + const orgWidth = orgBox.width; + const orgX = orgBox.x; + const title = g.append("text").attr("x", 0).attr("y", getConfig$2().state.titleShift).attr("font-size", getConfig$2().state.fontSize).attr("class", "state-title").text(stateDef.id); + const titleBox = title.node().getBBox(); + const titleWidth = titleBox.width + dblPad; + let width = Math.max(titleWidth, orgWidth); + if (width === orgWidth) { + width = width + dblPad; + } + let startX; + const graphBox = g.node().getBBox(); + if (stateDef.doc) + ; + startX = orgX - pad; + if (titleWidth > orgWidth) { + startX = (orgWidth - width) / 2 + pad; + } + if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) { + startX = orgX - (titleWidth - orgWidth) / 2; + } + const lineY = 1 - getConfig$2().state.textHeight; + g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr( + "height", + graphBox.height + getConfig$2().state.textHeight + getConfig$2().state.titleShift + 1 + ).attr("rx", "0"); + title.attr("x", startX + pad); + if (titleWidth <= orgWidth) { + title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad); + } + g.insert("rect", ":first-child").attr("x", startX).attr( + "y", + getConfig$2().state.titleShift - getConfig$2().state.textHeight - getConfig$2().state.padding + ).attr("width", width).attr("height", getConfig$2().state.textHeight * 3).attr("rx", getConfig$2().state.radius); + g.insert("rect", ":first-child").attr("x", startX).attr( + "y", + getConfig$2().state.titleShift - getConfig$2().state.textHeight - getConfig$2().state.padding + ).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig$2().state.textHeight).attr("rx", getConfig$2().state.radius); + return g; +}; +const drawEndState = (g) => { + g.append("circle").attr("class", "end-state-outer").attr("r", getConfig$2().state.sizeUnit + getConfig$2().state.miniPadding).attr( + "cx", + getConfig$2().state.padding + getConfig$2().state.sizeUnit + getConfig$2().state.miniPadding + ).attr( + "cy", + getConfig$2().state.padding + getConfig$2().state.sizeUnit + getConfig$2().state.miniPadding + ); + return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig$2().state.sizeUnit).attr("cx", getConfig$2().state.padding + getConfig$2().state.sizeUnit + 2).attr("cy", getConfig$2().state.padding + getConfig$2().state.sizeUnit + 2); +}; +const drawForkJoinState = (g, stateDef) => { + let width = getConfig$2().state.forkWidth; + let height = getConfig$2().state.forkHeight; + if (stateDef.parentId) { + let tmp = width; + width = height; + height = tmp; + } + return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig$2().state.padding).attr("y", getConfig$2().state.padding); +}; +const _drawLongText = (_text, x, y, g) => { + let textHeight = 0; + const textElem = g.append("text"); + textElem.style("text-anchor", "start"); + textElem.attr("class", "noteText"); + let text = _text.replace(/\r\n/g, "
    "); + text = text.replace(/\n/g, "
    "); + const lines = text.split(common$1.lineBreakRegex); + let tHeight = 1.25 * getConfig$2().state.noteMargin; + for (const line2 of lines) { + const txt = line2.trim(); + if (txt.length > 0) { + const span = textElem.append("tspan"); + span.text(txt); + if (tHeight === 0) { + const textBounds = span.node().getBBox(); + tHeight += textBounds.height; + } + textHeight += tHeight; + span.attr("x", x + getConfig$2().state.noteMargin); + span.attr("y", y + textHeight + 1.25 * getConfig$2().state.noteMargin); + } + } + return { textWidth: textElem.node().getBBox().width, textHeight }; +}; +const drawNote = (text, g) => { + g.attr("class", "state-note"); + const note = g.append("rect").attr("x", 0).attr("y", getConfig$2().state.padding); + const rectElem = g.append("g"); + const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem); + note.attr("height", textHeight + 2 * getConfig$2().state.noteMargin); + note.attr("width", textWidth + getConfig$2().state.noteMargin * 2); + return note; +}; +const drawState = function(elem, stateDef) { + const id = stateDef.id; + const stateInfo = { + id, + label: stateDef.id, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", id).attr("class", "stateGroup"); + if (stateDef.type === "start") { + drawStartState(g); + } + if (stateDef.type === "end") { + drawEndState(g); + } + if (stateDef.type === "fork" || stateDef.type === "join") { + drawForkJoinState(g, stateDef); + } + if (stateDef.type === "note") { + drawNote(stateDef.note.text, g); + } + if (stateDef.type === "divider") { + drawDivider(g); + } + if (stateDef.type === "default" && stateDef.descriptions.length === 0) { + drawSimpleState(g, stateDef); + } + if (stateDef.type === "default" && stateDef.descriptions.length > 0) { + drawDescrState(g, stateDef); + } + const stateBox = g.node().getBBox(); + stateInfo.width = stateBox.width + 2 * getConfig$2().state.padding; + stateInfo.height = stateBox.height + 2 * getConfig$2().state.padding; + return stateInfo; +}; +let edgeCount$1 = 0; +const drawEdge = function(elem, path, relation) { + const getRelationType = function(type) { + switch (type) { + case db$6.relationType.AGGREGATION: + return "aggregation"; + case db$6.relationType.EXTENSION: + return "extension"; + case db$6.relationType.COMPOSITION: + return "composition"; + case db$6.relationType.DEPENDENCY: + return "dependency"; + } + }; + path.points = path.points.filter((p) => !Number.isNaN(p.y)); + const lineData = path.points; + const lineFunction = line$1().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount$1).attr("class", "transition"); + let url = ""; + if (getConfig$2().state.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + svgPath.attr( + "marker-end", + "url(" + url + "#" + getRelationType(db$6.relationType.DEPENDENCY) + "End)" + ); + if (relation.title !== void 0) { + const label = elem.append("g").attr("class", "stateLabel"); + const { x, y } = utils.calcLabelPosition(path.points); + const rows = common$1.getRows(relation.title); + let titleHeight = 0; + const titleRows = []; + let maxWidth = 0; + let minX = 0; + for (let i = 0; i <= rows.length; i++) { + const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight); + const boundsTmp = title.node().getBBox(); + maxWidth = Math.max(maxWidth, boundsTmp.width); + minX = Math.min(minX, boundsTmp.x); + log$1.info(boundsTmp.x, x, y + titleHeight); + if (titleHeight === 0) { + const titleBox = title.node().getBBox(); + titleHeight = titleBox.height; + log$1.info("Title height", titleHeight, y); + } + titleRows.push(title); + } + let boxHeight = titleHeight * rows.length; + if (rows.length > 1) { + const heightAdj = (rows.length - 1) * titleHeight * 0.5; + titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj)); + boxHeight = titleHeight * rows.length; + } + const bounds = label.node().getBBox(); + label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig$2().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig$2().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig$2().state.padding).attr("height", boxHeight + getConfig$2().state.padding); + log$1.info(bounds); + } + edgeCount$1++; +}; +let conf$2; +const transformationLog = {}; +const setConf$2 = function() { +}; +const insertMarkers = function(elem) { + elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z"); +}; +const draw$7 = function(text, id, _version, diagObj) { + conf$2 = getConfig$2().state; + const securityLevel = getConfig$2().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + log$1.debug("Rendering diagram " + text); + const diagram2 = root.select(`[id='${id}']`); + insertMarkers(diagram2); + const rootDoc = diagObj.db.getRootDoc(); + renderDoc(rootDoc, diagram2, void 0, false, root, doc, diagObj); + const padding = conf$2.padding; + const bounds = diagram2.node().getBBox(); + const width = bounds.width + padding * 2; + const height = bounds.height + padding * 2; + const svgWidth = width * 1.75; + configureSvgSize(diagram2, height, svgWidth, conf$2.useMaxWidth); + diagram2.attr( + "viewBox", + `${bounds.x - conf$2.padding} ${bounds.y - conf$2.padding} ` + width + " " + height + ); +}; +const getLabelWidth = (text) => { + return text ? text.length * conf$2.fontSizeFactor : 1; +}; +const renderDoc = (doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => { + const graph = new Graph({ + compound: true, + multigraph: true + }); + let i; + let edgeFreeDoc = true; + for (i = 0; i < doc.length; i++) { + if (doc[i].stmt === "relation") { + edgeFreeDoc = false; + break; + } + } + if (parentId) { + graph.setGraph({ + rankdir: "LR", + multigraph: true, + compound: true, + // acyclicer: 'greedy', + ranker: "tight-tree", + ranksep: edgeFreeDoc ? 1 : conf$2.edgeLengthFactor, + nodeSep: edgeFreeDoc ? 1 : 50, + isMultiGraph: true + // ranksep: 5, + // nodesep: 1 + }); + } else { + graph.setGraph({ + rankdir: "TB", + multigraph: true, + compound: true, + // isCompound: true, + // acyclicer: 'greedy', + // ranker: 'longest-path' + ranksep: edgeFreeDoc ? 1 : conf$2.edgeLengthFactor, + nodeSep: edgeFreeDoc ? 1 : 50, + ranker: "tight-tree", + // ranker: 'network-simplex' + isMultiGraph: true + }); + } + graph.setDefaultEdgeLabel(function() { + return {}; + }); + diagObj.db.extract(doc); + const states = diagObj.db.getStates(); + const relations = diagObj.db.getRelations(); + const keys2 = Object.keys(states); + for (const key of keys2) { + const stateDef = states[key]; + if (parentId) { + stateDef.parentId = parentId; + } + let node; + if (stateDef.doc) { + let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup"); + node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj); + { + sub = addTitleAndBox(sub, stateDef, altBkg); + let boxBounds = sub.node().getBBox(); + node.width = boxBounds.width; + node.height = boxBounds.height + conf$2.padding / 2; + transformationLog[stateDef.id] = { y: conf$2.compositTitleSize }; + } + } else { + node = drawState(diagram2, stateDef); + } + if (stateDef.note) { + const noteDef = { + descriptions: [], + id: stateDef.id + "-note", + note: stateDef.note, + type: "note" + }; + const note = drawState(diagram2, noteDef); + if (stateDef.note.position === "left of") { + graph.setNode(node.id + "-note", note); + graph.setNode(node.id, node); + } else { + graph.setNode(node.id, node); + graph.setNode(node.id + "-note", note); + } + graph.setParent(node.id, node.id + "-group"); + graph.setParent(node.id + "-note", node.id + "-group"); + } else { + graph.setNode(node.id, node); + } + } + log$1.debug("Count=", graph.nodeCount(), graph); + let cnt = 0; + relations.forEach(function(relation) { + cnt++; + log$1.debug("Setting edge", relation); + graph.setEdge( + relation.id1, + relation.id2, + { + relation, + width: getLabelWidth(relation.title), + height: conf$2.labelHeight * common$1.getRows(relation.title).length, + labelpos: "c" + }, + "id" + cnt + ); + }); + layout$2(graph); + log$1.debug("Graph after layout", graph.nodes()); + const svgElem = diagram2.node(); + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + log$1.warn("Node " + v + ": " + JSON.stringify(graph.node(v))); + root.select("#" + svgElem.id + " #" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )" + ); + root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2); + const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider"); + dividers.forEach((divider) => { + const parent = divider.parentElement; + let pWidth = 0; + let pShift = 0; + if (parent) { + if (parent.parentElement) { + pWidth = parent.parentElement.getBBox().width; + } + pShift = parseInt(parent.getAttribute("data-x-shift"), 10); + if (Number.isNaN(pShift)) { + pShift = 0; + } + } + divider.setAttribute("x1", 0 - pShift + 8); + divider.setAttribute("x2", pWidth - pShift - 8); + }); + } else { + log$1.debug("No Node " + v + ": " + JSON.stringify(graph.node(v))); + } + }); + let stateBox = svgElem.getBBox(); + graph.edges().forEach(function(e) { + if (e !== void 0 && graph.edge(e) !== void 0) { + log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e))); + drawEdge(diagram2, graph.edge(e), graph.edge(e).relation); + } + }); + stateBox = svgElem.getBBox(); + const stateInfo = { + id: parentId ? parentId : "root", + label: parentId ? parentId : "root", + width: 0, + height: 0 + }; + stateInfo.width = stateBox.width + 2 * conf$2.padding; + stateInfo.height = stateBox.height + 2 * conf$2.padding; + log$1.debug("Doc rendered", stateInfo, graph); + return stateInfo; +}; +const renderer$8 = { + setConf: setConf$2, + draw: draw$7 +}; +const diagram$7 = { + parser: parser$1$5, + db: db$6, + renderer: renderer$8, + styles: styles$4, + init: (cnf) => { + if (!cnf.state) { + cnf.state = {}; + } + cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db$6.clear(); + } +}; + +var stateDiagram5dee940d = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$7 +}); + +const SHAPE_STATE = "rect"; +const SHAPE_STATE_WITH_DESC = "rectWithTitle"; +const SHAPE_START = "start"; +const SHAPE_END = "end"; +const SHAPE_DIVIDER = "divider"; +const SHAPE_GROUP = "roundedWithTitle"; +const SHAPE_NOTE = "note"; +const SHAPE_NOTEGROUP = "noteGroup"; +const CSS_DIAGRAM = "statediagram"; +const CSS_STATE = "state"; +const CSS_DIAGRAM_STATE = `${CSS_DIAGRAM}-${CSS_STATE}`; +const CSS_EDGE = "transition"; +const CSS_NOTE = "note"; +const CSS_NOTE_EDGE = "note-edge"; +const CSS_EDGE_NOTE_EDGE = `${CSS_EDGE} ${CSS_NOTE_EDGE}`; +const CSS_DIAGRAM_NOTE = `${CSS_DIAGRAM}-${CSS_NOTE}`; +const CSS_CLUSTER = "cluster"; +const CSS_DIAGRAM_CLUSTER = `${CSS_DIAGRAM}-${CSS_CLUSTER}`; +const CSS_CLUSTER_ALT = "cluster-alt"; +const CSS_DIAGRAM_CLUSTER_ALT = `${CSS_DIAGRAM}-${CSS_CLUSTER_ALT}`; +const PARENT = "parent"; +const NOTE = "note"; +const DOMID_STATE = "state"; +const DOMID_TYPE_SPACER = "----"; +const NOTE_ID = `${DOMID_TYPE_SPACER}${NOTE}`; +const PARENT_ID = `${DOMID_TYPE_SPACER}${PARENT}`; +const G_EDGE_STYLE = "fill:none"; +const G_EDGE_ARROWHEADSTYLE = "fill: #333"; +const G_EDGE_LABELPOS = "c"; +const G_EDGE_LABELTYPE = "text"; +const G_EDGE_THICKNESS = "normal"; +let nodeDb$1 = {}; +let graphItemCount = 0; +const setConf$1 = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + cnf[key]; + } +}; +const getClasses$3 = function(text, diagramObj) { + diagramObj.db.extract(diagramObj.db.getRootDocV2()); + return diagramObj.db.getClasses(); +}; +function getClassesFromDbInfo(dbInfoItem) { + if (dbInfoItem === void 0 || dbInfoItem === null) { + return ""; + } else { + if (dbInfoItem.classes) { + return dbInfoItem.classes.join(" "); + } else { + return ""; + } + } +} +function stateDomId(itemId = "", counter = 0, type = "", typeSpacer = DOMID_TYPE_SPACER) { + const typeStr = type !== null && type.length > 0 ? `${typeSpacer}${type}` : ""; + return `${DOMID_STATE}-${itemId}${typeStr}-${counter}`; +} +const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => { + const itemId = parsedItem.id; + const classStr = getClassesFromDbInfo(diagramStates[itemId]); + if (itemId !== "root") { + let shape = SHAPE_STATE; + if (parsedItem.start === true) { + shape = SHAPE_START; + } + if (parsedItem.start === false) { + shape = SHAPE_END; + } + if (parsedItem.type !== DEFAULT_STATE_TYPE) { + shape = parsedItem.type; + } + if (!nodeDb$1[itemId]) { + nodeDb$1[itemId] = { + id: itemId, + shape, + description: common$1.sanitizeText(itemId, getConfig$2()), + classes: `${classStr} ${CSS_DIAGRAM_STATE}` + }; + } + const newNode = nodeDb$1[itemId]; + if (parsedItem.description) { + if (Array.isArray(newNode.description)) { + newNode.shape = SHAPE_STATE_WITH_DESC; + newNode.description.push(parsedItem.description); + } else { + if (newNode.description.length > 0) { + newNode.shape = SHAPE_STATE_WITH_DESC; + if (newNode.description === itemId) { + newNode.description = [parsedItem.description]; + } else { + newNode.description = [newNode.description, parsedItem.description]; + } + } else { + newNode.shape = SHAPE_STATE; + newNode.description = parsedItem.description; + } + } + newNode.description = common$1.sanitizeTextOrArray(newNode.description, getConfig$2()); + } + if (newNode.description.length === 1 && newNode.shape === SHAPE_STATE_WITH_DESC) { + newNode.shape = SHAPE_STATE; + } + if (!newNode.type && parsedItem.doc) { + log$1.info("Setting cluster for ", itemId, getDir(parsedItem)); + newNode.type = "group"; + newNode.dir = getDir(parsedItem); + newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP; + newNode.classes = newNode.classes + " " + CSS_DIAGRAM_CLUSTER + " " + (altFlag ? CSS_DIAGRAM_CLUSTER_ALT : ""); + } + const nodeData = { + labelStyle: "", + shape: newNode.shape, + labelText: newNode.description, + // typeof newNode.description === 'object' + // ? newNode.description[0] + // : newNode.description, + classes: newNode.classes, + style: "", + //styles.style, + id: itemId, + dir: newNode.dir, + domId: stateDomId(itemId, graphItemCount), + type: newNode.type, + padding: 15 + //getConfig().flowchart.padding + }; + nodeData.centerLabel = true; + if (parsedItem.note) { + const noteData = { + labelStyle: "", + shape: SHAPE_NOTE, + labelText: parsedItem.note.text, + classes: CSS_DIAGRAM_NOTE, + // useHtmlLabels: false, + style: "", + // styles.style, + id: itemId + NOTE_ID + "-" + graphItemCount, + domId: stateDomId(itemId, graphItemCount, NOTE), + type: newNode.type, + padding: 15 + //getConfig().flowchart.padding + }; + const groupData = { + labelStyle: "", + shape: SHAPE_NOTEGROUP, + labelText: parsedItem.note.text, + classes: newNode.classes, + style: "", + // styles.style, + id: itemId + PARENT_ID, + domId: stateDomId(itemId, graphItemCount, PARENT), + type: "group", + padding: 0 + //getConfig().flowchart.padding + }; + graphItemCount++; + const parentNodeId = itemId + PARENT_ID; + g.setNode(parentNodeId, groupData); + g.setNode(noteData.id, noteData); + g.setNode(itemId, nodeData); + g.setParent(itemId, parentNodeId); + g.setParent(noteData.id, parentNodeId); + let from = itemId; + let to = noteData.id; + if (parsedItem.note.position === "left of") { + from = noteData.id; + to = itemId; + } + g.setEdge(from, to, { + arrowhead: "none", + arrowType: "", + style: G_EDGE_STYLE, + labelStyle: "", + classes: CSS_EDGE_NOTE_EDGE, + arrowheadStyle: G_EDGE_ARROWHEADSTYLE, + labelpos: G_EDGE_LABELPOS, + labelType: G_EDGE_LABELTYPE, + thickness: G_EDGE_THICKNESS + }); + } else { + g.setNode(itemId, nodeData); + } + } + if (parent && parent.id !== "root") { + log$1.trace("Setting node ", itemId, " to be child of its parent ", parent.id); + g.setParent(itemId, parent.id); + } + if (parsedItem.doc) { + log$1.trace("Adding nodes children "); + setupDoc(g, parsedItem, parsedItem.doc, diagramStates, diagramDb, !altFlag); + } +}; +const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) => { + log$1.trace("items", doc); + doc.forEach((item) => { + switch (item.stmt) { + case STMT_STATE: + setupNode(g, parentParsedItem, item, diagramStates, diagramDb, altFlag); + break; + case DEFAULT_STATE_TYPE: + setupNode(g, parentParsedItem, item, diagramStates, diagramDb, altFlag); + break; + case STMT_RELATION: + { + setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); + setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); + const edgeData = { + id: "edge" + graphItemCount, + arrowhead: "normal", + arrowTypeEnd: "arrow_barb", + style: G_EDGE_STYLE, + labelStyle: "", + label: common$1.sanitizeText(item.description, getConfig$2()), + arrowheadStyle: G_EDGE_ARROWHEADSTYLE, + labelpos: G_EDGE_LABELPOS, + labelType: G_EDGE_LABELTYPE, + thickness: G_EDGE_THICKNESS, + classes: CSS_EDGE + }; + g.setEdge(item.state1.id, item.state2.id, edgeData, graphItemCount); + graphItemCount++; + } + break; + } + }); +}; +const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => { + let dir = defaultDir; + if (parsedItem.doc) { + for (let i = 0; i < parsedItem.doc.length; i++) { + const parsedItemDoc = parsedItem.doc[i]; + if (parsedItemDoc.stmt === "dir") { + dir = parsedItemDoc.value; + } + } + } + return dir; +}; +const draw$6 = async function(text, id, _version, diag) { + log$1.info("Drawing state diagram (v2)", id); + nodeDb$1 = {}; + diag.db.getDirection(); + const { securityLevel, state: conf } = getConfig$2(); + const nodeSpacing = conf.nodeSpacing || 50; + const rankSpacing = conf.rankSpacing || 50; + log$1.info(diag.db.getRootDocV2()); + diag.db.extract(diag.db.getRootDocV2()); + log$1.info(diag.db.getRootDocV2()); + const diagramStates = diag.db.getStates(); + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: getDir(diag.db.getRootDocV2()), + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + setupNode(g, void 0, diag.db.getRootDocV2(), diagramStates, diag.db, true); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render(element, g, ["barb"], CSS_DIAGRAM, id); + const padding = 8; + utils.insertTitle(svg, "statediagramTitleText", conf.titleTopMargin, diag.db.getDiagramTitle()); + const bounds = svg.node().getBBox(); + const width = bounds.width + padding * 2; + const height = bounds.height + padding * 2; + svg.attr("class", CSS_DIAGRAM); + const svgBounds = svg.node().getBBox(); + configureSvgSize(svg, height, width, conf.useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`; + log$1.debug(`viewBox ${vBox}`); + svg.attr("viewBox", vBox); + const labels = document.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = document.createElementNS("http://www.w3.org/2000/svg", SHAPE_STATE); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } +}; +const renderer$7 = { + setConf: setConf$1, + getClasses: getClasses$3, + draw: draw$6 +}; +const diagram$6 = { + parser: parser$1$5, + db: db$6, + renderer: renderer$7, + styles: styles$4, + init: (cnf) => { + if (!cnf.state) { + cnf.state = {}; + } + cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db$6.clear(); + } +}; + +var stateDiagramV21992cada = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$6 +}); + +var parser$5 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 11, 12, 14, 16, 17, 18], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12], $V5 = [1, 13], $V6 = [1, 14]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "journey": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "title": 11, "acc_title": 12, "acc_title_value": 13, "acc_descr": 14, "acc_descr_value": 15, "acc_descr_multiline_value": 16, "section": 17, "taskName": 18, "taskData": 19, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "journey", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 18: "taskName", 19: "taskData" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 9: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 10: + case 11: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 12: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 13: + yy.addTask($$[$0 - 1], $$[$0]); + this.$ = "task"; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 15, 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), { 13: [1, 16] }, { 15: [1, 17] }, o($V0, [2, 11]), o($V0, [2, 12]), { 19: [1, 18] }, o($V0, [2, 4]), o($V0, [2, 9]), o($V0, [2, 10]), o($V0, [2, 13])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 10; + case 3: + break; + case 4: + break; + case 5: + return 4; + case 6: + return 11; + case 7: + this.begin("acc_title"); + return 12; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 14; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 17; + case 15: + return 18; + case 16: + return 19; + case 17: + return ":"; + case 18: + return 6; + case 19: + return "INVALID"; + } + }, + rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:journey\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$5.parser = parser$5; +const parser$1$4 = parser$5; +let currentSection$1 = ""; +const sections$1 = []; +const tasks$1 = []; +const rawTasks$1 = []; +const clear$4 = function() { + sections$1.length = 0; + tasks$1.length = 0; + currentSection$1 = ""; + rawTasks$1.length = 0; + clear$k(); +}; +const addSection$1 = function(txt) { + currentSection$1 = txt; + sections$1.push(txt); +}; +const getSections$1 = function() { + return sections$1; +}; +const getTasks$1 = function() { + let allItemsProcessed = compileTasks$1(); + const maxDepth = 100; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks$1(); + iterationCount++; + } + tasks$1.push(...rawTasks$1); + return tasks$1; +}; +const updateActors = function() { + const tempActors = []; + tasks$1.forEach((task) => { + if (task.people) { + tempActors.push(...task.people); + } + }); + const unique = new Set(tempActors); + return [...unique].sort(); +}; +const addTask$1 = function(descr, taskData) { + const pieces = taskData.substr(1).split(":"); + let score = 0; + let peeps = []; + if (pieces.length === 1) { + score = Number(pieces[0]); + peeps = []; + } else { + score = Number(pieces[0]); + peeps = pieces[1].split(","); + } + const peopleList = peeps.map((s) => s.trim()); + const rawTask = { + section: currentSection$1, + type: currentSection$1, + people: peopleList, + task: descr, + score + }; + rawTasks$1.push(rawTask); +}; +const addTaskOrg$1 = function(descr) { + const newTask = { + section: currentSection$1, + type: currentSection$1, + description: descr, + task: descr, + classes: [] + }; + tasks$1.push(newTask); +}; +const compileTasks$1 = function() { + const compileTask = function(pos) { + return rawTasks$1[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks$1.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const getActors = function() { + return updateActors(); +}; +const db$5 = { + getConfig: () => getConfig$2().journey, + clear: clear$4, + setDiagramTitle, + getDiagramTitle, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addSection: addSection$1, + getSections: getSections$1, + getTasks: getTasks$1, + addTask: addTask$1, + addTaskOrg: addTaskOrg$1, + getActors +}; +const getStyles$4 = (options) => `.label { + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + color: ${options.textColor}; + } + .mouth { + stroke: #666; + } + + line { + stroke: ${options.textColor} + } + + .legend { + fill: ${options.textColor}; + } + + .label text { + fill: #333; + } + .label { + color: ${options.textColor} + } + + .face { + ${options.faceColor ? `fill: ${options.faceColor}` : "fill: #FFF8DC"}; + stroke: #999; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 1.5px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + } + text-align: center; + } + + .cluster rect { + } + + .cluster text { + fill: ${options.titleColor}; + } + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .task-type-0, .section-type-0 { + ${options.fillType0 ? `fill: ${options.fillType0}` : ""}; + } + .task-type-1, .section-type-1 { + ${options.fillType0 ? `fill: ${options.fillType1}` : ""}; + } + .task-type-2, .section-type-2 { + ${options.fillType0 ? `fill: ${options.fillType2}` : ""}; + } + .task-type-3, .section-type-3 { + ${options.fillType0 ? `fill: ${options.fillType3}` : ""}; + } + .task-type-4, .section-type-4 { + ${options.fillType0 ? `fill: ${options.fillType4}` : ""}; + } + .task-type-5, .section-type-5 { + ${options.fillType0 ? `fill: ${options.fillType5}` : ""}; + } + .task-type-6, .section-type-6 { + ${options.fillType0 ? `fill: ${options.fillType6}` : ""}; + } + .task-type-7, .section-type-7 { + ${options.fillType0 ? `fill: ${options.fillType7}` : ""}; + } + + .actor-0 { + ${options.actor0 ? `fill: ${options.actor0}` : ""}; + } + .actor-1 { + ${options.actor1 ? `fill: ${options.actor1}` : ""}; + } + .actor-2 { + ${options.actor2 ? `fill: ${options.actor2}` : ""}; + } + .actor-3 { + ${options.actor3 ? `fill: ${options.actor3}` : ""}; + } + .actor-4 { + ${options.actor4 ? `fill: ${options.actor4}` : ""}; + } + .actor-5 { + ${options.actor5 ? `fill: ${options.actor5}` : ""}; + } +`; +const styles$3 = getStyles$4; +const drawRect$1 = function(elem, rectData) { + return drawRect$4(elem, rectData); +}; +const drawFace$1 = function(element, faceData) { + const radius = 15; + const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible"); + const face = element.append("g"); + face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + function smile(face2) { + const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")"); + } + function sad(face2) { + const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")"); + } + function ambivalent(face2) { + face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666"); + } + if (faceData.score > 3) { + smile(face); + } else if (faceData.score < 3) { + sad(face); + } else { + ambivalent(face); + } + return circleElement; +}; +const drawCircle$1 = function(element, circleData) { + const circleElement = element.append("circle"); + circleElement.attr("cx", circleData.cx); + circleElement.attr("cy", circleData.cy); + circleElement.attr("class", "actor-" + circleData.pos); + circleElement.attr("fill", circleData.fill); + circleElement.attr("stroke", circleData.stroke); + circleElement.attr("r", circleData.r); + if (circleElement.class !== void 0) { + circleElement.attr("class", circleElement.class); + } + if (circleData.title !== void 0) { + circleElement.append("title").text(circleData.title); + } + return circleElement; +}; +const drawText$1 = function(elem, textData) { + return drawText$4(elem, textData); +}; +const drawLabel$1 = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.labelMargin; + txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin; + drawText$1(elem, txtObject); +}; +const drawSection$1 = function(elem, section, conf2) { + const g = elem.append("g"); + const rect = getNoteRect$2(); + rect.x = section.x; + rect.y = section.y; + rect.fill = section.fill; + rect.width = conf2.width * section.taskCount + // width of the tasks + conf2.diagramMarginX * (section.taskCount - 1); + rect.height = conf2.height; + rect.class = "journey-section section-type-" + section.num; + rect.rx = 3; + rect.ry = 3; + drawRect$1(g, rect); + _drawTextCandidateFunc$1(conf2)( + section.text, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "journey-section section-type-" + section.num }, + conf2, + section.colour + ); +}; +let taskCount$1 = -1; +const drawTask$1 = function(elem, task, conf2) { + const center = task.x + conf2.width / 2; + const g = elem.append("g"); + taskCount$1++; + const maxHeight = 300 + 5 * 30; + g.append("line").attr("id", "task" + taskCount$1).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"); + drawFace$1(g, { + cx: center, + cy: 300 + (5 - task.score) * 30, + score: task.score + }); + const rect = getNoteRect$2(); + rect.x = task.x; + rect.y = task.y; + rect.fill = task.fill; + rect.width = conf2.width; + rect.height = conf2.height; + rect.class = "task task-type-" + task.num; + rect.rx = 3; + rect.ry = 3; + drawRect$1(g, rect); + let xPos = task.x + 14; + task.people.forEach((person) => { + const colour = task.actors[person].color; + const circle = { + cx: xPos, + cy: task.y, + r: 7, + fill: colour, + stroke: "#000", + title: person, + pos: task.actors[person].position + }; + drawCircle$1(g, circle); + xPos += 10; + }); + _drawTextCandidateFunc$1(conf2)( + task.task, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "task" }, + conf2, + task.colour + ); +}; +const drawBackgroundRect$1 = function(elem, bounds2) { + drawBackgroundRect$3(elem, bounds2); +}; +const _drawTextCandidateFunc$1 = function() { + function byText(content, g, x, y, width, height, textAttrs, colour) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2, colour) { + const { taskFontSize, taskFontFamily } = conf2; + const lines = content.split(//gi); + for (let i = 0; i < lines.length; i++) { + const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const body = g.append("switch"); + const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed"); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, body, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (key in fromTextAttrsDict) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const initGraphics$1 = function(graphics) { + graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z"); +}; +const svgDraw$1 = { + drawRect: drawRect$1, + drawCircle: drawCircle$1, + drawSection: drawSection$1, + drawText: drawText$1, + drawLabel: drawLabel$1, + drawTask: drawTask$1, + drawBackgroundRect: drawBackgroundRect$1, + initGraphics: initGraphics$1 +}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + keys.forEach(function(key) { + conf$1[key] = cnf[key]; + }); +}; +const actors = {}; +function drawActorLegend(diagram2) { + const conf2 = getConfig$2().journey; + let yPos = 60; + Object.keys(actors).forEach((person) => { + const colour = actors[person].color; + const circleData = { + cx: 20, + cy: yPos, + r: 7, + fill: colour, + stroke: "#000", + pos: actors[person].position + }; + svgDraw$1.drawCircle(diagram2, circleData); + const labelData = { + x: 40, + y: yPos + 7, + fill: "#666", + text: person, + textMargin: conf2.boxTextMargin | 5 + }; + svgDraw$1.drawText(diagram2, labelData); + yPos += 20; + }); +} +const conf$1 = getConfig$2().journey; +const LEFT_MARGIN = conf$1.leftMargin; +const draw$5 = function(text, id, version, diagObj) { + const conf2 = getConfig$2().journey; + const securityLevel = getConfig$2().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + bounds$1.init(); + const diagram2 = root.select("#" + id); + svgDraw$1.initGraphics(diagram2); + const tasks2 = diagObj.db.getTasks(); + const title = diagObj.db.getDiagramTitle(); + const actorNames = diagObj.db.getActors(); + for (const member in actors) { + delete actors[member]; + } + let actorPos = 0; + actorNames.forEach((actorName) => { + actors[actorName] = { + color: conf2.actorColours[actorPos % conf2.actorColours.length], + position: actorPos + }; + actorPos++; + }); + drawActorLegend(diagram2); + bounds$1.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50); + drawTasks$1(diagram2, tasks2, 0); + const box = bounds$1.getBounds(); + if (title) { + diagram2.append("text").text(title).attr("x", LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 25); + } + const height = box.stopy - box.starty + 2 * conf2.diagramMarginY; + const width = LEFT_MARGIN + box.stopx + 2 * conf2.diagramMarginX; + configureSvgSize(diagram2, height, width, conf2.useMaxWidth); + diagram2.append("line").attr("x1", LEFT_MARGIN).attr("y1", conf2.height * 4).attr("x2", width - LEFT_MARGIN - 4).attr("y2", conf2.height * 4).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"); + const extraVertForTitle = title ? 70 : 0; + diagram2.attr("viewBox", `${box.startx} -25 ${width} ${height + extraVertForTitle}`); + diagram2.attr("preserveAspectRatio", "xMinYMin meet"); + diagram2.attr("height", height + extraVertForTitle + 25); +}; +const bounds$1 = { + data: { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }, + verticalPos: 0, + sequenceItems: [], + init: function() { + this.sequenceItems = []; + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }; + this.verticalPos = 0; + }, + updateVal: function(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + }, + updateBounds: function(startx, starty, stopx, stopy) { + const conf2 = getConfig$2().journey; + const _self = this; + let cnt = 0; + function updateFn(type) { + return function updateItemBounds(item) { + cnt++; + const n = _self.sequenceItems.length - cnt + 1; + _self.updateVal(item, "starty", starty - n * conf2.boxMargin, Math.min); + _self.updateVal(item, "stopy", stopy + n * conf2.boxMargin, Math.max); + _self.updateVal(bounds$1.data, "startx", startx - n * conf2.boxMargin, Math.min); + _self.updateVal(bounds$1.data, "stopx", stopx + n * conf2.boxMargin, Math.max); + { + _self.updateVal(item, "startx", startx - n * conf2.boxMargin, Math.min); + _self.updateVal(item, "stopx", stopx + n * conf2.boxMargin, Math.max); + _self.updateVal(bounds$1.data, "starty", starty - n * conf2.boxMargin, Math.min); + _self.updateVal(bounds$1.data, "stopy", stopy + n * conf2.boxMargin, Math.max); + } + }; + } + this.sequenceItems.forEach(updateFn()); + }, + insert: function(startx, starty, stopx, stopy) { + const _startx = Math.min(startx, stopx); + const _stopx = Math.max(startx, stopx); + const _starty = Math.min(starty, stopy); + const _stopy = Math.max(starty, stopy); + this.updateVal(bounds$1.data, "startx", _startx, Math.min); + this.updateVal(bounds$1.data, "starty", _starty, Math.min); + this.updateVal(bounds$1.data, "stopx", _stopx, Math.max); + this.updateVal(bounds$1.data, "stopy", _stopy, Math.max); + this.updateBounds(_startx, _starty, _stopx, _stopy); + }, + bumpVerticalPos: function(bump) { + this.verticalPos = this.verticalPos + bump; + this.data.stopy = this.verticalPos; + }, + getVerticalPos: function() { + return this.verticalPos; + }, + getBounds: function() { + return this.data; + } +}; +const fills = conf$1.sectionFills; +const textColours = conf$1.sectionColours; +const drawTasks$1 = function(diagram2, tasks2, verticalPos) { + const conf2 = getConfig$2().journey; + let lastSection = ""; + const sectionVHeight = conf2.height * 2 + conf2.diagramMarginY; + const taskPos = verticalPos + sectionVHeight; + let sectionNumber = 0; + let fill = "#CCC"; + let colour = "black"; + let num = 0; + for (const [i, task] of tasks2.entries()) { + if (lastSection !== task.section) { + fill = fills[sectionNumber % fills.length]; + num = sectionNumber % fills.length; + colour = textColours[sectionNumber % textColours.length]; + let taskInSectionCount = 0; + const currentSection2 = task.section; + for (let taskIndex = i; taskIndex < tasks2.length; taskIndex++) { + if (tasks2[taskIndex].section == currentSection2) { + taskInSectionCount = taskInSectionCount + 1; + } else { + break; + } + } + const section = { + x: i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN, + y: 50, + text: task.section, + fill, + num, + colour, + taskCount: taskInSectionCount + }; + svgDraw$1.drawSection(diagram2, section, conf2); + lastSection = task.section; + sectionNumber++; + } + const taskActors = task.people.reduce((acc, actorName) => { + if (actors[actorName]) { + acc[actorName] = actors[actorName]; + } + return acc; + }, {}); + task.x = i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN; + task.y = taskPos; + task.width = conf2.diagramMarginX; + task.height = conf2.diagramMarginY; + task.colour = colour; + task.fill = fill; + task.num = num; + task.actors = taskActors; + svgDraw$1.drawTask(diagram2, task, conf2); + bounds$1.insert(task.x, task.y, task.x + task.width + conf2.taskMargin, 300 + 5 * 30); + } +}; +const renderer$6 = { + setConf, + draw: draw$5 +}; +const diagram$5 = { + parser: parser$1$4, + db: db$5, + renderer: renderer$6, + styles: styles$3, + init: (cnf) => { + renderer$6.setConf(cnf.journey); + db$5.clear(); + } +}; + +var journeyDiagram6625b456 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$5 +}); + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var elk_bundled = {exports: {}}; + +(function (module, exports) { + (function(f){{module.exports=f();}})(function(){return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof commonjsRequire&&commonjsRequire;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t);}return n[i].exports}for(var u="function"==typeof commonjsRequire&&commonjsRequire,i=0;i 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$defaultLayoutOpt = _ref.defaultLayoutOptions, + defaultLayoutOptions = _ref$defaultLayoutOpt === undefined ? {} : _ref$defaultLayoutOpt, + _ref$algorithms = _ref.algorithms, + algorithms = _ref$algorithms === undefined ? ['layered', 'stress', 'mrtree', 'radial', 'force', 'disco', 'sporeOverlap', 'sporeCompaction', 'rectpacking'] : _ref$algorithms, + workerFactory = _ref.workerFactory, + workerUrl = _ref.workerUrl; + + _classCallCheck(this, ELK); + + this.defaultLayoutOptions = defaultLayoutOptions; + this.initialized = false; + + // check valid worker construction possible + if (typeof workerUrl === 'undefined' && typeof workerFactory === 'undefined') { + throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'."); + } + var factory = workerFactory; + if (typeof workerUrl !== 'undefined' && typeof workerFactory === 'undefined') { + // use default Web Worker + factory = function factory(url) { + return new Worker(url); + }; + } + + // create the worker + var worker = factory(workerUrl); + if (typeof worker.postMessage !== 'function') { + throw new TypeError("Created worker does not provide" + " the required 'postMessage' function."); + } + + // wrap the worker to return promises + this.worker = new PromisedWorker(worker); + + // initially register algorithms + this.worker.postMessage({ + cmd: 'register', + algorithms: algorithms + }).then(function (r) { + return _this.initialized = true; + }).catch(console.err); + } + + _createClass(ELK, [{ + key: 'layout', + value: function layout(graph) { + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$layoutOptions = _ref2.layoutOptions, + layoutOptions = _ref2$layoutOptions === undefined ? this.defaultLayoutOptions : _ref2$layoutOptions, + _ref2$logging = _ref2.logging, + logging = _ref2$logging === undefined ? false : _ref2$logging, + _ref2$measureExecutio = _ref2.measureExecutionTime, + measureExecutionTime = _ref2$measureExecutio === undefined ? false : _ref2$measureExecutio; + + if (!graph) { + return Promise.reject(new Error("Missing mandatory parameter 'graph'.")); + } + return this.worker.postMessage({ + cmd: 'layout', + graph: graph, + layoutOptions: layoutOptions, + options: { + logging: logging, + measureExecutionTime: measureExecutionTime + } + }); + } + }, { + key: 'knownLayoutAlgorithms', + value: function knownLayoutAlgorithms() { + return this.worker.postMessage({ cmd: 'algorithms' }); + } + }, { + key: 'knownLayoutOptions', + value: function knownLayoutOptions() { + return this.worker.postMessage({ cmd: 'options' }); + } + }, { + key: 'knownLayoutCategories', + value: function knownLayoutCategories() { + return this.worker.postMessage({ cmd: 'categories' }); + } + }, { + key: 'terminateWorker', + value: function terminateWorker() { + if (this.worker) this.worker.terminate(); + } + }]); + + return ELK; + }(); + + exports.default = ELK; + + var PromisedWorker = function () { + function PromisedWorker(worker) { + var _this2 = this; + + _classCallCheck(this, PromisedWorker); + + if (worker === undefined) { + throw new Error("Missing mandatory parameter 'worker'."); + } + this.resolvers = {}; + this.worker = worker; + this.worker.onmessage = function (answer) { + // why is this necessary? + setTimeout(function () { + _this2.receive(_this2, answer); + }, 0); + }; + } + + _createClass(PromisedWorker, [{ + key: 'postMessage', + value: function postMessage(msg) { + var id = this.id || 0; + this.id = id + 1; + msg.id = id; + var self = this; + return new Promise(function (resolve, reject) { + // prepare the resolver + self.resolvers[id] = function (err, res) { + if (err) { + self.convertGwtStyleError(err); + reject(err); + } else { + resolve(res); + } + }; + // post the message + self.worker.postMessage(msg); + }); + } + }, { + key: 'receive', + value: function receive(self, answer) { + var json = answer.data; + var resolver = self.resolvers[json.id]; + if (resolver) { + delete self.resolvers[json.id]; + if (json.error) { + resolver(json.error); + } else { + resolver(null, json.data); + } + } + } + }, { + key: 'terminate', + value: function terminate() { + if (this.worker) { + this.worker.terminate(); + } + } + }, { + key: 'convertGwtStyleError', + value: function convertGwtStyleError(err) { + if (!err) { + return; + } + // Somewhat flatten the way GWT stores nested exception(s) + var javaException = err['__java$exception']; + if (javaException) { + // Note that the property name of the nested exception is different + // in the non-minified ('cause') and the minified (not deterministic) version. + // Hence, the version below only works for the non-minified version. + // However, as the minified stack trace is not of much use anyway, one + // should switch the used version for debugging in such a case. + if (javaException.cause && javaException.cause.backingJsObject) { + err.cause = javaException.cause.backingJsObject; + this.convertGwtStyleError(err.cause); + } + delete err['__java$exception']; + } + } + }]); + + return PromisedWorker; + }(); + },{}],2:[function(require,module,exports){ + (function (global){(function (){ + + // -------------- FAKE ELEMENTS GWT ASSUMES EXIST -------------- + var $wnd; + if (typeof window !== 'undefined') + $wnd = window; + else if (typeof global !== 'undefined') + $wnd = global; // nodejs + else if (typeof self !== 'undefined') + $wnd = self; // web worker + + // -------------- WORKAROUND STRICT MODE, SEE #127 -------------- + var o; + + // -------------- GENERATED CODE -------------- + function nb(){} + function xb(){} + function Fd(){} + function hh(){} + function lq(){} + function Nq(){} + function ir(){} + function Ws(){} + function Zw(){} + function jx(){} + function rx(){} + function sx(){} + function My(){} + function bA(){} + function mA(){} + function tA(){} + function aB(){} + function dB(){} + function jB(){} + function dC(){} + function keb(){} + function geb(){} + function oeb(){} + function iob(){} + function Job(){} + function Rob(){} + function apb(){} + function ipb(){} + function nrb(){} + function wrb(){} + function Brb(){} + function Prb(){} + function ltb(){} + function svb(){} + function xvb(){} + function zvb(){} + function $xb(){} + function Gzb(){} + function NAb(){} + function VAb(){} + function rBb(){} + function RBb(){} + function TBb(){} + function XBb(){} + function ZBb(){} + function _Bb(){} + function bCb(){} + function dCb(){} + function fCb(){} + function jCb(){} + function rCb(){} + function uCb(){} + function wCb(){} + function yCb(){} + function ACb(){} + function ECb(){} + function FEb(){} + function IEb(){} + function KEb(){} + function MEb(){} + function gFb(){} + function FFb(){} + function JFb(){} + function xGb(){} + function AGb(){} + function YGb(){} + function oHb(){} + function tHb(){} + function xHb(){} + function pIb(){} + function BJb(){} + function kLb(){} + function mLb(){} + function oLb(){} + function qLb(){} + function FLb(){} + function JLb(){} + function KMb(){} + function MMb(){} + function OMb(){} + function YMb(){} + function MNb(){} + function ONb(){} + function aOb(){} + function eOb(){} + function xOb(){} + function BOb(){} + function DOb(){} + function FOb(){} + function IOb(){} + function MOb(){} + function POb(){} + function UOb(){} + function ZOb(){} + function cPb(){} + function gPb(){} + function nPb(){} + function qPb(){} + function tPb(){} + function wPb(){} + function CPb(){} + function qQb(){} + function GQb(){} + function bRb(){} + function gRb(){} + function kRb(){} + function pRb(){} + function wRb(){} + function xSb(){} + function TSb(){} + function VSb(){} + function XSb(){} + function ZSb(){} + function _Sb(){} + function tTb(){} + function DTb(){} + function FTb(){} + function FXb(){} + function hXb(){} + function hWb(){} + function mWb(){} + function CVb(){} + function XXb(){} + function $Xb(){} + function bYb(){} + function lYb(){} + function FYb(){} + function XYb(){} + function aZb(){} + function SZb(){} + function ZZb(){} + function Z_b(){} + function j_b(){} + function j$b(){} + function b$b(){} + function f$b(){} + function n$b(){} + function K_b(){} + function V_b(){} + function b0b(){} + function l0b(){} + function X1b(){} + function _1b(){} + function x3b(){} + function r4b(){} + function w4b(){} + function A4b(){} + function E4b(){} + function I4b(){} + function M4b(){} + function o5b(){} + function q5b(){} + function w5b(){} + function A5b(){} + function E5b(){} + function h6b(){} + function j6b(){} + function l6b(){} + function q6b(){} + function v6b(){} + function y6b(){} + function G6b(){} + function K6b(){} + function N6b(){} + function P6b(){} + function R6b(){} + function b7b(){} + function f7b(){} + function j7b(){} + function n7b(){} + function C7b(){} + function H7b(){} + function J7b(){} + function L7b(){} + function N7b(){} + function P7b(){} + function a8b(){} + function c8b(){} + function e8b(){} + function g8b(){} + function i8b(){} + function m8b(){} + function Z8b(){} + function f9b(){} + function i9b(){} + function o9b(){} + function C9b(){} + function F9b(){} + function K9b(){} + function Q9b(){} + function aac(){} + function bac(){} + function eac(){} + function mac(){} + function pac(){} + function rac(){} + function tac(){} + function xac(){} + function Aac(){} + function Dac(){} + function Iac(){} + function Oac(){} + function Uac(){} + function Ucc(){} + function scc(){} + function ycc(){} + function Acc(){} + function Ccc(){} + function Ncc(){} + function Wcc(){} + function ydc(){} + function Adc(){} + function Gdc(){} + function Ldc(){} + function Zdc(){} + function fec(){} + function Dec(){} + function Gec(){} + function Kec(){} + function efc(){} + function jfc(){} + function nfc(){} + function Bfc(){} + function Ifc(){} + function Lfc(){} + function Rfc(){} + function Ufc(){} + function Zfc(){} + function cgc(){} + function egc(){} + function ggc(){} + function igc(){} + function kgc(){} + function Dgc(){} + function Hgc(){} + function Lgc(){} + function Ngc(){} + function Pgc(){} + function Vgc(){} + function Ygc(){} + function chc(){} + function ehc(){} + function ghc(){} + function ihc(){} + function mhc(){} + function rhc(){} + function uhc(){} + function whc(){} + function yhc(){} + function Ahc(){} + function Chc(){} + function Ghc(){} + function Nhc(){} + function Phc(){} + function Rhc(){} + function Thc(){} + function $hc(){} + function aic(){} + function cic(){} + function eic(){} + function jic(){} + function nic(){} + function pic(){} + function ric(){} + function vic(){} + function yic(){} + function Dic(){} + function Ric(){} + function Zic(){} + function bjc(){} + function djc(){} + function jjc(){} + function njc(){} + function rjc(){} + function tjc(){} + function zjc(){} + function Djc(){} + function Fjc(){} + function Ljc(){} + function Pjc(){} + function Rjc(){} + function fkc(){} + function Kkc(){} + function Mkc(){} + function Okc(){} + function Qkc(){} + function Skc(){} + function Ukc(){} + function Wkc(){} + function clc(){} + function elc(){} + function klc(){} + function mlc(){} + function olc(){} + function qlc(){} + function wlc(){} + function ylc(){} + function Alc(){} + function Jlc(){} + function Joc(){} + function poc(){} + function roc(){} + function toc(){} + function voc(){} + function Boc(){} + function Foc(){} + function Hoc(){} + function Loc(){} + function Noc(){} + function Poc(){} + function qnc(){} + function unc(){} + function upc(){} + function kpc(){} + function mpc(){} + function opc(){} + function qpc(){} + function ypc(){} + function Cpc(){} + function Mpc(){} + function Qpc(){} + function dqc(){} + function jqc(){} + function Aqc(){} + function Eqc(){} + function Gqc(){} + function Sqc(){} + function arc(){} + function lrc(){} + function zrc(){} + function Hrc(){} + function bsc(){} + function dsc(){} + function fsc(){} + function ksc(){} + function msc(){} + function Asc(){} + function Csc(){} + function Esc(){} + function Ksc(){} + function Nsc(){} + function Ssc(){} + function CCc(){} + function tGc(){} + function aHc(){} + function gHc(){} + function nIc(){} + function PJc(){} + function XKc(){} + function fLc(){} + function hLc(){} + function lLc(){} + function eNc(){} + function IOc(){} + function MOc(){} + function WOc(){} + function YOc(){} + function $Oc(){} + function cPc(){} + function iPc(){} + function mPc(){} + function oPc(){} + function qPc(){} + function sPc(){} + function wPc(){} + function APc(){} + function FPc(){} + function HPc(){} + function NPc(){} + function PPc(){} + function TPc(){} + function VPc(){} + function ZPc(){} + function _Pc(){} + function bQc(){} + function dQc(){} + function SQc(){} + function hRc(){} + function HRc(){} + function HSc(){} + function pSc(){} + function xSc(){} + function zSc(){} + function BSc(){} + function DSc(){} + function FSc(){} + function CTc(){} + function ITc(){} + function KTc(){} + function MTc(){} + function XTc(){} + function ZTc(){} + function jVc(){} + function lVc(){} + function zVc(){} + function IVc(){} + function KVc(){} + function KWc(){} + function uWc(){} + function xWc(){} + function AWc(){} + function QWc(){} + function UWc(){} + function qXc(){} + function KXc(){} + function OXc(){} + function SXc(){} + function $Xc(){} + function mYc(){} + function rYc(){} + function zYc(){} + function DYc(){} + function FYc(){} + function HYc(){} + function JYc(){} + function cZc(){} + function gZc(){} + function iZc(){} + function pZc(){} + function tZc(){} + function vZc(){} + function AZc(){} + function GZc(){} + function l_c(){} + function l1c(){} + function b1c(){} + function d1c(){} + function h1c(){} + function n1c(){} + function r1c(){} + function v1c(){} + function x1c(){} + function D1c(){} + function H1c(){} + function L1c(){} + function R1c(){} + function V1c(){} + function Z1c(){} + function Z0c(){} + function a0c(){} + function c0c(){} + function e0c(){} + function k0c(){} + function o0c(){} + function b2c(){} + function l2c(){} + function p2c(){} + function Y2c(){} + function _2c(){} + function A3c(){} + function F3c(){} + function I3c(){} + function K3c(){} + function M3c(){} + function Q3c(){} + function U3c(){} + function c5c(){} + function D5c(){} + function G5c(){} + function J5c(){} + function N5c(){} + function V5c(){} + function p6c(){} + function s6c(){} + function H6c(){} + function K6c(){} + function _7c(){} + function h8c(){} + function j8c(){} + function o8c(){} + function r8c(){} + function u8c(){} + function R8c(){} + function X8c(){} + function o9c(){} + function s9c(){} + function x9c(){} + function Qad(){} + function rcd(){} + function Xcd(){} + function vdd(){} + function Tdd(){} + function _dd(){} + function qed(){} + function sed(){} + function ved(){} + function Hed(){} + function Zed(){} + function bfd(){} + function ifd(){} + function Gfd(){} + function Ifd(){} + function Igd(){} + function agd(){} + function dgd(){} + function pgd(){} + function Hgd(){} + function Kgd(){} + function Mgd(){} + function Ogd(){} + function Qgd(){} + function Sgd(){} + function Ugd(){} + function Wgd(){} + function Ygd(){} + function $gd(){} + function ahd(){} + function chd(){} + function ehd(){} + function ghd(){} + function ihd(){} + function khd(){} + function mhd(){} + function ohd(){} + function qhd(){} + function shd(){} + function Shd(){} + function lkd(){} + function znd(){} + function Jpd(){} + function jrd(){} + function Mrd(){} + function Qrd(){} + function Urd(){} + function Yrd(){} + function Yud(){} + function eud(){} + function asd(){} + function Lsd(){} + function btd(){} + function dtd(){} + function jtd(){} + function otd(){} + function ztd(){} + function Xxd(){} + function $yd(){} + function rzd(){} + function Rzd(){} + function KAd(){} + function hCd(){} + function _Cd(){} + function _Sd(){} + function OSd(){} + function BDd(){} + function BId(){} + function JId(){} + function YHd(){} + function fLd(){} + function cPd(){} + function hQd(){} + function AQd(){} + function kUd(){} + function VUd(){} + function pVd(){} + function W$d(){} + function Z$d(){} + function a_d(){} + function i_d(){} + function v_d(){} + function y_d(){} + function f1d(){} + function L5d(){} + function v6d(){} + function b8d(){} + function e8d(){} + function h8d(){} + function k8d(){} + function n8d(){} + function q8d(){} + function t8d(){} + function w8d(){} + function z8d(){} + function X9d(){} + function _9d(){} + function Mae(){} + function cbe(){} + function ebe(){} + function hbe(){} + function kbe(){} + function nbe(){} + function qbe(){} + function tbe(){} + function wbe(){} + function zbe(){} + function Cbe(){} + function Fbe(){} + function Ibe(){} + function Lbe(){} + function Obe(){} + function Rbe(){} + function Ube(){} + function Xbe(){} + function $be(){} + function bce(){} + function ece(){} + function hce(){} + function kce(){} + function nce(){} + function qce(){} + function tce(){} + function wce(){} + function zce(){} + function Cce(){} + function Fce(){} + function Ice(){} + function Lce(){} + function Oce(){} + function Rce(){} + function Uce(){} + function Xce(){} + function $ce(){} + function bde(){} + function ede(){} + function hde(){} + function kde(){} + function nde(){} + function qde(){} + function tde(){} + function wde(){} + function Hie(){} + function rke(){} + function rne(){} + function Ene(){} + function Gne(){} + function Jne(){} + function Mne(){} + function Pne(){} + function Sne(){} + function Vne(){} + function Yne(){} + function _ne(){} + function yme(){} + function coe(){} + function foe(){} + function ioe(){} + function loe(){} + function ooe(){} + function roe(){} + function uoe(){} + function xoe(){} + function Aoe(){} + function Doe(){} + function Goe(){} + function Joe(){} + function Moe(){} + function Poe(){} + function Soe(){} + function Voe(){} + function Yoe(){} + function _oe(){} + function cpe(){} + function fpe(){} + function ipe(){} + function lpe(){} + function ope(){} + function rpe(){} + function upe(){} + function xpe(){} + function Ape(){} + function Dpe(){} + function Gpe(){} + function Jpe(){} + function Mpe(){} + function Ppe(){} + function Spe(){} + function Vpe(){} + function Ype(){} + function _pe(){} + function cqe(){} + function fqe(){} + function iqe(){} + function lqe(){} + function oqe(){} + function rqe(){} + function uqe(){} + function Tqe(){} + function sue(){} + function Cue(){} + function zl(){wb();} + function z7b(){s7b();} + function ZHb(){YHb();} + function fSb(){eSb();} + function vSb(){tSb();} + function PUb(){OUb();} + function AVb(){yVb();} + function RVb(){QVb();} + function fWb(){dWb();} + function N5b(){H5b();} + function $9b(){U9b();} + function Lcc(){Hcc();} + function pdc(){Zcc();} + function pec(){iec();} + function pGc(){nGc();} + function jGc(){gGc();} + function YGc(){SGc();} + function cGc(){_Fc();} + function NFc(){KFc();} + function xgc(){sgc();} + function xHc(){tHc();} + function pHc(){lHc();} + function IHc(){CHc();} + function XHc(){RHc();} + function boc(){Mnc();} + function yqc(){mqc();} + function Pzc(){Ozc();} + function ACc(){yCc();} + function aKc(){YJc();} + function FLc(){DLc();} + function DNc(){ANc();} + function TNc(){JNc();} + function iQc(){gQc();} + function WRc(){TRc();} + function C$c(){B$c();} + function J0c(){B0c();} + function x0c(){r0c();} + function j_c(){h_c();} + function N_c(){H_c();} + function V_c(){R_c();} + function E4c(){D4c();} + function a5c(){$4c();} + function v7c(){u7c();} + function Z7c(){X7c();} + function pcd(){ncd();} + function Lcd(){Kcd();} + function Vcd(){Tcd();} + function fUd(){TTd();} + function Bfd(){Afd();} + function jkd(){hkd();} + function vmd(){umd();} + function xnd(){vnd();} + function Hpd(){Fpd();} + function HYd(){lYd();} + function yAd(){qAd();} + function gke(){rue();} + function Yxb(a){uFb(a);} + function Yb(a){this.a=a;} + function cc(a){this.a=a;} + function df(a){this.a=a;} + function kf(a){this.a=a;} + function kj(a){this.a=a;} + function qj(a){this.a=a;} + function Lj(a){this.a=a;} + function jh(a){this.a=a;} + function th(a){this.a=a;} + function Bh(a){this.a=a;} + function Xh(a){this.a=a;} + function Xn(a){this.a=a;} + function Di(a){this.a=a;} + function Ki(a){this.a=a;} + function Ik(a){this.a=a;} + function Qk(a){this.a=a;} + function mp(a){this.a=a;} + function Lp(a){this.a=a;} + function iq(a){this.a=a;} + function Eq(a){this.a=a;} + function Vq(a){this.a=a;} + function Or(a){this.a=a;} + function $r(a){this.b=a;} + function Aj(a){this.c=a;} + function vu(a){this.a=a;} + function vw(a){this.a=a;} + function gw(a){this.a=a;} + function lw(a){this.a=a;} + function Iw(a){this.a=a;} + function Nw(a){this.a=a;} + function Sw(a){this.a=a;} + function ex(a){this.a=a;} + function fx(a){this.a=a;} + function lx(a){this.a=a;} + function my(a){this.a=a;} + function qy(a){this.a=a;} + function Oy(a){this.a=a;} + function NB(a){this.a=a;} + function XB(a){this.a=a;} + function hC(a){this.a=a;} + function vC(a){this.a=a;} + function MB(){this.a=[];} + function HEb(a,b){a.a=b;} + function E2b(a,b){a.a=b;} + function F2b(a,b){a.b=b;} + function PRb(a,b){a.b=b;} + function RRb(a,b){a.b=b;} + function QJb(a,b){a.j=b;} + function hQb(a,b){a.g=b;} + function iQb(a,b){a.i=b;} + function _Tb(a,b){a.c=b;} + function G2b(a,b){a.c=b;} + function H2b(a,b){a.d=b;} + function aUb(a,b){a.d=b;} + function h3b(a,b){a.k=b;} + function O3b(a,b){a.c=b;} + function Tmc(a,b){a.c=b;} + function Smc(a,b){a.a=b;} + function DJc(a,b){a.a=b;} + function EJc(a,b){a.f=b;} + function NSc(a,b){a.a=b;} + function OSc(a,b){a.b=b;} + function PSc(a,b){a.d=b;} + function QSc(a,b){a.i=b;} + function RSc(a,b){a.o=b;} + function SSc(a,b){a.r=b;} + function yUc(a,b){a.a=b;} + function zUc(a,b){a.b=b;} + function q3c(a,b){a.e=b;} + function r3c(a,b){a.f=b;} + function s3c(a,b){a.g=b;} + function Y9c(a,b){a.e=b;} + function Z9c(a,b){a.f=b;} + function kad(a,b){a.f=b;} + function Ntd(a,b){a.a=b;} + function Otd(a,b){a.b=b;} + function BWd(a,b){a.n=b;} + function $ee(a,b){a.a=b;} + function _ee(a,b){a.c=b;} + function ife(a,b){a.c=b;} + function Efe(a,b){a.c=b;} + function hfe(a,b){a.a=b;} + function Dfe(a,b){a.a=b;} + function jfe(a,b){a.d=b;} + function Ffe(a,b){a.d=b;} + function kfe(a,b){a.e=b;} + function Gfe(a,b){a.e=b;} + function lfe(a,b){a.g=b;} + function Hfe(a,b){a.f=b;} + function Ife(a,b){a.j=b;} + function wme(a,b){a.a=b;} + function Fme(a,b){a.a=b;} + function xme(a,b){a.b=b;} + function gmc(a){a.b=a.a;} + function Lg(a){a.c=a.d.d;} + function fgb(a){this.a=a;} + function zgb(a){this.a=a;} + function Xgb(a){this.a=a;} + function Xkb(a){this.a=a;} + function mkb(a){this.a=a;} + function reb(a){this.a=a;} + function Seb(a){this.a=a;} + function bfb(a){this.a=a;} + function Tfb(a){this.a=a;} + function blb(a){this.a=a;} + function glb(a){this.a=a;} + function llb(a){this.a=a;} + function Ulb(a){this.a=a;} + function _lb(a){this.a=a;} + function Plb(a){this.b=a;} + function Ppb(a){this.b=a;} + function xpb(a){this.b=a;} + function mpb(a){this.a=a;} + function Yqb(a){this.a=a;} + function uqb(a){this.c=a;} + function Anb(a){this.c=a;} + function zwb(a){this.c=a;} + function Dkb(a){this.d=a;} + function brb(a){this.a=a;} + function Frb(a){this.a=a;} + function hsb(a){this.a=a;} + function ctb(a){this.a=a;} + function cxb(a){this.a=a;} + function axb(a){this.a=a;} + function exb(a){this.a=a;} + function gxb(a){this.a=a;} + function wub(a){this.a=a;} + function zAb(a){this.a=a;} + function JAb(a){this.a=a;} + function LAb(a){this.a=a;} + function PAb(a){this.a=a;} + function VBb(a){this.a=a;} + function lCb(a){this.a=a;} + function nCb(a){this.a=a;} + function pCb(a){this.a=a;} + function CCb(a){this.a=a;} + function GCb(a){this.a=a;} + function bDb(a){this.a=a;} + function dDb(a){this.a=a;} + function fDb(a){this.a=a;} + function uDb(a){this.a=a;} + function $Db(a){this.a=a;} + function aEb(a){this.a=a;} + function eEb(a){this.a=a;} + function OEb(a){this.a=a;} + function SEb(a){this.a=a;} + function SFb(a){this.a=a;} + function HFb(a){this.a=a;} + function NFb(a){this.a=a;} + function WGb(a){this.a=a;} + function HJb(a){this.a=a;} + function PJb(a){this.a=a;} + function kNb(a){this.a=a;} + function tOb(a){this.a=a;} + function APb(a){this.a=a;} + function IQb(a){this.a=a;} + function bTb(a){this.a=a;} + function dTb(a){this.a=a;} + function wTb(a){this.a=a;} + function GWb(a){this.a=a;} + function UWb(a){this.a=a;} + function WWb(a){this.a=a;} + function fXb(a){this.a=a;} + function jXb(a){this.a=a;} + function M0b(a){this.a=a;} + function r1b(a){this.a=a;} + function D1b(a){this.e=a;} + function T3b(a){this.a=a;} + function W3b(a){this.a=a;} + function _3b(a){this.a=a;} + function c4b(a){this.a=a;} + function s5b(a){this.a=a;} + function u5b(a){this.a=a;} + function y5b(a){this.a=a;} + function C5b(a){this.a=a;} + function Q5b(a){this.a=a;} + function S5b(a){this.a=a;} + function U5b(a){this.a=a;} + function W5b(a){this.a=a;} + function l7b(a){this.a=a;} + function p7b(a){this.a=a;} + function k8b(a){this.a=a;} + function L8b(a){this.a=a;} + function Rac(a){this.a=a;} + function Xac(a){this.a=a;} + function $ac(a){this.a=a;} + function bbc(a){this.a=a;} + function Cdc(a){this.a=a;} + function Edc(a){this.a=a;} + function Ehc(a){this.a=a;} + function khc(a){this.a=a;} + function Ihc(a){this.a=a;} + function qfc(a){this.a=a;} + function tfc(a){this.a=a;} + function Wfc(a){this.a=a;} + function Fic(a){this.a=a;} + function Vic(a){this.a=a;} + function fjc(a){this.a=a;} + function pjc(a){this.a=a;} + function ckc(a){this.a=a;} + function hkc(a){this.a=a;} + function Ykc(a){this.a=a;} + function $kc(a){this.a=a;} + function alc(a){this.a=a;} + function glc(a){this.a=a;} + function ilc(a){this.a=a;} + function slc(a){this.a=a;} + function Clc(a){this.a=a;} + function xoc(a){this.a=a;} + function zoc(a){this.a=a;} + function spc(a){this.a=a;} + function Vqc(a){this.a=a;} + function Xqc(a){this.a=a;} + function Gsc(a){this.a=a;} + function Isc(a){this.a=a;} + function JGc(a){this.a=a;} + function NGc(a){this.a=a;} + function MHc(a){this.a=a;} + function JIc(a){this.a=a;} + function fJc(a){this.a=a;} + function BJc(a){this.a=a;} + function dJc(a){this.c=a;} + function Trc(a){this.b=a;} + function eKc(a){this.a=a;} + function IKc(a){this.a=a;} + function KKc(a){this.a=a;} + function MKc(a){this.a=a;} + function yLc(a){this.a=a;} + function HMc(a){this.a=a;} + function LMc(a){this.a=a;} + function PMc(a){this.a=a;} + function TMc(a){this.a=a;} + function XMc(a){this.a=a;} + function ZMc(a){this.a=a;} + function aNc(a){this.a=a;} + function jNc(a){this.a=a;} + function aPc(a){this.a=a;} + function gPc(a){this.a=a;} + function kPc(a){this.a=a;} + function yPc(a){this.a=a;} + function CPc(a){this.a=a;} + function JPc(a){this.a=a;} + function RPc(a){this.a=a;} + function XPc(a){this.a=a;} + function mRc(a){this.a=a;} + function xTc(a){this.a=a;} + function CWc(a){this.a=a;} + function EWc(a){this.a=a;} + function IWc(a){this.a=a;} + function OWc(a){this.a=a;} + function dXc(a){this.a=a;} + function gXc(a){this.a=a;} + function EXc(a){this.a=a;} + function WXc(a){this.a=a;} + function YXc(a){this.a=a;} + function aYc(a){this.a=a;} + function cYc(a){this.a=a;} + function eYc(a){this.a=a;} + function iYc(a){this.a=a;} + function i0c(a){this.a=a;} + function g0c(a){this.a=a;} + function P1c(a){this.a=a;} + function Sad(a){this.a=a;} + function Uad(a){this.a=a;} + function Wad(a){this.a=a;} + function Yad(a){this.a=a;} + function cbd(a){this.a=a;} + function ydd(a){this.a=a;} + function Kdd(a){this.a=a;} + function Mdd(a){this.a=a;} + function _ed(a){this.a=a;} + function dfd(a){this.a=a;} + function Kfd(a){this.a=a;} + function prd(a){this.a=a;} + function $rd(a){this.a=a;} + function csd(a){this.a=a;} + function Usd(a){this.a=a;} + function Vtd(a){this.a=a;} + function wud(a){this.a=a;} + function Rud(a){this.f=a;} + function LEd(a){this.a=a;} + function UEd(a){this.a=a;} + function VEd(a){this.a=a;} + function WEd(a){this.a=a;} + function XEd(a){this.a=a;} + function YEd(a){this.a=a;} + function ZEd(a){this.a=a;} + function $Ed(a){this.a=a;} + function _Ed(a){this.a=a;} + function aFd(a){this.a=a;} + function gFd(a){this.a=a;} + function iFd(a){this.a=a;} + function jFd(a){this.a=a;} + function kFd(a){this.a=a;} + function lFd(a){this.a=a;} + function nFd(a){this.a=a;} + function qFd(a){this.a=a;} + function wFd(a){this.a=a;} + function xFd(a){this.a=a;} + function zFd(a){this.a=a;} + function AFd(a){this.a=a;} + function BFd(a){this.a=a;} + function CFd(a){this.a=a;} + function DFd(a){this.a=a;} + function MFd(a){this.a=a;} + function OFd(a){this.a=a;} + function QFd(a){this.a=a;} + function SFd(a){this.a=a;} + function uGd(a){this.a=a;} + function QGd(a){this.a=a;} + function jGd(a){this.b=a;} + function YOd(a){this.a=a;} + function ePd(a){this.a=a;} + function kPd(a){this.a=a;} + function qPd(a){this.a=a;} + function IPd(a){this.a=a;} + function w$d(a){this.a=a;} + function e_d(a){this.a=a;} + function Q_d(a){this.b=a;} + function c1d(a){this.a=a;} + function c2d(a){this.a=a;} + function l5d(a){this.a=a;} + function I9d(a){this.a=a;} + function L6d(a){this.c=a;} + function t7d(a){this.e=a;} + function pae(a){this.a=a;} + function xae(a){this.a=a;} + function Zde(a){this.a=a;} + function Sde(a){this.d=a;} + function mee(a){this.a=a;} + function uje(a){this.a=a;} + function Bte(a){this.a=a;} + function Wse(a){this.e=a;} + function Xsd(){this.a=0;} + function Tsb(){akb(this);} + function bnb(){Pmb(this);} + function cHb(){bHb(this);} + function I2b(){} + function s2d(){this.c=d2d;} + function Prc(a,b){a.b+=b;} + function Uje(a,b){b.Wb(a);} + function UC(a){return a.a} + function nC(a){return a.a} + function BC(a){return a.a} + function TB(a){return a.a} + function _B(a){return a.a} + function Adb(a){return a.e} + function gC(){return null} + function MC(){return null} + function leb(){MId();OId();} + function qMb(a){a.b.Of(a.e);} + function A$b(a){a.b=new Ri;} + function A8b(a,b){a.b=b-a.b;} + function x8b(a,b){a.a=b-a.a;} + function ZEb(a,b){a.push(b);} + function bFb(a,b){a.sort(b);} + function Q5c(a,b){b.jd(a.a);} + function Voc(a,b){Q3b(b,a);} + function tp(a,b,c){a.Yd(c,b);} + function Ss(a,b){a.e=b;b.b=a;} + function im(a){_l();this.a=a;} + function xq(a){_l();this.a=a;} + function Gq(a){_l();this.a=a;} + function Xq(a){tm();this.a=a;} + function gA(a){fA();eA.le(a);} + function vA(){vA=geb;new Tsb;} + function xz(){mz.call(this);} + function Ceb(){mz.call(this);} + function ueb(){xz.call(this);} + function yeb(){xz.call(this);} + function Hfb(){xz.call(this);} + function _fb(){xz.call(this);} + function cgb(){xz.call(this);} + function Ngb(){xz.call(this);} + function jib(){xz.call(this);} + function Jrb(){xz.call(this);} + function Srb(){xz.call(this);} + function Dvb(){xz.call(this);} + function Ied(){xz.call(this);} + function R1d(){this.a=this;} + function k1d(){this.Bb|=256;} + function vWb(){this.b=new Et;} + function aFb(a,b){a.length=b;} + function dyb(a,b){Rmb(a.a,b);} + function jNb(a,b){LKb(a.c,b);} + function qRc(a,b){Ysb(a.b,b);} + function VOd(a,b){UNd(a.a,b);} + function WOd(a,b){VNd(a.a,b);} + function eZd(a,b){qvd(a.e,b);} + function Cke(a){bge(a.c,a.b);} + function uj(a,b){a.kc().Nb(b);} + function Ufb(a){this.a=Zfb(a);} + function _sb(){this.a=new Tsb;} + function $Ab(){this.a=new Tsb;} + function xAb(){this.a=new dzb;} + function gyb(){this.a=new bnb;} + function BIb(){this.a=new bnb;} + function GIb(){this.a=new bnb;} + function wIb(){this.a=new pIb;} + function gJb(){this.a=new DIb;} + function TTb(){this.a=new DTb;} + function jGb(){this.a=new fGb;} + function qGb(){this.a=new kGb;} + function q_b(){this.a=new bnb;} + function E_b(){this.a=new bnb;} + function EZb(){this.a=new bnb;} + function J$b(){this.a=new bnb;} + function YNb(){this.d=new bnb;} + function lXb(){this.a=new RWb;} + function y_b(){this.a=new _sb;} + function k5b(){this.a=new Tsb;} + function E0b(){this.b=new Tsb;} + function jHc(){this.b=new bnb;} + function ZNc(){this.e=new bnb;} + function ahc(){this.a=new boc;} + function UQc(){this.d=new bnb;} + function uRc(){tRc.call(this);} + function BRc(){tRc.call(this);} + function VOc(){bnb.call(this);} + function web(){ueb.call(this);} + function Fyb(){gyb.call(this);} + function fKb(){RJb.call(this);} + function N$b(){J$b.call(this);} + function P2b(){I2b.call(this);} + function T2b(){P2b.call(this);} + function z3b(){I2b.call(this);} + function C3b(){z3b.call(this);} + function cUc(){aUc.call(this);} + function hUc(){aUc.call(this);} + function mUc(){aUc.call(this);} + function Hdd(){Ddd.call(this);} + function ACd(){$yd.call(this);} + function PCd(){$yd.call(this);} + function Ejd(){Yub.call(this);} + function LQd(){wQd.call(this);} + function lRd(){wQd.call(this);} + function MSd(){Tsb.call(this);} + function VSd(){Tsb.call(this);} + function eTd(){Tsb.call(this);} + function mXd(){HWd.call(this);} + function i1d(){_sb.call(this);} + function A1d(){k1d.call(this);} + function q4d(){dWd.call(this);} + function O5d(){Tsb.call(this);} + function R5d(){dWd.call(this);} + function lae(){Tsb.call(this);} + function Cae(){Tsb.call(this);} + function ome(){kUd.call(this);} + function Hme(){ome.call(this);} + function Nme(){kUd.call(this);} + function Gre(){Tqe.call(this);} + function aUc(){this.a=new _sb;} + function nZc(){this.a=new Tsb;} + function DZc(){this.a=new bnb;} + function Ddd(){this.a=new Tsb;} + function Oqd(){this.a=new Yub;} + function Oed(){this.j=new bnb;} + function obd(){this.a=new nbd;} + function wQd(){this.a=new AQd;} + function R5c(){this.a=new V5c;} + function wb(){wb=geb;vb=new xb;} + function Wk(){Wk=geb;Vk=new Xk;} + function kl(){kl=geb;jl=new ll;} + function ll(){Qk.call(this,'');} + function Xk(){Qk.call(this,'');} + function Dd(a){yd.call(this,a);} + function Hd(a){yd.call(this,a);} + function xh(a){th.call(this,a);} + function $h(a){Wc.call(this,a);} + function Qi(a){Wc.call(this,a);} + function wi(a){$h.call(this,a);} + function Sp(a){$h.call(this,a);} + function Js(a){$h.call(this,a);} + function Jp(a){Xo.call(this,a);} + function Qp(a){Xo.call(this,a);} + function dq(a){ho.call(this,a);} + function Fv(a){uv.call(this,a);} + function aw(a){Tr.call(this,a);} + function cw(a){Tr.call(this,a);} + function _w(a){Tr.call(this,a);} + function Mx(a){Gn.call(this,a);} + function Nx(a){Mx.call(this,a);} + function yz(a){nz.call(this,a);} + function aC(a){yz.call(this,a);} + function uC(){vC.call(this,{});} + function cC(){cC=geb;bC=new dC;} + function zs(){zs=geb;ys=new As;} + function Az(){Az=geb;zz=new nb;} + function $z(){$z=geb;Zz=new bA;} + function $A(){$A=geb;ZA=new aB;} + function Ovb(a){Kvb();this.a=a;} + function FKc(a){jKc();this.a=a;} + function zud(a){nud();this.f=a;} + function Bud(a){nud();this.f=a;} + function Cde(a){KMd();this.a=a;} + function Lyb(a){a.b=null;a.c=0;} + function kz(a,b){a.e=b;hz(a,b);} + function NYb(a,b){a.a=b;PYb(a);} + function cLb(a,b,c){a.a[b.g]=c;} + function zsd(a,b,c){Hsd(c,a,b);} + function shc(a,b){Xmc(b.i,a.n);} + function HCc(a,b){ICc(a).Cd(b);} + function yw(a,b){a.a.ec().Mc(b);} + function ns(a,b){return a.g-b.g} + function AUb(a,b){return a*a/b} + function Heb(a){return uFb(a),a} + function Kfb(a){return uFb(a),a} + function Mfb(a){return uFb(a),a} + function JC(a){return new hC(a)} + function LC(a){return new OC(a)} + function shb(a){return uFb(a),a} + function Chb(a){return uFb(a),a} + function teb(a){yz.call(this,a);} + function veb(a){yz.call(this,a);} + function zeb(a){yz.call(this,a);} + function Aeb(a){nz.call(this,a);} + function Ifb(a){yz.call(this,a);} + function agb(a){yz.call(this,a);} + function dgb(a){yz.call(this,a);} + function Mgb(a){yz.call(this,a);} + function Ogb(a){yz.call(this,a);} + function kib(a){yz.call(this,a);} + function Jed(a){yz.call(this,a);} + function Ked(a){yz.call(this,a);} + function CDd(a){yz.call(this,a);} + function Mle(a){yz.call(this,a);} + function Lqe(a){yz.call(this,a);} + function mob(a){uFb(a);this.a=a;} + function yYb(a){sYb(a);return a} + function Nnb(a){Snb(a,a.length);} + function nmb(a){return a.b==a.c} + function Vyb(a){return !!a&&a.b} + function gLb(a){return !!a&&a.k} + function hLb(a){return !!a&&a.j} + function F_b(a,b,c){a.c.Ef(b,c);} + function Ts(a,b){a.be(b);b.ae(a);} + function Fy(a){_l();this.a=Qb(a);} + function Gb(){this.a=WD(Qb(pve));} + function jc(){throw Adb(new jib)} + function jn(){throw Adb(new jib)} + function Hh(){throw Adb(new jib)} + function Xi(){throw Adb(new jib)} + function Xj(){throw Adb(new jib)} + function Yj(){throw Adb(new jib)} + function Qz(){Qz=geb;!!(fA(),eA);} + function Qhb(){reb.call(this,'');} + function Rhb(){reb.call(this,'');} + function bib(){reb.call(this,'');} + function cib(){reb.call(this,'');} + function eib(a){veb.call(this,a);} + function xeb(a){veb.call(this,a);} + function Vgb(a){agb.call(this,a);} + function Lqb(a){xpb.call(this,a);} + function Sqb(a){Lqb.call(this,a);} + function irb(a){Upb.call(this,a);} + function pc(a){qc.call(this,a,0);} + function Ri(){Si.call(this,12,3);} + function WC(a,b){return xfb(a,b)} + function cFb(a,b){return dD(a,b)} + function Reb(a,b){return a.a-b.a} + function afb(a,b){return a.a-b.a} + function Wgb(a,b){return a.a-b.a} + function pC(b,a){return a in b.a} + function Vvb(a){return a.a?a.b:0} + function cwb(a){return a.a?a.b:0} + function Fxb(a,b,c){b.Cd(a.a[c]);} + function Kxb(a,b,c){b.Pe(a.a[c]);} + function uKb(a,b){a.b=new sjd(b);} + function QGb(a,b){a.b=b;return a} + function RGb(a,b){a.c=b;return a} + function SGb(a,b){a.f=b;return a} + function TGb(a,b){a.g=b;return a} + function yJb(a,b){a.a=b;return a} + function zJb(a,b){a.f=b;return a} + function AJb(a,b){a.k=b;return a} + function WNb(a,b){a.a=b;return a} + function XNb(a,b){a.e=b;return a} + function BYb(a,b){a.e=b;return a} + function CYb(a,b){a.f=b;return a} + function BRb(a,b){a.b=true;a.d=b;} + function WNc(a,b){return a.b-b.b} + function KSc(a,b){return a.g-b.g} + function pmc(a,b){return a?0:b-1} + function qKc(a,b){return a?0:b-1} + function pKc(a,b){return a?b-1:0} + function uVc(a,b){return a.s-b.s} + function Xed(a,b){return b.rg(a)} + function Xfd(a,b){a.b=b;return a} + function Wfd(a,b){a.a=b;return a} + function Yfd(a,b){a.c=b;return a} + function Zfd(a,b){a.d=b;return a} + function $fd(a,b){a.e=b;return a} + function _fd(a,b){a.f=b;return a} + function mgd(a,b){a.a=b;return a} + function ngd(a,b){a.b=b;return a} + function ogd(a,b){a.c=b;return a} + function Khd(a,b){a.c=b;return a} + function Jhd(a,b){a.b=b;return a} + function Lhd(a,b){a.d=b;return a} + function Mhd(a,b){a.e=b;return a} + function Nhd(a,b){a.f=b;return a} + function Ohd(a,b){a.g=b;return a} + function Phd(a,b){a.a=b;return a} + function Qhd(a,b){a.i=b;return a} + function Rhd(a,b){a.j=b;return a} + function coc(a,b){Mnc();P3b(b,a);} + function bbd(a,b,c){_ad(a.a,b,c);} + function Fjd(a){Zub.call(this,a);} + function TRb(a){SRb.call(this,a);} + function pLc(a){CIc.call(this,a);} + function ILc(a){CIc.call(this,a);} + function gLd(a){ZHd.call(this,a);} + function DPd(a){xPd.call(this,a);} + function FPd(a){xPd.call(this,a);} + function x2b(){y2b.call(this,'');} + function pjd(){this.a=0;this.b=0;} + function ATc(){this.b=0;this.a=0;} + function lXd(a,b){a.b=0;bWd(a,b);} + function Kqd(a,b){a.k=b;return a} + function Lqd(a,b){a.j=b;return a} + function vfe(a,b){a.c=b;a.b=true;} + function Etb(){Etb=geb;Dtb=Gtb();} + function bvd(){bvd=geb;avd=OAd();} + function dvd(){dvd=geb;cvd=aCd();} + function MId(){MId=geb;LId=ygd();} + function jTd(){jTd=geb;iTd=Qae();} + function Ole(){Ole=geb;Nle=vne();} + function Qle(){Qle=geb;Ple=Cne();} + function mfb(a){return a.e&&a.e()} + function FD(a){return a.l|a.m<<22} + function Oc(a,b){return a.c._b(b)} + function En(a,b){return Wv(a.b,b)} + function Vd(a){return !a?null:a.d} + function Vv(a){return !a?null:a.g} + function $v(a){return !a?null:a.i} + function nfb(a){lfb(a);return a.o} + function Khb(a,b){a.a+=b;return a} + function Lhb(a,b){a.a+=b;return a} + function Ohb(a,b){a.a+=b;return a} + function Uhb(a,b){a.a+=b;return a} + function _wb(a,b){while(a.Bd(b));} + function atb(a){this.a=new Usb(a);} + function $tb(){throw Adb(new jib)} + function qpb(){throw Adb(new jib)} + function rpb(){throw Adb(new jib)} + function spb(){throw Adb(new jib)} + function vpb(){throw Adb(new jib)} + function Opb(){throw Adb(new jib)} + function yAb(a){this.a=new ezb(a);} + function H2c(){this.a=new Wed(s0);} + function TVc(){this.b=new Wed(H$);} + function l6c(){this.a=new Wed(V0);} + function $ad(){this.b=new Wed(I1);} + function nbd(){this.b=new Wed(I1);} + function T2c(a){this.a=0;this.b=a;} + function Bib(a){tib();vib(this,a);} + function QDb(a){LCb(a);return a.a} + function dvb(a){return a.b!=a.d.c} + function AMc(a,b){return a.d[b.p]} + function ued(a,b){return ned(a,b)} + function $Eb(a,b,c){a.splice(b,c);} + function ixb(a,b){while(a.Re(b));} + function NKb(a){a.c?MKb(a):OKb(a);} + function mQd(){throw Adb(new jib)} + function nQd(){throw Adb(new jib)} + function oQd(){throw Adb(new jib)} + function pQd(){throw Adb(new jib)} + function qQd(){throw Adb(new jib)} + function rQd(){throw Adb(new jib)} + function sQd(){throw Adb(new jib)} + function tQd(){throw Adb(new jib)} + function uQd(){throw Adb(new jib)} + function vQd(){throw Adb(new jib)} + function zue(){throw Adb(new Dvb)} + function Aue(){throw Adb(new Dvb)} + function oue(a){this.a=new Dte(a);} + function Dte(a){Cte(this,a,sse());} + function cve(a){return !a||bve(a)} + function Cqe(a){return xqe[a]!=-1} + function Yz(){Nz!=0&&(Nz=0);Pz=-1;} + function beb(){_db==null&&(_db=[]);} + function eg(a,b){zf.call(this,a,b);} + function gg(a,b){eg.call(this,a,b);} + function Nj(a,b){this.a=a;this.b=b;} + function hk(a,b){this.a=a;this.b=b;} + function nk(a,b){this.a=a;this.b=b;} + function pk(a,b){this.a=a;this.b=b;} + function xk(a,b){this.a=a;this.b=b;} + function zk(a,b){this.a=a;this.b=b;} + function Kk(a,b){this.a=a;this.b=b;} + function ne(a,b){this.e=a;this.d=b;} + function Hf(a,b){this.b=a;this.c=b;} + function cp(a,b){this.b=a;this.a=b;} + function Cp(a,b){this.b=a;this.a=b;} + function qr(a,b){this.b=a;this.a=b;} + function Rr(a,b){this.b=a;this.a=b;} + function vr(a,b){this.a=a;this.b=b;} + function su(a,b){this.a=a;this.b=b;} + function Hu(a,b){this.a=a;this.f=b;} + function gp(a,b){this.g=a;this.i=b;} + function qs(a,b){this.f=a;this.g=b;} + function Gv(a,b){this.b=a;this.c=b;} + function Wc(a){Lb(a.dc());this.c=a;} + function Ex(a,b){this.a=a;this.b=b;} + function ey(a,b){this.a=a;this.b=b;} + function pv(a){this.a=RD(Qb(a),15);} + function uv(a){this.a=RD(Qb(a),15);} + function nw(a){this.a=RD(Qb(a),85);} + function rf(a){this.b=RD(Qb(a),85);} + function Tr(a){this.b=RD(Qb(a),51);} + function uB(){this.q=new $wnd.Date;} + function CC(a,b){this.a=a;this.b=b;} + function Bt(a,b){return Ujb(a.b,b)} + function tpb(a,b){return a.b.Hc(b)} + function upb(a,b){return a.b.Ic(b)} + function wpb(a,b){return a.b.Qc(b)} + function Pqb(a,b){return a.b.Hc(b)} + function pqb(a,b){return a.c.uc(b)} + function rqb(a,b){return pb(a.c,b)} + function Zsb(a,b){return a.a._b(b)} + function Xp(a,b){return a>b&&b0} + function Ldb(a,b){return Ddb(a,b)<0} + function Urb(a,b){return Bsb(a.a,b)} + function Beb(a,b){oz.call(this,a,b);} + function Qx(a){Px();ho.call(this,a);} + function Lnb(a,b){Pnb(a,a.length,b);} + function Mnb(a,b){Rnb(a,a.length,b);} + function Ktb(a,b){return a.a.get(b)} + function bub(a,b){return Ujb(a.e,b)} + function Zxb(a){return uFb(a),false} + function zw(a){this.a=RD(Qb(a),229);} + function $wb(a){Swb.call(this,a,21);} + function dAb(a,b){qs.call(this,a,b);} + function yBb(a,b){qs.call(this,a,b);} + function ssb(a,b){this.b=a;this.a=b;} + function xlb(a,b){this.d=a;this.e=b;} + function jEb(a,b){this.a=a;this.b=b;} + function pEb(a,b){this.a=a;this.b=b;} + function vEb(a,b){this.a=a;this.b=b;} + function BEb(a,b){this.a=a;this.b=b;} + function TFb(a,b){this.a=a;this.b=b;} + function QEb(a,b){this.b=a;this.a=b;} + function sHb(a,b){this.b=a;this.a=b;} + function EHb(a,b){qs.call(this,a,b);} + function MHb(a,b){qs.call(this,a,b);} + function jIb(a,b){qs.call(this,a,b);} + function $Jb(a,b){qs.call(this,a,b);} + function FKb(a,b){qs.call(this,a,b);} + function wLb(a,b){qs.call(this,a,b);} + function nOb(a,b){qs.call(this,a,b);} + function kPb(a,b){this.b=a;this.a=b;} + function JPb(a,b){qs.call(this,a,b);} + function fRb(a,b){this.b=a;this.a=b;} + function JRb(a,b){qs.call(this,a,b);} + function OTb(a,b){this.b=a;this.a=b;} + function UUb(a,b){qs.call(this,a,b);} + function BWb(a,b){qs.call(this,a,b);} + function tXb(a,b){qs.call(this,a,b);} + function XEb(a,b,c){a.splice(b,0,c);} + function pr(a,b,c){a.Mb(c)&&b.Cd(c);} + function lEb(a,b,c){b.Pe(a.a.Ye(c));} + function rEb(a,b,c){b.Dd(a.a.Ze(c));} + function xEb(a,b,c){b.Cd(a.a.Kb(c));} + function eYb(a,b){return Csb(a.c,b)} + function cGb(a,b){return Csb(a.e,b)} + function qZb(a,b){qs.call(this,a,b);} + function V$b(a,b){qs.call(this,a,b);} + function s3b(a,b){qs.call(this,a,b);} + function Q8b(a,b){qs.call(this,a,b);} + function icc(a,b){qs.call(this,a,b);} + function xec(a,b){qs.call(this,a,b);} + function gic(a,b){this.a=a;this.b=b;} + function Xic(a,b){this.a=a;this.b=b;} + function h4b(a,b){this.a=a;this.b=b;} + function vjc(a,b){this.a=a;this.b=b;} + function xjc(a,b){this.a=a;this.b=b;} + function Hjc(a,b){this.a=a;this.b=b;} + function hjc(a,b){this.b=a;this.a=b;} + function Jjc(a,b){this.b=a;this.a=b;} + function _Yb(a,b){this.b=a;this.a=b;} + function eZb(a,b){this.c=a;this.d=b;} + function Q1b(a,b){this.e=a;this.d=b;} + function Tjc(a,b){this.a=a;this.b=b;} + function ulc(a,b){this.a=a;this.b=b;} + function Elc(a,b){this.a=a;this.b=b;} + function fqc(a,b){this.b=a;this.a=b;} + function smc(a,b){this.b=b;this.c=a;} + function fnc(a,b){qs.call(this,a,b);} + function Cnc(a,b){qs.call(this,a,b);} + function koc(a,b){qs.call(this,a,b);} + function ktc(a,b){qs.call(this,a,b);} + function ctc(a,b){qs.call(this,a,b);} + function utc(a,b){qs.call(this,a,b);} + function Ftc(a,b){qs.call(this,a,b);} + function Rtc(a,b){qs.call(this,a,b);} + function _tc(a,b){qs.call(this,a,b);} + function iuc(a,b){qs.call(this,a,b);} + function vuc(a,b){qs.call(this,a,b);} + function Duc(a,b){qs.call(this,a,b);} + function Puc(a,b){qs.call(this,a,b);} + function _uc(a,b){qs.call(this,a,b);} + function pvc(a,b){qs.call(this,a,b);} + function yvc(a,b){qs.call(this,a,b);} + function Hvc(a,b){qs.call(this,a,b);} + function Pvc(a,b){qs.call(this,a,b);} + function dxc(a,b){qs.call(this,a,b);} + function bDc(a,b){qs.call(this,a,b);} + function nDc(a,b){qs.call(this,a,b);} + function yDc(a,b){qs.call(this,a,b);} + function LDc(a,b){qs.call(this,a,b);} + function bEc(a,b){qs.call(this,a,b);} + function lEc(a,b){qs.call(this,a,b);} + function tEc(a,b){qs.call(this,a,b);} + function CEc(a,b){qs.call(this,a,b);} + function LEc(a,b){qs.call(this,a,b);} + function UEc(a,b){qs.call(this,a,b);} + function mFc(a,b){qs.call(this,a,b);} + function vFc(a,b){qs.call(this,a,b);} + function EFc(a,b){qs.call(this,a,b);} + function SKc(a,b){qs.call(this,a,b);} + function cNc(a,b){this.b=a;this.a=b;} + function tNc(a,b){qs.call(this,a,b);} + function QOc(a,b){this.a=a;this.b=b;} + function ePc(a,b){this.a=a;this.b=b;} + function LPc(a,b){this.a=a;this.b=b;} + function xQc(a,b){qs.call(this,a,b);} + function FQc(a,b){qs.call(this,a,b);} + function MQc(a,b){this.a=a;this.b=b;} + function FMc(a,b){dMc();return b!=a} + function Uvb(a){sFb(a.a);return a.b} + function qYb(a){rYb(a,a.c);return a} + function Itb(){Etb();return new Dtb} + function _ec(){Rec();this.a=new e6b;} + function lSc(){dSc();this.a=new _sb;} + function aRc(){WQc();this.b=new _sb;} + function xRc(a,b){this.b=a;this.d=b;} + function nVc(a,b){this.a=a;this.b=b;} + function pVc(a,b){this.a=a;this.b=b;} + function GWc(a,b){this.a=a;this.b=b;} + function IXc(a,b){this.b=a;this.a=b;} + function gTc(a,b){qs.call(this,a,b);} + function eVc(a,b){qs.call(this,a,b);} + function $Vc(a,b){qs.call(this,a,b);} + function XYc(a,b){qs.call(this,a,b);} + function MZc(a,b){qs.call(this,a,b);} + function t_c(a,b){qs.call(this,a,b);} + function B_c(a,b){qs.call(this,a,b);} + function z2c(a,b){qs.call(this,a,b);} + function h3c(a,b){qs.call(this,a,b);} + function $3c(a,b){qs.call(this,a,b);} + function i4c(a,b){qs.call(this,a,b);} + function l5c(a,b){qs.call(this,a,b);} + function v5c(a,b){qs.call(this,a,b);} + function g6c(a,b){qs.call(this,a,b);} + function A6c(a,b){qs.call(this,a,b);} + function a7c(a,b){qs.call(this,a,b);} + function B8c(a,b){qs.call(this,a,b);} + function d9c(a,b){qs.call(this,a,b);} + function D9c(a,b){qs.call(this,a,b);} + function tad(a,b){qs.call(this,a,b);} + function hbd(a,b){qs.call(this,a,b);} + function Nbd(a,b){qs.call(this,a,b);} + function Ybd(a,b){qs.call(this,a,b);} + function ndd(a,b){qs.call(this,a,b);} + function z1c(a,b){this.b=a;this.a=b;} + function B1c(a,b){this.b=a;this.a=b;} + function d2c(a,b){this.b=a;this.a=b;} + function f2c(a,b){this.b=a;this.a=b;} + function m9c(a,b){this.a=a;this.b=b;} + function xed(a,b){this.a=a;this.b=b;} + function ffd(a,b){this.a=a;this.b=b;} + function rjd(a,b){this.a=a;this.b=b;} + function Sjd(a,b){qs.call(this,a,b);} + function Zhd(a,b){qs.call(this,a,b);} + function lid(a,b){qs.call(this,a,b);} + function vkd(a,b){qs.call(this,a,b);} + function Gmd(a,b){qs.call(this,a,b);} + function Pmd(a,b){qs.call(this,a,b);} + function Zmd(a,b){qs.call(this,a,b);} + function jnd(a,b){qs.call(this,a,b);} + function Gnd(a,b){qs.call(this,a,b);} + function Rnd(a,b){qs.call(this,a,b);} + function eod(a,b){qs.call(this,a,b);} + function qod(a,b){qs.call(this,a,b);} + function Eod(a,b){qs.call(this,a,b);} + function Qod(a,b){qs.call(this,a,b);} + function upd(a,b){qs.call(this,a,b);} + function Rpd(a,b){qs.call(this,a,b);} + function eqd(a,b){qs.call(this,a,b);} + function nqd(a,b){qs.call(this,a,b);} + function vqd(a,b){qs.call(this,a,b);} + function Hrd(a,b){qs.call(this,a,b);} + function esd(a,b){this.a=a;this.b=b;} + function gsd(a,b){this.a=a;this.b=b;} + function isd(a,b){this.a=a;this.b=b;} + function Osd(a,b){this.a=a;this.b=b;} + function Qsd(a,b){this.a=a;this.b=b;} + function Ssd(a,b){this.a=a;this.b=b;} + function Ptd(a,b){this.a=a;this.b=b;} + function JEd(a,b){this.a=a;this.b=b;} + function KEd(a,b){this.a=a;this.b=b;} + function MEd(a,b){this.a=a;this.b=b;} + function NEd(a,b){this.a=a;this.b=b;} + function QEd(a,b){this.a=a;this.b=b;} + function REd(a,b){this.a=a;this.b=b;} + function SEd(a,b){this.b=a;this.a=b;} + function TEd(a,b){this.b=a;this.a=b;} + function bFd(a,b){this.b=a;this.a=b;} + function dFd(a,b){this.b=a;this.a=b;} + function fFd(a,b){this.a=a;this.b=b;} + function hFd(a,b){this.a=a;this.b=b;} + function utd(a,b){qs.call(this,a,b);} + function sFd(a,b){this.a=a;this.b=b;} + function uFd(a,b){this.a=a;this.b=b;} + function bGd(a,b){qs.call(this,a,b);} + function uId(a,b){this.f=a;this.c=b;} + function Ofd(a,b){return Csb(a.g,b)} + function Tqc(a,b){return Csb(b.b,a)} + function HPd(a,b){return QNd(a.a,b)} + function Idd(a,b){return -a.b.af(b)} + function IId(a,b){!!a&&Zjb(CId,a,b);} + function yWd(a,b){a.i=null;zWd(a,b);} + function kEd(a,b,c){pDd(b,KDd(a,c));} + function lEd(a,b,c){pDd(b,KDd(a,c));} + function mFd(a,b){vEd(a.a,RD(b,58));} + function _Mc(a,b){GMc(a.a,RD(b,12));} + function KTd(a,b){this.a=a;this.b=b;} + function NTd(a,b){this.a=a;this.b=b;} + function B5d(a,b){this.a=a;this.b=b;} + function Z6d(a,b){this.a=a;this.b=b;} + function Ble(a,b){this.a=a;this.b=b;} + function afe(a,b){this.d=a;this.b=b;} + function wfe(a,b){this.e=a;this.a=b;} + function Eke(a,b){this.b=a;this.c=b;} + function zNd(a,b){this.i=a;this.g=b;} + function kZd(a,b){this.d=a;this.e=b;} + function ave(a,b){eve(new dMd(a),b);} + function Dke(a){return pge(a.c,a.b)} + function Wd(a){return !a?null:a.md()} + function dE(a){return a==null?null:a} + function bE(a){return typeof a===jve} + function $D(a){return typeof a===hve} + function _D(a){return typeof a===ive} + function Gdb(a,b){return Ddb(a,b)==0} + function Jdb(a,b){return Ddb(a,b)>=0} + function Pdb(a,b){return Ddb(a,b)!=0} + function ar(a,b){return zr(a.Kc(),b)} + function Qm(a,b){return a.Rd().Xb(b)} + function kg(a){ig(a);return a.d.gc()} + function fE(a){CFb(a==null);return a} + function Mhb(a,b){a.a+=''+b;return a} + function Nhb(a,b){a.a+=''+b;return a} + function Whb(a,b){a.a+=''+b;return a} + function Yhb(a,b){a.a+=''+b;return a} + function Zhb(a,b){a.a+=''+b;return a} + function Vhb(a,b){return a.a+=''+b,a} + function Pfb(a){return ''+(uFb(a),a)} + function Vsb(a){akb(this);Ld(this,a);} + function YFc(){RFc();UFc.call(this);} + function pxb(a,b){kxb.call(this,a,b);} + function txb(a,b){kxb.call(this,a,b);} + function xxb(a,b){kxb.call(this,a,b);} + function Oub(a,b){Pub(a,b,a.c.b,a.c);} + function Nub(a,b){Pub(a,b,a.a,a.a.a);} + function Iob(a){tFb(a,0);return null} + function Xvb(){this.b=0;this.a=false;} + function dwb(){this.b=0;this.a=false;} + function Et(){this.b=new Usb(Sv(12));} + function pMb(){pMb=geb;oMb=ss(nMb());} + function ncc(){ncc=geb;mcc=ss(lcc());} + function aZc(){aZc=geb;_Yc=ss($Yc());} + function WA(){WA=geb;vA();VA=new Tsb;} + function hjd(a){a.a=0;a.b=0;return a} + function qfd(a,b){a.a=b.g+1;return a} + function yNd(a,b){aMd.call(this,a,b);} + function lGd(a,b){kGd.call(this,a,b);} + function N$d(a,b){zNd.call(this,a,b);} + function Whe(a,b){Q2d.call(this,a,b);} + function She(a,b){Phe.call(this,a,b);} + function RRd(a,b){PRd();Zjb(ORd,a,b);} + function sB(a,b){a.q.setTime(Xdb(b));} + function Xz(a){$wnd.clearTimeout(a);} + function cr(a){return Qb(a),new Dl(a)} + function mb(a,b){return dE(a)===dE(b)} + function Mw(a,b){return a.a.a.a.cc(b)} + function qeb(a,b){return zhb(a.a,0,b)} + function SSb(a){return MSb(RD(a,74))} + function Nfb(a){return eE((uFb(a),a))} + function Ofb(a){return eE((uFb(a),a))} + function gD(a){return hD(a.l,a.m,a.h)} + function egb(a,b){return hgb(a.a,b.a)} + function ygb(a,b){return Agb(a.a,b.a)} + function Sfb(a,b){return Qfb(a.a,b.a)} + function qhb(a,b){return a.indexOf(b)} + function nOc(a,b){return a.j[b.p]==2} + function cz(a,b){return a==b?0:a?1:-1} + function AB(a){return a<10?'0'+a:''+a} + function Kdb(a){return typeof a===ive} + function oZb(a){return a==jZb||a==mZb} + function pZb(a){return a==jZb||a==kZb} + function ELb(a,b){return hgb(a.g,b.g)} + function Q4b(a){return Wmb(a.b.b,a,0)} + function Q2b(){J2b.call(this,0,0,0,0);} + function Iub(){ctb.call(this,new gub);} + function Znb(a,b){Wnb(a,0,a.length,b);} + function Eyb(a,b){Rmb(a.a,b);return b} + function Fkc(a,b){lkc();return b.a+=a} + function Hkc(a,b){lkc();return b.a+=a} + function Gkc(a,b){lkc();return b.c+=a} + function ied(a,b){Rmb(a.c,b);return a} + function Ped(a,b){ofd(a.a,b);return a} + function ttb(a){this.a=Itb();this.b=a;} + function Ntb(a){this.a=Itb();this.b=a;} + function sjd(a){this.a=a.a;this.b=a.b;} + function Dl(a){this.a=a;zl.call(this);} + function Gl(a){this.a=a;zl.call(this);} + function Tid(){Uid.call(this,0,0,0,0);} + function vfd(a){return ofd(new ufd,a)} + function Ksd(a){return iyd(RD(a,123))} + function Mvd(a){return a.vh()&&a.wh()} + function Dod(a){return a!=zod&&a!=Aod} + function Dmd(a){return a==ymd||a==zmd} + function Emd(a){return a==Bmd||a==xmd} + function xDc(a){return a==tDc||a==sDc} + function yrc(a,b){return hgb(a.g,b.g)} + function Yfe(a,b){return new Phe(b,a)} + function Zfe(a,b){return new Phe(b,a)} + function lr(a){return Dr(a.b.Kc(),a.a)} + function IXd(a,b){yXd(a,b);zXd(a,a.D);} + function Uxd(a,b,c){Vxd(a,b);Wxd(a,c);} + function zyd(a,b,c){Cyd(a,b);Ayd(a,c);} + function Byd(a,b,c){Dyd(a,b);Eyd(a,c);} + function Gzd(a,b,c){Hzd(a,b);Izd(a,c);} + function Nzd(a,b,c){Ozd(a,b);Pzd(a,c);} + function eh(a,b,c){bh.call(this,a,b,c);} + function zId(a){uId.call(this,a,true);} + function nAb(){dAb.call(this,'Tail',3);} + function iAb(){dAb.call(this,'Head',1);} + function ejb(a){Pib();fjb.call(this,a);} + function A3b(a){J2b.call(this,a,a,a,a);} + function Pmb(a){a.c=$C(jJ,rve,1,0,5,1);} + function yRb(a){a.b&&CRb(a);return a.a} + function zRb(a){a.b&&CRb(a);return a.c} + function mBb(a,b){if(dBb){return}a.b=b;} + function YCb(a,b){return a[a.length]=b} + function _Cb(a,b){return a[a.length]=b} + function l5b(a,b){return NGd(b,MCd(a))} + function m5b(a,b){return NGd(b,MCd(a))} + function DDd(a,b){return lp(Co(a.d),b)} + function EDd(a,b){return lp(Co(a.g),b)} + function FDd(a,b){return lp(Co(a.j),b)} + function mGd(a,b){kGd.call(this,a.b,b);} + function s0d(a,b){WGd(tYd(a.a),v0d(b));} + function B4d(a,b){WGd(o4d(a.a),E4d(b));} + function Asd(a,b,c){Byd(c,c.i+a,c.j+b);} + function eFc(a,b,c){bD(a.c[b.g],b.g,c);} + function zVd(a,b,c){RD(a.c,71).Gi(b,c);} + function LMd(a,b,c){bD(a,b,c);return c} + function DJb(a){Umb(a.Sf(),new HJb(a));} + function Gvb(a){return a!=null?tb(a):0} + function aOd(a){return a==null?0:tb(a)} + function iue(a){Vse();Wse.call(this,a);} + function Ug(a){this.a=a;Og.call(this,a);} + function Zy(){Zy=geb;$wnd.Math.log(2);} + function s7d(){s7d=geb;r7d=($Sd(),ZSd);} + function FRc(){FRc=geb;ERc=new Zrb(u3);} + function Hde(){Hde=geb;new Ide;new bnb;} + function Ide(){new Tsb;new Tsb;new Tsb;} + function yue(){throw Adb(new kib(bMe))} + function Nue(){throw Adb(new kib(bMe))} + function Bue(){throw Adb(new kib(cMe))} + function Que(){throw Adb(new kib(cMe))} + function Gp(a){this.a=a;rf.call(this,a);} + function Np(a){this.a=a;rf.call(this,a);} + function Sq(a,b){tm();this.a=a;this.b=b;} + function Jh(a,b){Qb(b);Ih(a).Jc(new jx);} + function _mb(a,b){Ynb(a.c,a.c.length,b);} + function xnb(a){return a.ab?1:0} + function Kgb(a,b){return Ddb(a,b)>0?a:b} + function hD(a,b,c){return {l:a,m:b,h:c}} + function Mvb(a,b){a.a!=null&&_Mc(b,a.a);} + function Lhc(a){Y0b(a,null);Z0b(a,null);} + function xkc(a,b,c){return Zjb(a.g,c,b)} + function bFc(a,b,c){return _Ec(b,c,a.c)} + function jOc(a,b,c){return Zjb(a.k,c,b)} + function pOc(a,b,c){qOc(a,b,c);return c} + function FOc(a,b){dOc();return b.n.b+=a} + function lUb(a){VTb.call(this);this.b=a;} + function y2b(a){v2b.call(this);this.a=a;} + function kAb(){dAb.call(this,'Range',2);} + function $Fb(a){this.b=a;this.a=new bnb;} + function WQb(a){this.b=new gRb;this.a=a;} + function Lub(a){a.a=new svb;a.c=new svb;} + function nrc(a){a.a=new Tsb;a.d=new Tsb;} + function $Sc(a){_Sc(a,null);aTc(a,null);} + function a2d(a,b){return xA(a.a,b,null)} + function Cdd(a,b){return Zjb(a.a,b.a,b)} + function ajd(a){return new rjd(a.a,a.b)} + function Pid(a){return new rjd(a.c,a.d)} + function Qid(a){return new rjd(a.c,a.d)} + function Ake(a,b){return Tfe(a.c,a.b,b)} + function ZD(a,b){return a!=null&&QD(a,b)} + function br(a,b){return Jr(a.Kc(),b)!=-1} + function Hr(a){return a.Ob()?a.Pb():null} + function _p(a){this.b=(yob(),new uqb(a));} + function zke(a){this.a=a;Tsb.call(this);} + function Uhe(){Q2d.call(this,null,null);} + function Yhe(){p3d.call(this,null,null);} + function As(){qs.call(this,'INSTANCE',0);} + function dXb(){_Wb();this.a=new Wed(UP);} + function Hhb(a){return Ihb(a,0,a.length)} + function Rv(a,b){return new ew(a.Kc(),b)} + function $sb(a,b){return a.a.Bc(b)!=null} + function hZd(a,b){sLd(a);a.Gc(RD(b,15));} + function ONd(a,b,c){a.c.bd(b,RD(c,136));} + function eOd(a,b,c){a.c.Ui(b,RD(c,136));} + function eub(a,b){if(a.c){rub(b);qub(b);}} + function oB(a,b){a.q.setHours(b);mB(a,b);} + function vTb(a,b){Zid(b,a.a.a.a,a.a.a.b);} + function tKb(a,b,c,d){bD(a.a[b.g],c.g,d);} + function oKb(a,b,c){return a.a[b.g][c.g]} + function AIc(a,b){return a.e[b.c.p][b.p]} + function TIc(a,b){return a.c[b.c.p][b.p]} + function pJc(a,b){return a.a[b.c.p][b.p]} + function mOc(a,b){return a.j[b.p]=AOc(b)} + function wAb(a,b){return a.a.Bc(b)!=null} + function wXc(a,b){return Kfb(UD(b.a))<=a} + function xXc(a,b){return Kfb(UD(b.a))>=a} + function vhd(a,b){return jhb(a.f,b.Pg())} + function cjd(a,b){return a.a*b.a+a.b*b.b} + function Wsd(a,b){return a.a0?b/(a*a):b*100} + function FUb(a,b){return a>0?b*b/a:b*b*100} + function $5b(a,b){return RD(cub(a.a,b),34)} + function doc(a,b){Mnc();return Rc(a,b.e,b)} + function NCc(a,b,c){GCc();return c.Mg(a,b)} + function L0c(a){B0c();return a.e.a+a.f.a/2} + function N0c(a,b,c){B0c();return c.e.a-a*b} + function V0c(a){B0c();return a.e.b+a.f.b/2} + function X0c(a,b,c){B0c();return c.e.b-a*b} + function _tb(a){a.d=new tub(a);a.e=new Tsb;} + function x3c(){this.a=new Tp;this.b=new Tp;} + function hmc(a){this.c=a;this.a=1;this.b=1;} + function C$b(a){z$b();A$b(this);this.Ff(a);} + function Efd(a,b,c){Afd();a.pf(b)&&c.Cd(a);} + function Red(a,b,c){return Rmb(b,Ted(a,c))} + function Zid(a,b,c){a.a+=b;a.b+=c;return a} + function jjd(a,b,c){a.a*=b;a.b*=c;return a} + function mjd(a,b){a.a=b.a;a.b=b.b;return a} + function fjd(a){a.a=-a.a;a.b=-a.b;return a} + function njd(a,b,c){a.a-=b;a.b-=c;return a} + function Gjd(a){Yub.call(this);zjd(this,a);} + function Dbd(){qs.call(this,'GROW_TREE',0);} + function WRb(){qs.call(this,'POLYOMINO',0);} + function SVd(a,b,c){DVd.call(this,a,b,c,2);} + function r0d(a,b,c){VGd(tYd(a.a),b,v0d(c));} + function e3d(a,b){N2d();Q2d.call(this,a,b);} + function D3d(a,b){j3d();p3d.call(this,a,b);} + function F3d(a,b){j3d();D3d.call(this,a,b);} + function H3d(a,b){j3d();p3d.call(this,a,b);} + function PNd(a,b){return a.c.Fc(RD(b,136))} + function A4d(a,b,c){VGd(o4d(a.a),b,E4d(c));} + function Ard(a){this.c=a;Dyd(a,0);Eyd(a,0);} + function Z8d(a,b){s7d();N8d.call(this,a,b);} + function _8d(a,b){s7d();Z8d.call(this,a,b);} + function b9d(a,b){s7d();Z8d.call(this,a,b);} + function n9d(a,b){s7d();N8d.call(this,a,b);} + function d9d(a,b){s7d();b9d.call(this,a,b);} + function p9d(a,b){s7d();n9d.call(this,a,b);} + function v9d(a,b){s7d();N8d.call(this,a,b);} + function lge(a,b,c){return b.zl(a.e,a.c,c)} + function nge(a,b,c){return b.Al(a.e,a.c,c)} + function Wee(a,b,c){return tfe(Pee(a,b),c)} + function Age(a,b){return Vvd(a.e,RD(b,54))} + function _me(a){return a==null?null:Bqe(a)} + function dne(a){return a==null?null:Iqe(a)} + function gne(a){return a==null?null:jeb(a)} + function hne(a){return a==null?null:jeb(a)} + function TD(a){CFb(a==null||$D(a));return a} + function UD(a){CFb(a==null||_D(a));return a} + function WD(a){CFb(a==null||bE(a));return a} + function lfb(a){if(a.o!=null){return}Bfb(a);} + function lFb(a){if(!a){throw Adb(new _fb)}} + function pFb(a){if(!a){throw Adb(new yeb)}} + function sFb(a){if(!a){throw Adb(new Dvb)}} + function yFb(a){if(!a){throw Adb(new cgb)}} + function zmb(a){if(!a){throw Adb(new Jrb)}} + function jQd(){jQd=geb;iQd=new LQd;new lRd;} + function u2c(){u2c=geb;t2c=new jGd('root');} + function d6d(){HWd.call(this);this.Bb|=txe;} + function Pg(a,b){this.d=a;Lg(this);this.b=b;} + function WCb(a,b){NCb.call(this,a);this.a=b;} + function oDb(a,b){NCb.call(this,a);this.a=b;} + function bh(a,b,c){lg.call(this,a,b,c,null);} + function fh(a,b,c){lg.call(this,a,b,c,null);} + function Mf(a,b){this.c=a;ne.call(this,a,b);} + function Uf(a,b){this.a=a;Mf.call(this,a,b);} + function wB(a){this.q=new $wnd.Date(Xdb(a));} + function OPb(a){if(a>8){return 0}return a+1} + function iBb(a,b){if(dBb){return}Rmb(a.a,b);} + function P5b(a,b){H5b();return n2b(b.d.i,a)} + function qdc(a,b){Zcc();return new xdc(b,a)} + function HAb(a,b,c){return a.Ne(b,c)<=0?c:b} + function IAb(a,b,c){return a.Ne(b,c)<=0?b:c} + function rgd(a,b){return RD(cub(a.b,b),143)} + function tgd(a,b){return RD(cub(a.c,b),233)} + function amc(a){return RD(Vmb(a.a,a.b),294)} + function Mid(a){return new rjd(a.c,a.d+a.a)} + function Jeb(a){return (uFb(a),a)?1231:1237} + function EPc(a){return dOc(),xDc(RD(a,203))} + function RMb(){RMb=geb;QMb=xsb((Qpd(),Ppd));} + function YQb(a,b){b.a?ZQb(a,b):wAb(a.a,b.b);} + function aJd(a,b,c){++a.j;a.tj();$Gd(a,b,c);} + function $Id(a,b,c){++a.j;a.qj(b,a.Zi(b,c));} + function B2d(a,b,c){var d;d=a.fd(b);d.Rb(c);} + function Bzd(a,b,c){c=xvd(a,b,6,c);return c} + function izd(a,b,c){c=xvd(a,b,3,c);return c} + function KCd(a,b,c){c=xvd(a,b,9,c);return c} + function SKb(a,b){Ivb(b,Pye);a.f=b;return a} + function bOd(a,b){return (b&lve)%a.d.length} + function Bke(a,b,c){return age(a.c,a.b,b,c)} + function ZLd(a,b){this.c=a;ZHd.call(this,b);} + function w0d(a,b){this.a=a;Q_d.call(this,b);} + function F4d(a,b){this.a=a;Q_d.call(this,b);} + function kGd(a,b){jGd.call(this,a);this.a=b;} + function U6d(a,b){L6d.call(this,a);this.a=b;} + function S9d(a,b){L6d.call(this,a);this.a=b;} + function jQb(a){gQb.call(this,0,0);this.f=a;} + function _hb(a,b,c){a.a+=Ihb(b,0,c);return a} + function _A(a){!a.a&&(a.a=new jB);return a.a} + function qlb(a,b){var c;c=a.e;a.e=b;return c} + function Clb(a,b){var c;c=b;return !!a.Fe(c)} + function Keb(a,b){Geb();return a==b?0:a?1:-1} + function Ikb(a,b){a.a.bd(a.b,b);++a.b;a.c=-1;} + function hg(a){a.b?hg(a.b):a.f.c.zc(a.e,a.d);} + function aub(a){akb(a.e);a.d.b=a.d;a.d.a=a.d;} + function VDb(a,b,c){xDb();HEb(a,b.Ve(a.a,c));} + function Xrb(a,b,c){return Wrb(a,RD(b,22),c)} + function WEb(a,b){return cFb(new Array(b),a)} + function Fgb(a){return Ydb(Udb(a,32))^Ydb(a)} + function XD(a){return String.fromCharCode(a)} + function Dz(a){return a==null?null:a.message} + function Rz(a,b,c){return a.apply(b,c);} + function Btb(a,b){var c;c=a[Jxe];c.call(a,b);} + function Ctb(a,b){var c;c=a[Jxe];c.call(a,b);} + function O5b(a,b){H5b();return !n2b(b.d.i,a)} + function R2b(a,b,c,d){J2b.call(this,a,b,c,d);} + function TJb(){RJb.call(this);this.a=new pjd;} + function v2b(){this.n=new pjd;this.o=new pjd;} + function kGb(){this.b=new pjd;this.c=new bnb;} + function cUb(){this.a=new bnb;this.b=new bnb;} + function kWb(){this.a=new DTb;this.b=new vWb;} + function e6b(){this.b=new gub;this.a=new gub;} + function jIc(){this.b=new _sb;this.a=new _sb;} + function vYc(){this.b=new Tsb;this.a=new Tsb;} + function fWc(){this.b=new TVc;this.a=new IVc;} + function Yhc(){this.a=new yqc;this.b=new Sqc;} + function lNc(){this.a=new bnb;this.d=new bnb;} + function RJb(){this.n=new z3b;this.i=new Tid;} + function hq(a){this.a=(dk(a,iwe),new cnb(a));} + function oq(a){this.a=(dk(a,iwe),new cnb(a));} + function tLd(a){return a<100?null:new gLd(a)} + function Lac(a,b){return a.n.a=(uFb(b),b)+10} + function Mac(a,b){return a.n.a=(uFb(b),b)+10} + function DYd(a,b){return b==a||PHd(sYd(b),a)} + function nae(a,b){return Zjb(a.a,b,'')==null} + function Hee(a,b){var c;c=b.qi(a.a);return c} + function $id(a,b){a.a+=b.a;a.b+=b.b;return a} + function ojd(a,b){a.a-=b.a;a.b-=b.b;return a} + function sfd(a){aFb(a.j.c,0);a.a=-1;return a} + function rCd(a,b,c){c=xvd(a,b,11,c);return c} + function SDd(a,b,c){c!=null&&Kzd(b,uEd(a,c));} + function TDd(a,b,c){c!=null&&Lzd(b,uEd(a,c));} + function G5d(a,b,c,d){C5d.call(this,a,b,c,d);} + function oie(a,b,c,d){C5d.call(this,a,b,c,d);} + function sie(a,b,c,d){oie.call(this,a,b,c,d);} + function Nie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Pie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Vie(a,b,c,d){Iie.call(this,a,b,c,d);} + function Tie(a,b,c,d){Pie.call(this,a,b,c,d);} + function $ie(a,b,c,d){Pie.call(this,a,b,c,d);} + function Yie(a,b,c,d){Vie.call(this,a,b,c,d);} + function bje(a,b,c,d){$ie.call(this,a,b,c,d);} + function Dje(a,b,c,d){wje.call(this,a,b,c,d);} + function aMd(a,b){veb.call(this,HJe+a+NIe+b);} + function Hje(a,b){return a.jk().wi().ri(a,b)} + function Ije(a,b){return a.jk().wi().ti(a,b)} + function Lfb(a,b){return uFb(a),dE(a)===dE(b)} + function lhb(a,b){return uFb(a),dE(a)===dE(b)} + function mEb(a,b){return a.b.Bd(new pEb(a,b))} + function sEb(a,b){return a.b.Bd(new vEb(a,b))} + function yEb(a,b){return a.b.Bd(new BEb(a,b))} + function Bk(a,b){return a.e=RD(a.d.Kb(b),159)} + function uhb(a,b,c){return a.lastIndexOf(b,c)} + function wWb(a,b,c){return Qfb(a[b.a],a[c.a])} + function TWb(a,b){return pQb(b,(yCc(),gAc),a)} + function Lpc(a,b){return hgb(b.a.d.p,a.a.d.p)} + function Kpc(a,b){return hgb(a.a.d.p,b.a.d.p)} + function zTc(a,b){return Qfb(a.c-a.s,b.c-b.s)} + function qWc(a,b){return Qfb(a.b.e.a,b.b.e.a)} + function sWc(a,b){return Qfb(a.c.e.a,b.c.e.a)} + function $2b(a){return !a.c?-1:Wmb(a.c.a,a,0)} + function Cod(a){return a==vod||a==xod||a==wod} + function CMd(a,b){this.c=a;nMd.call(this,a,b);} + function fq(a,b,c){this.a=a;qc.call(this,b,c);} + function YDb(a){this.c=a;xxb.call(this,Sve,0);} + function rk(a,b,c){this.c=b;this.b=c;this.a=a;} + function DMc(a){dMc();this.d=a;this.a=new wmb;} + function ho(a){_l();this.a=(yob(),new Lqb(a));} + function Xmc(a,b){Dmd(a.f)?Ymc(a,b):Zmc(a,b);} + function Lxb(a,b){Mxb.call(this,a,a.length,b);} + function nBb(a,b){if(dBb){return}!!b&&(a.d=b);} + function ZNd(a,b){return ZD(b,15)&&_Gd(a.c,b)} + function AVd(a,b,c){return RD(a.c,71).Wk(b,c)} + function BVd(a,b,c){return RD(a.c,71).Xk(b,c)} + function mge(a,b,c){return lge(a,RD(b,343),c)} + function oge(a,b,c){return nge(a,RD(b,343),c)} + function Ige(a,b,c){return Hge(a,RD(b,343),c)} + function Kge(a,b,c){return Jge(a,RD(b,343),c)} + function Fn(a,b){return b==null?null:Xv(a.b,b)} + function Qeb(a){return _D(a)?(uFb(a),a):a.ue()} + function Rfb(a){return !isNaN(a)&&!isFinite(a)} + function Zub(a){Lub(this);Xub(this);ye(this,a);} + function dnb(a){Pmb(this);YEb(this.c,0,a.Pc());} + function Fsb(a,b,c){this.a=a;this.b=b;this.c=c;} + function Vtb(a,b,c){this.a=a;this.b=b;this.c=c;} + function hvb(a,b,c){this.d=a;this.b=c;this.a=b;} + function aBb(a){this.a=a;gib();Hdb(Date.now());} + function wzb(a){Ckb(a.a);Yyb(a.c,a.b);a.b=null;} + function wvb(){wvb=geb;uvb=new xvb;vvb=new zvb;} + function KMd(){KMd=geb;JMd=$C(jJ,rve,1,0,5,1);} + function TTd(){TTd=geb;STd=$C(jJ,rve,1,0,5,1);} + function yUd(){yUd=geb;xUd=$C(jJ,rve,1,0,5,1);} + function _l(){_l=geb;new im((yob(),yob(),vob));} + function gAb(a){cAb();return ws((qAb(),pAb),a)} + function zBb(a){xBb();return ws((CBb(),BBb),a)} + function FHb(a){DHb();return ws((IHb(),HHb),a)} + function NHb(a){LHb();return ws((QHb(),PHb),a)} + function kIb(a){iIb();return ws((nIb(),mIb),a)} + function _Jb(a){ZJb();return ws((cKb(),bKb),a)} + function GKb(a){EKb();return ws((JKb(),IKb),a)} + function xLb(a){vLb();return ws((ALb(),zLb),a)} + function mMb(a){hMb();return ws((pMb(),oMb),a)} + function oOb(a){mOb();return ws((rOb(),qOb),a)} + function KPb(a){IPb();return ws((NPb(),MPb),a)} + function KRb(a){IRb();return ws((NRb(),MRb),a)} + function XRb(a){VRb();return ws(($Rb(),ZRb),a)} + function VUb(a){TUb();return ws((YUb(),XUb),a)} + function CWb(a){AWb();return ws((FWb(),EWb),a)} + function uXb(a){sXb();return ws((xXb(),wXb),a)} + function tZb(a){nZb();return ws((wZb(),vZb),a)} + function W$b(a){U$b();return ws((Z$b(),Y$b),a)} + function Mb(a,b){if(!a){throw Adb(new agb(b))}} + function Vb(a){if(!a){throw Adb(new dgb(tve))}} + function rFb(a,b){if(a!=b){throw Adb(new Jrb)}} + function KQb(a,b,c){this.a=a;this.b=b;this.c=c;} + function lRb(a,b,c){this.a=a;this.b=b;this.c=c;} + function h7b(a,b,c){this.a=a;this.b=b;this.c=c;} + function J0b(a,b,c){this.b=a;this.a=b;this.c=c;} + function dNb(a,b,c){this.b=a;this.c=b;this.a=c;} + function oac(a,b,c){this.a=a;this.b=b;this.c=c;} + function F1b(a,b,c){this.e=b;this.b=a;this.d=c;} + function Ecc(a,b,c){this.b=a;this.a=b;this.c=c;} + function UDb(a,b,c){xDb();a.a.Yd(b,c);return b} + function CJb(a){var b;b=new BJb;b.e=a;return b} + function _Nb(a){var b;b=new YNb;b.b=a;return b} + function U9b(){U9b=geb;S9b=new bac;T9b=new eac;} + function Rec(){Rec=geb;Qec=new efc;Pec=new jfc;} + function lkc(){lkc=geb;jkc=new Mkc;kkc=new Okc;} + function loc(a){joc();return ws((ooc(),noc),a)} + function kcc(a){hcc();return ws((ncc(),mcc),a)} + function yec(a){vec();return ws((Bec(),Aec),a)} + function gnc(a){enc();return ws((jnc(),inc),a)} + function Enc(a){Bnc();return ws((Hnc(),Gnc),a)} + function gpc(a){epc();return ws((jpc(),ipc),a)} + function dtc(a){btc();return ws((gtc(),ftc),a)} + function ltc(a){jtc();return ws((otc(),ntc),a)} + function xtc(a){stc();return ws((Atc(),ztc),a)} + function Gtc(a){Etc();return ws((Jtc(),Itc),a)} + function Utc(a){Ptc();return ws((Xtc(),Wtc),a)} + function auc(a){$tc();return ws((duc(),cuc),a)} + function avc(a){$uc();return ws((dvc(),cvc),a)} + function qvc(a){ovc();return ws((tvc(),svc),a)} + function zvc(a){xvc();return ws((Cvc(),Bvc),a)} + function Ivc(a){Gvc();return ws((Lvc(),Kvc),a)} + function Qvc(a){Ovc();return ws((Tvc(),Svc),a)} + function Quc(a){Ouc();return ws((Tuc(),Suc),a)} + function juc(a){huc();return ws((muc(),luc),a)} + function wuc(a){tuc();return ws((zuc(),yuc),a)} + function Euc(a){Cuc();return ws((Huc(),Guc),a)} + function exc(a){cxc();return ws((hxc(),gxc),a)} + function eDc(a){_Cc();return ws((hDc(),gDc),a)} + function oDc(a){lDc();return ws((rDc(),qDc),a)} + function ADc(a){wDc();return ws((DDc(),CDc),a)} + function ODc(a){JDc();return ws((RDc(),QDc),a)} + function cEc(a){aEc();return ws((fEc(),eEc),a)} + function mEc(a){kEc();return ws((pEc(),oEc),a)} + function uEc(a){sEc();return ws((xEc(),wEc),a)} + function DEc(a){BEc();return ws((GEc(),FEc),a)} + function MEc(a){KEc();return ws((PEc(),OEc),a)} + function VEc(a){TEc();return ws((YEc(),XEc),a)} + function nFc(a){lFc();return ws((qFc(),pFc),a)} + function wFc(a){uFc();return ws((zFc(),yFc),a)} + function FFc(a){DFc();return ws((IFc(),HFc),a)} + function TKc(a){RKc();return ws((WKc(),VKc),a)} + function uNc(a){sNc();return ws((xNc(),wNc),a)} + function yQc(a){wQc();return ws((BQc(),AQc),a)} + function GQc(a){EQc();return ws((JQc(),IQc),a)} + function hTc(a){fTc();return ws((kTc(),jTc),a)} + function fVc(a){dVc();return ws((iVc(),hVc),a)} + function bWc(a){YVc();return ws((eWc(),dWc),a)} + function ZYc(a){WYc();return ws((aZc(),_Yc),a)} + function NZc(a){LZc();return ws((QZc(),PZc),a)} + function u_c(a){s_c();return ws((x_c(),w_c),a)} + function C_c(a){A_c();return ws((F_c(),E_c),a)} + function C2c(a){x2c();return ws((F2c(),E2c),a)} + function j3c(a){g3c();return ws((m3c(),l3c),a)} + function j4c(a){g4c();return ws((m4c(),l4c),a)} + function _3c(a){Y3c();return ws((c4c(),b4c),a)} + function m5c(a){j5c();return ws((p5c(),o5c),a)} + function w5c(a){t5c();return ws((z5c(),y5c),a)} + function h6c(a){f6c();return ws((k6c(),j6c),a)} + function C6c(a){z6c();return ws((F6c(),E6c),a)} + function b7c(a){_6c();return ws((e7c(),d7c),a)} + function E8c(a){z8c();return ws((H8c(),G8c),a)} + function R8b(a){P8b();return ws((U8b(),T8b),a)} + function t3b(a){r3b();return ws((w3b(),v3b),a)} + function g9c(a){b9c();return ws((j9c(),i9c),a)} + function G9c(a){B9c();return ws((J9c(),I9c),a)} + function uad(a){sad();return ws((xad(),wad),a)} + function xbd(a){sbd();return ws((Abd(),zbd),a)} + function ibd(a){gbd();return ws((lbd(),kbd),a)} + function Gbd(a){Cbd();return ws((Jbd(),Ibd),a)} + function Obd(a){Mbd();return ws((Rbd(),Qbd),a)} + function Zbd(a){Xbd();return ws((acd(),_bd),a)} + function fdd(a){_cd();return ws((idd(),hdd),a)} + function qdd(a){ldd();return ws((tdd(),sdd),a)} + function $hd(a){Yhd();return ws((bid(),aid),a)} + function mid(a){kid();return ws((pid(),oid),a)} + function Tjd(a){Rjd();return ws((Wjd(),Vjd),a)} + function wkd(a){ukd();return ws((zkd(),ykd),a)} + function Hmd(a){Cmd();return ws((Kmd(),Jmd),a)} + function Qmd(a){Omd();return ws((Tmd(),Smd),a)} + function $md(a){Ymd();return ws((bnd(),and),a)} + function knd(a){ind();return ws((nnd(),mnd),a)} + function Hnd(a){Fnd();return ws((Knd(),Jnd),a)} + function Snd(a){Pnd();return ws((Vnd(),Und),a)} + function god(a){dod();return ws((jod(),iod),a)} + function rod(a){pod();return ws((uod(),tod),a)} + function Fod(a){Bod();return ws((Iod(),Hod),a)} + function Tod(a){Pod();return ws((Wod(),Vod),a)} + function wpd(a){qpd();return ws((zpd(),ypd),a)} + function Spd(a){Qpd();return ws((Vpd(),Upd),a)} + function fqd(a){dqd();return ws((iqd(),hqd),a)} + function oqd(a){mqd();return ws((rqd(),qqd),a)} + function zsc(a,b){return (uFb(a),a)+(uFb(b),b)} + function wqd(a){uqd();return ws((Eqd(),Dqd),a)} + function Ird(a){Grd();return ws((Lrd(),Krd),a)} + function vtd(a){ttd();return ws((ytd(),xtd),a)} + function dMc(){dMc=geb;bMc=(qpd(),ppd);cMc=Xod;} + function uqd(){uqd=geb;sqd=new zqd;tqd=new Bqd;} + function wJc(a){!a.e&&(a.e=new bnb);return a.e} + function BTc(a,b){this.c=a;this.a=b;this.b=b-a;} + function g8c(a,b,c){this.a=a;this.b=b;this.c=c;} + function gud(a,b,c){this.a=a;this.b=b;this.c=c;} + function Wdd(a,b,c){this.a=a;this.b=b;this.c=c;} + function ced(a,b,c){this.a=a;this.b=b;this.c=c;} + function pFd(a,b,c){this.a=a;this.b=b;this.c=c;} + function ZPd(a,b,c){this.a=a;this.b=b;this.c=c;} + function g7d(a,b,c){this.e=a;this.a=b;this.c=c;} + function K7d(a,b,c){s7d();C7d.call(this,a,b,c);} + function f9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function r9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function x9d(a,b,c){s7d();O8d.call(this,a,b,c);} + function h9d(a,b,c){s7d();f9d.call(this,a,b,c);} + function j9d(a,b,c){s7d();f9d.call(this,a,b,c);} + function l9d(a,b,c){s7d();j9d.call(this,a,b,c);} + function t9d(a,b,c){s7d();r9d.call(this,a,b,c);} + function z9d(a,b,c){s7d();x9d.call(this,a,b,c);} + function S2b(a){J2b.call(this,a.d,a.c,a.a,a.b);} + function B3b(a){J2b.call(this,a.d,a.c,a.a,a.b);} + function Og(a){this.d=a;Lg(this);this.b=ed(a.d);} + function cGd(a){aGd();return ws((fGd(),eGd),a)} + function gk(a,b){Qb(a);Qb(b);return new hk(a,b)} + function dr(a,b){Qb(a);Qb(b);return new mr(a,b)} + function hr(a,b){Qb(a);Qb(b);return new sr(a,b)} + function Dr(a,b){Qb(a);Qb(b);return new Rr(a,b)} + function Uub(a){sFb(a.b!=0);return Wub(a,a.a.a)} + function Vub(a){sFb(a.b!=0);return Wub(a,a.c.b)} + function q$d(a){!a.c&&(a.c=new X9d);return a.c} + function cv(a){var b;b=new bnb;xr(b,a);return b} + function Vx(a){var b;b=new _sb;xr(b,a);return b} + function Yx(a){var b;b=new xAb;_q(b,a);return b} + function gv(a){var b;b=new Yub;_q(b,a);return b} + function RD(a,b){CFb(a==null||QD(a,b));return a} + function Mxb(a,b,c){Axb.call(this,b,c);this.a=a;} + function kB(a,b){this.c=a;this.b=b;this.a=false;} + function hCb(){this.a=';,;';this.b='';this.c='';} + function $Cb(a,b,c){this.b=a;pxb.call(this,b,c);} + function uub(a,b,c){this.c=a;xlb.call(this,b,c);} + function fZb(a,b,c){eZb.call(this,a,b);this.b=c;} + function YEb(a,b,c){VEb(c,0,a,b,c.length,false);} + function JYb(a,b,c,d,e){a.b=b;a.c=c;a.d=d;a.a=e;} + function D2b(a,b,c,d,e){a.d=b;a.c=c;a.a=d;a.b=e;} + function XDb(a,b){if(b){a.b=b;a.a=(LCb(b),b.a);}} + function mFb(a,b){if(!a){throw Adb(new agb(b))}} + function zFb(a,b){if(!a){throw Adb(new dgb(b))}} + function qFb(a,b){if(!a){throw Adb(new zeb(b))}} + function zqc(a,b){mqc();return hgb(a.d.p,b.d.p)} + function T0c(a,b){B0c();return Qfb(a.e.b,b.e.b)} + function U0c(a,b){B0c();return Qfb(a.e.a,b.e.a)} + function Xoc(a,b){return hgb(N3b(a.d),N3b(b.d))} + function Izb(a,b){return !!b&&Jzb(a,b.d)?b:null} + function $lc(a,b){return b==(qpd(),ppd)?a.c:a.d} + function Qdb(a){return Edb(yD(Kdb(a)?Wdb(a):a))} + function Nid(a){return new rjd(a.c+a.b,a.d+a.a)} + function GSd(a){return a!=null&&!mSd(a,aSd,bSd)} + function DSd(a,b){return (JSd(a)<<4|JSd(b))&Bwe} + function Rid(a,b,c,d,e){a.c=b;a.d=c;a.b=d;a.a=e;} + function y8b(a){var b,c;b=a.b;c=a.c;a.b=c;a.c=b;} + function B8b(a){var b,c;c=a.d;b=a.a;a.d=b;a.a=c;} + function u6d(a,b){var c;c=a.c;t6d(a,b);return c} + function Nqd(a,b){b<0?(a.g=-1):(a.g=b);return a} + function kjd(a,b){gjd(a);a.a*=b;a.b*=b;return a} + function hrc(a,b,c){grc.call(this,b,c);this.d=a;} + function PZd(a,b,c){kZd.call(this,a,b);this.c=c;} + function Kfe(a,b,c){kZd.call(this,a,b);this.c=c;} + function zUd(a){yUd();kUd.call(this);this.ci(a);} + function Yee(){ree();Zee.call(this,(YSd(),XSd));} + function Yse(a){Vse();return new Hte(0,a)} + function uke(){uke=geb;tke=(yob(),new mpb(eLe));} + function ux(){ux=geb;new wx((kl(),jl),(Wk(),Vk));} + function ugb(){ugb=geb;tgb=$C(bJ,Nve,17,256,0,1);} + function zUb(){this.b=Kfb(UD(iGd((yVb(),sVb))));} + function Pq(a){this.b=a;this.a=gn(this.b.a).Od();} + function mr(a,b){this.b=a;this.a=b;zl.call(this);} + function sr(a,b){this.a=a;this.b=b;zl.call(this);} + function s_d(a,b,c){this.a=a;N$d.call(this,b,c);} + function n_d(a,b,c){this.a=a;N$d.call(this,b,c);} + function sDd(a,b,c){var d;d=new OC(c);sC(a,b,d);} + function _Eb(a,b,c){var d;d=a[b];a[b]=c;return d} + function UEb(a){var b;b=a.slice();return dD(b,a)} + function SJb(a){var b;b=a.n;return a.a.b+b.d+b.a} + function PKb(a){var b;b=a.n;return a.e.b+b.d+b.a} + function QKb(a){var b;b=a.n;return a.e.a+b.b+b.c} + function rub(a){a.a.b=a.b;a.b.a=a.a;a.a=a.b=null;} + function Mub(a,b){Pub(a,b,a.c.b,a.c);return true} + function w2b(a){if(a.a){return a.a}return R0b(a)} + function NSb(a){HSb();return JGd(a)==vCd(LGd(a))} + function OSb(a){HSb();return LGd(a)==vCd(JGd(a))} + function l_b(a,b){return k_b(a,new eZb(b.a,b.b))} + function xn(a,b){return fn(),ck(a,b),new zy(a,b)} + function fmc(a,b){return a.c=b){throw Adb(new web)}} + function JDb(a,b){return MDb(a,(uFb(b),new JAb(b)))} + function KDb(a,b){return MDb(a,(uFb(b),new LAb(b)))} + function prc(a,b,c){return qrc(a,RD(b,12),RD(c,12))} + function q4b(a){return J3b(),RD(a,12).g.c.length!=0} + function v4b(a){return J3b(),RD(a,12).e.c.length!=0} + function sdc(a,b){Zcc();return Qfb(b.a.o.a,a.a.o.a)} + function d_d(a,b){(b.Bb&QHe)!=0&&!a.a.o&&(a.a.o=b);} + function T3c(a,b){b.Ug("General 'Rotator",1);S3c(a);} + function MCc(a,b,c){b.qf(c,Kfb(UD(Wjb(a.b,c)))*a.a);} + function yid(a,b,c){tid();return xid(a,b)&&xid(a,c)} + function Rod(a){Pod();return !a.Hc(Lod)&&!a.Hc(Nod)} + function Nrc(a){if(a.e){return Src(a.e)}return null} + function Zdb(a){if(Kdb(a)){return ''+a}return GD(a)} + function XNc(a){var b;b=a;while(b.f){b=b.f;}return b} + function HBb(a,b,c){bD(b,0,tCb(b[0],c[0]));return b} + function Gpc(a,b,c,d){var e;e=a.i;e.i=b;e.a=c;e.b=d;} + function C5d(a,b,c,d){XZd.call(this,a,b,c);this.b=d;} + function N3d(a,b,c,d,e){O3d.call(this,a,b,c,d,e,-1);} + function b4d(a,b,c,d,e){c4d.call(this,a,b,c,d,e,-1);} + function Iie(a,b,c,d){PZd.call(this,a,b,c);this.b=d;} + function Xde(a){uId.call(this,a,false);this.a=false;} + function Bqd(){vqd.call(this,'LOOKAHEAD_LAYOUT',1);} + function nNd(a){this.b=a;mMd.call(this,a);mNd(this);} + function vNd(a){this.b=a;BMd.call(this,a);uNd(this);} + function J5d(a,b,c){this.a=a;G5d.call(this,b,c,5,6);} + function wje(a,b,c,d){this.b=a;XZd.call(this,b,c,d);} + function Tj(a,b){this.b=a;Aj.call(this,a.b);this.a=b;} + function NLc(a){this.a=LLc(a.a);this.b=new dnb(a.b);} + function Fx(a,b){tm();Ex.call(this,a,Pm(new mob(b)));} + function _se(a,b){Vse();return new aue(a,b,0)} + function bte(a,b){Vse();return new aue(6,a,b)} + function Ztb(a,b){uFb(b);while(a.Ob()){b.Cd(a.Pb());}} + function Ujb(a,b){return bE(b)?Yjb(a,b):!!qtb(a.f,b)} + function O_d(a,b){return b.Vh()?Vvd(a.b,RD(b,54)):b} + function whb(a,b){return lhb(a.substr(0,b.length),b)} + function Fl(a){return new is(new Il(a.a.length,a.a))} + function Oid(a){return new rjd(a.c+a.b/2,a.d+a.a/2)} + function yD(a){return hD(~a.l&dxe,~a.m&dxe,~a.h&exe)} + function cE(a){return typeof a===gve||typeof a===kve} + function akb(a){a.f=new ttb(a);a.i=new Ntb(a);++a.g;} + function Klb(a){if(!a){throw Adb(new Dvb)}return a.d} + function smb(a){var b;b=omb(a);sFb(b!=null);return b} + function tmb(a){var b;b=pmb(a);sFb(b!=null);return b} + function tv(a,b){var c;c=a.a.gc();Sb(b,c);return c-b} + function Ysb(a,b){var c;c=a.a.zc(b,a);return c==null} + function rAb(a,b){return a.a.zc(b,(Geb(),Eeb))==null} + function _nb(a){return new SDb(null,$nb(a,a.length))} + function yPb(a,b,c){return zPb(a,RD(b,42),RD(c,176))} + function Wrb(a,b,c){zsb(a.a,b);return _Eb(a.b,b.g,c)} + function fyb(a,b,c){lyb(c,a.a.c.length);$mb(a.a,c,b);} + function Knb(a,b,c,d){nFb(b,c,a.length);Onb(a,b,c,d);} + function Onb(a,b,c,d){var e;for(e=b;e0?$wnd.Math.log(a/b):-100} + function Agb(a,b){return Ddb(a,b)<0?-1:Ddb(a,b)>0?1:0} + function Dge(a,b){hZd(a,ZD(b,160)?b:RD(b,2036).Rl());} + function vFb(a,b){if(a==null){throw Adb(new Ogb(b))}} + function $nb(a,b){return jxb(b,a.length),new Gxb(a,b)} + function hsc(a,b){if(!b){return false}return ye(a,b)} + function Gs(){zs();return cD(WC(RG,1),jwe,549,0,[ys])} + function Xib(a){return a.e==0?a:new cjb(-a.e,a.d,a.a)} + function $Nb(a,b){return Qfb(a.c.c+a.c.b,b.c.c+b.c.b)} + function cvb(a,b){Pub(a.d,b,a.b.b,a.b);++a.a;a.c=null;} + function JCb(a,b){!a.c?Rmb(a.b,b):JCb(a.c,b);return a} + function KB(a,b,c){var d;d=JB(a,b);LB(a,b,c);return d} + function Rnb(a,b,c){var d;for(d=0;d=a.g} + function bD(a,b,c){pFb(c==null||VC(a,c));return a[b]=c} + function yhb(a,b){BFb(b,a.length+1);return a.substr(b)} + function yxb(a,b){uFb(b);while(a.c=a){return new rDb}return iDb(a-1)} + function Y2b(a){if(!a.a&&!!a.c){return a.c.b}return a.a} + function Zx(a){if(ZD(a,616)){return a}return new sy(a)} + function LCb(a){if(!a.c){MCb(a);a.d=true;}else {LCb(a.c);}} + function ICb(a){if(!a.c){a.d=true;KCb(a);}else {a.c.$e();}} + function bHb(a){a.b=false;a.c=false;a.d=false;a.a=false;} + function uMc(a){var b,c;b=a.c.i.c;c=a.d.i.c;return b==c} + function _vd(a,b){var c;c=a.Ih(b);c>=0?a.ki(c):Tvd(a,b);} + function mtd(a,b){a.c<0||a.b.b0){a=a<<1|(a<0?1:0);}return a} + function BGc(a,b){var c;c=new R4b(a);ZEb(b.c,c);return c} + function FMb(a,b){a.u.Hc((Pod(),Lod))&&DMb(a,b);HMb(a,b);} + function Fvb(a,b){return dE(a)===dE(b)||a!=null&&pb(a,b)} + function Vrb(a,b){return Bsb(a.a,b)?a.b[RD(b,22).g]:null} + function YRb(){VRb();return cD(WC($O,1),jwe,489,0,[URb])} + function ybd(){sbd();return cD(WC(M1,1),jwe,490,0,[rbd])} + function Hbd(){Cbd();return cD(WC(N1,1),jwe,558,0,[Bbd])} + function gdd(){_cd();return cD(WC(V1,1),jwe,539,0,[$cd])} + function iyd(a){!a.n&&(a.n=new C5d(I4,a,1,7));return a.n} + function wCd(a){!a.c&&(a.c=new C5d(K4,a,9,9));return a.c} + function mzd(a){!a.c&&(a.c=new Yie(E4,a,5,8));return a.c} + function lzd(a){!a.b&&(a.b=new Yie(E4,a,4,7));return a.b} + function Sed(a){a.j.c.length=0;Ae(a.c);sfd(a.a);return a} + function Afe(a){a.e==fLe&&Gfe(a,Aee(a.g,a.b));return a.e} + function Bfe(a){a.f==fLe&&Hfe(a,Bee(a.g,a.b));return a.f} + function xBd(a,b,c,d){wBd(a,b,c,false);j1d(a,d);return a} + function oNd(a,b){this.b=a;nMd.call(this,a,b);mNd(this);} + function wNd(a,b){this.b=a;CMd.call(this,a,b);uNd(this);} + function Kmb(a){this.d=a;this.a=this.d.b;this.b=this.d.c;} + function oy(a,b){this.b=a;this.c=b;this.a=new Osb(this.b);} + function ihb(a,b){BFb(b,a.length);return a.charCodeAt(b)} + function NDd(a,b){CGd(a,Kfb(vDd(b,'x')),Kfb(vDd(b,'y')));} + function $Dd(a,b){CGd(a,Kfb(vDd(b,'x')),Kfb(vDd(b,'y')));} + function CDb(a,b){MCb(a);return new SDb(a,new hEb(b,a.a))} + function GDb(a,b){MCb(a);return new SDb(a,new zEb(b,a.a))} + function HDb(a,b){MCb(a);return new WCb(a,new nEb(b,a.a))} + function IDb(a,b){MCb(a);return new oDb(a,new tEb(b,a.a))} + function Ty(a,b){return new Ry(RD(Qb(a),50),RD(Qb(b),50))} + function nHb(a,b){return Qfb(a.d.c+a.d.b/2,b.d.c+b.d.b/2)} + function gTb(a,b,c){c.a?Eyd(a,b.b-a.f/2):Dyd(a,b.a-a.g/2);} + function WYb(a,b){return Qfb(a.g.c+a.g.b/2,b.g.c+b.g.b/2)} + function RZb(a,b){NZb();return Qfb((uFb(a),a),(uFb(b),b))} + function wSd(a){return a!=null&&tpb(eSd,a.toLowerCase())} + function Ae(a){var b;for(b=a.Kc();b.Ob();){b.Pb();b.Qb();}} + function Ih(a){var b;b=a.b;!b&&(a.b=b=new Xh(a));return b} + function R0b(a){var b;b=Z5b(a);if(b){return b}return null} + function BSb(a,b){var c,d;c=a/b;d=eE(c);c>d&&++d;return d} + function Ck(a,b,c){var d;d=RD(a.d.Kb(c),159);!!d&&d.Nb(b);} + function Vhc(a,b,c){tqc(a.a,c);Jpc(c);Kqc(a.b,c);bqc(b,c);} + function oNc(a,b,c,d){this.a=a;this.c=b;this.b=c;this.d=d;} + function ROc(a,b,c,d){this.c=a;this.b=b;this.a=c;this.d=d;} + function uPc(a,b,c,d){this.c=a;this.b=b;this.d=c;this.a=d;} + function Uid(a,b,c,d){this.c=a;this.d=b;this.b=c;this.a=d;} + function GTc(a,b,c,d){this.a=a;this.d=b;this.c=c;this.b=d;} + function t1b(a,b,c,d){this.a=a;this.e=b;this.d=c;this.c=d;} + function $td(a,b,c,d){this.a=a;this.c=b;this.d=c;this.b=d;} + function ehb(a,b,c){this.a=ywe;this.d=a;this.b=b;this.c=c;} + function fpc(a,b,c,d){qs.call(this,a,b);this.a=c;this.b=d;} + function Uwb(a,b){this.d=(uFb(a),a);this.a=16449;this.c=b;} + function CIc(a){this.a=new bnb;this.e=$C(kE,Nve,53,a,0,2);} + function ELc(a){a.Ug('No crossing minimization',1);a.Vg();} + function Evb(){yz.call(this,'There is no more element.');} + function OEd(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;} + function PEd(a,b,c,d){this.a=a;this.b=b;this.c=c;this.d=d;} + function h7d(a,b,c,d){this.e=a;this.a=b;this.c=c;this.d=d;} + function x7d(a,b,c,d){this.a=a;this.c=b;this.d=c;this.b=d;} + function C8d(a,b,c,d){s7d();M7d.call(this,b,c,d);this.a=a;} + function J8d(a,b,c,d){s7d();M7d.call(this,b,c,d);this.a=a;} + function lwd(a,b,c){var d,e;d=oSd(a);e=b.ti(c,d);return e} + function lBd(a){var b,c;c=(b=new s2d,b);l2d(c,a);return c} + function mBd(a){var b,c;c=(b=new s2d,b);p2d(c,a);return c} + function HDd(a,b){var c;c=Wjb(a.f,b);wEd(b,c);return null} + function uCd(a){!a.b&&(a.b=new C5d(G4,a,12,3));return a.b} + function VD(a){CFb(a==null||cE(a)&&!(a.Tm===keb));return a} + function gz(a){if(a.n){a.e!==rwe&&a.je();a.j=null;}return a} + function Ng(a){ig(a.d);if(a.d.d!=a.c){throw Adb(new Jrb)}} + function Bkb(a){sFb(a.b0&&wPd(this);} + function Vg(a,b){this.a=a;Pg.call(this,a,RD(a.d,15).fd(b));} + function lrd(a,b){return Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function mrd(a,b){return Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function n5b(a){return ozd(a)&&Heb(TD(Gxd(a,(yCc(),OAc))))} + function Sfc(a,b){return Rc(a,RD(mQb(b,(yCc(),tBc)),17),b)} + function lic(a,b){RD(mQb(a,(Ywc(),qwc)),15).Fc(b);return b} + function C2b(a,b){a.b=b.b;a.c=b.c;a.d=b.d;a.a=b.a;return a} + function cEb(a,b,c,d){this.b=a;this.c=d;xxb.call(this,b,c);} + function Ulc(a,b,c){a.i=0;a.e=0;if(b==c){return}Qlc(a,b,c);} + function Vlc(a,b,c){a.i=0;a.e=0;if(b==c){return}Rlc(a,b,c);} + function akc(a,b,c){Wjc();return _Gb(RD(Wjb(a.e,b),529),c)} + function nd(a){var b;return b=a.f,!b?(a.f=new ne(a,a.c)):b} + function nTc(a,b){return VTc(a.j,b.s,b.c)+VTc(b.e,a.s,a.c)} + function Rrc(a,b){if(!!a.e&&!a.e.a){Prc(a.e,b);Rrc(a.e,b);}} + function Qrc(a,b){if(!!a.d&&!a.d.a){Prc(a.d,b);Qrc(a.d,b);}} + function krd(a,b){return -Qfb(urd(a)*trd(a),urd(b)*trd(b))} + function gtd(a){return RD(a.ld(),149).Pg()+':'+jeb(a.md())} + function EBd(){BBd(this,new yAd);this.wb=(lTd(),kTd);jTd();} + function G7b(a){this.b=new bnb;Tmb(this.b,this.b);this.a=a;} + function WWc(a,b){new Yub;this.a=new Ejd;this.b=a;this.c=b;} + function urb(){urb=geb;rrb=new wrb;srb=new wrb;trb=new Brb;} + function yob(){yob=geb;vob=new Job;wob=new apb;xob=new ipb;} + function FGb(){FGb=geb;CGb=new AGb;EGb=new fHb;DGb=new YGb;} + function HSb(){HSb=geb;GSb=new bnb;FSb=new Tsb;ESb=new bnb;} + function Rb(a,b){if(a==null){throw Adb(new Ogb(b))}return a} + function tCd(a){!a.a&&(a.a=new C5d(J4,a,10,11));return a.a} + function uYd(a){!a.q&&(a.q=new C5d(s7,a,11,10));return a.q} + function xYd(a){!a.s&&(a.s=new C5d(y7,a,21,17));return a.s} + function er(a){Qb(a);return Er(new is(Mr(a.a.Kc(),new ir)))} + function hfd(a,b){rb(a);rb(b);return ns(RD(a,22),RD(b,22))} + function qDd(a,b,c){var d,e;d=Qeb(c);e=new hC(d);sC(a,b,e);} + function d4d(a,b,c,d,e,f){c4d.call(this,a,b,c,d,e,f?-2:-1);} + function sje(a,b,c,d){kZd.call(this,b,c);this.b=a;this.a=d;} + function Ry(a,b){wi.call(this,new ezb(a));this.a=a;this.b=b;} + function Gu(a){this.b=a;this.c=a;a.e=null;a.c=null;this.a=1;} + function Dkc(a){lkc();var b;b=RD(a.g,10);b.n.a=a.d.c+b.d.b;} + function fA(){fA=geb;var a,b;b=!lA();a=new tA;eA=b?new mA:a;} + function Hob(a){yob();return ZD(a,59)?new irb(a):new Upb(a)} + function Ux(a){return ZD(a,16)?new btb(RD(a,16)):Vx(a.Kc())} + function Vi(a){return new ij(a,a.e.Rd().gc()*a.c.Rd().gc())} + function fj(a){return new sj(a,a.e.Rd().gc()*a.c.Rd().gc())} + function Iz(a){return !!a&&!!a.hashCode?a.hashCode():kFb(a)} + function Yjb(a,b){return b==null?!!qtb(a.f,null):Jtb(a.i,b)} + function hYb(a,b){var c;c=$sb(a.a,b);c&&(b.d=null);return c} + function MGb(a,b,c){if(a.f){return a.f.ef(b,c)}return false} + function cFc(a,b,c,d){bD(a.c[b.g],c.g,d);bD(a.c[c.g],b.g,d);} + function fFc(a,b,c,d){bD(a.c[b.g],b.g,c);bD(a.b[b.g],b.g,d);} + function sXc(a,b,c){return Kfb(UD(c.a))<=a&&Kfb(UD(c.b))>=b} + function yJc(a,b){this.g=a;this.d=cD(WC(jR,1),WAe,10,0,[b]);} + function lHb(a){this.c=a;this.b=new yAb(RD(Qb(new oHb),50));} + function UYb(a){this.c=a;this.b=new yAb(RD(Qb(new XYb),50));} + function $Qb(a){this.b=a;this.a=new yAb(RD(Qb(new bRb),50));} + function tRc(){this.b=new _sb;this.d=new Yub;this.e=new Fyb;} + function VTb(){this.c=new pjd;this.d=new pjd;this.e=new pjd;} + function a1b(){this.a=new Ejd;this.b=(dk(3,iwe),new cnb(3));} + function i7d(a,b){this.e=a;this.a=jJ;this.b=pje(b);this.c=b;} + function Vid(a){this.c=a.c;this.d=a.d;this.b=a.b;this.a=a.a;} + function VLd(a,b,c,d,e,f){this.a=a;NKd.call(this,b,c,d,e,f);} + function aLd(a,b,c,d,e,f){this.a=a;NKd.call(this,b,c,d,e,f);} + function fge(a,b,c,d,e,f,g){return new lle(a.e,b,c,d,e,f,g)} + function xhb(a,b,c){return c>=0&&lhb(a.substr(c,b.length),b)} + function hGd(a,b){return ZD(b,149)&&lhb(a.b,RD(b,149).Pg())} + function Tde(a,b){return a.a?b.Gh().Kc():RD(b.Gh(),71).Ii()} + function Qqb(a,b){var c;c=a.b.Qc(b);Rqb(c,a.b.gc());return c} + function Ivb(a,b){if(a==null){throw Adb(new Ogb(b))}return a} + function zYd(a){if(!a.u){yYd(a);a.u=new w0d(a,a);}return a.u} + function Kx(a){this.a=(yob(),ZD(a,59)?new irb(a):new Upb(a));} + function Uwd(a){var b;b=RD(Ywd(a,16),29);return !b?a.ii():b} + function lz(a,b){var c;c=nfb(a.Rm);return b==null?c:c+': '+b} + function zhb(a,b,c){AFb(b,c,a.length);return a.substr(b,c-b)} + function VKb(a,b){RJb.call(this);KKb(this);this.a=a;this.c=b;} + function neb(a){!a?vve:lz(a,a.ie());} + function Wz(a){Qz();$wnd.setTimeout(function(){throw a},0);} + function GHb(){DHb();return cD(WC(uN,1),jwe,436,0,[CHb,BHb])} + function OHb(){LHb();return cD(WC(vN,1),jwe,435,0,[JHb,KHb])} + function WUb(){TUb();return cD(WC(BP,1),jwe,432,0,[RUb,SUb])} + function S8b(){P8b();return cD(WC(vS,1),jwe,517,0,[O8b,N8b])} + function Rvc(){Ovc();return cD(WC(lX,1),jwe,429,0,[Mvc,Nvc])} + function buc(){$tc();return cD(WC(cX,1),jwe,428,0,[Ytc,Ztc])} + function mtc(){jtc();return cD(WC($W,1),jwe,431,0,[htc,itc])} + function vEc(){sEc();return cD(WC(xX,1),jwe,430,0,[qEc,rEc])} + function vNc(){sNc();return cD(WC(MY,1),jwe,531,0,[rNc,qNc])} + function D2c(){x2c();return cD(WC(s0,1),jwe,501,0,[v2c,w2c])} + function zQc(){wQc();return cD(WC(FZ,1),jwe,523,0,[vQc,uQc])} + function HQc(){EQc();return cD(WC(GZ,1),jwe,522,0,[CQc,DQc])} + function iTc(){fTc();return cD(WC(b$,1),jwe,528,0,[eTc,dTc])} + function Fuc(){Cuc();return cD(WC(fX,1),jwe,488,0,[Buc,Auc])} + function F8c(){z8c();return cD(WC(l1,1),jwe,491,0,[x8c,y8c])} + function H9c(){B9c();return cD(WC(t1,1),jwe,492,0,[z9c,A9c])} + function D_c(){A_c();return cD(WC(K_,1),jwe,433,0,[z_c,y_c])} + function a4c(){Y3c();return cD(WC(H0,1),jwe,434,0,[W3c,X3c])} + function gVc(){dVc();return cD(WC(w$,1),jwe,465,0,[bVc,cVc])} + function Pbd(){Mbd();return cD(WC(O1,1),jwe,438,0,[Lbd,Kbd])} + function rdd(){ldd();return cD(WC(W1,1),jwe,437,0,[kdd,jdd])} + function xqd(){uqd();return cD(WC(M3,1),jwe,347,0,[sqd,tqd])} + function Jvd(a,b,c,d){return c>=0?a.Uh(b,c,d):a.Ch(null,c,d)} + function ltd(a){if(a.b.b==0){return a.a.sf()}return Uub(a.b)} + function vKd(a){if(a.p!=5)throw Adb(new cgb);return Ydb(a.f)} + function EKd(a){if(a.p!=5)throw Adb(new cgb);return Ydb(a.k)} + function P$d(a){dE(a.a)===dE((lYd(),kYd))&&Q$d(a);return a.a} + function iad(a,b){a.b=b;a.c>0&&a.b>0&&(a.g=Aad(a.c,a.b,a.a));} + function jad(a,b){a.c=b;a.c>0&&a.b>0&&(a.g=Aad(a.c,a.b,a.a));} + function BUc(a,b){yUc(this,new rjd(a.a,a.b));zUc(this,gv(b));} + function Tp(){Sp.call(this,new Usb(Sv(12)));Lb(true);this.a=2;} + function eue(a,b,c){Vse();Wse.call(this,a);this.b=b;this.a=c;} + function C7d(a,b,c){s7d();t7d.call(this,b);this.a=a;this.b=c;} + function qub(a){var b;b=a.c.d.b;a.b=b;a.a=a.c.d;b.a=a.c.d.b=a;} + function Tub(a){return a.b==0?null:(sFb(a.b!=0),Wub(a,a.a.a))} + function Xjb(a,b){return b==null?Wd(qtb(a.f,null)):Ktb(a.i,b)} + function bzb(a,b,c,d,e){return new Kzb(a,(cAb(),aAb),b,c,d,e)} + function Fnb(a,b){oFb(b);return Hnb(a,$C(kE,Pwe,28,b,15,1),b)} + function Tx(a,b){Rb(a,'set1');Rb(b,'set2');return new ey(a,b)} + function Kz(a,b){var c=Jz[a.charCodeAt(0)];return c==null?a:c} + function Xyb(a,b){var c,d;c=b;d=new Gzb;Zyb(a,c,d);return d.d} + function EMb(a,b,c,d){var e;e=new TJb;b.a[c.g]=e;Wrb(a.b,d,e);} + function SXb(a,b){var c;c=BXb(a.f,b);return $id(fjd(c),a.f.d)} + function RFb(a){var b;EJb(a.a);DJb(a.a);b=new PJb(a.a);LJb(b);} + function _Mb(a,b){$Mb(a,true);Umb(a.e.Rf(),new dNb(a,true,b));} + function PSb(a,b){HSb();return a==vCd(JGd(b))||a==vCd(LGd(b))} + function R0c(a,b){B0c();return RD(mQb(b,(h_c(),f_c)),17).a==a} + function eE(a){return Math.max(Math.min(a,lve),-2147483648)|0} + function sy(a){this.a=RD(Qb(a),277);this.b=(yob(),new jrb(a));} + function qbd(a,b,c){this.i=new bnb;this.b=a;this.g=b;this.a=c;} + function had(a,b,c){this.a=new bnb;this.e=a;this.f=b;this.c=c;} + function _9c(a,b,c){this.c=new bnb;this.e=a;this.f=b;this.b=c;} + function TKb(a){RJb.call(this);KKb(this);this.a=a;this.c=true;} + function ieb(a){function b(){} +b.prototype=a||{};return new b} + function zfb(a){if(a.Ae()){return null}var b=a.n;return eeb[b]} + function kzd(a){if(a.Db>>16!=3)return null;return RD(a.Cb,27)} + function MCd(a){if(a.Db>>16!=9)return null;return RD(a.Cb,27)} + function Fzd(a){if(a.Db>>16!=6)return null;return RD(a.Cb,74)} + function dVc(){dVc=geb;bVc=new eVc(Nye,0);cVc=new eVc(Oye,1);} + function wQc(){wQc=geb;vQc=new xQc(Oye,0);uQc=new xQc(Nye,1);} + function EQc(){EQc=geb;CQc=new FQc(Zye,0);DQc=new FQc('UP',1);} + function Is(){Is=geb;Hs=ss((zs(),cD(WC(RG,1),jwe,549,0,[ys])));} + function Wx(a){var b;b=new atb(Sv(a.length));zob(b,a);return b} + function B2b(a,b){a.b+=b.b;a.c+=b.c;a.d+=b.d;a.a+=b.a;return a} + function qmb(a,b){if(kmb(a,b)){Jmb(a);return true}return false} + function qC(a,b){if(b==null){throw Adb(new Ngb)}return rC(a,b)} + function nB(a,b){var c;c=a.q.getHours();a.q.setDate(b);mB(a,c);} + function Xvd(a,b,c){var d;d=a.Ih(b);d>=0?a.bi(d,c):Svd(a,b,c);} + function Lvd(a,b){var c;c=a.Ih(b);return c>=0?a.Wh(c):Rvd(a,b)} + function zo(a,b){var c;Qb(b);for(c=a.a;c;c=c.c){b.Yd(c.g,c.i);}} + function pMc(a,b,c){var d;d=qMc(a,b,c);a.b=new _Lc(d.c.length);} + function HId(a,b,c){EId();!!a&&Zjb(DId,a,b);!!a&&Zjb(CId,a,c);} + function bfc(a,b){Rec();return Geb(),RD(b.a,17).a0} + function sId(a){var b;b=a.d;b=a.bj(a.f);WGd(a,b);return b.Ob()} + function bHd(a,b){var c;c=new Kub(b);Ve(c,a);return new dnb(c)} + function qKd(a){if(a.p!=0)throw Adb(new cgb);return Pdb(a.f,0)} + function zKd(a){if(a.p!=0)throw Adb(new cgb);return Pdb(a.k,0)} + function gBd(a){if(a.Db>>16!=7)return null;return RD(a.Cb,241)} + function xXd(a){if(a.Db>>16!=6)return null;return RD(a.Cb,241)} + function dCd(a){if(a.Db>>16!=7)return null;return RD(a.Cb,167)} + function vCd(a){if(a.Db>>16!=11)return null;return RD(a.Cb,27)} + function uWd(a){if(a.Db>>16!=17)return null;return RD(a.Cb,29)} + function kVd(a){if(a.Db>>16!=3)return null;return RD(a.Cb,155)} + function BDb(a){var b;MCb(a);b=new _sb;return CDb(a,new aEb(b))} + function xfb(a,b){var c=a.a=a.a||[];return c[b]||(c[b]=a.ve(b))} + function qB(a,b){var c;c=a.q.getHours();a.q.setMonth(b);mB(a,c);} + function oz(a,b){ez(this);this.f=b;this.g=a;gz(this);this.je();} + function TQb(a,b){this.a=a;this.c=ajd(this.a);this.b=new Vid(b);} + function aGb(a,b,c){this.a=b;this.c=a;this.b=(Qb(c),new dnb(c));} + function s$b(a,b,c){this.a=b;this.c=a;this.b=(Qb(c),new dnb(c));} + function _Kc(a){this.a=a;this.b=$C(qY,Nve,2043,a.e.length,0,2);} + function fGb(){this.a=new Iub;this.e=new _sb;this.g=0;this.i=0;} + function EId(){EId=geb;DId=new Tsb;CId=new Tsb;IId(zK,new JId);} + function KFc(){KFc=geb;JFc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function RFc(){RFc=geb;QFc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function gGc(){gGc=geb;fGc=nfd(new ufd,(sXb(),rXb),(hcc(),$bc));} + function ANc(){ANc=geb;zNc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function dOc(){dOc=geb;cOc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function gQc(){gQc=geb;fQc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function WQc(){WQc=geb;VQc=pfd(new ufd,(sXb(),rXb),(hcc(),ybc));} + function dZd(a,b,c,d,e,f){return new P3d(a.e,b,a.Lj(),c,d,e,f)} + function $jb(a,b,c){return b==null?rtb(a.f,null,c):Ltb(a.i,b,c)} + function Y0b(a,b){!!a.c&&Ymb(a.c.g,a);a.c=b;!!a.c&&Rmb(a.c.g,a);} + function g3b(a,b){!!a.c&&Ymb(a.c.a,a);a.c=b;!!a.c&&Rmb(a.c.a,a);} + function P3b(a,b){!!a.i&&Ymb(a.i.j,a);a.i=b;!!a.i&&Rmb(a.i.j,a);} + function Z0b(a,b){!!a.d&&Ymb(a.d.e,a);a.d=b;!!a.d&&Rmb(a.d.e,a);} + function _Sc(a,b){!!a.a&&Ymb(a.a.k,a);a.a=b;!!a.a&&Rmb(a.a.k,a);} + function aTc(a,b){!!a.b&&Ymb(a.b.f,a);a.b=b;!!a.b&&Rmb(a.b.f,a);} + function Odd(a,b){Pdd(a,a.b,a.c);RD(a.b.b,68);!!b&&RD(b.b,68).b;} + function j2c(a,b){return Qfb(RD(a.c,65).c.e.b,RD(b.c,65).c.e.b)} + function k2c(a,b){return Qfb(RD(a.c,65).c.e.a,RD(b.c,65).c.e.a)} + function YXb(a){NXb();return Geb(),RD(a.a,86).d.e!=0?true:false} + function LXd(a,b){ZD(a.Cb,184)&&(RD(a.Cb,184).tb=null);PAd(a,b);} + function CWd(a,b){ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),4);PAd(a,b);} + function _5d(a,b){a6d(a,b);ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),2);} + function JFd(a,b){var c,d;c=b.c;d=c!=null;d&&oDd(a,new OC(b.c));} + function v0d(a){var b,c;c=(jTd(),b=new s2d,b);l2d(c,a);return c} + function E4d(a){var b,c;c=(jTd(),b=new s2d,b);l2d(c,a);return c} + function Fr(a){var b;while(true){b=a.Pb();if(!a.Ob()){return b}}} + function nq(a,b,c){Rmb(a.a,(fn(),ck(b,c),new gp(b,c)));return a} + function rge(a,b){return nke(),wWd(b)?new ole(b,a):new Eke(b,a)} + function ojb(a){Pib();return Ddb(a,0)>=0?jjb(a):Xib(jjb(Odb(a)))} + function Asb(a){var b;b=RD(UEb(a.b),9);return new Fsb(a.a,b,a.c)} + function Qw(a,b){var c;c=RD(Xv(nd(a.a),b),16);return !c?0:c.gc()} + function Zmb(a,b,c){var d;xFb(b,c,a.c.length);d=c-b;$Eb(a.c,b,d);} + function Rkb(a,b,c){xFb(b,c,a.gc());this.c=a;this.a=b;this.b=c-b;} + function fgd(a){this.c=new Yub;this.b=a.b;this.d=a.c;this.a=a.a;} + function qjd(a){this.a=$wnd.Math.cos(a);this.b=$wnd.Math.sin(a);} + function bTc(a,b,c,d){this.c=a;this.d=d;_Sc(this,b);aTc(this,c);} + function Si(a,b){Qi.call(this,new Usb(Sv(a)));dk(b,Mve);this.a=b;} + function Ryb(a,b,c){return new Kzb(a,(cAb(),_zb),null,false,b,c)} + function czb(a,b,c){return new Kzb(a,(cAb(),bAb),b,c,null,false)} + function ABb(){xBb();return cD(WC(QL,1),jwe,108,0,[uBb,vBb,wBb])} + function yLb(){vLb();return cD(WC(TN,1),jwe,472,0,[uLb,tLb,sLb])} + function HKb(){EKb();return cD(WC(MN,1),jwe,471,0,[CKb,BKb,DKb])} + function aKb(){ZJb();return cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])} + function DWb(){AWb();return cD(WC(JP,1),jwe,391,0,[yWb,xWb,zWb])} + function moc(){joc();return cD(WC(UV,1),jwe,372,0,[ioc,hoc,goc])} + function ytc(){stc();return cD(WC(_W,1),jwe,322,0,[qtc,ptc,rtc])} + function Htc(){Etc();return cD(WC(aX,1),jwe,351,0,[Btc,Dtc,Ctc])} + function kuc(){huc();return cD(WC(dX,1),jwe,460,0,[fuc,euc,guc])} + function Avc(){xvc();return cD(WC(jX,1),jwe,299,0,[vvc,wvc,uvc])} + function Jvc(){Gvc();return cD(WC(kX,1),jwe,311,0,[Evc,Fvc,Dvc])} + function pDc(){lDc();return cD(WC(sX,1),jwe,390,0,[iDc,jDc,kDc])} + function EEc(){BEc();return cD(WC(yX,1),jwe,463,0,[AEc,yEc,zEc])} + function NEc(){KEc();return cD(WC(zX,1),jwe,387,0,[HEc,IEc,JEc])} + function WEc(){TEc();return cD(WC(AX,1),jwe,349,0,[SEc,QEc,REc])} + function oFc(){lFc();return cD(WC(CX,1),jwe,350,0,[iFc,jFc,kFc])} + function xFc(){uFc();return cD(WC(DX,1),jwe,352,0,[tFc,rFc,sFc])} + function GFc(){DFc();return cD(WC(EX,1),jwe,388,0,[BFc,CFc,AFc])} + function UKc(){RKc();return cD(WC(nY,1),jwe,464,0,[OKc,PKc,QKc])} + function K3b(a){return xjd(cD(WC(l3,1),Nve,8,0,[a.i.n,a.n,a.a]))} + function OZc(){LZc();return cD(WC(F_,1),jwe,392,0,[KZc,JZc,IZc])} + function H_c(){H_c=geb;G_c=nfd(new ufd,(YVc(),WVc),(WYc(),MYc));} + function A_c(){A_c=geb;z_c=new B_c('DFS',0);y_c=new B_c('BFS',1);} + function TQc(a,b,c){var d;d=new SQc;d.b=b;d.a=c;++b.b;Rmb(a.d,d);} + function NTb(a,b,c){var d;d=new sjd(c.d);$id(d,a);CGd(b,d.a,d.b);} + function Nwb(a,b){Mwb(a,Ydb(Cdb(Tdb(b,24),Pxe)),Ydb(Cdb(b,Pxe)));} + function wFb(a,b){if(a<0||a>b){throw Adb(new veb(cye+a+dye+b))}} + function tFb(a,b){if(a<0||a>=b){throw Adb(new veb(cye+a+dye+b))}} + function BFb(a,b){if(a<0||a>=b){throw Adb(new eib(cye+a+dye+b))}} + function Swb(a,b){this.b=(uFb(a),a);this.a=(b&qxe)==0?b|64|Ove:b;} + function ODb(a){var b;MCb(a);b=(urb(),urb(),srb);return PDb(a,b)} + function R9c(a,b,c){var d;d=S9c(a,b,false);return d.b<=b&&d.a<=c} + function h9c(){b9c();return cD(WC(o1,1),jwe,439,0,[$8c,a9c,_8c])} + function c7c(){_6c();return cD(WC(a1,1),jwe,394,0,[Z6c,$6c,Y6c])} + function i6c(){f6c();return cD(WC(V0,1),jwe,445,0,[c6c,d6c,e6c])} + function D6c(){z6c();return cD(WC(Z0,1),jwe,456,0,[w6c,y6c,x6c])} + function k4c(){g4c();return cD(WC(I0,1),jwe,393,0,[d4c,e4c,f4c])} + function x5c(){t5c();return cD(WC(N0,1),jwe,300,0,[r5c,s5c,q5c])} + function Ind(){Fnd();return cD(WC(y3,1),jwe,346,0,[Dnd,Cnd,End])} + function jbd(){gbd();return cD(WC(I1,1),jwe,444,0,[dbd,ebd,fbd])} + function Rmd(){Omd();return cD(WC(t3,1),jwe,278,0,[Lmd,Mmd,Nmd])} + function pqd(){mqd();return cD(WC(J3,1),jwe,280,0,[kqd,jqd,lqd])} + function bv(a){Qb(a);return ZD(a,16)?new dnb(RD(a,16)):cv(a.Kc())} + function Hz(a,b){return !!a&&!!a.equals?a.equals(b):dE(a)===dE(b)} + function Cdb(a,b){return Edb(tD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function Rdb(a,b){return Edb(zD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function $db(a,b){return Edb(HD(Kdb(a)?Wdb(a):a,Kdb(b)?Wdb(b):b))} + function xs(a,b){var c;c=(uFb(a),a).g;lFb(!!c);uFb(b);return c(b)} + function rv(a,b){var c,d;d=tv(a,b);c=a.a.fd(d);return new Gv(a,c)} + function CXd(a){if(a.Db>>16!=6)return null;return RD(yvd(a),241)} + function sKd(a){if(a.p!=2)throw Adb(new cgb);return Ydb(a.f)&Bwe} + function BKd(a){if(a.p!=2)throw Adb(new cgb);return Ydb(a.k)&Bwe} + function ynb(a){sFb(a.ad?1:0} + function Hmc(a,b){var c,d;c=Gmc(b);d=c;return RD(Wjb(a.c,d),17).a} + function CMc(a,b,c){var d;d=a.d[b.p];a.d[b.p]=a.d[c.p];a.d[c.p]=d;} + function Jqd(a,b,c){var d;if(a.n&&!!b&&!!c){d=new otd;Rmb(a.e,d);}} + function gYb(a,b){Ysb(a.a,b);if(b.d){throw Adb(new yz(jye))}b.d=a;} + function Had(a,b){this.a=new bnb;this.d=new bnb;this.f=a;this.c=b;} + function RWb(){this.c=new dXb;this.a=new I_b;this.b=new E0b;g0b();} + function med(){hed();this.b=new Tsb;this.a=new Tsb;this.c=new bnb;} + function KKd(a,b,c){this.d=a;this.j=b;this.e=c;this.o=-1;this.p=3;} + function LKd(a,b,c){this.d=a;this.k=b;this.f=c;this.o=-1;this.p=5;} + function S3d(a,b,c,d,e,f){R3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function U3d(a,b,c,d,e,f){T3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function W3d(a,b,c,d,e,f){V3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function Y3d(a,b,c,d,e,f){X3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function $3d(a,b,c,d,e,f){Z3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function a4d(a,b,c,d,e,f){_3d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function f4d(a,b,c,d,e,f){e4d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function h4d(a,b,c,d,e,f){g4d.call(this,a,b,c,d,e);f&&(this.o=-2);} + function N7d(a,b,c,d){t7d.call(this,c);this.b=a;this.c=b;this.d=d;} + function mfe(a,b){this.f=a;this.a=(ree(),pee);this.c=pee;this.b=b;} + function Jfe(a,b){this.g=a;this.d=(ree(),qee);this.a=qee;this.b=b;} + function Gme(a,b){!a.c&&(a.c=new Uge(a,0));Fge(a.c,(nme(),fme),b);} + function Oge(a,b){return Pge(a,b,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function lB(a,b){return Agb(Hdb(a.q.getTime()),Hdb(b.q.getTime()))} + function gj(a){return fk(a.e.Rd().gc()*a.c.Rd().gc(),16,new qj(a))} + function CYd(a){return !!a.u&&tYd(a.u.a).i!=0&&!(!!a.n&&d$d(a.n))} + function p4d(a){return !!a.a&&o4d(a.a.a).i!=0&&!(!!a.b&&o5d(a.b))} + function Cxd(a,b){if(b==0){return !!a.o&&a.o.f!=0}return Kvd(a,b)} + function Cc(a,b,c){var d;d=RD(a.Zb().xc(b),16);return !!d&&d.Hc(c)} + function Gc(a,b,c){var d;d=RD(a.Zb().xc(b),16);return !!d&&d.Mc(c)} + function _yb(a,b){var c;c=1-b;a.a[c]=azb(a.a[c],c);return azb(a,b)} + function DFb(a,b){var c,d;d=Cdb(a,yxe);c=Sdb(b,32);return Rdb(c,d)} + function bGb(a,b,c){var d;d=(Qb(a),new dnb(a));_Fb(new aGb(d,b,c));} + function t$b(a,b,c){var d;d=(Qb(a),new dnb(a));r$b(new s$b(d,b,c));} + function vBd(a,b,c,d,e,f){wBd(a,b,c,f);EYd(a,d);FYd(a,e);return a} + function Xhb(a,b,c,d){a.a+=''+zhb(b==null?vve:jeb(b),c,d);return a} + function Jkb(a,b){this.a=a;Dkb.call(this,a);wFb(b,a.gc());this.b=b;} + function xmb(a){this.a=$C(jJ,rve,1,mgb($wnd.Math.max(8,a))<<1,5,1);} + function t2b(a){return RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199)} + function s2b(a){return RD(anb(a,$C(WQ,VAe,18,a.c.length,0,1)),483)} + function Iyb(a){return !a.a?a.c:a.e.length==0?a.a.a:a.a.a+(''+a.e)} + function Rib(a){while(a.d>0&&a.a[--a.d]==0);a.a[a.d++]==0&&(a.e=0);} + function fvb(a){sFb(a.b.b!=a.d.a);a.c=a.b=a.b.b;--a.a;return a.c.c} + function sRc(a,b,c){a.a=b;a.c=c;a.b.a.$b();Xub(a.d);aFb(a.e.a.c,0);} + function Z5c(a,b){var c;a.e=new R5c;c=Q2c(b);_mb(c,a.c);$5c(a,c,0);} + function zgd(a,b,c,d){var e;e=new Hgd;e.a=b;e.b=c;e.c=d;Mub(a.a,e);} + function Agd(a,b,c,d){var e;e=new Hgd;e.a=b;e.b=c;e.c=d;Mub(a.b,e);} + function Tb(a,b,c){if(a<0||bc){throw Adb(new veb(Kb(a,b,c)))}} + function Pb(a,b){if(a<0||a>=b){throw Adb(new veb(Ib(a,b)))}return a} + function qz(b){if(!('stack' in b)){try{throw b}catch(a){}}return b} + function Zjc(a){Wjc();if(ZD(a.g,10)){return RD(a.g,10)}return null} + function nx(a){if(Ih(a).dc()){return false}Jh(a,new rx);return true} + function Xdb(a){var b;if(Kdb(a)){b=a;return b==-0.?0:b}return ED(a)} + function lkb(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function gsb(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function vub(a,b){if(ZD(b,44)){return Jd(a.a,RD(b,44))}return false} + function RCb(a){var b;LCb(a);b=new Prb;ixb(a.a,new fDb(b));return b} + function Vae(){var a,b,c;b=(c=(a=new s2d,a),c);Rmb(Rae,b);return b} + function mDb(a){var b;LCb(a);b=new ltb;ixb(a.a,new uDb(b));return b} + function jDb(a,b){if(a.a<=a.b){b.Dd(a.a++);return true}return false} + function xzb(a){yzb.call(this,a,(cAb(),$zb),null,false,null,false);} + function $Rb(){$Rb=geb;ZRb=ss((VRb(),cD(WC($O,1),jwe,489,0,[URb])));} + function CHc(){CHc=geb;BHc=yx(sgb(1),sgb(4));AHc=yx(sgb(1),sgb(2));} + function yXc(a,b){return new gud(b,njd(ajd(b.e),a,a),(Geb(),true))} + function fv(a){return new cnb((dk(a,lwe),dz(Bdb(Bdb(5,a),a/10|0))))} + function Wi(a){return fk(a.e.Rd().gc()*a.c.Rd().gc(),273,new kj(a))} + function u2b(a){return RD(anb(a,$C(xR,XAe,12,a.c.length,0,1)),2042)} + function COc(a){dOc();return !W0b(a)&&!(!W0b(a)&&a.c.i.c==a.d.i.c)} + function Y_c(a,b){R_c();return RD(mQb(b,(h_c(),W$c)),17).a>=a.gc()} + function q8b(a,b){w8b(b,a);y8b(a.d);y8b(RD(mQb(a,(yCc(),cBc)),214));} + function r8b(a,b){z8b(b,a);B8b(a.d);B8b(RD(mQb(a,(yCc(),cBc)),214));} + function $0b(a,b,c){!!a.d&&Ymb(a.d.e,a);a.d=b;!!a.d&&Qmb(a.d.e,c,a);} + function jPb(a,b,c){return c.f.c.length>0?yPb(a.a,b,c):yPb(a.b,b,c)} + function Uz(a,b,c){var d;d=Sz();try{return Rz(a,b,c)}finally{Vz(d);}} + function wDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=c.pe());return d} + function yDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=c.se());return d} + function xDd(a,b){var c,d;c=JB(a,b);d=null;!!c&&(d=c.se());return d} + function zDd(a,b){var c,d;c=qC(a,b);d=null;!!c&&(d=ADd(c));return d} + function rEd(a,b,c){var d;d=uDd(c);Do(a.g,d,b);Do(a.i,b,c);return b} + function UIc(a,b,c){this.d=new fJc(this);this.e=a;this.i=b;this.f=c;} + function Mk(a,b,c,d){this.e=null;this.c=a;this.d=b;this.a=c;this.b=d;} + function urc(a,b,c,d){nrc(this);this.c=a;this.e=b;this.f=c;this.b=d;} + function MKd(a,b,c,d){this.d=a;this.n=b;this.g=c;this.o=d;this.p=-1;} + function Vc(a,b,c,d){return ZD(c,59)?new Kg(a,b,c,d):new yg(a,b,c,d)} + function gr(a){if(ZD(a,16)){return RD(a,16).dc()}return !a.Kc().Ob()} + function Wo(a){if(a.e.g!=a.b){throw Adb(new Jrb)}return !!a.c&&a.d>0} + function evb(a){sFb(a.b!=a.d.c);a.c=a.b;a.b=a.b.a;++a.a;return a.c.c} + function imb(a,b){uFb(b);bD(a.a,a.c,b);a.c=a.c+1&a.a.length-1;mmb(a);} + function hmb(a,b){uFb(b);a.b=a.b-1&a.a.length-1;bD(a.a,a.b,b);mmb(a);} + function _je(a){var b;b=a.Gh();this.a=ZD(b,71)?RD(b,71).Ii():b.Kc();} + function px(a){return new Swb(Dob(RD(a.a.md(),16).gc(),a.a.ld()),16)} + function Abd(){Abd=geb;zbd=ss((sbd(),cD(WC(M1,1),jwe,490,0,[rbd])));} + function Jbd(){Jbd=geb;Ibd=ss((Cbd(),cD(WC(N1,1),jwe,558,0,[Bbd])));} + function idd(){idd=geb;hdd=ss((_cd(),cD(WC(V1,1),jwe,539,0,[$cd])));} + function X$b(){U$b();return cD(WC(CQ,1),jwe,389,0,[T$b,R$b,Q$b,S$b])} + function hAb(){cAb();return cD(WC(AL,1),jwe,304,0,[$zb,_zb,aAb,bAb])} + function LPb(){IPb();return cD(WC(DO,1),jwe,332,0,[FPb,EPb,GPb,HPb])} + function LRb(){IRb();return cD(WC(WO,1),jwe,406,0,[FRb,ERb,GRb,HRb])} + function pOb(){mOb();return cD(WC(hO,1),jwe,417,0,[lOb,iOb,jOb,kOb])} + function uZb(){nZb();return cD(WC(lQ,1),jwe,416,0,[jZb,mZb,kZb,lZb])} + function hnc(){enc();return cD(WC(LV,1),jwe,421,0,[anc,bnc,cnc,dnc])} + function zec(){vec();return cD(WC(qT,1),jwe,371,0,[uec,sec,tec,rec])} + function BDc(){wDc();return cD(WC(tX,1),jwe,203,0,[uDc,vDc,tDc,sDc])} + function nEc(){kEc();return cD(WC(wX,1),jwe,284,0,[hEc,gEc,iEc,jEc])} + function Unc(a){var b;return a.j==(qpd(),npd)&&(b=Vnc(a),Csb(b,Xod))} + function qhc(a,b){var c;c=b.a;Y0b(c,b.c.d);Z0b(c,b.d.d);Cjd(c.a,a.n);} + function _5b(a,b){var c;c=RD(cub(a.b,b),67);!c&&(c=new Yub);return c} + function $jc(a){Wjc();if(ZD(a.g,154)){return RD(a.g,154)}return null} + function gRc(a){a.a=null;a.e=null;aFb(a.b.c,0);aFb(a.f.c,0);a.c=null;} + function Ovc(){Ovc=geb;Mvc=new Pvc(Kye,0);Nvc=new Pvc('TOP_LEFT',1);} + function sNc(){sNc=geb;rNc=new tNc('UPPER',0);qNc=new tNc('LOWER',1);} + function nWc(a,b){return cjd(new rjd(b.e.a+b.f.a/2,b.e.b+b.f.b/2),a)} + function wqc(a,b){return RD(Lvb(JDb(RD(Qc(a.k,b),15).Oc(),lqc)),113)} + function xqc(a,b){return RD(Lvb(KDb(RD(Qc(a.k,b),15).Oc(),lqc)),113)} + function cWc(){YVc();return cD(WC(H$,1),jwe,405,0,[UVc,VVc,WVc,XVc])} + function v_c(){s_c();return cD(WC(J_,1),jwe,353,0,[r_c,p_c,q_c,o_c])} + function n5c(){j5c();return cD(WC(M0,1),jwe,354,0,[i5c,g5c,h5c,f5c])} + function Tpd(){Qpd();return cD(WC(H3,1),jwe,386,0,[Opd,Ppd,Npd,Mpd])} + function Tnd(){Pnd();return cD(WC(z3,1),jwe,291,0,[Ond,Lnd,Mnd,Nnd])} + function _md(){Ymd();return cD(WC(u3,1),jwe,223,0,[Xmd,Vmd,Umd,Wmd])} + function Jrd(){Grd();return cD(WC(R3,1),jwe,320,0,[Frd,Crd,Erd,Drd])} + function wtd(){ttd();return cD(WC(n4,1),jwe,415,0,[qtd,rtd,ptd,std])} + function GId(a){EId();return Ujb(DId,a)?RD(Wjb(DId,a),341).Qg():null} + function Avd(a,b,c){return b<0?Rvd(a,c):RD(c,69).wk().Bk(a,a.hi(),b)} + function sEd(a,b,c){var d;d=uDd(c);Do(a.j,d,b);Zjb(a.k,b,c);return b} + function qEd(a,b,c){var d;d=uDd(c);Do(a.d,d,b);Zjb(a.e,b,c);return b} + function DGd(a){var b,c;b=(bvd(),c=new rzd,c);!!a&&pzd(b,a);return b} + function WHd(a){var b;b=a.aj(a.i);a.i>0&&hib(a.g,0,b,0,a.i);return b} + function Led(a,b){var c;for(c=a.j.c.length;c>24} + function AKd(a){if(a.p!=1)throw Adb(new cgb);return Ydb(a.k)<<24>>24} + function GKd(a){if(a.p!=7)throw Adb(new cgb);return Ydb(a.k)<<16>>16} + function xKd(a){if(a.p!=7)throw Adb(new cgb);return Ydb(a.f)<<16>>16} + function Wib(a,b){if(b.e==0||a.e==0){return Oib}return Ljb(),Mjb(a,b)} + function Nd(a,b){return dE(b)===dE(a)?'(this Map)':b==null?vve:jeb(b)} + function MFb(a,b,c){return Jfb(UD(Wd(qtb(a.f,b))),UD(Wd(qtb(a.f,c))))} + function wkc(a,b,c){var d;d=RD(Wjb(a.g,c),60);Rmb(a.a.c,new Ptd(b,d));} + function Slc(a,b,c){a.i=0;a.e=0;if(b==c){return}Rlc(a,b,c);Qlc(a,b,c);} + function rTc(a,b,c,d,e){var f;f=mTc(e,c,d);Rmb(b,TSc(e,f));vTc(a,e,b);} + function Jrc(a,b,c,d,e){this.i=a;this.a=b;this.e=c;this.j=d;this.f=e;} + function iUb(a,b){VTb.call(this);this.a=a;this.b=b;Rmb(this.a.b,this);} + function rTb(a){this.b=new Tsb;this.c=new Tsb;this.d=new Tsb;this.a=a;} + function Dx(a,b){var c;c=new cib;a.Gd(c);c.a+='..';b.Hd(c);return c.a} + function Fsd(a,b){var c;c=b;while(c){Zid(a,c.i,c.j);c=vCd(c);}return a} + function pEd(a,b,c){var d;d=uDd(c);Zjb(a.b,d,b);Zjb(a.c,b,c);return b} + function Kr(a){var b;b=0;while(a.Ob()){a.Pb();b=Bdb(b,1);}return dz(b)} + function oke(a,b){nke();var c;c=RD(a,69).vk();K6d(c,b);return c.xl(b)} + function tC(d,a,b){if(b){var c=b.oe();d.a[a]=c(b);}else {delete d.a[a];}} + function tB(a,b){var c;c=a.q.getHours();a.q.setFullYear(b+Owe);mB(a,c);} + function KSd(a,b){return RD(b==null?Wd(qtb(a.f,null)):Ktb(a.i,b),288)} + function hOc(a,b){return a==(r3b(),p3b)&&b==p3b?4:a==p3b||b==p3b?8:32} + function cge(a,b,c){return dge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function jge(a,b,c){return kge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function Qge(a,b,c){return Rge(a,b,c,ZD(b,102)&&(RD(b,19).Bb&txe)!=0)} + function jmb(a){if(a.b==a.c){return}a.a=$C(jJ,rve,1,8,5,1);a.b=0;a.c=0;} + function Nsb(a){sFb(a.a=0&&a.a[c]===b[c];c--);return c<0} + function Xx(a){var b;if(a){return new Kub(a)}b=new Iub;_q(b,a);return b} + function nmc(a,b){var c,d;d=false;do{c=qmc(a,b);d=d|c;}while(c);return d} + function Vz(a){a&&aA(($z(),Zz));--Nz;if(a){if(Pz!=-1){Xz(Pz);Pz=-1;}}} + function Pwb(a){Hwb();Mwb(this,Ydb(Cdb(Tdb(a,24),Pxe)),Ydb(Cdb(a,Pxe)));} + function IHb(){IHb=geb;HHb=ss((DHb(),cD(WC(uN,1),jwe,436,0,[CHb,BHb])));} + function QHb(){QHb=geb;PHb=ss((LHb(),cD(WC(vN,1),jwe,435,0,[JHb,KHb])));} + function YUb(){YUb=geb;XUb=ss((TUb(),cD(WC(BP,1),jwe,432,0,[RUb,SUb])));} + function U8b(){U8b=geb;T8b=ss((P8b(),cD(WC(vS,1),jwe,517,0,[O8b,N8b])));} + function Tvc(){Tvc=geb;Svc=ss((Ovc(),cD(WC(lX,1),jwe,429,0,[Mvc,Nvc])));} + function duc(){duc=geb;cuc=ss(($tc(),cD(WC(cX,1),jwe,428,0,[Ytc,Ztc])));} + function Huc(){Huc=geb;Guc=ss((Cuc(),cD(WC(fX,1),jwe,488,0,[Buc,Auc])));} + function xEc(){xEc=geb;wEc=ss((sEc(),cD(WC(xX,1),jwe,430,0,[qEc,rEc])));} + function xNc(){xNc=geb;wNc=ss((sNc(),cD(WC(MY,1),jwe,531,0,[rNc,qNc])));} + function otc(){otc=geb;ntc=ss((jtc(),cD(WC($W,1),jwe,431,0,[htc,itc])));} + function F_c(){F_c=geb;E_c=ss((A_c(),cD(WC(K_,1),jwe,433,0,[z_c,y_c])));} + function F2c(){F2c=geb;E2c=ss((x2c(),cD(WC(s0,1),jwe,501,0,[v2c,w2c])));} + function BQc(){BQc=geb;AQc=ss((wQc(),cD(WC(FZ,1),jwe,523,0,[vQc,uQc])));} + function JQc(){JQc=geb;IQc=ss((EQc(),cD(WC(GZ,1),jwe,522,0,[CQc,DQc])));} + function kTc(){kTc=geb;jTc=ss((fTc(),cD(WC(b$,1),jwe,528,0,[eTc,dTc])));} + function iVc(){iVc=geb;hVc=ss((dVc(),cD(WC(w$,1),jwe,465,0,[bVc,cVc])));} + function c4c(){c4c=geb;b4c=ss((Y3c(),cD(WC(H0,1),jwe,434,0,[W3c,X3c])));} + function H8c(){H8c=geb;G8c=ss((z8c(),cD(WC(l1,1),jwe,491,0,[x8c,y8c])));} + function J9c(){J9c=geb;I9c=ss((B9c(),cD(WC(t1,1),jwe,492,0,[z9c,A9c])));} + function Rbd(){Rbd=geb;Qbd=ss((Mbd(),cD(WC(O1,1),jwe,438,0,[Lbd,Kbd])));} + function tdd(){tdd=geb;sdd=ss((ldd(),cD(WC(W1,1),jwe,437,0,[kdd,jdd])));} + function Eqd(){Eqd=geb;Dqd=ss((uqd(),cD(WC(M3,1),jwe,347,0,[sqd,tqd])));} + function Imd(){Cmd();return cD(WC(s3,1),jwe,88,0,[Amd,zmd,ymd,xmd,Bmd])} + function xpd(){qpd();return cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])} + function LSd(a,b,c){return RD(b==null?rtb(a.f,null,c):Ltb(a.i,b,c),288)} + function L6b(a){return (a.k==(r3b(),p3b)||a.k==m3b)&&nQb(a,(Ywc(),cwc))} + function bUb(a){return !!a.c&&!!a.d?kUb(a.c)+'->'+kUb(a.d):'e_'+kFb(a)} + function xgb(a,b){var c,d;uFb(b);for(d=a.Kc();d.Ob();){c=d.Pb();b.Cd(c);}} + function jEd(a,b){var c;c=new uC;qDd(c,'x',b.a);qDd(c,'y',b.b);oDd(a,c);} + function mEd(a,b){var c;c=new uC;qDd(c,'x',b.a);qDd(c,'y',b.b);oDd(a,c);} + function Gsd(a,b){var c;c=b;while(c){Zid(a,-c.i,-c.j);c=vCd(c);}return a} + function ZLc(a,b){var c,d;c=b;d=0;while(c>0){d+=a.a[c];c-=c&-c;}return d} + function $mb(a,b,c){var d;d=(tFb(b,a.c.length),a.c[b]);a.c[b]=c;return d} + function uIc(a,b,c){a.a.c.length=0;yIc(a,b,c);a.a.c.length==0||rIc(a,b);} + function wo(a){a.i=0;Mnb(a.b,null);Mnb(a.c,null);a.a=null;a.e=null;++a.g;} + function gBb(){gBb=geb;dBb=true;bBb=false;cBb=false;fBb=false;eBb=false;} + function oBb(a){gBb();if(dBb){return}this.c=a;this.e=true;this.a=new bnb;} + function kDb(a,b){this.c=0;this.b=b;txb.call(this,a,17493);this.a=this.c;} + function S_b(a){P_b();A$b(this);this.a=new Yub;Q_b(this,a);Mub(this.a,a);} + function m_b(){Pmb(this);this.b=new rjd(oxe,oxe);this.a=new rjd(pxe,pxe);} + function z8c(){z8c=geb;x8c=new B8c(CBe,0);y8c=new B8c('TARGET_WIDTH',1);} + function yDb(a,b){return (MCb(a),QDb(new SDb(a,new hEb(b,a.a)))).Bd(wDb)} + function vXb(){sXb();return cD(WC(UP,1),jwe,367,0,[nXb,oXb,pXb,qXb,rXb])} + function Fnc(){Bnc();return cD(WC(TV,1),jwe,375,0,[xnc,znc,Anc,ync,wnc])} + function Vtc(){Ptc();return cD(WC(bX,1),jwe,348,0,[Ltc,Ktc,Ntc,Otc,Mtc])} + function PDc(){JDc();return cD(WC(uX,1),jwe,323,0,[IDc,FDc,GDc,EDc,HDc])} + function fxc(){cxc();return cD(WC(mX,1),jwe,171,0,[bxc,Zwc,$wc,_wc,axc])} + function k3c(){g3c();return cD(WC(x0,1),jwe,368,0,[e3c,b3c,f3c,c3c,d3c])} + function vad(){sad();return cD(WC(x1,1),jwe,373,0,[oad,nad,qad,pad,rad])} + function $bd(){Xbd();return cD(WC(P1,1),jwe,324,0,[Sbd,Tbd,Wbd,Ubd,Vbd])} + function _hd(){Yhd();return cD(WC(d3,1),jwe,170,0,[Whd,Vhd,Thd,Xhd,Uhd])} + function sod(){pod();return cD(WC(B3,1),jwe,256,0,[mod,ood,kod,lod,nod])} + function Tz(b){Qz();return function(){return Uz(b,this,arguments);}} + function W0b(a){if(!a.c||!a.d){return false}return !!a.c.i&&a.c.i==a.d.i} + function Nfd(a,b){if(ZD(b,143)){return lhb(a.c,RD(b,143).c)}return false} + function yYd(a){if(!a.t){a.t=new w$d(a);VGd(new Cde(a),0,a.t);}return a.t} + function jNd(a){this.b=a;dMd.call(this,a);this.a=RD(Ywd(this.b.a,4),129);} + function sNd(a){this.b=a;yMd.call(this,a);this.a=RD(Ywd(this.b.a,4),129);} + function Q3d(a,b,c,d,e){OKd.call(this,b,d,e);this.c=a;this.b=c;} + function V3d(a,b,c,d,e){KKd.call(this,b,d,e);this.c=a;this.a=c;} + function Z3d(a,b,c,d,e){LKd.call(this,b,d,e);this.c=a;this.a=c;} + function g4d(a,b,c,d,e){OKd.call(this,b,d,e);this.c=a;this.a=c;} + function ugd(a,b){var c;c=RD(cub(a.d,b),23);return c?c:RD(cub(a.e,b),23)} + function Blb(a,b){var c,d;c=b.ld();d=a.Fe(c);return !!d&&Fvb(d.e,b.md())} + function me(a,b){var c;c=b.ld();return new gp(c,a.e.pc(c,RD(b.md(),16)))} + function ptb(a,b){var c;c=a.a.get(b);return c==null?$C(jJ,rve,1,0,5,1):c} + function khb(a){var b;b=a.length;return lhb(sxe.substr(sxe.length-b,b),a)} + function hs(a){if(gs(a)){a.c=a.a;return a.a.Pb()}else {throw Adb(new Dvb)}} + function $ib(a,b){if(b==0||a.e==0){return a}return b>0?tjb(a,b):qjb(a,-b)} + function Zib(a,b){if(b==0||a.e==0){return a}return b>0?qjb(a,b):tjb(a,-b)} + function Deb(a){Beb.call(this,a==null?vve:jeb(a),ZD(a,82)?RD(a,82):null);} + function Y5d(a){var b;if(!a.c){b=a.r;ZD(b,90)&&(a.c=RD(b,29));}return a.c} + function s0b(a){var b;b=new a1b;kQb(b,a);pQb(b,(yCc(),RAc),null);return b} + function lec(a){var b,c;b=a.c.i;c=a.d.i;return b.k==(r3b(),m3b)&&c.k==m3b} + function fD(a){var b,c,d;b=a&dxe;c=a>>22&dxe;d=a<0?exe:0;return hD(b,c,d)} + function Ky(a){var b,c,d,e;for(c=a,d=0,e=c.length;d=0?a.Lh(d,c,true):Qvd(a,b,c)} + function AXc(a,b,c){return Qfb(cjd(jWc(a),ajd(b.b)),cjd(jWc(a),ajd(c.b)))} + function BXc(a,b,c){return Qfb(cjd(jWc(a),ajd(b.e)),cjd(jWc(a),ajd(c.e)))} + function Kad(a,b){return $wnd.Math.min(bjd(b.a,a.d.d.c),bjd(b.b,a.d.d.c))} + function LHd(a,b){a._i(a.i+1);MHd(a,a.i,a.Zi(a.i,b));a.Mi(a.i++,b);a.Ni();} + function OHd(a){var b,c;++a.j;b=a.g;c=a.i;a.g=null;a.i=0;a.Oi(c,b);a.Ni();} + function yke(a,b,c){var d;d=new zke(a.a);Ld(d,a.a.a);rtb(d.f,b,c);a.a.a=d;} + function mKb(a,b,c,d){var e;for(e=0;eb){throw Adb(new veb(Jb(a,b,'index')))}return a} + function Xmb(a,b){var c;c=(tFb(b,a.c.length),a.c[b]);$Eb(a.c,b,1);return c} + function jhb(a,b){var c,d;c=(uFb(a),a);d=(uFb(b),b);return c==d?0:cb.p){return -1}return 0} + function hXd(a){var b;if(!a.a){b=a.r;ZD(b,156)&&(a.a=RD(b,156));}return a.a} + function iOd(a,b,c){var d;++a.e;--a.f;d=RD(a.d[b].gd(c),136);return d.md()} + function fd(a){var b,c;b=a.ld();c=RD(a.md(),16);return gk(c.Nc(),new jh(b))} + function oae(a,b){if(Ujb(a.a,b)){_jb(a.a,b);return true}else {return false}} + function Ui(a,b,c){Pb(b,a.e.Rd().gc());Pb(c,a.c.Rd().gc());return a.a[b][c]} + function _Uc(a,b,c){this.a=a;this.b=b;this.c=c;Rmb(a.t,this);Rmb(b.i,this);} + function lg(a,b,c,d){this.f=a;this.e=b;this.d=c;this.b=d;this.c=!d?null:d.d;} + function YWc(){this.b=new Yub;this.a=new Yub;this.b=new Yub;this.a=new Yub;} + function ree(){ree=geb;var a,b;pee=(jTd(),b=new k1d,b);qee=(a=new mXd,a);} + function UCb(a){var b;MCb(a);b=new $Cb(a,a.a.e,a.a.d|4);return new WCb(a,b)} + function ADb(a){var b;LCb(a);b=0;while(a.a.Bd(new MEb)){b=Bdb(b,1);}return b} + function zxb(a,b){uFb(b);if(a.c=0,'Initial capacity must not be negative');} + function rid(){rid=geb;qid=new jGd('org.eclipse.elk.labels.labelManager');} + function iec(){iec=geb;hec=new kGd('separateLayerConnections',(vec(),uec));} + function fTc(){fTc=geb;eTc=new gTc('REGULAR',0);dTc=new gTc('CRITICAL',1);} + function Mbd(){Mbd=geb;Lbd=new Nbd('FIXED',0);Kbd=new Nbd('CENTER_NODE',1);} + function jtc(){jtc=geb;htc=new ktc('QUADRATIC',0);itc=new ktc('SCANLINE',1);} + function Atc(){Atc=geb;ztc=ss((stc(),cD(WC(_W,1),jwe,322,0,[qtc,ptc,rtc])));} + function Jtc(){Jtc=geb;Itc=ss((Etc(),cD(WC(aX,1),jwe,351,0,[Btc,Dtc,Ctc])));} + function ooc(){ooc=geb;noc=ss((joc(),cD(WC(UV,1),jwe,372,0,[ioc,hoc,goc])));} + function muc(){muc=geb;luc=ss((huc(),cD(WC(dX,1),jwe,460,0,[fuc,euc,guc])));} + function Cvc(){Cvc=geb;Bvc=ss((xvc(),cD(WC(jX,1),jwe,299,0,[vvc,wvc,uvc])));} + function Lvc(){Lvc=geb;Kvc=ss((Gvc(),cD(WC(kX,1),jwe,311,0,[Evc,Fvc,Dvc])));} + function rDc(){rDc=geb;qDc=ss((lDc(),cD(WC(sX,1),jwe,390,0,[iDc,jDc,kDc])));} + function PEc(){PEc=geb;OEc=ss((KEc(),cD(WC(zX,1),jwe,387,0,[HEc,IEc,JEc])));} + function YEc(){YEc=geb;XEc=ss((TEc(),cD(WC(AX,1),jwe,349,0,[SEc,QEc,REc])));} + function GEc(){GEc=geb;FEc=ss((BEc(),cD(WC(yX,1),jwe,463,0,[AEc,yEc,zEc])));} + function qFc(){qFc=geb;pFc=ss((lFc(),cD(WC(CX,1),jwe,350,0,[iFc,jFc,kFc])));} + function zFc(){zFc=geb;yFc=ss((uFc(),cD(WC(DX,1),jwe,352,0,[tFc,rFc,sFc])));} + function IFc(){IFc=geb;HFc=ss((DFc(),cD(WC(EX,1),jwe,388,0,[BFc,CFc,AFc])));} + function QZc(){QZc=geb;PZc=ss((LZc(),cD(WC(F_,1),jwe,392,0,[KZc,JZc,IZc])));} + function m4c(){m4c=geb;l4c=ss((g4c(),cD(WC(I0,1),jwe,393,0,[d4c,e4c,f4c])));} + function z5c(){z5c=geb;y5c=ss((t5c(),cD(WC(N0,1),jwe,300,0,[r5c,s5c,q5c])));} + function k6c(){k6c=geb;j6c=ss((f6c(),cD(WC(V0,1),jwe,445,0,[c6c,d6c,e6c])));} + function F6c(){F6c=geb;E6c=ss((z6c(),cD(WC(Z0,1),jwe,456,0,[w6c,y6c,x6c])));} + function e7c(){e7c=geb;d7c=ss((_6c(),cD(WC(a1,1),jwe,394,0,[Z6c,$6c,Y6c])));} + function j9c(){j9c=geb;i9c=ss((b9c(),cD(WC(o1,1),jwe,439,0,[$8c,a9c,_8c])));} + function WKc(){WKc=geb;VKc=ss((RKc(),cD(WC(nY,1),jwe,464,0,[OKc,PKc,QKc])));} + function JKb(){JKb=geb;IKb=ss((EKb(),cD(WC(MN,1),jwe,471,0,[CKb,BKb,DKb])));} + function cKb(){cKb=geb;bKb=ss((ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])));} + function ALb(){ALb=geb;zLb=ss((vLb(),cD(WC(TN,1),jwe,472,0,[uLb,tLb,sLb])));} + function CBb(){CBb=geb;BBb=ss((xBb(),cD(WC(QL,1),jwe,108,0,[uBb,vBb,wBb])));} + function FWb(){FWb=geb;EWb=ss((AWb(),cD(WC(JP,1),jwe,391,0,[yWb,xWb,zWb])));} + function Knd(){Knd=geb;Jnd=ss((Fnd(),cD(WC(y3,1),jwe,346,0,[Dnd,Cnd,End])));} + function lbd(){lbd=geb;kbd=ss((gbd(),cD(WC(I1,1),jwe,444,0,[dbd,ebd,fbd])));} + function Tmd(){Tmd=geb;Smd=ss((Omd(),cD(WC(t3,1),jwe,278,0,[Lmd,Mmd,Nmd])));} + function rqd(){rqd=geb;qqd=ss((mqd(),cD(WC(J3,1),jwe,280,0,[kqd,jqd,lqd])));} + function Hxd(a,b){return !a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),QNd(a.o,b)} + function HMb(a,b){var c;if(a.C){c=RD(Vrb(a.b,b),127).n;c.d=a.C.d;c.a=a.C.a;}} + function F8b(a){var b,c,d,e;e=a.d;b=a.a;c=a.b;d=a.c;a.d=c;a.a=d;a.b=e;a.c=b;} + function cOd(a){!a.g&&(a.g=new hQd);!a.g.b&&(a.g.b=new ePd(a));return a.g.b} + function dOd(a){!a.g&&(a.g=new hQd);!a.g.c&&(a.g.c=new IPd(a));return a.g.c} + function lOd(a){!a.g&&(a.g=new hQd);!a.g.d&&(a.g.d=new kPd(a));return a.g.d} + function YNd(a){!a.g&&(a.g=new hQd);!a.g.a&&(a.g.a=new qPd(a));return a.g.a} + function B9d(a,b,c,d){!!c&&(d=c.Rh(b,BYd(c.Dh(),a.c.uk()),null,d));return d} + function C9d(a,b,c,d){!!c&&(d=c.Th(b,BYd(c.Dh(),a.c.uk()),null,d));return d} + function Cjb(a,b,c,d){var e;e=$C(kE,Pwe,28,b+1,15,1);Djb(e,a,b,c,d);return e} + function $C(a,b,c,d,e,f){var g;g=_C(e,d);e!=10&&cD(WC(a,f),b,c,e,g);return g} + function $fe(a,b,c){var d,e;e=new Phe(b,a);for(d=0;dc||b=0?a.Lh(c,true,true):Qvd(a,b,true)} + function gMc(a,b,c){var d;d=qMc(a,b,c);a.b=new _Lc(d.c.length);return iMc(a,d)} + function Pue(a){if(a.b<=0)throw Adb(new Dvb);--a.b;a.a-=a.c.c;return sgb(a.a)} + function PGd(a){var b;if(!a.a){throw Adb(new Evb)}b=a.a;a.a=vCd(a.a);return b} + function WDb(a){while(!a.a){if(!yEb(a.c,new $Db(a))){return false}}return true} + function Nr(a){var b;Qb(a);if(ZD(a,204)){b=RD(a,204);return b}return new Or(a)} + function Cfd(a){Afd();RD(a.of((umd(),Lld)),181).Fc((Pod(),Mod));a.qf(Kld,null);} + function Afd(){Afd=geb;xfd=new Gfd;zfd=new Ifd;yfd=yn((umd(),Kld),xfd,pld,zfd);} + function Y3c(){Y3c=geb;W3c=new $3c('LEAF_NUMBER',0);X3c=new $3c('NODE_SIZE',1);} + function YLc(a){a.a=$C(kE,Pwe,28,a.b+1,15,1);a.c=$C(kE,Pwe,28,a.b,15,1);a.d=0;} + function OZb(a,b){if(a.a.Ne(b.d,a.b)>0){Rmb(a.c,new fZb(b.c,b.d,a.d));a.b=b.d;}} + function NHd(a,b){if(a.g==null||b>=a.i)throw Adb(new yNd(b,a.i));return a.g[b]} + function P_d(a,b,c){gHd(a,c);if(c!=null&&!a.fk(c)){throw Adb(new yeb)}return c} + function dD(a,b){XC(b)!=10&&cD(rb(b),b.Sm,b.__elementTypeId$,XC(b),a);return a} + function Wnb(a,b,c,d){var e;d=(urb(),!d?rrb:d);e=a.slice(b,c);Xnb(e,a,b,c,-b,d);} + function zvd(a,b,c,d,e){return b<0?Qvd(a,c,d):RD(c,69).wk().yk(a,a.hi(),b,d,e)} + function J9b(a,b){return Qfb(Kfb(UD(mQb(a,(Ywc(),Jwc)))),Kfb(UD(mQb(b,Jwc))))} + function qAb(){qAb=geb;pAb=ss((cAb(),cD(WC(AL,1),jwe,304,0,[$zb,_zb,aAb,bAb])));} + function cAb(){cAb=geb;$zb=new dAb('All',0);_zb=new iAb;aAb=new kAb;bAb=new nAb;} + function EKb(){EKb=geb;CKb=new FKb(Nye,0);BKb=new FKb(Kye,1);DKb=new FKb(Oye,2);} + function Zme(){Zme=geb;qAd();Wme=oxe;Vme=pxe;Yme=new Tfb(oxe);Xme=new Tfb(pxe);} + function rOb(){rOb=geb;qOb=ss((mOb(),cD(WC(hO,1),jwe,417,0,[lOb,iOb,jOb,kOb])));} + function NRb(){NRb=geb;MRb=ss((IRb(),cD(WC(WO,1),jwe,406,0,[FRb,ERb,GRb,HRb])));} + function NPb(){NPb=geb;MPb=ss((IPb(),cD(WC(DO,1),jwe,332,0,[FPb,EPb,GPb,HPb])));} + function Z$b(){Z$b=geb;Y$b=ss((U$b(),cD(WC(CQ,1),jwe,389,0,[T$b,R$b,Q$b,S$b])));} + function wZb(){wZb=geb;vZb=ss((nZb(),cD(WC(lQ,1),jwe,416,0,[jZb,mZb,kZb,lZb])));} + function jnc(){jnc=geb;inc=ss((enc(),cD(WC(LV,1),jwe,421,0,[anc,bnc,cnc,dnc])));} + function Bec(){Bec=geb;Aec=ss((vec(),cD(WC(qT,1),jwe,371,0,[uec,sec,tec,rec])));} + function DDc(){DDc=geb;CDc=ss((wDc(),cD(WC(tX,1),jwe,203,0,[uDc,vDc,tDc,sDc])));} + function pEc(){pEc=geb;oEc=ss((kEc(),cD(WC(wX,1),jwe,284,0,[hEc,gEc,iEc,jEc])));} + function Cuc(){Cuc=geb;Buc=new Duc(LAe,0);Auc=new Duc('IMPROVE_STRAIGHTNESS',1);} + function _i(a,b){var c,d;d=b/a.c.Rd().gc()|0;c=b%a.c.Rd().gc();return Ui(a,d,c)} + function iZd(a){var b;if(a.nl()){for(b=a.i-1;b>=0;--b){QHd(a,b);}}return WHd(a)} + function Nyb(a){var b,c;if(!a.b){return null}c=a.b;while(b=c.a[0]){c=b;}return c} + function Oyb(a){var b,c;if(!a.b){return null}c=a.b;while(b=c.a[1]){c=b;}return c} + function Hae(a){if(ZD(a,180)){return ''+RD(a,180).a}return a==null?null:jeb(a)} + function Iae(a){if(ZD(a,180)){return ''+RD(a,180).a}return a==null?null:jeb(a)} + function eGb(a,b){if(b.a){throw Adb(new yz(jye))}Ysb(a.a,b);b.a=a;!a.j&&(a.j=b);} + function hEb(a,b){xxb.call(this,b.zd(),b.yd()&-16449);uFb(a);this.a=a;this.c=b;} + function zXc(a,b){return new gud(b,Zid(ajd(b.e),b.f.a+a,b.f.b+a),(Geb(),false))} + function EMc(a,b){dMc();return Rmb(a,new Ptd(b,sgb(b.e.c.length+b.g.c.length)))} + function GMc(a,b){dMc();return Rmb(a,new Ptd(b,sgb(b.e.c.length+b.g.c.length)))} + function p5c(){p5c=geb;o5c=ss((j5c(),cD(WC(M0,1),jwe,354,0,[i5c,g5c,h5c,f5c])));} + function x_c(){x_c=geb;w_c=ss((s_c(),cD(WC(J_,1),jwe,353,0,[r_c,p_c,q_c,o_c])));} + function eWc(){eWc=geb;dWc=ss((YVc(),cD(WC(H$,1),jwe,405,0,[UVc,VVc,WVc,XVc])));} + function bnd(){bnd=geb;and=ss((Ymd(),cD(WC(u3,1),jwe,223,0,[Xmd,Vmd,Umd,Wmd])));} + function Vnd(){Vnd=geb;Und=ss((Pnd(),cD(WC(z3,1),jwe,291,0,[Ond,Lnd,Mnd,Nnd])));} + function Vpd(){Vpd=geb;Upd=ss((Qpd(),cD(WC(H3,1),jwe,386,0,[Opd,Ppd,Npd,Mpd])));} + function Lrd(){Lrd=geb;Krd=ss((Grd(),cD(WC(R3,1),jwe,320,0,[Frd,Crd,Erd,Drd])));} + function ytd(){ytd=geb;xtd=ss((ttd(),cD(WC(n4,1),jwe,415,0,[qtd,rtd,ptd,std])));} + function b9c(){b9c=geb;$8c=new d9c(iFe,0);a9c=new d9c(mEe,1);_8c=new d9c(LAe,2);} + function sBb(a,b,c,d,e){uFb(a);uFb(b);uFb(c);uFb(d);uFb(e);return new DBb(a,b,d)} + function fub(a,b){var c;c=RD(_jb(a.e,b),400);if(c){rub(c);return c.e}return null} + function Ymb(a,b){var c;c=Wmb(a,b,0);if(c==-1){return false}Xmb(a,c);return true} + function LDb(a,b,c){var d;LCb(a);d=new IEb;d.a=b;a.a.Nb(new QEb(d,c));return d.a} + function VCb(a){var b;LCb(a);b=$C(iE,vxe,28,0,15,1);ixb(a.a,new dDb(b));return b} + function yc(a){var b;if(!xc(a)){throw Adb(new Dvb)}a.e=1;b=a.d;a.d=null;return b} + function Odb(a){var b;if(Kdb(a)){b=0-a;if(!isNaN(b)){return b}}return Edb(xD(a))} + function Wmb(a,b,c){for(;c=0?Dvd(a,c,true,true):Qvd(a,b,true)} + function Vwd(a){var b;b=SD(Ywd(a,32));if(b==null){Wwd(a);b=SD(Ywd(a,32));}return b} + function Yvd(a){var b;if(!a.Oh()){b=AYd(a.Dh())-a.ji();a.$h().Mk(b);}return a.zh()} + function zQb(a,b){yQb=new kRb;wQb=b;xQb=a;RD(xQb.b,68);BQb(xQb,yQb,null);AQb(xQb);} + function AWb(){AWb=geb;yWb=new BWb('XY',0);xWb=new BWb('X',1);zWb=new BWb('Y',2);} + function vLb(){vLb=geb;uLb=new wLb('TOP',0);tLb=new wLb(Kye,1);sLb=new wLb(Qye,2);} + function Gvc(){Gvc=geb;Evc=new Hvc(LAe,0);Fvc=new Hvc('TOP',1);Dvc=new Hvc(Qye,2);} + function sEc(){sEc=geb;qEc=new tEc('INPUT_ORDER',0);rEc=new tEc('PORT_DEGREE',1);} + function MD(){MD=geb;ID=hD(dxe,dxe,524287);JD=hD(0,0,fxe);KD=fD(1);fD(2);LD=fD(0);} + function wWd(a){var b;if(a.d!=a.r){b=WVd(a);a.e=!!b&&b.lk()==aKe;a.d=b;}return a.e} + function UHd(a,b,c){var d;d=a.g[b];MHd(a,b,a.Zi(b,c));a.Ri(b,c,d);a.Ni();return d} + function dHd(a,b){var c;c=a.dd(b);if(c>=0){a.gd(c);return true}else {return false}} + function xr(a,b){var c;Qb(a);Qb(b);c=false;while(b.Ob()){c=c|a.Fc(b.Pb());}return c} + function cub(a,b){var c;c=RD(Wjb(a.e,b),400);if(c){eub(a,c);return c.e}return null} + function iB(a){var b,c;b=a/60|0;c=a%60;if(c==0){return ''+b}return ''+b+':'+(''+c)} + function JB(d,a){var b=d.a[a];var c=(HC(),GC)[typeof b];return c?c(b):NC(typeof b)} + function EDb(a,b){var c,d;MCb(a);d=new zEb(b,a.a);c=new YDb(d);return new SDb(a,c)} + function mwb(a){var b;b=a.b.c.length==0?null:Vmb(a.b,0);b!=null&&owb(a,0);return b} + function ukc(a,b){var c,d,e;e=b.c.i;c=RD(Wjb(a.f,e),60);d=c.d.c-c.e.c;Bjd(b.a,d,0);} + function XLc(a,b){var c;++a.d;++a.c[b];c=b+1;while(c=0){++b[0];}} + function eEd(a,b){Dyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function fEd(a,b){Eyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function gEd(a,b){Cyd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function hEd(a,b){Ayd(a,b==null||Rfb((uFb(b),b))||isNaN((uFb(b),b))?0:(uFb(b),b));} + function oWc(a,b,c){return cjd(new rjd(c.e.a+c.f.a/2,c.e.b+c.f.b/2),a)==(uFb(b),b)} + function qge(a,b){return ZD(b,102)&&(RD(b,19).Bb&txe)!=0?new She(b,a):new Phe(b,a)} + function sge(a,b){return ZD(b,102)&&(RD(b,19).Bb&txe)!=0?new She(b,a):new Phe(b,a)} + function XC(a){return a.__elementTypeCategory$==null?10:a.__elementTypeCategory$} + function Bhb(a,b){return b==(wvb(),wvb(),vvb)?a.toLocaleLowerCase():a.toLowerCase()} + function Mu(a){if(!a.e){throw Adb(new Dvb)}a.c=a.a=a.e;a.e=a.e.e;--a.d;return a.a.f} + function Lu(a){if(!a.c){throw Adb(new Dvb)}a.e=a.a=a.c;a.c=a.c.c;++a.d;return a.a.f} + function Lsb(a){var b;++a.a;for(b=a.c.a.length;a.aa.a[d]&&(d=c);}return d} + function Krc(a){var b;b=RD(mQb(a,(Ywc(),Wvc)),313);if(b){return b.a==a}return false} + function Lrc(a){var b;b=RD(mQb(a,(Ywc(),Wvc)),313);if(b){return b.i==a}return false} + function xXb(){xXb=geb;wXb=ss((sXb(),cD(WC(UP,1),jwe,367,0,[nXb,oXb,pXb,qXb,rXb])));} + function Hnc(){Hnc=geb;Gnc=ss((Bnc(),cD(WC(TV,1),jwe,375,0,[xnc,znc,Anc,ync,wnc])));} + function Xtc(){Xtc=geb;Wtc=ss((Ptc(),cD(WC(bX,1),jwe,348,0,[Ltc,Ktc,Ntc,Otc,Mtc])));} + function RDc(){RDc=geb;QDc=ss((JDc(),cD(WC(uX,1),jwe,323,0,[IDc,FDc,GDc,EDc,HDc])));} + function hxc(){hxc=geb;gxc=ss((cxc(),cD(WC(mX,1),jwe,171,0,[bxc,Zwc,$wc,_wc,axc])));} + function m3c(){m3c=geb;l3c=ss((g3c(),cD(WC(x0,1),jwe,368,0,[e3c,b3c,f3c,c3c,d3c])));} + function xad(){xad=geb;wad=ss((sad(),cD(WC(x1,1),jwe,373,0,[oad,nad,qad,pad,rad])));} + function acd(){acd=geb;_bd=ss((Xbd(),cD(WC(P1,1),jwe,324,0,[Sbd,Tbd,Wbd,Ubd,Vbd])));} + function Kmd(){Kmd=geb;Jmd=ss((Cmd(),cD(WC(s3,1),jwe,88,0,[Amd,zmd,ymd,xmd,Bmd])));} + function bid(){bid=geb;aid=ss((Yhd(),cD(WC(d3,1),jwe,170,0,[Whd,Vhd,Thd,Xhd,Uhd])));} + function uod(){uod=geb;tod=ss((pod(),cD(WC(B3,1),jwe,256,0,[mod,ood,kod,lod,nod])));} + function zpd(){zpd=geb;ypd=ss((qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])));} + function LHb(){LHb=geb;JHb=new MHb('BY_SIZE',0);KHb=new MHb('BY_SIZE_AND_SHAPE',1);} + function TUb(){TUb=geb;RUb=new UUb('EADES',0);SUb=new UUb('FRUCHTERMAN_REINGOLD',1);} + function $tc(){$tc=geb;Ytc=new _tc('READING_DIRECTION',0);Ztc=new _tc('ROTATION',1);} + function CZb(){CZb=geb;zZb=new ZZb;AZb=new b$b;xZb=new f$b;yZb=new j$b;BZb=new n$b;} + function dGb(a){this.b=new bnb;this.a=new bnb;this.c=new bnb;this.d=new bnb;this.e=a;} + function XZb(a){this.g=a;this.f=new bnb;this.a=$wnd.Math.min(this.g.c.c,this.g.d.c);} + function UKb(a,b,c){RJb.call(this);KKb(this);this.a=a;this.c=c;this.b=b.d;this.f=b.e;} + function d6b(a,b,c){var d,e;for(e=new Anb(c);e.a=0&&b0?b-1:b;return Kqd(Lqd(Mqd(Nqd(new Oqd,c),a.n),a.j),a.k)} + function nBd(a){var b,c;c=(b=new q4d,b);WGd((!a.q&&(a.q=new C5d(s7,a,11,10)),a.q),c);} + function ofb(a){return ((a.i&2)!=0?'interface ':(a.i&1)!=0?'':'class ')+(lfb(a),a.o)} + function dz(a){if(Ddb(a,lve)>0){return lve}if(Ddb(a,qwe)<0){return qwe}return Ydb(a)} + function Sv(a){if(a<3){dk(a,fwe);return a+1}if(a=-0.01&&a.a<=Tye&&(a.a=0);a.b>=-0.01&&a.b<=Tye&&(a.b=0);return a} + function Hid(a){tid();var b,c;c=KEe;for(b=0;bc&&(c=a[b]);}return c} + function Zvd(a,b){var c;c=wYd(a.Dh(),b);if(!c){throw Adb(new agb(KHe+b+NHe))}return c} + function NGd(a,b){var c;c=a;while(vCd(c)){c=vCd(c);if(c==b){return true}}return false} + function ix(a,b){var c,d,e;d=b.a.ld();c=RD(b.a.md(),16).gc();for(e=0;ea||a>b){throw Adb(new xeb('fromIndex: 0, toIndex: '+a+Qxe+b))}} + function ZHd(a){if(a<0){throw Adb(new agb('Illegal Capacity: '+a))}this.g=this.aj(a);} + function _y(a,b){Zy();bz(pwe);return $wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)} + function xJc(a,b){var c,d,e,f;for(d=a.d,e=0,f=d.length;e0){a.a/=b;a.b/=b;}return a} + function BXd(a){var b;if(a.w){return a.w}else {b=CXd(a);!!b&&!b.Vh()&&(a.w=b);return b}} + function l2d(a,b){var c,d;d=a.a;c=m2d(a,b,null);d!=b&&!a.e&&(c=o2d(a,b,c));!!c&&c.oj();} + function rQc(a,b,c){var d,e;d=b;do{e=Kfb(a.p[d.p])+c;a.p[d.p]=e;d=a.a[d.p];}while(d!=b)} + function heb(a,b,c){var d=function(){return a.apply(d,arguments)};b.apply(d,c);return d} + function Gae(a){var b;if(a==null){return null}else {b=RD(a,195);return sAd(b,b.length)}} + function QHd(a,b){if(a.g==null||b>=a.i)throw Adb(new yNd(b,a.i));return a.Wi(b,a.g[b])} + function Dob(a,b){yob();var c,d;d=new bnb;for(c=0;c=14&&b<=16)));return a} + function ws(a,b){var c;uFb(b);c=a[':'+b];mFb(!!c,'Enum constant undefined: '+b);return c} + function tfb(a,b,c,d,e,f){var g;g=rfb(a,b);Ffb(c,g);g.i=e?8:0;g.f=d;g.e=e;g.g=f;return g} + function R3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=1;this.c=a;this.a=c;} + function T3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=2;this.c=a;this.a=c;} + function _3d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=6;this.c=a;this.a=c;} + function e4d(a,b,c,d,e){this.d=b;this.k=d;this.f=e;this.o=-1;this.p=7;this.c=a;this.a=c;} + function X3d(a,b,c,d,e){this.d=b;this.j=d;this.e=e;this.o=-1;this.p=4;this.c=a;this.a=c;} + function iGb(a,b){var c,d,e,f;for(d=b,e=0,f=d.length;e=0)){throw Adb(new agb('tolerance ('+a+') must be >= 0'))}return a} + function hOd(a,b){var c;if(ZD(b,44)){return a.c.Mc(b)}else {c=QNd(a,b);jOd(a,b);return c}} + function yBd(a,b,c){YVd(a,b);PAd(a,c);$Vd(a,0);bWd(a,1);aWd(a,true);_Vd(a,true);return a} + function ZGd(a,b){var c;c=a.gc();if(b<0||b>c)throw Adb(new aMd(b,c));return new CMd(a,b)} + function Cad(a,b){a.b=$wnd.Math.max(a.b,b.d);a.e+=b.r+(a.a.c.length==0?0:a.c);Rmb(a.a,b);} + function Jmb(a){yFb(a.c>=0);if(rmb(a.d,a.c)<0){a.a=a.a-1&a.d.a.length-1;a.b=a.d.c;}a.c=-1;} + function Nc(a){var b,c;for(c=a.c.Cc().Kc();c.Ob();){b=RD(c.Pb(),16);b.$b();}a.c.$b();a.d=0;} + function Zi(a){var b,c,d,e;for(c=a.a,d=0,e=c.length;d=0} + function Iqd(a,b){if(a.r>0&&a.c0&&a.g!=0&&Iqd(a.i,b/a.r*a.i.d);}} + function $Cd(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.c));} + function P1d(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,4,c,a.c));} + function jyd(a,b){var c;c=a.k;a.k=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,2,c,a.k));} + function JXd(a,b){var c;c=a.D;a.D=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,2,c,a.D));} + function Kzd(a,b){var c;c=a.f;a.f=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,8,c,a.f));} + function Lzd(a,b){var c;c=a.i;a.i=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,7,c,a.i));} + function fCd(a,b){var c;c=a.a;a.a=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,8,c,a.a));} + function ZCd(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,c,a.b));} + function s6d(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,c,a.b));} + function t6d(a,b){var c;c=a.c;a.c=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.c));} + function nVd(a,b){var c;c=a.d;a.d=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,1,c,a.d));} + function Cte(a,b,c){var d;a.b=b;a.a=c;d=(a.a&512)==512?new Gre:new Tqe;a.c=Nqe(d,a.b,a.a);} + function Gge(a,b){return qke(a.e,b)?(nke(),wWd(b)?new ole(b,a):new Eke(b,a)):new Ble(b,a)} + function iDb(a){var b,c;if(0>a){return new rDb}b=a+1;c=new kDb(b,a);return new oDb(null,c)} + function Gob(a,b){yob();var c;c=new Usb(1);bE(a)?$jb(c,a,b):rtb(c.f,a,b);return new uqb(c)} + function pQc(a,b){var c,d;c=a.c;d=b.e[a.p];if(d>0){return RD(Vmb(c.a,d-1),10)}return null} + function TOb(a,b){var c,d;c=a.o+a.p;d=b.o+b.p;if(cb){b<<=1;return b>0?b:hwe}return b} + function xc(a){Ub(a.e!=3);switch(a.e){case 2:return false;case 0:return true;}return zc(a)} + function djd(a,b){var c;if(ZD(b,8)){c=RD(b,8);return a.a==c.a&&a.b==c.b}else {return false}} + function Ydd(a,b){var c;c=new kRb;RD(b.b,68);RD(b.b,68);RD(b.b,68);Umb(b.a,new ced(a,c,b));} + function gOd(a,b){var c,d;for(d=b.vc().Kc();d.Ob();){c=RD(d.Pb(),44);fOd(a,c.ld(),c.md());}} + function Jzd(a,b){var c;c=a.d;a.d=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,11,c,a.d));} + function zWd(a,b){var c;c=a.j;a.j=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,13,c,a.j));} + function b6d(a,b){var c;c=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,21,c,a.b));} + function YAb(a,b){((gBb(),dBb)?null:b.c).length==0&&iBb(b,new rBb);$jb(a.a,dBb?null:b.c,b);} + function b9b(a,b){b.Ug('Hierarchical port constraint processing',1);c9b(a);e9b(a);b.Vg();} + function joc(){joc=geb;ioc=new koc('START',0);hoc=new koc('MIDDLE',1);goc=new koc('END',2);} + function x2c(){x2c=geb;v2c=new z2c('P1_NODE_PLACEMENT',0);w2c=new z2c('P2_EDGE_ROUTING',1);} + function JVb(){JVb=geb;HVb=new jGd(rAe);IVb=new jGd(sAe);GVb=new jGd(tAe);FVb=new jGd(uAe);} + function tkb(a){var b;rFb(a.f.g,a.d);sFb(a.b);a.c=a.a;b=RD(a.a.Pb(),44);a.b=skb(a);return b} + function P2d(a){var b;if(a.b==null){return j3d(),j3d(),i3d}b=a.ul()?a.tl():a.sl();return b} + function nwb(a,b){var c;c=b==null?-1:Wmb(a.b,b,0);if(c<0){return false}owb(a,c);return true} + function zsb(a,b){var c;uFb(b);c=b.g;if(!a.b[c]){bD(a.b,c,b);++a.c;return true}return false} + function azb(a,b){var c,d;c=1-b;d=a.a[c];a.a[c]=d.a[b];d.a[b]=a;a.b=true;d.b=false;return d} + function xRb(a,b){var c,d;for(d=b.Kc();d.Ob();){c=RD(d.Pb(),272);a.b=true;Ysb(a.e,c);c.b=a;}} + function kic(a,b){var c,d;c=RD(mQb(a,(yCc(),IBc)),8);d=RD(mQb(b,IBc),8);return Qfb(c.b,d.b)} + function SPb(a,b,c){var d,e,f;f=b>>5;e=b&31;d=Cdb(Udb(a.n[c][f],Ydb(Sdb(e,1))),3);return d} + function lmb(a,b,c){var d,e,f;f=a.a.length-1;for(e=a.b,d=0;d0?1:0}return (!a.c&&(a.c=ojb(Hdb(a.f))),a.c).e} + function GXd(a,b){if(b){if(a.B==null){a.B=a.D;a.D=null;}}else if(a.B!=null){a.D=a.B;a.B=null;}} + function rZb(a,b){nZb();return a==jZb&&b==mZb||a==mZb&&b==jZb||a==lZb&&b==kZb||a==kZb&&b==lZb} + function sZb(a,b){nZb();return a==jZb&&b==kZb||a==jZb&&b==lZb||a==mZb&&b==lZb||a==mZb&&b==kZb} + function zMb(a,b){return Zy(),bz(Tye),$wnd.Math.abs(0-b)<=Tye||0==b||isNaN(0)&&isNaN(b)?0:a/b} + function qsc(a,b){return Kfb(UD(Lvb(MDb(GDb(new SDb(null,new Swb(a.c.b,16)),new Isc(a)),b))))} + function tsc(a,b){return Kfb(UD(Lvb(MDb(GDb(new SDb(null,new Swb(a.c.b,16)),new Gsc(a)),b))))} + function rvc(){ovc();return cD(WC(iX,1),jwe,259,0,[fvc,hvc,ivc,jvc,kvc,lvc,nvc,evc,gvc,mvc])} + function dEc(){aEc();return cD(WC(vX,1),jwe,243,0,[$Dc,VDc,YDc,WDc,XDc,SDc,ZDc,_Dc,TDc,UDc])} + function z3c(a,b){var c;b.Ug('General Compactor',1);c=h4c(RD(Gxd(a,($4c(),I4c)),393));c.Cg(a);} + function T5c(a,b){var c,d;c=RD(Gxd(a,($4c(),P4c)),17);d=RD(Gxd(b,P4c),17);return hgb(c.a,d.a)} + function Bjd(a,b,c){var d,e;for(e=Sub(a,0);e.b!=e.d.c;){d=RD(evb(e),8);d.a+=b;d.b+=c;}return a} + function Go(a,b,c){var d;for(d=a.b[c&a.f];d;d=d.b){if(c==d.a&&Hb(b,d.g)){return d}}return null} + function Ho(a,b,c){var d;for(d=a.c[c&a.f];d;d=d.d){if(c==d.f&&Hb(b,d.i)){return d}}return null} + function sjb(a,b,c){var d,e,f;d=0;for(e=0;e>>31;}d!=0&&(a[c]=d);} + function yzb(a,b,c,d,e,f){var g;this.c=a;g=new bnb;Syb(a,g,b,a.b,c,d,e,f);this.a=new Jkb(g,0);} + function _5c(){this.c=new T2c(0);this.b=new T2c(FEe);this.d=new T2c(EEe);this.a=new T2c(Gze);} + function kMb(a,b,c,d,e,f,g){qs.call(this,a,b);this.d=c;this.e=d;this.c=e;this.b=f;this.a=dv(g);} + function tBd(a,b,c,d,e,f,g,h,i,j,k,l,m){ABd(a,b,c,d,e,f,g,h,i,j,k,l,m);kXd(a,false);return a} + function H0b(a){if(a.b.c.i.k==(r3b(),m3b)){return RD(mQb(a.b.c.i,(Ywc(),Awc)),12)}return a.b.c} + function I0b(a){if(a.b.d.i.k==(r3b(),m3b)){return RD(mQb(a.b.d.i,(Ywc(),Awc)),12)}return a.b.d} + function nDb(a){var b;b=mDb(a);if(Gdb(b.a,0)){return bwb(),bwb(),awb}return bwb(),new ewb(b.b)} + function SCb(a){var b;b=RCb(a);if(Gdb(b.a,0)){return Tvb(),Tvb(),Svb}return Tvb(),new Yvb(b.b)} + function TCb(a){var b;b=RCb(a);if(Gdb(b.a,0)){return Tvb(),Tvb(),Svb}return Tvb(),new Yvb(b.c)} + function o8b(a){switch(a.g){case 2:return qpd(),ppd;case 4:return qpd(),Xod;default:return a;}} + function p8b(a){switch(a.g){case 1:return qpd(),npd;case 3:return qpd(),Yod;default:return a;}} + function C9c(a){switch(a.g){case 0:return new s9c;case 1:return new x9c;default:return null;}} + function Zcc(){Zcc=geb;Ycc=new kGd('edgelabelcenterednessanalysis.includelabel',(Geb(),Eeb));} + function jKc(){jKc=geb;iKc=mfd(qfd(pfd(pfd(new ufd,(sXb(),pXb),(hcc(),Qbc)),qXb,Gbc),rXb),Pbc);} + function DLc(){DLc=geb;CLc=mfd(qfd(pfd(pfd(new ufd,(sXb(),pXb),(hcc(),Qbc)),qXb,Gbc),rXb),Pbc);} + function lYd(){lYd=geb;iYd=new i1d;kYd=cD(WC(y7,1),lKe,179,0,[]);jYd=cD(WC(s7,1),mKe,62,0,[]);} + function P8b(){P8b=geb;O8b=new Q8b('TO_INTERNAL_LTR',0);N8b=new Q8b('TO_INPUT_DIRECTION',1);} + function J3b(){J3b=geb;G3b=new r4b;E3b=new w4b;F3b=new A4b;D3b=new E4b;H3b=new I4b;I3b=new M4b;} + function Cac(a,b){b.Ug(iBe,1);LJb(KJb(new PJb((i1b(),new t1b(a,false,false,new _1b)))));b.Vg();} + function M_c(a,b,c){c.Ug('DFS Treeifying phase',1);L_c(a,b);J_c(a,b);a.a=null;a.b=null;c.Vg();} + function Leb(a,b){Geb();return bE(a)?jhb(a,WD(b)):_D(a)?Jfb(a,UD(b)):$D(a)?Ieb(a,TD(b)):a.Fd(b)} + function Ld(a,b){var c,d;uFb(b);for(d=b.vc().Kc();d.Ob();){c=RD(d.Pb(),44);a.zc(c.ld(),c.md());}} + function ege(a,b,c){var d;for(d=c.Kc();d.Ob();){if(!cge(a,b,d.Pb())){return false}}return true} + function S6d(a,b,c,d,e){var f;if(c){f=BYd(b.Dh(),a.c);e=c.Rh(b,-1-(f==-1?d:f),null,e);}return e} + function T6d(a,b,c,d,e){var f;if(c){f=BYd(b.Dh(),a.c);e=c.Th(b,-1-(f==-1?d:f),null,e);}return e} + function Uib(a){var b;if(a.b==-2){if(a.e==0){b=-1;}else {for(b=0;a.a[b]==0;b++);}a.b=b;}return a.b} + function fjb(a){uFb(a);if(a.length==0){throw Adb(new Vgb('Zero length BigInteger'))}mjb(this,a);} + function $Hd(a){this.i=a.gc();if(this.i>0){this.g=this.aj(this.i+(this.i/8|0)+1);a.Qc(this.g);}} + function dmc(a,b,c){this.g=a;this.d=b;this.e=c;this.a=new bnb;bmc(this);yob();_mb(this.a,null);} + function aad(a,b){b.q=a;a.d=$wnd.Math.max(a.d,b.r);a.b+=b.d+(a.a.c.length==0?0:a.c);Rmb(a.a,b);} + function xid(a,b){var c,d,e,f;e=a.c;c=a.c+a.b;f=a.d;d=a.d+a.a;return b.a>e&&b.af&&b.be?(c=e):BFb(b,c+1);a.a=zhb(a.a,0,b)+(''+d)+yhb(a.a,c);} + function ktb(a,b){a.a=Bdb(a.a,1);a.c=$wnd.Math.min(a.c,b);a.b=$wnd.Math.max(a.b,b);a.d=Bdb(a.d,b);} + function wdc(a,b){return b1||a.Ob()){++a.a;a.g=0;b=a.i;a.Ob();return b}else {throw Adb(new Dvb)}} + function GRc(a){switch(a.a.g){case 1:return new lSc;case 3:return new VUc;default:return new WRc;}} + function fyd(a,b){switch(b){case 1:return !!a.n&&a.n.i!=0;case 2:return a.k!=null;}return Cxd(a,b)} + function Hdb(a){if(jxe>22);e=a.h+b.h+(d>>22);return hD(c&dxe,d&dxe,e&exe)} + function DD(a,b){var c,d,e;c=a.l-b.l;d=a.m-b.m+(c>>22);e=a.h-b.h+(d>>22);return hD(c&dxe,d&dxe,e&exe)} + function Jpc(a){var b,c;Hpc(a);for(c=new Anb(a.d);c.ad)throw Adb(new aMd(b,d));a.Si()&&(c=bHd(a,c));return a.Ei(b,c)} + function eQb(a,b,c,d,e){var f,g;for(g=c;g<=e;g++){for(f=b;f<=d;f++){PPb(a,f,g)||TPb(a,f,g,true,false);}}} + function uid(a){tid();var b,c,d;c=$C(l3,Nve,8,2,0,1);d=0;for(b=0;b<2;b++){d+=0.5;c[b]=Cid(d,a);}return c} + function xD(a){var b,c,d;b=~a.l+1&dxe;c=~a.m+(b==0?1:0)&dxe;d=~a.h+(b==0&&c==0?1:0)&exe;return hD(b,c,d)} + function mgb(a){var b;if(a<0){return qwe}else if(a==0){return 0}else {for(b=hwe;(b&a)==0;b>>=1);return b}} + function zSd(a,b,c){if(a>=128)return false;return a<64?Pdb(Cdb(Sdb(1,a),c),0):Pdb(Cdb(Sdb(1,a-64),b),0)} + function oQb(a,b,c){return c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c)),a} + function pQb(a,b,c){c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c));return a} + function KTb(a){var b,c;c=new gUb;kQb(c,a);pQb(c,(JVb(),HVb),a);b=new Tsb;MTb(a,c,b);LTb(a,c,b);return c} + function cIc(a){var b,c;b=a.t-a.k[a.o.p]*a.d+a.j[a.o.p]>a.f;c=a.u+a.e[a.o.p]*a.d>a.f*a.s*a.d;return b||c} + function qmc(a,b){var c,d,e,f;c=false;d=a.a[b].length;for(f=0;f=0,'Negative initial capacity');mFb(b>=0,'Non-positive load factor');akb(this);} + function iib(a,b,c,d,e){var f,g;g=a.length;f=c.length;if(b<0||d<0||e<0||b+e>g||d+e>f){throw Adb(new ueb)}} + function zob(a,b){yob();var c,d,e,f,g;g=false;for(d=b,e=0,f=d.length;e1||b>=0&&a.b<3} + function nD(a){var b,c,d;b=~a.l+1&dxe;c=~a.m+(b==0?1:0)&dxe;d=~a.h+(b==0&&c==0?1:0)&exe;a.l=b;a.m=c;a.h=d;} + function Cob(a){yob();var b,c,d;d=1;for(c=a.Kc();c.Ob();){b=c.Pb();d=31*d+(b!=null?tb(b):0);d=d|0;}return d} + function kD(a,b,c,d,e){var f;f=BD(a,b);c&&nD(f);if(e){a=mD(a,b);d?(eD=xD(a)):(eD=hD(a.l,a.m,a.h));}return f} + function Qlc(a,b,c){a.g=Wlc(a,b,(qpd(),Xod),a.b);a.d=Wlc(a,c,Xod,a.b);if(a.g.c==0||a.d.c==0){return}Tlc(a);} + function Rlc(a,b,c){a.g=Wlc(a,b,(qpd(),ppd),a.j);a.d=Wlc(a,c,ppd,a.j);if(a.g.c==0||a.d.c==0){return}Tlc(a);} + function Xyd(a,b){switch(b){case 7:return !!a.e&&a.e.i!=0;case 8:return !!a.d&&a.d.i!=0;}return wyd(a,b)} + function STb(a,b){switch(b.g){case 0:ZD(a.b,641)||(a.b=new tUb);break;case 1:ZD(a.b,642)||(a.b=new zUb);}} + function tbd(a){switch(a.g){case 0:return new _dd;default:throw Adb(new agb(eGe+(a.f!=null?a.f:''+a.g)));}} + function bdd(a){switch(a.g){case 0:return new vdd;default:throw Adb(new agb(eGe+(a.f!=null?a.f:''+a.g)));}} + function LCc(a,b,c){return !QDb(CDb(new SDb(null,new Swb(a.c,16)),new PAb(new gsd(b,c)))).Bd((xDb(),wDb))} + function mWc(a,b){return cjd(jWc(RD(mQb(b,(h_c(),H$c)),88)),new rjd(a.c.e.a-a.b.e.a,a.c.e.b-a.b.e.b))<=0} + function dve(a,b){while(a.g==null&&!a.c?sId(a):a.g==null||a.i!=0&&RD(a.g[a.i-1],51).Ob()){mFd(b,tId(a));}} + function sYb(a){var b,c;for(c=new Anb(a.a.b);c.ad?1:0} + function ICc(a){Rmb(a.c,(hed(),fed));if(_y(a.a,Kfb(UD(iGd((QCc(),OCc)))))){return new asd}return new csd(a)} + function fs(a){while(!a.d||!a.d.Ob()){if(!!a.b&&!nmb(a.b)){a.d=RD(smb(a.b),51);}else {return null}}return a.d} + function BVc(a){switch(a.g){case 1:return EEe;default:case 2:return 0;case 3:return Gze;case 4:return FEe;}} + function fte(){Vse();var a;if(Cse)return Cse;a=Zse(hte('M',true));a=$se(hte('M',false),a);Cse=a;return Cse} + function ttd(){ttd=geb;qtd=new utd('ELK',0);rtd=new utd('JSON',1);ptd=new utd('DOT',2);std=new utd('SVG',3);} + function TEc(){TEc=geb;SEc=new UEc('STACKED',0);QEc=new UEc('REVERSE_STACKED',1);REc=new UEc('SEQUENCED',2);} + function LZc(){LZc=geb;KZc=new MZc(LAe,0);JZc=new MZc('MIDDLE_TO_MIDDLE',1);IZc=new MZc('AVOID_OVERLAP',2);} + function sgc(){sgc=geb;qgc=new Lgc;rgc=new Ngc;pgc=new Dgc;ogc=new Pgc;ngc=new Hgc;mgc=(uFb(ngc),new nrb);} + function vnd(){vnd=geb;tnd=new A3b(15);snd=new mGd((umd(),tld),tnd);und=Qld;ond=Ekd;pnd=kld;rnd=nld;qnd=mld;} + function wgd(a,b){var c,d,e,f,g;for(d=b,e=0,f=d.length;e=a.b.c.length){return}jwb(a,2*b+1);c=2*b+2;c0){b.Cd(c);c.i&&zKc(c);}}} + function Ejb(a,b,c){var d;for(d=c-1;d>=0&&a[d]===b[d];d--);return d<0?0:Ldb(Cdb(a[d],yxe),Cdb(b[d],yxe))?-1:1} + function it(a,b,c){var d,e;this.g=a;this.c=b;this.a=this;this.d=this;e=Wp(c);d=$C(UG,ewe,227,e,0,1);this.b=d;} + function fQb(a,b,c,d,e){var f,g;for(g=c;g<=e;g++){for(f=b;f<=d;f++){if(PPb(a,f,g)){return true}}}return false} + function Dc(a,b){var c,d;for(d=a.Zb().Cc().Kc();d.Ob();){c=RD(d.Pb(),16);if(c.Hc(b)){return true}}return false} + function iu(a,b,c){var d,e,f,g;uFb(c);g=false;f=a.fd(b);for(e=c.Kc();e.Ob();){d=e.Pb();f.Rb(d);g=true;}return g} + function NMd(a,b){var c,d;d=RD(Ywd(a.a,4),129);c=$C(d6,IJe,424,b,0,1);d!=null&&hib(d,0,c,0,d.length);return c} + function hSd(a,b){var c;c=new lSd((a.f&256)!=0,a.i,a.a,a.d,(a.f&16)!=0,a.j,a.g,b);a.e!=null||(c.c=a);return c} + function Tv(a,b){var c;if(a===b){return true}else if(ZD(b,85)){c=RD(b,85);return Rx(gn(a),c.vc())}return false} + function Vjb(a,b,c){var d,e;for(e=c.Kc();e.Ob();){d=RD(e.Pb(),44);if(a.Be(b,d.md())){return true}}return false} + function lmc(a,b,c){if(!a.d[b.p][c.p]){kmc(a,b,c);a.d[b.p][c.p]=true;a.d[c.p][b.p]=true;}return a.a[b.p][c.p]} + function vMc(a,b){var c;if(!a||a==b||!nQb(b,(Ywc(),pwc))){return false}c=RD(mQb(b,(Ywc(),pwc)),10);return c!=a} + function Bhe(a){switch(a.i){case 2:{return true}case 1:{return false}case -1:{++a.c;}default:{return a.$l()}}} + function Che(a){switch(a.i){case -2:{return true}case -1:{return false}case 1:{--a.c;}default:{return a._l()}}} + function bgb(a){oz.call(this,'The given string does not match the expected format for individual spacings.',a);} + function J6c(a,b){var c;b.Ug('Min Size Preprocessing',1);c=vsd(a);Ixd(a,(X6c(),U6c),c.a);Ixd(a,R6c,c.b);b.Vg();} + function Djd(a){var b,c,d;b=0;d=$C(l3,Nve,8,a.b,0,1);c=Sub(a,0);while(c.b!=c.d.c){d[b++]=RD(evb(c),8);}return d} + function Ajd(a,b,c){var d,e,f;d=new Yub;for(f=Sub(c,0);f.b!=f.d.c;){e=RD(evb(f),8);Mub(d,new sjd(e));}iu(a,b,d);} + function az(a,b){var c;c=Bdb(a,b);if(Ldb($db(a,b),0)|Jdb($db(a,c),0)){return c}return Bdb(Sve,$db(Udb(c,63),1))} + function le(a,b){var c,d;c=RD(a.d.Bc(b),16);if(!c){return null}d=a.e.hc();d.Gc(c);a.e.d-=c.gc();c.$b();return d} + function Dyb(a){var b;b=a.a.c.length;if(b>0){return lyb(b-1,a.a.c.length),Xmb(a.a,b-1)}else {throw Adb(new Srb)}} + function nFb(a,b,c){if(a>b){throw Adb(new agb(_xe+a+aye+b))}if(a<0||b>c){throw Adb(new xeb(_xe+a+bye+b+Qxe+c))}} + function yXd(a,b){if(a.D==null&&a.B!=null){a.D=a.B;a.B=null;}JXd(a,b==null?null:(uFb(b),b));!!a.C&&a.hl(null);} + function JCc(a,b){var c;c=iGd((QCc(),OCc))!=null&&b.Sg()!=null?Kfb(UD(b.Sg()))/Kfb(UD(iGd(OCc))):1;Zjb(a.b,b,c);} + function $Lc(a,b){var c,d;d=a.c[b];if(d==0){return}a.c[b]=0;a.d-=d;c=b+1;while(cDEe?a-c>DEe:c-a>DEe} + function vjd(a,b){var c;for(c=0;ce){ead(b.q,e);d=c!=b.q.d;}}return d} + function C3c(a,b){var c,d,e,f,g,h,i,j;i=b.i;j=b.j;d=a.f;e=d.i;f=d.j;g=i-e;h=j-f;c=$wnd.Math.sqrt(g*g+h*h);return c} + function pBd(a,b){var c,d;d=Hvd(a);if(!d){c=(gSd(),nSd(b));d=new Sde(c);WGd(d.El(),a);}return d} + function Sc(a,b){var c,d;c=RD(a.c.Bc(b),16);if(!c){return a.jc()}d=a.hc();d.Gc(c);a.d-=c.gc();c.$b();return a.mc(d)} + function tKc(a,b){var c,d;d=Kwb(a.d,1)!=0;c=true;while(c){c=false;c=b.c.mg(b.e,d);c=c|DKc(a,b,d,false);d=!d;}yKc(a);} + function omc(a,b,c,d){var e,f;a.a=b;f=d?0:1;a.f=(e=new mmc(a.c,a.a,c,f),new Pmc(c,a.a,e,a.e,a.b,a.c==(RKc(),PKc)));} + function Imb(a){var b;sFb(a.a!=a.b);b=a.d.a[a.a];zmb(a.b==a.d.c&&b!=null);a.c=a.a;a.a=a.a+1&a.d.a.length-1;return b} + function Vib(a){var b;if(a.c!=0){return a.c}for(b=0;b=a.c.b:a.a<=a.c.b)){throw Adb(new Dvb)}b=a.a;a.a+=a.c.c;++a.b;return sgb(b)} + function h5b(a){var b;b=new y2b(a.a);kQb(b,a);pQb(b,(Ywc(),Awc),a);b.o.a=a.g;b.o.b=a.f;b.n.a=a.i;b.n.b=a.j;return b} + function tVc(a){return (qpd(),hpd).Hc(a.j)?Kfb(UD(mQb(a,(Ywc(),Swc)))):xjd(cD(WC(l3,1),Nve,8,0,[a.i.n,a.n,a.a])).b} + function ZJc(a){var b;b=vfd(XJc);RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),kvc))&&pfd(b,(sXb(),pXb),(hcc(),Ybc));return b} + function M2c(a){var b,c,d,e;e=new _sb;for(d=new Anb(a);d.a=0?b:-b;while(d>0){if(d%2==0){c*=c;d=d/2|0;}else {e*=c;d-=1;}}return b<0?1/e:e} + function Jid(a,b){var c,d,e;e=1;c=a;d=b>=0?b:-b;while(d>0){if(d%2==0){c*=c;d=d/2|0;}else {e*=c;d-=1;}}return b<0?1/e:e} + function Vvd(a,b){var c,d,e,f;f=(e=a?Hvd(a):null,Pje((d=b,e?e.Gl():null,d)));if(f==b){c=Hvd(a);!!c&&c.Gl();}return f} + function g2d(a,b,c){var d,e;e=a.f;a.f=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,0,e,b);!c?(c=d):c.nj(d);}return c} + function e2d(a,b,c){var d,e;e=a.b;a.b=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,3,e,b);!c?(c=d):c.nj(d);}return c} + function rAd(a,b,c){var d,e;e=a.a;a.a=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,1,e,b);!c?(c=d):c.nj(d);}return c} + function SNd(a){var b,c;if(a!=null){for(c=0;c=d||b-129&&a<128){return ugb(),b=a+128,c=tgb[b],!c&&(c=tgb[b]=new fgb(a)),c}return new fgb(a)} + function bhb(a){var b,c;if(a>-129&&a<128){return dhb(),b=a+128,c=chb[b],!c&&(c=chb[b]=new Xgb(a)),c}return new Xgb(a)} + function M$b(a,b){var c;if(a.a.c.length>0){c=RD(Vmb(a.a,a.a.c.length-1),579);if(Q_b(c,b)){return}}Rmb(a.a,new S_b(b));} + function Ekc(a){lkc();var b,c;b=a.d.c-a.e.c;c=RD(a.g,154);Umb(c.b,new Ykc(b));Umb(c.c,new $kc(b));xgb(c.i,new alc(b));} + function Mlc(a){var b;b=new bib;b.a+='VerticalSegment ';Yhb(b,a.e);b.a+=' ';Zhb(b,Eb(new Gb,new Anb(a.k)));return b.a} + function Fmc(a,b){var c,d,e;c=0;for(e=b3b(a,b).Kc();e.Ob();){d=RD(e.Pb(),12);c+=mQb(d,(Ywc(),Iwc))!=null?1:0;}return c} + function VTc(a,b,c){var d,e,f;d=0;for(f=Sub(a,0);f.b!=f.d.c;){e=Kfb(UD(evb(f)));if(e>c){break}else e>=b&&++d;}return d} + function Wv(b,c){Qb(b);try{return b._b(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Nk(b,c){Qb(b);try{return b.Hc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Ok(b,c){Qb(b);try{return b.Mc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return false}else throw Adb(a)}} + function Xv(b,c){Qb(b);try{return b.xc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return null}else throw Adb(a)}} + function Yv(b,c){Qb(b);try{return b.Bc(c)}catch(a){a=zdb(a);if(ZD(a,212)||ZD(a,169)){return null}else throw Adb(a)}} + function aMc(a,b){switch(b.g){case 2:case 1:return b3b(a,b);case 3:case 4:return hv(b3b(a,b));}return yob(),yob(),vob} + function QAd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (name: ';Nhb(b,a.zb);b.a+=')';return b.a} + function Fgd(a){var b;b=RD(cub(a.c.c,''),233);if(!b){b=new fgd(ogd(ngd(new pgd,''),'Other'));dub(a.c.c,'',b);}return b} + function hBd(a,b,c){var d,e;e=a.sb;a.sb=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,4,e,b);!c?(c=d):c.nj(d);}return c} + function ZVd(a,b,c){var d,e;e=a.r;a.r=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,8,e,a.r);!c?(c=d):c.nj(d);}return c} + function q5d(a,b,c){var d,e;d=new P3d(a.e,4,13,(e=b.c,e?e:(JTd(),wTd)),null,fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function p5d(a,b,c){var d,e;d=new P3d(a.e,3,13,null,(e=b.c,e?e:(JTd(),wTd)),fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function Oee(a,b){var c,d;c=RD(b,691);d=c.el();!d&&c.fl(d=ZD(b,90)?new afe(a,RD(b,29)):new mfe(a,RD(b,156)));return d} + function KHd(a,b,c){var d;a._i(a.i+1);d=a.Zi(b,c);b!=a.i&&hib(a.g,b,a.g,b+1,a.i-b);bD(a.g,b,d);++a.i;a.Mi(b,c);a.Ni();} + function Hyb(a,b){var c;if(b.a){c=b.a.a.length;!a.a?(a.a=new dib(a.d)):Zhb(a.a,a.b);Xhb(a.a,b.a,b.d.length,c);}return a} + function wib(a,b){var c;a.c=b;a.a=pjb(b);a.a<54&&(a.f=(c=b.d>1?DFb(b.a[0],b.a[1]):DFb(b.a[0],0),Xdb(b.e>0?c:Odb(c))));} + function MDb(a,b){var c;c=new IEb;if(!a.a.Bd(c)){LCb(a);return Kvb(),Kvb(),Jvb}return Kvb(),new Ovb(uFb(LDb(a,c.a,b)))} + function t9b(a,b){var c;if(a.c.length==0){return}c=RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199);Znb(c,new F9b);q9b(c,b);} + function z9b(a,b){var c;if(a.c.length==0){return}c=RD(anb(a,$C(jR,WAe,10,a.c.length,0,1)),199);Znb(c,new K9b);q9b(c,b);} + function pb(a,b){return bE(a)?lhb(a,b):_D(a)?Lfb(a,b):$D(a)?(uFb(a),dE(a)===dE(b)):YD(a)?a.Fb(b):aD(a)?mb(a,b):Hz(a,b)} + function Cvd(a,b,c){if(b<0){Tvd(a,c);}else {if(!c.rk()){throw Adb(new agb(KHe+c.xe()+LHe))}RD(c,69).wk().Ek(a,a.hi(),b);}} + function xFb(a,b,c){if(a<0||b>c){throw Adb(new veb(_xe+a+bye+b+', size: '+c))}if(a>b){throw Adb(new agb(_xe+a+aye+b))}} + function oVd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (source: ';Nhb(b,a.d);b.a+=')';return b.a} + function JSd(a){if(a>=65&&a<=70){return a-65+10}if(a>=97&&a<=102){return a-97+10}if(a>=48&&a<=57){return a-48}return 0} + function lMb(a){hMb();var b,c,d,e;for(c=nMb(),d=0,e=c.length;d=0?jjb(a):Xib(jjb(Odb(a)))));} + function G0b(a,b,c,d,e,f){this.e=new bnb;this.f=(BEc(),AEc);Rmb(this.e,a);this.d=b;this.a=c;this.b=d;this.f=e;this.c=f;} + function bQb(a,b,c){a.n=YC(lE,[Nve,rxe],[376,28],14,[c,eE($wnd.Math.ceil(b/32))],2);a.o=b;a.p=c;a.j=b-1>>1;a.k=c-1>>1;} + function ggb(a){a-=a>>1&1431655765;a=(a>>2&858993459)+(a&858993459);a=(a>>4)+a&252645135;a+=a>>8;a+=a>>16;return a&63} + function C4d(a,b){var c,d;for(d=new dMd(a);d.e!=d.i.gc();){c=RD(bMd(d),142);if(dE(b)===dE(c)){return true}}return false} + function Iee(a,b,c){var d,e,f;f=(e=N5d(a.b,b),e);if(f){d=RD(tfe(Pee(a,f),''),29);if(d){return Ree(a,d,b,c)}}return null} + function Lee(a,b,c){var d,e,f;f=(e=N5d(a.b,b),e);if(f){d=RD(tfe(Pee(a,f),''),29);if(d){return See(a,d,b,c)}}return null} + function IDd(a,b){var c;c=Ao(a.i,b);if(c==null){throw Adb(new CDd('Node did not exist in input.'))}wEd(b,c);return null} + function wvd(a,b){var c;c=wYd(a,b);if(ZD(c,331)){return RD(c,35)}throw Adb(new agb(KHe+b+"' is not a valid attribute"))} + function VGd(a,b,c){var d;d=a.gc();if(b>d)throw Adb(new aMd(b,d));if(a.Si()&&a.Hc(c)){throw Adb(new agb(LIe))}a.Gi(b,c);} + function w7b(a,b){b.Ug('Sort end labels',1);FDb(CDb(EDb(new SDb(null,new Swb(a.b,16)),new H7b),new J7b),new L7b);b.Vg();} + function Cmd(){Cmd=geb;Amd=new Gmd(Sye,0);zmd=new Gmd(Oye,1);ymd=new Gmd(Nye,2);xmd=new Gmd(Zye,3);Bmd=new Gmd('UP',4);} + function gbd(){gbd=geb;dbd=new hbd('P1_STRUCTURE',0);ebd=new hbd('P2_PROCESSING_ORDER',1);fbd=new hbd('P3_EXECUTION',2);} + function r0c(){r0c=geb;q0c=mfd(mfd(rfd(mfd(mfd(rfd(pfd(new ufd,(YVc(),VVc),(WYc(),VYc)),WVc),RYc),TYc),XVc),NYc),UYc);} + function s8b(a){switch(RD(mQb(a,(Ywc(),owc)),311).g){case 1:pQb(a,owc,(Gvc(),Dvc));break;case 2:pQb(a,owc,(Gvc(),Fvc));}} + function bUc(a){switch(a){case 0:return new mUc;case 1:return new cUc;case 2:return new hUc;default:throw Adb(new _fb);}} + function Fmd(a){switch(a.g){case 2:return zmd;case 1:return ymd;case 4:return xmd;case 3:return Bmd;default:return Amd;}} + function UNb(a,b){switch(a.b.g){case 0:case 1:return b;case 2:case 3:return new Uid(b.d,0,b.a,b.b);default:return null;}} + function rpd(a){switch(a.g){case 1:return ppd;case 2:return Yod;case 3:return Xod;case 4:return npd;default:return opd;}} + function spd(a){switch(a.g){case 1:return npd;case 2:return ppd;case 3:return Yod;case 4:return Xod;default:return opd;}} + function tpd(a){switch(a.g){case 1:return Xod;case 2:return npd;case 3:return ppd;case 4:return Yod;default:return opd;}} + function cyd(a,b,c,d){switch(b){case 1:return !a.n&&(a.n=new C5d(I4,a,1,7)),a.n;case 2:return a.k;}return Axd(a,b,c,d)} + function uLd(a,b,c){var d,e;if(a.Pj()){e=a.Qj();d=SHd(a,b,c);a.Jj(a.Ij(7,sgb(c),d,b,e));return d}else {return SHd(a,b,c)}} + function VNd(a,b){var c,d,e;if(a.d==null){++a.e;--a.f;}else {e=b.ld();c=b.Bi();d=(c&lve)%a.d.length;iOd(a,d,XNd(a,d,c,e));}} + function xWd(a,b){var c;c=(a.Bb&gwe)!=0;b?(a.Bb|=gwe):(a.Bb&=-1025);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,10,c,b));} + function DWd(a,b){var c;c=(a.Bb&qxe)!=0;b?(a.Bb|=qxe):(a.Bb&=-4097);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,12,c,b));} + function EWd(a,b){var c;c=(a.Bb&bKe)!=0;b?(a.Bb|=bKe):(a.Bb&=-8193);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,15,c,b));} + function FWd(a,b){var c;c=(a.Bb&cKe)!=0;b?(a.Bb|=cKe):(a.Bb&=-2049);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,11,c,b));} + function zKc(a){var b;if(a.g){b=a.c.kg()?a.f:a.a;BKc(b.a,a.o,true);BKc(b.a,a.o,false);pQb(a.o,(yCc(),BBc),(Bod(),vod));}} + function Orc(a){var b;if(!a.a){throw Adb(new dgb('Cannot offset an unassigned cut.'))}b=a.c-a.b;a.b+=b;Qrc(a,b);Rrc(a,b);} + function JDd(a,b){var c;c=Wjb(a.k,b);if(c==null){throw Adb(new CDd('Port did not exist in input.'))}wEd(b,c);return null} + function Jje(a){var b,c;for(c=Kje(BXd(a)).Kc();c.Ob();){b=WD(c.Pb());if(bAd(a,b)){return USd((TSd(),SSd),b)}}return null} + function qJb(a){var b,c;for(c=a.p.a.ec().Kc();c.Ob();){b=RD(c.Pb(),218);if(b.f&&a.b[b.c]<-1.0E-10){return b}}return null} + function Lr(a){var b,c;c=Thb(new bib,91);b=true;while(a.Ob()){b||(c.a+=pve,c);b=false;Yhb(c,a.Pb());}return (c.a+=']',c).a} + function o_b(a){var b,c,d;b=new bnb;for(d=new Anb(a.b);d.ab){return 1}if(a==b){return a==0?Qfb(1/a,1/b):0}return isNaN(a)?isNaN(b)?0:1:-1} + function pmb(a){var b;b=a.a[a.c-1&a.a.length-1];if(b==null){return null}a.c=a.c-1&a.a.length-1;bD(a.a,a.c,null);return b} + function Dqe(a){var b,c,d;d=0;c=a.length;for(b=0;b=1?zmd:xmd}return c} + function Xhc(a){switch(RD(mQb(a,(yCc(),yAc)),223).g){case 1:return new jqc;case 3:return new arc;default:return new dqc;}} + function MCb(a){if(a.c){MCb(a.c);}else if(a.d){throw Adb(new dgb("Stream already terminated, can't be modified or used"))}} + function Ltb(a,b,c){var d;d=a.a.get(b);a.a.set(b,c===undefined?null:c);if(d===undefined){++a.c;++a.b.g;}else {++a.d;}return d} + function HHc(a,b,c){var d,e;for(e=a.a.ec().Kc();e.Ob();){d=RD(e.Pb(),10);if(Be(c,RD(Vmb(b,d.p),16))){return d}}return null} + function u0c(a,b,c){var d;d=0;!!b&&(Emd(a.a)?(d+=b.f.a/2):(d+=b.f.b/2));!!c&&(Emd(a.a)?(d+=c.f.a/2):(d+=c.f.b/2));return d} + function LWb(a,b,c){var d;d=c;!d&&(d=Nqd(new Oqd,0));d.Ug(EAe,2);y0b(a.b,b,d.eh(1));NWb(a,b,d.eh(1));h0b(b,d.eh(1));d.Vg();} + function CGd(a,b,c){var d,e;d=(bvd(),e=new Xxd,e);Vxd(d,b);Wxd(d,c);!!a&&WGd((!a.a&&(a.a=new XZd(D4,a,5)),a.a),d);return d} + function kyd(a){var b;if((a.Db&64)!=0)return awd(a);b=new Shb(awd(a));b.a+=' (identifier: ';Nhb(b,a.k);b.a+=')';return b.a} + function kXd(a,b){var c;c=(a.Bb&QHe)!=0;b?(a.Bb|=QHe):(a.Bb&=-32769);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,18,c,b));} + function a6d(a,b){var c;c=(a.Bb&QHe)!=0;b?(a.Bb|=QHe):(a.Bb&=-32769);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,18,c,b));} + function AWd(a,b){var c;c=(a.Bb&Ove)!=0;b?(a.Bb|=Ove):(a.Bb&=-16385);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,16,c,b));} + function c6d(a,b){var c;c=(a.Bb&txe)!=0;b?(a.Bb|=txe):(a.Bb&=-65537);(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new Q3d(a,1,20,c,b));} + function qse(a){var b;b=$C(hE,zwe,28,2,15,1);a-=txe;b[0]=(a>>10)+uxe&Bwe;b[1]=(a&1023)+56320&Bwe;return Ihb(b,0,b.length)} + function Zfb(a){var b;b=Neb(a);if(b>3.4028234663852886E38){return oxe}else if(b<-3.4028234663852886E38){return pxe}return b} + function Bdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a+b;if(jxe'+aXc(b.c):'e_'+tb(b),!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))} + function rWc(a,b){return lhb(!!b.b&&!!b.c?aXc(b.b)+'->'+aXc(b.c):'e_'+tb(b),!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))} + function $y(a,b){Zy();return bz(pwe),$wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b))} + function Ymd(){Ymd=geb;Xmd=new Zmd(Sye,0);Vmd=new Zmd('POLYLINE',1);Umd=new Zmd('ORTHOGONAL',2);Wmd=new Zmd('SPLINES',3);} + function _6c(){_6c=geb;Z6c=new a7c('ASPECT_RATIO_DRIVEN',0);$6c=new a7c('MAX_SCALE_DRIVEN',1);Y6c=new a7c('AREA_DRIVEN',2);} + function Db(b,c,d){var e;try{Cb(b,c,d);}catch(a){a=zdb(a);if(ZD(a,606)){e=a;throw Adb(new Deb(e))}else throw Adb(a)}return c} + function Im(a){var b,c,d;for(c=0,d=a.length;cb&&d.Ne(a[f-1],a[f])>0;--f){g=a[f];bD(a,f,a[f-1]);bD(a,f-1,g);}}} + function Egd(a,b){var c,d,e,f,g;c=b.f;dub(a.c.d,c,b);if(b.g!=null){for(e=b.g,f=0,g=e.length;fb){fvb(c);break}}cvb(c,b);} + function Kic(a,b){var c,d,e;d=Zjc(b);e=Kfb(UD(hFc(d,(yCc(),TBc))));c=$wnd.Math.max(0,e/2-0.5);Iic(b,c,1);Rmb(a,new hjc(b,c));} + function L5c(a,b,c){var d;c.Ug('Straight Line Edge Routing',1);c.dh(b,eFe);d=RD(Gxd(b,(u2c(),t2c)),27);M5c(a,d);c.dh(b,gFe);} + function K9c(a,b){a.n.c.length==0&&Rmb(a.n,new _9c(a.s,a.t,a.i));Rmb(a.b,b);W9c(RD(Vmb(a.n,a.n.c.length-1),209),b);M9c(a,b);} + function Zrb(a){var b;this.a=(b=RD(a.e&&a.e(),9),new Fsb(b,RD(WEb(b,b.length),9),0));this.b=$C(jJ,rve,1,this.a.a.length,5,1);} + function jeb(a){var b;if(Array.isArray(a)&&a.Tm===keb){return nfb(rb(a))+'@'+(b=tb(a)>>>0,b.toString(16))}return a.toString()} + function jD(a,b){if(a.h==fxe&&a.m==0&&a.l==0){b&&(eD=hD(0,0,0));return gD((MD(),KD))}b&&(eD=hD(a.l,a.m,a.h));return hD(0,0,0)} + function _Gb(a,b){switch(b.g){case 2:return a.b;case 1:return a.c;case 4:return a.d;case 3:return a.a;default:return false;}} + function IYb(a,b){switch(b.g){case 2:return a.b;case 1:return a.c;case 4:return a.d;case 3:return a.a;default:return false;}} + function vyd(a,b,c,d){switch(b){case 3:return a.f;case 4:return a.g;case 5:return a.i;case 6:return a.j;}return cyd(a,b,c,d)} + function oIb(a,b){if(b==a.d){return a.e}else if(b==a.e){return a.d}else {throw Adb(new agb('Node '+b+' not part of edge '+a))}} + function Uvd(a,b){var c;c=wYd(a.Dh(),b);if(ZD(c,102)){return RD(c,19)}throw Adb(new agb(KHe+b+"' is not a valid reference"))} + function Bvd(a,b,c,d){if(b<0){Svd(a,c,d);}else {if(!c.rk()){throw Adb(new agb(KHe+c.xe()+LHe))}RD(c,69).wk().Ck(a,a.hi(),b,d);}} + function ig(a){var b;if(a.b){ig(a.b);if(a.b.d!=a.c){throw Adb(new Jrb)}}else if(a.d.dc()){b=RD(a.f.c.xc(a.e),16);!!b&&(a.d=b);}} + function VMb(a){RMb();var b,c,d,e;b=a.o.b;for(d=RD(RD(Qc(a.r,(qpd(),npd)),21),87).Kc();d.Ob();){c=RD(d.Pb(),117);e=c.e;e.b+=b;}} + function SRb(a){var b,c,d;this.a=new Iub;for(d=new Anb(a);d.a=e){return b.c+c}}return b.c+b.b.gc()} + function lQd(a,b){jQd();var c,d,e,f;d=iZd(a);e=b;Wnb(d,0,d.length,e);for(c=0;c0){d+=e;++c;}}c>1&&(d+=a.d*(c-1));return d} + function FFd(a){var b,c,d,e,f;f=HFd(a);c=cve(a.c);d=!c;if(d){e=new MB;sC(f,'knownLayouters',e);b=new QFd(e);xgb(a.c,b);}return f} + function fHd(a){var b,c,d;d=new Qhb;d.a+='[';for(b=0,c=a.gc();b0&&(BFb(b-1,a.length),a.charCodeAt(b-1)==58)&&!mSd(a,aSd,bSd)} + function Sib(a,b){var c;if(dE(a)===dE(b)){return true}if(ZD(b,92)){c=RD(b,92);return a.e==c.e&&a.d==c.d&&Tib(a,c.a)}return false} + function vpd(a){qpd();switch(a.g){case 4:return Yod;case 1:return Xod;case 3:return npd;case 2:return ppd;default:return opd;}} + function jBb(a){var b,c;if(a.b){return a.b}c=dBb?null:a.d;while(c){b=dBb?null:c.b;if(b){return b}c=dBb?null:c.d;}return SAb(),RAb} + function LJb(a){var b,c,d;d=Kfb(UD(a.a.of((umd(),cmd))));for(c=new Anb(a.a.Sf());c.a>5;b=a&31;d=$C(kE,Pwe,28,c+1,15,1);d[c]=1<3){e*=10;--f;}a=(a+(e>>1))/e|0;}d.i=a;return true} + function BYd(a,b){var c,d,e;c=(a.i==null&&rYd(a),a.i);d=b.Lj();if(d!=-1){for(e=c.length;d=0;--d){b=c[d];for(e=0;e>1;this.k=b-1>>1;} + function Dfd(a){Afd();if(RD(a.of((umd(),pld)),181).Hc((dqd(),bqd))){RD(a.of(Lld),181).Fc((Pod(),Ood));RD(a.of(pld),181).Mc(bqd);}} + function ndc(a){var b,c;b=a.d==(btc(),Ysc);c=jdc(a);b&&!c||!b&&c?pQb(a.a,(yCc(),Rzc),(Rjd(),Pjd)):pQb(a.a,(yCc(),Rzc),(Rjd(),Ojd));} + function QCc(){QCc=geb;GCc();OCc=(yCc(),bCc);PCc=dv(cD(WC(V5,1),kEe,149,0,[SBc,TBc,VBc,WBc,ZBc,$Bc,_Bc,aCc,dCc,fCc,UBc,XBc,cCc]));} + function RDb(a,b){var c;c=RD(zDb(a,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);return c.Qc(__c(c.gc()))} + function nXc(a,b){var c,d;d=new zAb(a.a.ad(b,true));if(d.a.gc()<=1){throw Adb(new Ngb)}c=d.a.ec().Kc();c.Pb();return RD(c.Pb(),40)} + function lQc(a,b,c){var d,e;d=Kfb(a.p[b.i.p])+Kfb(a.d[b.i.p])+b.n.b+b.a.b;e=Kfb(a.p[c.i.p])+Kfb(a.d[c.i.p])+c.n.b+c.a.b;return e-d} + function XHd(a,b){var c;if(a.i>0){if(b.lengtha.i&&bD(b,a.i,null);return b} + function MXd(a){var b;if((a.Db&64)!=0)return QAd(a);b=new Shb(QAd(a));b.a+=' (instanceClassName: ';Nhb(b,a.D);b.a+=')';return b.a} + function ySd(a){var b,c,d,e;e=0;for(c=0,d=a.length;c0){a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=XNd(a,e,d,b);return c!=-1}else {return false}} + function Nrb(a,b){var c,d;a.a=Bdb(a.a,1);a.c=$wnd.Math.min(a.c,b);a.b=$wnd.Math.max(a.b,b);a.d+=b;c=b-a.f;d=a.e+c;a.f=d-a.e-c;a.e=d;} + function yyd(a,b){switch(b){case 3:Ayd(a,0);return;case 4:Cyd(a,0);return;case 5:Dyd(a,0);return;case 6:Eyd(a,0);return;}hyd(a,b);} + function c3b(a,b){switch(b.g){case 1:return dr(a.j,(J3b(),E3b));case 2:return dr(a.j,(J3b(),G3b));default:return yob(),yob(),vob;}} + function zm(a){tm();var b;b=a.Pc();switch(b.length){case 0:return sm;case 1:return new Dy(Qb(b[0]));default:return new Kx(Im(b));}} + function kMd(b,c){b.Xj();try{b.d.bd(b.e++,c);b.f=b.d.j;b.g=-1;}catch(a){a=zdb(a);if(ZD(a,77)){throw Adb(new Jrb)}else throw Adb(a)}} + function a8d(){a8d=geb;$7d=new b8d;T7d=new e8d;U7d=new h8d;V7d=new k8d;W7d=new n8d;X7d=new q8d;Y7d=new t8d;Z7d=new w8d;_7d=new z8d;} + function YA(a,b){WA();var c,d;c=_A(($A(),$A(),ZA));d=null;b==c&&(d=RD(Xjb(VA,a),624));if(!d){d=new XA(a);b==c&&$jb(VA,a,d);}return d} + function zDc(a){wDc();var b;(!a.q?(yob(),yob(),wob):a.q)._b((yCc(),iBc))?(b=RD(mQb(a,iBc),203)):(b=RD(mQb(Y2b(a),jBc),203));return b} + function hFc(a,b){var c,d;d=null;if(nQb(a,(yCc(),YBc))){c=RD(mQb(a,YBc),96);c.pf(b)&&(d=c.of(b));}d==null&&(d=mQb(Y2b(a),b));return d} + function Ze(a,b){var c,d,e;if(ZD(b,44)){c=RD(b,44);d=c.ld();e=Xv(a.Rc(),d);return Hb(e,c.md())&&(e!=null||a.Rc()._b(d))}return false} + function $Nd(a,b){var c,d,e;if(a.f>0){a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=WNd(a,e,d,b);if(c){return c.md()}}return null} + function qLd(a,b,c){var d,e,f;if(a.Pj()){d=a.i;f=a.Qj();KHd(a,d,b);e=a.Ij(3,null,b,d,f);!c?(c=e):c.nj(e);}else {KHd(a,a.i,b);}return c} + function f$d(a,b,c){var d,e;d=new P3d(a.e,4,10,(e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)),null,fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function e$d(a,b,c){var d,e;d=new P3d(a.e,3,10,null,(e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)),fZd(a,b),false);!c?(c=d):c.nj(d);return c} + function SMb(a){RMb();var b;b=new sjd(RD(a.e.of((umd(),nld)),8));if(a.B.Hc((dqd(),Ypd))){b.a<=0&&(b.a=20);b.b<=0&&(b.b=20);}return b} + function jjb(a){Pib();var b,c;c=Ydb(a);b=Ydb(Udb(a,32));if(b!=0){return new bjb(c,b)}if(c>10||c<0){return new ajb(1,c)}return Lib[c]} + function Mdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a%b;if(jxe=0){f=f.a[1];}else {e=f;f=f.a[0];}}return e} + function Qyb(a,b,c){var d,e,f;e=null;f=a.b;while(f){d=a.a.Ne(b,f.d);if(c&&d==0){return f}if(d<=0){f=f.a[0];}else {e=f;f=f.a[1];}}return e} + function rmc(a,b,c,d){var e,f,g;e=false;if(Lmc(a.f,c,d)){Omc(a.f,a.a[b][c],a.a[b][d]);f=a.a[b];g=f[d];f[d]=f[c];f[c]=g;e=true;}return e} + function Nqc(a,b,c){var d,e,f,g;e=RD(Wjb(a.b,c),183);d=0;for(g=new Anb(b.j);g.a>5;b&=31;e=a.d+c+(b==0?0:1);d=$C(kE,Pwe,28,e,15,1);rjb(d,a.a,c,b);f=new cjb(a.e,e,d);Rib(f);return f} + function zGc(a,b){var c,d,e;for(d=new is(Mr(a3b(a).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);e=c.d.i;if(e.c==b){return false}}return true} + function _Ec(a,b,c){var d,e,f,g,h;g=a.k;h=b.k;d=c[g.g][h.g];e=UD(hFc(a,d));f=UD(hFc(b,d));return $wnd.Math.max((uFb(e),e),(uFb(f),f))} + function lA(){if(Error.stackTraceLimit>0){$wnd.Error.stackTraceLimit=Error.stackTraceLimit=64;return true}return 'stack' in new Error} + function sGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))>0} + function uGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))<0} + function tGb(a,b){return Zy(),Zy(),bz(pwe),($wnd.Math.abs(a-b)<=pwe||a==b||isNaN(a)&&isNaN(b)?0:ab?1:cz(isNaN(a),isNaN(b)))<=0} + function Efb(a,b){var c=0;while(!b[c]||b[c]==''){c++;}var d=b[c++];for(;c0&&this.b>0&&(this.g=Aad(this.c,this.b,this.a));} + function rC(f,a){var b=f.a;var c;a=String(a);b.hasOwnProperty(a)&&(c=b[a]);var d=(HC(),GC)[typeof c];var e=d?d(c):NC(typeof c);return e} + function uDd(a){var b,c,d;d=null;b=uIe in a.a;c=!b;if(c){throw Adb(new CDd('Every element must have an id.'))}d=tDd(qC(a,uIe));return d} + function Qqe(a){var b,c;c=Rqe(a);b=null;while(a.c==2){Mqe(a);if(!b){b=(Vse(),Vse(),new iue(2));hue(b,c);c=b;}c.Jm(Rqe(a));}return c} + function jOd(a,b){var c,d,e;a._j();d=b==null?0:tb(b);e=(d&lve)%a.d.length;c=WNd(a,e,d,b);if(c){hOd(a,c);return c.md()}else {return null}} + function Qib(a,b){if(a.e>b.e){return 1}if(a.eb.d){return a.e}if(a.d=48&&a<48+$wnd.Math.min(10,10)){return a-48}if(a>=97&&a<97){return a-97+10}if(a>=65&&a<65){return a-65+10}return -1} + function UHc(a,b){if(b.c==a){return b.d}else if(b.d==a){return b.c}throw Adb(new agb('Input edge is not connected to the input port.'))} + function Fae(a){if(mhb(FGe,a)){return Geb(),Feb}else if(mhb(GGe,a)){return Geb(),Eeb}else {throw Adb(new agb('Expecting true or false'))}} + function jFb(a){switch(typeof(a)){case jve:return ohb(a);case ive:return Nfb(a);case hve:return Jeb(a);default:return a==null?0:kFb(a);}} + function mfd(a,b){if(a.a<0){throw Adb(new dgb('Did not call before(...) or after(...) before calling add(...).'))}tfd(a,a.a,b);return a} + function FId(a){EId();if(ZD(a,162)){return RD(Wjb(CId,zK),295).Rg(a)}if(Ujb(CId,rb(a))){return RD(Wjb(CId,rb(a)),295).Rg(a)}return null} + function Wwd(a){var b,c;if((a.Db&32)==0){c=(b=RD(Ywd(a,16),29),AYd(!b?a.ii():b)-AYd(a.ii()));c!=0&&$wd(a,32,$C(jJ,rve,1,c,5,1));}return a} + function $wd(a,b,c){var d;if((a.Db&b)!=0){if(c==null){Zwd(a,b);}else {d=Xwd(a,b);d==-1?(a.Eb=c):bD(SD(a.Eb),d,c);}}else c!=null&&Twd(a,b,c);} + function tTc(a,b,c,d){var e,f;if(b.c.length==0){return}e=pTc(c,d);f=oTc(b);FDb(PDb(new SDb(null,new Swb(f,1)),new CTc),new GTc(a,c,e,d));} + function rmb(a,b){var c,d,e,f;d=a.a.length-1;c=b-a.b&d;f=a.c-b&d;e=a.c-a.b&d;zmb(c=f){umb(a,b);return -1}else {vmb(a,b);return 1}} + function Hvd(a){var b,c,d;d=a.Jh();if(!d){b=0;for(c=a.Ph();c;c=c.Ph()){if(++b>wxe){return c.Qh()}d=c.Jh();if(!!d||c==a){break}}}return d} + function Ue(a,b){var c;if(dE(b)===dE(a)){return true}if(!ZD(b,21)){return false}c=RD(b,21);if(c.gc()!=a.gc()){return false}return a.Ic(c)} + function kNc(a,b){if(a.eb.e){return 1}else if(a.fb.f){return 1}return tb(a)-tb(b)} + function mhb(a,b){uFb(a);if(b==null){return false}if(lhb(a,b)){return true}return a.length==b.length&&lhb(a.toLowerCase(),b.toLowerCase())} + function Hgb(a){var b,c;if(Ddb(a,-129)>0&&Ddb(a,128)<0){return Jgb(),b=Ydb(a)+128,c=Igb[b],!c&&(c=Igb[b]=new zgb(a)),c}return new zgb(a)} + function U$b(){U$b=geb;T$b=new V$b(LAe,0);R$b=new V$b('INSIDE_PORT_SIDE_GROUPS',1);Q$b=new V$b('GROUP_MODEL_ORDER',2);S$b=new V$b(MAe,3);} + function ufe(a){var b;a.b||vfe(a,(b=Hee(a.e,a.a),!b||!lhb(GGe,$Nd((!b.b&&(b.b=new SVd((JTd(),FTd),C8,b)),b.b),'qualified'))));return a.c} + function BA(a,b){var c,d;c=(BFb(b,a.length),a.charCodeAt(b));d=b+1;while(d2000){Oz=a;Pz=$wnd.setTimeout(Yz,10);}}if(Nz++==0){_z(($z(),Zz));return true}return false} + function lBb(a,b,c){var d;(bBb?(jBb(a),true):cBb?(SAb(),true):fBb?(SAb(),true):eBb&&(SAb(),false))&&(d=new aBb(b),d.b=c,hBb(a,d),undefined);} + function oNb(a,b){var c;c=!a.A.Hc((Qpd(),Ppd))||a.q==(Bod(),wod);a.u.Hc((Pod(),Lod))?c?mNb(a,b):qNb(a,b):a.u.Hc(Nod)&&(c?nNb(a,b):rNb(a,b));} + function Bed(a){var b;if(dE(Gxd(a,(umd(),Xkd)))===dE((Fnd(),Dnd))){if(!vCd(a)){Ixd(a,Xkd,End);}else {b=RD(Gxd(vCd(a),Xkd),346);Ixd(a,Xkd,b);}}} + function _fc(a){var b,c;if(nQb(a.d.i,(yCc(),tBc))){b=RD(mQb(a.c.i,tBc),17);c=RD(mQb(a.d.i,tBc),17);return hgb(b.a,c.a)>0}else {return false}} + function g_b(a,b,c){return new Uid($wnd.Math.min(a.a,b.a)-c/2,$wnd.Math.min(a.b,b.b)-c/2,$wnd.Math.abs(a.a-b.a)+c,$wnd.Math.abs(a.b-b.b)+c)} + function _mc(a){var b;this.d=new bnb;this.j=new pjd;this.g=new pjd;b=a.g.b;this.f=RD(mQb(Y2b(b),(yCc(),rAc)),88);this.e=Kfb(UD(k2b(b,ZBc)));} + function onc(a){this.d=new bnb;this.e=new gub;this.c=$C(kE,Pwe,28,(qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,15,1);this.b=a;} + function $pc(a,b,c){var d;d=c[a.g][b];switch(a.g){case 1:case 3:return new rjd(0,d);case 2:case 4:return new rjd(d,0);default:return null;}} + function Ced(b,c,d){var e,f;f=RD(ltd(c.f),205);try{f.rf(b,d);mtd(c.f,f);}catch(a){a=zdb(a);if(ZD(a,103)){e=a;throw Adb(e)}else throw Adb(a)}} + function tEd(a,b,c){var d,e,f,g,h,i;d=null;h=vgd(ygd(),b);f=null;if(h){e=null;i=zhd(h,c);g=null;i!=null&&(g=a.qf(h,i));e=g;f=e;}d=f;return d} + function sSd(a,b,c,d){var e;e=a.length;if(b>=e)return e;for(b=b>0?b:0;bd&&bD(b,d,null);return b} + function lob(a,b){var c,d;d=a.a.length;b.lengthd&&bD(b,d,null);return b} + function Bde(a,b){var c,d;++a.j;if(b!=null){c=(d=a.a.Cb,ZD(d,99)?RD(d,99).th():null);if(Jnb(b,c)){$wd(a.a,4,c);return}}$wd(a.a,4,RD(b,129));} + function mne(a){var b;if(a==null)return null;b=Hqe(nue(a,true));if(b==null){throw Adb(new Mle("Invalid hexBinary value: '"+a+"'"))}return b} + function wA(a,b,c){var d;if(b.a.length>0){Rmb(a.b,new kB(b.a,c));d=b.a.length;0d&&(b.a+=Hhb($C(hE,zwe,28,-d,15,1)));}} + function yIb(a,b,c){var d,e,f;if(c[b.d]){return}c[b.d]=true;for(e=new Anb(CIb(b));e.a=a.b>>1){d=a.c;for(c=a.b;c>b;--c){d=d.b;}}else {d=a.a.a;for(c=0;c=0?a.Wh(e):Rvd(a,d)):c<0?Rvd(a,d):RD(d,69).wk().Bk(a,a.hi(),c)} + function Fxd(a){var b,c,d;d=(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),a.o);for(c=d.c.Kc();c.e!=c.i.gc();){b=RD(c.Yj(),44);b.md();}return dOd(d)} + function iGd(a){var b;if(ZD(a.a,4)){b=FId(a.a);if(b==null){throw Adb(new dgb(HGe+a.b+"'. "+DGe+(lfb(b6),b6.k)+EGe))}return b}else {return a.a}} + function iSd(a,b){var c,d;if(a.j.length!=b.j.length)return false;for(c=0,d=a.j.length;c=64&&b<128&&(e=Rdb(e,Sdb(1,b-64)));}return e} + function k2b(a,b){var c,d;d=null;if(nQb(a,(umd(),amd))){c=RD(mQb(a,amd),96);c.pf(b)&&(d=c.of(b));}d==null&&!!Y2b(a)&&(d=mQb(Y2b(a),b));return d} + function i0b(a,b){var c;c=RD(mQb(a,(yCc(),RAc)),75);if(br(b,f0b)){if(!c){c=new Ejd;pQb(a,RAc,c);}else {Xub(c);}}else !!c&&pQb(a,RAc,null);return c} + function tSb(){tSb=geb;sSb=(umd(),Yld);mSb=Ukd;hSb=Dkd;nSb=tld;qSb=(YHb(),UHb);pSb=SHb;rSb=WHb;oSb=RHb;jSb=(eSb(),aSb);iSb=_Rb;kSb=cSb;lSb=dSb;} + function PZb(a){NZb();this.c=new bnb;this.d=a;switch(a.g){case 0:case 2:this.a=Fob(MZb);this.b=oxe;break;case 3:case 1:this.a=MZb;this.b=pxe;}} + function c9b(a){var b;if(!Cod(RD(mQb(a,(yCc(),BBc)),101))){return}b=a.b;d9b((tFb(0,b.c.length),RD(b.c[0],30)));d9b(RD(Vmb(b,b.c.length-1),30));} + function ohc(a,b){b.Ug('Self-Loop post-processing',1);FDb(CDb(CDb(EDb(new SDb(null,new Swb(a.b,16)),new uhc),new whc),new yhc),new Ahc);b.Vg();} + function xrd(a,b,c){var d,e;if(a.c){Dyd(a.c,a.c.i+b);Eyd(a.c,a.c.j+c);}else {for(e=new Anb(a.b);e.a=0&&(c.d=a.t);break;case 3:a.t>=0&&(c.a=a.t);}if(a.C){c.b=a.C.b;c.c=a.C.c;}} + function JDc(){JDc=geb;IDc=new LDc(mEe,0);FDc=new LDc(BBe,1);GDc=new LDc('LINEAR_SEGMENTS',2);EDc=new LDc('BRANDES_KOEPF',3);HDc=new LDc(lEe,4);} + function IRb(){IRb=geb;FRb=new JRb(_ye,0);ERb=new JRb(aze,1);GRb=new JRb(bze,2);HRb=new JRb(cze,3);FRb.a=false;ERb.a=true;GRb.a=false;HRb.a=true;} + function IPb(){IPb=geb;FPb=new JPb(_ye,0);EPb=new JPb(aze,1);GPb=new JPb(bze,2);HPb=new JPb(cze,3);FPb.a=false;EPb.a=true;GPb.a=false;HPb.a=true;} + function Ivd(a,b,c,d){var e;if(c>=0){return a.Sh(b,c,d)}else {!!a.Ph()&&(d=(e=a.Fh(),e>=0?a.Ah(d):a.Ph().Th(a,-1-e,null,d)));return a.Ch(b,c,d)}} + function Zyd(a,b){switch(b){case 7:!a.e&&(a.e=new Yie(G4,a,7,4));sLd(a.e);return;case 8:!a.d&&(a.d=new Yie(G4,a,8,5));sLd(a.d);return;}yyd(a,b);} + function Ixd(a,b,c){c==null?(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),jOd(a.o,b)):(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),fOd(a.o,b,c));return a} + function Aob(a,b){yob();var c,d,e,f;c=a;f=b;if(ZD(a,21)&&!ZD(b,21)){c=b;f=a;}for(e=c.Kc();e.Ob();){d=e.Pb();if(f.Hc(d)){return false}}return true} + function qTc(a,b,c,d){if(b.ac.b){return true}}}return false} + function QD(a,b){if(bE(a)){return !!PD[b]}else if(a.Sm){return !!a.Sm[b]}else if(_D(a)){return !!OD[b]}else if($D(a)){return !!ND[b]}return false} + function udc(a){var b;b=a.a;do{b=RD(hs(new is(Mr(Z2b(b).a.Kc(),new ir))),18).c.i;b.k==(r3b(),o3b)&&a.b.Fc(b);}while(b.k==(r3b(),o3b));a.b=hv(a.b);} + function UGc(a,b){var c,d,e;e=a;for(d=new is(Mr(Z2b(b).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);!!c.c.i.c&&(e=$wnd.Math.max(e,c.c.i.c.p));}return e} + function INb(a,b){var c,d,e;e=0;d=RD(RD(Qc(a.r,b),21),87).Kc();while(d.Ob()){c=RD(d.Pb(),117);e+=c.d.d+c.b.Mf().b+c.d.a;d.Ob()&&(e+=a.w);}return e} + function AMb(a,b){var c,d,e;e=0;d=RD(RD(Qc(a.r,b),21),87).Kc();while(d.Ob()){c=RD(d.Pb(),117);e+=c.d.b+c.b.Mf().a+c.d.c;d.Ob()&&(e+=a.w);}return e} + function O2c(a){var b,c,d,e;d=0;e=Q2c(a);if(e.c.length==0){return 1}else {for(c=new Anb(e);c.a=0?a.Lh(g,c,true):Qvd(a,f,c)):RD(f,69).wk().yk(a,a.hi(),e,c,d)} + function aNb(a,b,c,d){var e,f;f=b.pf((umd(),ild))?RD(b.of(ild),21):a.j;e=lMb(f);if(e==(hMb(),gMb)){return}if(c&&!jMb(e)){return}LKb(cNb(a,e,d),b);} + function Y6b(a){switch(a.g){case 1:return mOb(),lOb;case 3:return mOb(),iOb;case 2:return mOb(),kOb;case 4:return mOb(),jOb;default:return null;}} + function kmc(a,b,c){if(a.e){switch(a.b){case 1:Ulc(a.c,b,c);break;case 0:Vlc(a.c,b,c);}}else {Slc(a.c,b,c);}a.a[b.p][c.p]=a.c.i;a.a[c.p][b.p]=a.c.e;} + function LLc(a){var b,c;if(a==null){return null}c=$C(jR,Nve,199,a.length,0,2);for(b=0;b=0)return e;if(a.ol()){for(d=0;d=e)throw Adb(new aMd(b,e));if(a.Si()){d=a.dd(c);if(d>=0&&d!=b){throw Adb(new agb(LIe))}}return a.Xi(b,c)} + function wx(a,b){this.a=RD(Qb(a),253);this.b=RD(Qb(b),253);if(a.Ed(b)>0||a==(Wk(),Vk)||b==(kl(),jl)){throw Adb(new agb('Invalid range: '+Dx(a,b)))}} + function p_b(a){var b,c;this.b=new bnb;this.c=a;this.a=false;for(c=new Anb(a.a);c.a0);if((b&-b)==b){return eE(b*Kwb(a,31)*4.6566128730773926E-10)}do{c=Kwb(a,31);d=c%b;}while(c-d+(b-1)<0);return eE(d)} + function d2b(a,b,c){switch(c.g){case 1:a.a=b.a/2;a.b=0;break;case 2:a.a=b.a;a.b=b.b/2;break;case 3:a.a=b.a/2;a.b=b.b;break;case 4:a.a=0;a.b=b.b/2;}} + function Onc(a,b,c,d){var e,f;for(e=b;e1&&(f=xIb(a,b));return f} + function yqd(a){var b;b=Kfb(UD(Gxd(a,(umd(),lmd))))*$wnd.Math.sqrt((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a).i);return new rjd(b,b/Kfb(UD(Gxd(a,kmd))))} + function Dzd(a){var b;if(!!a.f&&a.f.Vh()){b=RD(a.f,54);a.f=RD(Vvd(a,b),84);a.f!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,8,b,a.f));}return a.f} + function Ezd(a){var b;if(!!a.i&&a.i.Vh()){b=RD(a.i,54);a.i=RD(Vvd(a,b),84);a.i!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,7,b,a.i));}return a.i} + function Z5d(a){var b;if(!!a.b&&(a.b.Db&64)!=0){b=a.b;a.b=RD(Vvd(a,b),19);a.b!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,21,b,a.b));}return a.b} + function UNd(a,b){var c,d,e;if(a.d==null){++a.e;++a.f;}else {d=b.Bi();_Nd(a,a.f+1);e=(d&lve)%a.d.length;c=a.d[e];!c&&(c=a.d[e]=a.dk());c.Fc(b);++a.f;}} + function Mge(a,b,c){var d;if(b.tk()){return false}else if(b.Ik()!=-2){d=b.ik();return d==null?c==null:pb(d,c)}else return b.qk()==a.e.Dh()&&c==null} + function Io(){var a;dk(16,fwe);a=Wp(16);this.b=$C(XF,ewe,303,a,0,1);this.c=$C(XF,ewe,303,a,0,1);this.a=null;this.e=null;this.i=0;this.f=a-1;this.g=0;} + function j3b(a){v2b.call(this);this.k=(r3b(),p3b);this.j=(dk(6,iwe),new cnb(6));this.b=(dk(2,iwe),new cnb(2));this.d=new T2b;this.f=new C3b;this.a=a;} + function wgc(a){var b,c;if(a.c.length<=1){return}b=tgc(a,(qpd(),npd));vgc(a,RD(b.a,17).a,RD(b.b,17).a);c=tgc(a,ppd);vgc(a,RD(c.a,17).a,RD(c.b,17).a);} + function vHc(a,b,c){var d,e;e=a.a.b;for(d=e.c.length;d102)return -1;if(a<=57)return a-48;if(a<65)return -1;if(a<=70)return a-65+10;if(a<97)return -1;return a-97+10} + function ck(a,b){if(a==null){throw Adb(new Ogb('null key in entry: null='+b))}else if(b==null){throw Adb(new Ogb('null value in entry: '+a+'=null'))}} + function Cr(a,b){var c,d;while(a.Ob()){if(!b.Ob()){return false}c=a.Pb();d=b.Pb();if(!(dE(c)===dE(d)||c!=null&&pb(c,d))){return false}}return !b.Ob()} + function aLb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[gKb(a.a[0],b),gKb(a.a[1],b),gKb(a.a[2],b)]);if(a.d){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function bLb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[hKb(a.a[0],b),hKb(a.a[1],b),hKb(a.a[2],b)]);if(a.d){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function vIc(a,b,c){if(!Cod(RD(mQb(b,(yCc(),BBc)),101))){uIc(a,b,e3b(b,c));uIc(a,b,e3b(b,(qpd(),npd)));uIc(a,b,e3b(b,Yod));yob();_mb(b.j,new JIc(a));}} + function sUc(a){var b,c;a.c||vUc(a);c=new Ejd;b=new Anb(a.a);ynb(b);while(b.a0&&(BFb(0,b.length),b.charCodeAt(0)==43)?(BFb(1,b.length+1),b.substr(1)):b))} + function qne(a){var b;return a==null?null:new ejb((b=nue(a,true),b.length>0&&(BFb(0,b.length),b.charCodeAt(0)==43)?(BFb(1,b.length+1),b.substr(1)):b))} + function Syb(a,b,c,d,e,f,g,h){var i,j;if(!d){return}i=d.a[0];!!i&&Syb(a,b,c,i,e,f,g,h);Tyb(a,c,d.d,e,f,g,h)&&b.Fc(d);j=d.a[1];!!j&&Syb(a,b,c,j,e,f,g,h);} + function PPb(b,c,d){try{return Gdb(SPb(b,c,d),1)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function QPb(b,c,d){try{return Gdb(SPb(b,c,d),0)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function RPb(b,c,d){try{return Gdb(SPb(b,c,d),2)}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function lMd(b,c){if(b.g==-1){throw Adb(new cgb)}b.Xj();try{b.d.hd(b.g,c);b.f=b.d.j;}catch(a){a=zdb(a);if(ZD(a,77)){throw Adb(new Jrb)}else throw Adb(a)}} + function Y7b(a){var b,c,d,e,f;for(d=new Anb(a.b);d.af&&bD(b,f,null);return b} + function av(a,b){var c,d;d=a.gc();if(b==null){for(c=0;c0&&(i+=e);j[k]=g;g+=h*(i+d);}} + function vsc(a){var b,c,d;d=a.f;a.n=$C(iE,vxe,28,d,15,1);a.d=$C(iE,vxe,28,d,15,1);for(b=0;b0?a.c:0);++e;}a.b=d;a.d=f;} + function rKb(a,b){var c;c=cD(WC(iE,1),vxe,28,15,[qKb(a,(ZJb(),WJb),b),qKb(a,XJb,b),qKb(a,YJb,b)]);if(a.f){c[0]=$wnd.Math.max(c[0],c[2]);c[2]=c[0];}return c} + function cQb(b,c,d){var e;try{TPb(b,c+b.j,d+b.k,false,true);}catch(a){a=zdb(a);if(ZD(a,77)){e=a;throw Adb(new veb(e.g+ize+c+pve+d+').'))}else throw Adb(a)}} + function dQb(b,c,d){var e;try{TPb(b,c+b.j,d+b.k,true,false);}catch(a){a=zdb(a);if(ZD(a,77)){e=a;throw Adb(new veb(e.g+ize+c+pve+d+').'))}else throw Adb(a)}} + function u8b(a){var b;if(!nQb(a,(yCc(),dBc))){return}b=RD(mQb(a,dBc),21);if(b.Hc((dod(),Xnd))){b.Mc(Xnd);b.Fc(Znd);}else if(b.Hc(Znd)){b.Mc(Znd);b.Fc(Xnd);}} + function v8b(a){var b;if(!nQb(a,(yCc(),dBc))){return}b=RD(mQb(a,dBc),21);if(b.Hc((dod(),cod))){b.Mc(cod);b.Fc(aod);}else if(b.Hc(aod)){b.Mc(aod);b.Fc(cod);}} + function oqc(a,b,c,d){var e,f,g,h;a.a==null&&rqc(a,b);g=b.b.j.c.length;f=c.d.p;h=d.d.p;e=h-1;e<0&&(e=g-1);return f<=e?a.a[e]-a.a[f]:a.a[g-1]-a.a[f]+a.a[e]} + function Cud(a){var b,c;if(!a.b){a.b=fv(RD(a.f,27).kh().i);for(c=new dMd(RD(a.f,27).kh());c.e!=c.i.gc();){b=RD(bMd(c),135);Rmb(a.b,new Bud(b));}}return a.b} + function Dud(a){var b,c;if(!a.e){a.e=fv(wCd(RD(a.f,27)).i);for(c=new dMd(wCd(RD(a.f,27)));c.e!=c.i.gc();){b=RD(bMd(c),123);Rmb(a.e,new Rud(b));}}return a.e} + function yud(a){var b,c;if(!a.a){a.a=fv(tCd(RD(a.f,27)).i);for(c=new dMd(tCd(RD(a.f,27)));c.e!=c.i.gc();){b=RD(bMd(c),27);Rmb(a.a,new Fud(a,b));}}return a.a} + function DXd(b){var c;if(!b.C&&(b.D!=null||b.B!=null)){c=EXd(b);if(c){b.hl(c);}else {try{b.hl(null);}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}}return b.C} + function xMb(a){switch(a.q.g){case 5:uMb(a,(qpd(),Yod));uMb(a,npd);break;case 4:vMb(a,(qpd(),Yod));vMb(a,npd);break;default:wMb(a,(qpd(),Yod));wMb(a,npd);}} + function GNb(a){switch(a.q.g){case 5:DNb(a,(qpd(),Xod));DNb(a,ppd);break;case 4:ENb(a,(qpd(),Xod));ENb(a,ppd);break;default:FNb(a,(qpd(),Xod));FNb(a,ppd);}} + function G$b(a,b){var c,d,e;e=new pjd;for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);w$b(c,e.a,0);e.a+=c.f.a+b;e.b=$wnd.Math.max(e.b,c.f.b);}e.b>0&&(e.b+=b);return e} + function I$b(a,b){var c,d,e;e=new pjd;for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);w$b(c,0,e.b);e.b+=c.f.b+b;e.a=$wnd.Math.max(e.a,c.f.a);}e.a>0&&(e.a+=b);return e} + function l2b(a){var b,c,d;d=lve;for(c=new Anb(a.a);c.a>16==6){return a.Cb.Th(a,5,t7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?a.ii():c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function kA(a){fA();var b=a.e;if(b&&b.stack){var c=b.stack;var d=b+'\n';c.substring(0,d.length)==d&&(c=c.substring(d.length));return c.split('\n')}return []} + function pgb(a){var b;b=(wgb(),vgb);return b[a>>>28]|b[a>>24&15]<<4|b[a>>20&15]<<8|b[a>>16&15]<<12|b[a>>12&15]<<16|b[a>>8&15]<<20|b[a>>4&15]<<24|b[a&15]<<28} + function mmb(a){var b,c,d;if(a.b!=a.c){return}d=a.a.length;c=mgb($wnd.Math.max(8,d))<<1;if(a.b!=0){b=WEb(a.a,c);lmb(a,b,d);a.a=b;a.b=0;}else {aFb(a.a,c);}a.c=d;} + function uNb(a,b){var c;c=a.b;return c.pf((umd(),Gld))?c.ag()==(qpd(),ppd)?-c.Mf().a-Kfb(UD(c.of(Gld))):b+Kfb(UD(c.of(Gld))):c.ag()==(qpd(),ppd)?-c.Mf().a:b} + function X2b(a){var b;if(a.b.c.length!=0&&!!RD(Vmb(a.b,0),72).a){return RD(Vmb(a.b,0),72).a}b=R0b(a);if(b!=null){return b}return ''+(!a.c?-1:Wmb(a.c.a,a,0))} + function M3b(a){var b;if(a.f.c.length!=0&&!!RD(Vmb(a.f,0),72).a){return RD(Vmb(a.f,0),72).a}b=R0b(a);if(b!=null){return b}return ''+(!a.i?-1:Wmb(a.i.j,a,0))} + function skc(a,b){var c,d;if(b<0||b>=a.gc()){return null}for(c=b;c0?a.c:0);e=$wnd.Math.max(e,b.d);++d;}a.e=f;a.b=e;} + function Qud(a){var b,c;if(!a.b){a.b=fv(RD(a.f,123).kh().i);for(c=new dMd(RD(a.f,123).kh());c.e!=c.i.gc();){b=RD(bMd(c),135);Rmb(a.b,new Bud(b));}}return a.b} + function aHd(a,b){var c,d,e;if(b.dc()){return jQd(),jQd(),iQd}else {c=new ZLd(a,b.gc());for(e=new dMd(a);e.e!=e.i.gc();){d=bMd(e);b.Hc(d)&&WGd(c,d);}return c}} + function Axd(a,b,c,d){if(b==0){return d?(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),a.o):(!a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),dOd(a.o))}return Dvd(a,b,c,d)} + function rBd(a){var b,c;if(a.rb){for(b=0,c=a.rb.i;b>22);e+=d>>22;if(e<0){return false}a.l=c&dxe;a.m=d&dxe;a.h=e&exe;return true} + function Tyb(a,b,c,d,e,f,g){var h,i;if(b.Te()&&(i=a.a.Ne(c,d),i<0||!e&&i==0)){return false}if(b.Ue()&&(h=a.a.Ne(c,f),h>0||!g&&h==0)){return false}return true} + function Agc(a,b){sgc();var c;c=a.j.g-b.j.g;if(c!=0){return 0}switch(a.j.g){case 2:return Cgc(b,rgc)-Cgc(a,rgc);case 4:return Cgc(a,qgc)-Cgc(b,qgc);}return 0} + function uuc(a){switch(a.g){case 0:return nuc;case 1:return ouc;case 2:return puc;case 3:return quc;case 4:return ruc;case 5:return suc;default:return null;}} + function cBd(a,b,c){var d,e;d=(e=new R5d,YVd(e,b),PAd(e,c),WGd((!a.c&&(a.c=new C5d(u7,a,12,10)),a.c),e),e);$Vd(d,0);bWd(d,1);aWd(d,true);_Vd(d,true);return d} + function THd(a,b){var c,d;if(b>=a.i)throw Adb(new yNd(b,a.i));++a.j;c=a.g[b];d=a.i-b-1;d>0&&hib(a.g,b+1,a.g,b,d);bD(a.g,--a.i,null);a.Qi(b,c);a.Ni();return c} + function sWd(a,b){var c,d;if(a.Db>>16==17){return a.Cb.Th(a,21,h7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?a.ii():c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function _Fb(a){var b,c,d,e;yob();_mb(a.c,a.a);for(e=new Anb(a.c);e.ac.a.c.length)){throw Adb(new agb('index must be >= 0 and <= layer node count'))}!!a.c&&Ymb(a.c.a,a);a.c=c;!!c&&Qmb(c.a,b,a);} + function Gac(a,b){var c,d,e;for(d=new is(Mr(W2b(a).a.Kc(),new ir));gs(d);){c=RD(hs(d),18);e=RD(b.Kb(c),10);return new cc(Qb(e.n.b+e.o.b/2))}return wb(),wb(),vb} + function RQc(a,b){this.c=new Tsb;this.a=a;this.b=b;this.d=RD(mQb(a,(Ywc(),Qwc)),312);dE(mQb(a,(yCc(),eBc)))===dE((Cuc(),Auc))?(this.e=new BRc):(this.e=new uRc);} + function ftd(a,b){var c,d;d=null;if(a.pf((umd(),amd))){c=RD(a.of(amd),96);c.pf(b)&&(d=c.of(b));}d==null&&!!a.Tf()&&(d=a.Tf().of(b));d==null&&(d=iGd(b));return d} + function ku(b,c){var d,e;d=b.fd(c);try{e=d.Pb();d.Qb();return e}catch(a){a=zdb(a);if(ZD(a,112)){throw Adb(new veb("Can't remove element "+c))}else throw Adb(a)}} + function GA(a,b){var c,d,e;d=new uB;e=new vB(d.q.getFullYear()-Owe,d.q.getMonth(),d.q.getDate());c=FA(a,b,e);if(c==0||c0?b:0);++c;}return new rjd(d,e)} + function Czd(a,b){var c,d;if(a.Db>>16==6){return a.Cb.Th(a,6,G4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),hvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function cCd(a,b){var c,d;if(a.Db>>16==7){return a.Cb.Th(a,1,H4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),jvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function LCd(a,b){var c,d;if(a.Db>>16==9){return a.Cb.Th(a,9,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),lvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function M1d(a,b){var c,d;if(a.Db>>16==5){return a.Cb.Th(a,9,m7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),tTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function qBd(a,b){var c,d;if(a.Db>>16==7){return a.Cb.Th(a,6,t7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),CTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function iVd(a,b){var c,d;if(a.Db>>16==3){return a.Cb.Th(a,0,p7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),mTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function IEd(){this.a=new BDd;this.g=new Io;this.j=new Io;this.b=new Tsb;this.d=new Io;this.i=new Io;this.k=new Tsb;this.c=new Tsb;this.e=new Tsb;this.f=new Tsb;} + function kQd(a,b,c){var d,e,f;c<0&&(c=0);f=a.i;for(e=c;ewxe){return Oje(a,d)}if(d==a){return true}}}return false} + function yNb(a){tNb();switch(a.q.g){case 5:vNb(a,(qpd(),Yod));vNb(a,npd);break;case 4:wNb(a,(qpd(),Yod));wNb(a,npd);break;default:xNb(a,(qpd(),Yod));xNb(a,npd);}} + function CNb(a){tNb();switch(a.q.g){case 5:zNb(a,(qpd(),Xod));zNb(a,ppd);break;case 4:ANb(a,(qpd(),Xod));ANb(a,ppd);break;default:BNb(a,(qpd(),Xod));BNb(a,ppd);}} + function RTb(a){var b,c;b=RD(mQb(a,(yVb(),mVb)),17);if(b){c=b.a;c==0?pQb(a,(JVb(),IVb),new Owb):pQb(a,(JVb(),IVb),new Pwb(c));}else {pQb(a,(JVb(),IVb),new Pwb(1));}} + function b2b(a,b){var c;c=a.i;switch(b.g){case 1:return -(a.n.b+a.o.b);case 2:return a.n.a-c.o.a;case 3:return a.n.b-c.o.b;case 4:return -(a.n.a+a.o.a);}return 0} + function wec(a,b){switch(a.g){case 0:return b==(cxc(),$wc)?sec:tec;case 1:return b==(cxc(),$wc)?sec:rec;case 2:return b==(cxc(),$wc)?rec:tec;default:return rec;}} + function Fad(a,b){var c,d,e;Ymb(a.a,b);a.e-=b.r+(a.a.c.length==0?0:a.c);e=fFe;for(d=new Anb(a.a);d.a>16==3){return a.Cb.Th(a,12,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),gvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function sCd(a,b){var c,d;if(a.Db>>16==11){return a.Cb.Th(a,10,J4,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(pvd(),kvd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function n4d(a,b){var c,d;if(a.Db>>16==10){return a.Cb.Th(a,11,h7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),ATd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function Q5d(a,b){var c,d;if(a.Db>>16==10){return a.Cb.Th(a,12,s7,b)}return d=Z5d(RD(vYd((c=RD(Ywd(a,16),29),!c?(JTd(),DTd):c),a.Db>>16),19)),a.Cb.Th(a,d.n,d.f,b)} + function WVd(a){var b;if((a.Bb&1)==0&&!!a.r&&a.r.Vh()){b=RD(a.r,54);a.r=RD(Vvd(a,b),142);a.r!=b&&(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,9,8,b,a.r));}return a.r} + function pKb(a,b,c){var d;d=cD(WC(iE,1),vxe,28,15,[sKb(a,(ZJb(),WJb),b,c),sKb(a,XJb,b,c),sKb(a,YJb,b,c)]);if(a.f){d[0]=$wnd.Math.max(d[0],d[2]);d[2]=d[0];}return d} + function ddc(a,b){var c,d,e;e=kdc(a,b);if(e.c.length==0){return}_mb(e,new Gdc);c=e.c.length;for(d=0;d>19;j=b.h>>19;if(i!=j){return j-i}e=a.h;h=b.h;if(e!=h){return e-h}d=a.m;g=b.m;if(d!=g){return d-g}c=a.l;f=b.l;return c-f} + function YHb(){YHb=geb;XHb=(iIb(),fIb);WHb=new lGd(Aye,XHb);VHb=(LHb(),KHb);UHb=new lGd(Bye,VHb);THb=(DHb(),CHb);SHb=new lGd(Cye,THb);RHb=new lGd(Dye,(Geb(),true));} + function Iic(a,b,c){var d,e;d=b*c;if(ZD(a.g,154)){e=$jc(a);if(e.f.d){e.f.a||(a.d.a+=d+Tye);}else {a.d.d-=d+Tye;a.d.a+=d+Tye;}}else if(ZD(a.g,10)){a.d.d-=d;a.d.a+=2*d;}} + function _pc(a,b,c){var d,e,f,g,h;e=a[c.g];for(h=new Anb(b.d);h.a0?a.b:0);++c;}b.b=d;b.e=e;} + function Fo(a){var b,c,d;d=a.b;if(Xp(a.i,d.length)){c=d.length*2;a.b=$C(XF,ewe,303,c,0,1);a.c=$C(XF,ewe,303,c,0,1);a.f=c-1;a.i=0;for(b=a.a;b;b=b.c){Bo(a,b,b);}++a.g;}} + function VPb(a,b,c,d){var e,f,g,h;for(e=0;eg&&(h=g/d);e>f&&(i=f/e);ijd(a,$wnd.Math.min(h,i));return a} + function OAd(){qAd();var b,c;try{c=RD(M5d((YSd(),XSd),$He),2113);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new KAd} + function Qae(){qAd();var b,c;try{c=RD(M5d((YSd(),XSd),AKe),2040);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new Mae} + function vne(){Zme();var b,c;try{c=RD(M5d((YSd(),XSd),dLe),2122);if(c){return c}}catch(a){a=zdb(a);if(ZD(a,103)){b=a;UId((Hde(),b));}else throw Adb(a)}return new rne} + function f2d(a,b,c){var d,e;e=a.e;a.e=b;if((a.Db&4)!=0&&(a.Db&1)==0){d=new N3d(a,1,4,e,b);!c?(c=d):c.nj(d);}e!=b&&(b?(c=o2d(a,k2d(a,b),c)):(c=o2d(a,a.a,c)));return c} + function DB(){uB.call(this);this.e=-1;this.a=false;this.p=qwe;this.k=-1;this.c=-1;this.b=-1;this.g=false;this.f=-1;this.j=-1;this.n=-1;this.i=-1;this.d=-1;this.o=qwe;} + function hHb(a,b){var c,d,e;d=a.b.d.d;a.a||(d+=a.b.d.a);e=b.b.d.d;b.a||(e+=b.b.d.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function XQb(a,b){var c,d,e;d=a.b.b.d;a.a||(d+=a.b.b.a);e=b.b.b.d;b.a||(e+=b.b.b.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function RYb(a,b){var c,d,e;d=a.b.g.d;a.a||(d+=a.b.g.a);e=b.b.g.d;b.a||(e+=b.b.g.a);c=Qfb(d,e);if(c==0){if(!a.a&&b.a){return -1}else if(!b.a&&a.a){return 1}}return c} + function _Wb(){_Wb=geb;YWb=nfd(pfd(pfd(pfd(new ufd,(sXb(),qXb),(hcc(),Dbc)),qXb,Hbc),rXb,Obc),rXb,rbc);$Wb=pfd(pfd(new ufd,qXb,hbc),qXb,sbc);ZWb=nfd(new ufd,rXb,ubc);} + function J6b(a){var b,c,d,e,f;b=RD(mQb(a,(Ywc(),cwc)),85);f=a.n;for(d=b.Cc().Kc();d.Ob();){c=RD(d.Pb(),314);e=c.i;e.c+=f.a;e.d+=f.b;c.c?MKb(c):OKb(c);}pQb(a,cwc,null);} + function Wpc(a,b,c){var d,e;e=a.b;d=e.d;switch(b.g){case 1:return -d.d-c;case 2:return e.o.a+d.c+c;case 3:return e.o.b+d.a+c;case 4:return -d.b-c;default:return -1;}} + function CNc(a,b,c){var d,e;c.Ug('Interactive node placement',1);a.a=RD(mQb(b,(Ywc(),Qwc)),312);for(e=new Anb(b.b);e.a0){g=(f&lve)%a.d.length;e=WNd(a,g,f,b);if(e){h=e.nd(c);return h}}d=a.ck(f,b,c);a.c.Fc(d);return null} + function Tee(a,b){var c,d,e,f;switch(Oee(a,b).Kl()){case 3:case 2:{c=mYd(b);for(e=0,f=c.i;e=0;d--){if(lhb(a[d].d,b)||lhb(a[d].d,c)){a.length>=d+1&&a.splice(0,d+1);break}}return a} + function Fdb(a,b){var c;if(Kdb(a)&&Kdb(b)){c=a/b;if(jxe0){a.b+=2;a.a+=d;}}else {a.b+=1;a.a+=$wnd.Math.min(d,e);}} + function CVc(a){var b;b=RD(mQb(RD(ju(a.b,0),40),(h_c(),T$c)),107);pQb(a,(q$c(),SZc),new rjd(0,0));FVc(new YWc,a,b.b+b.c-Kfb(UD(mQb(a,ZZc))),b.d+b.a-Kfb(UD(mQb(a,_Zc))));} + function pDd(a,b){var c,d;d=false;if(bE(b)){d=true;oDd(a,new OC(WD(b)));}if(!d){if(ZD(b,242)){d=true;oDd(a,(c=Qeb(RD(b,242)),new hC(c)));}}if(!d){throw Adb(new Aeb(tIe))}} + function g$d(a,b,c,d){var e,f,g;e=new P3d(a.e,1,10,(g=b.c,ZD(g,90)?RD(g,29):(JTd(),zTd)),(f=c.c,ZD(f,90)?RD(f,29):(JTd(),zTd)),fZd(a,b),false);!d?(d=e):d.nj(e);return d} + function _2b(a){var b,c;switch(RD(mQb(Y2b(a),(yCc(),QAc)),429).g){case 0:b=a.n;c=a.o;return new rjd(b.a+c.a/2,b.b+c.b/2);case 1:return new sjd(a.n);default:return null;}} + function Ouc(){Ouc=geb;Luc=new Puc(LAe,0);Kuc=new Puc('LEFTUP',1);Nuc=new Puc('RIGHTUP',2);Juc=new Puc('LEFTDOWN',3);Muc=new Puc('RIGHTDOWN',4);Iuc=new Puc('BALANCED',5);} + function dKc(a,b,c){var d,e,f;d=Qfb(a.a[b.p],a.a[c.p]);if(d==0){e=RD(mQb(b,(Ywc(),qwc)),15);f=RD(mQb(c,qwc),15);if(e.Hc(c)){return -1}else if(f.Hc(b)){return 1}}return d} + function k5c(a){switch(a.g){case 1:return new K3c;case 2:return new M3c;case 3:return new I3c;case 0:return null;default:throw Adb(new agb(mFe+(a.f!=null?a.f:''+a.g)));}} + function gyd(a,b,c){switch(b){case 1:!a.n&&(a.n=new C5d(I4,a,1,7));sLd(a.n);!a.n&&(a.n=new C5d(I4,a,1,7));YGd(a.n,RD(c,16));return;case 2:jyd(a,WD(c));return;}Dxd(a,b,c);} + function xyd(a,b,c){switch(b){case 3:Ayd(a,Kfb(UD(c)));return;case 4:Cyd(a,Kfb(UD(c)));return;case 5:Dyd(a,Kfb(UD(c)));return;case 6:Eyd(a,Kfb(UD(c)));return;}gyd(a,b,c);} + function dBd(a,b,c){var d,e,f;f=(d=new R5d,d);e=XVd(f,b,null);!!e&&e.oj();PAd(f,c);WGd((!a.c&&(a.c=new C5d(u7,a,12,10)),a.c),f);$Vd(f,0);bWd(f,1);aWd(f,true);_Vd(f,true);} + function M5d(a,b){var c,d,e;c=Ktb(a.i,b);if(ZD(c,241)){e=RD(c,241);e.zi()==null&&undefined;return e.wi()}else if(ZD(c,507)){d=RD(c,2037);e=d.b;return e}else {return null}} + function aj(a,b,c,d){var e,f;Qb(b);Qb(c);f=RD(Fn(a.d,b),17);Ob(!!f,'Row %s not in %s',b,a.e);e=RD(Fn(a.b,c),17);Ob(!!e,'Column %s not in %s',c,a.c);return cj(a,f.a,e.a,d)} + function ZC(a,b,c,d,e,f,g){var h,i,j,k,l;k=e[f];j=f==g-1;h=j?d:0;l=_C(h,k);d!=10&&cD(WC(a,g-f),b[f],c[f],h,l);if(!j){++f;for(i=0;i1||h==-1){f=RD(i,15);e.Wb(Sje(a,f));}else {e.Wb(Rje(a,RD(i,58)));}}}} + function ceb(b,c,d,e){beb();var f=_db;function g(){for(var a=0;a0){return false}}return true} + function okc(a){var b,c,d,e,f;for(d=new vkb((new mkb(a.b)).a);d.b;){c=tkb(d);b=RD(c.ld(),10);f=RD(RD(c.md(),42).a,10);e=RD(RD(c.md(),42).b,8);$id(hjd(b.n),$id(ajd(f.n),e));}} + function Roc(a){switch(RD(mQb(a.b,(yCc(),BAc)),387).g){case 1:FDb(GDb(EDb(new SDb(null,new Swb(a.d,16)),new kpc),new mpc),new opc);break;case 2:Toc(a);break;case 0:Soc(a);}} + function SVc(a,b,c){var d,e,f;d=c;!d&&(d=new Oqd);d.Ug('Layout',a.a.c.length);for(f=new Anb(a.a);f.aAEe){return c}else e>-1.0E-6&&++c;}return c} + function n2d(a,b){var c;if(b!=a.b){c=null;!!a.b&&(c=Jvd(a.b,a,-4,c));!!b&&(c=Ivd(b,a,-4,c));c=e2d(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function q2d(a,b){var c;if(b!=a.f){c=null;!!a.f&&(c=Jvd(a.f,a,-1,c));!!b&&(c=Ivd(b,a,-1,c));c=g2d(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,0,b,b));} + function Lge(a,b,c,d){var e,f,g,h;if(Mvd(a.e)){e=b.Lk();h=b.md();f=c.md();g=fge(a,1,e,h,f,e.Jk()?kge(a,e,f,ZD(e,102)&&(RD(e,19).Bb&txe)!=0):-1,true);d?d.nj(g):(d=g);}return d} + function bne(a){var b,c,d;if(a==null)return null;c=RD(a,15);if(c.dc())return '';d=new Qhb;for(b=c.Kc();b.Ob();){Nhb(d,(nme(),WD(b.Pb())));d.a+=' ';}return qeb(d,d.a.length-1)} + function fne(a){var b,c,d;if(a==null)return null;c=RD(a,15);if(c.dc())return '';d=new Qhb;for(b=c.Kc();b.Ob();){Nhb(d,(nme(),WD(b.Pb())));d.a+=' ';}return qeb(d,d.a.length-1)} + function QIc(a,b,c){var d,e;d=a.c[b.c.p][b.p];e=a.c[c.c.p][c.p];if(d.a!=null&&e.a!=null){return Jfb(d.a,e.a)}else if(d.a!=null){return -1}else if(e.a!=null){return 1}return 0} + function RVc(a,b,c){c.Ug('Tree layout',1);Sed(a.b);Ved(a.b,(YVc(),UVc),UVc);Ved(a.b,VVc,VVc);Ved(a.b,WVc,WVc);Ved(a.b,XVc,XVc);a.a=Qed(a.b,b);SVc(a,b,c.eh(1));c.Vg();return b} + function ZDd(a,b){var c,d,e,f,g,h;if(b){f=b.a.length;c=new vue(f);for(h=(c.b-c.a)*c.c<0?(uue(),tue):new Rue(c);h.Ob();){g=RD(h.Pb(),17);e=xDd(b,g.a);d=new aFd(a);$Dd(d.a,e);}}} + function oEd(a,b){var c,d,e,f,g,h;if(b){f=b.a.length;c=new vue(f);for(h=(c.b-c.a)*c.c<0?(uue(),tue):new Rue(c);h.Ob();){g=RD(h.Pb(),17);e=xDd(b,g.a);d=new LEd(a);NDd(d.a,e);}}} + function ESd(b){var c;if(b!=null&&b.length>0&&ihb(b,b.length-1)==33){try{c=nSd(zhb(b,0,b.length-1));return c.e==null}catch(a){a=zdb(a);if(!ZD(a,33))throw Adb(a)}}return false} + function u0b(a,b,c){var d,e,f;d=Y2b(b);e=i2b(d);f=new R3b;P3b(f,b);switch(c.g){case 1:Q3b(f,spd(vpd(e)));break;case 2:Q3b(f,vpd(e));}pQb(f,(yCc(),ABc),UD(mQb(a,ABc)));return f} + function jdc(a){var b,c;b=RD(hs(new is(Mr(Z2b(a.a).a.Kc(),new ir))),18);c=RD(hs(new is(Mr(a3b(a.a).a.Kc(),new ir))),18);return Heb(TD(mQb(b,(Ywc(),Nwc))))||Heb(TD(mQb(c,Nwc)))} + function Bnc(){Bnc=geb;xnc=new Cnc('ONE_SIDE',0);znc=new Cnc('TWO_SIDES_CORNER',1);Anc=new Cnc('TWO_SIDES_OPPOSING',2);ync=new Cnc('THREE_SIDES',3);wnc=new Cnc('FOUR_SIDES',4);} + function Usc(a,b){var c,d,e,f;f=new bnb;e=0;d=b.Kc();while(d.Ob()){c=sgb(RD(d.Pb(),17).a+e);while(c.a=a.f){break}ZEb(f.c,c);}return f} + function iIc(a,b){var c,d,e,f,g;for(f=new Anb(b.a);f.a0&&Xlc(this,this.c-1,(qpd(),Xod));this.c0&&a[0].length>0&&(this.c=Heb(TD(mQb(Y2b(a[0][0]),(Ywc(),rwc)))));this.a=$C(aY,Nve,2117,a.length,0,2);this.b=$C(dY,Nve,2118,a.length,0,2);this.d=new Ks;} + function TOc(a){if(a.c.length==0){return false}if((tFb(0,a.c.length),RD(a.c[0],18)).c.i.k==(r3b(),o3b)){return true}return yDb(GDb(new SDb(null,new Swb(a,16)),new WOc),new YOc)} + function I5c(a,b){var c,d,e,f,g,h,i;h=Q2c(b);f=b.f;i=b.g;g=$wnd.Math.sqrt(f*f+i*i);e=0;for(d=new Anb(h);d.a=0){c=Fdb(a,ixe);d=Mdb(a,ixe);}else {b=Udb(a,1);c=Fdb(b,500000000);d=Mdb(b,500000000);d=Bdb(Sdb(d,1),Cdb(a,1));}return Rdb(Sdb(d,32),Cdb(c,yxe))} + function fTb(a,b,c){var d,e;d=(sFb(b.b!=0),RD(Wub(b,b.a.a),8));switch(c.g){case 0:d.b=0;break;case 2:d.b=a.f;break;case 3:d.a=0;break;default:d.a=a.g;}e=Sub(b,0);cvb(e,d);return b} + function Vpc(a,b,c,d){var e,f,g,h,i;i=a.b;f=b.d;g=f.j;h=$pc(g,i.d[g.g],c);e=$id(ajd(f.n),f.a);switch(f.j.g){case 1:case 3:h.a+=e.a;break;case 2:case 4:h.b+=e.b;}Pub(d,h,d.c.b,d.c);} + function YNc(a,b,c){var d,e,f,g;g=Wmb(a.e,b,0);f=new ZNc;f.b=c;d=new Jkb(a.e,g);while(d.b1;b>>=1){(b&1)!=0&&(d=Wib(d,c));c.d==1?(c=Wib(c,c)):(c=new djb(Tjb(c.a,c.d,$C(kE,Pwe,28,c.d<<1,15,1))));}d=Wib(d,c);return d} + function Hwb(){Hwb=geb;var a,b,c,d;Ewb=$C(iE,vxe,28,25,15,1);Fwb=$C(iE,vxe,28,33,15,1);d=1.52587890625E-5;for(b=32;b>=0;b--){Fwb[b]=d;d*=0.5;}c=1;for(a=24;a>=0;a--){Ewb[a]=c;c*=0.5;}} + function a5b(a){var b,c;if(Heb(TD(Gxd(a,(yCc(),NAc))))){for(c=new is(Mr(zGd(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),74);if(ozd(b)){if(Heb(TD(Gxd(b,OAc)))){return true}}}}return false} + function Qmc(a,b){var c,d,e;if(Ysb(a.f,b)){b.b=a;d=b.c;Wmb(a.j,d,0)!=-1||Rmb(a.j,d);e=b.d;Wmb(a.j,e,0)!=-1||Rmb(a.j,e);c=b.a.b;if(c.c.length!=0){!a.i&&(a.i=new _mc(a));Wmc(a.i,c);}}} + function Xpc(a){var b,c,d,e,f;c=a.c.d;d=c.j;e=a.d.d;f=e.j;if(d==f){return c.p=0&&lhb(a.substr(b,'GMT'.length),'GMT')){c[0]=b+3;return JA(a,c,d)}if(b>=0&&lhb(a.substr(b,'UTC'.length),'UTC')){c[0]=b+3;return JA(a,c,d)}return JA(a,c,d)} + function Zmc(a,b){var c,d,e,f,g;f=a.g.a;g=a.g.b;for(d=new Anb(a.d);d.ac;f--){a[f]|=b[f-c-1]>>>g;a[f-1]=b[f-c-1]<0&&hib(a.g,b,a.g,b+d,h);g=c.Kc();a.i+=d;for(e=0;e>4&15;f=a[d]&15;g[e++]=oAd[c];g[e++]=oAd[f];}return Ihb(g,0,g.length)}} + function Fhb(a){var b,c;if(a>=txe){b=uxe+(a-txe>>10&1023)&Bwe;c=56320+(a-txe&1023)&Bwe;return String.fromCharCode(b)+(''+String.fromCharCode(c))}else {return String.fromCharCode(a&Bwe)}} + function UMb(a,b){RMb();var c,d,e,f;e=RD(RD(Qc(a.r,b),21),87);if(e.gc()>=2){d=RD(e.Kc().Pb(),117);c=a.u.Hc((Pod(),Kod));f=a.u.Hc(Ood);return !d.a&&!c&&(e.gc()==2||f)}else {return false}} + function v3c(a,b,c,d,e){var f,g,h;f=w3c(a,b,c,d,e);h=false;while(!f){n3c(a,e,true);h=true;f=w3c(a,b,c,d,e);}h&&n3c(a,e,false);g=N2c(e);if(g.c.length!=0){!!a.d&&a.d.Gg(g);v3c(a,e,c,d,g);}} + function ind(){ind=geb;gnd=new jnd(LAe,0);end=new jnd('DIRECTED',1);hnd=new jnd('UNDIRECTED',2);cnd=new jnd('ASSOCIATION',3);fnd=new jnd('GENERALIZATION',4);dnd=new jnd('DEPENDENCY',5);} + function nsd(a,b){var c;if(!MCd(a)){throw Adb(new dgb(sHe))}c=MCd(a);switch(b.g){case 1:return -(a.j+a.f);case 2:return a.i-c.g;case 3:return a.j-c.f;case 4:return -(a.i+a.g);}return 0} + function Jge(a,b,c){var d,e,f;d=b.Lk();f=b.md();e=d.Jk()?fge(a,4,d,f,null,kge(a,d,f,ZD(d,102)&&(RD(d,19).Bb&txe)!=0),true):fge(a,d.tk()?2:1,d,f,d.ik(),-1,true);c?c.nj(e):(c=e);return c} + function lwb(a,b){var c,d;uFb(b);d=a.b.c.length;Rmb(a.b,b);while(d>0){c=d;d=(d-1)/2|0;if(a.a.Ne(Vmb(a.b,d),b)<=0){$mb(a.b,c,b);return true}$mb(a.b,c,Vmb(a.b,d));}$mb(a.b,d,b);return true} + function sKb(a,b,c,d){var e,f;e=0;if(!c){for(f=0;f=h} + function A8c(a){switch(a.g){case 0:return new o8c;case 1:return new u8c;default:throw Adb(new agb('No implementation is available for the width approximator '+(a.f!=null?a.f:''+a.g)));}} + function rDd(a,b,c,d){var e;e=false;if(bE(d)){e=true;sDd(b,c,WD(d));}if(!e){if($D(d)){e=true;rDd(a,b,c,d);}}if(!e){if(ZD(d,242)){e=true;qDd(b,c,RD(d,242));}}if(!e){throw Adb(new Aeb(tIe))}} + function uee(a,b){var c,d,e;c=b.qi(a.a);if(c){e=$Nd((!c.b&&(c.b=new SVd((JTd(),FTd),C8,c)),c.b),rKe);if(e!=null){for(d=1;d<(lke(),hke).length;++d){if(lhb(hke[d],e)){return d}}}}return 0} + function vee(a,b){var c,d,e;c=b.qi(a.a);if(c){e=$Nd((!c.b&&(c.b=new SVd((JTd(),FTd),C8,c)),c.b),rKe);if(e!=null){for(d=1;d<(lke(),ike).length;++d){if(lhb(ike[d],e)){return d}}}}return 0} + function Ve(a,b){var c,d,e,f;uFb(b);f=a.a.gc();if(f0?1:0;while(f.a[e]!=c){f=f.a[e];e=a.a.Ne(c.d,f.d)>0?1:0;}f.a[e]=d;d.b=c.b;d.a[0]=c.a[0];d.a[1]=c.a[1];c.a[0]=null;c.a[1]=null;} + function zIb(a){var b,c,d,e;b=new bnb;c=$C(xdb,Hye,28,a.a.c.length,16,1);Snb(c,c.length);for(e=new Anb(a.a);e.a0&&O9b((tFb(0,c.c.length),RD(c.c[0],30)),a);c.c.length>1&&O9b(RD(Vmb(c,c.c.length-1),30),a);b.Vg();} + function Sod(a){Pod();var b,c;b=ysb(Lod,cD(WC(D3,1),jwe,279,0,[Nod]));if(dy(Tx(b,a))>1){return false}c=ysb(Kod,cD(WC(D3,1),jwe,279,0,[Jod,Ood]));if(dy(Tx(c,a))>1){return false}return true} + function FBd(a,b){var c;c=Xjb((YSd(),XSd),a);ZD(c,507)?$jb(XSd,a,new B5d(this,b)):$jb(XSd,a,this);BBd(this,b);if(b==(jTd(),iTd)){this.wb=RD(this,2038);RD(b,2040);}else {this.wb=(lTd(),kTd);}} + function Lae(b){var c,d,e;if(b==null){return null}c=null;for(d=0;d=Awe?'error':d>=900?'warn':d>=800?'info':'log');eFb(c,a.a);!!a.b&&fFb(b,c,a.b,'Exception: ',true);} + function mQb(a,b){var c,d;d=(!a.q&&(a.q=new Tsb),Wjb(a.q,b));if(d!=null){return d}c=b.Sg();ZD(c,4)&&(c==null?(!a.q&&(a.q=new Tsb),_jb(a.q,b)):(!a.q&&(a.q=new Tsb),Zjb(a.q,b,c)),a);return c} + function sXb(){sXb=geb;nXb=new tXb('P1_CYCLE_BREAKING',0);oXb=new tXb('P2_LAYERING',1);pXb=new tXb('P3_NODE_ORDERING',2);qXb=new tXb('P4_NODE_PLACEMENT',3);rXb=new tXb('P5_EDGE_ROUTING',4);} + function KZb(a,b){CZb();var c;if(a.c==b.c){if(a.b==b.b||rZb(a.b,b.b)){c=oZb(a.b)?1:-1;if(a.a&&!b.a){return c}else if(!a.a&&b.a){return -c}}return hgb(a.b.g,b.b.g)}else {return Qfb(a.c,b.c)}} + function E3c(a,b){var c,d,e;if(p3c(a,b)){return true}for(d=new Anb(b);d.a=e||b<0)throw Adb(new veb(MIe+b+NIe+e));if(c>=e||c<0)throw Adb(new veb(OIe+c+NIe+e));b!=c?(d=(f=a.Cj(c),a.qj(b,f),f)):(d=a.xj(c));return d} + function Lje(a){var b,c,d;d=a;if(a){b=0;for(c=a.Eh();c;c=c.Eh()){if(++b>wxe){return Lje(c)}d=c;if(c==a){throw Adb(new dgb('There is a cycle in the containment hierarchy of '+a))}}}return d} + function Fe(a){var b,c,d;d=new Jyb(pve,'[',']');for(c=a.Kc();c.Ob();){b=c.Pb();Gyb(d,dE(b)===dE(a)?'(this Collection)':b==null?vve:jeb(b));}return !d.a?d.c:d.e.length==0?d.a.a:d.a.a+(''+d.e)} + function p3c(a,b){var c,d;d=false;if(b.gc()<2){return false}for(c=0;c1&&(a.j.b+=a.e);}else {a.j.a+=c.a;a.j.b=$wnd.Math.max(a.j.b,c.b);a.d.c.length>1&&(a.j.a+=a.e);}} + function Mnc(){Mnc=geb;Jnc=cD(WC(E3,1),NAe,64,0,[(qpd(),Yod),Xod,npd]);Inc=cD(WC(E3,1),NAe,64,0,[Xod,npd,ppd]);Knc=cD(WC(E3,1),NAe,64,0,[npd,ppd,Yod]);Lnc=cD(WC(E3,1),NAe,64,0,[ppd,Yod,Xod]);} + function Upc(a,b,c,d){var e,f,g,h,i,j,k;g=a.c.d;h=a.d.d;if(g.j==h.j){return}k=a.b;e=g.j;i=null;while(e!=h.j){i=b==0?tpd(e):rpd(e);f=$pc(e,k.d[e.g],c);j=$pc(i,k.d[i.g],c);Mub(d,$id(f,j));e=i;}} + function OJc(a,b,c,d){var e,f,g,h,i;g=hMc(a.a,b,c);h=RD(g.a,17).a;f=RD(g.b,17).a;if(d){i=RD(mQb(b,(Ywc(),Iwc)),10);e=RD(mQb(c,Iwc),10);if(!!i&&!!e){Slc(a.b,i,e);h+=a.b.i;f+=a.b.e;}}return h>f} + function OLc(a){var b,c,d,e,f,g,h,i,j;this.a=LLc(a);this.b=new bnb;for(c=a,d=0,e=c.length;damc(a.d).c){a.i+=a.g.c;cmc(a.d);}else if(amc(a.d).c>amc(a.g).c){a.e+=a.d.c;cmc(a.g);}else {a.i+=_lc(a.g);a.e+=_lc(a.d);cmc(a.g);cmc(a.d);}}} + function vTc(a,b,c){var d,e,f,g;f=b.q;g=b.r;new bTc((fTc(),dTc),b,f,1);new bTc(dTc,f,g,1);for(e=new Anb(c);e.ah&&(i=h/d);e>f&&(j=f/e);g=$wnd.Math.min(i,j);a.a+=g*(b.a-a.a);a.b+=g*(b.b-a.b);} + function I8c(a,b,c,d,e){var f,g;g=false;f=RD(Vmb(c.b,0),27);while(V8c(a,b,f,d,e)){g=true;T9c(c,f);if(c.b.c.length==0){break}f=RD(Vmb(c.b,0),27);}c.b.c.length==0&&Fad(c.j,c);g&&gad(b.q);return g} + function Eid(a,b){tid();var c,d,e,f;if(b.b<2){return false}f=Sub(b,0);c=RD(evb(f),8);d=c;while(f.b!=f.d.c){e=RD(evb(f),8);if(Did(a,d,e)){return true}d=e;}if(Did(a,d,c)){return true}return false} + function Bxd(a,b,c,d){var e,f;if(c==0){return !a.o&&(a.o=new DVd((pvd(),mvd),X4,a,0)),BVd(a.o,b,d)}return f=RD(vYd((e=RD(Ywd(a,16),29),!e?a.ii():e),c),69),f.wk().Ak(a,Wwd(a),c-AYd(a.ii()),b,d)} + function BBd(a,b){var c;if(b!=a.sb){c=null;!!a.sb&&(c=RD(a.sb,54).Th(a,1,n7,c));!!b&&(c=RD(b,54).Rh(a,1,n7,c));c=hBd(a,b,c);!!c&&c.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,4,b,b));} + function YDd(a,b){var c,d,e,f;if(b){e=vDd(b,'x');c=new ZEd(a);Hzd(c.a,(uFb(e),e));f=vDd(b,'y');d=new $Ed(a);Izd(d.a,(uFb(f),f));}else {throw Adb(new CDd('All edge sections need an end point.'))}} + function WDd(a,b){var c,d,e,f;if(b){e=vDd(b,'x');c=new WEd(a);Ozd(c.a,(uFb(e),e));f=vDd(b,'y');d=new XEd(a);Pzd(d.a,(uFb(f),f));}else {throw Adb(new CDd('All edge sections need a start point.'))}} + function hBb(a,b){var c,d,e,f,g,h,i;for(d=kBb(a),f=0,h=d.length;f>22-b;e=a.h<>22-b;}else if(b<44){c=0;d=a.l<>44-b;}else {c=0;d=0;e=a.l<a){throw Adb(new agb('k must be smaller than n'))}else return b==0||b==a?1:a==0?0:Bid(a)/(Bid(b)*Bid(a-b))} + function msd(a,b){var c,d,e,f;c=new zId(a);while(c.g==null&&!c.c?sId(c):c.g==null||c.i!=0&&RD(c.g[c.i-1],51).Ob()){f=RD(tId(c),58);if(ZD(f,167)){d=RD(f,167);for(e=0;e>4];b[c*2+1]=Fqe[f&15];}return Ihb(b,0,b.length)} + function sn(a){fn();var b,c,d;d=a.c.length;switch(d){case 0:return en;case 1:b=RD(Ir(new Anb(a)),44);return xn(b.ld(),b.md());default:c=RD(anb(a,$C(UK,Zve,44,a.c.length,0,1)),173);return new Mx(c);}} + function KWb(a){var b,c,d,e,f,g;b=new wmb;c=new wmb;hmb(b,a);hmb(c,a);while(c.b!=c.c){e=RD(smb(c),36);for(g=new Anb(e.a);g.a0&&uLc(a,c,b);return e}return rLc(a,b,c)} + function $4c(){$4c=geb;R4c=(umd(),Qld);Y4c=fmd;K4c=kld;L4c=nld;M4c=pld;J4c=ild;N4c=sld;Q4c=Lld;H4c=(D4c(),o4c);I4c=p4c;T4c=v4c;W4c=y4c;U4c=w4c;V4c=x4c;O4c=r4c;P4c=t4c;S4c=u4c;X4c=z4c;Z4c=B4c;G4c=n4c;} + function P9c(a,b){var c,d,e,f,g;if(a.e<=b){return a.g}if(R9c(a,a.g,b)){return a.g}f=a.r;d=a.g;g=a.r;e=(f-d)/2+d;while(d+11&&(a.e.b+=a.a);}else {a.e.a+=c.a;a.e.b=$wnd.Math.max(a.e.b,c.b);a.d.c.length>1&&(a.e.a+=a.a);}} + function Ipc(a){var b,c,d,e;e=a.i;b=e.b;d=e.j;c=e.g;switch(e.a.g){case 0:c.a=(a.g.b.o.a-d.a)/2;break;case 1:c.a=b.d.n.a+b.d.a.a;break;case 2:c.a=b.d.n.a+b.d.a.a-d.a;break;case 3:c.b=b.d.n.b+b.d.a.b;}} + function oOc(a,b,c){var d,e,f;for(e=new is(Mr(W2b(c).a.Kc(),new ir));gs(e);){d=RD(hs(e),18);if(!(!W0b(d)&&!(!W0b(d)&&d.c.i.c==d.d.i.c))){continue}f=gOc(a,d,c,new VOc);f.c.length>1&&(ZEb(b.c,f),true);}} + function _id(a,b,c,d,e){if(dd&&(a.a=d);a.be&&(a.b=e);return a} + function LFd(a){if(ZD(a,143)){return EFd(RD(a,143))}else if(ZD(a,233)){return FFd(RD(a,233))}else if(ZD(a,23)){return GFd(RD(a,23))}else {throw Adb(new agb(wIe+Fe(new mob(cD(WC(jJ,1),rve,1,5,[a])))))}} + function ujb(a,b,c,d,e){var f,g,h;f=true;for(g=0;g>>e|c[g+d+1]<>>e;++g;}return f} + function ZQc(a,b,c,d){var e,f,g;if(b.k==(r3b(),o3b)){for(f=new is(Mr(Z2b(b).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);g=e.c.i.k;if(g==o3b&&a.c.a[e.c.i.c.p]==d&&a.c.a[b.c.p]==c){return true}}}return false} + function CD(a,b){var c,d,e,f;b&=63;c=a.h&exe;if(b<22){f=c>>>b;e=a.m>>b|c<<22-b;d=a.l>>b|a.m<<22-b;}else if(b<44){f=0;e=c>>>b-22;d=a.m>>b-22|a.h<<44-b;}else {f=0;e=0;d=c>>>b-44;}return hD(d&dxe,e&dxe,f&exe)} + function mmc(a,b,c,d){var e;this.b=d;this.e=a==(RKc(),PKc);e=b[c];this.d=YC(xdb,[Nve,Hye],[183,28],16,[e.length,e.length],2);this.a=YC(kE,[Nve,Pwe],[53,28],15,[e.length,e.length],2);this.c=new Ylc(b,c);} + function Rmc(a){var b,c,d;a.k=new Si((qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,a.j.c.length);for(d=new Anb(a.j);d.a=c){_cc(a,b,d.p);return true}}return false} + function EA(a,b,c,d){var e,f,g,h,i,j;g=c.length;f=0;e=-1;j=Bhb((BFb(b,a.length+1),a.substr(b)),(wvb(),uvb));for(h=0;hf&&whb(j,Bhb(c[h],uvb))){e=h;f=i;}}e>=0&&(d[0]=b+f);return e} + function gCd(a){var b;if((a.Db&64)!=0)return Fyd(a);b=new dib(FHe);!a.a||Zhb(Zhb((b.a+=' "',b),a.a),'"');Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function xge(a,b,c){var d,e,f,g,h;h=pke(a.e.Dh(),b);e=RD(a.g,124);d=0;for(g=0;gc){return Jb(a,c,'start index')}if(b<0||b>c){return Jb(b,c,'end index')}return hc('end index (%s) must not be less than start index (%s)',cD(WC(jJ,1),rve,1,5,[sgb(b),sgb(a)]))} + function dA(b,c){var d,e,f,g;for(e=0,f=b.length;e0&&aGc(a,f,c));}}b.p=0;} + function Ahd(a){var b;this.c=new Yub;this.f=a.e;this.e=a.d;this.i=a.g;this.d=a.c;this.b=a.b;this.k=a.j;this.a=a.a;!a.i?(this.j=(b=RD(mfb(d3),9),new Fsb(b,RD(WEb(b,b.length),9),0))):(this.j=a.i);this.g=a.f;} + function Wb(a){var b,c,d,e;b=Thb(Zhb(new dib('Predicates.'),'and'),40);c=true;for(e=new Dkb(a);e.b0?h[g-1]:$C(jR,WAe,10,0,0,1);e=h[g];j=g=0?a.ki(e):Tvd(a,d);}else {throw Adb(new agb(KHe+d.xe()+LHe))}}else {Cvd(a,c,d);}} + function ADd(a){var b,c;c=null;b=false;if(ZD(a,211)){b=true;c=RD(a,211).a;}if(!b){if(ZD(a,263)){b=true;c=''+RD(a,263).a;}}if(!b){if(ZD(a,493)){b=true;c=''+RD(a,493).a;}}if(!b){throw Adb(new Aeb(tIe))}return c} + function gge(a,b,c){var d,e,f,g,h,i;i=pke(a.e.Dh(),b);d=0;h=a.i;e=RD(a.g,124);for(g=0;g=a.d.b.c.length){b=new R4b(a.d);b.p=d.p-1;Rmb(a.d.b,b);c=new R4b(a.d);c.p=d.p;Rmb(a.d.b,c);}g3b(d,RD(Vmb(a.d.b,d.p),30));}} + function DVc(a,b,c){var d,e,f;if(!a.b[b.g]){a.b[b.g]=true;d=c;!d&&(d=new YWc);Mub(d.b,b);for(f=a.a[b.g].Kc();f.Ob();){e=RD(f.Pb(),65);e.b!=b&&DVc(a,e.b,d);e.c!=b&&DVc(a,e.c,d);Mub(d.a,e);}return d}return null} + function iMb(a){switch(a.g){case 0:case 1:case 2:return qpd(),Yod;case 3:case 4:case 5:return qpd(),npd;case 6:case 7:case 8:return qpd(),ppd;case 9:case 10:case 11:return qpd(),Xod;default:return qpd(),opd;}} + function SOc(a,b){var c;if(a.c.length==0){return false}c=zDc((tFb(0,a.c.length),RD(a.c[0],18)).c.i);dOc();if(c==(wDc(),tDc)||c==sDc){return true}return yDb(GDb(new SDb(null,new Swb(a,16)),new $Oc),new aPc(b))} + function KDd(a,b){if(ZD(b,207)){return EDd(a,RD(b,27))}else if(ZD(b,193)){return FDd(a,RD(b,123))}else if(ZD(b,452)){return DDd(a,RD(b,166))}else {throw Adb(new agb(wIe+Fe(new mob(cD(WC(jJ,1),rve,1,5,[b])))))}} + function Ou(a,b,c){var d,e;this.f=a;d=RD(Wjb(a.b,b),260);e=!d?0:d.a;Sb(c,e);if(c>=(e/2|0)){this.e=!d?null:d.c;this.d=e;while(c++0){Lu(this);}}this.b=b;this.a=null;} + function iHb(a,b){var c,d;b.a?jHb(a,b):(c=RD(vAb(a.b,b.b),60),!!c&&c==a.a[b.b.f]&&!!c.a&&c.a!=b.b.a&&c.c.Fc(b.b),d=RD(uAb(a.b,b.b),60),!!d&&a.a[d.f]==b.b&&!!d.a&&d.a!=b.b.a&&b.b.c.Fc(d),wAb(a.b,b.b),undefined);} + function wMb(a,b){var c,d;c=RD(Vrb(a.b,b),127);if(RD(RD(Qc(a.r,b),21),87).dc()){c.n.b=0;c.n.c=0;return}c.n.b=a.C.b;c.n.c=a.C.c;a.A.Hc((Qpd(),Ppd))&&BMb(a,b);d=AMb(a,b);BLb(a,b)==(pod(),mod)&&(d+=2*a.w);c.a.a=d;} + function FNb(a,b){var c,d;c=RD(Vrb(a.b,b),127);if(RD(RD(Qc(a.r,b),21),87).dc()){c.n.d=0;c.n.a=0;return}c.n.d=a.C.d;c.n.a=a.C.a;a.A.Hc((Qpd(),Ppd))&&JNb(a,b);d=INb(a,b);BLb(a,b)==(pod(),mod)&&(d+=2*a.w);c.a.b=d;} + function VQb(a,b){var c,d,e,f;f=new bnb;for(d=new Anb(b);d.ad&&(BFb(b-1,a.length),a.charCodeAt(b-1)<=32)){--b;}return d>0||bc.a&&(d.Hc((ukd(),okd))?(e=(b.a-c.a)/2):d.Hc(qkd)&&(e=b.a-c.a));b.b>c.b&&(d.Hc((ukd(),skd))?(f=(b.b-c.b)/2):d.Hc(rkd)&&(f=b.b-c.b));Isd(a,e,f);} + function ABd(a,b,c,d,e,f,g,h,i,j,k,l,m){ZD(a.Cb,90)&&v$d(yYd(RD(a.Cb,90)),4);PAd(a,c);a.f=g;DWd(a,h);FWd(a,i);xWd(a,j);EWd(a,k);aWd(a,l);AWd(a,m);_Vd(a,true);$Vd(a,e);a.Zk(f);YVd(a,b);d!=null&&(a.i=null,zWd(a,d));} + function Jb(a,b,c){if(a<0){return hc(qve,cD(WC(jJ,1),rve,1,5,[c,sgb(a)]))}else if(b<0){throw Adb(new agb(sve+b))}else {return hc('%s (%s) must not be greater than size (%s)',cD(WC(jJ,1),rve,1,5,[c,sgb(a),sgb(b)]))}} + function Xnb(a,b,c,d,e,f){var g,h,i,j;g=d-c;if(g<7){Unb(b,c,d,f);return}i=c+e;h=d+e;j=i+(h-i>>1);Xnb(b,a,i,j,-e,f);Xnb(b,a,j,h,-e,f);if(f.Ne(a[j-1],a[j])<=0){while(c=0?a.bi(f,c):Svd(a,e,c);}else {throw Adb(new agb(KHe+e.xe()+LHe))}}else {Bvd(a,d,e,c);}} + function n3d(a){var b,c;if(a.f){while(a.n>0){b=RD(a.k.Xb(a.n-1),76);c=b.Lk();if(ZD(c,102)&&(RD(c,19).Bb&QHe)!=0&&(!a.e||c.pk()!=C4||c.Lj()!=0)&&b.md()!=null){return true}else {--a.n;}}return false}else {return a.n>0}} + function Pje(b){var c,d,e,f;d=RD(b,54)._h();if(d){try{e=null;c=N5d((YSd(),XSd),jSd(kSd(d)));if(c){f=c.ai();!!f&&(e=f.Fl(Chb(d.e)));}if(!!e&&e!=b){return Pje(e)}}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}return b} + function P3c(a,b,c){var d,e,f;c.Ug('Remove overlaps',1);c.dh(b,eFe);d=RD(Gxd(b,(u2c(),t2c)),27);a.f=d;a.a=u5c(RD(Gxd(b,($4c(),X4c)),300));e=UD(Gxd(b,(umd(),fmd)));s3c(a,(uFb(e),e));f=Q2c(d);O3c(a,b,f,c);c.dh(b,gFe);} + function Ded(a){var b,c,d;if(Heb(TD(Gxd(a,(umd(),$kd))))){d=new bnb;for(c=new is(Mr(zGd(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),74);ozd(b)&&Heb(TD(Gxd(b,_kd)))&&(ZEb(d.c,b),true);}return d}else {return yob(),yob(),vob}} + function KC(a){if(!a){return cC(),bC}var b=a.valueOf?a.valueOf():a;if(b!==a){var c=GC[typeof b];return c?c(b):NC(typeof b)}else if(a instanceof Array||a instanceof $wnd.Array){return new NB(a)}else {return new vC(a)}} + function IMb(a,b,c){var d,e,f;f=a.o;d=RD(Vrb(a.p,c),252);e=d.i;e.b=ZKb(d);e.a=YKb(d);e.b=$wnd.Math.max(e.b,f.a);e.b>f.a&&!b&&(e.b=f.a);e.c=-(e.b-f.a)/2;switch(c.g){case 1:e.d=-e.a;break;case 3:e.d=f.b;}$Kb(d);_Kb(d);} + function JMb(a,b,c){var d,e,f;f=a.o;d=RD(Vrb(a.p,c),252);e=d.i;e.b=ZKb(d);e.a=YKb(d);e.a=$wnd.Math.max(e.a,f.b);e.a>f.b&&!b&&(e.a=f.b);e.d=-(e.a-f.b)/2;switch(c.g){case 4:e.c=-e.b;break;case 2:e.c=f.a;}$Kb(d);_Kb(d);} + function nkc(a,b){var c,d,e,f,g;if(b.dc()){return}e=RD(b.Xb(0),131);if(b.gc()==1){mkc(a,e,e,1,0,b);return}c=1;while(c0){try{f=Oeb(c,qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){e=a;throw Adb(new RSd(e))}else throw Adb(a)}}d=(!b.a&&(b.a=new Zde(b)),b.a);return f=0?RD(QHd(d,f),58):null} + function Ib(a,b){if(a<0){return hc(qve,cD(WC(jJ,1),rve,1,5,['index',sgb(a)]))}else if(b<0){throw Adb(new agb(sve+b))}else {return hc('%s (%s) must be less than size (%s)',cD(WC(jJ,1),rve,1,5,['index',sgb(a),sgb(b)]))}} + function cob(a){var b,c,d,e,f;if(a==null){return vve}f=new Jyb(pve,'[',']');for(c=a,d=0,e=c.length;d=0?a.Lh(c,true,true):Qvd(a,e,true),160));RD(d,220).Zl(b);}else {throw Adb(new agb(KHe+b.xe()+LHe))}} + function Cib(a){var b,c;if(a>-140737488355328&&a<140737488355328){if(a==0){return 0}b=a<0;b&&(a=-a);c=eE($wnd.Math.floor($wnd.Math.log(a)/0.6931471805599453));(!b||a!=$wnd.Math.pow(2,c))&&++c;return c}return Dib(Hdb(a))} + function oTc(a){var b,c,d,e,f,g,h;f=new Iub;for(c=new Anb(a);c.a2&&h.e.b+h.j.b<=2){e=h;d=g;}f.a.zc(e,f);e.q=d;}return f} + function B5c(a,b,c){c.Ug('Eades radial',1);c.dh(b,gFe);a.d=RD(Gxd(b,(u2c(),t2c)),27);a.c=Kfb(UD(Gxd(b,($4c(),S4c))));a.e=u5c(RD(Gxd(b,X4c),300));a.a=Z3c(RD(Gxd(b,Z4c),434));a.b=k5c(RD(Gxd(b,O4c),354));C5c(a);c.dh(b,gFe);} + function t8c(a,b){b.Ug('Target Width Setter',1);if(Hxd(a,(X7c(),W7c))){Ixd(a,(X6c(),W6c),UD(Gxd(a,W7c)));}else {throw Adb(new Jed('A target width has to be set if the TargetWidthWidthApproximator should be used.'))}b.Vg();} + function _8b(a,b){var c,d,e;d=new j3b(a);kQb(d,b);pQb(d,(Ywc(),gwc),b);pQb(d,(yCc(),BBc),(Bod(),wod));pQb(d,Rzc,(Rjd(),Njd));h3b(d,(r3b(),m3b));c=new R3b;P3b(c,d);Q3b(c,(qpd(),ppd));e=new R3b;P3b(e,d);Q3b(e,Xod);return d} + function ttc(a){switch(a.g){case 0:return new FKc((RKc(),OKc));case 1:return new aKc;case 2:return new FLc;default:throw Adb(new agb('No implementation is available for the crossing minimizer '+(a.f!=null?a.f:''+a.g)));}} + function THc(a,b){var c,d,e,f,g;a.c[b.p]=true;Rmb(a.a,b);for(g=new Anb(b.j);g.a=f){g.$b();}else {e=g.Kc();for(d=0;d0?Hh():g<0&&Rw(a,b,-g);return true}else {return false}} + function YKb(a){var b,c,d,e,f,g,h;h=0;if(a.b==0){g=aLb(a,true);b=0;for(d=g,e=0,f=d.length;e0){h+=c;++b;}}b>1&&(h+=a.c*(b-1));}else {h=Vvb(SCb(HDb(CDb(_nb(a.a),new oLb),new qLb)));}return h>0?h+a.n.d+a.n.a:0} + function ZKb(a){var b,c,d,e,f,g,h;h=0;if(a.b==0){h=Vvb(SCb(HDb(CDb(_nb(a.a),new kLb),new mLb)));}else {g=bLb(a,true);b=0;for(d=g,e=0,f=d.length;e0){h+=c;++b;}}b>1&&(h+=a.c*(b-1));}return h>0?h+a.n.b+a.n.c:0} + function UOc(a){var b,c;if(a.c.length!=2){throw Adb(new dgb('Order only allowed for two paths.'))}b=(tFb(0,a.c.length),RD(a.c[0],18));c=(tFb(1,a.c.length),RD(a.c[1],18));if(b.d.i!=c.c.i){a.c.length=0;ZEb(a.c,c);ZEb(a.c,b);}} + function O8c(a,b,c){var d;zyd(c,b.g,b.f);Byd(c,b.i,b.j);for(d=0;d<(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i;d++){O8c(a,RD(QHd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),d),27),RD(QHd((!c.a&&(c.a=new C5d(J4,c,10,11)),c.a),d),27));}} + function DMb(a,b){var c,d,e,f;f=RD(Vrb(a.b,b),127);c=f.a;for(e=RD(RD(Qc(a.r,b),21),87).Kc();e.Ob();){d=RD(e.Pb(),117);!!d.c&&(c.a=$wnd.Math.max(c.a,QKb(d.c)));}if(c.a>0){switch(b.g){case 2:f.n.c=a.s;break;case 4:f.n.b=a.s;}}} + function ETb(a,b){var c,d,e;c=RD(mQb(b,(yVb(),lVb)),17).a-RD(mQb(a,lVb),17).a;if(c==0){d=ojd(ajd(RD(mQb(a,(JVb(),FVb)),8)),RD(mQb(a,GVb),8));e=ojd(ajd(RD(mQb(b,FVb),8)),RD(mQb(b,GVb),8));return Qfb(d.a*d.b,e.a*e.b)}return c} + function JVc(a,b){var c,d,e;c=RD(mQb(b,(h_c(),X$c)),17).a-RD(mQb(a,X$c),17).a;if(c==0){d=ojd(ajd(RD(mQb(a,(q$c(),RZc)),8)),RD(mQb(a,SZc),8));e=ojd(ajd(RD(mQb(b,RZc),8)),RD(mQb(b,SZc),8));return Qfb(d.a*d.b,e.a*e.b)}return c} + function _0b(a){var b,c;c=new bib;c.a+='e_';b=S0b(a);b!=null&&(c.a+=''+b,c);if(!!a.c&&!!a.d){Zhb((c.a+=' ',c),M3b(a.c));Zhb(Yhb((c.a+='[',c),a.c.i),']');Zhb((c.a+=SAe,c),M3b(a.d));Zhb(Yhb((c.a+='[',c),a.d.i),']');}return c.a} + function ZVc(a){switch(a.g){case 0:return new N_c;case 1:return new V_c;case 2:return new x0c;case 3:return new J0c;default:throw Adb(new agb('No implementation is available for the layout phase '+(a.f!=null?a.f:''+a.g)));}} + function qsd(a,b,c,d,e){var f;f=0;switch(e.g){case 1:f=$wnd.Math.max(0,b.b+a.b-(c.b+d));break;case 3:f=$wnd.Math.max(0,-a.b-d);break;case 2:f=$wnd.Math.max(0,-a.a-d);break;case 4:f=$wnd.Math.max(0,b.a+a.a-(c.a+d));}return f} + function MDd(a,b,c){var d,e,f,g,h;if(c){e=c.a.length;d=new vue(e);for(h=(d.b-d.a)*d.c<0?(uue(),tue):new Rue(d);h.Ob();){g=RD(h.Pb(),17);f=xDd(c,g.a);kIe in f.a||lIe in f.a?yEd(a,f,b):EEd(a,f,b);OGd(RD(Wjb(a.b,uDd(f)),74));}}} + function jXd(a){var b,c;switch(a.b){case -1:{return true}case 0:{c=a.t;if(c>1||c==-1){a.b=-1;return true}else {b=WVd(a);if(!!b&&(nke(),b.lk()==aKe)){a.b=-1;return true}else {a.b=1;return false}}}default:case 1:{return false}}} + function Sqe(a,b){var c,d,e,f;Mqe(a);if(a.c!=0||a.a!=123)throw Adb(new Lqe(TId((Hde(),eJe))));f=b==112;d=a.d;c=phb(a.i,125,d);if(c<0)throw Adb(new Lqe(TId((Hde(),fJe))));e=zhb(a.i,d,c);a.d=c+1;return ite(e,f,(a.e&512)==512)} + function YTb(a){var b,c,d,e,f,g,h;d=a.a.c.length;if(d>0){g=a.c.d;h=a.d.d;e=ijd(ojd(new rjd(h.a,h.b),g),1/(d+1));f=new rjd(g.a,g.b);for(c=new Anb(a.a);c.a=0&&f=0?a.Lh(c,true,true):Qvd(a,e,true),160));return RD(d,220).Wl(b)}else {throw Adb(new agb(KHe+b.xe()+NHe))}} + function _ae(){Tae();var a;if(Sae)return RD(N5d((YSd(),XSd),AKe),2038);RRd(UK,new hde);abe();a=RD(ZD(Xjb((YSd(),XSd),AKe),560)?Xjb(XSd,AKe):new $ae,560);Sae=true;Yae(a);Zae(a);Zjb((hTd(),gTd),a,new cbe);$jb(XSd,AKe,a);return a} + function Vfe(a,b){var c,d,e,f;a.j=-1;if(Mvd(a.e)){c=a.i;f=a.i!=0;LHd(a,b);d=new P3d(a.e,3,a.c,null,b,c,f);e=b.zl(a.e,a.c,null);e=Hge(a,b,e);if(!e){qvd(a.e,d);}else {e.nj(d);e.oj();}}else {LHd(a,b);e=b.zl(a.e,a.c,null);!!e&&e.oj();}} + function HA(a,b){var c,d,e;e=0;d=b[0];if(d>=a.length){return -1}c=(BFb(d,a.length),a.charCodeAt(d));while(c>=48&&c<=57){e=e*10+(c-48);++d;if(d>=a.length){break}c=(BFb(d,a.length),a.charCodeAt(d));}d>b[0]?(b[0]=d):(e=-1);return e} + function mPb(a){var b,c,d,e,f;e=RD(a.a,17).a;f=RD(a.b,17).a;c=e;d=f;b=$wnd.Math.max($wnd.Math.abs(e),$wnd.Math.abs(f));if(e<=0&&e==f){c=0;d=f-1;}else {if(e==-b&&f!=b){c=f;d=e;f>=0&&++c;}else {c=-f;d=e;}}return new Ptd(sgb(c),sgb(d))} + function YPb(a,b,c,d){var e,f,g,h,i,j;for(e=0;e=0&&j>=0&&i=a.i)throw Adb(new veb(MIe+b+NIe+a.i));if(c>=a.i)throw Adb(new veb(OIe+c+NIe+a.i));d=a.g[c];if(b!=c){b>16);b=d>>16&16;c=16-b;a=a>>b;d=a-256;b=d>>16&8;c+=b;a<<=b;d=a-qxe;b=d>>16&4;c+=b;a<<=b;d=a-Ove;b=d>>16&2;c+=b;a<<=b;d=a>>14;b=d&~(d>>1);return c+2-b}} + function RSb(a){HSb();var b,c,d,e;GSb=new bnb;FSb=new Tsb;ESb=new bnb;b=(!a.a&&(a.a=new C5d(J4,a,10,11)),a.a);JSb(b);for(e=new dMd(b);e.e!=e.i.gc();){d=RD(bMd(e),27);if(Wmb(GSb,d,0)==-1){c=new bnb;Rmb(ESb,c);KSb(d,c);}}return ESb} + function sTb(a,b,c){var d,e,f,g;a.a=c.b.d;if(ZD(b,326)){e=IGd(RD(b,74),false,false);f=ssd(e);d=new wTb(a);xgb(f,d);lsd(f,e);b.of((umd(),cld))!=null&&xgb(RD(b.of(cld),75),d);}else {g=RD(b,422);g.rh(g.nh()+a.a.a);g.sh(g.oh()+a.a.b);}} + function hWc(a,b){var c,d,e;e=new bnb;for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);c.c.g==a.g&&dE(mQb(c.b,(h_c(),f_c)))!==dE(mQb(c.c,f_c))&&!yDb(new SDb(null,new Swb(e,16)),new IWc(c))&&(ZEb(e.c,c),true);}_mb(e,new KWc);return e} + function fUb(a,b,c){var d,e,f,g;if(ZD(b,153)&&ZD(c,153)){f=RD(b,153);g=RD(c,153);return a.a[f.a][g.a]+a.a[g.a][f.a]}else if(ZD(b,250)&&ZD(c,250)){d=RD(b,250);e=RD(c,250);if(d.a==e.a){return RD(mQb(e.a,(yVb(),lVb)),17).a}}return 0} + function q9b(a,b){var c,d,e,f,g,h,i,j;j=Kfb(UD(mQb(b,(yCc(),fCc))));i=a[0].n.a+a[0].o.a+a[0].d.c+j;for(h=1;h=0){return c}h=ejd(ojd(new rjd(g.c+g.b/2,g.d+g.a/2),new rjd(f.c+f.b/2,f.d+f.a/2)));return -(oRb(f,g)-1)*h} + function ysd(a,b,c){var d;FDb(new SDb(null,(!c.a&&(c.a=new C5d(F4,c,6,6)),new Swb(c.a,16))),new Qsd(a,b));FDb(new SDb(null,(!c.n&&(c.n=new C5d(I4,c,1,7)),new Swb(c.n,16))),new Ssd(a,b));d=RD(Gxd(c,(umd(),cld)),75);!!d&&Bjd(d,a,b);} + function Qvd(a,b,c){var d,e,f;f=Eee((lke(),jke),a.Dh(),b);if(f){nke();RD(f,69).xk()||(f=zfe(Qee(jke,f)));e=(d=a.Ih(f),RD(d>=0?a.Lh(d,true,true):Qvd(a,f,true),160));return RD(e,220).Sl(b,c)}else {throw Adb(new agb(KHe+b.xe()+NHe))}} + function WNd(a,b,c,d){var e,f,g,h,i;e=a.d[b];if(e){f=e.g;i=e.i;if(d!=null){for(h=0;h=c){d=b;j=(i.c+i.a)/2;g=j-c;if(i.c<=j-c){e=new BTc(i.c,g);Qmb(a,d++,e);}h=j+c;if(h<=i.a){f=new BTc(h,i.a);wFb(d,a.c.length);XEb(a.c,d,f);}}} + function mZc(a,b,c){var d,e,f,g,h,i;if(!b.dc()){e=new Yub;for(i=b.Kc();i.Ob();){h=RD(i.Pb(),40);Zjb(a.a,sgb(h.g),sgb(c));for(g=(d=Sub((new dXc(h)).a.d,0),new gXc(d));dvb(g.a);){f=RD(evb(g.a),65).c;Pub(e,f,e.c.b,e.c);}}mZc(a,e,c+1);}} + function Ude(a){var b;if(!a.c&&a.g==null){a.d=a.bj(a.f);WGd(a,a.d);b=a.d;}else {if(a.g==null){return true}else if(a.i==0){return false}else {b=RD(a.g[a.i-1],51);}}if(b==a.b&&null.Vm>=null.Um()){tId(a);return Ude(a)}else {return b.Ob()}} + function t_b(a){this.a=a;if(a.c.i.k==(r3b(),m3b)){this.c=a.c;this.d=RD(mQb(a.c.i,(Ywc(),hwc)),64);}else if(a.d.i.k==m3b){this.c=a.d;this.d=RD(mQb(a.d.i,(Ywc(),hwc)),64);}else {throw Adb(new agb('Edge '+a+' is not an external edge.'))}} + function O1d(a,b){var c,d,e;e=a.b;a.b=b;(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,e,a.b));if(!b){PAd(a,null);Q1d(a,0);P1d(a,null);}else if(b!=a){PAd(a,b.zb);Q1d(a,b.d);c=(d=b.c,d==null?b.zb:d);P1d(a,c==null||lhb(c,b.zb)?null:c);}} + function hj(a,b){var c;this.e=(tm(),Qb(a),tm(),zm(a));this.c=(Qb(b),zm(b));Lb(this.e.Rd().dc()==this.c.Rd().dc());this.d=Uv(this.e);this.b=Uv(this.c);c=YC(jJ,[Nve,rve],[5,1],5,[this.e.Rd().gc(),this.c.Rd().gc()],2);this.a=c;Zi(this);} + function Lz(b){(!Jz&&(Jz=Mz()),Jz);var d=b.replace(/[\x00-\x1f\xad\u0600-\u0603\u06dd\u070f\u17b4\u17b5\u200b-\u200f\u2028-\u202e\u2060-\u2064\u206a-\u206f\ufeff\ufff9-\ufffb"\\]/g,function(a){return Kz(a)});return '"'+d+'"'} + function VEb(a,b,c,d,e,f){var g,h,i,j,k;if(e==0){return}if(dE(a)===dE(c)){a=a.slice(b,b+e);b=0;}i=c;for(h=b,j=b+e;h=g)throw Adb(new aMd(b,g));e=c[b];if(g==1){d=null;}else {d=$C(d6,IJe,424,g-1,0,1);hib(c,0,d,0,b);f=g-b-1;f>0&&hib(c,b+1,d,b,f);}Bde(a,d);Ade(a,b,e);return e} + function l3d(a){var b,c;if(a.f){while(a.n0?(f=vpd(c)):(f=spd(vpd(c)));}Ixd(b,GBc,f);} + function agc(a,b){var c;b.Ug('Partition preprocessing',1);c=RD(zDb(CDb(EDb(CDb(new SDb(null,new Swb(a.a,16)),new egc),new ggc),new igc),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);FDb(c.Oc(),new kgc);b.Vg();} + function Uoc(a,b){var c,d,e,f,g;g=a.j;b.a!=b.b&&_mb(g,new ypc);e=g.c.length/2|0;for(d=0;d0&&uLc(a,c,b);return f}else if(d.a!=null){uLc(a,b,c);return -1}else if(e.a!=null){uLc(a,c,b);return 1}return 0} + function EVc(a,b){var c,d,e,f,g;e=b.b.b;a.a=$C(QK,Ize,15,e,0,1);a.b=$C(xdb,Hye,28,e,16,1);for(g=Sub(b.b,0);g.b!=g.d.c;){f=RD(evb(g),40);a.a[f.g]=new Yub;}for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);a.a[c.b.g].Fc(c);a.a[c.c.g].Fc(c);}} + function SJd(a,b){var c,d,e,f;if(a.Pj()){c=a.Ej();f=a.Qj();++a.j;a.qj(c,a.Zi(c,b));d=a.Ij(3,null,b,c,f);if(a.Mj()){e=a.Nj(b,null);if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Jj(d);}}else {_Id(a,b);if(a.Mj()){e=a.Nj(b,null);!!e&&e.oj();}}} + function oLd(a,b,c){var d,e,f;if(a.Pj()){f=a.Qj();KHd(a,b,c);d=a.Ij(3,null,c,b,f);if(a.Mj()){e=a.Nj(c,null);a.Tj()&&(e=a.Uj(c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Jj(d);}}else {KHd(a,b,c);if(a.Mj()){e=a.Nj(c,null);!!e&&e.oj();}}} + function bge(a,b){var c,d,e,f,g;g=pke(a.e.Dh(),b);e=new YHd;c=RD(a.g,124);for(f=a.i;--f>=0;){d=c[f];g.am(d.Lk())&&WGd(e,d);}!wLd(a,e)&&Mvd(a.e)&&eZd(a,b.Jk()?fge(a,6,b,(yob(),vob),null,-1,false):fge(a,b.tk()?2:1,b,null,null,-1,false));} + function _7b(a,b){var c,d,e,f,g;if(a.a==($uc(),Yuc)){return true}f=b.a.c;c=b.a.c+b.a.b;if(b.j){d=b.A;g=d.c.c.a-d.o.a/2;e=f-(d.n.a+d.o.a);if(e>g){return false}}if(b.q){d=b.C;g=d.c.c.a-d.o.a/2;e=d.n.a-c;if(e>g){return false}}return true} + function bRc(a){WQc();var b,c,d,e,f,g,h;c=new gub;for(e=new Anb(a.e.b);e.a1?(a.e*=Kfb(a.a)):(a.f/=Kfb(a.a));uRb(a);vRb(a);rRb(a);pQb(a.b,(tSb(),lSb),a.g);} + function n9b(a,b,c){var d,e,f,g,h,i;d=0;i=c;if(!b){d=c*(a.c.length-1);i*=-1;}for(f=new Anb(a);f.a=0?a.Ah(null):a.Ph().Th(a,-1-b,null,null));a.Bh(RD(e,54),c);!!d&&d.oj();a.vh()&&a.wh()&&c>-1&&qvd(a,new N3d(a,9,c,f,e));return e}}}return f} + function stb(a,b){var c,d,e,f,g;f=a.b.Ce(b);d=(c=a.a.get(f),c==null?$C(jJ,rve,1,0,5,1):c);for(g=0;g>5;if(e>=a.d){return a.e<0}c=a.a[e];b=1<<(b&31);if(a.e<0){d=Uib(a);if(e>16)),15).dd(f);if(h0){!(Dmd(a.a.c)&&b.n.d)&&!(Emd(a.a.c)&&b.n.b)&&(b.g.d+=$wnd.Math.max(0,d/2-0.5));!(Dmd(a.a.c)&&b.n.a)&&!(Emd(a.a.c)&&b.n.c)&&(b.g.a-=d-1);}}} + function c7b(a){var b,c,d,e,f;e=new bnb;f=d7b(a,e);b=RD(mQb(a,(Ywc(),Iwc)),10);if(b){for(d=new Anb(b.j);d.a>b;f=a.m>>b|c<<22-b;e=a.l>>b|a.m<<22-b;}else if(b<44){g=d?exe:0;f=c>>b-22;e=a.m>>b-22|c<<44-b;}else {g=d?exe:0;f=d?dxe:0;e=c>>b-44;}return hD(e&dxe,f&dxe,g&exe)} + function ORb(a){var b,c,d,e,f,g;this.c=new bnb;this.d=a;d=oxe;e=oxe;b=pxe;c=pxe;for(g=Sub(a,0);g.b!=g.d.c;){f=RD(evb(g),8);d=$wnd.Math.min(d,f.a);e=$wnd.Math.min(e,f.b);b=$wnd.Math.max(b,f.a);c=$wnd.Math.max(c,f.b);}this.a=new Uid(d,e,b-d,c-e);} + function Udc(a,b){var c,d,e,f,g,h;for(f=new Anb(a.b);f.a0&&ZD(b,44)){a.a._j();j=RD(b,44);i=j.ld();f=i==null?0:tb(i);g=bOd(a.a,f);c=a.a.d[g];if(c){d=RD(c.g,379);k=c.i;for(h=0;h=2){c=e.Kc();b=UD(c.Pb());while(c.Ob()){f=b;b=UD(c.Pb());d=$wnd.Math.min(d,(uFb(b),b)-(uFb(f),f));}}return d} + function iWc(a,b){var c,d,e;e=new bnb;for(d=Sub(b.a,0);d.b!=d.d.c;){c=RD(evb(d),65);c.b.g==a.g&&!lhb(c.b.c,IEe)&&dE(mQb(c.b,(h_c(),f_c)))!==dE(mQb(c.c,f_c))&&!yDb(new SDb(null,new Swb(e,16)),new OWc(c))&&(ZEb(e.c,c),true);}_mb(e,new QWc);return e} + function $u(a,b){var c,d,e;if(dE(b)===dE(Qb(a))){return true}if(!ZD(b,15)){return false}d=RD(b,15);e=a.gc();if(e!=d.gc()){return false}if(ZD(d,59)){for(c=0;c0&&(e=c);for(g=new Anb(a.f.e);g.a0){b-=1;c-=1;}else {if(d>=0&&e<0){b+=1;c+=1;}else {if(d>0&&e>=0){b-=1;c+=1;}else {b+=1;c-=1;}}}}}return new Ptd(sgb(b),sgb(c))} + function nNc(a,b){if(a.cb.c){return 1}else if(a.bb.b){return 1}else if(a.a!=b.a){return tb(a.a)-tb(b.a)}else if(a.d==(sNc(),rNc)&&b.d==qNc){return -1}else if(a.d==qNc&&b.d==rNc){return 1}return 0} + function ARc(a,b){var c,d,e,f,g;f=b.a;f.c.i==b.b?(g=f.d):(g=f.c);f.c.i==b.b?(d=f.c):(d=f.d);e=lQc(a.a,g,d);if(e>0&&e0}else if(e<0&&-e0}return false} + function X9c(a,b,c,d){var e,f,g,h,i,j,k,l;e=(b-a.d)/a.c.c.length;f=0;a.a+=c;a.d=b;for(l=new Anb(a.c);l.a>24;}return g} + function Bfb(a){if(a.ze()){var b=a.c;b.Ae()?(a.o='['+b.n):!b.ze()?(a.o='[L'+b.xe()+';'):(a.o='['+b.xe());a.b=b.we()+'[]';a.k=b.ye()+'[]';return}var c=a.j;var d=a.d;d=d.split('/');a.o=Efb('.',[c,Efb('$',d)]);a.b=Efb('.',[c,Efb('.',d)]);a.k=d[d.length-1];} + function hJb(a,b){var c,d,e,f,g;g=null;for(f=new Anb(a.e.a);f.a=0;b-=2){for(c=0;c<=b;c+=2){if(a.b[c]>a.b[c+2]||a.b[c]===a.b[c+2]&&a.b[c+1]>a.b[c+3]){d=a.b[c+2];a.b[c+2]=a.b[c];a.b[c]=d;d=a.b[c+3];a.b[c+3]=a.b[c+1];a.b[c+1]=d;}}}a.c=true;} + function nKc(a,b){var c,d,e,f,g,h,i,j,k;j=-1;k=0;for(g=a,h=0,i=g.length;h0&&++k;}}++j;}return k} + function awd(a){var b,c;c=new dib(nfb(a.Rm));c.a+='@';Zhb(c,(b=tb(a)>>>0,b.toString(16)));if(a.Vh()){c.a+=' (eProxyURI: ';Yhb(c,a._h());if(a.Kh()){c.a+=' eClass: ';Yhb(c,a.Kh());}c.a+=')';}else if(a.Kh()){c.a+=' (eClass: ';Yhb(c,a.Kh());c.a+=')';}return c.a} + function KGb(a){var b,c,d,e;if(a.e){throw Adb(new dgb((lfb(lN),lye+lN.k+mye)))}a.d==(Cmd(),Amd)&&JGb(a,ymd);for(c=new Anb(a.a.a);c.a>24;}return c} + function cNb(a,b,c){var d,e,f;e=RD(Vrb(a.i,b),314);if(!e){e=new UKb(a.d,b,c);Wrb(a.i,b,e);if(jMb(b)){tKb(a.a,b.c,b.b,e);}else {f=iMb(b);d=RD(Vrb(a.p,f),252);switch(f.g){case 1:case 3:e.j=true;cLb(d,b.b,e);break;case 4:case 2:e.k=true;cLb(d,b.c,e);}}}return e} + function Ndc(a,b){var c,d,e,f,g,h,i,j,k;i=ev(a.c-a.b&a.a.length-1);j=null;k=null;for(f=new Kmb(a);f.a!=f.b;){e=RD(Imb(f),10);c=(h=RD(mQb(e,(Ywc(),vwc)),12),!h?null:h.i);d=(g=RD(mQb(e,wwc),12),!g?null:g.i);if(j!=c||k!=d){Rdc(i,b);j=c;k=d;}ZEb(i.c,e);}Rdc(i,b);} + function Rge(a,b,c,d){var e,f,g,h,i,j;h=new YHd;i=pke(a.e.Dh(),b);e=RD(a.g,124);nke();if(RD(b,69).xk()){for(g=0;g=0){return e}else {f=1;for(h=new Anb(b.j);h.a=0){return e}else {f=1;for(h=new Anb(b.j);h.a0&&b.Ne((tFb(e-1,a.c.length),RD(a.c[e-1],10)),f)>0){$mb(a,e,(tFb(e-1,a.c.length),RD(a.c[e-1],10)));--e;}tFb(e,a.c.length);a.c[e]=f;}c.a=new Tsb;c.b=new Tsb;} + function yhd(a,b,c){var d,e,f,g,h,i,j,k;k=(d=RD(b.e&&b.e(),9),new Fsb(d,RD(WEb(d,d.length),9),0));i=vhb(c,'[\\[\\]\\s,]+');for(f=i,g=0,h=f.length;g=0){if(!b){b=new Rhb;d>0&&Nhb(b,(AFb(0,d,a.length),a.substr(0,d)));}b.a+='\\';Jhb(b,c&Bwe);}else !!b&&Jhb(b,c&Bwe);}return b?b.a:a} + function MYb(a){var b,c,d;for(c=new Anb(a.a.a.b);c.a0){!(Dmd(a.a.c)&&b.n.d)&&!(Emd(a.a.c)&&b.n.b)&&(b.g.d-=$wnd.Math.max(0,d/2-0.5));!(Dmd(a.a.c)&&b.n.a)&&!(Emd(a.a.c)&&b.n.c)&&(b.g.a+=$wnd.Math.max(0,d-1));}}} + function Ydc(a,b,c){var d,e;if((a.c-a.b&a.a.length-1)==2){if(b==(qpd(),Yod)||b==Xod){Odc(RD(omb(a),15),(Pnd(),Lnd));Odc(RD(omb(a),15),Mnd);}else {Odc(RD(omb(a),15),(Pnd(),Mnd));Odc(RD(omb(a),15),Lnd);}}else {for(e=new Kmb(a);e.a!=e.b;){d=RD(Imb(e),15);Odc(d,c);}}} + function HGd(a,b){var c,d,e,f,g,h,i;e=cv(new QGd(a));h=new Jkb(e,e.c.length);f=cv(new QGd(b));i=new Jkb(f,f.c.length);g=null;while(h.b>0&&i.b>0){c=(sFb(h.b>0),RD(h.a.Xb(h.c=--h.b),27));d=(sFb(i.b>0),RD(i.a.Xb(i.c=--i.b),27));if(c==d){g=c;}else {break}}return g} + function Dmc(a,b,c){var d,e,f,g;if(Hmc(a,b)>Hmc(a,c)){d=b3b(c,(qpd(),Xod));a.d=d.dc()?0:L3b(RD(d.Xb(0),12));g=b3b(b,ppd);a.b=g.dc()?0:L3b(RD(g.Xb(0),12));}else {e=b3b(c,(qpd(),ppd));a.d=e.dc()?0:L3b(RD(e.Xb(0),12));f=b3b(b,Xod);a.b=f.dc()?0:L3b(RD(f.Xb(0),12));}} + function wNb(a,b){var c,d,e,f;c=a.o.a;for(f=RD(RD(Qc(a.r,b),21),87).Kc();f.Ob();){e=RD(f.Pb(),117);e.e.a=c*Kfb(UD(e.b.of(sNb)));e.e.b=(d=e.b,d.pf((umd(),Gld))?d.ag()==(qpd(),Yod)?-d.Mf().b-Kfb(UD(d.of(Gld))):Kfb(UD(d.of(Gld))):d.ag()==(qpd(),Yod)?-d.Mf().b:0);}} + function Mhc(a,b){var c,d,e,f;b.Ug('Self-Loop pre-processing',1);for(d=new Anb(a.a);d.aa.c){break}else if(e.a>=a.s){f<0&&(f=g);h=g;}}i=(a.s+a.c)/2;if(f>=0){d=lTc(a,b,f,h);i=yTc((tFb(d,b.c.length),RD(b.c[d],339)));wTc(b,d,c);}return i} + function _Ad(a,b,c){var d,e,f,g,h,i,j;g=(f=new pVd,f);nVd(g,(uFb(b),b));j=(!g.b&&(g.b=new SVd((JTd(),FTd),C8,g)),g.b);for(i=1;i0&&ASb(this,e);}} + function zTb(a,b,c,d,e,f){var g,h,i;if(!e[b.a]){e[b.a]=true;g=d;!g&&(g=new gUb);Rmb(g.e,b);for(i=f[b.a].Kc();i.Ob();){h=RD(i.Pb(),290);if(h.d==c||h.c==c){continue}h.c!=b&&zTb(a,h.c,b,g,e,f);h.d!=b&&zTb(a,h.d,b,g,e,f);Rmb(g.c,h);Tmb(g.d,h.b);}return g}return null} + function v7b(a){var b,c,d,e,f,g,h;b=0;for(e=new Anb(a.e);e.a=2} + function _qc(a,b,c,d,e){var f,g,h,i,j,k;f=a.c.d.j;g=RD(ju(c,0),8);for(k=1;k1){return false}b=ysb(Xnd,cD(WC(A3,1),jwe,95,0,[Wnd,Znd]));if(dy(Tx(b,a))>1){return false}d=ysb(cod,cD(WC(A3,1),jwe,95,0,[bod,aod]));if(dy(Tx(d,a))>1){return false}return true} + function $Uc(a,b,c){var d,e,f;for(f=new Anb(a.t);f.a0){d.b.n-=d.c;d.b.n<=0&&d.b.u>0&&Mub(b,d.b);}}for(e=new Anb(a.i);e.a0){d.a.u-=d.c;d.a.u<=0&&d.a.n>0&&Mub(c,d.a);}}} + function tId(a){var b,c,d,e,f;if(a.g==null){a.d=a.bj(a.f);WGd(a,a.d);if(a.c){f=a.f;return f}}b=RD(a.g[a.i-1],51);e=b.Pb();a.e=b;c=a.bj(e);if(c.Ob()){a.d=c;WGd(a,c);}else {a.d=null;while(!b.Ob()){bD(a.g,--a.i,null);if(a.i==0){break}d=RD(a.g[a.i-1],51);b=d;}}return e} + function Rfe(a,b){var c,d,e,f,g,h;d=b;e=d.Lk();if(qke(a.e,e)){if(e.Si()&&cge(a,e,d.md())){return false}}else {h=pke(a.e.Dh(),e);c=RD(a.g,124);for(f=0;f1||c>1){return 2}}if(b+c==1){return 2}return 0} + function Kwb(a,b){var c,d,e,f,g,h;f=a.a*Mxe+a.b*1502;h=a.b*Mxe+11;c=$wnd.Math.floor(h*Nxe);f+=c;h-=c*Oxe;f%=Oxe;a.a=f;a.b=h;if(b<=24){return $wnd.Math.floor(a.a*Ewb[b])}else {e=a.a*(1<=2147483648&&(d-=4294967296);return d}} + function uSc(a,b,c){var d,e,f,g,h,i,j;f=new bnb;j=new Yub;g=new Yub;vSc(a,j,g,b);tSc(a,j,g,b,c);for(i=new Anb(a);i.ad.b.g&&(ZEb(f.c,d),true);}}return f} + function jed(a,b,c){var d,e,f,g,h,i;h=a.c;for(g=(!c.q?(yob(),yob(),wob):c.q).vc().Kc();g.Ob();){f=RD(g.Pb(),44);d=!QDb(CDb(new SDb(null,new Swb(h,16)),new PAb(new xed(b,f)))).Bd((xDb(),wDb));if(d){i=f.md();if(ZD(i,4)){e=FId(i);e!=null&&(i=e);}b.qf(RD(f.ld(),149),i);}}} + function mbd(a,b,c){var d,e;Sed(a.b);Ved(a.b,(gbd(),dbd),(_cd(),$cd));Ved(a.b,ebd,b.g);Ved(a.b,fbd,b.a);a.a=Qed(a.b,b);c.Ug('Compaction by shrinking a tree',a.a.c.length);if(b.i.c.length>1){for(e=new Anb(a.a);e.a=0?a.Lh(d,true,true):Qvd(a,f,true),160));RD(e,220).Xl(b,c);}else {throw Adb(new agb(KHe+b.xe()+LHe))}} + function k2d(a,b){var c,d,e,f,g;if(!b){return null}else {f=ZD(a.Cb,90)||ZD(a.Cb,102);g=!f&&ZD(a.Cb,331);for(d=new dMd((!b.a&&(b.a=new iae(b,o7,b)),b.a));d.e!=d.i.gc();){c=RD(bMd(d),89);e=i2d(c);if(f?ZD(e,90):g?ZD(e,156):!!e){return e}}return f?(JTd(),zTd):(JTd(),wTd)}} + function W8b(a,b){var c,d,e,f;b.Ug('Resize child graph to fit parent.',1);for(d=new Anb(a.b);d.a=2*b&&Rmb(c,new BTc(g[d-1]+b,g[d]-b));}return c} + function dEd(a,b,c){var d,e,f,g,h,j,k,l;if(c){f=c.a.length;d=new vue(f);for(h=(d.b-d.a)*d.c<0?(uue(),tue):new Rue(d);h.Ob();){g=RD(h.Pb(),17);e=xDd(c,g.a);!!e&&(j=sEd(a,(k=(bvd(),l=new PCd,l),!!b&&NCd(k,b),k),e),jyd(j,zDd(e,uIe)),GEd(e,j),HEd(e,j),CEd(a,e,j));}}} + function sYd(a){var b,c,d,e,f,g;if(!a.j){g=new f1d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(zYd(a));d.e!=d.i.gc();){c=RD(bMd(d),29);e=sYd(c);YGd(g,e);WGd(g,c);}b.a.Bc(a)!=null;}VHd(g);a.j=new N$d((RD(QHd(xYd((lTd(),kTd).o),11),19),g.i),g.g);yYd(a).b&=-33;}return a.j} + function lne(a){var b,c,d,e;if(a==null){return null}else {d=nue(a,true);e=mLe.length;if(lhb(d.substr(d.length-e,e),mLe)){c=d.length;if(c==4){b=(BFb(0,d.length),d.charCodeAt(0));if(b==43){return Yme}else if(b==45){return Xme}}else if(c==3){return Yme}}return new Ufb(d)}} + function pD(a){var b,c,d;c=a.l;if((c&c-1)!=0){return -1}d=a.m;if((d&d-1)!=0){return -1}b=a.h;if((b&b-1)!=0){return -1}if(b==0&&d==0&&c==0){return -1}if(b==0&&d==0&&c!=0){return ogb(c)}if(b==0&&d!=0&&c==0){return ogb(d)+22}if(b!=0&&d==0&&c==0){return ogb(b)+44}return -1} + function yo(a,b){var c,d,e,f,g;e=b.a&a.f;f=null;for(d=a.b[e];true;d=d.b){if(d==b){!f?(a.b[e]=b.b):(f.b=b.b);break}f=d;}g=b.f&a.f;f=null;for(c=a.c[g];true;c=c.d){if(c==b){!f?(a.c[g]=b.d):(f.d=b.d);break}f=c;}!b.e?(a.a=b.c):(b.e.c=b.c);!b.c?(a.e=b.e):(b.c.e=b.e);--a.i;++a.g;} + function Dt(a,b){var c;b.d?(b.d.b=b.b):(a.a=b.b);b.b?(b.b.d=b.d):(a.e=b.d);if(!b.e&&!b.c){c=RD(Hvb(RD(_jb(a.b,b.a),260)),260);c.a=0;++a.c;}else {c=RD(Hvb(RD(Wjb(a.b,b.a),260)),260);--c.a;!b.e?(c.b=RD(Hvb(b.c),511)):(b.e.c=b.c);!b.c?(c.c=RD(Hvb(b.e),511)):(b.c.e=b.e);}--a.d;} + function XPb(a){var b,c,d,e,f,g,h,i,j,k;c=a.o;b=a.p;g=lve;e=qwe;h=lve;f=qwe;for(j=0;j0);f.a.Xb(f.c=--f.b);Ikb(f,e);sFb(f.b3&&UA(a,0,b-3);}} + function eXb(a){var b,c,d,e;if(dE(mQb(a,(yCc(),IAc)))===dE((Fnd(),Cnd))){return !a.e&&dE(mQb(a,gAc))!==dE((xvc(),uvc))}d=RD(mQb(a,hAc),299);e=Heb(TD(mQb(a,nAc)))||dE(mQb(a,oAc))===dE((stc(),ptc));b=RD(mQb(a,fAc),17).a;c=a.a.c.length;return !e&&d!=(xvc(),uvc)&&(b==0||b>c)} + function Rnc(a){var b,c;c=0;for(;c0){break}}if(c>0&&c0){break}}if(b>0&&c>16!=6&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+Qzd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?Czd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,6,d));d=Bzd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,6,b,b));} + function pzd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=3&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+qzd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?jzd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,12,d));d=izd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function NCd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=9&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+OCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?LCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,9,d));d=KCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,9,b,b));} + function tWd(b){var c,d,e,f,g;e=WVd(b);g=b.j;if(g==null&&!!e){return b.Jk()?null:e.ik()}else if(ZD(e,156)){d=e.jk();if(d){f=d.wi();if(f!=b.i){c=RD(e,156);if(c.nk()){try{b.g=f.ti(c,g);}catch(a){a=zdb(a);if(ZD(a,82)){b.g=null;}else throw Adb(a)}}b.i=f;}}return b.g}return null} + function nRb(a){var b;b=new bnb;Rmb(b,new TFb(new rjd(a.c,a.d),new rjd(a.c+a.b,a.d)));Rmb(b,new TFb(new rjd(a.c,a.d),new rjd(a.c,a.d+a.a)));Rmb(b,new TFb(new rjd(a.c+a.b,a.d+a.a),new rjd(a.c+a.b,a.d)));Rmb(b,new TFb(new rjd(a.c+a.b,a.d+a.a),new rjd(a.c,a.d+a.a)));return b} + function ic(b){var c,d,e;if(b==null){return vve}try{return jeb(b)}catch(a){a=zdb(a);if(ZD(a,103)){c=a;e=nfb(rb(b))+'@'+(d=(gib(),jFb(b))>>>0,d.toString(16));lBb(pBb(),(SAb(),'Exception during lenientFormat for '+e),c);return '<'+e+' threw '+nfb(c.Rm)+'>'}else throw Adb(a)}} + function mTb(a,b,c){var d,e,f;for(f=b.a.ec().Kc();f.Ob();){e=RD(f.Pb(),74);d=RD(Wjb(a.b,e),272);!d&&(vCd(JGd(e))==vCd(LGd(e))?lTb(a,e,c):JGd(e)==vCd(LGd(e))?Wjb(a.c,e)==null&&Wjb(a.b,LGd(e))!=null&&oTb(a,e,c,false):Wjb(a.d,e)==null&&Wjb(a.b,JGd(e))!=null&&oTb(a,e,c,true));}} + function Pfc(a,b){var c,d,e,f,g,h,i;for(e=a.Kc();e.Ob();){d=RD(e.Pb(),10);h=new R3b;P3b(h,d);Q3b(h,(qpd(),Xod));pQb(h,(Ywc(),Hwc),(Geb(),true));for(g=b.Kc();g.Ob();){f=RD(g.Pb(),10);i=new R3b;P3b(i,f);Q3b(i,ppd);pQb(i,Hwc,true);c=new a1b;pQb(c,Hwc,true);Y0b(c,h);Z0b(c,i);}}} + function Pqc(a,b,c,d){var e,f,g,h;e=Nqc(a,b,c);f=Nqc(a,c,b);g=RD(Wjb(a.c,b),118);h=RD(Wjb(a.c,c),118);if(e1){b=eJb((c=new gJb,++a.b,c),a.d);for(h=Sub(f,0);h.b!=h.d.c;){g=RD(evb(h),125);rIb(uIb(tIb(vIb(sIb(new wIb,1),0),b),g));}}} + function isc(a,b,c){var d,e,f,g,h;c.Ug('Breaking Point Removing',1);a.a=RD(mQb(b,(yCc(),yAc)),223);for(f=new Anb(b.b);f.a>16!=11&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+zCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?sCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=Ivd(b,a,10,d));d=rCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,11,b,b));} + function C0b(a){var b,c,d,e;for(d=new vkb((new mkb(a.b)).a);d.b;){c=tkb(d);e=RD(c.ld(),12);b=RD(c.md(),10);pQb(b,(Ywc(),Awc),e);pQb(e,Iwc,b);pQb(e,nwc,(Geb(),true));Q3b(e,RD(mQb(b,hwc),64));mQb(b,hwc);pQb(e.i,(yCc(),BBc),(Bod(),yod));RD(mQb(Y2b(e.i),kwc),21).Fc((ovc(),kvc));}} + function X7b(a,b,c){var d,e,f,g,h,i;f=0;g=0;if(a.c){for(i=new Anb(a.d.i.j);i.af.a){return -1}else if(e.ai){k=a.d;a.d=$C(D6,KJe,66,2*i+4,0,1);for(f=0;f=9223372036854775807){return MD(),ID}e=false;if(a<0){e=true;a=-a;}d=0;if(a>=hxe){d=eE(a/hxe);a-=d*hxe;}c=0;if(a>=gxe){c=eE(a/gxe);a-=c*gxe;}b=eE(a);f=hD(b,c,d);e&&nD(f);return f} + function KCb(a){var b,c,d,e,f;f=new bnb;Umb(a.b,new SEb(f));a.b.c.length=0;if(f.c.length!=0){b=(tFb(0,f.c.length),RD(f.c[0],82));for(c=1,d=f.c.length;c=-b&&d==b){return new Ptd(sgb(c-1),sgb(d))}return new Ptd(sgb(c),sgb(d-1))} + function lcc(){hcc();return cD(WC(YS,1),jwe,81,0,[nbc,kbc,obc,Ebc,Xbc,Ibc,bcc,Nbc,Vbc,zbc,Rbc,Mbc,Wbc,vbc,dcc,ebc,Qbc,Zbc,Fbc,Ybc,fcc,Tbc,fbc,Ubc,gcc,_bc,ecc,Gbc,sbc,Hbc,Dbc,ccc,ibc,qbc,Kbc,hbc,Lbc,Bbc,wbc,Obc,ybc,lbc,jbc,Cbc,xbc,Pbc,acc,gbc,Sbc,Abc,Jbc,tbc,rbc,$bc,pbc,ubc,mbc])} + function Cmc(a,b,c){a.d=0;a.b=0;b.k==(r3b(),q3b)&&c.k==q3b&&RD(mQb(b,(Ywc(),Awc)),10)==RD(mQb(c,Awc),10)&&(Gmc(b).j==(qpd(),Yod)?Dmc(a,b,c):Dmc(a,c,b));b.k==q3b&&c.k==o3b?Gmc(b).j==(qpd(),Yod)?(a.d=1):(a.b=1):c.k==q3b&&b.k==o3b&&(Gmc(c).j==(qpd(),Yod)?(a.b=1):(a.d=1));Imc(a,b,c);} + function EFd(a){var b,c,d,e,f,g,h,i,j,k,l;l=HFd(a);b=a.a;i=b!=null;i&&sDd(l,'category',a.a);e=cve(new Xkb(a.d));g=!e;if(g){j=new MB;sC(l,'knownOptions',j);c=new MFd(j);xgb(new Xkb(a.d),c);}f=cve(a.g);h=!f;if(h){k=new MB;sC(l,'supportedFeatures',k);d=new OFd(k);xgb(a.g,d);}return l} + function Ly(a){var b,c,d,e,f,g,h,i,j;d=false;b=336;c=0;f=new hq(a.length);for(h=a,i=0,j=h.length;i>16!=7&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+gCd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?cCd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=RD(b,54).Rh(a,1,H4,d));d=bCd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,7,b,b));} + function lVd(a,b){var c,d;if(b!=a.Cb||a.Db>>16!=3&&!!b){if(Oje(a,b))throw Adb(new agb(UHe+oVd(a)));d=null;!!a.Cb&&(d=(c=a.Db>>16,c>=0?iVd(a,d):a.Cb.Th(a,-1-c,null,d)));!!b&&(d=RD(b,54).Rh(a,0,p7,d));d=hVd(a,b,d);!!d&&d.oj();}else (a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,3,b,b));} + function Mjb(a,b){Ljb();var c,d,e,f,g,h,i,j,k;if(b.d>a.d){h=a;a=b;b=h;}if(b.d<63){return Qjb(a,b)}g=(a.d&-2)<<4;j=$ib(a,g);k=$ib(b,g);d=Gjb(a,Zib(j,g));e=Gjb(b,Zib(k,g));i=Mjb(j,k);c=Mjb(d,e);f=Mjb(Gjb(j,d),Gjb(e,k));f=Bjb(Bjb(f,i),c);f=Zib(f,g);i=Zib(i,g<<1);return Bjb(Bjb(i,f),c)} + function _Cc(){_Cc=geb;ZCc=new bDc(lEe,0);WCc=new bDc('LONGEST_PATH',1);XCc=new bDc('LONGEST_PATH_SOURCE',2);TCc=new bDc('COFFMAN_GRAHAM',3);VCc=new bDc(BBe,4);$Cc=new bDc('STRETCH_WIDTH',5);YCc=new bDc('MIN_WIDTH',6);SCc=new bDc('BF_MODEL_ORDER',7);UCc=new bDc('DF_MODEL_ORDER',8);} + function AKc(a,b,c){var d,e,f,g,h;g=aMc(a,c);h=$C(jR,WAe,10,b.length,0,1);d=0;for(f=g.Kc();f.Ob();){e=RD(f.Pb(),12);Heb(TD(mQb(e,(Ywc(),nwc))))&&(h[d++]=RD(mQb(e,Iwc),10));}if(d=0;f+=c?1:-1){g=g|b.c.lg(i,f,c,d&&!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,(Ywc(),Owc)))));g=g|b.q.ug(i,f,c);g=g|CKc(a,i[f],c,d);}Ysb(a.c,b);return g} + function F6b(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(k=u2b(a.j),l=0,m=k.length;l1&&(a.a=true);QQb(RD(c.b,68),$id(ajd(RD(b.b,68).c),ijd(ojd(ajd(RD(c.b,68).a),RD(b.b,68).a),e)));Odd(a,b);Qdd(a,c);}} + function tYb(a){var b,c,d,e,f,g,h;for(f=new Anb(a.a.a);f.a0&&f>0?(g.p=b++):d>0?(g.p=c++):f>0?(g.p=e++):(g.p=c++);}}yob();_mb(a.j,new Lfc);} + function zic(a){var b,c;c=null;b=RD(Vmb(a.g,0),18);do{c=b.d.i;if(nQb(c,(Ywc(),wwc))){return RD(mQb(c,wwc),12).i}if(c.k!=(r3b(),p3b)&&gs(new is(Mr(a3b(c).a.Kc(),new ir)))){b=RD(hs(new is(Mr(a3b(c).a.Kc(),new ir))),18);}else if(c.k!=p3b){return null}}while(!!c&&c.k!=(r3b(),p3b));return c} + function sqc(a,b){var c,d,e,f,g,h,i,j,k;h=b.j;g=b.g;i=RD(Vmb(h,h.c.length-1),113);k=(tFb(0,h.c.length),RD(h.c[0],113));j=oqc(a,g,i,k);for(f=1;fj){i=c;k=e;j=d;}}b.a=k;b.c=i;} + function fMc(a,b,c){var d,e,f,g,h,i,j;j=new yAb(new TMc(a));for(g=cD(WC(xR,1),XAe,12,0,[b,c]),h=0,i=g.length;hi-a.b&&hi-a.a&&h0){if(f.a){h=f.b.Mf().a;if(c>h){e=(c-h)/2;f.d.b=e;f.d.c=e;}}else {f.d.c=a.s+c;}}else if(Rod(a.u)){d=wsd(f.b);d.c<0&&(f.d.b=-d.c);d.c+d.b>f.b.Mf().a&&(f.d.c=d.c+d.b-f.b.Mf().a);}}} + function RUc(a,b){var c,d,e,f,g;g=new bnb;c=b;do{f=RD(Wjb(a.b,c),131);f.B=c.c;f.D=c.d;ZEb(g.c,f);c=RD(Wjb(a.k,c),18);}while(c);d=(tFb(0,g.c.length),RD(g.c[0],131));d.j=true;d.A=RD(d.d.a.ec().Kc().Pb(),18).c.i;e=RD(Vmb(g,g.c.length-1),131);e.q=true;e.C=RD(e.d.a.ec().Kc().Pb(),18).d.i;return g} + function pPb(a){var b,c;b=RD(a.a,17).a;c=RD(a.b,17).a;if(b>=0){if(b==c){return new Ptd(sgb(-b-1),sgb(-b-1))}if(b==-c){return new Ptd(sgb(-b),sgb(c+1))}}if($wnd.Math.abs(b)>$wnd.Math.abs(c)){if(b<0){return new Ptd(sgb(-b),sgb(c))}return new Ptd(sgb(-b),sgb(c+1))}return new Ptd(sgb(b+1),sgb(c))} + function H8b(a){var b,c;c=RD(mQb(a,(yCc(),UAc)),171);b=RD(mQb(a,(Ywc(),owc)),311);if(c==(cxc(),$wc)){pQb(a,UAc,bxc);pQb(a,owc,(Gvc(),Fvc));}else if(c==axc){pQb(a,UAc,bxc);pQb(a,owc,(Gvc(),Dvc));}else if(b==(Gvc(),Fvc)){pQb(a,UAc,$wc);pQb(a,owc,Evc);}else if(b==Dvc){pQb(a,UAc,axc);pQb(a,owc,Evc);}} + function dSc(){dSc=geb;bSc=new pSc;ZRc=pfd(new ufd,(sXb(),pXb),(hcc(),Fbc));aSc=nfd(pfd(new ufd,pXb,Tbc),rXb,Sbc);cSc=mfd(mfd(rfd(nfd(pfd(new ufd,nXb,bcc),rXb,acc),qXb),_bc),ccc);$Rc=nfd(pfd(pfd(pfd(new ufd,oXb,Ibc),qXb,Kbc),qXb,Lbc),rXb,Jbc);_Rc=nfd(pfd(pfd(new ufd,qXb,Lbc),qXb,qbc),rXb,pbc);} + function HUc(){HUc=geb;CUc=pfd(nfd(new ufd,(sXb(),rXb),(hcc(),tbc)),pXb,Fbc);GUc=mfd(mfd(rfd(nfd(pfd(new ufd,nXb,bcc),rXb,acc),qXb),_bc),ccc);DUc=nfd(pfd(pfd(pfd(new ufd,oXb,Ibc),qXb,Kbc),qXb,Lbc),rXb,Jbc);FUc=pfd(pfd(new ufd,pXb,Tbc),rXb,Sbc);EUc=nfd(pfd(pfd(new ufd,qXb,Lbc),qXb,qbc),rXb,pbc);} + function eSc(a,b,c,d,e){var f,g;if((!W0b(b)&&b.c.i.c==b.d.i.c||!djd(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])),c))&&!W0b(b)){b.c==e?hu(b.a,0,new sjd(c)):Mub(b.a,new sjd(c));if(d&&!Zsb(a.a,c)){g=RD(mQb(b,(yCc(),RAc)),75);if(!g){g=new Ejd;pQb(b,RAc,g);}f=new sjd(c);Pub(g,f,g.c.b,g.c);Ysb(a.a,f);}}} + function ht(a,b){var c,d,e,f;f=Ydb(Ndb(cwe,qgb(Ydb(Ndb(b==null?0:tb(b),dwe)),15)));c=f&a.b.length-1;e=null;for(d=a.b[c];d;e=d,d=d.a){if(d.d==f&&Hb(d.i,b)){!e?(a.b[c]=d.a):(e.a=d.a);Ts(RD(Hvb(d.c),604),RD(Hvb(d.f),604));Ss(RD(Hvb(d.b),227),RD(Hvb(d.e),227));--a.f;++a.e;return true}}return false} + function dec(a){var b,c;for(c=new is(Mr(Z2b(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),18);if(b.c.i.k!=(r3b(),n3b)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to FIRST, but has at least one incoming edge that "+' does not come from a FIRST_SEPARATE node. That must not happen.'))}}} + function Twd(a,b,c){var d,e,f,g,h,i,j;e=ggb(a.Db&254);if(e==0){a.Eb=c;}else {if(e==1){h=$C(jJ,rve,1,2,5,1);f=Xwd(a,b);if(f==0){h[0]=c;h[1]=a.Eb;}else {h[0]=a.Eb;h[1]=c;}}else {h=$C(jJ,rve,1,e+1,5,1);g=SD(a.Eb);for(d=2,i=0,j=0;d<=128;d<<=1){d==b?(h[j++]=c):(a.Db&d)!=0&&(h[j++]=g[i++]);}}a.Eb=h;}a.Db|=b;} + function vQb(a,b,c){var d,e,f,g;this.b=new bnb;e=0;d=0;for(g=new Anb(a);g.a0){f=RD(Vmb(this.b,0),176);e+=f.o;d+=f.p;}e*=2;d*=2;b>1?(e=eE($wnd.Math.ceil(e*b))):(d=eE($wnd.Math.ceil(d/b)));this.a=new gQb(e,d);} + function mkc(a,b,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r;k=d;if(b.j&&b.o){n=RD(Wjb(a.f,b.A),60);p=n.d.c+n.d.b;--k;}else {p=b.a.c+b.a.b;}l=e;if(c.q&&c.o){n=RD(Wjb(a.f,c.C),60);j=n.d.c;++l;}else {j=c.a.c;}q=j-p;i=$wnd.Math.max(2,l-k);h=q/i;o=p+h;for(m=k;m=0;g+=e?1:-1){h=b[g];i=d==(qpd(),Xod)?e?b3b(h,d):hv(b3b(h,d)):e?hv(b3b(h,d)):b3b(h,d);f&&(a.c[h.p]=i.gc());for(l=i.Kc();l.Ob();){k=RD(l.Pb(),12);a.d[k.p]=j++;}Tmb(c,i);}} + function AUc(a,b,c){var d,e,f,g,h,i,j,k;f=Kfb(UD(a.b.Kc().Pb()));j=Kfb(UD(fr(b.b)));d=ijd(ajd(a.a),j-c);e=ijd(ajd(b.a),c-f);k=$id(d,e);ijd(k,1/(j-f));this.a=k;this.b=new bnb;h=true;g=a.b.Kc();g.Pb();while(g.Ob()){i=Kfb(UD(g.Pb()));if(h&&i-c>AEe){this.b.Fc(c);h=false;}this.b.Fc(i);}h&&this.b.Fc(c);} + function mJb(a){var b,c,d,e;pJb(a,a.n);if(a.d.c.length>0){Nnb(a.c);while(xJb(a,RD(ynb(new Anb(a.e.a)),125))>5;b&=31;if(d>=a.d){return a.e<0?(Pib(),Jib):(Pib(),Oib)}f=a.d-d;e=$C(kE,Pwe,28,f+1,15,1);ujb(e,f,a.a,d,b);if(a.e<0){for(c=0;c0&&a.a[c]<<32-b!=0){for(c=0;c=0){return false}else {c=Eee((lke(),jke),e,b);if(!c){return true}else {d=c.Ik();return (d>1||d==-1)&&yfe(Qee(jke,c))!=3}}}}else {return false}} + function _4b(a,b,c,d){var e,f,g,h,i;h=AGd(RD(QHd((!b.b&&(b.b=new Yie(E4,b,4,7)),b.b),0),84));i=AGd(RD(QHd((!b.c&&(b.c=new Yie(E4,b,5,8)),b.c),0),84));if(vCd(h)==vCd(i)){return null}if(NGd(i,h)){return null}g=kzd(b);if(g==c){return d}else {f=RD(Wjb(a.a,g),10);if(f){e=f.e;if(e){return e}}}return null} + function uHc(a,b,c){var d,e,f,g,h;c.Ug('Longest path to source layering',1);a.a=b;h=a.a.a;a.b=$C(kE,Pwe,28,h.c.length,15,1);d=0;for(g=new Anb(h);g.a0){c[0]+=a.d;g-=c[0];}if(c[2]>0){c[2]+=a.d;g-=c[2];}f=$wnd.Math.max(0,g);c[1]=$wnd.Math.max(c[1],g);mKb(a,XJb,e.c+d.b+c[0]-(c[1]-g)/2,c);if(b==XJb){a.c.b=f;a.c.c=e.c+d.b+(f-g)/2;}} + function D_b(){this.c=$C(iE,vxe,28,(qpd(),cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd])).length,15,1);this.b=$C(iE,vxe,28,cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd]).length,15,1);this.a=$C(iE,vxe,28,cD(WC(E3,1),NAe,64,0,[opd,Yod,Xod,npd,ppd]).length,15,1);Lnb(this.c,oxe);Lnb(this.b,pxe);Lnb(this.a,pxe);} + function rte(a,b,c){var d,e,f,g;if(b<=c){e=b;f=c;}else {e=c;f=b;}d=0;if(a.b==null){a.b=$C(kE,Pwe,28,2,15,1);a.b[0]=e;a.b[1]=f;a.c=true;}else {d=a.b.length;if(a.b[d-1]+1==e){a.b[d-1]=f;return}g=$C(kE,Pwe,28,d+2,15,1);hib(a.b,0,g,0,d);a.b=g;a.b[d-1]>=e&&(a.c=false,a.a=false);a.b[d++]=e;a.b[d]=f;a.c||vte(a);}} + function Oqc(a,b,c){var d,e,f,g,h,i,j;j=b.d;a.a=new cnb(j.c.length);a.c=new Tsb;for(h=new Anb(j);h.a=0?a.Lh(j,false,true):Qvd(a,c,false),61));n:for(f=l.Kc();f.Ob();){e=RD(f.Pb(),58);for(k=0;k1){vLd(e,e.i-1);}}return d}} + function Vdc(a,b){var c,d,e,f,g,h,i;c=new wmb;for(f=new Anb(a.b);f.aa.d[g.p]){c+=ZLc(a.b,f);hmb(a.a,sgb(f));}}while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function Uec(a){var b,c,d,e,f,g,h,i,j;a.a=new e6b;j=0;e=0;for(d=new Anb(a.i.b);d.ah.d&&(k=h.d+h.a+j);}}c.c.d=k;b.a.zc(c,b);i=$wnd.Math.max(i,c.c.d+c.c.a);}return i} + function ovc(){ovc=geb;fvc=new pvc('COMMENTS',0);hvc=new pvc('EXTERNAL_PORTS',1);ivc=new pvc('HYPEREDGES',2);jvc=new pvc('HYPERNODES',3);kvc=new pvc('NON_FREE_PORTS',4);lvc=new pvc('NORTH_SOUTH_PORTS',5);nvc=new pvc(FBe,6);evc=new pvc('CENTER_LABELS',7);gvc=new pvc('END_LABELS',8);mvc=new pvc('PARTITIONS',9);} + function PA(a,b,c,d,e){if(d<0){d=EA(a,e,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe]),b);d<0&&(d=EA(a,e,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec']),b));if(d<0){return false}c.k=d;return true}else if(d>0){c.k=d-1;return true}return false} + function RA(a,b,c,d,e){if(d<0){d=EA(a,e,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe]),b);d<0&&(d=EA(a,e,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec']),b));if(d<0){return false}c.k=d;return true}else if(d>0){c.k=d-1;return true}return false} + function TA(a,b,c,d,e,f){var g,h,i,j;h=32;if(d<0){if(b[0]>=a.length){return false}h=ihb(a,b[0]);if(h!=43&&h!=45){return false}++b[0];d=HA(a,b);if(d<0){return false}h==45&&(d=-d);}if(h==32&&b[0]-c==2&&e.b==2){i=new uB;j=i.q.getFullYear()-Owe+Owe-80;g=j%100;f.a=d==g;d+=(j/100|0)*100+(d=0?jjb(a):Xib(jjb(Odb(a))));Kjb[b]=Jdb(Sdb(a,b),0)?jjb(Sdb(a,b)):Xib(jjb(Odb(Sdb(a,b))));a=Ndb(a,5);}for(;b=j&&(i=d);}!!i&&(k=$wnd.Math.max(k,i.a.o.a));if(k>m){l=j;m=k;}}return l} + function SNb(a){var b,c,d,e,f,g,h;f=new yAb(RD(Qb(new eOb),50));h=pxe;for(c=new Anb(a.d);c.aFFe?_mb(i,a.b):d<=FFe&&d>GFe?_mb(i,a.d):d<=GFe&&d>HFe?_mb(i,a.c):d<=HFe&&_mb(i,a.a);f=$5c(a,i,f);}return e} + function sTc(a,b,c,d){var e,f,g,h,i,j;e=(d.c+d.a)/2;Xub(b.j);Mub(b.j,e);Xub(c.e);Mub(c.e,e);j=new ATc;for(h=new Anb(a.f);h.a1;if(h){d=new rjd(e,c.b);Mub(b.a,d);}zjd(b.a,cD(WC(l3,1),Nve,8,0,[m,l]));} + function TGc(a,b,c){var d,e;if(b=48;c--){Eqe[c]=c-48<<24>>24;}for(d=70;d>=65;d--){Eqe[d]=d-65+10<<24>>24;}for(e=102;e>=97;e--){Eqe[e]=e-97+10<<24>>24;}for(f=0;f<10;f++)Fqe[f]=48+f&Bwe;for(a=10;a<=15;a++)Fqe[a]=65+a-10&Bwe;} + function yYc(a,b){b.Ug('Process graph bounds',1);pQb(a,(q$c(),ZZc),Uvb(TCb(HDb(new SDb(null,new Swb(a.b,16)),new DYc))));pQb(a,_Zc,Uvb(TCb(HDb(new SDb(null,new Swb(a.b,16)),new FYc))));pQb(a,YZc,Uvb(SCb(HDb(new SDb(null,new Swb(a.b,16)),new HYc))));pQb(a,$Zc,Uvb(SCb(HDb(new SDb(null,new Swb(a.b,16)),new JYc))));b.Vg();} + function PWb(a){var b,c,d,e,f;e=RD(mQb(a,(yCc(),lBc)),21);f=RD(mQb(a,oBc),21);c=new rjd(a.f.a+a.d.b+a.d.c,a.f.b+a.d.d+a.d.a);b=new sjd(c);if(e.Hc((Qpd(),Mpd))){d=RD(mQb(a,nBc),8);if(f.Hc((dqd(),Ypd))){d.a<=0&&(d.a=20);d.b<=0&&(d.b=20);}b.a=$wnd.Math.max(c.a,d.a);b.b=$wnd.Math.max(c.b,d.b);}Heb(TD(mQb(a,mBc)))||QWb(a,c,b);} + function lOc(a,b){var c,d,e,f;for(f=b3b(b,(qpd(),npd)).Kc();f.Ob();){d=RD(f.Pb(),12);c=RD(mQb(d,(Ywc(),Iwc)),10);!!c&&rIb(uIb(tIb(vIb(sIb(new wIb,0),0.1),a.i[b.p].d),a.i[c.p].a));}for(e=b3b(b,Yod).Kc();e.Ob();){d=RD(e.Pb(),12);c=RD(mQb(d,(Ywc(),Iwc)),10);!!c&&rIb(uIb(tIb(vIb(sIb(new wIb,0),0.1),a.i[c.p].d),a.i[b.p].a));}} + function oYd(a){var b,c,d,e,f,g;if(!a.c){g=new W$d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(tYd(a));d.e!=d.i.gc();){c=RD(bMd(d),89);e=i2d(c);ZD(e,90)&&YGd(g,oYd(RD(e,29)));WGd(g,c);}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}T$d(g);VHd(g);a.c=new N$d((RD(QHd(xYd((lTd(),kTd).o),15),19),g.i),g.g);yYd(a).b&=-33;}return a.c} + function Dre(a){var b;if(a.c!=10)throw Adb(new Lqe(TId((Hde(),VIe))));b=a.a;switch(b){case 110:b=10;break;case 114:b=13;break;case 116:b=9;break;case 92:case 124:case 46:case 94:case 45:case 63:case 42:case 43:case 123:case 125:case 40:case 41:case 91:case 93:break;default:throw Adb(new Lqe(TId((Hde(),xJe))));}return b} + function GD(a){var b,c,d,e,f;if(a.l==0&&a.m==0&&a.h==0){return '0'}if(a.h==fxe&&a.m==0&&a.l==0){return '-9223372036854775808'}if(a.h>>19!=0){return '-'+GD(xD(a))}c=a;d='';while(!(c.l==0&&c.m==0&&c.h==0)){e=fD(ixe);c=iD(c,e,true);b=''+FD(eD);if(!(c.l==0&&c.m==0&&c.h==0)){f=9-b.length;for(;f>0;f--){b='0'+b;}}d=b+d;}return d} + function tkc(a){var b,c,d,e,f,g,h;b=false;c=0;for(e=new Anb(a.d.b);e.a=a.a){return -1}if(!W9b(b,c)){return -1}if(gr(RD(d.Kb(b),20))){return 1}e=0;for(g=RD(d.Kb(b),20).Kc();g.Ob();){f=RD(g.Pb(),18);i=f.c.i==b?f.d.i:f.c.i;h=X9b(a,i,c,d);if(h==-1){return -1}e=$wnd.Math.max(e,h);if(e>a.c-1){return -1}}return e+1} + function _Gd(a,b){var c,d,e,f,g,h;if(dE(b)===dE(a)){return true}if(!ZD(b,15)){return false}d=RD(b,15);h=a.gc();if(d.gc()!=h){return false}g=d.Kc();if(a.Yi()){for(c=0;c0){a._j();if(b!=null){for(f=0;f>24}case 97:case 98:case 99:case 100:case 101:case 102:{return a-97+10<<24>>24}case 65:case 66:case 67:case 68:case 69:case 70:{return a-65+10<<24>>24}default:{throw Adb(new Vgb('Invalid hexadecimal'))}}} + function iIb(){iIb=geb;hIb=new jIb('SPIRAL',0);cIb=new jIb('LINE_BY_LINE',1);dIb=new jIb('MANHATTAN',2);bIb=new jIb('JITTER',3);fIb=new jIb('QUADRANTS_LINE_BY_LINE',4);gIb=new jIb('QUADRANTS_MANHATTAN',5);eIb=new jIb('QUADRANTS_JITTER',6);aIb=new jIb('COMBINE_LINE_BY_LINE_MANHATTAN',7);_Hb=new jIb('COMBINE_JITTER_MANHATTAN',8);} + function Urc(a,b,c,d){var e,f,g,h,i,j;i=Zrc(a,c);j=Zrc(b,c);e=false;while(!!i&&!!j){if(d||Xrc(i,j,c)){g=Zrc(i,c);h=Zrc(j,c);asc(b);asc(a);f=i.c;Hec(i,false);Hec(j,false);if(c){f3b(b,j.p,f);b.p=j.p;f3b(a,i.p+1,f);a.p=i.p;}else {f3b(a,i.p,f);a.p=i.p;f3b(b,j.p+1,f);b.p=j.p;}g3b(i,null);g3b(j,null);i=g;j=h;e=true;}else {break}}return e} + function aDc(a){switch(a.g){case 0:return new XHc;case 1:return new pHc;case 3:return new GGc;case 4:return new gHc;case 5:return new jIc;case 6:return new IHc;case 2:return new xHc;case 7:return new pGc;case 8:return new YGc;default:throw Adb(new agb('No implementation is available for the layerer '+(a.f!=null?a.f:''+a.g)));}} + function tIc(a,b,c,d){var e,f,g,h,i;e=false;f=false;for(h=new Anb(d.j);h.a=b.length){throw Adb(new veb('Greedy SwitchDecider: Free layer not in graph.'))}this.c=b[a];this.e=new DMc(d);rMc(this.e,this.c,(qpd(),ppd));this.i=new DMc(d);rMc(this.i,this.c,Xod);this.f=new Kmc(this.c);this.a=!f&&e.i&&!e.s&&this.c[0].k==(r3b(),m3b);this.a&&Nmc(this,a,b.length);} + function $Mb(a,b){var c,d,e,f,g,h;f=!a.B.Hc((dqd(),Wpd));g=a.B.Hc(Zpd);a.a=new wKb(g,f,a.c);!!a.n&&C2b(a.a.n,a.n);cLb(a.g,(ZJb(),XJb),a.a);if(!b){d=new dLb(1,f,a.c);d.n.a=a.k;Wrb(a.p,(qpd(),Yod),d);e=new dLb(1,f,a.c);e.n.d=a.k;Wrb(a.p,npd,e);h=new dLb(0,f,a.c);h.n.c=a.k;Wrb(a.p,ppd,h);c=new dLb(0,f,a.c);c.n.b=a.k;Wrb(a.p,Xod,c);}} + function zkc(a){var b,c,d;b=RD(mQb(a.d,(yCc(),yAc)),223);switch(b.g){case 2:c=rkc(a);break;case 3:c=(d=new bnb,FDb(CDb(GDb(EDb(EDb(new SDb(null,new Swb(a.d.b,16)),new wlc),new ylc),new Alc),new Kkc),new Clc(d)),d);break;default:throw Adb(new dgb('Compaction not supported for '+b+' edges.'));}ykc(a,c);xgb(new Xkb(a.g),new ilc(a));} + function qYc(a,b){var c,d,e,f,g,h,i;b.Ug('Process directions',1);c=RD(mQb(a,(h_c(),H$c)),88);if(c!=(Cmd(),xmd)){for(e=Sub(a.b,0);e.b!=e.d.c;){d=RD(evb(e),40);h=RD(mQb(d,(q$c(),o$c)),17).a;i=RD(mQb(d,p$c),17).a;switch(c.g){case 4:i*=-1;break;case 1:f=h;h=i;i=f;break;case 2:g=h;h=-i;i=g;}pQb(d,o$c,sgb(h));pQb(d,p$c,sgb(i));}}b.Vg();} + function led(a,b){var c;c=new qQb;!!b&&kQb(c,RD(Wjb(a.a,H4),96));ZD(b,422)&&kQb(c,RD(Wjb(a.a,L4),96));if(ZD(b,366)){kQb(c,RD(Wjb(a.a,I4),96));return c}ZD(b,84)&&kQb(c,RD(Wjb(a.a,E4),96));if(ZD(b,207)){kQb(c,RD(Wjb(a.a,J4),96));return c}if(ZD(b,193)){kQb(c,RD(Wjb(a.a,K4),96));return c}ZD(b,326)&&kQb(c,RD(Wjb(a.a,G4),96));return c} + function a_b(a){var b,c,d,e,f,g,h,i;i=new m_b;for(h=new Anb(a.a);h.a0&&b=0){return false}else {b.p=c.b;Rmb(c.e,b);}if(e==(r3b(),o3b)||e==q3b){for(g=new Anb(b.j);g.aa.d[h.p]){c+=ZLc(a.b,f);hmb(a.a,sgb(f));}}else {++g;}}c+=a.b.d*g;while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function pje(a){var b,c,d,e,f,g;f=0;b=WVd(a);!!b.kk()&&(f|=4);(a.Bb&bKe)!=0&&(f|=2);if(ZD(a,102)){c=RD(a,19);e=Z5d(c);(c.Bb&QHe)!=0&&(f|=32);if(e){AYd(uWd(e));f|=8;g=e.t;(g>1||g==-1)&&(f|=16);(e.Bb&QHe)!=0&&(f|=64);}(c.Bb&txe)!=0&&(f|=cKe);f|=gwe;}else {if(ZD(b,469)){f|=512;}else {d=b.kk();!!d&&(d.i&1)!=0&&(f|=256);}}(a.Bb&512)!=0&&(f|=128);return f} + function vke(a,b){var c;if(a.f==tke){c=yfe(Qee((lke(),jke),b));return a.e?c==4&&b!=(Lle(),Jle)&&b!=(Lle(),Gle)&&b!=(Lle(),Hle)&&b!=(Lle(),Ile):c==2}if(!!a.d&&(a.d.Hc(b)||a.d.Hc(zfe(Qee((lke(),jke),b)))||a.d.Hc(Eee((lke(),jke),a.b,b)))){return true}if(a.f){if(Xee((lke(),a.f),Bfe(Qee(jke,b)))){c=yfe(Qee(jke,b));return a.e?c==4:c==2}}return false} + function oKc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;m=-1;n=0;for(j=a,k=0,l=j.length;k0&&++n;}}}++m;}return n} + function S2c(a,b,c,d){var e,f,g,h,i,j,k,l;g=RD(Gxd(c,(umd(),Qld)),8);i=g.a;k=g.b+a;e=$wnd.Math.atan2(k,i);e<0&&(e+=dFe);e+=b;e>dFe&&(e-=dFe);h=RD(Gxd(d,Qld),8);j=h.a;l=h.b+a;f=$wnd.Math.atan2(l,j);f<0&&(f+=dFe);f+=b;f>dFe&&(f-=dFe);return Zy(),bz(1.0E-10),$wnd.Math.abs(e-f)<=1.0E-10||e==f||isNaN(e)&&isNaN(f)?0:ef?1:cz(isNaN(e),isNaN(f))} + function PGb(a){var b,c,d,e,f,g,h;h=new Tsb;for(d=new Anb(a.a.b);d.a=b.o){throw Adb(new web)}i=c>>5;h=c&31;g=Sdb(1,Ydb(Sdb(h,1)));f?(b.n[d][i]=Rdb(b.n[d][i],g)):(b.n[d][i]=Cdb(b.n[d][i],Qdb(g)));g=Sdb(g,1);e?(b.n[d][i]=Rdb(b.n[d][i],g)):(b.n[d][i]=Cdb(b.n[d][i],Qdb(g)));}catch(a){a=zdb(a);if(ZD(a,333)){throw Adb(new veb(fze+b.o+'*'+b.p+gze+c+pve+d+hze))}else throw Adb(a)}} + function eMc(a,b,c,d){var e,f,g,h,i,j,k,l,m;m=new yAb(new PMc(a));for(h=cD(WC(jR,1),WAe,10,0,[b,c]),i=0,j=h.length;i0){d=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!d||Zhb(Zhb((b.a+=' "',b),d),'"');}}else {Zhb(Zhb((b.a+=' "',b),c),'"');}Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function OCd(a){var b,c,d;if((a.Db&64)!=0)return Fyd(a);b=new dib(HHe);c=a.k;if(!c){!a.n&&(a.n=new C5d(I4,a,1,7));if(a.n.i>0){d=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!d||Zhb(Zhb((b.a+=' "',b),d),'"');}}else {Zhb(Zhb((b.a+=' "',b),c),'"');}Zhb(Uhb(Zhb(Uhb(Zhb(Uhb(Zhb(Uhb((b.a+=' (',b),a.i),','),a.j),' | '),a.g),','),a.f),')');return b.a} + function Xnc(a,b){var c,d,e,f,g;b==(TEc(),QEc)&&Eob(RD(Qc(a.a,(Bnc(),xnc)),15));for(e=RD(Qc(a.a,(Bnc(),xnc)),15).Kc();e.Ob();){d=RD(e.Pb(),105);c=RD(Vmb(d.j,0),113).d.j;f=new dnb(d.j);_mb(f,new Boc);switch(b.g){case 2:Pnc(a,f,c,(joc(),hoc),1);break;case 1:case 0:g=Rnc(f);Pnc(a,new Rkb(f,0,g),c,(joc(),hoc),0);Pnc(a,new Rkb(f,g,f.c.length),c,hoc,1);}}} + function sgd(a,b){var c,d,e,f,g,h,i;if(b==null||b.length==0){return null}e=RD(Xjb(a.a,b),143);if(!e){for(d=(h=(new glb(a.b)).a.vc().Kc(),new llb(h));d.a.Ob();){c=(f=RD(d.a.Pb(),44),RD(f.md(),143));g=c.c;i=b.length;if(lhb(g.substr(g.length-i,i),b)&&(b.length==g.length||ihb(g,g.length-b.length-1)==46)){if(e){return null}e=c;}}!!e&&$jb(a.a,b,e);}return e} + function HOb(a,b){var c,d,e,f;c=new MOb;d=RD(zDb(GDb(new SDb(null,new Swb(a.f,16)),c),sBb(new _Bb,new bCb,new yCb,new ACb,cD(WC(QL,1),jwe,108,0,[(xBb(),wBb),vBb]))),21);e=d.gc();d=RD(zDb(GDb(new SDb(null,new Swb(b.f,16)),c),sBb(new _Bb,new bCb,new yCb,new ACb,cD(WC(QL,1),jwe,108,0,[wBb,vBb]))),21);f=d.gc();if(ee.p){Q3b(f,npd);if(f.d){h=f.o.b;b=f.a.b;f.a.b=h-b;}}else if(f.j==npd&&e.p>a.p){Q3b(f,Yod);if(f.d){h=f.o.b;b=f.a.b;f.a.b=-(h-b);}}break}}return e} + function nTb(a,b,c,d,e){var f,g,h,i,j,k,l;if(!(ZD(b,207)||ZD(b,366)||ZD(b,193))){throw Adb(new agb('Method only works for ElkNode-, ElkLabel and ElkPort-objects.'))}g=a.a/2;i=b.i+d-g;k=b.j+e-g;j=i+b.g+a.a;l=k+b.f+a.a;f=new Ejd;Mub(f,new rjd(i,k));Mub(f,new rjd(i,l));Mub(f,new rjd(j,l));Mub(f,new rjd(j,k));h=new ORb(f);kQb(h,b);c&&Zjb(a.b,b,h);return h} + function w$b(a,b,c){var d,e,f,g,h,i,j,k,l,m;f=new rjd(b,c);for(k=new Anb(a.a);k.a1;if(h){d=new rjd(e,c.b);Mub(b.a,d);}zjd(b.a,cD(WC(l3,1),Nve,8,0,[m,l]));} + function aEc(){aEc=geb;$Dc=new bEc(LAe,0);VDc=new bEc('NIKOLOV',1);YDc=new bEc('NIKOLOV_PIXEL',2);WDc=new bEc('NIKOLOV_IMPROVED',3);XDc=new bEc('NIKOLOV_IMPROVED_PIXEL',4);SDc=new bEc('DUMMYNODE_PERCENTAGE',5);ZDc=new bEc('NODECOUNT_PERCENTAGE',6);_Dc=new bEc('NO_BOUNDARY',7);TDc=new bEc('MODEL_ORDER_LEFT_TO_RIGHT',8);UDc=new bEc('MODEL_ORDER_RIGHT_TO_LEFT',9);} + function use(a){var b,c,d,e,f;d=a.length;b=new Rhb;f=0;while(f=40;g&&wJb(a);nJb(a);mJb(a);c=qJb(a);d=0;while(!!c&&d0&&Mub(a.f,f);}else {a.c[g]-=j+1;a.c[g]<=0&&a.a[g]>0&&Mub(a.e,f);}}}}} + function FVc(a,b,c,d){var e,f,g,h,i,j,k;i=new rjd(c,d);ojd(i,RD(mQb(b,(q$c(),SZc)),8));for(k=Sub(b.b,0);k.b!=k.d.c;){j=RD(evb(k),40);$id(j.e,i);Mub(a.b,j);}for(h=RD(zDb(BDb(new SDb(null,new Swb(b.a,16))),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15).Kc();h.Ob();){g=RD(h.Pb(),65);for(f=Sub(g.a,0);f.b!=f.d.c;){e=RD(evb(f),8);e.a+=i.a;e.b+=i.b;}Mub(a.a,g);}} + function kWc(a,b){var c,d,e,f;if(0<(ZD(a,16)?RD(a,16).gc():Kr(a.Kc()))){e=b;if(1=0&&if*2){k=new zrd(l);j=urd(g)/trd(g);i=ird(k,b,new z3b,c,d,e,j);$id(hjd(k.e),i);l.c.length=0;f=0;ZEb(l.c,k);ZEb(l.c,g);f=urd(k)*trd(k)+urd(g)*trd(g);}else {ZEb(l.c,g);f+=urd(g)*trd(g);}}return l} + function O9b(a,b){var c,d,e,f,g,h;h=RD(mQb(b,(yCc(),BBc)),101);if(!(h==(Bod(),xod)||h==wod)){return}e=(new rjd(b.f.a+b.d.b+b.d.c,b.f.b+b.d.d+b.d.a)).b;for(g=new Anb(a.a);g.ac?b:c;j<=l;++j){if(j==c){h=d++;}else {f=e[j];k=o.am(f.Lk());j==b&&(i=j==l&&!k?d-1:d);k&&++d;}}m=RD(uLd(a,b,c),76);h!=i&&eZd(a,new c4d(a.e,7,g,sgb(h),n.md(),i));return m}}}else {return RD(SHd(a,b,c),76)}return RD(uLd(a,b,c),76)} + function ugc(a,b){var c,d,e,f,g,h,i;b.Ug('Port order processing',1);i=RD(mQb(a,(yCc(),HBc)),430);for(d=new Anb(a.b);d.a=0){h=rD(a,g);if(h){j<22?(i.l|=1<>>1;g.m=k>>>1|(l&1)<<21;g.l=m>>>1|(k&1)<<21;--j;}c&&nD(i);if(f){if(d){eD=xD(a);e&&(eD=DD(eD,(MD(),KD)));}else {eD=hD(a.l,a.m,a.h);}}return i} + function rIc(a,b){var c,d,e,f,g,h,i,j,k,l;j=a.e[b.c.p][b.p]+1;i=b.c.a.c.length+1;for(h=new Anb(a.a);h.a0&&(BFb(0,a.length),a.charCodeAt(0)==45||(BFb(0,a.length),a.charCodeAt(0)==43))?1:0;for(d=g;dc){throw Adb(new Vgb(nxe+a+'"'))}return h} + function Jqc(a){var b,c,d,e,f,g,h;g=new Yub;for(f=new Anb(a.a);f.a1)&&b==1&&RD(a.a[a.b],10).k==(r3b(),n3b)){Qdc(RD(a.a[a.b],10),(Pnd(),Lnd));}else if(d&&(!c||(a.c-a.b&a.a.length-1)>1)&&b==1&&RD(a.a[a.c-1&a.a.length-1],10).k==(r3b(),n3b)){Qdc(RD(a.a[a.c-1&a.a.length-1],10),(Pnd(),Mnd));}else if((a.c-a.b&a.a.length-1)==2){Qdc(RD(omb(a),10),(Pnd(),Lnd));Qdc(RD(omb(a),10),Mnd);}else {Ndc(a,e);}jmb(a);} + function QVc(a,b,c){var d,e,f,g,h;f=0;for(e=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));e.e!=e.i.gc();){d=RD(bMd(e),27);g='';(!d.n&&(d.n=new C5d(I4,d,1,7)),d.n).i==0||(g=RD(QHd((!d.n&&(d.n=new C5d(I4,d,1,7)),d.n),0),135).a);h=new bXc(f++,b,g);kQb(h,d);pQb(h,(q$c(),h$c),d);h.e.b=d.j+d.f/2;h.f.a=$wnd.Math.max(d.g,1);h.e.a=d.i+d.g/2;h.f.b=$wnd.Math.max(d.f,1);Mub(b.b,h);rtb(c.f,d,h);}} + function L5b(a){var b,c,d,e,f;d=RD(mQb(a,(Ywc(),Awc)),27);f=RD(Gxd(d,(yCc(),lBc)),181).Hc((Qpd(),Ppd));if(!a.e){e=RD(mQb(a,kwc),21);b=new rjd(a.f.a+a.d.b+a.d.c,a.f.b+a.d.d+a.d.a);if(e.Hc((ovc(),hvc))){Ixd(d,BBc,(Bod(),wod));Esd(d,b.a,b.b,false,true);}else {Heb(TD(Gxd(d,mBc)))||Esd(d,b.a,b.b,true,true);}}f?Ixd(d,lBc,xsb(Ppd)):Ixd(d,lBc,(c=RD(mfb(H3),9),new Fsb(c,RD(WEb(c,c.length),9),0)));} + function JA(a,b,c){var d,e,f,g;if(b[0]>=a.length){c.o=0;return true}switch(ihb(a,b[0])){case 43:e=1;break;case 45:e=-1;break;default:c.o=0;return true;}++b[0];f=b[0];g=HA(a,b);if(g==0&&b[0]==f){return false}if(b[0]h){h=e;k.c.length=0;}e==h&&Rmb(k,new Ptd(c.c.i,c));}yob();_mb(k,a.c);Qmb(a.b,i.p,k);}}} + function kRc(a,b){var c,d,e,f,g,h,i,j,k;for(g=new Anb(b.b);g.ah){h=e;k.c.length=0;}e==h&&Rmb(k,new Ptd(c.d.i,c));}yob();_mb(k,a.c);Qmb(a.f,i.p,k);}}} + function HVc(a,b){var c,d,e,f,g,h,i,j;j=TD(mQb(b,(h_c(),Z$c)));if(j==null||(uFb(j),j)){EVc(a,b);e=new bnb;for(i=Sub(b.b,0);i.b!=i.d.c;){g=RD(evb(i),40);c=DVc(a,g,null);if(c){kQb(c,b);ZEb(e.c,c);}}a.a=null;a.b=null;if(e.c.length>1){for(d=new Anb(e);d.a=0&&h!=c){f=new N3d(a,1,h,g,null);!d?(d=f):d.nj(f);}if(c>=0){f=new N3d(a,1,c,h==c?g:null,b);!d?(d=f):d.nj(f);}}return d} + function jSd(a){var b,c,d;if(a.b==null){d=new Qhb;if(a.i!=null){Nhb(d,a.i);d.a+=':';}if((a.f&256)!=0){if((a.f&256)!=0&&a.a!=null){wSd(a.i)||(d.a+='//',d);Nhb(d,a.a);}if(a.d!=null){d.a+='/';Nhb(d,a.d);}(a.f&16)!=0&&(d.a+='/',d);for(b=0,c=a.j.length;bm){return false}l=(i=S9c(d,m,false),i.a);if(k+h+l<=b.b){Q9c(c,f-c.s);c.c=true;Q9c(d,f-c.s);U9c(d,c.s,c.t+c.d+h);d.k=true;aad(c.q,d);n=true;if(e){Cad(b,d);d.j=b;if(a.c.length>g){Fad((tFb(g,a.c.length),RD(a.c[g],186)),d);(tFb(g,a.c.length),RD(a.c[g],186)).a.c.length==0&&Xmb(a,g);}}}return n} + function Qfc(a,b){var c,d,e,f,g,h;b.Ug('Partition midprocessing',1);e=new Tp;FDb(CDb(new SDb(null,new Swb(a.a,16)),new Ufc),new Wfc(e));if(e.d==0){return}h=RD(zDb(ODb((f=e.i,new SDb(null,(!f?(e.i=new zf(e,e.c)):f).Nc()))),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);d=h.Kc();c=RD(d.Pb(),17);while(d.Ob()){g=RD(d.Pb(),17);Pfc(RD(Qc(e,c),21),RD(Qc(e,g),21));c=g;}b.Vg();} + function G_b(a,b,c){var d,e,f,g,h,i,j,k;if(b.p==0){b.p=1;g=c;if(!g){e=new bnb;f=(d=RD(mfb(E3),9),new Fsb(d,RD(WEb(d,d.length),9),0));g=new Ptd(e,f);}RD(g.a,15).Fc(b);b.k==(r3b(),m3b)&&RD(g.b,21).Fc(RD(mQb(b,(Ywc(),hwc)),64));for(i=new Anb(b.j);i.a0){e=RD(a.Ab.g,2033);if(b==null){for(f=0;fc.s&&hg){return qpd(),Xod}break;case 4:case 3:if(k<0){return qpd(),Yod}else if(k+c>f){return qpd(),npd}}i=(j+h/2)/g;d=(k+c/2)/f;return i+d<=1&&i-d<=0?(qpd(),ppd):i+d>=1&&i-d>=0?(qpd(),Xod):d<0.5?(qpd(),Yod):(qpd(),npd)} + function PNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;c=false;k=Kfb(UD(mQb(b,(yCc(),bCc))));o=pwe*k;for(e=new Anb(b.b);e.ai+o){p=l.g+m.g;m.a=(m.g*m.a+l.g*l.a)/p;m.g=p;l.f=m;c=true;}}f=h;l=m;}}return c} + function MJb(a,b,c,d,e,f,g){var h,i,j,k,l,m;m=new Tid;for(j=b.Kc();j.Ob();){h=RD(j.Pb(),853);for(l=new Anb(h.Rf());l.a0){if(h.a){j=h.b.Mf().b;if(e>j){if(a.v||h.c.d.c.length==1){g=(e-j)/2;h.d.d=g;h.d.a=g;}else {c=RD(Vmb(h.c.d,0),187).Mf().b;d=(c-j)/2;h.d.d=$wnd.Math.max(0,d);h.d.a=e-d-j;}}}else {h.d.a=a.t+e;}}else if(Rod(a.u)){f=wsd(h.b);f.d<0&&(h.d.d=-f.d);f.d+f.a>h.b.Mf().b&&(h.d.a=f.d+f.a-h.b.Mf().b);}}} + function yVb(){yVb=geb;lVb=new mGd((umd(),Rld),sgb(1));rVb=new mGd(fmd,80);qVb=new mGd($ld,5);ZUb=new mGd(Dkd,Yze);mVb=new mGd(Sld,sgb(1));pVb=new mGd(Vld,(Geb(),true));iVb=new A3b(50);hVb=new mGd(tld,iVb);_Ub=ald;jVb=Hld;$Ub=new mGd(Pkd,false);gVb=sld;eVb=mld;fVb=pld;dVb=kld;cVb=ild;kVb=Lld;bVb=(OUb(),HUb);sVb=MUb;aVb=GUb;nVb=JUb;oVb=LUb;vVb=mmd;xVb=qmd;uVb=lmd;tVb=kmd;wVb=(mqd(),jqd);new mGd(nmd,wVb);} + function VC(a,b){var c;switch(XC(a)){case 6:return bE(b);case 7:return _D(b);case 8:return $D(b);case 3:return Array.isArray(b)&&(c=XC(b),!(c>=14&&c<=16));case 11:return b!=null&&typeof b===kve;case 12:return b!=null&&(typeof b===gve||typeof b==kve);case 0:return QD(b,a.__elementTypeId$);case 2:return cE(b)&&!(b.Tm===keb);case 1:return cE(b)&&!(b.Tm===keb)||QD(b,a.__elementTypeId$);default:return true;}} + function gNb(a){var b,c,d,e;d=a.o;RMb();if(a.A.dc()||pb(a.A,QMb)){e=d.a;}else {a.D?(e=$wnd.Math.max(d.a,ZKb(a.f))):(e=ZKb(a.f));if(a.A.Hc((Qpd(),Npd))&&!a.B.Hc((dqd(),_pd))){e=$wnd.Math.max(e,ZKb(RD(Vrb(a.p,(qpd(),Yod)),252)));e=$wnd.Math.max(e,ZKb(RD(Vrb(a.p,npd),252)));}b=TMb(a);!!b&&(e=$wnd.Math.max(e,b.a));}Heb(TD(a.e.Tf().of((umd(),mld))))?(d.a=$wnd.Math.max(d.a,e)):(d.a=e);c=a.f.i;c.c=0;c.b=e;$Kb(a.f);} + function oRb(a,b){var c,d,e,f;d=$wnd.Math.min($wnd.Math.abs(a.c-(b.c+b.b)),$wnd.Math.abs(a.c+a.b-b.c));f=$wnd.Math.min($wnd.Math.abs(a.d-(b.d+b.a)),$wnd.Math.abs(a.d+a.a-b.d));c=$wnd.Math.abs(a.c+a.b/2-(b.c+b.b/2));if(c>a.b/2+b.b/2){return 1}e=$wnd.Math.abs(a.d+a.a/2-(b.d+b.a/2));if(e>a.a/2+b.a/2){return 1}if(c==0&&e==0){return 0}if(c==0){return f/e+1}if(e==0){return d/c+1}return $wnd.Math.min(d/c,f/e)+1} + function oWb(a,b){var c,d,e,f,g,h,i;f=0;h=0;i=0;for(e=new Anb(a.f.e);e.a0&&a.d!=(AWb(),zWb)&&(h+=g*(d.d.a+a.a[b.a][d.a]*(b.d.a-d.d.a)/c));c>0&&a.d!=(AWb(),xWb)&&(i+=g*(d.d.b+a.a[b.a][d.a]*(b.d.b-d.d.b)/c));}switch(a.d.g){case 1:return new rjd(h/f,b.d.b);case 2:return new rjd(b.d.a,i/f);default:return new rjd(h/f,i/f);}} + function xsd(a){var b,c,d,e,f,g;c=(!a.a&&(a.a=new XZd(D4,a,5)),a.a).i+2;g=new cnb(c);Rmb(g,new rjd(a.j,a.k));FDb(new SDb(null,(!a.a&&(a.a=new XZd(D4,a,5)),new Swb(a.a,16))),new Usd(g));Rmb(g,new rjd(a.b,a.c));b=1;while(b0){aHb(i,false,(Cmd(),ymd));aHb(i,true,zmd);}Umb(b.g,new Elc(a,c));Zjb(a.g,b,c);} + function Ugb(){Ugb=geb;var a;Qgb=cD(WC(kE,1),Pwe,28,15,[-1,-1,30,19,15,13,11,11,10,9,9,8,8,8,8,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5]);Rgb=$C(kE,Pwe,28,37,15,1);Sgb=cD(WC(kE,1),Pwe,28,15,[-1,-1,63,40,32,28,25,23,21,20,19,19,18,18,17,17,16,16,16,15,15,15,15,14,14,14,14,14,14,13,13,13,13,13,13,13,13]);Tgb=$C(lE,rxe,28,37,14,1);for(a=2;a<=36;a++){Rgb[a]=eE($wnd.Math.pow(a,Qgb[a]));Tgb[a]=Fdb(Sve,Rgb[a]);}} + function tsd(a){var b;if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i!=1){throw Adb(new agb(tHe+(!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i))}b=new Ejd;!!BGd(RD(QHd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b),0),84))&&ye(b,usd(a,BGd(RD(QHd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b),0),84)),false));!!BGd(RD(QHd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c),0),84))&&ye(b,usd(a,BGd(RD(QHd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c),0),84)),true));return b} + function zRc(a,b){var c,d,e,f,g;b.d?(e=a.a.c==(wQc(),vQc)?Z2b(b.b):a3b(b.b)):(e=a.a.c==(wQc(),uQc)?Z2b(b.b):a3b(b.b));f=false;for(d=new is(Mr(e.a.Kc(),new ir));gs(d);){c=RD(hs(d),18);g=Heb(a.a.f[a.a.g[b.b.p].p]);if(!g&&!W0b(c)&&c.c.i.c==c.d.i.c){continue}if(Heb(a.a.n[a.a.g[b.b.p].p])||Heb(a.a.n[a.a.g[b.b.p].p])){continue}f=true;if(Zsb(a.b,a.a.g[rRc(c,b.b).p])){b.c=true;b.a=c;return b}}b.c=f;b.a=null;return b} + function QJd(a,b,c){var d,e,f,g,h,i,j;d=c.gc();if(d==0){return false}else {if(a.Pj()){i=a.Qj();ZId(a,b,c);g=d==1?a.Ij(3,null,c.Kc().Pb(),b,i):a.Ij(5,null,c,b,i);if(a.Mj()){h=d<100?null:new gLd(d);f=b+d;for(e=b;e0){for(g=0;g>16==-15&&a.Cb.Yh()&&pKd(new O3d(a.Cb,9,13,c,a.c,fZd(o4d(RD(a.Cb,62)),a)));}else if(ZD(a.Cb,90)){if(a.Db>>16==-23&&a.Cb.Yh()){b=a.c;ZD(b,90)||(b=(JTd(),zTd));ZD(c,90)||(c=(JTd(),zTd));pKd(new O3d(a.Cb,9,10,c,b,fZd(tYd(RD(a.Cb,29)),a)));}}}}return a.c} + function lac(a,b,c){var d,e,f,g,h,i,j,k,l;c.Ug('Hyperedge merging',1);jac(a,b);i=new Jkb(b.b,0);while(i.b0;h=oIb(b,f);c?FIb(h.b,b):FIb(h.g,b);CIb(h).c.length==1&&(Pub(d,h,d.c.b,d.c),true);e=new Ptd(f,b);hmb(a.o,e);Ymb(a.e.a,f);}} + function SQb(a,b){var c,d,e,f,g,h,i;d=$wnd.Math.abs(Oid(a.b).a-Oid(b.b).a);h=$wnd.Math.abs(Oid(a.b).b-Oid(b.b).b);e=0;i=0;c=1;g=1;if(d>a.b.b/2+b.b.b/2){e=$wnd.Math.min($wnd.Math.abs(a.b.c-(b.b.c+b.b.b)),$wnd.Math.abs(a.b.c+a.b.b-b.b.c));c=1-e/d;}if(h>a.b.a/2+b.b.a/2){i=$wnd.Math.min($wnd.Math.abs(a.b.d-(b.b.d+b.b.a)),$wnd.Math.abs(a.b.d+a.b.a-b.b.d));g=1-i/h;}f=$wnd.Math.min(c,g);return (1-f)*$wnd.Math.sqrt(d*d+h*h)} + function LUc(a){var b,c,d,e;NUc(a,a.e,a.f,(dVc(),bVc),true,a.c,a.i);NUc(a,a.e,a.f,bVc,false,a.c,a.i);NUc(a,a.e,a.f,cVc,true,a.c,a.i);NUc(a,a.e,a.f,cVc,false,a.c,a.i);MUc(a,a.c,a.e,a.f,a.i);d=new Jkb(a.i,0);while(d.b=65;c--){xqe[c]=c-65<<24>>24;}for(d=122;d>=97;d--){xqe[d]=d-97+26<<24>>24;}for(e=57;e>=48;e--){xqe[e]=e-48+52<<24>>24;}xqe[43]=62;xqe[47]=63;for(f=0;f<=25;f++)yqe[f]=65+f&Bwe;for(g=26,i=0;g<=51;++g,i++)yqe[g]=97+i&Bwe;for(a=52,h=0;a<=61;++a,h++)yqe[a]=48+h&Bwe;yqe[62]=43;yqe[63]=47;} + function uib(a,b){var c,d,e,f,g,h;e=xib(a);h=xib(b);if(e==h){if(a.e==b.e&&a.a<54&&b.a<54){return a.fb.f?1:0}d=a.e-b.e;c=(a.d>0?a.d:$wnd.Math.floor((a.a-1)*xxe)+1)-(b.d>0?b.d:$wnd.Math.floor((b.a-1)*xxe)+1);if(c>d+1){return e}else if(c0&&(g=Wib(g,Sjb(d)));return Qib(f,g)}}else return ej){m=0;n+=i+b;i=0;}w$b(g,m,n);c=$wnd.Math.max(c,m+k.a);i=$wnd.Math.max(i,k.b);m+=k.a+b;}return new rjd(c+b,n+i+b)} + function osd(a,b){var c,d,e,f,g,h,i;if(!MCd(a)){throw Adb(new dgb(sHe))}d=MCd(a);f=d.g;e=d.f;if(f<=0&&e<=0){return qpd(),opd}h=a.i;i=a.j;switch(b.g){case 2:case 1:if(h<0){return qpd(),ppd}else if(h+a.g>f){return qpd(),Xod}break;case 4:case 3:if(i<0){return qpd(),Yod}else if(i+a.f>e){return qpd(),npd}}g=(h+a.g/2)/f;c=(i+a.f/2)/e;return g+c<=1&&g-c<=0?(qpd(),ppd):g+c>=1&&g-c>=0?(qpd(),Xod):c<0.5?(qpd(),Yod):(qpd(),npd)} + function Djb(a,b,c,d,e){var f,g;f=Bdb(Cdb(b[0],yxe),Cdb(d[0],yxe));a[0]=Ydb(f);f=Tdb(f,32);if(c>=e){for(g=1;g0){e.b[g++]=0;e.b[g++]=f.b[0]-1;}for(b=1;b0){PSc(i,i.d-e.d);e.c==(fTc(),dTc)&&NSc(i,i.a-e.d);i.d<=0&&i.i>0&&(Pub(b,i,b.c.b,b.c),true);}}}for(f=new Anb(a.f);f.a0){QSc(h,h.i-e.d);e.c==(fTc(),dTc)&&OSc(h,h.b-e.d);h.i<=0&&h.d>0&&(Pub(c,h,c.c.b,c.c),true);}}}} + function drd(a,b,c,d,e){var f,g,h,i,j,k,l,m,n;yob();_mb(a,new Mrd);g=gv(a);n=new bnb;m=new bnb;h=null;i=0;while(g.b!=0){f=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),163);if(!h||urd(h)*trd(h)/21&&(i>urd(h)*trd(h)/2||g.b==0)){l=new zrd(m);k=urd(h)/trd(h);j=ird(l,b,new z3b,c,d,e,k);$id(hjd(l.e),j);h=l;ZEb(n.c,l);i=0;m.c.length=0;}}}Tmb(n,m);return n} + function hib(a,b,c,d,e){gib();var f,g,h,i,j,k,l;vFb(a,'src');vFb(c,'dest');l=rb(a);i=rb(c);qFb((l.i&4)!=0,'srcType is not an array');qFb((i.i&4)!=0,'destType is not an array');k=l.c;g=i.c;qFb((k.i&1)!=0?k==g:(g.i&1)==0,"Array types don't match");iib(a,b,c,d,e);if((k.i&1)==0&&l!=i){j=SD(a);f=SD(c);if(dE(a)===dE(c)&&bd;){bD(f,h,j[--b]);}}else {for(h=d+e;d0);d.a.Xb(d.c=--d.b);l>m+i&&Ckb(d);}for(g=new Anb(n);g.a0);d.a.Xb(d.c=--d.b);}}}} + function gte(){Vse();var a,b,c,d,e,f;if(Fse)return Fse;a=(new xte(4));ute(a,hte(WLe,true));wte(a,hte('M',true));wte(a,hte('C',true));f=(new xte(4));for(d=0;d<11;d++){rte(f,d,d);}b=(new xte(4));ute(b,hte('M',true));rte(b,4448,4607);rte(b,65438,65439);e=(new iue(2));hue(e,a);hue(e,Ese);c=(new iue(2));c.Jm($se(f,hte('L',true)));c.Jm(b);c=(new Kte(3,c));c=(new Qte(e,c));Fse=c;return Fse} + function vhb(a,b){var c,d,e,f,g,h,i,j;c=new RegExp(b,'g');i=$C(qJ,Nve,2,0,6,1);d=0;j=a;f=null;while(true){h=c.exec(j);if(h==null||j==''){i[d]=j;break}else {g=h.index;i[d]=(AFb(0,g,j.length),j.substr(0,g));j=zhb(j,g+h[0].length,j.length);c.lastIndex=0;if(f==j){i[d]=(AFb(0,1,j.length),j.substr(0,1));j=(BFb(1,j.length+1),j.substr(1));}f=j;++d;}}if(a.length>0){e=i.length;while(e>0&&i[e-1]==''){--e;}e0){l-=d[0]+a.c;d[0]+=a.c;}d[2]>0&&(l-=d[2]+a.c);d[1]=$wnd.Math.max(d[1],l);dKb(a.a[1],c.c+b.b+d[0]-(d[1]-l)/2,d[1]);}for(f=a.a,h=0,j=f.length;h0?(a.n.c.length-1)*a.i:0;for(d=new Anb(a.n);d.a1){for(d=Sub(e,0);d.b!=d.d.c;){c=RD(evb(d),235);f=0;for(i=new Anb(c.e);i.a0){b[0]+=a.c;l-=b[0];}b[2]>0&&(l-=b[2]+a.c);b[1]=$wnd.Math.max(b[1],l);eKb(a.a[1],d.d+c.d+b[0]-(b[1]-l)/2,b[1]);}else {o=d.d+c.d;n=d.a-c.d-c.a;for(g=a.a,i=0,k=g.length;i0||$y(e.b.d,a.b.d+a.b.a)==0&&d.b<0||$y(e.b.d+e.b.a,a.b.d)==0&&d.b>0){h=0;break}}else {h=$wnd.Math.min(h,PQb(a,e,d));}h=$wnd.Math.min(h,FQb(a,f,h,d));}return h} + function lsd(a,b){var c,d,e,f,g,h,i;if(a.b<2){throw Adb(new agb('The vector chain must contain at least a source and a target point.'))}e=(sFb(a.b!=0),RD(a.a.a.c,8));Nzd(b,e.a,e.b);i=new mMd((!b.a&&(b.a=new XZd(D4,b,5)),b.a));g=Sub(a,1);while(g.a=0&&f!=c){throw Adb(new agb(LIe))}}e=0;for(i=0;iKfb(pJc(g.g,g.d[0]).a)){sFb(i.b>0);i.a.Xb(i.c=--i.b);Ikb(i,g);e=true;}else if(!!h.e&&h.e.gc()>0){f=(!h.e&&(h.e=new bnb),h.e).Mc(b);j=(!h.e&&(h.e=new bnb),h.e).Mc(c);if(f||j){(!h.e&&(h.e=new bnb),h.e).Fc(g);++g.c;}}}e||(ZEb(d.c,g),true);} + function H3c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;l=a.a.i+a.a.g/2;m=a.a.i+a.a.g/2;o=b.i+b.g/2;q=b.j+b.f/2;h=new rjd(o,q);j=RD(Gxd(b,(umd(),Qld)),8);j.a=j.a+l;j.b=j.b+m;f=(h.b-j.b)/(h.a-j.a);d=h.b-f*h.a;p=c.i+c.g/2;r=c.j+c.f/2;i=new rjd(p,r);k=RD(Gxd(c,Qld),8);k.a=k.a+l;k.b=k.b+m;g=(i.b-k.b)/(i.a-k.a);e=i.b-g*i.a;n=(d-e)/(g-f);if(j.a>>0,'0'+b.toString(16));d='\\x'+zhb(c,c.length-2,c.length);}else if(a>=txe){c=(b=a>>>0,'0'+b.toString(16));d='\\v'+zhb(c,c.length-6,c.length);}else d=''+String.fromCharCode(a&Bwe);}return d} + function Ugc(a){var b,c,d;if(Dod(RD(mQb(a,(yCc(),BBc)),101))){for(c=new Anb(a.j);c.a=b.o&&c.f<=b.f||b.a*0.5<=c.f&&b.a*1.5>=c.f){g=RD(Vmb(b.n,b.n.c.length-1),209);if(g.e+g.d+c.g+e<=d&&(f=RD(Vmb(b.n,b.n.c.length-1),209),f.f-a.f+c.f<=a.b||a.a.c.length==1)){K9c(b,c);return true}else if(b.s+c.g<=d&&(b.t+b.d+c.f+e<=a.b||a.a.c.length==1)){Rmb(b.b,c);h=RD(Vmb(b.n,b.n.c.length-1),209);Rmb(b.n,new _9c(b.s,h.f+h.a+b.i,b.i));W9c(RD(Vmb(b.n,b.n.c.length-1),209),c);M9c(b,c);return true}}return false} + function xLd(a,b,c){var d,e,f,g;if(a.Pj()){e=null;f=a.Qj();d=a.Ij(1,g=UHd(a,b,c),c,b,f);if(a.Mj()&&!(a.Yi()&&g!=null?pb(g,c):dE(g)===dE(c))){g!=null&&(e=a.Oj(g,e));e=a.Nj(c,e);a.Tj()&&(e=a.Wj(g,c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}else {a.Tj()&&(e=a.Wj(g,c,e));if(!e){a.Jj(d);}else {e.nj(d);e.oj();}}return g}else {g=UHd(a,b,c);if(a.Mj()&&!(a.Yi()&&g!=null?pb(g,c):dE(g)===dE(c))){e=null;g!=null&&(e=a.Oj(g,null));e=a.Nj(c,e);!!e&&e.oj();}return g}} + function Rsc(a,b){var c,d,e,f,g;b.Ug('Path-Like Graph Wrapping',1);if(a.b.c.length==0){b.Vg();return}e=new ysc(a);g=(e.i==null&&(e.i=tsc(e,new Asc)),Kfb(e.i)*e.f);c=g/(e.i==null&&(e.i=tsc(e,new Asc)),Kfb(e.i));if(e.b>c){b.Vg();return}switch(RD(mQb(a,(yCc(),rCc)),351).g){case 2:f=new Ksc;break;case 0:f=new zrc;break;default:f=new Nsc;}d=f.og(a,e);if(!f.pg()){switch(RD(mQb(a,xCc),352).g){case 2:d=Wsc(e,d);break;case 1:d=Usc(e,d);}}Qsc(a,e,d);b.Vg();} + function mB(a,b){var c,d,e,f,g,h,i,j;b%=24;if(a.q.getHours()!=b){d=new $wnd.Date(a.q.getTime());d.setDate(d.getDate()+1);h=a.q.getTimezoneOffset()-d.getTimezoneOffset();if(h>0){i=h/60|0;j=h%60;e=a.q.getDate();c=a.q.getHours();c+i>=24&&++e;f=new $wnd.Date(a.q.getFullYear(),a.q.getMonth(),e,b+i,a.q.getMinutes()+j,a.q.getSeconds(),a.q.getMilliseconds());a.q.setTime(f.getTime());}}g=a.q.getTime();a.q.setTime(g+3600000);a.q.getHours()!=b&&a.q.setTime(g);} + function kKc(a,b){var c,d,e,f;Nwb(a.d,a.e);a.c.a.$b();if(Kfb(UD(mQb(b.j,(yCc(),Zzc))))!=0||Kfb(UD(mQb(b.j,Zzc)))!=0){c=Hze;dE(mQb(b.j,cAc))!==dE((kEc(),hEc))&&pQb(b.j,(Ywc(),jwc),(Geb(),true));f=RD(mQb(b.j,gCc),17).a;for(e=0;ee&&++j;Rmb(g,(tFb(h+j,b.c.length),RD(b.c[h+j],17)));i+=(tFb(h+j,b.c.length),RD(b.c[h+j],17)).a-d;++c;while(c=q&&a.e[i.p]>o*a.b||t>=c*q){ZEb(m.c,h);h=new bnb;ye(g,f);f.a.$b();j-=k;n=$wnd.Math.max(n,j*a.b+p);j+=t;s=t;t=0;k=0;p=0;}}return new Ptd(n,m)} + function pYd(a){var b,c,d,e,f,g,h;if(!a.d){h=new v_d;b=iYd;f=b.a.zc(a,b);if(f==null){for(d=new dMd(zYd(a));d.e!=d.i.gc();){c=RD(bMd(d),29);YGd(h,pYd(c));}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}g=h.i;for(e=(!a.q&&(a.q=new C5d(s7,a,11,10)),new dMd(a.q));e.e!=e.i.gc();++g){RD(bMd(e),411);}YGd(h,(!a.q&&(a.q=new C5d(s7,a,11,10)),a.q));VHd(h);a.d=new N$d((RD(QHd(xYd((lTd(),kTd).o),9),19),h.i),h.g);a.e=RD(h.g,688);a.e==null&&(a.e=jYd);yYd(a).b&=-17;}return a.d} + function kge(a,b,c,d){var e,f,g,h,i,j;j=pke(a.e.Dh(),b);i=0;e=RD(a.g,124);nke();if(RD(b,69).xk()){for(g=0;g1||o==-1){l=RD(p,71);m=RD(k,71);if(l.dc()){m.$b();}else {g=!!Z5d(b);f=0;for(h=a.a?l.Kc():l.Ii();h.Ob();){j=RD(h.Pb(),58);e=RD(cub(a,j),58);if(!e){if(a.b&&!g){m.Gi(f,j);++f;}}else {if(g){i=m.dd(e);i==-1?m.Gi(f,e):f!=i&&m.Ui(f,e);}else {m.Gi(f,e);}++f;}}}}else {if(p==null){k.Wb(null);}else {e=cub(a,p);e==null?a.b&&!Z5d(b)&&k.Wb(p):k.Wb(e);}}}}} + function V9b(a,b){var c,d,e,f,g,h,i,j;c=new aac;for(e=new is(Mr(Z2b(b).a.Kc(),new ir));gs(e);){d=RD(hs(e),18);if(W0b(d)){continue}h=d.c.i;if(W9b(h,T9b)){j=X9b(a,h,T9b,S9b);if(j==-1){continue}c.b=$wnd.Math.max(c.b,j);!c.a&&(c.a=new bnb);Rmb(c.a,h);}}for(g=new is(Mr(a3b(b).a.Kc(),new ir));gs(g);){f=RD(hs(g),18);if(W0b(f)){continue}i=f.d.i;if(W9b(i,S9b)){j=X9b(a,i,S9b,T9b);if(j==-1){continue}c.d=$wnd.Math.max(c.d,j);!c.c&&(c.c=new bnb);Rmb(c.c,i);}}return c} + function pcc(a,b,c,d){var e,f,g,h,i,j,k;if(c.d.i==b.i){return}e=new j3b(a);h3b(e,(r3b(),o3b));pQb(e,(Ywc(),Awc),c);pQb(e,(yCc(),BBc),(Bod(),wod));ZEb(d.c,e);g=new R3b;P3b(g,e);Q3b(g,(qpd(),ppd));h=new R3b;P3b(h,e);Q3b(h,Xod);k=c.d;Z0b(c,g);f=new a1b;kQb(f,c);pQb(f,RAc,null);Y0b(f,h);Z0b(f,k);j=new Jkb(c.b,0);while(j.b1000000){throw Adb(new teb('power of ten too big'))}if(a<=lve){return Zib(Yib(Jjb[1],b),b)}d=Yib(Jjb[1],lve);e=d;c=Hdb(a-lve);b=eE(a%lve);while(Ddb(c,lve)>0){e=Wib(e,d);c=Vdb(c,lve);}e=Wib(e,Yib(Jjb[1],b));e=Zib(e,lve);c=Hdb(a-lve);while(Ddb(c,lve)>0){e=Zib(e,lve);c=Vdb(c,lve);}e=Zib(e,b);return e} + function s9b(a){var b,c,d,e,f,g,h,i,j,k;for(i=new Anb(a.a);i.aj&&d>j){k=h;j=Kfb(b.p[h.p])+Kfb(b.d[h.p])+h.o.b+h.d.a;}else {e=false;c._g()&&c.bh('bk node placement breaks on '+h+' which should have been after '+k);break}}if(!e){break}}c._g()&&c.bh(b+' is feasible: '+e);return e} + function Dfc(a,b,c,d){var e,f,g,h,i,j,k,l,m;f=new j3b(a);h3b(f,(r3b(),q3b));pQb(f,(yCc(),BBc),(Bod(),wod));e=0;if(b){g=new R3b;pQb(g,(Ywc(),Awc),b);pQb(f,Awc,b.i);Q3b(g,(qpd(),ppd));P3b(g,f);m=s2b(b.e);for(j=m,k=0,l=j.length;k0){if(e<0&&k.a){e=i;f=j[0];d=0;}if(e>=0){h=k.b;if(i==e){h-=d++;if(h==0){return 0}}if(!MA(b,j,k,h,g)){i=e-1;j[0]=f;continue}}else {e=-1;if(!MA(b,j,k,0,g)){return 0}}}else {e=-1;if(ihb(k.c,0)==32){l=j[0];KA(b,j);if(j[0]>l){continue}}else if(xhb(b,k.c,j[0])){j[0]+=k.c.length;continue}return 0}}if(!CB(g,c)){return 0}return j[0]} + function qWb(a,b,c){var d,e,f,g,h,i,j,k,l,m;k=new pwb(new GWb(c));h=$C(xdb,Hye,28,a.f.e.c.length,16,1);Snb(h,h.length);c[b.a]=0;for(j=new Anb(a.f.e);j.a=0&&!PPb(a,k,l)){--l;}e[k]=l;}for(n=0;n=0&&!PPb(a,h,o)){--h;}f[o]=h;}for(i=0;ib[m]&&md[i]&&TPb(a,i,m,false,true);}}} + function hUb(a){var b,c,d,e,f,g,h,i;c=Heb(TD(mQb(a,(yVb(),$Ub))));f=a.a.c.d;h=a.a.d.d;if(c){g=ijd(ojd(new rjd(h.a,h.b),f),0.5);i=ijd(ajd(a.e),0.5);b=ojd($id(new rjd(f.a,f.b),g),i);mjd(a.d,b);}else {e=Kfb(UD(mQb(a.a,qVb)));d=a.d;if(f.a>=h.a){if(f.b>=h.b){d.a=h.a+(f.a-h.a)/2+e;d.b=h.b+(f.b-h.b)/2-e-a.e.b;}else {d.a=h.a+(f.a-h.a)/2+e;d.b=f.b+(h.b-f.b)/2+e;}}else {if(f.b>=h.b){d.a=f.a+(h.a-f.a)/2+e;d.b=h.b+(f.b-h.b)/2+e;}else {d.a=f.a+(h.a-f.a)/2+e;d.b=f.b+(h.b-f.b)/2-e-a.e.b;}}}} + function qYd(a){var b,c,d,e,f,g,h,i;if(!a.f){i=new a_d;h=new a_d;b=iYd;g=b.a.zc(a,b);if(g==null){for(f=new dMd(zYd(a));f.e!=f.i.gc();){e=RD(bMd(f),29);YGd(i,qYd(e));}b.a.Bc(a)!=null;b.a.gc()==0&&undefined;}for(d=(!a.s&&(a.s=new C5d(y7,a,21,17)),new dMd(a.s));d.e!=d.i.gc();){c=RD(bMd(d),179);ZD(c,102)&&WGd(h,RD(c,19));}VHd(h);a.r=new s_d(a,(RD(QHd(xYd((lTd(),kTd).o),6),19),h.i),h.g);YGd(i,a.r);VHd(i);a.f=new N$d((RD(QHd(xYd(kTd.o),5),19),i.i),i.g);yYd(a).b&=-3;}return a.f} + function uSb(a){Cgd(a,new Pfd($fd(Xfd(Zfd(Yfd(new agd,Aze),'ELK DisCo'),'Layouter for arranging unconnected subgraphs. The subgraphs themselves are, by default, not laid out.'),new xSb)));Agd(a,Aze,Bze,iGd(sSb));Agd(a,Aze,Cze,iGd(mSb));Agd(a,Aze,Dze,iGd(hSb));Agd(a,Aze,Eze,iGd(nSb));Agd(a,Aze,Bye,iGd(qSb));Agd(a,Aze,Cye,iGd(pSb));Agd(a,Aze,Aye,iGd(rSb));Agd(a,Aze,Dye,iGd(oSb));Agd(a,Aze,vze,iGd(jSb));Agd(a,Aze,wze,iGd(iSb));Agd(a,Aze,xze,iGd(kSb));Agd(a,Aze,yze,iGd(lSb));} + function qAd(){qAd=geb;oAd=cD(WC(hE,1),zwe,28,15,[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70]);pAd=new RegExp('[ \t\n\r\f]+');try{nAd=cD(WC(h8,1),rve,2114,0,[new c2d((WA(),YA("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",_A(($A(),$A(),ZA))))),new c2d(YA("yyyy-MM-dd'T'HH:mm:ss'.'SSS",_A((null,ZA)))),new c2d(YA("yyyy-MM-dd'T'HH:mm:ss",_A((null,ZA)))),new c2d(YA("yyyy-MM-dd'T'HH:mm",_A((null,ZA)))),new c2d(YA('yyyy-MM-dd',_A((null,ZA))))]);}catch(a){a=zdb(a);if(!ZD(a,82))throw Adb(a)}} + function uKc(a,b){var c,d,e,f;e=Kwb(a.d,1)!=0;d=mKc(a,b);if(d==0&&Heb(TD(mQb(b.j,(Ywc(),jwc))))){return 0}!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,Owc)))||dE(mQb(b.j,(yCc(),cAc)))===dE((kEc(),hEc))?b.c.mg(b.e,e):(e=Heb(TD(mQb(b.j,jwc))));DKc(a,b,e,true);Heb(TD(mQb(b.j,Owc)))&&pQb(b.j,Owc,(Geb(),false));if(Heb(TD(mQb(b.j,jwc)))){pQb(b.j,jwc,(Geb(),false));pQb(b.j,Owc,true);}c=mKc(a,b);do{yKc(a);if(c==0){return 0}e=!e;f=c;DKc(a,b,e,false);c=mKc(a,b);}while(f>c);return f} + function vKc(a,b){var c,d,e,f;e=Kwb(a.d,1)!=0;d=lKc(a,b);if(d==0&&Heb(TD(mQb(b.j,(Ywc(),jwc))))){return 0}!Heb(TD(mQb(b.j,(Ywc(),jwc))))&&!Heb(TD(mQb(b.j,Owc)))||dE(mQb(b.j,(yCc(),cAc)))===dE((kEc(),hEc))?b.c.mg(b.e,e):(e=Heb(TD(mQb(b.j,jwc))));DKc(a,b,e,true);Heb(TD(mQb(b.j,Owc)))&&pQb(b.j,Owc,(Geb(),false));if(Heb(TD(mQb(b.j,jwc)))){pQb(b.j,jwc,(Geb(),false));pQb(b.j,Owc,true);}c=lKc(a,b);do{yKc(a);if(c==0){return 0}e=!e;f=c;DKc(a,b,e,false);c=lKc(a,b);}while(f>c);return f} + function Gid(a,b,c,d){var e,f,g,h,i,j,k,l,m;i=ojd(new rjd(c.a,c.b),a);j=i.a*b.b-i.b*b.a;k=b.a*d.b-b.b*d.a;l=(i.a*d.b-i.b*d.a)/k;m=j/k;if(k==0){if(j==0){e=$id(new rjd(c.a,c.b),ijd(new rjd(d.a,d.b),0.5));f=bjd(a,e);g=bjd($id(new rjd(a.a,a.b),b),e);h=$wnd.Math.sqrt(d.a*d.a+d.b*d.b)*0.5;if(f=0&&l<=1&&m>=0&&m<=1?$id(new rjd(a.a,a.b),ijd(new rjd(b.a,b.b),l)):null}} + function QWb(a,b,c){var d,e,f,g,h;d=RD(mQb(a,(yCc(),dAc)),21);c.a>b.a&&(d.Hc((ukd(),okd))?(a.c.a+=(c.a-b.a)/2):d.Hc(qkd)&&(a.c.a+=c.a-b.a));c.b>b.b&&(d.Hc((ukd(),skd))?(a.c.b+=(c.b-b.b)/2):d.Hc(rkd)&&(a.c.b+=c.b-b.b));if(RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),hvc))&&(c.a>b.a||c.b>b.b)){for(h=new Anb(a.a);h.ab.a&&(d.Hc((ukd(),okd))?(a.c.a+=(c.a-b.a)/2):d.Hc(qkd)&&(a.c.a+=c.a-b.a));c.b>b.b&&(d.Hc((ukd(),skd))?(a.c.b+=(c.b-b.b)/2):d.Hc(rkd)&&(a.c.b+=c.b-b.b));if(RD(mQb(a,(Ywc(),kwc)),21).Hc((ovc(),hvc))&&(c.a>b.a||c.b>b.b)){for(g=new Anb(a.a);g.a0?a.i:0)>b&&i>0){f=0;g+=i+a.i;e=$wnd.Math.max(e,m);d+=i+a.i;i=0;m=0;if(c){++l;Rmb(a.n,new _9c(a.s,g,a.i));}h=0;}m+=j.g+(h>0?a.i:0);i=$wnd.Math.max(i,j.f);c&&W9c(RD(Vmb(a.n,l),209),j);f+=j.g+(h>0?a.i:0);++h;}e=$wnd.Math.max(e,m);d+=i;if(c){a.r=e;a.d=d;Ead(a.j);}return new Uid(a.s,a.t,e,d)} + function CRb(a){var b,c,d,e,f,g,h,i,j,k,l,m;a.b=false;l=oxe;i=pxe;m=oxe;j=pxe;for(d=a.e.a.ec().Kc();d.Ob();){c=RD(d.Pb(),272);e=c.a;l=$wnd.Math.min(l,e.c);i=$wnd.Math.max(i,e.c+e.b);m=$wnd.Math.min(m,e.d);j=$wnd.Math.max(j,e.d+e.a);for(g=new Anb(c.c);g.aa.o.a){k=(i-a.o.a)/2;h.b=$wnd.Math.max(h.b,k);h.c=$wnd.Math.max(h.c,k);}} + function RId(a){var b,c,d,e,f,g,h,i;f=new med;ied(f,(hed(),eed));for(d=(e=oC(a,$C(qJ,Nve,2,0,6,1)),new Dkb(new mob((new CC(a,e)).b)));d.bh?1:-1:Ejb(a.a,b.a,f);if(e==-1){l=-i;k=g==i?Hjb(b.a,h,a.a,f):Cjb(b.a,h,a.a,f);}else {l=g;if(g==i){if(e==0){return Pib(),Oib}k=Hjb(a.a,f,b.a,h);}else {k=Cjb(a.a,f,b.a,h);}}j=new cjb(l,k.length,k);Rib(j);return j} + function c5b(a,b){var c,d,e,f;f=Z4b(b);!b.c&&(b.c=new C5d(K4,b,9,9));FDb(new SDb(null,(!b.c&&(b.c=new C5d(K4,b,9,9)),new Swb(b.c,16))),new s5b(f));e=RD(mQb(f,(Ywc(),kwc)),21);Y4b(b,e);if(e.Hc((ovc(),hvc))){for(d=new dMd((!b.c&&(b.c=new C5d(K4,b,9,9)),b.c));d.e!=d.i.gc();){c=RD(bMd(d),123);g5b(a,b,f,c);}}RD(Gxd(b,(yCc(),lBc)),181).gc()!=0&&V4b(b,f);Heb(TD(mQb(f,sBc)))&&e.Fc(mvc);nQb(f,PBc)&&HCc(new RCc(Kfb(UD(mQb(f,PBc)))),f);dE(Gxd(b,IAc))===dE((Fnd(),Cnd))?d5b(a,b,f):b5b(a,b,f);return f} + function Vrc(a){var b,c,d,e,f,g,h,i;for(e=new Anb(a.b);e.a0?zhb(c.a,0,f-1):''}}else {return !c?a:c.a}} + function xic(a,b){var c,d,e,f,g,h,i;b.Ug('Sort By Input Model '+mQb(a,(yCc(),cAc)),1);e=0;for(d=new Anb(a.b);d.a=a.b.length){f[e++]=g.b[d++];f[e++]=g.b[d++];}else if(d>=g.b.length){f[e++]=a.b[c++];f[e++]=a.b[c++];}else if(g.b[d]0?a.i:0);}++b;}Ce(a.n,i);a.d=c;a.r=d;a.g=0;a.f=0;a.e=0;a.o=oxe;a.p=oxe;for(f=new Anb(a.b);f.a0){e=(!a.n&&(a.n=new C5d(I4,a,1,7)),RD(QHd(a.n,0),135)).a;!e||Zhb(Zhb((b.a+=' "',b),e),'"');}}else {Zhb(Zhb((b.a+=' "',b),d),'"');}c=(!a.b&&(a.b=new Yie(E4,a,4,7)),!(a.b.i<=1&&(!a.c&&(a.c=new Yie(E4,a,5,8)),a.c.i<=1)));c?(b.a+=' [',b):(b.a+=' ',b);Zhb(b,Eb(new Gb,new dMd(a.b)));c&&(b.a+=']',b);b.a+=SAe;c&&(b.a+='[',b);Zhb(b,Eb(new Gb,new dMd(a.c)));c&&(b.a+=']',b);return b.a} + function odc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;v=a.c;w=b.c;c=Wmb(v.a,a,0);d=Wmb(w.a,b,0);t=RD(c3b(a,(BEc(),yEc)).Kc().Pb(),12);C=RD(c3b(a,zEc).Kc().Pb(),12);u=RD(c3b(b,yEc).Kc().Pb(),12);D=RD(c3b(b,zEc).Kc().Pb(),12);r=s2b(t.e);A=s2b(C.g);s=s2b(u.e);B=s2b(D.g);f3b(a,d,w);for(g=s,k=0,o=g.length;kk){new bTc((fTc(),eTc),c,b,j-k);}else if(j>0&&k>0){new bTc((fTc(),eTc),b,c,0);new bTc(eTc,c,b,0);}}return g} + function pXc(a,b,c){var d,e,f;a.a=new bnb;for(f=Sub(b.b,0);f.b!=f.d.c;){e=RD(evb(f),40);while(RD(mQb(e,(h_c(),f_c)),17).a>a.a.c.length-1){Rmb(a.a,new Ptd(Hze,KEe));}d=RD(mQb(e,f_c),17).a;if(c==(Cmd(),ymd)||c==zmd){e.e.aKfb(UD(RD(Vmb(a.a,d),42).b))&&Otd(RD(Vmb(a.a,d),42),e.e.a+e.f.a);}else {e.e.bKfb(UD(RD(Vmb(a.a,d),42).b))&&Otd(RD(Vmb(a.a,d),42),e.e.b+e.f.b);}}} + function g2b(a,b,c,d){var e,f,g,h,i,j,k;f=i2b(d);h=Heb(TD(mQb(d,(yCc(),aBc))));if((h||Heb(TD(mQb(a,MAc))))&&!Dod(RD(mQb(a,BBc),101))){e=vpd(f);i=q2b(a,c,c==(BEc(),zEc)?e:spd(e));}else {i=new R3b;P3b(i,a);if(b){k=i.n;k.a=b.a-a.n.a;k.b=b.b-a.n.b;_id(k,0,0,a.o.a,a.o.b);Q3b(i,c2b(i,f));}else {e=vpd(f);Q3b(i,c==(BEc(),zEc)?e:spd(e));}g=RD(mQb(d,(Ywc(),kwc)),21);j=i.j;switch(f.g){case 2:case 1:(j==(qpd(),Yod)||j==npd)&&g.Fc((ovc(),lvc));break;case 4:case 3:(j==(qpd(),Xod)||j==ppd)&&g.Fc((ovc(),lvc));}}return i} + function VXb(a,b){var c,d,e,f,g,h;for(g=new vkb((new mkb(a.f.b)).a);g.b;){f=tkb(g);e=RD(f.ld(),602);if(b==1){if(e.Af()!=(Cmd(),Bmd)&&e.Af()!=xmd){continue}}else {if(e.Af()!=(Cmd(),ymd)&&e.Af()!=zmd){continue}}d=RD(RD(f.md(),42).b,86);h=RD(RD(f.md(),42).a,194);c=h.c;switch(e.Af().g){case 2:d.g.c=a.e.a;d.g.b=$wnd.Math.max(1,d.g.b+c);break;case 1:d.g.c=d.g.c+c;d.g.b=$wnd.Math.max(1,d.g.b-c);break;case 4:d.g.d=a.e.b;d.g.a=$wnd.Math.max(1,d.g.a+c);break;case 3:d.g.d=d.g.d+c;d.g.a=$wnd.Math.max(1,d.g.a-c);}}} + function NNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;h=$C(kE,Pwe,28,b.b.c.length,15,1);j=$C(hR,jwe,273,b.b.c.length,0,1);i=$C(jR,WAe,10,b.b.c.length,0,1);for(l=a.a,m=0,n=l.length;m0&&!!i[d]&&(o=bFc(a.b,i[d],e));p=$wnd.Math.max(p,e.c.c.b+o);}for(f=new Anb(k.e);f.a1){throw Adb(new agb(gLe))}if(!i){f=oke(b,d.Kc().Pb());g.Fc(f);}}return XGd(a,gge(a,b,c),g)} + function Fge(a,b,c){var d,e,f,g,h,i,j,k;if(qke(a.e,b)){i=(nke(),RD(b,69).xk()?new ole(b,a):new Eke(b,a));bge(i.c,i.b);Ake(i,RD(c,16));}else {k=pke(a.e.Dh(),b);d=RD(a.g,124);for(g=0;g';}i!=null&&(b.a+=''+i,b);}else if(a.e){h=a.e.zb;h!=null&&(b.a+=''+h,b);}else {b.a+='?';if(a.b){b.a+=' super ';r2d(a.b,b);}else {if(a.f){b.a+=' extends ';r2d(a.f,b);}}}} + function Uae(a){a.b=null;a.a=null;a.o=null;a.q=null;a.v=null;a.w=null;a.B=null;a.p=null;a.Q=null;a.R=null;a.S=null;a.T=null;a.U=null;a.V=null;a.W=null;a.bb=null;a.eb=null;a.ab=null;a.H=null;a.db=null;a.c=null;a.d=null;a.f=null;a.n=null;a.r=null;a.s=null;a.u=null;a.G=null;a.J=null;a.e=null;a.j=null;a.i=null;a.g=null;a.k=null;a.t=null;a.F=null;a.I=null;a.L=null;a.M=null;a.O=null;a.P=null;a.$=null;a.N=null;a.Z=null;a.cb=null;a.K=null;a.D=null;a.A=null;a.C=null;a._=null;a.fb=null;a.X=null;a.Y=null;a.gb=false;a.hb=false;} + function yib(a){var b,c,d,e;d=Ajb((!a.c&&(a.c=ojb(Hdb(a.f))),a.c),0);if(a.e==0||a.a==0&&a.f!=-1&&a.e<0){return d}b=xib(a)<0?1:0;c=a.e;e=(d.length+1+$wnd.Math.abs(eE(a.e)),new cib);b==1&&(e.a+='-',e);if(a.e>0){c-=d.length-b;if(c>=0){e.a+='0.';for(;c>mib.length;c-=mib.length){$hb(e,mib);}_hb(e,mib,eE(c));Zhb(e,(BFb(b,d.length+1),d.substr(b)));}else {c=b-c;Zhb(e,zhb(d,b,eE(c)));e.a+='.';Zhb(e,yhb(d,eE(c)));}}else {Zhb(e,(BFb(b,d.length+1),d.substr(b)));for(;c<-mib.length;c+=mib.length){$hb(e,mib);}_hb(e,mib,eE(-c));}return e.a} + function BOc(a){var b,c,d,e,f,g,h,i,j;if(a.k!=(r3b(),p3b)){return false}if(a.j.c.length<=1){return false}f=RD(mQb(a,(yCc(),BBc)),101);if(f==(Bod(),wod)){return false}e=(wDc(),(!a.q?(yob(),yob(),wob):a.q)._b(iBc)?(d=RD(mQb(a,iBc),203)):(d=RD(mQb(Y2b(a),jBc),203)),d);if(e==uDc){return false}if(!(e==tDc||e==sDc)){g=Kfb(UD(hFc(a,fCc)));b=RD(mQb(a,eCc),140);!b&&(b=new R2b(g,g,g,g));j=b3b(a,(qpd(),ppd));i=b.d+b.a+(j.gc()-1)*g;if(i>a.o.b){return false}c=b3b(a,Xod);h=b.d+b.a+(c.gc()-1)*g;if(h>a.o.b){return false}}return true} + function VRc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;b.Ug('Orthogonal edge routing',1);j=Kfb(UD(mQb(a,(yCc(),cCc))));c=Kfb(UD(mQb(a,UBc)));d=Kfb(UD(mQb(a,XBc)));m=new TTc(0,c);q=0;g=new Jkb(a.b,0);h=null;k=null;i=null;l=null;do{k=g.b0){n=(o-1)*c;!!h&&(n+=d);!!k&&(n+=d);nb||Heb(TD(Gxd(i,(X7c(),D7c))))){e=0;f+=k.b+c;ZEb(l.c,k);k=new Had(f,c);d=new V9c(0,k.f,k,c);Cad(k,d);e=0;}if(d.b.c.length==0||!Heb(TD(Gxd(vCd(i),(X7c(),L7c))))&&(i.f>=d.o&&i.f<=d.f||d.a*0.5<=i.f&&d.a*1.5>=i.f)){K9c(d,i);}else {g=new V9c(d.s+d.r+c,k.f,k,c);Cad(k,g);K9c(g,i);}e=i.i+i.g;}ZEb(l.c,k);return l} + function ste(a){var b,c,d,e;if(a.b==null||a.b.length<=2)return;if(a.a)return;b=0;e=0;while(e=a.b[e+1]){e+=2;}else if(c0){d=new dnb(RD(Qc(a.a,f),21));yob();_mb(d,new M0b(b));e=new Jkb(f.b,0);while(e.b0&&d>=-6){if(d>=0){aib(f,c-eE(a.e),String.fromCharCode(46));}else {peb(f,b-1,b-1,'0.');aib(f,b+1,Ihb(mib,0,-eE(d)-1));}}else {if(c-b>=1){aib(f,b,String.fromCharCode(46));++c;}aib(f,c,String.fromCharCode(69));d>0&&aib(f,++c,String.fromCharCode(43));aib(f,++c,''+Zdb(Hdb(d)));}a.g=f.a;return a.g} + function KNc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;d=Kfb(UD(mQb(b,(yCc(),hBc))));v=RD(mQb(b,gCc),17).a;m=4;e=3;w=20/v;n=false;i=0;g=lve;do{f=i!=1;l=i!=0;A=0;for(q=a.a,s=0,u=q.length;sv)){i=2;g=lve;}else if(i==0){i=1;g=A;}else {i=0;g=A;}}else {n=A>=g||g-A0?1:cz(isNaN(d),isNaN(0)))>=0^(bz(vEe),($wnd.Math.abs(h)<=vEe||h==0||isNaN(h)&&isNaN(0)?0:h<0?-1:h>0?1:cz(isNaN(h),isNaN(0)))>=0)){return $wnd.Math.max(h,d)}bz(vEe);if(($wnd.Math.abs(d)<=vEe||d==0||isNaN(d)&&isNaN(0)?0:d<0?-1:d>0?1:cz(isNaN(d),isNaN(0)))>0){return $wnd.Math.sqrt(h*h+d*d)}return -$wnd.Math.sqrt(h*h+d*d)} + function hue(a,b){var c,d,e,f,g,h;if(!b)return;!a.a&&(a.a=new gyb);if(a.e==2){dyb(a.a,b);return}if(b.e==1){for(e=0;e=txe?Nhb(c,qse(d)):Jhb(c,d&Bwe);g=(new eue(10,null,0));fyb(a.a,g,h-1);}else {c=(g.Mm().length+f,new Rhb);Nhb(c,g.Mm());}if(b.e==0){d=b.Km();d>=txe?Nhb(c,qse(d)):Jhb(c,d&Bwe);}else {Nhb(c,b.Mm());}RD(g,530).b=c.a;} + function Qsc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(c.dc()){return}h=0;m=0;d=c.Kc();o=RD(d.Pb(),17).a;while(h1&&(i=j.Hg(i,a.a,h));}if(i.c.length==1){return RD(Vmb(i,i.c.length-1),238)}if(i.c.length==2){return e8c((tFb(0,i.c.length),RD(i.c[0],238)),(tFb(1,i.c.length),RD(i.c[1],238)),g,f)}return null} + function CZc(a,b,c){var d,e,f,g,h,i,j;c.Ug('Find roots',1);a.a.c.length=0;for(e=Sub(b.b,0);e.b!=e.d.c;){d=RD(evb(e),40);if(d.b.b==0){pQb(d,(q$c(),n$c),(Geb(),true));Rmb(a.a,d);}}switch(a.a.c.length){case 0:f=new bXc(0,b,'DUMMY_ROOT');pQb(f,(q$c(),n$c),(Geb(),true));pQb(f,WZc,true);Mub(b.b,f);break;case 1:break;default:g=new bXc(0,b,IEe);for(i=new Anb(a.a);i.a=$wnd.Math.abs(d.b)){d.b=0;f.d+f.a>g.d&&f.dg.c&&f.c0){b=new zNd(a.i,a.g);c=a.i;f=c<100?null:new gLd(c);if(a.Tj()){for(d=0;d0){h=a.g;j=a.i;OHd(a);f=j<100?null:new gLd(j);for(d=0;d>13|(a.m&15)<<9;e=a.m>>4&8191;f=a.m>>17|(a.h&255)<<5;g=(a.h&1048320)>>8;h=b.l&8191;i=b.l>>13|(b.m&15)<<9;j=b.m>>4&8191;k=b.m>>17|(b.h&255)<<5;l=(b.h&1048320)>>8;B=c*h;C=d*h;D=e*h;F=f*h;G=g*h;if(i!=0){C+=c*i;D+=d*i;F+=e*i;G+=f*i;}if(j!=0){D+=c*j;F+=d*j;G+=e*j;}if(k!=0){F+=c*k;G+=d*k;}l!=0&&(G+=c*l);n=B&dxe;o=(C&511)<<13;m=n+o;q=B>>22;r=C>>9;s=(D&262143)<<4;t=(F&31)<<17;p=q+r+s+t;v=D>>18;w=F>>5;A=(G&4095)<<8;u=v+w+A;p+=m>>22;m&=dxe;u+=p>>22;p&=dxe;u&=exe;return hD(m,p,u)} + function Fac(a){var b,c,d,e,f,g,h;h=RD(Vmb(a.j,0),12);if(h.g.c.length!=0&&h.e.c.length!=0){throw Adb(new dgb('Interactive layout does not support NORTH/SOUTH ports with incoming _and_ outgoing edges.'))}if(h.g.c.length!=0){f=oxe;for(c=new Anb(h.g);c.a4){if(a.fk(b)){if(a.al()){e=RD(b,54);d=e.Eh();i=d==a.e&&(a.ml()?e.yh(e.Fh(),a.il())==a.jl():-1-e.Fh()==a.Lj());if(a.nl()&&!i&&!d&&!!e.Jh()){for(f=0;f0&&aGc(a,h,l);}for(e=new Anb(l);e.aa.d[g.p]){c+=ZLc(a.b,f)*RD(i.b,17).a;hmb(a.a,sgb(f));}}while(!nmb(a.a)){XLc(a.b,RD(smb(a.a),17).a);}}return c} + function x9b(a,b){var c,d,e,f,g,h,i,j,k,l;k=RD(mQb(a,(Ywc(),hwc)),64);d=RD(Vmb(a.j,0),12);k==(qpd(),Yod)?Q3b(d,npd):k==npd&&Q3b(d,Yod);if(RD(mQb(b,(yCc(),lBc)),181).Hc((Qpd(),Ppd))){i=Kfb(UD(mQb(a,_Bc)));j=Kfb(UD(mQb(a,aCc)));g=Kfb(UD(mQb(a,ZBc)));h=RD(mQb(b,EBc),21);if(h.Hc((Pod(),Lod))){c=j;l=a.o.a/2-d.n.a;for(f=new Anb(d.f);f.a0&&(j=a.n.a/f);break;case 2:case 4:e=a.i.o.b;e>0&&(j=a.n.b/e);}pQb(a,(Ywc(),Jwc),j);}i=a.o;g=a.a;if(d){g.a=d.a;g.b=d.b;a.d=true;}else if(b!=zod&&b!=Aod&&h!=opd){switch(h.g){case 1:g.a=i.a/2;break;case 2:g.a=i.a;g.b=i.b/2;break;case 3:g.a=i.a/2;g.b=i.b;break;case 4:g.b=i.b/2;}}else {g.a=i.a/2;g.b=i.b/2;}} + function VJd(a){var b,c,d,e,f,g,h,i,j,k;if(a.Pj()){k=a.Ej();i=a.Qj();if(k>0){b=new $Hd(a.pj());c=k;f=c<100?null:new gLd(c);aJd(a,c,b.g);e=c==1?a.Ij(4,QHd(b,0),null,0,i):a.Ij(6,b,null,-1,i);if(a.Mj()){for(d=new dMd(b);d.e!=d.i.gc();){f=a.Oj(bMd(d),f);}if(!f){a.Jj(e);}else {f.nj(e);f.oj();}}else {if(!f){a.Jj(e);}else {f.nj(e);f.oj();}}}else {aJd(a,a.Ej(),a.Fj());a.Jj(a.Ij(6,(yob(),vob),null,-1,i));}}else if(a.Mj()){k=a.Ej();if(k>0){h=a.Fj();j=k;aJd(a,k,h);f=j<100?null:new gLd(j);for(d=0;d1&&urd(g)*trd(g)/2>h[0]){f=0;while(fh[f]){++f;}o=new Rkb(p,0,f+1);l=new zrd(o);k=urd(g)/trd(g);i=ird(l,b,new z3b,c,d,e,k);$id(hjd(l.e),i);zFb(lwb(m,l),Bxe);n=new Rkb(p,f+1,p.c.length);iwb(m,n);p.c.length=0;j=0;Pnb(h,h.length,0);}else {q=m.b.c.length==0?null:Vmb(m.b,0);q!=null&&owb(m,0);j>0&&(h[j]=h[j-1]);h[j]+=urd(g)*trd(g);++j;ZEb(p.c,g);}}return p} + function _nc(a,b){var c,d,e,f;c=b.b;f=new dnb(c.j);e=0;d=c.j;d.c.length=0;Nnc(RD($i(a.b,(qpd(),Yod),(joc(),ioc)),15),c);e=Onc(f,e,new Hoc,d);Nnc(RD($i(a.b,Yod,hoc),15),c);e=Onc(f,e,new Joc,d);Nnc(RD($i(a.b,Yod,goc),15),c);Nnc(RD($i(a.b,Xod,ioc),15),c);Nnc(RD($i(a.b,Xod,hoc),15),c);e=Onc(f,e,new Loc,d);Nnc(RD($i(a.b,Xod,goc),15),c);Nnc(RD($i(a.b,npd,ioc),15),c);e=Onc(f,e,new Noc,d);Nnc(RD($i(a.b,npd,hoc),15),c);e=Onc(f,e,new Poc,d);Nnc(RD($i(a.b,npd,goc),15),c);Nnc(RD($i(a.b,ppd,ioc),15),c);e=Onc(f,e,new toc,d);Nnc(RD($i(a.b,ppd,hoc),15),c);Nnc(RD($i(a.b,ppd,goc),15),c);} + function jJc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;for(h=new Anb(b);h.a0.5?(r-=g*2*(o-0.5)):o<0.5&&(r+=f*2*(0.5-o));e=h.d.b;rq.a-p-k&&(r=q.a-p-k);h.n.a=b+r;}} + function jec(a){var b,c,d,e,f;d=RD(mQb(a,(yCc(),UAc)),171);if(d==(cxc(),$wc)){for(c=new is(Mr(Z2b(a).a.Kc(),new ir));gs(c);){b=RD(hs(c),18);if(!lec(b)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to FIRST_SEPARATE, but has at least one incoming edge. "+'FIRST_SEPARATE nodes must not have incoming edges.'))}}}else if(d==axc){for(f=new is(Mr(a3b(a).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(!lec(e)){throw Adb(new Jed(nBe+X2b(a)+"' has its layer constraint set to LAST_SEPARATE, but has at least one outgoing edge. "+'LAST_SEPARATE nodes must not have outgoing edges.'))}}}} + function Qed(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;if(a.e&&a.c.c>19!=0){b=xD(b);i=!i;}g=pD(b);f=false;e=false;d=false;if(a.h==fxe&&a.m==0&&a.l==0){e=true;f=true;if(g==-1){a=gD((MD(),ID));d=true;i=!i;}else {h=BD(a,g);i&&nD(h);c&&(eD=hD(0,0,0));return h}}else if(a.h>>19!=0){f=true;a=xD(a);d=true;i=!i;}if(g!=-1){return kD(a,g,i,f,c)}if(uD(a,b)<0){c&&(f?(eD=xD(a)):(eD=hD(a.l,a.m,a.h)));return hD(0,0,0)}return lD(d?a:hD(a.l,a.m,a.h),b,i,f,e,c)} + function Bjb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;g=a.e;i=b.e;if(g==0){return b}if(i==0){return a}f=a.d;h=b.d;if(f+h==2){c=Cdb(a.a[0],yxe);d=Cdb(b.a[0],yxe);if(g==i){k=Bdb(c,d);o=Ydb(k);n=Ydb(Udb(k,32));return n==0?new ajb(g,o):new cjb(g,2,cD(WC(kE,1),Pwe,28,15,[o,n]))}return Pib(),Jdb(g<0?Vdb(d,c):Vdb(c,d),0)?jjb(g<0?Vdb(d,c):Vdb(c,d)):Xib(jjb(Odb(g<0?Vdb(d,c):Vdb(c,d))))}else if(g==i){m=g;l=f>=h?Cjb(a.a,f,b.a,h):Cjb(b.a,h,a.a,f);}else {e=f!=h?f>h?1:-1:Ejb(a.a,b.a,f);if(e==0){return Pib(),Oib}if(e==1){m=g;l=Hjb(a.a,f,b.a,h);}else {m=i;l=Hjb(b.a,h,a.a,f);}}j=new cjb(m,l.length,l);Rib(j);return j} + function KUc(a,b){var c,d,e,f,g,h,i;if(a.g>b.f||b.g>a.f){return}c=0;d=0;for(g=a.w.a.ec().Kc();g.Ob();){e=RD(g.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,b.g,b.f)&&++c;}for(h=a.r.a.ec().Kc();h.Ob();){e=RD(h.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,b.g,b.f)&&--c;}for(i=b.w.a.ec().Kc();i.Ob();){e=RD(i.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,a.g,a.f)&&++d;}for(f=b.r.a.ec().Kc();f.Ob();){e=RD(f.Pb(),12);AVc(xjd(cD(WC(l3,1),Nve,8,0,[e.i.n,e.n,e.a])).b,a.g,a.f)&&--d;}if(c=0){return c}switch(yfe(Qee(a,c))){case 2:{if(lhb('',Oee(a,c.qk()).xe())){i=Bfe(Qee(a,c));h=Afe(Qee(a,c));k=Ree(a,b,i,h);if(k){return k}e=Fee(a,b);for(g=0,l=e.gc();g1){throw Adb(new agb(gLe))}k=pke(a.e.Dh(),b);d=RD(a.g,124);for(g=0;g1;for(j=new l4b(m.b);xnb(j.a)||xnb(j.b);){i=RD(xnb(j.a)?ynb(j.a):ynb(j.b),18);l=i.c==m?i.d:i.c;$wnd.Math.abs(xjd(cD(WC(l3,1),Nve,8,0,[l.i.n,l.n,l.a])).b-g.b)>1&&eSc(a,i,g,f,m);}}} + function vUc(a){var b,c,d,e,f,g;e=new Jkb(a.e,0);d=new Jkb(a.a,0);if(a.d){for(c=0;cAEe){f=b;g=0;while($wnd.Math.abs(b-f)0);e.a.Xb(e.c=--e.b);uUc(a,a.b-g,f,d,e);sFb(e.b0);d.a.Xb(d.c=--d.b);}if(!a.d){for(c=0;c0){a.f[k.p]=n/(k.e.c.length+k.g.c.length);a.c=$wnd.Math.min(a.c,a.f[k.p]);a.b=$wnd.Math.max(a.b,a.f[k.p]);}else h&&(a.f[k.p]=n);}} + function xne(a){a.b=null;a.bb=null;a.fb=null;a.qb=null;a.a=null;a.c=null;a.d=null;a.e=null;a.f=null;a.n=null;a.M=null;a.L=null;a.Q=null;a.R=null;a.K=null;a.db=null;a.eb=null;a.g=null;a.i=null;a.j=null;a.k=null;a.gb=null;a.o=null;a.p=null;a.q=null;a.r=null;a.$=null;a.ib=null;a.S=null;a.T=null;a.t=null;a.s=null;a.u=null;a.v=null;a.w=null;a.B=null;a.A=null;a.C=null;a.D=null;a.F=null;a.G=null;a.H=null;a.I=null;a.J=null;a.P=null;a.Z=null;a.U=null;a.V=null;a.W=null;a.X=null;a.Y=null;a._=null;a.ab=null;a.cb=null;a.hb=null;a.nb=null;a.lb=null;a.mb=null;a.ob=null;a.pb=null;a.jb=null;a.kb=null;a.N=false;a.O=false;} + function C8b(a,b,c){var d,e,f,g;c.Ug('Graph transformation ('+a.a+')',1);g=bv(b.a);for(f=new Anb(b.b);f.a=h.b.c)&&(h.b=b);if(!h.c||b.c<=h.c.c){h.d=h.c;h.c=b;}(!h.e||b.d>=h.e.d)&&(h.e=b);(!h.f||b.d<=h.f.d)&&(h.f=b);}d=new PZb((nZb(),jZb));t$b(a,AZb,new mob(cD(WC(wQ,1),rve,382,0,[d])));g=new PZb(mZb);t$b(a,zZb,new mob(cD(WC(wQ,1),rve,382,0,[g])));e=new PZb(kZb);t$b(a,yZb,new mob(cD(WC(wQ,1),rve,382,0,[e])));f=new PZb(lZb);t$b(a,xZb,new mob(cD(WC(wQ,1),rve,382,0,[f])));FZb(d.c,jZb);FZb(e.c,kZb);FZb(f.c,lZb);FZb(g.c,mZb);h.a.c.length=0;Tmb(h.a,d.c);Tmb(h.a,hv(e.c));Tmb(h.a,f.c);Tmb(h.a,hv(g.c));return h} + function n9c(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;b.Ug(bGe,1);n=Kfb(UD(Gxd(a,(X6c(),W6c))));g=Kfb(UD(Gxd(a,(X7c(),Q7c))));h=RD(Gxd(a,N7c),107);Bad((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));k=U8c((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a),n,g);!a.a&&(a.a=new C5d(J4,a,10,11));for(j=new Anb(k);j.a0){a.a=i+(n-1)*f;b.c.b+=a.a;b.f.b+=a.a;}}if(o.a.gc()!=0){m=new TTc(1,f);n=STc(m,b,o,p,b.f.b+i-b.c.b);n>0&&(b.f.b+=i+(n-1)*f);}} + function osc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;k=Kfb(UD(mQb(a,(yCc(),WBc))));d=Kfb(UD(mQb(a,nCc)));m=new dtd;pQb(m,WBc,k+d);j=b;r=j.d;p=j.c.i;s=j.d.i;q=Q4b(p.c);t=Q4b(s.c);e=new bnb;for(l=q;l<=t;l++){h=new j3b(a);h3b(h,(r3b(),o3b));pQb(h,(Ywc(),Awc),j);pQb(h,BBc,(Bod(),wod));pQb(h,YBc,m);n=RD(Vmb(a.b,l),30);l==q?f3b(h,n.a.c.length-c,n):g3b(h,n);u=Kfb(UD(mQb(j,FAc)));if(u<0){u=0;pQb(j,FAc,u);}h.o.b=u;o=$wnd.Math.floor(u/2);g=new R3b;Q3b(g,(qpd(),ppd));P3b(g,h);g.n.b=o;i=new R3b;Q3b(i,Xod);P3b(i,h);i.n.b=o;Z0b(j,g);f=new a1b;kQb(f,j);pQb(f,RAc,null);Y0b(f,i);Z0b(f,r);psc(h,j,f);ZEb(e.c,f);j=f;}return e} + function Hec(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;i=RD(e3b(a,(qpd(),ppd)).Kc().Pb(),12).e;n=RD(e3b(a,Xod).Kc().Pb(),12).g;h=i.c.length;t=K3b(RD(Vmb(a.j,0),12));while(h-->0){p=(tFb(0,i.c.length),RD(i.c[0],18));e=(tFb(0,n.c.length),RD(n.c[0],18));s=e.d.e;f=Wmb(s,e,0);$0b(p,e.d,f);Y0b(e,null);Z0b(e,null);o=p.a;b&&Mub(o,new sjd(t));for(d=Sub(e.a,0);d.b!=d.d.c;){c=RD(evb(d),8);Mub(o,new sjd(c));}r=p.b;for(m=new Anb(e.b);m.ag)&&Ysb(a.b,RD(q.b,18));}}++h;}f=g;}}}} + function zhd(b,c){var d;if(c==null||lhb(c,vve)){return null}if(c.length==0&&b.k!=(kid(),fid)){return null}switch(b.k.g){case 1:return mhb(c,FGe)?(Geb(),Feb):mhb(c,GGe)?(Geb(),Eeb):null;case 2:try{return sgb(Oeb(c,qwe,lve))}catch(a){a=zdb(a);if(ZD(a,130)){return null}else throw Adb(a)}case 4:try{return Neb(c)}catch(a){a=zdb(a);if(ZD(a,130)){return null}else throw Adb(a)}case 3:return c;case 5:uhd(b);return xhd(b,c);case 6:uhd(b);return yhd(b,b.a,c);case 7:try{d=whd(b);d.cg(c);return d}catch(a){a=zdb(a);if(ZD(a,33)){return null}else throw Adb(a)}default:throw Adb(new dgb('Invalid type set for this layout option.'));}} + function JKd(a){var b;switch(a.d){case 1:{if(a.Sj()){return a.o!=-2}break}case 2:{if(a.Sj()){return a.o==-2}break}case 3:case 5:case 4:case 6:case 7:{return a.o>-2}default:{return false}}b=a.Rj();switch(a.p){case 0:return b!=null&&Heb(TD(b))!=Pdb(a.k,0);case 1:return b!=null&&RD(b,222).a!=Ydb(a.k)<<24>>24;case 2:return b!=null&&RD(b,180).a!=(Ydb(a.k)&Bwe);case 6:return b!=null&&Pdb(RD(b,168).a,a.k);case 5:return b!=null&&RD(b,17).a!=Ydb(a.k);case 7:return b!=null&&RD(b,191).a!=Ydb(a.k)<<16>>16;case 3:return b!=null&&Kfb(UD(b))!=a.j;case 4:return b!=null&&RD(b,161).a!=a.j;default:return b==null?a.n!=null:!pb(b,a.n);}} + function N_d(a,b,c){var d,e,f,g;if(a.ol()&&a.nl()){g=O_d(a,RD(c,58));if(dE(g)!==dE(c)){a.xj(b);a.Dj(b,P_d(a,b,g));if(a.al()){f=(e=RD(c,54),a.ml()?a.kl()?e.Th(a.b,Z5d(RD(vYd(Uwd(a.b),a.Lj()),19)).n,RD(vYd(Uwd(a.b),a.Lj()).Hk(),29).kk(),null):e.Th(a.b,BYd(e.Dh(),Z5d(RD(vYd(Uwd(a.b),a.Lj()),19))),null,null):e.Th(a.b,-1-a.Lj(),null,null));!RD(g,54).Ph()&&(f=(d=RD(g,54),a.ml()?a.kl()?d.Rh(a.b,Z5d(RD(vYd(Uwd(a.b),a.Lj()),19)).n,RD(vYd(Uwd(a.b),a.Lj()).Hk(),29).kk(),f):d.Rh(a.b,BYd(d.Dh(),Z5d(RD(vYd(Uwd(a.b),a.Lj()),19))),null,f):d.Rh(a.b,-1-a.Lj(),null,f)));!!f&&f.oj();}Mvd(a.b)&&a.Jj(a.Ij(9,c,g,b,false));return g}}return c} + function iJb(a){var b,c,d,e,f,g,h,i,j,k;d=new bnb;for(g=new Anb(a.e.a);g.a0&&(g=$wnd.Math.max(g,zMb(a.C.b+d.d.b,e)));}else {n=m+k.d.c+a.w+d.d.b;g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(l-e)<=Tye||l==e||isNaN(l)&&isNaN(e)?0:n/(e-l)));}k=d;l=e;m=f;}if(!!a.C&&a.C.c>0){n=m+a.C.c;j&&(n+=k.d.c);g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(l-1)<=Tye||l==1||isNaN(l)&&isNaN(1)?0:n/(1-l)));}c.n.b=0;c.a.a=g;} + function ENb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;c=RD(Vrb(a.b,b),127);i=RD(RD(Qc(a.r,b),21),87);if(i.dc()){c.n.d=0;c.n.a=0;return}j=a.u.Hc((Pod(),Lod));g=0;a.A.Hc((Qpd(),Ppd))&&JNb(a,b);h=i.Kc();k=null;m=0;l=0;while(h.Ob()){d=RD(h.Pb(),117);f=Kfb(UD(d.b.of((tNb(),sNb))));e=d.b.Mf().b;if(!k){!!a.C&&a.C.d>0&&(g=$wnd.Math.max(g,zMb(a.C.d+d.d.d,f)));}else {n=l+k.d.a+a.w+d.d.d;g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(m-f)<=Tye||m==f||isNaN(m)&&isNaN(f)?0:n/(f-m)));}k=d;m=f;l=e;}if(!!a.C&&a.C.a>0){n=l+a.C.a;j&&(n+=k.d.a);g=$wnd.Math.max(g,(Zy(),bz(Tye),$wnd.Math.abs(m-1)<=Tye||m==1||isNaN(m)&&isNaN(1)?0:n/(1-m)));}c.n.d=0;c.a.b=g;} + function L8c(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r;o=false;j=dad(c.q,b.f+b.b-c.q.f);n=d.f>b.b&&h;r=e-(c.q.e+j-g);l=(i=S9c(d,r,false),i.a);if(n&&l>d.f){return false}if(n){m=0;for(q=new Anb(b.d);q.a=(tFb(f,a.c.length),RD(a.c[f],186)).e;if(!n&&l>b.b&&!k){return false}if(k||n||l<=b.b){if(k&&l>b.b){c.d=l;Q9c(c,P9c(c,l));}else {ead(c.q,j);c.c=true;}Q9c(d,e-(c.s+c.r));U9c(d,c.q.e+c.q.d,b.f);Cad(b,d);if(a.c.length>f){Fad((tFb(f,a.c.length),RD(a.c[f],186)),d);(tFb(f,a.c.length),RD(a.c[f],186)).a.c.length==0&&Xmb(a,f);}o=true;}return o} + function zJc(a,b,c){var d,e,f,g,h,i;this.g=a;h=b.d.length;i=c.d.length;this.d=$C(jR,WAe,10,h+i,0,1);for(g=0;g0?xJc(this,this.f/this.a):pJc(b.g,b.d[0]).a!=null&&pJc(c.g,c.d[0]).a!=null?xJc(this,(Kfb(pJc(b.g,b.d[0]).a)+Kfb(pJc(c.g,c.d[0]).a))/2):pJc(b.g,b.d[0]).a!=null?xJc(this,pJc(b.g,b.d[0]).a):pJc(c.g,c.d[0]).a!=null&&xJc(this,pJc(c.g,c.d[0]).a);} + function DXb(a,b){var c,d,e,f,g,h,i,j,k,l;a.a=new fYb(wsb(s3));for(d=new Anb(b.a);d.a=1){if(q-g>0&&l>=0){i.n.a+=p;i.n.b+=f*g;}else if(q-g<0&&k>=0){i.n.a+=p*q;i.n.b+=f;}}}a.o.a=b.a;a.o.b=b.b;pQb(a,(yCc(),lBc),(Qpd(),d=RD(mfb(H3),9),new Fsb(d,RD(WEb(d,d.length),9),0)));} + function ISd(a,b,c,d,e,f){var g;if(!(b==null||!mSd(b,ZRd,$Rd))){throw Adb(new agb('invalid scheme: '+b))}if(!a&&!(c!=null&&qhb(c,Fhb(35))==-1&&c.length>0&&(BFb(0,c.length),c.charCodeAt(0)!=47))){throw Adb(new agb('invalid opaquePart: '+c))}if(a&&!(b!=null&&tpb(eSd,b.toLowerCase()))&&!(c==null||!mSd(c,aSd,bSd))){throw Adb(new agb(NJe+c))}if(a&&b!=null&&tpb(eSd,b.toLowerCase())&&!ESd(c)){throw Adb(new agb(NJe+c))}if(!FSd(d)){throw Adb(new agb('invalid device: '+d))}if(!HSd(e)){g=e==null?'invalid segments: null':'invalid segment: '+tSd(e);throw Adb(new agb(g))}if(!(f==null||qhb(f,Fhb(35))==-1)){throw Adb(new agb('invalid query: '+f))}} + function WHc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;c.Ug('Network simplex layering',1);a.b=b;r=RD(mQb(b,(yCc(),gCc)),17).a*4;q=a.b.a;if(q.c.length<1){c.Vg();return}f=SHc(a,q);p=null;for(e=Sub(f,0);e.b!=e.d.c;){d=RD(evb(e),15);h=r*eE($wnd.Math.sqrt(d.gc()));g=VHc(d);lJb(yJb(AJb(zJb(CJb(g),h),p),true),c.eh(1));m=a.b.b;for(o=new Anb(g.a);o.a1){p=$C(kE,Pwe,28,a.b.b.c.length,15,1);l=0;for(j=new Anb(a.b.b);j.a0){wA(a,c,0);c.a+=String.fromCharCode(d);e=BA(b,f);wA(a,c,e);f+=e-1;continue}if(d==39){if(f+10&&o.a<=0){i.c.length=0;ZEb(i.c,o);break}n=o.i-o.d;if(n>=h){if(n>h){i.c.length=0;h=n;}ZEb(i.c,o);}}if(i.c.length!=0){g=RD(Vmb(i,Jwb(e,i.c.length)),118);t.a.Bc(g)!=null;g.g=k++;wSc(g,b,c,d);i.c.length=0;}}q=a.c.length+1;for(m=new Anb(a);m.apxe||b.o==CQc&&k=h&&e<=i){if(h<=e&&f<=i){c[k++]=e;c[k++]=f;d+=2;}else if(h<=e){c[k++]=e;c[k++]=i;a.b[d]=i+1;g+=2;}else if(f<=i){c[k++]=h;c[k++]=f;d+=2;}else {c[k++]=h;c[k++]=i;a.b[d]=i+1;}}else if(ipwe)&&h<10);BYb(a.c,new bYb);QXb(a);xYb(a.c);AXb(a.f);} + function B9b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p;c=RD(mQb(a,(yCc(),BBc)),101);g=a.f;f=a.d;h=g.a+f.b+f.c;i=0-f.d-a.c.b;k=g.b+f.d+f.a-a.c.b;j=new bnb;l=new bnb;for(e=new Anb(b);e.a=2){i=Sub(c,0);g=RD(evb(i),8);h=RD(evb(i),8);while(h.a0&&aHb(j,true,(Cmd(),zmd));h.k==(r3b(),m3b)&&bHb(j);Zjb(a.f,h,b);}}} + function OVc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;e=RD(mQb(a,(q$c(),h$c)),27);j=lve;k=lve;h=qwe;i=qwe;for(t=Sub(a.b,0);t.b!=t.d.c;){r=RD(evb(t),40);n=r.e;o=r.f;j=$wnd.Math.min(j,n.a-o.a/2);k=$wnd.Math.min(k,n.b-o.b/2);h=$wnd.Math.max(h,n.a+o.a/2);i=$wnd.Math.max(i,n.b+o.b/2);}m=RD(Gxd(e,(h_c(),T$c)),107);for(s=Sub(a.b,0);s.b!=s.d.c;){r=RD(evb(s),40);l=mQb(r,h$c);if(ZD(l,207)){f=RD(l,27);Byd(f,r.e.a,r.e.b);zxd(f,r);}}for(q=Sub(a.a,0);q.b!=q.d.c;){p=RD(evb(q),65);d=RD(mQb(p,h$c),74);if(d){b=p.a;c=IGd(d,true,true);lsd(b,c);}}u=h-j+(m.b+m.c);g=i-k+(m.d+m.a);Heb(TD(Gxd(e,(umd(),mld))))||Esd(e,u,g,false,false);Ixd(e,Ikd,u-(m.b+m.c));Ixd(e,Hkd,g-(m.d+m.a));} + function Wec(a,b){var c,d,e,f,g,h,i,j,k,l;i=true;e=0;j=a.g[b.p];k=b.o.b+a.o;c=a.d[b.p][2];$mb(a.b,j,sgb(RD(Vmb(a.b,j),17).a-1+c));$mb(a.c,j,Kfb(UD(Vmb(a.c,j)))-k+c*a.f);++j;if(j>=a.j){++a.j;Rmb(a.b,sgb(1));Rmb(a.c,k);}else {d=a.d[b.p][1];$mb(a.b,j,sgb(RD(Vmb(a.b,j),17).a+1-d));$mb(a.c,j,Kfb(UD(Vmb(a.c,j)))+k-d*a.f);}(a.r==(aEc(),VDc)&&(RD(Vmb(a.b,j),17).a>a.k||RD(Vmb(a.b,j-1),17).a>a.k)||a.r==YDc&&(Kfb(UD(Vmb(a.c,j)))>a.n||Kfb(UD(Vmb(a.c,j-1)))>a.n))&&(i=false);for(g=new is(Mr(Z2b(b).a.Kc(),new ir));gs(g);){f=RD(hs(g),18);h=f.c.i;if(a.g[h.p]==j){l=Wec(a,h);e=e+RD(l.a,17).a;i=i&&Heb(TD(l.b));}}a.g[b.p]=j;e=e+a.d[b.p][0];return new Ptd(sgb(e),(Geb(),i?true:false))} + function cXb(a,b){var c,d,e,f,g;c=Kfb(UD(mQb(b,(yCc(),TBc))));c<2&&pQb(b,TBc,2);d=RD(mQb(b,rAc),88);d==(Cmd(),Amd)&&pQb(b,rAc,i2b(b));e=RD(mQb(b,NBc),17);e.a==0?pQb(b,(Ywc(),Lwc),new Owb):pQb(b,(Ywc(),Lwc),new Pwb(e.a));f=TD(mQb(b,gBc));f==null&&pQb(b,gBc,(Geb(),dE(mQb(b,yAc))===dE((Ymd(),Umd))?true:false));FDb(new SDb(null,new Swb(b.a,16)),new fXb(a));FDb(EDb(new SDb(null,new Swb(b.b,16)),new hXb),new jXb(a));g=new gFc(b);pQb(b,(Ywc(),Qwc),g);Sed(a.a);Ved(a.a,(sXb(),nXb),RD(mQb(b,pAc),188));Ved(a.a,oXb,RD(mQb(b,$Ac),188));Ved(a.a,pXb,RD(mQb(b,oAc),188));Ved(a.a,qXb,RD(mQb(b,kBc),188));Ved(a.a,rXb,KRc(RD(mQb(b,yAc),223)));Ped(a.a,bXb(b));pQb(b,Kwc,Qed(a.a,b));} + function STc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r;l=new Tsb;g=new bnb;QTc(a,c,a.d.Ag(),g,l);QTc(a,d,a.d.Bg(),g,l);a.b=0.2*(p=RTc(EDb(new SDb(null,new Swb(g,16)),new XTc)),q=RTc(EDb(new SDb(null,new Swb(g,16)),new ZTc)),$wnd.Math.min(p,q));f=0;for(h=0;h=2&&(r=uSc(g,true,m),!a.e&&(a.e=new xTc(a)),tTc(a.e,r,g,a.b),undefined);UTc(g,m);WTc(g);n=-1;for(k=new Anb(g);k.ah} + function Iad(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;j=oxe;k=oxe;h=pxe;i=pxe;for(m=new Anb(b.i);m.a-1){for(e=Sub(h,0);e.b!=e.d.c;){d=RD(evb(e),131);d.v=g;}while(h.b!=0){d=RD(ku(h,0),131);for(c=new Anb(d.i);c.a-1){for(f=new Anb(h);f.a0){continue}RSc(i,$wnd.Math.min(i.o,e.o-1));QSc(i,i.i-1);i.i==0&&(ZEb(h.c,i),true);}}}} + function Lid(a,b,c,d,e){var f,g,h,i;i=oxe;g=false;h=Gid(a,ojd(new rjd(b.a,b.b),a),$id(new rjd(c.a,c.b),e),ojd(new rjd(d.a,d.b),c));f=!!h&&!($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe||$wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe);h=Gid(a,ojd(new rjd(b.a,b.b),a),c,e);!!h&&(($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe)==($wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe)||f?(i=$wnd.Math.min(i,ejd(ojd(h,c)))):(g=true));h=Gid(a,ojd(new rjd(b.a,b.b),a),d,e);!!h&&(g||($wnd.Math.abs(h.a-a.a)<=IGe&&$wnd.Math.abs(h.b-a.b)<=IGe)==($wnd.Math.abs(h.a-b.a)<=IGe&&$wnd.Math.abs(h.b-b.b)<=IGe)||f)&&(i=$wnd.Math.min(i,ejd(ojd(h,d))));return i} + function eWb(a){Cgd(a,new Pfd(Wfd($fd(Xfd(Zfd(Yfd(new agd,AAe),BAe),"Minimizes the stress within a layout using stress majorization. Stress exists if the euclidean distance between a pair of nodes doesn't match their graph theoretic distance, that is, the shortest path between the two nodes. The method allows to specify individual edge lengths."),new hWb),Zze)));Agd(a,AAe,dAe,iGd(XVb));Agd(a,AAe,fAe,(Geb(),true));Agd(a,AAe,jAe,iGd($Vb));Agd(a,AAe,CAe,iGd(_Vb));Agd(a,AAe,iAe,iGd(aWb));Agd(a,AAe,kAe,iGd(ZVb));Agd(a,AAe,gAe,iGd(bWb));Agd(a,AAe,lAe,iGd(cWb));Agd(a,AAe,vAe,iGd(WVb));Agd(a,AAe,xAe,iGd(UVb));Agd(a,AAe,yAe,iGd(VVb));Agd(a,AAe,zAe,iGd(YVb));Agd(a,AAe,wAe,iGd(TVb));} + function kJc(a){var b,c,d,e,f,g,h,i;b=null;for(d=new Anb(a);d.a0&&c.c==0){!b&&(b=new bnb);ZEb(b.c,c);}}if(b){while(b.c.length!=0){c=RD(Xmb(b,0),239);if(!!c.b&&c.b.c.length>0){for(f=(!c.b&&(c.b=new bnb),new Anb(c.b));f.aWmb(a,c,0)){return new Ptd(e,c)}}else if(Kfb(pJc(e.g,e.d[0]).a)>Kfb(pJc(c.g,c.d[0]).a)){return new Ptd(e,c)}}}for(h=(!c.e&&(c.e=new bnb),c.e).Kc();h.Ob();){g=RD(h.Pb(),239);i=(!g.b&&(g.b=new bnb),g.b);wFb(0,i.c.length);XEb(i.c,0,c);g.c==i.c.length&&(ZEb(b.c,g),true);}}}return null} + function _Jc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;b.Ug('Interactive crossing minimization',1);g=0;for(f=new Anb(a.b);f.a0){c+=i.n.a+i.o.a/2;++l;}for(o=new Anb(i.j);o.a0&&(c/=l);r=$C(iE,vxe,28,d.a.c.length,15,1);h=0;for(j=new Anb(d.a);j.a=h&&e<=i){if(h<=e&&f<=i){d+=2;}else if(h<=e){a.b[d]=i+1;g+=2;}else if(f<=i){c[k++]=e;c[k++]=h-1;d+=2;}else {c[k++]=e;c[k++]=h-1;a.b[d]=i+1;g+=2;}}else if(i2){k=new bnb;Tmb(k,new Rkb(r,1,r.b));f=jTb(k,t+a.a);s=new ORb(f);kQb(s,b);ZEb(c.c,s);}else {d?(s=RD(Wjb(a.b,JGd(b)),272)):(s=RD(Wjb(a.b,LGd(b)),272));}i=JGd(b);d&&(i=LGd(b));g=qTb(q,i);j=t+a.a;if(g.a){j+=$wnd.Math.abs(q.b-l.b);p=new rjd(l.a,(l.b+q.b)/2);}else {j+=$wnd.Math.abs(q.a-l.a);p=new rjd((l.a+q.a)/2,l.b);}d?Zjb(a.d,b,new QRb(s,g,p,j)):Zjb(a.c,b,new QRb(s,g,p,j));Zjb(a.b,b,s);o=(!b.n&&(b.n=new C5d(I4,b,1,7)),b.n);for(n=new dMd(o);n.e!=n.i.gc();){m=RD(bMd(n),135);e=nTb(a,m,true,0,0);ZEb(c.c,e);}} + function sMb(a){var b,c,d,e,f,g,h;if(a.A.dc()){return}if(a.A.Hc((Qpd(),Opd))){RD(Vrb(a.b,(qpd(),Yod)),127).k=true;RD(Vrb(a.b,npd),127).k=true;b=a.q!=(Bod(),xod)&&a.q!=wod;QJb(RD(Vrb(a.b,Xod),127),b);QJb(RD(Vrb(a.b,ppd),127),b);QJb(a.g,b);if(a.A.Hc(Ppd)){RD(Vrb(a.b,Yod),127).j=true;RD(Vrb(a.b,npd),127).j=true;RD(Vrb(a.b,Xod),127).k=true;RD(Vrb(a.b,ppd),127).k=true;a.g.k=true;}}if(a.A.Hc(Npd)){a.a.j=true;a.a.k=true;a.g.j=true;a.g.k=true;h=a.B.Hc((dqd(),_pd));for(e=nMb(),f=0,g=e.length;f0),RD(k.a.Xb(k.c=--k.b),18));while(f!=d&&k.b>0){a.a[f.p]=true;a.a[d.p]=true;f=(sFb(k.b>0),RD(k.a.Xb(k.c=--k.b),18));}k.b>0&&Ckb(k);}}}}} + function Zyb(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;if(!a.b){return false}g=null;m=null;i=new Fzb(null,null);e=1;i.a[1]=a.b;l=i;while(l.a[e]){j=e;h=m;m=l;l=l.a[e];d=a.a.Ne(b,l.d);e=d<0?0:1;d==0&&(!c.c||Fvb(l.e,c.d))&&(g=l);if(!(!!l&&l.b)&&!Vyb(l.a[e])){if(Vyb(l.a[1-e])){m=m.a[j]=azb(l,e);}else if(!Vyb(l.a[1-e])){n=m.a[1-j];if(n){if(!Vyb(n.a[1-j])&&!Vyb(n.a[j])){m.b=false;n.b=true;l.b=true;}else {f=h.a[1]==m?1:0;Vyb(n.a[j])?(h.a[f]=_yb(m,j)):Vyb(n.a[1-j])&&(h.a[f]=azb(m,j));l.b=h.a[f].b=true;h.a[f].a[0].b=false;h.a[f].a[1].b=false;}}}}}if(g){c.b=true;c.d=g.e;if(l!=g){k=new Fzb(l.d,l.e);$yb(a,i,g,k);m==g&&(m=k);}m.a[m.a[1]==l?1:0]=l.a[!l.a[0]?1:0];--a.c;}a.b=i.a[1];!!a.b&&(a.b.b=false);return c.b} + function Ilc(a){var b,c,d,e,f,g,h,i,j,k,l,m;for(e=new Anb(a.a.a.b);e.a0?(e-=86400000):(e+=86400000);i=new wB(Bdb(Hdb(b.q.getTime()),e));}k=new cib;j=a.a.length;for(f=0;f=97&&d<=122||d>=65&&d<=90){for(g=f+1;g=j){throw Adb(new agb("Missing trailing '"))}g+1=14&&k<=16))){if(b.a._b(d)){!c.a?(c.a=new dib(c.d)):Zhb(c.a,c.b);Whb(c.a,'[...]');}else {h=SD(d);j=new btb(b);Gyb(c,Inb(h,j));}}else ZD(d,183)?Gyb(c,hob(RD(d,183))):ZD(d,195)?Gyb(c,aob(RD(d,195))):ZD(d,201)?Gyb(c,bob(RD(d,201))):ZD(d,2111)?Gyb(c,gob(RD(d,2111))):ZD(d,53)?Gyb(c,eob(RD(d,53))):ZD(d,376)?Gyb(c,fob(RD(d,376))):ZD(d,846)?Gyb(c,dob(RD(d,846))):ZD(d,109)&&Gyb(c,cob(RD(d,109)));}else {Gyb(c,d==null?vve:jeb(d));}}return !c.a?c.c:c.e.length==0?c.a.a:c.a.a+(''+c.e)} + function KXd(a,b){var c,d,e,f;f=a.F;if(b==null){a.F=null;yXd(a,null);}else {a.F=(uFb(b),b);d=qhb(b,Fhb(60));if(d!=-1){e=(AFb(0,d,b.length),b.substr(0,d));qhb(b,Fhb(46))==-1&&!lhb(e,hve)&&!lhb(e,dKe)&&!lhb(e,eKe)&&!lhb(e,fKe)&&!lhb(e,gKe)&&!lhb(e,hKe)&&!lhb(e,iKe)&&!lhb(e,jKe)&&(e=kKe);c=thb(b,Fhb(62));c!=-1&&(e+=''+(BFb(c+1,b.length+1),b.substr(c+1)));yXd(a,e);}else {e=b;if(qhb(b,Fhb(46))==-1){d=qhb(b,Fhb(91));d!=-1&&(e=(AFb(0,d,b.length),b.substr(0,d)));if(!lhb(e,hve)&&!lhb(e,dKe)&&!lhb(e,eKe)&&!lhb(e,fKe)&&!lhb(e,gKe)&&!lhb(e,hKe)&&!lhb(e,iKe)&&!lhb(e,jKe)){e=kKe;d!=-1&&(e+=''+(BFb(d,b.length+1),b.substr(d)));}else {e=b;}}yXd(a,e);e==b&&(a.F=a.D);}}(a.Db&4)!=0&&(a.Db&1)==0&&qvd(a,new N3d(a,1,5,f,b));} + function Pvd(b,c){var d,e,f,g,h,i,j,k,l,m;j=c.length-1;i=(BFb(j,c.length),c.charCodeAt(j));if(i==93){h=qhb(c,Fhb(91));if(h>=0){f=Uvd(b,(AFb(1,h,c.length),c.substr(1,h-1)));l=(AFb(h+1,j,c.length),c.substr(h+1,j-(h+1)));return Nvd(b,l,f)}}else {d=-1;_eb==null&&(_eb=new RegExp('\\d'));if(_eb.test(String.fromCharCode(i))){d=uhb(c,Fhb(46),j-1);if(d>=0){e=RD(Fvd(b,Zvd(b,(AFb(1,d,c.length),c.substr(1,d-1))),false),61);k=0;try{k=Oeb((BFb(d+1,c.length+1),c.substr(d+1)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){g=a;throw Adb(new RSd(g))}else throw Adb(a)}if(k>16==-10){c=RD(a.Cb,292).Yk(b,c);}else if(a.Db>>16==-15){!b&&(b=(JTd(),wTd));!j&&(j=(JTd(),wTd));if(a.Cb.Yh()){i=new P3d(a.Cb,1,13,j,b,fZd(o4d(RD(a.Cb,62)),a),false);!c?(c=i):c.nj(i);}}}else if(ZD(a.Cb,90)){if(a.Db>>16==-23){ZD(b,90)||(b=(JTd(),zTd));ZD(j,90)||(j=(JTd(),zTd));if(a.Cb.Yh()){i=new P3d(a.Cb,1,10,j,b,fZd(tYd(RD(a.Cb,29)),a),false);!c?(c=i):c.nj(i);}}}else if(ZD(a.Cb,457)){h=RD(a.Cb,850);g=(!h.b&&(h.b=new pae(new lae)),h.b);for(f=(d=new vkb((new mkb(g.a)).a),new xae(d));f.a.b;){e=RD(tkb(f.a).ld(),89);c=o2d(e,k2d(e,h),c);}}}return c} + function Y4b(a,b){var c,d,e,f,g,h,i,j,k,l,m;g=Heb(TD(Gxd(a,(yCc(),NAc))));m=RD(Gxd(a,EBc),21);i=false;j=false;l=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));while(l.e!=l.i.gc()&&(!i||!j)){f=RD(bMd(l),123);h=0;for(e=Fl(Al(cD(WC(cJ,1),rve,20,0,[(!f.d&&(f.d=new Yie(G4,f,8,5)),f.d),(!f.e&&(f.e=new Yie(G4,f,7,4)),f.e)])));gs(e);){d=RD(hs(e),74);k=g&&ozd(d)&&Heb(TD(Gxd(d,OAc)));c=cZd((!d.b&&(d.b=new Yie(E4,d,4,7)),d.b),f)?a==vCd(AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))):a==vCd(AGd(RD(QHd((!d.b&&(d.b=new Yie(E4,d,4,7)),d.b),0),84)));if(k||c){++h;if(h>1){break}}}h>0?(i=true):m.Hc((Pod(),Lod))&&(!f.n&&(f.n=new C5d(I4,f,1,7)),f.n).i>0&&(i=true);h>1&&(j=true);}i&&b.Fc((ovc(),hvc));j&&b.Fc((ovc(),ivc));} + function Dsd(a){var b,c,d,e,f,g,h,i,j,k,l,m;m=RD(Gxd(a,(umd(),kld)),21);if(m.dc()){return null}h=0;g=0;if(m.Hc((Qpd(),Opd))){k=RD(Gxd(a,Hld),101);d=2;c=2;e=2;f=2;b=!vCd(a)?RD(Gxd(a,Nkd),88):RD(Gxd(vCd(a),Nkd),88);for(j=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));j.e!=j.i.gc();){i=RD(bMd(j),123);l=RD(Gxd(i,Old),64);if(l==(qpd(),opd)){l=osd(i,b);Ixd(i,Old,l);}if(k==(Bod(),wod)){switch(l.g){case 1:d=$wnd.Math.max(d,i.i+i.g);break;case 2:c=$wnd.Math.max(c,i.j+i.f);break;case 3:e=$wnd.Math.max(e,i.i+i.g);break;case 4:f=$wnd.Math.max(f,i.j+i.f);}}else {switch(l.g){case 1:d+=i.g+2;break;case 2:c+=i.f+2;break;case 3:e+=i.g+2;break;case 4:f+=i.f+2;}}}h=$wnd.Math.max(d,e);g=$wnd.Math.max(c,f);}return Esd(a,h,g,true,true)} + function Rqc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;s=RD(zDb(PDb(CDb(new SDb(null,new Swb(b.d,16)),new Vqc(c)),new Xqc(c)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);l=lve;k=qwe;for(i=new Anb(b.b.j);i.a0;if(j){if(j){m=r.p;g?++m:--m;l=RD(Vmb(r.c.a,m),10);d=Z7b(l);n=!(Did(d,w,c[0])||yid(d,w,c[0]));}}else {n=true;}}o=false;v=b.D.i;if(!!v&&!!v.c&&h.e){k=g&&v.p>0||!g&&v.p=0){i=null;h=new Jkb(k.a,j+1);while(h.bg?1:cz(isNaN(0),isNaN(g)))<0&&(bz(vEe),($wnd.Math.abs(g-1)<=vEe||g==1||isNaN(g)&&isNaN(1)?0:g<1?-1:g>1?1:cz(isNaN(g),isNaN(1)))<0)&&(bz(vEe),($wnd.Math.abs(0-h)<=vEe||0==h||isNaN(0)&&isNaN(h)?0:0h?1:cz(isNaN(0),isNaN(h)))<0)&&(bz(vEe),($wnd.Math.abs(h-1)<=vEe||h==1||isNaN(h)&&isNaN(1)?0:h<1?-1:h>1?1:cz(isNaN(h),isNaN(1)))<0));return f} + function EXd(b){var c,d,e,f;d=b.D!=null?b.D:b.B;c=qhb(d,Fhb(91));if(c!=-1){e=(AFb(0,c,d.length),d.substr(0,c));f=new Qhb;do f.a+='[';while((c=phb(d,91,++c))!=-1);if(lhb(e,hve))f.a+='Z';else if(lhb(e,dKe))f.a+='B';else if(lhb(e,eKe))f.a+='C';else if(lhb(e,fKe))f.a+='D';else if(lhb(e,gKe))f.a+='F';else if(lhb(e,hKe))f.a+='I';else if(lhb(e,iKe))f.a+='J';else if(lhb(e,jKe))f.a+='S';else {f.a+='L';f.a+=''+e;f.a+=';';}try{return null}catch(a){a=zdb(a);if(!ZD(a,63))throw Adb(a)}}else if(qhb(d,Fhb(46))==-1){if(lhb(d,hve))return xdb;else if(lhb(d,dKe))return gE;else if(lhb(d,eKe))return hE;else if(lhb(d,fKe))return iE;else if(lhb(d,gKe))return jE;else if(lhb(d,hKe))return kE;else if(lhb(d,iKe))return lE;else if(lhb(d,jKe))return wdb}return null} + function pTb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;a.e=b;h=RSb(b);w=new bnb;for(d=new Anb(h);d.a=0&&p=j.c.c.length?(k=hOc((r3b(),p3b),o3b)):(k=hOc((r3b(),o3b),o3b));k*=2;f=c.a.g;c.a.g=$wnd.Math.max(f,f+(k-f));g=c.b.g;c.b.g=$wnd.Math.max(g,g+(k-g));e=b;}}} + function qkc(a){var b,c,d,e;FDb(CDb(new SDb(null,new Swb(a.a.b,16)),new Qkc),new Skc);okc(a);FDb(CDb(new SDb(null,new Swb(a.a.b,16)),new Ukc),new Wkc);if(a.c==(Ymd(),Wmd)){FDb(CDb(EDb(new SDb(null,new Swb(new Xkb(a.f),1)),new clc),new elc),new glc(a));FDb(CDb(GDb(EDb(EDb(new SDb(null,new Swb(a.d.b,16)),new klc),new mlc),new olc),new qlc),new slc(a));}e=new rjd(oxe,oxe);b=new rjd(pxe,pxe);for(d=new Anb(a.a.b);d.a0&&(b.a+=pve,b);Csd(RD(bMd(h),167),b);}b.a+=SAe;i=new mMd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c));while(i.e!=i.i.gc()){i.e>0&&(b.a+=pve,b);Csd(RD(bMd(i),167),b);}b.a+=')';}}} + function LTb(a,b,c){var d,e,f,g,h,i,j,k;for(i=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));i.e!=i.i.gc();){h=RD(bMd(i),27);for(e=new is(Mr(zGd(h).a.Kc(),new ir));gs(e);){d=RD(hs(e),74);!d.b&&(d.b=new Yie(E4,d,4,7));if(!(d.b.i<=1&&(!d.c&&(d.c=new Yie(E4,d,5,8)),d.c.i<=1))){throw Adb(new Ked('Graph must not contain hyperedges.'))}if(!nzd(d)&&h!=AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))){j=new cUb;kQb(j,d);pQb(j,(JVb(),HVb),d);_Tb(j,RD(Wd(qtb(c.f,h)),153));aUb(j,RD(Wjb(c,AGd(RD(QHd((!d.c&&(d.c=new Yie(E4,d,5,8)),d.c),0),84))),153));Rmb(b.c,j);for(g=new dMd((!d.n&&(d.n=new C5d(I4,d,1,7)),d.n));g.e!=g.i.gc();){f=RD(bMd(g),135);k=new iUb(j,f.a);kQb(k,f);pQb(k,HVb,f);k.e.a=$wnd.Math.max(f.g,1);k.e.b=$wnd.Math.max(f.f,1);hUb(k);Rmb(b.d,k);}}}}} + function Vec(a,b,c){var d,e,f,g,h,i,j,k,l,m;c.Ug('Node promotion heuristic',1);a.i=b;a.r=RD(mQb(b,(yCc(),ZAc)),243);a.r!=(aEc(),TDc)&&a.r!=UDc?Tec(a):Uec(a);k=RD(mQb(a.i,YAc),17).a;f=new nfc;switch(a.r.g){case 2:case 1:Yec(a,f);break;case 3:a.r=_Dc;Yec(a,f);i=0;for(h=new Anb(a.b);h.aa.k){a.r=VDc;Yec(a,f);}break;case 4:a.r=_Dc;Yec(a,f);j=0;for(e=new Anb(a.c);e.aa.n){a.r=YDc;Yec(a,f);}break;case 6:m=eE($wnd.Math.ceil(a.g.length*k/100));Yec(a,new qfc(m));break;case 5:l=eE($wnd.Math.ceil(a.e*k/100));Yec(a,new tfc(l));break;case 8:Sec(a,true);break;case 9:Sec(a,false);break;default:Yec(a,f);}a.r!=TDc&&a.r!=UDc?Zec(a,b):$ec(a,b);c.Vg();} + function $rc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;l=a.b;k=new Jkb(l,0);Ikb(k,new R4b(a));s=false;g=1;while(k.b0){m.d+=k.n.d;m.d+=k.d;}if(m.a>0){m.a+=k.n.a;m.a+=k.d;}if(m.b>0){m.b+=k.n.b;m.b+=k.d;}if(m.c>0){m.c+=k.n.c;m.c+=k.d;}return m} + function u9b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o;m=c.d;l=c.c;f=new rjd(c.f.a+c.d.b+c.d.c,c.f.b+c.d.d+c.d.a);g=f.b;for(j=new Anb(a.a);j.a0){a.c[b.c.p][b.p].d+=Kwb(a.i,24)*Nxe*0.07000000029802322-0.03500000014901161;a.c[b.c.p][b.p].a=a.c[b.c.p][b.p].d/a.c[b.c.p][b.p].b;}} + function D8b(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;for(o=new Anb(a);o.ad.d;d.d=$wnd.Math.max(d.d,b);if(h&&c){d.d=$wnd.Math.max(d.d,d.a);d.a=d.d+e;}break;case 3:c=b>d.a;d.a=$wnd.Math.max(d.a,b);if(h&&c){d.a=$wnd.Math.max(d.a,d.d);d.d=d.a+e;}break;case 2:c=b>d.c;d.c=$wnd.Math.max(d.c,b);if(h&&c){d.c=$wnd.Math.max(d.b,d.c);d.b=d.c+e;}break;case 4:c=b>d.b;d.b=$wnd.Math.max(d.b,b);if(h&&c){d.b=$wnd.Math.max(d.b,d.c);d.c=d.b+e;}}}}} + function pA(a,b){var c,d,e,f,g,h,i,j,k;j='';if(b.length==0){return a.ne(ywe,wwe,-1,-1)}k=Dhb(b);lhb(k.substr(0,3),'at ')&&(k=(BFb(3,k.length+1),k.substr(3)));k=k.replace(/\[.*?\]/g,'');g=k.indexOf('(');if(g==-1){g=k.indexOf('@');if(g==-1){j=k;k='';}else {j=Dhb((BFb(g+1,k.length+1),k.substr(g+1)));k=Dhb((AFb(0,g,k.length),k.substr(0,g)));}}else {c=k.indexOf(')',g);j=(AFb(g+1,c,k.length),k.substr(g+1,c-(g+1)));k=Dhb((AFb(0,g,k.length),k.substr(0,g)));}g=qhb(k,Fhb(46));g!=-1&&(k=(BFb(g+1,k.length+1),k.substr(g+1)));(k.length==0||lhb(k,'Anonymous function'))&&(k=wwe);h=thb(j,Fhb(58));e=uhb(j,Fhb(58),h-1);i=-1;d=-1;f=ywe;if(h!=-1&&e!=-1){f=(AFb(0,e,j.length),j.substr(0,e));i=jA((AFb(e+1,h,j.length),j.substr(e+1,h-(e+1))));d=jA((BFb(h+1,j.length+1),j.substr(h+1)));}return a.ne(f,k,i,d)} + function C6b(a){var b,c,d,e,f,g,h,i,j,k,l;for(j=new Anb(a);j.a0||k.j==ppd&&k.e.c.length-k.g.c.length<0)){b=false;break}for(e=new Anb(k.g);e.a=j&&v>=q){m+=o.n.b+p.n.b+p.a.b-u;++h;}}}}if(c){for(g=new Anb(s.e);g.a=j&&v>=q){m+=o.n.b+p.n.b+p.a.b-u;++h;}}}}}if(h>0){w+=m/h;++n;}}if(n>0){b.a=e*w/n;b.g=n;}else {b.a=0;b.g=0;}} + function hTb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;f=a.f.b;m=f.a;k=f.b;o=a.e.g;n=a.e.f;zyd(a.e,f.a,f.b);w=m/o;A=k/n;for(j=new dMd(iyd(a.e));j.e!=j.i.gc();){i=RD(bMd(j),135);Dyd(i,i.i*w);Eyd(i,i.j*A);}for(s=new dMd(wCd(a.e));s.e!=s.i.gc();){r=RD(bMd(s),123);u=r.i;v=r.j;u>0&&Dyd(r,u*w);v>0&&Eyd(r,v*A);}Bvb(a.b,new tTb);b=new bnb;for(h=new vkb((new mkb(a.c)).a);h.b;){g=tkb(h);d=RD(g.ld(),74);c=RD(g.md(),407).a;e=IGd(d,false,false);l=fTb(JGd(d),ssd(e),c);lsd(l,e);t=KGd(d);if(!!t&&Wmb(b,t,0)==-1){ZEb(b.c,t);gTb(t,(sFb(l.b!=0),RD(l.a.a.c,8)),c);}}for(q=new vkb((new mkb(a.d)).a);q.b;){p=tkb(q);d=RD(p.ld(),74);c=RD(p.md(),407).a;e=IGd(d,false,false);l=fTb(LGd(d),Ijd(ssd(e)),c);l=Ijd(l);lsd(l,e);t=MGd(d);if(!!t&&Wmb(b,t,0)==-1){ZEb(b.c,t);gTb(t,(sFb(l.b!=0),RD(l.c.b.c,8)),c);}}} + function GJb(a,b,c,d){var e,f,g,h,i;h=new CLb(b);iNb(h,d);e=true;if(!!a&&a.pf((umd(),Nkd))){f=RD(a.of((umd(),Nkd)),88);e=f==(Cmd(),Amd)||f==ymd||f==zmd;}$Mb(h,false);Umb(h.e.Rf(),new dNb(h,false,e));EMb(h,h.f,(ZJb(),WJb),(qpd(),Yod));EMb(h,h.f,YJb,npd);EMb(h,h.g,WJb,ppd);EMb(h,h.g,YJb,Xod);GMb(h,Yod);GMb(h,npd);FMb(h,Xod);FMb(h,ppd);RMb();g=h.A.Hc((Qpd(),Mpd))&&h.B.Hc((dqd(),$pd))?SMb(h):null;!!g&&uKb(h.a,g);XMb(h);xMb(h);GNb(h);sMb(h);gNb(h);yNb(h);oNb(h,Yod);oNb(h,npd);tMb(h);fNb(h);if(!c){return h.o}VMb(h);CNb(h);oNb(h,Xod);oNb(h,ppd);i=h.B.Hc((dqd(),_pd));IMb(h,i,Yod);IMb(h,i,npd);JMb(h,i,Xod);JMb(h,i,ppd);FDb(new SDb(null,new Swb(new glb(h.i),0)),new KMb);FDb(CDb(new SDb(null,ki(h.r).a.oc()),new MMb),new OMb);WMb(h);h.e.Pf(h.o);FDb(new SDb(null,ki(h.r).a.oc()),new YMb);return h.o} + function LYb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;j=oxe;for(d=new Anb(a.a.b);d.a1){n=new xVc(o,t,d);xgb(t,new nVc(a,n));ZEb(g.c,n);for(l=t.a.ec().Kc();l.Ob();){k=RD(l.Pb(),42);Ymb(f,k.b);}}if(h.a.gc()>1){n=new xVc(o,h,d);xgb(h,new pVc(a,n));ZEb(g.c,n);for(l=h.a.ec().Kc();l.Ob();){k=RD(l.Pb(),42);Ymb(f,k.b);}}}} + function p6b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;p=a.n;q=a.o;m=a.d;l=Kfb(UD(hFc(a,(yCc(),QBc))));if(b){k=l*(b.gc()-1);n=0;for(i=b.Kc();i.Ob();){g=RD(i.Pb(),10);k+=g.o.a;n=$wnd.Math.max(n,g.o.b);}r=p.a-(k-q.a)/2;f=p.b-m.d+n;d=q.a/(b.gc()+1);e=d;for(h=b.Kc();h.Ob();){g=RD(h.Pb(),10);g.n.a=r;g.n.b=f-g.o.b;r+=g.o.a+l;j=n6b(g);j.n.a=g.o.a/2-j.a.a;j.n.b=g.o.b;o=RD(mQb(g,(Ywc(),Xvc)),12);if(o.e.c.length+o.g.c.length==1){o.n.a=e-o.a.a;o.n.b=0;P3b(o,a);}e+=d;}}if(c){k=l*(c.gc()-1);n=0;for(i=c.Kc();i.Ob();){g=RD(i.Pb(),10);k+=g.o.a;n=$wnd.Math.max(n,g.o.b);}r=p.a-(k-q.a)/2;f=p.b+q.b+m.a-n;d=q.a/(c.gc()+1);e=d;for(h=c.Kc();h.Ob();){g=RD(h.Pb(),10);g.n.a=r;g.n.b=f;r+=g.o.a+l;j=n6b(g);j.n.a=g.o.a/2-j.a.a;j.n.b=0;o=RD(mQb(g,(Ywc(),Xvc)),12);if(o.e.c.length+o.g.c.length==1){o.n.a=e-o.a.a;o.n.b=q.b;P3b(o,a);}e+=d;}}} + function Hac(a,b){var c,d,e,f,g,h;if(!RD(mQb(b,(Ywc(),kwc)),21).Hc((ovc(),hvc))){return}for(h=new Anb(b.a);h.a=0&&g0&&(RD(Vrb(a.b,b),127).a.b=c);} + function wcc(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;m=Kfb(UD(mQb(a,(yCc(),_Bc))));n=Kfb(UD(mQb(a,aCc)));l=Kfb(UD(mQb(a,ZBc)));h=a.o;f=RD(Vmb(a.j,0),12);g=f.n;p=ucc(f,l);if(!p){return}if(b.Hc((Pod(),Lod))){switch(RD(mQb(a,(Ywc(),hwc)),64).g){case 1:p.c=(h.a-p.b)/2-g.a;p.d=n;break;case 3:p.c=(h.a-p.b)/2-g.a;p.d=-n-p.a;break;case 2:if(c&&f.e.c.length==0&&f.g.c.length==0){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=h.b+n-g.b;}p.c=-m-p.b;break;case 4:if(c&&f.e.c.length==0&&f.g.c.length==0){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=h.b+n-g.b;}p.c=m;}}else if(b.Hc(Nod)){switch(RD(mQb(a,(Ywc(),hwc)),64).g){case 1:case 3:p.c=g.a+m;break;case 2:case 4:if(c&&!f.c){k=d?p.a:RD(Vmb(f.f,0),72).o.b;p.d=(h.b-k)/2-g.b;}else {p.d=g.b+n;}}}e=p.d;for(j=new Anb(f.f);j.a=b.length)return {done:true};var a=b[d++];return {value:[a,c.get(a)],done:false}}}};if(!Ftb()){e.prototype.createObject=function(){return {}};e.prototype.get=function(a){return this.obj[':'+a]};e.prototype.set=function(a,b){this.obj[':'+a]=b;};e.prototype[Jxe]=function(a){delete this.obj[':'+a];};e.prototype.keys=function(){var a=[];for(var b in this.obj){b.charCodeAt(0)==58&&a.push(b.substring(1));}return a};}return e} + function q$c(){q$c=geb;h$c=new jGd(rAe);new kGd('DEPTH',sgb(0));XZc=new kGd('FAN',sgb(0));VZc=new kGd(QEe,sgb(0));n$c=new kGd('ROOT',(Geb(),false));b$c=new kGd('LEFTNEIGHBOR',null);l$c=new kGd('RIGHTNEIGHBOR',null);c$c=new kGd('LEFTSIBLING',null);m$c=new kGd('RIGHTSIBLING',null);WZc=new kGd('DUMMY',false);new kGd('LEVEL',sgb(0));k$c=new kGd('REMOVABLE_EDGES',new Yub);o$c=new kGd('XCOOR',sgb(0));p$c=new kGd('YCOOR',sgb(0));d$c=new kGd('LEVELHEIGHT',0);f$c=new kGd('LEVELMIN',0);e$c=new kGd('LEVELMAX',0);ZZc=new kGd('GRAPH_XMIN',0);_Zc=new kGd('GRAPH_YMIN',0);YZc=new kGd('GRAPH_XMAX',0);$Zc=new kGd('GRAPH_YMAX',0);UZc=new kGd('COMPACT_LEVEL_ASCENSION',false);TZc=new kGd('COMPACT_CONSTRAINTS',new bnb);a$c=new kGd('ID','');i$c=new kGd('POSITION',sgb(0));j$c=new kGd('PRELIM',0);g$c=new kGd('MODIFIER',0);SZc=new jGd(tAe);RZc=new jGd(uAe);} + function Bqe(a){zqe();var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(a==null)return null;l=a.length*8;if(l==0){return ''}h=l%24;n=l/24|0;m=h!=0?n+1:n;f=null;f=$C(hE,zwe,28,m*4,15,1);j=0;k=0;b=0;c=0;d=0;g=0;e=0;for(i=0;i>24;j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;p=(c&-128)==0?c>>4<<24>>24:(c>>4^240)<<24>>24;q=(d&-128)==0?d>>6<<24>>24:(d>>6^252)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[p|j<<4];f[g++]=yqe[k<<2|q];f[g++]=yqe[d&63];}if(h==8){b=a[e];j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[j<<4];f[g++]=61;f[g++]=61;}else if(h==16){b=a[e];c=a[e+1];k=(c&15)<<24>>24;j=(b&3)<<24>>24;o=(b&-128)==0?b>>2<<24>>24:(b>>2^192)<<24>>24;p=(c&-128)==0?c>>4<<24>>24:(c>>4^240)<<24>>24;f[g++]=yqe[o];f[g++]=yqe[p|j<<4];f[g++]=yqe[k<<2];f[g++]=61;}return Ihb(f,0,f.length)} + function CB(a,b){var c,d,e,f,g,h,i;a.e==0&&a.p>0&&(a.p=-(a.p-1));a.p>qwe&&tB(b,a.p-Owe);g=b.q.getDate();nB(b,1);a.k>=0&&qB(b,a.k);if(a.c>=0){nB(b,a.c);}else if(a.k>=0){i=new vB(b.q.getFullYear()-Owe,b.q.getMonth(),35);d=35-i.q.getDate();nB(b,$wnd.Math.min(d,g));}else {nB(b,g);}a.f<0&&(a.f=b.q.getHours());a.b>0&&a.f<12&&(a.f+=12);oB(b,a.f==24&&a.g?0:a.f);a.j>=0&&pB(b,a.j);a.n>=0&&rB(b,a.n);a.i>=0&&sB(b,Bdb(Ndb(Fdb(Hdb(b.q.getTime()),Awe),Awe),a.i));if(a.a){e=new uB;tB(e,e.q.getFullYear()-Owe-80);Ldb(Hdb(b.q.getTime()),Hdb(e.q.getTime()))&&tB(b,e.q.getFullYear()-Owe+100);}if(a.d>=0){if(a.c==-1){c=(7+a.d-b.q.getDay())%7;c>3&&(c-=7);h=b.q.getMonth();nB(b,b.q.getDate()+c);b.q.getMonth()!=h&&nB(b,b.q.getDate()+(c>0?-7:7));}else {if(b.q.getDay()!=a.d){return false}}}if(a.o>qwe){f=b.q.getTimezoneOffset();sB(b,Bdb(Hdb(b.q.getTime()),(a.o-f)*60*Awe));}return true} + function J5b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;e=mQb(b,(Ywc(),Awc));if(!ZD(e,207)){return}o=RD(e,27);p=b.e;m=new sjd(b.c);f=b.d;m.a+=f.b;m.b+=f.d;u=RD(Gxd(o,(yCc(),oBc)),181);if(Csb(u,(dqd(),Xpd))){n=RD(Gxd(o,qBc),107);E2b(n,f.a);H2b(n,f.d);F2b(n,f.b);G2b(n,f.c);}c=new bnb;for(k=new Anb(b.a);k.ad.c.length-1){Rmb(d,new Ptd(Hze,KEe));}c=RD(mQb(e,f_c),17).a;if(Dmd(RD(mQb(a,H$c),88))){e.e.aKfb(UD((tFb(c,d.c.length),RD(d.c[c],42)).b))&&Otd((tFb(c,d.c.length),RD(d.c[c],42)),e.e.a+e.f.a);}else {e.e.bKfb(UD((tFb(c,d.c.length),RD(d.c[c],42)).b))&&Otd((tFb(c,d.c.length),RD(d.c[c],42)),e.e.b+e.f.b);}}for(f=Sub(a.b,0);f.b!=f.d.c;){e=RD(evb(f),40);c=RD(mQb(e,(h_c(),f_c)),17).a;pQb(e,(q$c(),f$c),UD((tFb(c,d.c.length),RD(d.c[c],42)).a));pQb(e,e$c,UD((tFb(c,d.c.length),RD(d.c[c],42)).b));}b.Vg();} + function Tec(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;a.o=Kfb(UD(mQb(a.i,(yCc(),bCc))));a.f=Kfb(UD(mQb(a.i,XBc)));a.j=a.i.b.c.length;h=a.j-1;m=0;a.k=0;a.n=0;a.b=dv($C(bJ,Nve,17,a.j,0,1));a.c=dv($C(VI,Nve,345,a.j,7,1));for(g=new Anb(a.i.b);g.a0&&Rmb(a.q,k);Rmb(a.p,k);}b-=d;n=i+b;j+=b*a.f;$mb(a.b,h,sgb(n));$mb(a.c,h,j);a.k=$wnd.Math.max(a.k,n);a.n=$wnd.Math.max(a.n,j);a.e+=b;b+=p;}} + function qpd(){qpd=geb;var a;opd=new upd(Sye,0);Yod=new upd(_ye,1);Xod=new upd(aze,2);npd=new upd(bze,3);ppd=new upd(cze,4);bpd=(yob(),new Lqb((a=RD(mfb(E3),9),new Fsb(a,RD(WEb(a,a.length),9),0))));cpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[])));Zod=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[])));kpd=eq(ysb(npd,cD(WC(E3,1),NAe,64,0,[])));mpd=eq(ysb(ppd,cD(WC(E3,1),NAe,64,0,[])));hpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[npd])));apd=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[ppd])));jpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[ppd])));dpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod])));lpd=eq(ysb(npd,cD(WC(E3,1),NAe,64,0,[ppd])));$od=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[npd])));gpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,ppd])));_od=eq(ysb(Xod,cD(WC(E3,1),NAe,64,0,[npd,ppd])));ipd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[npd,ppd])));epd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,npd])));fpd=eq(ysb(Yod,cD(WC(E3,1),NAe,64,0,[Xod,npd,ppd])));} + function Gfc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A;b.Ug(qBe,1);p=new bnb;w=new bnb;for(j=new Anb(a.b);j.a0&&(t-=n);p2b(g,t);k=0;for(m=new Anb(g.a);m.a0);h.a.Xb(h.c=--h.b);}i=0.4*d*k;!f&&h.b0){j=(BFb(0,c.length),c.charCodeAt(0));if(j!=64){if(j==37){m=c.lastIndexOf('%');k=false;if(m!=0&&(m==n-1||(k=(BFb(m+1,c.length),c.charCodeAt(m+1)==46)))){h=(AFb(1,m,c.length),c.substr(1,m-1));u=lhb('%',h)?null:oSd(h);e=0;if(k){try{e=Oeb((BFb(m+2,c.length+1),c.substr(m+2)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){i=a;throw Adb(new RSd(i))}else throw Adb(a)}}for(r=P2d(b.Gh());r.Ob();){p=k3d(r);if(ZD(p,519)){f=RD(p,598);t=f.d;if((u==null?t==null:lhb(u,t))&&e--==0){return f}}}return null}}l=c.lastIndexOf('.');o=l==-1?c:(AFb(0,l,c.length),c.substr(0,l));d=0;if(l!=-1){try{d=Oeb((BFb(l+1,c.length+1),c.substr(l+1)),qwe,lve);}catch(a){a=zdb(a);if(ZD(a,130)){o=c;}else throw Adb(a)}}o=lhb('%',o)?null:oSd(o);for(q=P2d(b.Gh());q.Ob();){p=k3d(q);if(ZD(p,197)){g=RD(p,197);s=g.xe();if((o==null?s==null:lhb(o,s))&&d--==0){return g}}}return null}}return Pvd(b,c)} + function Hlc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;k=new Tsb;i=new Tp;for(d=new Anb(a.a.a.b);d.ab.d.c){n=a.c[b.a.d];q=a.c[l.a.d];if(n==q){continue}rIb(uIb(tIb(vIb(sIb(new wIb,1),100),n),q));}}}}}}} + function mNb(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;m=RD(RD(Qc(a.r,b),21),87);if(b==(qpd(),Xod)||b==ppd){qNb(a,b);return}f=b==Yod?(mOb(),iOb):(mOb(),lOb);u=b==Yod?(vLb(),uLb):(vLb(),sLb);c=RD(Vrb(a.b,b),127);d=c.i;e=d.c+Hid(cD(WC(iE,1),vxe,28,15,[c.n.b,a.C.b,a.k]));r=d.c+d.b-Hid(cD(WC(iE,1),vxe,28,15,[c.n.c,a.C.c,a.k]));g=WNb(_Nb(f),a.t);s=b==Yod?pxe:oxe;for(l=m.Kc();l.Ob();){j=RD(l.Pb(),117);if(!j.c||j.c.d.c.length<=0){continue}q=j.b.Mf();p=j.e;n=j.c;o=n.i;o.b=(i=n.n,n.e.a+i.b+i.c);o.a=(h=n.n,n.e.b+h.d+h.a);Ivb(u,Pye);n.f=u;RKb(n,(EKb(),DKb));o.c=p.a-(o.b-q.a)/2;v=$wnd.Math.min(e,p.a);w=$wnd.Math.max(r,p.a+q.a);o.cw&&(o.c=w-o.b);Rmb(g.d,new sOb(o,UNb(g,o)));s=b==Yod?$wnd.Math.max(s,p.b+j.b.Mf().b):$wnd.Math.min(s,p.b);}s+=b==Yod?a.t:-a.t;t=VNb((g.e=s,g));t>0&&(RD(Vrb(a.b,b),127).a.b=t);for(k=m.Kc();k.Ob();){j=RD(k.Pb(),117);if(!j.c||j.c.d.c.length<=0){continue}o=j.c.i;o.c-=j.e.a;o.d-=j.e.b;}} + function JSb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;b=new Tsb;for(i=new dMd(a);i.e!=i.i.gc();){h=RD(bMd(i),27);c=new _sb;Zjb(FSb,h,c);n=new TSb;e=RD(zDb(new SDb(null,new Twb(new is(Mr(yGd(h).a.Kc(),new ir)))),OBb(n,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)])))),85);ISb(c,RD(e.xc((Geb(),true)),16),new VSb);d=RD(zDb(CDb(RD(e.xc(false),15).Lc(),new XSb),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);for(g=d.Kc();g.Ob();){f=RD(g.Pb(),74);m=KGd(f);if(m){j=RD(Wd(qtb(b.f,m)),21);if(!j){j=LSb(m);rtb(b.f,m,j);}ye(c,j);}}e=RD(zDb(new SDb(null,new Twb(new is(Mr(zGd(h).a.Kc(),new ir)))),OBb(n,tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb])))),85);ISb(c,RD(e.xc(true),16),new ZSb);d=RD(zDb(CDb(RD(e.xc(false),15).Lc(),new _Sb),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);for(l=d.Kc();l.Ob();){k=RD(l.Pb(),74);m=MGd(k);if(m){j=RD(Wd(qtb(b.f,m)),21);if(!j){j=LSb(m);rtb(b.f,m,j);}ye(c,j);}}}} + function zjb(a,b){xjb();var c,d,e,f,g,h,i,j,k,l,m,n,o,p;i=Ddb(a,0)<0;i&&(a=Odb(a));if(Ddb(a,0)==0){switch(b){case 0:return '0';case 1:return zxe;case 2:return '0.00';case 3:return '0.000';case 4:return '0.0000';case 5:return '0.00000';case 6:return '0.000000';default:n=new bib;b<0?(n.a+='0E+',n):(n.a+='0E',n);n.a+=b==qwe?'2147483648':''+-b;return n.a;}}k=18;l=$C(hE,zwe,28,k+1,15,1);c=k;p=a;do{j=p;p=Fdb(p,10);l[--c]=Ydb(Bdb(48,Vdb(j,Ndb(p,10))))&Bwe;}while(Ddb(p,0)!=0);e=Vdb(Vdb(Vdb(k,c),b),1);if(b==0){i&&(l[--c]=45);return Ihb(l,c,k-c)}if(b>0&&Ddb(e,-6)>=0){if(Ddb(e,0)>=0){f=c+Ydb(e);for(h=k-1;h>=f;h--){l[h+1]=l[h];}l[++f]=46;i&&(l[--c]=45);return Ihb(l,c,k-c+1)}for(g=2;Ldb(g,Bdb(Odb(e),1));g++){l[--c]=48;}l[--c]=46;l[--c]=48;i&&(l[--c]=45);return Ihb(l,c,k-c)}o=c+1;d=k;m=new cib;i&&(m.a+='-',m);if(d-o>=1){Thb(m,l[c]);m.a+='.';m.a+=Ihb(l,c+1,k-c-1);}else {m.a+=Ihb(l,c,k-c);}m.a+='E';Ddb(e,0)>0&&(m.a+='+',m);m.a+=''+Zdb(e);return m.a} + function Esd(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;q=new rjd(a.g,a.f);p=vsd(a);p.a=$wnd.Math.max(p.a,b);p.b=$wnd.Math.max(p.b,c);w=p.a/q.a;k=p.b/q.b;u=p.a-q.a;i=p.b-q.b;if(d){g=!vCd(a)?RD(Gxd(a,(umd(),Nkd)),88):RD(Gxd(vCd(a),(umd(),Nkd)),88);h=dE(Gxd(a,(umd(),Hld)))===dE((Bod(),wod));for(s=new dMd((!a.c&&(a.c=new C5d(K4,a,9,9)),a.c));s.e!=s.i.gc();){r=RD(bMd(s),123);t=RD(Gxd(r,Old),64);if(t==(qpd(),opd)){t=osd(r,g);Ixd(r,Old,t);}switch(t.g){case 1:h||Dyd(r,r.i*w);break;case 2:Dyd(r,r.i+u);h||Eyd(r,r.j*k);break;case 3:h||Dyd(r,r.i*w);Eyd(r,r.j+i);break;case 4:h||Eyd(r,r.j*k);}}}zyd(a,p.a,p.b);if(e){for(m=new dMd((!a.n&&(a.n=new C5d(I4,a,1,7)),a.n));m.e!=m.i.gc();){l=RD(bMd(m),135);n=l.i+l.g/2;o=l.j+l.f/2;v=n/q.a;j=o/q.b;if(v+j>=1){if(v-j>0&&o>=0){Dyd(l,l.i+u);Eyd(l,l.j+i*j);}else if(v-j<0&&n>=0){Dyd(l,l.i+u*v);Eyd(l,l.j+i);}}}}Ixd(a,(umd(),kld),(Qpd(),f=RD(mfb(H3),9),new Fsb(f,RD(WEb(f,f.length),9),0)));return new rjd(w,k)} + function _4c(a){Cgd(a,new Pfd(Wfd($fd(Xfd(Zfd(Yfd(new agd,CFe),'ELK Radial'),'A radial layout provider which is based on the algorithm of Peter Eades published in "Drawing free trees.", published by International Institute for Advanced Study of Social Information Science, Fujitsu Limited in 1991. The radial layouter takes a tree and places the nodes in radial order around the root. The nodes of the same tree level are placed on the same radius.'),new c5c),CFe)));Agd(a,CFe,fEe,iGd(R4c));Agd(a,CFe,_ze,iGd(Y4c));Agd(a,CFe,jAe,iGd(K4c));Agd(a,CFe,CAe,iGd(L4c));Agd(a,CFe,iAe,iGd(M4c));Agd(a,CFe,kAe,iGd(J4c));Agd(a,CFe,gAe,iGd(N4c));Agd(a,CFe,lAe,iGd(Q4c));Agd(a,CFe,tFe,iGd(H4c));Agd(a,CFe,sFe,iGd(I4c));Agd(a,CFe,rFe,iGd(T4c));Agd(a,CFe,xFe,iGd(W4c));Agd(a,CFe,yFe,iGd(U4c));Agd(a,CFe,zFe,iGd(V4c));Agd(a,CFe,wFe,iGd(O4c));Agd(a,CFe,pFe,iGd(P4c));Agd(a,CFe,qFe,iGd(S4c));Agd(a,CFe,uFe,iGd(X4c));Agd(a,CFe,vFe,iGd(Z4c));Agd(a,CFe,oFe,iGd(G4c));} + function Peb(a){var b,c,d,e,f,g,h,i,j,k,l;if(a==null){throw Adb(new Vgb(vve))}j=a;f=a.length;i=false;if(f>0){b=(BFb(0,a.length),a.charCodeAt(0));if(b==45||b==43){a=(BFb(1,a.length+1),a.substr(1));--f;i=b==45;}}if(f==0){throw Adb(new Vgb(nxe+j+'"'))}while(a.length>0&&(BFb(0,a.length),a.charCodeAt(0)==48)){a=(BFb(1,a.length+1),a.substr(1));--f;}if(f>(Ugb(),Sgb)[10]){throw Adb(new Vgb(nxe+j+'"'))}for(e=0;e0){l=-parseInt((AFb(0,d,a.length),a.substr(0,d)),10);a=(BFb(d,a.length+1),a.substr(d));f-=d;c=false;}while(f>=g){d=parseInt((AFb(0,g,a.length),a.substr(0,g)),10);a=(BFb(g,a.length+1),a.substr(g));f-=g;if(c){c=false;}else {if(Ddb(l,h)<0){throw Adb(new Vgb(nxe+j+'"'))}l=Ndb(l,k);}l=Vdb(l,d);}if(Ddb(l,0)>0){throw Adb(new Vgb(nxe+j+'"'))}if(!i){l=Odb(l);if(Ddb(l,0)<0){throw Adb(new Vgb(nxe+j+'"'))}}return l} + function oSd(a){gSd();var b,c,d,e,f,g,h,i;if(a==null)return null;e=qhb(a,Fhb(37));if(e<0){return a}else {i=new dib((AFb(0,e,a.length),a.substr(0,e)));b=$C(gE,YHe,28,4,15,1);h=0;d=0;for(g=a.length;ee+2&&zSd((BFb(e+1,a.length),a.charCodeAt(e+1)),XRd,YRd)&&zSd((BFb(e+2,a.length),a.charCodeAt(e+2)),XRd,YRd)){c=DSd((BFb(e+1,a.length),a.charCodeAt(e+1)),(BFb(e+2,a.length),a.charCodeAt(e+2)));e+=2;if(d>0){(c&192)==128?(b[h++]=c<<24>>24):(d=0);}else if(c>=128){if((c&224)==192){b[h++]=c<<24>>24;d=2;}else if((c&240)==224){b[h++]=c<<24>>24;d=3;}else if((c&248)==240){b[h++]=c<<24>>24;d=4;}}if(d>0){if(h==d){switch(h){case 2:{Thb(i,((b[0]&31)<<6|b[1]&63)&Bwe);break}case 3:{Thb(i,((b[0]&15)<<12|(b[1]&63)<<6|b[2]&63)&Bwe);break}}h=0;d=0;}}else {for(f=0;f=2){if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i==0){c=(bvd(),e=new Rzd,e);WGd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),c);}else if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i>1){m=new mMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));while(m.e!=m.i.gc()){cMd(m);}}lsd(b,RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166));}if(l){for(d=new dMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));d.e!=d.i.gc();){c=RD(bMd(d),166);for(j=new dMd((!c.a&&(c.a=new XZd(D4,c,5)),c.a));j.e!=j.i.gc();){i=RD(bMd(j),377);h.a=$wnd.Math.max(h.a,i.a);h.b=$wnd.Math.max(h.b,i.b);}}}for(g=new dMd((!a.n&&(a.n=new C5d(I4,a,1,7)),a.n));g.e!=g.i.gc();){f=RD(bMd(g),135);k=RD(Gxd(f,und),8);!!k&&Byd(f,k.a,k.b);if(l){h.a=$wnd.Math.max(h.a,f.i+f.g);h.b=$wnd.Math.max(h.b,f.j+f.f);}}return h} + function MA(a,b,c,d,e){var f,g,h;KA(a,b);g=b[0];f=ihb(c.c,0);h=-1;if(DA(c)){if(d>0){if(g+d>a.length){return false}h=HA((AFb(0,g+d,a.length),a.substr(0,g+d)),b);}else {h=HA(a,b);}}switch(f){case 71:h=EA(a,g,cD(WC(qJ,1),Nve,2,6,[Qwe,Rwe]),b);e.e=h;return true;case 77:return PA(a,b,e,h,g);case 76:return RA(a,b,e,h,g);case 69:return NA(a,b,g,e);case 99:return QA(a,b,g,e);case 97:h=EA(a,g,cD(WC(qJ,1),Nve,2,6,['AM','PM']),b);e.b=h;return true;case 121:return TA(a,b,g,h,c,e);case 100:if(h<=0){return false}e.c=h;return true;case 83:if(h<0){return false}return OA(h,g,b[0],e);case 104:h==12&&(h=0);case 75:case 72:if(h<0){return false}e.f=h;e.g=false;return true;case 107:if(h<0){return false}e.f=h;e.g=true;return true;case 109:if(h<0){return false}e.j=h;return true;case 115:if(h<0){return false}e.n=h;return true;case 90:if(gB[i]&&(q=i);for(l=new Anb(a.a.b);l.a1){e=N8c(b);l=f.g;o=RD(Gxd(b,N7c),107);p=Kfb(UD(Gxd(b,x7c)));(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i>1&&Kfb(UD(Gxd(b,(X6c(),T6c))))!=oxe&&(f.c+(o.b+o.c))/(f.b+(o.d+o.a))1&&Kfb(UD(Gxd(b,(X6c(),S6c))))!=oxe&&(f.c+(o.b+o.c))/(f.b+(o.d+o.a))>p&&Ixd(e,(X6c(),W6c),$wnd.Math.max(Kfb(UD(Gxd(b,U6c))),Kfb(UD(Gxd(e,W6c)))-Kfb(UD(Gxd(b,S6c)))));n=new m9c(d,k);i=l9c(n,e,m);j=i.g;if(j>=l&&j==j){for(g=0;g<(!e.a&&(e.a=new C5d(J4,e,10,11)),e.a).i;g++){O8c(a,RD(QHd((!e.a&&(e.a=new C5d(J4,e,10,11)),e.a),g),27),RD(QHd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),g),27));}P8c(b,n);jad(f,i.c);iad(f,i.b);}--h;}Ixd(b,(X6c(),N6c),f.b);Ixd(b,O6c,f.c);c.Vg();} + function fHc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;b.Ug('Interactive node layering',1);c=new bnb;for(m=new Anb(a.a);m.a=h){sFb(s.b>0);s.a.Xb(s.c=--s.b);break}else if(q.a>i){if(!d){Rmb(q.b,k);q.c=$wnd.Math.min(q.c,i);q.a=$wnd.Math.max(q.a,h);d=q;}else {Tmb(d.b,q.b);d.a=$wnd.Math.max(d.a,q.a);Ckb(s);}}}if(!d){d=new jHc;d.c=i;d.a=h;Ikb(s,d);Rmb(d.b,k);}}g=a.b;j=0;for(r=new Anb(c);r.an){if(f){Oub(w,m);Oub(B,sgb(j.b-1));}H=c.b;I+=m+b;m=0;k=$wnd.Math.max(k,c.b+c.c+G);}Dyd(h,H);Eyd(h,I);k=$wnd.Math.max(k,H+G+c.c);m=$wnd.Math.max(m,l);H+=G+b;}k=$wnd.Math.max(k,d);F=I+m+c.a;if(FVze;C=$wnd.Math.abs(m.b-o.b)>Vze;(!c&&B&&C||c&&(B||C))&&Mub(q.a,u);}ye(q.a,d);d.b==0?(m=u):(m=(sFb(d.b!=0),RD(d.c.b.c,8)));j0b(n,l,p);if(I0b(e)==A){if(Y2b(A.i)!=e.a){p=new pjd;e2b(p,Y2b(A.i),s);}pQb(q,Wwc,p);}k0b(n,q,s);k.a.zc(n,k);}Y0b(q,v);Z0b(q,A);}for(j=k.a.ec().Kc();j.Ob();){i=RD(j.Pb(),18);Y0b(i,null);Z0b(i,null);}b.Vg();} + function lXc(a,b){var c,d,e,f,g,h,i,j,k,l,m;e=RD(mQb(a,(h_c(),H$c)),88);k=e==(Cmd(),ymd)||e==zmd?xmd:zmd;c=RD(zDb(CDb(new SDb(null,new Swb(a.b,16)),new $Xc),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);i=RD(zDb(GDb(c.Oc(),new aYc(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);i.Gc(RD(zDb(GDb(c.Oc(),new cYc(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),16));i.jd(new eYc(k));m=new yAb(new iYc(e));d=new Tsb;for(h=i.Kc();h.Ob();){g=RD(h.Pb(),240);j=RD(g.a,40);if(Heb(TD(g.c))){m.a.zc(j,(Geb(),Eeb))==null;(new zAb(m.a.Zc(j,false))).a.gc()>0&&Zjb(d,j,RD((new zAb(m.a.Zc(j,false))).a.Vc(),40));(new zAb(m.a.ad(j,true))).a.gc()>1&&Zjb(d,nXc(m,j),j);}else {if((new zAb(m.a.Zc(j,false))).a.gc()>0){f=RD((new zAb(m.a.Zc(j,false))).a.Vc(),40);dE(f)===dE(Wd(qtb(d.f,j)))&&RD(mQb(j,(q$c(),TZc)),15).Fc(f);}if((new zAb(m.a.ad(j,true))).a.gc()>1){l=nXc(m,j);dE(Wd(qtb(d.f,l)))===dE(j)&&RD(mQb(l,(q$c(),TZc)),15).Fc(j);}m.a.Bc(j)!=null;}}} + function BTb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(a.gc()==1){return RD(a.Xb(0),235)}else if(a.gc()<=0){return new gUb}for(e=a.Kc();e.Ob();){c=RD(e.Pb(),235);o=0;k=lve;l=lve;i=qwe;j=qwe;for(n=new Anb(c.e);n.ah){t=0;u+=g+r;g=0;}ATb(p,c,t,u);b=$wnd.Math.max(b,t+q.a);g=$wnd.Math.max(g,q.b);t+=q.a+r;}return p} + function Aqe(a){zqe();var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(a==null)return null;f=Ahb(a);o=Dqe(f);if(o%4!=0){return null}p=o/4|0;if(p==0)return $C(gE,YHe,28,0,15,1);l=null;b=0;c=0;d=0;e=0;g=0;h=0;i=0;j=0;n=0;m=0;k=0;l=$C(gE,YHe,28,p*3,15,1);for(;n>4)<<24>>24;l[m++]=((c&15)<<4|d>>2&15)<<24>>24;l[m++]=(d<<6|e)<<24>>24;}if(!Cqe(g=f[k++])||!Cqe(h=f[k++])){return null}b=xqe[g];c=xqe[h];i=f[k++];j=f[k++];if(xqe[i]==-1||xqe[j]==-1){if(i==61&&j==61){if((c&15)!=0)return null;q=$C(gE,YHe,28,n*3+1,15,1);hib(l,0,q,0,n*3);q[m]=(b<<2|c>>4)<<24>>24;return q}else if(i!=61&&j==61){d=xqe[i];if((d&3)!=0)return null;q=$C(gE,YHe,28,n*3+2,15,1);hib(l,0,q,0,n*3);q[m++]=(b<<2|c>>4)<<24>>24;q[m]=((c&15)<<4|d>>2&15)<<24>>24;return q}else {return null}}else {d=xqe[i];e=xqe[j];l[m++]=(b<<2|c>>4)<<24>>24;l[m++]=((c&15)<<4|d>>2&15)<<24>>24;l[m++]=(d<<6|e)<<24>>24;}return l} + function wfc(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;b.Ug(qBe,1);o=RD(mQb(a,(yCc(),yAc)),223);for(e=new Anb(a.b);e.a=2){p=true;m=new Anb(f.j);c=RD(ynb(m),12);n=null;while(m.a0){d=l.gc();j=eE($wnd.Math.floor((d+1)/2))-1;e=eE($wnd.Math.ceil((d+1)/2))-1;if(b.o==DQc){for(k=e;k>=j;k--){if(b.a[u.p]==u){p=RD(l.Xb(k),42);o=RD(p.a,10);if(!Zsb(c,p.b)&&n>a.b.e[o.p]){b.a[o.p]=u;b.g[u.p]=b.g[o.p];b.a[u.p]=b.g[u.p];b.f[b.g[u.p].p]=(Geb(),Heb(b.f[b.g[u.p].p])&u.k==(r3b(),o3b)?true:false);n=a.b.e[o.p];}}}}else {for(k=j;k<=e;k++){if(b.a[u.p]==u){r=RD(l.Xb(k),42);q=RD(r.a,10);if(!Zsb(c,r.b)&&n0){e=RD(Vmb(q.c.a,w-1),10);g=a.i[e.p];B=$wnd.Math.ceil(bFc(a.n,e,q));f=v.a.e-q.d.d-(g.a.e+e.o.b+e.d.a)-B;}j=oxe;if(w0&&A.a.e.e-A.a.a-(A.b.e.e-A.b.a)<0;o=t.a.e.e-t.a.a-(t.b.e.e-t.b.a)<0&&A.a.e.e-A.a.a-(A.b.e.e-A.b.a)>0;n=t.a.e.e+t.b.aA.b.e.e+A.a.a;u=0;!p&&!o&&(m?f+l>0?(u=l):j-d>0&&(u=d):n&&(f+h>0?(u=h):j-s>0&&(u=s)));v.a.e+=u;v.b&&(v.d.e+=u);return false} + function OJb(a,b,c){var d,e,f,g,h,i,j,k,l,m;d=new Uid(b.Lf().a,b.Lf().b,b.Mf().a,b.Mf().b);e=new Tid;if(a.c){for(g=new Anb(b.Rf());g.aj&&(d.a+=Hhb($C(hE,zwe,28,-j,15,1)));d.a+='Is';if(qhb(i,Fhb(32))>=0){for(e=0;e=d.o.b/2;}else {s=!l;}if(s){r=RD(mQb(d,(Ywc(),Xwc)),15);if(!r){f=new bnb;pQb(d,Xwc,f);}else if(m){f=r;}else {e=RD(mQb(d,Vvc),15);if(!e){f=new bnb;pQb(d,Vvc,f);}else {r.gc()<=e.gc()?(f=r):(f=e);}}}else {e=RD(mQb(d,(Ywc(),Vvc)),15);if(!e){f=new bnb;pQb(d,Vvc,f);}else if(l){f=e;}else {r=RD(mQb(d,Xwc),15);if(!r){f=new bnb;pQb(d,Xwc,f);}else {e.gc()<=r.gc()?(f=e):(f=r);}}}f.Fc(a);pQb(a,(Ywc(),Xvc),c);if(b.d==c){Z0b(b,null);c.e.c.length+c.g.c.length==0&&P3b(c,null);u6b(c);}else {Y0b(b,null);c.e.c.length+c.g.c.length==0&&P3b(c,null);}Xub(b.a);} + function GHc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;c.Ug('MinWidth layering',1);n=b.b;A=b.a;I=RD(mQb(b,(yCc(),WAc)),17).a;h=RD(mQb(b,XAc),17).a;a.b=Kfb(UD(mQb(b,TBc)));a.d=oxe;for(u=new Anb(A);u.a0){j=0;!!q&&(j+=h);j+=(C-1)*g;!!t&&(j+=h);B&&!!t&&(j=$wnd.Math.max(j,JUc(t,g,s,A)));if(j=a.a){d=V9b(a,s);k=$wnd.Math.max(k,d.b);u=$wnd.Math.max(u,d.d);Rmb(h,new Ptd(s,d));}}B=new bnb;for(j=0;j0),q.a.Xb(q.c=--q.b),C=new R4b(a.b),Ikb(q,C),sFb(q.b0){m=k<100?null:new gLd(k);j=new $Hd(b);o=j.g;r=$C(kE,Pwe,28,k,15,1);d=0;u=new ZHd(k);for(e=0;e=0;){if(n!=null?pb(n,o[i]):dE(n)===dE(o[i])){if(r.length<=d){q=r;r=$C(kE,Pwe,28,2*r.length,15,1);hib(q,0,r,0,d);}r[d++]=e;WGd(u,o[i]);break v}}n=n;if(dE(n)===dE(h)){break}}}j=u;o=u.g;k=d;if(d>r.length){q=r;r=$C(kE,Pwe,28,d,15,1);hib(q,0,r,0,d);}if(d>0){t=true;for(f=0;f=0;){THd(a,r[g]);}if(d!=k){for(e=k;--e>=d;){THd(j,e);}q=r;r=$C(kE,Pwe,28,d,15,1);hib(q,0,r,0,d);}b=j;}}}else {b=aHd(a,b);for(e=a.i;--e>=0;){if(b.Hc(a.g[e])){THd(a,e);t=true;}}}if(t){if(r!=null){c=b.gc();l=c==1?dZd(a,4,b.Kc().Pb(),null,r[0],p):dZd(a,6,b,r,r[0],p);m=c<100?null:new gLd(c);for(e=b.Kc();e.Ob();){n=e.Pb();m=oge(a,RD(n,76),m);}if(!m){qvd(a.e,l);}else {m.nj(l);m.oj();}}else {m=tLd(b.gc());for(e=b.Kc();e.Ob();){n=e.Pb();m=oge(a,RD(n,76),m);}!!m&&m.oj();}return true}else {return false}} + function i_b(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;c=new p_b(b);c.a||b_b(b);j=a_b(b);i=new Tp;q=new D_b;for(p=new Anb(b.a);p.a0||c.o==DQc&&e=c} + function zEd(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G;t=b;s=new Tp;u=new Tp;k=wDd(t,mIe);d=new OEd(a,c,s,u);QDd(d.a,d.b,d.c,d.d,k);i=(A=s.i,!A?(s.i=new zf(s,s.c)):A);for(C=i.Kc();C.Ob();){B=RD(C.Pb(),166);e=RD(Qc(s,B),21);for(p=e.Kc();p.Ob();){o=p.Pb();v=RD(Ao(a.d,o),166);if(v){h=(!B.e&&(B.e=new Yie(F4,B,10,9)),B.e);WGd(h,v);}else {g=zDd(t,uIe);m=AIe+o+BIe+g;n=m+zIe;throw Adb(new CDd(n))}}}j=(w=u.i,!w?(u.i=new zf(u,u.c)):w);for(F=j.Kc();F.Ob();){D=RD(F.Pb(),166);f=RD(Qc(u,D),21);for(r=f.Kc();r.Ob();){q=r.Pb();v=RD(Ao(a.d,q),166);if(v){l=(!D.g&&(D.g=new Yie(F4,D,9,10)),D.g);WGd(l,v);}else {g=zDd(t,uIe);m=AIe+q+BIe+g;n=m+zIe;throw Adb(new CDd(n))}}}!c.b&&(c.b=new Yie(E4,c,4,7));if(c.b.i!=0&&(!c.c&&(c.c=new Yie(E4,c,5,8)),c.c.i!=0)&&(!c.b&&(c.b=new Yie(E4,c,4,7)),c.b.i<=1&&(!c.c&&(c.c=new Yie(E4,c,5,8)),c.c.i<=1))&&(!c.a&&(c.a=new C5d(F4,c,6,6)),c.a).i==1){G=RD(QHd((!c.a&&(c.a=new C5d(F4,c,6,6)),c.a),0),166);if(!Dzd(G)&&!Ezd(G)){Kzd(G,RD(QHd((!c.b&&(c.b=new Yie(E4,c,4,7)),c.b),0),84));Lzd(G,RD(QHd((!c.c&&(c.c=new Yie(E4,c,5,8)),c.c),0),84));}}} + function QNc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;for(t=a.a,u=0,v=t.length;u0){l=RD(Vmb(m.c.a,g-1),10);B=bFc(a.b,m,l);q=m.n.b-m.d.d-(l.n.b+l.o.b+l.d.a+B);}else {q=m.n.b-m.d.d;}j=$wnd.Math.min(q,j);if(g1&&(g=$wnd.Math.min(g,$wnd.Math.abs(RD(ju(h.a,1),8).b-k.b)));}}}}}else {for(p=new Anb(b.j);p.ae){f=m.a-e;g=lve;d.c.length=0;e=m.a;}if(m.a>=e){ZEb(d.c,h);h.a.b>1&&(g=$wnd.Math.min(g,$wnd.Math.abs(RD(ju(h.a,h.a.b-2),8).b-m.b)));}}}}}if(d.c.length!=0&&f>b.o.a/2&&g>b.o.b/2){n=new R3b;P3b(n,b);Q3b(n,(qpd(),Yod));n.n.a=b.o.a/2;r=new R3b;P3b(r,b);Q3b(r,npd);r.n.a=b.o.a/2;r.n.b=b.o.b;for(i=new Anb(d);i.a=j.b?Y0b(h,r):Y0b(h,n);}else {j=RD(Vub(h.a),8);q=h.a.b==0?K3b(h.c):RD(Rub(h.a),8);q.b>=j.b?Z0b(h,r):Z0b(h,n);}l=RD(mQb(h,(yCc(),RAc)),75);!!l&&ze(l,j,true);}b.n.a=e-b.o.a/2;}} + function E0c(a,b,c){var d,e,f,g,h,i,j,k,l,m;for(h=Sub(a.b,0);h.b!=h.d.c;){g=RD(evb(h),40);if(lhb(g.c,IEe)){continue}j=iWc(g,a);b==(Cmd(),ymd)||b==zmd?_mb(j,new D1c):_mb(j,new H1c);i=j.c.length;for(d=0;d=0?(n=vpd(h)):(n=spd(vpd(h)));a.qf(GBc,n);}j=new pjd;m=false;if(a.pf(zBc)){mjd(j,RD(a.of(zBc),8));m=true;}else {ljd(j,g.a/2,g.b/2);}switch(n.g){case 4:pQb(k,UAc,(cxc(),$wc));pQb(k,bwc,(huc(),guc));k.o.b=g.b;p<0&&(k.o.a=-p);Q3b(l,(qpd(),Xod));m||(j.a=g.a);j.a-=g.a;break;case 2:pQb(k,UAc,(cxc(),axc));pQb(k,bwc,(huc(),euc));k.o.b=g.b;p<0&&(k.o.a=-p);Q3b(l,(qpd(),ppd));m||(j.a=0);break;case 1:pQb(k,owc,(Gvc(),Fvc));k.o.a=g.a;p<0&&(k.o.b=-p);Q3b(l,(qpd(),npd));m||(j.b=g.b);j.b-=g.b;break;case 3:pQb(k,owc,(Gvc(),Dvc));k.o.a=g.a;p<0&&(k.o.b=-p);Q3b(l,(qpd(),Yod));m||(j.b=0);}mjd(l.n,j);pQb(k,zBc,j);if(b==vod||b==xod||b==wod){o=0;if(b==vod&&a.pf(CBc)){switch(n.g){case 1:case 2:o=RD(a.of(CBc),17).a;break;case 3:case 4:o=-RD(a.of(CBc),17).a;}}else {switch(n.g){case 4:case 2:o=f.b;b==xod&&(o/=e.b);break;case 1:case 3:o=f.a;b==xod&&(o/=e.a);}}pQb(k,Jwc,o);}pQb(k,hwc,n);return k} + function OId(){MId();function h(f){var g=this;this.dispatch=function(a){var b=a.data;switch(b.cmd){case 'algorithms':var c=PId((yob(),new xpb(new glb(LId.b))));f.postMessage({id:b.id,data:c});break;case 'categories':var d=PId((yob(),new xpb(new glb(LId.c))));f.postMessage({id:b.id,data:d});break;case 'options':var e=PId((yob(),new xpb(new glb(LId.d))));f.postMessage({id:b.id,data:e});break;case 'register':SId(b.algorithms);f.postMessage({id:b.id});break;case 'layout':QId(b.graph,b.layoutOptions||{},b.options||{});f.postMessage({id:b.id,data:b.graph});break;}};this.saveDispatch=function(b){try{g.dispatch(b);}catch(a){f.postMessage({id:b.data.id,error:a});}};} + function j(b){var c=this;this.dispatcher=new h({postMessage:function(a){c.onmessage({data:a});}});this.postMessage=function(a){setTimeout(function(){c.dispatcher.saveDispatch({data:a});},0);};} + if(typeof document===Yxe&&typeof self!==Yxe){var i=new h(self);self.onmessage=i.saveDispatch;}else if(typeof module!==Yxe&&module.exports){Object.defineProperty(exports,'__esModule',{value:true});module.exports={'default':j,Worker:j};}} + function i5b(a,b,c){var d,e,f,g,h,i,j,k,l,m;k=new j3b(c);kQb(k,b);pQb(k,(Ywc(),Awc),b);k.o.a=b.g;k.o.b=b.f;k.n.a=b.i;k.n.b=b.j;Rmb(c.a,k);Zjb(a.a,b,k);((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a).i!=0||Heb(TD(Gxd(b,(yCc(),NAc)))))&&pQb(k,Yvc,(Geb(),true));j=RD(mQb(c,kwc),21);l=RD(mQb(k,(yCc(),BBc)),101);l==(Bod(),Aod)?pQb(k,BBc,zod):l!=zod&&j.Fc((ovc(),kvc));m=0;d=RD(mQb(c,rAc),88);for(i=new dMd((!b.c&&(b.c=new C5d(K4,b,9,9)),b.c));i.e!=i.i.gc();){h=RD(bMd(i),123);e=vCd(b);(dE(Gxd(e,cAc))!==dE((kEc(),hEc))||dE(Gxd(e,pAc))===dE((Ptc(),Otc))||dE(Gxd(e,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(e,eAc)))||dE(Gxd(e,Yzc))!==dE((U$b(),T$b))||dE(Gxd(e,ZAc))===dE((aEc(),TDc))||dE(Gxd(e,ZAc))===dE((aEc(),UDc))||dE(Gxd(e,$Ac))===dE((_Cc(),SCc))||dE(Gxd(e,$Ac))===dE((_Cc(),UCc)))&&!Heb(TD(Gxd(b,aAc)))&&Ixd(h,zwc,sgb(m++));Heb(TD(Gxd(h,pBc)))||j5b(a,h,k,j,d,l);}for(g=new dMd((!b.n&&(b.n=new C5d(I4,b,1,7)),b.n));g.e!=g.i.gc();){f=RD(bMd(g),135);!Heb(TD(Gxd(f,pBc)))&&!!f.a&&Rmb(k.b,h5b(f));}Heb(TD(mQb(k,Uzc)))&&j.Fc((ovc(),fvc));if(Heb(TD(mQb(k,MAc)))){j.Fc((ovc(),jvc));j.Fc(ivc);pQb(k,BBc,zod);}return k} + function ird(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;p=0;D=0;for(j=new Anb(a.b);j.ap){if(f){Oub(w,n);Oub(B,sgb(k.b-1));Rmb(a.d,o);h.c.length=0;}H=c.b;I+=n+b;n=0;l=$wnd.Math.max(l,c.b+c.c+G);}ZEb(h.c,i);xrd(i,H,I);l=$wnd.Math.max(l,H+G+c.c);n=$wnd.Math.max(n,m);H+=G+b;o=i;}Tmb(a.a,h);Rmb(a.d,RD(Vmb(h,h.c.length-1),163));l=$wnd.Math.max(l,d);F=I+n+c.a;if(Fe.d.d+e.d.a){k.f.d=true;}else {k.f.d=true;k.f.a=true;}}}d.b!=d.d.c&&(b=c);}if(k){f=RD(Wjb(a.f,g.d.i),60);if(b.bf.d.d+f.d.a){k.f.d=true;}else {k.f.d=true;k.f.a=true;}}}}for(h=new is(Mr(Z2b(n).a.Kc(),new ir));gs(h);){g=RD(hs(h),18);if(g.a.b!=0){b=RD(Rub(g.a),8);if(g.d.j==(qpd(),Yod)){q=new Nlc(b,new rjd(b.a,e.d.d),e,g);q.f.a=true;q.a=g.d;ZEb(p.c,q);}if(g.d.j==npd){q=new Nlc(b,new rjd(b.a,e.d.d+e.d.a),e,g);q.f.d=true;q.a=g.d;ZEb(p.c,q);}}}}}return p} + function Nvd(a,b,c){var d,e,f,g,h,i,j,k,l,m;i=new bnb;l=b.length;g=$5d(c);for(j=0;j=o){if(s>o){n.c.length=0;o=s;}ZEb(n.c,g);}}if(n.c.length!=0){m=RD(Vmb(n,Jwb(b,n.c.length)),131);F.a.Bc(m)!=null;m.s=p++;$Uc(m,C,w);n.c.length=0;}}u=a.c.length+1;for(h=new Anb(a);h.aD.s){Ckb(c);Ymb(D.i,d);if(d.c>0){d.a=D;Rmb(D.t,d);d.b=A;Rmb(A.i,d);}}}}} + function Efc(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F;p=new cnb(b.b);u=new cnb(b.b);m=new cnb(b.b);B=new cnb(b.b);q=new cnb(b.b);for(A=Sub(b,0);A.b!=A.d.c;){v=RD(evb(A),12);for(h=new Anb(v.g);h.a0;r=v.g.c.length>0;j&&r?(ZEb(m.c,v),true):j?(ZEb(p.c,v),true):r&&(ZEb(u.c,v),true);}for(o=new Anb(p);o.as.nh()-j.b&&(m=s.nh()-j.b);n>s.oh()-j.d&&(n=s.oh()-j.d);k0){for(t=Sub(a.f,0);t.b!=t.d.c;){s=RD(evb(t),10);s.p+=m-a.e;}WGc(a);Xub(a.f);TGc(a,d,n);}else {Mub(a.f,n);n.p=d;a.e=$wnd.Math.max(a.e,d);for(f=new is(Mr(Z2b(n).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(!e.c.i.c&&e.c.i.k==(r3b(),n3b)){Mub(a.f,e.c.i);e.c.i.p=d-1;}}a.c=d;}}}else {WGc(a);Xub(a.f);d=0;if(gs(new is(Mr(Z2b(n).a.Kc(),new ir)))){m=0;m=UGc(m,n);d=m+2;TGc(a,d,n);}else {Mub(a.f,n);n.p=0;a.e=$wnd.Math.max(a.e,0);a.b=RD(Vmb(a.d.b,0),30);a.c=0;}}}}a.f.b==0||WGc(a);a.d.a.c.length=0;r=new bnb;for(j=new Anb(a.d.b);j.a=48&&b<=57){d=b-48;while(e=48&&b<=57){d=d*10+b-48;if(d<0)throw Adb(new Lqe(TId((Hde(),CJe))))}}else {throw Adb(new Lqe(TId((Hde(),yJe))))}c=d;if(b==44){if(e>=a.j){throw Adb(new Lqe(TId((Hde(),AJe))))}else if((b=ihb(a.i,e++))>=48&&b<=57){c=b-48;while(e=48&&b<=57){c=c*10+b-48;if(c<0)throw Adb(new Lqe(TId((Hde(),CJe))))}if(d>c)throw Adb(new Lqe(TId((Hde(),BJe))))}else {c=-1;}}if(b!=125)throw Adb(new Lqe(TId((Hde(),zJe))));if(a.bm(e)){f=(Vse(),Vse(),new Kte(9,f));a.d=e+1;}else {f=(Vse(),Vse(),new Kte(3,f));a.d=e;}f.Om(d);f.Nm(c);Mqe(a);}}return f} + function bXb(a){var b,c,d,e,f;c=RD(mQb(a,(Ywc(),kwc)),21);b=vfd(YWb);e=RD(mQb(a,(yCc(),IAc)),346);e==(Fnd(),Cnd)&&ofd(b,ZWb);Heb(TD(mQb(a,GAc)))?pfd(b,(sXb(),nXb),(hcc(),Zbc)):pfd(b,(sXb(),pXb),(hcc(),Zbc));mQb(a,(rid(),qid))!=null&&ofd(b,$Wb);(Heb(TD(mQb(a,PAc)))||Heb(TD(mQb(a,HAc))))&&nfd(b,(sXb(),rXb),(hcc(),lbc));switch(RD(mQb(a,rAc),88).g){case 2:case 3:case 4:nfd(pfd(b,(sXb(),nXb),(hcc(),nbc)),rXb,mbc);}c.Hc((ovc(),fvc))&&nfd(pfd(pfd(b,(sXb(),nXb),(hcc(),kbc)),qXb,ibc),rXb,jbc);dE(mQb(a,ZAc))!==dE((aEc(),$Dc))&&pfd(b,(sXb(),pXb),(hcc(),Rbc));if(c.Hc(mvc)){pfd(b,(sXb(),nXb),(hcc(),Xbc));pfd(b,oXb,Vbc);pfd(b,pXb,Wbc);}dE(mQb(a,Xzc))!==dE(($uc(),Yuc))&&dE(mQb(a,yAc))!==dE((Ymd(),Vmd))&&nfd(b,(sXb(),rXb),(hcc(),Abc));Heb(TD(mQb(a,KAc)))&&pfd(b,(sXb(),pXb),(hcc(),zbc));Heb(TD(mQb(a,nAc)))&&pfd(b,(sXb(),pXb),(hcc(),dcc));if(eXb(a)){dE(mQb(a,IAc))===dE(Cnd)?(d=RD(mQb(a,gAc),299)):(d=RD(mQb(a,hAc),299));f=d==(xvc(),vvc)?(hcc(),Ubc):(hcc(),gcc);pfd(b,(sXb(),qXb),f);}switch(RD(mQb(a,vCc),388).g){case 1:pfd(b,(sXb(),qXb),(hcc(),ecc));break;case 2:nfd(pfd(pfd(b,(sXb(),pXb),(hcc(),ebc)),qXb,fbc),rXb,gbc);}dE(mQb(a,cAc))!==dE((kEc(),hEc))&&pfd(b,(sXb(),pXb),(hcc(),fcc));return b} + function crc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;if(Ujb(a.a,b)){if(Zsb(RD(Wjb(a.a,b),49),c)){return 1}}else {Zjb(a.a,b,new _sb);}if(Ujb(a.a,c)){if(Zsb(RD(Wjb(a.a,c),49),b)){return -1}}else {Zjb(a.a,c,new _sb);}if(Ujb(a.e,b)){if(Zsb(RD(Wjb(a.e,b),49),c)){return -1}}else {Zjb(a.e,b,new _sb);}if(Ujb(a.e,c)){if(Zsb(RD(Wjb(a.a,c),49),b)){return 1}}else {Zjb(a.e,c,new _sb);}if(a.c==(kEc(),iEc)||!nQb(b,(Ywc(),zwc))||!nQb(c,(Ywc(),zwc))){l=null;for(j=new Anb(b.j);j.ag?erc(a,b,c):erc(a,c,b);return eg?1:0}}d=RD(mQb(b,(Ywc(),zwc)),17).a;f=RD(mQb(c,zwc),17).a;d>f?erc(a,b,c):erc(a,c,b);return df?1:0} + function uAd(b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(d==null){return null}if(b.a!=c.jk()){throw Adb(new agb(VHe+c.xe()+WHe))}if(ZD(c,469)){r=z1d(RD(c,685),d);if(!r){throw Adb(new agb(XHe+d+"' is not a valid enumerator of '"+c.xe()+"'"))}return r}switch(Oee((lke(),jke),c).Nl()){case 2:{d=nue(d,false);break}case 3:{d=nue(d,true);break}}e=Oee(jke,c).Jl();if(e){return e.jk().wi().ti(e,d)}n=Oee(jke,c).Ll();if(n){r=new bnb;for(k=xAd(d),l=0,m=k.length;l1){o=new mMd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a));while(o.e!=o.i.gc()){cMd(o);}}g=RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166);q=H;H>v+u?(q=v+u):Hw+p?(r=w+p):Iv-u&&qw-p&&rH+G?(B=H+G):vI+A?(C=I+A):wH-G&&BI-A&&Cc&&(m=c-1);n=N+Kwb(b,24)*Nxe*l-l/2;n<0?(n=1):n>d&&(n=d-1);e=(bvd(),i=new Xxd,i);Vxd(e,m);Wxd(e,n);WGd((!g.a&&(g.a=new XZd(D4,g,5)),g.a),e);}} + function Y7c(a){Cgd(a,new Pfd($fd(Xfd(Zfd(Yfd(new agd,$Fe),'ELK Rectangle Packing'),'Algorithm for packing of unconnected boxes, i.e. graphs without edges. The given order of the boxes is always preserved and the main reading direction of the boxes is left to right. The algorithm is divided into two phases. One phase approximates the width in which the rectangles can be placed. The next phase places the rectangles in rows using the previously calculated width as bounding width and bundles rectangles with a similar height in blocks. A compaction step reduces the size of the drawing. Finally, the rectangles are expanded to fill their bounding box and eliminate empty unused spaces.'),new _7c)));Agd(a,$Fe,Dze,1.3);Agd(a,$Fe,hAe,(Geb(),false));Agd(a,$Fe,Eze,O7c);Agd(a,$Fe,_ze,15);Agd(a,$Fe,YDe,iGd(y7c));Agd(a,$Fe,jAe,iGd(F7c));Agd(a,$Fe,CAe,iGd(H7c));Agd(a,$Fe,iAe,iGd(I7c));Agd(a,$Fe,kAe,iGd(E7c));Agd(a,$Fe,gAe,iGd(J7c));Agd(a,$Fe,lAe,iGd(P7c));Agd(a,$Fe,RFe,iGd(U7c));Agd(a,$Fe,SFe,iGd(T7c));Agd(a,$Fe,QFe,iGd(W7c));Agd(a,$Fe,PFe,iGd(V7c));Agd(a,$Fe,TFe,iGd(M7c));Agd(a,$Fe,UFe,iGd(L7c));Agd(a,$Fe,VFe,iGd(K7c));Agd(a,$Fe,WFe,iGd(S7c));Agd(a,$Fe,dAe,iGd(B7c));Agd(a,$Fe,iEe,iGd(C7c));Agd(a,$Fe,NFe,iGd(A7c));Agd(a,$Fe,MFe,iGd(z7c));Agd(a,$Fe,OFe,iGd(D7c));Agd(a,$Fe,LFe,iGd(R7c));} + function Ajb(a,b){xjb();var c,d,e,h,i,j,l,n,o,p,q,r,s,t,u,w,A,B,D,F,G,H;B=a.e;o=a.d;e=a.a;if(B==0){switch(b){case 0:return '0';case 1:return zxe;case 2:return '0.00';case 3:return '0.000';case 4:return '0.0000';case 5:return '0.00000';case 6:return '0.000000';default:w=new bib;(w.a+='0E',w);w.a+=-b;return w.a;}}t=o*10+1+7;u=$C(hE,zwe,28,t+1,15,1);c=t;if(o==1){h=e[0];if(h<0){H=Cdb(h,yxe);do{p=H;H=Fdb(H,10);u[--c]=48+Ydb(Vdb(p,Ndb(H,10)))&Bwe;}while(Ddb(H,0)!=0)}else {H=h;do{p=H;H=H/10|0;u[--c]=48+(p-H*10)&Bwe;}while(H!=0)}}else {D=$C(kE,Pwe,28,o,15,1);G=o;hib(e,0,D,0,G);I:while(true){A=0;for(j=G-1;j>=0;j--){F=Bdb(Sdb(A,32),Cdb(D[j],yxe));r=yjb(F);D[j]=Ydb(r);A=Ydb(Tdb(r,32));}s=Ydb(A);q=c;do{u[--c]=48+s%10&Bwe;}while((s=s/10|0)!=0&&c!=0);d=9-q+c;for(i=0;i0;i++){u[--c]=48;}l=G-1;for(;D[l]==0;l--){if(l==0){break I}}G=l+1;}while(u[c]==48){++c;}}n=B<0;{n&&(u[--c]=45);return Ihb(u,c,t-c)}} + function Jad(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;a.c=b;a.g=new Tsb;c=(lud(),new zud(a.c));d=new PJb(c);LJb(d);t=WD(Gxd(a.c,(ncd(),gcd)));i=RD(Gxd(a.c,icd),324);v=RD(Gxd(a.c,jcd),437);g=RD(Gxd(a.c,bcd),490);u=RD(Gxd(a.c,hcd),438);a.j=Kfb(UD(Gxd(a.c,kcd)));h=a.a;switch(i.g){case 0:h=a.a;break;case 1:h=a.b;break;case 2:h=a.i;break;case 3:h=a.e;break;case 4:h=a.f;break;default:throw Adb(new agb(eGe+(i.f!=null?i.f:''+i.g)));}a.d=new qbd(h,v,g);pQb(a.d,(OQb(),MQb),TD(Gxd(a.c,dcd)));a.d.c=Heb(TD(Gxd(a.c,ccd)));if(tCd(a.c).i==0){return a.d}for(l=new dMd(tCd(a.c));l.e!=l.i.gc();){k=RD(bMd(l),27);n=k.g/2;m=k.f/2;w=new rjd(k.i+n,k.j+m);while(Ujb(a.g,w)){Zid(w,($wnd.Math.random()-0.5)*Vze,($wnd.Math.random()-0.5)*Vze);}p=RD(Gxd(k,(umd(),eld)),140);q=new TQb(w,new Uid(w.a-n-a.j/2-p.b,w.b-m-a.j/2-p.d,k.g+a.j+(p.b+p.c),k.f+a.j+(p.d+p.a)));Rmb(a.d.i,q);Zjb(a.g,w,new Ptd(q,k));}switch(u.g){case 0:if(t==null){a.d.d=RD(Vmb(a.d.i,0),68);}else {for(s=new Anb(a.d.i);s.a0?G+1:1;}for(g=new Anb(w.g);g.a0?G+1:1;}}a.c[j]==0?Mub(a.e,p):a.a[j]==0&&Mub(a.f,p);++j;}o=-1;n=1;l=new bnb;a.d=RD(mQb(b,(Ywc(),Lwc)),234);while(L>0){while(a.e.b!=0){I=RD(Uub(a.e),10);a.b[I.p]=o--;TFc(a,I);--L;}while(a.f.b!=0){J=RD(Uub(a.f),10);a.b[J.p]=n++;TFc(a,J);--L;}if(L>0){m=qwe;for(s=new Anb(t);s.a=m){if(u>m){l.c.length=0;m=u;}ZEb(l.c,p);}}}k=a.sg(l);a.b[k.p]=n++;TFc(a,k);--L;}}H=t.c.length+1;for(j=0;ja.b[K]){X0b(d,true);pQb(b,awc,(Geb(),true));}}}}a.a=null;a.c=null;a.b=null;Xub(a.f);Xub(a.e);c.Vg();} + function usd(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;v=RD(QHd((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a),0),166);k=new Ejd;u=new Tsb;w=xsd(v);rtb(u.f,v,w);m=new Tsb;d=new Yub;for(o=Fl(Al(cD(WC(cJ,1),rve,20,0,[(!b.d&&(b.d=new Yie(G4,b,8,5)),b.d),(!b.e&&(b.e=new Yie(G4,b,7,4)),b.e)])));gs(o);){n=RD(hs(o),74);if((!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i!=1){throw Adb(new agb(tHe+(!a.a&&(a.a=new C5d(F4,a,6,6)),a.a).i))}if(n!=a){q=RD(QHd((!n.a&&(n.a=new C5d(F4,n,6,6)),n.a),0),166);Pub(d,q,d.c.b,d.c);p=RD(Wd(qtb(u.f,q)),13);if(!p){p=xsd(q);rtb(u.f,q,p);}l=c?ojd(new sjd(RD(Vmb(w,w.c.length-1),8)),RD(Vmb(p,p.c.length-1),8)):ojd(new sjd((tFb(0,w.c.length),RD(w.c[0],8))),(tFb(0,p.c.length),RD(p.c[0],8)));rtb(m.f,q,l);}}if(d.b!=0){r=RD(Vmb(w,c?w.c.length-1:0),8);for(j=1;j1&&(Pub(k,r,k.c.b,k.c),true);gvb(e);}}}r=s;}}return k} + function S_c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;c.Ug(_Ee,1);D=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new e0c),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);k=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new g0c(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);o=RD(zDb(CDb(new SDb(null,new Swb(b,16)),new i0c(b)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[vBb]))),15);p=$C(Z$,NEe,40,b.gc(),0,1);for(g=0;g=0&&C=0&&!p[n]){p[n]=e;k.gd(h);--h;break}n=C-m;if(n=0&&!p[n]){p[n]=e;k.gd(h);--h;break}}}o.jd(new k0c);for(i=p.length-1;i>=0;i--){if(!p[i]&&!o.dc()){p[i]=RD(o.Xb(0),40);o.gd(0);}}for(j=0;j=0;i--){Mub(c,(tFb(i,g.c.length),RD(g.c[i],8)));}return c} + function l9c(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;t=Kfb(UD(Gxd(b,(X6c(),W6c))));n=Kfb(UD(Gxd(b,U6c)));m=Kfb(UD(Gxd(b,R6c)));Bad((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));r=U8c((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a),t,a.b);for(q=0;qm&&Fad((tFb(m,b.c.length),RD(b.c[m],186)),k);k=null;while(b.c.length>m&&(tFb(m,b.c.length),RD(b.c[m],186)).a.c.length==0){Ymb(b,(tFb(m,b.c.length),b.c[m]));}}if(!k){--g;continue}if(!Heb(TD(RD(Vmb(k.b,0),27).of((X7c(),D7c))))&&K8c(b,o,f,k,q,c,m,d)){p=true;continue}if(q){n=o.b;l=k.f;if(!Heb(TD(RD(Vmb(k.b,0),27).of(D7c)))&&L8c(b,o,f,k,c,m,d,e)){p=true;if(n=a.j){a.a=-1;a.c=1;return}b=ihb(a.i,a.d++);a.a=b;if(a.b==1){switch(b){case 92:d=10;if(a.d>=a.j)throw Adb(new Lqe(TId((Hde(),VIe))));a.a=ihb(a.i,a.d++);break;case 45:if((a.e&512)==512&&a.d=a.j)break;if(ihb(a.i,a.d)!=63)break;if(++a.d>=a.j)throw Adb(new Lqe(TId((Hde(),WIe))));b=ihb(a.i,a.d++);switch(b){case 58:d=13;break;case 61:d=14;break;case 33:d=15;break;case 91:d=19;break;case 62:d=18;break;case 60:if(a.d>=a.j)throw Adb(new Lqe(TId((Hde(),WIe))));b=ihb(a.i,a.d++);if(b==61){d=16;}else if(b==33){d=17;}else throw Adb(new Lqe(TId((Hde(),XIe))));break;case 35:while(a.d=a.j)throw Adb(new Lqe(TId((Hde(),VIe))));a.a=ihb(a.i,a.d++);break;default:d=0;}a.c=d;} + function oXc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q;c.Ug('Process compaction',1);if(!Heb(TD(mQb(b,(h_c(),F$c))))){return}e=RD(mQb(b,H$c),88);n=Kfb(UD(mQb(b,_$c)));pXc(a,b,e);lXc(b,n/2/2);o=b.b;tvb(o,new EXc(e));for(j=Sub(o,0);j.b!=j.d.c;){i=RD(evb(j),40);if(!Heb(TD(mQb(i,(q$c(),n$c))))){d=mXc(i,e);p=lWc(i,b);l=0;m=0;if(d){q=d.e;switch(e.g){case 2:l=q.a-n-i.f.a;p.e.a-n-i.f.al&&(l=p.e.a+p.f.a+n);m=l+i.f.a;break;case 4:l=q.b-n-i.f.b;p.e.b-n-i.f.bl&&(l=p.e.b+p.f.b+n);m=l+i.f.b;}}else if(p){switch(e.g){case 2:l=p.e.a-n-i.f.a;m=l+i.f.a;break;case 1:l=p.e.a+p.f.a+n;m=l+i.f.a;break;case 4:l=p.e.b-n-i.f.b;m=l+i.f.b;break;case 3:l=p.e.b+p.f.b+n;m=l+i.f.b;}}if(dE(mQb(b,K$c))===dE((LZc(),IZc))){f=l;g=m;h=DDb(CDb(new SDb(null,new Swb(a.a,16)),new IXc(f,g)));if(h.a!=null){e==(Cmd(),ymd)||e==zmd?(i.e.a=l):(i.e.b=l);}else {e==(Cmd(),ymd)||e==Bmd?(h=DDb(CDb(NDb(new SDb(null,new Swb(a.a,16))),new WXc(f)))):(h=DDb(CDb(NDb(new SDb(null,new Swb(a.a,16))),new YXc(f))));h.a!=null&&(e==ymd||e==zmd?(i.e.a=Kfb(UD((sFb(h.a!=null),RD(h.a,42)).a))):(i.e.b=Kfb(UD((sFb(h.a!=null),RD(h.a,42)).a))));}if(h.a!=null){k=Wmb(a.a,(sFb(h.a!=null),h.a),0);if(k>0&&k!=RD(mQb(i,f_c),17).a){pQb(i,UZc,(Geb(),true));pQb(i,f_c,sgb(k));}}}else {e==(Cmd(),ymd)||e==zmd?(i.e.a=l):(i.e.b=l);}}}c.Vg();} + function Fre(a){var b,c,d,e,f,g,h,i,j;a.b=1;Mqe(a);b=null;if(a.c==0&&a.a==94){Mqe(a);b=(Vse(),Vse(),new xte(4));rte(b,0,MLe);h=(new xte(4));}else {h=(Vse(),Vse(),new xte(4));}e=true;while((j=a.c)!=1){if(j==0&&a.a==93&&!e){if(b){wte(b,h);h=b;}break}c=a.a;d=false;if(j==10){switch(c){case 100:case 68:case 119:case 87:case 115:case 83:ute(h,Ere(c));d=true;break;case 105:case 73:case 99:case 67:c=(ute(h,Ere(c)),-1);c<0&&(d=true);break;case 112:case 80:i=Sqe(a,c);if(!i)throw Adb(new Lqe(TId((Hde(),hJe))));ute(h,i);d=true;break;default:c=Dre(a);}}else if(j==24&&!e){if(b){wte(b,h);h=b;}f=Fre(a);wte(h,f);if(a.c!=0||a.a!=93)throw Adb(new Lqe(TId((Hde(),lJe))));break}Mqe(a);if(!d){if(j==0){if(c==91)throw Adb(new Lqe(TId((Hde(),mJe))));if(c==93)throw Adb(new Lqe(TId((Hde(),nJe))));if(c==45&&!e&&a.a!=93)throw Adb(new Lqe(TId((Hde(),oJe))))}if(a.c!=0||a.a!=45||c==45&&e){rte(h,c,c);}else {Mqe(a);if((j=a.c)==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(j==0&&a.a==93){rte(h,c,c);rte(h,45,45);}else if(j==0&&a.a==93||j==24){throw Adb(new Lqe(TId((Hde(),oJe))))}else {g=a.a;if(j==0){if(g==91)throw Adb(new Lqe(TId((Hde(),mJe))));if(g==93)throw Adb(new Lqe(TId((Hde(),nJe))));if(g==45)throw Adb(new Lqe(TId((Hde(),oJe))))}else j==10&&(g=Dre(a));Mqe(a);if(c>g)throw Adb(new Lqe(TId((Hde(),rJe))));rte(h,c,g);}}}e=false;}if(a.c==1)throw Adb(new Lqe(TId((Hde(),jJe))));vte(h);ste(h);a.b=0;Mqe(a);return h} + function EGc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;c.Ug('Coffman-Graham Layering',1);if(b.a.c.length==0){c.Vg();return}v=RD(mQb(b,(yCc(),SAc)),17).a;i=0;g=0;for(m=new Anb(b.a);m.a=v||!zGc(r,d))&&(d=BGc(b,k));g3b(r,d);for(f=new is(Mr(Z2b(r).a.Kc(),new ir));gs(f);){e=RD(hs(f),18);if(a.a[e.p]){continue}p=e.c.i;--a.e[p.p];a.e[p.p]==0&&(zFb(lwb(n,p),Bxe),true);}}for(j=k.c.length-1;j>=0;--j){Rmb(b.b,(tFb(j,k.c.length),RD(k.c[j],30)));}b.a.c.length=0;c.Vg();} + function Sec(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;u=false;do{u=false;for(f=b?(new Xkb(a.a.b)).a.gc()-2:1;b?f>=0:f<(new Xkb(a.a.b)).a.gc();f+=b?-1:1){e=_5b(a.a,sgb(f));for(n=0;nRD(mQb(q,zwc),17).a)&&(t=false);}if(!t){continue}i=b?f+1:f-1;h=_5b(a.a,sgb(i));g=false;s=true;d=false;for(k=Sub(h,0);k.b!=k.d.c;){j=RD(evb(k),10);if(nQb(j,zwc)){if(j.p!=l.p){g=g|(b?RD(mQb(j,zwc),17).aRD(mQb(l,zwc),17).a);s=false;}}else if(!g&&s){if(j.k==(r3b(),n3b)){d=true;b?(m=RD(hs(new is(Mr(Z2b(j).a.Kc(),new ir))),18).c.i):(m=RD(hs(new is(Mr(a3b(j).a.Kc(),new ir))),18).d.i);if(m==l){b?(c=RD(hs(new is(Mr(a3b(j).a.Kc(),new ir))),18).d.i):(c=RD(hs(new is(Mr(Z2b(j).a.Kc(),new ir))),18).c.i);(b?RD($5b(a.a,c),17).a-RD($5b(a.a,m),17).a:RD($5b(a.a,m),17).a-RD($5b(a.a,c),17).a)<=2&&(s=false);}}}}if(d&&s){b?(c=RD(hs(new is(Mr(a3b(l).a.Kc(),new ir))),18).d.i):(c=RD(hs(new is(Mr(Z2b(l).a.Kc(),new ir))),18).c.i);(b?RD($5b(a.a,c),17).a-RD($5b(a.a,l),17).a:RD($5b(a.a,l),17).a-RD($5b(a.a,c),17).a)<=2&&c.k==(r3b(),p3b)&&(s=false);}if(g||s){p=Xec(a,l,b);while(p.a.gc()!=0){o=RD(p.a.ec().Kc().Pb(),10);p.a.Bc(o)!=null;ye(p,Xec(a,o,b));}--n;u=true;}}}}while(u)} + function Xae(a){_Ad(a.c,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#decimal']));_Ad(a.d,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#integer']));_Ad(a.e,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#boolean']));_Ad(a.f,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EBoolean',GIe,'EBoolean:Object']));_Ad(a.i,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#byte']));_Ad(a.g,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#hexBinary']));_Ad(a.j,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EByte',GIe,'EByte:Object']));_Ad(a.n,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EChar',GIe,'EChar:Object']));_Ad(a.t,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#double']));_Ad(a.u,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EDouble',GIe,'EDouble:Object']));_Ad(a.F,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#float']));_Ad(a.G,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EFloat',GIe,'EFloat:Object']));_Ad(a.I,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#int']));_Ad(a.J,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EInt',GIe,'EInt:Object']));_Ad(a.N,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#long']));_Ad(a.O,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'ELong',GIe,'ELong:Object']));_Ad(a.Z,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#short']));_Ad(a.$,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'EShort',GIe,'EShort:Object']));_Ad(a._,qKe,cD(WC(qJ,1),Nve,2,6,[DKe,'http://www.w3.org/2001/XMLSchema#string']));} + function C0c(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o;m=RD(d.a,17).a;n=RD(d.b,17).a;l=a.b;o=a.c;h=0;k=0;if(b==(Cmd(),ymd)||b==zmd){k=Uvb(QCb(HDb(GDb(new SDb(null,new Swb(c.b,16)),new b2c),new b1c)));if(l.e.b+l.f.b/2>k){j=++n;h=Kfb(UD(Lvb(JDb(GDb(new SDb(null,new Swb(c.b,16)),new d2c(e,j)),new d1c))));}else {i=++m;h=Kfb(UD(Lvb(KDb(GDb(new SDb(null,new Swb(c.b,16)),new f2c(e,i)),new h1c))));}}else {k=Uvb(QCb(HDb(GDb(new SDb(null,new Swb(c.b,16)),new x1c),new l1c)));if(l.e.a+l.f.a/2>k){j=++n;h=Kfb(UD(Lvb(JDb(GDb(new SDb(null,new Swb(c.b,16)),new z1c(e,j)),new n1c))));}else {i=++m;h=Kfb(UD(Lvb(KDb(GDb(new SDb(null,new Swb(c.b,16)),new B1c(e,i)),new r1c))));}}if(b==ymd){Oub(a.a,new rjd(Kfb(UD(mQb(l,(q$c(),f$c))))-e,h));Oub(a.a,new rjd(o.e.a+o.f.a+e+f,h));Oub(a.a,new rjd(o.e.a+o.f.a+e+f,o.e.b+o.f.b/2));Oub(a.a,new rjd(o.e.a+o.f.a,o.e.b+o.f.b/2));}else if(b==zmd){Oub(a.a,new rjd(Kfb(UD(mQb(l,(q$c(),e$c))))+e,l.e.b+l.f.b/2));Oub(a.a,new rjd(l.e.a+l.f.a+e,h));Oub(a.a,new rjd(o.e.a-e-f,h));Oub(a.a,new rjd(o.e.a-e-f,o.e.b+o.f.b/2));Oub(a.a,new rjd(o.e.a,o.e.b+o.f.b/2));}else if(b==Bmd){Oub(a.a,new rjd(h,Kfb(UD(mQb(l,(q$c(),f$c))))-e));Oub(a.a,new rjd(h,o.e.b+o.f.b+e+f));Oub(a.a,new rjd(o.e.a+o.f.a/2,o.e.b+o.f.b+e+f));Oub(a.a,new rjd(o.e.a+o.f.a/2,o.e.b+o.f.b+e));}else {a.a.b==0||(RD(Rub(a.a),8).b=Kfb(UD(mQb(l,(q$c(),e$c))))+e*RD(g.b,17).a);Oub(a.a,new rjd(h,Kfb(UD(mQb(l,(q$c(),e$c))))+e*RD(g.b,17).a));Oub(a.a,new rjd(h,o.e.b-e*RD(g.a,17).a-f));}return new Ptd(sgb(m),sgb(n))} + function ASd(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;g=true;l=null;d=null;e=null;b=false;n=_Rd;j=null;f=null;h=0;i=sSd(a,h,ZRd,$Rd);if(i=0&&lhb(a.substr(h,'//'.length),'//')){h+=2;i=sSd(a,h,aSd,bSd);d=(AFb(h,i,a.length),a.substr(h,i-h));h=i;}else if(l!=null&&(h==a.length||(BFb(h,a.length),a.charCodeAt(h)!=47))){g=false;i=rhb(a,Fhb(35),h);i==-1&&(i=a.length);d=(AFb(h,i,a.length),a.substr(h,i-h));h=i;}if(!c&&h0&&ihb(k,k.length-1)==58){e=k;h=i;}}if(hqQc(f))&&(l=f);}}!l&&(l=(tFb(0,q.c.length),RD(q.c[0],185)));for(p=new Anb(b.b);p.al){F=0;G+=k+A;k=0;}FVc(v,g,F,G);b=$wnd.Math.max(b,F+w.a);k=$wnd.Math.max(k,w.b);F+=w.a+A;}u=new Tsb;c=new Tsb;for(C=new Anb(a);C.a=-1900?1:0;c>=4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Qwe,Rwe])[h]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['BC','AD'])[h]);break;case 121:AA(a,c,d);break;case 77:zA(a,c,d);break;case 107:i=e.q.getHours();i==0?UA(a,24,c):UA(a,i,c);break;case 83:yA(a,c,e);break;case 69:k=d.q.getDay();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['S','M','T','W','T','F','S'])[k]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Swe,Twe,Uwe,Vwe,Wwe,Xwe,Ywe])[k]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[k]);break;case 97:e.q.getHours()>=12&&e.q.getHours()<24?Zhb(a,cD(WC(qJ,1),Nve,2,6,['AM','PM'])[1]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['AM','PM'])[0]);break;case 104:l=e.q.getHours()%12;l==0?UA(a,12,c):UA(a,l,c);break;case 75:m=e.q.getHours()%12;UA(a,m,c);break;case 72:n=e.q.getHours();UA(a,n,c);break;case 99:o=d.q.getDay();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['S','M','T','W','T','F','S'])[o]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Swe,Twe,Uwe,Vwe,Wwe,Xwe,Ywe])[o]):c==3?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[o]):UA(a,o,1);break;case 76:p=d.q.getMonth();c==5?Zhb(a,cD(WC(qJ,1),Nve,2,6,['J','F','M','A','M','J','J','A','S','O','N','D'])[p]):c==4?Zhb(a,cD(WC(qJ,1),Nve,2,6,[Cwe,Dwe,Ewe,Fwe,Gwe,Hwe,Iwe,Jwe,Kwe,Lwe,Mwe,Nwe])[p]):c==3?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Jan','Feb','Mar','Apr',Gwe,'Jun','Jul','Aug','Sep','Oct','Nov','Dec'])[p]):UA(a,p+1,c);break;case 81:q=d.q.getMonth()/3|0;c<4?Zhb(a,cD(WC(qJ,1),Nve,2,6,['Q1','Q2','Q3','Q4'])[q]):Zhb(a,cD(WC(qJ,1),Nve,2,6,['1st quarter','2nd quarter','3rd quarter','4th quarter'])[q]);break;case 100:r=d.q.getDate();UA(a,r,c);break;case 109:j=e.q.getMinutes();UA(a,j,c);break;case 115:g=e.q.getSeconds();UA(a,g,c);break;case 122:c<4?Zhb(a,f.c[0]):Zhb(a,f.c[1]);break;case 118:Zhb(a,f.b);break;case 90:c<3?Zhb(a,cB(f)):c==3?Zhb(a,bB(f)):Zhb(a,eB(f.a));break;default:return false;}return true} + function f5b(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H;X4b(b);i=RD(QHd((!b.b&&(b.b=new Yie(E4,b,4,7)),b.b),0),84);k=RD(QHd((!b.c&&(b.c=new Yie(E4,b,5,8)),b.c),0),84);h=AGd(i);j=AGd(k);g=(!b.a&&(b.a=new C5d(F4,b,6,6)),b.a).i==0?null:RD(QHd((!b.a&&(b.a=new C5d(F4,b,6,6)),b.a),0),166);A=RD(Wjb(a.a,h),10);F=RD(Wjb(a.a,j),10);B=null;G=null;if(ZD(i,193)){w=RD(Wjb(a.a,i),305);if(ZD(w,12)){B=RD(w,12);}else if(ZD(w,10)){A=RD(w,10);B=RD(Vmb(A.j,0),12);}}if(ZD(k,193)){D=RD(Wjb(a.a,k),305);if(ZD(D,12)){G=RD(D,12);}else if(ZD(D,10)){F=RD(D,10);G=RD(Vmb(F.j,0),12);}}if(!A||!F){throw Adb(new Ked('The source or the target of edge '+b+' could not be found. '+'This usually happens when an edge connects a node laid out by ELK Layered to a node in '+'another level of hierarchy laid out by either another instance of ELK Layered or another '+'layout algorithm alltogether. The former can be solved by setting the hierarchyHandling '+'option to INCLUDE_CHILDREN.'))}p=new a1b;kQb(p,b);pQb(p,(Ywc(),Awc),b);pQb(p,(yCc(),RAc),null);n=RD(mQb(d,kwc),21);A==F&&n.Fc((ovc(),nvc));if(!B){v=(BEc(),zEc);C=null;if(!!g&&Dod(RD(mQb(A,BBc),101))){C=new rjd(g.j,g.k);Fsd(C,kzd(b));Gsd(C,c);if(NGd(j,h)){v=yEc;$id(C,A.n);}}B=g2b(A,C,v,d);}if(!G){v=(BEc(),yEc);H=null;if(!!g&&Dod(RD(mQb(F,BBc),101))){H=new rjd(g.b,g.c);Fsd(H,kzd(b));Gsd(H,c);}G=g2b(F,H,v,Y2b(F));}Y0b(p,B);Z0b(p,G);(B.e.c.length>1||B.g.c.length>1||G.e.c.length>1||G.g.c.length>1)&&n.Fc((ovc(),ivc));for(m=new dMd((!b.n&&(b.n=new C5d(I4,b,1,7)),b.n));m.e!=m.i.gc();){l=RD(bMd(m),135);if(!Heb(TD(Gxd(l,pBc)))&&!!l.a){q=h5b(l);Rmb(p.b,q);switch(RD(mQb(q,wAc),278).g){case 1:case 2:n.Fc((ovc(),gvc));break;case 0:n.Fc((ovc(),evc));pQb(q,wAc,(Omd(),Lmd));}}}f=RD(mQb(d,oAc),322);r=RD(mQb(d,kBc),323);e=f==(stc(),ptc)||r==(JDc(),FDc);if(!!g&&(!g.a&&(g.a=new XZd(D4,g,5)),g.a).i!=0&&e){s=ssd(g);o=new Ejd;for(u=Sub(s,0);u.b!=u.d.c;){t=RD(evb(u),8);Mub(o,new sjd(t));}pQb(p,Bwc,o);}return p} + function F0c(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I;C=0;D=0;A=new Tsb;v=RD(Lvb(JDb(GDb(new SDb(null,new Swb(a.b,16)),new v1c),new Z0c)),17).a+1;B=$C(kE,Pwe,28,v,15,1);q=$C(kE,Pwe,28,v,15,1);for(p=0;p1){for(h=G+1;hj.b.e.b*(1-r)+j.c.e.b*r){break}}if(w.gc()>0){H=j.a.b==0?ajd(j.b.e):RD(Rub(j.a),8);t=$id(ajd(RD(w.Xb(w.gc()-1),40).e),RD(w.Xb(w.gc()-1),40).f);m=$id(ajd(RD(w.Xb(0),40).e),RD(w.Xb(0),40).f);if(o>=w.gc()-1&&H.b>t.b&&j.c.e.b>t.b){continue}if(o<=0&&H.bj.b.e.a*(1-r)+j.c.e.a*r){break}}if(w.gc()>0){H=j.a.b==0?ajd(j.b.e):RD(Rub(j.a),8);t=$id(ajd(RD(w.Xb(w.gc()-1),40).e),RD(w.Xb(w.gc()-1),40).f);m=$id(ajd(RD(w.Xb(0),40).e),RD(w.Xb(0),40).f);if(o>=w.gc()-1&&H.a>t.a&&j.c.e.a>t.a){continue}if(o<=0&&H.a=Kfb(UD(mQb(a,(q$c(),$Zc))))&&++D;}else {n.f&&n.d.e.a<=Kfb(UD(mQb(a,(q$c(),ZZc))))&&++C;n.g&&n.c.e.a+n.c.f.a>=Kfb(UD(mQb(a,(q$c(),YZc))))&&++D;}}}else if(u==0){H0c(j);}else if(u<0){++B[G];++q[I];F=C0c(j,b,a,new Ptd(sgb(C),sgb(D)),c,d,new Ptd(sgb(q[I]),sgb(B[G])));C=RD(F.a,17).a;D=RD(F.b,17).a;}}} + function qrc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;d=b;i=c;if(a.b&&d.j==(qpd(),ppd)&&i.j==(qpd(),ppd)){s=d;d=i;i=s;}if(Ujb(a.a,d)){if(Zsb(RD(Wjb(a.a,d),49),i)){return 1}}else {Zjb(a.a,d,new _sb);}if(Ujb(a.a,i)){if(Zsb(RD(Wjb(a.a,i),49),d)){return -1}}else {Zjb(a.a,i,new _sb);}if(Ujb(a.d,d)){if(Zsb(RD(Wjb(a.d,d),49),i)){return -1}}else {Zjb(a.d,d,new _sb);}if(Ujb(a.d,i)){if(Zsb(RD(Wjb(a.a,i),49),d)){return 1}}else {Zjb(a.d,i,new _sb);}if(d.j!=i.j){r=yrc(d.j,i.j);r==-1?rrc(a,i,d):rrc(a,d,i);return r}if(d.e.c.length!=0&&i.e.c.length!=0){if(a.b){r=orc(d,i);if(r!=0){r==-1?rrc(a,i,d):r==1&&rrc(a,d,i);return r}}f=RD(Vmb(d.e,0),18).c.i;k=RD(Vmb(i.e,0),18).c.i;if(f==k){e=RD(mQb(RD(Vmb(d.e,0),18),(Ywc(),zwc)),17).a;j=RD(mQb(RD(Vmb(i.e,0),18),zwc),17).a;e>j?rrc(a,d,i):rrc(a,i,d);return ej?1:0}for(o=a.c,p=0,q=o.length;pj?rrc(a,d,i):rrc(a,i,d);return ej?1:0}if(a.b){r=orc(d,i);if(r!=0){r==-1?rrc(a,i,d):r==1&&rrc(a,d,i);return r}}g=0;l=0;nQb(RD(Vmb(d.g,0),18),zwc)&&(g=RD(mQb(RD(Vmb(d.g,0),18),zwc),17).a);nQb(RD(Vmb(i.g,0),18),zwc)&&(l=RD(mQb(RD(Vmb(d.g,0),18),zwc),17).a);if(!!h&&h==m){if(Heb(TD(mQb(RD(Vmb(d.g,0),18),Nwc)))&&!Heb(TD(mQb(RD(Vmb(i.g,0),18),Nwc)))){rrc(a,d,i);return 1}else if(!Heb(TD(mQb(RD(Vmb(d.g,0),18),Nwc)))&&Heb(TD(mQb(RD(Vmb(i.g,0),18),Nwc)))){rrc(a,i,d);return -1}g>l?rrc(a,d,i):rrc(a,i,d);return gl?1:0}if(a.f){a.f._b(h)&&(g=RD(a.f.xc(h),17).a);a.f._b(m)&&(l=RD(a.f.xc(m),17).a);}g>l?rrc(a,d,i):rrc(a,i,d);return gl?1:0}if(d.e.c.length!=0&&i.g.c.length!=0){rrc(a,d,i);return 1}else if(d.g.c.length!=0&&i.e.c.length!=0){rrc(a,i,d);return -1}else if(nQb(d,(Ywc(),zwc))&&nQb(i,zwc)){e=RD(mQb(d,zwc),17).a;j=RD(mQb(i,zwc),17).a;e>j?rrc(a,d,i):rrc(a,i,d);return ej?1:0}else {rrc(a,i,d);return -1}} + function Yae(a){if(a.gb)return;a.gb=true;a.b=jBd(a,0);iBd(a.b,18);oBd(a.b,19);a.a=jBd(a,1);iBd(a.a,1);oBd(a.a,2);oBd(a.a,3);oBd(a.a,4);oBd(a.a,5);a.o=jBd(a,2);iBd(a.o,8);iBd(a.o,9);oBd(a.o,10);oBd(a.o,11);oBd(a.o,12);oBd(a.o,13);oBd(a.o,14);oBd(a.o,15);oBd(a.o,16);oBd(a.o,17);oBd(a.o,18);oBd(a.o,19);oBd(a.o,20);oBd(a.o,21);oBd(a.o,22);oBd(a.o,23);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);nBd(a.o);a.p=jBd(a,3);iBd(a.p,2);iBd(a.p,3);iBd(a.p,4);iBd(a.p,5);oBd(a.p,6);oBd(a.p,7);nBd(a.p);nBd(a.p);a.q=jBd(a,4);iBd(a.q,8);a.v=jBd(a,5);oBd(a.v,9);nBd(a.v);nBd(a.v);nBd(a.v);a.w=jBd(a,6);iBd(a.w,2);iBd(a.w,3);iBd(a.w,4);oBd(a.w,5);a.B=jBd(a,7);oBd(a.B,1);nBd(a.B);nBd(a.B);nBd(a.B);a.Q=jBd(a,8);oBd(a.Q,0);nBd(a.Q);a.R=jBd(a,9);iBd(a.R,1);a.S=jBd(a,10);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);nBd(a.S);a.T=jBd(a,11);oBd(a.T,10);oBd(a.T,11);oBd(a.T,12);oBd(a.T,13);oBd(a.T,14);nBd(a.T);nBd(a.T);a.U=jBd(a,12);iBd(a.U,2);iBd(a.U,3);oBd(a.U,4);oBd(a.U,5);oBd(a.U,6);oBd(a.U,7);nBd(a.U);a.V=jBd(a,13);oBd(a.V,10);a.W=jBd(a,14);iBd(a.W,18);iBd(a.W,19);iBd(a.W,20);oBd(a.W,21);oBd(a.W,22);oBd(a.W,23);a.bb=jBd(a,15);iBd(a.bb,10);iBd(a.bb,11);iBd(a.bb,12);iBd(a.bb,13);iBd(a.bb,14);iBd(a.bb,15);iBd(a.bb,16);oBd(a.bb,17);nBd(a.bb);nBd(a.bb);a.eb=jBd(a,16);iBd(a.eb,2);iBd(a.eb,3);iBd(a.eb,4);iBd(a.eb,5);iBd(a.eb,6);iBd(a.eb,7);oBd(a.eb,8);oBd(a.eb,9);a.ab=jBd(a,17);iBd(a.ab,0);iBd(a.ab,1);a.H=jBd(a,18);oBd(a.H,0);oBd(a.H,1);oBd(a.H,2);oBd(a.H,3);oBd(a.H,4);oBd(a.H,5);nBd(a.H);a.db=jBd(a,19);oBd(a.db,2);a.c=kBd(a,20);a.d=kBd(a,21);a.e=kBd(a,22);a.f=kBd(a,23);a.i=kBd(a,24);a.g=kBd(a,25);a.j=kBd(a,26);a.k=kBd(a,27);a.n=kBd(a,28);a.r=kBd(a,29);a.s=kBd(a,30);a.t=kBd(a,31);a.u=kBd(a,32);a.fb=kBd(a,33);a.A=kBd(a,34);a.C=kBd(a,35);a.D=kBd(a,36);a.F=kBd(a,37);a.G=kBd(a,38);a.I=kBd(a,39);a.J=kBd(a,40);a.L=kBd(a,41);a.M=kBd(a,42);a.N=kBd(a,43);a.O=kBd(a,44);a.P=kBd(a,45);a.X=kBd(a,46);a.Y=kBd(a,47);a.Z=kBd(a,48);a.$=kBd(a,49);a._=kBd(a,50);a.cb=kBd(a,51);a.K=kBd(a,52);} + function d5b(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G;g=new Yub;w=RD(mQb(c,(yCc(),rAc)),88);p=0;ye(g,(!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));while(g.b!=0){k=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),27);j=vCd(k);(dE(Gxd(j,cAc))!==dE((kEc(),hEc))||dE(Gxd(j,pAc))===dE((Ptc(),Otc))||dE(Gxd(j,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(j,eAc)))||dE(Gxd(j,Yzc))!==dE((U$b(),T$b))||dE(Gxd(j,ZAc))===dE((aEc(),TDc))||dE(Gxd(j,ZAc))===dE((aEc(),UDc))||dE(Gxd(j,$Ac))===dE((_Cc(),SCc))||dE(Gxd(j,$Ac))===dE((_Cc(),UCc)))&&!Heb(TD(Gxd(k,aAc)))&&Ixd(k,(Ywc(),zwc),sgb(p++));r=!Heb(TD(Gxd(k,pBc)));if(r){m=(!k.a&&(k.a=new C5d(J4,k,10,11)),k.a).i!=0;o=a5b(k);n=dE(Gxd(k,IAc))===dE((Fnd(),Cnd));G=!Hxd(k,(umd(),Akd))||khb(WD(Gxd(k,Akd)));u=null;if(G&&n&&(m||o)){u=Z4b(k);pQb(u,rAc,w);nQb(u,PBc)&&HCc(new RCc(Kfb(UD(mQb(u,PBc)))),u);if(RD(Gxd(k,lBc),181).gc()!=0){l=u;FDb(new SDb(null,(!k.c&&(k.c=new C5d(K4,k,9,9)),new Swb(k.c,16))),new u5b(l));V4b(k,u);}}A=c;B=RD(Wjb(a.a,vCd(k)),10);!!B&&(A=B.e);t=i5b(a,k,A);if(u){t.e=u;u.e=t;ye(g,(!k.a&&(k.a=new C5d(J4,k,10,11)),k.a));}}}p=0;Pub(g,b,g.c.b,g.c);while(g.b!=0){f=RD(g.b==0?null:(sFb(g.b!=0),Wub(g,g.a.a)),27);for(i=new dMd((!f.b&&(f.b=new C5d(G4,f,12,3)),f.b));i.e!=i.i.gc();){h=RD(bMd(i),74);X4b(h);(dE(Gxd(b,cAc))!==dE((kEc(),hEc))||dE(Gxd(b,pAc))===dE((Ptc(),Otc))||dE(Gxd(b,pAc))===dE((Ptc(),Mtc))||Heb(TD(Gxd(b,eAc)))||dE(Gxd(b,Yzc))!==dE((U$b(),T$b))||dE(Gxd(b,ZAc))===dE((aEc(),TDc))||dE(Gxd(b,ZAc))===dE((aEc(),UDc))||dE(Gxd(b,$Ac))===dE((_Cc(),SCc))||dE(Gxd(b,$Ac))===dE((_Cc(),UCc)))&&Ixd(h,(Ywc(),zwc),sgb(p++));D=AGd(RD(QHd((!h.b&&(h.b=new Yie(E4,h,4,7)),h.b),0),84));F=AGd(RD(QHd((!h.c&&(h.c=new Yie(E4,h,5,8)),h.c),0),84));if(Heb(TD(Gxd(h,pBc)))||Heb(TD(Gxd(D,pBc)))||Heb(TD(Gxd(F,pBc)))){continue}q=ozd(h)&&Heb(TD(Gxd(D,NAc)))&&Heb(TD(Gxd(h,OAc)));v=f;q||NGd(F,D)?(v=D):NGd(D,F)&&(v=F);A=c;B=RD(Wjb(a.a,v),10);!!B&&(A=B.e);s=f5b(a,h,v,A);pQb(s,(Ywc(),Zvc),_4b(a,h,b,c));}n=dE(Gxd(f,IAc))===dE((Fnd(),Cnd));if(n){for(e=new dMd((!f.a&&(f.a=new C5d(J4,f,10,11)),f.a));e.e!=e.i.gc();){d=RD(bMd(e),27);G=!Hxd(d,(umd(),Akd))||khb(WD(Gxd(d,Akd)));C=dE(Gxd(d,IAc))===dE(Cnd);G&&C&&(Pub(g,d,g.c.b,g.c),true);}}}} + function Ywc(){Ywc=geb;var a,b;Awc=new jGd(rAe);Zvc=new jGd('coordinateOrigin');Kwc=new jGd('processors');Yvc=new kGd('compoundNode',(Geb(),false));nwc=new kGd('insideConnections',false);Bwc=new jGd('originalBendpoints');Cwc=new jGd('originalDummyNodePosition');Dwc=new jGd('originalLabelEdge');Mwc=new jGd('representedLabels');cwc=new jGd('endLabels');dwc=new jGd('endLabel.origin');swc=new kGd('labelSide',(Pnd(),Ond));ywc=new kGd('maxEdgeThickness',0);Nwc=new kGd('reversed',false);Lwc=new jGd(sAe);vwc=new kGd('longEdgeSource',null);wwc=new kGd('longEdgeTarget',null);uwc=new kGd('longEdgeHasLabelDummies',false);twc=new kGd('longEdgeBeforeLabelDummy',false);bwc=new kGd('edgeConstraint',(huc(),fuc));pwc=new jGd('inLayerLayoutUnit');owc=new kGd('inLayerConstraint',(Gvc(),Evc));qwc=new kGd('inLayerSuccessorConstraint',new bnb);rwc=new kGd('inLayerSuccessorConstraintBetweenNonDummies',false);Iwc=new jGd('portDummy');$vc=new kGd('crossingHint',sgb(0));kwc=new kGd('graphProperties',(b=RD(mfb(iX),9),new Fsb(b,RD(WEb(b,b.length),9),0)));hwc=new kGd('externalPortSide',(qpd(),opd));iwc=new kGd('externalPortSize',new pjd);fwc=new jGd('externalPortReplacedDummies');gwc=new jGd('externalPortReplacedDummy');ewc=new kGd('externalPortConnections',(a=RD(mfb(E3),9),new Fsb(a,RD(WEb(a,a.length),9),0)));Jwc=new kGd(Xye,0);Uvc=new jGd('barycenterAssociates');Xwc=new jGd('TopSideComments');Vvc=new jGd('BottomSideComments');Xvc=new jGd('CommentConnectionPort');mwc=new kGd('inputCollect',false);Gwc=new kGd('outputCollect',false);awc=new kGd('cyclic',false);_vc=new jGd('crossHierarchyMap');Wwc=new jGd('targetOffset');new kGd('splineLabelSize',new pjd);Qwc=new jGd('spacings');Hwc=new kGd('partitionConstraint',false);Wvc=new jGd('breakingPoint.info');Uwc=new jGd('splines.survivingEdge');Twc=new jGd('splines.route.start');Rwc=new jGd('splines.edgeChain');Fwc=new jGd('originalPortConstraints');Pwc=new jGd('selfLoopHolder');Swc=new jGd('splines.nsPortY');zwc=new jGd('modelOrder');xwc=new jGd('longEdgeTargetNode');jwc=new kGd(GBe,false);Owc=new kGd(GBe,false);lwc=new jGd('layerConstraints.hiddenNodes');Ewc=new jGd('layerConstraints.opposidePort');Vwc=new jGd('targetNode.modelOrder');} + function D0c(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o;for(l=Sub(a.b,0);l.b!=l.d.c;){k=RD(evb(l),40);if(lhb(k.c,IEe)){continue}f=RD(zDb(new SDb(null,new Swb(hWc(k,a),16)),tBb(new ZBb,new XBb,new wCb,cD(WC(QL,1),jwe,108,0,[(xBb(),vBb)]))),15);b==(Cmd(),ymd)||b==zmd?f.jd(new L1c):f.jd(new R1c);o=f.gc();for(e=0;e0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(i-n)/($wnd.Math.abs(h-m)/40)>50&&(n>i?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a+d/5.3,k.e.b+k.f.b*g-d/2)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a+d/5.3,k.e.b+k.f.b*g+d/2)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a,k.e.b+k.f.b*g));}else if(b==zmd){j=Kfb(UD(mQb(k,(q$c(),f$c))));if(k.e.a-d>j){Oub(RD(f.Xb(e),65).a,new rjd(j-c,k.e.b+k.f.b*g));}else if(RD(f.Xb(e),65).a.b>0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(i-n)/($wnd.Math.abs(h-m)/40)>50&&(n>i?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a-d/5.3,k.e.b+k.f.b*g-d/2)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a-d/5.3,k.e.b+k.f.b*g+d/2)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a,k.e.b+k.f.b*g));}else if(b==Bmd){j=Kfb(UD(mQb(k,(q$c(),e$c))));if(k.e.b+k.f.b+d0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(h-m)/($wnd.Math.abs(i-n)/40)>50&&(m>h?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g-d/2,k.e.b+d/5.3+k.f.b)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g+d/2,k.e.b+d/5.3+k.f.b)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,k.e.b+k.f.b));}else {j=Kfb(UD(mQb(k,(q$c(),f$c))));if(mWc(RD(f.Xb(e),65),a)){Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,RD(Rub(RD(f.Xb(e),65).a),8).b));}else if(k.e.b-d>j){Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,j-c));}else if(RD(f.Xb(e),65).a.b>0){h=RD(Rub(RD(f.Xb(e),65).a),8).a;m=k.e.a+k.f.a/2;i=RD(Rub(RD(f.Xb(e),65).a),8).b;n=k.e.b+k.f.b/2;d>0&&$wnd.Math.abs(h-m)/($wnd.Math.abs(i-n)/40)>50&&(m>h?Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g-d/2,k.e.b-d/5.3)):Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g+d/2,k.e.b-d/5.3)));}Oub(RD(f.Xb(e),65).a,new rjd(k.e.a+k.f.a*g,k.e.b));}}}} + function umd(){umd=geb;var a,b;Akd=new jGd(OGe);Tld=new jGd(PGe);Ckd=(Rjd(),Ljd);Bkd=new lGd(MDe,Ckd);Dkd=new lGd(Dze,null);Ekd=new jGd(QGe);Lkd=(ukd(),ysb(tkd,cD(WC(q3,1),jwe,298,0,[pkd])));Kkd=new lGd(YDe,Lkd);Mkd=new lGd(LDe,(Geb(),false));Okd=(Cmd(),Amd);Nkd=new lGd(PDe,Okd);Tkd=(Ymd(),Xmd);Skd=new lGd(kDe,Tkd);Wkd=new lGd(MGe,false);Ykd=(Fnd(),Dnd);Xkd=new lGd(fDe,Ykd);uld=new A3b(12);tld=new lGd(Eze,uld);ald=new lGd(dAe,false);bld=new lGd(iEe,false);sld=new lGd(gAe,false);Ild=(Bod(),Aod);Hld=new lGd(eAe,Ild);Qld=new jGd(fEe);Rld=new jGd($ze);Sld=new jGd(bAe);Vld=new jGd(cAe);dld=new Ejd;cld=new lGd(ZDe,dld);Jkd=new lGd(aEe,false);Zkd=new lGd(bEe,false);fld=new P2b;eld=new lGd(gEe,fld);rld=new lGd(JDe,false);Uld=new lGd(SGe,1);Ikd=new jGd(TGe);Hkd=new jGd(UGe);mmd=new lGd(mAe,false);new lGd(VGe,true);sgb(0);new lGd(WGe,sgb(100));new lGd(XGe,false);sgb(0);new lGd(YGe,sgb(4000));sgb(0);new lGd(ZGe,sgb(400));new lGd($Ge,false);new lGd(_Ge,false);new lGd(aHe,true);new lGd(bHe,false);Gkd=(Grd(),Frd);Fkd=new lGd(NGe,Gkd);Wld=new lGd(xDe,10);Xld=new lGd(yDe,10);Yld=new lGd(Bze,20);Zld=new lGd(zDe,10);$ld=new lGd(aAe,2);_ld=new lGd(ADe,10);bmd=new lGd(BDe,0);cmd=new lGd(EDe,5);dmd=new lGd(CDe,1);emd=new lGd(DDe,1);fmd=new lGd(_ze,20);gmd=new lGd(FDe,10);jmd=new lGd(GDe,10);amd=new jGd(HDe);imd=new Q2b;hmd=new lGd(hEe,imd);xld=new jGd(eEe);wld=false;vld=new lGd(dEe,wld);hld=new A3b(5);gld=new lGd(QDe,hld);jld=(dod(),b=RD(mfb(A3),9),new Fsb(b,RD(WEb(b,b.length),9),0));ild=new lGd(kAe,jld);Ald=(pod(),mod);zld=new lGd(TDe,Ald);Cld=new jGd(UDe);Dld=new jGd(VDe);Eld=new jGd(WDe);Bld=new jGd(XDe);lld=(a=RD(mfb(H3),9),new Fsb(a,RD(WEb(a,a.length),9),0));kld=new lGd(jAe,lld);qld=xsb((dqd(),Ypd));pld=new lGd(iAe,qld);old=new rjd(0,0);nld=new lGd(CAe,old);mld=new lGd(hAe,false);Rkd=(Omd(),Lmd);Qkd=new lGd($De,Rkd);Pkd=new lGd(fAe,false);sgb(1);new lGd(dHe,null);Fld=new jGd(cEe);Jld=new jGd(_De);Pld=(qpd(),opd);Old=new lGd(KDe,Pld);Gld=new jGd(IDe);Mld=(Pod(),xsb(Nod));Lld=new lGd(lAe,Mld);Kld=new lGd(RDe,false);Nld=new lGd(SDe,true);qmd=new lGd(nAe,1);smd=new lGd(eHe,null);lmd=new lGd(oAe,150);kmd=new lGd(pAe,1.414);nmd=new lGd(qAe,null);omd=new lGd(fHe,1);$kd=new lGd(NDe,false);_kd=new lGd(ODe,false);Ukd=new lGd(Cze,1);Vkd=(ind(),gnd);new lGd(gHe,Vkd);yld=true;rmd=(mqd(),jqd);tmd=jqd;pmd=jqd;} + function hcc(){hcc=geb;nbc=new icc('DIRECTION_PREPROCESSOR',0);kbc=new icc('COMMENT_PREPROCESSOR',1);obc=new icc('EDGE_AND_LAYER_CONSTRAINT_EDGE_REVERSER',2);Ebc=new icc('INTERACTIVE_EXTERNAL_PORT_POSITIONER',3);Xbc=new icc('PARTITION_PREPROCESSOR',4);Ibc=new icc('LABEL_DUMMY_INSERTER',5);bcc=new icc('SELF_LOOP_PREPROCESSOR',6);Nbc=new icc('LAYER_CONSTRAINT_PREPROCESSOR',7);Vbc=new icc('PARTITION_MIDPROCESSOR',8);zbc=new icc('HIGH_DEGREE_NODE_LAYER_PROCESSOR',9);Rbc=new icc('NODE_PROMOTION',10);Mbc=new icc('LAYER_CONSTRAINT_POSTPROCESSOR',11);Wbc=new icc('PARTITION_POSTPROCESSOR',12);vbc=new icc('HIERARCHICAL_PORT_CONSTRAINT_PROCESSOR',13);dcc=new icc('SEMI_INTERACTIVE_CROSSMIN_PROCESSOR',14);ebc=new icc('BREAKING_POINT_INSERTER',15);Qbc=new icc('LONG_EDGE_SPLITTER',16);Zbc=new icc('PORT_SIDE_PROCESSOR',17);Fbc=new icc('INVERTED_PORT_PROCESSOR',18);Ybc=new icc('PORT_LIST_SORTER',19);fcc=new icc('SORT_BY_INPUT_ORDER_OF_MODEL',20);Tbc=new icc('NORTH_SOUTH_PORT_PREPROCESSOR',21);fbc=new icc('BREAKING_POINT_PROCESSOR',22);Ubc=new icc(jBe,23);gcc=new icc(kBe,24);_bc=new icc('SELF_LOOP_PORT_RESTORER',25);ecc=new icc('SINGLE_EDGE_GRAPH_WRAPPER',26);Gbc=new icc('IN_LAYER_CONSTRAINT_PROCESSOR',27);sbc=new icc('END_NODE_PORT_LABEL_MANAGEMENT_PROCESSOR',28);Hbc=new icc('LABEL_AND_NODE_SIZE_PROCESSOR',29);Dbc=new icc('INNERMOST_NODE_MARGIN_CALCULATOR',30);ccc=new icc('SELF_LOOP_ROUTER',31);ibc=new icc('COMMENT_NODE_MARGIN_CALCULATOR',32);qbc=new icc('END_LABEL_PREPROCESSOR',33);Kbc=new icc('LABEL_DUMMY_SWITCHER',34);hbc=new icc('CENTER_LABEL_MANAGEMENT_PROCESSOR',35);Lbc=new icc('LABEL_SIDE_SELECTOR',36);Bbc=new icc('HYPEREDGE_DUMMY_MERGER',37);wbc=new icc('HIERARCHICAL_PORT_DUMMY_SIZE_PROCESSOR',38);Obc=new icc('LAYER_SIZE_AND_GRAPH_HEIGHT_CALCULATOR',39);ybc=new icc('HIERARCHICAL_PORT_POSITION_PROCESSOR',40);lbc=new icc('CONSTRAINTS_POSTPROCESSOR',41);jbc=new icc('COMMENT_POSTPROCESSOR',42);Cbc=new icc('HYPERNODE_PROCESSOR',43);xbc=new icc('HIERARCHICAL_PORT_ORTHOGONAL_EDGE_ROUTER',44);Pbc=new icc('LONG_EDGE_JOINER',45);acc=new icc('SELF_LOOP_POSTPROCESSOR',46);gbc=new icc('BREAKING_POINT_REMOVER',47);Sbc=new icc('NORTH_SOUTH_PORT_POSTPROCESSOR',48);Abc=new icc('HORIZONTAL_COMPACTOR',49);Jbc=new icc('LABEL_DUMMY_REMOVER',50);tbc=new icc('FINAL_SPLINE_BENDPOINTS_CALCULATOR',51);rbc=new icc('END_LABEL_SORTER',52);$bc=new icc('REVERSED_EDGE_RESTORER',53);pbc=new icc('END_LABEL_POSTPROCESSOR',54);ubc=new icc('HIERARCHICAL_NODE_RESIZER',55);mbc=new icc('DIRECTION_POSTPROCESSOR',56);} + function Ozc(){Ozc=geb;Uxc=($tc(),Ytc);Txc=new lGd(HBe,Uxc);jyc=new lGd(IBe,(Geb(),false));pyc=(Ovc(),Mvc);oyc=new lGd(JBe,pyc);Hyc=new lGd(KBe,false);Iyc=new lGd(LBe,true);ixc=new lGd(MBe,false);azc=(sEc(),qEc);_yc=new lGd(NBe,azc);sgb(1);izc=new lGd(OBe,sgb(7));jzc=new lGd(PBe,false);kyc=new lGd(QBe,false);Sxc=(Ptc(),Ltc);Rxc=new lGd(RBe,Sxc);Gyc=(_Cc(),ZCc);Fyc=new lGd(SBe,Gyc);wyc=(cxc(),bxc);vyc=new lGd(TBe,wyc);sgb(-1);uyc=new lGd(UBe,null);sgb(-1);xyc=new lGd(VBe,sgb(-1));sgb(-1);yyc=new lGd(WBe,sgb(4));sgb(-1);Ayc=new lGd(XBe,sgb(2));Eyc=(aEc(),$Dc);Dyc=new lGd(YBe,Eyc);sgb(0);Cyc=new lGd(ZBe,sgb(0));syc=new lGd($Be,sgb(lve));Qxc=(stc(),qtc);Pxc=new lGd(_Be,Qxc);yxc=new lGd(aCe,false);Hxc=new lGd(bCe,0.1);Nxc=new lGd(cCe,false);Jxc=new lGd(dCe,null);Kxc=new lGd(eCe,null);sgb(-1);Lxc=new lGd(fCe,null);sgb(-1);Mxc=new lGd(gCe,sgb(-1));sgb(0);zxc=new lGd(hCe,sgb(40));Fxc=(xvc(),wvc);Exc=new lGd(iCe,Fxc);Bxc=uvc;Axc=new lGd(jCe,Bxc);$yc=(JDc(),EDc);Zyc=new lGd(kCe,$yc);Pyc=new jGd(lCe);Kyc=(Cuc(),Auc);Jyc=new lGd(mCe,Kyc);Nyc=(Ouc(),Luc);Myc=new lGd(nCe,Nyc);Syc=new lGd(oCe,0.3);Uyc=new jGd(pCe);Wyc=(wDc(),uDc);Vyc=new lGd(qCe,Wyc);ayc=(KEc(),IEc);_xc=new lGd(rCe,ayc);cyc=(TEc(),SEc);byc=new lGd(sCe,cyc);eyc=(lFc(),kFc);dyc=new lGd(tCe,eyc);gyc=new lGd(uCe,0.2);Zxc=new lGd(vCe,2);ezc=new lGd(wCe,null);gzc=new lGd(xCe,10);fzc=new lGd(yCe,10);hzc=new lGd(zCe,20);sgb(0);bzc=new lGd(ACe,sgb(0));sgb(0);czc=new lGd(BCe,sgb(0));sgb(0);dzc=new lGd(CCe,sgb(0));jxc=new lGd(DCe,false);nxc=($uc(),Yuc);mxc=new lGd(ECe,nxc);lxc=(jtc(),itc);kxc=new lGd(FCe,lxc);myc=new lGd(GCe,false);sgb(0);lyc=new lGd(HCe,sgb(16));sgb(0);nyc=new lGd(ICe,sgb(5));Gzc=(DFc(),BFc);Fzc=new lGd(JCe,Gzc);kzc=new lGd(KCe,10);nzc=new lGd(LCe,1);wzc=(Etc(),Dtc);vzc=new lGd(MCe,wzc);qzc=new jGd(NCe);tzc=sgb(1);sgb(0);szc=new lGd(OCe,tzc);Lzc=(uFc(),rFc);Kzc=new lGd(PCe,Lzc);Hzc=new jGd(QCe);Bzc=new lGd(RCe,true);zzc=new lGd(SCe,2);Dzc=new lGd(TCe,true);Yxc=(tuc(),ruc);Xxc=new lGd(UCe,Yxc);Wxc=(btc(),Zsc);Vxc=new lGd(VCe,Wxc);xxc=(kEc(),hEc);wxc=new lGd(WCe,xxc);vxc=new lGd(XCe,false);uxc=new lGd(YCe,false);pxc=(U$b(),T$b);oxc=new lGd(ZCe,pxc);txc=(lDc(),iDc);sxc=new lGd($Ce,txc);qxc=new lGd(_Ce,0);rxc=new lGd(aDe,0);ryc=Ntc;qyc=ptc;zyc=YCc;Byc=YCc;tyc=TCc;Ixc=(Fnd(),Cnd);Oxc=qtc;Gxc=qtc;Cxc=qtc;Dxc=Cnd;Qyc=HDc;Ryc=EDc;Lyc=EDc;Oyc=EDc;Tyc=GDc;Yyc=HDc;Xyc=HDc;fyc=(Ymd(),Wmd);hyc=Wmd;iyc=kFc;$xc=Vmd;lzc=CFc;mzc=AFc;ozc=CFc;pzc=AFc;xzc=CFc;yzc=AFc;rzc=Ctc;uzc=Dtc;Mzc=CFc;Nzc=AFc;Izc=CFc;Jzc=AFc;Czc=AFc;Azc=AFc;Ezc=AFc;} + function iNc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,ab,bb,cb,db,eb,fb,gb,hb,ib,jb,kb,lb;cb=0;for(H=b,K=0,N=H.length;K0&&(a.a[U.p]=cb++);}}hb=0;for(I=c,L=0,O=I.length;L0){U=(sFb(Y.b>0),RD(Y.a.Xb(Y.c=--Y.b),12));X=0;for(h=new Anb(U.e);h.a0){if(U.j==(qpd(),Yod)){a.a[U.p]=hb;++hb;}else {a.a[U.p]=hb+P+R;++R;}}}hb+=R;}W=new Tsb;o=new Iub;for(G=b,J=0,M=G.length;Jj.b&&(j.b=Z);}else if(U.i.c==bb){Zj.c&&(j.c=Z);}}}Wnb(p,0,p.length,null);gb=$C(kE,Pwe,28,p.length,15,1);d=$C(kE,Pwe,28,hb+1,15,1);for(r=0;r0){A%2>0&&(e+=kb[A+1]);A=(A-1)/2|0;++kb[A];}}C=$C(NY,rve,374,p.length*2,0,1);for(u=0;u0&&(ltd(J.f),false)){if(RD(Gxd(r,nmd),280)==jqd){throw Adb(new Jed('Topdown Layout Providers should only be used on parallel nodes.'))}fE(ltd(J.f));null.Um();zyd(r,$wnd.Math.max(r.g,null.Vm),$wnd.Math.max(r.f,null.Vm));}else if(Gxd(r,smd)!=null){h=RD(Gxd(r,smd),347);W=h.Tg(r);zyd(r,$wnd.Math.max(r.g,W.a),$wnd.Math.max(r.f,W.b));}}}O=RD(Gxd(b,tld),107);n=b.g-(O.b+O.c);m=b.f-(O.d+O.a);Z.bh('Available Child Area: ('+n+'|'+m+')');Ixd(b,Dkd,n/m);Ced(b,e,d.eh(M));if(RD(Gxd(b,nmd),280)==lqd){psd(b);zyd(b,O.b+Kfb(UD(Gxd(b,Ikd)))+O.c,O.d+Kfb(UD(Gxd(b,Hkd)))+O.a);}Z.bh('Executed layout algorithm: '+WD(Gxd(b,Akd))+' on node '+b.k);if(RD(Gxd(b,nmd),280)==jqd){if(n<0||m<0){throw Adb(new Jed('The size defined by the parent parallel node is too small for the space provided by the paddings of the child hierarchical node. '+b.k))}Hxd(b,Ikd)||Hxd(b,Hkd)||psd(b);p=Kfb(UD(Gxd(b,Ikd)));o=Kfb(UD(Gxd(b,Hkd)));Z.bh('Desired Child Area: ('+p+'|'+o+')');Q=n/p;R=m/o;P=$wnd.Math.min(Q,$wnd.Math.min(R,Kfb(UD(Gxd(b,omd)))));Ixd(b,qmd,P);Z.bh(b.k+' -- Local Scale Factor (X|Y): ('+Q+'|'+R+')');u=RD(Gxd(b,Kkd),21);f=0;g=0;P'?":lhb(XIe,a)?"'(?<' or '(? toIndex: ',bye=', toIndex: ',cye='Index: ',dye=', Size: ',eye='org.eclipse.elk.alg.common',fye={50:1},gye='org.eclipse.elk.alg.common.compaction',hye='Scanline/EventHandler',iye='org.eclipse.elk.alg.common.compaction.oned',jye='CNode belongs to another CGroup.',kye='ISpacingsHandler/1',lye='The ',mye=' instance has been finished already.',nye='The direction ',oye=' is not supported by the CGraph instance.',pye='OneDimensionalCompactor',qye='OneDimensionalCompactor/lambda$0$Type',rye='Quadruplet',sye='ScanlineConstraintCalculator',tye='ScanlineConstraintCalculator/ConstraintsScanlineHandler',uye='ScanlineConstraintCalculator/ConstraintsScanlineHandler/lambda$0$Type',vye='ScanlineConstraintCalculator/Timestamp',wye='ScanlineConstraintCalculator/lambda$0$Type',xye={178:1,46:1},yye='org.eclipse.elk.alg.common.compaction.options',zye='org.eclipse.elk.core.data',Aye='org.eclipse.elk.polyomino.traversalStrategy',Bye='org.eclipse.elk.polyomino.lowLevelSort',Cye='org.eclipse.elk.polyomino.highLevelSort',Dye='org.eclipse.elk.polyomino.fill',Eye={134:1},Fye='polyomino',Gye='org.eclipse.elk.alg.common.networksimplex',Hye={183:1,3:1,4:1},Iye='org.eclipse.elk.alg.common.nodespacing',Jye='org.eclipse.elk.alg.common.nodespacing.cellsystem',Kye='CENTER',Lye={217:1,336:1},Mye={3:1,4:1,5:1,603:1},Nye='LEFT',Oye='RIGHT',Pye='Vertical alignment cannot be null',Qye='BOTTOM',Rye='org.eclipse.elk.alg.common.nodespacing.internal',Sye='UNDEFINED',Tye=0.01,Uye='org.eclipse.elk.alg.common.nodespacing.internal.algorithm',Vye='LabelPlacer/lambda$0$Type',Wye='LabelPlacer/lambda$1$Type',Xye='portRatioOrPosition',Yye='org.eclipse.elk.alg.common.overlaps',Zye='DOWN',$ye='org.eclipse.elk.alg.common.polyomino',_ye='NORTH',aze='EAST',bze='SOUTH',cze='WEST',dze='org.eclipse.elk.alg.common.polyomino.structures',eze='Direction',fze='Grid is only of size ',gze='. Requested point (',hze=') is out of bounds.',ize=' Given center based coordinates were (',jze='org.eclipse.elk.graph.properties',kze='IPropertyHolder',lze={3:1,96:1,137:1},mze='org.eclipse.elk.alg.common.spore',nze='org.eclipse.elk.alg.common.utils',oze={205:1},pze='org.eclipse.elk.core',qze='Connected Components Compaction',rze='org.eclipse.elk.alg.disco',sze='org.eclipse.elk.alg.disco.graph',tze='org.eclipse.elk.alg.disco.options',uze='CompactionStrategy',vze='org.eclipse.elk.disco.componentCompaction.strategy',wze='org.eclipse.elk.disco.componentCompaction.componentLayoutAlgorithm',xze='org.eclipse.elk.disco.debug.discoGraph',yze='org.eclipse.elk.disco.debug.discoPolys',zze='componentCompaction',Aze='org.eclipse.elk.disco',Bze='org.eclipse.elk.spacing.componentComponent',Cze='org.eclipse.elk.edge.thickness',Dze='org.eclipse.elk.aspectRatio',Eze='org.eclipse.elk.padding',Fze='org.eclipse.elk.alg.disco.transform',Gze=1.5707963267948966,Hze=1.7976931348623157E308,Ize={3:1,4:1,5:1,198:1},Jze={3:1,6:1,4:1,5:1,100:1,115:1},Kze='org.eclipse.elk.alg.force',Lze='ComponentsProcessor',Mze='ComponentsProcessor/1',Nze='ElkGraphImporter/lambda$0$Type',Oze='org.eclipse.elk.alg.force.graph',Pze='Component Layout',Qze='org.eclipse.elk.alg.force.model',Rze='org.eclipse.elk.force.model',Sze='org.eclipse.elk.force.iterations',Tze='org.eclipse.elk.force.repulsivePower',Uze='org.eclipse.elk.force.temperature',Vze=0.001,Wze='org.eclipse.elk.force.repulsion',Xze='org.eclipse.elk.alg.force.options',Yze=1.600000023841858,Zze='org.eclipse.elk.force',$ze='org.eclipse.elk.priority',_ze='org.eclipse.elk.spacing.nodeNode',aAe='org.eclipse.elk.spacing.edgeLabel',bAe='org.eclipse.elk.randomSeed',cAe='org.eclipse.elk.separateConnectedComponents',dAe='org.eclipse.elk.interactive',eAe='org.eclipse.elk.portConstraints',fAe='org.eclipse.elk.edgeLabels.inline',gAe='org.eclipse.elk.omitNodeMicroLayout',hAe='org.eclipse.elk.nodeSize.fixedGraphSize',iAe='org.eclipse.elk.nodeSize.options',jAe='org.eclipse.elk.nodeSize.constraints',kAe='org.eclipse.elk.nodeLabels.placement',lAe='org.eclipse.elk.portLabels.placement',mAe='org.eclipse.elk.topdownLayout',nAe='org.eclipse.elk.topdown.scaleFactor',oAe='org.eclipse.elk.topdown.hierarchicalNodeWidth',pAe='org.eclipse.elk.topdown.hierarchicalNodeAspectRatio',qAe='org.eclipse.elk.topdown.nodeType',rAe='origin',sAe='random',tAe='boundingBox.upLeft',uAe='boundingBox.lowRight',vAe='org.eclipse.elk.stress.fixed',wAe='org.eclipse.elk.stress.desiredEdgeLength',xAe='org.eclipse.elk.stress.dimension',yAe='org.eclipse.elk.stress.epsilon',zAe='org.eclipse.elk.stress.iterationLimit',AAe='org.eclipse.elk.stress',BAe='ELK Stress',CAe='org.eclipse.elk.nodeSize.minimum',DAe='org.eclipse.elk.alg.force.stress',EAe='Layered layout',FAe='org.eclipse.elk.alg.layered',GAe='org.eclipse.elk.alg.layered.compaction.components',HAe='org.eclipse.elk.alg.layered.compaction.oned',IAe='org.eclipse.elk.alg.layered.compaction.oned.algs',JAe='org.eclipse.elk.alg.layered.compaction.recthull',KAe='org.eclipse.elk.alg.layered.components',LAe='NONE',MAe='MODEL_ORDER',NAe={3:1,6:1,4:1,9:1,5:1,126:1},OAe={3:1,6:1,4:1,5:1,150:1,100:1,115:1},PAe='org.eclipse.elk.alg.layered.compound',QAe={47:1},RAe='org.eclipse.elk.alg.layered.graph',SAe=' -> ',TAe='Not supported by LGraph',UAe='Port side is undefined',VAe={3:1,6:1,4:1,5:1,483:1,150:1,100:1,115:1},WAe={3:1,6:1,4:1,5:1,150:1,199:1,210:1,100:1,115:1},XAe={3:1,6:1,4:1,5:1,150:1,2042:1,210:1,100:1,115:1},YAe='([{"\' \t\r\n',ZAe=')]}"\' \t\r\n',$Ae='The given string contains parts that cannot be parsed as numbers.',_Ae='org.eclipse.elk.core.math',aBe={3:1,4:1,140:1,214:1,423:1},bBe={3:1,4:1,107:1,214:1,423:1},cBe='org.eclipse.elk.alg.layered.graph.transform',dBe='ElkGraphImporter',eBe='ElkGraphImporter/lambda$1$Type',fBe='ElkGraphImporter/lambda$2$Type',gBe='ElkGraphImporter/lambda$4$Type',hBe='org.eclipse.elk.alg.layered.intermediate',iBe='Node margin calculation',jBe='ONE_SIDED_GREEDY_SWITCH',kBe='TWO_SIDED_GREEDY_SWITCH',lBe='No implementation is available for the layout processor ',mBe='IntermediateProcessorStrategy',nBe="Node '",oBe='FIRST_SEPARATE',pBe='LAST_SEPARATE',qBe='Odd port side processing',rBe='org.eclipse.elk.alg.layered.intermediate.compaction',sBe='org.eclipse.elk.alg.layered.intermediate.greedyswitch',tBe='org.eclipse.elk.alg.layered.p3order.counting',uBe={230:1},vBe='org.eclipse.elk.alg.layered.intermediate.loops',wBe='org.eclipse.elk.alg.layered.intermediate.loops.ordering',xBe='org.eclipse.elk.alg.layered.intermediate.loops.routing',yBe='org.eclipse.elk.alg.layered.intermediate.preserveorder',zBe='org.eclipse.elk.alg.layered.intermediate.wrapping',ABe='org.eclipse.elk.alg.layered.options',BBe='INTERACTIVE',CBe='GREEDY',DBe='DEPTH_FIRST',EBe='EDGE_LENGTH',FBe='SELF_LOOPS',GBe='firstTryWithInitialOrder',HBe='org.eclipse.elk.layered.directionCongruency',IBe='org.eclipse.elk.layered.feedbackEdges',JBe='org.eclipse.elk.layered.interactiveReferencePoint',KBe='org.eclipse.elk.layered.mergeEdges',LBe='org.eclipse.elk.layered.mergeHierarchyEdges',MBe='org.eclipse.elk.layered.allowNonFlowPortsToSwitchSides',NBe='org.eclipse.elk.layered.portSortingStrategy',OBe='org.eclipse.elk.layered.thoroughness',PBe='org.eclipse.elk.layered.unnecessaryBendpoints',QBe='org.eclipse.elk.layered.generatePositionAndLayerIds',RBe='org.eclipse.elk.layered.cycleBreaking.strategy',SBe='org.eclipse.elk.layered.layering.strategy',TBe='org.eclipse.elk.layered.layering.layerConstraint',UBe='org.eclipse.elk.layered.layering.layerChoiceConstraint',VBe='org.eclipse.elk.layered.layering.layerId',WBe='org.eclipse.elk.layered.layering.minWidth.upperBoundOnWidth',XBe='org.eclipse.elk.layered.layering.minWidth.upperLayerEstimationScalingFactor',YBe='org.eclipse.elk.layered.layering.nodePromotion.strategy',ZBe='org.eclipse.elk.layered.layering.nodePromotion.maxIterations',$Be='org.eclipse.elk.layered.layering.coffmanGraham.layerBound',_Be='org.eclipse.elk.layered.crossingMinimization.strategy',aCe='org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder',bCe='org.eclipse.elk.layered.crossingMinimization.hierarchicalSweepiness',cCe='org.eclipse.elk.layered.crossingMinimization.semiInteractive',dCe='org.eclipse.elk.layered.crossingMinimization.inLayerPredOf',eCe='org.eclipse.elk.layered.crossingMinimization.inLayerSuccOf',fCe='org.eclipse.elk.layered.crossingMinimization.positionChoiceConstraint',gCe='org.eclipse.elk.layered.crossingMinimization.positionId',hCe='org.eclipse.elk.layered.crossingMinimization.greedySwitch.activationThreshold',iCe='org.eclipse.elk.layered.crossingMinimization.greedySwitch.type',jCe='org.eclipse.elk.layered.crossingMinimization.greedySwitchHierarchical.type',kCe='org.eclipse.elk.layered.nodePlacement.strategy',lCe='org.eclipse.elk.layered.nodePlacement.favorStraightEdges',mCe='org.eclipse.elk.layered.nodePlacement.bk.edgeStraightening',nCe='org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment',oCe='org.eclipse.elk.layered.nodePlacement.linearSegments.deflectionDampening',pCe='org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility',qCe='org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default',rCe='org.eclipse.elk.layered.edgeRouting.selfLoopDistribution',sCe='org.eclipse.elk.layered.edgeRouting.selfLoopOrdering',tCe='org.eclipse.elk.layered.edgeRouting.splines.mode',uCe='org.eclipse.elk.layered.edgeRouting.splines.sloppy.layerSpacingFactor',vCe='org.eclipse.elk.layered.edgeRouting.polyline.slopedEdgeZoneWidth',wCe='org.eclipse.elk.layered.spacing.baseValue',xCe='org.eclipse.elk.layered.spacing.edgeNodeBetweenLayers',yCe='org.eclipse.elk.layered.spacing.edgeEdgeBetweenLayers',zCe='org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers',ACe='org.eclipse.elk.layered.priority.direction',BCe='org.eclipse.elk.layered.priority.shortness',CCe='org.eclipse.elk.layered.priority.straightness',DCe='org.eclipse.elk.layered.compaction.connectedComponents',ECe='org.eclipse.elk.layered.compaction.postCompaction.strategy',FCe='org.eclipse.elk.layered.compaction.postCompaction.constraints',GCe='org.eclipse.elk.layered.highDegreeNodes.treatment',HCe='org.eclipse.elk.layered.highDegreeNodes.threshold',ICe='org.eclipse.elk.layered.highDegreeNodes.treeHeight',JCe='org.eclipse.elk.layered.wrapping.strategy',KCe='org.eclipse.elk.layered.wrapping.additionalEdgeSpacing',LCe='org.eclipse.elk.layered.wrapping.correctionFactor',MCe='org.eclipse.elk.layered.wrapping.cutting.strategy',NCe='org.eclipse.elk.layered.wrapping.cutting.cuts',OCe='org.eclipse.elk.layered.wrapping.cutting.msd.freedom',PCe='org.eclipse.elk.layered.wrapping.validify.strategy',QCe='org.eclipse.elk.layered.wrapping.validify.forbiddenIndices',RCe='org.eclipse.elk.layered.wrapping.multiEdge.improveCuts',SCe='org.eclipse.elk.layered.wrapping.multiEdge.distancePenalty',TCe='org.eclipse.elk.layered.wrapping.multiEdge.improveWrappedEdges',UCe='org.eclipse.elk.layered.edgeLabels.sideSelection',VCe='org.eclipse.elk.layered.edgeLabels.centerLabelPlacementStrategy',WCe='org.eclipse.elk.layered.considerModelOrder.strategy',XCe='org.eclipse.elk.layered.considerModelOrder.portModelOrder',YCe='org.eclipse.elk.layered.considerModelOrder.noModelOrder',ZCe='org.eclipse.elk.layered.considerModelOrder.components',$Ce='org.eclipse.elk.layered.considerModelOrder.longEdgeStrategy',_Ce='org.eclipse.elk.layered.considerModelOrder.crossingCounterNodeInfluence',aDe='org.eclipse.elk.layered.considerModelOrder.crossingCounterPortInfluence',bDe='layering',cDe='layering.minWidth',dDe='layering.nodePromotion',eDe='crossingMinimization',fDe='org.eclipse.elk.hierarchyHandling',gDe='crossingMinimization.greedySwitch',hDe='nodePlacement',iDe='nodePlacement.bk',jDe='edgeRouting',kDe='org.eclipse.elk.edgeRouting',lDe='spacing',mDe='priority',nDe='compaction',oDe='compaction.postCompaction',pDe='Specifies whether and how post-process compaction is applied.',qDe='highDegreeNodes',rDe='wrapping',sDe='wrapping.cutting',tDe='wrapping.validify',uDe='wrapping.multiEdge',vDe='edgeLabels',wDe='considerModelOrder',xDe='org.eclipse.elk.spacing.commentComment',yDe='org.eclipse.elk.spacing.commentNode',zDe='org.eclipse.elk.spacing.edgeEdge',ADe='org.eclipse.elk.spacing.edgeNode',BDe='org.eclipse.elk.spacing.labelLabel',CDe='org.eclipse.elk.spacing.labelPortHorizontal',DDe='org.eclipse.elk.spacing.labelPortVertical',EDe='org.eclipse.elk.spacing.labelNode',FDe='org.eclipse.elk.spacing.nodeSelfLoop',GDe='org.eclipse.elk.spacing.portPort',HDe='org.eclipse.elk.spacing.individual',IDe='org.eclipse.elk.port.borderOffset',JDe='org.eclipse.elk.noLayout',KDe='org.eclipse.elk.port.side',LDe='org.eclipse.elk.debugMode',MDe='org.eclipse.elk.alignment',NDe='org.eclipse.elk.insideSelfLoops.activate',ODe='org.eclipse.elk.insideSelfLoops.yo',PDe='org.eclipse.elk.direction',QDe='org.eclipse.elk.nodeLabels.padding',RDe='org.eclipse.elk.portLabels.nextToPortIfPossible',SDe='org.eclipse.elk.portLabels.treatAsGroup',TDe='org.eclipse.elk.portAlignment.default',UDe='org.eclipse.elk.portAlignment.north',VDe='org.eclipse.elk.portAlignment.south',WDe='org.eclipse.elk.portAlignment.west',XDe='org.eclipse.elk.portAlignment.east',YDe='org.eclipse.elk.contentAlignment',ZDe='org.eclipse.elk.junctionPoints',$De='org.eclipse.elk.edgeLabels.placement',_De='org.eclipse.elk.port.index',aEe='org.eclipse.elk.commentBox',bEe='org.eclipse.elk.hypernode',cEe='org.eclipse.elk.port.anchor',dEe='org.eclipse.elk.partitioning.activate',eEe='org.eclipse.elk.partitioning.partition',fEe='org.eclipse.elk.position',gEe='org.eclipse.elk.margins',hEe='org.eclipse.elk.spacing.portsSurrounding',iEe='org.eclipse.elk.interactiveLayout',jEe='org.eclipse.elk.core.util',kEe={3:1,4:1,5:1,601:1},lEe='NETWORK_SIMPLEX',mEe='SIMPLE',nEe={106:1,47:1},oEe='org.eclipse.elk.alg.layered.p1cycles',pEe='org.eclipse.elk.alg.layered.p2layers',qEe={413:1,230:1},rEe={846:1,3:1,4:1},sEe='org.eclipse.elk.alg.layered.p3order',tEe='org.eclipse.elk.alg.layered.p4nodes',uEe={3:1,4:1,5:1,854:1},vEe=1.0E-5,wEe='org.eclipse.elk.alg.layered.p4nodes.bk',xEe='org.eclipse.elk.alg.layered.p5edges',yEe='org.eclipse.elk.alg.layered.p5edges.orthogonal',zEe='org.eclipse.elk.alg.layered.p5edges.orthogonal.direction',AEe=1.0E-6,BEe='org.eclipse.elk.alg.layered.p5edges.splines',CEe=0.09999999999999998,DEe=1.0E-8,EEe=4.71238898038469,FEe=3.141592653589793,GEe='org.eclipse.elk.alg.mrtree',HEe=0.10000000149011612,IEe='SUPER_ROOT',JEe='org.eclipse.elk.alg.mrtree.graph',KEe=-1.7976931348623157E308,LEe='org.eclipse.elk.alg.mrtree.intermediate',MEe='Processor compute fanout',NEe={3:1,6:1,4:1,5:1,534:1,100:1,115:1},OEe='Set neighbors in level',PEe='org.eclipse.elk.alg.mrtree.options',QEe='DESCENDANTS',REe='org.eclipse.elk.mrtree.compaction',SEe='org.eclipse.elk.mrtree.edgeEndTextureLength',TEe='org.eclipse.elk.mrtree.treeLevel',UEe='org.eclipse.elk.mrtree.positionConstraint',VEe='org.eclipse.elk.mrtree.weighting',WEe='org.eclipse.elk.mrtree.edgeRoutingMode',XEe='org.eclipse.elk.mrtree.searchOrder',YEe='Position Constraint',ZEe='org.eclipse.elk.mrtree',$Ee='org.eclipse.elk.tree',_Ee='Processor arrange level',aFe='org.eclipse.elk.alg.mrtree.p2order',bFe='org.eclipse.elk.alg.mrtree.p4route',cFe='org.eclipse.elk.alg.radial',dFe=6.283185307179586,eFe='Before',fFe=4.9E-324,gFe='After',hFe='org.eclipse.elk.alg.radial.intermediate',iFe='COMPACTION',jFe='org.eclipse.elk.alg.radial.intermediate.compaction',kFe={3:1,4:1,5:1,100:1},lFe='org.eclipse.elk.alg.radial.intermediate.optimization',mFe='No implementation is available for the layout option ',nFe='org.eclipse.elk.alg.radial.options',oFe='org.eclipse.elk.radial.centerOnRoot',pFe='org.eclipse.elk.radial.orderId',qFe='org.eclipse.elk.radial.radius',rFe='org.eclipse.elk.radial.rotate',sFe='org.eclipse.elk.radial.compactor',tFe='org.eclipse.elk.radial.compactionStepSize',uFe='org.eclipse.elk.radial.sorter',vFe='org.eclipse.elk.radial.wedgeCriteria',wFe='org.eclipse.elk.radial.optimizationCriteria',xFe='org.eclipse.elk.radial.rotation.targetAngle',yFe='org.eclipse.elk.radial.rotation.computeAdditionalWedgeSpace',zFe='org.eclipse.elk.radial.rotation.outgoingEdgeAngles',AFe='Compaction',BFe='rotation',CFe='org.eclipse.elk.radial',DFe='org.eclipse.elk.alg.radial.p1position.wedge',EFe='org.eclipse.elk.alg.radial.sorting',FFe=5.497787143782138,GFe=3.9269908169872414,HFe=2.356194490192345,IFe='org.eclipse.elk.alg.rectpacking',JFe='org.eclipse.elk.alg.rectpacking.intermediate',KFe='org.eclipse.elk.alg.rectpacking.options',LFe='org.eclipse.elk.rectpacking.trybox',MFe='org.eclipse.elk.rectpacking.currentPosition',NFe='org.eclipse.elk.rectpacking.desiredPosition',OFe='org.eclipse.elk.rectpacking.inNewRow',PFe='org.eclipse.elk.rectpacking.widthApproximation.strategy',QFe='org.eclipse.elk.rectpacking.widthApproximation.targetWidth',RFe='org.eclipse.elk.rectpacking.widthApproximation.optimizationGoal',SFe='org.eclipse.elk.rectpacking.widthApproximation.lastPlaceShift',TFe='org.eclipse.elk.rectpacking.packing.strategy',UFe='org.eclipse.elk.rectpacking.packing.compaction.rowHeightReevaluation',VFe='org.eclipse.elk.rectpacking.packing.compaction.iterations',WFe='org.eclipse.elk.rectpacking.whiteSpaceElimination.strategy',XFe='widthApproximation',YFe='Compaction Strategy',ZFe='packing.compaction',$Fe='org.eclipse.elk.rectpacking',_Fe='org.eclipse.elk.alg.rectpacking.p1widthapproximation',aGe='org.eclipse.elk.alg.rectpacking.p2packing',bGe='No Compaction',cGe='org.eclipse.elk.alg.rectpacking.p3whitespaceelimination',dGe='org.eclipse.elk.alg.rectpacking.util',eGe='No implementation available for ',fGe='org.eclipse.elk.alg.spore',gGe='org.eclipse.elk.alg.spore.options',hGe='org.eclipse.elk.sporeCompaction',iGe='org.eclipse.elk.underlyingLayoutAlgorithm',jGe='org.eclipse.elk.processingOrder.treeConstruction',kGe='org.eclipse.elk.processingOrder.spanningTreeCostFunction',lGe='org.eclipse.elk.processingOrder.preferredRoot',mGe='org.eclipse.elk.processingOrder.rootSelection',nGe='org.eclipse.elk.structure.structureExtractionStrategy',oGe='org.eclipse.elk.compaction.compactionStrategy',pGe='org.eclipse.elk.compaction.orthogonal',qGe='org.eclipse.elk.overlapRemoval.maxIterations',rGe='org.eclipse.elk.overlapRemoval.runScanline',sGe='processingOrder',tGe='overlapRemoval',uGe='org.eclipse.elk.sporeOverlap',vGe='org.eclipse.elk.alg.spore.p1structure',wGe='org.eclipse.elk.alg.spore.p2processingorder',xGe='org.eclipse.elk.alg.spore.p3execution',yGe='Topdown Layout',zGe='Invalid index: ',AGe='org.eclipse.elk.core.alg',BGe={341:1},CGe={295:1},DGe='Make sure its type is registered with the ',EGe=' utility class.',FGe='true',GGe='false',HGe="Couldn't clone property '",IGe=0.05,JGe='org.eclipse.elk.core.options',KGe=1.2999999523162842,LGe='org.eclipse.elk.box',MGe='org.eclipse.elk.expandNodes',NGe='org.eclipse.elk.box.packingMode',OGe='org.eclipse.elk.algorithm',PGe='org.eclipse.elk.resolvedAlgorithm',QGe='org.eclipse.elk.bendPoints',RGe='org.eclipse.elk.labelManager',SGe='org.eclipse.elk.scaleFactor',TGe='org.eclipse.elk.childAreaWidth',UGe='org.eclipse.elk.childAreaHeight',VGe='org.eclipse.elk.animate',WGe='org.eclipse.elk.animTimeFactor',XGe='org.eclipse.elk.layoutAncestors',YGe='org.eclipse.elk.maxAnimTime',ZGe='org.eclipse.elk.minAnimTime',$Ge='org.eclipse.elk.progressBar',_Ge='org.eclipse.elk.validateGraph',aHe='org.eclipse.elk.validateOptions',bHe='org.eclipse.elk.zoomToFit',cHe='org.eclipse.elk.font.name',dHe='org.eclipse.elk.font.size',eHe='org.eclipse.elk.topdown.sizeApproximator',fHe='org.eclipse.elk.topdown.scaleCap',gHe='org.eclipse.elk.edge.type',hHe='partitioning',iHe='nodeLabels',jHe='portAlignment',kHe='nodeSize',lHe='port',mHe='portLabels',nHe='topdown',oHe='insideSelfLoops',pHe='org.eclipse.elk.fixed',qHe='org.eclipse.elk.random',rHe={3:1,34:1,22:1,347:1},sHe='port must have a parent node to calculate the port side',tHe='The edge needs to have exactly one edge section. Found: ',uHe='org.eclipse.elk.core.util.adapters',vHe='org.eclipse.emf.ecore',wHe='org.eclipse.elk.graph',xHe='EMapPropertyHolder',yHe='ElkBendPoint',zHe='ElkGraphElement',AHe='ElkConnectableShape',BHe='ElkEdge',CHe='ElkEdgeSection',DHe='EModelElement',EHe='ENamedElement',FHe='ElkLabel',GHe='ElkNode',HHe='ElkPort',IHe={94:1,93:1},JHe='org.eclipse.emf.common.notify.impl',KHe="The feature '",LHe="' is not a valid changeable feature",MHe='Expecting null',NHe="' is not a valid feature",OHe='The feature ID',PHe=' is not a valid feature ID',QHe=32768,RHe={110:1,94:1,93:1,58:1,54:1,99:1},SHe='org.eclipse.emf.ecore.impl',THe='org.eclipse.elk.graph.impl',UHe='Recursive containment not allowed for ',VHe="The datatype '",WHe="' is not a valid classifier",XHe="The value '",YHe={195:1,3:1,4:1},ZHe="The class '",$He='http://www.eclipse.org/elk/ElkGraph',_He='property',aIe='value',bIe='source',cIe='properties',dIe='identifier',eIe='height',fIe='width',gIe='parent',hIe='text',iIe='children',jIe='hierarchical',kIe='sources',lIe='targets',mIe='sections',nIe='bendPoints',oIe='outgoingShape',pIe='incomingShape',qIe='outgoingSections',rIe='incomingSections',sIe='org.eclipse.emf.common.util',tIe='Severe implementation error in the Json to ElkGraph importer.',uIe='id',vIe='org.eclipse.elk.graph.json',wIe='Unhandled parameter types: ',xIe='startPoint',yIe="An edge must have at least one source and one target (edge id: '",zIe="').",AIe='Referenced edge section does not exist: ',BIe=" (edge id: '",CIe='target',DIe='sourcePoint',EIe='targetPoint',FIe='group',GIe='name',HIe='connectableShape cannot be null',IIe='edge cannot be null',JIe="Passed edge is not 'simple'.",KIe='org.eclipse.elk.graph.util',LIe="The 'no duplicates' constraint is violated",MIe='targetIndex=',NIe=', size=',OIe='sourceIndex=',PIe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1},QIe={3:1,4:1,20:1,31:1,56:1,16:1,51:1,15:1,59:1,70:1,66:1,61:1,596:1},RIe='logging',SIe='measureExecutionTime',TIe='parser.parse.1',UIe='parser.parse.2',VIe='parser.next.1',WIe='parser.next.2',XIe='parser.next.3',YIe='parser.next.4',ZIe='parser.factor.1',$Ie='parser.factor.2',_Ie='parser.factor.3',aJe='parser.factor.4',bJe='parser.factor.5',cJe='parser.factor.6',dJe='parser.atom.1',eJe='parser.atom.2',fJe='parser.atom.3',gJe='parser.atom.4',hJe='parser.atom.5',iJe='parser.cc.1',jJe='parser.cc.2',kJe='parser.cc.3',lJe='parser.cc.5',mJe='parser.cc.6',nJe='parser.cc.7',oJe='parser.cc.8',pJe='parser.ope.1',qJe='parser.ope.2',rJe='parser.ope.3',sJe='parser.descape.1',tJe='parser.descape.2',uJe='parser.descape.3',vJe='parser.descape.4',wJe='parser.descape.5',xJe='parser.process.1',yJe='parser.quantifier.1',zJe='parser.quantifier.2',AJe='parser.quantifier.3',BJe='parser.quantifier.4',CJe='parser.quantifier.5',DJe='org.eclipse.emf.common.notify',EJe={424:1,686:1},FJe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,70:1,61:1},GJe={378:1,152:1},HJe='index=',IJe={3:1,4:1,5:1,129:1},JJe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,61:1},KJe={3:1,6:1,4:1,5:1,198:1},LJe={3:1,4:1,5:1,173:1,379:1},MJe=';/?:@&=+$,',NJe='invalid authority: ',OJe='EAnnotation',PJe='ETypedElement',QJe='EStructuralFeature',RJe='EAttribute',SJe='EClassifier',TJe='EEnumLiteral',UJe='EGenericType',VJe='EOperation',WJe='EParameter',XJe='EReference',YJe='ETypeParameter',ZJe='org.eclipse.emf.ecore.util',$Je={79:1},_Je={3:1,20:1,16:1,15:1,61:1,597:1,79:1,71:1,97:1},aKe='org.eclipse.emf.ecore.util.FeatureMap$Entry',bKe=8192,cKe=2048,dKe='byte',eKe='char',fKe='double',gKe='float',hKe='int',iKe='long',jKe='short',kKe='java.lang.Object',lKe={3:1,4:1,5:1,254:1},mKe={3:1,4:1,5:1,688:1},nKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,71:1},oKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,79:1,71:1,97:1},pKe='mixed',qKe='http:///org/eclipse/emf/ecore/util/ExtendedMetaData',rKe='kind',sKe={3:1,4:1,5:1,689:1},tKe={3:1,4:1,20:1,31:1,56:1,16:1,15:1,70:1,61:1,79:1,71:1,97:1},uKe={20:1,31:1,56:1,16:1,15:1,61:1,71:1},vKe={51:1,128:1,287:1},wKe={76:1,343:1},xKe="The value of type '",yKe="' must be of type '",zKe=1352,AKe='http://www.eclipse.org/emf/2002/Ecore',BKe=-32768,CKe='constraints',DKe='baseType',EKe='getEStructuralFeature',FKe='getFeatureID',GKe='feature',HKe='getOperationID',IKe='operation',JKe='defaultValue',KKe='eTypeParameters',LKe='isInstance',MKe='getEEnumLiteral',NKe='eContainingClass',OKe={57:1},PKe={3:1,4:1,5:1,124:1},QKe='org.eclipse.emf.ecore.resource',RKe={94:1,93:1,599:1,2034:1},SKe='org.eclipse.emf.ecore.resource.impl',TKe='unspecified',UKe='simple',VKe='attribute',WKe='attributeWildcard',XKe='element',YKe='elementWildcard',ZKe='collapse',$Ke='itemType',_Ke='namespace',aLe='##targetNamespace',bLe='whiteSpace',cLe='wildcards',dLe='http://www.eclipse.org/emf/2003/XMLType',eLe='##any',fLe='uninitialized',gLe='The multiplicity constraint is violated',hLe='org.eclipse.emf.ecore.xml.type',iLe='ProcessingInstruction',jLe='SimpleAnyType',kLe='XMLTypeDocumentRoot',lLe='org.eclipse.emf.ecore.xml.type.impl',mLe='INF',nLe='processing',oLe='ENTITIES_._base',pLe='minLength',qLe='ENTITY',rLe='NCName',sLe='IDREFS_._base',tLe='integer',uLe='token',vLe='pattern',wLe='[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*',xLe='\\i\\c*',yLe='[\\i-[:]][\\c-[:]]*',zLe='nonPositiveInteger',ALe='maxInclusive',BLe='NMTOKEN',CLe='NMTOKENS_._base',DLe='nonNegativeInteger',ELe='minInclusive',FLe='normalizedString',GLe='unsignedByte',HLe='unsignedInt',ILe='18446744073709551615',JLe='unsignedShort',KLe='processingInstruction',LLe='org.eclipse.emf.ecore.xml.type.internal',MLe=1114111,NLe='Internal Error: shorthands: \\u',OLe='xml:isDigit',PLe='xml:isWord',QLe='xml:isSpace',RLe='xml:isNameChar',SLe='xml:isInitialNameChar',TLe='09\u0660\u0669\u06F0\u06F9\u0966\u096F\u09E6\u09EF\u0A66\u0A6F\u0AE6\u0AEF\u0B66\u0B6F\u0BE7\u0BEF\u0C66\u0C6F\u0CE6\u0CEF\u0D66\u0D6F\u0E50\u0E59\u0ED0\u0ED9\u0F20\u0F29',ULe='AZaz\xC0\xD6\xD8\xF6\xF8\u0131\u0134\u013E\u0141\u0148\u014A\u017E\u0180\u01C3\u01CD\u01F0\u01F4\u01F5\u01FA\u0217\u0250\u02A8\u02BB\u02C1\u0386\u0386\u0388\u038A\u038C\u038C\u038E\u03A1\u03A3\u03CE\u03D0\u03D6\u03DA\u03DA\u03DC\u03DC\u03DE\u03DE\u03E0\u03E0\u03E2\u03F3\u0401\u040C\u040E\u044F\u0451\u045C\u045E\u0481\u0490\u04C4\u04C7\u04C8\u04CB\u04CC\u04D0\u04EB\u04EE\u04F5\u04F8\u04F9\u0531\u0556\u0559\u0559\u0561\u0586\u05D0\u05EA\u05F0\u05F2\u0621\u063A\u0641\u064A\u0671\u06B7\u06BA\u06BE\u06C0\u06CE\u06D0\u06D3\u06D5\u06D5\u06E5\u06E6\u0905\u0939\u093D\u093D\u0958\u0961\u0985\u098C\u098F\u0990\u0993\u09A8\u09AA\u09B0\u09B2\u09B2\u09B6\u09B9\u09DC\u09DD\u09DF\u09E1\u09F0\u09F1\u0A05\u0A0A\u0A0F\u0A10\u0A13\u0A28\u0A2A\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59\u0A5C\u0A5E\u0A5E\u0A72\u0A74\u0A85\u0A8B\u0A8D\u0A8D\u0A8F\u0A91\u0A93\u0AA8\u0AAA\u0AB0\u0AB2\u0AB3\u0AB5\u0AB9\u0ABD\u0ABD\u0AE0\u0AE0\u0B05\u0B0C\u0B0F\u0B10\u0B13\u0B28\u0B2A\u0B30\u0B32\u0B33\u0B36\u0B39\u0B3D\u0B3D\u0B5C\u0B5D\u0B5F\u0B61\u0B85\u0B8A\u0B8E\u0B90\u0B92\u0B95\u0B99\u0B9A\u0B9C\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8\u0BAA\u0BAE\u0BB5\u0BB7\u0BB9\u0C05\u0C0C\u0C0E\u0C10\u0C12\u0C28\u0C2A\u0C33\u0C35\u0C39\u0C60\u0C61\u0C85\u0C8C\u0C8E\u0C90\u0C92\u0CA8\u0CAA\u0CB3\u0CB5\u0CB9\u0CDE\u0CDE\u0CE0\u0CE1\u0D05\u0D0C\u0D0E\u0D10\u0D12\u0D28\u0D2A\u0D39\u0D60\u0D61\u0E01\u0E2E\u0E30\u0E30\u0E32\u0E33\u0E40\u0E45\u0E81\u0E82\u0E84\u0E84\u0E87\u0E88\u0E8A\u0E8A\u0E8D\u0E8D\u0E94\u0E97\u0E99\u0E9F\u0EA1\u0EA3\u0EA5\u0EA5\u0EA7\u0EA7\u0EAA\u0EAB\u0EAD\u0EAE\u0EB0\u0EB0\u0EB2\u0EB3\u0EBD\u0EBD\u0EC0\u0EC4\u0F40\u0F47\u0F49\u0F69\u10A0\u10C5\u10D0\u10F6\u1100\u1100\u1102\u1103\u1105\u1107\u1109\u1109\u110B\u110C\u110E\u1112\u113C\u113C\u113E\u113E\u1140\u1140\u114C\u114C\u114E\u114E\u1150\u1150\u1154\u1155\u1159\u1159\u115F\u1161\u1163\u1163\u1165\u1165\u1167\u1167\u1169\u1169\u116D\u116E\u1172\u1173\u1175\u1175\u119E\u119E\u11A8\u11A8\u11AB\u11AB\u11AE\u11AF\u11B7\u11B8\u11BA\u11BA\u11BC\u11C2\u11EB\u11EB\u11F0\u11F0\u11F9\u11F9\u1E00\u1E9B\u1EA0\u1EF9\u1F00\u1F15\u1F18\u1F1D\u1F20\u1F45\u1F48\u1F4D\u1F50\u1F57\u1F59\u1F59\u1F5B\u1F5B\u1F5D\u1F5D\u1F5F\u1F7D\u1F80\u1FB4\u1FB6\u1FBC\u1FBE\u1FBE\u1FC2\u1FC4\u1FC6\u1FCC\u1FD0\u1FD3\u1FD6\u1FDB\u1FE0\u1FEC\u1FF2\u1FF4\u1FF6\u1FFC\u2126\u2126\u212A\u212B\u212E\u212E\u2180\u2182\u3007\u3007\u3021\u3029\u3041\u3094\u30A1\u30FA\u3105\u312C\u4E00\u9FA5\uAC00\uD7A3',VLe='Private Use',WLe='ASSIGNED',XLe='\x00\x7F\x80\xFF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF\u0900\u097F\u0980\u09FF\u0A00\u0A7F\u0A80\u0AFF\u0B00\u0B7F\u0B80\u0BFF\u0C00\u0C7F\u0C80\u0CFF\u0D00\u0D7F\u0D80\u0DFF\u0E00\u0E7F\u0E80\u0EFF\u0F00\u0FFF\u1000\u109F\u10A0\u10FF\u1100\u11FF\u1200\u137F\u13A0\u13FF\u1400\u167F\u1680\u169F\u16A0\u16FF\u1780\u17FF\u1800\u18AF\u1E00\u1EFF\u1F00\u1FFF\u2000\u206F\u2070\u209F\u20A0\u20CF\u20D0\u20FF\u2100\u214F\u2150\u218F\u2190\u21FF\u2200\u22FF\u2300\u23FF\u2400\u243F\u2440\u245F\u2460\u24FF\u2500\u257F\u2580\u259F\u25A0\u25FF\u2600\u26FF\u2700\u27BF\u2800\u28FF\u2E80\u2EFF\u2F00\u2FDF\u2FF0\u2FFF\u3000\u303F\u3040\u309F\u30A0\u30FF\u3100\u312F\u3130\u318F\u3190\u319F\u31A0\u31BF\u3200\u32FF\u3300\u33FF\u3400\u4DB5\u4E00\u9FFF\uA000\uA48F\uA490\uA4CF\uAC00\uD7A3\uE000\uF8FF\uF900\uFAFF\uFB00\uFB4F\uFB50\uFDFF\uFE20\uFE2F\uFE30\uFE4F\uFE50\uFE6F\uFE70\uFEFE\uFEFF\uFEFF\uFF00\uFFEF',YLe='UNASSIGNED',ZLe={3:1,122:1},$Le='org.eclipse.emf.ecore.xml.type.util',_Le={3:1,4:1,5:1,381:1},aMe='org.eclipse.xtext.xbase.lib',bMe='Cannot add elements to a Range',cMe='Cannot set elements in a Range',dMe='Cannot remove elements from a Range',eMe='user.agent';var _,eeb,_db;$wnd.goog=$wnd.goog||{};$wnd.goog.global=$wnd.goog.global||$wnd;eeb={};feb(1,null,{},nb);_.Fb=function ob(a){return mb(this,a)};_.Gb=function qb(){return this.Rm};_.Hb=function sb(){return kFb(this)};_.Ib=function ub(){var a;return nfb(rb(this))+'@'+(a=tb(this)>>>0,a.toString(16))};_.equals=function(a){return this.Fb(a)};_.hashCode=function(){return this.Hb()};_.toString=function(){return this.Ib()};var ND,OD,PD;feb(297,1,{297:1,2124:1},pfb);_.ve=function qfb(a){var b;b=new pfb;b.i=4;a>1?(b.c=xfb(this,a-1)):(b.c=this);return b};_.we=function wfb(){lfb(this);return this.b};_.xe=function yfb(){return nfb(this)};_.ye=function Afb(){return lfb(this),this.k};_.ze=function Cfb(){return (this.i&4)!=0};_.Ae=function Dfb(){return (this.i&1)!=0};_.Ib=function Gfb(){return ofb(this)};_.i=0;var jJ=sfb(mve,'Object',1);var UI=sfb(mve,'Class',297);feb(2096,1,nve);sfb(ove,'Optional',2096);feb(1191,2096,nve,xb);_.Fb=function yb(a){return a===this};_.Hb=function zb(){return 2040732332};_.Ib=function Ab(){return 'Optional.absent()'};_.Jb=function Bb(a){Qb(a);return wb(),vb};var vb;sfb(ove,'Absent',1191);feb(636,1,{},Gb);sfb(ove,'Joiner',636);var pE=ufb(ove,'Predicate');feb(589,1,{178:1,589:1,3:1,46:1},Yb);_.Mb=function ac(a){return Xb(this,a)};_.Lb=function Zb(a){return Xb(this,a)};_.Fb=function $b(a){var b;if(ZD(a,589)){b=RD(a,589);return Rt(this.a,b.a)}return false};_.Hb=function _b(){return Cob(this.a)+306654252};_.Ib=function bc(){return Wb(this.a)};sfb(ove,'Predicates/AndPredicate',589);feb(419,2096,{419:1,3:1},cc);_.Fb=function dc(a){var b;if(ZD(a,419)){b=RD(a,419);return pb(this.a,b.a)}return false};_.Hb=function ec(){return 1502476572+tb(this.a)};_.Ib=function fc(){return uve+this.a+')'};_.Jb=function gc(a){return new cc(Rb(a.Kb(this.a),'the Function passed to Optional.transform() must not return null.'))};sfb(ove,'Present',419);feb(204,1,wve);_.Nb=function kc(a){Ztb(this,a);};_.Qb=function lc(){jc();};sfb(xve,'UnmodifiableIterator',204);feb(2076,204,yve);_.Qb=function nc(){jc();};_.Rb=function mc(a){throw Adb(new jib)};_.Wb=function oc(a){throw Adb(new jib)};sfb(xve,'UnmodifiableListIterator',2076);feb(399,2076,yve);_.Ob=function rc(){return this.c0};_.Pb=function tc(){if(this.c>=this.d){throw Adb(new Dvb)}return this.Xb(this.c++)};_.Tb=function uc(){return this.c};_.Ub=function vc(){if(this.c<=0){throw Adb(new Dvb)}return this.Xb(--this.c)};_.Vb=function wc(){return this.c-1};_.c=0;_.d=0;sfb(xve,'AbstractIndexedListIterator',399);feb(713,204,wve);_.Ob=function Ac(){return xc(this)};_.Pb=function Bc(){return yc(this)};_.e=1;sfb(xve,'AbstractIterator',713);feb(2084,1,{229:1});_.Zb=function Hc(){var a;return a=this.f,!a?(this.f=this.ac()):a};_.Fb=function Ic(a){return xw(this,a)};_.Hb=function Jc(){return tb(this.Zb())};_.dc=function Kc(){return this.gc()==0};_.ec=function Lc(){return Ec(this)};_.Ib=function Mc(){return jeb(this.Zb())};sfb(xve,'AbstractMultimap',2084);feb(742,2084,zve);_.$b=function Xc(){Nc(this);};_._b=function Yc(a){return Oc(this,a)};_.ac=function Zc(){return new ne(this,this.c)};_.ic=function $c(a){return this.hc()};_.bc=function _c(){return new zf(this,this.c)};_.jc=function ad(){return this.mc(this.hc())};_.kc=function bd(){return new Hd(this)};_.lc=function cd(){return ek(this.c.vc().Nc(),new hh,64,this.d)};_.cc=function dd(a){return Qc(this,a)};_.fc=function gd(a){return Sc(this,a)};_.gc=function hd(){return this.d};_.mc=function jd(a){return yob(),new xpb(a)};_.nc=function kd(){return new Dd(this)};_.oc=function ld(){return ek(this.c.Cc().Nc(),new Fd,64,this.d)};_.pc=function md(a,b){return new lg(this,a,b,null)};_.d=0;sfb(xve,'AbstractMapBasedMultimap',742);feb(1696,742,zve);_.hc=function pd(){return new cnb(this.a)};_.jc=function qd(){return yob(),yob(),vob};_.cc=function sd(a){return RD(Qc(this,a),15)};_.fc=function ud(a){return RD(Sc(this,a),15)};_.Zb=function od(){return nd(this)};_.Fb=function rd(a){return xw(this,a)};_.qc=function td(a){return RD(Qc(this,a),15)};_.rc=function vd(a){return RD(Sc(this,a),15)};_.mc=function wd(a){return Hob(RD(a,15))};_.pc=function xd(a,b){return Vc(this,a,RD(b,15),null)};sfb(xve,'AbstractListMultimap',1696);feb(748,1,Ave);_.Nb=function zd(a){Ztb(this,a);};_.Ob=function Ad(){return this.c.Ob()||this.e.Ob()};_.Pb=function Bd(){var a;if(!this.e.Ob()){a=RD(this.c.Pb(),44);this.b=a.ld();this.a=RD(a.md(),16);this.e=this.a.Kc();}return this.sc(this.b,this.e.Pb())};_.Qb=function Cd(){this.e.Qb();RD(Hvb(this.a),16).dc()&&this.c.Qb();--this.d.d;};sfb(xve,'AbstractMapBasedMultimap/Itr',748);feb(1129,748,Ave,Dd);_.sc=function Ed(a,b){return b};sfb(xve,'AbstractMapBasedMultimap/1',1129);feb(1130,1,{},Fd);_.Kb=function Gd(a){return RD(a,16).Nc()};sfb(xve,'AbstractMapBasedMultimap/1methodref$spliterator$Type',1130);feb(1131,748,Ave,Hd);_.sc=function Id(a,b){return new gp(a,b)};sfb(xve,'AbstractMapBasedMultimap/2',1131);var VK=ufb(Bve,'Map');feb(2065,1,Cve);_.wc=function Td(a){Bvb(this,a);};_.yc=function $d(a,b,c){return Cvb(this,a,b,c)};_.$b=function Od(){this.vc().$b();};_.tc=function Pd(a){return Jd(this,a)};_._b=function Qd(a){return !!Kd(this,a,false)};_.uc=function Rd(a){var b,c,d;for(c=this.vc().Kc();c.Ob();){b=RD(c.Pb(),44);d=b.md();if(dE(a)===dE(d)||a!=null&&pb(a,d)){return true}}return false};_.Fb=function Sd(a){var b,c,d;if(a===this){return true}if(!ZD(a,85)){return false}d=RD(a,85);if(this.gc()!=d.gc()){return false}for(c=d.vc().Kc();c.Ob();){b=RD(c.Pb(),44);if(!this.tc(b)){return false}}return true};_.xc=function Ud(a){return Wd(Kd(this,a,false))};_.Hb=function Xd(){return Bob(this.vc())};_.dc=function Yd(){return this.gc()==0};_.ec=function Zd(){return new Xkb(this)};_.zc=function _d(a,b){throw Adb(new kib('Put not supported on this map'))};_.Ac=function ae(a){Ld(this,a);};_.Bc=function be(a){return Wd(Kd(this,a,true))};_.gc=function ce(){return this.vc().gc()};_.Ib=function de(){return Md(this)};_.Cc=function ee(){return new glb(this)};sfb(Bve,'AbstractMap',2065);feb(2085,2065,Cve);_.bc=function ge(){return new rf(this)};_.vc=function he(){return fe(this)};_.ec=function ie(){var a;a=this.g;return !a?(this.g=this.bc()):a};_.Cc=function je(){var a;a=this.i;return !a?(this.i=new nw(this)):a};sfb(xve,'Maps/ViewCachingAbstractMap',2085);feb(402,2085,Cve,ne);_.xc=function se(a){return ke(this,a)};_.Bc=function ve(a){return le(this,a)};_.$b=function oe(){this.d==this.e.c?this.e.$b():Ar(new mf(this));};_._b=function pe(a){return Wv(this.d,a)};_.Ec=function qe(){return new df(this)};_.Dc=function(){return this.Ec()};_.Fb=function re(a){return this===a||pb(this.d,a)};_.Hb=function te(){return tb(this.d)};_.ec=function ue(){return this.e.ec()};_.gc=function we(){return this.d.gc()};_.Ib=function xe(){return jeb(this.d)};sfb(xve,'AbstractMapBasedMultimap/AsMap',402);var cJ=ufb(mve,'Iterable');feb(31,1,Dve);_.Jc=function Le(a){xgb(this,a);};_.Lc=function Ne(){return this.Oc()};_.Nc=function Pe(){return new Swb(this,0)};_.Oc=function Qe(){return new SDb(null,this.Nc())};_.Fc=function Ge(a){throw Adb(new kib('Add not supported on this collection'))};_.Gc=function He(a){return ye(this,a)};_.$b=function Ie(){Ae(this);};_.Hc=function Je(a){return ze(this,a,false)};_.Ic=function Ke(a){return Be(this,a)};_.dc=function Me(){return this.gc()==0};_.Mc=function Oe(a){return ze(this,a,true)};_.Pc=function Re(){return De(this)};_.Qc=function Se(a){return Ee(this,a)};_.Ib=function Te(){return Fe(this)};sfb(Bve,'AbstractCollection',31);var bL=ufb(Bve,'Set');feb(Eve,31,Fve);_.Nc=function Ye(){return new Swb(this,1)};_.Fb=function We(a){return Ue(this,a)};_.Hb=function Xe(){return Bob(this)};sfb(Bve,'AbstractSet',Eve);feb(2068,Eve,Fve);sfb(xve,'Sets/ImprovedAbstractSet',2068);feb(2069,2068,Fve);_.$b=function $e(){this.Rc().$b();};_.Hc=function _e(a){return Ze(this,a)};_.dc=function af(){return this.Rc().dc()};_.Mc=function bf(a){var b;if(this.Hc(a)&&ZD(a,44)){b=RD(a,44);return this.Rc().ec().Mc(b.ld())}return false};_.gc=function cf(){return this.Rc().gc()};sfb(xve,'Maps/EntrySet',2069);feb(1127,2069,Fve,df);_.Hc=function ef(a){return Nk(this.a.d.vc(),a)};_.Kc=function ff(){return new mf(this.a)};_.Rc=function gf(){return this.a};_.Mc=function hf(a){var b;if(!Nk(this.a.d.vc(),a)){return false}b=RD(Hvb(RD(a,44)),44);Tc(this.a.e,b.ld());return true};_.Nc=function jf(){return gk(this.a.d.vc().Nc(),new kf(this.a))};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapEntries',1127);feb(1128,1,{},kf);_.Kb=function lf(a){return me(this.a,RD(a,44))};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapEntries/0methodref$wrapEntry$Type',1128);feb(746,1,Ave,mf);_.Nb=function nf(a){Ztb(this,a);};_.Pb=function pf(){var a;return a=RD(this.b.Pb(),44),this.a=RD(a.md(),16),me(this.c,a)};_.Ob=function of(){return this.b.Ob()};_.Qb=function qf(){Vb(!!this.a);this.b.Qb();this.c.e.d-=this.a.gc();this.a.$b();this.a=null;};sfb(xve,'AbstractMapBasedMultimap/AsMap/AsMapIterator',746);feb(542,2068,Fve,rf);_.$b=function sf(){this.b.$b();};_.Hc=function tf(a){return this.b._b(a)};_.Jc=function uf(a){Qb(a);this.b.wc(new lw(a));};_.dc=function vf(){return this.b.dc()};_.Kc=function wf(){return new aw(this.b.vc().Kc())};_.Mc=function xf(a){if(this.b._b(a)){this.b.Bc(a);return true}return false};_.gc=function yf(){return this.b.gc()};sfb(xve,'Maps/KeySet',542);feb(327,542,Fve,zf);_.$b=function Af(){var a;Ar((a=this.b.vc().Kc(),new Hf(this,a)));};_.Ic=function Bf(a){return this.b.ec().Ic(a)};_.Fb=function Cf(a){return this===a||pb(this.b.ec(),a)};_.Hb=function Df(){return tb(this.b.ec())};_.Kc=function Ef(){var a;return a=this.b.vc().Kc(),new Hf(this,a)};_.Mc=function Ff(a){var b,c;c=0;b=RD(this.b.Bc(a),16);if(b){c=b.gc();b.$b();this.a.d-=c;}return c>0};_.Nc=function Gf(){return this.b.ec().Nc()};sfb(xve,'AbstractMapBasedMultimap/KeySet',327);feb(747,1,Ave,Hf);_.Nb=function If(a){Ztb(this,a);};_.Ob=function Jf(){return this.c.Ob()};_.Pb=function Kf(){this.a=RD(this.c.Pb(),44);return this.a.ld()};_.Qb=function Lf(){var a;Vb(!!this.a);a=RD(this.a.md(),16);this.c.Qb();this.b.a.d-=a.gc();a.$b();this.a=null;};sfb(xve,'AbstractMapBasedMultimap/KeySet/1',747);feb(503,402,{85:1,133:1},Mf);_.bc=function Nf(){return this.Sc()};_.ec=function Qf(){return this.Uc()};_.Sc=function Of(){return new eg(this.c,this.Wc())};_.Tc=function Pf(){return this.Wc().Tc()};_.Uc=function Rf(){var a;return a=this.b,!a?(this.b=this.Sc()):a};_.Vc=function Sf(){return this.Wc().Vc()};_.Wc=function Tf(){return RD(this.d,133)};sfb(xve,'AbstractMapBasedMultimap/SortedAsMap',503);feb(446,503,Gve,Uf);_.bc=function Wf(){return new gg(this.a,RD(RD(this.d,133),139))};_.Sc=function Xf(){return new gg(this.a,RD(RD(this.d,133),139))};_.ec=function _f(){var a;return a=this.b,RD(!a?(this.b=new gg(this.a,RD(RD(this.d,133),139))):a,277)};_.Uc=function ag(){var a;return a=this.b,RD(!a?(this.b=new gg(this.a,RD(RD(this.d,133),139))):a,277)};_.Wc=function cg(){return RD(RD(this.d,133),139)};_.Xc=function Vf(a){return RD(RD(this.d,133),139).Xc(a)};_.Yc=function Yf(a){return RD(RD(this.d,133),139).Yc(a)};_.Zc=function Zf(a,b){return new Uf(this.a,RD(RD(this.d,133),139).Zc(a,b))};_.$c=function $f(a){return RD(RD(this.d,133),139).$c(a)};_._c=function bg(a){return RD(RD(this.d,133),139)._c(a)};_.ad=function dg(a,b){return new Uf(this.a,RD(RD(this.d,133),139).ad(a,b))};sfb(xve,'AbstractMapBasedMultimap/NavigableAsMap',446);feb(502,327,Hve,eg);_.Nc=function fg(){return this.b.ec().Nc()};sfb(xve,'AbstractMapBasedMultimap/SortedKeySet',502);feb(401,502,Ive,gg);sfb(xve,'AbstractMapBasedMultimap/NavigableKeySet',401);feb(551,31,Dve,lg);_.Fc=function mg(a){var b,c;ig(this);c=this.d.dc();b=this.d.Fc(a);if(b){++this.f.d;c&&hg(this);}return b};_.Gc=function ng(a){var b,c,d;if(a.dc()){return false}d=(ig(this),this.d.gc());b=this.d.Gc(a);if(b){c=this.d.gc();this.f.d+=c-d;d==0&&hg(this);}return b};_.$b=function og(){var a;a=(ig(this),this.d.gc());if(a==0){return}this.d.$b();this.f.d-=a;jg(this);};_.Hc=function pg(a){ig(this);return this.d.Hc(a)};_.Ic=function qg(a){ig(this);return this.d.Ic(a)};_.Fb=function rg(a){if(a===this){return true}ig(this);return pb(this.d,a)};_.Hb=function sg(){ig(this);return tb(this.d)};_.Kc=function tg(){ig(this);return new Og(this)};_.Mc=function ug(a){var b;ig(this);b=this.d.Mc(a);if(b){--this.f.d;jg(this);}return b};_.gc=function vg(){return kg(this)};_.Nc=function wg(){return ig(this),this.d.Nc()};_.Ib=function xg(){ig(this);return jeb(this.d)};sfb(xve,'AbstractMapBasedMultimap/WrappedCollection',551);var QK=ufb(Bve,'List');feb(744,551,{20:1,31:1,16:1,15:1},yg);_.jd=function Hg(a){tvb(this,a);};_.Nc=function Ig(){return ig(this),this.d.Nc()};_.bd=function zg(a,b){var c;ig(this);c=this.d.dc();RD(this.d,15).bd(a,b);++this.a.d;c&&hg(this);};_.cd=function Ag(a,b){var c,d,e;if(b.dc()){return false}e=(ig(this),this.d.gc());c=RD(this.d,15).cd(a,b);if(c){d=this.d.gc();this.a.d+=d-e;e==0&&hg(this);}return c};_.Xb=function Bg(a){ig(this);return RD(this.d,15).Xb(a)};_.dd=function Cg(a){ig(this);return RD(this.d,15).dd(a)};_.ed=function Dg(){ig(this);return new Ug(this)};_.fd=function Eg(a){ig(this);return new Vg(this,a)};_.gd=function Fg(a){var b;ig(this);b=RD(this.d,15).gd(a);--this.a.d;jg(this);return b};_.hd=function Gg(a,b){ig(this);return RD(this.d,15).hd(a,b)};_.kd=function Jg(a,b){ig(this);return Vc(this.a,this.e,RD(this.d,15).kd(a,b),!this.b?this:this.b)};sfb(xve,'AbstractMapBasedMultimap/WrappedList',744);feb(1126,744,{20:1,31:1,16:1,15:1,59:1},Kg);sfb(xve,'AbstractMapBasedMultimap/RandomAccessWrappedList',1126);feb(628,1,Ave,Og);_.Nb=function Qg(a){Ztb(this,a);};_.Ob=function Rg(){Ng(this);return this.b.Ob()};_.Pb=function Sg(){Ng(this);return this.b.Pb()};_.Qb=function Tg(){Mg(this);};sfb(xve,'AbstractMapBasedMultimap/WrappedCollection/WrappedIterator',628);feb(745,628,Jve,Ug,Vg);_.Qb=function _g(){Mg(this);};_.Rb=function Wg(a){var b;b=kg(this.a)==0;(Ng(this),RD(this.b,128)).Rb(a);++this.a.a.d;b&&hg(this.a);};_.Sb=function Xg(){return (Ng(this),RD(this.b,128)).Sb()};_.Tb=function Yg(){return (Ng(this),RD(this.b,128)).Tb()};_.Ub=function Zg(){return (Ng(this),RD(this.b,128)).Ub()};_.Vb=function $g(){return (Ng(this),RD(this.b,128)).Vb()};_.Wb=function ah(a){(Ng(this),RD(this.b,128)).Wb(a);};sfb(xve,'AbstractMapBasedMultimap/WrappedList/WrappedListIterator',745);feb(743,551,Hve,bh);_.Nc=function dh(){return ig(this),this.d.Nc()};sfb(xve,'AbstractMapBasedMultimap/WrappedSortedSet',743);feb(1125,743,Ive,eh);sfb(xve,'AbstractMapBasedMultimap/WrappedNavigableSet',1125);feb(1124,551,Fve,fh);_.Nc=function gh(){return ig(this),this.d.Nc()};sfb(xve,'AbstractMapBasedMultimap/WrappedSet',1124);feb(1133,1,{},hh);_.Kb=function ih(a){return fd(RD(a,44))};sfb(xve,'AbstractMapBasedMultimap/lambda$1$Type',1133);feb(1132,1,{},jh);_.Kb=function kh(a){return new gp(this.a,a)};sfb(xve,'AbstractMapBasedMultimap/lambda$2$Type',1132);var UK=ufb(Bve,'Map/Entry');feb(358,1,Kve);_.Fb=function lh(a){var b;if(ZD(a,44)){b=RD(a,44);return Hb(this.ld(),b.ld())&&Hb(this.md(),b.md())}return false};_.Hb=function mh(){var a,b;a=this.ld();b=this.md();return (a==null?0:tb(a))^(b==null?0:tb(b))};_.nd=function nh(a){throw Adb(new jib)};_.Ib=function oh(){return this.ld()+'='+this.md()};sfb(xve,Lve,358);feb(2086,31,Dve);_.$b=function ph(){this.od().$b();};_.Hc=function qh(a){var b;if(ZD(a,44)){b=RD(a,44);return Cc(this.od(),b.ld(),b.md())}return false};_.Mc=function rh(a){var b;if(ZD(a,44)){b=RD(a,44);return Gc(this.od(),b.ld(),b.md())}return false};_.gc=function sh(){return this.od().d};sfb(xve,'Multimaps/Entries',2086);feb(749,2086,Dve,th);_.Kc=function uh(){return this.a.kc()};_.od=function vh(){return this.a};_.Nc=function wh(){return this.a.lc()};sfb(xve,'AbstractMultimap/Entries',749);feb(750,749,Fve,xh);_.Nc=function Ah(){return this.a.lc()};_.Fb=function yh(a){return Rx(this,a)};_.Hb=function zh(){return Sx(this)};sfb(xve,'AbstractMultimap/EntrySet',750);feb(751,31,Dve,Bh);_.$b=function Ch(){this.a.$b();};_.Hc=function Dh(a){return Dc(this.a,a)};_.Kc=function Eh(){return this.a.nc()};_.gc=function Fh(){return this.a.d};_.Nc=function Gh(){return this.a.oc()};sfb(xve,'AbstractMultimap/Values',751);feb(2087,31,{849:1,20:1,31:1,16:1});_.Jc=function Oh(a){Qb(a);Ih(this).Jc(new lx(a));};_.Nc=function Sh(){var a;return a=Ih(this).Nc(),ek(a,new sx,64|a.yd()&1296,this.a.d)};_.Fc=function Kh(a){Hh();return true};_.Gc=function Lh(a){return Qb(this),Qb(a),ZD(a,552)?nx(RD(a,849)):!a.dc()&&xr(this,a.Kc())};_.Hc=function Mh(a){var b;return b=RD(Xv(nd(this.a),a),16),(!b?0:b.gc())>0};_.Fb=function Nh(a){return ox(this,a)};_.Hb=function Ph(){return tb(Ih(this))};_.dc=function Qh(){return Ih(this).dc()};_.Mc=function Rh(a){return Rw(this,a,1)>0};_.Ib=function Th(){return jeb(Ih(this))};sfb(xve,'AbstractMultiset',2087);feb(2089,2068,Fve);_.$b=function Uh(){Nc(this.a.a);};_.Hc=function Vh(a){var b,c;if(ZD(a,504)){c=RD(a,425);if(RD(c.a.md(),16).gc()<=0){return false}b=Qw(this.a,c.a.ld());return b==RD(c.a.md(),16).gc()}return false};_.Mc=function Wh(a){var b,c,d,e;if(ZD(a,504)){c=RD(a,425);b=c.a.ld();d=RD(c.a.md(),16).gc();if(d!=0){e=this.a;return qx(e,b,d)}}return false};sfb(xve,'Multisets/EntrySet',2089);feb(1139,2089,Fve,Xh);_.Kc=function Yh(){return new _w(fe(nd(this.a.a)).Kc())};_.gc=function Zh(){return nd(this.a.a).gc()};sfb(xve,'AbstractMultiset/EntrySet',1139);feb(627,742,zve);_.hc=function ai(){return this.pd()};_.jc=function bi(){return this.qd()};_.cc=function ei(a){return this.rd(a)};_.fc=function gi(a){return this.sd(a)};_.Zb=function _h(){var a;return a=this.f,!a?(this.f=this.ac()):a};_.qd=function ci(){return yob(),yob(),xob};_.Fb=function di(a){return xw(this,a)};_.rd=function fi(a){return RD(Qc(this,a),21)};_.sd=function hi(a){return RD(Sc(this,a),21)};_.mc=function ii(a){return yob(),new Lqb(RD(a,21))};_.pc=function ji(a,b){return new fh(this,a,RD(b,21))};sfb(xve,'AbstractSetMultimap',627);feb(1723,627,zve);_.hc=function mi(){return new yAb(this.b)};_.pd=function ni(){return new yAb(this.b)};_.jc=function oi(){return Zx(new yAb(this.b))};_.qd=function pi(){return Zx(new yAb(this.b))};_.cc=function qi(a){return RD(RD(Qc(this,a),21),87)};_.rd=function ri(a){return RD(RD(Qc(this,a),21),87)};_.fc=function si(a){return RD(RD(Sc(this,a),21),87)};_.sd=function ti(a){return RD(RD(Sc(this,a),21),87)};_.mc=function ui(a){return ZD(a,277)?Zx(RD(a,277)):(yob(),new jrb(RD(a,87)))};_.Zb=function li(){var a;return a=this.f,!a?(this.f=ZD(this.c,139)?new Uf(this,RD(this.c,139)):ZD(this.c,133)?new Mf(this,RD(this.c,133)):new ne(this,this.c)):a};_.pc=function vi(a,b){return ZD(b,277)?new eh(this,a,RD(b,277)):new bh(this,a,RD(b,87))};sfb(xve,'AbstractSortedSetMultimap',1723);feb(1724,1723,zve);_.Zb=function xi(){var a;return a=this.f,RD(RD(!a?(this.f=ZD(this.c,139)?new Uf(this,RD(this.c,139)):ZD(this.c,133)?new Mf(this,RD(this.c,133)):new ne(this,this.c)):a,133),139)};_.ec=function zi(){var a;return a=this.i,RD(RD(!a?(this.i=ZD(this.c,139)?new gg(this,RD(this.c,139)):ZD(this.c,133)?new eg(this,RD(this.c,133)):new zf(this,this.c)):a,87),277)};_.bc=function yi(){return ZD(this.c,139)?new gg(this,RD(this.c,139)):ZD(this.c,133)?new eg(this,RD(this.c,133)):new zf(this,this.c)};sfb(xve,'AbstractSortedKeySortedSetMultimap',1724);feb(2109,1,{2046:1});_.Fb=function Ai(a){return Qy(this,a)};_.Hb=function Bi(){var a;return Bob((a=this.g,!a?(this.g=new Di(this)):a))};_.Ib=function Ci(){var a;return Md((a=this.f,!a?(this.f=new Zj(this)):a))};sfb(xve,'AbstractTable',2109);feb(679,Eve,Fve,Di);_.$b=function Ei(){Xi();};_.Hc=function Fi(a){var b,c;if(ZD(a,479)){b=RD(a,697);c=RD(Xv(bj(this.a),Qm(b.c.e,b.b)),85);return !!c&&Nk(c.vc(),new gp(Qm(b.c.c,b.a),Ui(b.c,b.b,b.a)))}return false};_.Kc=function Gi(){return Vi(this.a)};_.Mc=function Hi(a){var b,c;if(ZD(a,479)){b=RD(a,697);c=RD(Xv(bj(this.a),Qm(b.c.e,b.b)),85);return !!c&&Ok(c.vc(),new gp(Qm(b.c.c,b.a),Ui(b.c,b.b,b.a)))}return false};_.gc=function Ii(){return dj(this.a)};_.Nc=function Ji(){return Wi(this.a)};sfb(xve,'AbstractTable/CellSet',679);feb(2025,31,Dve,Ki);_.$b=function Li(){Xi();};_.Hc=function Mi(a){return Yi(this.a,a)};_.Kc=function Ni(){return fj(this.a)};_.gc=function Oi(){return dj(this.a)};_.Nc=function Pi(){return gj(this.a)};sfb(xve,'AbstractTable/Values',2025);feb(1697,1696,zve);sfb(xve,'ArrayListMultimapGwtSerializationDependencies',1697);feb(520,1697,zve,Ri,Si);_.hc=function Ti(){return new cnb(this.a)};_.a=0;sfb(xve,'ArrayListMultimap',520);feb(678,2109,{678:1,2046:1,3:1},hj);sfb(xve,'ArrayTable',678);feb(2021,399,yve,ij);_.Xb=function jj(a){return new pj(this.a,a)};sfb(xve,'ArrayTable/1',2021);feb(2022,1,{},kj);_.td=function lj(a){return new pj(this.a,a)};sfb(xve,'ArrayTable/1methodref$getCell$Type',2022);feb(2110,1,{697:1});_.Fb=function mj(a){var b;if(a===this){return true}if(ZD(a,479)){b=RD(a,697);return Hb(Qm(this.c.e,this.b),Qm(b.c.e,b.b))&&Hb(Qm(this.c.c,this.a),Qm(b.c.c,b.a))&&Hb(Ui(this.c,this.b,this.a),Ui(b.c,b.b,b.a))}return false};_.Hb=function nj(){return Tnb(cD(WC(jJ,1),rve,1,5,[Qm(this.c.e,this.b),Qm(this.c.c,this.a),Ui(this.c,this.b,this.a)]))};_.Ib=function oj(){return '('+Qm(this.c.e,this.b)+','+Qm(this.c.c,this.a)+')='+Ui(this.c,this.b,this.a)};sfb(xve,'Tables/AbstractCell',2110);feb(479,2110,{479:1,697:1},pj);_.a=0;_.b=0;_.d=0;sfb(xve,'ArrayTable/2',479);feb(2024,1,{},qj);_.td=function rj(a){return _i(this.a,a)};sfb(xve,'ArrayTable/2methodref$getValue$Type',2024);feb(2023,399,yve,sj);_.Xb=function tj(a){return _i(this.a,a)};sfb(xve,'ArrayTable/3',2023);feb(2077,2065,Cve);_.$b=function vj(){Ar(this.kc());};_.vc=function wj(){return new gw(this)};_.lc=function xj(){return new Uwb(this.kc(),this.gc())};sfb(xve,'Maps/IteratorBasedAbstractMap',2077);feb(842,2077,Cve);_.$b=function Bj(){throw Adb(new jib)};_._b=function Cj(a){return En(this.c,a)};_.kc=function Dj(){return new Rj(this,this.c.b.c.gc())};_.lc=function Ej(){return fk(this.c.b.c.gc(),16,new Lj(this))};_.xc=function Fj(a){var b;b=RD(Fn(this.c,a),17);return !b?null:this.vd(b.a)};_.dc=function Gj(){return this.c.b.c.dc()};_.ec=function Hj(){return hn(this.c)};_.zc=function Ij(a,b){var c;c=RD(Fn(this.c,a),17);if(!c){throw Adb(new agb(this.ud()+' '+a+' not in '+hn(this.c)))}return this.wd(c.a,b)};_.Bc=function Jj(a){throw Adb(new jib)};_.gc=function Kj(){return this.c.b.c.gc()};sfb(xve,'ArrayTable/ArrayMap',842);feb(2020,1,{},Lj);_.td=function Mj(a){return yj(this.a,a)};sfb(xve,'ArrayTable/ArrayMap/0methodref$getEntry$Type',2020);feb(2018,358,Kve,Nj);_.ld=function Oj(){return zj(this.a,this.b)};_.md=function Pj(){return this.a.vd(this.b)};_.nd=function Qj(a){return this.a.wd(this.b,a)};_.b=0;sfb(xve,'ArrayTable/ArrayMap/1',2018);feb(2019,399,yve,Rj);_.Xb=function Sj(a){return yj(this.a,a)};sfb(xve,'ArrayTable/ArrayMap/2',2019);feb(2017,842,Cve,Tj);_.ud=function Uj(){return 'Column'};_.vd=function Vj(a){return Ui(this.b,this.a,a)};_.wd=function Wj(a,b){return cj(this.b,this.a,a,b)};_.a=0;sfb(xve,'ArrayTable/Row',2017);feb(843,842,Cve,Zj);_.vd=function _j(a){return new Tj(this.a,a)};_.zc=function ak(a,b){return RD(b,85),Xj()};_.wd=function bk(a,b){return RD(b,85),Yj()};_.ud=function $j(){return 'Row'};sfb(xve,'ArrayTable/RowMap',843);feb(1157,1,Pve,hk);_.Ad=function lk(a){return (this.a.yd()&-262&a)!=0};_.yd=function ik(){return this.a.yd()&-262};_.zd=function jk(){return this.a.zd()};_.Nb=function kk(a){this.a.Nb(new pk(a,this.b));};_.Bd=function mk(a){return this.a.Bd(new nk(a,this.b))};sfb(xve,'CollectSpliterators/1',1157);feb(1158,1,Qve,nk);_.Cd=function ok(a){this.a.Cd(this.b.Kb(a));};sfb(xve,'CollectSpliterators/1/lambda$0$Type',1158);feb(1159,1,Qve,pk);_.Cd=function qk(a){this.a.Cd(this.b.Kb(a));};sfb(xve,'CollectSpliterators/1/lambda$1$Type',1159);feb(1154,1,Pve,rk);_.Ad=function vk(a){return ((16464|this.b)&a)!=0};_.yd=function sk(){return 16464|this.b};_.zd=function tk(){return this.a.zd()};_.Nb=function uk(a){this.a.Qe(new zk(a,this.c));};_.Bd=function wk(a){return this.a.Re(new xk(a,this.c))};_.b=0;sfb(xve,'CollectSpliterators/1WithCharacteristics',1154);feb(1155,1,Rve,xk);_.Dd=function yk(a){this.a.Cd(this.b.td(a));};sfb(xve,'CollectSpliterators/1WithCharacteristics/lambda$0$Type',1155);feb(1156,1,Rve,zk);_.Dd=function Ak(a){this.a.Cd(this.b.td(a));};sfb(xve,'CollectSpliterators/1WithCharacteristics/lambda$1$Type',1156);feb(1150,1,Pve);_.Ad=function Gk(a){return (this.a&a)!=0};_.yd=function Dk(){return this.a};_.zd=function Ek(){!!this.e&&(this.b=Kgb(this.b,this.e.zd()));return Kgb(this.b,0)};_.Nb=function Fk(a){if(this.e){this.e.Nb(a);this.e=null;}this.c.Nb(new Kk(this,a));this.b=0;};_.Bd=function Hk(a){while(true){if(!!this.e&&this.e.Bd(a)){Pdb(this.b,Sve)&&(this.b=Vdb(this.b,1));return true}else {this.e=null;}if(!this.c.Bd(new Ik(this))){return false}}};_.a=0;_.b=0;sfb(xve,'CollectSpliterators/FlatMapSpliterator',1150);feb(1152,1,Qve,Ik);_.Cd=function Jk(a){Bk(this.a,a);};sfb(xve,'CollectSpliterators/FlatMapSpliterator/lambda$0$Type',1152);feb(1153,1,Qve,Kk);_.Cd=function Lk(a){Ck(this.a,this.b,a);};sfb(xve,'CollectSpliterators/FlatMapSpliterator/lambda$1$Type',1153);feb(1151,1150,Pve,Mk);sfb(xve,'CollectSpliterators/FlatMapSpliteratorOfObject',1151);feb(253,1,Tve);_.Fd=function Sk(a){return this.Ed(RD(a,253))};_.Ed=function Rk(a){var b;if(a==(kl(),jl)){return 1}if(a==(Wk(),Vk)){return -1}b=(ux(),Leb(this.a,a.a));if(b!=0){return b}return ZD(this,526)==ZD(a,526)?0:ZD(this,526)?1:-1};_.Id=function Tk(){return this.a};_.Fb=function Uk(a){return Pk(this,a)};sfb(xve,'Cut',253);feb(1823,253,Tve,Xk);_.Ed=function Yk(a){return a==this?0:1};_.Gd=function Zk(a){throw Adb(new Ceb)};_.Hd=function $k(a){a.a+='+\u221E)';};_.Id=function _k(){throw Adb(new dgb(Uve))};_.Hb=function al(){return gib(),jFb(this)};_.Jd=function bl(a){return false};_.Ib=function cl(){return '+\u221E'};var Vk;sfb(xve,'Cut/AboveAll',1823);feb(526,253,{253:1,526:1,3:1,34:1},dl);_.Gd=function el(a){Yhb((a.a+='(',a),this.a);};_.Hd=function fl(a){Thb(Yhb(a,this.a),93);};_.Hb=function gl(){return ~tb(this.a)};_.Jd=function hl(a){return ux(),Leb(this.a,a)<0};_.Ib=function il(){return '/'+this.a+'\\'};sfb(xve,'Cut/AboveValue',526);feb(1822,253,Tve,ll);_.Ed=function ml(a){return a==this?0:-1};_.Gd=function nl(a){a.a+='(-\u221E';};_.Hd=function ol(a){throw Adb(new Ceb)};_.Id=function pl(){throw Adb(new dgb(Uve))};_.Hb=function ql(){return gib(),jFb(this)};_.Jd=function rl(a){return true};_.Ib=function sl(){return '-\u221E'};var jl;sfb(xve,'Cut/BelowAll',1822);feb(1824,253,Tve,tl);_.Gd=function ul(a){Yhb((a.a+='[',a),this.a);};_.Hd=function vl(a){Thb(Yhb(a,this.a),41);};_.Hb=function wl(){return tb(this.a)};_.Jd=function xl(a){return ux(),Leb(this.a,a)<=0};_.Ib=function yl(){return '\\'+this.a+'/'};sfb(xve,'Cut/BelowValue',1824);feb(547,1,Vve);_.Jc=function Bl(a){xgb(this,a);};_.Ib=function Cl(){return Lr(RD(Rb(this,'use Optional.orNull() instead of Optional.or(null)'),20).Kc())};sfb(xve,'FluentIterable',547);feb(442,547,Vve,Dl);_.Kc=function El(){return new is(Mr(this.a.Kc(),new ir))};sfb(xve,'FluentIterable/2',442);feb(1059,547,Vve,Gl);_.Kc=function Hl(){return Fl(this)};sfb(xve,'FluentIterable/3',1059);feb(724,399,yve,Il);_.Xb=function Jl(a){return this.a[a].Kc()};sfb(xve,'FluentIterable/3/1',724);feb(2070,1,{});_.Ib=function Kl(){return jeb(this.Kd().b)};sfb(xve,'ForwardingObject',2070);feb(2071,2070,Wve);_.Kd=function Ql(){return this.Ld()};_.Jc=function Rl(a){xgb(this,a);};_.Lc=function Ul(){return this.Oc()};_.Nc=function Xl(){return new Swb(this,0)};_.Oc=function Yl(){return new SDb(null,this.Nc())};_.Fc=function Ll(a){return this.Ld(),qpb()};_.Gc=function Ml(a){return this.Ld(),rpb()};_.$b=function Nl(){this.Ld(),spb();};_.Hc=function Ol(a){return this.Ld().Hc(a)};_.Ic=function Pl(a){return this.Ld().Ic(a)};_.dc=function Sl(){return this.Ld().b.dc()};_.Kc=function Tl(){return this.Ld().Kc()};_.Mc=function Vl(a){return this.Ld(),vpb()};_.gc=function Wl(){return this.Ld().b.gc()};_.Pc=function Zl(){return this.Ld().Pc()};_.Qc=function $l(a){return this.Ld().Qc(a)};sfb(xve,'ForwardingCollection',2071);feb(2078,31,Xve);_.Kc=function gm(){return this.Od()};_.Fc=function am(a){throw Adb(new jib)};_.Gc=function bm(a){throw Adb(new jib)};_.Md=function cm(){var a;a=this.c;return !a?(this.c=this.Nd()):a};_.$b=function dm(){throw Adb(new jib)};_.Hc=function em(a){return a!=null&&ze(this,a,false)};_.Nd=function fm(){switch(this.gc()){case 0:return tm(),tm(),sm;case 1:return tm(),new Dy(Qb(this.Od().Pb()));default:return new Fx(this,this.Pc());}};_.Mc=function hm(a){throw Adb(new jib)};sfb(xve,'ImmutableCollection',2078);feb(727,2078,Xve,im);_.Kc=function nm(){return Nr(this.a.Kc())};_.Hc=function jm(a){return a!=null&&this.a.Hc(a)};_.Ic=function km(a){return this.a.Ic(a)};_.dc=function lm(){return this.a.dc()};_.Od=function mm(){return Nr(this.a.Kc())};_.gc=function om(){return this.a.gc()};_.Pc=function pm(){return this.a.Pc()};_.Qc=function qm(a){return this.a.Qc(a)};_.Ib=function rm(){return jeb(this.a)};sfb(xve,'ForwardingImmutableCollection',727);feb(307,2078,Yve);_.Kc=function Em(){return this.Od()};_.ed=function Fm(){return this.Pd(0)};_.fd=function Hm(a){return this.Pd(a)};_.jd=function Lm(a){tvb(this,a);};_.Nc=function Mm(){return new Swb(this,16)};_.kd=function Om(a,b){return this.Qd(a,b)};_.bd=function wm(a,b){throw Adb(new jib)};_.cd=function xm(a,b){throw Adb(new jib)};_.Md=function ym(){return this};_.Fb=function Am(a){return $u(this,a)};_.Hb=function Bm(){return _u(this)};_.dd=function Cm(a){return a==null?-1:av(this,a)};_.Od=function Dm(){return this.Pd(0)};_.Pd=function Gm(a){return um(this,a)};_.gd=function Jm(a){throw Adb(new jib)};_.hd=function Km(a,b){throw Adb(new jib)};_.Qd=function Nm(a,b){var c;return Pm((c=new pv(this),new Rkb(c,a,b)))};var sm;sfb(xve,'ImmutableList',307);feb(2105,307,Yve);_.Kc=function Zm(){return Nr(this.Rd().Kc())};_.kd=function an(a,b){return Pm(this.Rd().kd(a,b))};_.Hc=function Rm(a){return a!=null&&this.Rd().Hc(a)};_.Ic=function Sm(a){return this.Rd().Ic(a)};_.Fb=function Tm(a){return pb(this.Rd(),a)};_.Xb=function Um(a){return Qm(this,a)};_.Hb=function Vm(){return tb(this.Rd())};_.dd=function Wm(a){return this.Rd().dd(a)};_.dc=function Xm(){return this.Rd().dc()};_.Od=function Ym(){return Nr(this.Rd().Kc())};_.gc=function $m(){return this.Rd().gc()};_.Qd=function _m(a,b){return Pm(this.Rd().kd(a,b))};_.Pc=function bn(){return this.Rd().Qc($C(jJ,rve,1,this.Rd().gc(),5,1))};_.Qc=function cn(a){return this.Rd().Qc(a)};_.Ib=function dn(){return jeb(this.Rd())};sfb(xve,'ForwardingImmutableList',2105);feb(729,1,$ve);_.vc=function pn(){return gn(this)};_.wc=function rn(a){Bvb(this,a);};_.ec=function vn(){return hn(this)};_.yc=function wn(a,b,c){return Cvb(this,a,b,c)};_.Cc=function Dn(){return this.Vd()};_.$b=function kn(){throw Adb(new jib)};_._b=function ln(a){return this.xc(a)!=null};_.uc=function mn(a){return this.Vd().Hc(a)};_.Td=function nn(){return new xq(this)};_.Ud=function on(){return new Gq(this)};_.Fb=function qn(a){return Tv(this,a)};_.Hb=function tn(){return gn(this).Hb()};_.dc=function un(){return this.gc()==0};_.zc=function zn(a,b){return jn()};_.Bc=function An(a){throw Adb(new jib)};_.Ib=function Bn(){return Zv(this)};_.Vd=function Cn(){if(this.e){return this.e}return this.e=this.Ud()};_.c=null;_.d=null;_.e=null;var en;sfb(xve,'ImmutableMap',729);feb(730,729,$ve);_._b=function Hn(a){return En(this,a)};_.uc=function In(a){return pqb(this.b,a)};_.Sd=function Jn(){return go(new Xn(this))};_.Td=function Kn(){return go(sqb(this.b))};_.Ud=function Ln(){return _l(),new im(tqb(this.b))};_.Fb=function Mn(a){return rqb(this.b,a)};_.xc=function Nn(a){return Fn(this,a)};_.Hb=function On(){return tb(this.b.c)};_.dc=function Pn(){return this.b.c.dc()};_.gc=function Qn(){return this.b.c.gc()};_.Ib=function Rn(){return jeb(this.b.c)};sfb(xve,'ForwardingImmutableMap',730);feb(2072,2071,_ve);_.Kd=function Sn(){return this.Wd()};_.Ld=function Tn(){return this.Wd()};_.Nc=function Wn(){return new Swb(this,1)};_.Fb=function Un(a){return a===this||this.Wd().Fb(a)};_.Hb=function Vn(){return this.Wd().Hb()};sfb(xve,'ForwardingSet',2072);feb(1085,2072,_ve,Xn);_.Kd=function Zn(){return qqb(this.a.b)};_.Ld=function $n(){return qqb(this.a.b)};_.Hc=function Yn(b){if(ZD(b,44)&&RD(b,44).ld()==null){return false}try{return Pqb(qqb(this.a.b),b)}catch(a){a=zdb(a);if(ZD(a,212)){return false}else throw Adb(a)}};_.Wd=function _n(){return qqb(this.a.b)};_.Qc=function ao(a){var b;b=Qqb(qqb(this.a.b),a);qqb(this.a.b).b.gc()=0?'+':'')+(c/60|0);b=AB($wnd.Math.abs(c)%60);return (Mrb(),Krb)[this.q.getDay()]+' '+Lrb[this.q.getMonth()]+' '+AB(this.q.getDate())+' '+AB(this.q.getHours())+':'+AB(this.q.getMinutes())+':'+AB(this.q.getSeconds())+' GMT'+a+b+' '+this.q.getFullYear()};var qK=sfb(Bve,'Date',206);feb(2015,206,bxe,DB);_.a=false;_.b=0;_.c=0;_.d=0;_.e=0;_.f=0;_.g=false;_.i=0;_.j=0;_.k=0;_.n=0;_.o=0;_.p=0;sfb('com.google.gwt.i18n.shared.impl','DateRecord',2015);feb(2064,1,{});_.pe=function EB(){return null};_.qe=function FB(){return null};_.re=function GB(){return null};_.se=function HB(){return null};_.te=function IB(){return null};sfb(cxe,'JSONValue',2064);feb(221,2064,{221:1},MB,NB);_.Fb=function OB(a){if(!ZD(a,221)){return false}return Hz(this.a,RD(a,221).a)};_.oe=function PB(){return TB};_.Hb=function QB(){return Iz(this.a)};_.pe=function RB(){return this};_.Ib=function SB(){var a,b,c;c=new dib('[');for(b=0,a=this.a.length;b0&&(c.a+=',',c);Yhb(c,JB(this,b));}c.a+=']';return c.a};sfb(cxe,'JSONArray',221);feb(493,2064,{493:1},XB);_.oe=function YB(){return _B};_.qe=function ZB(){return this};_.Ib=function $B(){return Geb(),''+this.a};_.a=false;var UB,VB;sfb(cxe,'JSONBoolean',493);feb(997,63,swe,aC);sfb(cxe,'JSONException',997);feb(1036,2064,{},dC);_.oe=function eC(){return gC};_.Ib=function fC(){return vve};var bC;sfb(cxe,'JSONNull',1036);feb(263,2064,{263:1},hC);_.Fb=function iC(a){if(!ZD(a,263)){return false}return this.a==RD(a,263).a};_.oe=function jC(){return nC};_.Hb=function kC(){return Nfb(this.a)};_.re=function lC(){return this};_.Ib=function mC(){return this.a+''};_.a=0;sfb(cxe,'JSONNumber',263);feb(190,2064,{190:1},uC,vC);_.Fb=function wC(a){if(!ZD(a,190)){return false}return Hz(this.a,RD(a,190).a)};_.oe=function xC(){return BC};_.Hb=function yC(){return Iz(this.a)};_.se=function zC(){return this};_.Ib=function AC(){var a,b,c,d,e,f,g;g=new dib('{');a=true;f=oC(this,$C(qJ,Nve,2,0,6,1));for(c=f,d=0,e=c.length;d=0?':'+this.c:'')+')'};_.c=0;var mJ=sfb(mve,'StackTraceElement',319);PD={3:1,484:1,34:1,2:1};var qJ=sfb(mve,uwe,2);feb(111,427,{484:1},Qhb,Rhb,Shb);sfb(mve,'StringBuffer',111);feb(104,427,{484:1},bib,cib,dib);sfb(mve,'StringBuilder',104);feb(702,77,lxe,eib);sfb(mve,'StringIndexOutOfBoundsException',702);feb(2145,1,{});var fib;feb(48,63,{3:1,103:1,63:1,82:1,48:1},jib,kib);sfb(mve,'UnsupportedOperationException',48);feb(247,242,{3:1,34:1,242:1,247:1},Aib,Bib);_.Fd=function Eib(a){return uib(this,RD(a,247))};_.ue=function Fib(){return Neb(zib(this))};_.Fb=function Gib(a){var b;if(this===a){return true}if(ZD(a,247)){b=RD(a,247);return this.e==b.e&&uib(this,b)==0}return false};_.Hb=function Hib(){var a;if(this.b!=0){return this.b}if(this.a<54){a=Hdb(this.f);this.b=Ydb(Cdb(a,-1));this.b=33*this.b+Ydb(Cdb(Tdb(a,32),-1));this.b=17*this.b+eE(this.e);return this.b}this.b=17*Vib(this.c)+eE(this.e);return this.b};_.Ib=function Iib(){return zib(this)};_.a=0;_.b=0;_.d=0;_.e=0;_.f=0;var lib,mib,nib,oib,pib,qib,rib,sib;var tJ=sfb('java.math','BigDecimal',247);feb(92,242,{3:1,34:1,242:1,92:1},ajb,bjb,cjb,djb,ejb);_.Fd=function gjb(a){return Qib(this,RD(a,92))};_.ue=function hjb(){return Neb(Ajb(this,0))};_.Fb=function ijb(a){return Sib(this,a)};_.Hb=function ljb(){return Vib(this)};_.Ib=function njb(){return Ajb(this,0)};_.b=-2;_.c=0;_.d=0;_.e=0;var Jib,Kib,Lib,Mib,Nib,Oib;var uJ=sfb('java.math','BigInteger',92);var vjb,wjb;var Jjb,Kjb;feb(498,2065,Cve);_.$b=function dkb(){akb(this);};_._b=function ekb(a){return Ujb(this,a)};_.uc=function fkb(a){return Vjb(this,a,this.i)||Vjb(this,a,this.f)};_.vc=function gkb(){return new mkb(this)};_.xc=function hkb(a){return Wjb(this,a)};_.zc=function ikb(a,b){return Zjb(this,a,b)};_.Bc=function jkb(a){return _jb(this,a)};_.gc=function kkb(){return bkb(this)};_.g=0;sfb(Bve,'AbstractHashMap',498);feb(267,Eve,Fve,mkb);_.$b=function nkb(){this.a.$b();};_.Hc=function okb(a){return lkb(this,a)};_.Kc=function pkb(){return new vkb(this.a)};_.Mc=function qkb(a){var b;if(lkb(this,a)){b=RD(a,44).ld();this.a.Bc(b);return true}return false};_.gc=function rkb(){return this.a.gc()};sfb(Bve,'AbstractHashMap/EntrySet',267);feb(268,1,Ave,vkb);_.Nb=function wkb(a){Ztb(this,a);};_.Pb=function ykb(){return tkb(this)};_.Ob=function xkb(){return this.b};_.Qb=function zkb(){ukb(this);};_.b=false;_.d=0;sfb(Bve,'AbstractHashMap/EntrySetIterator',268);feb(426,1,Ave,Dkb);_.Nb=function Ekb(a){Ztb(this,a);};_.Ob=function Fkb(){return Akb(this)};_.Pb=function Gkb(){return Bkb(this)};_.Qb=function Hkb(){Ckb(this);};_.b=0;_.c=-1;sfb(Bve,'AbstractList/IteratorImpl',426);feb(98,426,Jve,Jkb);_.Qb=function Pkb(){Ckb(this);};_.Rb=function Kkb(a){Ikb(this,a);};_.Sb=function Lkb(){return this.b>0};_.Tb=function Mkb(){return this.b};_.Ub=function Nkb(){return sFb(this.b>0),this.a.Xb(this.c=--this.b)};_.Vb=function Okb(){return this.b-1};_.Wb=function Qkb(a){yFb(this.c!=-1);this.a.hd(this.c,a);};sfb(Bve,'AbstractList/ListIteratorImpl',98);feb(244,56,kwe,Rkb);_.bd=function Skb(a,b){wFb(a,this.b);this.c.bd(this.a+a,b);++this.b;};_.Xb=function Tkb(a){tFb(a,this.b);return this.c.Xb(this.a+a)};_.gd=function Ukb(a){var b;tFb(a,this.b);b=this.c.gd(this.a+a);--this.b;return b};_.hd=function Vkb(a,b){tFb(a,this.b);return this.c.hd(this.a+a,b)};_.gc=function Wkb(){return this.b};_.a=0;_.b=0;sfb(Bve,'AbstractList/SubList',244);feb(266,Eve,Fve,Xkb);_.$b=function Ykb(){this.a.$b();};_.Hc=function Zkb(a){return this.a._b(a)};_.Kc=function $kb(){var a;return a=this.a.vc().Kc(),new blb(a)};_.Mc=function _kb(a){if(this.a._b(a)){this.a.Bc(a);return true}return false};_.gc=function alb(){return this.a.gc()};sfb(Bve,'AbstractMap/1',266);feb(541,1,Ave,blb);_.Nb=function clb(a){Ztb(this,a);};_.Ob=function dlb(){return this.a.Ob()};_.Pb=function elb(){var a;return a=RD(this.a.Pb(),44),a.ld()};_.Qb=function flb(){this.a.Qb();};sfb(Bve,'AbstractMap/1/1',541);feb(231,31,Dve,glb);_.$b=function hlb(){this.a.$b();};_.Hc=function ilb(a){return this.a.uc(a)};_.Kc=function jlb(){var a;return a=this.a.vc().Kc(),new llb(a)};_.gc=function klb(){return this.a.gc()};sfb(Bve,'AbstractMap/2',231);feb(301,1,Ave,llb);_.Nb=function mlb(a){Ztb(this,a);};_.Ob=function nlb(){return this.a.Ob()};_.Pb=function olb(){var a;return a=RD(this.a.Pb(),44),a.md()};_.Qb=function plb(){this.a.Qb();};sfb(Bve,'AbstractMap/2/1',301);feb(494,1,{494:1,44:1});_.Fb=function rlb(a){var b;if(!ZD(a,44)){return false}b=RD(a,44);return Fvb(this.d,b.ld())&&Fvb(this.e,b.md())};_.ld=function slb(){return this.d};_.md=function tlb(){return this.e};_.Hb=function ulb(){return Gvb(this.d)^Gvb(this.e)};_.nd=function vlb(a){return qlb(this,a)};_.Ib=function wlb(){return this.d+'='+this.e};sfb(Bve,'AbstractMap/AbstractEntry',494);feb(397,494,{494:1,397:1,44:1},xlb);sfb(Bve,'AbstractMap/SimpleEntry',397);feb(2082,1,Axe);_.Fb=function ylb(a){var b;if(!ZD(a,44)){return false}b=RD(a,44);return Fvb(this.ld(),b.ld())&&Fvb(this.md(),b.md())};_.Hb=function zlb(){return Gvb(this.ld())^Gvb(this.md())};_.Ib=function Alb(){return this.ld()+'='+this.md()};sfb(Bve,Lve,2082);feb(2090,2065,Gve);_.Xc=function Dlb(a){return Vd(this.Ee(a))};_.tc=function Elb(a){return Blb(this,a)};_._b=function Flb(a){return Clb(this,a)};_.vc=function Glb(){return new Plb(this)};_.Tc=function Hlb(){return Klb(this.Ge())};_.Yc=function Ilb(a){return Vd(this.He(a))};_.xc=function Jlb(a){var b;b=a;return Wd(this.Fe(b))};_.$c=function Llb(a){return Vd(this.Ie(a))};_.ec=function Mlb(){return new Ulb(this)};_.Vc=function Nlb(){return Klb(this.Je())};_._c=function Olb(a){return Vd(this.Ke(a))};sfb(Bve,'AbstractNavigableMap',2090);feb(629,Eve,Fve,Plb);_.Hc=function Qlb(a){return ZD(a,44)&&Blb(this.b,RD(a,44))};_.Kc=function Rlb(){return this.b.De()};_.Mc=function Slb(a){var b;if(ZD(a,44)){b=RD(a,44);return this.b.Le(b)}return false};_.gc=function Tlb(){return this.b.gc()};sfb(Bve,'AbstractNavigableMap/EntrySet',629);feb(1146,Eve,Ive,Ulb);_.Nc=function $lb(){return new $wb(this)};_.$b=function Vlb(){this.a.$b();};_.Hc=function Wlb(a){return Clb(this.a,a)};_.Kc=function Xlb(){var a;a=this.a.vc().b.De();return new _lb(a)};_.Mc=function Ylb(a){if(Clb(this.a,a)){this.a.Bc(a);return true}return false};_.gc=function Zlb(){return this.a.gc()};sfb(Bve,'AbstractNavigableMap/NavigableKeySet',1146);feb(1147,1,Ave,_lb);_.Nb=function amb(a){Ztb(this,a);};_.Ob=function bmb(){return Akb(this.a.a)};_.Pb=function cmb(){var a;a=vzb(this.a);return a.ld()};_.Qb=function dmb(){wzb(this.a);};sfb(Bve,'AbstractNavigableMap/NavigableKeySet/1',1147);feb(2103,31,Dve);_.Fc=function emb(a){return zFb(lwb(this,a),Bxe),true};_.Gc=function fmb(a){uFb(a);mFb(a!=this,"Can't add a queue to itself");return ye(this,a)};_.$b=function gmb(){while(mwb(this)!=null);};sfb(Bve,'AbstractQueue',2103);feb(310,31,{4:1,20:1,31:1,16:1},wmb,xmb);_.Fc=function ymb(a){return imb(this,a),true};_.$b=function Amb(){jmb(this);};_.Hc=function Bmb(a){return kmb(new Kmb(this),a)};_.dc=function Cmb(){return nmb(this)};_.Kc=function Dmb(){return new Kmb(this)};_.Mc=function Emb(a){return qmb(new Kmb(this),a)};_.gc=function Fmb(){return this.c-this.b&this.a.length-1};_.Nc=function Gmb(){return new Swb(this,272)};_.Qc=function Hmb(a){var b;b=this.c-this.b&this.a.length-1;a.lengthb&&bD(a,b,null);return a};_.b=0;_.c=0;sfb(Bve,'ArrayDeque',310);feb(459,1,Ave,Kmb);_.Nb=function Lmb(a){Ztb(this,a);};_.Ob=function Mmb(){return this.a!=this.b};_.Pb=function Nmb(){return Imb(this)};_.Qb=function Omb(){Jmb(this);};_.a=0;_.b=0;_.c=-1;sfb(Bve,'ArrayDeque/IteratorImpl',459);feb(13,56,Cxe,bnb,cnb,dnb);_.bd=function enb(a,b){Qmb(this,a,b);};_.Fc=function fnb(a){return Rmb(this,a)};_.cd=function gnb(a,b){return Smb(this,a,b)};_.Gc=function hnb(a){return Tmb(this,a)};_.$b=function inb(){aFb(this.c,0);};_.Hc=function jnb(a){return Wmb(this,a,0)!=-1};_.Jc=function knb(a){Umb(this,a);};_.Xb=function lnb(a){return Vmb(this,a)};_.dd=function mnb(a){return Wmb(this,a,0)};_.dc=function nnb(){return this.c.length==0};_.Kc=function onb(){return new Anb(this)};_.gd=function pnb(a){return Xmb(this,a)};_.Mc=function qnb(a){return Ymb(this,a)};_.ce=function rnb(a,b){Zmb(this,a,b);};_.hd=function snb(a,b){return $mb(this,a,b)};_.gc=function tnb(){return this.c.length};_.jd=function unb(a){_mb(this,a);};_.Pc=function vnb(){return UEb(this.c)};_.Qc=function wnb(a){return anb(this,a)};var VJ=sfb(Bve,'ArrayList',13);feb(7,1,Ave,Anb);_.Nb=function Bnb(a){Ztb(this,a);};_.Ob=function Cnb(){return xnb(this)};_.Pb=function Dnb(){return ynb(this)};_.Qb=function Enb(){znb(this);};_.a=0;_.b=-1;sfb(Bve,'ArrayList/1',7);feb(2112,$wnd.Function,{},iob);_.Me=function job(a,b){return Qfb(a,b)};feb(151,56,Dxe,mob);_.Hc=function nob(a){return St(this,a)!=-1};_.Jc=function oob(a){var b,c,d,e;uFb(a);for(c=this.a,d=0,e=c.length;d0){throw Adb(new agb(Sxe+a+' greater than '+this.e))}return this.f.Te()?bzb(this.c,this.b,this.a,a,b):Ryb(this.c,a,b)};_.zc=function Vzb(a,b){if(!Tyb(this.c,this.f,a,this.b,this.a,this.e,this.d)){throw Adb(new agb(a+' outside the range '+this.b+' to '+this.e))}return Wyb(this.c,a,b)};_.Bc=function Wzb(a){var b;b=a;if(!Tyb(this.c,this.f,b,this.b,this.a,this.e,this.d)){return null}return Xyb(this.c,b)};_.Le=function Xzb(a){return Jzb(this,a.ld())&&Yyb(this.c,a)};_.gc=function Yzb(){var a,b,c;this.f.Te()?this.a?(b=Pyb(this.c,this.b,true)):(b=Pyb(this.c,this.b,false)):(b=Nyb(this.c));if(!(!!b&&Jzb(this,b.d)?b:null)){return 0}a=0;for(c=new yzb(this.c,this.f,this.b,this.a,this.e,this.d);Akb(c.a);c.b=RD(Bkb(c.a),44)){++a;}return a};_.ad=function Zzb(a,b){if(this.f.Te()&&this.c.a.Ne(a,this.b)<0){throw Adb(new agb(Sxe+a+Txe+this.b))}return this.f.Ue()?bzb(this.c,a,b,this.e,this.d):czb(this.c,a,b)};_.a=false;_.d=false;sfb(Bve,'TreeMap/SubMap',631);feb(304,22,Uxe,dAb);_.Te=function eAb(){return false};_.Ue=function fAb(){return false};var $zb,_zb,aAb,bAb;var AL=tfb(Bve,'TreeMap/SubMapType',304,WI,hAb,gAb);feb(1143,304,Uxe,iAb);_.Ue=function jAb(){return true};tfb(Bve,'TreeMap/SubMapType/1',1143,AL,null,null);feb(1144,304,Uxe,kAb);_.Te=function lAb(){return true};_.Ue=function mAb(){return true};tfb(Bve,'TreeMap/SubMapType/2',1144,AL,null,null);feb(1145,304,Uxe,nAb);_.Te=function oAb(){return true};tfb(Bve,'TreeMap/SubMapType/3',1145,AL,null,null);var pAb;feb(157,Eve,{3:1,20:1,31:1,16:1,277:1,21:1,87:1,157:1},xAb,yAb,zAb);_.Nc=function GAb(){return new $wb(this)};_.Fc=function AAb(a){return rAb(this,a)};_.$b=function BAb(){this.a.$b();};_.Hc=function CAb(a){return this.a._b(a)};_.Kc=function DAb(){return this.a.ec().Kc()};_.Mc=function EAb(a){return wAb(this,a)};_.gc=function FAb(){return this.a.gc()};var DL=sfb(Bve,'TreeSet',157);feb(1082,1,{},JAb);_.Ve=function KAb(a,b){return HAb(this.a,a,b)};sfb(Vxe,'BinaryOperator/lambda$0$Type',1082);feb(1083,1,{},LAb);_.Ve=function MAb(a,b){return IAb(this.a,a,b)};sfb(Vxe,'BinaryOperator/lambda$1$Type',1083);feb(952,1,{},NAb);_.Kb=function OAb(a){return a};sfb(Vxe,'Function/lambda$0$Type',952);feb(395,1,nwe,PAb);_.Mb=function QAb(a){return !this.a.Mb(a)};sfb(Vxe,'Predicate/lambda$2$Type',395);feb(581,1,{581:1});var JL=sfb(Wxe,'Handler',581);feb(2107,1,nve);_.xe=function TAb(){return 'DUMMY'};_.Ib=function UAb(){return this.xe()};var RAb;sfb(Wxe,'Level',2107);feb(1706,2107,nve,VAb);_.xe=function WAb(){return 'INFO'};sfb(Wxe,'Level/LevelInfo',1706);feb(1843,1,{},$Ab);var XAb;sfb(Wxe,'LogManager',1843);feb(1896,1,nve,aBb);_.b=null;sfb(Wxe,'LogRecord',1896);feb(525,1,{525:1},oBb);_.e=false;var bBb=false,cBb=false,dBb=false,eBb=false,fBb=false;sfb(Wxe,'Logger',525);feb(835,581,{581:1},rBb);sfb(Wxe,'SimpleConsoleLogHandler',835);feb(108,22,{3:1,34:1,22:1,108:1},yBb);var uBb,vBb,wBb;var QL=tfb(Zxe,'Collector/Characteristics',108,WI,ABb,zBb);var BBb;feb(758,1,{},DBb);sfb(Zxe,'CollectorImpl',758);feb(1074,1,{},RBb);_.Ve=function SBb(a,b){return Hyb(RD(a,213),RD(b,213))};sfb(Zxe,'Collectors/10methodref$merge$Type',1074);feb(1075,1,{},TBb);_.Kb=function UBb(a){return Iyb(RD(a,213))};sfb(Zxe,'Collectors/11methodref$toString$Type',1075);feb(1076,1,{},VBb);_.Kb=function WBb(a){return Geb(),SSb(a)?true:false};sfb(Zxe,'Collectors/12methodref$test$Type',1076);feb(144,1,{},XBb);_.Yd=function YBb(a,b){RD(a,16).Fc(b);};sfb(Zxe,'Collectors/20methodref$add$Type',144);feb(146,1,{},ZBb);_.Xe=function $Bb(){return new bnb};sfb(Zxe,'Collectors/21methodref$ctor$Type',146);feb(359,1,{},_Bb);_.Xe=function aCb(){return new _sb};sfb(Zxe,'Collectors/23methodref$ctor$Type',359);feb(360,1,{},bCb);_.Yd=function cCb(a,b){Ysb(RD(a,49),b);};sfb(Zxe,'Collectors/24methodref$add$Type',360);feb(1069,1,{},dCb);_.Ve=function eCb(a,b){return EBb(RD(a,15),RD(b,16))};sfb(Zxe,'Collectors/4methodref$addAll$Type',1069);feb(1073,1,{},fCb);_.Yd=function gCb(a,b){Gyb(RD(a,213),RD(b,484));};sfb(Zxe,'Collectors/9methodref$add$Type',1073);feb(1072,1,{},hCb);_.Xe=function iCb(){return new Jyb(this.a,this.b,this.c)};sfb(Zxe,'Collectors/lambda$15$Type',1072);feb(1077,1,{},jCb);_.Xe=function kCb(){var a;return a=new gub,dub(a,(Geb(),false),new bnb),dub(a,true,new bnb),a};sfb(Zxe,'Collectors/lambda$22$Type',1077);feb(1078,1,{},lCb);_.Xe=function mCb(){return cD(WC(jJ,1),rve,1,5,[this.a])};sfb(Zxe,'Collectors/lambda$25$Type',1078);feb(1079,1,{},nCb);_.Yd=function oCb(a,b){GBb(this.a,SD(a));};sfb(Zxe,'Collectors/lambda$26$Type',1079);feb(1080,1,{},pCb);_.Ve=function qCb(a,b){return HBb(this.a,SD(a),SD(b))};sfb(Zxe,'Collectors/lambda$27$Type',1080);feb(1081,1,{},rCb);_.Kb=function sCb(a){return SD(a)[0]};sfb(Zxe,'Collectors/lambda$28$Type',1081);feb(728,1,{},uCb);_.Ve=function vCb(a,b){return tCb(a,b)};sfb(Zxe,'Collectors/lambda$4$Type',728);feb(145,1,{},wCb);_.Ve=function xCb(a,b){return JBb(RD(a,16),RD(b,16))};sfb(Zxe,'Collectors/lambda$42$Type',145);feb(361,1,{},yCb);_.Ve=function zCb(a,b){return KBb(RD(a,49),RD(b,49))};sfb(Zxe,'Collectors/lambda$50$Type',361);feb(362,1,{},ACb);_.Kb=function BCb(a){return RD(a,49)};sfb(Zxe,'Collectors/lambda$51$Type',362);feb(1068,1,{},CCb);_.Yd=function DCb(a,b){LBb(this.a,RD(a,85),b);};sfb(Zxe,'Collectors/lambda$7$Type',1068);feb(1070,1,{},ECb);_.Ve=function FCb(a,b){return NBb(RD(a,85),RD(b,85),new dCb)};sfb(Zxe,'Collectors/lambda$8$Type',1070);feb(1071,1,{},GCb);_.Kb=function HCb(a){return MBb(this.a,RD(a,85))};sfb(Zxe,'Collectors/lambda$9$Type',1071);feb(550,1,{});_.$e=function OCb(){ICb(this);};_.d=false;sfb(Zxe,'TerminatableStream',550);feb(827,550,$xe,WCb);_.$e=function XCb(){ICb(this);};sfb(Zxe,'DoubleStreamImpl',827);feb(1847,736,Pve,$Cb);_.Re=function aDb(a){return ZCb(this,RD(a,189))};_.a=null;sfb(Zxe,'DoubleStreamImpl/2',1847);feb(1848,1,Gxe,bDb);_.Pe=function cDb(a){_Cb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/2/lambda$0$Type',1848);feb(1845,1,Gxe,dDb);_.Pe=function eDb(a){YCb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/lambda$0$Type',1845);feb(1846,1,Gxe,fDb);_.Pe=function gDb(a){Nrb(this.a,a);};sfb(Zxe,'DoubleStreamImpl/lambda$2$Type',1846);feb(1397,735,Pve,kDb);_.Re=function lDb(a){return jDb(this,RD(a,202))};_.a=0;_.b=0;_.c=0;sfb(Zxe,'IntStream/5',1397);feb(806,550,$xe,oDb);_.$e=function pDb(){ICb(this);};_._e=function qDb(){return LCb(this),this.a};sfb(Zxe,'IntStreamImpl',806);feb(807,550,$xe,rDb);_.$e=function sDb(){ICb(this);};_._e=function tDb(){return LCb(this),Txb(),Sxb};sfb(Zxe,'IntStreamImpl/Empty',807);feb(1687,1,Rve,uDb);_.Dd=function vDb(a){ktb(this.a,a);};sfb(Zxe,'IntStreamImpl/lambda$4$Type',1687);var RM=ufb(Zxe,'Stream');feb(26,550,{533:1,687:1,848:1},SDb);_.$e=function TDb(){ICb(this);};var wDb;sfb(Zxe,'StreamImpl',26);feb(1102,500,Pve,YDb);_.Bd=function ZDb(a){while(WDb(this)){if(this.a.Bd(a)){return true}else {ICb(this.b);this.b=null;this.a=null;}}return false};sfb(Zxe,'StreamImpl/1',1102);feb(1103,1,Qve,$Db);_.Cd=function _Db(a){XDb(this.a,RD(a,848));};sfb(Zxe,'StreamImpl/1/lambda$0$Type',1103);feb(1104,1,nwe,aEb);_.Mb=function bEb(a){return Ysb(this.a,a)};sfb(Zxe,'StreamImpl/1methodref$add$Type',1104);feb(1105,500,Pve,cEb);_.Bd=function dEb(a){var b;if(!this.a){b=new bnb;this.b.a.Nb(new eEb(b));yob();_mb(b,this.c);this.a=new Swb(b,16);}return Rwb(this.a,a)};_.a=null;sfb(Zxe,'StreamImpl/5',1105);feb(1106,1,Qve,eEb);_.Cd=function fEb(a){Rmb(this.a,a);};sfb(Zxe,'StreamImpl/5/2methodref$add$Type',1106);feb(737,500,Pve,hEb);_.Bd=function iEb(a){this.b=false;while(!this.b&&this.c.Bd(new jEb(this,a)));return this.b};_.b=false;sfb(Zxe,'StreamImpl/FilterSpliterator',737);feb(1096,1,Qve,jEb);_.Cd=function kEb(a){gEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/FilterSpliterator/lambda$0$Type',1096);feb(1091,736,Pve,nEb);_.Re=function oEb(a){return mEb(this,RD(a,189))};sfb(Zxe,'StreamImpl/MapToDoubleSpliterator',1091);feb(1095,1,Qve,pEb);_.Cd=function qEb(a){lEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToDoubleSpliterator/lambda$0$Type',1095);feb(1090,735,Pve,tEb);_.Re=function uEb(a){return sEb(this,RD(a,202))};sfb(Zxe,'StreamImpl/MapToIntSpliterator',1090);feb(1094,1,Qve,vEb);_.Cd=function wEb(a){rEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToIntSpliterator/lambda$0$Type',1094);feb(734,500,Pve,zEb);_.Bd=function AEb(a){return yEb(this,a)};sfb(Zxe,'StreamImpl/MapToObjSpliterator',734);feb(1093,1,Qve,BEb);_.Cd=function CEb(a){xEb(this.a,this.b,a);};sfb(Zxe,'StreamImpl/MapToObjSpliterator/lambda$0$Type',1093);feb(1092,500,Pve,DEb);_.Bd=function EEb(a){while(Idb(this.b,0)){if(!this.a.Bd(new FEb)){return false}this.b=Vdb(this.b,1);}return this.a.Bd(a)};_.b=0;sfb(Zxe,'StreamImpl/SkipSpliterator',1092);feb(1097,1,Qve,FEb);_.Cd=function GEb(a){};sfb(Zxe,'StreamImpl/SkipSpliterator/lambda$0$Type',1097);feb(626,1,Qve,IEb);_.Cd=function JEb(a){HEb(this,a);};sfb(Zxe,'StreamImpl/ValueConsumer',626);feb(1098,1,Qve,KEb);_.Cd=function LEb(a){xDb();};sfb(Zxe,'StreamImpl/lambda$0$Type',1098);feb(1099,1,Qve,MEb);_.Cd=function NEb(a){xDb();};sfb(Zxe,'StreamImpl/lambda$1$Type',1099);feb(1100,1,{},OEb);_.Ve=function PEb(a,b){return UDb(this.a,a,b)};sfb(Zxe,'StreamImpl/lambda$4$Type',1100);feb(1101,1,Qve,QEb);_.Cd=function REb(a){VDb(this.b,this.a,a);};sfb(Zxe,'StreamImpl/lambda$5$Type',1101);feb(1107,1,Qve,SEb);_.Cd=function TEb(a){PCb(this.a,RD(a,380));};sfb(Zxe,'TerminatableStream/lambda$0$Type',1107);feb(2142,1,{});feb(2014,1,{},gFb);sfb('javaemul.internal','ConsoleLogger',2014);var iFb=0;feb(2134,1,{});feb(1830,1,Qve,FFb);_.Cd=function GFb(a){RD(a,317);};sfb(eye,'BowyerWatsonTriangulation/lambda$0$Type',1830);feb(1831,1,Qve,HFb);_.Cd=function IFb(a){ye(this.a,RD(a,317).e);};sfb(eye,'BowyerWatsonTriangulation/lambda$1$Type',1831);feb(1832,1,Qve,JFb);_.Cd=function KFb(a){RD(a,177);};sfb(eye,'BowyerWatsonTriangulation/lambda$2$Type',1832);feb(1827,1,fye,NFb);_.Ne=function OFb(a,b){return MFb(this.a,RD(a,177),RD(b,177))};_.Fb=function PFb(a){return this===a};_.Oe=function QFb(){return new Frb(this)};sfb(eye,'NaiveMinST/lambda$0$Type',1827);feb(449,1,{},SFb);sfb(eye,'NodeMicroLayout',449);feb(177,1,{177:1},TFb);_.Fb=function UFb(a){var b;if(ZD(a,177)){b=RD(a,177);return Fvb(this.a,b.a)&&Fvb(this.b,b.b)||Fvb(this.a,b.b)&&Fvb(this.b,b.a)}else {return false}};_.Hb=function VFb(){return Gvb(this.a)+Gvb(this.b)};var $M=sfb(eye,'TEdge',177);feb(317,1,{317:1},XFb);_.Fb=function YFb(a){var b;if(ZD(a,317)){b=RD(a,317);return WFb(this,b.a)&&WFb(this,b.b)&&WFb(this,b.c)}else {return false}};_.Hb=function ZFb(){return Gvb(this.a)+Gvb(this.b)+Gvb(this.c)};sfb(eye,'TTriangle',317);feb(225,1,{225:1},$Fb);sfb(eye,'Tree',225);feb(1218,1,{},aGb);sfb(gye,'Scanline',1218);var bN=ufb(gye,hye);feb(1758,1,{},dGb);sfb(iye,'CGraph',1758);feb(316,1,{316:1},fGb);_.b=0;_.c=0;_.d=0;_.g=0;_.i=0;_.k=pxe;sfb(iye,'CGroup',316);feb(830,1,{},jGb);sfb(iye,'CGroup/CGroupBuilder',830);feb(60,1,{60:1},kGb);_.Ib=function lGb(){var a;if(this.j){return WD(this.j.Kb(this))}return lfb(hN),hN.o+'@'+(a=kFb(this)>>>0,a.toString(16))};_.f=0;_.i=pxe;var hN=sfb(iye,'CNode',60);feb(829,1,{},qGb);sfb(iye,'CNode/CNodeBuilder',829);var vGb;feb(1590,1,{},xGb);_.ff=function yGb(a,b){return 0};_.gf=function zGb(a,b){return 0};sfb(iye,kye,1590);feb(1853,1,{},AGb);_.cf=function BGb(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;j=oxe;for(d=new Anb(a.a.b);d.ad.d.c||d.d.c==f.d.c&&d.d.b0?a+this.n.d+this.n.a:0};_.kf=function yKb(){var a,b,c,d,e;e=0;if(this.e){this.b?(e=this.b.a):!!this.a[1][1]&&(e=this.a[1][1].kf());}else if(this.g){e=vKb(this,pKb(this,null,true));}else {for(b=(ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])),c=0,d=b.length;c0?e+this.n.b+this.n.c:0};_.lf=function zKb(){var a,b,c,d,e;if(this.g){a=pKb(this,null,false);for(c=(ZJb(),cD(WC(JN,1),jwe,237,0,[WJb,XJb,YJb])),d=0,e=c.length;d0){d[0]+=this.d;c-=d[0];}if(d[2]>0){d[2]+=this.d;c-=d[2];}this.c.a=$wnd.Math.max(0,c);this.c.d=b.d+a.d+(this.c.a-c)/2;d[1]=$wnd.Math.max(d[1],c);lKb(this,XJb,b.d+a.d+d[0]-(d[1]-c)/2,d);};_.b=null;_.d=0;_.e=false;_.f=false;_.g=false;var iKb=0,jKb=0;sfb(Jye,'GridContainerCell',1538);feb(471,22,{3:1,34:1,22:1,471:1},FKb);var BKb,CKb,DKb;var MN=tfb(Jye,'HorizontalLabelAlignment',471,WI,HKb,GKb);var IKb;feb(314,217,{217:1,314:1},TKb,UKb,VKb);_.jf=function WKb(){return PKb(this)};_.kf=function XKb(){return QKb(this)};_.a=0;_.c=false;var NN=sfb(Jye,'LabelCell',314);feb(252,336,{217:1,336:1,252:1},dLb);_.jf=function eLb(){return YKb(this)};_.kf=function fLb(){return ZKb(this)};_.lf=function iLb(){$Kb(this);};_.mf=function jLb(){_Kb(this);};_.b=0;_.c=0;_.d=false;sfb(Jye,'StripContainerCell',252);feb(1691,1,nwe,kLb);_.Mb=function lLb(a){return gLb(RD(a,217))};sfb(Jye,'StripContainerCell/lambda$0$Type',1691);feb(1692,1,{},mLb);_.Ye=function nLb(a){return RD(a,217).kf()};sfb(Jye,'StripContainerCell/lambda$1$Type',1692);feb(1693,1,nwe,oLb);_.Mb=function pLb(a){return hLb(RD(a,217))};sfb(Jye,'StripContainerCell/lambda$2$Type',1693);feb(1694,1,{},qLb);_.Ye=function rLb(a){return RD(a,217).jf()};sfb(Jye,'StripContainerCell/lambda$3$Type',1694);feb(472,22,{3:1,34:1,22:1,472:1},wLb);var sLb,tLb,uLb;var TN=tfb(Jye,'VerticalLabelAlignment',472,WI,yLb,xLb);var zLb;feb(800,1,{},CLb);_.c=0;_.d=0;_.k=0;_.s=0;_.t=0;_.v=false;_.w=0;_.D=false;_.F=false;sfb(Rye,'NodeContext',800);feb(1536,1,fye,FLb);_.Ne=function GLb(a,b){return ELb(RD(a,64),RD(b,64))};_.Fb=function HLb(a){return this===a};_.Oe=function ILb(){return new Frb(this)};sfb(Rye,'NodeContext/0methodref$comparePortSides$Type',1536);feb(1537,1,fye,JLb);_.Ne=function KLb(a,b){return DLb(RD(a,117),RD(b,117))};_.Fb=function LLb(a){return this===a};_.Oe=function MLb(){return new Frb(this)};sfb(Rye,'NodeContext/1methodref$comparePortContexts$Type',1537);feb(164,22,{3:1,34:1,22:1,164:1},kMb);var NLb,OLb,PLb,QLb,RLb,SLb,TLb,ULb,VLb,WLb,XLb,YLb,ZLb,$Lb,_Lb,aMb,bMb,cMb,dMb,eMb,fMb,gMb;var XN=tfb(Rye,'NodeLabelLocation',164,WI,nMb,mMb);var oMb;feb(117,1,{117:1},rMb);_.a=false;sfb(Rye,'PortContext',117);feb(1541,1,Qve,KMb);_.Cd=function LMb(a){NKb(RD(a,314));};sfb(Uye,Vye,1541);feb(1542,1,nwe,MMb);_.Mb=function NMb(a){return !!RD(a,117).c};sfb(Uye,Wye,1542);feb(1543,1,Qve,OMb);_.Cd=function PMb(a){NKb(RD(a,117).c);};sfb(Uye,'LabelPlacer/lambda$2$Type',1543);var QMb;feb(1540,1,Qve,YMb);_.Cd=function ZMb(a){RMb();qMb(RD(a,117));};sfb(Uye,'NodeLabelAndSizeUtilities/lambda$0$Type',1540);feb(801,1,Qve,dNb);_.Cd=function eNb(a){bNb(this.b,this.c,this.a,RD(a,187));};_.a=false;_.c=false;sfb(Uye,'NodeLabelCellCreator/lambda$0$Type',801);feb(1539,1,Qve,kNb);_.Cd=function lNb(a){jNb(this.a,RD(a,187));};sfb(Uye,'PortContextCreator/lambda$0$Type',1539);var sNb;feb(1902,1,{},MNb);sfb(Yye,'GreedyRectangleStripOverlapRemover',1902);feb(1903,1,fye,ONb);_.Ne=function PNb(a,b){return NNb(RD(a,226),RD(b,226))};_.Fb=function QNb(a){return this===a};_.Oe=function RNb(){return new Frb(this)};sfb(Yye,'GreedyRectangleStripOverlapRemover/0methodref$compareByYCoordinate$Type',1903);feb(1849,1,{},YNb);_.a=5;_.e=0;sfb(Yye,'RectangleStripOverlapRemover',1849);feb(1850,1,fye,aOb);_.Ne=function bOb(a,b){return ZNb(RD(a,226),RD(b,226))};_.Fb=function cOb(a){return this===a};_.Oe=function dOb(){return new Frb(this)};sfb(Yye,'RectangleStripOverlapRemover/0methodref$compareLeftRectangleBorders$Type',1850);feb(1852,1,fye,eOb);_.Ne=function fOb(a,b){return $Nb(RD(a,226),RD(b,226))};_.Fb=function gOb(a){return this===a};_.Oe=function hOb(){return new Frb(this)};sfb(Yye,'RectangleStripOverlapRemover/1methodref$compareRightRectangleBorders$Type',1852);feb(417,22,{3:1,34:1,22:1,417:1},nOb);var iOb,jOb,kOb,lOb;var hO=tfb(Yye,'RectangleStripOverlapRemover/OverlapRemovalDirection',417,WI,pOb,oOb);var qOb;feb(226,1,{226:1},sOb);sfb(Yye,'RectangleStripOverlapRemover/RectangleNode',226);feb(1851,1,Qve,tOb);_.Cd=function uOb(a){TNb(this.a,RD(a,226));};sfb(Yye,'RectangleStripOverlapRemover/lambda$1$Type',1851);feb(1323,1,fye,xOb);_.Ne=function yOb(a,b){return wOb(RD(a,176),RD(b,176))};_.Fb=function zOb(a){return this===a};_.Oe=function AOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator',1323);feb(1326,1,{},BOb);_.Kb=function COb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$0$Type',1326);feb(1327,1,nwe,DOb);_.Mb=function EOb(a){return RD(a,332).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$1$Type',1327);feb(1328,1,nwe,FOb);_.Mb=function GOb(a){return RD(a,332).a};sfb($ye,'PolyominoCompactor/CornerCasesGreaterThanRestComparator/lambda$2$Type',1328);feb(1321,1,fye,IOb);_.Ne=function JOb(a,b){return HOb(RD(a,176),RD(b,176))};_.Fb=function KOb(a){return this===a};_.Oe=function LOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinNumOfExtensionDirectionsComparator',1321);feb(1324,1,{},MOb);_.Kb=function NOb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/MinNumOfExtensionDirectionsComparator/lambda$0$Type',1324);feb(781,1,fye,POb);_.Ne=function QOb(a,b){return OOb(RD(a,176),RD(b,176))};_.Fb=function ROb(a){return this===a};_.Oe=function SOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinNumOfExtensionsComparator',781);feb(1319,1,fye,UOb);_.Ne=function VOb(a,b){return TOb(RD(a,330),RD(b,330))};_.Fb=function WOb(a){return this===a};_.Oe=function XOb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinPerimeterComparator',1319);feb(1320,1,fye,ZOb);_.Ne=function $Ob(a,b){return YOb(RD(a,330),RD(b,330))};_.Fb=function _Ob(a){return this===a};_.Oe=function aPb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/MinPerimeterComparatorWithShape',1320);feb(1322,1,fye,cPb);_.Ne=function dPb(a,b){return bPb(RD(a,176),RD(b,176))};_.Fb=function ePb(a){return this===a};_.Oe=function fPb(){return new Frb(this)};sfb($ye,'PolyominoCompactor/SingleExtensionSideGreaterThanRestComparator',1322);feb(1325,1,{},gPb);_.Kb=function hPb(a){return RD(a,334).a};sfb($ye,'PolyominoCompactor/SingleExtensionSideGreaterThanRestComparator/lambda$0$Type',1325);feb(782,1,{},kPb);_.Ve=function lPb(a,b){return jPb(this,RD(a,42),RD(b,176))};sfb($ye,'SuccessorCombination',782);feb(649,1,{},nPb);_.Ve=function oPb(a,b){var c;return mPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorJitter',649);feb(648,1,{},qPb);_.Ve=function rPb(a,b){var c;return pPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorLineByLine',648);feb(573,1,{},tPb);_.Ve=function uPb(a,b){var c;return sPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorManhattan',573);feb(1344,1,{},wPb);_.Ve=function xPb(a,b){var c;return vPb((c=RD(a,42),RD(b,176),c))};sfb($ye,'SuccessorMaxNormWindingInMathPosSense',1344);feb(409,1,{},APb);_.Ve=function BPb(a,b){return yPb(this,a,b)};_.c=false;_.d=false;_.e=false;_.f=false;sfb($ye,'SuccessorQuadrantsGeneric',409);feb(1345,1,{},CPb);_.Kb=function DPb(a){return RD(a,334).a};sfb($ye,'SuccessorQuadrantsGeneric/lambda$0$Type',1345);feb(332,22,{3:1,34:1,22:1,332:1},JPb);_.a=false;var EPb,FPb,GPb,HPb;var DO=tfb(dze,eze,332,WI,LPb,KPb);var MPb;feb(1317,1,{});_.Ib=function UPb(){var a,b,c,d,e,f;c=' ';a=sgb(0);for(e=0;e=0?'b'+a+'['+bUb(this.a)+']':'b['+bUb(this.a)+']'}return 'b_'+kFb(this)};sfb(Oze,'FBendpoint',250);feb(290,137,{3:1,290:1,96:1,137:1},cUb);_.Ib=function dUb(){return bUb(this)};sfb(Oze,'FEdge',290);feb(235,137,{3:1,235:1,96:1,137:1},gUb);var tP=sfb(Oze,'FGraph',235);feb(454,309,{3:1,454:1,309:1,96:1,137:1},iUb);_.Ib=function jUb(){return this.b==null||this.b.length==0?'l['+bUb(this.a)+']':'l_'+this.b};sfb(Oze,'FLabel',454);feb(153,309,{3:1,153:1,309:1,96:1,137:1},lUb);_.Ib=function mUb(){return kUb(this)};_.a=0;sfb(Oze,'FNode',153);feb(2100,1,{});_.vf=function rUb(a){nUb(this,a);};_.wf=function sUb(){oUb(this);};_.d=0;sfb(Qze,'AbstractForceModel',2100);feb(641,2100,{641:1},tUb);_.uf=function vUb(a,b){var c,d,e,f,g;qUb(this.f,a,b);e=ojd(ajd(b.d),a.d);g=$wnd.Math.sqrt(e.a*e.a+e.b*e.b);d=$wnd.Math.max(0,g-ejd(a.e)/2-ejd(b.e)/2);c=fUb(this.e,a,b);c>0?(f=-uUb(d,this.c)*c):(f=yUb(d,this.b)*RD(mQb(a,(yVb(),lVb)),17).a);ijd(e,f/g);return e};_.vf=function wUb(a){nUb(this,a);this.a=RD(mQb(a,(yVb(),aVb)),17).a;this.c=Kfb(UD(mQb(a,rVb)));this.b=Kfb(UD(mQb(a,nVb)));};_.xf=function xUb(a){return a0&&(f-=AUb(d,this.a)*c);ijd(e,f*this.b/g);return e};_.vf=function CUb(a){var b,c,d,e,f,g,h;nUb(this,a);this.b=Kfb(UD(mQb(a,(yVb(),sVb))));this.c=this.b/RD(mQb(a,aVb),17).a;d=a.e.c.length;f=0;e=0;for(h=new Anb(a.e);h.a0};_.a=0;_.b=0;_.c=0;sfb(Qze,'FruchtermanReingoldModel',642);feb(860,1,Eye,PUb);_.hf=function QUb(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Rze),''),'Force Model'),'Determines the model for force calculation.'),IUb),(kid(),eid)),BP),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Sze),''),'Iterations'),'The number of iterations on the force model.'),sgb(300)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Tze),''),'Repulsive Power'),'Determines how many bend points are added to the edge; such bend points are regarded as repelling particles in the force model'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Uze),''),'FR Temperature'),'The temperature is used as a scaling factor for particle displacements.'),Vze),did),VI),xsb(Whd))));zgd(a,Uze,Rze,NUb);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Wze),''),'Eades Repulsion'),"Factor for repulsive forces in Eades' model."),5),did),VI),xsb(Whd))));zgd(a,Wze,Rze,KUb);zVb((new AVb,a));};var GUb,HUb,IUb,JUb,KUb,LUb,MUb,NUb;sfb(Xze,'ForceMetaDataProvider',860);feb(432,22,{3:1,34:1,22:1,432:1},UUb);var RUb,SUb;var BP=tfb(Xze,'ForceModelStrategy',432,WI,WUb,VUb);var XUb;feb(Awe,1,Eye,AVb);_.hf=function BVb(a){zVb(a);};var ZUb,$Ub,_Ub,aVb,bVb,cVb,dVb,eVb,fVb,gVb,hVb,iVb,jVb,kVb,lVb,mVb,nVb,oVb,pVb,qVb,rVb,sVb,tVb,uVb,vVb,wVb,xVb;sfb(Xze,'ForceOptions',Awe);feb(1001,1,{},CVb);_.sf=function DVb(){var a;return a=new TTb,a};_.tf=function EVb(a){};sfb(Xze,'ForceOptions/ForceFactory',1001);var FVb,GVb,HVb,IVb;feb(861,1,Eye,RVb);_.hf=function SVb(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,vAe),''),'Fixed Position'),'Prevent that the node is moved by the layout algorithm.'),(Geb(),false)),(kid(),cid)),QI),xsb((Yhd(),Vhd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,wAe),''),'Desired Edge Length'),'Either specified for parent nodes or for individual edges, where the latter takes higher precedence.'),100),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Thd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xAe),''),'Layout Dimension'),'Dimensions that are permitted to be altered during layout.'),MVb),eid),JP),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yAe),''),'Stress Epsilon'),'Termination criterion for the iterative process.'),Vze),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zAe),''),'Iteration Limit'),"Maximum number of performed iterations. Takes higher precedence than 'epsilon'."),sgb(lve)),gid),bJ),xsb(Whd))));eWb((new fWb,a));};var KVb,LVb,MVb,NVb,OVb,PVb;sfb(Xze,'StressMetaDataProvider',861);feb(1004,1,Eye,fWb);_.hf=function gWb(a){eWb(a);};var TVb,UVb,VVb,WVb,XVb,YVb,ZVb,$Vb,_Vb,aWb,bWb,cWb;sfb(Xze,'StressOptions',1004);feb(1005,1,{},hWb);_.sf=function iWb(){var a;return a=new kWb,a};_.tf=function jWb(a){};sfb(Xze,'StressOptions/StressFactory',1005);feb(1110,205,oze,kWb);_.rf=function lWb(a,b){var c,d,e,f,g;b.Ug(BAe,1);Heb(TD(Gxd(a,(dWb(),XVb))))?Heb(TD(Gxd(a,bWb)))||RFb((c=new SFb((lud(),new zud(a))),c)):QTb(new TTb,a,b.eh(1));e=KTb(a);d=CTb(this.a,e);for(g=d.Kc();g.Ob();){f=RD(g.Pb(),235);if(f.e.c.length<=1){continue}uWb(this.b,f);sWb(this.b);Umb(f.d,new mWb);}e=BTb(d);JTb(e);b.Vg();};sfb(DAe,'StressLayoutProvider',1110);feb(1111,1,Qve,mWb);_.Cd=function nWb(a){hUb(RD(a,454));};sfb(DAe,'StressLayoutProvider/lambda$0$Type',1111);feb(1002,1,{},vWb);_.c=0;_.e=0;_.g=0;sfb(DAe,'StressMajorization',1002);feb(391,22,{3:1,34:1,22:1,391:1},BWb);var xWb,yWb,zWb;var JP=tfb(DAe,'StressMajorization/Dimension',391,WI,DWb,CWb);var EWb;feb(1003,1,fye,GWb);_.Ne=function HWb(a,b){return wWb(this.a,RD(a,153),RD(b,153))};_.Fb=function IWb(a){return this===a};_.Oe=function JWb(){return new Frb(this)};sfb(DAe,'StressMajorization/lambda$0$Type',1003);feb(1192,1,{},RWb);sfb(FAe,'ElkLayered',1192);feb(1193,1,Qve,UWb);_.Cd=function VWb(a){SWb(this.a,RD(a,36));};sfb(FAe,'ElkLayered/lambda$0$Type',1193);feb(1194,1,Qve,WWb);_.Cd=function XWb(a){TWb(this.a,RD(a,36));};sfb(FAe,'ElkLayered/lambda$1$Type',1194);feb(1281,1,{},dXb);var YWb,ZWb,$Wb;sfb(FAe,'GraphConfigurator',1281);feb(770,1,Qve,fXb);_.Cd=function gXb(a){aXb(this.a,RD(a,10));};sfb(FAe,'GraphConfigurator/lambda$0$Type',770);feb(771,1,{},hXb);_.Kb=function iXb(a){return _Wb(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(FAe,'GraphConfigurator/lambda$1$Type',771);feb(772,1,Qve,jXb);_.Cd=function kXb(a){aXb(this.a,RD(a,10));};sfb(FAe,'GraphConfigurator/lambda$2$Type',772);feb(1109,205,oze,lXb);_.rf=function mXb(a,b){var c;c=c5b(new k5b,a);dE(Gxd(a,(yCc(),IAc)))===dE((Fnd(),Cnd))?LWb(this.a,c,b):MWb(this.a,c,b);b.$g()||J5b(new N5b,c);};sfb(FAe,'LayeredLayoutProvider',1109);feb(367,22,{3:1,34:1,22:1,367:1},tXb);var nXb,oXb,pXb,qXb,rXb;var UP=tfb(FAe,'LayeredPhases',367,WI,vXb,uXb);var wXb;feb(1717,1,{},EXb);_.i=0;var yXb;sfb(GAe,'ComponentsToCGraphTransformer',1717);var jYb;feb(1718,1,{},FXb);_.yf=function GXb(a,b){return $wnd.Math.min(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};_.zf=function HXb(a,b){return $wnd.Math.min(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};sfb(GAe,'ComponentsToCGraphTransformer/1',1718);feb(86,1,{86:1});_.i=0;_.k=true;_.o=pxe;var bQ=sfb(HAe,'CNode',86);feb(470,86,{470:1,86:1},IXb,JXb);_.Ib=function KXb(){return ''};sfb(GAe,'ComponentsToCGraphTransformer/CRectNode',470);feb(1688,1,{},XXb);var LXb,MXb;sfb(GAe,'OneDimensionalComponentsCompaction',1688);feb(1689,1,{},$Xb);_.Kb=function _Xb(a){return YXb(RD(a,42))};_.Fb=function aYb(a){return this===a};sfb(GAe,'OneDimensionalComponentsCompaction/lambda$0$Type',1689);feb(1690,1,{},bYb);_.Kb=function cYb(a){return ZXb(RD(a,42))};_.Fb=function dYb(a){return this===a};sfb(GAe,'OneDimensionalComponentsCompaction/lambda$1$Type',1690);feb(1720,1,{},fYb);sfb(HAe,'CGraph',1720);feb(194,1,{194:1},iYb);_.b=0;_.c=0;_.e=0;_.g=true;_.i=pxe;sfb(HAe,'CGroup',194);feb(1719,1,{},lYb);_.yf=function mYb(a,b){return $wnd.Math.max(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};_.zf=function nYb(a,b){return $wnd.Math.max(a.a!=null?Kfb(a.a):a.c.i,b.a!=null?Kfb(b.a):b.c.i)};sfb(HAe,kye,1719);feb(1721,1,{},EYb);_.d=false;var oYb;var eQ=sfb(HAe,pye,1721);feb(1722,1,{},FYb);_.Kb=function GYb(a){return pYb(),Geb(),RD(RD(a,42).a,86).d.e!=0?true:false};_.Fb=function HYb(a){return this===a};sfb(HAe,qye,1722);feb(833,1,{},KYb);_.a=false;_.b=false;_.c=false;_.d=false;sfb(HAe,rye,833);feb(1898,1,{},QYb);sfb(IAe,sye,1898);var wQ=ufb(JAe,hye);feb(1899,1,{382:1},UYb);_.bf=function VYb(a){SYb(this,RD(a,476));};sfb(IAe,tye,1899);feb(Owe,1,fye,XYb);_.Ne=function YYb(a,b){return WYb(RD(a,86),RD(b,86))};_.Fb=function ZYb(a){return this===a};_.Oe=function $Yb(){return new Frb(this)};sfb(IAe,uye,Owe);feb(476,1,{476:1},_Yb);_.a=false;sfb(IAe,vye,476);feb(1901,1,fye,aZb);_.Ne=function bZb(a,b){return RYb(RD(a,476),RD(b,476))};_.Fb=function cZb(a){return this===a};_.Oe=function dZb(){return new Frb(this)};sfb(IAe,wye,1901);feb(148,1,{148:1},eZb,fZb);_.Fb=function gZb(a){var b;if(a==null){return false}if(mQ!=rb(a)){return false}b=RD(a,148);return Fvb(this.c,b.c)&&Fvb(this.d,b.d)};_.Hb=function hZb(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.c,this.d]))};_.Ib=function iZb(){return '('+this.c+pve+this.d+(this.a?'cx':'')+this.b+')'};_.a=true;_.c=0;_.d=0;var mQ=sfb(JAe,'Point',148);feb(416,22,{3:1,34:1,22:1,416:1},qZb);var jZb,kZb,lZb,mZb;var lQ=tfb(JAe,'Point/Quadrant',416,WI,uZb,tZb);var vZb;feb(1708,1,{},EZb);_.b=null;_.c=null;_.d=null;_.e=null;_.f=null;var xZb,yZb,zZb,AZb,BZb;sfb(JAe,'RectilinearConvexHull',1708);feb(583,1,{382:1},PZb);_.bf=function QZb(a){OZb(this,RD(a,148));};_.b=0;var MZb;sfb(JAe,'RectilinearConvexHull/MaximalElementsEventHandler',583);feb(1710,1,fye,SZb);_.Ne=function TZb(a,b){return RZb(UD(a),UD(b))};_.Fb=function UZb(a){return this===a};_.Oe=function VZb(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/MaximalElementsEventHandler/lambda$0$Type',1710);feb(1709,1,{382:1},XZb);_.bf=function YZb(a){WZb(this,RD(a,148));};_.a=0;_.b=null;_.c=null;_.d=null;_.e=null;sfb(JAe,'RectilinearConvexHull/RectangleEventHandler',1709);feb(1711,1,fye,ZZb);_.Ne=function $Zb(a,b){return GZb(RD(a,148),RD(b,148))};_.Fb=function _Zb(a){return this===a};_.Oe=function a$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$0$Type',1711);feb(1712,1,fye,b$b);_.Ne=function c$b(a,b){return HZb(RD(a,148),RD(b,148))};_.Fb=function d$b(a){return this===a};_.Oe=function e$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$1$Type',1712);feb(1713,1,fye,f$b);_.Ne=function g$b(a,b){return IZb(RD(a,148),RD(b,148))};_.Fb=function h$b(a){return this===a};_.Oe=function i$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$2$Type',1713);feb(1714,1,fye,j$b);_.Ne=function k$b(a,b){return JZb(RD(a,148),RD(b,148))};_.Fb=function l$b(a){return this===a};_.Oe=function m$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$3$Type',1714);feb(1715,1,fye,n$b);_.Ne=function o$b(a,b){return KZb(RD(a,148),RD(b,148))};_.Fb=function p$b(a){return this===a};_.Oe=function q$b(){return new Frb(this)};sfb(JAe,'RectilinearConvexHull/lambda$4$Type',1715);feb(1716,1,{},s$b);sfb(JAe,'Scanline',1716);feb(2104,1,{});sfb(KAe,'AbstractGraphPlacer',2104);feb(335,1,{335:1},C$b);_.Ff=function D$b(a){if(this.Gf(a)){Rc(this.b,RD(mQb(a,(Ywc(),ewc)),21),a);return true}else {return false}};_.Gf=function E$b(a){var b,c,d,e;b=RD(mQb(a,(Ywc(),ewc)),21);e=RD(Qc(y$b,b),21);for(d=e.Kc();d.Ob();){c=RD(d.Pb(),21);if(!RD(Qc(this.b,c),15).dc()){return false}}return true};var y$b;sfb(KAe,'ComponentGroup',335);feb(779,2104,{},J$b);_.Hf=function K$b(a){var b,c;for(c=new Anb(this.a);c.ac){k=0;l+=h+d;h=0;}i=f.c;w$b(f,k+i.a,l+i.b);hjd(i);e=$wnd.Math.max(e,k+j.a);h=$wnd.Math.max(h,j.b);k+=j.a+d;}b.f.a=e;b.f.b=l+h;};_.Jf=function Y_b(a,b){var c,d,e,f,g;if(dE(mQb(b,(yCc(),Yzc)))===dE((U$b(),T$b))){for(d=a.Kc();d.Ob();){c=RD(d.Pb(),36);g=0;for(f=new Anb(c.a);f.ac&&!RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),Yod))||!!i&&RD(mQb(i,(Ywc(),ewc)),21).Hc((qpd(),Xod))||RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),ppd))){m=l;n+=h+d;h=0;}j=f.c;RD(mQb(f,(Ywc(),ewc)),21).Hc((qpd(),Yod))&&(m=e+d);w$b(f,m+j.a,n+j.b);e=$wnd.Math.max(e,m+k.a);RD(mQb(f,ewc),21).Hc(npd)&&(l=$wnd.Math.max(l,m+k.a+d));hjd(j);h=$wnd.Math.max(h,k.b);m+=k.a+d;i=f;}b.f.a=e;b.f.b=n+h;};_.Jf=function __b(a,b){};sfb(KAe,'ModelOrderRowGraphPlacer',1313);feb(1311,1,fye,b0b);_.Ne=function c0b(a,b){return a0b(RD(a,36),RD(b,36))};_.Fb=function d0b(a){return this===a};_.Oe=function e0b(){return new Frb(this)};sfb(KAe,'SimpleRowGraphPlacer/1',1311);var f0b;feb(1280,1,xye,l0b);_.Lb=function m0b(a){var b;return b=RD(mQb(RD(a,249).b,(yCc(),RAc)),75),!!b&&b.b!=0};_.Fb=function n0b(a){return this===a};_.Mb=function o0b(a){var b;return b=RD(mQb(RD(a,249).b,(yCc(),RAc)),75),!!b&&b.b!=0};sfb(PAe,'CompoundGraphPostprocessor/1',1280);feb(1279,1,QAe,E0b);_.Kf=function F0b(a,b){y0b(this,RD(a,36),b);};sfb(PAe,'CompoundGraphPreprocessor',1279);feb(453,1,{453:1},G0b);_.c=false;sfb(PAe,'CompoundGraphPreprocessor/ExternalPort',453);feb(249,1,{249:1},J0b);_.Ib=function K0b(){return ps(this.c)+':'+_0b(this.b)};sfb(PAe,'CrossHierarchyEdge',249);feb(777,1,fye,M0b);_.Ne=function N0b(a,b){return L0b(this,RD(a,249),RD(b,249))};_.Fb=function O0b(a){return this===a};_.Oe=function Q0b(){return new Frb(this)};sfb(PAe,'CrossHierarchyEdgeComparator',777);feb(305,137,{3:1,305:1,96:1,137:1});_.p=0;sfb(RAe,'LGraphElement',305);feb(18,305,{3:1,18:1,305:1,96:1,137:1},a1b);_.Ib=function b1b(){return _0b(this)};var WQ=sfb(RAe,'LEdge',18);feb(36,305,{3:1,20:1,36:1,305:1,96:1,137:1},d1b);_.Jc=function e1b(a){xgb(this,a);};_.Kc=function f1b(){return new Anb(this.b)};_.Ib=function g1b(){if(this.b.c.length==0){return 'G-unlayered'+Fe(this.a)}else if(this.a.c.length==0){return 'G-layered'+Fe(this.b)}return 'G[layerless'+Fe(this.a)+', layers'+Fe(this.b)+']'};var eR=sfb(RAe,'LGraph',36);var h1b;feb(666,1,{});_.Lf=function j1b(){return this.e.n};_.of=function k1b(a){return mQb(this.e,a)};_.Mf=function l1b(){return this.e.o};_.Nf=function m1b(){return this.e.p};_.pf=function n1b(a){return nQb(this.e,a)};_.Of=function o1b(a){this.e.n.a=a.a;this.e.n.b=a.b;};_.Pf=function p1b(a){this.e.o.a=a.a;this.e.o.b=a.b;};_.Qf=function q1b(a){this.e.p=a;};sfb(RAe,'LGraphAdapters/AbstractLShapeAdapter',666);feb(474,1,{853:1},r1b);_.Rf=function s1b(){var a,b;if(!this.b){this.b=ev(this.a.b.c.length);for(b=new Anb(this.a.b);b.a0&&M2b((BFb(c-1,b.length),b.charCodeAt(c-1)),ZAe)){--c;}if(g> ',a),M3b(c));Zhb(Yhb((a.a+='[',a),c.i),']');}return a.a};_.c=true;_.d=false;var D3b,E3b,F3b,G3b,H3b,I3b;var xR=sfb(RAe,'LPort',12);feb(408,1,Vve,T3b);_.Jc=function U3b(a){xgb(this,a);};_.Kc=function V3b(){var a;a=new Anb(this.a.e);return new W3b(a)};sfb(RAe,'LPort/1',408);feb(1309,1,Ave,W3b);_.Nb=function X3b(a){Ztb(this,a);};_.Pb=function Z3b(){return RD(ynb(this.a),18).c};_.Ob=function Y3b(){return xnb(this.a)};_.Qb=function $3b(){znb(this.a);};sfb(RAe,'LPort/1/1',1309);feb(369,1,Vve,_3b);_.Jc=function a4b(a){xgb(this,a);};_.Kc=function b4b(){var a;return a=new Anb(this.a.g),new c4b(a)};sfb(RAe,'LPort/2',369);feb(776,1,Ave,c4b);_.Nb=function d4b(a){Ztb(this,a);};_.Pb=function f4b(){return RD(ynb(this.a),18).d};_.Ob=function e4b(){return xnb(this.a)};_.Qb=function g4b(){znb(this.a);};sfb(RAe,'LPort/2/1',776);feb(1302,1,Vve,h4b);_.Jc=function i4b(a){xgb(this,a);};_.Kc=function j4b(){return new l4b(this)};sfb(RAe,'LPort/CombineIter',1302);feb(208,1,Ave,l4b);_.Nb=function m4b(a){Ztb(this,a);};_.Qb=function p4b(){$tb();};_.Ob=function n4b(){return k4b(this)};_.Pb=function o4b(){return xnb(this.a)?ynb(this.a):ynb(this.b)};sfb(RAe,'LPort/CombineIter/1',208);feb(1303,1,xye,r4b);_.Lb=function s4b(a){return q4b(a)};_.Fb=function t4b(a){return this===a};_.Mb=function u4b(a){return J3b(),RD(a,12).g.c.length!=0};sfb(RAe,'LPort/lambda$0$Type',1303);feb(1304,1,xye,w4b);_.Lb=function x4b(a){return v4b(a)};_.Fb=function y4b(a){return this===a};_.Mb=function z4b(a){return J3b(),RD(a,12).e.c.length!=0};sfb(RAe,'LPort/lambda$1$Type',1304);feb(1305,1,xye,A4b);_.Lb=function B4b(a){return J3b(),RD(a,12).j==(qpd(),Yod)};_.Fb=function C4b(a){return this===a};_.Mb=function D4b(a){return J3b(),RD(a,12).j==(qpd(),Yod)};sfb(RAe,'LPort/lambda$2$Type',1305);feb(1306,1,xye,E4b);_.Lb=function F4b(a){return J3b(),RD(a,12).j==(qpd(),Xod)};_.Fb=function G4b(a){return this===a};_.Mb=function H4b(a){return J3b(),RD(a,12).j==(qpd(),Xod)};sfb(RAe,'LPort/lambda$3$Type',1306);feb(1307,1,xye,I4b);_.Lb=function J4b(a){return J3b(),RD(a,12).j==(qpd(),npd)};_.Fb=function K4b(a){return this===a};_.Mb=function L4b(a){return J3b(),RD(a,12).j==(qpd(),npd)};sfb(RAe,'LPort/lambda$4$Type',1307);feb(1308,1,xye,M4b);_.Lb=function N4b(a){return J3b(),RD(a,12).j==(qpd(),ppd)};_.Fb=function O4b(a){return this===a};_.Mb=function P4b(a){return J3b(),RD(a,12).j==(qpd(),ppd)};sfb(RAe,'LPort/lambda$5$Type',1308);feb(30,305,{3:1,20:1,305:1,30:1,96:1,137:1},R4b);_.Jc=function S4b(a){xgb(this,a);};_.Kc=function T4b(){return new Anb(this.a)};_.Ib=function U4b(){return 'L_'+Wmb(this.b.b,this,0)+Fe(this.a)};sfb(RAe,'Layer',30);feb(1330,1,{},k5b);sfb(cBe,dBe,1330);feb(1334,1,{},o5b);_.Kb=function p5b(a){return AGd(RD(a,84))};sfb(cBe,'ElkGraphImporter/0methodref$connectableShapeToNode$Type',1334);feb(1337,1,{},q5b);_.Kb=function r5b(a){return AGd(RD(a,84))};sfb(cBe,'ElkGraphImporter/1methodref$connectableShapeToNode$Type',1337);feb(1331,1,Qve,s5b);_.Cd=function t5b(a){$4b(this.a,RD(a,123));};sfb(cBe,Nze,1331);feb(1332,1,Qve,u5b);_.Cd=function v5b(a){$4b(this.a,RD(a,123));};sfb(cBe,eBe,1332);feb(1333,1,{},w5b);_.Kb=function x5b(a){return new SDb(null,new Swb(mzd(RD(a,74)),16))};sfb(cBe,fBe,1333);feb(1335,1,nwe,y5b);_.Mb=function z5b(a){return l5b(this.a,RD(a,27))};sfb(cBe,gBe,1335);feb(1336,1,{},A5b);_.Kb=function B5b(a){return new SDb(null,new Swb(lzd(RD(a,74)),16))};sfb(cBe,'ElkGraphImporter/lambda$5$Type',1336);feb(1338,1,nwe,C5b);_.Mb=function D5b(a){return m5b(this.a,RD(a,27))};sfb(cBe,'ElkGraphImporter/lambda$7$Type',1338);feb(1339,1,nwe,E5b);_.Mb=function F5b(a){return n5b(RD(a,74))};sfb(cBe,'ElkGraphImporter/lambda$8$Type',1339);feb(1297,1,{},N5b);var G5b;sfb(cBe,'ElkGraphLayoutTransferrer',1297);feb(1298,1,nwe,Q5b);_.Mb=function R5b(a){return O5b(this.a,RD(a,18))};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$0$Type',1298);feb(1299,1,Qve,S5b);_.Cd=function T5b(a){H5b();Rmb(this.a,RD(a,18));};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$1$Type',1299);feb(1300,1,nwe,U5b);_.Mb=function V5b(a){return P5b(this.a,RD(a,18))};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$2$Type',1300);feb(1301,1,Qve,W5b);_.Cd=function X5b(a){H5b();Rmb(this.a,RD(a,18));};sfb(cBe,'ElkGraphLayoutTransferrer/lambda$3$Type',1301);feb(819,1,{},e6b);sfb(hBe,'BiLinkedHashMultiMap',819);feb(1550,1,QAe,h6b);_.Kf=function i6b(a,b){f6b(RD(a,36),b);};sfb(hBe,'CommentNodeMarginCalculator',1550);feb(1551,1,{},j6b);_.Kb=function k6b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'CommentNodeMarginCalculator/lambda$0$Type',1551);feb(1552,1,Qve,l6b);_.Cd=function m6b(a){g6b(RD(a,10));};sfb(hBe,'CommentNodeMarginCalculator/lambda$1$Type',1552);feb(1553,1,QAe,q6b);_.Kf=function r6b(a,b){o6b(RD(a,36),b);};sfb(hBe,'CommentPostprocessor',1553);feb(1554,1,QAe,v6b);_.Kf=function w6b(a,b){s6b(RD(a,36),b);};sfb(hBe,'CommentPreprocessor',1554);feb(1555,1,QAe,y6b);_.Kf=function z6b(a,b){x6b(RD(a,36),b);};sfb(hBe,'ConstraintsPostprocessor',1555);feb(1556,1,QAe,G6b);_.Kf=function H6b(a,b){E6b(RD(a,36),b);};sfb(hBe,'EdgeAndLayerConstraintEdgeReverser',1556);feb(1557,1,QAe,K6b);_.Kf=function M6b(a,b){I6b(RD(a,36),b);};sfb(hBe,'EndLabelPostprocessor',1557);feb(1558,1,{},N6b);_.Kb=function O6b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelPostprocessor/lambda$0$Type',1558);feb(1559,1,nwe,P6b);_.Mb=function Q6b(a){return L6b(RD(a,10))};sfb(hBe,'EndLabelPostprocessor/lambda$1$Type',1559);feb(1560,1,Qve,R6b);_.Cd=function S6b(a){J6b(RD(a,10));};sfb(hBe,'EndLabelPostprocessor/lambda$2$Type',1560);feb(1561,1,QAe,b7b);_.Kf=function e7b(a,b){Z6b(RD(a,36),b);};sfb(hBe,'EndLabelPreprocessor',1561);feb(1562,1,{},f7b);_.Kb=function g7b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelPreprocessor/lambda$0$Type',1562);feb(1563,1,Qve,h7b);_.Cd=function i7b(a){V6b(this.a,this.b,this.c,RD(a,10));};_.a=0;_.b=0;_.c=false;sfb(hBe,'EndLabelPreprocessor/lambda$1$Type',1563);feb(1564,1,nwe,j7b);_.Mb=function k7b(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Nmd))};sfb(hBe,'EndLabelPreprocessor/lambda$2$Type',1564);feb(1565,1,Qve,l7b);_.Cd=function m7b(a){Mub(this.a,RD(a,72));};sfb(hBe,'EndLabelPreprocessor/lambda$3$Type',1565);feb(1566,1,nwe,n7b);_.Mb=function o7b(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Mmd))};sfb(hBe,'EndLabelPreprocessor/lambda$4$Type',1566);feb(1567,1,Qve,p7b);_.Cd=function q7b(a){Mub(this.a,RD(a,72));};sfb(hBe,'EndLabelPreprocessor/lambda$5$Type',1567);feb(1615,1,QAe,z7b);_.Kf=function A7b(a,b){w7b(RD(a,36),b);};var r7b;sfb(hBe,'EndLabelSorter',1615);feb(1616,1,fye,C7b);_.Ne=function D7b(a,b){return B7b(RD(a,466),RD(b,466))};_.Fb=function E7b(a){return this===a};_.Oe=function F7b(){return new Frb(this)};sfb(hBe,'EndLabelSorter/1',1616);feb(466,1,{466:1},G7b);sfb(hBe,'EndLabelSorter/LabelGroup',466);feb(1617,1,{},H7b);_.Kb=function I7b(a){return s7b(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'EndLabelSorter/lambda$0$Type',1617);feb(1618,1,nwe,J7b);_.Mb=function K7b(a){return s7b(),RD(a,10).k==(r3b(),p3b)};sfb(hBe,'EndLabelSorter/lambda$1$Type',1618);feb(1619,1,Qve,L7b);_.Cd=function M7b(a){x7b(RD(a,10));};sfb(hBe,'EndLabelSorter/lambda$2$Type',1619);feb(1620,1,nwe,N7b);_.Mb=function O7b(a){return s7b(),dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Mmd))};sfb(hBe,'EndLabelSorter/lambda$3$Type',1620);feb(1621,1,nwe,P7b);_.Mb=function Q7b(a){return s7b(),dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Nmd))};sfb(hBe,'EndLabelSorter/lambda$4$Type',1621);feb(1568,1,QAe,a8b);_.Kf=function b8b(a,b){$7b(this,RD(a,36));};_.b=0;_.c=0;sfb(hBe,'FinalSplineBendpointsCalculator',1568);feb(1569,1,{},c8b);_.Kb=function d8b(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$0$Type',1569);feb(1570,1,{},e8b);_.Kb=function f8b(a){return new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$1$Type',1570);feb(1571,1,nwe,g8b);_.Mb=function h8b(a){return !W0b(RD(a,18))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$2$Type',1571);feb(1572,1,nwe,i8b);_.Mb=function j8b(a){return nQb(RD(a,18),(Ywc(),Twc))};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$3$Type',1572);feb(1573,1,Qve,k8b);_.Cd=function l8b(a){T7b(this.a,RD(a,131));};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$4$Type',1573);feb(1574,1,Qve,m8b);_.Cd=function n8b(a){Eob(RD(a,18).a);};sfb(hBe,'FinalSplineBendpointsCalculator/lambda$5$Type',1574);feb(803,1,QAe,L8b);_.Kf=function M8b(a,b){C8b(this,RD(a,36),b);};sfb(hBe,'GraphTransformer',803);feb(517,22,{3:1,34:1,22:1,517:1},Q8b);var N8b,O8b;var vS=tfb(hBe,'GraphTransformer/Mode',517,WI,S8b,R8b);var T8b;feb(1575,1,QAe,Z8b);_.Kf=function $8b(a,b){W8b(RD(a,36),b);};sfb(hBe,'HierarchicalNodeResizingProcessor',1575);feb(1576,1,QAe,f9b);_.Kf=function g9b(a,b){b9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortConstraintProcessor',1576);feb(1577,1,fye,i9b);_.Ne=function j9b(a,b){return h9b(RD(a,10),RD(b,10))};_.Fb=function k9b(a){return this===a};_.Oe=function l9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortConstraintProcessor/NodeComparator',1577);feb(1578,1,QAe,o9b);_.Kf=function p9b(a,b){m9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortDummySizeProcessor',1578);feb(1579,1,QAe,C9b);_.Kf=function D9b(a,b){v9b(this,RD(a,36),b);};_.a=0;sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter',1579);feb(1580,1,fye,F9b);_.Ne=function G9b(a,b){return E9b(RD(a,10),RD(b,10))};_.Fb=function H9b(a){return this===a};_.Oe=function I9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter/1',1580);feb(1581,1,fye,K9b);_.Ne=function L9b(a,b){return J9b(RD(a,10),RD(b,10))};_.Fb=function M9b(a){return this===a};_.Oe=function N9b(){return new Frb(this)};sfb(hBe,'HierarchicalPortOrthogonalEdgeRouter/2',1581);feb(1582,1,QAe,Q9b);_.Kf=function R9b(a,b){P9b(RD(a,36),b);};sfb(hBe,'HierarchicalPortPositionProcessor',1582);feb(1583,1,QAe,$9b);_.Kf=function _9b(a,b){Z9b(this,RD(a,36));};_.a=0;_.c=0;var S9b,T9b;sfb(hBe,'HighDegreeNodeLayeringProcessor',1583);feb(580,1,{580:1},aac);_.b=-1;_.d=-1;sfb(hBe,'HighDegreeNodeLayeringProcessor/HighDegreeNodeInformation',580);feb(1584,1,{},bac);_.Kb=function cac(a){return U9b(),Z2b(RD(a,10))};_.Fb=function dac(a){return this===a};sfb(hBe,'HighDegreeNodeLayeringProcessor/lambda$0$Type',1584);feb(1585,1,{},eac);_.Kb=function fac(a){return U9b(),a3b(RD(a,10))};_.Fb=function gac(a){return this===a};sfb(hBe,'HighDegreeNodeLayeringProcessor/lambda$1$Type',1585);feb(1591,1,QAe,mac);_.Kf=function nac(a,b){lac(this,RD(a,36),b);};sfb(hBe,'HyperedgeDummyMerger',1591);feb(804,1,{},oac);_.a=false;_.b=false;_.c=false;sfb(hBe,'HyperedgeDummyMerger/MergeState',804);feb(1592,1,{},pac);_.Kb=function qac(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'HyperedgeDummyMerger/lambda$0$Type',1592);feb(1593,1,{},rac);_.Kb=function sac(a){return new SDb(null,new Swb(RD(a,10).j,16))};sfb(hBe,'HyperedgeDummyMerger/lambda$1$Type',1593);feb(1594,1,Qve,tac);_.Cd=function uac(a){RD(a,12).p=-1;};sfb(hBe,'HyperedgeDummyMerger/lambda$2$Type',1594);feb(1595,1,QAe,xac);_.Kf=function yac(a,b){wac(RD(a,36),b);};sfb(hBe,'HypernodesProcessor',1595);feb(1596,1,QAe,Aac);_.Kf=function Bac(a,b){zac(RD(a,36),b);};sfb(hBe,'InLayerConstraintProcessor',1596);feb(1597,1,QAe,Dac);_.Kf=function Eac(a,b){Cac(RD(a,36),b);};sfb(hBe,'InnermostNodeMarginCalculator',1597);feb(1598,1,QAe,Iac);_.Kf=function Nac(a,b){Hac(this,RD(a,36));};_.a=pxe;_.b=pxe;_.c=oxe;_.d=oxe;var XS=sfb(hBe,'InteractiveExternalPortPositioner',1598);feb(1599,1,{},Oac);_.Kb=function Pac(a){return RD(a,18).d.i};_.Fb=function Qac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$0$Type',1599);feb(1600,1,{},Rac);_.Kb=function Sac(a){return Jac(this.a,UD(a))};_.Fb=function Tac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$1$Type',1600);feb(1601,1,{},Uac);_.Kb=function Vac(a){return RD(a,18).c.i};_.Fb=function Wac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$2$Type',1601);feb(1602,1,{},Xac);_.Kb=function Yac(a){return Kac(this.a,UD(a))};_.Fb=function Zac(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$3$Type',1602);feb(1603,1,{},$ac);_.Kb=function _ac(a){return Lac(this.a,UD(a))};_.Fb=function abc(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$4$Type',1603);feb(1604,1,{},bbc);_.Kb=function cbc(a){return Mac(this.a,UD(a))};_.Fb=function dbc(a){return this===a};sfb(hBe,'InteractiveExternalPortPositioner/lambda$5$Type',1604);feb(81,22,{3:1,34:1,22:1,81:1,196:1},icc);_.dg=function jcc(){switch(this.g){case 15:return new Hrc;case 22:return new bsc;case 47:return new ksc;case 28:case 35:return new Ldc;case 32:return new h6b;case 42:return new q6b;case 1:return new v6b;case 41:return new y6b;case 56:return new L8b((P8b(),O8b));case 0:return new L8b((P8b(),N8b));case 2:return new G6b;case 54:return new K6b;case 33:return new b7b;case 51:return new a8b;case 55:return new Z8b;case 13:return new f9b;case 38:return new o9b;case 44:return new C9b;case 40:return new Q9b;case 9:return new $9b;case 49:return new Yjc;case 37:return new mac;case 43:return new xac;case 27:return new Aac;case 30:return new Dac;case 3:return new Iac;case 18:return new scc;case 29:return new ycc;case 5:return new Lcc;case 50:return new Ucc;case 34:return new pdc;case 36:return new Zdc;case 52:return new z7b;case 11:return new fec;case 7:return new pec;case 39:return new Dec;case 45:return new Gec;case 16:return new Kec;case 10:return new _ec;case 48:return new Bfc;case 21:return new Ifc;case 23:return new FKc((RKc(),PKc));case 8:return new Rfc;case 12:return new Zfc;case 4:return new cgc;case 19:return new xgc;case 17:return new Vgc;case 53:return new Ygc;case 6:return new Nhc;case 25:return new ahc;case 46:return new rhc;case 31:return new Yhc;case 14:return new jic;case 26:return new Ssc;case 20:return new yic;case 24:return new FKc((RKc(),QKc));default:throw Adb(new agb(lBe+(this.f!=null?this.f:''+this.g)));}};var ebc,fbc,gbc,hbc,ibc,jbc,kbc,lbc,mbc,nbc,obc,pbc,qbc,rbc,sbc,tbc,ubc,vbc,wbc,xbc,ybc,zbc,Abc,Bbc,Cbc,Dbc,Ebc,Fbc,Gbc,Hbc,Ibc,Jbc,Kbc,Lbc,Mbc,Nbc,Obc,Pbc,Qbc,Rbc,Sbc,Tbc,Ubc,Vbc,Wbc,Xbc,Ybc,Zbc,$bc,_bc,acc,bcc,ccc,dcc,ecc,fcc,gcc;var YS=tfb(hBe,mBe,81,WI,lcc,kcc);var mcc;feb(1605,1,QAe,scc);_.Kf=function tcc(a,b){qcc(RD(a,36),b);};sfb(hBe,'InvertedPortProcessor',1605);feb(1606,1,QAe,ycc);_.Kf=function zcc(a,b){xcc(RD(a,36),b);};sfb(hBe,'LabelAndNodeSizeProcessor',1606);feb(1607,1,nwe,Acc);_.Mb=function Bcc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'LabelAndNodeSizeProcessor/lambda$0$Type',1607);feb(1608,1,nwe,Ccc);_.Mb=function Dcc(a){return RD(a,10).k==(r3b(),m3b)};sfb(hBe,'LabelAndNodeSizeProcessor/lambda$1$Type',1608);feb(1609,1,Qve,Ecc);_.Cd=function Fcc(a){vcc(this.b,this.a,this.c,RD(a,10));};_.a=false;_.c=false;sfb(hBe,'LabelAndNodeSizeProcessor/lambda$2$Type',1609);feb(1610,1,QAe,Lcc);_.Kf=function Mcc(a,b){Jcc(RD(a,36),b);};var Gcc;sfb(hBe,'LabelDummyInserter',1610);feb(1611,1,xye,Ncc);_.Lb=function Occ(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Lmd))};_.Fb=function Pcc(a){return this===a};_.Mb=function Qcc(a){return dE(mQb(RD(a,72),(yCc(),wAc)))===dE((Omd(),Lmd))};sfb(hBe,'LabelDummyInserter/1',1611);feb(1612,1,QAe,Ucc);_.Kf=function Vcc(a,b){Tcc(RD(a,36),b);};sfb(hBe,'LabelDummyRemover',1612);feb(1613,1,nwe,Wcc);_.Mb=function Xcc(a){return Heb(TD(mQb(RD(a,72),(yCc(),vAc))))};sfb(hBe,'LabelDummyRemover/lambda$0$Type',1613);feb(1378,1,QAe,pdc);_.Kf=function tdc(a,b){ldc(this,RD(a,36),b);};_.a=null;var Ycc;sfb(hBe,'LabelDummySwitcher',1378);feb(293,1,{293:1},xdc);_.c=0;_.d=null;_.f=0;sfb(hBe,'LabelDummySwitcher/LabelDummyInfo',293);feb(1379,1,{},ydc);_.Kb=function zdc(a){return Zcc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'LabelDummySwitcher/lambda$0$Type',1379);feb(1380,1,nwe,Adc);_.Mb=function Bdc(a){return Zcc(),RD(a,10).k==(r3b(),n3b)};sfb(hBe,'LabelDummySwitcher/lambda$1$Type',1380);feb(1381,1,{},Cdc);_.Kb=function Ddc(a){return qdc(this.a,RD(a,10))};sfb(hBe,'LabelDummySwitcher/lambda$2$Type',1381);feb(1382,1,Qve,Edc);_.Cd=function Fdc(a){rdc(this.a,RD(a,293));};sfb(hBe,'LabelDummySwitcher/lambda$3$Type',1382);feb(1383,1,fye,Gdc);_.Ne=function Hdc(a,b){return sdc(RD(a,293),RD(b,293))};_.Fb=function Idc(a){return this===a};_.Oe=function Jdc(){return new Frb(this)};sfb(hBe,'LabelDummySwitcher/lambda$4$Type',1383);feb(802,1,QAe,Ldc);_.Kf=function Mdc(a,b){Kdc(RD(a,36),b);};sfb(hBe,'LabelManagementProcessor',802);feb(1614,1,QAe,Zdc);_.Kf=function $dc(a,b){Tdc(RD(a,36),b);};sfb(hBe,'LabelSideSelector',1614);feb(1622,1,QAe,fec);_.Kf=function gec(a,b){bec(RD(a,36),b);};sfb(hBe,'LayerConstraintPostprocessor',1622);feb(1623,1,QAe,pec);_.Kf=function qec(a,b){nec(RD(a,36),b);};var hec;sfb(hBe,'LayerConstraintPreprocessor',1623);feb(371,22,{3:1,34:1,22:1,371:1},xec);var rec,sec,tec,uec;var qT=tfb(hBe,'LayerConstraintPreprocessor/HiddenNodeConnections',371,WI,zec,yec);var Aec;feb(1624,1,QAe,Dec);_.Kf=function Eec(a,b){Cec(RD(a,36),b);};sfb(hBe,'LayerSizeAndGraphHeightCalculator',1624);feb(1625,1,QAe,Gec);_.Kf=function Iec(a,b){Fec(RD(a,36),b);};sfb(hBe,'LongEdgeJoiner',1625);feb(1626,1,QAe,Kec);_.Kf=function Mec(a,b){Jec(RD(a,36),b);};sfb(hBe,'LongEdgeSplitter',1626);feb(1627,1,QAe,_ec);_.Kf=function cfc(a,b){Vec(this,RD(a,36),b);};_.e=0;_.f=0;_.j=0;_.k=0;_.n=0;_.o=0;var Pec,Qec;sfb(hBe,'NodePromotion',1627);feb(1628,1,fye,efc);_.Ne=function ffc(a,b){return dfc(RD(a,10),RD(b,10))};_.Fb=function gfc(a){return this===a};_.Oe=function hfc(){return new Frb(this)};sfb(hBe,'NodePromotion/1',1628);feb(1629,1,fye,jfc);_.Ne=function kfc(a,b){return ifc(RD(a,10),RD(b,10))};_.Fb=function lfc(a){return this===a};_.Oe=function mfc(){return new Frb(this)};sfb(hBe,'NodePromotion/2',1629);feb(1630,1,{},nfc);_.Kb=function ofc(a){return RD(a,42),Rec(),Geb(),true};_.Fb=function pfc(a){return this===a};sfb(hBe,'NodePromotion/lambda$0$Type',1630);feb(1631,1,{},qfc);_.Kb=function rfc(a){return afc(this.a,RD(a,42))};_.Fb=function sfc(a){return this===a};_.a=0;sfb(hBe,'NodePromotion/lambda$1$Type',1631);feb(1632,1,{},tfc);_.Kb=function ufc(a){return bfc(this.a,RD(a,42))};_.Fb=function vfc(a){return this===a};_.a=0;sfb(hBe,'NodePromotion/lambda$2$Type',1632);feb(1633,1,QAe,Bfc);_.Kf=function Cfc(a,b){wfc(RD(a,36),b);};sfb(hBe,'NorthSouthPortPostprocessor',1633);feb(1634,1,QAe,Ifc);_.Kf=function Kfc(a,b){Gfc(RD(a,36),b);};sfb(hBe,'NorthSouthPortPreprocessor',1634);feb(1635,1,fye,Lfc);_.Ne=function Mfc(a,b){return Jfc(RD(a,12),RD(b,12))};_.Fb=function Nfc(a){return this===a};_.Oe=function Ofc(){return new Frb(this)};sfb(hBe,'NorthSouthPortPreprocessor/lambda$0$Type',1635);feb(1636,1,QAe,Rfc);_.Kf=function Tfc(a,b){Qfc(RD(a,36),b);};sfb(hBe,'PartitionMidprocessor',1636);feb(1637,1,nwe,Ufc);_.Mb=function Vfc(a){return nQb(RD(a,10),(yCc(),tBc))};sfb(hBe,'PartitionMidprocessor/lambda$0$Type',1637);feb(1638,1,Qve,Wfc);_.Cd=function Xfc(a){Sfc(this.a,RD(a,10));};sfb(hBe,'PartitionMidprocessor/lambda$1$Type',1638);feb(1639,1,QAe,Zfc);_.Kf=function $fc(a,b){Yfc(RD(a,36),b);};sfb(hBe,'PartitionPostprocessor',1639);feb(1640,1,QAe,cgc);_.Kf=function dgc(a,b){agc(RD(a,36),b);};sfb(hBe,'PartitionPreprocessor',1640);feb(1641,1,nwe,egc);_.Mb=function fgc(a){return nQb(RD(a,10),(yCc(),tBc))};sfb(hBe,'PartitionPreprocessor/lambda$0$Type',1641);feb(1642,1,{},ggc);_.Kb=function hgc(a){return new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(hBe,'PartitionPreprocessor/lambda$1$Type',1642);feb(1643,1,nwe,igc);_.Mb=function jgc(a){return _fc(RD(a,18))};sfb(hBe,'PartitionPreprocessor/lambda$2$Type',1643);feb(1644,1,Qve,kgc);_.Cd=function lgc(a){bgc(RD(a,18));};sfb(hBe,'PartitionPreprocessor/lambda$3$Type',1644);feb(1645,1,QAe,xgc);_.Kf=function Bgc(a,b){ugc(RD(a,36),b);};var mgc,ngc,ogc,pgc,qgc,rgc;sfb(hBe,'PortListSorter',1645);feb(1648,1,fye,Dgc);_.Ne=function Egc(a,b){return ygc(RD(a,12),RD(b,12))};_.Fb=function Fgc(a){return this===a};_.Oe=function Ggc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$0$Type',1648);feb(1650,1,fye,Hgc);_.Ne=function Igc(a,b){return zgc(RD(a,12),RD(b,12))};_.Fb=function Jgc(a){return this===a};_.Oe=function Kgc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$1$Type',1650);feb(1646,1,{},Lgc);_.Kb=function Mgc(a){return sgc(),RD(a,12).e};sfb(hBe,'PortListSorter/lambda$2$Type',1646);feb(1647,1,{},Ngc);_.Kb=function Ogc(a){return sgc(),RD(a,12).g};sfb(hBe,'PortListSorter/lambda$3$Type',1647);feb(1649,1,fye,Pgc);_.Ne=function Qgc(a,b){return Agc(RD(a,12),RD(b,12))};_.Fb=function Rgc(a){return this===a};_.Oe=function Sgc(){return new Frb(this)};sfb(hBe,'PortListSorter/lambda$4$Type',1649);feb(1651,1,QAe,Vgc);_.Kf=function Wgc(a,b){Tgc(RD(a,36),b);};sfb(hBe,'PortSideProcessor',1651);feb(1652,1,QAe,Ygc);_.Kf=function Zgc(a,b){Xgc(RD(a,36),b);};sfb(hBe,'ReversedEdgeRestorer',1652);feb(1657,1,QAe,ahc);_.Kf=function bhc(a,b){$gc(this,RD(a,36),b);};sfb(hBe,'SelfLoopPortRestorer',1657);feb(1658,1,{},chc);_.Kb=function dhc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopPortRestorer/lambda$0$Type',1658);feb(1659,1,nwe,ehc);_.Mb=function fhc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopPortRestorer/lambda$1$Type',1659);feb(1660,1,nwe,ghc);_.Mb=function hhc(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopPortRestorer/lambda$2$Type',1660);feb(1661,1,{},ihc);_.Kb=function jhc(a){return RD(mQb(RD(a,10),(Ywc(),Pwc)),337)};sfb(hBe,'SelfLoopPortRestorer/lambda$3$Type',1661);feb(1662,1,Qve,khc);_.Cd=function lhc(a){_gc(this.a,RD(a,337));};sfb(hBe,'SelfLoopPortRestorer/lambda$4$Type',1662);feb(805,1,Qve,mhc);_.Cd=function nhc(a){Rmc(RD(a,105));};sfb(hBe,'SelfLoopPortRestorer/lambda$5$Type',805);feb(1663,1,QAe,rhc);_.Kf=function thc(a,b){ohc(RD(a,36),b);};sfb(hBe,'SelfLoopPostProcessor',1663);feb(1664,1,{},uhc);_.Kb=function vhc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopPostProcessor/lambda$0$Type',1664);feb(1665,1,nwe,whc);_.Mb=function xhc(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopPostProcessor/lambda$1$Type',1665);feb(1666,1,nwe,yhc);_.Mb=function zhc(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopPostProcessor/lambda$2$Type',1666);feb(1667,1,Qve,Ahc);_.Cd=function Bhc(a){phc(RD(a,10));};sfb(hBe,'SelfLoopPostProcessor/lambda$3$Type',1667);feb(1668,1,{},Chc);_.Kb=function Dhc(a){return new SDb(null,new Swb(RD(a,105).f,1))};sfb(hBe,'SelfLoopPostProcessor/lambda$4$Type',1668);feb(1669,1,Qve,Ehc);_.Cd=function Fhc(a){qhc(this.a,RD(a,340));};sfb(hBe,'SelfLoopPostProcessor/lambda$5$Type',1669);feb(1670,1,nwe,Ghc);_.Mb=function Hhc(a){return !!RD(a,105).i};sfb(hBe,'SelfLoopPostProcessor/lambda$6$Type',1670);feb(1671,1,Qve,Ihc);_.Cd=function Jhc(a){shc(this.a,RD(a,105));};sfb(hBe,'SelfLoopPostProcessor/lambda$7$Type',1671);feb(1653,1,QAe,Nhc);_.Kf=function Ohc(a,b){Mhc(RD(a,36),b);};sfb(hBe,'SelfLoopPreProcessor',1653);feb(1654,1,{},Phc);_.Kb=function Qhc(a){return new SDb(null,new Swb(RD(a,105).f,1))};sfb(hBe,'SelfLoopPreProcessor/lambda$0$Type',1654);feb(1655,1,{},Rhc);_.Kb=function Shc(a){return RD(a,340).a};sfb(hBe,'SelfLoopPreProcessor/lambda$1$Type',1655);feb(1656,1,Qve,Thc);_.Cd=function Uhc(a){Lhc(RD(a,18));};sfb(hBe,'SelfLoopPreProcessor/lambda$2$Type',1656);feb(1672,1,QAe,Yhc);_.Kf=function Zhc(a,b){Whc(this,RD(a,36),b);};sfb(hBe,'SelfLoopRouter',1672);feb(1673,1,{},$hc);_.Kb=function _hc(a){return new SDb(null,new Swb(RD(a,30).a,16))};sfb(hBe,'SelfLoopRouter/lambda$0$Type',1673);feb(1674,1,nwe,aic);_.Mb=function bic(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SelfLoopRouter/lambda$1$Type',1674);feb(1675,1,nwe,cic);_.Mb=function dic(a){return nQb(RD(a,10),(Ywc(),Pwc))};sfb(hBe,'SelfLoopRouter/lambda$2$Type',1675);feb(1676,1,{},eic);_.Kb=function fic(a){return RD(mQb(RD(a,10),(Ywc(),Pwc)),337)};sfb(hBe,'SelfLoopRouter/lambda$3$Type',1676);feb(1677,1,Qve,gic);_.Cd=function hic(a){Vhc(this.a,this.b,RD(a,337));};sfb(hBe,'SelfLoopRouter/lambda$4$Type',1677);feb(1678,1,QAe,jic);_.Kf=function mic(a,b){iic(RD(a,36),b);};sfb(hBe,'SemiInteractiveCrossMinProcessor',1678);feb(1679,1,nwe,nic);_.Mb=function oic(a){return RD(a,10).k==(r3b(),p3b)};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$0$Type',1679);feb(1680,1,nwe,pic);_.Mb=function qic(a){return lQb(RD(a,10))._b((yCc(),IBc))};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$1$Type',1680);feb(1681,1,fye,ric);_.Ne=function sic(a,b){return kic(RD(a,10),RD(b,10))};_.Fb=function tic(a){return this===a};_.Oe=function uic(){return new Frb(this)};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$2$Type',1681);feb(1682,1,{},vic);_.Ve=function wic(a,b){return lic(RD(a,10),RD(b,10))};sfb(hBe,'SemiInteractiveCrossMinProcessor/lambda$3$Type',1682);feb(1684,1,QAe,yic);_.Kf=function Cic(a,b){xic(RD(a,36),b);};sfb(hBe,'SortByInputModelProcessor',1684);feb(1685,1,nwe,Dic);_.Mb=function Eic(a){return RD(a,12).g.c.length!=0};sfb(hBe,'SortByInputModelProcessor/lambda$0$Type',1685);feb(1686,1,Qve,Fic);_.Cd=function Gic(a){Aic(this.a,RD(a,12));};sfb(hBe,'SortByInputModelProcessor/lambda$1$Type',1686);feb(1759,817,{},Pic);_.df=function Qic(a){var b,c,d,e;this.c=a;switch(this.a.g){case 2:b=new bnb;FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new Rjc),new Tjc(this,b));eHb(this,new Zic);Umb(b,new bjc);b.c.length=0;FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new djc),new fjc(b));eHb(this,new jjc);Umb(b,new njc);b.c.length=0;c=Wvb(TCb(HDb(new SDb(null,new Swb(this.c.a.b,16)),new pjc(this))),new rjc);FDb(new SDb(null,new Swb(this.c.a.a,16)),new vjc(c,b));eHb(this,new zjc);Umb(b,new Djc);b.c.length=0;break;case 3:d=new bnb;eHb(this,new Ric);e=Wvb(TCb(HDb(new SDb(null,new Swb(this.c.a.b,16)),new Vic(this))),new tjc);FDb(CDb(new SDb(null,new Swb(this.c.a.b,16)),new Fjc),new Hjc(e,d));eHb(this,new Ljc);Umb(d,new Pjc);d.c.length=0;break;default:throw Adb(new Ied);}};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation',1759);feb(1760,1,xye,Ric);_.Lb=function Sic(a){return ZD(RD(a,60).g,154)};_.Fb=function Tic(a){return this===a};_.Mb=function Uic(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$0$Type',1760);feb(1761,1,{},Vic);_.Ye=function Wic(a){return Jic(this.a,RD(a,60))};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$1$Type',1761);feb(1769,1,owe,Xic);_.de=function Yic(){Iic(this.a,this.b,-1);};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$10$Type',1769);feb(1771,1,xye,Zic);_.Lb=function $ic(a){return ZD(RD(a,60).g,154)};_.Fb=function _ic(a){return this===a};_.Mb=function ajc(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$11$Type',1771);feb(1772,1,Qve,bjc);_.Cd=function cjc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$12$Type',1772);feb(1773,1,nwe,djc);_.Mb=function ejc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$13$Type',1773);feb(1775,1,Qve,fjc);_.Cd=function gjc(a){Kic(this.a,RD(a,60));};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$14$Type',1775);feb(1774,1,owe,hjc);_.de=function ijc(){Iic(this.b,this.a,-1);};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$15$Type',1774);feb(1776,1,xye,jjc);_.Lb=function kjc(a){return ZD(RD(a,60).g,10)};_.Fb=function ljc(a){return this===a};_.Mb=function mjc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$16$Type',1776);feb(1777,1,Qve,njc);_.Cd=function ojc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$17$Type',1777);feb(1778,1,{},pjc);_.Ye=function qjc(a){return Lic(this.a,RD(a,60))};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$18$Type',1778);feb(1779,1,{},rjc);_.We=function sjc(){return 0};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$19$Type',1779);feb(1762,1,{},tjc);_.We=function ujc(){return 0};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$2$Type',1762);feb(1781,1,Qve,vjc);_.Cd=function wjc(a){Mic(this.a,this.b,RD(a,316));};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$20$Type',1781);feb(1780,1,owe,xjc);_.de=function yjc(){Hic(this.a,this.b,-1);};_.b=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$21$Type',1780);feb(1782,1,xye,zjc);_.Lb=function Ajc(a){return RD(a,60),true};_.Fb=function Bjc(a){return this===a};_.Mb=function Cjc(a){return RD(a,60),true};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$22$Type',1782);feb(1783,1,Qve,Djc);_.Cd=function Ejc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$23$Type',1783);feb(1763,1,nwe,Fjc);_.Mb=function Gjc(a){return ZD(RD(a,60).g,10)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$3$Type',1763);feb(1765,1,Qve,Hjc);_.Cd=function Ijc(a){Nic(this.a,this.b,RD(a,60));};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$4$Type',1765);feb(1764,1,owe,Jjc);_.de=function Kjc(){Iic(this.b,this.a,-1);};_.a=0;sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$5$Type',1764);feb(1766,1,xye,Ljc);_.Lb=function Mjc(a){return RD(a,60),true};_.Fb=function Njc(a){return this===a};_.Mb=function Ojc(a){return RD(a,60),true};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$6$Type',1766);feb(1767,1,Qve,Pjc);_.Cd=function Qjc(a){RD(a,380).de();};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$7$Type',1767);feb(1768,1,nwe,Rjc);_.Mb=function Sjc(a){return ZD(RD(a,60).g,154)};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$8$Type',1768);feb(1770,1,Qve,Tjc);_.Cd=function Ujc(a){Oic(this.a,this.b,RD(a,60));};sfb(rBe,'EdgeAwareScanlineConstraintCalculation/lambda$9$Type',1770);feb(1586,1,QAe,Yjc);_.Kf=function bkc(a,b){Xjc(this,RD(a,36),b);};var Vjc;sfb(rBe,'HorizontalGraphCompactor',1586);feb(1587,1,{},ckc);_.ff=function dkc(a,b){var c,d,e;if(_jc(a,b)){return 0}c=Zjc(a);d=Zjc(b);if(!!c&&c.k==(r3b(),m3b)||!!d&&d.k==(r3b(),m3b)){return 0}e=RD(mQb(this.a.a,(Ywc(),Qwc)),312);return ZEc(e,c?c.k:(r3b(),o3b),d?d.k:(r3b(),o3b))};_.gf=function ekc(a,b){var c,d,e;if(_jc(a,b)){return 1}c=Zjc(a);d=Zjc(b);e=RD(mQb(this.a.a,(Ywc(),Qwc)),312);return aFc(e,c?c.k:(r3b(),o3b),d?d.k:(r3b(),o3b))};sfb(rBe,'HorizontalGraphCompactor/1',1587);feb(1588,1,{},fkc);_.ef=function gkc(a,b){return Wjc(),a.a.i==0};sfb(rBe,'HorizontalGraphCompactor/lambda$0$Type',1588);feb(1589,1,{},hkc);_.ef=function ikc(a,b){return akc(this.a,a,b)};sfb(rBe,'HorizontalGraphCompactor/lambda$1$Type',1589);feb(1730,1,{},Ckc);var jkc,kkc;sfb(rBe,'LGraphToCGraphTransformer',1730);feb(1738,1,nwe,Kkc);_.Mb=function Lkc(a){return a!=null};sfb(rBe,'LGraphToCGraphTransformer/0methodref$nonNull$Type',1738);feb(1731,1,{},Mkc);_.Kb=function Nkc(a){return lkc(),jeb(mQb(RD(RD(a,60).g,10),(Ywc(),Awc)))};sfb(rBe,'LGraphToCGraphTransformer/lambda$0$Type',1731);feb(1732,1,{},Okc);_.Kb=function Pkc(a){return lkc(),Mlc(RD(RD(a,60).g,154))};sfb(rBe,'LGraphToCGraphTransformer/lambda$1$Type',1732);feb(1741,1,nwe,Qkc);_.Mb=function Rkc(a){return lkc(),ZD(RD(a,60).g,10)};sfb(rBe,'LGraphToCGraphTransformer/lambda$10$Type',1741);feb(1742,1,Qve,Skc);_.Cd=function Tkc(a){Dkc(RD(a,60));};sfb(rBe,'LGraphToCGraphTransformer/lambda$11$Type',1742);feb(1743,1,nwe,Ukc);_.Mb=function Vkc(a){return lkc(),ZD(RD(a,60).g,154)};sfb(rBe,'LGraphToCGraphTransformer/lambda$12$Type',1743);feb(1747,1,Qve,Wkc);_.Cd=function Xkc(a){Ekc(RD(a,60));};sfb(rBe,'LGraphToCGraphTransformer/lambda$13$Type',1747);feb(1744,1,Qve,Ykc);_.Cd=function Zkc(a){Fkc(this.a,RD(a,8));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$14$Type',1744);feb(1745,1,Qve,$kc);_.Cd=function _kc(a){Gkc(this.a,RD(a,116));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$15$Type',1745);feb(1746,1,Qve,alc);_.Cd=function blc(a){Hkc(this.a,RD(a,8));};_.a=0;sfb(rBe,'LGraphToCGraphTransformer/lambda$16$Type',1746);feb(1748,1,{},clc);_.Kb=function dlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$17$Type',1748);feb(1749,1,nwe,elc);_.Mb=function flc(a){return lkc(),W0b(RD(a,18))};sfb(rBe,'LGraphToCGraphTransformer/lambda$18$Type',1749);feb(1750,1,Qve,glc);_.Cd=function hlc(a){ukc(this.a,RD(a,18));};sfb(rBe,'LGraphToCGraphTransformer/lambda$19$Type',1750);feb(1734,1,Qve,ilc);_.Cd=function jlc(a){vkc(this.a,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$2$Type',1734);feb(1751,1,{},klc);_.Kb=function llc(a){return lkc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(rBe,'LGraphToCGraphTransformer/lambda$20$Type',1751);feb(1752,1,{},mlc);_.Kb=function nlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$21$Type',1752);feb(1753,1,{},olc);_.Kb=function plc(a){return lkc(),RD(mQb(RD(a,18),(Ywc(),Twc)),15)};sfb(rBe,'LGraphToCGraphTransformer/lambda$22$Type',1753);feb(1754,1,nwe,qlc);_.Mb=function rlc(a){return Ikc(RD(a,15))};sfb(rBe,'LGraphToCGraphTransformer/lambda$23$Type',1754);feb(1755,1,Qve,slc);_.Cd=function tlc(a){nkc(this.a,RD(a,15));};sfb(rBe,'LGraphToCGraphTransformer/lambda$24$Type',1755);feb(1733,1,Qve,ulc);_.Cd=function vlc(a){wkc(this.a,this.b,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$3$Type',1733);feb(1735,1,{},wlc);_.Kb=function xlc(a){return lkc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(rBe,'LGraphToCGraphTransformer/lambda$4$Type',1735);feb(1736,1,{},ylc);_.Kb=function zlc(a){return lkc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(rBe,'LGraphToCGraphTransformer/lambda$5$Type',1736);feb(1737,1,{},Alc);_.Kb=function Blc(a){return lkc(),RD(mQb(RD(a,18),(Ywc(),Twc)),15)};sfb(rBe,'LGraphToCGraphTransformer/lambda$6$Type',1737);feb(1739,1,Qve,Clc);_.Cd=function Dlc(a){Jkc(this.a,RD(a,15));};sfb(rBe,'LGraphToCGraphTransformer/lambda$8$Type',1739);feb(1740,1,Qve,Elc);_.Cd=function Flc(a){xkc(this.a,this.b,RD(a,154));};sfb(rBe,'LGraphToCGraphTransformer/lambda$9$Type',1740);feb(1729,1,{},Jlc);_.cf=function Klc(a){var b,c,d,e,f;this.a=a;this.d=new BIb;this.c=$C(DN,rve,125,this.a.a.a.c.length,0,1);this.b=0;for(c=new Anb(this.a.a.a);c.a=p){Rmb(f,sgb(k));s=$wnd.Math.max(s,t[k-1]-l);h+=o;q+=t[k-1]-q;l=t[k-1];o=i[k];}o=$wnd.Math.max(o,i[k]);++k;}h+=o;}n=$wnd.Math.min(1/s,1/b.b/h);if(n>d){d=n;c=f;}}return c};_.pg=function Psc(){return false};sfb(zBe,'MSDCutIndexHeuristic',816);feb(1683,1,QAe,Ssc);_.Kf=function Tsc(a,b){Rsc(RD(a,36),b);};sfb(zBe,'SingleEdgeGraphWrapper',1683);feb(232,22,{3:1,34:1,22:1,232:1},ctc);var Xsc,Ysc,Zsc,$sc,_sc,atc;var ZW=tfb(ABe,'CenterEdgeLabelPlacementStrategy',232,WI,etc,dtc);var ftc;feb(431,22,{3:1,34:1,22:1,431:1},ktc);var htc,itc;var $W=tfb(ABe,'ConstraintCalculationStrategy',431,WI,mtc,ltc);var ntc;feb(322,22,{3:1,34:1,22:1,322:1,188:1,196:1},utc);_.dg=function wtc(){return ttc(this)};_.qg=function vtc(){return ttc(this)};var ptc,qtc,rtc;var _W=tfb(ABe,'CrossingMinimizationStrategy',322,WI,ytc,xtc);var ztc;feb(351,22,{3:1,34:1,22:1,351:1},Ftc);var Btc,Ctc,Dtc;var aX=tfb(ABe,'CuttingStrategy',351,WI,Htc,Gtc);var Itc;feb(348,22,{3:1,34:1,22:1,348:1,188:1,196:1},Rtc);_.dg=function Ttc(){return Qtc(this)};_.qg=function Stc(){return Qtc(this)};var Ktc,Ltc,Mtc,Ntc,Otc;var bX=tfb(ABe,'CycleBreakingStrategy',348,WI,Vtc,Utc);var Wtc;feb(428,22,{3:1,34:1,22:1,428:1},_tc);var Ytc,Ztc;var cX=tfb(ABe,'DirectionCongruency',428,WI,buc,auc);var cuc;feb(460,22,{3:1,34:1,22:1,460:1},iuc);var euc,fuc,guc;var dX=tfb(ABe,'EdgeConstraint',460,WI,kuc,juc);var luc;feb(283,22,{3:1,34:1,22:1,283:1},vuc);var nuc,ouc,puc,quc,ruc,suc;var eX=tfb(ABe,'EdgeLabelSideSelection',283,WI,xuc,wuc);var yuc;feb(488,22,{3:1,34:1,22:1,488:1},Duc);var Auc,Buc;var fX=tfb(ABe,'EdgeStraighteningStrategy',488,WI,Fuc,Euc);var Guc;feb(281,22,{3:1,34:1,22:1,281:1},Puc);var Iuc,Juc,Kuc,Luc,Muc,Nuc;var gX=tfb(ABe,'FixedAlignment',281,WI,Ruc,Quc);var Suc;feb(282,22,{3:1,34:1,22:1,282:1},_uc);var Uuc,Vuc,Wuc,Xuc,Yuc,Zuc;var hX=tfb(ABe,'GraphCompactionStrategy',282,WI,bvc,avc);var cvc;feb(259,22,{3:1,34:1,22:1,259:1},pvc);var evc,fvc,gvc,hvc,ivc,jvc,kvc,lvc,mvc,nvc;var iX=tfb(ABe,'GraphProperties',259,WI,rvc,qvc);var svc;feb(299,22,{3:1,34:1,22:1,299:1},yvc);var uvc,vvc,wvc;var jX=tfb(ABe,'GreedySwitchType',299,WI,Avc,zvc);var Bvc;feb(311,22,{3:1,34:1,22:1,311:1},Hvc);var Dvc,Evc,Fvc;var kX=tfb(ABe,'InLayerConstraint',311,WI,Jvc,Ivc);var Kvc;feb(429,22,{3:1,34:1,22:1,429:1},Pvc);var Mvc,Nvc;var lX=tfb(ABe,'InteractiveReferencePoint',429,WI,Rvc,Qvc);var Svc;var Uvc,Vvc,Wvc,Xvc,Yvc,Zvc,$vc,_vc,awc,bwc,cwc,dwc,ewc,fwc,gwc,hwc,iwc,jwc,kwc,lwc,mwc,nwc,owc,pwc,qwc,rwc,swc,twc,uwc,vwc,wwc,xwc,ywc,zwc,Awc,Bwc,Cwc,Dwc,Ewc,Fwc,Gwc,Hwc,Iwc,Jwc,Kwc,Lwc,Mwc,Nwc,Owc,Pwc,Qwc,Rwc,Swc,Twc,Uwc,Vwc,Wwc,Xwc;feb(171,22,{3:1,34:1,22:1,171:1},dxc);var Zwc,$wc,_wc,axc,bxc;var mX=tfb(ABe,'LayerConstraint',171,WI,fxc,exc);var gxc;feb(859,1,Eye,Pzc);_.hf=function Qzc(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,HBe),''),'Direction Congruency'),'Specifies how drawings of the same graph with different layout directions compare to each other: either a natural reading direction is preserved or the drawings are rotated versions of each other.'),Uxc),(kid(),eid)),cX),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,IBe),''),'Feedback Edges'),'Whether feedback edges should be highlighted by routing around the nodes.'),(Geb(),false)),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JBe),''),'Interactive Reference Point'),'Determines which point of a node is considered by interactive layout phases.'),pyc),eid),lX),xsb(Whd))));zgd(a,JBe,RBe,ryc);zgd(a,JBe,_Be,qyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KBe),''),'Merge Edges'),'Edges that have no ports are merged so they touch the connected nodes at the same points. When this option is disabled, one port is created for each edge directly connected to a node. When it is enabled, all such incoming edges share an input port, and all outgoing edges share an output port.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LBe),''),'Merge Hierarchy-Crossing Edges'),'If hierarchical layout is active, hierarchy-crossing edges use as few hierarchical ports as possible. They are broken by the algorithm, with hierarchical ports inserted as required. Usually, one such port is created for each edge at each hierarchy crossing point. With this option set to true, we try to create as few hierarchical ports as possible in the process. In particular, all edges that form a hyperedge can share a port.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Nhd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MBe),''),'Allow Non-Flow Ports To Switch Sides'),"Specifies whether non-flow ports may switch sides if their node's port constraints are either FIXED_SIDE or FIXED_ORDER. A non-flow port is a port on a side that is not part of the currently configured layout flow. For instance, given a left-to-right layout direction, north and south ports would be considered non-flow ports. Further note that the underlying criterium whether to switch sides or not solely relies on the minimization of edge crossings. Hence, edge length and other aesthetics criteria are not addressed."),false),cid),QI),xsb(Xhd)),cD(WC(qJ,1),Nve,2,6,['org.eclipse.elk.layered.northOrSouthPort']))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NBe),''),'Port Sorting Strategy'),"Only relevant for nodes with FIXED_SIDE port constraints. Determines the way a node's ports are distributed on the sides of a node if their order is not prescribed. The option is set on parent nodes."),azc),eid),xX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,OBe),''),'Thoroughness'),'How much effort should be spent to produce a nice layout.'),sgb(7)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PBe),''),'Add Unnecessary Bendpoints'),'Adds bend points even if an edge does not change direction. If true, each long edge dummy will contribute a bend point to its edges and hierarchy-crossing edges will always get a bend point where they cross hierarchy boundaries. By default, bend points are only added where an edge changes direction.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,QBe),''),'Generate Position and Layer IDs'),'If enabled position id and layer id are generated, which are usually only used internally when setting the interactiveLayout option. This option should be specified on the root node.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RBe),'cycleBreaking'),'Cycle Breaking Strategy'),'Strategy for cycle breaking. Cycle breaking looks for cycles in the graph and determines which edges to reverse to break the cycles. Reversed edges will end up pointing to the opposite direction of regular edges (that is, reversed edges will point left if edges usually point right).'),Sxc),eid),bX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SBe),bDe),'Node Layering Strategy'),'Strategy for node layering.'),Gyc),eid),rX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TBe),bDe),'Layer Constraint'),'Determines a constraint on the placement of the node regarding the layering.'),wyc),eid),mX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UBe),bDe),'Layer Choice Constraint'),"Allows to set a constraint regarding the layer placement of a node. Let i be the value of teh constraint. Assumed the drawing has n layers and i < n. If set to i, it expresses that the node should be placed in i-th layer. Should i>=n be true then the node is placed in the last layer of the drawing. Note that this option is not part of any of ELK Layered's default configurations but is only evaluated as part of the `InteractiveLayeredGraphVisitor`, which must be applied manually or used via the `DiagramLayoutEngine."),null),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VBe),bDe),'Layer ID'),'Layer identifier that was calculated by ELK Layered for a node. This is only generated if interactiveLayot or generatePositionAndLayerIds is set.'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WBe),cDe),'Upper Bound On Width [MinWidth Layerer]'),"Defines a loose upper bound on the width of the MinWidth layerer. If set to '-1' multiple values are tested and the best result is selected."),sgb(4)),gid),bJ),xsb(Whd))));zgd(a,WBe,SBe,zyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XBe),cDe),'Upper Layer Estimation Scaling Factor [MinWidth Layerer]'),"Multiplied with Upper Bound On Width for defining an upper bound on the width of layers which haven't been determined yet, but whose maximum width had been (roughly) estimated by the MinWidth algorithm. Compensates for too high estimations. If set to '-1' multiple values are tested and the best result is selected."),sgb(2)),gid),bJ),xsb(Whd))));zgd(a,XBe,SBe,Byc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YBe),dDe),'Node Promotion Strategy'),'Reduces number of dummy nodes after layering phase (if possible).'),Eyc),eid),vX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZBe),dDe),'Max Node Promotion Iterations'),'Limits the number of iterations for node promotion.'),sgb(0)),gid),bJ),xsb(Whd))));zgd(a,ZBe,YBe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Be),'layering.coffmanGraham'),'Layer Bound'),'The maximum number of nodes allowed per layer.'),sgb(lve)),gid),bJ),xsb(Whd))));zgd(a,$Be,SBe,tyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Be),eDe),'Crossing Minimization Strategy'),'Strategy for crossing minimization.'),Qxc),eid),_W),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aCe),eDe),'Force Node Model Order'),'The node order given by the model does not change to produce a better layout. E.g. if node A is before node B in the model this is not changed during crossing minimization. This assumes that the node model order is already respected before crossing minimization. This can be achieved by setting considerModelOrder.strategy to NODES_AND_EDGES.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bCe),eDe),'Hierarchical Sweepiness'),'How likely it is to use cross-hierarchy (1) vs bottom-up (-1).'),0.1),did),VI),xsb(Whd))));zgd(a,bCe,fDe,Ixc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,cCe),eDe),'Semi-Interactive Crossing Minimization'),"Preserves the order of nodes within a layer but still minimizes crossings between edges connecting long edge dummies. Derives the desired order from positions specified by the 'org.eclipse.elk.position' layout option. Requires a crossing minimization strategy that is able to process 'in-layer' constraints."),false),cid),QI),xsb(Whd))));zgd(a,cCe,_Be,Oxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dCe),eDe),'In Layer Predecessor of'),"Allows to set a constraint which specifies of which node the current node is the predecessor. If set to 's' then the node is the predecessor of 's' and is in the same layer"),null),iid),qJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eCe),eDe),'In Layer Successor of'),"Allows to set a constraint which specifies of which node the current node is the successor. If set to 's' then the node is the successor of 's' and is in the same layer"),null),iid),qJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fCe),eDe),'Position Choice Constraint'),"Allows to set a constraint regarding the position placement of a node in a layer. Assumed the layer in which the node placed includes n other nodes and i < n. If set to i, it expresses that the node should be placed at the i-th position. Should i>=n be true then the node is placed at the last position in the layer. Note that this option is not part of any of ELK Layered's default configurations but is only evaluated as part of the `InteractiveLayeredGraphVisitor`, which must be applied manually or used via the `DiagramLayoutEngine."),null),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gCe),eDe),'Position ID'),'Position within a layer that was determined by ELK Layered for a node. This is only generated if interactiveLayot or generatePositionAndLayerIds is set.'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hCe),gDe),'Greedy Switch Activation Threshold'),"By default it is decided automatically if the greedy switch is activated or not. The decision is based on whether the size of the input graph (without dummy nodes) is smaller than the value of this option. A '0' enforces the activation."),sgb(40)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iCe),gDe),'Greedy Switch Crossing Minimization'),"Greedy Switch strategy for crossing minimization. The greedy switch heuristic is executed after the regular crossing minimization as a post-processor. Note that if 'hierarchyHandling' is set to 'INCLUDE_CHILDREN', the 'greedySwitchHierarchical.type' option must be used."),Fxc),eid),jX),xsb(Whd))));zgd(a,iCe,_Be,Gxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,jCe),'crossingMinimization.greedySwitchHierarchical'),'Greedy Switch Crossing Minimization (hierarchical)'),"Activates the greedy switch heuristic in case hierarchical layout is used. The differences to the non-hierarchical case (see 'greedySwitch.type') are: 1) greedy switch is inactive by default, 3) only the option value set on the node at which hierarchical layout starts is relevant, and 2) if it's activated by the user, it properly addresses hierarchy-crossing edges."),Bxc),eid),jX),xsb(Whd))));zgd(a,jCe,_Be,Cxc);zgd(a,jCe,fDe,Dxc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kCe),hDe),'Node Placement Strategy'),'Strategy for node placement.'),$yc),eid),uX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,lCe),hDe),'Favor Straight Edges Over Balancing'),"Favor straight edges over a balanced node placement. The default behavior is determined automatically based on the used 'edgeRouting'. For an orthogonal style it is set to true, for all other styles to false."),cid),QI),xsb(Whd))));zgd(a,lCe,kCe,Qyc);zgd(a,lCe,kCe,Ryc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,mCe),iDe),'BK Edge Straightening'),"Specifies whether the Brandes Koepf node placer tries to increase the number of straight edges at the expense of diagram size. There is a subtle difference to the 'favorStraightEdges' option, which decides whether a balanced placement of the nodes is desired, or not. In bk terms this means combining the four alignments into a single balanced one, or not. This option on the other hand tries to straighten additional edges during the creation of each of the four alignments."),Kyc),eid),fX),xsb(Whd))));zgd(a,mCe,kCe,Lyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,nCe),iDe),'BK Fixed Alignment'),'Tells the BK node placer to use a certain alignment (out of its four) instead of the one producing the smallest height, or the combination of all four.'),Nyc),eid),gX),xsb(Whd))));zgd(a,nCe,kCe,Oyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,oCe),'nodePlacement.linearSegments'),'Linear Segments Deflection Dampening'),'Dampens the movement of nodes to keep the diagram from getting too large.'),0.3),did),VI),xsb(Whd))));zgd(a,oCe,kCe,Tyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,pCe),'nodePlacement.networkSimplex'),'Node Flexibility'),"Aims at shorter and straighter edges. Two configurations are possible: (a) allow ports to move freely on the side they are assigned to (the order is always defined beforehand), (b) additionally allow to enlarge a node wherever it helps. If this option is not configured for a node, the 'nodeFlexibility.default' value is used, which is specified for the node's parent."),eid),tX),xsb(Vhd))));zgd(a,pCe,kCe,Yyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,qCe),'nodePlacement.networkSimplex.nodeFlexibility'),'Node Flexibility Default'),"Default value of the 'nodeFlexibility' option for the children of a hierarchical node."),Wyc),eid),tX),xsb(Whd))));zgd(a,qCe,kCe,Xyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,rCe),jDe),'Self-Loop Distribution'),'Alter the distribution of the loops around the node. It only takes effect for PortConstraints.FREE.'),ayc),eid),zX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,sCe),jDe),'Self-Loop Ordering'),'Alter the ordering of the loops they can either be stacked or sequenced. It only takes effect for PortConstraints.FREE.'),cyc),eid),AX),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,tCe),'edgeRouting.splines'),'Spline Routing Mode'),'Specifies the way control points are assembled for each individual edge. CONSERVATIVE ensures that edges are properly routed around the nodes but feels rather orthogonal at times. SLOPPY uses fewer control points to obtain curvier edge routes but may result in edges overlapping nodes.'),eyc),eid),CX),xsb(Whd))));zgd(a,tCe,kDe,fyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,uCe),'edgeRouting.splines.sloppy'),'Sloppy Spline Layer Spacing Factor'),'Spacing factor for routing area between layers when using sloppy spline routing.'),0.2),did),VI),xsb(Whd))));zgd(a,uCe,kDe,hyc);zgd(a,uCe,tCe,iyc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,vCe),'edgeRouting.polyline'),'Sloped Edge Zone Width'),'Width of the strip to the left and to the right of each layer where the polyline edge router is allowed to refrain from ensuring that edges are routed horizontally. This prevents awkward bend points for nodes that extent almost to the edge of their layer.'),2),did),VI),xsb(Whd))));zgd(a,vCe,kDe,$xc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,wCe),lDe),'Spacing Base Value'),"An optional base value for all other layout options of the 'spacing' group. It can be used to conveniently alter the overall 'spaciousness' of the drawing. Whenever an explicit value is set for the other layout options, this base value will have no effect. The base value is not inherited, i.e. it must be set for each hierarchical node."),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xCe),lDe),'Edge Node Between Layers Spacing'),"The spacing to be preserved between nodes and edges that are routed next to the node's layer. For the spacing between nodes and edges that cross the node's layer 'spacing.edgeNode' is used."),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yCe),lDe),'Edge Edge Between Layer Spacing'),"Spacing to be preserved between pairs of edges that are routed between the same pair of layers. Note that 'spacing.edgeEdge' is used for the spacing between pairs of edges crossing the same layer."),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zCe),lDe),'Node Node Between Layers Spacing'),"The spacing to be preserved between any pair of nodes of two adjacent layers. Note that 'spacing.nodeNode' is used for the spacing between nodes within the layer itself."),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ACe),mDe),'Direction Priority'),'Defines how important it is to have a certain edge point into the direction of the overall layout. This option is evaluated during the cycle breaking phase.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,BCe),mDe),'Shortness Priority'),'Defines how important it is to keep an edge as short as possible. This option is evaluated during the layering phase.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CCe),mDe),'Straightness Priority'),'Defines how important it is to keep an edge straight, i.e. aligned with one of the two axes. This option is evaluated during node placement.'),sgb(0)),gid),bJ),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,DCe),nDe),qze),'Tries to further compact components (disconnected sub-graphs).'),false),cid),QI),xsb(Whd))));zgd(a,DCe,cAe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ECe),oDe),'Post Compaction Strategy'),pDe),nxc),eid),hX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,FCe),oDe),'Post Compaction Constraint Calculation'),pDe),lxc),eid),$W),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,GCe),qDe),'High Degree Node Treatment'),'Makes room around high degree nodes to place leafs and trees.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,HCe),qDe),'High Degree Node Threshold'),'Whether a node is considered to have a high degree.'),sgb(16)),gid),bJ),xsb(Whd))));zgd(a,HCe,GCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ICe),qDe),'High Degree Node Maximum Tree Height'),'Maximum height of a subtree connected to a high degree node to be moved to separate layers.'),sgb(5)),gid),bJ),xsb(Whd))));zgd(a,ICe,GCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JCe),rDe),'Graph Wrapping Strategy'),"For certain graphs and certain prescribed drawing areas it may be desirable to split the laid out graph into chunks that are placed side by side. The edges that connect different chunks are 'wrapped' around from the end of one chunk to the start of the other chunk. The points between the chunks are referred to as 'cuts'."),Gzc),eid),EX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KCe),rDe),'Additional Wrapped Edges Spacing'),'To visually separate edges that are wrapped from regularly routed edges an additional spacing value can be specified in form of this layout option. The spacing is added to the regular edgeNode spacing.'),10),did),VI),xsb(Whd))));zgd(a,KCe,JCe,lzc);zgd(a,KCe,JCe,mzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LCe),rDe),'Correction Factor for Wrapping'),"At times and for certain types of graphs the executed wrapping may produce results that are consistently biased in the same fashion: either wrapping to often or to rarely. This factor can be used to correct the bias. Internally, it is simply multiplied with the 'aspect ratio' layout option."),1),did),VI),xsb(Whd))));zgd(a,LCe,JCe,ozc);zgd(a,LCe,JCe,pzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MCe),sDe),'Cutting Strategy'),'The strategy by which the layer indexes are determined at which the layering crumbles into chunks.'),wzc),eid),aX),xsb(Whd))));zgd(a,MCe,JCe,xzc);zgd(a,MCe,JCe,yzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,NCe),sDe),'Manually Specified Cuts'),'Allows the user to specify her own cuts for a certain graph.'),hid),QK),xsb(Whd))));zgd(a,NCe,MCe,rzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,OCe),'wrapping.cutting.msd'),'MSD Freedom'),'The MSD cutting strategy starts with an initial guess on the number of chunks the graph should be split into. The freedom specifies how much the strategy may deviate from this guess. E.g. if an initial number of 3 is computed, a freedom of 1 allows 2, 3, and 4 cuts.'),tzc),gid),bJ),xsb(Whd))));zgd(a,OCe,MCe,uzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PCe),tDe),'Validification Strategy'),'When wrapping graphs, one can specify indices that are not allowed as split points. The validification strategy makes sure every computed split point is allowed.'),Lzc),eid),DX),xsb(Whd))));zgd(a,PCe,JCe,Mzc);zgd(a,PCe,JCe,Nzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,QCe),tDe),'Valid Indices for Wrapping'),null),hid),QK),xsb(Whd))));zgd(a,QCe,JCe,Izc);zgd(a,QCe,JCe,Jzc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RCe),uDe),'Improve Cuts'),'For general graphs it is important that not too many edges wrap backwards. Thus a compromise between evenly-distributed cuts and the total number of cut edges is sought.'),true),cid),QI),xsb(Whd))));zgd(a,RCe,JCe,Czc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SCe),uDe),'Distance Penalty When Improving Cuts'),null),2),did),VI),xsb(Whd))));zgd(a,SCe,JCe,Azc);zgd(a,SCe,RCe,true);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TCe),uDe),'Improve Wrapped Edges'),'The initial wrapping is performed in a very simple way. As a consequence, edges that wrap from one chunk to another may be unnecessarily long. Activating this option tries to shorten such edges.'),true),cid),QI),xsb(Whd))));zgd(a,TCe,JCe,Ezc);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UCe),vDe),'Edge Label Side Selection'),'Method to decide on edge label sides.'),Yxc),eid),eX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VCe),vDe),'Edge Center Label Placement Strategy'),'Determines in which layer center labels of long edges should be placed.'),Wxc),eid),ZW),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WCe),wDe),'Consider Model Order'),'Preserves the order of nodes and edges in the model file if this does not lead to additional edge crossings. Depending on the strategy this is not always possible since the node and edge order might be conflicting.'),xxc),eid),wX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XCe),wDe),'Consider Port Order'),'If disabled the port order of output ports is derived from the edge order and input ports are ordered by their incoming connections. If enabled all ports are ordered by the port model order.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YCe),wDe),'No Model Order'),'Set on a node to not set a model order for this node even though it is a real node.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZCe),wDe),'Consider Model Order for Components'),'If set to NONE the usual ordering strategy (by cumulative node priority and size of nodes) is used. INSIDE_PORT_SIDES orders the components with external ports only inside the groups with the same port side. FORCE_MODEL_ORDER enforces the mode order on components. This option might produce bad alignments and sub optimal drawings in terms of used area since the ordering should be respected.'),pxc),eid),CQ),xsb(Whd))));zgd(a,ZCe,cAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Ce),wDe),'Long Edge Ordering Strategy'),'Indicates whether long edges are sorted under, over, or equal to nodes that have no connection to a previous layer in a left-to-right or right-to-left layout. Under and over changes to right and left in a vertical layout.'),txc),eid),sX),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Ce),wDe),'Crossing Counter Node Order Influence'),'Indicates with what percentage (1 for 100%) violations of the node model order are weighted against the crossings e.g. a value of 0.5 means two model order violations are as important as on edge crossing. This allows some edge crossings in favor of preserving the model order. It is advised to set this value to a very small positive value (e.g. 0.001) to have minimal crossing and a optimal node order. Defaults to no influence (0).'),0),did),VI),xsb(Whd))));zgd(a,_Ce,WCe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aDe),wDe),'Crossing Counter Port Order Influence'),'Indicates with what percentage (1 for 100%) violations of the port model order are weighted against the crossings e.g. a value of 0.5 means two model order violations are as important as on edge crossing. This allows some edge crossings in favor of preserving the model order. It is advised to set this value to a very small positive value (e.g. 0.001) to have minimal crossing and a optimal port order. Defaults to no influence (0).'),0),did),VI),xsb(Whd))));zgd(a,aDe,WCe,null);zCc((new ACc,a));};var ixc,jxc,kxc,lxc,mxc,nxc,oxc,pxc,qxc,rxc,sxc,txc,uxc,vxc,wxc,xxc,yxc,zxc,Axc,Bxc,Cxc,Dxc,Exc,Fxc,Gxc,Hxc,Ixc,Jxc,Kxc,Lxc,Mxc,Nxc,Oxc,Pxc,Qxc,Rxc,Sxc,Txc,Uxc,Vxc,Wxc,Xxc,Yxc,Zxc,$xc,_xc,ayc,byc,cyc,dyc,eyc,fyc,gyc,hyc,iyc,jyc,kyc,lyc,myc,nyc,oyc,pyc,qyc,ryc,syc,tyc,uyc,vyc,wyc,xyc,yyc,zyc,Ayc,Byc,Cyc,Dyc,Eyc,Fyc,Gyc,Hyc,Iyc,Jyc,Kyc,Lyc,Myc,Nyc,Oyc,Pyc,Qyc,Ryc,Syc,Tyc,Uyc,Vyc,Wyc,Xyc,Yyc,Zyc,$yc,_yc,azc,bzc,czc,dzc,ezc,fzc,gzc,hzc,izc,jzc,kzc,lzc,mzc,nzc,ozc,pzc,qzc,rzc,szc,tzc,uzc,vzc,wzc,xzc,yzc,zzc,Azc,Bzc,Czc,Dzc,Ezc,Fzc,Gzc,Hzc,Izc,Jzc,Kzc,Lzc,Mzc,Nzc;sfb(ABe,'LayeredMetaDataProvider',859);feb(998,1,Eye,ACc);_.hf=function BCc(a){zCc(a);};var Rzc,Szc,Tzc,Uzc,Vzc,Wzc,Xzc,Yzc,Zzc,$zc,_zc,aAc,bAc,cAc,dAc,eAc,fAc,gAc,hAc,iAc,jAc,kAc,lAc,mAc,nAc,oAc,pAc,qAc,rAc,sAc,tAc,uAc,vAc,wAc,xAc,yAc,zAc,AAc,BAc,CAc,DAc,EAc,FAc,GAc,HAc,IAc,JAc,KAc,LAc,MAc,NAc,OAc,PAc,QAc,RAc,SAc,TAc,UAc,VAc,WAc,XAc,YAc,ZAc,$Ac,_Ac,aBc,bBc,cBc,dBc,eBc,fBc,gBc,hBc,iBc,jBc,kBc,lBc,mBc,nBc,oBc,pBc,qBc,rBc,sBc,tBc,uBc,vBc,wBc,xBc,yBc,zBc,ABc,BBc,CBc,DBc,EBc,FBc,GBc,HBc,IBc,JBc,KBc,LBc,MBc,NBc,OBc,PBc,QBc,RBc,SBc,TBc,UBc,VBc,WBc,XBc,YBc,ZBc,$Bc,_Bc,aCc,bCc,cCc,dCc,eCc,fCc,gCc,hCc,iCc,jCc,kCc,lCc,mCc,nCc,oCc,pCc,qCc,rCc,sCc,tCc,uCc,vCc,wCc,xCc;sfb(ABe,'LayeredOptions',998);feb(999,1,{},CCc);_.sf=function DCc(){var a;return a=new lXb,a};_.tf=function ECc(a){};sfb(ABe,'LayeredOptions/LayeredFactory',999);feb(1391,1,{});_.a=0;var FCc;sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder',1391);feb(792,1391,{},RCc);var OCc,PCc;sfb(ABe,'LayeredSpacings/LayeredSpacingsBuilder',792);feb(265,22,{3:1,34:1,22:1,265:1,188:1,196:1},bDc);_.dg=function dDc(){return aDc(this)};_.qg=function cDc(){return aDc(this)};var SCc,TCc,UCc,VCc,WCc,XCc,YCc,ZCc,$Cc;var rX=tfb(ABe,'LayeringStrategy',265,WI,fDc,eDc);var gDc;feb(390,22,{3:1,34:1,22:1,390:1},nDc);var iDc,jDc,kDc;var sX=tfb(ABe,'LongEdgeOrderingStrategy',390,WI,pDc,oDc);var qDc;feb(203,22,{3:1,34:1,22:1,203:1},yDc);var sDc,tDc,uDc,vDc;var tX=tfb(ABe,'NodeFlexibility',203,WI,BDc,ADc);var CDc;feb(323,22,{3:1,34:1,22:1,323:1,188:1,196:1},LDc);_.dg=function NDc(){return KDc(this)};_.qg=function MDc(){return KDc(this)};var EDc,FDc,GDc,HDc,IDc;var uX=tfb(ABe,'NodePlacementStrategy',323,WI,PDc,ODc);var QDc;feb(243,22,{3:1,34:1,22:1,243:1},bEc);var SDc,TDc,UDc,VDc,WDc,XDc,YDc,ZDc,$Dc,_Dc;var vX=tfb(ABe,'NodePromotionStrategy',243,WI,dEc,cEc);var eEc;feb(284,22,{3:1,34:1,22:1,284:1},lEc);var gEc,hEc,iEc,jEc;var wX=tfb(ABe,'OrderingStrategy',284,WI,nEc,mEc);var oEc;feb(430,22,{3:1,34:1,22:1,430:1},tEc);var qEc,rEc;var xX=tfb(ABe,'PortSortingStrategy',430,WI,vEc,uEc);var wEc;feb(463,22,{3:1,34:1,22:1,463:1},CEc);var yEc,zEc,AEc;var yX=tfb(ABe,'PortType',463,WI,EEc,DEc);var FEc;feb(387,22,{3:1,34:1,22:1,387:1},LEc);var HEc,IEc,JEc;var zX=tfb(ABe,'SelfLoopDistributionStrategy',387,WI,NEc,MEc);var OEc;feb(349,22,{3:1,34:1,22:1,349:1},UEc);var QEc,REc,SEc;var AX=tfb(ABe,'SelfLoopOrderingStrategy',349,WI,WEc,VEc);var XEc;feb(312,1,{312:1},gFc);sfb(ABe,'Spacings',312);feb(350,22,{3:1,34:1,22:1,350:1},mFc);var iFc,jFc,kFc;var CX=tfb(ABe,'SplineRoutingMode',350,WI,oFc,nFc);var pFc;feb(352,22,{3:1,34:1,22:1,352:1},vFc);var rFc,sFc,tFc;var DX=tfb(ABe,'ValidifyStrategy',352,WI,xFc,wFc);var yFc;feb(388,22,{3:1,34:1,22:1,388:1},EFc);var AFc,BFc,CFc;var EX=tfb(ABe,'WrappingStrategy',388,WI,GFc,FFc);var HFc;feb(1398,1,nEe,NFc);_.rg=function OFc(a){return RD(a,36),JFc};_.Kf=function PFc(a,b){MFc(this,RD(a,36),b);};var JFc;sfb(oEe,'DepthFirstCycleBreaker',1398);feb(793,1,nEe,UFc);_.rg=function WFc(a){return RD(a,36),QFc};_.Kf=function XFc(a,b){SFc(this,RD(a,36),b);};_.sg=function VFc(a){return RD(Vmb(a,Jwb(this.d,a.c.length)),10)};var QFc;sfb(oEe,'GreedyCycleBreaker',793);feb(1401,793,nEe,YFc);_.sg=function ZFc(a){var b,c,d,e;e=null;b=lve;for(d=new Anb(a);d.a1){Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),(yCc(),eAc))))?wLc(a,this.d,RD(this,669)):(yob(),_mb(a,this.d));nJc(this.e,a);}};_.lg=function bJc(a,b,c,d){var e,f,g,h,i,j,k;if(b!=SIc(c,a.length)){f=a[b-(c?1:-1)];sIc(this.f,f,c?(BEc(),zEc):(BEc(),yEc));}e=a[b][0];k=!d||e.k==(r3b(),m3b);j=dv(a[b]);this.vg(j,k,false,c);g=0;for(i=new Anb(j);i.a');a0?(pMc(this.a,a[b-1],a[b]),undefined):!c&&b1){Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),(yCc(),eAc))))?wLc(a,this.d,this):(yob(),_mb(a,this.d));Heb(TD(mQb(Y2b((tFb(0,a.c.length),RD(a.c[0],10))),eAc)))||nJc(this.e,a);}};sfb(sEe,'ModelOrderBarycenterHeuristic',669);feb(1866,1,fye,yLc);_.Ne=function zLc(a,b){return tLc(this.a,RD(a,10),RD(b,10))};_.Fb=function ALc(a){return this===a};_.Oe=function BLc(){return new Frb(this)};sfb(sEe,'ModelOrderBarycenterHeuristic/lambda$0$Type',1866);feb(1423,1,nEe,FLc);_.rg=function GLc(a){var b;return RD(a,36),b=vfd(CLc),pfd(b,(sXb(),pXb),(hcc(),Ybc)),b};_.Kf=function HLc(a,b){ELc((RD(a,36),b));};var CLc;sfb(sEe,'NoCrossingMinimizer',1423);feb(809,413,qEe,ILc);_.tg=function JLc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n;l=this.g;switch(c.g){case 1:{e=0;f=0;for(k=new Anb(a.j);k.a1&&(e.j==(qpd(),Xod)?(this.b[a]=true):e.j==ppd&&a>0&&(this.b[a-1]=true));};_.f=0;sfb(tBe,'AllCrossingsCounter',1861);feb(595,1,{},_Lc);_.b=0;_.d=0;sfb(tBe,'BinaryIndexedTree',595);feb(532,1,{},DMc);var bMc,cMc;sfb(tBe,'CrossingsCounter',532);feb(1950,1,fye,HMc);_.Ne=function IMc(a,b){return wMc(this.a,RD(a,12),RD(b,12))};_.Fb=function JMc(a){return this===a};_.Oe=function KMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$0$Type',1950);feb(1951,1,fye,LMc);_.Ne=function MMc(a,b){return xMc(this.a,RD(a,12),RD(b,12))};_.Fb=function NMc(a){return this===a};_.Oe=function OMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$1$Type',1951);feb(1952,1,fye,PMc);_.Ne=function QMc(a,b){return yMc(this.a,RD(a,12),RD(b,12))};_.Fb=function RMc(a){return this===a};_.Oe=function SMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$2$Type',1952);feb(1953,1,fye,TMc);_.Ne=function UMc(a,b){return zMc(this.a,RD(a,12),RD(b,12))};_.Fb=function VMc(a){return this===a};_.Oe=function WMc(){return new Frb(this)};sfb(tBe,'CrossingsCounter/lambda$3$Type',1953);feb(1954,1,Qve,XMc);_.Cd=function YMc(a){EMc(this.a,RD(a,12));};sfb(tBe,'CrossingsCounter/lambda$4$Type',1954);feb(1955,1,nwe,ZMc);_.Mb=function $Mc(a){return FMc(this.a,RD(a,12))};sfb(tBe,'CrossingsCounter/lambda$5$Type',1955);feb(1956,1,Qve,aNc);_.Cd=function bNc(a){_Mc(this,a);};sfb(tBe,'CrossingsCounter/lambda$6$Type',1956);feb(1957,1,Qve,cNc);_.Cd=function dNc(a){var b;dMc();hmb(this.b,(b=this.a,RD(a,12),b));};sfb(tBe,'CrossingsCounter/lambda$7$Type',1957);feb(839,1,xye,eNc);_.Lb=function fNc(a){return dMc(),nQb(RD(a,12),(Ywc(),Iwc))};_.Fb=function gNc(a){return this===a};_.Mb=function hNc(a){return dMc(),nQb(RD(a,12),(Ywc(),Iwc))};sfb(tBe,'CrossingsCounter/lambda$8$Type',839);feb(1949,1,{},jNc);sfb(tBe,'HyperedgeCrossingsCounter',1949);feb(478,1,{34:1,478:1},lNc);_.Fd=function mNc(a){return kNc(this,RD(a,478))};_.b=0;_.c=0;_.e=0;_.f=0;var OY=sfb(tBe,'HyperedgeCrossingsCounter/Hyperedge',478);feb(374,1,{34:1,374:1},oNc);_.Fd=function pNc(a){return nNc(this,RD(a,374))};_.b=0;_.c=0;var NY=sfb(tBe,'HyperedgeCrossingsCounter/HyperedgeCorner',374);feb(531,22,{3:1,34:1,22:1,531:1},tNc);var qNc,rNc;var MY=tfb(tBe,'HyperedgeCrossingsCounter/HyperedgeCorner/Type',531,WI,vNc,uNc);var wNc;feb(1425,1,nEe,DNc);_.rg=function ENc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?zNc:null};_.Kf=function FNc(a,b){CNc(this,RD(a,36),b);};var zNc;sfb(tEe,'InteractiveNodePlacer',1425);feb(1426,1,nEe,TNc);_.rg=function UNc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?GNc:null};_.Kf=function VNc(a,b){RNc(this,RD(a,36),b);};var GNc,HNc,INc;sfb(tEe,'LinearSegmentsNodePlacer',1426);feb(261,1,{34:1,261:1},ZNc);_.Fd=function $Nc(a){return WNc(this,RD(a,261))};_.Fb=function _Nc(a){var b;if(ZD(a,261)){b=RD(a,261);return this.b==b.b}return false};_.Hb=function aOc(){return this.b};_.Ib=function bOc(){return 'ls'+Fe(this.e)};_.a=0;_.b=0;_.c=-1;_.d=-1;_.g=0;var SY=sfb(tEe,'LinearSegmentsNodePlacer/LinearSegment',261);feb(1428,1,nEe,yOc);_.rg=function zOc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?cOc:null};_.Kf=function HOc(a,b){uOc(this,RD(a,36),b);};_.b=0;_.g=0;var cOc;sfb(tEe,'NetworkSimplexPlacer',1428);feb(1447,1,fye,IOc);_.Ne=function JOc(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function KOc(a){return this===a};_.Oe=function LOc(){return new Frb(this)};sfb(tEe,'NetworkSimplexPlacer/0methodref$compare$Type',1447);feb(1449,1,fye,MOc);_.Ne=function NOc(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function OOc(a){return this===a};_.Oe=function POc(){return new Frb(this)};sfb(tEe,'NetworkSimplexPlacer/1methodref$compare$Type',1449);feb(655,1,{655:1},QOc);var WY=sfb(tEe,'NetworkSimplexPlacer/EdgeRep',655);feb(412,1,{412:1},ROc);_.b=false;var XY=sfb(tEe,'NetworkSimplexPlacer/NodeRep',412);feb(515,13,{3:1,4:1,20:1,31:1,56:1,13:1,16:1,15:1,59:1,515:1},VOc);sfb(tEe,'NetworkSimplexPlacer/Path',515);feb(1429,1,{},WOc);_.Kb=function XOc(a){return RD(a,18).d.i.k};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$0$Type',1429);feb(1430,1,nwe,YOc);_.Mb=function ZOc(a){return RD(a,273)==(r3b(),o3b)};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$1$Type',1430);feb(1431,1,{},$Oc);_.Kb=function _Oc(a){return RD(a,18).d.i};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$2$Type',1431);feb(1432,1,nwe,aPc);_.Mb=function bPc(a){return EPc(zDc(RD(a,10)))};sfb(tEe,'NetworkSimplexPlacer/Path/lambda$3$Type',1432);feb(1433,1,nwe,cPc);_.Mb=function dPc(a){return DOc(RD(a,12))};sfb(tEe,'NetworkSimplexPlacer/lambda$0$Type',1433);feb(1434,1,Qve,ePc);_.Cd=function fPc(a){jOc(this.a,this.b,RD(a,12));};sfb(tEe,'NetworkSimplexPlacer/lambda$1$Type',1434);feb(1443,1,Qve,gPc);_.Cd=function hPc(a){kOc(this.a,RD(a,18));};sfb(tEe,'NetworkSimplexPlacer/lambda$10$Type',1443);feb(1444,1,{},iPc);_.Kb=function jPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$11$Type',1444);feb(1445,1,Qve,kPc);_.Cd=function lPc(a){lOc(this.a,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$12$Type',1445);feb(1446,1,{},mPc);_.Kb=function nPc(a){return dOc(),sgb(RD(a,125).e)};sfb(tEe,'NetworkSimplexPlacer/lambda$13$Type',1446);feb(1448,1,{},oPc);_.Kb=function pPc(a){return dOc(),sgb(RD(a,125).e)};sfb(tEe,'NetworkSimplexPlacer/lambda$15$Type',1448);feb(1450,1,nwe,qPc);_.Mb=function rPc(a){return dOc(),RD(a,412).c.k==(r3b(),p3b)};sfb(tEe,'NetworkSimplexPlacer/lambda$17$Type',1450);feb(1451,1,nwe,sPc);_.Mb=function tPc(a){return dOc(),RD(a,412).c.j.c.length>1};sfb(tEe,'NetworkSimplexPlacer/lambda$18$Type',1451);feb(1452,1,Qve,uPc);_.Cd=function vPc(a){EOc(this.c,this.b,this.d,this.a,RD(a,412));};_.c=0;_.d=0;sfb(tEe,'NetworkSimplexPlacer/lambda$19$Type',1452);feb(1435,1,{},wPc);_.Kb=function xPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$2$Type',1435);feb(1453,1,Qve,yPc);_.Cd=function zPc(a){FOc(this.a,RD(a,12));};_.a=0;sfb(tEe,'NetworkSimplexPlacer/lambda$20$Type',1453);feb(1454,1,{},APc);_.Kb=function BPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$21$Type',1454);feb(1455,1,Qve,CPc);_.Cd=function DPc(a){mOc(this.a,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$22$Type',1455);feb(1456,1,nwe,FPc);_.Mb=function GPc(a){return EPc(a)};sfb(tEe,'NetworkSimplexPlacer/lambda$23$Type',1456);feb(1457,1,{},HPc);_.Kb=function IPc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$24$Type',1457);feb(1458,1,nwe,JPc);_.Mb=function KPc(a){return nOc(this.a,RD(a,10))};sfb(tEe,'NetworkSimplexPlacer/lambda$25$Type',1458);feb(1459,1,Qve,LPc);_.Cd=function MPc(a){oOc(this.a,this.b,RD(a,10));};sfb(tEe,'NetworkSimplexPlacer/lambda$26$Type',1459);feb(1460,1,nwe,NPc);_.Mb=function OPc(a){return dOc(),!W0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$27$Type',1460);feb(1461,1,nwe,PPc);_.Mb=function QPc(a){return dOc(),!W0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$28$Type',1461);feb(1462,1,{},RPc);_.Ve=function SPc(a,b){return pOc(this.a,RD(a,30),RD(b,30))};sfb(tEe,'NetworkSimplexPlacer/lambda$29$Type',1462);feb(1436,1,{},TPc);_.Kb=function UPc(a){return dOc(),new SDb(null,new Twb(new is(Mr(a3b(RD(a,10)).a.Kc(),new ir))))};sfb(tEe,'NetworkSimplexPlacer/lambda$3$Type',1436);feb(1437,1,nwe,VPc);_.Mb=function WPc(a){return dOc(),COc(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$4$Type',1437);feb(1438,1,Qve,XPc);_.Cd=function YPc(a){vOc(this.a,RD(a,18));};sfb(tEe,'NetworkSimplexPlacer/lambda$5$Type',1438);feb(1439,1,{},ZPc);_.Kb=function $Pc(a){return dOc(),new SDb(null,new Swb(RD(a,30).a,16))};sfb(tEe,'NetworkSimplexPlacer/lambda$6$Type',1439);feb(1440,1,nwe,_Pc);_.Mb=function aQc(a){return dOc(),RD(a,10).k==(r3b(),p3b)};sfb(tEe,'NetworkSimplexPlacer/lambda$7$Type',1440);feb(1441,1,{},bQc);_.Kb=function cQc(a){return dOc(),new SDb(null,new Twb(new is(Mr(W2b(RD(a,10)).a.Kc(),new ir))))};sfb(tEe,'NetworkSimplexPlacer/lambda$8$Type',1441);feb(1442,1,nwe,dQc);_.Mb=function eQc(a){return dOc(),V0b(RD(a,18))};sfb(tEe,'NetworkSimplexPlacer/lambda$9$Type',1442);feb(1424,1,nEe,iQc);_.rg=function jQc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?fQc:null};_.Kf=function kQc(a,b){hQc(RD(a,36),b);};var fQc;sfb(tEe,'SimpleNodePlacer',1424);feb(185,1,{185:1},sQc);_.Ib=function tQc(){var a;a='';this.c==(wQc(),vQc)?(a+=Oye):this.c==uQc&&(a+=Nye);this.o==(EQc(),CQc)?(a+=Zye):this.o==DQc?(a+='UP'):(a+='BALANCED');return a};sfb(wEe,'BKAlignedLayout',185);feb(523,22,{3:1,34:1,22:1,523:1},xQc);var uQc,vQc;var FZ=tfb(wEe,'BKAlignedLayout/HDirection',523,WI,zQc,yQc);var AQc;feb(522,22,{3:1,34:1,22:1,522:1},FQc);var CQc,DQc;var GZ=tfb(wEe,'BKAlignedLayout/VDirection',522,WI,HQc,GQc);var IQc;feb(1699,1,{},MQc);sfb(wEe,'BKAligner',1699);feb(1702,1,{},RQc);sfb(wEe,'BKCompactor',1702);feb(663,1,{663:1},SQc);_.a=0;sfb(wEe,'BKCompactor/ClassEdge',663);feb(467,1,{467:1},UQc);_.a=null;_.b=0;sfb(wEe,'BKCompactor/ClassNode',467);feb(1427,1,nEe,aRc);_.rg=function eRc(a){return RD(mQb(RD(a,36),(Ywc(),kwc)),21).Hc((ovc(),hvc))?VQc:null};_.Kf=function fRc(a,b){_Qc(this,RD(a,36),b);};_.d=false;var VQc;sfb(wEe,'BKNodePlacer',1427);feb(1700,1,{},hRc);_.d=0;sfb(wEe,'NeighborhoodInformation',1700);feb(1701,1,fye,mRc);_.Ne=function nRc(a,b){return lRc(this,RD(a,42),RD(b,42))};_.Fb=function oRc(a){return this===a};_.Oe=function pRc(){return new Frb(this)};sfb(wEe,'NeighborhoodInformation/NeighborComparator',1701);feb(823,1,{});sfb(wEe,'ThresholdStrategy',823);feb(1825,823,{},uRc);_.wg=function vRc(a,b,c){return this.a.o==(EQc(),DQc)?oxe:pxe};_.xg=function wRc(){};sfb(wEe,'ThresholdStrategy/NullThresholdStrategy',1825);feb(587,1,{587:1},xRc);_.c=false;_.d=false;sfb(wEe,'ThresholdStrategy/Postprocessable',587);feb(1826,823,{},BRc);_.wg=function CRc(a,b,c){var d,e,f;e=b==c;d=this.a.a[c.p]==b;if(!(e||d)){return a}f=a;if(this.a.c==(wQc(),vQc)){e&&(f=yRc(this,b,true));!isNaN(f)&&!isFinite(f)&&d&&(f=yRc(this,c,false));}else {e&&(f=yRc(this,b,true));!isNaN(f)&&!isFinite(f)&&d&&(f=yRc(this,c,false));}return f};_.xg=function DRc(){var a,b,c,d,e;while(this.d.b!=0){e=RD(Tub(this.d),587);d=zRc(this,e);if(!d.a){continue}a=d.a;c=Heb(this.a.f[this.a.g[e.b.p].p]);if(!c&&!W0b(a)&&a.c.i.c==a.d.i.c){continue}b=ARc(this,e);b||Eyb(this.e,e);}while(this.e.a.c.length!=0){ARc(this,RD(Dyb(this.e),587));}};sfb(wEe,'ThresholdStrategy/SimpleThresholdStrategy',1826);feb(645,1,{645:1,188:1,196:1},HRc);_.dg=function JRc(){return GRc(this)};_.qg=function IRc(){return GRc(this)};var ERc;sfb(xEe,'EdgeRouterFactory',645);feb(1485,1,nEe,WRc);_.rg=function XRc(a){return URc(RD(a,36))};_.Kf=function YRc(a,b){VRc(RD(a,36),b);};var LRc,MRc,NRc,ORc,PRc,QRc,RRc,SRc;sfb(xEe,'OrthogonalEdgeRouter',1485);feb(1478,1,nEe,lSc);_.rg=function mSc(a){return gSc(RD(a,36))};_.Kf=function nSc(a,b){iSc(this,RD(a,36),b);};var ZRc,$Rc,_Rc,aSc,bSc,cSc;sfb(xEe,'PolylineEdgeRouter',1478);feb(1479,1,xye,pSc);_.Lb=function qSc(a){return oSc(RD(a,10))};_.Fb=function rSc(a){return this===a};_.Mb=function sSc(a){return oSc(RD(a,10))};sfb(xEe,'PolylineEdgeRouter/1',1479);feb(1872,1,nwe,xSc);_.Mb=function ySc(a){return RD(a,132).c==(fTc(),dTc)};sfb(yEe,'HyperEdgeCycleDetector/lambda$0$Type',1872);feb(1873,1,{},zSc);_.Ze=function ASc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$1$Type',1873);feb(1874,1,nwe,BSc);_.Mb=function CSc(a){return RD(a,132).c==(fTc(),dTc)};sfb(yEe,'HyperEdgeCycleDetector/lambda$2$Type',1874);feb(1875,1,{},DSc);_.Ze=function ESc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$3$Type',1875);feb(1876,1,{},FSc);_.Ze=function GSc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$4$Type',1876);feb(1877,1,{},HSc);_.Ze=function ISc(a){return RD(a,132).d};sfb(yEe,'HyperEdgeCycleDetector/lambda$5$Type',1877);feb(118,1,{34:1,118:1},USc);_.Fd=function VSc(a){return KSc(this,RD(a,118))};_.Fb=function WSc(a){var b;if(ZD(a,118)){b=RD(a,118);return this.g==b.g}return false};_.Hb=function XSc(){return this.g};_.Ib=function ZSc(){var a,b,c,d;a=new dib('{');d=new Anb(this.n);while(d.a'+this.b+' ('+os(this.c)+')'};_.d=0;sfb(yEe,'HyperEdgeSegmentDependency',132);feb(528,22,{3:1,34:1,22:1,528:1},gTc);var dTc,eTc;var b$=tfb(yEe,'HyperEdgeSegmentDependency/DependencyType',528,WI,iTc,hTc);var jTc;feb(1878,1,{},xTc);sfb(yEe,'HyperEdgeSegmentSplitter',1878);feb(1879,1,{},ATc);_.a=0;_.b=0;sfb(yEe,'HyperEdgeSegmentSplitter/AreaRating',1879);feb(339,1,{339:1},BTc);_.a=0;_.b=0;_.c=0;sfb(yEe,'HyperEdgeSegmentSplitter/FreeArea',339);feb(1880,1,fye,CTc);_.Ne=function DTc(a,b){return zTc(RD(a,118),RD(b,118))};_.Fb=function ETc(a){return this===a};_.Oe=function FTc(){return new Frb(this)};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$0$Type',1880);feb(1881,1,Qve,GTc);_.Cd=function HTc(a){rTc(this.a,this.d,this.c,this.b,RD(a,118));};_.b=0;sfb(yEe,'HyperEdgeSegmentSplitter/lambda$1$Type',1881);feb(1882,1,{},ITc);_.Kb=function JTc(a){return new SDb(null,new Swb(RD(a,118).e,16))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$2$Type',1882);feb(1883,1,{},KTc);_.Kb=function LTc(a){return new SDb(null,new Swb(RD(a,118).j,16))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$3$Type',1883);feb(1884,1,{},MTc);_.Ye=function NTc(a){return Kfb(UD(a))};sfb(yEe,'HyperEdgeSegmentSplitter/lambda$4$Type',1884);feb(664,1,{},TTc);_.a=0;_.b=0;_.c=0;sfb(yEe,'OrthogonalRoutingGenerator',664);feb(1703,1,{},XTc);_.Kb=function YTc(a){return new SDb(null,new Swb(RD(a,118).e,16))};sfb(yEe,'OrthogonalRoutingGenerator/lambda$0$Type',1703);feb(1704,1,{},ZTc);_.Kb=function $Tc(a){return new SDb(null,new Swb(RD(a,118).j,16))};sfb(yEe,'OrthogonalRoutingGenerator/lambda$1$Type',1704);feb(670,1,{});sfb(zEe,'BaseRoutingDirectionStrategy',670);feb(1870,670,{},cUc);_.yg=function dUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b+a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(l,f);Mub(g.a,d);_Tc(this,g,e,d,false);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);f=b+m.o*c;e=m;d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);}d=new rjd(p,f);Mub(g.a,d);_Tc(this,g,e,d,false);}}}}};_.zg=function eUc(a){return a.i.n.a+a.n.a+a.a.a};_.Ag=function fUc(){return qpd(),npd};_.Bg=function gUc(){return qpd(),Yod};sfb(zEe,'NorthToSouthRoutingStrategy',1870);feb(1871,670,{},hUc);_.yg=function iUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b-a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(l,f);Mub(g.a,d);_Tc(this,g,e,d,false);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);f=b-m.o*c;e=m;d=new rjd(n,f);Mub(g.a,d);_Tc(this,g,e,d,false);}d=new rjd(p,f);Mub(g.a,d);_Tc(this,g,e,d,false);}}}}};_.zg=function jUc(a){return a.i.n.a+a.n.a+a.a.a};_.Ag=function kUc(){return qpd(),Yod};_.Bg=function lUc(){return qpd(),npd};sfb(zEe,'SouthToNorthRoutingStrategy',1871);feb(1869,670,{},mUc);_.yg=function nUc(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p;if(!!a.r&&!a.q){return}k=b+a.o*c;for(j=new Anb(a.n);j.aVze){f=k;e=a;d=new rjd(f,l);Mub(g.a,d);_Tc(this,g,e,d,true);m=a.r;if(m){n=Kfb(UD(ju(m.e,0)));d=new rjd(f,n);Mub(g.a,d);_Tc(this,g,e,d,true);f=b+m.o*c;e=m;d=new rjd(f,n);Mub(g.a,d);_Tc(this,g,e,d,true);}d=new rjd(f,p);Mub(g.a,d);_Tc(this,g,e,d,true);}}}}};_.zg=function oUc(a){return a.i.n.b+a.n.b+a.a.b};_.Ag=function pUc(){return qpd(),Xod};_.Bg=function qUc(){return qpd(),ppd};sfb(zEe,'WestToEastRoutingStrategy',1869);feb(828,1,{},wUc);_.Ib=function xUc(){return Fe(this.a)};_.b=0;_.c=false;_.d=false;_.f=0;sfb(BEe,'NubSpline',828);feb(418,1,{418:1},AUc,BUc);sfb(BEe,'NubSpline/PolarCP',418);feb(1480,1,nEe,VUc);_.rg=function XUc(a){return QUc(RD(a,36))};_.Kf=function YUc(a,b){UUc(this,RD(a,36),b);};var CUc,DUc,EUc,FUc,GUc;sfb(BEe,'SplineEdgeRouter',1480);feb(274,1,{274:1},_Uc);_.Ib=function aVc(){return this.a+' ->('+this.c+') '+this.b};_.c=0;sfb(BEe,'SplineEdgeRouter/Dependency',274);feb(465,22,{3:1,34:1,22:1,465:1},eVc);var bVc,cVc;var w$=tfb(BEe,'SplineEdgeRouter/SideToProcess',465,WI,gVc,fVc);var hVc;feb(1481,1,nwe,jVc);_.Mb=function kVc(a){return HUc(),!RD(a,131).o};sfb(BEe,'SplineEdgeRouter/lambda$0$Type',1481);feb(1482,1,{},lVc);_.Ze=function mVc(a){return HUc(),RD(a,131).v+1};sfb(BEe,'SplineEdgeRouter/lambda$1$Type',1482);feb(1483,1,Qve,nVc);_.Cd=function oVc(a){SUc(this.a,this.b,RD(a,42));};sfb(BEe,'SplineEdgeRouter/lambda$2$Type',1483);feb(1484,1,Qve,pVc);_.Cd=function qVc(a){TUc(this.a,this.b,RD(a,42));};sfb(BEe,'SplineEdgeRouter/lambda$3$Type',1484);feb(131,1,{34:1,131:1},wVc,xVc);_.Fd=function yVc(a){return uVc(this,RD(a,131))};_.b=0;_.e=false;_.f=0;_.g=0;_.j=false;_.k=false;_.n=0;_.o=false;_.p=false;_.q=false;_.s=0;_.u=0;_.v=0;_.F=0;sfb(BEe,'SplineSegment',131);feb(468,1,{468:1},zVc);_.a=0;_.b=false;_.c=false;_.d=false;_.e=false;_.f=0;sfb(BEe,'SplineSegment/EdgeInformation',468);feb(1198,1,{},IVc);sfb(GEe,Lze,1198);feb(1199,1,fye,KVc);_.Ne=function LVc(a,b){return JVc(RD(a,121),RD(b,121))};_.Fb=function MVc(a){return this===a};_.Oe=function NVc(){return new Frb(this)};sfb(GEe,Mze,1199);feb(1197,1,{},TVc);sfb(GEe,'MrTree',1197);feb(405,22,{3:1,34:1,22:1,405:1,188:1,196:1},$Vc);_.dg=function aWc(){return ZVc(this)};_.qg=function _Vc(){return ZVc(this)};var UVc,VVc,WVc,XVc;var H$=tfb(GEe,'TreeLayoutPhases',405,WI,cWc,bWc);var dWc;feb(1112,205,oze,fWc);_.rf=function gWc(a,b){var c,d,e,f,g,h,i,j;Heb(TD(Gxd(a,(h_c(),S$c))))||RFb((c=new SFb((lud(),new zud(a))),c));g=b.eh(HEe);g.Ug('build tGraph',1);h=(i=new YWc,kQb(i,a),pQb(i,(q$c(),h$c),a),j=new Tsb,QVc(a,i,j),PVc(a,i,j),i);g.Vg();g=b.eh(HEe);g.Ug('Split graph',1);f=HVc(this.a,h);g.Vg();for(e=new Anb(f);e.a'+aXc(this.c):'e_'+tb(this)};sfb(JEe,'TEdge',65);feb(121,137,{3:1,121:1,96:1,137:1},YWc);_.Ib=function ZWc(){var a,b,c,d,e;e=null;for(d=Sub(this.b,0);d.b!=d.d.c;){c=RD(evb(d),40);e+=(c.c==null||c.c.length==0?'n_'+c.g:'n_'+c.c)+'\n';}for(b=Sub(this.a,0);b.b!=b.d.c;){a=RD(evb(b),65);e+=(!!a.b&&!!a.c?aXc(a.b)+'->'+aXc(a.c):'e_'+tb(a))+'\n';}return e};var W$=sfb(JEe,'TGraph',121);feb(643,508,{3:1,508:1,643:1,96:1,137:1});sfb(JEe,'TShape',643);feb(40,643,{3:1,508:1,40:1,643:1,96:1,137:1},bXc);_.Ib=function cXc(){return aXc(this)};var Z$=sfb(JEe,'TNode',40);feb(236,1,Vve,dXc);_.Jc=function eXc(a){xgb(this,a);};_.Kc=function fXc(){var a;return a=Sub(this.a.d,0),new gXc(a)};sfb(JEe,'TNode/2',236);feb(329,1,Ave,gXc);_.Nb=function hXc(a){Ztb(this,a);};_.Pb=function jXc(){return RD(evb(this.a),65).c};_.Ob=function iXc(){return dvb(this.a)};_.Qb=function kXc(){gvb(this.a);};sfb(JEe,'TNode/2/1',329);feb(1923,1,QAe,qXc);_.Kf=function DXc(a,b){oXc(this,RD(a,121),b);};sfb(LEe,'CompactionProcessor',1923);feb(1924,1,fye,EXc);_.Ne=function FXc(a,b){return rXc(this.a,RD(a,40),RD(b,40))};_.Fb=function GXc(a){return this===a};_.Oe=function HXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$0$Type',1924);feb(1925,1,nwe,IXc);_.Mb=function JXc(a){return sXc(this.b,this.a,RD(a,42))};_.a=0;_.b=0;sfb(LEe,'CompactionProcessor/lambda$1$Type',1925);feb(1934,1,fye,KXc);_.Ne=function LXc(a,b){return tXc(RD(a,40),RD(b,40))};_.Fb=function MXc(a){return this===a};_.Oe=function NXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$10$Type',1934);feb(1935,1,fye,OXc);_.Ne=function PXc(a,b){return uXc(RD(a,40),RD(b,40))};_.Fb=function QXc(a){return this===a};_.Oe=function RXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$11$Type',1935);feb(1936,1,fye,SXc);_.Ne=function TXc(a,b){return vXc(RD(a,40),RD(b,40))};_.Fb=function UXc(a){return this===a};_.Oe=function VXc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$12$Type',1936);feb(1926,1,nwe,WXc);_.Mb=function XXc(a){return wXc(this.a,RD(a,42))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$2$Type',1926);feb(1927,1,nwe,YXc);_.Mb=function ZXc(a){return xXc(this.a,RD(a,42))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$3$Type',1927);feb(1928,1,nwe,$Xc);_.Mb=function _Xc(a){return RD(a,40).c.indexOf(IEe)==-1};sfb(LEe,'CompactionProcessor/lambda$4$Type',1928);feb(1929,1,{},aYc);_.Kb=function bYc(a){return yXc(this.a,RD(a,40))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$5$Type',1929);feb(1930,1,{},cYc);_.Kb=function dYc(a){return zXc(this.a,RD(a,40))};_.a=0;sfb(LEe,'CompactionProcessor/lambda$6$Type',1930);feb(1931,1,fye,eYc);_.Ne=function fYc(a,b){return AXc(this.a,RD(a,240),RD(b,240))};_.Fb=function gYc(a){return this===a};_.Oe=function hYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$7$Type',1931);feb(1932,1,fye,iYc);_.Ne=function jYc(a,b){return BXc(this.a,RD(a,40),RD(b,40))};_.Fb=function kYc(a){return this===a};_.Oe=function lYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$8$Type',1932);feb(1933,1,fye,mYc);_.Ne=function nYc(a,b){return CXc(RD(a,40),RD(b,40))};_.Fb=function oYc(a){return this===a};_.Oe=function pYc(){return new Frb(this)};sfb(LEe,'CompactionProcessor/lambda$9$Type',1933);feb(1921,1,QAe,rYc);_.Kf=function sYc(a,b){qYc(RD(a,121),b);};sfb(LEe,'DirectionProcessor',1921);feb(1913,1,QAe,vYc);_.Kf=function xYc(a,b){uYc(this,RD(a,121),b);};sfb(LEe,'FanProcessor',1913);feb(1937,1,QAe,zYc);_.Kf=function CYc(a,b){yYc(RD(a,121),b);};sfb(LEe,'GraphBoundsProcessor',1937);feb(1938,1,{},DYc);_.Ye=function EYc(a){return RD(a,40).e.a};sfb(LEe,'GraphBoundsProcessor/lambda$0$Type',1938);feb(1939,1,{},FYc);_.Ye=function GYc(a){return RD(a,40).e.b};sfb(LEe,'GraphBoundsProcessor/lambda$1$Type',1939);feb(1940,1,{},HYc);_.Ye=function IYc(a){return AYc(RD(a,40))};sfb(LEe,'GraphBoundsProcessor/lambda$2$Type',1940);feb(1941,1,{},JYc);_.Ye=function KYc(a){return BYc(RD(a,40))};sfb(LEe,'GraphBoundsProcessor/lambda$3$Type',1941);feb(262,22,{3:1,34:1,22:1,262:1,196:1},XYc);_.dg=function YYc(){switch(this.g){case 0:return new DZc;case 1:return new vYc;case 2:return new nZc;case 3:return new tZc;case 4:return new gZc;case 8:return new cZc;case 5:return new rYc;case 6:return new AZc;case 7:return new qXc;case 9:return new zYc;case 10:return new GZc;default:throw Adb(new agb(lBe+(this.f!=null?this.f:''+this.g)));}};var LYc,MYc,NYc,OYc,PYc,QYc,RYc,SYc,TYc,UYc,VYc;var u_=tfb(LEe,mBe,262,WI,$Yc,ZYc);var _Yc;feb(1920,1,QAe,cZc);_.Kf=function dZc(a,b){bZc(RD(a,121),b);};sfb(LEe,'LevelCoordinatesProcessor',1920);feb(1918,1,QAe,gZc);_.Kf=function hZc(a,b){eZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'LevelHeightProcessor',1918);feb(1919,1,Vve,iZc);_.Jc=function jZc(a){xgb(this,a);};_.Kc=function kZc(){return yob(),Qob(),Pob};sfb(LEe,'LevelHeightProcessor/1',1919);feb(1914,1,QAe,nZc);_.Kf=function oZc(a,b){lZc(this,RD(a,121),b);};sfb(LEe,'LevelProcessor',1914);feb(1915,1,nwe,pZc);_.Mb=function qZc(a){return Heb(TD(mQb(RD(a,40),(q$c(),n$c))))};sfb(LEe,'LevelProcessor/lambda$0$Type',1915);feb(1916,1,QAe,tZc);_.Kf=function uZc(a,b){rZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'NeighborsProcessor',1916);feb(1917,1,Vve,vZc);_.Jc=function wZc(a){xgb(this,a);};_.Kc=function xZc(){return yob(),Qob(),Pob};sfb(LEe,'NeighborsProcessor/1',1917);feb(1922,1,QAe,AZc);_.Kf=function BZc(a,b){yZc(this,RD(a,121),b);};_.a=0;sfb(LEe,'NodePositionProcessor',1922);feb(1912,1,QAe,DZc);_.Kf=function EZc(a,b){CZc(this,RD(a,121),b);};sfb(LEe,'RootProcessor',1912);feb(1942,1,QAe,GZc);_.Kf=function HZc(a,b){FZc(RD(a,121),b);};sfb(LEe,'Untreeifyer',1942);feb(392,22,{3:1,34:1,22:1,392:1},MZc);var IZc,JZc,KZc;var F_=tfb(PEe,'EdgeRoutingMode',392,WI,OZc,NZc);var PZc;var RZc,SZc,TZc,UZc,VZc,WZc,XZc,YZc,ZZc,$Zc,_Zc,a$c,b$c,c$c,d$c,e$c,f$c,g$c,h$c,i$c,j$c,k$c,l$c,m$c,n$c,o$c,p$c;feb(862,1,Eye,C$c);_.hf=function D$c(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,REe),''),YEe),'Turns on Tree compaction which decreases the size of the whole tree by placing nodes of multiple levels in one large level'),(Geb(),false)),(kid(),cid)),QI),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SEe),''),'Edge End Texture Length'),'Should be set to the length of the texture at the end of an edge. This value can be used to improve the Edge Routing.'),7),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TEe),''),'Tree Level'),'The index for the tree level the node is in'),sgb(0)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,UEe),''),YEe),'When set to a positive number this option will force the algorithm to place the node to the specified position within the trees layer if weighting is set to constraint'),sgb(-1)),gid),bJ),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VEe),''),'Weighting of Nodes'),'Which weighting to use when computing a node order.'),A$c),eid),J_),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WEe),''),'Edge Routing Mode'),'Chooses an Edge Routing algorithm.'),u$c),eid),F_),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XEe),''),'Search Order'),'Which search order to use when computing a spanning tree.'),x$c),eid),K_),xsb(Whd))));i_c((new j_c,a));};var r$c,s$c,t$c,u$c,v$c,w$c,x$c,y$c,z$c,A$c;sfb(PEe,'MrTreeMetaDataProvider',862);feb(1006,1,Eye,j_c);_.hf=function k_c(a){i_c(a);};var E$c,F$c,G$c,H$c,I$c,J$c,K$c,L$c,M$c,N$c,O$c,P$c,Q$c,R$c,S$c,T$c,U$c,V$c,W$c,X$c,Y$c,Z$c,$$c,_$c,a_c,b_c,c_c,d_c,e_c,f_c,g_c;sfb(PEe,'MrTreeOptions',1006);feb(1007,1,{},l_c);_.sf=function m_c(){var a;return a=new fWc,a};_.tf=function n_c(a){};sfb(PEe,'MrTreeOptions/MrtreeFactory',1007);feb(353,22,{3:1,34:1,22:1,353:1},t_c);var o_c,p_c,q_c,r_c;var J_=tfb(PEe,'OrderWeighting',353,WI,v_c,u_c);var w_c;feb(433,22,{3:1,34:1,22:1,433:1},B_c);var y_c,z_c;var K_=tfb(PEe,'TreeifyingOrder',433,WI,D_c,C_c);var E_c;feb(1486,1,nEe,N_c);_.rg=function O_c(a){return RD(a,121),G_c};_.Kf=function P_c(a,b){M_c(this,RD(a,121),b);};var G_c;sfb('org.eclipse.elk.alg.mrtree.p1treeify','DFSTreeifyer',1486);feb(1487,1,nEe,V_c);_.rg=function W_c(a){return RD(a,121),Q_c};_.Kf=function $_c(a,b){U_c(this,RD(a,121),b);};var Q_c;sfb(aFe,'NodeOrderer',1487);feb(1494,1,{},a0c);_.td=function b0c(a){return __c(a)};sfb(aFe,'NodeOrderer/0methodref$lambda$6$Type',1494);feb(1488,1,nwe,c0c);_.Mb=function d0c(a){return R_c(),Heb(TD(mQb(RD(a,40),(q$c(),n$c))))};sfb(aFe,'NodeOrderer/lambda$0$Type',1488);feb(1489,1,nwe,e0c);_.Mb=function f0c(a){return R_c(),RD(mQb(RD(a,40),(h_c(),W$c)),17).a<0};sfb(aFe,'NodeOrderer/lambda$1$Type',1489);feb(1490,1,nwe,g0c);_.Mb=function h0c(a){return X_c(this.a,RD(a,40))};sfb(aFe,'NodeOrderer/lambda$2$Type',1490);feb(1491,1,nwe,i0c);_.Mb=function j0c(a){return Y_c(this.a,RD(a,40))};sfb(aFe,'NodeOrderer/lambda$3$Type',1491);feb(1492,1,fye,k0c);_.Ne=function l0c(a,b){return Z_c(RD(a,40),RD(b,40))};_.Fb=function m0c(a){return this===a};_.Oe=function n0c(){return new Frb(this)};sfb(aFe,'NodeOrderer/lambda$4$Type',1492);feb(1493,1,nwe,o0c);_.Mb=function p0c(a){return R_c(),RD(mQb(RD(a,40),(q$c(),XZc)),17).a!=0};sfb(aFe,'NodeOrderer/lambda$5$Type',1493);feb(1495,1,nEe,x0c);_.rg=function y0c(a){return RD(a,121),q0c};_.Kf=function z0c(a,b){v0c(this,RD(a,121),b);};_.b=0;var q0c;sfb('org.eclipse.elk.alg.mrtree.p3place','NodePlacer',1495);feb(1496,1,nEe,J0c);_.rg=function K0c(a){return RD(a,121),A0c};_.Kf=function Y0c(a,b){I0c(RD(a,121),b);};var A0c;var o0=sfb(bFe,'EdgeRouter',1496);feb(1498,1,fye,Z0c);_.Ne=function $0c(a,b){return hgb(RD(a,17).a,RD(b,17).a)};_.Fb=function _0c(a){return this===a};_.Oe=function a1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/0methodref$compare$Type',1498);feb(1503,1,{},b1c);_.Ye=function c1c(a){return Kfb(UD(a))};sfb(bFe,'EdgeRouter/1methodref$doubleValue$Type',1503);feb(1505,1,fye,d1c);_.Ne=function e1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function f1c(a){return this===a};_.Oe=function g1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/2methodref$compare$Type',1505);feb(1507,1,fye,h1c);_.Ne=function i1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function j1c(a){return this===a};_.Oe=function k1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/3methodref$compare$Type',1507);feb(1509,1,{},l1c);_.Ye=function m1c(a){return Kfb(UD(a))};sfb(bFe,'EdgeRouter/4methodref$doubleValue$Type',1509);feb(1511,1,fye,n1c);_.Ne=function o1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function p1c(a){return this===a};_.Oe=function q1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/5methodref$compare$Type',1511);feb(1513,1,fye,r1c);_.Ne=function s1c(a,b){return Qfb(Kfb(UD(a)),Kfb(UD(b)))};_.Fb=function t1c(a){return this===a};_.Oe=function u1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/6methodref$compare$Type',1513);feb(1497,1,{},v1c);_.Kb=function w1c(a){return B0c(),RD(mQb(RD(a,40),(h_c(),f_c)),17)};sfb(bFe,'EdgeRouter/lambda$0$Type',1497);feb(1508,1,{},x1c);_.Kb=function y1c(a){return L0c(RD(a,40))};sfb(bFe,'EdgeRouter/lambda$11$Type',1508);feb(1510,1,{},z1c);_.Kb=function A1c(a){return M0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$13$Type',1510);feb(1512,1,{},B1c);_.Kb=function C1c(a){return N0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$15$Type',1512);feb(1514,1,fye,D1c);_.Ne=function E1c(a,b){return O0c(RD(a,65),RD(b,65))};_.Fb=function F1c(a){return this===a};_.Oe=function G1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$17$Type',1514);feb(1515,1,fye,H1c);_.Ne=function I1c(a,b){return P0c(RD(a,65),RD(b,65))};_.Fb=function J1c(a){return this===a};_.Oe=function K1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$18$Type',1515);feb(1516,1,fye,L1c);_.Ne=function M1c(a,b){return Q0c(RD(a,65),RD(b,65))};_.Fb=function N1c(a){return this===a};_.Oe=function O1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$19$Type',1516);feb(1499,1,nwe,P1c);_.Mb=function Q1c(a){return R0c(this.a,RD(a,40))};_.a=0;sfb(bFe,'EdgeRouter/lambda$2$Type',1499);feb(1517,1,fye,R1c);_.Ne=function S1c(a,b){return S0c(RD(a,65),RD(b,65))};_.Fb=function T1c(a){return this===a};_.Oe=function U1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$20$Type',1517);feb(1500,1,fye,V1c);_.Ne=function W1c(a,b){return T0c(RD(a,40),RD(b,40))};_.Fb=function X1c(a){return this===a};_.Oe=function Y1c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$3$Type',1500);feb(1501,1,fye,Z1c);_.Ne=function $1c(a,b){return U0c(RD(a,40),RD(b,40))};_.Fb=function _1c(a){return this===a};_.Oe=function a2c(){return new Frb(this)};sfb(bFe,'EdgeRouter/lambda$4$Type',1501);feb(1502,1,{},b2c);_.Kb=function c2c(a){return V0c(RD(a,40))};sfb(bFe,'EdgeRouter/lambda$5$Type',1502);feb(1504,1,{},d2c);_.Kb=function e2c(a){return W0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$7$Type',1504);feb(1506,1,{},f2c);_.Kb=function g2c(a){return X0c(this.b,this.a,RD(a,40))};_.a=0;_.b=0;sfb(bFe,'EdgeRouter/lambda$9$Type',1506);feb(675,1,{675:1},i2c);_.e=0;_.f=false;_.g=false;sfb(bFe,'MultiLevelEdgeNodeNodeGap',675);feb(1943,1,fye,l2c);_.Ne=function m2c(a,b){return j2c(RD(a,240),RD(b,240))};_.Fb=function n2c(a){return this===a};_.Oe=function o2c(){return new Frb(this)};sfb(bFe,'MultiLevelEdgeNodeNodeGap/lambda$0$Type',1943);feb(1944,1,fye,p2c);_.Ne=function q2c(a,b){return k2c(RD(a,240),RD(b,240))};_.Fb=function r2c(a){return this===a};_.Oe=function s2c(){return new Frb(this)};sfb(bFe,'MultiLevelEdgeNodeNodeGap/lambda$1$Type',1944);var t2c;feb(501,22,{3:1,34:1,22:1,501:1,188:1,196:1},z2c);_.dg=function B2c(){return y2c(this)};_.qg=function A2c(){return y2c(this)};var v2c,w2c;var s0=tfb(cFe,'RadialLayoutPhases',501,WI,D2c,C2c);var E2c;feb(1113,205,oze,H2c);_.rf=function I2c(a,b){var c,d,e,f,g,h;c=G2c(this,a);b.Ug('Radial layout',c.c.length);Heb(TD(Gxd(a,($4c(),N4c))))||RFb((d=new SFb((lud(),new zud(a))),d));h=K2c(a);Ixd(a,(u2c(),t2c),h);if(!h){throw Adb(new agb('The given graph is not a tree!'))}e=Kfb(UD(Gxd(a,S4c)));e==0&&(e=J2c(a));Ixd(a,S4c,e);for(g=new Anb(G2c(this,a));g.a=3){v=RD(QHd(t,0),27);w=RD(QHd(t,1),27);f=0;while(f+2=v.f+w.f+k||w.f>=u.f+v.f+k){B=true;break}else {++f;}}}else {B=true;}if(!B){m=t.i;for(h=new dMd(t);h.e!=h.i.gc();){g=RD(bMd(h),27);Ixd(g,(umd(),Rld),sgb(m));--m;}crd(a,new Oqd);b.Vg();return}c=(Sed(this.a),Ved(this.a,(f6c(),c6c),RD(Gxd(a,V7c),188)),Ved(this.a,d6c,RD(Gxd(a,M7c),188)),Ved(this.a,e6c,RD(Gxd(a,S7c),188)),Ped(this.a,(D=new ufd,pfd(D,c6c,(z6c(),y6c)),pfd(D,d6c,x6c),Heb(TD(Gxd(a,B7c)))&&pfd(D,c6c,w6c),D)),Qed(this.a,a));j=1/c.c.length;for(o=new Anb(c);o.a0&&vjd((BFb(c-1,b.length),b.charCodeAt(c-1)),ZAe)){--c;}if(e>=c){throw Adb(new agb('The given string does not contain any numbers.'))}f=vhb((AFb(e,c,b.length),b.substr(e,c-e)),',|;|\r|\n');if(f.length!=2){throw Adb(new agb('Exactly two numbers are expected, '+f.length+' were found.'))}try{this.a=Neb(Dhb(f[0]));this.b=Neb(Dhb(f[1]));}catch(a){a=zdb(a);if(ZD(a,130)){d=a;throw Adb(new agb($Ae+d))}else throw Adb(a)}};_.Ib=function yjd(){return '('+this.a+','+this.b+')'};_.a=0;_.b=0;var l3=sfb(_Ae,'KVector',8);feb(75,67,{3:1,4:1,20:1,31:1,56:1,16:1,67:1,15:1,75:1,423:1},Ejd,Fjd,Gjd);_.Pc=function Jjd(){return Djd(this)};_.cg=function Hjd(b){var c,d,e,f,g,h;e=vhb(b,',|;|\\(|\\)|\\[|\\]|\\{|\\}| |\t|\n');Xub(this);try{d=0;g=0;f=0;h=0;while(d0){g%2==0?(f=Neb(e[d])):(h=Neb(e[d]));g>0&&g%2!=0&&Mub(this,new rjd(f,h));++g;}++d;}}catch(a){a=zdb(a);if(ZD(a,130)){c=a;throw Adb(new agb('The given string does not match the expected format for vectors.'+c))}else throw Adb(a)}};_.Ib=function Kjd(){var a,b,c;a=new dib('(');b=Sub(this,0);while(b.b!=b.d.c){c=RD(evb(b),8);Zhb(a,c.a+','+c.b);b.b!=b.d.c&&(a.a+='; ',a);}return (a.a+=')',a).a};var k3=sfb(_Ae,'KVectorChain',75);feb(255,22,{3:1,34:1,22:1,255:1},Sjd);var Ljd,Mjd,Njd,Ojd,Pjd,Qjd;var n3=tfb(JGe,'Alignment',255,WI,Ujd,Tjd);var Vjd;feb(991,1,Eye,jkd);_.hf=function kkd(a){ikd(a);};var Xjd,Yjd,Zjd,$jd,_jd,akd,bkd,ckd,dkd,ekd,fkd,gkd;sfb(JGe,'BoxLayouterOptions',991);feb(992,1,{},lkd);_.sf=function mkd(){var a;return a=new jrd,a};_.tf=function nkd(a){};sfb(JGe,'BoxLayouterOptions/BoxFactory',992);feb(298,22,{3:1,34:1,22:1,298:1},vkd);var okd,pkd,qkd,rkd,skd,tkd;var q3=tfb(JGe,'ContentAlignment',298,WI,xkd,wkd);var ykd;feb(699,1,Eye,vmd);_.hf=function wmd(a){Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,OGe),''),'Layout Algorithm'),'Select a specific layout algorithm.'),(kid(),iid)),qJ),xsb((Yhd(),Whd)))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,PGe),''),'Resolved Layout Algorithm'),'Meta data associated with the selected algorithm.'),hid),D2),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MDe),''),'Alignment'),'Alignment of the selected node relative to other nodes; the exact meaning depends on the used algorithm.'),Ckd),eid),n3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,Dze),''),'Aspect Ratio'),'The desired aspect ratio of the drawing, that is the quotient of width by height.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,QGe),''),'Bend Points'),"A fixed list of bend points for the edge. This is used by the 'Fixed Layout' algorithm to specify a pre-defined routing for an edge. The vector chain must include the source point, any bend points, and the target point, so it must have at least two points."),hid),k3),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YDe),''),'Content Alignment'),'Specifies how the content of a node are aligned. Each node can individually control the alignment of its contents. I.e. if a node should be aligned top left in its parent node, the parent node should specify that option.'),Lkd),fid),q3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,LDe),''),'Debug Mode'),'Whether additional debug information shall be generated.'),(Geb(),false)),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,PDe),''),eze),'Overall direction of edges: horizontal (right / left) or vertical (down / up).'),Okd),eid),s3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kDe),''),'Edge Routing'),'What kind of edge routing style should be applied for the content of a parent node. Algorithms may also set this option to single edges in order to mark them as splines. The bend point list of edges with this option set to SPLINES must be interpreted as control points for a piecewise cubic spline.'),Tkd),eid),u3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,MGe),''),'Expand Nodes'),'If active, nodes are expanded to fill the area of their parent.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fDe),''),'Hierarchy Handling'),"Determines whether separate layout runs are triggered for different compound nodes in a hierarchical graph. Setting a node's hierarchy handling to `INCLUDE_CHILDREN` will lay out that node and all of its descendants in a single layout run, until a descendant is encountered which has its hierarchy handling set to `SEPARATE_CHILDREN`. In general, `SEPARATE_CHILDREN` will ensure that a new layout run is triggered for a node with that setting. Including multiple levels of hierarchy in a single layout run may allow cross-hierarchical edges to be laid out properly. If the root node is set to `INHERIT` (or not set at all), the default behavior is `SEPARATE_CHILDREN`."),Ykd),eid),y3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Eze),''),'Padding'),"The padding to be left to a parent element's border when placing child elements. This can also serve as an output option of a layout algorithm if node size calculation is setup appropriately."),uld),hid),i3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dAe),''),'Interactive'),'Whether the algorithm should be run in interactive mode for the content of a parent node. What this means exactly depends on how the specific algorithm interprets this option. Usually in the interactive mode algorithms try to modify the current layout as little as possible.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iEe),''),'interactive Layout'),'Whether the graph should be changeable interactively and by setting constraints'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gAe),''),'Omit Node Micro Layout'),"Node micro layout comprises the computation of node dimensions (if requested), the placement of ports and their labels, and the placement of node labels. The functionality is implemented independent of any specific layout algorithm and shouldn't have any negative impact on the layout algorithm's performance itself. Yet, if any unforeseen behavior occurs, this option allows to deactivate the micro layout."),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eAe),''),'Port Constraints'),'Defines constraints of the position of the ports of a node.'),Ild),eid),C3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,fEe),''),'Position'),"The position of a node, port, or label. This is used by the 'Fixed Layout' algorithm to specify a pre-defined position."),hid),l3),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,$ze),''),'Priority'),'Defines the priority of an object; its meaning depends on the specific layout algorithm and the context where it is used.'),gid),bJ),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,bAe),''),'Randomization Seed'),'Seed used for pseudo-random number generators to control the layout algorithm. If the value is 0, the seed shall be determined pseudo-randomly (e.g. from the system time).'),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cAe),''),'Separate Connected Components'),'Whether each connected component should be processed separately.'),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZDe),''),'Junction Points'),'This option is not used as option, but as output of the layout algorithms. It is attached to edges and determines the points where junction symbols should be drawn in order to represent hyperedges with orthogonal routing. Whether such points are computed depends on the chosen layout algorithm and edge routing style. The points are put into the vector chain with no specific order.'),dld),hid),k3),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aEe),''),'Comment Box'),'Whether the node should be regarded as a comment box instead of a regular node. In that case its placement should be similar to how labels are handled. Any edges incident to a comment box specify to which graph elements the comment is related.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bEe),''),'Hypernode'),'Whether the node should be handled as a hypernode.'),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,RGe),''),'Label Manager'),"Label managers can shorten labels upon a layout algorithm's request."),hid),g3),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gEe),''),'Margins'),"Margins define additional space around the actual bounds of a graph element. For instance, ports or labels being placed on the outside of a node's border might introduce such a margin. The margin is used to guarantee non-overlap of other graph elements with those ports or labels."),fld),hid),h3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,JDe),''),'No Layout'),"No layout is done for the associated element. This is used to mark parts of a diagram to avoid their inclusion in the layout graph, or to mark parts of the layout graph to prevent layout engines from processing them. If you wish to exclude the contents of a compound node from automatic layout, while the node itself is still considered on its own layer, use the 'Fixed Layout' algorithm for that node."),false),cid),QI),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd,Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SGe),''),'Scale Factor'),"The scaling factor to be applied to the corresponding node in recursive layout. It causes the corresponding node's size to be adjusted, and its ports and labels to be sized and placed accordingly after the layout of that node has been determined (and before the node itself and its siblings are arranged). The scaling is not reverted afterwards, so the resulting layout graph contains the adjusted size and position data. This option is currently not supported if 'Layout Hierarchy' is set."),1),did),VI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,TGe),''),'Child Area Width'),'The width of the area occupied by the laid out children of a node.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,UGe),''),'Child Area Height'),'The height of the area occupied by the laid out children of a node.'),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,mAe),''),yGe),"Turns topdown layout on and off. If this option is enabled, hierarchical layout will be computed first for the root node and then for its children recursively. Layouts are then scaled down to fit the area provided by their parents. Graphs must follow a certain structure for topdown layout to work properly. {@link TopdownNodeTypes.PARALLEL_NODE} nodes must have children of type {@link TopdownNodeTypes.HIERARCHICAL_NODE} and must define {@link topdown.hierarchicalNodeWidth} and {@link topdown.hierarchicalNodeAspectRatio} for their children. Furthermore they need to be laid out using an algorithm that is a {@link TopdownLayoutProvider}. Hierarchical nodes can also be parents of other hierarchical nodes and can optionally use a {@link TopdownSizeApproximator} to dynamically set sizes during topdown layout. In this case {@link topdown.hierarchicalNodeWidth} and {@link topdown.hierarchicalNodeAspectRatio} should be set on the node itself rather than the parent. The values are then used by the size approximator as base values. Hierarchical nodes require the layout option {@link nodeSize.fixedGraphSize} to be true to prevent the algorithm used there from resizing the hierarchical node. This option is not supported if 'Hierarchy Handling' is set to 'INCLUDE_CHILDREN'"),false),cid),QI),xsb(Whd))));zgd(a,mAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,VGe),''),'Animate'),'Whether the shift from the old layout to the new computed layout shall be animated.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,WGe),''),'Animation Time Factor'),"Factor for computation of animation time. The higher the value, the longer the animation time. If the value is 0, the resulting time is always equal to the minimum defined by 'Minimal Animation Time'."),sgb(100)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,XGe),''),'Layout Ancestors'),'Whether the hierarchy levels on the path from the selected element to the root of the diagram shall be included in the layout process.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,YGe),''),'Maximal Animation Time'),'The maximal time for animations, in milliseconds.'),sgb(4000)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ZGe),''),'Minimal Animation Time'),'The minimal time for animations, in milliseconds.'),sgb(400)),gid),bJ),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$Ge),''),'Progress Bar'),'Whether a progress bar shall be displayed during layout computations.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_Ge),''),'Validate Graph'),'Whether the graph shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aHe),''),'Validate Options'),'Whether layout options shall be validated before any layout algorithm is applied. If this option is enabled and at least one error is found, the layout process is aborted and a message is shown to the user.'),true),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,bHe),''),'Zoom to Fit'),'Whether the zoom level shall be set to view the whole diagram after layout.'),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NGe),'box'),'Box Layout Mode'),'Configures the packing mode used by the {@link BoxLayoutProvider}. If SIMPLE is not required (neither priorities are used nor the interactive mode), GROUP_DEC can improve the packing and decrease the area. GROUP_MIXED and GROUP_INC may, in very specific scenarios, work better.'),Gkd),eid),R3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,xDe),lDe),'Comment Comment Spacing'),'Spacing to be preserved between a comment box and other comment boxes connected to the same node. The space left between comment boxes of different nodes is controlled by the node-node spacing.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,yDe),lDe),'Comment Node Spacing'),'Spacing to be preserved between a node and its connected comment boxes. The space left between a node and the comments of another node is controlled by the node-node spacing.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Bze),lDe),'Components Spacing'),"Spacing to be preserved between pairs of connected components. This option is only relevant if 'separateConnectedComponents' is activated."),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,zDe),lDe),'Edge Spacing'),'Spacing to be preserved between any two edges. Note that while this can somewhat easily be satisfied for the segments of orthogonally drawn edges, it is harder for general polylines or splines.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,aAe),lDe),'Edge Label Spacing'),"The minimal distance to be preserved between a label and the edge it is associated with. Note that the placement of a label is influenced by the 'edgelabels.placement' option."),2),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ADe),lDe),'Edge Node Spacing'),'Spacing to be preserved between nodes and edges.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,BDe),lDe),'Label Spacing'),'Determines the amount of space to be left between two labels of the same graph element.'),0),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,EDe),lDe),'Label Node Spacing'),"Spacing to be preserved between labels and the border of node they are associated with. Note that the placement of a label is influenced by the 'nodelabels.placement' option."),5),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CDe),lDe),'Horizontal spacing between Label and Port'),"Horizontal spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,DDe),lDe),'Vertical spacing between Label and Port'),"Vertical spacing to be preserved between labels and the ports they are associated with. Note that the placement of a label is influenced by the 'portlabels.placement' option."),1),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,_ze),lDe),'Node Spacing'),'The minimal distance to be preserved between each two nodes.'),20),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,FDe),lDe),'Node Self Loop Spacing'),'Spacing to be preserved between a node and its self loops.'),10),did),VI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,GDe),lDe),'Port Spacing'),'Spacing between pairs of ports of the same node.'),10),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,HDe),lDe),'Individual Spacing'),"Allows to specify individual spacing values for graph elements that shall be different from the value specified for the element's parent."),hid),l4),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Thd,Xhd,Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hEe),lDe),'Additional Port Space'),'Additional space around the sets of ports on each node side. For each side of a node, this option can reserve additional space before and after the ports on each side. For example, a top spacing of 20 makes sure that the first port on the western and eastern side is 20 units away from the northern border.'),imd),hid),h3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,eEe),hHe),'Layout Partition'),'Partition to which the node belongs. This requires Layout Partitioning to be active. Nodes with lower partition IDs will appear to the left of nodes with higher partition IDs (assuming a left-to-right layout direction).'),gid),bJ),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,eEe,dEe,yld);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,dEe),hHe),'Layout Partitioning'),'Whether to activate partitioned layout. This will allow to group nodes through the Layout Partition option. a pair of nodes with different partition indices is then placed such that the node with lower index is placed to the left of the other node (with left-to-right layout direction). Depending on the layout algorithm, this may only be guaranteed to work if all nodes have a layout partition configured, or at least if edges that cross partitions are not part of a partition-crossing cycle.'),wld),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,QDe),iHe),'Node Label Padding'),'Define padding for node labels that are placed inside of a node.'),hld),hid),i3),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,kAe),iHe),'Node Label Placement'),"Hints for where node labels are to be placed; if empty, the node label's position is not modified."),jld),fid),A3),ysb(Vhd,cD(WC(d3,1),jwe,170,0,[Uhd])))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,TDe),jHe),'Port Alignment'),'Defines the default port distribution for a node. May be overridden for each side individually.'),Ald),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,UDe),jHe),'Port Alignment (North)'),"Defines how ports on the northern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,VDe),jHe),'Port Alignment (South)'),"Defines how ports on the southern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,WDe),jHe),'Port Alignment (West)'),"Defines how ports on the western side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,XDe),jHe),'Port Alignment (East)'),"Defines how ports on the eastern side are placed, overriding the node's general port alignment."),eid),B3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,jAe),kHe),'Node Size Constraints'),"What should be taken into account when calculating a node's size. Empty size constraints specify that a node's size is already fixed and should not be changed."),lld),fid),H3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,iAe),kHe),'Node Size Options'),'Options modifying the behavior of the size constraints set on a node. Each member of the set specifies something that should be taken into account when calculating node sizes. The empty set corresponds to no further modifications.'),qld),fid),I3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,CAe),kHe),'Node Size Minimum'),'The minimal size to which a node can be reduced.'),old),hid),l3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,hAe),kHe),'Fixed Graph Size'),"By default, the fixed layout provider will enlarge a graph until it is large enough to contain its children. If this option is set, it won't do so."),false),cid),QI),xsb(Whd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,$De),vDe),'Edge Label Placement'),'Gives a hint on where to put edge labels.'),Rkd),eid),t3),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fAe),vDe),'Inline Edge Labels'),"If true, an edge label is placed directly on its edge. May only apply to center edge labels. This kind of label placement is only advisable if the label's rendering is such that it is not crossed by its edge and thus stays legible."),false),cid),QI),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cHe),'font'),'Font Name'),'Font name used for a label.'),iid),qJ),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,dHe),'font'),'Font Size'),'Font size used for a label.'),gid),bJ),xsb(Uhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,cEe),lHe),'Port Anchor Offset'),'The offset to the port position where connections shall be attached.'),hid),l3),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,_De),lHe),'Port Index'),"The index of a port in the fixed order around a node. The order is assumed as clockwise, starting with the leftmost port on the top side. This option must be set if 'Port Constraints' is set to FIXED_ORDER and no specific positions are given for the ports. Additionally, the option 'Port Side' must be defined in this case."),gid),bJ),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,KDe),lHe),'Port Side'),"The side of a node on which a port is situated. This option must be set if 'Port Constraints' is set to FIXED_SIDE or FIXED_ORDER and no specific positions are given for the ports."),Pld),eid),E3),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Khd(Ohd(Lhd(Mhd(new Shd,IDe),lHe),'Port Border Offset'),"The offset of ports on the node border. With a positive offset the port is moved outside of the node, while with a negative offset the port is moved towards the inside. An offset of 0 means that the port is placed directly on the node border, i.e. if the port side is north, the port's south border touches the nodes's north border; if the port side is east, the port's west border touches the nodes's east border; if the port side is south, the port's north border touches the node's south border; if the port side is west, the port's east border touches the node's west border."),did),VI),xsb(Xhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,lAe),mHe),'Port Label Placement'),"Decides on a placement method for port labels; if empty, the node label's position is not modified."),Mld),fid),D3),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,RDe),mHe),'Port Labels Next to Port'),"Use 'portLabels.placement': NEXT_TO_PORT_OF_POSSIBLE."),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,SDe),mHe),'Treat Port Labels as Group'),'If this option is true (default), the labels of a port will be treated as a group when it comes to centering them next to their port. If this option is false, only the first label will be centered next to the port, with the others being placed below. This only applies to labels of eastern and western ports and will have no effect if labels are not placed next to their port.'),true),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,nAe),nHe),'Topdown Scale Factor'),"The scaling factor to be applied to the nodes laid out within the node in recursive topdown layout. The difference to 'Scale Factor' is that the node itself is not scaled. This value has to be set on hierarchical nodes."),1),did),VI),xsb(Whd))));zgd(a,nAe,qAe,rmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,eHe),nHe),'Topdown Size Approximator'),'The size approximator to be used to set sizes of hierarchical nodes during topdown layout. The default value is null, which results in nodes keeping whatever size is defined for them e.g. through parent parallel node or by manually setting the size.'),null),eid),M3),xsb(Vhd))));zgd(a,eHe,qAe,tmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,oAe),nHe),'Topdown Hierarchical Node Width'),'The fixed size of a hierarchical node when using topdown layout. If this value is set on a parallel node it applies to its children, when set on a hierarchical node it applies to the node itself.'),150),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,oAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,pAe),nHe),'Topdown Hierarchical Node Aspect Ratio'),'The fixed aspect ratio of a hierarchical node when using topdown layout. Default is 1/sqrt(2). If this value is set on a parallel node it applies to its children, when set on a hierarchical node it applies to the node itself.'),1.414),did),VI),ysb(Whd,cD(WC(d3,1),jwe,170,0,[Vhd])))));zgd(a,pAe,qAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,qAe),nHe),'Topdown Node Type'),'The different node types used for topdown layout. If the node type is set to {@link TopdownNodeTypes.PARALLEL_NODE} the algorithm must be set to a {@link TopdownLayoutProvider} such as {@link TopdownPacking}. The {@link nodeSize.fixedGraphSize} option is technically only required for hierarchical nodes.'),null),eid),J3),xsb(Vhd))));zgd(a,qAe,hAe,null);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,fHe),nHe),'Topdown Scale Cap'),'Determines the upper limit for the topdown scale factor. The default value is 1.0 which ensures that nested children never end up appearing larger than their parents in terms of unit sizes such as the font size. If the limit is larger, nodes will fully utilize the available space, but it is counteriniuitive for inner nodes to have a larger scale than outer nodes.'),1),did),VI),xsb(Whd))));zgd(a,fHe,qAe,pmd);Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,NDe),oHe),'Activate Inside Self Loops'),"Whether this node allows to route self loops inside of it instead of around it. If set to true, this will make the node a compound node if it isn't already, and will require the layout algorithm to support compound nodes with hierarchical ports."),false),cid),QI),xsb(Vhd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,ODe),oHe),'Inside Self Loop'),'Whether a self loop should be routed inside a node instead of around that node.'),false),cid),QI),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,Cze),'edge'),'Edge Thickness'),'The thickness of an edge. This is a hint on the line width used to draw an edge, possibly requiring more space to be reserved for it.'),1),did),VI),xsb(Thd))));Egd(a,new Ahd(Qhd(Phd(Rhd(Jhd(Khd(Ohd(Lhd(Mhd(new Shd,gHe),'edge'),'Edge Type'),'The type of an edge. This is usually used for UML class diagrams, where associations must be handled differently from generalizations.'),Vkd),eid),v3),xsb(Thd))));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,sxe),'Layered'),'The layer-based method was introduced by Sugiyama, Tagawa and Toda in 1981. It emphasizes the direction of edges by pointing as many edges as possible into the same direction. The nodes are arranged in layers, which are sometimes called "hierarchies", and then reordered such that the number of edge crossings is minimized. Afterwards, concrete coordinates are computed for the nodes and edge bend points.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.orthogonal'),'Orthogonal'),'Orthogonal methods that follow the "topology-shape-metrics" approach by Batini, Nardelli and Tamassia \'86. The first phase determines the topology of the drawing by applying a planarization technique, which results in a planar representation of the graph. The orthogonal shape is computed in the second phase, which aims at minimizing the number of edge bends, and is called orthogonalization. The third phase leads to concrete coordinates for nodes and edge bend points by applying a compaction method, thus defining the metrics.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,Zze),'Force'),'Layout algorithms that follow physical analogies by simulating a system of attractive and repulsive forces. The first successful method of this kind was proposed by Eades in 1984.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.circle'),'Circle'),'Circular layout algorithms emphasize cycles or biconnected components of a graph by arranging them in circles. This is useful if a drawing is desired where such components are clearly grouped, or where cycles are shown as prominent OPTIONS of the graph.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,$Ee),'Tree'),'Specialized layout methods for trees, i.e. acyclic graphs. The regular structure of graphs that have no undirected cycles can be emphasized using an algorithm of this type.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,'org.eclipse.elk.planar'),'Planar'),'Algorithms that require a planar or upward planar graph. Most of these algorithms are theoretically interesting, but not practically usable.')));Dgd(a,new fgd(mgd(ogd(ngd(new pgd,CFe),'Radial'),'Radial layout algorithms usually position the nodes of the graph on concentric circles.')));wnd((new xnd,a));ikd((new jkd,a));Gpd((new Hpd,a));};var Akd,Bkd,Ckd,Dkd,Ekd,Fkd,Gkd,Hkd,Ikd,Jkd,Kkd,Lkd,Mkd,Nkd,Okd,Pkd,Qkd,Rkd,Skd,Tkd,Ukd,Vkd,Wkd,Xkd,Ykd,Zkd,$kd,_kd,ald,bld,cld,dld,eld,fld,gld,hld,ild,jld,kld,lld,mld,nld,old,pld,qld,rld,sld,tld,uld,vld,wld,xld,yld,zld,Ald,Bld,Cld,Dld,Eld,Fld,Gld,Hld,Ild,Jld,Kld,Lld,Mld,Nld,Old,Pld,Qld,Rld,Sld,Tld,Uld,Vld,Wld,Xld,Yld,Zld,$ld,_ld,amd,bmd,cmd,dmd,emd,fmd,gmd,hmd,imd,jmd,kmd,lmd,mmd,nmd,omd,pmd,qmd,rmd,smd,tmd;sfb(JGe,'CoreOptions',699);feb(88,22,{3:1,34:1,22:1,88:1},Gmd);var xmd,ymd,zmd,Amd,Bmd;var s3=tfb(JGe,eze,88,WI,Imd,Hmd);var Jmd;feb(278,22,{3:1,34:1,22:1,278:1},Pmd);var Lmd,Mmd,Nmd;var t3=tfb(JGe,'EdgeLabelPlacement',278,WI,Rmd,Qmd);var Smd;feb(223,22,{3:1,34:1,22:1,223:1},Zmd);var Umd,Vmd,Wmd,Xmd;var u3=tfb(JGe,'EdgeRouting',223,WI,_md,$md);var and;feb(321,22,{3:1,34:1,22:1,321:1},jnd);var cnd,dnd,end,fnd,gnd,hnd;var v3=tfb(JGe,'EdgeType',321,WI,lnd,knd);var mnd;feb(989,1,Eye,xnd);_.hf=function ynd(a){wnd(a);};var ond,pnd,qnd,rnd,snd,tnd,und;sfb(JGe,'FixedLayouterOptions',989);feb(990,1,{},znd);_.sf=function And(){var a;return a=new btd,a};_.tf=function Bnd(a){};sfb(JGe,'FixedLayouterOptions/FixedFactory',990);feb(346,22,{3:1,34:1,22:1,346:1},Gnd);var Cnd,Dnd,End;var y3=tfb(JGe,'HierarchyHandling',346,WI,Ind,Hnd);var Jnd;feb(291,22,{3:1,34:1,22:1,291:1},Rnd);var Lnd,Mnd,Nnd,Ond;var z3=tfb(JGe,'LabelSide',291,WI,Tnd,Snd);var Und;feb(95,22,{3:1,34:1,22:1,95:1},eod);var Wnd,Xnd,Ynd,Znd,$nd,_nd,aod,bod,cod;var A3=tfb(JGe,'NodeLabelPlacement',95,WI,hod,god);var iod;feb(256,22,{3:1,34:1,22:1,256:1},qod);var kod,lod,mod,nod,ood;var B3=tfb(JGe,'PortAlignment',256,WI,sod,rod);var tod;feb(101,22,{3:1,34:1,22:1,101:1},Eod);var vod,wod,xod,yod,zod,Aod;var C3=tfb(JGe,'PortConstraints',101,WI,God,Fod);var Hod;feb(279,22,{3:1,34:1,22:1,279:1},Qod);var Jod,Kod,Lod,Mod,Nod,Ood;var D3=tfb(JGe,'PortLabelPlacement',279,WI,Uod,Tod);var Vod;feb(64,22,{3:1,34:1,22:1,64:1},upd);var Xod,Yod,Zod,$od,_od,apd,bpd,cpd,dpd,epd,fpd,gpd,hpd,ipd,jpd,kpd,lpd,mpd,npd,opd,ppd;var E3=tfb(JGe,'PortSide',64,WI,xpd,wpd);var ypd;feb(993,1,Eye,Hpd);_.hf=function Ipd(a){Gpd(a);};var Apd,Bpd,Cpd,Dpd,Epd;sfb(JGe,'RandomLayouterOptions',993);feb(994,1,{},Jpd);_.sf=function Kpd(){var a;return a=new eud,a};_.tf=function Lpd(a){};sfb(JGe,'RandomLayouterOptions/RandomFactory',994);feb(386,22,{3:1,34:1,22:1,386:1},Rpd);var Mpd,Npd,Opd,Ppd;var H3=tfb(JGe,'SizeConstraint',386,WI,Tpd,Spd);var Upd;feb(264,22,{3:1,34:1,22:1,264:1},eqd);var Wpd,Xpd,Ypd,Zpd,$pd,_pd,aqd,bqd,cqd;var I3=tfb(JGe,'SizeOptions',264,WI,gqd,fqd);var hqd;feb(280,22,{3:1,34:1,22:1,280:1},nqd);var jqd,kqd,lqd;var J3=tfb(JGe,'TopdownNodeTypes',280,WI,pqd,oqd);var qqd;feb(347,22,rHe);var sqd,tqd;var M3=tfb(JGe,'TopdownSizeApproximator',347,WI,xqd,wqd);feb(987,347,rHe,zqd);_.Tg=function Aqd(a){return yqd(a)};tfb(JGe,'TopdownSizeApproximator/1',987,M3,null,null);feb(988,347,rHe,Bqd);_.Tg=function Cqd(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D;c=RD(Gxd(b,(umd(),Tld)),143);A=(bvd(),o=new ACd,o);zxd(A,b);B=new Tsb;for(g=new dMd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));g.e!=g.i.gc();){e=RD(bMd(g),27);t=(n=new ACd,n);yCd(t,A);zxd(t,e);D=yqd(e);zyd(t,$wnd.Math.max(e.g,D.a),$wnd.Math.max(e.f,D.b));rtb(B.f,e,t);}for(f=new dMd((!b.a&&(b.a=new C5d(J4,b,10,11)),b.a));f.e!=f.i.gc();){e=RD(bMd(f),27);for(l=new dMd((!e.e&&(e.e=new Yie(G4,e,7,4)),e.e));l.e!=l.i.gc();){k=RD(bMd(l),74);v=RD(Wd(qtb(B.f,e)),27);w=RD(Wjb(B,QHd((!k.c&&(k.c=new Yie(E4,k,5,8)),k.c),0)),27);u=(m=new rzd,m);WGd((!u.b&&(u.b=new Yie(E4,u,4,7)),u.b),v);WGd((!u.c&&(u.c=new Yie(E4,u,5,8)),u.c),w);pzd(u,vCd(v));zxd(u,k);}}q=RD(ltd(c.f),205);try{q.rf(A,new ztd);mtd(c.f,q);}catch(a){a=zdb(a);if(ZD(a,103)){p=a;throw Adb(p)}else throw Adb(a)}Hxd(A,Ikd)||Hxd(A,Hkd)||psd(A);j=Kfb(UD(Gxd(A,Ikd)));i=Kfb(UD(Gxd(A,Hkd)));h=j/i;d=Kfb(UD(Gxd(A,lmd)))*$wnd.Math.sqrt((!A.a&&(A.a=new C5d(J4,A,10,11)),A.a).i);C=RD(Gxd(A,tld),107);s=C.b+C.c+1;r=C.d+C.a+1;return new rjd($wnd.Math.max(s,d),$wnd.Math.max(r,d/h))};tfb(JGe,'TopdownSizeApproximator/2',988,M3,null,null);var Dqd;feb(344,1,{871:1},Oqd);_.Ug=function Pqd(a,b){return Fqd(this,a,b)};_.Vg=function Qqd(){Hqd(this);};_.Wg=function Rqd(){return this.q};_.Xg=function Sqd(){return !this.f?null:Hob(this.f)};_.Yg=function Tqd(){return Hob(this.a)};_.Zg=function Uqd(){return this.p};_.$g=function Vqd(){return false};_._g=function Wqd(){return this.n};_.ah=function Xqd(){return this.p!=null&&!this.b};_.bh=function Yqd(a){var b;if(this.n){b=a;Rmb(this.f,b);}};_.dh=function Zqd(a,b){var c,d;this.n&&!!a&&Jqd(this,(c=new Zje,d=Rje(c,a),Yje(c),d),(ttd(),qtd));};_.eh=function $qd(a){var b;if(this.b){return null}else {b=Gqd(this,this.g);Mub(this.a,b);b.i=this;this.d=a;return b}};_.fh=function _qd(a){a>0&&!this.b&&Iqd(this,a);};_.b=false;_.c=0;_.d=-1;_.e=null;_.f=null;_.g=-1;_.j=false;_.k=false;_.n=false;_.o=0;_.q=0;_.r=0;sfb(jEe,'BasicProgressMonitor',344);feb(717,205,oze,jrd);_.rf=function nrd(a,b){crd(a,b);};sfb(jEe,'BoxLayoutProvider',717);feb(983,1,fye,prd);_.Ne=function qrd(a,b){return ord(this,RD(a,27),RD(b,27))};_.Fb=function rrd(a){return this===a};_.Oe=function srd(){return new Frb(this)};_.a=false;sfb(jEe,'BoxLayoutProvider/1',983);feb(163,1,{163:1},zrd,Ard);_.Ib=function Brd(){return this.c?zCd(this.c):Fe(this.b)};sfb(jEe,'BoxLayoutProvider/Group',163);feb(320,22,{3:1,34:1,22:1,320:1},Hrd);var Crd,Drd,Erd,Frd;var R3=tfb(jEe,'BoxLayoutProvider/PackingMode',320,WI,Jrd,Ird);var Krd;feb(984,1,fye,Mrd);_.Ne=function Nrd(a,b){return krd(RD(a,163),RD(b,163))};_.Fb=function Ord(a){return this===a};_.Oe=function Prd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$0$Type',984);feb(985,1,fye,Qrd);_.Ne=function Rrd(a,b){return lrd(RD(a,163),RD(b,163))};_.Fb=function Srd(a){return this===a};_.Oe=function Trd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$1$Type',985);feb(986,1,fye,Urd);_.Ne=function Vrd(a,b){return mrd(RD(a,163),RD(b,163))};_.Fb=function Wrd(a){return this===a};_.Oe=function Xrd(){return new Frb(this)};sfb(jEe,'BoxLayoutProvider/lambda$2$Type',986);feb(1384,1,{845:1},Yrd);_.Mg=function Zrd(a,b){return GCc(),!ZD(b,167)||ued((hed(),RD(a,167)),b)};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$0$Type',1384);feb(1385,1,Qve,$rd);_.Cd=function _rd(a){JCc(this.a,RD(a,149));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$1$Type',1385);feb(1386,1,Qve,asd);_.Cd=function bsd(a){RD(a,96);GCc();};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$2$Type',1386);feb(1390,1,Qve,csd);_.Cd=function dsd(a){KCc(this.a,RD(a,96));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$3$Type',1390);feb(1388,1,nwe,esd);_.Mb=function fsd(a){return LCc(this.a,this.b,RD(a,149))};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$4$Type',1388);feb(1387,1,nwe,gsd);_.Mb=function hsd(a){return NCc(this.a,this.b,RD(a,845))};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$5$Type',1387);feb(1389,1,Qve,isd);_.Cd=function jsd(a){MCc(this.a,this.b,RD(a,149));};sfb(jEe,'ElkSpacings/AbstractSpacingsBuilder/lambda$6$Type',1389);feb(947,1,{},Lsd);_.Kb=function Msd(a){return Ksd(a)};_.Fb=function Nsd(a){return this===a};sfb(jEe,'ElkUtil/lambda$0$Type',947);feb(948,1,Qve,Osd);_.Cd=function Psd(a){ysd(this.a,this.b,RD(a,74));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$1$Type',948);feb(949,1,Qve,Qsd);_.Cd=function Rsd(a){zsd(this.a,this.b,RD(a,166));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$2$Type',949);feb(950,1,Qve,Ssd);_.Cd=function Tsd(a){Asd(this.a,this.b,RD(a,135));};_.a=0;_.b=0;sfb(jEe,'ElkUtil/lambda$3$Type',950);feb(951,1,Qve,Usd);_.Cd=function Vsd(a){Bsd(this.a,RD(a,377));};sfb(jEe,'ElkUtil/lambda$4$Type',951);feb(325,1,{34:1,325:1},Xsd);_.Fd=function Ysd(a){return Wsd(this,RD(a,242))};_.Fb=function Zsd(a){var b;if(ZD(a,325)){b=RD(a,325);return this.a==b.a}return false};_.Hb=function $sd(){return eE(this.a)};_.Ib=function _sd(){return this.a+' (exclusive)'};_.a=0;sfb(jEe,'ExclusiveBounds/ExclusiveLowerBound',325);feb(1119,205,oze,btd);_.rf=function ctd(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B;b.Ug('Fixed Layout',1);f=RD(Gxd(a,(umd(),Skd)),223);l=0;m=0;for(s=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));s.e!=s.i.gc();){q=RD(bMd(s),27);B=RD(Gxd(q,(vnd(),und)),8);if(B){Byd(q,B.a,B.b);if(RD(Gxd(q,pnd),181).Hc((Qpd(),Mpd))){n=RD(Gxd(q,rnd),8);n.a>0&&n.b>0&&Esd(q,n.a,n.b,true,true);}}l=$wnd.Math.max(l,q.i+q.g);m=$wnd.Math.max(m,q.j+q.f);for(j=new dMd((!q.n&&(q.n=new C5d(I4,q,1,7)),q.n));j.e!=j.i.gc();){h=RD(bMd(j),135);B=RD(Gxd(h,und),8);!!B&&Byd(h,B.a,B.b);l=$wnd.Math.max(l,q.i+h.i+h.g);m=$wnd.Math.max(m,q.j+h.j+h.f);}for(v=new dMd((!q.c&&(q.c=new C5d(K4,q,9,9)),q.c));v.e!=v.i.gc();){u=RD(bMd(v),123);B=RD(Gxd(u,und),8);!!B&&Byd(u,B.a,B.b);w=q.i+u.i;A=q.j+u.j;l=$wnd.Math.max(l,w+u.g);m=$wnd.Math.max(m,A+u.f);for(i=new dMd((!u.n&&(u.n=new C5d(I4,u,1,7)),u.n));i.e!=i.i.gc();){h=RD(bMd(i),135);B=RD(Gxd(h,und),8);!!B&&Byd(h,B.a,B.b);l=$wnd.Math.max(l,w+h.i+h.g);m=$wnd.Math.max(m,A+h.j+h.f);}}for(e=new is(Mr(zGd(q).a.Kc(),new ir));gs(e);){c=RD(hs(e),74);k=atd(c);l=$wnd.Math.max(l,k.a);m=$wnd.Math.max(m,k.b);}for(d=new is(Mr(yGd(q).a.Kc(),new ir));gs(d);){c=RD(hs(d),74);if(vCd(JGd(c))!=a){k=atd(c);l=$wnd.Math.max(l,k.a);m=$wnd.Math.max(m,k.b);}}}if(f==(Ymd(),Umd)){for(r=new dMd((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a));r.e!=r.i.gc();){q=RD(bMd(r),27);for(d=new is(Mr(zGd(q).a.Kc(),new ir));gs(d);){c=RD(hs(d),74);g=tsd(c);g.b==0?Ixd(c,cld,null):Ixd(c,cld,g);}}}if(!Heb(TD(Gxd(a,(vnd(),qnd))))){t=RD(Gxd(a,snd),107);p=l+t.b+t.c;o=m+t.d+t.a;Esd(a,p,o,true,true);}b.Vg();};sfb(jEe,'FixedLayoutProvider',1119);feb(385,137,{3:1,423:1,385:1,96:1,137:1},dtd,etd);_.cg=function htd(b){var c,d,e,f,g,h,i,j,k;if(!b){return}try{j=vhb(b,';,;');for(g=j,h=0,i=g.length;h>16&Bwe|b^d<<16};_.Kc=function Ttd(){return new Vtd(this)};_.Ib=function Utd(){return this.a==null&&this.b==null?'pair(null,null)':this.a==null?'pair(null,'+jeb(this.b)+')':this.b==null?'pair('+jeb(this.a)+',null)':'pair('+jeb(this.a)+','+jeb(this.b)+')'};sfb(jEe,'Pair',42);feb(995,1,Ave,Vtd);_.Nb=function Wtd(a){Ztb(this,a);};_.Ob=function Xtd(){return !this.c&&(!this.b&&this.a.a!=null||this.a.b!=null)};_.Pb=function Ytd(){if(!this.c&&!this.b&&this.a.a!=null){this.b=true;return this.a.a}else if(!this.c&&this.a.b!=null){this.c=true;return this.a.b}throw Adb(new Dvb)};_.Qb=function Ztd(){this.c&&this.a.b!=null?(this.a.b=null):this.b&&this.a.a!=null&&(this.a.a=null);throw Adb(new cgb)};_.b=false;_.c=false;sfb(jEe,'Pair/1',995);feb(455,1,{455:1},$td);_.Fb=function _td(a){return Fvb(this.a,RD(a,455).a)&&Fvb(this.c,RD(a,455).c)&&Fvb(this.d,RD(a,455).d)&&Fvb(this.b,RD(a,455).b)};_.Hb=function aud(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.a,this.c,this.d,this.b]))};_.Ib=function bud(){return '('+this.a+pve+this.c+pve+this.d+pve+this.b+')'};sfb(jEe,'Quadruple',455);feb(1108,205,oze,eud);_.rf=function fud(a,b){var c,d,e,f,g;b.Ug('Random Layout',1);if((!a.a&&(a.a=new C5d(J4,a,10,11)),a.a).i==0){b.Vg();return}f=RD(Gxd(a,(Fpd(),Dpd)),17);!!f&&f.a!=0?(e=new Pwb(f.a)):(e=new Owb);c=Mfb(UD(Gxd(a,Apd)));g=Mfb(UD(Gxd(a,Epd)));d=RD(Gxd(a,Bpd),107);dud(a,e,c,g,d);b.Vg();};sfb(jEe,'RandomLayoutProvider',1108);feb(240,1,{240:1},gud);_.Fb=function hud(a){return Fvb(this.a,RD(a,240).a)&&Fvb(this.b,RD(a,240).b)&&Fvb(this.c,RD(a,240).c)};_.Hb=function iud(){return Tnb(cD(WC(jJ,1),rve,1,5,[this.a,this.b,this.c]))};_.Ib=function jud(){return '('+this.a+pve+this.b+pve+this.c+')'};sfb(jEe,'Triple',240);var kud;feb(562,1,{});_.Lf=function oud(){return new rjd(this.f.i,this.f.j)};_.of=function pud(a){if(hGd(a,(umd(),Gld))){return Gxd(this.f,mud)}return Gxd(this.f,a)};_.Mf=function qud(){return new rjd(this.f.g,this.f.f)};_.Nf=function rud(){return this.g};_.pf=function sud(a){return Hxd(this.f,a)};_.Of=function tud(a){Dyd(this.f,a.a);Eyd(this.f,a.b);};_.Pf=function uud(a){Cyd(this.f,a.a);Ayd(this.f,a.b);};_.Qf=function vud(a){this.g=a;};_.g=0;var mud;sfb(uHe,'ElkGraphAdapters/AbstractElkGraphElementAdapter',562);feb(563,1,{853:1},wud);_.Rf=function xud(){var a,b;if(!this.b){this.b=fv(iyd(this.a).i);for(b=new dMd(iyd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),135);Rmb(this.b,new Bud(a));}}return this.b};_.b=null;sfb(uHe,'ElkGraphAdapters/ElkEdgeAdapter',563);feb(289,562,{},zud);_.Sf=function Aud(){return yud(this)};_.a=null;sfb(uHe,'ElkGraphAdapters/ElkGraphAdapter',289);feb(640,562,{187:1},Bud);sfb(uHe,'ElkGraphAdapters/ElkLabelAdapter',640);feb(639,562,{695:1},Fud);_.Rf=function Iud(){return Cud(this)};_.Vf=function Jud(){var a;return a=RD(Gxd(this.f,(umd(),eld)),140),!a&&(a=new P2b),a};_.Xf=function Lud(){return Dud(this)};_.Zf=function Nud(a){var b;b=new S2b(a);Ixd(this.f,(umd(),eld),b);};_.$f=function Oud(a){Ixd(this.f,(umd(),tld),new B3b(a));};_.Tf=function Gud(){return this.d};_.Uf=function Hud(){var a,b;if(!this.a){this.a=new bnb;for(b=new is(Mr(yGd(RD(this.f,27)).a.Kc(),new ir));gs(b);){a=RD(hs(b),74);Rmb(this.a,new wud(a));}}return this.a};_.Wf=function Kud(){var a,b;if(!this.c){this.c=new bnb;for(b=new is(Mr(zGd(RD(this.f,27)).a.Kc(),new ir));gs(b);){a=RD(hs(b),74);Rmb(this.c,new wud(a));}}return this.c};_.Yf=function Mud(){return tCd(RD(this.f,27)).i!=0||Heb(TD(RD(this.f,27).of((umd(),$kd))))};_._f=function Pud(){Eud(this,(lud(),kud));};_.a=null;_.b=null;_.c=null;_.d=null;_.e=null;sfb(uHe,'ElkGraphAdapters/ElkNodeAdapter',639);feb(1284,562,{852:1},Rud);_.Rf=function Tud(){return Qud(this)};_.Uf=function Sud(){var a,b;if(!this.a){this.a=ev(RD(this.f,123).hh().i);for(b=new dMd(RD(this.f,123).hh());b.e!=b.i.gc();){a=RD(bMd(b),74);Rmb(this.a,new wud(a));}}return this.a};_.Wf=function Uud(){var a,b;if(!this.c){this.c=ev(RD(this.f,123).ih().i);for(b=new dMd(RD(this.f,123).ih());b.e!=b.i.gc();){a=RD(bMd(b),74);Rmb(this.c,new wud(a));}}return this.c};_.ag=function Vud(){return RD(RD(this.f,123).of((umd(),Old)),64)};_.bg=function Wud(){var a,b,c,d,e,f,g,h;d=MCd(RD(this.f,123));for(c=new dMd(RD(this.f,123).ih());c.e!=c.i.gc();){a=RD(bMd(c),74);for(h=new dMd((!a.c&&(a.c=new Yie(E4,a,5,8)),a.c));h.e!=h.i.gc();){g=RD(bMd(h),84);if(NGd(AGd(g),d)){return true}else if(AGd(g)==d&&Heb(TD(Gxd(a,(umd(),_kd))))){return true}}}for(b=new dMd(RD(this.f,123).hh());b.e!=b.i.gc();){a=RD(bMd(b),74);for(f=new dMd((!a.b&&(a.b=new Yie(E4,a,4,7)),a.b));f.e!=f.i.gc();){e=RD(bMd(f),84);if(NGd(AGd(e),d)){return true}}}return false};_.a=null;_.b=null;_.c=null;sfb(uHe,'ElkGraphAdapters/ElkPortAdapter',1284);feb(1285,1,fye,Yud);_.Ne=function Zud(a,b){return Xud(RD(a,123),RD(b,123))};_.Fb=function $ud(a){return this===a};_.Oe=function _ud(){return new Frb(this)};sfb(uHe,'ElkGraphAdapters/PortComparator',1285);var r7=ufb(vHe,'EObject');var C4=ufb(wHe,xHe);var D4=ufb(wHe,yHe);var H4=ufb(wHe,zHe);var L4=ufb(wHe,'ElkShape');var E4=ufb(wHe,AHe);var G4=ufb(wHe,BHe);var F4=ufb(wHe,CHe);var p7=ufb(vHe,DHe);var n7=ufb(vHe,'EFactory');var avd;var q7=ufb(vHe,EHe);var t7=ufb(vHe,'EPackage');var cvd;var evd,fvd,gvd,hvd,ivd,jvd,kvd,lvd,mvd,nvd,ovd;var I4=ufb(wHe,FHe);var J4=ufb(wHe,GHe);var K4=ufb(wHe,HHe);feb(93,1,IHe);_.th=function rvd(){this.uh();return null};_.uh=function svd(){return null};_.vh=function tvd(){return this.uh(),false};_.wh=function uvd(){return false};_.xh=function vvd(a){qvd(this,a);};sfb(JHe,'BasicNotifierImpl',93);feb(99,93,RHe);_.Yh=function Dwd(){return Mvd(this)};_.yh=function bwd(a,b){return a};_.zh=function cwd(){throw Adb(new jib)};_.Ah=function dwd(a){var b;return b=Z5d(RD(vYd(this.Dh(),this.Fh()),19)),this.Ph().Th(this,b.n,b.f,a)};_.Bh=function ewd(a,b){throw Adb(new jib)};_.Ch=function fwd(a,b,c){return xvd(this,a,b,c)};_.Dh=function gwd(){var a;if(this.zh()){a=this.zh().Nk();if(a){return a}}return this.ii()};_.Eh=function hwd(){return yvd(this)};_.Fh=function iwd(){throw Adb(new jib)};_.Gh=function kwd(){var a,b;b=this.$h().Ok();!b&&this.zh().Tk(b=(N2d(),a=P$d(rYd(this.Dh())),a==null?M2d:new Q2d(this,a)));return b};_.Hh=function mwd(a,b){return a};_.Ih=function nwd(a){var b;b=a.pk();return !b?BYd(this.Dh(),a):a.Lj()};_.Jh=function owd(){var a;a=this.zh();return !a?null:a.Qk()};_.Kh=function pwd(){return !this.zh()?null:this.zh().Nk()};_.Lh=function qwd(a,b,c){return Dvd(this,a,b,c)};_.Mh=function rwd(a){return Evd(this,a)};_.Nh=function swd(a,b){return Fvd(this,a,b)};_.Oh=function twd(){var a;a=this.zh();return !!a&&a.Rk()};_.Ph=function uwd(){throw Adb(new jib)};_.Qh=function vwd(){return Hvd(this)};_.Rh=function wwd(a,b,c,d){return Ivd(this,a,b,d)};_.Sh=function xwd(a,b,c){var d;return d=RD(vYd(this.Dh(),b),69),d.wk().zk(this,this.hi(),b-this.ji(),a,c)};_.Th=function ywd(a,b,c,d){return Jvd(this,a,b,d)};_.Uh=function zwd(a,b,c){var d;return d=RD(vYd(this.Dh(),b),69),d.wk().Ak(this,this.hi(),b-this.ji(),a,c)};_.Vh=function Awd(){return !!this.zh()&&!!this.zh().Pk()};_.Wh=function Bwd(a){return Kvd(this,a)};_.Xh=function Cwd(a){return Lvd(this,a)};_.Zh=function Ewd(a){return Pvd(this,a)};_.$h=function Fwd(){throw Adb(new jib)};_._h=function Gwd(){return !this.zh()?null:this.zh().Pk()};_.ai=function Hwd(){return Hvd(this)};_.bi=function Iwd(a,b){Wvd(this,a,b);};_.ci=function Jwd(a){this.$h().Sk(a);};_.di=function Kwd(a){this.$h().Vk(a);};_.ei=function Lwd(a){this.$h().Uk(a);};_.fi=function Mwd(a,b){var c,d,e,f;f=this.Jh();if(!!f&&!!a){b=rLd(f.El(),this,b);f.Il(this);}d=this.Ph();if(d){if((jwd(this,this.Ph(),this.Fh()).Bb&txe)!=0){e=d.Qh();!!e&&(!a?e.Hl(this):!f&&e.Il(this));}else {b=(c=this.Fh(),c>=0?this.Ah(b):this.Ph().Th(this,-1-c,null,b));b=this.Ch(null,-1,b);}}this.di(a);return b};_.gi=function Nwd(a){var b,c,d,e,f,g,h,i;c=this.Dh();f=BYd(c,a);b=this.ji();if(f>=b){return RD(a,69).wk().Dk(this,this.hi(),f-b)}else if(f<=-1){g=Eee((lke(),jke),c,a);if(g){nke();RD(g,69).xk()||(g=zfe(Qee(jke,g)));e=(d=this.Ih(g),RD(d>=0?this.Lh(d,true,true):Qvd(this,g,true),160));i=g.Ik();if(i>1||i==-1){return RD(RD(e,220).Sl(a,false),79)}}else {throw Adb(new agb(KHe+a.xe()+NHe))}}else if(a.Jk()){return d=this.Ih(a),RD(d>=0?this.Lh(d,false,true):Qvd(this,a,false),79)}h=new NTd(this,a);return h};_.hi=function Owd(){return Yvd(this)};_.ii=function Pwd(){return (lTd(),kTd).S};_.ji=function Qwd(){return AYd(this.ii())};_.ki=function Rwd(a){$vd(this,a);};_.Ib=function Swd(){return awd(this)};sfb(SHe,'BasicEObjectImpl',99);var ZSd;feb(119,99,{110:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1});_.li=function _wd(a){var b;b=Vwd(this);return b[a]};_.mi=function axd(a,b){var c;c=Vwd(this);bD(c,a,b);};_.ni=function bxd(a){var b;b=Vwd(this);bD(b,a,null);};_.th=function cxd(){return RD(Ywd(this,4),129)};_.uh=function dxd(){throw Adb(new jib)};_.vh=function exd(){return (this.Db&4)!=0};_.zh=function fxd(){throw Adb(new jib)};_.oi=function gxd(a){$wd(this,2,a);};_.Bh=function hxd(a,b){this.Db=b<<16|this.Db&255;this.oi(a);};_.Dh=function ixd(){return Uwd(this)};_.Fh=function jxd(){return this.Db>>16};_.Gh=function kxd(){var a,b;return N2d(),b=P$d(rYd((a=RD(Ywd(this,16),29),!a?this.ii():a))),b==null?(M2d):new Q2d(this,b)};_.wh=function lxd(){return (this.Db&1)==0};_.Jh=function mxd(){return RD(Ywd(this,128),2034)};_.Kh=function nxd(){return RD(Ywd(this,16),29)};_.Oh=function oxd(){return (this.Db&32)!=0};_.Ph=function pxd(){return RD(Ywd(this,2),54)};_.Vh=function qxd(){return (this.Db&64)!=0};_.$h=function rxd(){throw Adb(new jib)};_._h=function sxd(){return RD(Ywd(this,64),288)};_.ci=function txd(a){$wd(this,16,a);};_.di=function uxd(a){$wd(this,128,a);};_.ei=function vxd(a){$wd(this,64,a);};_.hi=function wxd(){return Wwd(this)};_.Db=0;sfb(SHe,'MinimalEObjectImpl',119);feb(120,119,{110:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.oi=function xxd(a){this.Cb=a;};_.Ph=function yxd(){return this.Cb};sfb(SHe,'MinimalEObjectImpl/Container',120);feb(2083,120,{110:1,342:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function Jxd(a,b,c){return Axd(this,a,b,c)};_.Uh=function Kxd(a,b,c){return Bxd(this,a,b,c)};_.Wh=function Lxd(a){return Cxd(this,a)};_.bi=function Mxd(a,b){Dxd(this,a,b);};_.ii=function Nxd(){return pvd(),ovd};_.ki=function Oxd(a){Exd(this,a);};_.nf=function Pxd(){return Fxd(this)};_.gh=function Qxd(){return !this.o&&(this.o=new DVd((pvd(),mvd),X4,this,0)),this.o};_.of=function Rxd(a){return Gxd(this,a)};_.pf=function Sxd(a){return Hxd(this,a)};_.qf=function Txd(a,b){return Ixd(this,a,b)};sfb(THe,'EMapPropertyHolderImpl',2083);feb(572,120,{110:1,377:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},Xxd);_.Lh=function Yxd(a,b,c){switch(a){case 0:return this.a;case 1:return this.b;}return Dvd(this,a,b,c)};_.Wh=function Zxd(a){switch(a){case 0:return this.a!=0;case 1:return this.b!=0;}return Kvd(this,a)};_.bi=function $xd(a,b){switch(a){case 0:Vxd(this,Kfb(UD(b)));return;case 1:Wxd(this,Kfb(UD(b)));return;}Wvd(this,a,b);};_.ii=function _xd(){return pvd(),evd};_.ki=function ayd(a){switch(a){case 0:Vxd(this,0);return;case 1:Wxd(this,0);return;}$vd(this,a);};_.Ib=function byd(){var a;if((this.Db&64)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (x: ';Khb(a,this.a);a.a+=', y: ';Khb(a,this.b);a.a+=')';return a.a};_.a=0;_.b=0;sfb(THe,'ElkBendPointImpl',572);feb(739,2083,{110:1,342:1,167:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function lyd(a,b,c){return cyd(this,a,b,c)};_.Sh=function myd(a,b,c){return dyd(this,a,b,c)};_.Uh=function nyd(a,b,c){return eyd(this,a,b,c)};_.Wh=function oyd(a){return fyd(this,a)};_.bi=function pyd(a,b){gyd(this,a,b);};_.ii=function qyd(){return pvd(),ivd};_.ki=function ryd(a){hyd(this,a);};_.jh=function syd(){return this.k};_.kh=function tyd(){return iyd(this)};_.Ib=function uyd(){return kyd(this)};_.k=null;sfb(THe,'ElkGraphElementImpl',739);feb(740,739,{110:1,342:1,167:1,422:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function Gyd(a,b,c){return vyd(this,a,b,c)};_.Wh=function Hyd(a){return wyd(this,a)};_.bi=function Iyd(a,b){xyd(this,a,b);};_.ii=function Jyd(){return pvd(),nvd};_.ki=function Kyd(a){yyd(this,a);};_.lh=function Lyd(){return this.f};_.mh=function Myd(){return this.g};_.nh=function Nyd(){return this.i};_.oh=function Oyd(){return this.j};_.ph=function Pyd(a,b){zyd(this,a,b);};_.qh=function Qyd(a,b){Byd(this,a,b);};_.rh=function Ryd(a){Dyd(this,a);};_.sh=function Syd(a){Eyd(this,a);};_.Ib=function Tyd(){return Fyd(this)};_.f=0;_.g=0;_.i=0;_.j=0;sfb(THe,'ElkShapeImpl',740);feb(741,740,{110:1,342:1,84:1,167:1,422:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1});_.Lh=function _yd(a,b,c){return Uyd(this,a,b,c)};_.Sh=function azd(a,b,c){return Vyd(this,a,b,c)};_.Uh=function bzd(a,b,c){return Wyd(this,a,b,c)};_.Wh=function czd(a){return Xyd(this,a)};_.bi=function dzd(a,b){Yyd(this,a,b);};_.ii=function ezd(){return pvd(),fvd};_.ki=function fzd(a){Zyd(this,a);};_.hh=function gzd(){return !this.d&&(this.d=new Yie(G4,this,8,5)),this.d};_.ih=function hzd(){return !this.e&&(this.e=new Yie(G4,this,7,4)),this.e};sfb(THe,'ElkConnectableShapeImpl',741);feb(326,739,{110:1,342:1,74:1,167:1,326:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},rzd);_.Ah=function szd(a){return jzd(this,a)};_.Lh=function tzd(a,b,c){switch(a){case 3:return kzd(this);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),this.b;case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),this.c;case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),this.a;case 7:return Geb(),!this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i<=1&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i<=1)?false:true;case 8:return Geb(),nzd(this)?true:false;case 9:return Geb(),ozd(this)?true:false;case 10:return Geb(),!this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i!=0)?true:false;}return cyd(this,a,b,c)};_.Sh=function uzd(a,b,c){var d;switch(b){case 3:!!this.Cb&&(c=(d=this.Db>>16,d>=0?jzd(this,c):this.Cb.Th(this,-1-d,null,c)));return izd(this,RD(a,27),c);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),qLd(this.b,a,c);case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),qLd(this.c,a,c);case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),qLd(this.a,a,c);}return dyd(this,a,b,c)};_.Uh=function vzd(a,b,c){switch(b){case 3:return izd(this,null,c);case 4:return !this.b&&(this.b=new Yie(E4,this,4,7)),rLd(this.b,a,c);case 5:return !this.c&&(this.c=new Yie(E4,this,5,8)),rLd(this.c,a,c);case 6:return !this.a&&(this.a=new C5d(F4,this,6,6)),rLd(this.a,a,c);}return eyd(this,a,b,c)};_.Wh=function wzd(a){switch(a){case 3:return !!kzd(this);case 4:return !!this.b&&this.b.i!=0;case 5:return !!this.c&&this.c.i!=0;case 6:return !!this.a&&this.a.i!=0;case 7:return !this.b&&(this.b=new Yie(E4,this,4,7)),!(this.b.i<=1&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i<=1));case 8:return nzd(this);case 9:return ozd(this);case 10:return !this.b&&(this.b=new Yie(E4,this,4,7)),this.b.i!=0&&(!this.c&&(this.c=new Yie(E4,this,5,8)),this.c.i!=0);}return fyd(this,a)};_.bi=function xzd(a,b){switch(a){case 3:pzd(this,RD(b,27));return;case 4:!this.b&&(this.b=new Yie(E4,this,4,7));sLd(this.b);!this.b&&(this.b=new Yie(E4,this,4,7));YGd(this.b,RD(b,16));return;case 5:!this.c&&(this.c=new Yie(E4,this,5,8));sLd(this.c);!this.c&&(this.c=new Yie(E4,this,5,8));YGd(this.c,RD(b,16));return;case 6:!this.a&&(this.a=new C5d(F4,this,6,6));sLd(this.a);!this.a&&(this.a=new C5d(F4,this,6,6));YGd(this.a,RD(b,16));return;}gyd(this,a,b);};_.ii=function yzd(){return pvd(),gvd};_.ki=function zzd(a){switch(a){case 3:pzd(this,null);return;case 4:!this.b&&(this.b=new Yie(E4,this,4,7));sLd(this.b);return;case 5:!this.c&&(this.c=new Yie(E4,this,5,8));sLd(this.c);return;case 6:!this.a&&(this.a=new C5d(F4,this,6,6));sLd(this.a);return;}hyd(this,a);};_.Ib=function Azd(){return qzd(this)};sfb(THe,'ElkEdgeImpl',326);feb(452,2083,{110:1,342:1,166:1,452:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},Rzd);_.Ah=function Szd(a){return Czd(this,a)};_.Lh=function Tzd(a,b,c){switch(a){case 1:return this.j;case 2:return this.k;case 3:return this.b;case 4:return this.c;case 5:return !this.a&&(this.a=new XZd(D4,this,5)),this.a;case 6:return Fzd(this);case 7:if(b)return Ezd(this);return this.i;case 8:if(b)return Dzd(this);return this.f;case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),this.g;case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),this.e;case 11:return this.d;}return Axd(this,a,b,c)};_.Sh=function Uzd(a,b,c){var d,e,f;switch(b){case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?Czd(this,c):this.Cb.Th(this,-1-e,null,c)));return Bzd(this,RD(a,74),c);case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),qLd(this.g,a,c);case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),qLd(this.e,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(pvd(),hvd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((pvd(),hvd)),a,c)};_.Uh=function Vzd(a,b,c){switch(b){case 5:return !this.a&&(this.a=new XZd(D4,this,5)),rLd(this.a,a,c);case 6:return Bzd(this,null,c);case 9:return !this.g&&(this.g=new Yie(F4,this,9,10)),rLd(this.g,a,c);case 10:return !this.e&&(this.e=new Yie(F4,this,10,9)),rLd(this.e,a,c);}return Bxd(this,a,b,c)};_.Wh=function Wzd(a){switch(a){case 1:return this.j!=0;case 2:return this.k!=0;case 3:return this.b!=0;case 4:return this.c!=0;case 5:return !!this.a&&this.a.i!=0;case 6:return !!Fzd(this);case 7:return !!this.i;case 8:return !!this.f;case 9:return !!this.g&&this.g.i!=0;case 10:return !!this.e&&this.e.i!=0;case 11:return this.d!=null;}return Cxd(this,a)};_.bi=function Xzd(a,b){switch(a){case 1:Ozd(this,Kfb(UD(b)));return;case 2:Pzd(this,Kfb(UD(b)));return;case 3:Hzd(this,Kfb(UD(b)));return;case 4:Izd(this,Kfb(UD(b)));return;case 5:!this.a&&(this.a=new XZd(D4,this,5));sLd(this.a);!this.a&&(this.a=new XZd(D4,this,5));YGd(this.a,RD(b,16));return;case 6:Mzd(this,RD(b,74));return;case 7:Lzd(this,RD(b,84));return;case 8:Kzd(this,RD(b,84));return;case 9:!this.g&&(this.g=new Yie(F4,this,9,10));sLd(this.g);!this.g&&(this.g=new Yie(F4,this,9,10));YGd(this.g,RD(b,16));return;case 10:!this.e&&(this.e=new Yie(F4,this,10,9));sLd(this.e);!this.e&&(this.e=new Yie(F4,this,10,9));YGd(this.e,RD(b,16));return;case 11:Jzd(this,WD(b));return;}Dxd(this,a,b);};_.ii=function Yzd(){return pvd(),hvd};_.ki=function Zzd(a){switch(a){case 1:Ozd(this,0);return;case 2:Pzd(this,0);return;case 3:Hzd(this,0);return;case 4:Izd(this,0);return;case 5:!this.a&&(this.a=new XZd(D4,this,5));sLd(this.a);return;case 6:Mzd(this,null);return;case 7:Lzd(this,null);return;case 8:Kzd(this,null);return;case 9:!this.g&&(this.g=new Yie(F4,this,9,10));sLd(this.g);return;case 10:!this.e&&(this.e=new Yie(F4,this,10,9));sLd(this.e);return;case 11:Jzd(this,null);return;}Exd(this,a);};_.Ib=function $zd(){return Qzd(this)};_.b=0;_.c=0;_.d=null;_.j=0;_.k=0;sfb(THe,'ElkEdgeSectionImpl',452);feb(158,120,{110:1,94:1,93:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1});_.Lh=function cAd(a,b,c){var d;if(a==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function dAd(a,b,c){var d,e;if(b==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c)}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function eAd(a,b,c){var d,e;if(b==0){return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c)}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function fAd(a){var b;if(a==0){return !!this.Ab&&this.Ab.i!=0}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.Zh=function gAd(a){return _zd(this,a)};_.bi=function hAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.di=function iAd(a){$wd(this,128,a);};_.ii=function jAd(){return JTd(),xTd};_.ki=function kAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function lAd(){this.Bb|=1;};_.qi=function mAd(a){return bAd(this,a)};_.Bb=0;sfb(SHe,'EModelElementImpl',158);feb(720,158,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1},yAd);_.ri=function zAd(a,b){return tAd(this,a,b)};_.si=function AAd(a){var b,c,d,e,f;if(this.a!=BXd(a)||(a.Bb&256)!=0){throw Adb(new agb(ZHe+a.zb+WHe))}for(d=zYd(a);tYd(d.a).i!=0;){c=RD(N_d(d,0,(b=RD(QHd(tYd(d.a),0),89),f=b.c,ZD(f,90)?RD(f,29):(JTd(),zTd))),29);if(DXd(c)){e=BXd(c).wi().si(c);RD(e,54).ci(a);return e}d=zYd(c);}return (a.D!=null?a.D:a.B)=='java.util.Map$Entry'?new LUd(a):new zUd(a)};_.ti=function BAd(a,b){return uAd(this,a,b)};_.Lh=function CAd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.a;}return zvd(this,a-AYd((JTd(),uTd)),vYd((d=RD(Ywd(this,16),29),!d?uTd:d),a),b,c)};_.Sh=function DAd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 1:!!this.a&&(c=RD(this.a,54).Th(this,4,t7,c));return rAd(this,RD(a,241),c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),uTd):d),b),69),e.wk().zk(this,Wwd(this),b-AYd((JTd(),uTd)),a,c)};_.Uh=function EAd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 1:return rAd(this,null,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),uTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),uTd)),a,c)};_.Wh=function FAd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return !!this.a;}return Avd(this,a-AYd((JTd(),uTd)),vYd((b=RD(Ywd(this,16),29),!b?uTd:b),a))};_.bi=function GAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:wAd(this,RD(b,241));return;}Bvd(this,a-AYd((JTd(),uTd)),vYd((c=RD(Ywd(this,16),29),!c?uTd:c),a),b);};_.ii=function HAd(){return JTd(),uTd};_.ki=function IAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:wAd(this,null);return;}Cvd(this,a-AYd((JTd(),uTd)),vYd((b=RD(Ywd(this,16),29),!b?uTd:b),a));};var nAd,oAd,pAd;sfb(SHe,'EFactoryImpl',720);feb(1037,720,{110:1,2113:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1},KAd);_.ri=function LAd(a,b){switch(a.hk()){case 12:return RD(b,149).Pg();case 13:return jeb(b);default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function MAd(a){var b,c,d,e,f,g,h,i;switch(a.G==-1&&(a.G=(b=BXd(a),b?fZd(b.vi(),a):-1)),a.G){case 4:return f=new hCd,f;case 6:return g=new ACd,g;case 7:return h=new PCd,h;case 8:return d=new rzd,d;case 9:return c=new Xxd,c;case 10:return e=new Rzd,e;case 11:return i=new _Cd,i;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function NAd(a,b){switch(a.hk()){case 13:case 12:return null;default:throw Adb(new agb(VHe+a.xe()+WHe));}};sfb(THe,'ElkGraphFactoryImpl',1037);feb(448,158,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1});_.Gh=function RAd(){var a,b;b=(a=RD(Ywd(this,16),29),P$d(rYd(!a?this.ii():a)));return b==null?(N2d(),N2d(),M2d):new e3d(this,b)};_.Lh=function SAd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.xe();}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Wh=function TAd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function UAd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:this.ui(WD(b));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function VAd(){return JTd(),yTd};_.ki=function WAd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:this.ui(null);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.xe=function XAd(){return this.zb};_.ui=function YAd(a){PAd(this,a);};_.Ib=function ZAd(){return QAd(this)};_.zb=null;sfb(SHe,'ENamedElementImpl',448);feb(184,448,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1},EBd);_.Ah=function GBd(a){return qBd(this,a)};_.Lh=function HBd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.yb;case 3:return this.xb;case 4:return this.sb;case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),this.rb;case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),this.vb;case 7:if(b)return this.Db>>16==7?RD(this.Cb,241):null;return gBd(this);}return zvd(this,a-AYd((JTd(),CTd)),vYd((d=RD(Ywd(this,16),29),!d?CTd:d),a),b,c)};_.Sh=function IBd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 4:!!this.sb&&(c=RD(this.sb,54).Th(this,1,n7,c));return hBd(this,RD(a,480),c);case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),qLd(this.rb,a,c);case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),qLd(this.vb,a,c);case 7:!!this.Cb&&(c=(e=this.Db>>16,e>=0?qBd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,7,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),CTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),CTd)),a,c)};_.Uh=function JBd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 4:return hBd(this,null,c);case 5:return !this.rb&&(this.rb=new J5d(this,i7,this)),rLd(this.rb,a,c);case 6:return !this.vb&&(this.vb=new G5d(t7,this,6,7)),rLd(this.vb,a,c);case 7:return xvd(this,null,7,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),CTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),CTd)),a,c)};_.Wh=function KBd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.yb!=null;case 3:return this.xb!=null;case 4:return !!this.sb;case 5:return !!this.rb&&this.rb.i!=0;case 6:return !!this.vb&&this.vb.i!=0;case 7:return !!gBd(this);}return Avd(this,a-AYd((JTd(),CTd)),vYd((b=RD(Ywd(this,16),29),!b?CTd:b),a))};_.Zh=function LBd(a){var b;b=sBd(this,a);return b?b:_zd(this,a)};_.bi=function MBd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:DBd(this,WD(b));return;case 3:CBd(this,WD(b));return;case 4:BBd(this,RD(b,480));return;case 5:!this.rb&&(this.rb=new J5d(this,i7,this));sLd(this.rb);!this.rb&&(this.rb=new J5d(this,i7,this));YGd(this.rb,RD(b,16));return;case 6:!this.vb&&(this.vb=new G5d(t7,this,6,7));sLd(this.vb);!this.vb&&(this.vb=new G5d(t7,this,6,7));YGd(this.vb,RD(b,16));return;}Bvd(this,a-AYd((JTd(),CTd)),vYd((c=RD(Ywd(this,16),29),!c?CTd:c),a),b);};_.ei=function NBd(a){var b,c;if(!!a&&!!this.rb){for(c=new dMd(this.rb);c.e!=c.i.gc();){b=bMd(c);ZD(b,364)&&(RD(b,364).w=null);}}$wd(this,64,a);};_.ii=function OBd(){return JTd(),CTd};_.ki=function PBd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:DBd(this,null);return;case 3:CBd(this,null);return;case 4:BBd(this,null);return;case 5:!this.rb&&(this.rb=new J5d(this,i7,this));sLd(this.rb);return;case 6:!this.vb&&(this.vb=new G5d(t7,this,6,7));sLd(this.vb);return;}Cvd(this,a-AYd((JTd(),CTd)),vYd((b=RD(Ywd(this,16),29),!b?CTd:b),a));};_.pi=function QBd(){rBd(this);};_.vi=function RBd(){return !this.rb&&(this.rb=new J5d(this,i7,this)),this.rb};_.wi=function SBd(){return this.sb};_.xi=function TBd(){return this.ub};_.yi=function UBd(){return this.xb};_.zi=function VBd(){return this.yb};_.Ai=function WBd(a){this.ub=a;};_.Ib=function XBd(){var a;if((this.Db&64)!=0)return QAd(this);a=new Shb(QAd(this));a.a+=' (nsURI: ';Nhb(a,this.yb);a.a+=', nsPrefix: ';Nhb(a,this.xb);a.a+=')';return a.a};_.xb=null;_.yb=null;sfb(SHe,'EPackageImpl',184);feb(569,184,{110:1,2115:1,569:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1},_Bd);_.q=false;_.r=false;var YBd=false;sfb(THe,'ElkGraphPackageImpl',569);feb(366,740,{110:1,342:1,167:1,135:1,422:1,366:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},hCd);_.Ah=function iCd(a){return cCd(this,a)};_.Lh=function jCd(a,b,c){switch(a){case 7:return dCd(this);case 8:return this.a;}return vyd(this,a,b,c)};_.Sh=function kCd(a,b,c){var d;switch(b){case 7:!!this.Cb&&(c=(d=this.Db>>16,d>=0?cCd(this,c):this.Cb.Th(this,-1-d,null,c)));return bCd(this,RD(a,167),c);}return dyd(this,a,b,c)};_.Uh=function lCd(a,b,c){if(b==7){return bCd(this,null,c)}return eyd(this,a,b,c)};_.Wh=function mCd(a){switch(a){case 7:return !!dCd(this);case 8:return !lhb('',this.a);}return wyd(this,a)};_.bi=function nCd(a,b){switch(a){case 7:eCd(this,RD(b,167));return;case 8:fCd(this,WD(b));return;}xyd(this,a,b);};_.ii=function oCd(){return pvd(),jvd};_.ki=function pCd(a){switch(a){case 7:eCd(this,null);return;case 8:fCd(this,'');return;}yyd(this,a);};_.Ib=function qCd(){return gCd(this)};_.a='';sfb(THe,'ElkLabelImpl',366);feb(207,741,{110:1,342:1,84:1,167:1,27:1,422:1,207:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},ACd);_.Ah=function BCd(a){return sCd(this,a)};_.Lh=function CCd(a,b,c){switch(a){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),this.c;case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),this.a;case 11:return vCd(this);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),this.b;case 13:return Geb(),!this.a&&(this.a=new C5d(J4,this,10,11)),this.a.i>0?true:false;}return Uyd(this,a,b,c)};_.Sh=function DCd(a,b,c){var d;switch(b){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),qLd(this.c,a,c);case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),qLd(this.a,a,c);case 11:!!this.Cb&&(c=(d=this.Db>>16,d>=0?sCd(this,c):this.Cb.Th(this,-1-d,null,c)));return rCd(this,RD(a,27),c);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),qLd(this.b,a,c);}return Vyd(this,a,b,c)};_.Uh=function ECd(a,b,c){switch(b){case 9:return !this.c&&(this.c=new C5d(K4,this,9,9)),rLd(this.c,a,c);case 10:return !this.a&&(this.a=new C5d(J4,this,10,11)),rLd(this.a,a,c);case 11:return rCd(this,null,c);case 12:return !this.b&&(this.b=new C5d(G4,this,12,3)),rLd(this.b,a,c);}return Wyd(this,a,b,c)};_.Wh=function FCd(a){switch(a){case 9:return !!this.c&&this.c.i!=0;case 10:return !!this.a&&this.a.i!=0;case 11:return !!vCd(this);case 12:return !!this.b&&this.b.i!=0;case 13:return !this.a&&(this.a=new C5d(J4,this,10,11)),this.a.i>0;}return Xyd(this,a)};_.bi=function GCd(a,b){switch(a){case 9:!this.c&&(this.c=new C5d(K4,this,9,9));sLd(this.c);!this.c&&(this.c=new C5d(K4,this,9,9));YGd(this.c,RD(b,16));return;case 10:!this.a&&(this.a=new C5d(J4,this,10,11));sLd(this.a);!this.a&&(this.a=new C5d(J4,this,10,11));YGd(this.a,RD(b,16));return;case 11:yCd(this,RD(b,27));return;case 12:!this.b&&(this.b=new C5d(G4,this,12,3));sLd(this.b);!this.b&&(this.b=new C5d(G4,this,12,3));YGd(this.b,RD(b,16));return;}Yyd(this,a,b);};_.ii=function HCd(){return pvd(),kvd};_.ki=function ICd(a){switch(a){case 9:!this.c&&(this.c=new C5d(K4,this,9,9));sLd(this.c);return;case 10:!this.a&&(this.a=new C5d(J4,this,10,11));sLd(this.a);return;case 11:yCd(this,null);return;case 12:!this.b&&(this.b=new C5d(G4,this,12,3));sLd(this.b);return;}Zyd(this,a);};_.Ib=function JCd(){return zCd(this)};sfb(THe,'ElkNodeImpl',207);feb(193,741,{110:1,342:1,84:1,167:1,123:1,422:1,193:1,96:1,94:1,93:1,58:1,114:1,54:1,99:1,119:1,120:1},PCd);_.Ah=function QCd(a){return LCd(this,a)};_.Lh=function RCd(a,b,c){if(a==9){return MCd(this)}return Uyd(this,a,b,c)};_.Sh=function SCd(a,b,c){var d;switch(b){case 9:!!this.Cb&&(c=(d=this.Db>>16,d>=0?LCd(this,c):this.Cb.Th(this,-1-d,null,c)));return KCd(this,RD(a,27),c);}return Vyd(this,a,b,c)};_.Uh=function TCd(a,b,c){if(b==9){return KCd(this,null,c)}return Wyd(this,a,b,c)};_.Wh=function UCd(a){if(a==9){return !!MCd(this)}return Xyd(this,a)};_.bi=function VCd(a,b){switch(a){case 9:NCd(this,RD(b,27));return;}Yyd(this,a,b);};_.ii=function WCd(){return pvd(),lvd};_.ki=function XCd(a){switch(a){case 9:NCd(this,null);return;}Zyd(this,a);};_.Ib=function YCd(){return OCd(this)};sfb(THe,'ElkPortImpl',193);var O6=ufb(sIe,'BasicEMap/Entry');feb(1122,120,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1,119:1,120:1},_Cd);_.Fb=function fDd(a){return this===a};_.ld=function hDd(){return this.b};_.Hb=function jDd(){return kFb(this)};_.Di=function lDd(a){ZCd(this,RD(a,149));};_.Lh=function aDd(a,b,c){switch(a){case 0:return this.b;case 1:return this.c;}return Dvd(this,a,b,c)};_.Wh=function bDd(a){switch(a){case 0:return !!this.b;case 1:return this.c!=null;}return Kvd(this,a)};_.bi=function cDd(a,b){switch(a){case 0:ZCd(this,RD(b,149));return;case 1:$Cd(this,b);return;}Wvd(this,a,b);};_.ii=function dDd(){return pvd(),mvd};_.ki=function eDd(a){switch(a){case 0:ZCd(this,null);return;case 1:$Cd(this,null);return;}$vd(this,a);};_.Bi=function gDd(){var a;if(this.a==-1){a=this.b;this.a=!a?0:tb(a);}return this.a};_.md=function iDd(){return this.c};_.Ci=function kDd(a){this.a=a;};_.nd=function mDd(a){var b;b=this.c;$Cd(this,a);return b};_.Ib=function nDd(){var a;if((this.Db&64)!=0)return awd(this);a=new bib;Zhb(Zhb(Zhb(a,this.b?this.b.Pg():vve),SAe),Ghb(this.c));return a.a};_.a=-1;_.c=null;var X4=sfb(THe,'ElkPropertyToValueMapEntryImpl',1122);feb(996,1,{},BDd);sfb(vIe,'JsonAdapter',996);feb(216,63,swe,CDd);sfb(vIe,'JsonImportException',216);feb(868,1,{},IEd);sfb(vIe,'JsonImporter',868);feb(903,1,{},JEd);sfb(vIe,'JsonImporter/lambda$0$Type',903);feb(904,1,{},KEd);sfb(vIe,'JsonImporter/lambda$1$Type',904);feb(912,1,{},LEd);sfb(vIe,'JsonImporter/lambda$10$Type',912);feb(914,1,{},MEd);sfb(vIe,'JsonImporter/lambda$11$Type',914);feb(915,1,{},NEd);sfb(vIe,'JsonImporter/lambda$12$Type',915);feb(921,1,{},OEd);sfb(vIe,'JsonImporter/lambda$13$Type',921);feb(920,1,{},PEd);sfb(vIe,'JsonImporter/lambda$14$Type',920);feb(916,1,{},QEd);sfb(vIe,'JsonImporter/lambda$15$Type',916);feb(917,1,{},REd);sfb(vIe,'JsonImporter/lambda$16$Type',917);feb(918,1,{},SEd);sfb(vIe,'JsonImporter/lambda$17$Type',918);feb(919,1,{},TEd);sfb(vIe,'JsonImporter/lambda$18$Type',919);feb(924,1,{},UEd);sfb(vIe,'JsonImporter/lambda$19$Type',924);feb(905,1,{},VEd);sfb(vIe,'JsonImporter/lambda$2$Type',905);feb(922,1,{},WEd);sfb(vIe,'JsonImporter/lambda$20$Type',922);feb(923,1,{},XEd);sfb(vIe,'JsonImporter/lambda$21$Type',923);feb(927,1,{},YEd);sfb(vIe,'JsonImporter/lambda$22$Type',927);feb(925,1,{},ZEd);sfb(vIe,'JsonImporter/lambda$23$Type',925);feb(926,1,{},$Ed);sfb(vIe,'JsonImporter/lambda$24$Type',926);feb(929,1,{},_Ed);sfb(vIe,'JsonImporter/lambda$25$Type',929);feb(928,1,{},aFd);sfb(vIe,'JsonImporter/lambda$26$Type',928);feb(930,1,Qve,bFd);_.Cd=function cFd(a){_Dd(this.b,this.a,WD(a));};sfb(vIe,'JsonImporter/lambda$27$Type',930);feb(931,1,Qve,dFd);_.Cd=function eFd(a){aEd(this.b,this.a,WD(a));};sfb(vIe,'JsonImporter/lambda$28$Type',931);feb(932,1,{},fFd);sfb(vIe,'JsonImporter/lambda$29$Type',932);feb(908,1,{},gFd);sfb(vIe,'JsonImporter/lambda$3$Type',908);feb(933,1,{},hFd);sfb(vIe,'JsonImporter/lambda$30$Type',933);feb(934,1,{},iFd);sfb(vIe,'JsonImporter/lambda$31$Type',934);feb(935,1,{},jFd);sfb(vIe,'JsonImporter/lambda$32$Type',935);feb(936,1,{},kFd);sfb(vIe,'JsonImporter/lambda$33$Type',936);feb(937,1,{},lFd);sfb(vIe,'JsonImporter/lambda$34$Type',937);feb(870,1,{},nFd);sfb(vIe,'JsonImporter/lambda$35$Type',870);feb(941,1,{},pFd);sfb(vIe,'JsonImporter/lambda$36$Type',941);feb(938,1,Qve,qFd);_.Cd=function rFd(a){jEd(this.a,RD(a,377));};sfb(vIe,'JsonImporter/lambda$37$Type',938);feb(939,1,Qve,sFd);_.Cd=function tFd(a){kEd(this.a,this.b,RD(a,166));};sfb(vIe,'JsonImporter/lambda$38$Type',939);feb(940,1,Qve,uFd);_.Cd=function vFd(a){lEd(this.a,this.b,RD(a,166));};sfb(vIe,'JsonImporter/lambda$39$Type',940);feb(906,1,{},wFd);sfb(vIe,'JsonImporter/lambda$4$Type',906);feb(942,1,Qve,xFd);_.Cd=function yFd(a){mEd(this.a,RD(a,8));};sfb(vIe,'JsonImporter/lambda$40$Type',942);feb(907,1,{},zFd);sfb(vIe,'JsonImporter/lambda$5$Type',907);feb(911,1,{},AFd);sfb(vIe,'JsonImporter/lambda$6$Type',911);feb(909,1,{},BFd);sfb(vIe,'JsonImporter/lambda$7$Type',909);feb(910,1,{},CFd);sfb(vIe,'JsonImporter/lambda$8$Type',910);feb(913,1,{},DFd);sfb(vIe,'JsonImporter/lambda$9$Type',913);feb(961,1,Qve,MFd);_.Cd=function NFd(a){oDd(this.a,new OC(WD(a)));};sfb(vIe,'JsonMetaDataConverter/lambda$0$Type',961);feb(962,1,Qve,OFd);_.Cd=function PFd(a){IFd(this.a,RD(a,245));};sfb(vIe,'JsonMetaDataConverter/lambda$1$Type',962);feb(963,1,Qve,QFd);_.Cd=function RFd(a){JFd(this.a,RD(a,143));};sfb(vIe,'JsonMetaDataConverter/lambda$2$Type',963);feb(964,1,Qve,SFd);_.Cd=function TFd(a){KFd(this.a,RD(a,170));};sfb(vIe,'JsonMetaDataConverter/lambda$3$Type',964);feb(245,22,{3:1,34:1,22:1,245:1},bGd);var UFd,VFd,WFd,XFd,YFd,ZFd,$Fd,_Fd;var T5=tfb(jze,'GraphFeature',245,WI,dGd,cGd);var eGd;feb(11,1,{34:1,149:1},jGd,kGd,lGd,mGd);_.Fd=function nGd(a){return gGd(this,RD(a,149))};_.Fb=function oGd(a){return hGd(this,a)};_.Sg=function pGd(){return iGd(this)};_.Pg=function qGd(){return this.b};_.Hb=function rGd(){return ohb(this.b)};_.Ib=function sGd(){return this.b};sfb(jze,'Property',11);feb(671,1,fye,uGd);_.Ne=function vGd(a,b){return tGd(this,RD(a,96),RD(b,96))};_.Fb=function wGd(a){return this===a};_.Oe=function xGd(){return new Frb(this)};sfb(jze,'PropertyHolderComparator',671);feb(709,1,Ave,QGd);_.Nb=function RGd(a){Ztb(this,a);};_.Pb=function TGd(){return PGd(this)};_.Qb=function UGd(){$tb();};_.Ob=function SGd(){return !!this.a};sfb(KIe,'ElkGraphUtil/AncestorIterator',709);var Y6=ufb(sIe,'EList');feb(70,56,{20:1,31:1,56:1,16:1,15:1,70:1,61:1});_.bd=function hHd(a,b){VGd(this,a,b);};_.Fc=function iHd(a){return WGd(this,a)};_.cd=function jHd(a,b){return XGd(this,a,b)};_.Gc=function kHd(a){return YGd(this,a)};_.Ii=function lHd(){return new yMd(this)};_.Ji=function mHd(){return new BMd(this)};_.Ki=function nHd(a){return ZGd(this,a)};_.Li=function oHd(){return true};_.Mi=function pHd(a,b){};_.Ni=function qHd(){};_.Oi=function rHd(a,b){$Gd(this,a,b);};_.Pi=function sHd(a,b,c){};_.Qi=function tHd(a,b){};_.Ri=function uHd(a,b,c){};_.Fb=function vHd(a){return _Gd(this,a)};_.Hb=function wHd(){return cHd(this)};_.Si=function xHd(){return false};_.Kc=function yHd(){return new dMd(this)};_.ed=function zHd(){return new mMd(this)};_.fd=function AHd(a){var b;b=this.gc();if(a<0||a>b)throw Adb(new aMd(a,b));return new nMd(this,a)};_.Ui=function BHd(a,b){this.Ti(a,this.dd(b));};_.Mc=function CHd(a){return dHd(this,a)};_.Wi=function DHd(a,b){return b};_.hd=function EHd(a,b){return eHd(this,a,b)};_.Ib=function FHd(){return fHd(this)};_.Yi=function GHd(){return true};_.Zi=function HHd(a,b){return gHd(this,b)};sfb(sIe,'AbstractEList',70);feb(66,70,PIe,YHd,ZHd,$Hd);_.Ei=function _Hd(a,b){return IHd(this,a,b)};_.Fi=function aId(a){return JHd(this,a)};_.Gi=function bId(a,b){KHd(this,a,b);};_.Hi=function cId(a){LHd(this,a);};_.$i=function dId(a){return NHd(this,a)};_.$b=function eId(){OHd(this);};_.Hc=function fId(a){return PHd(this,a)};_.Xb=function gId(a){return QHd(this,a)};_._i=function hId(a){var b,c,d;++this.j;c=this.g==null?0:this.g.length;if(a>c){d=this.g;b=c+(c/2|0)+4;b=0){this.gd(b);return true}else {return false}};_.Xi=function LJd(a,b){return this.Dj(a,this.Zi(a,b))};_.gc=function MJd(){return this.Ej()};_.Pc=function NJd(){return this.Fj()};_.Qc=function OJd(a){return this.Gj(a)};_.Ib=function PJd(){return this.Hj()};sfb(sIe,'DelegatingEList',2093);feb(2094,2093,FJe);_.Ei=function XJd(a,b){return QJd(this,a,b)};_.Fi=function YJd(a){return this.Ei(this.Ej(),a)};_.Gi=function ZJd(a,b){RJd(this,a,b);};_.Hi=function $Jd(a){SJd(this,a);};_.Li=function _Jd(){return !this.Mj()};_.$b=function aKd(){VJd(this);};_.Ij=function bKd(a,b,c,d,e){return new aLd(this,a,b,c,d,e)};_.Jj=function cKd(a){qvd(this.jj(),a);};_.Kj=function dKd(){return null};_.Lj=function eKd(){return -1};_.jj=function fKd(){return null};_.Mj=function gKd(){return false};_.Nj=function hKd(a,b){return b};_.Oj=function iKd(a,b){return b};_.Pj=function jKd(){return false};_.Qj=function kKd(){return !this.Aj()};_.Ti=function lKd(a,b){var c,d;if(this.Pj()){d=this.Qj();c=bJd(this,a,b);this.Jj(this.Ij(7,sgb(b),c,a,d));return c}else {return bJd(this,a,b)}};_.gd=function mKd(a){var b,c,d,e;if(this.Pj()){c=null;d=this.Qj();b=this.Ij(4,e=cJd(this,a),null,a,d);if(this.Mj()&&!!e){c=this.Oj(e,c);if(!c){this.Jj(b);}else {c.nj(b);c.oj();}}else {if(!c){this.Jj(b);}else {c.nj(b);c.oj();}}return e}else {e=cJd(this,a);if(this.Mj()&&!!e){c=this.Oj(e,null);!!c&&c.oj();}return e}};_.Xi=function nKd(a,b){return WJd(this,a,b)};sfb(JHe,'DelegatingNotifyingListImpl',2094);feb(152,1,GJe);_.nj=function PKd(a){return oKd(this,a)};_.oj=function QKd(){pKd(this);};_.gj=function RKd(){return this.d};_.Kj=function SKd(){return null};_.Rj=function TKd(){return null};_.hj=function UKd(a){return -1};_.ij=function VKd(){return yKd(this)};_.jj=function WKd(){return null};_.kj=function XKd(){return HKd(this)};_.lj=function YKd(){return this.o<0?this.o<-2?-2-this.o-1:-1:this.o};_.Sj=function ZKd(){return false};_.mj=function $Kd(a){var b,c,d,e,f,g,h,i,j,k,l;switch(this.d){case 1:case 2:{e=a.gj();switch(e){case 1:case 2:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){this.g=a.ij();a.gj()==1&&(this.d=1);return true}}}}case 4:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){j=JKd(this);i=this.o<0?this.o<-2?-2-this.o-1:-1:this.o;g=a.lj();this.d=6;l=new ZHd(2);if(i<=g){WGd(l,this.n);WGd(l,a.kj());this.g=cD(WC(kE,1),Pwe,28,15,[this.o=i,g+1]);}else {WGd(l,a.kj());WGd(l,this.n);this.g=cD(WC(kE,1),Pwe,28,15,[this.o=g,i]);}this.n=l;j||(this.o=-2-this.o-1);return true}break}}break}case 6:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.jj())&&this.hj(null)==a.hj(null)){j=JKd(this);g=a.lj();k=RD(this.g,53);d=$C(kE,Pwe,28,k.length+1,15,1);b=0;while(b>>0,b.toString(16)));d.a+=' (eventType: ';switch(this.d){case 1:{d.a+='SET';break}case 2:{d.a+='UNSET';break}case 3:{d.a+='ADD';break}case 5:{d.a+='ADD_MANY';break}case 4:{d.a+='REMOVE';break}case 6:{d.a+='REMOVE_MANY';break}case 7:{d.a+='MOVE';break}case 8:{d.a+='REMOVING_ADAPTER';break}case 9:{d.a+='RESOLVE';break}default:{Lhb(d,this.d);break}}IKd(this)&&(d.a+=', touch: true',d);d.a+=', position: ';Lhb(d,this.o<0?this.o<-2?-2-this.o-1:-1:this.o);d.a+=', notifier: ';Mhb(d,this.jj());d.a+=', feature: ';Mhb(d,this.Kj());d.a+=', oldValue: ';Mhb(d,HKd(this));d.a+=', newValue: ';if(this.d==6&&ZD(this.g,53)){c=RD(this.g,53);d.a+='[';for(a=0;a10){if(!this.b||this.c.j!=this.a){this.b=new btb(this);this.a=this.j;}return Zsb(this.b,a)}else {return PHd(this,a)}};_.Yi=function _Ld(){return true};_.a=0;sfb(sIe,'AbstractEList/1',966);feb(302,77,lxe,aMd);sfb(sIe,'AbstractEList/BasicIndexOutOfBoundsException',302);feb(37,1,Ave,dMd);_.Nb=function gMd(a){Ztb(this,a);};_.Xj=function eMd(){if(this.i.j!=this.f){throw Adb(new Jrb)}};_.Yj=function fMd(){return bMd(this)};_.Ob=function hMd(){return this.e!=this.i.gc()};_.Pb=function iMd(){return this.Yj()};_.Qb=function jMd(){cMd(this);};_.e=0;_.f=0;_.g=-1;sfb(sIe,'AbstractEList/EIterator',37);feb(286,37,Jve,mMd,nMd);_.Qb=function vMd(){cMd(this);};_.Rb=function oMd(a){kMd(this,a);};_.Zj=function pMd(){var b;try{b=this.d.Xb(--this.e);this.Xj();this.g=this.e;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.$j=function qMd(a){lMd(this,a);};_.Sb=function rMd(){return this.e!=0};_.Tb=function sMd(){return this.e};_.Ub=function tMd(){return this.Zj()};_.Vb=function uMd(){return this.e-1};_.Wb=function wMd(a){this.$j(a);};sfb(sIe,'AbstractEList/EListIterator',286);feb(355,37,Ave,yMd);_.Yj=function zMd(){return xMd(this)};_.Qb=function AMd(){throw Adb(new jib)};sfb(sIe,'AbstractEList/NonResolvingEIterator',355);feb(398,286,Jve,BMd,CMd);_.Rb=function DMd(a){throw Adb(new jib)};_.Yj=function EMd(){var b;try{b=this.c.Vi(this.e);this.Xj();this.g=this.e++;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.Zj=function FMd(){var b;try{b=this.c.Vi(--this.e);this.Xj();this.g=this.e;return b}catch(a){a=zdb(a);if(ZD(a,77)){this.Xj();throw Adb(new Dvb)}else throw Adb(a)}};_.Qb=function GMd(){throw Adb(new jib)};_.Wb=function HMd(a){throw Adb(new jib)};sfb(sIe,'AbstractEList/NonResolvingEListIterator',398);feb(2080,70,JJe);_.Ei=function PMd(a,b){var c,d,e,f,g,h,i,j,k,l,m;e=b.gc();if(e!=0){j=RD(Ywd(this.a,4),129);k=j==null?0:j.length;m=k+e;d=NMd(this,m);l=k-a;l>0&&hib(j,a,d,a+e,l);i=b.Kc();for(g=0;gc)throw Adb(new aMd(a,c));return new wNd(this,a)};_.$b=function WMd(){var a,b;++this.j;a=RD(Ywd(this.a,4),129);b=a==null?0:a.length;Bde(this,null);$Gd(this,b,a);};_.Hc=function XMd(a){var b,c,d,e,f;b=RD(Ywd(this.a,4),129);if(b!=null){if(a!=null){for(d=b,e=0,f=d.length;e=c)throw Adb(new aMd(a,c));return b[a]};_.dd=function ZMd(a){var b,c,d;b=RD(Ywd(this.a,4),129);if(b!=null){if(a!=null){for(c=0,d=b.length;cc)throw Adb(new aMd(a,c));return new oNd(this,a)};_.Ti=function cNd(a,b){var c,d,e;c=MMd(this);e=c==null?0:c.length;if(a>=e)throw Adb(new veb(MIe+a+NIe+e));if(b>=e)throw Adb(new veb(OIe+b+NIe+e));d=c[b];if(a!=b){a0&&hib(a,0,b,0,c);return b};_.Qc=function iNd(a){var b,c,d;b=RD(Ywd(this.a,4),129);d=b==null?0:b.length;if(d>0){if(a.lengthd&&bD(a,d,null);return a};var JMd;sfb(sIe,'ArrayDelegatingEList',2080);feb(1051,37,Ave,jNd);_.Xj=function kNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};_.Qb=function lNd(){cMd(this);this.a=RD(Ywd(this.b.a,4),129);};sfb(sIe,'ArrayDelegatingEList/EIterator',1051);feb(722,286,Jve,nNd,oNd);_.Xj=function pNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};_.$j=function qNd(a){lMd(this,a);this.a=RD(Ywd(this.b.a,4),129);};_.Qb=function rNd(){cMd(this);this.a=RD(Ywd(this.b.a,4),129);};sfb(sIe,'ArrayDelegatingEList/EListIterator',722);feb(1052,355,Ave,sNd);_.Xj=function tNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};sfb(sIe,'ArrayDelegatingEList/NonResolvingEIterator',1052);feb(723,398,Jve,vNd,wNd);_.Xj=function xNd(){if(this.b.j!=this.f||dE(RD(Ywd(this.b.a,4),129))!==dE(this.a)){throw Adb(new Jrb)}};sfb(sIe,'ArrayDelegatingEList/NonResolvingEListIterator',723);feb(615,302,lxe,yNd);sfb(sIe,'BasicEList/BasicIndexOutOfBoundsException',615);feb(710,66,PIe,zNd);_.bd=function ANd(a,b){throw Adb(new jib)};_.Fc=function BNd(a){throw Adb(new jib)};_.cd=function CNd(a,b){throw Adb(new jib)};_.Gc=function DNd(a){throw Adb(new jib)};_.$b=function ENd(){throw Adb(new jib)};_._i=function FNd(a){throw Adb(new jib)};_.Kc=function GNd(){return this.Ii()};_.ed=function HNd(){return this.Ji()};_.fd=function INd(a){return this.Ki(a)};_.Ti=function JNd(a,b){throw Adb(new jib)};_.Ui=function KNd(a,b){throw Adb(new jib)};_.gd=function LNd(a){throw Adb(new jib)};_.Mc=function MNd(a){throw Adb(new jib)};_.hd=function NNd(a,b){throw Adb(new jib)};sfb(sIe,'BasicEList/UnmodifiableEList',710);feb(721,1,{3:1,20:1,16:1,15:1,61:1,597:1});_.bd=function mOd(a,b){ONd(this,a,RD(b,44));};_.Fc=function nOd(a){return PNd(this,RD(a,44))};_.Jc=function vOd(a){xgb(this,a);};_.Xb=function wOd(a){return RD(QHd(this.c,a),136)};_.Ti=function FOd(a,b){return RD(this.c.Ti(a,b),44)};_.Ui=function GOd(a,b){eOd(this,a,RD(b,44));};_.Lc=function JOd(){return new SDb(null,new Swb(this,16))};_.gd=function KOd(a){return RD(this.c.gd(a),44)};_.hd=function MOd(a,b){return kOd(this,a,RD(b,44))};_.jd=function OOd(a){tvb(this,a);};_.Nc=function POd(){return new Swb(this,16)};_.Oc=function QOd(){return new SDb(null,new Swb(this,16))};_.cd=function oOd(a,b){return this.c.cd(a,b)};_.Gc=function pOd(a){return this.c.Gc(a)};_.$b=function qOd(){this.c.$b();};_.Hc=function rOd(a){return this.c.Hc(a)};_.Ic=function sOd(a){return Be(this.c,a)};_._j=function tOd(){var a,b,c;if(this.d==null){this.d=$C(D6,KJe,66,2*this.f+1,0,1);c=this.e;this.f=0;for(b=this.c.Kc();b.e!=b.i.gc();){a=RD(b.Yj(),136);UNd(this,a);}this.e=c;}};_.Fb=function uOd(a){return ZNd(this,a)};_.Hb=function xOd(){return cHd(this.c)};_.dd=function yOd(a){return this.c.dd(a)};_.ak=function zOd(){this.c=new YOd(this);};_.dc=function AOd(){return this.f==0};_.Kc=function BOd(){return this.c.Kc()};_.ed=function COd(){return this.c.ed()};_.fd=function DOd(a){return this.c.fd(a)};_.bk=function EOd(){return dOd(this)};_.ck=function HOd(a,b,c){return new ZPd(a,b,c)};_.dk=function IOd(){return new cPd};_.Mc=function LOd(a){return hOd(this,a)};_.gc=function NOd(){return this.f};_.kd=function ROd(a,b){return new Rkb(this.c,a,b)};_.Pc=function SOd(){return this.c.Pc()};_.Qc=function TOd(a){return this.c.Qc(a)};_.Ib=function UOd(){return fHd(this.c)};_.e=0;_.f=0;sfb(sIe,'BasicEMap',721);feb(1046,66,PIe,YOd);_.Mi=function ZOd(a,b){VOd(this,RD(b,136));};_.Pi=function _Od(a,b,c){var d;++(d=this,RD(b,136),d).a.e;};_.Qi=function aPd(a,b){WOd(this,RD(b,136));};_.Ri=function bPd(a,b,c){XOd(this,RD(b,136),RD(c,136));};_.Oi=function $Od(a,b){TNd(this.a);};sfb(sIe,'BasicEMap/1',1046);feb(1047,66,PIe,cPd);_.aj=function dPd(a){return $C(N6,LJe,621,a,0,1)};sfb(sIe,'BasicEMap/2',1047);feb(1048,Eve,Fve,ePd);_.$b=function fPd(){this.a.c.$b();};_.Hc=function gPd(a){return QNd(this.a,a)};_.Kc=function hPd(){return this.a.f==0?(jQd(),iQd.a):new DPd(this.a)};_.Mc=function iPd(a){var b;b=this.a.f;jOd(this.a,a);return this.a.f!=b};_.gc=function jPd(){return this.a.f};sfb(sIe,'BasicEMap/3',1048);feb(1049,31,Dve,kPd);_.$b=function lPd(){this.a.c.$b();};_.Hc=function mPd(a){return RNd(this.a,a)};_.Kc=function nPd(){return this.a.f==0?(jQd(),iQd.a):new FPd(this.a)};_.gc=function oPd(){return this.a.f};sfb(sIe,'BasicEMap/4',1049);feb(1050,Eve,Fve,qPd);_.$b=function rPd(){this.a.c.$b();};_.Hc=function sPd(a){var b,c,d,e,f,g,h,i,j;if(this.a.f>0&&ZD(a,44)){this.a._j();i=RD(a,44);h=i.ld();e=h==null?0:tb(h);f=bOd(this.a,e);b=this.a.d[f];if(b){c=RD(b.g,379);j=b.i;for(g=0;g'+this.c};_.a=0;var N6=sfb(sIe,'BasicEMap/EntryImpl',621);feb(546,1,{},hQd);sfb(sIe,'BasicEMap/View',546);var iQd;feb(783,1,{});_.Fb=function xQd(a){return Rt((yob(),vob),a)};_.Hb=function yQd(){return Cob((yob(),vob))};_.Ib=function zQd(){return Fe((yob(),vob))};sfb(sIe,'ECollections/BasicEmptyUnmodifiableEList',783);feb(1348,1,Jve,AQd);_.Nb=function CQd(a){Ztb(this,a);};_.Rb=function BQd(a){throw Adb(new jib)};_.Ob=function DQd(){return false};_.Sb=function EQd(){return false};_.Pb=function FQd(){throw Adb(new Dvb)};_.Tb=function GQd(){return 0};_.Ub=function HQd(){throw Adb(new Dvb)};_.Vb=function IQd(){return -1};_.Qb=function JQd(){throw Adb(new jib)};_.Wb=function KQd(a){throw Adb(new jib)};sfb(sIe,'ECollections/BasicEmptyUnmodifiableEList/1',1348);feb(1346,783,{20:1,16:1,15:1,61:1},LQd);_.bd=function MQd(a,b){mQd();};_.Fc=function NQd(a){return nQd()};_.cd=function OQd(a,b){return oQd()};_.Gc=function PQd(a){return pQd()};_.$b=function QQd(){qQd();};_.Hc=function RQd(a){return false};_.Ic=function SQd(a){return false};_.Jc=function TQd(a){xgb(this,a);};_.Xb=function UQd(a){return Iob((yob(),a)),null};_.dd=function VQd(a){return -1};_.dc=function WQd(){return true};_.Kc=function XQd(){return this.a};_.ed=function YQd(){return this.a};_.fd=function ZQd(a){return this.a};_.Ti=function $Qd(a,b){return rQd()};_.Ui=function _Qd(a,b){sQd();};_.Lc=function aRd(){return new SDb(null,new Swb(this,16))};_.gd=function bRd(a){return tQd()};_.Mc=function cRd(a){return uQd()};_.hd=function dRd(a,b){return vQd()};_.gc=function eRd(){return 0};_.jd=function fRd(a){tvb(this,a);};_.Nc=function gRd(){return new Swb(this,16)};_.Oc=function hRd(){return new SDb(null,new Swb(this,16))};_.kd=function iRd(a,b){return yob(),new Rkb(vob,a,b)};_.Pc=function jRd(){return De((yob(),vob))};_.Qc=function kRd(a){return yob(),Ee(vob,a)};sfb(sIe,'ECollections/EmptyUnmodifiableEList',1346);feb(1347,783,{20:1,16:1,15:1,61:1,597:1},lRd);_.bd=function mRd(a,b){mQd();};_.Fc=function nRd(a){return nQd()};_.cd=function oRd(a,b){return oQd()};_.Gc=function pRd(a){return pQd()};_.$b=function qRd(){qQd();};_.Hc=function rRd(a){return false};_.Ic=function sRd(a){return false};_.Jc=function tRd(a){xgb(this,a);};_.Xb=function uRd(a){return Iob((yob(),a)),null};_.dd=function vRd(a){return -1};_.dc=function wRd(){return true};_.Kc=function xRd(){return this.a};_.ed=function yRd(){return this.a};_.fd=function zRd(a){return this.a};_.Ti=function BRd(a,b){return rQd()};_.Ui=function CRd(a,b){sQd();};_.Lc=function DRd(){return new SDb(null,new Swb(this,16))};_.gd=function ERd(a){return tQd()};_.Mc=function FRd(a){return uQd()};_.hd=function GRd(a,b){return vQd()};_.gc=function HRd(){return 0};_.jd=function IRd(a){tvb(this,a);};_.Nc=function JRd(){return new Swb(this,16)};_.Oc=function KRd(){return new SDb(null,new Swb(this,16))};_.kd=function LRd(a,b){return yob(),new Rkb(vob,a,b)};_.Pc=function MRd(){return De((yob(),vob))};_.Qc=function NRd(a){return yob(),Ee(vob,a)};_.bk=function ARd(){return yob(),yob(),wob};sfb(sIe,'ECollections/EmptyUnmodifiableEMap',1347);var Z6=ufb(sIe,'Enumerator');var ORd;feb(288,1,{288:1},lSd);_.Fb=function pSd(a){var b;if(this===a)return true;if(!ZD(a,288))return false;b=RD(a,288);return this.f==b.f&&rSd(this.i,b.i)&&qSd(this.a,(this.f&256)!=0?(b.f&256)!=0?b.a:null:(b.f&256)!=0?null:b.a)&&qSd(this.d,b.d)&&qSd(this.g,b.g)&&qSd(this.e,b.e)&&iSd(this,b)};_.Hb=function uSd(){return this.f};_.Ib=function CSd(){return jSd(this)};_.f=0;var SRd=0,TRd=0,URd=0,VRd=0,WRd=0,XRd=0,YRd=0,ZRd=0,$Rd=0,_Rd,aSd=0,bSd=0,cSd=0,dSd=0,eSd,fSd;sfb(sIe,'URI',288);feb(1121,45,Hxe,MSd);_.zc=function NSd(a,b){return RD($jb(this,WD(a),RD(b,288)),288)};sfb(sIe,'URI/URICache',1121);feb(506,66,PIe,OSd,PSd);_.Si=function QSd(){return true};sfb(sIe,'UniqueEList',506);feb(590,63,swe,RSd);sfb(sIe,'WrappedException',590);var f7=ufb(vHe,OJe);var A7=ufb(vHe,PJe);var y7=ufb(vHe,QJe);var g7=ufb(vHe,RJe);var i7=ufb(vHe,SJe);var h7=ufb(vHe,'EClass');var k7=ufb(vHe,'EDataType');var SSd;feb(1233,45,Hxe,VSd);_.xc=function WSd(a){return bE(a)?Xjb(this,a):Wd(qtb(this.f,a))};sfb(vHe,'EDataType/Internal/ConversionDelegate/Factory/Registry/Impl',1233);var m7=ufb(vHe,'EEnum');var l7=ufb(vHe,TJe);var o7=ufb(vHe,UJe);var s7=ufb(vHe,VJe);var XSd;var u7=ufb(vHe,WJe);var v7=ufb(vHe,XJe);feb(1042,1,{},_Sd);_.Ib=function aTd(){return 'NIL'};sfb(vHe,'EStructuralFeature/Internal/DynamicValueHolder/1',1042);var bTd;feb(1041,45,Hxe,eTd);_.xc=function fTd(a){return bE(a)?Xjb(this,a):Wd(qtb(this.f,a))};sfb(vHe,'EStructuralFeature/Internal/SettingDelegate/Factory/Registry/Impl',1041);var z7=ufb(vHe,YJe);var B7=ufb(vHe,'EValidator/PatternMatcher');var gTd;var iTd;var kTd;var mTd,nTd,oTd,pTd,qTd,rTd,sTd,tTd,uTd,vTd,wTd,xTd,yTd,zTd,ATd,BTd,CTd,DTd,ETd,FTd,GTd,HTd,ITd;var Jbb=ufb(ZJe,'FeatureMap/Entry');feb(545,1,{76:1},KTd);_.Lk=function LTd(){return this.a};_.md=function MTd(){return this.b};sfb(SHe,'BasicEObjectImpl/1',545);feb(1040,1,$Je,NTd);_.Fk=function OTd(a){return Fvd(this.a,this.b,a)};_.Qj=function PTd(){return Lvd(this.a,this.b)};_.Wb=function QTd(a){Xvd(this.a,this.b,a);};_.Gk=function RTd(){_vd(this.a,this.b);};sfb(SHe,'BasicEObjectImpl/4',1040);feb(2081,1,{114:1});_.Mk=function UTd(a){this.e=a==0?STd:$C(jJ,rve,1,a,5,1);};_.li=function VTd(a){return this.e[a]};_.mi=function WTd(a,b){this.e[a]=b;};_.ni=function XTd(a){this.e[a]=null;};_.Nk=function YTd(){return this.c};_.Ok=function ZTd(){throw Adb(new jib)};_.Pk=function $Td(){throw Adb(new jib)};_.Qk=function _Td(){return this.d};_.Rk=function aUd(){return this.e!=null};_.Sk=function bUd(a){this.c=a;};_.Tk=function cUd(a){throw Adb(new jib)};_.Uk=function dUd(a){throw Adb(new jib)};_.Vk=function eUd(a){this.d=a;};var STd;sfb(SHe,'BasicEObjectImpl/EPropertiesHolderBaseImpl',2081);feb(192,2081,{114:1},fUd);_.Ok=function gUd(){return this.a};_.Pk=function hUd(){return this.b};_.Tk=function iUd(a){this.a=a;};_.Uk=function jUd(a){this.b=a;};sfb(SHe,'BasicEObjectImpl/EPropertiesHolderImpl',192);feb(516,99,RHe,kUd);_.uh=function lUd(){return this.f};_.zh=function mUd(){return this.k};_.Bh=function nUd(a,b){this.g=a;this.i=b;};_.Dh=function oUd(){return (this.j&2)==0?this.ii():this.$h().Nk()};_.Fh=function pUd(){return this.i};_.wh=function qUd(){return (this.j&1)!=0};_.Ph=function rUd(){return this.g};_.Vh=function sUd(){return (this.j&4)!=0};_.$h=function tUd(){return !this.k&&(this.k=new fUd),this.k};_.ci=function uUd(a){this.$h().Sk(a);a?(this.j|=2):(this.j&=-3);};_.ei=function vUd(a){this.$h().Uk(a);a?(this.j|=4):(this.j&=-5);};_.ii=function wUd(){return (lTd(),kTd).S};_.i=0;_.j=1;sfb(SHe,'EObjectImpl',516);feb(798,516,{110:1,94:1,93:1,58:1,114:1,54:1,99:1},zUd);_.li=function AUd(a){return this.e[a]};_.mi=function BUd(a,b){this.e[a]=b;};_.ni=function CUd(a){this.e[a]=null;};_.Dh=function DUd(){return this.d};_.Ih=function EUd(a){return BYd(this.d,a)};_.Kh=function FUd(){return this.d};_.Oh=function GUd(){return this.e!=null};_.$h=function HUd(){!this.k&&(this.k=new VUd);return this.k};_.ci=function IUd(a){this.d=a;};_.hi=function JUd(){var a;if(this.e==null){a=AYd(this.d);this.e=a==0?xUd:$C(jJ,rve,1,a,5,1);}return this};_.ji=function KUd(){return 0};var xUd;sfb(SHe,'DynamicEObjectImpl',798);feb(1522,798,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1},LUd);_.Fb=function NUd(a){return this===a};_.Hb=function RUd(){return kFb(this)};_.ci=function MUd(a){this.d=a;this.b=wYd(a,'key');this.c=wYd(a,aIe);};_.Bi=function OUd(){var a;if(this.a==-1){a=Gvd(this,this.b);this.a=a==null?0:tb(a);}return this.a};_.ld=function PUd(){return Gvd(this,this.b)};_.md=function QUd(){return Gvd(this,this.c)};_.Ci=function SUd(a){this.a=a;};_.Di=function TUd(a){Xvd(this,this.b,a);};_.nd=function UUd(a){var b;b=Gvd(this,this.c);Xvd(this,this.c,a);return b};_.a=0;sfb(SHe,'DynamicEObjectImpl/BasicEMapEntry',1522);feb(1523,1,{114:1},VUd);_.Mk=function WUd(a){throw Adb(new jib)};_.li=function XUd(a){throw Adb(new jib)};_.mi=function YUd(a,b){throw Adb(new jib)};_.ni=function ZUd(a){throw Adb(new jib)};_.Nk=function $Ud(){throw Adb(new jib)};_.Ok=function _Ud(){return this.a};_.Pk=function aVd(){return this.b};_.Qk=function bVd(){return this.c};_.Rk=function cVd(){throw Adb(new jib)};_.Sk=function dVd(a){throw Adb(new jib)};_.Tk=function eVd(a){this.a=a;};_.Uk=function fVd(a){this.b=a;};_.Vk=function gVd(a){this.c=a;};sfb(SHe,'DynamicEObjectImpl/DynamicEPropertiesHolderImpl',1523);feb(519,158,{110:1,94:1,93:1,598:1,155:1,58:1,114:1,54:1,99:1,519:1,158:1,119:1,120:1},pVd);_.Ah=function qVd(a){return iVd(this,a)};_.Lh=function rVd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.d;case 2:return c?(!this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),this.b):(!this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),dOd(this.b));case 3:return kVd(this);case 4:return !this.a&&(this.a=new XZd(r7,this,4)),this.a;case 5:return !this.c&&(this.c=new zie(r7,this,5)),this.c;}return zvd(this,a-AYd((JTd(),mTd)),vYd((d=RD(Ywd(this,16),29),!d?mTd:d),a),b,c)};_.Sh=function sVd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 3:!!this.Cb&&(c=(e=this.Db>>16,e>=0?iVd(this,c):this.Cb.Th(this,-1-e,null,c)));return hVd(this,RD(a,155),c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),mTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),mTd)),a,c)};_.Uh=function tVd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 2:return !this.b&&(this.b=new SVd((JTd(),FTd),C8,this)),BVd(this.b,a,c);case 3:return hVd(this,null,c);case 4:return !this.a&&(this.a=new XZd(r7,this,4)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),mTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),mTd)),a,c)};_.Wh=function uVd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.d!=null;case 2:return !!this.b&&this.b.f!=0;case 3:return !!kVd(this);case 4:return !!this.a&&this.a.i!=0;case 5:return !!this.c&&this.c.i!=0;}return Avd(this,a-AYd((JTd(),mTd)),vYd((b=RD(Ywd(this,16),29),!b?mTd:b),a))};_.bi=function vVd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:mVd(this,WD(b));return;case 2:!this.b&&(this.b=new SVd((JTd(),FTd),C8,this));CVd(this.b,b);return;case 3:lVd(this,RD(b,155));return;case 4:!this.a&&(this.a=new XZd(r7,this,4));sLd(this.a);!this.a&&(this.a=new XZd(r7,this,4));YGd(this.a,RD(b,16));return;case 5:!this.c&&(this.c=new zie(r7,this,5));sLd(this.c);!this.c&&(this.c=new zie(r7,this,5));YGd(this.c,RD(b,16));return;}Bvd(this,a-AYd((JTd(),mTd)),vYd((c=RD(Ywd(this,16),29),!c?mTd:c),a),b);};_.ii=function wVd(){return JTd(),mTd};_.ki=function xVd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:nVd(this,null);return;case 2:!this.b&&(this.b=new SVd((JTd(),FTd),C8,this));this.b.c.$b();return;case 3:lVd(this,null);return;case 4:!this.a&&(this.a=new XZd(r7,this,4));sLd(this.a);return;case 5:!this.c&&(this.c=new zie(r7,this,5));sLd(this.c);return;}Cvd(this,a-AYd((JTd(),mTd)),vYd((b=RD(Ywd(this,16),29),!b?mTd:b),a));};_.Ib=function yVd(){return oVd(this)};_.d=null;sfb(SHe,'EAnnotationImpl',519);feb(141,721,_Je,DVd);_.Gi=function EVd(a,b){zVd(this,a,RD(b,44));};_.Wk=function FVd(a,b){return AVd(this,RD(a,44),b)};_.$i=function GVd(a){return RD(RD(this.c,71).$i(a),136)};_.Ii=function HVd(){return RD(this.c,71).Ii()};_.Ji=function IVd(){return RD(this.c,71).Ji()};_.Ki=function JVd(a){return RD(this.c,71).Ki(a)};_.Xk=function KVd(a,b){return BVd(this,a,b)};_.Fk=function LVd(a){return RD(this.c,79).Fk(a)};_.ak=function MVd(){};_.Qj=function NVd(){return RD(this.c,79).Qj()};_.ck=function OVd(a,b,c){var d;d=RD(BXd(this.b).wi().si(this.b),136);d.Ci(a);d.Di(b);d.nd(c);return d};_.dk=function PVd(){return new uje(this)};_.Wb=function QVd(a){CVd(this,a);};_.Gk=function RVd(){RD(this.c,79).Gk();};sfb(ZJe,'EcoreEMap',141);feb(165,141,_Je,SVd);_._j=function TVd(){var a,b,c,d,e,f;if(this.d==null){f=$C(D6,KJe,66,2*this.f+1,0,1);for(c=this.c.Kc();c.e!=c.i.gc();){b=RD(c.Yj(),136);d=b.Bi();e=(d&lve)%f.length;a=f[e];!a&&(a=f[e]=new uje(this));a.Fc(b);}this.d=f;}};sfb(SHe,'EAnnotationImpl/1',165);feb(292,448,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,481:1,54:1,99:1,158:1,292:1,119:1,120:1});_.Lh=function eWd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),this.Jk()?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Uh=function fWd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function gWd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.Jk();case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function hWd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:this.ui(WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:this.Zk(RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function iWd(){return JTd(),HTd};_.ki=function jWd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:this.ui(null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.Zk(1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function kWd(){WVd(this);this.Bb|=1;};_.Hk=function lWd(){return WVd(this)};_.Ik=function mWd(){return this.t};_.Jk=function nWd(){var a;return a=this.t,a>1||a==-1};_.Si=function oWd(){return (this.Bb&512)!=0};_.Yk=function pWd(a,b){return ZVd(this,a,b)};_.Zk=function qWd(a){bWd(this,a);};_.Ib=function rWd(){return cWd(this)};_.s=0;_.t=1;sfb(SHe,'ETypedElementImpl',292);feb(462,292,{110:1,94:1,93:1,155:1,197:1,58:1,179:1,69:1,114:1,481:1,54:1,99:1,158:1,462:1,292:1,119:1,120:1,692:1});_.Ah=function IWd(a){return sWd(this,a)};_.Lh=function JWd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),this.Jk()?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function KWd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 17:!!this.Cb&&(c=(e=this.Db>>16,e>=0?sWd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,17,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),f.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function LWd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 17:return xvd(this,null,17,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function MWd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return this.Jk();case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function NWd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:this.Zk(RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function OWd(){return JTd(),GTd};_.ki=function PWd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.Zk(1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.pi=function QWd(){Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.pk=function RWd(){return this.f};_.ik=function SWd(){return tWd(this)};_.qk=function TWd(){return uWd(this)};_.uk=function UWd(){return null};_.$k=function VWd(){return this.k};_.Lj=function WWd(){return this.n};_.vk=function XWd(){return vWd(this)};_.wk=function YWd(){var a,b,c,d,e,f,g,h,i;if(!this.p){c=uWd(this);(c.i==null&&rYd(c),c.i).length;d=this.uk();!!d&&AYd(uWd(d));e=WVd(this);g=e.kk();a=!g?null:(g.i&1)!=0?g==xdb?QI:g==kE?bJ:g==jE?ZI:g==iE?VI:g==lE?eJ:g==wdb?lJ:g==gE?RI:SI:g;b=tWd(this);h=e.ik();Mje(this);(this.Bb&Ove)!=0&&(!!(f=Tee((lke(),jke),c))&&f!=this||!!(f=zfe(Qee(jke,this))))?(this.p=new Z6d(this,f)):this.Jk()?this.al()?!d?(this.Bb&bKe)!=0?!a?this.bl()?(this.p=new i7d(42,this)):(this.p=new i7d(0,this)):a==UK?(this.p=new g7d(50,O6,this)):this.bl()?(this.p=new g7d(43,a,this)):(this.p=new g7d(1,a,this)):!a?this.bl()?(this.p=new i7d(44,this)):(this.p=new i7d(2,this)):a==UK?(this.p=new g7d(41,O6,this)):this.bl()?(this.p=new g7d(45,a,this)):(this.p=new g7d(3,a,this)):(this.Bb&bKe)!=0?!a?this.bl()?(this.p=new j7d(46,this,d)):(this.p=new j7d(4,this,d)):this.bl()?(this.p=new h7d(47,a,this,d)):(this.p=new h7d(5,a,this,d)):!a?this.bl()?(this.p=new j7d(48,this,d)):(this.p=new j7d(6,this,d)):this.bl()?(this.p=new h7d(49,a,this,d)):(this.p=new h7d(7,a,this,d)):ZD(e,156)?a==Jbb?(this.p=new i7d(40,this)):(this.Bb&512)!=0?(this.Bb&bKe)!=0?!a?(this.p=new i7d(8,this)):(this.p=new g7d(9,a,this)):!a?(this.p=new i7d(10,this)):(this.p=new g7d(11,a,this)):(this.Bb&bKe)!=0?!a?(this.p=new i7d(12,this)):(this.p=new g7d(13,a,this)):!a?(this.p=new i7d(14,this)):(this.p=new g7d(15,a,this)):!d?this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new i7d(16,this)):(this.p=new g7d(17,a,this)):!a?(this.p=new i7d(18,this)):(this.p=new g7d(19,a,this)):(this.Bb&bKe)!=0?!a?(this.p=new i7d(20,this)):(this.p=new g7d(21,a,this)):!a?(this.p=new i7d(22,this)):(this.p=new g7d(23,a,this)):(i=d.t,i>1||i==-1?this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new j7d(24,this,d)):(this.p=new h7d(25,a,this,d)):!a?(this.p=new j7d(26,this,d)):(this.p=new h7d(27,a,this,d)):(this.Bb&bKe)!=0?!a?(this.p=new j7d(28,this,d)):(this.p=new h7d(29,a,this,d)):!a?(this.p=new j7d(30,this,d)):(this.p=new h7d(31,a,this,d)):this.bl()?(this.Bb&bKe)!=0?!a?(this.p=new j7d(32,this,d)):(this.p=new h7d(33,a,this,d)):!a?(this.p=new j7d(34,this,d)):(this.p=new h7d(35,a,this,d)):(this.Bb&bKe)!=0?!a?(this.p=new j7d(36,this,d)):(this.p=new h7d(37,a,this,d)):!a?(this.p=new j7d(38,this,d)):(this.p=new h7d(39,a,this,d))):this._k()?this.bl()?(this.p=new K7d(RD(e,29),this,d)):(this.p=new C7d(RD(e,29),this,d)):ZD(e,156)?a==Jbb?(this.p=new i7d(40,this)):(this.Bb&bKe)!=0?!a?(this.p=new J8d(RD(e,156),b,h,this)):(this.p=new L8d(b,h,this,(a8d(),g==kE?Y7d:g==xdb?T7d:g==lE?Z7d:g==jE?X7d:g==iE?W7d:g==wdb?_7d:g==gE?U7d:g==hE?V7d:$7d))):!a?(this.p=new C8d(RD(e,156),b,h,this)):(this.p=new E8d(b,h,this,(a8d(),g==kE?Y7d:g==xdb?T7d:g==lE?Z7d:g==jE?X7d:g==iE?W7d:g==wdb?_7d:g==gE?U7d:g==hE?V7d:$7d))):this.al()?!d?(this.Bb&bKe)!=0?this.bl()?(this.p=new d9d(RD(e,29),this)):(this.p=new b9d(RD(e,29),this)):this.bl()?(this.p=new _8d(RD(e,29),this)):(this.p=new Z8d(RD(e,29),this)):(this.Bb&bKe)!=0?this.bl()?(this.p=new l9d(RD(e,29),this,d)):(this.p=new j9d(RD(e,29),this,d)):this.bl()?(this.p=new h9d(RD(e,29),this,d)):(this.p=new f9d(RD(e,29),this,d)):this.bl()?!d?(this.Bb&bKe)!=0?(this.p=new p9d(RD(e,29),this)):(this.p=new n9d(RD(e,29),this)):(this.Bb&bKe)!=0?(this.p=new t9d(RD(e,29),this,d)):(this.p=new r9d(RD(e,29),this,d)):!d?(this.Bb&bKe)!=0?(this.p=new v9d(RD(e,29),this)):(this.p=new N8d(RD(e,29),this)):(this.Bb&bKe)!=0?(this.p=new z9d(RD(e,29),this,d)):(this.p=new x9d(RD(e,29),this,d));}return this.p};_.rk=function ZWd(){return (this.Bb&gwe)!=0};_._k=function $Wd(){return false};_.al=function _Wd(){return false};_.sk=function aXd(){return (this.Bb&Ove)!=0};_.xk=function bXd(){return wWd(this)};_.bl=function cXd(){return false};_.tk=function dXd(){return (this.Bb&bKe)!=0};_.cl=function eXd(a){this.k=a;};_.ui=function fXd(a){CWd(this,a);};_.Ib=function gXd(){return GWd(this)};_.e=false;_.n=0;sfb(SHe,'EStructuralFeatureImpl',462);feb(331,462,{110:1,94:1,93:1,35:1,155:1,197:1,58:1,179:1,69:1,114:1,481:1,54:1,99:1,331:1,158:1,462:1,292:1,119:1,120:1,692:1},mXd);_.Lh=function nXd(a,b,c){var d,e;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),jXd(this)?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);case 18:return Geb(),(this.Bb&QHe)!=0?true:false;case 19:if(b)return iXd(this);return hXd(this);}return zvd(this,a-AYd((JTd(),nTd)),vYd((d=RD(Ywd(this,16),29),!d?nTd:d),a),b,c)};_.Wh=function oXd(a){var b,c;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return jXd(this);case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);case 18:return (this.Bb&QHe)!=0;case 19:return !!hXd(this);}return Avd(this,a-AYd((JTd(),nTd)),vYd((b=RD(Ywd(this,16),29),!b?nTd:b),a))};_.bi=function pXd(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:lXd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;case 18:kXd(this,Heb(TD(b)));return;}Bvd(this,a-AYd((JTd(),nTd)),vYd((c=RD(Ywd(this,16),29),!c?nTd:c),a),b);};_.ii=function qXd(){return JTd(),nTd};_.ki=function rXd(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:this.b=0;bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;case 18:kXd(this,false);return;}Cvd(this,a-AYd((JTd(),nTd)),vYd((b=RD(Ywd(this,16),29),!b?nTd:b),a));};_.pi=function sXd(){iXd(this);Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.Jk=function tXd(){return jXd(this)};_.Yk=function uXd(a,b){this.b=0;this.a=null;return ZVd(this,a,b)};_.Zk=function vXd(a){lXd(this,a);};_.Ib=function wXd(){var a;if((this.Db&64)!=0)return GWd(this);a=new Shb(GWd(this));a.a+=' (iD: ';Ohb(a,(this.Bb&QHe)!=0);a.a+=')';return a.a};_.b=0;sfb(SHe,'EAttributeImpl',331);feb(364,448,{110:1,94:1,93:1,142:1,155:1,197:1,58:1,114:1,54:1,99:1,364:1,158:1,119:1,120:1,691:1});_.dl=function NXd(a){return a.Dh()==this};_.Ah=function OXd(a){return AXd(this,a)};_.Bh=function PXd(a,b){this.w=null;this.Db=b<<16|this.Db&255;this.Cb=a;};_.Lh=function QXd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return DXd(this);case 4:return this.ik();case 5:return this.F;case 6:if(b)return BXd(this);return xXd(this);case 7:return !this.A&&(this.A=new iie(z7,this,7)),this.A;}return zvd(this,a-AYd(this.ii()),vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),a),b,c)};_.Sh=function RXd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),f.wk().zk(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Uh=function SXd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?this.ii():d),b),69),e.wk().Ak(this,Wwd(this),b-AYd(this.ii()),a,c)};_.Wh=function TXd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return this.ik()!=null;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;}return Avd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a))};_.bi=function UXd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;}Bvd(this,a-AYd(this.ii()),vYd((c=RD(Ywd(this,16),29),!c?this.ii():c),a),b);};_.ii=function VXd(){return JTd(),pTd};_.ki=function WXd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;}Cvd(this,a-AYd(this.ii()),vYd((b=RD(Ywd(this,16),29),!b?this.ii():b),a));};_.hk=function XXd(){var a;return this.G==-1&&(this.G=(a=BXd(this),a?fZd(a.vi(),this):-1)),this.G};_.ik=function YXd(){return null};_.jk=function ZXd(){return BXd(this)};_.el=function $Xd(){return this.v};_.kk=function _Xd(){return DXd(this)};_.lk=function aYd(){return this.D!=null?this.D:this.B};_.mk=function bYd(){return this.F};_.fk=function cYd(a){return FXd(this,a)};_.fl=function dYd(a){this.v=a;};_.gl=function eYd(a){GXd(this,a);};_.hl=function fYd(a){this.C=a;};_.ui=function gYd(a){LXd(this,a);};_.Ib=function hYd(){return MXd(this)};_.C=null;_.D=null;_.G=-1;sfb(SHe,'EClassifierImpl',364);feb(90,364,{110:1,94:1,93:1,29:1,142:1,155:1,197:1,58:1,114:1,54:1,99:1,90:1,364:1,158:1,482:1,119:1,120:1,691:1},HYd);_.dl=function IYd(a){return DYd(this,a.Dh())};_.Lh=function JYd(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return this.D!=null?this.D:this.B;case 3:return DXd(this);case 4:return null;case 5:return this.F;case 6:if(b)return BXd(this);return xXd(this);case 7:return !this.A&&(this.A=new iie(z7,this,7)),this.A;case 8:return Geb(),(this.Bb&256)!=0?true:false;case 9:return Geb(),(this.Bb&512)!=0?true:false;case 10:return zYd(this);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),this.q;case 12:return mYd(this);case 13:return qYd(this);case 14:return qYd(this),this.r;case 15:return mYd(this),this.k;case 16:return nYd(this);case 17:return pYd(this);case 18:return rYd(this);case 19:return sYd(this);case 20:return mYd(this),this.o;case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),this.s;case 22:return tYd(this);case 23:return oYd(this);}return zvd(this,a-AYd((JTd(),oTd)),vYd((d=RD(Ywd(this,16),29),!d?oTd:d),a),b,c)};_.Sh=function KYd(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 6:!!this.Cb&&(c=(e=this.Db>>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),qLd(this.q,a,c);case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),qLd(this.s,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),oTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),oTd)),a,c)};_.Uh=function LYd(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);case 11:return !this.q&&(this.q=new C5d(s7,this,11,10)),rLd(this.q,a,c);case 21:return !this.s&&(this.s=new C5d(y7,this,21,17)),rLd(this.s,a,c);case 22:return rLd(tYd(this),a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),oTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),oTd)),a,c)};_.Wh=function MYd(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return false;case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;case 8:return (this.Bb&256)!=0;case 9:return (this.Bb&512)!=0;case 10:return !!this.u&&tYd(this.u.a).i!=0&&!(!!this.n&&d$d(this.n));case 11:return !!this.q&&this.q.i!=0;case 12:return mYd(this).i!=0;case 13:return qYd(this).i!=0;case 14:return qYd(this),this.r.i!=0;case 15:return mYd(this),this.k.i!=0;case 16:return nYd(this).i!=0;case 17:return pYd(this).i!=0;case 18:return rYd(this).i!=0;case 19:return sYd(this).i!=0;case 20:return mYd(this),!!this.o;case 21:return !!this.s&&this.s.i!=0;case 22:return !!this.n&&d$d(this.n);case 23:return oYd(this).i!=0;}return Avd(this,a-AYd((JTd(),oTd)),vYd((b=RD(Ywd(this,16),29),!b?oTd:b),a))};_.Zh=function NYd(a){var b;b=this.i==null||!!this.q&&this.q.i!=0?null:wYd(this,a);return b?b:_zd(this,a)};_.bi=function OYd(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;case 8:EYd(this,Heb(TD(b)));return;case 9:FYd(this,Heb(TD(b)));return;case 10:VJd(zYd(this));YGd(zYd(this),RD(b,16));return;case 11:!this.q&&(this.q=new C5d(s7,this,11,10));sLd(this.q);!this.q&&(this.q=new C5d(s7,this,11,10));YGd(this.q,RD(b,16));return;case 21:!this.s&&(this.s=new C5d(y7,this,21,17));sLd(this.s);!this.s&&(this.s=new C5d(y7,this,21,17));YGd(this.s,RD(b,16));return;case 22:sLd(tYd(this));YGd(tYd(this),RD(b,16));return;}Bvd(this,a-AYd((JTd(),oTd)),vYd((c=RD(Ywd(this,16),29),!c?oTd:c),a),b);};_.ii=function PYd(){return JTd(),oTd};_.ki=function QYd(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;case 8:EYd(this,false);return;case 9:FYd(this,false);return;case 10:!!this.u&&VJd(this.u);return;case 11:!this.q&&(this.q=new C5d(s7,this,11,10));sLd(this.q);return;case 21:!this.s&&(this.s=new C5d(y7,this,21,17));sLd(this.s);return;case 22:!!this.n&&sLd(this.n);return;}Cvd(this,a-AYd((JTd(),oTd)),vYd((b=RD(Ywd(this,16),29),!b?oTd:b),a));};_.pi=function RYd(){var a,b;mYd(this);qYd(this);nYd(this);pYd(this);rYd(this);sYd(this);oYd(this);OHd(q$d(yYd(this)));if(this.s){for(a=0,b=this.s.i;a=0;--b){QHd(this,b);}}return XHd(this,a)};_.Gk=function NZd(){sLd(this);};_.Zi=function OZd(a,b){return jZd(this,a,b)};sfb(ZJe,'EcoreEList',632);feb(505,632,oKe,PZd);_.Li=function QZd(){return false};_.Lj=function RZd(){return this.c};_.Mj=function SZd(){return false};_.ol=function TZd(){return true};_.Si=function UZd(){return true};_.Wi=function VZd(a,b){return b};_.Yi=function WZd(){return false};_.c=0;sfb(ZJe,'EObjectEList',505);feb(83,505,oKe,XZd);_.Mj=function YZd(){return true};_.ml=function ZZd(){return false};_.al=function $Zd(){return true};sfb(ZJe,'EObjectContainmentEList',83);feb(555,83,oKe,_Zd);_.Ni=function a$d(){this.b=true;};_.Qj=function b$d(){return this.b};_.Gk=function c$d(){var a;sLd(this);if(Mvd(this.e)){a=this.b;this.b=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.b=false;}};_.b=false;sfb(ZJe,'EObjectContainmentEList/Unsettable',555);feb(1161,555,oKe,h$d);_.Ti=function l$d(a,b){var c,d;return c=RD(uLd(this,a,b),89),Mvd(this.e)&&eZd(this,new c4d(this.a,7,(JTd(),qTd),sgb(b),(d=c.c,ZD(d,90)?RD(d,29):zTd),a)),c};_.Uj=function m$d(a,b){return e$d(this,RD(a,89),b)};_.Vj=function n$d(a,b){return f$d(this,RD(a,89),b)};_.Wj=function o$d(a,b,c){return g$d(this,RD(a,89),RD(b,89),c)};_.Ij=function i$d(a,b,c,d,e){switch(a){case 3:{return dZd(this,a,b,c,d,this.i>1)}case 5:{return dZd(this,a,b,c,d,this.i-RD(c,15).gc()>0)}default:{return new P3d(this.e,a,this.c,b,c,d,true)}}};_.Tj=function j$d(){return true};_.Qj=function k$d(){return d$d(this)};_.Gk=function p$d(){sLd(this);};sfb(SHe,'EClassImpl/1',1161);feb(1175,1174,EJe);_.dj=function t$d(a){var b,c,d,e,f,g,h;c=a.gj();if(c!=8){d=s$d(a);if(d==0){switch(c){case 1:case 9:{h=a.kj();if(h!=null){b=yYd(RD(h,482));!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}g=a.ij();if(g!=null){e=RD(g,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}break}case 3:{g=a.ij();if(g!=null){e=RD(g,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}break}case 5:{g=a.ij();if(g!=null){for(f=RD(g,16).Kc();f.Ob();){e=RD(f.Pb(),482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);WGd(b.c,RD(a.jj(),29));}}}break}case 4:{h=a.kj();if(h!=null){e=RD(h,482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}}break}case 6:{h=a.kj();if(h!=null){for(f=RD(h,16).Kc();f.Ob();){e=RD(f.Pb(),482);if((e.Bb&1)==0){b=yYd(e);!b.c&&(b.c=new X9d);dHd(b.c,a.jj());}}}break}}}this.ql(d);}};_.ql=function u$d(a){r$d(this,a);};_.b=63;sfb(SHe,'ESuperAdapter',1175);feb(1176,1175,EJe,w$d);_.ql=function x$d(a){v$d(this,a);};sfb(SHe,'EClassImpl/10',1176);feb(1165,710,oKe);_.Ei=function y$d(a,b){return IHd(this,a,b)};_.Fi=function z$d(a){return JHd(this,a)};_.Gi=function A$d(a,b){KHd(this,a,b);};_.Hi=function B$d(a){LHd(this,a);};_.$i=function D$d(a){return NHd(this,a)};_.Xi=function L$d(a,b){return UHd(this,a,b)};_.Wk=function C$d(a,b){throw Adb(new jib)};_.Ii=function E$d(){return new yMd(this)};_.Ji=function F$d(){return new BMd(this)};_.Ki=function G$d(a){return ZGd(this,a)};_.Xk=function H$d(a,b){throw Adb(new jib)};_.Fk=function I$d(a){return this};_.Qj=function J$d(){return this.i!=0};_.Wb=function K$d(a){throw Adb(new jib)};_.Gk=function M$d(){throw Adb(new jib)};sfb(ZJe,'EcoreEList/UnmodifiableEList',1165);feb(328,1165,oKe,N$d);_.Yi=function O$d(){return false};sfb(ZJe,'EcoreEList/UnmodifiableEList/FastCompare',328);feb(1168,328,oKe,R$d);_.dd=function S$d(a){var b,c,d;if(ZD(a,179)){b=RD(a,179);c=b.Lj();if(c!=-1){for(d=this.i;c4){if(this.fk(a)){if(this.al()){d=RD(a,54);c=d.Eh();h=c==this.b&&(this.ml()?d.yh(d.Fh(),RD(vYd(Uwd(this.b),this.Lj()).Hk(),29).kk())==Z5d(RD(vYd(Uwd(this.b),this.Lj()),19)).n:-1-d.Fh()==this.Lj());if(this.nl()&&!h&&!c&&!!d.Jh()){for(e=0;e1||d==-1)}else {return false}};_.ml=function a0d(){var a,b,c;b=vYd(Uwd(this.b),this.Lj());if(ZD(b,102)){a=RD(b,19);c=Z5d(a);return !!c}else {return false}};_.nl=function b0d(){var a,b;b=vYd(Uwd(this.b),this.Lj());if(ZD(b,102)){a=RD(b,19);return (a.Bb&txe)!=0}else {return false}};_.dd=function c0d(a){var b,c,d,e;d=this.zj(a);if(d>=0)return d;if(this.ol()){for(c=0,e=this.Ej();c=0;--a){N_d(this,a,this.xj(a));}}return this.Fj()};_.Qc=function o0d(a){var b;if(this.nl()){for(b=this.Ej()-1;b>=0;--b){N_d(this,b,this.xj(b));}}return this.Gj(a)};_.Gk=function p0d(){VJd(this);};_.Zi=function q0d(a,b){return P_d(this,a,b)};sfb(ZJe,'DelegatingEcoreEList',756);feb(1171,756,tKe,w0d);_.qj=function z0d(a,b){r0d(this,a,RD(b,29));};_.rj=function A0d(a){s0d(this,RD(a,29));};_.xj=function G0d(a){var b,c;return b=RD(QHd(tYd(this.a),a),89),c=b.c,ZD(c,90)?RD(c,29):(JTd(),zTd)};_.Cj=function L0d(a){var b,c;return b=RD(vLd(tYd(this.a),a),89),c=b.c,ZD(c,90)?RD(c,29):(JTd(),zTd)};_.Dj=function M0d(a,b){return u0d(this,a,RD(b,29))};_.Li=function x0d(){return false};_.Ij=function y0d(a,b,c,d,e){return null};_.sj=function B0d(){return new c1d(this)};_.tj=function C0d(){sLd(tYd(this.a));};_.uj=function D0d(a){return t0d(this,a)};_.vj=function E0d(a){var b,c;for(c=a.Kc();c.Ob();){b=c.Pb();if(!t0d(this,b)){return false}}return true};_.wj=function F0d(a){var b,c,d;if(ZD(a,15)){d=RD(a,15);if(d.gc()==tYd(this.a).i){for(b=d.Kc(),c=new dMd(this);b.Ob();){if(dE(b.Pb())!==dE(bMd(c))){return false}}return true}}return false};_.yj=function H0d(){var a,b,c,d,e;c=1;for(b=new dMd(tYd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),89);d=(e=a.c,ZD(e,90)?RD(e,29):(JTd(),zTd));c=31*c+(!d?0:kFb(d));}return c};_.zj=function I0d(a){var b,c,d,e;d=0;for(c=new dMd(tYd(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);if(dE(a)===dE((e=b.c,ZD(e,90)?RD(e,29):(JTd(),zTd)))){return d}++d;}return -1};_.Aj=function J0d(){return tYd(this.a).i==0};_.Bj=function K0d(){return null};_.Ej=function N0d(){return tYd(this.a).i};_.Fj=function O0d(){var a,b,c,d,e,f;f=tYd(this.a).i;e=$C(jJ,rve,1,f,5,1);c=0;for(b=new dMd(tYd(this.a));b.e!=b.i.gc();){a=RD(bMd(b),89);e[c++]=(d=a.c,ZD(d,90)?RD(d,29):(JTd(),zTd));}return e};_.Gj=function P0d(a){var b,c,d,e,f,g,h;h=tYd(this.a).i;if(a.lengthh&&bD(a,h,null);d=0;for(c=new dMd(tYd(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);f=(g=b.c,ZD(g,90)?RD(g,29):(JTd(),zTd));bD(a,d++,f);}return a};_.Hj=function Q0d(){var a,b,c,d,e;e=new Qhb;e.a+='[';a=tYd(this.a);for(b=0,d=tYd(this.a).i;b>16,e>=0?AXd(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,6,c);case 9:return !this.a&&(this.a=new C5d(l7,this,9,5)),qLd(this.a,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),sTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),sTd)),a,c)};_.Uh=function D1d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 6:return xvd(this,null,6,c);case 7:return !this.A&&(this.A=new iie(z7,this,7)),rLd(this.A,a,c);case 9:return !this.a&&(this.a=new C5d(l7,this,9,5)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),sTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),sTd)),a,c)};_.Wh=function E1d(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.D!=null&&this.D==this.F;case 3:return !!DXd(this);case 4:return !!y1d(this);case 5:return this.F!=null&&this.F!=this.D&&this.F!=this.B;case 6:return !!xXd(this);case 7:return !!this.A&&this.A.i!=0;case 8:return (this.Bb&256)==0;case 9:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),sTd)),vYd((b=RD(Ywd(this,16),29),!b?sTd:b),a))};_.bi=function F1d(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:LXd(this,WD(b));return;case 2:IXd(this,WD(b));return;case 5:KXd(this,WD(b));return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);!this.A&&(this.A=new iie(z7,this,7));YGd(this.A,RD(b,16));return;case 8:j1d(this,Heb(TD(b)));return;case 9:!this.a&&(this.a=new C5d(l7,this,9,5));sLd(this.a);!this.a&&(this.a=new C5d(l7,this,9,5));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),sTd)),vYd((c=RD(Ywd(this,16),29),!c?sTd:c),a),b);};_.ii=function G1d(){return JTd(),sTd};_.ki=function H1d(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,184)&&(RD(this.Cb,184).tb=null);PAd(this,null);return;case 2:yXd(this,null);zXd(this,this.D);return;case 5:KXd(this,null);return;case 7:!this.A&&(this.A=new iie(z7,this,7));sLd(this.A);return;case 8:j1d(this,true);return;case 9:!this.a&&(this.a=new C5d(l7,this,9,5));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),sTd)),vYd((b=RD(Ywd(this,16),29),!b?sTd:b),a));};_.pi=function I1d(){var a,b;if(this.a){for(a=0,b=this.a.i;a>16==5?RD(this.Cb,685):null;}return zvd(this,a-AYd((JTd(),tTd)),vYd((d=RD(Ywd(this,16),29),!d?tTd:d),a),b,c)};_.Sh=function U1d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 5:!!this.Cb&&(c=(e=this.Db>>16,e>=0?M1d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,5,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),tTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),tTd)),a,c)};_.Uh=function V1d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 5:return xvd(this,null,5,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),tTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),tTd)),a,c)};_.Wh=function W1d(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return this.d!=0;case 3:return !!this.b;case 4:return this.c!=null;case 5:return !!(this.Db>>16==5?RD(this.Cb,685):null);}return Avd(this,a-AYd((JTd(),tTd)),vYd((b=RD(Ywd(this,16),29),!b?tTd:b),a))};_.bi=function X1d(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:Q1d(this,RD(b,17).a);return;case 3:O1d(this,RD(b,2039));return;case 4:P1d(this,WD(b));return;}Bvd(this,a-AYd((JTd(),tTd)),vYd((c=RD(Ywd(this,16),29),!c?tTd:c),a),b);};_.ii=function Y1d(){return JTd(),tTd};_.ki=function Z1d(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:Q1d(this,0);return;case 3:O1d(this,null);return;case 4:P1d(this,null);return;}Cvd(this,a-AYd((JTd(),tTd)),vYd((b=RD(Ywd(this,16),29),!b?tTd:b),a));};_.Ib=function _1d(){var a;return a=this.c,a==null?this.zb:a};_.b=null;_.c=null;_.d=0;sfb(SHe,'EEnumLiteralImpl',582);var h8=ufb(SHe,'EFactoryImpl/InternalEDateTimeFormat');feb(499,1,{2114:1},c2d);sfb(SHe,'EFactoryImpl/1ClientInternalEDateTimeFormat',499);feb(248,120,{110:1,94:1,93:1,89:1,58:1,114:1,54:1,99:1,248:1,119:1,120:1},s2d);_.Ch=function t2d(a,b,c){var d;c=xvd(this,a,b,c);if(!!this.e&&ZD(a,179)){d=k2d(this,this.e);d!=this.c&&(c=o2d(this,d,c));}return c};_.Lh=function u2d(a,b,c){var d;switch(a){case 0:return this.f;case 1:return !this.d&&(this.d=new XZd(o7,this,1)),this.d;case 2:if(b)return i2d(this);return this.c;case 3:return this.b;case 4:return this.e;case 5:if(b)return h2d(this);return this.a;}return zvd(this,a-AYd((JTd(),vTd)),vYd((d=RD(Ywd(this,16),29),!d?vTd:d),a),b,c)};_.Uh=function v2d(a,b,c){var d,e;switch(b){case 0:return g2d(this,null,c);case 1:return !this.d&&(this.d=new XZd(o7,this,1)),rLd(this.d,a,c);case 3:return e2d(this,null,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),vTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),vTd)),a,c)};_.Wh=function w2d(a){var b;switch(a){case 0:return !!this.f;case 1:return !!this.d&&this.d.i!=0;case 2:return !!this.c;case 3:return !!this.b;case 4:return !!this.e;case 5:return !!this.a;}return Avd(this,a-AYd((JTd(),vTd)),vYd((b=RD(Ywd(this,16),29),!b?vTd:b),a))};_.bi=function x2d(a,b){var c;switch(a){case 0:q2d(this,RD(b,89));return;case 1:!this.d&&(this.d=new XZd(o7,this,1));sLd(this.d);!this.d&&(this.d=new XZd(o7,this,1));YGd(this.d,RD(b,16));return;case 3:n2d(this,RD(b,89));return;case 4:p2d(this,RD(b,850));return;case 5:l2d(this,RD(b,142));return;}Bvd(this,a-AYd((JTd(),vTd)),vYd((c=RD(Ywd(this,16),29),!c?vTd:c),a),b);};_.ii=function y2d(){return JTd(),vTd};_.ki=function z2d(a){var b;switch(a){case 0:q2d(this,null);return;case 1:!this.d&&(this.d=new XZd(o7,this,1));sLd(this.d);return;case 3:n2d(this,null);return;case 4:p2d(this,null);return;case 5:l2d(this,null);return;}Cvd(this,a-AYd((JTd(),vTd)),vYd((b=RD(Ywd(this,16),29),!b?vTd:b),a));};_.Ib=function A2d(){var a;a=new dib(awd(this));a.a+=' (expression: ';r2d(this,a);a.a+=')';return a.a};var d2d;sfb(SHe,'EGenericTypeImpl',248);feb(2067,2062,uKe);_.Gi=function C2d(a,b){B2d(this,a,b);};_.Wk=function D2d(a,b){B2d(this,this.gc(),a);return b};_.$i=function E2d(a){return ju(this.pj(),a)};_.Ii=function F2d(){return this.Ji()};_.pj=function G2d(){return new mee(this)};_.Ji=function H2d(){return this.Ki(0)};_.Ki=function I2d(a){return this.pj().fd(a)};_.Xk=function J2d(a,b){ze(this,a,true);return b};_.Ti=function K2d(a,b){var c,d;d=ku(this,b);c=this.fd(a);c.Rb(d);return d};_.Ui=function L2d(a,b){var c;ze(this,b,true);c=this.fd(a);c.Rb(b);};sfb(ZJe,'AbstractSequentialInternalEList',2067);feb(496,2067,uKe,Q2d);_.$i=function R2d(a){return ju(this.pj(),a)};_.Ii=function S2d(){if(this.b==null){return j3d(),j3d(),i3d}return this.sl()};_.pj=function T2d(){return new Whe(this.a,this.b)};_.Ji=function U2d(){if(this.b==null){return j3d(),j3d(),i3d}return this.sl()};_.Ki=function V2d(a){var b,c;if(this.b==null){if(a<0||a>1){throw Adb(new veb(HJe+a+', size=0'))}return j3d(),j3d(),i3d}c=this.sl();for(b=0;b0){b=this.c[--this.d];if((!this.e||b.pk()!=C4||b.Lj()!=0)&&(!this.vl()||this.b.Xh(b))){f=this.b.Nh(b,this.ul());this.f=(nke(),RD(b,69).xk());if(this.f||b.Jk()){if(this.ul()){d=RD(f,15);this.k=d;}else {d=RD(f,71);this.k=this.j=d;}if(ZD(this.k,59)){this.o=this.k.gc();this.n=this.o;}else {this.p=!this.j?this.k.fd(this.k.gc()):this.j.Ki(this.k.gc());}if(!this.p?n3d(this):o3d(this,this.p)){e=!this.p?!this.j?this.k.Xb(--this.n):this.j.$i(--this.n):this.p.Ub();if(this.f){a=RD(e,76);a.Lk();c=a.md();this.i=c;}else {c=e;this.i=c;}this.g=-3;return true}}else if(f!=null){this.k=null;this.p=null;c=f;this.i=c;this.g=-2;return true}}}this.k=null;this.p=null;this.g=-1;return false}else {e=!this.p?!this.j?this.k.Xb(--this.n):this.j.$i(--this.n):this.p.Ub();if(this.f){a=RD(e,76);a.Lk();c=a.md();this.i=c;}else {c=e;this.i=c;}this.g=-3;return true}}}};_.Pb=function v3d(){return k3d(this)};_.Tb=function w3d(){return this.a};_.Ub=function x3d(){var a;if(this.g<-1||this.Sb()){--this.a;this.g=0;a=this.i;this.Sb();return a}else {throw Adb(new Dvb)}};_.Vb=function y3d(){return this.a-1};_.Qb=function z3d(){throw Adb(new jib)};_.ul=function A3d(){return false};_.Wb=function B3d(a){throw Adb(new jib)};_.vl=function C3d(){return true};_.a=0;_.d=0;_.f=false;_.g=0;_.n=0;_.o=0;var i3d;sfb(ZJe,'EContentsEList/FeatureIteratorImpl',287);feb(711,287,vKe,D3d);_.ul=function E3d(){return true};sfb(ZJe,'EContentsEList/ResolvingFeatureIteratorImpl',711);feb(1178,711,vKe,F3d);_.vl=function G3d(){return false};sfb(SHe,'ENamedElementImpl/1/1',1178);feb(1179,287,vKe,H3d);_.vl=function I3d(){return false};sfb(SHe,'ENamedElementImpl/1/2',1179);feb(39,152,GJe,L3d,M3d,N3d,O3d,P3d,Q3d,R3d,S3d,T3d,U3d,V3d,W3d,X3d,Y3d,Z3d,$3d,_3d,a4d,b4d,c4d,d4d,e4d,f4d,g4d,h4d);_.Kj=function i4d(){return K3d(this)};_.Rj=function j4d(){var a;a=K3d(this);if(a){return a.ik()}return null};_.hj=function k4d(a){this.b==-1&&!!this.a&&(this.b=this.c.Hh(this.a.Lj(),this.a.pk()));return this.c.yh(this.b,a)};_.jj=function l4d(){return this.c};_.Sj=function m4d(){var a;a=K3d(this);if(a){return a.tk()}return false};_.b=-1;sfb(SHe,'ENotificationImpl',39);feb(411,292,{110:1,94:1,93:1,155:1,197:1,58:1,62:1,114:1,481:1,54:1,99:1,158:1,411:1,292:1,119:1,120:1},q4d);_.Ah=function r4d(a){return n4d(this,a)};_.Lh=function s4d(a,b,c){var d,e,f;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),f=this.t,f>1||f==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return this.Db>>16==10?RD(this.Cb,29):null;case 11:return !this.d&&(this.d=new iie(z7,this,11)),this.d;case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),this.c;case 13:return !this.a&&(this.a=new F4d(this,this)),this.a;case 14:return o4d(this);}return zvd(this,a-AYd((JTd(),ATd)),vYd((d=RD(Ywd(this,16),29),!d?ATd:d),a),b,c)};_.Sh=function t4d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 10:!!this.Cb&&(c=(e=this.Db>>16,e>=0?n4d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,10,c);case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),qLd(this.c,a,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ATd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),ATd)),a,c)};_.Uh=function u4d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 10:return xvd(this,null,10,c);case 11:return !this.d&&(this.d=new iie(z7,this,11)),rLd(this.d,a,c);case 12:return !this.c&&(this.c=new C5d(u7,this,12,10)),rLd(this.c,a,c);case 14:return rLd(o4d(this),a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ATd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),ATd)),a,c)};_.Wh=function v4d(a){var b,c,d;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return d=this.t,d>1||d==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return !!(this.Db>>16==10?RD(this.Cb,29):null);case 11:return !!this.d&&this.d.i!=0;case 12:return !!this.c&&this.c.i!=0;case 13:return !!this.a&&o4d(this.a.a).i!=0&&!(!!this.b&&o5d(this.b));case 14:return !!this.b&&o5d(this.b);}return Avd(this,a-AYd((JTd(),ATd)),vYd((b=RD(Ywd(this,16),29),!b?ATd:b),a))};_.bi=function w4d(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:bWd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 11:!this.d&&(this.d=new iie(z7,this,11));sLd(this.d);!this.d&&(this.d=new iie(z7,this,11));YGd(this.d,RD(b,16));return;case 12:!this.c&&(this.c=new C5d(u7,this,12,10));sLd(this.c);!this.c&&(this.c=new C5d(u7,this,12,10));YGd(this.c,RD(b,16));return;case 13:!this.a&&(this.a=new F4d(this,this));VJd(this.a);!this.a&&(this.a=new F4d(this,this));YGd(this.a,RD(b,16));return;case 14:sLd(o4d(this));YGd(o4d(this),RD(b,16));return;}Bvd(this,a-AYd((JTd(),ATd)),vYd((c=RD(Ywd(this,16),29),!c?ATd:c),a),b);};_.ii=function x4d(){return JTd(),ATd};_.ki=function y4d(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 11:!this.d&&(this.d=new iie(z7,this,11));sLd(this.d);return;case 12:!this.c&&(this.c=new C5d(u7,this,12,10));sLd(this.c);return;case 13:!!this.a&&VJd(this.a);return;case 14:!!this.b&&sLd(this.b);return;}Cvd(this,a-AYd((JTd(),ATd)),vYd((b=RD(Ywd(this,16),29),!b?ATd:b),a));};_.pi=function z4d(){var a,b;if(this.c){for(a=0,b=this.c.i;ah&&bD(a,h,null);d=0;for(c=new dMd(o4d(this.a));c.e!=c.i.gc();){b=RD(bMd(c),89);f=(g=b.c,g?g:(JTd(),wTd));bD(a,d++,f);}return a};_.Hj=function Z4d(){var a,b,c,d,e;e=new Qhb;e.a+='[';a=o4d(this.a);for(b=0,d=o4d(this.a).i;b1)}case 5:{return dZd(this,a,b,c,d,this.i-RD(c,15).gc()>0)}default:{return new P3d(this.e,a,this.c,b,c,d,true)}}};_.Tj=function u5d(){return true};_.Qj=function v5d(){return o5d(this)};_.Gk=function A5d(){sLd(this);};sfb(SHe,'EOperationImpl/2',1377);feb(507,1,{2037:1,507:1},B5d);sfb(SHe,'EPackageImpl/1',507);feb(14,83,oKe,C5d);_.il=function D5d(){return this.d};_.jl=function E5d(){return this.b};_.ml=function F5d(){return true};_.b=0;sfb(ZJe,'EObjectContainmentWithInverseEList',14);feb(365,14,oKe,G5d);_.nl=function H5d(){return true};_.Wi=function I5d(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentWithInverseEList/Resolving',365);feb(308,365,oKe,J5d);_.Ni=function K5d(){this.a.tb=null;};sfb(SHe,'EPackageImpl/2',308);feb(1278,1,{},L5d);sfb(SHe,'EPackageImpl/3',1278);feb(733,45,Hxe,O5d);_._b=function P5d(a){return bE(a)?Yjb(this,a):!!qtb(this.f,a)};sfb(SHe,'EPackageRegistryImpl',733);feb(518,292,{110:1,94:1,93:1,155:1,197:1,58:1,2116:1,114:1,481:1,54:1,99:1,158:1,518:1,292:1,119:1,120:1},R5d);_.Ah=function S5d(a){return Q5d(this,a)};_.Lh=function T5d(a,b,c){var d,e,f;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),f=this.t,f>1||f==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return this.Db>>16==10?RD(this.Cb,62):null;}return zvd(this,a-AYd((JTd(),DTd)),vYd((d=RD(Ywd(this,16),29),!d?DTd:d),a),b,c)};_.Sh=function U5d(a,b,c){var d,e,f;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),qLd(this.Ab,a,c);case 10:!!this.Cb&&(c=(e=this.Db>>16,e>=0?Q5d(this,c):this.Cb.Th(this,-1-e,null,c)));return xvd(this,a,10,c);}return f=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),DTd):d),b),69),f.wk().zk(this,Wwd(this),b-AYd((JTd(),DTd)),a,c)};_.Uh=function V5d(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 9:return VVd(this,c);case 10:return xvd(this,null,10,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),DTd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),DTd)),a,c)};_.Wh=function W5d(a){var b,c,d;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return d=this.t,d>1||d==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return !!(this.Db>>16==10?RD(this.Cb,62):null);}return Avd(this,a-AYd((JTd(),DTd)),vYd((b=RD(Ywd(this,16),29),!b?DTd:b),a))};_.ii=function X5d(){return JTd(),DTd};sfb(SHe,'EParameterImpl',518);feb(102,462,{110:1,94:1,93:1,155:1,197:1,58:1,19:1,179:1,69:1,114:1,481:1,54:1,99:1,158:1,102:1,462:1,292:1,119:1,120:1,692:1},d6d);_.Lh=function e6d(a,b,c){var d,e,f,g;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return Geb(),(this.Bb&256)!=0?true:false;case 3:return Geb(),(this.Bb&512)!=0?true:false;case 4:return sgb(this.s);case 5:return sgb(this.t);case 6:return Geb(),g=this.t,g>1||g==-1?true:false;case 7:return Geb(),e=this.s,e>=1?true:false;case 8:if(b)return WVd(this);return this.r;case 9:return this.q;case 10:return Geb(),(this.Bb&gwe)!=0?true:false;case 11:return Geb(),(this.Bb&cKe)!=0?true:false;case 12:return Geb(),(this.Bb&qxe)!=0?true:false;case 13:return this.j;case 14:return tWd(this);case 15:return Geb(),(this.Bb&bKe)!=0?true:false;case 16:return Geb(),(this.Bb&Ove)!=0?true:false;case 17:return uWd(this);case 18:return Geb(),(this.Bb&QHe)!=0?true:false;case 19:return Geb(),f=Z5d(this),!!f&&(f.Bb&QHe)!=0?true:false;case 20:return Geb(),(this.Bb&txe)!=0?true:false;case 21:if(b)return Z5d(this);return this.b;case 22:if(b)return $5d(this);return Y5d(this);case 23:return !this.a&&(this.a=new zie(g7,this,23)),this.a;}return zvd(this,a-AYd((JTd(),ETd)),vYd((d=RD(Ywd(this,16),29),!d?ETd:d),a),b,c)};_.Wh=function f6d(a){var b,c,d,e;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return (this.Bb&256)==0;case 3:return (this.Bb&512)==0;case 4:return this.s!=0;case 5:return this.t!=1;case 6:return e=this.t,e>1||e==-1;case 7:return c=this.s,c>=1;case 8:return !!this.r&&!this.q.e&&j2d(this.q).i==0;case 9:return !!this.q&&!(!!this.r&&!this.q.e&&j2d(this.q).i==0);case 10:return (this.Bb&gwe)==0;case 11:return (this.Bb&cKe)!=0;case 12:return (this.Bb&qxe)!=0;case 13:return this.j!=null;case 14:return tWd(this)!=null;case 15:return (this.Bb&bKe)!=0;case 16:return (this.Bb&Ove)!=0;case 17:return !!uWd(this);case 18:return (this.Bb&QHe)!=0;case 19:return d=Z5d(this),!!d&&(d.Bb&QHe)!=0;case 20:return (this.Bb&txe)==0;case 21:return !!this.b;case 22:return !!Y5d(this);case 23:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),ETd)),vYd((b=RD(Ywd(this,16),29),!b?ETd:b),a))};_.bi=function g6d(a,b){var c,d;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:CWd(this,WD(b));return;case 2:_Vd(this,Heb(TD(b)));return;case 3:aWd(this,Heb(TD(b)));return;case 4:$Vd(this,RD(b,17).a);return;case 5:bWd(this,RD(b,17).a);return;case 8:YVd(this,RD(b,142));return;case 9:d=XVd(this,RD(b,89),null);!!d&&d.oj();return;case 10:xWd(this,Heb(TD(b)));return;case 11:FWd(this,Heb(TD(b)));return;case 12:DWd(this,Heb(TD(b)));return;case 13:yWd(this,WD(b));return;case 15:EWd(this,Heb(TD(b)));return;case 16:AWd(this,Heb(TD(b)));return;case 18:_5d(this,Heb(TD(b)));return;case 20:c6d(this,Heb(TD(b)));return;case 21:b6d(this,RD(b,19));return;case 23:!this.a&&(this.a=new zie(g7,this,23));sLd(this.a);!this.a&&(this.a=new zie(g7,this,23));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),ETd)),vYd((c=RD(Ywd(this,16),29),!c?ETd:c),a),b);};_.ii=function h6d(){return JTd(),ETd};_.ki=function i6d(a){var b,c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),4);PAd(this,null);return;case 2:_Vd(this,true);return;case 3:aWd(this,true);return;case 4:$Vd(this,0);return;case 5:bWd(this,1);return;case 8:YVd(this,null);return;case 9:c=XVd(this,null,null);!!c&&c.oj();return;case 10:xWd(this,true);return;case 11:FWd(this,false);return;case 12:DWd(this,false);return;case 13:this.i=null;zWd(this,null);return;case 15:EWd(this,false);return;case 16:AWd(this,false);return;case 18:a6d(this,false);ZD(this.Cb,90)&&v$d(yYd(RD(this.Cb,90)),2);return;case 20:c6d(this,true);return;case 21:b6d(this,null);return;case 23:!this.a&&(this.a=new zie(g7,this,23));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),ETd)),vYd((b=RD(Ywd(this,16),29),!b?ETd:b),a));};_.pi=function j6d(){$5d(this);Afe(Qee((lke(),jke),this));WVd(this);this.Bb|=1;};_.uk=function k6d(){return Z5d(this)};_._k=function l6d(){var a;return a=Z5d(this),!!a&&(a.Bb&QHe)!=0};_.al=function m6d(){return (this.Bb&QHe)!=0};_.bl=function n6d(){return (this.Bb&txe)!=0};_.Yk=function o6d(a,b){this.c=null;return ZVd(this,a,b)};_.Ib=function p6d(){var a;if((this.Db&64)!=0)return GWd(this);a=new Shb(GWd(this));a.a+=' (containment: ';Ohb(a,(this.Bb&QHe)!=0);a.a+=', resolveProxies: ';Ohb(a,(this.Bb&txe)!=0);a.a+=')';return a.a};sfb(SHe,'EReferenceImpl',102);feb(561,120,{110:1,44:1,94:1,93:1,136:1,58:1,114:1,54:1,99:1,561:1,119:1,120:1},v6d);_.Fb=function B6d(a){return this===a};_.ld=function D6d(){return this.b};_.md=function E6d(){return this.c};_.Hb=function F6d(){return kFb(this)};_.Di=function H6d(a){q6d(this,WD(a));};_.nd=function I6d(a){return u6d(this,WD(a))};_.Lh=function w6d(a,b,c){var d;switch(a){case 0:return this.b;case 1:return this.c;}return zvd(this,a-AYd((JTd(),FTd)),vYd((d=RD(Ywd(this,16),29),!d?FTd:d),a),b,c)};_.Wh=function x6d(a){var b;switch(a){case 0:return this.b!=null;case 1:return this.c!=null;}return Avd(this,a-AYd((JTd(),FTd)),vYd((b=RD(Ywd(this,16),29),!b?FTd:b),a))};_.bi=function y6d(a,b){var c;switch(a){case 0:r6d(this,WD(b));return;case 1:t6d(this,WD(b));return;}Bvd(this,a-AYd((JTd(),FTd)),vYd((c=RD(Ywd(this,16),29),!c?FTd:c),a),b);};_.ii=function z6d(){return JTd(),FTd};_.ki=function A6d(a){var b;switch(a){case 0:s6d(this,null);return;case 1:t6d(this,null);return;}Cvd(this,a-AYd((JTd(),FTd)),vYd((b=RD(Ywd(this,16),29),!b?FTd:b),a));};_.Bi=function C6d(){var a;if(this.a==-1){a=this.b;this.a=a==null?0:ohb(a);}return this.a};_.Ci=function G6d(a){this.a=a;};_.Ib=function J6d(){var a;if((this.Db&64)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (key: ';Nhb(a,this.b);a.a+=', value: ';Nhb(a,this.c);a.a+=')';return a.a};_.a=-1;_.b=null;_.c=null;var C8=sfb(SHe,'EStringToStringMapEntryImpl',561);var Ibb=ufb(ZJe,'FeatureMap/Entry/Internal');feb(576,1,wKe);_.xl=function M6d(a){return this.yl(RD(a,54))};_.yl=function N6d(a){return this.xl(a)};_.Fb=function O6d(a){var b,c;if(this===a){return true}else if(ZD(a,76)){b=RD(a,76);if(b.Lk()==this.c){c=this.md();return c==null?b.md()==null:pb(c,b.md())}else {return false}}else {return false}};_.Lk=function P6d(){return this.c};_.Hb=function Q6d(){var a;a=this.md();return tb(this.c)^(a==null?0:tb(a))};_.Ib=function R6d(){var a,b;a=this.c;b=BXd(a.qk()).yi();a.xe();return (b!=null&&b.length!=0?b+':'+a.xe():a.xe())+'='+this.md()};sfb(SHe,'EStructuralFeatureImpl/BasicFeatureMapEntry',576);feb(791,576,wKe,U6d);_.yl=function V6d(a){return new U6d(this.c,a)};_.md=function W6d(){return this.a};_.zl=function X6d(a,b,c){return S6d(this,a,this.a,b,c)};_.Al=function Y6d(a,b,c){return T6d(this,a,this.a,b,c)};sfb(SHe,'EStructuralFeatureImpl/ContainmentUpdatingFeatureMapEntry',791);feb(1350,1,{},Z6d);_.yk=function $6d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Yl(this.a).Fk(d)};_.zk=function _6d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Pl(this.a,d,e)};_.Ak=function a7d(a,b,c,d,e){var f;f=RD(Evd(a,this.b),220);return f.Ql(this.a,d,e)};_.Bk=function b7d(a,b,c){var d;d=RD(Evd(a,this.b),220);return d.Yl(this.a).Qj()};_.Ck=function c7d(a,b,c,d){var e;e=RD(Evd(a,this.b),220);e.Yl(this.a).Wb(d);};_.Dk=function d7d(a,b,c){return RD(Evd(a,this.b),220).Yl(this.a)};_.Ek=function e7d(a,b,c){var d;d=RD(Evd(a,this.b),220);d.Yl(this.a).Gk();};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateFeatureMapDelegator',1350);feb(91,1,{},g7d,h7d,i7d,j7d);_.yk=function k7d(a,b,c,d,e){var f;f=b.li(c);f==null&&b.mi(c,f=f7d(this,a));if(!e){switch(this.e){case 50:case 41:return RD(f,597).bk();case 40:return RD(f,220).Vl();}}return f};_.zk=function l7d(a,b,c,d,e){var f,g;g=b.li(c);g==null&&b.mi(c,g=f7d(this,a));f=RD(g,71).Wk(d,e);return f};_.Ak=function m7d(a,b,c,d,e){var f;f=b.li(c);f!=null&&(e=RD(f,71).Xk(d,e));return e};_.Bk=function n7d(a,b,c){var d;d=b.li(c);return d!=null&&RD(d,79).Qj()};_.Ck=function o7d(a,b,c,d){var e;e=RD(b.li(c),79);!e&&b.mi(c,e=f7d(this,a));e.Wb(d);};_.Dk=function p7d(a,b,c){var d,e;e=b.li(c);e==null&&b.mi(c,e=f7d(this,a));if(ZD(e,79)){return RD(e,79)}else {d=RD(b.li(c),15);return new I9d(d)}};_.Ek=function q7d(a,b,c){var d;d=RD(b.li(c),79);!d&&b.mi(c,d=f7d(this,a));d.Gk();};_.b=0;_.e=0;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateMany',91);feb(512,1,{});_.zk=function u7d(a,b,c,d,e){throw Adb(new jib)};_.Ak=function v7d(a,b,c,d,e){throw Adb(new jib)};_.Dk=function w7d(a,b,c){return new x7d(this,a,b,c)};var r7d;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingle',512);feb(1367,1,$Je,x7d);_.Fk=function y7d(a){return this.a.yk(this.c,this.d,this.b,a,true)};_.Qj=function z7d(){return this.a.Bk(this.c,this.d,this.b)};_.Wb=function A7d(a){this.a.Ck(this.c,this.d,this.b,a);};_.Gk=function B7d(){this.a.Ek(this.c,this.d,this.b);};_.b=0;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingle/1',1367);feb(784,512,{},C7d);_.yk=function D7d(a,b,c,d,e){return jwd(a,a.Ph(),a.Fh())==this.b?this.bl()&&d?yvd(a):a.Ph():null};_.zk=function E7d(a,b,c,d,e){var f,g;!!a.Ph()&&(e=(f=a.Fh(),f>=0?a.Ah(e):a.Ph().Th(a,-1-f,null,e)));g=BYd(a.Dh(),this.e);return a.Ch(d,g,e)};_.Ak=function F7d(a,b,c,d,e){var f;f=BYd(a.Dh(),this.e);return a.Ch(null,f,e)};_.Bk=function G7d(a,b,c){var d;d=BYd(a.Dh(),this.e);return !!a.Ph()&&a.Fh()==d};_.Ck=function H7d(a,b,c,d){var e,f,g,h,i;if(d!=null&&!FXd(this.a,d)){throw Adb(new Ifb(xKe+(ZD(d,58)?GYd(RD(d,58).Dh()):ofb(rb(d)))+yKe+this.a+"'"))}e=a.Ph();g=BYd(a.Dh(),this.e);if(dE(d)!==dE(e)||a.Fh()!=g&&d!=null){if(Oje(a,RD(d,58)))throw Adb(new agb(UHe+a.Ib()));i=null;!!e&&(i=(f=a.Fh(),f>=0?a.Ah(i):a.Ph().Th(a,-1-f,null,i)));h=RD(d,54);!!h&&(i=h.Rh(a,BYd(h.Dh(),this.b),null,i));i=a.Ch(h,g,i);!!i&&i.oj();}else {a.vh()&&a.wh()&&qvd(a,new N3d(a,1,g,d,d));}};_.Ek=function I7d(a,b,c){var d,e,f,g;d=a.Ph();if(d){g=(e=a.Fh(),e>=0?a.Ah(null):a.Ph().Th(a,-1-e,null,null));f=BYd(a.Dh(),this.e);g=a.Ch(null,f,g);!!g&&g.oj();}else {a.vh()&&a.wh()&&qvd(a,new b4d(a,1,this.e,null,null));}};_.bl=function J7d(){return false};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleContainer',784);feb(1351,784,{},K7d);_.bl=function L7d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleContainerResolving',1351);feb(574,512,{});_.yk=function O7d(a,b,c,d,e){var f;return f=b.li(c),f==null?this.b:dE(f)===dE(r7d)?null:f};_.Bk=function P7d(a,b,c){var d;d=b.li(c);return d!=null&&(dE(d)===dE(r7d)||!pb(d,this.b))};_.Ck=function Q7d(a,b,c,d){var e,f;if(a.vh()&&a.wh()){e=(f=b.li(c),f==null?this.b:dE(f)===dE(r7d)?null:f);if(d==null){if(this.c!=null){b.mi(c,null);d=this.b;}else this.b!=null?b.mi(c,r7d):b.mi(c,null);}else {this.Bl(d);b.mi(c,d);}qvd(a,this.d.Cl(a,1,this.e,e,d));}else {if(d==null){this.c!=null?b.mi(c,null):this.b!=null?b.mi(c,r7d):b.mi(c,null);}else {this.Bl(d);b.mi(c,d);}}};_.Ek=function R7d(a,b,c){var d,e;if(a.vh()&&a.wh()){d=(e=b.li(c),e==null?this.b:dE(e)===dE(r7d)?null:e);b.ni(c);qvd(a,this.d.Cl(a,1,this.e,d,this.b));}else {b.ni(c);}};_.Bl=function S7d(a){throw Adb(new Hfb)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData',574);feb(zKe,1,{},b8d);_.Cl=function c8d(a,b,c,d,e){return new b4d(a,b,c,d,e)};_.Dl=function d8d(a,b,c,d,e,f){return new d4d(a,b,c,d,e,f)};var T7d,U7d,V7d,W7d,X7d,Y7d,Z7d,$7d,_7d;sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator',zKe);feb(1368,zKe,{},e8d);_.Cl=function f8d(a,b,c,d,e){return new g4d(a,b,c,Heb(TD(d)),Heb(TD(e)))};_.Dl=function g8d(a,b,c,d,e,f){return new h4d(a,b,c,Heb(TD(d)),Heb(TD(e)),f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/1',1368);feb(1369,zKe,{},h8d);_.Cl=function i8d(a,b,c,d,e){return new R3d(a,b,c,RD(d,222).a,RD(e,222).a)};_.Dl=function j8d(a,b,c,d,e,f){return new S3d(a,b,c,RD(d,222).a,RD(e,222).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/2',1369);feb(1370,zKe,{},k8d);_.Cl=function l8d(a,b,c,d,e){return new T3d(a,b,c,RD(d,180).a,RD(e,180).a)};_.Dl=function m8d(a,b,c,d,e,f){return new U3d(a,b,c,RD(d,180).a,RD(e,180).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/3',1370);feb(1371,zKe,{},n8d);_.Cl=function o8d(a,b,c,d,e){return new V3d(a,b,c,Kfb(UD(d)),Kfb(UD(e)))};_.Dl=function p8d(a,b,c,d,e,f){return new W3d(a,b,c,Kfb(UD(d)),Kfb(UD(e)),f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/4',1371);feb(1372,zKe,{},q8d);_.Cl=function r8d(a,b,c,d,e){return new X3d(a,b,c,RD(d,161).a,RD(e,161).a)};_.Dl=function s8d(a,b,c,d,e,f){return new Y3d(a,b,c,RD(d,161).a,RD(e,161).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/5',1372);feb(1373,zKe,{},t8d);_.Cl=function u8d(a,b,c,d,e){return new Z3d(a,b,c,RD(d,17).a,RD(e,17).a)};_.Dl=function v8d(a,b,c,d,e,f){return new $3d(a,b,c,RD(d,17).a,RD(e,17).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/6',1373);feb(1374,zKe,{},w8d);_.Cl=function x8d(a,b,c,d,e){return new _3d(a,b,c,RD(d,168).a,RD(e,168).a)};_.Dl=function y8d(a,b,c,d,e,f){return new a4d(a,b,c,RD(d,168).a,RD(e,168).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/7',1374);feb(1375,zKe,{},z8d);_.Cl=function A8d(a,b,c,d,e){return new e4d(a,b,c,RD(d,191).a,RD(e,191).a)};_.Dl=function B8d(a,b,c,d,e,f){return new f4d(a,b,c,RD(d,191).a,RD(e,191).a,f)};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleData/NotificationCreator/8',1375);feb(1353,574,{},C8d);_.Bl=function D8d(a){if(!this.a.fk(a)){throw Adb(new Ifb(xKe+rb(a)+yKe+this.a+"'"))}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataDynamic',1353);feb(1354,574,{},E8d);_.Bl=function F8d(a){};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataStatic',1354);feb(785,574,{});_.Bk=function G8d(a,b,c){var d;d=b.li(c);return d!=null};_.Ck=function H8d(a,b,c,d){var e,f;if(a.vh()&&a.wh()){e=true;f=b.li(c);if(f==null){e=false;f=this.b;}else dE(f)===dE(r7d)&&(f=null);if(d==null){if(this.c!=null){b.mi(c,null);d=this.b;}else {b.mi(c,r7d);}}else {this.Bl(d);b.mi(c,d);}qvd(a,this.d.Dl(a,1,this.e,f,d,!e));}else {if(d==null){this.c!=null?b.mi(c,null):b.mi(c,r7d);}else {this.Bl(d);b.mi(c,d);}}};_.Ek=function I8d(a,b,c){var d,e;if(a.vh()&&a.wh()){d=true;e=b.li(c);if(e==null){d=false;e=this.b;}else dE(e)===dE(r7d)&&(e=null);b.ni(c);qvd(a,this.d.Dl(a,2,this.e,e,this.b,d));}else {b.ni(c);}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettable',785);feb(1355,785,{},J8d);_.Bl=function K8d(a){if(!this.a.fk(a)){throw Adb(new Ifb(xKe+rb(a)+yKe+this.a+"'"))}};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableDynamic',1355);feb(1356,785,{},L8d);_.Bl=function M8d(a){};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleDataUnsettableStatic',1356);feb(410,512,{},N8d);_.yk=function P8d(a,b,c,d,e){var f,g,h,i,j;j=b.li(c);if(this.tk()&&dE(j)===dE(r7d)){return null}else if(this.bl()&&d&&j!=null){h=RD(j,54);if(h.Vh()){i=Vvd(a,h);if(h!=i){if(!FXd(this.a,i)){throw Adb(new Ifb(xKe+rb(i)+yKe+this.a+"'"))}b.mi(c,j=i);if(this.al()){f=RD(i,54);g=h.Th(a,!this.b?-1-BYd(a.Dh(),this.e):BYd(h.Dh(),this.b),null,null);!f.Ph()&&(g=f.Rh(a,!this.b?-1-BYd(a.Dh(),this.e):BYd(f.Dh(),this.b),null,g));!!g&&g.oj();}a.vh()&&a.wh()&&qvd(a,new b4d(a,9,this.e,h,i));}}return j}else {return j}};_.zk=function Q8d(a,b,c,d,e){var f,g;g=b.li(c);dE(g)===dE(r7d)&&(g=null);b.mi(c,d);if(this.Mj()){if(dE(g)!==dE(d)&&g!=null){f=RD(g,54);e=f.Th(a,BYd(f.Dh(),this.b),null,e);}}else this.al()&&g!=null&&(e=RD(g,54).Th(a,-1-BYd(a.Dh(),this.e),null,e));if(a.vh()&&a.wh()){!e&&(e=new gLd(4));e.nj(new b4d(a,1,this.e,g,d));}return e};_.Ak=function R8d(a,b,c,d,e){var f;f=b.li(c);dE(f)===dE(r7d)&&(f=null);b.ni(c);if(a.vh()&&a.wh()){!e&&(e=new gLd(4));this.tk()?e.nj(new b4d(a,2,this.e,f,null)):e.nj(new b4d(a,1,this.e,f,null));}return e};_.Bk=function S8d(a,b,c){var d;d=b.li(c);return d!=null};_.Ck=function T8d(a,b,c,d){var e,f,g,h,i;if(d!=null&&!FXd(this.a,d)){throw Adb(new Ifb(xKe+(ZD(d,58)?GYd(RD(d,58).Dh()):ofb(rb(d)))+yKe+this.a+"'"))}i=b.li(c);h=i!=null;this.tk()&&dE(i)===dE(r7d)&&(i=null);g=null;if(this.Mj()){if(dE(i)!==dE(d)){if(i!=null){e=RD(i,54);g=e.Th(a,BYd(e.Dh(),this.b),null,g);}if(d!=null){e=RD(d,54);g=e.Rh(a,BYd(e.Dh(),this.b),null,g);}}}else if(this.al()){if(dE(i)!==dE(d)){i!=null&&(g=RD(i,54).Th(a,-1-BYd(a.Dh(),this.e),null,g));d!=null&&(g=RD(d,54).Rh(a,-1-BYd(a.Dh(),this.e),null,g));}}d==null&&this.tk()?b.mi(c,r7d):b.mi(c,d);if(a.vh()&&a.wh()){f=new d4d(a,1,this.e,i,d,this.tk()&&!h);if(!g){qvd(a,f);}else {g.nj(f);g.oj();}}else !!g&&g.oj();};_.Ek=function U8d(a,b,c){var d,e,f,g,h;h=b.li(c);g=h!=null;this.tk()&&dE(h)===dE(r7d)&&(h=null);f=null;if(h!=null){if(this.Mj()){d=RD(h,54);f=d.Th(a,BYd(d.Dh(),this.b),null,f);}else this.al()&&(f=RD(h,54).Th(a,-1-BYd(a.Dh(),this.e),null,f));}b.ni(c);if(a.vh()&&a.wh()){e=new d4d(a,this.tk()?2:1,this.e,h,null,g);if(!f){qvd(a,e);}else {f.nj(e);f.oj();}}else !!f&&f.oj();};_.Mj=function V8d(){return false};_.al=function W8d(){return false};_.bl=function X8d(){return false};_.tk=function Y8d(){return false};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObject',410);feb(575,410,{},Z8d);_.al=function $8d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainment',575);feb(1359,575,{},_8d);_.bl=function a9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentResolving',1359);feb(787,575,{},b9d);_.tk=function c9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettable',787);feb(1361,787,{},d9d);_.bl=function e9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentUnsettableResolving',1361);feb(650,575,{},f9d);_.Mj=function g9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverse',650);feb(1360,650,{},h9d);_.bl=function i9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseResolving',1360);feb(788,650,{},j9d);_.tk=function k9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettable',788);feb(1362,788,{},l9d);_.bl=function m9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectContainmentWithInverseUnsettableResolving',1362);feb(651,410,{},n9d);_.bl=function o9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolving',651);feb(1363,651,{},p9d);_.tk=function q9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingUnsettable',1363);feb(789,651,{},r9d);_.Mj=function s9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverse',789);feb(1364,789,{},t9d);_.tk=function u9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectResolvingWithInverseUnsettable',1364);feb(1357,410,{},v9d);_.tk=function w9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectUnsettable',1357);feb(786,410,{},x9d);_.Mj=function y9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverse',786);feb(1358,786,{},z9d);_.tk=function A9d(){return true};sfb(SHe,'EStructuralFeatureImpl/InternalSettingDelegateSingleEObjectWithInverseUnsettable',1358);feb(790,576,wKe,D9d);_.yl=function E9d(a){return new D9d(this.a,this.c,a)};_.md=function F9d(){return this.b};_.zl=function G9d(a,b,c){return B9d(this,a,this.b,c)};_.Al=function H9d(a,b,c){return C9d(this,a,this.b,c)};sfb(SHe,'EStructuralFeatureImpl/InverseUpdatingFeatureMapEntry',790);feb(1365,1,$Je,I9d);_.Fk=function J9d(a){return this.a};_.Qj=function K9d(){return ZD(this.a,97)?RD(this.a,97).Qj():!this.a.dc()};_.Wb=function L9d(a){this.a.$b();this.a.Gc(RD(a,15));};_.Gk=function M9d(){ZD(this.a,97)?RD(this.a,97).Gk():this.a.$b();};sfb(SHe,'EStructuralFeatureImpl/SettingMany',1365);feb(1366,576,wKe,N9d);_.xl=function O9d(a){return new S9d((nme(),mme),this.b.ri(this.a,a))};_.md=function P9d(){return null};_.zl=function Q9d(a,b,c){return c};_.Al=function R9d(a,b,c){return c};sfb(SHe,'EStructuralFeatureImpl/SimpleContentFeatureMapEntry',1366);feb(652,576,wKe,S9d);_.xl=function T9d(a){return new S9d(this.c,a)};_.md=function U9d(){return this.a};_.zl=function V9d(a,b,c){return c};_.Al=function W9d(a,b,c){return c};sfb(SHe,'EStructuralFeatureImpl/SimpleFeatureMapEntry',652);feb(403,506,PIe,X9d);_.aj=function Y9d(a){return $C(h7,rve,29,a,0,1)};_.Yi=function Z9d(){return false};sfb(SHe,'ESuperAdapter/1',403);feb(457,448,{110:1,94:1,93:1,155:1,197:1,58:1,114:1,850:1,54:1,99:1,158:1,457:1,119:1,120:1},_9d);_.Lh=function aae(a,b,c){var d;switch(a){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),this.Ab;case 1:return this.zb;case 2:return !this.a&&(this.a=new iae(this,o7,this)),this.a;}return zvd(this,a-AYd((JTd(),ITd)),vYd((d=RD(Ywd(this,16),29),!d?ITd:d),a),b,c)};_.Uh=function bae(a,b,c){var d,e;switch(b){case 0:return !this.Ab&&(this.Ab=new C5d(f7,this,0,3)),rLd(this.Ab,a,c);case 2:return !this.a&&(this.a=new iae(this,o7,this)),rLd(this.a,a,c);}return e=RD(vYd((d=RD(Ywd(this,16),29),!d?(JTd(),ITd):d),b),69),e.wk().Ak(this,Wwd(this),b-AYd((JTd(),ITd)),a,c)};_.Wh=function cae(a){var b;switch(a){case 0:return !!this.Ab&&this.Ab.i!=0;case 1:return this.zb!=null;case 2:return !!this.a&&this.a.i!=0;}return Avd(this,a-AYd((JTd(),ITd)),vYd((b=RD(Ywd(this,16),29),!b?ITd:b),a))};_.bi=function dae(a,b){var c;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);!this.Ab&&(this.Ab=new C5d(f7,this,0,3));YGd(this.Ab,RD(b,16));return;case 1:PAd(this,WD(b));return;case 2:!this.a&&(this.a=new iae(this,o7,this));sLd(this.a);!this.a&&(this.a=new iae(this,o7,this));YGd(this.a,RD(b,16));return;}Bvd(this,a-AYd((JTd(),ITd)),vYd((c=RD(Ywd(this,16),29),!c?ITd:c),a),b);};_.ii=function eae(){return JTd(),ITd};_.ki=function fae(a){var b;switch(a){case 0:!this.Ab&&(this.Ab=new C5d(f7,this,0,3));sLd(this.Ab);return;case 1:PAd(this,null);return;case 2:!this.a&&(this.a=new iae(this,o7,this));sLd(this.a);return;}Cvd(this,a-AYd((JTd(),ITd)),vYd((b=RD(Ywd(this,16),29),!b?ITd:b),a));};sfb(SHe,'ETypeParameterImpl',457);feb(458,83,oKe,iae);_.Nj=function jae(a,b){return gae(this,RD(a,89),b)};_.Oj=function kae(a,b){return hae(this,RD(a,89),b)};sfb(SHe,'ETypeParameterImpl/1',458);feb(647,45,Hxe,lae);_.ec=function mae(){return new pae(this)};sfb(SHe,'ETypeParameterImpl/2',647);feb(570,Eve,Fve,pae);_.Fc=function qae(a){return nae(this,RD(a,89))};_.Gc=function rae(a){var b,c,d;d=false;for(c=a.Kc();c.Ob();){b=RD(c.Pb(),89);Zjb(this.a,b,'')==null&&(d=true);}return d};_.$b=function sae(){akb(this.a);};_.Hc=function tae(a){return Ujb(this.a,a)};_.Kc=function uae(){var a;return a=new vkb((new mkb(this.a)).a),new xae(a)};_.Mc=function vae(a){return oae(this,a)};_.gc=function wae(){return bkb(this.a)};sfb(SHe,'ETypeParameterImpl/2/1',570);feb(571,1,Ave,xae);_.Nb=function yae(a){Ztb(this,a);};_.Pb=function Aae(){return RD(tkb(this.a).ld(),89)};_.Ob=function zae(){return this.a.b};_.Qb=function Bae(){ukb(this.a);};sfb(SHe,'ETypeParameterImpl/2/1/1',571);feb(1329,45,Hxe,Cae);_._b=function Dae(a){return bE(a)?Yjb(this,a):!!qtb(this.f,a)};_.xc=function Eae(a){var b,c;b=bE(a)?Xjb(this,a):Wd(qtb(this.f,a));if(ZD(b,851)){c=RD(b,851);b=c.Kk();Zjb(this,RD(a,241),b);return b}else return b!=null?b:a==null?(Gie(),Fie):null};sfb(SHe,'EValidatorRegistryImpl',1329);feb(1349,720,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,2040:1,54:1,99:1,158:1,119:1,120:1},Mae);_.ri=function Nae(a,b){switch(a.hk()){case 21:case 22:case 23:case 24:case 26:case 31:case 32:case 37:case 38:case 39:case 40:case 43:case 44:case 48:case 49:case 20:return b==null?null:jeb(b);case 25:return Gae(b);case 27:return Hae(b);case 28:return Iae(b);case 29:return b==null?null:a2d(nAd[0],RD(b,206));case 41:return b==null?'':nfb(RD(b,297));case 42:return jeb(b);case 50:return WD(b);default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function Oae(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;switch(a.G==-1&&(a.G=(m=BXd(a),m?fZd(m.vi(),a):-1)),a.G){case 0:return c=new mXd,c;case 1:return b=new pVd,b;case 2:return d=new HYd,d;case 4:return e=new k1d,e;case 5:return f=new A1d,f;case 6:return g=new R1d,g;case 7:return h=new yAd,h;case 10:return j=new kUd,j;case 11:return k=new q4d,k;case 12:return l=new EBd,l;case 13:return n=new R5d,n;case 14:return o=new d6d,o;case 17:return p=new v6d,p;case 18:return i=new s2d,i;case 19:return q=new _9d,q;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function Pae(a,b){switch(a.hk()){case 20:return b==null?null:new Bib(b);case 21:return b==null?null:new ejb(b);case 23:case 22:return b==null?null:Fae(b);case 26:case 24:return b==null?null:$eb(Oeb(b,-128,127)<<24>>24);case 25:return vAd(b);case 27:return Jae(b);case 28:return Kae(b);case 29:return Lae(b);case 32:case 31:return b==null?null:Neb(b);case 38:case 37:return b==null?null:new Ufb(b);case 40:case 39:return b==null?null:sgb(Oeb(b,qwe,lve));case 41:return null;case 42:return b==null?null:null;case 44:case 43:return b==null?null:Hgb(Peb(b));case 49:case 48:return b==null?null:bhb(Oeb(b,BKe,32767)<<16>>16);case 50:return b;default:throw Adb(new agb(VHe+a.xe()+WHe));}};sfb(SHe,'EcoreFactoryImpl',1349);feb(560,184,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,2038:1,54:1,99:1,158:1,184:1,560:1,119:1,120:1,690:1},$ae);_.gb=false;_.hb=false;var Rae,Sae=false;sfb(SHe,'EcorePackageImpl',560);feb(1234,1,{851:1},cbe);_.Kk=function dbe(){return fke(),eke};sfb(SHe,'EcorePackageImpl/1',1234);feb(1243,1,OKe,ebe);_.fk=function fbe(a){return ZD(a,155)};_.gk=function gbe(a){return $C(p7,rve,155,a,0,1)};sfb(SHe,'EcorePackageImpl/10',1243);feb(1244,1,OKe,hbe);_.fk=function ibe(a){return ZD(a,197)};_.gk=function jbe(a){return $C(q7,rve,197,a,0,1)};sfb(SHe,'EcorePackageImpl/11',1244);feb(1245,1,OKe,kbe);_.fk=function lbe(a){return ZD(a,58)};_.gk=function mbe(a){return $C(r7,rve,58,a,0,1)};sfb(SHe,'EcorePackageImpl/12',1245);feb(1246,1,OKe,nbe);_.fk=function obe(a){return ZD(a,411)};_.gk=function pbe(a){return $C(s7,mKe,62,a,0,1)};sfb(SHe,'EcorePackageImpl/13',1246);feb(1247,1,OKe,qbe);_.fk=function rbe(a){return ZD(a,241)};_.gk=function sbe(a){return $C(t7,rve,241,a,0,1)};sfb(SHe,'EcorePackageImpl/14',1247);feb(1248,1,OKe,tbe);_.fk=function ube(a){return ZD(a,518)};_.gk=function vbe(a){return $C(u7,rve,2116,a,0,1)};sfb(SHe,'EcorePackageImpl/15',1248);feb(1249,1,OKe,wbe);_.fk=function xbe(a){return ZD(a,102)};_.gk=function ybe(a){return $C(v7,lKe,19,a,0,1)};sfb(SHe,'EcorePackageImpl/16',1249);feb(1250,1,OKe,zbe);_.fk=function Abe(a){return ZD(a,179)};_.gk=function Bbe(a){return $C(y7,lKe,179,a,0,1)};sfb(SHe,'EcorePackageImpl/17',1250);feb(1251,1,OKe,Cbe);_.fk=function Dbe(a){return ZD(a,481)};_.gk=function Ebe(a){return $C(A7,rve,481,a,0,1)};sfb(SHe,'EcorePackageImpl/18',1251);feb(1252,1,OKe,Fbe);_.fk=function Gbe(a){return ZD(a,561)};_.gk=function Hbe(a){return $C(C8,LJe,561,a,0,1)};sfb(SHe,'EcorePackageImpl/19',1252);feb(1235,1,OKe,Ibe);_.fk=function Jbe(a){return ZD(a,331)};_.gk=function Kbe(a){return $C(g7,lKe,35,a,0,1)};sfb(SHe,'EcorePackageImpl/2',1235);feb(1253,1,OKe,Lbe);_.fk=function Mbe(a){return ZD(a,248)};_.gk=function Nbe(a){return $C(o7,sKe,89,a,0,1)};sfb(SHe,'EcorePackageImpl/20',1253);feb(1254,1,OKe,Obe);_.fk=function Pbe(a){return ZD(a,457)};_.gk=function Qbe(a){return $C(z7,rve,850,a,0,1)};sfb(SHe,'EcorePackageImpl/21',1254);feb(1255,1,OKe,Rbe);_.fk=function Sbe(a){return $D(a)};_.gk=function Tbe(a){return $C(QI,Nve,485,a,8,1)};sfb(SHe,'EcorePackageImpl/22',1255);feb(1256,1,OKe,Ube);_.fk=function Vbe(a){return ZD(a,195)};_.gk=function Wbe(a){return $C(gE,Nve,195,a,0,2)};sfb(SHe,'EcorePackageImpl/23',1256);feb(1257,1,OKe,Xbe);_.fk=function Ybe(a){return ZD(a,222)};_.gk=function Zbe(a){return $C(RI,Nve,222,a,0,1)};sfb(SHe,'EcorePackageImpl/24',1257);feb(1258,1,OKe,$be);_.fk=function _be(a){return ZD(a,180)};_.gk=function ace(a){return $C(SI,Nve,180,a,0,1)};sfb(SHe,'EcorePackageImpl/25',1258);feb(1259,1,OKe,bce);_.fk=function cce(a){return ZD(a,206)};_.gk=function dce(a){return $C(qK,Nve,206,a,0,1)};sfb(SHe,'EcorePackageImpl/26',1259);feb(1260,1,OKe,ece);_.fk=function fce(a){return false};_.gk=function gce(a){return $C(T6,rve,2215,a,0,1)};sfb(SHe,'EcorePackageImpl/27',1260);feb(1261,1,OKe,hce);_.fk=function ice(a){return _D(a)};_.gk=function jce(a){return $C(VI,Nve,345,a,7,1)};sfb(SHe,'EcorePackageImpl/28',1261);feb(1262,1,OKe,kce);_.fk=function lce(a){return ZD(a,61)};_.gk=function mce(a){return $C(Y6,Ize,61,a,0,1)};sfb(SHe,'EcorePackageImpl/29',1262);feb(1236,1,OKe,nce);_.fk=function oce(a){return ZD(a,519)};_.gk=function pce(a){return $C(f7,{3:1,4:1,5:1,2033:1},598,a,0,1)};sfb(SHe,'EcorePackageImpl/3',1236);feb(1263,1,OKe,qce);_.fk=function rce(a){return ZD(a,582)};_.gk=function sce(a){return $C(Z6,rve,2039,a,0,1)};sfb(SHe,'EcorePackageImpl/30',1263);feb(1264,1,OKe,tce);_.fk=function uce(a){return ZD(a,160)};_.gk=function vce(a){return $C(Tbb,Ize,160,a,0,1)};sfb(SHe,'EcorePackageImpl/31',1264);feb(1265,1,OKe,wce);_.fk=function xce(a){return ZD(a,76)};_.gk=function yce(a){return $C(Jbb,PKe,76,a,0,1)};sfb(SHe,'EcorePackageImpl/32',1265);feb(1266,1,OKe,zce);_.fk=function Ace(a){return ZD(a,161)};_.gk=function Bce(a){return $C(ZI,Nve,161,a,0,1)};sfb(SHe,'EcorePackageImpl/33',1266);feb(1267,1,OKe,Cce);_.fk=function Dce(a){return ZD(a,17)};_.gk=function Ece(a){return $C(bJ,Nve,17,a,0,1)};sfb(SHe,'EcorePackageImpl/34',1267);feb(1268,1,OKe,Fce);_.fk=function Gce(a){return ZD(a,297)};_.gk=function Hce(a){return $C(UI,rve,297,a,0,1)};sfb(SHe,'EcorePackageImpl/35',1268);feb(1269,1,OKe,Ice);_.fk=function Jce(a){return ZD(a,168)};_.gk=function Kce(a){return $C(eJ,Nve,168,a,0,1)};sfb(SHe,'EcorePackageImpl/36',1269);feb(1270,1,OKe,Lce);_.fk=function Mce(a){return ZD(a,85)};_.gk=function Nce(a){return $C(VK,rve,85,a,0,1)};sfb(SHe,'EcorePackageImpl/37',1270);feb(1271,1,OKe,Oce);_.fk=function Pce(a){return ZD(a,599)};_.gk=function Qce(a){return $C(Aab,rve,599,a,0,1)};sfb(SHe,'EcorePackageImpl/38',1271);feb(1272,1,OKe,Rce);_.fk=function Sce(a){return false};_.gk=function Tce(a){return $C(zab,rve,2216,a,0,1)};sfb(SHe,'EcorePackageImpl/39',1272);feb(1237,1,OKe,Uce);_.fk=function Vce(a){return ZD(a,90)};_.gk=function Wce(a){return $C(h7,rve,29,a,0,1)};sfb(SHe,'EcorePackageImpl/4',1237);feb(1273,1,OKe,Xce);_.fk=function Yce(a){return ZD(a,191)};_.gk=function Zce(a){return $C(lJ,Nve,191,a,0,1)};sfb(SHe,'EcorePackageImpl/40',1273);feb(1274,1,OKe,$ce);_.fk=function _ce(a){return bE(a)};_.gk=function ade(a){return $C(qJ,Nve,2,a,6,1)};sfb(SHe,'EcorePackageImpl/41',1274);feb(1275,1,OKe,bde);_.fk=function cde(a){return ZD(a,596)};_.gk=function dde(a){return $C(a7,rve,596,a,0,1)};sfb(SHe,'EcorePackageImpl/42',1275);feb(1276,1,OKe,ede);_.fk=function fde(a){return false};_.gk=function gde(a){return $C($6,Nve,2217,a,0,1)};sfb(SHe,'EcorePackageImpl/43',1276);feb(1277,1,OKe,hde);_.fk=function ide(a){return ZD(a,44)};_.gk=function jde(a){return $C(UK,Zve,44,a,0,1)};sfb(SHe,'EcorePackageImpl/44',1277);feb(1238,1,OKe,kde);_.fk=function lde(a){return ZD(a,142)};_.gk=function mde(a){return $C(i7,rve,142,a,0,1)};sfb(SHe,'EcorePackageImpl/5',1238);feb(1239,1,OKe,nde);_.fk=function ode(a){return ZD(a,156)};_.gk=function pde(a){return $C(k7,rve,156,a,0,1)};sfb(SHe,'EcorePackageImpl/6',1239);feb(1240,1,OKe,qde);_.fk=function rde(a){return ZD(a,469)};_.gk=function sde(a){return $C(m7,rve,685,a,0,1)};sfb(SHe,'EcorePackageImpl/7',1240);feb(1241,1,OKe,tde);_.fk=function ude(a){return ZD(a,582)};_.gk=function vde(a){return $C(l7,rve,694,a,0,1)};sfb(SHe,'EcorePackageImpl/8',1241);feb(1242,1,OKe,wde);_.fk=function xde(a){return ZD(a,480)};_.gk=function yde(a){return $C(n7,rve,480,a,0,1)};sfb(SHe,'EcorePackageImpl/9',1242);feb(1038,2080,JJe,Cde);_.Mi=function Dde(a,b){zde(this,RD(b,424));};_.Qi=function Ede(a,b){Ade(this,a,RD(b,424));};sfb(SHe,'MinimalEObjectImpl/1ArrayDelegatingAdapterList',1038);feb(1039,152,GJe,Fde);_.jj=function Gde(){return this.a.a};sfb(SHe,'MinimalEObjectImpl/1ArrayDelegatingAdapterList/1',1039);feb(1067,1066,{},Ide);sfb('org.eclipse.emf.ecore.plugin','EcorePlugin',1067);var Aab=ufb(QKe,'Resource');feb(799,1524,RKe);_.Hl=function Mde(a){};_.Il=function Nde(a){};_.El=function Ode(){return !this.a&&(this.a=new Zde(this)),this.a};_.Fl=function Pde(a){var b,c,d,e,f;d=a.length;if(d>0){BFb(0,a.length);if(a.charCodeAt(0)==47){f=new cnb(4);e=1;for(b=1;b0&&(a=(AFb(0,c,a.length),a.substr(0,c)));}}}return Kde(this,a)};_.Gl=function Qde(){return this.c};_.Ib=function Rde(){var a;return nfb(this.Rm)+'@'+(a=tb(this)>>>0,a.toString(16))+" uri='"+this.d+"'"};_.b=false;sfb(SKe,'ResourceImpl',799);feb(1525,799,RKe,Sde);sfb(SKe,'BinaryResourceImpl',1525);feb(1190,708,QIe);_.bj=function Vde(a){return ZD(a,58)?Tde(this,RD(a,58)):ZD(a,599)?new dMd(RD(a,599).El()):dE(a)===dE(this.f)?RD(a,16).Kc():(jQd(),iQd.a)};_.Ob=function Wde(){return Ude(this)};_.a=false;sfb(ZJe,'EcoreUtil/ContentTreeIterator',1190);feb(1526,1190,QIe,Xde);_.bj=function Yde(a){return dE(a)===dE(this.f)?RD(a,15).Kc():new _je(RD(a,58))};sfb(SKe,'ResourceImpl/5',1526);feb(658,2092,nKe,Zde);_.Hc=function $de(a){return this.i<=4?PHd(this,a):ZD(a,54)&&RD(a,54).Jh()==this.a};_.Mi=function _de(a,b){a==this.i-1&&(this.a.b||(this.a.b=true,null));};_.Oi=function aee(a,b){a==0?this.a.b||(this.a.b=true,null):$Gd(this,a,b);};_.Qi=function bee(a,b){};_.Ri=function cee(a,b,c){};_.Lj=function dee(){return 2};_.jj=function eee(){return this.a};_.Mj=function fee(){return true};_.Nj=function gee(a,b){var c;c=RD(a,54);b=c.fi(this.a,b);return b};_.Oj=function hee(a,b){var c;c=RD(a,54);return c.fi(null,b)};_.Pj=function iee(){return false};_.Si=function jee(){return true};_.aj=function kee(a){return $C(r7,rve,58,a,0,1)};_.Yi=function lee(){return false};sfb(SKe,'ResourceImpl/ContentsEList',658);feb(970,2062,kwe,mee);_.fd=function nee(a){return this.a.Ki(a)};_.gc=function oee(){return this.a.gc()};sfb(ZJe,'AbstractSequentialInternalEList/1',970);var hke,ike,jke,kke;feb(634,1,{},Yee);var pee,qee;sfb(ZJe,'BasicExtendedMetaData',634);feb(1181,1,{},afe);_.Jl=function bfe(){return null};_.Kl=function cfe(){this.a==-2&&$ee(this,uee(this.d,this.b));return this.a};_.Ll=function dfe(){return null};_.Ml=function efe(){return yob(),yob(),vob};_.xe=function ffe(){this.c==fLe&&_ee(this,zee(this.d,this.b));return this.c};_.Nl=function gfe(){return 0};_.a=-2;_.c=fLe;sfb(ZJe,'BasicExtendedMetaData/EClassExtendedMetaDataImpl',1181);feb(1182,1,{},mfe);_.Jl=function nfe(){this.a==(ree(),pee)&&hfe(this,tee(this.f,this.b));return this.a};_.Kl=function ofe(){return 0};_.Ll=function pfe(){this.c==(ree(),pee)&&ife(this,xee(this.f,this.b));return this.c};_.Ml=function qfe(){!this.d&&jfe(this,yee(this.f,this.b));return this.d};_.xe=function rfe(){this.e==fLe&&kfe(this,zee(this.f,this.b));return this.e};_.Nl=function sfe(){this.g==-2&&lfe(this,Cee(this.f,this.b));return this.g};_.e=fLe;_.g=-2;sfb(ZJe,'BasicExtendedMetaData/EDataTypeExtendedMetaDataImpl',1182);feb(1180,1,{},wfe);_.b=false;_.c=false;sfb(ZJe,'BasicExtendedMetaData/EPackageExtendedMetaDataImpl',1180);feb(1183,1,{},Jfe);_.c=-2;_.e=fLe;_.f=fLe;sfb(ZJe,'BasicExtendedMetaData/EStructuralFeatureExtendedMetaDataImpl',1183);feb(593,632,oKe,Kfe);_.Lj=function Lfe(){return this.c};_.ol=function Mfe(){return false};_.Wi=function Nfe(a,b){return b};_.c=0;sfb(ZJe,'EDataTypeEList',593);var Tbb=ufb(ZJe,'FeatureMap');feb(78,593,{3:1,4:1,20:1,31:1,56:1,16:1,15:1,59:1,70:1,66:1,61:1,79:1,160:1,220:1,2036:1,71:1,97:1},Uge);_.bd=function Vge(a,b){Ofe(this,a,RD(b,76));};_.Fc=function Wge(a){return Rfe(this,RD(a,76))};_.Hi=function _ge(a){Wfe(this,RD(a,76));};_.Nj=function khe(a,b){return mge(this,RD(a,76),b)};_.Oj=function lhe(a,b){return oge(this,RD(a,76),b)};_.Ti=function nhe(a,b){return uge(this,a,b)};_.Wi=function phe(a,b){return zge(this,a,RD(b,76))};_.hd=function rhe(a,b){return Cge(this,a,RD(b,76))};_.Uj=function vhe(a,b){return Ige(this,RD(a,76),b)};_.Vj=function whe(a,b){return Kge(this,RD(a,76),b)};_.Wj=function xhe(a,b,c){return Lge(this,RD(a,76),RD(b,76),c)};_.Zi=function zhe(a,b){return Tge(this,a,RD(b,76))};_.Ol=function Xge(a,b){return Qfe(this,a,b)};_.cd=function Yge(a,b){var c,d,e,f,g,h,i,j,k;j=new ZHd(b.gc());for(e=b.Kc();e.Ob();){d=RD(e.Pb(),76);f=d.Lk();if(qke(this.e,f)){(!f.Si()||!cge(this,f,d.md())&&!PHd(j,d))&&WGd(j,d);}else {k=pke(this.e.Dh(),f);c=RD(this.g,124);g=true;for(h=0;h=0){b=a[this.c];if(this.k.am(b.Lk())){this.j=this.f?b:b.md();this.i=-2;return true}}this.i=-1;this.g=-1;return false};sfb(ZJe,'BasicFeatureMap/FeatureEIterator',420);feb(676,420,Jve,She);_.ul=function The(){return true};sfb(ZJe,'BasicFeatureMap/ResolvingFeatureEIterator',676);feb(968,496,uKe,Uhe);_.pj=function Vhe(){return this};sfb(ZJe,'EContentsEList/1',968);feb(969,496,uKe,Whe);_.ul=function Xhe(){return false};sfb(ZJe,'EContentsEList/2',969);feb(967,287,vKe,Yhe);_.wl=function Zhe(a){};_.Ob=function $he(){return false};_.Sb=function _he(){return false};sfb(ZJe,'EContentsEList/FeatureIteratorImpl/1',967);feb(840,593,oKe,aie);_.Ni=function bie(){this.a=true;};_.Qj=function cie(){return this.a};_.Gk=function die(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EDataTypeEList/Unsettable',840);feb(1958,593,oKe,eie);_.Si=function fie(){return true};sfb(ZJe,'EDataTypeUniqueEList',1958);feb(1959,840,oKe,gie);_.Si=function hie(){return true};sfb(ZJe,'EDataTypeUniqueEList/Unsettable',1959);feb(147,83,oKe,iie);_.nl=function jie(){return true};_.Wi=function kie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentEList/Resolving',147);feb(1184,555,oKe,lie);_.nl=function mie(){return true};_.Wi=function nie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentEList/Unsettable/Resolving',1184);feb(766,14,oKe,oie);_.Ni=function pie(){this.a=true;};_.Qj=function qie(){return this.a};_.Gk=function rie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectContainmentWithInverseEList/Unsettable',766);feb(1222,766,oKe,sie);_.nl=function tie(){return true};_.Wi=function uie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectContainmentWithInverseEList/Unsettable/Resolving',1222);feb(757,505,oKe,vie);_.Ni=function wie(){this.a=true;};_.Qj=function xie(){return this.a};_.Gk=function yie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectEList/Unsettable',757);feb(338,505,oKe,zie);_.nl=function Aie(){return true};_.Wi=function Bie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectResolvingEList',338);feb(1844,757,oKe,Cie);_.nl=function Die(){return true};_.Wi=function Eie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectResolvingEList/Unsettable',1844);feb(1527,1,{},Hie);var Fie;sfb(ZJe,'EObjectValidator',1527);feb(559,505,oKe,Iie);_.il=function Jie(){return this.d};_.jl=function Kie(){return this.b};_.Mj=function Lie(){return true};_.ml=function Mie(){return true};_.b=0;sfb(ZJe,'EObjectWithInverseEList',559);feb(1225,559,oKe,Nie);_.ll=function Oie(){return true};sfb(ZJe,'EObjectWithInverseEList/ManyInverse',1225);feb(635,559,oKe,Pie);_.Ni=function Qie(){this.a=true;};_.Qj=function Rie(){return this.a};_.Gk=function Sie(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EObjectWithInverseEList/Unsettable',635);feb(1224,635,oKe,Tie);_.ll=function Uie(){return true};sfb(ZJe,'EObjectWithInverseEList/Unsettable/ManyInverse',1224);feb(767,559,oKe,Vie);_.nl=function Wie(){return true};_.Wi=function Xie(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectWithInverseResolvingEList',767);feb(32,767,oKe,Yie);_.ll=function Zie(){return true};sfb(ZJe,'EObjectWithInverseResolvingEList/ManyInverse',32);feb(768,635,oKe,$ie);_.nl=function _ie(){return true};_.Wi=function aje(a,b){return gZd(this,a,RD(b,58))};sfb(ZJe,'EObjectWithInverseResolvingEList/Unsettable',768);feb(1223,768,oKe,bje);_.ll=function cje(){return true};sfb(ZJe,'EObjectWithInverseResolvingEList/Unsettable/ManyInverse',1223);feb(1185,632,oKe);_.Li=function dje(){return (this.b&1792)==0};_.Ni=function eje(){this.b|=1;};_.kl=function fje(){return (this.b&4)!=0};_.Mj=function gje(){return (this.b&40)!=0};_.ll=function hje(){return (this.b&16)!=0};_.ml=function ije(){return (this.b&8)!=0};_.nl=function jje(){return (this.b&cKe)!=0};_.al=function kje(){return (this.b&32)!=0};_.ol=function lje(){return (this.b&gwe)!=0};_.fk=function mje(a){return !this.d?this.Lk().Hk().fk(a):QRd(this.d,a)};_.Qj=function nje(){return (this.b&2)!=0?(this.b&1)!=0:this.i!=0};_.Si=function oje(){return (this.b&128)!=0};_.Gk=function qje(){var a;sLd(this);if((this.b&2)!=0){if(Mvd(this.e)){a=(this.b&1)!=0;this.b&=-2;eZd(this,new Q3d(this.e,2,BYd(this.e.Dh(),this.Lk()),a,false));}else {this.b&=-2;}}};_.Yi=function rje(){return (this.b&1536)==0};_.b=0;sfb(ZJe,'EcoreEList/Generic',1185);feb(1186,1185,oKe,sje);_.Lk=function tje(){return this.a};sfb(ZJe,'EcoreEList/Dynamic',1186);feb(765,66,PIe,uje);_.aj=function vje(a){return IMd(this.a.a,a)};sfb(ZJe,'EcoreEMap/1',765);feb(764,83,oKe,wje);_.Mi=function xje(a,b){UNd(this.b,RD(b,136));};_.Oi=function yje(a,b){TNd(this.b);};_.Pi=function zje(a,b,c){var d;++(d=this.b,RD(b,136),d).e;};_.Qi=function Aje(a,b){VNd(this.b,RD(b,136));};_.Ri=function Bje(a,b,c){VNd(this.b,RD(c,136));dE(c)===dE(b)&&RD(c,136).Ci(aOd(RD(b,136).ld()));UNd(this.b,RD(b,136));};sfb(ZJe,'EcoreEMap/DelegateEObjectContainmentEList',764);feb(1220,141,_Je,Cje);sfb(ZJe,'EcoreEMap/Unsettable',1220);feb(1221,764,oKe,Dje);_.Ni=function Eje(){this.a=true;};_.Qj=function Fje(){return this.a};_.Gk=function Gje(){var a;sLd(this);if(Mvd(this.e)){a=this.a;this.a=false;qvd(this.e,new Q3d(this.e,2,this.c,a,false));}else {this.a=false;}};_.a=false;sfb(ZJe,'EcoreEMap/Unsettable/UnsettableDelegateEObjectContainmentEList',1221);feb(1189,215,Hxe,Zje);_.a=false;_.b=false;sfb(ZJe,'EcoreUtil/Copier',1189);feb(759,1,Ave,_je);_.Nb=function ake(a){Ztb(this,a);};_.Ob=function bke(){return $je(this)};_.Pb=function cke(){var a;$je(this);a=this.b;this.b=null;return a};_.Qb=function dke(){this.a.Qb();};sfb(ZJe,'EcoreUtil/ProperContentIterator',759);feb(1528,1527,{},gke);var eke;sfb(ZJe,'EcoreValidator',1528);var mke;ufb(ZJe,'FeatureMapUtil/Validator');feb(1295,1,{2041:1},rke);_.am=function ske(a){return true};sfb(ZJe,'FeatureMapUtil/1',1295);feb(773,1,{2041:1},wke);_.am=function xke(a){var b;if(this.c==a)return true;b=TD(Wjb(this.a,a));if(b==null){if(vke(this,a)){yke(this.a,a,(Geb(),Feb));return true}else {yke(this.a,a,(Geb(),Eeb));return false}}else {return b==(Geb(),Feb)}};_.e=false;var tke;sfb(ZJe,'FeatureMapUtil/BasicValidator',773);feb(774,45,Hxe,zke);sfb(ZJe,'FeatureMapUtil/BasicValidator/Cache',774);feb(509,56,{20:1,31:1,56:1,16:1,15:1,61:1,79:1,71:1,97:1},Eke);_.bd=function Fke(a,b){Pfe(this.c,this.b,a,b);};_.Fc=function Gke(a){return Qfe(this.c,this.b,a)};_.cd=function Hke(a,b){return Sfe(this.c,this.b,a,b)};_.Gc=function Ike(a){return Ake(this,a)};_.Gi=function Jke(a,b){Ufe(this.c,this.b,a,b);};_.Wk=function Kke(a,b){return Xfe(this.c,this.b,a,b)};_.$i=function Lke(a){return hge(this.c,this.b,a,false)};_.Ii=function Mke(){return Yfe(this.c,this.b)};_.Ji=function Nke(){return Zfe(this.c,this.b)};_.Ki=function Oke(a){return $fe(this.c,this.b,a)};_.Xk=function Pke(a,b){return Bke(this,a,b)};_.$b=function Qke(){Cke(this);};_.Hc=function Rke(a){return cge(this.c,this.b,a)};_.Ic=function Ske(a){return ege(this.c,this.b,a)};_.Xb=function Tke(a){return hge(this.c,this.b,a,true)};_.Fk=function Uke(a){return this};_.dd=function Vke(a){return jge(this.c,this.b,a)};_.dc=function Wke(){return Dke(this)};_.Qj=function Xke(){return !pge(this.c,this.b)};_.Kc=function Yke(){return qge(this.c,this.b)};_.ed=function Zke(){return sge(this.c,this.b)};_.fd=function $ke(a){return tge(this.c,this.b,a)};_.Ti=function _ke(a,b){return vge(this.c,this.b,a,b)};_.Ui=function ale(a,b){wge(this.c,this.b,a,b);};_.gd=function ble(a){return xge(this.c,this.b,a)};_.Mc=function cle(a){return yge(this.c,this.b,a)};_.hd=function dle(a,b){return Ege(this.c,this.b,a,b)};_.Wb=function ele(a){bge(this.c,this.b);Ake(this,RD(a,15));};_.gc=function fle(){return Nge(this.c,this.b)};_.Pc=function gle(){return Oge(this.c,this.b)};_.Qc=function hle(a){return Qge(this.c,this.b,a)};_.Ib=function ile(){var a,b;b=new Qhb;b.a+='[';for(a=Yfe(this.c,this.b);Bhe(a);){Nhb(b,Ghb(Dhe(a)));Bhe(a)&&(b.a+=pve,b);}b.a+=']';return b.a};_.Gk=function jle(){bge(this.c,this.b);};sfb(ZJe,'FeatureMapUtil/FeatureEList',509);feb(644,39,GJe,lle);_.hj=function mle(a){return kle(this,a)};_.mj=function nle(a){var b,c,d,e,f,g,h;switch(this.d){case 1:case 2:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.g=a.ij();a.gj()==1&&(this.d=1);return true}break}case 3:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=5;b=new ZHd(2);WGd(b,this.g);WGd(b,a.ij());this.g=b;return true}break}}break}case 5:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){c=RD(this.g,16);c.Fc(a.ij());return true}break}}break}case 4:{e=a.gj();switch(e){case 3:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=1;this.g=a.ij();return true}break}case 4:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){this.d=6;h=new ZHd(2);WGd(h,this.n);WGd(h,a.kj());this.n=h;g=cD(WC(kE,1),Pwe,28,15,[this.o,a.lj()]);this.g=g;return true}break}}break}case 6:{e=a.gj();switch(e){case 4:{f=a.jj();if(dE(f)===dE(this.c)&&kle(this,null)==a.hj(null)){c=RD(this.n,16);c.Fc(a.kj());g=RD(this.g,53);d=$C(kE,Pwe,28,g.length+1,15,1);hib(g,0,d,0,g.length);d[g.length]=a.lj();this.g=d;return true}break}}break}}return false};sfb(ZJe,'FeatureMapUtil/FeatureENotificationImpl',644);feb(564,509,{20:1,31:1,56:1,16:1,15:1,61:1,79:1,160:1,220:1,2036:1,71:1,97:1},ole);_.Ol=function ple(a,b){return Qfe(this.c,a,b)};_.Pl=function qle(a,b,c){return Xfe(this.c,a,b,c)};_.Ql=function rle(a,b,c){return age(this.c,a,b,c)};_.Rl=function sle(){return this};_.Sl=function tle(a,b){return ige(this.c,a,b)};_.Tl=function ule(a){return RD(hge(this.c,this.b,a,false),76).Lk()};_.Ul=function vle(a){return RD(hge(this.c,this.b,a,false),76).md()};_.Vl=function wle(){return this.a};_.Wl=function xle(a){return !pge(this.c,a)};_.Xl=function yle(a,b){Fge(this.c,a,b);};_.Yl=function zle(a){return Gge(this.c,a)};_.Zl=function Ale(a){Sge(this.c,a);};sfb(ZJe,'FeatureMapUtil/FeatureFeatureMap',564);feb(1294,1,$Je,Ble);_.Fk=function Cle(a){return hge(this.b,this.a,-1,a)};_.Qj=function Dle(){return !pge(this.b,this.a)};_.Wb=function Ele(a){Fge(this.b,this.a,a);};_.Gk=function Fle(){bge(this.b,this.a);};sfb(ZJe,'FeatureMapUtil/FeatureValue',1294);var Gle,Hle,Ile,Jle,Kle;var Vbb=ufb(hLe,'AnyType');feb(680,63,swe,Mle);sfb(hLe,'InvalidDatatypeValueException',680);var Xbb=ufb(hLe,iLe);var Ybb=ufb(hLe,jLe);var Zbb=ufb(hLe,kLe);var Nle;var Ple;var Rle,Sle,Tle,Ule,Vle,Wle,Xle,Yle,Zle,$le,_le,ame,bme,cme,dme,eme,fme,gme,hme,ime,jme,kme,lme,mme;feb(844,516,{110:1,94:1,93:1,58:1,54:1,99:1,857:1},ome);_.Lh=function pme(a,b,c){switch(a){case 0:if(c)return !this.c&&(this.c=new Uge(this,0)),this.c;return !this.c&&(this.c=new Uge(this,0)),this.c.b;case 1:if(c)return !this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160);return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Vl();case 2:if(c)return !this.b&&(this.b=new Uge(this,2)),this.b;return !this.b&&(this.b=new Uge(this,2)),this.b.b;}return zvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Uh=function qme(a,b,c){var d;switch(b){case 0:return !this.c&&(this.c=new Uge(this,0)),_fe(this.c,a,c);case 1:return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),71)).Xk(a,c);case 2:return !this.b&&(this.b=new Uge(this,2)),_fe(this.b,a,c);}return d=RD(vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),b),69),d.wk().Ak(this,Yvd(this),b-AYd(this.ii()),a,c)};_.Wh=function rme(a){switch(a){case 0:return !!this.c&&this.c.i!=0;case 1:return !(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).dc();case 2:return !!this.b&&this.b.i!=0;}return Avd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function sme(a,b){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));Dge(this.c,b);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Wb(b);return;case 2:!this.b&&(this.b=new Uge(this,2));Dge(this.b,b);return;}Bvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function tme(){return nme(),Rle};_.ki=function ume(a){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));sLd(this.c);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).$b();return;case 2:!this.b&&(this.b=new Uge(this,2));sLd(this.b);return;}Cvd(this,a-AYd(this.ii()),vYd((this.j&2)==0?this.ii():(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function vme(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (mixed: ';Mhb(a,this.c);a.a+=', anyAttribute: ';Mhb(a,this.b);a.a+=')';return a.a};sfb(lLe,'AnyTypeImpl',844);feb(681,516,{110:1,94:1,93:1,58:1,54:1,99:1,2119:1,681:1},yme);_.Lh=function zme(a,b,c){switch(a){case 0:return this.a;case 1:return this.b;}return zvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Wh=function Ame(a){switch(a){case 0:return this.a!=null;case 1:return this.b!=null;}return Avd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Bme(a,b){switch(a){case 0:wme(this,WD(b));return;case 1:xme(this,WD(b));return;}Bvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Cme(){return nme(),cme};_.ki=function Dme(a){switch(a){case 0:this.a=null;return;case 1:this.b=null;return;}Cvd(this,a-AYd((nme(),cme)),vYd((this.j&2)==0?cme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function Eme(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (data: ';Nhb(a,this.a);a.a+=', target: ';Nhb(a,this.b);a.a+=')';return a.a};_.a=null;_.b=null;sfb(lLe,'ProcessingInstructionImpl',681);feb(682,844,{110:1,94:1,93:1,58:1,54:1,99:1,857:1,2120:1,682:1},Hme);_.Lh=function Ime(a,b,c){switch(a){case 0:if(c)return !this.c&&(this.c=new Uge(this,0)),this.c;return !this.c&&(this.c=new Uge(this,0)),this.c.b;case 1:if(c)return !this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160);return (!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Vl();case 2:if(c)return !this.b&&(this.b=new Uge(this,2)),this.b;return !this.b&&(this.b=new Uge(this,2)),this.b.b;case 3:return !this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true));case 4:return Ije(this.a,(!this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))));case 5:return this.a;}return zvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Wh=function Jme(a){switch(a){case 0:return !!this.c&&this.c.i!=0;case 1:return !(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).dc();case 2:return !!this.b&&this.b.i!=0;case 3:return !this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))!=null;case 4:return Ije(this.a,(!this.c&&(this.c=new Uge(this,0)),WD(ige(this.c,(nme(),fme),true))))!=null;case 5:return !!this.a;}return Avd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Kme(a,b){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));Dge(this.c,b);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(RD(rge(this.c,(nme(),Sle)),160),220)).Wb(b);return;case 2:!this.b&&(this.b=new Uge(this,2));Dge(this.b,b);return;case 3:Gme(this,WD(b));return;case 4:Gme(this,Hje(this.a,b));return;case 5:Fme(this,RD(b,156));return;}Bvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Lme(){return nme(),eme};_.ki=function Mme(a){switch(a){case 0:!this.c&&(this.c=new Uge(this,0));sLd(this.c);return;case 1:(!this.c&&(this.c=new Uge(this,0)),RD(rge(this.c,(nme(),Sle)),160)).$b();return;case 2:!this.b&&(this.b=new Uge(this,2));sLd(this.b);return;case 3:!this.c&&(this.c=new Uge(this,0));Fge(this.c,(nme(),fme),null);return;case 4:Gme(this,Hje(this.a,null));return;case 5:this.a=null;return;}Cvd(this,a-AYd((nme(),eme)),vYd((this.j&2)==0?eme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};sfb(lLe,'SimpleAnyTypeImpl',682);feb(683,516,{110:1,94:1,93:1,58:1,54:1,99:1,2121:1,683:1},Nme);_.Lh=function Ome(a,b,c){switch(a){case 0:if(c)return !this.a&&(this.a=new Uge(this,0)),this.a;return !this.a&&(this.a=new Uge(this,0)),this.a.b;case 1:return c?(!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),this.b):(!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),dOd(this.b));case 2:return c?(!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),this.c):(!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),dOd(this.c));case 3:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),ime));case 4:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),jme));case 5:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),lme));case 6:return !this.a&&(this.a=new Uge(this,0)),rge(this.a,(nme(),mme));}return zvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b,c)};_.Uh=function Pme(a,b,c){var d;switch(b){case 0:return !this.a&&(this.a=new Uge(this,0)),_fe(this.a,a,c);case 1:return !this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1)),BVd(this.b,a,c);case 2:return !this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2)),BVd(this.c,a,c);case 5:return !this.a&&(this.a=new Uge(this,0)),Bke(rge(this.a,(nme(),lme)),a,c);}return d=RD(vYd((this.j&2)==0?(nme(),hme):(!this.k&&(this.k=new fUd),this.k).Nk(),b),69),d.wk().Ak(this,Yvd(this),b-AYd((nme(),hme)),a,c)};_.Wh=function Qme(a){switch(a){case 0:return !!this.a&&this.a.i!=0;case 1:return !!this.b&&this.b.f!=0;case 2:return !!this.c&&this.c.f!=0;case 3:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),ime)));case 4:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),jme)));case 5:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),lme)));case 6:return !this.a&&(this.a=new Uge(this,0)),!Dke(rge(this.a,(nme(),mme)));}return Avd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a))};_.bi=function Rme(a,b){switch(a){case 0:!this.a&&(this.a=new Uge(this,0));Dge(this.a,b);return;case 1:!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1));CVd(this.b,b);return;case 2:!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2));CVd(this.c,b);return;case 3:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),ime)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,ime),RD(b,16));return;case 4:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),jme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,jme),RD(b,16));return;case 5:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),lme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,lme),RD(b,16));return;case 6:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),mme)));!this.a&&(this.a=new Uge(this,0));Ake(rge(this.a,mme),RD(b,16));return;}Bvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a),b);};_.ii=function Sme(){return nme(),hme};_.ki=function Tme(a){switch(a){case 0:!this.a&&(this.a=new Uge(this,0));sLd(this.a);return;case 1:!this.b&&(this.b=new DVd((JTd(),FTd),C8,this,1));this.b.c.$b();return;case 2:!this.c&&(this.c=new DVd((JTd(),FTd),C8,this,2));this.c.c.$b();return;case 3:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),ime)));return;case 4:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),jme)));return;case 5:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),lme)));return;case 6:!this.a&&(this.a=new Uge(this,0));Cke(rge(this.a,(nme(),mme)));return;}Cvd(this,a-AYd((nme(),hme)),vYd((this.j&2)==0?hme:(!this.k&&(this.k=new fUd),this.k).Nk(),a));};_.Ib=function Ume(){var a;if((this.j&4)!=0)return awd(this);a=new Shb(awd(this));a.a+=' (mixed: ';Mhb(a,this.a);a.a+=')';return a.a};sfb(lLe,'XMLTypeDocumentRootImpl',683);feb(2028,720,{110:1,94:1,93:1,480:1,155:1,58:1,114:1,54:1,99:1,158:1,119:1,120:1,2122:1},rne);_.ri=function sne(a,b){switch(a.hk()){case 7:case 8:case 9:case 10:case 16:case 22:case 23:case 24:case 25:case 26:case 32:case 33:case 34:case 36:case 37:case 44:case 45:case 50:case 51:case 53:case 55:case 56:case 57:case 58:case 60:case 61:case 4:return b==null?null:jeb(b);case 19:case 28:case 29:case 35:case 38:case 39:case 41:case 46:case 52:case 54:case 5:return WD(b);case 6:return _me(RD(b,195));case 12:case 47:case 49:case 11:return tAd(this,a,b);case 13:return b==null?null:yib(RD(b,247));case 15:case 14:return b==null?null:ane(Kfb(UD(b)));case 17:return bne((nme(),b));case 18:return bne(b);case 21:case 20:return b==null?null:cne(RD(b,161).a);case 27:return dne(RD(b,195));case 30:return ene((nme(),RD(b,15)));case 31:return ene(RD(b,15));case 40:return hne((nme(),b));case 42:return fne((nme(),b));case 43:return fne(b);case 59:case 48:return gne((nme(),b));default:throw Adb(new agb(VHe+a.xe()+WHe));}};_.si=function tne(a){var b,c,d,e,f;switch(a.G==-1&&(a.G=(c=BXd(a),c?fZd(c.vi(),a):-1)),a.G){case 0:return b=new ome,b;case 1:return d=new yme,d;case 2:return e=new Hme,e;case 3:return f=new Nme,f;default:throw Adb(new agb(ZHe+a.zb+WHe));}};_.ti=function une(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;switch(a.hk()){case 5:case 52:case 4:return b;case 6:return ine(b);case 8:case 7:return b==null?null:$me(b);case 9:return b==null?null:$eb(Oeb((d=nue(b,true),d.length>0&&(BFb(0,d.length),d.charCodeAt(0)==43)?(BFb(1,d.length+1),d.substr(1)):d),-128,127)<<24>>24);case 10:return b==null?null:$eb(Oeb((e=nue(b,true),e.length>0&&(BFb(0,e.length),e.charCodeAt(0)==43)?(BFb(1,e.length+1),e.substr(1)):e),-128,127)<<24>>24);case 11:return WD(uAd(this,(nme(),Vle),b));case 12:return WD(uAd(this,(nme(),Wle),b));case 13:return b==null?null:new Bib(nue(b,true));case 15:case 14:return jne(b);case 16:return WD(uAd(this,(nme(),Xle),b));case 17:return kne((nme(),b));case 18:return kne(b);case 28:case 29:case 35:case 38:case 39:case 41:case 54:case 19:return nue(b,true);case 21:case 20:return lne(b);case 22:return WD(uAd(this,(nme(),Yle),b));case 23:return WD(uAd(this,(nme(),Zle),b));case 24:return WD(uAd(this,(nme(),$le),b));case 25:return WD(uAd(this,(nme(),_le),b));case 26:return WD(uAd(this,(nme(),ame),b));case 27:return mne(b);case 30:return nne((nme(),b));case 31:return nne(b);case 32:return b==null?null:sgb(Oeb((k=nue(b,true),k.length>0&&(BFb(0,k.length),k.charCodeAt(0)==43)?(BFb(1,k.length+1),k.substr(1)):k),qwe,lve));case 33:return b==null?null:new ejb((l=nue(b,true),l.length>0&&(BFb(0,l.length),l.charCodeAt(0)==43)?(BFb(1,l.length+1),l.substr(1)):l));case 34:return b==null?null:sgb(Oeb((m=nue(b,true),m.length>0&&(BFb(0,m.length),m.charCodeAt(0)==43)?(BFb(1,m.length+1),m.substr(1)):m),qwe,lve));case 36:return b==null?null:Hgb(Peb((n=nue(b,true),n.length>0&&(BFb(0,n.length),n.charCodeAt(0)==43)?(BFb(1,n.length+1),n.substr(1)):n)));case 37:return b==null?null:Hgb(Peb((o=nue(b,true),o.length>0&&(BFb(0,o.length),o.charCodeAt(0)==43)?(BFb(1,o.length+1),o.substr(1)):o)));case 40:return qne((nme(),b));case 42:return one((nme(),b));case 43:return one(b);case 44:return b==null?null:new ejb((p=nue(b,true),p.length>0&&(BFb(0,p.length),p.charCodeAt(0)==43)?(BFb(1,p.length+1),p.substr(1)):p));case 45:return b==null?null:new ejb((q=nue(b,true),q.length>0&&(BFb(0,q.length),q.charCodeAt(0)==43)?(BFb(1,q.length+1),q.substr(1)):q));case 46:return nue(b,false);case 47:return WD(uAd(this,(nme(),bme),b));case 59:case 48:return pne((nme(),b));case 49:return WD(uAd(this,(nme(),dme),b));case 50:return b==null?null:bhb(Oeb((r=nue(b,true),r.length>0&&(BFb(0,r.length),r.charCodeAt(0)==43)?(BFb(1,r.length+1),r.substr(1)):r),BKe,32767)<<16>>16);case 51:return b==null?null:bhb(Oeb((f=nue(b,true),f.length>0&&(BFb(0,f.length),f.charCodeAt(0)==43)?(BFb(1,f.length+1),f.substr(1)):f),BKe,32767)<<16>>16);case 53:return WD(uAd(this,(nme(),gme),b));case 55:return b==null?null:bhb(Oeb((g=nue(b,true),g.length>0&&(BFb(0,g.length),g.charCodeAt(0)==43)?(BFb(1,g.length+1),g.substr(1)):g),BKe,32767)<<16>>16);case 56:return b==null?null:bhb(Oeb((h=nue(b,true),h.length>0&&(BFb(0,h.length),h.charCodeAt(0)==43)?(BFb(1,h.length+1),h.substr(1)):h),BKe,32767)<<16>>16);case 57:return b==null?null:Hgb(Peb((i=nue(b,true),i.length>0&&(BFb(0,i.length),i.charCodeAt(0)==43)?(BFb(1,i.length+1),i.substr(1)):i)));case 58:return b==null?null:Hgb(Peb((j=nue(b,true),j.length>0&&(BFb(0,j.length),j.charCodeAt(0)==43)?(BFb(1,j.length+1),j.substr(1)):j)));case 60:return b==null?null:sgb(Oeb((c=nue(b,true),c.length>0&&(BFb(0,c.length),c.charCodeAt(0)==43)?(BFb(1,c.length+1),c.substr(1)):c),qwe,lve));case 61:return b==null?null:sgb(Oeb(nue(b,true),qwe,lve));default:throw Adb(new agb(VHe+a.xe()+WHe));}};var Vme,Wme,Xme,Yme;sfb(lLe,'XMLTypeFactoryImpl',2028);feb(594,184,{110:1,94:1,93:1,155:1,197:1,58:1,241:1,114:1,54:1,99:1,158:1,184:1,119:1,120:1,690:1,2044:1,594:1},Bne);_.N=false;_.O=false;var wne=false;sfb(lLe,'XMLTypePackageImpl',594);feb(1961,1,{851:1},Ene);_.Kk=function Fne(){return rue(),que};sfb(lLe,'XMLTypePackageImpl/1',1961);feb(1970,1,OKe,Gne);_.fk=function Hne(a){return bE(a)};_.gk=function Ine(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/10',1970);feb(1971,1,OKe,Jne);_.fk=function Kne(a){return bE(a)};_.gk=function Lne(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/11',1971);feb(1972,1,OKe,Mne);_.fk=function Nne(a){return bE(a)};_.gk=function One(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/12',1972);feb(1973,1,OKe,Pne);_.fk=function Qne(a){return _D(a)};_.gk=function Rne(a){return $C(VI,Nve,345,a,7,1)};sfb(lLe,'XMLTypePackageImpl/13',1973);feb(1974,1,OKe,Sne);_.fk=function Tne(a){return bE(a)};_.gk=function Une(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/14',1974);feb(1975,1,OKe,Vne);_.fk=function Wne(a){return ZD(a,15)};_.gk=function Xne(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/15',1975);feb(1976,1,OKe,Yne);_.fk=function Zne(a){return ZD(a,15)};_.gk=function $ne(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/16',1976);feb(1977,1,OKe,_ne);_.fk=function aoe(a){return bE(a)};_.gk=function boe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/17',1977);feb(1978,1,OKe,coe);_.fk=function doe(a){return ZD(a,161)};_.gk=function eoe(a){return $C(ZI,Nve,161,a,0,1)};sfb(lLe,'XMLTypePackageImpl/18',1978);feb(1979,1,OKe,foe);_.fk=function goe(a){return bE(a)};_.gk=function hoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/19',1979);feb(1962,1,OKe,ioe);_.fk=function joe(a){return ZD(a,857)};_.gk=function koe(a){return $C(Vbb,rve,857,a,0,1)};sfb(lLe,'XMLTypePackageImpl/2',1962);feb(1980,1,OKe,loe);_.fk=function moe(a){return bE(a)};_.gk=function noe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/20',1980);feb(1981,1,OKe,ooe);_.fk=function poe(a){return bE(a)};_.gk=function qoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/21',1981);feb(1982,1,OKe,roe);_.fk=function soe(a){return bE(a)};_.gk=function toe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/22',1982);feb(1983,1,OKe,uoe);_.fk=function voe(a){return bE(a)};_.gk=function woe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/23',1983);feb(1984,1,OKe,xoe);_.fk=function yoe(a){return ZD(a,195)};_.gk=function zoe(a){return $C(gE,Nve,195,a,0,2)};sfb(lLe,'XMLTypePackageImpl/24',1984);feb(1985,1,OKe,Aoe);_.fk=function Boe(a){return bE(a)};_.gk=function Coe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/25',1985);feb(1986,1,OKe,Doe);_.fk=function Eoe(a){return bE(a)};_.gk=function Foe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/26',1986);feb(1987,1,OKe,Goe);_.fk=function Hoe(a){return ZD(a,15)};_.gk=function Ioe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/27',1987);feb(1988,1,OKe,Joe);_.fk=function Koe(a){return ZD(a,15)};_.gk=function Loe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/28',1988);feb(1989,1,OKe,Moe);_.fk=function Noe(a){return bE(a)};_.gk=function Ooe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/29',1989);feb(1963,1,OKe,Poe);_.fk=function Qoe(a){return ZD(a,681)};_.gk=function Roe(a){return $C(Xbb,rve,2119,a,0,1)};sfb(lLe,'XMLTypePackageImpl/3',1963);feb(1990,1,OKe,Soe);_.fk=function Toe(a){return ZD(a,17)};_.gk=function Uoe(a){return $C(bJ,Nve,17,a,0,1)};sfb(lLe,'XMLTypePackageImpl/30',1990);feb(1991,1,OKe,Voe);_.fk=function Woe(a){return bE(a)};_.gk=function Xoe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/31',1991);feb(1992,1,OKe,Yoe);_.fk=function Zoe(a){return ZD(a,168)};_.gk=function $oe(a){return $C(eJ,Nve,168,a,0,1)};sfb(lLe,'XMLTypePackageImpl/32',1992);feb(1993,1,OKe,_oe);_.fk=function ape(a){return bE(a)};_.gk=function bpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/33',1993);feb(1994,1,OKe,cpe);_.fk=function dpe(a){return bE(a)};_.gk=function epe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/34',1994);feb(1995,1,OKe,fpe);_.fk=function gpe(a){return bE(a)};_.gk=function hpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/35',1995);feb(1996,1,OKe,ipe);_.fk=function jpe(a){return bE(a)};_.gk=function kpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/36',1996);feb(1997,1,OKe,lpe);_.fk=function mpe(a){return ZD(a,15)};_.gk=function npe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/37',1997);feb(1998,1,OKe,ope);_.fk=function ppe(a){return ZD(a,15)};_.gk=function qpe(a){return $C(QK,Ize,15,a,0,1)};sfb(lLe,'XMLTypePackageImpl/38',1998);feb(1999,1,OKe,rpe);_.fk=function spe(a){return bE(a)};_.gk=function tpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/39',1999);feb(1964,1,OKe,upe);_.fk=function vpe(a){return ZD(a,682)};_.gk=function wpe(a){return $C(Ybb,rve,2120,a,0,1)};sfb(lLe,'XMLTypePackageImpl/4',1964);feb(2000,1,OKe,xpe);_.fk=function ype(a){return bE(a)};_.gk=function zpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/40',2000);feb(2001,1,OKe,Ape);_.fk=function Bpe(a){return bE(a)};_.gk=function Cpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/41',2001);feb(2002,1,OKe,Dpe);_.fk=function Epe(a){return bE(a)};_.gk=function Fpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/42',2002);feb(2003,1,OKe,Gpe);_.fk=function Hpe(a){return bE(a)};_.gk=function Ipe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/43',2003);feb(2004,1,OKe,Jpe);_.fk=function Kpe(a){return bE(a)};_.gk=function Lpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/44',2004);feb(2005,1,OKe,Mpe);_.fk=function Npe(a){return ZD(a,191)};_.gk=function Ope(a){return $C(lJ,Nve,191,a,0,1)};sfb(lLe,'XMLTypePackageImpl/45',2005);feb(2006,1,OKe,Ppe);_.fk=function Qpe(a){return bE(a)};_.gk=function Rpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/46',2006);feb(2007,1,OKe,Spe);_.fk=function Tpe(a){return bE(a)};_.gk=function Upe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/47',2007);feb(2008,1,OKe,Vpe);_.fk=function Wpe(a){return bE(a)};_.gk=function Xpe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/48',2008);feb(2009,1,OKe,Ype);_.fk=function Zpe(a){return ZD(a,191)};_.gk=function $pe(a){return $C(lJ,Nve,191,a,0,1)};sfb(lLe,'XMLTypePackageImpl/49',2009);feb(1965,1,OKe,_pe);_.fk=function aqe(a){return ZD(a,683)};_.gk=function bqe(a){return $C(Zbb,rve,2121,a,0,1)};sfb(lLe,'XMLTypePackageImpl/5',1965);feb(2010,1,OKe,cqe);_.fk=function dqe(a){return ZD(a,168)};_.gk=function eqe(a){return $C(eJ,Nve,168,a,0,1)};sfb(lLe,'XMLTypePackageImpl/50',2010);feb(2011,1,OKe,fqe);_.fk=function gqe(a){return bE(a)};_.gk=function hqe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/51',2011);feb(2012,1,OKe,iqe);_.fk=function jqe(a){return ZD(a,17)};_.gk=function kqe(a){return $C(bJ,Nve,17,a,0,1)};sfb(lLe,'XMLTypePackageImpl/52',2012);feb(1966,1,OKe,lqe);_.fk=function mqe(a){return bE(a)};_.gk=function nqe(a){return $C(qJ,Nve,2,a,6,1)};sfb(lLe,'XMLTypePackageImpl/6',1966);feb(1967,1,OKe,oqe);_.fk=function pqe(a){return ZD(a,195)};_.gk=function qqe(a){return $C(gE,Nve,195,a,0,2)};sfb(lLe,'XMLTypePackageImpl/7',1967);feb(1968,1,OKe,rqe);_.fk=function sqe(a){return $D(a)};_.gk=function tqe(a){return $C(QI,Nve,485,a,8,1)};sfb(lLe,'XMLTypePackageImpl/8',1968);feb(1969,1,OKe,uqe);_.fk=function vqe(a){return ZD(a,222)};_.gk=function wqe(a){return $C(RI,Nve,222,a,0,1)};sfb(lLe,'XMLTypePackageImpl/9',1969);var xqe,yqe;var Eqe,Fqe;var Jqe;feb(55,63,swe,Lqe);sfb(LLe,'RegEx/ParseException',55);feb(836,1,{},Tqe);_.bm=function Uqe(a){return ac*16)throw Adb(new Lqe(TId((Hde(),tJe))));c=c*16+e;}while(true);if(this.a!=125)throw Adb(new Lqe(TId((Hde(),uJe))));if(c>MLe)throw Adb(new Lqe(TId((Hde(),vJe))));a=c;}else {e=0;if(this.c!=0||(e=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));c=e;Mqe(this);if(this.c!=0||(e=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));c=c*16+e;a=c;}break;case 117:d=0;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;a=b;break;case 118:Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;Mqe(this);if(this.c!=0||(d=Xqe(this.a))<0)throw Adb(new Lqe(TId((Hde(),sJe))));b=b*16+d;if(b>MLe)throw Adb(new Lqe(TId((Hde(),'parser.descappe.4'))));a=b;break;case 65:case 90:case 122:throw Adb(new Lqe(TId((Hde(),wJe))));}return a};_.dm=function Wqe(a){var b,c;switch(a){case 100:c=(this.e&32)==32?hte('Nd',true):(Vse(),Bse);break;case 68:c=(this.e&32)==32?hte('Nd',false):(Vse(),Ise);break;case 119:c=(this.e&32)==32?hte('IsWord',true):(Vse(),Rse);break;case 87:c=(this.e&32)==32?hte('IsWord',false):(Vse(),Kse);break;case 115:c=(this.e&32)==32?hte('IsSpace',true):(Vse(),Mse);break;case 83:c=(this.e&32)==32?hte('IsSpace',false):(Vse(),Jse);break;default:throw Adb(new yz((b=a,NLe+b.toString(16))));}return c};_.em=function Yqe(a){var b,c,d,e,f,g,h,i,j,k,l,m;this.b=1;Mqe(this);b=null;if(this.c==0&&this.a==94){Mqe(this);if(a){k=(Vse(),Vse(),new xte(5));}else {b=(Vse(),Vse(),new xte(4));rte(b,0,MLe);k=(new xte(4));}}else {k=(Vse(),Vse(),new xte(4));}e=true;while((m=this.c)!=1){if(m==0&&this.a==93&&!e)break;e=false;c=this.a;d=false;if(m==10){switch(c){case 100:case 68:case 119:case 87:case 115:case 83:ute(k,this.dm(c));d=true;break;case 105:case 73:case 99:case 67:c=this.um(k,c);c<0&&(d=true);break;case 112:case 80:l=Sqe(this,c);if(!l)throw Adb(new Lqe(TId((Hde(),hJe))));ute(k,l);d=true;break;default:c=this.cm();}}else if(m==20){g=phb(this.i,58,this.d);if(g<0)throw Adb(new Lqe(TId((Hde(),iJe))));h=true;if(ihb(this.i,this.d)==94){++this.d;h=false;}f=zhb(this.i,this.d,g);i=ite(f,h,(this.e&512)==512);if(!i)throw Adb(new Lqe(TId((Hde(),kJe))));ute(k,i);d=true;if(g+1>=this.j||ihb(this.i,g+1)!=93)throw Adb(new Lqe(TId((Hde(),iJe))));this.d=g+2;}Mqe(this);if(!d){if(this.c!=0||this.a!=45){rte(k,c,c);}else {Mqe(this);if((m=this.c)==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(m==0&&this.a==93){rte(k,c,c);rte(k,45,45);}else {j=this.a;m==10&&(j=this.cm());Mqe(this);rte(k,c,j);}}}(this.e&gwe)==gwe&&this.c==0&&this.a==44&&Mqe(this);}if(this.c==1)throw Adb(new Lqe(TId((Hde(),jJe))));if(b){wte(b,k);k=b;}vte(k);ste(k);this.b=0;Mqe(this);return k};_.fm=function Zqe(){var a,b,c,d;c=this.em(false);while((d=this.c)!=7){a=this.a;if(d==0&&(a==45||a==38)||d==4){Mqe(this);if(this.c!=9)throw Adb(new Lqe(TId((Hde(),pJe))));b=this.em(false);if(d==4)ute(c,b);else if(a==45)wte(c,b);else if(a==38)tte(c,b);else throw Adb(new yz('ASSERT'))}else {throw Adb(new Lqe(TId((Hde(),qJe))))}}Mqe(this);return c};_.gm=function $qe(){var a,b;a=this.a-48;b=(Vse(),Vse(),new eue(12,null,a));!this.g&&(this.g=new gyb);dyb(this.g,new Bte(a));Mqe(this);return b};_.hm=function _qe(){Mqe(this);return Vse(),Nse};_.im=function are(){Mqe(this);return Vse(),Lse};_.jm=function bre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.km=function cre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.lm=function dre(){Mqe(this);return fte()};_.mm=function ere(){Mqe(this);return Vse(),Pse};_.nm=function fre(){Mqe(this);return Vse(),Sse};_.om=function gre(){var a;if(this.d>=this.j||((a=ihb(this.i,this.d++))&65504)!=64)throw Adb(new Lqe(TId((Hde(),dJe))));Mqe(this);return Vse(),Vse(),new Hte(0,a-64)};_.pm=function hre(){Mqe(this);return gte()};_.qm=function ire(){Mqe(this);return Vse(),Tse};_.rm=function jre(){var a;a=(Vse(),Vse(),new Hte(0,105));Mqe(this);return a};_.sm=function kre(){Mqe(this);return Vse(),Qse};_.tm=function lre(){Mqe(this);return Vse(),Ose};_.um=function mre(a,b){return this.cm()};_.vm=function nre(){Mqe(this);return Vse(),Gse};_.wm=function ore(){var a,b,c,d,e;if(this.d+1>=this.j)throw Adb(new Lqe(TId((Hde(),aJe))));d=-1;b=null;a=ihb(this.i,this.d);if(49<=a&&a<=57){d=a-48;!this.g&&(this.g=new gyb);dyb(this.g,new Bte(d));++this.d;if(ihb(this.i,this.d)!=41)throw Adb(new Lqe(TId((Hde(),ZIe))));++this.d;}else {a==63&&--this.d;Mqe(this);b=Pqe(this);switch(b.e){case 20:case 21:case 22:case 23:break;case 8:if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));break;default:throw Adb(new Lqe(TId((Hde(),bJe))));}}Mqe(this);e=Qqe(this);c=null;if(e.e==2){if(e.Pm()!=2)throw Adb(new Lqe(TId((Hde(),cJe))));c=e.Lm(1);e=e.Lm(0);}if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return Vse(),Vse(),new Ute(d,b,e,c)};_.xm=function pre(){Mqe(this);return Vse(),Hse};_.ym=function qre(){var a;Mqe(this);a=_se(24,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.zm=function rre(){var a;Mqe(this);a=_se(20,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Am=function sre(){var a;Mqe(this);a=_se(22,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Bm=function tre(){var a,b,c,d,e;a=0;c=0;b=-1;while(this.d=this.j)throw Adb(new Lqe(TId((Hde(),$Ie))));if(b==45){++this.d;while(this.d=this.j)throw Adb(new Lqe(TId((Hde(),$Ie))))}if(b==58){++this.d;Mqe(this);d=ate(Qqe(this),a,c);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);}else if(b==41){++this.d;Mqe(this);d=ate(Qqe(this),a,c);}else throw Adb(new Lqe(TId((Hde(),_Ie))));return d};_.Cm=function ure(){var a;Mqe(this);a=_se(21,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Dm=function vre(){var a;Mqe(this);a=_se(23,Qqe(this));if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Em=function wre(){var a,b;Mqe(this);a=this.f++;b=bte(Qqe(this),a);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return b};_.Fm=function xre(){var a;Mqe(this);a=bte(Qqe(this),0);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Gm=function yre(a){Mqe(this);if(this.c==5){Mqe(this);return $se(a,(Vse(),Vse(),new Kte(9,a)))}else return $se(a,(Vse(),Vse(),new Kte(3,a)))};_.Hm=function zre(a){var b;Mqe(this);b=(Vse(),Vse(),new iue(2));if(this.c==5){Mqe(this);hue(b,(Ese));hue(b,a);}else {hue(b,a);hue(b,(Ese));}return b};_.Im=function Are(a){Mqe(this);if(this.c==5){Mqe(this);return Vse(),Vse(),new Kte(9,a)}else return Vse(),Vse(),new Kte(3,a)};_.a=0;_.b=0;_.c=0;_.d=0;_.e=0;_.f=1;_.g=null;_.j=0;sfb(LLe,'RegEx/RegexParser',836);feb(1947,836,{},Gre);_.bm=function Hre(a){return false};_.cm=function Ire(){return Dre(this)};_.dm=function Kre(a){return Ere(a)};_.em=function Lre(a){return Fre(this)};_.fm=function Mre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.gm=function Nre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.hm=function Ore(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.im=function Pre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.jm=function Qre(){Mqe(this);return Ere(67)};_.km=function Rre(){Mqe(this);return Ere(73)};_.lm=function Sre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.mm=function Tre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.nm=function Ure(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.om=function Vre(){Mqe(this);return Ere(99)};_.pm=function Wre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.qm=function Xre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.rm=function Yre(){Mqe(this);return Ere(105)};_.sm=function Zre(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.tm=function $re(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.um=function _re(a,b){return ute(a,Ere(b)),-1};_.vm=function ase(){Mqe(this);return Vse(),Vse(),new Hte(0,94)};_.wm=function bse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.xm=function cse(){Mqe(this);return Vse(),Vse(),new Hte(0,36)};_.ym=function dse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.zm=function ese(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Am=function fse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Bm=function gse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Cm=function hse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Dm=function ise(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Em=function jse(){var a;Mqe(this);a=bte(Qqe(this),0);if(this.c!=7)throw Adb(new Lqe(TId((Hde(),ZIe))));Mqe(this);return a};_.Fm=function kse(){throw Adb(new Lqe(TId((Hde(),xJe))))};_.Gm=function lse(a){Mqe(this);return $se(a,(Vse(),Vse(),new Kte(3,a)))};_.Hm=function mse(a){var b;Mqe(this);b=(Vse(),Vse(),new iue(2));hue(b,a);hue(b,(Ese));return b};_.Im=function nse(a){Mqe(this);return Vse(),Vse(),new Kte(3,a)};var Bre=null,Cre=null;sfb(LLe,'RegEx/ParserForXMLSchema',1947);feb(122,1,ZLe,Wse);_.Jm=function Xse(a){throw Adb(new yz('Not supported.'))};_.Km=function dte(){return -1};_.Lm=function ete(a){return null};_.Mm=function jte(){return null};_.Nm=function mte(a){};_.Om=function nte(a){};_.Pm=function ote(){return 0};_.Ib=function pte(){return this.Qm(0)};_.Qm=function qte(a){return this.e==11?'.':''};_.e=0;var vse,wse,xse,yse,zse,Ase=null,Bse,Cse=null,Dse,Ese,Fse=null,Gse,Hse,Ise,Jse,Kse,Lse,Mse,Nse,Ose,Pse,Qse,Rse,Sse,Tse;var qdb=sfb(LLe,'RegEx/Token',122);feb(138,122,{3:1,138:1,122:1},xte);_.Qm=function Ate(a){var b,c,d;if(this.e==4){if(this==Dse)c='.';else if(this==Bse)c='\\d';else if(this==Rse)c='\\w';else if(this==Mse)c='\\s';else {d=new Qhb;d.a+='[';for(b=0;b0&&(d.a+=',',d);if(this.b[b]===this.b[b+1]){Nhb(d,zte(this.b[b]));}else {Nhb(d,zte(this.b[b]));d.a+='-';Nhb(d,zte(this.b[b+1]));}}d.a+=']';c=d.a;}}else {if(this==Ise)c='\\D';else if(this==Kse)c='\\W';else if(this==Jse)c='\\S';else {d=new Qhb;d.a+='[^';for(b=0;b0&&(d.a+=',',d);if(this.b[b]===this.b[b+1]){Nhb(d,zte(this.b[b]));}else {Nhb(d,zte(this.b[b]));d.a+='-';Nhb(d,zte(this.b[b+1]));}}d.a+=']';c=d.a;}}return c};_.a=false;_.c=false;sfb(LLe,'RegEx/RangeToken',138);feb(592,1,{592:1},Bte);_.a=0;sfb(LLe,'RegEx/RegexParser/ReferencePosition',592);feb(591,1,{3:1,591:1},Dte);_.Fb=function Ete(a){var b;if(a==null)return false;if(!ZD(a,591))return false;b=RD(a,591);return lhb(this.b,b.b)&&this.a==b.a};_.Hb=function Fte(){return ohb(this.b+'/'+pse(this.a))};_.Ib=function Gte(){return this.c.Qm(this.a)};_.a=0;sfb(LLe,'RegEx/RegularExpression',591);feb(228,122,ZLe,Hte);_.Km=function Ite(){return this.a};_.Qm=function Jte(a){var b,c,d;switch(this.e){case 0:switch(this.a){case 124:case 42:case 43:case 63:case 40:case 41:case 46:case 91:case 123:case 92:d='\\'+XD(this.a&Bwe);break;case 12:d='\\f';break;case 10:d='\\n';break;case 13:d='\\r';break;case 9:d='\\t';break;case 27:d='\\e';break;default:if(this.a>=txe){c=(b=this.a>>>0,'0'+b.toString(16));d='\\v'+zhb(c,c.length-6,c.length);}else d=''+XD(this.a&Bwe);}break;case 8:this==Gse||this==Hse?(d=''+XD(this.a&Bwe)):(d='\\'+XD(this.a&Bwe));break;default:d=null;}return d};_.a=0;sfb(LLe,'RegEx/Token/CharToken',228);feb(318,122,ZLe,Kte);_.Lm=function Lte(a){return this.a};_.Nm=function Mte(a){this.b=a;};_.Om=function Nte(a){this.c=a;};_.Pm=function Ote(){return 1};_.Qm=function Pte(a){var b;if(this.e==3){if(this.c<0&&this.b<0){b=this.a.Qm(a)+'*';}else if(this.c==this.b){b=this.a.Qm(a)+'{'+this.c+'}';}else if(this.c>=0&&this.b>=0){b=this.a.Qm(a)+'{'+this.c+','+this.b+'}';}else if(this.c>=0&&this.b<0){b=this.a.Qm(a)+'{'+this.c+',}';}else throw Adb(new yz('Token#toString(): CLOSURE '+this.c+pve+this.b))}else {if(this.c<0&&this.b<0){b=this.a.Qm(a)+'*?';}else if(this.c==this.b){b=this.a.Qm(a)+'{'+this.c+'}?';}else if(this.c>=0&&this.b>=0){b=this.a.Qm(a)+'{'+this.c+','+this.b+'}?';}else if(this.c>=0&&this.b<0){b=this.a.Qm(a)+'{'+this.c+',}?';}else throw Adb(new yz('Token#toString(): NONGREEDYCLOSURE '+this.c+pve+this.b))}return b};_.b=0;_.c=0;sfb(LLe,'RegEx/Token/ClosureToken',318);feb(837,122,ZLe,Qte);_.Lm=function Rte(a){return a==0?this.a:this.b};_.Pm=function Ste(){return 2};_.Qm=function Tte(a){var b;this.b.e==3&&this.b.Lm(0)==this.a?(b=this.a.Qm(a)+'+'):this.b.e==9&&this.b.Lm(0)==this.a?(b=this.a.Qm(a)+'+?'):(b=this.a.Qm(a)+(''+this.b.Qm(a)));return b};sfb(LLe,'RegEx/Token/ConcatToken',837);feb(1945,122,ZLe,Ute);_.Lm=function Vte(a){if(a==0)return this.d;if(a==1)return this.b;throw Adb(new yz('Internal Error: '+a))};_.Pm=function Wte(){return !this.b?1:2};_.Qm=function Xte(a){var b;this.c>0?(b='(?('+this.c+')'):this.a.e==8?(b='(?('+this.a+')'):(b='(?'+this.a);!this.b?(b+=this.d+')'):(b+=this.d+'|'+this.b+')');return b};_.c=0;sfb(LLe,'RegEx/Token/ConditionToken',1945);feb(1946,122,ZLe,Yte);_.Lm=function Zte(a){return this.b};_.Pm=function $te(){return 1};_.Qm=function _te(a){return '(?'+(this.a==0?'':pse(this.a))+(this.c==0?'':pse(this.c))+':'+this.b.Qm(a)+')'};_.a=0;_.c=0;sfb(LLe,'RegEx/Token/ModifierToken',1946);feb(838,122,ZLe,aue);_.Lm=function bue(a){return this.a};_.Pm=function cue(){return 1};_.Qm=function due(a){var b;b=null;switch(this.e){case 6:this.b==0?(b='(?:'+this.a.Qm(a)+')'):(b='('+this.a.Qm(a)+')');break;case 20:b='(?='+this.a.Qm(a)+')';break;case 21:b='(?!'+this.a.Qm(a)+')';break;case 22:b='(?<='+this.a.Qm(a)+')';break;case 23:b='(?'+this.a.Qm(a)+')';}return b};_.b=0;sfb(LLe,'RegEx/Token/ParenToken',838);feb(530,122,{3:1,122:1,530:1},eue);_.Mm=function fue(){return this.b};_.Qm=function gue(a){return this.e==12?'\\'+this.a:tse(this.b)};_.a=0;sfb(LLe,'RegEx/Token/StringToken',530);feb(477,122,ZLe,iue);_.Jm=function jue(a){hue(this,a);};_.Lm=function kue(a){return RD(eyb(this.a,a),122)};_.Pm=function lue(){return !this.a?0:this.a.a.c.length};_.Qm=function mue(a){var b,c,d,e,f;if(this.e==1){if(this.a.a.c.length==2){b=RD(eyb(this.a,0),122);c=RD(eyb(this.a,1),122);c.e==3&&c.Lm(0)==b?(e=b.Qm(a)+'+'):c.e==9&&c.Lm(0)==b?(e=b.Qm(a)+'+?'):(e=b.Qm(a)+(''+c.Qm(a)));}else {f=new Qhb;for(d=0;d=this.c.b:this.a<=this.c.b};_.Sb=function Vue(){return this.b>0};_.Tb=function Xue(){return this.b};_.Vb=function Zue(){return this.b-1};_.Qb=function $ue(){throw Adb(new kib(dMe))};_.a=0;_.b=0;sfb(aMe,'ExclusiveRange/RangeIterator',258);var hE=vfb(eKe,'C');var kE=vfb(hKe,'I');var xdb=vfb(hve,'Z');var lE=vfb(iKe,'J');var gE=vfb(dKe,'B');var iE=vfb(fKe,'D');var jE=vfb(gKe,'F');var wdb=vfb(jKe,'S');var g3=ufb('org.eclipse.elk.core.labels','ILabelManager');var T6=ufb(sIe,'DiagnosticChain');var zab=ufb(QKe,'ResourceSet');var $6=sfb(sIe,'InvocationTargetException',null);var fve=(Qz(),Tz);var gwtOnLoad=gwtOnLoad=ceb;aeb(leb);deb('permProps',[[['locale','default'],[eMe,'gecko1_8']],[['locale','default'],[eMe,'safari']]]); + // -------------- RUN GWT INITIALIZATION CODE -------------- + gwtOnLoad(null, 'elk', null); + + }).call(this);}).call(this,typeof commonjsGlobal$1 !== "undefined" ? commonjsGlobal$1 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}); + },{}],3:[function(require,module,exports){ + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + /******************************************************************************* + * Copyright (c) 2021 Kiel University and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ + var ELK = require('./elk-api.js').default; + + var ELKNode = function (_ELK) { + _inherits(ELKNode, _ELK); + + function ELKNode() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, ELKNode); + + var optionsClone = Object.assign({}, options); + + var workerThreadsExist = false; + try { + require.resolve('web-worker'); + workerThreadsExist = true; + } catch (e) {} + + // user requested a worker + if (options.workerUrl) { + if (workerThreadsExist) { + var Worker = require('web-worker'); + optionsClone.workerFactory = function (url) { + return new Worker(url); + }; + } else { + console.warn('Web worker requested but \'web-worker\' package not installed. \nConsider installing the package or pass your own \'workerFactory\' to ELK\'s constructor.\n... Falling back to non-web worker version.'); + } + } + + // unless no other workerFactory is registered, use the fake worker + if (!optionsClone.workerFactory) { + var _require = require('./elk-worker.min.js'), + _Worker = _require.Worker; + + optionsClone.workerFactory = function (url) { + return new _Worker(url); + }; + } + + return _possibleConstructorReturn(this, (ELKNode.__proto__ || Object.getPrototypeOf(ELKNode)).call(this, optionsClone)); + } + + return ELKNode; + }(ELK); + + Object.defineProperty(module.exports, "__esModule", { + value: true + }); + module.exports = ELKNode; + ELKNode.default = ELKNode; + },{"./elk-api.js":1,"./elk-worker.min.js":2,"web-worker":4}],4:[function(require,module,exports){ + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + module.exports = Worker; + },{}]},{},[3])(3) + }); +} (elk_bundled)); + +var elk_bundledExports = elk_bundled.exports; +var ELK = /*@__PURE__*/getDefaultExportFromCjs(elk_bundledExports); + +const findCommonAncestor = (id1, id2, treeData) => { + const { parentById } = treeData; + const visited = /* @__PURE__ */ new Set(); + let currentId = id1; + while (currentId) { + visited.add(currentId); + if (currentId === id2) { + return currentId; + } + currentId = parentById[currentId]; + } + currentId = id2; + while (currentId) { + if (visited.has(currentId)) { + return currentId; + } + currentId = parentById[currentId]; + } + return "root"; +}; +const elk = new ELK(); +let portPos = {}; +const conf = {}; +let nodeDb = {}; +const addVertices = async function(vert, svgId, root, doc, diagObj, parentLookupDb, graph) { + const svg = root.select(`[id="${svgId}"]`); + const nodes = svg.insert("g").attr("class", "nodes"); + const keys = Object.keys(vert); + await Promise.all( + keys.map(async function(id) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + classStr = classStr + " flowchart-label"; + const styles2 = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + const labelData = { width: 0, height: 0 }; + const ports = [ + { + id: vertex.id + "-west", + layoutOptions: { + "port.side": "WEST" + } + }, + { + id: vertex.id + "-east", + layoutOptions: { + "port.side": "EAST" + } + }, + { + id: vertex.id + "-south", + layoutOptions: { + "port.side": "SOUTH" + } + }, + { + id: vertex.id + "-north", + layoutOptions: { + "port.side": "NORTH" + } + } + ]; + let radius = 0; + let _shape = ""; + let layoutOptions = {}; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + layoutOptions = { + portConstraints: "FIXED_SIDE" + }; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + case "doublecircle": + _shape = "doublecircle"; + break; + default: + _shape = "rect"; + } + const node = { + labelStyle: styles2.labelStyle, + shape: _shape, + labelText: vertexText, + labelType: vertex.labelType, + rx: radius, + ry: radius, + class: classStr, + style: styles2.style, + id: vertex.id, + link: vertex.link, + linkTarget: vertex.linkTarget, + tooltip: diagObj.db.getTooltip(vertex.id) || "", + domId: diagObj.db.lookUpDomId(vertex.id), + haveCallback: vertex.haveCallback, + width: vertex.type === "group" ? 500 : void 0, + dir: vertex.dir, + type: vertex.type, + props: vertex.props, + padding: getConfig$1().flowchart.padding + }; + let boundingBox; + let nodeEl; + if (node.type !== "group") { + nodeEl = await insertNode(nodes, node, vertex.dir); + boundingBox = nodeEl.node().getBBox(); + } else { + doc.createElementNS("http://www.w3.org/2000/svg", "text"); + const { shapeSvg, bbox } = await labelHelper(nodes, node, void 0, true); + labelData.width = bbox.width; + labelData.wrappingWidth = getConfig$1().flowchart.wrappingWidth; + labelData.height = bbox.height; + labelData.labelNode = shapeSvg.node(); + node.labelData = labelData; + } + const data = { + id: vertex.id, + ports: vertex.type === "diamond" ? ports : [], + // labelStyle: styles.labelStyle, + // shape: _shape, + layoutOptions, + labelText: vertexText, + labelData, + // labels: [{ text: vertexText }], + // rx: radius, + // ry: radius, + // class: classStr, + // style: styles.style, + // link: vertex.link, + // linkTarget: vertex.linkTarget, + // tooltip: diagObj.db.getTooltip(vertex.id) || '', + domId: diagObj.db.lookUpDomId(vertex.id), + // haveCallback: vertex.haveCallback, + width: boundingBox == null ? void 0 : boundingBox.width, + height: boundingBox == null ? void 0 : boundingBox.height, + // dir: vertex.dir, + type: vertex.type, + // props: vertex.props, + // padding: getConfig().flowchart.padding, + // boundingBox, + el: nodeEl, + parent: parentLookupDb.parentById[vertex.id] + }; + nodeDb[node.id] = data; + }) + ); + return graph; +}; +const getNextPosition = (position, edgeDirection, graphDirection) => { + const portPos2 = { + TB: { + in: { + north: "north" + }, + out: { + south: "west", + west: "east", + east: "south" + } + }, + LR: { + in: { + west: "west" + }, + out: { + east: "south", + south: "north", + north: "east" + } + }, + RL: { + in: { + east: "east" + }, + out: { + west: "north", + north: "south", + south: "west" + } + }, + BT: { + in: { + south: "south" + }, + out: { + north: "east", + east: "west", + west: "north" + } + } + }; + portPos2.TD = portPos2.TB; + return portPos2[graphDirection][edgeDirection][position]; +}; +const getNextPort = (node, edgeDirection, graphDirection) => { + log$1.info("getNextPort", { node, edgeDirection, graphDirection }); + if (!portPos[node]) { + switch (graphDirection) { + case "TB": + case "TD": + portPos[node] = { + inPosition: "north", + outPosition: "south" + }; + break; + case "BT": + portPos[node] = { + inPosition: "south", + outPosition: "north" + }; + break; + case "RL": + portPos[node] = { + inPosition: "east", + outPosition: "west" + }; + break; + case "LR": + portPos[node] = { + inPosition: "west", + outPosition: "east" + }; + break; + } + } + const result = edgeDirection === "in" ? portPos[node].inPosition : portPos[node].outPosition; + if (edgeDirection === "in") { + portPos[node].inPosition = getNextPosition( + portPos[node].inPosition, + edgeDirection, + graphDirection + ); + } else { + portPos[node].outPosition = getNextPosition( + portPos[node].outPosition, + edgeDirection, + graphDirection + ); + } + return result; +}; +const getEdgeStartEndPoint = (edge, dir) => { + let source = edge.start; + let target = edge.end; + const sourceId = source; + const targetId = target; + const startNode = nodeDb[source]; + const endNode = nodeDb[target]; + if (!startNode || !endNode) { + return { source, target }; + } + if (startNode.type === "diamond") { + source = `${source}-${getNextPort(source, "out", dir)}`; + } + if (endNode.type === "diamond") { + target = `${target}-${getNextPort(target, "in", dir)}`; + } + return { source, target, sourceId, targetId }; +}; +const addEdges = function(edges, diagObj, graph, svg) { + log$1.info("abc78 edges = ", edges); + const labelsEl = svg.insert("g").attr("class", "edgeLabels"); + let linkIdCnt = {}; + let dir = diagObj.db.getDirection(); + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + edges.forEach(function(edge) { + const linkIdBase = "L-" + edge.start + "-" + edge.end; + if (linkIdCnt[linkIdBase] === void 0) { + linkIdCnt[linkIdBase] = 0; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } else { + linkIdCnt[linkIdBase]++; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } + let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase]; + log$1.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]); + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = { style: "", labelStyle: "" }; + edgeData.minlen = edge.length || 1; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + edgeData.arrowTypeStart = "arrow_open"; + edgeData.arrowTypeEnd = "arrow_open"; + switch (edge.type) { + case "double_arrow_cross": + edgeData.arrowTypeStart = "arrow_cross"; + case "arrow_cross": + edgeData.arrowTypeEnd = "arrow_cross"; + break; + case "double_arrow_point": + edgeData.arrowTypeStart = "arrow_point"; + case "arrow_point": + edgeData.arrowTypeEnd = "arrow_point"; + break; + case "double_arrow_circle": + edgeData.arrowTypeStart = "arrow_circle"; + case "arrow_circle": + edgeData.arrowTypeEnd = "arrow_circle"; + break; + } + let style = ""; + let labelStyle = ""; + switch (edge.stroke) { + case "normal": + style = "fill:none;"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + edgeData.thickness = "normal"; + edgeData.pattern = "solid"; + break; + case "dotted": + edgeData.thickness = "normal"; + edgeData.pattern = "dotted"; + edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + edgeData.thickness = "thick"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 3.5px;fill:none;"; + break; + } + if (edge.style !== void 0) { + const styles2 = getStylesFromArray(edge.style); + style = styles2.style; + labelStyle = styles2.labelStyle; + } + edgeData.style = edgeData.style += style; + edgeData.labelStyle = edgeData.labelStyle += labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + } + edgeData.labelType = edge.labelType; + edgeData.label = edge.text.replace(common$1.lineBreakRegex, "\n"); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + edgeData.id = linkId; + edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd; + const labelEl = insertEdgeLabel(labelsEl, edgeData); + const { source, target, sourceId, targetId } = getEdgeStartEndPoint(edge, dir); + log$1.debug("abc78 source and target", source, target); + graph.edges.push({ + id: "e" + edge.start + edge.end, + sources: [source], + targets: [target], + sourceId, + targetId, + labelEl, + labels: [ + { + width: edgeData.width, + height: edgeData.height, + orgWidth: edgeData.width, + orgHeight: edgeData.height, + text: edgeData.label, + layoutOptions: { + "edgeLabels.inline": "true", + "edgeLabels.placement": "CENTER" + } + } + ], + edgeData + }); + }); + return graph; +}; +const addMarkersToEdge = function(svgPath, edgeData, diagramType, arrowMarkerAbsolute, id) { + let url = ""; + if (arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + addEdgeMarkers(svgPath, edgeData, url, id, diagramType); +}; +const getClasses$2 = function(text, diagObj) { + log$1.info("Extracting classes"); + return diagObj.db.getClasses(); +}; +const addSubGraphs = function(db2) { + const parentLookupDb = { parentById: {}, childrenById: {} }; + const subgraphs = db2.getSubGraphs(); + log$1.info("Subgraphs - ", subgraphs); + subgraphs.forEach(function(subgraph) { + subgraph.nodes.forEach(function(node) { + parentLookupDb.parentById[node] = subgraph.id; + if (parentLookupDb.childrenById[subgraph.id] === void 0) { + parentLookupDb.childrenById[subgraph.id] = []; + } + parentLookupDb.childrenById[subgraph.id].push(node); + }); + }); + subgraphs.forEach(function(subgraph) { + ({ id: subgraph.id }); + if (parentLookupDb.parentById[subgraph.id] !== void 0) { + parentLookupDb.parentById[subgraph.id]; + } + }); + return parentLookupDb; +}; +const calcOffset = function(src, dest, parentLookupDb) { + const ancestor = findCommonAncestor(src, dest, parentLookupDb); + if (ancestor === void 0 || ancestor === "root") { + return { x: 0, y: 0 }; + } + const ancestorOffset = nodeDb[ancestor].offset; + return { x: ancestorOffset.posX, y: ancestorOffset.posY }; +}; +const insertEdge = function(edgesEl, edge, edgeData, diagObj, parentLookupDb, id) { + const offset = calcOffset(edge.sourceId, edge.targetId, parentLookupDb); + const src = edge.sections[0].startPoint; + const dest = edge.sections[0].endPoint; + const segments = edge.sections[0].bendPoints ? edge.sections[0].bendPoints : []; + const segPoints = segments.map((segment) => [segment.x + offset.x, segment.y + offset.y]); + const points = [ + [src.x + offset.x, src.y + offset.y], + ...segPoints, + [dest.x + offset.x, dest.y + offset.y] + ]; + const { x, y } = getLineFunctionsWithOffset(edge.edgeData); + const curve = line$1().x(x).y(y).curve(curveLinear); + const edgePath = edgesEl.insert("path").attr("d", curve(points)).attr("class", "path " + edgeData.classes).attr("fill", "none"); + const edgeG = edgesEl.insert("g").attr("class", "edgeLabel"); + const edgeWithLabel = select(edgeG.node().appendChild(edge.labelEl)); + const box = edgeWithLabel.node().firstChild.getBoundingClientRect(); + edgeWithLabel.attr("width", box.width); + edgeWithLabel.attr("height", box.height); + edgeG.attr( + "transform", + `translate(${edge.labels[0].x + offset.x}, ${edge.labels[0].y + offset.y})` + ); + addMarkersToEdge(edgePath, edgeData, diagObj.type, diagObj.arrowMarkerAbsolute, id); +}; +const insertChildren = (nodeArray, parentLookupDb) => { + nodeArray.forEach((node) => { + if (!node.children) { + node.children = []; + } + const childIds = parentLookupDb.childrenById[node.id]; + if (childIds) { + childIds.forEach((childId) => { + node.children.push(nodeDb[childId]); + }); + } + insertChildren(node.children, parentLookupDb); + }); +}; +const draw$4 = async function(text, id, _version, diagObj) { + var _a; + diagObj.db.clear(); + nodeDb = {}; + portPos = {}; + diagObj.db.setGen("gen-2"); + diagObj.parser.parse(text); + const renderEl = select("body").append("div").attr("style", "height:400px").attr("id", "cy"); + let graph = { + id: "root", + layoutOptions: { + "elk.hierarchyHandling": "INCLUDE_CHILDREN", + "org.eclipse.elk.padding": "[top=100, left=100, bottom=110, right=110]", + "elk.layered.spacing.edgeNodeBetweenLayers": "30", + // 'elk.layered.mergeEdges': 'true', + "elk.direction": "DOWN" + // 'elk.ports.sameLayerEdges': true, + // 'nodePlacement.strategy': 'SIMPLE', + }, + children: [], + edges: [] + }; + log$1.info("Drawing flowchart using v3 renderer", elk); + let dir = diagObj.db.getDirection(); + switch (dir) { + case "BT": + graph.layoutOptions["elk.direction"] = "UP"; + break; + case "TB": + graph.layoutOptions["elk.direction"] = "DOWN"; + break; + case "LR": + graph.layoutOptions["elk.direction"] = "RIGHT"; + break; + case "RL": + graph.layoutOptions["elk.direction"] = "LEFT"; + break; + } + const { securityLevel, flowchart: conf2 } = getConfig$1(); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const svg = root.select(`[id="${id}"]`); + const markers = ["point", "circle", "cross"]; + insertMarkers$1$1(svg, markers, diagObj.type, id); + const vert = diagObj.db.getVertices(); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + log$1.info("Subgraphs - ", subGraphs); + for (let i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + diagObj.db.addVertex( + subG.id, + { text: subG.title, type: subG.labelType }, + "group", + void 0, + subG.classes, + subG.dir + ); + } + const subGraphsEl = svg.insert("g").attr("class", "subgraphs"); + const parentLookupDb = addSubGraphs(diagObj.db); + graph = await addVertices(vert, id, root, doc, diagObj, parentLookupDb, graph); + const edgesEl = svg.insert("g").attr("class", "edges edgePath"); + const edges = diagObj.db.getEdges(); + graph = addEdges(edges, diagObj, graph, svg); + const nodes = Object.keys(nodeDb); + nodes.forEach((nodeId) => { + const node = nodeDb[nodeId]; + if (!node.parent) { + graph.children.push(node); + } + if (parentLookupDb.childrenById[nodeId] !== void 0) { + node.labels = [ + { + text: node.labelText, + layoutOptions: { + "nodeLabels.placement": "[H_CENTER, V_TOP, INSIDE]" + }, + width: node.labelData.width, + height: node.labelData.height + // width: 100, + // height: 100, + } + ]; + delete node.x; + delete node.y; + delete node.width; + delete node.height; + } + }); + insertChildren(graph.children, parentLookupDb); + log$1.info("after layout", JSON.stringify(graph, null, 2)); + const g = await elk.layout(graph); + drawNodes$1(0, 0, g.children, svg, subGraphsEl, diagObj, 0); + log$1.info("after layout", g); + (_a = g.edges) == null ? void 0 : _a.map((edge) => { + insertEdge(edgesEl, edge, edge.edgeData, diagObj, parentLookupDb, id); + }); + setupGraphViewbox$1({}, svg, conf2.diagramPadding, conf2.useMaxWidth); + renderEl.remove(); +}; +const drawNodes$1 = (relX, relY, nodeArray, svg, subgraphsEl, diagObj, depth) => { + nodeArray.forEach(function(node) { + if (node) { + nodeDb[node.id].offset = { + posX: node.x + relX, + posY: node.y + relY, + x: relX, + y: relY, + depth, + width: node.width, + height: node.height + }; + if (node.type === "group") { + const subgraphEl = subgraphsEl.insert("g").attr("class", "subgraph"); + subgraphEl.insert("rect").attr("class", "subgraph subgraph-lvl-" + depth % 5 + " node").attr("x", node.x + relX).attr("y", node.y + relY).attr("width", node.width).attr("height", node.height); + const label = subgraphEl.insert("g").attr("class", "label"); + const labelCentering = getConfig$1().flowchart.htmlLabels ? node.labelData.width / 2 : 0; + label.attr( + "transform", + `translate(${node.labels[0].x + relX + node.x + labelCentering}, ${node.labels[0].y + relY + node.y + 3})` + ); + label.node().appendChild(node.labelData.labelNode); + log$1.info("Id (UGH)= ", node.type, node.labels); + } else { + log$1.info("Id (UGH)= ", node.id); + node.el.attr( + "transform", + `translate(${node.x + relX + node.width / 2}, ${node.y + relY + node.height / 2})` + ); + } + } + }); + nodeArray.forEach(function(node) { + if (node && node.type === "group") { + drawNodes$1(relX + node.x, relY + node.y, node.children, svg, subgraphsEl, diagObj, depth + 1); + } + }); +}; +const renderer$5 = { + getClasses: getClasses$2, + draw: draw$4 +}; +const genSections$2 = (options) => { + let sections = ""; + for (let i = 0; i < 5; i++) { + sections += ` + .subgraph-lvl-${i} { + fill: ${options[`surface${i}`]}; + stroke: ${options[`surfacePeer${i}`]}; + } + `; + } + return sections; +}; +const getStyles$3 = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span { + color: ${options.titleColor}; + } + + .label text,span { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.85; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + .cluster rect { + fill: ${options.clusterBkg}; + stroke: ${options.clusterBorder}; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } + .subgraph { + stroke-width:2; + rx:3; + } + // .subgraph-lvl-1 { + // fill:#ccc; + // // stroke:black; + // } + + .flowchart-label text { + text-anchor: middle; + } + + ${genSections$2(options)} +`; +const styles$2 = getStyles$3; +const diagram$4 = { + db: db$e, + renderer: renderer$5, + parser: parser$1$d, + styles: styles$2 +}; + +var flowchartElkDefinitionAe0efee6 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$4 +}); + +var parser$4 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 11, 12, 14, 16, 17, 20, 21], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12], $V5 = [1, 13], $V6 = [1, 16], $V7 = [1, 17]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "timeline": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "title": 11, "acc_title": 12, "acc_title_value": 13, "acc_descr": 14, "acc_descr_value": 15, "acc_descr_multiline_value": 16, "section": 17, "period_statement": 18, "event_statement": 19, "period": 20, "event": 21, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "timeline", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 20: "period", 21: "event" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 1], [18, 1], [19, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.getCommonDb().setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 9: + this.$ = $$[$0].trim(); + yy.getCommonDb().setAccTitle(this.$); + break; + case 10: + case 11: + this.$ = $$[$0].trim(); + yy.getCommonDb().setAccDescription(this.$); + break; + case 12: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 15: + yy.addTask($$[$0], 0, ""); + this.$ = $$[$0]; + break; + case 16: + yy.addEvent($$[$0].substr(2)); + this.$ = $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: 14, 19: 15, 20: $V6, 21: $V7 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 18, 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: 14, 19: 15, 20: $V6, 21: $V7 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), { 13: [1, 19] }, { 15: [1, 20] }, o($V0, [2, 11]), o($V0, [2, 12]), o($V0, [2, 13]), o($V0, [2, 14]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 4]), o($V0, [2, 9]), o($V0, [2, 10])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 10; + case 3: + break; + case 4: + break; + case 5: + return 4; + case 6: + return 11; + case 7: + this.begin("acc_title"); + return 12; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 14; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 17; + case 15: + return 21; + case 16: + return 20; + case 17: + return 6; + case 18: + return "INVALID"; + } + }, + rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:timeline\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?::\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$4.parser = parser$4; +const parser$1$3 = parser$4; +let currentSection = ""; +let currentTaskId = 0; +const sections = []; +const tasks = []; +const rawTasks = []; +const getCommonDb = () => commonDb; +const clear$3 = function() { + sections.length = 0; + tasks.length = 0; + currentSection = ""; + rawTasks.length = 0; + clear$k(); +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 100; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks.push(...rawTasks); + return tasks; +}; +const addTask = function(period, length, event) { + const rawTask = { + id: currentTaskId++, + section: currentSection, + type: currentSection, + task: period, + score: length ? length : 0, + //if event is defined, then add it the events array + events: event ? [event] : [] + }; + rawTasks.push(rawTask); +}; +const addEvent = function(event) { + const currentTask = rawTasks.find((task) => task.id === currentTaskId - 1); + currentTask.events.push(event); +}; +const addTaskOrg = function(descr) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const timelineDb = { + clear: clear$3, + getCommonDb, + addSection, + getSections, + getTasks, + addTask, + addTaskOrg, + addEvent +}; +const db$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + addEvent, + addSection, + addTask, + addTaskOrg, + clear: clear$3, + default: timelineDb, + getCommonDb, + getSections, + getTasks +}, Symbol.toStringTag, { value: "Module" })); +const MAX_SECTIONS$1 = 12; +const drawRect = function(elem, rectData) { + const rectElem = elem.append("rect"); + rectElem.attr("x", rectData.x); + rectElem.attr("y", rectData.y); + rectElem.attr("fill", rectData.fill); + rectElem.attr("stroke", rectData.stroke); + rectElem.attr("width", rectData.width); + rectElem.attr("height", rectData.height); + rectElem.attr("rx", rectData.rx); + rectElem.attr("ry", rectData.ry); + if (rectData.class !== void 0) { + rectElem.attr("class", rectData.class); + } + return rectElem; +}; +const drawFace = function(element, faceData) { + const radius = 15; + const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible"); + const face = element.append("g"); + face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + function smile(face2) { + const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")"); + } + function sad(face2) { + const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")"); + } + function ambivalent(face2) { + face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666"); + } + if (faceData.score > 3) { + smile(face); + } else if (faceData.score < 3) { + sad(face); + } else { + ambivalent(face); + } + return circleElement; +}; +const drawCircle = function(element, circleData) { + const circleElement = element.append("circle"); + circleElement.attr("cx", circleData.cx); + circleElement.attr("cy", circleData.cy); + circleElement.attr("class", "actor-" + circleData.pos); + circleElement.attr("fill", circleData.fill); + circleElement.attr("stroke", circleData.stroke); + circleElement.attr("r", circleData.r); + if (circleElement.class !== void 0) { + circleElement.attr("class", circleElement.class); + } + if (circleData.title !== void 0) { + circleElement.append("title").text(circleData.title); + } + return circleElement; +}; +const drawText = function(elem, textData) { + const nText = textData.text.replace(//gi, " "); + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.attr("class", "legend"); + textElem.style("text-anchor", textData.anchor); + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + const span = textElem.append("tspan"); + span.attr("x", textData.x + textData.textMargin * 2); + span.text(nText); + return textElem; +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.labelMargin; + txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin; + drawText(elem, txtObject); +}; +const drawSection = function(elem, section, conf) { + const g = elem.append("g"); + const rect = getNoteRect(); + rect.x = section.x; + rect.y = section.y; + rect.fill = section.fill; + rect.width = conf.width; + rect.height = conf.height; + rect.class = "journey-section section-type-" + section.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + _drawTextCandidateFunc(conf)( + section.text, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "journey-section section-type-" + section.num }, + conf, + section.colour + ); +}; +let taskCount = -1; +const drawTask = function(elem, task, conf) { + const center = task.x + conf.width / 2; + const g = elem.append("g"); + taskCount++; + const maxHeight = 300 + 5 * 30; + g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"); + drawFace(g, { + cx: center, + cy: 300 + (5 - task.score) * 30, + score: task.score + }); + const rect = getNoteRect(); + rect.x = task.x; + rect.y = task.y; + rect.fill = task.fill; + rect.width = conf.width; + rect.height = conf.height; + rect.class = "task task-type-" + task.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + task.x + 14; + _drawTextCandidateFunc(conf)( + task.task, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "task" }, + conf, + task.colour + ); +}; +const drawBackgroundRect = function(elem, bounds) { + const rectElem = drawRect(elem, { + x: bounds.startx, + y: bounds.starty, + width: bounds.stopx - bounds.startx, + height: bounds.stopy - bounds.starty, + fill: bounds.fill, + class: "rect" + }); + rectElem.lower(); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + "text-anchor": "start", + width: 100, + height: 100, + textMargin: 0, + rx: 0, + ry: 0 + }; +}; +const getNoteRect = function() { + return { + x: 0, + y: 0, + width: 100, + anchor: "start", + height: 100, + rx: 0, + ry: 0 + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs, colour) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) { + const { taskFontSize, taskFontFamily } = conf; + const lines = content.split(//gi); + for (let i = 0; i < lines.length; i++) { + const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf) { + const body = g.append("switch"); + const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed"); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, body, x, y, width, height, textAttrs, conf); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (key in fromTextAttrsDict) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf) { + return conf.textPlacement === "fo" ? byFo : conf.textPlacement === "old" ? byText : byTspan; + }; +}(); +const initGraphics = function(graphics) { + graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z"); +}; +function wrap(text, width) { + text.each(function() { + var text2 = select(this), words = text2.text().split(/(\s+|
    )/).reverse(), word, line = [], lineHeight = 1.1, y = text2.attr("y"), dy = parseFloat(text2.attr("dy")), tspan = text2.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", dy + "em"); + for (let j = 0; j < words.length; j++) { + word = words[words.length - 1 - j]; + line.push(word); + tspan.text(line.join(" ").trim()); + if (tspan.node().getComputedTextLength() > width || word === "
    ") { + line.pop(); + tspan.text(line.join(" ").trim()); + if (word === "
    ") { + line = [""]; + } else { + line = [word]; + } + tspan = text2.append("tspan").attr("x", 0).attr("y", y).attr("dy", lineHeight + "em").text(word); + } + } + }); +} +const drawNode$1 = function(elem, node, fullSection, conf) { + const section = fullSection % MAX_SECTIONS$1 - 1; + const nodeElem = elem.append("g"); + node.section = section; + nodeElem.attr( + "class", + (node.class ? node.class + " " : "") + "timeline-node " + ("section-" + section) + ); + const bkgElem = nodeElem.append("g"); + const textElem = nodeElem.append("g"); + const txt = textElem.append("text").text(node.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(wrap, node.width); + const bbox = txt.node().getBBox(); + const fontSize = conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; + node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; + node.height = Math.max(node.height, node.maxHeight); + node.width = node.width + 2 * node.padding; + textElem.attr("transform", "translate(" + node.width / 2 + ", " + node.padding / 2 + ")"); + defaultBkg$1(bkgElem, node, section); + return node; +}; +const getVirtualNodeHeight = function(elem, node, conf) { + const textElem = elem.append("g"); + const txt = textElem.append("text").text(node.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(wrap, node.width); + const bbox = txt.node().getBBox(); + const fontSize = conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; + textElem.remove(); + return bbox.height + fontSize * 1.1 * 0.5 + node.padding; +}; +const defaultBkg$1 = function(elem, node, section) { + const rd = 5; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + node.type).attr( + "d", + `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` + ); + elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); +}; +const svgDraw = { + drawRect, + drawCircle, + drawSection, + drawText, + drawLabel, + drawTask, + drawBackgroundRect, + getTextObj, + getNoteRect, + initGraphics, + drawNode: drawNode$1, + getVirtualNodeHeight +}; +const draw$3 = function(text, id, version, diagObj) { + var _a, _b; + const conf = getConfig$2(); + const LEFT_MARGIN = conf.leftMargin ?? 50; + log$1.debug("timeline", diagObj.db); + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select("#" + id); + svg.append("g"); + const tasks2 = diagObj.db.getTasks(); + const title = diagObj.db.getCommonDb().getDiagramTitle(); + log$1.debug("task", tasks2); + svgDraw.initGraphics(svg); + const sections2 = diagObj.db.getSections(); + log$1.debug("sections", sections2); + let maxSectionHeight = 0; + let maxTaskHeight = 0; + let depthY = 0; + let sectionBeginY = 0; + let masterX = 50 + LEFT_MARGIN; + let masterY = 50; + sectionBeginY = 50; + let sectionNumber = 0; + let hasSections = true; + sections2.forEach(function(section) { + const sectionNode = { + number: sectionNumber, + descr: section, + section: sectionNumber, + width: 150, + padding: 20, + maxHeight: maxSectionHeight + }; + const sectionHeight = svgDraw.getVirtualNodeHeight(svg, sectionNode, conf); + log$1.debug("sectionHeight before draw", sectionHeight); + maxSectionHeight = Math.max(maxSectionHeight, sectionHeight + 20); + }); + let maxEventCount = 0; + let maxEventLineLength = 0; + log$1.debug("tasks.length", tasks2.length); + for (const [i, task] of tasks2.entries()) { + const taskNode = { + number: i, + descr: task, + section: task.section, + width: 150, + padding: 20, + maxHeight: maxTaskHeight + }; + const taskHeight = svgDraw.getVirtualNodeHeight(svg, taskNode, conf); + log$1.debug("taskHeight before draw", taskHeight); + maxTaskHeight = Math.max(maxTaskHeight, taskHeight + 20); + maxEventCount = Math.max(maxEventCount, task.events.length); + let maxEventLineLengthTemp = 0; + for (let j = 0; j < task.events.length; j++) { + const event = task.events[j]; + const eventNode = { + descr: event, + section: task.section, + number: task.section, + width: 150, + padding: 20, + maxHeight: 50 + }; + maxEventLineLengthTemp += svgDraw.getVirtualNodeHeight(svg, eventNode, conf); + } + maxEventLineLength = Math.max(maxEventLineLength, maxEventLineLengthTemp); + } + log$1.debug("maxSectionHeight before draw", maxSectionHeight); + log$1.debug("maxTaskHeight before draw", maxTaskHeight); + if (sections2 && sections2.length > 0) { + sections2.forEach((section) => { + const tasksForSection = tasks2.filter((task) => task.section === section); + const sectionNode = { + number: sectionNumber, + descr: section, + section: sectionNumber, + width: 200 * Math.max(tasksForSection.length, 1) - 50, + padding: 20, + maxHeight: maxSectionHeight + }; + log$1.debug("sectionNode", sectionNode); + const sectionNodeWrapper = svg.append("g"); + const node = svgDraw.drawNode(sectionNodeWrapper, sectionNode, sectionNumber, conf); + log$1.debug("sectionNode output", node); + sectionNodeWrapper.attr("transform", `translate(${masterX}, ${sectionBeginY})`); + masterY += maxSectionHeight + 50; + if (tasksForSection.length > 0) { + drawTasks( + svg, + tasksForSection, + sectionNumber, + masterX, + masterY, + maxTaskHeight, + conf, + maxEventCount, + maxEventLineLength, + maxSectionHeight, + false + ); + } + masterX += 200 * Math.max(tasksForSection.length, 1); + masterY = sectionBeginY; + sectionNumber++; + }); + } else { + hasSections = false; + drawTasks( + svg, + tasks2, + sectionNumber, + masterX, + masterY, + maxTaskHeight, + conf, + maxEventCount, + maxEventLineLength, + maxSectionHeight, + true + ); + } + const box = svg.node().getBBox(); + log$1.debug("bounds", box); + if (title) { + svg.append("text").text(title).attr("x", box.width / 2 - LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20); + } + depthY = hasSections ? maxSectionHeight + maxTaskHeight + 150 : maxTaskHeight + 100; + const lineWrapper = svg.append("g").attr("class", "lineWrapper"); + lineWrapper.append("line").attr("x1", LEFT_MARGIN).attr("y1", depthY).attr("x2", box.width + 3 * LEFT_MARGIN).attr("y2", depthY).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"); + setupGraphViewbox$1( + void 0, + svg, + ((_a = conf.timeline) == null ? void 0 : _a.padding) ?? 50, + ((_b = conf.timeline) == null ? void 0 : _b.useMaxWidth) ?? false + ); +}; +const drawTasks = function(diagram2, tasks2, sectionColor, masterX, masterY, maxTaskHeight, conf, maxEventCount, maxEventLineLength, maxSectionHeight, isWithoutSections) { + var _a; + for (const task of tasks2) { + const taskNode = { + descr: task.task, + section: sectionColor, + number: sectionColor, + width: 150, + padding: 20, + maxHeight: maxTaskHeight + }; + log$1.debug("taskNode", taskNode); + const taskWrapper = diagram2.append("g").attr("class", "taskWrapper"); + const node = svgDraw.drawNode(taskWrapper, taskNode, sectionColor, conf); + const taskHeight = node.height; + log$1.debug("taskHeight after draw", taskHeight); + taskWrapper.attr("transform", `translate(${masterX}, ${masterY})`); + maxTaskHeight = Math.max(maxTaskHeight, taskHeight); + if (task.events) { + const lineWrapper = diagram2.append("g").attr("class", "lineWrapper"); + let lineLength = maxTaskHeight; + masterY += 100; + lineLength = lineLength + drawEvents(diagram2, task.events, sectionColor, masterX, masterY, conf); + masterY -= 100; + lineWrapper.append("line").attr("x1", masterX + 190 / 2).attr("y1", masterY + maxTaskHeight).attr("x2", masterX + 190 / 2).attr( + "y2", + masterY + maxTaskHeight + (isWithoutSections ? maxTaskHeight : maxSectionHeight) + maxEventLineLength + 120 + ).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", "url(#arrowhead)").attr("stroke-dasharray", "5,5"); + } + masterX = masterX + 200; + if (isWithoutSections && !((_a = conf.timeline) == null ? void 0 : _a.disableMulticolor)) { + sectionColor++; + } + } + masterY = masterY - 10; +}; +const drawEvents = function(diagram2, events, sectionColor, masterX, masterY, conf) { + let maxEventHeight = 0; + const eventBeginY = masterY; + masterY = masterY + 100; + for (const event of events) { + const eventNode = { + descr: event, + section: sectionColor, + number: sectionColor, + width: 150, + padding: 20, + maxHeight: 50 + }; + log$1.debug("eventNode", eventNode); + const eventWrapper = diagram2.append("g").attr("class", "eventWrapper"); + const node = svgDraw.drawNode(eventWrapper, eventNode, sectionColor, conf); + const eventHeight = node.height; + maxEventHeight = maxEventHeight + eventHeight; + eventWrapper.attr("transform", `translate(${masterX}, ${masterY})`); + masterY = masterY + 10 + eventHeight; + } + masterY = eventBeginY; + return maxEventHeight; +}; +const renderer$4 = { + setConf: () => { + }, + draw: draw$3 +}; +const genSections$1 = (options) => { + let sections2 = ""; + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i]; + if (isDark(options["lineColor" + i])) { + options["lineColor" + i] = lighten(options["lineColor" + i], 20); + } else { + options["lineColor" + i] = darken(options["lineColor" + i], 20); + } + } + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + const sw = "" + (17 - 3 * i); + sections2 += ` + .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} path { + fill: ${options["cScale" + i]}; + } + .section-${i - 1} text { + fill: ${options["cScaleLabel" + i]}; + } + .node-icon-${i - 1} { + font-size: 40px; + color: ${options["cScaleLabel" + i]}; + } + .section-edge-${i - 1}{ + stroke: ${options["cScale" + i]}; + } + .edge-depth-${i - 1}{ + stroke-width: ${sw}; + } + .section-${i - 1} line { + stroke: ${options["cScaleInv" + i]} ; + stroke-width: 3; + } + + .lineWrapper line{ + stroke: ${options["cScaleLabel" + i]} ; + } + + .disabled, .disabled circle, .disabled text { + fill: lightgray; + } + .disabled text { + fill: #efefef; + } + `; + } + return sections2; +}; +const getStyles$2 = (options) => ` + .edge { + stroke-width: 3; + } + ${genSections$1(options)} + .section-root rect, .section-root path, .section-root circle { + fill: ${options.git0}; + } + .section-root text { + fill: ${options.gitBranchLabel0}; + } + .icon-container { + height:100%; + display: flex; + justify-content: center; + align-items: center; + } + .edge { + fill: none; + } + .eventWrapper { + filter: brightness(120%); + } +`; +const styles$1 = getStyles$2; +const diagram$3 = { + db: db$4, + renderer: renderer$4, + parser: parser$1$3, + styles: styles$1 +}; + +var timelineDefinitionBf702344 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$3 +}); + +/** + * Copyright (c) 2016-2024, The Cytoscape Consortium. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the “Software”), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +function _typeof(obj) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); +} +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; +} +function _defineProperty$1(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} +function _iterableToArrayLimit(arr, i) { + var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; + if (_i == null) return; + var _arr = []; + var _n = true; + var _d = false; + var _s, _e; + try { + for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; +} +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +function _createForOfIteratorHelper(o, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; + if (!it) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { + if (it) o = it; + var i = 0; + var F = function () {}; + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = it.call(o); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +var _window = typeof window === 'undefined' ? null : window; // eslint-disable-line no-undef + +var navigator$1 = _window ? _window.navigator : null; +_window ? _window.document : null; +var typeofstr = _typeof(''); +var typeofobj = _typeof({}); +var typeoffn = _typeof(function () {}); +var typeofhtmlele = typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement); +var instanceStr = function instanceStr(obj) { + return obj && obj.instanceString && fn$6(obj.instanceString) ? obj.instanceString() : null; +}; + +var string = function string(obj) { + return obj != null && _typeof(obj) == typeofstr; +}; +var fn$6 = function fn(obj) { + return obj != null && _typeof(obj) === typeoffn; +}; +var array = function array(obj) { + return !elementOrCollection(obj) && (Array.isArray ? Array.isArray(obj) : obj != null && obj instanceof Array); +}; +var plainObject = function plainObject(obj) { + return obj != null && _typeof(obj) === typeofobj && !array(obj) && obj.constructor === Object; +}; +var object = function object(obj) { + return obj != null && _typeof(obj) === typeofobj; +}; +var number$1 = function number(obj) { + return obj != null && _typeof(obj) === _typeof(1) && !isNaN(obj); +}; +var integer = function integer(obj) { + return number$1(obj) && Math.floor(obj) === obj; +}; +var htmlElement = function htmlElement(obj) { + if ('undefined' === typeofhtmlele) { + return undefined; + } else { + return null != obj && obj instanceof HTMLElement; + } +}; +var elementOrCollection = function elementOrCollection(obj) { + return element(obj) || collection(obj); +}; +var element = function element(obj) { + return instanceStr(obj) === 'collection' && obj._private.single; +}; +var collection = function collection(obj) { + return instanceStr(obj) === 'collection' && !obj._private.single; +}; +var core = function core(obj) { + return instanceStr(obj) === 'core'; +}; +var stylesheet = function stylesheet(obj) { + return instanceStr(obj) === 'stylesheet'; +}; +var event = function event(obj) { + return instanceStr(obj) === 'event'; +}; +var emptyString = function emptyString(obj) { + if (obj === undefined || obj === null) { + // null is empty + return true; + } else if (obj === '' || obj.match(/^\s+$/)) { + return true; // empty string is empty + } + + return false; // otherwise, we don't know what we've got +}; +var domElement = function domElement(obj) { + if (typeof HTMLElement === 'undefined') { + return false; // we're not in a browser so it doesn't matter + } else { + return obj instanceof HTMLElement; + } +}; +var boundingBox = function boundingBox(obj) { + return plainObject(obj) && number$1(obj.x1) && number$1(obj.x2) && number$1(obj.y1) && number$1(obj.y2); +}; +var promise = function promise(obj) { + return object(obj) && fn$6(obj.then); +}; +var ms = function ms() { + return navigator$1 && navigator$1.userAgent.match(/msie|trident|edge/i); +}; // probably a better way to detect this... + +var memoize$1 = function memoize(fn, keyFn) { + if (!keyFn) { + keyFn = function keyFn() { + if (arguments.length === 1) { + return arguments[0]; + } else if (arguments.length === 0) { + return 'undefined'; + } + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + return args.join('$'); + }; + } + var memoizedFn = function memoizedFn() { + var self = this; + var args = arguments; + var ret; + var k = keyFn.apply(self, args); + var cache = memoizedFn.cache; + if (!(ret = cache[k])) { + ret = cache[k] = fn.apply(self, args); + } + return ret; + }; + memoizedFn.cache = {}; + return memoizedFn; +}; + +var camel2dash = memoize$1(function (str) { + return str.replace(/([A-Z])/g, function (v) { + return '-' + v.toLowerCase(); + }); +}); +var dash2camel = memoize$1(function (str) { + return str.replace(/(-\w)/g, function (v) { + return v[1].toUpperCase(); + }); +}); +var prependCamel = memoize$1(function (prefix, str) { + return prefix + str[0].toUpperCase() + str.substring(1); +}, function (prefix, str) { + return prefix + '$' + str; +}); +var capitalize = function capitalize(str) { + if (emptyString(str)) { + return str; + } + return str.charAt(0).toUpperCase() + str.substring(1); +}; + +var number = '(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))'; +var rgba = 'rgb[a]?\\((' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)(?:\\s*,\\s*(' + number + '))?\\)'; +var rgbaNoBackRefs = 'rgb[a]?\\((?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)(?:\\s*,\\s*(?:' + number + '))?\\)'; +var hsla = 'hsl[a]?\\((' + number + ')\\s*,\\s*(' + number + '[%])\\s*,\\s*(' + number + '[%])(?:\\s*,\\s*(' + number + '))?\\)'; +var hslaNoBackRefs = 'hsl[a]?\\((?:' + number + ')\\s*,\\s*(?:' + number + '[%])\\s*,\\s*(?:' + number + '[%])(?:\\s*,\\s*(?:' + number + '))?\\)'; +var hex3 = '\\#[0-9a-fA-F]{3}'; +var hex6 = '\\#[0-9a-fA-F]{6}'; + +var ascending = function ascending(a, b) { + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } +}; +var descending = function descending(a, b) { + return -1 * ascending(a, b); +}; + +var extend = Object.assign != null ? Object.assign.bind(Object) : function (tgt) { + var args = arguments; + for (var i = 1; i < args.length; i++) { + var obj = args[i]; + if (obj == null) { + continue; + } + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; j++) { + var k = keys[j]; + tgt[k] = obj[k]; + } + } + return tgt; +}; + +// get [r, g, b] from #abc or #aabbcc +var hex2tuple = function hex2tuple(hex) { + if (!(hex.length === 4 || hex.length === 7) || hex[0] !== '#') { + return; + } + var shortHex = hex.length === 4; + var r, g, b; + var base = 16; + if (shortHex) { + r = parseInt(hex[1] + hex[1], base); + g = parseInt(hex[2] + hex[2], base); + b = parseInt(hex[3] + hex[3], base); + } else { + r = parseInt(hex[1] + hex[2], base); + g = parseInt(hex[3] + hex[4], base); + b = parseInt(hex[5] + hex[6], base); + } + return [r, g, b]; +}; + +// get [r, g, b, a] from hsl(0, 0, 0) or hsla(0, 0, 0, 0) +var hsl2tuple = function hsl2tuple(hsl) { + var ret; + var h, s, l, a, r, g, b; + function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; + return p; + } + var m = new RegExp('^' + hsla + '$').exec(hsl); + if (m) { + // get hue + h = parseInt(m[1]); + if (h < 0) { + h = (360 - -1 * h % 360) % 360; + } else if (h > 360) { + h = h % 360; + } + h /= 360; // normalise on [0, 1] + + s = parseFloat(m[2]); + if (s < 0 || s > 100) { + return; + } // saturation is [0, 100] + s = s / 100; // normalise on [0, 1] + + l = parseFloat(m[3]); + if (l < 0 || l > 100) { + return; + } // lightness is [0, 100] + l = l / 100; // normalise on [0, 1] + + a = m[4]; + if (a !== undefined) { + a = parseFloat(a); + if (a < 0 || a > 1) { + return; + } // alpha is [0, 1] + } + + // now, convert to rgb + // code from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript + if (s === 0) { + r = g = b = Math.round(l * 255); // achromatic + } else { + var q = l < 0.5 ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + r = Math.round(255 * hue2rgb(p, q, h + 1 / 3)); + g = Math.round(255 * hue2rgb(p, q, h)); + b = Math.round(255 * hue2rgb(p, q, h - 1 / 3)); + } + ret = [r, g, b, a]; + } + return ret; +}; + +// get [r, g, b, a] from rgb(0, 0, 0) or rgba(0, 0, 0, 0) +var rgb2tuple = function rgb2tuple(rgb) { + var ret; + var m = new RegExp('^' + rgba + '$').exec(rgb); + if (m) { + ret = []; + var isPct = []; + for (var i = 1; i <= 3; i++) { + var channel = m[i]; + if (channel[channel.length - 1] === '%') { + isPct[i] = true; + } + channel = parseFloat(channel); + if (isPct[i]) { + channel = channel / 100 * 255; // normalise to [0, 255] + } + + if (channel < 0 || channel > 255) { + return; + } // invalid channel value + + ret.push(Math.floor(channel)); + } + var atLeastOneIsPct = isPct[1] || isPct[2] || isPct[3]; + var allArePct = isPct[1] && isPct[2] && isPct[3]; + if (atLeastOneIsPct && !allArePct) { + return; + } // must all be percent values if one is + + var alpha = m[4]; + if (alpha !== undefined) { + alpha = parseFloat(alpha); + if (alpha < 0 || alpha > 1) { + return; + } // invalid alpha value + + ret.push(alpha); + } + } + return ret; +}; +var colorname2tuple = function colorname2tuple(color) { + return colors[color.toLowerCase()]; +}; +var color2tuple = function color2tuple(color) { + return (array(color) ? color : null) || colorname2tuple(color) || hex2tuple(color) || rgb2tuple(color) || hsl2tuple(color); +}; +var colors = { + // special colour names + transparent: [0, 0, 0, 0], + // NB alpha === 0 + + // regular colours + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + grey: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] +}; + +// sets the value in a map (map may not be built) +var setMap = function setMap(options) { + var obj = options.map; + var keys = options.keys; + var l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (plainObject(key)) { + throw Error('Tried to set map with object key'); + } + if (i < keys.length - 1) { + // extend the map if necessary + if (obj[key] == null) { + obj[key] = {}; + } + obj = obj[key]; + } else { + // set the value + obj[key] = options.value; + } + } +}; + +// gets the value in a map even if it's not built in places +var getMap = function getMap(options) { + var obj = options.map; + var keys = options.keys; + var l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (plainObject(key)) { + throw Error('Tried to get map with object key'); + } + obj = obj[key]; + if (obj == null) { + return obj; + } + } + return obj; +}; + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +var isObject_1 = isObject; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + +var _freeGlobal = freeGlobal; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = _freeGlobal || freeSelf || Function('return this')(); + +var _root = root; + +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ +var now = function() { + return _root.Date.now(); +}; + +var now_1 = now; + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +var _trimmedEndIndex = trimmedEndIndex; + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +var _baseTrim = baseTrim; + +/** Built-in value references. */ +var Symbol$1 = _root.Symbol; + +var _Symbol = Symbol$1; + +/** Used for built-in method references. */ +var objectProto$5 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$4 = objectProto$5.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$5.toString; + +/** Built-in value references. */ +var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString$1.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +var _getRawTag = getRawTag; + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto$4.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +var _objectToString = objectToString; + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? _getRawTag(value) + : _objectToString(value); +} + +var _baseGetTag = baseGetTag; + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +var isObjectLike_1 = isObjectLike; + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike_1(value) && _baseGetTag(value) == symbolTag); +} + +var isSymbol_1 = isSymbol; + +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol_1(value)) { + return NAN; + } + if (isObject_1(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject_1(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = _baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); +} + +var toNumber_1 = toNumber; + +/** Error message constants. */ +var FUNC_ERROR_TEXT$1 = 'Expected a function'; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max, + nativeMin = Math.min; + +/** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ +function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$1); + } + wait = toNumber_1(wait) || 0; + if (isObject_1(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } + + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; + + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now_1(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } + + function trailingEdge(time) { + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } + + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } + + function flush() { + return timerId === undefined ? result : trailingEdge(now_1()); + } + + function debounced() { + var time = now_1(), + isInvoking = shouldInvoke(time); + + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; +} + +var debounce_1 = debounce; + +var performance$1 = _window ? _window.performance : null; +var pnow = performance$1 && performance$1.now ? function () { + return performance$1.now(); +} : function () { + return Date.now(); +}; +var raf = function () { + if (_window) { + if (_window.requestAnimationFrame) { + return function (fn) { + _window.requestAnimationFrame(fn); + }; + } else if (_window.mozRequestAnimationFrame) { + return function (fn) { + _window.mozRequestAnimationFrame(fn); + }; + } else if (_window.webkitRequestAnimationFrame) { + return function (fn) { + _window.webkitRequestAnimationFrame(fn); + }; + } else if (_window.msRequestAnimationFrame) { + return function (fn) { + _window.msRequestAnimationFrame(fn); + }; + } + } + return function (fn) { + if (fn) { + setTimeout(function () { + fn(pnow()); + }, 1000 / 60); + } + }; +}(); +var requestAnimationFrame$1 = function requestAnimationFrame(fn) { + return raf(fn); +}; +var performanceNow = pnow; + +var DEFAULT_HASH_SEED = 9261; +var K = 65599; // 37 also works pretty well +var DEFAULT_HASH_SEED_ALT = 5381; +var hashIterableInts = function hashIterableInts(iterator) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED; + // sdbm/string-hash + var hash = seed; + var entry; + for (;;) { + entry = iterator.next(); + if (entry.done) { + break; + } + hash = hash * K + entry.value | 0; + } + return hash; +}; +var hashInt = function hashInt(num) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED; + // sdbm/string-hash + return seed * K + num | 0; +}; +var hashIntAlt = function hashIntAlt(num) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED_ALT; + // djb2/string-hash + return (seed << 5) + seed + num | 0; +}; +var combineHashes = function combineHashes(hash1, hash2) { + return hash1 * 0x200000 + hash2; +}; +var combineHashesArray = function combineHashesArray(hashes) { + return hashes[0] * 0x200000 + hashes[1]; +}; +var hashArrays = function hashArrays(hashes1, hashes2) { + return [hashInt(hashes1[0], hashes2[0]), hashIntAlt(hashes1[1], hashes2[1])]; +}; +var hashIntsArray = function hashIntsArray(ints, seed) { + var entry = { + value: 0, + done: false + }; + var i = 0; + var length = ints.length; + var iterator = { + next: function next() { + if (i < length) { + entry.value = ints[i++]; + } else { + entry.done = true; + } + return entry; + } + }; + return hashIterableInts(iterator, seed); +}; +var hashString = function hashString(str, seed) { + var entry = { + value: 0, + done: false + }; + var i = 0; + var length = str.length; + var iterator = { + next: function next() { + if (i < length) { + entry.value = str.charCodeAt(i++); + } else { + entry.done = true; + } + return entry; + } + }; + return hashIterableInts(iterator, seed); +}; +var hashStrings = function hashStrings() { + return hashStringsArray(arguments); +}; +var hashStringsArray = function hashStringsArray(strs) { + var hash; + for (var i = 0; i < strs.length; i++) { + var str = strs[i]; + if (i === 0) { + hash = hashString(str); + } else { + hash = hashString(str, hash); + } + } + return hash; +}; + +/*global console */ +var warningsEnabled = true; +var warnSupported = console.warn != null; // eslint-disable-line no-console +var traceSupported = console.trace != null; // eslint-disable-line no-console + +var MAX_INT$1 = Number.MAX_SAFE_INTEGER || 9007199254740991; +var trueify = function trueify() { + return true; +}; +var falsify = function falsify() { + return false; +}; +var zeroify = function zeroify() { + return 0; +}; +var noop$1 = function noop() {}; +var error = function error(msg) { + throw new Error(msg); +}; +var warnings = function warnings(enabled) { + if (enabled !== undefined) { + warningsEnabled = !!enabled; + } else { + return warningsEnabled; + } +}; +var warn = function warn(msg) { + /* eslint-disable no-console */ + if (!warnings()) { + return; + } + if (warnSupported) { + console.warn(msg); + } else { + console.log(msg); + if (traceSupported) { + console.trace(); + } + } +}; /* eslint-enable */ + +var clone = function clone(obj) { + return extend({}, obj); +}; + +// gets a shallow copy of the argument +var copy = function copy(obj) { + if (obj == null) { + return obj; + } + if (array(obj)) { + return obj.slice(); + } else if (plainObject(obj)) { + return clone(obj); + } else { + return obj; + } +}; +var copyArray$1 = function copyArray(arr) { + return arr.slice(); +}; +var uuid = function uuid(a, b /* placeholders */) { + for ( + // loop :) + b = a = ''; + // b - result , a - numeric letiable + a++ < 36; + // + b += a * 51 & 52 // if "a" is not 9 or 14 or 19 or 24 + ? + // return a random number or 4 + (a ^ 15 // if "a" is not 15 + ? + // generate a random number from 0 to 15 + 8 ^ Math.random() * (a ^ 20 ? 16 : 4) // unless "a" is 20, in which case a random number from 8 to 11 + : 4 // otherwise 4 + ).toString(16) : '-' // in other cases (if "a" is 9,14,19,24) insert "-" + ) { + } + return b; +}; +var _staticEmptyObject = {}; +var staticEmptyObject = function staticEmptyObject() { + return _staticEmptyObject; +}; +var defaults$g = function defaults(_defaults) { + var keys = Object.keys(_defaults); + return function (opts) { + var filledOpts = {}; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var optVal = opts == null ? undefined : opts[key]; + filledOpts[key] = optVal === undefined ? _defaults[key] : optVal; + } + return filledOpts; + }; +}; +var removeFromArray = function removeFromArray(arr, ele, oneCopy) { + for (var i = arr.length - 1; i >= 0; i--) { + if (arr[i] === ele) { + arr.splice(i, 1); + } + } +}; +var clearArray = function clearArray(arr) { + arr.splice(0, arr.length); +}; +var push = function push(arr, otherArr) { + for (var i = 0; i < otherArr.length; i++) { + var el = otherArr[i]; + arr.push(el); + } +}; +var getPrefixedProperty = function getPrefixedProperty(obj, propName, prefix) { + if (prefix) { + propName = prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth + } + + return obj[propName]; +}; +var setPrefixedProperty = function setPrefixedProperty(obj, propName, prefix, value) { + if (prefix) { + propName = prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth + } + + obj[propName] = value; +}; + +/* global Map */ +var ObjectMap = /*#__PURE__*/function () { + function ObjectMap() { + _classCallCheck(this, ObjectMap); + this._obj = {}; + } + _createClass(ObjectMap, [{ + key: "set", + value: function set(key, val) { + this._obj[key] = val; + return this; + } + }, { + key: "delete", + value: function _delete(key) { + this._obj[key] = undefined; + return this; + } + }, { + key: "clear", + value: function clear() { + this._obj = {}; + } + }, { + key: "has", + value: function has(key) { + return this._obj[key] !== undefined; + } + }, { + key: "get", + value: function get(key) { + return this._obj[key]; + } + }]); + return ObjectMap; +}(); +var Map$2 = typeof Map !== 'undefined' ? Map : ObjectMap; + +/* global Set */ + +var undef = "undefined" ; +var ObjectSet = /*#__PURE__*/function () { + function ObjectSet(arrayOrObjectSet) { + _classCallCheck(this, ObjectSet); + this._obj = Object.create(null); + this.size = 0; + if (arrayOrObjectSet != null) { + var arr; + if (arrayOrObjectSet.instanceString != null && arrayOrObjectSet.instanceString() === this.instanceString()) { + arr = arrayOrObjectSet.toArray(); + } else { + arr = arrayOrObjectSet; + } + for (var i = 0; i < arr.length; i++) { + this.add(arr[i]); + } + } + } + _createClass(ObjectSet, [{ + key: "instanceString", + value: function instanceString() { + return 'set'; + } + }, { + key: "add", + value: function add(val) { + var o = this._obj; + if (o[val] !== 1) { + o[val] = 1; + this.size++; + } + } + }, { + key: "delete", + value: function _delete(val) { + var o = this._obj; + if (o[val] === 1) { + o[val] = 0; + this.size--; + } + } + }, { + key: "clear", + value: function clear() { + this._obj = Object.create(null); + } + }, { + key: "has", + value: function has(val) { + return this._obj[val] === 1; + } + }, { + key: "toArray", + value: function toArray() { + var _this = this; + return Object.keys(this._obj).filter(function (key) { + return _this.has(key); + }); + } + }, { + key: "forEach", + value: function forEach(callback, thisArg) { + return this.toArray().forEach(callback, thisArg); + } + }]); + return ObjectSet; +}(); +var Set$1 = (typeof Set === "undefined" ? "undefined" : _typeof(Set)) !== undef ? Set : ObjectSet; + +// represents a node or an edge +var Element = function Element(cy, params) { + var restore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + if (cy === undefined || params === undefined || !core(cy)) { + error('An element must have a core reference and parameters set'); + return; + } + var group = params.group; + + // try to automatically infer the group if unspecified + if (group == null) { + if (params.data && params.data.source != null && params.data.target != null) { + group = 'edges'; + } else { + group = 'nodes'; + } + } + + // validate group + if (group !== 'nodes' && group !== 'edges') { + error('An element must be of type `nodes` or `edges`; you specified `' + group + '`'); + return; + } + + // make the element array-like, just like a collection + this.length = 1; + this[0] = this; + + // NOTE: when something is added here, add also to ele.json() + var _p = this._private = { + cy: cy, + single: true, + // indicates this is an element + data: params.data || {}, + // data object + position: params.position || { + x: 0, + y: 0 + }, + // (x, y) position pair + autoWidth: undefined, + // width and height of nodes calculated by the renderer when set to special 'auto' value + autoHeight: undefined, + autoPadding: undefined, + compoundBoundsClean: false, + // whether the compound dimensions need to be recalculated the next time dimensions are read + listeners: [], + // array of bound listeners + group: group, + // string; 'nodes' or 'edges' + style: {}, + // properties as set by the style + rstyle: {}, + // properties for style sent from the renderer to the core + styleCxts: [], + // applied style contexts from the styler + styleKeys: {}, + // per-group keys of style property values + removed: true, + // whether it's inside the vis; true if removed (set true here since we call restore) + selected: params.selected ? true : false, + // whether it's selected + selectable: params.selectable === undefined ? true : params.selectable ? true : false, + // whether it's selectable + locked: params.locked ? true : false, + // whether the element is locked (cannot be moved) + grabbed: false, + // whether the element is grabbed by the mouse; renderer sets this privately + grabbable: params.grabbable === undefined ? true : params.grabbable ? true : false, + // whether the element can be grabbed + pannable: params.pannable === undefined ? group === 'edges' ? true : false : params.pannable ? true : false, + // whether the element has passthrough panning enabled + active: false, + // whether the element is active from user interaction + classes: new Set$1(), + // map ( className => true ) + animation: { + // object for currently-running animations + current: [], + queue: [] + }, + rscratch: {}, + // object in which the renderer can store information + scratch: params.scratch || {}, + // scratch objects + edges: [], + // array of connected edges + children: [], + // array of children + parent: params.parent && params.parent.isNode() ? params.parent : null, + // parent ref + traversalCache: {}, + // cache of output of traversal functions + backgrounding: false, + // whether background images are loading + bbCache: null, + // cache of the current bounding box + bbCacheShift: { + x: 0, + y: 0 + }, + // shift applied to cached bb to be applied on next get + bodyBounds: null, + // bounds cache of element body, w/o overlay + overlayBounds: null, + // bounds cache of element body, including overlay + labelBounds: { + // bounds cache of labels + all: null, + source: null, + target: null, + main: null + }, + arrowBounds: { + // bounds cache of edge arrows + source: null, + target: null, + 'mid-source': null, + 'mid-target': null + } + }; + if (_p.position.x == null) { + _p.position.x = 0; + } + if (_p.position.y == null) { + _p.position.y = 0; + } + + // renderedPosition overrides if specified + if (params.renderedPosition) { + var rpos = params.renderedPosition; + var pan = cy.pan(); + var zoom = cy.zoom(); + _p.position = { + x: (rpos.x - pan.x) / zoom, + y: (rpos.y - pan.y) / zoom + }; + } + var classes = []; + if (array(params.classes)) { + classes = params.classes; + } else if (string(params.classes)) { + classes = params.classes.split(/\s+/); + } + for (var i = 0, l = classes.length; i < l; i++) { + var cls = classes[i]; + if (!cls || cls === '') { + continue; + } + _p.classes.add(cls); + } + this.createEmitter(); + var bypass = params.style || params.css; + if (bypass) { + warn('Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead.'); + this.style(bypass); + } + if (restore === undefined || restore) { + this.restore(); + } +}; + +var defineSearch = function defineSearch(params) { + params = { + bfs: params.bfs || !params.dfs, + dfs: params.dfs || !params.bfs + }; + + // from pseudocode on wikipedia + return function searchFn(roots, fn, directed) { + var options; + if (plainObject(roots) && !elementOrCollection(roots)) { + options = roots; + roots = options.roots || options.root; + fn = options.visit; + directed = options.directed; + } + directed = arguments.length === 2 && !fn$6(fn) ? fn : directed; + fn = fn$6(fn) ? fn : function () {}; + var cy = this._private.cy; + var v = roots = string(roots) ? this.filter(roots) : roots; + var Q = []; + var connectedNodes = []; + var connectedBy = {}; + var id2depth = {}; + var V = {}; + var j = 0; + var found; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + + // enqueue v + for (var i = 0; i < v.length; i++) { + var vi = v[i]; + var viId = vi.id(); + if (vi.isNode()) { + Q.unshift(vi); + if (params.bfs) { + V[viId] = true; + connectedNodes.push(vi); + } + id2depth[viId] = 0; + } + } + var _loop = function _loop() { + var v = params.bfs ? Q.shift() : Q.pop(); + var vId = v.id(); + if (params.dfs) { + if (V[vId]) { + return "continue"; + } + V[vId] = true; + connectedNodes.push(v); + } + var depth = id2depth[vId]; + var prevEdge = connectedBy[vId]; + var src = prevEdge != null ? prevEdge.source() : null; + var tgt = prevEdge != null ? prevEdge.target() : null; + var prevNode = prevEdge == null ? undefined : v.same(src) ? tgt[0] : src[0]; + var ret = void 0; + ret = fn(v, prevEdge, prevNode, j++, depth); + if (ret === true) { + found = v; + return "break"; + } + if (ret === false) { + return "break"; + } + var vwEdges = v.connectedEdges().filter(function (e) { + return (!directed || e.source().same(v)) && edges.has(e); + }); + for (var _i2 = 0; _i2 < vwEdges.length; _i2++) { + var e = vwEdges[_i2]; + var w = e.connectedNodes().filter(function (n) { + return !n.same(v) && nodes.has(n); + }); + var wId = w.id(); + if (w.length !== 0 && !V[wId]) { + w = w[0]; + Q.push(w); + if (params.bfs) { + V[wId] = true; + connectedNodes.push(w); + } + connectedBy[wId] = e; + id2depth[wId] = id2depth[vId] + 1; + } + } + }; + while (Q.length !== 0) { + var _ret = _loop(); + if (_ret === "continue") continue; + if (_ret === "break") break; + } + var connectedEles = cy.collection(); + for (var _i = 0; _i < connectedNodes.length; _i++) { + var node = connectedNodes[_i]; + var edge = connectedBy[node.id()]; + if (edge != null) { + connectedEles.push(edge); + } + connectedEles.push(node); + } + return { + path: cy.collection(connectedEles), + found: cy.collection(found) + }; + }; +}; + +// search, spanning trees, etc +var elesfn$v = { + breadthFirstSearch: defineSearch({ + bfs: true + }), + depthFirstSearch: defineSearch({ + dfs: true + }) +}; + +// nice, short mathematical alias +elesfn$v.bfs = elesfn$v.breadthFirstSearch; +elesfn$v.dfs = elesfn$v.depthFirstSearch; + +var heap$1 = createCommonjsModule(function (module, exports) { +// Generated by CoffeeScript 1.8.0 +(function() { + var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup; + + floor = Math.floor, min = Math.min; + + + /* + Default comparison function to be used + */ + + defaultCmp = function(x, y) { + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } + return 0; + }; + + + /* + Insert item x in list a, and keep it sorted assuming a is sorted. + + If x is already in a, insert it to the right of the rightmost x. + + Optional args lo (default 0) and hi (default a.length) bound the slice + of a to be searched. + */ + + insort = function(a, x, lo, hi, cmp) { + var mid; + if (lo == null) { + lo = 0; + } + if (cmp == null) { + cmp = defaultCmp; + } + if (lo < 0) { + throw new Error('lo must be non-negative'); + } + if (hi == null) { + hi = a.length; + } + while (lo < hi) { + mid = floor((lo + hi) / 2); + if (cmp(x, a[mid]) < 0) { + hi = mid; + } else { + lo = mid + 1; + } + } + return ([].splice.apply(a, [lo, lo - lo].concat(x)), x); + }; + + + /* + Push item onto heap, maintaining the heap invariant. + */ + + heappush = function(array, item, cmp) { + if (cmp == null) { + cmp = defaultCmp; + } + array.push(item); + return _siftdown(array, 0, array.length - 1, cmp); + }; + + + /* + Pop the smallest item off the heap, maintaining the heap invariant. + */ + + heappop = function(array, cmp) { + var lastelt, returnitem; + if (cmp == null) { + cmp = defaultCmp; + } + lastelt = array.pop(); + if (array.length) { + returnitem = array[0]; + array[0] = lastelt; + _siftup(array, 0, cmp); + } else { + returnitem = lastelt; + } + return returnitem; + }; + + + /* + Pop and return the current smallest value, and add the new item. + + This is more efficient than heappop() followed by heappush(), and can be + more appropriate when using a fixed size heap. Note that the value + returned may be larger than item! That constrains reasonable use of + this routine unless written as part of a conditional replacement: + if item > array[0] + item = heapreplace(array, item) + */ + + heapreplace = function(array, item, cmp) { + var returnitem; + if (cmp == null) { + cmp = defaultCmp; + } + returnitem = array[0]; + array[0] = item; + _siftup(array, 0, cmp); + return returnitem; + }; + + + /* + Fast version of a heappush followed by a heappop. + */ + + heappushpop = function(array, item, cmp) { + var _ref; + if (cmp == null) { + cmp = defaultCmp; + } + if (array.length && cmp(array[0], item) < 0) { + _ref = [array[0], item], item = _ref[0], array[0] = _ref[1]; + _siftup(array, 0, cmp); + } + return item; + }; + + + /* + Transform list into a heap, in-place, in O(array.length) time. + */ + + heapify = function(array, cmp) { + var i, _i, _len, _ref1, _results, _results1; + if (cmp == null) { + cmp = defaultCmp; + } + _ref1 = (function() { + _results1 = []; + for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); } + return _results1; + }).apply(this).reverse(); + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + i = _ref1[_i]; + _results.push(_siftup(array, i, cmp)); + } + return _results; + }; + + + /* + Update the position of the given item in the heap. + This function should be called every time the item is being modified. + */ + + updateItem = function(array, item, cmp) { + var pos; + if (cmp == null) { + cmp = defaultCmp; + } + pos = array.indexOf(item); + if (pos === -1) { + return; + } + _siftdown(array, 0, pos, cmp); + return _siftup(array, pos, cmp); + }; + + + /* + Find the n largest elements in a dataset. + */ + + nlargest = function(array, n, cmp) { + var elem, result, _i, _len, _ref; + if (cmp == null) { + cmp = defaultCmp; + } + result = array.slice(0, n); + if (!result.length) { + return result; + } + heapify(result, cmp); + _ref = array.slice(n); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elem = _ref[_i]; + heappushpop(result, elem, cmp); + } + return result.sort(cmp).reverse(); + }; + + + /* + Find the n smallest elements in a dataset. + */ + + nsmallest = function(array, n, cmp) { + var elem, los, result, _i, _j, _len, _ref, _ref1, _results; + if (cmp == null) { + cmp = defaultCmp; + } + if (n * 10 <= array.length) { + result = array.slice(0, n).sort(cmp); + if (!result.length) { + return result; + } + los = result[result.length - 1]; + _ref = array.slice(n); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elem = _ref[_i]; + if (cmp(elem, los) < 0) { + insort(result, elem, 0, null, cmp); + result.pop(); + los = result[result.length - 1]; + } + } + return result; + } + heapify(array, cmp); + _results = []; + for (_j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; 0 <= _ref1 ? ++_j : --_j) { + _results.push(heappop(array, cmp)); + } + return _results; + }; + + _siftdown = function(array, startpos, pos, cmp) { + var newitem, parent, parentpos; + if (cmp == null) { + cmp = defaultCmp; + } + newitem = array[pos]; + while (pos > startpos) { + parentpos = (pos - 1) >> 1; + parent = array[parentpos]; + if (cmp(newitem, parent) < 0) { + array[pos] = parent; + pos = parentpos; + continue; + } + break; + } + return array[pos] = newitem; + }; + + _siftup = function(array, pos, cmp) { + var childpos, endpos, newitem, rightpos, startpos; + if (cmp == null) { + cmp = defaultCmp; + } + endpos = array.length; + startpos = pos; + newitem = array[pos]; + childpos = 2 * pos + 1; + while (childpos < endpos) { + rightpos = childpos + 1; + if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) { + childpos = rightpos; + } + array[pos] = array[childpos]; + pos = childpos; + childpos = 2 * pos + 1; + } + array[pos] = newitem; + return _siftdown(array, startpos, pos, cmp); + }; + + Heap = (function() { + Heap.push = heappush; + + Heap.pop = heappop; + + Heap.replace = heapreplace; + + Heap.pushpop = heappushpop; + + Heap.heapify = heapify; + + Heap.updateItem = updateItem; + + Heap.nlargest = nlargest; + + Heap.nsmallest = nsmallest; + + function Heap(cmp) { + this.cmp = cmp != null ? cmp : defaultCmp; + this.nodes = []; + } + + Heap.prototype.push = function(x) { + return heappush(this.nodes, x, this.cmp); + }; + + Heap.prototype.pop = function() { + return heappop(this.nodes, this.cmp); + }; + + Heap.prototype.peek = function() { + return this.nodes[0]; + }; + + Heap.prototype.contains = function(x) { + return this.nodes.indexOf(x) !== -1; + }; + + Heap.prototype.replace = function(x) { + return heapreplace(this.nodes, x, this.cmp); + }; + + Heap.prototype.pushpop = function(x) { + return heappushpop(this.nodes, x, this.cmp); + }; + + Heap.prototype.heapify = function() { + return heapify(this.nodes, this.cmp); + }; + + Heap.prototype.updateItem = function(x) { + return updateItem(this.nodes, x, this.cmp); + }; + + Heap.prototype.clear = function() { + return this.nodes = []; + }; + + Heap.prototype.empty = function() { + return this.nodes.length === 0; + }; + + Heap.prototype.size = function() { + return this.nodes.length; + }; + + Heap.prototype.clone = function() { + var heap; + heap = new Heap(); + heap.nodes = this.nodes.slice(0); + return heap; + }; + + Heap.prototype.toArray = function() { + return this.nodes.slice(0); + }; + + Heap.prototype.insert = Heap.prototype.push; + + Heap.prototype.top = Heap.prototype.peek; + + Heap.prototype.front = Heap.prototype.peek; + + Heap.prototype.has = Heap.prototype.contains; + + Heap.prototype.copy = Heap.prototype.clone; + + return Heap; + + })(); + + (function(root, factory) { + { + return module.exports = factory(); + } + })(this, function() { + return Heap; + }); + +}).call(commonjsGlobal); +}); + +var heap = heap$1; + +var dijkstraDefaults = defaults$g({ + root: null, + weight: function weight(edge) { + return 1; + }, + directed: false +}); +var elesfn$u = { + dijkstra: function dijkstra(options) { + if (!plainObject(options)) { + var args = arguments; + options = { + root: args[0], + weight: args[1], + directed: args[2] + }; + } + var _dijkstraDefaults = dijkstraDefaults(options), + root = _dijkstraDefaults.root, + weight = _dijkstraDefaults.weight, + directed = _dijkstraDefaults.directed; + var eles = this; + var weightFn = weight; + var source = string(root) ? this.filter(root)[0] : root[0]; + var dist = {}; + var prev = {}; + var knownDist = {}; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + edges.unmergeBy(function (ele) { + return ele.isLoop(); + }); + var getDist = function getDist(node) { + return dist[node.id()]; + }; + var setDist = function setDist(node, d) { + dist[node.id()] = d; + Q.updateItem(node); + }; + var Q = new heap(function (a, b) { + return getDist(a) - getDist(b); + }); + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + dist[node.id()] = node.same(source) ? 0 : Infinity; + Q.push(node); + } + var distBetween = function distBetween(u, v) { + var uvs = (directed ? u.edgesTo(v) : u.edgesWith(v)).intersect(edges); + var smallestDistance = Infinity; + var smallestEdge; + for (var _i = 0; _i < uvs.length; _i++) { + var edge = uvs[_i]; + var _weight = weightFn(edge); + if (_weight < smallestDistance || !smallestEdge) { + smallestDistance = _weight; + smallestEdge = edge; + } + } + return { + edge: smallestEdge, + dist: smallestDistance + }; + }; + while (Q.size() > 0) { + var u = Q.pop(); + var smalletsDist = getDist(u); + var uid = u.id(); + knownDist[uid] = smalletsDist; + if (smalletsDist === Infinity) { + continue; + } + var neighbors = u.neighborhood().intersect(nodes); + for (var _i2 = 0; _i2 < neighbors.length; _i2++) { + var v = neighbors[_i2]; + var vid = v.id(); + var vDist = distBetween(u, v); + var alt = smalletsDist + vDist.dist; + if (alt < getDist(v)) { + setDist(v, alt); + prev[vid] = { + node: u, + edge: vDist.edge + }; + } + } // for + } // while + + return { + distanceTo: function distanceTo(node) { + var target = string(node) ? nodes.filter(node)[0] : node[0]; + return knownDist[target.id()]; + }, + pathTo: function pathTo(node) { + var target = string(node) ? nodes.filter(node)[0] : node[0]; + var S = []; + var u = target; + var uid = u.id(); + if (target.length > 0) { + S.unshift(target); + while (prev[uid]) { + var p = prev[uid]; + S.unshift(p.edge); + S.unshift(p.node); + u = p.node; + uid = u.id(); + } + } + return eles.spawn(S); + } + }; + } +}; + +var elesfn$t = { + // kruskal's algorithm (finds min spanning tree, assuming undirected graph) + // implemented from pseudocode from wikipedia + kruskal: function kruskal(weightFn) { + weightFn = weightFn || function (edge) { + return 1; + }; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var numNodes = nodes.length; + var forest = new Array(numNodes); + var A = nodes; // assumes byGroup() creates new collections that can be safely mutated + + var findSetIndex = function findSetIndex(ele) { + for (var i = 0; i < forest.length; i++) { + var eles = forest[i]; + if (eles.has(ele)) { + return i; + } + } + }; + + // start with one forest per node + for (var i = 0; i < numNodes; i++) { + forest[i] = this.spawn(nodes[i]); + } + var S = edges.sort(function (a, b) { + return weightFn(a) - weightFn(b); + }); + for (var _i = 0; _i < S.length; _i++) { + var edge = S[_i]; + var u = edge.source()[0]; + var v = edge.target()[0]; + var setUIndex = findSetIndex(u); + var setVIndex = findSetIndex(v); + var setU = forest[setUIndex]; + var setV = forest[setVIndex]; + if (setUIndex !== setVIndex) { + A.merge(edge); + + // combine forests for u and v + setU.merge(setV); + forest.splice(setVIndex, 1); + } + } + return A; + } +}; + +var aStarDefaults = defaults$g({ + root: null, + goal: null, + weight: function weight(edge) { + return 1; + }, + heuristic: function heuristic(edge) { + return 0; + }, + directed: false +}); +var elesfn$s = { + // Implemented from pseudocode from wikipedia + aStar: function aStar(options) { + var cy = this.cy(); + var _aStarDefaults = aStarDefaults(options), + root = _aStarDefaults.root, + goal = _aStarDefaults.goal, + heuristic = _aStarDefaults.heuristic, + directed = _aStarDefaults.directed, + weight = _aStarDefaults.weight; + root = cy.collection(root)[0]; + goal = cy.collection(goal)[0]; + var sid = root.id(); + var tid = goal.id(); + var gScore = {}; + var fScore = {}; + var closedSetIds = {}; + var openSet = new heap(function (a, b) { + return fScore[a.id()] - fScore[b.id()]; + }); + var openSetIds = new Set$1(); + var cameFrom = {}; + var cameFromEdge = {}; + var addToOpenSet = function addToOpenSet(ele, id) { + openSet.push(ele); + openSetIds.add(id); + }; + var cMin, cMinId; + var popFromOpenSet = function popFromOpenSet() { + cMin = openSet.pop(); + cMinId = cMin.id(); + openSetIds["delete"](cMinId); + }; + var isInOpenSet = function isInOpenSet(id) { + return openSetIds.has(id); + }; + addToOpenSet(root, sid); + gScore[sid] = 0; + fScore[sid] = heuristic(root); + + // Counter + var steps = 0; + + // Main loop + while (openSet.size() > 0) { + popFromOpenSet(); + steps++; + + // If we've found our goal, then we are done + if (cMinId === tid) { + var path = []; + var pathNode = goal; + var pathNodeId = tid; + var pathEdge = cameFromEdge[pathNodeId]; + for (;;) { + path.unshift(pathNode); + if (pathEdge != null) { + path.unshift(pathEdge); + } + pathNode = cameFrom[pathNodeId]; + if (pathNode == null) { + break; + } + pathNodeId = pathNode.id(); + pathEdge = cameFromEdge[pathNodeId]; + } + return { + found: true, + distance: gScore[cMinId], + path: this.spawn(path), + steps: steps + }; + } + + // Add cMin to processed nodes + closedSetIds[cMinId] = true; + + // Update scores for neighbors of cMin + // Take into account if graph is directed or not + var vwEdges = cMin._private.edges; + for (var i = 0; i < vwEdges.length; i++) { + var e = vwEdges[i]; + + // edge must be in set of calling eles + if (!this.hasElementWithId(e.id())) { + continue; + } + + // cMin must be the source of edge if directed + if (directed && e.data('source') !== cMinId) { + continue; + } + var wSrc = e.source(); + var wTgt = e.target(); + var w = wSrc.id() !== cMinId ? wSrc : wTgt; + var wid = w.id(); + + // node must be in set of calling eles + if (!this.hasElementWithId(wid)) { + continue; + } + + // if node is in closedSet, ignore it + if (closedSetIds[wid]) { + continue; + } + + // New tentative score for node w + var tempScore = gScore[cMinId] + weight(e); + + // Update gScore for node w if: + // w not present in openSet + // OR + // tentative gScore is less than previous value + + // w not in openSet + if (!isInOpenSet(wid)) { + gScore[wid] = tempScore; + fScore[wid] = tempScore + heuristic(w); + addToOpenSet(w, wid); + cameFrom[wid] = cMin; + cameFromEdge[wid] = e; + continue; + } + + // w already in openSet, but with greater gScore + if (tempScore < gScore[wid]) { + gScore[wid] = tempScore; + fScore[wid] = tempScore + heuristic(w); + cameFrom[wid] = cMin; + cameFromEdge[wid] = e; + } + } // End of neighbors update + } // End of main loop + + // If we've reached here, then we've not reached our goal + return { + found: false, + distance: undefined, + path: undefined, + steps: steps + }; + } +}; // elesfn + +var floydWarshallDefaults = defaults$g({ + weight: function weight(edge) { + return 1; + }, + directed: false +}); +var elesfn$r = { + // Implemented from pseudocode from wikipedia + floydWarshall: function floydWarshall(options) { + var cy = this.cy(); + var _floydWarshallDefault = floydWarshallDefaults(options), + weight = _floydWarshallDefault.weight, + directed = _floydWarshallDefault.directed; + var weightFn = weight; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var N = nodes.length; + var Nsq = N * N; + var indexOf = function indexOf(node) { + return nodes.indexOf(node); + }; + var atIndex = function atIndex(i) { + return nodes[i]; + }; + + // Initialize distance matrix + var dist = new Array(Nsq); + for (var n = 0; n < Nsq; n++) { + var j = n % N; + var i = (n - j) / N; + if (i === j) { + dist[n] = 0; + } else { + dist[n] = Infinity; + } + } + + // Initialize matrix used for path reconstruction + // Initialize distance matrix + var next = new Array(Nsq); + var edgeNext = new Array(Nsq); + + // Process edges + for (var _i = 0; _i < edges.length; _i++) { + var edge = edges[_i]; + var src = edge.source()[0]; + var tgt = edge.target()[0]; + if (src === tgt) { + continue; + } // exclude loops + + var s = indexOf(src); + var t = indexOf(tgt); + var st = s * N + t; // source to target index + var _weight = weightFn(edge); + + // Check if already process another edge between same 2 nodes + if (dist[st] > _weight) { + dist[st] = _weight; + next[st] = t; + edgeNext[st] = edge; + } + + // If undirected graph, process 'reversed' edge + if (!directed) { + var ts = t * N + s; // target to source index + + if (!directed && dist[ts] > _weight) { + dist[ts] = _weight; + next[ts] = s; + edgeNext[ts] = edge; + } + } + } + + // Main loop + for (var k = 0; k < N; k++) { + for (var _i2 = 0; _i2 < N; _i2++) { + var ik = _i2 * N + k; + for (var _j = 0; _j < N; _j++) { + var ij = _i2 * N + _j; + var kj = k * N + _j; + if (dist[ik] + dist[kj] < dist[ij]) { + dist[ij] = dist[ik] + dist[kj]; + next[ij] = next[ik]; + } + } + } + } + var getArgEle = function getArgEle(ele) { + return (string(ele) ? cy.filter(ele) : ele)[0]; + }; + var indexOfArgEle = function indexOfArgEle(ele) { + return indexOf(getArgEle(ele)); + }; + var res = { + distance: function distance(from, to) { + var i = indexOfArgEle(from); + var j = indexOfArgEle(to); + return dist[i * N + j]; + }, + path: function path(from, to) { + var i = indexOfArgEle(from); + var j = indexOfArgEle(to); + var fromNode = atIndex(i); + if (i === j) { + return fromNode.collection(); + } + if (next[i * N + j] == null) { + return cy.collection(); + } + var path = cy.collection(); + var prev = i; + var edge; + path.merge(fromNode); + while (i !== j) { + prev = i; + i = next[i * N + j]; + edge = edgeNext[prev * N + i]; + path.merge(edge); + path.merge(atIndex(i)); + } + return path; + } + }; + return res; + } // floydWarshall +}; // elesfn + +var bellmanFordDefaults = defaults$g({ + weight: function weight(edge) { + return 1; + }, + directed: false, + root: null +}); +var elesfn$q = { + // Implemented from pseudocode from wikipedia + bellmanFord: function bellmanFord(options) { + var _this = this; + var _bellmanFordDefaults = bellmanFordDefaults(options), + weight = _bellmanFordDefaults.weight, + directed = _bellmanFordDefaults.directed, + root = _bellmanFordDefaults.root; + var weightFn = weight; + var eles = this; + var cy = this.cy(); + var _this$byGroup = this.byGroup(), + edges = _this$byGroup.edges, + nodes = _this$byGroup.nodes; + var numNodes = nodes.length; + var infoMap = new Map$2(); + var hasNegativeWeightCycle = false; + var negativeWeightCycles = []; + root = cy.collection(root)[0]; // in case selector passed + + edges.unmergeBy(function (edge) { + return edge.isLoop(); + }); + var numEdges = edges.length; + var getInfo = function getInfo(node) { + var obj = infoMap.get(node.id()); + if (!obj) { + obj = {}; + infoMap.set(node.id(), obj); + } + return obj; + }; + var getNodeFromTo = function getNodeFromTo(to) { + return (string(to) ? cy.$(to) : to)[0]; + }; + var distanceTo = function distanceTo(to) { + return getInfo(getNodeFromTo(to)).dist; + }; + var pathTo = function pathTo(to) { + var thisStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : root; + var end = getNodeFromTo(to); + var path = []; + var node = end; + for (;;) { + if (node == null) { + return _this.spawn(); + } + var _getInfo = getInfo(node), + edge = _getInfo.edge, + pred = _getInfo.pred; + path.unshift(node[0]); + if (node.same(thisStart) && path.length > 0) { + break; + } + if (edge != null) { + path.unshift(edge); + } + node = pred; + } + return eles.spawn(path); + }; + + // Initializations { dist, pred, edge } + for (var i = 0; i < numNodes; i++) { + var node = nodes[i]; + var info = getInfo(node); + if (node.same(root)) { + info.dist = 0; + } else { + info.dist = Infinity; + } + info.pred = null; + info.edge = null; + } + + // Edges relaxation + var replacedEdge = false; + var checkForEdgeReplacement = function checkForEdgeReplacement(node1, node2, edge, info1, info2, weight) { + var dist = info1.dist + weight; + if (dist < info2.dist && !edge.same(info1.edge)) { + info2.dist = dist; + info2.pred = node1; + info2.edge = edge; + replacedEdge = true; + } + }; + for (var _i = 1; _i < numNodes; _i++) { + replacedEdge = false; + for (var e = 0; e < numEdges; e++) { + var edge = edges[e]; + var src = edge.source(); + var tgt = edge.target(); + var _weight = weightFn(edge); + var srcInfo = getInfo(src); + var tgtInfo = getInfo(tgt); + checkForEdgeReplacement(src, tgt, edge, srcInfo, tgtInfo, _weight); + + // If undirected graph, we need to take into account the 'reverse' edge + if (!directed) { + checkForEdgeReplacement(tgt, src, edge, tgtInfo, srcInfo, _weight); + } + } + if (!replacedEdge) { + break; + } + } + if (replacedEdge) { + // Check for negative weight cycles + var negativeWeightCycleIds = []; + for (var _e = 0; _e < numEdges; _e++) { + var _edge = edges[_e]; + var _src = _edge.source(); + var _tgt = _edge.target(); + var _weight2 = weightFn(_edge); + var srcDist = getInfo(_src).dist; + var tgtDist = getInfo(_tgt).dist; + if (srcDist + _weight2 < tgtDist || !directed && tgtDist + _weight2 < srcDist) { + if (!hasNegativeWeightCycle) { + warn('Graph contains a negative weight cycle for Bellman-Ford'); + hasNegativeWeightCycle = true; + } + if (options.findNegativeWeightCycles !== false) { + var negativeNodes = []; + if (srcDist + _weight2 < tgtDist) { + negativeNodes.push(_src); + } + if (!directed && tgtDist + _weight2 < srcDist) { + negativeNodes.push(_tgt); + } + var numNegativeNodes = negativeNodes.length; + for (var n = 0; n < numNegativeNodes; n++) { + var start = negativeNodes[n]; + var cycle = [start]; + cycle.push(getInfo(start).edge); + var _node = getInfo(start).pred; + while (cycle.indexOf(_node) === -1) { + cycle.push(_node); + cycle.push(getInfo(_node).edge); + _node = getInfo(_node).pred; + } + cycle = cycle.slice(cycle.indexOf(_node)); + var smallestId = cycle[0].id(); + var smallestIndex = 0; + for (var c = 2; c < cycle.length; c += 2) { + if (cycle[c].id() < smallestId) { + smallestId = cycle[c].id(); + smallestIndex = c; + } + } + cycle = cycle.slice(smallestIndex).concat(cycle.slice(0, smallestIndex)); + cycle.push(cycle[0]); + var cycleId = cycle.map(function (el) { + return el.id(); + }).join(","); + if (negativeWeightCycleIds.indexOf(cycleId) === -1) { + negativeWeightCycles.push(eles.spawn(cycle)); + negativeWeightCycleIds.push(cycleId); + } + } + } else { + break; + } + } + } + } + return { + distanceTo: distanceTo, + pathTo: pathTo, + hasNegativeWeightCycle: hasNegativeWeightCycle, + negativeWeightCycles: negativeWeightCycles + }; + } // bellmanFord +}; // elesfn + +var sqrt2 = Math.sqrt(2); + +// Function which colapses 2 (meta) nodes into one +// Updates the remaining edge lists +// Receives as a paramater the edge which causes the collapse +var collapse = function collapse(edgeIndex, nodeMap, remainingEdges) { + if (remainingEdges.length === 0) { + error("Karger-Stein must be run on a connected (sub)graph"); + } + var edgeInfo = remainingEdges[edgeIndex]; + var sourceIn = edgeInfo[1]; + var targetIn = edgeInfo[2]; + var partition1 = nodeMap[sourceIn]; + var partition2 = nodeMap[targetIn]; + var newEdges = remainingEdges; // re-use array + + // Delete all edges between partition1 and partition2 + for (var i = newEdges.length - 1; i >= 0; i--) { + var edge = newEdges[i]; + var src = edge[1]; + var tgt = edge[2]; + if (nodeMap[src] === partition1 && nodeMap[tgt] === partition2 || nodeMap[src] === partition2 && nodeMap[tgt] === partition1) { + newEdges.splice(i, 1); + } + } + + // All edges pointing to partition2 should now point to partition1 + for (var _i = 0; _i < newEdges.length; _i++) { + var _edge = newEdges[_i]; + if (_edge[1] === partition2) { + // Check source + newEdges[_i] = _edge.slice(); // copy + newEdges[_i][1] = partition1; + } else if (_edge[2] === partition2) { + // Check target + newEdges[_i] = _edge.slice(); // copy + newEdges[_i][2] = partition1; + } + } + + // Move all nodes from partition2 to partition1 + for (var _i2 = 0; _i2 < nodeMap.length; _i2++) { + if (nodeMap[_i2] === partition2) { + nodeMap[_i2] = partition1; + } + } + return newEdges; +}; + +// Contracts a graph until we reach a certain number of meta nodes +var contractUntil = function contractUntil(metaNodeMap, remainingEdges, size, sizeLimit) { + while (size > sizeLimit) { + // Choose an edge randomly + var edgeIndex = Math.floor(Math.random() * remainingEdges.length); + + // Collapse graph based on edge + remainingEdges = collapse(edgeIndex, metaNodeMap, remainingEdges); + size--; + } + return remainingEdges; +}; +var elesfn$p = { + // Computes the minimum cut of an undirected graph + // Returns the correct answer with high probability + kargerStein: function kargerStein() { + var _this = this; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + edges.unmergeBy(function (edge) { + return edge.isLoop(); + }); + var numNodes = nodes.length; + var numEdges = edges.length; + var numIter = Math.ceil(Math.pow(Math.log(numNodes) / Math.LN2, 2)); + var stopSize = Math.floor(numNodes / sqrt2); + if (numNodes < 2) { + error('At least 2 nodes are required for Karger-Stein algorithm'); + return undefined; + } + + // Now store edge destination as indexes + // Format for each edge (edge index, source node index, target node index) + var edgeIndexes = []; + for (var i = 0; i < numEdges; i++) { + var e = edges[i]; + edgeIndexes.push([i, nodes.indexOf(e.source()), nodes.indexOf(e.target())]); + } + + // We will store the best cut found here + var minCutSize = Infinity; + var minCutEdgeIndexes = []; + var minCutNodeMap = new Array(numNodes); + + // Initial meta node partition + var metaNodeMap = new Array(numNodes); + var metaNodeMap2 = new Array(numNodes); + var copyNodesMap = function copyNodesMap(from, to) { + for (var _i3 = 0; _i3 < numNodes; _i3++) { + to[_i3] = from[_i3]; + } + }; + + // Main loop + for (var iter = 0; iter <= numIter; iter++) { + // Reset meta node partition + for (var _i4 = 0; _i4 < numNodes; _i4++) { + metaNodeMap[_i4] = _i4; + } + + // Contract until stop point (stopSize nodes) + var edgesState = contractUntil(metaNodeMap, edgeIndexes.slice(), numNodes, stopSize); + var edgesState2 = edgesState.slice(); // copy + + // Create a copy of the colapsed nodes state + copyNodesMap(metaNodeMap, metaNodeMap2); + + // Run 2 iterations starting in the stop state + var res1 = contractUntil(metaNodeMap, edgesState, stopSize, 2); + var res2 = contractUntil(metaNodeMap2, edgesState2, stopSize, 2); + + // Is any of the 2 results the best cut so far? + if (res1.length <= res2.length && res1.length < minCutSize) { + minCutSize = res1.length; + minCutEdgeIndexes = res1; + copyNodesMap(metaNodeMap, minCutNodeMap); + } else if (res2.length <= res1.length && res2.length < minCutSize) { + minCutSize = res2.length; + minCutEdgeIndexes = res2; + copyNodesMap(metaNodeMap2, minCutNodeMap); + } + } // end of main loop + + // Construct result + var cut = this.spawn(minCutEdgeIndexes.map(function (e) { + return edges[e[0]]; + })); + var partition1 = this.spawn(); + var partition2 = this.spawn(); + + // traverse metaNodeMap for best cut + var witnessNodePartition = minCutNodeMap[0]; + for (var _i5 = 0; _i5 < minCutNodeMap.length; _i5++) { + var partitionId = minCutNodeMap[_i5]; + var node = nodes[_i5]; + if (partitionId === witnessNodePartition) { + partition1.merge(node); + } else { + partition2.merge(node); + } + } + + // construct components corresponding to each disjoint subset of nodes + var constructComponent = function constructComponent(subset) { + var component = _this.spawn(); + subset.forEach(function (node) { + component.merge(node); + node.connectedEdges().forEach(function (edge) { + // ensure edge is within calling collection and edge is not in cut + if (_this.contains(edge) && !cut.contains(edge)) { + component.merge(edge); + } + }); + }); + return component; + }; + var components = [constructComponent(partition1), constructComponent(partition2)]; + var ret = { + cut: cut, + components: components, + // n.b. partitions are included to be compatible with the old api spec + // (could be removed in a future major version) + partition1: partition1, + partition2: partition2 + }; + return ret; + } +}; // elesfn + +var copyPosition = function copyPosition(p) { + return { + x: p.x, + y: p.y + }; +}; +var modelToRenderedPosition = function modelToRenderedPosition(p, zoom, pan) { + return { + x: p.x * zoom + pan.x, + y: p.y * zoom + pan.y + }; +}; +var renderedToModelPosition = function renderedToModelPosition(p, zoom, pan) { + return { + x: (p.x - pan.x) / zoom, + y: (p.y - pan.y) / zoom + }; +}; +var array2point = function array2point(arr) { + return { + x: arr[0], + y: arr[1] + }; +}; +var min$1 = function min(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var min = Infinity; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + min = Math.min(val, min); + } + } + return min; +}; +var max$1 = function max(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var max = -Infinity; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + max = Math.max(val, max); + } + } + return max; +}; +var mean = function mean(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var total = 0; + var n = 0; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + total += val; + n++; + } + } + return total / n; +}; +var median = function median(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var copy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var sort = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var includeHoles = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + if (copy) { + arr = arr.slice(begin, end); + } else { + if (end < arr.length) { + arr.splice(end, arr.length - end); + } + if (begin > 0) { + arr.splice(0, begin); + } + } + + // all non finite (e.g. Infinity, NaN) elements must be -Infinity so they go to the start + var off = 0; // offset from non-finite values + for (var i = arr.length - 1; i >= 0; i--) { + var v = arr[i]; + if (includeHoles) { + if (!isFinite(v)) { + arr[i] = -Infinity; + off++; + } + } else { + // just remove it if we don't want to consider holes + arr.splice(i, 1); + } + } + if (sort) { + arr.sort(function (a, b) { + return a - b; + }); // requires copy = true if you don't want to change the orig + } + + var len = arr.length; + var mid = Math.floor(len / 2); + if (len % 2 !== 0) { + return arr[mid + 1 + off]; + } else { + return (arr[mid - 1 + off] + arr[mid + off]) / 2; + } +}; +var deg2rad = function deg2rad(deg) { + return Math.PI * deg / 180; +}; +var getAngleFromDisp = function getAngleFromDisp(dispX, dispY) { + return Math.atan2(dispY, dispX) - Math.PI / 2; +}; +var log2 = Math.log2 || function (n) { + return Math.log(n) / Math.log(2); +}; +var signum = function signum(x) { + if (x > 0) { + return 1; + } else if (x < 0) { + return -1; + } else { + return 0; + } +}; +var dist = function dist(p1, p2) { + return Math.sqrt(sqdist(p1, p2)); +}; +var sqdist = function sqdist(p1, p2) { + var dx = p2.x - p1.x; + var dy = p2.y - p1.y; + return dx * dx + dy * dy; +}; +var inPlaceSumNormalize = function inPlaceSumNormalize(v) { + var length = v.length; + + // First, get sum of all elements + var total = 0; + for (var i = 0; i < length; i++) { + total += v[i]; + } + + // Now, divide each by the sum of all elements + for (var _i = 0; _i < length; _i++) { + v[_i] = v[_i] / total; + } + return v; +}; + +// from http://en.wikipedia.org/wiki/Bézier_curve#Quadratic_curves +var qbezierAt = function qbezierAt(p0, p1, p2, t) { + return (1 - t) * (1 - t) * p0 + 2 * (1 - t) * t * p1 + t * t * p2; +}; +var qbezierPtAt = function qbezierPtAt(p0, p1, p2, t) { + return { + x: qbezierAt(p0.x, p1.x, p2.x, t), + y: qbezierAt(p0.y, p1.y, p2.y, t) + }; +}; +var lineAt = function lineAt(p0, p1, t, d) { + var vec = { + x: p1.x - p0.x, + y: p1.y - p0.y + }; + var vecDist = dist(p0, p1); + var normVec = { + x: vec.x / vecDist, + y: vec.y / vecDist + }; + t = t == null ? 0 : t; + d = d != null ? d : t * vecDist; + return { + x: p0.x + normVec.x * d, + y: p0.y + normVec.y * d + }; +}; +var bound = function bound(min, val, max) { + return Math.max(min, Math.min(max, val)); +}; + +// makes a full bb (x1, y1, x2, y2, w, h) from implicit params +var makeBoundingBox = function makeBoundingBox(bb) { + if (bb == null) { + return { + x1: Infinity, + y1: Infinity, + x2: -Infinity, + y2: -Infinity, + w: 0, + h: 0 + }; + } else if (bb.x1 != null && bb.y1 != null) { + if (bb.x2 != null && bb.y2 != null && bb.x2 >= bb.x1 && bb.y2 >= bb.y1) { + return { + x1: bb.x1, + y1: bb.y1, + x2: bb.x2, + y2: bb.y2, + w: bb.x2 - bb.x1, + h: bb.y2 - bb.y1 + }; + } else if (bb.w != null && bb.h != null && bb.w >= 0 && bb.h >= 0) { + return { + x1: bb.x1, + y1: bb.y1, + x2: bb.x1 + bb.w, + y2: bb.y1 + bb.h, + w: bb.w, + h: bb.h + }; + } + } +}; +var copyBoundingBox = function copyBoundingBox(bb) { + return { + x1: bb.x1, + x2: bb.x2, + w: bb.w, + y1: bb.y1, + y2: bb.y2, + h: bb.h + }; +}; +var clearBoundingBox = function clearBoundingBox(bb) { + bb.x1 = Infinity; + bb.y1 = Infinity; + bb.x2 = -Infinity; + bb.y2 = -Infinity; + bb.w = 0; + bb.h = 0; +}; +var shiftBoundingBox = function shiftBoundingBox(bb, dx, dy) { + return { + x1: bb.x1 + dx, + x2: bb.x2 + dx, + y1: bb.y1 + dy, + y2: bb.y2 + dy, + w: bb.w, + h: bb.h + }; +}; +var updateBoundingBox = function updateBoundingBox(bb1, bb2) { + // update bb1 with bb2 bounds + + bb1.x1 = Math.min(bb1.x1, bb2.x1); + bb1.x2 = Math.max(bb1.x2, bb2.x2); + bb1.w = bb1.x2 - bb1.x1; + bb1.y1 = Math.min(bb1.y1, bb2.y1); + bb1.y2 = Math.max(bb1.y2, bb2.y2); + bb1.h = bb1.y2 - bb1.y1; +}; +var expandBoundingBoxByPoint = function expandBoundingBoxByPoint(bb, x, y) { + bb.x1 = Math.min(bb.x1, x); + bb.x2 = Math.max(bb.x2, x); + bb.w = bb.x2 - bb.x1; + bb.y1 = Math.min(bb.y1, y); + bb.y2 = Math.max(bb.y2, y); + bb.h = bb.y2 - bb.y1; +}; +var expandBoundingBox = function expandBoundingBox(bb) { + var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + bb.x1 -= padding; + bb.x2 += padding; + bb.y1 -= padding; + bb.y2 += padding; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + return bb; +}; +var expandBoundingBoxSides = function expandBoundingBoxSides(bb) { + var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0]; + var top, right, bottom, left; + if (padding.length === 1) { + top = right = bottom = left = padding[0]; + } else if (padding.length === 2) { + top = bottom = padding[0]; + left = right = padding[1]; + } else if (padding.length === 4) { + var _padding = _slicedToArray(padding, 4); + top = _padding[0]; + right = _padding[1]; + bottom = _padding[2]; + left = _padding[3]; + } + bb.x1 -= left; + bb.x2 += right; + bb.y1 -= top; + bb.y2 += bottom; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + return bb; +}; + +// assign the values of bb2 into bb1 +var assignBoundingBox = function assignBoundingBox(bb1, bb2) { + bb1.x1 = bb2.x1; + bb1.y1 = bb2.y1; + bb1.x2 = bb2.x2; + bb1.y2 = bb2.y2; + bb1.w = bb1.x2 - bb1.x1; + bb1.h = bb1.y2 - bb1.y1; +}; +var boundingBoxesIntersect = function boundingBoxesIntersect(bb1, bb2) { + // case: one bb to right of other + if (bb1.x1 > bb2.x2) { + return false; + } + if (bb2.x1 > bb1.x2) { + return false; + } + + // case: one bb to left of other + if (bb1.x2 < bb2.x1) { + return false; + } + if (bb2.x2 < bb1.x1) { + return false; + } + + // case: one bb above other + if (bb1.y2 < bb2.y1) { + return false; + } + if (bb2.y2 < bb1.y1) { + return false; + } + + // case: one bb below other + if (bb1.y1 > bb2.y2) { + return false; + } + if (bb2.y1 > bb1.y2) { + return false; + } + + // otherwise, must have some overlap + return true; +}; +var inBoundingBox = function inBoundingBox(bb, x, y) { + return bb.x1 <= x && x <= bb.x2 && bb.y1 <= y && y <= bb.y2; +}; +var pointInBoundingBox = function pointInBoundingBox(bb, pt) { + return inBoundingBox(bb, pt.x, pt.y); +}; +var boundingBoxInBoundingBox = function boundingBoxInBoundingBox(bb1, bb2) { + return inBoundingBox(bb1, bb2.x1, bb2.y1) && inBoundingBox(bb1, bb2.x2, bb2.y2); +}; +var roundRectangleIntersectLine = function roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding) { + var radius = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'auto'; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : radius; + var halfWidth = width / 2; + var halfHeight = height / 2; + cornerRadius = Math.min(cornerRadius, halfWidth, halfHeight); + var doWidth = cornerRadius !== halfWidth, + doHeight = cornerRadius !== halfHeight; + + // Check intersections with straight line segments + var straightLineIntersections; + + // Top segment, left to right + if (doWidth) { + var topStartX = nodeX - halfWidth + cornerRadius - padding; + var topStartY = nodeY - halfHeight - padding; + var topEndX = nodeX + halfWidth - cornerRadius + padding; + var topEndY = topStartY; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Right segment, top to bottom + if (doHeight) { + var rightStartX = nodeX + halfWidth + padding; + var rightStartY = nodeY - halfHeight + cornerRadius - padding; + var rightEndX = rightStartX; + var rightEndY = nodeY + halfHeight - cornerRadius + padding; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, rightStartX, rightStartY, rightEndX, rightEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Bottom segment, left to right + if (doWidth) { + var bottomStartX = nodeX - halfWidth + cornerRadius - padding; + var bottomStartY = nodeY + halfHeight + padding; + var bottomEndX = nodeX + halfWidth - cornerRadius + padding; + var bottomEndY = bottomStartY; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, bottomStartX, bottomStartY, bottomEndX, bottomEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Left segment, top to bottom + if (doHeight) { + var leftStartX = nodeX - halfWidth - padding; + var leftStartY = nodeY - halfHeight + cornerRadius - padding; + var leftEndX = leftStartX; + var leftEndY = nodeY + halfHeight - cornerRadius + padding; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, leftStartX, leftStartY, leftEndX, leftEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Check intersections with arc segments + var arcIntersections; + + // Top Left + { + var topLeftCenterX = nodeX - halfWidth + cornerRadius; + var topLeftCenterY = nodeY - halfHeight + cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, topLeftCenterX, topLeftCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] <= topLeftCenterX && arcIntersections[1] <= topLeftCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Top Right + { + var topRightCenterX = nodeX + halfWidth - cornerRadius; + var topRightCenterY = nodeY - halfHeight + cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, topRightCenterX, topRightCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] >= topRightCenterX && arcIntersections[1] <= topRightCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Bottom Right + { + var bottomRightCenterX = nodeX + halfWidth - cornerRadius; + var bottomRightCenterY = nodeY + halfHeight - cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, bottomRightCenterX, bottomRightCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] >= bottomRightCenterX && arcIntersections[1] >= bottomRightCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Bottom Left + { + var bottomLeftCenterX = nodeX - halfWidth + cornerRadius; + var bottomLeftCenterY = nodeY + halfHeight - cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, bottomLeftCenterX, bottomLeftCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] <= bottomLeftCenterX && arcIntersections[1] >= bottomLeftCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + return []; // if nothing +}; + +var inLineVicinity = function inLineVicinity(x, y, lx1, ly1, lx2, ly2, tolerance) { + var t = tolerance; + var x1 = Math.min(lx1, lx2); + var x2 = Math.max(lx1, lx2); + var y1 = Math.min(ly1, ly2); + var y2 = Math.max(ly1, ly2); + return x1 - t <= x && x <= x2 + t && y1 - t <= y && y <= y2 + t; +}; +var inBezierVicinity = function inBezierVicinity(x, y, x1, y1, x2, y2, x3, y3, tolerance) { + var bb = { + x1: Math.min(x1, x3, x2) - tolerance, + x2: Math.max(x1, x3, x2) + tolerance, + y1: Math.min(y1, y3, y2) - tolerance, + y2: Math.max(y1, y3, y2) + tolerance + }; + + // if outside the rough bounding box for the bezier, then it can't be a hit + if (x < bb.x1 || x > bb.x2 || y < bb.y1 || y > bb.y2) { + // console.log('bezier out of rough bb') + return false; + } else { + // console.log('do more expensive check'); + return true; + } +}; +var solveQuadratic = function solveQuadratic(a, b, c, val) { + c -= val; + var r = b * b - 4 * a * c; + if (r < 0) { + return []; + } + var sqrtR = Math.sqrt(r); + var denom = 2 * a; + var root1 = (-b + sqrtR) / denom; + var root2 = (-b - sqrtR) / denom; + return [root1, root2]; +}; +var solveCubic = function solveCubic(a, b, c, d, result) { + // Solves a cubic function, returns root in form [r1, i1, r2, i2, r3, i3], where + // r is the real component, i is the imaginary component + + // An implementation of the Cardano method from the year 1545 + // http://en.wikipedia.org/wiki/Cubic_function#The_nature_of_the_roots + + var epsilon = 0.00001; + + // avoid division by zero while keeping the overall expression close in value + if (a === 0) { + a = epsilon; + } + b /= a; + c /= a; + d /= a; + var discriminant, q, r, dum1, s, t, term1, r13; + q = (3.0 * c - b * b) / 9.0; + r = -(27.0 * d) + b * (9.0 * c - 2.0 * (b * b)); + r /= 54.0; + discriminant = q * q * q + r * r; + result[1] = 0; + term1 = b / 3.0; + if (discriminant > 0) { + s = r + Math.sqrt(discriminant); + s = s < 0 ? -Math.pow(-s, 1.0 / 3.0) : Math.pow(s, 1.0 / 3.0); + t = r - Math.sqrt(discriminant); + t = t < 0 ? -Math.pow(-t, 1.0 / 3.0) : Math.pow(t, 1.0 / 3.0); + result[0] = -term1 + s + t; + term1 += (s + t) / 2.0; + result[4] = result[2] = -term1; + term1 = Math.sqrt(3.0) * (-t + s) / 2; + result[3] = term1; + result[5] = -term1; + return; + } + result[5] = result[3] = 0; + if (discriminant === 0) { + r13 = r < 0 ? -Math.pow(-r, 1.0 / 3.0) : Math.pow(r, 1.0 / 3.0); + result[0] = -term1 + 2.0 * r13; + result[4] = result[2] = -(r13 + term1); + return; + } + q = -q; + dum1 = q * q * q; + dum1 = Math.acos(r / Math.sqrt(dum1)); + r13 = 2.0 * Math.sqrt(q); + result[0] = -term1 + r13 * Math.cos(dum1 / 3.0); + result[2] = -term1 + r13 * Math.cos((dum1 + 2.0 * Math.PI) / 3.0); + result[4] = -term1 + r13 * Math.cos((dum1 + 4.0 * Math.PI) / 3.0); + return; +}; +var sqdistToQuadraticBezier = function sqdistToQuadraticBezier(x, y, x1, y1, x2, y2, x3, y3) { + // Find minimum distance by using the minimum of the distance + // function between the given point and the curve + + // This gives the coefficients of the resulting cubic equation + // whose roots tell us where a possible minimum is + // (Coefficients are divided by 4) + + var a = 1.0 * x1 * x1 - 4 * x1 * x2 + 2 * x1 * x3 + 4 * x2 * x2 - 4 * x2 * x3 + x3 * x3 + y1 * y1 - 4 * y1 * y2 + 2 * y1 * y3 + 4 * y2 * y2 - 4 * y2 * y3 + y3 * y3; + var b = 1.0 * 9 * x1 * x2 - 3 * x1 * x1 - 3 * x1 * x3 - 6 * x2 * x2 + 3 * x2 * x3 + 9 * y1 * y2 - 3 * y1 * y1 - 3 * y1 * y3 - 6 * y2 * y2 + 3 * y2 * y3; + var c = 1.0 * 3 * x1 * x1 - 6 * x1 * x2 + x1 * x3 - x1 * x + 2 * x2 * x2 + 2 * x2 * x - x3 * x + 3 * y1 * y1 - 6 * y1 * y2 + y1 * y3 - y1 * y + 2 * y2 * y2 + 2 * y2 * y - y3 * y; + var d = 1.0 * x1 * x2 - x1 * x1 + x1 * x - x2 * x + y1 * y2 - y1 * y1 + y1 * y - y2 * y; + + // debug("coefficients: " + a / a + ", " + b / a + ", " + c / a + ", " + d / a); + + var roots = []; + + // Use the cubic solving algorithm + solveCubic(a, b, c, d, roots); + var zeroThreshold = 0.0000001; + var params = []; + for (var index = 0; index < 6; index += 2) { + if (Math.abs(roots[index + 1]) < zeroThreshold && roots[index] >= 0 && roots[index] <= 1.0) { + params.push(roots[index]); + } + } + params.push(1.0); + params.push(0.0); + var minDistanceSquared = -1; + var curX, curY, distSquared; + for (var i = 0; i < params.length; i++) { + curX = Math.pow(1.0 - params[i], 2.0) * x1 + 2.0 * (1 - params[i]) * params[i] * x2 + params[i] * params[i] * x3; + curY = Math.pow(1 - params[i], 2.0) * y1 + 2 * (1.0 - params[i]) * params[i] * y2 + params[i] * params[i] * y3; + distSquared = Math.pow(curX - x, 2) + Math.pow(curY - y, 2); + // debug('distance for param ' + params[i] + ": " + Math.sqrt(distSquared)); + if (minDistanceSquared >= 0) { + if (distSquared < minDistanceSquared) { + minDistanceSquared = distSquared; + } + } else { + minDistanceSquared = distSquared; + } + } + return minDistanceSquared; +}; +var sqdistToFiniteLine = function sqdistToFiniteLine(x, y, x1, y1, x2, y2) { + var offset = [x - x1, y - y1]; + var line = [x2 - x1, y2 - y1]; + var lineSq = line[0] * line[0] + line[1] * line[1]; + var hypSq = offset[0] * offset[0] + offset[1] * offset[1]; + var dotProduct = offset[0] * line[0] + offset[1] * line[1]; + var adjSq = dotProduct * dotProduct / lineSq; + if (dotProduct < 0) { + return hypSq; + } + if (adjSq > lineSq) { + return (x - x2) * (x - x2) + (y - y2) * (y - y2); + } + return hypSq - adjSq; +}; +var pointInsidePolygonPoints = function pointInsidePolygonPoints(x, y, points) { + var x1, y1, x2, y2; + var y3; + + // Intersect with vertical line through (x, y) + var up = 0; + // let down = 0; + for (var i = 0; i < points.length / 2; i++) { + x1 = points[i * 2]; + y1 = points[i * 2 + 1]; + if (i + 1 < points.length / 2) { + x2 = points[(i + 1) * 2]; + y2 = points[(i + 1) * 2 + 1]; + } else { + x2 = points[(i + 1 - points.length / 2) * 2]; + y2 = points[(i + 1 - points.length / 2) * 2 + 1]; + } + if (x1 == x && x2 == x) ; else if (x1 >= x && x >= x2 || x1 <= x && x <= x2) { + y3 = (x - x1) / (x2 - x1) * (y2 - y1) + y1; + if (y3 > y) { + up++; + } + + // if( y3 < y ){ + // down++; + // } + } else { + continue; + } + } + if (up % 2 === 0) { + return false; + } else { + return true; + } +}; +var pointInsidePolygon = function pointInsidePolygon(x, y, basePoints, centerX, centerY, width, height, direction, padding) { + var transformedPoints = new Array(basePoints.length); + + // Gives negative angle + var angle; + if (direction[0] != null) { + angle = Math.atan(direction[1] / direction[0]); + if (direction[0] < 0) { + angle = angle + Math.PI / 2; + } else { + angle = -angle - Math.PI / 2; + } + } else { + angle = direction; + } + var cos = Math.cos(-angle); + var sin = Math.sin(-angle); + + // console.log("base: " + basePoints); + for (var i = 0; i < transformedPoints.length / 2; i++) { + transformedPoints[i * 2] = width / 2 * (basePoints[i * 2] * cos - basePoints[i * 2 + 1] * sin); + transformedPoints[i * 2 + 1] = height / 2 * (basePoints[i * 2 + 1] * cos + basePoints[i * 2] * sin); + transformedPoints[i * 2] += centerX; + transformedPoints[i * 2 + 1] += centerY; + } + var points; + if (padding > 0) { + var expandedLineSet = expandPolygon(transformedPoints, -padding); + points = joinLines(expandedLineSet); + } else { + points = transformedPoints; + } + return pointInsidePolygonPoints(x, y, points); +}; +var pointInsideRoundPolygon = function pointInsideRoundPolygon(x, y, basePoints, centerX, centerY, width, height, corners) { + var cutPolygonPoints = new Array(basePoints.length * 2); + for (var i = 0; i < corners.length; i++) { + var corner = corners[i]; + cutPolygonPoints[i * 4 + 0] = corner.startX; + cutPolygonPoints[i * 4 + 1] = corner.startY; + cutPolygonPoints[i * 4 + 2] = corner.stopX; + cutPolygonPoints[i * 4 + 3] = corner.stopY; + var squaredDistance = Math.pow(corner.cx - x, 2) + Math.pow(corner.cy - y, 2); + if (squaredDistance <= Math.pow(corner.radius, 2)) { + return true; + } + } + return pointInsidePolygonPoints(x, y, cutPolygonPoints); +}; +var joinLines = function joinLines(lineSet) { + var vertices = new Array(lineSet.length / 2); + var currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY; + var nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY; + for (var i = 0; i < lineSet.length / 4; i++) { + currentLineStartX = lineSet[i * 4]; + currentLineStartY = lineSet[i * 4 + 1]; + currentLineEndX = lineSet[i * 4 + 2]; + currentLineEndY = lineSet[i * 4 + 3]; + if (i < lineSet.length / 4 - 1) { + nextLineStartX = lineSet[(i + 1) * 4]; + nextLineStartY = lineSet[(i + 1) * 4 + 1]; + nextLineEndX = lineSet[(i + 1) * 4 + 2]; + nextLineEndY = lineSet[(i + 1) * 4 + 3]; + } else { + nextLineStartX = lineSet[0]; + nextLineStartY = lineSet[1]; + nextLineEndX = lineSet[2]; + nextLineEndY = lineSet[3]; + } + var intersection = finiteLinesIntersect(currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY, nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY, true); + vertices[i * 2] = intersection[0]; + vertices[i * 2 + 1] = intersection[1]; + } + return vertices; +}; +var expandPolygon = function expandPolygon(points, pad) { + var expandedLineSet = new Array(points.length * 2); + var currentPointX, currentPointY, nextPointX, nextPointY; + for (var i = 0; i < points.length / 2; i++) { + currentPointX = points[i * 2]; + currentPointY = points[i * 2 + 1]; + if (i < points.length / 2 - 1) { + nextPointX = points[(i + 1) * 2]; + nextPointY = points[(i + 1) * 2 + 1]; + } else { + nextPointX = points[0]; + nextPointY = points[1]; + } + + // Current line: [currentPointX, currentPointY] to [nextPointX, nextPointY] + + // Assume CCW polygon winding + + var offsetX = nextPointY - currentPointY; + var offsetY = -(nextPointX - currentPointX); + + // Normalize + var offsetLength = Math.sqrt(offsetX * offsetX + offsetY * offsetY); + var normalizedOffsetX = offsetX / offsetLength; + var normalizedOffsetY = offsetY / offsetLength; + expandedLineSet[i * 4] = currentPointX + normalizedOffsetX * pad; + expandedLineSet[i * 4 + 1] = currentPointY + normalizedOffsetY * pad; + expandedLineSet[i * 4 + 2] = nextPointX + normalizedOffsetX * pad; + expandedLineSet[i * 4 + 3] = nextPointY + normalizedOffsetY * pad; + } + return expandedLineSet; +}; +var intersectLineEllipse = function intersectLineEllipse(x, y, centerX, centerY, ellipseWradius, ellipseHradius) { + var dispX = centerX - x; + var dispY = centerY - y; + dispX /= ellipseWradius; + dispY /= ellipseHradius; + var len = Math.sqrt(dispX * dispX + dispY * dispY); + var newLength = len - 1; + if (newLength < 0) { + return []; + } + var lenProportion = newLength / len; + return [(centerX - x) * lenProportion + x, (centerY - y) * lenProportion + y]; +}; +var checkInEllipse = function checkInEllipse(x, y, width, height, centerX, centerY, padding) { + x -= centerX; + y -= centerY; + x /= width / 2 + padding; + y /= height / 2 + padding; + return x * x + y * y <= 1; +}; + +// Returns intersections of increasing distance from line's start point +var intersectLineCircle = function intersectLineCircle(x1, y1, x2, y2, centerX, centerY, radius) { + // Calculate d, direction vector of line + var d = [x2 - x1, y2 - y1]; // Direction vector of line + var f = [x1 - centerX, y1 - centerY]; + var a = d[0] * d[0] + d[1] * d[1]; + var b = 2 * (f[0] * d[0] + f[1] * d[1]); + var c = f[0] * f[0] + f[1] * f[1] - radius * radius; + var discriminant = b * b - 4 * a * c; + if (discriminant < 0) { + return []; + } + var t1 = (-b + Math.sqrt(discriminant)) / (2 * a); + var t2 = (-b - Math.sqrt(discriminant)) / (2 * a); + var tMin = Math.min(t1, t2); + var tMax = Math.max(t1, t2); + var inRangeParams = []; + if (tMin >= 0 && tMin <= 1) { + inRangeParams.push(tMin); + } + if (tMax >= 0 && tMax <= 1) { + inRangeParams.push(tMax); + } + if (inRangeParams.length === 0) { + return []; + } + var nearIntersectionX = inRangeParams[0] * d[0] + x1; + var nearIntersectionY = inRangeParams[0] * d[1] + y1; + if (inRangeParams.length > 1) { + if (inRangeParams[0] == inRangeParams[1]) { + return [nearIntersectionX, nearIntersectionY]; + } else { + var farIntersectionX = inRangeParams[1] * d[0] + x1; + var farIntersectionY = inRangeParams[1] * d[1] + y1; + return [nearIntersectionX, nearIntersectionY, farIntersectionX, farIntersectionY]; + } + } else { + return [nearIntersectionX, nearIntersectionY]; + } +}; +var midOfThree = function midOfThree(a, b, c) { + if (b <= a && a <= c || c <= a && a <= b) { + return a; + } else if (a <= b && b <= c || c <= b && b <= a) { + return b; + } else { + return c; + } +}; + +// (x1,y1)=>(x2,y2) intersect with (x3,y3)=>(x4,y4) +var finiteLinesIntersect = function finiteLinesIntersect(x1, y1, x2, y2, x3, y3, x4, y4, infiniteLines) { + var dx13 = x1 - x3; + var dx21 = x2 - x1; + var dx43 = x4 - x3; + var dy13 = y1 - y3; + var dy21 = y2 - y1; + var dy43 = y4 - y3; + var ua_t = dx43 * dy13 - dy43 * dx13; + var ub_t = dx21 * dy13 - dy21 * dx13; + var u_b = dy43 * dx21 - dx43 * dy21; + if (u_b !== 0) { + var ua = ua_t / u_b; + var ub = ub_t / u_b; + var flptThreshold = 0.001; + var _min = 0 - flptThreshold; + var _max = 1 + flptThreshold; + if (_min <= ua && ua <= _max && _min <= ub && ub <= _max) { + return [x1 + ua * dx21, y1 + ua * dy21]; + } else { + if (!infiniteLines) { + return []; + } else { + return [x1 + ua * dx21, y1 + ua * dy21]; + } + } + } else { + if (ua_t === 0 || ub_t === 0) { + // Parallel, coincident lines. Check if overlap + + // Check endpoint of second line + if (midOfThree(x1, x2, x4) === x4) { + return [x4, y4]; + } + + // Check start point of second line + if (midOfThree(x1, x2, x3) === x3) { + return [x3, y3]; + } + + // Endpoint of first line + if (midOfThree(x3, x4, x2) === x2) { + return [x2, y2]; + } + return []; + } else { + // Parallel, non-coincident + return []; + } + } +}; + +// math.polygonIntersectLine( x, y, basePoints, centerX, centerY, width, height, padding ) +// intersect a node polygon (pts transformed) +// +// math.polygonIntersectLine( x, y, basePoints, centerX, centerY ) +// intersect the points (no transform) +var polygonIntersectLine = function polygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding) { + var intersections = []; + var intersection; + var transformedPoints = new Array(basePoints.length); + var doTransform = true; + if (width == null) { + doTransform = false; + } + var points; + if (doTransform) { + for (var i = 0; i < transformedPoints.length / 2; i++) { + transformedPoints[i * 2] = basePoints[i * 2] * width + centerX; + transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY; + } + if (padding > 0) { + var expandedLineSet = expandPolygon(transformedPoints, -padding); + points = joinLines(expandedLineSet); + } else { + points = transformedPoints; + } + } else { + points = basePoints; + } + var currentX, currentY, nextX, nextY; + for (var _i2 = 0; _i2 < points.length / 2; _i2++) { + currentX = points[_i2 * 2]; + currentY = points[_i2 * 2 + 1]; + if (_i2 < points.length / 2 - 1) { + nextX = points[(_i2 + 1) * 2]; + nextY = points[(_i2 + 1) * 2 + 1]; + } else { + nextX = points[0]; + nextY = points[1]; + } + intersection = finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + } + return intersections; +}; +var roundPolygonIntersectLine = function roundPolygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding, corners) { + var intersections = []; + var intersection; + var lines = new Array(basePoints.length * 2); + corners.forEach(function (corner, i) { + if (i === 0) { + lines[lines.length - 2] = corner.startX; + lines[lines.length - 1] = corner.startY; + } else { + lines[i * 4 - 2] = corner.startX; + lines[i * 4 - 1] = corner.startY; + } + lines[i * 4] = corner.stopX; + lines[i * 4 + 1] = corner.stopY; + intersection = intersectLineCircle(x, y, centerX, centerY, corner.cx, corner.cy, corner.radius); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + }); + for (var i = 0; i < lines.length / 4; i++) { + intersection = finiteLinesIntersect(x, y, centerX, centerY, lines[i * 4], lines[i * 4 + 1], lines[i * 4 + 2], lines[i * 4 + 3], false); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + } + if (intersections.length > 2) { + var lowestIntersection = [intersections[0], intersections[1]]; + var lowestSquaredDistance = Math.pow(lowestIntersection[0] - x, 2) + Math.pow(lowestIntersection[1] - y, 2); + for (var _i3 = 1; _i3 < intersections.length / 2; _i3++) { + var squaredDistance = Math.pow(intersections[_i3 * 2] - x, 2) + Math.pow(intersections[_i3 * 2 + 1] - y, 2); + if (squaredDistance <= lowestSquaredDistance) { + lowestIntersection[0] = intersections[_i3 * 2]; + lowestIntersection[1] = intersections[_i3 * 2 + 1]; + lowestSquaredDistance = squaredDistance; + } + } + return lowestIntersection; + } + return intersections; +}; +var shortenIntersection = function shortenIntersection(intersection, offset, amount) { + var disp = [intersection[0] - offset[0], intersection[1] - offset[1]]; + var length = Math.sqrt(disp[0] * disp[0] + disp[1] * disp[1]); + var lenRatio = (length - amount) / length; + if (lenRatio < 0) { + lenRatio = 0.00001; + } + return [offset[0] + lenRatio * disp[0], offset[1] + lenRatio * disp[1]]; +}; +var generateUnitNgonPointsFitToSquare = function generateUnitNgonPointsFitToSquare(sides, rotationRadians) { + var points = generateUnitNgonPoints(sides, rotationRadians); + points = fitPolygonToSquare(points); + return points; +}; +var fitPolygonToSquare = function fitPolygonToSquare(points) { + var x, y; + var sides = points.length / 2; + var minX = Infinity, + minY = Infinity, + maxX = -Infinity, + maxY = -Infinity; + for (var i = 0; i < sides; i++) { + x = points[2 * i]; + y = points[2 * i + 1]; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + + // stretch factors + var sx = 2 / (maxX - minX); + var sy = 2 / (maxY - minY); + for (var _i4 = 0; _i4 < sides; _i4++) { + x = points[2 * _i4] = points[2 * _i4] * sx; + y = points[2 * _i4 + 1] = points[2 * _i4 + 1] * sy; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + if (minY < -1) { + for (var _i5 = 0; _i5 < sides; _i5++) { + y = points[2 * _i5 + 1] = points[2 * _i5 + 1] + (-1 - minY); + } + } + return points; +}; +var generateUnitNgonPoints = function generateUnitNgonPoints(sides, rotationRadians) { + var increment = 1.0 / sides * 2 * Math.PI; + var startAngle = sides % 2 === 0 ? Math.PI / 2.0 + increment / 2.0 : Math.PI / 2.0; + startAngle += rotationRadians; + var points = new Array(sides * 2); + var currentAngle; + for (var i = 0; i < sides; i++) { + currentAngle = i * increment + startAngle; + points[2 * i] = Math.cos(currentAngle); // x + points[2 * i + 1] = Math.sin(-currentAngle); // y + } + + return points; +}; + +// Set the default radius, unless half of width or height is smaller than default +var getRoundRectangleRadius = function getRoundRectangleRadius(width, height) { + return Math.min(width / 4, height / 4, 8); +}; + +// Set the default radius +var getRoundPolygonRadius = function getRoundPolygonRadius(width, height) { + return Math.min(width / 10, height / 10, 8); +}; +var getCutRectangleCornerLength = function getCutRectangleCornerLength() { + return 8; +}; +var bezierPtsToQuadCoeff = function bezierPtsToQuadCoeff(p0, p1, p2) { + return [p0 - 2 * p1 + p2, 2 * (p1 - p0), p0]; +}; + +// get curve width, height, and control point position offsets as a percentage of node height / width +var getBarrelCurveConstants = function getBarrelCurveConstants(width, height) { + return { + heightOffset: Math.min(15, 0.05 * height), + widthOffset: Math.min(100, 0.25 * width), + ctrlPtOffsetPct: 0.05 + }; +}; + +var pageRankDefaults = defaults$g({ + dampingFactor: 0.8, + precision: 0.000001, + iterations: 200, + weight: function weight(edge) { + return 1; + } +}); +var elesfn$o = { + pageRank: function pageRank(options) { + var _pageRankDefaults = pageRankDefaults(options), + dampingFactor = _pageRankDefaults.dampingFactor, + precision = _pageRankDefaults.precision, + iterations = _pageRankDefaults.iterations, + weight = _pageRankDefaults.weight; + var cy = this._private.cy; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var numNodes = nodes.length; + var numNodesSqd = numNodes * numNodes; + var numEdges = edges.length; + + // Construct transposed adjacency matrix + // First lets have a zeroed matrix of the right size + // We'll also keep track of the sum of each column + var matrix = new Array(numNodesSqd); + var columnSum = new Array(numNodes); + var additionalProb = (1 - dampingFactor) / numNodes; + + // Create null matrix + for (var i = 0; i < numNodes; i++) { + for (var j = 0; j < numNodes; j++) { + var n = i * numNodes + j; + matrix[n] = 0; + } + columnSum[i] = 0; + } + + // Now, process edges + for (var _i = 0; _i < numEdges; _i++) { + var edge = edges[_i]; + var srcId = edge.data('source'); + var tgtId = edge.data('target'); + + // Don't include loops in the matrix + if (srcId === tgtId) { + continue; + } + var s = nodes.indexOfId(srcId); + var t = nodes.indexOfId(tgtId); + var w = weight(edge); + var _n = t * numNodes + s; + + // Update matrix + matrix[_n] += w; + + // Update column sum + columnSum[s] += w; + } + + // Add additional probability based on damping factor + // Also, take into account columns that have sum = 0 + var p = 1.0 / numNodes + additionalProb; // Shorthand + + // Traverse matrix, column by column + for (var _j = 0; _j < numNodes; _j++) { + if (columnSum[_j] === 0) { + // No 'links' out from node jth, assume equal probability for each possible node + for (var _i2 = 0; _i2 < numNodes; _i2++) { + var _n2 = _i2 * numNodes + _j; + matrix[_n2] = p; + } + } else { + // Node jth has outgoing link, compute normalized probabilities + for (var _i3 = 0; _i3 < numNodes; _i3++) { + var _n3 = _i3 * numNodes + _j; + matrix[_n3] = matrix[_n3] / columnSum[_j] + additionalProb; + } + } + } + + // Compute dominant eigenvector using power method + var eigenvector = new Array(numNodes); + var temp = new Array(numNodes); + var previous; + + // Start with a vector of all 1's + // Also, initialize a null vector which will be used as shorthand + for (var _i4 = 0; _i4 < numNodes; _i4++) { + eigenvector[_i4] = 1; + } + for (var iter = 0; iter < iterations; iter++) { + // Temp array with all 0's + for (var _i5 = 0; _i5 < numNodes; _i5++) { + temp[_i5] = 0; + } + + // Multiply matrix with previous result + for (var _i6 = 0; _i6 < numNodes; _i6++) { + for (var _j2 = 0; _j2 < numNodes; _j2++) { + var _n4 = _i6 * numNodes + _j2; + temp[_i6] += matrix[_n4] * eigenvector[_j2]; + } + } + inPlaceSumNormalize(temp); + previous = eigenvector; + eigenvector = temp; + temp = previous; + var diff = 0; + // Compute difference (squared module) of both vectors + for (var _i7 = 0; _i7 < numNodes; _i7++) { + var delta = previous[_i7] - eigenvector[_i7]; + diff += delta * delta; + } + + // If difference is less than the desired threshold, stop iterating + if (diff < precision) { + break; + } + } + + // Construct result + var res = { + rank: function rank(node) { + node = cy.collection(node)[0]; + return eigenvector[nodes.indexOf(node)]; + } + }; + return res; + } // pageRank +}; // elesfn + +var defaults$f = defaults$g({ + root: null, + weight: function weight(edge) { + return 1; + }, + directed: false, + alpha: 0 +}); +var elesfn$n = { + degreeCentralityNormalized: function degreeCentralityNormalized(options) { + options = defaults$f(options); + var cy = this.cy(); + var nodes = this.nodes(); + var numNodes = nodes.length; + if (!options.directed) { + var degrees = {}; + var maxDegree = 0; + for (var i = 0; i < numNodes; i++) { + var node = nodes[i]; + + // add current node to the current options object and call degreeCentrality + options.root = node; + var currDegree = this.degreeCentrality(options); + if (maxDegree < currDegree.degree) { + maxDegree = currDegree.degree; + } + degrees[node.id()] = currDegree.degree; + } + return { + degree: function degree(node) { + if (maxDegree === 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return degrees[node.id()] / maxDegree; + } + }; + } else { + var indegrees = {}; + var outdegrees = {}; + var maxIndegree = 0; + var maxOutdegree = 0; + for (var _i = 0; _i < numNodes; _i++) { + var _node = nodes[_i]; + var id = _node.id(); + + // add current node to the current options object and call degreeCentrality + options.root = _node; + var _currDegree = this.degreeCentrality(options); + if (maxIndegree < _currDegree.indegree) maxIndegree = _currDegree.indegree; + if (maxOutdegree < _currDegree.outdegree) maxOutdegree = _currDegree.outdegree; + indegrees[id] = _currDegree.indegree; + outdegrees[id] = _currDegree.outdegree; + } + return { + indegree: function indegree(node) { + if (maxIndegree == 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return indegrees[node.id()] / maxIndegree; + }, + outdegree: function outdegree(node) { + if (maxOutdegree === 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return outdegrees[node.id()] / maxOutdegree; + } + }; + } + }, + // degreeCentralityNormalized + + // Implemented from the algorithm in Opsahl's paper + // "Node centrality in weighted networks: Generalizing degree and shortest paths" + // check the heading 2 "Degree" + degreeCentrality: function degreeCentrality(options) { + options = defaults$f(options); + var cy = this.cy(); + var callingEles = this; + var _options = options, + root = _options.root, + weight = _options.weight, + directed = _options.directed, + alpha = _options.alpha; + root = cy.collection(root)[0]; + if (!directed) { + var connEdges = root.connectedEdges().intersection(callingEles); + var k = connEdges.length; + var s = 0; + + // Now, sum edge weights + for (var i = 0; i < connEdges.length; i++) { + s += weight(connEdges[i]); + } + return { + degree: Math.pow(k, 1 - alpha) * Math.pow(s, alpha) + }; + } else { + var edges = root.connectedEdges(); + var incoming = edges.filter(function (edge) { + return edge.target().same(root) && callingEles.has(edge); + }); + var outgoing = edges.filter(function (edge) { + return edge.source().same(root) && callingEles.has(edge); + }); + var k_in = incoming.length; + var k_out = outgoing.length; + var s_in = 0; + var s_out = 0; + + // Now, sum incoming edge weights + for (var _i2 = 0; _i2 < incoming.length; _i2++) { + s_in += weight(incoming[_i2]); + } + + // Now, sum outgoing edge weights + for (var _i3 = 0; _i3 < outgoing.length; _i3++) { + s_out += weight(outgoing[_i3]); + } + return { + indegree: Math.pow(k_in, 1 - alpha) * Math.pow(s_in, alpha), + outdegree: Math.pow(k_out, 1 - alpha) * Math.pow(s_out, alpha) + }; + } + } // degreeCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$n.dc = elesfn$n.degreeCentrality; +elesfn$n.dcn = elesfn$n.degreeCentralityNormalised = elesfn$n.degreeCentralityNormalized; + +var defaults$e = defaults$g({ + harmonic: true, + weight: function weight() { + return 1; + }, + directed: false, + root: null +}); +var elesfn$m = { + closenessCentralityNormalized: function closenessCentralityNormalized(options) { + var _defaults = defaults$e(options), + harmonic = _defaults.harmonic, + weight = _defaults.weight, + directed = _defaults.directed; + var cy = this.cy(); + var closenesses = {}; + var maxCloseness = 0; + var nodes = this.nodes(); + var fw = this.floydWarshall({ + weight: weight, + directed: directed + }); + + // Compute closeness for every node and find the maximum closeness + for (var i = 0; i < nodes.length; i++) { + var currCloseness = 0; + var node_i = nodes[i]; + for (var j = 0; j < nodes.length; j++) { + if (i !== j) { + var d = fw.distance(node_i, nodes[j]); + if (harmonic) { + currCloseness += 1 / d; + } else { + currCloseness += d; + } + } + } + if (!harmonic) { + currCloseness = 1 / currCloseness; + } + if (maxCloseness < currCloseness) { + maxCloseness = currCloseness; + } + closenesses[node_i.id()] = currCloseness; + } + return { + closeness: function closeness(node) { + if (maxCloseness == 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node)[0].id(); + } else { + // from is a node + node = node.id(); + } + return closenesses[node] / maxCloseness; + } + }; + }, + // Implemented from pseudocode from wikipedia + closenessCentrality: function closenessCentrality(options) { + var _defaults2 = defaults$e(options), + root = _defaults2.root, + weight = _defaults2.weight, + directed = _defaults2.directed, + harmonic = _defaults2.harmonic; + root = this.filter(root)[0]; + + // we need distance from this node to every other node + var dijkstra = this.dijkstra({ + root: root, + weight: weight, + directed: directed + }); + var totalDistance = 0; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + if (!n.same(root)) { + var d = dijkstra.distanceTo(n); + if (harmonic) { + totalDistance += 1 / d; + } else { + totalDistance += d; + } + } + } + return harmonic ? totalDistance : 1 / totalDistance; + } // closenessCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$m.cc = elesfn$m.closenessCentrality; +elesfn$m.ccn = elesfn$m.closenessCentralityNormalised = elesfn$m.closenessCentralityNormalized; + +var defaults$d = defaults$g({ + weight: null, + directed: false +}); +var elesfn$l = { + // Implemented from the algorithm in the paper "On Variants of Shortest-Path Betweenness Centrality and their Generic Computation" by Ulrik Brandes + betweennessCentrality: function betweennessCentrality(options) { + var _defaults = defaults$d(options), + directed = _defaults.directed, + weight = _defaults.weight; + var weighted = weight != null; + var cy = this.cy(); + + // starting + var V = this.nodes(); + var A = {}; + var _C = {}; + var max = 0; + var C = { + set: function set(key, val) { + _C[key] = val; + if (val > max) { + max = val; + } + }, + get: function get(key) { + return _C[key]; + } + }; + + // A contains the neighborhoods of every node + for (var i = 0; i < V.length; i++) { + var v = V[i]; + var vid = v.id(); + if (directed) { + A[vid] = v.outgoers().nodes(); // get outgoers of every node + } else { + A[vid] = v.openNeighborhood().nodes(); // get neighbors of every node + } + + C.set(vid, 0); + } + var _loop = function _loop(s) { + var sid = V[s].id(); + var S = []; // stack + var P = {}; + var g = {}; + var d = {}; + var Q = new heap(function (a, b) { + return d[a] - d[b]; + }); // queue + + // init dictionaries + for (var _i = 0; _i < V.length; _i++) { + var _vid = V[_i].id(); + P[_vid] = []; + g[_vid] = 0; + d[_vid] = Infinity; + } + g[sid] = 1; // sigma + d[sid] = 0; // distance to s + + Q.push(sid); + while (!Q.empty()) { + var _v = Q.pop(); + S.push(_v); + if (weighted) { + for (var j = 0; j < A[_v].length; j++) { + var w = A[_v][j]; + var vEle = cy.getElementById(_v); + var edge = void 0; + if (vEle.edgesTo(w).length > 0) { + edge = vEle.edgesTo(w)[0]; + } else { + edge = w.edgesTo(vEle)[0]; + } + var edgeWeight = weight(edge); + w = w.id(); + if (d[w] > d[_v] + edgeWeight) { + d[w] = d[_v] + edgeWeight; + if (Q.nodes.indexOf(w) < 0) { + //if w is not in Q + Q.push(w); + } else { + // update position if w is in Q + Q.updateItem(w); + } + g[w] = 0; + P[w] = []; + } + if (d[w] == d[_v] + edgeWeight) { + g[w] = g[w] + g[_v]; + P[w].push(_v); + } + } + } else { + for (var _j = 0; _j < A[_v].length; _j++) { + var _w = A[_v][_j].id(); + if (d[_w] == Infinity) { + Q.push(_w); + d[_w] = d[_v] + 1; + } + if (d[_w] == d[_v] + 1) { + g[_w] = g[_w] + g[_v]; + P[_w].push(_v); + } + } + } + } + var e = {}; + for (var _i2 = 0; _i2 < V.length; _i2++) { + e[V[_i2].id()] = 0; + } + while (S.length > 0) { + var _w2 = S.pop(); + for (var _j2 = 0; _j2 < P[_w2].length; _j2++) { + var _v2 = P[_w2][_j2]; + e[_v2] = e[_v2] + g[_v2] / g[_w2] * (1 + e[_w2]); + } + if (_w2 != V[s].id()) { + C.set(_w2, C.get(_w2) + e[_w2]); + } + } + }; + for (var s = 0; s < V.length; s++) { + _loop(s); + } + var ret = { + betweenness: function betweenness(node) { + var id = cy.collection(node).id(); + return C.get(id); + }, + betweennessNormalized: function betweennessNormalized(node) { + if (max == 0) { + return 0; + } + var id = cy.collection(node).id(); + return C.get(id) / max; + } + }; + + // alias + ret.betweennessNormalised = ret.betweennessNormalized; + return ret; + } // betweennessCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$l.bc = elesfn$l.betweennessCentrality; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 + +/* eslint-disable no-unused-vars */ +var defaults$c = defaults$g({ + expandFactor: 2, + // affects time of computation and cluster granularity to some extent: M * M + inflateFactor: 2, + // affects cluster granularity (the greater the value, the more clusters): M(i,j) / E(j) + multFactor: 1, + // optional self loops for each node. Use a neutral value to improve cluster computations. + maxIterations: 20, + // maximum number of iterations of the MCL algorithm in a single run + attributes: [ + // attributes/features used to group nodes, ie. similarity values between nodes + function (edge) { + return 1; + }] +}); +/* eslint-enable */ + +var setOptions$3 = function setOptions(options) { + return defaults$c(options); +}; +/* eslint-enable */ + +var getSimilarity$1 = function getSimilarity(edge, attributes) { + var total = 0; + for (var i = 0; i < attributes.length; i++) { + total += attributes[i](edge); + } + return total; +}; +var addLoops = function addLoops(M, n, val) { + for (var i = 0; i < n; i++) { + M[i * n + i] = val; + } +}; +var normalize = function normalize(M, n) { + var sum; + for (var col = 0; col < n; col++) { + sum = 0; + for (var row = 0; row < n; row++) { + sum += M[row * n + col]; + } + for (var _row = 0; _row < n; _row++) { + M[_row * n + col] = M[_row * n + col] / sum; + } + } +}; + +// TODO: blocked matrix multiplication? +var mmult = function mmult(A, B, n) { + var C = new Array(n * n); + for (var i = 0; i < n; i++) { + for (var j = 0; j < n; j++) { + C[i * n + j] = 0; + } + for (var k = 0; k < n; k++) { + for (var _j = 0; _j < n; _j++) { + C[i * n + _j] += A[i * n + k] * B[k * n + _j]; + } + } + } + return C; +}; +var expand = function expand(M, n, expandFactor /** power **/) { + var _M = M.slice(0); + for (var p = 1; p < expandFactor; p++) { + M = mmult(M, _M, n); + } + return M; +}; +var inflate = function inflate(M, n, inflateFactor /** r **/) { + var _M = new Array(n * n); + + // M(i,j) ^ inflatePower + for (var i = 0; i < n * n; i++) { + _M[i] = Math.pow(M[i], inflateFactor); + } + normalize(_M, n); + return _M; +}; +var hasConverged = function hasConverged(M, _M, n2, roundFactor) { + // Check that both matrices have the same elements (i,j) + for (var i = 0; i < n2; i++) { + var v1 = Math.round(M[i] * Math.pow(10, roundFactor)) / Math.pow(10, roundFactor); // truncate to 'roundFactor' decimal places + var v2 = Math.round(_M[i] * Math.pow(10, roundFactor)) / Math.pow(10, roundFactor); + if (v1 !== v2) { + return false; + } + } + return true; +}; +var assign$2 = function assign(M, n, nodes, cy) { + var clusters = []; + for (var i = 0; i < n; i++) { + var cluster = []; + for (var j = 0; j < n; j++) { + // Row-wise attractors and elements that they attract belong in same cluster + if (Math.round(M[i * n + j] * 1000) / 1000 > 0) { + cluster.push(nodes[j]); + } + } + if (cluster.length !== 0) { + clusters.push(cy.collection(cluster)); + } + } + return clusters; +}; +var isDuplicate = function isDuplicate(c1, c2) { + for (var i = 0; i < c1.length; i++) { + if (!c2[i] || c1[i].id() !== c2[i].id()) { + return false; + } + } + return true; +}; +var removeDuplicates = function removeDuplicates(clusters) { + for (var i = 0; i < clusters.length; i++) { + for (var j = 0; j < clusters.length; j++) { + if (i != j && isDuplicate(clusters[i], clusters[j])) { + clusters.splice(j, 1); + } + } + } + return clusters; +}; +var markovClustering = function markovClustering(options) { + var nodes = this.nodes(); + var edges = this.edges(); + var cy = this.cy(); + + // Set parameters of algorithm: + var opts = setOptions$3(options); + + // Map each node to its position in node array + var id2position = {}; + for (var i = 0; i < nodes.length; i++) { + id2position[nodes[i].id()] = i; + } + + // Generate stochastic matrix M from input graph G (should be symmetric/undirected) + var n = nodes.length, + n2 = n * n; + var M = new Array(n2), + _M; + for (var _i = 0; _i < n2; _i++) { + M[_i] = 0; + } + for (var e = 0; e < edges.length; e++) { + var edge = edges[e]; + var _i2 = id2position[edge.source().id()]; + var j = id2position[edge.target().id()]; + var sim = getSimilarity$1(edge, opts.attributes); + M[_i2 * n + j] += sim; // G should be symmetric and undirected + M[j * n + _i2] += sim; + } + + // Begin Markov cluster algorithm + + // Step 1: Add self loops to each node, ie. add multFactor to matrix diagonal + addLoops(M, n, opts.multFactor); + + // Step 2: M = normalize( M ); + normalize(M, n); + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + isStillMoving = false; + + // Step 3: + _M = expand(M, n, opts.expandFactor); + + // Step 4: + M = inflate(_M, n, opts.inflateFactor); + + // Step 5: check to see if ~steady state has been reached + if (!hasConverged(M, _M, n2, 4)) { + isStillMoving = true; + } + iterations++; + } + + // Build clusters from matrix + var clusters = assign$2(M, n, nodes, cy); + + // Remove duplicate clusters due to symmetry of graph and M matrix + clusters = removeDuplicates(clusters); + return clusters; +}; +var markovClustering$1 = { + markovClustering: markovClustering, + mcl: markovClustering +}; + +// Common distance metrics for clustering algorithms +var identity = function identity(x) { + return x; +}; +var absDiff = function absDiff(p, q) { + return Math.abs(q - p); +}; +var addAbsDiff = function addAbsDiff(total, p, q) { + return total + absDiff(p, q); +}; +var addSquaredDiff = function addSquaredDiff(total, p, q) { + return total + Math.pow(q - p, 2); +}; +var sqrt = function sqrt(x) { + return Math.sqrt(x); +}; +var maxAbsDiff = function maxAbsDiff(currentMax, p, q) { + return Math.max(currentMax, absDiff(p, q)); +}; +var getDistance = function getDistance(length, getP, getQ, init, visit) { + var post = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : identity; + var ret = init; + var p, q; + for (var dim = 0; dim < length; dim++) { + p = getP(dim); + q = getQ(dim); + ret = visit(ret, p, q); + } + return post(ret); +}; +var distances = { + euclidean: function euclidean(length, getP, getQ) { + if (length >= 2) { + return getDistance(length, getP, getQ, 0, addSquaredDiff, sqrt); + } else { + // for single attr case, more efficient to avoid sqrt + return getDistance(length, getP, getQ, 0, addAbsDiff); + } + }, + squaredEuclidean: function squaredEuclidean(length, getP, getQ) { + return getDistance(length, getP, getQ, 0, addSquaredDiff); + }, + manhattan: function manhattan(length, getP, getQ) { + return getDistance(length, getP, getQ, 0, addAbsDiff); + }, + max: function max(length, getP, getQ) { + return getDistance(length, getP, getQ, -Infinity, maxAbsDiff); + } +}; + +// in case the user accidentally doesn't use camel case +distances['squared-euclidean'] = distances['squaredEuclidean']; +distances['squaredeuclidean'] = distances['squaredEuclidean']; +function clusteringDistance (method, length, getP, getQ, nodeP, nodeQ) { + var impl; + if (fn$6(method)) { + impl = method; + } else { + impl = distances[method] || distances.euclidean; + } + if (length === 0 && fn$6(method)) { + return impl(nodeP, nodeQ); + } else { + return impl(length, getP, getQ, nodeP, nodeQ); + } +} + +var defaults$b = defaults$g({ + k: 2, + m: 2, + sensitivityThreshold: 0.0001, + distance: 'euclidean', + maxIterations: 10, + attributes: [], + testMode: false, + testCentroids: null +}); +var setOptions$2 = function setOptions(options) { + return defaults$b(options); +}; + +var getDist = function getDist(type, node, centroid, attributes, mode) { + var noNodeP = mode !== 'kMedoids'; + var getP = noNodeP ? function (i) { + return centroid[i]; + } : function (i) { + return attributes[i](centroid); + }; + var getQ = function getQ(i) { + return attributes[i](node); + }; + var nodeP = centroid; + var nodeQ = node; + return clusteringDistance(type, attributes.length, getP, getQ, nodeP, nodeQ); +}; +var randomCentroids = function randomCentroids(nodes, k, attributes) { + var ndim = attributes.length; + var min = new Array(ndim); + var max = new Array(ndim); + var centroids = new Array(k); + var centroid = null; + + // Find min, max values for each attribute dimension + for (var i = 0; i < ndim; i++) { + min[i] = nodes.min(attributes[i]).value; + max[i] = nodes.max(attributes[i]).value; + } + + // Build k centroids, each represented as an n-dim feature vector + for (var c = 0; c < k; c++) { + centroid = []; + for (var _i = 0; _i < ndim; _i++) { + centroid[_i] = Math.random() * (max[_i] - min[_i]) + min[_i]; // random initial value + } + + centroids[c] = centroid; + } + return centroids; +}; +var classify = function classify(node, centroids, distance, attributes, type) { + var min = Infinity; + var index = 0; + for (var i = 0; i < centroids.length; i++) { + var dist = getDist(distance, node, centroids[i], attributes, type); + if (dist < min) { + min = dist; + index = i; + } + } + return index; +}; +var buildCluster = function buildCluster(centroid, nodes, assignment) { + var cluster = []; + var node = null; + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + if (assignment[node.id()] === centroid) { + //console.log("Node " + node.id() + " is associated with medoid #: " + m); + cluster.push(node); + } + } + return cluster; +}; +var haveValuesConverged = function haveValuesConverged(v1, v2, sensitivityThreshold) { + return Math.abs(v2 - v1) <= sensitivityThreshold; +}; +var haveMatricesConverged = function haveMatricesConverged(v1, v2, sensitivityThreshold) { + for (var i = 0; i < v1.length; i++) { + for (var j = 0; j < v1[i].length; j++) { + var diff = Math.abs(v1[i][j] - v2[i][j]); + if (diff > sensitivityThreshold) { + return false; + } + } + } + return true; +}; +var seenBefore = function seenBefore(node, medoids, n) { + for (var i = 0; i < n; i++) { + if (node === medoids[i]) return true; + } + return false; +}; +var randomMedoids = function randomMedoids(nodes, k) { + var medoids = new Array(k); + + // For small data sets, the probability of medoid conflict is greater, + // so we need to check to see if we've already seen or chose this node before. + if (nodes.length < 50) { + // Randomly select k medoids from the n nodes + for (var i = 0; i < k; i++) { + var node = nodes[Math.floor(Math.random() * nodes.length)]; + + // If we've already chosen this node to be a medoid, don't choose it again (for small data sets). + // Instead choose a different random node. + while (seenBefore(node, medoids, i)) { + node = nodes[Math.floor(Math.random() * nodes.length)]; + } + medoids[i] = node; + } + } else { + // Relatively large data set, so pretty safe to not check and just select random nodes + for (var _i2 = 0; _i2 < k; _i2++) { + medoids[_i2] = nodes[Math.floor(Math.random() * nodes.length)]; + } + } + return medoids; +}; +var findCost = function findCost(potentialNewMedoid, cluster, attributes) { + var cost = 0; + for (var n = 0; n < cluster.length; n++) { + cost += getDist('manhattan', cluster[n], potentialNewMedoid, attributes, 'kMedoids'); + } + return cost; +}; +var kMeans = function kMeans(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var node = null; + + // Set parameters of algorithm: # of clusters, distance metric, etc. + var opts = setOptions$2(options); + + // Begin k-means algorithm + var clusters = new Array(opts.k); + var assignment = {}; + var centroids; + + // Step 1: Initialize centroid positions + if (opts.testMode) { + if (typeof opts.testCentroids === 'number') { + // TODO: implement a seeded random number generator. + opts.testCentroids; + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } else if (_typeof(opts.testCentroids) === 'object') { + centroids = opts.testCentroids; + } else { + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } + } else { + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + // Step 2: Assign nodes to the nearest centroid + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + // Determine which cluster this node belongs to: node id => cluster # + assignment[node.id()] = classify(node, centroids, opts.distance, opts.attributes, 'kMeans'); + } + + // Step 3: For each of the k clusters, update its centroid + isStillMoving = false; + for (var c = 0; c < opts.k; c++) { + // Get all nodes that belong to this cluster + var cluster = buildCluster(c, nodes, assignment); + if (cluster.length === 0) { + // If cluster is empty, break out early & move to next cluster + continue; + } + + // Update centroids by calculating avg of all nodes within the cluster. + var ndim = opts.attributes.length; + var centroid = centroids[c]; // [ dim_1, dim_2, dim_3, ... , dim_n ] + var newCentroid = new Array(ndim); + var sum = new Array(ndim); + for (var d = 0; d < ndim; d++) { + sum[d] = 0.0; + for (var i = 0; i < cluster.length; i++) { + node = cluster[i]; + sum[d] += opts.attributes[d](node); + } + newCentroid[d] = sum[d] / cluster.length; + + // Check to see if algorithm has converged, i.e. when centroids no longer change + if (!haveValuesConverged(newCentroid[d], centroid[d], opts.sensitivityThreshold)) { + isStillMoving = true; + } + } + centroids[c] = newCentroid; + clusters[c] = cy.collection(cluster); + } + iterations++; + } + return clusters; +}; +var kMedoids = function kMedoids(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var node = null; + var opts = setOptions$2(options); + + // Begin k-medoids algorithm + var clusters = new Array(opts.k); + var medoids; + var assignment = {}; + var curCost; + var minCosts = new Array(opts.k); // minimum cost configuration for each cluster + + // Step 1: Initialize k medoids + if (opts.testMode) { + if (typeof opts.testCentroids === 'number') ; else if (_typeof(opts.testCentroids) === 'object') { + medoids = opts.testCentroids; + } else { + medoids = randomMedoids(nodes, opts.k); + } + } else { + medoids = randomMedoids(nodes, opts.k); + } + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + // Step 2: Assign nodes to the nearest medoid + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + // Determine which cluster this node belongs to: node id => cluster # + assignment[node.id()] = classify(node, medoids, opts.distance, opts.attributes, 'kMedoids'); + } + isStillMoving = false; + // Step 3: For each medoid m, and for each node associated with mediod m, + // select the node with the lowest configuration cost as new medoid. + for (var m = 0; m < medoids.length; m++) { + // Get all nodes that belong to this medoid + var cluster = buildCluster(m, nodes, assignment); + if (cluster.length === 0) { + // If cluster is empty, break out early & move to next cluster + continue; + } + minCosts[m] = findCost(medoids[m], cluster, opts.attributes); // original cost + + // Select different medoid if its configuration has the lowest cost + for (var _n = 0; _n < cluster.length; _n++) { + curCost = findCost(cluster[_n], cluster, opts.attributes); + if (curCost < minCosts[m]) { + minCosts[m] = curCost; + medoids[m] = cluster[_n]; + isStillMoving = true; + } + } + clusters[m] = cy.collection(cluster); + } + iterations++; + } + return clusters; +}; +var updateCentroids = function updateCentroids(centroids, nodes, U, weight, opts) { + var numerator, denominator; + for (var n = 0; n < nodes.length; n++) { + for (var c = 0; c < centroids.length; c++) { + weight[n][c] = Math.pow(U[n][c], opts.m); + } + } + for (var _c = 0; _c < centroids.length; _c++) { + for (var dim = 0; dim < opts.attributes.length; dim++) { + numerator = 0; + denominator = 0; + for (var _n2 = 0; _n2 < nodes.length; _n2++) { + numerator += weight[_n2][_c] * opts.attributes[dim](nodes[_n2]); + denominator += weight[_n2][_c]; + } + centroids[_c][dim] = numerator / denominator; + } + } +}; +var updateMembership = function updateMembership(U, _U, centroids, nodes, opts) { + // Save previous step + for (var i = 0; i < U.length; i++) { + _U[i] = U[i].slice(); + } + var sum, numerator, denominator; + var pow = 2 / (opts.m - 1); + for (var c = 0; c < centroids.length; c++) { + for (var n = 0; n < nodes.length; n++) { + sum = 0; + for (var k = 0; k < centroids.length; k++) { + // against all other centroids + numerator = getDist(opts.distance, nodes[n], centroids[c], opts.attributes, 'cmeans'); + denominator = getDist(opts.distance, nodes[n], centroids[k], opts.attributes, 'cmeans'); + sum += Math.pow(numerator / denominator, pow); + } + U[n][c] = 1 / sum; + } + } +}; +var assign$1 = function assign(nodes, U, opts, cy) { + var clusters = new Array(opts.k); + for (var c = 0; c < clusters.length; c++) { + clusters[c] = []; + } + var max; + var index; + for (var n = 0; n < U.length; n++) { + // for each node (U is N x C matrix) + max = -Infinity; + index = -1; + // Determine which cluster the node is most likely to belong in + for (var _c2 = 0; _c2 < U[0].length; _c2++) { + if (U[n][_c2] > max) { + max = U[n][_c2]; + index = _c2; + } + } + clusters[index].push(nodes[n]); + } + + // Turn every array into a collection of nodes + for (var _c3 = 0; _c3 < clusters.length; _c3++) { + clusters[_c3] = cy.collection(clusters[_c3]); + } + return clusters; +}; +var fuzzyCMeans = function fuzzyCMeans(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var opts = setOptions$2(options); + + // Begin fuzzy c-means algorithm + var clusters; + var centroids; + var U; + var _U; + var weight; + + // Step 1: Initialize letiables. + _U = new Array(nodes.length); + for (var i = 0; i < nodes.length; i++) { + // N x C matrix + _U[i] = new Array(opts.k); + } + U = new Array(nodes.length); + for (var _i3 = 0; _i3 < nodes.length; _i3++) { + // N x C matrix + U[_i3] = new Array(opts.k); + } + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + var total = 0; + for (var j = 0; j < opts.k; j++) { + U[_i4][j] = Math.random(); + total += U[_i4][j]; + } + for (var _j = 0; _j < opts.k; _j++) { + U[_i4][_j] = U[_i4][_j] / total; + } + } + centroids = new Array(opts.k); + for (var _i5 = 0; _i5 < opts.k; _i5++) { + centroids[_i5] = new Array(opts.attributes.length); + } + weight = new Array(nodes.length); + for (var _i6 = 0; _i6 < nodes.length; _i6++) { + // N x C matrix + weight[_i6] = new Array(opts.k); + } + // end init FCM + + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + isStillMoving = false; + + // Step 2: Calculate the centroids for each step. + updateCentroids(centroids, nodes, U, weight, opts); + + // Step 3: Update the partition matrix U. + updateMembership(U, _U, centroids, nodes, opts); + + // Step 4: Check for convergence. + if (!haveMatricesConverged(U, _U, opts.sensitivityThreshold)) { + isStillMoving = true; + } + iterations++; + } + + // Assign nodes to clusters with highest probability. + clusters = assign$1(nodes, U, opts, cy); + return { + clusters: clusters, + degreeOfMembership: U + }; +}; +var kClustering = { + kMeans: kMeans, + kMedoids: kMedoids, + fuzzyCMeans: fuzzyCMeans, + fcm: fuzzyCMeans +}; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 +var defaults$a = defaults$g({ + distance: 'euclidean', + // distance metric to compare nodes + linkage: 'min', + // linkage criterion : how to determine the distance between clusters of nodes + mode: 'threshold', + // mode:'threshold' => clusters must be threshold distance apart + threshold: Infinity, + // the distance threshold + // mode:'dendrogram' => the nodes are organised as leaves in a tree (siblings are close), merging makes clusters + addDendrogram: false, + // whether to add the dendrogram to the graph for viz + dendrogramDepth: 0, + // depth at which dendrogram branches are merged into the returned clusters + attributes: [] // array of attr functions +}); + +var linkageAliases = { + 'single': 'min', + 'complete': 'max' +}; +var setOptions$1 = function setOptions(options) { + var opts = defaults$a(options); + var preferredAlias = linkageAliases[opts.linkage]; + if (preferredAlias != null) { + opts.linkage = preferredAlias; + } + return opts; +}; +var mergeClosest = function mergeClosest(clusters, index, dists, mins, opts) { + // Find two closest clusters from cached mins + var minKey = 0; + var min = Infinity; + var dist; + var attrs = opts.attributes; + var getDist = function getDist(n1, n2) { + return clusteringDistance(opts.distance, attrs.length, function (i) { + return attrs[i](n1); + }, function (i) { + return attrs[i](n2); + }, n1, n2); + }; + for (var i = 0; i < clusters.length; i++) { + var key = clusters[i].key; + var _dist = dists[key][mins[key]]; + if (_dist < min) { + minKey = key; + min = _dist; + } + } + if (opts.mode === 'threshold' && min >= opts.threshold || opts.mode === 'dendrogram' && clusters.length === 1) { + return false; + } + var c1 = index[minKey]; + var c2 = index[mins[minKey]]; + var merged; + + // Merge two closest clusters + if (opts.mode === 'dendrogram') { + merged = { + left: c1, + right: c2, + key: c1.key + }; + } else { + merged = { + value: c1.value.concat(c2.value), + key: c1.key + }; + } + clusters[c1.index] = merged; + clusters.splice(c2.index, 1); + index[c1.key] = merged; + + // Update distances with new merged cluster + for (var _i = 0; _i < clusters.length; _i++) { + var cur = clusters[_i]; + if (c1.key === cur.key) { + dist = Infinity; + } else if (opts.linkage === 'min') { + dist = dists[c1.key][cur.key]; + if (dists[c1.key][cur.key] > dists[c2.key][cur.key]) { + dist = dists[c2.key][cur.key]; + } + } else if (opts.linkage === 'max') { + dist = dists[c1.key][cur.key]; + if (dists[c1.key][cur.key] < dists[c2.key][cur.key]) { + dist = dists[c2.key][cur.key]; + } + } else if (opts.linkage === 'mean') { + dist = (dists[c1.key][cur.key] * c1.size + dists[c2.key][cur.key] * c2.size) / (c1.size + c2.size); + } else { + if (opts.mode === 'dendrogram') dist = getDist(cur.value, c1.value);else dist = getDist(cur.value[0], c1.value[0]); + } + dists[c1.key][cur.key] = dists[cur.key][c1.key] = dist; // distance matrix is symmetric + } + + // Update cached mins + for (var _i2 = 0; _i2 < clusters.length; _i2++) { + var key1 = clusters[_i2].key; + if (mins[key1] === c1.key || mins[key1] === c2.key) { + var _min = key1; + for (var j = 0; j < clusters.length; j++) { + var key2 = clusters[j].key; + if (dists[key1][key2] < dists[key1][_min]) { + _min = key2; + } + } + mins[key1] = _min; + } + clusters[_i2].index = _i2; + } + + // Clean up meta data used for clustering + c1.key = c2.key = c1.index = c2.index = null; + return true; +}; +var getAllChildren = function getAllChildren(root, arr, cy) { + if (!root) return; + if (root.value) { + arr.push(root.value); + } else { + if (root.left) getAllChildren(root.left, arr); + if (root.right) getAllChildren(root.right, arr); + } +}; +var buildDendrogram = function buildDendrogram(root, cy) { + if (!root) return ''; + if (root.left && root.right) { + var leftStr = buildDendrogram(root.left, cy); + var rightStr = buildDendrogram(root.right, cy); + var node = cy.add({ + group: 'nodes', + data: { + id: leftStr + ',' + rightStr + } + }); + cy.add({ + group: 'edges', + data: { + source: leftStr, + target: node.id() + } + }); + cy.add({ + group: 'edges', + data: { + source: rightStr, + target: node.id() + } + }); + return node.id(); + } else if (root.value) { + return root.value.id(); + } +}; +var buildClustersFromTree = function buildClustersFromTree(root, k, cy) { + if (!root) return []; + var left = [], + right = [], + leaves = []; + if (k === 0) { + // don't cut tree, simply return all nodes as 1 single cluster + if (root.left) getAllChildren(root.left, left); + if (root.right) getAllChildren(root.right, right); + leaves = left.concat(right); + return [cy.collection(leaves)]; + } else if (k === 1) { + // cut at root + + if (root.value) { + // leaf node + return [cy.collection(root.value)]; + } else { + if (root.left) getAllChildren(root.left, left); + if (root.right) getAllChildren(root.right, right); + return [cy.collection(left), cy.collection(right)]; + } + } else { + if (root.value) { + return [cy.collection(root.value)]; + } else { + if (root.left) left = buildClustersFromTree(root.left, k - 1, cy); + if (root.right) right = buildClustersFromTree(root.right, k - 1, cy); + return left.concat(right); + } + } +}; + +var hierarchicalClustering = function hierarchicalClustering(options) { + var cy = this.cy(); + var nodes = this.nodes(); + + // Set parameters of algorithm: linkage type, distance metric, etc. + var opts = setOptions$1(options); + var attrs = opts.attributes; + var getDist = function getDist(n1, n2) { + return clusteringDistance(opts.distance, attrs.length, function (i) { + return attrs[i](n1); + }, function (i) { + return attrs[i](n2); + }, n1, n2); + }; + + // Begin hierarchical algorithm + var clusters = []; + var dists = []; // distances between each pair of clusters + var mins = []; // closest cluster for each cluster + var index = []; // hash of all clusters by key + + // In agglomerative (bottom-up) clustering, each node starts as its own cluster + for (var n = 0; n < nodes.length; n++) { + var cluster = { + value: opts.mode === 'dendrogram' ? nodes[n] : [nodes[n]], + key: n, + index: n + }; + clusters[n] = cluster; + index[n] = cluster; + dists[n] = []; + mins[n] = 0; + } + + // Calculate the distance between each pair of clusters + for (var i = 0; i < clusters.length; i++) { + for (var j = 0; j <= i; j++) { + var dist = void 0; + if (opts.mode === 'dendrogram') { + // modes store cluster values differently + dist = i === j ? Infinity : getDist(clusters[i].value, clusters[j].value); + } else { + dist = i === j ? Infinity : getDist(clusters[i].value[0], clusters[j].value[0]); + } + dists[i][j] = dist; + dists[j][i] = dist; + if (dist < dists[i][mins[i]]) { + mins[i] = j; // Cache mins: closest cluster to cluster i is cluster j + } + } + } + + // Find the closest pair of clusters and merge them into a single cluster. + // Update distances between new cluster and each of the old clusters, and loop until threshold reached. + var merged = mergeClosest(clusters, index, dists, mins, opts); + while (merged) { + merged = mergeClosest(clusters, index, dists, mins, opts); + } + var retClusters; + + // Dendrogram mode builds the hierarchy and adds intermediary nodes + edges + // in addition to returning the clusters. + if (opts.mode === 'dendrogram') { + retClusters = buildClustersFromTree(clusters[0], opts.dendrogramDepth, cy); + if (opts.addDendrogram) buildDendrogram(clusters[0], cy); + } else { + // Regular mode simply returns the clusters + + retClusters = new Array(clusters.length); + clusters.forEach(function (cluster, i) { + // Clean up meta data used for clustering + cluster.key = cluster.index = null; + retClusters[i] = cy.collection(cluster.value); + }); + } + return retClusters; +}; +var hierarchicalClustering$1 = { + hierarchicalClustering: hierarchicalClustering, + hca: hierarchicalClustering +}; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 +var defaults$9 = defaults$g({ + distance: 'euclidean', + // distance metric to compare attributes between two nodes + preference: 'median', + // suitability of a data point to serve as an exemplar + damping: 0.8, + // damping factor between [0.5, 1) + maxIterations: 1000, + // max number of iterations to run + minIterations: 100, + // min number of iterations to run in order for clustering to stop + attributes: [// functions to quantify the similarity between any two points + // e.g. node => node.data('weight') + ] +}); +var setOptions = function setOptions(options) { + var dmp = options.damping; + var pref = options.preference; + if (!(0.5 <= dmp && dmp < 1)) { + error("Damping must range on [0.5, 1). Got: ".concat(dmp)); + } + var validPrefs = ['median', 'mean', 'min', 'max']; + if (!(validPrefs.some(function (v) { + return v === pref; + }) || number$1(pref))) { + error("Preference must be one of [".concat(validPrefs.map(function (p) { + return "'".concat(p, "'"); + }).join(', '), "] or a number. Got: ").concat(pref)); + } + return defaults$9(options); +}; + +var getSimilarity = function getSimilarity(type, n1, n2, attributes) { + var attr = function attr(n, i) { + return attributes[i](n); + }; + + // nb negative because similarity should have an inverse relationship to distance + return -clusteringDistance(type, attributes.length, function (i) { + return attr(n1, i); + }, function (i) { + return attr(n2, i); + }, n1, n2); +}; +var getPreference = function getPreference(S, preference) { + // larger preference = greater # of clusters + var p = null; + if (preference === 'median') { + p = median(S); + } else if (preference === 'mean') { + p = mean(S); + } else if (preference === 'min') { + p = min$1(S); + } else if (preference === 'max') { + p = max$1(S); + } else { + // Custom preference number, as set by user + p = preference; + } + return p; +}; +var findExemplars = function findExemplars(n, R, A) { + var indices = []; + for (var i = 0; i < n; i++) { + if (R[i * n + i] + A[i * n + i] > 0) { + indices.push(i); + } + } + return indices; +}; +var assignClusters = function assignClusters(n, S, exemplars) { + var clusters = []; + for (var i = 0; i < n; i++) { + var index = -1; + var max = -Infinity; + for (var ei = 0; ei < exemplars.length; ei++) { + var e = exemplars[ei]; + if (S[i * n + e] > max) { + index = e; + max = S[i * n + e]; + } + } + if (index > 0) { + clusters.push(index); + } + } + for (var _ei = 0; _ei < exemplars.length; _ei++) { + clusters[exemplars[_ei]] = exemplars[_ei]; + } + return clusters; +}; +var assign = function assign(n, S, exemplars) { + var clusters = assignClusters(n, S, exemplars); + for (var ei = 0; ei < exemplars.length; ei++) { + var ii = []; + for (var c = 0; c < clusters.length; c++) { + if (clusters[c] === exemplars[ei]) { + ii.push(c); + } + } + var maxI = -1; + var maxSum = -Infinity; + for (var i = 0; i < ii.length; i++) { + var sum = 0; + for (var j = 0; j < ii.length; j++) { + sum += S[ii[j] * n + ii[i]]; + } + if (sum > maxSum) { + maxI = i; + maxSum = sum; + } + } + exemplars[ei] = ii[maxI]; + } + clusters = assignClusters(n, S, exemplars); + return clusters; +}; +var affinityPropagation = function affinityPropagation(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var opts = setOptions(options); + + // Map each node to its position in node array + var id2position = {}; + for (var i = 0; i < nodes.length; i++) { + id2position[nodes[i].id()] = i; + } + + // Begin affinity propagation algorithm + + var n; // number of data points + var n2; // size of matrices + var S; // similarity matrix (1D array) + var p; // preference/suitability of a data point to serve as an exemplar + var R; // responsibility matrix (1D array) + var A; // availability matrix (1D array) + + n = nodes.length; + n2 = n * n; + + // Initialize and build S similarity matrix + S = new Array(n2); + for (var _i = 0; _i < n2; _i++) { + S[_i] = -Infinity; // for cases where two data points shouldn't be linked together + } + + for (var _i2 = 0; _i2 < n; _i2++) { + for (var j = 0; j < n; j++) { + if (_i2 !== j) { + S[_i2 * n + j] = getSimilarity(opts.distance, nodes[_i2], nodes[j], opts.attributes); + } + } + } + + // Place preferences on the diagonal of S + p = getPreference(S, opts.preference); + for (var _i3 = 0; _i3 < n; _i3++) { + S[_i3 * n + _i3] = p; + } + + // Initialize R responsibility matrix + R = new Array(n2); + for (var _i4 = 0; _i4 < n2; _i4++) { + R[_i4] = 0.0; + } + + // Initialize A availability matrix + A = new Array(n2); + for (var _i5 = 0; _i5 < n2; _i5++) { + A[_i5] = 0.0; + } + var old = new Array(n); + var Rp = new Array(n); + var se = new Array(n); + for (var _i6 = 0; _i6 < n; _i6++) { + old[_i6] = 0.0; + Rp[_i6] = 0.0; + se[_i6] = 0; + } + var e = new Array(n * opts.minIterations); + for (var _i7 = 0; _i7 < e.length; _i7++) { + e[_i7] = 0; + } + var iter; + for (iter = 0; iter < opts.maxIterations; iter++) { + // main algorithmic loop + + // Update R responsibility matrix + for (var _i8 = 0; _i8 < n; _i8++) { + var max = -Infinity, + max2 = -Infinity, + maxI = -1, + AS = 0.0; + for (var _j = 0; _j < n; _j++) { + old[_j] = R[_i8 * n + _j]; + AS = A[_i8 * n + _j] + S[_i8 * n + _j]; + if (AS >= max) { + max2 = max; + max = AS; + maxI = _j; + } else if (AS > max2) { + max2 = AS; + } + } + for (var _j2 = 0; _j2 < n; _j2++) { + R[_i8 * n + _j2] = (1 - opts.damping) * (S[_i8 * n + _j2] - max) + opts.damping * old[_j2]; + } + R[_i8 * n + maxI] = (1 - opts.damping) * (S[_i8 * n + maxI] - max2) + opts.damping * old[maxI]; + } + + // Update A availability matrix + for (var _i9 = 0; _i9 < n; _i9++) { + var sum = 0; + for (var _j3 = 0; _j3 < n; _j3++) { + old[_j3] = A[_j3 * n + _i9]; + Rp[_j3] = Math.max(0, R[_j3 * n + _i9]); + sum += Rp[_j3]; + } + sum -= Rp[_i9]; + Rp[_i9] = R[_i9 * n + _i9]; + sum += Rp[_i9]; + for (var _j4 = 0; _j4 < n; _j4++) { + A[_j4 * n + _i9] = (1 - opts.damping) * Math.min(0, sum - Rp[_j4]) + opts.damping * old[_j4]; + } + A[_i9 * n + _i9] = (1 - opts.damping) * (sum - Rp[_i9]) + opts.damping * old[_i9]; + } + + // Check for convergence + var K = 0; + for (var _i10 = 0; _i10 < n; _i10++) { + var E = A[_i10 * n + _i10] + R[_i10 * n + _i10] > 0 ? 1 : 0; + e[iter % opts.minIterations * n + _i10] = E; + K += E; + } + if (K > 0 && (iter >= opts.minIterations - 1 || iter == opts.maxIterations - 1)) { + var _sum = 0; + for (var _i11 = 0; _i11 < n; _i11++) { + se[_i11] = 0; + for (var _j5 = 0; _j5 < opts.minIterations; _j5++) { + se[_i11] += e[_j5 * n + _i11]; + } + if (se[_i11] === 0 || se[_i11] === opts.minIterations) { + _sum++; + } + } + if (_sum === n) { + // then we have convergence + break; + } + } + } + + // Identify exemplars (cluster centers) + var exemplarsIndices = findExemplars(n, R, A); + + // Assign nodes to clusters + var clusterIndices = assign(n, S, exemplarsIndices); + var clusters = {}; + for (var c = 0; c < exemplarsIndices.length; c++) { + clusters[exemplarsIndices[c]] = []; + } + for (var _i12 = 0; _i12 < nodes.length; _i12++) { + var pos = id2position[nodes[_i12].id()]; + var clusterIndex = clusterIndices[pos]; + if (clusterIndex != null) { + // the node may have not been assigned a cluster if no valid attributes were specified + clusters[clusterIndex].push(nodes[_i12]); + } + } + var retClusters = new Array(exemplarsIndices.length); + for (var _c = 0; _c < exemplarsIndices.length; _c++) { + retClusters[_c] = cy.collection(clusters[exemplarsIndices[_c]]); + } + return retClusters; +}; +var affinityPropagation$1 = { + affinityPropagation: affinityPropagation, + ap: affinityPropagation +}; + +var hierholzerDefaults = defaults$g({ + root: undefined, + directed: false +}); +var elesfn$k = { + hierholzer: function hierholzer(options) { + if (!plainObject(options)) { + var args = arguments; + options = { + root: args[0], + directed: args[1] + }; + } + var _hierholzerDefaults = hierholzerDefaults(options), + root = _hierholzerDefaults.root, + directed = _hierholzerDefaults.directed; + var eles = this; + var dflag = false; + var oddIn; + var oddOut; + var startVertex; + if (root) startVertex = string(root) ? this.filter(root)[0].id() : root[0].id(); + var nodes = {}; + var edges = {}; + if (directed) { + eles.forEach(function (ele) { + var id = ele.id(); + if (ele.isNode()) { + var ind = ele.indegree(true); + var outd = ele.outdegree(true); + var d1 = ind - outd; + var d2 = outd - ind; + if (d1 == 1) { + if (oddIn) dflag = true;else oddIn = id; + } else if (d2 == 1) { + if (oddOut) dflag = true;else oddOut = id; + } else if (d2 > 1 || d1 > 1) { + dflag = true; + } + nodes[id] = []; + ele.outgoers().forEach(function (e) { + if (e.isEdge()) nodes[id].push(e.id()); + }); + } else { + edges[id] = [undefined, ele.target().id()]; + } + }); + } else { + eles.forEach(function (ele) { + var id = ele.id(); + if (ele.isNode()) { + var d = ele.degree(true); + if (d % 2) { + if (!oddIn) oddIn = id;else if (!oddOut) oddOut = id;else dflag = true; + } + nodes[id] = []; + ele.connectedEdges().forEach(function (e) { + return nodes[id].push(e.id()); + }); + } else { + edges[id] = [ele.source().id(), ele.target().id()]; + } + }); + } + var result = { + found: false, + trail: undefined + }; + if (dflag) return result;else if (oddOut && oddIn) { + if (directed) { + if (startVertex && oddOut != startVertex) { + return result; + } + startVertex = oddOut; + } else { + if (startVertex && oddOut != startVertex && oddIn != startVertex) { + return result; + } else if (!startVertex) { + startVertex = oddOut; + } + } + } else { + if (!startVertex) startVertex = eles[0].id(); + } + var walk = function walk(v) { + var currentNode = v; + var subtour = [v]; + var adj, adjTail, adjHead; + while (nodes[currentNode].length) { + adj = nodes[currentNode].shift(); + adjTail = edges[adj][0]; + adjHead = edges[adj][1]; + if (currentNode != adjHead) { + nodes[adjHead] = nodes[adjHead].filter(function (e) { + return e != adj; + }); + currentNode = adjHead; + } else if (!directed && currentNode != adjTail) { + nodes[adjTail] = nodes[adjTail].filter(function (e) { + return e != adj; + }); + currentNode = adjTail; + } + subtour.unshift(adj); + subtour.unshift(currentNode); + } + return subtour; + }; + var trail = []; + var subtour = []; + subtour = walk(startVertex); + while (subtour.length != 1) { + if (nodes[subtour[0]].length == 0) { + trail.unshift(eles.getElementById(subtour.shift())); + trail.unshift(eles.getElementById(subtour.shift())); + } else { + subtour = walk(subtour.shift()).concat(subtour); + } + } + trail.unshift(eles.getElementById(subtour.shift())); // final node + + for (var d in nodes) { + if (nodes[d].length) { + return result; + } + } + result.found = true; + result.trail = this.spawn(trail, true); + return result; + } +}; + +var hopcroftTarjanBiconnected = function hopcroftTarjanBiconnected() { + var eles = this; + var nodes = {}; + var id = 0; + var edgeCount = 0; + var components = []; + var stack = []; + var visitedEdges = {}; + var buildComponent = function buildComponent(x, y) { + var i = stack.length - 1; + var cutset = []; + var component = eles.spawn(); + while (stack[i].x != x || stack[i].y != y) { + cutset.push(stack.pop().edge); + i--; + } + cutset.push(stack.pop().edge); + cutset.forEach(function (edge) { + var connectedNodes = edge.connectedNodes().intersection(eles); + component.merge(edge); + connectedNodes.forEach(function (node) { + var nodeId = node.id(); + var connectedEdges = node.connectedEdges().intersection(eles); + component.merge(node); + if (!nodes[nodeId].cutVertex) { + component.merge(connectedEdges); + } else { + component.merge(connectedEdges.filter(function (edge) { + return edge.isLoop(); + })); + } + }); + }); + components.push(component); + }; + var biconnectedSearch = function biconnectedSearch(root, currentNode, parent) { + if (root === parent) edgeCount += 1; + nodes[currentNode] = { + id: id, + low: id++, + cutVertex: false + }; + var edges = eles.getElementById(currentNode).connectedEdges().intersection(eles); + if (edges.size() === 0) { + components.push(eles.spawn(eles.getElementById(currentNode))); + } else { + var sourceId, targetId, otherNodeId, edgeId; + edges.forEach(function (edge) { + sourceId = edge.source().id(); + targetId = edge.target().id(); + otherNodeId = sourceId === currentNode ? targetId : sourceId; + if (otherNodeId !== parent) { + edgeId = edge.id(); + if (!visitedEdges[edgeId]) { + visitedEdges[edgeId] = true; + stack.push({ + x: currentNode, + y: otherNodeId, + edge: edge + }); + } + if (!(otherNodeId in nodes)) { + biconnectedSearch(root, otherNodeId, currentNode); + nodes[currentNode].low = Math.min(nodes[currentNode].low, nodes[otherNodeId].low); + if (nodes[currentNode].id <= nodes[otherNodeId].low) { + nodes[currentNode].cutVertex = true; + buildComponent(currentNode, otherNodeId); + } + } else { + nodes[currentNode].low = Math.min(nodes[currentNode].low, nodes[otherNodeId].id); + } + } + }); + } + }; + eles.forEach(function (ele) { + if (ele.isNode()) { + var nodeId = ele.id(); + if (!(nodeId in nodes)) { + edgeCount = 0; + biconnectedSearch(nodeId, nodeId); + nodes[nodeId].cutVertex = edgeCount > 1; + } + } + }); + var cutVertices = Object.keys(nodes).filter(function (id) { + return nodes[id].cutVertex; + }).map(function (id) { + return eles.getElementById(id); + }); + return { + cut: eles.spawn(cutVertices), + components: components + }; +}; +var hopcroftTarjanBiconnected$1 = { + hopcroftTarjanBiconnected: hopcroftTarjanBiconnected, + htbc: hopcroftTarjanBiconnected, + htb: hopcroftTarjanBiconnected, + hopcroftTarjanBiconnectedComponents: hopcroftTarjanBiconnected +}; + +var tarjanStronglyConnected = function tarjanStronglyConnected() { + var eles = this; + var nodes = {}; + var index = 0; + var components = []; + var stack = []; + var cut = eles.spawn(eles); + var stronglyConnectedSearch = function stronglyConnectedSearch(sourceNodeId) { + stack.push(sourceNodeId); + nodes[sourceNodeId] = { + index: index, + low: index++, + explored: false + }; + var connectedEdges = eles.getElementById(sourceNodeId).connectedEdges().intersection(eles); + connectedEdges.forEach(function (edge) { + var targetNodeId = edge.target().id(); + if (targetNodeId !== sourceNodeId) { + if (!(targetNodeId in nodes)) { + stronglyConnectedSearch(targetNodeId); + } + if (!nodes[targetNodeId].explored) { + nodes[sourceNodeId].low = Math.min(nodes[sourceNodeId].low, nodes[targetNodeId].low); + } + } + }); + if (nodes[sourceNodeId].index === nodes[sourceNodeId].low) { + var componentNodes = eles.spawn(); + for (;;) { + var nodeId = stack.pop(); + componentNodes.merge(eles.getElementById(nodeId)); + nodes[nodeId].low = nodes[sourceNodeId].index; + nodes[nodeId].explored = true; + if (nodeId === sourceNodeId) { + break; + } + } + var componentEdges = componentNodes.edgesWith(componentNodes); + var component = componentNodes.merge(componentEdges); + components.push(component); + cut = cut.difference(component); + } + }; + eles.forEach(function (ele) { + if (ele.isNode()) { + var nodeId = ele.id(); + if (!(nodeId in nodes)) { + stronglyConnectedSearch(nodeId); + } + } + }); + return { + cut: cut, + components: components + }; +}; +var tarjanStronglyConnected$1 = { + tarjanStronglyConnected: tarjanStronglyConnected, + tsc: tarjanStronglyConnected, + tscc: tarjanStronglyConnected, + tarjanStronglyConnectedComponents: tarjanStronglyConnected +}; + +var elesfn$j = {}; +[elesfn$v, elesfn$u, elesfn$t, elesfn$s, elesfn$r, elesfn$q, elesfn$p, elesfn$o, elesfn$n, elesfn$m, elesfn$l, markovClustering$1, kClustering, hierarchicalClustering$1, affinityPropagation$1, elesfn$k, hopcroftTarjanBiconnected$1, tarjanStronglyConnected$1].forEach(function (props) { + extend(elesfn$j, props); +}); + +/*! +Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable +Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) +Licensed under The MIT License (http://opensource.org/licenses/MIT) +*/ + +/* promise states [Promises/A+ 2.1] */ +var STATE_PENDING = 0; /* [Promises/A+ 2.1.1] */ +var STATE_FULFILLED = 1; /* [Promises/A+ 2.1.2] */ +var STATE_REJECTED = 2; /* [Promises/A+ 2.1.3] */ + +/* promise object constructor */ +var api = function api(executor) { + /* optionally support non-constructor/plain-function call */ + if (!(this instanceof api)) return new api(executor); + + /* initialize object */ + this.id = 'Thenable/1.0.7'; + this.state = STATE_PENDING; /* initial state */ + this.fulfillValue = undefined; /* initial value */ /* [Promises/A+ 1.3, 2.1.2.2] */ + this.rejectReason = undefined; /* initial reason */ /* [Promises/A+ 1.5, 2.1.3.2] */ + this.onFulfilled = []; /* initial handlers */ + this.onRejected = []; /* initial handlers */ + + /* provide optional information-hiding proxy */ + this.proxy = { + then: this.then.bind(this) + }; + + /* support optional executor function */ + if (typeof executor === 'function') executor.call(this, this.fulfill.bind(this), this.reject.bind(this)); +}; + +/* promise API methods */ +api.prototype = { + /* promise resolving methods */ + fulfill: function fulfill(value) { + return deliver(this, STATE_FULFILLED, 'fulfillValue', value); + }, + reject: function reject(value) { + return deliver(this, STATE_REJECTED, 'rejectReason', value); + }, + /* "The then Method" [Promises/A+ 1.1, 1.2, 2.2] */ + then: function then(onFulfilled, onRejected) { + var curr = this; + var next = new api(); /* [Promises/A+ 2.2.7] */ + curr.onFulfilled.push(resolver(onFulfilled, next, 'fulfill')); /* [Promises/A+ 2.2.2/2.2.6] */ + curr.onRejected.push(resolver(onRejected, next, 'reject')); /* [Promises/A+ 2.2.3/2.2.6] */ + execute(curr); + return next.proxy; /* [Promises/A+ 2.2.7, 3.3] */ + } +}; + +/* deliver an action */ +var deliver = function deliver(curr, state, name, value) { + if (curr.state === STATE_PENDING) { + curr.state = state; /* [Promises/A+ 2.1.2.1, 2.1.3.1] */ + curr[name] = value; /* [Promises/A+ 2.1.2.2, 2.1.3.2] */ + execute(curr); + } + return curr; +}; + +/* execute all handlers */ +var execute = function execute(curr) { + if (curr.state === STATE_FULFILLED) execute_handlers(curr, 'onFulfilled', curr.fulfillValue);else if (curr.state === STATE_REJECTED) execute_handlers(curr, 'onRejected', curr.rejectReason); +}; + +/* execute particular set of handlers */ +var execute_handlers = function execute_handlers(curr, name, value) { + /* global setImmediate: true */ + /* global setTimeout: true */ + + /* short-circuit processing */ + if (curr[name].length === 0) return; + + /* iterate over all handlers, exactly once */ + var handlers = curr[name]; + curr[name] = []; /* [Promises/A+ 2.2.2.3, 2.2.3.3] */ + var func = function func() { + for (var i = 0; i < handlers.length; i++) { + handlers[i](value); + } /* [Promises/A+ 2.2.5] */ + }; + + /* execute procedure asynchronously */ /* [Promises/A+ 2.2.4, 3.1] */ + if (typeof setImmediate === 'function') setImmediate(func);else setTimeout(func, 0); +}; + +/* generate a resolver function */ +var resolver = function resolver(cb, next, method) { + return function (value) { + if (typeof cb !== 'function') /* [Promises/A+ 2.2.1, 2.2.7.3, 2.2.7.4] */ + next[method].call(next, value); /* [Promises/A+ 2.2.7.3, 2.2.7.4] */else { + var result; + try { + result = cb(value); + } /* [Promises/A+ 2.2.2.1, 2.2.3.1, 2.2.5, 3.2] */ catch (e) { + next.reject(e); /* [Promises/A+ 2.2.7.2] */ + return; + } + resolve(next, result); /* [Promises/A+ 2.2.7.1] */ + } + }; +}; + +/* "Promise Resolution Procedure" */ /* [Promises/A+ 2.3] */ +var resolve = function resolve(promise, x) { + /* sanity check arguments */ /* [Promises/A+ 2.3.1] */ + if (promise === x || promise.proxy === x) { + promise.reject(new TypeError('cannot resolve promise with itself')); + return; + } + + /* surgically check for a "then" method + (mainly to just call the "getter" of "then" only once) */ + var then; + if (_typeof(x) === 'object' && x !== null || typeof x === 'function') { + try { + then = x.then; + } /* [Promises/A+ 2.3.3.1, 3.5] */ catch (e) { + promise.reject(e); /* [Promises/A+ 2.3.3.2] */ + return; + } + } + + /* handle own Thenables [Promises/A+ 2.3.2] + and similar "thenables" [Promises/A+ 2.3.3] */ + if (typeof then === 'function') { + var resolved = false; + try { + /* call retrieved "then" method */ /* [Promises/A+ 2.3.3.3] */ + then.call(x, /* resolvePromise */ /* [Promises/A+ 2.3.3.3.1] */ + function (y) { + if (resolved) return; + resolved = true; /* [Promises/A+ 2.3.3.3.3] */ + if (y === x) /* [Promises/A+ 3.6] */ + promise.reject(new TypeError('circular thenable chain'));else resolve(promise, y); + }, /* rejectPromise */ /* [Promises/A+ 2.3.3.3.2] */ + function (r) { + if (resolved) return; + resolved = true; /* [Promises/A+ 2.3.3.3.3] */ + promise.reject(r); + }); + } catch (e) { + if (!resolved) /* [Promises/A+ 2.3.3.3.3] */ + promise.reject(e); /* [Promises/A+ 2.3.3.3.4] */ + } + + return; + } + + /* handle other values */ + promise.fulfill(x); /* [Promises/A+ 2.3.4, 2.3.3.4] */ +}; + +// so we always have Promise.all() +api.all = function (ps) { + return new api(function (resolveAll, rejectAll) { + var vals = new Array(ps.length); + var doneCount = 0; + var fulfill = function fulfill(i, val) { + vals[i] = val; + doneCount++; + if (doneCount === ps.length) { + resolveAll(vals); + } + }; + for (var i = 0; i < ps.length; i++) { + (function (i) { + var p = ps[i]; + var isPromise = p != null && p.then != null; + if (isPromise) { + p.then(function (val) { + fulfill(i, val); + }, function (err) { + rejectAll(err); + }); + } else { + var val = p; + fulfill(i, val); + } + })(i); + } + }); +}; +api.resolve = function (val) { + return new api(function (resolve, reject) { + resolve(val); + }); +}; +api.reject = function (val) { + return new api(function (resolve, reject) { + reject(val); + }); +}; +var Promise$1 = typeof Promise !== 'undefined' ? Promise : api; // eslint-disable-line no-undef + +var Animation = function Animation(target, opts, opts2) { + var isCore = core(target); + var isEle = !isCore; + var _p = this._private = extend({ + duration: 1000 + }, opts, opts2); + _p.target = target; + _p.style = _p.style || _p.css; + _p.started = false; + _p.playing = false; + _p.hooked = false; + _p.applying = false; + _p.progress = 0; + _p.completes = []; + _p.frames = []; + if (_p.complete && fn$6(_p.complete)) { + _p.completes.push(_p.complete); + } + if (isEle) { + var pos = target.position(); + _p.startPosition = _p.startPosition || { + x: pos.x, + y: pos.y + }; + _p.startStyle = _p.startStyle || target.cy().style().getAnimationStartStyle(target, _p.style); + } + if (isCore) { + var pan = target.pan(); + _p.startPan = { + x: pan.x, + y: pan.y + }; + _p.startZoom = target.zoom(); + } + + // for future timeline/animations impl + this.length = 1; + this[0] = this; +}; +var anifn = Animation.prototype; +extend(anifn, { + instanceString: function instanceString() { + return 'animation'; + }, + hook: function hook() { + var _p = this._private; + if (!_p.hooked) { + // add to target's animation queue + var q; + var tAni = _p.target._private.animation; + if (_p.queue) { + q = tAni.queue; + } else { + q = tAni.current; + } + q.push(this); + + // add to the animation loop pool + if (elementOrCollection(_p.target)) { + _p.target.cy().addToAnimationPool(_p.target); + } + _p.hooked = true; + } + return this; + }, + play: function play() { + var _p = this._private; + + // autorewind + if (_p.progress === 1) { + _p.progress = 0; + } + _p.playing = true; + _p.started = false; // needs to be started by animation loop + _p.stopped = false; + this.hook(); + + // the animation loop will start the animation... + + return this; + }, + playing: function playing() { + return this._private.playing; + }, + apply: function apply() { + var _p = this._private; + _p.applying = true; + _p.started = false; // needs to be started by animation loop + _p.stopped = false; + this.hook(); + + // the animation loop will apply the animation at this progress + + return this; + }, + applying: function applying() { + return this._private.applying; + }, + pause: function pause() { + var _p = this._private; + _p.playing = false; + _p.started = false; + return this; + }, + stop: function stop() { + var _p = this._private; + _p.playing = false; + _p.started = false; + _p.stopped = true; // to be removed from animation queues + + return this; + }, + rewind: function rewind() { + return this.progress(0); + }, + fastforward: function fastforward() { + return this.progress(1); + }, + time: function time(t) { + var _p = this._private; + if (t === undefined) { + return _p.progress * _p.duration; + } else { + return this.progress(t / _p.duration); + } + }, + progress: function progress(p) { + var _p = this._private; + var wasPlaying = _p.playing; + if (p === undefined) { + return _p.progress; + } else { + if (wasPlaying) { + this.pause(); + } + _p.progress = p; + _p.started = false; + if (wasPlaying) { + this.play(); + } + } + return this; + }, + completed: function completed() { + return this._private.progress === 1; + }, + reverse: function reverse() { + var _p = this._private; + var wasPlaying = _p.playing; + if (wasPlaying) { + this.pause(); + } + _p.progress = 1 - _p.progress; + _p.started = false; + var swap = function swap(a, b) { + var _pa = _p[a]; + if (_pa == null) { + return; + } + _p[a] = _p[b]; + _p[b] = _pa; + }; + swap('zoom', 'startZoom'); + swap('pan', 'startPan'); + swap('position', 'startPosition'); + + // swap styles + if (_p.style) { + for (var i = 0; i < _p.style.length; i++) { + var prop = _p.style[i]; + var name = prop.name; + var startStyleProp = _p.startStyle[name]; + _p.startStyle[name] = prop; + _p.style[i] = startStyleProp; + } + } + if (wasPlaying) { + this.play(); + } + return this; + }, + promise: function promise(type) { + var _p = this._private; + var arr; + switch (type) { + case 'frame': + arr = _p.frames; + break; + default: + case 'complete': + case 'completed': + arr = _p.completes; + } + return new Promise$1(function (resolve, reject) { + arr.push(function () { + resolve(); + }); + }); + } +}); +anifn.complete = anifn.completed; +anifn.run = anifn.play; +anifn.running = anifn.playing; + +var define$3 = { + animated: function animated() { + return function animatedImpl() { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return false; + } + var ele = all[0]; + if (ele) { + return ele._private.animation.current.length > 0; + } + }; + }, + // animated + + clearQueue: function clearQueue() { + return function clearQueueImpl() { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + ele._private.animation.queue = []; + } + return this; + }; + }, + // clearQueue + + delay: function delay() { + return function delayImpl(time, complete) { + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + return this.animate({ + delay: time, + duration: time, + complete: complete + }); + }; + }, + // delay + + delayAnimation: function delayAnimation() { + return function delayAnimationImpl(time, complete) { + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + return this.animation({ + delay: time, + duration: time, + complete: complete + }); + }; + }, + // delay + + animation: function animation() { + return function animationImpl(properties, params) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + var isCore = !selfIsArrayLike; + var isEles = !isCore; + if (!cy.styleEnabled()) { + return this; + } + var style = cy.style(); + properties = extend({}, properties, params); + var propertiesEmpty = Object.keys(properties).length === 0; + if (propertiesEmpty) { + return new Animation(all[0], properties); // nothing to animate + } + + if (properties.duration === undefined) { + properties.duration = 400; + } + switch (properties.duration) { + case 'slow': + properties.duration = 600; + break; + case 'fast': + properties.duration = 200; + break; + } + if (isEles) { + properties.style = style.getPropsList(properties.style || properties.css); + properties.css = undefined; + } + if (isEles && properties.renderedPosition != null) { + var rpos = properties.renderedPosition; + var pan = cy.pan(); + var zoom = cy.zoom(); + properties.position = renderedToModelPosition(rpos, zoom, pan); + } + + // override pan w/ panBy if set + if (isCore && properties.panBy != null) { + var panBy = properties.panBy; + var cyPan = cy.pan(); + properties.pan = { + x: cyPan.x + panBy.x, + y: cyPan.y + panBy.y + }; + } + + // override pan w/ center if set + var center = properties.center || properties.centre; + if (isCore && center != null) { + var centerPan = cy.getCenterPan(center.eles, properties.zoom); + if (centerPan != null) { + properties.pan = centerPan; + } + } + + // override pan & zoom w/ fit if set + if (isCore && properties.fit != null) { + var fit = properties.fit; + var fitVp = cy.getFitViewport(fit.eles || fit.boundingBox, fit.padding); + if (fitVp != null) { + properties.pan = fitVp.pan; + properties.zoom = fitVp.zoom; + } + } + + // override zoom (& potentially pan) w/ zoom obj if set + if (isCore && plainObject(properties.zoom)) { + var vp = cy.getZoomedViewport(properties.zoom); + if (vp != null) { + if (vp.zoomed) { + properties.zoom = vp.zoom; + } + if (vp.panned) { + properties.pan = vp.pan; + } + } else { + properties.zoom = null; // an inavalid zoom (e.g. no delta) gets automatically destroyed + } + } + + return new Animation(all[0], properties); + }; + }, + // animate + + animate: function animate() { + return function animateImpl(properties, params) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + if (params) { + properties = extend({}, properties, params); + } + + // manually hook and run the animation + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + var queue = ele.animated() && (properties.queue === undefined || properties.queue); + var ani = ele.animation(properties, queue ? { + queue: true + } : undefined); + ani.play(); + } + return this; // chaining + }; + }, + + // animate + + stop: function stop() { + return function stopImpl(clearQueue, jumpToEnd) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + var _p = ele._private; + var anis = _p.animation.current; + for (var j = 0; j < anis.length; j++) { + var ani = anis[j]; + var ani_p = ani._private; + if (jumpToEnd) { + // next iteration of the animation loop, the animation + // will go straight to the end and be removed + ani_p.duration = 0; + } + } + + // clear the queue of future animations + if (clearQueue) { + _p.animation.queue = []; + } + if (!jumpToEnd) { + _p.animation.current = []; + } + } + + // we have to notify (the animation loop doesn't do it for us on `stop`) + cy.notify('draw'); + return this; + }; + } // stop +}; // define + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +var isArray_1 = isArray; + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray_1(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol_1(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + +var _isKey = isKey; + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject_1(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = _baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +var isFunction_1 = isFunction; + +/** Used to detect overreaching core-js shims. */ +var coreJsData = _root['__core-js_shared__']; + +var _coreJsData = coreJsData; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +var _isMasked = isMasked; + +/** Used for built-in method references. */ +var funcProto$1 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$1 = funcProto$1.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString$1.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +var _toSource = toSource; + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto$3 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty$3).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject_1(value) || _isMasked(value)) { + return false; + } + var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor; + return pattern.test(_toSource(value)); +} + +var _baseIsNative = baseIsNative; + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue$1(object, key) { + return object == null ? undefined : object[key]; +} + +var _getValue = getValue$1; + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = _getValue(object, key); + return _baseIsNative(value) ? value : undefined; +} + +var _getNative = getNative; + +/* Built-in method references that are verified to be native. */ +var nativeCreate = _getNative(Object, 'create'); + +var _nativeCreate = nativeCreate; + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = _nativeCreate ? _nativeCreate(null) : {}; + this.size = 0; +} + +var _hashClear = hashClear; + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +var _hashDelete = hashDelete; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (_nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED$1 ? undefined : result; + } + return hasOwnProperty$2.call(data, key) ? data[key] : undefined; +} + +var _hashGet = hashGet; + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key); +} + +var _hashHas = hashHas; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +var _hashSet = hashSet; + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = _hashClear; +Hash.prototype['delete'] = _hashDelete; +Hash.prototype.get = _hashGet; +Hash.prototype.has = _hashHas; +Hash.prototype.set = _hashSet; + +var _Hash = Hash; + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +var _listCacheClear = listCacheClear; + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +var eq_1 = eq; + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq_1(array[length][0], key)) { + return length; + } + } + return -1; +} + +var _assocIndexOf = assocIndexOf; + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +var _listCacheDelete = listCacheDelete; + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +var _listCacheGet = listCacheGet; + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return _assocIndexOf(this.__data__, key) > -1; +} + +var _listCacheHas = listCacheHas; + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +var _listCacheSet = listCacheSet; + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = _listCacheClear; +ListCache.prototype['delete'] = _listCacheDelete; +ListCache.prototype.get = _listCacheGet; +ListCache.prototype.has = _listCacheHas; +ListCache.prototype.set = _listCacheSet; + +var _ListCache = ListCache; + +/* Built-in method references that are verified to be native. */ +var Map$1 = _getNative(_root, 'Map'); + +var _Map = Map$1; + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new _Hash, + 'map': new (_Map || _ListCache), + 'string': new _Hash + }; +} + +var _mapCacheClear = mapCacheClear; + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +var _isKeyable = isKeyable; + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return _isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +var _getMapData = getMapData; + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = _getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +var _mapCacheDelete = mapCacheDelete; + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return _getMapData(this, key).get(key); +} + +var _mapCacheGet = mapCacheGet; + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return _getMapData(this, key).has(key); +} + +var _mapCacheHas = mapCacheHas; + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = _getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +var _mapCacheSet = mapCacheSet; + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = _mapCacheClear; +MapCache.prototype['delete'] = _mapCacheDelete; +MapCache.prototype.get = _mapCacheGet; +MapCache.prototype.has = _mapCacheHas; +MapCache.prototype.set = _mapCacheSet; + +var _MapCache = MapCache; + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || _MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = _MapCache; + +var memoize_1 = memoize; + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped(func) { + var result = memoize_1(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +var _memoizeCapped = memoizeCapped; + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = _memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +var _stringToPath = stringToPath; + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +var _arrayMap = arrayMap; + +/** Used as references for various `Number` constants. */ +var INFINITY$1 = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = _Symbol ? _Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray_1(value)) { + // Recursively convert values (susceptible to call stack limits). + return _arrayMap(value, baseToString) + ''; + } + if (isSymbol_1(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result; +} + +var _baseToString = baseToString; + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString$1(value) { + return value == null ? '' : _baseToString(value); +} + +var toString_1 = toString$1; + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value, object) { + if (isArray_1(value)) { + return value; + } + return _isKey(value, object) ? [value] : _stringToPath(toString_1(value)); +} + +var _castPath = castPath; + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol_1(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +var _toKey = toKey; + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = _castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[_toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +var _baseGet = baseGet; + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get(object, path, defaultValue) { + var result = object == null ? undefined : _baseGet(object, path); + return result === undefined ? defaultValue : result; +} + +var get_1 = get; + +var defineProperty = (function() { + try { + var func = _getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +var _defineProperty = defineProperty; + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue(object, key, value) { + if (key == '__proto__' && _defineProperty) { + _defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +var _baseAssignValue = baseAssignValue; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq_1(objValue, value)) || + (value === undefined && !(key in object))) { + _baseAssignValue(object, key, value); + } +} + +var _assignValue = assignValue; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +var _isIndex = isIndex; + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject_1(object)) { + return object; + } + path = _castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = _toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject_1(objValue) + ? objValue + : (_isIndex(path[index + 1]) ? [] : {}); + } + } + _assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +var _baseSet = baseSet; + +/** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ +function set(object, path, value) { + return object == null ? object : _baseSet(object, path, value); +} + +var set_1 = set; + +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} + +var _copyArray = copyArray; + +/** + * Converts `value` to a property path array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {*} value The value to convert. + * @returns {Array} Returns the new property path array. + * @example + * + * _.toPath('a.b.c'); + * // => ['a', 'b', 'c'] + * + * _.toPath('a[0].b.c'); + * // => ['a', '0', 'b', 'c'] + */ +function toPath(value) { + if (isArray_1(value)) { + return _arrayMap(value, _toKey); + } + return isSymbol_1(value) ? [value] : _copyArray(_stringToPath(toString_1(value))); +} + +var toPath_1 = toPath; + +var define$2 = { + // access data field + data: function data(params) { + var defaults = { + field: 'data', + bindingEvent: 'data', + allowBinding: false, + allowSetting: false, + allowGetting: false, + settingEvent: 'data', + settingTriggersEvent: false, + triggerFnName: 'trigger', + immutableKeys: {}, + // key => true if immutable + updateStyle: false, + beforeGet: function beforeGet(self) {}, + beforeSet: function beforeSet(self, obj) {}, + onSet: function onSet(self) {}, + canSet: function canSet(self) { + return true; + } + }; + params = extend({}, defaults, params); + return function dataImpl(name, value) { + var p = params; + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var single = selfIsArrayLike ? self[0] : self; + + // .data('foo', ...) + if (string(name)) { + // set or get property + var isPathLike = name.indexOf('.') !== -1; // there might be a normal field with a dot + var path = isPathLike && toPath_1(name); + + // .data('foo') + if (p.allowGetting && value === undefined) { + // get + + var ret; + if (single) { + p.beforeGet(single); + + // check if it's path and a field with the same name doesn't exist + if (path && single._private[p.field][name] === undefined) { + ret = get_1(single._private[p.field], path); + } else { + ret = single._private[p.field][name]; + } + } + return ret; + + // .data('foo', 'bar') + } else if (p.allowSetting && value !== undefined) { + // set + var valid = !p.immutableKeys[name]; + if (valid) { + var change = _defineProperty$1({}, name, value); + p.beforeSet(self, change); + for (var i = 0, l = all.length; i < l; i++) { + var ele = all[i]; + if (p.canSet(ele)) { + if (path && single._private[p.field][name] === undefined) { + set_1(ele._private[p.field], path, value); + } else { + ele._private[p.field][name] = value; + } + } + } + + // update mappers if asked + if (p.updateStyle) { + self.updateStyle(); + } + + // call onSet callback + p.onSet(self); + if (p.settingTriggersEvent) { + self[p.triggerFnName](p.settingEvent); + } + } + } + + // .data({ 'foo': 'bar' }) + } else if (p.allowSetting && plainObject(name)) { + // extend + var obj = name; + var k, v; + var keys = Object.keys(obj); + p.beforeSet(self, obj); + for (var _i = 0; _i < keys.length; _i++) { + k = keys[_i]; + v = obj[k]; + var _valid = !p.immutableKeys[k]; + if (_valid) { + for (var j = 0; j < all.length; j++) { + var _ele = all[j]; + if (p.canSet(_ele)) { + _ele._private[p.field][k] = v; + } + } + } + } + + // update mappers if asked + if (p.updateStyle) { + self.updateStyle(); + } + + // call onSet callback + p.onSet(self); + if (p.settingTriggersEvent) { + self[p.triggerFnName](p.settingEvent); + } + + // .data(function(){ ... }) + } else if (p.allowBinding && fn$6(name)) { + // bind to event + var fn = name; + self.on(p.bindingEvent, fn); + + // .data() + } else if (p.allowGetting && name === undefined) { + // get whole object + var _ret; + if (single) { + p.beforeGet(single); + _ret = single._private[p.field]; + } + return _ret; + } + return self; // maintain chainability + }; // function + }, + + // data + + // remove data field + removeData: function removeData(params) { + var defaults = { + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: false, + immutableKeys: {} // key => true if immutable + }; + + params = extend({}, defaults, params); + return function removeDataImpl(names) { + var p = params; + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + + // .removeData('foo bar') + if (string(names)) { + // then get the list of keys, and delete them + var keys = names.split(/\s+/); + var l = keys.length; + for (var i = 0; i < l; i++) { + // delete each non-empty key + var key = keys[i]; + if (emptyString(key)) { + continue; + } + var valid = !p.immutableKeys[key]; // not valid if immutable + if (valid) { + for (var i_a = 0, l_a = all.length; i_a < l_a; i_a++) { + all[i_a]._private[p.field][key] = undefined; + } + } + } + if (p.triggerEvent) { + self[p.triggerFnName](p.event); + } + + // .removeData() + } else if (names === undefined) { + // then delete all keys + + for (var _i_a = 0, _l_a = all.length; _i_a < _l_a; _i_a++) { + var _privateFields = all[_i_a]._private[p.field]; + var _keys = Object.keys(_privateFields); + for (var _i2 = 0; _i2 < _keys.length; _i2++) { + var _key = _keys[_i2]; + var validKeyToDelete = !p.immutableKeys[_key]; + if (validKeyToDelete) { + _privateFields[_key] = undefined; + } + } + } + if (p.triggerEvent) { + self[p.triggerFnName](p.event); + } + } + return self; // maintain chaining + }; // function + } // removeData +}; // define + +var define$1 = { + eventAliasesOn: function eventAliasesOn(proto) { + var p = proto; + p.addListener = p.listen = p.bind = p.on; + p.unlisten = p.unbind = p.off = p.removeListener; + p.trigger = p.emit; + + // this is just a wrapper alias of .on() + p.pon = p.promiseOn = function (events, selector) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + return new Promise$1(function (resolve, reject) { + var callback = function callback(e) { + self.off.apply(self, offArgs); + resolve(e); + }; + var onArgs = args.concat([callback]); + var offArgs = onArgs.concat([]); + self.on.apply(self, onArgs); + }); + }; + } +}; // define + +// use this module to cherry pick functions into your prototype +var define = {}; +[define$3, define$2, define$1].forEach(function (m) { + extend(define, m); +}); + +var elesfn$i = { + animate: define.animate(), + animation: define.animation(), + animated: define.animated(), + clearQueue: define.clearQueue(), + delay: define.delay(), + delayAnimation: define.delayAnimation(), + stop: define.stop() +}; + +var elesfn$h = { + classes: function classes(_classes) { + var self = this; + if (_classes === undefined) { + var ret = []; + self[0]._private.classes.forEach(function (cls) { + return ret.push(cls); + }); + return ret; + } else if (!array(_classes)) { + // extract classes from string + _classes = (_classes || '').match(/\S+/g) || []; + } + var changed = []; + var classesSet = new Set$1(_classes); + + // check and update each ele + for (var j = 0; j < self.length; j++) { + var ele = self[j]; + var _p = ele._private; + var eleClasses = _p.classes; + var changedEle = false; + + // check if ele has all of the passed classes + for (var i = 0; i < _classes.length; i++) { + var cls = _classes[i]; + var eleHasClass = eleClasses.has(cls); + if (!eleHasClass) { + changedEle = true; + break; + } + } + + // check if ele has classes outside of those passed + if (!changedEle) { + changedEle = eleClasses.size !== _classes.length; + } + if (changedEle) { + _p.classes = classesSet; + changed.push(ele); + } + } + + // trigger update style on those eles that had class changes + if (changed.length > 0) { + this.spawn(changed).updateStyle().emit('class'); + } + return self; + }, + addClass: function addClass(classes) { + return this.toggleClass(classes, true); + }, + hasClass: function hasClass(className) { + var ele = this[0]; + return ele != null && ele._private.classes.has(className); + }, + toggleClass: function toggleClass(classes, toggle) { + if (!array(classes)) { + // extract classes from string + classes = classes.match(/\S+/g) || []; + } + var self = this; + var toggleUndefd = toggle === undefined; + var changed = []; // eles who had classes changed + + for (var i = 0, il = self.length; i < il; i++) { + var ele = self[i]; + var eleClasses = ele._private.classes; + var changedEle = false; + for (var j = 0; j < classes.length; j++) { + var cls = classes[j]; + var hasClass = eleClasses.has(cls); + var changedNow = false; + if (toggle || toggleUndefd && !hasClass) { + eleClasses.add(cls); + changedNow = true; + } else if (!toggle || toggleUndefd && hasClass) { + eleClasses["delete"](cls); + changedNow = true; + } + if (!changedEle && changedNow) { + changed.push(ele); + changedEle = true; + } + } // for j classes + } // for i eles + + // trigger update style on those eles that had class changes + if (changed.length > 0) { + this.spawn(changed).updateStyle().emit('class'); + } + return self; + }, + removeClass: function removeClass(classes) { + return this.toggleClass(classes, false); + }, + flashClass: function flashClass(classes, duration) { + var self = this; + if (duration == null) { + duration = 250; + } else if (duration === 0) { + return self; // nothing to do really + } + + self.addClass(classes); + setTimeout(function () { + self.removeClass(classes); + }, duration); + return self; + } +}; +elesfn$h.className = elesfn$h.classNames = elesfn$h.classes; + +// tokens in the query language +var tokens = { + metaChar: '[\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]', + // chars we need to escape in let names, etc + comparatorOp: '=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=', + // binary comparison op (used in data selectors) + boolOp: '\\?|\\!|\\^', + // boolean (unary) operators (used in data selectors) + string: '"(?:\\\\"|[^"])*"' + '|' + "'(?:\\\\'|[^'])*'", + // string literals (used in data selectors) -- doublequotes | singlequotes + number: number, + // number literal (used in data selectors) --- e.g. 0.1234, 1234, 12e123 + meta: 'degree|indegree|outdegree', + // allowed metadata fields (i.e. allowed functions to use from Collection) + separator: '\\s*,\\s*', + // queries are separated by commas, e.g. edge[foo = 'bar'], node.someClass + descendant: '\\s+', + child: '\\s+>\\s+', + subject: '\\$', + group: 'node|edge|\\*', + directedEdge: '\\s+->\\s+', + undirectedEdge: '\\s+<->\\s+' +}; +tokens.variable = '(?:[\\w-.]|(?:\\\\' + tokens.metaChar + '))+'; // a variable name can have letters, numbers, dashes, and periods +tokens.className = '(?:[\\w-]|(?:\\\\' + tokens.metaChar + '))+'; // a class name has the same rules as a variable except it can't have a '.' in the name +tokens.value = tokens.string + '|' + tokens.number; // a value literal, either a string or number +tokens.id = tokens.variable; // an element id (follows variable conventions) + +(function () { + var ops, op, i; + + // add @ variants to comparatorOp + ops = tokens.comparatorOp.split('|'); + for (i = 0; i < ops.length; i++) { + op = ops[i]; + tokens.comparatorOp += '|@' + op; + } + + // add ! variants to comparatorOp + ops = tokens.comparatorOp.split('|'); + for (i = 0; i < ops.length; i++) { + op = ops[i]; + if (op.indexOf('!') >= 0) { + continue; + } // skip ops that explicitly contain ! + if (op === '=') { + continue; + } // skip = b/c != is explicitly defined + + tokens.comparatorOp += '|\\!' + op; + } +})(); + +/** + * Make a new query object + * + * @prop type {Type} The type enum (int) of the query + * @prop checks List of checks to make against an ele to test for a match + */ +var newQuery = function newQuery() { + return { + checks: [] + }; +}; + +/** + * A check type enum-like object. Uses integer values for fast match() lookup. + * The ordering does not matter as long as the ints are unique. + */ +var Type = { + /** E.g. node */ + GROUP: 0, + /** A collection of elements */ + COLLECTION: 1, + /** A filter(ele) function */ + FILTER: 2, + /** E.g. [foo > 1] */ + DATA_COMPARE: 3, + /** E.g. [foo] */ + DATA_EXIST: 4, + /** E.g. [?foo] */ + DATA_BOOL: 5, + /** E.g. [[degree > 2]] */ + META_COMPARE: 6, + /** E.g. :selected */ + STATE: 7, + /** E.g. #foo */ + ID: 8, + /** E.g. .foo */ + CLASS: 9, + /** E.g. #foo <-> #bar */ + UNDIRECTED_EDGE: 10, + /** E.g. #foo -> #bar */ + DIRECTED_EDGE: 11, + /** E.g. $#foo -> #bar */ + NODE_SOURCE: 12, + /** E.g. #foo -> $#bar */ + NODE_TARGET: 13, + /** E.g. $#foo <-> #bar */ + NODE_NEIGHBOR: 14, + /** E.g. #foo > #bar */ + CHILD: 15, + /** E.g. #foo #bar */ + DESCENDANT: 16, + /** E.g. $#foo > #bar */ + PARENT: 17, + /** E.g. $#foo #bar */ + ANCESTOR: 18, + /** E.g. #foo > $bar > #baz */ + COMPOUND_SPLIT: 19, + /** Always matches, useful placeholder for subject in `COMPOUND_SPLIT` */ + TRUE: 20 +}; + +var stateSelectors = [{ + selector: ':selected', + matches: function matches(ele) { + return ele.selected(); + } +}, { + selector: ':unselected', + matches: function matches(ele) { + return !ele.selected(); + } +}, { + selector: ':selectable', + matches: function matches(ele) { + return ele.selectable(); + } +}, { + selector: ':unselectable', + matches: function matches(ele) { + return !ele.selectable(); + } +}, { + selector: ':locked', + matches: function matches(ele) { + return ele.locked(); + } +}, { + selector: ':unlocked', + matches: function matches(ele) { + return !ele.locked(); + } +}, { + selector: ':visible', + matches: function matches(ele) { + return ele.visible(); + } +}, { + selector: ':hidden', + matches: function matches(ele) { + return !ele.visible(); + } +}, { + selector: ':transparent', + matches: function matches(ele) { + return ele.transparent(); + } +}, { + selector: ':grabbed', + matches: function matches(ele) { + return ele.grabbed(); + } +}, { + selector: ':free', + matches: function matches(ele) { + return !ele.grabbed(); + } +}, { + selector: ':removed', + matches: function matches(ele) { + return ele.removed(); + } +}, { + selector: ':inside', + matches: function matches(ele) { + return !ele.removed(); + } +}, { + selector: ':grabbable', + matches: function matches(ele) { + return ele.grabbable(); + } +}, { + selector: ':ungrabbable', + matches: function matches(ele) { + return !ele.grabbable(); + } +}, { + selector: ':animated', + matches: function matches(ele) { + return ele.animated(); + } +}, { + selector: ':unanimated', + matches: function matches(ele) { + return !ele.animated(); + } +}, { + selector: ':parent', + matches: function matches(ele) { + return ele.isParent(); + } +}, { + selector: ':childless', + matches: function matches(ele) { + return ele.isChildless(); + } +}, { + selector: ':child', + matches: function matches(ele) { + return ele.isChild(); + } +}, { + selector: ':orphan', + matches: function matches(ele) { + return ele.isOrphan(); + } +}, { + selector: ':nonorphan', + matches: function matches(ele) { + return ele.isChild(); + } +}, { + selector: ':compound', + matches: function matches(ele) { + if (ele.isNode()) { + return ele.isParent(); + } else { + return ele.source().isParent() || ele.target().isParent(); + } + } +}, { + selector: ':loop', + matches: function matches(ele) { + return ele.isLoop(); + } +}, { + selector: ':simple', + matches: function matches(ele) { + return ele.isSimple(); + } +}, { + selector: ':active', + matches: function matches(ele) { + return ele.active(); + } +}, { + selector: ':inactive', + matches: function matches(ele) { + return !ele.active(); + } +}, { + selector: ':backgrounding', + matches: function matches(ele) { + return ele.backgrounding(); + } +}, { + selector: ':nonbackgrounding', + matches: function matches(ele) { + return !ele.backgrounding(); + } +}].sort(function (a, b) { + // n.b. selectors that are starting substrings of others must have the longer ones first + return descending(a.selector, b.selector); +}); +var lookup = function () { + var selToFn = {}; + var s; + for (var i = 0; i < stateSelectors.length; i++) { + s = stateSelectors[i]; + selToFn[s.selector] = s.matches; + } + return selToFn; +}(); +var stateSelectorMatches = function stateSelectorMatches(sel, ele) { + return lookup[sel](ele); +}; +var stateSelectorRegex = '(' + stateSelectors.map(function (s) { + return s.selector; +}).join('|') + ')'; + +// when a token like a variable has escaped meta characters, we need to clean the backslashes out +// so that values get compared properly in Selector.filter() +var cleanMetaChars = function cleanMetaChars(str) { + return str.replace(new RegExp('\\\\(' + tokens.metaChar + ')', 'g'), function (match, $1) { + return $1; + }); +}; +var replaceLastQuery = function replaceLastQuery(selector, examiningQuery, replacementQuery) { + selector[selector.length - 1] = replacementQuery; +}; + +// NOTE: add new expression syntax here to have it recognised by the parser; +// - a query contains all adjacent (i.e. no separator in between) expressions; +// - the current query is stored in selector[i] +// - you need to check the query objects in match() for it actually filter properly, but that's pretty straight forward +var exprs = [{ + name: 'group', + // just used for identifying when debugging + query: true, + regex: '(' + tokens.group + ')', + populate: function populate(selector, query, _ref) { + var _ref2 = _slicedToArray(_ref, 1), + group = _ref2[0]; + query.checks.push({ + type: Type.GROUP, + value: group === '*' ? group : group + 's' + }); + } +}, { + name: 'state', + query: true, + regex: stateSelectorRegex, + populate: function populate(selector, query, _ref3) { + var _ref4 = _slicedToArray(_ref3, 1), + state = _ref4[0]; + query.checks.push({ + type: Type.STATE, + value: state + }); + } +}, { + name: 'id', + query: true, + regex: '\\#(' + tokens.id + ')', + populate: function populate(selector, query, _ref5) { + var _ref6 = _slicedToArray(_ref5, 1), + id = _ref6[0]; + query.checks.push({ + type: Type.ID, + value: cleanMetaChars(id) + }); + } +}, { + name: 'className', + query: true, + regex: '\\.(' + tokens.className + ')', + populate: function populate(selector, query, _ref7) { + var _ref8 = _slicedToArray(_ref7, 1), + className = _ref8[0]; + query.checks.push({ + type: Type.CLASS, + value: cleanMetaChars(className) + }); + } +}, { + name: 'dataExists', + query: true, + regex: '\\[\\s*(' + tokens.variable + ')\\s*\\]', + populate: function populate(selector, query, _ref9) { + var _ref10 = _slicedToArray(_ref9, 1), + variable = _ref10[0]; + query.checks.push({ + type: Type.DATA_EXIST, + field: cleanMetaChars(variable) + }); + } +}, { + name: 'dataCompare', + query: true, + regex: '\\[\\s*(' + tokens.variable + ')\\s*(' + tokens.comparatorOp + ')\\s*(' + tokens.value + ')\\s*\\]', + populate: function populate(selector, query, _ref11) { + var _ref12 = _slicedToArray(_ref11, 3), + variable = _ref12[0], + comparatorOp = _ref12[1], + value = _ref12[2]; + var valueIsString = new RegExp('^' + tokens.string + '$').exec(value) != null; + if (valueIsString) { + value = value.substring(1, value.length - 1); + } else { + value = parseFloat(value); + } + query.checks.push({ + type: Type.DATA_COMPARE, + field: cleanMetaChars(variable), + operator: comparatorOp, + value: value + }); + } +}, { + name: 'dataBool', + query: true, + regex: '\\[\\s*(' + tokens.boolOp + ')\\s*(' + tokens.variable + ')\\s*\\]', + populate: function populate(selector, query, _ref13) { + var _ref14 = _slicedToArray(_ref13, 2), + boolOp = _ref14[0], + variable = _ref14[1]; + query.checks.push({ + type: Type.DATA_BOOL, + field: cleanMetaChars(variable), + operator: boolOp + }); + } +}, { + name: 'metaCompare', + query: true, + regex: '\\[\\[\\s*(' + tokens.meta + ')\\s*(' + tokens.comparatorOp + ')\\s*(' + tokens.number + ')\\s*\\]\\]', + populate: function populate(selector, query, _ref15) { + var _ref16 = _slicedToArray(_ref15, 3), + meta = _ref16[0], + comparatorOp = _ref16[1], + number = _ref16[2]; + query.checks.push({ + type: Type.META_COMPARE, + field: cleanMetaChars(meta), + operator: comparatorOp, + value: parseFloat(number) + }); + } +}, { + name: 'nextQuery', + separator: true, + regex: tokens.separator, + populate: function populate(selector, query) { + var currentSubject = selector.currentSubject; + var edgeCount = selector.edgeCount; + var compoundCount = selector.compoundCount; + var lastQ = selector[selector.length - 1]; + if (currentSubject != null) { + lastQ.subject = currentSubject; + selector.currentSubject = null; + } + lastQ.edgeCount = edgeCount; + lastQ.compoundCount = compoundCount; + selector.edgeCount = 0; + selector.compoundCount = 0; + + // go on to next query + var nextQuery = selector[selector.length++] = newQuery(); + return nextQuery; // this is the new query to be filled by the following exprs + } +}, { + name: 'directedEdge', + separator: true, + regex: tokens.directedEdge, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // undirected edge + var edgeQuery = newQuery(); + var source = query; + var target = newQuery(); + edgeQuery.checks.push({ + type: Type.DIRECTED_EDGE, + source: source, + target: target + }); + + // the query in the selector should be the edge rather than the source + replaceLastQuery(selector, query, edgeQuery); + selector.edgeCount++; + + // we're now populating the target query with expressions that follow + return target; + } else { + // source/target + var srcTgtQ = newQuery(); + var _source = query; + var _target = newQuery(); + srcTgtQ.checks.push({ + type: Type.NODE_SOURCE, + source: _source, + target: _target + }); + + // the query in the selector should be the neighbourhood rather than the node + replaceLastQuery(selector, query, srcTgtQ); + selector.edgeCount++; + return _target; // now populating the target with the following expressions + } + } +}, { + name: 'undirectedEdge', + separator: true, + regex: tokens.undirectedEdge, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // undirected edge + var edgeQuery = newQuery(); + var source = query; + var target = newQuery(); + edgeQuery.checks.push({ + type: Type.UNDIRECTED_EDGE, + nodes: [source, target] + }); + + // the query in the selector should be the edge rather than the source + replaceLastQuery(selector, query, edgeQuery); + selector.edgeCount++; + + // we're now populating the target query with expressions that follow + return target; + } else { + // neighbourhood + var nhoodQ = newQuery(); + var node = query; + var neighbor = newQuery(); + nhoodQ.checks.push({ + type: Type.NODE_NEIGHBOR, + node: node, + neighbor: neighbor + }); + + // the query in the selector should be the neighbourhood rather than the node + replaceLastQuery(selector, query, nhoodQ); + return neighbor; // now populating the neighbor with following expressions + } + } +}, { + name: 'child', + separator: true, + regex: tokens.child, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // default: child query + var parentChildQuery = newQuery(); + var child = newQuery(); + var parent = selector[selector.length - 1]; + parentChildQuery.checks.push({ + type: Type.CHILD, + parent: parent, + child: child + }); + + // the query in the selector should be the '>' itself + replaceLastQuery(selector, query, parentChildQuery); + selector.compoundCount++; + + // we're now populating the child query with expressions that follow + return child; + } else if (selector.currentSubject === query) { + // compound split query + var compound = newQuery(); + var left = selector[selector.length - 1]; + var right = newQuery(); + var subject = newQuery(); + var _child = newQuery(); + var _parent = newQuery(); + + // set up the root compound q + compound.checks.push({ + type: Type.COMPOUND_SPLIT, + left: left, + right: right, + subject: subject + }); + + // populate the subject and replace the q at the old spot (within left) with TRUE + subject.checks = query.checks; // take the checks from the left + query.checks = [{ + type: Type.TRUE + }]; // checks under left refs the subject implicitly + + // set up the right q + _parent.checks.push({ + type: Type.TRUE + }); // parent implicitly refs the subject + right.checks.push({ + type: Type.PARENT, + // type is swapped on right side queries + parent: _parent, + child: _child // empty for now + }); + + replaceLastQuery(selector, left, compound); + + // update the ref since we moved things around for `query` + selector.currentSubject = subject; + selector.compoundCount++; + return _child; // now populating the right side's child + } else { + // parent query + // info for parent query + var _parent2 = newQuery(); + var _child2 = newQuery(); + var pcQChecks = [{ + type: Type.PARENT, + parent: _parent2, + child: _child2 + }]; + + // the parent-child query takes the place of the query previously being populated + _parent2.checks = query.checks; // the previous query contains the checks for the parent + query.checks = pcQChecks; // pc query takes over + + selector.compoundCount++; + return _child2; // we're now populating the child + } + } +}, { + name: 'descendant', + separator: true, + regex: tokens.descendant, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // default: descendant query + var ancChQuery = newQuery(); + var descendant = newQuery(); + var ancestor = selector[selector.length - 1]; + ancChQuery.checks.push({ + type: Type.DESCENDANT, + ancestor: ancestor, + descendant: descendant + }); + + // the query in the selector should be the '>' itself + replaceLastQuery(selector, query, ancChQuery); + selector.compoundCount++; + + // we're now populating the descendant query with expressions that follow + return descendant; + } else if (selector.currentSubject === query) { + // compound split query + var compound = newQuery(); + var left = selector[selector.length - 1]; + var right = newQuery(); + var subject = newQuery(); + var _descendant = newQuery(); + var _ancestor = newQuery(); + + // set up the root compound q + compound.checks.push({ + type: Type.COMPOUND_SPLIT, + left: left, + right: right, + subject: subject + }); + + // populate the subject and replace the q at the old spot (within left) with TRUE + subject.checks = query.checks; // take the checks from the left + query.checks = [{ + type: Type.TRUE + }]; // checks under left refs the subject implicitly + + // set up the right q + _ancestor.checks.push({ + type: Type.TRUE + }); // ancestor implicitly refs the subject + right.checks.push({ + type: Type.ANCESTOR, + // type is swapped on right side queries + ancestor: _ancestor, + descendant: _descendant // empty for now + }); + + replaceLastQuery(selector, left, compound); + + // update the ref since we moved things around for `query` + selector.currentSubject = subject; + selector.compoundCount++; + return _descendant; // now populating the right side's descendant + } else { + // ancestor query + // info for parent query + var _ancestor2 = newQuery(); + var _descendant2 = newQuery(); + var adQChecks = [{ + type: Type.ANCESTOR, + ancestor: _ancestor2, + descendant: _descendant2 + }]; + + // the parent-child query takes the place of the query previously being populated + _ancestor2.checks = query.checks; // the previous query contains the checks for the parent + query.checks = adQChecks; // pc query takes over + + selector.compoundCount++; + return _descendant2; // we're now populating the child + } + } +}, { + name: 'subject', + modifier: true, + regex: tokens.subject, + populate: function populate(selector, query) { + if (selector.currentSubject != null && selector.currentSubject !== query) { + warn('Redefinition of subject in selector `' + selector.toString() + '`'); + return false; + } + selector.currentSubject = query; + var topQ = selector[selector.length - 1]; + var topChk = topQ.checks[0]; + var topType = topChk == null ? null : topChk.type; + if (topType === Type.DIRECTED_EDGE) { + // directed edge with subject on the target + + // change to target node check + topChk.type = Type.NODE_TARGET; + } else if (topType === Type.UNDIRECTED_EDGE) { + // undirected edge with subject on the second node + + // change to neighbor check + topChk.type = Type.NODE_NEIGHBOR; + topChk.node = topChk.nodes[1]; // second node is subject + topChk.neighbor = topChk.nodes[0]; + + // clean up unused fields for new type + topChk.nodes = null; + } + } +}]; +exprs.forEach(function (e) { + return e.regexObj = new RegExp('^' + e.regex); +}); + +/** + * Of all the expressions, find the first match in the remaining text. + * @param {string} remaining The remaining text to parse + * @returns The matched expression and the newly remaining text `{ expr, match, name, remaining }` + */ +var consumeExpr = function consumeExpr(remaining) { + var expr; + var match; + var name; + for (var j = 0; j < exprs.length; j++) { + var e = exprs[j]; + var n = e.name; + var m = remaining.match(e.regexObj); + if (m != null) { + match = m; + expr = e; + name = n; + var consumed = m[0]; + remaining = remaining.substring(consumed.length); + break; // we've consumed one expr, so we can return now + } + } + + return { + expr: expr, + match: match, + name: name, + remaining: remaining + }; +}; + +/** + * Consume all the leading whitespace + * @param {string} remaining The text to consume + * @returns The text with the leading whitespace removed + */ +var consumeWhitespace = function consumeWhitespace(remaining) { + var match = remaining.match(/^\s+/); + if (match) { + var consumed = match[0]; + remaining = remaining.substring(consumed.length); + } + return remaining; +}; + +/** + * Parse the string and store the parsed representation in the Selector. + * @param {string} selector The selector string + * @returns `true` if the selector was successfully parsed, `false` otherwise + */ +var parse = function parse(selector) { + var self = this; + var remaining = self.inputText = selector; + var currentQuery = self[0] = newQuery(); + self.length = 1; + remaining = consumeWhitespace(remaining); // get rid of leading whitespace + + for (;;) { + var exprInfo = consumeExpr(remaining); + if (exprInfo.expr == null) { + warn('The selector `' + selector + '`is invalid'); + return false; + } else { + var args = exprInfo.match.slice(1); + + // let the token populate the selector object in currentQuery + var ret = exprInfo.expr.populate(self, currentQuery, args); + if (ret === false) { + return false; // exit if population failed + } else if (ret != null) { + currentQuery = ret; // change the current query to be filled if the expr specifies + } + } + + remaining = exprInfo.remaining; + + // we're done when there's nothing left to parse + if (remaining.match(/^\s*$/)) { + break; + } + } + var lastQ = self[self.length - 1]; + if (self.currentSubject != null) { + lastQ.subject = self.currentSubject; + } + lastQ.edgeCount = self.edgeCount; + lastQ.compoundCount = self.compoundCount; + for (var i = 0; i < self.length; i++) { + var q = self[i]; + + // in future, this could potentially be allowed if there were operator precedence and detection of invalid combinations + if (q.compoundCount > 0 && q.edgeCount > 0) { + warn('The selector `' + selector + '` is invalid because it uses both a compound selector and an edge selector'); + return false; + } + if (q.edgeCount > 1) { + warn('The selector `' + selector + '` is invalid because it uses multiple edge selectors'); + return false; + } else if (q.edgeCount === 1) { + warn('The selector `' + selector + '` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.'); + } + } + return true; // success +}; + +/** + * Get the selector represented as a string. This value uses default formatting, + * so things like spacing may differ from the input text passed to the constructor. + * @returns {string} The selector string + */ +var toString = function toString() { + if (this.toStringCache != null) { + return this.toStringCache; + } + var clean = function clean(obj) { + if (obj == null) { + return ''; + } else { + return obj; + } + }; + var cleanVal = function cleanVal(val) { + if (string(val)) { + return '"' + val + '"'; + } else { + return clean(val); + } + }; + var space = function space(val) { + return ' ' + val + ' '; + }; + var checkToString = function checkToString(check, subject) { + var type = check.type, + value = check.value; + switch (type) { + case Type.GROUP: + { + var group = clean(value); + return group.substring(0, group.length - 1); + } + case Type.DATA_COMPARE: + { + var field = check.field, + operator = check.operator; + return '[' + field + space(clean(operator)) + cleanVal(value) + ']'; + } + case Type.DATA_BOOL: + { + var _operator = check.operator, + _field = check.field; + return '[' + clean(_operator) + _field + ']'; + } + case Type.DATA_EXIST: + { + var _field2 = check.field; + return '[' + _field2 + ']'; + } + case Type.META_COMPARE: + { + var _operator2 = check.operator, + _field3 = check.field; + return '[[' + _field3 + space(clean(_operator2)) + cleanVal(value) + ']]'; + } + case Type.STATE: + { + return value; + } + case Type.ID: + { + return '#' + value; + } + case Type.CLASS: + { + return '.' + value; + } + case Type.PARENT: + case Type.CHILD: + { + return queryToString(check.parent, subject) + space('>') + queryToString(check.child, subject); + } + case Type.ANCESTOR: + case Type.DESCENDANT: + { + return queryToString(check.ancestor, subject) + ' ' + queryToString(check.descendant, subject); + } + case Type.COMPOUND_SPLIT: + { + var lhs = queryToString(check.left, subject); + var sub = queryToString(check.subject, subject); + var rhs = queryToString(check.right, subject); + return lhs + (lhs.length > 0 ? ' ' : '') + sub + rhs; + } + case Type.TRUE: + { + return ''; + } + } + }; + var queryToString = function queryToString(query, subject) { + return query.checks.reduce(function (str, chk, i) { + return str + (subject === query && i === 0 ? '$' : '') + checkToString(chk, subject); + }, ''); + }; + var str = ''; + for (var i = 0; i < this.length; i++) { + var query = this[i]; + str += queryToString(query, query.subject); + if (this.length > 1 && i < this.length - 1) { + str += ', '; + } + } + this.toStringCache = str; + return str; +}; +var parse$1 = { + parse: parse, + toString: toString +}; + +var valCmp = function valCmp(fieldVal, operator, value) { + var matches; + var isFieldStr = string(fieldVal); + var isFieldNum = number$1(fieldVal); + var isValStr = string(value); + var fieldStr, valStr; + var caseInsensitive = false; + var notExpr = false; + var isIneqCmp = false; + if (operator.indexOf('!') >= 0) { + operator = operator.replace('!', ''); + notExpr = true; + } + if (operator.indexOf('@') >= 0) { + operator = operator.replace('@', ''); + caseInsensitive = true; + } + if (isFieldStr || isValStr || caseInsensitive) { + fieldStr = !isFieldStr && !isFieldNum ? '' : '' + fieldVal; + valStr = '' + value; + } + + // if we're doing a case insensitive comparison, then we're using a STRING comparison + // even if we're comparing numbers + if (caseInsensitive) { + fieldVal = fieldStr = fieldStr.toLowerCase(); + value = valStr = valStr.toLowerCase(); + } + switch (operator) { + case '*=': + matches = fieldStr.indexOf(valStr) >= 0; + break; + case '$=': + matches = fieldStr.indexOf(valStr, fieldStr.length - valStr.length) >= 0; + break; + case '^=': + matches = fieldStr.indexOf(valStr) === 0; + break; + case '=': + matches = fieldVal === value; + break; + case '>': + isIneqCmp = true; + matches = fieldVal > value; + break; + case '>=': + isIneqCmp = true; + matches = fieldVal >= value; + break; + case '<': + isIneqCmp = true; + matches = fieldVal < value; + break; + case '<=': + isIneqCmp = true; + matches = fieldVal <= value; + break; + default: + matches = false; + break; + } + + // apply the not op, but null vals for inequalities should always stay non-matching + if (notExpr && (fieldVal != null || !isIneqCmp)) { + matches = !matches; + } + return matches; +}; +var boolCmp = function boolCmp(fieldVal, operator) { + switch (operator) { + case '?': + return fieldVal ? true : false; + case '!': + return fieldVal ? false : true; + case '^': + return fieldVal === undefined; + } +}; +var existCmp = function existCmp(fieldVal) { + return fieldVal !== undefined; +}; +var data$1 = function data(ele, field) { + return ele.data(field); +}; +var meta = function meta(ele, field) { + return ele[field](); +}; + +/** A lookup of `match(check, ele)` functions by `Type` int */ +var match = []; + +/** + * Returns whether the query matches for the element + * @param query The `{ type, value, ... }` query object + * @param ele The element to compare against +*/ +var matches$1 = function matches(query, ele) { + return query.checks.every(function (chk) { + return match[chk.type](chk, ele); + }); +}; +match[Type.GROUP] = function (check, ele) { + var group = check.value; + return group === '*' || group === ele.group(); +}; +match[Type.STATE] = function (check, ele) { + var stateSelector = check.value; + return stateSelectorMatches(stateSelector, ele); +}; +match[Type.ID] = function (check, ele) { + var id = check.value; + return ele.id() === id; +}; +match[Type.CLASS] = function (check, ele) { + var cls = check.value; + return ele.hasClass(cls); +}; +match[Type.META_COMPARE] = function (check, ele) { + var field = check.field, + operator = check.operator, + value = check.value; + return valCmp(meta(ele, field), operator, value); +}; +match[Type.DATA_COMPARE] = function (check, ele) { + var field = check.field, + operator = check.operator, + value = check.value; + return valCmp(data$1(ele, field), operator, value); +}; +match[Type.DATA_BOOL] = function (check, ele) { + var field = check.field, + operator = check.operator; + return boolCmp(data$1(ele, field), operator); +}; +match[Type.DATA_EXIST] = function (check, ele) { + var field = check.field; + check.operator; + return existCmp(data$1(ele, field)); +}; +match[Type.UNDIRECTED_EDGE] = function (check, ele) { + var qA = check.nodes[0]; + var qB = check.nodes[1]; + var src = ele.source(); + var tgt = ele.target(); + return matches$1(qA, src) && matches$1(qB, tgt) || matches$1(qB, src) && matches$1(qA, tgt); +}; +match[Type.NODE_NEIGHBOR] = function (check, ele) { + return matches$1(check.node, ele) && ele.neighborhood().some(function (n) { + return n.isNode() && matches$1(check.neighbor, n); + }); +}; +match[Type.DIRECTED_EDGE] = function (check, ele) { + return matches$1(check.source, ele.source()) && matches$1(check.target, ele.target()); +}; +match[Type.NODE_SOURCE] = function (check, ele) { + return matches$1(check.source, ele) && ele.outgoers().some(function (n) { + return n.isNode() && matches$1(check.target, n); + }); +}; +match[Type.NODE_TARGET] = function (check, ele) { + return matches$1(check.target, ele) && ele.incomers().some(function (n) { + return n.isNode() && matches$1(check.source, n); + }); +}; +match[Type.CHILD] = function (check, ele) { + return matches$1(check.child, ele) && matches$1(check.parent, ele.parent()); +}; +match[Type.PARENT] = function (check, ele) { + return matches$1(check.parent, ele) && ele.children().some(function (c) { + return matches$1(check.child, c); + }); +}; +match[Type.DESCENDANT] = function (check, ele) { + return matches$1(check.descendant, ele) && ele.ancestors().some(function (a) { + return matches$1(check.ancestor, a); + }); +}; +match[Type.ANCESTOR] = function (check, ele) { + return matches$1(check.ancestor, ele) && ele.descendants().some(function (d) { + return matches$1(check.descendant, d); + }); +}; +match[Type.COMPOUND_SPLIT] = function (check, ele) { + return matches$1(check.subject, ele) && matches$1(check.left, ele) && matches$1(check.right, ele); +}; +match[Type.TRUE] = function () { + return true; +}; +match[Type.COLLECTION] = function (check, ele) { + var collection = check.value; + return collection.has(ele); +}; +match[Type.FILTER] = function (check, ele) { + var filter = check.value; + return filter(ele); +}; + +// filter an existing collection +var filter = function filter(collection) { + var self = this; + + // for 1 id #foo queries, just get the element + if (self.length === 1 && self[0].checks.length === 1 && self[0].checks[0].type === Type.ID) { + return collection.getElementById(self[0].checks[0].value).collection(); + } + var selectorFunction = function selectorFunction(element) { + for (var j = 0; j < self.length; j++) { + var query = self[j]; + if (matches$1(query, element)) { + return true; + } + } + return false; + }; + if (self.text() == null) { + selectorFunction = function selectorFunction() { + return true; + }; + } + return collection.filter(selectorFunction); +}; // filter + +// does selector match a single element? +var matches = function matches(ele) { + var self = this; + for (var j = 0; j < self.length; j++) { + var query = self[j]; + if (matches$1(query, ele)) { + return true; + } + } + return false; +}; // matches + +var matching = { + matches: matches, + filter: filter +}; + +var Selector = function Selector(selector) { + this.inputText = selector; + this.currentSubject = null; + this.compoundCount = 0; + this.edgeCount = 0; + this.length = 0; + if (selector == null || string(selector) && selector.match(/^\s*$/)) ; else if (elementOrCollection(selector)) { + this.addQuery({ + checks: [{ + type: Type.COLLECTION, + value: selector.collection() + }] + }); + } else if (fn$6(selector)) { + this.addQuery({ + checks: [{ + type: Type.FILTER, + value: selector + }] + }); + } else if (string(selector)) { + if (!this.parse(selector)) { + this.invalid = true; + } + } else { + error('A selector must be created from a string; found '); + } +}; +var selfn = Selector.prototype; +[parse$1, matching].forEach(function (p) { + return extend(selfn, p); +}); +selfn.text = function () { + return this.inputText; +}; +selfn.size = function () { + return this.length; +}; +selfn.eq = function (i) { + return this[i]; +}; +selfn.sameText = function (otherSel) { + return !this.invalid && !otherSel.invalid && this.text() === otherSel.text(); +}; +selfn.addQuery = function (q) { + this[this.length++] = q; +}; +selfn.selector = selfn.toString; + +var elesfn$g = { + allAre: function allAre(selector) { + var selObj = new Selector(selector); + return this.every(function (ele) { + return selObj.matches(ele); + }); + }, + is: function is(selector) { + var selObj = new Selector(selector); + return this.some(function (ele) { + return selObj.matches(ele); + }); + }, + some: function some(fn, thisArg) { + for (var i = 0; i < this.length; i++) { + var ret = !thisArg ? fn(this[i], i, this) : fn.apply(thisArg, [this[i], i, this]); + if (ret) { + return true; + } + } + return false; + }, + every: function every(fn, thisArg) { + for (var i = 0; i < this.length; i++) { + var ret = !thisArg ? fn(this[i], i, this) : fn.apply(thisArg, [this[i], i, this]); + if (!ret) { + return false; + } + } + return true; + }, + same: function same(collection) { + // cheap collection ref check + if (this === collection) { + return true; + } + collection = this.cy().collection(collection); + var thisLength = this.length; + var collectionLength = collection.length; + + // cheap length check + if (thisLength !== collectionLength) { + return false; + } + + // cheap element ref check + if (thisLength === 1) { + return this[0] === collection[0]; + } + return this.every(function (ele) { + return collection.hasElementWithId(ele.id()); + }); + }, + anySame: function anySame(collection) { + collection = this.cy().collection(collection); + return this.some(function (ele) { + return collection.hasElementWithId(ele.id()); + }); + }, + allAreNeighbors: function allAreNeighbors(collection) { + collection = this.cy().collection(collection); + var nhood = this.neighborhood(); + return collection.every(function (ele) { + return nhood.hasElementWithId(ele.id()); + }); + }, + contains: function contains(collection) { + collection = this.cy().collection(collection); + var self = this; + return collection.every(function (ele) { + return self.hasElementWithId(ele.id()); + }); + } +}; +elesfn$g.allAreNeighbours = elesfn$g.allAreNeighbors; +elesfn$g.has = elesfn$g.contains; +elesfn$g.equal = elesfn$g.equals = elesfn$g.same; + +var cache = function cache(fn, name) { + return function traversalCache(arg1, arg2, arg3, arg4) { + var selectorOrEles = arg1; + var eles = this; + var key; + if (selectorOrEles == null) { + key = ''; + } else if (elementOrCollection(selectorOrEles) && selectorOrEles.length === 1) { + key = selectorOrEles.id(); + } + if (eles.length === 1 && key) { + var _p = eles[0]._private; + var tch = _p.traversalCache = _p.traversalCache || {}; + var ch = tch[name] = tch[name] || []; + var hash = hashString(key); + var cacheHit = ch[hash]; + if (cacheHit) { + return cacheHit; + } else { + return ch[hash] = fn.call(eles, arg1, arg2, arg3, arg4); + } + } else { + return fn.call(eles, arg1, arg2, arg3, arg4); + } + }; +}; + +var elesfn$f = { + parent: function parent(selector) { + var parents = []; + + // optimisation for single ele call + if (this.length === 1) { + var parent = this[0]._private.parent; + if (parent) { + return parent; + } + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _parent = ele._private.parent; + if (_parent) { + parents.push(_parent); + } + } + return this.spawn(parents, true).filter(selector); + }, + parents: function parents(selector) { + var parents = []; + var eles = this.parent(); + while (eles.nonempty()) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + parents.push(ele); + } + eles = eles.parent(); + } + return this.spawn(parents, true).filter(selector); + }, + commonAncestors: function commonAncestors(selector) { + var ancestors; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var parents = ele.parents(); + ancestors = ancestors || parents; + ancestors = ancestors.intersect(parents); // current list must be common with current ele parents set + } + + return ancestors.filter(selector); + }, + orphans: function orphans(selector) { + return this.stdFilter(function (ele) { + return ele.isOrphan(); + }).filter(selector); + }, + nonorphans: function nonorphans(selector) { + return this.stdFilter(function (ele) { + return ele.isChild(); + }).filter(selector); + }, + children: cache(function (selector) { + var children = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var eleChildren = ele._private.children; + for (var j = 0; j < eleChildren.length; j++) { + children.push(eleChildren[j]); + } + } + return this.spawn(children, true).filter(selector); + }, 'children'), + siblings: function siblings(selector) { + return this.parent().children().not(this).filter(selector); + }, + isParent: function isParent() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.children.length !== 0; + } + }, + isChildless: function isChildless() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.children.length === 0; + } + }, + isChild: function isChild() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.parent != null; + } + }, + isOrphan: function isOrphan() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.parent == null; + } + }, + descendants: function descendants(selector) { + var elements = []; + function add(eles) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + elements.push(ele); + if (ele.children().nonempty()) { + add(ele.children()); + } + } + } + add(this.children()); + return this.spawn(elements, true).filter(selector); + } +}; +function forEachCompound(eles, fn, includeSelf, recursiveStep) { + var q = []; + var did = new Set$1(); + var cy = eles.cy(); + var hasCompounds = cy.hasCompoundNodes(); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (includeSelf) { + q.push(ele); + } else if (hasCompounds) { + recursiveStep(q, did, ele); + } + } + while (q.length > 0) { + var _ele = q.shift(); + fn(_ele); + did.add(_ele.id()); + if (hasCompounds) { + recursiveStep(q, did, _ele); + } + } + return eles; +} +function addChildren(q, did, ele) { + if (ele.isParent()) { + var children = ele._private.children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (!did.has(child.id())) { + q.push(child); + } + } + } +} + +// very efficient version of eles.add( eles.descendants() ).forEach() +// for internal use +elesfn$f.forEachDown = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addChildren); +}; +function addParent(q, did, ele) { + if (ele.isChild()) { + var parent = ele._private.parent; + if (!did.has(parent.id())) { + q.push(parent); + } + } +} +elesfn$f.forEachUp = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addParent); +}; +function addParentAndChildren(q, did, ele) { + addParent(q, did, ele); + addChildren(q, did, ele); +} +elesfn$f.forEachUpAndDown = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addParentAndChildren); +}; + +// aliases +elesfn$f.ancestors = elesfn$f.parents; + +var fn$5, elesfn$e; +fn$5 = elesfn$e = { + data: define.data({ + field: 'data', + bindingEvent: 'data', + allowBinding: true, + allowSetting: true, + settingEvent: 'data', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + immutableKeys: { + 'id': true, + 'source': true, + 'target': true, + 'parent': true + }, + updateStyle: true + }), + removeData: define.removeData({ + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: true, + immutableKeys: { + 'id': true, + 'source': true, + 'target': true, + 'parent': true + }, + updateStyle: true + }), + scratch: define.data({ + field: 'scratch', + bindingEvent: 'scratch', + allowBinding: true, + allowSetting: true, + settingEvent: 'scratch', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeScratch: define.removeData({ + field: 'scratch', + event: 'scratch', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }), + rscratch: define.data({ + field: 'rscratch', + allowBinding: false, + allowSetting: true, + settingTriggersEvent: false, + allowGetting: true + }), + removeRscratch: define.removeData({ + field: 'rscratch', + triggerEvent: false + }), + id: function id() { + var ele = this[0]; + if (ele) { + return ele._private.data.id; + } + } +}; + +// aliases +fn$5.attr = fn$5.data; +fn$5.removeAttr = fn$5.removeData; +var data = elesfn$e; + +var elesfn$d = {}; +function defineDegreeFunction(callback) { + return function (includeLoops) { + var self = this; + if (includeLoops === undefined) { + includeLoops = true; + } + if (self.length === 0) { + return; + } + if (self.isNode() && !self.removed()) { + var degree = 0; + var node = self[0]; + var connectedEdges = node._private.edges; + for (var i = 0; i < connectedEdges.length; i++) { + var edge = connectedEdges[i]; + if (!includeLoops && edge.isLoop()) { + continue; + } + degree += callback(node, edge); + } + return degree; + } else { + return; + } + }; +} +extend(elesfn$d, { + degree: defineDegreeFunction(function (node, edge) { + if (edge.source().same(edge.target())) { + return 2; + } else { + return 1; + } + }), + indegree: defineDegreeFunction(function (node, edge) { + if (edge.target().same(node)) { + return 1; + } else { + return 0; + } + }), + outdegree: defineDegreeFunction(function (node, edge) { + if (edge.source().same(node)) { + return 1; + } else { + return 0; + } + }) +}); +function defineDegreeBoundsFunction(degreeFn, callback) { + return function (includeLoops) { + var ret; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + var ele = nodes[i]; + var degree = ele[degreeFn](includeLoops); + if (degree !== undefined && (ret === undefined || callback(degree, ret))) { + ret = degree; + } + } + return ret; + }; +} +extend(elesfn$d, { + minDegree: defineDegreeBoundsFunction('degree', function (degree, min) { + return degree < min; + }), + maxDegree: defineDegreeBoundsFunction('degree', function (degree, max) { + return degree > max; + }), + minIndegree: defineDegreeBoundsFunction('indegree', function (degree, min) { + return degree < min; + }), + maxIndegree: defineDegreeBoundsFunction('indegree', function (degree, max) { + return degree > max; + }), + minOutdegree: defineDegreeBoundsFunction('outdegree', function (degree, min) { + return degree < min; + }), + maxOutdegree: defineDegreeBoundsFunction('outdegree', function (degree, max) { + return degree > max; + }) +}); +extend(elesfn$d, { + totalDegree: function totalDegree(includeLoops) { + var total = 0; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + total += nodes[i].degree(includeLoops); + } + return total; + } +}); + +var fn$4, elesfn$c; +var beforePositionSet = function beforePositionSet(eles, newPos, silent) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.locked()) { + var oldPos = ele._private.position; + var delta = { + x: newPos.x != null ? newPos.x - oldPos.x : 0, + y: newPos.y != null ? newPos.y - oldPos.y : 0 + }; + if (ele.isParent() && !(delta.x === 0 && delta.y === 0)) { + ele.children().shift(delta, silent); + } + ele.dirtyBoundingBoxCache(); + } + } +}; +var positionDef = { + field: 'position', + bindingEvent: 'position', + allowBinding: true, + allowSetting: true, + settingEvent: 'position', + settingTriggersEvent: true, + triggerFnName: 'emitAndNotify', + allowGetting: true, + validKeys: ['x', 'y'], + beforeGet: function beforeGet(ele) { + ele.updateCompoundBounds(); + }, + beforeSet: function beforeSet(eles, newPos) { + beforePositionSet(eles, newPos, false); + }, + onSet: function onSet(eles) { + eles.dirtyCompoundBoundsCache(); + }, + canSet: function canSet(ele) { + return !ele.locked(); + } +}; +fn$4 = elesfn$c = { + position: define.data(positionDef), + // position but no notification to renderer + silentPosition: define.data(extend({}, positionDef, { + allowBinding: false, + allowSetting: true, + settingTriggersEvent: false, + allowGetting: false, + beforeSet: function beforeSet(eles, newPos) { + beforePositionSet(eles, newPos, true); + }, + onSet: function onSet(eles) { + eles.dirtyCompoundBoundsCache(); + } + })), + positions: function positions(pos, silent) { + if (plainObject(pos)) { + if (silent) { + this.silentPosition(pos); + } else { + this.position(pos); + } + } else if (fn$6(pos)) { + var _fn = pos; + var cy = this.cy(); + cy.startBatch(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _pos = void 0; + if (_pos = _fn(ele, i)) { + if (silent) { + ele.silentPosition(_pos); + } else { + ele.position(_pos); + } + } + } + cy.endBatch(); + } + return this; // chaining + }, + + silentPositions: function silentPositions(pos) { + return this.positions(pos, true); + }, + shift: function shift(dim, val, silent) { + var delta; + if (plainObject(dim)) { + delta = { + x: number$1(dim.x) ? dim.x : 0, + y: number$1(dim.y) ? dim.y : 0 + }; + silent = val; + } else if (string(dim) && number$1(val)) { + delta = { + x: 0, + y: 0 + }; + delta[dim] = val; + } + if (delta != null) { + var cy = this.cy(); + cy.startBatch(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + + // exclude any node that is a descendant of the calling collection + if (cy.hasCompoundNodes() && ele.isChild() && ele.ancestors().anySame(this)) { + continue; + } + var pos = ele.position(); + var newPos = { + x: pos.x + delta.x, + y: pos.y + delta.y + }; + if (silent) { + ele.silentPosition(newPos); + } else { + ele.position(newPos); + } + } + cy.endBatch(); + } + return this; + }, + silentShift: function silentShift(dim, val) { + if (plainObject(dim)) { + this.shift(dim, true); + } else if (string(dim) && number$1(val)) { + this.shift(dim, val, true); + } + return this; + }, + // get/set the rendered (i.e. on screen) positon of the element + renderedPosition: function renderedPosition(dim, val) { + var ele = this[0]; + var cy = this.cy(); + var zoom = cy.zoom(); + var pan = cy.pan(); + var rpos = plainObject(dim) ? dim : undefined; + var setting = rpos !== undefined || val !== undefined && string(dim); + if (ele && ele.isNode()) { + // must have an element and must be a node to return position + if (setting) { + for (var i = 0; i < this.length; i++) { + var _ele = this[i]; + if (val !== undefined) { + // set one dimension + _ele.position(dim, (val - pan[dim]) / zoom); + } else if (rpos !== undefined) { + // set whole position + _ele.position(renderedToModelPosition(rpos, zoom, pan)); + } + } + } else { + // getting + var pos = ele.position(); + rpos = modelToRenderedPosition(pos, zoom, pan); + if (dim === undefined) { + // then return the whole rendered position + return rpos; + } else { + // then return the specified dimension + return rpos[dim]; + } + } + } else if (!setting) { + return undefined; // for empty collection case + } + + return this; // chaining + }, + + // get/set the position relative to the parent + relativePosition: function relativePosition(dim, val) { + var ele = this[0]; + var cy = this.cy(); + var ppos = plainObject(dim) ? dim : undefined; + var setting = ppos !== undefined || val !== undefined && string(dim); + var hasCompoundNodes = cy.hasCompoundNodes(); + if (ele && ele.isNode()) { + // must have an element and must be a node to return position + if (setting) { + for (var i = 0; i < this.length; i++) { + var _ele2 = this[i]; + var parent = hasCompoundNodes ? _ele2.parent() : null; + var hasParent = parent && parent.length > 0; + var relativeToParent = hasParent; + if (hasParent) { + parent = parent[0]; + } + var origin = relativeToParent ? parent.position() : { + x: 0, + y: 0 + }; + if (val !== undefined) { + // set one dimension + _ele2.position(dim, val + origin[dim]); + } else if (ppos !== undefined) { + // set whole position + _ele2.position({ + x: ppos.x + origin.x, + y: ppos.y + origin.y + }); + } + } + } else { + // getting + var pos = ele.position(); + var _parent = hasCompoundNodes ? ele.parent() : null; + var _hasParent = _parent && _parent.length > 0; + var _relativeToParent = _hasParent; + if (_hasParent) { + _parent = _parent[0]; + } + var _origin = _relativeToParent ? _parent.position() : { + x: 0, + y: 0 + }; + ppos = { + x: pos.x - _origin.x, + y: pos.y - _origin.y + }; + if (dim === undefined) { + // then return the whole rendered position + return ppos; + } else { + // then return the specified dimension + return ppos[dim]; + } + } + } else if (!setting) { + return undefined; // for empty collection case + } + + return this; // chaining + } +}; + +// aliases +fn$4.modelPosition = fn$4.point = fn$4.position; +fn$4.modelPositions = fn$4.points = fn$4.positions; +fn$4.renderedPoint = fn$4.renderedPosition; +fn$4.relativePoint = fn$4.relativePosition; +var position = elesfn$c; + +var fn$3, elesfn$b; +fn$3 = elesfn$b = {}; +elesfn$b.renderedBoundingBox = function (options) { + var bb = this.boundingBox(options); + var cy = this.cy(); + var zoom = cy.zoom(); + var pan = cy.pan(); + var x1 = bb.x1 * zoom + pan.x; + var x2 = bb.x2 * zoom + pan.x; + var y1 = bb.y1 * zoom + pan.y; + var y2 = bb.y2 * zoom + pan.y; + return { + x1: x1, + x2: x2, + y1: y1, + y2: y2, + w: x2 - x1, + h: y2 - y1 + }; +}; +elesfn$b.dirtyCompoundBoundsCache = function () { + var silent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var cy = this.cy(); + if (!cy.styleEnabled() || !cy.hasCompoundNodes()) { + return this; + } + this.forEachUp(function (ele) { + if (ele.isParent()) { + var _p = ele._private; + _p.compoundBoundsClean = false; + _p.bbCache = null; + if (!silent) { + ele.emitAndNotify('bounds'); + } + } + }); + return this; +}; +elesfn$b.updateCompoundBounds = function () { + var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var cy = this.cy(); + + // not possible to do on non-compound graphs or with the style disabled + if (!cy.styleEnabled() || !cy.hasCompoundNodes()) { + return this; + } + + // save cycles when batching -- but bounds will be stale (or not exist yet) + if (!force && cy.batching()) { + return this; + } + function update(parent) { + if (!parent.isParent()) { + return; + } + var _p = parent._private; + var children = parent.children(); + var includeLabels = parent.pstyle('compound-sizing-wrt-labels').value === 'include'; + var min = { + width: { + val: parent.pstyle('min-width').pfValue, + left: parent.pstyle('min-width-bias-left'), + right: parent.pstyle('min-width-bias-right') + }, + height: { + val: parent.pstyle('min-height').pfValue, + top: parent.pstyle('min-height-bias-top'), + bottom: parent.pstyle('min-height-bias-bottom') + } + }; + var bb = children.boundingBox({ + includeLabels: includeLabels, + includeOverlays: false, + // updating the compound bounds happens outside of the regular + // cache cycle (i.e. before fired events) + useCache: false + }); + var pos = _p.position; + + // if children take up zero area then keep position and fall back on stylesheet w/h + if (bb.w === 0 || bb.h === 0) { + bb = { + w: parent.pstyle('width').pfValue, + h: parent.pstyle('height').pfValue + }; + bb.x1 = pos.x - bb.w / 2; + bb.x2 = pos.x + bb.w / 2; + bb.y1 = pos.y - bb.h / 2; + bb.y2 = pos.y + bb.h / 2; + } + function computeBiasValues(propDiff, propBias, propBiasComplement) { + var biasDiff = 0; + var biasComplementDiff = 0; + var biasTotal = propBias + propBiasComplement; + if (propDiff > 0 && biasTotal > 0) { + biasDiff = propBias / biasTotal * propDiff; + biasComplementDiff = propBiasComplement / biasTotal * propDiff; + } + return { + biasDiff: biasDiff, + biasComplementDiff: biasComplementDiff + }; + } + function computePaddingValues(width, height, paddingObject, relativeTo) { + // Assuming percentage is number from 0 to 1 + if (paddingObject.units === '%') { + switch (relativeTo) { + case 'width': + return width > 0 ? paddingObject.pfValue * width : 0; + case 'height': + return height > 0 ? paddingObject.pfValue * height : 0; + case 'average': + return width > 0 && height > 0 ? paddingObject.pfValue * (width + height) / 2 : 0; + case 'min': + return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * height : paddingObject.pfValue * width : 0; + case 'max': + return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * width : paddingObject.pfValue * height : 0; + default: + return 0; + } + } else if (paddingObject.units === 'px') { + return paddingObject.pfValue; + } else { + return 0; + } + } + var leftVal = min.width.left.value; + if (min.width.left.units === 'px' && min.width.val > 0) { + leftVal = leftVal * 100 / min.width.val; + } + var rightVal = min.width.right.value; + if (min.width.right.units === 'px' && min.width.val > 0) { + rightVal = rightVal * 100 / min.width.val; + } + var topVal = min.height.top.value; + if (min.height.top.units === 'px' && min.height.val > 0) { + topVal = topVal * 100 / min.height.val; + } + var bottomVal = min.height.bottom.value; + if (min.height.bottom.units === 'px' && min.height.val > 0) { + bottomVal = bottomVal * 100 / min.height.val; + } + var widthBiasDiffs = computeBiasValues(min.width.val - bb.w, leftVal, rightVal); + var diffLeft = widthBiasDiffs.biasDiff; + var diffRight = widthBiasDiffs.biasComplementDiff; + var heightBiasDiffs = computeBiasValues(min.height.val - bb.h, topVal, bottomVal); + var diffTop = heightBiasDiffs.biasDiff; + var diffBottom = heightBiasDiffs.biasComplementDiff; + _p.autoPadding = computePaddingValues(bb.w, bb.h, parent.pstyle('padding'), parent.pstyle('padding-relative-to').value); + _p.autoWidth = Math.max(bb.w, min.width.val); + pos.x = (-diffLeft + bb.x1 + bb.x2 + diffRight) / 2; + _p.autoHeight = Math.max(bb.h, min.height.val); + pos.y = (-diffTop + bb.y1 + bb.y2 + diffBottom) / 2; + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _p = ele._private; + if (!_p.compoundBoundsClean || force) { + update(ele); + if (!cy.batching()) { + _p.compoundBoundsClean = true; + } + } + } + return this; +}; +var noninf = function noninf(x) { + if (x === Infinity || x === -Infinity) { + return 0; + } + return x; +}; +var updateBounds = function updateBounds(b, x1, y1, x2, y2) { + // don't update with zero area boxes + if (x2 - x1 === 0 || y2 - y1 === 0) { + return; + } + + // don't update with null dim + if (x1 == null || y1 == null || x2 == null || y2 == null) { + return; + } + b.x1 = x1 < b.x1 ? x1 : b.x1; + b.x2 = x2 > b.x2 ? x2 : b.x2; + b.y1 = y1 < b.y1 ? y1 : b.y1; + b.y2 = y2 > b.y2 ? y2 : b.y2; + b.w = b.x2 - b.x1; + b.h = b.y2 - b.y1; +}; +var updateBoundsFromBox = function updateBoundsFromBox(b, b2) { + if (b2 == null) { + return b; + } + return updateBounds(b, b2.x1, b2.y1, b2.x2, b2.y2); +}; +var prefixedProperty = function prefixedProperty(obj, field, prefix) { + return getPrefixedProperty(obj, field, prefix); +}; +var updateBoundsFromArrow = function updateBoundsFromArrow(bounds, ele, prefix) { + if (ele.cy().headless()) { + return; + } + var _p = ele._private; + var rstyle = _p.rstyle; + var halfArW = rstyle.arrowWidth / 2; + var arrowType = ele.pstyle(prefix + '-arrow-shape').value; + var x; + var y; + if (arrowType !== 'none') { + if (prefix === 'source') { + x = rstyle.srcX; + y = rstyle.srcY; + } else if (prefix === 'target') { + x = rstyle.tgtX; + y = rstyle.tgtY; + } else { + x = rstyle.midX; + y = rstyle.midY; + } + + // always store the individual arrow bounds + var bbs = _p.arrowBounds = _p.arrowBounds || {}; + var bb = bbs[prefix] = bbs[prefix] || {}; + bb.x1 = x - halfArW; + bb.y1 = y - halfArW; + bb.x2 = x + halfArW; + bb.y2 = y + halfArW; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + expandBoundingBox(bb, 1); + updateBounds(bounds, bb.x1, bb.y1, bb.x2, bb.y2); + } +}; +var updateBoundsFromLabel = function updateBoundsFromLabel(bounds, ele, prefix) { + if (ele.cy().headless()) { + return; + } + var prefixDash; + if (prefix) { + prefixDash = prefix + '-'; + } else { + prefixDash = ''; + } + var _p = ele._private; + var rstyle = _p.rstyle; + var label = ele.pstyle(prefixDash + 'label').strValue; + if (label) { + var halign = ele.pstyle('text-halign'); + var valign = ele.pstyle('text-valign'); + var labelWidth = prefixedProperty(rstyle, 'labelWidth', prefix); + var labelHeight = prefixedProperty(rstyle, 'labelHeight', prefix); + var labelX = prefixedProperty(rstyle, 'labelX', prefix); + var labelY = prefixedProperty(rstyle, 'labelY', prefix); + var marginX = ele.pstyle(prefixDash + 'text-margin-x').pfValue; + var marginY = ele.pstyle(prefixDash + 'text-margin-y').pfValue; + var isEdge = ele.isEdge(); + var rotation = ele.pstyle(prefixDash + 'text-rotation'); + var outlineWidth = ele.pstyle('text-outline-width').pfValue; + var borderWidth = ele.pstyle('text-border-width').pfValue; + var halfBorderWidth = borderWidth / 2; + var padding = ele.pstyle('text-background-padding').pfValue; + var marginOfError = 2; // expand to work around browser dimension inaccuracies + + var lh = labelHeight; + var lw = labelWidth; + var lw_2 = lw / 2; + var lh_2 = lh / 2; + var lx1, lx2, ly1, ly2; + if (isEdge) { + lx1 = labelX - lw_2; + lx2 = labelX + lw_2; + ly1 = labelY - lh_2; + ly2 = labelY + lh_2; + } else { + switch (halign.value) { + case 'left': + lx1 = labelX - lw; + lx2 = labelX; + break; + case 'center': + lx1 = labelX - lw_2; + lx2 = labelX + lw_2; + break; + case 'right': + lx1 = labelX; + lx2 = labelX + lw; + break; + } + switch (valign.value) { + case 'top': + ly1 = labelY - lh; + ly2 = labelY; + break; + case 'center': + ly1 = labelY - lh_2; + ly2 = labelY + lh_2; + break; + case 'bottom': + ly1 = labelY; + ly2 = labelY + lh; + break; + } + } + + // shift by margin and expand by outline and border + lx1 += marginX - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; + lx2 += marginX + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; + ly1 += marginY - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; + ly2 += marginY + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; + + // always store the unrotated label bounds separately + var bbPrefix = prefix || 'main'; + var bbs = _p.labelBounds; + var bb = bbs[bbPrefix] = bbs[bbPrefix] || {}; + bb.x1 = lx1; + bb.y1 = ly1; + bb.x2 = lx2; + bb.y2 = ly2; + bb.w = lx2 - lx1; + bb.h = ly2 - ly1; + var isAutorotate = isEdge && rotation.strValue === 'autorotate'; + var isPfValue = rotation.pfValue != null && rotation.pfValue !== 0; + if (isAutorotate || isPfValue) { + var theta = isAutorotate ? prefixedProperty(_p.rstyle, 'labelAngle', prefix) : rotation.pfValue; + var cos = Math.cos(theta); + var sin = Math.sin(theta); + + // rotation point (default value for center-center) + var xo = (lx1 + lx2) / 2; + var yo = (ly1 + ly2) / 2; + if (!isEdge) { + switch (halign.value) { + case 'left': + xo = lx2; + break; + case 'right': + xo = lx1; + break; + } + switch (valign.value) { + case 'top': + yo = ly2; + break; + case 'bottom': + yo = ly1; + break; + } + } + var rotate = function rotate(x, y) { + x = x - xo; + y = y - yo; + return { + x: x * cos - y * sin + xo, + y: x * sin + y * cos + yo + }; + }; + var px1y1 = rotate(lx1, ly1); + var px1y2 = rotate(lx1, ly2); + var px2y1 = rotate(lx2, ly1); + var px2y2 = rotate(lx2, ly2); + lx1 = Math.min(px1y1.x, px1y2.x, px2y1.x, px2y2.x); + lx2 = Math.max(px1y1.x, px1y2.x, px2y1.x, px2y2.x); + ly1 = Math.min(px1y1.y, px1y2.y, px2y1.y, px2y2.y); + ly2 = Math.max(px1y1.y, px1y2.y, px2y1.y, px2y2.y); + } + var bbPrefixRot = bbPrefix + 'Rot'; + var bbRot = bbs[bbPrefixRot] = bbs[bbPrefixRot] || {}; + bbRot.x1 = lx1; + bbRot.y1 = ly1; + bbRot.x2 = lx2; + bbRot.y2 = ly2; + bbRot.w = lx2 - lx1; + bbRot.h = ly2 - ly1; + updateBounds(bounds, lx1, ly1, lx2, ly2); + updateBounds(_p.labelBounds.all, lx1, ly1, lx2, ly2); + } + return bounds; +}; +var updateBoundsFromOutline = function updateBoundsFromOutline(bounds, ele) { + if (ele.cy().headless()) { + return; + } + var outlineOpacity = ele.pstyle('outline-opacity').value; + var outlineWidth = ele.pstyle('outline-width').value; + if (outlineOpacity > 0 && outlineWidth > 0) { + var outlineOffset = ele.pstyle('outline-offset').value; + var nodeShape = ele.pstyle('shape').value; + var outlineSize = outlineWidth + outlineOffset; + var scaleX = (bounds.w + outlineSize * 2) / bounds.w; + var scaleY = (bounds.h + outlineSize * 2) / bounds.h; + var xOffset = 0; + var yOffset = 0; + if (["diamond", "pentagon", "round-triangle"].includes(nodeShape)) { + scaleX = (bounds.w + outlineSize * 2.4) / bounds.w; + yOffset = -outlineSize / 3.6; + } else if (["concave-hexagon", "rhomboid", "right-rhomboid"].includes(nodeShape)) { + scaleX = (bounds.w + outlineSize * 2.4) / bounds.w; + } else if (nodeShape === "star") { + scaleX = (bounds.w + outlineSize * 2.8) / bounds.w; + scaleY = (bounds.h + outlineSize * 2.6) / bounds.h; + yOffset = -outlineSize / 3.8; + } else if (nodeShape === "triangle") { + scaleX = (bounds.w + outlineSize * 2.8) / bounds.w; + scaleY = (bounds.h + outlineSize * 2.4) / bounds.h; + yOffset = -outlineSize / 1.4; + } else if (nodeShape === "vee") { + scaleX = (bounds.w + outlineSize * 4.4) / bounds.w; + scaleY = (bounds.h + outlineSize * 3.8) / bounds.h; + yOffset = -outlineSize * .5; + } + var hDelta = bounds.h * scaleY - bounds.h; + var wDelta = bounds.w * scaleX - bounds.w; + expandBoundingBoxSides(bounds, [Math.ceil(hDelta / 2), Math.ceil(wDelta / 2)]); + if (xOffset != 0 || yOffset !== 0) { + var oBounds = shiftBoundingBox(bounds, xOffset, yOffset); + updateBoundingBox(bounds, oBounds); + } + } +}; + +// get the bounding box of the elements (in raw model position) +var boundingBoxImpl = function boundingBoxImpl(ele, options) { + var cy = ele._private.cy; + var styleEnabled = cy.styleEnabled(); + var headless = cy.headless(); + var bounds = makeBoundingBox(); + var _p = ele._private; + var isNode = ele.isNode(); + var isEdge = ele.isEdge(); + var ex1, ex2, ey1, ey2; // extrema of body / lines + var x, y; // node pos + var rstyle = _p.rstyle; + var manualExpansion = isNode && styleEnabled ? ele.pstyle('bounds-expansion').pfValue : [0]; + + // must use `display` prop only, as reading `compound.width()` causes recursion + // (other factors like width values will be considered later in this function anyway) + var isDisplayed = function isDisplayed(ele) { + return ele.pstyle('display').value !== 'none'; + }; + var displayed = !styleEnabled || isDisplayed(ele) + + // must take into account connected nodes b/c of implicit edge hiding on display:none node + && (!isEdge || isDisplayed(ele.source()) && isDisplayed(ele.target())); + if (displayed) { + // displayed suffices, since we will find zero area eles anyway + var overlayOpacity = 0; + var overlayPadding = 0; + if (styleEnabled && options.includeOverlays) { + overlayOpacity = ele.pstyle('overlay-opacity').value; + if (overlayOpacity !== 0) { + overlayPadding = ele.pstyle('overlay-padding').value; + } + } + var underlayOpacity = 0; + var underlayPadding = 0; + if (styleEnabled && options.includeUnderlays) { + underlayOpacity = ele.pstyle('underlay-opacity').value; + if (underlayOpacity !== 0) { + underlayPadding = ele.pstyle('underlay-padding').value; + } + } + var padding = Math.max(overlayPadding, underlayPadding); + var w = 0; + var wHalf = 0; + if (styleEnabled) { + w = ele.pstyle('width').pfValue; + wHalf = w / 2; + } + if (isNode && options.includeNodes) { + var pos = ele.position(); + x = pos.x; + y = pos.y; + var _w = ele.outerWidth(); + var halfW = _w / 2; + var h = ele.outerHeight(); + var halfH = h / 2; + + // handle node dimensions + ///////////////////////// + + ex1 = x - halfW; + ex2 = x + halfW; + ey1 = y - halfH; + ey2 = y + halfH; + updateBounds(bounds, ex1, ey1, ex2, ey2); + if (styleEnabled && options.includeOutlines) { + updateBoundsFromOutline(bounds, ele); + } + } else if (isEdge && options.includeEdges) { + if (styleEnabled && !headless) { + var curveStyle = ele.pstyle('curve-style').strValue; + + // handle edge dimensions (rough box estimate) + ////////////////////////////////////////////// + + ex1 = Math.min(rstyle.srcX, rstyle.midX, rstyle.tgtX); + ex2 = Math.max(rstyle.srcX, rstyle.midX, rstyle.tgtX); + ey1 = Math.min(rstyle.srcY, rstyle.midY, rstyle.tgtY); + ey2 = Math.max(rstyle.srcY, rstyle.midY, rstyle.tgtY); + + // take into account edge width + ex1 -= wHalf; + ex2 += wHalf; + ey1 -= wHalf; + ey2 += wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + + // precise edges + //////////////// + + if (curveStyle === 'haystack') { + var hpts = rstyle.haystackPts; + if (hpts && hpts.length === 2) { + ex1 = hpts[0].x; + ey1 = hpts[0].y; + ex2 = hpts[1].x; + ey2 = hpts[1].y; + if (ex1 > ex2) { + var temp = ex1; + ex1 = ex2; + ex2 = temp; + } + if (ey1 > ey2) { + var _temp = ey1; + ey1 = ey2; + ey2 = _temp; + } + updateBounds(bounds, ex1 - wHalf, ey1 - wHalf, ex2 + wHalf, ey2 + wHalf); + } + } else if (curveStyle === 'bezier' || curveStyle === 'unbundled-bezier' || curveStyle.endsWith('segments') || curveStyle.endsWith('taxi')) { + var pts; + switch (curveStyle) { + case 'bezier': + case 'unbundled-bezier': + pts = rstyle.bezierPts; + break; + case 'segments': + case 'taxi': + case 'round-segments': + case 'round-taxi': + pts = rstyle.linePts; + break; + } + if (pts != null) { + for (var j = 0; j < pts.length; j++) { + var pt = pts[j]; + ex1 = pt.x - wHalf; + ex2 = pt.x + wHalf; + ey1 = pt.y - wHalf; + ey2 = pt.y + wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + } + } + } // bezier-like or segment-like edge + } else { + // headless or style disabled + + // fallback on source and target positions + ////////////////////////////////////////// + + var n1 = ele.source(); + var n1pos = n1.position(); + var n2 = ele.target(); + var n2pos = n2.position(); + ex1 = n1pos.x; + ex2 = n2pos.x; + ey1 = n1pos.y; + ey2 = n2pos.y; + if (ex1 > ex2) { + var _temp2 = ex1; + ex1 = ex2; + ex2 = _temp2; + } + if (ey1 > ey2) { + var _temp3 = ey1; + ey1 = ey2; + ey2 = _temp3; + } + + // take into account edge width + ex1 -= wHalf; + ex2 += wHalf; + ey1 -= wHalf; + ey2 += wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + } // headless or style disabled + } // edges + + // handle edge arrow size + ///////////////////////// + + if (styleEnabled && options.includeEdges && isEdge) { + updateBoundsFromArrow(bounds, ele, 'mid-source'); + updateBoundsFromArrow(bounds, ele, 'mid-target'); + updateBoundsFromArrow(bounds, ele, 'source'); + updateBoundsFromArrow(bounds, ele, 'target'); + } + + // ghost + //////// + + if (styleEnabled) { + var ghost = ele.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = ele.pstyle('ghost-offset-x').pfValue; + var gy = ele.pstyle('ghost-offset-y').pfValue; + updateBounds(bounds, bounds.x1 + gx, bounds.y1 + gy, bounds.x2 + gx, bounds.y2 + gy); + } + } + + // always store the body bounds separately from the labels + var bbBody = _p.bodyBounds = _p.bodyBounds || {}; + assignBoundingBox(bbBody, bounds); + expandBoundingBoxSides(bbBody, manualExpansion); + expandBoundingBox(bbBody, 1); // expand to work around browser dimension inaccuracies + + // overlay + ////////// + + if (styleEnabled) { + ex1 = bounds.x1; + ex2 = bounds.x2; + ey1 = bounds.y1; + ey2 = bounds.y2; + updateBounds(bounds, ex1 - padding, ey1 - padding, ex2 + padding, ey2 + padding); + } + + // always store the body bounds separately from the labels + var bbOverlay = _p.overlayBounds = _p.overlayBounds || {}; + assignBoundingBox(bbOverlay, bounds); + expandBoundingBoxSides(bbOverlay, manualExpansion); + expandBoundingBox(bbOverlay, 1); // expand to work around browser dimension inaccuracies + + // handle label dimensions + ////////////////////////// + + var bbLabels = _p.labelBounds = _p.labelBounds || {}; + if (bbLabels.all != null) { + clearBoundingBox(bbLabels.all); + } else { + bbLabels.all = makeBoundingBox(); + } + if (styleEnabled && options.includeLabels) { + if (options.includeMainLabels) { + updateBoundsFromLabel(bounds, ele, null); + } + if (isEdge) { + if (options.includeSourceLabels) { + updateBoundsFromLabel(bounds, ele, 'source'); + } + if (options.includeTargetLabels) { + updateBoundsFromLabel(bounds, ele, 'target'); + } + } + } // style enabled for labels + } // if displayed + + bounds.x1 = noninf(bounds.x1); + bounds.y1 = noninf(bounds.y1); + bounds.x2 = noninf(bounds.x2); + bounds.y2 = noninf(bounds.y2); + bounds.w = noninf(bounds.x2 - bounds.x1); + bounds.h = noninf(bounds.y2 - bounds.y1); + if (bounds.w > 0 && bounds.h > 0 && displayed) { + expandBoundingBoxSides(bounds, manualExpansion); + + // expand bounds by 1 because antialiasing can increase the visual/effective size by 1 on all sides + expandBoundingBox(bounds, 1); + } + return bounds; +}; +var getKey = function getKey(opts) { + var i = 0; + var tf = function tf(val) { + return (val ? 1 : 0) << i++; + }; + var key = 0; + key += tf(opts.incudeNodes); + key += tf(opts.includeEdges); + key += tf(opts.includeLabels); + key += tf(opts.includeMainLabels); + key += tf(opts.includeSourceLabels); + key += tf(opts.includeTargetLabels); + key += tf(opts.includeOverlays); + key += tf(opts.includeOutlines); + return key; +}; +var getBoundingBoxPosKey = function getBoundingBoxPosKey(ele) { + if (ele.isEdge()) { + var p1 = ele.source().position(); + var p2 = ele.target().position(); + var r = function r(x) { + return Math.round(x); + }; + return hashIntsArray([r(p1.x), r(p1.y), r(p2.x), r(p2.y)]); + } else { + return 0; + } +}; +var cachedBoundingBoxImpl = function cachedBoundingBoxImpl(ele, opts) { + var _p = ele._private; + var bb; + var isEdge = ele.isEdge(); + var key = opts == null ? defBbOptsKey : getKey(opts); + var usingDefOpts = key === defBbOptsKey; + var currPosKey = getBoundingBoxPosKey(ele); + var isPosKeySame = _p.bbCachePosKey === currPosKey; + var useCache = opts.useCache && isPosKeySame; + var isDirty = function isDirty(ele) { + return ele._private.bbCache == null || ele._private.styleDirty; + }; + var needRecalc = !useCache || isDirty(ele) || isEdge && isDirty(ele.source()) || isDirty(ele.target()); + if (needRecalc) { + if (!isPosKeySame) { + ele.recalculateRenderedStyle(useCache); + } + bb = boundingBoxImpl(ele, defBbOpts); + _p.bbCache = bb; + _p.bbCachePosKey = currPosKey; + } else { + bb = _p.bbCache; + } + + // not using def opts => need to build up bb from combination of sub bbs + if (!usingDefOpts) { + var isNode = ele.isNode(); + bb = makeBoundingBox(); + if (opts.includeNodes && isNode || opts.includeEdges && !isNode) { + if (opts.includeOverlays) { + updateBoundsFromBox(bb, _p.overlayBounds); + } else { + updateBoundsFromBox(bb, _p.bodyBounds); + } + } + if (opts.includeLabels) { + if (opts.includeMainLabels && (!isEdge || opts.includeSourceLabels && opts.includeTargetLabels)) { + updateBoundsFromBox(bb, _p.labelBounds.all); + } else { + if (opts.includeMainLabels) { + updateBoundsFromBox(bb, _p.labelBounds.mainRot); + } + if (opts.includeSourceLabels) { + updateBoundsFromBox(bb, _p.labelBounds.sourceRot); + } + if (opts.includeTargetLabels) { + updateBoundsFromBox(bb, _p.labelBounds.targetRot); + } + } + } + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + } + return bb; +}; +var defBbOpts = { + includeNodes: true, + includeEdges: true, + includeLabels: true, + includeMainLabels: true, + includeSourceLabels: true, + includeTargetLabels: true, + includeOverlays: true, + includeUnderlays: true, + includeOutlines: true, + useCache: true +}; +var defBbOptsKey = getKey(defBbOpts); +var filledBbOpts = defaults$g(defBbOpts); +elesfn$b.boundingBox = function (options) { + var bounds; + + // the main usecase is ele.boundingBox() for a single element with no/def options + // specified s.t. the cache is used, so check for this case to make it faster by + // avoiding the overhead of the rest of the function + if (this.length === 1 && this[0]._private.bbCache != null && !this[0]._private.styleDirty && (options === undefined || options.useCache === undefined || options.useCache === true)) { + if (options === undefined) { + options = defBbOpts; + } else { + options = filledBbOpts(options); + } + bounds = cachedBoundingBoxImpl(this[0], options); + } else { + bounds = makeBoundingBox(); + options = options || defBbOpts; + var opts = filledBbOpts(options); + var eles = this; + var cy = eles.cy(); + var styleEnabled = cy.styleEnabled(); + if (styleEnabled) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var currPosKey = getBoundingBoxPosKey(ele); + var isPosKeySame = _p.bbCachePosKey === currPosKey; + var useCache = opts.useCache && isPosKeySame && !_p.styleDirty; + ele.recalculateRenderedStyle(useCache); + } + } + this.updateCompoundBounds(!options.useCache); + for (var _i = 0; _i < eles.length; _i++) { + var _ele = eles[_i]; + updateBoundsFromBox(bounds, cachedBoundingBoxImpl(_ele, opts)); + } + } + bounds.x1 = noninf(bounds.x1); + bounds.y1 = noninf(bounds.y1); + bounds.x2 = noninf(bounds.x2); + bounds.y2 = noninf(bounds.y2); + bounds.w = noninf(bounds.x2 - bounds.x1); + bounds.h = noninf(bounds.y2 - bounds.y1); + return bounds; +}; +elesfn$b.dirtyBoundingBoxCache = function () { + for (var i = 0; i < this.length; i++) { + var _p = this[i]._private; + _p.bbCache = null; + _p.bbCachePosKey = null; + _p.bodyBounds = null; + _p.overlayBounds = null; + _p.labelBounds.all = null; + _p.labelBounds.source = null; + _p.labelBounds.target = null; + _p.labelBounds.main = null; + _p.labelBounds.sourceRot = null; + _p.labelBounds.targetRot = null; + _p.labelBounds.mainRot = null; + _p.arrowBounds.source = null; + _p.arrowBounds.target = null; + _p.arrowBounds['mid-source'] = null; + _p.arrowBounds['mid-target'] = null; + } + this.emitAndNotify('bounds'); + return this; +}; + +// private helper to get bounding box for custom node positions +// - good for perf in certain cases but currently requires dirtying the rendered style +// - would be better to not modify the nodes but the nodes are read directly everywhere in the renderer... +// - try to use for only things like discrete layouts where the node position would change anyway +elesfn$b.boundingBoxAt = function (fn) { + var nodes = this.nodes(); + var cy = this.cy(); + var hasCompoundNodes = cy.hasCompoundNodes(); + var parents = cy.collection(); + if (hasCompoundNodes) { + parents = nodes.filter(function (node) { + return node.isParent(); + }); + nodes = nodes.not(parents); + } + if (plainObject(fn)) { + var obj = fn; + fn = function fn() { + return obj; + }; + } + var storeOldPos = function storeOldPos(node, i) { + return node._private.bbAtOldPos = fn(node, i); + }; + var getOldPos = function getOldPos(node) { + return node._private.bbAtOldPos; + }; + cy.startBatch(); + nodes.forEach(storeOldPos).silentPositions(fn); + if (hasCompoundNodes) { + parents.dirtyCompoundBoundsCache(); + parents.dirtyBoundingBoxCache(); + parents.updateCompoundBounds(true); // force update b/c we're inside a batch cycle + } + + var bb = copyBoundingBox(this.boundingBox({ + useCache: false + })); + nodes.silentPositions(getOldPos); + if (hasCompoundNodes) { + parents.dirtyCompoundBoundsCache(); + parents.dirtyBoundingBoxCache(); + parents.updateCompoundBounds(true); // force update b/c we're inside a batch cycle + } + + cy.endBatch(); + return bb; +}; +fn$3.boundingbox = fn$3.bb = fn$3.boundingBox; +fn$3.renderedBoundingbox = fn$3.renderedBoundingBox; +var bounds = elesfn$b; + +var fn$2, elesfn$a; +fn$2 = elesfn$a = {}; +var defineDimFns = function defineDimFns(opts) { + opts.uppercaseName = capitalize(opts.name); + opts.autoName = 'auto' + opts.uppercaseName; + opts.labelName = 'label' + opts.uppercaseName; + opts.outerName = 'outer' + opts.uppercaseName; + opts.uppercaseOuterName = capitalize(opts.outerName); + fn$2[opts.name] = function dimImpl() { + var ele = this[0]; + var _p = ele._private; + var cy = _p.cy; + var styleEnabled = cy._private.styleEnabled; + if (ele) { + if (styleEnabled) { + if (ele.isParent()) { + ele.updateCompoundBounds(); + return _p[opts.autoName] || 0; + } + var d = ele.pstyle(opts.name); + switch (d.strValue) { + case 'label': + ele.recalculateRenderedStyle(); + return _p.rstyle[opts.labelName] || 0; + default: + return d.pfValue; + } + } else { + return 1; + } + } + }; + fn$2['outer' + opts.uppercaseName] = function outerDimImpl() { + var ele = this[0]; + var _p = ele._private; + var cy = _p.cy; + var styleEnabled = cy._private.styleEnabled; + if (ele) { + if (styleEnabled) { + var dim = ele[opts.name](); + var border = ele.pstyle('border-width').pfValue; // n.b. 1/2 each side + var padding = 2 * ele.padding(); + return dim + border + padding; + } else { + return 1; + } + } + }; + fn$2['rendered' + opts.uppercaseName] = function renderedDimImpl() { + var ele = this[0]; + if (ele) { + var d = ele[opts.name](); + return d * this.cy().zoom(); + } + }; + fn$2['rendered' + opts.uppercaseOuterName] = function renderedOuterDimImpl() { + var ele = this[0]; + if (ele) { + var od = ele[opts.outerName](); + return od * this.cy().zoom(); + } + }; +}; +defineDimFns({ + name: 'width' +}); +defineDimFns({ + name: 'height' +}); +elesfn$a.padding = function () { + var ele = this[0]; + var _p = ele._private; + if (ele.isParent()) { + ele.updateCompoundBounds(); + if (_p.autoPadding !== undefined) { + return _p.autoPadding; + } else { + return ele.pstyle('padding').pfValue; + } + } else { + return ele.pstyle('padding').pfValue; + } +}; +elesfn$a.paddedHeight = function () { + var ele = this[0]; + return ele.height() + 2 * ele.padding(); +}; +elesfn$a.paddedWidth = function () { + var ele = this[0]; + return ele.width() + 2 * ele.padding(); +}; +var widthHeight = elesfn$a; + +var ifEdge = function ifEdge(ele, getValue) { + if (ele.isEdge()) { + return getValue(ele); + } +}; +var ifEdgeRenderedPosition = function ifEdgeRenderedPosition(ele, getPoint) { + if (ele.isEdge()) { + var cy = ele.cy(); + return modelToRenderedPosition(getPoint(ele), cy.zoom(), cy.pan()); + } +}; +var ifEdgeRenderedPositions = function ifEdgeRenderedPositions(ele, getPoints) { + if (ele.isEdge()) { + var cy = ele.cy(); + var pan = cy.pan(); + var zoom = cy.zoom(); + return getPoints(ele).map(function (p) { + return modelToRenderedPosition(p, zoom, pan); + }); + } +}; +var controlPoints = function controlPoints(ele) { + return ele.renderer().getControlPoints(ele); +}; +var segmentPoints = function segmentPoints(ele) { + return ele.renderer().getSegmentPoints(ele); +}; +var sourceEndpoint = function sourceEndpoint(ele) { + return ele.renderer().getSourceEndpoint(ele); +}; +var targetEndpoint = function targetEndpoint(ele) { + return ele.renderer().getTargetEndpoint(ele); +}; +var midpoint = function midpoint(ele) { + return ele.renderer().getEdgeMidpoint(ele); +}; +var pts = { + controlPoints: { + get: controlPoints, + mult: true + }, + segmentPoints: { + get: segmentPoints, + mult: true + }, + sourceEndpoint: { + get: sourceEndpoint + }, + targetEndpoint: { + get: targetEndpoint + }, + midpoint: { + get: midpoint + } +}; +var renderedName = function renderedName(name) { + return 'rendered' + name[0].toUpperCase() + name.substr(1); +}; +var edgePoints = Object.keys(pts).reduce(function (obj, name) { + var spec = pts[name]; + var rName = renderedName(name); + obj[name] = function () { + return ifEdge(this, spec.get); + }; + if (spec.mult) { + obj[rName] = function () { + return ifEdgeRenderedPositions(this, spec.get); + }; + } else { + obj[rName] = function () { + return ifEdgeRenderedPosition(this, spec.get); + }; + } + return obj; +}, {}); + +var dimensions = extend({}, position, bounds, widthHeight, edgePoints); + +/*! +Event object based on jQuery events, MIT license + +https://jquery.org/license/ +https://tldrlegal.com/license/mit-license +https://github.com/jquery/jquery/blob/master/src/event.js +*/ + +var Event = function Event(src, props) { + this.recycle(src, props); +}; +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +Event.prototype = { + instanceString: function instanceString() { + return 'event'; + }, + recycle: function recycle(src, props) { + this.isImmediatePropagationStopped = this.isPropagationStopped = this.isDefaultPrevented = returnFalse; + if (src != null && src.preventDefault) { + // Browser Event object + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented ? returnTrue : returnFalse; + } else if (src != null && src.type) { + // Plain object containing all event details + props = src; + } else { + // Event string + this.type = src; + } + + // Put explicitly provided properties onto the event object + if (props != null) { + // more efficient to manually copy fields we use + this.originalEvent = props.originalEvent; + this.type = props.type != null ? props.type : this.type; + this.cy = props.cy; + this.target = props.target; + this.position = props.position; + this.renderedPosition = props.renderedPosition; + this.namespace = props.namespace; + this.layout = props.layout; + } + if (this.cy != null && this.position != null && this.renderedPosition == null) { + // create a rendered position based on the passed position + var pos = this.position; + var zoom = this.cy.zoom(); + var pan = this.cy.pan(); + this.renderedPosition = { + x: pos.x * zoom + pan.x, + y: pos.y * zoom + pan.y + }; + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || Date.now(); + }, + preventDefault: function preventDefault() { + this.isDefaultPrevented = returnTrue; + var e = this.originalEvent; + if (!e) { + return; + } + + // if preventDefault exists run it on the original event + if (e.preventDefault) { + e.preventDefault(); + } + }, + stopPropagation: function stopPropagation() { + this.isPropagationStopped = returnTrue; + var e = this.originalEvent; + if (!e) { + return; + } + + // if stopPropagation exists run it on the original event + if (e.stopPropagation) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function stopImmediatePropagation() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +var eventRegex = /^([^.]+)(\.(?:[^.]+))?$/; // regex for matching event strings (e.g. "click.namespace") +var universalNamespace = '.*'; // matches as if no namespace specified and prevents users from unbinding accidentally + +var defaults$8 = { + qualifierCompare: function qualifierCompare(q1, q2) { + return q1 === q2; + }, + eventMatches: function eventMatches( /*context, listener, eventObj*/ + ) { + return true; + }, + addEventFields: function addEventFields( /*context, evt*/ + ) {}, + callbackContext: function callbackContext(context /*, listener, eventObj*/) { + return context; + }, + beforeEmit: function beforeEmit( /* context, listener, eventObj */ + ) {}, + afterEmit: function afterEmit( /* context, listener, eventObj */ + ) {}, + bubble: function bubble( /*context*/ + ) { + return false; + }, + parent: function parent( /*context*/ + ) { + return null; + }, + context: null +}; +var defaultsKeys = Object.keys(defaults$8); +var emptyOpts = {}; +function Emitter() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : emptyOpts; + var context = arguments.length > 1 ? arguments[1] : undefined; + // micro-optimisation vs Object.assign() -- reduces Element instantiation time + for (var i = 0; i < defaultsKeys.length; i++) { + var key = defaultsKeys[i]; + this[key] = opts[key] || defaults$8[key]; + } + this.context = context || this.context; + this.listeners = []; + this.emitting = 0; +} +var p = Emitter.prototype; +var forEachEvent = function forEachEvent(self, handler, events, qualifier, callback, conf, confOverrides) { + if (fn$6(qualifier)) { + callback = qualifier; + qualifier = null; + } + if (confOverrides) { + if (conf == null) { + conf = confOverrides; + } else { + conf = extend({}, conf, confOverrides); + } + } + var eventList = array(events) ? events : events.split(/\s+/); + for (var i = 0; i < eventList.length; i++) { + var evt = eventList[i]; + if (emptyString(evt)) { + continue; + } + var match = evt.match(eventRegex); // type[.namespace] + + if (match) { + var type = match[1]; + var namespace = match[2] ? match[2] : null; + var ret = handler(self, evt, type, namespace, qualifier, callback, conf); + if (ret === false) { + break; + } // allow exiting early + } + } +}; + +var makeEventObj = function makeEventObj(self, obj) { + self.addEventFields(self.context, obj); + return new Event(obj.type, obj); +}; +var forEachEventObj = function forEachEventObj(self, handler, events) { + if (event(events)) { + handler(self, events); + return; + } else if (plainObject(events)) { + handler(self, makeEventObj(self, events)); + return; + } + var eventList = array(events) ? events : events.split(/\s+/); + for (var i = 0; i < eventList.length; i++) { + var evt = eventList[i]; + if (emptyString(evt)) { + continue; + } + var match = evt.match(eventRegex); // type[.namespace] + + if (match) { + var type = match[1]; + var namespace = match[2] ? match[2] : null; + var eventObj = makeEventObj(self, { + type: type, + namespace: namespace, + target: self.context + }); + handler(self, eventObj); + } + } +}; +p.on = p.addListener = function (events, qualifier, callback, conf, confOverrides) { + forEachEvent(this, function (self, event, type, namespace, qualifier, callback, conf) { + if (fn$6(callback)) { + self.listeners.push({ + event: event, + // full event string + callback: callback, + // callback to run + type: type, + // the event type (e.g. 'click') + namespace: namespace, + // the event namespace (e.g. ".foo") + qualifier: qualifier, + // a restriction on whether to match this emitter + conf: conf // additional configuration + }); + } + }, events, qualifier, callback, conf, confOverrides); + return this; +}; +p.one = function (events, qualifier, callback, conf) { + return this.on(events, qualifier, callback, conf, { + one: true + }); +}; +p.removeListener = p.off = function (events, qualifier, callback, conf) { + var _this = this; + if (this.emitting !== 0) { + this.listeners = copyArray$1(this.listeners); + } + var listeners = this.listeners; + var _loop = function _loop(i) { + var listener = listeners[i]; + forEachEvent(_this, function (self, event, type, namespace, qualifier, callback /*, conf*/) { + if ((listener.type === type || events === '*') && (!namespace && listener.namespace !== '.*' || listener.namespace === namespace) && (!qualifier || self.qualifierCompare(listener.qualifier, qualifier)) && (!callback || listener.callback === callback)) { + listeners.splice(i, 1); + return false; + } + }, events, qualifier, callback, conf); + }; + for (var i = listeners.length - 1; i >= 0; i--) { + _loop(i); + } + return this; +}; +p.removeAllListeners = function () { + return this.removeListener('*'); +}; +p.emit = p.trigger = function (events, extraParams, manualCallback) { + var listeners = this.listeners; + var numListenersBeforeEmit = listeners.length; + this.emitting++; + if (!array(extraParams)) { + extraParams = [extraParams]; + } + forEachEventObj(this, function (self, eventObj) { + if (manualCallback != null) { + listeners = [{ + event: eventObj.event, + type: eventObj.type, + namespace: eventObj.namespace, + callback: manualCallback + }]; + numListenersBeforeEmit = listeners.length; + } + var _loop2 = function _loop2(i) { + var listener = listeners[i]; + if (listener.type === eventObj.type && (!listener.namespace || listener.namespace === eventObj.namespace || listener.namespace === universalNamespace) && self.eventMatches(self.context, listener, eventObj)) { + var args = [eventObj]; + if (extraParams != null) { + push(args, extraParams); + } + self.beforeEmit(self.context, listener, eventObj); + if (listener.conf && listener.conf.one) { + self.listeners = self.listeners.filter(function (l) { + return l !== listener; + }); + } + var context = self.callbackContext(self.context, listener, eventObj); + var ret = listener.callback.apply(context, args); + self.afterEmit(self.context, listener, eventObj); + if (ret === false) { + eventObj.stopPropagation(); + eventObj.preventDefault(); + } + } // if listener matches + }; + for (var i = 0; i < numListenersBeforeEmit; i++) { + _loop2(i); + } // for listener + + if (self.bubble(self.context) && !eventObj.isPropagationStopped()) { + self.parent(self.context).emit(eventObj, extraParams); + } + }, events); + this.emitting--; + return this; +}; + +var emitterOptions$1 = { + qualifierCompare: function qualifierCompare(selector1, selector2) { + if (selector1 == null || selector2 == null) { + return selector1 == null && selector2 == null; + } else { + return selector1.sameText(selector2); + } + }, + eventMatches: function eventMatches(ele, listener, eventObj) { + var selector = listener.qualifier; + if (selector != null) { + return ele !== eventObj.target && element(eventObj.target) && selector.matches(eventObj.target); + } + return true; + }, + addEventFields: function addEventFields(ele, evt) { + evt.cy = ele.cy(); + evt.target = ele; + }, + callbackContext: function callbackContext(ele, listener, eventObj) { + return listener.qualifier != null ? eventObj.target : ele; + }, + beforeEmit: function beforeEmit(context, listener /*, eventObj*/) { + if (listener.conf && listener.conf.once) { + listener.conf.onceCollection.removeListener(listener.event, listener.qualifier, listener.callback); + } + }, + bubble: function bubble() { + return true; + }, + parent: function parent(ele) { + return ele.isChild() ? ele.parent() : ele.cy(); + } +}; +var argSelector$1 = function argSelector(arg) { + if (string(arg)) { + return new Selector(arg); + } else { + return arg; + } +}; +var elesfn$9 = { + createEmitter: function createEmitter() { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _p = ele._private; + if (!_p.emitter) { + _p.emitter = new Emitter(emitterOptions$1, ele); + } + } + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().on(events, argSel, callback); + } + return this; + }, + removeListener: function removeListener(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().removeListener(events, argSel, callback); + } + return this; + }, + removeAllListeners: function removeAllListeners() { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().removeAllListeners(); + } + return this; + }, + one: function one(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().one(events, argSel, callback); + } + return this; + }, + once: function once(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().on(events, argSel, callback, { + once: true, + onceCollection: this + }); + } + }, + emit: function emit(events, extraParams) { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().emit(events, extraParams); + } + return this; + }, + emitAndNotify: function emitAndNotify(event, extraParams) { + // for internal use only + if (this.length === 0) { + return; + } // empty collections don't need to notify anything + + // notify renderer + this.cy().notify(event, this); + this.emit(event, extraParams); + return this; + } +}; +define.eventAliasesOn(elesfn$9); + +var elesfn$8 = { + nodes: function nodes(selector) { + return this.filter(function (ele) { + return ele.isNode(); + }).filter(selector); + }, + edges: function edges(selector) { + return this.filter(function (ele) { + return ele.isEdge(); + }).filter(selector); + }, + // internal helper to get nodes and edges as separate collections with single iteration over elements + byGroup: function byGroup() { + var nodes = this.spawn(); + var edges = this.spawn(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + if (ele.isNode()) { + nodes.push(ele); + } else { + edges.push(ele); + } + } + return { + nodes: nodes, + edges: edges + }; + }, + filter: function filter(_filter, thisArg) { + if (_filter === undefined) { + // check this first b/c it's the most common/performant case + return this; + } else if (string(_filter) || elementOrCollection(_filter)) { + return new Selector(_filter).filter(this); + } else if (fn$6(_filter)) { + var filterEles = this.spawn(); + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var include = thisArg ? _filter.apply(thisArg, [ele, i, eles]) : _filter(ele, i, eles); + if (include) { + filterEles.push(ele); + } + } + return filterEles; + } + return this.spawn(); // if not handled by above, give 'em an empty collection + }, + + not: function not(toRemove) { + if (!toRemove) { + return this; + } else { + if (string(toRemove)) { + toRemove = this.filter(toRemove); + } + var elements = this.spawn(); + for (var i = 0; i < this.length; i++) { + var element = this[i]; + var remove = toRemove.has(element); + if (!remove) { + elements.push(element); + } + } + return elements; + } + }, + absoluteComplement: function absoluteComplement() { + var cy = this.cy(); + return cy.mutableElements().not(this); + }, + intersect: function intersect(other) { + // if a selector is specified, then filter by it instead + if (string(other)) { + var selector = other; + return this.filter(selector); + } + var elements = this.spawn(); + var col1 = this; + var col2 = other; + var col1Smaller = this.length < other.length; + var colS = col1Smaller ? col1 : col2; + var colL = col1Smaller ? col2 : col1; + for (var i = 0; i < colS.length; i++) { + var ele = colS[i]; + if (colL.has(ele)) { + elements.push(ele); + } + } + return elements; + }, + xor: function xor(other) { + var cy = this._private.cy; + if (string(other)) { + other = cy.$(other); + } + var elements = this.spawn(); + var col1 = this; + var col2 = other; + var add = function add(col, other) { + for (var i = 0; i < col.length; i++) { + var ele = col[i]; + var id = ele._private.data.id; + var inOther = other.hasElementWithId(id); + if (!inOther) { + elements.push(ele); + } + } + }; + add(col1, col2); + add(col2, col1); + return elements; + }, + diff: function diff(other) { + var cy = this._private.cy; + if (string(other)) { + other = cy.$(other); + } + var left = this.spawn(); + var right = this.spawn(); + var both = this.spawn(); + var col1 = this; + var col2 = other; + var add = function add(col, other, retEles) { + for (var i = 0; i < col.length; i++) { + var ele = col[i]; + var id = ele._private.data.id; + var inOther = other.hasElementWithId(id); + if (inOther) { + both.merge(ele); + } else { + retEles.push(ele); + } + } + }; + add(col1, col2, left); + add(col2, col1, right); + return { + left: left, + right: right, + both: both + }; + }, + add: function add(toAdd) { + var cy = this._private.cy; + if (!toAdd) { + return this; + } + if (string(toAdd)) { + var selector = toAdd; + toAdd = cy.mutableElements().filter(selector); + } + var elements = this.spawnSelf(); + for (var i = 0; i < toAdd.length; i++) { + var ele = toAdd[i]; + var add = !this.has(ele); + if (add) { + elements.push(ele); + } + } + return elements; + }, + // in place merge on calling collection + merge: function merge(toAdd) { + var _p = this._private; + var cy = _p.cy; + if (!toAdd) { + return this; + } + if (toAdd && string(toAdd)) { + var selector = toAdd; + toAdd = cy.mutableElements().filter(selector); + } + var map = _p.map; + for (var i = 0; i < toAdd.length; i++) { + var toAddEle = toAdd[i]; + var id = toAddEle._private.data.id; + var add = !map.has(id); + if (add) { + var index = this.length++; + this[index] = toAddEle; + map.set(id, { + ele: toAddEle, + index: index + }); + } + } + return this; // chaining + }, + + unmergeAt: function unmergeAt(i) { + var ele = this[i]; + var id = ele.id(); + var _p = this._private; + var map = _p.map; + + // remove ele + this[i] = undefined; + map["delete"](id); + var unmergedLastEle = i === this.length - 1; + + // replace empty spot with last ele in collection + if (this.length > 1 && !unmergedLastEle) { + var lastEleI = this.length - 1; + var lastEle = this[lastEleI]; + var lastEleId = lastEle._private.data.id; + this[lastEleI] = undefined; + this[i] = lastEle; + map.set(lastEleId, { + ele: lastEle, + index: i + }); + } + + // the collection is now 1 ele smaller + this.length--; + return this; + }, + // remove single ele in place in calling collection + unmergeOne: function unmergeOne(ele) { + ele = ele[0]; + var _p = this._private; + var id = ele._private.data.id; + var map = _p.map; + var entry = map.get(id); + if (!entry) { + return this; // no need to remove + } + + var i = entry.index; + this.unmergeAt(i); + return this; + }, + // remove eles in place on calling collection + unmerge: function unmerge(toRemove) { + var cy = this._private.cy; + if (!toRemove) { + return this; + } + if (toRemove && string(toRemove)) { + var selector = toRemove; + toRemove = cy.mutableElements().filter(selector); + } + for (var i = 0; i < toRemove.length; i++) { + this.unmergeOne(toRemove[i]); + } + return this; // chaining + }, + + unmergeBy: function unmergeBy(toRmFn) { + for (var i = this.length - 1; i >= 0; i--) { + var ele = this[i]; + if (toRmFn(ele)) { + this.unmergeAt(i); + } + } + return this; + }, + map: function map(mapFn, thisArg) { + var arr = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var ret = thisArg ? mapFn.apply(thisArg, [ele, i, eles]) : mapFn(ele, i, eles); + arr.push(ret); + } + return arr; + }, + reduce: function reduce(fn, initialValue) { + var val = initialValue; + var eles = this; + for (var i = 0; i < eles.length; i++) { + val = fn(val, eles[i], i, eles); + } + return val; + }, + max: function max(valFn, thisArg) { + var max = -Infinity; + var maxEle; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var val = thisArg ? valFn.apply(thisArg, [ele, i, eles]) : valFn(ele, i, eles); + if (val > max) { + max = val; + maxEle = ele; + } + } + return { + value: max, + ele: maxEle + }; + }, + min: function min(valFn, thisArg) { + var min = Infinity; + var minEle; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var val = thisArg ? valFn.apply(thisArg, [ele, i, eles]) : valFn(ele, i, eles); + if (val < min) { + min = val; + minEle = ele; + } + } + return { + value: min, + ele: minEle + }; + } +}; + +// aliases +var fn$1 = elesfn$8; +fn$1['u'] = fn$1['|'] = fn$1['+'] = fn$1.union = fn$1.or = fn$1.add; +fn$1['\\'] = fn$1['!'] = fn$1['-'] = fn$1.difference = fn$1.relativeComplement = fn$1.subtract = fn$1.not; +fn$1['n'] = fn$1['&'] = fn$1['.'] = fn$1.and = fn$1.intersection = fn$1.intersect; +fn$1['^'] = fn$1['(+)'] = fn$1['(-)'] = fn$1.symmetricDifference = fn$1.symdiff = fn$1.xor; +fn$1.fnFilter = fn$1.filterFn = fn$1.stdFilter = fn$1.filter; +fn$1.complement = fn$1.abscomp = fn$1.absoluteComplement; + +var elesfn$7 = { + isNode: function isNode() { + return this.group() === 'nodes'; + }, + isEdge: function isEdge() { + return this.group() === 'edges'; + }, + isLoop: function isLoop() { + return this.isEdge() && this.source()[0] === this.target()[0]; + }, + isSimple: function isSimple() { + return this.isEdge() && this.source()[0] !== this.target()[0]; + }, + group: function group() { + var ele = this[0]; + if (ele) { + return ele._private.group; + } + } +}; + +/** + * Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges), + * and z-index (low to high). These styles affect how this applies: + * + * z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the + * same depth as the root of the compound graph, followed by the default value `auto` which draws in order from + * root to leaves of the compound graph. The last drawn is `top`. + * z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes. + * `manual` ignores this convention and draws based on the `z-index` value setting. + * z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher + * `z-index` will be drawn on top of an element with a lower `z-index`. + */ +var zIndexSort = function zIndexSort(a, b) { + var cy = a.cy(); + var hasCompoundNodes = cy.hasCompoundNodes(); + function getDepth(ele) { + var style = ele.pstyle('z-compound-depth'); + if (style.value === 'auto') { + return hasCompoundNodes ? ele.zDepth() : 0; + } else if (style.value === 'bottom') { + return -1; + } else if (style.value === 'top') { + return MAX_INT$1; + } + // 'orphan' + return 0; + } + var depthDiff = getDepth(a) - getDepth(b); + if (depthDiff !== 0) { + return depthDiff; + } + function getEleDepth(ele) { + var style = ele.pstyle('z-index-compare'); + if (style.value === 'auto') { + return ele.isNode() ? 1 : 0; + } + // 'manual' + return 0; + } + var eleDiff = getEleDepth(a) - getEleDepth(b); + if (eleDiff !== 0) { + return eleDiff; + } + var zDiff = a.pstyle('z-index').value - b.pstyle('z-index').value; + if (zDiff !== 0) { + return zDiff; + } + // compare indices in the core (order added to graph w/ last on top) + return a.poolIndex() - b.poolIndex(); +}; + +var elesfn$6 = { + forEach: function forEach(fn, thisArg) { + if (fn$6(fn)) { + var N = this.length; + for (var i = 0; i < N; i++) { + var ele = this[i]; + var ret = thisArg ? fn.apply(thisArg, [ele, i, this]) : fn(ele, i, this); + if (ret === false) { + break; + } // exit each early on return false + } + } + + return this; + }, + toArray: function toArray() { + var array = []; + for (var i = 0; i < this.length; i++) { + array.push(this[i]); + } + return array; + }, + slice: function slice(start, end) { + var array = []; + var thisSize = this.length; + if (end == null) { + end = thisSize; + } + if (start == null) { + start = 0; + } + if (start < 0) { + start = thisSize + start; + } + if (end < 0) { + end = thisSize + end; + } + for (var i = start; i >= 0 && i < end && i < thisSize; i++) { + array.push(this[i]); + } + return this.spawn(array); + }, + size: function size() { + return this.length; + }, + eq: function eq(i) { + return this[i] || this.spawn(); + }, + first: function first() { + return this[0] || this.spawn(); + }, + last: function last() { + return this[this.length - 1] || this.spawn(); + }, + empty: function empty() { + return this.length === 0; + }, + nonempty: function nonempty() { + return !this.empty(); + }, + sort: function sort(sortFn) { + if (!fn$6(sortFn)) { + return this; + } + var sorted = this.toArray().sort(sortFn); + return this.spawn(sorted); + }, + sortByZIndex: function sortByZIndex() { + return this.sort(zIndexSort); + }, + zDepth: function zDepth() { + var ele = this[0]; + if (!ele) { + return undefined; + } + + // let cy = ele.cy(); + var _p = ele._private; + var group = _p.group; + if (group === 'nodes') { + var depth = _p.data.parent ? ele.parents().size() : 0; + if (!ele.isParent()) { + return MAX_INT$1 - 1; // childless nodes always on top + } + + return depth; + } else { + var src = _p.source; + var tgt = _p.target; + var srcDepth = src.zDepth(); + var tgtDepth = tgt.zDepth(); + return Math.max(srcDepth, tgtDepth, 0); // depth of deepest parent + } + } +}; + +elesfn$6.each = elesfn$6.forEach; +var defineSymbolIterator = function defineSymbolIterator() { + var typeofUndef = "undefined" ; + var isIteratorSupported = (typeof Symbol === "undefined" ? "undefined" : _typeof(Symbol)) != typeofUndef && _typeof(Symbol.iterator) != typeofUndef; // eslint-disable-line no-undef + + if (isIteratorSupported) { + elesfn$6[Symbol.iterator] = function () { + var _this = this; + // eslint-disable-line no-undef + var entry = { + value: undefined, + done: false + }; + var i = 0; + var length = this.length; + return _defineProperty$1({ + next: function next() { + if (i < length) { + entry.value = _this[i++]; + } else { + entry.value = undefined; + entry.done = true; + } + return entry; + } + }, Symbol.iterator, function () { + // eslint-disable-line no-undef + return this; + }); + }; + } +}; +defineSymbolIterator(); + +var getLayoutDimensionOptions = defaults$g({ + nodeDimensionsIncludeLabels: false +}); +var elesfn$5 = { + // Calculates and returns node dimensions { x, y } based on options given + layoutDimensions: function layoutDimensions(options) { + options = getLayoutDimensionOptions(options); + var dims; + if (!this.takesUpSpace()) { + dims = { + w: 0, + h: 0 + }; + } else if (options.nodeDimensionsIncludeLabels) { + var bbDim = this.boundingBox(); + dims = { + w: bbDim.w, + h: bbDim.h + }; + } else { + dims = { + w: this.outerWidth(), + h: this.outerHeight() + }; + } + + // sanitise the dimensions for external layouts (avoid division by zero) + if (dims.w === 0 || dims.h === 0) { + dims.w = dims.h = 1; + } + return dims; + }, + // using standard layout options, apply position function (w/ or w/o animation) + layoutPositions: function layoutPositions(layout, options, fn) { + var nodes = this.nodes().filter(function (n) { + return !n.isParent(); + }); + var cy = this.cy(); + var layoutEles = options.eles; // nodes & edges + var getMemoizeKey = function getMemoizeKey(node) { + return node.id(); + }; + var fnMem = memoize$1(fn, getMemoizeKey); // memoized version of position function + + layout.emit({ + type: 'layoutstart', + layout: layout + }); + layout.animations = []; + var calculateSpacing = function calculateSpacing(spacing, nodesBb, pos) { + var center = { + x: nodesBb.x1 + nodesBb.w / 2, + y: nodesBb.y1 + nodesBb.h / 2 + }; + var spacingVector = { + // scale from center of bounding box (not necessarily 0,0) + x: (pos.x - center.x) * spacing, + y: (pos.y - center.y) * spacing + }; + return { + x: center.x + spacingVector.x, + y: center.y + spacingVector.y + }; + }; + var useSpacingFactor = options.spacingFactor && options.spacingFactor !== 1; + var spacingBb = function spacingBb() { + if (!useSpacingFactor) { + return null; + } + var bb = makeBoundingBox(); + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var pos = fnMem(node, i); + expandBoundingBoxByPoint(bb, pos.x, pos.y); + } + return bb; + }; + var bb = spacingBb(); + var getFinalPos = memoize$1(function (node, i) { + var newPos = fnMem(node, i); + if (useSpacingFactor) { + var spacing = Math.abs(options.spacingFactor); + newPos = calculateSpacing(spacing, bb, newPos); + } + if (options.transform != null) { + newPos = options.transform(node, newPos); + } + return newPos; + }, getMemoizeKey); + if (options.animate) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var newPos = getFinalPos(node, i); + var animateNode = options.animateFilter == null || options.animateFilter(node, i); + if (animateNode) { + var ani = node.animation({ + position: newPos, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(ani); + } else { + node.position(newPos); + } + } + if (options.fit) { + var fitAni = cy.animation({ + fit: { + boundingBox: layoutEles.boundingBoxAt(getFinalPos), + padding: options.padding + }, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(fitAni); + } else if (options.zoom !== undefined && options.pan !== undefined) { + var zoomPanAni = cy.animation({ + zoom: options.zoom, + pan: options.pan, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(zoomPanAni); + } + layout.animations.forEach(function (ani) { + return ani.play(); + }); + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: layout + }); + Promise$1.all(layout.animations.map(function (ani) { + return ani.promise(); + })).then(function () { + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + }); + } else { + nodes.positions(getFinalPos); + if (options.fit) { + cy.fit(options.eles, options.padding); + } + if (options.zoom != null) { + cy.zoom(options.zoom); + } + if (options.pan) { + cy.pan(options.pan); + } + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: layout + }); + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + } + return this; // chaining + }, + + layout: function layout(options) { + var cy = this.cy(); + return cy.makeLayout(extend({}, options, { + eles: this + })); + } +}; + +// aliases: +elesfn$5.createLayout = elesfn$5.makeLayout = elesfn$5.layout; + +function styleCache(key, fn, ele) { + var _p = ele._private; + var cache = _p.styleCache = _p.styleCache || []; + var val; + if ((val = cache[key]) != null) { + return val; + } else { + val = cache[key] = fn(ele); + return val; + } +} +function cacheStyleFunction(key, fn) { + key = hashString(key); + return function cachedStyleFunction(ele) { + return styleCache(key, fn, ele); + }; +} +function cachePrototypeStyleFunction(key, fn) { + key = hashString(key); + var selfFn = function selfFn(ele) { + return fn.call(ele); + }; + return function cachedPrototypeStyleFunction() { + var ele = this[0]; + if (ele) { + return styleCache(key, selfFn, ele); + } + }; +} +var elesfn$4 = { + recalculateRenderedStyle: function recalculateRenderedStyle(useCache) { + var cy = this.cy(); + var renderer = cy.renderer(); + var styleEnabled = cy.styleEnabled(); + if (renderer && styleEnabled) { + renderer.recalculateRenderedStyle(this, useCache); + } + return this; + }, + dirtyStyleCache: function dirtyStyleCache() { + var cy = this.cy(); + var dirty = function dirty(ele) { + return ele._private.styleCache = null; + }; + if (cy.hasCompoundNodes()) { + var eles; + eles = this.spawnSelf().merge(this.descendants()).merge(this.parents()); + eles.merge(eles.connectedEdges()); + eles.forEach(dirty); + } else { + this.forEach(function (ele) { + dirty(ele); + ele.connectedEdges().forEach(dirty); + }); + } + return this; + }, + // fully updates (recalculates) the style for the elements + updateStyle: function updateStyle(notifyRenderer) { + var cy = this._private.cy; + if (!cy.styleEnabled()) { + return this; + } + if (cy.batching()) { + var bEles = cy._private.batchStyleEles; + bEles.merge(this); + return this; // chaining and exit early when batching + } + + var hasCompounds = cy.hasCompoundNodes(); + var updatedEles = this; + notifyRenderer = notifyRenderer || notifyRenderer === undefined ? true : false; + if (hasCompounds) { + // then add everything up and down for compound selector checks + updatedEles = this.spawnSelf().merge(this.descendants()).merge(this.parents()); + } + + // let changedEles = style.apply( updatedEles ); + var changedEles = updatedEles; + if (notifyRenderer) { + changedEles.emitAndNotify('style'); // let renderer know we changed style + } else { + changedEles.emit('style'); // just fire the event + } + + updatedEles.forEach(function (ele) { + return ele._private.styleDirty = true; + }); + return this; // chaining + }, + + // private: clears dirty flag and recalculates style + cleanStyle: function cleanStyle() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return; + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + if (ele._private.styleDirty) { + // n.b. this flag should be set before apply() to avoid potential infinite recursion + ele._private.styleDirty = false; + cy.style().apply(ele); + } + } + }, + // get the internal parsed style object for the specified property + parsedStyle: function parsedStyle(property) { + var includeNonDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var ele = this[0]; + var cy = ele.cy(); + if (!cy.styleEnabled()) { + return; + } + if (ele) { + this.cleanStyle(); + var overriddenStyle = ele._private.style[property]; + if (overriddenStyle != null) { + return overriddenStyle; + } else if (includeNonDefault) { + return cy.style().getDefaultProperty(property); + } else { + return null; + } + } + }, + numericStyle: function numericStyle(property) { + var ele = this[0]; + if (!ele.cy().styleEnabled()) { + return; + } + if (ele) { + var pstyle = ele.pstyle(property); + return pstyle.pfValue !== undefined ? pstyle.pfValue : pstyle.value; + } + }, + numericStyleUnits: function numericStyleUnits(property) { + var ele = this[0]; + if (!ele.cy().styleEnabled()) { + return; + } + if (ele) { + return ele.pstyle(property).units; + } + }, + // get the specified css property as a rendered value (i.e. on-screen value) + // or get the whole rendered style if no property specified (NB doesn't allow setting) + renderedStyle: function renderedStyle(property) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var ele = this[0]; + if (ele) { + return cy.style().getRenderedStyle(ele, property); + } + }, + // read the calculated css style of the element or override the style (via a bypass) + style: function style(name, value) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var updateTransitions = false; + var style = cy.style(); + if (plainObject(name)) { + // then extend the bypass + var props = name; + style.applyBypass(this, props, updateTransitions); + this.emitAndNotify('style'); // let the renderer know we've updated style + } else if (string(name)) { + if (value === undefined) { + // then get the property from the style + var ele = this[0]; + if (ele) { + return style.getStylePropertyValue(ele, name); + } else { + // empty collection => can't get any value + return; + } + } else { + // then set the bypass with the property value + style.applyBypass(this, name, value, updateTransitions); + this.emitAndNotify('style'); // let the renderer know we've updated style + } + } else if (name === undefined) { + var _ele = this[0]; + if (_ele) { + return style.getRawStyle(_ele); + } else { + // empty collection => can't get any value + return; + } + } + return this; // chaining + }, + + removeStyle: function removeStyle(names) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var updateTransitions = false; + var style = cy.style(); + var eles = this; + if (names === undefined) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + style.removeAllBypasses(ele, updateTransitions); + } + } else { + names = names.split(/\s+/); + for (var _i = 0; _i < eles.length; _i++) { + var _ele2 = eles[_i]; + style.removeBypasses(_ele2, names, updateTransitions); + } + } + this.emitAndNotify('style'); // let the renderer know we've updated style + + return this; // chaining + }, + + show: function show() { + this.css('display', 'element'); + return this; // chaining + }, + + hide: function hide() { + this.css('display', 'none'); + return this; // chaining + }, + + effectiveOpacity: function effectiveOpacity() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return 1; + } + var hasCompoundNodes = cy.hasCompoundNodes(); + var ele = this[0]; + if (ele) { + var _p = ele._private; + var parentOpacity = ele.pstyle('opacity').value; + if (!hasCompoundNodes) { + return parentOpacity; + } + var parents = !_p.data.parent ? null : ele.parents(); + if (parents) { + for (var i = 0; i < parents.length; i++) { + var parent = parents[i]; + var opacity = parent.pstyle('opacity').value; + parentOpacity = opacity * parentOpacity; + } + } + return parentOpacity; + } + }, + transparent: function transparent() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return false; + } + var ele = this[0]; + var hasCompoundNodes = ele.cy().hasCompoundNodes(); + if (ele) { + if (!hasCompoundNodes) { + return ele.pstyle('opacity').value === 0; + } else { + return ele.effectiveOpacity() === 0; + } + } + }, + backgrounding: function backgrounding() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return false; + } + var ele = this[0]; + return ele._private.backgrounding ? true : false; + } +}; +function checkCompound(ele, parentOk) { + var _p = ele._private; + var parents = _p.data.parent ? ele.parents() : null; + if (parents) { + for (var i = 0; i < parents.length; i++) { + var parent = parents[i]; + if (!parentOk(parent)) { + return false; + } + } + } + return true; +} +function defineDerivedStateFunction(specs) { + var ok = specs.ok; + var edgeOkViaNode = specs.edgeOkViaNode || specs.ok; + var parentOk = specs.parentOk || specs.ok; + return function () { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return true; + } + var ele = this[0]; + var hasCompoundNodes = cy.hasCompoundNodes(); + if (ele) { + var _p = ele._private; + if (!ok(ele)) { + return false; + } + if (ele.isNode()) { + return !hasCompoundNodes || checkCompound(ele, parentOk); + } else { + var src = _p.source; + var tgt = _p.target; + return edgeOkViaNode(src) && (!hasCompoundNodes || checkCompound(src, edgeOkViaNode)) && (src === tgt || edgeOkViaNode(tgt) && (!hasCompoundNodes || checkCompound(tgt, edgeOkViaNode))); + } + } + }; +} +var eleTakesUpSpace = cacheStyleFunction('eleTakesUpSpace', function (ele) { + return ele.pstyle('display').value === 'element' && ele.width() !== 0 && (ele.isNode() ? ele.height() !== 0 : true); +}); +elesfn$4.takesUpSpace = cachePrototypeStyleFunction('takesUpSpace', defineDerivedStateFunction({ + ok: eleTakesUpSpace +})); +var eleInteractive = cacheStyleFunction('eleInteractive', function (ele) { + return ele.pstyle('events').value === 'yes' && ele.pstyle('visibility').value === 'visible' && eleTakesUpSpace(ele); +}); +var parentInteractive = cacheStyleFunction('parentInteractive', function (parent) { + return parent.pstyle('visibility').value === 'visible' && eleTakesUpSpace(parent); +}); +elesfn$4.interactive = cachePrototypeStyleFunction('interactive', defineDerivedStateFunction({ + ok: eleInteractive, + parentOk: parentInteractive, + edgeOkViaNode: eleTakesUpSpace +})); +elesfn$4.noninteractive = function () { + var ele = this[0]; + if (ele) { + return !ele.interactive(); + } +}; +var eleVisible = cacheStyleFunction('eleVisible', function (ele) { + return ele.pstyle('visibility').value === 'visible' && ele.pstyle('opacity').pfValue !== 0 && eleTakesUpSpace(ele); +}); +var edgeVisibleViaNode = eleTakesUpSpace; +elesfn$4.visible = cachePrototypeStyleFunction('visible', defineDerivedStateFunction({ + ok: eleVisible, + edgeOkViaNode: edgeVisibleViaNode +})); +elesfn$4.hidden = function () { + var ele = this[0]; + if (ele) { + return !ele.visible(); + } +}; +elesfn$4.isBundledBezier = cachePrototypeStyleFunction('isBundledBezier', function () { + if (!this.cy().styleEnabled()) { + return false; + } + return !this.removed() && this.pstyle('curve-style').value === 'bezier' && this.takesUpSpace(); +}); +elesfn$4.bypass = elesfn$4.css = elesfn$4.style; +elesfn$4.renderedCss = elesfn$4.renderedStyle; +elesfn$4.removeBypass = elesfn$4.removeCss = elesfn$4.removeStyle; +elesfn$4.pstyle = elesfn$4.parsedStyle; + +var elesfn$3 = {}; +function defineSwitchFunction(params) { + return function () { + var args = arguments; + var changedEles = []; + + // e.g. cy.nodes().select( data, handler ) + if (args.length === 2) { + var data = args[0]; + var handler = args[1]; + this.on(params.event, data, handler); + } + + // e.g. cy.nodes().select( handler ) + else if (args.length === 1 && fn$6(args[0])) { + var _handler = args[0]; + this.on(params.event, _handler); + } + + // e.g. cy.nodes().select() + // e.g. (private) cy.nodes().select(['tapselect']) + else if (args.length === 0 || args.length === 1 && array(args[0])) { + var addlEvents = args.length === 1 ? args[0] : null; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var able = !params.ableField || ele._private[params.ableField]; + var changed = ele._private[params.field] != params.value; + if (params.overrideAble) { + var overrideAble = params.overrideAble(ele); + if (overrideAble !== undefined) { + able = overrideAble; + if (!overrideAble) { + return this; + } // to save cycles assume not able for all on override + } + } + + if (able) { + ele._private[params.field] = params.value; + if (changed) { + changedEles.push(ele); + } + } + } + var changedColl = this.spawn(changedEles); + changedColl.updateStyle(); // change of state => possible change of style + changedColl.emit(params.event); + if (addlEvents) { + changedColl.emit(addlEvents); + } + } + return this; + }; +} +function defineSwitchSet(params) { + elesfn$3[params.field] = function () { + var ele = this[0]; + if (ele) { + if (params.overrideField) { + var val = params.overrideField(ele); + if (val !== undefined) { + return val; + } + } + return ele._private[params.field]; + } + }; + elesfn$3[params.on] = defineSwitchFunction({ + event: params.on, + field: params.field, + ableField: params.ableField, + overrideAble: params.overrideAble, + value: true + }); + elesfn$3[params.off] = defineSwitchFunction({ + event: params.off, + field: params.field, + ableField: params.ableField, + overrideAble: params.overrideAble, + value: false + }); +} +defineSwitchSet({ + field: 'locked', + overrideField: function overrideField(ele) { + return ele.cy().autolock() ? true : undefined; + }, + on: 'lock', + off: 'unlock' +}); +defineSwitchSet({ + field: 'grabbable', + overrideField: function overrideField(ele) { + return ele.cy().autoungrabify() || ele.pannable() ? false : undefined; + }, + on: 'grabify', + off: 'ungrabify' +}); +defineSwitchSet({ + field: 'selected', + ableField: 'selectable', + overrideAble: function overrideAble(ele) { + return ele.cy().autounselectify() ? false : undefined; + }, + on: 'select', + off: 'unselect' +}); +defineSwitchSet({ + field: 'selectable', + overrideField: function overrideField(ele) { + return ele.cy().autounselectify() ? false : undefined; + }, + on: 'selectify', + off: 'unselectify' +}); +elesfn$3.deselect = elesfn$3.unselect; +elesfn$3.grabbed = function () { + var ele = this[0]; + if (ele) { + return ele._private.grabbed; + } +}; +defineSwitchSet({ + field: 'active', + on: 'activate', + off: 'unactivate' +}); +defineSwitchSet({ + field: 'pannable', + on: 'panify', + off: 'unpanify' +}); +elesfn$3.inactive = function () { + var ele = this[0]; + if (ele) { + return !ele._private.active; + } +}; + +var elesfn$2 = {}; + +// DAG functions +//////////////// + +var defineDagExtremity = function defineDagExtremity(params) { + return function dagExtremityImpl(selector) { + var eles = this; + var ret = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + var disqualified = false; + var edges = ele.connectedEdges(); + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + var src = edge.source(); + var tgt = edge.target(); + if (params.noIncomingEdges && tgt === ele && src !== ele || params.noOutgoingEdges && src === ele && tgt !== ele) { + disqualified = true; + break; + } + } + if (!disqualified) { + ret.push(ele); + } + } + return this.spawn(ret, true).filter(selector); + }; +}; +var defineDagOneHop = function defineDagOneHop(params) { + return function (selector) { + var eles = this; + var oEles = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + var edges = ele.connectedEdges(); + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + var src = edge.source(); + var tgt = edge.target(); + if (params.outgoing && src === ele) { + oEles.push(edge); + oEles.push(tgt); + } else if (params.incoming && tgt === ele) { + oEles.push(edge); + oEles.push(src); + } + } + } + return this.spawn(oEles, true).filter(selector); + }; +}; +var defineDagAllHops = function defineDagAllHops(params) { + return function (selector) { + var eles = this; + var sEles = []; + var sElesIds = {}; + for (;;) { + var next = params.outgoing ? eles.outgoers() : eles.incomers(); + if (next.length === 0) { + break; + } // done if none left + + var newNext = false; + for (var i = 0; i < next.length; i++) { + var n = next[i]; + var nid = n.id(); + if (!sElesIds[nid]) { + sElesIds[nid] = true; + sEles.push(n); + newNext = true; + } + } + if (!newNext) { + break; + } // done if touched all outgoers already + + eles = next; + } + return this.spawn(sEles, true).filter(selector); + }; +}; +elesfn$2.clearTraversalCache = function () { + for (var i = 0; i < this.length; i++) { + this[i]._private.traversalCache = null; + } +}; +extend(elesfn$2, { + // get the root nodes in the DAG + roots: defineDagExtremity({ + noIncomingEdges: true + }), + // get the leaf nodes in the DAG + leaves: defineDagExtremity({ + noOutgoingEdges: true + }), + // normally called children in graph theory + // these nodes =edges=> outgoing nodes + outgoers: cache(defineDagOneHop({ + outgoing: true + }), 'outgoers'), + // aka DAG descendants + successors: defineDagAllHops({ + outgoing: true + }), + // normally called parents in graph theory + // these nodes <=edges= incoming nodes + incomers: cache(defineDagOneHop({ + incoming: true + }), 'incomers'), + // aka DAG ancestors + predecessors: defineDagAllHops({ + incoming: true + }) +}); + +// Neighbourhood functions +////////////////////////// + +extend(elesfn$2, { + neighborhood: cache(function (selector) { + var elements = []; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + // for all nodes + var node = nodes[i]; + var connectedEdges = node.connectedEdges(); + + // for each connected edge, add the edge and the other node + for (var j = 0; j < connectedEdges.length; j++) { + var edge = connectedEdges[j]; + var src = edge.source(); + var tgt = edge.target(); + var otherNode = node === src ? tgt : src; + + // need check in case of loop + if (otherNode.length > 0) { + elements.push(otherNode[0]); // add node 1 hop away + } + + // add connected edge + elements.push(edge[0]); + } + } + return this.spawn(elements, true).filter(selector); + }, 'neighborhood'), + closedNeighborhood: function closedNeighborhood(selector) { + return this.neighborhood().add(this).filter(selector); + }, + openNeighborhood: function openNeighborhood(selector) { + return this.neighborhood(selector); + } +}); + +// aliases +elesfn$2.neighbourhood = elesfn$2.neighborhood; +elesfn$2.closedNeighbourhood = elesfn$2.closedNeighborhood; +elesfn$2.openNeighbourhood = elesfn$2.openNeighborhood; + +// Edge functions +///////////////// + +extend(elesfn$2, { + source: cache(function sourceImpl(selector) { + var ele = this[0]; + var src; + if (ele) { + src = ele._private.source || ele.cy().collection(); + } + return src && selector ? src.filter(selector) : src; + }, 'source'), + target: cache(function targetImpl(selector) { + var ele = this[0]; + var tgt; + if (ele) { + tgt = ele._private.target || ele.cy().collection(); + } + return tgt && selector ? tgt.filter(selector) : tgt; + }, 'target'), + sources: defineSourceFunction({ + attr: 'source' + }), + targets: defineSourceFunction({ + attr: 'target' + }) +}); +function defineSourceFunction(params) { + return function sourceImpl(selector) { + var sources = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var src = ele._private[params.attr]; + if (src) { + sources.push(src); + } + } + return this.spawn(sources, true).filter(selector); + }; +} +extend(elesfn$2, { + edgesWith: cache(defineEdgesWithFunction(), 'edgesWith'), + edgesTo: cache(defineEdgesWithFunction({ + thisIsSrc: true + }), 'edgesTo') +}); +function defineEdgesWithFunction(params) { + return function edgesWithImpl(otherNodes) { + var elements = []; + var cy = this._private.cy; + var p = params || {}; + + // get elements if a selector is specified + if (string(otherNodes)) { + otherNodes = cy.$(otherNodes); + } + for (var h = 0; h < otherNodes.length; h++) { + var edges = otherNodes[h]._private.edges; + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var edgeData = edge._private.data; + var thisToOther = this.hasElementWithId(edgeData.source) && otherNodes.hasElementWithId(edgeData.target); + var otherToThis = otherNodes.hasElementWithId(edgeData.source) && this.hasElementWithId(edgeData.target); + var edgeConnectsThisAndOther = thisToOther || otherToThis; + if (!edgeConnectsThisAndOther) { + continue; + } + if (p.thisIsSrc || p.thisIsTgt) { + if (p.thisIsSrc && !thisToOther) { + continue; + } + if (p.thisIsTgt && !otherToThis) { + continue; + } + } + elements.push(edge); + } + } + return this.spawn(elements, true); + }; +} +extend(elesfn$2, { + connectedEdges: cache(function (selector) { + var retEles = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var node = eles[i]; + if (!node.isNode()) { + continue; + } + var edges = node._private.edges; + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + retEles.push(edge); + } + } + return this.spawn(retEles, true).filter(selector); + }, 'connectedEdges'), + connectedNodes: cache(function (selector) { + var retEles = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var edge = eles[i]; + if (!edge.isEdge()) { + continue; + } + retEles.push(edge.source()[0]); + retEles.push(edge.target()[0]); + } + return this.spawn(retEles, true).filter(selector); + }, 'connectedNodes'), + parallelEdges: cache(defineParallelEdgesFunction(), 'parallelEdges'), + codirectedEdges: cache(defineParallelEdgesFunction({ + codirected: true + }), 'codirectedEdges') +}); +function defineParallelEdgesFunction(params) { + var defaults = { + codirected: false + }; + params = extend({}, defaults, params); + return function parallelEdgesImpl(selector) { + // micro-optimised for renderer + var elements = []; + var edges = this.edges(); + var p = params; + + // look at all the edges in the collection + for (var i = 0; i < edges.length; i++) { + var edge1 = edges[i]; + var edge1_p = edge1._private; + var src1 = edge1_p.source; + var srcid1 = src1._private.data.id; + var tgtid1 = edge1_p.data.target; + var srcEdges1 = src1._private.edges; + + // look at edges connected to the src node of this edge + for (var j = 0; j < srcEdges1.length; j++) { + var edge2 = srcEdges1[j]; + var edge2data = edge2._private.data; + var tgtid2 = edge2data.target; + var srcid2 = edge2data.source; + var codirected = tgtid2 === tgtid1 && srcid2 === srcid1; + var oppdirected = srcid1 === tgtid2 && tgtid1 === srcid2; + if (p.codirected && codirected || !p.codirected && (codirected || oppdirected)) { + elements.push(edge2); + } + } + } + return this.spawn(elements, true).filter(selector); + }; +} + +// Misc functions +///////////////// + +extend(elesfn$2, { + components: function components(root) { + var self = this; + var cy = self.cy(); + var visited = cy.collection(); + var unvisited = root == null ? self.nodes() : root.nodes(); + var components = []; + if (root != null && unvisited.empty()) { + // root may contain only edges + unvisited = root.sources(); // doesn't matter which node to use (undirected), so just use the source sides + } + + var visitInComponent = function visitInComponent(node, component) { + visited.merge(node); + unvisited.unmerge(node); + component.merge(node); + }; + if (unvisited.empty()) { + return self.spawn(); + } + var _loop = function _loop() { + // each iteration yields a component + var cmpt = cy.collection(); + components.push(cmpt); + var root = unvisited[0]; + visitInComponent(root, cmpt); + self.bfs({ + directed: false, + roots: root, + visit: function visit(v) { + return visitInComponent(v, cmpt); + } + }); + cmpt.forEach(function (node) { + node.connectedEdges().forEach(function (e) { + // connectedEdges() usually cached + if (self.has(e) && cmpt.has(e.source()) && cmpt.has(e.target())) { + // has() is cheap + cmpt.merge(e); // forEach() only considers nodes -- sets N at call time + } + }); + }); + }; + do { + _loop(); + } while (unvisited.length > 0); + return components; + }, + component: function component() { + var ele = this[0]; + return ele.cy().mutableElements().components(ele)[0]; + } +}); +elesfn$2.componentsOf = elesfn$2.components; + +// represents a set of nodes, edges, or both together +var Collection = function Collection(cy, elements) { + var unique = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var removed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + if (cy === undefined) { + error('A collection must have a reference to the core'); + return; + } + var map = new Map$2(); + var createdElements = false; + if (!elements) { + elements = []; + } else if (elements.length > 0 && plainObject(elements[0]) && !element(elements[0])) { + createdElements = true; + + // make elements from json and restore all at once later + var eles = []; + var elesIds = new Set$1(); + for (var i = 0, l = elements.length; i < l; i++) { + var json = elements[i]; + if (json.data == null) { + json.data = {}; + } + var _data = json.data; + + // make sure newly created elements have valid ids + if (_data.id == null) { + _data.id = uuid(); + } else if (cy.hasElementWithId(_data.id) || elesIds.has(_data.id)) { + continue; // can't create element if prior id already exists + } + + var ele = new Element(cy, json, false); + eles.push(ele); + elesIds.add(_data.id); + } + elements = eles; + } + this.length = 0; + for (var _i = 0, _l = elements.length; _i < _l; _i++) { + var element$1 = elements[_i][0]; // [0] in case elements is an array of collections, rather than array of elements + if (element$1 == null) { + continue; + } + var id = element$1._private.data.id; + if (!unique || !map.has(id)) { + if (unique) { + map.set(id, { + index: this.length, + ele: element$1 + }); + } + this[this.length] = element$1; + this.length++; + } + } + this._private = { + eles: this, + cy: cy, + get map() { + if (this.lazyMap == null) { + this.rebuildMap(); + } + return this.lazyMap; + }, + set map(m) { + this.lazyMap = m; + }, + rebuildMap: function rebuildMap() { + var m = this.lazyMap = new Map$2(); + var eles = this.eles; + for (var _i2 = 0; _i2 < eles.length; _i2++) { + var _ele = eles[_i2]; + m.set(_ele.id(), { + index: _i2, + ele: _ele + }); + } + } + }; + if (unique) { + this._private.map = map; + } + + // restore the elements if we created them from json + if (createdElements && !removed) { + this.restore(); + } +}; + +// Functions +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// keep the prototypes in sync (an element has the same functions as a collection) +// and use elefn and elesfn as shorthands to the prototypes +var elesfn$1 = Element.prototype = Collection.prototype = Object.create(Array.prototype); +elesfn$1.instanceString = function () { + return 'collection'; +}; +elesfn$1.spawn = function (eles, unique) { + return new Collection(this.cy(), eles, unique); +}; +elesfn$1.spawnSelf = function () { + return this.spawn(this); +}; +elesfn$1.cy = function () { + return this._private.cy; +}; +elesfn$1.renderer = function () { + return this._private.cy.renderer(); +}; +elesfn$1.element = function () { + return this[0]; +}; +elesfn$1.collection = function () { + if (collection(this)) { + return this; + } else { + // an element + return new Collection(this._private.cy, [this]); + } +}; +elesfn$1.unique = function () { + return new Collection(this._private.cy, this, true); +}; +elesfn$1.hasElementWithId = function (id) { + id = '' + id; // id must be string + + return this._private.map.has(id); +}; +elesfn$1.getElementById = function (id) { + id = '' + id; // id must be string + + var cy = this._private.cy; + var entry = this._private.map.get(id); + return entry ? entry.ele : new Collection(cy); // get ele or empty collection +}; + +elesfn$1.$id = elesfn$1.getElementById; +elesfn$1.poolIndex = function () { + var cy = this._private.cy; + var eles = cy._private.elements; + var id = this[0]._private.data.id; + return eles._private.map.get(id).index; +}; +elesfn$1.indexOf = function (ele) { + var id = ele[0]._private.data.id; + return this._private.map.get(id).index; +}; +elesfn$1.indexOfId = function (id) { + id = '' + id; // id must be string + + return this._private.map.get(id).index; +}; +elesfn$1.json = function (obj) { + var ele = this.element(); + var cy = this.cy(); + if (ele == null && obj) { + return this; + } // can't set to no eles + + if (ele == null) { + return undefined; + } // can't get from no eles + + var p = ele._private; + if (plainObject(obj)) { + // set + + cy.startBatch(); + if (obj.data) { + ele.data(obj.data); + var _data2 = p.data; + if (ele.isEdge()) { + // source and target are immutable via data() + var move = false; + var spec = {}; + var src = obj.data.source; + var tgt = obj.data.target; + if (src != null && src != _data2.source) { + spec.source = '' + src; // id must be string + move = true; + } + if (tgt != null && tgt != _data2.target) { + spec.target = '' + tgt; // id must be string + move = true; + } + if (move) { + ele = ele.move(spec); + } + } else { + // parent is immutable via data() + var newParentValSpecd = ('parent' in obj.data); + var parent = obj.data.parent; + if (newParentValSpecd && (parent != null || _data2.parent != null) && parent != _data2.parent) { + if (parent === undefined) { + // can't set undefined imperatively, so use null + parent = null; + } + if (parent != null) { + parent = '' + parent; // id must be string + } + + ele = ele.move({ + parent: parent + }); + } + } + } + if (obj.position) { + ele.position(obj.position); + } + + // ignore group -- immutable + + var checkSwitch = function checkSwitch(k, trueFnName, falseFnName) { + var obj_k = obj[k]; + if (obj_k != null && obj_k !== p[k]) { + if (obj_k) { + ele[trueFnName](); + } else { + ele[falseFnName](); + } + } + }; + checkSwitch('removed', 'remove', 'restore'); + checkSwitch('selected', 'select', 'unselect'); + checkSwitch('selectable', 'selectify', 'unselectify'); + checkSwitch('locked', 'lock', 'unlock'); + checkSwitch('grabbable', 'grabify', 'ungrabify'); + checkSwitch('pannable', 'panify', 'unpanify'); + if (obj.classes != null) { + ele.classes(obj.classes); + } + cy.endBatch(); + return this; + } else if (obj === undefined) { + // get + + var json = { + data: copy(p.data), + position: copy(p.position), + group: p.group, + removed: p.removed, + selected: p.selected, + selectable: p.selectable, + locked: p.locked, + grabbable: p.grabbable, + pannable: p.pannable, + classes: null + }; + json.classes = ''; + var i = 0; + p.classes.forEach(function (cls) { + return json.classes += i++ === 0 ? cls : ' ' + cls; + }); + return json; + } +}; +elesfn$1.jsons = function () { + var jsons = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var json = ele.json(); + jsons.push(json); + } + return jsons; +}; +elesfn$1.clone = function () { + var cy = this.cy(); + var elesArr = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var json = ele.json(); + var clone = new Element(cy, json, false); // NB no restore + + elesArr.push(clone); + } + return new Collection(cy, elesArr); +}; +elesfn$1.copy = elesfn$1.clone; +elesfn$1.restore = function () { + var notifyRenderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var addToPool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var self = this; + var cy = self.cy(); + var cy_p = cy._private; + + // create arrays of nodes and edges, since we need to + // restore the nodes first + var nodes = []; + var edges = []; + var elements; + for (var _i3 = 0, l = self.length; _i3 < l; _i3++) { + var ele = self[_i3]; + if (addToPool && !ele.removed()) { + // don't need to handle this ele + continue; + } + + // keep nodes first in the array and edges after + if (ele.isNode()) { + // put to front of array if node + nodes.push(ele); + } else { + // put to end of array if edge + edges.push(ele); + } + } + elements = nodes.concat(edges); + var i; + var removeFromElements = function removeFromElements() { + elements.splice(i, 1); + i--; + }; + + // now, restore each element + for (i = 0; i < elements.length; i++) { + var _ele2 = elements[i]; + var _private = _ele2._private; + var _data3 = _private.data; + + // the traversal cache should start fresh when ele is added + _ele2.clearTraversalCache(); + + // set id and validate + if (!addToPool && !_private.removed) ; else if (_data3.id === undefined) { + _data3.id = uuid(); + } else if (number$1(_data3.id)) { + _data3.id = '' + _data3.id; // now it's a string + } else if (emptyString(_data3.id) || !string(_data3.id)) { + error('Can not create element with invalid string ID `' + _data3.id + '`'); + + // can't create element if it has empty string as id or non-string id + removeFromElements(); + continue; + } else if (cy.hasElementWithId(_data3.id)) { + error('Can not create second element with ID `' + _data3.id + '`'); + + // can't create element if one already has that id + removeFromElements(); + continue; + } + var id = _data3.id; // id is finalised, now let's keep a ref + + if (_ele2.isNode()) { + // extra checks for nodes + var pos = _private.position; + + // make sure the nodes have a defined position + + if (pos.x == null) { + pos.x = 0; + } + if (pos.y == null) { + pos.y = 0; + } + } + if (_ele2.isEdge()) { + // extra checks for edges + + var edge = _ele2; + var fields = ['source', 'target']; + var fieldsLength = fields.length; + var badSourceOrTarget = false; + for (var j = 0; j < fieldsLength; j++) { + var field = fields[j]; + var val = _data3[field]; + if (number$1(val)) { + val = _data3[field] = '' + _data3[field]; // now string + } + + if (val == null || val === '') { + // can't create if source or target is not defined properly + error('Can not create edge `' + id + '` with unspecified ' + field); + badSourceOrTarget = true; + } else if (!cy.hasElementWithId(val)) { + // can't create edge if one of its nodes doesn't exist + error('Can not create edge `' + id + '` with nonexistant ' + field + ' `' + val + '`'); + badSourceOrTarget = true; + } + } + if (badSourceOrTarget) { + removeFromElements(); + continue; + } // can't create this + + var src = cy.getElementById(_data3.source); + var tgt = cy.getElementById(_data3.target); + + // only one edge in node if loop + if (src.same(tgt)) { + src._private.edges.push(edge); + } else { + src._private.edges.push(edge); + tgt._private.edges.push(edge); + } + edge._private.source = src; + edge._private.target = tgt; + } // if is edge + + // create mock ids / indexes maps for element so it can be used like collections + _private.map = new Map$2(); + _private.map.set(id, { + ele: _ele2, + index: 0 + }); + _private.removed = false; + if (addToPool) { + cy.addToPool(_ele2); + } + } // for each element + + // do compound node sanity checks + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + // each node + var node = nodes[_i4]; + var _data4 = node._private.data; + if (number$1(_data4.parent)) { + // then automake string + _data4.parent = '' + _data4.parent; + } + var parentId = _data4.parent; + var specifiedParent = parentId != null; + if (specifiedParent || node._private.parent) { + var parent = node._private.parent ? cy.collection().merge(node._private.parent) : cy.getElementById(parentId); + if (parent.empty()) { + // non-existant parent; just remove it + _data4.parent = undefined; + } else if (parent[0].removed()) { + warn('Node added with missing parent, reference to parent removed'); + _data4.parent = undefined; + node._private.parent = null; + } else { + var selfAsParent = false; + var ancestor = parent; + while (!ancestor.empty()) { + if (node.same(ancestor)) { + // mark self as parent and remove from data + selfAsParent = true; + _data4.parent = undefined; // remove parent reference + + // exit or we loop forever + break; + } + ancestor = ancestor.parent(); + } + if (!selfAsParent) { + // connect with children + parent[0]._private.children.push(node); + node._private.parent = parent[0]; + + // let the core know we have a compound graph + cy_p.hasCompoundNodes = true; + } + } // else + } // if specified parent + } // for each node + + if (elements.length > 0) { + var restored = elements.length === self.length ? self : new Collection(cy, elements); + for (var _i5 = 0; _i5 < restored.length; _i5++) { + var _ele3 = restored[_i5]; + if (_ele3.isNode()) { + continue; + } + + // adding an edge invalidates the traversal caches for the parallel edges + _ele3.parallelEdges().clearTraversalCache(); + + // adding an edge invalidates the traversal cache for the connected nodes + _ele3.source().clearTraversalCache(); + _ele3.target().clearTraversalCache(); + } + var toUpdateStyle; + if (cy_p.hasCompoundNodes) { + toUpdateStyle = cy.collection().merge(restored).merge(restored.connectedNodes()).merge(restored.parent()); + } else { + toUpdateStyle = restored; + } + toUpdateStyle.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(notifyRenderer); + if (notifyRenderer) { + restored.emitAndNotify('add'); + } else if (addToPool) { + restored.emit('add'); + } + } + return self; // chainability +}; + +elesfn$1.removed = function () { + var ele = this[0]; + return ele && ele._private.removed; +}; +elesfn$1.inside = function () { + var ele = this[0]; + return ele && !ele._private.removed; +}; +elesfn$1.remove = function () { + var notifyRenderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var removeFromPool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var self = this; + var elesToRemove = []; + var elesToRemoveIds = {}; + var cy = self._private.cy; + + // add connected edges + function addConnectedEdges(node) { + var edges = node._private.edges; + for (var i = 0; i < edges.length; i++) { + add(edges[i]); + } + } + + // add descendant nodes + function addChildren(node) { + var children = node._private.children; + for (var i = 0; i < children.length; i++) { + add(children[i]); + } + } + function add(ele) { + var alreadyAdded = elesToRemoveIds[ele.id()]; + if (removeFromPool && ele.removed() || alreadyAdded) { + return; + } else { + elesToRemoveIds[ele.id()] = true; + } + if (ele.isNode()) { + elesToRemove.push(ele); // nodes are removed last + + addConnectedEdges(ele); + addChildren(ele); + } else { + elesToRemove.unshift(ele); // edges are removed first + } + } + + // make the list of elements to remove + // (may be removing more than specified due to connected edges etc) + + for (var i = 0, l = self.length; i < l; i++) { + var ele = self[i]; + add(ele); + } + function removeEdgeRef(node, edge) { + var connectedEdges = node._private.edges; + removeFromArray(connectedEdges, edge); + + // removing an edges invalidates the traversal cache for its nodes + node.clearTraversalCache(); + } + function removeParallelRef(pllEdge) { + // removing an edge invalidates the traversal caches for the parallel edges + pllEdge.clearTraversalCache(); + } + var alteredParents = []; + alteredParents.ids = {}; + function removeChildRef(parent, ele) { + ele = ele[0]; + parent = parent[0]; + var children = parent._private.children; + var pid = parent.id(); + removeFromArray(children, ele); // remove parent => child ref + + ele._private.parent = null; // remove child => parent ref + + if (!alteredParents.ids[pid]) { + alteredParents.ids[pid] = true; + alteredParents.push(parent); + } + } + self.dirtyCompoundBoundsCache(); + if (removeFromPool) { + cy.removeFromPool(elesToRemove); // remove from core pool + } + + for (var _i6 = 0; _i6 < elesToRemove.length; _i6++) { + var _ele4 = elesToRemove[_i6]; + if (_ele4.isEdge()) { + // remove references to this edge in its connected nodes + var src = _ele4.source()[0]; + var tgt = _ele4.target()[0]; + removeEdgeRef(src, _ele4); + removeEdgeRef(tgt, _ele4); + var pllEdges = _ele4.parallelEdges(); + for (var j = 0; j < pllEdges.length; j++) { + var pllEdge = pllEdges[j]; + removeParallelRef(pllEdge); + if (pllEdge.isBundledBezier()) { + pllEdge.dirtyBoundingBoxCache(); + } + } + } else { + // remove reference to parent + var parent = _ele4.parent(); + if (parent.length !== 0) { + removeChildRef(parent, _ele4); + } + } + if (removeFromPool) { + // mark as removed + _ele4._private.removed = true; + } + } + + // check to see if we have a compound graph or not + var elesStillInside = cy._private.elements; + cy._private.hasCompoundNodes = false; + for (var _i7 = 0; _i7 < elesStillInside.length; _i7++) { + var _ele5 = elesStillInside[_i7]; + if (_ele5.isParent()) { + cy._private.hasCompoundNodes = true; + break; + } + } + var removedElements = new Collection(this.cy(), elesToRemove); + if (removedElements.size() > 0) { + // must manually notify since trigger won't do this automatically once removed + + if (notifyRenderer) { + removedElements.emitAndNotify('remove'); + } else if (removeFromPool) { + removedElements.emit('remove'); + } + } + + // the parents who were modified by the removal need their style updated + for (var _i8 = 0; _i8 < alteredParents.length; _i8++) { + var _ele6 = alteredParents[_i8]; + if (!removeFromPool || !_ele6.removed()) { + _ele6.updateStyle(); + } + } + return removedElements; +}; +elesfn$1.move = function (struct) { + var cy = this._private.cy; + var eles = this; + + // just clean up refs, caches, etc. in the same way as when removing and then restoring + // (our calls to remove/restore do not remove from the graph or make events) + var notifyRenderer = false; + var modifyPool = false; + var toString = function toString(id) { + return id == null ? id : '' + id; + }; // id must be string + + if (struct.source !== undefined || struct.target !== undefined) { + var srcId = toString(struct.source); + var tgtId = toString(struct.target); + var srcExists = srcId != null && cy.hasElementWithId(srcId); + var tgtExists = tgtId != null && cy.hasElementWithId(tgtId); + if (srcExists || tgtExists) { + cy.batch(function () { + // avoid duplicate style updates + eles.remove(notifyRenderer, modifyPool); // clean up refs etc. + eles.emitAndNotify('moveout'); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _data5 = ele._private.data; + if (ele.isEdge()) { + if (srcExists) { + _data5.source = srcId; + } + if (tgtExists) { + _data5.target = tgtId; + } + } + } + eles.restore(notifyRenderer, modifyPool); // make new refs, style, etc. + }); + + eles.emitAndNotify('move'); + } + } else if (struct.parent !== undefined) { + // move node to new parent + var parentId = toString(struct.parent); + var parentExists = parentId === null || cy.hasElementWithId(parentId); + if (parentExists) { + var pidToAssign = parentId === null ? undefined : parentId; + cy.batch(function () { + // avoid duplicate style updates + var updated = eles.remove(notifyRenderer, modifyPool); // clean up refs etc. + updated.emitAndNotify('moveout'); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _data6 = ele._private.data; + if (ele.isNode()) { + _data6.parent = pidToAssign; + } + } + updated.restore(notifyRenderer, modifyPool); // make new refs, style, etc. + }); + + eles.emitAndNotify('move'); + } + } + return this; +}; +[elesfn$j, elesfn$i, elesfn$h, elesfn$g, elesfn$f, data, elesfn$d, dimensions, elesfn$9, elesfn$8, elesfn$7, elesfn$6, elesfn$5, elesfn$4, elesfn$3, elesfn$2].forEach(function (props) { + extend(elesfn$1, props); +}); + +var corefn$9 = { + add: function add(opts) { + var elements; + var cy = this; + + // add the elements + if (elementOrCollection(opts)) { + var eles = opts; + if (eles._private.cy === cy) { + // same instance => just restore + elements = eles.restore(); + } else { + // otherwise, copy from json + var jsons = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + jsons.push(ele.json()); + } + elements = new Collection(cy, jsons); + } + } + + // specify an array of options + else if (array(opts)) { + var _jsons = opts; + elements = new Collection(cy, _jsons); + } + + // specify via opts.nodes and opts.edges + else if (plainObject(opts) && (array(opts.nodes) || array(opts.edges))) { + var elesByGroup = opts; + var _jsons2 = []; + var grs = ['nodes', 'edges']; + for (var _i = 0, il = grs.length; _i < il; _i++) { + var group = grs[_i]; + var elesArray = elesByGroup[group]; + if (array(elesArray)) { + for (var j = 0, jl = elesArray.length; j < jl; j++) { + var json = extend({ + group: group + }, elesArray[j]); + _jsons2.push(json); + } + } + } + elements = new Collection(cy, _jsons2); + } + + // specify options for one element + else { + var _json = opts; + elements = new Element(cy, _json).collection(); + } + return elements; + }, + remove: function remove(collection) { + if (elementOrCollection(collection)) ; else if (string(collection)) { + var selector = collection; + collection = this.$(selector); + } + return collection.remove(); + } +}; + +/* global Float32Array */ + +/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ +function generateCubicBezier(mX1, mY1, mX2, mY2) { + var NEWTON_ITERATIONS = 4, + NEWTON_MIN_SLOPE = 0.001, + SUBDIVISION_PRECISION = 0.0000001, + SUBDIVISION_MAX_ITERATIONS = 10, + kSplineTableSize = 11, + kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), + float32ArraySupported = typeof Float32Array !== 'undefined'; + + /* Must contain four arguments. */ + if (arguments.length !== 4) { + return false; + } + + /* Arguments must be numbers. */ + for (var i = 0; i < 4; ++i) { + if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { + return false; + } + } + + /* X values must be in the [0, 1] range. */ + mX1 = Math.min(mX1, 1); + mX2 = Math.min(mX2, 1); + mX1 = Math.max(mX1, 0); + mX2 = Math.max(mX2, 0); + var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); + function A(aA1, aA2) { + return 1.0 - 3.0 * aA2 + 3.0 * aA1; + } + function B(aA1, aA2) { + return 3.0 * aA2 - 6.0 * aA1; + } + function C(aA1) { + return 3.0 * aA1; + } + function calcBezier(aT, aA1, aA2) { + return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; + } + function getSlope(aT, aA1, aA2) { + return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); + } + function newtonRaphsonIterate(aX, aGuessT) { + for (var _i = 0; _i < NEWTON_ITERATIONS; ++_i) { + var currentSlope = getSlope(aGuessT, mX1, mX2); + if (currentSlope === 0.0) { + return aGuessT; + } + var currentX = calcBezier(aGuessT, mX1, mX2) - aX; + aGuessT -= currentX / currentSlope; + } + return aGuessT; + } + function calcSampleValues() { + for (var _i2 = 0; _i2 < kSplineTableSize; ++_i2) { + mSampleValues[_i2] = calcBezier(_i2 * kSampleStepSize, mX1, mX2); + } + } + function binarySubdivide(aX, aA, aB) { + var currentX, + currentT, + i = 0; + do { + currentT = aA + (aB - aA) / 2.0; + currentX = calcBezier(currentT, mX1, mX2) - aX; + if (currentX > 0.0) { + aB = currentT; + } else { + aA = currentT; + } + } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); + return currentT; + } + function getTForX(aX) { + var intervalStart = 0.0, + currentSample = 1, + lastSample = kSplineTableSize - 1; + for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { + intervalStart += kSampleStepSize; + } + --currentSample; + var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]), + guessForT = intervalStart + dist * kSampleStepSize, + initialSlope = getSlope(guessForT, mX1, mX2); + if (initialSlope >= NEWTON_MIN_SLOPE) { + return newtonRaphsonIterate(aX, guessForT); + } else if (initialSlope === 0.0) { + return guessForT; + } else { + return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); + } + } + var _precomputed = false; + function precompute() { + _precomputed = true; + if (mX1 !== mY1 || mX2 !== mY2) { + calcSampleValues(); + } + } + var f = function f(aX) { + if (!_precomputed) { + precompute(); + } + if (mX1 === mY1 && mX2 === mY2) { + return aX; + } + if (aX === 0) { + return 0; + } + if (aX === 1) { + return 1; + } + return calcBezier(getTForX(aX), mY1, mY2); + }; + f.getControlPoints = function () { + return [{ + x: mX1, + y: mY1 + }, { + x: mX2, + y: mY2 + }]; + }; + var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; + f.toString = function () { + return str; + }; + return f; +} + +/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ +/* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass + then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ +var generateSpringRK4 = function () { + function springAccelerationForState(state) { + return -state.tension * state.x - state.friction * state.v; + } + function springEvaluateStateWithDerivative(initialState, dt, derivative) { + var state = { + x: initialState.x + derivative.dx * dt, + v: initialState.v + derivative.dv * dt, + tension: initialState.tension, + friction: initialState.friction + }; + return { + dx: state.v, + dv: springAccelerationForState(state) + }; + } + function springIntegrateState(state, dt) { + var a = { + dx: state.v, + dv: springAccelerationForState(state) + }, + b = springEvaluateStateWithDerivative(state, dt * 0.5, a), + c = springEvaluateStateWithDerivative(state, dt * 0.5, b), + d = springEvaluateStateWithDerivative(state, dt, c), + dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), + dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); + state.x = state.x + dxdt * dt; + state.v = state.v + dvdt * dt; + return state; + } + return function springRK4Factory(tension, friction, duration) { + var initState = { + x: -1, + v: 0, + tension: null, + friction: null + }, + path = [0], + time_lapsed = 0, + tolerance = 1 / 10000, + DT = 16 / 1000, + have_duration, + dt, + last_state; + tension = parseFloat(tension) || 500; + friction = parseFloat(friction) || 20; + duration = duration || null; + initState.tension = tension; + initState.friction = friction; + have_duration = duration !== null; + + /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ + if (have_duration) { + /* Run the simulation without a duration. */ + time_lapsed = springRK4Factory(tension, friction); + /* Compute the adjusted time delta. */ + dt = time_lapsed / duration * DT; + } else { + dt = DT; + } + for (;;) { + /* Next/step function .*/ + last_state = springIntegrateState(last_state || initState, dt); + /* Store the position. */ + path.push(1 + last_state.x); + time_lapsed += 16; + /* If the change threshold is reached, break. */ + if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { + break; + } + } + + /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the + computed path and returns a snapshot of the position according to a given percentComplete. */ + return !have_duration ? time_lapsed : function (percentComplete) { + return path[percentComplete * (path.length - 1) | 0]; + }; + }; +}(); + +var cubicBezier = function cubicBezier(t1, p1, t2, p2) { + var bezier = generateCubicBezier(t1, p1, t2, p2); + return function (start, end, percent) { + return start + (end - start) * bezier(percent); + }; +}; +var easings = { + 'linear': function linear(start, end, percent) { + return start + (end - start) * percent; + }, + // default easings + 'ease': cubicBezier(0.25, 0.1, 0.25, 1), + 'ease-in': cubicBezier(0.42, 0, 1, 1), + 'ease-out': cubicBezier(0, 0, 0.58, 1), + 'ease-in-out': cubicBezier(0.42, 0, 0.58, 1), + // sine + 'ease-in-sine': cubicBezier(0.47, 0, 0.745, 0.715), + 'ease-out-sine': cubicBezier(0.39, 0.575, 0.565, 1), + 'ease-in-out-sine': cubicBezier(0.445, 0.05, 0.55, 0.95), + // quad + 'ease-in-quad': cubicBezier(0.55, 0.085, 0.68, 0.53), + 'ease-out-quad': cubicBezier(0.25, 0.46, 0.45, 0.94), + 'ease-in-out-quad': cubicBezier(0.455, 0.03, 0.515, 0.955), + // cubic + 'ease-in-cubic': cubicBezier(0.55, 0.055, 0.675, 0.19), + 'ease-out-cubic': cubicBezier(0.215, 0.61, 0.355, 1), + 'ease-in-out-cubic': cubicBezier(0.645, 0.045, 0.355, 1), + // quart + 'ease-in-quart': cubicBezier(0.895, 0.03, 0.685, 0.22), + 'ease-out-quart': cubicBezier(0.165, 0.84, 0.44, 1), + 'ease-in-out-quart': cubicBezier(0.77, 0, 0.175, 1), + // quint + 'ease-in-quint': cubicBezier(0.755, 0.05, 0.855, 0.06), + 'ease-out-quint': cubicBezier(0.23, 1, 0.32, 1), + 'ease-in-out-quint': cubicBezier(0.86, 0, 0.07, 1), + // expo + 'ease-in-expo': cubicBezier(0.95, 0.05, 0.795, 0.035), + 'ease-out-expo': cubicBezier(0.19, 1, 0.22, 1), + 'ease-in-out-expo': cubicBezier(1, 0, 0, 1), + // circ + 'ease-in-circ': cubicBezier(0.6, 0.04, 0.98, 0.335), + 'ease-out-circ': cubicBezier(0.075, 0.82, 0.165, 1), + 'ease-in-out-circ': cubicBezier(0.785, 0.135, 0.15, 0.86), + // user param easings... + + 'spring': function spring(tension, friction, duration) { + if (duration === 0) { + // can't get a spring w/ duration 0 + return easings.linear; // duration 0 => jump to end so impl doesn't matter + } + + var spring = generateSpringRK4(tension, friction, duration); + return function (start, end, percent) { + return start + (end - start) * spring(percent); + }; + }, + 'cubic-bezier': cubicBezier +}; + +function getEasedValue(type, start, end, percent, easingFn) { + if (percent === 1) { + return end; + } + if (start === end) { + return end; + } + var val = easingFn(start, end, percent); + if (type == null) { + return val; + } + if (type.roundValue || type.color) { + val = Math.round(val); + } + if (type.min !== undefined) { + val = Math.max(val, type.min); + } + if (type.max !== undefined) { + val = Math.min(val, type.max); + } + return val; +} +function getValue(prop, spec) { + if (prop.pfValue != null || prop.value != null) { + if (prop.pfValue != null && (spec == null || spec.type.units !== '%')) { + return prop.pfValue; + } else { + return prop.value; + } + } else { + return prop; + } +} +function ease(startProp, endProp, percent, easingFn, propSpec) { + var type = propSpec != null ? propSpec.type : null; + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + var start = getValue(startProp, propSpec); + var end = getValue(endProp, propSpec); + if (number$1(start) && number$1(end)) { + return getEasedValue(type, start, end, percent, easingFn); + } else if (array(start) && array(end)) { + var easedArr = []; + for (var i = 0; i < end.length; i++) { + var si = start[i]; + var ei = end[i]; + if (si != null && ei != null) { + var val = getEasedValue(type, si, ei, percent, easingFn); + easedArr.push(val); + } else { + easedArr.push(ei); + } + } + return easedArr; + } + return undefined; +} + +function step$1(self, ani, now, isCore) { + var isEles = !isCore; + var _p = self._private; + var ani_p = ani._private; + var pEasing = ani_p.easing; + var startTime = ani_p.startTime; + var cy = isCore ? self : self.cy(); + var style = cy.style(); + if (!ani_p.easingImpl) { + if (pEasing == null) { + // use default + ani_p.easingImpl = easings['linear']; + } else { + // then define w/ name + var easingVals; + if (string(pEasing)) { + var easingProp = style.parse('transition-timing-function', pEasing); + easingVals = easingProp.value; + } else { + // then assume preparsed array + easingVals = pEasing; + } + var name, args; + if (string(easingVals)) { + name = easingVals; + args = []; + } else { + name = easingVals[1]; + args = easingVals.slice(2).map(function (n) { + return +n; + }); + } + if (args.length > 0) { + // create with args + if (name === 'spring') { + args.push(ani_p.duration); // need duration to generate spring + } + + ani_p.easingImpl = easings[name].apply(null, args); + } else { + // static impl by name + ani_p.easingImpl = easings[name]; + } + } + } + var easing = ani_p.easingImpl; + var percent; + if (ani_p.duration === 0) { + percent = 1; + } else { + percent = (now - startTime) / ani_p.duration; + } + if (ani_p.applying) { + percent = ani_p.progress; + } + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + if (ani_p.delay == null) { + // then update + + var startPos = ani_p.startPosition; + var endPos = ani_p.position; + if (endPos && isEles && !self.locked()) { + var newPos = {}; + if (valid(startPos.x, endPos.x)) { + newPos.x = ease(startPos.x, endPos.x, percent, easing); + } + if (valid(startPos.y, endPos.y)) { + newPos.y = ease(startPos.y, endPos.y, percent, easing); + } + self.position(newPos); + } + var startPan = ani_p.startPan; + var endPan = ani_p.pan; + var pan = _p.pan; + var animatingPan = endPan != null && isCore; + if (animatingPan) { + if (valid(startPan.x, endPan.x)) { + pan.x = ease(startPan.x, endPan.x, percent, easing); + } + if (valid(startPan.y, endPan.y)) { + pan.y = ease(startPan.y, endPan.y, percent, easing); + } + self.emit('pan'); + } + var startZoom = ani_p.startZoom; + var endZoom = ani_p.zoom; + var animatingZoom = endZoom != null && isCore; + if (animatingZoom) { + if (valid(startZoom, endZoom)) { + _p.zoom = bound(_p.minZoom, ease(startZoom, endZoom, percent, easing), _p.maxZoom); + } + self.emit('zoom'); + } + if (animatingPan || animatingZoom) { + self.emit('viewport'); + } + var props = ani_p.style; + if (props && props.length > 0 && isEles) { + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + var _name = prop.name; + var end = prop; + var start = ani_p.startStyle[_name]; + var propSpec = style.properties[start.name]; + var easedVal = ease(start, end, percent, easing, propSpec); + style.overrideBypass(self, _name, easedVal); + } // for props + + self.emit('style'); + } // if + } + + ani_p.progress = percent; + return percent; +} +function valid(start, end) { + if (start == null || end == null) { + return false; + } + if (number$1(start) && number$1(end)) { + return true; + } else if (start && end) { + return true; + } + return false; +} + +function startAnimation(self, ani, now, isCore) { + var ani_p = ani._private; + ani_p.started = true; + ani_p.startTime = now - ani_p.progress * ani_p.duration; +} + +function stepAll(now, cy) { + var eles = cy._private.aniEles; + var doneEles = []; + function stepOne(ele, isCore) { + var _p = ele._private; + var current = _p.animation.current; + var queue = _p.animation.queue; + var ranAnis = false; + + // if nothing currently animating, get something from the queue + if (current.length === 0) { + var next = queue.shift(); + if (next) { + current.push(next); + } + } + var callbacks = function callbacks(_callbacks) { + for (var j = _callbacks.length - 1; j >= 0; j--) { + var cb = _callbacks[j]; + cb(); + } + _callbacks.splice(0, _callbacks.length); + }; + + // step and remove if done + for (var i = current.length - 1; i >= 0; i--) { + var ani = current[i]; + var ani_p = ani._private; + if (ani_p.stopped) { + current.splice(i, 1); + ani_p.hooked = false; + ani_p.playing = false; + ani_p.started = false; + callbacks(ani_p.frames); + continue; + } + if (!ani_p.playing && !ani_p.applying) { + continue; + } + + // an apply() while playing shouldn't do anything + if (ani_p.playing && ani_p.applying) { + ani_p.applying = false; + } + if (!ani_p.started) { + startAnimation(ele, ani, now); + } + step$1(ele, ani, now, isCore); + if (ani_p.applying) { + ani_p.applying = false; + } + callbacks(ani_p.frames); + if (ani_p.step != null) { + ani_p.step(now); + } + if (ani.completed()) { + current.splice(i, 1); + ani_p.hooked = false; + ani_p.playing = false; + ani_p.started = false; + callbacks(ani_p.completes); + } + ranAnis = true; + } + if (!isCore && current.length === 0 && queue.length === 0) { + doneEles.push(ele); + } + return ranAnis; + } // stepElement + + // handle all eles + var ranEleAni = false; + for (var e = 0; e < eles.length; e++) { + var ele = eles[e]; + var handledThisEle = stepOne(ele); + ranEleAni = ranEleAni || handledThisEle; + } // each element + + var ranCoreAni = stepOne(cy, true); + + // notify renderer + if (ranEleAni || ranCoreAni) { + if (eles.length > 0) { + cy.notify('draw', eles); + } else { + cy.notify('draw'); + } + } + + // remove elements from list of currently animating if its queues are empty + eles.unmerge(doneEles); + cy.emit('step'); +} // stepAll + +var corefn$8 = { + // pull in animation functions + animate: define.animate(), + animation: define.animation(), + animated: define.animated(), + clearQueue: define.clearQueue(), + delay: define.delay(), + delayAnimation: define.delayAnimation(), + stop: define.stop(), + addToAnimationPool: function addToAnimationPool(eles) { + var cy = this; + if (!cy.styleEnabled()) { + return; + } // save cycles when no style used + + cy._private.aniEles.merge(eles); + }, + stopAnimationLoop: function stopAnimationLoop() { + this._private.animationsRunning = false; + }, + startAnimationLoop: function startAnimationLoop() { + var cy = this; + cy._private.animationsRunning = true; + if (!cy.styleEnabled()) { + return; + } // save cycles when no style used + + // NB the animation loop will exec in headless environments if style enabled + // and explicit cy.destroy() is necessary to stop the loop + + function headlessStep() { + if (!cy._private.animationsRunning) { + return; + } + requestAnimationFrame$1(function animationStep(now) { + stepAll(now, cy); + headlessStep(); + }); + } + var renderer = cy.renderer(); + if (renderer && renderer.beforeRender) { + // let the renderer schedule animations + renderer.beforeRender(function rendererAnimationStep(willDraw, now) { + stepAll(now, cy); + }, renderer.beforeRenderPriorities.animations); + } else { + // manage the animation loop ourselves + headlessStep(); // first call + } + } +}; + +var emitterOptions = { + qualifierCompare: function qualifierCompare(selector1, selector2) { + if (selector1 == null || selector2 == null) { + return selector1 == null && selector2 == null; + } else { + return selector1.sameText(selector2); + } + }, + eventMatches: function eventMatches(cy, listener, eventObj) { + var selector = listener.qualifier; + if (selector != null) { + return cy !== eventObj.target && element(eventObj.target) && selector.matches(eventObj.target); + } + return true; + }, + addEventFields: function addEventFields(cy, evt) { + evt.cy = cy; + evt.target = cy; + }, + callbackContext: function callbackContext(cy, listener, eventObj) { + return listener.qualifier != null ? eventObj.target : cy; + } +}; +var argSelector = function argSelector(arg) { + if (string(arg)) { + return new Selector(arg); + } else { + return arg; + } +}; +var elesfn = { + createEmitter: function createEmitter() { + var _p = this._private; + if (!_p.emitter) { + _p.emitter = new Emitter(emitterOptions, this); + } + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(events, selector, callback) { + this.emitter().on(events, argSelector(selector), callback); + return this; + }, + removeListener: function removeListener(events, selector, callback) { + this.emitter().removeListener(events, argSelector(selector), callback); + return this; + }, + removeAllListeners: function removeAllListeners() { + this.emitter().removeAllListeners(); + return this; + }, + one: function one(events, selector, callback) { + this.emitter().one(events, argSelector(selector), callback); + return this; + }, + once: function once(events, selector, callback) { + this.emitter().one(events, argSelector(selector), callback); + return this; + }, + emit: function emit(events, extraParams) { + this.emitter().emit(events, extraParams); + return this; + }, + emitAndNotify: function emitAndNotify(event, eles) { + this.emit(event); + this.notify(event, eles); + return this; + } +}; +define.eventAliasesOn(elesfn); + +var corefn$7 = { + png: function png(options) { + var renderer = this._private.renderer; + options = options || {}; + return renderer.png(options); + }, + jpg: function jpg(options) { + var renderer = this._private.renderer; + options = options || {}; + options.bg = options.bg || '#fff'; + return renderer.jpg(options); + } +}; +corefn$7.jpeg = corefn$7.jpg; + +var corefn$6 = { + layout: function layout(options) { + var cy = this; + if (options == null) { + error('Layout options must be specified to make a layout'); + return; + } + if (options.name == null) { + error('A `name` must be specified to make a layout'); + return; + } + var name = options.name; + var Layout = cy.extension('layout', name); + if (Layout == null) { + error('No such layout `' + name + '` found. Did you forget to import it and `cytoscape.use()` it?'); + return; + } + var eles; + if (string(options.eles)) { + eles = cy.$(options.eles); + } else { + eles = options.eles != null ? options.eles : cy.$(); + } + var layout = new Layout(extend({}, options, { + cy: cy, + eles: eles + })); + return layout; + } +}; +corefn$6.createLayout = corefn$6.makeLayout = corefn$6.layout; + +var corefn$5 = { + notify: function notify(eventName, eventEles) { + var _p = this._private; + if (this.batching()) { + _p.batchNotifications = _p.batchNotifications || {}; + var eles = _p.batchNotifications[eventName] = _p.batchNotifications[eventName] || this.collection(); + if (eventEles != null) { + eles.merge(eventEles); + } + return; // notifications are disabled during batching + } + + if (!_p.notificationsEnabled) { + return; + } // exit on disabled + + var renderer = this.renderer(); + + // exit if destroy() called on core or renderer in between frames #1499 #1528 + if (this.destroyed() || !renderer) { + return; + } + renderer.notify(eventName, eventEles); + }, + notifications: function notifications(bool) { + var p = this._private; + if (bool === undefined) { + return p.notificationsEnabled; + } else { + p.notificationsEnabled = bool ? true : false; + } + return this; + }, + noNotifications: function noNotifications(callback) { + this.notifications(false); + callback(); + this.notifications(true); + }, + batching: function batching() { + return this._private.batchCount > 0; + }, + startBatch: function startBatch() { + var _p = this._private; + if (_p.batchCount == null) { + _p.batchCount = 0; + } + if (_p.batchCount === 0) { + _p.batchStyleEles = this.collection(); + _p.batchNotifications = {}; + } + _p.batchCount++; + return this; + }, + endBatch: function endBatch() { + var _p = this._private; + if (_p.batchCount === 0) { + return this; + } + _p.batchCount--; + if (_p.batchCount === 0) { + // update style for dirty eles + _p.batchStyleEles.updateStyle(); + var renderer = this.renderer(); + + // notify the renderer of queued eles and event types + Object.keys(_p.batchNotifications).forEach(function (eventName) { + var eles = _p.batchNotifications[eventName]; + if (eles.empty()) { + renderer.notify(eventName); + } else { + renderer.notify(eventName, eles); + } + }); + } + return this; + }, + batch: function batch(callback) { + this.startBatch(); + callback(); + this.endBatch(); + return this; + }, + // for backwards compatibility + batchData: function batchData(map) { + var cy = this; + return this.batch(function () { + var ids = Object.keys(map); + for (var i = 0; i < ids.length; i++) { + var id = ids[i]; + var data = map[id]; + var ele = cy.getElementById(id); + ele.data(data); + } + }); + } +}; + +var rendererDefaults = defaults$g({ + hideEdgesOnViewport: false, + textureOnViewport: false, + motionBlur: false, + motionBlurOpacity: 0.05, + pixelRatio: undefined, + desktopTapThreshold: 4, + touchTapThreshold: 8, + wheelSensitivity: 1, + debug: false, + showFps: false +}); +var corefn$4 = { + renderTo: function renderTo(context, zoom, pan, pxRatio) { + var r = this._private.renderer; + r.renderTo(context, zoom, pan, pxRatio); + return this; + }, + renderer: function renderer() { + return this._private.renderer; + }, + forceRender: function forceRender() { + this.notify('draw'); + return this; + }, + resize: function resize() { + this.invalidateSize(); + this.emitAndNotify('resize'); + return this; + }, + initRenderer: function initRenderer(options) { + var cy = this; + var RendererProto = cy.extension('renderer', options.name); + if (RendererProto == null) { + error("Can not initialise: No such renderer `".concat(options.name, "` found. Did you forget to import it and `cytoscape.use()` it?")); + return; + } + if (options.wheelSensitivity !== undefined) { + warn("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine."); + } + var rOpts = rendererDefaults(options); + rOpts.cy = cy; + cy._private.renderer = new RendererProto(rOpts); + this.notify('init'); + }, + destroyRenderer: function destroyRenderer() { + var cy = this; + cy.notify('destroy'); // destroy the renderer + + var domEle = cy.container(); + if (domEle) { + domEle._cyreg = null; + while (domEle.childNodes.length > 0) { + domEle.removeChild(domEle.childNodes[0]); + } + } + cy._private.renderer = null; // to be extra safe, remove the ref + cy.mutableElements().forEach(function (ele) { + var _p = ele._private; + _p.rscratch = {}; + _p.rstyle = {}; + _p.animation.current = []; + _p.animation.queue = []; + }); + }, + onRender: function onRender(fn) { + return this.on('render', fn); + }, + offRender: function offRender(fn) { + return this.off('render', fn); + } +}; +corefn$4.invalidateDimensions = corefn$4.resize; + +var corefn$3 = { + // get a collection + // - empty collection on no args + // - collection of elements in the graph on selector arg + // - guarantee a returned collection when elements or collection specified + collection: function collection(eles, opts) { + if (string(eles)) { + return this.$(eles); + } else if (elementOrCollection(eles)) { + return eles.collection(); + } else if (array(eles)) { + if (!opts) { + opts = {}; + } + return new Collection(this, eles, opts.unique, opts.removed); + } + return new Collection(this); + }, + nodes: function nodes(selector) { + var nodes = this.$(function (ele) { + return ele.isNode(); + }); + if (selector) { + return nodes.filter(selector); + } + return nodes; + }, + edges: function edges(selector) { + var edges = this.$(function (ele) { + return ele.isEdge(); + }); + if (selector) { + return edges.filter(selector); + } + return edges; + }, + // search the graph like jQuery + $: function $(selector) { + var eles = this._private.elements; + if (selector) { + return eles.filter(selector); + } else { + return eles.spawnSelf(); + } + }, + mutableElements: function mutableElements() { + return this._private.elements; + } +}; + +// aliases +corefn$3.elements = corefn$3.filter = corefn$3.$; + +var styfn$8 = {}; + +// keys for style blocks, e.g. ttfftt +var TRUE = 't'; +var FALSE = 'f'; + +// (potentially expensive calculation) +// apply the style to the element based on +// - its bypass +// - what selectors match it +styfn$8.apply = function (eles) { + var self = this; + var _p = self._private; + var cy = _p.cy; + var updatedEles = cy.collection(); + for (var ie = 0; ie < eles.length; ie++) { + var ele = eles[ie]; + var cxtMeta = self.getContextMeta(ele); + if (cxtMeta.empty) { + continue; + } + var cxtStyle = self.getContextStyle(cxtMeta); + var app = self.applyContextStyle(cxtMeta, cxtStyle, ele); + if (ele._private.appliedInitStyle) { + self.updateTransitions(ele, app.diffProps); + } else { + ele._private.appliedInitStyle = true; + } + var hintsDiff = self.updateStyleHints(ele); + if (hintsDiff) { + updatedEles.push(ele); + } + } // for elements + + return updatedEles; +}; +styfn$8.getPropertiesDiff = function (oldCxtKey, newCxtKey) { + var self = this; + var cache = self._private.propDiffs = self._private.propDiffs || {}; + var dualCxtKey = oldCxtKey + '-' + newCxtKey; + var cachedVal = cache[dualCxtKey]; + if (cachedVal) { + return cachedVal; + } + var diffProps = []; + var addedProp = {}; + for (var i = 0; i < self.length; i++) { + var cxt = self[i]; + var oldHasCxt = oldCxtKey[i] === TRUE; + var newHasCxt = newCxtKey[i] === TRUE; + var cxtHasDiffed = oldHasCxt !== newHasCxt; + var cxtHasMappedProps = cxt.mappedProperties.length > 0; + if (cxtHasDiffed || newHasCxt && cxtHasMappedProps) { + var props = void 0; + if (cxtHasDiffed && cxtHasMappedProps) { + props = cxt.properties; // suffices b/c mappedProperties is a subset of properties + } else if (cxtHasDiffed) { + props = cxt.properties; // need to check them all + } else if (cxtHasMappedProps) { + props = cxt.mappedProperties; // only need to check mapped + } + + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + var name = prop.name; + + // if a later context overrides this property, then the fact that this context has switched/diffed doesn't matter + // (semi expensive check since it makes this function O(n^2) on context length, but worth it since overall result + // is cached) + var laterCxtOverrides = false; + for (var k = i + 1; k < self.length; k++) { + var laterCxt = self[k]; + var hasLaterCxt = newCxtKey[k] === TRUE; + if (!hasLaterCxt) { + continue; + } // can't override unless the context is active + + laterCxtOverrides = laterCxt.properties[prop.name] != null; + if (laterCxtOverrides) { + break; + } // exit early as long as one later context overrides + } + + if (!addedProp[name] && !laterCxtOverrides) { + addedProp[name] = true; + diffProps.push(name); + } + } // for props + } // if + } // for contexts + + cache[dualCxtKey] = diffProps; + return diffProps; +}; +styfn$8.getContextMeta = function (ele) { + var self = this; + var cxtKey = ''; + var diffProps; + var prevKey = ele._private.styleCxtKey || ''; + + // get the cxt key + for (var i = 0; i < self.length; i++) { + var context = self[i]; + var contextSelectorMatches = context.selector && context.selector.matches(ele); // NB: context.selector may be null for 'core' + + if (contextSelectorMatches) { + cxtKey += TRUE; + } else { + cxtKey += FALSE; + } + } // for context + + diffProps = self.getPropertiesDiff(prevKey, cxtKey); + ele._private.styleCxtKey = cxtKey; + return { + key: cxtKey, + diffPropNames: diffProps, + empty: diffProps.length === 0 + }; +}; + +// gets a computed ele style object based on matched contexts +styfn$8.getContextStyle = function (cxtMeta) { + var cxtKey = cxtMeta.key; + var self = this; + var cxtStyles = this._private.contextStyles = this._private.contextStyles || {}; + + // if already computed style, returned cached copy + if (cxtStyles[cxtKey]) { + return cxtStyles[cxtKey]; + } + var style = { + _private: { + key: cxtKey + } + }; + for (var i = 0; i < self.length; i++) { + var cxt = self[i]; + var hasCxt = cxtKey[i] === TRUE; + if (!hasCxt) { + continue; + } + for (var j = 0; j < cxt.properties.length; j++) { + var prop = cxt.properties[j]; + style[prop.name] = prop; + } + } + cxtStyles[cxtKey] = style; + return style; +}; +styfn$8.applyContextStyle = function (cxtMeta, cxtStyle, ele) { + var self = this; + var diffProps = cxtMeta.diffPropNames; + var retDiffProps = {}; + var types = self.types; + for (var i = 0; i < diffProps.length; i++) { + var diffPropName = diffProps[i]; + var cxtProp = cxtStyle[diffPropName]; + var eleProp = ele.pstyle(diffPropName); + if (!cxtProp) { + // no context prop means delete + if (!eleProp) { + continue; // no existing prop means nothing needs to be removed + // nb affects initial application on mapped values like control-point-distances + } else if (eleProp.bypass) { + cxtProp = { + name: diffPropName, + deleteBypassed: true + }; + } else { + cxtProp = { + name: diffPropName, + "delete": true + }; + } + } + + // save cycles when the context prop doesn't need to be applied + if (eleProp === cxtProp) { + continue; + } + + // save cycles when a mapped context prop doesn't need to be applied + if (cxtProp.mapped === types.fn // context prop is function mapper + && eleProp != null // some props can be null even by default (e.g. a prop that overrides another one) + && eleProp.mapping != null // ele prop is a concrete value from from a mapper + && eleProp.mapping.value === cxtProp.value // the current prop on the ele is a flat prop value for the function mapper + ) { + // NB don't write to cxtProp, as it's shared among eles (stored in stylesheet) + var mapping = eleProp.mapping; // can write to mapping, as it's a per-ele copy + var fnValue = mapping.fnValue = cxtProp.value(ele); // temporarily cache the value in case of a miss + + if (fnValue === mapping.prevFnValue) { + continue; + } + } + var retDiffProp = retDiffProps[diffPropName] = { + prev: eleProp + }; + self.applyParsedProperty(ele, cxtProp); + retDiffProp.next = ele.pstyle(diffPropName); + if (retDiffProp.next && retDiffProp.next.bypass) { + retDiffProp.next = retDiffProp.next.bypassed; + } + } + return { + diffProps: retDiffProps + }; +}; +styfn$8.updateStyleHints = function (ele) { + var _p = ele._private; + var self = this; + var propNames = self.propertyGroupNames; + var propGrKeys = self.propertyGroupKeys; + var propHash = function propHash(ele, propNames, seedKey) { + return self.getPropertiesHash(ele, propNames, seedKey); + }; + var oldStyleKey = _p.styleKey; + if (ele.removed()) { + return false; + } + var isNode = _p.group === 'nodes'; + + // get the style key hashes per prop group + // but lazily -- only use non-default prop values to reduce the number of hashes + // + + var overriddenStyles = ele._private.style; + propNames = Object.keys(overriddenStyles); + for (var i = 0; i < propGrKeys.length; i++) { + var grKey = propGrKeys[i]; + _p.styleKeys[grKey] = [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]; + } + var updateGrKey1 = function updateGrKey1(val, grKey) { + return _p.styleKeys[grKey][0] = hashInt(val, _p.styleKeys[grKey][0]); + }; + var updateGrKey2 = function updateGrKey2(val, grKey) { + return _p.styleKeys[grKey][1] = hashIntAlt(val, _p.styleKeys[grKey][1]); + }; + var updateGrKey = function updateGrKey(val, grKey) { + updateGrKey1(val, grKey); + updateGrKey2(val, grKey); + }; + var updateGrKeyWStr = function updateGrKeyWStr(strVal, grKey) { + for (var j = 0; j < strVal.length; j++) { + var ch = strVal.charCodeAt(j); + updateGrKey1(ch, grKey); + updateGrKey2(ch, grKey); + } + }; + + // - hashing works on 32 bit ints b/c we use bitwise ops + // - small numbers get cut off (e.g. 0.123 is seen as 0 by the hashing function) + // - raise up small numbers so more significant digits are seen by hashing + // - make small numbers larger than a normal value to avoid collisions + // - works in practice and it's relatively cheap + var N = 2000000000; + var cleanNum = function cleanNum(val) { + return -128 < val && val < 128 && Math.floor(val) !== val ? N - (val * 1024 | 0) : val; + }; + for (var _i = 0; _i < propNames.length; _i++) { + var name = propNames[_i]; + var parsedProp = overriddenStyles[name]; + if (parsedProp == null) { + continue; + } + var propInfo = this.properties[name]; + var type = propInfo.type; + var _grKey = propInfo.groupKey; + var normalizedNumberVal = void 0; + if (propInfo.hashOverride != null) { + normalizedNumberVal = propInfo.hashOverride(ele, parsedProp); + } else if (parsedProp.pfValue != null) { + normalizedNumberVal = parsedProp.pfValue; + } + + // might not be a number if it allows enums + var numberVal = propInfo.enums == null ? parsedProp.value : null; + var haveNormNum = normalizedNumberVal != null; + var haveUnitedNum = numberVal != null; + var haveNum = haveNormNum || haveUnitedNum; + var units = parsedProp.units; + + // numbers are cheaper to hash than strings + // 1 hash op vs n hash ops (for length n string) + if (type.number && haveNum && !type.multiple) { + var v = haveNormNum ? normalizedNumberVal : numberVal; + updateGrKey(cleanNum(v), _grKey); + if (!haveNormNum && units != null) { + updateGrKeyWStr(units, _grKey); + } + } else { + updateGrKeyWStr(parsedProp.strValue, _grKey); + } + } + + // overall style key + // + + var hash = [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]; + for (var _i2 = 0; _i2 < propGrKeys.length; _i2++) { + var _grKey2 = propGrKeys[_i2]; + var grHash = _p.styleKeys[_grKey2]; + hash[0] = hashInt(grHash[0], hash[0]); + hash[1] = hashIntAlt(grHash[1], hash[1]); + } + _p.styleKey = combineHashes(hash[0], hash[1]); + + // label dims + // + + var sk = _p.styleKeys; + _p.labelDimsKey = combineHashesArray(sk.labelDimensions); + var labelKeys = propHash(ele, ['label'], sk.labelDimensions); + _p.labelKey = combineHashesArray(labelKeys); + _p.labelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, labelKeys)); + if (!isNode) { + var sourceLabelKeys = propHash(ele, ['source-label'], sk.labelDimensions); + _p.sourceLabelKey = combineHashesArray(sourceLabelKeys); + _p.sourceLabelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, sourceLabelKeys)); + var targetLabelKeys = propHash(ele, ['target-label'], sk.labelDimensions); + _p.targetLabelKey = combineHashesArray(targetLabelKeys); + _p.targetLabelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, targetLabelKeys)); + } + + // node + // + + if (isNode) { + var _p$styleKeys = _p.styleKeys, + nodeBody = _p$styleKeys.nodeBody, + nodeBorder = _p$styleKeys.nodeBorder, + nodeOutline = _p$styleKeys.nodeOutline, + backgroundImage = _p$styleKeys.backgroundImage, + compound = _p$styleKeys.compound, + pie = _p$styleKeys.pie; + var nodeKeys = [nodeBody, nodeBorder, nodeOutline, backgroundImage, compound, pie].filter(function (k) { + return k != null; + }).reduce(hashArrays, [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]); + _p.nodeKey = combineHashesArray(nodeKeys); + _p.hasPie = pie != null && pie[0] !== DEFAULT_HASH_SEED && pie[1] !== DEFAULT_HASH_SEED_ALT; + } + return oldStyleKey !== _p.styleKey; +}; +styfn$8.clearStyleHints = function (ele) { + var _p = ele._private; + _p.styleCxtKey = ''; + _p.styleKeys = {}; + _p.styleKey = null; + _p.labelKey = null; + _p.labelStyleKey = null; + _p.sourceLabelKey = null; + _p.sourceLabelStyleKey = null; + _p.targetLabelKey = null; + _p.targetLabelStyleKey = null; + _p.nodeKey = null; + _p.hasPie = null; +}; + +// apply a property to the style (for internal use) +// returns whether application was successful +// +// now, this function flattens the property, and here's how: +// +// for parsedProp:{ bypass: true, deleteBypass: true } +// no property is generated, instead the bypass property in the +// element's style is replaced by what's pointed to by the `bypassed` +// field in the bypass property (i.e. restoring the property the +// bypass was overriding) +// +// for parsedProp:{ mapped: truthy } +// the generated flattenedProp:{ mapping: prop } +// +// for parsedProp:{ bypass: true } +// the generated flattenedProp:{ bypassed: parsedProp } +styfn$8.applyParsedProperty = function (ele, parsedProp) { + var self = this; + var prop = parsedProp; + var style = ele._private.style; + var flatProp; + var types = self.types; + var type = self.properties[prop.name].type; + var propIsBypass = prop.bypass; + var origProp = style[prop.name]; + var origPropIsBypass = origProp && origProp.bypass; + var _p = ele._private; + var flatPropMapping = 'mapping'; + var getVal = function getVal(p) { + if (p == null) { + return null; + } else if (p.pfValue != null) { + return p.pfValue; + } else { + return p.value; + } + }; + var checkTriggers = function checkTriggers() { + var fromVal = getVal(origProp); + var toVal = getVal(prop); + self.checkTriggers(ele, prop.name, fromVal, toVal); + }; + + // edge sanity checks to prevent the client from making serious mistakes + if (parsedProp.name === 'curve-style' && ele.isEdge() && ( + // loops must be bundled beziers + parsedProp.value !== 'bezier' && ele.isLoop() || + // edges connected to compound nodes can not be haystacks + parsedProp.value === 'haystack' && (ele.source().isParent() || ele.target().isParent()))) { + prop = parsedProp = this.parse(parsedProp.name, 'bezier', propIsBypass); + } + if (prop["delete"]) { + // delete the property and use the default value on falsey value + style[prop.name] = undefined; + checkTriggers(); + return true; + } + if (prop.deleteBypassed) { + // delete the property that the + if (!origProp) { + checkTriggers(); + return true; // can't delete if no prop + } else if (origProp.bypass) { + // delete bypassed + origProp.bypassed = undefined; + checkTriggers(); + return true; + } else { + return false; // we're unsuccessful deleting the bypassed + } + } + + // check if we need to delete the current bypass + if (prop.deleteBypass) { + // then this property is just here to indicate we need to delete + if (!origProp) { + checkTriggers(); + return true; // property is already not defined + } else if (origProp.bypass) { + // then replace the bypass property with the original + // because the bypassed property was already applied (and therefore parsed), we can just replace it (no reapplying necessary) + style[prop.name] = origProp.bypassed; + checkTriggers(); + return true; + } else { + return false; // we're unsuccessful deleting the bypass + } + } + + var printMappingErr = function printMappingErr() { + warn('Do not assign mappings to elements without corresponding data (i.e. ele `' + ele.id() + '` has no mapping for property `' + prop.name + '` with data field `' + prop.field + '`); try a `[' + prop.field + ']` selector to limit scope to elements with `' + prop.field + '` defined'); + }; + + // put the property in the style objects + switch (prop.mapped) { + // flatten the property if mapped + case types.mapData: + { + // flatten the field (e.g. data.foo.bar) + var fields = prop.field.split('.'); + var fieldVal = _p.data; + for (var i = 0; i < fields.length && fieldVal; i++) { + var field = fields[i]; + fieldVal = fieldVal[field]; + } + if (fieldVal == null) { + printMappingErr(); + return false; + } + var percent; + if (!number$1(fieldVal)) { + // then don't apply and fall back on the existing style + warn('Do not use continuous mappers without specifying numeric data (i.e. `' + prop.field + ': ' + fieldVal + '` for `' + ele.id() + '` is non-numeric)'); + return false; + } else { + var fieldWidth = prop.fieldMax - prop.fieldMin; + if (fieldWidth === 0) { + // safety check -- not strictly necessary as no props of zero range should be passed here + percent = 0; + } else { + percent = (fieldVal - prop.fieldMin) / fieldWidth; + } + } + + // make sure to bound percent value + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + if (type.color) { + var r1 = prop.valueMin[0]; + var r2 = prop.valueMax[0]; + var g1 = prop.valueMin[1]; + var g2 = prop.valueMax[1]; + var b1 = prop.valueMin[2]; + var b2 = prop.valueMax[2]; + var a1 = prop.valueMin[3] == null ? 1 : prop.valueMin[3]; + var a2 = prop.valueMax[3] == null ? 1 : prop.valueMax[3]; + var clr = [Math.round(r1 + (r2 - r1) * percent), Math.round(g1 + (g2 - g1) * percent), Math.round(b1 + (b2 - b1) * percent), Math.round(a1 + (a2 - a1) * percent)]; + flatProp = { + // colours are simple, so just create the flat property instead of expensive string parsing + bypass: prop.bypass, + // we're a bypass if the mapping property is a bypass + name: prop.name, + value: clr, + strValue: 'rgb(' + clr[0] + ', ' + clr[1] + ', ' + clr[2] + ')' + }; + } else if (type.number) { + var calcValue = prop.valueMin + (prop.valueMax - prop.valueMin) * percent; + flatProp = this.parse(prop.name, calcValue, prop.bypass, flatPropMapping); + } else { + return false; // can only map to colours and numbers + } + + if (!flatProp) { + // if we can't flatten the property, then don't apply the property and fall back on the existing style + printMappingErr(); + return false; + } + flatProp.mapping = prop; // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + + // direct mapping + case types.data: + { + // flatten the field (e.g. data.foo.bar) + var _fields = prop.field.split('.'); + var _fieldVal = _p.data; + for (var _i3 = 0; _i3 < _fields.length && _fieldVal; _i3++) { + var _field = _fields[_i3]; + _fieldVal = _fieldVal[_field]; + } + if (_fieldVal != null) { + flatProp = this.parse(prop.name, _fieldVal, prop.bypass, flatPropMapping); + } + if (!flatProp) { + // if we can't flatten the property, then don't apply and fall back on the existing style + printMappingErr(); + return false; + } + flatProp.mapping = prop; // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + case types.fn: + { + var fn = prop.value; + var fnRetVal = prop.fnValue != null ? prop.fnValue : fn(ele); // check for cached value before calling function + + prop.prevFnValue = fnRetVal; + if (fnRetVal == null) { + warn('Custom function mappers may not return null (i.e. `' + prop.name + '` for ele `' + ele.id() + '` is null)'); + return false; + } + flatProp = this.parse(prop.name, fnRetVal, prop.bypass, flatPropMapping); + if (!flatProp) { + warn('Custom function mappers may not return invalid values for the property type (i.e. `' + prop.name + '` for ele `' + ele.id() + '` is invalid)'); + return false; + } + flatProp.mapping = copy(prop); // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + case undefined: + break; + // just set the property + + default: + return false; + // not a valid mapping + } + + // if the property is a bypass property, then link the resultant property to the original one + if (propIsBypass) { + if (origPropIsBypass) { + // then this bypass overrides the existing one + prop.bypassed = origProp.bypassed; // steal bypassed prop from old bypass + } else { + // then link the orig prop to the new bypass + prop.bypassed = origProp; + } + style[prop.name] = prop; // and set + } else { + // prop is not bypass + if (origPropIsBypass) { + // then keep the orig prop (since it's a bypass) and link to the new prop + origProp.bypassed = prop; + } else { + // then just replace the old prop with the new one + style[prop.name] = prop; + } + } + checkTriggers(); + return true; +}; +styfn$8.cleanElements = function (eles, keepBypasses) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + this.clearStyleHints(ele); + ele.dirtyCompoundBoundsCache(); + ele.dirtyBoundingBoxCache(); + if (!keepBypasses) { + ele._private.style = {}; + } else { + var style = ele._private.style; + var propNames = Object.keys(style); + for (var j = 0; j < propNames.length; j++) { + var propName = propNames[j]; + var eleProp = style[propName]; + if (eleProp != null) { + if (eleProp.bypass) { + eleProp.bypassed = null; + } else { + style[propName] = null; + } + } + } + } + } +}; + +// updates the visual style for all elements (useful for manual style modification after init) +styfn$8.update = function () { + var cy = this._private.cy; + var eles = cy.mutableElements(); + eles.updateStyle(); +}; + +// diffProps : { name => { prev, next } } +styfn$8.updateTransitions = function (ele, diffProps) { + var self = this; + var _p = ele._private; + var props = ele.pstyle('transition-property').value; + var duration = ele.pstyle('transition-duration').pfValue; + var delay = ele.pstyle('transition-delay').pfValue; + if (props.length > 0 && duration > 0) { + var style = {}; + + // build up the style to animate towards + var anyPrev = false; + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + var styProp = ele.pstyle(prop); + var diffProp = diffProps[prop]; + if (!diffProp) { + continue; + } + var prevProp = diffProp.prev; + var fromProp = prevProp; + var toProp = diffProp.next != null ? diffProp.next : styProp; + var diff = false; + var initVal = void 0; + var initDt = 0.000001; // delta time % value for initVal (allows animating out of init zero opacity) + + if (!fromProp) { + continue; + } + + // consider px values + if (number$1(fromProp.pfValue) && number$1(toProp.pfValue)) { + diff = toProp.pfValue - fromProp.pfValue; // nonzero is truthy + initVal = fromProp.pfValue + initDt * diff; + + // consider numerical values + } else if (number$1(fromProp.value) && number$1(toProp.value)) { + diff = toProp.value - fromProp.value; // nonzero is truthy + initVal = fromProp.value + initDt * diff; + + // consider colour values + } else if (array(fromProp.value) && array(toProp.value)) { + diff = fromProp.value[0] !== toProp.value[0] || fromProp.value[1] !== toProp.value[1] || fromProp.value[2] !== toProp.value[2]; + initVal = fromProp.strValue; + } + + // the previous value is good for an animation only if it's different + if (diff) { + style[prop] = toProp.strValue; // to val + this.applyBypass(ele, prop, initVal); // from val + anyPrev = true; + } + } // end if props allow ani + + // can't transition if there's nothing previous to transition from + if (!anyPrev) { + return; + } + _p.transitioning = true; + new Promise$1(function (resolve) { + if (delay > 0) { + ele.delayAnimation(delay).play().promise().then(resolve); + } else { + resolve(); + } + }).then(function () { + return ele.animation({ + style: style, + duration: duration, + easing: ele.pstyle('transition-timing-function').value, + queue: false + }).play().promise(); + }).then(function () { + // if( !isBypass ){ + self.removeBypasses(ele, props); + ele.emitAndNotify('style'); + // } + + _p.transitioning = false; + }); + } else if (_p.transitioning) { + this.removeBypasses(ele, props); + ele.emitAndNotify('style'); + _p.transitioning = false; + } +}; +styfn$8.checkTrigger = function (ele, name, fromValue, toValue, getTrigger, onTrigger) { + var prop = this.properties[name]; + var triggerCheck = getTrigger(prop); + if (triggerCheck != null && triggerCheck(fromValue, toValue)) { + onTrigger(prop); + } +}; +styfn$8.checkZOrderTrigger = function (ele, name, fromValue, toValue) { + var _this = this; + this.checkTrigger(ele, name, fromValue, toValue, function (prop) { + return prop.triggersZOrder; + }, function () { + _this._private.cy.notify('zorder', ele); + }); +}; +styfn$8.checkBoundsTrigger = function (ele, name, fromValue, toValue) { + this.checkTrigger(ele, name, fromValue, toValue, function (prop) { + return prop.triggersBounds; + }, function (prop) { + ele.dirtyCompoundBoundsCache(); + ele.dirtyBoundingBoxCache(); + + // if the prop change makes the bb of pll bezier edges invalid, + // then dirty the pll edge bb cache as well + if ( + // only for beziers -- so performance of other edges isn't affected + prop.triggersBoundsOfParallelBeziers && name === 'curve-style' && (fromValue === 'bezier' || toValue === 'bezier')) { + ele.parallelEdges().forEach(function (pllEdge) { + if (pllEdge.isBundledBezier()) { + pllEdge.dirtyBoundingBoxCache(); + } + }); + } + if (prop.triggersBoundsOfConnectedEdges && name === 'display' && (fromValue === 'none' || toValue === 'none')) { + ele.connectedEdges().forEach(function (edge) { + edge.dirtyBoundingBoxCache(); + }); + } + }); +}; +styfn$8.checkTriggers = function (ele, name, fromValue, toValue) { + ele.dirtyStyleCache(); + this.checkZOrderTrigger(ele, name, fromValue, toValue); + this.checkBoundsTrigger(ele, name, fromValue, toValue); +}; + +var styfn$7 = {}; + +// bypasses are applied to an existing style on an element, and just tacked on temporarily +// returns true iff application was successful for at least 1 specified property +styfn$7.applyBypass = function (eles, name, value, updateTransitions) { + var self = this; + var props = []; + var isBypass = true; + + // put all the properties (can specify one or many) in an array after parsing them + if (name === '*' || name === '**') { + // apply to all property names + + if (value !== undefined) { + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var _name = prop.name; + var parsedProp = this.parse(_name, value, true); + if (parsedProp) { + props.push(parsedProp); + } + } + } + } else if (string(name)) { + // then parse the single property + var _parsedProp = this.parse(name, value, true); + if (_parsedProp) { + props.push(_parsedProp); + } + } else if (plainObject(name)) { + // then parse each property + var specifiedProps = name; + updateTransitions = value; + var names = Object.keys(specifiedProps); + for (var _i = 0; _i < names.length; _i++) { + var _name2 = names[_i]; + var _value = specifiedProps[_name2]; + if (_value === undefined) { + // try camel case name too + _value = specifiedProps[dash2camel(_name2)]; + } + if (_value !== undefined) { + var _parsedProp2 = this.parse(_name2, _value, true); + if (_parsedProp2) { + props.push(_parsedProp2); + } + } + } + } else { + // can't do anything without well defined properties + return false; + } + + // we've failed if there are no valid properties + if (props.length === 0) { + return false; + } + + // now, apply the bypass properties on the elements + var ret = false; // return true if at least one succesful bypass applied + for (var _i2 = 0; _i2 < eles.length; _i2++) { + // for each ele + var ele = eles[_i2]; + var diffProps = {}; + var diffProp = void 0; + for (var j = 0; j < props.length; j++) { + // for each prop + var _prop = props[j]; + if (updateTransitions) { + var prevProp = ele.pstyle(_prop.name); + diffProp = diffProps[_prop.name] = { + prev: prevProp + }; + } + ret = this.applyParsedProperty(ele, copy(_prop)) || ret; + if (updateTransitions) { + diffProp.next = ele.pstyle(_prop.name); + } + } // for props + + if (ret) { + this.updateStyleHints(ele); + } + if (updateTransitions) { + this.updateTransitions(ele, diffProps, isBypass); + } + } // for eles + + return ret; +}; + +// only useful in specific cases like animation +styfn$7.overrideBypass = function (eles, name, value) { + name = camel2dash(name); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var prop = ele._private.style[name]; + var type = this.properties[name].type; + var isColor = type.color; + var isMulti = type.mutiple; + var oldValue = !prop ? null : prop.pfValue != null ? prop.pfValue : prop.value; + if (!prop || !prop.bypass) { + // need a bypass if one doesn't exist + this.applyBypass(ele, name, value); + } else { + prop.value = value; + if (prop.pfValue != null) { + prop.pfValue = value; + } + if (isColor) { + prop.strValue = 'rgb(' + value.join(',') + ')'; + } else if (isMulti) { + prop.strValue = value.join(' '); + } else { + prop.strValue = '' + value; + } + this.updateStyleHints(ele); + } + this.checkTriggers(ele, name, oldValue, value); + } +}; +styfn$7.removeAllBypasses = function (eles, updateTransitions) { + return this.removeBypasses(eles, this.propertyNames, updateTransitions); +}; +styfn$7.removeBypasses = function (eles, props, updateTransitions) { + var isBypass = true; + for (var j = 0; j < eles.length; j++) { + var ele = eles[j]; + var diffProps = {}; + for (var i = 0; i < props.length; i++) { + var name = props[i]; + var prop = this.properties[name]; + var prevProp = ele.pstyle(prop.name); + if (!prevProp || !prevProp.bypass) { + // if a bypass doesn't exist for the prop, nothing needs to be removed + continue; + } + var value = ''; // empty => remove bypass + var parsedProp = this.parse(name, value, true); + var diffProp = diffProps[prop.name] = { + prev: prevProp + }; + this.applyParsedProperty(ele, parsedProp); + diffProp.next = ele.pstyle(prop.name); + } // for props + + this.updateStyleHints(ele); + if (updateTransitions) { + this.updateTransitions(ele, diffProps, isBypass); + } + } // for eles +}; + +var styfn$6 = {}; + +// gets what an em size corresponds to in pixels relative to a dom element +styfn$6.getEmSizeInPixels = function () { + var px = this.containerCss('font-size'); + if (px != null) { + return parseFloat(px); + } else { + return 1; // for headless + } +}; + +// gets css property from the core container +styfn$6.containerCss = function (propName) { + var cy = this._private.cy; + var domElement = cy.container(); + var containerWindow = cy.window(); + if (containerWindow && domElement && containerWindow.getComputedStyle) { + return containerWindow.getComputedStyle(domElement).getPropertyValue(propName); + } +}; + +var styfn$5 = {}; + +// gets the rendered style for an element +styfn$5.getRenderedStyle = function (ele, prop) { + if (prop) { + return this.getStylePropertyValue(ele, prop, true); + } else { + return this.getRawStyle(ele, true); + } +}; + +// gets the raw style for an element +styfn$5.getRawStyle = function (ele, isRenderedVal) { + var self = this; + ele = ele[0]; // insure it's an element + + if (ele) { + var rstyle = {}; + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var val = self.getStylePropertyValue(ele, prop.name, isRenderedVal); + if (val != null) { + rstyle[prop.name] = val; + rstyle[dash2camel(prop.name)] = val; + } + } + return rstyle; + } +}; +styfn$5.getIndexedStyle = function (ele, property, subproperty, index) { + var pstyle = ele.pstyle(property)[subproperty][index]; + return pstyle != null ? pstyle : ele.cy().style().getDefaultProperty(property)[subproperty][0]; +}; +styfn$5.getStylePropertyValue = function (ele, propName, isRenderedVal) { + var self = this; + ele = ele[0]; // insure it's an element + + if (ele) { + var prop = self.properties[propName]; + if (prop.alias) { + prop = prop.pointsTo; + } + var type = prop.type; + var styleProp = ele.pstyle(prop.name); + if (styleProp) { + var value = styleProp.value, + units = styleProp.units, + strValue = styleProp.strValue; + if (isRenderedVal && type.number && value != null && number$1(value)) { + var zoom = ele.cy().zoom(); + var getRenderedValue = function getRenderedValue(val) { + return val * zoom; + }; + var getValueStringWithUnits = function getValueStringWithUnits(val, units) { + return getRenderedValue(val) + units; + }; + var isArrayValue = array(value); + var haveUnits = isArrayValue ? units.every(function (u) { + return u != null; + }) : units != null; + if (haveUnits) { + if (isArrayValue) { + return value.map(function (v, i) { + return getValueStringWithUnits(v, units[i]); + }).join(' '); + } else { + return getValueStringWithUnits(value, units); + } + } else { + if (isArrayValue) { + return value.map(function (v) { + return string(v) ? v : '' + getRenderedValue(v); + }).join(' '); + } else { + return '' + getRenderedValue(value); + } + } + } else if (strValue != null) { + return strValue; + } + } + return null; + } +}; +styfn$5.getAnimationStartStyle = function (ele, aniProps) { + var rstyle = {}; + for (var i = 0; i < aniProps.length; i++) { + var aniProp = aniProps[i]; + var name = aniProp.name; + var styleProp = ele.pstyle(name); + if (styleProp !== undefined) { + // then make a prop of it + if (plainObject(styleProp)) { + styleProp = this.parse(name, styleProp.strValue); + } else { + styleProp = this.parse(name, styleProp); + } + } + if (styleProp) { + rstyle[name] = styleProp; + } + } + return rstyle; +}; +styfn$5.getPropsList = function (propsObj) { + var self = this; + var rstyle = []; + var style = propsObj; + var props = self.properties; + if (style) { + var names = Object.keys(style); + for (var i = 0; i < names.length; i++) { + var name = names[i]; + var val = style[name]; + var prop = props[name] || props[camel2dash(name)]; + var styleProp = this.parse(prop.name, val); + if (styleProp) { + rstyle.push(styleProp); + } + } + } + return rstyle; +}; +styfn$5.getNonDefaultPropertiesHash = function (ele, propNames, seed) { + var hash = seed.slice(); + var name, val, strVal, chVal; + var i, j; + for (i = 0; i < propNames.length; i++) { + name = propNames[i]; + val = ele.pstyle(name, false); + if (val == null) { + continue; + } else if (val.pfValue != null) { + hash[0] = hashInt(chVal, hash[0]); + hash[1] = hashIntAlt(chVal, hash[1]); + } else { + strVal = val.strValue; + for (j = 0; j < strVal.length; j++) { + chVal = strVal.charCodeAt(j); + hash[0] = hashInt(chVal, hash[0]); + hash[1] = hashIntAlt(chVal, hash[1]); + } + } + } + return hash; +}; +styfn$5.getPropertiesHash = styfn$5.getNonDefaultPropertiesHash; + +var styfn$4 = {}; +styfn$4.appendFromJson = function (json) { + var style = this; + for (var i = 0; i < json.length; i++) { + var context = json[i]; + var selector = context.selector; + var props = context.style || context.css; + var names = Object.keys(props); + style.selector(selector); // apply selector + + for (var j = 0; j < names.length; j++) { + var name = names[j]; + var value = props[name]; + style.css(name, value); // apply property + } + } + + return style; +}; + +// accessible cy.style() function +styfn$4.fromJson = function (json) { + var style = this; + style.resetToDefault(); + style.appendFromJson(json); + return style; +}; + +// get json from cy.style() api +styfn$4.json = function () { + var json = []; + for (var i = this.defaultLength; i < this.length; i++) { + var cxt = this[i]; + var selector = cxt.selector; + var props = cxt.properties; + var css = {}; + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + css[prop.name] = prop.strValue; + } + json.push({ + selector: !selector ? 'core' : selector.toString(), + style: css + }); + } + return json; +}; + +var styfn$3 = {}; +styfn$3.appendFromString = function (string) { + var self = this; + var style = this; + var remaining = '' + string; + var selAndBlockStr; + var blockRem; + var propAndValStr; + + // remove comments from the style string + remaining = remaining.replace(/[/][*](\s|.)+?[*][/]/g, ''); + function removeSelAndBlockFromRemaining() { + // remove the parsed selector and block from the remaining text to parse + if (remaining.length > selAndBlockStr.length) { + remaining = remaining.substr(selAndBlockStr.length); + } else { + remaining = ''; + } + } + function removePropAndValFromRem() { + // remove the parsed property and value from the remaining block text to parse + if (blockRem.length > propAndValStr.length) { + blockRem = blockRem.substr(propAndValStr.length); + } else { + blockRem = ''; + } + } + for (;;) { + var nothingLeftToParse = remaining.match(/^\s*$/); + if (nothingLeftToParse) { + break; + } + var selAndBlock = remaining.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/); + if (!selAndBlock) { + warn('Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: ' + remaining); + break; + } + selAndBlockStr = selAndBlock[0]; + + // parse the selector + var selectorStr = selAndBlock[1]; + if (selectorStr !== 'core') { + var selector = new Selector(selectorStr); + if (selector.invalid) { + warn('Skipping parsing of block: Invalid selector found in string stylesheet: ' + selectorStr); + + // skip this selector and block + removeSelAndBlockFromRemaining(); + continue; + } + } + + // parse the block of properties and values + var blockStr = selAndBlock[2]; + var invalidBlock = false; + blockRem = blockStr; + var props = []; + for (;;) { + var _nothingLeftToParse = blockRem.match(/^\s*$/); + if (_nothingLeftToParse) { + break; + } + var propAndVal = blockRem.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/); + if (!propAndVal) { + warn('Skipping parsing of block: Invalid formatting of style property and value definitions found in:' + blockStr); + invalidBlock = true; + break; + } + propAndValStr = propAndVal[0]; + var propStr = propAndVal[1]; + var valStr = propAndVal[2]; + var prop = self.properties[propStr]; + if (!prop) { + warn('Skipping property: Invalid property name in: ' + propAndValStr); + + // skip this property in the block + removePropAndValFromRem(); + continue; + } + var parsedProp = style.parse(propStr, valStr); + if (!parsedProp) { + warn('Skipping property: Invalid property definition in: ' + propAndValStr); + + // skip this property in the block + removePropAndValFromRem(); + continue; + } + props.push({ + name: propStr, + val: valStr + }); + removePropAndValFromRem(); + } + if (invalidBlock) { + removeSelAndBlockFromRemaining(); + break; + } + + // put the parsed block in the style + style.selector(selectorStr); + for (var i = 0; i < props.length; i++) { + var _prop = props[i]; + style.css(_prop.name, _prop.val); + } + removeSelAndBlockFromRemaining(); + } + return style; +}; +styfn$3.fromString = function (string) { + var style = this; + style.resetToDefault(); + style.appendFromString(string); + return style; +}; + +var styfn$2 = {}; +(function () { + var number$1 = number; + var rgba = rgbaNoBackRefs; + var hsla = hslaNoBackRefs; + var hex3$1 = hex3; + var hex6$1 = hex6; + var data = function data(prefix) { + return '^' + prefix + '\\s*\\(\\s*([\\w\\.]+)\\s*\\)$'; + }; + var mapData = function mapData(prefix) { + var mapArg = number$1 + '|\\w+|' + rgba + '|' + hsla + '|' + hex3$1 + '|' + hex6$1; + return '^' + prefix + '\\s*\\(([\\w\\.]+)\\s*\\,\\s*(' + number$1 + ')\\s*\\,\\s*(' + number$1 + ')\\s*,\\s*(' + mapArg + ')\\s*\\,\\s*(' + mapArg + ')\\)$'; + }; + var urlRegexes = ['^url\\s*\\(\\s*[\'"]?(.+?)[\'"]?\\s*\\)$', '^(none)$', '^(.+)$']; + + // each visual style property has a type and needs to be validated according to it + styfn$2.types = { + time: { + number: true, + min: 0, + units: 's|ms', + implicitUnits: 'ms' + }, + percent: { + number: true, + min: 0, + max: 100, + units: '%', + implicitUnits: '%' + }, + percentages: { + number: true, + min: 0, + max: 100, + units: '%', + implicitUnits: '%', + multiple: true + }, + zeroOneNumber: { + number: true, + min: 0, + max: 1, + unitless: true + }, + zeroOneNumbers: { + number: true, + min: 0, + max: 1, + unitless: true, + multiple: true + }, + nOneOneNumber: { + number: true, + min: -1, + max: 1, + unitless: true + }, + nonNegativeInt: { + number: true, + min: 0, + integer: true, + unitless: true + }, + nonNegativeNumber: { + number: true, + min: 0, + unitless: true + }, + position: { + enums: ['parent', 'origin'] + }, + nodeSize: { + number: true, + min: 0, + enums: ['label'] + }, + number: { + number: true, + unitless: true + }, + numbers: { + number: true, + unitless: true, + multiple: true + }, + positiveNumber: { + number: true, + unitless: true, + min: 0, + strictMin: true + }, + size: { + number: true, + min: 0 + }, + bidirectionalSize: { + number: true + }, + // allows negative + bidirectionalSizeMaybePercent: { + number: true, + allowPercent: true + }, + // allows negative + bidirectionalSizes: { + number: true, + multiple: true + }, + // allows negative + sizeMaybePercent: { + number: true, + min: 0, + allowPercent: true + }, + axisDirection: { + enums: ['horizontal', 'leftward', 'rightward', 'vertical', 'upward', 'downward', 'auto'] + }, + paddingRelativeTo: { + enums: ['width', 'height', 'average', 'min', 'max'] + }, + bgWH: { + number: true, + min: 0, + allowPercent: true, + enums: ['auto'], + multiple: true + }, + bgPos: { + number: true, + allowPercent: true, + multiple: true + }, + bgRelativeTo: { + enums: ['inner', 'include-padding'], + multiple: true + }, + bgRepeat: { + enums: ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'], + multiple: true + }, + bgFit: { + enums: ['none', 'contain', 'cover'], + multiple: true + }, + bgCrossOrigin: { + enums: ['anonymous', 'use-credentials', 'null'], + multiple: true + }, + bgClip: { + enums: ['none', 'node'], + multiple: true + }, + bgContainment: { + enums: ['inside', 'over'], + multiple: true + }, + color: { + color: true + }, + colors: { + color: true, + multiple: true + }, + fill: { + enums: ['solid', 'linear-gradient', 'radial-gradient'] + }, + bool: { + enums: ['yes', 'no'] + }, + bools: { + enums: ['yes', 'no'], + multiple: true + }, + lineStyle: { + enums: ['solid', 'dotted', 'dashed'] + }, + lineCap: { + enums: ['butt', 'round', 'square'] + }, + linePosition: { + enums: ['center', 'inside', 'outside'] + }, + lineJoin: { + enums: ['round', 'bevel', 'miter'] + }, + borderStyle: { + enums: ['solid', 'dotted', 'dashed', 'double'] + }, + curveStyle: { + enums: ['bezier', 'unbundled-bezier', 'haystack', 'segments', 'straight', 'straight-triangle', 'taxi', 'round-segments', 'round-taxi'] + }, + radiusType: { + enums: ['arc-radius', 'influence-radius'], + multiple: true + }, + fontFamily: { + regex: '^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$' + }, + fontStyle: { + enums: ['italic', 'normal', 'oblique'] + }, + fontWeight: { + enums: ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '800', '900', 100, 200, 300, 400, 500, 600, 700, 800, 900] + }, + textDecoration: { + enums: ['none', 'underline', 'overline', 'line-through'] + }, + textTransform: { + enums: ['none', 'uppercase', 'lowercase'] + }, + textWrap: { + enums: ['none', 'wrap', 'ellipsis'] + }, + textOverflowWrap: { + enums: ['whitespace', 'anywhere'] + }, + textBackgroundShape: { + enums: ['rectangle', 'roundrectangle', 'round-rectangle'] + }, + nodeShape: { + enums: ['rectangle', 'roundrectangle', 'round-rectangle', 'cutrectangle', 'cut-rectangle', 'bottomroundrectangle', 'bottom-round-rectangle', 'barrel', 'ellipse', 'triangle', 'round-triangle', 'square', 'pentagon', 'round-pentagon', 'hexagon', 'round-hexagon', 'concavehexagon', 'concave-hexagon', 'heptagon', 'round-heptagon', 'octagon', 'round-octagon', 'tag', 'round-tag', 'star', 'diamond', 'round-diamond', 'vee', 'rhomboid', 'right-rhomboid', 'polygon'] + }, + overlayShape: { + enums: ['roundrectangle', 'round-rectangle', 'ellipse'] + }, + cornerRadius: { + number: true, + min: 0, + units: 'px|em', + implicitUnits: 'px', + enums: ['auto'] + }, + compoundIncludeLabels: { + enums: ['include', 'exclude'] + }, + arrowShape: { + enums: ['tee', 'triangle', 'triangle-tee', 'circle-triangle', 'triangle-cross', 'triangle-backcurve', 'vee', 'square', 'circle', 'diamond', 'chevron', 'none'] + }, + arrowFill: { + enums: ['filled', 'hollow'] + }, + arrowWidth: { + number: true, + units: '%|px|em', + implicitUnits: 'px', + enums: ['match-line'] + }, + display: { + enums: ['element', 'none'] + }, + visibility: { + enums: ['hidden', 'visible'] + }, + zCompoundDepth: { + enums: ['bottom', 'orphan', 'auto', 'top'] + }, + zIndexCompare: { + enums: ['auto', 'manual'] + }, + valign: { + enums: ['top', 'center', 'bottom'] + }, + halign: { + enums: ['left', 'center', 'right'] + }, + justification: { + enums: ['left', 'center', 'right', 'auto'] + }, + text: { + string: true + }, + data: { + mapping: true, + regex: data('data') + }, + layoutData: { + mapping: true, + regex: data('layoutData') + }, + scratch: { + mapping: true, + regex: data('scratch') + }, + mapData: { + mapping: true, + regex: mapData('mapData') + }, + mapLayoutData: { + mapping: true, + regex: mapData('mapLayoutData') + }, + mapScratch: { + mapping: true, + regex: mapData('mapScratch') + }, + fn: { + mapping: true, + fn: true + }, + url: { + regexes: urlRegexes, + singleRegexMatchValue: true + }, + urls: { + regexes: urlRegexes, + singleRegexMatchValue: true, + multiple: true + }, + propList: { + propList: true + }, + angle: { + number: true, + units: 'deg|rad', + implicitUnits: 'rad' + }, + textRotation: { + number: true, + units: 'deg|rad', + implicitUnits: 'rad', + enums: ['none', 'autorotate'] + }, + polygonPointList: { + number: true, + multiple: true, + evenMultiple: true, + min: -1, + max: 1, + unitless: true + }, + edgeDistances: { + enums: ['intersection', 'node-position', 'endpoints'] + }, + edgeEndpoint: { + number: true, + multiple: true, + units: '%|px|em|deg|rad', + implicitUnits: 'px', + enums: ['inside-to-node', 'outside-to-node', 'outside-to-node-or-label', 'outside-to-line', 'outside-to-line-or-label'], + singleEnum: true, + validate: function validate(valArr, unitsArr) { + switch (valArr.length) { + case 2: + // can be % or px only + return unitsArr[0] !== 'deg' && unitsArr[0] !== 'rad' && unitsArr[1] !== 'deg' && unitsArr[1] !== 'rad'; + case 1: + // can be enum, deg, or rad only + return string(valArr[0]) || unitsArr[0] === 'deg' || unitsArr[0] === 'rad'; + default: + return false; + } + } + }, + easing: { + regexes: ['^(spring)\\s*\\(\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*\\)$', '^(cubic-bezier)\\s*\\(\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*\\)$'], + enums: ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'ease-in-sine', 'ease-out-sine', 'ease-in-out-sine', 'ease-in-quad', 'ease-out-quad', 'ease-in-out-quad', 'ease-in-cubic', 'ease-out-cubic', 'ease-in-out-cubic', 'ease-in-quart', 'ease-out-quart', 'ease-in-out-quart', 'ease-in-quint', 'ease-out-quint', 'ease-in-out-quint', 'ease-in-expo', 'ease-out-expo', 'ease-in-out-expo', 'ease-in-circ', 'ease-out-circ', 'ease-in-out-circ'] + }, + gradientDirection: { + enums: ['to-bottom', 'to-top', 'to-left', 'to-right', 'to-bottom-right', 'to-bottom-left', 'to-top-right', 'to-top-left', 'to-right-bottom', 'to-left-bottom', 'to-right-top', 'to-left-top' // different order + ] + }, + + boundsExpansion: { + number: true, + multiple: true, + min: 0, + validate: function validate(valArr) { + var length = valArr.length; + return length === 1 || length === 2 || length === 4; + } + } + }; + var diff = { + zeroNonZero: function zeroNonZero(val1, val2) { + if ((val1 == null || val2 == null) && val1 !== val2) { + return true; // null cases could represent any value + } + if (val1 == 0 && val2 != 0) { + return true; + } else if (val1 != 0 && val2 == 0) { + return true; + } else { + return false; + } + }, + any: function any(val1, val2) { + return val1 != val2; + }, + emptyNonEmpty: function emptyNonEmpty(str1, str2) { + var empty1 = emptyString(str1); + var empty2 = emptyString(str2); + return empty1 && !empty2 || !empty1 && empty2; + } + }; + + // define visual style properties + // + // - n.b. adding a new group of props may require updates to updateStyleHints() + // - adding new props to an existing group gets handled automatically + + var t = styfn$2.types; + var mainLabel = [{ + name: 'label', + type: t.text, + triggersBounds: diff.any, + triggersZOrder: diff.emptyNonEmpty + }, { + name: 'text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }]; + var sourceLabel = [{ + name: 'source-label', + type: t.text, + triggersBounds: diff.any + }, { + name: 'source-text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'source-text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'source-text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'source-text-offset', + type: t.size, + triggersBounds: diff.any + }]; + var targetLabel = [{ + name: 'target-label', + type: t.text, + triggersBounds: diff.any + }, { + name: 'target-text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'target-text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'target-text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'target-text-offset', + type: t.size, + triggersBounds: diff.any + }]; + var labelDimensions = [{ + name: 'font-family', + type: t.fontFamily, + triggersBounds: diff.any + }, { + name: 'font-style', + type: t.fontStyle, + triggersBounds: diff.any + }, { + name: 'font-weight', + type: t.fontWeight, + triggersBounds: diff.any + }, { + name: 'font-size', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-transform', + type: t.textTransform, + triggersBounds: diff.any + }, { + name: 'text-wrap', + type: t.textWrap, + triggersBounds: diff.any + }, { + name: 'text-overflow-wrap', + type: t.textOverflowWrap, + triggersBounds: diff.any + }, { + name: 'text-max-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-outline-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'line-height', + type: t.positiveNumber, + triggersBounds: diff.any + }]; + var commonLabel = [{ + name: 'text-valign', + type: t.valign, + triggersBounds: diff.any + }, { + name: 'text-halign', + type: t.halign, + triggersBounds: diff.any + }, { + name: 'color', + type: t.color + }, { + name: 'text-outline-color', + type: t.color + }, { + name: 'text-outline-opacity', + type: t.zeroOneNumber + }, { + name: 'text-background-color', + type: t.color + }, { + name: 'text-background-opacity', + type: t.zeroOneNumber + }, { + name: 'text-background-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-border-opacity', + type: t.zeroOneNumber + }, { + name: 'text-border-color', + type: t.color + }, { + name: 'text-border-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-border-style', + type: t.borderStyle, + triggersBounds: diff.any + }, { + name: 'text-background-shape', + type: t.textBackgroundShape, + triggersBounds: diff.any + }, { + name: 'text-justification', + type: t.justification + }]; + var behavior = [{ + name: 'events', + type: t.bool, + triggersZOrder: diff.any + }, { + name: 'text-events', + type: t.bool, + triggersZOrder: diff.any + }]; + var visibility = [{ + name: 'display', + type: t.display, + triggersZOrder: diff.any, + triggersBounds: diff.any, + triggersBoundsOfConnectedEdges: true + }, { + name: 'visibility', + type: t.visibility, + triggersZOrder: diff.any + }, { + name: 'opacity', + type: t.zeroOneNumber, + triggersZOrder: diff.zeroNonZero + }, { + name: 'text-opacity', + type: t.zeroOneNumber + }, { + name: 'min-zoomed-font-size', + type: t.size + }, { + name: 'z-compound-depth', + type: t.zCompoundDepth, + triggersZOrder: diff.any + }, { + name: 'z-index-compare', + type: t.zIndexCompare, + triggersZOrder: diff.any + }, { + name: 'z-index', + type: t.number, + triggersZOrder: diff.any + }]; + var overlay = [{ + name: 'overlay-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'overlay-color', + type: t.color + }, { + name: 'overlay-opacity', + type: t.zeroOneNumber, + triggersBounds: diff.zeroNonZero + }, { + name: 'overlay-shape', + type: t.overlayShape, + triggersBounds: diff.any + }, { + name: 'overlay-corner-radius', + type: t.cornerRadius + }]; + var underlay = [{ + name: 'underlay-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'underlay-color', + type: t.color + }, { + name: 'underlay-opacity', + type: t.zeroOneNumber, + triggersBounds: diff.zeroNonZero + }, { + name: 'underlay-shape', + type: t.overlayShape, + triggersBounds: diff.any + }, { + name: 'underlay-corner-radius', + type: t.cornerRadius + }]; + var transition = [{ + name: 'transition-property', + type: t.propList + }, { + name: 'transition-duration', + type: t.time + }, { + name: 'transition-delay', + type: t.time + }, { + name: 'transition-timing-function', + type: t.easing + }]; + var nodeSizeHashOverride = function nodeSizeHashOverride(ele, parsedProp) { + if (parsedProp.value === 'label') { + return -ele.poolIndex(); // no hash key hits is using label size (hitrate for perf probably low anyway) + } else { + return parsedProp.pfValue; + } + }; + var nodeBody = [{ + name: 'height', + type: t.nodeSize, + triggersBounds: diff.any, + hashOverride: nodeSizeHashOverride + }, { + name: 'width', + type: t.nodeSize, + triggersBounds: diff.any, + hashOverride: nodeSizeHashOverride + }, { + name: 'shape', + type: t.nodeShape, + triggersBounds: diff.any + }, { + name: 'shape-polygon-points', + type: t.polygonPointList, + triggersBounds: diff.any + }, { + name: 'corner-radius', + type: t.cornerRadius + }, { + name: 'background-color', + type: t.color + }, { + name: 'background-fill', + type: t.fill + }, { + name: 'background-opacity', + type: t.zeroOneNumber + }, { + name: 'background-blacken', + type: t.nOneOneNumber + }, { + name: 'background-gradient-stop-colors', + type: t.colors + }, { + name: 'background-gradient-stop-positions', + type: t.percentages + }, { + name: 'background-gradient-direction', + type: t.gradientDirection + }, { + name: 'padding', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'padding-relative-to', + type: t.paddingRelativeTo, + triggersBounds: diff.any + }, { + name: 'bounds-expansion', + type: t.boundsExpansion, + triggersBounds: diff.any + }]; + var nodeBorder = [{ + name: 'border-color', + type: t.color + }, { + name: 'border-opacity', + type: t.zeroOneNumber + }, { + name: 'border-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'border-style', + type: t.borderStyle + }, { + name: 'border-cap', + type: t.lineCap + }, { + name: 'border-join', + type: t.lineJoin + }, { + name: 'border-dash-pattern', + type: t.numbers + }, { + name: 'border-dash-offset', + type: t.number + }, { + name: 'border-position', + type: t.linePosition + }]; + var nodeOutline = [{ + name: 'outline-color', + type: t.color + }, { + name: 'outline-opacity', + type: t.zeroOneNumber + }, { + name: 'outline-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'outline-style', + type: t.borderStyle + }, { + name: 'outline-offset', + type: t.size, + triggersBounds: diff.any + }]; + var backgroundImage = [{ + name: 'background-image', + type: t.urls + }, { + name: 'background-image-crossorigin', + type: t.bgCrossOrigin + }, { + name: 'background-image-opacity', + type: t.zeroOneNumbers + }, { + name: 'background-image-containment', + type: t.bgContainment + }, { + name: 'background-image-smoothing', + type: t.bools + }, { + name: 'background-position-x', + type: t.bgPos + }, { + name: 'background-position-y', + type: t.bgPos + }, { + name: 'background-width-relative-to', + type: t.bgRelativeTo + }, { + name: 'background-height-relative-to', + type: t.bgRelativeTo + }, { + name: 'background-repeat', + type: t.bgRepeat + }, { + name: 'background-fit', + type: t.bgFit + }, { + name: 'background-clip', + type: t.bgClip + }, { + name: 'background-width', + type: t.bgWH + }, { + name: 'background-height', + type: t.bgWH + }, { + name: 'background-offset-x', + type: t.bgPos + }, { + name: 'background-offset-y', + type: t.bgPos + }]; + var compound = [{ + name: 'position', + type: t.position, + triggersBounds: diff.any + }, { + name: 'compound-sizing-wrt-labels', + type: t.compoundIncludeLabels, + triggersBounds: diff.any + }, { + name: 'min-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'min-width-bias-left', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-width-bias-right', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-height', + type: t.size, + triggersBounds: diff.any + }, { + name: 'min-height-bias-top', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-height-bias-bottom', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }]; + var edgeLine = [{ + name: 'line-style', + type: t.lineStyle + }, { + name: 'line-color', + type: t.color + }, { + name: 'line-fill', + type: t.fill + }, { + name: 'line-cap', + type: t.lineCap + }, { + name: 'line-opacity', + type: t.zeroOneNumber + }, { + name: 'line-dash-pattern', + type: t.numbers + }, { + name: 'line-dash-offset', + type: t.number + }, { + name: 'line-gradient-stop-colors', + type: t.colors + }, { + name: 'line-gradient-stop-positions', + type: t.percentages + }, { + name: 'curve-style', + type: t.curveStyle, + triggersBounds: diff.any, + triggersBoundsOfParallelBeziers: true + }, { + name: 'haystack-radius', + type: t.zeroOneNumber, + triggersBounds: diff.any + }, { + name: 'source-endpoint', + type: t.edgeEndpoint, + triggersBounds: diff.any + }, { + name: 'target-endpoint', + type: t.edgeEndpoint, + triggersBounds: diff.any + }, { + name: 'control-point-step-size', + type: t.size, + triggersBounds: diff.any + }, { + name: 'control-point-distances', + type: t.bidirectionalSizes, + triggersBounds: diff.any + }, { + name: 'control-point-weights', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'segment-distances', + type: t.bidirectionalSizes, + triggersBounds: diff.any + }, { + name: 'segment-weights', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'segment-radii', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'radius-type', + type: t.radiusType, + triggersBounds: diff.any + }, { + name: 'taxi-turn', + type: t.bidirectionalSizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'taxi-turn-min-distance', + type: t.size, + triggersBounds: diff.any + }, { + name: 'taxi-direction', + type: t.axisDirection, + triggersBounds: diff.any + }, { + name: 'taxi-radius', + type: t.number, + triggersBounds: diff.any + }, { + name: 'edge-distances', + type: t.edgeDistances, + triggersBounds: diff.any + }, { + name: 'arrow-scale', + type: t.positiveNumber, + triggersBounds: diff.any + }, { + name: 'loop-direction', + type: t.angle, + triggersBounds: diff.any + }, { + name: 'loop-sweep', + type: t.angle, + triggersBounds: diff.any + }, { + name: 'source-distance-from-node', + type: t.size, + triggersBounds: diff.any + }, { + name: 'target-distance-from-node', + type: t.size, + triggersBounds: diff.any + }]; + var ghost = [{ + name: 'ghost', + type: t.bool, + triggersBounds: diff.any + }, { + name: 'ghost-offset-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'ghost-offset-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'ghost-opacity', + type: t.zeroOneNumber + }]; + var core = [{ + name: 'selection-box-color', + type: t.color + }, { + name: 'selection-box-opacity', + type: t.zeroOneNumber + }, { + name: 'selection-box-border-color', + type: t.color + }, { + name: 'selection-box-border-width', + type: t.size + }, { + name: 'active-bg-color', + type: t.color + }, { + name: 'active-bg-opacity', + type: t.zeroOneNumber + }, { + name: 'active-bg-size', + type: t.size + }, { + name: 'outside-texture-bg-color', + type: t.color + }, { + name: 'outside-texture-bg-opacity', + type: t.zeroOneNumber + }]; + + // pie backgrounds for nodes + var pie = []; + styfn$2.pieBackgroundN = 16; // because the pie properties are numbered, give access to a constant N (for renderer use) + pie.push({ + name: 'pie-size', + type: t.sizeMaybePercent + }); + for (var i = 1; i <= styfn$2.pieBackgroundN; i++) { + pie.push({ + name: 'pie-' + i + '-background-color', + type: t.color + }); + pie.push({ + name: 'pie-' + i + '-background-size', + type: t.percent + }); + pie.push({ + name: 'pie-' + i + '-background-opacity', + type: t.zeroOneNumber + }); + } + + // edge arrows + var edgeArrow = []; + var arrowPrefixes = styfn$2.arrowPrefixes = ['source', 'mid-source', 'target', 'mid-target']; + [{ + name: 'arrow-shape', + type: t.arrowShape, + triggersBounds: diff.any + }, { + name: 'arrow-color', + type: t.color + }, { + name: 'arrow-fill', + type: t.arrowFill + }, { + name: 'arrow-width', + type: t.arrowWidth + }].forEach(function (prop) { + arrowPrefixes.forEach(function (prefix) { + var name = prefix + '-' + prop.name; + var type = prop.type, + triggersBounds = prop.triggersBounds; + edgeArrow.push({ + name: name, + type: type, + triggersBounds: triggersBounds + }); + }); + }, {}); + var props = styfn$2.properties = [].concat(behavior, transition, visibility, overlay, underlay, ghost, commonLabel, labelDimensions, mainLabel, sourceLabel, targetLabel, nodeBody, nodeBorder, nodeOutline, backgroundImage, pie, compound, edgeLine, edgeArrow, core); + var propGroups = styfn$2.propertyGroups = { + // common to all eles + behavior: behavior, + transition: transition, + visibility: visibility, + overlay: overlay, + underlay: underlay, + ghost: ghost, + // labels + commonLabel: commonLabel, + labelDimensions: labelDimensions, + mainLabel: mainLabel, + sourceLabel: sourceLabel, + targetLabel: targetLabel, + // node props + nodeBody: nodeBody, + nodeBorder: nodeBorder, + nodeOutline: nodeOutline, + backgroundImage: backgroundImage, + pie: pie, + compound: compound, + // edge props + edgeLine: edgeLine, + edgeArrow: edgeArrow, + core: core + }; + var propGroupNames = styfn$2.propertyGroupNames = {}; + var propGroupKeys = styfn$2.propertyGroupKeys = Object.keys(propGroups); + propGroupKeys.forEach(function (key) { + propGroupNames[key] = propGroups[key].map(function (prop) { + return prop.name; + }); + propGroups[key].forEach(function (prop) { + return prop.groupKey = key; + }); + }); + + // define aliases + var aliases = styfn$2.aliases = [{ + name: 'content', + pointsTo: 'label' + }, { + name: 'control-point-distance', + pointsTo: 'control-point-distances' + }, { + name: 'control-point-weight', + pointsTo: 'control-point-weights' + }, { + name: 'segment-distance', + pointsTo: 'segment-distances' + }, { + name: 'segment-weight', + pointsTo: 'segment-weights' + }, { + name: 'segment-radius', + pointsTo: 'segment-radii' + }, { + name: 'edge-text-rotation', + pointsTo: 'text-rotation' + }, { + name: 'padding-left', + pointsTo: 'padding' + }, { + name: 'padding-right', + pointsTo: 'padding' + }, { + name: 'padding-top', + pointsTo: 'padding' + }, { + name: 'padding-bottom', + pointsTo: 'padding' + }]; + + // list of property names + styfn$2.propertyNames = props.map(function (p) { + return p.name; + }); + + // allow access of properties by name ( e.g. style.properties.height ) + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + props[prop.name] = prop; // allow lookup by name + } + + // map aliases + for (var _i2 = 0; _i2 < aliases.length; _i2++) { + var alias = aliases[_i2]; + var pointsToProp = props[alias.pointsTo]; + var aliasProp = { + name: alias.name, + alias: true, + pointsTo: pointsToProp + }; + + // add alias prop for parsing + props.push(aliasProp); + props[alias.name] = aliasProp; // allow lookup by name + } +})(); + +styfn$2.getDefaultProperty = function (name) { + return this.getDefaultProperties()[name]; +}; +styfn$2.getDefaultProperties = function () { + var _p = this._private; + if (_p.defaultProperties != null) { + return _p.defaultProperties; + } + var rawProps = extend({ + // core props + 'selection-box-color': '#ddd', + 'selection-box-opacity': 0.65, + 'selection-box-border-color': '#aaa', + 'selection-box-border-width': 1, + 'active-bg-color': 'black', + 'active-bg-opacity': 0.15, + 'active-bg-size': 30, + 'outside-texture-bg-color': '#000', + 'outside-texture-bg-opacity': 0.125, + // common node/edge props + 'events': 'yes', + 'text-events': 'no', + 'text-valign': 'top', + 'text-halign': 'center', + 'text-justification': 'auto', + 'line-height': 1, + 'color': '#000', + 'text-outline-color': '#000', + 'text-outline-width': 0, + 'text-outline-opacity': 1, + 'text-opacity': 1, + 'text-decoration': 'none', + 'text-transform': 'none', + 'text-wrap': 'none', + 'text-overflow-wrap': 'whitespace', + 'text-max-width': 9999, + 'text-background-color': '#000', + 'text-background-opacity': 0, + 'text-background-shape': 'rectangle', + 'text-background-padding': 0, + 'text-border-opacity': 0, + 'text-border-width': 0, + 'text-border-style': 'solid', + 'text-border-color': '#000', + 'font-family': 'Helvetica Neue, Helvetica, sans-serif', + 'font-style': 'normal', + 'font-weight': 'normal', + 'font-size': 16, + 'min-zoomed-font-size': 0, + 'text-rotation': 'none', + 'source-text-rotation': 'none', + 'target-text-rotation': 'none', + 'visibility': 'visible', + 'display': 'element', + 'opacity': 1, + 'z-compound-depth': 'auto', + 'z-index-compare': 'auto', + 'z-index': 0, + 'label': '', + 'text-margin-x': 0, + 'text-margin-y': 0, + 'source-label': '', + 'source-text-offset': 0, + 'source-text-margin-x': 0, + 'source-text-margin-y': 0, + 'target-label': '', + 'target-text-offset': 0, + 'target-text-margin-x': 0, + 'target-text-margin-y': 0, + 'overlay-opacity': 0, + 'overlay-color': '#000', + 'overlay-padding': 10, + 'overlay-shape': 'round-rectangle', + 'overlay-corner-radius': 'auto', + 'underlay-opacity': 0, + 'underlay-color': '#000', + 'underlay-padding': 10, + 'underlay-shape': 'round-rectangle', + 'underlay-corner-radius': 'auto', + 'transition-property': 'none', + 'transition-duration': 0, + 'transition-delay': 0, + 'transition-timing-function': 'linear', + // node props + 'background-blacken': 0, + 'background-color': '#999', + 'background-fill': 'solid', + 'background-opacity': 1, + 'background-image': 'none', + 'background-image-crossorigin': 'anonymous', + 'background-image-opacity': 1, + 'background-image-containment': 'inside', + 'background-image-smoothing': 'yes', + 'background-position-x': '50%', + 'background-position-y': '50%', + 'background-offset-x': 0, + 'background-offset-y': 0, + 'background-width-relative-to': 'include-padding', + 'background-height-relative-to': 'include-padding', + 'background-repeat': 'no-repeat', + 'background-fit': 'none', + 'background-clip': 'node', + 'background-width': 'auto', + 'background-height': 'auto', + 'border-color': '#000', + 'border-opacity': 1, + 'border-width': 0, + 'border-style': 'solid', + 'border-dash-pattern': [4, 2], + 'border-dash-offset': 0, + 'border-cap': 'butt', + 'border-join': 'miter', + 'border-position': 'center', + 'outline-color': '#999', + 'outline-opacity': 1, + 'outline-width': 0, + 'outline-offset': 0, + 'outline-style': 'solid', + 'height': 30, + 'width': 30, + 'shape': 'ellipse', + 'shape-polygon-points': '-1, -1, 1, -1, 1, 1, -1, 1', + 'corner-radius': 'auto', + 'bounds-expansion': 0, + // node gradient + 'background-gradient-direction': 'to-bottom', + 'background-gradient-stop-colors': '#999', + 'background-gradient-stop-positions': '0%', + // ghost props + 'ghost': 'no', + 'ghost-offset-y': 0, + 'ghost-offset-x': 0, + 'ghost-opacity': 0, + // compound props + 'padding': 0, + 'padding-relative-to': 'width', + 'position': 'origin', + 'compound-sizing-wrt-labels': 'include', + 'min-width': 0, + 'min-width-bias-left': 0, + 'min-width-bias-right': 0, + 'min-height': 0, + 'min-height-bias-top': 0, + 'min-height-bias-bottom': 0 + }, { + // node pie bg + 'pie-size': '100%' + }, [{ + name: 'pie-{{i}}-background-color', + value: 'black' + }, { + name: 'pie-{{i}}-background-size', + value: '0%' + }, { + name: 'pie-{{i}}-background-opacity', + value: 1 + }].reduce(function (css, prop) { + for (var i = 1; i <= styfn$2.pieBackgroundN; i++) { + var name = prop.name.replace('{{i}}', i); + var val = prop.value; + css[name] = val; + } + return css; + }, {}), { + // edge props + 'line-style': 'solid', + 'line-color': '#999', + 'line-fill': 'solid', + 'line-cap': 'butt', + 'line-opacity': 1, + 'line-gradient-stop-colors': '#999', + 'line-gradient-stop-positions': '0%', + 'control-point-step-size': 40, + 'control-point-weights': 0.5, + 'segment-weights': 0.5, + 'segment-distances': 20, + 'segment-radii': 15, + 'radius-type': 'arc-radius', + 'taxi-turn': '50%', + 'taxi-radius': 15, + 'taxi-turn-min-distance': 10, + 'taxi-direction': 'auto', + 'edge-distances': 'intersection', + 'curve-style': 'haystack', + 'haystack-radius': 0, + 'arrow-scale': 1, + 'loop-direction': '-45deg', + 'loop-sweep': '-90deg', + 'source-distance-from-node': 0, + 'target-distance-from-node': 0, + 'source-endpoint': 'outside-to-node', + 'target-endpoint': 'outside-to-node', + 'line-dash-pattern': [6, 3], + 'line-dash-offset': 0 + }, [{ + name: 'arrow-shape', + value: 'none' + }, { + name: 'arrow-color', + value: '#999' + }, { + name: 'arrow-fill', + value: 'filled' + }, { + name: 'arrow-width', + value: 1 + }].reduce(function (css, prop) { + styfn$2.arrowPrefixes.forEach(function (prefix) { + var name = prefix + '-' + prop.name; + var val = prop.value; + css[name] = val; + }); + return css; + }, {})); + var parsedProps = {}; + for (var i = 0; i < this.properties.length; i++) { + var prop = this.properties[i]; + if (prop.pointsTo) { + continue; + } + var name = prop.name; + var val = rawProps[name]; + var parsedProp = this.parse(name, val); + parsedProps[name] = parsedProp; + } + _p.defaultProperties = parsedProps; + return _p.defaultProperties; +}; +styfn$2.addDefaultStylesheet = function () { + this.selector(':parent').css({ + 'shape': 'rectangle', + 'padding': 10, + 'background-color': '#eee', + 'border-color': '#ccc', + 'border-width': 1 + }).selector('edge').css({ + 'width': 3 + }).selector(':loop').css({ + 'curve-style': 'bezier' + }).selector('edge:compound').css({ + 'curve-style': 'bezier', + 'source-endpoint': 'outside-to-line', + 'target-endpoint': 'outside-to-line' + }).selector(':selected').css({ + 'background-color': '#0169D9', + 'line-color': '#0169D9', + 'source-arrow-color': '#0169D9', + 'target-arrow-color': '#0169D9', + 'mid-source-arrow-color': '#0169D9', + 'mid-target-arrow-color': '#0169D9' + }).selector(':parent:selected').css({ + 'background-color': '#CCE1F9', + 'border-color': '#aec8e5' + }).selector(':active').css({ + 'overlay-color': 'black', + 'overlay-padding': 10, + 'overlay-opacity': 0.25 + }); + this.defaultLength = this.length; +}; + +var styfn$1 = {}; + +// a caching layer for property parsing +styfn$1.parse = function (name, value, propIsBypass, propIsFlat) { + var self = this; + + // function values can't be cached in all cases, and there isn't much benefit of caching them anyway + if (fn$6(value)) { + return self.parseImplWarn(name, value, propIsBypass, propIsFlat); + } + var flatKey = propIsFlat === 'mapping' || propIsFlat === true || propIsFlat === false || propIsFlat == null ? 'dontcare' : propIsFlat; + var bypassKey = propIsBypass ? 't' : 'f'; + var valueKey = '' + value; + var argHash = hashStrings(name, valueKey, bypassKey, flatKey); + var propCache = self.propCache = self.propCache || []; + var ret; + if (!(ret = propCache[argHash])) { + ret = propCache[argHash] = self.parseImplWarn(name, value, propIsBypass, propIsFlat); + } + + // - bypasses can't be shared b/c the value can be changed by animations or otherwise overridden + // - mappings can't be shared b/c mappings are per-element + if (propIsBypass || propIsFlat === 'mapping') { + // need a copy since props are mutated later in their lifecycles + ret = copy(ret); + if (ret) { + ret.value = copy(ret.value); // because it could be an array, e.g. colour + } + } + + return ret; +}; +styfn$1.parseImplWarn = function (name, value, propIsBypass, propIsFlat) { + var prop = this.parseImpl(name, value, propIsBypass, propIsFlat); + if (!prop && value != null) { + warn("The style property `".concat(name, ": ").concat(value, "` is invalid")); + } + if (prop && (prop.name === 'width' || prop.name === 'height') && value === 'label') { + warn('The style value of `label` is deprecated for `' + prop.name + '`'); + } + return prop; +}; + +// parse a property; return null on invalid; return parsed property otherwise +// fields : +// - name : the name of the property +// - value : the parsed, native-typed value of the property +// - strValue : a string value that represents the property value in valid css +// - bypass : true iff the property is a bypass property +styfn$1.parseImpl = function (name, value, propIsBypass, propIsFlat) { + var self = this; + name = camel2dash(name); // make sure the property name is in dash form (e.g. 'property-name' not 'propertyName') + + var property = self.properties[name]; + var passedValue = value; + var types = self.types; + if (!property) { + return null; + } // return null on property of unknown name + if (value === undefined) { + return null; + } // can't assign undefined + + // the property may be an alias + if (property.alias) { + property = property.pointsTo; + name = property.name; + } + var valueIsString = string(value); + if (valueIsString) { + // trim the value to make parsing easier + value = value.trim(); + } + var type = property.type; + if (!type) { + return null; + } // no type, no luck + + // check if bypass is null or empty string (i.e. indication to delete bypass property) + if (propIsBypass && (value === '' || value === null)) { + return { + name: name, + value: value, + bypass: true, + deleteBypass: true + }; + } + + // check if value is a function used as a mapper + if (fn$6(value)) { + return { + name: name, + value: value, + strValue: 'fn', + mapped: types.fn, + bypass: propIsBypass + }; + } + + // check if value is mapped + var data, mapData; + if (!valueIsString || propIsFlat || value.length < 7 || value[1] !== 'a') ; else if (value.length >= 7 && value[0] === 'd' && (data = new RegExp(types.data.regex).exec(value))) { + if (propIsBypass) { + return false; + } // mappers not allowed in bypass + + var mapped = types.data; + return { + name: name, + value: data, + strValue: '' + value, + mapped: mapped, + field: data[1], + bypass: propIsBypass + }; + } else if (value.length >= 10 && value[0] === 'm' && (mapData = new RegExp(types.mapData.regex).exec(value))) { + if (propIsBypass) { + return false; + } // mappers not allowed in bypass + if (type.multiple) { + return false; + } // impossible to map to num + + var _mapped = types.mapData; + + // we can map only if the type is a colour or a number + if (!(type.color || type.number)) { + return false; + } + var valueMin = this.parse(name, mapData[4]); // parse to validate + if (!valueMin || valueMin.mapped) { + return false; + } // can't be invalid or mapped + + var valueMax = this.parse(name, mapData[5]); // parse to validate + if (!valueMax || valueMax.mapped) { + return false; + } // can't be invalid or mapped + + // check if valueMin and valueMax are the same + if (valueMin.pfValue === valueMax.pfValue || valueMin.strValue === valueMax.strValue) { + warn('`' + name + ': ' + value + '` is not a valid mapper because the output range is zero; converting to `' + name + ': ' + valueMin.strValue + '`'); + return this.parse(name, valueMin.strValue); // can't make much of a mapper without a range + } else if (type.color) { + var c1 = valueMin.value; + var c2 = valueMax.value; + var same = c1[0] === c2[0] // red + && c1[1] === c2[1] // green + && c1[2] === c2[2] // blue + && ( + // optional alpha + c1[3] === c2[3] // same alpha outright + || (c1[3] == null || c1[3] === 1 // full opacity for colour 1? + ) && (c2[3] == null || c2[3] === 1) // full opacity for colour 2? + ); + + if (same) { + return false; + } // can't make a mapper without a range + } + + return { + name: name, + value: mapData, + strValue: '' + value, + mapped: _mapped, + field: mapData[1], + fieldMin: parseFloat(mapData[2]), + // min & max are numeric + fieldMax: parseFloat(mapData[3]), + valueMin: valueMin.value, + valueMax: valueMax.value, + bypass: propIsBypass + }; + } + if (type.multiple && propIsFlat !== 'multiple') { + var vals; + if (valueIsString) { + vals = value.split(/\s+/); + } else if (array(value)) { + vals = value; + } else { + vals = [value]; + } + if (type.evenMultiple && vals.length % 2 !== 0) { + return null; + } + var valArr = []; + var unitsArr = []; + var pfValArr = []; + var strVal = ''; + var hasEnum = false; + for (var i = 0; i < vals.length; i++) { + var p = self.parse(name, vals[i], propIsBypass, 'multiple'); + hasEnum = hasEnum || string(p.value); + valArr.push(p.value); + pfValArr.push(p.pfValue != null ? p.pfValue : p.value); + unitsArr.push(p.units); + strVal += (i > 0 ? ' ' : '') + p.strValue; + } + if (type.validate && !type.validate(valArr, unitsArr)) { + return null; + } + if (type.singleEnum && hasEnum) { + if (valArr.length === 1 && string(valArr[0])) { + return { + name: name, + value: valArr[0], + strValue: valArr[0], + bypass: propIsBypass + }; + } else { + return null; + } + } + return { + name: name, + value: valArr, + pfValue: pfValArr, + strValue: strVal, + bypass: propIsBypass, + units: unitsArr + }; + } + + // several types also allow enums + var checkEnums = function checkEnums() { + for (var _i = 0; _i < type.enums.length; _i++) { + var en = type.enums[_i]; + if (en === value) { + return { + name: name, + value: value, + strValue: '' + value, + bypass: propIsBypass + }; + } + } + return null; + }; + + // check the type and return the appropriate object + if (type.number) { + var units; + var implicitUnits = 'px'; // not set => px + + if (type.units) { + // use specified units if set + units = type.units; + } + if (type.implicitUnits) { + implicitUnits = type.implicitUnits; + } + if (!type.unitless) { + if (valueIsString) { + var unitsRegex = 'px|em' + (type.allowPercent ? '|\\%' : ''); + if (units) { + unitsRegex = units; + } // only allow explicit units if so set + var match = value.match('^(' + number + ')(' + unitsRegex + ')?' + '$'); + if (match) { + value = match[1]; + units = match[2] || implicitUnits; + } + } else if (!units || type.implicitUnits) { + units = implicitUnits; // implicitly px if unspecified + } + } + + value = parseFloat(value); + + // if not a number and enums not allowed, then the value is invalid + if (isNaN(value) && type.enums === undefined) { + return null; + } + + // check if this number type also accepts special keywords in place of numbers + // (i.e. `left`, `auto`, etc) + if (isNaN(value) && type.enums !== undefined) { + value = passedValue; + return checkEnums(); + } + + // check if value must be an integer + if (type.integer && !integer(value)) { + return null; + } + + // check value is within range + if (type.min !== undefined && (value < type.min || type.strictMin && value === type.min) || type.max !== undefined && (value > type.max || type.strictMax && value === type.max)) { + return null; + } + var ret = { + name: name, + value: value, + strValue: '' + value + (units ? units : ''), + units: units, + bypass: propIsBypass + }; + + // normalise value in pixels + if (type.unitless || units !== 'px' && units !== 'em') { + ret.pfValue = value; + } else { + ret.pfValue = units === 'px' || !units ? value : this.getEmSizeInPixels() * value; + } + + // normalise value in ms + if (units === 'ms' || units === 's') { + ret.pfValue = units === 'ms' ? value : 1000 * value; + } + + // normalise value in rad + if (units === 'deg' || units === 'rad') { + ret.pfValue = units === 'rad' ? value : deg2rad(value); + } + + // normalize value in % + if (units === '%') { + ret.pfValue = value / 100; + } + return ret; + } else if (type.propList) { + var props = []; + var propsStr = '' + value; + if (propsStr === 'none') ; else { + // go over each prop + + var propsSplit = propsStr.split(/\s*,\s*|\s+/); + for (var _i2 = 0; _i2 < propsSplit.length; _i2++) { + var propName = propsSplit[_i2].trim(); + if (self.properties[propName]) { + props.push(propName); + } else { + warn('`' + propName + '` is not a valid property name'); + } + } + if (props.length === 0) { + return null; + } + } + return { + name: name, + value: props, + strValue: props.length === 0 ? 'none' : props.join(' '), + bypass: propIsBypass + }; + } else if (type.color) { + var tuple = color2tuple(value); + if (!tuple) { + return null; + } + return { + name: name, + value: tuple, + pfValue: tuple, + strValue: 'rgb(' + tuple[0] + ',' + tuple[1] + ',' + tuple[2] + ')', + // n.b. no spaces b/c of multiple support + bypass: propIsBypass + }; + } else if (type.regex || type.regexes) { + // first check enums + if (type.enums) { + var enumProp = checkEnums(); + if (enumProp) { + return enumProp; + } + } + var regexes = type.regexes ? type.regexes : [type.regex]; + for (var _i3 = 0; _i3 < regexes.length; _i3++) { + var regex = new RegExp(regexes[_i3]); // make a regex from the type string + var m = regex.exec(value); + if (m) { + // regex matches + return { + name: name, + value: type.singleRegexMatchValue ? m[1] : m, + strValue: '' + value, + bypass: propIsBypass + }; + } + } + return null; // didn't match any + } else if (type.string) { + // just return + return { + name: name, + value: '' + value, + strValue: '' + value, + bypass: propIsBypass + }; + } else if (type.enums) { + // check enums last because it's a combo type in others + return checkEnums(); + } else { + return null; // not a type we can handle + } +}; + +var Style = function Style(cy) { + if (!(this instanceof Style)) { + return new Style(cy); + } + if (!core(cy)) { + error('A style must have a core reference'); + return; + } + this._private = { + cy: cy, + coreStyle: {} + }; + this.length = 0; + this.resetToDefault(); +}; +var styfn = Style.prototype; +styfn.instanceString = function () { + return 'style'; +}; + +// remove all contexts +styfn.clear = function () { + var _p = this._private; + var cy = _p.cy; + var eles = cy.elements(); + for (var i = 0; i < this.length; i++) { + this[i] = undefined; + } + this.length = 0; + _p.contextStyles = {}; + _p.propDiffs = {}; + this.cleanElements(eles, true); + eles.forEach(function (ele) { + var ele_p = ele[0]._private; + ele_p.styleDirty = true; + ele_p.appliedInitStyle = false; + }); + return this; // chaining +}; + +styfn.resetToDefault = function () { + this.clear(); + this.addDefaultStylesheet(); + return this; +}; + +// builds a style object for the 'core' selector +styfn.core = function (propName) { + return this._private.coreStyle[propName] || this.getDefaultProperty(propName); +}; + +// create a new context from the specified selector string and switch to that context +styfn.selector = function (selectorStr) { + // 'core' is a special case and does not need a selector + var selector = selectorStr === 'core' ? null : new Selector(selectorStr); + var i = this.length++; // new context means new index + this[i] = { + selector: selector, + properties: [], + mappedProperties: [], + index: i + }; + return this; // chaining +}; + +// add one or many css rules to the current context +styfn.css = function () { + var self = this; + var args = arguments; + if (args.length === 1) { + var map = args[0]; + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var mapVal = map[prop.name]; + if (mapVal === undefined) { + mapVal = map[dash2camel(prop.name)]; + } + if (mapVal !== undefined) { + this.cssRule(prop.name, mapVal); + } + } + } else if (args.length === 2) { + this.cssRule(args[0], args[1]); + } + + // do nothing if args are invalid + + return this; // chaining +}; + +styfn.style = styfn.css; + +// add a single css rule to the current context +styfn.cssRule = function (name, value) { + // name-value pair + var property = this.parse(name, value); + + // add property to current context if valid + if (property) { + var i = this.length - 1; + this[i].properties.push(property); + this[i].properties[property.name] = property; // allow access by name as well + + if (property.name.match(/pie-(\d+)-background-size/) && property.value) { + this._private.hasPie = true; + } + if (property.mapped) { + this[i].mappedProperties.push(property); + } + + // add to core style if necessary + var currentSelectorIsCore = !this[i].selector; + if (currentSelectorIsCore) { + this._private.coreStyle[property.name] = property; + } + } + return this; // chaining +}; + +styfn.append = function (style) { + if (stylesheet(style)) { + style.appendToStyle(this); + } else if (array(style)) { + this.appendFromJson(style); + } else if (string(style)) { + this.appendFromString(style); + } // you probably wouldn't want to append a Style, since you'd duplicate the default parts + + return this; +}; + +// static function +Style.fromJson = function (cy, json) { + var style = new Style(cy); + style.fromJson(json); + return style; +}; +Style.fromString = function (cy, string) { + return new Style(cy).fromString(string); +}; +[styfn$8, styfn$7, styfn$6, styfn$5, styfn$4, styfn$3, styfn$2, styfn$1].forEach(function (props) { + extend(styfn, props); +}); +Style.types = styfn.types; +Style.properties = styfn.properties; +Style.propertyGroups = styfn.propertyGroups; +Style.propertyGroupNames = styfn.propertyGroupNames; +Style.propertyGroupKeys = styfn.propertyGroupKeys; + +var corefn$2 = { + style: function style(newStyle) { + if (newStyle) { + var s = this.setStyle(newStyle); + s.update(); + } + return this._private.style; + }, + setStyle: function setStyle(style) { + var _p = this._private; + if (stylesheet(style)) { + _p.style = style.generateStyle(this); + } else if (array(style)) { + _p.style = Style.fromJson(this, style); + } else if (string(style)) { + _p.style = Style.fromString(this, style); + } else { + _p.style = Style(this); + } + return _p.style; + }, + // e.g. cy.data() changed => recalc ele mappers + updateStyle: function updateStyle() { + this.mutableElements().updateStyle(); // just send to all eles + } +}; + +var defaultSelectionType = 'single'; +var corefn$1 = { + autolock: function autolock(bool) { + if (bool !== undefined) { + this._private.autolock = bool ? true : false; + } else { + return this._private.autolock; + } + return this; // chaining + }, + + autoungrabify: function autoungrabify(bool) { + if (bool !== undefined) { + this._private.autoungrabify = bool ? true : false; + } else { + return this._private.autoungrabify; + } + return this; // chaining + }, + + autounselectify: function autounselectify(bool) { + if (bool !== undefined) { + this._private.autounselectify = bool ? true : false; + } else { + return this._private.autounselectify; + } + return this; // chaining + }, + + selectionType: function selectionType(selType) { + var _p = this._private; + if (_p.selectionType == null) { + _p.selectionType = defaultSelectionType; + } + if (selType !== undefined) { + if (selType === 'additive' || selType === 'single') { + _p.selectionType = selType; + } + } else { + return _p.selectionType; + } + return this; + }, + panningEnabled: function panningEnabled(bool) { + if (bool !== undefined) { + this._private.panningEnabled = bool ? true : false; + } else { + return this._private.panningEnabled; + } + return this; // chaining + }, + + userPanningEnabled: function userPanningEnabled(bool) { + if (bool !== undefined) { + this._private.userPanningEnabled = bool ? true : false; + } else { + return this._private.userPanningEnabled; + } + return this; // chaining + }, + + zoomingEnabled: function zoomingEnabled(bool) { + if (bool !== undefined) { + this._private.zoomingEnabled = bool ? true : false; + } else { + return this._private.zoomingEnabled; + } + return this; // chaining + }, + + userZoomingEnabled: function userZoomingEnabled(bool) { + if (bool !== undefined) { + this._private.userZoomingEnabled = bool ? true : false; + } else { + return this._private.userZoomingEnabled; + } + return this; // chaining + }, + + boxSelectionEnabled: function boxSelectionEnabled(bool) { + if (bool !== undefined) { + this._private.boxSelectionEnabled = bool ? true : false; + } else { + return this._private.boxSelectionEnabled; + } + return this; // chaining + }, + + pan: function pan() { + var args = arguments; + var pan = this._private.pan; + var dim, val, dims, x, y; + switch (args.length) { + case 0: + // .pan() + return pan; + case 1: + if (string(args[0])) { + // .pan('x') + dim = args[0]; + return pan[dim]; + } else if (plainObject(args[0])) { + // .pan({ x: 0, y: 100 }) + if (!this._private.panningEnabled) { + return this; + } + dims = args[0]; + x = dims.x; + y = dims.y; + if (number$1(x)) { + pan.x = x; + } + if (number$1(y)) { + pan.y = y; + } + this.emit('pan viewport'); + } + break; + case 2: + // .pan('x', 100) + if (!this._private.panningEnabled) { + return this; + } + dim = args[0]; + val = args[1]; + if ((dim === 'x' || dim === 'y') && number$1(val)) { + pan[dim] = val; + } + this.emit('pan viewport'); + break; + // invalid + } + + this.notify('viewport'); + return this; // chaining + }, + + panBy: function panBy(arg0, arg1) { + var args = arguments; + var pan = this._private.pan; + var dim, val, dims, x, y; + if (!this._private.panningEnabled) { + return this; + } + switch (args.length) { + case 1: + if (plainObject(arg0)) { + // .panBy({ x: 0, y: 100 }) + dims = args[0]; + x = dims.x; + y = dims.y; + if (number$1(x)) { + pan.x += x; + } + if (number$1(y)) { + pan.y += y; + } + this.emit('pan viewport'); + } + break; + case 2: + // .panBy('x', 100) + dim = arg0; + val = arg1; + if ((dim === 'x' || dim === 'y') && number$1(val)) { + pan[dim] += val; + } + this.emit('pan viewport'); + break; + // invalid + } + + this.notify('viewport'); + return this; // chaining + }, + + fit: function fit(elements, padding) { + var viewportState = this.getFitViewport(elements, padding); + if (viewportState) { + var _p = this._private; + _p.zoom = viewportState.zoom; + _p.pan = viewportState.pan; + this.emit('pan zoom viewport'); + this.notify('viewport'); + } + return this; // chaining + }, + + getFitViewport: function getFitViewport(elements, padding) { + if (number$1(elements) && padding === undefined) { + // elements is optional + padding = elements; + elements = undefined; + } + if (!this._private.panningEnabled || !this._private.zoomingEnabled) { + return; + } + var bb; + if (string(elements)) { + var sel = elements; + elements = this.$(sel); + } else if (boundingBox(elements)) { + // assume bb + var bbe = elements; + bb = { + x1: bbe.x1, + y1: bbe.y1, + x2: bbe.x2, + y2: bbe.y2 + }; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + } else if (!elementOrCollection(elements)) { + elements = this.mutableElements(); + } + if (elementOrCollection(elements) && elements.empty()) { + return; + } // can't fit to nothing + + bb = bb || elements.boundingBox(); + var w = this.width(); + var h = this.height(); + var zoom; + padding = number$1(padding) ? padding : 0; + if (!isNaN(w) && !isNaN(h) && w > 0 && h > 0 && !isNaN(bb.w) && !isNaN(bb.h) && bb.w > 0 && bb.h > 0) { + zoom = Math.min((w - 2 * padding) / bb.w, (h - 2 * padding) / bb.h); + + // crop zoom + zoom = zoom > this._private.maxZoom ? this._private.maxZoom : zoom; + zoom = zoom < this._private.minZoom ? this._private.minZoom : zoom; + var pan = { + // now pan to middle + x: (w - zoom * (bb.x1 + bb.x2)) / 2, + y: (h - zoom * (bb.y1 + bb.y2)) / 2 + }; + return { + zoom: zoom, + pan: pan + }; + } + return; + }, + zoomRange: function zoomRange(min, max) { + var _p = this._private; + if (max == null) { + var opts = min; + min = opts.min; + max = opts.max; + } + if (number$1(min) && number$1(max) && min <= max) { + _p.minZoom = min; + _p.maxZoom = max; + } else if (number$1(min) && max === undefined && min <= _p.maxZoom) { + _p.minZoom = min; + } else if (number$1(max) && min === undefined && max >= _p.minZoom) { + _p.maxZoom = max; + } + return this; + }, + minZoom: function minZoom(zoom) { + if (zoom === undefined) { + return this._private.minZoom; + } else { + return this.zoomRange({ + min: zoom + }); + } + }, + maxZoom: function maxZoom(zoom) { + if (zoom === undefined) { + return this._private.maxZoom; + } else { + return this.zoomRange({ + max: zoom + }); + } + }, + getZoomedViewport: function getZoomedViewport(params) { + var _p = this._private; + var currentPan = _p.pan; + var currentZoom = _p.zoom; + var pos; // in rendered px + var zoom; + var bail = false; + if (!_p.zoomingEnabled) { + // zooming disabled + bail = true; + } + if (number$1(params)) { + // then set the zoom + zoom = params; + } else if (plainObject(params)) { + // then zoom about a point + zoom = params.level; + if (params.position != null) { + pos = modelToRenderedPosition(params.position, currentZoom, currentPan); + } else if (params.renderedPosition != null) { + pos = params.renderedPosition; + } + if (pos != null && !_p.panningEnabled) { + // panning disabled + bail = true; + } + } + + // crop zoom + zoom = zoom > _p.maxZoom ? _p.maxZoom : zoom; + zoom = zoom < _p.minZoom ? _p.minZoom : zoom; + + // can't zoom with invalid params + if (bail || !number$1(zoom) || zoom === currentZoom || pos != null && (!number$1(pos.x) || !number$1(pos.y))) { + return null; + } + if (pos != null) { + // set zoom about position + var pan1 = currentPan; + var zoom1 = currentZoom; + var zoom2 = zoom; + var pan2 = { + x: -zoom2 / zoom1 * (pos.x - pan1.x) + pos.x, + y: -zoom2 / zoom1 * (pos.y - pan1.y) + pos.y + }; + return { + zoomed: true, + panned: true, + zoom: zoom2, + pan: pan2 + }; + } else { + // just set the zoom + return { + zoomed: true, + panned: false, + zoom: zoom, + pan: currentPan + }; + } + }, + zoom: function zoom(params) { + if (params === undefined) { + // get + return this._private.zoom; + } else { + // set + var vp = this.getZoomedViewport(params); + var _p = this._private; + if (vp == null || !vp.zoomed) { + return this; + } + _p.zoom = vp.zoom; + if (vp.panned) { + _p.pan.x = vp.pan.x; + _p.pan.y = vp.pan.y; + } + this.emit('zoom' + (vp.panned ? ' pan' : '') + ' viewport'); + this.notify('viewport'); + return this; // chaining + } + }, + + viewport: function viewport(opts) { + var _p = this._private; + var zoomDefd = true; + var panDefd = true; + var events = []; // to trigger + var zoomFailed = false; + var panFailed = false; + if (!opts) { + return this; + } + if (!number$1(opts.zoom)) { + zoomDefd = false; + } + if (!plainObject(opts.pan)) { + panDefd = false; + } + if (!zoomDefd && !panDefd) { + return this; + } + if (zoomDefd) { + var z = opts.zoom; + if (z < _p.minZoom || z > _p.maxZoom || !_p.zoomingEnabled) { + zoomFailed = true; + } else { + _p.zoom = z; + events.push('zoom'); + } + } + if (panDefd && (!zoomFailed || !opts.cancelOnFailedZoom) && _p.panningEnabled) { + var p = opts.pan; + if (number$1(p.x)) { + _p.pan.x = p.x; + panFailed = false; + } + if (number$1(p.y)) { + _p.pan.y = p.y; + panFailed = false; + } + if (!panFailed) { + events.push('pan'); + } + } + if (events.length > 0) { + events.push('viewport'); + this.emit(events.join(' ')); + this.notify('viewport'); + } + return this; // chaining + }, + + center: function center(elements) { + var pan = this.getCenterPan(elements); + if (pan) { + this._private.pan = pan; + this.emit('pan viewport'); + this.notify('viewport'); + } + return this; // chaining + }, + + getCenterPan: function getCenterPan(elements, zoom) { + if (!this._private.panningEnabled) { + return; + } + if (string(elements)) { + var selector = elements; + elements = this.mutableElements().filter(selector); + } else if (!elementOrCollection(elements)) { + elements = this.mutableElements(); + } + if (elements.length === 0) { + return; + } // can't centre pan to nothing + + var bb = elements.boundingBox(); + var w = this.width(); + var h = this.height(); + zoom = zoom === undefined ? this._private.zoom : zoom; + var pan = { + // middle + x: (w - zoom * (bb.x1 + bb.x2)) / 2, + y: (h - zoom * (bb.y1 + bb.y2)) / 2 + }; + return pan; + }, + reset: function reset() { + if (!this._private.panningEnabled || !this._private.zoomingEnabled) { + return this; + } + this.viewport({ + pan: { + x: 0, + y: 0 + }, + zoom: 1 + }); + return this; // chaining + }, + + invalidateSize: function invalidateSize() { + this._private.sizeCache = null; + }, + size: function size() { + var _p = this._private; + var container = _p.container; + var cy = this; + return _p.sizeCache = _p.sizeCache || (container ? function () { + var style = cy.window().getComputedStyle(container); + var val = function val(name) { + return parseFloat(style.getPropertyValue(name)); + }; + return { + width: container.clientWidth - val('padding-left') - val('padding-right'), + height: container.clientHeight - val('padding-top') - val('padding-bottom') + }; + }() : { + // fallback if no container (not 0 b/c can be used for dividing etc) + width: 1, + height: 1 + }); + }, + width: function width() { + return this.size().width; + }, + height: function height() { + return this.size().height; + }, + extent: function extent() { + var pan = this._private.pan; + var zoom = this._private.zoom; + var rb = this.renderedExtent(); + var b = { + x1: (rb.x1 - pan.x) / zoom, + x2: (rb.x2 - pan.x) / zoom, + y1: (rb.y1 - pan.y) / zoom, + y2: (rb.y2 - pan.y) / zoom + }; + b.w = b.x2 - b.x1; + b.h = b.y2 - b.y1; + return b; + }, + renderedExtent: function renderedExtent() { + var width = this.width(); + var height = this.height(); + return { + x1: 0, + y1: 0, + x2: width, + y2: height, + w: width, + h: height + }; + }, + multiClickDebounceTime: function multiClickDebounceTime(_int) { + if (_int) this._private.multiClickDebounceTime = _int;else return this._private.multiClickDebounceTime; + return this; // chaining + } +}; + +// aliases +corefn$1.centre = corefn$1.center; + +// backwards compatibility +corefn$1.autolockNodes = corefn$1.autolock; +corefn$1.autoungrabifyNodes = corefn$1.autoungrabify; + +var fn = { + data: define.data({ + field: 'data', + bindingEvent: 'data', + allowBinding: true, + allowSetting: true, + settingEvent: 'data', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeData: define.removeData({ + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }), + scratch: define.data({ + field: 'scratch', + bindingEvent: 'scratch', + allowBinding: true, + allowSetting: true, + settingEvent: 'scratch', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeScratch: define.removeData({ + field: 'scratch', + event: 'scratch', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }) +}; + +// aliases +fn.attr = fn.data; +fn.removeAttr = fn.removeData; + +var Core = function Core(opts) { + var cy = this; + opts = extend({}, opts); + var container = opts.container; + + // allow for passing a wrapped jquery object + // e.g. cytoscape({ container: $('#cy') }) + if (container && !htmlElement(container) && htmlElement(container[0])) { + container = container[0]; + } + var reg = container ? container._cyreg : null; // e.g. already registered some info (e.g. readies) via jquery + reg = reg || {}; + if (reg && reg.cy) { + reg.cy.destroy(); + reg = {}; // old instance => replace reg completely + } + + var readies = reg.readies = reg.readies || []; + if (container) { + container._cyreg = reg; + } // make sure container assoc'd reg points to this cy + reg.cy = cy; + var head = _window !== undefined && container !== undefined && !opts.headless; + var options = opts; + options.layout = extend({ + name: head ? 'grid' : 'null' + }, options.layout); + options.renderer = extend({ + name: head ? 'canvas' : 'null' + }, options.renderer); + var defVal = function defVal(def, val, altVal) { + if (val !== undefined) { + return val; + } else if (altVal !== undefined) { + return altVal; + } else { + return def; + } + }; + var _p = this._private = { + container: container, + // html dom ele container + ready: false, + // whether ready has been triggered + options: options, + // cached options + elements: new Collection(this), + // elements in the graph + listeners: [], + // list of listeners + aniEles: new Collection(this), + // elements being animated + data: options.data || {}, + // data for the core + scratch: {}, + // scratch object for core + layout: null, + renderer: null, + destroyed: false, + // whether destroy was called + notificationsEnabled: true, + // whether notifications are sent to the renderer + minZoom: 1e-50, + maxZoom: 1e50, + zoomingEnabled: defVal(true, options.zoomingEnabled), + userZoomingEnabled: defVal(true, options.userZoomingEnabled), + panningEnabled: defVal(true, options.panningEnabled), + userPanningEnabled: defVal(true, options.userPanningEnabled), + boxSelectionEnabled: defVal(true, options.boxSelectionEnabled), + autolock: defVal(false, options.autolock, options.autolockNodes), + autoungrabify: defVal(false, options.autoungrabify, options.autoungrabifyNodes), + autounselectify: defVal(false, options.autounselectify), + styleEnabled: options.styleEnabled === undefined ? head : options.styleEnabled, + zoom: number$1(options.zoom) ? options.zoom : 1, + pan: { + x: plainObject(options.pan) && number$1(options.pan.x) ? options.pan.x : 0, + y: plainObject(options.pan) && number$1(options.pan.y) ? options.pan.y : 0 + }, + animation: { + // object for currently-running animations + current: [], + queue: [] + }, + hasCompoundNodes: false, + multiClickDebounceTime: defVal(250, options.multiClickDebounceTime) + }; + this.createEmitter(); + + // set selection type + this.selectionType(options.selectionType); + + // init zoom bounds + this.zoomRange({ + min: options.minZoom, + max: options.maxZoom + }); + var loadExtData = function loadExtData(extData, next) { + var anyIsPromise = extData.some(promise); + if (anyIsPromise) { + return Promise$1.all(extData).then(next); // load all data asynchronously, then exec rest of init + } else { + next(extData); // exec synchronously for convenience + } + }; + + // start with the default stylesheet so we have something before loading an external stylesheet + if (_p.styleEnabled) { + cy.setStyle([]); + } + + // create the renderer + var rendererOptions = extend({}, options, options.renderer); // allow rendering hints in top level options + cy.initRenderer(rendererOptions); + var setElesAndLayout = function setElesAndLayout(elements, onload, ondone) { + cy.notifications(false); + + // remove old elements + var oldEles = cy.mutableElements(); + if (oldEles.length > 0) { + oldEles.remove(); + } + if (elements != null) { + if (plainObject(elements) || array(elements)) { + cy.add(elements); + } + } + cy.one('layoutready', function (e) { + cy.notifications(true); + cy.emit(e); // we missed this event by turning notifications off, so pass it on + + cy.one('load', onload); + cy.emitAndNotify('load'); + }).one('layoutstop', function () { + cy.one('done', ondone); + cy.emit('done'); + }); + var layoutOpts = extend({}, cy._private.options.layout); + layoutOpts.eles = cy.elements(); + cy.layout(layoutOpts).run(); + }; + loadExtData([options.style, options.elements], function (thens) { + var initStyle = thens[0]; + var initEles = thens[1]; + + // init style + if (_p.styleEnabled) { + cy.style().append(initStyle); + } + + // initial load + setElesAndLayout(initEles, function () { + // onready + cy.startAnimationLoop(); + _p.ready = true; + + // if a ready callback is specified as an option, the bind it + if (fn$6(options.ready)) { + cy.on('ready', options.ready); + } + + // bind all the ready handlers registered before creating this instance + for (var i = 0; i < readies.length; i++) { + var fn = readies[i]; + cy.on('ready', fn); + } + if (reg) { + reg.readies = []; + } // clear b/c we've bound them all and don't want to keep it around in case a new core uses the same div etc + + cy.emit('ready'); + }, options.done); + }); +}; +var corefn = Core.prototype; // short alias + +extend(corefn, { + instanceString: function instanceString() { + return 'core'; + }, + isReady: function isReady() { + return this._private.ready; + }, + destroyed: function destroyed() { + return this._private.destroyed; + }, + ready: function ready(fn) { + if (this.isReady()) { + this.emitter().emit('ready', [], fn); // just calls fn as though triggered via ready event + } else { + this.on('ready', fn); + } + return this; + }, + destroy: function destroy() { + var cy = this; + if (cy.destroyed()) return; + cy.stopAnimationLoop(); + cy.destroyRenderer(); + this.emit('destroy'); + cy._private.destroyed = true; + return cy; + }, + hasElementWithId: function hasElementWithId(id) { + return this._private.elements.hasElementWithId(id); + }, + getElementById: function getElementById(id) { + return this._private.elements.getElementById(id); + }, + hasCompoundNodes: function hasCompoundNodes() { + return this._private.hasCompoundNodes; + }, + headless: function headless() { + return this._private.renderer.isHeadless(); + }, + styleEnabled: function styleEnabled() { + return this._private.styleEnabled; + }, + addToPool: function addToPool(eles) { + this._private.elements.merge(eles); + return this; // chaining + }, + + removeFromPool: function removeFromPool(eles) { + this._private.elements.unmerge(eles); + return this; + }, + container: function container() { + return this._private.container || null; + }, + window: function window() { + var container = this._private.container; + if (container == null) return _window; + var ownerDocument = this._private.container.ownerDocument; + if (ownerDocument === undefined || ownerDocument == null) { + return _window; + } + return ownerDocument.defaultView || _window; + }, + mount: function mount(container) { + if (container == null) { + return; + } + var cy = this; + var _p = cy._private; + var options = _p.options; + if (!htmlElement(container) && htmlElement(container[0])) { + container = container[0]; + } + cy.stopAnimationLoop(); + cy.destroyRenderer(); + _p.container = container; + _p.styleEnabled = true; + cy.invalidateSize(); + cy.initRenderer(extend({}, options, options.renderer, { + // allow custom renderer name to be re-used, otherwise use canvas + name: options.renderer.name === 'null' ? 'canvas' : options.renderer.name + })); + cy.startAnimationLoop(); + cy.style(options.style); + cy.emit('mount'); + return cy; + }, + unmount: function unmount() { + var cy = this; + cy.stopAnimationLoop(); + cy.destroyRenderer(); + cy.initRenderer({ + name: 'null' + }); + cy.emit('unmount'); + return cy; + }, + options: function options() { + return copy(this._private.options); + }, + json: function json(obj) { + var cy = this; + var _p = cy._private; + var eles = cy.mutableElements(); + var getFreshRef = function getFreshRef(ele) { + return cy.getElementById(ele.id()); + }; + if (plainObject(obj)) { + // set + + cy.startBatch(); + if (obj.elements) { + var idInJson = {}; + var updateEles = function updateEles(jsons, gr) { + var toAdd = []; + var toMod = []; + for (var i = 0; i < jsons.length; i++) { + var json = jsons[i]; + if (!json.data.id) { + warn('cy.json() cannot handle elements without an ID attribute'); + continue; + } + var id = '' + json.data.id; // id must be string + var ele = cy.getElementById(id); + idInJson[id] = true; + if (ele.length !== 0) { + // existing element should be updated + toMod.push({ + ele: ele, + json: json + }); + } else { + // otherwise should be added + if (gr) { + json.group = gr; + toAdd.push(json); + } else { + toAdd.push(json); + } + } + } + cy.add(toAdd); + for (var _i = 0; _i < toMod.length; _i++) { + var _toMod$_i = toMod[_i], + _ele = _toMod$_i.ele, + _json = _toMod$_i.json; + _ele.json(_json); + } + }; + if (array(obj.elements)) { + // elements: [] + updateEles(obj.elements); + } else { + // elements: { nodes: [], edges: [] } + var grs = ['nodes', 'edges']; + for (var i = 0; i < grs.length; i++) { + var gr = grs[i]; + var elements = obj.elements[gr]; + if (array(elements)) { + updateEles(elements, gr); + } + } + } + var parentsToRemove = cy.collection(); + eles.filter(function (ele) { + return !idInJson[ele.id()]; + }).forEach(function (ele) { + if (ele.isParent()) { + parentsToRemove.merge(ele); + } else { + ele.remove(); + } + }); + + // so that children are not removed w/parent + parentsToRemove.forEach(function (ele) { + return ele.children().move({ + parent: null + }); + }); + + // intermediate parents may be moved by prior line, so make sure we remove by fresh refs + parentsToRemove.forEach(function (ele) { + return getFreshRef(ele).remove(); + }); + } + if (obj.style) { + cy.style(obj.style); + } + if (obj.zoom != null && obj.zoom !== _p.zoom) { + cy.zoom(obj.zoom); + } + if (obj.pan) { + if (obj.pan.x !== _p.pan.x || obj.pan.y !== _p.pan.y) { + cy.pan(obj.pan); + } + } + if (obj.data) { + cy.data(obj.data); + } + var fields = ['minZoom', 'maxZoom', 'zoomingEnabled', 'userZoomingEnabled', 'panningEnabled', 'userPanningEnabled', 'boxSelectionEnabled', 'autolock', 'autoungrabify', 'autounselectify', 'multiClickDebounceTime']; + for (var _i2 = 0; _i2 < fields.length; _i2++) { + var f = fields[_i2]; + if (obj[f] != null) { + cy[f](obj[f]); + } + } + cy.endBatch(); + return this; // chaining + } else { + // get + var flat = !!obj; + var json = {}; + if (flat) { + json.elements = this.elements().map(function (ele) { + return ele.json(); + }); + } else { + json.elements = {}; + eles.forEach(function (ele) { + var group = ele.group(); + if (!json.elements[group]) { + json.elements[group] = []; + } + json.elements[group].push(ele.json()); + }); + } + if (this._private.styleEnabled) { + json.style = cy.style().json(); + } + json.data = copy(cy.data()); + var options = _p.options; + json.zoomingEnabled = _p.zoomingEnabled; + json.userZoomingEnabled = _p.userZoomingEnabled; + json.zoom = _p.zoom; + json.minZoom = _p.minZoom; + json.maxZoom = _p.maxZoom; + json.panningEnabled = _p.panningEnabled; + json.userPanningEnabled = _p.userPanningEnabled; + json.pan = copy(_p.pan); + json.boxSelectionEnabled = _p.boxSelectionEnabled; + json.renderer = copy(options.renderer); + json.hideEdgesOnViewport = options.hideEdgesOnViewport; + json.textureOnViewport = options.textureOnViewport; + json.wheelSensitivity = options.wheelSensitivity; + json.motionBlur = options.motionBlur; + json.multiClickDebounceTime = options.multiClickDebounceTime; + return json; + } + } +}); +corefn.$id = corefn.getElementById; +[corefn$9, corefn$8, elesfn, corefn$7, corefn$6, corefn$5, corefn$4, corefn$3, corefn$2, corefn$1, fn].forEach(function (props) { + extend(corefn, props); +}); + +/* eslint-disable no-unused-vars */ +var defaults$7 = { + fit: true, + // whether to fit the viewport to the graph + directed: false, + // whether the tree is directed downwards (or edges can point in any direction if false) + padding: 30, + // padding on fit + circle: false, + // put depths in concentric circles if true, put depths top down if false + grid: false, + // whether to create an even grid into which the DAG is placed (circle:false only) + spacingFactor: 1.75, + // positive spacing factor, larger => more space between nodes (N.B. n/a if causes overlap) + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + roots: undefined, + // the roots of the trees + depthSort: undefined, + // a sorting function to order nodes at equal depth. e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled, + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +var deprecatedOptionDefaults = { + maximal: false, + // whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only); setting acyclic to true sets maximal to true also + acyclic: false // whether the tree is acyclic and thus a node could be shifted (due to the maximal option) multiple times without causing an infinite loop; setting to true sets maximal to true also; if you are uncertain whether a tree is acyclic, set to false to avoid potential infinite loops +}; + +/* eslint-enable */ + +var getInfo = function getInfo(ele) { + return ele.scratch('breadthfirst'); +}; +var setInfo = function setInfo(ele, obj) { + return ele.scratch('breadthfirst', obj); +}; +function BreadthFirstLayout(options) { + this.options = extend({}, defaults$7, deprecatedOptionDefaults, options); +} +BreadthFirstLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().filter(function (n) { + return !n.isParent(); + }); + var graph = eles; + var directed = options.directed; + var maximal = options.acyclic || options.maximal || options.maximalAdjustments > 0; // maximalAdjustments for compat. w/ old code; also, setting acyclic to true sets maximal to true + + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var roots; + if (elementOrCollection(options.roots)) { + roots = options.roots; + } else if (array(options.roots)) { + var rootsArray = []; + for (var i = 0; i < options.roots.length; i++) { + var id = options.roots[i]; + var ele = cy.getElementById(id); + rootsArray.push(ele); + } + roots = cy.collection(rootsArray); + } else if (string(options.roots)) { + roots = cy.$(options.roots); + } else { + if (directed) { + roots = nodes.roots(); + } else { + var components = eles.components(); + roots = cy.collection(); + var _loop = function _loop(_i) { + var comp = components[_i]; + var maxDegree = comp.maxDegree(false); + var compRoots = comp.filter(function (ele) { + return ele.degree(false) === maxDegree; + }); + roots = roots.add(compRoots); + }; + for (var _i = 0; _i < components.length; _i++) { + _loop(_i); + } + } + } + var depths = []; + var foundByBfs = {}; + var addToDepth = function addToDepth(ele, d) { + if (depths[d] == null) { + depths[d] = []; + } + var i = depths[d].length; + depths[d].push(ele); + setInfo(ele, { + index: i, + depth: d + }); + }; + var changeDepth = function changeDepth(ele, newDepth) { + var _getInfo = getInfo(ele), + depth = _getInfo.depth, + index = _getInfo.index; + depths[depth][index] = null; + addToDepth(ele, newDepth); + }; + + // find the depths of the nodes + graph.bfs({ + roots: roots, + directed: options.directed, + visit: function visit(node, edge, pNode, i, depth) { + var ele = node[0]; + var id = ele.id(); + addToDepth(ele, depth); + foundByBfs[id] = true; + } + }); + + // check for nodes not found by bfs + var orphanNodes = []; + for (var _i2 = 0; _i2 < nodes.length; _i2++) { + var _ele = nodes[_i2]; + if (foundByBfs[_ele.id()]) { + continue; + } else { + orphanNodes.push(_ele); + } + } + + // assign the nodes a depth and index + + var assignDepthsAt = function assignDepthsAt(i) { + var eles = depths[i]; + for (var j = 0; j < eles.length; j++) { + var _ele2 = eles[j]; + if (_ele2 == null) { + eles.splice(j, 1); + j--; + continue; + } + setInfo(_ele2, { + depth: i, + index: j + }); + } + }; + var assignDepths = function assignDepths() { + for (var _i3 = 0; _i3 < depths.length; _i3++) { + assignDepthsAt(_i3); + } + }; + var adjustMaximally = function adjustMaximally(ele, shifted) { + var eInfo = getInfo(ele); + var incomers = ele.incomers().filter(function (el) { + return el.isNode() && eles.has(el); + }); + var maxDepth = -1; + var id = ele.id(); + for (var k = 0; k < incomers.length; k++) { + var incmr = incomers[k]; + var iInfo = getInfo(incmr); + maxDepth = Math.max(maxDepth, iInfo.depth); + } + if (eInfo.depth <= maxDepth) { + if (!options.acyclic && shifted[id]) { + return null; + } + var newDepth = maxDepth + 1; + changeDepth(ele, newDepth); + shifted[id] = newDepth; + return true; + } + return false; + }; + + // for the directed case, try to make the edges all go down (i.e. depth i => depth i + 1) + if (directed && maximal) { + var Q = []; + var shifted = {}; + var enqueue = function enqueue(n) { + return Q.push(n); + }; + var dequeue = function dequeue() { + return Q.shift(); + }; + nodes.forEach(function (n) { + return Q.push(n); + }); + while (Q.length > 0) { + var _ele3 = dequeue(); + var didShift = adjustMaximally(_ele3, shifted); + if (didShift) { + _ele3.outgoers().filter(function (el) { + return el.isNode() && eles.has(el); + }).forEach(enqueue); + } else if (didShift === null) { + warn('Detected double maximal shift for node `' + _ele3.id() + '`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.'); + break; // exit on failure + } + } + } + + assignDepths(); // clear holes + + // find min distance we need to leave between nodes + var minDistance = 0; + if (options.avoidOverlap) { + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + var n = nodes[_i4]; + var nbb = n.layoutDimensions(options); + var w = nbb.w; + var h = nbb.h; + minDistance = Math.max(minDistance, w, h); + } + } + + // get the weighted percent for an element based on its connectivity to other levels + var cachedWeightedPercent = {}; + var getWeightedPercent = function getWeightedPercent(ele) { + if (cachedWeightedPercent[ele.id()]) { + return cachedWeightedPercent[ele.id()]; + } + var eleDepth = getInfo(ele).depth; + var neighbors = ele.neighborhood(); + var percent = 0; + var samples = 0; + for (var _i5 = 0; _i5 < neighbors.length; _i5++) { + var neighbor = neighbors[_i5]; + if (neighbor.isEdge() || neighbor.isParent() || !nodes.has(neighbor)) { + continue; + } + var bf = getInfo(neighbor); + if (bf == null) { + continue; + } + var index = bf.index; + var depth = bf.depth; + + // unassigned neighbours shouldn't affect the ordering + if (index == null || depth == null) { + continue; + } + var nDepth = depths[depth].length; + if (depth < eleDepth) { + // only get influenced by elements above + percent += index / nDepth; + samples++; + } + } + samples = Math.max(1, samples); + percent = percent / samples; + if (samples === 0) { + // put lone nodes at the start + percent = 0; + } + cachedWeightedPercent[ele.id()] = percent; + return percent; + }; + + // rearrange the indices in each depth level based on connectivity + + var sortFn = function sortFn(a, b) { + var apct = getWeightedPercent(a); + var bpct = getWeightedPercent(b); + var diff = apct - bpct; + if (diff === 0) { + return ascending(a.id(), b.id()); // make sure sort doesn't have don't-care comparisons + } else { + return diff; + } + }; + if (options.depthSort !== undefined) { + sortFn = options.depthSort; + } + + // sort each level to make connected nodes closer + for (var _i6 = 0; _i6 < depths.length; _i6++) { + depths[_i6].sort(sortFn); + assignDepthsAt(_i6); + } + + // assign orphan nodes to a new top-level depth + var orphanDepth = []; + for (var _i7 = 0; _i7 < orphanNodes.length; _i7++) { + orphanDepth.push(orphanNodes[_i7]); + } + depths.unshift(orphanDepth); + assignDepths(); + var biggestDepthSize = 0; + for (var _i8 = 0; _i8 < depths.length; _i8++) { + biggestDepthSize = Math.max(depths[_i8].length, biggestDepthSize); + } + var center = { + x: bb.x1 + bb.w / 2, + y: bb.x1 + bb.h / 2 + }; + var maxDepthSize = depths.reduce(function (max, eles) { + return Math.max(max, eles.length); + }, 0); + var getPosition = function getPosition(ele) { + var _getInfo2 = getInfo(ele), + depth = _getInfo2.depth, + index = _getInfo2.index; + var depthSize = depths[depth].length; + var distanceX = Math.max(bb.w / ((options.grid ? maxDepthSize : depthSize) + 1), minDistance); + var distanceY = Math.max(bb.h / (depths.length + 1), minDistance); + var radiusStepSize = Math.min(bb.w / 2 / depths.length, bb.h / 2 / depths.length); + radiusStepSize = Math.max(radiusStepSize, minDistance); + if (!options.circle) { + var epos = { + x: center.x + (index + 1 - (depthSize + 1) / 2) * distanceX, + y: (depth + 1) * distanceY + }; + return epos; + } else { + var radius = radiusStepSize * depth + radiusStepSize - (depths.length > 0 && depths[0].length <= 3 ? radiusStepSize / 2 : 0); + var theta = 2 * Math.PI / depths[depth].length * index; + if (depth === 0 && depths[0].length === 1) { + radius = 1; + } + return { + x: center.x + radius * Math.cos(theta), + y: center.y + radius * Math.sin(theta) + }; + } + }; + eles.nodes().layoutPositions(this, options, getPosition); + return this; // chaining +}; + +var defaults$6 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // the padding on fit + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox and radius if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + radius: undefined, + // the radius of the circle + startAngle: 3 / 2 * Math.PI, + // where nodes start in radians + sweep: undefined, + // how many radians should be between the first and last node (defaults to full circle) + clockwise: true, + // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) + sort: undefined, + // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function CircleLayout(options) { + this.options = extend({}, defaults$6, options); +} +CircleLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var clockwise = options.counterclockwise !== undefined ? !options.counterclockwise : options.clockwise; + var nodes = eles.nodes().not(':parent'); + if (options.sort) { + nodes = nodes.sort(options.sort); + } + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var center = { + x: bb.x1 + bb.w / 2, + y: bb.y1 + bb.h / 2 + }; + var sweep = options.sweep === undefined ? 2 * Math.PI - 2 * Math.PI / nodes.length : options.sweep; + var dTheta = sweep / Math.max(1, nodes.length - 1); + var r; + var minDistance = 0; + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + var nbb = n.layoutDimensions(options); + var w = nbb.w; + var h = nbb.h; + minDistance = Math.max(minDistance, w, h); + } + if (number$1(options.radius)) { + r = options.radius; + } else if (nodes.length <= 1) { + r = 0; + } else { + r = Math.min(bb.h, bb.w) / 2 - minDistance; + } + + // calculate the radius + if (nodes.length > 1 && options.avoidOverlap) { + // but only if more than one node (can't overlap) + minDistance *= 1.75; // just to have some nice spacing + + var dcos = Math.cos(dTheta) - Math.cos(0); + var dsin = Math.sin(dTheta) - Math.sin(0); + var rMin = Math.sqrt(minDistance * minDistance / (dcos * dcos + dsin * dsin)); // s.t. no nodes overlapping + r = Math.max(rMin, r); + } + var getPos = function getPos(ele, i) { + var theta = options.startAngle + i * dTheta * (clockwise ? 1 : -1); + var rx = r * Math.cos(theta); + var ry = r * Math.sin(theta); + var pos = { + x: center.x + rx, + y: center.y + ry + }; + return pos; + }; + eles.nodes().layoutPositions(this, options, getPos); + return this; // chaining +}; + +var defaults$5 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // the padding on fit + startAngle: 3 / 2 * Math.PI, + // where nodes start in radians + sweep: undefined, + // how many radians should be between the first and last node (defaults to full circle) + clockwise: true, + // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) + equidistant: false, + // whether levels have an equal radial distance betwen them, may cause bounding box overflow + minNodeSpacing: 10, + // min spacing between outside of nodes (used for radius adjustment) + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + height: undefined, + // height of layout area (overrides container height) + width: undefined, + // width of layout area (overrides container width) + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + concentric: function concentric(node) { + // returns numeric value for each node, placing higher nodes in levels towards the centre + return node.degree(); + }, + levelWidth: function levelWidth(nodes) { + // the variation of concentric values in each level + return nodes.maxDegree() / 4; + }, + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function ConcentricLayout(options) { + this.options = extend({}, defaults$5, options); +} +ConcentricLayout.prototype.run = function () { + var params = this.options; + var options = params; + var clockwise = options.counterclockwise !== undefined ? !options.counterclockwise : options.clockwise; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().not(':parent'); + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var center = { + x: bb.x1 + bb.w / 2, + y: bb.y1 + bb.h / 2 + }; + var nodeValues = []; // { node, value } + var maxNodeSize = 0; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var value = void 0; + + // calculate the node value + value = options.concentric(node); + nodeValues.push({ + value: value, + node: node + }); + + // for style mapping + node._private.scratch.concentric = value; + } + + // in case we used the `concentric` in style + nodes.updateStyle(); + + // calculate max size now based on potentially updated mappers + for (var _i = 0; _i < nodes.length; _i++) { + var _node = nodes[_i]; + var nbb = _node.layoutDimensions(options); + maxNodeSize = Math.max(maxNodeSize, nbb.w, nbb.h); + } + + // sort node values in descreasing order + nodeValues.sort(function (a, b) { + return b.value - a.value; + }); + var levelWidth = options.levelWidth(nodes); + + // put the values into levels + var levels = [[]]; + var currentLevel = levels[0]; + for (var _i2 = 0; _i2 < nodeValues.length; _i2++) { + var val = nodeValues[_i2]; + if (currentLevel.length > 0) { + var diff = Math.abs(currentLevel[0].value - val.value); + if (diff >= levelWidth) { + currentLevel = []; + levels.push(currentLevel); + } + } + currentLevel.push(val); + } + + // create positions from levels + + var minDist = maxNodeSize + options.minNodeSpacing; // min dist between nodes + + if (!options.avoidOverlap) { + // then strictly constrain to bb + var firstLvlHasMulti = levels.length > 0 && levels[0].length > 1; + var maxR = Math.min(bb.w, bb.h) / 2 - minDist; + var rStep = maxR / (levels.length + firstLvlHasMulti ? 1 : 0); + minDist = Math.min(minDist, rStep); + } + + // find the metrics for each level + var r = 0; + for (var _i3 = 0; _i3 < levels.length; _i3++) { + var level = levels[_i3]; + var sweep = options.sweep === undefined ? 2 * Math.PI - 2 * Math.PI / level.length : options.sweep; + var dTheta = level.dTheta = sweep / Math.max(1, level.length - 1); + + // calculate the radius + if (level.length > 1 && options.avoidOverlap) { + // but only if more than one node (can't overlap) + var dcos = Math.cos(dTheta) - Math.cos(0); + var dsin = Math.sin(dTheta) - Math.sin(0); + var rMin = Math.sqrt(minDist * minDist / (dcos * dcos + dsin * dsin)); // s.t. no nodes overlapping + + r = Math.max(rMin, r); + } + level.r = r; + r += minDist; + } + if (options.equidistant) { + var rDeltaMax = 0; + var _r = 0; + for (var _i4 = 0; _i4 < levels.length; _i4++) { + var _level = levels[_i4]; + var rDelta = _level.r - _r; + rDeltaMax = Math.max(rDeltaMax, rDelta); + } + _r = 0; + for (var _i5 = 0; _i5 < levels.length; _i5++) { + var _level2 = levels[_i5]; + if (_i5 === 0) { + _r = _level2.r; + } + _level2.r = _r; + _r += rDeltaMax; + } + } + + // calculate the node positions + var pos = {}; // id => position + for (var _i6 = 0; _i6 < levels.length; _i6++) { + var _level3 = levels[_i6]; + var _dTheta = _level3.dTheta; + var _r2 = _level3.r; + for (var j = 0; j < _level3.length; j++) { + var _val = _level3[j]; + var theta = options.startAngle + (clockwise ? 1 : -1) * _dTheta * j; + var p = { + x: center.x + _r2 * Math.cos(theta), + y: center.y + _r2 * Math.sin(theta) + }; + pos[_val.node.id()] = p; + } + } + + // position the nodes + eles.nodes().layoutPositions(this, options, function (ele) { + var id = ele.id(); + return pos[id]; + }); + return this; // chaining +}; + +/* +The CoSE layout was written by Gerardo Huck. +https://www.linkedin.com/in/gerardohuck/ + +Based on the following article: +http://dl.acm.org/citation.cfm?id=1498047 + +Modifications tracked on Github. +*/ +var DEBUG; + +/** + * @brief : default layout options + */ +var defaults$4 = { + // Called on `layoutready` + ready: function ready() {}, + // Called on `layoutstop` + stop: function stop() {}, + // Whether to animate while running the layout + // true : Animate continuously as the layout is running + // false : Just show the end result + // 'end' : Animate with the end result, from the initial positions to the end positions + animate: true, + // Easing of the animation for animate:'end' + animationEasing: undefined, + // The duration of the animation for animate:'end' + animationDuration: undefined, + // A function that determines whether the node should be animated + // All nodes animated by default on animate enabled + // Non-animated nodes are positioned immediately when the layout starts + animateFilter: function animateFilter(node, i) { + return true; + }, + // The layout animates only after this many milliseconds for animate:true + // (prevents flashing on fast runs) + animationThreshold: 250, + // Number of iterations between consecutive screen positions update + refresh: 20, + // Whether to fit the network view after when done + fit: true, + // Padding on fit + padding: 30, + // Constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + boundingBox: undefined, + // Excludes the label when calculating node bounding boxes for the layout algorithm + nodeDimensionsIncludeLabels: false, + // Randomize the initial positions of the nodes (true) or use existing positions (false) + randomize: false, + // Extra spacing between components in non-compound graphs + componentSpacing: 40, + // Node repulsion (non overlapping) multiplier + nodeRepulsion: function nodeRepulsion(node) { + return 2048; + }, + // Node repulsion (overlapping) multiplier + nodeOverlap: 4, + // Ideal edge (non nested) length + idealEdgeLength: function idealEdgeLength(edge) { + return 32; + }, + // Divisor to compute edge forces + edgeElasticity: function edgeElasticity(edge) { + return 32; + }, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 1.2, + // Gravity force (constant) + gravity: 1, + // Maximum number of iterations to perform + numIter: 1000, + // Initial temperature (maximum node displacement) + initialTemp: 1000, + // Cooling factor (how the temperature is reduced between consecutive iterations + coolingFactor: 0.99, + // Lower temperature threshold (below this point the layout will end) + minTemp: 1.0 +}; + +/** + * @brief : constructor + * @arg options : object containing layout options + */ +function CoseLayout(options) { + this.options = extend({}, defaults$4, options); + this.options.layout = this; + + // Exclude any edge that has a source or target node that is not in the set of passed-in nodes + var nodes = this.options.eles.nodes(); + var edges = this.options.eles.edges(); + var notEdges = edges.filter(function (e) { + var sourceId = e.source().data('id'); + var targetId = e.target().data('id'); + var hasSource = nodes.some(function (n) { + return n.data('id') === sourceId; + }); + var hasTarget = nodes.some(function (n) { + return n.data('id') === targetId; + }); + return !hasSource || !hasTarget; + }); + this.options.eles = this.options.eles.not(notEdges); +} + +/** + * @brief : runs the layout + */ +CoseLayout.prototype.run = function () { + var options = this.options; + var cy = options.cy; + var layout = this; + layout.stopped = false; + if (options.animate === true || options.animate === false) { + layout.emit({ + type: 'layoutstart', + layout: layout + }); + } + + // Set DEBUG - Global variable + if (true === options.debug) { + DEBUG = true; + } else { + DEBUG = false; + } + + // Initialize layout info + var layoutInfo = createLayoutInfo(cy, layout, options); + + // Show LayoutInfo contents if debugging + if (DEBUG) { + printLayoutInfo(layoutInfo); + } + + // If required, randomize node positions + if (options.randomize) { + randomizePositions(layoutInfo); + } + var startTime = performanceNow(); + var refresh = function refresh() { + refreshPositions(layoutInfo, cy, options); + + // Fit the graph if necessary + if (true === options.fit) { + cy.fit(options.padding); + } + }; + var mainLoop = function mainLoop(i) { + if (layout.stopped || i >= options.numIter) { + // logDebug("Layout manually stopped. Stopping computation in step " + i); + return false; + } + + // Do one step in the phisical simulation + step(layoutInfo, options); + + // Update temperature + layoutInfo.temperature = layoutInfo.temperature * options.coolingFactor; + // logDebug("New temperature: " + layoutInfo.temperature); + + if (layoutInfo.temperature < options.minTemp) { + // logDebug("Temperature drop below minimum threshold. Stopping computation in step " + i); + return false; + } + return true; + }; + var done = function done() { + if (options.animate === true || options.animate === false) { + refresh(); + + // Layout has finished + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + } else { + var nodes = options.eles.nodes(); + var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes); + nodes.layoutPositions(layout, options, getScaledPos); + } + }; + var i = 0; + var loopRet = true; + if (options.animate === true) { + var frame = function frame() { + var f = 0; + while (loopRet && f < options.refresh) { + loopRet = mainLoop(i); + i++; + f++; + } + if (!loopRet) { + // it's done + separateComponents(layoutInfo, options); + done(); + } else { + var now = performanceNow(); + if (now - startTime >= options.animationThreshold) { + refresh(); + } + requestAnimationFrame$1(frame); + } + }; + frame(); + } else { + while (loopRet) { + loopRet = mainLoop(i); + i++; + } + separateComponents(layoutInfo, options); + done(); + } + return this; // chaining +}; + +/** + * @brief : called on continuous layouts to stop them before they finish + */ +CoseLayout.prototype.stop = function () { + this.stopped = true; + if (this.thread) { + this.thread.stop(); + } + this.emit('layoutstop'); + return this; // chaining +}; + +CoseLayout.prototype.destroy = function () { + if (this.thread) { + this.thread.stop(); + } + return this; // chaining +}; + +/** + * @brief : Creates an object which is contains all the data + * used in the layout process + * @arg cy : cytoscape.js object + * @return : layoutInfo object initialized + */ +var createLayoutInfo = function createLayoutInfo(cy, layout, options) { + // Shortcut + var edges = options.eles.edges(); + var nodes = options.eles.nodes(); + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var layoutInfo = { + isCompound: cy.hasCompoundNodes(), + layoutNodes: [], + idToIndex: {}, + nodeSize: nodes.size(), + graphSet: [], + indexToGraph: [], + layoutEdges: [], + edgeSize: edges.size(), + temperature: options.initialTemp, + clientWidth: bb.w, + clientHeight: bb.h, + boundingBox: bb + }; + var components = options.eles.components(); + var id2cmptId = {}; + for (var i = 0; i < components.length; i++) { + var component = components[i]; + for (var j = 0; j < component.length; j++) { + var node = component[j]; + id2cmptId[node.id()] = i; + } + } + + // Iterate over all nodes, creating layout nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = nodes[i]; + var nbb = n.layoutDimensions(options); + var tempNode = {}; + tempNode.isLocked = n.locked(); + tempNode.id = n.data('id'); + tempNode.parentId = n.data('parent'); + tempNode.cmptId = id2cmptId[n.id()]; + tempNode.children = []; + tempNode.positionX = n.position('x'); + tempNode.positionY = n.position('y'); + tempNode.offsetX = 0; + tempNode.offsetY = 0; + tempNode.height = nbb.w; + tempNode.width = nbb.h; + tempNode.maxX = tempNode.positionX + tempNode.width / 2; + tempNode.minX = tempNode.positionX - tempNode.width / 2; + tempNode.maxY = tempNode.positionY + tempNode.height / 2; + tempNode.minY = tempNode.positionY - tempNode.height / 2; + tempNode.padLeft = parseFloat(n.style('padding')); + tempNode.padRight = parseFloat(n.style('padding')); + tempNode.padTop = parseFloat(n.style('padding')); + tempNode.padBottom = parseFloat(n.style('padding')); + + // forces + tempNode.nodeRepulsion = fn$6(options.nodeRepulsion) ? options.nodeRepulsion(n) : options.nodeRepulsion; + + // Add new node + layoutInfo.layoutNodes.push(tempNode); + // Add entry to id-index map + layoutInfo.idToIndex[tempNode.id] = i; + } + + // Inline implementation of a queue, used for traversing the graph in BFS order + var queue = []; + var start = 0; // Points to the start the queue + var end = -1; // Points to the end of the queue + + var tempGraph = []; + + // Second pass to add child information and + // initialize queue for hierarchical traversal + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + var p_id = n.parentId; + // Check if node n has a parent node + if (null != p_id) { + // Add node Id to parent's list of children + layoutInfo.layoutNodes[layoutInfo.idToIndex[p_id]].children.push(n.id); + } else { + // If a node doesn't have a parent, then it's in the root graph + queue[++end] = n.id; + tempGraph.push(n.id); + } + } + + // Add root graph to graphSet + layoutInfo.graphSet.push(tempGraph); + + // Traverse the graph, level by level, + while (start <= end) { + // Get the node to visit and remove it from queue + var node_id = queue[start++]; + var node_ix = layoutInfo.idToIndex[node_id]; + var node = layoutInfo.layoutNodes[node_ix]; + var children = node.children; + if (children.length > 0) { + // Add children nodes as a new graph to graph set + layoutInfo.graphSet.push(children); + // Add children to que queue to be visited + for (var i = 0; i < children.length; i++) { + queue[++end] = children[i]; + } + } + } + + // Create indexToGraph map + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + for (var j = 0; j < graph.length; j++) { + var index = layoutInfo.idToIndex[graph[j]]; + layoutInfo.indexToGraph[index] = i; + } + } + + // Iterate over all edges, creating Layout Edges + for (var i = 0; i < layoutInfo.edgeSize; i++) { + var e = edges[i]; + var tempEdge = {}; + tempEdge.id = e.data('id'); + tempEdge.sourceId = e.data('source'); + tempEdge.targetId = e.data('target'); + + // Compute ideal length + var idealLength = fn$6(options.idealEdgeLength) ? options.idealEdgeLength(e) : options.idealEdgeLength; + var elasticity = fn$6(options.edgeElasticity) ? options.edgeElasticity(e) : options.edgeElasticity; + + // Check if it's an inter graph edge + var sourceIx = layoutInfo.idToIndex[tempEdge.sourceId]; + var targetIx = layoutInfo.idToIndex[tempEdge.targetId]; + var sourceGraph = layoutInfo.indexToGraph[sourceIx]; + var targetGraph = layoutInfo.indexToGraph[targetIx]; + if (sourceGraph != targetGraph) { + // Find lowest common graph ancestor + var lca = findLCA(tempEdge.sourceId, tempEdge.targetId, layoutInfo); + + // Compute sum of node depths, relative to lca graph + var lcaGraph = layoutInfo.graphSet[lca]; + var depth = 0; + + // Source depth + var tempNode = layoutInfo.layoutNodes[sourceIx]; + while (-1 === lcaGraph.indexOf(tempNode.id)) { + tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]]; + depth++; + } + + // Target depth + tempNode = layoutInfo.layoutNodes[targetIx]; + while (-1 === lcaGraph.indexOf(tempNode.id)) { + tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]]; + depth++; + } + + // logDebug('LCA of nodes ' + tempEdge.sourceId + ' and ' + tempEdge.targetId + + // ". Index: " + lca + " Contents: " + lcaGraph.toString() + + // ". Depth: " + depth); + + // Update idealLength + idealLength *= depth * options.nestingFactor; + } + tempEdge.idealLength = idealLength; + tempEdge.elasticity = elasticity; + layoutInfo.layoutEdges.push(tempEdge); + } + + // Finally, return layoutInfo object + return layoutInfo; +}; + +/** + * @brief : This function finds the index of the lowest common + * graph ancestor between 2 nodes in the subtree + * (from the graph hierarchy induced tree) whose + * root is graphIx + * + * @arg node1: node1's ID + * @arg node2: node2's ID + * @arg layoutInfo: layoutInfo object + * + */ +var findLCA = function findLCA(node1, node2, layoutInfo) { + // Find their common ancester, starting from the root graph + var res = findLCA_aux(node1, node2, 0, layoutInfo); + if (2 > res.count) { + // If aux function couldn't find the common ancester, + // then it is the root graph + return 0; + } else { + return res.graph; + } +}; + +/** + * @brief : Auxiliary function used for LCA computation + * + * @arg node1 : node1's ID + * @arg node2 : node2's ID + * @arg graphIx : subgraph index + * @arg layoutInfo : layoutInfo object + * + * @return : object of the form {count: X, graph: Y}, where: + * X is the number of ancestors (max: 2) found in + * graphIx (and it's subgraphs), + * Y is the graph index of the lowest graph containing + * all X nodes + */ +var findLCA_aux = function findLCA_aux(node1, node2, graphIx, layoutInfo) { + var graph = layoutInfo.graphSet[graphIx]; + // If both nodes belongs to graphIx + if (-1 < graph.indexOf(node1) && -1 < graph.indexOf(node2)) { + return { + count: 2, + graph: graphIx + }; + } + + // Make recursive calls for all subgraphs + var c = 0; + for (var i = 0; i < graph.length; i++) { + var nodeId = graph[i]; + var nodeIx = layoutInfo.idToIndex[nodeId]; + var children = layoutInfo.layoutNodes[nodeIx].children; + + // If the node has no child, skip it + if (0 === children.length) { + continue; + } + var childGraphIx = layoutInfo.indexToGraph[layoutInfo.idToIndex[children[0]]]; + var result = findLCA_aux(node1, node2, childGraphIx, layoutInfo); + if (0 === result.count) { + // Neither node1 nor node2 are present in this subgraph + continue; + } else if (1 === result.count) { + // One of (node1, node2) is present in this subgraph + c++; + if (2 === c) { + // We've already found both nodes, no need to keep searching + break; + } + } else { + // Both nodes are present in this subgraph + return result; + } + } + return { + count: c, + graph: graphIx + }; +}; + +/** + * @brief: printsLayoutInfo into js console + * Only used for debbuging + */ +var printLayoutInfo; + +/** + * @brief : Randomizes the position of all nodes + */ +var randomizePositions = function randomizePositions(layoutInfo, cy) { + var width = layoutInfo.clientWidth; + var height = layoutInfo.clientHeight; + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + + // No need to randomize compound nodes or locked nodes + if (0 === n.children.length && !n.isLocked) { + n.positionX = Math.random() * width; + n.positionY = Math.random() * height; + } + } +}; +var getScaleInBoundsFn = function getScaleInBoundsFn(layoutInfo, options, nodes) { + var bb = layoutInfo.boundingBox; + var coseBB = { + x1: Infinity, + x2: -Infinity, + y1: Infinity, + y2: -Infinity + }; + if (options.boundingBox) { + nodes.forEach(function (node) { + var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[node.data('id')]]; + coseBB.x1 = Math.min(coseBB.x1, lnode.positionX); + coseBB.x2 = Math.max(coseBB.x2, lnode.positionX); + coseBB.y1 = Math.min(coseBB.y1, lnode.positionY); + coseBB.y2 = Math.max(coseBB.y2, lnode.positionY); + }); + coseBB.w = coseBB.x2 - coseBB.x1; + coseBB.h = coseBB.y2 - coseBB.y1; + } + return function (ele, i) { + var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[ele.data('id')]]; + if (options.boundingBox) { + // then add extra bounding box constraint + var pctX = (lnode.positionX - coseBB.x1) / coseBB.w; + var pctY = (lnode.positionY - coseBB.y1) / coseBB.h; + return { + x: bb.x1 + pctX * bb.w, + y: bb.y1 + pctY * bb.h + }; + } else { + return { + x: lnode.positionX, + y: lnode.positionY + }; + } + }; +}; + +/** + * @brief : Updates the positions of nodes in the network + * @arg layoutInfo : LayoutInfo object + * @arg cy : Cytoscape object + * @arg options : Layout options + */ +var refreshPositions = function refreshPositions(layoutInfo, cy, options) { + // var s = 'Refreshing positions'; + // logDebug(s); + + var layout = options.layout; + var nodes = options.eles.nodes(); + var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes); + nodes.positions(getScaledPos); + + // Trigger layoutReady only on first call + if (true !== layoutInfo.ready) { + // s = 'Triggering layoutready'; + // logDebug(s); + layoutInfo.ready = true; + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: this + }); + } +}; + +/** + * @brief : Logs a debug message in JS console, if DEBUG is ON + */ +// var logDebug = function(text) { +// if (DEBUG) { +// console.debug(text); +// } +// }; + +/** + * @brief : Performs one iteration of the physical simulation + * @arg layoutInfo : LayoutInfo object already initialized + * @arg cy : Cytoscape object + * @arg options : Layout options + */ +var step = function step(layoutInfo, options, _step) { + // var s = "\n\n###############################"; + // s += "\nSTEP: " + step; + // s += "\n###############################\n"; + // logDebug(s); + + // Calculate node repulsions + calculateNodeForces(layoutInfo, options); + // Calculate edge forces + calculateEdgeForces(layoutInfo); + // Calculate gravity forces + calculateGravityForces(layoutInfo, options); + // Propagate forces from parent to child + propagateForces(layoutInfo); + // Update positions based on calculated forces + updatePositions(layoutInfo); +}; + +/** + * @brief : Computes the node repulsion forces + */ +var calculateNodeForces = function calculateNodeForces(layoutInfo, options) { + // Go through each of the graphs in graphSet + // Nodes only repel each other if they belong to the same graph + // var s = 'calculateNodeForces'; + // logDebug(s); + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + var numNodes = graph.length; + + // s = "Set: " + graph.toString(); + // logDebug(s); + + // Now get all the pairs of nodes + // Only get each pair once, (A, B) = (B, A) + for (var j = 0; j < numNodes; j++) { + var node1 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; + for (var k = j + 1; k < numNodes; k++) { + var node2 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[k]]]; + nodeRepulsion(node1, node2, layoutInfo, options); + } + } + } +}; +var randomDistance = function randomDistance(max) { + return -max + 2 * max * Math.random(); +}; + +/** + * @brief : Compute the node repulsion forces between a pair of nodes + */ +var nodeRepulsion = function nodeRepulsion(node1, node2, layoutInfo, options) { + // var s = "Node repulsion. Node1: " + node1.id + " Node2: " + node2.id; + + var cmptId1 = node1.cmptId; + var cmptId2 = node2.cmptId; + if (cmptId1 !== cmptId2 && !layoutInfo.isCompound) { + return; + } + + // Get direction of line connecting both node centers + var directionX = node2.positionX - node1.positionX; + var directionY = node2.positionY - node1.positionY; + var maxRandDist = 1; + // s += "\ndirectionX: " + directionX + ", directionY: " + directionY; + + // If both centers are the same, apply a random force + if (0 === directionX && 0 === directionY) { + directionX = randomDistance(maxRandDist); + directionY = randomDistance(maxRandDist); + } + var overlap = nodesOverlap(node1, node2, directionX, directionY); + if (overlap > 0) { + // s += "\nNodes DO overlap."; + // s += "\nOverlap: " + overlap; + // If nodes overlap, repulsion force is proportional + // to the overlap + var force = options.nodeOverlap * overlap; + + // Compute the module and components of the force vector + var distance = Math.sqrt(directionX * directionX + directionY * directionY); + // s += "\nDistance: " + distance; + var forceX = force * directionX / distance; + var forceY = force * directionY / distance; + } else { + // s += "\nNodes do NOT overlap."; + // If there's no overlap, force is inversely proportional + // to squared distance + + // Get clipping points for both nodes + var point1 = findClippingPoint(node1, directionX, directionY); + var point2 = findClippingPoint(node2, -1 * directionX, -1 * directionY); + + // Use clipping points to compute distance + var distanceX = point2.x - point1.x; + var distanceY = point2.y - point1.y; + var distanceSqr = distanceX * distanceX + distanceY * distanceY; + var distance = Math.sqrt(distanceSqr); + // s += "\nDistance: " + distance; + + // Compute the module and components of the force vector + var force = (node1.nodeRepulsion + node2.nodeRepulsion) / distanceSqr; + var forceX = force * distanceX / distance; + var forceY = force * distanceY / distance; + } + + // Apply force + if (!node1.isLocked) { + node1.offsetX -= forceX; + node1.offsetY -= forceY; + } + if (!node2.isLocked) { + node2.offsetX += forceX; + node2.offsetY += forceY; + } + + // s += "\nForceX: " + forceX + " ForceY: " + forceY; + // logDebug(s); + + return; +}; + +/** + * @brief : Determines whether two nodes overlap or not + * @return : Amount of overlapping (0 => no overlap) + */ +var nodesOverlap = function nodesOverlap(node1, node2, dX, dY) { + if (dX > 0) { + var overlapX = node1.maxX - node2.minX; + } else { + var overlapX = node2.maxX - node1.minX; + } + if (dY > 0) { + var overlapY = node1.maxY - node2.minY; + } else { + var overlapY = node2.maxY - node1.minY; + } + if (overlapX >= 0 && overlapY >= 0) { + return Math.sqrt(overlapX * overlapX + overlapY * overlapY); + } else { + return 0; + } +}; + +/** + * @brief : Finds the point in which an edge (direction dX, dY) intersects + * the rectangular bounding box of it's source/target node + */ +var findClippingPoint = function findClippingPoint(node, dX, dY) { + // Shorcuts + var X = node.positionX; + var Y = node.positionY; + var H = node.height || 1; + var W = node.width || 1; + var dirSlope = dY / dX; + var nodeSlope = H / W; + + // var s = 'Computing clipping point of node ' + node.id + + // " . Height: " + H + ", Width: " + W + + // "\nDirection " + dX + ", " + dY; + // + // Compute intersection + var res = {}; + + // Case: Vertical direction (up) + if (0 === dX && 0 < dY) { + res.x = X; + // s += "\nUp direction"; + res.y = Y + H / 2; + return res; + } + + // Case: Vertical direction (down) + if (0 === dX && 0 > dY) { + res.x = X; + res.y = Y + H / 2; + // s += "\nDown direction"; + + return res; + } + + // Case: Intersects the right border + if (0 < dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) { + res.x = X + W / 2; + res.y = Y + W * dY / 2 / dX; + // s += "\nRightborder"; + + return res; + } + + // Case: Intersects the left border + if (0 > dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) { + res.x = X - W / 2; + res.y = Y - W * dY / 2 / dX; + // s += "\nLeftborder"; + + return res; + } + + // Case: Intersects the top border + if (0 < dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) { + res.x = X + H * dX / 2 / dY; + res.y = Y + H / 2; + // s += "\nTop border"; + + return res; + } + + // Case: Intersects the bottom border + if (0 > dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) { + res.x = X - H * dX / 2 / dY; + res.y = Y - H / 2; + // s += "\nBottom border"; + + return res; + } + + // s += "\nClipping point found at " + res.x + ", " + res.y; + // logDebug(s); + return res; +}; + +/** + * @brief : Calculates all edge forces + */ +var calculateEdgeForces = function calculateEdgeForces(layoutInfo, options) { + // Iterate over all edges + for (var i = 0; i < layoutInfo.edgeSize; i++) { + // Get edge, source & target nodes + var edge = layoutInfo.layoutEdges[i]; + var sourceIx = layoutInfo.idToIndex[edge.sourceId]; + var source = layoutInfo.layoutNodes[sourceIx]; + var targetIx = layoutInfo.idToIndex[edge.targetId]; + var target = layoutInfo.layoutNodes[targetIx]; + + // Get direction of line connecting both node centers + var directionX = target.positionX - source.positionX; + var directionY = target.positionY - source.positionY; + + // If both centers are the same, do nothing. + // A random force has already been applied as node repulsion + if (0 === directionX && 0 === directionY) { + continue; + } + + // Get clipping points for both nodes + var point1 = findClippingPoint(source, directionX, directionY); + var point2 = findClippingPoint(target, -1 * directionX, -1 * directionY); + var lx = point2.x - point1.x; + var ly = point2.y - point1.y; + var l = Math.sqrt(lx * lx + ly * ly); + var force = Math.pow(edge.idealLength - l, 2) / edge.elasticity; + if (0 !== l) { + var forceX = force * lx / l; + var forceY = force * ly / l; + } else { + var forceX = 0; + var forceY = 0; + } + + // Add this force to target and source nodes + if (!source.isLocked) { + source.offsetX += forceX; + source.offsetY += forceY; + } + if (!target.isLocked) { + target.offsetX -= forceX; + target.offsetY -= forceY; + } + + // var s = 'Edge force between nodes ' + source.id + ' and ' + target.id; + // s += "\nDistance: " + l + " Force: (" + forceX + ", " + forceY + ")"; + // logDebug(s); + } +}; + +/** + * @brief : Computes gravity forces for all nodes + */ +var calculateGravityForces = function calculateGravityForces(layoutInfo, options) { + if (options.gravity === 0) { + return; + } + var distThreshold = 1; + + // var s = 'calculateGravityForces'; + // logDebug(s); + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + var numNodes = graph.length; + + // s = "Set: " + graph.toString(); + // logDebug(s); + + // Compute graph center + if (0 === i) { + var centerX = layoutInfo.clientHeight / 2; + var centerY = layoutInfo.clientWidth / 2; + } else { + // Get Parent node for this graph, and use its position as center + var temp = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[0]]]; + var parent = layoutInfo.layoutNodes[layoutInfo.idToIndex[temp.parentId]]; + var centerX = parent.positionX; + var centerY = parent.positionY; + } + // s = "Center found at: " + centerX + ", " + centerY; + // logDebug(s); + + // Apply force to all nodes in graph + for (var j = 0; j < numNodes; j++) { + var node = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; + // s = "Node: " + node.id; + + if (node.isLocked) { + continue; + } + var dx = centerX - node.positionX; + var dy = centerY - node.positionY; + var d = Math.sqrt(dx * dx + dy * dy); + if (d > distThreshold) { + var fx = options.gravity * dx / d; + var fy = options.gravity * dy / d; + node.offsetX += fx; + node.offsetY += fy; + // s += ": Applied force: " + fx + ", " + fy; + } + // logDebug(s); + } + } +}; + +/** + * @brief : This function propagates the existing offsets from + * parent nodes to its descendents. + * @arg layoutInfo : layoutInfo Object + * @arg cy : cytoscape Object + * @arg options : Layout options + */ +var propagateForces = function propagateForces(layoutInfo, options) { + // Inline implementation of a queue, used for traversing the graph in BFS order + var queue = []; + var start = 0; // Points to the start the queue + var end = -1; // Points to the end of the queue + + // logDebug('propagateForces'); + + // Start by visiting the nodes in the root graph + queue.push.apply(queue, layoutInfo.graphSet[0]); + end += layoutInfo.graphSet[0].length; + + // Traverse the graph, level by level, + while (start <= end) { + // Get the node to visit and remove it from queue + var nodeId = queue[start++]; + var nodeIndex = layoutInfo.idToIndex[nodeId]; + var node = layoutInfo.layoutNodes[nodeIndex]; + var children = node.children; + + // We only need to process the node if it's compound + if (0 < children.length && !node.isLocked) { + var offX = node.offsetX; + var offY = node.offsetY; + + // var s = "Propagating offset from parent node : " + node.id + + // ". OffsetX: " + offX + ". OffsetY: " + offY; + // s += "\n Children: " + children.toString(); + // logDebug(s); + + for (var i = 0; i < children.length; i++) { + var childNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[children[i]]]; + // Propagate offset + childNode.offsetX += offX; + childNode.offsetY += offY; + // Add children to queue to be visited + queue[++end] = children[i]; + } + + // Reset parent offsets + node.offsetX = 0; + node.offsetY = 0; + } + } +}; + +/** + * @brief : Updates the layout model positions, based on + * the accumulated forces + */ +var updatePositions = function updatePositions(layoutInfo, options) { + // var s = 'Updating positions'; + // logDebug(s); + + // Reset boundaries for compound nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length) { + // logDebug("Resetting boundaries of compound node: " + n.id); + n.maxX = undefined; + n.minX = undefined; + n.maxY = undefined; + n.minY = undefined; + } + } + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length || n.isLocked) { + // No need to set compound or locked node position + // logDebug("Skipping position update of node: " + n.id); + continue; + } + // s = "Node: " + n.id + " Previous position: (" + + // n.positionX + ", " + n.positionY + ")."; + + // Limit displacement in order to improve stability + var tempForce = limitForce(n.offsetX, n.offsetY, layoutInfo.temperature); + n.positionX += tempForce.x; + n.positionY += tempForce.y; + n.offsetX = 0; + n.offsetY = 0; + n.minX = n.positionX - n.width; + n.maxX = n.positionX + n.width; + n.minY = n.positionY - n.height; + n.maxY = n.positionY + n.height; + // s += " New Position: (" + n.positionX + ", " + n.positionY + ")."; + // logDebug(s); + + // Update ancestry boudaries + updateAncestryBoundaries(n, layoutInfo); + } + + // Update size, position of compund nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length && !n.isLocked) { + n.positionX = (n.maxX + n.minX) / 2; + n.positionY = (n.maxY + n.minY) / 2; + n.width = n.maxX - n.minX; + n.height = n.maxY - n.minY; + // s = "Updating position, size of compound node " + n.id; + // s += "\nPositionX: " + n.positionX + ", PositionY: " + n.positionY; + // s += "\nWidth: " + n.width + ", Height: " + n.height; + // logDebug(s); + } + } +}; + +/** + * @brief : Limits a force (forceX, forceY) to be not + * greater (in modulo) than max. + 8 Preserves force direction. + */ +var limitForce = function limitForce(forceX, forceY, max) { + // var s = "Limiting force: (" + forceX + ", " + forceY + "). Max: " + max; + var force = Math.sqrt(forceX * forceX + forceY * forceY); + if (force > max) { + var res = { + x: max * forceX / force, + y: max * forceY / force + }; + } else { + var res = { + x: forceX, + y: forceY + }; + } + + // s += ".\nResult: (" + res.x + ", " + res.y + ")"; + // logDebug(s); + + return res; +}; + +/** + * @brief : Function used for keeping track of compound node + * sizes, since they should bound all their subnodes. + */ +var updateAncestryBoundaries = function updateAncestryBoundaries(node, layoutInfo) { + // var s = "Propagating new position/size of node " + node.id; + var parentId = node.parentId; + if (null == parentId) { + // If there's no parent, we are done + // s += ". No parent node."; + // logDebug(s); + return; + } + + // Get Parent Node + var p = layoutInfo.layoutNodes[layoutInfo.idToIndex[parentId]]; + var flag = false; + + // MaxX + if (null == p.maxX || node.maxX + p.padRight > p.maxX) { + p.maxX = node.maxX + p.padRight; + flag = true; + // s += "\nNew maxX for parent node " + p.id + ": " + p.maxX; + } + + // MinX + if (null == p.minX || node.minX - p.padLeft < p.minX) { + p.minX = node.minX - p.padLeft; + flag = true; + // s += "\nNew minX for parent node " + p.id + ": " + p.minX; + } + + // MaxY + if (null == p.maxY || node.maxY + p.padBottom > p.maxY) { + p.maxY = node.maxY + p.padBottom; + flag = true; + // s += "\nNew maxY for parent node " + p.id + ": " + p.maxY; + } + + // MinY + if (null == p.minY || node.minY - p.padTop < p.minY) { + p.minY = node.minY - p.padTop; + flag = true; + // s += "\nNew minY for parent node " + p.id + ": " + p.minY; + } + + // If updated boundaries, propagate changes upward + if (flag) { + // logDebug(s); + return updateAncestryBoundaries(p, layoutInfo); + } + + // s += ". No changes in boundaries/position of parent node " + p.id; + // logDebug(s); + return; +}; +var separateComponents = function separateComponents(layoutInfo, options) { + var nodes = layoutInfo.layoutNodes; + var components = []; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var cid = node.cmptId; + var component = components[cid] = components[cid] || []; + component.push(node); + } + var totalA = 0; + for (var i = 0; i < components.length; i++) { + var c = components[i]; + if (!c) { + continue; + } + c.x1 = Infinity; + c.x2 = -Infinity; + c.y1 = Infinity; + c.y2 = -Infinity; + for (var j = 0; j < c.length; j++) { + var n = c[j]; + c.x1 = Math.min(c.x1, n.positionX - n.width / 2); + c.x2 = Math.max(c.x2, n.positionX + n.width / 2); + c.y1 = Math.min(c.y1, n.positionY - n.height / 2); + c.y2 = Math.max(c.y2, n.positionY + n.height / 2); + } + c.w = c.x2 - c.x1; + c.h = c.y2 - c.y1; + totalA += c.w * c.h; + } + components.sort(function (c1, c2) { + return c2.w * c2.h - c1.w * c1.h; + }); + var x = 0; + var y = 0; + var usedW = 0; + var rowH = 0; + var maxRowW = Math.sqrt(totalA) * layoutInfo.clientWidth / layoutInfo.clientHeight; + for (var i = 0; i < components.length; i++) { + var c = components[i]; + if (!c) { + continue; + } + for (var j = 0; j < c.length; j++) { + var n = c[j]; + if (!n.isLocked) { + n.positionX += x - c.x1; + n.positionY += y - c.y1; + } + } + x += c.w + options.componentSpacing; + usedW += c.w + options.componentSpacing; + rowH = Math.max(rowH, c.h); + if (usedW > maxRowW) { + y += rowH + options.componentSpacing; + x = 0; + usedW = 0; + rowH = 0; + } + } +}; + +var defaults$3 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // padding used on fit + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + avoidOverlapPadding: 10, + // extra spacing around nodes when avoidOverlap: true + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + condense: false, + // uses all available space on false, uses minimal space on true + rows: undefined, + // force num of rows in the grid + cols: undefined, + // force num of columns in the grid + position: function position(node) {}, + // returns { row, col } for element + sort: undefined, + // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function GridLayout(options) { + this.options = extend({}, defaults$3, options); +} +GridLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().not(':parent'); + if (options.sort) { + nodes = nodes.sort(options.sort); + } + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + if (bb.h === 0 || bb.w === 0) { + eles.nodes().layoutPositions(this, options, function (ele) { + return { + x: bb.x1, + y: bb.y1 + }; + }); + } else { + // width/height * splits^2 = cells where splits is number of times to split width + var cells = nodes.size(); + var splits = Math.sqrt(cells * bb.h / bb.w); + var rows = Math.round(splits); + var cols = Math.round(bb.w / bb.h * splits); + var small = function small(val) { + if (val == null) { + return Math.min(rows, cols); + } else { + var min = Math.min(rows, cols); + if (min == rows) { + rows = val; + } else { + cols = val; + } + } + }; + var large = function large(val) { + if (val == null) { + return Math.max(rows, cols); + } else { + var max = Math.max(rows, cols); + if (max == rows) { + rows = val; + } else { + cols = val; + } + } + }; + var oRows = options.rows; + var oCols = options.cols != null ? options.cols : options.columns; + + // if rows or columns were set in options, use those values + if (oRows != null && oCols != null) { + rows = oRows; + cols = oCols; + } else if (oRows != null && oCols == null) { + rows = oRows; + cols = Math.ceil(cells / rows); + } else if (oRows == null && oCols != null) { + cols = oCols; + rows = Math.ceil(cells / cols); + } + + // otherwise use the automatic values and adjust accordingly + + // if rounding was up, see if we can reduce rows or columns + else if (cols * rows > cells) { + var sm = small(); + var lg = large(); + + // reducing the small side takes away the most cells, so try it first + if ((sm - 1) * lg >= cells) { + small(sm - 1); + } else if ((lg - 1) * sm >= cells) { + large(lg - 1); + } + } else { + // if rounding was too low, add rows or columns + while (cols * rows < cells) { + var _sm = small(); + var _lg = large(); + + // try to add to larger side first (adds less in multiplication) + if ((_lg + 1) * _sm >= cells) { + large(_lg + 1); + } else { + small(_sm + 1); + } + } + } + var cellWidth = bb.w / cols; + var cellHeight = bb.h / rows; + if (options.condense) { + cellWidth = 0; + cellHeight = 0; + } + if (options.avoidOverlap) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var pos = node._private.position; + if (pos.x == null || pos.y == null) { + // for bb + pos.x = 0; + pos.y = 0; + } + var nbb = node.layoutDimensions(options); + var p = options.avoidOverlapPadding; + var w = nbb.w + p; + var h = nbb.h + p; + cellWidth = Math.max(cellWidth, w); + cellHeight = Math.max(cellHeight, h); + } + } + var cellUsed = {}; // e.g. 'c-0-2' => true + + var used = function used(row, col) { + return cellUsed['c-' + row + '-' + col] ? true : false; + }; + var use = function use(row, col) { + cellUsed['c-' + row + '-' + col] = true; + }; + + // to keep track of current cell position + var row = 0; + var col = 0; + var moveToNextCell = function moveToNextCell() { + col++; + if (col >= cols) { + col = 0; + row++; + } + }; + + // get a cache of all the manual positions + var id2manPos = {}; + for (var _i = 0; _i < nodes.length; _i++) { + var _node = nodes[_i]; + var rcPos = options.position(_node); + if (rcPos && (rcPos.row !== undefined || rcPos.col !== undefined)) { + // must have at least row or col def'd + var _pos = { + row: rcPos.row, + col: rcPos.col + }; + if (_pos.col === undefined) { + // find unused col + _pos.col = 0; + while (used(_pos.row, _pos.col)) { + _pos.col++; + } + } else if (_pos.row === undefined) { + // find unused row + _pos.row = 0; + while (used(_pos.row, _pos.col)) { + _pos.row++; + } + } + id2manPos[_node.id()] = _pos; + use(_pos.row, _pos.col); + } + } + var getPos = function getPos(element, i) { + var x, y; + if (element.locked() || element.isParent()) { + return false; + } + + // see if we have a manual position set + var rcPos = id2manPos[element.id()]; + if (rcPos) { + x = rcPos.col * cellWidth + cellWidth / 2 + bb.x1; + y = rcPos.row * cellHeight + cellHeight / 2 + bb.y1; + } else { + // otherwise set automatically + + while (used(row, col)) { + moveToNextCell(); + } + x = col * cellWidth + cellWidth / 2 + bb.x1; + y = row * cellHeight + cellHeight / 2 + bb.y1; + use(row, col); + moveToNextCell(); + } + return { + x: x, + y: y + }; + }; + nodes.layoutPositions(this, options, getPos); + } + return this; // chaining +}; + +// default layout options +var defaults$2 = { + ready: function ready() {}, + // on layoutready + stop: function stop() {} // on layoutstop +}; + +// constructor +// options : object containing layout options +function NullLayout(options) { + this.options = extend({}, defaults$2, options); +} + +// runs the layout +NullLayout.prototype.run = function () { + var options = this.options; + var eles = options.eles; // elements to consider in the layout + var layout = this; + + // cy is automatically populated for us in the constructor + // (disable eslint for next line as this serves as example layout code to external developers) + // eslint-disable-next-line no-unused-vars + options.cy; + layout.emit('layoutstart'); + + // puts all nodes at (0, 0) + // n.b. most layouts would use layoutPositions(), instead of positions() and manual events + eles.nodes().positions(function () { + return { + x: 0, + y: 0 + }; + }); + + // trigger layoutready when each node has had its position set at least once + layout.one('layoutready', options.ready); + layout.emit('layoutready'); + + // trigger layoutstop when the layout stops (e.g. finishes) + layout.one('layoutstop', options.stop); + layout.emit('layoutstop'); + return this; // chaining +}; + +// called on continuous layouts to stop them before they finish +NullLayout.prototype.stop = function () { + return this; // chaining +}; + +var defaults$1 = { + positions: undefined, + // map of (node id) => (position obj); or function(node){ return somPos; } + zoom: undefined, + // the zoom level to set (prob want fit = false if set) + pan: undefined, + // the pan level to set (prob want fit = false if set) + fit: true, + // whether to fit to viewport + padding: 30, + // padding on fit + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function PresetLayout(options) { + this.options = extend({}, defaults$1, options); +} +PresetLayout.prototype.run = function () { + var options = this.options; + var eles = options.eles; + var nodes = eles.nodes(); + var posIsFn = fn$6(options.positions); + function getPosition(node) { + if (options.positions == null) { + return copyPosition(node.position()); + } + if (posIsFn) { + return options.positions(node); + } + var pos = options.positions[node._private.data.id]; + if (pos == null) { + return null; + } + return pos; + } + nodes.layoutPositions(this, options, function (node, i) { + var position = getPosition(node); + if (node.locked() || position == null) { + return false; + } + return position; + }); + return this; // chaining +}; + +var defaults = { + fit: true, + // whether to fit to viewport + padding: 30, + // fit padding + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function RandomLayout(options) { + this.options = extend({}, defaults, options); +} +RandomLayout.prototype.run = function () { + var options = this.options; + var cy = options.cy; + var eles = options.eles; + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var getPos = function getPos(node, i) { + return { + x: bb.x1 + Math.round(Math.random() * bb.w), + y: bb.y1 + Math.round(Math.random() * bb.h) + }; + }; + eles.nodes().layoutPositions(this, options, getPos); + return this; // chaining +}; + +var layout$1 = [{ + name: 'breadthfirst', + impl: BreadthFirstLayout +}, { + name: 'circle', + impl: CircleLayout +}, { + name: 'concentric', + impl: ConcentricLayout +}, { + name: 'cose', + impl: CoseLayout +}, { + name: 'grid', + impl: GridLayout +}, { + name: 'null', + impl: NullLayout +}, { + name: 'preset', + impl: PresetLayout +}, { + name: 'random', + impl: RandomLayout +}]; + +function NullRenderer(options) { + this.options = options; + this.notifications = 0; // for testing +} + +var noop = function noop() {}; +var throwImgErr = function throwImgErr() { + throw new Error('A headless instance can not render images'); +}; +NullRenderer.prototype = { + recalculateRenderedStyle: noop, + notify: function notify() { + this.notifications++; + }, + init: noop, + isHeadless: function isHeadless() { + return true; + }, + png: throwImgErr, + jpg: throwImgErr +}; + +var BRp$f = {}; +BRp$f.arrowShapeWidth = 0.3; +BRp$f.registerArrowShapes = function () { + var arrowShapes = this.arrowShapes = {}; + var renderer = this; + + // Contract for arrow shapes: + // 0, 0 is arrow tip + // (0, 1) is direction towards node + // (1, 0) is right + // + // functional api: + // collide: check x, y in shape + // roughCollide: called before collide, no false negatives + // draw: draw + // spacing: dist(arrowTip, nodeBoundary) + // gap: dist(edgeTip, nodeBoundary), edgeTip may != arrowTip + + var bbCollide = function bbCollide(x, y, size, angle, translation, edgeWidth, padding) { + var x1 = translation.x - size / 2 - padding; + var x2 = translation.x + size / 2 + padding; + var y1 = translation.y - size / 2 - padding; + var y2 = translation.y + size / 2 + padding; + var inside = x1 <= x && x <= x2 && y1 <= y && y <= y2; + return inside; + }; + var transform = function transform(x, y, size, angle, translation) { + var xRotated = x * Math.cos(angle) - y * Math.sin(angle); + var yRotated = x * Math.sin(angle) + y * Math.cos(angle); + var xScaled = xRotated * size; + var yScaled = yRotated * size; + var xTranslated = xScaled + translation.x; + var yTranslated = yScaled + translation.y; + return { + x: xTranslated, + y: yTranslated + }; + }; + var transformPoints = function transformPoints(pts, size, angle, translation) { + var retPts = []; + for (var i = 0; i < pts.length; i += 2) { + var x = pts[i]; + var y = pts[i + 1]; + retPts.push(transform(x, y, size, angle, translation)); + } + return retPts; + }; + var pointsToArr = function pointsToArr(pts) { + var ret = []; + for (var i = 0; i < pts.length; i++) { + var p = pts[i]; + ret.push(p.x, p.y); + } + return ret; + }; + var standardGap = function standardGap(edge) { + return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').pfValue * 2; + }; + var defineArrowShape = function defineArrowShape(name, defn) { + if (string(defn)) { + defn = arrowShapes[defn]; + } + arrowShapes[name] = extend({ + name: name, + points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3], + collide: function collide(x, y, size, angle, translation, padding) { + var points = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, points); + return inside; + }, + roughCollide: bbCollide, + draw: function draw(context, size, angle, translation) { + var points = transformPoints(this.points, size, angle, translation); + renderer.arrowShapeImpl('polygon')(context, points); + }, + spacing: function spacing(edge) { + return 0; + }, + gap: standardGap + }, defn); + }; + defineArrowShape('none', { + collide: falsify, + roughCollide: falsify, + draw: noop$1, + spacing: zeroify, + gap: zeroify + }); + defineArrowShape('triangle', { + points: [-0.15, -0.3, 0, 0, 0.15, -0.3] + }); + defineArrowShape('arrow', 'triangle'); + defineArrowShape('triangle-backcurve', { + points: arrowShapes['triangle'].points, + controlPoint: [0, -0.15], + roughCollide: bbCollide, + draw: function draw(context, size, angle, translation, edgeWidth) { + var ptsTrans = transformPoints(this.points, size, angle, translation); + var ctrlPt = this.controlPoint; + var ctrlPtTrans = transform(ctrlPt[0], ctrlPt[1], size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, ptsTrans, ctrlPtTrans); + }, + gap: function gap(edge) { + return standardGap(edge) * 0.8; + } + }); + defineArrowShape('triangle-tee', { + points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0], + pointsTee: [-0.15, -0.4, -0.15, -0.5, 0.15, -0.5, 0.15, -0.4], + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var teePts = pointsToArr(transformPoints(this.pointsTee, size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, triPts) || pointInsidePolygonPoints(x, y, teePts); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.points, size, angle, translation); + var teePts = transformPoints(this.pointsTee, size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, teePts); + } + }); + defineArrowShape('circle-triangle', { + radius: 0.15, + pointsTr: [0, -0.15, 0.15, -0.45, -0.15, -0.45, 0, -0.15], + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var t = translation; + var circleInside = Math.pow(t.x - x, 2) + Math.pow(t.y - y, 2) <= Math.pow((size + 2 * padding) * this.radius, 2); + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + return pointInsidePolygonPoints(x, y, triPts) || circleInside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.pointsTr, size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, translation.x, translation.y, this.radius * size); + }, + spacing: function spacing(edge) { + return renderer.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.radius; + } + }); + defineArrowShape('triangle-cross', { + points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0], + baseCrossLinePts: [-0.15, -0.4, + // first half of the rectangle + -0.15, -0.4, 0.15, -0.4, + // second half of the rectangle + 0.15, -0.4], + crossLinePts: function crossLinePts(size, edgeWidth) { + // shift points so that the distance between the cross points matches edge width + var p = this.baseCrossLinePts.slice(); + var shiftFactor = edgeWidth / size; + var y0 = 3; + var y1 = 5; + p[y0] = p[y0] - shiftFactor; + p[y1] = p[y1] - shiftFactor; + return p; + }, + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var teePts = pointsToArr(transformPoints(this.crossLinePts(size, edgeWidth), size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, triPts) || pointInsidePolygonPoints(x, y, teePts); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.points, size, angle, translation); + var crossLinePts = transformPoints(this.crossLinePts(size, edgeWidth), size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, crossLinePts); + } + }); + defineArrowShape('vee', { + points: [-0.15, -0.3, 0, 0, 0.15, -0.3, 0, -0.15], + gap: function gap(edge) { + return standardGap(edge) * 0.525; + } + }); + defineArrowShape('circle', { + radius: 0.15, + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var t = translation; + var inside = Math.pow(t.x - x, 2) + Math.pow(t.y - y, 2) <= Math.pow((size + 2 * padding) * this.radius, 2); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + renderer.arrowShapeImpl(this.name)(context, translation.x, translation.y, this.radius * size); + }, + spacing: function spacing(edge) { + return renderer.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.radius; + } + }); + defineArrowShape('tee', { + points: [-0.15, 0, -0.15, -0.1, 0.15, -0.1, 0.15, 0], + spacing: function spacing(edge) { + return 1; + }, + gap: function gap(edge) { + return 1; + } + }); + defineArrowShape('square', { + points: [-0.15, 0.00, 0.15, 0.00, 0.15, -0.3, -0.15, -0.3] + }); + defineArrowShape('diamond', { + points: [-0.15, -0.15, 0, -0.3, 0.15, -0.15, 0, 0], + gap: function gap(edge) { + return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').value; + } + }); + defineArrowShape('chevron', { + points: [0, 0, -0.15, -0.15, -0.1, -0.2, 0, -0.1, 0.1, -0.2, 0.15, -0.15], + gap: function gap(edge) { + return 0.95 * edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').value; + } + }); +}; + +var BRp$e = {}; + +// Project mouse +BRp$e.projectIntoViewport = function (clientX, clientY) { + var cy = this.cy; + var offsets = this.findContainerClientCoords(); + var offsetLeft = offsets[0]; + var offsetTop = offsets[1]; + var scale = offsets[4]; + var pan = cy.pan(); + var zoom = cy.zoom(); + var x = ((clientX - offsetLeft) / scale - pan.x) / zoom; + var y = ((clientY - offsetTop) / scale - pan.y) / zoom; + return [x, y]; +}; +BRp$e.findContainerClientCoords = function () { + if (this.containerBB) { + return this.containerBB; + } + var container = this.container; + var rect = container.getBoundingClientRect(); + var style = this.cy.window().getComputedStyle(container); + var styleValue = function styleValue(name) { + return parseFloat(style.getPropertyValue(name)); + }; + var padding = { + left: styleValue('padding-left'), + right: styleValue('padding-right'), + top: styleValue('padding-top'), + bottom: styleValue('padding-bottom') + }; + var border = { + left: styleValue('border-left-width'), + right: styleValue('border-right-width'), + top: styleValue('border-top-width'), + bottom: styleValue('border-bottom-width') + }; + var clientWidth = container.clientWidth; + var clientHeight = container.clientHeight; + var paddingHor = padding.left + padding.right; + var paddingVer = padding.top + padding.bottom; + var borderHor = border.left + border.right; + var scale = rect.width / (clientWidth + borderHor); + var unscaledW = clientWidth - paddingHor; + var unscaledH = clientHeight - paddingVer; + var left = rect.left + padding.left + border.left; + var top = rect.top + padding.top + border.top; + return this.containerBB = [left, top, unscaledW, unscaledH, scale]; +}; +BRp$e.invalidateContainerClientCoordsCache = function () { + this.containerBB = null; +}; +BRp$e.findNearestElement = function (x, y, interactiveElementsOnly, isTouch) { + return this.findNearestElements(x, y, interactiveElementsOnly, isTouch)[0]; +}; +BRp$e.findNearestElements = function (x, y, interactiveElementsOnly, isTouch) { + var self = this; + var r = this; + var eles = r.getCachedZSortedEles(); + var near = []; // 1 node max, 1 edge max + var zoom = r.cy.zoom(); + var hasCompounds = r.cy.hasCompoundNodes(); + var edgeThreshold = (isTouch ? 24 : 8) / zoom; + var nodeThreshold = (isTouch ? 8 : 2) / zoom; + var labelThreshold = (isTouch ? 8 : 2) / zoom; + var minSqDist = Infinity; + var nearEdge; + var nearNode; + if (interactiveElementsOnly) { + eles = eles.interactive; + } + function addEle(ele, sqDist) { + if (ele.isNode()) { + if (nearNode) { + return; // can't replace node + } else { + nearNode = ele; + near.push(ele); + } + } + if (ele.isEdge() && (sqDist == null || sqDist < minSqDist)) { + if (nearEdge) { + // then replace existing edge + // can replace only if same z-index + if (nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value && nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value) { + for (var i = 0; i < near.length; i++) { + if (near[i].isEdge()) { + near[i] = ele; + nearEdge = ele; + minSqDist = sqDist != null ? sqDist : minSqDist; + break; + } + } + } + } else { + near.push(ele); + nearEdge = ele; + minSqDist = sqDist != null ? sqDist : minSqDist; + } + } + } + function checkNode(node) { + var width = node.outerWidth() + 2 * nodeThreshold; + var height = node.outerHeight() + 2 * nodeThreshold; + var hw = width / 2; + var hh = height / 2; + var pos = node.position(); + var cornerRadius = node.pstyle('corner-radius').value === 'auto' ? 'auto' : node.pstyle('corner-radius').pfValue; + var rs = node._private.rscratch; + if (pos.x - hw <= x && x <= pos.x + hw // bb check x + && pos.y - hh <= y && y <= pos.y + hh // bb check y + ) { + var shape = r.nodeShapes[self.getNodeShape(node)]; + if (shape.checkPoint(x, y, 0, width, height, pos.x, pos.y, cornerRadius, rs)) { + addEle(node, 0); + return true; + } + } + } + function checkEdge(edge) { + var _p = edge._private; + var rs = _p.rscratch; + var styleWidth = edge.pstyle('width').pfValue; + var scale = edge.pstyle('arrow-scale').value; + var width = styleWidth / 2 + edgeThreshold; // more like a distance radius from centre + var widthSq = width * width; + var width2 = width * 2; + var src = _p.source; + var tgt = _p.target; + var sqDist; + if (rs.edgeType === 'segments' || rs.edgeType === 'straight' || rs.edgeType === 'haystack') { + var pts = rs.allpts; + for (var i = 0; i + 3 < pts.length; i += 2) { + if (inLineVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], width2) && widthSq > (sqDist = sqdistToFiniteLine(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3]))) { + addEle(edge, sqDist); + return true; + } + } + } else if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') { + var pts = rs.allpts; + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + if (inBezierVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5], width2) && widthSq > (sqDist = sqdistToQuadraticBezier(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5]))) { + addEle(edge, sqDist); + return true; + } + } + } + + // if we're close to the edge but didn't hit it, maybe we hit its arrows + + var src = src || _p.source; + var tgt = tgt || _p.target; + var arSize = self.getArrowWidth(styleWidth, scale); + var arrows = [{ + name: 'source', + x: rs.arrowStartX, + y: rs.arrowStartY, + angle: rs.srcArrowAngle + }, { + name: 'target', + x: rs.arrowEndX, + y: rs.arrowEndY, + angle: rs.tgtArrowAngle + }, { + name: 'mid-source', + x: rs.midX, + y: rs.midY, + angle: rs.midsrcArrowAngle + }, { + name: 'mid-target', + x: rs.midX, + y: rs.midY, + angle: rs.midtgtArrowAngle + }]; + for (var i = 0; i < arrows.length; i++) { + var ar = arrows[i]; + var shape = r.arrowShapes[edge.pstyle(ar.name + '-arrow-shape').value]; + var edgeWidth = edge.pstyle('width').pfValue; + if (shape.roughCollide(x, y, arSize, ar.angle, { + x: ar.x, + y: ar.y + }, edgeWidth, edgeThreshold) && shape.collide(x, y, arSize, ar.angle, { + x: ar.x, + y: ar.y + }, edgeWidth, edgeThreshold)) { + addEle(edge); + return true; + } + } + + // for compound graphs, hitting edge may actually want a connected node instead (b/c edge may have greater z-index precedence) + if (hasCompounds && near.length > 0) { + checkNode(src); + checkNode(tgt); + } + } + function preprop(obj, name, pre) { + return getPrefixedProperty(obj, name, pre); + } + function checkLabel(ele, prefix) { + var _p = ele._private; + var th = labelThreshold; + var prefixDash; + if (prefix) { + prefixDash = prefix + '-'; + } else { + prefixDash = ''; + } + ele.boundingBox(); + var bb = _p.labelBounds[prefix || 'main']; + var text = ele.pstyle(prefixDash + 'label').value; + var eventsEnabled = ele.pstyle('text-events').strValue === 'yes'; + if (!eventsEnabled || !text) { + return; + } + var lx = preprop(_p.rscratch, 'labelX', prefix); + var ly = preprop(_p.rscratch, 'labelY', prefix); + var theta = preprop(_p.rscratch, 'labelAngle', prefix); + var ox = ele.pstyle(prefixDash + 'text-margin-x').pfValue; + var oy = ele.pstyle(prefixDash + 'text-margin-y').pfValue; + var lx1 = bb.x1 - th - ox; // (-ox, -oy) as bb already includes margin + var lx2 = bb.x2 + th - ox; // and rotation is about (lx, ly) + var ly1 = bb.y1 - th - oy; + var ly2 = bb.y2 + th - oy; + if (theta) { + var cos = Math.cos(theta); + var sin = Math.sin(theta); + var rotate = function rotate(x, y) { + x = x - lx; + y = y - ly; + return { + x: x * cos - y * sin + lx, + y: x * sin + y * cos + ly + }; + }; + var px1y1 = rotate(lx1, ly1); + var px1y2 = rotate(lx1, ly2); + var px2y1 = rotate(lx2, ly1); + var px2y2 = rotate(lx2, ly2); + var points = [ + // with the margin added after the rotation is applied + px1y1.x + ox, px1y1.y + oy, px2y1.x + ox, px2y1.y + oy, px2y2.x + ox, px2y2.y + oy, px1y2.x + ox, px1y2.y + oy]; + if (pointInsidePolygonPoints(x, y, points)) { + addEle(ele); + return true; + } + } else { + // do a cheaper bb check + if (inBoundingBox(bb, x, y)) { + addEle(ele); + return true; + } + } + } + for (var i = eles.length - 1; i >= 0; i--) { + // reverse order for precedence + var ele = eles[i]; + if (ele.isNode()) { + checkNode(ele) || checkLabel(ele); + } else { + // then edge + checkEdge(ele) || checkLabel(ele) || checkLabel(ele, 'source') || checkLabel(ele, 'target'); + } + } + return near; +}; + +// 'Give me everything from this box' +BRp$e.getAllInBox = function (x1, y1, x2, y2) { + var eles = this.getCachedZSortedEles().interactive; + var box = []; + var x1c = Math.min(x1, x2); + var x2c = Math.max(x1, x2); + var y1c = Math.min(y1, y2); + var y2c = Math.max(y1, y2); + x1 = x1c; + x2 = x2c; + y1 = y1c; + y2 = y2c; + var boxBb = makeBoundingBox({ + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }); + for (var e = 0; e < eles.length; e++) { + var ele = eles[e]; + if (ele.isNode()) { + var node = ele; + var nodeBb = node.boundingBox({ + includeNodes: true, + includeEdges: false, + includeLabels: false + }); + if (boundingBoxesIntersect(boxBb, nodeBb) && !boundingBoxInBoundingBox(nodeBb, boxBb)) { + box.push(node); + } + } else { + var edge = ele; + var _p = edge._private; + var rs = _p.rscratch; + if (rs.startX != null && rs.startY != null && !inBoundingBox(boxBb, rs.startX, rs.startY)) { + continue; + } + if (rs.endX != null && rs.endY != null && !inBoundingBox(boxBb, rs.endX, rs.endY)) { + continue; + } + if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound' || rs.edgeType === 'segments' || rs.edgeType === 'haystack') { + var pts = _p.rstyle.bezierPts || _p.rstyle.linePts || _p.rstyle.haystackPts; + var allInside = true; + for (var i = 0; i < pts.length; i++) { + if (!pointInBoundingBox(boxBb, pts[i])) { + allInside = false; + break; + } + } + if (allInside) { + box.push(edge); + } + } else if (rs.edgeType === 'haystack' || rs.edgeType === 'straight') { + box.push(edge); + } + } + } + return box; +}; + +var BRp$d = {}; +BRp$d.calculateArrowAngles = function (edge) { + var rs = edge._private.rscratch; + var isHaystack = rs.edgeType === 'haystack'; + var isBezier = rs.edgeType === 'bezier'; + var isMultibezier = rs.edgeType === 'multibezier'; + var isSegments = rs.edgeType === 'segments'; + var isCompound = rs.edgeType === 'compound'; + var isSelf = rs.edgeType === 'self'; + + // Displacement gives direction for arrowhead orientation + var dispX, dispY; + var startX, startY, endX, endY, midX, midY; + if (isHaystack) { + startX = rs.haystackPts[0]; + startY = rs.haystackPts[1]; + endX = rs.haystackPts[2]; + endY = rs.haystackPts[3]; + } else { + startX = rs.arrowStartX; + startY = rs.arrowStartY; + endX = rs.arrowEndX; + endY = rs.arrowEndY; + } + midX = rs.midX; + midY = rs.midY; + + // source + // + + if (isSegments) { + dispX = startX - rs.segpts[0]; + dispY = startY - rs.segpts[1]; + } else if (isMultibezier || isCompound || isSelf || isBezier) { + var pts = rs.allpts; + var bX = qbezierAt(pts[0], pts[2], pts[4], 0.1); + var bY = qbezierAt(pts[1], pts[3], pts[5], 0.1); + dispX = startX - bX; + dispY = startY - bY; + } else { + dispX = startX - midX; + dispY = startY - midY; + } + rs.srcArrowAngle = getAngleFromDisp(dispX, dispY); + + // mid target + // + + var midX = rs.midX; + var midY = rs.midY; + if (isHaystack) { + midX = (startX + endX) / 2; + midY = (startY + endY) / 2; + } + dispX = endX - startX; + dispY = endY - startY; + if (isSegments) { + var pts = rs.allpts; + if (pts.length / 2 % 2 === 0) { + var i2 = pts.length / 2; + var i1 = i2 - 2; + dispX = pts[i2] - pts[i1]; + dispY = pts[i2 + 1] - pts[i1 + 1]; + } else if (rs.isRound) { + dispX = rs.midVector[1]; + dispY = -rs.midVector[0]; + } else { + var i2 = pts.length / 2 - 1; + var i1 = i2 - 2; + dispX = pts[i2] - pts[i1]; + dispY = pts[i2 + 1] - pts[i1 + 1]; + } + } else if (isMultibezier || isCompound || isSelf) { + var pts = rs.allpts; + var cpts = rs.ctrlpts; + var bp0x, bp0y; + var bp1x, bp1y; + if (cpts.length / 2 % 2 === 0) { + var p0 = pts.length / 2 - 1; // startpt + var ic = p0 + 2; + var p1 = ic + 2; + bp0x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.0); + bp0y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.0); + bp1x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.0001); + bp1y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.0001); + } else { + var ic = pts.length / 2 - 1; // ctrpt + var p0 = ic - 2; // startpt + var p1 = ic + 2; // endpt + + bp0x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.4999); + bp0y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.4999); + bp1x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.5); + bp1y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.5); + } + dispX = bp1x - bp0x; + dispY = bp1y - bp0y; + } + rs.midtgtArrowAngle = getAngleFromDisp(dispX, dispY); + rs.midDispX = dispX; + rs.midDispY = dispY; + + // mid source + // + + dispX *= -1; + dispY *= -1; + if (isSegments) { + var pts = rs.allpts; + if (pts.length / 2 % 2 === 0) ; else if (!rs.isRound) { + var i2 = pts.length / 2 - 1; + var i3 = i2 + 2; + dispX = -(pts[i3] - pts[i2]); + dispY = -(pts[i3 + 1] - pts[i2 + 1]); + } + } + rs.midsrcArrowAngle = getAngleFromDisp(dispX, dispY); + + // target + // + + if (isSegments) { + dispX = endX - rs.segpts[rs.segpts.length - 2]; + dispY = endY - rs.segpts[rs.segpts.length - 1]; + } else if (isMultibezier || isCompound || isSelf || isBezier) { + var pts = rs.allpts; + var l = pts.length; + var bX = qbezierAt(pts[l - 6], pts[l - 4], pts[l - 2], 0.9); + var bY = qbezierAt(pts[l - 5], pts[l - 3], pts[l - 1], 0.9); + dispX = endX - bX; + dispY = endY - bY; + } else { + dispX = endX - midX; + dispY = endY - midY; + } + rs.tgtArrowAngle = getAngleFromDisp(dispX, dispY); +}; +BRp$d.getArrowWidth = BRp$d.getArrowHeight = function (edgeWidth, scale) { + var cache = this.arrowWidthCache = this.arrowWidthCache || {}; + var cachedVal = cache[edgeWidth + ', ' + scale]; + if (cachedVal) { + return cachedVal; + } + cachedVal = Math.max(Math.pow(edgeWidth * 13.37, 0.9), 29) * scale; + cache[edgeWidth + ', ' + scale] = cachedVal; + return cachedVal; +}; + +/** + * Explained by Blindman67 at https://stackoverflow.com/a/44856925/11028828 + */ + +// Declare reused variable to avoid reallocating variables every time the function is called +var x$1, + y$1, + v1 = {}, + v2 = {}, + sinA, + sinA90, + radDirection, + drawDirection, + angle, + halfAngle, + cRadius, + lenOut, + radius, + limit; +var startX, startY, stopX, stopY; +var lastPoint; + +// convert 2 points into vector form, polar form, and normalised +var asVec = function asVec(p, pp, v) { + v.x = pp.x - p.x; + v.y = pp.y - p.y; + v.len = Math.sqrt(v.x * v.x + v.y * v.y); + v.nx = v.x / v.len; + v.ny = v.y / v.len; + v.ang = Math.atan2(v.ny, v.nx); +}; +var invertVec = function invertVec(originalV, invertedV) { + invertedV.x = originalV.x * -1; + invertedV.y = originalV.y * -1; + invertedV.nx = originalV.nx * -1; + invertedV.ny = originalV.ny * -1; + invertedV.ang = originalV.ang > 0 ? -(Math.PI - originalV.ang) : Math.PI + originalV.ang; +}; +var calcCornerArc = function calcCornerArc(previousPoint, currentPoint, nextPoint, radiusMax, isArcRadius) { + //----------------------------------------- + // Part 1 + previousPoint !== lastPoint ? asVec(currentPoint, previousPoint, v1) : invertVec(v2, v1); // Avoid recalculating vec if it is the invert of the last one calculated + asVec(currentPoint, nextPoint, v2); + sinA = v1.nx * v2.ny - v1.ny * v2.nx; + sinA90 = v1.nx * v2.nx - v1.ny * -v2.ny; + angle = Math.asin(Math.max(-1, Math.min(1, sinA))); + if (Math.abs(angle) < 1e-6) { + x$1 = currentPoint.x; + y$1 = currentPoint.y; + cRadius = radius = 0; + return; + } + //----------------------------------------- + radDirection = 1; + drawDirection = false; + if (sinA90 < 0) { + if (angle < 0) { + angle = Math.PI + angle; + } else { + angle = Math.PI - angle; + radDirection = -1; + drawDirection = true; + } + } else { + if (angle > 0) { + radDirection = -1; + drawDirection = true; + } + } + if (currentPoint.radius !== undefined) { + radius = currentPoint.radius; + } else { + radius = radiusMax; + } + //----------------------------------------- + // Part 2 + halfAngle = angle / 2; + //----------------------------------------- + + limit = Math.min(v1.len / 2, v2.len / 2); + if (isArcRadius) { + //----------------------------------------- + // Part 3 + lenOut = Math.abs(Math.cos(halfAngle) * radius / Math.sin(halfAngle)); + + //----------------------------------------- + // Special part A + if (lenOut > limit) { + lenOut = limit; + cRadius = Math.abs(lenOut * Math.sin(halfAngle) / Math.cos(halfAngle)); + } else { + cRadius = radius; + } + } else { + lenOut = Math.min(limit, radius); + cRadius = Math.abs(lenOut * Math.sin(halfAngle) / Math.cos(halfAngle)); + } + //----------------------------------------- + + //----------------------------------------- + // Part 4 + stopX = currentPoint.x + v2.nx * lenOut; + stopY = currentPoint.y + v2.ny * lenOut; + //----------------------------------------- + // Part 5 + x$1 = stopX - v2.ny * cRadius * radDirection; + y$1 = stopY + v2.nx * cRadius * radDirection; + //----------------------------------------- + // Additional Part : calculate start point E + startX = currentPoint.x + v1.nx * lenOut; + startY = currentPoint.y + v1.ny * lenOut; + + // Save last point to avoid recalculating vector when not needed + lastPoint = currentPoint; +}; + +/** + * Draw corner provided by {@link getRoundCorner} + * + * @param ctx :CanvasRenderingContext2D + * @param roundCorner {{cx:number, cy:number, radius:number, endAngle: number, startAngle: number, counterClockwise: boolean}} + */ +function drawPreparedRoundCorner(ctx, roundCorner) { + if (roundCorner.radius === 0) ctx.lineTo(roundCorner.cx, roundCorner.cy);else ctx.arc(roundCorner.cx, roundCorner.cy, roundCorner.radius, roundCorner.startAngle, roundCorner.endAngle, roundCorner.counterClockwise); +} + +/** + * Get round corner from a point and its previous and next neighbours in a path + * + * @param previousPoint {{x: number, y:number, radius: number?}} + * @param currentPoint {{x: number, y:number, radius: number?}} + * @param nextPoint {{x: number, y:number, radius: number?}} + * @param radiusMax :number + * @param isArcRadius :boolean + * @return {{ + * cx:number, cy:number, radius:number, + * startX:number, startY:number, + * stopX:number, stopY: number, + * endAngle: number, startAngle: number, counterClockwise: boolean + * }} + */ +function getRoundCorner(previousPoint, currentPoint, nextPoint, radiusMax) { + var isArcRadius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + if (radiusMax === 0 || currentPoint.radius === 0) return { + cx: currentPoint.x, + cy: currentPoint.y, + radius: 0, + startX: currentPoint.x, + startY: currentPoint.y, + stopX: currentPoint.x, + stopY: currentPoint.y, + startAngle: undefined, + endAngle: undefined, + counterClockwise: undefined + }; + calcCornerArc(previousPoint, currentPoint, nextPoint, radiusMax, isArcRadius); + return { + cx: x$1, + cy: y$1, + radius: cRadius, + startX: startX, + startY: startY, + stopX: stopX, + stopY: stopY, + startAngle: v1.ang + Math.PI / 2 * radDirection, + endAngle: v2.ang - Math.PI / 2 * radDirection, + counterClockwise: drawDirection + }; +} + +var BRp$c = {}; +BRp$c.findMidptPtsEtc = function (edge, pairInfo) { + var posPts = pairInfo.posPts, + intersectionPts = pairInfo.intersectionPts, + vectorNormInverse = pairInfo.vectorNormInverse; + var midptPts; + + // n.b. assumes all edges in bezier bundle have same endpoints specified + var srcManEndpt = edge.pstyle('source-endpoint'); + var tgtManEndpt = edge.pstyle('target-endpoint'); + var haveManualEndPts = srcManEndpt.units != null && tgtManEndpt.units != null; + var recalcVectorNormInverse = function recalcVectorNormInverse(x1, y1, x2, y2) { + var dy = y2 - y1; + var dx = x2 - x1; + var l = Math.sqrt(dx * dx + dy * dy); + return { + x: -dy / l, + y: dx / l + }; + }; + var edgeDistances = edge.pstyle('edge-distances').value; + switch (edgeDistances) { + case 'node-position': + midptPts = posPts; + break; + case 'intersection': + midptPts = intersectionPts; + break; + case 'endpoints': + { + if (haveManualEndPts) { + var _this$manualEndptToPx = this.manualEndptToPx(edge.source()[0], srcManEndpt), + _this$manualEndptToPx2 = _slicedToArray(_this$manualEndptToPx, 2), + x1 = _this$manualEndptToPx2[0], + y1 = _this$manualEndptToPx2[1]; + var _this$manualEndptToPx3 = this.manualEndptToPx(edge.target()[0], tgtManEndpt), + _this$manualEndptToPx4 = _slicedToArray(_this$manualEndptToPx3, 2), + x2 = _this$manualEndptToPx4[0], + y2 = _this$manualEndptToPx4[1]; + var endPts = { + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }; + vectorNormInverse = recalcVectorNormInverse(x1, y1, x2, y2); + midptPts = endPts; + } else { + warn("Edge ".concat(edge.id(), " has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")); + midptPts = intersectionPts; // back to default + } + + break; + } + } + return { + midptPts: midptPts, + vectorNormInverse: vectorNormInverse + }; +}; +BRp$c.findHaystackPoints = function (edges) { + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var _p = edge._private; + var rs = _p.rscratch; + if (!rs.haystack) { + var angle = Math.random() * 2 * Math.PI; + rs.source = { + x: Math.cos(angle), + y: Math.sin(angle) + }; + angle = Math.random() * 2 * Math.PI; + rs.target = { + x: Math.cos(angle), + y: Math.sin(angle) + }; + } + var src = _p.source; + var tgt = _p.target; + var srcPos = src.position(); + var tgtPos = tgt.position(); + var srcW = src.width(); + var tgtW = tgt.width(); + var srcH = src.height(); + var tgtH = tgt.height(); + var radius = edge.pstyle('haystack-radius').value; + var halfRadius = radius / 2; // b/c have to half width/height + + rs.haystackPts = rs.allpts = [rs.source.x * srcW * halfRadius + srcPos.x, rs.source.y * srcH * halfRadius + srcPos.y, rs.target.x * tgtW * halfRadius + tgtPos.x, rs.target.y * tgtH * halfRadius + tgtPos.y]; + rs.midX = (rs.allpts[0] + rs.allpts[2]) / 2; + rs.midY = (rs.allpts[1] + rs.allpts[3]) / 2; + + // always override as haystack in case set to different type previously + rs.edgeType = 'haystack'; + rs.haystack = true; + this.storeEdgeProjections(edge); + this.calculateArrowAngles(edge); + this.recalculateEdgeLabelProjections(edge); + this.calculateLabelAngles(edge); + } +}; +BRp$c.findSegmentsPoints = function (edge, pairInfo) { + // Segments (multiple straight lines) + + var rs = edge._private.rscratch; + var segmentWs = edge.pstyle('segment-weights'); + var segmentDs = edge.pstyle('segment-distances'); + var segmentRs = edge.pstyle('segment-radii'); + var segmentTs = edge.pstyle('radius-type'); + var segmentsN = Math.min(segmentWs.pfValue.length, segmentDs.pfValue.length); + var lastRadius = segmentRs.pfValue[segmentRs.pfValue.length - 1]; + var lastRadiusType = segmentTs.pfValue[segmentTs.pfValue.length - 1]; + rs.edgeType = 'segments'; + rs.segpts = []; + rs.radii = []; + rs.isArcRadius = []; + for (var s = 0; s < segmentsN; s++) { + var w = segmentWs.pfValue[s]; + var d = segmentDs.pfValue[s]; + var w1 = 1 - w; + var w2 = w; + var _this$findMidptPtsEtc = this.findMidptPtsEtc(edge, pairInfo), + midptPts = _this$findMidptPtsEtc.midptPts, + vectorNormInverse = _this$findMidptPtsEtc.vectorNormInverse; + var adjustedMidpt = { + x: midptPts.x1 * w1 + midptPts.x2 * w2, + y: midptPts.y1 * w1 + midptPts.y2 * w2 + }; + rs.segpts.push(adjustedMidpt.x + vectorNormInverse.x * d, adjustedMidpt.y + vectorNormInverse.y * d); + rs.radii.push(segmentRs.pfValue[s] !== undefined ? segmentRs.pfValue[s] : lastRadius); + rs.isArcRadius.push((segmentTs.pfValue[s] !== undefined ? segmentTs.pfValue[s] : lastRadiusType) === 'arc-radius'); + } +}; +BRp$c.findLoopPoints = function (edge, pairInfo, i, edgeIsUnbundled) { + // Self-edge + + var rs = edge._private.rscratch; + var dirCounts = pairInfo.dirCounts, + srcPos = pairInfo.srcPos; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var loopDir = edge.pstyle('loop-direction').pfValue; + var loopSwp = edge.pstyle('loop-sweep').pfValue; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + rs.edgeType = 'self'; + var j = i; + var loopDist = stepSize; + if (edgeIsUnbundled) { + j = 0; + loopDist = ctrlptDist; + } + var loopAngle = loopDir - Math.PI / 2; + var outAngle = loopAngle - loopSwp / 2; + var inAngle = loopAngle + loopSwp / 2; + + // increase by step size for overlapping loops, keyed on direction and sweep values + var dc = String(loopDir + '_' + loopSwp); + j = dirCounts[dc] === undefined ? dirCounts[dc] = 0 : ++dirCounts[dc]; + rs.ctrlpts = [srcPos.x + Math.cos(outAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.y + Math.sin(outAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.x + Math.cos(inAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.y + Math.sin(inAngle) * 1.4 * loopDist * (j / 3 + 1)]; +}; +BRp$c.findCompoundLoopPoints = function (edge, pairInfo, i, edgeIsUnbundled) { + // Compound edge + + var rs = edge._private.rscratch; + rs.edgeType = 'compound'; + var srcPos = pairInfo.srcPos, + tgtPos = pairInfo.tgtPos, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var j = i; + var loopDist = stepSize; + if (edgeIsUnbundled) { + j = 0; + loopDist = ctrlptDist; + } + var loopW = 50; + var loopaPos = { + x: srcPos.x - srcW / 2, + y: srcPos.y - srcH / 2 + }; + var loopbPos = { + x: tgtPos.x - tgtW / 2, + y: tgtPos.y - tgtH / 2 + }; + var loopPos = { + x: Math.min(loopaPos.x, loopbPos.x), + y: Math.min(loopaPos.y, loopbPos.y) + }; + + // avoids cases with impossible beziers + var minCompoundStretch = 0.5; + var compoundStretchA = Math.max(minCompoundStretch, Math.log(srcW * 0.01)); + var compoundStretchB = Math.max(minCompoundStretch, Math.log(tgtW * 0.01)); + rs.ctrlpts = [loopPos.x, loopPos.y - (1 + Math.pow(loopW, 1.12) / 100) * loopDist * (j / 3 + 1) * compoundStretchA, loopPos.x - (1 + Math.pow(loopW, 1.12) / 100) * loopDist * (j / 3 + 1) * compoundStretchB, loopPos.y]; +}; +BRp$c.findStraightEdgePoints = function (edge) { + // Straight edge within bundle + + edge._private.rscratch.edgeType = 'straight'; +}; +BRp$c.findBezierPoints = function (edge, pairInfo, i, edgeIsUnbundled, edgeIsSwapped) { + var rs = edge._private.rscratch; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptWs = edge.pstyle('control-point-weights'); + var bezierN = ctrlptDists && ctrlptWs ? Math.min(ctrlptDists.value.length, ctrlptWs.value.length) : 1; + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var ctrlptWeight = ctrlptWs.value[0]; + + // (Multi)bezier + + var multi = edgeIsUnbundled; + rs.edgeType = multi ? 'multibezier' : 'bezier'; + rs.ctrlpts = []; + for (var b = 0; b < bezierN; b++) { + var normctrlptDist = (0.5 - pairInfo.eles.length / 2 + i) * stepSize * (edgeIsSwapped ? -1 : 1); + var manctrlptDist = void 0; + var sign = signum(normctrlptDist); + if (multi) { + ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[b] : stepSize; // fall back on step size + ctrlptWeight = ctrlptWs.value[b]; + } + if (edgeIsUnbundled) { + // multi or single unbundled + manctrlptDist = ctrlptDist; + } else { + manctrlptDist = ctrlptDist !== undefined ? sign * ctrlptDist : undefined; + } + var distanceFromMidpoint = manctrlptDist !== undefined ? manctrlptDist : normctrlptDist; + var w1 = 1 - ctrlptWeight; + var w2 = ctrlptWeight; + var _this$findMidptPtsEtc2 = this.findMidptPtsEtc(edge, pairInfo), + midptPts = _this$findMidptPtsEtc2.midptPts, + vectorNormInverse = _this$findMidptPtsEtc2.vectorNormInverse; + var adjustedMidpt = { + x: midptPts.x1 * w1 + midptPts.x2 * w2, + y: midptPts.y1 * w1 + midptPts.y2 * w2 + }; + rs.ctrlpts.push(adjustedMidpt.x + vectorNormInverse.x * distanceFromMidpoint, adjustedMidpt.y + vectorNormInverse.y * distanceFromMidpoint); + } +}; +BRp$c.findTaxiPoints = function (edge, pairInfo) { + // Taxicab geometry with two turns maximum + + var rs = edge._private.rscratch; + rs.edgeType = 'segments'; + var VERTICAL = 'vertical'; + var HORIZONTAL = 'horizontal'; + var LEFTWARD = 'leftward'; + var RIGHTWARD = 'rightward'; + var DOWNWARD = 'downward'; + var UPWARD = 'upward'; + var AUTO = 'auto'; + var posPts = pairInfo.posPts, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH; + var edgeDistances = edge.pstyle('edge-distances').value; + var dIncludesNodeBody = edgeDistances !== 'node-position'; + var taxiDir = edge.pstyle('taxi-direction').value; + var rawTaxiDir = taxiDir; // unprocessed value + var taxiTurn = edge.pstyle('taxi-turn'); + var turnIsPercent = taxiTurn.units === '%'; + var taxiTurnPfVal = taxiTurn.pfValue; + var turnIsNegative = taxiTurnPfVal < 0; // i.e. from target side + var minD = edge.pstyle('taxi-turn-min-distance').pfValue; + var dw = dIncludesNodeBody ? (srcW + tgtW) / 2 : 0; + var dh = dIncludesNodeBody ? (srcH + tgtH) / 2 : 0; + var pdx = posPts.x2 - posPts.x1; + var pdy = posPts.y2 - posPts.y1; + + // take away the effective w/h from the magnitude of the delta value + var subDWH = function subDWH(dxy, dwh) { + if (dxy > 0) { + return Math.max(dxy - dwh, 0); + } else { + return Math.min(dxy + dwh, 0); + } + }; + var dx = subDWH(pdx, dw); + var dy = subDWH(pdy, dh); + var isExplicitDir = false; + if (rawTaxiDir === AUTO) { + taxiDir = Math.abs(dx) > Math.abs(dy) ? HORIZONTAL : VERTICAL; + } else if (rawTaxiDir === UPWARD || rawTaxiDir === DOWNWARD) { + taxiDir = VERTICAL; + isExplicitDir = true; + } else if (rawTaxiDir === LEFTWARD || rawTaxiDir === RIGHTWARD) { + taxiDir = HORIZONTAL; + isExplicitDir = true; + } + var isVert = taxiDir === VERTICAL; + var l = isVert ? dy : dx; + var pl = isVert ? pdy : pdx; + var sgnL = signum(pl); + var forcedDir = false; + if (!(isExplicitDir && (turnIsPercent || turnIsNegative)) // forcing in this case would cause weird growing in the opposite direction + && (rawTaxiDir === DOWNWARD && pl < 0 || rawTaxiDir === UPWARD && pl > 0 || rawTaxiDir === LEFTWARD && pl > 0 || rawTaxiDir === RIGHTWARD && pl < 0)) { + sgnL *= -1; + l = sgnL * Math.abs(l); + forcedDir = true; + } + var d; + if (turnIsPercent) { + var p = taxiTurnPfVal < 0 ? 1 + taxiTurnPfVal : taxiTurnPfVal; + d = p * l; + } else { + var k = taxiTurnPfVal < 0 ? l : 0; + d = k + taxiTurnPfVal * sgnL; + } + var getIsTooClose = function getIsTooClose(d) { + return Math.abs(d) < minD || Math.abs(d) >= Math.abs(l); + }; + var isTooCloseSrc = getIsTooClose(d); + var isTooCloseTgt = getIsTooClose(Math.abs(l) - Math.abs(d)); + var isTooClose = isTooCloseSrc || isTooCloseTgt; + if (isTooClose && !forcedDir) { + // non-ideal routing + if (isVert) { + // vertical fallbacks + var lShapeInsideSrc = Math.abs(pl) <= srcH / 2; + var lShapeInsideTgt = Math.abs(pdx) <= tgtW / 2; + if (lShapeInsideSrc) { + // horizontal Z-shape (direction not respected) + var x = (posPts.x1 + posPts.x2) / 2; + var y1 = posPts.y1, + y2 = posPts.y2; + rs.segpts = [x, y1, x, y2]; + } else if (lShapeInsideTgt) { + // vertical Z-shape (distance not respected) + var y = (posPts.y1 + posPts.y2) / 2; + var x1 = posPts.x1, + x2 = posPts.x2; + rs.segpts = [x1, y, x2, y]; + } else { + // L-shape fallback (turn distance not respected, but works well with tree siblings) + rs.segpts = [posPts.x1, posPts.y2]; + } + } else { + // horizontal fallbacks + var _lShapeInsideSrc = Math.abs(pl) <= srcW / 2; + var _lShapeInsideTgt = Math.abs(pdy) <= tgtH / 2; + if (_lShapeInsideSrc) { + // vertical Z-shape (direction not respected) + var _y = (posPts.y1 + posPts.y2) / 2; + var _x = posPts.x1, + _x2 = posPts.x2; + rs.segpts = [_x, _y, _x2, _y]; + } else if (_lShapeInsideTgt) { + // horizontal Z-shape (turn distance not respected) + var _x3 = (posPts.x1 + posPts.x2) / 2; + var _y2 = posPts.y1, + _y3 = posPts.y2; + rs.segpts = [_x3, _y2, _x3, _y3]; + } else { + // L-shape (turn distance not respected, but works well for tree siblings) + rs.segpts = [posPts.x2, posPts.y1]; + } + } + } else { + // ideal routing + if (isVert) { + var _y4 = posPts.y1 + d + (dIncludesNodeBody ? srcH / 2 * sgnL : 0); + var _x4 = posPts.x1, + _x5 = posPts.x2; + rs.segpts = [_x4, _y4, _x5, _y4]; + } else { + // horizontal + var _x6 = posPts.x1 + d + (dIncludesNodeBody ? srcW / 2 * sgnL : 0); + var _y5 = posPts.y1, + _y6 = posPts.y2; + rs.segpts = [_x6, _y5, _x6, _y6]; + } + } + if (rs.isRound) { + var radius = edge.pstyle('taxi-radius').value; + var isArcRadius = edge.pstyle('radius-type').value[0] === 'arc-radius'; + rs.radii = new Array(rs.segpts.length / 2).fill(radius); + rs.isArcRadius = new Array(rs.segpts.length / 2).fill(isArcRadius); + } +}; +BRp$c.tryToCorrectInvalidPoints = function (edge, pairInfo) { + var rs = edge._private.rscratch; + + // can only correct beziers for now... + if (rs.edgeType === 'bezier') { + var srcPos = pairInfo.srcPos, + tgtPos = pairInfo.tgtPos, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH, + srcShape = pairInfo.srcShape, + tgtShape = pairInfo.tgtShape, + srcCornerRadius = pairInfo.srcCornerRadius, + tgtCornerRadius = pairInfo.tgtCornerRadius, + srcRs = pairInfo.srcRs, + tgtRs = pairInfo.tgtRs; + var badStart = !number$1(rs.startX) || !number$1(rs.startY); + var badAStart = !number$1(rs.arrowStartX) || !number$1(rs.arrowStartY); + var badEnd = !number$1(rs.endX) || !number$1(rs.endY); + var badAEnd = !number$1(rs.arrowEndX) || !number$1(rs.arrowEndY); + var minCpADistFactor = 3; + var arrowW = this.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.arrowShapeWidth; + var minCpADist = minCpADistFactor * arrowW; + var startACpDist = dist({ + x: rs.ctrlpts[0], + y: rs.ctrlpts[1] + }, { + x: rs.startX, + y: rs.startY + }); + var closeStartACp = startACpDist < minCpADist; + var endACpDist = dist({ + x: rs.ctrlpts[0], + y: rs.ctrlpts[1] + }, { + x: rs.endX, + y: rs.endY + }); + var closeEndACp = endACpDist < minCpADist; + var overlapping = false; + if (badStart || badAStart || closeStartACp) { + overlapping = true; + + // project control point along line from src centre to outside the src shape + // (otherwise intersection will yield nothing) + var cpD = { + // delta + x: rs.ctrlpts[0] - srcPos.x, + y: rs.ctrlpts[1] - srcPos.y + }; + var cpL = Math.sqrt(cpD.x * cpD.x + cpD.y * cpD.y); // length of line + var cpM = { + // normalised delta + x: cpD.x / cpL, + y: cpD.y / cpL + }; + var radius = Math.max(srcW, srcH); + var cpProj = { + // *2 radius guarantees outside shape + x: rs.ctrlpts[0] + cpM.x * 2 * radius, + y: rs.ctrlpts[1] + cpM.y * 2 * radius + }; + var srcCtrlPtIntn = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, cpProj.x, cpProj.y, 0, srcCornerRadius, srcRs); + if (closeStartACp) { + rs.ctrlpts[0] = rs.ctrlpts[0] + cpM.x * (minCpADist - startACpDist); + rs.ctrlpts[1] = rs.ctrlpts[1] + cpM.y * (minCpADist - startACpDist); + } else { + rs.ctrlpts[0] = srcCtrlPtIntn[0] + cpM.x * minCpADist; + rs.ctrlpts[1] = srcCtrlPtIntn[1] + cpM.y * minCpADist; + } + } + if (badEnd || badAEnd || closeEndACp) { + overlapping = true; + + // project control point along line from tgt centre to outside the tgt shape + // (otherwise intersection will yield nothing) + var _cpD = { + // delta + x: rs.ctrlpts[0] - tgtPos.x, + y: rs.ctrlpts[1] - tgtPos.y + }; + var _cpL = Math.sqrt(_cpD.x * _cpD.x + _cpD.y * _cpD.y); // length of line + var _cpM = { + // normalised delta + x: _cpD.x / _cpL, + y: _cpD.y / _cpL + }; + var _radius = Math.max(srcW, srcH); + var _cpProj = { + // *2 radius guarantees outside shape + x: rs.ctrlpts[0] + _cpM.x * 2 * _radius, + y: rs.ctrlpts[1] + _cpM.y * 2 * _radius + }; + var tgtCtrlPtIntn = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, _cpProj.x, _cpProj.y, 0, tgtCornerRadius, tgtRs); + if (closeEndACp) { + rs.ctrlpts[0] = rs.ctrlpts[0] + _cpM.x * (minCpADist - endACpDist); + rs.ctrlpts[1] = rs.ctrlpts[1] + _cpM.y * (minCpADist - endACpDist); + } else { + rs.ctrlpts[0] = tgtCtrlPtIntn[0] + _cpM.x * minCpADist; + rs.ctrlpts[1] = tgtCtrlPtIntn[1] + _cpM.y * minCpADist; + } + } + if (overlapping) { + // recalc endpts + this.findEndpoints(edge); + } + } +}; +BRp$c.storeAllpts = function (edge) { + var rs = edge._private.rscratch; + if (rs.edgeType === 'multibezier' || rs.edgeType === 'bezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') { + rs.allpts = []; + rs.allpts.push(rs.startX, rs.startY); + for (var b = 0; b + 1 < rs.ctrlpts.length; b += 2) { + // ctrl pt itself + rs.allpts.push(rs.ctrlpts[b], rs.ctrlpts[b + 1]); + + // the midpt between ctrlpts as intermediate destination pts + if (b + 3 < rs.ctrlpts.length) { + rs.allpts.push((rs.ctrlpts[b] + rs.ctrlpts[b + 2]) / 2, (rs.ctrlpts[b + 1] + rs.ctrlpts[b + 3]) / 2); + } + } + rs.allpts.push(rs.endX, rs.endY); + var m, mt; + if (rs.ctrlpts.length / 2 % 2 === 0) { + m = rs.allpts.length / 2 - 1; + rs.midX = rs.allpts[m]; + rs.midY = rs.allpts[m + 1]; + } else { + m = rs.allpts.length / 2 - 3; + mt = 0.5; + rs.midX = qbezierAt(rs.allpts[m], rs.allpts[m + 2], rs.allpts[m + 4], mt); + rs.midY = qbezierAt(rs.allpts[m + 1], rs.allpts[m + 3], rs.allpts[m + 5], mt); + } + } else if (rs.edgeType === 'straight') { + // need to calc these after endpts + rs.allpts = [rs.startX, rs.startY, rs.endX, rs.endY]; + + // default midpt for labels etc + rs.midX = (rs.startX + rs.endX + rs.arrowStartX + rs.arrowEndX) / 4; + rs.midY = (rs.startY + rs.endY + rs.arrowStartY + rs.arrowEndY) / 4; + } else if (rs.edgeType === 'segments') { + rs.allpts = []; + rs.allpts.push(rs.startX, rs.startY); + rs.allpts.push.apply(rs.allpts, rs.segpts); + rs.allpts.push(rs.endX, rs.endY); + if (rs.isRound) { + rs.roundCorners = []; + for (var i = 2; i + 3 < rs.allpts.length; i += 2) { + var radius = rs.radii[i / 2 - 1]; + var isArcRadius = rs.isArcRadius[i / 2 - 1]; + rs.roundCorners.push(getRoundCorner({ + x: rs.allpts[i - 2], + y: rs.allpts[i - 1] + }, { + x: rs.allpts[i], + y: rs.allpts[i + 1], + radius: radius + }, { + x: rs.allpts[i + 2], + y: rs.allpts[i + 3] + }, radius, isArcRadius)); + } + } + if (rs.segpts.length % 4 === 0) { + var i2 = rs.segpts.length / 2; + var i1 = i2 - 2; + rs.midX = (rs.segpts[i1] + rs.segpts[i2]) / 2; + rs.midY = (rs.segpts[i1 + 1] + rs.segpts[i2 + 1]) / 2; + } else { + var _i = rs.segpts.length / 2 - 1; + if (!rs.isRound) { + rs.midX = rs.segpts[_i]; + rs.midY = rs.segpts[_i + 1]; + } else { + var point = { + x: rs.segpts[_i], + y: rs.segpts[_i + 1] + }; + var corner = rs.roundCorners[_i / 2]; + var v = [point.x - corner.cx, point.y - corner.cy]; + var factor = corner.radius / Math.sqrt(Math.pow(v[0], 2) + Math.pow(v[1], 2)); + v = v.map(function (c) { + return c * factor; + }); + rs.midX = corner.cx + v[0]; + rs.midY = corner.cy + v[1]; + rs.midVector = v; + } + } + } +}; +BRp$c.checkForInvalidEdgeWarning = function (edge) { + var rs = edge[0]._private.rscratch; + if (rs.nodesOverlap || number$1(rs.startX) && number$1(rs.startY) && number$1(rs.endX) && number$1(rs.endY)) { + rs.loggedErr = false; + } else { + if (!rs.loggedErr) { + rs.loggedErr = true; + warn('Edge `' + edge.id() + '` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap.'); + } + } +}; +BRp$c.findEdgeControlPoints = function (edges) { + var _this = this; + if (!edges || edges.length === 0) { + return; + } + var r = this; + var cy = r.cy; + var hasCompounds = cy.hasCompoundNodes(); + var hashTable = { + map: new Map$2(), + get: function get(pairId) { + var map2 = this.map.get(pairId[0]); + if (map2 != null) { + return map2.get(pairId[1]); + } else { + return null; + } + }, + set: function set(pairId, val) { + var map2 = this.map.get(pairId[0]); + if (map2 == null) { + map2 = new Map$2(); + this.map.set(pairId[0], map2); + } + map2.set(pairId[1], val); + } + }; + var pairIds = []; + var haystackEdges = []; + + // create a table of edge (src, tgt) => list of edges between them + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var _p = edge._private; + var curveStyle = edge.pstyle('curve-style').value; + + // ignore edges who are not to be displayed + // they shouldn't take up space + if (edge.removed() || !edge.takesUpSpace()) { + continue; + } + if (curveStyle === 'haystack') { + haystackEdges.push(edge); + continue; + } + var edgeIsUnbundled = curveStyle === 'unbundled-bezier' || curveStyle.endsWith('segments') || curveStyle === 'straight' || curveStyle === 'straight-triangle' || curveStyle.endsWith('taxi'); + var edgeIsBezier = curveStyle === 'unbundled-bezier' || curveStyle === 'bezier'; + var src = _p.source; + var tgt = _p.target; + var srcIndex = src.poolIndex(); + var tgtIndex = tgt.poolIndex(); + var pairId = [srcIndex, tgtIndex].sort(); + var tableEntry = hashTable.get(pairId); + if (tableEntry == null) { + tableEntry = { + eles: [] + }; + hashTable.set(pairId, tableEntry); + pairIds.push(pairId); + } + tableEntry.eles.push(edge); + if (edgeIsUnbundled) { + tableEntry.hasUnbundled = true; + } + if (edgeIsBezier) { + tableEntry.hasBezier = true; + } + } + + // for each pair (src, tgt), create the ctrl pts + // Nested for loop is OK; total number of iterations for both loops = edgeCount + var _loop = function _loop(p) { + var pairId = pairIds[p]; + var pairInfo = hashTable.get(pairId); + var swappedpairInfo = void 0; + if (!pairInfo.hasUnbundled) { + var pllEdges = pairInfo.eles[0].parallelEdges().filter(function (e) { + return e.isBundledBezier(); + }); + clearArray(pairInfo.eles); + pllEdges.forEach(function (edge) { + return pairInfo.eles.push(edge); + }); + + // for each pair id, the edges should be sorted by index + pairInfo.eles.sort(function (edge1, edge2) { + return edge1.poolIndex() - edge2.poolIndex(); + }); + } + var firstEdge = pairInfo.eles[0]; + var src = firstEdge.source(); + var tgt = firstEdge.target(); + + // make sure src/tgt distinction is consistent w.r.t. pairId + if (src.poolIndex() > tgt.poolIndex()) { + var temp = src; + src = tgt; + tgt = temp; + } + var srcPos = pairInfo.srcPos = src.position(); + var tgtPos = pairInfo.tgtPos = tgt.position(); + var srcW = pairInfo.srcW = src.outerWidth(); + var srcH = pairInfo.srcH = src.outerHeight(); + var tgtW = pairInfo.tgtW = tgt.outerWidth(); + var tgtH = pairInfo.tgtH = tgt.outerHeight(); + var srcShape = pairInfo.srcShape = r.nodeShapes[_this.getNodeShape(src)]; + var tgtShape = pairInfo.tgtShape = r.nodeShapes[_this.getNodeShape(tgt)]; + var srcCornerRadius = pairInfo.srcCornerRadius = src.pstyle('corner-radius').value === 'auto' ? 'auto' : src.pstyle('corner-radius').pfValue; + var tgtCornerRadius = pairInfo.tgtCornerRadius = tgt.pstyle('corner-radius').value === 'auto' ? 'auto' : tgt.pstyle('corner-radius').pfValue; + var tgtRs = pairInfo.tgtRs = tgt._private.rscratch; + var srcRs = pairInfo.srcRs = src._private.rscratch; + pairInfo.dirCounts = { + 'north': 0, + 'west': 0, + 'south': 0, + 'east': 0, + 'northwest': 0, + 'southwest': 0, + 'northeast': 0, + 'southeast': 0 + }; + for (var _i2 = 0; _i2 < pairInfo.eles.length; _i2++) { + var _edge = pairInfo.eles[_i2]; + var rs = _edge[0]._private.rscratch; + var _curveStyle = _edge.pstyle('curve-style').value; + var _edgeIsUnbundled = _curveStyle === 'unbundled-bezier' || _curveStyle.endsWith('segments') || _curveStyle.endsWith('taxi'); + + // whether the normalised pair order is the reverse of the edge's src-tgt order + var edgeIsSwapped = !src.same(_edge.source()); + if (!pairInfo.calculatedIntersection && src !== tgt && (pairInfo.hasBezier || pairInfo.hasUnbundled)) { + pairInfo.calculatedIntersection = true; + + // pt outside src shape to calc distance/displacement from src to tgt + var srcOutside = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, tgtPos.x, tgtPos.y, 0, srcCornerRadius, srcRs); + var srcIntn = pairInfo.srcIntn = srcOutside; + + // pt outside tgt shape to calc distance/displacement from src to tgt + var tgtOutside = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, srcPos.x, srcPos.y, 0, tgtCornerRadius, tgtRs); + var tgtIntn = pairInfo.tgtIntn = tgtOutside; + var intersectionPts = pairInfo.intersectionPts = { + x1: srcOutside[0], + x2: tgtOutside[0], + y1: srcOutside[1], + y2: tgtOutside[1] + }; + var posPts = pairInfo.posPts = { + x1: srcPos.x, + x2: tgtPos.x, + y1: srcPos.y, + y2: tgtPos.y + }; + var dy = tgtOutside[1] - srcOutside[1]; + var dx = tgtOutside[0] - srcOutside[0]; + var l = Math.sqrt(dx * dx + dy * dy); + var vector = pairInfo.vector = { + x: dx, + y: dy + }; + var vectorNorm = pairInfo.vectorNorm = { + x: vector.x / l, + y: vector.y / l + }; + var vectorNormInverse = { + x: -vectorNorm.y, + y: vectorNorm.x + }; + + // if node shapes overlap, then no ctrl pts to draw + pairInfo.nodesOverlap = !number$1(l) || tgtShape.checkPoint(srcOutside[0], srcOutside[1], 0, tgtW, tgtH, tgtPos.x, tgtPos.y, tgtCornerRadius, tgtRs) || srcShape.checkPoint(tgtOutside[0], tgtOutside[1], 0, srcW, srcH, srcPos.x, srcPos.y, srcCornerRadius, srcRs); + pairInfo.vectorNormInverse = vectorNormInverse; + swappedpairInfo = { + nodesOverlap: pairInfo.nodesOverlap, + dirCounts: pairInfo.dirCounts, + calculatedIntersection: true, + hasBezier: pairInfo.hasBezier, + hasUnbundled: pairInfo.hasUnbundled, + eles: pairInfo.eles, + srcPos: tgtPos, + tgtPos: srcPos, + srcW: tgtW, + srcH: tgtH, + tgtW: srcW, + tgtH: srcH, + srcIntn: tgtIntn, + tgtIntn: srcIntn, + srcShape: tgtShape, + tgtShape: srcShape, + posPts: { + x1: posPts.x2, + y1: posPts.y2, + x2: posPts.x1, + y2: posPts.y1 + }, + intersectionPts: { + x1: intersectionPts.x2, + y1: intersectionPts.y2, + x2: intersectionPts.x1, + y2: intersectionPts.y1 + }, + vector: { + x: -vector.x, + y: -vector.y + }, + vectorNorm: { + x: -vectorNorm.x, + y: -vectorNorm.y + }, + vectorNormInverse: { + x: -vectorNormInverse.x, + y: -vectorNormInverse.y + } + }; + } + var passedPairInfo = edgeIsSwapped ? swappedpairInfo : pairInfo; + rs.nodesOverlap = passedPairInfo.nodesOverlap; + rs.srcIntn = passedPairInfo.srcIntn; + rs.tgtIntn = passedPairInfo.tgtIntn; + rs.isRound = _curveStyle.startsWith('round'); + if (hasCompounds && (src.isParent() || src.isChild() || tgt.isParent() || tgt.isChild()) && (src.parents().anySame(tgt) || tgt.parents().anySame(src) || src.same(tgt) && src.isParent())) { + _this.findCompoundLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled); + } else if (src === tgt) { + _this.findLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled); + } else if (_curveStyle.endsWith('segments')) { + _this.findSegmentsPoints(_edge, passedPairInfo); + } else if (_curveStyle.endsWith('taxi')) { + _this.findTaxiPoints(_edge, passedPairInfo); + } else if (_curveStyle === 'straight' || !_edgeIsUnbundled && pairInfo.eles.length % 2 === 1 && _i2 === Math.floor(pairInfo.eles.length / 2)) { + _this.findStraightEdgePoints(_edge); + } else { + _this.findBezierPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled, edgeIsSwapped); + } + _this.findEndpoints(_edge); + _this.tryToCorrectInvalidPoints(_edge, passedPairInfo); + _this.checkForInvalidEdgeWarning(_edge); + _this.storeAllpts(_edge); + _this.storeEdgeProjections(_edge); + _this.calculateArrowAngles(_edge); + _this.recalculateEdgeLabelProjections(_edge); + _this.calculateLabelAngles(_edge); + } // for pair edges + }; + for (var p = 0; p < pairIds.length; p++) { + _loop(p); + } // for pair ids + + // haystacks avoid the expense of pairInfo stuff (intersections etc.) + this.findHaystackPoints(haystackEdges); +}; +function getPts(pts) { + var retPts = []; + if (pts == null) { + return; + } + for (var i = 0; i < pts.length; i += 2) { + var x = pts[i]; + var y = pts[i + 1]; + retPts.push({ + x: x, + y: y + }); + } + return retPts; +} +BRp$c.getSegmentPoints = function (edge) { + var rs = edge[0]._private.rscratch; + var type = rs.edgeType; + if (type === 'segments') { + this.recalculateRenderedStyle(edge); + return getPts(rs.segpts); + } +}; +BRp$c.getControlPoints = function (edge) { + var rs = edge[0]._private.rscratch; + var type = rs.edgeType; + if (type === 'bezier' || type === 'multibezier' || type === 'self' || type === 'compound') { + this.recalculateRenderedStyle(edge); + return getPts(rs.ctrlpts); + } +}; +BRp$c.getEdgeMidpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + return { + x: rs.midX, + y: rs.midY + }; +}; + +var BRp$b = {}; +BRp$b.manualEndptToPx = function (node, prop) { + var r = this; + var npos = node.position(); + var w = node.outerWidth(); + var h = node.outerHeight(); + var rs = node._private.rscratch; + if (prop.value.length === 2) { + var p = [prop.pfValue[0], prop.pfValue[1]]; + if (prop.units[0] === '%') { + p[0] = p[0] * w; + } + if (prop.units[1] === '%') { + p[1] = p[1] * h; + } + p[0] += npos.x; + p[1] += npos.y; + return p; + } else { + var angle = prop.pfValue[0]; + angle = -Math.PI / 2 + angle; // start at 12 o'clock + + var l = 2 * Math.max(w, h); + var _p = [npos.x + Math.cos(angle) * l, npos.y + Math.sin(angle) * l]; + return r.nodeShapes[this.getNodeShape(node)].intersectLine(npos.x, npos.y, w, h, _p[0], _p[1], 0, node.pstyle('corner-radius').value === 'auto' ? 'auto' : node.pstyle('corner-radius').pfValue, rs); + } +}; +BRp$b.findEndpoints = function (edge) { + var r = this; + var intersect; + var source = edge.source()[0]; + var target = edge.target()[0]; + var srcPos = source.position(); + var tgtPos = target.position(); + var tgtArShape = edge.pstyle('target-arrow-shape').value; + var srcArShape = edge.pstyle('source-arrow-shape').value; + var tgtDist = edge.pstyle('target-distance-from-node').pfValue; + var srcDist = edge.pstyle('source-distance-from-node').pfValue; + var srcRs = source._private.rscratch; + var tgtRs = target._private.rscratch; + var curveStyle = edge.pstyle('curve-style').value; + var rs = edge._private.rscratch; + var et = rs.edgeType; + var taxi = curveStyle === 'taxi'; + var self = et === 'self' || et === 'compound'; + var bezier = et === 'bezier' || et === 'multibezier' || self; + var multi = et !== 'bezier'; + var lines = et === 'straight' || et === 'segments'; + var segments = et === 'segments'; + var hasEndpts = bezier || multi || lines; + var overrideEndpts = self || taxi; + var srcManEndpt = edge.pstyle('source-endpoint'); + var srcManEndptVal = overrideEndpts ? 'outside-to-node' : srcManEndpt.value; + var srcCornerRadius = source.pstyle('corner-radius').value === 'auto' ? 'auto' : source.pstyle('corner-radius').pfValue; + var tgtManEndpt = edge.pstyle('target-endpoint'); + var tgtManEndptVal = overrideEndpts ? 'outside-to-node' : tgtManEndpt.value; + var tgtCornerRadius = target.pstyle('corner-radius').value === 'auto' ? 'auto' : target.pstyle('corner-radius').pfValue; + rs.srcManEndpt = srcManEndpt; + rs.tgtManEndpt = tgtManEndpt; + var p1; // last known point of edge on target side + var p2; // last known point of edge on source side + + var p1_i; // point to intersect with target shape + var p2_i; // point to intersect with source shape + + if (bezier) { + var cpStart = [rs.ctrlpts[0], rs.ctrlpts[1]]; + var cpEnd = multi ? [rs.ctrlpts[rs.ctrlpts.length - 2], rs.ctrlpts[rs.ctrlpts.length - 1]] : cpStart; + p1 = cpEnd; + p2 = cpStart; + } else if (lines) { + var srcArrowFromPt = !segments ? [tgtPos.x, tgtPos.y] : rs.segpts.slice(0, 2); + var tgtArrowFromPt = !segments ? [srcPos.x, srcPos.y] : rs.segpts.slice(rs.segpts.length - 2); + p1 = tgtArrowFromPt; + p2 = srcArrowFromPt; + } + if (tgtManEndptVal === 'inside-to-node') { + intersect = [tgtPos.x, tgtPos.y]; + } else if (tgtManEndpt.units) { + intersect = this.manualEndptToPx(target, tgtManEndpt); + } else if (tgtManEndptVal === 'outside-to-line') { + intersect = rs.tgtIntn; // use cached value from ctrlpt calc + } else { + if (tgtManEndptVal === 'outside-to-node' || tgtManEndptVal === 'outside-to-node-or-label') { + p1_i = p1; + } else if (tgtManEndptVal === 'outside-to-line' || tgtManEndptVal === 'outside-to-line-or-label') { + p1_i = [srcPos.x, srcPos.y]; + } + intersect = r.nodeShapes[this.getNodeShape(target)].intersectLine(tgtPos.x, tgtPos.y, target.outerWidth(), target.outerHeight(), p1_i[0], p1_i[1], 0, tgtCornerRadius, tgtRs); + if (tgtManEndptVal === 'outside-to-node-or-label' || tgtManEndptVal === 'outside-to-line-or-label') { + var trs = target._private.rscratch; + var lw = trs.labelWidth; + var lh = trs.labelHeight; + var lx = trs.labelX; + var ly = trs.labelY; + var lw2 = lw / 2; + var lh2 = lh / 2; + var va = target.pstyle('text-valign').value; + if (va === 'top') { + ly -= lh2; + } else if (va === 'bottom') { + ly += lh2; + } + var ha = target.pstyle('text-halign').value; + if (ha === 'left') { + lx -= lw2; + } else if (ha === 'right') { + lx += lw2; + } + var labelIntersect = polygonIntersectLine(p1_i[0], p1_i[1], [lx - lw2, ly - lh2, lx + lw2, ly - lh2, lx + lw2, ly + lh2, lx - lw2, ly + lh2], tgtPos.x, tgtPos.y); + if (labelIntersect.length > 0) { + var refPt = srcPos; + var intSqdist = sqdist(refPt, array2point(intersect)); + var labIntSqdist = sqdist(refPt, array2point(labelIntersect)); + var minSqDist = intSqdist; + if (labIntSqdist < intSqdist) { + intersect = labelIntersect; + minSqDist = labIntSqdist; + } + if (labelIntersect.length > 2) { + var labInt2SqDist = sqdist(refPt, { + x: labelIntersect[2], + y: labelIntersect[3] + }); + if (labInt2SqDist < minSqDist) { + intersect = [labelIntersect[2], labelIntersect[3]]; + } + } + } + } + } + var arrowEnd = shortenIntersection(intersect, p1, r.arrowShapes[tgtArShape].spacing(edge) + tgtDist); + var edgeEnd = shortenIntersection(intersect, p1, r.arrowShapes[tgtArShape].gap(edge) + tgtDist); + rs.endX = edgeEnd[0]; + rs.endY = edgeEnd[1]; + rs.arrowEndX = arrowEnd[0]; + rs.arrowEndY = arrowEnd[1]; + if (srcManEndptVal === 'inside-to-node') { + intersect = [srcPos.x, srcPos.y]; + } else if (srcManEndpt.units) { + intersect = this.manualEndptToPx(source, srcManEndpt); + } else if (srcManEndptVal === 'outside-to-line') { + intersect = rs.srcIntn; // use cached value from ctrlpt calc + } else { + if (srcManEndptVal === 'outside-to-node' || srcManEndptVal === 'outside-to-node-or-label') { + p2_i = p2; + } else if (srcManEndptVal === 'outside-to-line' || srcManEndptVal === 'outside-to-line-or-label') { + p2_i = [tgtPos.x, tgtPos.y]; + } + intersect = r.nodeShapes[this.getNodeShape(source)].intersectLine(srcPos.x, srcPos.y, source.outerWidth(), source.outerHeight(), p2_i[0], p2_i[1], 0, srcCornerRadius, srcRs); + if (srcManEndptVal === 'outside-to-node-or-label' || srcManEndptVal === 'outside-to-line-or-label') { + var srs = source._private.rscratch; + var _lw = srs.labelWidth; + var _lh = srs.labelHeight; + var _lx = srs.labelX; + var _ly = srs.labelY; + var _lw2 = _lw / 2; + var _lh2 = _lh / 2; + var _va = source.pstyle('text-valign').value; + if (_va === 'top') { + _ly -= _lh2; + } else if (_va === 'bottom') { + _ly += _lh2; + } + var _ha = source.pstyle('text-halign').value; + if (_ha === 'left') { + _lx -= _lw2; + } else if (_ha === 'right') { + _lx += _lw2; + } + var _labelIntersect = polygonIntersectLine(p2_i[0], p2_i[1], [_lx - _lw2, _ly - _lh2, _lx + _lw2, _ly - _lh2, _lx + _lw2, _ly + _lh2, _lx - _lw2, _ly + _lh2], srcPos.x, srcPos.y); + if (_labelIntersect.length > 0) { + var _refPt = tgtPos; + var _intSqdist = sqdist(_refPt, array2point(intersect)); + var _labIntSqdist = sqdist(_refPt, array2point(_labelIntersect)); + var _minSqDist = _intSqdist; + if (_labIntSqdist < _intSqdist) { + intersect = [_labelIntersect[0], _labelIntersect[1]]; + _minSqDist = _labIntSqdist; + } + if (_labelIntersect.length > 2) { + var _labInt2SqDist = sqdist(_refPt, { + x: _labelIntersect[2], + y: _labelIntersect[3] + }); + if (_labInt2SqDist < _minSqDist) { + intersect = [_labelIntersect[2], _labelIntersect[3]]; + } + } + } + } + } + var arrowStart = shortenIntersection(intersect, p2, r.arrowShapes[srcArShape].spacing(edge) + srcDist); + var edgeStart = shortenIntersection(intersect, p2, r.arrowShapes[srcArShape].gap(edge) + srcDist); + rs.startX = edgeStart[0]; + rs.startY = edgeStart[1]; + rs.arrowStartX = arrowStart[0]; + rs.arrowStartY = arrowStart[1]; + if (hasEndpts) { + if (!number$1(rs.startX) || !number$1(rs.startY) || !number$1(rs.endX) || !number$1(rs.endY)) { + rs.badLine = true; + } else { + rs.badLine = false; + } + } +}; +BRp$b.getSourceEndpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + switch (rs.edgeType) { + case 'haystack': + return { + x: rs.haystackPts[0], + y: rs.haystackPts[1] + }; + default: + return { + x: rs.arrowStartX, + y: rs.arrowStartY + }; + } +}; +BRp$b.getTargetEndpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + switch (rs.edgeType) { + case 'haystack': + return { + x: rs.haystackPts[2], + y: rs.haystackPts[3] + }; + default: + return { + x: rs.arrowEndX, + y: rs.arrowEndY + }; + } +}; + +var BRp$a = {}; +function pushBezierPts(r, edge, pts) { + var qbezierAt$1 = function qbezierAt$1(p1, p2, p3, t) { + return qbezierAt(p1, p2, p3, t); + }; + var _p = edge._private; + var bpts = _p.rstyle.bezierPts; + for (var i = 0; i < r.bezierProjPcts.length; i++) { + var p = r.bezierProjPcts[i]; + bpts.push({ + x: qbezierAt$1(pts[0], pts[2], pts[4], p), + y: qbezierAt$1(pts[1], pts[3], pts[5], p) + }); + } +} +BRp$a.storeEdgeProjections = function (edge) { + var _p = edge._private; + var rs = _p.rscratch; + var et = rs.edgeType; + + // clear the cached points state + _p.rstyle.bezierPts = null; + _p.rstyle.linePts = null; + _p.rstyle.haystackPts = null; + if (et === 'multibezier' || et === 'bezier' || et === 'self' || et === 'compound') { + _p.rstyle.bezierPts = []; + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + pushBezierPts(this, edge, rs.allpts.slice(i, i + 6)); + } + } else if (et === 'segments') { + var lpts = _p.rstyle.linePts = []; + for (var i = 0; i + 1 < rs.allpts.length; i += 2) { + lpts.push({ + x: rs.allpts[i], + y: rs.allpts[i + 1] + }); + } + } else if (et === 'haystack') { + var hpts = rs.haystackPts; + _p.rstyle.haystackPts = [{ + x: hpts[0], + y: hpts[1] + }, { + x: hpts[2], + y: hpts[3] + }]; + } + _p.rstyle.arrowWidth = this.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.arrowShapeWidth; +}; +BRp$a.recalculateEdgeProjections = function (edges) { + this.findEdgeControlPoints(edges); +}; + +/* global document */ + +var BRp$9 = {}; +BRp$9.recalculateNodeLabelProjection = function (node) { + var content = node.pstyle('label').strValue; + if (emptyString(content)) { + return; + } + var textX, textY; + var _p = node._private; + var nodeWidth = node.width(); + var nodeHeight = node.height(); + var padding = node.padding(); + var nodePos = node.position(); + var textHalign = node.pstyle('text-halign').strValue; + var textValign = node.pstyle('text-valign').strValue; + var rs = _p.rscratch; + var rstyle = _p.rstyle; + switch (textHalign) { + case 'left': + textX = nodePos.x - nodeWidth / 2 - padding; + break; + case 'right': + textX = nodePos.x + nodeWidth / 2 + padding; + break; + default: + // e.g. center + textX = nodePos.x; + } + switch (textValign) { + case 'top': + textY = nodePos.y - nodeHeight / 2 - padding; + break; + case 'bottom': + textY = nodePos.y + nodeHeight / 2 + padding; + break; + default: + // e.g. middle + textY = nodePos.y; + } + rs.labelX = textX; + rs.labelY = textY; + rstyle.labelX = textX; + rstyle.labelY = textY; + this.calculateLabelAngles(node); + this.applyLabelDimensions(node); +}; +var lineAngleFromDelta = function lineAngleFromDelta(dx, dy) { + var angle = Math.atan(dy / dx); + if (dx === 0 && angle < 0) { + angle = angle * -1; + } + return angle; +}; +var lineAngle = function lineAngle(p0, p1) { + var dx = p1.x - p0.x; + var dy = p1.y - p0.y; + return lineAngleFromDelta(dx, dy); +}; +var bezierAngle = function bezierAngle(p0, p1, p2, t) { + var t0 = bound(0, t - 0.001, 1); + var t1 = bound(0, t + 0.001, 1); + var lp0 = qbezierPtAt(p0, p1, p2, t0); + var lp1 = qbezierPtAt(p0, p1, p2, t1); + return lineAngle(lp0, lp1); +}; +BRp$9.recalculateEdgeLabelProjections = function (edge) { + var p; + var _p = edge._private; + var rs = _p.rscratch; + var r = this; + var content = { + mid: edge.pstyle('label').strValue, + source: edge.pstyle('source-label').strValue, + target: edge.pstyle('target-label').strValue + }; + if (content.mid || content.source || content.target) ; else { + return; // no labels => no calcs + } + + // add center point to style so bounding box calculations can use it + // + p = { + x: rs.midX, + y: rs.midY + }; + var setRs = function setRs(propName, prefix, value) { + setPrefixedProperty(_p.rscratch, propName, prefix, value); + setPrefixedProperty(_p.rstyle, propName, prefix, value); + }; + setRs('labelX', null, p.x); + setRs('labelY', null, p.y); + var midAngle = lineAngleFromDelta(rs.midDispX, rs.midDispY); + setRs('labelAutoAngle', null, midAngle); + var createControlPointInfo = function createControlPointInfo() { + if (createControlPointInfo.cache) { + return createControlPointInfo.cache; + } // use cache so only 1x per edge + + var ctrlpts = []; + + // store each ctrlpt info init + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + var p0 = { + x: rs.allpts[i], + y: rs.allpts[i + 1] + }; + var p1 = { + x: rs.allpts[i + 2], + y: rs.allpts[i + 3] + }; // ctrlpt + var p2 = { + x: rs.allpts[i + 4], + y: rs.allpts[i + 5] + }; + ctrlpts.push({ + p0: p0, + p1: p1, + p2: p2, + startDist: 0, + length: 0, + segments: [] + }); + } + var bpts = _p.rstyle.bezierPts; + var nProjs = r.bezierProjPcts.length; + function addSegment(cp, p0, p1, t0, t1) { + var length = dist(p0, p1); + var prevSegment = cp.segments[cp.segments.length - 1]; + var segment = { + p0: p0, + p1: p1, + t0: t0, + t1: t1, + startDist: prevSegment ? prevSegment.startDist + prevSegment.length : 0, + length: length + }; + cp.segments.push(segment); + cp.length += length; + } + + // update each ctrlpt with segment info + for (var _i = 0; _i < ctrlpts.length; _i++) { + var cp = ctrlpts[_i]; + var prevCp = ctrlpts[_i - 1]; + if (prevCp) { + cp.startDist = prevCp.startDist + prevCp.length; + } + addSegment(cp, cp.p0, bpts[_i * nProjs], 0, r.bezierProjPcts[0]); // first + + for (var j = 0; j < nProjs - 1; j++) { + addSegment(cp, bpts[_i * nProjs + j], bpts[_i * nProjs + j + 1], r.bezierProjPcts[j], r.bezierProjPcts[j + 1]); + } + addSegment(cp, bpts[_i * nProjs + nProjs - 1], cp.p2, r.bezierProjPcts[nProjs - 1], 1); // last + } + + return createControlPointInfo.cache = ctrlpts; + }; + var calculateEndProjection = function calculateEndProjection(prefix) { + var angle; + var isSrc = prefix === 'source'; + if (!content[prefix]) { + return; + } + var offset = edge.pstyle(prefix + '-text-offset').pfValue; + switch (rs.edgeType) { + case 'self': + case 'compound': + case 'bezier': + case 'multibezier': + { + var cps = createControlPointInfo(); + var selected; + var startDist = 0; + var totalDist = 0; + + // find the segment we're on + for (var i = 0; i < cps.length; i++) { + var _cp = cps[isSrc ? i : cps.length - 1 - i]; + for (var j = 0; j < _cp.segments.length; j++) { + var _seg = _cp.segments[isSrc ? j : _cp.segments.length - 1 - j]; + var lastSeg = i === cps.length - 1 && j === _cp.segments.length - 1; + startDist = totalDist; + totalDist += _seg.length; + if (totalDist >= offset || lastSeg) { + selected = { + cp: _cp, + segment: _seg + }; + break; + } + } + if (selected) { + break; + } + } + var cp = selected.cp; + var seg = selected.segment; + var tSegment = (offset - startDist) / seg.length; + var segDt = seg.t1 - seg.t0; + var t = isSrc ? seg.t0 + segDt * tSegment : seg.t1 - segDt * tSegment; + t = bound(0, t, 1); + p = qbezierPtAt(cp.p0, cp.p1, cp.p2, t); + angle = bezierAngle(cp.p0, cp.p1, cp.p2, t); + break; + } + case 'straight': + case 'segments': + case 'haystack': + { + var d = 0, + di, + d0; + var p0, p1; + var l = rs.allpts.length; + for (var _i2 = 0; _i2 + 3 < l; _i2 += 2) { + if (isSrc) { + p0 = { + x: rs.allpts[_i2], + y: rs.allpts[_i2 + 1] + }; + p1 = { + x: rs.allpts[_i2 + 2], + y: rs.allpts[_i2 + 3] + }; + } else { + p0 = { + x: rs.allpts[l - 2 - _i2], + y: rs.allpts[l - 1 - _i2] + }; + p1 = { + x: rs.allpts[l - 4 - _i2], + y: rs.allpts[l - 3 - _i2] + }; + } + di = dist(p0, p1); + d0 = d; + d += di; + if (d >= offset) { + break; + } + } + var pD = offset - d0; + var _t = pD / di; + _t = bound(0, _t, 1); + p = lineAt(p0, p1, _t); + angle = lineAngle(p0, p1); + break; + } + } + setRs('labelX', prefix, p.x); + setRs('labelY', prefix, p.y); + setRs('labelAutoAngle', prefix, angle); + }; + calculateEndProjection('source'); + calculateEndProjection('target'); + this.applyLabelDimensions(edge); +}; +BRp$9.applyLabelDimensions = function (ele) { + this.applyPrefixedLabelDimensions(ele); + if (ele.isEdge()) { + this.applyPrefixedLabelDimensions(ele, 'source'); + this.applyPrefixedLabelDimensions(ele, 'target'); + } +}; +BRp$9.applyPrefixedLabelDimensions = function (ele, prefix) { + var _p = ele._private; + var text = this.getLabelText(ele, prefix); + var labelDims = this.calculateLabelDimensions(ele, text); + var lineHeight = ele.pstyle('line-height').pfValue; + var textWrap = ele.pstyle('text-wrap').strValue; + var lines = getPrefixedProperty(_p.rscratch, 'labelWrapCachedLines', prefix) || []; + var numLines = textWrap !== 'wrap' ? 1 : Math.max(lines.length, 1); + var normPerLineHeight = labelDims.height / numLines; + var labelLineHeight = normPerLineHeight * lineHeight; + var width = labelDims.width; + var height = labelDims.height + (numLines - 1) * (lineHeight - 1) * normPerLineHeight; + setPrefixedProperty(_p.rstyle, 'labelWidth', prefix, width); + setPrefixedProperty(_p.rscratch, 'labelWidth', prefix, width); + setPrefixedProperty(_p.rstyle, 'labelHeight', prefix, height); + setPrefixedProperty(_p.rscratch, 'labelHeight', prefix, height); + setPrefixedProperty(_p.rscratch, 'labelLineHeight', prefix, labelLineHeight); +}; +BRp$9.getLabelText = function (ele, prefix) { + var _p = ele._private; + var pfd = prefix ? prefix + '-' : ''; + var text = ele.pstyle(pfd + 'label').strValue; + var textTransform = ele.pstyle('text-transform').value; + var rscratch = function rscratch(propName, value) { + if (value) { + setPrefixedProperty(_p.rscratch, propName, prefix, value); + return value; + } else { + return getPrefixedProperty(_p.rscratch, propName, prefix); + } + }; + + // for empty text, skip all processing + if (!text) { + return ''; + } + if (textTransform == 'none') ; else if (textTransform == 'uppercase') { + text = text.toUpperCase(); + } else if (textTransform == 'lowercase') { + text = text.toLowerCase(); + } + var wrapStyle = ele.pstyle('text-wrap').value; + if (wrapStyle === 'wrap') { + var labelKey = rscratch('labelKey'); + + // save recalc if the label is the same as before + if (labelKey != null && rscratch('labelWrapKey') === labelKey) { + return rscratch('labelWrapCachedText'); + } + var zwsp = "\u200B"; + var lines = text.split('\n'); + var maxW = ele.pstyle('text-max-width').pfValue; + var overflow = ele.pstyle('text-overflow-wrap').value; + var overflowAny = overflow === 'anywhere'; + var wrappedLines = []; + var wordsRegex = /[\s\u200b]+/; + var wordSeparator = overflowAny ? '' : ' '; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var lineDims = this.calculateLabelDimensions(ele, line); + var lineW = lineDims.width; + if (overflowAny) { + var processedLine = line.split('').join(zwsp); + line = processedLine; + } + if (lineW > maxW) { + // line is too long + var words = line.split(wordsRegex); + var subline = ''; + for (var w = 0; w < words.length; w++) { + var word = words[w]; + var testLine = subline.length === 0 ? word : subline + wordSeparator + word; + var testDims = this.calculateLabelDimensions(ele, testLine); + var testW = testDims.width; + if (testW <= maxW) { + // word fits on current line + subline += word + wordSeparator; + } else { + // word starts new line + if (subline) { + wrappedLines.push(subline); + } + subline = word + wordSeparator; + } + } + + // if there's remaining text, put it in a wrapped line + if (!subline.match(/^[\s\u200b]+$/)) { + wrappedLines.push(subline); + } + } else { + // line is already short enough + wrappedLines.push(line); + } + } // for + + rscratch('labelWrapCachedLines', wrappedLines); + text = rscratch('labelWrapCachedText', wrappedLines.join('\n')); + rscratch('labelWrapKey', labelKey); + } else if (wrapStyle === 'ellipsis') { + var _maxW = ele.pstyle('text-max-width').pfValue; + var ellipsized = ''; + var ellipsis = "\u2026"; + var incLastCh = false; + if (this.calculateLabelDimensions(ele, text).width < _maxW) { + // the label already fits + return text; + } + for (var i = 0; i < text.length; i++) { + var widthWithNextCh = this.calculateLabelDimensions(ele, ellipsized + text[i] + ellipsis).width; + if (widthWithNextCh > _maxW) { + break; + } + ellipsized += text[i]; + if (i === text.length - 1) { + incLastCh = true; + } + } + if (!incLastCh) { + ellipsized += ellipsis; + } + return ellipsized; + } // if ellipsize + + return text; +}; +BRp$9.getLabelJustification = function (ele) { + var justification = ele.pstyle('text-justification').strValue; + var textHalign = ele.pstyle('text-halign').strValue; + if (justification === 'auto') { + if (ele.isNode()) { + switch (textHalign) { + case 'left': + return 'right'; + case 'right': + return 'left'; + default: + return 'center'; + } + } else { + return 'center'; + } + } else { + return justification; + } +}; +BRp$9.calculateLabelDimensions = function (ele, text) { + var r = this; + var cacheKey = hashString(text, ele._private.labelDimsKey); + var cache = r.labelDimCache || (r.labelDimCache = []); + var existingVal = cache[cacheKey]; + if (existingVal != null) { + return existingVal; + } + var padding = 0; // add padding around text dims, as the measurement isn't that accurate + var fStyle = ele.pstyle('font-style').strValue; + var size = ele.pstyle('font-size').pfValue; + var family = ele.pstyle('font-family').strValue; + var weight = ele.pstyle('font-weight').strValue; + var canvas = this.labelCalcCanvas; + var c2d = this.labelCalcCanvasContext; + if (!canvas) { + canvas = this.labelCalcCanvas = document.createElement('canvas'); + c2d = this.labelCalcCanvasContext = canvas.getContext('2d'); + var ds = canvas.style; + ds.position = 'absolute'; + ds.left = '-9999px'; + ds.top = '-9999px'; + ds.zIndex = '-1'; + ds.visibility = 'hidden'; + ds.pointerEvents = 'none'; + } + c2d.font = "".concat(fStyle, " ").concat(weight, " ").concat(size, "px ").concat(family); + var width = 0; + var height = 0; + var lines = text.split('\n'); + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + var metrics = c2d.measureText(line); + var w = Math.ceil(metrics.width); + var h = size; + width = Math.max(w, width); + height += h; + } + width += padding; + height += padding; + return cache[cacheKey] = { + width: width, + height: height + }; +}; +BRp$9.calculateLabelAngle = function (ele, prefix) { + var _p = ele._private; + var rs = _p.rscratch; + var isEdge = ele.isEdge(); + var prefixDash = prefix ? prefix + '-' : ''; + var rot = ele.pstyle(prefixDash + 'text-rotation'); + var rotStr = rot.strValue; + if (rotStr === 'none') { + return 0; + } else if (isEdge && rotStr === 'autorotate') { + return rs.labelAutoAngle; + } else if (rotStr === 'autorotate') { + return 0; + } else { + return rot.pfValue; + } +}; +BRp$9.calculateLabelAngles = function (ele) { + var r = this; + var isEdge = ele.isEdge(); + var _p = ele._private; + var rs = _p.rscratch; + rs.labelAngle = r.calculateLabelAngle(ele); + if (isEdge) { + rs.sourceLabelAngle = r.calculateLabelAngle(ele, 'source'); + rs.targetLabelAngle = r.calculateLabelAngle(ele, 'target'); + } +}; + +var BRp$8 = {}; +var TOO_SMALL_CUT_RECT = 28; +var warnedCutRect = false; +BRp$8.getNodeShape = function (node) { + var r = this; + var shape = node.pstyle('shape').value; + if (shape === 'cutrectangle' && (node.width() < TOO_SMALL_CUT_RECT || node.height() < TOO_SMALL_CUT_RECT)) { + if (!warnedCutRect) { + warn('The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead'); + warnedCutRect = true; + } + return 'rectangle'; + } + if (node.isParent()) { + if (shape === 'rectangle' || shape === 'roundrectangle' || shape === 'round-rectangle' || shape === 'cutrectangle' || shape === 'cut-rectangle' || shape === 'barrel') { + return shape; + } else { + return 'rectangle'; + } + } + if (shape === 'polygon') { + var points = node.pstyle('shape-polygon-points').value; + return r.nodeShapes.makePolygon(points).name; + } + return shape; +}; + +var BRp$7 = {}; +BRp$7.registerCalculationListeners = function () { + var cy = this.cy; + var elesToUpdate = cy.collection(); + var r = this; + var enqueue = function enqueue(eles) { + var dirtyStyleCaches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + elesToUpdate.merge(eles); + if (dirtyStyleCaches) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var rstyle = _p.rstyle; + rstyle.clean = false; + rstyle.cleanConnected = false; + } + } + }; + r.binder(cy).on('bounds.* dirty.*', function onDirtyBounds(e) { + var ele = e.target; + enqueue(ele); + }).on('style.* background.*', function onDirtyStyle(e) { + var ele = e.target; + enqueue(ele, false); + }); + var updateEleCalcs = function updateEleCalcs(willDraw) { + if (willDraw) { + var fns = r.onUpdateEleCalcsFns; + + // because we need to have up-to-date style (e.g. stylesheet mappers) + // before calculating rendered style (and pstyle might not be called yet) + elesToUpdate.cleanStyle(); + for (var i = 0; i < elesToUpdate.length; i++) { + var ele = elesToUpdate[i]; + var rstyle = ele._private.rstyle; + if (ele.isNode() && !rstyle.cleanConnected) { + enqueue(ele.connectedEdges()); + rstyle.cleanConnected = true; + } + } + if (fns) { + for (var _i = 0; _i < fns.length; _i++) { + var fn = fns[_i]; + fn(willDraw, elesToUpdate); + } + } + r.recalculateRenderedStyle(elesToUpdate); + elesToUpdate = cy.collection(); + } + }; + r.flushRenderedStyleQueue = function () { + updateEleCalcs(true); + }; + r.beforeRender(updateEleCalcs, r.beforeRenderPriorities.eleCalcs); +}; +BRp$7.onUpdateEleCalcs = function (fn) { + var fns = this.onUpdateEleCalcsFns = this.onUpdateEleCalcsFns || []; + fns.push(fn); +}; +BRp$7.recalculateRenderedStyle = function (eles, useCache) { + var isCleanConnected = function isCleanConnected(ele) { + return ele._private.rstyle.cleanConnected; + }; + var edges = []; + var nodes = []; + + // the renderer can't be used for calcs when destroyed, e.g. ele.boundingBox() + if (this.destroyed) { + return; + } + + // use cache by default for perf + if (useCache === undefined) { + useCache = true; + } + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var rstyle = _p.rstyle; + + // an edge may be implicitly dirty b/c of one of its connected nodes + // (and a request for recalc may come in between frames) + if (ele.isEdge() && (!isCleanConnected(ele.source()) || !isCleanConnected(ele.target()))) { + rstyle.clean = false; + } + + // only update if dirty and in graph + if (useCache && rstyle.clean || ele.removed()) { + continue; + } + + // only update if not display: none + if (ele.pstyle('display').value === 'none') { + continue; + } + if (_p.group === 'nodes') { + nodes.push(ele); + } else { + // edges + edges.push(ele); + } + rstyle.clean = true; + } + + // update node data from projections + for (var _i2 = 0; _i2 < nodes.length; _i2++) { + var _ele = nodes[_i2]; + var _p2 = _ele._private; + var _rstyle = _p2.rstyle; + var pos = _ele.position(); + this.recalculateNodeLabelProjection(_ele); + _rstyle.nodeX = pos.x; + _rstyle.nodeY = pos.y; + _rstyle.nodeW = _ele.pstyle('width').pfValue; + _rstyle.nodeH = _ele.pstyle('height').pfValue; + } + this.recalculateEdgeProjections(edges); + + // update edge data from projections + for (var _i3 = 0; _i3 < edges.length; _i3++) { + var _ele2 = edges[_i3]; + var _p3 = _ele2._private; + var _rstyle2 = _p3.rstyle; + var rs = _p3.rscratch; + + // update rstyle positions + _rstyle2.srcX = rs.arrowStartX; + _rstyle2.srcY = rs.arrowStartY; + _rstyle2.tgtX = rs.arrowEndX; + _rstyle2.tgtY = rs.arrowEndY; + _rstyle2.midX = rs.midX; + _rstyle2.midY = rs.midY; + _rstyle2.labelAngle = rs.labelAngle; + _rstyle2.sourceLabelAngle = rs.sourceLabelAngle; + _rstyle2.targetLabelAngle = rs.targetLabelAngle; + } +}; + +var BRp$6 = {}; +BRp$6.updateCachedGrabbedEles = function () { + var eles = this.cachedZSortedEles; + if (!eles) { + // just let this be recalculated on the next z sort tick + return; + } + eles.drag = []; + eles.nondrag = []; + var grabTargets = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var rs = ele._private.rscratch; + if (ele.grabbed() && !ele.isParent()) { + grabTargets.push(ele); + } else if (rs.inDragLayer) { + eles.drag.push(ele); + } else { + eles.nondrag.push(ele); + } + } + + // put the grab target nodes last so it's on top of its neighbourhood + for (var i = 0; i < grabTargets.length; i++) { + var ele = grabTargets[i]; + eles.drag.push(ele); + } +}; +BRp$6.invalidateCachedZSortedEles = function () { + this.cachedZSortedEles = null; +}; +BRp$6.getCachedZSortedEles = function (forceRecalc) { + if (forceRecalc || !this.cachedZSortedEles) { + var eles = this.cy.mutableElements().toArray(); + eles.sort(zIndexSort); + eles.interactive = eles.filter(function (ele) { + return ele.interactive(); + }); + this.cachedZSortedEles = eles; + this.updateCachedGrabbedEles(); + } else { + eles = this.cachedZSortedEles; + } + return eles; +}; + +var BRp$5 = {}; +[BRp$e, BRp$d, BRp$c, BRp$b, BRp$a, BRp$9, BRp$8, BRp$7, BRp$6].forEach(function (props) { + extend(BRp$5, props); +}); + +var BRp$4 = {}; +BRp$4.getCachedImage = function (url, crossOrigin, onLoad) { + var r = this; + var imageCache = r.imageCache = r.imageCache || {}; + var cache = imageCache[url]; + if (cache) { + if (!cache.image.complete) { + cache.image.addEventListener('load', onLoad); + } + return cache.image; + } else { + cache = imageCache[url] = imageCache[url] || {}; + var image = cache.image = new Image(); // eslint-disable-line no-undef + + image.addEventListener('load', onLoad); + image.addEventListener('error', function () { + image.error = true; + }); + + // #1582 safari doesn't load data uris with crossOrigin properly + // https://bugs.webkit.org/show_bug.cgi?id=123978 + var dataUriPrefix = 'data:'; + var isDataUri = url.substring(0, dataUriPrefix.length).toLowerCase() === dataUriPrefix; + if (!isDataUri) { + // if crossorigin is 'null'(stringified), then manually set it to null + crossOrigin = crossOrigin === 'null' ? null : crossOrigin; + image.crossOrigin = crossOrigin; // prevent tainted canvas + } + + image.src = url; + return image; + } +}; + +var BRp$3 = {}; + +/* global document, window, ResizeObserver, MutationObserver */ + +BRp$3.registerBinding = function (target, event, handler, useCapture) { + // eslint-disable-line no-unused-vars + var args = Array.prototype.slice.apply(arguments, [1]); // copy + var b = this.binder(target); + return b.on.apply(b, args); +}; +BRp$3.binder = function (tgt) { + var r = this; + var containerWindow = r.cy.window(); + var tgtIsDom = tgt === containerWindow || tgt === containerWindow.document || tgt === containerWindow.document.body || domElement(tgt); + if (r.supportsPassiveEvents == null) { + // from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection + var supportsPassive = false; + try { + var opts = Object.defineProperty({}, 'passive', { + get: function get() { + supportsPassive = true; + return true; + } + }); + containerWindow.addEventListener('test', null, opts); + } catch (err) { + // not supported + } + r.supportsPassiveEvents = supportsPassive; + } + var on = function on(event, handler, useCapture) { + var args = Array.prototype.slice.call(arguments); + if (tgtIsDom && r.supportsPassiveEvents) { + // replace useCapture w/ opts obj + args[2] = { + capture: useCapture != null ? useCapture : false, + passive: false, + once: false + }; + } + r.bindings.push({ + target: tgt, + args: args + }); + (tgt.addEventListener || tgt.on).apply(tgt, args); + return this; + }; + return { + on: on, + addEventListener: on, + addListener: on, + bind: on + }; +}; +BRp$3.nodeIsDraggable = function (node) { + return node && node.isNode() && !node.locked() && node.grabbable(); +}; +BRp$3.nodeIsGrabbable = function (node) { + return this.nodeIsDraggable(node) && node.interactive(); +}; +BRp$3.load = function () { + var r = this; + var containerWindow = r.cy.window(); + var isSelected = function isSelected(ele) { + return ele.selected(); + }; + var triggerEvents = function triggerEvents(target, names, e, position) { + if (target == null) { + target = r.cy; + } + for (var i = 0; i < names.length; i++) { + var name = names[i]; + target.emit({ + originalEvent: e, + type: name, + position: position + }); + } + }; + var isMultSelKeyDown = function isMultSelKeyDown(e) { + return e.shiftKey || e.metaKey || e.ctrlKey; // maybe e.altKey + }; + + var allowPanningPassthrough = function allowPanningPassthrough(down, downs) { + var allowPassthrough = true; + if (r.cy.hasCompoundNodes() && down && down.pannable()) { + // a grabbable compound node below the ele => no passthrough panning + for (var i = 0; downs && i < downs.length; i++) { + var down = downs[i]; + + //if any parent node in event hierarchy isn't pannable, reject passthrough + if (down.isNode() && down.isParent() && !down.pannable()) { + allowPassthrough = false; + break; + } + } + } else { + allowPassthrough = true; + } + return allowPassthrough; + }; + var setGrabbed = function setGrabbed(ele) { + ele[0]._private.grabbed = true; + }; + var setFreed = function setFreed(ele) { + ele[0]._private.grabbed = false; + }; + var setInDragLayer = function setInDragLayer(ele) { + ele[0]._private.rscratch.inDragLayer = true; + }; + var setOutDragLayer = function setOutDragLayer(ele) { + ele[0]._private.rscratch.inDragLayer = false; + }; + var setGrabTarget = function setGrabTarget(ele) { + ele[0]._private.rscratch.isGrabTarget = true; + }; + var removeGrabTarget = function removeGrabTarget(ele) { + ele[0]._private.rscratch.isGrabTarget = false; + }; + var addToDragList = function addToDragList(ele, opts) { + var list = opts.addToList; + var listHasEle = list.has(ele); + if (!listHasEle && ele.grabbable() && !ele.locked()) { + list.merge(ele); + setGrabbed(ele); + } + }; + + // helper function to determine which child nodes and inner edges + // of a compound node to be dragged as well as the grabbed and selected nodes + var addDescendantsToDrag = function addDescendantsToDrag(node, opts) { + if (!node.cy().hasCompoundNodes()) { + return; + } + if (opts.inDragLayer == null && opts.addToList == null) { + return; + } // nothing to do + + var innerNodes = node.descendants(); + if (opts.inDragLayer) { + innerNodes.forEach(setInDragLayer); + innerNodes.connectedEdges().forEach(setInDragLayer); + } + if (opts.addToList) { + addToDragList(innerNodes, opts); + } + }; + + // adds the given nodes and its neighbourhood to the drag layer + var addNodesToDrag = function addNodesToDrag(nodes, opts) { + opts = opts || {}; + var hasCompoundNodes = nodes.cy().hasCompoundNodes(); + if (opts.inDragLayer) { + nodes.forEach(setInDragLayer); + nodes.neighborhood().stdFilter(function (ele) { + return !hasCompoundNodes || ele.isEdge(); + }).forEach(setInDragLayer); + } + if (opts.addToList) { + nodes.forEach(function (ele) { + addToDragList(ele, opts); + }); + } + addDescendantsToDrag(nodes, opts); // always add to drag + + // also add nodes and edges related to the topmost ancestor + updateAncestorsInDragLayer(nodes, { + inDragLayer: opts.inDragLayer + }); + r.updateCachedGrabbedEles(); + }; + var addNodeToDrag = addNodesToDrag; + var freeDraggedElements = function freeDraggedElements(grabbedEles) { + if (!grabbedEles) { + return; + } + + // just go over all elements rather than doing a bunch of (possibly expensive) traversals + r.getCachedZSortedEles().forEach(function (ele) { + setFreed(ele); + setOutDragLayer(ele); + removeGrabTarget(ele); + }); + r.updateCachedGrabbedEles(); + }; + + // helper function to determine which ancestor nodes and edges should go + // to the drag layer (or should be removed from drag layer). + var updateAncestorsInDragLayer = function updateAncestorsInDragLayer(node, opts) { + if (opts.inDragLayer == null && opts.addToList == null) { + return; + } // nothing to do + + if (!node.cy().hasCompoundNodes()) { + return; + } + + // find top-level parent + var parent = node.ancestors().orphans(); + + // no parent node: no nodes to add to the drag layer + if (parent.same(node)) { + return; + } + var nodes = parent.descendants().spawnSelf().merge(parent).unmerge(node).unmerge(node.descendants()); + var edges = nodes.connectedEdges(); + if (opts.inDragLayer) { + edges.forEach(setInDragLayer); + nodes.forEach(setInDragLayer); + } + if (opts.addToList) { + nodes.forEach(function (ele) { + addToDragList(ele, opts); + }); + } + }; + var blurActiveDomElement = function blurActiveDomElement() { + if (document.activeElement != null && document.activeElement.blur != null) { + document.activeElement.blur(); + } + }; + var haveMutationsApi = typeof MutationObserver !== 'undefined'; + var haveResizeObserverApi = typeof ResizeObserver !== 'undefined'; + + // watch for when the cy container is removed from the dom + if (haveMutationsApi) { + r.removeObserver = new MutationObserver(function (mutns) { + // eslint-disable-line no-undef + for (var i = 0; i < mutns.length; i++) { + var mutn = mutns[i]; + var rNodes = mutn.removedNodes; + if (rNodes) { + for (var j = 0; j < rNodes.length; j++) { + var rNode = rNodes[j]; + if (rNode === r.container) { + r.destroy(); + break; + } + } + } + } + }); + if (r.container.parentNode) { + r.removeObserver.observe(r.container.parentNode, { + childList: true + }); + } + } else { + r.registerBinding(r.container, 'DOMNodeRemoved', function (e) { + // eslint-disable-line no-unused-vars + r.destroy(); + }); + } + var onResize = debounce_1(function () { + r.cy.resize(); + }, 100); + if (haveMutationsApi) { + r.styleObserver = new MutationObserver(onResize); // eslint-disable-line no-undef + + r.styleObserver.observe(r.container, { + attributes: true + }); + } + + // auto resize + r.registerBinding(containerWindow, 'resize', onResize); // eslint-disable-line no-undef + + if (haveResizeObserverApi) { + r.resizeObserver = new ResizeObserver(onResize); // eslint-disable-line no-undef + + r.resizeObserver.observe(r.container); + } + var forEachUp = function forEachUp(domEle, fn) { + while (domEle != null) { + fn(domEle); + domEle = domEle.parentNode; + } + }; + var invalidateCoords = function invalidateCoords() { + r.invalidateContainerClientCoordsCache(); + }; + forEachUp(r.container, function (domEle) { + r.registerBinding(domEle, 'transitionend', invalidateCoords); + r.registerBinding(domEle, 'animationend', invalidateCoords); + r.registerBinding(domEle, 'scroll', invalidateCoords); + }); + + // stop right click menu from appearing on cy + r.registerBinding(r.container, 'contextmenu', function (e) { + e.preventDefault(); + }); + var inBoxSelection = function inBoxSelection() { + return r.selection[4] !== 0; + }; + var eventInContainer = function eventInContainer(e) { + // save cycles if mouse events aren't to be captured + var containerPageCoords = r.findContainerClientCoords(); + var x = containerPageCoords[0]; + var y = containerPageCoords[1]; + var width = containerPageCoords[2]; + var height = containerPageCoords[3]; + var positions = e.touches ? e.touches : [e]; + var atLeastOnePosInside = false; + for (var i = 0; i < positions.length; i++) { + var p = positions[i]; + if (x <= p.clientX && p.clientX <= x + width && y <= p.clientY && p.clientY <= y + height) { + atLeastOnePosInside = true; + break; + } + } + if (!atLeastOnePosInside) { + return false; + } + var container = r.container; + var target = e.target; + var tParent = target.parentNode; + var containerIsTarget = false; + while (tParent) { + if (tParent === container) { + containerIsTarget = true; + break; + } + tParent = tParent.parentNode; + } + if (!containerIsTarget) { + return false; + } // if target is outisde cy container, then this event is not for us + + return true; + }; + + // Primary key + r.registerBinding(r.container, 'mousedown', function mousedownHandler(e) { + if (!eventInContainer(e)) { + return; + } + e.preventDefault(); + blurActiveDomElement(); + r.hoverData.capture = true; + r.hoverData.which = e.which; + var cy = r.cy; + var gpos = [e.clientX, e.clientY]; + var pos = r.projectIntoViewport(gpos[0], gpos[1]); + var select = r.selection; + var nears = r.findNearestElements(pos[0], pos[1], true, false); + var near = nears[0]; + var draggedElements = r.dragData.possibleDragElements; + r.hoverData.mdownPos = pos; + r.hoverData.mdownGPos = gpos; + var checkForTaphold = function checkForTaphold() { + r.hoverData.tapholdCancelled = false; + clearTimeout(r.hoverData.tapholdTimeout); + r.hoverData.tapholdTimeout = setTimeout(function () { + if (r.hoverData.tapholdCancelled) { + return; + } else { + var ele = r.hoverData.down; + if (ele) { + ele.emit({ + originalEvent: e, + type: 'taphold', + position: { + x: pos[0], + y: pos[1] + } + }); + } else { + cy.emit({ + originalEvent: e, + type: 'taphold', + position: { + x: pos[0], + y: pos[1] + } + }); + } + } + }, r.tapholdDuration); + }; + + // Right click button + if (e.which == 3) { + r.hoverData.cxtStarted = true; + var cxtEvt = { + originalEvent: e, + type: 'cxttapstart', + position: { + x: pos[0], + y: pos[1] + } + }; + if (near) { + near.activate(); + near.emit(cxtEvt); + r.hoverData.down = near; + } else { + cy.emit(cxtEvt); + } + r.hoverData.downTime = new Date().getTime(); + r.hoverData.cxtDragged = false; + + // Primary button + } else if (e.which == 1) { + if (near) { + near.activate(); + } + + // Element dragging + { + // If something is under the cursor and it is draggable, prepare to grab it + if (near != null) { + if (r.nodeIsGrabbable(near)) { + var makeEvent = function makeEvent(type) { + return { + originalEvent: e, + type: type, + position: { + x: pos[0], + y: pos[1] + } + }; + }; + var triggerGrab = function triggerGrab(ele) { + ele.emit(makeEvent('grab')); + }; + setGrabTarget(near); + if (!near.selected()) { + draggedElements = r.dragData.possibleDragElements = cy.collection(); + addNodeToDrag(near, { + addToList: draggedElements + }); + near.emit(makeEvent('grabon')).emit(makeEvent('grab')); + } else { + draggedElements = r.dragData.possibleDragElements = cy.collection(); + var selectedNodes = cy.$(function (ele) { + return ele.isNode() && ele.selected() && r.nodeIsGrabbable(ele); + }); + addNodesToDrag(selectedNodes, { + addToList: draggedElements + }); + near.emit(makeEvent('grabon')); + selectedNodes.forEach(triggerGrab); + } + r.redrawHint('eles', true); + r.redrawHint('drag', true); + } + } + r.hoverData.down = near; + r.hoverData.downs = nears; + r.hoverData.downTime = new Date().getTime(); + } + triggerEvents(near, ['mousedown', 'tapstart', 'vmousedown'], e, { + x: pos[0], + y: pos[1] + }); + if (near == null) { + select[4] = 1; + r.data.bgActivePosistion = { + x: pos[0], + y: pos[1] + }; + r.redrawHint('select', true); + r.redraw(); + } else if (near.pannable()) { + select[4] = 1; // for future pan + } + + checkForTaphold(); + } + + // Initialize selection box coordinates + select[0] = select[2] = pos[0]; + select[1] = select[3] = pos[1]; + }, false); + r.registerBinding(containerWindow, 'mousemove', function mousemoveHandler(e) { + // eslint-disable-line no-undef + var capture = r.hoverData.capture; + if (!capture && !eventInContainer(e)) { + return; + } + var preventDefault = false; + var cy = r.cy; + var zoom = cy.zoom(); + var gpos = [e.clientX, e.clientY]; + var pos = r.projectIntoViewport(gpos[0], gpos[1]); + var mdownPos = r.hoverData.mdownPos; + var mdownGPos = r.hoverData.mdownGPos; + var select = r.selection; + var near = null; + if (!r.hoverData.draggingEles && !r.hoverData.dragging && !r.hoverData.selecting) { + near = r.findNearestElement(pos[0], pos[1], true, false); + } + var last = r.hoverData.last; + var down = r.hoverData.down; + var disp = [pos[0] - select[2], pos[1] - select[3]]; + var draggedElements = r.dragData.possibleDragElements; + var isOverThresholdDrag; + if (mdownGPos) { + var dx = gpos[0] - mdownGPos[0]; + var dx2 = dx * dx; + var dy = gpos[1] - mdownGPos[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + r.hoverData.isOverThresholdDrag = isOverThresholdDrag = dist2 >= r.desktopTapThreshold2; + } + var multSelKeyDown = isMultSelKeyDown(e); + if (isOverThresholdDrag) { + r.hoverData.tapholdCancelled = true; + } + var updateDragDelta = function updateDragDelta() { + var dragDelta = r.hoverData.dragDelta = r.hoverData.dragDelta || []; + if (dragDelta.length === 0) { + dragDelta.push(disp[0]); + dragDelta.push(disp[1]); + } else { + dragDelta[0] += disp[0]; + dragDelta[1] += disp[1]; + } + }; + preventDefault = true; + triggerEvents(near, ['mousemove', 'vmousemove', 'tapdrag'], e, { + x: pos[0], + y: pos[1] + }); + var goIntoBoxMode = function goIntoBoxMode() { + r.data.bgActivePosistion = undefined; + if (!r.hoverData.selecting) { + cy.emit({ + originalEvent: e, + type: 'boxstart', + position: { + x: pos[0], + y: pos[1] + } + }); + } + select[4] = 1; + r.hoverData.selecting = true; + r.redrawHint('select', true); + r.redraw(); + }; + + // trigger context drag if rmouse down + if (r.hoverData.which === 3) { + // but only if over threshold + if (isOverThresholdDrag) { + var cxtEvt = { + originalEvent: e, + type: 'cxtdrag', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + r.hoverData.cxtDragged = true; + if (!r.hoverData.cxtOver || near !== r.hoverData.cxtOver) { + if (r.hoverData.cxtOver) { + r.hoverData.cxtOver.emit({ + originalEvent: e, + type: 'cxtdragout', + position: { + x: pos[0], + y: pos[1] + } + }); + } + r.hoverData.cxtOver = near; + if (near) { + near.emit({ + originalEvent: e, + type: 'cxtdragover', + position: { + x: pos[0], + y: pos[1] + } + }); + } + } + } + + // Check if we are drag panning the entire graph + } else if (r.hoverData.dragging) { + preventDefault = true; + if (cy.panningEnabled() && cy.userPanningEnabled()) { + var deltaP; + if (r.hoverData.justStartedPan) { + var mdPos = r.hoverData.mdownPos; + deltaP = { + x: (pos[0] - mdPos[0]) * zoom, + y: (pos[1] - mdPos[1]) * zoom + }; + r.hoverData.justStartedPan = false; + } else { + deltaP = { + x: disp[0] * zoom, + y: disp[1] * zoom + }; + } + cy.panBy(deltaP); + cy.emit('dragpan'); + r.hoverData.dragged = true; + } + + // Needs reproject due to pan changing viewport + pos = r.projectIntoViewport(e.clientX, e.clientY); + + // Checks primary button down & out of time & mouse not moved much + } else if (select[4] == 1 && (down == null || down.pannable())) { + if (isOverThresholdDrag) { + if (!r.hoverData.dragging && cy.boxSelectionEnabled() && (multSelKeyDown || !cy.panningEnabled() || !cy.userPanningEnabled())) { + goIntoBoxMode(); + } else if (!r.hoverData.selecting && cy.panningEnabled() && cy.userPanningEnabled()) { + var allowPassthrough = allowPanningPassthrough(down, r.hoverData.downs); + if (allowPassthrough) { + r.hoverData.dragging = true; + r.hoverData.justStartedPan = true; + select[4] = 0; + r.data.bgActivePosistion = array2point(mdownPos); + r.redrawHint('select', true); + r.redraw(); + } + } + if (down && down.pannable() && down.active()) { + down.unactivate(); + } + } + } else { + if (down && down.pannable() && down.active()) { + down.unactivate(); + } + if ((!down || !down.grabbed()) && near != last) { + if (last) { + triggerEvents(last, ['mouseout', 'tapdragout'], e, { + x: pos[0], + y: pos[1] + }); + } + if (near) { + triggerEvents(near, ['mouseover', 'tapdragover'], e, { + x: pos[0], + y: pos[1] + }); + } + r.hoverData.last = near; + } + if (down) { + if (isOverThresholdDrag) { + // then we can take action + + if (cy.boxSelectionEnabled() && multSelKeyDown) { + // then selection overrides + if (down && down.grabbed()) { + freeDraggedElements(draggedElements); + down.emit('freeon'); + draggedElements.emit('free'); + if (r.dragData.didDrag) { + down.emit('dragfreeon'); + draggedElements.emit('dragfree'); + } + } + goIntoBoxMode(); + } else if (down && down.grabbed() && r.nodeIsDraggable(down)) { + // drag node + var justStartedDrag = !r.dragData.didDrag; + if (justStartedDrag) { + r.redrawHint('eles', true); + } + r.dragData.didDrag = true; // indicate that we actually did drag the node + + // now, add the elements to the drag layer if not done already + if (!r.hoverData.draggingEles) { + addNodesToDrag(draggedElements, { + inDragLayer: true + }); + } + var totalShift = { + x: 0, + y: 0 + }; + if (number$1(disp[0]) && number$1(disp[1])) { + totalShift.x += disp[0]; + totalShift.y += disp[1]; + if (justStartedDrag) { + var dragDelta = r.hoverData.dragDelta; + if (dragDelta && number$1(dragDelta[0]) && number$1(dragDelta[1])) { + totalShift.x += dragDelta[0]; + totalShift.y += dragDelta[1]; + } + } + } + r.hoverData.draggingEles = true; + draggedElements.silentShift(totalShift).emit('position drag'); + r.redrawHint('drag', true); + r.redraw(); + } + } else { + // otherwise save drag delta for when we actually start dragging so the relative grab pos is constant + updateDragDelta(); + } + } + + // prevent the dragging from triggering text selection on the page + preventDefault = true; + } + select[2] = pos[0]; + select[3] = pos[1]; + if (preventDefault) { + if (e.stopPropagation) e.stopPropagation(); + if (e.preventDefault) e.preventDefault(); + return false; + } + }, false); + var clickTimeout, didDoubleClick, prevClickTimeStamp; + r.registerBinding(containerWindow, 'mouseup', function mouseupHandler(e) { + // eslint-disable-line no-undef + var capture = r.hoverData.capture; + if (!capture) { + return; + } + r.hoverData.capture = false; + var cy = r.cy; + var pos = r.projectIntoViewport(e.clientX, e.clientY); + var select = r.selection; + var near = r.findNearestElement(pos[0], pos[1], true, false); + var draggedElements = r.dragData.possibleDragElements; + var down = r.hoverData.down; + var multSelKeyDown = isMultSelKeyDown(e); + if (r.data.bgActivePosistion) { + r.redrawHint('select', true); + r.redraw(); + } + r.hoverData.tapholdCancelled = true; + r.data.bgActivePosistion = undefined; // not active bg now + + if (down) { + down.unactivate(); + } + if (r.hoverData.which === 3) { + var cxtEvt = { + originalEvent: e, + type: 'cxttapend', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + if (!r.hoverData.cxtDragged) { + var cxtTap = { + originalEvent: e, + type: 'cxttap', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtTap); + } else { + cy.emit(cxtTap); + } + } + r.hoverData.cxtDragged = false; + r.hoverData.which = null; + } else if (r.hoverData.which === 1) { + triggerEvents(near, ['mouseup', 'tapend', 'vmouseup'], e, { + x: pos[0], + y: pos[1] + }); + if (!r.dragData.didDrag && + // didn't move a node around + !r.hoverData.dragged && + // didn't pan + !r.hoverData.selecting && + // not box selection + !r.hoverData.isOverThresholdDrag // didn't move too much + ) { + triggerEvents(down, ["click", "tap", "vclick"], e, { + x: pos[0], + y: pos[1] + }); + didDoubleClick = false; + if (e.timeStamp - prevClickTimeStamp <= cy.multiClickDebounceTime()) { + clickTimeout && clearTimeout(clickTimeout); + didDoubleClick = true; + prevClickTimeStamp = null; + triggerEvents(down, ["dblclick", "dbltap", "vdblclick"], e, { + x: pos[0], + y: pos[1] + }); + } else { + clickTimeout = setTimeout(function () { + if (didDoubleClick) return; + triggerEvents(down, ["oneclick", "onetap", "voneclick"], e, { + x: pos[0], + y: pos[1] + }); + }, cy.multiClickDebounceTime()); + prevClickTimeStamp = e.timeStamp; + } + } + + // Deselect all elements if nothing is currently under the mouse cursor and we aren't dragging something + if (down == null // not mousedown on node + && !r.dragData.didDrag // didn't move the node around + && !r.hoverData.selecting // not box selection + && !r.hoverData.dragged // didn't pan + && !isMultSelKeyDown(e)) { + cy.$(isSelected).unselect(['tapunselect']); + if (draggedElements.length > 0) { + r.redrawHint('eles', true); + } + r.dragData.possibleDragElements = draggedElements = cy.collection(); + } + + // Single selection + if (near == down && !r.dragData.didDrag && !r.hoverData.selecting) { + if (near != null && near._private.selectable) { + if (r.hoverData.dragging) ; else if (cy.selectionType() === 'additive' || multSelKeyDown) { + if (near.selected()) { + near.unselect(['tapunselect']); + } else { + near.select(['tapselect']); + } + } else { + if (!multSelKeyDown) { + cy.$(isSelected).unmerge(near).unselect(['tapunselect']); + near.select(['tapselect']); + } + } + r.redrawHint('eles', true); + } + } + if (r.hoverData.selecting) { + var box = cy.collection(r.getAllInBox(select[0], select[1], select[2], select[3])); + r.redrawHint('select', true); + if (box.length > 0) { + r.redrawHint('eles', true); + } + cy.emit({ + type: 'boxend', + originalEvent: e, + position: { + x: pos[0], + y: pos[1] + } + }); + var eleWouldBeSelected = function eleWouldBeSelected(ele) { + return ele.selectable() && !ele.selected(); + }; + if (cy.selectionType() === 'additive') { + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + } else { + if (!multSelKeyDown) { + cy.$(isSelected).unmerge(box).unselect(); + } + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + } + + // always need redraw in case eles unselectable + r.redraw(); + } + + // Cancel drag pan + if (r.hoverData.dragging) { + r.hoverData.dragging = false; + r.redrawHint('select', true); + r.redrawHint('eles', true); + r.redraw(); + } + if (!select[4]) { + r.redrawHint('drag', true); + r.redrawHint('eles', true); + var downWasGrabbed = down && down.grabbed(); + freeDraggedElements(draggedElements); + if (downWasGrabbed) { + down.emit('freeon'); + draggedElements.emit('free'); + if (r.dragData.didDrag) { + down.emit('dragfreeon'); + draggedElements.emit('dragfree'); + } + } + } + } // else not right mouse + + select[4] = 0; + r.hoverData.down = null; + r.hoverData.cxtStarted = false; + r.hoverData.draggingEles = false; + r.hoverData.selecting = false; + r.hoverData.isOverThresholdDrag = false; + r.dragData.didDrag = false; + r.hoverData.dragged = false; + r.hoverData.dragDelta = []; + r.hoverData.mdownPos = null; + r.hoverData.mdownGPos = null; + }, false); + var wheelHandler = function wheelHandler(e) { + if (r.scrollingPage) { + return; + } // while scrolling, ignore wheel-to-zoom + + var cy = r.cy; + var zoom = cy.zoom(); + var pan = cy.pan(); + var pos = r.projectIntoViewport(e.clientX, e.clientY); + var rpos = [pos[0] * zoom + pan.x, pos[1] * zoom + pan.y]; + if (r.hoverData.draggingEles || r.hoverData.dragging || r.hoverData.cxtStarted || inBoxSelection()) { + // if pan dragging or cxt dragging, wheel movements make no zoom + e.preventDefault(); + return; + } + if (cy.panningEnabled() && cy.userPanningEnabled() && cy.zoomingEnabled() && cy.userZoomingEnabled()) { + e.preventDefault(); + r.data.wheelZooming = true; + clearTimeout(r.data.wheelTimeout); + r.data.wheelTimeout = setTimeout(function () { + r.data.wheelZooming = false; + r.redrawHint('eles', true); + r.redraw(); + }, 150); + var diff; + if (e.deltaY != null) { + diff = e.deltaY / -250; + } else if (e.wheelDeltaY != null) { + diff = e.wheelDeltaY / 1000; + } else { + diff = e.wheelDelta / 1000; + } + diff = diff * r.wheelSensitivity; + var needsWheelFix = e.deltaMode === 1; + if (needsWheelFix) { + // fixes slow wheel events on ff/linux and ff/windows + diff *= 33; + } + var newZoom = cy.zoom() * Math.pow(10, diff); + if (e.type === 'gesturechange') { + newZoom = r.gestureStartZoom * e.scale; + } + cy.zoom({ + level: newZoom, + renderedPosition: { + x: rpos[0], + y: rpos[1] + } + }); + cy.emit(e.type === 'gesturechange' ? 'pinchzoom' : 'scrollzoom'); + } + }; + + // Functions to help with whether mouse wheel should trigger zooming + // -- + r.registerBinding(r.container, 'wheel', wheelHandler, true); + + // disable nonstandard wheel events + // r.registerBinding(r.container, 'mousewheel', wheelHandler, true); + // r.registerBinding(r.container, 'DOMMouseScroll', wheelHandler, true); + // r.registerBinding(r.container, 'MozMousePixelScroll', wheelHandler, true); // older firefox + + r.registerBinding(containerWindow, 'scroll', function scrollHandler(e) { + // eslint-disable-line no-unused-vars + r.scrollingPage = true; + clearTimeout(r.scrollingPageTimeout); + r.scrollingPageTimeout = setTimeout(function () { + r.scrollingPage = false; + }, 250); + }, true); + + // desktop safari pinch to zoom start + r.registerBinding(r.container, 'gesturestart', function gestureStartHandler(e) { + r.gestureStartZoom = r.cy.zoom(); + if (!r.hasTouchStarted) { + // don't affect touch devices like iphone + e.preventDefault(); + } + }, true); + r.registerBinding(r.container, 'gesturechange', function (e) { + if (!r.hasTouchStarted) { + // don't affect touch devices like iphone + wheelHandler(e); + } + }, true); + + // Functions to help with handling mouseout/mouseover on the Cytoscape container + // Handle mouseout on Cytoscape container + r.registerBinding(r.container, 'mouseout', function mouseOutHandler(e) { + var pos = r.projectIntoViewport(e.clientX, e.clientY); + r.cy.emit({ + originalEvent: e, + type: 'mouseout', + position: { + x: pos[0], + y: pos[1] + } + }); + }, false); + r.registerBinding(r.container, 'mouseover', function mouseOverHandler(e) { + var pos = r.projectIntoViewport(e.clientX, e.clientY); + r.cy.emit({ + originalEvent: e, + type: 'mouseover', + position: { + x: pos[0], + y: pos[1] + } + }); + }, false); + var f1x1, f1y1, f2x1, f2y1; // starting points for pinch-to-zoom + var distance1, distance1Sq; // initial distance between finger 1 and finger 2 for pinch-to-zoom + var center1, modelCenter1; // center point on start pinch to zoom + var offsetLeft, offsetTop; + var containerWidth, containerHeight; + var twoFingersStartInside; + var distance = function distance(x1, y1, x2, y2) { + return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + }; + var distanceSq = function distanceSq(x1, y1, x2, y2) { + return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); + }; + var touchstartHandler; + r.registerBinding(r.container, 'touchstart', touchstartHandler = function touchstartHandler(e) { + r.hasTouchStarted = true; + if (!eventInContainer(e)) { + return; + } + blurActiveDomElement(); + r.touchData.capture = true; + r.data.bgActivePosistion = undefined; + var cy = r.cy; + var now = r.touchData.now; + var earlier = r.touchData.earlier; + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + + // record starting points for pinch-to-zoom + if (e.touches[1]) { + r.touchData.singleTouchMoved = true; + freeDraggedElements(r.dragData.touchDragEles); + var offsets = r.findContainerClientCoords(); + offsetLeft = offsets[0]; + offsetTop = offsets[1]; + containerWidth = offsets[2]; + containerHeight = offsets[3]; + f1x1 = e.touches[0].clientX - offsetLeft; + f1y1 = e.touches[0].clientY - offsetTop; + f2x1 = e.touches[1].clientX - offsetLeft; + f2y1 = e.touches[1].clientY - offsetTop; + twoFingersStartInside = 0 <= f1x1 && f1x1 <= containerWidth && 0 <= f2x1 && f2x1 <= containerWidth && 0 <= f1y1 && f1y1 <= containerHeight && 0 <= f2y1 && f2y1 <= containerHeight; + var pan = cy.pan(); + var zoom = cy.zoom(); + distance1 = distance(f1x1, f1y1, f2x1, f2y1); + distance1Sq = distanceSq(f1x1, f1y1, f2x1, f2y1); + center1 = [(f1x1 + f2x1) / 2, (f1y1 + f2y1) / 2]; + modelCenter1 = [(center1[0] - pan.x) / zoom, (center1[1] - pan.y) / zoom]; + + // consider context tap + var cxtDistThreshold = 200; + var cxtDistThresholdSq = cxtDistThreshold * cxtDistThreshold; + if (distance1Sq < cxtDistThresholdSq && !e.touches[2]) { + var near1 = r.findNearestElement(now[0], now[1], true, true); + var near2 = r.findNearestElement(now[2], now[3], true, true); + if (near1 && near1.isNode()) { + near1.activate().emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + r.touchData.start = near1; + } else if (near2 && near2.isNode()) { + near2.activate().emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + r.touchData.start = near2; + } else { + cy.emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxt = true; + r.touchData.cxtDragged = false; + r.data.bgActivePosistion = undefined; + r.redraw(); + return; + } + } + if (e.touches[2]) { + // ignore + + // safari on ios pans the page otherwise (normally you should be able to preventdefault on touchmove...) + if (cy.boxSelectionEnabled()) { + e.preventDefault(); + } + } else if (e.touches[1]) ; else if (e.touches[0]) { + var nears = r.findNearestElements(now[0], now[1], true, true); + var near = nears[0]; + if (near != null) { + near.activate(); + r.touchData.start = near; + r.touchData.starts = nears; + if (r.nodeIsGrabbable(near)) { + var draggedEles = r.dragData.touchDragEles = cy.collection(); + var selectedNodes = null; + r.redrawHint('eles', true); + r.redrawHint('drag', true); + if (near.selected()) { + // reset drag elements, since near will be added again + + selectedNodes = cy.$(function (ele) { + return ele.selected() && r.nodeIsGrabbable(ele); + }); + addNodesToDrag(selectedNodes, { + addToList: draggedEles + }); + } else { + addNodeToDrag(near, { + addToList: draggedEles + }); + } + setGrabTarget(near); + var makeEvent = function makeEvent(type) { + return { + originalEvent: e, + type: type, + position: { + x: now[0], + y: now[1] + } + }; + }; + near.emit(makeEvent('grabon')); + if (selectedNodes) { + selectedNodes.forEach(function (n) { + n.emit(makeEvent('grab')); + }); + } else { + near.emit(makeEvent('grab')); + } + } + } + triggerEvents(near, ['touchstart', 'tapstart', 'vmousedown'], e, { + x: now[0], + y: now[1] + }); + if (near == null) { + r.data.bgActivePosistion = { + x: pos[0], + y: pos[1] + }; + r.redrawHint('select', true); + r.redraw(); + } + + // Tap, taphold + // ----- + + r.touchData.singleTouchMoved = false; + r.touchData.singleTouchStartTime = +new Date(); + clearTimeout(r.touchData.tapholdTimeout); + r.touchData.tapholdTimeout = setTimeout(function () { + if (r.touchData.singleTouchMoved === false && !r.pinching // if pinching, then taphold unselect shouldn't take effect + && !r.touchData.selecting // box selection shouldn't allow taphold through + ) { + triggerEvents(r.touchData.start, ['taphold'], e, { + x: now[0], + y: now[1] + }); + } + }, r.tapholdDuration); + } + if (e.touches.length >= 1) { + var sPos = r.touchData.startPosition = [null, null, null, null, null, null]; + for (var i = 0; i < now.length; i++) { + sPos[i] = earlier[i] = now[i]; + } + var touch0 = e.touches[0]; + r.touchData.startGPosition = [touch0.clientX, touch0.clientY]; + } + }, false); + var touchmoveHandler; + r.registerBinding(window, 'touchmove', touchmoveHandler = function touchmoveHandler(e) { + // eslint-disable-line no-undef + var capture = r.touchData.capture; + if (!capture && !eventInContainer(e)) { + return; + } + var select = r.selection; + var cy = r.cy; + var now = r.touchData.now; + var earlier = r.touchData.earlier; + var zoom = cy.zoom(); + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + var startGPos = r.touchData.startGPosition; + var isOverThresholdDrag; + if (capture && e.touches[0] && startGPos) { + var disp = []; + for (var j = 0; j < now.length; j++) { + disp[j] = now[j] - earlier[j]; + } + var dx = e.touches[0].clientX - startGPos[0]; + var dx2 = dx * dx; + var dy = e.touches[0].clientY - startGPos[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + isOverThresholdDrag = dist2 >= r.touchTapThreshold2; + } + + // context swipe cancelling + if (capture && r.touchData.cxt) { + e.preventDefault(); + var f1x2 = e.touches[0].clientX - offsetLeft, + f1y2 = e.touches[0].clientY - offsetTop; + var f2x2 = e.touches[1].clientX - offsetLeft, + f2y2 = e.touches[1].clientY - offsetTop; + // var distance2 = distance( f1x2, f1y2, f2x2, f2y2 ); + var distance2Sq = distanceSq(f1x2, f1y2, f2x2, f2y2); + var factorSq = distance2Sq / distance1Sq; + var distThreshold = 150; + var distThresholdSq = distThreshold * distThreshold; + var factorThreshold = 1.5; + var factorThresholdSq = factorThreshold * factorThreshold; + + // cancel ctx gestures if the distance b/t the fingers increases + if (factorSq >= factorThresholdSq || distance2Sq >= distThresholdSq) { + r.touchData.cxt = false; + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var cxtEvt = { + originalEvent: e, + type: 'cxttapend', + position: { + x: now[0], + y: now[1] + } + }; + if (r.touchData.start) { + r.touchData.start.unactivate().emit(cxtEvt); + r.touchData.start = null; + } else { + cy.emit(cxtEvt); + } + } + } + + // context swipe + if (capture && r.touchData.cxt) { + var cxtEvt = { + originalEvent: e, + type: 'cxtdrag', + position: { + x: now[0], + y: now[1] + } + }; + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + if (r.touchData.start) { + r.touchData.start.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxtDragged = true; + var near = r.findNearestElement(now[0], now[1], true, true); + if (!r.touchData.cxtOver || near !== r.touchData.cxtOver) { + if (r.touchData.cxtOver) { + r.touchData.cxtOver.emit({ + originalEvent: e, + type: 'cxtdragout', + position: { + x: now[0], + y: now[1] + } + }); + } + r.touchData.cxtOver = near; + if (near) { + near.emit({ + originalEvent: e, + type: 'cxtdragover', + position: { + x: now[0], + y: now[1] + } + }); + } + } + + // box selection + } else if (capture && e.touches[2] && cy.boxSelectionEnabled()) { + e.preventDefault(); + r.data.bgActivePosistion = undefined; + this.lastThreeTouch = +new Date(); + if (!r.touchData.selecting) { + cy.emit({ + originalEvent: e, + type: 'boxstart', + position: { + x: now[0], + y: now[1] + } + }); + } + r.touchData.selecting = true; + r.touchData.didSelect = true; + select[4] = 1; + if (!select || select.length === 0 || select[0] === undefined) { + select[0] = (now[0] + now[2] + now[4]) / 3; + select[1] = (now[1] + now[3] + now[5]) / 3; + select[2] = (now[0] + now[2] + now[4]) / 3 + 1; + select[3] = (now[1] + now[3] + now[5]) / 3 + 1; + } else { + select[2] = (now[0] + now[2] + now[4]) / 3; + select[3] = (now[1] + now[3] + now[5]) / 3; + } + r.redrawHint('select', true); + r.redraw(); + + // pinch to zoom + } else if (capture && e.touches[1] && !r.touchData.didSelect // don't allow box selection to degrade to pinch-to-zoom + && cy.zoomingEnabled() && cy.panningEnabled() && cy.userZoomingEnabled() && cy.userPanningEnabled()) { + // two fingers => pinch to zoom + e.preventDefault(); + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var draggedEles = r.dragData.touchDragEles; + if (draggedEles) { + r.redrawHint('drag', true); + for (var i = 0; i < draggedEles.length; i++) { + var de_p = draggedEles[i]._private; + de_p.grabbed = false; + de_p.rscratch.inDragLayer = false; + } + } + var _start = r.touchData.start; + + // (x2, y2) for fingers 1 and 2 + var f1x2 = e.touches[0].clientX - offsetLeft, + f1y2 = e.touches[0].clientY - offsetTop; + var f2x2 = e.touches[1].clientX - offsetLeft, + f2y2 = e.touches[1].clientY - offsetTop; + var distance2 = distance(f1x2, f1y2, f2x2, f2y2); + // var distance2Sq = distanceSq( f1x2, f1y2, f2x2, f2y2 ); + // var factor = Math.sqrt( distance2Sq ) / Math.sqrt( distance1Sq ); + var factor = distance2 / distance1; + if (twoFingersStartInside) { + // delta finger1 + var df1x = f1x2 - f1x1; + var df1y = f1y2 - f1y1; + + // delta finger 2 + var df2x = f2x2 - f2x1; + var df2y = f2y2 - f2y1; + + // translation is the normalised vector of the two fingers movement + // i.e. so pinching cancels out and moving together pans + var tx = (df1x + df2x) / 2; + var ty = (df1y + df2y) / 2; + + // now calculate the zoom + var zoom1 = cy.zoom(); + var zoom2 = zoom1 * factor; + var pan1 = cy.pan(); + + // the model center point converted to the current rendered pos + var ctrx = modelCenter1[0] * zoom1 + pan1.x; + var ctry = modelCenter1[1] * zoom1 + pan1.y; + var pan2 = { + x: -zoom2 / zoom1 * (ctrx - pan1.x - tx) + ctrx, + y: -zoom2 / zoom1 * (ctry - pan1.y - ty) + ctry + }; + + // remove dragged eles + if (_start && _start.active()) { + var draggedEles = r.dragData.touchDragEles; + freeDraggedElements(draggedEles); + r.redrawHint('drag', true); + r.redrawHint('eles', true); + _start.unactivate().emit('freeon'); + draggedEles.emit('free'); + if (r.dragData.didDrag) { + _start.emit('dragfreeon'); + draggedEles.emit('dragfree'); + } + } + cy.viewport({ + zoom: zoom2, + pan: pan2, + cancelOnFailedZoom: true + }); + cy.emit('pinchzoom'); + distance1 = distance2; + f1x1 = f1x2; + f1y1 = f1y2; + f2x1 = f2x2; + f2y1 = f2y2; + r.pinching = true; + } + + // Re-project + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + } else if (e.touches[0] && !r.touchData.didSelect // don't allow box selection to degrade to single finger events like panning + ) { + var start = r.touchData.start; + var last = r.touchData.last; + var near; + if (!r.hoverData.draggingEles && !r.swipePanning) { + near = r.findNearestElement(now[0], now[1], true, true); + } + if (capture && start != null) { + e.preventDefault(); + } + + // dragging nodes + if (capture && start != null && r.nodeIsDraggable(start)) { + if (isOverThresholdDrag) { + // then dragging can happen + var draggedEles = r.dragData.touchDragEles; + var justStartedDrag = !r.dragData.didDrag; + if (justStartedDrag) { + addNodesToDrag(draggedEles, { + inDragLayer: true + }); + } + r.dragData.didDrag = true; + var totalShift = { + x: 0, + y: 0 + }; + if (number$1(disp[0]) && number$1(disp[1])) { + totalShift.x += disp[0]; + totalShift.y += disp[1]; + if (justStartedDrag) { + r.redrawHint('eles', true); + var dragDelta = r.touchData.dragDelta; + if (dragDelta && number$1(dragDelta[0]) && number$1(dragDelta[1])) { + totalShift.x += dragDelta[0]; + totalShift.y += dragDelta[1]; + } + } + } + r.hoverData.draggingEles = true; + draggedEles.silentShift(totalShift).emit('position drag'); + r.redrawHint('drag', true); + if (r.touchData.startPosition[0] == earlier[0] && r.touchData.startPosition[1] == earlier[1]) { + r.redrawHint('eles', true); + } + r.redraw(); + } else { + // otherwise keep track of drag delta for later + var dragDelta = r.touchData.dragDelta = r.touchData.dragDelta || []; + if (dragDelta.length === 0) { + dragDelta.push(disp[0]); + dragDelta.push(disp[1]); + } else { + dragDelta[0] += disp[0]; + dragDelta[1] += disp[1]; + } + } + } + + // touchmove + { + triggerEvents(start || near, ['touchmove', 'tapdrag', 'vmousemove'], e, { + x: now[0], + y: now[1] + }); + if ((!start || !start.grabbed()) && near != last) { + if (last) { + last.emit({ + originalEvent: e, + type: 'tapdragout', + position: { + x: now[0], + y: now[1] + } + }); + } + if (near) { + near.emit({ + originalEvent: e, + type: 'tapdragover', + position: { + x: now[0], + y: now[1] + } + }); + } + } + r.touchData.last = near; + } + + // check to cancel taphold + if (capture) { + for (var i = 0; i < now.length; i++) { + if (now[i] && r.touchData.startPosition[i] && isOverThresholdDrag) { + r.touchData.singleTouchMoved = true; + } + } + } + + // panning + if (capture && (start == null || start.pannable()) && cy.panningEnabled() && cy.userPanningEnabled()) { + var allowPassthrough = allowPanningPassthrough(start, r.touchData.starts); + if (allowPassthrough) { + e.preventDefault(); + if (!r.data.bgActivePosistion) { + r.data.bgActivePosistion = array2point(r.touchData.startPosition); + } + if (r.swipePanning) { + cy.panBy({ + x: disp[0] * zoom, + y: disp[1] * zoom + }); + cy.emit('dragpan'); + } else if (isOverThresholdDrag) { + r.swipePanning = true; + cy.panBy({ + x: dx * zoom, + y: dy * zoom + }); + cy.emit('dragpan'); + if (start) { + start.unactivate(); + r.redrawHint('select', true); + r.touchData.start = null; + } + } + } + + // Re-project + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + } + for (var j = 0; j < now.length; j++) { + earlier[j] = now[j]; + } + + // the active bg indicator should be removed when making a swipe that is neither for dragging nodes or panning + if (capture && e.touches.length > 0 && !r.hoverData.draggingEles && !r.swipePanning && r.data.bgActivePosistion != null) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + r.redraw(); + } + }, false); + var touchcancelHandler; + r.registerBinding(containerWindow, 'touchcancel', touchcancelHandler = function touchcancelHandler(e) { + // eslint-disable-line no-unused-vars + var start = r.touchData.start; + r.touchData.capture = false; + if (start) { + start.unactivate(); + } + }); + var touchendHandler, didDoubleTouch, touchTimeout, prevTouchTimeStamp; + r.registerBinding(containerWindow, 'touchend', touchendHandler = function touchendHandler(e) { + // eslint-disable-line no-unused-vars + var start = r.touchData.start; + var capture = r.touchData.capture; + if (capture) { + if (e.touches.length === 0) { + r.touchData.capture = false; + } + e.preventDefault(); + } else { + return; + } + var select = r.selection; + r.swipePanning = false; + r.hoverData.draggingEles = false; + var cy = r.cy; + var zoom = cy.zoom(); + var now = r.touchData.now; + var earlier = r.touchData.earlier; + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + if (start) { + start.unactivate(); + } + var ctxTapend; + if (r.touchData.cxt) { + ctxTapend = { + originalEvent: e, + type: 'cxttapend', + position: { + x: now[0], + y: now[1] + } + }; + if (start) { + start.emit(ctxTapend); + } else { + cy.emit(ctxTapend); + } + if (!r.touchData.cxtDragged) { + var ctxTap = { + originalEvent: e, + type: 'cxttap', + position: { + x: now[0], + y: now[1] + } + }; + if (start) { + start.emit(ctxTap); + } else { + cy.emit(ctxTap); + } + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxt = false; + r.touchData.start = null; + r.redraw(); + return; + } + + // no more box selection if we don't have three fingers + if (!e.touches[2] && cy.boxSelectionEnabled() && r.touchData.selecting) { + r.touchData.selecting = false; + var box = cy.collection(r.getAllInBox(select[0], select[1], select[2], select[3])); + select[0] = undefined; + select[1] = undefined; + select[2] = undefined; + select[3] = undefined; + select[4] = 0; + r.redrawHint('select', true); + cy.emit({ + type: 'boxend', + originalEvent: e, + position: { + x: now[0], + y: now[1] + } + }); + var eleWouldBeSelected = function eleWouldBeSelected(ele) { + return ele.selectable() && !ele.selected(); + }; + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + if (box.nonempty()) { + r.redrawHint('eles', true); + } + r.redraw(); + } + if (start != null) { + start.unactivate(); + } + if (e.touches[2]) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + } else if (e.touches[1]) ; else if (e.touches[0]) ; else if (!e.touches[0]) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var draggedEles = r.dragData.touchDragEles; + if (start != null) { + var startWasGrabbed = start._private.grabbed; + freeDraggedElements(draggedEles); + r.redrawHint('drag', true); + r.redrawHint('eles', true); + if (startWasGrabbed) { + start.emit('freeon'); + draggedEles.emit('free'); + if (r.dragData.didDrag) { + start.emit('dragfreeon'); + draggedEles.emit('dragfree'); + } + } + triggerEvents(start, ['touchend', 'tapend', 'vmouseup', 'tapdragout'], e, { + x: now[0], + y: now[1] + }); + start.unactivate(); + r.touchData.start = null; + } else { + var near = r.findNearestElement(now[0], now[1], true, true); + triggerEvents(near, ['touchend', 'tapend', 'vmouseup', 'tapdragout'], e, { + x: now[0], + y: now[1] + }); + } + var dx = r.touchData.startPosition[0] - now[0]; + var dx2 = dx * dx; + var dy = r.touchData.startPosition[1] - now[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + var rdist2 = dist2 * zoom * zoom; + + // Tap event, roughly same as mouse click event for touch + if (!r.touchData.singleTouchMoved) { + if (!start) { + cy.$(':selected').unselect(['tapunselect']); + } + triggerEvents(start, ['tap', 'vclick'], e, { + x: now[0], + y: now[1] + }); + didDoubleTouch = false; + if (e.timeStamp - prevTouchTimeStamp <= cy.multiClickDebounceTime()) { + touchTimeout && clearTimeout(touchTimeout); + didDoubleTouch = true; + prevTouchTimeStamp = null; + triggerEvents(start, ['dbltap', 'vdblclick'], e, { + x: now[0], + y: now[1] + }); + } else { + touchTimeout = setTimeout(function () { + if (didDoubleTouch) return; + triggerEvents(start, ['onetap', 'voneclick'], e, { + x: now[0], + y: now[1] + }); + }, cy.multiClickDebounceTime()); + prevTouchTimeStamp = e.timeStamp; + } + } + + // Prepare to select the currently touched node, only if it hasn't been dragged past a certain distance + if (start != null && !r.dragData.didDrag // didn't drag nodes around + && start._private.selectable && rdist2 < r.touchTapThreshold2 && !r.pinching // pinch to zoom should not affect selection + ) { + if (cy.selectionType() === 'single') { + cy.$(isSelected).unmerge(start).unselect(['tapunselect']); + start.select(['tapselect']); + } else { + if (start.selected()) { + start.unselect(['tapunselect']); + } else { + start.select(['tapselect']); + } + } + r.redrawHint('eles', true); + } + r.touchData.singleTouchMoved = true; + } + for (var j = 0; j < now.length; j++) { + earlier[j] = now[j]; + } + r.dragData.didDrag = false; // reset for next touchstart + + if (e.touches.length === 0) { + r.touchData.dragDelta = []; + r.touchData.startPosition = [null, null, null, null, null, null]; + r.touchData.startGPosition = null; + r.touchData.didSelect = false; + } + if (e.touches.length < 2) { + if (e.touches.length === 1) { + // the old start global pos'n may not be the same finger that remains + r.touchData.startGPosition = [e.touches[0].clientX, e.touches[0].clientY]; + } + r.pinching = false; + r.redrawHint('eles', true); + r.redraw(); + } + + //r.redraw(); + }, false); + + // fallback compatibility layer for ms pointer events + if (typeof TouchEvent === 'undefined') { + var pointers = []; + var makeTouch = function makeTouch(e) { + return { + clientX: e.clientX, + clientY: e.clientY, + force: 1, + identifier: e.pointerId, + pageX: e.pageX, + pageY: e.pageY, + radiusX: e.width / 2, + radiusY: e.height / 2, + screenX: e.screenX, + screenY: e.screenY, + target: e.target + }; + }; + var makePointer = function makePointer(e) { + return { + event: e, + touch: makeTouch(e) + }; + }; + var addPointer = function addPointer(e) { + pointers.push(makePointer(e)); + }; + var removePointer = function removePointer(e) { + for (var i = 0; i < pointers.length; i++) { + var p = pointers[i]; + if (p.event.pointerId === e.pointerId) { + pointers.splice(i, 1); + return; + } + } + }; + var updatePointer = function updatePointer(e) { + var p = pointers.filter(function (p) { + return p.event.pointerId === e.pointerId; + })[0]; + p.event = e; + p.touch = makeTouch(e); + }; + var addTouchesToEvent = function addTouchesToEvent(e) { + e.touches = pointers.map(function (p) { + return p.touch; + }); + }; + var pointerIsMouse = function pointerIsMouse(e) { + return e.pointerType === 'mouse' || e.pointerType === 4; + }; + r.registerBinding(r.container, 'pointerdown', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + e.preventDefault(); + addPointer(e); + addTouchesToEvent(e); + touchstartHandler(e); + }); + r.registerBinding(r.container, 'pointerup', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + removePointer(e); + addTouchesToEvent(e); + touchendHandler(e); + }); + r.registerBinding(r.container, 'pointercancel', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + removePointer(e); + addTouchesToEvent(e); + touchcancelHandler(e); + }); + r.registerBinding(r.container, 'pointermove', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + e.preventDefault(); + updatePointer(e); + addTouchesToEvent(e); + touchmoveHandler(e); + }); + } +}; + +var BRp$2 = {}; +BRp$2.generatePolygon = function (name, points) { + return this.nodeShapes[name] = { + renderer: this, + name: name, + points: points, + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl('polygon', context, centerX, centerY, width, height, this.points); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return polygonIntersectLine(x, y, this.points, nodeX, nodeY, width / 2, height / 2, padding); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + return pointInsidePolygon(x, y, this.points, centerX, centerY, width, height, [0, -1], padding); + } + }; +}; +BRp$2.generateEllipse = function () { + return this.nodeShapes['ellipse'] = { + renderer: this, + name: 'ellipse', + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return intersectLineEllipse(x, y, nodeX, nodeY, width / 2 + padding, height / 2 + padding); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + return checkInEllipse(x, y, width, height, centerX, centerY, padding); + } + }; +}; +BRp$2.generateRoundPolygon = function (name, points) { + return this.nodeShapes[name] = { + renderer: this, + name: name, + points: points, + getOrCreateCorners: function getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, field) { + if (rs[field] !== undefined && rs[field + '-cx'] === centerX && rs[field + '-cy'] === centerY) { + return rs[field]; + } + rs[field] = new Array(points.length / 2); + rs[field + '-cx'] = centerX; + rs[field + '-cy'] = centerY; + var halfW = width / 2; + var halfH = height / 2; + cornerRadius = cornerRadius === 'auto' ? getRoundPolygonRadius(width, height) : cornerRadius; + var p = new Array(points.length / 2); + for (var _i = 0; _i < points.length / 2; _i++) { + p[_i] = { + x: centerX + halfW * points[_i * 2], + y: centerY + halfH * points[_i * 2 + 1] + }; + } + var i, + p1, + p2, + p3, + len = p.length; + p1 = p[len - 1]; + // for each point + for (i = 0; i < len; i++) { + p2 = p[i % len]; + p3 = p[(i + 1) % len]; + rs[field][i] = getRoundCorner(p1, p2, p3, cornerRadius); + p1 = p2; + p2 = p3; + } + return rs[field]; + }, + draw: function draw(context, centerX, centerY, width, height, cornerRadius, rs) { + this.renderer.nodeShapeImpl('round-polygon', context, centerX, centerY, width, height, this.points, this.getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, 'drawCorners')); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius, rs) { + return roundPolygonIntersectLine(x, y, this.points, nodeX, nodeY, width, height, padding, this.getOrCreateCorners(nodeX, nodeY, width, height, cornerRadius, rs, 'corners')); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius, rs) { + return pointInsideRoundPolygon(x, y, this.points, centerX, centerY, width, height, this.getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, 'corners')); + } + }; +}; +BRp$2.generateRoundRectangle = function () { + return this.nodeShapes['round-rectangle'] = this.nodeShapes['roundrectangle'] = { + renderer: this, + name: 'round-rectangle', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, this.points, cornerRadius); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding, cornerRadius); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(width, height) : cornerRadius; + cornerRadius = Math.min(halfWidth, halfHeight, cornerRadius); + var diam = cornerRadius * 2; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - diam, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - diam, height, [0, -1], padding)) { + return true; + } + + // Check top left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - halfWidth + cornerRadius, centerY - halfHeight + cornerRadius, padding)) { + return true; + } + + // Check top right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + halfWidth - cornerRadius, centerY - halfHeight + cornerRadius, padding)) { + return true; + } + + // Check bottom right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + halfWidth - cornerRadius, centerY + halfHeight - cornerRadius, padding)) { + return true; + } + + // Check bottom left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - halfWidth + cornerRadius, centerY + halfHeight - cornerRadius, padding)) { + return true; + } + return false; + } + }; +}; +BRp$2.generateCutRectangle = function () { + return this.nodeShapes['cut-rectangle'] = this.nodeShapes['cutrectangle'] = { + renderer: this, + name: 'cut-rectangle', + cornerLength: getCutRectangleCornerLength(), + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, null, cornerRadius); + }, + generateCutTrianglePts: function generateCutTrianglePts(width, height, centerX, centerY, cornerRadius) { + var cl = cornerRadius === 'auto' ? this.cornerLength : cornerRadius; + var hh = height / 2; + var hw = width / 2; + var xBegin = centerX - hw; + var xEnd = centerX + hw; + var yBegin = centerY - hh; + var yEnd = centerY + hh; + + // points are in clockwise order, inner (imaginary) triangle pt on [4, 5] + return { + topLeft: [xBegin, yBegin + cl, xBegin + cl, yBegin, xBegin + cl, yBegin + cl], + topRight: [xEnd - cl, yBegin, xEnd, yBegin + cl, xEnd - cl, yBegin + cl], + bottomRight: [xEnd, yEnd - cl, xEnd - cl, yEnd, xEnd - cl, yEnd - cl], + bottomLeft: [xBegin + cl, yEnd, xBegin, yEnd - cl, xBegin + cl, yEnd - cl] + }; + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + var cPts = this.generateCutTrianglePts(width + 2 * padding, height + 2 * padding, nodeX, nodeY, cornerRadius); + var pts = [].concat.apply([], [cPts.topLeft.splice(0, 4), cPts.topRight.splice(0, 4), cPts.bottomRight.splice(0, 4), cPts.bottomLeft.splice(0, 4)]); + return polygonIntersectLine(x, y, pts, nodeX, nodeY); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var cl = cornerRadius === 'auto' ? this.cornerLength : cornerRadius; + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - 2 * cl, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - 2 * cl, height, [0, -1], padding)) { + return true; + } + var cutTrianglePts = this.generateCutTrianglePts(width, height, centerX, centerY); + return pointInsidePolygonPoints(x, y, cutTrianglePts.topLeft) || pointInsidePolygonPoints(x, y, cutTrianglePts.topRight) || pointInsidePolygonPoints(x, y, cutTrianglePts.bottomRight) || pointInsidePolygonPoints(x, y, cutTrianglePts.bottomLeft); + } + }; +}; +BRp$2.generateBarrel = function () { + return this.nodeShapes['barrel'] = { + renderer: this, + name: 'barrel', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + // use two fixed t values for the bezier curve approximation + + var t0 = 0.15; + var t1 = 0.5; + var t2 = 0.85; + var bPts = this.generateBarrelBezierPts(width + 2 * padding, height + 2 * padding, nodeX, nodeY); + var approximateBarrelCurvePts = function approximateBarrelCurvePts(pts) { + // approximate curve pts based on the two t values + var m0 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t0); + var m1 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t1); + var m2 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t2); + return [pts[0], pts[1], m0.x, m0.y, m1.x, m1.y, m2.x, m2.y, pts[4], pts[5]]; + }; + var pts = [].concat(approximateBarrelCurvePts(bPts.topLeft), approximateBarrelCurvePts(bPts.topRight), approximateBarrelCurvePts(bPts.bottomRight), approximateBarrelCurvePts(bPts.bottomLeft)); + return polygonIntersectLine(x, y, pts, nodeX, nodeY); + }, + generateBarrelBezierPts: function generateBarrelBezierPts(width, height, centerX, centerY) { + var hh = height / 2; + var hw = width / 2; + var xBegin = centerX - hw; + var xEnd = centerX + hw; + var yBegin = centerY - hh; + var yEnd = centerY + hh; + var curveConstants = getBarrelCurveConstants(width, height); + var hOffset = curveConstants.heightOffset; + var wOffset = curveConstants.widthOffset; + var ctrlPtXOffset = curveConstants.ctrlPtOffsetPct * width; + + // points are in clockwise order, inner (imaginary) control pt on [4, 5] + var pts = { + topLeft: [xBegin, yBegin + hOffset, xBegin + ctrlPtXOffset, yBegin, xBegin + wOffset, yBegin], + topRight: [xEnd - wOffset, yBegin, xEnd - ctrlPtXOffset, yBegin, xEnd, yBegin + hOffset], + bottomRight: [xEnd, yEnd - hOffset, xEnd - ctrlPtXOffset, yEnd, xEnd - wOffset, yEnd], + bottomLeft: [xBegin + wOffset, yEnd, xBegin + ctrlPtXOffset, yEnd, xBegin, yEnd - hOffset] + }; + pts.topLeft.isTop = true; + pts.topRight.isTop = true; + pts.bottomLeft.isBottom = true; + pts.bottomRight.isBottom = true; + return pts; + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var curveConstants = getBarrelCurveConstants(width, height); + var hOffset = curveConstants.heightOffset; + var wOffset = curveConstants.widthOffset; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - 2 * hOffset, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - 2 * wOffset, height, [0, -1], padding)) { + return true; + } + var barrelCurvePts = this.generateBarrelBezierPts(width, height, centerX, centerY); + var getCurveT = function getCurveT(x, y, curvePts) { + var x0 = curvePts[4]; + var x1 = curvePts[2]; + var x2 = curvePts[0]; + var y0 = curvePts[5]; + // var y1 = curvePts[ 3 ]; + var y2 = curvePts[1]; + var xMin = Math.min(x0, x2); + var xMax = Math.max(x0, x2); + var yMin = Math.min(y0, y2); + var yMax = Math.max(y0, y2); + if (xMin <= x && x <= xMax && yMin <= y && y <= yMax) { + var coeff = bezierPtsToQuadCoeff(x0, x1, x2); + var roots = solveQuadratic(coeff[0], coeff[1], coeff[2], x); + var validRoots = roots.filter(function (r) { + return 0 <= r && r <= 1; + }); + if (validRoots.length > 0) { + return validRoots[0]; + } + } + return null; + }; + var curveRegions = Object.keys(barrelCurvePts); + for (var i = 0; i < curveRegions.length; i++) { + var corner = curveRegions[i]; + var cornerPts = barrelCurvePts[corner]; + var t = getCurveT(x, y, cornerPts); + if (t == null) { + continue; + } + var y0 = cornerPts[5]; + var y1 = cornerPts[3]; + var y2 = cornerPts[1]; + var bezY = qbezierAt(y0, y1, y2, t); + if (cornerPts.isTop && bezY <= y) { + return true; + } + if (cornerPts.isBottom && y <= bezY) { + return true; + } + } + return false; + } + }; +}; +BRp$2.generateBottomRoundrectangle = function () { + return this.nodeShapes['bottom-round-rectangle'] = this.nodeShapes['bottomroundrectangle'] = { + renderer: this, + name: 'bottom-round-rectangle', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, this.points, cornerRadius); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + var topStartX = nodeX - (width / 2 + padding); + var topStartY = nodeY - (height / 2 + padding); + var topEndY = topStartY; + var topEndX = nodeX + (width / 2 + padding); + var topIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false); + if (topIntersections.length > 0) { + return topIntersections; + } + return roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding, cornerRadius); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(width, height) : cornerRadius; + var diam = 2 * cornerRadius; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - diam, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - diam, height, [0, -1], padding)) { + return true; + } + + // check non-rounded top side + var outerWidth = width / 2 + 2 * padding; + var outerHeight = height / 2 + 2 * padding; + var points = [centerX - outerWidth, centerY - outerHeight, centerX - outerWidth, centerY, centerX + outerWidth, centerY, centerX + outerWidth, centerY - outerHeight]; + if (pointInsidePolygonPoints(x, y, points)) { + return true; + } + + // Check bottom right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + width / 2 - cornerRadius, centerY + height / 2 - cornerRadius, padding)) { + return true; + } + + // Check bottom left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - width / 2 + cornerRadius, centerY + height / 2 - cornerRadius, padding)) { + return true; + } + return false; + } + }; +}; +BRp$2.registerNodeShapes = function () { + var nodeShapes = this.nodeShapes = {}; + var renderer = this; + this.generateEllipse(); + this.generatePolygon('triangle', generateUnitNgonPointsFitToSquare(3, 0)); + this.generateRoundPolygon('round-triangle', generateUnitNgonPointsFitToSquare(3, 0)); + this.generatePolygon('rectangle', generateUnitNgonPointsFitToSquare(4, 0)); + nodeShapes['square'] = nodeShapes['rectangle']; + this.generateRoundRectangle(); + this.generateCutRectangle(); + this.generateBarrel(); + this.generateBottomRoundrectangle(); + { + var diamondPoints = [0, 1, 1, 0, 0, -1, -1, 0]; + this.generatePolygon('diamond', diamondPoints); + this.generateRoundPolygon('round-diamond', diamondPoints); + } + this.generatePolygon('pentagon', generateUnitNgonPointsFitToSquare(5, 0)); + this.generateRoundPolygon('round-pentagon', generateUnitNgonPointsFitToSquare(5, 0)); + this.generatePolygon('hexagon', generateUnitNgonPointsFitToSquare(6, 0)); + this.generateRoundPolygon('round-hexagon', generateUnitNgonPointsFitToSquare(6, 0)); + this.generatePolygon('heptagon', generateUnitNgonPointsFitToSquare(7, 0)); + this.generateRoundPolygon('round-heptagon', generateUnitNgonPointsFitToSquare(7, 0)); + this.generatePolygon('octagon', generateUnitNgonPointsFitToSquare(8, 0)); + this.generateRoundPolygon('round-octagon', generateUnitNgonPointsFitToSquare(8, 0)); + var star5Points = new Array(20); + { + var outerPoints = generateUnitNgonPoints(5, 0); + var innerPoints = generateUnitNgonPoints(5, Math.PI / 5); + + // Outer radius is 1; inner radius of star is smaller + var innerRadius = 0.5 * (3 - Math.sqrt(5)); + innerRadius *= 1.57; + for (var i = 0; i < innerPoints.length / 2; i++) { + innerPoints[i * 2] *= innerRadius; + innerPoints[i * 2 + 1] *= innerRadius; + } + for (var i = 0; i < 20 / 4; i++) { + star5Points[i * 4] = outerPoints[i * 2]; + star5Points[i * 4 + 1] = outerPoints[i * 2 + 1]; + star5Points[i * 4 + 2] = innerPoints[i * 2]; + star5Points[i * 4 + 3] = innerPoints[i * 2 + 1]; + } + } + star5Points = fitPolygonToSquare(star5Points); + this.generatePolygon('star', star5Points); + this.generatePolygon('vee', [-1, -1, 0, -0.333, 1, -1, 0, 1]); + this.generatePolygon('rhomboid', [-1, -1, 0.333, -1, 1, 1, -0.333, 1]); + this.generatePolygon('right-rhomboid', [-0.333, -1, 1, -1, 0.333, 1, -1, 1]); + this.nodeShapes['concavehexagon'] = this.generatePolygon('concave-hexagon', [-1, -0.95, -0.75, 0, -1, 0.95, 1, 0.95, 0.75, 0, 1, -0.95]); + { + var tagPoints = [-1, -1, 0.25, -1, 1, 0, 0.25, 1, -1, 1]; + this.generatePolygon('tag', tagPoints); + this.generateRoundPolygon('round-tag', tagPoints); + } + nodeShapes.makePolygon = function (points) { + // use caching on user-specified polygons so they are as fast as native shapes + + var key = points.join('$'); + var name = 'polygon-' + key; + var shape; + if (shape = this[name]) { + // got cached shape + return shape; + } + + // create and cache new shape + return renderer.generatePolygon(name, points); + }; +}; + +var BRp$1 = {}; +BRp$1.timeToRender = function () { + return this.redrawTotalTime / this.redrawCount; +}; +BRp$1.redraw = function (options) { + options = options || staticEmptyObject(); + var r = this; + if (r.averageRedrawTime === undefined) { + r.averageRedrawTime = 0; + } + if (r.lastRedrawTime === undefined) { + r.lastRedrawTime = 0; + } + if (r.lastDrawTime === undefined) { + r.lastDrawTime = 0; + } + r.requestedFrame = true; + r.renderOptions = options; +}; +BRp$1.beforeRender = function (fn, priority) { + // the renderer can't add tick callbacks when destroyed + if (this.destroyed) { + return; + } + if (priority == null) { + error('Priority is not optional for beforeRender'); + } + var cbs = this.beforeRenderCallbacks; + cbs.push({ + fn: fn, + priority: priority + }); + + // higher priority callbacks executed first + cbs.sort(function (a, b) { + return b.priority - a.priority; + }); +}; +var beforeRenderCallbacks = function beforeRenderCallbacks(r, willDraw, startTime) { + var cbs = r.beforeRenderCallbacks; + for (var i = 0; i < cbs.length; i++) { + cbs[i].fn(willDraw, startTime); + } +}; +BRp$1.startRenderLoop = function () { + var r = this; + var cy = r.cy; + if (r.renderLoopStarted) { + return; + } else { + r.renderLoopStarted = true; + } + var renderFn = function renderFn(requestTime) { + if (r.destroyed) { + return; + } + if (cy.batching()) ; else if (r.requestedFrame && !r.skipFrame) { + beforeRenderCallbacks(r, true, requestTime); + var startTime = performanceNow(); + r.render(r.renderOptions); + var endTime = r.lastDrawTime = performanceNow(); + if (r.averageRedrawTime === undefined) { + r.averageRedrawTime = endTime - startTime; + } + if (r.redrawCount === undefined) { + r.redrawCount = 0; + } + r.redrawCount++; + if (r.redrawTotalTime === undefined) { + r.redrawTotalTime = 0; + } + var duration = endTime - startTime; + r.redrawTotalTime += duration; + r.lastRedrawTime = duration; + + // use a weighted average with a bias from the previous average so we don't spike so easily + r.averageRedrawTime = r.averageRedrawTime / 2 + duration / 2; + r.requestedFrame = false; + } else { + beforeRenderCallbacks(r, false, requestTime); + } + r.skipFrame = false; + requestAnimationFrame$1(renderFn); + }; + requestAnimationFrame$1(renderFn); +}; + +var BaseRenderer = function BaseRenderer(options) { + this.init(options); +}; +var BR = BaseRenderer; +var BRp = BR.prototype; +BRp.clientFunctions = ['redrawHint', 'render', 'renderTo', 'matchCanvasSize', 'nodeShapeImpl', 'arrowShapeImpl']; +BRp.init = function (options) { + var r = this; + r.options = options; + r.cy = options.cy; + var ctr = r.container = options.cy.container(); + var containerWindow = r.cy.window(); + + // prepend a stylesheet in the head such that + if (containerWindow) { + var document = containerWindow.document; + var head = document.head; + var stylesheetId = '__________cytoscape_stylesheet'; + var className = '__________cytoscape_container'; + var stylesheetAlreadyExists = document.getElementById(stylesheetId) != null; + if (ctr.className.indexOf(className) < 0) { + ctr.className = (ctr.className || '') + ' ' + className; + } + if (!stylesheetAlreadyExists) { + var stylesheet = document.createElement('style'); + stylesheet.id = stylesheetId; + stylesheet.textContent = '.' + className + ' { position: relative; }'; + head.insertBefore(stylesheet, head.children[0]); // first so lowest priority + } + + var computedStyle = containerWindow.getComputedStyle(ctr); + var position = computedStyle.getPropertyValue('position'); + if (position === 'static') { + warn('A Cytoscape container has style position:static and so can not use UI extensions properly'); + } + } + r.selection = [undefined, undefined, undefined, undefined, 0]; // Coordinates for selection box, plus enabled flag + + r.bezierProjPcts = [0.05, 0.225, 0.4, 0.5, 0.6, 0.775, 0.95]; + + //--Pointer-related data + r.hoverData = { + down: null, + last: null, + downTime: null, + triggerMode: null, + dragging: false, + initialPan: [null, null], + capture: false + }; + r.dragData = { + possibleDragElements: [] + }; + r.touchData = { + start: null, + capture: false, + // These 3 fields related to tap, taphold events + startPosition: [null, null, null, null, null, null], + singleTouchStartTime: null, + singleTouchMoved: true, + now: [null, null, null, null, null, null], + earlier: [null, null, null, null, null, null] + }; + r.redraws = 0; + r.showFps = options.showFps; + r.debug = options.debug; + r.hideEdgesOnViewport = options.hideEdgesOnViewport; + r.textureOnViewport = options.textureOnViewport; + r.wheelSensitivity = options.wheelSensitivity; + r.motionBlurEnabled = options.motionBlur; // on by default + r.forcedPixelRatio = number$1(options.pixelRatio) ? options.pixelRatio : null; + r.motionBlur = options.motionBlur; // for initial kick off + r.motionBlurOpacity = options.motionBlurOpacity; + r.motionBlurTransparency = 1 - r.motionBlurOpacity; + r.motionBlurPxRatio = 1; + r.mbPxRBlurry = 1; //0.8; + r.minMbLowQualFrames = 4; + r.fullQualityMb = false; + r.clearedForMotionBlur = []; + r.desktopTapThreshold = options.desktopTapThreshold; + r.desktopTapThreshold2 = options.desktopTapThreshold * options.desktopTapThreshold; + r.touchTapThreshold = options.touchTapThreshold; + r.touchTapThreshold2 = options.touchTapThreshold * options.touchTapThreshold; + r.tapholdDuration = 500; + r.bindings = []; + r.beforeRenderCallbacks = []; + r.beforeRenderPriorities = { + // higher priority execs before lower one + animations: 400, + eleCalcs: 300, + eleTxrDeq: 200, + lyrTxrDeq: 150, + lyrTxrSkip: 100 + }; + r.registerNodeShapes(); + r.registerArrowShapes(); + r.registerCalculationListeners(); +}; +BRp.notify = function (eventName, eles) { + var r = this; + var cy = r.cy; + + // the renderer can't be notified after it's destroyed + if (this.destroyed) { + return; + } + if (eventName === 'init') { + r.load(); + return; + } + if (eventName === 'destroy') { + r.destroy(); + return; + } + if (eventName === 'add' || eventName === 'remove' || eventName === 'move' && cy.hasCompoundNodes() || eventName === 'load' || eventName === 'zorder' || eventName === 'mount') { + r.invalidateCachedZSortedEles(); + } + if (eventName === 'viewport') { + r.redrawHint('select', true); + } + if (eventName === 'load' || eventName === 'resize' || eventName === 'mount') { + r.invalidateContainerClientCoordsCache(); + r.matchCanvasSize(r.container); + } + r.redrawHint('eles', true); + r.redrawHint('drag', true); + this.startRenderLoop(); + this.redraw(); +}; +BRp.destroy = function () { + var r = this; + r.destroyed = true; + r.cy.stopAnimationLoop(); + for (var i = 0; i < r.bindings.length; i++) { + var binding = r.bindings[i]; + var b = binding; + var tgt = b.target; + (tgt.off || tgt.removeEventListener).apply(tgt, b.args); + } + r.bindings = []; + r.beforeRenderCallbacks = []; + r.onUpdateEleCalcsFns = []; + if (r.removeObserver) { + r.removeObserver.disconnect(); + } + if (r.styleObserver) { + r.styleObserver.disconnect(); + } + if (r.resizeObserver) { + r.resizeObserver.disconnect(); + } + if (r.labelCalcDiv) { + try { + document.body.removeChild(r.labelCalcDiv); // eslint-disable-line no-undef + } catch (e) { + // ie10 issue #1014 + } + } +}; +BRp.isHeadless = function () { + return false; +}; +[BRp$f, BRp$5, BRp$4, BRp$3, BRp$2, BRp$1].forEach(function (props) { + extend(BRp, props); +}); + +var fullFpsTime = 1000 / 60; // assume 60 frames per second + +var defs = { + setupDequeueing: function setupDequeueing(opts) { + return function setupDequeueingImpl() { + var self = this; + var r = this.renderer; + if (self.dequeueingSetup) { + return; + } else { + self.dequeueingSetup = true; + } + var queueRedraw = debounce_1(function () { + r.redrawHint('eles', true); + r.redrawHint('drag', true); + r.redraw(); + }, opts.deqRedrawThreshold); + var dequeue = function dequeue(willDraw, frameStartTime) { + var startTime = performanceNow(); + var avgRenderTime = r.averageRedrawTime; + var renderTime = r.lastRedrawTime; + var deqd = []; + var extent = r.cy.extent(); + var pixelRatio = r.getPixelRatio(); + + // if we aren't in a tick that causes a draw, then the rendered style + // queue won't automatically be flushed before dequeueing starts + if (!willDraw) { + r.flushRenderedStyleQueue(); + } + while (true) { + // eslint-disable-line no-constant-condition + var now = performanceNow(); + var duration = now - startTime; + var frameDuration = now - frameStartTime; + if (renderTime < fullFpsTime) { + // if we're rendering faster than the ideal fps, then do dequeueing + // during all of the remaining frame time + + var timeAvailable = fullFpsTime - (willDraw ? avgRenderTime : 0); + if (frameDuration >= opts.deqFastCost * timeAvailable) { + break; + } + } else { + if (willDraw) { + if (duration >= opts.deqCost * renderTime || duration >= opts.deqAvgCost * avgRenderTime) { + break; + } + } else if (frameDuration >= opts.deqNoDrawCost * fullFpsTime) { + break; + } + } + var thisDeqd = opts.deq(self, pixelRatio, extent); + if (thisDeqd.length > 0) { + for (var i = 0; i < thisDeqd.length; i++) { + deqd.push(thisDeqd[i]); + } + } else { + break; + } + } + + // callbacks on dequeue + if (deqd.length > 0) { + opts.onDeqd(self, deqd); + if (!willDraw && opts.shouldRedraw(self, deqd, pixelRatio, extent)) { + queueRedraw(); + } + } + }; + var priority = opts.priority || noop$1; + r.beforeRender(dequeue, priority(self)); + }; + } +}; + +// Allows lookups for (ele, lvl) => cache. +// Uses keys so elements may share the same cache. +var ElementTextureCacheLookup = /*#__PURE__*/function () { + function ElementTextureCacheLookup(getKey) { + var doesEleInvalidateKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : falsify; + _classCallCheck(this, ElementTextureCacheLookup); + this.idsByKey = new Map$2(); + this.keyForId = new Map$2(); + this.cachesByLvl = new Map$2(); + this.lvls = []; + this.getKey = getKey; + this.doesEleInvalidateKey = doesEleInvalidateKey; + } + _createClass(ElementTextureCacheLookup, [{ + key: "getIdsFor", + value: function getIdsFor(key) { + if (key == null) { + error("Can not get id list for null key"); + } + var idsByKey = this.idsByKey; + var ids = this.idsByKey.get(key); + if (!ids) { + ids = new Set$1(); + idsByKey.set(key, ids); + } + return ids; + } + }, { + key: "addIdForKey", + value: function addIdForKey(key, id) { + if (key != null) { + this.getIdsFor(key).add(id); + } + } + }, { + key: "deleteIdForKey", + value: function deleteIdForKey(key, id) { + if (key != null) { + this.getIdsFor(key)["delete"](id); + } + } + }, { + key: "getNumberOfIdsForKey", + value: function getNumberOfIdsForKey(key) { + if (key == null) { + return 0; + } else { + return this.getIdsFor(key).size; + } + } + }, { + key: "updateKeyMappingFor", + value: function updateKeyMappingFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + var currKey = this.getKey(ele); + this.deleteIdForKey(prevKey, id); + this.addIdForKey(currKey, id); + this.keyForId.set(id, currKey); + } + }, { + key: "deleteKeyMappingFor", + value: function deleteKeyMappingFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + this.deleteIdForKey(prevKey, id); + this.keyForId["delete"](id); + } + }, { + key: "keyHasChangedFor", + value: function keyHasChangedFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + var newKey = this.getKey(ele); + return prevKey !== newKey; + } + }, { + key: "isInvalid", + value: function isInvalid(ele) { + return this.keyHasChangedFor(ele) || this.doesEleInvalidateKey(ele); + } + }, { + key: "getCachesAt", + value: function getCachesAt(lvl) { + var cachesByLvl = this.cachesByLvl, + lvls = this.lvls; + var caches = cachesByLvl.get(lvl); + if (!caches) { + caches = new Map$2(); + cachesByLvl.set(lvl, caches); + lvls.push(lvl); + } + return caches; + } + }, { + key: "getCache", + value: function getCache(key, lvl) { + return this.getCachesAt(lvl).get(key); + } + }, { + key: "get", + value: function get(ele, lvl) { + var key = this.getKey(ele); + var cache = this.getCache(key, lvl); + + // getting for an element may need to add to the id list b/c eles can share keys + if (cache != null) { + this.updateKeyMappingFor(ele); + } + return cache; + } + }, { + key: "getForCachedKey", + value: function getForCachedKey(ele, lvl) { + var key = this.keyForId.get(ele.id()); // n.b. use cached key, not newly computed key + var cache = this.getCache(key, lvl); + return cache; + } + }, { + key: "hasCache", + value: function hasCache(key, lvl) { + return this.getCachesAt(lvl).has(key); + } + }, { + key: "has", + value: function has(ele, lvl) { + var key = this.getKey(ele); + return this.hasCache(key, lvl); + } + }, { + key: "setCache", + value: function setCache(key, lvl, cache) { + cache.key = key; + this.getCachesAt(lvl).set(key, cache); + } + }, { + key: "set", + value: function set(ele, lvl, cache) { + var key = this.getKey(ele); + this.setCache(key, lvl, cache); + this.updateKeyMappingFor(ele); + } + }, { + key: "deleteCache", + value: function deleteCache(key, lvl) { + this.getCachesAt(lvl)["delete"](key); + } + }, { + key: "delete", + value: function _delete(ele, lvl) { + var key = this.getKey(ele); + this.deleteCache(key, lvl); + } + }, { + key: "invalidateKey", + value: function invalidateKey(key) { + var _this = this; + this.lvls.forEach(function (lvl) { + return _this.deleteCache(key, lvl); + }); + } + + // returns true if no other eles reference the invalidated cache (n.b. other eles may need the cache with the same key) + }, { + key: "invalidate", + value: function invalidate(ele) { + var id = ele.id(); + var key = this.keyForId.get(id); // n.b. use stored key rather than current (potential key) + + this.deleteKeyMappingFor(ele); + var entireKeyInvalidated = this.doesEleInvalidateKey(ele); + if (entireKeyInvalidated) { + // clear mapping for current key + this.invalidateKey(key); + } + return entireKeyInvalidated || this.getNumberOfIdsForKey(key) === 0; + } + }]); + return ElementTextureCacheLookup; +}(); + +var minTxrH = 25; // the size of the texture cache for small height eles (special case) +var txrStepH = 50; // the min size of the regular cache, and the size it increases with each step up +var minLvl$1 = -4; // when scaling smaller than that we don't need to re-render +var maxLvl$1 = 3; // when larger than this scale just render directly (caching is not helpful) +var maxZoom$1 = 7.99; // beyond this zoom level, layered textures are not used +var eleTxrSpacing = 8; // spacing between elements on textures to avoid blitting overlaps +var defTxrWidth = 1024; // default/minimum texture width +var maxTxrW = 1024; // the maximum width of a texture +var maxTxrH = 1024; // the maximum height of a texture +var minUtility = 0.2; // if usage of texture is less than this, it is retired +var maxFullness = 0.8; // fullness of texture after which queue removal is checked +var maxFullnessChecks = 10; // dequeued after this many checks +var deqCost$1 = 0.15; // % of add'l rendering cost allowed for dequeuing ele caches each frame +var deqAvgCost$1 = 0.1; // % of add'l rendering cost compared to average overall redraw time +var deqNoDrawCost$1 = 0.9; // % of avg frame time that can be used for dequeueing when not drawing +var deqFastCost$1 = 0.9; // % of frame time to be used when >60fps +var deqRedrawThreshold$1 = 100; // time to batch redraws together from dequeueing to allow more dequeueing calcs to happen in the meanwhile +var maxDeqSize$1 = 1; // number of eles to dequeue and render at higher texture in each batch + +var getTxrReasons = { + dequeue: 'dequeue', + downscale: 'downscale', + highQuality: 'highQuality' +}; +var initDefaults = defaults$g({ + getKey: null, + doesEleInvalidateKey: falsify, + drawElement: null, + getBoundingBox: null, + getRotationPoint: null, + getRotationOffset: null, + isVisible: trueify, + allowEdgeTxrCaching: true, + allowParentTxrCaching: true +}); +var ElementTextureCache = function ElementTextureCache(renderer, initOptions) { + var self = this; + self.renderer = renderer; + self.onDequeues = []; + var opts = initDefaults(initOptions); + extend(self, opts); + self.lookup = new ElementTextureCacheLookup(opts.getKey, opts.doesEleInvalidateKey); + self.setupDequeueing(); +}; +var ETCp = ElementTextureCache.prototype; +ETCp.reasons = getTxrReasons; + +// the list of textures in which new subtextures for elements can be placed +ETCp.getTextureQueue = function (txrH) { + var self = this; + self.eleImgCaches = self.eleImgCaches || {}; + return self.eleImgCaches[txrH] = self.eleImgCaches[txrH] || []; +}; + +// the list of usused textures which can be recycled (in use in texture queue) +ETCp.getRetiredTextureQueue = function (txrH) { + var self = this; + var rtxtrQs = self.eleImgCaches.retired = self.eleImgCaches.retired || {}; + var rtxtrQ = rtxtrQs[txrH] = rtxtrQs[txrH] || []; + return rtxtrQ; +}; + +// queue of element draw requests at different scale levels +ETCp.getElementQueue = function () { + var self = this; + var q = self.eleCacheQueue = self.eleCacheQueue || new heap(function (a, b) { + return b.reqs - a.reqs; + }); + return q; +}; + +// queue of element draw requests at different scale levels (element id lookup) +ETCp.getElementKeyToQueue = function () { + var self = this; + var k2q = self.eleKeyToCacheQueue = self.eleKeyToCacheQueue || {}; + return k2q; +}; +ETCp.getElement = function (ele, bb, pxRatio, lvl, reason) { + var self = this; + var r = this.renderer; + var zoom = r.cy.zoom(); + var lookup = this.lookup; + if (!bb || bb.w === 0 || bb.h === 0 || isNaN(bb.w) || isNaN(bb.h) || !ele.visible() || ele.removed()) { + return null; + } + if (!self.allowEdgeTxrCaching && ele.isEdge() || !self.allowParentTxrCaching && ele.isParent()) { + return null; + } + if (lvl == null) { + lvl = Math.ceil(log2(zoom * pxRatio)); + } + if (lvl < minLvl$1) { + lvl = minLvl$1; + } else if (zoom >= maxZoom$1 || lvl > maxLvl$1) { + return null; + } + var scale = Math.pow(2, lvl); + var eleScaledH = bb.h * scale; + var eleScaledW = bb.w * scale; + var scaledLabelShown = r.eleTextBiggerThanMin(ele, scale); + if (!this.isVisible(ele, scaledLabelShown)) { + return null; + } + var eleCache = lookup.get(ele, lvl); + + // if this get was on an unused/invalidated cache, then restore the texture usage metric + if (eleCache && eleCache.invalidated) { + eleCache.invalidated = false; + eleCache.texture.invalidatedWidth -= eleCache.width; + } + if (eleCache) { + return eleCache; + } + var txrH; // which texture height this ele belongs to + + if (eleScaledH <= minTxrH) { + txrH = minTxrH; + } else if (eleScaledH <= txrStepH) { + txrH = txrStepH; + } else { + txrH = Math.ceil(eleScaledH / txrStepH) * txrStepH; + } + if (eleScaledH > maxTxrH || eleScaledW > maxTxrW) { + return null; // caching large elements is not efficient + } + + var txrQ = self.getTextureQueue(txrH); + + // first try the second last one in case it has space at the end + var txr = txrQ[txrQ.length - 2]; + var addNewTxr = function addNewTxr() { + return self.recycleTexture(txrH, eleScaledW) || self.addTexture(txrH, eleScaledW); + }; + + // try the last one if there is no second last one + if (!txr) { + txr = txrQ[txrQ.length - 1]; + } + + // if the last one doesn't exist, we need a first one + if (!txr) { + txr = addNewTxr(); + } + + // if there's no room in the current texture, we need a new one + if (txr.width - txr.usedWidth < eleScaledW) { + txr = addNewTxr(); + } + var scalableFrom = function scalableFrom(otherCache) { + return otherCache && otherCache.scaledLabelShown === scaledLabelShown; + }; + var deqing = reason && reason === getTxrReasons.dequeue; + var highQualityReq = reason && reason === getTxrReasons.highQuality; + var downscaleReq = reason && reason === getTxrReasons.downscale; + var higherCache; // the nearest cache with a higher level + for (var l = lvl + 1; l <= maxLvl$1; l++) { + var c = lookup.get(ele, l); + if (c) { + higherCache = c; + break; + } + } + var oneUpCache = higherCache && higherCache.level === lvl + 1 ? higherCache : null; + var downscale = function downscale() { + txr.context.drawImage(oneUpCache.texture.canvas, oneUpCache.x, 0, oneUpCache.width, oneUpCache.height, txr.usedWidth, 0, eleScaledW, eleScaledH); + }; + + // reset ele area in texture + txr.context.setTransform(1, 0, 0, 1, 0, 0); + txr.context.clearRect(txr.usedWidth, 0, eleScaledW, txrH); + if (scalableFrom(oneUpCache)) { + // then we can relatively cheaply rescale the existing image w/o rerendering + downscale(); + } else if (scalableFrom(higherCache)) { + // then use the higher cache for now and queue the next level down + // to cheaply scale towards the smaller level + + if (highQualityReq) { + for (var _l = higherCache.level; _l > lvl; _l--) { + oneUpCache = self.getElement(ele, bb, pxRatio, _l, getTxrReasons.downscale); + } + downscale(); + } else { + self.queueElement(ele, higherCache.level - 1); + return higherCache; + } + } else { + var lowerCache; // the nearest cache with a lower level + if (!deqing && !highQualityReq && !downscaleReq) { + for (var _l2 = lvl - 1; _l2 >= minLvl$1; _l2--) { + var _c = lookup.get(ele, _l2); + if (_c) { + lowerCache = _c; + break; + } + } + } + if (scalableFrom(lowerCache)) { + // then use the lower quality cache for now and queue the better one for later + + self.queueElement(ele, lvl); + return lowerCache; + } + txr.context.translate(txr.usedWidth, 0); + txr.context.scale(scale, scale); + this.drawElement(txr.context, ele, bb, scaledLabelShown, false); + txr.context.scale(1 / scale, 1 / scale); + txr.context.translate(-txr.usedWidth, 0); + } + eleCache = { + x: txr.usedWidth, + texture: txr, + level: lvl, + scale: scale, + width: eleScaledW, + height: eleScaledH, + scaledLabelShown: scaledLabelShown + }; + txr.usedWidth += Math.ceil(eleScaledW + eleTxrSpacing); + txr.eleCaches.push(eleCache); + lookup.set(ele, lvl, eleCache); + self.checkTextureFullness(txr); + return eleCache; +}; +ETCp.invalidateElements = function (eles) { + for (var i = 0; i < eles.length; i++) { + this.invalidateElement(eles[i]); + } +}; +ETCp.invalidateElement = function (ele) { + var self = this; + var lookup = self.lookup; + var caches = []; + var invalid = lookup.isInvalid(ele); + if (!invalid) { + return; // override the invalidation request if the element key has not changed + } + + for (var lvl = minLvl$1; lvl <= maxLvl$1; lvl++) { + var cache = lookup.getForCachedKey(ele, lvl); + if (cache) { + caches.push(cache); + } + } + var noOtherElesUseCache = lookup.invalidate(ele); + if (noOtherElesUseCache) { + for (var i = 0; i < caches.length; i++) { + var _cache = caches[i]; + var txr = _cache.texture; + + // remove space from the texture it belongs to + txr.invalidatedWidth += _cache.width; + + // mark the cache as invalidated + _cache.invalidated = true; + + // retire the texture if its utility is low + self.checkTextureUtility(txr); + } + } + + // remove from queue since the old req was for the old state + self.removeFromQueue(ele); +}; +ETCp.checkTextureUtility = function (txr) { + // invalidate all entries in the cache if the cache size is small + if (txr.invalidatedWidth >= minUtility * txr.width) { + this.retireTexture(txr); + } +}; +ETCp.checkTextureFullness = function (txr) { + // if texture has been mostly filled and passed over several times, remove + // it from the queue so we don't need to waste time looking at it to put new things + + var self = this; + var txrQ = self.getTextureQueue(txr.height); + if (txr.usedWidth / txr.width > maxFullness && txr.fullnessChecks >= maxFullnessChecks) { + removeFromArray(txrQ, txr); + } else { + txr.fullnessChecks++; + } +}; +ETCp.retireTexture = function (txr) { + var self = this; + var txrH = txr.height; + var txrQ = self.getTextureQueue(txrH); + var lookup = this.lookup; + + // retire the texture from the active / searchable queue: + + removeFromArray(txrQ, txr); + txr.retired = true; + + // remove the refs from the eles to the caches: + + var eleCaches = txr.eleCaches; + for (var i = 0; i < eleCaches.length; i++) { + var eleCache = eleCaches[i]; + lookup.deleteCache(eleCache.key, eleCache.level); + } + clearArray(eleCaches); + + // add the texture to a retired queue so it can be recycled in future: + + var rtxtrQ = self.getRetiredTextureQueue(txrH); + rtxtrQ.push(txr); +}; +ETCp.addTexture = function (txrH, minW) { + var self = this; + var txrQ = self.getTextureQueue(txrH); + var txr = {}; + txrQ.push(txr); + txr.eleCaches = []; + txr.height = txrH; + txr.width = Math.max(defTxrWidth, minW); + txr.usedWidth = 0; + txr.invalidatedWidth = 0; + txr.fullnessChecks = 0; + txr.canvas = self.renderer.makeOffscreenCanvas(txr.width, txr.height); + txr.context = txr.canvas.getContext('2d'); + return txr; +}; +ETCp.recycleTexture = function (txrH, minW) { + var self = this; + var txrQ = self.getTextureQueue(txrH); + var rtxtrQ = self.getRetiredTextureQueue(txrH); + for (var i = 0; i < rtxtrQ.length; i++) { + var txr = rtxtrQ[i]; + if (txr.width >= minW) { + txr.retired = false; + txr.usedWidth = 0; + txr.invalidatedWidth = 0; + txr.fullnessChecks = 0; + clearArray(txr.eleCaches); + txr.context.setTransform(1, 0, 0, 1, 0, 0); + txr.context.clearRect(0, 0, txr.width, txr.height); + removeFromArray(rtxtrQ, txr); + txrQ.push(txr); + return txr; + } + } +}; +ETCp.queueElement = function (ele, lvl) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var key = this.getKey(ele); + var existingReq = k2q[key]; + if (existingReq) { + // use the max lvl b/c in between lvls are cheap to make + existingReq.level = Math.max(existingReq.level, lvl); + existingReq.eles.merge(ele); + existingReq.reqs++; + q.updateItem(existingReq); + } else { + var req = { + eles: ele.spawn().merge(ele), + level: lvl, + reqs: 1, + key: key + }; + q.push(req); + k2q[key] = req; + } +}; +ETCp.dequeue = function (pxRatio /*, extent*/) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var dequeued = []; + var lookup = self.lookup; + for (var i = 0; i < maxDeqSize$1; i++) { + if (q.size() > 0) { + var req = q.pop(); + var key = req.key; + var ele = req.eles[0]; // all eles have the same key + var cacheExists = lookup.hasCache(ele, req.level); + + // clear out the key to req lookup + k2q[key] = null; + + // dequeueing isn't necessary with an existing cache + if (cacheExists) { + continue; + } + dequeued.push(req); + var bb = self.getBoundingBox(ele); + self.getElement(ele, bb, pxRatio, req.level, getTxrReasons.dequeue); + } else { + break; + } + } + return dequeued; +}; +ETCp.removeFromQueue = function (ele) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var key = this.getKey(ele); + var req = k2q[key]; + if (req != null) { + if (req.eles.length === 1) { + // remove if last ele in the req + // bring to front of queue + req.reqs = MAX_INT$1; + q.updateItem(req); + q.pop(); // remove from queue + + k2q[key] = null; // remove from lookup map + } else { + // otherwise just remove ele from req + req.eles.unmerge(ele); + } + } +}; +ETCp.onDequeue = function (fn) { + this.onDequeues.push(fn); +}; +ETCp.offDequeue = function (fn) { + removeFromArray(this.onDequeues, fn); +}; +ETCp.setupDequeueing = defs.setupDequeueing({ + deqRedrawThreshold: deqRedrawThreshold$1, + deqCost: deqCost$1, + deqAvgCost: deqAvgCost$1, + deqNoDrawCost: deqNoDrawCost$1, + deqFastCost: deqFastCost$1, + deq: function deq(self, pxRatio, extent) { + return self.dequeue(pxRatio, extent); + }, + onDeqd: function onDeqd(self, deqd) { + for (var i = 0; i < self.onDequeues.length; i++) { + var fn = self.onDequeues[i]; + fn(deqd); + } + }, + shouldRedraw: function shouldRedraw(self, deqd, pxRatio, extent) { + for (var i = 0; i < deqd.length; i++) { + var eles = deqd[i].eles; + for (var j = 0; j < eles.length; j++) { + var bb = eles[j].boundingBox(); + if (boundingBoxesIntersect(bb, extent)) { + return true; + } + } + } + return false; + }, + priority: function priority(self) { + return self.renderer.beforeRenderPriorities.eleTxrDeq; + } +}); + +var defNumLayers = 1; // default number of layers to use +var minLvl = -4; // when scaling smaller than that we don't need to re-render +var maxLvl = 2; // when larger than this scale just render directly (caching is not helpful) +var maxZoom = 3.99; // beyond this zoom level, layered textures are not used +var deqRedrawThreshold = 50; // time to batch redraws together from dequeueing to allow more dequeueing calcs to happen in the meanwhile +var refineEleDebounceTime = 50; // time to debounce sharper ele texture updates +var deqCost = 0.15; // % of add'l rendering cost allowed for dequeuing ele caches each frame +var deqAvgCost = 0.1; // % of add'l rendering cost compared to average overall redraw time +var deqNoDrawCost = 0.9; // % of avg frame time that can be used for dequeueing when not drawing +var deqFastCost = 0.9; // % of frame time to be used when >60fps +var maxDeqSize = 1; // number of eles to dequeue and render at higher texture in each batch +var invalidThreshold = 250; // time threshold for disabling b/c of invalidations +var maxLayerArea = 4000 * 4000; // layers can't be bigger than this +var useHighQualityEleTxrReqs = true; // whether to use high quality ele txr requests (generally faster and cheaper in the longterm) + +// var log = function(){ console.log.apply( console, arguments ); }; + +var LayeredTextureCache = function LayeredTextureCache(renderer) { + var self = this; + var r = self.renderer = renderer; + var cy = r.cy; + self.layersByLevel = {}; // e.g. 2 => [ layer1, layer2, ..., layerN ] + + self.firstGet = true; + self.lastInvalidationTime = performanceNow() - 2 * invalidThreshold; + self.skipping = false; + self.eleTxrDeqs = cy.collection(); + self.scheduleElementRefinement = debounce_1(function () { + self.refineElementTextures(self.eleTxrDeqs); + self.eleTxrDeqs.unmerge(self.eleTxrDeqs); + }, refineEleDebounceTime); + r.beforeRender(function (willDraw, now) { + if (now - self.lastInvalidationTime <= invalidThreshold) { + self.skipping = true; + } else { + self.skipping = false; + } + }, r.beforeRenderPriorities.lyrTxrSkip); + var qSort = function qSort(a, b) { + return b.reqs - a.reqs; + }; + self.layersQueue = new heap(qSort); + self.setupDequeueing(); +}; +var LTCp = LayeredTextureCache.prototype; +var layerIdPool = 0; +var MAX_INT = Math.pow(2, 53) - 1; +LTCp.makeLayer = function (bb, lvl) { + var scale = Math.pow(2, lvl); + var w = Math.ceil(bb.w * scale); + var h = Math.ceil(bb.h * scale); + var canvas = this.renderer.makeOffscreenCanvas(w, h); + var layer = { + id: layerIdPool = ++layerIdPool % MAX_INT, + bb: bb, + level: lvl, + width: w, + height: h, + canvas: canvas, + context: canvas.getContext('2d'), + eles: [], + elesQueue: [], + reqs: 0 + }; + + // log('make layer %s with w %s and h %s and lvl %s', layer.id, layer.width, layer.height, layer.level); + + var cxt = layer.context; + var dx = -layer.bb.x1; + var dy = -layer.bb.y1; + + // do the transform on creation to save cycles (it's the same for all eles) + cxt.scale(scale, scale); + cxt.translate(dx, dy); + return layer; +}; +LTCp.getLayers = function (eles, pxRatio, lvl) { + var self = this; + var r = self.renderer; + var cy = r.cy; + var zoom = cy.zoom(); + var firstGet = self.firstGet; + self.firstGet = false; + + // log('--\nget layers with %s eles', eles.length); + //log eles.map(function(ele){ return ele.id() }) ); + + if (lvl == null) { + lvl = Math.ceil(log2(zoom * pxRatio)); + if (lvl < minLvl) { + lvl = minLvl; + } else if (zoom >= maxZoom || lvl > maxLvl) { + return null; + } + } + self.validateLayersElesOrdering(lvl, eles); + var layersByLvl = self.layersByLevel; + var scale = Math.pow(2, lvl); + var layers = layersByLvl[lvl] = layersByLvl[lvl] || []; + var bb; + var lvlComplete = self.levelIsComplete(lvl, eles); + var tmpLayers; + var checkTempLevels = function checkTempLevels() { + var canUseAsTmpLvl = function canUseAsTmpLvl(l) { + self.validateLayersElesOrdering(l, eles); + if (self.levelIsComplete(l, eles)) { + tmpLayers = layersByLvl[l]; + return true; + } + }; + var checkLvls = function checkLvls(dir) { + if (tmpLayers) { + return; + } + for (var l = lvl + dir; minLvl <= l && l <= maxLvl; l += dir) { + if (canUseAsTmpLvl(l)) { + break; + } + } + }; + checkLvls(+1); + checkLvls(-1); + + // remove the invalid layers; they will be replaced as needed later in this function + for (var i = layers.length - 1; i >= 0; i--) { + var layer = layers[i]; + if (layer.invalid) { + removeFromArray(layers, layer); + } + } + }; + if (!lvlComplete) { + // if the current level is incomplete, then use the closest, best quality layerset temporarily + // and later queue the current layerset so we can get the proper quality level soon + + checkTempLevels(); + } else { + // log('level complete, using existing layers\n--'); + return layers; + } + var getBb = function getBb() { + if (!bb) { + bb = makeBoundingBox(); + for (var i = 0; i < eles.length; i++) { + updateBoundingBox(bb, eles[i].boundingBox()); + } + } + return bb; + }; + var makeLayer = function makeLayer(opts) { + opts = opts || {}; + var after = opts.after; + getBb(); + var area = bb.w * scale * (bb.h * scale); + if (area > maxLayerArea) { + return null; + } + var layer = self.makeLayer(bb, lvl); + if (after != null) { + var index = layers.indexOf(after) + 1; + layers.splice(index, 0, layer); + } else if (opts.insert === undefined || opts.insert) { + // no after specified => first layer made so put at start + layers.unshift(layer); + } + + // if( tmpLayers ){ + //self.queueLayer( layer ); + // } + + return layer; + }; + if (self.skipping && !firstGet) { + // log('skip layers'); + return null; + } + + // log('do layers'); + + var layer = null; + var maxElesPerLayer = eles.length / defNumLayers; + var allowLazyQueueing = !firstGet; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var rs = ele._private.rscratch; + var caches = rs.imgLayerCaches = rs.imgLayerCaches || {}; + + // log('look at ele', ele.id()); + + var existingLayer = caches[lvl]; + if (existingLayer) { + // reuse layer for later eles + // log('reuse layer for', ele.id()); + layer = existingLayer; + continue; + } + if (!layer || layer.eles.length >= maxElesPerLayer || !boundingBoxInBoundingBox(layer.bb, ele.boundingBox())) { + // log('make new layer for ele %s', ele.id()); + + layer = makeLayer({ + insert: true, + after: layer + }); + + // if now layer can be built then we can't use layers at this level + if (!layer) { + return null; + } + + // log('new layer with id %s', layer.id); + } + + if (tmpLayers || allowLazyQueueing) { + // log('queue ele %s in layer %s', ele.id(), layer.id); + self.queueLayer(layer, ele); + } else { + // log('draw ele %s in layer %s', ele.id(), layer.id); + self.drawEleInLayer(layer, ele, lvl, pxRatio); + } + layer.eles.push(ele); + caches[lvl] = layer; + } + + // log('--'); + + if (tmpLayers) { + // then we only queued the current layerset and can't draw it yet + return tmpLayers; + } + if (allowLazyQueueing) { + // log('lazy queue level', lvl); + return null; + } + return layers; +}; + +// a layer may want to use an ele cache of a higher level to avoid blurriness +// so the layer level might not equal the ele level +LTCp.getEleLevelForLayerLevel = function (lvl, pxRatio) { + return lvl; +}; +LTCp.drawEleInLayer = function (layer, ele, lvl, pxRatio) { + var self = this; + var r = this.renderer; + var context = layer.context; + var bb = ele.boundingBox(); + if (bb.w === 0 || bb.h === 0 || !ele.visible()) { + return; + } + lvl = self.getEleLevelForLayerLevel(lvl, pxRatio); + { + r.setImgSmoothing(context, false); + } + { + r.drawCachedElement(context, ele, null, null, lvl, useHighQualityEleTxrReqs); + } + { + r.setImgSmoothing(context, true); + } +}; +LTCp.levelIsComplete = function (lvl, eles) { + var self = this; + var layers = self.layersByLevel[lvl]; + if (!layers || layers.length === 0) { + return false; + } + var numElesInLayers = 0; + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + + // if there are any eles needed to be drawn yet, the level is not complete + if (layer.reqs > 0) { + return false; + } + + // if the layer is invalid, the level is not complete + if (layer.invalid) { + return false; + } + numElesInLayers += layer.eles.length; + } + + // we should have exactly the number of eles passed in to be complete + if (numElesInLayers !== eles.length) { + return false; + } + return true; +}; +LTCp.validateLayersElesOrdering = function (lvl, eles) { + var layers = this.layersByLevel[lvl]; + if (!layers) { + return; + } + + // if in a layer the eles are not in the same order, then the layer is invalid + // (i.e. there is an ele in between the eles in the layer) + + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + var offset = -1; + + // find the offset + for (var j = 0; j < eles.length; j++) { + if (layer.eles[0] === eles[j]) { + offset = j; + break; + } + } + if (offset < 0) { + // then the layer has nonexistent elements and is invalid + this.invalidateLayer(layer); + continue; + } + + // the eles in the layer must be in the same continuous order, else the layer is invalid + + var o = offset; + for (var j = 0; j < layer.eles.length; j++) { + if (layer.eles[j] !== eles[o + j]) { + // log('invalidate based on ordering', layer.id); + + this.invalidateLayer(layer); + break; + } + } + } +}; +LTCp.updateElementsInLayers = function (eles, update) { + var self = this; + var isEles = element(eles[0]); + + // collect udpated elements (cascaded from the layers) and update each + // layer itself along the way + for (var i = 0; i < eles.length; i++) { + var req = isEles ? null : eles[i]; + var ele = isEles ? eles[i] : eles[i].ele; + var rs = ele._private.rscratch; + var caches = rs.imgLayerCaches = rs.imgLayerCaches || {}; + for (var l = minLvl; l <= maxLvl; l++) { + var layer = caches[l]; + if (!layer) { + continue; + } + + // if update is a request from the ele cache, then it affects only + // the matching level + if (req && self.getEleLevelForLayerLevel(layer.level) !== req.level) { + continue; + } + update(layer, ele, req); + } + } +}; +LTCp.haveLayers = function () { + var self = this; + var haveLayers = false; + for (var l = minLvl; l <= maxLvl; l++) { + var layers = self.layersByLevel[l]; + if (layers && layers.length > 0) { + haveLayers = true; + break; + } + } + return haveLayers; +}; +LTCp.invalidateElements = function (eles) { + var self = this; + if (eles.length === 0) { + return; + } + self.lastInvalidationTime = performanceNow(); + + // log('update invalidate layer time from eles'); + + if (eles.length === 0 || !self.haveLayers()) { + return; + } + self.updateElementsInLayers(eles, function invalAssocLayers(layer, ele, req) { + self.invalidateLayer(layer); + }); +}; +LTCp.invalidateLayer = function (layer) { + // log('update invalidate layer time'); + + this.lastInvalidationTime = performanceNow(); + if (layer.invalid) { + return; + } // save cycles + + var lvl = layer.level; + var eles = layer.eles; + var layers = this.layersByLevel[lvl]; + + // log('invalidate layer', layer.id ); + + removeFromArray(layers, layer); + // layer.eles = []; + + layer.elesQueue = []; + layer.invalid = true; + if (layer.replacement) { + layer.replacement.invalid = true; + } + for (var i = 0; i < eles.length; i++) { + var caches = eles[i]._private.rscratch.imgLayerCaches; + if (caches) { + caches[lvl] = null; + } + } +}; +LTCp.refineElementTextures = function (eles) { + var self = this; + + // log('refine', eles.length); + + self.updateElementsInLayers(eles, function refineEachEle(layer, ele, req) { + var rLyr = layer.replacement; + if (!rLyr) { + rLyr = layer.replacement = self.makeLayer(layer.bb, layer.level); + rLyr.replaces = layer; + rLyr.eles = layer.eles; + + // log('make replacement layer %s for %s with level %s', rLyr.id, layer.id, rLyr.level); + } + + if (!rLyr.reqs) { + for (var i = 0; i < rLyr.eles.length; i++) { + self.queueLayer(rLyr, rLyr.eles[i]); + } + + // log('queue replacement layer refinement', rLyr.id); + } + }); +}; + +LTCp.enqueueElementRefinement = function (ele) { + this.eleTxrDeqs.merge(ele); + this.scheduleElementRefinement(); +}; +LTCp.queueLayer = function (layer, ele) { + var self = this; + var q = self.layersQueue; + var elesQ = layer.elesQueue; + var hasId = elesQ.hasId = elesQ.hasId || {}; + + // if a layer is going to be replaced, queuing is a waste of time + if (layer.replacement) { + return; + } + if (ele) { + if (hasId[ele.id()]) { + return; + } + elesQ.push(ele); + hasId[ele.id()] = true; + } + if (layer.reqs) { + layer.reqs++; + q.updateItem(layer); + } else { + layer.reqs = 1; + q.push(layer); + } +}; +LTCp.dequeue = function (pxRatio) { + var self = this; + var q = self.layersQueue; + var deqd = []; + var eleDeqs = 0; + while (eleDeqs < maxDeqSize) { + if (q.size() === 0) { + break; + } + var layer = q.peek(); + + // if a layer has been or will be replaced, then don't waste time with it + if (layer.replacement) { + // log('layer %s in queue skipped b/c it already has a replacement', layer.id); + q.pop(); + continue; + } + + // if this is a replacement layer that has been superceded, then forget it + if (layer.replaces && layer !== layer.replaces.replacement) { + // log('layer is no longer the most uptodate replacement; dequeued', layer.id) + q.pop(); + continue; + } + if (layer.invalid) { + // log('replacement layer %s is invalid; dequeued', layer.id); + q.pop(); + continue; + } + var ele = layer.elesQueue.shift(); + if (ele) { + // log('dequeue layer %s', layer.id); + + self.drawEleInLayer(layer, ele, layer.level, pxRatio); + eleDeqs++; + } + if (deqd.length === 0) { + // we need only one entry in deqd to queue redrawing etc + deqd.push(true); + } + + // if the layer has all its eles done, then remove from the queue + if (layer.elesQueue.length === 0) { + q.pop(); + layer.reqs = 0; + + // log('dequeue of layer %s complete', layer.id); + + // when a replacement layer is dequeued, it replaces the old layer in the level + if (layer.replaces) { + self.applyLayerReplacement(layer); + } + self.requestRedraw(); + } + } + return deqd; +}; +LTCp.applyLayerReplacement = function (layer) { + var self = this; + var layersInLevel = self.layersByLevel[layer.level]; + var replaced = layer.replaces; + var index = layersInLevel.indexOf(replaced); + + // if the replaced layer is not in the active list for the level, then replacing + // refs would be a mistake (i.e. overwriting the true active layer) + if (index < 0 || replaced.invalid) { + // log('replacement layer would have no effect', layer.id); + return; + } + layersInLevel[index] = layer; // replace level ref + + // replace refs in eles + for (var i = 0; i < layer.eles.length; i++) { + var _p = layer.eles[i]._private; + var cache = _p.imgLayerCaches = _p.imgLayerCaches || {}; + if (cache) { + cache[layer.level] = layer; + } + } + + // log('apply replacement layer %s over %s', layer.id, replaced.id); + + self.requestRedraw(); +}; +LTCp.requestRedraw = debounce_1(function () { + var r = this.renderer; + r.redrawHint('eles', true); + r.redrawHint('drag', true); + r.redraw(); +}, 100); +LTCp.setupDequeueing = defs.setupDequeueing({ + deqRedrawThreshold: deqRedrawThreshold, + deqCost: deqCost, + deqAvgCost: deqAvgCost, + deqNoDrawCost: deqNoDrawCost, + deqFastCost: deqFastCost, + deq: function deq(self, pxRatio) { + return self.dequeue(pxRatio); + }, + onDeqd: noop$1, + shouldRedraw: trueify, + priority: function priority(self) { + return self.renderer.beforeRenderPriorities.lyrTxrDeq; + } +}); + +var CRp$a = {}; +var impl; +function polygon(context, points) { + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + context.lineTo(pt.x, pt.y); + } +} +function triangleBackcurve(context, points, controlPoint) { + var firstPt; + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + if (i === 0) { + firstPt = pt; + } + context.lineTo(pt.x, pt.y); + } + context.quadraticCurveTo(controlPoint.x, controlPoint.y, firstPt.x, firstPt.y); +} +function triangleTee(context, trianglePoints, teePoints) { + if (context.beginPath) { + context.beginPath(); + } + var triPts = trianglePoints; + for (var i = 0; i < triPts.length; i++) { + var pt = triPts[i]; + context.lineTo(pt.x, pt.y); + } + var teePts = teePoints; + var firstTeePt = teePoints[0]; + context.moveTo(firstTeePt.x, firstTeePt.y); + for (var i = 1; i < teePts.length; i++) { + var pt = teePts[i]; + context.lineTo(pt.x, pt.y); + } + if (context.closePath) { + context.closePath(); + } +} +function circleTriangle(context, trianglePoints, rx, ry, r) { + if (context.beginPath) { + context.beginPath(); + } + context.arc(rx, ry, r, 0, Math.PI * 2, false); + var triPts = trianglePoints; + var firstTrPt = triPts[0]; + context.moveTo(firstTrPt.x, firstTrPt.y); + for (var i = 0; i < triPts.length; i++) { + var pt = triPts[i]; + context.lineTo(pt.x, pt.y); + } + if (context.closePath) { + context.closePath(); + } +} +function circle(context, rx, ry, r) { + context.arc(rx, ry, r, 0, Math.PI * 2, false); +} +CRp$a.arrowShapeImpl = function (name) { + return (impl || (impl = { + 'polygon': polygon, + 'triangle-backcurve': triangleBackcurve, + 'triangle-tee': triangleTee, + 'circle-triangle': circleTriangle, + 'triangle-cross': triangleTee, + 'circle': circle + }))[name]; +}; + +var CRp$9 = {}; +CRp$9.drawElement = function (context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity) { + var r = this; + if (ele.isNode()) { + r.drawNode(context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity); + } else { + r.drawEdge(context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity); + } +}; +CRp$9.drawElementOverlay = function (context, ele) { + var r = this; + if (ele.isNode()) { + r.drawNodeOverlay(context, ele); + } else { + r.drawEdgeOverlay(context, ele); + } +}; +CRp$9.drawElementUnderlay = function (context, ele) { + var r = this; + if (ele.isNode()) { + r.drawNodeUnderlay(context, ele); + } else { + r.drawEdgeUnderlay(context, ele); + } +}; +CRp$9.drawCachedElementPortion = function (context, ele, eleTxrCache, pxRatio, lvl, reason, getRotation, getOpacity) { + var r = this; + var bb = eleTxrCache.getBoundingBox(ele); + if (bb.w === 0 || bb.h === 0) { + return; + } // ignore zero size case + + var eleCache = eleTxrCache.getElement(ele, bb, pxRatio, lvl, reason); + if (eleCache != null) { + var opacity = getOpacity(r, ele); + if (opacity === 0) { + return; + } + var theta = getRotation(r, ele); + var x1 = bb.x1, + y1 = bb.y1, + w = bb.w, + h = bb.h; + var x, y, sx, sy, smooth; + if (theta !== 0) { + var rotPt = eleTxrCache.getRotationPoint(ele); + sx = rotPt.x; + sy = rotPt.y; + context.translate(sx, sy); + context.rotate(theta); + smooth = r.getImgSmoothing(context); + if (!smooth) { + r.setImgSmoothing(context, true); + } + var off = eleTxrCache.getRotationOffset(ele); + x = off.x; + y = off.y; + } else { + x = x1; + y = y1; + } + var oldGlobalAlpha; + if (opacity !== 1) { + oldGlobalAlpha = context.globalAlpha; + context.globalAlpha = oldGlobalAlpha * opacity; + } + context.drawImage(eleCache.texture.canvas, eleCache.x, 0, eleCache.width, eleCache.height, x, y, w, h); + if (opacity !== 1) { + context.globalAlpha = oldGlobalAlpha; + } + if (theta !== 0) { + context.rotate(-theta); + context.translate(-sx, -sy); + if (!smooth) { + r.setImgSmoothing(context, false); + } + } + } else { + eleTxrCache.drawElement(context, ele); // direct draw fallback + } +}; + +var getZeroRotation = function getZeroRotation() { + return 0; +}; +var getLabelRotation = function getLabelRotation(r, ele) { + return r.getTextAngle(ele, null); +}; +var getSourceLabelRotation = function getSourceLabelRotation(r, ele) { + return r.getTextAngle(ele, 'source'); +}; +var getTargetLabelRotation = function getTargetLabelRotation(r, ele) { + return r.getTextAngle(ele, 'target'); +}; +var getOpacity = function getOpacity(r, ele) { + return ele.effectiveOpacity(); +}; +var getTextOpacity = function getTextOpacity(e, ele) { + return ele.pstyle('text-opacity').pfValue * ele.effectiveOpacity(); +}; +CRp$9.drawCachedElement = function (context, ele, pxRatio, extent, lvl, requestHighQuality) { + var r = this; + var _r$data = r.data, + eleTxrCache = _r$data.eleTxrCache, + lblTxrCache = _r$data.lblTxrCache, + slbTxrCache = _r$data.slbTxrCache, + tlbTxrCache = _r$data.tlbTxrCache; + var bb = ele.boundingBox(); + var reason = requestHighQuality === true ? eleTxrCache.reasons.highQuality : null; + if (bb.w === 0 || bb.h === 0 || !ele.visible()) { + return; + } + if (!extent || boundingBoxesIntersect(bb, extent)) { + var isEdge = ele.isEdge(); + var badLine = ele.element()._private.rscratch.badLine; + r.drawElementUnderlay(context, ele); + r.drawCachedElementPortion(context, ele, eleTxrCache, pxRatio, lvl, reason, getZeroRotation, getOpacity); + if (!isEdge || !badLine) { + r.drawCachedElementPortion(context, ele, lblTxrCache, pxRatio, lvl, reason, getLabelRotation, getTextOpacity); + } + if (isEdge && !badLine) { + r.drawCachedElementPortion(context, ele, slbTxrCache, pxRatio, lvl, reason, getSourceLabelRotation, getTextOpacity); + r.drawCachedElementPortion(context, ele, tlbTxrCache, pxRatio, lvl, reason, getTargetLabelRotation, getTextOpacity); + } + r.drawElementOverlay(context, ele); + } +}; +CRp$9.drawElements = function (context, eles) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + r.drawElement(context, ele); + } +}; +CRp$9.drawCachedElements = function (context, eles, pxRatio, extent) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + r.drawCachedElement(context, ele, pxRatio, extent); + } +}; +CRp$9.drawCachedNodes = function (context, eles, pxRatio, extent) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + r.drawCachedElement(context, ele, pxRatio, extent); + } +}; +CRp$9.drawLayeredElements = function (context, eles, pxRatio, extent) { + var r = this; + var layers = r.data.lyrTxrCache.getLayers(eles, pxRatio); + if (layers) { + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + var bb = layer.bb; + if (bb.w === 0 || bb.h === 0) { + continue; + } + context.drawImage(layer.canvas, bb.x1, bb.y1, bb.w, bb.h); + } + } else { + // fall back on plain caching if no layers + r.drawCachedElements(context, eles, pxRatio, extent); + } +}; + +var CRp$8 = {}; +CRp$8.drawEdge = function (context, edge, shiftToOriginWithBb) { + var drawLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var shouldDrawOverlay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var shouldDrawOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + var rs = edge._private.rscratch; + if (shouldDrawOpacity && !edge.visible()) { + return; + } + + // if bezier ctrl pts can not be calculated, then die + if (rs.badLine || rs.allpts == null || isNaN(rs.allpts[0])) { + // isNaN in case edge is impossible and browser bugs (e.g. safari) + return; + } + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + var opacity = shouldDrawOpacity ? edge.pstyle('opacity').value : 1; + var lineOpacity = shouldDrawOpacity ? edge.pstyle('line-opacity').value : 1; + var curveStyle = edge.pstyle('curve-style').value; + var lineStyle = edge.pstyle('line-style').value; + var edgeWidth = edge.pstyle('width').pfValue; + var lineCap = edge.pstyle('line-cap').value; + var effectiveLineOpacity = opacity * lineOpacity; + // separate arrow opacity would require arrow-opacity property + var effectiveArrowOpacity = opacity * lineOpacity; + var drawLine = function drawLine() { + var strokeOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : effectiveLineOpacity; + if (curveStyle === 'straight-triangle') { + r.eleStrokeStyle(context, edge, strokeOpacity); + r.drawEdgeTrianglePath(edge, context, rs.allpts); + } else { + context.lineWidth = edgeWidth; + context.lineCap = lineCap; + r.eleStrokeStyle(context, edge, strokeOpacity); + r.drawEdgePath(edge, context, rs.allpts, lineStyle); + context.lineCap = 'butt'; // reset for other drawing functions + } + }; + + var drawOverlay = function drawOverlay() { + if (!shouldDrawOverlay) { + return; + } + r.drawEdgeOverlay(context, edge); + }; + var drawUnderlay = function drawUnderlay() { + if (!shouldDrawOverlay) { + return; + } + r.drawEdgeUnderlay(context, edge); + }; + var drawArrows = function drawArrows() { + var arrowOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : effectiveArrowOpacity; + r.drawArrowheads(context, edge, arrowOpacity); + }; + var drawText = function drawText() { + r.drawElementText(context, edge, null, drawLabel); + }; + context.lineJoin = 'round'; + var ghost = edge.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = edge.pstyle('ghost-offset-x').pfValue; + var gy = edge.pstyle('ghost-offset-y').pfValue; + var ghostOpacity = edge.pstyle('ghost-opacity').value; + var effectiveGhostOpacity = effectiveLineOpacity * ghostOpacity; + context.translate(gx, gy); + drawLine(effectiveGhostOpacity); + drawArrows(effectiveGhostOpacity); + context.translate(-gx, -gy); + } + drawUnderlay(); + drawLine(); + drawArrows(); + drawOverlay(); + drawText(); + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +var drawEdgeOverlayUnderlay = function drawEdgeOverlayUnderlay(overlayOrUnderlay) { + if (!['overlay', 'underlay'].includes(overlayOrUnderlay)) { + throw new Error('Invalid state'); + } + return function (context, edge) { + if (!edge.visible()) { + return; + } + var opacity = edge.pstyle("".concat(overlayOrUnderlay, "-opacity")).value; + if (opacity === 0) { + return; + } + var r = this; + var usePaths = r.usePaths(); + var rs = edge._private.rscratch; + var padding = edge.pstyle("".concat(overlayOrUnderlay, "-padding")).pfValue; + var width = 2 * padding; + var color = edge.pstyle("".concat(overlayOrUnderlay, "-color")).value; + context.lineWidth = width; + if (rs.edgeType === 'self' && !usePaths) { + context.lineCap = 'butt'; + } else { + context.lineCap = 'round'; + } + r.colorStrokeStyle(context, color[0], color[1], color[2], opacity); + r.drawEdgePath(edge, context, rs.allpts, 'solid'); + }; +}; +CRp$8.drawEdgeOverlay = drawEdgeOverlayUnderlay('overlay'); +CRp$8.drawEdgeUnderlay = drawEdgeOverlayUnderlay('underlay'); +CRp$8.drawEdgePath = function (edge, context, pts, type) { + var rs = edge._private.rscratch; + var canvasCxt = context; + var path; + var pathCacheHit = false; + var usePaths = this.usePaths(); + var lineDashPattern = edge.pstyle('line-dash-pattern').pfValue; + var lineDashOffset = edge.pstyle('line-dash-offset').pfValue; + if (usePaths) { + var pathCacheKey = pts.join('$'); + var keyMatches = rs.pathCacheKey && rs.pathCacheKey === pathCacheKey; + if (keyMatches) { + path = context = rs.pathCache; + pathCacheHit = true; + } else { + path = context = new Path2D(); + rs.pathCacheKey = pathCacheKey; + rs.pathCache = path; + } + } + if (canvasCxt.setLineDash) { + // for very outofdate browsers + switch (type) { + case 'dotted': + canvasCxt.setLineDash([1, 1]); + break; + case 'dashed': + canvasCxt.setLineDash(lineDashPattern); + canvasCxt.lineDashOffset = lineDashOffset; + break; + case 'solid': + canvasCxt.setLineDash([]); + break; + } + } + if (!pathCacheHit && !rs.badLine) { + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(pts[0], pts[1]); + switch (rs.edgeType) { + case 'bezier': + case 'self': + case 'compound': + case 'multibezier': + for (var i = 2; i + 3 < pts.length; i += 4) { + context.quadraticCurveTo(pts[i], pts[i + 1], pts[i + 2], pts[i + 3]); + } + break; + case 'straight': + case 'haystack': + for (var _i = 2; _i + 1 < pts.length; _i += 2) { + context.lineTo(pts[_i], pts[_i + 1]); + } + break; + case 'segments': + if (rs.isRound) { + var _iterator = _createForOfIteratorHelper(rs.roundCorners), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var corner = _step.value; + drawPreparedRoundCorner(context, corner); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + context.lineTo(pts[pts.length - 2], pts[pts.length - 1]); + } else { + for (var _i2 = 2; _i2 + 1 < pts.length; _i2 += 2) { + context.lineTo(pts[_i2], pts[_i2 + 1]); + } + } + break; + } + } + context = canvasCxt; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + + // reset any line dashes + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } +}; +CRp$8.drawEdgeTrianglePath = function (edge, context, pts) { + // use line stroke style for triangle fill style + context.fillStyle = context.strokeStyle; + var edgeWidth = edge.pstyle('width').pfValue; + for (var i = 0; i + 1 < pts.length; i += 2) { + var vector = [pts[i + 2] - pts[i], pts[i + 3] - pts[i + 1]]; + var length = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + var normal = [vector[1] / length, -vector[0] / length]; + var triangleHead = [normal[0] * edgeWidth / 2, normal[1] * edgeWidth / 2]; + context.beginPath(); + context.moveTo(pts[i] - triangleHead[0], pts[i + 1] - triangleHead[1]); + context.lineTo(pts[i] + triangleHead[0], pts[i + 1] + triangleHead[1]); + context.lineTo(pts[i + 2], pts[i + 3]); + context.closePath(); + context.fill(); + } +}; +CRp$8.drawArrowheads = function (context, edge, opacity) { + var rs = edge._private.rscratch; + var isHaystack = rs.edgeType === 'haystack'; + if (!isHaystack) { + this.drawArrowhead(context, edge, 'source', rs.arrowStartX, rs.arrowStartY, rs.srcArrowAngle, opacity); + } + this.drawArrowhead(context, edge, 'mid-target', rs.midX, rs.midY, rs.midtgtArrowAngle, opacity); + this.drawArrowhead(context, edge, 'mid-source', rs.midX, rs.midY, rs.midsrcArrowAngle, opacity); + if (!isHaystack) { + this.drawArrowhead(context, edge, 'target', rs.arrowEndX, rs.arrowEndY, rs.tgtArrowAngle, opacity); + } +}; +CRp$8.drawArrowhead = function (context, edge, prefix, x, y, angle, opacity) { + if (isNaN(x) || x == null || isNaN(y) || y == null || isNaN(angle) || angle == null) { + return; + } + var self = this; + var arrowShape = edge.pstyle(prefix + '-arrow-shape').value; + if (arrowShape === 'none') { + return; + } + var arrowClearFill = edge.pstyle(prefix + '-arrow-fill').value === 'hollow' ? 'both' : 'filled'; + var arrowFill = edge.pstyle(prefix + '-arrow-fill').value; + var edgeWidth = edge.pstyle('width').pfValue; + var pArrowWidth = edge.pstyle(prefix + '-arrow-width'); + var arrowWidth = pArrowWidth.value === 'match-line' ? edgeWidth : pArrowWidth.pfValue; + if (pArrowWidth.units === '%') arrowWidth *= edgeWidth; + var edgeOpacity = edge.pstyle('opacity').value; + if (opacity === undefined) { + opacity = edgeOpacity; + } + var gco = context.globalCompositeOperation; + if (opacity !== 1 || arrowFill === 'hollow') { + // then extra clear is needed + context.globalCompositeOperation = 'destination-out'; + self.colorFillStyle(context, 255, 255, 255, 1); + self.colorStrokeStyle(context, 255, 255, 255, 1); + self.drawArrowShape(edge, context, arrowClearFill, edgeWidth, arrowShape, arrowWidth, x, y, angle); + context.globalCompositeOperation = gco; + } // otherwise, the opaque arrow clears it for free :) + + var color = edge.pstyle(prefix + '-arrow-color').value; + self.colorFillStyle(context, color[0], color[1], color[2], opacity); + self.colorStrokeStyle(context, color[0], color[1], color[2], opacity); + self.drawArrowShape(edge, context, arrowFill, edgeWidth, arrowShape, arrowWidth, x, y, angle); +}; +CRp$8.drawArrowShape = function (edge, context, fill, edgeWidth, shape, shapeWidth, x, y, angle) { + var r = this; + var usePaths = this.usePaths() && shape !== 'triangle-cross'; + var pathCacheHit = false; + var path; + var canvasContext = context; + var translation = { + x: x, + y: y + }; + var scale = edge.pstyle('arrow-scale').value; + var size = this.getArrowWidth(edgeWidth, scale); + var shapeImpl = r.arrowShapes[shape]; + if (usePaths) { + var cache = r.arrowPathCache = r.arrowPathCache || []; + var key = hashString(shape); + var cachedPath = cache[key]; + if (cachedPath != null) { + path = context = cachedPath; + pathCacheHit = true; + } else { + path = context = new Path2D(); + cache[key] = path; + } + } + if (!pathCacheHit) { + if (context.beginPath) { + context.beginPath(); + } + if (usePaths) { + // store in the path cache with values easily manipulated later + shapeImpl.draw(context, 1, 0, { + x: 0, + y: 0 + }, 1); + } else { + shapeImpl.draw(context, size, angle, translation, edgeWidth); + } + if (context.closePath) { + context.closePath(); + } + } + context = canvasContext; + if (usePaths) { + // set transform to arrow position/orientation + context.translate(x, y); + context.rotate(angle); + context.scale(size, size); + } + if (fill === 'filled' || fill === 'both') { + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + } + if (fill === 'hollow' || fill === 'both') { + context.lineWidth = shapeWidth / (usePaths ? size : 1); + context.lineJoin = 'miter'; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + } + if (usePaths) { + // reset transform by applying inverse + context.scale(1 / size, 1 / size); + context.rotate(-angle); + context.translate(-x, -y); + } +}; + +var CRp$7 = {}; +CRp$7.safeDrawImage = function (context, img, ix, iy, iw, ih, x, y, w, h) { + // detect problematic cases for old browsers with bad images (cheaper than try-catch) + if (iw <= 0 || ih <= 0 || w <= 0 || h <= 0) { + return; + } + try { + context.drawImage(img, ix, iy, iw, ih, x, y, w, h); + } catch (e) { + warn(e); + } +}; +CRp$7.drawInscribedImage = function (context, img, node, index, nodeOpacity) { + var r = this; + var pos = node.position(); + var nodeX = pos.x; + var nodeY = pos.y; + var styleObj = node.cy().style(); + var getIndexedStyle = styleObj.getIndexedStyle.bind(styleObj); + var fit = getIndexedStyle(node, 'background-fit', 'value', index); + var repeat = getIndexedStyle(node, 'background-repeat', 'value', index); + var nodeW = node.width(); + var nodeH = node.height(); + var paddingX2 = node.padding() * 2; + var nodeTW = nodeW + (getIndexedStyle(node, 'background-width-relative-to', 'value', index) === 'inner' ? 0 : paddingX2); + var nodeTH = nodeH + (getIndexedStyle(node, 'background-height-relative-to', 'value', index) === 'inner' ? 0 : paddingX2); + var rs = node._private.rscratch; + var clip = getIndexedStyle(node, 'background-clip', 'value', index); + var shouldClip = clip === 'node'; + var imgOpacity = getIndexedStyle(node, 'background-image-opacity', 'value', index) * nodeOpacity; + var smooth = getIndexedStyle(node, 'background-image-smoothing', 'value', index); + var cornerRadius = node.pstyle('corner-radius').value; + if (cornerRadius !== 'auto') cornerRadius = node.pstyle('corner-radius').pfValue; + var imgW = img.width || img.cachedW; + var imgH = img.height || img.cachedH; + + // workaround for broken browsers like ie + if (null == imgW || null == imgH) { + document.body.appendChild(img); // eslint-disable-line no-undef + + imgW = img.cachedW = img.width || img.offsetWidth; + imgH = img.cachedH = img.height || img.offsetHeight; + document.body.removeChild(img); // eslint-disable-line no-undef + } + + var w = imgW; + var h = imgH; + if (getIndexedStyle(node, 'background-width', 'value', index) !== 'auto') { + if (getIndexedStyle(node, 'background-width', 'units', index) === '%') { + w = getIndexedStyle(node, 'background-width', 'pfValue', index) * nodeTW; + } else { + w = getIndexedStyle(node, 'background-width', 'pfValue', index); + } + } + if (getIndexedStyle(node, 'background-height', 'value', index) !== 'auto') { + if (getIndexedStyle(node, 'background-height', 'units', index) === '%') { + h = getIndexedStyle(node, 'background-height', 'pfValue', index) * nodeTH; + } else { + h = getIndexedStyle(node, 'background-height', 'pfValue', index); + } + } + if (w === 0 || h === 0) { + return; // no point in drawing empty image (and chrome is broken in this case) + } + + if (fit === 'contain') { + var scale = Math.min(nodeTW / w, nodeTH / h); + w *= scale; + h *= scale; + } else if (fit === 'cover') { + var scale = Math.max(nodeTW / w, nodeTH / h); + w *= scale; + h *= scale; + } + var x = nodeX - nodeTW / 2; // left + var posXUnits = getIndexedStyle(node, 'background-position-x', 'units', index); + var posXPfVal = getIndexedStyle(node, 'background-position-x', 'pfValue', index); + if (posXUnits === '%') { + x += (nodeTW - w) * posXPfVal; + } else { + x += posXPfVal; + } + var offXUnits = getIndexedStyle(node, 'background-offset-x', 'units', index); + var offXPfVal = getIndexedStyle(node, 'background-offset-x', 'pfValue', index); + if (offXUnits === '%') { + x += (nodeTW - w) * offXPfVal; + } else { + x += offXPfVal; + } + var y = nodeY - nodeTH / 2; // top + var posYUnits = getIndexedStyle(node, 'background-position-y', 'units', index); + var posYPfVal = getIndexedStyle(node, 'background-position-y', 'pfValue', index); + if (posYUnits === '%') { + y += (nodeTH - h) * posYPfVal; + } else { + y += posYPfVal; + } + var offYUnits = getIndexedStyle(node, 'background-offset-y', 'units', index); + var offYPfVal = getIndexedStyle(node, 'background-offset-y', 'pfValue', index); + if (offYUnits === '%') { + y += (nodeTH - h) * offYPfVal; + } else { + y += offYPfVal; + } + if (rs.pathCache) { + x -= nodeX; + y -= nodeY; + nodeX = 0; + nodeY = 0; + } + var gAlpha = context.globalAlpha; + context.globalAlpha = imgOpacity; + var smoothingEnabled = r.getImgSmoothing(context); + var isSmoothingSwitched = false; + if (smooth === 'no' && smoothingEnabled) { + r.setImgSmoothing(context, false); + isSmoothingSwitched = true; + } else if (smooth === 'yes' && !smoothingEnabled) { + r.setImgSmoothing(context, true); + isSmoothingSwitched = true; + } + if (repeat === 'no-repeat') { + if (shouldClip) { + context.save(); + if (rs.pathCache) { + context.clip(rs.pathCache); + } else { + r.nodeShapes[r.getNodeShape(node)].draw(context, nodeX, nodeY, nodeTW, nodeTH, cornerRadius, rs); + context.clip(); + } + } + r.safeDrawImage(context, img, 0, 0, imgW, imgH, x, y, w, h); + if (shouldClip) { + context.restore(); + } + } else { + var pattern = context.createPattern(img, repeat); + context.fillStyle = pattern; + r.nodeShapes[r.getNodeShape(node)].draw(context, nodeX, nodeY, nodeTW, nodeTH, cornerRadius, rs); + context.translate(x, y); + context.fill(); + context.translate(-x, -y); + } + context.globalAlpha = gAlpha; + if (isSmoothingSwitched) { + r.setImgSmoothing(context, smoothingEnabled); + } +}; + +var CRp$6 = {}; +CRp$6.eleTextBiggerThanMin = function (ele, scale) { + if (!scale) { + var zoom = ele.cy().zoom(); + var pxRatio = this.getPixelRatio(); + var lvl = Math.ceil(log2(zoom * pxRatio)); // the effective texture level + + scale = Math.pow(2, lvl); + } + var computedSize = ele.pstyle('font-size').pfValue * scale; + var minSize = ele.pstyle('min-zoomed-font-size').pfValue; + if (computedSize < minSize) { + return false; + } + return true; +}; +CRp$6.drawElementText = function (context, ele, shiftToOriginWithBb, force, prefix) { + var useEleOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + if (force == null) { + if (useEleOpacity && !r.eleTextBiggerThanMin(ele)) { + return; + } + } else if (force === false) { + return; + } + if (ele.isNode()) { + var label = ele.pstyle('label'); + if (!label || !label.value) { + return; + } + var justification = r.getLabelJustification(ele); + context.textAlign = justification; + context.textBaseline = 'bottom'; + } else { + var badLine = ele.element()._private.rscratch.badLine; + var _label = ele.pstyle('label'); + var srcLabel = ele.pstyle('source-label'); + var tgtLabel = ele.pstyle('target-label'); + if (badLine || (!_label || !_label.value) && (!srcLabel || !srcLabel.value) && (!tgtLabel || !tgtLabel.value)) { + return; + } + context.textAlign = 'center'; + context.textBaseline = 'bottom'; + } + var applyRotation = !shiftToOriginWithBb; + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + if (prefix == null) { + r.drawText(context, ele, null, applyRotation, useEleOpacity); + if (ele.isEdge()) { + r.drawText(context, ele, 'source', applyRotation, useEleOpacity); + r.drawText(context, ele, 'target', applyRotation, useEleOpacity); + } + } else { + r.drawText(context, ele, prefix, applyRotation, useEleOpacity); + } + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +CRp$6.getFontCache = function (context) { + var cache; + this.fontCaches = this.fontCaches || []; + for (var i = 0; i < this.fontCaches.length; i++) { + cache = this.fontCaches[i]; + if (cache.context === context) { + return cache; + } + } + cache = { + context: context + }; + this.fontCaches.push(cache); + return cache; +}; + +// set up canvas context with font +// returns transformed text string +CRp$6.setupTextStyle = function (context, ele) { + var useEleOpacity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + // Font style + var labelStyle = ele.pstyle('font-style').strValue; + var labelSize = ele.pstyle('font-size').pfValue + 'px'; + var labelFamily = ele.pstyle('font-family').strValue; + var labelWeight = ele.pstyle('font-weight').strValue; + var opacity = useEleOpacity ? ele.effectiveOpacity() * ele.pstyle('text-opacity').value : 1; + var outlineOpacity = ele.pstyle('text-outline-opacity').value * opacity; + var color = ele.pstyle('color').value; + var outlineColor = ele.pstyle('text-outline-color').value; + context.font = labelStyle + ' ' + labelWeight + ' ' + labelSize + ' ' + labelFamily; + context.lineJoin = 'round'; // so text outlines aren't jagged + + this.colorFillStyle(context, color[0], color[1], color[2], opacity); + this.colorStrokeStyle(context, outlineColor[0], outlineColor[1], outlineColor[2], outlineOpacity); +}; + +// TODO ensure re-used +function roundRect(ctx, x, y, width, height) { + var radius = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 5; + var stroke = arguments.length > 6 ? arguments[6] : undefined; + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + if (stroke) ctx.stroke();else ctx.fill(); +} +CRp$6.getTextAngle = function (ele, prefix) { + var theta; + var _p = ele._private; + var rscratch = _p.rscratch; + var pdash = prefix ? prefix + '-' : ''; + var rotation = ele.pstyle(pdash + 'text-rotation'); + var textAngle = getPrefixedProperty(rscratch, 'labelAngle', prefix); + if (rotation.strValue === 'autorotate') { + theta = ele.isEdge() ? textAngle : 0; + } else if (rotation.strValue === 'none') { + theta = 0; + } else { + theta = rotation.pfValue; + } + return theta; +}; +CRp$6.drawText = function (context, ele, prefix) { + var applyRotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var useEleOpacity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var _p = ele._private; + var rscratch = _p.rscratch; + var parentOpacity = useEleOpacity ? ele.effectiveOpacity() : 1; + if (useEleOpacity && (parentOpacity === 0 || ele.pstyle('text-opacity').value === 0)) { + return; + } + + // use 'main' as an alias for the main label (i.e. null prefix) + if (prefix === 'main') { + prefix = null; + } + var textX = getPrefixedProperty(rscratch, 'labelX', prefix); + var textY = getPrefixedProperty(rscratch, 'labelY', prefix); + var orgTextX, orgTextY; // used for rotation + var text = this.getLabelText(ele, prefix); + if (text != null && text !== '' && !isNaN(textX) && !isNaN(textY)) { + this.setupTextStyle(context, ele, useEleOpacity); + var pdash = prefix ? prefix + '-' : ''; + var textW = getPrefixedProperty(rscratch, 'labelWidth', prefix); + var textH = getPrefixedProperty(rscratch, 'labelHeight', prefix); + var marginX = ele.pstyle(pdash + 'text-margin-x').pfValue; + var marginY = ele.pstyle(pdash + 'text-margin-y').pfValue; + var isEdge = ele.isEdge(); + var halign = ele.pstyle('text-halign').value; + var valign = ele.pstyle('text-valign').value; + if (isEdge) { + halign = 'center'; + valign = 'center'; + } + textX += marginX; + textY += marginY; + var theta; + if (!applyRotation) { + theta = 0; + } else { + theta = this.getTextAngle(ele, prefix); + } + if (theta !== 0) { + orgTextX = textX; + orgTextY = textY; + context.translate(orgTextX, orgTextY); + context.rotate(theta); + textX = 0; + textY = 0; + } + switch (valign) { + case 'top': + break; + case 'center': + textY += textH / 2; + break; + case 'bottom': + textY += textH; + break; + } + var backgroundOpacity = ele.pstyle('text-background-opacity').value; + var borderOpacity = ele.pstyle('text-border-opacity').value; + var textBorderWidth = ele.pstyle('text-border-width').pfValue; + var backgroundPadding = ele.pstyle('text-background-padding').pfValue; + var styleShape = ele.pstyle('text-background-shape').strValue; + var rounded = styleShape.indexOf('round') === 0; + var roundRadius = 2; + if (backgroundOpacity > 0 || textBorderWidth > 0 && borderOpacity > 0) { + var bgX = textX - backgroundPadding; + switch (halign) { + case 'left': + bgX -= textW; + break; + case 'center': + bgX -= textW / 2; + break; + } + var bgY = textY - textH - backgroundPadding; + var bgW = textW + 2 * backgroundPadding; + var bgH = textH + 2 * backgroundPadding; + if (backgroundOpacity > 0) { + var textFill = context.fillStyle; + var textBackgroundColor = ele.pstyle('text-background-color').value; + context.fillStyle = 'rgba(' + textBackgroundColor[0] + ',' + textBackgroundColor[1] + ',' + textBackgroundColor[2] + ',' + backgroundOpacity * parentOpacity + ')'; + if (rounded) { + roundRect(context, bgX, bgY, bgW, bgH, roundRadius); + } else { + context.fillRect(bgX, bgY, bgW, bgH); + } + context.fillStyle = textFill; + } + if (textBorderWidth > 0 && borderOpacity > 0) { + var textStroke = context.strokeStyle; + var textLineWidth = context.lineWidth; + var textBorderColor = ele.pstyle('text-border-color').value; + var textBorderStyle = ele.pstyle('text-border-style').value; + context.strokeStyle = 'rgba(' + textBorderColor[0] + ',' + textBorderColor[1] + ',' + textBorderColor[2] + ',' + borderOpacity * parentOpacity + ')'; + context.lineWidth = textBorderWidth; + if (context.setLineDash) { + // for very outofdate browsers + switch (textBorderStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash([4, 2]); + break; + case 'double': + context.lineWidth = textBorderWidth / 4; // 50% reserved for white between the two borders + context.setLineDash([]); + break; + case 'solid': + context.setLineDash([]); + break; + } + } + if (rounded) { + roundRect(context, bgX, bgY, bgW, bgH, roundRadius, 'stroke'); + } else { + context.strokeRect(bgX, bgY, bgW, bgH); + } + if (textBorderStyle === 'double') { + var whiteWidth = textBorderWidth / 2; + if (rounded) { + roundRect(context, bgX + whiteWidth, bgY + whiteWidth, bgW - whiteWidth * 2, bgH - whiteWidth * 2, roundRadius, 'stroke'); + } else { + context.strokeRect(bgX + whiteWidth, bgY + whiteWidth, bgW - whiteWidth * 2, bgH - whiteWidth * 2); + } + } + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + context.lineWidth = textLineWidth; + context.strokeStyle = textStroke; + } + } + var lineWidth = 2 * ele.pstyle('text-outline-width').pfValue; // *2 b/c the stroke is drawn centred on the middle + + if (lineWidth > 0) { + context.lineWidth = lineWidth; + } + if (ele.pstyle('text-wrap').value === 'wrap') { + var lines = getPrefixedProperty(rscratch, 'labelWrapCachedLines', prefix); + var lineHeight = getPrefixedProperty(rscratch, 'labelLineHeight', prefix); + var halfTextW = textW / 2; + var justification = this.getLabelJustification(ele); + if (justification === 'auto') ; else if (halign === 'left') { + // auto justification : right + if (justification === 'left') { + textX += -textW; + } else if (justification === 'center') { + textX += -halfTextW; + } // else same as auto + } else if (halign === 'center') { + // auto justfication : center + if (justification === 'left') { + textX += -halfTextW; + } else if (justification === 'right') { + textX += halfTextW; + } // else same as auto + } else if (halign === 'right') { + // auto justification : left + if (justification === 'center') { + textX += halfTextW; + } else if (justification === 'right') { + textX += textW; + } // else same as auto + } + + switch (valign) { + case 'top': + textY -= (lines.length - 1) * lineHeight; + break; + case 'center': + case 'bottom': + textY -= (lines.length - 1) * lineHeight; + break; + } + for (var l = 0; l < lines.length; l++) { + if (lineWidth > 0) { + context.strokeText(lines[l], textX, textY); + } + context.fillText(lines[l], textX, textY); + textY += lineHeight; + } + } else { + if (lineWidth > 0) { + context.strokeText(text, textX, textY); + } + context.fillText(text, textX, textY); + } + if (theta !== 0) { + context.rotate(-theta); + context.translate(-orgTextX, -orgTextY); + } + } +}; + +/* global Path2D */ +var CRp$5 = {}; +CRp$5.drawNode = function (context, node, shiftToOriginWithBb) { + var drawLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var shouldDrawOverlay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var shouldDrawOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + var nodeWidth, nodeHeight; + var _p = node._private; + var rs = _p.rscratch; + var pos = node.position(); + if (!number$1(pos.x) || !number$1(pos.y)) { + return; // can't draw node with undefined position + } + + if (shouldDrawOpacity && !node.visible()) { + return; + } + var eleOpacity = shouldDrawOpacity ? node.effectiveOpacity() : 1; + var usePaths = r.usePaths(); + var path; + var pathCacheHit = false; + var padding = node.padding(); + nodeWidth = node.width() + 2 * padding; + nodeHeight = node.height() + 2 * padding; + + // + // setup shift + + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + + // + // load bg image + + var bgImgProp = node.pstyle('background-image'); + var urls = bgImgProp.value; + var urlDefined = new Array(urls.length); + var image = new Array(urls.length); + var numImages = 0; + for (var i = 0; i < urls.length; i++) { + var url = urls[i]; + var defd = urlDefined[i] = url != null && url !== 'none'; + if (defd) { + var bgImgCrossOrigin = node.cy().style().getIndexedStyle(node, 'background-image-crossorigin', 'value', i); + numImages++; + + // get image, and if not loaded then ask to redraw when later loaded + image[i] = r.getCachedImage(url, bgImgCrossOrigin, function () { + _p.backgroundTimestamp = Date.now(); + node.emitAndNotify('background'); + }); + } + } + + // + // setup styles + + var darkness = node.pstyle('background-blacken').value; + var borderWidth = node.pstyle('border-width').pfValue; + var bgOpacity = node.pstyle('background-opacity').value * eleOpacity; + var borderColor = node.pstyle('border-color').value; + var borderStyle = node.pstyle('border-style').value; + var borderJoin = node.pstyle('border-join').value; + var borderCap = node.pstyle('border-cap').value; + var borderPosition = node.pstyle('border-position').value; + var borderPattern = node.pstyle('border-dash-pattern').pfValue; + var borderOffset = node.pstyle('border-dash-offset').pfValue; + var borderOpacity = node.pstyle('border-opacity').value * eleOpacity; + var outlineWidth = node.pstyle('outline-width').pfValue; + var outlineColor = node.pstyle('outline-color').value; + var outlineStyle = node.pstyle('outline-style').value; + var outlineOpacity = node.pstyle('outline-opacity').value * eleOpacity; + var outlineOffset = node.pstyle('outline-offset').value; + var cornerRadius = node.pstyle('corner-radius').value; + if (cornerRadius !== 'auto') cornerRadius = node.pstyle('corner-radius').pfValue; + var setupShapeColor = function setupShapeColor() { + var bgOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bgOpacity; + r.eleFillStyle(context, node, bgOpy); + }; + var setupBorderColor = function setupBorderColor() { + var bdrOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : borderOpacity; + r.colorStrokeStyle(context, borderColor[0], borderColor[1], borderColor[2], bdrOpy); + }; + var setupOutlineColor = function setupOutlineColor() { + var otlnOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : outlineOpacity; + r.colorStrokeStyle(context, outlineColor[0], outlineColor[1], outlineColor[2], otlnOpy); + }; + + // + // setup shape + + var getPath = function getPath(width, height, shape, points) { + var pathCache = r.nodePathCache = r.nodePathCache || []; + var key = hashStrings(shape === 'polygon' ? shape + ',' + points.join(',') : shape, '' + height, '' + width, '' + cornerRadius); + var cachedPath = pathCache[key]; + var path; + var cacheHit = false; + if (cachedPath != null) { + path = cachedPath; + cacheHit = true; + rs.pathCache = path; + } else { + path = new Path2D(); + pathCache[key] = rs.pathCache = path; + } + return { + path: path, + cacheHit: cacheHit + }; + }; + var styleShape = node.pstyle('shape').strValue; + var shapePts = node.pstyle('shape-polygon-points').pfValue; + if (usePaths) { + context.translate(pos.x, pos.y); + var shapePath = getPath(nodeWidth, nodeHeight, styleShape, shapePts); + path = shapePath.path; + pathCacheHit = shapePath.cacheHit; + } + var drawShape = function drawShape() { + if (!pathCacheHit) { + var npos = pos; + if (usePaths) { + npos = { + x: 0, + y: 0 + }; + } + r.nodeShapes[r.getNodeShape(node)].draw(path || context, npos.x, npos.y, nodeWidth, nodeHeight, cornerRadius, rs); + } + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + }; + var drawImages = function drawImages() { + var nodeOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eleOpacity; + var inside = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var prevBging = _p.backgrounding; + var totalCompleted = 0; + for (var _i = 0; _i < image.length; _i++) { + var bgContainment = node.cy().style().getIndexedStyle(node, 'background-image-containment', 'value', _i); + if (inside && bgContainment === 'over' || !inside && bgContainment === 'inside') { + totalCompleted++; + continue; + } + if (urlDefined[_i] && image[_i].complete && !image[_i].error) { + totalCompleted++; + r.drawInscribedImage(context, image[_i], node, _i, nodeOpacity); + } + } + _p.backgrounding = !(totalCompleted === numImages); + if (prevBging !== _p.backgrounding) { + // update style b/c :backgrounding state changed + node.updateStyle(false); + } + }; + var drawPie = function drawPie() { + var redrawShape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var pieOpacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : eleOpacity; + if (r.hasPie(node)) { + r.drawPie(context, node, pieOpacity); + + // redraw/restore path if steps after pie need it + if (redrawShape) { + if (!usePaths) { + r.nodeShapes[r.getNodeShape(node)].draw(context, pos.x, pos.y, nodeWidth, nodeHeight, cornerRadius, rs); + } + } + } + }; + var darken = function darken() { + var darkenOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eleOpacity; + var opacity = (darkness > 0 ? darkness : -darkness) * darkenOpacity; + var c = darkness > 0 ? 0 : 255; + if (darkness !== 0) { + r.colorFillStyle(context, c, c, c, opacity); + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + } + }; + var drawBorder = function drawBorder() { + if (borderWidth > 0) { + context.lineWidth = borderWidth; + context.lineCap = borderCap; + context.lineJoin = borderJoin; + if (context.setLineDash) { + // for very outofdate browsers + switch (borderStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash(borderPattern); + context.lineDashOffset = borderOffset; + break; + case 'solid': + case 'double': + context.setLineDash([]); + break; + } + } + if (borderPosition !== 'center') { + context.save(); + context.lineWidth *= 2; + if (borderPosition === 'inside') { + usePaths ? context.clip(path) : context.clip(); + } else { + var region = new Path2D(); + region.rect(-nodeWidth / 2 - borderWidth, -nodeHeight / 2 - borderWidth, nodeWidth + 2 * borderWidth, nodeHeight + 2 * borderWidth); + region.addPath(path); + context.clip(region, 'evenodd'); + } + usePaths ? context.stroke(path) : context.stroke(); + context.restore(); + } else { + usePaths ? context.stroke(path) : context.stroke(); + } + if (borderStyle === 'double') { + context.lineWidth = borderWidth / 3; + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + context.globalCompositeOperation = gco; + } + + // reset in case we changed the border style + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + } + }; + var drawOutline = function drawOutline() { + if (outlineWidth > 0) { + context.lineWidth = outlineWidth; + context.lineCap = 'butt'; + if (context.setLineDash) { + // for very outofdate browsers + switch (outlineStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash([4, 2]); + break; + case 'solid': + case 'double': + context.setLineDash([]); + break; + } + } + var npos = pos; + if (usePaths) { + npos = { + x: 0, + y: 0 + }; + } + var shape = r.getNodeShape(node); + var bWidth = borderWidth; + if (borderPosition === 'inside') bWidth = 0; + if (borderPosition === 'outside') bWidth *= 2; + var scaleX = (nodeWidth + bWidth + (outlineWidth + outlineOffset)) / nodeWidth; + var scaleY = (nodeHeight + bWidth + (outlineWidth + outlineOffset)) / nodeHeight; + var sWidth = nodeWidth * scaleX; + var sHeight = nodeHeight * scaleY; + var points = r.nodeShapes[shape].points; + var _path; + if (usePaths) { + var outlinePath = getPath(sWidth, sHeight, shape, points); + _path = outlinePath.path; + } + + // draw the outline path, either by using expanded points or by scaling + // the dimensions, depending on shape + if (shape === "ellipse") { + r.drawEllipsePath(_path || context, npos.x, npos.y, sWidth, sHeight); + } else if (['round-diamond', 'round-heptagon', 'round-hexagon', 'round-octagon', 'round-pentagon', 'round-polygon', 'round-triangle', 'round-tag'].includes(shape)) { + var sMult = 0; + var offsetX = 0; + var offsetY = 0; + if (shape === 'round-diamond') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.4; + } else if (shape === 'round-heptagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.075; + offsetY = -(bWidth / 2 + outlineOffset + outlineWidth) / 35; + } else if (shape === 'round-hexagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.12; + } else if (shape === 'round-pentagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.13; + offsetY = -(bWidth / 2 + outlineOffset + outlineWidth) / 15; + } else if (shape === 'round-tag') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.12; + offsetX = (bWidth / 2 + outlineWidth + outlineOffset) * .07; + } else if (shape === 'round-triangle') { + sMult = (bWidth + outlineOffset + outlineWidth) * (Math.PI / 2); + offsetY = -(bWidth + outlineOffset / 2 + outlineWidth) / Math.PI; + } + if (sMult !== 0) { + scaleX = (nodeWidth + sMult) / nodeWidth; + sWidth = nodeWidth * scaleX; + if (!['round-hexagon', 'round-tag'].includes(shape)) { + scaleY = (nodeHeight + sMult) / nodeHeight; + sHeight = nodeHeight * scaleY; + } + } + cornerRadius = cornerRadius === 'auto' ? getRoundPolygonRadius(sWidth, sHeight) : cornerRadius; + var halfW = sWidth / 2; + var halfH = sHeight / 2; + var radius = cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2; + var p = new Array(points.length / 2); + var corners = new Array(points.length / 2); + for (var _i3 = 0; _i3 < points.length / 2; _i3++) { + p[_i3] = { + x: npos.x + offsetX + halfW * points[_i3 * 2], + y: npos.y + offsetY + halfH * points[_i3 * 2 + 1] + }; + } + var _i2, + p1, + p2, + p3, + len = p.length; + p1 = p[len - 1]; + // for each point + for (_i2 = 0; _i2 < len; _i2++) { + p2 = p[_i2 % len]; + p3 = p[(_i2 + 1) % len]; + corners[_i2] = getRoundCorner(p1, p2, p3, radius); + p1 = p2; + p2 = p3; + } + r.drawRoundPolygonPath(_path || context, npos.x + offsetX, npos.y + offsetY, nodeWidth * scaleX, nodeHeight * scaleY, points, corners); + } else if (['roundrectangle', 'round-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(sWidth, sHeight) : cornerRadius; + r.drawRoundRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2); + } else if (['cutrectangle', 'cut-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getCutRectangleCornerLength() : cornerRadius; + r.drawCutRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, null, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 4); + } else if (['bottomroundrectangle', 'bottom-round-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(sWidth, sHeight) : cornerRadius; + r.drawBottomRoundRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2); + } else if (shape === "barrel") { + r.drawBarrelPath(_path || context, npos.x, npos.y, sWidth, sHeight); + } else if (shape.startsWith("polygon") || ['rhomboid', 'right-rhomboid', 'round-tag', 'tag', 'vee'].includes(shape)) { + var pad = (bWidth + outlineWidth + outlineOffset) / nodeWidth; + points = joinLines(expandPolygon(points, pad)); + r.drawPolygonPath(_path || context, npos.x, npos.y, nodeWidth, nodeHeight, points); + } else { + var _pad = (bWidth + outlineWidth + outlineOffset) / nodeWidth; + points = joinLines(expandPolygon(points, -_pad)); + r.drawPolygonPath(_path || context, npos.x, npos.y, nodeWidth, nodeHeight, points); + } + if (usePaths) { + context.stroke(_path); + } else { + context.stroke(); + } + if (outlineStyle === 'double') { + context.lineWidth = bWidth / 3; + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + if (usePaths) { + context.stroke(_path); + } else { + context.stroke(); + } + context.globalCompositeOperation = gco; + } + + // reset in case we changed the border style + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + } + }; + var drawOverlay = function drawOverlay() { + if (shouldDrawOverlay) { + r.drawNodeOverlay(context, node, pos, nodeWidth, nodeHeight); + } + }; + var drawUnderlay = function drawUnderlay() { + if (shouldDrawOverlay) { + r.drawNodeUnderlay(context, node, pos, nodeWidth, nodeHeight); + } + }; + var drawText = function drawText() { + r.drawElementText(context, node, null, drawLabel); + }; + var ghost = node.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = node.pstyle('ghost-offset-x').pfValue; + var gy = node.pstyle('ghost-offset-y').pfValue; + var ghostOpacity = node.pstyle('ghost-opacity').value; + var effGhostOpacity = ghostOpacity * eleOpacity; + context.translate(gx, gy); + setupOutlineColor(); + drawOutline(); + setupShapeColor(ghostOpacity * bgOpacity); + drawShape(); + drawImages(effGhostOpacity, true); + setupBorderColor(ghostOpacity * borderOpacity); + drawBorder(); + drawPie(darkness !== 0 || borderWidth !== 0); + drawImages(effGhostOpacity, false); + darken(effGhostOpacity); + context.translate(-gx, -gy); + } + if (usePaths) { + context.translate(-pos.x, -pos.y); + } + drawUnderlay(); + if (usePaths) { + context.translate(pos.x, pos.y); + } + setupOutlineColor(); + drawOutline(); + setupShapeColor(); + drawShape(); + drawImages(eleOpacity, true); + setupBorderColor(); + drawBorder(); + drawPie(darkness !== 0 || borderWidth !== 0); + drawImages(eleOpacity, false); + darken(); + if (usePaths) { + context.translate(-pos.x, -pos.y); + } + drawText(); + drawOverlay(); + + // + // clean up shift + + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +var drawNodeOverlayUnderlay = function drawNodeOverlayUnderlay(overlayOrUnderlay) { + if (!['overlay', 'underlay'].includes(overlayOrUnderlay)) { + throw new Error('Invalid state'); + } + return function (context, node, pos, nodeWidth, nodeHeight) { + var r = this; + if (!node.visible()) { + return; + } + var padding = node.pstyle("".concat(overlayOrUnderlay, "-padding")).pfValue; + var opacity = node.pstyle("".concat(overlayOrUnderlay, "-opacity")).value; + var color = node.pstyle("".concat(overlayOrUnderlay, "-color")).value; + var shape = node.pstyle("".concat(overlayOrUnderlay, "-shape")).value; + var radius = node.pstyle("".concat(overlayOrUnderlay, "-corner-radius")).value; + if (opacity > 0) { + pos = pos || node.position(); + if (nodeWidth == null || nodeHeight == null) { + var _padding = node.padding(); + nodeWidth = node.width() + 2 * _padding; + nodeHeight = node.height() + 2 * _padding; + } + r.colorFillStyle(context, color[0], color[1], color[2], opacity); + r.nodeShapes[shape].draw(context, pos.x, pos.y, nodeWidth + padding * 2, nodeHeight + padding * 2, radius); + context.fill(); + } + }; +}; +CRp$5.drawNodeOverlay = drawNodeOverlayUnderlay('overlay'); +CRp$5.drawNodeUnderlay = drawNodeOverlayUnderlay('underlay'); + +// does the node have at least one pie piece? +CRp$5.hasPie = function (node) { + node = node[0]; // ensure ele ref + + return node._private.hasPie; +}; +CRp$5.drawPie = function (context, node, nodeOpacity, pos) { + node = node[0]; // ensure ele ref + pos = pos || node.position(); + var cyStyle = node.cy().style(); + var pieSize = node.pstyle('pie-size'); + var x = pos.x; + var y = pos.y; + var nodeW = node.width(); + var nodeH = node.height(); + var radius = Math.min(nodeW, nodeH) / 2; // must fit in node + var lastPercent = 0; // what % to continue drawing pie slices from on [0, 1] + var usePaths = this.usePaths(); + if (usePaths) { + x = 0; + y = 0; + } + if (pieSize.units === '%') { + radius = radius * pieSize.pfValue; + } else if (pieSize.pfValue !== undefined) { + radius = pieSize.pfValue / 2; + } + for (var i = 1; i <= cyStyle.pieBackgroundN; i++) { + // 1..N + var size = node.pstyle('pie-' + i + '-background-size').value; + var color = node.pstyle('pie-' + i + '-background-color').value; + var opacity = node.pstyle('pie-' + i + '-background-opacity').value * nodeOpacity; + var percent = size / 100; // map integer range [0, 100] to [0, 1] + + // percent can't push beyond 1 + if (percent + lastPercent > 1) { + percent = 1 - lastPercent; + } + var angleStart = 1.5 * Math.PI + 2 * Math.PI * lastPercent; // start at 12 o'clock and go clockwise + var angleDelta = 2 * Math.PI * percent; + var angleEnd = angleStart + angleDelta; + + // ignore if + // - zero size + // - we're already beyond the full circle + // - adding the current slice would go beyond the full circle + if (size === 0 || lastPercent >= 1 || lastPercent + percent > 1) { + continue; + } + context.beginPath(); + context.moveTo(x, y); + context.arc(x, y, radius, angleStart, angleEnd); + context.closePath(); + this.colorFillStyle(context, color[0], color[1], color[2], opacity); + context.fill(); + lastPercent += percent; + } +}; + +var CRp$4 = {}; +var motionBlurDelay = 100; + +// var isFirefox = typeof InstallTrigger !== 'undefined'; + +CRp$4.getPixelRatio = function () { + var context = this.data.contexts[0]; + if (this.forcedPixelRatio != null) { + return this.forcedPixelRatio; + } + var backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; + return (window.devicePixelRatio || 1) / backingStore; // eslint-disable-line no-undef +}; + +CRp$4.paintCache = function (context) { + var caches = this.paintCaches = this.paintCaches || []; + var needToCreateCache = true; + var cache; + for (var i = 0; i < caches.length; i++) { + cache = caches[i]; + if (cache.context === context) { + needToCreateCache = false; + break; + } + } + if (needToCreateCache) { + cache = { + context: context + }; + caches.push(cache); + } + return cache; +}; +CRp$4.createGradientStyleFor = function (context, shapeStyleName, ele, fill, opacity) { + var gradientStyle; + var usePaths = this.usePaths(); + var colors = ele.pstyle(shapeStyleName + '-gradient-stop-colors').value, + positions = ele.pstyle(shapeStyleName + '-gradient-stop-positions').pfValue; + if (fill === 'radial-gradient') { + if (ele.isEdge()) { + var start = ele.sourceEndpoint(), + end = ele.targetEndpoint(), + mid = ele.midpoint(); + var d1 = dist(start, mid); + var d2 = dist(end, mid); + gradientStyle = context.createRadialGradient(mid.x, mid.y, 0, mid.x, mid.y, Math.max(d1, d2)); + } else { + var pos = usePaths ? { + x: 0, + y: 0 + } : ele.position(), + width = ele.paddedWidth(), + height = ele.paddedHeight(); + gradientStyle = context.createRadialGradient(pos.x, pos.y, 0, pos.x, pos.y, Math.max(width, height)); + } + } else { + if (ele.isEdge()) { + var _start = ele.sourceEndpoint(), + _end = ele.targetEndpoint(); + gradientStyle = context.createLinearGradient(_start.x, _start.y, _end.x, _end.y); + } else { + var _pos = usePaths ? { + x: 0, + y: 0 + } : ele.position(), + _width = ele.paddedWidth(), + _height = ele.paddedHeight(), + halfWidth = _width / 2, + halfHeight = _height / 2; + var direction = ele.pstyle('background-gradient-direction').value; + switch (direction) { + case 'to-bottom': + gradientStyle = context.createLinearGradient(_pos.x, _pos.y - halfHeight, _pos.x, _pos.y + halfHeight); + break; + case 'to-top': + gradientStyle = context.createLinearGradient(_pos.x, _pos.y + halfHeight, _pos.x, _pos.y - halfHeight); + break; + case 'to-left': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y, _pos.x - halfWidth, _pos.y); + break; + case 'to-right': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y, _pos.x + halfWidth, _pos.y); + break; + case 'to-bottom-right': + case 'to-right-bottom': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y - halfHeight, _pos.x + halfWidth, _pos.y + halfHeight); + break; + case 'to-top-right': + case 'to-right-top': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y + halfHeight, _pos.x + halfWidth, _pos.y - halfHeight); + break; + case 'to-bottom-left': + case 'to-left-bottom': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y - halfHeight, _pos.x - halfWidth, _pos.y + halfHeight); + break; + case 'to-top-left': + case 'to-left-top': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y + halfHeight, _pos.x - halfWidth, _pos.y - halfHeight); + break; + } + } + } + if (!gradientStyle) return null; // invalid gradient style + + var hasPositions = positions.length === colors.length; + var length = colors.length; + for (var i = 0; i < length; i++) { + gradientStyle.addColorStop(hasPositions ? positions[i] : i / (length - 1), 'rgba(' + colors[i][0] + ',' + colors[i][1] + ',' + colors[i][2] + ',' + opacity + ')'); + } + return gradientStyle; +}; +CRp$4.gradientFillStyle = function (context, ele, fill, opacity) { + var gradientStyle = this.createGradientStyleFor(context, 'background', ele, fill, opacity); + if (!gradientStyle) return null; // error + context.fillStyle = gradientStyle; +}; +CRp$4.colorFillStyle = function (context, r, g, b, a) { + context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + // turn off for now, seems context does its own caching + + // var cache = this.paintCache(context); + + // var fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + + // if( cache.fillStyle !== fillStyle ){ + // context.fillStyle = cache.fillStyle = fillStyle; + // } +}; + +CRp$4.eleFillStyle = function (context, ele, opacity) { + var backgroundFill = ele.pstyle('background-fill').value; + if (backgroundFill === 'linear-gradient' || backgroundFill === 'radial-gradient') { + this.gradientFillStyle(context, ele, backgroundFill, opacity); + } else { + var backgroundColor = ele.pstyle('background-color').value; + this.colorFillStyle(context, backgroundColor[0], backgroundColor[1], backgroundColor[2], opacity); + } +}; +CRp$4.gradientStrokeStyle = function (context, ele, fill, opacity) { + var gradientStyle = this.createGradientStyleFor(context, 'line', ele, fill, opacity); + if (!gradientStyle) return null; // error + context.strokeStyle = gradientStyle; +}; +CRp$4.colorStrokeStyle = function (context, r, g, b, a) { + context.strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + // turn off for now, seems context does its own caching + + // var cache = this.paintCache(context); + + // var strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + + // if( cache.strokeStyle !== strokeStyle ){ + // context.strokeStyle = cache.strokeStyle = strokeStyle; + // } +}; + +CRp$4.eleStrokeStyle = function (context, ele, opacity) { + var lineFill = ele.pstyle('line-fill').value; + if (lineFill === 'linear-gradient' || lineFill === 'radial-gradient') { + this.gradientStrokeStyle(context, ele, lineFill, opacity); + } else { + var lineColor = ele.pstyle('line-color').value; + this.colorStrokeStyle(context, lineColor[0], lineColor[1], lineColor[2], opacity); + } +}; + +// Resize canvas +CRp$4.matchCanvasSize = function (container) { + var r = this; + var data = r.data; + var bb = r.findContainerClientCoords(); + var width = bb[2]; + var height = bb[3]; + var pixelRatio = r.getPixelRatio(); + var mbPxRatio = r.motionBlurPxRatio; + if (container === r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE] || container === r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG]) { + pixelRatio = mbPxRatio; + } + var canvasWidth = width * pixelRatio; + var canvasHeight = height * pixelRatio; + var canvas; + if (canvasWidth === r.canvasWidth && canvasHeight === r.canvasHeight) { + return; // save cycles if same + } + + r.fontCaches = null; // resizing resets the style + + var canvasContainer = data.canvasContainer; + canvasContainer.style.width = width + 'px'; + canvasContainer.style.height = height + 'px'; + for (var i = 0; i < r.CANVAS_LAYERS; i++) { + canvas = data.canvases[i]; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + } + for (var i = 0; i < r.BUFFER_COUNT; i++) { + canvas = data.bufferCanvases[i]; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + } + r.textureMult = 1; + if (pixelRatio <= 1) { + canvas = data.bufferCanvases[r.TEXTURE_BUFFER]; + r.textureMult = 2; + canvas.width = canvasWidth * r.textureMult; + canvas.height = canvasHeight * r.textureMult; + } + r.canvasWidth = canvasWidth; + r.canvasHeight = canvasHeight; +}; +CRp$4.renderTo = function (cxt, zoom, pan, pxRatio) { + this.render({ + forcedContext: cxt, + forcedZoom: zoom, + forcedPan: pan, + drawAllLayers: true, + forcedPxRatio: pxRatio + }); +}; +CRp$4.render = function (options) { + options = options || staticEmptyObject(); + var forcedContext = options.forcedContext; + var drawAllLayers = options.drawAllLayers; + var drawOnlyNodeLayer = options.drawOnlyNodeLayer; + var forcedZoom = options.forcedZoom; + var forcedPan = options.forcedPan; + var r = this; + var pixelRatio = options.forcedPxRatio === undefined ? this.getPixelRatio() : options.forcedPxRatio; + var cy = r.cy; + var data = r.data; + var needDraw = data.canvasNeedsRedraw; + var textureDraw = r.textureOnViewport && !forcedContext && (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming); + var motionBlur = options.motionBlur !== undefined ? options.motionBlur : r.motionBlur; + var mbPxRatio = r.motionBlurPxRatio; + var hasCompoundNodes = cy.hasCompoundNodes(); + var inNodeDragGesture = r.hoverData.draggingEles; + var inBoxSelection = r.hoverData.selecting || r.touchData.selecting ? true : false; + motionBlur = motionBlur && !forcedContext && r.motionBlurEnabled && !inBoxSelection; + var motionBlurFadeEffect = motionBlur; + if (!forcedContext) { + if (r.prevPxRatio !== pixelRatio) { + r.invalidateContainerClientCoordsCache(); + r.matchCanvasSize(r.container); + r.redrawHint('eles', true); + r.redrawHint('drag', true); + } + r.prevPxRatio = pixelRatio; + } + if (!forcedContext && r.motionBlurTimeout) { + clearTimeout(r.motionBlurTimeout); + } + if (motionBlur) { + if (r.mbFrames == null) { + r.mbFrames = 0; + } + r.mbFrames++; + if (r.mbFrames < 3) { + // need several frames before even high quality motionblur + motionBlurFadeEffect = false; + } + + // go to lower quality blurry frames when several m/b frames have been rendered (avoids flashing) + if (r.mbFrames > r.minMbLowQualFrames) { + //r.fullQualityMb = false; + r.motionBlurPxRatio = r.mbPxRBlurry; + } + } + if (r.clearingMotionBlur) { + r.motionBlurPxRatio = 1; + } + + // b/c drawToContext() may be async w.r.t. redraw(), keep track of last texture frame + // because a rogue async texture frame would clear needDraw + if (r.textureDrawLastFrame && !textureDraw) { + needDraw[r.NODE] = true; + needDraw[r.SELECT_BOX] = true; + } + var style = cy.style(); + var zoom = cy.zoom(); + var effectiveZoom = forcedZoom !== undefined ? forcedZoom : zoom; + var pan = cy.pan(); + var effectivePan = { + x: pan.x, + y: pan.y + }; + var vp = { + zoom: zoom, + pan: { + x: pan.x, + y: pan.y + } + }; + var prevVp = r.prevViewport; + var viewportIsDiff = prevVp === undefined || vp.zoom !== prevVp.zoom || vp.pan.x !== prevVp.pan.x || vp.pan.y !== prevVp.pan.y; + + // we want the low quality motionblur only when the viewport is being manipulated etc (where it's not noticed) + if (!viewportIsDiff && !(inNodeDragGesture && !hasCompoundNodes)) { + r.motionBlurPxRatio = 1; + } + if (forcedPan) { + effectivePan = forcedPan; + } + + // apply pixel ratio + + effectiveZoom *= pixelRatio; + effectivePan.x *= pixelRatio; + effectivePan.y *= pixelRatio; + var eles = r.getCachedZSortedEles(); + function mbclear(context, x, y, w, h) { + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + r.colorFillStyle(context, 255, 255, 255, r.motionBlurTransparency); + context.fillRect(x, y, w, h); + context.globalCompositeOperation = gco; + } + function setContextTransform(context, clear) { + var ePan, eZoom, w, h; + if (!r.clearingMotionBlur && (context === data.bufferContexts[r.MOTIONBLUR_BUFFER_NODE] || context === data.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG])) { + ePan = { + x: pan.x * mbPxRatio, + y: pan.y * mbPxRatio + }; + eZoom = zoom * mbPxRatio; + w = r.canvasWidth * mbPxRatio; + h = r.canvasHeight * mbPxRatio; + } else { + ePan = effectivePan; + eZoom = effectiveZoom; + w = r.canvasWidth; + h = r.canvasHeight; + } + context.setTransform(1, 0, 0, 1, 0, 0); + if (clear === 'motionBlur') { + mbclear(context, 0, 0, w, h); + } else if (!forcedContext && (clear === undefined || clear)) { + context.clearRect(0, 0, w, h); + } + if (!drawAllLayers) { + context.translate(ePan.x, ePan.y); + context.scale(eZoom, eZoom); + } + if (forcedPan) { + context.translate(forcedPan.x, forcedPan.y); + } + if (forcedZoom) { + context.scale(forcedZoom, forcedZoom); + } + } + if (!textureDraw) { + r.textureDrawLastFrame = false; + } + if (textureDraw) { + r.textureDrawLastFrame = true; + if (!r.textureCache) { + r.textureCache = {}; + r.textureCache.bb = cy.mutableElements().boundingBox(); + r.textureCache.texture = r.data.bufferCanvases[r.TEXTURE_BUFFER]; + var cxt = r.data.bufferContexts[r.TEXTURE_BUFFER]; + cxt.setTransform(1, 0, 0, 1, 0, 0); + cxt.clearRect(0, 0, r.canvasWidth * r.textureMult, r.canvasHeight * r.textureMult); + r.render({ + forcedContext: cxt, + drawOnlyNodeLayer: true, + forcedPxRatio: pixelRatio * r.textureMult + }); + var vp = r.textureCache.viewport = { + zoom: cy.zoom(), + pan: cy.pan(), + width: r.canvasWidth, + height: r.canvasHeight + }; + vp.mpan = { + x: (0 - vp.pan.x) / vp.zoom, + y: (0 - vp.pan.y) / vp.zoom + }; + } + needDraw[r.DRAG] = false; + needDraw[r.NODE] = false; + var context = data.contexts[r.NODE]; + var texture = r.textureCache.texture; + var vp = r.textureCache.viewport; + context.setTransform(1, 0, 0, 1, 0, 0); + if (motionBlur) { + mbclear(context, 0, 0, vp.width, vp.height); + } else { + context.clearRect(0, 0, vp.width, vp.height); + } + var outsideBgColor = style.core('outside-texture-bg-color').value; + var outsideBgOpacity = style.core('outside-texture-bg-opacity').value; + r.colorFillStyle(context, outsideBgColor[0], outsideBgColor[1], outsideBgColor[2], outsideBgOpacity); + context.fillRect(0, 0, vp.width, vp.height); + var zoom = cy.zoom(); + setContextTransform(context, false); + context.clearRect(vp.mpan.x, vp.mpan.y, vp.width / vp.zoom / pixelRatio, vp.height / vp.zoom / pixelRatio); + context.drawImage(texture, vp.mpan.x, vp.mpan.y, vp.width / vp.zoom / pixelRatio, vp.height / vp.zoom / pixelRatio); + } else if (r.textureOnViewport && !forcedContext) { + // clear the cache since we don't need it + r.textureCache = null; + } + var extent = cy.extent(); + var vpManip = r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming || r.hoverData.draggingEles || r.cy.animated(); + var hideEdges = r.hideEdgesOnViewport && vpManip; + var needMbClear = []; + needMbClear[r.NODE] = !needDraw[r.NODE] && motionBlur && !r.clearedForMotionBlur[r.NODE] || r.clearingMotionBlur; + if (needMbClear[r.NODE]) { + r.clearedForMotionBlur[r.NODE] = true; + } + needMbClear[r.DRAG] = !needDraw[r.DRAG] && motionBlur && !r.clearedForMotionBlur[r.DRAG] || r.clearingMotionBlur; + if (needMbClear[r.DRAG]) { + r.clearedForMotionBlur[r.DRAG] = true; + } + if (needDraw[r.NODE] || drawAllLayers || drawOnlyNodeLayer || needMbClear[r.NODE]) { + var useBuffer = motionBlur && !needMbClear[r.NODE] && mbPxRatio !== 1; + var context = forcedContext || (useBuffer ? r.data.bufferContexts[r.MOTIONBLUR_BUFFER_NODE] : data.contexts[r.NODE]); + var clear = motionBlur && !useBuffer ? 'motionBlur' : undefined; + setContextTransform(context, clear); + if (hideEdges) { + r.drawCachedNodes(context, eles.nondrag, pixelRatio, extent); + } else { + r.drawLayeredElements(context, eles.nondrag, pixelRatio, extent); + } + if (r.debug) { + r.drawDebugPoints(context, eles.nondrag); + } + if (!drawAllLayers && !motionBlur) { + needDraw[r.NODE] = false; + } + } + if (!drawOnlyNodeLayer && (needDraw[r.DRAG] || drawAllLayers || needMbClear[r.DRAG])) { + var useBuffer = motionBlur && !needMbClear[r.DRAG] && mbPxRatio !== 1; + var context = forcedContext || (useBuffer ? r.data.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG] : data.contexts[r.DRAG]); + setContextTransform(context, motionBlur && !useBuffer ? 'motionBlur' : undefined); + if (hideEdges) { + r.drawCachedNodes(context, eles.drag, pixelRatio, extent); + } else { + r.drawCachedElements(context, eles.drag, pixelRatio, extent); + } + if (r.debug) { + r.drawDebugPoints(context, eles.drag); + } + if (!drawAllLayers && !motionBlur) { + needDraw[r.DRAG] = false; + } + } + if (r.showFps || !drawOnlyNodeLayer && needDraw[r.SELECT_BOX] && !drawAllLayers) { + var context = forcedContext || data.contexts[r.SELECT_BOX]; + setContextTransform(context); + if (r.selection[4] == 1 && (r.hoverData.selecting || r.touchData.selecting)) { + var zoom = r.cy.zoom(); + var borderWidth = style.core('selection-box-border-width').value / zoom; + context.lineWidth = borderWidth; + context.fillStyle = 'rgba(' + style.core('selection-box-color').value[0] + ',' + style.core('selection-box-color').value[1] + ',' + style.core('selection-box-color').value[2] + ',' + style.core('selection-box-opacity').value + ')'; + context.fillRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]); + if (borderWidth > 0) { + context.strokeStyle = 'rgba(' + style.core('selection-box-border-color').value[0] + ',' + style.core('selection-box-border-color').value[1] + ',' + style.core('selection-box-border-color').value[2] + ',' + style.core('selection-box-opacity').value + ')'; + context.strokeRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]); + } + } + if (data.bgActivePosistion && !r.hoverData.selecting) { + var zoom = r.cy.zoom(); + var pos = data.bgActivePosistion; + context.fillStyle = 'rgba(' + style.core('active-bg-color').value[0] + ',' + style.core('active-bg-color').value[1] + ',' + style.core('active-bg-color').value[2] + ',' + style.core('active-bg-opacity').value + ')'; + context.beginPath(); + context.arc(pos.x, pos.y, style.core('active-bg-size').pfValue / zoom, 0, 2 * Math.PI); + context.fill(); + } + var timeToRender = r.lastRedrawTime; + if (r.showFps && timeToRender) { + timeToRender = Math.round(timeToRender); + var fps = Math.round(1000 / timeToRender); + context.setTransform(1, 0, 0, 1, 0, 0); + context.fillStyle = 'rgba(255, 0, 0, 0.75)'; + context.strokeStyle = 'rgba(255, 0, 0, 0.75)'; + context.lineWidth = 1; + context.fillText('1 frame = ' + timeToRender + ' ms = ' + fps + ' fps', 0, 20); + var maxFps = 60; + context.strokeRect(0, 30, 250, 20); + context.fillRect(0, 30, 250 * Math.min(fps / maxFps, 1), 20); + } + if (!drawAllLayers) { + needDraw[r.SELECT_BOX] = false; + } + } + + // motionblur: blit rendered blurry frames + if (motionBlur && mbPxRatio !== 1) { + var cxtNode = data.contexts[r.NODE]; + var txtNode = r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE]; + var cxtDrag = data.contexts[r.DRAG]; + var txtDrag = r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG]; + var drawMotionBlur = function drawMotionBlur(cxt, txt, needClear) { + cxt.setTransform(1, 0, 0, 1, 0, 0); + if (needClear || !motionBlurFadeEffect) { + cxt.clearRect(0, 0, r.canvasWidth, r.canvasHeight); + } else { + mbclear(cxt, 0, 0, r.canvasWidth, r.canvasHeight); + } + var pxr = mbPxRatio; + cxt.drawImage(txt, + // img + 0, 0, + // sx, sy + r.canvasWidth * pxr, r.canvasHeight * pxr, + // sw, sh + 0, 0, + // x, y + r.canvasWidth, r.canvasHeight // w, h + ); + }; + + if (needDraw[r.NODE] || needMbClear[r.NODE]) { + drawMotionBlur(cxtNode, txtNode, needMbClear[r.NODE]); + needDraw[r.NODE] = false; + } + if (needDraw[r.DRAG] || needMbClear[r.DRAG]) { + drawMotionBlur(cxtDrag, txtDrag, needMbClear[r.DRAG]); + needDraw[r.DRAG] = false; + } + } + r.prevViewport = vp; + if (r.clearingMotionBlur) { + r.clearingMotionBlur = false; + r.motionBlurCleared = true; + r.motionBlur = true; + } + if (motionBlur) { + r.motionBlurTimeout = setTimeout(function () { + r.motionBlurTimeout = null; + r.clearedForMotionBlur[r.NODE] = false; + r.clearedForMotionBlur[r.DRAG] = false; + r.motionBlur = false; + r.clearingMotionBlur = !textureDraw; + r.mbFrames = 0; + needDraw[r.NODE] = true; + needDraw[r.DRAG] = true; + r.redraw(); + }, motionBlurDelay); + } + if (!forcedContext) { + cy.emit('render'); + } +}; + +var CRp$3 = {}; + +// @O Polygon drawing +CRp$3.drawPolygonPath = function (context, x, y, width, height, points) { + var halfW = width / 2; + var halfH = height / 2; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(x + halfW * points[0], y + halfH * points[1]); + for (var i = 1; i < points.length / 2; i++) { + context.lineTo(x + halfW * points[i * 2], y + halfH * points[i * 2 + 1]); + } + context.closePath(); +}; +CRp$3.drawRoundPolygonPath = function (context, x, y, width, height, points, corners) { + corners.forEach(function (corner) { + return drawPreparedRoundCorner(context, corner); + }); + context.closePath(); +}; + +// Round rectangle drawing +CRp$3.drawRoundRectanglePath = function (context, x, y, width, height, radius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : Math.min(radius, halfHeight, halfWidth); + if (context.beginPath) { + context.beginPath(); + } + + // Start at top middle + context.moveTo(x, y - halfHeight); + // Arc from middle top to right side + context.arcTo(x + halfWidth, y - halfHeight, x + halfWidth, y, cornerRadius); + // Arc from right side to bottom + context.arcTo(x + halfWidth, y + halfHeight, x, y + halfHeight, cornerRadius); + // Arc from bottom to left side + context.arcTo(x - halfWidth, y + halfHeight, x - halfWidth, y, cornerRadius); + // Arc from left side to topBorder + context.arcTo(x - halfWidth, y - halfHeight, x, y - halfHeight, cornerRadius); + // Join line + context.lineTo(x, y - halfHeight); + context.closePath(); +}; +CRp$3.drawBottomRoundRectanglePath = function (context, x, y, width, height, radius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : radius; + if (context.beginPath) { + context.beginPath(); + } + + // Start at top middle + context.moveTo(x, y - halfHeight); + context.lineTo(x + halfWidth, y - halfHeight); + context.lineTo(x + halfWidth, y); + context.arcTo(x + halfWidth, y + halfHeight, x, y + halfHeight, cornerRadius); + context.arcTo(x - halfWidth, y + halfHeight, x - halfWidth, y, cornerRadius); + context.lineTo(x - halfWidth, y - halfHeight); + context.lineTo(x, y - halfHeight); + context.closePath(); +}; +CRp$3.drawCutRectanglePath = function (context, x, y, width, height, points, corners) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerLength = corners === 'auto' ? getCutRectangleCornerLength() : corners; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(x - halfWidth + cornerLength, y - halfHeight); + context.lineTo(x + halfWidth - cornerLength, y - halfHeight); + context.lineTo(x + halfWidth, y - halfHeight + cornerLength); + context.lineTo(x + halfWidth, y + halfHeight - cornerLength); + context.lineTo(x + halfWidth - cornerLength, y + halfHeight); + context.lineTo(x - halfWidth + cornerLength, y + halfHeight); + context.lineTo(x - halfWidth, y + halfHeight - cornerLength); + context.lineTo(x - halfWidth, y - halfHeight + cornerLength); + context.closePath(); +}; +CRp$3.drawBarrelPath = function (context, x, y, width, height) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var xBegin = x - halfWidth; + var xEnd = x + halfWidth; + var yBegin = y - halfHeight; + var yEnd = y + halfHeight; + var barrelCurveConstants = getBarrelCurveConstants(width, height); + var wOffset = barrelCurveConstants.widthOffset; + var hOffset = barrelCurveConstants.heightOffset; + var ctrlPtXOffset = barrelCurveConstants.ctrlPtOffsetPct * wOffset; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(xBegin, yBegin + hOffset); + context.lineTo(xBegin, yEnd - hOffset); + context.quadraticCurveTo(xBegin + ctrlPtXOffset, yEnd, xBegin + wOffset, yEnd); + context.lineTo(xEnd - wOffset, yEnd); + context.quadraticCurveTo(xEnd - ctrlPtXOffset, yEnd, xEnd, yEnd - hOffset); + context.lineTo(xEnd, yBegin + hOffset); + context.quadraticCurveTo(xEnd - ctrlPtXOffset, yBegin, xEnd - wOffset, yBegin); + context.lineTo(xBegin + wOffset, yBegin); + context.quadraticCurveTo(xBegin + ctrlPtXOffset, yBegin, xBegin, yBegin + hOffset); + context.closePath(); +}; +var sin0 = Math.sin(0); +var cos0 = Math.cos(0); +var sin = {}; +var cos = {}; +var ellipseStepSize = Math.PI / 40; +for (var i = 0 * Math.PI; i < 2 * Math.PI; i += ellipseStepSize) { + sin[i] = Math.sin(i); + cos[i] = Math.cos(i); +} +CRp$3.drawEllipsePath = function (context, centerX, centerY, width, height) { + if (context.beginPath) { + context.beginPath(); + } + if (context.ellipse) { + context.ellipse(centerX, centerY, width / 2, height / 2, 0, 0, 2 * Math.PI); + } else { + var xPos, yPos; + var rw = width / 2; + var rh = height / 2; + for (var i = 0 * Math.PI; i < 2 * Math.PI; i += ellipseStepSize) { + xPos = centerX - rw * sin[i] * sin0 + rw * cos[i] * cos0; + yPos = centerY + rh * cos[i] * sin0 + rh * sin[i] * cos0; + if (i === 0) { + context.moveTo(xPos, yPos); + } else { + context.lineTo(xPos, yPos); + } + } + } + context.closePath(); +}; + +/* global atob, ArrayBuffer, Uint8Array, Blob */ +var CRp$2 = {}; +CRp$2.createBuffer = function (w, h) { + var buffer = document.createElement('canvas'); // eslint-disable-line no-undef + buffer.width = w; + buffer.height = h; + return [buffer, buffer.getContext('2d')]; +}; +CRp$2.bufferCanvasImage = function (options) { + var cy = this.cy; + var eles = cy.mutableElements(); + var bb = eles.boundingBox(); + var ctrRect = this.findContainerClientCoords(); + var width = options.full ? Math.ceil(bb.w) : ctrRect[2]; + var height = options.full ? Math.ceil(bb.h) : ctrRect[3]; + var specdMaxDims = number$1(options.maxWidth) || number$1(options.maxHeight); + var pxRatio = this.getPixelRatio(); + var scale = 1; + if (options.scale !== undefined) { + width *= options.scale; + height *= options.scale; + scale = options.scale; + } else if (specdMaxDims) { + var maxScaleW = Infinity; + var maxScaleH = Infinity; + if (number$1(options.maxWidth)) { + maxScaleW = scale * options.maxWidth / width; + } + if (number$1(options.maxHeight)) { + maxScaleH = scale * options.maxHeight / height; + } + scale = Math.min(maxScaleW, maxScaleH); + width *= scale; + height *= scale; + } + if (!specdMaxDims) { + width *= pxRatio; + height *= pxRatio; + scale *= pxRatio; + } + var buffCanvas = document.createElement('canvas'); // eslint-disable-line no-undef + + buffCanvas.width = width; + buffCanvas.height = height; + buffCanvas.style.width = width + 'px'; + buffCanvas.style.height = height + 'px'; + var buffCxt = buffCanvas.getContext('2d'); + + // Rasterize the layers, but only if container has nonzero size + if (width > 0 && height > 0) { + buffCxt.clearRect(0, 0, width, height); + buffCxt.globalCompositeOperation = 'source-over'; + var zsortedEles = this.getCachedZSortedEles(); + if (options.full) { + // draw the full bounds of the graph + buffCxt.translate(-bb.x1 * scale, -bb.y1 * scale); + buffCxt.scale(scale, scale); + this.drawElements(buffCxt, zsortedEles); + buffCxt.scale(1 / scale, 1 / scale); + buffCxt.translate(bb.x1 * scale, bb.y1 * scale); + } else { + // draw the current view + var pan = cy.pan(); + var translation = { + x: pan.x * scale, + y: pan.y * scale + }; + scale *= cy.zoom(); + buffCxt.translate(translation.x, translation.y); + buffCxt.scale(scale, scale); + this.drawElements(buffCxt, zsortedEles); + buffCxt.scale(1 / scale, 1 / scale); + buffCxt.translate(-translation.x, -translation.y); + } + + // need to fill bg at end like this in order to fill cleared transparent pixels in jpgs + if (options.bg) { + buffCxt.globalCompositeOperation = 'destination-over'; + buffCxt.fillStyle = options.bg; + buffCxt.rect(0, 0, width, height); + buffCxt.fill(); + } + } + return buffCanvas; +}; +function b64ToBlob(b64, mimeType) { + var bytes = atob(b64); + var buff = new ArrayBuffer(bytes.length); + var buffUint8 = new Uint8Array(buff); + for (var i = 0; i < bytes.length; i++) { + buffUint8[i] = bytes.charCodeAt(i); + } + return new Blob([buff], { + type: mimeType + }); +} +function b64UriToB64(b64uri) { + var i = b64uri.indexOf(','); + return b64uri.substr(i + 1); +} +function output(options, canvas, mimeType) { + var getB64Uri = function getB64Uri() { + return canvas.toDataURL(mimeType, options.quality); + }; + switch (options.output) { + case 'blob-promise': + return new Promise$1(function (resolve, reject) { + try { + canvas.toBlob(function (blob) { + if (blob != null) { + resolve(blob); + } else { + reject(new Error('`canvas.toBlob()` sent a null value in its callback')); + } + }, mimeType, options.quality); + } catch (err) { + reject(err); + } + }); + case 'blob': + return b64ToBlob(b64UriToB64(getB64Uri()), mimeType); + case 'base64': + return b64UriToB64(getB64Uri()); + case 'base64uri': + default: + return getB64Uri(); + } +} +CRp$2.png = function (options) { + return output(options, this.bufferCanvasImage(options), 'image/png'); +}; +CRp$2.jpg = function (options) { + return output(options, this.bufferCanvasImage(options), 'image/jpeg'); +}; + +var CRp$1 = {}; +CRp$1.nodeShapeImpl = function (name, context, centerX, centerY, width, height, points, corners) { + switch (name) { + case 'ellipse': + return this.drawEllipsePath(context, centerX, centerY, width, height); + case 'polygon': + return this.drawPolygonPath(context, centerX, centerY, width, height, points); + case 'round-polygon': + return this.drawRoundPolygonPath(context, centerX, centerY, width, height, points, corners); + case 'roundrectangle': + case 'round-rectangle': + return this.drawRoundRectanglePath(context, centerX, centerY, width, height, corners); + case 'cutrectangle': + case 'cut-rectangle': + return this.drawCutRectanglePath(context, centerX, centerY, width, height, points, corners); + case 'bottomroundrectangle': + case 'bottom-round-rectangle': + return this.drawBottomRoundRectanglePath(context, centerX, centerY, width, height, corners); + case 'barrel': + return this.drawBarrelPath(context, centerX, centerY, width, height); + } +}; + +var CR = CanvasRenderer; +var CRp = CanvasRenderer.prototype; +CRp.CANVAS_LAYERS = 3; +// +CRp.SELECT_BOX = 0; +CRp.DRAG = 1; +CRp.NODE = 2; +CRp.BUFFER_COUNT = 3; +// +CRp.TEXTURE_BUFFER = 0; +CRp.MOTIONBLUR_BUFFER_NODE = 1; +CRp.MOTIONBLUR_BUFFER_DRAG = 2; +function CanvasRenderer(options) { + var r = this; + r.data = { + canvases: new Array(CRp.CANVAS_LAYERS), + contexts: new Array(CRp.CANVAS_LAYERS), + canvasNeedsRedraw: new Array(CRp.CANVAS_LAYERS), + bufferCanvases: new Array(CRp.BUFFER_COUNT), + bufferContexts: new Array(CRp.CANVAS_LAYERS) + }; + var tapHlOffAttr = '-webkit-tap-highlight-color'; + var tapHlOffStyle = 'rgba(0,0,0,0)'; + r.data.canvasContainer = document.createElement('div'); // eslint-disable-line no-undef + var containerStyle = r.data.canvasContainer.style; + r.data.canvasContainer.style[tapHlOffAttr] = tapHlOffStyle; + containerStyle.position = 'relative'; + containerStyle.zIndex = '0'; + containerStyle.overflow = 'hidden'; + var container = options.cy.container(); + container.appendChild(r.data.canvasContainer); + container.style[tapHlOffAttr] = tapHlOffStyle; + var styleMap = { + '-webkit-user-select': 'none', + '-moz-user-select': '-moz-none', + 'user-select': 'none', + '-webkit-tap-highlight-color': 'rgba(0,0,0,0)', + 'outline-style': 'none' + }; + if (ms()) { + styleMap['-ms-touch-action'] = 'none'; + styleMap['touch-action'] = 'none'; + } + for (var i = 0; i < CRp.CANVAS_LAYERS; i++) { + var canvas = r.data.canvases[i] = document.createElement('canvas'); // eslint-disable-line no-undef + r.data.contexts[i] = canvas.getContext('2d'); + Object.keys(styleMap).forEach(function (k) { + canvas.style[k] = styleMap[k]; + }); + canvas.style.position = 'absolute'; + canvas.setAttribute('data-id', 'layer' + i); + canvas.style.zIndex = String(CRp.CANVAS_LAYERS - i); + r.data.canvasContainer.appendChild(canvas); + r.data.canvasNeedsRedraw[i] = false; + } + r.data.topCanvas = r.data.canvases[0]; + r.data.canvases[CRp.NODE].setAttribute('data-id', 'layer' + CRp.NODE + '-node'); + r.data.canvases[CRp.SELECT_BOX].setAttribute('data-id', 'layer' + CRp.SELECT_BOX + '-selectbox'); + r.data.canvases[CRp.DRAG].setAttribute('data-id', 'layer' + CRp.DRAG + '-drag'); + for (var i = 0; i < CRp.BUFFER_COUNT; i++) { + r.data.bufferCanvases[i] = document.createElement('canvas'); // eslint-disable-line no-undef + r.data.bufferContexts[i] = r.data.bufferCanvases[i].getContext('2d'); + r.data.bufferCanvases[i].style.position = 'absolute'; + r.data.bufferCanvases[i].setAttribute('data-id', 'buffer' + i); + r.data.bufferCanvases[i].style.zIndex = String(-i - 1); + r.data.bufferCanvases[i].style.visibility = 'hidden'; + //r.data.canvasContainer.appendChild(r.data.bufferCanvases[i]); + } + + r.pathsEnabled = true; + var emptyBb = makeBoundingBox(); + var getBoxCenter = function getBoxCenter(bb) { + return { + x: (bb.x1 + bb.x2) / 2, + y: (bb.y1 + bb.y2) / 2 + }; + }; + var getCenterOffset = function getCenterOffset(bb) { + return { + x: -bb.w / 2, + y: -bb.h / 2 + }; + }; + var backgroundTimestampHasChanged = function backgroundTimestampHasChanged(ele) { + var _p = ele[0]._private; + var same = _p.oldBackgroundTimestamp === _p.backgroundTimestamp; + return !same; + }; + var getStyleKey = function getStyleKey(ele) { + return ele[0]._private.nodeKey; + }; + var getLabelKey = function getLabelKey(ele) { + return ele[0]._private.labelStyleKey; + }; + var getSourceLabelKey = function getSourceLabelKey(ele) { + return ele[0]._private.sourceLabelStyleKey; + }; + var getTargetLabelKey = function getTargetLabelKey(ele) { + return ele[0]._private.targetLabelStyleKey; + }; + var drawElement = function drawElement(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElement(context, ele, bb, false, false, useEleOpacity); + }; + var drawLabel = function drawLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'main', useEleOpacity); + }; + var drawSourceLabel = function drawSourceLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'source', useEleOpacity); + }; + var drawTargetLabel = function drawTargetLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'target', useEleOpacity); + }; + var getElementBox = function getElementBox(ele) { + ele.boundingBox(); + return ele[0]._private.bodyBounds; + }; + var getLabelBox = function getLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.main || emptyBb; + }; + var getSourceLabelBox = function getSourceLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.source || emptyBb; + }; + var getTargetLabelBox = function getTargetLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.target || emptyBb; + }; + var isLabelVisibleAtScale = function isLabelVisibleAtScale(ele, scaledLabelShown) { + return scaledLabelShown; + }; + var getElementRotationPoint = function getElementRotationPoint(ele) { + return getBoxCenter(getElementBox(ele)); + }; + var addTextMargin = function addTextMargin(prefix, pt, ele) { + var pre = prefix ? prefix + '-' : ''; + return { + x: pt.x + ele.pstyle(pre + 'text-margin-x').pfValue, + y: pt.y + ele.pstyle(pre + 'text-margin-y').pfValue + }; + }; + var getRsPt = function getRsPt(ele, x, y) { + var rs = ele[0]._private.rscratch; + return { + x: rs[x], + y: rs[y] + }; + }; + var getLabelRotationPoint = function getLabelRotationPoint(ele) { + return addTextMargin('', getRsPt(ele, 'labelX', 'labelY'), ele); + }; + var getSourceLabelRotationPoint = function getSourceLabelRotationPoint(ele) { + return addTextMargin('source', getRsPt(ele, 'sourceLabelX', 'sourceLabelY'), ele); + }; + var getTargetLabelRotationPoint = function getTargetLabelRotationPoint(ele) { + return addTextMargin('target', getRsPt(ele, 'targetLabelX', 'targetLabelY'), ele); + }; + var getElementRotationOffset = function getElementRotationOffset(ele) { + return getCenterOffset(getElementBox(ele)); + }; + var getSourceLabelRotationOffset = function getSourceLabelRotationOffset(ele) { + return getCenterOffset(getSourceLabelBox(ele)); + }; + var getTargetLabelRotationOffset = function getTargetLabelRotationOffset(ele) { + return getCenterOffset(getTargetLabelBox(ele)); + }; + var getLabelRotationOffset = function getLabelRotationOffset(ele) { + var bb = getLabelBox(ele); + var p = getCenterOffset(getLabelBox(ele)); + if (ele.isNode()) { + switch (ele.pstyle('text-halign').value) { + case 'left': + p.x = -bb.w; + break; + case 'right': + p.x = 0; + break; + } + switch (ele.pstyle('text-valign').value) { + case 'top': + p.y = -bb.h; + break; + case 'bottom': + p.y = 0; + break; + } + } + return p; + }; + var eleTxrCache = r.data.eleTxrCache = new ElementTextureCache(r, { + getKey: getStyleKey, + doesEleInvalidateKey: backgroundTimestampHasChanged, + drawElement: drawElement, + getBoundingBox: getElementBox, + getRotationPoint: getElementRotationPoint, + getRotationOffset: getElementRotationOffset, + allowEdgeTxrCaching: false, + allowParentTxrCaching: false + }); + var lblTxrCache = r.data.lblTxrCache = new ElementTextureCache(r, { + getKey: getLabelKey, + drawElement: drawLabel, + getBoundingBox: getLabelBox, + getRotationPoint: getLabelRotationPoint, + getRotationOffset: getLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var slbTxrCache = r.data.slbTxrCache = new ElementTextureCache(r, { + getKey: getSourceLabelKey, + drawElement: drawSourceLabel, + getBoundingBox: getSourceLabelBox, + getRotationPoint: getSourceLabelRotationPoint, + getRotationOffset: getSourceLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var tlbTxrCache = r.data.tlbTxrCache = new ElementTextureCache(r, { + getKey: getTargetLabelKey, + drawElement: drawTargetLabel, + getBoundingBox: getTargetLabelBox, + getRotationPoint: getTargetLabelRotationPoint, + getRotationOffset: getTargetLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var lyrTxrCache = r.data.lyrTxrCache = new LayeredTextureCache(r); + r.onUpdateEleCalcs(function invalidateTextureCaches(willDraw, eles) { + // each cache should check for sub-key diff to see that the update affects that cache particularly + eleTxrCache.invalidateElements(eles); + lblTxrCache.invalidateElements(eles); + slbTxrCache.invalidateElements(eles); + tlbTxrCache.invalidateElements(eles); + + // any change invalidates the layers + lyrTxrCache.invalidateElements(eles); + + // update the old bg timestamp so diffs can be done in the ele txr caches + for (var _i = 0; _i < eles.length; _i++) { + var _p = eles[_i]._private; + _p.oldBackgroundTimestamp = _p.backgroundTimestamp; + } + }); + var refineInLayers = function refineInLayers(reqs) { + for (var i = 0; i < reqs.length; i++) { + lyrTxrCache.enqueueElementRefinement(reqs[i].ele); + } + }; + eleTxrCache.onDequeue(refineInLayers); + lblTxrCache.onDequeue(refineInLayers); + slbTxrCache.onDequeue(refineInLayers); + tlbTxrCache.onDequeue(refineInLayers); +} +CRp.redrawHint = function (group, bool) { + var r = this; + switch (group) { + case 'eles': + r.data.canvasNeedsRedraw[CRp.NODE] = bool; + break; + case 'drag': + r.data.canvasNeedsRedraw[CRp.DRAG] = bool; + break; + case 'select': + r.data.canvasNeedsRedraw[CRp.SELECT_BOX] = bool; + break; + } +}; + +// whether to use Path2D caching for drawing +var pathsImpld = typeof Path2D !== 'undefined'; +CRp.path2dEnabled = function (on) { + if (on === undefined) { + return this.pathsEnabled; + } + this.pathsEnabled = on ? true : false; +}; +CRp.usePaths = function () { + return pathsImpld && this.pathsEnabled; +}; +CRp.setImgSmoothing = function (context, bool) { + if (context.imageSmoothingEnabled != null) { + context.imageSmoothingEnabled = bool; + } else { + context.webkitImageSmoothingEnabled = bool; + context.mozImageSmoothingEnabled = bool; + context.msImageSmoothingEnabled = bool; + } +}; +CRp.getImgSmoothing = function (context) { + if (context.imageSmoothingEnabled != null) { + return context.imageSmoothingEnabled; + } else { + return context.webkitImageSmoothingEnabled || context.mozImageSmoothingEnabled || context.msImageSmoothingEnabled; + } +}; +CRp.makeOffscreenCanvas = function (width, height) { + var canvas; + if ((typeof OffscreenCanvas === "undefined" ? "undefined" : _typeof(OffscreenCanvas)) !== ("undefined" )) { + canvas = new OffscreenCanvas(width, height); + } else { + canvas = document.createElement('canvas'); // eslint-disable-line no-undef + canvas.width = width; + canvas.height = height; + } + return canvas; +}; +[CRp$a, CRp$9, CRp$8, CRp$7, CRp$6, CRp$5, CRp$4, CRp$3, CRp$2, CRp$1].forEach(function (props) { + extend(CRp, props); +}); + +var renderer$3 = [{ + name: 'null', + impl: NullRenderer +}, { + name: 'base', + impl: BR +}, { + name: 'canvas', + impl: CR +}]; + +var incExts = [{ + type: 'layout', + extensions: layout$1 +}, { + type: 'renderer', + extensions: renderer$3 +}]; + +// registered extensions to cytoscape, indexed by name +var extensions = {}; + +// registered modules for extensions, indexed by name +var modules = {}; +function setExtension(type, name, registrant) { + var ext = registrant; + var overrideErr = function overrideErr(field) { + warn('Can not register `' + name + '` for `' + type + '` since `' + field + '` already exists in the prototype and can not be overridden'); + }; + if (type === 'core') { + if (Core.prototype[name]) { + return overrideErr(name); + } else { + Core.prototype[name] = registrant; + } + } else if (type === 'collection') { + if (Collection.prototype[name]) { + return overrideErr(name); + } else { + Collection.prototype[name] = registrant; + } + } else if (type === 'layout') { + // fill in missing layout functions in the prototype + + var Layout = function Layout(options) { + this.options = options; + registrant.call(this, options); + + // make sure layout has _private for use w/ std apis like .on() + if (!plainObject(this._private)) { + this._private = {}; + } + this._private.cy = options.cy; + this._private.listeners = []; + this.createEmitter(); + }; + var layoutProto = Layout.prototype = Object.create(registrant.prototype); + var optLayoutFns = []; + for (var i = 0; i < optLayoutFns.length; i++) { + var fnName = optLayoutFns[i]; + layoutProto[fnName] = layoutProto[fnName] || function () { + return this; + }; + } + + // either .start() or .run() is defined, so autogen the other + if (layoutProto.start && !layoutProto.run) { + layoutProto.run = function () { + this.start(); + return this; + }; + } else if (!layoutProto.start && layoutProto.run) { + layoutProto.start = function () { + this.run(); + return this; + }; + } + var regStop = registrant.prototype.stop; + layoutProto.stop = function () { + var opts = this.options; + if (opts && opts.animate) { + var anis = this.animations; + if (anis) { + for (var _i = 0; _i < anis.length; _i++) { + anis[_i].stop(); + } + } + } + if (regStop) { + regStop.call(this); + } else { + this.emit('layoutstop'); + } + return this; + }; + if (!layoutProto.destroy) { + layoutProto.destroy = function () { + return this; + }; + } + layoutProto.cy = function () { + return this._private.cy; + }; + var getCy = function getCy(layout) { + return layout._private.cy; + }; + var emitterOpts = { + addEventFields: function addEventFields(layout, evt) { + evt.layout = layout; + evt.cy = getCy(layout); + evt.target = layout; + }, + bubble: function bubble() { + return true; + }, + parent: function parent(layout) { + return getCy(layout); + } + }; + extend(layoutProto, { + createEmitter: function createEmitter() { + this._private.emitter = new Emitter(emitterOpts, this); + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(evt, cb) { + this.emitter().on(evt, cb); + return this; + }, + one: function one(evt, cb) { + this.emitter().one(evt, cb); + return this; + }, + once: function once(evt, cb) { + this.emitter().one(evt, cb); + return this; + }, + removeListener: function removeListener(evt, cb) { + this.emitter().removeListener(evt, cb); + return this; + }, + removeAllListeners: function removeAllListeners() { + this.emitter().removeAllListeners(); + return this; + }, + emit: function emit(evt, params) { + this.emitter().emit(evt, params); + return this; + } + }); + define.eventAliasesOn(layoutProto); + ext = Layout; // replace with our wrapped layout + } else if (type === 'renderer' && name !== 'null' && name !== 'base') { + // user registered renderers inherit from base + + var BaseRenderer = getExtension('renderer', 'base'); + var bProto = BaseRenderer.prototype; + var RegistrantRenderer = registrant; + var rProto = registrant.prototype; + var Renderer = function Renderer() { + BaseRenderer.apply(this, arguments); + RegistrantRenderer.apply(this, arguments); + }; + var proto = Renderer.prototype; + for (var pName in bProto) { + var pVal = bProto[pName]; + var existsInR = rProto[pName] != null; + if (existsInR) { + return overrideErr(pName); + } + proto[pName] = pVal; // take impl from base + } + + for (var _pName in rProto) { + proto[_pName] = rProto[_pName]; // take impl from registrant + } + + bProto.clientFunctions.forEach(function (name) { + proto[name] = proto[name] || function () { + error('Renderer does not implement `renderer.' + name + '()` on its prototype'); + }; + }); + ext = Renderer; + } else if (type === '__proto__' || type === 'constructor' || type === 'prototype') { + // to avoid potential prototype pollution + return error(type + ' is an illegal type to be registered, possibly lead to prototype pollutions'); + } + return setMap({ + map: extensions, + keys: [type, name], + value: ext + }); +} +function getExtension(type, name) { + return getMap({ + map: extensions, + keys: [type, name] + }); +} +function setModule(type, name, moduleType, moduleName, registrant) { + return setMap({ + map: modules, + keys: [type, name, moduleType, moduleName], + value: registrant + }); +} +function getModule(type, name, moduleType, moduleName) { + return getMap({ + map: modules, + keys: [type, name, moduleType, moduleName] + }); +} +var extension = function extension() { + // e.g. extension('renderer', 'svg') + if (arguments.length === 2) { + return getExtension.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', { ... }) + else if (arguments.length === 3) { + return setExtension.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', 'nodeShape', 'ellipse') + else if (arguments.length === 4) { + return getModule.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', 'nodeShape', 'ellipse', { ... }) + else if (arguments.length === 5) { + return setModule.apply(null, arguments); + } else { + error('Invalid extension access syntax'); + } +}; + +// allows a core instance to access extensions internally +Core.prototype.extension = extension; + +// included extensions +incExts.forEach(function (group) { + group.extensions.forEach(function (ext) { + setExtension(group.type, ext.name, ext.impl); + }); +}); + +// a dummy stylesheet object that doesn't need a reference to the core +// (useful for init) +var Stylesheet = function Stylesheet() { + if (!(this instanceof Stylesheet)) { + return new Stylesheet(); + } + this.length = 0; +}; +var sheetfn = Stylesheet.prototype; +sheetfn.instanceString = function () { + return 'stylesheet'; +}; + +// just store the selector to be parsed later +sheetfn.selector = function (selector) { + var i = this.length++; + this[i] = { + selector: selector, + properties: [] + }; + return this; // chaining +}; + +// just store the property to be parsed later +sheetfn.css = function (name, value) { + var i = this.length - 1; + if (string(name)) { + this[i].properties.push({ + name: name, + value: value + }); + } else if (plainObject(name)) { + var map = name; + var propNames = Object.keys(map); + for (var j = 0; j < propNames.length; j++) { + var key = propNames[j]; + var mapVal = map[key]; + if (mapVal == null) { + continue; + } + var prop = Style.properties[key] || Style.properties[dash2camel(key)]; + if (prop == null) { + continue; + } + var _name = prop.name; + var _value = mapVal; + this[i].properties.push({ + name: _name, + value: _value + }); + } + } + return this; // chaining +}; + +sheetfn.style = sheetfn.css; + +// generate a real style object from the dummy stylesheet +sheetfn.generateStyle = function (cy) { + var style = new Style(cy); + return this.appendToStyle(style); +}; + +// append a dummy stylesheet object on a real style object +sheetfn.appendToStyle = function (style) { + for (var i = 0; i < this.length; i++) { + var context = this[i]; + var selector = context.selector; + var props = context.properties; + style.selector(selector); // apply selector + + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + style.css(prop.name, prop.value); // apply property + } + } + + return style; +}; + +var version = "3.29.2"; + +var cytoscape$1 = function cytoscape(options) { + // if no options specified, use default + if (options === undefined) { + options = {}; + } + + // create instance + if (plainObject(options)) { + return new Core(options); + } + + // allow for registration of extensions + else if (string(options)) { + return extension.apply(extension, arguments); + } +}; + +// e.g. cytoscape.use( require('cytoscape-foo'), bar ) +cytoscape$1.use = function (ext) { + var args = Array.prototype.slice.call(arguments, 1); // args to pass to ext + + args.unshift(cytoscape$1); // cytoscape is first arg to ext + + ext.apply(null, args); + return this; +}; +cytoscape$1.warnings = function (bool) { + return warnings(bool); +}; + +// replaced by build system +cytoscape$1.version = version; + +// expose public apis (mostly for extensions) +cytoscape$1.stylesheet = cytoscape$1.Stylesheet = Stylesheet; + +var cytoscapeCoseBilkent = {exports: {}}; + +var coseBase = {exports: {}}; + +var layoutBase = {exports: {}}; + +var hasRequiredLayoutBase; + +function requireLayoutBase () { + if (hasRequiredLayoutBase) return layoutBase.exports; + hasRequiredLayoutBase = 1; + (function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(); + })(commonjsGlobal$1, function() { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 26); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports, __webpack_require__) { + + + function LayoutConstants() {} + + /** + * Layout Quality: 0:draft, 1:default, 2:proof + */ + LayoutConstants.QUALITY = 1; + + /** + * Default parameters + */ + LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; + LayoutConstants.DEFAULT_INCREMENTAL = false; + LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; + LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; + LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; + LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; + + // ----------------------------------------------------------------------------- + // Section: General other constants + // ----------------------------------------------------------------------------- + /* + * Margins of a graph to be applied on bouding rectangle of its contents. We + * assume margins on all four sides to be uniform. + */ + LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; + + /* + * Whether to consider labels in node dimensions or not + */ + LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; + + /* + * Default dimension of a non-compound node. + */ + LayoutConstants.SIMPLE_NODE_SIZE = 40; + + /* + * Default dimension of a non-compound node. + */ + LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; + + /* + * Empty compound node size. When a compound node is empty, its both + * dimensions should be of this value. + */ + LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; + + /* + * Minimum length that an edge should take during layout + */ + LayoutConstants.MIN_EDGE_LENGTH = 1; + + /* + * World boundaries that layout operates on + */ + LayoutConstants.WORLD_BOUNDARY = 1000000; + + /* + * World boundaries that random positioning can be performed with + */ + LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000; + + /* + * Coordinates of the world center + */ + LayoutConstants.WORLD_CENTER_X = 1200; + LayoutConstants.WORLD_CENTER_Y = 900; + + module.exports = LayoutConstants; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var IGeometry = __webpack_require__(8); + var IMath = __webpack_require__(9); + + function LEdge(source, target, vEdge) { + LGraphObject.call(this, vEdge); + + this.isOverlapingSourceAndTarget = false; + this.vGraphObject = vEdge; + this.bendpoints = []; + this.source = source; + this.target = target; + } + + LEdge.prototype = Object.create(LGraphObject.prototype); + + for (var prop in LGraphObject) { + LEdge[prop] = LGraphObject[prop]; + } + + LEdge.prototype.getSource = function () { + return this.source; + }; + + LEdge.prototype.getTarget = function () { + return this.target; + }; + + LEdge.prototype.isInterGraph = function () { + return this.isInterGraph; + }; + + LEdge.prototype.getLength = function () { + return this.length; + }; + + LEdge.prototype.isOverlapingSourceAndTarget = function () { + return this.isOverlapingSourceAndTarget; + }; + + LEdge.prototype.getBendpoints = function () { + return this.bendpoints; + }; + + LEdge.prototype.getLca = function () { + return this.lca; + }; + + LEdge.prototype.getSourceInLca = function () { + return this.sourceInLca; + }; + + LEdge.prototype.getTargetInLca = function () { + return this.targetInLca; + }; + + LEdge.prototype.getOtherEnd = function (node) { + if (this.source === node) { + return this.target; + } else if (this.target === node) { + return this.source; + } else { + throw "Node is not incident with this edge"; + } + }; + + LEdge.prototype.getOtherEndInGraph = function (node, graph) { + var otherEnd = this.getOtherEnd(node); + var root = graph.getGraphManager().getRoot(); + + while (true) { + if (otherEnd.getOwner() == graph) { + return otherEnd; + } + + if (otherEnd.getOwner() == root) { + break; + } + + otherEnd = otherEnd.getOwner().getParent(); + } + + return null; + }; + + LEdge.prototype.updateLength = function () { + var clipPointCoordinates = new Array(4); + + this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates); + + if (!this.isOverlapingSourceAndTarget) { + this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; + this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + } + }; + + LEdge.prototype.updateLengthSimple = function () { + this.lengthX = this.target.getCenterX() - this.source.getCenterX(); + this.lengthY = this.target.getCenterY() - this.source.getCenterY(); + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + }; + + module.exports = LEdge; + + /***/ }), + /* 2 */ + /***/ (function(module, exports, __webpack_require__) { + + + function LGraphObject(vGraphObject) { + this.vGraphObject = vGraphObject; + } + + module.exports = LGraphObject; + + /***/ }), + /* 3 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var Integer = __webpack_require__(10); + var RectangleD = __webpack_require__(13); + var LayoutConstants = __webpack_require__(0); + var RandomSeed = __webpack_require__(16); + var PointD = __webpack_require__(4); + + function LNode(gm, loc, size, vNode) { + //Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode) + if (size == null && vNode == null) { + vNode = loc; + } + + LGraphObject.call(this, vNode); + + //Alternative constructor 2 : LNode(Layout layout, Object vNode) + if (gm.graphManager != null) gm = gm.graphManager; + + this.estimatedSize = Integer.MIN_VALUE; + this.inclusionTreeDepth = Integer.MAX_VALUE; + this.vGraphObject = vNode; + this.edges = []; + this.graphManager = gm; + + if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);else this.rect = new RectangleD(); + } + + LNode.prototype = Object.create(LGraphObject.prototype); + for (var prop in LGraphObject) { + LNode[prop] = LGraphObject[prop]; + } + + LNode.prototype.getEdges = function () { + return this.edges; + }; + + LNode.prototype.getChild = function () { + return this.child; + }; + + LNode.prototype.getOwner = function () { + // if (this.owner != null) { + // if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) { + // throw "assert failed"; + // } + // } + + return this.owner; + }; + + LNode.prototype.getWidth = function () { + return this.rect.width; + }; + + LNode.prototype.setWidth = function (width) { + this.rect.width = width; + }; + + LNode.prototype.getHeight = function () { + return this.rect.height; + }; + + LNode.prototype.setHeight = function (height) { + this.rect.height = height; + }; + + LNode.prototype.getCenterX = function () { + return this.rect.x + this.rect.width / 2; + }; + + LNode.prototype.getCenterY = function () { + return this.rect.y + this.rect.height / 2; + }; + + LNode.prototype.getCenter = function () { + return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2); + }; + + LNode.prototype.getLocation = function () { + return new PointD(this.rect.x, this.rect.y); + }; + + LNode.prototype.getRect = function () { + return this.rect; + }; + + LNode.prototype.getDiagonal = function () { + return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height); + }; + + /** + * This method returns half the diagonal length of this node. + */ + LNode.prototype.getHalfTheDiagonal = function () { + return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2; + }; + + LNode.prototype.setRect = function (upperLeft, dimension) { + this.rect.x = upperLeft.x; + this.rect.y = upperLeft.y; + this.rect.width = dimension.width; + this.rect.height = dimension.height; + }; + + LNode.prototype.setCenter = function (cx, cy) { + this.rect.x = cx - this.rect.width / 2; + this.rect.y = cy - this.rect.height / 2; + }; + + LNode.prototype.setLocation = function (x, y) { + this.rect.x = x; + this.rect.y = y; + }; + + LNode.prototype.moveBy = function (dx, dy) { + this.rect.x += dx; + this.rect.y += dy; + }; + + LNode.prototype.getEdgeListToNode = function (to) { + var edgeList = []; + var self = this; + + self.edges.forEach(function (edge) { + + if (edge.target == to) { + if (edge.source != self) throw "Incorrect edge source!"; + + edgeList.push(edge); + } + }); + + return edgeList; + }; + + LNode.prototype.getEdgesBetween = function (other) { + var edgeList = []; + + var self = this; + self.edges.forEach(function (edge) { + + if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target"; + + if (edge.target == other || edge.source == other) { + edgeList.push(edge); + } + }); + + return edgeList; + }; + + LNode.prototype.getNeighborsList = function () { + var neighbors = new Set(); + + var self = this; + self.edges.forEach(function (edge) { + + if (edge.source == self) { + neighbors.add(edge.target); + } else { + if (edge.target != self) { + throw "Incorrect incidency!"; + } + + neighbors.add(edge.source); + } + }); + + return neighbors; + }; + + LNode.prototype.withChildren = function () { + var withNeighborsList = new Set(); + var childNode; + var children; + + withNeighborsList.add(this); + + if (this.child != null) { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + children = childNode.withChildren(); + children.forEach(function (node) { + withNeighborsList.add(node); + }); + } + } + + return withNeighborsList; + }; + + LNode.prototype.getNoOfChildren = function () { + var noOfChildren = 0; + var childNode; + + if (this.child == null) { + noOfChildren = 1; + } else { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + + noOfChildren += childNode.getNoOfChildren(); + } + } + + if (noOfChildren == 0) { + noOfChildren = 1; + } + return noOfChildren; + }; + + LNode.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; + }; + + LNode.prototype.calcEstimatedSize = function () { + if (this.child == null) { + return this.estimatedSize = (this.rect.width + this.rect.height) / 2; + } else { + this.estimatedSize = this.child.calcEstimatedSize(); + this.rect.width = this.estimatedSize; + this.rect.height = this.estimatedSize; + + return this.estimatedSize; + } + }; + + LNode.prototype.scatter = function () { + var randomCenterX; + var randomCenterY; + + var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX; + + var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY; + + this.rect.x = randomCenterX; + this.rect.y = randomCenterY; + }; + + LNode.prototype.updateBounds = function () { + if (this.getChild() == null) { + throw "assert failed"; + } + if (this.getChild().getNodes().length != 0) { + // wrap the children nodes by re-arranging the boundaries + var childGraph = this.getChild(); + childGraph.updateBounds(true); + + this.rect.x = childGraph.getLeft(); + this.rect.y = childGraph.getTop(); + + this.setWidth(childGraph.getRight() - childGraph.getLeft()); + this.setHeight(childGraph.getBottom() - childGraph.getTop()); + + // Update compound bounds considering its label properties + if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = childGraph.getRight() - childGraph.getLeft(); + var height = childGraph.getBottom() - childGraph.getTop(); + + if (this.labelWidth > width) { + this.rect.x -= (this.labelWidth - width) / 2; + this.setWidth(this.labelWidth); + } + + if (this.labelHeight > height) { + if (this.labelPos == "center") { + this.rect.y -= (this.labelHeight - height) / 2; + } else if (this.labelPos == "top") { + this.rect.y -= this.labelHeight - height; + } + this.setHeight(this.labelHeight); + } + } + } + }; + + LNode.prototype.getInclusionTreeDepth = function () { + if (this.inclusionTreeDepth == Integer.MAX_VALUE) { + throw "assert failed"; + } + return this.inclusionTreeDepth; + }; + + LNode.prototype.transform = function (trans) { + var left = this.rect.x; + + if (left > LayoutConstants.WORLD_BOUNDARY) { + left = LayoutConstants.WORLD_BOUNDARY; + } else if (left < -LayoutConstants.WORLD_BOUNDARY) { + left = -LayoutConstants.WORLD_BOUNDARY; + } + + var top = this.rect.y; + + if (top > LayoutConstants.WORLD_BOUNDARY) { + top = LayoutConstants.WORLD_BOUNDARY; + } else if (top < -LayoutConstants.WORLD_BOUNDARY) { + top = -LayoutConstants.WORLD_BOUNDARY; + } + + var leftTop = new PointD(left, top); + var vLeftTop = trans.inverseTransformPoint(leftTop); + + this.setLocation(vLeftTop.x, vLeftTop.y); + }; + + LNode.prototype.getLeft = function () { + return this.rect.x; + }; + + LNode.prototype.getRight = function () { + return this.rect.x + this.rect.width; + }; + + LNode.prototype.getTop = function () { + return this.rect.y; + }; + + LNode.prototype.getBottom = function () { + return this.rect.y + this.rect.height; + }; + + LNode.prototype.getParent = function () { + if (this.owner == null) { + return null; + } + + return this.owner.getParent(); + }; + + module.exports = LNode; + + /***/ }), + /* 4 */ + /***/ (function(module, exports, __webpack_require__) { + + + function PointD(x, y) { + if (x == null && y == null) { + this.x = 0; + this.y = 0; + } else { + this.x = x; + this.y = y; + } + } + + PointD.prototype.getX = function () { + return this.x; + }; + + PointD.prototype.getY = function () { + return this.y; + }; + + PointD.prototype.setX = function (x) { + this.x = x; + }; + + PointD.prototype.setY = function (y) { + this.y = y; + }; + + PointD.prototype.getDifference = function (pt) { + return new DimensionD(this.x - pt.x, this.y - pt.y); + }; + + PointD.prototype.getCopy = function () { + return new PointD(this.x, this.y); + }; + + PointD.prototype.translate = function (dim) { + this.x += dim.width; + this.y += dim.height; + return this; + }; + + module.exports = PointD; + + /***/ }), + /* 5 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var Integer = __webpack_require__(10); + var LayoutConstants = __webpack_require__(0); + var LGraphManager = __webpack_require__(6); + var LNode = __webpack_require__(3); + var LEdge = __webpack_require__(1); + var RectangleD = __webpack_require__(13); + var Point = __webpack_require__(12); + var LinkedList = __webpack_require__(11); + + function LGraph(parent, obj2, vGraph) { + LGraphObject.call(this, vGraph); + this.estimatedSize = Integer.MIN_VALUE; + this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; + this.edges = []; + this.nodes = []; + this.isConnected = false; + this.parent = parent; + + if (obj2 != null && obj2 instanceof LGraphManager) { + this.graphManager = obj2; + } else if (obj2 != null && obj2 instanceof Layout) { + this.graphManager = obj2.graphManager; + } + } + + LGraph.prototype = Object.create(LGraphObject.prototype); + for (var prop in LGraphObject) { + LGraph[prop] = LGraphObject[prop]; + } + + LGraph.prototype.getNodes = function () { + return this.nodes; + }; + + LGraph.prototype.getEdges = function () { + return this.edges; + }; + + LGraph.prototype.getGraphManager = function () { + return this.graphManager; + }; + + LGraph.prototype.getParent = function () { + return this.parent; + }; + + LGraph.prototype.getLeft = function () { + return this.left; + }; + + LGraph.prototype.getRight = function () { + return this.right; + }; + + LGraph.prototype.getTop = function () { + return this.top; + }; + + LGraph.prototype.getBottom = function () { + return this.bottom; + }; + + LGraph.prototype.isConnected = function () { + return this.isConnected; + }; + + LGraph.prototype.add = function (obj1, sourceNode, targetNode) { + if (sourceNode == null && targetNode == null) { + var newNode = obj1; + if (this.graphManager == null) { + throw "Graph has no graph mgr!"; + } + if (this.getNodes().indexOf(newNode) > -1) { + throw "Node already in graph!"; + } + newNode.owner = this; + this.getNodes().push(newNode); + + return newNode; + } else { + var newEdge = obj1; + if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) { + throw "Source or target not in graph!"; + } + + if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { + throw "Both owners must be this graph!"; + } + + if (sourceNode.owner != targetNode.owner) { + return null; + } + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // set as intra-graph edge + newEdge.isInterGraph = false; + + // add to graph edge list + this.getEdges().push(newEdge); + + // add to incidency lists + sourceNode.edges.push(newEdge); + + if (targetNode != sourceNode) { + targetNode.edges.push(newEdge); + } + + return newEdge; + } + }; + + LGraph.prototype.remove = function (obj) { + var node = obj; + if (obj instanceof LNode) { + if (node == null) { + throw "Node is null!"; + } + if (!(node.owner != null && node.owner == this)) { + throw "Owner graph is invalid!"; + } + if (this.graphManager == null) { + throw "Owner graph manager is invalid!"; + } + // remove incident edges first (make a copy to do it safely) + var edgesToBeRemoved = node.edges.slice(); + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + + if (edge.isInterGraph) { + this.graphManager.remove(edge); + } else { + edge.source.owner.remove(edge); + } + } + + // now the node itself + var index = this.nodes.indexOf(node); + if (index == -1) { + throw "Node not in owner node list!"; + } + + this.nodes.splice(index, 1); + } else if (obj instanceof LEdge) { + var edge = obj; + if (edge == null) { + throw "Edge is null!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) { + throw "Source and/or target owner is invalid!"; + } + + var sourceIndex = edge.source.edges.indexOf(edge); + var targetIndex = edge.target.edges.indexOf(edge); + if (!(sourceIndex > -1 && targetIndex > -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + edge.source.edges.splice(sourceIndex, 1); + + if (edge.target != edge.source) { + edge.target.edges.splice(targetIndex, 1); + } + + var index = edge.source.owner.getEdges().indexOf(edge); + if (index == -1) { + throw "Not in owner's edge list!"; + } + + edge.source.owner.getEdges().splice(index, 1); + } + }; + + LGraph.prototype.updateLeftTop = function () { + var top = Integer.MAX_VALUE; + var left = Integer.MAX_VALUE; + var nodeTop; + var nodeLeft; + var margin; + + var nodes = this.getNodes(); + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeTop = lNode.getTop(); + nodeLeft = lNode.getLeft(); + + if (top > nodeTop) { + top = nodeTop; + } + + if (left > nodeLeft) { + left = nodeLeft; + } + } + + // Do we have any nodes in this graph? + if (top == Integer.MAX_VALUE) { + return null; + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = left - margin; + this.top = top - margin; + + // Apply the margins and return the result + return new Point(this.left, this.top); + }; + + LGraph.prototype.updateBounds = function (recursive) { + // calculate bounds + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + var margin; + + var nodes = this.nodes; + var s = nodes.length; + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + + if (recursive && lNode.child != null) { + lNode.updateBounds(); + } + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + if (left == Integer.MAX_VALUE) { + this.left = this.parent.getLeft(); + this.right = this.parent.getRight(); + this.top = this.parent.getTop(); + this.bottom = this.parent.getBottom(); + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = boundingRect.x - margin; + this.right = boundingRect.x + boundingRect.width + margin; + this.top = boundingRect.y - margin; + this.bottom = boundingRect.y + boundingRect.height + margin; + }; + + LGraph.calculateBounds = function (nodes) { + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + + return boundingRect; + }; + + LGraph.prototype.getInclusionTreeDepth = function () { + if (this == this.graphManager.getRoot()) { + return 1; + } else { + return this.parent.getInclusionTreeDepth(); + } + }; + + LGraph.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; + }; + + LGraph.prototype.calcEstimatedSize = function () { + var size = 0; + var nodes = this.nodes; + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + size += lNode.calcEstimatedSize(); + } + + if (size == 0) { + this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; + } else { + this.estimatedSize = size / Math.sqrt(this.nodes.length); + } + + return this.estimatedSize; + }; + + LGraph.prototype.updateConnected = function () { + var self = this; + if (this.nodes.length == 0) { + this.isConnected = true; + return; + } + + var queue = new LinkedList(); + var visited = new Set(); + var currentNode = this.nodes[0]; + var neighborEdges; + var currentNeighbor; + var childrenOfNode = currentNode.withChildren(); + childrenOfNode.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + + while (queue.length !== 0) { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + neighborEdges = currentNode.getEdges(); + var size = neighborEdges.length; + for (var i = 0; i < size; i++) { + var neighborEdge = neighborEdges[i]; + currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this); + + // Add unvisited neighbors to the list to visit + if (currentNeighbor != null && !visited.has(currentNeighbor)) { + var childrenOfNeighbor = currentNeighbor.withChildren(); + + childrenOfNeighbor.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + } + } + } + + this.isConnected = false; + + if (visited.size >= this.nodes.length) { + var noOfVisitedInThisGraph = 0; + + visited.forEach(function (visitedNode) { + if (visitedNode.owner == self) { + noOfVisitedInThisGraph++; + } + }); + + if (noOfVisitedInThisGraph == this.nodes.length) { + this.isConnected = true; + } + } + }; + + module.exports = LGraph; + + /***/ }), + /* 6 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraph; + var LEdge = __webpack_require__(1); + + function LGraphManager(layout) { + LGraph = __webpack_require__(5); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now. + this.layout = layout; + + this.graphs = []; + this.edges = []; + } + + LGraphManager.prototype.addRoot = function () { + var ngraph = this.layout.newGraph(); + var nnode = this.layout.newNode(null); + var root = this.add(ngraph, nnode); + this.setRootGraph(root); + return this.rootGraph; + }; + + LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) { + //there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge + if (newEdge == null && sourceNode == null && targetNode == null) { + if (newGraph == null) { + throw "Graph is null!"; + } + if (parentNode == null) { + throw "Parent node is null!"; + } + if (this.graphs.indexOf(newGraph) > -1) { + throw "Graph already in this graph mgr!"; + } + + this.graphs.push(newGraph); + + if (newGraph.parent != null) { + throw "Already has a parent!"; + } + if (parentNode.child != null) { + throw "Already has a child!"; + } + + newGraph.parent = parentNode; + parentNode.child = newGraph; + + return newGraph; + } else { + //change the order of the parameters + targetNode = newEdge; + sourceNode = parentNode; + newEdge = newGraph; + var sourceGraph = sourceNode.getOwner(); + var targetGraph = targetNode.getOwner(); + + if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { + throw "Source not in this graph mgr!"; + } + if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { + throw "Target not in this graph mgr!"; + } + + if (sourceGraph == targetGraph) { + newEdge.isInterGraph = false; + return sourceGraph.add(newEdge, sourceNode, targetNode); + } else { + newEdge.isInterGraph = true; + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // add edge to inter-graph edge list + if (this.edges.indexOf(newEdge) > -1) { + throw "Edge already in inter-graph edge list!"; + } + + this.edges.push(newEdge); + + // add edge to source and target incidency lists + if (!(newEdge.source != null && newEdge.target != null)) { + throw "Edge source and/or target is null!"; + } + + if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { + throw "Edge already in source and/or target incidency list!"; + } + + newEdge.source.edges.push(newEdge); + newEdge.target.edges.push(newEdge); + + return newEdge; + } + } + }; + + LGraphManager.prototype.remove = function (lObj) { + if (lObj instanceof LGraph) { + var graph = lObj; + if (graph.getGraphManager() != this) { + throw "Graph not in this graph mgr"; + } + if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) { + throw "Invalid parent node!"; + } + + // first the edges (make a copy to do it safely) + var edgesToBeRemoved = []; + + edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); + + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + graph.remove(edge); + } + + // then the nodes (make a copy to do it safely) + var nodesToBeRemoved = []; + + nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); + + var node; + s = nodesToBeRemoved.length; + for (var i = 0; i < s; i++) { + node = nodesToBeRemoved[i]; + graph.remove(node); + } + + // check if graph is the root + if (graph == this.rootGraph) { + this.setRootGraph(null); + } + + // now remove the graph itself + var index = this.graphs.indexOf(graph); + this.graphs.splice(index, 1); + + // also reset the parent of the graph + graph.parent = null; + } else if (lObj instanceof LEdge) { + edge = lObj; + if (edge == null) { + throw "Edge is null!"; + } + if (!edge.isInterGraph) { + throw "Not an inter-graph edge!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + + // remove edge from source and target nodes' incidency lists + + if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + var index = edge.source.edges.indexOf(edge); + edge.source.edges.splice(index, 1); + index = edge.target.edges.indexOf(edge); + edge.target.edges.splice(index, 1); + + // remove edge from owner graph manager's inter-graph edge list + + if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { + throw "Edge owner graph or owner graph manager is null!"; + } + if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { + throw "Not in owner graph manager's edge list!"; + } + + var index = edge.source.owner.getGraphManager().edges.indexOf(edge); + edge.source.owner.getGraphManager().edges.splice(index, 1); + } + }; + + LGraphManager.prototype.updateBounds = function () { + this.rootGraph.updateBounds(true); + }; + + LGraphManager.prototype.getGraphs = function () { + return this.graphs; + }; + + LGraphManager.prototype.getAllNodes = function () { + if (this.allNodes == null) { + var nodeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < s; i++) { + nodeList = nodeList.concat(graphs[i].getNodes()); + } + this.allNodes = nodeList; + } + return this.allNodes; + }; + + LGraphManager.prototype.resetAllNodes = function () { + this.allNodes = null; + }; + + LGraphManager.prototype.resetAllEdges = function () { + this.allEdges = null; + }; + + LGraphManager.prototype.resetAllNodesToApplyGravitation = function () { + this.allNodesToApplyGravitation = null; + }; + + LGraphManager.prototype.getAllEdges = function () { + if (this.allEdges == null) { + var edgeList = []; + var graphs = this.getGraphs(); + graphs.length; + for (var i = 0; i < graphs.length; i++) { + edgeList = edgeList.concat(graphs[i].getEdges()); + } + + edgeList = edgeList.concat(this.edges); + + this.allEdges = edgeList; + } + return this.allEdges; + }; + + LGraphManager.prototype.getAllNodesToApplyGravitation = function () { + return this.allNodesToApplyGravitation; + }; + + LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) { + if (this.allNodesToApplyGravitation != null) { + throw "assert failed"; + } + + this.allNodesToApplyGravitation = nodeList; + }; + + LGraphManager.prototype.getRoot = function () { + return this.rootGraph; + }; + + LGraphManager.prototype.setRootGraph = function (graph) { + if (graph.getGraphManager() != this) { + throw "Root not in this graph mgr!"; + } + + this.rootGraph = graph; + // root graph must have a root node associated with it for convenience + if (graph.parent == null) { + graph.parent = this.layout.newNode("Root node"); + } + }; + + LGraphManager.prototype.getLayout = function () { + return this.layout; + }; + + LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) { + if (!(firstNode != null && secondNode != null)) { + throw "assert failed"; + } + + if (firstNode == secondNode) { + return true; + } + // Is second node an ancestor of the first one? + var ownerGraph = firstNode.getOwner(); + var parentNode; + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == secondNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + // Is first node an ancestor of the second one? + ownerGraph = secondNode.getOwner(); + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == firstNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + + return false; + }; + + LGraphManager.prototype.calcLowestCommonAncestors = function () { + var edge; + var sourceNode; + var targetNode; + var sourceAncestorGraph; + var targetAncestorGraph; + + var edges = this.getAllEdges(); + var s = edges.length; + for (var i = 0; i < s; i++) { + edge = edges[i]; + + sourceNode = edge.source; + targetNode = edge.target; + edge.lca = null; + edge.sourceInLca = sourceNode; + edge.targetInLca = targetNode; + + if (sourceNode == targetNode) { + edge.lca = sourceNode.getOwner(); + continue; + } + + sourceAncestorGraph = sourceNode.getOwner(); + + while (edge.lca == null) { + edge.targetInLca = targetNode; + targetAncestorGraph = targetNode.getOwner(); + + while (edge.lca == null) { + if (targetAncestorGraph == sourceAncestorGraph) { + edge.lca = targetAncestorGraph; + break; + } + + if (targetAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca != null) { + throw "assert failed"; + } + edge.targetInLca = targetAncestorGraph.getParent(); + targetAncestorGraph = edge.targetInLca.getOwner(); + } + + if (sourceAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca == null) { + edge.sourceInLca = sourceAncestorGraph.getParent(); + sourceAncestorGraph = edge.sourceInLca.getOwner(); + } + } + + if (edge.lca == null) { + throw "assert failed"; + } + } + }; + + LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) { + if (firstNode == secondNode) { + return firstNode.getOwner(); + } + var firstOwnerGraph = firstNode.getOwner(); + + do { + if (firstOwnerGraph == null) { + break; + } + var secondOwnerGraph = secondNode.getOwner(); + + do { + if (secondOwnerGraph == null) { + break; + } + + if (secondOwnerGraph == firstOwnerGraph) { + return secondOwnerGraph; + } + secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); + } while (true); + + firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); + } while (true); + + return firstOwnerGraph; + }; + + LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) { + if (graph == null && depth == null) { + graph = this.rootGraph; + depth = 1; + } + var node; + + var nodes = graph.getNodes(); + var s = nodes.length; + for (var i = 0; i < s; i++) { + node = nodes[i]; + node.inclusionTreeDepth = depth; + + if (node.child != null) { + this.calcInclusionTreeDepths(node.child, depth + 1); + } + } + }; + + LGraphManager.prototype.includesInvalidEdge = function () { + var edge; + + var s = this.edges.length; + for (var i = 0; i < s; i++) { + edge = this.edges[i]; + + if (this.isOneAncestorOfOther(edge.source, edge.target)) { + return true; + } + } + return false; + }; + + module.exports = LGraphManager; + + /***/ }), + /* 7 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LayoutConstants = __webpack_require__(0); + + function FDLayoutConstants() {} + + //FDLayoutConstants inherits static props in LayoutConstants + for (var prop in LayoutConstants) { + FDLayoutConstants[prop] = LayoutConstants[prop]; + } + + FDLayoutConstants.MAX_ITERATIONS = 2500; + + FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; + FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45; + FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0; + FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4; + FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0; + FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8; + FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5; + FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true; + FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true; + FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3; + FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33; + FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000; + FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000; + FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0; + FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3; + FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; + FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100; + FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1; + FDLayoutConstants.MIN_EDGE_LENGTH = 1; + FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10; + + module.exports = FDLayoutConstants; + + /***/ }), + /* 8 */ + /***/ (function(module, exports, __webpack_require__) { + + + /** + * This class maintains a list of static geometry related utility methods. + * + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + + var Point = __webpack_require__(12); + + function IGeometry() {} + + /** + * This method calculates *half* the amount in x and y directions of the two + * input rectangles needed to separate them keeping their respective + * positioning, and returns the result in the input array. An input + * separation buffer added to the amount in both directions. We assume that + * the two rectangles do intersect. + */ + IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) { + if (!rectA.intersects(rectB)) { + throw "assert failed"; + } + + var directions = new Array(2); + + this.decideDirectionsForOverlappingNodes(rectA, rectB, directions); + + overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x); + overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y); + + // update the overlapping amounts for the following cases: + if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) { + /* Case x.1: + * + * rectA + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectB + */ + overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight()); + } else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) { + /* Case x.2: + * + * rectB + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectA + */ + overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight()); + } + if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) { + /* Case y.1: + * ________ rectA + * | + * | + * ______|____ rectB + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom()); + } else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) { + /* Case y.2: + * ________ rectB + * | + * | + * ______|____ rectA + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom()); + } + + // find slope of the line passes two centers + var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX())); + // if centers are overlapped + if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) { + // assume the slope is 1 (45 degree) + slope = 1.0; + } + + var moveByY = slope * overlapAmount[0]; + var moveByX = overlapAmount[1] / slope; + if (overlapAmount[0] < moveByX) { + moveByX = overlapAmount[0]; + } else { + moveByY = overlapAmount[1]; + } + // return half the amount so that if each rectangle is moved by these + // amounts in opposite directions, overlap will be resolved + overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer); + overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer); + }; + + /** + * This method decides the separation direction of overlapping nodes + * + * if directions[0] = -1, then rectA goes left + * if directions[0] = 1, then rectA goes right + * if directions[1] = -1, then rectA goes up + * if directions[1] = 1, then rectA goes down + */ + IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) { + if (rectA.getCenterX() < rectB.getCenterX()) { + directions[0] = -1; + } else { + directions[0] = 1; + } + + if (rectA.getCenterY() < rectB.getCenterY()) { + directions[1] = -1; + } else { + directions[1] = 1; + } + }; + + /** + * This method calculates the intersection (clipping) points of the two + * input rectangles with line segment defined by the centers of these two + * rectangles. The clipping points are saved in the input double array and + * whether or not the two rectangles overlap is returned. + */ + IGeometry.getIntersection2 = function (rectA, rectB, result) { + //result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB + var p1x = rectA.getCenterX(); + var p1y = rectA.getCenterY(); + var p2x = rectB.getCenterX(); + var p2y = rectB.getCenterY(); + + //if two rectangles intersect, then clipping points are centers + if (rectA.intersects(rectB)) { + result[0] = p1x; + result[1] = p1y; + result[2] = p2x; + result[3] = p2y; + return true; + } + //variables for rectA + var topLeftAx = rectA.getX(); + var topLeftAy = rectA.getY(); + var topRightAx = rectA.getRight(); + var bottomLeftAx = rectA.getX(); + var bottomLeftAy = rectA.getBottom(); + var bottomRightAx = rectA.getRight(); + var halfWidthA = rectA.getWidthHalf(); + var halfHeightA = rectA.getHeightHalf(); + //variables for rectB + var topLeftBx = rectB.getX(); + var topLeftBy = rectB.getY(); + var topRightBx = rectB.getRight(); + var bottomLeftBx = rectB.getX(); + var bottomLeftBy = rectB.getBottom(); + var bottomRightBx = rectB.getRight(); + var halfWidthB = rectB.getWidthHalf(); + var halfHeightB = rectB.getHeightHalf(); + + //flag whether clipping points are found + var clipPointAFound = false; + var clipPointBFound = false; + + // line is vertical + if (p1x === p2x) { + if (p1y > p2y) { + result[0] = p1x; + result[1] = topLeftAy; + result[2] = p2x; + result[3] = bottomLeftBy; + return false; + } else if (p1y < p2y) { + result[0] = p1x; + result[1] = bottomLeftAy; + result[2] = p2x; + result[3] = topLeftBy; + return false; + } else ; + } + // line is horizontal + else if (p1y === p2y) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = p1y; + result[2] = topRightBx; + result[3] = p2y; + return false; + } else if (p1x < p2x) { + result[0] = topRightAx; + result[1] = p1y; + result[2] = topLeftBx; + result[3] = p2y; + return false; + } else ; + } else { + //slopes of rectA's and rectB's diagonals + var slopeA = rectA.height / rectA.width; + var slopeB = rectB.height / rectB.width; + + //slope of line between center of rectA and center of rectB + var slopePrime = (p2y - p1y) / (p2x - p1x); + var cardinalDirectionA = void 0; + var cardinalDirectionB = void 0; + var tempPointAx = void 0; + var tempPointAy = void 0; + var tempPointBx = void 0; + var tempPointBy = void 0; + + //determine whether clipping point is the corner of nodeA + if (-slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = bottomLeftAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } else { + result[0] = topRightAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + } else if (slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = topLeftAy; + clipPointAFound = true; + } else { + result[0] = bottomRightAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + } + + //determine whether clipping point is the corner of nodeB + if (-slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = bottomLeftBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } else { + result[2] = topRightBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + } else if (slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = topLeftBx; + result[3] = topLeftBy; + clipPointBFound = true; + } else { + result[2] = bottomRightBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + } + + //if both clipping points are corners + if (clipPointAFound && clipPointBFound) { + return false; + } + + //determine Cardinal Direction of rectangles + if (p1x > p2x) { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2); + } else { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1); + } + } else { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3); + } else { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4); + } + } + //calculate clipping Point if it is not found before + if (!clipPointAFound) { + switch (cardinalDirectionA) { + case 1: + tempPointAy = topLeftAy; + tempPointAx = p1x + -halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 2: + tempPointAx = bottomRightAx; + tempPointAy = p1y + halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 3: + tempPointAy = bottomLeftAy; + tempPointAx = p1x + halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 4: + tempPointAx = bottomLeftAx; + tempPointAy = p1y + -halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + } + } + if (!clipPointBFound) { + switch (cardinalDirectionB) { + case 1: + tempPointBy = topLeftBy; + tempPointBx = p2x + -halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 2: + tempPointBx = bottomRightBx; + tempPointBy = p2y + halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 3: + tempPointBy = bottomLeftBy; + tempPointBx = p2x + halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 4: + tempPointBx = bottomLeftBx; + tempPointBy = p2y + -halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + } + } + } + return false; + }; + + /** + * This method returns in which cardinal direction does input point stays + * 1: North + * 2: East + * 3: South + * 4: West + */ + IGeometry.getCardinalDirection = function (slope, slopePrime, line) { + if (slope > slopePrime) { + return line; + } else { + return 1 + line % 4; + } + }; + + /** + * This method calculates the intersection of the two lines defined by + * point pairs (s1,s2) and (f1,f2). + */ + IGeometry.getIntersection = function (s1, s2, f1, f2) { + if (f2 == null) { + return this.getIntersection2(s1, s2, f1); + } + + var x1 = s1.x; + var y1 = s1.y; + var x2 = s2.x; + var y2 = s2.y; + var x3 = f1.x; + var y3 = f1.y; + var x4 = f2.x; + var y4 = f2.y; + var x = void 0, + y = void 0; // intersection point + var a1 = void 0, + a2 = void 0, + b1 = void 0, + b2 = void 0, + c1 = void 0, + c2 = void 0; // coefficients of line eqns. + var denom = void 0; + + a1 = y2 - y1; + b1 = x1 - x2; + c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 } + + a2 = y4 - y3; + b2 = x3 - x4; + c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 } + + denom = a1 * b2 - a2 * b1; + + if (denom === 0) { + return null; + } + + x = (b1 * c2 - b2 * c1) / denom; + y = (a2 * c1 - a1 * c2) / denom; + + return new Point(x, y); + }; + + /** + * This method finds and returns the angle of the vector from the + x-axis + * in clockwise direction (compatible w/ Java coordinate system!). + */ + IGeometry.angleOfVector = function (Cx, Cy, Nx, Ny) { + var C_angle = void 0; + + if (Cx !== Nx) { + C_angle = Math.atan((Ny - Cy) / (Nx - Cx)); + + if (Nx < Cx) { + C_angle += Math.PI; + } else if (Ny < Cy) { + C_angle += this.TWO_PI; + } + } else if (Ny < Cy) { + C_angle = this.ONE_AND_HALF_PI; // 270 degrees + } else { + C_angle = this.HALF_PI; // 90 degrees + } + + return C_angle; + }; + + /** + * This method checks whether the given two line segments (one with point + * p1 and p2, the other with point p3 and p4) intersect at a point other + * than these points. + */ + IGeometry.doIntersect = function (p1, p2, p3, p4) { + var a = p1.x; + var b = p1.y; + var c = p2.x; + var d = p2.y; + var p = p3.x; + var q = p3.y; + var r = p4.x; + var s = p4.y; + var det = (c - a) * (s - q) - (r - p) * (d - b); + + if (det === 0) { + return false; + } else { + var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det; + var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det; + return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1; + } + }; + + // ----------------------------------------------------------------------------- + // Section: Class Constants + // ----------------------------------------------------------------------------- + /** + * Some useful pre-calculated constants + */ + IGeometry.HALF_PI = 0.5 * Math.PI; + IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI; + IGeometry.TWO_PI = 2.0 * Math.PI; + IGeometry.THREE_PI = 3.0 * Math.PI; + + module.exports = IGeometry; + + /***/ }), + /* 9 */ + /***/ (function(module, exports, __webpack_require__) { + + + function IMath() {} + + /** + * This method returns the sign of the input value. + */ + IMath.sign = function (value) { + if (value > 0) { + return 1; + } else if (value < 0) { + return -1; + } else { + return 0; + } + }; + + IMath.floor = function (value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); + }; + + IMath.ceil = function (value) { + return value < 0 ? Math.floor(value) : Math.ceil(value); + }; + + module.exports = IMath; + + /***/ }), + /* 10 */ + /***/ (function(module, exports, __webpack_require__) { + + + function Integer() {} + + Integer.MAX_VALUE = 2147483647; + Integer.MIN_VALUE = -2147483648; + + module.exports = Integer; + + /***/ }), + /* 11 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var nodeFrom = function nodeFrom(value) { + return { value: value, next: null, prev: null }; + }; + + var add = function add(prev, node, next, list) { + if (prev !== null) { + prev.next = node; + } else { + list.head = node; + } + + if (next !== null) { + next.prev = node; + } else { + list.tail = node; + } + + node.prev = prev; + node.next = next; + + list.length++; + + return node; + }; + + var _remove = function _remove(node, list) { + var prev = node.prev, + next = node.next; + + + if (prev !== null) { + prev.next = next; + } else { + list.head = next; + } + + if (next !== null) { + next.prev = prev; + } else { + list.tail = prev; + } + + node.prev = node.next = null; + + list.length--; + + return node; + }; + + var LinkedList = function () { + function LinkedList(vals) { + var _this = this; + + _classCallCheck(this, LinkedList); + + this.length = 0; + this.head = null; + this.tail = null; + + if (vals != null) { + vals.forEach(function (v) { + return _this.push(v); + }); + } + } + + _createClass(LinkedList, [{ + key: "size", + value: function size() { + return this.length; + } + }, { + key: "insertBefore", + value: function insertBefore(val, otherNode) { + return add(otherNode.prev, nodeFrom(val), otherNode, this); + } + }, { + key: "insertAfter", + value: function insertAfter(val, otherNode) { + return add(otherNode, nodeFrom(val), otherNode.next, this); + } + }, { + key: "insertNodeBefore", + value: function insertNodeBefore(newNode, otherNode) { + return add(otherNode.prev, newNode, otherNode, this); + } + }, { + key: "insertNodeAfter", + value: function insertNodeAfter(newNode, otherNode) { + return add(otherNode, newNode, otherNode.next, this); + } + }, { + key: "push", + value: function push(val) { + return add(this.tail, nodeFrom(val), null, this); + } + }, { + key: "unshift", + value: function unshift(val) { + return add(null, nodeFrom(val), this.head, this); + } + }, { + key: "remove", + value: function remove(node) { + return _remove(node, this); + } + }, { + key: "pop", + value: function pop() { + return _remove(this.tail, this).value; + } + }, { + key: "popNode", + value: function popNode() { + return _remove(this.tail, this); + } + }, { + key: "shift", + value: function shift() { + return _remove(this.head, this).value; + } + }, { + key: "shiftNode", + value: function shiftNode() { + return _remove(this.head, this); + } + }, { + key: "get_object_at", + value: function get_object_at(index) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + return current.value; + } + } + }, { + key: "set_object_at", + value: function set_object_at(index, value) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + current.value = value; + } + } + }]); + + return LinkedList; + }(); + + module.exports = LinkedList; + + /***/ }), + /* 12 */ + /***/ (function(module, exports, __webpack_require__) { + + + /* + *This class is the javascript implementation of the Point.java class in jdk + */ + function Point(x, y, p) { + this.x = null; + this.y = null; + if (x == null && y == null && p == null) { + this.x = 0; + this.y = 0; + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + this.x = x; + this.y = y; + } else if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.x = p.x; + this.y = p.y; + } + } + + Point.prototype.getX = function () { + return this.x; + }; + + Point.prototype.getY = function () { + return this.y; + }; + + Point.prototype.getLocation = function () { + return new Point(this.x, this.y); + }; + + Point.prototype.setLocation = function (x, y, p) { + if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.setLocation(p.x, p.y); + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + //if both parameters are integer just move (x,y) location + if (parseInt(x) == x && parseInt(y) == y) { + this.move(x, y); + } else { + this.x = Math.floor(x + 0.5); + this.y = Math.floor(y + 0.5); + } + } + }; + + Point.prototype.move = function (x, y) { + this.x = x; + this.y = y; + }; + + Point.prototype.translate = function (dx, dy) { + this.x += dx; + this.y += dy; + }; + + Point.prototype.equals = function (obj) { + if (obj.constructor.name == "Point") { + var pt = obj; + return this.x == pt.x && this.y == pt.y; + } + return this == obj; + }; + + Point.prototype.toString = function () { + return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]"; + }; + + module.exports = Point; + + /***/ }), + /* 13 */ + /***/ (function(module, exports, __webpack_require__) { + + + function RectangleD(x, y, width, height) { + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + + if (x != null && y != null && width != null && height != null) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + } + + RectangleD.prototype.getX = function () { + return this.x; + }; + + RectangleD.prototype.setX = function (x) { + this.x = x; + }; + + RectangleD.prototype.getY = function () { + return this.y; + }; + + RectangleD.prototype.setY = function (y) { + this.y = y; + }; + + RectangleD.prototype.getWidth = function () { + return this.width; + }; + + RectangleD.prototype.setWidth = function (width) { + this.width = width; + }; + + RectangleD.prototype.getHeight = function () { + return this.height; + }; + + RectangleD.prototype.setHeight = function (height) { + this.height = height; + }; + + RectangleD.prototype.getRight = function () { + return this.x + this.width; + }; + + RectangleD.prototype.getBottom = function () { + return this.y + this.height; + }; + + RectangleD.prototype.intersects = function (a) { + if (this.getRight() < a.x) { + return false; + } + + if (this.getBottom() < a.y) { + return false; + } + + if (a.getRight() < this.x) { + return false; + } + + if (a.getBottom() < this.y) { + return false; + } + + return true; + }; + + RectangleD.prototype.getCenterX = function () { + return this.x + this.width / 2; + }; + + RectangleD.prototype.getMinX = function () { + return this.getX(); + }; + + RectangleD.prototype.getMaxX = function () { + return this.getX() + this.width; + }; + + RectangleD.prototype.getCenterY = function () { + return this.y + this.height / 2; + }; + + RectangleD.prototype.getMinY = function () { + return this.getY(); + }; + + RectangleD.prototype.getMaxY = function () { + return this.getY() + this.height; + }; + + RectangleD.prototype.getWidthHalf = function () { + return this.width / 2; + }; + + RectangleD.prototype.getHeightHalf = function () { + return this.height / 2; + }; + + module.exports = RectangleD; + + /***/ }), + /* 14 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function UniqueIDGeneretor() {} + + UniqueIDGeneretor.lastID = 0; + + UniqueIDGeneretor.createID = function (obj) { + if (UniqueIDGeneretor.isPrimitive(obj)) { + return obj; + } + if (obj.uniqueID != null) { + return obj.uniqueID; + } + obj.uniqueID = UniqueIDGeneretor.getString(); + UniqueIDGeneretor.lastID++; + return obj.uniqueID; + }; + + UniqueIDGeneretor.getString = function (id) { + if (id == null) id = UniqueIDGeneretor.lastID; + return "Object#" + id + ""; + }; + + UniqueIDGeneretor.isPrimitive = function (arg) { + var type = typeof arg === "undefined" ? "undefined" : _typeof(arg); + return arg == null || type != "object" && type != "function"; + }; + + module.exports = UniqueIDGeneretor; + + /***/ }), + /* 15 */ + /***/ (function(module, exports, __webpack_require__) { + + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var LayoutConstants = __webpack_require__(0); + var LGraphManager = __webpack_require__(6); + var LNode = __webpack_require__(3); + var LEdge = __webpack_require__(1); + var LGraph = __webpack_require__(5); + var PointD = __webpack_require__(4); + var Transform = __webpack_require__(17); + var Emitter = __webpack_require__(27); + + function Layout(isRemoteUse) { + Emitter.call(this); + + //Layout Quality: 0:draft, 1:default, 2:proof + this.layoutQuality = LayoutConstants.QUALITY; + //Whether layout should create bendpoints as needed or not + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + //Whether layout should be incremental or not + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + //Whether we animate from before to after layout node positions + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + //Whether we animate the layout process or not + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + //Number iterations that should be done between two successive animations + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + /** + * Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When + * they are, both spring and repulsion forces between two leaf nodes can be + * calculated without the expensive clipping point calculations, resulting + * in major speed-up. + */ + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + /** + * This is used for creation of bendpoints by using dummy nodes and edges. + * Maps an LEdge to its dummy bendpoint path. + */ + this.edgeToDummyNodes = new Map(); + this.graphManager = new LGraphManager(this); + this.isLayoutFinished = false; + this.isSubLayout = false; + this.isRemoteUse = false; + + if (isRemoteUse != null) { + this.isRemoteUse = isRemoteUse; + } + } + + Layout.RANDOM_SEED = 1; + + Layout.prototype = Object.create(Emitter.prototype); + + Layout.prototype.getGraphManager = function () { + return this.graphManager; + }; + + Layout.prototype.getAllNodes = function () { + return this.graphManager.getAllNodes(); + }; + + Layout.prototype.getAllEdges = function () { + return this.graphManager.getAllEdges(); + }; + + Layout.prototype.getAllNodesToApplyGravitation = function () { + return this.graphManager.getAllNodesToApplyGravitation(); + }; + + Layout.prototype.newGraphManager = function () { + var gm = new LGraphManager(this); + this.graphManager = gm; + return gm; + }; + + Layout.prototype.newGraph = function (vGraph) { + return new LGraph(null, this.graphManager, vGraph); + }; + + Layout.prototype.newNode = function (vNode) { + return new LNode(this.graphManager, vNode); + }; + + Layout.prototype.newEdge = function (vEdge) { + return new LEdge(null, null, vEdge); + }; + + Layout.prototype.checkLayoutSuccess = function () { + return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge(); + }; + + Layout.prototype.runLayout = function () { + this.isLayoutFinished = false; + + if (this.tilingPreLayout) { + this.tilingPreLayout(); + } + + this.initParameters(); + var isLayoutSuccessfull; + + if (this.checkLayoutSuccess()) { + isLayoutSuccessfull = false; + } else { + isLayoutSuccessfull = this.layout(); + } + + if (LayoutConstants.ANIMATE === 'during') { + // If this is a 'during' layout animation. Layout is not finished yet. + // We need to perform these in index.js when layout is really finished. + return false; + } + + if (isLayoutSuccessfull) { + if (!this.isSubLayout) { + this.doPostLayout(); + } + } + + if (this.tilingPostLayout) { + this.tilingPostLayout(); + } + + this.isLayoutFinished = true; + + return isLayoutSuccessfull; + }; + + /** + * This method performs the operations required after layout. + */ + Layout.prototype.doPostLayout = function () { + //assert !isSubLayout : "Should not be called on sub-layout!"; + // Propagate geometric changes to v-level objects + if (!this.incremental) { + this.transform(); + } + this.update(); + }; + + /** + * This method updates the geometry of the target graph according to + * calculated layout. + */ + Layout.prototype.update2 = function () { + // update bend points + if (this.createBendsAsNeeded) { + this.createBendpointsFromDummyNodes(); + + // reset all edges, since the topology has changed + this.graphManager.resetAllEdges(); + } + + // perform edge, node and root updates if layout is not called + // remotely + if (!this.isRemoteUse) { + var allEdges = this.graphManager.getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + allEdges[i]; + // this.update(edge); + } + var nodes = this.graphManager.getRoot().getNodes(); + for (var i = 0; i < nodes.length; i++) { + nodes[i]; + // this.update(node); + } + + // update root graph + this.update(this.graphManager.getRoot()); + } + }; + + Layout.prototype.update = function (obj) { + if (obj == null) { + this.update2(); + } else if (obj instanceof LNode) { + var node = obj; + if (node.getChild() != null) { + // since node is compound, recursively update child nodes + var nodes = node.getChild().getNodes(); + for (var i = 0; i < nodes.length; i++) { + update(nodes[i]); + } + } + + // if the l-level node is associated with a v-level graph object, + // then it is assumed that the v-level node implements the + // interface Updatable. + if (node.vGraphObject != null) { + // cast to Updatable without any type check + var vNode = node.vGraphObject; + + // call the update method of the interface + vNode.update(node); + } + } else if (obj instanceof LEdge) { + var edge = obj; + // if the l-level edge is associated with a v-level graph object, + // then it is assumed that the v-level edge implements the + // interface Updatable. + + if (edge.vGraphObject != null) { + // cast to Updatable without any type check + var vEdge = edge.vGraphObject; + + // call the update method of the interface + vEdge.update(edge); + } + } else if (obj instanceof LGraph) { + var graph = obj; + // if the l-level graph is associated with a v-level graph object, + // then it is assumed that the v-level object implements the + // interface Updatable. + + if (graph.vGraphObject != null) { + // cast to Updatable without any type check + var vGraph = graph.vGraphObject; + + // call the update method of the interface + vGraph.update(graph); + } + } + }; + + /** + * This method is used to set all layout parameters to default values + * determined at compile time. + */ + Layout.prototype.initParameters = function () { + if (!this.isSubLayout) { + this.layoutQuality = LayoutConstants.QUALITY; + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + } + + if (this.animationDuringLayout) { + this.animationOnLayout = false; + } + }; + + Layout.prototype.transform = function (newLeftTop) { + if (newLeftTop == undefined) { + this.transform(new PointD(0, 0)); + } else { + // create a transformation object (from Eclipse to layout). When an + // inverse transform is applied, we get upper-left coordinate of the + // drawing or the root graph at given input coordinate (some margins + // already included in calculation of left-top). + + var trans = new Transform(); + var leftTop = this.graphManager.getRoot().updateLeftTop(); + + if (leftTop != null) { + trans.setWorldOrgX(newLeftTop.x); + trans.setWorldOrgY(newLeftTop.y); + + trans.setDeviceOrgX(leftTop.x); + trans.setDeviceOrgY(leftTop.y); + + var nodes = this.getAllNodes(); + var node; + + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + node.transform(trans); + } + } + } + }; + + Layout.prototype.positionNodesRandomly = function (graph) { + + if (graph == undefined) { + //assert !this.incremental; + this.positionNodesRandomly(this.getGraphManager().getRoot()); + this.getGraphManager().getRoot().updateBounds(true); + } else { + var lNode; + var childGraph; + + var nodes = graph.getNodes(); + for (var i = 0; i < nodes.length; i++) { + lNode = nodes[i]; + childGraph = lNode.getChild(); + + if (childGraph == null) { + lNode.scatter(); + } else if (childGraph.getNodes().length == 0) { + lNode.scatter(); + } else { + this.positionNodesRandomly(childGraph); + lNode.updateBounds(); + } + } + } + }; + + /** + * This method returns a list of trees where each tree is represented as a + * list of l-nodes. The method returns a list of size 0 when: + * - The graph is not flat or + * - One of the component(s) of the graph is not a tree. + */ + Layout.prototype.getFlatForest = function () { + var flatForest = []; + var isForest = true; + + // Quick reference for all nodes in the graph manager associated with + // this layout. The list should not be changed. + var allNodes = this.graphManager.getRoot().getNodes(); + + // First be sure that the graph is flat + var isFlat = true; + + for (var i = 0; i < allNodes.length; i++) { + if (allNodes[i].getChild() != null) { + isFlat = false; + } + } + + // Return empty forest if the graph is not flat. + if (!isFlat) { + return flatForest; + } + + // Run BFS for each component of the graph. + + var visited = new Set(); + var toBeVisited = []; + var parents = new Map(); + var unProcessedNodes = []; + + unProcessedNodes = unProcessedNodes.concat(allNodes); + + // Each iteration of this loop finds a component of the graph and + // decides whether it is a tree or not. If it is a tree, adds it to the + // forest and continued with the next component. + + while (unProcessedNodes.length > 0 && isForest) { + toBeVisited.push(unProcessedNodes[0]); + + // Start the BFS. Each iteration of this loop visits a node in a + // BFS manner. + while (toBeVisited.length > 0 && isForest) { + //pool operation + var currentNode = toBeVisited[0]; + toBeVisited.splice(0, 1); + visited.add(currentNode); + + // Traverse all neighbors of this node + var neighborEdges = currentNode.getEdges(); + + for (var i = 0; i < neighborEdges.length; i++) { + var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode); + + // If BFS is not growing from this neighbor. + if (parents.get(currentNode) != currentNeighbor) { + // We haven't previously visited this neighbor. + if (!visited.has(currentNeighbor)) { + toBeVisited.push(currentNeighbor); + parents.set(currentNeighbor, currentNode); + } + // Since we have previously visited this neighbor and + // this neighbor is not parent of currentNode, given + // graph contains a component that is not tree, hence + // it is not a forest. + else { + isForest = false; + break; + } + } + } + } + + // The graph contains a component that is not a tree. Empty + // previously found trees. The method will end. + if (!isForest) { + flatForest = []; + } + // Save currently visited nodes as a tree in our forest. Reset + // visited and parents lists. Continue with the next component of + // the graph, if any. + else { + var temp = [].concat(_toConsumableArray(visited)); + flatForest.push(temp); + //flatForest = flatForest.concat(temp); + //unProcessedNodes.removeAll(visited); + for (var i = 0; i < temp.length; i++) { + var value = temp[i]; + var index = unProcessedNodes.indexOf(value); + if (index > -1) { + unProcessedNodes.splice(index, 1); + } + } + visited = new Set(); + parents = new Map(); + } + } + + return flatForest; + }; + + /** + * This method creates dummy nodes (an l-level node with minimal dimensions) + * for the given edge (one per bendpoint). The existing l-level structure + * is updated accordingly. + */ + Layout.prototype.createDummyNodesForBendpoints = function (edge) { + var dummyNodes = []; + var prev = edge.source; + + var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target); + + for (var i = 0; i < edge.bendpoints.length; i++) { + // create new dummy node + var dummyNode = this.newNode(null); + dummyNode.setRect(new Point(0, 0), new Dimension(1, 1)); + + graph.add(dummyNode); + + // create new dummy edge between prev and dummy node + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, dummyNode); + + dummyNodes.add(dummyNode); + prev = dummyNode; + } + + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, edge.target); + + this.edgeToDummyNodes.set(edge, dummyNodes); + + // remove real edge from graph manager if it is inter-graph + if (edge.isInterGraph()) { + this.graphManager.remove(edge); + } + // else, remove the edge from the current graph + else { + graph.remove(edge); + } + + return dummyNodes; + }; + + /** + * This method creates bendpoints for edges from the dummy nodes + * at l-level. + */ + Layout.prototype.createBendpointsFromDummyNodes = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges); + + for (var k = 0; k < edges.length; k++) { + var lEdge = edges[k]; + + if (lEdge.bendpoints.length > 0) { + var path = this.edgeToDummyNodes.get(lEdge); + + for (var i = 0; i < path.length; i++) { + var dummyNode = path[i]; + var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY()); + + // update bendpoint's location according to dummy node + var ebp = lEdge.bendpoints.get(i); + ebp.x = p.x; + ebp.y = p.y; + + // remove the dummy node, dummy edges incident with this + // dummy node is also removed (within the remove method) + dummyNode.getOwner().remove(dummyNode); + } + + // add the real edge to graph + this.graphManager.add(lEdge, lEdge.source, lEdge.target); + } + } + }; + + Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) { + if (minDiv != undefined && maxMul != undefined) { + var value = defaultValue; + + if (sliderValue <= 50) { + var minValue = defaultValue / minDiv; + value -= (defaultValue - minValue) / 50 * (50 - sliderValue); + } else { + var maxValue = defaultValue * maxMul; + value += (maxValue - defaultValue) / 50 * (sliderValue - 50); + } + + return value; + } else { + var a, b; + + if (sliderValue <= 50) { + a = 9.0 * defaultValue / 500.0; + b = defaultValue / 10.0; + } else { + a = 9.0 * defaultValue / 50.0; + b = -8 * defaultValue; + } + + return a * sliderValue + b; + } + }; + + /** + * This method finds and returns the center of the given nodes, assuming + * that the given nodes form a tree in themselves. + */ + Layout.findCenterOfTree = function (nodes) { + var list = []; + list = list.concat(nodes); + + var removedNodes = []; + var remainingDegrees = new Map(); + var foundCenter = false; + var centerNode = null; + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + var degree = node.getNeighborsList().size; + remainingDegrees.set(node, node.getNeighborsList().size); + + if (degree == 1) { + removedNodes.push(node); + } + } + + var tempList = []; + tempList = tempList.concat(removedNodes); + + while (!foundCenter) { + var tempList2 = []; + tempList2 = tempList2.concat(tempList); + tempList = []; + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + + var index = list.indexOf(node); + if (index >= 0) { + list.splice(index, 1); + } + + var neighbours = node.getNeighborsList(); + + neighbours.forEach(function (neighbour) { + if (removedNodes.indexOf(neighbour) < 0) { + var otherDegree = remainingDegrees.get(neighbour); + var newDegree = otherDegree - 1; + + if (newDegree == 1) { + tempList.push(neighbour); + } + + remainingDegrees.set(neighbour, newDegree); + } + }); + } + + removedNodes = removedNodes.concat(tempList); + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + } + + return centerNode; + }; + + /** + * During the coarsening process, this layout may be referenced by two graph managers + * this setter function grants access to change the currently being used graph manager + */ + Layout.prototype.setGraphManager = function (gm) { + this.graphManager = gm; + }; + + module.exports = Layout; + + /***/ }), + /* 16 */ + /***/ (function(module, exports, __webpack_require__) { + + + function RandomSeed() {} + // adapted from: https://stackoverflow.com/a/19303725 + RandomSeed.seed = 1; + RandomSeed.x = 0; + + RandomSeed.nextDouble = function () { + RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000; + return RandomSeed.x - Math.floor(RandomSeed.x); + }; + + module.exports = RandomSeed; + + /***/ }), + /* 17 */ + /***/ (function(module, exports, __webpack_require__) { + + + var PointD = __webpack_require__(4); + + function Transform(x, y) { + this.lworldOrgX = 0.0; + this.lworldOrgY = 0.0; + this.ldeviceOrgX = 0.0; + this.ldeviceOrgY = 0.0; + this.lworldExtX = 1.0; + this.lworldExtY = 1.0; + this.ldeviceExtX = 1.0; + this.ldeviceExtY = 1.0; + } + + Transform.prototype.getWorldOrgX = function () { + return this.lworldOrgX; + }; + + Transform.prototype.setWorldOrgX = function (wox) { + this.lworldOrgX = wox; + }; + + Transform.prototype.getWorldOrgY = function () { + return this.lworldOrgY; + }; + + Transform.prototype.setWorldOrgY = function (woy) { + this.lworldOrgY = woy; + }; + + Transform.prototype.getWorldExtX = function () { + return this.lworldExtX; + }; + + Transform.prototype.setWorldExtX = function (wex) { + this.lworldExtX = wex; + }; + + Transform.prototype.getWorldExtY = function () { + return this.lworldExtY; + }; + + Transform.prototype.setWorldExtY = function (wey) { + this.lworldExtY = wey; + }; + + /* Device related */ + + Transform.prototype.getDeviceOrgX = function () { + return this.ldeviceOrgX; + }; + + Transform.prototype.setDeviceOrgX = function (dox) { + this.ldeviceOrgX = dox; + }; + + Transform.prototype.getDeviceOrgY = function () { + return this.ldeviceOrgY; + }; + + Transform.prototype.setDeviceOrgY = function (doy) { + this.ldeviceOrgY = doy; + }; + + Transform.prototype.getDeviceExtX = function () { + return this.ldeviceExtX; + }; + + Transform.prototype.setDeviceExtX = function (dex) { + this.ldeviceExtX = dex; + }; + + Transform.prototype.getDeviceExtY = function () { + return this.ldeviceExtY; + }; + + Transform.prototype.setDeviceExtY = function (dey) { + this.ldeviceExtY = dey; + }; + + Transform.prototype.transformX = function (x) { + var xDevice = 0.0; + var worldExtX = this.lworldExtX; + if (worldExtX != 0.0) { + xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX; + } + + return xDevice; + }; + + Transform.prototype.transformY = function (y) { + var yDevice = 0.0; + var worldExtY = this.lworldExtY; + if (worldExtY != 0.0) { + yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY; + } + + return yDevice; + }; + + Transform.prototype.inverseTransformX = function (x) { + var xWorld = 0.0; + var deviceExtX = this.ldeviceExtX; + if (deviceExtX != 0.0) { + xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX; + } + + return xWorld; + }; + + Transform.prototype.inverseTransformY = function (y) { + var yWorld = 0.0; + var deviceExtY = this.ldeviceExtY; + if (deviceExtY != 0.0) { + yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY; + } + return yWorld; + }; + + Transform.prototype.inverseTransformPoint = function (inPoint) { + var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y)); + return outPoint; + }; + + module.exports = Transform; + + /***/ }), + /* 18 */ + /***/ (function(module, exports, __webpack_require__) { + + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var Layout = __webpack_require__(15); + var FDLayoutConstants = __webpack_require__(7); + var LayoutConstants = __webpack_require__(0); + var IGeometry = __webpack_require__(8); + var IMath = __webpack_require__(9); + + function FDLayout() { + Layout.call(this); + + this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100; + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.totalDisplacement = 0.0; + this.oldTotalDisplacement = 0.0; + this.maxIterations = FDLayoutConstants.MAX_ITERATIONS; + } + + FDLayout.prototype = Object.create(Layout.prototype); + + for (var prop in Layout) { + FDLayout[prop] = Layout[prop]; + } + + FDLayout.prototype.initParameters = function () { + Layout.prototype.initParameters.call(this, arguments); + + this.totalIterations = 0; + this.notAnimatedIterations = 0; + + this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION; + + this.grid = []; + }; + + FDLayout.prototype.calcIdealEdgeLengths = function () { + var edge; + var lcaDepth; + var source; + var target; + var sizeOfSourceInLca; + var sizeOfTargetInLca; + + var allEdges = this.getGraphManager().getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + + edge.idealLength = this.idealEdgeLength; + + if (edge.isInterGraph) { + source = edge.getSource(); + target = edge.getTarget(); + + sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize(); + sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize(); + + if (this.useSmartIdealEdgeLengthCalculation) { + edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE; + } + + lcaDepth = edge.getLca().getInclusionTreeDepth(); + + edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth); + } + } + }; + + FDLayout.prototype.initSpringEmbedder = function () { + + var s = this.getAllNodes().length; + if (this.incremental) { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL; + } else { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } else { + this.coolingFactor = 1.0; + } + this.initialCoolingFactor = this.coolingFactor; + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT; + } + + this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations); + + this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length; + + this.repulsionRange = this.calcRepulsionRange(); + }; + + FDLayout.prototype.calcSpringForces = function () { + var lEdges = this.getAllEdges(); + var edge; + + for (var i = 0; i < lEdges.length; i++) { + edge = lEdges[i]; + + this.calcSpringForce(edge, edge.idealLength); + } + }; + + FDLayout.prototype.calcRepulsionForces = function () { + var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + var i, j; + var nodeA, nodeB; + var lNodes = this.getAllNodes(); + var processedNodeSet; + + if (this.useFRGridVariant) { + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) { + this.updateGrid(); + } + + processedNodeSet = new Set(); + + // calculate repulsion forces between each nodes and its surrounding + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate); + processedNodeSet.add(nodeA); + } + } else { + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + + for (j = i + 1; j < lNodes.length; j++) { + nodeB = lNodes[j]; + + // If both nodes are not members of the same graph, skip. + if (nodeA.getOwner() != nodeB.getOwner()) { + continue; + } + + this.calcRepulsionForce(nodeA, nodeB); + } + } + } + }; + + FDLayout.prototype.calcGravitationalForces = function () { + var node; + var lNodes = this.getAllNodesToApplyGravitation(); + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + this.calcGravitationalForce(node); + } + }; + + FDLayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.move(); + } + }; + + FDLayout.prototype.calcSpringForce = function (edge, idealLength) { + var sourceNode = edge.getSource(); + var targetNode = edge.getTarget(); + + var length; + var springForce; + var springForceX; + var springForceY; + + // Update edge length + if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) { + edge.updateLengthSimple(); + } else { + edge.updateLength(); + + if (edge.isOverlapingSourceAndTarget) { + return; + } + } + + length = edge.getLength(); + + if (length == 0) return; + + // Calculate spring forces + springForce = this.springConstant * (length - idealLength); + + // Project force onto x and y axes + springForceX = springForce * (edge.lengthX / length); + springForceY = springForce * (edge.lengthY / length); + + // Apply forces on the end nodes + sourceNode.springForceX += springForceX; + sourceNode.springForceY += springForceY; + targetNode.springForceX -= springForceX; + targetNode.springForceY -= springForceY; + }; + + FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) { + var rectA = nodeA.getRect(); + var rectB = nodeB.getRect(); + var overlapAmount = new Array(2); + var clipPoints = new Array(4); + var distanceX; + var distanceY; + var distanceSquared; + var distance; + var repulsionForce; + var repulsionForceX; + var repulsionForceY; + + if (rectA.intersects(rectB)) // two nodes overlap + { + // calculate separation amount in x and y directions + IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0); + + repulsionForceX = 2 * overlapAmount[0]; + repulsionForceY = 2 * overlapAmount[1]; + + var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); + + // Apply forces on the two nodes + nodeA.repulsionForceX -= childrenConstant * repulsionForceX; + nodeA.repulsionForceY -= childrenConstant * repulsionForceY; + nodeB.repulsionForceX += childrenConstant * repulsionForceX; + nodeB.repulsionForceY += childrenConstant * repulsionForceY; + } else // no overlap + { + // calculate distance + + if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) // simply base repulsion on distance of node centers + { + distanceX = rectB.getCenterX() - rectA.getCenterX(); + distanceY = rectB.getCenterY() - rectA.getCenterY(); + } else // use clipping points + { + IGeometry.getIntersection(rectA, rectB, clipPoints); + + distanceX = clipPoints[2] - clipPoints[0]; + distanceY = clipPoints[3] - clipPoints[1]; + } + + // No repulsion range. FR grid variant should take care of this. + if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + distanceSquared = distanceX * distanceX + distanceY * distanceY; + distance = Math.sqrt(distanceSquared); + + repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; + + // Project force onto x and y axes + repulsionForceX = repulsionForce * distanceX / distance; + repulsionForceY = repulsionForce * distanceY / distance; + + // Apply forces on the two nodes + nodeA.repulsionForceX -= repulsionForceX; + nodeA.repulsionForceY -= repulsionForceY; + nodeB.repulsionForceX += repulsionForceX; + nodeB.repulsionForceY += repulsionForceY; + } + }; + + FDLayout.prototype.calcGravitationalForce = function (node) { + var ownerGraph; + var ownerCenterX; + var ownerCenterY; + var distanceX; + var distanceY; + var absDistanceX; + var absDistanceY; + var estimatedSize; + ownerGraph = node.getOwner(); + + ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2; + ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2; + distanceX = node.getCenterX() - ownerCenterX; + distanceY = node.getCenterY() - ownerCenterY; + absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; + absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; + + if (node.getOwner() == this.graphManager.getRoot()) // in the root graph + { + estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX; + node.gravitationForceY = -this.gravityConstant * distanceY; + } + } else // inside a compound + { + estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant; + node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant; + } + } + }; + + FDLayout.prototype.isConverged = function () { + var converged; + var oscilating = false; + + if (this.totalIterations > this.maxIterations / 3) { + oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2; + } + + converged = this.totalDisplacement < this.totalDisplacementThreshold; + + this.oldTotalDisplacement = this.totalDisplacement; + + return converged || oscilating; + }; + + FDLayout.prototype.animate = function () { + if (this.animationDuringLayout && !this.isSubLayout) { + if (this.notAnimatedIterations == this.animationPeriod) { + this.update(); + this.notAnimatedIterations = 0; + } else { + this.notAnimatedIterations++; + } + } + }; + + //This method calculates the number of children (weight) for all nodes + FDLayout.prototype.calcNoOfChildrenForAllNodes = function () { + var node; + var allNodes = this.graphManager.getAllNodes(); + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + node.noOfChildren = node.getNoOfChildren(); + } + }; + + // ----------------------------------------------------------------------------- + // Section: FR-Grid Variant Repulsion Force Calculation + // ----------------------------------------------------------------------------- + + FDLayout.prototype.calcGrid = function (graph) { + + var sizeX = 0; + var sizeY = 0; + + sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange)); + sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange)); + + var grid = new Array(sizeX); + + for (var i = 0; i < sizeX; i++) { + grid[i] = new Array(sizeY); + } + + for (var i = 0; i < sizeX; i++) { + for (var j = 0; j < sizeY; j++) { + grid[i][j] = new Array(); + } + } + + return grid; + }; + + FDLayout.prototype.addNodeToGrid = function (v, left, top) { + + var startX = 0; + var finishX = 0; + var startY = 0; + var finishY = 0; + + startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange)); + finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange)); + startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange)); + finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange)); + + for (var i = startX; i <= finishX; i++) { + for (var j = startY; j <= finishY; j++) { + this.grid[i][j].push(v); + v.setGridCoordinates(startX, finishX, startY, finishY); + } + } + }; + + FDLayout.prototype.updateGrid = function () { + var i; + var nodeA; + var lNodes = this.getAllNodes(); + + this.grid = this.calcGrid(this.graphManager.getRoot()); + + // put all nodes to proper grid cells + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop()); + } + }; + + FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) { + + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) { + var surrounding = new Set(); + nodeA.surrounding = new Array(); + var nodeB; + var grid = this.grid; + + for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) { + for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) { + if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) { + for (var k = 0; k < grid[i][j].length; k++) { + nodeB = grid[i][j][k]; + + // If both nodes are not members of the same graph, + // or both nodes are the same, skip. + if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) { + continue; + } + + // check if the repulsion force between + // nodeA and nodeB has already been calculated + if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) { + var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2); + var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2); + + // if the distance between nodeA and nodeB + // is less then calculation range + if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) { + //then add nodeB to surrounding of nodeA + surrounding.add(nodeB); + } + } + } + } + } + } + + nodeA.surrounding = [].concat(_toConsumableArray(surrounding)); + } + for (i = 0; i < nodeA.surrounding.length; i++) { + this.calcRepulsionForce(nodeA, nodeA.surrounding[i]); + } + }; + + FDLayout.prototype.calcRepulsionRange = function () { + return 0.0; + }; + + module.exports = FDLayout; + + /***/ }), + /* 19 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LEdge = __webpack_require__(1); + var FDLayoutConstants = __webpack_require__(7); + + function FDLayoutEdge(source, target, vEdge) { + LEdge.call(this, source, target, vEdge); + this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + } + + FDLayoutEdge.prototype = Object.create(LEdge.prototype); + + for (var prop in LEdge) { + FDLayoutEdge[prop] = LEdge[prop]; + } + + module.exports = FDLayoutEdge; + + /***/ }), + /* 20 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LNode = __webpack_require__(3); + + function FDLayoutNode(gm, loc, size, vNode) { + // alternative constructor is handled inside LNode + LNode.call(this, gm, loc, size, vNode); + //Spring, repulsion and gravitational forces acting on this node + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + //Amount by which this node is to be moved in this iteration + this.displacementX = 0; + this.displacementY = 0; + + //Start and finish grid coordinates that this node is fallen into + this.startX = 0; + this.finishX = 0; + this.startY = 0; + this.finishY = 0; + + //Geometric neighbors of this node + this.surrounding = []; + } + + FDLayoutNode.prototype = Object.create(LNode.prototype); + + for (var prop in LNode) { + FDLayoutNode[prop] = LNode[prop]; + } + + FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) { + this.startX = _startX; + this.finishX = _finishX; + this.startY = _startY; + this.finishY = _finishY; + }; + + module.exports = FDLayoutNode; + + /***/ }), + /* 21 */ + /***/ (function(module, exports, __webpack_require__) { + + + function DimensionD(width, height) { + this.width = 0; + this.height = 0; + if (width !== null && height !== null) { + this.height = height; + this.width = width; + } + } + + DimensionD.prototype.getWidth = function () { + return this.width; + }; + + DimensionD.prototype.setWidth = function (width) { + this.width = width; + }; + + DimensionD.prototype.getHeight = function () { + return this.height; + }; + + DimensionD.prototype.setHeight = function (height) { + this.height = height; + }; + + module.exports = DimensionD; + + /***/ }), + /* 22 */ + /***/ (function(module, exports, __webpack_require__) { + + + var UniqueIDGeneretor = __webpack_require__(14); + + function HashMap() { + this.map = {}; + this.keys = []; + } + + HashMap.prototype.put = function (key, value) { + var theId = UniqueIDGeneretor.createID(key); + if (!this.contains(theId)) { + this.map[theId] = value; + this.keys.push(key); + } + }; + + HashMap.prototype.contains = function (key) { + UniqueIDGeneretor.createID(key); + return this.map[key] != null; + }; + + HashMap.prototype.get = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[theId]; + }; + + HashMap.prototype.keySet = function () { + return this.keys; + }; + + module.exports = HashMap; + + /***/ }), + /* 23 */ + /***/ (function(module, exports, __webpack_require__) { + + + var UniqueIDGeneretor = __webpack_require__(14); + + function HashSet() { + this.set = {}; + } + + HashSet.prototype.add = function (obj) { + var theId = UniqueIDGeneretor.createID(obj); + if (!this.contains(theId)) this.set[theId] = obj; + }; + + HashSet.prototype.remove = function (obj) { + delete this.set[UniqueIDGeneretor.createID(obj)]; + }; + + HashSet.prototype.clear = function () { + this.set = {}; + }; + + HashSet.prototype.contains = function (obj) { + return this.set[UniqueIDGeneretor.createID(obj)] == obj; + }; + + HashSet.prototype.isEmpty = function () { + return this.size() === 0; + }; + + HashSet.prototype.size = function () { + return Object.keys(this.set).length; + }; + + //concats this.set to the given list + HashSet.prototype.addAllTo = function (list) { + var keys = Object.keys(this.set); + var length = keys.length; + for (var i = 0; i < length; i++) { + list.push(this.set[keys[i]]); + } + }; + + HashSet.prototype.size = function () { + return Object.keys(this.set).length; + }; + + HashSet.prototype.addAll = function (list) { + var s = list.length; + for (var i = 0; i < s; i++) { + var v = list[i]; + this.add(v); + } + }; + + module.exports = HashSet; + + /***/ }), + /* 24 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * A classic Quicksort algorithm with Hoare's partition + * - Works also on LinkedList objects + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + + var LinkedList = __webpack_require__(11); + + var Quicksort = function () { + function Quicksort(A, compareFunction) { + _classCallCheck(this, Quicksort); + + if (compareFunction !== null || compareFunction !== undefined) this.compareFunction = this._defaultCompareFunction; + + var length = void 0; + if (A instanceof LinkedList) length = A.size();else length = A.length; + + this._quicksort(A, 0, length - 1); + } + + _createClass(Quicksort, [{ + key: '_quicksort', + value: function _quicksort(A, p, r) { + if (p < r) { + var q = this._partition(A, p, r); + this._quicksort(A, p, q); + this._quicksort(A, q + 1, r); + } + } + }, { + key: '_partition', + value: function _partition(A, p, r) { + var x = this._get(A, p); + var i = p; + var j = r; + while (true) { + while (this.compareFunction(x, this._get(A, j))) { + j--; + }while (this.compareFunction(this._get(A, i), x)) { + i++; + }if (i < j) { + this._swap(A, i, j); + i++; + j--; + } else return j; + } + } + }, { + key: '_get', + value: function _get(object, index) { + if (object instanceof LinkedList) return object.get_object_at(index);else return object[index]; + } + }, { + key: '_set', + value: function _set(object, index, value) { + if (object instanceof LinkedList) object.set_object_at(index, value);else object[index] = value; + } + }, { + key: '_swap', + value: function _swap(A, i, j) { + var temp = this._get(A, i); + this._set(A, i, this._get(A, j)); + this._set(A, j, temp); + } + }, { + key: '_defaultCompareFunction', + value: function _defaultCompareFunction(a, b) { + return b > a; + } + }]); + + return Quicksort; + }(); + + module.exports = Quicksort; + + /***/ }), + /* 25 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string + * sequences by S.B.Needleman and C.D.Wunsch (1970). + * + * Aside from the inputs, you can assign the scores for, + * - Match: The two characters at the current index are same. + * - Mismatch: The two characters at the current index are different. + * - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string. + */ + + var NeedlemanWunsch = function () { + function NeedlemanWunsch(sequence1, sequence2) { + var match_score = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + var mismatch_penalty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1; + var gap_penalty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + + _classCallCheck(this, NeedlemanWunsch); + + this.sequence1 = sequence1; + this.sequence2 = sequence2; + this.match_score = match_score; + this.mismatch_penalty = mismatch_penalty; + this.gap_penalty = gap_penalty; + + // Just the remove redundancy + this.iMax = sequence1.length + 1; + this.jMax = sequence2.length + 1; + + // Grid matrix of scores + this.grid = new Array(this.iMax); + for (var i = 0; i < this.iMax; i++) { + this.grid[i] = new Array(this.jMax); + + for (var j = 0; j < this.jMax; j++) { + this.grid[i][j] = 0; + } + } + + // Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions) + this.tracebackGrid = new Array(this.iMax); + for (var _i = 0; _i < this.iMax; _i++) { + this.tracebackGrid[_i] = new Array(this.jMax); + + for (var _j = 0; _j < this.jMax; _j++) { + this.tracebackGrid[_i][_j] = [null, null, null]; + } + } + + // The aligned sequences (return multiple possibilities) + this.alignments = []; + + // Final alignment score + this.score = -1; + + // Calculate scores and tracebacks + this.computeGrids(); + } + + _createClass(NeedlemanWunsch, [{ + key: "getScore", + value: function getScore() { + return this.score; + } + }, { + key: "getAlignments", + value: function getAlignments() { + return this.alignments; + } + + // Main dynamic programming procedure + + }, { + key: "computeGrids", + value: function computeGrids() { + // Fill in the first row + for (var j = 1; j < this.jMax; j++) { + this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty; + this.tracebackGrid[0][j] = [false, false, true]; + } + + // Fill in the first column + for (var i = 1; i < this.iMax; i++) { + this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty; + this.tracebackGrid[i][0] = [false, true, false]; + } + + // Fill the rest of the grid + for (var _i2 = 1; _i2 < this.iMax; _i2++) { + for (var _j2 = 1; _j2 < this.jMax; _j2++) { + // Find the max score(s) among [`Diag`, `Up`, `Left`] + var diag = void 0; + if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty; + + var up = this.grid[_i2 - 1][_j2] + this.gap_penalty; + var left = this.grid[_i2][_j2 - 1] + this.gap_penalty; + + // If there exists multiple max values, capture them for multiple paths + var maxOf = [diag, up, left]; + var indices = this.arrayAllMaxIndexes(maxOf); + + // Update Grids + this.grid[_i2][_j2] = maxOf[indices[0]]; + this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)]; + } + } + + // Update alignment score + this.score = this.grid[this.iMax - 1][this.jMax - 1]; + } + + // Gets all possible valid sequence combinations + + }, { + key: "alignmentTraceback", + value: function alignmentTraceback() { + var inProcessAlignments = []; + + inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length], + seq1: "", + seq2: "" + }); + + while (inProcessAlignments[0]) { + var current = inProcessAlignments[0]; + var directions = this.tracebackGrid[current.pos[0]][current.pos[1]]; + + if (directions[0]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1] - 1], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + if (directions[1]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1]], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: '-' + current.seq2 + }); + } + if (directions[2]) { + inProcessAlignments.push({ pos: [current.pos[0], current.pos[1] - 1], + seq1: '-' + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + + if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({ sequence1: current.seq1, + sequence2: current.seq2 + }); + + inProcessAlignments.shift(); + } + + return this.alignments; + } + + // Helper Functions + + }, { + key: "getAllIndexes", + value: function getAllIndexes(arr, val) { + var indexes = [], + i = -1; + while ((i = arr.indexOf(val, i + 1)) !== -1) { + indexes.push(i); + } + return indexes; + } + }, { + key: "arrayAllMaxIndexes", + value: function arrayAllMaxIndexes(array) { + return this.getAllIndexes(array, Math.max.apply(null, array)); + } + }]); + + return NeedlemanWunsch; + }(); + + module.exports = NeedlemanWunsch; + + /***/ }), + /* 26 */ + /***/ (function(module, exports, __webpack_require__) { + + + var layoutBase = function layoutBase() { + return; + }; + + layoutBase.FDLayout = __webpack_require__(18); + layoutBase.FDLayoutConstants = __webpack_require__(7); + layoutBase.FDLayoutEdge = __webpack_require__(19); + layoutBase.FDLayoutNode = __webpack_require__(20); + layoutBase.DimensionD = __webpack_require__(21); + layoutBase.HashMap = __webpack_require__(22); + layoutBase.HashSet = __webpack_require__(23); + layoutBase.IGeometry = __webpack_require__(8); + layoutBase.IMath = __webpack_require__(9); + layoutBase.Integer = __webpack_require__(10); + layoutBase.Point = __webpack_require__(12); + layoutBase.PointD = __webpack_require__(4); + layoutBase.RandomSeed = __webpack_require__(16); + layoutBase.RectangleD = __webpack_require__(13); + layoutBase.Transform = __webpack_require__(17); + layoutBase.UniqueIDGeneretor = __webpack_require__(14); + layoutBase.Quicksort = __webpack_require__(24); + layoutBase.LinkedList = __webpack_require__(11); + layoutBase.LGraphObject = __webpack_require__(2); + layoutBase.LGraph = __webpack_require__(5); + layoutBase.LEdge = __webpack_require__(1); + layoutBase.LGraphManager = __webpack_require__(6); + layoutBase.LNode = __webpack_require__(3); + layoutBase.Layout = __webpack_require__(15); + layoutBase.LayoutConstants = __webpack_require__(0); + layoutBase.NeedlemanWunsch = __webpack_require__(25); + + module.exports = layoutBase; + + /***/ }), + /* 27 */ + /***/ (function(module, exports, __webpack_require__) { + + + function Emitter() { + this.listeners = []; + } + + var p = Emitter.prototype; + + p.addListener = function (event, callback) { + this.listeners.push({ + event: event, + callback: callback + }); + }; + + p.removeListener = function (event, callback) { + for (var i = this.listeners.length; i >= 0; i--) { + var l = this.listeners[i]; + + if (l.event === event && l.callback === callback) { + this.listeners.splice(i, 1); + } + } + }; + + p.emit = function (event, data) { + for (var i = 0; i < this.listeners.length; i++) { + var l = this.listeners[i]; + + if (event === l.event) { + l.callback(data); + } + } + }; + + module.exports = Emitter; + + /***/ }) + /******/ ]); + }); + } (layoutBase)); + return layoutBase.exports; +} + +var hasRequiredCoseBase; + +function requireCoseBase () { + if (hasRequiredCoseBase) return coseBase.exports; + hasRequiredCoseBase = 1; + (function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(requireLayoutBase()); + })(commonjsGlobal$1, function(__WEBPACK_EXTERNAL_MODULE_0__) { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 7); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants; + + function CoSEConstants() {} + + //CoSEConstants inherits static props in FDLayoutConstants + for (var prop in FDLayoutConstants) { + CoSEConstants[prop] = FDLayoutConstants[prop]; + } + + CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false; + CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60; + CoSEConstants.TILE = true; + CoSEConstants.TILING_PADDING_VERTICAL = 10; + CoSEConstants.TILING_PADDING_HORIZONTAL = 10; + CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout + + module.exports = CoSEConstants; + + /***/ }), + /* 2 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutEdge = __webpack_require__(0).FDLayoutEdge; + + function CoSEEdge(source, target, vEdge) { + FDLayoutEdge.call(this, source, target, vEdge); + } + + CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype); + for (var prop in FDLayoutEdge) { + CoSEEdge[prop] = FDLayoutEdge[prop]; + } + + module.exports = CoSEEdge; + + /***/ }), + /* 3 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraph = __webpack_require__(0).LGraph; + + function CoSEGraph(parent, graphMgr, vGraph) { + LGraph.call(this, parent, graphMgr, vGraph); + } + + CoSEGraph.prototype = Object.create(LGraph.prototype); + for (var prop in LGraph) { + CoSEGraph[prop] = LGraph[prop]; + } + + module.exports = CoSEGraph; + + /***/ }), + /* 4 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphManager = __webpack_require__(0).LGraphManager; + + function CoSEGraphManager(layout) { + LGraphManager.call(this, layout); + } + + CoSEGraphManager.prototype = Object.create(LGraphManager.prototype); + for (var prop in LGraphManager) { + CoSEGraphManager[prop] = LGraphManager[prop]; + } + + module.exports = CoSEGraphManager; + + /***/ }), + /* 5 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutNode = __webpack_require__(0).FDLayoutNode; + var IMath = __webpack_require__(0).IMath; + + function CoSENode(gm, loc, size, vNode) { + FDLayoutNode.call(this, gm, loc, size, vNode); + } + + CoSENode.prototype = Object.create(FDLayoutNode.prototype); + for (var prop in FDLayoutNode) { + CoSENode[prop] = FDLayoutNode[prop]; + } + + CoSENode.prototype.move = function () { + var layout = this.graphManager.getLayout(); + this.displacementX = layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren; + this.displacementY = layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren; + + if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX); + } + + if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY); + } + + // a simple node, just move it + if (this.child == null) { + this.moveBy(this.displacementX, this.displacementY); + } + // an empty compound node, again just move it + else if (this.child.getNodes().length == 0) { + this.moveBy(this.displacementX, this.displacementY); + } + // non-empty compound node, propogate movement to children as well + else { + this.propogateDisplacementToChildren(this.displacementX, this.displacementY); + } + + layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY); + + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + this.displacementX = 0; + this.displacementY = 0; + }; + + CoSENode.prototype.propogateDisplacementToChildren = function (dX, dY) { + var nodes = this.getChild().getNodes(); + var node; + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + if (node.getChild() == null) { + node.moveBy(dX, dY); + node.displacementX += dX; + node.displacementY += dY; + } else { + node.propogateDisplacementToChildren(dX, dY); + } + } + }; + + CoSENode.prototype.setPred1 = function (pred1) { + this.pred1 = pred1; + }; + + CoSENode.prototype.getPred1 = function () { + return pred1; + }; + + CoSENode.prototype.getPred2 = function () { + return pred2; + }; + + CoSENode.prototype.setNext = function (next) { + this.next = next; + }; + + CoSENode.prototype.getNext = function () { + return next; + }; + + CoSENode.prototype.setProcessed = function (processed) { + this.processed = processed; + }; + + CoSENode.prototype.isProcessed = function () { + return processed; + }; + + module.exports = CoSENode; + + /***/ }), + /* 6 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayout = __webpack_require__(0).FDLayout; + var CoSEGraphManager = __webpack_require__(4); + var CoSEGraph = __webpack_require__(3); + var CoSENode = __webpack_require__(5); + var CoSEEdge = __webpack_require__(2); + var CoSEConstants = __webpack_require__(1); + var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants; + var LayoutConstants = __webpack_require__(0).LayoutConstants; + var Point = __webpack_require__(0).Point; + var PointD = __webpack_require__(0).PointD; + var Layout = __webpack_require__(0).Layout; + var Integer = __webpack_require__(0).Integer; + var IGeometry = __webpack_require__(0).IGeometry; + var LGraph = __webpack_require__(0).LGraph; + var Transform = __webpack_require__(0).Transform; + + function CoSELayout() { + FDLayout.call(this); + + this.toBeTiled = {}; // Memorize if a node is to be tiled or is tiled + } + + CoSELayout.prototype = Object.create(FDLayout.prototype); + + for (var prop in FDLayout) { + CoSELayout[prop] = FDLayout[prop]; + } + + CoSELayout.prototype.newGraphManager = function () { + var gm = new CoSEGraphManager(this); + this.graphManager = gm; + return gm; + }; + + CoSELayout.prototype.newGraph = function (vGraph) { + return new CoSEGraph(null, this.graphManager, vGraph); + }; + + CoSELayout.prototype.newNode = function (vNode) { + return new CoSENode(this.graphManager, vNode); + }; + + CoSELayout.prototype.newEdge = function (vEdge) { + return new CoSEEdge(null, null, vEdge); + }; + + CoSELayout.prototype.initParameters = function () { + FDLayout.prototype.initParameters.call(this, arguments); + if (!this.isSubLayout) { + if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) { + this.idealEdgeLength = 10; + } else { + this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH; + } + + this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + + // variables for tree reduction support + this.prunedNodesAll = []; + this.growTreeIterations = 0; + this.afterGrowthIterations = 0; + this.isTreeGrowing = false; + this.isGrowthFinished = false; + + // variables for cooling + this.coolingCycle = 0; + this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD; + this.finalTemperature = FDLayoutConstants.CONVERGENCE_CHECK_PERIOD / this.maxIterations; + this.coolingAdjuster = 1; + } + }; + + CoSELayout.prototype.layout = function () { + var createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + if (createBendsAsNeeded) { + this.createBendpoints(); + this.graphManager.resetAllEdges(); + } + + this.level = 0; + return this.classicLayout(); + }; + + CoSELayout.prototype.classicLayout = function () { + this.nodesWithGravity = this.calculateNodesToApplyGravitationTo(); + this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity); + this.calcNoOfChildrenForAllNodes(); + this.graphManager.calcLowestCommonAncestors(); + this.graphManager.calcInclusionTreeDepths(); + this.graphManager.getRoot().calcEstimatedSize(); + this.calcIdealEdgeLengths(); + + if (!this.incremental) { + var forest = this.getFlatForest(); + + // The graph associated with this layout is flat and a forest + if (forest.length > 0) { + this.positionNodesRadially(forest); + } + // The graph associated with this layout is not flat or a forest + else { + // Reduce the trees when incremental mode is not enabled and graph is not a forest + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.positionNodesRandomly(); + } + } else { + if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) { + // Reduce the trees in incremental mode if only this constant is set to true + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + } + } + + this.initSpringEmbedder(); + this.runSpringEmbedder(); + + return true; + }; + + CoSELayout.prototype.tick = function () { + this.totalIterations++; + + if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.isConverged()) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + this.coolingCycle++; + + if (this.layoutQuality == 0) { + // quality - "draft" + this.coolingAdjuster = this.coolingCycle; + } else if (this.layoutQuality == 1) { + // quality - "default" + this.coolingAdjuster = this.coolingCycle / 3; + } + + // cooling schedule is based on http://www.btluke.com/simanf1.html -> cooling schedule 3 + this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature); + this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor)); + } + // Operations while tree is growing again + if (this.isTreeGrowing) { + if (this.growTreeIterations % 10 == 0) { + if (this.prunedNodesAll.length > 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + this.growTree(this.prunedNodesAll); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.graphManager.updateBounds(); + this.updateGrid(); + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + } else { + this.isTreeGrowing = false; + this.isGrowthFinished = true; + } + } + this.growTreeIterations++; + } + // Operations after growth is finished + if (this.isGrowthFinished) { + if (this.isConverged()) { + return true; + } + if (this.afterGrowthIterations % 10 == 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + } + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100); + this.afterGrowthIterations++; + } + + var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished; + var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished; + + this.totalDisplacement = 0; + this.graphManager.updateBounds(); + this.calcSpringForces(); + this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate); + this.calcGravitationalForces(); + this.moveNodes(); + this.animate(); + + return false; // Layout is not ended yet return false + }; + + CoSELayout.prototype.getPositionsData = function () { + var allNodes = this.graphManager.getAllNodes(); + var pData = {}; + for (var i = 0; i < allNodes.length; i++) { + var rect = allNodes[i].rect; + var id = allNodes[i].id; + pData[id] = { + id: id, + x: rect.getCenterX(), + y: rect.getCenterY(), + w: rect.width, + h: rect.height + }; + } + + return pData; + }; + + CoSELayout.prototype.runSpringEmbedder = function () { + this.initialAnimationPeriod = 25; + this.animationPeriod = this.initialAnimationPeriod; + var layoutEnded = false; + + // If aminate option is 'during' signal that layout is supposed to start iterating + if (FDLayoutConstants.ANIMATE === 'during') { + this.emit('layoutstarted'); + } else { + // If aminate option is 'during' tick() function will be called on index.js + while (!layoutEnded) { + layoutEnded = this.tick(); + } + + this.graphManager.updateBounds(); + } + }; + + CoSELayout.prototype.calculateNodesToApplyGravitationTo = function () { + var nodeList = []; + var graph; + + var graphs = this.graphManager.getGraphs(); + var size = graphs.length; + var i; + for (i = 0; i < size; i++) { + graph = graphs[i]; + + graph.updateConnected(); + + if (!graph.isConnected) { + nodeList = nodeList.concat(graph.getNodes()); + } + } + + return nodeList; + }; + + CoSELayout.prototype.createBendpoints = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + var visited = new Set(); + var i; + for (i = 0; i < edges.length; i++) { + var edge = edges[i]; + + if (!visited.has(edge)) { + var source = edge.getSource(); + var target = edge.getTarget(); + + if (source == target) { + edge.getBendpoints().push(new PointD()); + edge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(edge); + visited.add(edge); + } else { + var edgeList = []; + + edgeList = edgeList.concat(source.getEdgeListToNode(target)); + edgeList = edgeList.concat(target.getEdgeListToNode(source)); + + if (!visited.has(edgeList[0])) { + if (edgeList.length > 1) { + var k; + for (k = 0; k < edgeList.length; k++) { + var multiEdge = edgeList[k]; + multiEdge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(multiEdge); + } + } + edgeList.forEach(function (edge) { + visited.add(edge); + }); + } + } + } + + if (visited.size == edges.length) { + break; + } + } + }; + + CoSELayout.prototype.positionNodesRadially = function (forest) { + // We tile the trees to a grid row by row; first tree starts at (0,0) + var currentStartingPoint = new Point(0, 0); + var numberOfColumns = Math.ceil(Math.sqrt(forest.length)); + var height = 0; + var currentY = 0; + var currentX = 0; + var point = new PointD(0, 0); + + for (var i = 0; i < forest.length; i++) { + if (i % numberOfColumns == 0) { + // Start of a new row, make the x coordinate 0, increment the + // y coordinate with the max height of the previous row + currentX = 0; + currentY = height; + + if (i != 0) { + currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION; + } + + height = 0; + } + + var tree = forest[i]; + + // Find the center of the tree + var centerNode = Layout.findCenterOfTree(tree); + + // Set the staring point of the next tree + currentStartingPoint.x = currentX; + currentStartingPoint.y = currentY; + + // Do a radial layout starting with the center + point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint); + + if (point.y > height) { + height = Math.floor(point.y); + } + + currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION); + } + + this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2)); + }; + + CoSELayout.radialLayout = function (tree, centerNode, startingPoint) { + var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION); + CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep); + var bounds = LGraph.calculateBounds(tree); + + var transform = new Transform(); + transform.setDeviceOrgX(bounds.getMinX()); + transform.setDeviceOrgY(bounds.getMinY()); + transform.setWorldOrgX(startingPoint.x); + transform.setWorldOrgY(startingPoint.y); + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + node.transform(transform); + } + + var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY()); + + return transform.inverseTransformPoint(bottomRight); + }; + + CoSELayout.branchRadialLayout = function (node, parentOfNode, startAngle, endAngle, distance, radialSeparation) { + // First, position this node by finding its angle. + var halfInterval = (endAngle - startAngle + 1) / 2; + + if (halfInterval < 0) { + halfInterval += 180; + } + + var nodeAngle = (halfInterval + startAngle) % 360; + var teta = nodeAngle * IGeometry.TWO_PI / 360; + var x_ = distance * Math.cos(teta); + var y_ = distance * Math.sin(teta); + + node.setCenter(x_, y_); + + // Traverse all neighbors of this node and recursively call this + // function. + var neighborEdges = []; + neighborEdges = neighborEdges.concat(node.getEdges()); + var childCount = neighborEdges.length; + + if (parentOfNode != null) { + childCount--; + } + + var branchCount = 0; + + var incEdgesCount = neighborEdges.length; + var startIndex; + + var edges = node.getEdgesBetween(parentOfNode); + + // If there are multiple edges, prune them until there remains only one + // edge. + while (edges.length > 1) { + //neighborEdges.remove(edges.remove(0)); + var temp = edges[0]; + edges.splice(0, 1); + var index = neighborEdges.indexOf(temp); + if (index >= 0) { + neighborEdges.splice(index, 1); + } + incEdgesCount--; + childCount--; + } + + if (parentOfNode != null) { + //assert edges.length == 1; + startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount; + } else { + startIndex = 0; + } + + var stepAngle = Math.abs(endAngle - startAngle) / childCount; + + for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) { + var currentNeighbor = neighborEdges[i].getOtherEnd(node); + + // Don't back traverse to root node in current tree. + if (currentNeighbor == parentOfNode) { + continue; + } + + var childStartAngle = (startAngle + branchCount * stepAngle) % 360; + var childEndAngle = (childStartAngle + stepAngle) % 360; + + CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation); + + branchCount++; + } + }; + + CoSELayout.maxDiagonalInTree = function (tree) { + var maxDiagonal = Integer.MIN_VALUE; + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + var diagonal = node.getDiagonal(); + + if (diagonal > maxDiagonal) { + maxDiagonal = diagonal; + } + } + + return maxDiagonal; + }; + + CoSELayout.prototype.calcRepulsionRange = function () { + // formula is 2 x (level + 1) x idealEdgeLength + return 2 * (this.level + 1) * this.idealEdgeLength; + }; + + // Tiling methods + + // Group zero degree members whose parents are not to be tiled, create dummy parents where needed and fill memberGroups by their dummp parent id's + CoSELayout.prototype.groupZeroDegreeMembers = function () { + var self = this; + // array of [parent_id x oneDegreeNode_id] + var tempMemberGroups = {}; // A temporary map of parent node and its zero degree members + this.memberGroups = {}; // A map of dummy parent node and its zero degree members whose parents are not to be tiled + this.idToDummyNode = {}; // A map of id to dummy node + + var zeroDegree = []; // List of zero degree nodes whose parents are not to be tiled + var allNodes = this.graphManager.getAllNodes(); + + // Fill zero degree list + for (var i = 0; i < allNodes.length; i++) { + var node = allNodes[i]; + var parent = node.getParent(); + // If a node has zero degree and its parent is not to be tiled if exists add that node to zeroDegres list + if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == undefined || !this.getToBeTiled(parent))) { + zeroDegree.push(node); + } + } + + // Create a map of parent node and its zero degree members + for (var i = 0; i < zeroDegree.length; i++) { + var node = zeroDegree[i]; // Zero degree node itself + var p_id = node.getParent().id; // Parent id + + if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = []; + + tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node); // Push node to the list belongs to its parent in tempMemberGroups + } + + // If there are at least two nodes at a level, create a dummy compound for them + Object.keys(tempMemberGroups).forEach(function (p_id) { + if (tempMemberGroups[p_id].length > 1) { + var dummyCompoundId = "DummyCompound_" + p_id; // The id of dummy compound which will be created soon + self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id]; // Add dummy compound to memberGroups + + var parent = tempMemberGroups[p_id][0].getParent(); // The parent of zero degree nodes will be the parent of new dummy compound + + // Create a dummy compound with calculated id + var dummyCompound = new CoSENode(self.graphManager); + dummyCompound.id = dummyCompoundId; + dummyCompound.paddingLeft = parent.paddingLeft || 0; + dummyCompound.paddingRight = parent.paddingRight || 0; + dummyCompound.paddingBottom = parent.paddingBottom || 0; + dummyCompound.paddingTop = parent.paddingTop || 0; + + self.idToDummyNode[dummyCompoundId] = dummyCompound; + + var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound); + var parentGraph = parent.getChild(); + + // Add dummy compound to parent the graph + parentGraph.add(dummyCompound); + + // For each zero degree node in this level remove it from its parent graph and add it to the graph of dummy parent + for (var i = 0; i < tempMemberGroups[p_id].length; i++) { + var node = tempMemberGroups[p_id][i]; + + parentGraph.remove(node); + dummyParentGraph.add(node); + } + } + }); + }; + + CoSELayout.prototype.clearCompounds = function () { + var childGraphMap = {}; + var idToNode = {}; + + // Get compound ordering by finding the inner one first + this.performDFSOnCompounds(); + + for (var i = 0; i < this.compoundOrder.length; i++) { + + idToNode[this.compoundOrder[i].id] = this.compoundOrder[i]; + childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes()); + + // Remove children of compounds + this.graphManager.remove(this.compoundOrder[i].getChild()); + this.compoundOrder[i].child = null; + } + + this.graphManager.resetAllNodes(); + + // Tile the removed children + this.tileCompoundMembers(childGraphMap, idToNode); + }; + + CoSELayout.prototype.clearZeroDegreeMembers = function () { + var self = this; + var tiledZeroDegreePack = this.tiledZeroDegreePack = []; + + Object.keys(this.memberGroups).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound + + tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + // Set the width and height of the dummy compound as calculated + compoundNode.rect.width = tiledZeroDegreePack[id].width; + compoundNode.rect.height = tiledZeroDegreePack[id].height; + }); + }; + + CoSELayout.prototype.repopulateCompounds = function () { + for (var i = this.compoundOrder.length - 1; i >= 0; i--) { + var lCompoundNode = this.compoundOrder[i]; + var id = lCompoundNode.id; + var horizontalMargin = lCompoundNode.paddingLeft; + var verticalMargin = lCompoundNode.paddingTop; + + this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin); + } + }; + + CoSELayout.prototype.repopulateZeroDegreeMembers = function () { + var self = this; + var tiledPack = this.tiledZeroDegreePack; + + Object.keys(tiledPack).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound by its id + var horizontalMargin = compoundNode.paddingLeft; + var verticalMargin = compoundNode.paddingTop; + + // Adjust the positions of nodes wrt its compound + self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin); + }); + }; + + CoSELayout.prototype.getToBeTiled = function (node) { + var id = node.id; + //firstly check the previous results + if (this.toBeTiled[id] != null) { + return this.toBeTiled[id]; + } + + //only compound nodes are to be tiled + var childGraph = node.getChild(); + if (childGraph == null) { + this.toBeTiled[id] = false; + return false; + } + + var children = childGraph.getNodes(); // Get the children nodes + + //a compound node is not to be tiled if all of its compound children are not to be tiled + for (var i = 0; i < children.length; i++) { + var theChild = children[i]; + + if (this.getNodeDegree(theChild) > 0) { + this.toBeTiled[id] = false; + return false; + } + + //pass the children not having the compound structure + if (theChild.getChild() == null) { + this.toBeTiled[theChild.id] = false; + continue; + } + + if (!this.getToBeTiled(theChild)) { + this.toBeTiled[id] = false; + return false; + } + } + this.toBeTiled[id] = true; + return true; + }; + + // Get degree of a node depending of its edges and independent of its children + CoSELayout.prototype.getNodeDegree = function (node) { + node.id; + var edges = node.getEdges(); + var degree = 0; + + // For the edges connected + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + if (edge.getSource().id !== edge.getTarget().id) { + degree = degree + 1; + } + } + return degree; + }; + + // Get degree of a node with its children + CoSELayout.prototype.getNodeDegreeWithChildren = function (node) { + var degree = this.getNodeDegree(node); + if (node.getChild() == null) { + return degree; + } + var children = node.getChild().getNodes(); + for (var i = 0; i < children.length; i++) { + var child = children[i]; + degree += this.getNodeDegreeWithChildren(child); + } + return degree; + }; + + CoSELayout.prototype.performDFSOnCompounds = function () { + this.compoundOrder = []; + this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes()); + }; + + CoSELayout.prototype.fillCompexOrderByDFS = function (children) { + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.getChild() != null) { + this.fillCompexOrderByDFS(child.getChild().getNodes()); + } + if (this.getToBeTiled(child)) { + this.compoundOrder.push(child); + } + } + }; + + /** + * This method places each zero degree member wrt given (x,y) coordinates (top left). + */ + CoSELayout.prototype.adjustLocations = function (organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) { + x += compoundHorizontalMargin; + y += compoundVerticalMargin; + + var left = x; + + for (var i = 0; i < organization.rows.length; i++) { + var row = organization.rows[i]; + x = left; + var maxHeight = 0; + + for (var j = 0; j < row.length; j++) { + var lnode = row[j]; + + lnode.rect.x = x; // + lnode.rect.width / 2; + lnode.rect.y = y; // + lnode.rect.height / 2; + + x += lnode.rect.width + organization.horizontalPadding; + + if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height; + } + + y += maxHeight + organization.verticalPadding; + } + }; + + CoSELayout.prototype.tileCompoundMembers = function (childGraphMap, idToNode) { + var self = this; + this.tiledMemberPack = []; + + Object.keys(childGraphMap).forEach(function (id) { + // Get the compound node + var compoundNode = idToNode[id]; + + self.tiledMemberPack[id] = self.tileNodes(childGraphMap[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + compoundNode.rect.width = self.tiledMemberPack[id].width; + compoundNode.rect.height = self.tiledMemberPack[id].height; + }); + }; + + CoSELayout.prototype.tileNodes = function (nodes, minWidth) { + var verticalPadding = CoSEConstants.TILING_PADDING_VERTICAL; + var horizontalPadding = CoSEConstants.TILING_PADDING_HORIZONTAL; + var organization = { + rows: [], + rowWidth: [], + rowHeight: [], + width: 0, + height: minWidth, // assume minHeight equals to minWidth + verticalPadding: verticalPadding, + horizontalPadding: horizontalPadding + }; + + // Sort the nodes in ascending order of their areas + nodes.sort(function (n1, n2) { + if (n1.rect.width * n1.rect.height > n2.rect.width * n2.rect.height) return -1; + if (n1.rect.width * n1.rect.height < n2.rect.width * n2.rect.height) return 1; + return 0; + }); + + // Create the organization -> tile members + for (var i = 0; i < nodes.length; i++) { + var lNode = nodes[i]; + + if (organization.rows.length == 0) { + this.insertNodeToRow(organization, lNode, 0, minWidth); + } else if (this.canAddHorizontal(organization, lNode.rect.width, lNode.rect.height)) { + this.insertNodeToRow(organization, lNode, this.getShortestRowIndex(organization), minWidth); + } else { + this.insertNodeToRow(organization, lNode, organization.rows.length, minWidth); + } + + this.shiftToLastRow(organization); + } + + return organization; + }; + + CoSELayout.prototype.insertNodeToRow = function (organization, node, rowIndex, minWidth) { + var minCompoundSize = minWidth; + + // Add new row if needed + if (rowIndex == organization.rows.length) { + var secondDimension = []; + + organization.rows.push(secondDimension); + organization.rowWidth.push(minCompoundSize); + organization.rowHeight.push(0); + } + + // Update row width + var w = organization.rowWidth[rowIndex] + node.rect.width; + + if (organization.rows[rowIndex].length > 0) { + w += organization.horizontalPadding; + } + + organization.rowWidth[rowIndex] = w; + // Update compound width + if (organization.width < w) { + organization.width = w; + } + + // Update height + var h = node.rect.height; + if (rowIndex > 0) h += organization.verticalPadding; + + var extraHeight = 0; + if (h > organization.rowHeight[rowIndex]) { + extraHeight = organization.rowHeight[rowIndex]; + organization.rowHeight[rowIndex] = h; + extraHeight = organization.rowHeight[rowIndex] - extraHeight; + } + + organization.height += extraHeight; + + // Insert node + organization.rows[rowIndex].push(node); + }; + + //Scans the rows of an organization and returns the one with the min width + CoSELayout.prototype.getShortestRowIndex = function (organization) { + var r = -1; + var min = Number.MAX_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + if (organization.rowWidth[i] < min) { + r = i; + min = organization.rowWidth[i]; + } + } + return r; + }; + + //Scans the rows of an organization and returns the one with the max width + CoSELayout.prototype.getLongestRowIndex = function (organization) { + var r = -1; + var max = Number.MIN_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + + if (organization.rowWidth[i] > max) { + r = i; + max = organization.rowWidth[i]; + } + } + + return r; + }; + + /** + * This method checks whether adding extra width to the organization violates + * the aspect ratio(1) or not. + */ + CoSELayout.prototype.canAddHorizontal = function (organization, extraWidth, extraHeight) { + + var sri = this.getShortestRowIndex(organization); + + if (sri < 0) { + return true; + } + + var min = organization.rowWidth[sri]; + + if (min + organization.horizontalPadding + extraWidth <= organization.width) return true; + + var hDiff = 0; + + // Adding to an existing row + if (organization.rowHeight[sri] < extraHeight) { + if (sri > 0) hDiff = extraHeight + organization.verticalPadding - organization.rowHeight[sri]; + } + + var add_to_row_ratio; + if (organization.width - min >= extraWidth + organization.horizontalPadding) { + add_to_row_ratio = (organization.height + hDiff) / (min + extraWidth + organization.horizontalPadding); + } else { + add_to_row_ratio = (organization.height + hDiff) / organization.width; + } + + // Adding a new row for this node + hDiff = extraHeight + organization.verticalPadding; + var add_new_row_ratio; + if (organization.width < extraWidth) { + add_new_row_ratio = (organization.height + hDiff) / extraWidth; + } else { + add_new_row_ratio = (organization.height + hDiff) / organization.width; + } + + if (add_new_row_ratio < 1) add_new_row_ratio = 1 / add_new_row_ratio; + + if (add_to_row_ratio < 1) add_to_row_ratio = 1 / add_to_row_ratio; + + return add_to_row_ratio < add_new_row_ratio; + }; + + //If moving the last node from the longest row and adding it to the last + //row makes the bounding box smaller, do it. + CoSELayout.prototype.shiftToLastRow = function (organization) { + var longest = this.getLongestRowIndex(organization); + var last = organization.rowWidth.length - 1; + var row = organization.rows[longest]; + var node = row[row.length - 1]; + + var diff = node.width + organization.horizontalPadding; + + // Check if there is enough space on the last row + if (organization.width - organization.rowWidth[last] > diff && longest != last) { + // Remove the last element of the longest row + row.splice(-1, 1); + + // Push it to the last row + organization.rows[last].push(node); + + organization.rowWidth[longest] = organization.rowWidth[longest] - diff; + organization.rowWidth[last] = organization.rowWidth[last] + diff; + organization.width = organization.rowWidth[instance.getLongestRowIndex(organization)]; + + // Update heights of the organization + var maxHeight = Number.MIN_VALUE; + for (var i = 0; i < row.length; i++) { + if (row[i].height > maxHeight) maxHeight = row[i].height; + } + if (longest > 0) maxHeight += organization.verticalPadding; + + var prevTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + + organization.rowHeight[longest] = maxHeight; + if (organization.rowHeight[last] < node.height + organization.verticalPadding) organization.rowHeight[last] = node.height + organization.verticalPadding; + + var finalTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + organization.height += finalTotal - prevTotal; + + this.shiftToLastRow(organization); + } + }; + + CoSELayout.prototype.tilingPreLayout = function () { + if (CoSEConstants.TILE) { + // Find zero degree nodes and create a compound for each level + this.groupZeroDegreeMembers(); + // Tile and clear children of each compound + this.clearCompounds(); + // Separately tile and clear zero degree nodes for each level + this.clearZeroDegreeMembers(); + } + }; + + CoSELayout.prototype.tilingPostLayout = function () { + if (CoSEConstants.TILE) { + this.repopulateZeroDegreeMembers(); + this.repopulateCompounds(); + } + }; + + // ----------------------------------------------------------------------------- + // Section: Tree Reduction methods + // ----------------------------------------------------------------------------- + // Reduce trees + CoSELayout.prototype.reduceTrees = function () { + var prunedNodesAll = []; + var containsLeaf = true; + var node; + + while (containsLeaf) { + var allNodes = this.graphManager.getAllNodes(); + var prunedNodesInStepTemp = []; + containsLeaf = false; + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + if (node.getEdges().length == 1 && !node.getEdges()[0].isInterGraph && node.getChild() == null) { + prunedNodesInStepTemp.push([node, node.getEdges()[0], node.getOwner()]); + containsLeaf = true; + } + } + if (containsLeaf == true) { + var prunedNodesInStep = []; + for (var j = 0; j < prunedNodesInStepTemp.length; j++) { + if (prunedNodesInStepTemp[j][0].getEdges().length == 1) { + prunedNodesInStep.push(prunedNodesInStepTemp[j]); + prunedNodesInStepTemp[j][0].getOwner().remove(prunedNodesInStepTemp[j][0]); + } + } + prunedNodesAll.push(prunedNodesInStep); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + } + } + this.prunedNodesAll = prunedNodesAll; + }; + + // Grow tree one step + CoSELayout.prototype.growTree = function (prunedNodesAll) { + var lengthOfPrunedNodesInStep = prunedNodesAll.length; + var prunedNodesInStep = prunedNodesAll[lengthOfPrunedNodesInStep - 1]; + + var nodeData; + for (var i = 0; i < prunedNodesInStep.length; i++) { + nodeData = prunedNodesInStep[i]; + + this.findPlaceforPrunedNode(nodeData); + + nodeData[2].add(nodeData[0]); + nodeData[2].add(nodeData[1], nodeData[1].source, nodeData[1].target); + } + + prunedNodesAll.splice(prunedNodesAll.length - 1, 1); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + }; + + // Find an appropriate position to replace pruned node, this method can be improved + CoSELayout.prototype.findPlaceforPrunedNode = function (nodeData) { + + var gridForPrunedNode; + var nodeToConnect; + var prunedNode = nodeData[0]; + if (prunedNode == nodeData[1].source) { + nodeToConnect = nodeData[1].target; + } else { + nodeToConnect = nodeData[1].source; + } + var startGridX = nodeToConnect.startX; + var finishGridX = nodeToConnect.finishX; + var startGridY = nodeToConnect.startY; + var finishGridY = nodeToConnect.finishY; + + var upNodeCount = 0; + var downNodeCount = 0; + var rightNodeCount = 0; + var leftNodeCount = 0; + var controlRegions = [upNodeCount, rightNodeCount, downNodeCount, leftNodeCount]; + + if (startGridY > 0) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[0] += this.grid[i][startGridY - 1].length + this.grid[i][startGridY].length - 1; + } + } + if (finishGridX < this.grid.length - 1) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[1] += this.grid[finishGridX + 1][i].length + this.grid[finishGridX][i].length - 1; + } + } + if (finishGridY < this.grid[0].length - 1) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[2] += this.grid[i][finishGridY + 1].length + this.grid[i][finishGridY].length - 1; + } + } + if (startGridX > 0) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[3] += this.grid[startGridX - 1][i].length + this.grid[startGridX][i].length - 1; + } + } + var min = Integer.MAX_VALUE; + var minCount; + var minIndex; + for (var j = 0; j < controlRegions.length; j++) { + if (controlRegions[j] < min) { + min = controlRegions[j]; + minCount = 1; + minIndex = j; + } else if (controlRegions[j] == min) { + minCount++; + } + } + + if (minCount == 3 && min == 0) { + if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[2] == 0) { + gridForPrunedNode = 1; + } else if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 0; + } else if (controlRegions[0] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 3; + } else if (controlRegions[1] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 2; + } + } else if (minCount == 2 && min == 0) { + var random = Math.floor(Math.random() * 2); + if (controlRegions[0] == 0 && controlRegions[1] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 1; + } + } else if (controlRegions[0] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[0] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 3; + } + } else if (controlRegions[1] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[1] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 3; + } + } else { + if (random == 0) { + gridForPrunedNode = 2; + } else { + gridForPrunedNode = 3; + } + } + } else if (minCount == 4 && min == 0) { + var random = Math.floor(Math.random() * 4); + gridForPrunedNode = random; + } else { + gridForPrunedNode = minIndex; + } + + if (gridForPrunedNode == 0) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() - nodeToConnect.getHeight() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getHeight() / 2); + } else if (gridForPrunedNode == 1) { + prunedNode.setCenter(nodeToConnect.getCenterX() + nodeToConnect.getWidth() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } else if (gridForPrunedNode == 2) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() + nodeToConnect.getHeight() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getHeight() / 2); + } else { + prunedNode.setCenter(nodeToConnect.getCenterX() - nodeToConnect.getWidth() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } + }; + + module.exports = CoSELayout; + + /***/ }), + /* 7 */ + /***/ (function(module, exports, __webpack_require__) { + + + var coseBase = {}; + + coseBase.layoutBase = __webpack_require__(0); + coseBase.CoSEConstants = __webpack_require__(1); + coseBase.CoSEEdge = __webpack_require__(2); + coseBase.CoSEGraph = __webpack_require__(3); + coseBase.CoSEGraphManager = __webpack_require__(4); + coseBase.CoSELayout = __webpack_require__(6); + coseBase.CoSENode = __webpack_require__(5); + + module.exports = coseBase; + + /***/ }) + /******/ ]); + }); + } (coseBase)); + return coseBase.exports; +} + +(function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(requireCoseBase()); + })(commonjsGlobal$1, function(__WEBPACK_EXTERNAL_MODULE_0__) { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 1); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LayoutConstants = __webpack_require__(0).layoutBase.LayoutConstants; + var FDLayoutConstants = __webpack_require__(0).layoutBase.FDLayoutConstants; + var CoSEConstants = __webpack_require__(0).CoSEConstants; + var CoSELayout = __webpack_require__(0).CoSELayout; + var CoSENode = __webpack_require__(0).CoSENode; + var PointD = __webpack_require__(0).layoutBase.PointD; + var DimensionD = __webpack_require__(0).layoutBase.DimensionD; + + var defaults = { + // Called on `layoutready` + ready: function ready() {}, + // Called on `layoutstop` + stop: function stop() {}, + // 'draft', 'default' or 'proof" + // - 'draft' fast cooling rate + // - 'default' moderate cooling rate + // - "proof" slow cooling rate + quality: 'default', + // include labels in node dimensions + nodeDimensionsIncludeLabels: false, + // number of ticks per frame; higher is faster but more jerky + refresh: 30, + // Whether to fit the network view after when done + fit: true, + // Padding on fit + padding: 10, + // Whether to enable incremental mode + randomize: true, + // Node repulsion (non overlapping) multiplier + nodeRepulsion: 4500, + // Ideal edge (non nested) length + idealEdgeLength: 50, + // Divisor to compute edge forces + edgeElasticity: 0.45, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 0.1, + // Gravity force (constant) + gravity: 0.25, + // Maximum number of iterations to perform + numIter: 2500, + // For enabling tiling + tile: true, + // Type of layout animation. The option set is {'during', 'end', false} + animate: 'end', + // Duration for animate:end + animationDuration: 500, + // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingVertical: 10, + // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingHorizontal: 10, + // Gravity range (constant) for compounds + gravityRangeCompound: 1.5, + // Gravity force (constant) for compounds + gravityCompound: 1.0, + // Gravity range (constant) + gravityRange: 3.8, + // Initial cooling factor for incremental layout + initialEnergyOnIncremental: 0.5 + }; + + function extend(defaults, options) { + var obj = {}; + + for (var i in defaults) { + obj[i] = defaults[i]; + } + + for (var i in options) { + obj[i] = options[i]; + } + + return obj; + } + function _CoSELayout(_options) { + this.options = extend(defaults, _options); + getUserOptions(this.options); + } + + var getUserOptions = function getUserOptions(options) { + if (options.nodeRepulsion != null) CoSEConstants.DEFAULT_REPULSION_STRENGTH = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = options.nodeRepulsion; + if (options.idealEdgeLength != null) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength; + if (options.edgeElasticity != null) CoSEConstants.DEFAULT_SPRING_STRENGTH = FDLayoutConstants.DEFAULT_SPRING_STRENGTH = options.edgeElasticity; + if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor; + if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity; + if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter; + if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange; + if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound; + if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound; + if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental; + + if (options.quality == 'draft') LayoutConstants.QUALITY = 0;else if (options.quality == 'proof') LayoutConstants.QUALITY = 2;else LayoutConstants.QUALITY = 1; + + CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels; + CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize; + CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate; + CoSEConstants.TILE = options.tile; + CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === 'function' ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical; + CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === 'function' ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal; + }; + + _CoSELayout.prototype.run = function () { + var ready; + var frameId; + var options = this.options; + this.idToLNode = {}; + var layout = this.layout = new CoSELayout(); + var self = this; + + self.stopped = false; + + this.cy = this.options.cy; + + this.cy.trigger({ type: 'layoutstart', layout: this }); + + var gm = layout.newGraphManager(); + this.gm = gm; + + var nodes = this.options.eles.nodes(); + var edges = this.options.eles.edges(); + + this.root = gm.addRoot(); + this.processChildrenList(this.root, this.getTopMostNodes(nodes), layout); + + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var sourceNode = this.idToLNode[edge.data("source")]; + var targetNode = this.idToLNode[edge.data("target")]; + if (sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) { + var e1 = gm.add(layout.newEdge(), sourceNode, targetNode); + e1.id = edge.id(); + } + } + + var getPositions = function getPositions(ele, i) { + if (typeof ele === "number") { + ele = i; + } + var theId = ele.data('id'); + var lNode = self.idToLNode[theId]; + + return { + x: lNode.getRect().getCenterX(), + y: lNode.getRect().getCenterY() + }; + }; + + /* + * Reposition nodes in iterations animatedly + */ + var iterateAnimated = function iterateAnimated() { + // Thigs to perform after nodes are repositioned on screen + var afterReposition = function afterReposition() { + if (options.fit) { + options.cy.fit(options.eles, options.padding); + } + + if (!ready) { + ready = true; + self.cy.one('layoutready', options.ready); + self.cy.trigger({ type: 'layoutready', layout: self }); + } + }; + + var ticksPerFrame = self.options.refresh; + var isDone; + + for (var i = 0; i < ticksPerFrame && !isDone; i++) { + isDone = self.stopped || self.layout.tick(); + } + + // If layout is done + if (isDone) { + // If the layout is not a sublayout and it is successful perform post layout. + if (layout.checkLayoutSuccess() && !layout.isSubLayout) { + layout.doPostLayout(); + } + + // If layout has a tilingPostLayout function property call it. + if (layout.tilingPostLayout) { + layout.tilingPostLayout(); + } + + layout.isLayoutFinished = true; + + self.options.eles.nodes().positions(getPositions); + + afterReposition(); + + // trigger layoutstop when the layout stops (e.g. finishes) + self.cy.one('layoutstop', self.options.stop); + self.cy.trigger({ type: 'layoutstop', layout: self }); + + if (frameId) { + cancelAnimationFrame(frameId); + } + + ready = false; + return; + } + + var animationData = self.layout.getPositionsData(); // Get positions of layout nodes note that all nodes may not be layout nodes because of tiling + + // Position nodes, for the nodes whose id does not included in data (because they are removed from their parents and included in dummy compounds) + // use position of their ancestors or dummy ancestors + options.eles.nodes().positions(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + // If ele is a compound node, then its position will be defined by its children + if (!ele.isParent()) { + var theId = ele.id(); + var pNode = animationData[theId]; + var temp = ele; + // If pNode is undefined search until finding position data of its first ancestor (It may be dummy as well) + while (pNode == null) { + pNode = animationData[temp.data('parent')] || animationData['DummyCompound_' + temp.data('parent')]; + animationData[theId] = pNode; + temp = temp.parent()[0]; + if (temp == undefined) { + break; + } + } + if (pNode != null) { + return { + x: pNode.x, + y: pNode.y + }; + } else { + return { + x: ele.position('x'), + y: ele.position('y') + }; + } + } + }); + + afterReposition(); + + frameId = requestAnimationFrame(iterateAnimated); + }; + + /* + * Listen 'layoutstarted' event and start animated iteration if animate option is 'during' + */ + layout.addListener('layoutstarted', function () { + if (self.options.animate === 'during') { + frameId = requestAnimationFrame(iterateAnimated); + } + }); + + layout.runLayout(); // Run cose layout + + /* + * If animate option is not 'during' ('end' or false) perform these here (If it is 'during' similar things are already performed) + */ + if (this.options.animate !== "during") { + self.options.eles.nodes().not(":parent").layoutPositions(self, self.options, getPositions); // Use layout positions to reposition the nodes it considers the options parameter + ready = false; + } + + return this; // chaining + }; + + //Get the top most ones of a list of nodes + _CoSELayout.prototype.getTopMostNodes = function (nodes) { + var nodesMap = {}; + for (var i = 0; i < nodes.length; i++) { + nodesMap[nodes[i].id()] = true; + } + var roots = nodes.filter(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + var parent = ele.parent()[0]; + while (parent != null) { + if (nodesMap[parent.id()]) { + return false; + } + parent = parent.parent()[0]; + } + return true; + }); + + return roots; + }; + + _CoSELayout.prototype.processChildrenList = function (parent, children, layout) { + var size = children.length; + for (var i = 0; i < size; i++) { + var theChild = children[i]; + var children_of_children = theChild.children(); + var theNode; + + var dimensions = theChild.layoutDimensions({ + nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels + }); + + if (theChild.outerWidth() != null && theChild.outerHeight() != null) { + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position('x') - dimensions.w / 2, theChild.position('y') - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h)))); + } else { + theNode = parent.add(new CoSENode(this.graphManager)); + } + // Attach id to the layout node + theNode.id = theChild.data("id"); + // Attach the paddings of cy node to layout node + theNode.paddingLeft = parseInt(theChild.css('padding')); + theNode.paddingTop = parseInt(theChild.css('padding')); + theNode.paddingRight = parseInt(theChild.css('padding')); + theNode.paddingBottom = parseInt(theChild.css('padding')); + + //Attach the label properties to compound if labels will be included in node dimensions + if (this.options.nodeDimensionsIncludeLabels) { + if (theChild.isParent()) { + var labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false }).w; + var labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false }).h; + var labelPos = theChild.css("text-halign"); + theNode.labelWidth = labelWidth; + theNode.labelHeight = labelHeight; + theNode.labelPos = labelPos; + } + } + + // Map the layout node + this.idToLNode[theChild.data("id")] = theNode; + + if (isNaN(theNode.rect.x)) { + theNode.rect.x = 0; + } + + if (isNaN(theNode.rect.y)) { + theNode.rect.y = 0; + } + + if (children_of_children != null && children_of_children.length > 0) { + var theNewGraph; + theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode); + this.processChildrenList(theNewGraph, children_of_children, layout); + } + } + }; + + /** + * @brief : called on continuous layouts to stop them before they finish + */ + _CoSELayout.prototype.stop = function () { + this.stopped = true; + + return this; // chaining + }; + + var register = function register(cytoscape) { + // var Layout = getLayout( cytoscape ); + + cytoscape('layout', 'cose-bilkent', _CoSELayout); + }; + + // auto reg for globals + if (typeof cytoscape !== 'undefined') { + register(cytoscape); + } + + module.exports = register; + + /***/ }) + /******/ ]); + }); +} (cytoscapeCoseBilkent)); + +var cytoscapeCoseBilkentExports = cytoscapeCoseBilkent.exports; +var coseBilkent = /*@__PURE__*/getDefaultExportFromCjs(cytoscapeCoseBilkentExports); + +var parser$3 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 4], $V1 = [1, 13], $V2 = [1, 12], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 20], $V6 = [1, 19], $V7 = [6, 7, 8], $V8 = [1, 26], $V9 = [1, 24], $Va = [1, 25], $Vb = [6, 7, 11], $Vc = [1, 6, 13, 15, 16, 19, 22], $Vd = [1, 33], $Ve = [1, 34], $Vf = [1, 6, 7, 11, 13, 15, 16, 19, 22]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mindMap": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "MINDMAP": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "node": 14, "ICON": 15, "CLASS": 16, "nodeWithId": 17, "nodeWithoutId": 18, "NODE_DSTART": 19, "NODE_DESCR": 20, "NODE_DEND": 21, "NODE_ID": 22, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" }, + productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 6: + case 7: + return yy; + case 8: + yy.getLogger().trace("Stop NL "); + break; + case 9: + yy.getLogger().trace("Stop EOF "); + break; + case 11: + yy.getLogger().trace("Stop NL2 "); + break; + case 12: + yy.getLogger().trace("Stop EOF2 "); + break; + case 15: + yy.getLogger().info("Node: ", $$[$0].id); + yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type); + break; + case 16: + yy.getLogger().trace("Icon: ", $$[$0]); + yy.decorateNode({ icon: $$[$0] }); + break; + case 17: + case 21: + yy.decorateNode({ class: $$[$0] }); + break; + case 18: + yy.getLogger().trace("SPACELIST"); + break; + case 19: + yy.getLogger().trace("Node: ", $$[$0].id); + yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type); + break; + case 20: + yy.decorateNode({ icon: $$[$0] }); + break; + case 25: + yy.getLogger().trace("node found ..", $$[$0 - 2]); + this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; + break; + case 26: + this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT }; + break; + case 27: + yy.getLogger().trace("node found ..", $$[$0 - 3]); + this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($V7, [2, 3]), { 1: [2, 2] }, o($V7, [2, 4]), o($V7, [2, 5]), { 1: [2, 6], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V1, 9: 22, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V8, 7: $V9, 10: 23, 11: $Va }, o($Vb, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: $V5, 22: $V6 }), o($Vb, [2, 18]), o($Vb, [2, 19]), o($Vb, [2, 20]), o($Vb, [2, 21]), o($Vb, [2, 23]), o($Vb, [2, 24]), o($Vb, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: $V8, 7: $V9, 10: 32, 11: $Va }, { 1: [2, 7], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($Vc, [2, 14], { 7: $Vd, 11: $Ve }), o($Vf, [2, 8]), o($Vf, [2, 9]), o($Vf, [2, 10]), o($Vb, [2, 15]), o($Vb, [2, 16]), o($Vb, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, o($Vc, [2, 13], { 7: $Vd, 11: $Ve }), o($Vf, [2, 11]), o($Vf, [2, 12]), { 21: [1, 37] }, o($Vb, [2, 25]), o($Vb, [2, 27])], + defaultActions: { 2: [2, 1], 6: [2, 2] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + yy.getLogger().trace("Found comment", yy_.yytext); + return 6; + case 1: + return 8; + case 2: + this.begin("CLASS"); + break; + case 3: + this.popState(); + return 16; + case 4: + this.popState(); + break; + case 5: + yy.getLogger().trace("Begin icon"); + this.begin("ICON"); + break; + case 6: + yy.getLogger().trace("SPACELINE"); + return 6; + case 7: + return 7; + case 8: + return 15; + case 9: + yy.getLogger().trace("end icon"); + this.popState(); + break; + case 10: + yy.getLogger().trace("Exploding node"); + this.begin("NODE"); + return 19; + case 11: + yy.getLogger().trace("Cloud"); + this.begin("NODE"); + return 19; + case 12: + yy.getLogger().trace("Explosion Bang"); + this.begin("NODE"); + return 19; + case 13: + yy.getLogger().trace("Cloud Bang"); + this.begin("NODE"); + return 19; + case 14: + this.begin("NODE"); + return 19; + case 15: + this.begin("NODE"); + return 19; + case 16: + this.begin("NODE"); + return 19; + case 17: + this.begin("NODE"); + return 19; + case 18: + return 13; + case 19: + return 22; + case 20: + return 11; + case 21: + this.begin("NSTR2"); + break; + case 22: + return "NODE_DESCR"; + case 23: + this.popState(); + break; + case 24: + yy.getLogger().trace("Starting NSTR"); + this.begin("NSTR"); + break; + case 25: + yy.getLogger().trace("description:", yy_.yytext); + return "NODE_DESCR"; + case 26: + this.popState(); + break; + case 27: + this.popState(); + yy.getLogger().trace("node end ))"); + return "NODE_DEND"; + case 28: + this.popState(); + yy.getLogger().trace("node end )"); + return "NODE_DEND"; + case 29: + this.popState(); + yy.getLogger().trace("node end ...", yy_.yytext); + return "NODE_DEND"; + case 30: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 31: + this.popState(); + yy.getLogger().trace("node end (-"); + return "NODE_DEND"; + case 32: + this.popState(); + yy.getLogger().trace("node end (-"); + return "NODE_DEND"; + case 33: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 34: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 35: + yy.getLogger().trace("Long description:", yy_.yytext); + return 20; + case 36: + yy.getLogger().trace("Long description:", yy_.yytext); + return 20; + } + }, + rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i], + conditions: { "CLASS": { "rules": [3, 4], "inclusive": false }, "ICON": { "rules": [8, 9], "inclusive": false }, "NSTR2": { "rules": [22, 23], "inclusive": false }, "NSTR": { "rules": [25, 26], "inclusive": false }, "NODE": { "rules": [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$3.parser = parser$3; +const parser$1$2 = parser$3; +let nodes$1 = []; +let cnt$1 = 0; +let elements = {}; +const clear$2 = () => { + nodes$1 = []; + cnt$1 = 0; + elements = {}; +}; +const getParent = function(level) { + for (let i = nodes$1.length - 1; i >= 0; i--) { + if (nodes$1[i].level < level) { + return nodes$1[i]; + } + } + return null; +}; +const getMindmap = () => { + return nodes$1.length > 0 ? nodes$1[0] : null; +}; +const addNode = (level, id, descr, type) => { + var _a, _b; + log$1.info("addNode", level, id, descr, type); + const conf = getConfig$2(); + let padding = ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig$2.mindmap.padding; + switch (type) { + case nodeType.ROUNDED_RECT: + case nodeType.RECT: + case nodeType.HEXAGON: + padding *= 2; + } + const node = { + id: cnt$1++, + nodeId: sanitizeText$2$1(id, conf), + level, + descr: sanitizeText$2$1(descr, conf), + type, + children: [], + width: ((_b = conf.mindmap) == null ? void 0 : _b.maxNodeWidth) ?? defaultConfig$2.mindmap.maxNodeWidth, + padding + }; + const parent = getParent(level); + if (parent) { + parent.children.push(node); + nodes$1.push(node); + } else { + if (nodes$1.length === 0) { + nodes$1.push(node); + } else { + throw new Error( + 'There can be only one root. No parent could be found for ("' + node.descr + '")' + ); + } + } +}; +const nodeType = { + DEFAULT: 0, + NO_BORDER: 0, + ROUNDED_RECT: 1, + RECT: 2, + CIRCLE: 3, + CLOUD: 4, + BANG: 5, + HEXAGON: 6 +}; +const getType = (startStr, endStr) => { + log$1.debug("In get type", startStr, endStr); + switch (startStr) { + case "[": + return nodeType.RECT; + case "(": + return endStr === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD; + case "((": + return nodeType.CIRCLE; + case ")": + return nodeType.CLOUD; + case "))": + return nodeType.BANG; + case "{{": + return nodeType.HEXAGON; + default: + return nodeType.DEFAULT; + } +}; +const setElementForId = (id, element) => { + elements[id] = element; +}; +const decorateNode = (decoration) => { + if (!decoration) { + return; + } + const config = getConfig$2(); + const node = nodes$1[nodes$1.length - 1]; + if (decoration.icon) { + node.icon = sanitizeText$2$1(decoration.icon, config); + } + if (decoration.class) { + node.class = sanitizeText$2$1(decoration.class, config); + } +}; +const type2Str = (type) => { + switch (type) { + case nodeType.DEFAULT: + return "no-border"; + case nodeType.RECT: + return "rect"; + case nodeType.ROUNDED_RECT: + return "rounded-rect"; + case nodeType.CIRCLE: + return "circle"; + case nodeType.CLOUD: + return "cloud"; + case nodeType.BANG: + return "bang"; + case nodeType.HEXAGON: + return "hexgon"; + default: + return "no-border"; + } +}; +const getLogger$1 = () => log$1; +const getElementById = (id) => elements[id]; +const db$3 = { + clear: clear$2, + addNode, + getMindmap, + nodeType, + getType, + setElementForId, + decorateNode, + type2Str, + getLogger: getLogger$1, + getElementById +}; +const db$1$1 = db$3; +const MAX_SECTIONS = 12; +const defaultBkg = function(db2, elem, node, section) { + const rd = 5; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` + ); + elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); +}; +const rectBkg = function(db2, elem, node) { + elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("width", node.width); +}; +const cloudBkg = function(db2, elem, node) { + const w = node.width; + const h = node.height; + const r1 = 0.15 * w; + const r2 = 0.25 * w; + const r3 = 0.35 * w; + const r4 = 0.2 * w; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 0 a${r1},${r1} 0 0,1 ${w * 0.25},${-1 * w * 0.1} + a${r3},${r3} 1 0,1 ${w * 0.4},${-1 * w * 0.1} + a${r2},${r2} 1 0,1 ${w * 0.35},${1 * w * 0.2} + + a${r1},${r1} 1 0,1 ${w * 0.15},${1 * h * 0.35} + a${r4},${r4} 1 0,1 ${-1 * w * 0.15},${1 * h * 0.65} + + a${r2},${r1} 1 0,1 ${-1 * w * 0.25},${w * 0.15} + a${r3},${r3} 1 0,1 ${-1 * w * 0.5},${0} + a${r1},${r1} 1 0,1 ${-1 * w * 0.25},${-1 * w * 0.15} + + a${r1},${r1} 1 0,1 ${-1 * w * 0.1},${-1 * h * 0.35} + a${r4},${r4} 1 0,1 ${w * 0.1},${-1 * h * 0.65} + + H0 V0 Z` + ); +}; +const bangBkg = function(db2, elem, node) { + const w = node.width; + const h = node.height; + const r = 0.15 * w; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 0 a${r},${r} 1 0,0 ${w * 0.25},${-1 * h * 0.1} + a${r},${r} 1 0,0 ${w * 0.25},${0} + a${r},${r} 1 0,0 ${w * 0.25},${0} + a${r},${r} 1 0,0 ${w * 0.25},${1 * h * 0.1} + + a${r},${r} 1 0,0 ${w * 0.15},${1 * h * 0.33} + a${r * 0.8},${r * 0.8} 1 0,0 ${0},${1 * h * 0.34} + a${r},${r} 1 0,0 ${-1 * w * 0.15},${1 * h * 0.33} + + a${r},${r} 1 0,0 ${-1 * w * 0.25},${h * 0.15} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${-1 * h * 0.15} + + a${r},${r} 1 0,0 ${-1 * w * 0.1},${-1 * h * 0.33} + a${r * 0.8},${r * 0.8} 1 0,0 ${0},${-1 * h * 0.34} + a${r},${r} 1 0,0 ${w * 0.1},${-1 * h * 0.33} + + H0 V0 Z` + ); +}; +const circleBkg = function(db2, elem, node) { + elem.append("circle").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("r", node.width / 2); +}; +function insertPolygonShape(parent, w, h, points, node) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("transform", "translate(" + (node.width - w) / 2 + ", " + h + ")"); +} +const hexagonBkg = function(_db, elem, node) { + const h = node.height; + const f = 4; + const m = h / f; + const w = node.width - node.padding + 2 * m; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + insertPolygonShape(elem, w, h, points, node); +}; +const roundedRectBkg = function(db2, elem, node) { + elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("rx", node.padding).attr("ry", node.padding).attr("width", node.width); +}; +const drawNode = function(db2, elem, node, fullSection, conf) { + const htmlLabels = conf.htmlLabels; + const section = fullSection % (MAX_SECTIONS - 1); + const nodeElem = elem.append("g"); + node.section = section; + let sectionClass = "section-" + section; + if (section < 0) { + sectionClass += " section-root"; + } + nodeElem.attr("class", (node.class ? node.class + " " : "") + "mindmap-node " + sectionClass); + const bkgElem = nodeElem.append("g"); + const textElem = nodeElem.append("g"); + const description = node.descr.replace(/()/g, "\n"); + createText(textElem, description, { + useHtmlLabels: htmlLabels, + width: node.width, + classes: "mindmap-node-label" + }); + if (!htmlLabels) { + textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle"); + } + const bbox = textElem.node().getBBox(); + const [fontSize] = parseFontSize(conf.fontSize); + node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; + node.width = bbox.width + 2 * node.padding; + if (node.icon) { + if (node.type === db2.nodeType.CIRCLE) { + node.height += 50; + node.width += 50; + const icon = nodeElem.append("foreignObject").attr("height", "50px").attr("width", node.width).attr("style", "text-align: center;"); + icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); + textElem.attr( + "transform", + "translate(" + node.width / 2 + ", " + (node.height / 2 - 1.5 * node.padding) + ")" + ); + } else { + node.width += 50; + const orgHeight = node.height; + node.height = Math.max(orgHeight, 60); + const heightDiff = Math.abs(node.height - orgHeight); + const icon = nodeElem.append("foreignObject").attr("width", "60px").attr("height", node.height).attr("style", "text-align: center;margin-top:" + heightDiff / 2 + "px;"); + icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); + textElem.attr( + "transform", + "translate(" + (25 + node.width / 2) + ", " + (heightDiff / 2 + node.padding / 2) + ")" + ); + } + } else { + if (!htmlLabels) { + const dx = node.width / 2; + const dy = node.padding / 2; + textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); + } else { + const dx = (node.width - bbox.width) / 2; + const dy = (node.height - bbox.height) / 2; + textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); + } + } + switch (node.type) { + case db2.nodeType.DEFAULT: + defaultBkg(db2, bkgElem, node, section); + break; + case db2.nodeType.ROUNDED_RECT: + roundedRectBkg(db2, bkgElem, node); + break; + case db2.nodeType.RECT: + rectBkg(db2, bkgElem, node); + break; + case db2.nodeType.CIRCLE: + bkgElem.attr("transform", "translate(" + node.width / 2 + ", " + +node.height / 2 + ")"); + circleBkg(db2, bkgElem, node); + break; + case db2.nodeType.CLOUD: + cloudBkg(db2, bkgElem, node); + break; + case db2.nodeType.BANG: + bangBkg(db2, bkgElem, node); + break; + case db2.nodeType.HEXAGON: + hexagonBkg(db2, bkgElem, node); + break; + } + db2.setElementForId(node.id, nodeElem); + return node.height; +}; +const positionNode = function(db2, node) { + const nodeElem = db2.getElementById(node.id); + const x = node.x || 0; + const y = node.y || 0; + nodeElem.attr("transform", "translate(" + x + "," + y + ")"); +}; +cytoscape$1.use(coseBilkent); +function drawNodes(db2, svg, mindmap, section, conf) { + drawNode(db2, svg, mindmap, section, conf); + if (mindmap.children) { + mindmap.children.forEach((child, index) => { + drawNodes(db2, svg, child, section < 0 ? index : section, conf); + }); + } +} +function drawEdges(edgesEl, cy) { + cy.edges().map((edge, id) => { + const data = edge.data(); + if (edge[0]._private.bodyBounds) { + const bounds = edge[0]._private.rscratch; + log$1.trace("Edge: ", id, data); + edgesEl.insert("path").attr( + "d", + `M ${bounds.startX},${bounds.startY} L ${bounds.midX},${bounds.midY} L${bounds.endX},${bounds.endY} ` + ).attr("class", "edge section-edge-" + data.section + " edge-depth-" + data.depth); + } + }); +} +function addNodes(mindmap, cy, conf, level) { + cy.add({ + group: "nodes", + data: { + id: mindmap.id.toString(), + labelText: mindmap.descr, + height: mindmap.height, + width: mindmap.width, + level, + nodeId: mindmap.id, + padding: mindmap.padding, + type: mindmap.type + }, + position: { + x: mindmap.x, + y: mindmap.y + } + }); + if (mindmap.children) { + mindmap.children.forEach((child) => { + addNodes(child, cy, conf, level + 1); + cy.add({ + group: "edges", + data: { + id: `${mindmap.id}_${child.id}`, + source: mindmap.id, + target: child.id, + depth: level, + section: child.section + } + }); + }); + } +} +function layoutMindmap(node, conf) { + return new Promise((resolve) => { + const renderEl = select("body").append("div").attr("id", "cy").attr("style", "display:none"); + const cy = cytoscape$1({ + container: document.getElementById("cy"), + // container to render in + style: [ + { + selector: "edge", + style: { + "curve-style": "bezier" + } + } + ] + }); + renderEl.remove(); + addNodes(node, cy, conf, 0); + cy.nodes().forEach(function(n) { + n.layoutDimensions = () => { + const data = n.data(); + return { w: data.width, h: data.height }; + }; + }); + cy.layout({ + name: "cose-bilkent", + // @ts-ignore Types for cose-bilkent are not correct? + quality: "proof", + styleEnabled: false, + animate: false + }).run(); + cy.ready((e) => { + log$1.info("Ready", e); + resolve(cy); + }); + }); +} +function positionNodes(db2, cy) { + cy.nodes().map((node, id) => { + const data = node.data(); + data.x = node.position().x; + data.y = node.position().y; + positionNode(db2, data); + const el = db2.getElementById(data.nodeId); + log$1.info("Id:", id, "Position: (", node.position().x, ", ", node.position().y, ")", data); + el.attr( + "transform", + `translate(${node.position().x - data.width / 2}, ${node.position().y - data.height / 2})` + ); + el.attr("attr", `apa-${id})`); + }); +} +const draw$2 = async (text, id, _version, diagObj) => { + var _a, _b; + log$1.debug("Rendering mindmap diagram\n" + text); + const db2 = diagObj.db; + const mm = db2.getMindmap(); + if (!mm) { + return; + } + const conf = getConfig$2(); + conf.htmlLabels = false; + const svg = selectSvgElement(id); + const edgesElem = svg.append("g"); + edgesElem.attr("class", "mindmap-edges"); + const nodesElem = svg.append("g"); + nodesElem.attr("class", "mindmap-nodes"); + drawNodes(db2, nodesElem, mm, -1, conf); + const cy = await layoutMindmap(mm, conf); + drawEdges(edgesElem, cy); + positionNodes(db2, cy); + setupGraphViewbox$1( + void 0, + svg, + ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig$2.mindmap.padding, + ((_b = conf.mindmap) == null ? void 0 : _b.useMaxWidth) ?? defaultConfig$2.mindmap.useMaxWidth + ); +}; +const renderer$2 = { + draw: draw$2 +}; +const genSections = (options) => { + let sections = ""; + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i]; + if (isDark(options["lineColor" + i])) { + options["lineColor" + i] = lighten(options["lineColor" + i], 20); + } else { + options["lineColor" + i] = darken(options["lineColor" + i], 20); + } + } + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + const sw = "" + (17 - 3 * i); + sections += ` + .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path { + fill: ${options["cScale" + i]}; + } + .section-${i - 1} text { + fill: ${options["cScaleLabel" + i]}; + } + .node-icon-${i - 1} { + font-size: 40px; + color: ${options["cScaleLabel" + i]}; + } + .section-edge-${i - 1}{ + stroke: ${options["cScale" + i]}; + } + .edge-depth-${i - 1}{ + stroke-width: ${sw}; + } + .section-${i - 1} line { + stroke: ${options["cScaleInv" + i]} ; + stroke-width: 3; + } + + .disabled, .disabled circle, .disabled text { + fill: lightgray; + } + .disabled text { + fill: #efefef; + } + `; + } + return sections; +}; +const getStyles$1 = (options) => ` + .edge { + stroke-width: 3; + } + ${genSections(options)} + .section-root rect, .section-root path, .section-root circle, .section-root polygon { + fill: ${options.git0}; + } + .section-root text { + fill: ${options.gitBranchLabel0}; + } + .icon-container { + height:100%; + display: flex; + justify-content: center; + align-items: center; + } + .edge { + fill: none; + } + .mindmap-node-label { + dy: 1em; + alignment-baseline: middle; + text-anchor: middle; + dominant-baseline: middle; + text-align: center; + } +`; +const styles = getStyles$1; +const diagram$2 = { + db: db$1$1, + renderer: renderer$2, + parser: parser$1$2, + styles +}; + +var mindmapDefinition307c710a = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$2 +}); + +function max(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +function sum(values, valueof) { + let sum = 0; + if (valueof === undefined) { + for (let value of values) { + if (value = +value) { + sum += value; + } + } + } else { + let index = -1; + for (let value of values) { + if (value = +valueof(value, ++index, values)) { + sum += value; + } + } + } + return sum; +} + +function targetDepth(d) { + return d.target.depth; +} + +function left(node) { + return node.depth; +} + +function right(node, n) { + return n - 1 - node.height; +} + +function justify(node, n) { + return node.sourceLinks.length ? node.depth : n - 1; +} + +function center(node) { + return node.targetLinks.length ? node.depth + : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 + : 0; +} + +function constant$1(x) { + return function() { + return x; + }; +} + +function ascendingSourceBreadth(a, b) { + return ascendingBreadth(a.source, b.source) || a.index - b.index; +} + +function ascendingTargetBreadth(a, b) { + return ascendingBreadth(a.target, b.target) || a.index - b.index; +} + +function ascendingBreadth(a, b) { + return a.y0 - b.y0; +} + +function value(d) { + return d.value; +} + +function defaultId(d) { + return d.index; +} + +function defaultNodes(graph) { + return graph.nodes; +} + +function defaultLinks(graph) { + return graph.links; +} + +function find(nodeById, id) { + const node = nodeById.get(id); + if (!node) throw new Error("missing: " + id); + return node; +} + +function computeLinkBreadths({nodes}) { + for (const node of nodes) { + let y0 = node.y0; + let y1 = y0; + for (const link of node.sourceLinks) { + link.y0 = y0 + link.width / 2; + y0 += link.width; + } + for (const link of node.targetLinks) { + link.y1 = y1 + link.width / 2; + y1 += link.width; + } + } +} + +function Sankey() { + let x0 = 0, y0 = 0, x1 = 1, y1 = 1; // extent + let dx = 24; // nodeWidth + let dy = 8, py; // nodePadding + let id = defaultId; + let align = justify; + let sort; + let linkSort; + let nodes = defaultNodes; + let links = defaultLinks; + let iterations = 6; + + function sankey() { + const graph = {nodes: nodes.apply(null, arguments), links: links.apply(null, arguments)}; + computeNodeLinks(graph); + computeNodeValues(graph); + computeNodeDepths(graph); + computeNodeHeights(graph); + computeNodeBreadths(graph); + computeLinkBreadths(graph); + return graph; + } + + sankey.update = function(graph) { + computeLinkBreadths(graph); + return graph; + }; + + sankey.nodeId = function(_) { + return arguments.length ? (id = typeof _ === "function" ? _ : constant$1(_), sankey) : id; + }; + + sankey.nodeAlign = function(_) { + return arguments.length ? (align = typeof _ === "function" ? _ : constant$1(_), sankey) : align; + }; + + sankey.nodeSort = function(_) { + return arguments.length ? (sort = _, sankey) : sort; + }; + + sankey.nodeWidth = function(_) { + return arguments.length ? (dx = +_, sankey) : dx; + }; + + sankey.nodePadding = function(_) { + return arguments.length ? (dy = py = +_, sankey) : dy; + }; + + sankey.nodes = function(_) { + return arguments.length ? (nodes = typeof _ === "function" ? _ : constant$1(_), sankey) : nodes; + }; + + sankey.links = function(_) { + return arguments.length ? (links = typeof _ === "function" ? _ : constant$1(_), sankey) : links; + }; + + sankey.linkSort = function(_) { + return arguments.length ? (linkSort = _, sankey) : linkSort; + }; + + sankey.size = function(_) { + return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0]; + }; + + sankey.extent = function(_) { + return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]]; + }; + + sankey.iterations = function(_) { + return arguments.length ? (iterations = +_, sankey) : iterations; + }; + + function computeNodeLinks({nodes, links}) { + for (const [i, node] of nodes.entries()) { + node.index = i; + node.sourceLinks = []; + node.targetLinks = []; + } + const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d])); + for (const [i, link] of links.entries()) { + link.index = i; + let {source, target} = link; + if (typeof source !== "object") source = link.source = find(nodeById, source); + if (typeof target !== "object") target = link.target = find(nodeById, target); + source.sourceLinks.push(link); + target.targetLinks.push(link); + } + if (linkSort != null) { + for (const {sourceLinks, targetLinks} of nodes) { + sourceLinks.sort(linkSort); + targetLinks.sort(linkSort); + } + } + } + + function computeNodeValues({nodes}) { + for (const node of nodes) { + node.value = node.fixedValue === undefined + ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value)) + : node.fixedValue; + } + } + + function computeNodeDepths({nodes}) { + const n = nodes.length; + let current = new Set(nodes); + let next = new Set; + let x = 0; + while (current.size) { + for (const node of current) { + node.depth = x; + for (const {target} of node.sourceLinks) { + next.add(target); + } + } + if (++x > n) throw new Error("circular link"); + current = next; + next = new Set; + } + } + + function computeNodeHeights({nodes}) { + const n = nodes.length; + let current = new Set(nodes); + let next = new Set; + let x = 0; + while (current.size) { + for (const node of current) { + node.height = x; + for (const {source} of node.targetLinks) { + next.add(source); + } + } + if (++x > n) throw new Error("circular link"); + current = next; + next = new Set; + } + } + + function computeNodeLayers({nodes}) { + const x = max(nodes, d => d.depth) + 1; + const kx = (x1 - x0 - dx) / (x - 1); + const columns = new Array(x); + for (const node of nodes) { + const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x)))); + node.layer = i; + node.x0 = x0 + i * kx; + node.x1 = node.x0 + dx; + if (columns[i]) columns[i].push(node); + else columns[i] = [node]; + } + if (sort) for (const column of columns) { + column.sort(sort); + } + return columns; + } + + function initializeNodeBreadths(columns) { + const ky = min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum(c, value)); + for (const nodes of columns) { + let y = y0; + for (const node of nodes) { + node.y0 = y; + node.y1 = y + node.value * ky; + y = node.y1 + py; + for (const link of node.sourceLinks) { + link.width = link.value * ky; + } + } + y = (y1 - y + py) / (nodes.length + 1); + for (let i = 0; i < nodes.length; ++i) { + const node = nodes[i]; + node.y0 += y * (i + 1); + node.y1 += y * (i + 1); + } + reorderLinks(nodes); + } + } + + function computeNodeBreadths(graph) { + const columns = computeNodeLayers(graph); + py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1)); + initializeNodeBreadths(columns); + for (let i = 0; i < iterations; ++i) { + const alpha = Math.pow(0.99, i); + const beta = Math.max(1 - alpha, (i + 1) / iterations); + relaxRightToLeft(columns, alpha, beta); + relaxLeftToRight(columns, alpha, beta); + } + } + + // Reposition each node based on its incoming (target) links. + function relaxLeftToRight(columns, alpha, beta) { + for (let i = 1, n = columns.length; i < n; ++i) { + const column = columns[i]; + for (const target of column) { + let y = 0; + let w = 0; + for (const {source, value} of target.targetLinks) { + let v = value * (target.layer - source.layer); + y += targetTop(source, target) * v; + w += v; + } + if (!(w > 0)) continue; + let dy = (y / w - target.y0) * alpha; + target.y0 += dy; + target.y1 += dy; + reorderNodeLinks(target); + } + if (sort === undefined) column.sort(ascendingBreadth); + resolveCollisions(column, beta); + } + } + + // Reposition each node based on its outgoing (source) links. + function relaxRightToLeft(columns, alpha, beta) { + for (let n = columns.length, i = n - 2; i >= 0; --i) { + const column = columns[i]; + for (const source of column) { + let y = 0; + let w = 0; + for (const {target, value} of source.sourceLinks) { + let v = value * (target.layer - source.layer); + y += sourceTop(source, target) * v; + w += v; + } + if (!(w > 0)) continue; + let dy = (y / w - source.y0) * alpha; + source.y0 += dy; + source.y1 += dy; + reorderNodeLinks(source); + } + if (sort === undefined) column.sort(ascendingBreadth); + resolveCollisions(column, beta); + } + } + + function resolveCollisions(nodes, alpha) { + const i = nodes.length >> 1; + const subject = nodes[i]; + resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha); + resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha); + resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha); + resolveCollisionsTopToBottom(nodes, y0, 0, alpha); + } + + // Push any overlapping nodes down. + function resolveCollisionsTopToBottom(nodes, y, i, alpha) { + for (; i < nodes.length; ++i) { + const node = nodes[i]; + const dy = (y - node.y0) * alpha; + if (dy > 1e-6) node.y0 += dy, node.y1 += dy; + y = node.y1 + py; + } + } + + // Push any overlapping nodes up. + function resolveCollisionsBottomToTop(nodes, y, i, alpha) { + for (; i >= 0; --i) { + const node = nodes[i]; + const dy = (node.y1 - y) * alpha; + if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy; + y = node.y0 - py; + } + } + + function reorderNodeLinks({sourceLinks, targetLinks}) { + if (linkSort === undefined) { + for (const {source: {sourceLinks}} of targetLinks) { + sourceLinks.sort(ascendingTargetBreadth); + } + for (const {target: {targetLinks}} of sourceLinks) { + targetLinks.sort(ascendingSourceBreadth); + } + } + } + + function reorderLinks(nodes) { + if (linkSort === undefined) { + for (const {sourceLinks, targetLinks} of nodes) { + sourceLinks.sort(ascendingTargetBreadth); + targetLinks.sort(ascendingSourceBreadth); + } + } + } + + // Returns the target.y0 that would produce an ideal link from source to target. + function targetTop(source, target) { + let y = source.y0 - (source.sourceLinks.length - 1) * py / 2; + for (const {target: node, width} of source.sourceLinks) { + if (node === target) break; + y += width + py; + } + for (const {source: node, width} of target.targetLinks) { + if (node === source) break; + y -= width; + } + return y; + } + + // Returns the source.y0 that would produce an ideal link from source to target. + function sourceTop(source, target) { + let y = target.y0 - (target.targetLinks.length - 1) * py / 2; + for (const {source: node, width} of target.targetLinks) { + if (node === source) break; + y += width + py; + } + for (const {target: node, width} of source.sourceLinks) { + if (node === target) break; + y -= width; + } + return y; + } + + return sankey; +} + +var pi = Math.PI, + tau = 2 * pi, + epsilon = 1e-6, + tauEpsilon = tau - epsilon; + +function Path() { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; +} + +function path() { + return new Path; +} + +Path.prototype = path.prototype = { + constructor: Path, + moveTo: function(x, y) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y); + }, + closePath: function() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._ += "Z"; + } + }, + lineTo: function(x, y) { + this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y); + }, + quadraticCurveTo: function(x1, y1, x, y) { + this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { + this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + arcTo: function(x1, y1, x2, y2, r) { + x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; + var x0 = this._x1, + y0 = this._y1, + x21 = x2 - x1, + y21 = y2 - y1, + x01 = x0 - x1, + y01 = y0 - y1, + l01_2 = x01 * x01 + y01 * y01; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x1,y1). + if (this._x1 === null) { + this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Or, is (x1,y1) coincident with (x0,y0)? Do nothing. + else if (!(l01_2 > epsilon)); + + // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear? + // Equivalently, is (x1,y1) coincident with (x2,y2)? + // Or, is the radius zero? Line to (x1,y1). + else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) { + this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Otherwise, draw an arc! + else { + var x20 = x2 - x0, + y20 = y2 - y0, + l21_2 = x21 * x21 + y21 * y21, + l20_2 = x20 * x20 + y20 * y20, + l21 = Math.sqrt(l21_2), + l01 = Math.sqrt(l01_2), + l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), + t01 = l / l01, + t21 = l / l21; + + // If the start tangent is not coincident with (x0,y0), line to. + if (Math.abs(t01 - 1) > epsilon) { + this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01); + } + + this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21); + } + }, + arc: function(x, y, r, a0, a1, ccw) { + x = +x, y = +y, r = +r, ccw = !!ccw; + var dx = r * Math.cos(a0), + dy = r * Math.sin(a0), + x0 = x + dx, + y0 = y + dy, + cw = 1 ^ ccw, + da = ccw ? a0 - a1 : a1 - a0; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x0,y0). + if (this._x1 === null) { + this._ += "M" + x0 + "," + y0; + } + + // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). + else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) { + this._ += "L" + x0 + "," + y0; + } + + // Is this arc empty? We’re done. + if (!r) return; + + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau + tau; + + // Is this a complete circle? Draw two arcs to complete the circle. + if (da > tauEpsilon) { + this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0); + } + + // Is this arc non-empty? Draw an arc! + else if (da > epsilon) { + this._ += "A" + r + "," + r + ",0," + (+(da >= pi)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1)); + } + }, + rect: function(x, y, w, h) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z"; + }, + toString: function() { + return this._; + } +}; + +function constant(x) { + return function constant() { + return x; + }; +} + +function x(p) { + return p[0]; +} + +function y(p) { + return p[1]; +} + +var slice = Array.prototype.slice; + +function linkSource(d) { + return d.source; +} + +function linkTarget(d) { + return d.target; +} + +function link(curve) { + var source = linkSource, + target = linkTarget, + x$1 = x, + y$1 = y, + context = null; + + function link() { + var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv); + if (!context) context = buffer = path(); + curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv)); + if (buffer) return context = null, buffer + "" || null; + } + + link.source = function(_) { + return arguments.length ? (source = _, link) : source; + }; + + link.target = function(_) { + return arguments.length ? (target = _, link) : target; + }; + + link.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link) : x$1; + }; + + link.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link) : y$1; + }; + + link.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), link) : context; + }; + + return link; +} + +function curveHorizontal(context, x0, y0, x1, y1) { + context.moveTo(x0, y0); + context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1); +} + +function linkHorizontal() { + return link(curveHorizontal); +} + +function horizontalSource(d) { + return [d.source.x1, d.y0]; +} + +function horizontalTarget(d) { + return [d.target.x0, d.y1]; +} + +function sankeyLinkHorizontal() { + return linkHorizontal() + .source(horizontalSource) + .target(horizontalTarget); +} + +var parser$2 = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SANKEY": 4, "NEWLINE": 5, "csv": 6, "opt_eof": 7, "record": 8, "csv_tail": 9, "EOF": 10, "field[source]": 11, "COMMA": 12, "field[target]": 13, "field[value]": 14, "field": 15, "escaped": 16, "non_escaped": 17, "DQUOTE": 18, "ESCAPED_TEXT": 19, "NON_ESCAPED_TEXT": 20, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" }, + productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 7: + const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"')); + const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"')); + const value = parseFloat($$[$0].trim()); + yy.addLink(source, target, value); + break; + case 8: + case 9: + case 11: + this.$ = $$[$0]; + break; + case 10: + this.$ = $$[$0 - 1]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])], + defaultActions: { 11: [2, 1], 12: [2, 5] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.pushState("csv"); + return 4; + case 1: + return 10; + case 2: + return 5; + case 3: + return 12; + case 4: + this.pushState("escaped_text"); + return 18; + case 5: + return 20; + case 6: + this.popState("escaped_text"); + return 18; + case 7: + return 19; + } + }, + rules: [/^(?:sankey-beta\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i], + conditions: { "csv": { "rules": [1, 2, 3, 4, 5, 6, 7], "inclusive": false }, "escaped_text": { "rules": [6, 7], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser$2.parser = parser$2; +const parser$1$1 = parser$2; +let links = []; +let nodes = []; +let nodesMap = {}; +const clear$1 = () => { + links = []; + nodes = []; + nodesMap = {}; + clear$k(); +}; +class SankeyLink { + constructor(source, target, value = 0) { + this.source = source; + this.target = target; + this.value = value; + } +} +const addLink = (source, target, value) => { + links.push(new SankeyLink(source, target, value)); +}; +class SankeyNode { + constructor(ID) { + this.ID = ID; + } +} +const findOrCreateNode = (ID) => { + ID = common$1.sanitizeText(ID, getConfig$2()); + if (!nodesMap[ID]) { + nodesMap[ID] = new SankeyNode(ID); + nodes.push(nodesMap[ID]); + } + return nodesMap[ID]; +}; +const getNodes = () => nodes; +const getLinks = () => links; +const getGraph = () => ({ + nodes: nodes.map((node) => ({ id: node.ID })), + links: links.map((link) => ({ + source: link.source.ID, + target: link.target.ID, + value: link.value + })) +}); +const db$2 = { + nodesMap, + getConfig: () => getConfig$2().sankey, + getNodes, + getLinks, + getGraph, + addLink, + findOrCreateNode, + getAccTitle, + setAccTitle, + getAccDescription, + setAccDescription, + getDiagramTitle, + setDiagramTitle, + clear: clear$1 +}; +const _Uid = class _Uid2 { + static next(name) { + return new _Uid2(name + ++_Uid2.count); + } + constructor(id) { + this.id = id; + this.href = `#${id}`; + } + toString() { + return "url(" + this.href + ")"; + } +}; +_Uid.count = 0; +let Uid = _Uid; +const alignmentsMap = { + left: left, + right: right, + center: center, + justify: justify +}; +const draw$1 = function(text, id, _version, diagObj) { + const { securityLevel, sankey: conf } = getConfig$2(); + const defaultSankeyConfig = defaultConfig.sankey; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const width = (conf == null ? void 0 : conf.width) ?? defaultSankeyConfig.width; + const height = (conf == null ? void 0 : conf.height) ?? defaultSankeyConfig.width; + const useMaxWidth = (conf == null ? void 0 : conf.useMaxWidth) ?? defaultSankeyConfig.useMaxWidth; + const nodeAlignment = (conf == null ? void 0 : conf.nodeAlignment) ?? defaultSankeyConfig.nodeAlignment; + const prefix = (conf == null ? void 0 : conf.prefix) ?? defaultSankeyConfig.prefix; + const suffix = (conf == null ? void 0 : conf.suffix) ?? defaultSankeyConfig.suffix; + const showValues = (conf == null ? void 0 : conf.showValues) ?? defaultSankeyConfig.showValues; + const graph = diagObj.db.getGraph(); + const nodeAlign = alignmentsMap[nodeAlignment]; + const nodeWidth = 10; + const sankey$1 = Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(10 + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([ + [0, 0], + [width, height] + ]); + sankey$1(graph); + const colorScheme = ordinal(schemeTableau10); + svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) { + return "translate(" + d.x0 + "," + d.y0 + ")"; + }).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => { + return d.y1 - d.y0; + }).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => colorScheme(d.id)); + const getText = ({ id: id2, value }) => { + if (!showValues) { + return id2; + } + return `${id2} +${prefix}${Math.round(value * 100) / 100}${suffix}`; + }; + svg.append("g").attr("class", "node-labels").attr("font-family", "sans-serif").attr("font-size", 14).selectAll("text").data(graph.nodes).join("text").attr("x", (d) => d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => d.x0 < width / 2 ? "start" : "end").text(getText); + const link = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply"); + const linkColor = (conf == null ? void 0 : conf.linkColor) || "gradient"; + if (linkColor === "gradient") { + const gradient = link.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0); + gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => colorScheme(d.source.id)); + gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => colorScheme(d.target.id)); + } + let coloring; + switch (linkColor) { + case "gradient": + coloring = (d) => d.uid; + break; + case "source": + coloring = (d) => colorScheme(d.source.id); + break; + case "target": + coloring = (d) => colorScheme(d.target.id); + break; + default: + coloring = linkColor; + } + link.append("path").attr("d", sankeyLinkHorizontal()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width)); + setupGraphViewbox$1(void 0, svg, 0, useMaxWidth); +}; +const renderer$1 = { + draw: draw$1 +}; +const prepareTextForParsing = (text) => { + const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, "\n").trim(); + return textToParse; +}; +const originalParse = parser$1$1.parse.bind(parser$1$1); +parser$1$1.parse = (text) => originalParse(prepareTextForParsing(text)); +const diagram$1 = { + parser: parser$1$1, + db: db$2, + renderer: renderer$1 +}; + +var sankeyDiagram707fac0f = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram$1 +}); + +var _a, _b; +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 7], $V1 = [1, 13], $V2 = [1, 14], $V3 = [1, 15], $V4 = [1, 19], $V5 = [1, 16], $V6 = [1, 17], $V7 = [1, 18], $V8 = [8, 30], $V9 = [8, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Va = [1, 23], $Vb = [1, 24], $Vc = [8, 15, 16, 21, 28, 29, 30, 31, 32, 40, 44, 47], $Vd = [8, 15, 16, 21, 27, 28, 29, 30, 31, 32, 40, 44, 47], $Ve = [1, 49]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "spaceLines": 3, "SPACELINE": 4, "NL": 5, "separator": 6, "SPACE": 7, "EOF": 8, "start": 9, "BLOCK_DIAGRAM_KEY": 10, "document": 11, "stop": 12, "statement": 13, "link": 14, "LINK": 15, "START_LINK": 16, "LINK_LABEL": 17, "STR": 18, "nodeStatement": 19, "columnsStatement": 20, "SPACE_BLOCK": 21, "blockStatement": 22, "classDefStatement": 23, "cssClassStatement": 24, "styleStatement": 25, "node": 26, "SIZE": 27, "COLUMNS": 28, "id-block": 29, "end": 30, "block": 31, "NODE_ID": 32, "nodeShapeNLabel": 33, "dirList": 34, "DIR": 35, "NODE_DSTART": 36, "NODE_DEND": 37, "BLOCK_ARROW_START": 38, "BLOCK_ARROW_END": 39, "classDef": 40, "CLASSDEF_ID": 41, "CLASSDEF_STYLEOPTS": 42, "DEFAULT": 43, "class": 44, "CLASSENTITY_IDS": 45, "STYLECLASS": 46, "style": 47, "STYLE_ENTITY_IDS": 48, "STYLE_DEFINITION_DATA": 49, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACELINE", 5: "NL", 7: "SPACE", 8: "EOF", 10: "BLOCK_DIAGRAM_KEY", 15: "LINK", 16: "START_LINK", 17: "LINK_LABEL", 18: "STR", 21: "SPACE_BLOCK", 27: "SIZE", 28: "COLUMNS", 29: "id-block", 30: "end", 31: "block", 32: "NODE_ID", 35: "DIR", 36: "NODE_DSTART", 37: "NODE_DEND", 38: "BLOCK_ARROW_START", 39: "BLOCK_ARROW_END", 40: "classDef", 41: "CLASSDEF_ID", 42: "CLASSDEF_STYLEOPTS", 43: "DEFAULT", 44: "class", 45: "CLASSENTITY_IDS", 46: "STYLECLASS", 47: "style", 48: "STYLE_ENTITY_IDS", 49: "STYLE_DEFINITION_DATA" }, + productions_: [0, [3, 1], [3, 2], [3, 2], [6, 1], [6, 1], [6, 1], [9, 3], [12, 1], [12, 1], [12, 2], [12, 2], [11, 1], [11, 2], [14, 1], [14, 4], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [13, 1], [19, 3], [19, 2], [19, 1], [20, 1], [22, 4], [22, 3], [26, 1], [26, 2], [34, 1], [34, 2], [33, 3], [33, 4], [23, 3], [23, 3], [24, 3], [25, 3]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 4: + yy.getLogger().debug("Rule: separator (NL) "); + break; + case 5: + yy.getLogger().debug("Rule: separator (Space) "); + break; + case 6: + yy.getLogger().debug("Rule: separator (EOF) "); + break; + case 7: + yy.getLogger().debug("Rule: hierarchy: ", $$[$0 - 1]); + yy.setHierarchy($$[$0 - 1]); + break; + case 8: + yy.getLogger().debug("Stop NL "); + break; + case 9: + yy.getLogger().debug("Stop EOF "); + break; + case 10: + yy.getLogger().debug("Stop NL2 "); + break; + case 11: + yy.getLogger().debug("Stop EOF2 "); + break; + case 12: + yy.getLogger().debug("Rule: statement: ", $$[$0]); + typeof $$[$0].length === "number" ? this.$ = $$[$0] : this.$ = [$$[$0]]; + break; + case 13: + yy.getLogger().debug("Rule: statement #2: ", $$[$0 - 1]); + this.$ = [$$[$0 - 1]].concat($$[$0]); + break; + case 14: + yy.getLogger().debug("Rule: link: ", $$[$0], yytext); + this.$ = { edgeTypeStr: $$[$0], label: "" }; + break; + case 15: + yy.getLogger().debug("Rule: LABEL link: ", $$[$0 - 3], $$[$0 - 1], $$[$0]); + this.$ = { edgeTypeStr: $$[$0], label: $$[$0 - 1] }; + break; + case 18: + const num = parseInt($$[$0]); + const spaceId = yy.generateId(); + this.$ = { id: spaceId, type: "space", label: "", width: num, children: [] }; + break; + case 23: + yy.getLogger().debug("Rule: (nodeStatement link node) ", $$[$0 - 2], $$[$0 - 1], $$[$0], " typestr: ", $$[$0 - 1].edgeTypeStr); + const edgeData = yy.edgeStrToEdgeData($$[$0 - 1].edgeTypeStr); + this.$ = [ + { id: $$[$0 - 2].id, label: $$[$0 - 2].label, type: $$[$0 - 2].type, directions: $$[$0 - 2].directions }, + { id: $$[$0 - 2].id + "-" + $$[$0].id, start: $$[$0 - 2].id, end: $$[$0].id, label: $$[$0 - 1].label, type: "edge", directions: $$[$0].directions, arrowTypeEnd: edgeData, arrowTypeStart: "arrow_open" }, + { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions } + ]; + break; + case 24: + yy.getLogger().debug("Rule: nodeStatement (abc88 node size) ", $$[$0 - 1], $$[$0]); + this.$ = { id: $$[$0 - 1].id, label: $$[$0 - 1].label, type: yy.typeStr2Type($$[$0 - 1].typeStr), directions: $$[$0 - 1].directions, widthInColumns: parseInt($$[$0], 10) }; + break; + case 25: + yy.getLogger().debug("Rule: nodeStatement (node) ", $$[$0]); + this.$ = { id: $$[$0].id, label: $$[$0].label, type: yy.typeStr2Type($$[$0].typeStr), directions: $$[$0].directions, widthInColumns: 1 }; + break; + case 26: + yy.getLogger().debug("APA123", this ? this : "na"); + yy.getLogger().debug("COLUMNS: ", $$[$0]); + this.$ = { type: "column-setting", columns: $$[$0] === "auto" ? -1 : parseInt($$[$0]) }; + break; + case 27: + yy.getLogger().debug("Rule: id-block statement : ", $$[$0 - 2], $$[$0 - 1]); + yy.generateId(); + this.$ = { ...$$[$0 - 2], type: "composite", children: $$[$0 - 1] }; + break; + case 28: + yy.getLogger().debug("Rule: blockStatement : ", $$[$0 - 2], $$[$0 - 1], $$[$0]); + const id = yy.generateId(); + this.$ = { id, type: "composite", label: "", children: $$[$0 - 1] }; + break; + case 29: + yy.getLogger().debug("Rule: node (NODE_ID separator): ", $$[$0]); + this.$ = { id: $$[$0] }; + break; + case 30: + yy.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ", $$[$0 - 1], $$[$0]); + this.$ = { id: $$[$0 - 1], label: $$[$0].label, typeStr: $$[$0].typeStr, directions: $$[$0].directions }; + break; + case 31: + yy.getLogger().debug("Rule: dirList: ", $$[$0]); + this.$ = [$$[$0]]; + break; + case 32: + yy.getLogger().debug("Rule: dirList: ", $$[$0 - 1], $$[$0]); + this.$ = [$$[$0 - 1]].concat($$[$0]); + break; + case 33: + yy.getLogger().debug("Rule: nodeShapeNLabel: ", $$[$0 - 2], $$[$0 - 1], $$[$0]); + this.$ = { typeStr: $$[$0 - 2] + $$[$0], label: $$[$0 - 1] }; + break; + case 34: + yy.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ", $$[$0 - 3], $$[$0 - 2], " #3:", $$[$0 - 1], $$[$0]); + this.$ = { typeStr: $$[$0 - 3] + $$[$0], label: $$[$0 - 2], directions: $$[$0 - 1] }; + break; + case 35: + case 36: + this.$ = { type: "classDef", id: $$[$0 - 1].trim(), css: $$[$0].trim() }; + break; + case 37: + this.$ = { type: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; + break; + case 38: + this.$ = { type: "applyStyles", id: $$[$0 - 1].trim(), stylesStr: $$[$0].trim() }; + break; + } + }, + table: [{ 9: 1, 10: [1, 2] }, { 1: [3] }, { 11: 3, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 8: [1, 20] }, o($V8, [2, 12], { 13: 4, 19: 5, 20: 6, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 11: 21, 21: $V0, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }), o($V9, [2, 16], { 14: 22, 15: $Va, 16: $Vb }), o($V9, [2, 17]), o($V9, [2, 18]), o($V9, [2, 19]), o($V9, [2, 20]), o($V9, [2, 21]), o($V9, [2, 22]), o($Vc, [2, 25], { 27: [1, 25] }), o($V9, [2, 26]), { 19: 26, 26: 12, 32: $V4 }, { 11: 27, 13: 4, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 41: [1, 28], 43: [1, 29] }, { 45: [1, 30] }, { 48: [1, 31] }, o($Vd, [2, 29], { 33: 32, 36: [1, 33], 38: [1, 34] }), { 1: [2, 7] }, o($V8, [2, 13]), { 26: 35, 32: $V4 }, { 32: [2, 14] }, { 17: [1, 36] }, o($Vc, [2, 24]), { 11: 37, 13: 4, 14: 22, 15: $Va, 16: $Vb, 19: 5, 20: 6, 21: $V0, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 28: $V1, 29: $V2, 31: $V3, 32: $V4, 40: $V5, 44: $V6, 47: $V7 }, { 30: [1, 38] }, { 42: [1, 39] }, { 42: [1, 40] }, { 46: [1, 41] }, { 49: [1, 42] }, o($Vd, [2, 30]), { 18: [1, 43] }, { 18: [1, 44] }, o($Vc, [2, 23]), { 18: [1, 45] }, { 30: [1, 46] }, o($V9, [2, 28]), o($V9, [2, 35]), o($V9, [2, 36]), o($V9, [2, 37]), o($V9, [2, 38]), { 37: [1, 47] }, { 34: 48, 35: $Ve }, { 15: [1, 50] }, o($V9, [2, 27]), o($Vd, [2, 33]), { 39: [1, 51] }, { 34: 52, 35: $Ve, 39: [2, 31] }, { 32: [2, 15] }, o($Vd, [2, 34]), { 39: [2, 32] }], + defaultActions: { 20: [2, 7], 23: [2, 14], 50: [2, 15], 52: [2, 32] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 10; + case 1: + yy.getLogger().debug("Found space-block"); + return 31; + case 2: + yy.getLogger().debug("Found nl-block"); + return 31; + case 3: + yy.getLogger().debug("Found space-block"); + return 29; + case 4: + yy.getLogger().debug(".", yy_.yytext); + break; + case 5: + yy.getLogger().debug("_", yy_.yytext); + break; + case 6: + return 5; + case 7: + yy_.yytext = -1; + return 28; + case 8: + yy_.yytext = yy_.yytext.replace(/columns\s+/, ""); + yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); + return 28; + case 9: + this.pushState("md_string"); + break; + case 10: + return "MD_STR"; + case 11: + this.popState(); + break; + case 12: + this.pushState("string"); + break; + case 13: + yy.getLogger().debug("LEX: POPPING STR:", yy_.yytext); + this.popState(); + break; + case 14: + yy.getLogger().debug("LEX: STR end:", yy_.yytext); + return "STR"; + case 15: + yy_.yytext = yy_.yytext.replace(/space\:/, ""); + yy.getLogger().debug("SPACE NUM (LEX)", yy_.yytext); + return 21; + case 16: + yy_.yytext = "1"; + yy.getLogger().debug("COLUMNS (LEX)", yy_.yytext); + return 21; + case 17: + return 43; + case 18: + return "LINKSTYLE"; + case 19: + return "INTERPOLATE"; + case 20: + this.pushState("CLASSDEF"); + return 40; + case 21: + this.popState(); + this.pushState("CLASSDEFID"); + return "DEFAULT_CLASSDEF_ID"; + case 22: + this.popState(); + this.pushState("CLASSDEFID"); + return 41; + case 23: + this.popState(); + return 42; + case 24: + this.pushState("CLASS"); + return 44; + case 25: + this.popState(); + this.pushState("CLASS_STYLE"); + return 45; + case 26: + this.popState(); + return 46; + case 27: + this.pushState("STYLE_STMNT"); + return 47; + case 28: + this.popState(); + this.pushState("STYLE_DEFINITION"); + return 48; + case 29: + this.popState(); + return 49; + case 30: + this.pushState("acc_title"); + return "acc_title"; + case 31: + this.popState(); + return "acc_title_value"; + case 32: + this.pushState("acc_descr"); + return "acc_descr"; + case 33: + this.popState(); + return "acc_descr_value"; + case 34: + this.pushState("acc_descr_multiline"); + break; + case 35: + this.popState(); + break; + case 36: + return "acc_descr_multiline_value"; + case 37: + return 30; + case 38: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 39: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 40: + this.popState(); + yy.getLogger().debug("Lex: ))"); + return "NODE_DEND"; + case 41: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 42: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 43: + this.popState(); + yy.getLogger().debug("Lex: (-"); + return "NODE_DEND"; + case 44: + this.popState(); + yy.getLogger().debug("Lex: -)"); + return "NODE_DEND"; + case 45: + this.popState(); + yy.getLogger().debug("Lex: (("); + return "NODE_DEND"; + case 46: + this.popState(); + yy.getLogger().debug("Lex: ]]"); + return "NODE_DEND"; + case 47: + this.popState(); + yy.getLogger().debug("Lex: ("); + return "NODE_DEND"; + case 48: + this.popState(); + yy.getLogger().debug("Lex: ])"); + return "NODE_DEND"; + case 49: + this.popState(); + yy.getLogger().debug("Lex: /]"); + return "NODE_DEND"; + case 50: + this.popState(); + yy.getLogger().debug("Lex: /]"); + return "NODE_DEND"; + case 51: + this.popState(); + yy.getLogger().debug("Lex: )]"); + return "NODE_DEND"; + case 52: + this.popState(); + yy.getLogger().debug("Lex: )"); + return "NODE_DEND"; + case 53: + this.popState(); + yy.getLogger().debug("Lex: ]>"); + return "NODE_DEND"; + case 54: + this.popState(); + yy.getLogger().debug("Lex: ]"); + return "NODE_DEND"; + case 55: + yy.getLogger().debug("Lexa: -)"); + this.pushState("NODE"); + return 36; + case 56: + yy.getLogger().debug("Lexa: (-"); + this.pushState("NODE"); + return 36; + case 57: + yy.getLogger().debug("Lexa: ))"); + this.pushState("NODE"); + return 36; + case 58: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 59: + yy.getLogger().debug("Lex: ((("); + this.pushState("NODE"); + return 36; + case 60: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 61: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 62: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 63: + yy.getLogger().debug("Lexc: >"); + this.pushState("NODE"); + return 36; + case 64: + yy.getLogger().debug("Lexa: (["); + this.pushState("NODE"); + return 36; + case 65: + yy.getLogger().debug("Lexa: )"); + this.pushState("NODE"); + return 36; + case 66: + this.pushState("NODE"); + return 36; + case 67: + this.pushState("NODE"); + return 36; + case 68: + this.pushState("NODE"); + return 36; + case 69: + this.pushState("NODE"); + return 36; + case 70: + this.pushState("NODE"); + return 36; + case 71: + this.pushState("NODE"); + return 36; + case 72: + this.pushState("NODE"); + return 36; + case 73: + yy.getLogger().debug("Lexa: ["); + this.pushState("NODE"); + return 36; + case 74: + this.pushState("BLOCK_ARROW"); + yy.getLogger().debug("LEX ARR START"); + return 38; + case 75: + yy.getLogger().debug("Lex: NODE_ID", yy_.yytext); + return 32; + case 76: + yy.getLogger().debug("Lex: EOF", yy_.yytext); + return 8; + case 77: + this.pushState("md_string"); + break; + case 78: + this.pushState("md_string"); + break; + case 79: + return "NODE_DESCR"; + case 80: + this.popState(); + break; + case 81: + yy.getLogger().debug("Lex: Starting string"); + this.pushState("string"); + break; + case 82: + yy.getLogger().debug("LEX ARR: Starting string"); + this.pushState("string"); + break; + case 83: + yy.getLogger().debug("LEX: NODE_DESCR:", yy_.yytext); + return "NODE_DESCR"; + case 84: + yy.getLogger().debug("LEX POPPING"); + this.popState(); + break; + case 85: + yy.getLogger().debug("Lex: =>BAE"); + this.pushState("ARROW_DIR"); + break; + case 86: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (right): dir:", yy_.yytext); + return "DIR"; + case 87: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (left):", yy_.yytext); + return "DIR"; + case 88: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (x):", yy_.yytext); + return "DIR"; + case 89: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (y):", yy_.yytext); + return "DIR"; + case 90: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (up):", yy_.yytext); + return "DIR"; + case 91: + yy_.yytext = yy_.yytext.replace(/^,\s*/, ""); + yy.getLogger().debug("Lex (down):", yy_.yytext); + return "DIR"; + case 92: + yy_.yytext = "]>"; + yy.getLogger().debug("Lex (ARROW_DIR end):", yy_.yytext); + this.popState(); + this.popState(); + return "BLOCK_ARROW_END"; + case 93: + yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); + return 15; + case 94: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 95: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 96: + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 97: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 98: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 99: + yy.getLogger().debug("Lex: START_LINK", yy_.yytext); + this.pushState("LLABEL"); + return 16; + case 100: + this.pushState("md_string"); + break; + case 101: + yy.getLogger().debug("Lex: Starting string"); + this.pushState("string"); + return "LINK_LABEL"; + case 102: + this.popState(); + yy.getLogger().debug("Lex: LINK", "#" + yy_.yytext + "#"); + return 15; + case 103: + this.popState(); + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 104: + this.popState(); + yy.getLogger().debug("Lex: LINK", yy_.yytext); + return 15; + case 105: + yy.getLogger().debug("Lex: COLON", yy_.yytext); + yy_.yytext = yy_.yytext.slice(1); + return 27; + } + }, + rules: [/^(?:block-beta\b)/, /^(?:block\s+)/, /^(?:block\n+)/, /^(?:block:)/, /^(?:[\s]+)/, /^(?:[\n]+)/, /^(?:((\u000D\u000A)|(\u000A)))/, /^(?:columns\s+auto\b)/, /^(?:columns\s+[\d]+)/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]*)/, /^(?:space[:]\d+)/, /^(?:space\b)/, /^(?:default\b)/, /^(?:linkStyle\b)/, /^(?:interpolate\b)/, /^(?:classDef\s+)/, /^(?:DEFAULT\s+)/, /^(?:\w+\s+)/, /^(?:[^\n]*)/, /^(?:class\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:style\s+)/, /^(?:(\w+)+((,\s*\w+)*))/, /^(?:[^\n]*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:end\b\s*)/, /^(?:\(\(\()/, /^(?:\)\)\))/, /^(?:[\)]\))/, /^(?:\}\})/, /^(?:\})/, /^(?:\(-)/, /^(?:-\))/, /^(?:\(\()/, /^(?:\]\])/, /^(?:\()/, /^(?:\]\))/, /^(?:\\\])/, /^(?:\/\])/, /^(?:\)\])/, /^(?:[\)])/, /^(?:\]>)/, /^(?:[\]])/, /^(?:-\))/, /^(?:\(-)/, /^(?:\)\))/, /^(?:\))/, /^(?:\(\(\()/, /^(?:\(\()/, /^(?:\{\{)/, /^(?:\{)/, /^(?:>)/, /^(?:\(\[)/, /^(?:\()/, /^(?:\[\[)/, /^(?:\[\|)/, /^(?:\[\()/, /^(?:\)\)\))/, /^(?:\[\\)/, /^(?:\[\/)/, /^(?:\[\\)/, /^(?:\[)/, /^(?:<\[)/, /^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/, /^(?:$)/, /^(?:["][`])/, /^(?:["][`])/, /^(?:[^`"]+)/, /^(?:[`]["])/, /^(?:["])/, /^(?:["])/, /^(?:[^"]+)/, /^(?:["])/, /^(?:\]>\s*\()/, /^(?:,?\s*right\s*)/, /^(?:,?\s*left\s*)/, /^(?:,?\s*x\s*)/, /^(?:,?\s*y\s*)/, /^(?:,?\s*up\s*)/, /^(?:,?\s*down\s*)/, /^(?:\)\s*)/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?:\s*~~[\~]+\s*)/, /^(?:\s*[xo<]?--\s*)/, /^(?:\s*[xo<]?==\s*)/, /^(?:\s*[xo<]?-\.\s*)/, /^(?:["][`])/, /^(?:["])/, /^(?:\s*[xo<]?--+[-xo>]\s*)/, /^(?:\s*[xo<]?==+[=xo>]\s*)/, /^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/, /^(?::\d+)/], + conditions: { "STYLE_DEFINITION": { "rules": [29], "inclusive": false }, "STYLE_STMNT": { "rules": [28], "inclusive": false }, "CLASSDEFID": { "rules": [23], "inclusive": false }, "CLASSDEF": { "rules": [21, 22], "inclusive": false }, "CLASS_STYLE": { "rules": [26], "inclusive": false }, "CLASS": { "rules": [25], "inclusive": false }, "LLABEL": { "rules": [100, 101, 102, 103, 104], "inclusive": false }, "ARROW_DIR": { "rules": [86, 87, 88, 89, 90, 91, 92], "inclusive": false }, "BLOCK_ARROW": { "rules": [77, 82, 85], "inclusive": false }, "NODE": { "rules": [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 78, 81], "inclusive": false }, "md_string": { "rules": [10, 11, 79, 80], "inclusive": false }, "space": { "rules": [], "inclusive": false }, "string": { "rules": [13, 14, 83, 84], "inclusive": false }, "acc_descr_multiline": { "rules": [35, 36], "inclusive": false }, "acc_descr": { "rules": [33], "inclusive": false }, "acc_title": { "rules": [31], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 24, 27, 30, 32, 34, 37, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 93, 94, 95, 96, 97, 98, 99, 105], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let blockDatabase = {}; +let edgeList = []; +let edgeCount = {}; +const COLOR_KEYWORD = "color"; +const FILL_KEYWORD = "fill"; +const BG_FILL = "bgFill"; +const STYLECLASS_SEP = ","; +const config = getConfig$2(); +let classes = {}; +const sanitizeText = (txt) => common$1.sanitizeText(txt, config); +const addStyleClass = function(id, styleAttributes = "") { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + const foundClass = classes[id]; + if (styleAttributes !== void 0 && styleAttributes !== null) { + styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { + const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); + if (attrib.match(COLOR_KEYWORD)) { + const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL); + const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD); + foundClass.textStyles.push(newStyle2); + } + foundClass.styles.push(fixedAttrib); + }); + } +}; +const addStyle2Node = function(id, styles = "") { + const foundBlock = blockDatabase[id]; + if (styles !== void 0 && styles !== null) { + foundBlock.styles = styles.split(STYLECLASS_SEP); + } +}; +const setCssClass = function(itemIds, cssClassName) { + itemIds.split(",").forEach(function(id) { + let foundBlock = blockDatabase[id]; + if (foundBlock === void 0) { + const trimmedId = id.trim(); + blockDatabase[trimmedId] = { id: trimmedId, type: "na", children: [] }; + foundBlock = blockDatabase[trimmedId]; + } + if (!foundBlock.classes) { + foundBlock.classes = []; + } + foundBlock.classes.push(cssClassName); + }); +}; +const populateBlockDatabase = (_blockList, parent) => { + const blockList = _blockList.flat(); + const children = []; + for (const block of blockList) { + if (block.label) { + block.label = sanitizeText(block.label); + } + if (block.type === "classDef") { + addStyleClass(block.id, block.css); + continue; + } + if (block.type === "applyClass") { + setCssClass(block.id, (block == null ? void 0 : block.styleClass) || ""); + continue; + } + if (block.type === "applyStyles") { + if (block == null ? void 0 : block.stylesStr) { + addStyle2Node(block.id, block == null ? void 0 : block.stylesStr); + } + continue; + } + if (block.type === "column-setting") { + parent.columns = block.columns || -1; + } else if (block.type === "edge") { + if (edgeCount[block.id]) { + edgeCount[block.id]++; + } else { + edgeCount[block.id] = 1; + } + block.id = edgeCount[block.id] + "-" + block.id; + edgeList.push(block); + } else { + if (!block.label) { + if (block.type === "composite") { + block.label = ""; + } else { + block.label = block.id; + } + } + const newBlock = !blockDatabase[block.id]; + if (newBlock) { + blockDatabase[block.id] = block; + } else { + if (block.type !== "na") { + blockDatabase[block.id].type = block.type; + } + if (block.label !== block.id) { + blockDatabase[block.id].label = block.label; + } + } + if (block.children) { + populateBlockDatabase(block.children, block); + } + if (block.type === "space") { + const w = block.width || 1; + for (let j = 0; j < w; j++) { + const newBlock2 = clone$2(block); + newBlock2.id = newBlock2.id + "-" + j; + blockDatabase[newBlock2.id] = newBlock2; + children.push(newBlock2); + } + } else if (newBlock) { + children.push(block); + } + } + } + parent.children = children; +}; +let blocks = []; +let rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; +const clear = () => { + log$1.debug("Clear called"); + clear$k(); + rootBlock = { id: "root", type: "composite", children: [], columns: -1 }; + blockDatabase = { root: rootBlock }; + blocks = []; + classes = {}; + edgeList = []; + edgeCount = {}; +}; +function typeStr2Type(typeStr) { + log$1.debug("typeStr2Type", typeStr); + switch (typeStr) { + case "[]": + return "square"; + case "()": + log$1.debug("we have a round"); + return "round"; + case "(())": + return "circle"; + case ">]": + return "rect_left_inv_arrow"; + case "{}": + return "diamond"; + case "{{}}": + return "hexagon"; + case "([])": + return "stadium"; + case "[[]]": + return "subroutine"; + case "[()]": + return "cylinder"; + case "((()))": + return "doublecircle"; + case "[//]": + return "lean_right"; + case "[\\\\]": + return "lean_left"; + case "[/\\]": + return "trapezoid"; + case "[\\/]": + return "inv_trapezoid"; + case "<[]>": + return "block_arrow"; + default: + return "na"; + } +} +function edgeTypeStr2Type(typeStr) { + log$1.debug("typeStr2Type", typeStr); + switch (typeStr) { + case "==": + return "thick"; + default: + return "normal"; + } +} +function edgeStrToEdgeData(typeStr) { + switch (typeStr.trim()) { + case "--x": + return "arrow_cross"; + case "--o": + return "arrow_circle"; + default: + return "arrow_point"; + } +} +let cnt = 0; +const generateId = () => { + cnt++; + return "id-" + Math.random().toString(36).substr(2, 12) + "-" + cnt; +}; +const setHierarchy = (block) => { + rootBlock.children = block; + populateBlockDatabase(block, rootBlock); + blocks = rootBlock.children; +}; +const getColumns = (blockId) => { + const block = blockDatabase[blockId]; + if (!block) { + return -1; + } + if (block.columns) { + return block.columns; + } + if (!block.children) { + return -1; + } + return block.children.length; +}; +const getBlocksFlat = () => { + return [...Object.values(blockDatabase)]; +}; +const getBlocks = () => { + return blocks || []; +}; +const getEdges = () => { + return edgeList; +}; +const getBlock = (id) => { + return blockDatabase[id]; +}; +const setBlock = (block) => { + blockDatabase[block.id] = block; +}; +const getLogger = () => console; +const getClasses$1 = function() { + return classes; +}; +const db = { + getConfig: () => getConfig$1().block, + typeStr2Type, + edgeTypeStr2Type, + edgeStrToEdgeData, + getLogger, + getBlocksFlat, + getBlocks, + getEdges, + setHierarchy, + getBlock, + setBlock, + getColumns, + getClasses: getClasses$1, + clear, + generateId +}; +const db$1 = db; +const fade = (color, opacity) => { + const channel$1 = channel; + const r = channel$1(color, "r"); + const g = channel$1(color, "g"); + const b = channel$1(color, "b"); + return rgba$1(r, g, b, opacity); +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span,p { + color: ${options.titleColor}; + } + + + + .label text,span,p { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + .flowchart-label text { + text-anchor: middle; + } + // .flowchart-label .text-outer-tspan { + // text-anchor: middle; + // } + // .flowchart-label .text-inner-tspan { + // text-anchor: start; + // } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + /* For html labels only */ + .labelBkg { + background-color: ${fade(options.edgeLabelBackground, 0.5)}; + // background-color: + } + + .node .cluster { + // fill: ${fade(options.mainBkg, 0.5)}; + fill: ${fade(options.clusterBkg, 0.5)}; + stroke: ${fade(options.clusterBorder, 0.2)}; + box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span,p { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } +`; +const flowStyles = getStyles; +function getNodeFromBlock(block, db2, positioned = false) { + var _a2, _b2, _c; + const vertex = block; + let classStr = "default"; + if ((((_a2 = vertex == null ? void 0 : vertex.classes) == null ? void 0 : _a2.length) || 0) > 0) { + classStr = ((vertex == null ? void 0 : vertex.classes) || []).join(" "); + } + classStr = classStr + " flowchart-label"; + let radius = 0; + let shape = ""; + let padding2; + switch (vertex.type) { + case "round": + radius = 5; + shape = "rect"; + break; + case "composite": + radius = 0; + shape = "composite"; + padding2 = 0; + break; + case "square": + shape = "rect"; + break; + case "diamond": + shape = "question"; + break; + case "hexagon": + shape = "hexagon"; + break; + case "block_arrow": + shape = "block_arrow"; + break; + case "odd": + shape = "rect_left_inv_arrow"; + break; + case "lean_right": + shape = "lean_right"; + break; + case "lean_left": + shape = "lean_left"; + break; + case "trapezoid": + shape = "trapezoid"; + break; + case "inv_trapezoid": + shape = "inv_trapezoid"; + break; + case "rect_left_inv_arrow": + shape = "rect_left_inv_arrow"; + break; + case "circle": + shape = "circle"; + break; + case "ellipse": + shape = "ellipse"; + break; + case "stadium": + shape = "stadium"; + break; + case "subroutine": + shape = "subroutine"; + break; + case "cylinder": + shape = "cylinder"; + break; + case "group": + shape = "rect"; + break; + case "doublecircle": + shape = "doublecircle"; + break; + default: + shape = "rect"; + } + const styles = getStylesFromArray((vertex == null ? void 0 : vertex.styles) || []); + const vertexText = vertex.label; + const bounds = vertex.size || { width: 0, height: 0, x: 0, y: 0 }; + const node = { + labelStyle: styles.labelStyle, + shape, + labelText: vertexText, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + directions: vertex.directions, + width: bounds.width, + height: bounds.height, + x: bounds.x, + y: bounds.y, + positioned, + intersect: void 0, + type: vertex.type, + padding: padding2 ?? (((_c = (_b2 = getConfig$1()) == null ? void 0 : _b2.block) == null ? void 0 : _c.padding) || 0) + }; + return node; +} +async function calculateBlockSize(elem, block, db2) { + const node = getNodeFromBlock(block, db2, false); + if (node.type === "group") { + return; + } + const nodeEl = await insertNode(elem, node); + const boundingBox = nodeEl.node().getBBox(); + const obj = db2.getBlock(node.id); + obj.size = { width: boundingBox.width, height: boundingBox.height, x: 0, y: 0, node: nodeEl }; + db2.setBlock(obj); + nodeEl.remove(); +} +async function insertBlockPositioned(elem, block, db2) { + const node = getNodeFromBlock(block, db2, true); + const obj = db2.getBlock(node.id); + if (obj.type !== "space") { + await insertNode(elem, node); + block.intersect = node == null ? void 0 : node.intersect; + positionNode$1(node); + } +} +async function performOperations(elem, blocks2, db2, operation) { + for (const block of blocks2) { + await operation(elem, block, db2); + if (block.children) { + await performOperations(elem, block.children, db2, operation); + } + } +} +async function calculateBlockSizes(elem, blocks2, db2) { + await performOperations(elem, blocks2, db2, calculateBlockSize); +} +async function insertBlocks(elem, blocks2, db2) { + await performOperations(elem, blocks2, db2, insertBlockPositioned); +} +async function insertEdges(elem, edges, blocks2, db2, id) { + const g = new Graph({ + multigraph: true, + compound: true + }); + g.setGraph({ + rankdir: "TB", + nodesep: 10, + ranksep: 10, + marginx: 8, + marginy: 8 + }); + for (const block of blocks2) { + if (block.size) { + g.setNode(block.id, { + width: block.size.width, + height: block.size.height, + intersect: block.intersect + }); + } + } + for (const edge of edges) { + if (edge.start && edge.end) { + const startBlock = db2.getBlock(edge.start); + const endBlock = db2.getBlock(edge.end); + if ((startBlock == null ? void 0 : startBlock.size) && (endBlock == null ? void 0 : endBlock.size)) { + const start = startBlock.size; + const end = endBlock.size; + const points = [ + { x: start.x, y: start.y }, + { x: start.x + (end.x - start.x) / 2, y: start.y + (end.y - start.y) / 2 }, + { x: end.x, y: end.y } + ]; + await insertEdge$1( + elem, + { v: edge.start, w: edge.end, name: edge.id }, + { + ...edge, + arrowTypeEnd: edge.arrowTypeEnd, + arrowTypeStart: edge.arrowTypeStart, + points, + classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" + }, + void 0, + "block", + g, + id + ); + if (edge.label) { + await insertEdgeLabel(elem, { + ...edge, + label: edge.label, + labelStyle: "stroke: #333; stroke-width: 1.5px;fill:none;", + arrowTypeEnd: edge.arrowTypeEnd, + arrowTypeStart: edge.arrowTypeStart, + points, + classes: "edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1" + }); + await positionEdgeLabel( + { ...edge, x: points[1].x, y: points[1].y }, + { + originalPath: points + } + ); + } + } + } + } +} +const padding = ((_b = (_a = getConfig$2()) == null ? void 0 : _a.block) == null ? void 0 : _b.padding) || 8; +function calculateBlockPosition(columns, position) { + if (columns === 0 || !Number.isInteger(columns)) { + throw new Error("Columns must be an integer !== 0."); + } + if (position < 0 || !Number.isInteger(position)) { + throw new Error("Position must be a non-negative integer." + position); + } + if (columns < 0) { + return { px: position, py: 0 }; + } + if (columns === 1) { + return { px: 0, py: position }; + } + const px = position % columns; + const py = Math.floor(position / columns); + return { px, py }; +} +const getMaxChildSize = (block) => { + let maxWidth = 0; + let maxHeight = 0; + for (const child of block.children) { + const { width, height, x, y } = child.size || { width: 0, height: 0, x: 0, y: 0 }; + log$1.debug( + "getMaxChildSize abc95 child:", + child.id, + "width:", + width, + "height:", + height, + "x:", + x, + "y:", + y, + child.type + ); + if (child.type === "space") { + continue; + } + if (width > maxWidth) { + maxWidth = width / (block.widthInColumns || 1); + } + if (height > maxHeight) { + maxHeight = height; + } + } + return { width: maxWidth, height: maxHeight }; +}; +function setBlockSizes(block, db2, siblingWidth = 0, siblingHeight = 0) { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k; + log$1.debug( + "setBlockSizes abc95 (start)", + block.id, + (_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x, + "block width =", + block == null ? void 0 : block.size, + "sieblingWidth", + siblingWidth + ); + if (!((_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.width)) { + block.size = { + width: siblingWidth, + height: siblingHeight, + x: 0, + y: 0 + }; + } + let maxWidth = 0; + let maxHeight = 0; + if (((_c = block.children) == null ? void 0 : _c.length) > 0) { + for (const child of block.children) { + setBlockSizes(child, db2); + } + const childSize = getMaxChildSize(block); + maxWidth = childSize.width; + maxHeight = childSize.height; + log$1.debug("setBlockSizes abc95 maxWidth of", block.id, ":s children is ", maxWidth, maxHeight); + for (const child of block.children) { + if (child.size) { + log$1.debug( + `abc95 Setting size of children of ${block.id} id=${child.id} ${maxWidth} ${maxHeight} ${child.size}` + ); + child.size.width = maxWidth * (child.widthInColumns || 1) + padding * ((child.widthInColumns || 1) - 1); + child.size.height = maxHeight; + child.size.x = 0; + child.size.y = 0; + log$1.debug( + `abc95 updating size of ${block.id} children child:${child.id} maxWidth:${maxWidth} maxHeight:${maxHeight}` + ); + } + } + for (const child of block.children) { + setBlockSizes(child, db2, maxWidth, maxHeight); + } + const columns = block.columns || -1; + let numItems = 0; + for (const child of block.children) { + numItems += child.widthInColumns || 1; + } + let xSize = block.children.length; + if (columns > 0 && columns < numItems) { + xSize = columns; + } + block.widthInColumns || 1; + const ySize = Math.ceil(numItems / xSize); + let width = xSize * (maxWidth + padding) + padding; + let height = ySize * (maxHeight + padding) + padding; + if (width < siblingWidth) { + log$1.debug( + `Detected to small siebling: abc95 ${block.id} sieblingWidth ${siblingWidth} sieblingHeight ${siblingHeight} width ${width}` + ); + width = siblingWidth; + height = siblingHeight; + const childWidth = (siblingWidth - xSize * padding - padding) / xSize; + const childHeight = (siblingHeight - ySize * padding - padding) / ySize; + log$1.debug("Size indata abc88", block.id, "childWidth", childWidth, "maxWidth", maxWidth); + log$1.debug("Size indata abc88", block.id, "childHeight", childHeight, "maxHeight", maxHeight); + log$1.debug("Size indata abc88 xSize", xSize, "padding", padding); + for (const child of block.children) { + if (child.size) { + child.size.width = childWidth; + child.size.height = childHeight; + child.size.x = 0; + child.size.y = 0; + } + } + } + log$1.debug( + `abc95 (finale calc) ${block.id} xSize ${xSize} ySize ${ySize} columns ${columns}${block.children.length} width=${Math.max(width, ((_d = block.size) == null ? void 0 : _d.width) || 0)}` + ); + if (width < (((_e = block == null ? void 0 : block.size) == null ? void 0 : _e.width) || 0)) { + width = ((_f = block == null ? void 0 : block.size) == null ? void 0 : _f.width) || 0; + const num = columns > 0 ? Math.min(block.children.length, columns) : block.children.length; + if (num > 0) { + const childWidth = (width - num * padding - padding) / num; + log$1.debug("abc95 (growing to fit) width", block.id, width, (_g = block.size) == null ? void 0 : _g.width, childWidth); + for (const child of block.children) { + if (child.size) { + child.size.width = childWidth; + } + } + } + } + block.size = { + width, + height, + x: 0, + y: 0 + }; + } + log$1.debug( + "setBlockSizes abc94 (done)", + block.id, + (_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x, + (_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width, + (_j = block == null ? void 0 : block.size) == null ? void 0 : _j.y, + (_k = block == null ? void 0 : block.size) == null ? void 0 : _k.height + ); +} +function layoutBlocks(block, db2) { + var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q; + log$1.debug( + `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${(_a2 = block == null ? void 0 : block.size) == null ? void 0 : _a2.x} y: ${(_b2 = block == null ? void 0 : block.size) == null ? void 0 : _b2.y} width: ${(_c = block == null ? void 0 : block.size) == null ? void 0 : _c.width}` + ); + const columns = block.columns || -1; + log$1.debug("layoutBlocks columns abc95", block.id, "=>", columns, block); + if (block.children && // find max width of children + block.children.length > 0) { + const width = ((_e = (_d = block == null ? void 0 : block.children[0]) == null ? void 0 : _d.size) == null ? void 0 : _e.width) || 0; + const widthOfChildren = block.children.length * width + (block.children.length - 1) * padding; + log$1.debug("widthOfChildren 88", widthOfChildren, "posX"); + let columnPos = 0; + log$1.debug("abc91 block?.size?.x", block.id, (_f = block == null ? void 0 : block.size) == null ? void 0 : _f.x); + let startingPosX = ((_g = block == null ? void 0 : block.size) == null ? void 0 : _g.x) ? ((_h = block == null ? void 0 : block.size) == null ? void 0 : _h.x) + (-((_i = block == null ? void 0 : block.size) == null ? void 0 : _i.width) / 2 || 0) : -padding; + let rowPos = 0; + for (const child of block.children) { + const parent = block; + if (!child.size) { + continue; + } + const { width: width2, height } = child.size; + const { px, py } = calculateBlockPosition(columns, columnPos); + if (py != rowPos) { + rowPos = py; + startingPosX = ((_j = block == null ? void 0 : block.size) == null ? void 0 : _j.x) ? ((_k = block == null ? void 0 : block.size) == null ? void 0 : _k.x) + (-((_l = block == null ? void 0 : block.size) == null ? void 0 : _l.width) / 2 || 0) : -padding; + log$1.debug("New row in layout for block", block.id, " and child ", child.id, rowPos); + } + log$1.debug( + `abc89 layout blocks (child) id: ${child.id} Pos: ${columnPos} (px, py) ${px},${py} (${(_m = parent == null ? void 0 : parent.size) == null ? void 0 : _m.x},${(_n = parent == null ? void 0 : parent.size) == null ? void 0 : _n.y}) parent: ${parent.id} width: ${width2}${padding}` + ); + if (parent.size) { + const halfWidth = width2 / 2; + child.size.x = startingPosX + padding + halfWidth; + log$1.debug( + `abc91 layout blocks (calc) px, pyid:${child.id} startingPos=X${startingPosX} new startingPosX${child.size.x} ${halfWidth} padding=${padding} width=${width2} halfWidth=${halfWidth} => x:${child.size.x} y:${child.size.y} ${child.widthInColumns} (width * (child?.w || 1)) / 2 ${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}` + ); + startingPosX = child.size.x + halfWidth; + child.size.y = parent.size.y - parent.size.height / 2 + py * (height + padding) + height / 2 + padding; + log$1.debug( + `abc88 layout blocks (calc) px, pyid:${child.id}startingPosX${startingPosX}${padding}${halfWidth}=>x:${child.size.x}y:${child.size.y}${child.widthInColumns}(width * (child?.w || 1)) / 2${width2 * ((child == null ? void 0 : child.widthInColumns) || 1) / 2}` + ); + } + if (child.children) { + layoutBlocks(child); + } + columnPos += (child == null ? void 0 : child.widthInColumns) || 1; + log$1.debug("abc88 columnsPos", child, columnPos); + } + } + log$1.debug( + `layout blocks (<==layoutBlocks) ${block.id} x: ${(_o = block == null ? void 0 : block.size) == null ? void 0 : _o.x} y: ${(_p = block == null ? void 0 : block.size) == null ? void 0 : _p.y} width: ${(_q = block == null ? void 0 : block.size) == null ? void 0 : _q.width}` + ); +} +function findBounds(block, { minX, minY, maxX, maxY } = { minX: 0, minY: 0, maxX: 0, maxY: 0 }) { + if (block.size && block.id !== "root") { + const { x, y, width, height } = block.size; + if (x - width / 2 < minX) { + minX = x - width / 2; + } + if (y - height / 2 < minY) { + minY = y - height / 2; + } + if (x + width / 2 > maxX) { + maxX = x + width / 2; + } + if (y + height / 2 > maxY) { + maxY = y + height / 2; + } + } + if (block.children) { + for (const child of block.children) { + ({ minX, minY, maxX, maxY } = findBounds(child, { minX, minY, maxX, maxY })); + } + } + return { minX, minY, maxX, maxY }; +} +function layout(db2) { + const root = db2.getBlock("root"); + if (!root) { + return; + } + setBlockSizes(root, db2, 0, 0); + layoutBlocks(root); + log$1.debug("getBlocks", JSON.stringify(root, null, 2)); + const { minX, minY, maxX, maxY } = findBounds(root); + const height = maxY - minY; + const width = maxX - minX; + return { x: minX, y: minY, width, height }; +} +const getClasses = function(text, diagObj) { + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + const { securityLevel, block: conf } = getConfig$1(); + const db2 = diagObj.db; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const markers = ["point", "circle", "cross"]; + insertMarkers$1$1(svg, markers, diagObj.type, id); + const bl = db2.getBlocks(); + const blArr = db2.getBlocksFlat(); + const edges = db2.getEdges(); + const nodes = svg.insert("g").attr("class", "block"); + await calculateBlockSizes(nodes, bl, db2); + const bounds = layout(db2); + await insertBlocks(nodes, bl, db2); + await insertEdges(nodes, edges, blArr, db2, id); + if (bounds) { + const bounds2 = bounds; + const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height))); + const height = bounds2.height + magicFactor + 10; + const width = bounds2.width + 10; + const { useMaxWidth } = conf; + configureSvgSize(svg, height, width, !!useMaxWidth); + log$1.debug("Here Bounds", bounds, bounds2); + svg.attr( + "viewBox", + `${bounds2.x - 5} ${bounds2.y - 5} ${bounds2.width + 10} ${bounds2.height + 10}` + ); + } + ordinal(schemeTableau10); +}; +const renderer = { + draw, + getClasses +}; +const diagram = { + parser: parser$1, + db: db$1, + renderer, + styles: flowStyles +}; + +var blockDiagram9f4a6865 = /*#__PURE__*/Object.freeze({ + __proto__: null, + diagram: diagram +}); + +export { md2Html, parseMermaidHtml }; diff --git a/libs/marked/infoDiagram-94cd232f-BX5-hJJ1.js b/libs/marked/infoDiagram-94cd232f-BX5-hJJ1.js new file mode 100644 index 0000000..e87bfa0 --- /dev/null +++ b/libs/marked/infoDiagram-94cd232f-BX5-hJJ1.js @@ -0,0 +1,510 @@ +import { l as log$1, U as selectSvgElement, i as configureSvgSize } from './index-CN3YjQ0n.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 9, 10]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "info": 4, "document": 5, "EOF": 6, "line": 7, "statement": 8, "NL": 9, "showInfo": 10, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "info", 6: "EOF", 9: "NL", 10: "showInfo" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 1], [7, 1], [8, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + $$.length - 1; + switch (yystate) { + case 1: + return yy; + case 4: + break; + case 6: + yy.setInfo(true); + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: 6, 9: [1, 7], 10: [1, 8] }, { 1: [2, 1] }, o($V0, [2, 3]), o($V0, [2, 4]), o($V0, [2, 5]), o($V0, [2, 6])], + defaultActions: { 4: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 4; + case 1: + return 9; + case 2: + return "space"; + case 3: + return 10; + case 4: + return 6; + case 5: + return "TXT"; + } + }, + rules: [/^(?:info\b)/i, /^(?:[\s\n\r]+)/i, /^(?:[\s]+)/i, /^(?:showInfo\b)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const DEFAULT_INFO_DB = { + info: false +}; +let info = DEFAULT_INFO_DB.info; +const setInfo = (toggle) => { + info = toggle; +}; +const getInfo = () => info; +const clear = () => { + info = DEFAULT_INFO_DB.info; +}; +const db = { + clear, + setInfo, + getInfo +}; +const draw = (text, id, version) => { + log$1.debug("rendering info diagram\n" + text); + const svg = selectSvgElement(id); + configureSvgSize(svg, 100, 400, true); + const group = svg.append("g"); + group.append("text").attr("x", 100).attr("y", 40).attr("class", "version").attr("font-size", 32).style("text-anchor", "middle").text(`v${version}`); +}; +const renderer = { draw }; +const diagram = { + parser: parser$1, + db, + renderer +}; + +export { diagram }; diff --git a/libs/marked/infoDiagram-94cd232f-UXAz4oPL.js b/libs/marked/infoDiagram-94cd232f-UXAz4oPL.js new file mode 100644 index 0000000..faba9e2 --- /dev/null +++ b/libs/marked/infoDiagram-94cd232f-UXAz4oPL.js @@ -0,0 +1,510 @@ +import { l as log$1, U as selectSvgElement, i as configureSvgSize } from './index-Bd_FDXSq.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 9, 10]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "info": 4, "document": 5, "EOF": 6, "line": 7, "statement": 8, "NL": 9, "showInfo": 10, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "info", 6: "EOF", 9: "NL", 10: "showInfo" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 1], [7, 1], [8, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + $$.length - 1; + switch (yystate) { + case 1: + return yy; + case 4: + break; + case 6: + yy.setInfo(true); + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: 6, 9: [1, 7], 10: [1, 8] }, { 1: [2, 1] }, o($V0, [2, 3]), o($V0, [2, 4]), o($V0, [2, 5]), o($V0, [2, 6])], + defaultActions: { 4: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 4; + case 1: + return 9; + case 2: + return "space"; + case 3: + return 10; + case 4: + return 6; + case 5: + return "TXT"; + } + }, + rules: [/^(?:info\b)/i, /^(?:[\s\n\r]+)/i, /^(?:[\s]+)/i, /^(?:showInfo\b)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const DEFAULT_INFO_DB = { + info: false +}; +let info = DEFAULT_INFO_DB.info; +const setInfo = (toggle) => { + info = toggle; +}; +const getInfo = () => info; +const clear = () => { + info = DEFAULT_INFO_DB.info; +}; +const db = { + clear, + setInfo, + getInfo +}; +const draw = (text, id, version) => { + log$1.debug("rendering info diagram\n" + text); + const svg = selectSvgElement(id); + configureSvgSize(svg, 100, 400, true); + const group = svg.append("g"); + group.append("text").attr("x", 100).attr("y", 40).attr("class", "version").attr("font-size", 32).style("text-anchor", "middle").text(`v${version}`); +}; +const renderer = { draw }; +const diagram = { + parser: parser$1, + db, + renderer +}; + +export { diagram }; diff --git a/libs/marked/init-zpY4DTin.js b/libs/marked/init-zpY4DTin.js new file mode 100644 index 0000000..008fc26 --- /dev/null +++ b/libs/marked/init-zpY4DTin.js @@ -0,0 +1,10 @@ +function initRange(domain, range) { + switch (arguments.length) { + case 0: break; + case 1: this.range(domain); break; + default: this.range(range).domain(domain); break; + } + return this; +} + +export { initRange as i }; diff --git a/libs/marked/journeyDiagram-6625b456-DVx0F7XZ.js b/libs/marked/journeyDiagram-6625b456-DVx0F7XZ.js new file mode 100644 index 0000000..50057e9 --- /dev/null +++ b/libs/marked/journeyDiagram-6625b456-DVx0F7XZ.js @@ -0,0 +1,1183 @@ +import { c as getConfig, C as setDiagramTitle, D as getDiagramTitle, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, E as clear$1, h as select, i as configureSvgSize } from './index-CN3YjQ0n.js'; +import { d as drawRect$1, f as drawText$1, a as drawBackgroundRect$1, g as getNoteRect } from './svgDrawCommon-5e1cfd1d-BKN147IX.js'; +import { a as arc } from './arc-CNdYl1O_.js'; +import './path-BZ3S9nBE.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 11, 12, 14, 16, 17, 18], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12], $V5 = [1, 13], $V6 = [1, 14]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "journey": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "title": 11, "acc_title": 12, "acc_title_value": 13, "acc_descr": 14, "acc_descr_value": 15, "acc_descr_multiline_value": 16, "section": 17, "taskName": 18, "taskData": 19, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "journey", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 18: "taskName", 19: "taskData" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 9: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 10: + case 11: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 12: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 13: + yy.addTask($$[$0 - 1], $$[$0]); + this.$ = "task"; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 15, 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), { 13: [1, 16] }, { 15: [1, 17] }, o($V0, [2, 11]), o($V0, [2, 12]), { 19: [1, 18] }, o($V0, [2, 4]), o($V0, [2, 9]), o($V0, [2, 10]), o($V0, [2, 13])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 10; + case 3: + break; + case 4: + break; + case 5: + return 4; + case 6: + return 11; + case 7: + this.begin("acc_title"); + return 12; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 14; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 17; + case 15: + return 18; + case 16: + return 19; + case 17: + return ":"; + case 18: + return 6; + case 19: + return "INVALID"; + } + }, + rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:journey\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let currentSection = ""; +const sections = []; +const tasks = []; +const rawTasks = []; +const clear = function() { + sections.length = 0; + tasks.length = 0; + currentSection = ""; + rawTasks.length = 0; + clear$1(); +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 100; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks.push(...rawTasks); + return tasks; +}; +const updateActors = function() { + const tempActors = []; + tasks.forEach((task) => { + if (task.people) { + tempActors.push(...task.people); + } + }); + const unique = new Set(tempActors); + return [...unique].sort(); +}; +const addTask = function(descr, taskData) { + const pieces = taskData.substr(1).split(":"); + let score = 0; + let peeps = []; + if (pieces.length === 1) { + score = Number(pieces[0]); + peeps = []; + } else { + score = Number(pieces[0]); + peeps = pieces[1].split(","); + } + const peopleList = peeps.map((s) => s.trim()); + const rawTask = { + section: currentSection, + type: currentSection, + people: peopleList, + task: descr, + score + }; + rawTasks.push(rawTask); +}; +const addTaskOrg = function(descr) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const getActors = function() { + return updateActors(); +}; +const db = { + getConfig: () => getConfig().journey, + clear, + setDiagramTitle, + getDiagramTitle, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addSection, + getSections, + getTasks, + addTask, + addTaskOrg, + getActors +}; +const getStyles = (options) => `.label { + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + color: ${options.textColor}; + } + .mouth { + stroke: #666; + } + + line { + stroke: ${options.textColor} + } + + .legend { + fill: ${options.textColor}; + } + + .label text { + fill: #333; + } + .label { + color: ${options.textColor} + } + + .face { + ${options.faceColor ? `fill: ${options.faceColor}` : "fill: #FFF8DC"}; + stroke: #999; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 1.5px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + } + text-align: center; + } + + .cluster rect { + } + + .cluster text { + fill: ${options.titleColor}; + } + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .task-type-0, .section-type-0 { + ${options.fillType0 ? `fill: ${options.fillType0}` : ""}; + } + .task-type-1, .section-type-1 { + ${options.fillType0 ? `fill: ${options.fillType1}` : ""}; + } + .task-type-2, .section-type-2 { + ${options.fillType0 ? `fill: ${options.fillType2}` : ""}; + } + .task-type-3, .section-type-3 { + ${options.fillType0 ? `fill: ${options.fillType3}` : ""}; + } + .task-type-4, .section-type-4 { + ${options.fillType0 ? `fill: ${options.fillType4}` : ""}; + } + .task-type-5, .section-type-5 { + ${options.fillType0 ? `fill: ${options.fillType5}` : ""}; + } + .task-type-6, .section-type-6 { + ${options.fillType0 ? `fill: ${options.fillType6}` : ""}; + } + .task-type-7, .section-type-7 { + ${options.fillType0 ? `fill: ${options.fillType7}` : ""}; + } + + .actor-0 { + ${options.actor0 ? `fill: ${options.actor0}` : ""}; + } + .actor-1 { + ${options.actor1 ? `fill: ${options.actor1}` : ""}; + } + .actor-2 { + ${options.actor2 ? `fill: ${options.actor2}` : ""}; + } + .actor-3 { + ${options.actor3 ? `fill: ${options.actor3}` : ""}; + } + .actor-4 { + ${options.actor4 ? `fill: ${options.actor4}` : ""}; + } + .actor-5 { + ${options.actor5 ? `fill: ${options.actor5}` : ""}; + } +`; +const styles = getStyles; +const drawRect = function(elem, rectData) { + return drawRect$1(elem, rectData); +}; +const drawFace = function(element, faceData) { + const radius = 15; + const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible"); + const face = element.append("g"); + face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + function smile(face2) { + const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")"); + } + function sad(face2) { + const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")"); + } + function ambivalent(face2) { + face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666"); + } + if (faceData.score > 3) { + smile(face); + } else if (faceData.score < 3) { + sad(face); + } else { + ambivalent(face); + } + return circleElement; +}; +const drawCircle = function(element, circleData) { + const circleElement = element.append("circle"); + circleElement.attr("cx", circleData.cx); + circleElement.attr("cy", circleData.cy); + circleElement.attr("class", "actor-" + circleData.pos); + circleElement.attr("fill", circleData.fill); + circleElement.attr("stroke", circleData.stroke); + circleElement.attr("r", circleData.r); + if (circleElement.class !== void 0) { + circleElement.attr("class", circleElement.class); + } + if (circleData.title !== void 0) { + circleElement.append("title").text(circleData.title); + } + return circleElement; +}; +const drawText = function(elem, textData) { + return drawText$1(elem, textData); +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.labelMargin; + txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin; + drawText(elem, txtObject); +}; +const drawSection = function(elem, section, conf2) { + const g = elem.append("g"); + const rect = getNoteRect(); + rect.x = section.x; + rect.y = section.y; + rect.fill = section.fill; + rect.width = conf2.width * section.taskCount + // width of the tasks + conf2.diagramMarginX * (section.taskCount - 1); + rect.height = conf2.height; + rect.class = "journey-section section-type-" + section.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + _drawTextCandidateFunc(conf2)( + section.text, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "journey-section section-type-" + section.num }, + conf2, + section.colour + ); +}; +let taskCount = -1; +const drawTask = function(elem, task, conf2) { + const center = task.x + conf2.width / 2; + const g = elem.append("g"); + taskCount++; + const maxHeight = 300 + 5 * 30; + g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"); + drawFace(g, { + cx: center, + cy: 300 + (5 - task.score) * 30, + score: task.score + }); + const rect = getNoteRect(); + rect.x = task.x; + rect.y = task.y; + rect.fill = task.fill; + rect.width = conf2.width; + rect.height = conf2.height; + rect.class = "task task-type-" + task.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + let xPos = task.x + 14; + task.people.forEach((person) => { + const colour = task.actors[person].color; + const circle = { + cx: xPos, + cy: task.y, + r: 7, + fill: colour, + stroke: "#000", + title: person, + pos: task.actors[person].position + }; + drawCircle(g, circle); + xPos += 10; + }); + _drawTextCandidateFunc(conf2)( + task.task, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "task" }, + conf2, + task.colour + ); +}; +const drawBackgroundRect = function(elem, bounds2) { + drawBackgroundRect$1(elem, bounds2); +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs, colour) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2, colour) { + const { taskFontSize, taskFontFamily } = conf2; + const lines = content.split(//gi); + for (let i = 0; i < lines.length; i++) { + const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const body = g.append("switch"); + const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed"); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, body, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (key in fromTextAttrsDict) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const initGraphics = function(graphics) { + graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z"); +}; +const svgDraw = { + drawRect, + drawCircle, + drawSection, + drawText, + drawLabel, + drawTask, + drawBackgroundRect, + initGraphics +}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + keys.forEach(function(key) { + conf[key] = cnf[key]; + }); +}; +const actors = {}; +function drawActorLegend(diagram2) { + const conf2 = getConfig().journey; + let yPos = 60; + Object.keys(actors).forEach((person) => { + const colour = actors[person].color; + const circleData = { + cx: 20, + cy: yPos, + r: 7, + fill: colour, + stroke: "#000", + pos: actors[person].position + }; + svgDraw.drawCircle(diagram2, circleData); + const labelData = { + x: 40, + y: yPos + 7, + fill: "#666", + text: person, + textMargin: conf2.boxTextMargin | 5 + }; + svgDraw.drawText(diagram2, labelData); + yPos += 20; + }); +} +const conf = getConfig().journey; +const LEFT_MARGIN = conf.leftMargin; +const draw = function(text, id, version, diagObj) { + const conf2 = getConfig().journey; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + bounds.init(); + const diagram2 = root.select("#" + id); + svgDraw.initGraphics(diagram2); + const tasks2 = diagObj.db.getTasks(); + const title = diagObj.db.getDiagramTitle(); + const actorNames = diagObj.db.getActors(); + for (const member in actors) { + delete actors[member]; + } + let actorPos = 0; + actorNames.forEach((actorName) => { + actors[actorName] = { + color: conf2.actorColours[actorPos % conf2.actorColours.length], + position: actorPos + }; + actorPos++; + }); + drawActorLegend(diagram2); + bounds.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50); + drawTasks(diagram2, tasks2, 0); + const box = bounds.getBounds(); + if (title) { + diagram2.append("text").text(title).attr("x", LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 25); + } + const height = box.stopy - box.starty + 2 * conf2.diagramMarginY; + const width = LEFT_MARGIN + box.stopx + 2 * conf2.diagramMarginX; + configureSvgSize(diagram2, height, width, conf2.useMaxWidth); + diagram2.append("line").attr("x1", LEFT_MARGIN).attr("y1", conf2.height * 4).attr("x2", width - LEFT_MARGIN - 4).attr("y2", conf2.height * 4).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"); + const extraVertForTitle = title ? 70 : 0; + diagram2.attr("viewBox", `${box.startx} -25 ${width} ${height + extraVertForTitle}`); + diagram2.attr("preserveAspectRatio", "xMinYMin meet"); + diagram2.attr("height", height + extraVertForTitle + 25); +}; +const bounds = { + data: { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }, + verticalPos: 0, + sequenceItems: [], + init: function() { + this.sequenceItems = []; + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }; + this.verticalPos = 0; + }, + updateVal: function(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + }, + updateBounds: function(startx, starty, stopx, stopy) { + const conf2 = getConfig().journey; + const _self = this; + let cnt = 0; + function updateFn(type) { + return function updateItemBounds(item) { + cnt++; + const n = _self.sequenceItems.length - cnt + 1; + _self.updateVal(item, "starty", starty - n * conf2.boxMargin, Math.min); + _self.updateVal(item, "stopy", stopy + n * conf2.boxMargin, Math.max); + _self.updateVal(bounds.data, "startx", startx - n * conf2.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopx", stopx + n * conf2.boxMargin, Math.max); + { + _self.updateVal(item, "startx", startx - n * conf2.boxMargin, Math.min); + _self.updateVal(item, "stopx", stopx + n * conf2.boxMargin, Math.max); + _self.updateVal(bounds.data, "starty", starty - n * conf2.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopy", stopy + n * conf2.boxMargin, Math.max); + } + }; + } + this.sequenceItems.forEach(updateFn()); + }, + insert: function(startx, starty, stopx, stopy) { + const _startx = Math.min(startx, stopx); + const _stopx = Math.max(startx, stopx); + const _starty = Math.min(starty, stopy); + const _stopy = Math.max(starty, stopy); + this.updateVal(bounds.data, "startx", _startx, Math.min); + this.updateVal(bounds.data, "starty", _starty, Math.min); + this.updateVal(bounds.data, "stopx", _stopx, Math.max); + this.updateVal(bounds.data, "stopy", _stopy, Math.max); + this.updateBounds(_startx, _starty, _stopx, _stopy); + }, + bumpVerticalPos: function(bump) { + this.verticalPos = this.verticalPos + bump; + this.data.stopy = this.verticalPos; + }, + getVerticalPos: function() { + return this.verticalPos; + }, + getBounds: function() { + return this.data; + } +}; +const fills = conf.sectionFills; +const textColours = conf.sectionColours; +const drawTasks = function(diagram2, tasks2, verticalPos) { + const conf2 = getConfig().journey; + let lastSection = ""; + const sectionVHeight = conf2.height * 2 + conf2.diagramMarginY; + const taskPos = verticalPos + sectionVHeight; + let sectionNumber = 0; + let fill = "#CCC"; + let colour = "black"; + let num = 0; + for (const [i, task] of tasks2.entries()) { + if (lastSection !== task.section) { + fill = fills[sectionNumber % fills.length]; + num = sectionNumber % fills.length; + colour = textColours[sectionNumber % textColours.length]; + let taskInSectionCount = 0; + const currentSection2 = task.section; + for (let taskIndex = i; taskIndex < tasks2.length; taskIndex++) { + if (tasks2[taskIndex].section == currentSection2) { + taskInSectionCount = taskInSectionCount + 1; + } else { + break; + } + } + const section = { + x: i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN, + y: 50, + text: task.section, + fill, + num, + colour, + taskCount: taskInSectionCount + }; + svgDraw.drawSection(diagram2, section, conf2); + lastSection = task.section; + sectionNumber++; + } + const taskActors = task.people.reduce((acc, actorName) => { + if (actors[actorName]) { + acc[actorName] = actors[actorName]; + } + return acc; + }, {}); + task.x = i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN; + task.y = taskPos; + task.width = conf2.diagramMarginX; + task.height = conf2.diagramMarginY; + task.colour = colour; + task.fill = fill; + task.num = num; + task.actors = taskActors; + svgDraw.drawTask(diagram2, task, conf2); + bounds.insert(task.x, task.y, task.x + task.width + conf2.taskMargin, 300 + 5 * 30); + } +}; +const renderer = { + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + renderer.setConf(cnf.journey); + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/journeyDiagram-6625b456-DuhFx8Fo.js b/libs/marked/journeyDiagram-6625b456-DuhFx8Fo.js new file mode 100644 index 0000000..5b861eb --- /dev/null +++ b/libs/marked/journeyDiagram-6625b456-DuhFx8Fo.js @@ -0,0 +1,1183 @@ +import { c as getConfig, C as setDiagramTitle, D as getDiagramTitle, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, E as clear$1, h as select, i as configureSvgSize } from './index-Bd_FDXSq.js'; +import { d as drawRect$1, f as drawText$1, a as drawBackgroundRect$1, g as getNoteRect } from './svgDrawCommon-5e1cfd1d-CHZPGcFQ.js'; +import { a as arc } from './arc-DhQC9rXN.js'; +import './path-BZ3S9nBE.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 11, 12, 14, 16, 17, 18], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12], $V5 = [1, 13], $V6 = [1, 14]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "journey": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "title": 11, "acc_title": 12, "acc_title_value": 13, "acc_descr": 14, "acc_descr_value": 15, "acc_descr_multiline_value": 16, "section": 17, "taskName": 18, "taskData": 19, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "journey", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 18: "taskName", 19: "taskData" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 9: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 10: + case 11: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 12: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 13: + yy.addTask($$[$0 - 1], $$[$0]); + this.$ = "task"; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: $V6 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 15, 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: $V6 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), { 13: [1, 16] }, { 15: [1, 17] }, o($V0, [2, 11]), o($V0, [2, 12]), { 19: [1, 18] }, o($V0, [2, 4]), o($V0, [2, 9]), o($V0, [2, 10]), o($V0, [2, 13])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 10; + case 3: + break; + case 4: + break; + case 5: + return 4; + case 6: + return 11; + case 7: + this.begin("acc_title"); + return 12; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 14; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 17; + case 15: + return 18; + case 16: + return 19; + case 17: + return ":"; + case 18: + return 6; + case 19: + return "INVALID"; + } + }, + rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:journey\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let currentSection = ""; +const sections = []; +const tasks = []; +const rawTasks = []; +const clear = function() { + sections.length = 0; + tasks.length = 0; + currentSection = ""; + rawTasks.length = 0; + clear$1(); +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 100; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks.push(...rawTasks); + return tasks; +}; +const updateActors = function() { + const tempActors = []; + tasks.forEach((task) => { + if (task.people) { + tempActors.push(...task.people); + } + }); + const unique = new Set(tempActors); + return [...unique].sort(); +}; +const addTask = function(descr, taskData) { + const pieces = taskData.substr(1).split(":"); + let score = 0; + let peeps = []; + if (pieces.length === 1) { + score = Number(pieces[0]); + peeps = []; + } else { + score = Number(pieces[0]); + peeps = pieces[1].split(","); + } + const peopleList = peeps.map((s) => s.trim()); + const rawTask = { + section: currentSection, + type: currentSection, + people: peopleList, + task: descr, + score + }; + rawTasks.push(rawTask); +}; +const addTaskOrg = function(descr) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const getActors = function() { + return updateActors(); +}; +const db = { + getConfig: () => getConfig().journey, + clear, + setDiagramTitle, + getDiagramTitle, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addSection, + getSections, + getTasks, + addTask, + addTaskOrg, + getActors +}; +const getStyles = (options) => `.label { + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + color: ${options.textColor}; + } + .mouth { + stroke: #666; + } + + line { + stroke: ${options.textColor} + } + + .legend { + fill: ${options.textColor}; + } + + .label text { + fill: #333; + } + .label { + color: ${options.textColor} + } + + .face { + ${options.faceColor ? `fill: ${options.faceColor}` : "fill: #FFF8DC"}; + stroke: #999; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 1.5px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + } + text-align: center; + } + + .cluster rect { + } + + .cluster text { + fill: ${options.titleColor}; + } + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: 'trebuchet ms', verdana, arial, sans-serif; + font-family: var(--mermaid-font-family); + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .task-type-0, .section-type-0 { + ${options.fillType0 ? `fill: ${options.fillType0}` : ""}; + } + .task-type-1, .section-type-1 { + ${options.fillType0 ? `fill: ${options.fillType1}` : ""}; + } + .task-type-2, .section-type-2 { + ${options.fillType0 ? `fill: ${options.fillType2}` : ""}; + } + .task-type-3, .section-type-3 { + ${options.fillType0 ? `fill: ${options.fillType3}` : ""}; + } + .task-type-4, .section-type-4 { + ${options.fillType0 ? `fill: ${options.fillType4}` : ""}; + } + .task-type-5, .section-type-5 { + ${options.fillType0 ? `fill: ${options.fillType5}` : ""}; + } + .task-type-6, .section-type-6 { + ${options.fillType0 ? `fill: ${options.fillType6}` : ""}; + } + .task-type-7, .section-type-7 { + ${options.fillType0 ? `fill: ${options.fillType7}` : ""}; + } + + .actor-0 { + ${options.actor0 ? `fill: ${options.actor0}` : ""}; + } + .actor-1 { + ${options.actor1 ? `fill: ${options.actor1}` : ""}; + } + .actor-2 { + ${options.actor2 ? `fill: ${options.actor2}` : ""}; + } + .actor-3 { + ${options.actor3 ? `fill: ${options.actor3}` : ""}; + } + .actor-4 { + ${options.actor4 ? `fill: ${options.actor4}` : ""}; + } + .actor-5 { + ${options.actor5 ? `fill: ${options.actor5}` : ""}; + } +`; +const styles = getStyles; +const drawRect = function(elem, rectData) { + return drawRect$1(elem, rectData); +}; +const drawFace = function(element, faceData) { + const radius = 15; + const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible"); + const face = element.append("g"); + face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + function smile(face2) { + const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")"); + } + function sad(face2) { + const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")"); + } + function ambivalent(face2) { + face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666"); + } + if (faceData.score > 3) { + smile(face); + } else if (faceData.score < 3) { + sad(face); + } else { + ambivalent(face); + } + return circleElement; +}; +const drawCircle = function(element, circleData) { + const circleElement = element.append("circle"); + circleElement.attr("cx", circleData.cx); + circleElement.attr("cy", circleData.cy); + circleElement.attr("class", "actor-" + circleData.pos); + circleElement.attr("fill", circleData.fill); + circleElement.attr("stroke", circleData.stroke); + circleElement.attr("r", circleData.r); + if (circleElement.class !== void 0) { + circleElement.attr("class", circleElement.class); + } + if (circleData.title !== void 0) { + circleElement.append("title").text(circleData.title); + } + return circleElement; +}; +const drawText = function(elem, textData) { + return drawText$1(elem, textData); +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.labelMargin; + txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin; + drawText(elem, txtObject); +}; +const drawSection = function(elem, section, conf2) { + const g = elem.append("g"); + const rect = getNoteRect(); + rect.x = section.x; + rect.y = section.y; + rect.fill = section.fill; + rect.width = conf2.width * section.taskCount + // width of the tasks + conf2.diagramMarginX * (section.taskCount - 1); + rect.height = conf2.height; + rect.class = "journey-section section-type-" + section.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + _drawTextCandidateFunc(conf2)( + section.text, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "journey-section section-type-" + section.num }, + conf2, + section.colour + ); +}; +let taskCount = -1; +const drawTask = function(elem, task, conf2) { + const center = task.x + conf2.width / 2; + const g = elem.append("g"); + taskCount++; + const maxHeight = 300 + 5 * 30; + g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"); + drawFace(g, { + cx: center, + cy: 300 + (5 - task.score) * 30, + score: task.score + }); + const rect = getNoteRect(); + rect.x = task.x; + rect.y = task.y; + rect.fill = task.fill; + rect.width = conf2.width; + rect.height = conf2.height; + rect.class = "task task-type-" + task.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + let xPos = task.x + 14; + task.people.forEach((person) => { + const colour = task.actors[person].color; + const circle = { + cx: xPos, + cy: task.y, + r: 7, + fill: colour, + stroke: "#000", + title: person, + pos: task.actors[person].position + }; + drawCircle(g, circle); + xPos += 10; + }); + _drawTextCandidateFunc(conf2)( + task.task, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "task" }, + conf2, + task.colour + ); +}; +const drawBackgroundRect = function(elem, bounds2) { + drawBackgroundRect$1(elem, bounds2); +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs, colour) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2, colour) { + const { taskFontSize, taskFontFamily } = conf2; + const lines = content.split(//gi); + for (let i = 0; i < lines.length; i++) { + const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const body = g.append("switch"); + const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed"); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, body, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (key in fromTextAttrsDict) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const initGraphics = function(graphics) { + graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z"); +}; +const svgDraw = { + drawRect, + drawCircle, + drawSection, + drawText, + drawLabel, + drawTask, + drawBackgroundRect, + initGraphics +}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + keys.forEach(function(key) { + conf[key] = cnf[key]; + }); +}; +const actors = {}; +function drawActorLegend(diagram2) { + const conf2 = getConfig().journey; + let yPos = 60; + Object.keys(actors).forEach((person) => { + const colour = actors[person].color; + const circleData = { + cx: 20, + cy: yPos, + r: 7, + fill: colour, + stroke: "#000", + pos: actors[person].position + }; + svgDraw.drawCircle(diagram2, circleData); + const labelData = { + x: 40, + y: yPos + 7, + fill: "#666", + text: person, + textMargin: conf2.boxTextMargin | 5 + }; + svgDraw.drawText(diagram2, labelData); + yPos += 20; + }); +} +const conf = getConfig().journey; +const LEFT_MARGIN = conf.leftMargin; +const draw = function(text, id, version, diagObj) { + const conf2 = getConfig().journey; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + bounds.init(); + const diagram2 = root.select("#" + id); + svgDraw.initGraphics(diagram2); + const tasks2 = diagObj.db.getTasks(); + const title = diagObj.db.getDiagramTitle(); + const actorNames = diagObj.db.getActors(); + for (const member in actors) { + delete actors[member]; + } + let actorPos = 0; + actorNames.forEach((actorName) => { + actors[actorName] = { + color: conf2.actorColours[actorPos % conf2.actorColours.length], + position: actorPos + }; + actorPos++; + }); + drawActorLegend(diagram2); + bounds.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50); + drawTasks(diagram2, tasks2, 0); + const box = bounds.getBounds(); + if (title) { + diagram2.append("text").text(title).attr("x", LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 25); + } + const height = box.stopy - box.starty + 2 * conf2.diagramMarginY; + const width = LEFT_MARGIN + box.stopx + 2 * conf2.diagramMarginX; + configureSvgSize(diagram2, height, width, conf2.useMaxWidth); + diagram2.append("line").attr("x1", LEFT_MARGIN).attr("y1", conf2.height * 4).attr("x2", width - LEFT_MARGIN - 4).attr("y2", conf2.height * 4).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"); + const extraVertForTitle = title ? 70 : 0; + diagram2.attr("viewBox", `${box.startx} -25 ${width} ${height + extraVertForTitle}`); + diagram2.attr("preserveAspectRatio", "xMinYMin meet"); + diagram2.attr("height", height + extraVertForTitle + 25); +}; +const bounds = { + data: { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }, + verticalPos: 0, + sequenceItems: [], + init: function() { + this.sequenceItems = []; + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }; + this.verticalPos = 0; + }, + updateVal: function(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + }, + updateBounds: function(startx, starty, stopx, stopy) { + const conf2 = getConfig().journey; + const _self = this; + let cnt = 0; + function updateFn(type) { + return function updateItemBounds(item) { + cnt++; + const n = _self.sequenceItems.length - cnt + 1; + _self.updateVal(item, "starty", starty - n * conf2.boxMargin, Math.min); + _self.updateVal(item, "stopy", stopy + n * conf2.boxMargin, Math.max); + _self.updateVal(bounds.data, "startx", startx - n * conf2.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopx", stopx + n * conf2.boxMargin, Math.max); + { + _self.updateVal(item, "startx", startx - n * conf2.boxMargin, Math.min); + _self.updateVal(item, "stopx", stopx + n * conf2.boxMargin, Math.max); + _self.updateVal(bounds.data, "starty", starty - n * conf2.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopy", stopy + n * conf2.boxMargin, Math.max); + } + }; + } + this.sequenceItems.forEach(updateFn()); + }, + insert: function(startx, starty, stopx, stopy) { + const _startx = Math.min(startx, stopx); + const _stopx = Math.max(startx, stopx); + const _starty = Math.min(starty, stopy); + const _stopy = Math.max(starty, stopy); + this.updateVal(bounds.data, "startx", _startx, Math.min); + this.updateVal(bounds.data, "starty", _starty, Math.min); + this.updateVal(bounds.data, "stopx", _stopx, Math.max); + this.updateVal(bounds.data, "stopy", _stopy, Math.max); + this.updateBounds(_startx, _starty, _stopx, _stopy); + }, + bumpVerticalPos: function(bump) { + this.verticalPos = this.verticalPos + bump; + this.data.stopy = this.verticalPos; + }, + getVerticalPos: function() { + return this.verticalPos; + }, + getBounds: function() { + return this.data; + } +}; +const fills = conf.sectionFills; +const textColours = conf.sectionColours; +const drawTasks = function(diagram2, tasks2, verticalPos) { + const conf2 = getConfig().journey; + let lastSection = ""; + const sectionVHeight = conf2.height * 2 + conf2.diagramMarginY; + const taskPos = verticalPos + sectionVHeight; + let sectionNumber = 0; + let fill = "#CCC"; + let colour = "black"; + let num = 0; + for (const [i, task] of tasks2.entries()) { + if (lastSection !== task.section) { + fill = fills[sectionNumber % fills.length]; + num = sectionNumber % fills.length; + colour = textColours[sectionNumber % textColours.length]; + let taskInSectionCount = 0; + const currentSection2 = task.section; + for (let taskIndex = i; taskIndex < tasks2.length; taskIndex++) { + if (tasks2[taskIndex].section == currentSection2) { + taskInSectionCount = taskInSectionCount + 1; + } else { + break; + } + } + const section = { + x: i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN, + y: 50, + text: task.section, + fill, + num, + colour, + taskCount: taskInSectionCount + }; + svgDraw.drawSection(diagram2, section, conf2); + lastSection = task.section; + sectionNumber++; + } + const taskActors = task.people.reduce((acc, actorName) => { + if (actors[actorName]) { + acc[actorName] = actors[actorName]; + } + return acc; + }, {}); + task.x = i * conf2.taskMargin + i * conf2.width + LEFT_MARGIN; + task.y = taskPos; + task.width = conf2.diagramMarginX; + task.height = conf2.diagramMarginY; + task.colour = colour; + task.fill = fill; + task.num = num; + task.actors = taskActors; + svgDraw.drawTask(diagram2, task, conf2); + bounds.insert(task.x, task.y, task.x + task.width + conf2.taskMargin, 300 + 5 * 30); + } +}; +const renderer = { + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + renderer.setConf(cnf.journey); + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/layout-BOZlZI7g.js b/libs/marked/layout-BOZlZI7g.js new file mode 100644 index 0000000..cf78dda --- /dev/null +++ b/libs/marked/layout-BOZlZI7g.js @@ -0,0 +1,3926 @@ +import { a as isSymbol, b as baseFlatten, c as baseClone, d as baseIteratee, k as keys, e as baseFindIndex, g as baseEach, j as arrayMap, l as castFunction, m as baseForOwn, n as castPath, t as toKey, o as baseGet, p as hasIn, q as toString, f as forEach, G as Graph, h as has, i as isUndefined, r as filter, v as values, s as reduce } from './graph-DadsyNmk.js'; +import { a8 as isObject, a9 as setToString, aa as overRest, ab as baseRest, ac as isIterateeCall, ad as keysIn, ae as eq, af as isArrayLike, ag as isArray, ah as baseFor, ai as baseAssignValue, aj as identity, ak as isIndex, al as assignValue, am as baseUnary, an as constant, ao as merge } from './index-CN3YjQ0n.js'; + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); +} + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0, + MAX_INTEGER = 1.7976931348623157e+308; + +/** + * Converts `value` to a finite number. + * + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 + */ +function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; + } + return value === value ? value : 0; +} + +/** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ +function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + + return result === result ? (remainder ? result - remainder : result) : 0; +} + +/** + * Flattens `array` a single level deep. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] + */ +function flatten(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array) : []; +} + +/** + * A specialized version of `baseRest` which flattens the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ +function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); +} + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG = 1, + CLONE_SYMBOLS_FLAG = 4; + +/** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ +function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); +} + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep + * @example + * + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ +var defaults = baseRest(function(object, sources) { + object = Object(object); + + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } + + return object; +}); + +/** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ +function last(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; +} + +/** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ +function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = baseIteratee(predicate); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$1 = Math.max; + +/** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 + */ +function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax$1(length + index, 0); + } + return baseFindIndex(array, baseIteratee(predicate), index); +} + +/** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' + * + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' + */ +var find = createFind(findIndex); + +/** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; +} + +/** + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + * @example + * + * function square(n) { + * return n * n; + * } + * + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ +function map(collection, iteratee) { + var func = isArray(collection) ? arrayMap : baseMap; + return func(collection, baseIteratee(iteratee)); +} + +/** + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + */ +function forIn(object, iteratee) { + return object == null + ? object + : baseFor(object, castFunction(iteratee), keysIn); +} + +/** + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +function forOwn(object, iteratee) { + return object && baseForOwn(object, castFunction(iteratee)); +} + +/** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ +function baseGt(value, other) { + return value > other; +} + +/** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ +function baseLt(value, other) { + return value < other; +} + +/** + * Creates an object with the same keys as `object` and values generated + * by running each own enumerable string keyed property of `object` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapKeys + * @example + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * _.mapValues(users, function(o) { return o.age; }); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * + * // The `_.property` iteratee shorthand. + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ +function mapValues(object, iteratee) { + var result = {}; + iteratee = baseIteratee(iteratee); + + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, key, iteratee(value, key, object)); + }); + return result; +} + +/** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ +function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index], + current = iteratee(value); + + if (current != null && (computed === undefined + ? (current === current && !isSymbol(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; +} + +/** + * Computes the maximum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * _.max([]); + * // => undefined + */ +function max(array) { + return (array && array.length) + ? baseExtremum(array, identity, baseGt) + : undefined; +} + +/** + * Computes the minimum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * _.min([]); + * // => undefined + */ +function min(array) { + return (array && array.length) + ? baseExtremum(array, identity, baseLt) + : undefined; +} + +/** + * This method is like `_.min` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * the value is ranked. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {*} Returns the minimum value. + * @example + * + * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * + * _.minBy(objects, function(o) { return o.n; }); + * // => { 'n': 1 } + * + * // The `_.property` iteratee shorthand. + * _.minBy(objects, 'n'); + * // => { 'n': 1 } + */ +function minBy(array, iteratee) { + return (array && array.length) + ? baseExtremum(array, baseIteratee(iteratee), baseLt) + : undefined; +} + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +/** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ +function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; + + while (++index < length) { + var path = paths[index], + value = baseGet(object, path); + + if (predicate(value, path)) { + baseSet(result, castPath(path, object), value); + } + } + return result; +} + +/** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ +function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; +} + +/** + * Compares values to sort them in ascending order. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ +function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol(value); + + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol(other); + + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; + } + } + return 0; +} + +/** + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ +function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; +} + +/** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ +function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; + } + + var index = -1; + iteratees = arrayMap(iteratees, baseUnary(baseIteratee)); + + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); +} + +/** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ +function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); +} + +/** + * Creates an object composed of the picked `object` properties. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } + */ +var pick = flatRest(function(object, paths) { + return object == null ? {} : basePick(object, paths); +}); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil, + nativeMax = Math.max; + +/** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ +function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[++index] = start; + start += step; + } + return result; +} + +/** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ +function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step); + }; +} + +/** + * Creates an array of numbers (positive and/or negative) progressing from + * `start` up to, but not including, `end`. A step of `-1` is used if a negative + * `start` is specified without an `end` or `step`. If `end` is not specified, + * it's set to `start` with `start` then set to `0`. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the range of numbers. + * @see _.inRange, _.rangeRight + * @example + * + * _.range(4); + * // => [0, 1, 2, 3] + * + * _.range(-4); + * // => [0, -1, -2, -3] + * + * _.range(1, 5); + * // => [1, 2, 3, 4] + * + * _.range(0, 20, 5); + * // => [0, 5, 10, 15] + * + * _.range(0, -4, -1); + * // => [0, -1, -2, -3] + * + * _.range(1, 4, 0); + * // => [1, 1, 1] + * + * _.range(0); + * // => [] + */ +var range = createRange(); + +/** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection thru each iteratee. This method + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The iteratees are invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to sort by. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 30 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.sortBy(users, [function(o) { return o.user; }]); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] + * + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] + */ +var sortBy = baseRest(function(collection, iteratees) { + if (collection == null) { + return []; + } + var length = iteratees.length; + if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + iteratees = []; + } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + iteratees = [iteratees[0]]; + } + return baseOrderBy(collection, baseFlatten(iteratees), []); +}); + +/** Used to generate unique IDs. */ +var idCounter = 0; + +/** + * Generates a unique ID. If `prefix` is given, the ID is appended to it. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {string} [prefix=''] The value to prefix the ID with. + * @returns {string} Returns the unique ID. + * @example + * + * _.uniqueId('contact_'); + * // => 'contact_104' + * + * _.uniqueId(); + * // => '105' + */ +function uniqueId(prefix) { + var id = ++idCounter; + return toString(prefix) + id; +} + +/** + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. + * + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. + */ +function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; +} + +/** + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property identifiers and one of corresponding values. + * + * @static + * @memberOf _ + * @since 0.4.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject(['a', 'b'], [1, 2]); + * // => { 'a': 1, 'b': 2 } + */ +function zipObject(props, values) { + return baseZipObject(props || [], values || [], assignValue); +} + +/* + * Simple doubly linked list implementation derived from Cormen, et al., + * "Introduction to Algorithms". + */ + + +class List { + constructor() { + var sentinel = {}; + sentinel._next = sentinel._prev = sentinel; + this._sentinel = sentinel; + } + dequeue() { + var sentinel = this._sentinel; + var entry = sentinel._prev; + if (entry !== sentinel) { + unlink(entry); + return entry; + } + } + enqueue(entry) { + var sentinel = this._sentinel; + if (entry._prev && entry._next) { + unlink(entry); + } + entry._next = sentinel._next; + sentinel._next._prev = entry; + sentinel._next = entry; + entry._prev = sentinel; + } + toString() { + var strs = []; + var sentinel = this._sentinel; + var curr = sentinel._prev; + while (curr !== sentinel) { + strs.push(JSON.stringify(curr, filterOutLinks)); + curr = curr._prev; + } + return '[' + strs.join(', ') + ']'; + } +} + +function unlink(entry) { + entry._prev._next = entry._next; + entry._next._prev = entry._prev; + delete entry._next; + delete entry._prev; +} + +function filterOutLinks(k, v) { + if (k !== '_next' && k !== '_prev') { + return v; + } +} + +var DEFAULT_WEIGHT_FN = constant(1); + +function greedyFAS(g, weightFn) { + if (g.nodeCount() <= 1) { + return []; + } + var state = buildState(g, weightFn || DEFAULT_WEIGHT_FN); + var results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx); + + // Expand multi-edges + return flatten( + map(results, function (e) { + return g.outEdges(e.v, e.w); + }) + ); +} + +function doGreedyFAS(g, buckets, zeroIdx) { + var results = []; + var sources = buckets[buckets.length - 1]; + var sinks = buckets[0]; + + var entry; + while (g.nodeCount()) { + while ((entry = sinks.dequeue())) { + removeNode(g, buckets, zeroIdx, entry); + } + while ((entry = sources.dequeue())) { + removeNode(g, buckets, zeroIdx, entry); + } + if (g.nodeCount()) { + for (var i = buckets.length - 2; i > 0; --i) { + entry = buckets[i].dequeue(); + if (entry) { + results = results.concat(removeNode(g, buckets, zeroIdx, entry, true)); + break; + } + } + } + } + + return results; +} + +function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) { + var results = collectPredecessors ? [] : undefined; + + forEach(g.inEdges(entry.v), function (edge) { + var weight = g.edge(edge); + var uEntry = g.node(edge.v); + + if (collectPredecessors) { + results.push({ v: edge.v, w: edge.w }); + } + + uEntry.out -= weight; + assignBucket(buckets, zeroIdx, uEntry); + }); + + forEach(g.outEdges(entry.v), function (edge) { + var weight = g.edge(edge); + var w = edge.w; + var wEntry = g.node(w); + wEntry['in'] -= weight; + assignBucket(buckets, zeroIdx, wEntry); + }); + + g.removeNode(entry.v); + + return results; +} + +function buildState(g, weightFn) { + var fasGraph = new Graph(); + var maxIn = 0; + var maxOut = 0; + + forEach(g.nodes(), function (v) { + fasGraph.setNode(v, { v: v, in: 0, out: 0 }); + }); + + // Aggregate weights on nodes, but also sum the weights across multi-edges + // into a single edge for the fasGraph. + forEach(g.edges(), function (e) { + var prevWeight = fasGraph.edge(e.v, e.w) || 0; + var weight = weightFn(e); + var edgeWeight = prevWeight + weight; + fasGraph.setEdge(e.v, e.w, edgeWeight); + maxOut = Math.max(maxOut, (fasGraph.node(e.v).out += weight)); + maxIn = Math.max(maxIn, (fasGraph.node(e.w)['in'] += weight)); + }); + + var buckets = range(maxOut + maxIn + 3).map(function () { + return new List(); + }); + var zeroIdx = maxIn + 1; + + forEach(fasGraph.nodes(), function (v) { + assignBucket(buckets, zeroIdx, fasGraph.node(v)); + }); + + return { graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx }; +} + +function assignBucket(buckets, zeroIdx, entry) { + if (!entry.out) { + buckets[0].enqueue(entry); + } else if (!entry['in']) { + buckets[buckets.length - 1].enqueue(entry); + } else { + buckets[entry.out - entry['in'] + zeroIdx].enqueue(entry); + } +} + +function run$2(g) { + var fas = g.graph().acyclicer === 'greedy' ? greedyFAS(g, weightFn(g)) : dfsFAS(g); + forEach(fas, function (e) { + var label = g.edge(e); + g.removeEdge(e); + label.forwardName = e.name; + label.reversed = true; + g.setEdge(e.w, e.v, label, uniqueId('rev')); + }); + + function weightFn(g) { + return function (e) { + return g.edge(e).weight; + }; + } +} + +function dfsFAS(g) { + var fas = []; + var stack = {}; + var visited = {}; + + function dfs(v) { + if (has(visited, v)) { + return; + } + visited[v] = true; + stack[v] = true; + forEach(g.outEdges(v), function (e) { + if (has(stack, e.w)) { + fas.push(e); + } else { + dfs(e.w); + } + }); + delete stack[v]; + } + + forEach(g.nodes(), dfs); + return fas; +} + +function undo$2(g) { + forEach(g.edges(), function (e) { + var label = g.edge(e); + if (label.reversed) { + g.removeEdge(e); + + var forwardName = label.forwardName; + delete label.reversed; + delete label.forwardName; + g.setEdge(e.w, e.v, label, forwardName); + } + }); +} + +/* + * Adds a dummy node to the graph and return v. + */ +function addDummyNode(g, type, attrs, name) { + var v; + do { + v = uniqueId(name); + } while (g.hasNode(v)); + + attrs.dummy = type; + g.setNode(v, attrs); + return v; +} + +/* + * Returns a new graph with only simple edges. Handles aggregation of data + * associated with multi-edges. + */ +function simplify(g) { + var simplified = new Graph().setGraph(g.graph()); + forEach(g.nodes(), function (v) { + simplified.setNode(v, g.node(v)); + }); + forEach(g.edges(), function (e) { + var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 }; + var label = g.edge(e); + simplified.setEdge(e.v, e.w, { + weight: simpleLabel.weight + label.weight, + minlen: Math.max(simpleLabel.minlen, label.minlen), + }); + }); + return simplified; +} + +function asNonCompoundGraph(g) { + var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph()); + forEach(g.nodes(), function (v) { + if (!g.children(v).length) { + simplified.setNode(v, g.node(v)); + } + }); + forEach(g.edges(), function (e) { + simplified.setEdge(e, g.edge(e)); + }); + return simplified; +} + +/* + * Finds where a line starting at point ({x, y}) would intersect a rectangle + * ({x, y, width, height}) if it were pointing at the rectangle's center. + */ +function intersectRect(rect, point) { + var x = rect.x; + var y = rect.y; + + // Rectangle intersection algorithm from: + // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes + var dx = point.x - x; + var dy = point.y - y; + var w = rect.width / 2; + var h = rect.height / 2; + + if (!dx && !dy) { + throw new Error('Not possible to find intersection inside of the rectangle'); + } + + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + // Intersection is top or bottom of rect. + if (dy < 0) { + h = -h; + } + sx = (h * dx) / dy; + sy = h; + } else { + // Intersection is left or right of rect. + if (dx < 0) { + w = -w; + } + sx = w; + sy = (w * dy) / dx; + } + + return { x: x + sx, y: y + sy }; +} + +/* + * Given a DAG with each node assigned "rank" and "order" properties, this + * function will produce a matrix with the ids of each node. + */ +function buildLayerMatrix(g) { + var layering = map(range(maxRank(g) + 1), function () { + return []; + }); + forEach(g.nodes(), function (v) { + var node = g.node(v); + var rank = node.rank; + if (!isUndefined(rank)) { + layering[rank][node.order] = v; + } + }); + return layering; +} + +/* + * Adjusts the ranks for all nodes in the graph such that all nodes v have + * rank(v) >= 0 and at least one node w has rank(w) = 0. + */ +function normalizeRanks(g) { + var min$1 = min( + map(g.nodes(), function (v) { + return g.node(v).rank; + }) + ); + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (has(node, 'rank')) { + node.rank -= min$1; + } + }); +} + +function removeEmptyRanks(g) { + // Ranks may not start at 0, so we need to offset them + var offset = min( + map(g.nodes(), function (v) { + return g.node(v).rank; + }) + ); + + var layers = []; + forEach(g.nodes(), function (v) { + var rank = g.node(v).rank - offset; + if (!layers[rank]) { + layers[rank] = []; + } + layers[rank].push(v); + }); + + var delta = 0; + var nodeRankFactor = g.graph().nodeRankFactor; + forEach(layers, function (vs, i) { + if (isUndefined(vs) && i % nodeRankFactor !== 0) { + --delta; + } else if (delta) { + forEach(vs, function (v) { + g.node(v).rank += delta; + }); + } + }); +} + +function addBorderNode$1(g, prefix, rank, order) { + var node = { + width: 0, + height: 0, + }; + if (arguments.length >= 4) { + node.rank = rank; + node.order = order; + } + return addDummyNode(g, 'border', node, prefix); +} + +function maxRank(g) { + return max( + map(g.nodes(), function (v) { + var rank = g.node(v).rank; + if (!isUndefined(rank)) { + return rank; + } + }) + ); +} + +/* + * Partition a collection into two groups: `lhs` and `rhs`. If the supplied + * function returns true for an entry it goes into `lhs`. Otherwise it goes + * into `rhs. + */ +function partition(collection, fn) { + var result = { lhs: [], rhs: [] }; + forEach(collection, function (value) { + if (fn(value)) { + result.lhs.push(value); + } else { + result.rhs.push(value); + } + }); + return result; +} + +function notime(name, fn) { + return fn(); +} + +function addBorderSegments(g) { + function dfs(v) { + var children = g.children(v); + var node = g.node(v); + if (children.length) { + forEach(children, dfs); + } + + if (has(node, 'minRank')) { + node.borderLeft = []; + node.borderRight = []; + for (var rank = node.minRank, maxRank = node.maxRank + 1; rank < maxRank; ++rank) { + addBorderNode(g, 'borderLeft', '_bl', v, node, rank); + addBorderNode(g, 'borderRight', '_br', v, node, rank); + } + } + } + + forEach(g.children(), dfs); +} + +function addBorderNode(g, prop, prefix, sg, sgNode, rank) { + var label = { width: 0, height: 0, rank: rank, borderType: prop }; + var prev = sgNode[prop][rank - 1]; + var curr = addDummyNode(g, 'border', label, prefix); + sgNode[prop][rank] = curr; + g.setParent(curr, sg); + if (prev) { + g.setEdge(prev, curr, { weight: 1 }); + } +} + +function adjust(g) { + var rankDir = g.graph().rankdir.toLowerCase(); + if (rankDir === 'lr' || rankDir === 'rl') { + swapWidthHeight(g); + } +} + +function undo$1(g) { + var rankDir = g.graph().rankdir.toLowerCase(); + if (rankDir === 'bt' || rankDir === 'rl') { + reverseY(g); + } + + if (rankDir === 'lr' || rankDir === 'rl') { + swapXY(g); + swapWidthHeight(g); + } +} + +function swapWidthHeight(g) { + forEach(g.nodes(), function (v) { + swapWidthHeightOne(g.node(v)); + }); + forEach(g.edges(), function (e) { + swapWidthHeightOne(g.edge(e)); + }); +} + +function swapWidthHeightOne(attrs) { + var w = attrs.width; + attrs.width = attrs.height; + attrs.height = w; +} + +function reverseY(g) { + forEach(g.nodes(), function (v) { + reverseYOne(g.node(v)); + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, reverseYOne); + if (has(edge, 'y')) { + reverseYOne(edge); + } + }); +} + +function reverseYOne(attrs) { + attrs.y = -attrs.y; +} + +function swapXY(g) { + forEach(g.nodes(), function (v) { + swapXYOne(g.node(v)); + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, swapXYOne); + if (has(edge, 'x')) { + swapXYOne(edge); + } + }); +} + +function swapXYOne(attrs) { + var x = attrs.x; + attrs.x = attrs.y; + attrs.y = x; +} + +/* + * Breaks any long edges in the graph into short segments that span 1 layer + * each. This operation is undoable with the denormalize function. + * + * Pre-conditions: + * + * 1. The input graph is a DAG. + * 2. Each node in the graph has a "rank" property. + * + * Post-condition: + * + * 1. All edges in the graph have a length of 1. + * 2. Dummy nodes are added where edges have been split into segments. + * 3. The graph is augmented with a "dummyChains" attribute which contains + * the first dummy in each chain of dummy nodes produced. + */ +function run$1(g) { + g.graph().dummyChains = []; + forEach(g.edges(), function (edge) { + normalizeEdge(g, edge); + }); +} + +function normalizeEdge(g, e) { + var v = e.v; + var vRank = g.node(v).rank; + var w = e.w; + var wRank = g.node(w).rank; + var name = e.name; + var edgeLabel = g.edge(e); + var labelRank = edgeLabel.labelRank; + + if (wRank === vRank + 1) return; + + g.removeEdge(e); + + var dummy, attrs, i; + for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) { + edgeLabel.points = []; + attrs = { + width: 0, + height: 0, + edgeLabel: edgeLabel, + edgeObj: e, + rank: vRank, + }; + dummy = addDummyNode(g, 'edge', attrs, '_d'); + if (vRank === labelRank) { + attrs.width = edgeLabel.width; + attrs.height = edgeLabel.height; + // @ts-expect-error + attrs.dummy = 'edge-label'; + // @ts-expect-error + attrs.labelpos = edgeLabel.labelpos; + } + g.setEdge(v, dummy, { weight: edgeLabel.weight }, name); + if (i === 0) { + g.graph().dummyChains.push(dummy); + } + v = dummy; + } + + g.setEdge(v, w, { weight: edgeLabel.weight }, name); +} + +function undo(g) { + forEach(g.graph().dummyChains, function (v) { + var node = g.node(v); + var origLabel = node.edgeLabel; + var w; + g.setEdge(node.edgeObj, origLabel); + while (node.dummy) { + w = g.successors(v)[0]; + g.removeNode(v); + origLabel.points.push({ x: node.x, y: node.y }); + if (node.dummy === 'edge-label') { + origLabel.x = node.x; + origLabel.y = node.y; + origLabel.width = node.width; + origLabel.height = node.height; + } + v = w; + node = g.node(v); + } + }); +} + +/* + * Initializes ranks for the input graph using the longest path algorithm. This + * algorithm scales well and is fast in practice, it yields rather poor + * solutions. Nodes are pushed to the lowest layer possible, leaving the bottom + * ranks wide and leaving edges longer than necessary. However, due to its + * speed, this algorithm is good for getting an initial ranking that can be fed + * into other algorithms. + * + * This algorithm does not normalize layers because it will be used by other + * algorithms in most cases. If using this algorithm directly, be sure to + * run normalize at the end. + * + * Pre-conditions: + * + * 1. Input graph is a DAG. + * 2. Input graph node labels can be assigned properties. + * + * Post-conditions: + * + * 1. Each node will be assign an (unnormalized) "rank" property. + */ +function longestPath(g) { + var visited = {}; + + function dfs(v) { + var label = g.node(v); + if (has(visited, v)) { + return label.rank; + } + visited[v] = true; + + var rank = min( + map(g.outEdges(v), function (e) { + return dfs(e.w) - g.edge(e).minlen; + }) + ); + + if ( + rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3 + rank === undefined || // return value of _.map([]) for Lodash 4 + rank === null + ) { + // return value of _.map([null]) + rank = 0; + } + + return (label.rank = rank); + } + + forEach(g.sources(), dfs); +} + +/* + * Returns the amount of slack for the given edge. The slack is defined as the + * difference between the length of the edge and its minimum length. + */ +function slack(g, e) { + return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen; +} + +/* + * Constructs a spanning tree with tight edges and adjusted the input node's + * ranks to achieve this. A tight edge is one that is has a length that matches + * its "minlen" attribute. + * + * The basic structure for this function is derived from Gansner, et al., "A + * Technique for Drawing Directed Graphs." + * + * Pre-conditions: + * + * 1. Graph must be a DAG. + * 2. Graph must be connected. + * 3. Graph must have at least one node. + * 5. Graph nodes must have been previously assigned a "rank" property that + * respects the "minlen" property of incident edges. + * 6. Graph edges must have a "minlen" property. + * + * Post-conditions: + * + * - Graph nodes will have their rank adjusted to ensure that all edges are + * tight. + * + * Returns a tree (undirected graph) that is constructed using only "tight" + * edges. + */ +function feasibleTree(g) { + var t = new Graph({ directed: false }); + + // Choose arbitrary node from which to start our tree + var start = g.nodes()[0]; + var size = g.nodeCount(); + t.setNode(start, {}); + + var edge, delta; + while (tightTree(t, g) < size) { + edge = findMinSlackEdge(t, g); + delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); + shiftRanks(t, g, delta); + } + + return t; +} + +/* + * Finds a maximal tree of tight edges and returns the number of nodes in the + * tree. + */ +function tightTree(t, g) { + function dfs(v) { + forEach(g.nodeEdges(v), function (e) { + var edgeV = e.v, + w = v === edgeV ? e.w : edgeV; + if (!t.hasNode(w) && !slack(g, e)) { + t.setNode(w, {}); + t.setEdge(v, w, {}); + dfs(w); + } + }); + } + + forEach(t.nodes(), dfs); + return t.nodeCount(); +} + +/* + * Finds the edge with the smallest slack that is incident on tree and returns + * it. + */ +function findMinSlackEdge(t, g) { + return minBy(g.edges(), function (e) { + if (t.hasNode(e.v) !== t.hasNode(e.w)) { + return slack(g, e); + } + }); +} + +function shiftRanks(t, g, delta) { + forEach(t.nodes(), function (v) { + g.node(v).rank += delta; + }); +} + +function CycleException() {} +CycleException.prototype = new Error(); // must be an instance of Error to pass testing + +/* + * A helper that preforms a pre- or post-order traversal on the input graph + * and returns the nodes in the order they were visited. If the graph is + * undirected then this algorithm will navigate using neighbors. If the graph + * is directed then this algorithm will navigate using successors. + * + * Order must be one of "pre" or "post". + */ +function dfs$1(g, vs, order) { + if (!isArray(vs)) { + vs = [vs]; + } + + var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g); + + var acc = []; + var visited = {}; + forEach(vs, function (v) { + if (!g.hasNode(v)) { + throw new Error('Graph does not have node: ' + v); + } + + doDfs(g, v, order === 'post', visited, navigation, acc); + }); + return acc; +} + +function doDfs(g, v, postorder, visited, navigation, acc) { + if (!has(visited, v)) { + visited[v] = true; + + if (!postorder) { + acc.push(v); + } + forEach(navigation(v), function (w) { + doDfs(g, w, postorder, visited, navigation, acc); + }); + if (postorder) { + acc.push(v); + } + } +} + +function postorder$1(g, vs) { + return dfs$1(g, vs, 'post'); +} + +function preorder(g, vs) { + return dfs$1(g, vs, 'pre'); +} + +// Expose some internals for testing purposes +networkSimplex.initLowLimValues = initLowLimValues; +networkSimplex.initCutValues = initCutValues; +networkSimplex.calcCutValue = calcCutValue; +networkSimplex.leaveEdge = leaveEdge; +networkSimplex.enterEdge = enterEdge; +networkSimplex.exchangeEdges = exchangeEdges; + +/* + * The network simplex algorithm assigns ranks to each node in the input graph + * and iteratively improves the ranking to reduce the length of edges. + * + * Preconditions: + * + * 1. The input graph must be a DAG. + * 2. All nodes in the graph must have an object value. + * 3. All edges in the graph must have "minlen" and "weight" attributes. + * + * Postconditions: + * + * 1. All nodes in the graph will have an assigned "rank" attribute that has + * been optimized by the network simplex algorithm. Ranks start at 0. + * + * + * A rough sketch of the algorithm is as follows: + * + * 1. Assign initial ranks to each node. We use the longest path algorithm, + * which assigns ranks to the lowest position possible. In general this + * leads to very wide bottom ranks and unnecessarily long edges. + * 2. Construct a feasible tight tree. A tight tree is one such that all + * edges in the tree have no slack (difference between length of edge + * and minlen for the edge). This by itself greatly improves the assigned + * rankings by shorting edges. + * 3. Iteratively find edges that have negative cut values. Generally a + * negative cut value indicates that the edge could be removed and a new + * tree edge could be added to produce a more compact graph. + * + * Much of the algorithms here are derived from Gansner, et al., "A Technique + * for Drawing Directed Graphs." The structure of the file roughly follows the + * structure of the overall algorithm. + */ +function networkSimplex(g) { + g = simplify(g); + longestPath(g); + var t = feasibleTree(g); + initLowLimValues(t); + initCutValues(t, g); + + var e, f; + while ((e = leaveEdge(t))) { + f = enterEdge(t, g, e); + exchangeEdges(t, g, e, f); + } +} + +/* + * Initializes cut values for all edges in the tree. + */ +function initCutValues(t, g) { + var vs = postorder$1(t, t.nodes()); + vs = vs.slice(0, vs.length - 1); + forEach(vs, function (v) { + assignCutValue(t, g, v); + }); +} + +function assignCutValue(t, g, child) { + var childLab = t.node(child); + var parent = childLab.parent; + t.edge(child, parent).cutvalue = calcCutValue(t, g, child); +} + +/* + * Given the tight tree, its graph, and a child in the graph calculate and + * return the cut value for the edge between the child and its parent. + */ +function calcCutValue(t, g, child) { + var childLab = t.node(child); + var parent = childLab.parent; + // True if the child is on the tail end of the edge in the directed graph + var childIsTail = true; + // The graph's view of the tree edge we're inspecting + var graphEdge = g.edge(child, parent); + // The accumulated cut value for the edge between this node and its parent + var cutValue = 0; + + if (!graphEdge) { + childIsTail = false; + graphEdge = g.edge(parent, child); + } + + cutValue = graphEdge.weight; + + forEach(g.nodeEdges(child), function (e) { + var isOutEdge = e.v === child, + other = isOutEdge ? e.w : e.v; + + if (other !== parent) { + var pointsToHead = isOutEdge === childIsTail, + otherWeight = g.edge(e).weight; + + cutValue += pointsToHead ? otherWeight : -otherWeight; + if (isTreeEdge(t, child, other)) { + var otherCutValue = t.edge(child, other).cutvalue; + cutValue += pointsToHead ? -otherCutValue : otherCutValue; + } + } + }); + + return cutValue; +} + +function initLowLimValues(tree, root) { + if (arguments.length < 2) { + root = tree.nodes()[0]; + } + dfsAssignLowLim(tree, {}, 1, root); +} + +function dfsAssignLowLim(tree, visited, nextLim, v, parent) { + var low = nextLim; + var label = tree.node(v); + + visited[v] = true; + forEach(tree.neighbors(v), function (w) { + if (!has(visited, w)) { + nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v); + } + }); + + label.low = low; + label.lim = nextLim++; + if (parent) { + label.parent = parent; + } else { + // TODO should be able to remove this when we incrementally update low lim + delete label.parent; + } + + return nextLim; +} + +function leaveEdge(tree) { + return find(tree.edges(), function (e) { + return tree.edge(e).cutvalue < 0; + }); +} + +function enterEdge(t, g, edge) { + var v = edge.v; + var w = edge.w; + + // For the rest of this function we assume that v is the tail and w is the + // head, so if we don't have this edge in the graph we should flip it to + // match the correct orientation. + if (!g.hasEdge(v, w)) { + v = edge.w; + w = edge.v; + } + + var vLabel = t.node(v); + var wLabel = t.node(w); + var tailLabel = vLabel; + var flip = false; + + // If the root is in the tail of the edge then we need to flip the logic that + // checks for the head and tail nodes in the candidates function below. + if (vLabel.lim > wLabel.lim) { + tailLabel = wLabel; + flip = true; + } + + var candidates = filter(g.edges(), function (edge) { + return ( + flip === isDescendant(t, t.node(edge.v), tailLabel) && + flip !== isDescendant(t, t.node(edge.w), tailLabel) + ); + }); + + return minBy(candidates, function (edge) { + return slack(g, edge); + }); +} + +function exchangeEdges(t, g, e, f) { + var v = e.v; + var w = e.w; + t.removeEdge(v, w); + t.setEdge(f.v, f.w, {}); + initLowLimValues(t); + initCutValues(t, g); + updateRanks(t, g); +} + +function updateRanks(t, g) { + var root = find(t.nodes(), function (v) { + return !g.node(v).parent; + }); + var vs = preorder(t, root); + vs = vs.slice(1); + forEach(vs, function (v) { + var parent = t.node(v).parent, + edge = g.edge(v, parent), + flipped = false; + + if (!edge) { + edge = g.edge(parent, v); + flipped = true; + } + + g.node(v).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen); + }); +} + +/* + * Returns true if the edge is in the tree. + */ +function isTreeEdge(tree, u, v) { + return tree.hasEdge(u, v); +} + +/* + * Returns true if the specified node is descendant of the root node per the + * assigned low and lim attributes in the tree. + */ +function isDescendant(tree, vLabel, rootLabel) { + return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim; +} + +/* + * Assigns a rank to each node in the input graph that respects the "minlen" + * constraint specified on edges between nodes. + * + * This basic structure is derived from Gansner, et al., "A Technique for + * Drawing Directed Graphs." + * + * Pre-conditions: + * + * 1. Graph must be a connected DAG + * 2. Graph nodes must be objects + * 3. Graph edges must have "weight" and "minlen" attributes + * + * Post-conditions: + * + * 1. Graph nodes will have a "rank" attribute based on the results of the + * algorithm. Ranks can start at any index (including negative), we'll + * fix them up later. + */ +function rank(g) { + switch (g.graph().ranker) { + case 'network-simplex': + networkSimplexRanker(g); + break; + case 'tight-tree': + tightTreeRanker(g); + break; + case 'longest-path': + longestPathRanker(g); + break; + default: + networkSimplexRanker(g); + } +} + +// A fast and simple ranker, but results are far from optimal. +var longestPathRanker = longestPath; + +function tightTreeRanker(g) { + longestPath(g); + feasibleTree(g); +} + +function networkSimplexRanker(g) { + networkSimplex(g); +} + +/* + * A nesting graph creates dummy nodes for the tops and bottoms of subgraphs, + * adds appropriate edges to ensure that all cluster nodes are placed between + * these boundries, and ensures that the graph is connected. + * + * In addition we ensure, through the use of the minlen property, that nodes + * and subgraph border nodes to not end up on the same rank. + * + * Preconditions: + * + * 1. Input graph is a DAG + * 2. Nodes in the input graph has a minlen attribute + * + * Postconditions: + * + * 1. Input graph is connected. + * 2. Dummy nodes are added for the tops and bottoms of subgraphs. + * 3. The minlen attribute for nodes is adjusted to ensure nodes do not + * get placed on the same rank as subgraph border nodes. + * + * The nesting graph idea comes from Sander, "Layout of Compound Directed + * Graphs." + */ +function run(g) { + var root = addDummyNode(g, 'root', {}, '_root'); + var depths = treeDepths(g); + var height = max(values(depths)) - 1; // Note: depths is an Object not an array + var nodeSep = 2 * height + 1; + + g.graph().nestingRoot = root; + + // Multiply minlen by nodeSep to align nodes on non-border ranks. + forEach(g.edges(), function (e) { + g.edge(e).minlen *= nodeSep; + }); + + // Calculate a weight that is sufficient to keep subgraphs vertically compact + var weight = sumWeights(g) + 1; + + // Create border nodes and link them up + forEach(g.children(), function (child) { + dfs(g, root, nodeSep, weight, height, depths, child); + }); + + // Save the multiplier for node layers for later removal of empty border + // layers. + g.graph().nodeRankFactor = nodeSep; +} + +function dfs(g, root, nodeSep, weight, height, depths, v) { + var children = g.children(v); + if (!children.length) { + if (v !== root) { + g.setEdge(root, v, { weight: 0, minlen: nodeSep }); + } + return; + } + + var top = addBorderNode$1(g, '_bt'); + var bottom = addBorderNode$1(g, '_bb'); + var label = g.node(v); + + g.setParent(top, v); + label.borderTop = top; + g.setParent(bottom, v); + label.borderBottom = bottom; + + forEach(children, function (child) { + dfs(g, root, nodeSep, weight, height, depths, child); + + var childNode = g.node(child); + var childTop = childNode.borderTop ? childNode.borderTop : child; + var childBottom = childNode.borderBottom ? childNode.borderBottom : child; + var thisWeight = childNode.borderTop ? weight : 2 * weight; + var minlen = childTop !== childBottom ? 1 : height - depths[v] + 1; + + g.setEdge(top, childTop, { + weight: thisWeight, + minlen: minlen, + nestingEdge: true, + }); + + g.setEdge(childBottom, bottom, { + weight: thisWeight, + minlen: minlen, + nestingEdge: true, + }); + }); + + if (!g.parent(v)) { + g.setEdge(root, top, { weight: 0, minlen: height + depths[v] }); + } +} + +function treeDepths(g) { + var depths = {}; + function dfs(v, depth) { + var children = g.children(v); + if (children && children.length) { + forEach(children, function (child) { + dfs(child, depth + 1); + }); + } + depths[v] = depth; + } + forEach(g.children(), function (v) { + dfs(v, 1); + }); + return depths; +} + +function sumWeights(g) { + return reduce( + g.edges(), + function (acc, e) { + return acc + g.edge(e).weight; + }, + 0 + ); +} + +function cleanup(g) { + var graphLabel = g.graph(); + g.removeNode(graphLabel.nestingRoot); + delete graphLabel.nestingRoot; + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.nestingEdge) { + g.removeEdge(e); + } + }); +} + +function addSubgraphConstraints(g, cg, vs) { + var prev = {}, + rootPrev; + + forEach(vs, function (v) { + var child = g.parent(v), + parent, + prevChild; + while (child) { + parent = g.parent(child); + if (parent) { + prevChild = prev[parent]; + prev[parent] = child; + } else { + prevChild = rootPrev; + rootPrev = child; + } + if (prevChild && prevChild !== child) { + cg.setEdge(prevChild, child); + return; + } + child = parent; + } + }); + + /* + function dfs(v) { + var children = v ? g.children(v) : g.children(); + if (children.length) { + var min = Number.POSITIVE_INFINITY, + subgraphs = []; + _.each(children, function(child) { + var childMin = dfs(child); + if (g.children(child).length) { + subgraphs.push({ v: child, order: childMin }); + } + min = Math.min(min, childMin); + }); + _.reduce(_.sortBy(subgraphs, "order"), function(prev, curr) { + cg.setEdge(prev.v, curr.v); + return curr; + }); + return min; + } + return g.node(v).order; + } + dfs(undefined); + */ +} + +/* + * Constructs a graph that can be used to sort a layer of nodes. The graph will + * contain all base and subgraph nodes from the request layer in their original + * hierarchy and any edges that are incident on these nodes and are of the type + * requested by the "relationship" parameter. + * + * Nodes from the requested rank that do not have parents are assigned a root + * node in the output graph, which is set in the root graph attribute. This + * makes it easy to walk the hierarchy of movable nodes during ordering. + * + * Pre-conditions: + * + * 1. Input graph is a DAG + * 2. Base nodes in the input graph have a rank attribute + * 3. Subgraph nodes in the input graph has minRank and maxRank attributes + * 4. Edges have an assigned weight + * + * Post-conditions: + * + * 1. Output graph has all nodes in the movable rank with preserved + * hierarchy. + * 2. Root nodes in the movable layer are made children of the node + * indicated by the root attribute of the graph. + * 3. Non-movable nodes incident on movable nodes, selected by the + * relationship parameter, are included in the graph (without hierarchy). + * 4. Edges incident on movable nodes, selected by the relationship + * parameter, are added to the output graph. + * 5. The weights for copied edges are aggregated as need, since the output + * graph is not a multi-graph. + */ +function buildLayerGraph(g, rank, relationship) { + var root = createRootNode(g), + result = new Graph({ compound: true }) + .setGraph({ root: root }) + .setDefaultNodeLabel(function (v) { + return g.node(v); + }); + + forEach(g.nodes(), function (v) { + var node = g.node(v), + parent = g.parent(v); + + if (node.rank === rank || (node.minRank <= rank && rank <= node.maxRank)) { + result.setNode(v); + result.setParent(v, parent || root); + + // This assumes we have only short edges! + forEach(g[relationship](v), function (e) { + var u = e.v === v ? e.w : e.v, + edge = result.edge(u, v), + weight = !isUndefined(edge) ? edge.weight : 0; + result.setEdge(u, v, { weight: g.edge(e).weight + weight }); + }); + + if (has(node, 'minRank')) { + result.setNode(v, { + borderLeft: node.borderLeft[rank], + borderRight: node.borderRight[rank], + }); + } + } + }); + + return result; +} + +function createRootNode(g) { + var v; + while (g.hasNode((v = uniqueId('_root')))); + return v; +} + +/* + * A function that takes a layering (an array of layers, each with an array of + * ordererd nodes) and a graph and returns a weighted crossing count. + * + * Pre-conditions: + * + * 1. Input graph must be simple (not a multigraph), directed, and include + * only simple edges. + * 2. Edges in the input graph must have assigned weights. + * + * Post-conditions: + * + * 1. The graph and layering matrix are left unchanged. + * + * This algorithm is derived from Barth, et al., "Bilayer Cross Counting." + */ +function crossCount(g, layering) { + var cc = 0; + for (var i = 1; i < layering.length; ++i) { + cc += twoLayerCrossCount(g, layering[i - 1], layering[i]); + } + return cc; +} + +function twoLayerCrossCount(g, northLayer, southLayer) { + // Sort all of the edges between the north and south layers by their position + // in the north layer and then the south. Map these edges to the position of + // their head in the south layer. + var southPos = zipObject( + southLayer, + map(southLayer, function (v, i) { + return i; + }) + ); + var southEntries = flatten( + map(northLayer, function (v) { + return sortBy( + map(g.outEdges(v), function (e) { + return { pos: southPos[e.w], weight: g.edge(e).weight }; + }), + 'pos' + ); + }) + ); + + // Build the accumulator tree + var firstIndex = 1; + while (firstIndex < southLayer.length) firstIndex <<= 1; + var treeSize = 2 * firstIndex - 1; + firstIndex -= 1; + var tree = map(new Array(treeSize), function () { + return 0; + }); + + // Calculate the weighted crossings + var cc = 0; + forEach( + // @ts-expect-error + southEntries.forEach(function (entry) { + var index = entry.pos + firstIndex; + tree[index] += entry.weight; + var weightSum = 0; + // @ts-expect-error + while (index > 0) { + // @ts-expect-error + if (index % 2) { + weightSum += tree[index + 1]; + } + // @ts-expect-error + index = (index - 1) >> 1; + tree[index] += entry.weight; + } + cc += entry.weight * weightSum; + }) + ); + + return cc; +} + +/* + * Assigns an initial order value for each node by performing a DFS search + * starting from nodes in the first rank. Nodes are assigned an order in their + * rank as they are first visited. + * + * This approach comes from Gansner, et al., "A Technique for Drawing Directed + * Graphs." + * + * Returns a layering matrix with an array per layer and each layer sorted by + * the order of its nodes. + */ +function initOrder(g) { + var visited = {}; + var simpleNodes = filter(g.nodes(), function (v) { + return !g.children(v).length; + }); + var maxRank = max( + map(simpleNodes, function (v) { + return g.node(v).rank; + }) + ); + var layers = map(range(maxRank + 1), function () { + return []; + }); + + function dfs(v) { + if (has(visited, v)) return; + visited[v] = true; + var node = g.node(v); + layers[node.rank].push(v); + forEach(g.successors(v), dfs); + } + + var orderedVs = sortBy(simpleNodes, function (v) { + return g.node(v).rank; + }); + forEach(orderedVs, dfs); + + return layers; +} + +function barycenter(g, movable) { + return map(movable, function (v) { + var inV = g.inEdges(v); + if (!inV.length) { + return { v: v }; + } else { + var result = reduce( + inV, + function (acc, e) { + var edge = g.edge(e), + nodeU = g.node(e.v); + return { + sum: acc.sum + edge.weight * nodeU.order, + weight: acc.weight + edge.weight, + }; + }, + { sum: 0, weight: 0 } + ); + + return { + v: v, + barycenter: result.sum / result.weight, + weight: result.weight, + }; + } + }); +} + +/* + * Given a list of entries of the form {v, barycenter, weight} and a + * constraint graph this function will resolve any conflicts between the + * constraint graph and the barycenters for the entries. If the barycenters for + * an entry would violate a constraint in the constraint graph then we coalesce + * the nodes in the conflict into a new node that respects the contraint and + * aggregates barycenter and weight information. + * + * This implementation is based on the description in Forster, "A Fast and + * Simple Hueristic for Constrained Two-Level Crossing Reduction," thought it + * differs in some specific details. + * + * Pre-conditions: + * + * 1. Each entry has the form {v, barycenter, weight}, or if the node has + * no barycenter, then {v}. + * + * Returns: + * + * A new list of entries of the form {vs, i, barycenter, weight}. The list + * `vs` may either be a singleton or it may be an aggregation of nodes + * ordered such that they do not violate constraints from the constraint + * graph. The property `i` is the lowest original index of any of the + * elements in `vs`. + */ +function resolveConflicts(entries, cg) { + var mappedEntries = {}; + forEach(entries, function (entry, i) { + var tmp = (mappedEntries[entry.v] = { + indegree: 0, + in: [], + out: [], + vs: [entry.v], + i: i, + }); + if (!isUndefined(entry.barycenter)) { + // @ts-expect-error + tmp.barycenter = entry.barycenter; + // @ts-expect-error + tmp.weight = entry.weight; + } + }); + + forEach(cg.edges(), function (e) { + var entryV = mappedEntries[e.v]; + var entryW = mappedEntries[e.w]; + if (!isUndefined(entryV) && !isUndefined(entryW)) { + entryW.indegree++; + entryV.out.push(mappedEntries[e.w]); + } + }); + + var sourceSet = filter(mappedEntries, function (entry) { + // @ts-expect-error + return !entry.indegree; + }); + + return doResolveConflicts(sourceSet); +} + +function doResolveConflicts(sourceSet) { + var entries = []; + + function handleIn(vEntry) { + return function (uEntry) { + if (uEntry.merged) { + return; + } + if ( + isUndefined(uEntry.barycenter) || + isUndefined(vEntry.barycenter) || + uEntry.barycenter >= vEntry.barycenter + ) { + mergeEntries(vEntry, uEntry); + } + }; + } + + function handleOut(vEntry) { + return function (wEntry) { + wEntry['in'].push(vEntry); + if (--wEntry.indegree === 0) { + sourceSet.push(wEntry); + } + }; + } + + while (sourceSet.length) { + var entry = sourceSet.pop(); + entries.push(entry); + forEach(entry['in'].reverse(), handleIn(entry)); + forEach(entry.out, handleOut(entry)); + } + + return map( + filter(entries, function (entry) { + return !entry.merged; + }), + function (entry) { + return pick(entry, ['vs', 'i', 'barycenter', 'weight']); + } + ); +} + +function mergeEntries(target, source) { + var sum = 0; + var weight = 0; + + if (target.weight) { + sum += target.barycenter * target.weight; + weight += target.weight; + } + + if (source.weight) { + sum += source.barycenter * source.weight; + weight += source.weight; + } + + target.vs = source.vs.concat(target.vs); + target.barycenter = sum / weight; + target.weight = weight; + target.i = Math.min(source.i, target.i); + source.merged = true; +} + +function sort(entries, biasRight) { + var parts = partition(entries, function (entry) { + return has(entry, 'barycenter'); + }); + var sortable = parts.lhs, + unsortable = sortBy(parts.rhs, function (entry) { + return -entry.i; + }), + vs = [], + sum = 0, + weight = 0, + vsIndex = 0; + + sortable.sort(compareWithBias(!!biasRight)); + + vsIndex = consumeUnsortable(vs, unsortable, vsIndex); + + forEach(sortable, function (entry) { + vsIndex += entry.vs.length; + vs.push(entry.vs); + sum += entry.barycenter * entry.weight; + weight += entry.weight; + vsIndex = consumeUnsortable(vs, unsortable, vsIndex); + }); + + var result = { vs: flatten(vs) }; + if (weight) { + result.barycenter = sum / weight; + result.weight = weight; + } + return result; +} + +function consumeUnsortable(vs, unsortable, index) { + var last$1; + while (unsortable.length && (last$1 = last(unsortable)).i <= index) { + unsortable.pop(); + vs.push(last$1.vs); + index++; + } + return index; +} + +function compareWithBias(bias) { + return function (entryV, entryW) { + if (entryV.barycenter < entryW.barycenter) { + return -1; + } else if (entryV.barycenter > entryW.barycenter) { + return 1; + } + + return !bias ? entryV.i - entryW.i : entryW.i - entryV.i; + }; +} + +function sortSubgraph(g, v, cg, biasRight) { + var movable = g.children(v); + var node = g.node(v); + var bl = node ? node.borderLeft : undefined; + var br = node ? node.borderRight : undefined; + var subgraphs = {}; + + if (bl) { + movable = filter(movable, function (w) { + return w !== bl && w !== br; + }); + } + + var barycenters = barycenter(g, movable); + forEach(barycenters, function (entry) { + if (g.children(entry.v).length) { + var subgraphResult = sortSubgraph(g, entry.v, cg, biasRight); + subgraphs[entry.v] = subgraphResult; + if (has(subgraphResult, 'barycenter')) { + mergeBarycenters(entry, subgraphResult); + } + } + }); + + var entries = resolveConflicts(barycenters, cg); + expandSubgraphs(entries, subgraphs); + + var result = sort(entries, biasRight); + + if (bl) { + result.vs = flatten([bl, result.vs, br]); + if (g.predecessors(bl).length) { + var blPred = g.node(g.predecessors(bl)[0]), + brPred = g.node(g.predecessors(br)[0]); + if (!has(result, 'barycenter')) { + result.barycenter = 0; + result.weight = 0; + } + result.barycenter = + (result.barycenter * result.weight + blPred.order + brPred.order) / (result.weight + 2); + result.weight += 2; + } + } + + return result; +} + +function expandSubgraphs(entries, subgraphs) { + forEach(entries, function (entry) { + entry.vs = flatten( + entry.vs.map(function (v) { + if (subgraphs[v]) { + return subgraphs[v].vs; + } + return v; + }) + ); + }); +} + +function mergeBarycenters(target, other) { + if (!isUndefined(target.barycenter)) { + target.barycenter = + (target.barycenter * target.weight + other.barycenter * other.weight) / + (target.weight + other.weight); + target.weight += other.weight; + } else { + target.barycenter = other.barycenter; + target.weight = other.weight; + } +} + +/* + * Applies heuristics to minimize edge crossings in the graph and sets the best + * order solution as an order attribute on each node. + * + * Pre-conditions: + * + * 1. Graph must be DAG + * 2. Graph nodes must be objects with a "rank" attribute + * 3. Graph edges must have the "weight" attribute + * + * Post-conditions: + * + * 1. Graph nodes will have an "order" attribute based on the results of the + * algorithm. + */ +function order(g) { + var maxRank$1 = maxRank(g), + downLayerGraphs = buildLayerGraphs(g, range(1, maxRank$1 + 1), 'inEdges'), + upLayerGraphs = buildLayerGraphs(g, range(maxRank$1 - 1, -1, -1), 'outEdges'); + + var layering = initOrder(g); + assignOrder(g, layering); + + var bestCC = Number.POSITIVE_INFINITY, + best; + + for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) { + sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2); + + layering = buildLayerMatrix(g); + var cc = crossCount(g, layering); + if (cc < bestCC) { + lastBest = 0; + best = cloneDeep(layering); + bestCC = cc; + } + } + + assignOrder(g, best); +} + +function buildLayerGraphs(g, ranks, relationship) { + return map(ranks, function (rank) { + return buildLayerGraph(g, rank, relationship); + }); +} + +function sweepLayerGraphs(layerGraphs, biasRight) { + var cg = new Graph(); + forEach(layerGraphs, function (lg) { + var root = lg.graph().root; + var sorted = sortSubgraph(lg, root, cg, biasRight); + forEach(sorted.vs, function (v, i) { + lg.node(v).order = i; + }); + addSubgraphConstraints(lg, cg, sorted.vs); + }); +} + +function assignOrder(g, layering) { + forEach(layering, function (layer) { + forEach(layer, function (v, i) { + g.node(v).order = i; + }); + }); +} + +function parentDummyChains(g) { + var postorderNums = postorder(g); + + forEach(g.graph().dummyChains, function (v) { + var node = g.node(v); + var edgeObj = node.edgeObj; + var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w); + var path = pathData.path; + var lca = pathData.lca; + var pathIdx = 0; + var pathV = path[pathIdx]; + var ascending = true; + + while (v !== edgeObj.w) { + node = g.node(v); + + if (ascending) { + while ((pathV = path[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) { + pathIdx++; + } + + if (pathV === lca) { + ascending = false; + } + } + + if (!ascending) { + while ( + pathIdx < path.length - 1 && + g.node((pathV = path[pathIdx + 1])).minRank <= node.rank + ) { + pathIdx++; + } + pathV = path[pathIdx]; + } + + g.setParent(v, pathV); + v = g.successors(v)[0]; + } + }); +} + +// Find a path from v to w through the lowest common ancestor (LCA). Return the +// full path and the LCA. +function findPath(g, postorderNums, v, w) { + var vPath = []; + var wPath = []; + var low = Math.min(postorderNums[v].low, postorderNums[w].low); + var lim = Math.max(postorderNums[v].lim, postorderNums[w].lim); + var parent; + var lca; + + // Traverse up from v to find the LCA + parent = v; + do { + parent = g.parent(parent); + vPath.push(parent); + } while (parent && (postorderNums[parent].low > low || lim > postorderNums[parent].lim)); + lca = parent; + + // Traverse from w to LCA + parent = w; + while ((parent = g.parent(parent)) !== lca) { + wPath.push(parent); + } + + return { path: vPath.concat(wPath.reverse()), lca: lca }; +} + +function postorder(g) { + var result = {}; + var lim = 0; + + function dfs(v) { + var low = lim; + forEach(g.children(v), dfs); + result[v] = { low: low, lim: lim++ }; + } + forEach(g.children(), dfs); + + return result; +} + +/* + * Marks all edges in the graph with a type-1 conflict with the "type1Conflict" + * property. A type-1 conflict is one where a non-inner segment crosses an + * inner segment. An inner segment is an edge with both incident nodes marked + * with the "dummy" property. + * + * This algorithm scans layer by layer, starting with the second, for type-1 + * conflicts between the current layer and the previous layer. For each layer + * it scans the nodes from left to right until it reaches one that is incident + * on an inner segment. It then scans predecessors to determine if they have + * edges that cross that inner segment. At the end a final scan is done for all + * nodes on the current rank to see if they cross the last visited inner + * segment. + * + * This algorithm (safely) assumes that a dummy node will only be incident on a + * single node in the layers being scanned. + */ +function findType1Conflicts(g, layering) { + var conflicts = {}; + + function visitLayer(prevLayer, layer) { + var // last visited node in the previous layer that is incident on an inner + // segment. + k0 = 0, + // Tracks the last node in this layer scanned for crossings with a type-1 + // segment. + scanPos = 0, + prevLayerLength = prevLayer.length, + lastNode = last(layer); + + forEach(layer, function (v, i) { + var w = findOtherInnerSegmentNode(g, v), + k1 = w ? g.node(w).order : prevLayerLength; + + if (w || v === lastNode) { + forEach(layer.slice(scanPos, i + 1), function (scanNode) { + forEach(g.predecessors(scanNode), function (u) { + var uLabel = g.node(u), + uPos = uLabel.order; + if ((uPos < k0 || k1 < uPos) && !(uLabel.dummy && g.node(scanNode).dummy)) { + addConflict(conflicts, u, scanNode); + } + }); + }); + // @ts-expect-error + scanPos = i + 1; + k0 = k1; + } + }); + + return layer; + } + + reduce(layering, visitLayer); + return conflicts; +} + +function findType2Conflicts(g, layering) { + var conflicts = {}; + + function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) { + var v; + forEach(range(southPos, southEnd), function (i) { + v = south[i]; + if (g.node(v).dummy) { + forEach(g.predecessors(v), function (u) { + var uNode = g.node(u); + if (uNode.dummy && (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) { + addConflict(conflicts, u, v); + } + }); + } + }); + } + + function visitLayer(north, south) { + var prevNorthPos = -1, + nextNorthPos, + southPos = 0; + + forEach(south, function (v, southLookahead) { + if (g.node(v).dummy === 'border') { + var predecessors = g.predecessors(v); + if (predecessors.length) { + nextNorthPos = g.node(predecessors[0]).order; + scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos); + // @ts-expect-error + southPos = southLookahead; + prevNorthPos = nextNorthPos; + } + } + scan(south, southPos, south.length, nextNorthPos, north.length); + }); + + return south; + } + + reduce(layering, visitLayer); + return conflicts; +} + +function findOtherInnerSegmentNode(g, v) { + if (g.node(v).dummy) { + return find(g.predecessors(v), function (u) { + return g.node(u).dummy; + }); + } +} + +function addConflict(conflicts, v, w) { + if (v > w) { + var tmp = v; + v = w; + w = tmp; + } + + var conflictsV = conflicts[v]; + if (!conflictsV) { + conflicts[v] = conflictsV = {}; + } + conflictsV[w] = true; +} + +function hasConflict(conflicts, v, w) { + if (v > w) { + var tmp = v; + v = w; + w = tmp; + } + return has(conflicts[v], w); +} + +/* + * Try to align nodes into vertical "blocks" where possible. This algorithm + * attempts to align a node with one of its median neighbors. If the edge + * connecting a neighbor is a type-1 conflict then we ignore that possibility. + * If a previous node has already formed a block with a node after the node + * we're trying to form a block with, we also ignore that possibility - our + * blocks would be split in that scenario. + */ +function verticalAlignment(g, layering, conflicts, neighborFn) { + var root = {}, + align = {}, + pos = {}; + + // We cache the position here based on the layering because the graph and + // layering may be out of sync. The layering matrix is manipulated to + // generate different extreme alignments. + forEach(layering, function (layer) { + forEach(layer, function (v, order) { + root[v] = v; + align[v] = v; + pos[v] = order; + }); + }); + + forEach(layering, function (layer) { + var prevIdx = -1; + forEach(layer, function (v) { + var ws = neighborFn(v); + if (ws.length) { + ws = sortBy(ws, function (w) { + return pos[w]; + }); + var mp = (ws.length - 1) / 2; + for (var i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) { + var w = ws[i]; + if (align[v] === v && prevIdx < pos[w] && !hasConflict(conflicts, v, w)) { + align[w] = v; + align[v] = root[v] = root[w]; + prevIdx = pos[w]; + } + } + } + }); + }); + + return { root: root, align: align }; +} + +function horizontalCompaction(g, layering, root, align, reverseSep) { + // This portion of the algorithm differs from BK due to a number of problems. + // Instead of their algorithm we construct a new block graph and do two + // sweeps. The first sweep places blocks with the smallest possible + // coordinates. The second sweep removes unused space by moving blocks to the + // greatest coordinates without violating separation. + var xs = {}, + blockG = buildBlockGraph(g, layering, root, reverseSep), + borderType = reverseSep ? 'borderLeft' : 'borderRight'; + + function iterate(setXsFunc, nextNodesFunc) { + var stack = blockG.nodes(); + var elem = stack.pop(); + var visited = {}; + while (elem) { + if (visited[elem]) { + setXsFunc(elem); + } else { + visited[elem] = true; + stack.push(elem); + stack = stack.concat(nextNodesFunc(elem)); + } + + elem = stack.pop(); + } + } + + // First pass, assign smallest coordinates + function pass1(elem) { + xs[elem] = blockG.inEdges(elem).reduce(function (acc, e) { + return Math.max(acc, xs[e.v] + blockG.edge(e)); + }, 0); + } + + // Second pass, assign greatest coordinates + function pass2(elem) { + var min = blockG.outEdges(elem).reduce(function (acc, e) { + return Math.min(acc, xs[e.w] - blockG.edge(e)); + }, Number.POSITIVE_INFINITY); + + var node = g.node(elem); + if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) { + xs[elem] = Math.max(xs[elem], min); + } + } + + iterate(pass1, blockG.predecessors.bind(blockG)); + iterate(pass2, blockG.successors.bind(blockG)); + + // Assign x coordinates to all nodes + forEach(align, function (v) { + xs[v] = xs[root[v]]; + }); + + return xs; +} + +function buildBlockGraph(g, layering, root, reverseSep) { + var blockGraph = new Graph(), + graphLabel = g.graph(), + sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep); + + forEach(layering, function (layer) { + var u; + forEach(layer, function (v) { + var vRoot = root[v]; + blockGraph.setNode(vRoot); + if (u) { + var uRoot = root[u], + prevMax = blockGraph.edge(uRoot, vRoot); + blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0)); + } + u = v; + }); + }); + + return blockGraph; +} + +/* + * Returns the alignment that has the smallest width of the given alignments. + */ +function findSmallestWidthAlignment(g, xss) { + return minBy(values(xss), function (xs) { + var max = Number.NEGATIVE_INFINITY; + var min = Number.POSITIVE_INFINITY; + + forIn(xs, function (x, v) { + var halfWidth = width(g, v) / 2; + + max = Math.max(x + halfWidth, max); + min = Math.min(x - halfWidth, min); + }); + + return max - min; + }); +} + +/* + * Align the coordinates of each of the layout alignments such that + * left-biased alignments have their minimum coordinate at the same point as + * the minimum coordinate of the smallest width alignment and right-biased + * alignments have their maximum coordinate at the same point as the maximum + * coordinate of the smallest width alignment. + */ +function alignCoordinates(xss, alignTo) { + var alignToVals = values(alignTo), + alignToMin = min(alignToVals), + alignToMax = max(alignToVals); + + forEach(['u', 'd'], function (vert) { + forEach(['l', 'r'], function (horiz) { + var alignment = vert + horiz, + xs = xss[alignment], + delta; + if (xs === alignTo) return; + + var xsVals = values(xs); + delta = horiz === 'l' ? alignToMin - min(xsVals) : alignToMax - max(xsVals); + + if (delta) { + xss[alignment] = mapValues(xs, function (x) { + return x + delta; + }); + } + }); + }); +} + +function balance(xss, align) { + return mapValues(xss.ul, function (ignore, v) { + if (align) { + return xss[align.toLowerCase()][v]; + } else { + var xs = sortBy(map(xss, v)); + return (xs[1] + xs[2]) / 2; + } + }); +} + +function positionX(g) { + var layering = buildLayerMatrix(g); + var conflicts = merge(findType1Conflicts(g, layering), findType2Conflicts(g, layering)); + + var xss = {}; + var adjustedLayering; + forEach(['u', 'd'], function (vert) { + adjustedLayering = vert === 'u' ? layering : values(layering).reverse(); + forEach(['l', 'r'], function (horiz) { + if (horiz === 'r') { + adjustedLayering = map(adjustedLayering, function (inner) { + return values(inner).reverse(); + }); + } + + var neighborFn = (vert === 'u' ? g.predecessors : g.successors).bind(g); + var align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn); + var xs = horizontalCompaction(g, adjustedLayering, align.root, align.align, horiz === 'r'); + if (horiz === 'r') { + xs = mapValues(xs, function (x) { + return -x; + }); + } + xss[vert + horiz] = xs; + }); + }); + + var smallestWidth = findSmallestWidthAlignment(g, xss); + alignCoordinates(xss, smallestWidth); + return balance(xss, g.graph().align); +} + +function sep(nodeSep, edgeSep, reverseSep) { + return function (g, v, w) { + var vLabel = g.node(v); + var wLabel = g.node(w); + var sum = 0; + var delta; + + sum += vLabel.width / 2; + if (has(vLabel, 'labelpos')) { + switch (vLabel.labelpos.toLowerCase()) { + case 'l': + delta = -vLabel.width / 2; + break; + case 'r': + delta = vLabel.width / 2; + break; + } + } + if (delta) { + sum += reverseSep ? delta : -delta; + } + delta = 0; + + sum += (vLabel.dummy ? edgeSep : nodeSep) / 2; + sum += (wLabel.dummy ? edgeSep : nodeSep) / 2; + + sum += wLabel.width / 2; + if (has(wLabel, 'labelpos')) { + switch (wLabel.labelpos.toLowerCase()) { + case 'l': + delta = wLabel.width / 2; + break; + case 'r': + delta = -wLabel.width / 2; + break; + } + } + if (delta) { + sum += reverseSep ? delta : -delta; + } + delta = 0; + + return sum; + }; +} + +function width(g, v) { + return g.node(v).width; +} + +function position(g) { + g = asNonCompoundGraph(g); + + positionY(g); + forOwn(positionX(g), function (x, v) { + g.node(v).x = x; + }); +} + +function positionY(g) { + var layering = buildLayerMatrix(g); + var rankSep = g.graph().ranksep; + var prevY = 0; + forEach(layering, function (layer) { + var maxHeight = max( + map(layer, function (v) { + return g.node(v).height; + }) + ); + forEach(layer, function (v) { + g.node(v).y = prevY + maxHeight / 2; + }); + prevY += maxHeight + rankSep; + }); +} + +function layout(g, opts) { + var time = notime; + time('layout', function () { + var layoutGraph = time(' buildLayoutGraph', function () { + return buildLayoutGraph(g); + }); + time(' runLayout', function () { + runLayout(layoutGraph, time); + }); + time(' updateInputGraph', function () { + updateInputGraph(g, layoutGraph); + }); + }); +} + +function runLayout(g, time) { + time(' makeSpaceForEdgeLabels', function () { + makeSpaceForEdgeLabels(g); + }); + time(' removeSelfEdges', function () { + removeSelfEdges(g); + }); + time(' acyclic', function () { + run$2(g); + }); + time(' nestingGraph.run', function () { + run(g); + }); + time(' rank', function () { + rank(asNonCompoundGraph(g)); + }); + time(' injectEdgeLabelProxies', function () { + injectEdgeLabelProxies(g); + }); + time(' removeEmptyRanks', function () { + removeEmptyRanks(g); + }); + time(' nestingGraph.cleanup', function () { + cleanup(g); + }); + time(' normalizeRanks', function () { + normalizeRanks(g); + }); + time(' assignRankMinMax', function () { + assignRankMinMax(g); + }); + time(' removeEdgeLabelProxies', function () { + removeEdgeLabelProxies(g); + }); + time(' normalize.run', function () { + run$1(g); + }); + time(' parentDummyChains', function () { + parentDummyChains(g); + }); + time(' addBorderSegments', function () { + addBorderSegments(g); + }); + time(' order', function () { + order(g); + }); + time(' insertSelfEdges', function () { + insertSelfEdges(g); + }); + time(' adjustCoordinateSystem', function () { + adjust(g); + }); + time(' position', function () { + position(g); + }); + time(' positionSelfEdges', function () { + positionSelfEdges(g); + }); + time(' removeBorderNodes', function () { + removeBorderNodes(g); + }); + time(' normalize.undo', function () { + undo(g); + }); + time(' fixupEdgeLabelCoords', function () { + fixupEdgeLabelCoords(g); + }); + time(' undoCoordinateSystem', function () { + undo$1(g); + }); + time(' translateGraph', function () { + translateGraph(g); + }); + time(' assignNodeIntersects', function () { + assignNodeIntersects(g); + }); + time(' reversePoints', function () { + reversePointsForReversedEdges(g); + }); + time(' acyclic.undo', function () { + undo$2(g); + }); +} + +/* + * Copies final layout information from the layout graph back to the input + * graph. This process only copies whitelisted attributes from the layout graph + * to the input graph, so it serves as a good place to determine what + * attributes can influence layout. + */ +function updateInputGraph(inputGraph, layoutGraph) { + forEach(inputGraph.nodes(), function (v) { + var inputLabel = inputGraph.node(v); + var layoutLabel = layoutGraph.node(v); + + if (inputLabel) { + inputLabel.x = layoutLabel.x; + inputLabel.y = layoutLabel.y; + + if (layoutGraph.children(v).length) { + inputLabel.width = layoutLabel.width; + inputLabel.height = layoutLabel.height; + } + } + }); + + forEach(inputGraph.edges(), function (e) { + var inputLabel = inputGraph.edge(e); + var layoutLabel = layoutGraph.edge(e); + + inputLabel.points = layoutLabel.points; + if (has(layoutLabel, 'x')) { + inputLabel.x = layoutLabel.x; + inputLabel.y = layoutLabel.y; + } + }); + + inputGraph.graph().width = layoutGraph.graph().width; + inputGraph.graph().height = layoutGraph.graph().height; +} + +var graphNumAttrs = ['nodesep', 'edgesep', 'ranksep', 'marginx', 'marginy']; +var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: 'tb' }; +var graphAttrs = ['acyclicer', 'ranker', 'rankdir', 'align']; +var nodeNumAttrs = ['width', 'height']; +var nodeDefaults = { width: 0, height: 0 }; +var edgeNumAttrs = ['minlen', 'weight', 'width', 'height', 'labeloffset']; +var edgeDefaults = { + minlen: 1, + weight: 1, + width: 0, + height: 0, + labeloffset: 10, + labelpos: 'r', +}; +var edgeAttrs = ['labelpos']; + +/* + * Constructs a new graph from the input graph, which can be used for layout. + * This process copies only whitelisted attributes from the input graph to the + * layout graph. Thus this function serves as a good place to determine what + * attributes can influence layout. + */ +function buildLayoutGraph(inputGraph) { + var g = new Graph({ multigraph: true, compound: true }); + var graph = canonicalize(inputGraph.graph()); + + g.setGraph( + merge({}, graphDefaults, selectNumberAttrs(graph, graphNumAttrs), pick(graph, graphAttrs)) + ); + + forEach(inputGraph.nodes(), function (v) { + var node = canonicalize(inputGraph.node(v)); + g.setNode(v, defaults(selectNumberAttrs(node, nodeNumAttrs), nodeDefaults)); + g.setParent(v, inputGraph.parent(v)); + }); + + forEach(inputGraph.edges(), function (e) { + var edge = canonicalize(inputGraph.edge(e)); + g.setEdge( + e, + merge({}, edgeDefaults, selectNumberAttrs(edge, edgeNumAttrs), pick(edge, edgeAttrs)) + ); + }); + + return g; +} + +/* + * This idea comes from the Gansner paper: to account for edge labels in our + * layout we split each rank in half by doubling minlen and halving ranksep. + * Then we can place labels at these mid-points between nodes. + * + * We also add some minimal padding to the width to push the label for the edge + * away from the edge itself a bit. + */ +function makeSpaceForEdgeLabels(g) { + var graph = g.graph(); + graph.ranksep /= 2; + forEach(g.edges(), function (e) { + var edge = g.edge(e); + edge.minlen *= 2; + if (edge.labelpos.toLowerCase() !== 'c') { + if (graph.rankdir === 'TB' || graph.rankdir === 'BT') { + edge.width += edge.labeloffset; + } else { + edge.height += edge.labeloffset; + } + } + }); +} + +/* + * Creates temporary dummy nodes that capture the rank in which each edge's + * label is going to, if it has one of non-zero width and height. We do this + * so that we can safely remove empty ranks while preserving balance for the + * label's position. + */ +function injectEdgeLabelProxies(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.width && edge.height) { + var v = g.node(e.v); + var w = g.node(e.w); + var label = { rank: (w.rank - v.rank) / 2 + v.rank, e: e }; + addDummyNode(g, 'edge-proxy', label, '_ep'); + } + }); +} + +function assignRankMinMax(g) { + var maxRank = 0; + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.borderTop) { + node.minRank = g.node(node.borderTop).rank; + node.maxRank = g.node(node.borderBottom).rank; + // @ts-expect-error + maxRank = max(maxRank, node.maxRank); + } + }); + g.graph().maxRank = maxRank; +} + +function removeEdgeLabelProxies(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.dummy === 'edge-proxy') { + g.edge(node.e).labelRank = node.rank; + g.removeNode(v); + } + }); +} + +function translateGraph(g) { + var minX = Number.POSITIVE_INFINITY; + var maxX = 0; + var minY = Number.POSITIVE_INFINITY; + var maxY = 0; + var graphLabel = g.graph(); + var marginX = graphLabel.marginx || 0; + var marginY = graphLabel.marginy || 0; + + function getExtremes(attrs) { + var x = attrs.x; + var y = attrs.y; + var w = attrs.width; + var h = attrs.height; + minX = Math.min(minX, x - w / 2); + maxX = Math.max(maxX, x + w / 2); + minY = Math.min(minY, y - h / 2); + maxY = Math.max(maxY, y + h / 2); + } + + forEach(g.nodes(), function (v) { + getExtremes(g.node(v)); + }); + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (has(edge, 'x')) { + getExtremes(edge); + } + }); + + minX -= marginX; + minY -= marginY; + + forEach(g.nodes(), function (v) { + var node = g.node(v); + node.x -= minX; + node.y -= minY; + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, function (p) { + p.x -= minX; + p.y -= minY; + }); + if (has(edge, 'x')) { + edge.x -= minX; + } + if (has(edge, 'y')) { + edge.y -= minY; + } + }); + + graphLabel.width = maxX - minX + marginX; + graphLabel.height = maxY - minY + marginY; +} + +function assignNodeIntersects(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + var nodeV = g.node(e.v); + var nodeW = g.node(e.w); + var p1, p2; + if (!edge.points) { + edge.points = []; + p1 = nodeW; + p2 = nodeV; + } else { + p1 = edge.points[0]; + p2 = edge.points[edge.points.length - 1]; + } + edge.points.unshift(intersectRect(nodeV, p1)); + edge.points.push(intersectRect(nodeW, p2)); + }); +} + +function fixupEdgeLabelCoords(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (has(edge, 'x')) { + if (edge.labelpos === 'l' || edge.labelpos === 'r') { + edge.width -= edge.labeloffset; + } + switch (edge.labelpos) { + case 'l': + edge.x -= edge.width / 2 + edge.labeloffset; + break; + case 'r': + edge.x += edge.width / 2 + edge.labeloffset; + break; + } + } + }); +} + +function reversePointsForReversedEdges(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.reversed) { + edge.points.reverse(); + } + }); +} + +function removeBorderNodes(g) { + forEach(g.nodes(), function (v) { + if (g.children(v).length) { + var node = g.node(v); + var t = g.node(node.borderTop); + var b = g.node(node.borderBottom); + var l = g.node(last(node.borderLeft)); + var r = g.node(last(node.borderRight)); + + node.width = Math.abs(r.x - l.x); + node.height = Math.abs(b.y - t.y); + node.x = l.x + node.width / 2; + node.y = t.y + node.height / 2; + } + }); + + forEach(g.nodes(), function (v) { + if (g.node(v).dummy === 'border') { + g.removeNode(v); + } + }); +} + +function removeSelfEdges(g) { + forEach(g.edges(), function (e) { + if (e.v === e.w) { + var node = g.node(e.v); + if (!node.selfEdges) { + node.selfEdges = []; + } + node.selfEdges.push({ e: e, label: g.edge(e) }); + g.removeEdge(e); + } + }); +} + +function insertSelfEdges(g) { + var layers = buildLayerMatrix(g); + forEach(layers, function (layer) { + var orderShift = 0; + forEach(layer, function (v, i) { + var node = g.node(v); + node.order = i + orderShift; + forEach(node.selfEdges, function (selfEdge) { + addDummyNode( + g, + 'selfedge', + { + width: selfEdge.label.width, + height: selfEdge.label.height, + rank: node.rank, + order: i + ++orderShift, + e: selfEdge.e, + label: selfEdge.label, + }, + '_se' + ); + }); + delete node.selfEdges; + }); + }); +} + +function positionSelfEdges(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.dummy === 'selfedge') { + var selfNode = g.node(node.e.v); + var x = selfNode.x + selfNode.width / 2; + var y = selfNode.y; + var dx = node.x - x; + var dy = selfNode.height / 2; + g.setEdge(node.e, node.label); + g.removeNode(v); + node.label.points = [ + { x: x + (2 * dx) / 3, y: y - dy }, + { x: x + (5 * dx) / 6, y: y - dy }, + { x: x + dx, y: y }, + { x: x + (5 * dx) / 6, y: y + dy }, + { x: x + (2 * dx) / 3, y: y + dy }, + ]; + node.label.x = node.x; + node.label.y = node.y; + } + }); +} + +function selectNumberAttrs(obj, attrs) { + return mapValues(pick(obj, attrs), Number); +} + +function canonicalize(attrs) { + var newAttrs = {}; + forEach(attrs, function (v, k) { + newAttrs[k.toLowerCase()] = v; + }); + return newAttrs; +} + +export { defaults as d, layout as l, map as m, pick as p, range as r, uniqueId as u }; diff --git a/libs/marked/layout-BnytXFfq.js b/libs/marked/layout-BnytXFfq.js new file mode 100644 index 0000000..9497360 --- /dev/null +++ b/libs/marked/layout-BnytXFfq.js @@ -0,0 +1,3926 @@ +import { a as isSymbol, b as baseFlatten, c as baseClone, d as baseIteratee, k as keys, e as baseFindIndex, g as baseEach, j as arrayMap, l as castFunction, m as baseForOwn, n as castPath, t as toKey, o as baseGet, p as hasIn, q as toString, f as forEach, G as Graph, h as has, i as isUndefined, r as filter, v as values, s as reduce } from './graph-KZW2Npeo.js'; +import { a8 as isObject, a9 as setToString, aa as overRest, ab as baseRest, ac as isIterateeCall, ad as keysIn, ae as eq, af as isArrayLike, ag as isArray, ah as baseFor, ai as baseAssignValue, aj as identity, ak as isIndex, al as assignValue, am as baseUnary, an as constant, ao as merge } from './index-Bd_FDXSq.js'; + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); +} + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0, + MAX_INTEGER = 1.7976931348623157e+308; + +/** + * Converts `value` to a finite number. + * + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 + */ +function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; + } + value = toNumber(value); + if (value === INFINITY || value === -INFINITY) { + var sign = (value < 0 ? -1 : 1); + return sign * MAX_INTEGER; + } + return value === value ? value : 0; +} + +/** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ +function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + + return result === result ? (remainder ? result - remainder : result) : 0; +} + +/** + * Flattens `array` a single level deep. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. + * @example + * + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] + */ +function flatten(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array) : []; +} + +/** + * A specialized version of `baseRest` which flattens the rest array. + * + * @private + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. + */ +function flatRest(func) { + return setToString(overRest(func, undefined, flatten), func + ''); +} + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG = 1, + CLONE_SYMBOLS_FLAG = 4; + +/** + * This method is like `_.clone` except that it recursively clones `value`. + * + * @static + * @memberOf _ + * @since 1.0.0 + * @category Lang + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone + * @example + * + * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); + * // => false + */ +function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); +} + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep + * @example + * + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } + */ +var defaults = baseRest(function(object, sources) { + object = Object(object); + + var index = -1; + var length = sources.length; + var guard = length > 2 ? sources[2] : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + length = 1; + } + + while (++index < length) { + var source = sources[index]; + var props = keysIn(source); + var propsIndex = -1; + var propsLength = props.length; + + while (++propsIndex < propsLength) { + var key = props[propsIndex]; + var value = object[key]; + + if (value === undefined || + (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { + object[key] = source[key]; + } + } + } + + return object; +}); + +/** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ +function last(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; +} + +/** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ +function createFind(findIndexFunc) { + return function(collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = baseIteratee(predicate); + collection = keys(collection); + predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$1 = Math.max; + +/** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. + * + * @static + * @memberOf _ + * @since 1.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. + * @example + * + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; + * + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 + */ +function findIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax$1(length + index, 0); + } + return baseFindIndex(array, baseIteratee(predicate), index); +} + +/** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' + * + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' + */ +var find = createFind(findIndex); + +/** + * The base implementation of `_.map` without support for iteratee shorthands. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; + + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; +} + +/** + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + * @example + * + * function square(n) { + * return n * n; + * } + * + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ +function map(collection, iteratee) { + var func = isArray(collection) ? arrayMap : baseMap; + return func(collection, baseIteratee(iteratee)); +} + +/** + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + */ +function forIn(object, iteratee) { + return object == null + ? object + : baseFor(object, castFunction(iteratee), keysIn); +} + +/** + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. + * + * @static + * @memberOf _ + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). + */ +function forOwn(object, iteratee) { + return object && baseForOwn(object, castFunction(iteratee)); +} + +/** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ +function baseGt(value, other) { + return value > other; +} + +/** + * The base implementation of `_.lt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is less than `other`, + * else `false`. + */ +function baseLt(value, other) { + return value < other; +} + +/** + * Creates an object with the same keys as `object` and values generated + * by running each own enumerable string keyed property of `object` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, key, object). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns the new mapped object. + * @see _.mapKeys + * @example + * + * var users = { + * 'fred': { 'user': 'fred', 'age': 40 }, + * 'pebbles': { 'user': 'pebbles', 'age': 1 } + * }; + * + * _.mapValues(users, function(o) { return o.age; }); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * + * // The `_.property` iteratee shorthand. + * _.mapValues(users, 'age'); + * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + */ +function mapValues(object, iteratee) { + var result = {}; + iteratee = baseIteratee(iteratee); + + baseForOwn(object, function(value, key, object) { + baseAssignValue(result, key, iteratee(value, key, object)); + }); + return result; +} + +/** + * The base implementation of methods like `_.max` and `_.min` which accepts a + * `comparator` to determine the extremum value. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The iteratee invoked per iteration. + * @param {Function} comparator The comparator used to compare values. + * @returns {*} Returns the extremum value. + */ +function baseExtremum(array, iteratee, comparator) { + var index = -1, + length = array.length; + + while (++index < length) { + var value = array[index], + current = iteratee(value); + + if (current != null && (computed === undefined + ? (current === current && !isSymbol(current)) + : comparator(current, computed) + )) { + var computed = current, + result = value; + } + } + return result; +} + +/** + * Computes the maximum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * _.max([]); + * // => undefined + */ +function max(array) { + return (array && array.length) + ? baseExtremum(array, identity, baseGt) + : undefined; +} + +/** + * Computes the minimum value of `array`. If `array` is empty or falsey, + * `undefined` is returned. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Math + * @param {Array} array The array to iterate over. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * _.min([]); + * // => undefined + */ +function min(array) { + return (array && array.length) + ? baseExtremum(array, identity, baseLt) + : undefined; +} + +/** + * This method is like `_.min` except that it accepts `iteratee` which is + * invoked for each element in `array` to generate the criterion by which + * the value is ranked. The iteratee is invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Math + * @param {Array} array The array to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {*} Returns the minimum value. + * @example + * + * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * + * _.minBy(objects, function(o) { return o.n; }); + * // => { 'n': 1 } + * + * // The `_.property` iteratee shorthand. + * _.minBy(objects, 'n'); + * // => { 'n': 1 } + */ +function minBy(array, iteratee) { + return (array && array.length) + ? baseExtremum(array, baseIteratee(iteratee), baseLt) + : undefined; +} + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +/** + * The base implementation of `_.pickBy` without support for iteratee shorthands. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @param {Function} predicate The function invoked per property. + * @returns {Object} Returns the new object. + */ +function basePickBy(object, paths, predicate) { + var index = -1, + length = paths.length, + result = {}; + + while (++index < length) { + var path = paths[index], + value = baseGet(object, path); + + if (predicate(value, path)) { + baseSet(result, castPath(path, object), value); + } + } + return result; +} + +/** + * The base implementation of `_.sortBy` which uses `comparer` to define the + * sort order of `array` and replaces criteria objects with their corresponding + * values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ +function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; +} + +/** + * Compares values to sort them in ascending order. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {number} Returns the sort order indicator for `value`. + */ +function compareAscending(value, other) { + if (value !== other) { + var valIsDefined = value !== undefined, + valIsNull = value === null, + valIsReflexive = value === value, + valIsSymbol = isSymbol(value); + + var othIsDefined = other !== undefined, + othIsNull = other === null, + othIsReflexive = other === other, + othIsSymbol = isSymbol(other); + + if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || + (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || + (valIsNull && othIsDefined && othIsReflexive) || + (!valIsDefined && othIsReflexive) || + !valIsReflexive) { + return 1; + } + if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || + (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || + (othIsNull && valIsDefined && valIsReflexive) || + (!othIsDefined && valIsReflexive) || + !othIsReflexive) { + return -1; + } + } + return 0; +} + +/** + * Used by `_.orderBy` to compare multiple properties of a value to another + * and stable sort them. + * + * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, + * specify an order of "desc" for descending or "asc" for ascending sort order + * of corresponding values. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {boolean[]|string[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ +function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length, + ordersLength = orders.length; + + while (++index < length) { + var result = compareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (index >= ordersLength) { + return result; + } + var order = orders[index]; + return result * (order == 'desc' ? -1 : 1); + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; +} + +/** + * The base implementation of `_.orderBy` without param guards. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. + * @param {string[]} orders The sort orders of `iteratees`. + * @returns {Array} Returns the new sorted array. + */ +function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; + } + + var index = -1; + iteratees = arrayMap(iteratees, baseUnary(baseIteratee)); + + var result = baseMap(collection, function(value, key, collection) { + var criteria = arrayMap(iteratees, function(iteratee) { + return iteratee(value); + }); + return { 'criteria': criteria, 'index': ++index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); +} + +/** + * The base implementation of `_.pick` without support for individual + * property identifiers. + * + * @private + * @param {Object} object The source object. + * @param {string[]} paths The property paths to pick. + * @returns {Object} Returns the new object. + */ +function basePick(object, paths) { + return basePickBy(object, paths, function(value, path) { + return hasIn(object, path); + }); +} + +/** + * Creates an object composed of the picked `object` properties. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The source object. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Object} Returns the new object. + * @example + * + * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * + * _.pick(object, ['a', 'c']); + * // => { 'a': 1, 'c': 3 } + */ +var pick = flatRest(function(object, paths) { + return object == null ? {} : basePick(object, paths); +}); + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil, + nativeMax = Math.max; + +/** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ +function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[++index] = start; + start += step; + } + return result; +} + +/** + * Creates a `_.range` or `_.rangeRight` function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new range function. + */ +function createRange(fromRight) { + return function(start, end, step) { + if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { + end = step = undefined; + } + // Ensure the sign of `-0` is preserved. + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); + return baseRange(start, end, step); + }; +} + +/** + * Creates an array of numbers (positive and/or negative) progressing from + * `start` up to, but not including, `end`. A step of `-1` is used if a negative + * `start` is specified without an `end` or `step`. If `end` is not specified, + * it's set to `start` with `start` then set to `0`. + * + * **Note:** JavaScript follows the IEEE-754 standard for resolving + * floating-point values which can produce unexpected results. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @param {number} [step=1] The value to increment or decrement by. + * @returns {Array} Returns the range of numbers. + * @see _.inRange, _.rangeRight + * @example + * + * _.range(4); + * // => [0, 1, 2, 3] + * + * _.range(-4); + * // => [0, -1, -2, -3] + * + * _.range(1, 5); + * // => [1, 2, 3, 4] + * + * _.range(0, 20, 5); + * // => [0, 5, 10, 15] + * + * _.range(0, -4, -1); + * // => [0, -1, -2, -3] + * + * _.range(1, 4, 0); + * // => [1, 1, 1] + * + * _.range(0); + * // => [] + */ +var range = createRange(); + +/** + * Creates an array of elements, sorted in ascending order by the results of + * running each element in a collection thru each iteratee. This method + * performs a stable sort, that is, it preserves the original sort order of + * equal elements. The iteratees are invoked with one argument: (value). + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {...(Function|Function[])} [iteratees=[_.identity]] + * The iteratees to sort by. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'fred', 'age': 48 }, + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 30 }, + * { 'user': 'barney', 'age': 34 } + * ]; + * + * _.sortBy(users, [function(o) { return o.user; }]); + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] + * + * _.sortBy(users, ['user', 'age']); + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] + */ +var sortBy = baseRest(function(collection, iteratees) { + if (collection == null) { + return []; + } + var length = iteratees.length; + if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { + iteratees = []; + } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { + iteratees = [iteratees[0]]; + } + return baseOrderBy(collection, baseFlatten(iteratees), []); +}); + +/** Used to generate unique IDs. */ +var idCounter = 0; + +/** + * Generates a unique ID. If `prefix` is given, the ID is appended to it. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {string} [prefix=''] The value to prefix the ID with. + * @returns {string} Returns the unique ID. + * @example + * + * _.uniqueId('contact_'); + * // => 'contact_104' + * + * _.uniqueId(); + * // => '105' + */ +function uniqueId(prefix) { + var id = ++idCounter; + return toString(prefix) + id; +} + +/** + * This base implementation of `_.zipObject` which assigns values using `assignFunc`. + * + * @private + * @param {Array} props The property identifiers. + * @param {Array} values The property values. + * @param {Function} assignFunc The function to assign values. + * @returns {Object} Returns the new object. + */ +function baseZipObject(props, values, assignFunc) { + var index = -1, + length = props.length, + valsLength = values.length, + result = {}; + + while (++index < length) { + var value = index < valsLength ? values[index] : undefined; + assignFunc(result, props[index], value); + } + return result; +} + +/** + * This method is like `_.fromPairs` except that it accepts two arrays, + * one of property identifiers and one of corresponding values. + * + * @static + * @memberOf _ + * @since 0.4.0 + * @category Array + * @param {Array} [props=[]] The property identifiers. + * @param {Array} [values=[]] The property values. + * @returns {Object} Returns the new object. + * @example + * + * _.zipObject(['a', 'b'], [1, 2]); + * // => { 'a': 1, 'b': 2 } + */ +function zipObject(props, values) { + return baseZipObject(props || [], values || [], assignValue); +} + +/* + * Simple doubly linked list implementation derived from Cormen, et al., + * "Introduction to Algorithms". + */ + + +class List { + constructor() { + var sentinel = {}; + sentinel._next = sentinel._prev = sentinel; + this._sentinel = sentinel; + } + dequeue() { + var sentinel = this._sentinel; + var entry = sentinel._prev; + if (entry !== sentinel) { + unlink(entry); + return entry; + } + } + enqueue(entry) { + var sentinel = this._sentinel; + if (entry._prev && entry._next) { + unlink(entry); + } + entry._next = sentinel._next; + sentinel._next._prev = entry; + sentinel._next = entry; + entry._prev = sentinel; + } + toString() { + var strs = []; + var sentinel = this._sentinel; + var curr = sentinel._prev; + while (curr !== sentinel) { + strs.push(JSON.stringify(curr, filterOutLinks)); + curr = curr._prev; + } + return '[' + strs.join(', ') + ']'; + } +} + +function unlink(entry) { + entry._prev._next = entry._next; + entry._next._prev = entry._prev; + delete entry._next; + delete entry._prev; +} + +function filterOutLinks(k, v) { + if (k !== '_next' && k !== '_prev') { + return v; + } +} + +var DEFAULT_WEIGHT_FN = constant(1); + +function greedyFAS(g, weightFn) { + if (g.nodeCount() <= 1) { + return []; + } + var state = buildState(g, weightFn || DEFAULT_WEIGHT_FN); + var results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx); + + // Expand multi-edges + return flatten( + map(results, function (e) { + return g.outEdges(e.v, e.w); + }) + ); +} + +function doGreedyFAS(g, buckets, zeroIdx) { + var results = []; + var sources = buckets[buckets.length - 1]; + var sinks = buckets[0]; + + var entry; + while (g.nodeCount()) { + while ((entry = sinks.dequeue())) { + removeNode(g, buckets, zeroIdx, entry); + } + while ((entry = sources.dequeue())) { + removeNode(g, buckets, zeroIdx, entry); + } + if (g.nodeCount()) { + for (var i = buckets.length - 2; i > 0; --i) { + entry = buckets[i].dequeue(); + if (entry) { + results = results.concat(removeNode(g, buckets, zeroIdx, entry, true)); + break; + } + } + } + } + + return results; +} + +function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) { + var results = collectPredecessors ? [] : undefined; + + forEach(g.inEdges(entry.v), function (edge) { + var weight = g.edge(edge); + var uEntry = g.node(edge.v); + + if (collectPredecessors) { + results.push({ v: edge.v, w: edge.w }); + } + + uEntry.out -= weight; + assignBucket(buckets, zeroIdx, uEntry); + }); + + forEach(g.outEdges(entry.v), function (edge) { + var weight = g.edge(edge); + var w = edge.w; + var wEntry = g.node(w); + wEntry['in'] -= weight; + assignBucket(buckets, zeroIdx, wEntry); + }); + + g.removeNode(entry.v); + + return results; +} + +function buildState(g, weightFn) { + var fasGraph = new Graph(); + var maxIn = 0; + var maxOut = 0; + + forEach(g.nodes(), function (v) { + fasGraph.setNode(v, { v: v, in: 0, out: 0 }); + }); + + // Aggregate weights on nodes, but also sum the weights across multi-edges + // into a single edge for the fasGraph. + forEach(g.edges(), function (e) { + var prevWeight = fasGraph.edge(e.v, e.w) || 0; + var weight = weightFn(e); + var edgeWeight = prevWeight + weight; + fasGraph.setEdge(e.v, e.w, edgeWeight); + maxOut = Math.max(maxOut, (fasGraph.node(e.v).out += weight)); + maxIn = Math.max(maxIn, (fasGraph.node(e.w)['in'] += weight)); + }); + + var buckets = range(maxOut + maxIn + 3).map(function () { + return new List(); + }); + var zeroIdx = maxIn + 1; + + forEach(fasGraph.nodes(), function (v) { + assignBucket(buckets, zeroIdx, fasGraph.node(v)); + }); + + return { graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx }; +} + +function assignBucket(buckets, zeroIdx, entry) { + if (!entry.out) { + buckets[0].enqueue(entry); + } else if (!entry['in']) { + buckets[buckets.length - 1].enqueue(entry); + } else { + buckets[entry.out - entry['in'] + zeroIdx].enqueue(entry); + } +} + +function run$2(g) { + var fas = g.graph().acyclicer === 'greedy' ? greedyFAS(g, weightFn(g)) : dfsFAS(g); + forEach(fas, function (e) { + var label = g.edge(e); + g.removeEdge(e); + label.forwardName = e.name; + label.reversed = true; + g.setEdge(e.w, e.v, label, uniqueId('rev')); + }); + + function weightFn(g) { + return function (e) { + return g.edge(e).weight; + }; + } +} + +function dfsFAS(g) { + var fas = []; + var stack = {}; + var visited = {}; + + function dfs(v) { + if (has(visited, v)) { + return; + } + visited[v] = true; + stack[v] = true; + forEach(g.outEdges(v), function (e) { + if (has(stack, e.w)) { + fas.push(e); + } else { + dfs(e.w); + } + }); + delete stack[v]; + } + + forEach(g.nodes(), dfs); + return fas; +} + +function undo$2(g) { + forEach(g.edges(), function (e) { + var label = g.edge(e); + if (label.reversed) { + g.removeEdge(e); + + var forwardName = label.forwardName; + delete label.reversed; + delete label.forwardName; + g.setEdge(e.w, e.v, label, forwardName); + } + }); +} + +/* + * Adds a dummy node to the graph and return v. + */ +function addDummyNode(g, type, attrs, name) { + var v; + do { + v = uniqueId(name); + } while (g.hasNode(v)); + + attrs.dummy = type; + g.setNode(v, attrs); + return v; +} + +/* + * Returns a new graph with only simple edges. Handles aggregation of data + * associated with multi-edges. + */ +function simplify(g) { + var simplified = new Graph().setGraph(g.graph()); + forEach(g.nodes(), function (v) { + simplified.setNode(v, g.node(v)); + }); + forEach(g.edges(), function (e) { + var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 }; + var label = g.edge(e); + simplified.setEdge(e.v, e.w, { + weight: simpleLabel.weight + label.weight, + minlen: Math.max(simpleLabel.minlen, label.minlen), + }); + }); + return simplified; +} + +function asNonCompoundGraph(g) { + var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph()); + forEach(g.nodes(), function (v) { + if (!g.children(v).length) { + simplified.setNode(v, g.node(v)); + } + }); + forEach(g.edges(), function (e) { + simplified.setEdge(e, g.edge(e)); + }); + return simplified; +} + +/* + * Finds where a line starting at point ({x, y}) would intersect a rectangle + * ({x, y, width, height}) if it were pointing at the rectangle's center. + */ +function intersectRect(rect, point) { + var x = rect.x; + var y = rect.y; + + // Rectangle intersection algorithm from: + // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes + var dx = point.x - x; + var dy = point.y - y; + var w = rect.width / 2; + var h = rect.height / 2; + + if (!dx && !dy) { + throw new Error('Not possible to find intersection inside of the rectangle'); + } + + var sx, sy; + if (Math.abs(dy) * w > Math.abs(dx) * h) { + // Intersection is top or bottom of rect. + if (dy < 0) { + h = -h; + } + sx = (h * dx) / dy; + sy = h; + } else { + // Intersection is left or right of rect. + if (dx < 0) { + w = -w; + } + sx = w; + sy = (w * dy) / dx; + } + + return { x: x + sx, y: y + sy }; +} + +/* + * Given a DAG with each node assigned "rank" and "order" properties, this + * function will produce a matrix with the ids of each node. + */ +function buildLayerMatrix(g) { + var layering = map(range(maxRank(g) + 1), function () { + return []; + }); + forEach(g.nodes(), function (v) { + var node = g.node(v); + var rank = node.rank; + if (!isUndefined(rank)) { + layering[rank][node.order] = v; + } + }); + return layering; +} + +/* + * Adjusts the ranks for all nodes in the graph such that all nodes v have + * rank(v) >= 0 and at least one node w has rank(w) = 0. + */ +function normalizeRanks(g) { + var min$1 = min( + map(g.nodes(), function (v) { + return g.node(v).rank; + }) + ); + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (has(node, 'rank')) { + node.rank -= min$1; + } + }); +} + +function removeEmptyRanks(g) { + // Ranks may not start at 0, so we need to offset them + var offset = min( + map(g.nodes(), function (v) { + return g.node(v).rank; + }) + ); + + var layers = []; + forEach(g.nodes(), function (v) { + var rank = g.node(v).rank - offset; + if (!layers[rank]) { + layers[rank] = []; + } + layers[rank].push(v); + }); + + var delta = 0; + var nodeRankFactor = g.graph().nodeRankFactor; + forEach(layers, function (vs, i) { + if (isUndefined(vs) && i % nodeRankFactor !== 0) { + --delta; + } else if (delta) { + forEach(vs, function (v) { + g.node(v).rank += delta; + }); + } + }); +} + +function addBorderNode$1(g, prefix, rank, order) { + var node = { + width: 0, + height: 0, + }; + if (arguments.length >= 4) { + node.rank = rank; + node.order = order; + } + return addDummyNode(g, 'border', node, prefix); +} + +function maxRank(g) { + return max( + map(g.nodes(), function (v) { + var rank = g.node(v).rank; + if (!isUndefined(rank)) { + return rank; + } + }) + ); +} + +/* + * Partition a collection into two groups: `lhs` and `rhs`. If the supplied + * function returns true for an entry it goes into `lhs`. Otherwise it goes + * into `rhs. + */ +function partition(collection, fn) { + var result = { lhs: [], rhs: [] }; + forEach(collection, function (value) { + if (fn(value)) { + result.lhs.push(value); + } else { + result.rhs.push(value); + } + }); + return result; +} + +function notime(name, fn) { + return fn(); +} + +function addBorderSegments(g) { + function dfs(v) { + var children = g.children(v); + var node = g.node(v); + if (children.length) { + forEach(children, dfs); + } + + if (has(node, 'minRank')) { + node.borderLeft = []; + node.borderRight = []; + for (var rank = node.minRank, maxRank = node.maxRank + 1; rank < maxRank; ++rank) { + addBorderNode(g, 'borderLeft', '_bl', v, node, rank); + addBorderNode(g, 'borderRight', '_br', v, node, rank); + } + } + } + + forEach(g.children(), dfs); +} + +function addBorderNode(g, prop, prefix, sg, sgNode, rank) { + var label = { width: 0, height: 0, rank: rank, borderType: prop }; + var prev = sgNode[prop][rank - 1]; + var curr = addDummyNode(g, 'border', label, prefix); + sgNode[prop][rank] = curr; + g.setParent(curr, sg); + if (prev) { + g.setEdge(prev, curr, { weight: 1 }); + } +} + +function adjust(g) { + var rankDir = g.graph().rankdir.toLowerCase(); + if (rankDir === 'lr' || rankDir === 'rl') { + swapWidthHeight(g); + } +} + +function undo$1(g) { + var rankDir = g.graph().rankdir.toLowerCase(); + if (rankDir === 'bt' || rankDir === 'rl') { + reverseY(g); + } + + if (rankDir === 'lr' || rankDir === 'rl') { + swapXY(g); + swapWidthHeight(g); + } +} + +function swapWidthHeight(g) { + forEach(g.nodes(), function (v) { + swapWidthHeightOne(g.node(v)); + }); + forEach(g.edges(), function (e) { + swapWidthHeightOne(g.edge(e)); + }); +} + +function swapWidthHeightOne(attrs) { + var w = attrs.width; + attrs.width = attrs.height; + attrs.height = w; +} + +function reverseY(g) { + forEach(g.nodes(), function (v) { + reverseYOne(g.node(v)); + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, reverseYOne); + if (has(edge, 'y')) { + reverseYOne(edge); + } + }); +} + +function reverseYOne(attrs) { + attrs.y = -attrs.y; +} + +function swapXY(g) { + forEach(g.nodes(), function (v) { + swapXYOne(g.node(v)); + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, swapXYOne); + if (has(edge, 'x')) { + swapXYOne(edge); + } + }); +} + +function swapXYOne(attrs) { + var x = attrs.x; + attrs.x = attrs.y; + attrs.y = x; +} + +/* + * Breaks any long edges in the graph into short segments that span 1 layer + * each. This operation is undoable with the denormalize function. + * + * Pre-conditions: + * + * 1. The input graph is a DAG. + * 2. Each node in the graph has a "rank" property. + * + * Post-condition: + * + * 1. All edges in the graph have a length of 1. + * 2. Dummy nodes are added where edges have been split into segments. + * 3. The graph is augmented with a "dummyChains" attribute which contains + * the first dummy in each chain of dummy nodes produced. + */ +function run$1(g) { + g.graph().dummyChains = []; + forEach(g.edges(), function (edge) { + normalizeEdge(g, edge); + }); +} + +function normalizeEdge(g, e) { + var v = e.v; + var vRank = g.node(v).rank; + var w = e.w; + var wRank = g.node(w).rank; + var name = e.name; + var edgeLabel = g.edge(e); + var labelRank = edgeLabel.labelRank; + + if (wRank === vRank + 1) return; + + g.removeEdge(e); + + var dummy, attrs, i; + for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) { + edgeLabel.points = []; + attrs = { + width: 0, + height: 0, + edgeLabel: edgeLabel, + edgeObj: e, + rank: vRank, + }; + dummy = addDummyNode(g, 'edge', attrs, '_d'); + if (vRank === labelRank) { + attrs.width = edgeLabel.width; + attrs.height = edgeLabel.height; + // @ts-expect-error + attrs.dummy = 'edge-label'; + // @ts-expect-error + attrs.labelpos = edgeLabel.labelpos; + } + g.setEdge(v, dummy, { weight: edgeLabel.weight }, name); + if (i === 0) { + g.graph().dummyChains.push(dummy); + } + v = dummy; + } + + g.setEdge(v, w, { weight: edgeLabel.weight }, name); +} + +function undo(g) { + forEach(g.graph().dummyChains, function (v) { + var node = g.node(v); + var origLabel = node.edgeLabel; + var w; + g.setEdge(node.edgeObj, origLabel); + while (node.dummy) { + w = g.successors(v)[0]; + g.removeNode(v); + origLabel.points.push({ x: node.x, y: node.y }); + if (node.dummy === 'edge-label') { + origLabel.x = node.x; + origLabel.y = node.y; + origLabel.width = node.width; + origLabel.height = node.height; + } + v = w; + node = g.node(v); + } + }); +} + +/* + * Initializes ranks for the input graph using the longest path algorithm. This + * algorithm scales well and is fast in practice, it yields rather poor + * solutions. Nodes are pushed to the lowest layer possible, leaving the bottom + * ranks wide and leaving edges longer than necessary. However, due to its + * speed, this algorithm is good for getting an initial ranking that can be fed + * into other algorithms. + * + * This algorithm does not normalize layers because it will be used by other + * algorithms in most cases. If using this algorithm directly, be sure to + * run normalize at the end. + * + * Pre-conditions: + * + * 1. Input graph is a DAG. + * 2. Input graph node labels can be assigned properties. + * + * Post-conditions: + * + * 1. Each node will be assign an (unnormalized) "rank" property. + */ +function longestPath(g) { + var visited = {}; + + function dfs(v) { + var label = g.node(v); + if (has(visited, v)) { + return label.rank; + } + visited[v] = true; + + var rank = min( + map(g.outEdges(v), function (e) { + return dfs(e.w) - g.edge(e).minlen; + }) + ); + + if ( + rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3 + rank === undefined || // return value of _.map([]) for Lodash 4 + rank === null + ) { + // return value of _.map([null]) + rank = 0; + } + + return (label.rank = rank); + } + + forEach(g.sources(), dfs); +} + +/* + * Returns the amount of slack for the given edge. The slack is defined as the + * difference between the length of the edge and its minimum length. + */ +function slack(g, e) { + return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen; +} + +/* + * Constructs a spanning tree with tight edges and adjusted the input node's + * ranks to achieve this. A tight edge is one that is has a length that matches + * its "minlen" attribute. + * + * The basic structure for this function is derived from Gansner, et al., "A + * Technique for Drawing Directed Graphs." + * + * Pre-conditions: + * + * 1. Graph must be a DAG. + * 2. Graph must be connected. + * 3. Graph must have at least one node. + * 5. Graph nodes must have been previously assigned a "rank" property that + * respects the "minlen" property of incident edges. + * 6. Graph edges must have a "minlen" property. + * + * Post-conditions: + * + * - Graph nodes will have their rank adjusted to ensure that all edges are + * tight. + * + * Returns a tree (undirected graph) that is constructed using only "tight" + * edges. + */ +function feasibleTree(g) { + var t = new Graph({ directed: false }); + + // Choose arbitrary node from which to start our tree + var start = g.nodes()[0]; + var size = g.nodeCount(); + t.setNode(start, {}); + + var edge, delta; + while (tightTree(t, g) < size) { + edge = findMinSlackEdge(t, g); + delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); + shiftRanks(t, g, delta); + } + + return t; +} + +/* + * Finds a maximal tree of tight edges and returns the number of nodes in the + * tree. + */ +function tightTree(t, g) { + function dfs(v) { + forEach(g.nodeEdges(v), function (e) { + var edgeV = e.v, + w = v === edgeV ? e.w : edgeV; + if (!t.hasNode(w) && !slack(g, e)) { + t.setNode(w, {}); + t.setEdge(v, w, {}); + dfs(w); + } + }); + } + + forEach(t.nodes(), dfs); + return t.nodeCount(); +} + +/* + * Finds the edge with the smallest slack that is incident on tree and returns + * it. + */ +function findMinSlackEdge(t, g) { + return minBy(g.edges(), function (e) { + if (t.hasNode(e.v) !== t.hasNode(e.w)) { + return slack(g, e); + } + }); +} + +function shiftRanks(t, g, delta) { + forEach(t.nodes(), function (v) { + g.node(v).rank += delta; + }); +} + +function CycleException() {} +CycleException.prototype = new Error(); // must be an instance of Error to pass testing + +/* + * A helper that preforms a pre- or post-order traversal on the input graph + * and returns the nodes in the order they were visited. If the graph is + * undirected then this algorithm will navigate using neighbors. If the graph + * is directed then this algorithm will navigate using successors. + * + * Order must be one of "pre" or "post". + */ +function dfs$1(g, vs, order) { + if (!isArray(vs)) { + vs = [vs]; + } + + var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g); + + var acc = []; + var visited = {}; + forEach(vs, function (v) { + if (!g.hasNode(v)) { + throw new Error('Graph does not have node: ' + v); + } + + doDfs(g, v, order === 'post', visited, navigation, acc); + }); + return acc; +} + +function doDfs(g, v, postorder, visited, navigation, acc) { + if (!has(visited, v)) { + visited[v] = true; + + if (!postorder) { + acc.push(v); + } + forEach(navigation(v), function (w) { + doDfs(g, w, postorder, visited, navigation, acc); + }); + if (postorder) { + acc.push(v); + } + } +} + +function postorder$1(g, vs) { + return dfs$1(g, vs, 'post'); +} + +function preorder(g, vs) { + return dfs$1(g, vs, 'pre'); +} + +// Expose some internals for testing purposes +networkSimplex.initLowLimValues = initLowLimValues; +networkSimplex.initCutValues = initCutValues; +networkSimplex.calcCutValue = calcCutValue; +networkSimplex.leaveEdge = leaveEdge; +networkSimplex.enterEdge = enterEdge; +networkSimplex.exchangeEdges = exchangeEdges; + +/* + * The network simplex algorithm assigns ranks to each node in the input graph + * and iteratively improves the ranking to reduce the length of edges. + * + * Preconditions: + * + * 1. The input graph must be a DAG. + * 2. All nodes in the graph must have an object value. + * 3. All edges in the graph must have "minlen" and "weight" attributes. + * + * Postconditions: + * + * 1. All nodes in the graph will have an assigned "rank" attribute that has + * been optimized by the network simplex algorithm. Ranks start at 0. + * + * + * A rough sketch of the algorithm is as follows: + * + * 1. Assign initial ranks to each node. We use the longest path algorithm, + * which assigns ranks to the lowest position possible. In general this + * leads to very wide bottom ranks and unnecessarily long edges. + * 2. Construct a feasible tight tree. A tight tree is one such that all + * edges in the tree have no slack (difference between length of edge + * and minlen for the edge). This by itself greatly improves the assigned + * rankings by shorting edges. + * 3. Iteratively find edges that have negative cut values. Generally a + * negative cut value indicates that the edge could be removed and a new + * tree edge could be added to produce a more compact graph. + * + * Much of the algorithms here are derived from Gansner, et al., "A Technique + * for Drawing Directed Graphs." The structure of the file roughly follows the + * structure of the overall algorithm. + */ +function networkSimplex(g) { + g = simplify(g); + longestPath(g); + var t = feasibleTree(g); + initLowLimValues(t); + initCutValues(t, g); + + var e, f; + while ((e = leaveEdge(t))) { + f = enterEdge(t, g, e); + exchangeEdges(t, g, e, f); + } +} + +/* + * Initializes cut values for all edges in the tree. + */ +function initCutValues(t, g) { + var vs = postorder$1(t, t.nodes()); + vs = vs.slice(0, vs.length - 1); + forEach(vs, function (v) { + assignCutValue(t, g, v); + }); +} + +function assignCutValue(t, g, child) { + var childLab = t.node(child); + var parent = childLab.parent; + t.edge(child, parent).cutvalue = calcCutValue(t, g, child); +} + +/* + * Given the tight tree, its graph, and a child in the graph calculate and + * return the cut value for the edge between the child and its parent. + */ +function calcCutValue(t, g, child) { + var childLab = t.node(child); + var parent = childLab.parent; + // True if the child is on the tail end of the edge in the directed graph + var childIsTail = true; + // The graph's view of the tree edge we're inspecting + var graphEdge = g.edge(child, parent); + // The accumulated cut value for the edge between this node and its parent + var cutValue = 0; + + if (!graphEdge) { + childIsTail = false; + graphEdge = g.edge(parent, child); + } + + cutValue = graphEdge.weight; + + forEach(g.nodeEdges(child), function (e) { + var isOutEdge = e.v === child, + other = isOutEdge ? e.w : e.v; + + if (other !== parent) { + var pointsToHead = isOutEdge === childIsTail, + otherWeight = g.edge(e).weight; + + cutValue += pointsToHead ? otherWeight : -otherWeight; + if (isTreeEdge(t, child, other)) { + var otherCutValue = t.edge(child, other).cutvalue; + cutValue += pointsToHead ? -otherCutValue : otherCutValue; + } + } + }); + + return cutValue; +} + +function initLowLimValues(tree, root) { + if (arguments.length < 2) { + root = tree.nodes()[0]; + } + dfsAssignLowLim(tree, {}, 1, root); +} + +function dfsAssignLowLim(tree, visited, nextLim, v, parent) { + var low = nextLim; + var label = tree.node(v); + + visited[v] = true; + forEach(tree.neighbors(v), function (w) { + if (!has(visited, w)) { + nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v); + } + }); + + label.low = low; + label.lim = nextLim++; + if (parent) { + label.parent = parent; + } else { + // TODO should be able to remove this when we incrementally update low lim + delete label.parent; + } + + return nextLim; +} + +function leaveEdge(tree) { + return find(tree.edges(), function (e) { + return tree.edge(e).cutvalue < 0; + }); +} + +function enterEdge(t, g, edge) { + var v = edge.v; + var w = edge.w; + + // For the rest of this function we assume that v is the tail and w is the + // head, so if we don't have this edge in the graph we should flip it to + // match the correct orientation. + if (!g.hasEdge(v, w)) { + v = edge.w; + w = edge.v; + } + + var vLabel = t.node(v); + var wLabel = t.node(w); + var tailLabel = vLabel; + var flip = false; + + // If the root is in the tail of the edge then we need to flip the logic that + // checks for the head and tail nodes in the candidates function below. + if (vLabel.lim > wLabel.lim) { + tailLabel = wLabel; + flip = true; + } + + var candidates = filter(g.edges(), function (edge) { + return ( + flip === isDescendant(t, t.node(edge.v), tailLabel) && + flip !== isDescendant(t, t.node(edge.w), tailLabel) + ); + }); + + return minBy(candidates, function (edge) { + return slack(g, edge); + }); +} + +function exchangeEdges(t, g, e, f) { + var v = e.v; + var w = e.w; + t.removeEdge(v, w); + t.setEdge(f.v, f.w, {}); + initLowLimValues(t); + initCutValues(t, g); + updateRanks(t, g); +} + +function updateRanks(t, g) { + var root = find(t.nodes(), function (v) { + return !g.node(v).parent; + }); + var vs = preorder(t, root); + vs = vs.slice(1); + forEach(vs, function (v) { + var parent = t.node(v).parent, + edge = g.edge(v, parent), + flipped = false; + + if (!edge) { + edge = g.edge(parent, v); + flipped = true; + } + + g.node(v).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen); + }); +} + +/* + * Returns true if the edge is in the tree. + */ +function isTreeEdge(tree, u, v) { + return tree.hasEdge(u, v); +} + +/* + * Returns true if the specified node is descendant of the root node per the + * assigned low and lim attributes in the tree. + */ +function isDescendant(tree, vLabel, rootLabel) { + return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim; +} + +/* + * Assigns a rank to each node in the input graph that respects the "minlen" + * constraint specified on edges between nodes. + * + * This basic structure is derived from Gansner, et al., "A Technique for + * Drawing Directed Graphs." + * + * Pre-conditions: + * + * 1. Graph must be a connected DAG + * 2. Graph nodes must be objects + * 3. Graph edges must have "weight" and "minlen" attributes + * + * Post-conditions: + * + * 1. Graph nodes will have a "rank" attribute based on the results of the + * algorithm. Ranks can start at any index (including negative), we'll + * fix them up later. + */ +function rank(g) { + switch (g.graph().ranker) { + case 'network-simplex': + networkSimplexRanker(g); + break; + case 'tight-tree': + tightTreeRanker(g); + break; + case 'longest-path': + longestPathRanker(g); + break; + default: + networkSimplexRanker(g); + } +} + +// A fast and simple ranker, but results are far from optimal. +var longestPathRanker = longestPath; + +function tightTreeRanker(g) { + longestPath(g); + feasibleTree(g); +} + +function networkSimplexRanker(g) { + networkSimplex(g); +} + +/* + * A nesting graph creates dummy nodes for the tops and bottoms of subgraphs, + * adds appropriate edges to ensure that all cluster nodes are placed between + * these boundries, and ensures that the graph is connected. + * + * In addition we ensure, through the use of the minlen property, that nodes + * and subgraph border nodes to not end up on the same rank. + * + * Preconditions: + * + * 1. Input graph is a DAG + * 2. Nodes in the input graph has a minlen attribute + * + * Postconditions: + * + * 1. Input graph is connected. + * 2. Dummy nodes are added for the tops and bottoms of subgraphs. + * 3. The minlen attribute for nodes is adjusted to ensure nodes do not + * get placed on the same rank as subgraph border nodes. + * + * The nesting graph idea comes from Sander, "Layout of Compound Directed + * Graphs." + */ +function run(g) { + var root = addDummyNode(g, 'root', {}, '_root'); + var depths = treeDepths(g); + var height = max(values(depths)) - 1; // Note: depths is an Object not an array + var nodeSep = 2 * height + 1; + + g.graph().nestingRoot = root; + + // Multiply minlen by nodeSep to align nodes on non-border ranks. + forEach(g.edges(), function (e) { + g.edge(e).minlen *= nodeSep; + }); + + // Calculate a weight that is sufficient to keep subgraphs vertically compact + var weight = sumWeights(g) + 1; + + // Create border nodes and link them up + forEach(g.children(), function (child) { + dfs(g, root, nodeSep, weight, height, depths, child); + }); + + // Save the multiplier for node layers for later removal of empty border + // layers. + g.graph().nodeRankFactor = nodeSep; +} + +function dfs(g, root, nodeSep, weight, height, depths, v) { + var children = g.children(v); + if (!children.length) { + if (v !== root) { + g.setEdge(root, v, { weight: 0, minlen: nodeSep }); + } + return; + } + + var top = addBorderNode$1(g, '_bt'); + var bottom = addBorderNode$1(g, '_bb'); + var label = g.node(v); + + g.setParent(top, v); + label.borderTop = top; + g.setParent(bottom, v); + label.borderBottom = bottom; + + forEach(children, function (child) { + dfs(g, root, nodeSep, weight, height, depths, child); + + var childNode = g.node(child); + var childTop = childNode.borderTop ? childNode.borderTop : child; + var childBottom = childNode.borderBottom ? childNode.borderBottom : child; + var thisWeight = childNode.borderTop ? weight : 2 * weight; + var minlen = childTop !== childBottom ? 1 : height - depths[v] + 1; + + g.setEdge(top, childTop, { + weight: thisWeight, + minlen: minlen, + nestingEdge: true, + }); + + g.setEdge(childBottom, bottom, { + weight: thisWeight, + minlen: minlen, + nestingEdge: true, + }); + }); + + if (!g.parent(v)) { + g.setEdge(root, top, { weight: 0, minlen: height + depths[v] }); + } +} + +function treeDepths(g) { + var depths = {}; + function dfs(v, depth) { + var children = g.children(v); + if (children && children.length) { + forEach(children, function (child) { + dfs(child, depth + 1); + }); + } + depths[v] = depth; + } + forEach(g.children(), function (v) { + dfs(v, 1); + }); + return depths; +} + +function sumWeights(g) { + return reduce( + g.edges(), + function (acc, e) { + return acc + g.edge(e).weight; + }, + 0 + ); +} + +function cleanup(g) { + var graphLabel = g.graph(); + g.removeNode(graphLabel.nestingRoot); + delete graphLabel.nestingRoot; + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.nestingEdge) { + g.removeEdge(e); + } + }); +} + +function addSubgraphConstraints(g, cg, vs) { + var prev = {}, + rootPrev; + + forEach(vs, function (v) { + var child = g.parent(v), + parent, + prevChild; + while (child) { + parent = g.parent(child); + if (parent) { + prevChild = prev[parent]; + prev[parent] = child; + } else { + prevChild = rootPrev; + rootPrev = child; + } + if (prevChild && prevChild !== child) { + cg.setEdge(prevChild, child); + return; + } + child = parent; + } + }); + + /* + function dfs(v) { + var children = v ? g.children(v) : g.children(); + if (children.length) { + var min = Number.POSITIVE_INFINITY, + subgraphs = []; + _.each(children, function(child) { + var childMin = dfs(child); + if (g.children(child).length) { + subgraphs.push({ v: child, order: childMin }); + } + min = Math.min(min, childMin); + }); + _.reduce(_.sortBy(subgraphs, "order"), function(prev, curr) { + cg.setEdge(prev.v, curr.v); + return curr; + }); + return min; + } + return g.node(v).order; + } + dfs(undefined); + */ +} + +/* + * Constructs a graph that can be used to sort a layer of nodes. The graph will + * contain all base and subgraph nodes from the request layer in their original + * hierarchy and any edges that are incident on these nodes and are of the type + * requested by the "relationship" parameter. + * + * Nodes from the requested rank that do not have parents are assigned a root + * node in the output graph, which is set in the root graph attribute. This + * makes it easy to walk the hierarchy of movable nodes during ordering. + * + * Pre-conditions: + * + * 1. Input graph is a DAG + * 2. Base nodes in the input graph have a rank attribute + * 3. Subgraph nodes in the input graph has minRank and maxRank attributes + * 4. Edges have an assigned weight + * + * Post-conditions: + * + * 1. Output graph has all nodes in the movable rank with preserved + * hierarchy. + * 2. Root nodes in the movable layer are made children of the node + * indicated by the root attribute of the graph. + * 3. Non-movable nodes incident on movable nodes, selected by the + * relationship parameter, are included in the graph (without hierarchy). + * 4. Edges incident on movable nodes, selected by the relationship + * parameter, are added to the output graph. + * 5. The weights for copied edges are aggregated as need, since the output + * graph is not a multi-graph. + */ +function buildLayerGraph(g, rank, relationship) { + var root = createRootNode(g), + result = new Graph({ compound: true }) + .setGraph({ root: root }) + .setDefaultNodeLabel(function (v) { + return g.node(v); + }); + + forEach(g.nodes(), function (v) { + var node = g.node(v), + parent = g.parent(v); + + if (node.rank === rank || (node.minRank <= rank && rank <= node.maxRank)) { + result.setNode(v); + result.setParent(v, parent || root); + + // This assumes we have only short edges! + forEach(g[relationship](v), function (e) { + var u = e.v === v ? e.w : e.v, + edge = result.edge(u, v), + weight = !isUndefined(edge) ? edge.weight : 0; + result.setEdge(u, v, { weight: g.edge(e).weight + weight }); + }); + + if (has(node, 'minRank')) { + result.setNode(v, { + borderLeft: node.borderLeft[rank], + borderRight: node.borderRight[rank], + }); + } + } + }); + + return result; +} + +function createRootNode(g) { + var v; + while (g.hasNode((v = uniqueId('_root')))); + return v; +} + +/* + * A function that takes a layering (an array of layers, each with an array of + * ordererd nodes) and a graph and returns a weighted crossing count. + * + * Pre-conditions: + * + * 1. Input graph must be simple (not a multigraph), directed, and include + * only simple edges. + * 2. Edges in the input graph must have assigned weights. + * + * Post-conditions: + * + * 1. The graph and layering matrix are left unchanged. + * + * This algorithm is derived from Barth, et al., "Bilayer Cross Counting." + */ +function crossCount(g, layering) { + var cc = 0; + for (var i = 1; i < layering.length; ++i) { + cc += twoLayerCrossCount(g, layering[i - 1], layering[i]); + } + return cc; +} + +function twoLayerCrossCount(g, northLayer, southLayer) { + // Sort all of the edges between the north and south layers by their position + // in the north layer and then the south. Map these edges to the position of + // their head in the south layer. + var southPos = zipObject( + southLayer, + map(southLayer, function (v, i) { + return i; + }) + ); + var southEntries = flatten( + map(northLayer, function (v) { + return sortBy( + map(g.outEdges(v), function (e) { + return { pos: southPos[e.w], weight: g.edge(e).weight }; + }), + 'pos' + ); + }) + ); + + // Build the accumulator tree + var firstIndex = 1; + while (firstIndex < southLayer.length) firstIndex <<= 1; + var treeSize = 2 * firstIndex - 1; + firstIndex -= 1; + var tree = map(new Array(treeSize), function () { + return 0; + }); + + // Calculate the weighted crossings + var cc = 0; + forEach( + // @ts-expect-error + southEntries.forEach(function (entry) { + var index = entry.pos + firstIndex; + tree[index] += entry.weight; + var weightSum = 0; + // @ts-expect-error + while (index > 0) { + // @ts-expect-error + if (index % 2) { + weightSum += tree[index + 1]; + } + // @ts-expect-error + index = (index - 1) >> 1; + tree[index] += entry.weight; + } + cc += entry.weight * weightSum; + }) + ); + + return cc; +} + +/* + * Assigns an initial order value for each node by performing a DFS search + * starting from nodes in the first rank. Nodes are assigned an order in their + * rank as they are first visited. + * + * This approach comes from Gansner, et al., "A Technique for Drawing Directed + * Graphs." + * + * Returns a layering matrix with an array per layer and each layer sorted by + * the order of its nodes. + */ +function initOrder(g) { + var visited = {}; + var simpleNodes = filter(g.nodes(), function (v) { + return !g.children(v).length; + }); + var maxRank = max( + map(simpleNodes, function (v) { + return g.node(v).rank; + }) + ); + var layers = map(range(maxRank + 1), function () { + return []; + }); + + function dfs(v) { + if (has(visited, v)) return; + visited[v] = true; + var node = g.node(v); + layers[node.rank].push(v); + forEach(g.successors(v), dfs); + } + + var orderedVs = sortBy(simpleNodes, function (v) { + return g.node(v).rank; + }); + forEach(orderedVs, dfs); + + return layers; +} + +function barycenter(g, movable) { + return map(movable, function (v) { + var inV = g.inEdges(v); + if (!inV.length) { + return { v: v }; + } else { + var result = reduce( + inV, + function (acc, e) { + var edge = g.edge(e), + nodeU = g.node(e.v); + return { + sum: acc.sum + edge.weight * nodeU.order, + weight: acc.weight + edge.weight, + }; + }, + { sum: 0, weight: 0 } + ); + + return { + v: v, + barycenter: result.sum / result.weight, + weight: result.weight, + }; + } + }); +} + +/* + * Given a list of entries of the form {v, barycenter, weight} and a + * constraint graph this function will resolve any conflicts between the + * constraint graph and the barycenters for the entries. If the barycenters for + * an entry would violate a constraint in the constraint graph then we coalesce + * the nodes in the conflict into a new node that respects the contraint and + * aggregates barycenter and weight information. + * + * This implementation is based on the description in Forster, "A Fast and + * Simple Hueristic for Constrained Two-Level Crossing Reduction," thought it + * differs in some specific details. + * + * Pre-conditions: + * + * 1. Each entry has the form {v, barycenter, weight}, or if the node has + * no barycenter, then {v}. + * + * Returns: + * + * A new list of entries of the form {vs, i, barycenter, weight}. The list + * `vs` may either be a singleton or it may be an aggregation of nodes + * ordered such that they do not violate constraints from the constraint + * graph. The property `i` is the lowest original index of any of the + * elements in `vs`. + */ +function resolveConflicts(entries, cg) { + var mappedEntries = {}; + forEach(entries, function (entry, i) { + var tmp = (mappedEntries[entry.v] = { + indegree: 0, + in: [], + out: [], + vs: [entry.v], + i: i, + }); + if (!isUndefined(entry.barycenter)) { + // @ts-expect-error + tmp.barycenter = entry.barycenter; + // @ts-expect-error + tmp.weight = entry.weight; + } + }); + + forEach(cg.edges(), function (e) { + var entryV = mappedEntries[e.v]; + var entryW = mappedEntries[e.w]; + if (!isUndefined(entryV) && !isUndefined(entryW)) { + entryW.indegree++; + entryV.out.push(mappedEntries[e.w]); + } + }); + + var sourceSet = filter(mappedEntries, function (entry) { + // @ts-expect-error + return !entry.indegree; + }); + + return doResolveConflicts(sourceSet); +} + +function doResolveConflicts(sourceSet) { + var entries = []; + + function handleIn(vEntry) { + return function (uEntry) { + if (uEntry.merged) { + return; + } + if ( + isUndefined(uEntry.barycenter) || + isUndefined(vEntry.barycenter) || + uEntry.barycenter >= vEntry.barycenter + ) { + mergeEntries(vEntry, uEntry); + } + }; + } + + function handleOut(vEntry) { + return function (wEntry) { + wEntry['in'].push(vEntry); + if (--wEntry.indegree === 0) { + sourceSet.push(wEntry); + } + }; + } + + while (sourceSet.length) { + var entry = sourceSet.pop(); + entries.push(entry); + forEach(entry['in'].reverse(), handleIn(entry)); + forEach(entry.out, handleOut(entry)); + } + + return map( + filter(entries, function (entry) { + return !entry.merged; + }), + function (entry) { + return pick(entry, ['vs', 'i', 'barycenter', 'weight']); + } + ); +} + +function mergeEntries(target, source) { + var sum = 0; + var weight = 0; + + if (target.weight) { + sum += target.barycenter * target.weight; + weight += target.weight; + } + + if (source.weight) { + sum += source.barycenter * source.weight; + weight += source.weight; + } + + target.vs = source.vs.concat(target.vs); + target.barycenter = sum / weight; + target.weight = weight; + target.i = Math.min(source.i, target.i); + source.merged = true; +} + +function sort(entries, biasRight) { + var parts = partition(entries, function (entry) { + return has(entry, 'barycenter'); + }); + var sortable = parts.lhs, + unsortable = sortBy(parts.rhs, function (entry) { + return -entry.i; + }), + vs = [], + sum = 0, + weight = 0, + vsIndex = 0; + + sortable.sort(compareWithBias(!!biasRight)); + + vsIndex = consumeUnsortable(vs, unsortable, vsIndex); + + forEach(sortable, function (entry) { + vsIndex += entry.vs.length; + vs.push(entry.vs); + sum += entry.barycenter * entry.weight; + weight += entry.weight; + vsIndex = consumeUnsortable(vs, unsortable, vsIndex); + }); + + var result = { vs: flatten(vs) }; + if (weight) { + result.barycenter = sum / weight; + result.weight = weight; + } + return result; +} + +function consumeUnsortable(vs, unsortable, index) { + var last$1; + while (unsortable.length && (last$1 = last(unsortable)).i <= index) { + unsortable.pop(); + vs.push(last$1.vs); + index++; + } + return index; +} + +function compareWithBias(bias) { + return function (entryV, entryW) { + if (entryV.barycenter < entryW.barycenter) { + return -1; + } else if (entryV.barycenter > entryW.barycenter) { + return 1; + } + + return !bias ? entryV.i - entryW.i : entryW.i - entryV.i; + }; +} + +function sortSubgraph(g, v, cg, biasRight) { + var movable = g.children(v); + var node = g.node(v); + var bl = node ? node.borderLeft : undefined; + var br = node ? node.borderRight : undefined; + var subgraphs = {}; + + if (bl) { + movable = filter(movable, function (w) { + return w !== bl && w !== br; + }); + } + + var barycenters = barycenter(g, movable); + forEach(barycenters, function (entry) { + if (g.children(entry.v).length) { + var subgraphResult = sortSubgraph(g, entry.v, cg, biasRight); + subgraphs[entry.v] = subgraphResult; + if (has(subgraphResult, 'barycenter')) { + mergeBarycenters(entry, subgraphResult); + } + } + }); + + var entries = resolveConflicts(barycenters, cg); + expandSubgraphs(entries, subgraphs); + + var result = sort(entries, biasRight); + + if (bl) { + result.vs = flatten([bl, result.vs, br]); + if (g.predecessors(bl).length) { + var blPred = g.node(g.predecessors(bl)[0]), + brPred = g.node(g.predecessors(br)[0]); + if (!has(result, 'barycenter')) { + result.barycenter = 0; + result.weight = 0; + } + result.barycenter = + (result.barycenter * result.weight + blPred.order + brPred.order) / (result.weight + 2); + result.weight += 2; + } + } + + return result; +} + +function expandSubgraphs(entries, subgraphs) { + forEach(entries, function (entry) { + entry.vs = flatten( + entry.vs.map(function (v) { + if (subgraphs[v]) { + return subgraphs[v].vs; + } + return v; + }) + ); + }); +} + +function mergeBarycenters(target, other) { + if (!isUndefined(target.barycenter)) { + target.barycenter = + (target.barycenter * target.weight + other.barycenter * other.weight) / + (target.weight + other.weight); + target.weight += other.weight; + } else { + target.barycenter = other.barycenter; + target.weight = other.weight; + } +} + +/* + * Applies heuristics to minimize edge crossings in the graph and sets the best + * order solution as an order attribute on each node. + * + * Pre-conditions: + * + * 1. Graph must be DAG + * 2. Graph nodes must be objects with a "rank" attribute + * 3. Graph edges must have the "weight" attribute + * + * Post-conditions: + * + * 1. Graph nodes will have an "order" attribute based on the results of the + * algorithm. + */ +function order(g) { + var maxRank$1 = maxRank(g), + downLayerGraphs = buildLayerGraphs(g, range(1, maxRank$1 + 1), 'inEdges'), + upLayerGraphs = buildLayerGraphs(g, range(maxRank$1 - 1, -1, -1), 'outEdges'); + + var layering = initOrder(g); + assignOrder(g, layering); + + var bestCC = Number.POSITIVE_INFINITY, + best; + + for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) { + sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2); + + layering = buildLayerMatrix(g); + var cc = crossCount(g, layering); + if (cc < bestCC) { + lastBest = 0; + best = cloneDeep(layering); + bestCC = cc; + } + } + + assignOrder(g, best); +} + +function buildLayerGraphs(g, ranks, relationship) { + return map(ranks, function (rank) { + return buildLayerGraph(g, rank, relationship); + }); +} + +function sweepLayerGraphs(layerGraphs, biasRight) { + var cg = new Graph(); + forEach(layerGraphs, function (lg) { + var root = lg.graph().root; + var sorted = sortSubgraph(lg, root, cg, biasRight); + forEach(sorted.vs, function (v, i) { + lg.node(v).order = i; + }); + addSubgraphConstraints(lg, cg, sorted.vs); + }); +} + +function assignOrder(g, layering) { + forEach(layering, function (layer) { + forEach(layer, function (v, i) { + g.node(v).order = i; + }); + }); +} + +function parentDummyChains(g) { + var postorderNums = postorder(g); + + forEach(g.graph().dummyChains, function (v) { + var node = g.node(v); + var edgeObj = node.edgeObj; + var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w); + var path = pathData.path; + var lca = pathData.lca; + var pathIdx = 0; + var pathV = path[pathIdx]; + var ascending = true; + + while (v !== edgeObj.w) { + node = g.node(v); + + if (ascending) { + while ((pathV = path[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) { + pathIdx++; + } + + if (pathV === lca) { + ascending = false; + } + } + + if (!ascending) { + while ( + pathIdx < path.length - 1 && + g.node((pathV = path[pathIdx + 1])).minRank <= node.rank + ) { + pathIdx++; + } + pathV = path[pathIdx]; + } + + g.setParent(v, pathV); + v = g.successors(v)[0]; + } + }); +} + +// Find a path from v to w through the lowest common ancestor (LCA). Return the +// full path and the LCA. +function findPath(g, postorderNums, v, w) { + var vPath = []; + var wPath = []; + var low = Math.min(postorderNums[v].low, postorderNums[w].low); + var lim = Math.max(postorderNums[v].lim, postorderNums[w].lim); + var parent; + var lca; + + // Traverse up from v to find the LCA + parent = v; + do { + parent = g.parent(parent); + vPath.push(parent); + } while (parent && (postorderNums[parent].low > low || lim > postorderNums[parent].lim)); + lca = parent; + + // Traverse from w to LCA + parent = w; + while ((parent = g.parent(parent)) !== lca) { + wPath.push(parent); + } + + return { path: vPath.concat(wPath.reverse()), lca: lca }; +} + +function postorder(g) { + var result = {}; + var lim = 0; + + function dfs(v) { + var low = lim; + forEach(g.children(v), dfs); + result[v] = { low: low, lim: lim++ }; + } + forEach(g.children(), dfs); + + return result; +} + +/* + * Marks all edges in the graph with a type-1 conflict with the "type1Conflict" + * property. A type-1 conflict is one where a non-inner segment crosses an + * inner segment. An inner segment is an edge with both incident nodes marked + * with the "dummy" property. + * + * This algorithm scans layer by layer, starting with the second, for type-1 + * conflicts between the current layer and the previous layer. For each layer + * it scans the nodes from left to right until it reaches one that is incident + * on an inner segment. It then scans predecessors to determine if they have + * edges that cross that inner segment. At the end a final scan is done for all + * nodes on the current rank to see if they cross the last visited inner + * segment. + * + * This algorithm (safely) assumes that a dummy node will only be incident on a + * single node in the layers being scanned. + */ +function findType1Conflicts(g, layering) { + var conflicts = {}; + + function visitLayer(prevLayer, layer) { + var // last visited node in the previous layer that is incident on an inner + // segment. + k0 = 0, + // Tracks the last node in this layer scanned for crossings with a type-1 + // segment. + scanPos = 0, + prevLayerLength = prevLayer.length, + lastNode = last(layer); + + forEach(layer, function (v, i) { + var w = findOtherInnerSegmentNode(g, v), + k1 = w ? g.node(w).order : prevLayerLength; + + if (w || v === lastNode) { + forEach(layer.slice(scanPos, i + 1), function (scanNode) { + forEach(g.predecessors(scanNode), function (u) { + var uLabel = g.node(u), + uPos = uLabel.order; + if ((uPos < k0 || k1 < uPos) && !(uLabel.dummy && g.node(scanNode).dummy)) { + addConflict(conflicts, u, scanNode); + } + }); + }); + // @ts-expect-error + scanPos = i + 1; + k0 = k1; + } + }); + + return layer; + } + + reduce(layering, visitLayer); + return conflicts; +} + +function findType2Conflicts(g, layering) { + var conflicts = {}; + + function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) { + var v; + forEach(range(southPos, southEnd), function (i) { + v = south[i]; + if (g.node(v).dummy) { + forEach(g.predecessors(v), function (u) { + var uNode = g.node(u); + if (uNode.dummy && (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) { + addConflict(conflicts, u, v); + } + }); + } + }); + } + + function visitLayer(north, south) { + var prevNorthPos = -1, + nextNorthPos, + southPos = 0; + + forEach(south, function (v, southLookahead) { + if (g.node(v).dummy === 'border') { + var predecessors = g.predecessors(v); + if (predecessors.length) { + nextNorthPos = g.node(predecessors[0]).order; + scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos); + // @ts-expect-error + southPos = southLookahead; + prevNorthPos = nextNorthPos; + } + } + scan(south, southPos, south.length, nextNorthPos, north.length); + }); + + return south; + } + + reduce(layering, visitLayer); + return conflicts; +} + +function findOtherInnerSegmentNode(g, v) { + if (g.node(v).dummy) { + return find(g.predecessors(v), function (u) { + return g.node(u).dummy; + }); + } +} + +function addConflict(conflicts, v, w) { + if (v > w) { + var tmp = v; + v = w; + w = tmp; + } + + var conflictsV = conflicts[v]; + if (!conflictsV) { + conflicts[v] = conflictsV = {}; + } + conflictsV[w] = true; +} + +function hasConflict(conflicts, v, w) { + if (v > w) { + var tmp = v; + v = w; + w = tmp; + } + return has(conflicts[v], w); +} + +/* + * Try to align nodes into vertical "blocks" where possible. This algorithm + * attempts to align a node with one of its median neighbors. If the edge + * connecting a neighbor is a type-1 conflict then we ignore that possibility. + * If a previous node has already formed a block with a node after the node + * we're trying to form a block with, we also ignore that possibility - our + * blocks would be split in that scenario. + */ +function verticalAlignment(g, layering, conflicts, neighborFn) { + var root = {}, + align = {}, + pos = {}; + + // We cache the position here based on the layering because the graph and + // layering may be out of sync. The layering matrix is manipulated to + // generate different extreme alignments. + forEach(layering, function (layer) { + forEach(layer, function (v, order) { + root[v] = v; + align[v] = v; + pos[v] = order; + }); + }); + + forEach(layering, function (layer) { + var prevIdx = -1; + forEach(layer, function (v) { + var ws = neighborFn(v); + if (ws.length) { + ws = sortBy(ws, function (w) { + return pos[w]; + }); + var mp = (ws.length - 1) / 2; + for (var i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) { + var w = ws[i]; + if (align[v] === v && prevIdx < pos[w] && !hasConflict(conflicts, v, w)) { + align[w] = v; + align[v] = root[v] = root[w]; + prevIdx = pos[w]; + } + } + } + }); + }); + + return { root: root, align: align }; +} + +function horizontalCompaction(g, layering, root, align, reverseSep) { + // This portion of the algorithm differs from BK due to a number of problems. + // Instead of their algorithm we construct a new block graph and do two + // sweeps. The first sweep places blocks with the smallest possible + // coordinates. The second sweep removes unused space by moving blocks to the + // greatest coordinates without violating separation. + var xs = {}, + blockG = buildBlockGraph(g, layering, root, reverseSep), + borderType = reverseSep ? 'borderLeft' : 'borderRight'; + + function iterate(setXsFunc, nextNodesFunc) { + var stack = blockG.nodes(); + var elem = stack.pop(); + var visited = {}; + while (elem) { + if (visited[elem]) { + setXsFunc(elem); + } else { + visited[elem] = true; + stack.push(elem); + stack = stack.concat(nextNodesFunc(elem)); + } + + elem = stack.pop(); + } + } + + // First pass, assign smallest coordinates + function pass1(elem) { + xs[elem] = blockG.inEdges(elem).reduce(function (acc, e) { + return Math.max(acc, xs[e.v] + blockG.edge(e)); + }, 0); + } + + // Second pass, assign greatest coordinates + function pass2(elem) { + var min = blockG.outEdges(elem).reduce(function (acc, e) { + return Math.min(acc, xs[e.w] - blockG.edge(e)); + }, Number.POSITIVE_INFINITY); + + var node = g.node(elem); + if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) { + xs[elem] = Math.max(xs[elem], min); + } + } + + iterate(pass1, blockG.predecessors.bind(blockG)); + iterate(pass2, blockG.successors.bind(blockG)); + + // Assign x coordinates to all nodes + forEach(align, function (v) { + xs[v] = xs[root[v]]; + }); + + return xs; +} + +function buildBlockGraph(g, layering, root, reverseSep) { + var blockGraph = new Graph(), + graphLabel = g.graph(), + sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep); + + forEach(layering, function (layer) { + var u; + forEach(layer, function (v) { + var vRoot = root[v]; + blockGraph.setNode(vRoot); + if (u) { + var uRoot = root[u], + prevMax = blockGraph.edge(uRoot, vRoot); + blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0)); + } + u = v; + }); + }); + + return blockGraph; +} + +/* + * Returns the alignment that has the smallest width of the given alignments. + */ +function findSmallestWidthAlignment(g, xss) { + return minBy(values(xss), function (xs) { + var max = Number.NEGATIVE_INFINITY; + var min = Number.POSITIVE_INFINITY; + + forIn(xs, function (x, v) { + var halfWidth = width(g, v) / 2; + + max = Math.max(x + halfWidth, max); + min = Math.min(x - halfWidth, min); + }); + + return max - min; + }); +} + +/* + * Align the coordinates of each of the layout alignments such that + * left-biased alignments have their minimum coordinate at the same point as + * the minimum coordinate of the smallest width alignment and right-biased + * alignments have their maximum coordinate at the same point as the maximum + * coordinate of the smallest width alignment. + */ +function alignCoordinates(xss, alignTo) { + var alignToVals = values(alignTo), + alignToMin = min(alignToVals), + alignToMax = max(alignToVals); + + forEach(['u', 'd'], function (vert) { + forEach(['l', 'r'], function (horiz) { + var alignment = vert + horiz, + xs = xss[alignment], + delta; + if (xs === alignTo) return; + + var xsVals = values(xs); + delta = horiz === 'l' ? alignToMin - min(xsVals) : alignToMax - max(xsVals); + + if (delta) { + xss[alignment] = mapValues(xs, function (x) { + return x + delta; + }); + } + }); + }); +} + +function balance(xss, align) { + return mapValues(xss.ul, function (ignore, v) { + if (align) { + return xss[align.toLowerCase()][v]; + } else { + var xs = sortBy(map(xss, v)); + return (xs[1] + xs[2]) / 2; + } + }); +} + +function positionX(g) { + var layering = buildLayerMatrix(g); + var conflicts = merge(findType1Conflicts(g, layering), findType2Conflicts(g, layering)); + + var xss = {}; + var adjustedLayering; + forEach(['u', 'd'], function (vert) { + adjustedLayering = vert === 'u' ? layering : values(layering).reverse(); + forEach(['l', 'r'], function (horiz) { + if (horiz === 'r') { + adjustedLayering = map(adjustedLayering, function (inner) { + return values(inner).reverse(); + }); + } + + var neighborFn = (vert === 'u' ? g.predecessors : g.successors).bind(g); + var align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn); + var xs = horizontalCompaction(g, adjustedLayering, align.root, align.align, horiz === 'r'); + if (horiz === 'r') { + xs = mapValues(xs, function (x) { + return -x; + }); + } + xss[vert + horiz] = xs; + }); + }); + + var smallestWidth = findSmallestWidthAlignment(g, xss); + alignCoordinates(xss, smallestWidth); + return balance(xss, g.graph().align); +} + +function sep(nodeSep, edgeSep, reverseSep) { + return function (g, v, w) { + var vLabel = g.node(v); + var wLabel = g.node(w); + var sum = 0; + var delta; + + sum += vLabel.width / 2; + if (has(vLabel, 'labelpos')) { + switch (vLabel.labelpos.toLowerCase()) { + case 'l': + delta = -vLabel.width / 2; + break; + case 'r': + delta = vLabel.width / 2; + break; + } + } + if (delta) { + sum += reverseSep ? delta : -delta; + } + delta = 0; + + sum += (vLabel.dummy ? edgeSep : nodeSep) / 2; + sum += (wLabel.dummy ? edgeSep : nodeSep) / 2; + + sum += wLabel.width / 2; + if (has(wLabel, 'labelpos')) { + switch (wLabel.labelpos.toLowerCase()) { + case 'l': + delta = wLabel.width / 2; + break; + case 'r': + delta = -wLabel.width / 2; + break; + } + } + if (delta) { + sum += reverseSep ? delta : -delta; + } + delta = 0; + + return sum; + }; +} + +function width(g, v) { + return g.node(v).width; +} + +function position(g) { + g = asNonCompoundGraph(g); + + positionY(g); + forOwn(positionX(g), function (x, v) { + g.node(v).x = x; + }); +} + +function positionY(g) { + var layering = buildLayerMatrix(g); + var rankSep = g.graph().ranksep; + var prevY = 0; + forEach(layering, function (layer) { + var maxHeight = max( + map(layer, function (v) { + return g.node(v).height; + }) + ); + forEach(layer, function (v) { + g.node(v).y = prevY + maxHeight / 2; + }); + prevY += maxHeight + rankSep; + }); +} + +function layout(g, opts) { + var time = notime; + time('layout', function () { + var layoutGraph = time(' buildLayoutGraph', function () { + return buildLayoutGraph(g); + }); + time(' runLayout', function () { + runLayout(layoutGraph, time); + }); + time(' updateInputGraph', function () { + updateInputGraph(g, layoutGraph); + }); + }); +} + +function runLayout(g, time) { + time(' makeSpaceForEdgeLabels', function () { + makeSpaceForEdgeLabels(g); + }); + time(' removeSelfEdges', function () { + removeSelfEdges(g); + }); + time(' acyclic', function () { + run$2(g); + }); + time(' nestingGraph.run', function () { + run(g); + }); + time(' rank', function () { + rank(asNonCompoundGraph(g)); + }); + time(' injectEdgeLabelProxies', function () { + injectEdgeLabelProxies(g); + }); + time(' removeEmptyRanks', function () { + removeEmptyRanks(g); + }); + time(' nestingGraph.cleanup', function () { + cleanup(g); + }); + time(' normalizeRanks', function () { + normalizeRanks(g); + }); + time(' assignRankMinMax', function () { + assignRankMinMax(g); + }); + time(' removeEdgeLabelProxies', function () { + removeEdgeLabelProxies(g); + }); + time(' normalize.run', function () { + run$1(g); + }); + time(' parentDummyChains', function () { + parentDummyChains(g); + }); + time(' addBorderSegments', function () { + addBorderSegments(g); + }); + time(' order', function () { + order(g); + }); + time(' insertSelfEdges', function () { + insertSelfEdges(g); + }); + time(' adjustCoordinateSystem', function () { + adjust(g); + }); + time(' position', function () { + position(g); + }); + time(' positionSelfEdges', function () { + positionSelfEdges(g); + }); + time(' removeBorderNodes', function () { + removeBorderNodes(g); + }); + time(' normalize.undo', function () { + undo(g); + }); + time(' fixupEdgeLabelCoords', function () { + fixupEdgeLabelCoords(g); + }); + time(' undoCoordinateSystem', function () { + undo$1(g); + }); + time(' translateGraph', function () { + translateGraph(g); + }); + time(' assignNodeIntersects', function () { + assignNodeIntersects(g); + }); + time(' reversePoints', function () { + reversePointsForReversedEdges(g); + }); + time(' acyclic.undo', function () { + undo$2(g); + }); +} + +/* + * Copies final layout information from the layout graph back to the input + * graph. This process only copies whitelisted attributes from the layout graph + * to the input graph, so it serves as a good place to determine what + * attributes can influence layout. + */ +function updateInputGraph(inputGraph, layoutGraph) { + forEach(inputGraph.nodes(), function (v) { + var inputLabel = inputGraph.node(v); + var layoutLabel = layoutGraph.node(v); + + if (inputLabel) { + inputLabel.x = layoutLabel.x; + inputLabel.y = layoutLabel.y; + + if (layoutGraph.children(v).length) { + inputLabel.width = layoutLabel.width; + inputLabel.height = layoutLabel.height; + } + } + }); + + forEach(inputGraph.edges(), function (e) { + var inputLabel = inputGraph.edge(e); + var layoutLabel = layoutGraph.edge(e); + + inputLabel.points = layoutLabel.points; + if (has(layoutLabel, 'x')) { + inputLabel.x = layoutLabel.x; + inputLabel.y = layoutLabel.y; + } + }); + + inputGraph.graph().width = layoutGraph.graph().width; + inputGraph.graph().height = layoutGraph.graph().height; +} + +var graphNumAttrs = ['nodesep', 'edgesep', 'ranksep', 'marginx', 'marginy']; +var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: 'tb' }; +var graphAttrs = ['acyclicer', 'ranker', 'rankdir', 'align']; +var nodeNumAttrs = ['width', 'height']; +var nodeDefaults = { width: 0, height: 0 }; +var edgeNumAttrs = ['minlen', 'weight', 'width', 'height', 'labeloffset']; +var edgeDefaults = { + minlen: 1, + weight: 1, + width: 0, + height: 0, + labeloffset: 10, + labelpos: 'r', +}; +var edgeAttrs = ['labelpos']; + +/* + * Constructs a new graph from the input graph, which can be used for layout. + * This process copies only whitelisted attributes from the input graph to the + * layout graph. Thus this function serves as a good place to determine what + * attributes can influence layout. + */ +function buildLayoutGraph(inputGraph) { + var g = new Graph({ multigraph: true, compound: true }); + var graph = canonicalize(inputGraph.graph()); + + g.setGraph( + merge({}, graphDefaults, selectNumberAttrs(graph, graphNumAttrs), pick(graph, graphAttrs)) + ); + + forEach(inputGraph.nodes(), function (v) { + var node = canonicalize(inputGraph.node(v)); + g.setNode(v, defaults(selectNumberAttrs(node, nodeNumAttrs), nodeDefaults)); + g.setParent(v, inputGraph.parent(v)); + }); + + forEach(inputGraph.edges(), function (e) { + var edge = canonicalize(inputGraph.edge(e)); + g.setEdge( + e, + merge({}, edgeDefaults, selectNumberAttrs(edge, edgeNumAttrs), pick(edge, edgeAttrs)) + ); + }); + + return g; +} + +/* + * This idea comes from the Gansner paper: to account for edge labels in our + * layout we split each rank in half by doubling minlen and halving ranksep. + * Then we can place labels at these mid-points between nodes. + * + * We also add some minimal padding to the width to push the label for the edge + * away from the edge itself a bit. + */ +function makeSpaceForEdgeLabels(g) { + var graph = g.graph(); + graph.ranksep /= 2; + forEach(g.edges(), function (e) { + var edge = g.edge(e); + edge.minlen *= 2; + if (edge.labelpos.toLowerCase() !== 'c') { + if (graph.rankdir === 'TB' || graph.rankdir === 'BT') { + edge.width += edge.labeloffset; + } else { + edge.height += edge.labeloffset; + } + } + }); +} + +/* + * Creates temporary dummy nodes that capture the rank in which each edge's + * label is going to, if it has one of non-zero width and height. We do this + * so that we can safely remove empty ranks while preserving balance for the + * label's position. + */ +function injectEdgeLabelProxies(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.width && edge.height) { + var v = g.node(e.v); + var w = g.node(e.w); + var label = { rank: (w.rank - v.rank) / 2 + v.rank, e: e }; + addDummyNode(g, 'edge-proxy', label, '_ep'); + } + }); +} + +function assignRankMinMax(g) { + var maxRank = 0; + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.borderTop) { + node.minRank = g.node(node.borderTop).rank; + node.maxRank = g.node(node.borderBottom).rank; + // @ts-expect-error + maxRank = max(maxRank, node.maxRank); + } + }); + g.graph().maxRank = maxRank; +} + +function removeEdgeLabelProxies(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.dummy === 'edge-proxy') { + g.edge(node.e).labelRank = node.rank; + g.removeNode(v); + } + }); +} + +function translateGraph(g) { + var minX = Number.POSITIVE_INFINITY; + var maxX = 0; + var minY = Number.POSITIVE_INFINITY; + var maxY = 0; + var graphLabel = g.graph(); + var marginX = graphLabel.marginx || 0; + var marginY = graphLabel.marginy || 0; + + function getExtremes(attrs) { + var x = attrs.x; + var y = attrs.y; + var w = attrs.width; + var h = attrs.height; + minX = Math.min(minX, x - w / 2); + maxX = Math.max(maxX, x + w / 2); + minY = Math.min(minY, y - h / 2); + maxY = Math.max(maxY, y + h / 2); + } + + forEach(g.nodes(), function (v) { + getExtremes(g.node(v)); + }); + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (has(edge, 'x')) { + getExtremes(edge); + } + }); + + minX -= marginX; + minY -= marginY; + + forEach(g.nodes(), function (v) { + var node = g.node(v); + node.x -= minX; + node.y -= minY; + }); + + forEach(g.edges(), function (e) { + var edge = g.edge(e); + forEach(edge.points, function (p) { + p.x -= minX; + p.y -= minY; + }); + if (has(edge, 'x')) { + edge.x -= minX; + } + if (has(edge, 'y')) { + edge.y -= minY; + } + }); + + graphLabel.width = maxX - minX + marginX; + graphLabel.height = maxY - minY + marginY; +} + +function assignNodeIntersects(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + var nodeV = g.node(e.v); + var nodeW = g.node(e.w); + var p1, p2; + if (!edge.points) { + edge.points = []; + p1 = nodeW; + p2 = nodeV; + } else { + p1 = edge.points[0]; + p2 = edge.points[edge.points.length - 1]; + } + edge.points.unshift(intersectRect(nodeV, p1)); + edge.points.push(intersectRect(nodeW, p2)); + }); +} + +function fixupEdgeLabelCoords(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (has(edge, 'x')) { + if (edge.labelpos === 'l' || edge.labelpos === 'r') { + edge.width -= edge.labeloffset; + } + switch (edge.labelpos) { + case 'l': + edge.x -= edge.width / 2 + edge.labeloffset; + break; + case 'r': + edge.x += edge.width / 2 + edge.labeloffset; + break; + } + } + }); +} + +function reversePointsForReversedEdges(g) { + forEach(g.edges(), function (e) { + var edge = g.edge(e); + if (edge.reversed) { + edge.points.reverse(); + } + }); +} + +function removeBorderNodes(g) { + forEach(g.nodes(), function (v) { + if (g.children(v).length) { + var node = g.node(v); + var t = g.node(node.borderTop); + var b = g.node(node.borderBottom); + var l = g.node(last(node.borderLeft)); + var r = g.node(last(node.borderRight)); + + node.width = Math.abs(r.x - l.x); + node.height = Math.abs(b.y - t.y); + node.x = l.x + node.width / 2; + node.y = t.y + node.height / 2; + } + }); + + forEach(g.nodes(), function (v) { + if (g.node(v).dummy === 'border') { + g.removeNode(v); + } + }); +} + +function removeSelfEdges(g) { + forEach(g.edges(), function (e) { + if (e.v === e.w) { + var node = g.node(e.v); + if (!node.selfEdges) { + node.selfEdges = []; + } + node.selfEdges.push({ e: e, label: g.edge(e) }); + g.removeEdge(e); + } + }); +} + +function insertSelfEdges(g) { + var layers = buildLayerMatrix(g); + forEach(layers, function (layer) { + var orderShift = 0; + forEach(layer, function (v, i) { + var node = g.node(v); + node.order = i + orderShift; + forEach(node.selfEdges, function (selfEdge) { + addDummyNode( + g, + 'selfedge', + { + width: selfEdge.label.width, + height: selfEdge.label.height, + rank: node.rank, + order: i + ++orderShift, + e: selfEdge.e, + label: selfEdge.label, + }, + '_se' + ); + }); + delete node.selfEdges; + }); + }); +} + +function positionSelfEdges(g) { + forEach(g.nodes(), function (v) { + var node = g.node(v); + if (node.dummy === 'selfedge') { + var selfNode = g.node(node.e.v); + var x = selfNode.x + selfNode.width / 2; + var y = selfNode.y; + var dx = node.x - x; + var dy = selfNode.height / 2; + g.setEdge(node.e, node.label); + g.removeNode(v); + node.label.points = [ + { x: x + (2 * dx) / 3, y: y - dy }, + { x: x + (5 * dx) / 6, y: y - dy }, + { x: x + dx, y: y }, + { x: x + (5 * dx) / 6, y: y + dy }, + { x: x + (2 * dx) / 3, y: y + dy }, + ]; + node.label.x = node.x; + node.label.y = node.y; + } + }); +} + +function selectNumberAttrs(obj, attrs) { + return mapValues(pick(obj, attrs), Number); +} + +function canonicalize(attrs) { + var newAttrs = {}; + forEach(attrs, function (v, k) { + newAttrs[k.toLowerCase()] = v; + }); + return newAttrs; +} + +export { defaults as d, layout as l, map as m, pick as p, range as r, uniqueId as u }; diff --git a/libs/marked/line-D1aCvau7.js b/libs/marked/line-D1aCvau7.js new file mode 100644 index 0000000..8f64ba2 --- /dev/null +++ b/libs/marked/line-D1aCvau7.js @@ -0,0 +1,66 @@ +import { a as array } from './array-DJxSMw-N.js'; +import { w as withPath, c as constant } from './path-BZ3S9nBE.js'; +import { n as curveLinear } from './index-CN3YjQ0n.js'; + +function x(p) { + return p[0]; +} + +function y(p) { + return p[1]; +} + +function line(x$1, y$1) { + var defined = constant(true), + context = null, + curve = curveLinear, + output = null, + path = withPath(line); + + x$1 = typeof x$1 === "function" ? x$1 : (x$1 === undefined) ? x : constant(x$1); + y$1 = typeof y$1 === "function" ? y$1 : (y$1 === undefined) ? y : constant(y$1); + + function line(data) { + var i, + n = (data = array(data)).length, + d, + defined0 = false, + buffer; + + if (context == null) output = curve(buffer = path()); + + for (i = 0; i <= n; ++i) { + if (!(i < n && defined(d = data[i], i, data)) === defined0) { + if (defined0 = !defined0) output.lineStart(); + else output.lineEnd(); + } + if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data)); + } + + if (buffer) return output = null, buffer + "" || null; + } + + line.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line) : x$1; + }; + + line.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line) : y$1; + }; + + line.defined = function(_) { + return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line) : defined; + }; + + line.curve = function(_) { + return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve; + }; + + line.context = function(_) { + return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context; + }; + + return line; +} + +export { line as l }; diff --git a/libs/marked/line-DUwhS6kk.js b/libs/marked/line-DUwhS6kk.js new file mode 100644 index 0000000..e73365c --- /dev/null +++ b/libs/marked/line-DUwhS6kk.js @@ -0,0 +1,66 @@ +import { a as array } from './array-DJxSMw-N.js'; +import { w as withPath, c as constant } from './path-BZ3S9nBE.js'; +import { n as curveLinear } from './index-Bd_FDXSq.js'; + +function x(p) { + return p[0]; +} + +function y(p) { + return p[1]; +} + +function line(x$1, y$1) { + var defined = constant(true), + context = null, + curve = curveLinear, + output = null, + path = withPath(line); + + x$1 = typeof x$1 === "function" ? x$1 : (x$1 === undefined) ? x : constant(x$1); + y$1 = typeof y$1 === "function" ? y$1 : (y$1 === undefined) ? y : constant(y$1); + + function line(data) { + var i, + n = (data = array(data)).length, + d, + defined0 = false, + buffer; + + if (context == null) output = curve(buffer = path()); + + for (i = 0; i <= n; ++i) { + if (!(i < n && defined(d = data[i], i, data)) === defined0) { + if (defined0 = !defined0) output.lineStart(); + else output.lineEnd(); + } + if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data)); + } + + if (buffer) return output = null, buffer + "" || null; + } + + line.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line) : x$1; + }; + + line.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line) : y$1; + }; + + line.defined = function(_) { + return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line) : defined; + }; + + line.curve = function(_) { + return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve; + }; + + line.context = function(_) { + return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context; + }; + + return line; +} + +export { line as l }; diff --git a/libs/marked/linear--P89MwVW.js b/libs/marked/linear--P89MwVW.js new file mode 100644 index 0000000..7dbad02 --- /dev/null +++ b/libs/marked/linear--P89MwVW.js @@ -0,0 +1,764 @@ +import { $ as constant, a0 as interpolateNumber, a1 as color, a2 as interpolateRgb, a3 as interpolateString } from './index-CN3YjQ0n.js'; +import { i as initRange } from './init-zpY4DTin.js'; + +function ascending(a, b) { + return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function descending(a, b) { + return a == null || b == null ? NaN + : b < a ? -1 + : b > a ? 1 + : b >= a ? 0 + : NaN; +} + +function bisector(f) { + let compare1, compare2, delta; + + // If an accessor is specified, promote it to a comparator. In this case we + // can test whether the search value is (self-) comparable. We can’t do this + // for a comparator (except for specific, known comparators) because we can’t + // tell if the comparator is symmetric, and an asymmetric comparator can’t be + // used to test whether a single value is comparable. + if (f.length !== 2) { + compare1 = ascending; + compare2 = (d, x) => ascending(f(d), x); + delta = (d, x) => f(d) - x; + } else { + compare1 = f === ascending || f === descending ? f : zero; + compare2 = f; + delta = f; + } + + function left(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) < 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function right(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) <= 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function center(a, x, lo = 0, hi = a.length) { + const i = left(a, x, lo, hi - 1); + return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; + } + + return {left, center, right}; +} + +function zero() { + return 0; +} + +function number$1(x) { + return x === null ? NaN : +x; +} + +const ascendingBisect = bisector(ascending); +const bisectRight = ascendingBisect.right; +bisector(number$1).center; + +const e10 = Math.sqrt(50), + e5 = Math.sqrt(10), + e2 = Math.sqrt(2); + +function tickSpec(start, stop, count) { + const step = (stop - start) / Math.max(0, count), + power = Math.floor(Math.log10(step)), + error = step / Math.pow(10, power), + factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; + let i1, i2, inc; + if (power < 0) { + inc = Math.pow(10, -power) / factor; + i1 = Math.round(start * inc); + i2 = Math.round(stop * inc); + if (i1 / inc < start) ++i1; + if (i2 / inc > stop) --i2; + inc = -inc; + } else { + inc = Math.pow(10, power) * factor; + i1 = Math.round(start / inc); + i2 = Math.round(stop / inc); + if (i1 * inc < start) ++i1; + if (i2 * inc > stop) --i2; + } + if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); + return [i1, i2, inc]; +} + +function ticks(start, stop, count) { + stop = +stop, start = +start, count = +count; + if (!(count > 0)) return []; + if (start === stop) return [start]; + const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count); + if (!(i2 >= i1)) return []; + const n = i2 - i1 + 1, ticks = new Array(n); + if (reverse) { + if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) / -inc; + else for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) * inc; + } else { + if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) / -inc; + else for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) * inc; + } + return ticks; +} + +function tickIncrement(start, stop, count) { + stop = +stop, start = +start, count = +count; + return tickSpec(start, stop, count)[2]; +} + +function tickStep(start, stop, count) { + stop = +stop, start = +start, count = +count; + const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count); + return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); +} + +function numberArray(a, b) { + if (!b) b = []; + var n = a ? Math.min(b.length, a.length) : 0, + c = b.slice(), + i; + return function(t) { + for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t; + return c; + }; +} + +function isNumberArray(x) { + return ArrayBuffer.isView(x) && !(x instanceof DataView); +} + +function genericArray(a, b) { + var nb = b ? b.length : 0, + na = a ? Math.min(nb, a.length) : 0, + x = new Array(na), + c = new Array(nb), + i; + + for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]); + for (; i < nb; ++i) c[i] = b[i]; + + return function(t) { + for (i = 0; i < na; ++i) c[i] = x[i](t); + return c; + }; +} + +function date(a, b) { + var d = new Date; + return a = +a, b = +b, function(t) { + return d.setTime(a * (1 - t) + b * t), d; + }; +} + +function object(a, b) { + var i = {}, + c = {}, + k; + + if (a === null || typeof a !== "object") a = {}; + if (b === null || typeof b !== "object") b = {}; + + for (k in b) { + if (k in a) { + i[k] = interpolate(a[k], b[k]); + } else { + c[k] = b[k]; + } + } + + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; +} + +function interpolate(a, b) { + var t = typeof b, c; + return b == null || t === "boolean" ? constant(b) + : (t === "number" ? interpolateNumber + : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString) + : b instanceof color ? interpolateRgb + : b instanceof Date ? date + : isNumberArray(b) ? numberArray + : Array.isArray(b) ? genericArray + : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object + : interpolateNumber)(a, b); +} + +function interpolateRound(a, b) { + return a = +a, b = +b, function(t) { + return Math.round(a * (1 - t) + b * t); + }; +} + +function formatDecimal(x) { + return Math.abs(x = Math.round(x)) >= 1e21 + ? x.toLocaleString("en").replace(/,/g, "") + : x.toString(10); +} + +// Computes the decimal coefficient and exponent of the specified number x with +// significant digits p, where x is positive and p is in [1, 21] or undefined. +// For example, formatDecimalParts(1.23) returns ["123", 0]. +function formatDecimalParts(x, p) { + if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity + var i, coefficient = x.slice(0, i); + + // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ + // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). + return [ + coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, + +x.slice(i + 1) + ]; +} + +function exponent(x) { + return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN; +} + +function formatGroup(grouping, thousands) { + return function(value, width) { + var i = value.length, + t = [], + j = 0, + g = grouping[0], + length = 0; + + while (i > 0 && g > 0) { + if (length + g + 1 > width) g = Math.max(1, width - length); + t.push(value.substring(i -= g, i + g)); + if ((length += g + 1) > width) break; + g = grouping[j = (j + 1) % grouping.length]; + } + + return t.reverse().join(thousands); + }; +} + +function formatNumerals(numerals) { + return function(value) { + return value.replace(/[0-9]/g, function(i) { + return numerals[+i]; + }); + }; +} + +// [[fill]align][sign][symbol][0][width][,][.precision][~][type] +var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; + +function formatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + return new FormatSpecifier({ + fill: match[1], + align: match[2], + sign: match[3], + symbol: match[4], + zero: match[5], + width: match[6], + comma: match[7], + precision: match[8] && match[8].slice(1), + trim: match[9], + type: match[10] + }); +} + +formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof + +function FormatSpecifier(specifier) { + this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; + this.align = specifier.align === undefined ? ">" : specifier.align + ""; + this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; + this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; + this.zero = !!specifier.zero; + this.width = specifier.width === undefined ? undefined : +specifier.width; + this.comma = !!specifier.comma; + this.precision = specifier.precision === undefined ? undefined : +specifier.precision; + this.trim = !!specifier.trim; + this.type = specifier.type === undefined ? "" : specifier.type + ""; +} + +FormatSpecifier.prototype.toString = function() { + return this.fill + + this.align + + this.sign + + this.symbol + + (this.zero ? "0" : "") + + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + + (this.comma ? "," : "") + + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + + (this.trim ? "~" : "") + + this.type; +}; + +// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. +function formatTrim(s) { + out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { + switch (s[i]) { + case ".": i0 = i1 = i; break; + case "0": if (i0 === 0) i0 = i; i1 = i; break; + default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break; + } + } + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; +} + +var prefixExponent; + +function formatPrefixAuto(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1], + i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, + n = coefficient.length; + return i === n ? coefficient + : i > n ? coefficient + new Array(i - n + 1).join("0") + : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) + : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y! +} + +function formatRounded(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1]; + return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient + : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) + : coefficient + new Array(exponent - coefficient.length + 2).join("0"); +} + +var formatTypes = { + "%": (x, p) => (x * 100).toFixed(p), + "b": (x) => Math.round(x).toString(2), + "c": (x) => x + "", + "d": formatDecimal, + "e": (x, p) => x.toExponential(p), + "f": (x, p) => x.toFixed(p), + "g": (x, p) => x.toPrecision(p), + "o": (x) => Math.round(x).toString(8), + "p": (x, p) => formatRounded(x * 100, p), + "r": formatRounded, + "s": formatPrefixAuto, + "X": (x) => Math.round(x).toString(16).toUpperCase(), + "x": (x) => Math.round(x).toString(16) +}; + +function identity$1(x) { + return x; +} + +var map = Array.prototype.map, + prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; + +function formatLocale(locale) { + var group = locale.grouping === undefined || locale.thousands === undefined ? identity$1 : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""), + currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", + currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", + decimal = locale.decimal === undefined ? "." : locale.decimal + "", + numerals = locale.numerals === undefined ? identity$1 : formatNumerals(map.call(locale.numerals, String)), + percent = locale.percent === undefined ? "%" : locale.percent + "", + minus = locale.minus === undefined ? "−" : locale.minus + "", + nan = locale.nan === undefined ? "NaN" : locale.nan + ""; + + function newFormat(specifier) { + specifier = formatSpecifier(specifier); + + var fill = specifier.fill, + align = specifier.align, + sign = specifier.sign, + symbol = specifier.symbol, + zero = specifier.zero, + width = specifier.width, + comma = specifier.comma, + precision = specifier.precision, + trim = specifier.trim, + type = specifier.type; + + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + + // The "" type, and any invalid type, is an alias for ".12~g". + else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g"; + + // If zero fill is specified, padding goes after sign and before digits. + if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; + + // Compute the prefix and suffix. + // For SI-prefix, the suffix is lazily computed. + var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", + suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; + + // What format function should we use? + // Is this an integer type? + // Can this type generate exponential notation? + var formatType = formatTypes[type], + maybeSuffix = /[defgprs%]/.test(type); + + // Set the default precision if not specified, + // or clamp the specified precision to the supported range. + // For significant precision, it must be in [1, 21]. + // For fixed precision, it must be in [0, 20]. + precision = precision === undefined ? 6 + : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) + : Math.max(0, Math.min(20, precision)); + + function format(value) { + var valuePrefix = prefix, + valueSuffix = suffix, + i, n, c; + + if (type === "c") { + valueSuffix = formatType(value) + valueSuffix; + value = ""; + } else { + value = +value; + + // Determine the sign. -0 is not less than 0, but 1 / -0 is! + var valueNegative = value < 0 || 1 / value < 0; + + // Perform the initial formatting. + value = isNaN(value) ? nan : formatType(Math.abs(value), precision); + + // Trim insignificant zeros. + if (trim) value = formatTrim(value); + + // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. + if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; + + // Compute the prefix and suffix. + valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; + valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); + + // Break the formatted value into the integer “value” part that can be + // grouped, and fractional or exponential “suffix” part that is not. + if (maybeSuffix) { + i = -1, n = value.length; + while (++i < n) { + if (c = value.charCodeAt(i), 48 > c || c > 57) { + valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; + value = value.slice(0, i); + break; + } + } + } + } + + // If the fill character is not "0", grouping is applied before padding. + if (comma && !zero) value = group(value, Infinity); + + // Compute the padding. + var length = valuePrefix.length + value.length + valueSuffix.length, + padding = length < width ? new Array(width - length + 1).join(fill) : ""; + + // If the fill character is "0", grouping is applied after padding. + if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; + + // Reconstruct the final output based on the desired alignment. + switch (align) { + case "<": value = valuePrefix + value + valueSuffix + padding; break; + case "=": value = valuePrefix + padding + value + valueSuffix; break; + case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; + default: value = padding + valuePrefix + value + valueSuffix; break; + } + + return numerals(value); + } + + format.toString = function() { + return specifier + ""; + }; + + return format; + } + + function formatPrefix(specifier, value) { + var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), + e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, + k = Math.pow(10, -e), + prefix = prefixes[8 + e / 3]; + return function(value) { + return f(k * value) + prefix; + }; + } + + return { + format: newFormat, + formatPrefix: formatPrefix + }; +} + +var locale; +var format; +var formatPrefix; + +defaultLocale({ + thousands: ",", + grouping: [3], + currency: ["$", ""] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + format = locale.format; + formatPrefix = locale.formatPrefix; + return locale; +} + +function precisionFixed(step) { + return Math.max(0, -exponent(Math.abs(step))); +} + +function precisionPrefix(step, value) { + return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step))); +} + +function precisionRound(step, max) { + step = Math.abs(step), max = Math.abs(max) - step; + return Math.max(0, exponent(max) - exponent(step)) + 1; +} + +function constants(x) { + return function() { + return x; + }; +} + +function number(x) { + return +x; +} + +var unit = [0, 1]; + +function identity(x) { + return x; +} + +function normalize(a, b) { + return (b -= (a = +a)) + ? function(x) { return (x - a) / b; } + : constants(isNaN(b) ? NaN : 0.5); +} + +function clamper(a, b) { + var t; + if (a > b) t = a, a = b, b = t; + return function(x) { return Math.max(a, Math.min(b, x)); }; +} + +// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. +// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b]. +function bimap(domain, range, interpolate) { + var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; + if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); + else d0 = normalize(d0, d1), r0 = interpolate(r0, r1); + return function(x) { return r0(d0(x)); }; +} + +function polymap(domain, range, interpolate) { + var j = Math.min(domain.length, range.length) - 1, + d = new Array(j), + r = new Array(j), + i = -1; + + // Reverse descending domains. + if (domain[j] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + + while (++i < j) { + d[i] = normalize(domain[i], domain[i + 1]); + r[i] = interpolate(range[i], range[i + 1]); + } + + return function(x) { + var i = bisectRight(domain, x, 1, j) - 1; + return r[i](d[i](x)); + }; +} + +function copy(source, target) { + return target + .domain(source.domain()) + .range(source.range()) + .interpolate(source.interpolate()) + .clamp(source.clamp()) + .unknown(source.unknown()); +} + +function transformer() { + var domain = unit, + range = unit, + interpolate$1 = interpolate, + transform, + untransform, + unknown, + clamp = identity, + piecewise, + output, + input; + + function rescale() { + var n = Math.min(domain.length, range.length); + if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]); + piecewise = n > 2 ? polymap : bimap; + output = input = null; + return scale; + } + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x))); + } + + scale.invert = function(y) { + return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y))); + }; + + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice(); + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + + scale.rangeRound = function(_) { + return range = Array.from(_), interpolate$1 = interpolateRound, rescale(); + }; + + scale.clamp = function(_) { + return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity; + }; + + scale.interpolate = function(_) { + return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1; + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + return function(t, u) { + transform = t, untransform = u; + return rescale(); + }; +} + +function continuous() { + return transformer()(identity, identity); +} + +function tickFormat(start, stop, count, specifier) { + var step = tickStep(start, stop, count), + precision; + specifier = formatSpecifier(specifier == null ? ",f" : specifier); + switch (specifier.type) { + case "s": { + var value = Math.max(Math.abs(start), Math.abs(stop)); + if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision; + return formatPrefix(specifier, value); + } + case "": + case "e": + case "g": + case "p": + case "r": { + if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); + break; + } + case "f": + case "%": { + if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2; + break; + } + } + return format(specifier); +} + +function linearish(scale) { + var domain = scale.domain; + + scale.ticks = function(count) { + var d = domain(); + return ticks(d[0], d[d.length - 1], count == null ? 10 : count); + }; + + scale.tickFormat = function(count, specifier) { + var d = domain(); + return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier); + }; + + scale.nice = function(count) { + if (count == null) count = 10; + + var d = domain(); + var i0 = 0; + var i1 = d.length - 1; + var start = d[i0]; + var stop = d[i1]; + var prestep; + var step; + var maxIter = 10; + + if (stop < start) { + step = start, start = stop, stop = step; + step = i0, i0 = i1, i1 = step; + } + + while (maxIter-- > 0) { + step = tickIncrement(start, stop, count); + if (step === prestep) { + d[i0] = start; + d[i1] = stop; + return domain(d); + } else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; + } else { + break; + } + prestep = step; + } + + return scale; + }; + + return scale; +} + +function linear() { + var scale = continuous(); + + scale.copy = function() { + return copy(scale, linear()); + }; + + initRange.apply(scale, arguments); + + return linearish(scale); +} + +export { copy as a, bisector as b, continuous as c, linear as l, tickStep as t }; diff --git a/libs/marked/linear-DNP-QGmo.js b/libs/marked/linear-DNP-QGmo.js new file mode 100644 index 0000000..1b3027e --- /dev/null +++ b/libs/marked/linear-DNP-QGmo.js @@ -0,0 +1,764 @@ +import { $ as constant, a0 as interpolateNumber, a1 as color, a2 as interpolateRgb, a3 as interpolateString } from './index-Bd_FDXSq.js'; +import { i as initRange } from './init-zpY4DTin.js'; + +function ascending(a, b) { + return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +function descending(a, b) { + return a == null || b == null ? NaN + : b < a ? -1 + : b > a ? 1 + : b >= a ? 0 + : NaN; +} + +function bisector(f) { + let compare1, compare2, delta; + + // If an accessor is specified, promote it to a comparator. In this case we + // can test whether the search value is (self-) comparable. We can’t do this + // for a comparator (except for specific, known comparators) because we can’t + // tell if the comparator is symmetric, and an asymmetric comparator can’t be + // used to test whether a single value is comparable. + if (f.length !== 2) { + compare1 = ascending; + compare2 = (d, x) => ascending(f(d), x); + delta = (d, x) => f(d) - x; + } else { + compare1 = f === ascending || f === descending ? f : zero; + compare2 = f; + delta = f; + } + + function left(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) < 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function right(a, x, lo = 0, hi = a.length) { + if (lo < hi) { + if (compare1(x, x) !== 0) return hi; + do { + const mid = (lo + hi) >>> 1; + if (compare2(a[mid], x) <= 0) lo = mid + 1; + else hi = mid; + } while (lo < hi); + } + return lo; + } + + function center(a, x, lo = 0, hi = a.length) { + const i = left(a, x, lo, hi - 1); + return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i; + } + + return {left, center, right}; +} + +function zero() { + return 0; +} + +function number$1(x) { + return x === null ? NaN : +x; +} + +const ascendingBisect = bisector(ascending); +const bisectRight = ascendingBisect.right; +bisector(number$1).center; + +const e10 = Math.sqrt(50), + e5 = Math.sqrt(10), + e2 = Math.sqrt(2); + +function tickSpec(start, stop, count) { + const step = (stop - start) / Math.max(0, count), + power = Math.floor(Math.log10(step)), + error = step / Math.pow(10, power), + factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1; + let i1, i2, inc; + if (power < 0) { + inc = Math.pow(10, -power) / factor; + i1 = Math.round(start * inc); + i2 = Math.round(stop * inc); + if (i1 / inc < start) ++i1; + if (i2 / inc > stop) --i2; + inc = -inc; + } else { + inc = Math.pow(10, power) * factor; + i1 = Math.round(start / inc); + i2 = Math.round(stop / inc); + if (i1 * inc < start) ++i1; + if (i2 * inc > stop) --i2; + } + if (i2 < i1 && 0.5 <= count && count < 2) return tickSpec(start, stop, count * 2); + return [i1, i2, inc]; +} + +function ticks(start, stop, count) { + stop = +stop, start = +start, count = +count; + if (!(count > 0)) return []; + if (start === stop) return [start]; + const reverse = stop < start, [i1, i2, inc] = reverse ? tickSpec(stop, start, count) : tickSpec(start, stop, count); + if (!(i2 >= i1)) return []; + const n = i2 - i1 + 1, ticks = new Array(n); + if (reverse) { + if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) / -inc; + else for (let i = 0; i < n; ++i) ticks[i] = (i2 - i) * inc; + } else { + if (inc < 0) for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) / -inc; + else for (let i = 0; i < n; ++i) ticks[i] = (i1 + i) * inc; + } + return ticks; +} + +function tickIncrement(start, stop, count) { + stop = +stop, start = +start, count = +count; + return tickSpec(start, stop, count)[2]; +} + +function tickStep(start, stop, count) { + stop = +stop, start = +start, count = +count; + const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count); + return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc); +} + +function numberArray(a, b) { + if (!b) b = []; + var n = a ? Math.min(b.length, a.length) : 0, + c = b.slice(), + i; + return function(t) { + for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t; + return c; + }; +} + +function isNumberArray(x) { + return ArrayBuffer.isView(x) && !(x instanceof DataView); +} + +function genericArray(a, b) { + var nb = b ? b.length : 0, + na = a ? Math.min(nb, a.length) : 0, + x = new Array(na), + c = new Array(nb), + i; + + for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]); + for (; i < nb; ++i) c[i] = b[i]; + + return function(t) { + for (i = 0; i < na; ++i) c[i] = x[i](t); + return c; + }; +} + +function date(a, b) { + var d = new Date; + return a = +a, b = +b, function(t) { + return d.setTime(a * (1 - t) + b * t), d; + }; +} + +function object(a, b) { + var i = {}, + c = {}, + k; + + if (a === null || typeof a !== "object") a = {}; + if (b === null || typeof b !== "object") b = {}; + + for (k in b) { + if (k in a) { + i[k] = interpolate(a[k], b[k]); + } else { + c[k] = b[k]; + } + } + + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; +} + +function interpolate(a, b) { + var t = typeof b, c; + return b == null || t === "boolean" ? constant(b) + : (t === "number" ? interpolateNumber + : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString) + : b instanceof color ? interpolateRgb + : b instanceof Date ? date + : isNumberArray(b) ? numberArray + : Array.isArray(b) ? genericArray + : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object + : interpolateNumber)(a, b); +} + +function interpolateRound(a, b) { + return a = +a, b = +b, function(t) { + return Math.round(a * (1 - t) + b * t); + }; +} + +function formatDecimal(x) { + return Math.abs(x = Math.round(x)) >= 1e21 + ? x.toLocaleString("en").replace(/,/g, "") + : x.toString(10); +} + +// Computes the decimal coefficient and exponent of the specified number x with +// significant digits p, where x is positive and p is in [1, 21] or undefined. +// For example, formatDecimalParts(1.23) returns ["123", 0]. +function formatDecimalParts(x, p) { + if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity + var i, coefficient = x.slice(0, i); + + // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ + // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). + return [ + coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, + +x.slice(i + 1) + ]; +} + +function exponent(x) { + return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN; +} + +function formatGroup(grouping, thousands) { + return function(value, width) { + var i = value.length, + t = [], + j = 0, + g = grouping[0], + length = 0; + + while (i > 0 && g > 0) { + if (length + g + 1 > width) g = Math.max(1, width - length); + t.push(value.substring(i -= g, i + g)); + if ((length += g + 1) > width) break; + g = grouping[j = (j + 1) % grouping.length]; + } + + return t.reverse().join(thousands); + }; +} + +function formatNumerals(numerals) { + return function(value) { + return value.replace(/[0-9]/g, function(i) { + return numerals[+i]; + }); + }; +} + +// [[fill]align][sign][symbol][0][width][,][.precision][~][type] +var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; + +function formatSpecifier(specifier) { + if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); + var match; + return new FormatSpecifier({ + fill: match[1], + align: match[2], + sign: match[3], + symbol: match[4], + zero: match[5], + width: match[6], + comma: match[7], + precision: match[8] && match[8].slice(1), + trim: match[9], + type: match[10] + }); +} + +formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof + +function FormatSpecifier(specifier) { + this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; + this.align = specifier.align === undefined ? ">" : specifier.align + ""; + this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; + this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; + this.zero = !!specifier.zero; + this.width = specifier.width === undefined ? undefined : +specifier.width; + this.comma = !!specifier.comma; + this.precision = specifier.precision === undefined ? undefined : +specifier.precision; + this.trim = !!specifier.trim; + this.type = specifier.type === undefined ? "" : specifier.type + ""; +} + +FormatSpecifier.prototype.toString = function() { + return this.fill + + this.align + + this.sign + + this.symbol + + (this.zero ? "0" : "") + + (this.width === undefined ? "" : Math.max(1, this.width | 0)) + + (this.comma ? "," : "") + + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) + + (this.trim ? "~" : "") + + this.type; +}; + +// Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. +function formatTrim(s) { + out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { + switch (s[i]) { + case ".": i0 = i1 = i; break; + case "0": if (i0 === 0) i0 = i; i1 = i; break; + default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break; + } + } + return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; +} + +var prefixExponent; + +function formatPrefixAuto(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1], + i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, + n = coefficient.length; + return i === n ? coefficient + : i > n ? coefficient + new Array(i - n + 1).join("0") + : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) + : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y! +} + +function formatRounded(x, p) { + var d = formatDecimalParts(x, p); + if (!d) return x + ""; + var coefficient = d[0], + exponent = d[1]; + return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient + : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) + : coefficient + new Array(exponent - coefficient.length + 2).join("0"); +} + +var formatTypes = { + "%": (x, p) => (x * 100).toFixed(p), + "b": (x) => Math.round(x).toString(2), + "c": (x) => x + "", + "d": formatDecimal, + "e": (x, p) => x.toExponential(p), + "f": (x, p) => x.toFixed(p), + "g": (x, p) => x.toPrecision(p), + "o": (x) => Math.round(x).toString(8), + "p": (x, p) => formatRounded(x * 100, p), + "r": formatRounded, + "s": formatPrefixAuto, + "X": (x) => Math.round(x).toString(16).toUpperCase(), + "x": (x) => Math.round(x).toString(16) +}; + +function identity$1(x) { + return x; +} + +var map = Array.prototype.map, + prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; + +function formatLocale(locale) { + var group = locale.grouping === undefined || locale.thousands === undefined ? identity$1 : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""), + currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", + currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", + decimal = locale.decimal === undefined ? "." : locale.decimal + "", + numerals = locale.numerals === undefined ? identity$1 : formatNumerals(map.call(locale.numerals, String)), + percent = locale.percent === undefined ? "%" : locale.percent + "", + minus = locale.minus === undefined ? "−" : locale.minus + "", + nan = locale.nan === undefined ? "NaN" : locale.nan + ""; + + function newFormat(specifier) { + specifier = formatSpecifier(specifier); + + var fill = specifier.fill, + align = specifier.align, + sign = specifier.sign, + symbol = specifier.symbol, + zero = specifier.zero, + width = specifier.width, + comma = specifier.comma, + precision = specifier.precision, + trim = specifier.trim, + type = specifier.type; + + // The "n" type is an alias for ",g". + if (type === "n") comma = true, type = "g"; + + // The "" type, and any invalid type, is an alias for ".12~g". + else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g"; + + // If zero fill is specified, padding goes after sign and before digits. + if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; + + // Compute the prefix and suffix. + // For SI-prefix, the suffix is lazily computed. + var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", + suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : ""; + + // What format function should we use? + // Is this an integer type? + // Can this type generate exponential notation? + var formatType = formatTypes[type], + maybeSuffix = /[defgprs%]/.test(type); + + // Set the default precision if not specified, + // or clamp the specified precision to the supported range. + // For significant precision, it must be in [1, 21]. + // For fixed precision, it must be in [0, 20]. + precision = precision === undefined ? 6 + : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) + : Math.max(0, Math.min(20, precision)); + + function format(value) { + var valuePrefix = prefix, + valueSuffix = suffix, + i, n, c; + + if (type === "c") { + valueSuffix = formatType(value) + valueSuffix; + value = ""; + } else { + value = +value; + + // Determine the sign. -0 is not less than 0, but 1 / -0 is! + var valueNegative = value < 0 || 1 / value < 0; + + // Perform the initial formatting. + value = isNaN(value) ? nan : formatType(Math.abs(value), precision); + + // Trim insignificant zeros. + if (trim) value = formatTrim(value); + + // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. + if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; + + // Compute the prefix and suffix. + valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; + valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); + + // Break the formatted value into the integer “value” part that can be + // grouped, and fractional or exponential “suffix” part that is not. + if (maybeSuffix) { + i = -1, n = value.length; + while (++i < n) { + if (c = value.charCodeAt(i), 48 > c || c > 57) { + valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; + value = value.slice(0, i); + break; + } + } + } + } + + // If the fill character is not "0", grouping is applied before padding. + if (comma && !zero) value = group(value, Infinity); + + // Compute the padding. + var length = valuePrefix.length + value.length + valueSuffix.length, + padding = length < width ? new Array(width - length + 1).join(fill) : ""; + + // If the fill character is "0", grouping is applied after padding. + if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; + + // Reconstruct the final output based on the desired alignment. + switch (align) { + case "<": value = valuePrefix + value + valueSuffix + padding; break; + case "=": value = valuePrefix + padding + value + valueSuffix; break; + case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; + default: value = padding + valuePrefix + value + valueSuffix; break; + } + + return numerals(value); + } + + format.toString = function() { + return specifier + ""; + }; + + return format; + } + + function formatPrefix(specifier, value) { + var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), + e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, + k = Math.pow(10, -e), + prefix = prefixes[8 + e / 3]; + return function(value) { + return f(k * value) + prefix; + }; + } + + return { + format: newFormat, + formatPrefix: formatPrefix + }; +} + +var locale; +var format; +var formatPrefix; + +defaultLocale({ + thousands: ",", + grouping: [3], + currency: ["$", ""] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + format = locale.format; + formatPrefix = locale.formatPrefix; + return locale; +} + +function precisionFixed(step) { + return Math.max(0, -exponent(Math.abs(step))); +} + +function precisionPrefix(step, value) { + return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step))); +} + +function precisionRound(step, max) { + step = Math.abs(step), max = Math.abs(max) - step; + return Math.max(0, exponent(max) - exponent(step)) + 1; +} + +function constants(x) { + return function() { + return x; + }; +} + +function number(x) { + return +x; +} + +var unit = [0, 1]; + +function identity(x) { + return x; +} + +function normalize(a, b) { + return (b -= (a = +a)) + ? function(x) { return (x - a) / b; } + : constants(isNaN(b) ? NaN : 0.5); +} + +function clamper(a, b) { + var t; + if (a > b) t = a, a = b, b = t; + return function(x) { return Math.max(a, Math.min(b, x)); }; +} + +// normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. +// interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b]. +function bimap(domain, range, interpolate) { + var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1]; + if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0); + else d0 = normalize(d0, d1), r0 = interpolate(r0, r1); + return function(x) { return r0(d0(x)); }; +} + +function polymap(domain, range, interpolate) { + var j = Math.min(domain.length, range.length) - 1, + d = new Array(j), + r = new Array(j), + i = -1; + + // Reverse descending domains. + if (domain[j] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + + while (++i < j) { + d[i] = normalize(domain[i], domain[i + 1]); + r[i] = interpolate(range[i], range[i + 1]); + } + + return function(x) { + var i = bisectRight(domain, x, 1, j) - 1; + return r[i](d[i](x)); + }; +} + +function copy(source, target) { + return target + .domain(source.domain()) + .range(source.range()) + .interpolate(source.interpolate()) + .clamp(source.clamp()) + .unknown(source.unknown()); +} + +function transformer() { + var domain = unit, + range = unit, + interpolate$1 = interpolate, + transform, + untransform, + unknown, + clamp = identity, + piecewise, + output, + input; + + function rescale() { + var n = Math.min(domain.length, range.length); + if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]); + piecewise = n > 2 ? polymap : bimap; + output = input = null; + return scale; + } + + function scale(x) { + return x == null || isNaN(x = +x) ? unknown : (output || (output = piecewise(domain.map(transform), range, interpolate$1)))(transform(clamp(x))); + } + + scale.invert = function(y) { + return clamp(untransform((input || (input = piecewise(range, domain.map(transform), interpolateNumber)))(y))); + }; + + scale.domain = function(_) { + return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice(); + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), rescale()) : range.slice(); + }; + + scale.rangeRound = function(_) { + return range = Array.from(_), interpolate$1 = interpolateRound, rescale(); + }; + + scale.clamp = function(_) { + return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity; + }; + + scale.interpolate = function(_) { + return arguments.length ? (interpolate$1 = _, rescale()) : interpolate$1; + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + return function(t, u) { + transform = t, untransform = u; + return rescale(); + }; +} + +function continuous() { + return transformer()(identity, identity); +} + +function tickFormat(start, stop, count, specifier) { + var step = tickStep(start, stop, count), + precision; + specifier = formatSpecifier(specifier == null ? ",f" : specifier); + switch (specifier.type) { + case "s": { + var value = Math.max(Math.abs(start), Math.abs(stop)); + if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) specifier.precision = precision; + return formatPrefix(specifier, value); + } + case "": + case "e": + case "g": + case "p": + case "r": { + if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e"); + break; + } + case "f": + case "%": { + if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2; + break; + } + } + return format(specifier); +} + +function linearish(scale) { + var domain = scale.domain; + + scale.ticks = function(count) { + var d = domain(); + return ticks(d[0], d[d.length - 1], count == null ? 10 : count); + }; + + scale.tickFormat = function(count, specifier) { + var d = domain(); + return tickFormat(d[0], d[d.length - 1], count == null ? 10 : count, specifier); + }; + + scale.nice = function(count) { + if (count == null) count = 10; + + var d = domain(); + var i0 = 0; + var i1 = d.length - 1; + var start = d[i0]; + var stop = d[i1]; + var prestep; + var step; + var maxIter = 10; + + if (stop < start) { + step = start, start = stop, stop = step; + step = i0, i0 = i1, i1 = step; + } + + while (maxIter-- > 0) { + step = tickIncrement(start, stop, count); + if (step === prestep) { + d[i0] = start; + d[i1] = stop; + return domain(d); + } else if (step > 0) { + start = Math.floor(start / step) * step; + stop = Math.ceil(stop / step) * step; + } else if (step < 0) { + start = Math.ceil(start * step) / step; + stop = Math.floor(stop * step) / step; + } else { + break; + } + prestep = step; + } + + return scale; + }; + + return scale; +} + +function linear() { + var scale = continuous(); + + scale.copy = function() { + return copy(scale, linear()); + }; + + initRange.apply(scale, arguments); + + return linearish(scale); +} + +export { copy as a, bisector as b, continuous as c, linear as l, tickStep as t }; diff --git a/libs/marked/mindmap-definition-307c710a-CVAgfJ2r.js b/libs/marked/mindmap-definition-307c710a-CVAgfJ2r.js new file mode 100644 index 0000000..5104990 --- /dev/null +++ b/libs/marked/mindmap-definition-307c710a-CVAgfJ2r.js @@ -0,0 +1,38625 @@ +import { P as commonjsGlobal$1, Q as getDefaultExportFromCjs, l as log$1, c as getConfig, U as selectSvgElement, t as setupGraphViewbox$1, W as defaultConfig$2, d as sanitizeText$2, h as select, as as isDark, at as lighten, au as darken, Y as parseFontSize } from './index-CN3YjQ0n.js'; +import { a as createText } from './createText-ca0c5216-DF05SDfj.js'; + +/** + * Copyright (c) 2016-2024, The Cytoscape Consortium. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the “Software”), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +function _typeof(obj) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); +} +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; +} +function _defineProperty$1(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} +function _iterableToArrayLimit(arr, i) { + var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; + if (_i == null) return; + var _arr = []; + var _n = true; + var _d = false; + var _s, _e; + try { + for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; +} +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +function _createForOfIteratorHelper(o, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; + if (!it) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { + if (it) o = it; + var i = 0; + var F = function () {}; + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = it.call(o); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +var _window = typeof window === 'undefined' ? null : window; // eslint-disable-line no-undef + +var navigator = _window ? _window.navigator : null; +_window ? _window.document : null; +var typeofstr = _typeof(''); +var typeofobj = _typeof({}); +var typeoffn = _typeof(function () {}); +var typeofhtmlele = typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement); +var instanceStr = function instanceStr(obj) { + return obj && obj.instanceString && fn$6(obj.instanceString) ? obj.instanceString() : null; +}; + +var string = function string(obj) { + return obj != null && _typeof(obj) == typeofstr; +}; +var fn$6 = function fn(obj) { + return obj != null && _typeof(obj) === typeoffn; +}; +var array = function array(obj) { + return !elementOrCollection(obj) && (Array.isArray ? Array.isArray(obj) : obj != null && obj instanceof Array); +}; +var plainObject = function plainObject(obj) { + return obj != null && _typeof(obj) === typeofobj && !array(obj) && obj.constructor === Object; +}; +var object = function object(obj) { + return obj != null && _typeof(obj) === typeofobj; +}; +var number$1 = function number(obj) { + return obj != null && _typeof(obj) === _typeof(1) && !isNaN(obj); +}; +var integer = function integer(obj) { + return number$1(obj) && Math.floor(obj) === obj; +}; +var htmlElement = function htmlElement(obj) { + if ('undefined' === typeofhtmlele) { + return undefined; + } else { + return null != obj && obj instanceof HTMLElement; + } +}; +var elementOrCollection = function elementOrCollection(obj) { + return element(obj) || collection(obj); +}; +var element = function element(obj) { + return instanceStr(obj) === 'collection' && obj._private.single; +}; +var collection = function collection(obj) { + return instanceStr(obj) === 'collection' && !obj._private.single; +}; +var core = function core(obj) { + return instanceStr(obj) === 'core'; +}; +var stylesheet = function stylesheet(obj) { + return instanceStr(obj) === 'stylesheet'; +}; +var event = function event(obj) { + return instanceStr(obj) === 'event'; +}; +var emptyString = function emptyString(obj) { + if (obj === undefined || obj === null) { + // null is empty + return true; + } else if (obj === '' || obj.match(/^\s+$/)) { + return true; // empty string is empty + } + + return false; // otherwise, we don't know what we've got +}; +var domElement = function domElement(obj) { + if (typeof HTMLElement === 'undefined') { + return false; // we're not in a browser so it doesn't matter + } else { + return obj instanceof HTMLElement; + } +}; +var boundingBox = function boundingBox(obj) { + return plainObject(obj) && number$1(obj.x1) && number$1(obj.x2) && number$1(obj.y1) && number$1(obj.y2); +}; +var promise = function promise(obj) { + return object(obj) && fn$6(obj.then); +}; +var ms = function ms() { + return navigator && navigator.userAgent.match(/msie|trident|edge/i); +}; // probably a better way to detect this... + +var memoize$1 = function memoize(fn, keyFn) { + if (!keyFn) { + keyFn = function keyFn() { + if (arguments.length === 1) { + return arguments[0]; + } else if (arguments.length === 0) { + return 'undefined'; + } + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + return args.join('$'); + }; + } + var memoizedFn = function memoizedFn() { + var self = this; + var args = arguments; + var ret; + var k = keyFn.apply(self, args); + var cache = memoizedFn.cache; + if (!(ret = cache[k])) { + ret = cache[k] = fn.apply(self, args); + } + return ret; + }; + memoizedFn.cache = {}; + return memoizedFn; +}; + +var camel2dash = memoize$1(function (str) { + return str.replace(/([A-Z])/g, function (v) { + return '-' + v.toLowerCase(); + }); +}); +var dash2camel = memoize$1(function (str) { + return str.replace(/(-\w)/g, function (v) { + return v[1].toUpperCase(); + }); +}); +var prependCamel = memoize$1(function (prefix, str) { + return prefix + str[0].toUpperCase() + str.substring(1); +}, function (prefix, str) { + return prefix + '$' + str; +}); +var capitalize = function capitalize(str) { + if (emptyString(str)) { + return str; + } + return str.charAt(0).toUpperCase() + str.substring(1); +}; + +var number = '(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))'; +var rgba = 'rgb[a]?\\((' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)(?:\\s*,\\s*(' + number + '))?\\)'; +var rgbaNoBackRefs = 'rgb[a]?\\((?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)(?:\\s*,\\s*(?:' + number + '))?\\)'; +var hsla = 'hsl[a]?\\((' + number + ')\\s*,\\s*(' + number + '[%])\\s*,\\s*(' + number + '[%])(?:\\s*,\\s*(' + number + '))?\\)'; +var hslaNoBackRefs = 'hsl[a]?\\((?:' + number + ')\\s*,\\s*(?:' + number + '[%])\\s*,\\s*(?:' + number + '[%])(?:\\s*,\\s*(?:' + number + '))?\\)'; +var hex3 = '\\#[0-9a-fA-F]{3}'; +var hex6 = '\\#[0-9a-fA-F]{6}'; + +var ascending = function ascending(a, b) { + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } +}; +var descending = function descending(a, b) { + return -1 * ascending(a, b); +}; + +var extend = Object.assign != null ? Object.assign.bind(Object) : function (tgt) { + var args = arguments; + for (var i = 1; i < args.length; i++) { + var obj = args[i]; + if (obj == null) { + continue; + } + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; j++) { + var k = keys[j]; + tgt[k] = obj[k]; + } + } + return tgt; +}; + +// get [r, g, b] from #abc or #aabbcc +var hex2tuple = function hex2tuple(hex) { + if (!(hex.length === 4 || hex.length === 7) || hex[0] !== '#') { + return; + } + var shortHex = hex.length === 4; + var r, g, b; + var base = 16; + if (shortHex) { + r = parseInt(hex[1] + hex[1], base); + g = parseInt(hex[2] + hex[2], base); + b = parseInt(hex[3] + hex[3], base); + } else { + r = parseInt(hex[1] + hex[2], base); + g = parseInt(hex[3] + hex[4], base); + b = parseInt(hex[5] + hex[6], base); + } + return [r, g, b]; +}; + +// get [r, g, b, a] from hsl(0, 0, 0) or hsla(0, 0, 0, 0) +var hsl2tuple = function hsl2tuple(hsl) { + var ret; + var h, s, l, a, r, g, b; + function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; + return p; + } + var m = new RegExp('^' + hsla + '$').exec(hsl); + if (m) { + // get hue + h = parseInt(m[1]); + if (h < 0) { + h = (360 - -1 * h % 360) % 360; + } else if (h > 360) { + h = h % 360; + } + h /= 360; // normalise on [0, 1] + + s = parseFloat(m[2]); + if (s < 0 || s > 100) { + return; + } // saturation is [0, 100] + s = s / 100; // normalise on [0, 1] + + l = parseFloat(m[3]); + if (l < 0 || l > 100) { + return; + } // lightness is [0, 100] + l = l / 100; // normalise on [0, 1] + + a = m[4]; + if (a !== undefined) { + a = parseFloat(a); + if (a < 0 || a > 1) { + return; + } // alpha is [0, 1] + } + + // now, convert to rgb + // code from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript + if (s === 0) { + r = g = b = Math.round(l * 255); // achromatic + } else { + var q = l < 0.5 ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + r = Math.round(255 * hue2rgb(p, q, h + 1 / 3)); + g = Math.round(255 * hue2rgb(p, q, h)); + b = Math.round(255 * hue2rgb(p, q, h - 1 / 3)); + } + ret = [r, g, b, a]; + } + return ret; +}; + +// get [r, g, b, a] from rgb(0, 0, 0) or rgba(0, 0, 0, 0) +var rgb2tuple = function rgb2tuple(rgb) { + var ret; + var m = new RegExp('^' + rgba + '$').exec(rgb); + if (m) { + ret = []; + var isPct = []; + for (var i = 1; i <= 3; i++) { + var channel = m[i]; + if (channel[channel.length - 1] === '%') { + isPct[i] = true; + } + channel = parseFloat(channel); + if (isPct[i]) { + channel = channel / 100 * 255; // normalise to [0, 255] + } + + if (channel < 0 || channel > 255) { + return; + } // invalid channel value + + ret.push(Math.floor(channel)); + } + var atLeastOneIsPct = isPct[1] || isPct[2] || isPct[3]; + var allArePct = isPct[1] && isPct[2] && isPct[3]; + if (atLeastOneIsPct && !allArePct) { + return; + } // must all be percent values if one is + + var alpha = m[4]; + if (alpha !== undefined) { + alpha = parseFloat(alpha); + if (alpha < 0 || alpha > 1) { + return; + } // invalid alpha value + + ret.push(alpha); + } + } + return ret; +}; +var colorname2tuple = function colorname2tuple(color) { + return colors[color.toLowerCase()]; +}; +var color2tuple = function color2tuple(color) { + return (array(color) ? color : null) || colorname2tuple(color) || hex2tuple(color) || rgb2tuple(color) || hsl2tuple(color); +}; +var colors = { + // special colour names + transparent: [0, 0, 0, 0], + // NB alpha === 0 + + // regular colours + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + grey: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] +}; + +// sets the value in a map (map may not be built) +var setMap = function setMap(options) { + var obj = options.map; + var keys = options.keys; + var l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (plainObject(key)) { + throw Error('Tried to set map with object key'); + } + if (i < keys.length - 1) { + // extend the map if necessary + if (obj[key] == null) { + obj[key] = {}; + } + obj = obj[key]; + } else { + // set the value + obj[key] = options.value; + } + } +}; + +// gets the value in a map even if it's not built in places +var getMap = function getMap(options) { + var obj = options.map; + var keys = options.keys; + var l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (plainObject(key)) { + throw Error('Tried to get map with object key'); + } + obj = obj[key]; + if (obj == null) { + return obj; + } + } + return obj; +}; + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +var isObject_1 = isObject; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + +var _freeGlobal = freeGlobal; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = _freeGlobal || freeSelf || Function('return this')(); + +var _root = root; + +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ +var now = function() { + return _root.Date.now(); +}; + +var now_1 = now; + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +var _trimmedEndIndex = trimmedEndIndex; + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +var _baseTrim = baseTrim; + +/** Built-in value references. */ +var Symbol$1 = _root.Symbol; + +var _Symbol = Symbol$1; + +/** Used for built-in method references. */ +var objectProto$5 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$4 = objectProto$5.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$5.toString; + +/** Built-in value references. */ +var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString$1.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +var _getRawTag = getRawTag; + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto$4.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +var _objectToString = objectToString; + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? _getRawTag(value) + : _objectToString(value); +} + +var _baseGetTag = baseGetTag; + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +var isObjectLike_1 = isObjectLike; + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike_1(value) && _baseGetTag(value) == symbolTag); +} + +var isSymbol_1 = isSymbol; + +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol_1(value)) { + return NAN; + } + if (isObject_1(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject_1(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = _baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); +} + +var toNumber_1 = toNumber; + +/** Error message constants. */ +var FUNC_ERROR_TEXT$1 = 'Expected a function'; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max, + nativeMin = Math.min; + +/** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ +function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$1); + } + wait = toNumber_1(wait) || 0; + if (isObject_1(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } + + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; + + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now_1(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } + + function trailingEdge(time) { + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } + + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } + + function flush() { + return timerId === undefined ? result : trailingEdge(now_1()); + } + + function debounced() { + var time = now_1(), + isInvoking = shouldInvoke(time); + + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; +} + +var debounce_1 = debounce; + +var performance = _window ? _window.performance : null; +var pnow = performance && performance.now ? function () { + return performance.now(); +} : function () { + return Date.now(); +}; +var raf = function () { + if (_window) { + if (_window.requestAnimationFrame) { + return function (fn) { + _window.requestAnimationFrame(fn); + }; + } else if (_window.mozRequestAnimationFrame) { + return function (fn) { + _window.mozRequestAnimationFrame(fn); + }; + } else if (_window.webkitRequestAnimationFrame) { + return function (fn) { + _window.webkitRequestAnimationFrame(fn); + }; + } else if (_window.msRequestAnimationFrame) { + return function (fn) { + _window.msRequestAnimationFrame(fn); + }; + } + } + return function (fn) { + if (fn) { + setTimeout(function () { + fn(pnow()); + }, 1000 / 60); + } + }; +}(); +var requestAnimationFrame$1 = function requestAnimationFrame(fn) { + return raf(fn); +}; +var performanceNow = pnow; + +var DEFAULT_HASH_SEED = 9261; +var K = 65599; // 37 also works pretty well +var DEFAULT_HASH_SEED_ALT = 5381; +var hashIterableInts = function hashIterableInts(iterator) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED; + // sdbm/string-hash + var hash = seed; + var entry; + for (;;) { + entry = iterator.next(); + if (entry.done) { + break; + } + hash = hash * K + entry.value | 0; + } + return hash; +}; +var hashInt = function hashInt(num) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED; + // sdbm/string-hash + return seed * K + num | 0; +}; +var hashIntAlt = function hashIntAlt(num) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED_ALT; + // djb2/string-hash + return (seed << 5) + seed + num | 0; +}; +var combineHashes = function combineHashes(hash1, hash2) { + return hash1 * 0x200000 + hash2; +}; +var combineHashesArray = function combineHashesArray(hashes) { + return hashes[0] * 0x200000 + hashes[1]; +}; +var hashArrays = function hashArrays(hashes1, hashes2) { + return [hashInt(hashes1[0], hashes2[0]), hashIntAlt(hashes1[1], hashes2[1])]; +}; +var hashIntsArray = function hashIntsArray(ints, seed) { + var entry = { + value: 0, + done: false + }; + var i = 0; + var length = ints.length; + var iterator = { + next: function next() { + if (i < length) { + entry.value = ints[i++]; + } else { + entry.done = true; + } + return entry; + } + }; + return hashIterableInts(iterator, seed); +}; +var hashString = function hashString(str, seed) { + var entry = { + value: 0, + done: false + }; + var i = 0; + var length = str.length; + var iterator = { + next: function next() { + if (i < length) { + entry.value = str.charCodeAt(i++); + } else { + entry.done = true; + } + return entry; + } + }; + return hashIterableInts(iterator, seed); +}; +var hashStrings = function hashStrings() { + return hashStringsArray(arguments); +}; +var hashStringsArray = function hashStringsArray(strs) { + var hash; + for (var i = 0; i < strs.length; i++) { + var str = strs[i]; + if (i === 0) { + hash = hashString(str); + } else { + hash = hashString(str, hash); + } + } + return hash; +}; + +/*global console */ +var warningsEnabled = true; +var warnSupported = console.warn != null; // eslint-disable-line no-console +var traceSupported = console.trace != null; // eslint-disable-line no-console + +var MAX_INT$1 = Number.MAX_SAFE_INTEGER || 9007199254740991; +var trueify = function trueify() { + return true; +}; +var falsify = function falsify() { + return false; +}; +var zeroify = function zeroify() { + return 0; +}; +var noop$1 = function noop() {}; +var error = function error(msg) { + throw new Error(msg); +}; +var warnings = function warnings(enabled) { + if (enabled !== undefined) { + warningsEnabled = !!enabled; + } else { + return warningsEnabled; + } +}; +var warn = function warn(msg) { + /* eslint-disable no-console */ + if (!warnings()) { + return; + } + if (warnSupported) { + console.warn(msg); + } else { + console.log(msg); + if (traceSupported) { + console.trace(); + } + } +}; /* eslint-enable */ + +var clone = function clone(obj) { + return extend({}, obj); +}; + +// gets a shallow copy of the argument +var copy = function copy(obj) { + if (obj == null) { + return obj; + } + if (array(obj)) { + return obj.slice(); + } else if (plainObject(obj)) { + return clone(obj); + } else { + return obj; + } +}; +var copyArray$1 = function copyArray(arr) { + return arr.slice(); +}; +var uuid = function uuid(a, b /* placeholders */) { + for ( + // loop :) + b = a = ''; + // b - result , a - numeric letiable + a++ < 36; + // + b += a * 51 & 52 // if "a" is not 9 or 14 or 19 or 24 + ? + // return a random number or 4 + (a ^ 15 // if "a" is not 15 + ? + // generate a random number from 0 to 15 + 8 ^ Math.random() * (a ^ 20 ? 16 : 4) // unless "a" is 20, in which case a random number from 8 to 11 + : 4 // otherwise 4 + ).toString(16) : '-' // in other cases (if "a" is 9,14,19,24) insert "-" + ) { + } + return b; +}; +var _staticEmptyObject = {}; +var staticEmptyObject = function staticEmptyObject() { + return _staticEmptyObject; +}; +var defaults$g = function defaults(_defaults) { + var keys = Object.keys(_defaults); + return function (opts) { + var filledOpts = {}; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var optVal = opts == null ? undefined : opts[key]; + filledOpts[key] = optVal === undefined ? _defaults[key] : optVal; + } + return filledOpts; + }; +}; +var removeFromArray = function removeFromArray(arr, ele, oneCopy) { + for (var i = arr.length - 1; i >= 0; i--) { + if (arr[i] === ele) { + arr.splice(i, 1); + } + } +}; +var clearArray = function clearArray(arr) { + arr.splice(0, arr.length); +}; +var push = function push(arr, otherArr) { + for (var i = 0; i < otherArr.length; i++) { + var el = otherArr[i]; + arr.push(el); + } +}; +var getPrefixedProperty = function getPrefixedProperty(obj, propName, prefix) { + if (prefix) { + propName = prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth + } + + return obj[propName]; +}; +var setPrefixedProperty = function setPrefixedProperty(obj, propName, prefix, value) { + if (prefix) { + propName = prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth + } + + obj[propName] = value; +}; + +/* global Map */ +var ObjectMap = /*#__PURE__*/function () { + function ObjectMap() { + _classCallCheck(this, ObjectMap); + this._obj = {}; + } + _createClass(ObjectMap, [{ + key: "set", + value: function set(key, val) { + this._obj[key] = val; + return this; + } + }, { + key: "delete", + value: function _delete(key) { + this._obj[key] = undefined; + return this; + } + }, { + key: "clear", + value: function clear() { + this._obj = {}; + } + }, { + key: "has", + value: function has(key) { + return this._obj[key] !== undefined; + } + }, { + key: "get", + value: function get(key) { + return this._obj[key]; + } + }]); + return ObjectMap; +}(); +var Map$2 = typeof Map !== 'undefined' ? Map : ObjectMap; + +/* global Set */ + +var undef = "undefined" ; +var ObjectSet = /*#__PURE__*/function () { + function ObjectSet(arrayOrObjectSet) { + _classCallCheck(this, ObjectSet); + this._obj = Object.create(null); + this.size = 0; + if (arrayOrObjectSet != null) { + var arr; + if (arrayOrObjectSet.instanceString != null && arrayOrObjectSet.instanceString() === this.instanceString()) { + arr = arrayOrObjectSet.toArray(); + } else { + arr = arrayOrObjectSet; + } + for (var i = 0; i < arr.length; i++) { + this.add(arr[i]); + } + } + } + _createClass(ObjectSet, [{ + key: "instanceString", + value: function instanceString() { + return 'set'; + } + }, { + key: "add", + value: function add(val) { + var o = this._obj; + if (o[val] !== 1) { + o[val] = 1; + this.size++; + } + } + }, { + key: "delete", + value: function _delete(val) { + var o = this._obj; + if (o[val] === 1) { + o[val] = 0; + this.size--; + } + } + }, { + key: "clear", + value: function clear() { + this._obj = Object.create(null); + } + }, { + key: "has", + value: function has(val) { + return this._obj[val] === 1; + } + }, { + key: "toArray", + value: function toArray() { + var _this = this; + return Object.keys(this._obj).filter(function (key) { + return _this.has(key); + }); + } + }, { + key: "forEach", + value: function forEach(callback, thisArg) { + return this.toArray().forEach(callback, thisArg); + } + }]); + return ObjectSet; +}(); +var Set$1 = (typeof Set === "undefined" ? "undefined" : _typeof(Set)) !== undef ? Set : ObjectSet; + +// represents a node or an edge +var Element = function Element(cy, params) { + var restore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + if (cy === undefined || params === undefined || !core(cy)) { + error('An element must have a core reference and parameters set'); + return; + } + var group = params.group; + + // try to automatically infer the group if unspecified + if (group == null) { + if (params.data && params.data.source != null && params.data.target != null) { + group = 'edges'; + } else { + group = 'nodes'; + } + } + + // validate group + if (group !== 'nodes' && group !== 'edges') { + error('An element must be of type `nodes` or `edges`; you specified `' + group + '`'); + return; + } + + // make the element array-like, just like a collection + this.length = 1; + this[0] = this; + + // NOTE: when something is added here, add also to ele.json() + var _p = this._private = { + cy: cy, + single: true, + // indicates this is an element + data: params.data || {}, + // data object + position: params.position || { + x: 0, + y: 0 + }, + // (x, y) position pair + autoWidth: undefined, + // width and height of nodes calculated by the renderer when set to special 'auto' value + autoHeight: undefined, + autoPadding: undefined, + compoundBoundsClean: false, + // whether the compound dimensions need to be recalculated the next time dimensions are read + listeners: [], + // array of bound listeners + group: group, + // string; 'nodes' or 'edges' + style: {}, + // properties as set by the style + rstyle: {}, + // properties for style sent from the renderer to the core + styleCxts: [], + // applied style contexts from the styler + styleKeys: {}, + // per-group keys of style property values + removed: true, + // whether it's inside the vis; true if removed (set true here since we call restore) + selected: params.selected ? true : false, + // whether it's selected + selectable: params.selectable === undefined ? true : params.selectable ? true : false, + // whether it's selectable + locked: params.locked ? true : false, + // whether the element is locked (cannot be moved) + grabbed: false, + // whether the element is grabbed by the mouse; renderer sets this privately + grabbable: params.grabbable === undefined ? true : params.grabbable ? true : false, + // whether the element can be grabbed + pannable: params.pannable === undefined ? group === 'edges' ? true : false : params.pannable ? true : false, + // whether the element has passthrough panning enabled + active: false, + // whether the element is active from user interaction + classes: new Set$1(), + // map ( className => true ) + animation: { + // object for currently-running animations + current: [], + queue: [] + }, + rscratch: {}, + // object in which the renderer can store information + scratch: params.scratch || {}, + // scratch objects + edges: [], + // array of connected edges + children: [], + // array of children + parent: params.parent && params.parent.isNode() ? params.parent : null, + // parent ref + traversalCache: {}, + // cache of output of traversal functions + backgrounding: false, + // whether background images are loading + bbCache: null, + // cache of the current bounding box + bbCacheShift: { + x: 0, + y: 0 + }, + // shift applied to cached bb to be applied on next get + bodyBounds: null, + // bounds cache of element body, w/o overlay + overlayBounds: null, + // bounds cache of element body, including overlay + labelBounds: { + // bounds cache of labels + all: null, + source: null, + target: null, + main: null + }, + arrowBounds: { + // bounds cache of edge arrows + source: null, + target: null, + 'mid-source': null, + 'mid-target': null + } + }; + if (_p.position.x == null) { + _p.position.x = 0; + } + if (_p.position.y == null) { + _p.position.y = 0; + } + + // renderedPosition overrides if specified + if (params.renderedPosition) { + var rpos = params.renderedPosition; + var pan = cy.pan(); + var zoom = cy.zoom(); + _p.position = { + x: (rpos.x - pan.x) / zoom, + y: (rpos.y - pan.y) / zoom + }; + } + var classes = []; + if (array(params.classes)) { + classes = params.classes; + } else if (string(params.classes)) { + classes = params.classes.split(/\s+/); + } + for (var i = 0, l = classes.length; i < l; i++) { + var cls = classes[i]; + if (!cls || cls === '') { + continue; + } + _p.classes.add(cls); + } + this.createEmitter(); + var bypass = params.style || params.css; + if (bypass) { + warn('Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead.'); + this.style(bypass); + } + if (restore === undefined || restore) { + this.restore(); + } +}; + +var defineSearch = function defineSearch(params) { + params = { + bfs: params.bfs || !params.dfs, + dfs: params.dfs || !params.bfs + }; + + // from pseudocode on wikipedia + return function searchFn(roots, fn, directed) { + var options; + if (plainObject(roots) && !elementOrCollection(roots)) { + options = roots; + roots = options.roots || options.root; + fn = options.visit; + directed = options.directed; + } + directed = arguments.length === 2 && !fn$6(fn) ? fn : directed; + fn = fn$6(fn) ? fn : function () {}; + var cy = this._private.cy; + var v = roots = string(roots) ? this.filter(roots) : roots; + var Q = []; + var connectedNodes = []; + var connectedBy = {}; + var id2depth = {}; + var V = {}; + var j = 0; + var found; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + + // enqueue v + for (var i = 0; i < v.length; i++) { + var vi = v[i]; + var viId = vi.id(); + if (vi.isNode()) { + Q.unshift(vi); + if (params.bfs) { + V[viId] = true; + connectedNodes.push(vi); + } + id2depth[viId] = 0; + } + } + var _loop = function _loop() { + var v = params.bfs ? Q.shift() : Q.pop(); + var vId = v.id(); + if (params.dfs) { + if (V[vId]) { + return "continue"; + } + V[vId] = true; + connectedNodes.push(v); + } + var depth = id2depth[vId]; + var prevEdge = connectedBy[vId]; + var src = prevEdge != null ? prevEdge.source() : null; + var tgt = prevEdge != null ? prevEdge.target() : null; + var prevNode = prevEdge == null ? undefined : v.same(src) ? tgt[0] : src[0]; + var ret = void 0; + ret = fn(v, prevEdge, prevNode, j++, depth); + if (ret === true) { + found = v; + return "break"; + } + if (ret === false) { + return "break"; + } + var vwEdges = v.connectedEdges().filter(function (e) { + return (!directed || e.source().same(v)) && edges.has(e); + }); + for (var _i2 = 0; _i2 < vwEdges.length; _i2++) { + var e = vwEdges[_i2]; + var w = e.connectedNodes().filter(function (n) { + return !n.same(v) && nodes.has(n); + }); + var wId = w.id(); + if (w.length !== 0 && !V[wId]) { + w = w[0]; + Q.push(w); + if (params.bfs) { + V[wId] = true; + connectedNodes.push(w); + } + connectedBy[wId] = e; + id2depth[wId] = id2depth[vId] + 1; + } + } + }; + while (Q.length !== 0) { + var _ret = _loop(); + if (_ret === "continue") continue; + if (_ret === "break") break; + } + var connectedEles = cy.collection(); + for (var _i = 0; _i < connectedNodes.length; _i++) { + var node = connectedNodes[_i]; + var edge = connectedBy[node.id()]; + if (edge != null) { + connectedEles.push(edge); + } + connectedEles.push(node); + } + return { + path: cy.collection(connectedEles), + found: cy.collection(found) + }; + }; +}; + +// search, spanning trees, etc +var elesfn$v = { + breadthFirstSearch: defineSearch({ + bfs: true + }), + depthFirstSearch: defineSearch({ + dfs: true + }) +}; + +// nice, short mathematical alias +elesfn$v.bfs = elesfn$v.breadthFirstSearch; +elesfn$v.dfs = elesfn$v.depthFirstSearch; + +var heap$1 = createCommonjsModule(function (module, exports) { +// Generated by CoffeeScript 1.8.0 +(function() { + var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup; + + floor = Math.floor, min = Math.min; + + + /* + Default comparison function to be used + */ + + defaultCmp = function(x, y) { + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } + return 0; + }; + + + /* + Insert item x in list a, and keep it sorted assuming a is sorted. + + If x is already in a, insert it to the right of the rightmost x. + + Optional args lo (default 0) and hi (default a.length) bound the slice + of a to be searched. + */ + + insort = function(a, x, lo, hi, cmp) { + var mid; + if (lo == null) { + lo = 0; + } + if (cmp == null) { + cmp = defaultCmp; + } + if (lo < 0) { + throw new Error('lo must be non-negative'); + } + if (hi == null) { + hi = a.length; + } + while (lo < hi) { + mid = floor((lo + hi) / 2); + if (cmp(x, a[mid]) < 0) { + hi = mid; + } else { + lo = mid + 1; + } + } + return ([].splice.apply(a, [lo, lo - lo].concat(x)), x); + }; + + + /* + Push item onto heap, maintaining the heap invariant. + */ + + heappush = function(array, item, cmp) { + if (cmp == null) { + cmp = defaultCmp; + } + array.push(item); + return _siftdown(array, 0, array.length - 1, cmp); + }; + + + /* + Pop the smallest item off the heap, maintaining the heap invariant. + */ + + heappop = function(array, cmp) { + var lastelt, returnitem; + if (cmp == null) { + cmp = defaultCmp; + } + lastelt = array.pop(); + if (array.length) { + returnitem = array[0]; + array[0] = lastelt; + _siftup(array, 0, cmp); + } else { + returnitem = lastelt; + } + return returnitem; + }; + + + /* + Pop and return the current smallest value, and add the new item. + + This is more efficient than heappop() followed by heappush(), and can be + more appropriate when using a fixed size heap. Note that the value + returned may be larger than item! That constrains reasonable use of + this routine unless written as part of a conditional replacement: + if item > array[0] + item = heapreplace(array, item) + */ + + heapreplace = function(array, item, cmp) { + var returnitem; + if (cmp == null) { + cmp = defaultCmp; + } + returnitem = array[0]; + array[0] = item; + _siftup(array, 0, cmp); + return returnitem; + }; + + + /* + Fast version of a heappush followed by a heappop. + */ + + heappushpop = function(array, item, cmp) { + var _ref; + if (cmp == null) { + cmp = defaultCmp; + } + if (array.length && cmp(array[0], item) < 0) { + _ref = [array[0], item], item = _ref[0], array[0] = _ref[1]; + _siftup(array, 0, cmp); + } + return item; + }; + + + /* + Transform list into a heap, in-place, in O(array.length) time. + */ + + heapify = function(array, cmp) { + var i, _i, _len, _ref1, _results, _results1; + if (cmp == null) { + cmp = defaultCmp; + } + _ref1 = (function() { + _results1 = []; + for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); } + return _results1; + }).apply(this).reverse(); + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + i = _ref1[_i]; + _results.push(_siftup(array, i, cmp)); + } + return _results; + }; + + + /* + Update the position of the given item in the heap. + This function should be called every time the item is being modified. + */ + + updateItem = function(array, item, cmp) { + var pos; + if (cmp == null) { + cmp = defaultCmp; + } + pos = array.indexOf(item); + if (pos === -1) { + return; + } + _siftdown(array, 0, pos, cmp); + return _siftup(array, pos, cmp); + }; + + + /* + Find the n largest elements in a dataset. + */ + + nlargest = function(array, n, cmp) { + var elem, result, _i, _len, _ref; + if (cmp == null) { + cmp = defaultCmp; + } + result = array.slice(0, n); + if (!result.length) { + return result; + } + heapify(result, cmp); + _ref = array.slice(n); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elem = _ref[_i]; + heappushpop(result, elem, cmp); + } + return result.sort(cmp).reverse(); + }; + + + /* + Find the n smallest elements in a dataset. + */ + + nsmallest = function(array, n, cmp) { + var elem, los, result, _i, _j, _len, _ref, _ref1, _results; + if (cmp == null) { + cmp = defaultCmp; + } + if (n * 10 <= array.length) { + result = array.slice(0, n).sort(cmp); + if (!result.length) { + return result; + } + los = result[result.length - 1]; + _ref = array.slice(n); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elem = _ref[_i]; + if (cmp(elem, los) < 0) { + insort(result, elem, 0, null, cmp); + result.pop(); + los = result[result.length - 1]; + } + } + return result; + } + heapify(array, cmp); + _results = []; + for (_j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; 0 <= _ref1 ? ++_j : --_j) { + _results.push(heappop(array, cmp)); + } + return _results; + }; + + _siftdown = function(array, startpos, pos, cmp) { + var newitem, parent, parentpos; + if (cmp == null) { + cmp = defaultCmp; + } + newitem = array[pos]; + while (pos > startpos) { + parentpos = (pos - 1) >> 1; + parent = array[parentpos]; + if (cmp(newitem, parent) < 0) { + array[pos] = parent; + pos = parentpos; + continue; + } + break; + } + return array[pos] = newitem; + }; + + _siftup = function(array, pos, cmp) { + var childpos, endpos, newitem, rightpos, startpos; + if (cmp == null) { + cmp = defaultCmp; + } + endpos = array.length; + startpos = pos; + newitem = array[pos]; + childpos = 2 * pos + 1; + while (childpos < endpos) { + rightpos = childpos + 1; + if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) { + childpos = rightpos; + } + array[pos] = array[childpos]; + pos = childpos; + childpos = 2 * pos + 1; + } + array[pos] = newitem; + return _siftdown(array, startpos, pos, cmp); + }; + + Heap = (function() { + Heap.push = heappush; + + Heap.pop = heappop; + + Heap.replace = heapreplace; + + Heap.pushpop = heappushpop; + + Heap.heapify = heapify; + + Heap.updateItem = updateItem; + + Heap.nlargest = nlargest; + + Heap.nsmallest = nsmallest; + + function Heap(cmp) { + this.cmp = cmp != null ? cmp : defaultCmp; + this.nodes = []; + } + + Heap.prototype.push = function(x) { + return heappush(this.nodes, x, this.cmp); + }; + + Heap.prototype.pop = function() { + return heappop(this.nodes, this.cmp); + }; + + Heap.prototype.peek = function() { + return this.nodes[0]; + }; + + Heap.prototype.contains = function(x) { + return this.nodes.indexOf(x) !== -1; + }; + + Heap.prototype.replace = function(x) { + return heapreplace(this.nodes, x, this.cmp); + }; + + Heap.prototype.pushpop = function(x) { + return heappushpop(this.nodes, x, this.cmp); + }; + + Heap.prototype.heapify = function() { + return heapify(this.nodes, this.cmp); + }; + + Heap.prototype.updateItem = function(x) { + return updateItem(this.nodes, x, this.cmp); + }; + + Heap.prototype.clear = function() { + return this.nodes = []; + }; + + Heap.prototype.empty = function() { + return this.nodes.length === 0; + }; + + Heap.prototype.size = function() { + return this.nodes.length; + }; + + Heap.prototype.clone = function() { + var heap; + heap = new Heap(); + heap.nodes = this.nodes.slice(0); + return heap; + }; + + Heap.prototype.toArray = function() { + return this.nodes.slice(0); + }; + + Heap.prototype.insert = Heap.prototype.push; + + Heap.prototype.top = Heap.prototype.peek; + + Heap.prototype.front = Heap.prototype.peek; + + Heap.prototype.has = Heap.prototype.contains; + + Heap.prototype.copy = Heap.prototype.clone; + + return Heap; + + })(); + + (function(root, factory) { + { + return module.exports = factory(); + } + })(this, function() { + return Heap; + }); + +}).call(commonjsGlobal); +}); + +var heap = heap$1; + +var dijkstraDefaults = defaults$g({ + root: null, + weight: function weight(edge) { + return 1; + }, + directed: false +}); +var elesfn$u = { + dijkstra: function dijkstra(options) { + if (!plainObject(options)) { + var args = arguments; + options = { + root: args[0], + weight: args[1], + directed: args[2] + }; + } + var _dijkstraDefaults = dijkstraDefaults(options), + root = _dijkstraDefaults.root, + weight = _dijkstraDefaults.weight, + directed = _dijkstraDefaults.directed; + var eles = this; + var weightFn = weight; + var source = string(root) ? this.filter(root)[0] : root[0]; + var dist = {}; + var prev = {}; + var knownDist = {}; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + edges.unmergeBy(function (ele) { + return ele.isLoop(); + }); + var getDist = function getDist(node) { + return dist[node.id()]; + }; + var setDist = function setDist(node, d) { + dist[node.id()] = d; + Q.updateItem(node); + }; + var Q = new heap(function (a, b) { + return getDist(a) - getDist(b); + }); + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + dist[node.id()] = node.same(source) ? 0 : Infinity; + Q.push(node); + } + var distBetween = function distBetween(u, v) { + var uvs = (directed ? u.edgesTo(v) : u.edgesWith(v)).intersect(edges); + var smallestDistance = Infinity; + var smallestEdge; + for (var _i = 0; _i < uvs.length; _i++) { + var edge = uvs[_i]; + var _weight = weightFn(edge); + if (_weight < smallestDistance || !smallestEdge) { + smallestDistance = _weight; + smallestEdge = edge; + } + } + return { + edge: smallestEdge, + dist: smallestDistance + }; + }; + while (Q.size() > 0) { + var u = Q.pop(); + var smalletsDist = getDist(u); + var uid = u.id(); + knownDist[uid] = smalletsDist; + if (smalletsDist === Infinity) { + continue; + } + var neighbors = u.neighborhood().intersect(nodes); + for (var _i2 = 0; _i2 < neighbors.length; _i2++) { + var v = neighbors[_i2]; + var vid = v.id(); + var vDist = distBetween(u, v); + var alt = smalletsDist + vDist.dist; + if (alt < getDist(v)) { + setDist(v, alt); + prev[vid] = { + node: u, + edge: vDist.edge + }; + } + } // for + } // while + + return { + distanceTo: function distanceTo(node) { + var target = string(node) ? nodes.filter(node)[0] : node[0]; + return knownDist[target.id()]; + }, + pathTo: function pathTo(node) { + var target = string(node) ? nodes.filter(node)[0] : node[0]; + var S = []; + var u = target; + var uid = u.id(); + if (target.length > 0) { + S.unshift(target); + while (prev[uid]) { + var p = prev[uid]; + S.unshift(p.edge); + S.unshift(p.node); + u = p.node; + uid = u.id(); + } + } + return eles.spawn(S); + } + }; + } +}; + +var elesfn$t = { + // kruskal's algorithm (finds min spanning tree, assuming undirected graph) + // implemented from pseudocode from wikipedia + kruskal: function kruskal(weightFn) { + weightFn = weightFn || function (edge) { + return 1; + }; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var numNodes = nodes.length; + var forest = new Array(numNodes); + var A = nodes; // assumes byGroup() creates new collections that can be safely mutated + + var findSetIndex = function findSetIndex(ele) { + for (var i = 0; i < forest.length; i++) { + var eles = forest[i]; + if (eles.has(ele)) { + return i; + } + } + }; + + // start with one forest per node + for (var i = 0; i < numNodes; i++) { + forest[i] = this.spawn(nodes[i]); + } + var S = edges.sort(function (a, b) { + return weightFn(a) - weightFn(b); + }); + for (var _i = 0; _i < S.length; _i++) { + var edge = S[_i]; + var u = edge.source()[0]; + var v = edge.target()[0]; + var setUIndex = findSetIndex(u); + var setVIndex = findSetIndex(v); + var setU = forest[setUIndex]; + var setV = forest[setVIndex]; + if (setUIndex !== setVIndex) { + A.merge(edge); + + // combine forests for u and v + setU.merge(setV); + forest.splice(setVIndex, 1); + } + } + return A; + } +}; + +var aStarDefaults = defaults$g({ + root: null, + goal: null, + weight: function weight(edge) { + return 1; + }, + heuristic: function heuristic(edge) { + return 0; + }, + directed: false +}); +var elesfn$s = { + // Implemented from pseudocode from wikipedia + aStar: function aStar(options) { + var cy = this.cy(); + var _aStarDefaults = aStarDefaults(options), + root = _aStarDefaults.root, + goal = _aStarDefaults.goal, + heuristic = _aStarDefaults.heuristic, + directed = _aStarDefaults.directed, + weight = _aStarDefaults.weight; + root = cy.collection(root)[0]; + goal = cy.collection(goal)[0]; + var sid = root.id(); + var tid = goal.id(); + var gScore = {}; + var fScore = {}; + var closedSetIds = {}; + var openSet = new heap(function (a, b) { + return fScore[a.id()] - fScore[b.id()]; + }); + var openSetIds = new Set$1(); + var cameFrom = {}; + var cameFromEdge = {}; + var addToOpenSet = function addToOpenSet(ele, id) { + openSet.push(ele); + openSetIds.add(id); + }; + var cMin, cMinId; + var popFromOpenSet = function popFromOpenSet() { + cMin = openSet.pop(); + cMinId = cMin.id(); + openSetIds["delete"](cMinId); + }; + var isInOpenSet = function isInOpenSet(id) { + return openSetIds.has(id); + }; + addToOpenSet(root, sid); + gScore[sid] = 0; + fScore[sid] = heuristic(root); + + // Counter + var steps = 0; + + // Main loop + while (openSet.size() > 0) { + popFromOpenSet(); + steps++; + + // If we've found our goal, then we are done + if (cMinId === tid) { + var path = []; + var pathNode = goal; + var pathNodeId = tid; + var pathEdge = cameFromEdge[pathNodeId]; + for (;;) { + path.unshift(pathNode); + if (pathEdge != null) { + path.unshift(pathEdge); + } + pathNode = cameFrom[pathNodeId]; + if (pathNode == null) { + break; + } + pathNodeId = pathNode.id(); + pathEdge = cameFromEdge[pathNodeId]; + } + return { + found: true, + distance: gScore[cMinId], + path: this.spawn(path), + steps: steps + }; + } + + // Add cMin to processed nodes + closedSetIds[cMinId] = true; + + // Update scores for neighbors of cMin + // Take into account if graph is directed or not + var vwEdges = cMin._private.edges; + for (var i = 0; i < vwEdges.length; i++) { + var e = vwEdges[i]; + + // edge must be in set of calling eles + if (!this.hasElementWithId(e.id())) { + continue; + } + + // cMin must be the source of edge if directed + if (directed && e.data('source') !== cMinId) { + continue; + } + var wSrc = e.source(); + var wTgt = e.target(); + var w = wSrc.id() !== cMinId ? wSrc : wTgt; + var wid = w.id(); + + // node must be in set of calling eles + if (!this.hasElementWithId(wid)) { + continue; + } + + // if node is in closedSet, ignore it + if (closedSetIds[wid]) { + continue; + } + + // New tentative score for node w + var tempScore = gScore[cMinId] + weight(e); + + // Update gScore for node w if: + // w not present in openSet + // OR + // tentative gScore is less than previous value + + // w not in openSet + if (!isInOpenSet(wid)) { + gScore[wid] = tempScore; + fScore[wid] = tempScore + heuristic(w); + addToOpenSet(w, wid); + cameFrom[wid] = cMin; + cameFromEdge[wid] = e; + continue; + } + + // w already in openSet, but with greater gScore + if (tempScore < gScore[wid]) { + gScore[wid] = tempScore; + fScore[wid] = tempScore + heuristic(w); + cameFrom[wid] = cMin; + cameFromEdge[wid] = e; + } + } // End of neighbors update + } // End of main loop + + // If we've reached here, then we've not reached our goal + return { + found: false, + distance: undefined, + path: undefined, + steps: steps + }; + } +}; // elesfn + +var floydWarshallDefaults = defaults$g({ + weight: function weight(edge) { + return 1; + }, + directed: false +}); +var elesfn$r = { + // Implemented from pseudocode from wikipedia + floydWarshall: function floydWarshall(options) { + var cy = this.cy(); + var _floydWarshallDefault = floydWarshallDefaults(options), + weight = _floydWarshallDefault.weight, + directed = _floydWarshallDefault.directed; + var weightFn = weight; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var N = nodes.length; + var Nsq = N * N; + var indexOf = function indexOf(node) { + return nodes.indexOf(node); + }; + var atIndex = function atIndex(i) { + return nodes[i]; + }; + + // Initialize distance matrix + var dist = new Array(Nsq); + for (var n = 0; n < Nsq; n++) { + var j = n % N; + var i = (n - j) / N; + if (i === j) { + dist[n] = 0; + } else { + dist[n] = Infinity; + } + } + + // Initialize matrix used for path reconstruction + // Initialize distance matrix + var next = new Array(Nsq); + var edgeNext = new Array(Nsq); + + // Process edges + for (var _i = 0; _i < edges.length; _i++) { + var edge = edges[_i]; + var src = edge.source()[0]; + var tgt = edge.target()[0]; + if (src === tgt) { + continue; + } // exclude loops + + var s = indexOf(src); + var t = indexOf(tgt); + var st = s * N + t; // source to target index + var _weight = weightFn(edge); + + // Check if already process another edge between same 2 nodes + if (dist[st] > _weight) { + dist[st] = _weight; + next[st] = t; + edgeNext[st] = edge; + } + + // If undirected graph, process 'reversed' edge + if (!directed) { + var ts = t * N + s; // target to source index + + if (!directed && dist[ts] > _weight) { + dist[ts] = _weight; + next[ts] = s; + edgeNext[ts] = edge; + } + } + } + + // Main loop + for (var k = 0; k < N; k++) { + for (var _i2 = 0; _i2 < N; _i2++) { + var ik = _i2 * N + k; + for (var _j = 0; _j < N; _j++) { + var ij = _i2 * N + _j; + var kj = k * N + _j; + if (dist[ik] + dist[kj] < dist[ij]) { + dist[ij] = dist[ik] + dist[kj]; + next[ij] = next[ik]; + } + } + } + } + var getArgEle = function getArgEle(ele) { + return (string(ele) ? cy.filter(ele) : ele)[0]; + }; + var indexOfArgEle = function indexOfArgEle(ele) { + return indexOf(getArgEle(ele)); + }; + var res = { + distance: function distance(from, to) { + var i = indexOfArgEle(from); + var j = indexOfArgEle(to); + return dist[i * N + j]; + }, + path: function path(from, to) { + var i = indexOfArgEle(from); + var j = indexOfArgEle(to); + var fromNode = atIndex(i); + if (i === j) { + return fromNode.collection(); + } + if (next[i * N + j] == null) { + return cy.collection(); + } + var path = cy.collection(); + var prev = i; + var edge; + path.merge(fromNode); + while (i !== j) { + prev = i; + i = next[i * N + j]; + edge = edgeNext[prev * N + i]; + path.merge(edge); + path.merge(atIndex(i)); + } + return path; + } + }; + return res; + } // floydWarshall +}; // elesfn + +var bellmanFordDefaults = defaults$g({ + weight: function weight(edge) { + return 1; + }, + directed: false, + root: null +}); +var elesfn$q = { + // Implemented from pseudocode from wikipedia + bellmanFord: function bellmanFord(options) { + var _this = this; + var _bellmanFordDefaults = bellmanFordDefaults(options), + weight = _bellmanFordDefaults.weight, + directed = _bellmanFordDefaults.directed, + root = _bellmanFordDefaults.root; + var weightFn = weight; + var eles = this; + var cy = this.cy(); + var _this$byGroup = this.byGroup(), + edges = _this$byGroup.edges, + nodes = _this$byGroup.nodes; + var numNodes = nodes.length; + var infoMap = new Map$2(); + var hasNegativeWeightCycle = false; + var negativeWeightCycles = []; + root = cy.collection(root)[0]; // in case selector passed + + edges.unmergeBy(function (edge) { + return edge.isLoop(); + }); + var numEdges = edges.length; + var getInfo = function getInfo(node) { + var obj = infoMap.get(node.id()); + if (!obj) { + obj = {}; + infoMap.set(node.id(), obj); + } + return obj; + }; + var getNodeFromTo = function getNodeFromTo(to) { + return (string(to) ? cy.$(to) : to)[0]; + }; + var distanceTo = function distanceTo(to) { + return getInfo(getNodeFromTo(to)).dist; + }; + var pathTo = function pathTo(to) { + var thisStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : root; + var end = getNodeFromTo(to); + var path = []; + var node = end; + for (;;) { + if (node == null) { + return _this.spawn(); + } + var _getInfo = getInfo(node), + edge = _getInfo.edge, + pred = _getInfo.pred; + path.unshift(node[0]); + if (node.same(thisStart) && path.length > 0) { + break; + } + if (edge != null) { + path.unshift(edge); + } + node = pred; + } + return eles.spawn(path); + }; + + // Initializations { dist, pred, edge } + for (var i = 0; i < numNodes; i++) { + var node = nodes[i]; + var info = getInfo(node); + if (node.same(root)) { + info.dist = 0; + } else { + info.dist = Infinity; + } + info.pred = null; + info.edge = null; + } + + // Edges relaxation + var replacedEdge = false; + var checkForEdgeReplacement = function checkForEdgeReplacement(node1, node2, edge, info1, info2, weight) { + var dist = info1.dist + weight; + if (dist < info2.dist && !edge.same(info1.edge)) { + info2.dist = dist; + info2.pred = node1; + info2.edge = edge; + replacedEdge = true; + } + }; + for (var _i = 1; _i < numNodes; _i++) { + replacedEdge = false; + for (var e = 0; e < numEdges; e++) { + var edge = edges[e]; + var src = edge.source(); + var tgt = edge.target(); + var _weight = weightFn(edge); + var srcInfo = getInfo(src); + var tgtInfo = getInfo(tgt); + checkForEdgeReplacement(src, tgt, edge, srcInfo, tgtInfo, _weight); + + // If undirected graph, we need to take into account the 'reverse' edge + if (!directed) { + checkForEdgeReplacement(tgt, src, edge, tgtInfo, srcInfo, _weight); + } + } + if (!replacedEdge) { + break; + } + } + if (replacedEdge) { + // Check for negative weight cycles + var negativeWeightCycleIds = []; + for (var _e = 0; _e < numEdges; _e++) { + var _edge = edges[_e]; + var _src = _edge.source(); + var _tgt = _edge.target(); + var _weight2 = weightFn(_edge); + var srcDist = getInfo(_src).dist; + var tgtDist = getInfo(_tgt).dist; + if (srcDist + _weight2 < tgtDist || !directed && tgtDist + _weight2 < srcDist) { + if (!hasNegativeWeightCycle) { + warn('Graph contains a negative weight cycle for Bellman-Ford'); + hasNegativeWeightCycle = true; + } + if (options.findNegativeWeightCycles !== false) { + var negativeNodes = []; + if (srcDist + _weight2 < tgtDist) { + negativeNodes.push(_src); + } + if (!directed && tgtDist + _weight2 < srcDist) { + negativeNodes.push(_tgt); + } + var numNegativeNodes = negativeNodes.length; + for (var n = 0; n < numNegativeNodes; n++) { + var start = negativeNodes[n]; + var cycle = [start]; + cycle.push(getInfo(start).edge); + var _node = getInfo(start).pred; + while (cycle.indexOf(_node) === -1) { + cycle.push(_node); + cycle.push(getInfo(_node).edge); + _node = getInfo(_node).pred; + } + cycle = cycle.slice(cycle.indexOf(_node)); + var smallestId = cycle[0].id(); + var smallestIndex = 0; + for (var c = 2; c < cycle.length; c += 2) { + if (cycle[c].id() < smallestId) { + smallestId = cycle[c].id(); + smallestIndex = c; + } + } + cycle = cycle.slice(smallestIndex).concat(cycle.slice(0, smallestIndex)); + cycle.push(cycle[0]); + var cycleId = cycle.map(function (el) { + return el.id(); + }).join(","); + if (negativeWeightCycleIds.indexOf(cycleId) === -1) { + negativeWeightCycles.push(eles.spawn(cycle)); + negativeWeightCycleIds.push(cycleId); + } + } + } else { + break; + } + } + } + } + return { + distanceTo: distanceTo, + pathTo: pathTo, + hasNegativeWeightCycle: hasNegativeWeightCycle, + negativeWeightCycles: negativeWeightCycles + }; + } // bellmanFord +}; // elesfn + +var sqrt2 = Math.sqrt(2); + +// Function which colapses 2 (meta) nodes into one +// Updates the remaining edge lists +// Receives as a paramater the edge which causes the collapse +var collapse = function collapse(edgeIndex, nodeMap, remainingEdges) { + if (remainingEdges.length === 0) { + error("Karger-Stein must be run on a connected (sub)graph"); + } + var edgeInfo = remainingEdges[edgeIndex]; + var sourceIn = edgeInfo[1]; + var targetIn = edgeInfo[2]; + var partition1 = nodeMap[sourceIn]; + var partition2 = nodeMap[targetIn]; + var newEdges = remainingEdges; // re-use array + + // Delete all edges between partition1 and partition2 + for (var i = newEdges.length - 1; i >= 0; i--) { + var edge = newEdges[i]; + var src = edge[1]; + var tgt = edge[2]; + if (nodeMap[src] === partition1 && nodeMap[tgt] === partition2 || nodeMap[src] === partition2 && nodeMap[tgt] === partition1) { + newEdges.splice(i, 1); + } + } + + // All edges pointing to partition2 should now point to partition1 + for (var _i = 0; _i < newEdges.length; _i++) { + var _edge = newEdges[_i]; + if (_edge[1] === partition2) { + // Check source + newEdges[_i] = _edge.slice(); // copy + newEdges[_i][1] = partition1; + } else if (_edge[2] === partition2) { + // Check target + newEdges[_i] = _edge.slice(); // copy + newEdges[_i][2] = partition1; + } + } + + // Move all nodes from partition2 to partition1 + for (var _i2 = 0; _i2 < nodeMap.length; _i2++) { + if (nodeMap[_i2] === partition2) { + nodeMap[_i2] = partition1; + } + } + return newEdges; +}; + +// Contracts a graph until we reach a certain number of meta nodes +var contractUntil = function contractUntil(metaNodeMap, remainingEdges, size, sizeLimit) { + while (size > sizeLimit) { + // Choose an edge randomly + var edgeIndex = Math.floor(Math.random() * remainingEdges.length); + + // Collapse graph based on edge + remainingEdges = collapse(edgeIndex, metaNodeMap, remainingEdges); + size--; + } + return remainingEdges; +}; +var elesfn$p = { + // Computes the minimum cut of an undirected graph + // Returns the correct answer with high probability + kargerStein: function kargerStein() { + var _this = this; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + edges.unmergeBy(function (edge) { + return edge.isLoop(); + }); + var numNodes = nodes.length; + var numEdges = edges.length; + var numIter = Math.ceil(Math.pow(Math.log(numNodes) / Math.LN2, 2)); + var stopSize = Math.floor(numNodes / sqrt2); + if (numNodes < 2) { + error('At least 2 nodes are required for Karger-Stein algorithm'); + return undefined; + } + + // Now store edge destination as indexes + // Format for each edge (edge index, source node index, target node index) + var edgeIndexes = []; + for (var i = 0; i < numEdges; i++) { + var e = edges[i]; + edgeIndexes.push([i, nodes.indexOf(e.source()), nodes.indexOf(e.target())]); + } + + // We will store the best cut found here + var minCutSize = Infinity; + var minCutEdgeIndexes = []; + var minCutNodeMap = new Array(numNodes); + + // Initial meta node partition + var metaNodeMap = new Array(numNodes); + var metaNodeMap2 = new Array(numNodes); + var copyNodesMap = function copyNodesMap(from, to) { + for (var _i3 = 0; _i3 < numNodes; _i3++) { + to[_i3] = from[_i3]; + } + }; + + // Main loop + for (var iter = 0; iter <= numIter; iter++) { + // Reset meta node partition + for (var _i4 = 0; _i4 < numNodes; _i4++) { + metaNodeMap[_i4] = _i4; + } + + // Contract until stop point (stopSize nodes) + var edgesState = contractUntil(metaNodeMap, edgeIndexes.slice(), numNodes, stopSize); + var edgesState2 = edgesState.slice(); // copy + + // Create a copy of the colapsed nodes state + copyNodesMap(metaNodeMap, metaNodeMap2); + + // Run 2 iterations starting in the stop state + var res1 = contractUntil(metaNodeMap, edgesState, stopSize, 2); + var res2 = contractUntil(metaNodeMap2, edgesState2, stopSize, 2); + + // Is any of the 2 results the best cut so far? + if (res1.length <= res2.length && res1.length < minCutSize) { + minCutSize = res1.length; + minCutEdgeIndexes = res1; + copyNodesMap(metaNodeMap, minCutNodeMap); + } else if (res2.length <= res1.length && res2.length < minCutSize) { + minCutSize = res2.length; + minCutEdgeIndexes = res2; + copyNodesMap(metaNodeMap2, minCutNodeMap); + } + } // end of main loop + + // Construct result + var cut = this.spawn(minCutEdgeIndexes.map(function (e) { + return edges[e[0]]; + })); + var partition1 = this.spawn(); + var partition2 = this.spawn(); + + // traverse metaNodeMap for best cut + var witnessNodePartition = minCutNodeMap[0]; + for (var _i5 = 0; _i5 < minCutNodeMap.length; _i5++) { + var partitionId = minCutNodeMap[_i5]; + var node = nodes[_i5]; + if (partitionId === witnessNodePartition) { + partition1.merge(node); + } else { + partition2.merge(node); + } + } + + // construct components corresponding to each disjoint subset of nodes + var constructComponent = function constructComponent(subset) { + var component = _this.spawn(); + subset.forEach(function (node) { + component.merge(node); + node.connectedEdges().forEach(function (edge) { + // ensure edge is within calling collection and edge is not in cut + if (_this.contains(edge) && !cut.contains(edge)) { + component.merge(edge); + } + }); + }); + return component; + }; + var components = [constructComponent(partition1), constructComponent(partition2)]; + var ret = { + cut: cut, + components: components, + // n.b. partitions are included to be compatible with the old api spec + // (could be removed in a future major version) + partition1: partition1, + partition2: partition2 + }; + return ret; + } +}; // elesfn + +var copyPosition = function copyPosition(p) { + return { + x: p.x, + y: p.y + }; +}; +var modelToRenderedPosition = function modelToRenderedPosition(p, zoom, pan) { + return { + x: p.x * zoom + pan.x, + y: p.y * zoom + pan.y + }; +}; +var renderedToModelPosition = function renderedToModelPosition(p, zoom, pan) { + return { + x: (p.x - pan.x) / zoom, + y: (p.y - pan.y) / zoom + }; +}; +var array2point = function array2point(arr) { + return { + x: arr[0], + y: arr[1] + }; +}; +var min = function min(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var min = Infinity; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + min = Math.min(val, min); + } + } + return min; +}; +var max = function max(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var max = -Infinity; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + max = Math.max(val, max); + } + } + return max; +}; +var mean = function mean(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var total = 0; + var n = 0; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + total += val; + n++; + } + } + return total / n; +}; +var median = function median(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var copy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var sort = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var includeHoles = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + if (copy) { + arr = arr.slice(begin, end); + } else { + if (end < arr.length) { + arr.splice(end, arr.length - end); + } + if (begin > 0) { + arr.splice(0, begin); + } + } + + // all non finite (e.g. Infinity, NaN) elements must be -Infinity so they go to the start + var off = 0; // offset from non-finite values + for (var i = arr.length - 1; i >= 0; i--) { + var v = arr[i]; + if (includeHoles) { + if (!isFinite(v)) { + arr[i] = -Infinity; + off++; + } + } else { + // just remove it if we don't want to consider holes + arr.splice(i, 1); + } + } + if (sort) { + arr.sort(function (a, b) { + return a - b; + }); // requires copy = true if you don't want to change the orig + } + + var len = arr.length; + var mid = Math.floor(len / 2); + if (len % 2 !== 0) { + return arr[mid + 1 + off]; + } else { + return (arr[mid - 1 + off] + arr[mid + off]) / 2; + } +}; +var deg2rad = function deg2rad(deg) { + return Math.PI * deg / 180; +}; +var getAngleFromDisp = function getAngleFromDisp(dispX, dispY) { + return Math.atan2(dispY, dispX) - Math.PI / 2; +}; +var log2 = Math.log2 || function (n) { + return Math.log(n) / Math.log(2); +}; +var signum = function signum(x) { + if (x > 0) { + return 1; + } else if (x < 0) { + return -1; + } else { + return 0; + } +}; +var dist = function dist(p1, p2) { + return Math.sqrt(sqdist(p1, p2)); +}; +var sqdist = function sqdist(p1, p2) { + var dx = p2.x - p1.x; + var dy = p2.y - p1.y; + return dx * dx + dy * dy; +}; +var inPlaceSumNormalize = function inPlaceSumNormalize(v) { + var length = v.length; + + // First, get sum of all elements + var total = 0; + for (var i = 0; i < length; i++) { + total += v[i]; + } + + // Now, divide each by the sum of all elements + for (var _i = 0; _i < length; _i++) { + v[_i] = v[_i] / total; + } + return v; +}; + +// from http://en.wikipedia.org/wiki/Bézier_curve#Quadratic_curves +var qbezierAt = function qbezierAt(p0, p1, p2, t) { + return (1 - t) * (1 - t) * p0 + 2 * (1 - t) * t * p1 + t * t * p2; +}; +var qbezierPtAt = function qbezierPtAt(p0, p1, p2, t) { + return { + x: qbezierAt(p0.x, p1.x, p2.x, t), + y: qbezierAt(p0.y, p1.y, p2.y, t) + }; +}; +var lineAt = function lineAt(p0, p1, t, d) { + var vec = { + x: p1.x - p0.x, + y: p1.y - p0.y + }; + var vecDist = dist(p0, p1); + var normVec = { + x: vec.x / vecDist, + y: vec.y / vecDist + }; + t = t == null ? 0 : t; + d = d != null ? d : t * vecDist; + return { + x: p0.x + normVec.x * d, + y: p0.y + normVec.y * d + }; +}; +var bound = function bound(min, val, max) { + return Math.max(min, Math.min(max, val)); +}; + +// makes a full bb (x1, y1, x2, y2, w, h) from implicit params +var makeBoundingBox = function makeBoundingBox(bb) { + if (bb == null) { + return { + x1: Infinity, + y1: Infinity, + x2: -Infinity, + y2: -Infinity, + w: 0, + h: 0 + }; + } else if (bb.x1 != null && bb.y1 != null) { + if (bb.x2 != null && bb.y2 != null && bb.x2 >= bb.x1 && bb.y2 >= bb.y1) { + return { + x1: bb.x1, + y1: bb.y1, + x2: bb.x2, + y2: bb.y2, + w: bb.x2 - bb.x1, + h: bb.y2 - bb.y1 + }; + } else if (bb.w != null && bb.h != null && bb.w >= 0 && bb.h >= 0) { + return { + x1: bb.x1, + y1: bb.y1, + x2: bb.x1 + bb.w, + y2: bb.y1 + bb.h, + w: bb.w, + h: bb.h + }; + } + } +}; +var copyBoundingBox = function copyBoundingBox(bb) { + return { + x1: bb.x1, + x2: bb.x2, + w: bb.w, + y1: bb.y1, + y2: bb.y2, + h: bb.h + }; +}; +var clearBoundingBox = function clearBoundingBox(bb) { + bb.x1 = Infinity; + bb.y1 = Infinity; + bb.x2 = -Infinity; + bb.y2 = -Infinity; + bb.w = 0; + bb.h = 0; +}; +var shiftBoundingBox = function shiftBoundingBox(bb, dx, dy) { + return { + x1: bb.x1 + dx, + x2: bb.x2 + dx, + y1: bb.y1 + dy, + y2: bb.y2 + dy, + w: bb.w, + h: bb.h + }; +}; +var updateBoundingBox = function updateBoundingBox(bb1, bb2) { + // update bb1 with bb2 bounds + + bb1.x1 = Math.min(bb1.x1, bb2.x1); + bb1.x2 = Math.max(bb1.x2, bb2.x2); + bb1.w = bb1.x2 - bb1.x1; + bb1.y1 = Math.min(bb1.y1, bb2.y1); + bb1.y2 = Math.max(bb1.y2, bb2.y2); + bb1.h = bb1.y2 - bb1.y1; +}; +var expandBoundingBoxByPoint = function expandBoundingBoxByPoint(bb, x, y) { + bb.x1 = Math.min(bb.x1, x); + bb.x2 = Math.max(bb.x2, x); + bb.w = bb.x2 - bb.x1; + bb.y1 = Math.min(bb.y1, y); + bb.y2 = Math.max(bb.y2, y); + bb.h = bb.y2 - bb.y1; +}; +var expandBoundingBox = function expandBoundingBox(bb) { + var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + bb.x1 -= padding; + bb.x2 += padding; + bb.y1 -= padding; + bb.y2 += padding; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + return bb; +}; +var expandBoundingBoxSides = function expandBoundingBoxSides(bb) { + var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0]; + var top, right, bottom, left; + if (padding.length === 1) { + top = right = bottom = left = padding[0]; + } else if (padding.length === 2) { + top = bottom = padding[0]; + left = right = padding[1]; + } else if (padding.length === 4) { + var _padding = _slicedToArray(padding, 4); + top = _padding[0]; + right = _padding[1]; + bottom = _padding[2]; + left = _padding[3]; + } + bb.x1 -= left; + bb.x2 += right; + bb.y1 -= top; + bb.y2 += bottom; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + return bb; +}; + +// assign the values of bb2 into bb1 +var assignBoundingBox = function assignBoundingBox(bb1, bb2) { + bb1.x1 = bb2.x1; + bb1.y1 = bb2.y1; + bb1.x2 = bb2.x2; + bb1.y2 = bb2.y2; + bb1.w = bb1.x2 - bb1.x1; + bb1.h = bb1.y2 - bb1.y1; +}; +var boundingBoxesIntersect = function boundingBoxesIntersect(bb1, bb2) { + // case: one bb to right of other + if (bb1.x1 > bb2.x2) { + return false; + } + if (bb2.x1 > bb1.x2) { + return false; + } + + // case: one bb to left of other + if (bb1.x2 < bb2.x1) { + return false; + } + if (bb2.x2 < bb1.x1) { + return false; + } + + // case: one bb above other + if (bb1.y2 < bb2.y1) { + return false; + } + if (bb2.y2 < bb1.y1) { + return false; + } + + // case: one bb below other + if (bb1.y1 > bb2.y2) { + return false; + } + if (bb2.y1 > bb1.y2) { + return false; + } + + // otherwise, must have some overlap + return true; +}; +var inBoundingBox = function inBoundingBox(bb, x, y) { + return bb.x1 <= x && x <= bb.x2 && bb.y1 <= y && y <= bb.y2; +}; +var pointInBoundingBox = function pointInBoundingBox(bb, pt) { + return inBoundingBox(bb, pt.x, pt.y); +}; +var boundingBoxInBoundingBox = function boundingBoxInBoundingBox(bb1, bb2) { + return inBoundingBox(bb1, bb2.x1, bb2.y1) && inBoundingBox(bb1, bb2.x2, bb2.y2); +}; +var roundRectangleIntersectLine = function roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding) { + var radius = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'auto'; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : radius; + var halfWidth = width / 2; + var halfHeight = height / 2; + cornerRadius = Math.min(cornerRadius, halfWidth, halfHeight); + var doWidth = cornerRadius !== halfWidth, + doHeight = cornerRadius !== halfHeight; + + // Check intersections with straight line segments + var straightLineIntersections; + + // Top segment, left to right + if (doWidth) { + var topStartX = nodeX - halfWidth + cornerRadius - padding; + var topStartY = nodeY - halfHeight - padding; + var topEndX = nodeX + halfWidth - cornerRadius + padding; + var topEndY = topStartY; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Right segment, top to bottom + if (doHeight) { + var rightStartX = nodeX + halfWidth + padding; + var rightStartY = nodeY - halfHeight + cornerRadius - padding; + var rightEndX = rightStartX; + var rightEndY = nodeY + halfHeight - cornerRadius + padding; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, rightStartX, rightStartY, rightEndX, rightEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Bottom segment, left to right + if (doWidth) { + var bottomStartX = nodeX - halfWidth + cornerRadius - padding; + var bottomStartY = nodeY + halfHeight + padding; + var bottomEndX = nodeX + halfWidth - cornerRadius + padding; + var bottomEndY = bottomStartY; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, bottomStartX, bottomStartY, bottomEndX, bottomEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Left segment, top to bottom + if (doHeight) { + var leftStartX = nodeX - halfWidth - padding; + var leftStartY = nodeY - halfHeight + cornerRadius - padding; + var leftEndX = leftStartX; + var leftEndY = nodeY + halfHeight - cornerRadius + padding; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, leftStartX, leftStartY, leftEndX, leftEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Check intersections with arc segments + var arcIntersections; + + // Top Left + { + var topLeftCenterX = nodeX - halfWidth + cornerRadius; + var topLeftCenterY = nodeY - halfHeight + cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, topLeftCenterX, topLeftCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] <= topLeftCenterX && arcIntersections[1] <= topLeftCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Top Right + { + var topRightCenterX = nodeX + halfWidth - cornerRadius; + var topRightCenterY = nodeY - halfHeight + cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, topRightCenterX, topRightCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] >= topRightCenterX && arcIntersections[1] <= topRightCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Bottom Right + { + var bottomRightCenterX = nodeX + halfWidth - cornerRadius; + var bottomRightCenterY = nodeY + halfHeight - cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, bottomRightCenterX, bottomRightCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] >= bottomRightCenterX && arcIntersections[1] >= bottomRightCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Bottom Left + { + var bottomLeftCenterX = nodeX - halfWidth + cornerRadius; + var bottomLeftCenterY = nodeY + halfHeight - cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, bottomLeftCenterX, bottomLeftCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] <= bottomLeftCenterX && arcIntersections[1] >= bottomLeftCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + return []; // if nothing +}; + +var inLineVicinity = function inLineVicinity(x, y, lx1, ly1, lx2, ly2, tolerance) { + var t = tolerance; + var x1 = Math.min(lx1, lx2); + var x2 = Math.max(lx1, lx2); + var y1 = Math.min(ly1, ly2); + var y2 = Math.max(ly1, ly2); + return x1 - t <= x && x <= x2 + t && y1 - t <= y && y <= y2 + t; +}; +var inBezierVicinity = function inBezierVicinity(x, y, x1, y1, x2, y2, x3, y3, tolerance) { + var bb = { + x1: Math.min(x1, x3, x2) - tolerance, + x2: Math.max(x1, x3, x2) + tolerance, + y1: Math.min(y1, y3, y2) - tolerance, + y2: Math.max(y1, y3, y2) + tolerance + }; + + // if outside the rough bounding box for the bezier, then it can't be a hit + if (x < bb.x1 || x > bb.x2 || y < bb.y1 || y > bb.y2) { + // console.log('bezier out of rough bb') + return false; + } else { + // console.log('do more expensive check'); + return true; + } +}; +var solveQuadratic = function solveQuadratic(a, b, c, val) { + c -= val; + var r = b * b - 4 * a * c; + if (r < 0) { + return []; + } + var sqrtR = Math.sqrt(r); + var denom = 2 * a; + var root1 = (-b + sqrtR) / denom; + var root2 = (-b - sqrtR) / denom; + return [root1, root2]; +}; +var solveCubic = function solveCubic(a, b, c, d, result) { + // Solves a cubic function, returns root in form [r1, i1, r2, i2, r3, i3], where + // r is the real component, i is the imaginary component + + // An implementation of the Cardano method from the year 1545 + // http://en.wikipedia.org/wiki/Cubic_function#The_nature_of_the_roots + + var epsilon = 0.00001; + + // avoid division by zero while keeping the overall expression close in value + if (a === 0) { + a = epsilon; + } + b /= a; + c /= a; + d /= a; + var discriminant, q, r, dum1, s, t, term1, r13; + q = (3.0 * c - b * b) / 9.0; + r = -(27.0 * d) + b * (9.0 * c - 2.0 * (b * b)); + r /= 54.0; + discriminant = q * q * q + r * r; + result[1] = 0; + term1 = b / 3.0; + if (discriminant > 0) { + s = r + Math.sqrt(discriminant); + s = s < 0 ? -Math.pow(-s, 1.0 / 3.0) : Math.pow(s, 1.0 / 3.0); + t = r - Math.sqrt(discriminant); + t = t < 0 ? -Math.pow(-t, 1.0 / 3.0) : Math.pow(t, 1.0 / 3.0); + result[0] = -term1 + s + t; + term1 += (s + t) / 2.0; + result[4] = result[2] = -term1; + term1 = Math.sqrt(3.0) * (-t + s) / 2; + result[3] = term1; + result[5] = -term1; + return; + } + result[5] = result[3] = 0; + if (discriminant === 0) { + r13 = r < 0 ? -Math.pow(-r, 1.0 / 3.0) : Math.pow(r, 1.0 / 3.0); + result[0] = -term1 + 2.0 * r13; + result[4] = result[2] = -(r13 + term1); + return; + } + q = -q; + dum1 = q * q * q; + dum1 = Math.acos(r / Math.sqrt(dum1)); + r13 = 2.0 * Math.sqrt(q); + result[0] = -term1 + r13 * Math.cos(dum1 / 3.0); + result[2] = -term1 + r13 * Math.cos((dum1 + 2.0 * Math.PI) / 3.0); + result[4] = -term1 + r13 * Math.cos((dum1 + 4.0 * Math.PI) / 3.0); + return; +}; +var sqdistToQuadraticBezier = function sqdistToQuadraticBezier(x, y, x1, y1, x2, y2, x3, y3) { + // Find minimum distance by using the minimum of the distance + // function between the given point and the curve + + // This gives the coefficients of the resulting cubic equation + // whose roots tell us where a possible minimum is + // (Coefficients are divided by 4) + + var a = 1.0 * x1 * x1 - 4 * x1 * x2 + 2 * x1 * x3 + 4 * x2 * x2 - 4 * x2 * x3 + x3 * x3 + y1 * y1 - 4 * y1 * y2 + 2 * y1 * y3 + 4 * y2 * y2 - 4 * y2 * y3 + y3 * y3; + var b = 1.0 * 9 * x1 * x2 - 3 * x1 * x1 - 3 * x1 * x3 - 6 * x2 * x2 + 3 * x2 * x3 + 9 * y1 * y2 - 3 * y1 * y1 - 3 * y1 * y3 - 6 * y2 * y2 + 3 * y2 * y3; + var c = 1.0 * 3 * x1 * x1 - 6 * x1 * x2 + x1 * x3 - x1 * x + 2 * x2 * x2 + 2 * x2 * x - x3 * x + 3 * y1 * y1 - 6 * y1 * y2 + y1 * y3 - y1 * y + 2 * y2 * y2 + 2 * y2 * y - y3 * y; + var d = 1.0 * x1 * x2 - x1 * x1 + x1 * x - x2 * x + y1 * y2 - y1 * y1 + y1 * y - y2 * y; + + // debug("coefficients: " + a / a + ", " + b / a + ", " + c / a + ", " + d / a); + + var roots = []; + + // Use the cubic solving algorithm + solveCubic(a, b, c, d, roots); + var zeroThreshold = 0.0000001; + var params = []; + for (var index = 0; index < 6; index += 2) { + if (Math.abs(roots[index + 1]) < zeroThreshold && roots[index] >= 0 && roots[index] <= 1.0) { + params.push(roots[index]); + } + } + params.push(1.0); + params.push(0.0); + var minDistanceSquared = -1; + var curX, curY, distSquared; + for (var i = 0; i < params.length; i++) { + curX = Math.pow(1.0 - params[i], 2.0) * x1 + 2.0 * (1 - params[i]) * params[i] * x2 + params[i] * params[i] * x3; + curY = Math.pow(1 - params[i], 2.0) * y1 + 2 * (1.0 - params[i]) * params[i] * y2 + params[i] * params[i] * y3; + distSquared = Math.pow(curX - x, 2) + Math.pow(curY - y, 2); + // debug('distance for param ' + params[i] + ": " + Math.sqrt(distSquared)); + if (minDistanceSquared >= 0) { + if (distSquared < minDistanceSquared) { + minDistanceSquared = distSquared; + } + } else { + minDistanceSquared = distSquared; + } + } + return minDistanceSquared; +}; +var sqdistToFiniteLine = function sqdistToFiniteLine(x, y, x1, y1, x2, y2) { + var offset = [x - x1, y - y1]; + var line = [x2 - x1, y2 - y1]; + var lineSq = line[0] * line[0] + line[1] * line[1]; + var hypSq = offset[0] * offset[0] + offset[1] * offset[1]; + var dotProduct = offset[0] * line[0] + offset[1] * line[1]; + var adjSq = dotProduct * dotProduct / lineSq; + if (dotProduct < 0) { + return hypSq; + } + if (adjSq > lineSq) { + return (x - x2) * (x - x2) + (y - y2) * (y - y2); + } + return hypSq - adjSq; +}; +var pointInsidePolygonPoints = function pointInsidePolygonPoints(x, y, points) { + var x1, y1, x2, y2; + var y3; + + // Intersect with vertical line through (x, y) + var up = 0; + // let down = 0; + for (var i = 0; i < points.length / 2; i++) { + x1 = points[i * 2]; + y1 = points[i * 2 + 1]; + if (i + 1 < points.length / 2) { + x2 = points[(i + 1) * 2]; + y2 = points[(i + 1) * 2 + 1]; + } else { + x2 = points[(i + 1 - points.length / 2) * 2]; + y2 = points[(i + 1 - points.length / 2) * 2 + 1]; + } + if (x1 == x && x2 == x) ; else if (x1 >= x && x >= x2 || x1 <= x && x <= x2) { + y3 = (x - x1) / (x2 - x1) * (y2 - y1) + y1; + if (y3 > y) { + up++; + } + + // if( y3 < y ){ + // down++; + // } + } else { + continue; + } + } + if (up % 2 === 0) { + return false; + } else { + return true; + } +}; +var pointInsidePolygon = function pointInsidePolygon(x, y, basePoints, centerX, centerY, width, height, direction, padding) { + var transformedPoints = new Array(basePoints.length); + + // Gives negative angle + var angle; + if (direction[0] != null) { + angle = Math.atan(direction[1] / direction[0]); + if (direction[0] < 0) { + angle = angle + Math.PI / 2; + } else { + angle = -angle - Math.PI / 2; + } + } else { + angle = direction; + } + var cos = Math.cos(-angle); + var sin = Math.sin(-angle); + + // console.log("base: " + basePoints); + for (var i = 0; i < transformedPoints.length / 2; i++) { + transformedPoints[i * 2] = width / 2 * (basePoints[i * 2] * cos - basePoints[i * 2 + 1] * sin); + transformedPoints[i * 2 + 1] = height / 2 * (basePoints[i * 2 + 1] * cos + basePoints[i * 2] * sin); + transformedPoints[i * 2] += centerX; + transformedPoints[i * 2 + 1] += centerY; + } + var points; + if (padding > 0) { + var expandedLineSet = expandPolygon(transformedPoints, -padding); + points = joinLines(expandedLineSet); + } else { + points = transformedPoints; + } + return pointInsidePolygonPoints(x, y, points); +}; +var pointInsideRoundPolygon = function pointInsideRoundPolygon(x, y, basePoints, centerX, centerY, width, height, corners) { + var cutPolygonPoints = new Array(basePoints.length * 2); + for (var i = 0; i < corners.length; i++) { + var corner = corners[i]; + cutPolygonPoints[i * 4 + 0] = corner.startX; + cutPolygonPoints[i * 4 + 1] = corner.startY; + cutPolygonPoints[i * 4 + 2] = corner.stopX; + cutPolygonPoints[i * 4 + 3] = corner.stopY; + var squaredDistance = Math.pow(corner.cx - x, 2) + Math.pow(corner.cy - y, 2); + if (squaredDistance <= Math.pow(corner.radius, 2)) { + return true; + } + } + return pointInsidePolygonPoints(x, y, cutPolygonPoints); +}; +var joinLines = function joinLines(lineSet) { + var vertices = new Array(lineSet.length / 2); + var currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY; + var nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY; + for (var i = 0; i < lineSet.length / 4; i++) { + currentLineStartX = lineSet[i * 4]; + currentLineStartY = lineSet[i * 4 + 1]; + currentLineEndX = lineSet[i * 4 + 2]; + currentLineEndY = lineSet[i * 4 + 3]; + if (i < lineSet.length / 4 - 1) { + nextLineStartX = lineSet[(i + 1) * 4]; + nextLineStartY = lineSet[(i + 1) * 4 + 1]; + nextLineEndX = lineSet[(i + 1) * 4 + 2]; + nextLineEndY = lineSet[(i + 1) * 4 + 3]; + } else { + nextLineStartX = lineSet[0]; + nextLineStartY = lineSet[1]; + nextLineEndX = lineSet[2]; + nextLineEndY = lineSet[3]; + } + var intersection = finiteLinesIntersect(currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY, nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY, true); + vertices[i * 2] = intersection[0]; + vertices[i * 2 + 1] = intersection[1]; + } + return vertices; +}; +var expandPolygon = function expandPolygon(points, pad) { + var expandedLineSet = new Array(points.length * 2); + var currentPointX, currentPointY, nextPointX, nextPointY; + for (var i = 0; i < points.length / 2; i++) { + currentPointX = points[i * 2]; + currentPointY = points[i * 2 + 1]; + if (i < points.length / 2 - 1) { + nextPointX = points[(i + 1) * 2]; + nextPointY = points[(i + 1) * 2 + 1]; + } else { + nextPointX = points[0]; + nextPointY = points[1]; + } + + // Current line: [currentPointX, currentPointY] to [nextPointX, nextPointY] + + // Assume CCW polygon winding + + var offsetX = nextPointY - currentPointY; + var offsetY = -(nextPointX - currentPointX); + + // Normalize + var offsetLength = Math.sqrt(offsetX * offsetX + offsetY * offsetY); + var normalizedOffsetX = offsetX / offsetLength; + var normalizedOffsetY = offsetY / offsetLength; + expandedLineSet[i * 4] = currentPointX + normalizedOffsetX * pad; + expandedLineSet[i * 4 + 1] = currentPointY + normalizedOffsetY * pad; + expandedLineSet[i * 4 + 2] = nextPointX + normalizedOffsetX * pad; + expandedLineSet[i * 4 + 3] = nextPointY + normalizedOffsetY * pad; + } + return expandedLineSet; +}; +var intersectLineEllipse = function intersectLineEllipse(x, y, centerX, centerY, ellipseWradius, ellipseHradius) { + var dispX = centerX - x; + var dispY = centerY - y; + dispX /= ellipseWradius; + dispY /= ellipseHradius; + var len = Math.sqrt(dispX * dispX + dispY * dispY); + var newLength = len - 1; + if (newLength < 0) { + return []; + } + var lenProportion = newLength / len; + return [(centerX - x) * lenProportion + x, (centerY - y) * lenProportion + y]; +}; +var checkInEllipse = function checkInEllipse(x, y, width, height, centerX, centerY, padding) { + x -= centerX; + y -= centerY; + x /= width / 2 + padding; + y /= height / 2 + padding; + return x * x + y * y <= 1; +}; + +// Returns intersections of increasing distance from line's start point +var intersectLineCircle = function intersectLineCircle(x1, y1, x2, y2, centerX, centerY, radius) { + // Calculate d, direction vector of line + var d = [x2 - x1, y2 - y1]; // Direction vector of line + var f = [x1 - centerX, y1 - centerY]; + var a = d[0] * d[0] + d[1] * d[1]; + var b = 2 * (f[0] * d[0] + f[1] * d[1]); + var c = f[0] * f[0] + f[1] * f[1] - radius * radius; + var discriminant = b * b - 4 * a * c; + if (discriminant < 0) { + return []; + } + var t1 = (-b + Math.sqrt(discriminant)) / (2 * a); + var t2 = (-b - Math.sqrt(discriminant)) / (2 * a); + var tMin = Math.min(t1, t2); + var tMax = Math.max(t1, t2); + var inRangeParams = []; + if (tMin >= 0 && tMin <= 1) { + inRangeParams.push(tMin); + } + if (tMax >= 0 && tMax <= 1) { + inRangeParams.push(tMax); + } + if (inRangeParams.length === 0) { + return []; + } + var nearIntersectionX = inRangeParams[0] * d[0] + x1; + var nearIntersectionY = inRangeParams[0] * d[1] + y1; + if (inRangeParams.length > 1) { + if (inRangeParams[0] == inRangeParams[1]) { + return [nearIntersectionX, nearIntersectionY]; + } else { + var farIntersectionX = inRangeParams[1] * d[0] + x1; + var farIntersectionY = inRangeParams[1] * d[1] + y1; + return [nearIntersectionX, nearIntersectionY, farIntersectionX, farIntersectionY]; + } + } else { + return [nearIntersectionX, nearIntersectionY]; + } +}; +var midOfThree = function midOfThree(a, b, c) { + if (b <= a && a <= c || c <= a && a <= b) { + return a; + } else if (a <= b && b <= c || c <= b && b <= a) { + return b; + } else { + return c; + } +}; + +// (x1,y1)=>(x2,y2) intersect with (x3,y3)=>(x4,y4) +var finiteLinesIntersect = function finiteLinesIntersect(x1, y1, x2, y2, x3, y3, x4, y4, infiniteLines) { + var dx13 = x1 - x3; + var dx21 = x2 - x1; + var dx43 = x4 - x3; + var dy13 = y1 - y3; + var dy21 = y2 - y1; + var dy43 = y4 - y3; + var ua_t = dx43 * dy13 - dy43 * dx13; + var ub_t = dx21 * dy13 - dy21 * dx13; + var u_b = dy43 * dx21 - dx43 * dy21; + if (u_b !== 0) { + var ua = ua_t / u_b; + var ub = ub_t / u_b; + var flptThreshold = 0.001; + var _min = 0 - flptThreshold; + var _max = 1 + flptThreshold; + if (_min <= ua && ua <= _max && _min <= ub && ub <= _max) { + return [x1 + ua * dx21, y1 + ua * dy21]; + } else { + if (!infiniteLines) { + return []; + } else { + return [x1 + ua * dx21, y1 + ua * dy21]; + } + } + } else { + if (ua_t === 0 || ub_t === 0) { + // Parallel, coincident lines. Check if overlap + + // Check endpoint of second line + if (midOfThree(x1, x2, x4) === x4) { + return [x4, y4]; + } + + // Check start point of second line + if (midOfThree(x1, x2, x3) === x3) { + return [x3, y3]; + } + + // Endpoint of first line + if (midOfThree(x3, x4, x2) === x2) { + return [x2, y2]; + } + return []; + } else { + // Parallel, non-coincident + return []; + } + } +}; + +// math.polygonIntersectLine( x, y, basePoints, centerX, centerY, width, height, padding ) +// intersect a node polygon (pts transformed) +// +// math.polygonIntersectLine( x, y, basePoints, centerX, centerY ) +// intersect the points (no transform) +var polygonIntersectLine = function polygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding) { + var intersections = []; + var intersection; + var transformedPoints = new Array(basePoints.length); + var doTransform = true; + if (width == null) { + doTransform = false; + } + var points; + if (doTransform) { + for (var i = 0; i < transformedPoints.length / 2; i++) { + transformedPoints[i * 2] = basePoints[i * 2] * width + centerX; + transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY; + } + if (padding > 0) { + var expandedLineSet = expandPolygon(transformedPoints, -padding); + points = joinLines(expandedLineSet); + } else { + points = transformedPoints; + } + } else { + points = basePoints; + } + var currentX, currentY, nextX, nextY; + for (var _i2 = 0; _i2 < points.length / 2; _i2++) { + currentX = points[_i2 * 2]; + currentY = points[_i2 * 2 + 1]; + if (_i2 < points.length / 2 - 1) { + nextX = points[(_i2 + 1) * 2]; + nextY = points[(_i2 + 1) * 2 + 1]; + } else { + nextX = points[0]; + nextY = points[1]; + } + intersection = finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + } + return intersections; +}; +var roundPolygonIntersectLine = function roundPolygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding, corners) { + var intersections = []; + var intersection; + var lines = new Array(basePoints.length * 2); + corners.forEach(function (corner, i) { + if (i === 0) { + lines[lines.length - 2] = corner.startX; + lines[lines.length - 1] = corner.startY; + } else { + lines[i * 4 - 2] = corner.startX; + lines[i * 4 - 1] = corner.startY; + } + lines[i * 4] = corner.stopX; + lines[i * 4 + 1] = corner.stopY; + intersection = intersectLineCircle(x, y, centerX, centerY, corner.cx, corner.cy, corner.radius); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + }); + for (var i = 0; i < lines.length / 4; i++) { + intersection = finiteLinesIntersect(x, y, centerX, centerY, lines[i * 4], lines[i * 4 + 1], lines[i * 4 + 2], lines[i * 4 + 3], false); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + } + if (intersections.length > 2) { + var lowestIntersection = [intersections[0], intersections[1]]; + var lowestSquaredDistance = Math.pow(lowestIntersection[0] - x, 2) + Math.pow(lowestIntersection[1] - y, 2); + for (var _i3 = 1; _i3 < intersections.length / 2; _i3++) { + var squaredDistance = Math.pow(intersections[_i3 * 2] - x, 2) + Math.pow(intersections[_i3 * 2 + 1] - y, 2); + if (squaredDistance <= lowestSquaredDistance) { + lowestIntersection[0] = intersections[_i3 * 2]; + lowestIntersection[1] = intersections[_i3 * 2 + 1]; + lowestSquaredDistance = squaredDistance; + } + } + return lowestIntersection; + } + return intersections; +}; +var shortenIntersection = function shortenIntersection(intersection, offset, amount) { + var disp = [intersection[0] - offset[0], intersection[1] - offset[1]]; + var length = Math.sqrt(disp[0] * disp[0] + disp[1] * disp[1]); + var lenRatio = (length - amount) / length; + if (lenRatio < 0) { + lenRatio = 0.00001; + } + return [offset[0] + lenRatio * disp[0], offset[1] + lenRatio * disp[1]]; +}; +var generateUnitNgonPointsFitToSquare = function generateUnitNgonPointsFitToSquare(sides, rotationRadians) { + var points = generateUnitNgonPoints(sides, rotationRadians); + points = fitPolygonToSquare(points); + return points; +}; +var fitPolygonToSquare = function fitPolygonToSquare(points) { + var x, y; + var sides = points.length / 2; + var minX = Infinity, + minY = Infinity, + maxX = -Infinity, + maxY = -Infinity; + for (var i = 0; i < sides; i++) { + x = points[2 * i]; + y = points[2 * i + 1]; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + + // stretch factors + var sx = 2 / (maxX - minX); + var sy = 2 / (maxY - minY); + for (var _i4 = 0; _i4 < sides; _i4++) { + x = points[2 * _i4] = points[2 * _i4] * sx; + y = points[2 * _i4 + 1] = points[2 * _i4 + 1] * sy; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + if (minY < -1) { + for (var _i5 = 0; _i5 < sides; _i5++) { + y = points[2 * _i5 + 1] = points[2 * _i5 + 1] + (-1 - minY); + } + } + return points; +}; +var generateUnitNgonPoints = function generateUnitNgonPoints(sides, rotationRadians) { + var increment = 1.0 / sides * 2 * Math.PI; + var startAngle = sides % 2 === 0 ? Math.PI / 2.0 + increment / 2.0 : Math.PI / 2.0; + startAngle += rotationRadians; + var points = new Array(sides * 2); + var currentAngle; + for (var i = 0; i < sides; i++) { + currentAngle = i * increment + startAngle; + points[2 * i] = Math.cos(currentAngle); // x + points[2 * i + 1] = Math.sin(-currentAngle); // y + } + + return points; +}; + +// Set the default radius, unless half of width or height is smaller than default +var getRoundRectangleRadius = function getRoundRectangleRadius(width, height) { + return Math.min(width / 4, height / 4, 8); +}; + +// Set the default radius +var getRoundPolygonRadius = function getRoundPolygonRadius(width, height) { + return Math.min(width / 10, height / 10, 8); +}; +var getCutRectangleCornerLength = function getCutRectangleCornerLength() { + return 8; +}; +var bezierPtsToQuadCoeff = function bezierPtsToQuadCoeff(p0, p1, p2) { + return [p0 - 2 * p1 + p2, 2 * (p1 - p0), p0]; +}; + +// get curve width, height, and control point position offsets as a percentage of node height / width +var getBarrelCurveConstants = function getBarrelCurveConstants(width, height) { + return { + heightOffset: Math.min(15, 0.05 * height), + widthOffset: Math.min(100, 0.25 * width), + ctrlPtOffsetPct: 0.05 + }; +}; + +var pageRankDefaults = defaults$g({ + dampingFactor: 0.8, + precision: 0.000001, + iterations: 200, + weight: function weight(edge) { + return 1; + } +}); +var elesfn$o = { + pageRank: function pageRank(options) { + var _pageRankDefaults = pageRankDefaults(options), + dampingFactor = _pageRankDefaults.dampingFactor, + precision = _pageRankDefaults.precision, + iterations = _pageRankDefaults.iterations, + weight = _pageRankDefaults.weight; + var cy = this._private.cy; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var numNodes = nodes.length; + var numNodesSqd = numNodes * numNodes; + var numEdges = edges.length; + + // Construct transposed adjacency matrix + // First lets have a zeroed matrix of the right size + // We'll also keep track of the sum of each column + var matrix = new Array(numNodesSqd); + var columnSum = new Array(numNodes); + var additionalProb = (1 - dampingFactor) / numNodes; + + // Create null matrix + for (var i = 0; i < numNodes; i++) { + for (var j = 0; j < numNodes; j++) { + var n = i * numNodes + j; + matrix[n] = 0; + } + columnSum[i] = 0; + } + + // Now, process edges + for (var _i = 0; _i < numEdges; _i++) { + var edge = edges[_i]; + var srcId = edge.data('source'); + var tgtId = edge.data('target'); + + // Don't include loops in the matrix + if (srcId === tgtId) { + continue; + } + var s = nodes.indexOfId(srcId); + var t = nodes.indexOfId(tgtId); + var w = weight(edge); + var _n = t * numNodes + s; + + // Update matrix + matrix[_n] += w; + + // Update column sum + columnSum[s] += w; + } + + // Add additional probability based on damping factor + // Also, take into account columns that have sum = 0 + var p = 1.0 / numNodes + additionalProb; // Shorthand + + // Traverse matrix, column by column + for (var _j = 0; _j < numNodes; _j++) { + if (columnSum[_j] === 0) { + // No 'links' out from node jth, assume equal probability for each possible node + for (var _i2 = 0; _i2 < numNodes; _i2++) { + var _n2 = _i2 * numNodes + _j; + matrix[_n2] = p; + } + } else { + // Node jth has outgoing link, compute normalized probabilities + for (var _i3 = 0; _i3 < numNodes; _i3++) { + var _n3 = _i3 * numNodes + _j; + matrix[_n3] = matrix[_n3] / columnSum[_j] + additionalProb; + } + } + } + + // Compute dominant eigenvector using power method + var eigenvector = new Array(numNodes); + var temp = new Array(numNodes); + var previous; + + // Start with a vector of all 1's + // Also, initialize a null vector which will be used as shorthand + for (var _i4 = 0; _i4 < numNodes; _i4++) { + eigenvector[_i4] = 1; + } + for (var iter = 0; iter < iterations; iter++) { + // Temp array with all 0's + for (var _i5 = 0; _i5 < numNodes; _i5++) { + temp[_i5] = 0; + } + + // Multiply matrix with previous result + for (var _i6 = 0; _i6 < numNodes; _i6++) { + for (var _j2 = 0; _j2 < numNodes; _j2++) { + var _n4 = _i6 * numNodes + _j2; + temp[_i6] += matrix[_n4] * eigenvector[_j2]; + } + } + inPlaceSumNormalize(temp); + previous = eigenvector; + eigenvector = temp; + temp = previous; + var diff = 0; + // Compute difference (squared module) of both vectors + for (var _i7 = 0; _i7 < numNodes; _i7++) { + var delta = previous[_i7] - eigenvector[_i7]; + diff += delta * delta; + } + + // If difference is less than the desired threshold, stop iterating + if (diff < precision) { + break; + } + } + + // Construct result + var res = { + rank: function rank(node) { + node = cy.collection(node)[0]; + return eigenvector[nodes.indexOf(node)]; + } + }; + return res; + } // pageRank +}; // elesfn + +var defaults$f = defaults$g({ + root: null, + weight: function weight(edge) { + return 1; + }, + directed: false, + alpha: 0 +}); +var elesfn$n = { + degreeCentralityNormalized: function degreeCentralityNormalized(options) { + options = defaults$f(options); + var cy = this.cy(); + var nodes = this.nodes(); + var numNodes = nodes.length; + if (!options.directed) { + var degrees = {}; + var maxDegree = 0; + for (var i = 0; i < numNodes; i++) { + var node = nodes[i]; + + // add current node to the current options object and call degreeCentrality + options.root = node; + var currDegree = this.degreeCentrality(options); + if (maxDegree < currDegree.degree) { + maxDegree = currDegree.degree; + } + degrees[node.id()] = currDegree.degree; + } + return { + degree: function degree(node) { + if (maxDegree === 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return degrees[node.id()] / maxDegree; + } + }; + } else { + var indegrees = {}; + var outdegrees = {}; + var maxIndegree = 0; + var maxOutdegree = 0; + for (var _i = 0; _i < numNodes; _i++) { + var _node = nodes[_i]; + var id = _node.id(); + + // add current node to the current options object and call degreeCentrality + options.root = _node; + var _currDegree = this.degreeCentrality(options); + if (maxIndegree < _currDegree.indegree) maxIndegree = _currDegree.indegree; + if (maxOutdegree < _currDegree.outdegree) maxOutdegree = _currDegree.outdegree; + indegrees[id] = _currDegree.indegree; + outdegrees[id] = _currDegree.outdegree; + } + return { + indegree: function indegree(node) { + if (maxIndegree == 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return indegrees[node.id()] / maxIndegree; + }, + outdegree: function outdegree(node) { + if (maxOutdegree === 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return outdegrees[node.id()] / maxOutdegree; + } + }; + } + }, + // degreeCentralityNormalized + + // Implemented from the algorithm in Opsahl's paper + // "Node centrality in weighted networks: Generalizing degree and shortest paths" + // check the heading 2 "Degree" + degreeCentrality: function degreeCentrality(options) { + options = defaults$f(options); + var cy = this.cy(); + var callingEles = this; + var _options = options, + root = _options.root, + weight = _options.weight, + directed = _options.directed, + alpha = _options.alpha; + root = cy.collection(root)[0]; + if (!directed) { + var connEdges = root.connectedEdges().intersection(callingEles); + var k = connEdges.length; + var s = 0; + + // Now, sum edge weights + for (var i = 0; i < connEdges.length; i++) { + s += weight(connEdges[i]); + } + return { + degree: Math.pow(k, 1 - alpha) * Math.pow(s, alpha) + }; + } else { + var edges = root.connectedEdges(); + var incoming = edges.filter(function (edge) { + return edge.target().same(root) && callingEles.has(edge); + }); + var outgoing = edges.filter(function (edge) { + return edge.source().same(root) && callingEles.has(edge); + }); + var k_in = incoming.length; + var k_out = outgoing.length; + var s_in = 0; + var s_out = 0; + + // Now, sum incoming edge weights + for (var _i2 = 0; _i2 < incoming.length; _i2++) { + s_in += weight(incoming[_i2]); + } + + // Now, sum outgoing edge weights + for (var _i3 = 0; _i3 < outgoing.length; _i3++) { + s_out += weight(outgoing[_i3]); + } + return { + indegree: Math.pow(k_in, 1 - alpha) * Math.pow(s_in, alpha), + outdegree: Math.pow(k_out, 1 - alpha) * Math.pow(s_out, alpha) + }; + } + } // degreeCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$n.dc = elesfn$n.degreeCentrality; +elesfn$n.dcn = elesfn$n.degreeCentralityNormalised = elesfn$n.degreeCentralityNormalized; + +var defaults$e = defaults$g({ + harmonic: true, + weight: function weight() { + return 1; + }, + directed: false, + root: null +}); +var elesfn$m = { + closenessCentralityNormalized: function closenessCentralityNormalized(options) { + var _defaults = defaults$e(options), + harmonic = _defaults.harmonic, + weight = _defaults.weight, + directed = _defaults.directed; + var cy = this.cy(); + var closenesses = {}; + var maxCloseness = 0; + var nodes = this.nodes(); + var fw = this.floydWarshall({ + weight: weight, + directed: directed + }); + + // Compute closeness for every node and find the maximum closeness + for (var i = 0; i < nodes.length; i++) { + var currCloseness = 0; + var node_i = nodes[i]; + for (var j = 0; j < nodes.length; j++) { + if (i !== j) { + var d = fw.distance(node_i, nodes[j]); + if (harmonic) { + currCloseness += 1 / d; + } else { + currCloseness += d; + } + } + } + if (!harmonic) { + currCloseness = 1 / currCloseness; + } + if (maxCloseness < currCloseness) { + maxCloseness = currCloseness; + } + closenesses[node_i.id()] = currCloseness; + } + return { + closeness: function closeness(node) { + if (maxCloseness == 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node)[0].id(); + } else { + // from is a node + node = node.id(); + } + return closenesses[node] / maxCloseness; + } + }; + }, + // Implemented from pseudocode from wikipedia + closenessCentrality: function closenessCentrality(options) { + var _defaults2 = defaults$e(options), + root = _defaults2.root, + weight = _defaults2.weight, + directed = _defaults2.directed, + harmonic = _defaults2.harmonic; + root = this.filter(root)[0]; + + // we need distance from this node to every other node + var dijkstra = this.dijkstra({ + root: root, + weight: weight, + directed: directed + }); + var totalDistance = 0; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + if (!n.same(root)) { + var d = dijkstra.distanceTo(n); + if (harmonic) { + totalDistance += 1 / d; + } else { + totalDistance += d; + } + } + } + return harmonic ? totalDistance : 1 / totalDistance; + } // closenessCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$m.cc = elesfn$m.closenessCentrality; +elesfn$m.ccn = elesfn$m.closenessCentralityNormalised = elesfn$m.closenessCentralityNormalized; + +var defaults$d = defaults$g({ + weight: null, + directed: false +}); +var elesfn$l = { + // Implemented from the algorithm in the paper "On Variants of Shortest-Path Betweenness Centrality and their Generic Computation" by Ulrik Brandes + betweennessCentrality: function betweennessCentrality(options) { + var _defaults = defaults$d(options), + directed = _defaults.directed, + weight = _defaults.weight; + var weighted = weight != null; + var cy = this.cy(); + + // starting + var V = this.nodes(); + var A = {}; + var _C = {}; + var max = 0; + var C = { + set: function set(key, val) { + _C[key] = val; + if (val > max) { + max = val; + } + }, + get: function get(key) { + return _C[key]; + } + }; + + // A contains the neighborhoods of every node + for (var i = 0; i < V.length; i++) { + var v = V[i]; + var vid = v.id(); + if (directed) { + A[vid] = v.outgoers().nodes(); // get outgoers of every node + } else { + A[vid] = v.openNeighborhood().nodes(); // get neighbors of every node + } + + C.set(vid, 0); + } + var _loop = function _loop(s) { + var sid = V[s].id(); + var S = []; // stack + var P = {}; + var g = {}; + var d = {}; + var Q = new heap(function (a, b) { + return d[a] - d[b]; + }); // queue + + // init dictionaries + for (var _i = 0; _i < V.length; _i++) { + var _vid = V[_i].id(); + P[_vid] = []; + g[_vid] = 0; + d[_vid] = Infinity; + } + g[sid] = 1; // sigma + d[sid] = 0; // distance to s + + Q.push(sid); + while (!Q.empty()) { + var _v = Q.pop(); + S.push(_v); + if (weighted) { + for (var j = 0; j < A[_v].length; j++) { + var w = A[_v][j]; + var vEle = cy.getElementById(_v); + var edge = void 0; + if (vEle.edgesTo(w).length > 0) { + edge = vEle.edgesTo(w)[0]; + } else { + edge = w.edgesTo(vEle)[0]; + } + var edgeWeight = weight(edge); + w = w.id(); + if (d[w] > d[_v] + edgeWeight) { + d[w] = d[_v] + edgeWeight; + if (Q.nodes.indexOf(w) < 0) { + //if w is not in Q + Q.push(w); + } else { + // update position if w is in Q + Q.updateItem(w); + } + g[w] = 0; + P[w] = []; + } + if (d[w] == d[_v] + edgeWeight) { + g[w] = g[w] + g[_v]; + P[w].push(_v); + } + } + } else { + for (var _j = 0; _j < A[_v].length; _j++) { + var _w = A[_v][_j].id(); + if (d[_w] == Infinity) { + Q.push(_w); + d[_w] = d[_v] + 1; + } + if (d[_w] == d[_v] + 1) { + g[_w] = g[_w] + g[_v]; + P[_w].push(_v); + } + } + } + } + var e = {}; + for (var _i2 = 0; _i2 < V.length; _i2++) { + e[V[_i2].id()] = 0; + } + while (S.length > 0) { + var _w2 = S.pop(); + for (var _j2 = 0; _j2 < P[_w2].length; _j2++) { + var _v2 = P[_w2][_j2]; + e[_v2] = e[_v2] + g[_v2] / g[_w2] * (1 + e[_w2]); + } + if (_w2 != V[s].id()) { + C.set(_w2, C.get(_w2) + e[_w2]); + } + } + }; + for (var s = 0; s < V.length; s++) { + _loop(s); + } + var ret = { + betweenness: function betweenness(node) { + var id = cy.collection(node).id(); + return C.get(id); + }, + betweennessNormalized: function betweennessNormalized(node) { + if (max == 0) { + return 0; + } + var id = cy.collection(node).id(); + return C.get(id) / max; + } + }; + + // alias + ret.betweennessNormalised = ret.betweennessNormalized; + return ret; + } // betweennessCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$l.bc = elesfn$l.betweennessCentrality; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 + +/* eslint-disable no-unused-vars */ +var defaults$c = defaults$g({ + expandFactor: 2, + // affects time of computation and cluster granularity to some extent: M * M + inflateFactor: 2, + // affects cluster granularity (the greater the value, the more clusters): M(i,j) / E(j) + multFactor: 1, + // optional self loops for each node. Use a neutral value to improve cluster computations. + maxIterations: 20, + // maximum number of iterations of the MCL algorithm in a single run + attributes: [ + // attributes/features used to group nodes, ie. similarity values between nodes + function (edge) { + return 1; + }] +}); +/* eslint-enable */ + +var setOptions$3 = function setOptions(options) { + return defaults$c(options); +}; +/* eslint-enable */ + +var getSimilarity$1 = function getSimilarity(edge, attributes) { + var total = 0; + for (var i = 0; i < attributes.length; i++) { + total += attributes[i](edge); + } + return total; +}; +var addLoops = function addLoops(M, n, val) { + for (var i = 0; i < n; i++) { + M[i * n + i] = val; + } +}; +var normalize = function normalize(M, n) { + var sum; + for (var col = 0; col < n; col++) { + sum = 0; + for (var row = 0; row < n; row++) { + sum += M[row * n + col]; + } + for (var _row = 0; _row < n; _row++) { + M[_row * n + col] = M[_row * n + col] / sum; + } + } +}; + +// TODO: blocked matrix multiplication? +var mmult = function mmult(A, B, n) { + var C = new Array(n * n); + for (var i = 0; i < n; i++) { + for (var j = 0; j < n; j++) { + C[i * n + j] = 0; + } + for (var k = 0; k < n; k++) { + for (var _j = 0; _j < n; _j++) { + C[i * n + _j] += A[i * n + k] * B[k * n + _j]; + } + } + } + return C; +}; +var expand = function expand(M, n, expandFactor /** power **/) { + var _M = M.slice(0); + for (var p = 1; p < expandFactor; p++) { + M = mmult(M, _M, n); + } + return M; +}; +var inflate = function inflate(M, n, inflateFactor /** r **/) { + var _M = new Array(n * n); + + // M(i,j) ^ inflatePower + for (var i = 0; i < n * n; i++) { + _M[i] = Math.pow(M[i], inflateFactor); + } + normalize(_M, n); + return _M; +}; +var hasConverged = function hasConverged(M, _M, n2, roundFactor) { + // Check that both matrices have the same elements (i,j) + for (var i = 0; i < n2; i++) { + var v1 = Math.round(M[i] * Math.pow(10, roundFactor)) / Math.pow(10, roundFactor); // truncate to 'roundFactor' decimal places + var v2 = Math.round(_M[i] * Math.pow(10, roundFactor)) / Math.pow(10, roundFactor); + if (v1 !== v2) { + return false; + } + } + return true; +}; +var assign$2 = function assign(M, n, nodes, cy) { + var clusters = []; + for (var i = 0; i < n; i++) { + var cluster = []; + for (var j = 0; j < n; j++) { + // Row-wise attractors and elements that they attract belong in same cluster + if (Math.round(M[i * n + j] * 1000) / 1000 > 0) { + cluster.push(nodes[j]); + } + } + if (cluster.length !== 0) { + clusters.push(cy.collection(cluster)); + } + } + return clusters; +}; +var isDuplicate = function isDuplicate(c1, c2) { + for (var i = 0; i < c1.length; i++) { + if (!c2[i] || c1[i].id() !== c2[i].id()) { + return false; + } + } + return true; +}; +var removeDuplicates = function removeDuplicates(clusters) { + for (var i = 0; i < clusters.length; i++) { + for (var j = 0; j < clusters.length; j++) { + if (i != j && isDuplicate(clusters[i], clusters[j])) { + clusters.splice(j, 1); + } + } + } + return clusters; +}; +var markovClustering = function markovClustering(options) { + var nodes = this.nodes(); + var edges = this.edges(); + var cy = this.cy(); + + // Set parameters of algorithm: + var opts = setOptions$3(options); + + // Map each node to its position in node array + var id2position = {}; + for (var i = 0; i < nodes.length; i++) { + id2position[nodes[i].id()] = i; + } + + // Generate stochastic matrix M from input graph G (should be symmetric/undirected) + var n = nodes.length, + n2 = n * n; + var M = new Array(n2), + _M; + for (var _i = 0; _i < n2; _i++) { + M[_i] = 0; + } + for (var e = 0; e < edges.length; e++) { + var edge = edges[e]; + var _i2 = id2position[edge.source().id()]; + var j = id2position[edge.target().id()]; + var sim = getSimilarity$1(edge, opts.attributes); + M[_i2 * n + j] += sim; // G should be symmetric and undirected + M[j * n + _i2] += sim; + } + + // Begin Markov cluster algorithm + + // Step 1: Add self loops to each node, ie. add multFactor to matrix diagonal + addLoops(M, n, opts.multFactor); + + // Step 2: M = normalize( M ); + normalize(M, n); + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + isStillMoving = false; + + // Step 3: + _M = expand(M, n, opts.expandFactor); + + // Step 4: + M = inflate(_M, n, opts.inflateFactor); + + // Step 5: check to see if ~steady state has been reached + if (!hasConverged(M, _M, n2, 4)) { + isStillMoving = true; + } + iterations++; + } + + // Build clusters from matrix + var clusters = assign$2(M, n, nodes, cy); + + // Remove duplicate clusters due to symmetry of graph and M matrix + clusters = removeDuplicates(clusters); + return clusters; +}; +var markovClustering$1 = { + markovClustering: markovClustering, + mcl: markovClustering +}; + +// Common distance metrics for clustering algorithms +var identity = function identity(x) { + return x; +}; +var absDiff = function absDiff(p, q) { + return Math.abs(q - p); +}; +var addAbsDiff = function addAbsDiff(total, p, q) { + return total + absDiff(p, q); +}; +var addSquaredDiff = function addSquaredDiff(total, p, q) { + return total + Math.pow(q - p, 2); +}; +var sqrt = function sqrt(x) { + return Math.sqrt(x); +}; +var maxAbsDiff = function maxAbsDiff(currentMax, p, q) { + return Math.max(currentMax, absDiff(p, q)); +}; +var getDistance = function getDistance(length, getP, getQ, init, visit) { + var post = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : identity; + var ret = init; + var p, q; + for (var dim = 0; dim < length; dim++) { + p = getP(dim); + q = getQ(dim); + ret = visit(ret, p, q); + } + return post(ret); +}; +var distances = { + euclidean: function euclidean(length, getP, getQ) { + if (length >= 2) { + return getDistance(length, getP, getQ, 0, addSquaredDiff, sqrt); + } else { + // for single attr case, more efficient to avoid sqrt + return getDistance(length, getP, getQ, 0, addAbsDiff); + } + }, + squaredEuclidean: function squaredEuclidean(length, getP, getQ) { + return getDistance(length, getP, getQ, 0, addSquaredDiff); + }, + manhattan: function manhattan(length, getP, getQ) { + return getDistance(length, getP, getQ, 0, addAbsDiff); + }, + max: function max(length, getP, getQ) { + return getDistance(length, getP, getQ, -Infinity, maxAbsDiff); + } +}; + +// in case the user accidentally doesn't use camel case +distances['squared-euclidean'] = distances['squaredEuclidean']; +distances['squaredeuclidean'] = distances['squaredEuclidean']; +function clusteringDistance (method, length, getP, getQ, nodeP, nodeQ) { + var impl; + if (fn$6(method)) { + impl = method; + } else { + impl = distances[method] || distances.euclidean; + } + if (length === 0 && fn$6(method)) { + return impl(nodeP, nodeQ); + } else { + return impl(length, getP, getQ, nodeP, nodeQ); + } +} + +var defaults$b = defaults$g({ + k: 2, + m: 2, + sensitivityThreshold: 0.0001, + distance: 'euclidean', + maxIterations: 10, + attributes: [], + testMode: false, + testCentroids: null +}); +var setOptions$2 = function setOptions(options) { + return defaults$b(options); +}; + +var getDist = function getDist(type, node, centroid, attributes, mode) { + var noNodeP = mode !== 'kMedoids'; + var getP = noNodeP ? function (i) { + return centroid[i]; + } : function (i) { + return attributes[i](centroid); + }; + var getQ = function getQ(i) { + return attributes[i](node); + }; + var nodeP = centroid; + var nodeQ = node; + return clusteringDistance(type, attributes.length, getP, getQ, nodeP, nodeQ); +}; +var randomCentroids = function randomCentroids(nodes, k, attributes) { + var ndim = attributes.length; + var min = new Array(ndim); + var max = new Array(ndim); + var centroids = new Array(k); + var centroid = null; + + // Find min, max values for each attribute dimension + for (var i = 0; i < ndim; i++) { + min[i] = nodes.min(attributes[i]).value; + max[i] = nodes.max(attributes[i]).value; + } + + // Build k centroids, each represented as an n-dim feature vector + for (var c = 0; c < k; c++) { + centroid = []; + for (var _i = 0; _i < ndim; _i++) { + centroid[_i] = Math.random() * (max[_i] - min[_i]) + min[_i]; // random initial value + } + + centroids[c] = centroid; + } + return centroids; +}; +var classify = function classify(node, centroids, distance, attributes, type) { + var min = Infinity; + var index = 0; + for (var i = 0; i < centroids.length; i++) { + var dist = getDist(distance, node, centroids[i], attributes, type); + if (dist < min) { + min = dist; + index = i; + } + } + return index; +}; +var buildCluster = function buildCluster(centroid, nodes, assignment) { + var cluster = []; + var node = null; + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + if (assignment[node.id()] === centroid) { + //console.log("Node " + node.id() + " is associated with medoid #: " + m); + cluster.push(node); + } + } + return cluster; +}; +var haveValuesConverged = function haveValuesConverged(v1, v2, sensitivityThreshold) { + return Math.abs(v2 - v1) <= sensitivityThreshold; +}; +var haveMatricesConverged = function haveMatricesConverged(v1, v2, sensitivityThreshold) { + for (var i = 0; i < v1.length; i++) { + for (var j = 0; j < v1[i].length; j++) { + var diff = Math.abs(v1[i][j] - v2[i][j]); + if (diff > sensitivityThreshold) { + return false; + } + } + } + return true; +}; +var seenBefore = function seenBefore(node, medoids, n) { + for (var i = 0; i < n; i++) { + if (node === medoids[i]) return true; + } + return false; +}; +var randomMedoids = function randomMedoids(nodes, k) { + var medoids = new Array(k); + + // For small data sets, the probability of medoid conflict is greater, + // so we need to check to see if we've already seen or chose this node before. + if (nodes.length < 50) { + // Randomly select k medoids from the n nodes + for (var i = 0; i < k; i++) { + var node = nodes[Math.floor(Math.random() * nodes.length)]; + + // If we've already chosen this node to be a medoid, don't choose it again (for small data sets). + // Instead choose a different random node. + while (seenBefore(node, medoids, i)) { + node = nodes[Math.floor(Math.random() * nodes.length)]; + } + medoids[i] = node; + } + } else { + // Relatively large data set, so pretty safe to not check and just select random nodes + for (var _i2 = 0; _i2 < k; _i2++) { + medoids[_i2] = nodes[Math.floor(Math.random() * nodes.length)]; + } + } + return medoids; +}; +var findCost = function findCost(potentialNewMedoid, cluster, attributes) { + var cost = 0; + for (var n = 0; n < cluster.length; n++) { + cost += getDist('manhattan', cluster[n], potentialNewMedoid, attributes, 'kMedoids'); + } + return cost; +}; +var kMeans = function kMeans(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var node = null; + + // Set parameters of algorithm: # of clusters, distance metric, etc. + var opts = setOptions$2(options); + + // Begin k-means algorithm + var clusters = new Array(opts.k); + var assignment = {}; + var centroids; + + // Step 1: Initialize centroid positions + if (opts.testMode) { + if (typeof opts.testCentroids === 'number') { + // TODO: implement a seeded random number generator. + opts.testCentroids; + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } else if (_typeof(opts.testCentroids) === 'object') { + centroids = opts.testCentroids; + } else { + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } + } else { + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + // Step 2: Assign nodes to the nearest centroid + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + // Determine which cluster this node belongs to: node id => cluster # + assignment[node.id()] = classify(node, centroids, opts.distance, opts.attributes, 'kMeans'); + } + + // Step 3: For each of the k clusters, update its centroid + isStillMoving = false; + for (var c = 0; c < opts.k; c++) { + // Get all nodes that belong to this cluster + var cluster = buildCluster(c, nodes, assignment); + if (cluster.length === 0) { + // If cluster is empty, break out early & move to next cluster + continue; + } + + // Update centroids by calculating avg of all nodes within the cluster. + var ndim = opts.attributes.length; + var centroid = centroids[c]; // [ dim_1, dim_2, dim_3, ... , dim_n ] + var newCentroid = new Array(ndim); + var sum = new Array(ndim); + for (var d = 0; d < ndim; d++) { + sum[d] = 0.0; + for (var i = 0; i < cluster.length; i++) { + node = cluster[i]; + sum[d] += opts.attributes[d](node); + } + newCentroid[d] = sum[d] / cluster.length; + + // Check to see if algorithm has converged, i.e. when centroids no longer change + if (!haveValuesConverged(newCentroid[d], centroid[d], opts.sensitivityThreshold)) { + isStillMoving = true; + } + } + centroids[c] = newCentroid; + clusters[c] = cy.collection(cluster); + } + iterations++; + } + return clusters; +}; +var kMedoids = function kMedoids(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var node = null; + var opts = setOptions$2(options); + + // Begin k-medoids algorithm + var clusters = new Array(opts.k); + var medoids; + var assignment = {}; + var curCost; + var minCosts = new Array(opts.k); // minimum cost configuration for each cluster + + // Step 1: Initialize k medoids + if (opts.testMode) { + if (typeof opts.testCentroids === 'number') ; else if (_typeof(opts.testCentroids) === 'object') { + medoids = opts.testCentroids; + } else { + medoids = randomMedoids(nodes, opts.k); + } + } else { + medoids = randomMedoids(nodes, opts.k); + } + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + // Step 2: Assign nodes to the nearest medoid + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + // Determine which cluster this node belongs to: node id => cluster # + assignment[node.id()] = classify(node, medoids, opts.distance, opts.attributes, 'kMedoids'); + } + isStillMoving = false; + // Step 3: For each medoid m, and for each node associated with mediod m, + // select the node with the lowest configuration cost as new medoid. + for (var m = 0; m < medoids.length; m++) { + // Get all nodes that belong to this medoid + var cluster = buildCluster(m, nodes, assignment); + if (cluster.length === 0) { + // If cluster is empty, break out early & move to next cluster + continue; + } + minCosts[m] = findCost(medoids[m], cluster, opts.attributes); // original cost + + // Select different medoid if its configuration has the lowest cost + for (var _n = 0; _n < cluster.length; _n++) { + curCost = findCost(cluster[_n], cluster, opts.attributes); + if (curCost < minCosts[m]) { + minCosts[m] = curCost; + medoids[m] = cluster[_n]; + isStillMoving = true; + } + } + clusters[m] = cy.collection(cluster); + } + iterations++; + } + return clusters; +}; +var updateCentroids = function updateCentroids(centroids, nodes, U, weight, opts) { + var numerator, denominator; + for (var n = 0; n < nodes.length; n++) { + for (var c = 0; c < centroids.length; c++) { + weight[n][c] = Math.pow(U[n][c], opts.m); + } + } + for (var _c = 0; _c < centroids.length; _c++) { + for (var dim = 0; dim < opts.attributes.length; dim++) { + numerator = 0; + denominator = 0; + for (var _n2 = 0; _n2 < nodes.length; _n2++) { + numerator += weight[_n2][_c] * opts.attributes[dim](nodes[_n2]); + denominator += weight[_n2][_c]; + } + centroids[_c][dim] = numerator / denominator; + } + } +}; +var updateMembership = function updateMembership(U, _U, centroids, nodes, opts) { + // Save previous step + for (var i = 0; i < U.length; i++) { + _U[i] = U[i].slice(); + } + var sum, numerator, denominator; + var pow = 2 / (opts.m - 1); + for (var c = 0; c < centroids.length; c++) { + for (var n = 0; n < nodes.length; n++) { + sum = 0; + for (var k = 0; k < centroids.length; k++) { + // against all other centroids + numerator = getDist(opts.distance, nodes[n], centroids[c], opts.attributes, 'cmeans'); + denominator = getDist(opts.distance, nodes[n], centroids[k], opts.attributes, 'cmeans'); + sum += Math.pow(numerator / denominator, pow); + } + U[n][c] = 1 / sum; + } + } +}; +var assign$1 = function assign(nodes, U, opts, cy) { + var clusters = new Array(opts.k); + for (var c = 0; c < clusters.length; c++) { + clusters[c] = []; + } + var max; + var index; + for (var n = 0; n < U.length; n++) { + // for each node (U is N x C matrix) + max = -Infinity; + index = -1; + // Determine which cluster the node is most likely to belong in + for (var _c2 = 0; _c2 < U[0].length; _c2++) { + if (U[n][_c2] > max) { + max = U[n][_c2]; + index = _c2; + } + } + clusters[index].push(nodes[n]); + } + + // Turn every array into a collection of nodes + for (var _c3 = 0; _c3 < clusters.length; _c3++) { + clusters[_c3] = cy.collection(clusters[_c3]); + } + return clusters; +}; +var fuzzyCMeans = function fuzzyCMeans(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var opts = setOptions$2(options); + + // Begin fuzzy c-means algorithm + var clusters; + var centroids; + var U; + var _U; + var weight; + + // Step 1: Initialize letiables. + _U = new Array(nodes.length); + for (var i = 0; i < nodes.length; i++) { + // N x C matrix + _U[i] = new Array(opts.k); + } + U = new Array(nodes.length); + for (var _i3 = 0; _i3 < nodes.length; _i3++) { + // N x C matrix + U[_i3] = new Array(opts.k); + } + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + var total = 0; + for (var j = 0; j < opts.k; j++) { + U[_i4][j] = Math.random(); + total += U[_i4][j]; + } + for (var _j = 0; _j < opts.k; _j++) { + U[_i4][_j] = U[_i4][_j] / total; + } + } + centroids = new Array(opts.k); + for (var _i5 = 0; _i5 < opts.k; _i5++) { + centroids[_i5] = new Array(opts.attributes.length); + } + weight = new Array(nodes.length); + for (var _i6 = 0; _i6 < nodes.length; _i6++) { + // N x C matrix + weight[_i6] = new Array(opts.k); + } + // end init FCM + + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + isStillMoving = false; + + // Step 2: Calculate the centroids for each step. + updateCentroids(centroids, nodes, U, weight, opts); + + // Step 3: Update the partition matrix U. + updateMembership(U, _U, centroids, nodes, opts); + + // Step 4: Check for convergence. + if (!haveMatricesConverged(U, _U, opts.sensitivityThreshold)) { + isStillMoving = true; + } + iterations++; + } + + // Assign nodes to clusters with highest probability. + clusters = assign$1(nodes, U, opts, cy); + return { + clusters: clusters, + degreeOfMembership: U + }; +}; +var kClustering = { + kMeans: kMeans, + kMedoids: kMedoids, + fuzzyCMeans: fuzzyCMeans, + fcm: fuzzyCMeans +}; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 +var defaults$a = defaults$g({ + distance: 'euclidean', + // distance metric to compare nodes + linkage: 'min', + // linkage criterion : how to determine the distance between clusters of nodes + mode: 'threshold', + // mode:'threshold' => clusters must be threshold distance apart + threshold: Infinity, + // the distance threshold + // mode:'dendrogram' => the nodes are organised as leaves in a tree (siblings are close), merging makes clusters + addDendrogram: false, + // whether to add the dendrogram to the graph for viz + dendrogramDepth: 0, + // depth at which dendrogram branches are merged into the returned clusters + attributes: [] // array of attr functions +}); + +var linkageAliases = { + 'single': 'min', + 'complete': 'max' +}; +var setOptions$1 = function setOptions(options) { + var opts = defaults$a(options); + var preferredAlias = linkageAliases[opts.linkage]; + if (preferredAlias != null) { + opts.linkage = preferredAlias; + } + return opts; +}; +var mergeClosest = function mergeClosest(clusters, index, dists, mins, opts) { + // Find two closest clusters from cached mins + var minKey = 0; + var min = Infinity; + var dist; + var attrs = opts.attributes; + var getDist = function getDist(n1, n2) { + return clusteringDistance(opts.distance, attrs.length, function (i) { + return attrs[i](n1); + }, function (i) { + return attrs[i](n2); + }, n1, n2); + }; + for (var i = 0; i < clusters.length; i++) { + var key = clusters[i].key; + var _dist = dists[key][mins[key]]; + if (_dist < min) { + minKey = key; + min = _dist; + } + } + if (opts.mode === 'threshold' && min >= opts.threshold || opts.mode === 'dendrogram' && clusters.length === 1) { + return false; + } + var c1 = index[minKey]; + var c2 = index[mins[minKey]]; + var merged; + + // Merge two closest clusters + if (opts.mode === 'dendrogram') { + merged = { + left: c1, + right: c2, + key: c1.key + }; + } else { + merged = { + value: c1.value.concat(c2.value), + key: c1.key + }; + } + clusters[c1.index] = merged; + clusters.splice(c2.index, 1); + index[c1.key] = merged; + + // Update distances with new merged cluster + for (var _i = 0; _i < clusters.length; _i++) { + var cur = clusters[_i]; + if (c1.key === cur.key) { + dist = Infinity; + } else if (opts.linkage === 'min') { + dist = dists[c1.key][cur.key]; + if (dists[c1.key][cur.key] > dists[c2.key][cur.key]) { + dist = dists[c2.key][cur.key]; + } + } else if (opts.linkage === 'max') { + dist = dists[c1.key][cur.key]; + if (dists[c1.key][cur.key] < dists[c2.key][cur.key]) { + dist = dists[c2.key][cur.key]; + } + } else if (opts.linkage === 'mean') { + dist = (dists[c1.key][cur.key] * c1.size + dists[c2.key][cur.key] * c2.size) / (c1.size + c2.size); + } else { + if (opts.mode === 'dendrogram') dist = getDist(cur.value, c1.value);else dist = getDist(cur.value[0], c1.value[0]); + } + dists[c1.key][cur.key] = dists[cur.key][c1.key] = dist; // distance matrix is symmetric + } + + // Update cached mins + for (var _i2 = 0; _i2 < clusters.length; _i2++) { + var key1 = clusters[_i2].key; + if (mins[key1] === c1.key || mins[key1] === c2.key) { + var _min = key1; + for (var j = 0; j < clusters.length; j++) { + var key2 = clusters[j].key; + if (dists[key1][key2] < dists[key1][_min]) { + _min = key2; + } + } + mins[key1] = _min; + } + clusters[_i2].index = _i2; + } + + // Clean up meta data used for clustering + c1.key = c2.key = c1.index = c2.index = null; + return true; +}; +var getAllChildren = function getAllChildren(root, arr, cy) { + if (!root) return; + if (root.value) { + arr.push(root.value); + } else { + if (root.left) getAllChildren(root.left, arr); + if (root.right) getAllChildren(root.right, arr); + } +}; +var buildDendrogram = function buildDendrogram(root, cy) { + if (!root) return ''; + if (root.left && root.right) { + var leftStr = buildDendrogram(root.left, cy); + var rightStr = buildDendrogram(root.right, cy); + var node = cy.add({ + group: 'nodes', + data: { + id: leftStr + ',' + rightStr + } + }); + cy.add({ + group: 'edges', + data: { + source: leftStr, + target: node.id() + } + }); + cy.add({ + group: 'edges', + data: { + source: rightStr, + target: node.id() + } + }); + return node.id(); + } else if (root.value) { + return root.value.id(); + } +}; +var buildClustersFromTree = function buildClustersFromTree(root, k, cy) { + if (!root) return []; + var left = [], + right = [], + leaves = []; + if (k === 0) { + // don't cut tree, simply return all nodes as 1 single cluster + if (root.left) getAllChildren(root.left, left); + if (root.right) getAllChildren(root.right, right); + leaves = left.concat(right); + return [cy.collection(leaves)]; + } else if (k === 1) { + // cut at root + + if (root.value) { + // leaf node + return [cy.collection(root.value)]; + } else { + if (root.left) getAllChildren(root.left, left); + if (root.right) getAllChildren(root.right, right); + return [cy.collection(left), cy.collection(right)]; + } + } else { + if (root.value) { + return [cy.collection(root.value)]; + } else { + if (root.left) left = buildClustersFromTree(root.left, k - 1, cy); + if (root.right) right = buildClustersFromTree(root.right, k - 1, cy); + return left.concat(right); + } + } +}; + +var hierarchicalClustering = function hierarchicalClustering(options) { + var cy = this.cy(); + var nodes = this.nodes(); + + // Set parameters of algorithm: linkage type, distance metric, etc. + var opts = setOptions$1(options); + var attrs = opts.attributes; + var getDist = function getDist(n1, n2) { + return clusteringDistance(opts.distance, attrs.length, function (i) { + return attrs[i](n1); + }, function (i) { + return attrs[i](n2); + }, n1, n2); + }; + + // Begin hierarchical algorithm + var clusters = []; + var dists = []; // distances between each pair of clusters + var mins = []; // closest cluster for each cluster + var index = []; // hash of all clusters by key + + // In agglomerative (bottom-up) clustering, each node starts as its own cluster + for (var n = 0; n < nodes.length; n++) { + var cluster = { + value: opts.mode === 'dendrogram' ? nodes[n] : [nodes[n]], + key: n, + index: n + }; + clusters[n] = cluster; + index[n] = cluster; + dists[n] = []; + mins[n] = 0; + } + + // Calculate the distance between each pair of clusters + for (var i = 0; i < clusters.length; i++) { + for (var j = 0; j <= i; j++) { + var dist = void 0; + if (opts.mode === 'dendrogram') { + // modes store cluster values differently + dist = i === j ? Infinity : getDist(clusters[i].value, clusters[j].value); + } else { + dist = i === j ? Infinity : getDist(clusters[i].value[0], clusters[j].value[0]); + } + dists[i][j] = dist; + dists[j][i] = dist; + if (dist < dists[i][mins[i]]) { + mins[i] = j; // Cache mins: closest cluster to cluster i is cluster j + } + } + } + + // Find the closest pair of clusters and merge them into a single cluster. + // Update distances between new cluster and each of the old clusters, and loop until threshold reached. + var merged = mergeClosest(clusters, index, dists, mins, opts); + while (merged) { + merged = mergeClosest(clusters, index, dists, mins, opts); + } + var retClusters; + + // Dendrogram mode builds the hierarchy and adds intermediary nodes + edges + // in addition to returning the clusters. + if (opts.mode === 'dendrogram') { + retClusters = buildClustersFromTree(clusters[0], opts.dendrogramDepth, cy); + if (opts.addDendrogram) buildDendrogram(clusters[0], cy); + } else { + // Regular mode simply returns the clusters + + retClusters = new Array(clusters.length); + clusters.forEach(function (cluster, i) { + // Clean up meta data used for clustering + cluster.key = cluster.index = null; + retClusters[i] = cy.collection(cluster.value); + }); + } + return retClusters; +}; +var hierarchicalClustering$1 = { + hierarchicalClustering: hierarchicalClustering, + hca: hierarchicalClustering +}; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 +var defaults$9 = defaults$g({ + distance: 'euclidean', + // distance metric to compare attributes between two nodes + preference: 'median', + // suitability of a data point to serve as an exemplar + damping: 0.8, + // damping factor between [0.5, 1) + maxIterations: 1000, + // max number of iterations to run + minIterations: 100, + // min number of iterations to run in order for clustering to stop + attributes: [// functions to quantify the similarity between any two points + // e.g. node => node.data('weight') + ] +}); +var setOptions = function setOptions(options) { + var dmp = options.damping; + var pref = options.preference; + if (!(0.5 <= dmp && dmp < 1)) { + error("Damping must range on [0.5, 1). Got: ".concat(dmp)); + } + var validPrefs = ['median', 'mean', 'min', 'max']; + if (!(validPrefs.some(function (v) { + return v === pref; + }) || number$1(pref))) { + error("Preference must be one of [".concat(validPrefs.map(function (p) { + return "'".concat(p, "'"); + }).join(', '), "] or a number. Got: ").concat(pref)); + } + return defaults$9(options); +}; + +var getSimilarity = function getSimilarity(type, n1, n2, attributes) { + var attr = function attr(n, i) { + return attributes[i](n); + }; + + // nb negative because similarity should have an inverse relationship to distance + return -clusteringDistance(type, attributes.length, function (i) { + return attr(n1, i); + }, function (i) { + return attr(n2, i); + }, n1, n2); +}; +var getPreference = function getPreference(S, preference) { + // larger preference = greater # of clusters + var p = null; + if (preference === 'median') { + p = median(S); + } else if (preference === 'mean') { + p = mean(S); + } else if (preference === 'min') { + p = min(S); + } else if (preference === 'max') { + p = max(S); + } else { + // Custom preference number, as set by user + p = preference; + } + return p; +}; +var findExemplars = function findExemplars(n, R, A) { + var indices = []; + for (var i = 0; i < n; i++) { + if (R[i * n + i] + A[i * n + i] > 0) { + indices.push(i); + } + } + return indices; +}; +var assignClusters = function assignClusters(n, S, exemplars) { + var clusters = []; + for (var i = 0; i < n; i++) { + var index = -1; + var max = -Infinity; + for (var ei = 0; ei < exemplars.length; ei++) { + var e = exemplars[ei]; + if (S[i * n + e] > max) { + index = e; + max = S[i * n + e]; + } + } + if (index > 0) { + clusters.push(index); + } + } + for (var _ei = 0; _ei < exemplars.length; _ei++) { + clusters[exemplars[_ei]] = exemplars[_ei]; + } + return clusters; +}; +var assign = function assign(n, S, exemplars) { + var clusters = assignClusters(n, S, exemplars); + for (var ei = 0; ei < exemplars.length; ei++) { + var ii = []; + for (var c = 0; c < clusters.length; c++) { + if (clusters[c] === exemplars[ei]) { + ii.push(c); + } + } + var maxI = -1; + var maxSum = -Infinity; + for (var i = 0; i < ii.length; i++) { + var sum = 0; + for (var j = 0; j < ii.length; j++) { + sum += S[ii[j] * n + ii[i]]; + } + if (sum > maxSum) { + maxI = i; + maxSum = sum; + } + } + exemplars[ei] = ii[maxI]; + } + clusters = assignClusters(n, S, exemplars); + return clusters; +}; +var affinityPropagation = function affinityPropagation(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var opts = setOptions(options); + + // Map each node to its position in node array + var id2position = {}; + for (var i = 0; i < nodes.length; i++) { + id2position[nodes[i].id()] = i; + } + + // Begin affinity propagation algorithm + + var n; // number of data points + var n2; // size of matrices + var S; // similarity matrix (1D array) + var p; // preference/suitability of a data point to serve as an exemplar + var R; // responsibility matrix (1D array) + var A; // availability matrix (1D array) + + n = nodes.length; + n2 = n * n; + + // Initialize and build S similarity matrix + S = new Array(n2); + for (var _i = 0; _i < n2; _i++) { + S[_i] = -Infinity; // for cases where two data points shouldn't be linked together + } + + for (var _i2 = 0; _i2 < n; _i2++) { + for (var j = 0; j < n; j++) { + if (_i2 !== j) { + S[_i2 * n + j] = getSimilarity(opts.distance, nodes[_i2], nodes[j], opts.attributes); + } + } + } + + // Place preferences on the diagonal of S + p = getPreference(S, opts.preference); + for (var _i3 = 0; _i3 < n; _i3++) { + S[_i3 * n + _i3] = p; + } + + // Initialize R responsibility matrix + R = new Array(n2); + for (var _i4 = 0; _i4 < n2; _i4++) { + R[_i4] = 0.0; + } + + // Initialize A availability matrix + A = new Array(n2); + for (var _i5 = 0; _i5 < n2; _i5++) { + A[_i5] = 0.0; + } + var old = new Array(n); + var Rp = new Array(n); + var se = new Array(n); + for (var _i6 = 0; _i6 < n; _i6++) { + old[_i6] = 0.0; + Rp[_i6] = 0.0; + se[_i6] = 0; + } + var e = new Array(n * opts.minIterations); + for (var _i7 = 0; _i7 < e.length; _i7++) { + e[_i7] = 0; + } + var iter; + for (iter = 0; iter < opts.maxIterations; iter++) { + // main algorithmic loop + + // Update R responsibility matrix + for (var _i8 = 0; _i8 < n; _i8++) { + var max = -Infinity, + max2 = -Infinity, + maxI = -1, + AS = 0.0; + for (var _j = 0; _j < n; _j++) { + old[_j] = R[_i8 * n + _j]; + AS = A[_i8 * n + _j] + S[_i8 * n + _j]; + if (AS >= max) { + max2 = max; + max = AS; + maxI = _j; + } else if (AS > max2) { + max2 = AS; + } + } + for (var _j2 = 0; _j2 < n; _j2++) { + R[_i8 * n + _j2] = (1 - opts.damping) * (S[_i8 * n + _j2] - max) + opts.damping * old[_j2]; + } + R[_i8 * n + maxI] = (1 - opts.damping) * (S[_i8 * n + maxI] - max2) + opts.damping * old[maxI]; + } + + // Update A availability matrix + for (var _i9 = 0; _i9 < n; _i9++) { + var sum = 0; + for (var _j3 = 0; _j3 < n; _j3++) { + old[_j3] = A[_j3 * n + _i9]; + Rp[_j3] = Math.max(0, R[_j3 * n + _i9]); + sum += Rp[_j3]; + } + sum -= Rp[_i9]; + Rp[_i9] = R[_i9 * n + _i9]; + sum += Rp[_i9]; + for (var _j4 = 0; _j4 < n; _j4++) { + A[_j4 * n + _i9] = (1 - opts.damping) * Math.min(0, sum - Rp[_j4]) + opts.damping * old[_j4]; + } + A[_i9 * n + _i9] = (1 - opts.damping) * (sum - Rp[_i9]) + opts.damping * old[_i9]; + } + + // Check for convergence + var K = 0; + for (var _i10 = 0; _i10 < n; _i10++) { + var E = A[_i10 * n + _i10] + R[_i10 * n + _i10] > 0 ? 1 : 0; + e[iter % opts.minIterations * n + _i10] = E; + K += E; + } + if (K > 0 && (iter >= opts.minIterations - 1 || iter == opts.maxIterations - 1)) { + var _sum = 0; + for (var _i11 = 0; _i11 < n; _i11++) { + se[_i11] = 0; + for (var _j5 = 0; _j5 < opts.minIterations; _j5++) { + se[_i11] += e[_j5 * n + _i11]; + } + if (se[_i11] === 0 || se[_i11] === opts.minIterations) { + _sum++; + } + } + if (_sum === n) { + // then we have convergence + break; + } + } + } + + // Identify exemplars (cluster centers) + var exemplarsIndices = findExemplars(n, R, A); + + // Assign nodes to clusters + var clusterIndices = assign(n, S, exemplarsIndices); + var clusters = {}; + for (var c = 0; c < exemplarsIndices.length; c++) { + clusters[exemplarsIndices[c]] = []; + } + for (var _i12 = 0; _i12 < nodes.length; _i12++) { + var pos = id2position[nodes[_i12].id()]; + var clusterIndex = clusterIndices[pos]; + if (clusterIndex != null) { + // the node may have not been assigned a cluster if no valid attributes were specified + clusters[clusterIndex].push(nodes[_i12]); + } + } + var retClusters = new Array(exemplarsIndices.length); + for (var _c = 0; _c < exemplarsIndices.length; _c++) { + retClusters[_c] = cy.collection(clusters[exemplarsIndices[_c]]); + } + return retClusters; +}; +var affinityPropagation$1 = { + affinityPropagation: affinityPropagation, + ap: affinityPropagation +}; + +var hierholzerDefaults = defaults$g({ + root: undefined, + directed: false +}); +var elesfn$k = { + hierholzer: function hierholzer(options) { + if (!plainObject(options)) { + var args = arguments; + options = { + root: args[0], + directed: args[1] + }; + } + var _hierholzerDefaults = hierholzerDefaults(options), + root = _hierholzerDefaults.root, + directed = _hierholzerDefaults.directed; + var eles = this; + var dflag = false; + var oddIn; + var oddOut; + var startVertex; + if (root) startVertex = string(root) ? this.filter(root)[0].id() : root[0].id(); + var nodes = {}; + var edges = {}; + if (directed) { + eles.forEach(function (ele) { + var id = ele.id(); + if (ele.isNode()) { + var ind = ele.indegree(true); + var outd = ele.outdegree(true); + var d1 = ind - outd; + var d2 = outd - ind; + if (d1 == 1) { + if (oddIn) dflag = true;else oddIn = id; + } else if (d2 == 1) { + if (oddOut) dflag = true;else oddOut = id; + } else if (d2 > 1 || d1 > 1) { + dflag = true; + } + nodes[id] = []; + ele.outgoers().forEach(function (e) { + if (e.isEdge()) nodes[id].push(e.id()); + }); + } else { + edges[id] = [undefined, ele.target().id()]; + } + }); + } else { + eles.forEach(function (ele) { + var id = ele.id(); + if (ele.isNode()) { + var d = ele.degree(true); + if (d % 2) { + if (!oddIn) oddIn = id;else if (!oddOut) oddOut = id;else dflag = true; + } + nodes[id] = []; + ele.connectedEdges().forEach(function (e) { + return nodes[id].push(e.id()); + }); + } else { + edges[id] = [ele.source().id(), ele.target().id()]; + } + }); + } + var result = { + found: false, + trail: undefined + }; + if (dflag) return result;else if (oddOut && oddIn) { + if (directed) { + if (startVertex && oddOut != startVertex) { + return result; + } + startVertex = oddOut; + } else { + if (startVertex && oddOut != startVertex && oddIn != startVertex) { + return result; + } else if (!startVertex) { + startVertex = oddOut; + } + } + } else { + if (!startVertex) startVertex = eles[0].id(); + } + var walk = function walk(v) { + var currentNode = v; + var subtour = [v]; + var adj, adjTail, adjHead; + while (nodes[currentNode].length) { + adj = nodes[currentNode].shift(); + adjTail = edges[adj][0]; + adjHead = edges[adj][1]; + if (currentNode != adjHead) { + nodes[adjHead] = nodes[adjHead].filter(function (e) { + return e != adj; + }); + currentNode = adjHead; + } else if (!directed && currentNode != adjTail) { + nodes[adjTail] = nodes[adjTail].filter(function (e) { + return e != adj; + }); + currentNode = adjTail; + } + subtour.unshift(adj); + subtour.unshift(currentNode); + } + return subtour; + }; + var trail = []; + var subtour = []; + subtour = walk(startVertex); + while (subtour.length != 1) { + if (nodes[subtour[0]].length == 0) { + trail.unshift(eles.getElementById(subtour.shift())); + trail.unshift(eles.getElementById(subtour.shift())); + } else { + subtour = walk(subtour.shift()).concat(subtour); + } + } + trail.unshift(eles.getElementById(subtour.shift())); // final node + + for (var d in nodes) { + if (nodes[d].length) { + return result; + } + } + result.found = true; + result.trail = this.spawn(trail, true); + return result; + } +}; + +var hopcroftTarjanBiconnected = function hopcroftTarjanBiconnected() { + var eles = this; + var nodes = {}; + var id = 0; + var edgeCount = 0; + var components = []; + var stack = []; + var visitedEdges = {}; + var buildComponent = function buildComponent(x, y) { + var i = stack.length - 1; + var cutset = []; + var component = eles.spawn(); + while (stack[i].x != x || stack[i].y != y) { + cutset.push(stack.pop().edge); + i--; + } + cutset.push(stack.pop().edge); + cutset.forEach(function (edge) { + var connectedNodes = edge.connectedNodes().intersection(eles); + component.merge(edge); + connectedNodes.forEach(function (node) { + var nodeId = node.id(); + var connectedEdges = node.connectedEdges().intersection(eles); + component.merge(node); + if (!nodes[nodeId].cutVertex) { + component.merge(connectedEdges); + } else { + component.merge(connectedEdges.filter(function (edge) { + return edge.isLoop(); + })); + } + }); + }); + components.push(component); + }; + var biconnectedSearch = function biconnectedSearch(root, currentNode, parent) { + if (root === parent) edgeCount += 1; + nodes[currentNode] = { + id: id, + low: id++, + cutVertex: false + }; + var edges = eles.getElementById(currentNode).connectedEdges().intersection(eles); + if (edges.size() === 0) { + components.push(eles.spawn(eles.getElementById(currentNode))); + } else { + var sourceId, targetId, otherNodeId, edgeId; + edges.forEach(function (edge) { + sourceId = edge.source().id(); + targetId = edge.target().id(); + otherNodeId = sourceId === currentNode ? targetId : sourceId; + if (otherNodeId !== parent) { + edgeId = edge.id(); + if (!visitedEdges[edgeId]) { + visitedEdges[edgeId] = true; + stack.push({ + x: currentNode, + y: otherNodeId, + edge: edge + }); + } + if (!(otherNodeId in nodes)) { + biconnectedSearch(root, otherNodeId, currentNode); + nodes[currentNode].low = Math.min(nodes[currentNode].low, nodes[otherNodeId].low); + if (nodes[currentNode].id <= nodes[otherNodeId].low) { + nodes[currentNode].cutVertex = true; + buildComponent(currentNode, otherNodeId); + } + } else { + nodes[currentNode].low = Math.min(nodes[currentNode].low, nodes[otherNodeId].id); + } + } + }); + } + }; + eles.forEach(function (ele) { + if (ele.isNode()) { + var nodeId = ele.id(); + if (!(nodeId in nodes)) { + edgeCount = 0; + biconnectedSearch(nodeId, nodeId); + nodes[nodeId].cutVertex = edgeCount > 1; + } + } + }); + var cutVertices = Object.keys(nodes).filter(function (id) { + return nodes[id].cutVertex; + }).map(function (id) { + return eles.getElementById(id); + }); + return { + cut: eles.spawn(cutVertices), + components: components + }; +}; +var hopcroftTarjanBiconnected$1 = { + hopcroftTarjanBiconnected: hopcroftTarjanBiconnected, + htbc: hopcroftTarjanBiconnected, + htb: hopcroftTarjanBiconnected, + hopcroftTarjanBiconnectedComponents: hopcroftTarjanBiconnected +}; + +var tarjanStronglyConnected = function tarjanStronglyConnected() { + var eles = this; + var nodes = {}; + var index = 0; + var components = []; + var stack = []; + var cut = eles.spawn(eles); + var stronglyConnectedSearch = function stronglyConnectedSearch(sourceNodeId) { + stack.push(sourceNodeId); + nodes[sourceNodeId] = { + index: index, + low: index++, + explored: false + }; + var connectedEdges = eles.getElementById(sourceNodeId).connectedEdges().intersection(eles); + connectedEdges.forEach(function (edge) { + var targetNodeId = edge.target().id(); + if (targetNodeId !== sourceNodeId) { + if (!(targetNodeId in nodes)) { + stronglyConnectedSearch(targetNodeId); + } + if (!nodes[targetNodeId].explored) { + nodes[sourceNodeId].low = Math.min(nodes[sourceNodeId].low, nodes[targetNodeId].low); + } + } + }); + if (nodes[sourceNodeId].index === nodes[sourceNodeId].low) { + var componentNodes = eles.spawn(); + for (;;) { + var nodeId = stack.pop(); + componentNodes.merge(eles.getElementById(nodeId)); + nodes[nodeId].low = nodes[sourceNodeId].index; + nodes[nodeId].explored = true; + if (nodeId === sourceNodeId) { + break; + } + } + var componentEdges = componentNodes.edgesWith(componentNodes); + var component = componentNodes.merge(componentEdges); + components.push(component); + cut = cut.difference(component); + } + }; + eles.forEach(function (ele) { + if (ele.isNode()) { + var nodeId = ele.id(); + if (!(nodeId in nodes)) { + stronglyConnectedSearch(nodeId); + } + } + }); + return { + cut: cut, + components: components + }; +}; +var tarjanStronglyConnected$1 = { + tarjanStronglyConnected: tarjanStronglyConnected, + tsc: tarjanStronglyConnected, + tscc: tarjanStronglyConnected, + tarjanStronglyConnectedComponents: tarjanStronglyConnected +}; + +var elesfn$j = {}; +[elesfn$v, elesfn$u, elesfn$t, elesfn$s, elesfn$r, elesfn$q, elesfn$p, elesfn$o, elesfn$n, elesfn$m, elesfn$l, markovClustering$1, kClustering, hierarchicalClustering$1, affinityPropagation$1, elesfn$k, hopcroftTarjanBiconnected$1, tarjanStronglyConnected$1].forEach(function (props) { + extend(elesfn$j, props); +}); + +/*! +Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable +Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) +Licensed under The MIT License (http://opensource.org/licenses/MIT) +*/ + +/* promise states [Promises/A+ 2.1] */ +var STATE_PENDING = 0; /* [Promises/A+ 2.1.1] */ +var STATE_FULFILLED = 1; /* [Promises/A+ 2.1.2] */ +var STATE_REJECTED = 2; /* [Promises/A+ 2.1.3] */ + +/* promise object constructor */ +var api = function api(executor) { + /* optionally support non-constructor/plain-function call */ + if (!(this instanceof api)) return new api(executor); + + /* initialize object */ + this.id = 'Thenable/1.0.7'; + this.state = STATE_PENDING; /* initial state */ + this.fulfillValue = undefined; /* initial value */ /* [Promises/A+ 1.3, 2.1.2.2] */ + this.rejectReason = undefined; /* initial reason */ /* [Promises/A+ 1.5, 2.1.3.2] */ + this.onFulfilled = []; /* initial handlers */ + this.onRejected = []; /* initial handlers */ + + /* provide optional information-hiding proxy */ + this.proxy = { + then: this.then.bind(this) + }; + + /* support optional executor function */ + if (typeof executor === 'function') executor.call(this, this.fulfill.bind(this), this.reject.bind(this)); +}; + +/* promise API methods */ +api.prototype = { + /* promise resolving methods */ + fulfill: function fulfill(value) { + return deliver(this, STATE_FULFILLED, 'fulfillValue', value); + }, + reject: function reject(value) { + return deliver(this, STATE_REJECTED, 'rejectReason', value); + }, + /* "The then Method" [Promises/A+ 1.1, 1.2, 2.2] */ + then: function then(onFulfilled, onRejected) { + var curr = this; + var next = new api(); /* [Promises/A+ 2.2.7] */ + curr.onFulfilled.push(resolver(onFulfilled, next, 'fulfill')); /* [Promises/A+ 2.2.2/2.2.6] */ + curr.onRejected.push(resolver(onRejected, next, 'reject')); /* [Promises/A+ 2.2.3/2.2.6] */ + execute(curr); + return next.proxy; /* [Promises/A+ 2.2.7, 3.3] */ + } +}; + +/* deliver an action */ +var deliver = function deliver(curr, state, name, value) { + if (curr.state === STATE_PENDING) { + curr.state = state; /* [Promises/A+ 2.1.2.1, 2.1.3.1] */ + curr[name] = value; /* [Promises/A+ 2.1.2.2, 2.1.3.2] */ + execute(curr); + } + return curr; +}; + +/* execute all handlers */ +var execute = function execute(curr) { + if (curr.state === STATE_FULFILLED) execute_handlers(curr, 'onFulfilled', curr.fulfillValue);else if (curr.state === STATE_REJECTED) execute_handlers(curr, 'onRejected', curr.rejectReason); +}; + +/* execute particular set of handlers */ +var execute_handlers = function execute_handlers(curr, name, value) { + /* global setImmediate: true */ + /* global setTimeout: true */ + + /* short-circuit processing */ + if (curr[name].length === 0) return; + + /* iterate over all handlers, exactly once */ + var handlers = curr[name]; + curr[name] = []; /* [Promises/A+ 2.2.2.3, 2.2.3.3] */ + var func = function func() { + for (var i = 0; i < handlers.length; i++) { + handlers[i](value); + } /* [Promises/A+ 2.2.5] */ + }; + + /* execute procedure asynchronously */ /* [Promises/A+ 2.2.4, 3.1] */ + if (typeof setImmediate === 'function') setImmediate(func);else setTimeout(func, 0); +}; + +/* generate a resolver function */ +var resolver = function resolver(cb, next, method) { + return function (value) { + if (typeof cb !== 'function') /* [Promises/A+ 2.2.1, 2.2.7.3, 2.2.7.4] */ + next[method].call(next, value); /* [Promises/A+ 2.2.7.3, 2.2.7.4] */else { + var result; + try { + result = cb(value); + } /* [Promises/A+ 2.2.2.1, 2.2.3.1, 2.2.5, 3.2] */ catch (e) { + next.reject(e); /* [Promises/A+ 2.2.7.2] */ + return; + } + resolve(next, result); /* [Promises/A+ 2.2.7.1] */ + } + }; +}; + +/* "Promise Resolution Procedure" */ /* [Promises/A+ 2.3] */ +var resolve = function resolve(promise, x) { + /* sanity check arguments */ /* [Promises/A+ 2.3.1] */ + if (promise === x || promise.proxy === x) { + promise.reject(new TypeError('cannot resolve promise with itself')); + return; + } + + /* surgically check for a "then" method + (mainly to just call the "getter" of "then" only once) */ + var then; + if (_typeof(x) === 'object' && x !== null || typeof x === 'function') { + try { + then = x.then; + } /* [Promises/A+ 2.3.3.1, 3.5] */ catch (e) { + promise.reject(e); /* [Promises/A+ 2.3.3.2] */ + return; + } + } + + /* handle own Thenables [Promises/A+ 2.3.2] + and similar "thenables" [Promises/A+ 2.3.3] */ + if (typeof then === 'function') { + var resolved = false; + try { + /* call retrieved "then" method */ /* [Promises/A+ 2.3.3.3] */ + then.call(x, /* resolvePromise */ /* [Promises/A+ 2.3.3.3.1] */ + function (y) { + if (resolved) return; + resolved = true; /* [Promises/A+ 2.3.3.3.3] */ + if (y === x) /* [Promises/A+ 3.6] */ + promise.reject(new TypeError('circular thenable chain'));else resolve(promise, y); + }, /* rejectPromise */ /* [Promises/A+ 2.3.3.3.2] */ + function (r) { + if (resolved) return; + resolved = true; /* [Promises/A+ 2.3.3.3.3] */ + promise.reject(r); + }); + } catch (e) { + if (!resolved) /* [Promises/A+ 2.3.3.3.3] */ + promise.reject(e); /* [Promises/A+ 2.3.3.3.4] */ + } + + return; + } + + /* handle other values */ + promise.fulfill(x); /* [Promises/A+ 2.3.4, 2.3.3.4] */ +}; + +// so we always have Promise.all() +api.all = function (ps) { + return new api(function (resolveAll, rejectAll) { + var vals = new Array(ps.length); + var doneCount = 0; + var fulfill = function fulfill(i, val) { + vals[i] = val; + doneCount++; + if (doneCount === ps.length) { + resolveAll(vals); + } + }; + for (var i = 0; i < ps.length; i++) { + (function (i) { + var p = ps[i]; + var isPromise = p != null && p.then != null; + if (isPromise) { + p.then(function (val) { + fulfill(i, val); + }, function (err) { + rejectAll(err); + }); + } else { + var val = p; + fulfill(i, val); + } + })(i); + } + }); +}; +api.resolve = function (val) { + return new api(function (resolve, reject) { + resolve(val); + }); +}; +api.reject = function (val) { + return new api(function (resolve, reject) { + reject(val); + }); +}; +var Promise$1 = typeof Promise !== 'undefined' ? Promise : api; // eslint-disable-line no-undef + +var Animation = function Animation(target, opts, opts2) { + var isCore = core(target); + var isEle = !isCore; + var _p = this._private = extend({ + duration: 1000 + }, opts, opts2); + _p.target = target; + _p.style = _p.style || _p.css; + _p.started = false; + _p.playing = false; + _p.hooked = false; + _p.applying = false; + _p.progress = 0; + _p.completes = []; + _p.frames = []; + if (_p.complete && fn$6(_p.complete)) { + _p.completes.push(_p.complete); + } + if (isEle) { + var pos = target.position(); + _p.startPosition = _p.startPosition || { + x: pos.x, + y: pos.y + }; + _p.startStyle = _p.startStyle || target.cy().style().getAnimationStartStyle(target, _p.style); + } + if (isCore) { + var pan = target.pan(); + _p.startPan = { + x: pan.x, + y: pan.y + }; + _p.startZoom = target.zoom(); + } + + // for future timeline/animations impl + this.length = 1; + this[0] = this; +}; +var anifn = Animation.prototype; +extend(anifn, { + instanceString: function instanceString() { + return 'animation'; + }, + hook: function hook() { + var _p = this._private; + if (!_p.hooked) { + // add to target's animation queue + var q; + var tAni = _p.target._private.animation; + if (_p.queue) { + q = tAni.queue; + } else { + q = tAni.current; + } + q.push(this); + + // add to the animation loop pool + if (elementOrCollection(_p.target)) { + _p.target.cy().addToAnimationPool(_p.target); + } + _p.hooked = true; + } + return this; + }, + play: function play() { + var _p = this._private; + + // autorewind + if (_p.progress === 1) { + _p.progress = 0; + } + _p.playing = true; + _p.started = false; // needs to be started by animation loop + _p.stopped = false; + this.hook(); + + // the animation loop will start the animation... + + return this; + }, + playing: function playing() { + return this._private.playing; + }, + apply: function apply() { + var _p = this._private; + _p.applying = true; + _p.started = false; // needs to be started by animation loop + _p.stopped = false; + this.hook(); + + // the animation loop will apply the animation at this progress + + return this; + }, + applying: function applying() { + return this._private.applying; + }, + pause: function pause() { + var _p = this._private; + _p.playing = false; + _p.started = false; + return this; + }, + stop: function stop() { + var _p = this._private; + _p.playing = false; + _p.started = false; + _p.stopped = true; // to be removed from animation queues + + return this; + }, + rewind: function rewind() { + return this.progress(0); + }, + fastforward: function fastforward() { + return this.progress(1); + }, + time: function time(t) { + var _p = this._private; + if (t === undefined) { + return _p.progress * _p.duration; + } else { + return this.progress(t / _p.duration); + } + }, + progress: function progress(p) { + var _p = this._private; + var wasPlaying = _p.playing; + if (p === undefined) { + return _p.progress; + } else { + if (wasPlaying) { + this.pause(); + } + _p.progress = p; + _p.started = false; + if (wasPlaying) { + this.play(); + } + } + return this; + }, + completed: function completed() { + return this._private.progress === 1; + }, + reverse: function reverse() { + var _p = this._private; + var wasPlaying = _p.playing; + if (wasPlaying) { + this.pause(); + } + _p.progress = 1 - _p.progress; + _p.started = false; + var swap = function swap(a, b) { + var _pa = _p[a]; + if (_pa == null) { + return; + } + _p[a] = _p[b]; + _p[b] = _pa; + }; + swap('zoom', 'startZoom'); + swap('pan', 'startPan'); + swap('position', 'startPosition'); + + // swap styles + if (_p.style) { + for (var i = 0; i < _p.style.length; i++) { + var prop = _p.style[i]; + var name = prop.name; + var startStyleProp = _p.startStyle[name]; + _p.startStyle[name] = prop; + _p.style[i] = startStyleProp; + } + } + if (wasPlaying) { + this.play(); + } + return this; + }, + promise: function promise(type) { + var _p = this._private; + var arr; + switch (type) { + case 'frame': + arr = _p.frames; + break; + default: + case 'complete': + case 'completed': + arr = _p.completes; + } + return new Promise$1(function (resolve, reject) { + arr.push(function () { + resolve(); + }); + }); + } +}); +anifn.complete = anifn.completed; +anifn.run = anifn.play; +anifn.running = anifn.playing; + +var define$3 = { + animated: function animated() { + return function animatedImpl() { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return false; + } + var ele = all[0]; + if (ele) { + return ele._private.animation.current.length > 0; + } + }; + }, + // animated + + clearQueue: function clearQueue() { + return function clearQueueImpl() { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + ele._private.animation.queue = []; + } + return this; + }; + }, + // clearQueue + + delay: function delay() { + return function delayImpl(time, complete) { + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + return this.animate({ + delay: time, + duration: time, + complete: complete + }); + }; + }, + // delay + + delayAnimation: function delayAnimation() { + return function delayAnimationImpl(time, complete) { + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + return this.animation({ + delay: time, + duration: time, + complete: complete + }); + }; + }, + // delay + + animation: function animation() { + return function animationImpl(properties, params) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + var isCore = !selfIsArrayLike; + var isEles = !isCore; + if (!cy.styleEnabled()) { + return this; + } + var style = cy.style(); + properties = extend({}, properties, params); + var propertiesEmpty = Object.keys(properties).length === 0; + if (propertiesEmpty) { + return new Animation(all[0], properties); // nothing to animate + } + + if (properties.duration === undefined) { + properties.duration = 400; + } + switch (properties.duration) { + case 'slow': + properties.duration = 600; + break; + case 'fast': + properties.duration = 200; + break; + } + if (isEles) { + properties.style = style.getPropsList(properties.style || properties.css); + properties.css = undefined; + } + if (isEles && properties.renderedPosition != null) { + var rpos = properties.renderedPosition; + var pan = cy.pan(); + var zoom = cy.zoom(); + properties.position = renderedToModelPosition(rpos, zoom, pan); + } + + // override pan w/ panBy if set + if (isCore && properties.panBy != null) { + var panBy = properties.panBy; + var cyPan = cy.pan(); + properties.pan = { + x: cyPan.x + panBy.x, + y: cyPan.y + panBy.y + }; + } + + // override pan w/ center if set + var center = properties.center || properties.centre; + if (isCore && center != null) { + var centerPan = cy.getCenterPan(center.eles, properties.zoom); + if (centerPan != null) { + properties.pan = centerPan; + } + } + + // override pan & zoom w/ fit if set + if (isCore && properties.fit != null) { + var fit = properties.fit; + var fitVp = cy.getFitViewport(fit.eles || fit.boundingBox, fit.padding); + if (fitVp != null) { + properties.pan = fitVp.pan; + properties.zoom = fitVp.zoom; + } + } + + // override zoom (& potentially pan) w/ zoom obj if set + if (isCore && plainObject(properties.zoom)) { + var vp = cy.getZoomedViewport(properties.zoom); + if (vp != null) { + if (vp.zoomed) { + properties.zoom = vp.zoom; + } + if (vp.panned) { + properties.pan = vp.pan; + } + } else { + properties.zoom = null; // an inavalid zoom (e.g. no delta) gets automatically destroyed + } + } + + return new Animation(all[0], properties); + }; + }, + // animate + + animate: function animate() { + return function animateImpl(properties, params) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + if (params) { + properties = extend({}, properties, params); + } + + // manually hook and run the animation + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + var queue = ele.animated() && (properties.queue === undefined || properties.queue); + var ani = ele.animation(properties, queue ? { + queue: true + } : undefined); + ani.play(); + } + return this; // chaining + }; + }, + + // animate + + stop: function stop() { + return function stopImpl(clearQueue, jumpToEnd) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + var _p = ele._private; + var anis = _p.animation.current; + for (var j = 0; j < anis.length; j++) { + var ani = anis[j]; + var ani_p = ani._private; + if (jumpToEnd) { + // next iteration of the animation loop, the animation + // will go straight to the end and be removed + ani_p.duration = 0; + } + } + + // clear the queue of future animations + if (clearQueue) { + _p.animation.queue = []; + } + if (!jumpToEnd) { + _p.animation.current = []; + } + } + + // we have to notify (the animation loop doesn't do it for us on `stop`) + cy.notify('draw'); + return this; + }; + } // stop +}; // define + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +var isArray_1 = isArray; + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray_1(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol_1(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + +var _isKey = isKey; + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject_1(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = _baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +var isFunction_1 = isFunction; + +/** Used to detect overreaching core-js shims. */ +var coreJsData = _root['__core-js_shared__']; + +var _coreJsData = coreJsData; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +var _isMasked = isMasked; + +/** Used for built-in method references. */ +var funcProto$1 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$1 = funcProto$1.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString$1.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +var _toSource = toSource; + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto$3 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty$3).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject_1(value) || _isMasked(value)) { + return false; + } + var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor; + return pattern.test(_toSource(value)); +} + +var _baseIsNative = baseIsNative; + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue$1(object, key) { + return object == null ? undefined : object[key]; +} + +var _getValue = getValue$1; + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = _getValue(object, key); + return _baseIsNative(value) ? value : undefined; +} + +var _getNative = getNative; + +/* Built-in method references that are verified to be native. */ +var nativeCreate = _getNative(Object, 'create'); + +var _nativeCreate = nativeCreate; + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = _nativeCreate ? _nativeCreate(null) : {}; + this.size = 0; +} + +var _hashClear = hashClear; + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +var _hashDelete = hashDelete; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (_nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED$1 ? undefined : result; + } + return hasOwnProperty$2.call(data, key) ? data[key] : undefined; +} + +var _hashGet = hashGet; + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key); +} + +var _hashHas = hashHas; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +var _hashSet = hashSet; + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = _hashClear; +Hash.prototype['delete'] = _hashDelete; +Hash.prototype.get = _hashGet; +Hash.prototype.has = _hashHas; +Hash.prototype.set = _hashSet; + +var _Hash = Hash; + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +var _listCacheClear = listCacheClear; + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +var eq_1 = eq; + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq_1(array[length][0], key)) { + return length; + } + } + return -1; +} + +var _assocIndexOf = assocIndexOf; + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +var _listCacheDelete = listCacheDelete; + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +var _listCacheGet = listCacheGet; + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return _assocIndexOf(this.__data__, key) > -1; +} + +var _listCacheHas = listCacheHas; + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +var _listCacheSet = listCacheSet; + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = _listCacheClear; +ListCache.prototype['delete'] = _listCacheDelete; +ListCache.prototype.get = _listCacheGet; +ListCache.prototype.has = _listCacheHas; +ListCache.prototype.set = _listCacheSet; + +var _ListCache = ListCache; + +/* Built-in method references that are verified to be native. */ +var Map$1 = _getNative(_root, 'Map'); + +var _Map = Map$1; + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new _Hash, + 'map': new (_Map || _ListCache), + 'string': new _Hash + }; +} + +var _mapCacheClear = mapCacheClear; + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +var _isKeyable = isKeyable; + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return _isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +var _getMapData = getMapData; + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = _getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +var _mapCacheDelete = mapCacheDelete; + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return _getMapData(this, key).get(key); +} + +var _mapCacheGet = mapCacheGet; + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return _getMapData(this, key).has(key); +} + +var _mapCacheHas = mapCacheHas; + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = _getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +var _mapCacheSet = mapCacheSet; + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = _mapCacheClear; +MapCache.prototype['delete'] = _mapCacheDelete; +MapCache.prototype.get = _mapCacheGet; +MapCache.prototype.has = _mapCacheHas; +MapCache.prototype.set = _mapCacheSet; + +var _MapCache = MapCache; + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || _MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = _MapCache; + +var memoize_1 = memoize; + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped(func) { + var result = memoize_1(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +var _memoizeCapped = memoizeCapped; + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = _memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +var _stringToPath = stringToPath; + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +var _arrayMap = arrayMap; + +/** Used as references for various `Number` constants. */ +var INFINITY$1 = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = _Symbol ? _Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray_1(value)) { + // Recursively convert values (susceptible to call stack limits). + return _arrayMap(value, baseToString) + ''; + } + if (isSymbol_1(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result; +} + +var _baseToString = baseToString; + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString$1(value) { + return value == null ? '' : _baseToString(value); +} + +var toString_1 = toString$1; + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value, object) { + if (isArray_1(value)) { + return value; + } + return _isKey(value, object) ? [value] : _stringToPath(toString_1(value)); +} + +var _castPath = castPath; + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol_1(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +var _toKey = toKey; + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = _castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[_toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +var _baseGet = baseGet; + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get(object, path, defaultValue) { + var result = object == null ? undefined : _baseGet(object, path); + return result === undefined ? defaultValue : result; +} + +var get_1 = get; + +var defineProperty = (function() { + try { + var func = _getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +var _defineProperty = defineProperty; + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue(object, key, value) { + if (key == '__proto__' && _defineProperty) { + _defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +var _baseAssignValue = baseAssignValue; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq_1(objValue, value)) || + (value === undefined && !(key in object))) { + _baseAssignValue(object, key, value); + } +} + +var _assignValue = assignValue; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +var _isIndex = isIndex; + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject_1(object)) { + return object; + } + path = _castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = _toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject_1(objValue) + ? objValue + : (_isIndex(path[index + 1]) ? [] : {}); + } + } + _assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +var _baseSet = baseSet; + +/** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ +function set(object, path, value) { + return object == null ? object : _baseSet(object, path, value); +} + +var set_1 = set; + +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} + +var _copyArray = copyArray; + +/** + * Converts `value` to a property path array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {*} value The value to convert. + * @returns {Array} Returns the new property path array. + * @example + * + * _.toPath('a.b.c'); + * // => ['a', 'b', 'c'] + * + * _.toPath('a[0].b.c'); + * // => ['a', '0', 'b', 'c'] + */ +function toPath(value) { + if (isArray_1(value)) { + return _arrayMap(value, _toKey); + } + return isSymbol_1(value) ? [value] : _copyArray(_stringToPath(toString_1(value))); +} + +var toPath_1 = toPath; + +var define$2 = { + // access data field + data: function data(params) { + var defaults = { + field: 'data', + bindingEvent: 'data', + allowBinding: false, + allowSetting: false, + allowGetting: false, + settingEvent: 'data', + settingTriggersEvent: false, + triggerFnName: 'trigger', + immutableKeys: {}, + // key => true if immutable + updateStyle: false, + beforeGet: function beforeGet(self) {}, + beforeSet: function beforeSet(self, obj) {}, + onSet: function onSet(self) {}, + canSet: function canSet(self) { + return true; + } + }; + params = extend({}, defaults, params); + return function dataImpl(name, value) { + var p = params; + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var single = selfIsArrayLike ? self[0] : self; + + // .data('foo', ...) + if (string(name)) { + // set or get property + var isPathLike = name.indexOf('.') !== -1; // there might be a normal field with a dot + var path = isPathLike && toPath_1(name); + + // .data('foo') + if (p.allowGetting && value === undefined) { + // get + + var ret; + if (single) { + p.beforeGet(single); + + // check if it's path and a field with the same name doesn't exist + if (path && single._private[p.field][name] === undefined) { + ret = get_1(single._private[p.field], path); + } else { + ret = single._private[p.field][name]; + } + } + return ret; + + // .data('foo', 'bar') + } else if (p.allowSetting && value !== undefined) { + // set + var valid = !p.immutableKeys[name]; + if (valid) { + var change = _defineProperty$1({}, name, value); + p.beforeSet(self, change); + for (var i = 0, l = all.length; i < l; i++) { + var ele = all[i]; + if (p.canSet(ele)) { + if (path && single._private[p.field][name] === undefined) { + set_1(ele._private[p.field], path, value); + } else { + ele._private[p.field][name] = value; + } + } + } + + // update mappers if asked + if (p.updateStyle) { + self.updateStyle(); + } + + // call onSet callback + p.onSet(self); + if (p.settingTriggersEvent) { + self[p.triggerFnName](p.settingEvent); + } + } + } + + // .data({ 'foo': 'bar' }) + } else if (p.allowSetting && plainObject(name)) { + // extend + var obj = name; + var k, v; + var keys = Object.keys(obj); + p.beforeSet(self, obj); + for (var _i = 0; _i < keys.length; _i++) { + k = keys[_i]; + v = obj[k]; + var _valid = !p.immutableKeys[k]; + if (_valid) { + for (var j = 0; j < all.length; j++) { + var _ele = all[j]; + if (p.canSet(_ele)) { + _ele._private[p.field][k] = v; + } + } + } + } + + // update mappers if asked + if (p.updateStyle) { + self.updateStyle(); + } + + // call onSet callback + p.onSet(self); + if (p.settingTriggersEvent) { + self[p.triggerFnName](p.settingEvent); + } + + // .data(function(){ ... }) + } else if (p.allowBinding && fn$6(name)) { + // bind to event + var fn = name; + self.on(p.bindingEvent, fn); + + // .data() + } else if (p.allowGetting && name === undefined) { + // get whole object + var _ret; + if (single) { + p.beforeGet(single); + _ret = single._private[p.field]; + } + return _ret; + } + return self; // maintain chainability + }; // function + }, + + // data + + // remove data field + removeData: function removeData(params) { + var defaults = { + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: false, + immutableKeys: {} // key => true if immutable + }; + + params = extend({}, defaults, params); + return function removeDataImpl(names) { + var p = params; + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + + // .removeData('foo bar') + if (string(names)) { + // then get the list of keys, and delete them + var keys = names.split(/\s+/); + var l = keys.length; + for (var i = 0; i < l; i++) { + // delete each non-empty key + var key = keys[i]; + if (emptyString(key)) { + continue; + } + var valid = !p.immutableKeys[key]; // not valid if immutable + if (valid) { + for (var i_a = 0, l_a = all.length; i_a < l_a; i_a++) { + all[i_a]._private[p.field][key] = undefined; + } + } + } + if (p.triggerEvent) { + self[p.triggerFnName](p.event); + } + + // .removeData() + } else if (names === undefined) { + // then delete all keys + + for (var _i_a = 0, _l_a = all.length; _i_a < _l_a; _i_a++) { + var _privateFields = all[_i_a]._private[p.field]; + var _keys = Object.keys(_privateFields); + for (var _i2 = 0; _i2 < _keys.length; _i2++) { + var _key = _keys[_i2]; + var validKeyToDelete = !p.immutableKeys[_key]; + if (validKeyToDelete) { + _privateFields[_key] = undefined; + } + } + } + if (p.triggerEvent) { + self[p.triggerFnName](p.event); + } + } + return self; // maintain chaining + }; // function + } // removeData +}; // define + +var define$1 = { + eventAliasesOn: function eventAliasesOn(proto) { + var p = proto; + p.addListener = p.listen = p.bind = p.on; + p.unlisten = p.unbind = p.off = p.removeListener; + p.trigger = p.emit; + + // this is just a wrapper alias of .on() + p.pon = p.promiseOn = function (events, selector) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + return new Promise$1(function (resolve, reject) { + var callback = function callback(e) { + self.off.apply(self, offArgs); + resolve(e); + }; + var onArgs = args.concat([callback]); + var offArgs = onArgs.concat([]); + self.on.apply(self, onArgs); + }); + }; + } +}; // define + +// use this module to cherry pick functions into your prototype +var define = {}; +[define$3, define$2, define$1].forEach(function (m) { + extend(define, m); +}); + +var elesfn$i = { + animate: define.animate(), + animation: define.animation(), + animated: define.animated(), + clearQueue: define.clearQueue(), + delay: define.delay(), + delayAnimation: define.delayAnimation(), + stop: define.stop() +}; + +var elesfn$h = { + classes: function classes(_classes) { + var self = this; + if (_classes === undefined) { + var ret = []; + self[0]._private.classes.forEach(function (cls) { + return ret.push(cls); + }); + return ret; + } else if (!array(_classes)) { + // extract classes from string + _classes = (_classes || '').match(/\S+/g) || []; + } + var changed = []; + var classesSet = new Set$1(_classes); + + // check and update each ele + for (var j = 0; j < self.length; j++) { + var ele = self[j]; + var _p = ele._private; + var eleClasses = _p.classes; + var changedEle = false; + + // check if ele has all of the passed classes + for (var i = 0; i < _classes.length; i++) { + var cls = _classes[i]; + var eleHasClass = eleClasses.has(cls); + if (!eleHasClass) { + changedEle = true; + break; + } + } + + // check if ele has classes outside of those passed + if (!changedEle) { + changedEle = eleClasses.size !== _classes.length; + } + if (changedEle) { + _p.classes = classesSet; + changed.push(ele); + } + } + + // trigger update style on those eles that had class changes + if (changed.length > 0) { + this.spawn(changed).updateStyle().emit('class'); + } + return self; + }, + addClass: function addClass(classes) { + return this.toggleClass(classes, true); + }, + hasClass: function hasClass(className) { + var ele = this[0]; + return ele != null && ele._private.classes.has(className); + }, + toggleClass: function toggleClass(classes, toggle) { + if (!array(classes)) { + // extract classes from string + classes = classes.match(/\S+/g) || []; + } + var self = this; + var toggleUndefd = toggle === undefined; + var changed = []; // eles who had classes changed + + for (var i = 0, il = self.length; i < il; i++) { + var ele = self[i]; + var eleClasses = ele._private.classes; + var changedEle = false; + for (var j = 0; j < classes.length; j++) { + var cls = classes[j]; + var hasClass = eleClasses.has(cls); + var changedNow = false; + if (toggle || toggleUndefd && !hasClass) { + eleClasses.add(cls); + changedNow = true; + } else if (!toggle || toggleUndefd && hasClass) { + eleClasses["delete"](cls); + changedNow = true; + } + if (!changedEle && changedNow) { + changed.push(ele); + changedEle = true; + } + } // for j classes + } // for i eles + + // trigger update style on those eles that had class changes + if (changed.length > 0) { + this.spawn(changed).updateStyle().emit('class'); + } + return self; + }, + removeClass: function removeClass(classes) { + return this.toggleClass(classes, false); + }, + flashClass: function flashClass(classes, duration) { + var self = this; + if (duration == null) { + duration = 250; + } else if (duration === 0) { + return self; // nothing to do really + } + + self.addClass(classes); + setTimeout(function () { + self.removeClass(classes); + }, duration); + return self; + } +}; +elesfn$h.className = elesfn$h.classNames = elesfn$h.classes; + +// tokens in the query language +var tokens = { + metaChar: '[\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]', + // chars we need to escape in let names, etc + comparatorOp: '=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=', + // binary comparison op (used in data selectors) + boolOp: '\\?|\\!|\\^', + // boolean (unary) operators (used in data selectors) + string: '"(?:\\\\"|[^"])*"' + '|' + "'(?:\\\\'|[^'])*'", + // string literals (used in data selectors) -- doublequotes | singlequotes + number: number, + // number literal (used in data selectors) --- e.g. 0.1234, 1234, 12e123 + meta: 'degree|indegree|outdegree', + // allowed metadata fields (i.e. allowed functions to use from Collection) + separator: '\\s*,\\s*', + // queries are separated by commas, e.g. edge[foo = 'bar'], node.someClass + descendant: '\\s+', + child: '\\s+>\\s+', + subject: '\\$', + group: 'node|edge|\\*', + directedEdge: '\\s+->\\s+', + undirectedEdge: '\\s+<->\\s+' +}; +tokens.variable = '(?:[\\w-.]|(?:\\\\' + tokens.metaChar + '))+'; // a variable name can have letters, numbers, dashes, and periods +tokens.className = '(?:[\\w-]|(?:\\\\' + tokens.metaChar + '))+'; // a class name has the same rules as a variable except it can't have a '.' in the name +tokens.value = tokens.string + '|' + tokens.number; // a value literal, either a string or number +tokens.id = tokens.variable; // an element id (follows variable conventions) + +(function () { + var ops, op, i; + + // add @ variants to comparatorOp + ops = tokens.comparatorOp.split('|'); + for (i = 0; i < ops.length; i++) { + op = ops[i]; + tokens.comparatorOp += '|@' + op; + } + + // add ! variants to comparatorOp + ops = tokens.comparatorOp.split('|'); + for (i = 0; i < ops.length; i++) { + op = ops[i]; + if (op.indexOf('!') >= 0) { + continue; + } // skip ops that explicitly contain ! + if (op === '=') { + continue; + } // skip = b/c != is explicitly defined + + tokens.comparatorOp += '|\\!' + op; + } +})(); + +/** + * Make a new query object + * + * @prop type {Type} The type enum (int) of the query + * @prop checks List of checks to make against an ele to test for a match + */ +var newQuery = function newQuery() { + return { + checks: [] + }; +}; + +/** + * A check type enum-like object. Uses integer values for fast match() lookup. + * The ordering does not matter as long as the ints are unique. + */ +var Type = { + /** E.g. node */ + GROUP: 0, + /** A collection of elements */ + COLLECTION: 1, + /** A filter(ele) function */ + FILTER: 2, + /** E.g. [foo > 1] */ + DATA_COMPARE: 3, + /** E.g. [foo] */ + DATA_EXIST: 4, + /** E.g. [?foo] */ + DATA_BOOL: 5, + /** E.g. [[degree > 2]] */ + META_COMPARE: 6, + /** E.g. :selected */ + STATE: 7, + /** E.g. #foo */ + ID: 8, + /** E.g. .foo */ + CLASS: 9, + /** E.g. #foo <-> #bar */ + UNDIRECTED_EDGE: 10, + /** E.g. #foo -> #bar */ + DIRECTED_EDGE: 11, + /** E.g. $#foo -> #bar */ + NODE_SOURCE: 12, + /** E.g. #foo -> $#bar */ + NODE_TARGET: 13, + /** E.g. $#foo <-> #bar */ + NODE_NEIGHBOR: 14, + /** E.g. #foo > #bar */ + CHILD: 15, + /** E.g. #foo #bar */ + DESCENDANT: 16, + /** E.g. $#foo > #bar */ + PARENT: 17, + /** E.g. $#foo #bar */ + ANCESTOR: 18, + /** E.g. #foo > $bar > #baz */ + COMPOUND_SPLIT: 19, + /** Always matches, useful placeholder for subject in `COMPOUND_SPLIT` */ + TRUE: 20 +}; + +var stateSelectors = [{ + selector: ':selected', + matches: function matches(ele) { + return ele.selected(); + } +}, { + selector: ':unselected', + matches: function matches(ele) { + return !ele.selected(); + } +}, { + selector: ':selectable', + matches: function matches(ele) { + return ele.selectable(); + } +}, { + selector: ':unselectable', + matches: function matches(ele) { + return !ele.selectable(); + } +}, { + selector: ':locked', + matches: function matches(ele) { + return ele.locked(); + } +}, { + selector: ':unlocked', + matches: function matches(ele) { + return !ele.locked(); + } +}, { + selector: ':visible', + matches: function matches(ele) { + return ele.visible(); + } +}, { + selector: ':hidden', + matches: function matches(ele) { + return !ele.visible(); + } +}, { + selector: ':transparent', + matches: function matches(ele) { + return ele.transparent(); + } +}, { + selector: ':grabbed', + matches: function matches(ele) { + return ele.grabbed(); + } +}, { + selector: ':free', + matches: function matches(ele) { + return !ele.grabbed(); + } +}, { + selector: ':removed', + matches: function matches(ele) { + return ele.removed(); + } +}, { + selector: ':inside', + matches: function matches(ele) { + return !ele.removed(); + } +}, { + selector: ':grabbable', + matches: function matches(ele) { + return ele.grabbable(); + } +}, { + selector: ':ungrabbable', + matches: function matches(ele) { + return !ele.grabbable(); + } +}, { + selector: ':animated', + matches: function matches(ele) { + return ele.animated(); + } +}, { + selector: ':unanimated', + matches: function matches(ele) { + return !ele.animated(); + } +}, { + selector: ':parent', + matches: function matches(ele) { + return ele.isParent(); + } +}, { + selector: ':childless', + matches: function matches(ele) { + return ele.isChildless(); + } +}, { + selector: ':child', + matches: function matches(ele) { + return ele.isChild(); + } +}, { + selector: ':orphan', + matches: function matches(ele) { + return ele.isOrphan(); + } +}, { + selector: ':nonorphan', + matches: function matches(ele) { + return ele.isChild(); + } +}, { + selector: ':compound', + matches: function matches(ele) { + if (ele.isNode()) { + return ele.isParent(); + } else { + return ele.source().isParent() || ele.target().isParent(); + } + } +}, { + selector: ':loop', + matches: function matches(ele) { + return ele.isLoop(); + } +}, { + selector: ':simple', + matches: function matches(ele) { + return ele.isSimple(); + } +}, { + selector: ':active', + matches: function matches(ele) { + return ele.active(); + } +}, { + selector: ':inactive', + matches: function matches(ele) { + return !ele.active(); + } +}, { + selector: ':backgrounding', + matches: function matches(ele) { + return ele.backgrounding(); + } +}, { + selector: ':nonbackgrounding', + matches: function matches(ele) { + return !ele.backgrounding(); + } +}].sort(function (a, b) { + // n.b. selectors that are starting substrings of others must have the longer ones first + return descending(a.selector, b.selector); +}); +var lookup = function () { + var selToFn = {}; + var s; + for (var i = 0; i < stateSelectors.length; i++) { + s = stateSelectors[i]; + selToFn[s.selector] = s.matches; + } + return selToFn; +}(); +var stateSelectorMatches = function stateSelectorMatches(sel, ele) { + return lookup[sel](ele); +}; +var stateSelectorRegex = '(' + stateSelectors.map(function (s) { + return s.selector; +}).join('|') + ')'; + +// when a token like a variable has escaped meta characters, we need to clean the backslashes out +// so that values get compared properly in Selector.filter() +var cleanMetaChars = function cleanMetaChars(str) { + return str.replace(new RegExp('\\\\(' + tokens.metaChar + ')', 'g'), function (match, $1) { + return $1; + }); +}; +var replaceLastQuery = function replaceLastQuery(selector, examiningQuery, replacementQuery) { + selector[selector.length - 1] = replacementQuery; +}; + +// NOTE: add new expression syntax here to have it recognised by the parser; +// - a query contains all adjacent (i.e. no separator in between) expressions; +// - the current query is stored in selector[i] +// - you need to check the query objects in match() for it actually filter properly, but that's pretty straight forward +var exprs = [{ + name: 'group', + // just used for identifying when debugging + query: true, + regex: '(' + tokens.group + ')', + populate: function populate(selector, query, _ref) { + var _ref2 = _slicedToArray(_ref, 1), + group = _ref2[0]; + query.checks.push({ + type: Type.GROUP, + value: group === '*' ? group : group + 's' + }); + } +}, { + name: 'state', + query: true, + regex: stateSelectorRegex, + populate: function populate(selector, query, _ref3) { + var _ref4 = _slicedToArray(_ref3, 1), + state = _ref4[0]; + query.checks.push({ + type: Type.STATE, + value: state + }); + } +}, { + name: 'id', + query: true, + regex: '\\#(' + tokens.id + ')', + populate: function populate(selector, query, _ref5) { + var _ref6 = _slicedToArray(_ref5, 1), + id = _ref6[0]; + query.checks.push({ + type: Type.ID, + value: cleanMetaChars(id) + }); + } +}, { + name: 'className', + query: true, + regex: '\\.(' + tokens.className + ')', + populate: function populate(selector, query, _ref7) { + var _ref8 = _slicedToArray(_ref7, 1), + className = _ref8[0]; + query.checks.push({ + type: Type.CLASS, + value: cleanMetaChars(className) + }); + } +}, { + name: 'dataExists', + query: true, + regex: '\\[\\s*(' + tokens.variable + ')\\s*\\]', + populate: function populate(selector, query, _ref9) { + var _ref10 = _slicedToArray(_ref9, 1), + variable = _ref10[0]; + query.checks.push({ + type: Type.DATA_EXIST, + field: cleanMetaChars(variable) + }); + } +}, { + name: 'dataCompare', + query: true, + regex: '\\[\\s*(' + tokens.variable + ')\\s*(' + tokens.comparatorOp + ')\\s*(' + tokens.value + ')\\s*\\]', + populate: function populate(selector, query, _ref11) { + var _ref12 = _slicedToArray(_ref11, 3), + variable = _ref12[0], + comparatorOp = _ref12[1], + value = _ref12[2]; + var valueIsString = new RegExp('^' + tokens.string + '$').exec(value) != null; + if (valueIsString) { + value = value.substring(1, value.length - 1); + } else { + value = parseFloat(value); + } + query.checks.push({ + type: Type.DATA_COMPARE, + field: cleanMetaChars(variable), + operator: comparatorOp, + value: value + }); + } +}, { + name: 'dataBool', + query: true, + regex: '\\[\\s*(' + tokens.boolOp + ')\\s*(' + tokens.variable + ')\\s*\\]', + populate: function populate(selector, query, _ref13) { + var _ref14 = _slicedToArray(_ref13, 2), + boolOp = _ref14[0], + variable = _ref14[1]; + query.checks.push({ + type: Type.DATA_BOOL, + field: cleanMetaChars(variable), + operator: boolOp + }); + } +}, { + name: 'metaCompare', + query: true, + regex: '\\[\\[\\s*(' + tokens.meta + ')\\s*(' + tokens.comparatorOp + ')\\s*(' + tokens.number + ')\\s*\\]\\]', + populate: function populate(selector, query, _ref15) { + var _ref16 = _slicedToArray(_ref15, 3), + meta = _ref16[0], + comparatorOp = _ref16[1], + number = _ref16[2]; + query.checks.push({ + type: Type.META_COMPARE, + field: cleanMetaChars(meta), + operator: comparatorOp, + value: parseFloat(number) + }); + } +}, { + name: 'nextQuery', + separator: true, + regex: tokens.separator, + populate: function populate(selector, query) { + var currentSubject = selector.currentSubject; + var edgeCount = selector.edgeCount; + var compoundCount = selector.compoundCount; + var lastQ = selector[selector.length - 1]; + if (currentSubject != null) { + lastQ.subject = currentSubject; + selector.currentSubject = null; + } + lastQ.edgeCount = edgeCount; + lastQ.compoundCount = compoundCount; + selector.edgeCount = 0; + selector.compoundCount = 0; + + // go on to next query + var nextQuery = selector[selector.length++] = newQuery(); + return nextQuery; // this is the new query to be filled by the following exprs + } +}, { + name: 'directedEdge', + separator: true, + regex: tokens.directedEdge, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // undirected edge + var edgeQuery = newQuery(); + var source = query; + var target = newQuery(); + edgeQuery.checks.push({ + type: Type.DIRECTED_EDGE, + source: source, + target: target + }); + + // the query in the selector should be the edge rather than the source + replaceLastQuery(selector, query, edgeQuery); + selector.edgeCount++; + + // we're now populating the target query with expressions that follow + return target; + } else { + // source/target + var srcTgtQ = newQuery(); + var _source = query; + var _target = newQuery(); + srcTgtQ.checks.push({ + type: Type.NODE_SOURCE, + source: _source, + target: _target + }); + + // the query in the selector should be the neighbourhood rather than the node + replaceLastQuery(selector, query, srcTgtQ); + selector.edgeCount++; + return _target; // now populating the target with the following expressions + } + } +}, { + name: 'undirectedEdge', + separator: true, + regex: tokens.undirectedEdge, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // undirected edge + var edgeQuery = newQuery(); + var source = query; + var target = newQuery(); + edgeQuery.checks.push({ + type: Type.UNDIRECTED_EDGE, + nodes: [source, target] + }); + + // the query in the selector should be the edge rather than the source + replaceLastQuery(selector, query, edgeQuery); + selector.edgeCount++; + + // we're now populating the target query with expressions that follow + return target; + } else { + // neighbourhood + var nhoodQ = newQuery(); + var node = query; + var neighbor = newQuery(); + nhoodQ.checks.push({ + type: Type.NODE_NEIGHBOR, + node: node, + neighbor: neighbor + }); + + // the query in the selector should be the neighbourhood rather than the node + replaceLastQuery(selector, query, nhoodQ); + return neighbor; // now populating the neighbor with following expressions + } + } +}, { + name: 'child', + separator: true, + regex: tokens.child, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // default: child query + var parentChildQuery = newQuery(); + var child = newQuery(); + var parent = selector[selector.length - 1]; + parentChildQuery.checks.push({ + type: Type.CHILD, + parent: parent, + child: child + }); + + // the query in the selector should be the '>' itself + replaceLastQuery(selector, query, parentChildQuery); + selector.compoundCount++; + + // we're now populating the child query with expressions that follow + return child; + } else if (selector.currentSubject === query) { + // compound split query + var compound = newQuery(); + var left = selector[selector.length - 1]; + var right = newQuery(); + var subject = newQuery(); + var _child = newQuery(); + var _parent = newQuery(); + + // set up the root compound q + compound.checks.push({ + type: Type.COMPOUND_SPLIT, + left: left, + right: right, + subject: subject + }); + + // populate the subject and replace the q at the old spot (within left) with TRUE + subject.checks = query.checks; // take the checks from the left + query.checks = [{ + type: Type.TRUE + }]; // checks under left refs the subject implicitly + + // set up the right q + _parent.checks.push({ + type: Type.TRUE + }); // parent implicitly refs the subject + right.checks.push({ + type: Type.PARENT, + // type is swapped on right side queries + parent: _parent, + child: _child // empty for now + }); + + replaceLastQuery(selector, left, compound); + + // update the ref since we moved things around for `query` + selector.currentSubject = subject; + selector.compoundCount++; + return _child; // now populating the right side's child + } else { + // parent query + // info for parent query + var _parent2 = newQuery(); + var _child2 = newQuery(); + var pcQChecks = [{ + type: Type.PARENT, + parent: _parent2, + child: _child2 + }]; + + // the parent-child query takes the place of the query previously being populated + _parent2.checks = query.checks; // the previous query contains the checks for the parent + query.checks = pcQChecks; // pc query takes over + + selector.compoundCount++; + return _child2; // we're now populating the child + } + } +}, { + name: 'descendant', + separator: true, + regex: tokens.descendant, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // default: descendant query + var ancChQuery = newQuery(); + var descendant = newQuery(); + var ancestor = selector[selector.length - 1]; + ancChQuery.checks.push({ + type: Type.DESCENDANT, + ancestor: ancestor, + descendant: descendant + }); + + // the query in the selector should be the '>' itself + replaceLastQuery(selector, query, ancChQuery); + selector.compoundCount++; + + // we're now populating the descendant query with expressions that follow + return descendant; + } else if (selector.currentSubject === query) { + // compound split query + var compound = newQuery(); + var left = selector[selector.length - 1]; + var right = newQuery(); + var subject = newQuery(); + var _descendant = newQuery(); + var _ancestor = newQuery(); + + // set up the root compound q + compound.checks.push({ + type: Type.COMPOUND_SPLIT, + left: left, + right: right, + subject: subject + }); + + // populate the subject and replace the q at the old spot (within left) with TRUE + subject.checks = query.checks; // take the checks from the left + query.checks = [{ + type: Type.TRUE + }]; // checks under left refs the subject implicitly + + // set up the right q + _ancestor.checks.push({ + type: Type.TRUE + }); // ancestor implicitly refs the subject + right.checks.push({ + type: Type.ANCESTOR, + // type is swapped on right side queries + ancestor: _ancestor, + descendant: _descendant // empty for now + }); + + replaceLastQuery(selector, left, compound); + + // update the ref since we moved things around for `query` + selector.currentSubject = subject; + selector.compoundCount++; + return _descendant; // now populating the right side's descendant + } else { + // ancestor query + // info for parent query + var _ancestor2 = newQuery(); + var _descendant2 = newQuery(); + var adQChecks = [{ + type: Type.ANCESTOR, + ancestor: _ancestor2, + descendant: _descendant2 + }]; + + // the parent-child query takes the place of the query previously being populated + _ancestor2.checks = query.checks; // the previous query contains the checks for the parent + query.checks = adQChecks; // pc query takes over + + selector.compoundCount++; + return _descendant2; // we're now populating the child + } + } +}, { + name: 'subject', + modifier: true, + regex: tokens.subject, + populate: function populate(selector, query) { + if (selector.currentSubject != null && selector.currentSubject !== query) { + warn('Redefinition of subject in selector `' + selector.toString() + '`'); + return false; + } + selector.currentSubject = query; + var topQ = selector[selector.length - 1]; + var topChk = topQ.checks[0]; + var topType = topChk == null ? null : topChk.type; + if (topType === Type.DIRECTED_EDGE) { + // directed edge with subject on the target + + // change to target node check + topChk.type = Type.NODE_TARGET; + } else if (topType === Type.UNDIRECTED_EDGE) { + // undirected edge with subject on the second node + + // change to neighbor check + topChk.type = Type.NODE_NEIGHBOR; + topChk.node = topChk.nodes[1]; // second node is subject + topChk.neighbor = topChk.nodes[0]; + + // clean up unused fields for new type + topChk.nodes = null; + } + } +}]; +exprs.forEach(function (e) { + return e.regexObj = new RegExp('^' + e.regex); +}); + +/** + * Of all the expressions, find the first match in the remaining text. + * @param {string} remaining The remaining text to parse + * @returns The matched expression and the newly remaining text `{ expr, match, name, remaining }` + */ +var consumeExpr = function consumeExpr(remaining) { + var expr; + var match; + var name; + for (var j = 0; j < exprs.length; j++) { + var e = exprs[j]; + var n = e.name; + var m = remaining.match(e.regexObj); + if (m != null) { + match = m; + expr = e; + name = n; + var consumed = m[0]; + remaining = remaining.substring(consumed.length); + break; // we've consumed one expr, so we can return now + } + } + + return { + expr: expr, + match: match, + name: name, + remaining: remaining + }; +}; + +/** + * Consume all the leading whitespace + * @param {string} remaining The text to consume + * @returns The text with the leading whitespace removed + */ +var consumeWhitespace = function consumeWhitespace(remaining) { + var match = remaining.match(/^\s+/); + if (match) { + var consumed = match[0]; + remaining = remaining.substring(consumed.length); + } + return remaining; +}; + +/** + * Parse the string and store the parsed representation in the Selector. + * @param {string} selector The selector string + * @returns `true` if the selector was successfully parsed, `false` otherwise + */ +var parse = function parse(selector) { + var self = this; + var remaining = self.inputText = selector; + var currentQuery = self[0] = newQuery(); + self.length = 1; + remaining = consumeWhitespace(remaining); // get rid of leading whitespace + + for (;;) { + var exprInfo = consumeExpr(remaining); + if (exprInfo.expr == null) { + warn('The selector `' + selector + '`is invalid'); + return false; + } else { + var args = exprInfo.match.slice(1); + + // let the token populate the selector object in currentQuery + var ret = exprInfo.expr.populate(self, currentQuery, args); + if (ret === false) { + return false; // exit if population failed + } else if (ret != null) { + currentQuery = ret; // change the current query to be filled if the expr specifies + } + } + + remaining = exprInfo.remaining; + + // we're done when there's nothing left to parse + if (remaining.match(/^\s*$/)) { + break; + } + } + var lastQ = self[self.length - 1]; + if (self.currentSubject != null) { + lastQ.subject = self.currentSubject; + } + lastQ.edgeCount = self.edgeCount; + lastQ.compoundCount = self.compoundCount; + for (var i = 0; i < self.length; i++) { + var q = self[i]; + + // in future, this could potentially be allowed if there were operator precedence and detection of invalid combinations + if (q.compoundCount > 0 && q.edgeCount > 0) { + warn('The selector `' + selector + '` is invalid because it uses both a compound selector and an edge selector'); + return false; + } + if (q.edgeCount > 1) { + warn('The selector `' + selector + '` is invalid because it uses multiple edge selectors'); + return false; + } else if (q.edgeCount === 1) { + warn('The selector `' + selector + '` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.'); + } + } + return true; // success +}; + +/** + * Get the selector represented as a string. This value uses default formatting, + * so things like spacing may differ from the input text passed to the constructor. + * @returns {string} The selector string + */ +var toString = function toString() { + if (this.toStringCache != null) { + return this.toStringCache; + } + var clean = function clean(obj) { + if (obj == null) { + return ''; + } else { + return obj; + } + }; + var cleanVal = function cleanVal(val) { + if (string(val)) { + return '"' + val + '"'; + } else { + return clean(val); + } + }; + var space = function space(val) { + return ' ' + val + ' '; + }; + var checkToString = function checkToString(check, subject) { + var type = check.type, + value = check.value; + switch (type) { + case Type.GROUP: + { + var group = clean(value); + return group.substring(0, group.length - 1); + } + case Type.DATA_COMPARE: + { + var field = check.field, + operator = check.operator; + return '[' + field + space(clean(operator)) + cleanVal(value) + ']'; + } + case Type.DATA_BOOL: + { + var _operator = check.operator, + _field = check.field; + return '[' + clean(_operator) + _field + ']'; + } + case Type.DATA_EXIST: + { + var _field2 = check.field; + return '[' + _field2 + ']'; + } + case Type.META_COMPARE: + { + var _operator2 = check.operator, + _field3 = check.field; + return '[[' + _field3 + space(clean(_operator2)) + cleanVal(value) + ']]'; + } + case Type.STATE: + { + return value; + } + case Type.ID: + { + return '#' + value; + } + case Type.CLASS: + { + return '.' + value; + } + case Type.PARENT: + case Type.CHILD: + { + return queryToString(check.parent, subject) + space('>') + queryToString(check.child, subject); + } + case Type.ANCESTOR: + case Type.DESCENDANT: + { + return queryToString(check.ancestor, subject) + ' ' + queryToString(check.descendant, subject); + } + case Type.COMPOUND_SPLIT: + { + var lhs = queryToString(check.left, subject); + var sub = queryToString(check.subject, subject); + var rhs = queryToString(check.right, subject); + return lhs + (lhs.length > 0 ? ' ' : '') + sub + rhs; + } + case Type.TRUE: + { + return ''; + } + } + }; + var queryToString = function queryToString(query, subject) { + return query.checks.reduce(function (str, chk, i) { + return str + (subject === query && i === 0 ? '$' : '') + checkToString(chk, subject); + }, ''); + }; + var str = ''; + for (var i = 0; i < this.length; i++) { + var query = this[i]; + str += queryToString(query, query.subject); + if (this.length > 1 && i < this.length - 1) { + str += ', '; + } + } + this.toStringCache = str; + return str; +}; +var parse$1 = { + parse: parse, + toString: toString +}; + +var valCmp = function valCmp(fieldVal, operator, value) { + var matches; + var isFieldStr = string(fieldVal); + var isFieldNum = number$1(fieldVal); + var isValStr = string(value); + var fieldStr, valStr; + var caseInsensitive = false; + var notExpr = false; + var isIneqCmp = false; + if (operator.indexOf('!') >= 0) { + operator = operator.replace('!', ''); + notExpr = true; + } + if (operator.indexOf('@') >= 0) { + operator = operator.replace('@', ''); + caseInsensitive = true; + } + if (isFieldStr || isValStr || caseInsensitive) { + fieldStr = !isFieldStr && !isFieldNum ? '' : '' + fieldVal; + valStr = '' + value; + } + + // if we're doing a case insensitive comparison, then we're using a STRING comparison + // even if we're comparing numbers + if (caseInsensitive) { + fieldVal = fieldStr = fieldStr.toLowerCase(); + value = valStr = valStr.toLowerCase(); + } + switch (operator) { + case '*=': + matches = fieldStr.indexOf(valStr) >= 0; + break; + case '$=': + matches = fieldStr.indexOf(valStr, fieldStr.length - valStr.length) >= 0; + break; + case '^=': + matches = fieldStr.indexOf(valStr) === 0; + break; + case '=': + matches = fieldVal === value; + break; + case '>': + isIneqCmp = true; + matches = fieldVal > value; + break; + case '>=': + isIneqCmp = true; + matches = fieldVal >= value; + break; + case '<': + isIneqCmp = true; + matches = fieldVal < value; + break; + case '<=': + isIneqCmp = true; + matches = fieldVal <= value; + break; + default: + matches = false; + break; + } + + // apply the not op, but null vals for inequalities should always stay non-matching + if (notExpr && (fieldVal != null || !isIneqCmp)) { + matches = !matches; + } + return matches; +}; +var boolCmp = function boolCmp(fieldVal, operator) { + switch (operator) { + case '?': + return fieldVal ? true : false; + case '!': + return fieldVal ? false : true; + case '^': + return fieldVal === undefined; + } +}; +var existCmp = function existCmp(fieldVal) { + return fieldVal !== undefined; +}; +var data$1 = function data(ele, field) { + return ele.data(field); +}; +var meta = function meta(ele, field) { + return ele[field](); +}; + +/** A lookup of `match(check, ele)` functions by `Type` int */ +var match = []; + +/** + * Returns whether the query matches for the element + * @param query The `{ type, value, ... }` query object + * @param ele The element to compare against +*/ +var matches$1 = function matches(query, ele) { + return query.checks.every(function (chk) { + return match[chk.type](chk, ele); + }); +}; +match[Type.GROUP] = function (check, ele) { + var group = check.value; + return group === '*' || group === ele.group(); +}; +match[Type.STATE] = function (check, ele) { + var stateSelector = check.value; + return stateSelectorMatches(stateSelector, ele); +}; +match[Type.ID] = function (check, ele) { + var id = check.value; + return ele.id() === id; +}; +match[Type.CLASS] = function (check, ele) { + var cls = check.value; + return ele.hasClass(cls); +}; +match[Type.META_COMPARE] = function (check, ele) { + var field = check.field, + operator = check.operator, + value = check.value; + return valCmp(meta(ele, field), operator, value); +}; +match[Type.DATA_COMPARE] = function (check, ele) { + var field = check.field, + operator = check.operator, + value = check.value; + return valCmp(data$1(ele, field), operator, value); +}; +match[Type.DATA_BOOL] = function (check, ele) { + var field = check.field, + operator = check.operator; + return boolCmp(data$1(ele, field), operator); +}; +match[Type.DATA_EXIST] = function (check, ele) { + var field = check.field; + check.operator; + return existCmp(data$1(ele, field)); +}; +match[Type.UNDIRECTED_EDGE] = function (check, ele) { + var qA = check.nodes[0]; + var qB = check.nodes[1]; + var src = ele.source(); + var tgt = ele.target(); + return matches$1(qA, src) && matches$1(qB, tgt) || matches$1(qB, src) && matches$1(qA, tgt); +}; +match[Type.NODE_NEIGHBOR] = function (check, ele) { + return matches$1(check.node, ele) && ele.neighborhood().some(function (n) { + return n.isNode() && matches$1(check.neighbor, n); + }); +}; +match[Type.DIRECTED_EDGE] = function (check, ele) { + return matches$1(check.source, ele.source()) && matches$1(check.target, ele.target()); +}; +match[Type.NODE_SOURCE] = function (check, ele) { + return matches$1(check.source, ele) && ele.outgoers().some(function (n) { + return n.isNode() && matches$1(check.target, n); + }); +}; +match[Type.NODE_TARGET] = function (check, ele) { + return matches$1(check.target, ele) && ele.incomers().some(function (n) { + return n.isNode() && matches$1(check.source, n); + }); +}; +match[Type.CHILD] = function (check, ele) { + return matches$1(check.child, ele) && matches$1(check.parent, ele.parent()); +}; +match[Type.PARENT] = function (check, ele) { + return matches$1(check.parent, ele) && ele.children().some(function (c) { + return matches$1(check.child, c); + }); +}; +match[Type.DESCENDANT] = function (check, ele) { + return matches$1(check.descendant, ele) && ele.ancestors().some(function (a) { + return matches$1(check.ancestor, a); + }); +}; +match[Type.ANCESTOR] = function (check, ele) { + return matches$1(check.ancestor, ele) && ele.descendants().some(function (d) { + return matches$1(check.descendant, d); + }); +}; +match[Type.COMPOUND_SPLIT] = function (check, ele) { + return matches$1(check.subject, ele) && matches$1(check.left, ele) && matches$1(check.right, ele); +}; +match[Type.TRUE] = function () { + return true; +}; +match[Type.COLLECTION] = function (check, ele) { + var collection = check.value; + return collection.has(ele); +}; +match[Type.FILTER] = function (check, ele) { + var filter = check.value; + return filter(ele); +}; + +// filter an existing collection +var filter = function filter(collection) { + var self = this; + + // for 1 id #foo queries, just get the element + if (self.length === 1 && self[0].checks.length === 1 && self[0].checks[0].type === Type.ID) { + return collection.getElementById(self[0].checks[0].value).collection(); + } + var selectorFunction = function selectorFunction(element) { + for (var j = 0; j < self.length; j++) { + var query = self[j]; + if (matches$1(query, element)) { + return true; + } + } + return false; + }; + if (self.text() == null) { + selectorFunction = function selectorFunction() { + return true; + }; + } + return collection.filter(selectorFunction); +}; // filter + +// does selector match a single element? +var matches = function matches(ele) { + var self = this; + for (var j = 0; j < self.length; j++) { + var query = self[j]; + if (matches$1(query, ele)) { + return true; + } + } + return false; +}; // matches + +var matching = { + matches: matches, + filter: filter +}; + +var Selector = function Selector(selector) { + this.inputText = selector; + this.currentSubject = null; + this.compoundCount = 0; + this.edgeCount = 0; + this.length = 0; + if (selector == null || string(selector) && selector.match(/^\s*$/)) ; else if (elementOrCollection(selector)) { + this.addQuery({ + checks: [{ + type: Type.COLLECTION, + value: selector.collection() + }] + }); + } else if (fn$6(selector)) { + this.addQuery({ + checks: [{ + type: Type.FILTER, + value: selector + }] + }); + } else if (string(selector)) { + if (!this.parse(selector)) { + this.invalid = true; + } + } else { + error('A selector must be created from a string; found '); + } +}; +var selfn = Selector.prototype; +[parse$1, matching].forEach(function (p) { + return extend(selfn, p); +}); +selfn.text = function () { + return this.inputText; +}; +selfn.size = function () { + return this.length; +}; +selfn.eq = function (i) { + return this[i]; +}; +selfn.sameText = function (otherSel) { + return !this.invalid && !otherSel.invalid && this.text() === otherSel.text(); +}; +selfn.addQuery = function (q) { + this[this.length++] = q; +}; +selfn.selector = selfn.toString; + +var elesfn$g = { + allAre: function allAre(selector) { + var selObj = new Selector(selector); + return this.every(function (ele) { + return selObj.matches(ele); + }); + }, + is: function is(selector) { + var selObj = new Selector(selector); + return this.some(function (ele) { + return selObj.matches(ele); + }); + }, + some: function some(fn, thisArg) { + for (var i = 0; i < this.length; i++) { + var ret = !thisArg ? fn(this[i], i, this) : fn.apply(thisArg, [this[i], i, this]); + if (ret) { + return true; + } + } + return false; + }, + every: function every(fn, thisArg) { + for (var i = 0; i < this.length; i++) { + var ret = !thisArg ? fn(this[i], i, this) : fn.apply(thisArg, [this[i], i, this]); + if (!ret) { + return false; + } + } + return true; + }, + same: function same(collection) { + // cheap collection ref check + if (this === collection) { + return true; + } + collection = this.cy().collection(collection); + var thisLength = this.length; + var collectionLength = collection.length; + + // cheap length check + if (thisLength !== collectionLength) { + return false; + } + + // cheap element ref check + if (thisLength === 1) { + return this[0] === collection[0]; + } + return this.every(function (ele) { + return collection.hasElementWithId(ele.id()); + }); + }, + anySame: function anySame(collection) { + collection = this.cy().collection(collection); + return this.some(function (ele) { + return collection.hasElementWithId(ele.id()); + }); + }, + allAreNeighbors: function allAreNeighbors(collection) { + collection = this.cy().collection(collection); + var nhood = this.neighborhood(); + return collection.every(function (ele) { + return nhood.hasElementWithId(ele.id()); + }); + }, + contains: function contains(collection) { + collection = this.cy().collection(collection); + var self = this; + return collection.every(function (ele) { + return self.hasElementWithId(ele.id()); + }); + } +}; +elesfn$g.allAreNeighbours = elesfn$g.allAreNeighbors; +elesfn$g.has = elesfn$g.contains; +elesfn$g.equal = elesfn$g.equals = elesfn$g.same; + +var cache = function cache(fn, name) { + return function traversalCache(arg1, arg2, arg3, arg4) { + var selectorOrEles = arg1; + var eles = this; + var key; + if (selectorOrEles == null) { + key = ''; + } else if (elementOrCollection(selectorOrEles) && selectorOrEles.length === 1) { + key = selectorOrEles.id(); + } + if (eles.length === 1 && key) { + var _p = eles[0]._private; + var tch = _p.traversalCache = _p.traversalCache || {}; + var ch = tch[name] = tch[name] || []; + var hash = hashString(key); + var cacheHit = ch[hash]; + if (cacheHit) { + return cacheHit; + } else { + return ch[hash] = fn.call(eles, arg1, arg2, arg3, arg4); + } + } else { + return fn.call(eles, arg1, arg2, arg3, arg4); + } + }; +}; + +var elesfn$f = { + parent: function parent(selector) { + var parents = []; + + // optimisation for single ele call + if (this.length === 1) { + var parent = this[0]._private.parent; + if (parent) { + return parent; + } + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _parent = ele._private.parent; + if (_parent) { + parents.push(_parent); + } + } + return this.spawn(parents, true).filter(selector); + }, + parents: function parents(selector) { + var parents = []; + var eles = this.parent(); + while (eles.nonempty()) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + parents.push(ele); + } + eles = eles.parent(); + } + return this.spawn(parents, true).filter(selector); + }, + commonAncestors: function commonAncestors(selector) { + var ancestors; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var parents = ele.parents(); + ancestors = ancestors || parents; + ancestors = ancestors.intersect(parents); // current list must be common with current ele parents set + } + + return ancestors.filter(selector); + }, + orphans: function orphans(selector) { + return this.stdFilter(function (ele) { + return ele.isOrphan(); + }).filter(selector); + }, + nonorphans: function nonorphans(selector) { + return this.stdFilter(function (ele) { + return ele.isChild(); + }).filter(selector); + }, + children: cache(function (selector) { + var children = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var eleChildren = ele._private.children; + for (var j = 0; j < eleChildren.length; j++) { + children.push(eleChildren[j]); + } + } + return this.spawn(children, true).filter(selector); + }, 'children'), + siblings: function siblings(selector) { + return this.parent().children().not(this).filter(selector); + }, + isParent: function isParent() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.children.length !== 0; + } + }, + isChildless: function isChildless() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.children.length === 0; + } + }, + isChild: function isChild() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.parent != null; + } + }, + isOrphan: function isOrphan() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.parent == null; + } + }, + descendants: function descendants(selector) { + var elements = []; + function add(eles) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + elements.push(ele); + if (ele.children().nonempty()) { + add(ele.children()); + } + } + } + add(this.children()); + return this.spawn(elements, true).filter(selector); + } +}; +function forEachCompound(eles, fn, includeSelf, recursiveStep) { + var q = []; + var did = new Set$1(); + var cy = eles.cy(); + var hasCompounds = cy.hasCompoundNodes(); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (includeSelf) { + q.push(ele); + } else if (hasCompounds) { + recursiveStep(q, did, ele); + } + } + while (q.length > 0) { + var _ele = q.shift(); + fn(_ele); + did.add(_ele.id()); + if (hasCompounds) { + recursiveStep(q, did, _ele); + } + } + return eles; +} +function addChildren(q, did, ele) { + if (ele.isParent()) { + var children = ele._private.children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (!did.has(child.id())) { + q.push(child); + } + } + } +} + +// very efficient version of eles.add( eles.descendants() ).forEach() +// for internal use +elesfn$f.forEachDown = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addChildren); +}; +function addParent(q, did, ele) { + if (ele.isChild()) { + var parent = ele._private.parent; + if (!did.has(parent.id())) { + q.push(parent); + } + } +} +elesfn$f.forEachUp = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addParent); +}; +function addParentAndChildren(q, did, ele) { + addParent(q, did, ele); + addChildren(q, did, ele); +} +elesfn$f.forEachUpAndDown = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addParentAndChildren); +}; + +// aliases +elesfn$f.ancestors = elesfn$f.parents; + +var fn$5, elesfn$e; +fn$5 = elesfn$e = { + data: define.data({ + field: 'data', + bindingEvent: 'data', + allowBinding: true, + allowSetting: true, + settingEvent: 'data', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + immutableKeys: { + 'id': true, + 'source': true, + 'target': true, + 'parent': true + }, + updateStyle: true + }), + removeData: define.removeData({ + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: true, + immutableKeys: { + 'id': true, + 'source': true, + 'target': true, + 'parent': true + }, + updateStyle: true + }), + scratch: define.data({ + field: 'scratch', + bindingEvent: 'scratch', + allowBinding: true, + allowSetting: true, + settingEvent: 'scratch', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeScratch: define.removeData({ + field: 'scratch', + event: 'scratch', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }), + rscratch: define.data({ + field: 'rscratch', + allowBinding: false, + allowSetting: true, + settingTriggersEvent: false, + allowGetting: true + }), + removeRscratch: define.removeData({ + field: 'rscratch', + triggerEvent: false + }), + id: function id() { + var ele = this[0]; + if (ele) { + return ele._private.data.id; + } + } +}; + +// aliases +fn$5.attr = fn$5.data; +fn$5.removeAttr = fn$5.removeData; +var data = elesfn$e; + +var elesfn$d = {}; +function defineDegreeFunction(callback) { + return function (includeLoops) { + var self = this; + if (includeLoops === undefined) { + includeLoops = true; + } + if (self.length === 0) { + return; + } + if (self.isNode() && !self.removed()) { + var degree = 0; + var node = self[0]; + var connectedEdges = node._private.edges; + for (var i = 0; i < connectedEdges.length; i++) { + var edge = connectedEdges[i]; + if (!includeLoops && edge.isLoop()) { + continue; + } + degree += callback(node, edge); + } + return degree; + } else { + return; + } + }; +} +extend(elesfn$d, { + degree: defineDegreeFunction(function (node, edge) { + if (edge.source().same(edge.target())) { + return 2; + } else { + return 1; + } + }), + indegree: defineDegreeFunction(function (node, edge) { + if (edge.target().same(node)) { + return 1; + } else { + return 0; + } + }), + outdegree: defineDegreeFunction(function (node, edge) { + if (edge.source().same(node)) { + return 1; + } else { + return 0; + } + }) +}); +function defineDegreeBoundsFunction(degreeFn, callback) { + return function (includeLoops) { + var ret; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + var ele = nodes[i]; + var degree = ele[degreeFn](includeLoops); + if (degree !== undefined && (ret === undefined || callback(degree, ret))) { + ret = degree; + } + } + return ret; + }; +} +extend(elesfn$d, { + minDegree: defineDegreeBoundsFunction('degree', function (degree, min) { + return degree < min; + }), + maxDegree: defineDegreeBoundsFunction('degree', function (degree, max) { + return degree > max; + }), + minIndegree: defineDegreeBoundsFunction('indegree', function (degree, min) { + return degree < min; + }), + maxIndegree: defineDegreeBoundsFunction('indegree', function (degree, max) { + return degree > max; + }), + minOutdegree: defineDegreeBoundsFunction('outdegree', function (degree, min) { + return degree < min; + }), + maxOutdegree: defineDegreeBoundsFunction('outdegree', function (degree, max) { + return degree > max; + }) +}); +extend(elesfn$d, { + totalDegree: function totalDegree(includeLoops) { + var total = 0; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + total += nodes[i].degree(includeLoops); + } + return total; + } +}); + +var fn$4, elesfn$c; +var beforePositionSet = function beforePositionSet(eles, newPos, silent) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.locked()) { + var oldPos = ele._private.position; + var delta = { + x: newPos.x != null ? newPos.x - oldPos.x : 0, + y: newPos.y != null ? newPos.y - oldPos.y : 0 + }; + if (ele.isParent() && !(delta.x === 0 && delta.y === 0)) { + ele.children().shift(delta, silent); + } + ele.dirtyBoundingBoxCache(); + } + } +}; +var positionDef = { + field: 'position', + bindingEvent: 'position', + allowBinding: true, + allowSetting: true, + settingEvent: 'position', + settingTriggersEvent: true, + triggerFnName: 'emitAndNotify', + allowGetting: true, + validKeys: ['x', 'y'], + beforeGet: function beforeGet(ele) { + ele.updateCompoundBounds(); + }, + beforeSet: function beforeSet(eles, newPos) { + beforePositionSet(eles, newPos, false); + }, + onSet: function onSet(eles) { + eles.dirtyCompoundBoundsCache(); + }, + canSet: function canSet(ele) { + return !ele.locked(); + } +}; +fn$4 = elesfn$c = { + position: define.data(positionDef), + // position but no notification to renderer + silentPosition: define.data(extend({}, positionDef, { + allowBinding: false, + allowSetting: true, + settingTriggersEvent: false, + allowGetting: false, + beforeSet: function beforeSet(eles, newPos) { + beforePositionSet(eles, newPos, true); + }, + onSet: function onSet(eles) { + eles.dirtyCompoundBoundsCache(); + } + })), + positions: function positions(pos, silent) { + if (plainObject(pos)) { + if (silent) { + this.silentPosition(pos); + } else { + this.position(pos); + } + } else if (fn$6(pos)) { + var _fn = pos; + var cy = this.cy(); + cy.startBatch(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _pos = void 0; + if (_pos = _fn(ele, i)) { + if (silent) { + ele.silentPosition(_pos); + } else { + ele.position(_pos); + } + } + } + cy.endBatch(); + } + return this; // chaining + }, + + silentPositions: function silentPositions(pos) { + return this.positions(pos, true); + }, + shift: function shift(dim, val, silent) { + var delta; + if (plainObject(dim)) { + delta = { + x: number$1(dim.x) ? dim.x : 0, + y: number$1(dim.y) ? dim.y : 0 + }; + silent = val; + } else if (string(dim) && number$1(val)) { + delta = { + x: 0, + y: 0 + }; + delta[dim] = val; + } + if (delta != null) { + var cy = this.cy(); + cy.startBatch(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + + // exclude any node that is a descendant of the calling collection + if (cy.hasCompoundNodes() && ele.isChild() && ele.ancestors().anySame(this)) { + continue; + } + var pos = ele.position(); + var newPos = { + x: pos.x + delta.x, + y: pos.y + delta.y + }; + if (silent) { + ele.silentPosition(newPos); + } else { + ele.position(newPos); + } + } + cy.endBatch(); + } + return this; + }, + silentShift: function silentShift(dim, val) { + if (plainObject(dim)) { + this.shift(dim, true); + } else if (string(dim) && number$1(val)) { + this.shift(dim, val, true); + } + return this; + }, + // get/set the rendered (i.e. on screen) positon of the element + renderedPosition: function renderedPosition(dim, val) { + var ele = this[0]; + var cy = this.cy(); + var zoom = cy.zoom(); + var pan = cy.pan(); + var rpos = plainObject(dim) ? dim : undefined; + var setting = rpos !== undefined || val !== undefined && string(dim); + if (ele && ele.isNode()) { + // must have an element and must be a node to return position + if (setting) { + for (var i = 0; i < this.length; i++) { + var _ele = this[i]; + if (val !== undefined) { + // set one dimension + _ele.position(dim, (val - pan[dim]) / zoom); + } else if (rpos !== undefined) { + // set whole position + _ele.position(renderedToModelPosition(rpos, zoom, pan)); + } + } + } else { + // getting + var pos = ele.position(); + rpos = modelToRenderedPosition(pos, zoom, pan); + if (dim === undefined) { + // then return the whole rendered position + return rpos; + } else { + // then return the specified dimension + return rpos[dim]; + } + } + } else if (!setting) { + return undefined; // for empty collection case + } + + return this; // chaining + }, + + // get/set the position relative to the parent + relativePosition: function relativePosition(dim, val) { + var ele = this[0]; + var cy = this.cy(); + var ppos = plainObject(dim) ? dim : undefined; + var setting = ppos !== undefined || val !== undefined && string(dim); + var hasCompoundNodes = cy.hasCompoundNodes(); + if (ele && ele.isNode()) { + // must have an element and must be a node to return position + if (setting) { + for (var i = 0; i < this.length; i++) { + var _ele2 = this[i]; + var parent = hasCompoundNodes ? _ele2.parent() : null; + var hasParent = parent && parent.length > 0; + var relativeToParent = hasParent; + if (hasParent) { + parent = parent[0]; + } + var origin = relativeToParent ? parent.position() : { + x: 0, + y: 0 + }; + if (val !== undefined) { + // set one dimension + _ele2.position(dim, val + origin[dim]); + } else if (ppos !== undefined) { + // set whole position + _ele2.position({ + x: ppos.x + origin.x, + y: ppos.y + origin.y + }); + } + } + } else { + // getting + var pos = ele.position(); + var _parent = hasCompoundNodes ? ele.parent() : null; + var _hasParent = _parent && _parent.length > 0; + var _relativeToParent = _hasParent; + if (_hasParent) { + _parent = _parent[0]; + } + var _origin = _relativeToParent ? _parent.position() : { + x: 0, + y: 0 + }; + ppos = { + x: pos.x - _origin.x, + y: pos.y - _origin.y + }; + if (dim === undefined) { + // then return the whole rendered position + return ppos; + } else { + // then return the specified dimension + return ppos[dim]; + } + } + } else if (!setting) { + return undefined; // for empty collection case + } + + return this; // chaining + } +}; + +// aliases +fn$4.modelPosition = fn$4.point = fn$4.position; +fn$4.modelPositions = fn$4.points = fn$4.positions; +fn$4.renderedPoint = fn$4.renderedPosition; +fn$4.relativePoint = fn$4.relativePosition; +var position = elesfn$c; + +var fn$3, elesfn$b; +fn$3 = elesfn$b = {}; +elesfn$b.renderedBoundingBox = function (options) { + var bb = this.boundingBox(options); + var cy = this.cy(); + var zoom = cy.zoom(); + var pan = cy.pan(); + var x1 = bb.x1 * zoom + pan.x; + var x2 = bb.x2 * zoom + pan.x; + var y1 = bb.y1 * zoom + pan.y; + var y2 = bb.y2 * zoom + pan.y; + return { + x1: x1, + x2: x2, + y1: y1, + y2: y2, + w: x2 - x1, + h: y2 - y1 + }; +}; +elesfn$b.dirtyCompoundBoundsCache = function () { + var silent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var cy = this.cy(); + if (!cy.styleEnabled() || !cy.hasCompoundNodes()) { + return this; + } + this.forEachUp(function (ele) { + if (ele.isParent()) { + var _p = ele._private; + _p.compoundBoundsClean = false; + _p.bbCache = null; + if (!silent) { + ele.emitAndNotify('bounds'); + } + } + }); + return this; +}; +elesfn$b.updateCompoundBounds = function () { + var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var cy = this.cy(); + + // not possible to do on non-compound graphs or with the style disabled + if (!cy.styleEnabled() || !cy.hasCompoundNodes()) { + return this; + } + + // save cycles when batching -- but bounds will be stale (or not exist yet) + if (!force && cy.batching()) { + return this; + } + function update(parent) { + if (!parent.isParent()) { + return; + } + var _p = parent._private; + var children = parent.children(); + var includeLabels = parent.pstyle('compound-sizing-wrt-labels').value === 'include'; + var min = { + width: { + val: parent.pstyle('min-width').pfValue, + left: parent.pstyle('min-width-bias-left'), + right: parent.pstyle('min-width-bias-right') + }, + height: { + val: parent.pstyle('min-height').pfValue, + top: parent.pstyle('min-height-bias-top'), + bottom: parent.pstyle('min-height-bias-bottom') + } + }; + var bb = children.boundingBox({ + includeLabels: includeLabels, + includeOverlays: false, + // updating the compound bounds happens outside of the regular + // cache cycle (i.e. before fired events) + useCache: false + }); + var pos = _p.position; + + // if children take up zero area then keep position and fall back on stylesheet w/h + if (bb.w === 0 || bb.h === 0) { + bb = { + w: parent.pstyle('width').pfValue, + h: parent.pstyle('height').pfValue + }; + bb.x1 = pos.x - bb.w / 2; + bb.x2 = pos.x + bb.w / 2; + bb.y1 = pos.y - bb.h / 2; + bb.y2 = pos.y + bb.h / 2; + } + function computeBiasValues(propDiff, propBias, propBiasComplement) { + var biasDiff = 0; + var biasComplementDiff = 0; + var biasTotal = propBias + propBiasComplement; + if (propDiff > 0 && biasTotal > 0) { + biasDiff = propBias / biasTotal * propDiff; + biasComplementDiff = propBiasComplement / biasTotal * propDiff; + } + return { + biasDiff: biasDiff, + biasComplementDiff: biasComplementDiff + }; + } + function computePaddingValues(width, height, paddingObject, relativeTo) { + // Assuming percentage is number from 0 to 1 + if (paddingObject.units === '%') { + switch (relativeTo) { + case 'width': + return width > 0 ? paddingObject.pfValue * width : 0; + case 'height': + return height > 0 ? paddingObject.pfValue * height : 0; + case 'average': + return width > 0 && height > 0 ? paddingObject.pfValue * (width + height) / 2 : 0; + case 'min': + return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * height : paddingObject.pfValue * width : 0; + case 'max': + return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * width : paddingObject.pfValue * height : 0; + default: + return 0; + } + } else if (paddingObject.units === 'px') { + return paddingObject.pfValue; + } else { + return 0; + } + } + var leftVal = min.width.left.value; + if (min.width.left.units === 'px' && min.width.val > 0) { + leftVal = leftVal * 100 / min.width.val; + } + var rightVal = min.width.right.value; + if (min.width.right.units === 'px' && min.width.val > 0) { + rightVal = rightVal * 100 / min.width.val; + } + var topVal = min.height.top.value; + if (min.height.top.units === 'px' && min.height.val > 0) { + topVal = topVal * 100 / min.height.val; + } + var bottomVal = min.height.bottom.value; + if (min.height.bottom.units === 'px' && min.height.val > 0) { + bottomVal = bottomVal * 100 / min.height.val; + } + var widthBiasDiffs = computeBiasValues(min.width.val - bb.w, leftVal, rightVal); + var diffLeft = widthBiasDiffs.biasDiff; + var diffRight = widthBiasDiffs.biasComplementDiff; + var heightBiasDiffs = computeBiasValues(min.height.val - bb.h, topVal, bottomVal); + var diffTop = heightBiasDiffs.biasDiff; + var diffBottom = heightBiasDiffs.biasComplementDiff; + _p.autoPadding = computePaddingValues(bb.w, bb.h, parent.pstyle('padding'), parent.pstyle('padding-relative-to').value); + _p.autoWidth = Math.max(bb.w, min.width.val); + pos.x = (-diffLeft + bb.x1 + bb.x2 + diffRight) / 2; + _p.autoHeight = Math.max(bb.h, min.height.val); + pos.y = (-diffTop + bb.y1 + bb.y2 + diffBottom) / 2; + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _p = ele._private; + if (!_p.compoundBoundsClean || force) { + update(ele); + if (!cy.batching()) { + _p.compoundBoundsClean = true; + } + } + } + return this; +}; +var noninf = function noninf(x) { + if (x === Infinity || x === -Infinity) { + return 0; + } + return x; +}; +var updateBounds = function updateBounds(b, x1, y1, x2, y2) { + // don't update with zero area boxes + if (x2 - x1 === 0 || y2 - y1 === 0) { + return; + } + + // don't update with null dim + if (x1 == null || y1 == null || x2 == null || y2 == null) { + return; + } + b.x1 = x1 < b.x1 ? x1 : b.x1; + b.x2 = x2 > b.x2 ? x2 : b.x2; + b.y1 = y1 < b.y1 ? y1 : b.y1; + b.y2 = y2 > b.y2 ? y2 : b.y2; + b.w = b.x2 - b.x1; + b.h = b.y2 - b.y1; +}; +var updateBoundsFromBox = function updateBoundsFromBox(b, b2) { + if (b2 == null) { + return b; + } + return updateBounds(b, b2.x1, b2.y1, b2.x2, b2.y2); +}; +var prefixedProperty = function prefixedProperty(obj, field, prefix) { + return getPrefixedProperty(obj, field, prefix); +}; +var updateBoundsFromArrow = function updateBoundsFromArrow(bounds, ele, prefix) { + if (ele.cy().headless()) { + return; + } + var _p = ele._private; + var rstyle = _p.rstyle; + var halfArW = rstyle.arrowWidth / 2; + var arrowType = ele.pstyle(prefix + '-arrow-shape').value; + var x; + var y; + if (arrowType !== 'none') { + if (prefix === 'source') { + x = rstyle.srcX; + y = rstyle.srcY; + } else if (prefix === 'target') { + x = rstyle.tgtX; + y = rstyle.tgtY; + } else { + x = rstyle.midX; + y = rstyle.midY; + } + + // always store the individual arrow bounds + var bbs = _p.arrowBounds = _p.arrowBounds || {}; + var bb = bbs[prefix] = bbs[prefix] || {}; + bb.x1 = x - halfArW; + bb.y1 = y - halfArW; + bb.x2 = x + halfArW; + bb.y2 = y + halfArW; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + expandBoundingBox(bb, 1); + updateBounds(bounds, bb.x1, bb.y1, bb.x2, bb.y2); + } +}; +var updateBoundsFromLabel = function updateBoundsFromLabel(bounds, ele, prefix) { + if (ele.cy().headless()) { + return; + } + var prefixDash; + if (prefix) { + prefixDash = prefix + '-'; + } else { + prefixDash = ''; + } + var _p = ele._private; + var rstyle = _p.rstyle; + var label = ele.pstyle(prefixDash + 'label').strValue; + if (label) { + var halign = ele.pstyle('text-halign'); + var valign = ele.pstyle('text-valign'); + var labelWidth = prefixedProperty(rstyle, 'labelWidth', prefix); + var labelHeight = prefixedProperty(rstyle, 'labelHeight', prefix); + var labelX = prefixedProperty(rstyle, 'labelX', prefix); + var labelY = prefixedProperty(rstyle, 'labelY', prefix); + var marginX = ele.pstyle(prefixDash + 'text-margin-x').pfValue; + var marginY = ele.pstyle(prefixDash + 'text-margin-y').pfValue; + var isEdge = ele.isEdge(); + var rotation = ele.pstyle(prefixDash + 'text-rotation'); + var outlineWidth = ele.pstyle('text-outline-width').pfValue; + var borderWidth = ele.pstyle('text-border-width').pfValue; + var halfBorderWidth = borderWidth / 2; + var padding = ele.pstyle('text-background-padding').pfValue; + var marginOfError = 2; // expand to work around browser dimension inaccuracies + + var lh = labelHeight; + var lw = labelWidth; + var lw_2 = lw / 2; + var lh_2 = lh / 2; + var lx1, lx2, ly1, ly2; + if (isEdge) { + lx1 = labelX - lw_2; + lx2 = labelX + lw_2; + ly1 = labelY - lh_2; + ly2 = labelY + lh_2; + } else { + switch (halign.value) { + case 'left': + lx1 = labelX - lw; + lx2 = labelX; + break; + case 'center': + lx1 = labelX - lw_2; + lx2 = labelX + lw_2; + break; + case 'right': + lx1 = labelX; + lx2 = labelX + lw; + break; + } + switch (valign.value) { + case 'top': + ly1 = labelY - lh; + ly2 = labelY; + break; + case 'center': + ly1 = labelY - lh_2; + ly2 = labelY + lh_2; + break; + case 'bottom': + ly1 = labelY; + ly2 = labelY + lh; + break; + } + } + + // shift by margin and expand by outline and border + lx1 += marginX - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; + lx2 += marginX + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; + ly1 += marginY - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; + ly2 += marginY + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; + + // always store the unrotated label bounds separately + var bbPrefix = prefix || 'main'; + var bbs = _p.labelBounds; + var bb = bbs[bbPrefix] = bbs[bbPrefix] || {}; + bb.x1 = lx1; + bb.y1 = ly1; + bb.x2 = lx2; + bb.y2 = ly2; + bb.w = lx2 - lx1; + bb.h = ly2 - ly1; + var isAutorotate = isEdge && rotation.strValue === 'autorotate'; + var isPfValue = rotation.pfValue != null && rotation.pfValue !== 0; + if (isAutorotate || isPfValue) { + var theta = isAutorotate ? prefixedProperty(_p.rstyle, 'labelAngle', prefix) : rotation.pfValue; + var cos = Math.cos(theta); + var sin = Math.sin(theta); + + // rotation point (default value for center-center) + var xo = (lx1 + lx2) / 2; + var yo = (ly1 + ly2) / 2; + if (!isEdge) { + switch (halign.value) { + case 'left': + xo = lx2; + break; + case 'right': + xo = lx1; + break; + } + switch (valign.value) { + case 'top': + yo = ly2; + break; + case 'bottom': + yo = ly1; + break; + } + } + var rotate = function rotate(x, y) { + x = x - xo; + y = y - yo; + return { + x: x * cos - y * sin + xo, + y: x * sin + y * cos + yo + }; + }; + var px1y1 = rotate(lx1, ly1); + var px1y2 = rotate(lx1, ly2); + var px2y1 = rotate(lx2, ly1); + var px2y2 = rotate(lx2, ly2); + lx1 = Math.min(px1y1.x, px1y2.x, px2y1.x, px2y2.x); + lx2 = Math.max(px1y1.x, px1y2.x, px2y1.x, px2y2.x); + ly1 = Math.min(px1y1.y, px1y2.y, px2y1.y, px2y2.y); + ly2 = Math.max(px1y1.y, px1y2.y, px2y1.y, px2y2.y); + } + var bbPrefixRot = bbPrefix + 'Rot'; + var bbRot = bbs[bbPrefixRot] = bbs[bbPrefixRot] || {}; + bbRot.x1 = lx1; + bbRot.y1 = ly1; + bbRot.x2 = lx2; + bbRot.y2 = ly2; + bbRot.w = lx2 - lx1; + bbRot.h = ly2 - ly1; + updateBounds(bounds, lx1, ly1, lx2, ly2); + updateBounds(_p.labelBounds.all, lx1, ly1, lx2, ly2); + } + return bounds; +}; +var updateBoundsFromOutline = function updateBoundsFromOutline(bounds, ele) { + if (ele.cy().headless()) { + return; + } + var outlineOpacity = ele.pstyle('outline-opacity').value; + var outlineWidth = ele.pstyle('outline-width').value; + if (outlineOpacity > 0 && outlineWidth > 0) { + var outlineOffset = ele.pstyle('outline-offset').value; + var nodeShape = ele.pstyle('shape').value; + var outlineSize = outlineWidth + outlineOffset; + var scaleX = (bounds.w + outlineSize * 2) / bounds.w; + var scaleY = (bounds.h + outlineSize * 2) / bounds.h; + var xOffset = 0; + var yOffset = 0; + if (["diamond", "pentagon", "round-triangle"].includes(nodeShape)) { + scaleX = (bounds.w + outlineSize * 2.4) / bounds.w; + yOffset = -outlineSize / 3.6; + } else if (["concave-hexagon", "rhomboid", "right-rhomboid"].includes(nodeShape)) { + scaleX = (bounds.w + outlineSize * 2.4) / bounds.w; + } else if (nodeShape === "star") { + scaleX = (bounds.w + outlineSize * 2.8) / bounds.w; + scaleY = (bounds.h + outlineSize * 2.6) / bounds.h; + yOffset = -outlineSize / 3.8; + } else if (nodeShape === "triangle") { + scaleX = (bounds.w + outlineSize * 2.8) / bounds.w; + scaleY = (bounds.h + outlineSize * 2.4) / bounds.h; + yOffset = -outlineSize / 1.4; + } else if (nodeShape === "vee") { + scaleX = (bounds.w + outlineSize * 4.4) / bounds.w; + scaleY = (bounds.h + outlineSize * 3.8) / bounds.h; + yOffset = -outlineSize * .5; + } + var hDelta = bounds.h * scaleY - bounds.h; + var wDelta = bounds.w * scaleX - bounds.w; + expandBoundingBoxSides(bounds, [Math.ceil(hDelta / 2), Math.ceil(wDelta / 2)]); + if (xOffset != 0 || yOffset !== 0) { + var oBounds = shiftBoundingBox(bounds, xOffset, yOffset); + updateBoundingBox(bounds, oBounds); + } + } +}; + +// get the bounding box of the elements (in raw model position) +var boundingBoxImpl = function boundingBoxImpl(ele, options) { + var cy = ele._private.cy; + var styleEnabled = cy.styleEnabled(); + var headless = cy.headless(); + var bounds = makeBoundingBox(); + var _p = ele._private; + var isNode = ele.isNode(); + var isEdge = ele.isEdge(); + var ex1, ex2, ey1, ey2; // extrema of body / lines + var x, y; // node pos + var rstyle = _p.rstyle; + var manualExpansion = isNode && styleEnabled ? ele.pstyle('bounds-expansion').pfValue : [0]; + + // must use `display` prop only, as reading `compound.width()` causes recursion + // (other factors like width values will be considered later in this function anyway) + var isDisplayed = function isDisplayed(ele) { + return ele.pstyle('display').value !== 'none'; + }; + var displayed = !styleEnabled || isDisplayed(ele) + + // must take into account connected nodes b/c of implicit edge hiding on display:none node + && (!isEdge || isDisplayed(ele.source()) && isDisplayed(ele.target())); + if (displayed) { + // displayed suffices, since we will find zero area eles anyway + var overlayOpacity = 0; + var overlayPadding = 0; + if (styleEnabled && options.includeOverlays) { + overlayOpacity = ele.pstyle('overlay-opacity').value; + if (overlayOpacity !== 0) { + overlayPadding = ele.pstyle('overlay-padding').value; + } + } + var underlayOpacity = 0; + var underlayPadding = 0; + if (styleEnabled && options.includeUnderlays) { + underlayOpacity = ele.pstyle('underlay-opacity').value; + if (underlayOpacity !== 0) { + underlayPadding = ele.pstyle('underlay-padding').value; + } + } + var padding = Math.max(overlayPadding, underlayPadding); + var w = 0; + var wHalf = 0; + if (styleEnabled) { + w = ele.pstyle('width').pfValue; + wHalf = w / 2; + } + if (isNode && options.includeNodes) { + var pos = ele.position(); + x = pos.x; + y = pos.y; + var _w = ele.outerWidth(); + var halfW = _w / 2; + var h = ele.outerHeight(); + var halfH = h / 2; + + // handle node dimensions + ///////////////////////// + + ex1 = x - halfW; + ex2 = x + halfW; + ey1 = y - halfH; + ey2 = y + halfH; + updateBounds(bounds, ex1, ey1, ex2, ey2); + if (styleEnabled && options.includeOutlines) { + updateBoundsFromOutline(bounds, ele); + } + } else if (isEdge && options.includeEdges) { + if (styleEnabled && !headless) { + var curveStyle = ele.pstyle('curve-style').strValue; + + // handle edge dimensions (rough box estimate) + ////////////////////////////////////////////// + + ex1 = Math.min(rstyle.srcX, rstyle.midX, rstyle.tgtX); + ex2 = Math.max(rstyle.srcX, rstyle.midX, rstyle.tgtX); + ey1 = Math.min(rstyle.srcY, rstyle.midY, rstyle.tgtY); + ey2 = Math.max(rstyle.srcY, rstyle.midY, rstyle.tgtY); + + // take into account edge width + ex1 -= wHalf; + ex2 += wHalf; + ey1 -= wHalf; + ey2 += wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + + // precise edges + //////////////// + + if (curveStyle === 'haystack') { + var hpts = rstyle.haystackPts; + if (hpts && hpts.length === 2) { + ex1 = hpts[0].x; + ey1 = hpts[0].y; + ex2 = hpts[1].x; + ey2 = hpts[1].y; + if (ex1 > ex2) { + var temp = ex1; + ex1 = ex2; + ex2 = temp; + } + if (ey1 > ey2) { + var _temp = ey1; + ey1 = ey2; + ey2 = _temp; + } + updateBounds(bounds, ex1 - wHalf, ey1 - wHalf, ex2 + wHalf, ey2 + wHalf); + } + } else if (curveStyle === 'bezier' || curveStyle === 'unbundled-bezier' || curveStyle.endsWith('segments') || curveStyle.endsWith('taxi')) { + var pts; + switch (curveStyle) { + case 'bezier': + case 'unbundled-bezier': + pts = rstyle.bezierPts; + break; + case 'segments': + case 'taxi': + case 'round-segments': + case 'round-taxi': + pts = rstyle.linePts; + break; + } + if (pts != null) { + for (var j = 0; j < pts.length; j++) { + var pt = pts[j]; + ex1 = pt.x - wHalf; + ex2 = pt.x + wHalf; + ey1 = pt.y - wHalf; + ey2 = pt.y + wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + } + } + } // bezier-like or segment-like edge + } else { + // headless or style disabled + + // fallback on source and target positions + ////////////////////////////////////////// + + var n1 = ele.source(); + var n1pos = n1.position(); + var n2 = ele.target(); + var n2pos = n2.position(); + ex1 = n1pos.x; + ex2 = n2pos.x; + ey1 = n1pos.y; + ey2 = n2pos.y; + if (ex1 > ex2) { + var _temp2 = ex1; + ex1 = ex2; + ex2 = _temp2; + } + if (ey1 > ey2) { + var _temp3 = ey1; + ey1 = ey2; + ey2 = _temp3; + } + + // take into account edge width + ex1 -= wHalf; + ex2 += wHalf; + ey1 -= wHalf; + ey2 += wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + } // headless or style disabled + } // edges + + // handle edge arrow size + ///////////////////////// + + if (styleEnabled && options.includeEdges && isEdge) { + updateBoundsFromArrow(bounds, ele, 'mid-source'); + updateBoundsFromArrow(bounds, ele, 'mid-target'); + updateBoundsFromArrow(bounds, ele, 'source'); + updateBoundsFromArrow(bounds, ele, 'target'); + } + + // ghost + //////// + + if (styleEnabled) { + var ghost = ele.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = ele.pstyle('ghost-offset-x').pfValue; + var gy = ele.pstyle('ghost-offset-y').pfValue; + updateBounds(bounds, bounds.x1 + gx, bounds.y1 + gy, bounds.x2 + gx, bounds.y2 + gy); + } + } + + // always store the body bounds separately from the labels + var bbBody = _p.bodyBounds = _p.bodyBounds || {}; + assignBoundingBox(bbBody, bounds); + expandBoundingBoxSides(bbBody, manualExpansion); + expandBoundingBox(bbBody, 1); // expand to work around browser dimension inaccuracies + + // overlay + ////////// + + if (styleEnabled) { + ex1 = bounds.x1; + ex2 = bounds.x2; + ey1 = bounds.y1; + ey2 = bounds.y2; + updateBounds(bounds, ex1 - padding, ey1 - padding, ex2 + padding, ey2 + padding); + } + + // always store the body bounds separately from the labels + var bbOverlay = _p.overlayBounds = _p.overlayBounds || {}; + assignBoundingBox(bbOverlay, bounds); + expandBoundingBoxSides(bbOverlay, manualExpansion); + expandBoundingBox(bbOverlay, 1); // expand to work around browser dimension inaccuracies + + // handle label dimensions + ////////////////////////// + + var bbLabels = _p.labelBounds = _p.labelBounds || {}; + if (bbLabels.all != null) { + clearBoundingBox(bbLabels.all); + } else { + bbLabels.all = makeBoundingBox(); + } + if (styleEnabled && options.includeLabels) { + if (options.includeMainLabels) { + updateBoundsFromLabel(bounds, ele, null); + } + if (isEdge) { + if (options.includeSourceLabels) { + updateBoundsFromLabel(bounds, ele, 'source'); + } + if (options.includeTargetLabels) { + updateBoundsFromLabel(bounds, ele, 'target'); + } + } + } // style enabled for labels + } // if displayed + + bounds.x1 = noninf(bounds.x1); + bounds.y1 = noninf(bounds.y1); + bounds.x2 = noninf(bounds.x2); + bounds.y2 = noninf(bounds.y2); + bounds.w = noninf(bounds.x2 - bounds.x1); + bounds.h = noninf(bounds.y2 - bounds.y1); + if (bounds.w > 0 && bounds.h > 0 && displayed) { + expandBoundingBoxSides(bounds, manualExpansion); + + // expand bounds by 1 because antialiasing can increase the visual/effective size by 1 on all sides + expandBoundingBox(bounds, 1); + } + return bounds; +}; +var getKey = function getKey(opts) { + var i = 0; + var tf = function tf(val) { + return (val ? 1 : 0) << i++; + }; + var key = 0; + key += tf(opts.incudeNodes); + key += tf(opts.includeEdges); + key += tf(opts.includeLabels); + key += tf(opts.includeMainLabels); + key += tf(opts.includeSourceLabels); + key += tf(opts.includeTargetLabels); + key += tf(opts.includeOverlays); + key += tf(opts.includeOutlines); + return key; +}; +var getBoundingBoxPosKey = function getBoundingBoxPosKey(ele) { + if (ele.isEdge()) { + var p1 = ele.source().position(); + var p2 = ele.target().position(); + var r = function r(x) { + return Math.round(x); + }; + return hashIntsArray([r(p1.x), r(p1.y), r(p2.x), r(p2.y)]); + } else { + return 0; + } +}; +var cachedBoundingBoxImpl = function cachedBoundingBoxImpl(ele, opts) { + var _p = ele._private; + var bb; + var isEdge = ele.isEdge(); + var key = opts == null ? defBbOptsKey : getKey(opts); + var usingDefOpts = key === defBbOptsKey; + var currPosKey = getBoundingBoxPosKey(ele); + var isPosKeySame = _p.bbCachePosKey === currPosKey; + var useCache = opts.useCache && isPosKeySame; + var isDirty = function isDirty(ele) { + return ele._private.bbCache == null || ele._private.styleDirty; + }; + var needRecalc = !useCache || isDirty(ele) || isEdge && isDirty(ele.source()) || isDirty(ele.target()); + if (needRecalc) { + if (!isPosKeySame) { + ele.recalculateRenderedStyle(useCache); + } + bb = boundingBoxImpl(ele, defBbOpts); + _p.bbCache = bb; + _p.bbCachePosKey = currPosKey; + } else { + bb = _p.bbCache; + } + + // not using def opts => need to build up bb from combination of sub bbs + if (!usingDefOpts) { + var isNode = ele.isNode(); + bb = makeBoundingBox(); + if (opts.includeNodes && isNode || opts.includeEdges && !isNode) { + if (opts.includeOverlays) { + updateBoundsFromBox(bb, _p.overlayBounds); + } else { + updateBoundsFromBox(bb, _p.bodyBounds); + } + } + if (opts.includeLabels) { + if (opts.includeMainLabels && (!isEdge || opts.includeSourceLabels && opts.includeTargetLabels)) { + updateBoundsFromBox(bb, _p.labelBounds.all); + } else { + if (opts.includeMainLabels) { + updateBoundsFromBox(bb, _p.labelBounds.mainRot); + } + if (opts.includeSourceLabels) { + updateBoundsFromBox(bb, _p.labelBounds.sourceRot); + } + if (opts.includeTargetLabels) { + updateBoundsFromBox(bb, _p.labelBounds.targetRot); + } + } + } + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + } + return bb; +}; +var defBbOpts = { + includeNodes: true, + includeEdges: true, + includeLabels: true, + includeMainLabels: true, + includeSourceLabels: true, + includeTargetLabels: true, + includeOverlays: true, + includeUnderlays: true, + includeOutlines: true, + useCache: true +}; +var defBbOptsKey = getKey(defBbOpts); +var filledBbOpts = defaults$g(defBbOpts); +elesfn$b.boundingBox = function (options) { + var bounds; + + // the main usecase is ele.boundingBox() for a single element with no/def options + // specified s.t. the cache is used, so check for this case to make it faster by + // avoiding the overhead of the rest of the function + if (this.length === 1 && this[0]._private.bbCache != null && !this[0]._private.styleDirty && (options === undefined || options.useCache === undefined || options.useCache === true)) { + if (options === undefined) { + options = defBbOpts; + } else { + options = filledBbOpts(options); + } + bounds = cachedBoundingBoxImpl(this[0], options); + } else { + bounds = makeBoundingBox(); + options = options || defBbOpts; + var opts = filledBbOpts(options); + var eles = this; + var cy = eles.cy(); + var styleEnabled = cy.styleEnabled(); + if (styleEnabled) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var currPosKey = getBoundingBoxPosKey(ele); + var isPosKeySame = _p.bbCachePosKey === currPosKey; + var useCache = opts.useCache && isPosKeySame && !_p.styleDirty; + ele.recalculateRenderedStyle(useCache); + } + } + this.updateCompoundBounds(!options.useCache); + for (var _i = 0; _i < eles.length; _i++) { + var _ele = eles[_i]; + updateBoundsFromBox(bounds, cachedBoundingBoxImpl(_ele, opts)); + } + } + bounds.x1 = noninf(bounds.x1); + bounds.y1 = noninf(bounds.y1); + bounds.x2 = noninf(bounds.x2); + bounds.y2 = noninf(bounds.y2); + bounds.w = noninf(bounds.x2 - bounds.x1); + bounds.h = noninf(bounds.y2 - bounds.y1); + return bounds; +}; +elesfn$b.dirtyBoundingBoxCache = function () { + for (var i = 0; i < this.length; i++) { + var _p = this[i]._private; + _p.bbCache = null; + _p.bbCachePosKey = null; + _p.bodyBounds = null; + _p.overlayBounds = null; + _p.labelBounds.all = null; + _p.labelBounds.source = null; + _p.labelBounds.target = null; + _p.labelBounds.main = null; + _p.labelBounds.sourceRot = null; + _p.labelBounds.targetRot = null; + _p.labelBounds.mainRot = null; + _p.arrowBounds.source = null; + _p.arrowBounds.target = null; + _p.arrowBounds['mid-source'] = null; + _p.arrowBounds['mid-target'] = null; + } + this.emitAndNotify('bounds'); + return this; +}; + +// private helper to get bounding box for custom node positions +// - good for perf in certain cases but currently requires dirtying the rendered style +// - would be better to not modify the nodes but the nodes are read directly everywhere in the renderer... +// - try to use for only things like discrete layouts where the node position would change anyway +elesfn$b.boundingBoxAt = function (fn) { + var nodes = this.nodes(); + var cy = this.cy(); + var hasCompoundNodes = cy.hasCompoundNodes(); + var parents = cy.collection(); + if (hasCompoundNodes) { + parents = nodes.filter(function (node) { + return node.isParent(); + }); + nodes = nodes.not(parents); + } + if (plainObject(fn)) { + var obj = fn; + fn = function fn() { + return obj; + }; + } + var storeOldPos = function storeOldPos(node, i) { + return node._private.bbAtOldPos = fn(node, i); + }; + var getOldPos = function getOldPos(node) { + return node._private.bbAtOldPos; + }; + cy.startBatch(); + nodes.forEach(storeOldPos).silentPositions(fn); + if (hasCompoundNodes) { + parents.dirtyCompoundBoundsCache(); + parents.dirtyBoundingBoxCache(); + parents.updateCompoundBounds(true); // force update b/c we're inside a batch cycle + } + + var bb = copyBoundingBox(this.boundingBox({ + useCache: false + })); + nodes.silentPositions(getOldPos); + if (hasCompoundNodes) { + parents.dirtyCompoundBoundsCache(); + parents.dirtyBoundingBoxCache(); + parents.updateCompoundBounds(true); // force update b/c we're inside a batch cycle + } + + cy.endBatch(); + return bb; +}; +fn$3.boundingbox = fn$3.bb = fn$3.boundingBox; +fn$3.renderedBoundingbox = fn$3.renderedBoundingBox; +var bounds = elesfn$b; + +var fn$2, elesfn$a; +fn$2 = elesfn$a = {}; +var defineDimFns = function defineDimFns(opts) { + opts.uppercaseName = capitalize(opts.name); + opts.autoName = 'auto' + opts.uppercaseName; + opts.labelName = 'label' + opts.uppercaseName; + opts.outerName = 'outer' + opts.uppercaseName; + opts.uppercaseOuterName = capitalize(opts.outerName); + fn$2[opts.name] = function dimImpl() { + var ele = this[0]; + var _p = ele._private; + var cy = _p.cy; + var styleEnabled = cy._private.styleEnabled; + if (ele) { + if (styleEnabled) { + if (ele.isParent()) { + ele.updateCompoundBounds(); + return _p[opts.autoName] || 0; + } + var d = ele.pstyle(opts.name); + switch (d.strValue) { + case 'label': + ele.recalculateRenderedStyle(); + return _p.rstyle[opts.labelName] || 0; + default: + return d.pfValue; + } + } else { + return 1; + } + } + }; + fn$2['outer' + opts.uppercaseName] = function outerDimImpl() { + var ele = this[0]; + var _p = ele._private; + var cy = _p.cy; + var styleEnabled = cy._private.styleEnabled; + if (ele) { + if (styleEnabled) { + var dim = ele[opts.name](); + var border = ele.pstyle('border-width').pfValue; // n.b. 1/2 each side + var padding = 2 * ele.padding(); + return dim + border + padding; + } else { + return 1; + } + } + }; + fn$2['rendered' + opts.uppercaseName] = function renderedDimImpl() { + var ele = this[0]; + if (ele) { + var d = ele[opts.name](); + return d * this.cy().zoom(); + } + }; + fn$2['rendered' + opts.uppercaseOuterName] = function renderedOuterDimImpl() { + var ele = this[0]; + if (ele) { + var od = ele[opts.outerName](); + return od * this.cy().zoom(); + } + }; +}; +defineDimFns({ + name: 'width' +}); +defineDimFns({ + name: 'height' +}); +elesfn$a.padding = function () { + var ele = this[0]; + var _p = ele._private; + if (ele.isParent()) { + ele.updateCompoundBounds(); + if (_p.autoPadding !== undefined) { + return _p.autoPadding; + } else { + return ele.pstyle('padding').pfValue; + } + } else { + return ele.pstyle('padding').pfValue; + } +}; +elesfn$a.paddedHeight = function () { + var ele = this[0]; + return ele.height() + 2 * ele.padding(); +}; +elesfn$a.paddedWidth = function () { + var ele = this[0]; + return ele.width() + 2 * ele.padding(); +}; +var widthHeight = elesfn$a; + +var ifEdge = function ifEdge(ele, getValue) { + if (ele.isEdge()) { + return getValue(ele); + } +}; +var ifEdgeRenderedPosition = function ifEdgeRenderedPosition(ele, getPoint) { + if (ele.isEdge()) { + var cy = ele.cy(); + return modelToRenderedPosition(getPoint(ele), cy.zoom(), cy.pan()); + } +}; +var ifEdgeRenderedPositions = function ifEdgeRenderedPositions(ele, getPoints) { + if (ele.isEdge()) { + var cy = ele.cy(); + var pan = cy.pan(); + var zoom = cy.zoom(); + return getPoints(ele).map(function (p) { + return modelToRenderedPosition(p, zoom, pan); + }); + } +}; +var controlPoints = function controlPoints(ele) { + return ele.renderer().getControlPoints(ele); +}; +var segmentPoints = function segmentPoints(ele) { + return ele.renderer().getSegmentPoints(ele); +}; +var sourceEndpoint = function sourceEndpoint(ele) { + return ele.renderer().getSourceEndpoint(ele); +}; +var targetEndpoint = function targetEndpoint(ele) { + return ele.renderer().getTargetEndpoint(ele); +}; +var midpoint = function midpoint(ele) { + return ele.renderer().getEdgeMidpoint(ele); +}; +var pts = { + controlPoints: { + get: controlPoints, + mult: true + }, + segmentPoints: { + get: segmentPoints, + mult: true + }, + sourceEndpoint: { + get: sourceEndpoint + }, + targetEndpoint: { + get: targetEndpoint + }, + midpoint: { + get: midpoint + } +}; +var renderedName = function renderedName(name) { + return 'rendered' + name[0].toUpperCase() + name.substr(1); +}; +var edgePoints = Object.keys(pts).reduce(function (obj, name) { + var spec = pts[name]; + var rName = renderedName(name); + obj[name] = function () { + return ifEdge(this, spec.get); + }; + if (spec.mult) { + obj[rName] = function () { + return ifEdgeRenderedPositions(this, spec.get); + }; + } else { + obj[rName] = function () { + return ifEdgeRenderedPosition(this, spec.get); + }; + } + return obj; +}, {}); + +var dimensions = extend({}, position, bounds, widthHeight, edgePoints); + +/*! +Event object based on jQuery events, MIT license + +https://jquery.org/license/ +https://tldrlegal.com/license/mit-license +https://github.com/jquery/jquery/blob/master/src/event.js +*/ + +var Event = function Event(src, props) { + this.recycle(src, props); +}; +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +Event.prototype = { + instanceString: function instanceString() { + return 'event'; + }, + recycle: function recycle(src, props) { + this.isImmediatePropagationStopped = this.isPropagationStopped = this.isDefaultPrevented = returnFalse; + if (src != null && src.preventDefault) { + // Browser Event object + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented ? returnTrue : returnFalse; + } else if (src != null && src.type) { + // Plain object containing all event details + props = src; + } else { + // Event string + this.type = src; + } + + // Put explicitly provided properties onto the event object + if (props != null) { + // more efficient to manually copy fields we use + this.originalEvent = props.originalEvent; + this.type = props.type != null ? props.type : this.type; + this.cy = props.cy; + this.target = props.target; + this.position = props.position; + this.renderedPosition = props.renderedPosition; + this.namespace = props.namespace; + this.layout = props.layout; + } + if (this.cy != null && this.position != null && this.renderedPosition == null) { + // create a rendered position based on the passed position + var pos = this.position; + var zoom = this.cy.zoom(); + var pan = this.cy.pan(); + this.renderedPosition = { + x: pos.x * zoom + pan.x, + y: pos.y * zoom + pan.y + }; + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || Date.now(); + }, + preventDefault: function preventDefault() { + this.isDefaultPrevented = returnTrue; + var e = this.originalEvent; + if (!e) { + return; + } + + // if preventDefault exists run it on the original event + if (e.preventDefault) { + e.preventDefault(); + } + }, + stopPropagation: function stopPropagation() { + this.isPropagationStopped = returnTrue; + var e = this.originalEvent; + if (!e) { + return; + } + + // if stopPropagation exists run it on the original event + if (e.stopPropagation) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function stopImmediatePropagation() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +var eventRegex = /^([^.]+)(\.(?:[^.]+))?$/; // regex for matching event strings (e.g. "click.namespace") +var universalNamespace = '.*'; // matches as if no namespace specified and prevents users from unbinding accidentally + +var defaults$8 = { + qualifierCompare: function qualifierCompare(q1, q2) { + return q1 === q2; + }, + eventMatches: function eventMatches( /*context, listener, eventObj*/ + ) { + return true; + }, + addEventFields: function addEventFields( /*context, evt*/ + ) {}, + callbackContext: function callbackContext(context /*, listener, eventObj*/) { + return context; + }, + beforeEmit: function beforeEmit( /* context, listener, eventObj */ + ) {}, + afterEmit: function afterEmit( /* context, listener, eventObj */ + ) {}, + bubble: function bubble( /*context*/ + ) { + return false; + }, + parent: function parent( /*context*/ + ) { + return null; + }, + context: null +}; +var defaultsKeys = Object.keys(defaults$8); +var emptyOpts = {}; +function Emitter() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : emptyOpts; + var context = arguments.length > 1 ? arguments[1] : undefined; + // micro-optimisation vs Object.assign() -- reduces Element instantiation time + for (var i = 0; i < defaultsKeys.length; i++) { + var key = defaultsKeys[i]; + this[key] = opts[key] || defaults$8[key]; + } + this.context = context || this.context; + this.listeners = []; + this.emitting = 0; +} +var p = Emitter.prototype; +var forEachEvent = function forEachEvent(self, handler, events, qualifier, callback, conf, confOverrides) { + if (fn$6(qualifier)) { + callback = qualifier; + qualifier = null; + } + if (confOverrides) { + if (conf == null) { + conf = confOverrides; + } else { + conf = extend({}, conf, confOverrides); + } + } + var eventList = array(events) ? events : events.split(/\s+/); + for (var i = 0; i < eventList.length; i++) { + var evt = eventList[i]; + if (emptyString(evt)) { + continue; + } + var match = evt.match(eventRegex); // type[.namespace] + + if (match) { + var type = match[1]; + var namespace = match[2] ? match[2] : null; + var ret = handler(self, evt, type, namespace, qualifier, callback, conf); + if (ret === false) { + break; + } // allow exiting early + } + } +}; + +var makeEventObj = function makeEventObj(self, obj) { + self.addEventFields(self.context, obj); + return new Event(obj.type, obj); +}; +var forEachEventObj = function forEachEventObj(self, handler, events) { + if (event(events)) { + handler(self, events); + return; + } else if (plainObject(events)) { + handler(self, makeEventObj(self, events)); + return; + } + var eventList = array(events) ? events : events.split(/\s+/); + for (var i = 0; i < eventList.length; i++) { + var evt = eventList[i]; + if (emptyString(evt)) { + continue; + } + var match = evt.match(eventRegex); // type[.namespace] + + if (match) { + var type = match[1]; + var namespace = match[2] ? match[2] : null; + var eventObj = makeEventObj(self, { + type: type, + namespace: namespace, + target: self.context + }); + handler(self, eventObj); + } + } +}; +p.on = p.addListener = function (events, qualifier, callback, conf, confOverrides) { + forEachEvent(this, function (self, event, type, namespace, qualifier, callback, conf) { + if (fn$6(callback)) { + self.listeners.push({ + event: event, + // full event string + callback: callback, + // callback to run + type: type, + // the event type (e.g. 'click') + namespace: namespace, + // the event namespace (e.g. ".foo") + qualifier: qualifier, + // a restriction on whether to match this emitter + conf: conf // additional configuration + }); + } + }, events, qualifier, callback, conf, confOverrides); + return this; +}; +p.one = function (events, qualifier, callback, conf) { + return this.on(events, qualifier, callback, conf, { + one: true + }); +}; +p.removeListener = p.off = function (events, qualifier, callback, conf) { + var _this = this; + if (this.emitting !== 0) { + this.listeners = copyArray$1(this.listeners); + } + var listeners = this.listeners; + var _loop = function _loop(i) { + var listener = listeners[i]; + forEachEvent(_this, function (self, event, type, namespace, qualifier, callback /*, conf*/) { + if ((listener.type === type || events === '*') && (!namespace && listener.namespace !== '.*' || listener.namespace === namespace) && (!qualifier || self.qualifierCompare(listener.qualifier, qualifier)) && (!callback || listener.callback === callback)) { + listeners.splice(i, 1); + return false; + } + }, events, qualifier, callback, conf); + }; + for (var i = listeners.length - 1; i >= 0; i--) { + _loop(i); + } + return this; +}; +p.removeAllListeners = function () { + return this.removeListener('*'); +}; +p.emit = p.trigger = function (events, extraParams, manualCallback) { + var listeners = this.listeners; + var numListenersBeforeEmit = listeners.length; + this.emitting++; + if (!array(extraParams)) { + extraParams = [extraParams]; + } + forEachEventObj(this, function (self, eventObj) { + if (manualCallback != null) { + listeners = [{ + event: eventObj.event, + type: eventObj.type, + namespace: eventObj.namespace, + callback: manualCallback + }]; + numListenersBeforeEmit = listeners.length; + } + var _loop2 = function _loop2(i) { + var listener = listeners[i]; + if (listener.type === eventObj.type && (!listener.namespace || listener.namespace === eventObj.namespace || listener.namespace === universalNamespace) && self.eventMatches(self.context, listener, eventObj)) { + var args = [eventObj]; + if (extraParams != null) { + push(args, extraParams); + } + self.beforeEmit(self.context, listener, eventObj); + if (listener.conf && listener.conf.one) { + self.listeners = self.listeners.filter(function (l) { + return l !== listener; + }); + } + var context = self.callbackContext(self.context, listener, eventObj); + var ret = listener.callback.apply(context, args); + self.afterEmit(self.context, listener, eventObj); + if (ret === false) { + eventObj.stopPropagation(); + eventObj.preventDefault(); + } + } // if listener matches + }; + for (var i = 0; i < numListenersBeforeEmit; i++) { + _loop2(i); + } // for listener + + if (self.bubble(self.context) && !eventObj.isPropagationStopped()) { + self.parent(self.context).emit(eventObj, extraParams); + } + }, events); + this.emitting--; + return this; +}; + +var emitterOptions$1 = { + qualifierCompare: function qualifierCompare(selector1, selector2) { + if (selector1 == null || selector2 == null) { + return selector1 == null && selector2 == null; + } else { + return selector1.sameText(selector2); + } + }, + eventMatches: function eventMatches(ele, listener, eventObj) { + var selector = listener.qualifier; + if (selector != null) { + return ele !== eventObj.target && element(eventObj.target) && selector.matches(eventObj.target); + } + return true; + }, + addEventFields: function addEventFields(ele, evt) { + evt.cy = ele.cy(); + evt.target = ele; + }, + callbackContext: function callbackContext(ele, listener, eventObj) { + return listener.qualifier != null ? eventObj.target : ele; + }, + beforeEmit: function beforeEmit(context, listener /*, eventObj*/) { + if (listener.conf && listener.conf.once) { + listener.conf.onceCollection.removeListener(listener.event, listener.qualifier, listener.callback); + } + }, + bubble: function bubble() { + return true; + }, + parent: function parent(ele) { + return ele.isChild() ? ele.parent() : ele.cy(); + } +}; +var argSelector$1 = function argSelector(arg) { + if (string(arg)) { + return new Selector(arg); + } else { + return arg; + } +}; +var elesfn$9 = { + createEmitter: function createEmitter() { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _p = ele._private; + if (!_p.emitter) { + _p.emitter = new Emitter(emitterOptions$1, ele); + } + } + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().on(events, argSel, callback); + } + return this; + }, + removeListener: function removeListener(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().removeListener(events, argSel, callback); + } + return this; + }, + removeAllListeners: function removeAllListeners() { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().removeAllListeners(); + } + return this; + }, + one: function one(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().one(events, argSel, callback); + } + return this; + }, + once: function once(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().on(events, argSel, callback, { + once: true, + onceCollection: this + }); + } + }, + emit: function emit(events, extraParams) { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().emit(events, extraParams); + } + return this; + }, + emitAndNotify: function emitAndNotify(event, extraParams) { + // for internal use only + if (this.length === 0) { + return; + } // empty collections don't need to notify anything + + // notify renderer + this.cy().notify(event, this); + this.emit(event, extraParams); + return this; + } +}; +define.eventAliasesOn(elesfn$9); + +var elesfn$8 = { + nodes: function nodes(selector) { + return this.filter(function (ele) { + return ele.isNode(); + }).filter(selector); + }, + edges: function edges(selector) { + return this.filter(function (ele) { + return ele.isEdge(); + }).filter(selector); + }, + // internal helper to get nodes and edges as separate collections with single iteration over elements + byGroup: function byGroup() { + var nodes = this.spawn(); + var edges = this.spawn(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + if (ele.isNode()) { + nodes.push(ele); + } else { + edges.push(ele); + } + } + return { + nodes: nodes, + edges: edges + }; + }, + filter: function filter(_filter, thisArg) { + if (_filter === undefined) { + // check this first b/c it's the most common/performant case + return this; + } else if (string(_filter) || elementOrCollection(_filter)) { + return new Selector(_filter).filter(this); + } else if (fn$6(_filter)) { + var filterEles = this.spawn(); + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var include = thisArg ? _filter.apply(thisArg, [ele, i, eles]) : _filter(ele, i, eles); + if (include) { + filterEles.push(ele); + } + } + return filterEles; + } + return this.spawn(); // if not handled by above, give 'em an empty collection + }, + + not: function not(toRemove) { + if (!toRemove) { + return this; + } else { + if (string(toRemove)) { + toRemove = this.filter(toRemove); + } + var elements = this.spawn(); + for (var i = 0; i < this.length; i++) { + var element = this[i]; + var remove = toRemove.has(element); + if (!remove) { + elements.push(element); + } + } + return elements; + } + }, + absoluteComplement: function absoluteComplement() { + var cy = this.cy(); + return cy.mutableElements().not(this); + }, + intersect: function intersect(other) { + // if a selector is specified, then filter by it instead + if (string(other)) { + var selector = other; + return this.filter(selector); + } + var elements = this.spawn(); + var col1 = this; + var col2 = other; + var col1Smaller = this.length < other.length; + var colS = col1Smaller ? col1 : col2; + var colL = col1Smaller ? col2 : col1; + for (var i = 0; i < colS.length; i++) { + var ele = colS[i]; + if (colL.has(ele)) { + elements.push(ele); + } + } + return elements; + }, + xor: function xor(other) { + var cy = this._private.cy; + if (string(other)) { + other = cy.$(other); + } + var elements = this.spawn(); + var col1 = this; + var col2 = other; + var add = function add(col, other) { + for (var i = 0; i < col.length; i++) { + var ele = col[i]; + var id = ele._private.data.id; + var inOther = other.hasElementWithId(id); + if (!inOther) { + elements.push(ele); + } + } + }; + add(col1, col2); + add(col2, col1); + return elements; + }, + diff: function diff(other) { + var cy = this._private.cy; + if (string(other)) { + other = cy.$(other); + } + var left = this.spawn(); + var right = this.spawn(); + var both = this.spawn(); + var col1 = this; + var col2 = other; + var add = function add(col, other, retEles) { + for (var i = 0; i < col.length; i++) { + var ele = col[i]; + var id = ele._private.data.id; + var inOther = other.hasElementWithId(id); + if (inOther) { + both.merge(ele); + } else { + retEles.push(ele); + } + } + }; + add(col1, col2, left); + add(col2, col1, right); + return { + left: left, + right: right, + both: both + }; + }, + add: function add(toAdd) { + var cy = this._private.cy; + if (!toAdd) { + return this; + } + if (string(toAdd)) { + var selector = toAdd; + toAdd = cy.mutableElements().filter(selector); + } + var elements = this.spawnSelf(); + for (var i = 0; i < toAdd.length; i++) { + var ele = toAdd[i]; + var add = !this.has(ele); + if (add) { + elements.push(ele); + } + } + return elements; + }, + // in place merge on calling collection + merge: function merge(toAdd) { + var _p = this._private; + var cy = _p.cy; + if (!toAdd) { + return this; + } + if (toAdd && string(toAdd)) { + var selector = toAdd; + toAdd = cy.mutableElements().filter(selector); + } + var map = _p.map; + for (var i = 0; i < toAdd.length; i++) { + var toAddEle = toAdd[i]; + var id = toAddEle._private.data.id; + var add = !map.has(id); + if (add) { + var index = this.length++; + this[index] = toAddEle; + map.set(id, { + ele: toAddEle, + index: index + }); + } + } + return this; // chaining + }, + + unmergeAt: function unmergeAt(i) { + var ele = this[i]; + var id = ele.id(); + var _p = this._private; + var map = _p.map; + + // remove ele + this[i] = undefined; + map["delete"](id); + var unmergedLastEle = i === this.length - 1; + + // replace empty spot with last ele in collection + if (this.length > 1 && !unmergedLastEle) { + var lastEleI = this.length - 1; + var lastEle = this[lastEleI]; + var lastEleId = lastEle._private.data.id; + this[lastEleI] = undefined; + this[i] = lastEle; + map.set(lastEleId, { + ele: lastEle, + index: i + }); + } + + // the collection is now 1 ele smaller + this.length--; + return this; + }, + // remove single ele in place in calling collection + unmergeOne: function unmergeOne(ele) { + ele = ele[0]; + var _p = this._private; + var id = ele._private.data.id; + var map = _p.map; + var entry = map.get(id); + if (!entry) { + return this; // no need to remove + } + + var i = entry.index; + this.unmergeAt(i); + return this; + }, + // remove eles in place on calling collection + unmerge: function unmerge(toRemove) { + var cy = this._private.cy; + if (!toRemove) { + return this; + } + if (toRemove && string(toRemove)) { + var selector = toRemove; + toRemove = cy.mutableElements().filter(selector); + } + for (var i = 0; i < toRemove.length; i++) { + this.unmergeOne(toRemove[i]); + } + return this; // chaining + }, + + unmergeBy: function unmergeBy(toRmFn) { + for (var i = this.length - 1; i >= 0; i--) { + var ele = this[i]; + if (toRmFn(ele)) { + this.unmergeAt(i); + } + } + return this; + }, + map: function map(mapFn, thisArg) { + var arr = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var ret = thisArg ? mapFn.apply(thisArg, [ele, i, eles]) : mapFn(ele, i, eles); + arr.push(ret); + } + return arr; + }, + reduce: function reduce(fn, initialValue) { + var val = initialValue; + var eles = this; + for (var i = 0; i < eles.length; i++) { + val = fn(val, eles[i], i, eles); + } + return val; + }, + max: function max(valFn, thisArg) { + var max = -Infinity; + var maxEle; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var val = thisArg ? valFn.apply(thisArg, [ele, i, eles]) : valFn(ele, i, eles); + if (val > max) { + max = val; + maxEle = ele; + } + } + return { + value: max, + ele: maxEle + }; + }, + min: function min(valFn, thisArg) { + var min = Infinity; + var minEle; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var val = thisArg ? valFn.apply(thisArg, [ele, i, eles]) : valFn(ele, i, eles); + if (val < min) { + min = val; + minEle = ele; + } + } + return { + value: min, + ele: minEle + }; + } +}; + +// aliases +var fn$1 = elesfn$8; +fn$1['u'] = fn$1['|'] = fn$1['+'] = fn$1.union = fn$1.or = fn$1.add; +fn$1['\\'] = fn$1['!'] = fn$1['-'] = fn$1.difference = fn$1.relativeComplement = fn$1.subtract = fn$1.not; +fn$1['n'] = fn$1['&'] = fn$1['.'] = fn$1.and = fn$1.intersection = fn$1.intersect; +fn$1['^'] = fn$1['(+)'] = fn$1['(-)'] = fn$1.symmetricDifference = fn$1.symdiff = fn$1.xor; +fn$1.fnFilter = fn$1.filterFn = fn$1.stdFilter = fn$1.filter; +fn$1.complement = fn$1.abscomp = fn$1.absoluteComplement; + +var elesfn$7 = { + isNode: function isNode() { + return this.group() === 'nodes'; + }, + isEdge: function isEdge() { + return this.group() === 'edges'; + }, + isLoop: function isLoop() { + return this.isEdge() && this.source()[0] === this.target()[0]; + }, + isSimple: function isSimple() { + return this.isEdge() && this.source()[0] !== this.target()[0]; + }, + group: function group() { + var ele = this[0]; + if (ele) { + return ele._private.group; + } + } +}; + +/** + * Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges), + * and z-index (low to high). These styles affect how this applies: + * + * z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the + * same depth as the root of the compound graph, followed by the default value `auto` which draws in order from + * root to leaves of the compound graph. The last drawn is `top`. + * z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes. + * `manual` ignores this convention and draws based on the `z-index` value setting. + * z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher + * `z-index` will be drawn on top of an element with a lower `z-index`. + */ +var zIndexSort = function zIndexSort(a, b) { + var cy = a.cy(); + var hasCompoundNodes = cy.hasCompoundNodes(); + function getDepth(ele) { + var style = ele.pstyle('z-compound-depth'); + if (style.value === 'auto') { + return hasCompoundNodes ? ele.zDepth() : 0; + } else if (style.value === 'bottom') { + return -1; + } else if (style.value === 'top') { + return MAX_INT$1; + } + // 'orphan' + return 0; + } + var depthDiff = getDepth(a) - getDepth(b); + if (depthDiff !== 0) { + return depthDiff; + } + function getEleDepth(ele) { + var style = ele.pstyle('z-index-compare'); + if (style.value === 'auto') { + return ele.isNode() ? 1 : 0; + } + // 'manual' + return 0; + } + var eleDiff = getEleDepth(a) - getEleDepth(b); + if (eleDiff !== 0) { + return eleDiff; + } + var zDiff = a.pstyle('z-index').value - b.pstyle('z-index').value; + if (zDiff !== 0) { + return zDiff; + } + // compare indices in the core (order added to graph w/ last on top) + return a.poolIndex() - b.poolIndex(); +}; + +var elesfn$6 = { + forEach: function forEach(fn, thisArg) { + if (fn$6(fn)) { + var N = this.length; + for (var i = 0; i < N; i++) { + var ele = this[i]; + var ret = thisArg ? fn.apply(thisArg, [ele, i, this]) : fn(ele, i, this); + if (ret === false) { + break; + } // exit each early on return false + } + } + + return this; + }, + toArray: function toArray() { + var array = []; + for (var i = 0; i < this.length; i++) { + array.push(this[i]); + } + return array; + }, + slice: function slice(start, end) { + var array = []; + var thisSize = this.length; + if (end == null) { + end = thisSize; + } + if (start == null) { + start = 0; + } + if (start < 0) { + start = thisSize + start; + } + if (end < 0) { + end = thisSize + end; + } + for (var i = start; i >= 0 && i < end && i < thisSize; i++) { + array.push(this[i]); + } + return this.spawn(array); + }, + size: function size() { + return this.length; + }, + eq: function eq(i) { + return this[i] || this.spawn(); + }, + first: function first() { + return this[0] || this.spawn(); + }, + last: function last() { + return this[this.length - 1] || this.spawn(); + }, + empty: function empty() { + return this.length === 0; + }, + nonempty: function nonempty() { + return !this.empty(); + }, + sort: function sort(sortFn) { + if (!fn$6(sortFn)) { + return this; + } + var sorted = this.toArray().sort(sortFn); + return this.spawn(sorted); + }, + sortByZIndex: function sortByZIndex() { + return this.sort(zIndexSort); + }, + zDepth: function zDepth() { + var ele = this[0]; + if (!ele) { + return undefined; + } + + // let cy = ele.cy(); + var _p = ele._private; + var group = _p.group; + if (group === 'nodes') { + var depth = _p.data.parent ? ele.parents().size() : 0; + if (!ele.isParent()) { + return MAX_INT$1 - 1; // childless nodes always on top + } + + return depth; + } else { + var src = _p.source; + var tgt = _p.target; + var srcDepth = src.zDepth(); + var tgtDepth = tgt.zDepth(); + return Math.max(srcDepth, tgtDepth, 0); // depth of deepest parent + } + } +}; + +elesfn$6.each = elesfn$6.forEach; +var defineSymbolIterator = function defineSymbolIterator() { + var typeofUndef = "undefined" ; + var isIteratorSupported = (typeof Symbol === "undefined" ? "undefined" : _typeof(Symbol)) != typeofUndef && _typeof(Symbol.iterator) != typeofUndef; // eslint-disable-line no-undef + + if (isIteratorSupported) { + elesfn$6[Symbol.iterator] = function () { + var _this = this; + // eslint-disable-line no-undef + var entry = { + value: undefined, + done: false + }; + var i = 0; + var length = this.length; + return _defineProperty$1({ + next: function next() { + if (i < length) { + entry.value = _this[i++]; + } else { + entry.value = undefined; + entry.done = true; + } + return entry; + } + }, Symbol.iterator, function () { + // eslint-disable-line no-undef + return this; + }); + }; + } +}; +defineSymbolIterator(); + +var getLayoutDimensionOptions = defaults$g({ + nodeDimensionsIncludeLabels: false +}); +var elesfn$5 = { + // Calculates and returns node dimensions { x, y } based on options given + layoutDimensions: function layoutDimensions(options) { + options = getLayoutDimensionOptions(options); + var dims; + if (!this.takesUpSpace()) { + dims = { + w: 0, + h: 0 + }; + } else if (options.nodeDimensionsIncludeLabels) { + var bbDim = this.boundingBox(); + dims = { + w: bbDim.w, + h: bbDim.h + }; + } else { + dims = { + w: this.outerWidth(), + h: this.outerHeight() + }; + } + + // sanitise the dimensions for external layouts (avoid division by zero) + if (dims.w === 0 || dims.h === 0) { + dims.w = dims.h = 1; + } + return dims; + }, + // using standard layout options, apply position function (w/ or w/o animation) + layoutPositions: function layoutPositions(layout, options, fn) { + var nodes = this.nodes().filter(function (n) { + return !n.isParent(); + }); + var cy = this.cy(); + var layoutEles = options.eles; // nodes & edges + var getMemoizeKey = function getMemoizeKey(node) { + return node.id(); + }; + var fnMem = memoize$1(fn, getMemoizeKey); // memoized version of position function + + layout.emit({ + type: 'layoutstart', + layout: layout + }); + layout.animations = []; + var calculateSpacing = function calculateSpacing(spacing, nodesBb, pos) { + var center = { + x: nodesBb.x1 + nodesBb.w / 2, + y: nodesBb.y1 + nodesBb.h / 2 + }; + var spacingVector = { + // scale from center of bounding box (not necessarily 0,0) + x: (pos.x - center.x) * spacing, + y: (pos.y - center.y) * spacing + }; + return { + x: center.x + spacingVector.x, + y: center.y + spacingVector.y + }; + }; + var useSpacingFactor = options.spacingFactor && options.spacingFactor !== 1; + var spacingBb = function spacingBb() { + if (!useSpacingFactor) { + return null; + } + var bb = makeBoundingBox(); + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var pos = fnMem(node, i); + expandBoundingBoxByPoint(bb, pos.x, pos.y); + } + return bb; + }; + var bb = spacingBb(); + var getFinalPos = memoize$1(function (node, i) { + var newPos = fnMem(node, i); + if (useSpacingFactor) { + var spacing = Math.abs(options.spacingFactor); + newPos = calculateSpacing(spacing, bb, newPos); + } + if (options.transform != null) { + newPos = options.transform(node, newPos); + } + return newPos; + }, getMemoizeKey); + if (options.animate) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var newPos = getFinalPos(node, i); + var animateNode = options.animateFilter == null || options.animateFilter(node, i); + if (animateNode) { + var ani = node.animation({ + position: newPos, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(ani); + } else { + node.position(newPos); + } + } + if (options.fit) { + var fitAni = cy.animation({ + fit: { + boundingBox: layoutEles.boundingBoxAt(getFinalPos), + padding: options.padding + }, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(fitAni); + } else if (options.zoom !== undefined && options.pan !== undefined) { + var zoomPanAni = cy.animation({ + zoom: options.zoom, + pan: options.pan, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(zoomPanAni); + } + layout.animations.forEach(function (ani) { + return ani.play(); + }); + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: layout + }); + Promise$1.all(layout.animations.map(function (ani) { + return ani.promise(); + })).then(function () { + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + }); + } else { + nodes.positions(getFinalPos); + if (options.fit) { + cy.fit(options.eles, options.padding); + } + if (options.zoom != null) { + cy.zoom(options.zoom); + } + if (options.pan) { + cy.pan(options.pan); + } + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: layout + }); + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + } + return this; // chaining + }, + + layout: function layout(options) { + var cy = this.cy(); + return cy.makeLayout(extend({}, options, { + eles: this + })); + } +}; + +// aliases: +elesfn$5.createLayout = elesfn$5.makeLayout = elesfn$5.layout; + +function styleCache(key, fn, ele) { + var _p = ele._private; + var cache = _p.styleCache = _p.styleCache || []; + var val; + if ((val = cache[key]) != null) { + return val; + } else { + val = cache[key] = fn(ele); + return val; + } +} +function cacheStyleFunction(key, fn) { + key = hashString(key); + return function cachedStyleFunction(ele) { + return styleCache(key, fn, ele); + }; +} +function cachePrototypeStyleFunction(key, fn) { + key = hashString(key); + var selfFn = function selfFn(ele) { + return fn.call(ele); + }; + return function cachedPrototypeStyleFunction() { + var ele = this[0]; + if (ele) { + return styleCache(key, selfFn, ele); + } + }; +} +var elesfn$4 = { + recalculateRenderedStyle: function recalculateRenderedStyle(useCache) { + var cy = this.cy(); + var renderer = cy.renderer(); + var styleEnabled = cy.styleEnabled(); + if (renderer && styleEnabled) { + renderer.recalculateRenderedStyle(this, useCache); + } + return this; + }, + dirtyStyleCache: function dirtyStyleCache() { + var cy = this.cy(); + var dirty = function dirty(ele) { + return ele._private.styleCache = null; + }; + if (cy.hasCompoundNodes()) { + var eles; + eles = this.spawnSelf().merge(this.descendants()).merge(this.parents()); + eles.merge(eles.connectedEdges()); + eles.forEach(dirty); + } else { + this.forEach(function (ele) { + dirty(ele); + ele.connectedEdges().forEach(dirty); + }); + } + return this; + }, + // fully updates (recalculates) the style for the elements + updateStyle: function updateStyle(notifyRenderer) { + var cy = this._private.cy; + if (!cy.styleEnabled()) { + return this; + } + if (cy.batching()) { + var bEles = cy._private.batchStyleEles; + bEles.merge(this); + return this; // chaining and exit early when batching + } + + var hasCompounds = cy.hasCompoundNodes(); + var updatedEles = this; + notifyRenderer = notifyRenderer || notifyRenderer === undefined ? true : false; + if (hasCompounds) { + // then add everything up and down for compound selector checks + updatedEles = this.spawnSelf().merge(this.descendants()).merge(this.parents()); + } + + // let changedEles = style.apply( updatedEles ); + var changedEles = updatedEles; + if (notifyRenderer) { + changedEles.emitAndNotify('style'); // let renderer know we changed style + } else { + changedEles.emit('style'); // just fire the event + } + + updatedEles.forEach(function (ele) { + return ele._private.styleDirty = true; + }); + return this; // chaining + }, + + // private: clears dirty flag and recalculates style + cleanStyle: function cleanStyle() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return; + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + if (ele._private.styleDirty) { + // n.b. this flag should be set before apply() to avoid potential infinite recursion + ele._private.styleDirty = false; + cy.style().apply(ele); + } + } + }, + // get the internal parsed style object for the specified property + parsedStyle: function parsedStyle(property) { + var includeNonDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var ele = this[0]; + var cy = ele.cy(); + if (!cy.styleEnabled()) { + return; + } + if (ele) { + this.cleanStyle(); + var overriddenStyle = ele._private.style[property]; + if (overriddenStyle != null) { + return overriddenStyle; + } else if (includeNonDefault) { + return cy.style().getDefaultProperty(property); + } else { + return null; + } + } + }, + numericStyle: function numericStyle(property) { + var ele = this[0]; + if (!ele.cy().styleEnabled()) { + return; + } + if (ele) { + var pstyle = ele.pstyle(property); + return pstyle.pfValue !== undefined ? pstyle.pfValue : pstyle.value; + } + }, + numericStyleUnits: function numericStyleUnits(property) { + var ele = this[0]; + if (!ele.cy().styleEnabled()) { + return; + } + if (ele) { + return ele.pstyle(property).units; + } + }, + // get the specified css property as a rendered value (i.e. on-screen value) + // or get the whole rendered style if no property specified (NB doesn't allow setting) + renderedStyle: function renderedStyle(property) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var ele = this[0]; + if (ele) { + return cy.style().getRenderedStyle(ele, property); + } + }, + // read the calculated css style of the element or override the style (via a bypass) + style: function style(name, value) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var updateTransitions = false; + var style = cy.style(); + if (plainObject(name)) { + // then extend the bypass + var props = name; + style.applyBypass(this, props, updateTransitions); + this.emitAndNotify('style'); // let the renderer know we've updated style + } else if (string(name)) { + if (value === undefined) { + // then get the property from the style + var ele = this[0]; + if (ele) { + return style.getStylePropertyValue(ele, name); + } else { + // empty collection => can't get any value + return; + } + } else { + // then set the bypass with the property value + style.applyBypass(this, name, value, updateTransitions); + this.emitAndNotify('style'); // let the renderer know we've updated style + } + } else if (name === undefined) { + var _ele = this[0]; + if (_ele) { + return style.getRawStyle(_ele); + } else { + // empty collection => can't get any value + return; + } + } + return this; // chaining + }, + + removeStyle: function removeStyle(names) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var updateTransitions = false; + var style = cy.style(); + var eles = this; + if (names === undefined) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + style.removeAllBypasses(ele, updateTransitions); + } + } else { + names = names.split(/\s+/); + for (var _i = 0; _i < eles.length; _i++) { + var _ele2 = eles[_i]; + style.removeBypasses(_ele2, names, updateTransitions); + } + } + this.emitAndNotify('style'); // let the renderer know we've updated style + + return this; // chaining + }, + + show: function show() { + this.css('display', 'element'); + return this; // chaining + }, + + hide: function hide() { + this.css('display', 'none'); + return this; // chaining + }, + + effectiveOpacity: function effectiveOpacity() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return 1; + } + var hasCompoundNodes = cy.hasCompoundNodes(); + var ele = this[0]; + if (ele) { + var _p = ele._private; + var parentOpacity = ele.pstyle('opacity').value; + if (!hasCompoundNodes) { + return parentOpacity; + } + var parents = !_p.data.parent ? null : ele.parents(); + if (parents) { + for (var i = 0; i < parents.length; i++) { + var parent = parents[i]; + var opacity = parent.pstyle('opacity').value; + parentOpacity = opacity * parentOpacity; + } + } + return parentOpacity; + } + }, + transparent: function transparent() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return false; + } + var ele = this[0]; + var hasCompoundNodes = ele.cy().hasCompoundNodes(); + if (ele) { + if (!hasCompoundNodes) { + return ele.pstyle('opacity').value === 0; + } else { + return ele.effectiveOpacity() === 0; + } + } + }, + backgrounding: function backgrounding() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return false; + } + var ele = this[0]; + return ele._private.backgrounding ? true : false; + } +}; +function checkCompound(ele, parentOk) { + var _p = ele._private; + var parents = _p.data.parent ? ele.parents() : null; + if (parents) { + for (var i = 0; i < parents.length; i++) { + var parent = parents[i]; + if (!parentOk(parent)) { + return false; + } + } + } + return true; +} +function defineDerivedStateFunction(specs) { + var ok = specs.ok; + var edgeOkViaNode = specs.edgeOkViaNode || specs.ok; + var parentOk = specs.parentOk || specs.ok; + return function () { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return true; + } + var ele = this[0]; + var hasCompoundNodes = cy.hasCompoundNodes(); + if (ele) { + var _p = ele._private; + if (!ok(ele)) { + return false; + } + if (ele.isNode()) { + return !hasCompoundNodes || checkCompound(ele, parentOk); + } else { + var src = _p.source; + var tgt = _p.target; + return edgeOkViaNode(src) && (!hasCompoundNodes || checkCompound(src, edgeOkViaNode)) && (src === tgt || edgeOkViaNode(tgt) && (!hasCompoundNodes || checkCompound(tgt, edgeOkViaNode))); + } + } + }; +} +var eleTakesUpSpace = cacheStyleFunction('eleTakesUpSpace', function (ele) { + return ele.pstyle('display').value === 'element' && ele.width() !== 0 && (ele.isNode() ? ele.height() !== 0 : true); +}); +elesfn$4.takesUpSpace = cachePrototypeStyleFunction('takesUpSpace', defineDerivedStateFunction({ + ok: eleTakesUpSpace +})); +var eleInteractive = cacheStyleFunction('eleInteractive', function (ele) { + return ele.pstyle('events').value === 'yes' && ele.pstyle('visibility').value === 'visible' && eleTakesUpSpace(ele); +}); +var parentInteractive = cacheStyleFunction('parentInteractive', function (parent) { + return parent.pstyle('visibility').value === 'visible' && eleTakesUpSpace(parent); +}); +elesfn$4.interactive = cachePrototypeStyleFunction('interactive', defineDerivedStateFunction({ + ok: eleInteractive, + parentOk: parentInteractive, + edgeOkViaNode: eleTakesUpSpace +})); +elesfn$4.noninteractive = function () { + var ele = this[0]; + if (ele) { + return !ele.interactive(); + } +}; +var eleVisible = cacheStyleFunction('eleVisible', function (ele) { + return ele.pstyle('visibility').value === 'visible' && ele.pstyle('opacity').pfValue !== 0 && eleTakesUpSpace(ele); +}); +var edgeVisibleViaNode = eleTakesUpSpace; +elesfn$4.visible = cachePrototypeStyleFunction('visible', defineDerivedStateFunction({ + ok: eleVisible, + edgeOkViaNode: edgeVisibleViaNode +})); +elesfn$4.hidden = function () { + var ele = this[0]; + if (ele) { + return !ele.visible(); + } +}; +elesfn$4.isBundledBezier = cachePrototypeStyleFunction('isBundledBezier', function () { + if (!this.cy().styleEnabled()) { + return false; + } + return !this.removed() && this.pstyle('curve-style').value === 'bezier' && this.takesUpSpace(); +}); +elesfn$4.bypass = elesfn$4.css = elesfn$4.style; +elesfn$4.renderedCss = elesfn$4.renderedStyle; +elesfn$4.removeBypass = elesfn$4.removeCss = elesfn$4.removeStyle; +elesfn$4.pstyle = elesfn$4.parsedStyle; + +var elesfn$3 = {}; +function defineSwitchFunction(params) { + return function () { + var args = arguments; + var changedEles = []; + + // e.g. cy.nodes().select( data, handler ) + if (args.length === 2) { + var data = args[0]; + var handler = args[1]; + this.on(params.event, data, handler); + } + + // e.g. cy.nodes().select( handler ) + else if (args.length === 1 && fn$6(args[0])) { + var _handler = args[0]; + this.on(params.event, _handler); + } + + // e.g. cy.nodes().select() + // e.g. (private) cy.nodes().select(['tapselect']) + else if (args.length === 0 || args.length === 1 && array(args[0])) { + var addlEvents = args.length === 1 ? args[0] : null; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var able = !params.ableField || ele._private[params.ableField]; + var changed = ele._private[params.field] != params.value; + if (params.overrideAble) { + var overrideAble = params.overrideAble(ele); + if (overrideAble !== undefined) { + able = overrideAble; + if (!overrideAble) { + return this; + } // to save cycles assume not able for all on override + } + } + + if (able) { + ele._private[params.field] = params.value; + if (changed) { + changedEles.push(ele); + } + } + } + var changedColl = this.spawn(changedEles); + changedColl.updateStyle(); // change of state => possible change of style + changedColl.emit(params.event); + if (addlEvents) { + changedColl.emit(addlEvents); + } + } + return this; + }; +} +function defineSwitchSet(params) { + elesfn$3[params.field] = function () { + var ele = this[0]; + if (ele) { + if (params.overrideField) { + var val = params.overrideField(ele); + if (val !== undefined) { + return val; + } + } + return ele._private[params.field]; + } + }; + elesfn$3[params.on] = defineSwitchFunction({ + event: params.on, + field: params.field, + ableField: params.ableField, + overrideAble: params.overrideAble, + value: true + }); + elesfn$3[params.off] = defineSwitchFunction({ + event: params.off, + field: params.field, + ableField: params.ableField, + overrideAble: params.overrideAble, + value: false + }); +} +defineSwitchSet({ + field: 'locked', + overrideField: function overrideField(ele) { + return ele.cy().autolock() ? true : undefined; + }, + on: 'lock', + off: 'unlock' +}); +defineSwitchSet({ + field: 'grabbable', + overrideField: function overrideField(ele) { + return ele.cy().autoungrabify() || ele.pannable() ? false : undefined; + }, + on: 'grabify', + off: 'ungrabify' +}); +defineSwitchSet({ + field: 'selected', + ableField: 'selectable', + overrideAble: function overrideAble(ele) { + return ele.cy().autounselectify() ? false : undefined; + }, + on: 'select', + off: 'unselect' +}); +defineSwitchSet({ + field: 'selectable', + overrideField: function overrideField(ele) { + return ele.cy().autounselectify() ? false : undefined; + }, + on: 'selectify', + off: 'unselectify' +}); +elesfn$3.deselect = elesfn$3.unselect; +elesfn$3.grabbed = function () { + var ele = this[0]; + if (ele) { + return ele._private.grabbed; + } +}; +defineSwitchSet({ + field: 'active', + on: 'activate', + off: 'unactivate' +}); +defineSwitchSet({ + field: 'pannable', + on: 'panify', + off: 'unpanify' +}); +elesfn$3.inactive = function () { + var ele = this[0]; + if (ele) { + return !ele._private.active; + } +}; + +var elesfn$2 = {}; + +// DAG functions +//////////////// + +var defineDagExtremity = function defineDagExtremity(params) { + return function dagExtremityImpl(selector) { + var eles = this; + var ret = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + var disqualified = false; + var edges = ele.connectedEdges(); + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + var src = edge.source(); + var tgt = edge.target(); + if (params.noIncomingEdges && tgt === ele && src !== ele || params.noOutgoingEdges && src === ele && tgt !== ele) { + disqualified = true; + break; + } + } + if (!disqualified) { + ret.push(ele); + } + } + return this.spawn(ret, true).filter(selector); + }; +}; +var defineDagOneHop = function defineDagOneHop(params) { + return function (selector) { + var eles = this; + var oEles = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + var edges = ele.connectedEdges(); + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + var src = edge.source(); + var tgt = edge.target(); + if (params.outgoing && src === ele) { + oEles.push(edge); + oEles.push(tgt); + } else if (params.incoming && tgt === ele) { + oEles.push(edge); + oEles.push(src); + } + } + } + return this.spawn(oEles, true).filter(selector); + }; +}; +var defineDagAllHops = function defineDagAllHops(params) { + return function (selector) { + var eles = this; + var sEles = []; + var sElesIds = {}; + for (;;) { + var next = params.outgoing ? eles.outgoers() : eles.incomers(); + if (next.length === 0) { + break; + } // done if none left + + var newNext = false; + for (var i = 0; i < next.length; i++) { + var n = next[i]; + var nid = n.id(); + if (!sElesIds[nid]) { + sElesIds[nid] = true; + sEles.push(n); + newNext = true; + } + } + if (!newNext) { + break; + } // done if touched all outgoers already + + eles = next; + } + return this.spawn(sEles, true).filter(selector); + }; +}; +elesfn$2.clearTraversalCache = function () { + for (var i = 0; i < this.length; i++) { + this[i]._private.traversalCache = null; + } +}; +extend(elesfn$2, { + // get the root nodes in the DAG + roots: defineDagExtremity({ + noIncomingEdges: true + }), + // get the leaf nodes in the DAG + leaves: defineDagExtremity({ + noOutgoingEdges: true + }), + // normally called children in graph theory + // these nodes =edges=> outgoing nodes + outgoers: cache(defineDagOneHop({ + outgoing: true + }), 'outgoers'), + // aka DAG descendants + successors: defineDagAllHops({ + outgoing: true + }), + // normally called parents in graph theory + // these nodes <=edges= incoming nodes + incomers: cache(defineDagOneHop({ + incoming: true + }), 'incomers'), + // aka DAG ancestors + predecessors: defineDagAllHops({ + incoming: true + }) +}); + +// Neighbourhood functions +////////////////////////// + +extend(elesfn$2, { + neighborhood: cache(function (selector) { + var elements = []; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + // for all nodes + var node = nodes[i]; + var connectedEdges = node.connectedEdges(); + + // for each connected edge, add the edge and the other node + for (var j = 0; j < connectedEdges.length; j++) { + var edge = connectedEdges[j]; + var src = edge.source(); + var tgt = edge.target(); + var otherNode = node === src ? tgt : src; + + // need check in case of loop + if (otherNode.length > 0) { + elements.push(otherNode[0]); // add node 1 hop away + } + + // add connected edge + elements.push(edge[0]); + } + } + return this.spawn(elements, true).filter(selector); + }, 'neighborhood'), + closedNeighborhood: function closedNeighborhood(selector) { + return this.neighborhood().add(this).filter(selector); + }, + openNeighborhood: function openNeighborhood(selector) { + return this.neighborhood(selector); + } +}); + +// aliases +elesfn$2.neighbourhood = elesfn$2.neighborhood; +elesfn$2.closedNeighbourhood = elesfn$2.closedNeighborhood; +elesfn$2.openNeighbourhood = elesfn$2.openNeighborhood; + +// Edge functions +///////////////// + +extend(elesfn$2, { + source: cache(function sourceImpl(selector) { + var ele = this[0]; + var src; + if (ele) { + src = ele._private.source || ele.cy().collection(); + } + return src && selector ? src.filter(selector) : src; + }, 'source'), + target: cache(function targetImpl(selector) { + var ele = this[0]; + var tgt; + if (ele) { + tgt = ele._private.target || ele.cy().collection(); + } + return tgt && selector ? tgt.filter(selector) : tgt; + }, 'target'), + sources: defineSourceFunction({ + attr: 'source' + }), + targets: defineSourceFunction({ + attr: 'target' + }) +}); +function defineSourceFunction(params) { + return function sourceImpl(selector) { + var sources = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var src = ele._private[params.attr]; + if (src) { + sources.push(src); + } + } + return this.spawn(sources, true).filter(selector); + }; +} +extend(elesfn$2, { + edgesWith: cache(defineEdgesWithFunction(), 'edgesWith'), + edgesTo: cache(defineEdgesWithFunction({ + thisIsSrc: true + }), 'edgesTo') +}); +function defineEdgesWithFunction(params) { + return function edgesWithImpl(otherNodes) { + var elements = []; + var cy = this._private.cy; + var p = params || {}; + + // get elements if a selector is specified + if (string(otherNodes)) { + otherNodes = cy.$(otherNodes); + } + for (var h = 0; h < otherNodes.length; h++) { + var edges = otherNodes[h]._private.edges; + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var edgeData = edge._private.data; + var thisToOther = this.hasElementWithId(edgeData.source) && otherNodes.hasElementWithId(edgeData.target); + var otherToThis = otherNodes.hasElementWithId(edgeData.source) && this.hasElementWithId(edgeData.target); + var edgeConnectsThisAndOther = thisToOther || otherToThis; + if (!edgeConnectsThisAndOther) { + continue; + } + if (p.thisIsSrc || p.thisIsTgt) { + if (p.thisIsSrc && !thisToOther) { + continue; + } + if (p.thisIsTgt && !otherToThis) { + continue; + } + } + elements.push(edge); + } + } + return this.spawn(elements, true); + }; +} +extend(elesfn$2, { + connectedEdges: cache(function (selector) { + var retEles = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var node = eles[i]; + if (!node.isNode()) { + continue; + } + var edges = node._private.edges; + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + retEles.push(edge); + } + } + return this.spawn(retEles, true).filter(selector); + }, 'connectedEdges'), + connectedNodes: cache(function (selector) { + var retEles = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var edge = eles[i]; + if (!edge.isEdge()) { + continue; + } + retEles.push(edge.source()[0]); + retEles.push(edge.target()[0]); + } + return this.spawn(retEles, true).filter(selector); + }, 'connectedNodes'), + parallelEdges: cache(defineParallelEdgesFunction(), 'parallelEdges'), + codirectedEdges: cache(defineParallelEdgesFunction({ + codirected: true + }), 'codirectedEdges') +}); +function defineParallelEdgesFunction(params) { + var defaults = { + codirected: false + }; + params = extend({}, defaults, params); + return function parallelEdgesImpl(selector) { + // micro-optimised for renderer + var elements = []; + var edges = this.edges(); + var p = params; + + // look at all the edges in the collection + for (var i = 0; i < edges.length; i++) { + var edge1 = edges[i]; + var edge1_p = edge1._private; + var src1 = edge1_p.source; + var srcid1 = src1._private.data.id; + var tgtid1 = edge1_p.data.target; + var srcEdges1 = src1._private.edges; + + // look at edges connected to the src node of this edge + for (var j = 0; j < srcEdges1.length; j++) { + var edge2 = srcEdges1[j]; + var edge2data = edge2._private.data; + var tgtid2 = edge2data.target; + var srcid2 = edge2data.source; + var codirected = tgtid2 === tgtid1 && srcid2 === srcid1; + var oppdirected = srcid1 === tgtid2 && tgtid1 === srcid2; + if (p.codirected && codirected || !p.codirected && (codirected || oppdirected)) { + elements.push(edge2); + } + } + } + return this.spawn(elements, true).filter(selector); + }; +} + +// Misc functions +///////////////// + +extend(elesfn$2, { + components: function components(root) { + var self = this; + var cy = self.cy(); + var visited = cy.collection(); + var unvisited = root == null ? self.nodes() : root.nodes(); + var components = []; + if (root != null && unvisited.empty()) { + // root may contain only edges + unvisited = root.sources(); // doesn't matter which node to use (undirected), so just use the source sides + } + + var visitInComponent = function visitInComponent(node, component) { + visited.merge(node); + unvisited.unmerge(node); + component.merge(node); + }; + if (unvisited.empty()) { + return self.spawn(); + } + var _loop = function _loop() { + // each iteration yields a component + var cmpt = cy.collection(); + components.push(cmpt); + var root = unvisited[0]; + visitInComponent(root, cmpt); + self.bfs({ + directed: false, + roots: root, + visit: function visit(v) { + return visitInComponent(v, cmpt); + } + }); + cmpt.forEach(function (node) { + node.connectedEdges().forEach(function (e) { + // connectedEdges() usually cached + if (self.has(e) && cmpt.has(e.source()) && cmpt.has(e.target())) { + // has() is cheap + cmpt.merge(e); // forEach() only considers nodes -- sets N at call time + } + }); + }); + }; + do { + _loop(); + } while (unvisited.length > 0); + return components; + }, + component: function component() { + var ele = this[0]; + return ele.cy().mutableElements().components(ele)[0]; + } +}); +elesfn$2.componentsOf = elesfn$2.components; + +// represents a set of nodes, edges, or both together +var Collection = function Collection(cy, elements) { + var unique = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var removed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + if (cy === undefined) { + error('A collection must have a reference to the core'); + return; + } + var map = new Map$2(); + var createdElements = false; + if (!elements) { + elements = []; + } else if (elements.length > 0 && plainObject(elements[0]) && !element(elements[0])) { + createdElements = true; + + // make elements from json and restore all at once later + var eles = []; + var elesIds = new Set$1(); + for (var i = 0, l = elements.length; i < l; i++) { + var json = elements[i]; + if (json.data == null) { + json.data = {}; + } + var _data = json.data; + + // make sure newly created elements have valid ids + if (_data.id == null) { + _data.id = uuid(); + } else if (cy.hasElementWithId(_data.id) || elesIds.has(_data.id)) { + continue; // can't create element if prior id already exists + } + + var ele = new Element(cy, json, false); + eles.push(ele); + elesIds.add(_data.id); + } + elements = eles; + } + this.length = 0; + for (var _i = 0, _l = elements.length; _i < _l; _i++) { + var element$1 = elements[_i][0]; // [0] in case elements is an array of collections, rather than array of elements + if (element$1 == null) { + continue; + } + var id = element$1._private.data.id; + if (!unique || !map.has(id)) { + if (unique) { + map.set(id, { + index: this.length, + ele: element$1 + }); + } + this[this.length] = element$1; + this.length++; + } + } + this._private = { + eles: this, + cy: cy, + get map() { + if (this.lazyMap == null) { + this.rebuildMap(); + } + return this.lazyMap; + }, + set map(m) { + this.lazyMap = m; + }, + rebuildMap: function rebuildMap() { + var m = this.lazyMap = new Map$2(); + var eles = this.eles; + for (var _i2 = 0; _i2 < eles.length; _i2++) { + var _ele = eles[_i2]; + m.set(_ele.id(), { + index: _i2, + ele: _ele + }); + } + } + }; + if (unique) { + this._private.map = map; + } + + // restore the elements if we created them from json + if (createdElements && !removed) { + this.restore(); + } +}; + +// Functions +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// keep the prototypes in sync (an element has the same functions as a collection) +// and use elefn and elesfn as shorthands to the prototypes +var elesfn$1 = Element.prototype = Collection.prototype = Object.create(Array.prototype); +elesfn$1.instanceString = function () { + return 'collection'; +}; +elesfn$1.spawn = function (eles, unique) { + return new Collection(this.cy(), eles, unique); +}; +elesfn$1.spawnSelf = function () { + return this.spawn(this); +}; +elesfn$1.cy = function () { + return this._private.cy; +}; +elesfn$1.renderer = function () { + return this._private.cy.renderer(); +}; +elesfn$1.element = function () { + return this[0]; +}; +elesfn$1.collection = function () { + if (collection(this)) { + return this; + } else { + // an element + return new Collection(this._private.cy, [this]); + } +}; +elesfn$1.unique = function () { + return new Collection(this._private.cy, this, true); +}; +elesfn$1.hasElementWithId = function (id) { + id = '' + id; // id must be string + + return this._private.map.has(id); +}; +elesfn$1.getElementById = function (id) { + id = '' + id; // id must be string + + var cy = this._private.cy; + var entry = this._private.map.get(id); + return entry ? entry.ele : new Collection(cy); // get ele or empty collection +}; + +elesfn$1.$id = elesfn$1.getElementById; +elesfn$1.poolIndex = function () { + var cy = this._private.cy; + var eles = cy._private.elements; + var id = this[0]._private.data.id; + return eles._private.map.get(id).index; +}; +elesfn$1.indexOf = function (ele) { + var id = ele[0]._private.data.id; + return this._private.map.get(id).index; +}; +elesfn$1.indexOfId = function (id) { + id = '' + id; // id must be string + + return this._private.map.get(id).index; +}; +elesfn$1.json = function (obj) { + var ele = this.element(); + var cy = this.cy(); + if (ele == null && obj) { + return this; + } // can't set to no eles + + if (ele == null) { + return undefined; + } // can't get from no eles + + var p = ele._private; + if (plainObject(obj)) { + // set + + cy.startBatch(); + if (obj.data) { + ele.data(obj.data); + var _data2 = p.data; + if (ele.isEdge()) { + // source and target are immutable via data() + var move = false; + var spec = {}; + var src = obj.data.source; + var tgt = obj.data.target; + if (src != null && src != _data2.source) { + spec.source = '' + src; // id must be string + move = true; + } + if (tgt != null && tgt != _data2.target) { + spec.target = '' + tgt; // id must be string + move = true; + } + if (move) { + ele = ele.move(spec); + } + } else { + // parent is immutable via data() + var newParentValSpecd = ('parent' in obj.data); + var parent = obj.data.parent; + if (newParentValSpecd && (parent != null || _data2.parent != null) && parent != _data2.parent) { + if (parent === undefined) { + // can't set undefined imperatively, so use null + parent = null; + } + if (parent != null) { + parent = '' + parent; // id must be string + } + + ele = ele.move({ + parent: parent + }); + } + } + } + if (obj.position) { + ele.position(obj.position); + } + + // ignore group -- immutable + + var checkSwitch = function checkSwitch(k, trueFnName, falseFnName) { + var obj_k = obj[k]; + if (obj_k != null && obj_k !== p[k]) { + if (obj_k) { + ele[trueFnName](); + } else { + ele[falseFnName](); + } + } + }; + checkSwitch('removed', 'remove', 'restore'); + checkSwitch('selected', 'select', 'unselect'); + checkSwitch('selectable', 'selectify', 'unselectify'); + checkSwitch('locked', 'lock', 'unlock'); + checkSwitch('grabbable', 'grabify', 'ungrabify'); + checkSwitch('pannable', 'panify', 'unpanify'); + if (obj.classes != null) { + ele.classes(obj.classes); + } + cy.endBatch(); + return this; + } else if (obj === undefined) { + // get + + var json = { + data: copy(p.data), + position: copy(p.position), + group: p.group, + removed: p.removed, + selected: p.selected, + selectable: p.selectable, + locked: p.locked, + grabbable: p.grabbable, + pannable: p.pannable, + classes: null + }; + json.classes = ''; + var i = 0; + p.classes.forEach(function (cls) { + return json.classes += i++ === 0 ? cls : ' ' + cls; + }); + return json; + } +}; +elesfn$1.jsons = function () { + var jsons = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var json = ele.json(); + jsons.push(json); + } + return jsons; +}; +elesfn$1.clone = function () { + var cy = this.cy(); + var elesArr = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var json = ele.json(); + var clone = new Element(cy, json, false); // NB no restore + + elesArr.push(clone); + } + return new Collection(cy, elesArr); +}; +elesfn$1.copy = elesfn$1.clone; +elesfn$1.restore = function () { + var notifyRenderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var addToPool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var self = this; + var cy = self.cy(); + var cy_p = cy._private; + + // create arrays of nodes and edges, since we need to + // restore the nodes first + var nodes = []; + var edges = []; + var elements; + for (var _i3 = 0, l = self.length; _i3 < l; _i3++) { + var ele = self[_i3]; + if (addToPool && !ele.removed()) { + // don't need to handle this ele + continue; + } + + // keep nodes first in the array and edges after + if (ele.isNode()) { + // put to front of array if node + nodes.push(ele); + } else { + // put to end of array if edge + edges.push(ele); + } + } + elements = nodes.concat(edges); + var i; + var removeFromElements = function removeFromElements() { + elements.splice(i, 1); + i--; + }; + + // now, restore each element + for (i = 0; i < elements.length; i++) { + var _ele2 = elements[i]; + var _private = _ele2._private; + var _data3 = _private.data; + + // the traversal cache should start fresh when ele is added + _ele2.clearTraversalCache(); + + // set id and validate + if (!addToPool && !_private.removed) ; else if (_data3.id === undefined) { + _data3.id = uuid(); + } else if (number$1(_data3.id)) { + _data3.id = '' + _data3.id; // now it's a string + } else if (emptyString(_data3.id) || !string(_data3.id)) { + error('Can not create element with invalid string ID `' + _data3.id + '`'); + + // can't create element if it has empty string as id or non-string id + removeFromElements(); + continue; + } else if (cy.hasElementWithId(_data3.id)) { + error('Can not create second element with ID `' + _data3.id + '`'); + + // can't create element if one already has that id + removeFromElements(); + continue; + } + var id = _data3.id; // id is finalised, now let's keep a ref + + if (_ele2.isNode()) { + // extra checks for nodes + var pos = _private.position; + + // make sure the nodes have a defined position + + if (pos.x == null) { + pos.x = 0; + } + if (pos.y == null) { + pos.y = 0; + } + } + if (_ele2.isEdge()) { + // extra checks for edges + + var edge = _ele2; + var fields = ['source', 'target']; + var fieldsLength = fields.length; + var badSourceOrTarget = false; + for (var j = 0; j < fieldsLength; j++) { + var field = fields[j]; + var val = _data3[field]; + if (number$1(val)) { + val = _data3[field] = '' + _data3[field]; // now string + } + + if (val == null || val === '') { + // can't create if source or target is not defined properly + error('Can not create edge `' + id + '` with unspecified ' + field); + badSourceOrTarget = true; + } else if (!cy.hasElementWithId(val)) { + // can't create edge if one of its nodes doesn't exist + error('Can not create edge `' + id + '` with nonexistant ' + field + ' `' + val + '`'); + badSourceOrTarget = true; + } + } + if (badSourceOrTarget) { + removeFromElements(); + continue; + } // can't create this + + var src = cy.getElementById(_data3.source); + var tgt = cy.getElementById(_data3.target); + + // only one edge in node if loop + if (src.same(tgt)) { + src._private.edges.push(edge); + } else { + src._private.edges.push(edge); + tgt._private.edges.push(edge); + } + edge._private.source = src; + edge._private.target = tgt; + } // if is edge + + // create mock ids / indexes maps for element so it can be used like collections + _private.map = new Map$2(); + _private.map.set(id, { + ele: _ele2, + index: 0 + }); + _private.removed = false; + if (addToPool) { + cy.addToPool(_ele2); + } + } // for each element + + // do compound node sanity checks + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + // each node + var node = nodes[_i4]; + var _data4 = node._private.data; + if (number$1(_data4.parent)) { + // then automake string + _data4.parent = '' + _data4.parent; + } + var parentId = _data4.parent; + var specifiedParent = parentId != null; + if (specifiedParent || node._private.parent) { + var parent = node._private.parent ? cy.collection().merge(node._private.parent) : cy.getElementById(parentId); + if (parent.empty()) { + // non-existant parent; just remove it + _data4.parent = undefined; + } else if (parent[0].removed()) { + warn('Node added with missing parent, reference to parent removed'); + _data4.parent = undefined; + node._private.parent = null; + } else { + var selfAsParent = false; + var ancestor = parent; + while (!ancestor.empty()) { + if (node.same(ancestor)) { + // mark self as parent and remove from data + selfAsParent = true; + _data4.parent = undefined; // remove parent reference + + // exit or we loop forever + break; + } + ancestor = ancestor.parent(); + } + if (!selfAsParent) { + // connect with children + parent[0]._private.children.push(node); + node._private.parent = parent[0]; + + // let the core know we have a compound graph + cy_p.hasCompoundNodes = true; + } + } // else + } // if specified parent + } // for each node + + if (elements.length > 0) { + var restored = elements.length === self.length ? self : new Collection(cy, elements); + for (var _i5 = 0; _i5 < restored.length; _i5++) { + var _ele3 = restored[_i5]; + if (_ele3.isNode()) { + continue; + } + + // adding an edge invalidates the traversal caches for the parallel edges + _ele3.parallelEdges().clearTraversalCache(); + + // adding an edge invalidates the traversal cache for the connected nodes + _ele3.source().clearTraversalCache(); + _ele3.target().clearTraversalCache(); + } + var toUpdateStyle; + if (cy_p.hasCompoundNodes) { + toUpdateStyle = cy.collection().merge(restored).merge(restored.connectedNodes()).merge(restored.parent()); + } else { + toUpdateStyle = restored; + } + toUpdateStyle.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(notifyRenderer); + if (notifyRenderer) { + restored.emitAndNotify('add'); + } else if (addToPool) { + restored.emit('add'); + } + } + return self; // chainability +}; + +elesfn$1.removed = function () { + var ele = this[0]; + return ele && ele._private.removed; +}; +elesfn$1.inside = function () { + var ele = this[0]; + return ele && !ele._private.removed; +}; +elesfn$1.remove = function () { + var notifyRenderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var removeFromPool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var self = this; + var elesToRemove = []; + var elesToRemoveIds = {}; + var cy = self._private.cy; + + // add connected edges + function addConnectedEdges(node) { + var edges = node._private.edges; + for (var i = 0; i < edges.length; i++) { + add(edges[i]); + } + } + + // add descendant nodes + function addChildren(node) { + var children = node._private.children; + for (var i = 0; i < children.length; i++) { + add(children[i]); + } + } + function add(ele) { + var alreadyAdded = elesToRemoveIds[ele.id()]; + if (removeFromPool && ele.removed() || alreadyAdded) { + return; + } else { + elesToRemoveIds[ele.id()] = true; + } + if (ele.isNode()) { + elesToRemove.push(ele); // nodes are removed last + + addConnectedEdges(ele); + addChildren(ele); + } else { + elesToRemove.unshift(ele); // edges are removed first + } + } + + // make the list of elements to remove + // (may be removing more than specified due to connected edges etc) + + for (var i = 0, l = self.length; i < l; i++) { + var ele = self[i]; + add(ele); + } + function removeEdgeRef(node, edge) { + var connectedEdges = node._private.edges; + removeFromArray(connectedEdges, edge); + + // removing an edges invalidates the traversal cache for its nodes + node.clearTraversalCache(); + } + function removeParallelRef(pllEdge) { + // removing an edge invalidates the traversal caches for the parallel edges + pllEdge.clearTraversalCache(); + } + var alteredParents = []; + alteredParents.ids = {}; + function removeChildRef(parent, ele) { + ele = ele[0]; + parent = parent[0]; + var children = parent._private.children; + var pid = parent.id(); + removeFromArray(children, ele); // remove parent => child ref + + ele._private.parent = null; // remove child => parent ref + + if (!alteredParents.ids[pid]) { + alteredParents.ids[pid] = true; + alteredParents.push(parent); + } + } + self.dirtyCompoundBoundsCache(); + if (removeFromPool) { + cy.removeFromPool(elesToRemove); // remove from core pool + } + + for (var _i6 = 0; _i6 < elesToRemove.length; _i6++) { + var _ele4 = elesToRemove[_i6]; + if (_ele4.isEdge()) { + // remove references to this edge in its connected nodes + var src = _ele4.source()[0]; + var tgt = _ele4.target()[0]; + removeEdgeRef(src, _ele4); + removeEdgeRef(tgt, _ele4); + var pllEdges = _ele4.parallelEdges(); + for (var j = 0; j < pllEdges.length; j++) { + var pllEdge = pllEdges[j]; + removeParallelRef(pllEdge); + if (pllEdge.isBundledBezier()) { + pllEdge.dirtyBoundingBoxCache(); + } + } + } else { + // remove reference to parent + var parent = _ele4.parent(); + if (parent.length !== 0) { + removeChildRef(parent, _ele4); + } + } + if (removeFromPool) { + // mark as removed + _ele4._private.removed = true; + } + } + + // check to see if we have a compound graph or not + var elesStillInside = cy._private.elements; + cy._private.hasCompoundNodes = false; + for (var _i7 = 0; _i7 < elesStillInside.length; _i7++) { + var _ele5 = elesStillInside[_i7]; + if (_ele5.isParent()) { + cy._private.hasCompoundNodes = true; + break; + } + } + var removedElements = new Collection(this.cy(), elesToRemove); + if (removedElements.size() > 0) { + // must manually notify since trigger won't do this automatically once removed + + if (notifyRenderer) { + removedElements.emitAndNotify('remove'); + } else if (removeFromPool) { + removedElements.emit('remove'); + } + } + + // the parents who were modified by the removal need their style updated + for (var _i8 = 0; _i8 < alteredParents.length; _i8++) { + var _ele6 = alteredParents[_i8]; + if (!removeFromPool || !_ele6.removed()) { + _ele6.updateStyle(); + } + } + return removedElements; +}; +elesfn$1.move = function (struct) { + var cy = this._private.cy; + var eles = this; + + // just clean up refs, caches, etc. in the same way as when removing and then restoring + // (our calls to remove/restore do not remove from the graph or make events) + var notifyRenderer = false; + var modifyPool = false; + var toString = function toString(id) { + return id == null ? id : '' + id; + }; // id must be string + + if (struct.source !== undefined || struct.target !== undefined) { + var srcId = toString(struct.source); + var tgtId = toString(struct.target); + var srcExists = srcId != null && cy.hasElementWithId(srcId); + var tgtExists = tgtId != null && cy.hasElementWithId(tgtId); + if (srcExists || tgtExists) { + cy.batch(function () { + // avoid duplicate style updates + eles.remove(notifyRenderer, modifyPool); // clean up refs etc. + eles.emitAndNotify('moveout'); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _data5 = ele._private.data; + if (ele.isEdge()) { + if (srcExists) { + _data5.source = srcId; + } + if (tgtExists) { + _data5.target = tgtId; + } + } + } + eles.restore(notifyRenderer, modifyPool); // make new refs, style, etc. + }); + + eles.emitAndNotify('move'); + } + } else if (struct.parent !== undefined) { + // move node to new parent + var parentId = toString(struct.parent); + var parentExists = parentId === null || cy.hasElementWithId(parentId); + if (parentExists) { + var pidToAssign = parentId === null ? undefined : parentId; + cy.batch(function () { + // avoid duplicate style updates + var updated = eles.remove(notifyRenderer, modifyPool); // clean up refs etc. + updated.emitAndNotify('moveout'); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _data6 = ele._private.data; + if (ele.isNode()) { + _data6.parent = pidToAssign; + } + } + updated.restore(notifyRenderer, modifyPool); // make new refs, style, etc. + }); + + eles.emitAndNotify('move'); + } + } + return this; +}; +[elesfn$j, elesfn$i, elesfn$h, elesfn$g, elesfn$f, data, elesfn$d, dimensions, elesfn$9, elesfn$8, elesfn$7, elesfn$6, elesfn$5, elesfn$4, elesfn$3, elesfn$2].forEach(function (props) { + extend(elesfn$1, props); +}); + +var corefn$9 = { + add: function add(opts) { + var elements; + var cy = this; + + // add the elements + if (elementOrCollection(opts)) { + var eles = opts; + if (eles._private.cy === cy) { + // same instance => just restore + elements = eles.restore(); + } else { + // otherwise, copy from json + var jsons = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + jsons.push(ele.json()); + } + elements = new Collection(cy, jsons); + } + } + + // specify an array of options + else if (array(opts)) { + var _jsons = opts; + elements = new Collection(cy, _jsons); + } + + // specify via opts.nodes and opts.edges + else if (plainObject(opts) && (array(opts.nodes) || array(opts.edges))) { + var elesByGroup = opts; + var _jsons2 = []; + var grs = ['nodes', 'edges']; + for (var _i = 0, il = grs.length; _i < il; _i++) { + var group = grs[_i]; + var elesArray = elesByGroup[group]; + if (array(elesArray)) { + for (var j = 0, jl = elesArray.length; j < jl; j++) { + var json = extend({ + group: group + }, elesArray[j]); + _jsons2.push(json); + } + } + } + elements = new Collection(cy, _jsons2); + } + + // specify options for one element + else { + var _json = opts; + elements = new Element(cy, _json).collection(); + } + return elements; + }, + remove: function remove(collection) { + if (elementOrCollection(collection)) ; else if (string(collection)) { + var selector = collection; + collection = this.$(selector); + } + return collection.remove(); + } +}; + +/* global Float32Array */ + +/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ +function generateCubicBezier(mX1, mY1, mX2, mY2) { + var NEWTON_ITERATIONS = 4, + NEWTON_MIN_SLOPE = 0.001, + SUBDIVISION_PRECISION = 0.0000001, + SUBDIVISION_MAX_ITERATIONS = 10, + kSplineTableSize = 11, + kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), + float32ArraySupported = typeof Float32Array !== 'undefined'; + + /* Must contain four arguments. */ + if (arguments.length !== 4) { + return false; + } + + /* Arguments must be numbers. */ + for (var i = 0; i < 4; ++i) { + if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { + return false; + } + } + + /* X values must be in the [0, 1] range. */ + mX1 = Math.min(mX1, 1); + mX2 = Math.min(mX2, 1); + mX1 = Math.max(mX1, 0); + mX2 = Math.max(mX2, 0); + var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); + function A(aA1, aA2) { + return 1.0 - 3.0 * aA2 + 3.0 * aA1; + } + function B(aA1, aA2) { + return 3.0 * aA2 - 6.0 * aA1; + } + function C(aA1) { + return 3.0 * aA1; + } + function calcBezier(aT, aA1, aA2) { + return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; + } + function getSlope(aT, aA1, aA2) { + return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); + } + function newtonRaphsonIterate(aX, aGuessT) { + for (var _i = 0; _i < NEWTON_ITERATIONS; ++_i) { + var currentSlope = getSlope(aGuessT, mX1, mX2); + if (currentSlope === 0.0) { + return aGuessT; + } + var currentX = calcBezier(aGuessT, mX1, mX2) - aX; + aGuessT -= currentX / currentSlope; + } + return aGuessT; + } + function calcSampleValues() { + for (var _i2 = 0; _i2 < kSplineTableSize; ++_i2) { + mSampleValues[_i2] = calcBezier(_i2 * kSampleStepSize, mX1, mX2); + } + } + function binarySubdivide(aX, aA, aB) { + var currentX, + currentT, + i = 0; + do { + currentT = aA + (aB - aA) / 2.0; + currentX = calcBezier(currentT, mX1, mX2) - aX; + if (currentX > 0.0) { + aB = currentT; + } else { + aA = currentT; + } + } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); + return currentT; + } + function getTForX(aX) { + var intervalStart = 0.0, + currentSample = 1, + lastSample = kSplineTableSize - 1; + for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { + intervalStart += kSampleStepSize; + } + --currentSample; + var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]), + guessForT = intervalStart + dist * kSampleStepSize, + initialSlope = getSlope(guessForT, mX1, mX2); + if (initialSlope >= NEWTON_MIN_SLOPE) { + return newtonRaphsonIterate(aX, guessForT); + } else if (initialSlope === 0.0) { + return guessForT; + } else { + return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); + } + } + var _precomputed = false; + function precompute() { + _precomputed = true; + if (mX1 !== mY1 || mX2 !== mY2) { + calcSampleValues(); + } + } + var f = function f(aX) { + if (!_precomputed) { + precompute(); + } + if (mX1 === mY1 && mX2 === mY2) { + return aX; + } + if (aX === 0) { + return 0; + } + if (aX === 1) { + return 1; + } + return calcBezier(getTForX(aX), mY1, mY2); + }; + f.getControlPoints = function () { + return [{ + x: mX1, + y: mY1 + }, { + x: mX2, + y: mY2 + }]; + }; + var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; + f.toString = function () { + return str; + }; + return f; +} + +/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ +/* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass + then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ +var generateSpringRK4 = function () { + function springAccelerationForState(state) { + return -state.tension * state.x - state.friction * state.v; + } + function springEvaluateStateWithDerivative(initialState, dt, derivative) { + var state = { + x: initialState.x + derivative.dx * dt, + v: initialState.v + derivative.dv * dt, + tension: initialState.tension, + friction: initialState.friction + }; + return { + dx: state.v, + dv: springAccelerationForState(state) + }; + } + function springIntegrateState(state, dt) { + var a = { + dx: state.v, + dv: springAccelerationForState(state) + }, + b = springEvaluateStateWithDerivative(state, dt * 0.5, a), + c = springEvaluateStateWithDerivative(state, dt * 0.5, b), + d = springEvaluateStateWithDerivative(state, dt, c), + dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), + dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); + state.x = state.x + dxdt * dt; + state.v = state.v + dvdt * dt; + return state; + } + return function springRK4Factory(tension, friction, duration) { + var initState = { + x: -1, + v: 0, + tension: null, + friction: null + }, + path = [0], + time_lapsed = 0, + tolerance = 1 / 10000, + DT = 16 / 1000, + have_duration, + dt, + last_state; + tension = parseFloat(tension) || 500; + friction = parseFloat(friction) || 20; + duration = duration || null; + initState.tension = tension; + initState.friction = friction; + have_duration = duration !== null; + + /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ + if (have_duration) { + /* Run the simulation without a duration. */ + time_lapsed = springRK4Factory(tension, friction); + /* Compute the adjusted time delta. */ + dt = time_lapsed / duration * DT; + } else { + dt = DT; + } + for (;;) { + /* Next/step function .*/ + last_state = springIntegrateState(last_state || initState, dt); + /* Store the position. */ + path.push(1 + last_state.x); + time_lapsed += 16; + /* If the change threshold is reached, break. */ + if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { + break; + } + } + + /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the + computed path and returns a snapshot of the position according to a given percentComplete. */ + return !have_duration ? time_lapsed : function (percentComplete) { + return path[percentComplete * (path.length - 1) | 0]; + }; + }; +}(); + +var cubicBezier = function cubicBezier(t1, p1, t2, p2) { + var bezier = generateCubicBezier(t1, p1, t2, p2); + return function (start, end, percent) { + return start + (end - start) * bezier(percent); + }; +}; +var easings = { + 'linear': function linear(start, end, percent) { + return start + (end - start) * percent; + }, + // default easings + 'ease': cubicBezier(0.25, 0.1, 0.25, 1), + 'ease-in': cubicBezier(0.42, 0, 1, 1), + 'ease-out': cubicBezier(0, 0, 0.58, 1), + 'ease-in-out': cubicBezier(0.42, 0, 0.58, 1), + // sine + 'ease-in-sine': cubicBezier(0.47, 0, 0.745, 0.715), + 'ease-out-sine': cubicBezier(0.39, 0.575, 0.565, 1), + 'ease-in-out-sine': cubicBezier(0.445, 0.05, 0.55, 0.95), + // quad + 'ease-in-quad': cubicBezier(0.55, 0.085, 0.68, 0.53), + 'ease-out-quad': cubicBezier(0.25, 0.46, 0.45, 0.94), + 'ease-in-out-quad': cubicBezier(0.455, 0.03, 0.515, 0.955), + // cubic + 'ease-in-cubic': cubicBezier(0.55, 0.055, 0.675, 0.19), + 'ease-out-cubic': cubicBezier(0.215, 0.61, 0.355, 1), + 'ease-in-out-cubic': cubicBezier(0.645, 0.045, 0.355, 1), + // quart + 'ease-in-quart': cubicBezier(0.895, 0.03, 0.685, 0.22), + 'ease-out-quart': cubicBezier(0.165, 0.84, 0.44, 1), + 'ease-in-out-quart': cubicBezier(0.77, 0, 0.175, 1), + // quint + 'ease-in-quint': cubicBezier(0.755, 0.05, 0.855, 0.06), + 'ease-out-quint': cubicBezier(0.23, 1, 0.32, 1), + 'ease-in-out-quint': cubicBezier(0.86, 0, 0.07, 1), + // expo + 'ease-in-expo': cubicBezier(0.95, 0.05, 0.795, 0.035), + 'ease-out-expo': cubicBezier(0.19, 1, 0.22, 1), + 'ease-in-out-expo': cubicBezier(1, 0, 0, 1), + // circ + 'ease-in-circ': cubicBezier(0.6, 0.04, 0.98, 0.335), + 'ease-out-circ': cubicBezier(0.075, 0.82, 0.165, 1), + 'ease-in-out-circ': cubicBezier(0.785, 0.135, 0.15, 0.86), + // user param easings... + + 'spring': function spring(tension, friction, duration) { + if (duration === 0) { + // can't get a spring w/ duration 0 + return easings.linear; // duration 0 => jump to end so impl doesn't matter + } + + var spring = generateSpringRK4(tension, friction, duration); + return function (start, end, percent) { + return start + (end - start) * spring(percent); + }; + }, + 'cubic-bezier': cubicBezier +}; + +function getEasedValue(type, start, end, percent, easingFn) { + if (percent === 1) { + return end; + } + if (start === end) { + return end; + } + var val = easingFn(start, end, percent); + if (type == null) { + return val; + } + if (type.roundValue || type.color) { + val = Math.round(val); + } + if (type.min !== undefined) { + val = Math.max(val, type.min); + } + if (type.max !== undefined) { + val = Math.min(val, type.max); + } + return val; +} +function getValue(prop, spec) { + if (prop.pfValue != null || prop.value != null) { + if (prop.pfValue != null && (spec == null || spec.type.units !== '%')) { + return prop.pfValue; + } else { + return prop.value; + } + } else { + return prop; + } +} +function ease(startProp, endProp, percent, easingFn, propSpec) { + var type = propSpec != null ? propSpec.type : null; + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + var start = getValue(startProp, propSpec); + var end = getValue(endProp, propSpec); + if (number$1(start) && number$1(end)) { + return getEasedValue(type, start, end, percent, easingFn); + } else if (array(start) && array(end)) { + var easedArr = []; + for (var i = 0; i < end.length; i++) { + var si = start[i]; + var ei = end[i]; + if (si != null && ei != null) { + var val = getEasedValue(type, si, ei, percent, easingFn); + easedArr.push(val); + } else { + easedArr.push(ei); + } + } + return easedArr; + } + return undefined; +} + +function step$1(self, ani, now, isCore) { + var isEles = !isCore; + var _p = self._private; + var ani_p = ani._private; + var pEasing = ani_p.easing; + var startTime = ani_p.startTime; + var cy = isCore ? self : self.cy(); + var style = cy.style(); + if (!ani_p.easingImpl) { + if (pEasing == null) { + // use default + ani_p.easingImpl = easings['linear']; + } else { + // then define w/ name + var easingVals; + if (string(pEasing)) { + var easingProp = style.parse('transition-timing-function', pEasing); + easingVals = easingProp.value; + } else { + // then assume preparsed array + easingVals = pEasing; + } + var name, args; + if (string(easingVals)) { + name = easingVals; + args = []; + } else { + name = easingVals[1]; + args = easingVals.slice(2).map(function (n) { + return +n; + }); + } + if (args.length > 0) { + // create with args + if (name === 'spring') { + args.push(ani_p.duration); // need duration to generate spring + } + + ani_p.easingImpl = easings[name].apply(null, args); + } else { + // static impl by name + ani_p.easingImpl = easings[name]; + } + } + } + var easing = ani_p.easingImpl; + var percent; + if (ani_p.duration === 0) { + percent = 1; + } else { + percent = (now - startTime) / ani_p.duration; + } + if (ani_p.applying) { + percent = ani_p.progress; + } + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + if (ani_p.delay == null) { + // then update + + var startPos = ani_p.startPosition; + var endPos = ani_p.position; + if (endPos && isEles && !self.locked()) { + var newPos = {}; + if (valid(startPos.x, endPos.x)) { + newPos.x = ease(startPos.x, endPos.x, percent, easing); + } + if (valid(startPos.y, endPos.y)) { + newPos.y = ease(startPos.y, endPos.y, percent, easing); + } + self.position(newPos); + } + var startPan = ani_p.startPan; + var endPan = ani_p.pan; + var pan = _p.pan; + var animatingPan = endPan != null && isCore; + if (animatingPan) { + if (valid(startPan.x, endPan.x)) { + pan.x = ease(startPan.x, endPan.x, percent, easing); + } + if (valid(startPan.y, endPan.y)) { + pan.y = ease(startPan.y, endPan.y, percent, easing); + } + self.emit('pan'); + } + var startZoom = ani_p.startZoom; + var endZoom = ani_p.zoom; + var animatingZoom = endZoom != null && isCore; + if (animatingZoom) { + if (valid(startZoom, endZoom)) { + _p.zoom = bound(_p.minZoom, ease(startZoom, endZoom, percent, easing), _p.maxZoom); + } + self.emit('zoom'); + } + if (animatingPan || animatingZoom) { + self.emit('viewport'); + } + var props = ani_p.style; + if (props && props.length > 0 && isEles) { + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + var _name = prop.name; + var end = prop; + var start = ani_p.startStyle[_name]; + var propSpec = style.properties[start.name]; + var easedVal = ease(start, end, percent, easing, propSpec); + style.overrideBypass(self, _name, easedVal); + } // for props + + self.emit('style'); + } // if + } + + ani_p.progress = percent; + return percent; +} +function valid(start, end) { + if (start == null || end == null) { + return false; + } + if (number$1(start) && number$1(end)) { + return true; + } else if (start && end) { + return true; + } + return false; +} + +function startAnimation(self, ani, now, isCore) { + var ani_p = ani._private; + ani_p.started = true; + ani_p.startTime = now - ani_p.progress * ani_p.duration; +} + +function stepAll(now, cy) { + var eles = cy._private.aniEles; + var doneEles = []; + function stepOne(ele, isCore) { + var _p = ele._private; + var current = _p.animation.current; + var queue = _p.animation.queue; + var ranAnis = false; + + // if nothing currently animating, get something from the queue + if (current.length === 0) { + var next = queue.shift(); + if (next) { + current.push(next); + } + } + var callbacks = function callbacks(_callbacks) { + for (var j = _callbacks.length - 1; j >= 0; j--) { + var cb = _callbacks[j]; + cb(); + } + _callbacks.splice(0, _callbacks.length); + }; + + // step and remove if done + for (var i = current.length - 1; i >= 0; i--) { + var ani = current[i]; + var ani_p = ani._private; + if (ani_p.stopped) { + current.splice(i, 1); + ani_p.hooked = false; + ani_p.playing = false; + ani_p.started = false; + callbacks(ani_p.frames); + continue; + } + if (!ani_p.playing && !ani_p.applying) { + continue; + } + + // an apply() while playing shouldn't do anything + if (ani_p.playing && ani_p.applying) { + ani_p.applying = false; + } + if (!ani_p.started) { + startAnimation(ele, ani, now); + } + step$1(ele, ani, now, isCore); + if (ani_p.applying) { + ani_p.applying = false; + } + callbacks(ani_p.frames); + if (ani_p.step != null) { + ani_p.step(now); + } + if (ani.completed()) { + current.splice(i, 1); + ani_p.hooked = false; + ani_p.playing = false; + ani_p.started = false; + callbacks(ani_p.completes); + } + ranAnis = true; + } + if (!isCore && current.length === 0 && queue.length === 0) { + doneEles.push(ele); + } + return ranAnis; + } // stepElement + + // handle all eles + var ranEleAni = false; + for (var e = 0; e < eles.length; e++) { + var ele = eles[e]; + var handledThisEle = stepOne(ele); + ranEleAni = ranEleAni || handledThisEle; + } // each element + + var ranCoreAni = stepOne(cy, true); + + // notify renderer + if (ranEleAni || ranCoreAni) { + if (eles.length > 0) { + cy.notify('draw', eles); + } else { + cy.notify('draw'); + } + } + + // remove elements from list of currently animating if its queues are empty + eles.unmerge(doneEles); + cy.emit('step'); +} // stepAll + +var corefn$8 = { + // pull in animation functions + animate: define.animate(), + animation: define.animation(), + animated: define.animated(), + clearQueue: define.clearQueue(), + delay: define.delay(), + delayAnimation: define.delayAnimation(), + stop: define.stop(), + addToAnimationPool: function addToAnimationPool(eles) { + var cy = this; + if (!cy.styleEnabled()) { + return; + } // save cycles when no style used + + cy._private.aniEles.merge(eles); + }, + stopAnimationLoop: function stopAnimationLoop() { + this._private.animationsRunning = false; + }, + startAnimationLoop: function startAnimationLoop() { + var cy = this; + cy._private.animationsRunning = true; + if (!cy.styleEnabled()) { + return; + } // save cycles when no style used + + // NB the animation loop will exec in headless environments if style enabled + // and explicit cy.destroy() is necessary to stop the loop + + function headlessStep() { + if (!cy._private.animationsRunning) { + return; + } + requestAnimationFrame$1(function animationStep(now) { + stepAll(now, cy); + headlessStep(); + }); + } + var renderer = cy.renderer(); + if (renderer && renderer.beforeRender) { + // let the renderer schedule animations + renderer.beforeRender(function rendererAnimationStep(willDraw, now) { + stepAll(now, cy); + }, renderer.beforeRenderPriorities.animations); + } else { + // manage the animation loop ourselves + headlessStep(); // first call + } + } +}; + +var emitterOptions = { + qualifierCompare: function qualifierCompare(selector1, selector2) { + if (selector1 == null || selector2 == null) { + return selector1 == null && selector2 == null; + } else { + return selector1.sameText(selector2); + } + }, + eventMatches: function eventMatches(cy, listener, eventObj) { + var selector = listener.qualifier; + if (selector != null) { + return cy !== eventObj.target && element(eventObj.target) && selector.matches(eventObj.target); + } + return true; + }, + addEventFields: function addEventFields(cy, evt) { + evt.cy = cy; + evt.target = cy; + }, + callbackContext: function callbackContext(cy, listener, eventObj) { + return listener.qualifier != null ? eventObj.target : cy; + } +}; +var argSelector = function argSelector(arg) { + if (string(arg)) { + return new Selector(arg); + } else { + return arg; + } +}; +var elesfn = { + createEmitter: function createEmitter() { + var _p = this._private; + if (!_p.emitter) { + _p.emitter = new Emitter(emitterOptions, this); + } + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(events, selector, callback) { + this.emitter().on(events, argSelector(selector), callback); + return this; + }, + removeListener: function removeListener(events, selector, callback) { + this.emitter().removeListener(events, argSelector(selector), callback); + return this; + }, + removeAllListeners: function removeAllListeners() { + this.emitter().removeAllListeners(); + return this; + }, + one: function one(events, selector, callback) { + this.emitter().one(events, argSelector(selector), callback); + return this; + }, + once: function once(events, selector, callback) { + this.emitter().one(events, argSelector(selector), callback); + return this; + }, + emit: function emit(events, extraParams) { + this.emitter().emit(events, extraParams); + return this; + }, + emitAndNotify: function emitAndNotify(event, eles) { + this.emit(event); + this.notify(event, eles); + return this; + } +}; +define.eventAliasesOn(elesfn); + +var corefn$7 = { + png: function png(options) { + var renderer = this._private.renderer; + options = options || {}; + return renderer.png(options); + }, + jpg: function jpg(options) { + var renderer = this._private.renderer; + options = options || {}; + options.bg = options.bg || '#fff'; + return renderer.jpg(options); + } +}; +corefn$7.jpeg = corefn$7.jpg; + +var corefn$6 = { + layout: function layout(options) { + var cy = this; + if (options == null) { + error('Layout options must be specified to make a layout'); + return; + } + if (options.name == null) { + error('A `name` must be specified to make a layout'); + return; + } + var name = options.name; + var Layout = cy.extension('layout', name); + if (Layout == null) { + error('No such layout `' + name + '` found. Did you forget to import it and `cytoscape.use()` it?'); + return; + } + var eles; + if (string(options.eles)) { + eles = cy.$(options.eles); + } else { + eles = options.eles != null ? options.eles : cy.$(); + } + var layout = new Layout(extend({}, options, { + cy: cy, + eles: eles + })); + return layout; + } +}; +corefn$6.createLayout = corefn$6.makeLayout = corefn$6.layout; + +var corefn$5 = { + notify: function notify(eventName, eventEles) { + var _p = this._private; + if (this.batching()) { + _p.batchNotifications = _p.batchNotifications || {}; + var eles = _p.batchNotifications[eventName] = _p.batchNotifications[eventName] || this.collection(); + if (eventEles != null) { + eles.merge(eventEles); + } + return; // notifications are disabled during batching + } + + if (!_p.notificationsEnabled) { + return; + } // exit on disabled + + var renderer = this.renderer(); + + // exit if destroy() called on core or renderer in between frames #1499 #1528 + if (this.destroyed() || !renderer) { + return; + } + renderer.notify(eventName, eventEles); + }, + notifications: function notifications(bool) { + var p = this._private; + if (bool === undefined) { + return p.notificationsEnabled; + } else { + p.notificationsEnabled = bool ? true : false; + } + return this; + }, + noNotifications: function noNotifications(callback) { + this.notifications(false); + callback(); + this.notifications(true); + }, + batching: function batching() { + return this._private.batchCount > 0; + }, + startBatch: function startBatch() { + var _p = this._private; + if (_p.batchCount == null) { + _p.batchCount = 0; + } + if (_p.batchCount === 0) { + _p.batchStyleEles = this.collection(); + _p.batchNotifications = {}; + } + _p.batchCount++; + return this; + }, + endBatch: function endBatch() { + var _p = this._private; + if (_p.batchCount === 0) { + return this; + } + _p.batchCount--; + if (_p.batchCount === 0) { + // update style for dirty eles + _p.batchStyleEles.updateStyle(); + var renderer = this.renderer(); + + // notify the renderer of queued eles and event types + Object.keys(_p.batchNotifications).forEach(function (eventName) { + var eles = _p.batchNotifications[eventName]; + if (eles.empty()) { + renderer.notify(eventName); + } else { + renderer.notify(eventName, eles); + } + }); + } + return this; + }, + batch: function batch(callback) { + this.startBatch(); + callback(); + this.endBatch(); + return this; + }, + // for backwards compatibility + batchData: function batchData(map) { + var cy = this; + return this.batch(function () { + var ids = Object.keys(map); + for (var i = 0; i < ids.length; i++) { + var id = ids[i]; + var data = map[id]; + var ele = cy.getElementById(id); + ele.data(data); + } + }); + } +}; + +var rendererDefaults = defaults$g({ + hideEdgesOnViewport: false, + textureOnViewport: false, + motionBlur: false, + motionBlurOpacity: 0.05, + pixelRatio: undefined, + desktopTapThreshold: 4, + touchTapThreshold: 8, + wheelSensitivity: 1, + debug: false, + showFps: false +}); +var corefn$4 = { + renderTo: function renderTo(context, zoom, pan, pxRatio) { + var r = this._private.renderer; + r.renderTo(context, zoom, pan, pxRatio); + return this; + }, + renderer: function renderer() { + return this._private.renderer; + }, + forceRender: function forceRender() { + this.notify('draw'); + return this; + }, + resize: function resize() { + this.invalidateSize(); + this.emitAndNotify('resize'); + return this; + }, + initRenderer: function initRenderer(options) { + var cy = this; + var RendererProto = cy.extension('renderer', options.name); + if (RendererProto == null) { + error("Can not initialise: No such renderer `".concat(options.name, "` found. Did you forget to import it and `cytoscape.use()` it?")); + return; + } + if (options.wheelSensitivity !== undefined) { + warn("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine."); + } + var rOpts = rendererDefaults(options); + rOpts.cy = cy; + cy._private.renderer = new RendererProto(rOpts); + this.notify('init'); + }, + destroyRenderer: function destroyRenderer() { + var cy = this; + cy.notify('destroy'); // destroy the renderer + + var domEle = cy.container(); + if (domEle) { + domEle._cyreg = null; + while (domEle.childNodes.length > 0) { + domEle.removeChild(domEle.childNodes[0]); + } + } + cy._private.renderer = null; // to be extra safe, remove the ref + cy.mutableElements().forEach(function (ele) { + var _p = ele._private; + _p.rscratch = {}; + _p.rstyle = {}; + _p.animation.current = []; + _p.animation.queue = []; + }); + }, + onRender: function onRender(fn) { + return this.on('render', fn); + }, + offRender: function offRender(fn) { + return this.off('render', fn); + } +}; +corefn$4.invalidateDimensions = corefn$4.resize; + +var corefn$3 = { + // get a collection + // - empty collection on no args + // - collection of elements in the graph on selector arg + // - guarantee a returned collection when elements or collection specified + collection: function collection(eles, opts) { + if (string(eles)) { + return this.$(eles); + } else if (elementOrCollection(eles)) { + return eles.collection(); + } else if (array(eles)) { + if (!opts) { + opts = {}; + } + return new Collection(this, eles, opts.unique, opts.removed); + } + return new Collection(this); + }, + nodes: function nodes(selector) { + var nodes = this.$(function (ele) { + return ele.isNode(); + }); + if (selector) { + return nodes.filter(selector); + } + return nodes; + }, + edges: function edges(selector) { + var edges = this.$(function (ele) { + return ele.isEdge(); + }); + if (selector) { + return edges.filter(selector); + } + return edges; + }, + // search the graph like jQuery + $: function $(selector) { + var eles = this._private.elements; + if (selector) { + return eles.filter(selector); + } else { + return eles.spawnSelf(); + } + }, + mutableElements: function mutableElements() { + return this._private.elements; + } +}; + +// aliases +corefn$3.elements = corefn$3.filter = corefn$3.$; + +var styfn$8 = {}; + +// keys for style blocks, e.g. ttfftt +var TRUE = 't'; +var FALSE = 'f'; + +// (potentially expensive calculation) +// apply the style to the element based on +// - its bypass +// - what selectors match it +styfn$8.apply = function (eles) { + var self = this; + var _p = self._private; + var cy = _p.cy; + var updatedEles = cy.collection(); + for (var ie = 0; ie < eles.length; ie++) { + var ele = eles[ie]; + var cxtMeta = self.getContextMeta(ele); + if (cxtMeta.empty) { + continue; + } + var cxtStyle = self.getContextStyle(cxtMeta); + var app = self.applyContextStyle(cxtMeta, cxtStyle, ele); + if (ele._private.appliedInitStyle) { + self.updateTransitions(ele, app.diffProps); + } else { + ele._private.appliedInitStyle = true; + } + var hintsDiff = self.updateStyleHints(ele); + if (hintsDiff) { + updatedEles.push(ele); + } + } // for elements + + return updatedEles; +}; +styfn$8.getPropertiesDiff = function (oldCxtKey, newCxtKey) { + var self = this; + var cache = self._private.propDiffs = self._private.propDiffs || {}; + var dualCxtKey = oldCxtKey + '-' + newCxtKey; + var cachedVal = cache[dualCxtKey]; + if (cachedVal) { + return cachedVal; + } + var diffProps = []; + var addedProp = {}; + for (var i = 0; i < self.length; i++) { + var cxt = self[i]; + var oldHasCxt = oldCxtKey[i] === TRUE; + var newHasCxt = newCxtKey[i] === TRUE; + var cxtHasDiffed = oldHasCxt !== newHasCxt; + var cxtHasMappedProps = cxt.mappedProperties.length > 0; + if (cxtHasDiffed || newHasCxt && cxtHasMappedProps) { + var props = void 0; + if (cxtHasDiffed && cxtHasMappedProps) { + props = cxt.properties; // suffices b/c mappedProperties is a subset of properties + } else if (cxtHasDiffed) { + props = cxt.properties; // need to check them all + } else if (cxtHasMappedProps) { + props = cxt.mappedProperties; // only need to check mapped + } + + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + var name = prop.name; + + // if a later context overrides this property, then the fact that this context has switched/diffed doesn't matter + // (semi expensive check since it makes this function O(n^2) on context length, but worth it since overall result + // is cached) + var laterCxtOverrides = false; + for (var k = i + 1; k < self.length; k++) { + var laterCxt = self[k]; + var hasLaterCxt = newCxtKey[k] === TRUE; + if (!hasLaterCxt) { + continue; + } // can't override unless the context is active + + laterCxtOverrides = laterCxt.properties[prop.name] != null; + if (laterCxtOverrides) { + break; + } // exit early as long as one later context overrides + } + + if (!addedProp[name] && !laterCxtOverrides) { + addedProp[name] = true; + diffProps.push(name); + } + } // for props + } // if + } // for contexts + + cache[dualCxtKey] = diffProps; + return diffProps; +}; +styfn$8.getContextMeta = function (ele) { + var self = this; + var cxtKey = ''; + var diffProps; + var prevKey = ele._private.styleCxtKey || ''; + + // get the cxt key + for (var i = 0; i < self.length; i++) { + var context = self[i]; + var contextSelectorMatches = context.selector && context.selector.matches(ele); // NB: context.selector may be null for 'core' + + if (contextSelectorMatches) { + cxtKey += TRUE; + } else { + cxtKey += FALSE; + } + } // for context + + diffProps = self.getPropertiesDiff(prevKey, cxtKey); + ele._private.styleCxtKey = cxtKey; + return { + key: cxtKey, + diffPropNames: diffProps, + empty: diffProps.length === 0 + }; +}; + +// gets a computed ele style object based on matched contexts +styfn$8.getContextStyle = function (cxtMeta) { + var cxtKey = cxtMeta.key; + var self = this; + var cxtStyles = this._private.contextStyles = this._private.contextStyles || {}; + + // if already computed style, returned cached copy + if (cxtStyles[cxtKey]) { + return cxtStyles[cxtKey]; + } + var style = { + _private: { + key: cxtKey + } + }; + for (var i = 0; i < self.length; i++) { + var cxt = self[i]; + var hasCxt = cxtKey[i] === TRUE; + if (!hasCxt) { + continue; + } + for (var j = 0; j < cxt.properties.length; j++) { + var prop = cxt.properties[j]; + style[prop.name] = prop; + } + } + cxtStyles[cxtKey] = style; + return style; +}; +styfn$8.applyContextStyle = function (cxtMeta, cxtStyle, ele) { + var self = this; + var diffProps = cxtMeta.diffPropNames; + var retDiffProps = {}; + var types = self.types; + for (var i = 0; i < diffProps.length; i++) { + var diffPropName = diffProps[i]; + var cxtProp = cxtStyle[diffPropName]; + var eleProp = ele.pstyle(diffPropName); + if (!cxtProp) { + // no context prop means delete + if (!eleProp) { + continue; // no existing prop means nothing needs to be removed + // nb affects initial application on mapped values like control-point-distances + } else if (eleProp.bypass) { + cxtProp = { + name: diffPropName, + deleteBypassed: true + }; + } else { + cxtProp = { + name: diffPropName, + "delete": true + }; + } + } + + // save cycles when the context prop doesn't need to be applied + if (eleProp === cxtProp) { + continue; + } + + // save cycles when a mapped context prop doesn't need to be applied + if (cxtProp.mapped === types.fn // context prop is function mapper + && eleProp != null // some props can be null even by default (e.g. a prop that overrides another one) + && eleProp.mapping != null // ele prop is a concrete value from from a mapper + && eleProp.mapping.value === cxtProp.value // the current prop on the ele is a flat prop value for the function mapper + ) { + // NB don't write to cxtProp, as it's shared among eles (stored in stylesheet) + var mapping = eleProp.mapping; // can write to mapping, as it's a per-ele copy + var fnValue = mapping.fnValue = cxtProp.value(ele); // temporarily cache the value in case of a miss + + if (fnValue === mapping.prevFnValue) { + continue; + } + } + var retDiffProp = retDiffProps[diffPropName] = { + prev: eleProp + }; + self.applyParsedProperty(ele, cxtProp); + retDiffProp.next = ele.pstyle(diffPropName); + if (retDiffProp.next && retDiffProp.next.bypass) { + retDiffProp.next = retDiffProp.next.bypassed; + } + } + return { + diffProps: retDiffProps + }; +}; +styfn$8.updateStyleHints = function (ele) { + var _p = ele._private; + var self = this; + var propNames = self.propertyGroupNames; + var propGrKeys = self.propertyGroupKeys; + var propHash = function propHash(ele, propNames, seedKey) { + return self.getPropertiesHash(ele, propNames, seedKey); + }; + var oldStyleKey = _p.styleKey; + if (ele.removed()) { + return false; + } + var isNode = _p.group === 'nodes'; + + // get the style key hashes per prop group + // but lazily -- only use non-default prop values to reduce the number of hashes + // + + var overriddenStyles = ele._private.style; + propNames = Object.keys(overriddenStyles); + for (var i = 0; i < propGrKeys.length; i++) { + var grKey = propGrKeys[i]; + _p.styleKeys[grKey] = [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]; + } + var updateGrKey1 = function updateGrKey1(val, grKey) { + return _p.styleKeys[grKey][0] = hashInt(val, _p.styleKeys[grKey][0]); + }; + var updateGrKey2 = function updateGrKey2(val, grKey) { + return _p.styleKeys[grKey][1] = hashIntAlt(val, _p.styleKeys[grKey][1]); + }; + var updateGrKey = function updateGrKey(val, grKey) { + updateGrKey1(val, grKey); + updateGrKey2(val, grKey); + }; + var updateGrKeyWStr = function updateGrKeyWStr(strVal, grKey) { + for (var j = 0; j < strVal.length; j++) { + var ch = strVal.charCodeAt(j); + updateGrKey1(ch, grKey); + updateGrKey2(ch, grKey); + } + }; + + // - hashing works on 32 bit ints b/c we use bitwise ops + // - small numbers get cut off (e.g. 0.123 is seen as 0 by the hashing function) + // - raise up small numbers so more significant digits are seen by hashing + // - make small numbers larger than a normal value to avoid collisions + // - works in practice and it's relatively cheap + var N = 2000000000; + var cleanNum = function cleanNum(val) { + return -128 < val && val < 128 && Math.floor(val) !== val ? N - (val * 1024 | 0) : val; + }; + for (var _i = 0; _i < propNames.length; _i++) { + var name = propNames[_i]; + var parsedProp = overriddenStyles[name]; + if (parsedProp == null) { + continue; + } + var propInfo = this.properties[name]; + var type = propInfo.type; + var _grKey = propInfo.groupKey; + var normalizedNumberVal = void 0; + if (propInfo.hashOverride != null) { + normalizedNumberVal = propInfo.hashOverride(ele, parsedProp); + } else if (parsedProp.pfValue != null) { + normalizedNumberVal = parsedProp.pfValue; + } + + // might not be a number if it allows enums + var numberVal = propInfo.enums == null ? parsedProp.value : null; + var haveNormNum = normalizedNumberVal != null; + var haveUnitedNum = numberVal != null; + var haveNum = haveNormNum || haveUnitedNum; + var units = parsedProp.units; + + // numbers are cheaper to hash than strings + // 1 hash op vs n hash ops (for length n string) + if (type.number && haveNum && !type.multiple) { + var v = haveNormNum ? normalizedNumberVal : numberVal; + updateGrKey(cleanNum(v), _grKey); + if (!haveNormNum && units != null) { + updateGrKeyWStr(units, _grKey); + } + } else { + updateGrKeyWStr(parsedProp.strValue, _grKey); + } + } + + // overall style key + // + + var hash = [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]; + for (var _i2 = 0; _i2 < propGrKeys.length; _i2++) { + var _grKey2 = propGrKeys[_i2]; + var grHash = _p.styleKeys[_grKey2]; + hash[0] = hashInt(grHash[0], hash[0]); + hash[1] = hashIntAlt(grHash[1], hash[1]); + } + _p.styleKey = combineHashes(hash[0], hash[1]); + + // label dims + // + + var sk = _p.styleKeys; + _p.labelDimsKey = combineHashesArray(sk.labelDimensions); + var labelKeys = propHash(ele, ['label'], sk.labelDimensions); + _p.labelKey = combineHashesArray(labelKeys); + _p.labelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, labelKeys)); + if (!isNode) { + var sourceLabelKeys = propHash(ele, ['source-label'], sk.labelDimensions); + _p.sourceLabelKey = combineHashesArray(sourceLabelKeys); + _p.sourceLabelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, sourceLabelKeys)); + var targetLabelKeys = propHash(ele, ['target-label'], sk.labelDimensions); + _p.targetLabelKey = combineHashesArray(targetLabelKeys); + _p.targetLabelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, targetLabelKeys)); + } + + // node + // + + if (isNode) { + var _p$styleKeys = _p.styleKeys, + nodeBody = _p$styleKeys.nodeBody, + nodeBorder = _p$styleKeys.nodeBorder, + nodeOutline = _p$styleKeys.nodeOutline, + backgroundImage = _p$styleKeys.backgroundImage, + compound = _p$styleKeys.compound, + pie = _p$styleKeys.pie; + var nodeKeys = [nodeBody, nodeBorder, nodeOutline, backgroundImage, compound, pie].filter(function (k) { + return k != null; + }).reduce(hashArrays, [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]); + _p.nodeKey = combineHashesArray(nodeKeys); + _p.hasPie = pie != null && pie[0] !== DEFAULT_HASH_SEED && pie[1] !== DEFAULT_HASH_SEED_ALT; + } + return oldStyleKey !== _p.styleKey; +}; +styfn$8.clearStyleHints = function (ele) { + var _p = ele._private; + _p.styleCxtKey = ''; + _p.styleKeys = {}; + _p.styleKey = null; + _p.labelKey = null; + _p.labelStyleKey = null; + _p.sourceLabelKey = null; + _p.sourceLabelStyleKey = null; + _p.targetLabelKey = null; + _p.targetLabelStyleKey = null; + _p.nodeKey = null; + _p.hasPie = null; +}; + +// apply a property to the style (for internal use) +// returns whether application was successful +// +// now, this function flattens the property, and here's how: +// +// for parsedProp:{ bypass: true, deleteBypass: true } +// no property is generated, instead the bypass property in the +// element's style is replaced by what's pointed to by the `bypassed` +// field in the bypass property (i.e. restoring the property the +// bypass was overriding) +// +// for parsedProp:{ mapped: truthy } +// the generated flattenedProp:{ mapping: prop } +// +// for parsedProp:{ bypass: true } +// the generated flattenedProp:{ bypassed: parsedProp } +styfn$8.applyParsedProperty = function (ele, parsedProp) { + var self = this; + var prop = parsedProp; + var style = ele._private.style; + var flatProp; + var types = self.types; + var type = self.properties[prop.name].type; + var propIsBypass = prop.bypass; + var origProp = style[prop.name]; + var origPropIsBypass = origProp && origProp.bypass; + var _p = ele._private; + var flatPropMapping = 'mapping'; + var getVal = function getVal(p) { + if (p == null) { + return null; + } else if (p.pfValue != null) { + return p.pfValue; + } else { + return p.value; + } + }; + var checkTriggers = function checkTriggers() { + var fromVal = getVal(origProp); + var toVal = getVal(prop); + self.checkTriggers(ele, prop.name, fromVal, toVal); + }; + + // edge sanity checks to prevent the client from making serious mistakes + if (parsedProp.name === 'curve-style' && ele.isEdge() && ( + // loops must be bundled beziers + parsedProp.value !== 'bezier' && ele.isLoop() || + // edges connected to compound nodes can not be haystacks + parsedProp.value === 'haystack' && (ele.source().isParent() || ele.target().isParent()))) { + prop = parsedProp = this.parse(parsedProp.name, 'bezier', propIsBypass); + } + if (prop["delete"]) { + // delete the property and use the default value on falsey value + style[prop.name] = undefined; + checkTriggers(); + return true; + } + if (prop.deleteBypassed) { + // delete the property that the + if (!origProp) { + checkTriggers(); + return true; // can't delete if no prop + } else if (origProp.bypass) { + // delete bypassed + origProp.bypassed = undefined; + checkTriggers(); + return true; + } else { + return false; // we're unsuccessful deleting the bypassed + } + } + + // check if we need to delete the current bypass + if (prop.deleteBypass) { + // then this property is just here to indicate we need to delete + if (!origProp) { + checkTriggers(); + return true; // property is already not defined + } else if (origProp.bypass) { + // then replace the bypass property with the original + // because the bypassed property was already applied (and therefore parsed), we can just replace it (no reapplying necessary) + style[prop.name] = origProp.bypassed; + checkTriggers(); + return true; + } else { + return false; // we're unsuccessful deleting the bypass + } + } + + var printMappingErr = function printMappingErr() { + warn('Do not assign mappings to elements without corresponding data (i.e. ele `' + ele.id() + '` has no mapping for property `' + prop.name + '` with data field `' + prop.field + '`); try a `[' + prop.field + ']` selector to limit scope to elements with `' + prop.field + '` defined'); + }; + + // put the property in the style objects + switch (prop.mapped) { + // flatten the property if mapped + case types.mapData: + { + // flatten the field (e.g. data.foo.bar) + var fields = prop.field.split('.'); + var fieldVal = _p.data; + for (var i = 0; i < fields.length && fieldVal; i++) { + var field = fields[i]; + fieldVal = fieldVal[field]; + } + if (fieldVal == null) { + printMappingErr(); + return false; + } + var percent; + if (!number$1(fieldVal)) { + // then don't apply and fall back on the existing style + warn('Do not use continuous mappers without specifying numeric data (i.e. `' + prop.field + ': ' + fieldVal + '` for `' + ele.id() + '` is non-numeric)'); + return false; + } else { + var fieldWidth = prop.fieldMax - prop.fieldMin; + if (fieldWidth === 0) { + // safety check -- not strictly necessary as no props of zero range should be passed here + percent = 0; + } else { + percent = (fieldVal - prop.fieldMin) / fieldWidth; + } + } + + // make sure to bound percent value + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + if (type.color) { + var r1 = prop.valueMin[0]; + var r2 = prop.valueMax[0]; + var g1 = prop.valueMin[1]; + var g2 = prop.valueMax[1]; + var b1 = prop.valueMin[2]; + var b2 = prop.valueMax[2]; + var a1 = prop.valueMin[3] == null ? 1 : prop.valueMin[3]; + var a2 = prop.valueMax[3] == null ? 1 : prop.valueMax[3]; + var clr = [Math.round(r1 + (r2 - r1) * percent), Math.round(g1 + (g2 - g1) * percent), Math.round(b1 + (b2 - b1) * percent), Math.round(a1 + (a2 - a1) * percent)]; + flatProp = { + // colours are simple, so just create the flat property instead of expensive string parsing + bypass: prop.bypass, + // we're a bypass if the mapping property is a bypass + name: prop.name, + value: clr, + strValue: 'rgb(' + clr[0] + ', ' + clr[1] + ', ' + clr[2] + ')' + }; + } else if (type.number) { + var calcValue = prop.valueMin + (prop.valueMax - prop.valueMin) * percent; + flatProp = this.parse(prop.name, calcValue, prop.bypass, flatPropMapping); + } else { + return false; // can only map to colours and numbers + } + + if (!flatProp) { + // if we can't flatten the property, then don't apply the property and fall back on the existing style + printMappingErr(); + return false; + } + flatProp.mapping = prop; // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + + // direct mapping + case types.data: + { + // flatten the field (e.g. data.foo.bar) + var _fields = prop.field.split('.'); + var _fieldVal = _p.data; + for (var _i3 = 0; _i3 < _fields.length && _fieldVal; _i3++) { + var _field = _fields[_i3]; + _fieldVal = _fieldVal[_field]; + } + if (_fieldVal != null) { + flatProp = this.parse(prop.name, _fieldVal, prop.bypass, flatPropMapping); + } + if (!flatProp) { + // if we can't flatten the property, then don't apply and fall back on the existing style + printMappingErr(); + return false; + } + flatProp.mapping = prop; // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + case types.fn: + { + var fn = prop.value; + var fnRetVal = prop.fnValue != null ? prop.fnValue : fn(ele); // check for cached value before calling function + + prop.prevFnValue = fnRetVal; + if (fnRetVal == null) { + warn('Custom function mappers may not return null (i.e. `' + prop.name + '` for ele `' + ele.id() + '` is null)'); + return false; + } + flatProp = this.parse(prop.name, fnRetVal, prop.bypass, flatPropMapping); + if (!flatProp) { + warn('Custom function mappers may not return invalid values for the property type (i.e. `' + prop.name + '` for ele `' + ele.id() + '` is invalid)'); + return false; + } + flatProp.mapping = copy(prop); // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + case undefined: + break; + // just set the property + + default: + return false; + // not a valid mapping + } + + // if the property is a bypass property, then link the resultant property to the original one + if (propIsBypass) { + if (origPropIsBypass) { + // then this bypass overrides the existing one + prop.bypassed = origProp.bypassed; // steal bypassed prop from old bypass + } else { + // then link the orig prop to the new bypass + prop.bypassed = origProp; + } + style[prop.name] = prop; // and set + } else { + // prop is not bypass + if (origPropIsBypass) { + // then keep the orig prop (since it's a bypass) and link to the new prop + origProp.bypassed = prop; + } else { + // then just replace the old prop with the new one + style[prop.name] = prop; + } + } + checkTriggers(); + return true; +}; +styfn$8.cleanElements = function (eles, keepBypasses) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + this.clearStyleHints(ele); + ele.dirtyCompoundBoundsCache(); + ele.dirtyBoundingBoxCache(); + if (!keepBypasses) { + ele._private.style = {}; + } else { + var style = ele._private.style; + var propNames = Object.keys(style); + for (var j = 0; j < propNames.length; j++) { + var propName = propNames[j]; + var eleProp = style[propName]; + if (eleProp != null) { + if (eleProp.bypass) { + eleProp.bypassed = null; + } else { + style[propName] = null; + } + } + } + } + } +}; + +// updates the visual style for all elements (useful for manual style modification after init) +styfn$8.update = function () { + var cy = this._private.cy; + var eles = cy.mutableElements(); + eles.updateStyle(); +}; + +// diffProps : { name => { prev, next } } +styfn$8.updateTransitions = function (ele, diffProps) { + var self = this; + var _p = ele._private; + var props = ele.pstyle('transition-property').value; + var duration = ele.pstyle('transition-duration').pfValue; + var delay = ele.pstyle('transition-delay').pfValue; + if (props.length > 0 && duration > 0) { + var style = {}; + + // build up the style to animate towards + var anyPrev = false; + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + var styProp = ele.pstyle(prop); + var diffProp = diffProps[prop]; + if (!diffProp) { + continue; + } + var prevProp = diffProp.prev; + var fromProp = prevProp; + var toProp = diffProp.next != null ? diffProp.next : styProp; + var diff = false; + var initVal = void 0; + var initDt = 0.000001; // delta time % value for initVal (allows animating out of init zero opacity) + + if (!fromProp) { + continue; + } + + // consider px values + if (number$1(fromProp.pfValue) && number$1(toProp.pfValue)) { + diff = toProp.pfValue - fromProp.pfValue; // nonzero is truthy + initVal = fromProp.pfValue + initDt * diff; + + // consider numerical values + } else if (number$1(fromProp.value) && number$1(toProp.value)) { + diff = toProp.value - fromProp.value; // nonzero is truthy + initVal = fromProp.value + initDt * diff; + + // consider colour values + } else if (array(fromProp.value) && array(toProp.value)) { + diff = fromProp.value[0] !== toProp.value[0] || fromProp.value[1] !== toProp.value[1] || fromProp.value[2] !== toProp.value[2]; + initVal = fromProp.strValue; + } + + // the previous value is good for an animation only if it's different + if (diff) { + style[prop] = toProp.strValue; // to val + this.applyBypass(ele, prop, initVal); // from val + anyPrev = true; + } + } // end if props allow ani + + // can't transition if there's nothing previous to transition from + if (!anyPrev) { + return; + } + _p.transitioning = true; + new Promise$1(function (resolve) { + if (delay > 0) { + ele.delayAnimation(delay).play().promise().then(resolve); + } else { + resolve(); + } + }).then(function () { + return ele.animation({ + style: style, + duration: duration, + easing: ele.pstyle('transition-timing-function').value, + queue: false + }).play().promise(); + }).then(function () { + // if( !isBypass ){ + self.removeBypasses(ele, props); + ele.emitAndNotify('style'); + // } + + _p.transitioning = false; + }); + } else if (_p.transitioning) { + this.removeBypasses(ele, props); + ele.emitAndNotify('style'); + _p.transitioning = false; + } +}; +styfn$8.checkTrigger = function (ele, name, fromValue, toValue, getTrigger, onTrigger) { + var prop = this.properties[name]; + var triggerCheck = getTrigger(prop); + if (triggerCheck != null && triggerCheck(fromValue, toValue)) { + onTrigger(prop); + } +}; +styfn$8.checkZOrderTrigger = function (ele, name, fromValue, toValue) { + var _this = this; + this.checkTrigger(ele, name, fromValue, toValue, function (prop) { + return prop.triggersZOrder; + }, function () { + _this._private.cy.notify('zorder', ele); + }); +}; +styfn$8.checkBoundsTrigger = function (ele, name, fromValue, toValue) { + this.checkTrigger(ele, name, fromValue, toValue, function (prop) { + return prop.triggersBounds; + }, function (prop) { + ele.dirtyCompoundBoundsCache(); + ele.dirtyBoundingBoxCache(); + + // if the prop change makes the bb of pll bezier edges invalid, + // then dirty the pll edge bb cache as well + if ( + // only for beziers -- so performance of other edges isn't affected + prop.triggersBoundsOfParallelBeziers && name === 'curve-style' && (fromValue === 'bezier' || toValue === 'bezier')) { + ele.parallelEdges().forEach(function (pllEdge) { + if (pllEdge.isBundledBezier()) { + pllEdge.dirtyBoundingBoxCache(); + } + }); + } + if (prop.triggersBoundsOfConnectedEdges && name === 'display' && (fromValue === 'none' || toValue === 'none')) { + ele.connectedEdges().forEach(function (edge) { + edge.dirtyBoundingBoxCache(); + }); + } + }); +}; +styfn$8.checkTriggers = function (ele, name, fromValue, toValue) { + ele.dirtyStyleCache(); + this.checkZOrderTrigger(ele, name, fromValue, toValue); + this.checkBoundsTrigger(ele, name, fromValue, toValue); +}; + +var styfn$7 = {}; + +// bypasses are applied to an existing style on an element, and just tacked on temporarily +// returns true iff application was successful for at least 1 specified property +styfn$7.applyBypass = function (eles, name, value, updateTransitions) { + var self = this; + var props = []; + var isBypass = true; + + // put all the properties (can specify one or many) in an array after parsing them + if (name === '*' || name === '**') { + // apply to all property names + + if (value !== undefined) { + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var _name = prop.name; + var parsedProp = this.parse(_name, value, true); + if (parsedProp) { + props.push(parsedProp); + } + } + } + } else if (string(name)) { + // then parse the single property + var _parsedProp = this.parse(name, value, true); + if (_parsedProp) { + props.push(_parsedProp); + } + } else if (plainObject(name)) { + // then parse each property + var specifiedProps = name; + updateTransitions = value; + var names = Object.keys(specifiedProps); + for (var _i = 0; _i < names.length; _i++) { + var _name2 = names[_i]; + var _value = specifiedProps[_name2]; + if (_value === undefined) { + // try camel case name too + _value = specifiedProps[dash2camel(_name2)]; + } + if (_value !== undefined) { + var _parsedProp2 = this.parse(_name2, _value, true); + if (_parsedProp2) { + props.push(_parsedProp2); + } + } + } + } else { + // can't do anything without well defined properties + return false; + } + + // we've failed if there are no valid properties + if (props.length === 0) { + return false; + } + + // now, apply the bypass properties on the elements + var ret = false; // return true if at least one succesful bypass applied + for (var _i2 = 0; _i2 < eles.length; _i2++) { + // for each ele + var ele = eles[_i2]; + var diffProps = {}; + var diffProp = void 0; + for (var j = 0; j < props.length; j++) { + // for each prop + var _prop = props[j]; + if (updateTransitions) { + var prevProp = ele.pstyle(_prop.name); + diffProp = diffProps[_prop.name] = { + prev: prevProp + }; + } + ret = this.applyParsedProperty(ele, copy(_prop)) || ret; + if (updateTransitions) { + diffProp.next = ele.pstyle(_prop.name); + } + } // for props + + if (ret) { + this.updateStyleHints(ele); + } + if (updateTransitions) { + this.updateTransitions(ele, diffProps, isBypass); + } + } // for eles + + return ret; +}; + +// only useful in specific cases like animation +styfn$7.overrideBypass = function (eles, name, value) { + name = camel2dash(name); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var prop = ele._private.style[name]; + var type = this.properties[name].type; + var isColor = type.color; + var isMulti = type.mutiple; + var oldValue = !prop ? null : prop.pfValue != null ? prop.pfValue : prop.value; + if (!prop || !prop.bypass) { + // need a bypass if one doesn't exist + this.applyBypass(ele, name, value); + } else { + prop.value = value; + if (prop.pfValue != null) { + prop.pfValue = value; + } + if (isColor) { + prop.strValue = 'rgb(' + value.join(',') + ')'; + } else if (isMulti) { + prop.strValue = value.join(' '); + } else { + prop.strValue = '' + value; + } + this.updateStyleHints(ele); + } + this.checkTriggers(ele, name, oldValue, value); + } +}; +styfn$7.removeAllBypasses = function (eles, updateTransitions) { + return this.removeBypasses(eles, this.propertyNames, updateTransitions); +}; +styfn$7.removeBypasses = function (eles, props, updateTransitions) { + var isBypass = true; + for (var j = 0; j < eles.length; j++) { + var ele = eles[j]; + var diffProps = {}; + for (var i = 0; i < props.length; i++) { + var name = props[i]; + var prop = this.properties[name]; + var prevProp = ele.pstyle(prop.name); + if (!prevProp || !prevProp.bypass) { + // if a bypass doesn't exist for the prop, nothing needs to be removed + continue; + } + var value = ''; // empty => remove bypass + var parsedProp = this.parse(name, value, true); + var diffProp = diffProps[prop.name] = { + prev: prevProp + }; + this.applyParsedProperty(ele, parsedProp); + diffProp.next = ele.pstyle(prop.name); + } // for props + + this.updateStyleHints(ele); + if (updateTransitions) { + this.updateTransitions(ele, diffProps, isBypass); + } + } // for eles +}; + +var styfn$6 = {}; + +// gets what an em size corresponds to in pixels relative to a dom element +styfn$6.getEmSizeInPixels = function () { + var px = this.containerCss('font-size'); + if (px != null) { + return parseFloat(px); + } else { + return 1; // for headless + } +}; + +// gets css property from the core container +styfn$6.containerCss = function (propName) { + var cy = this._private.cy; + var domElement = cy.container(); + var containerWindow = cy.window(); + if (containerWindow && domElement && containerWindow.getComputedStyle) { + return containerWindow.getComputedStyle(domElement).getPropertyValue(propName); + } +}; + +var styfn$5 = {}; + +// gets the rendered style for an element +styfn$5.getRenderedStyle = function (ele, prop) { + if (prop) { + return this.getStylePropertyValue(ele, prop, true); + } else { + return this.getRawStyle(ele, true); + } +}; + +// gets the raw style for an element +styfn$5.getRawStyle = function (ele, isRenderedVal) { + var self = this; + ele = ele[0]; // insure it's an element + + if (ele) { + var rstyle = {}; + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var val = self.getStylePropertyValue(ele, prop.name, isRenderedVal); + if (val != null) { + rstyle[prop.name] = val; + rstyle[dash2camel(prop.name)] = val; + } + } + return rstyle; + } +}; +styfn$5.getIndexedStyle = function (ele, property, subproperty, index) { + var pstyle = ele.pstyle(property)[subproperty][index]; + return pstyle != null ? pstyle : ele.cy().style().getDefaultProperty(property)[subproperty][0]; +}; +styfn$5.getStylePropertyValue = function (ele, propName, isRenderedVal) { + var self = this; + ele = ele[0]; // insure it's an element + + if (ele) { + var prop = self.properties[propName]; + if (prop.alias) { + prop = prop.pointsTo; + } + var type = prop.type; + var styleProp = ele.pstyle(prop.name); + if (styleProp) { + var value = styleProp.value, + units = styleProp.units, + strValue = styleProp.strValue; + if (isRenderedVal && type.number && value != null && number$1(value)) { + var zoom = ele.cy().zoom(); + var getRenderedValue = function getRenderedValue(val) { + return val * zoom; + }; + var getValueStringWithUnits = function getValueStringWithUnits(val, units) { + return getRenderedValue(val) + units; + }; + var isArrayValue = array(value); + var haveUnits = isArrayValue ? units.every(function (u) { + return u != null; + }) : units != null; + if (haveUnits) { + if (isArrayValue) { + return value.map(function (v, i) { + return getValueStringWithUnits(v, units[i]); + }).join(' '); + } else { + return getValueStringWithUnits(value, units); + } + } else { + if (isArrayValue) { + return value.map(function (v) { + return string(v) ? v : '' + getRenderedValue(v); + }).join(' '); + } else { + return '' + getRenderedValue(value); + } + } + } else if (strValue != null) { + return strValue; + } + } + return null; + } +}; +styfn$5.getAnimationStartStyle = function (ele, aniProps) { + var rstyle = {}; + for (var i = 0; i < aniProps.length; i++) { + var aniProp = aniProps[i]; + var name = aniProp.name; + var styleProp = ele.pstyle(name); + if (styleProp !== undefined) { + // then make a prop of it + if (plainObject(styleProp)) { + styleProp = this.parse(name, styleProp.strValue); + } else { + styleProp = this.parse(name, styleProp); + } + } + if (styleProp) { + rstyle[name] = styleProp; + } + } + return rstyle; +}; +styfn$5.getPropsList = function (propsObj) { + var self = this; + var rstyle = []; + var style = propsObj; + var props = self.properties; + if (style) { + var names = Object.keys(style); + for (var i = 0; i < names.length; i++) { + var name = names[i]; + var val = style[name]; + var prop = props[name] || props[camel2dash(name)]; + var styleProp = this.parse(prop.name, val); + if (styleProp) { + rstyle.push(styleProp); + } + } + } + return rstyle; +}; +styfn$5.getNonDefaultPropertiesHash = function (ele, propNames, seed) { + var hash = seed.slice(); + var name, val, strVal, chVal; + var i, j; + for (i = 0; i < propNames.length; i++) { + name = propNames[i]; + val = ele.pstyle(name, false); + if (val == null) { + continue; + } else if (val.pfValue != null) { + hash[0] = hashInt(chVal, hash[0]); + hash[1] = hashIntAlt(chVal, hash[1]); + } else { + strVal = val.strValue; + for (j = 0; j < strVal.length; j++) { + chVal = strVal.charCodeAt(j); + hash[0] = hashInt(chVal, hash[0]); + hash[1] = hashIntAlt(chVal, hash[1]); + } + } + } + return hash; +}; +styfn$5.getPropertiesHash = styfn$5.getNonDefaultPropertiesHash; + +var styfn$4 = {}; +styfn$4.appendFromJson = function (json) { + var style = this; + for (var i = 0; i < json.length; i++) { + var context = json[i]; + var selector = context.selector; + var props = context.style || context.css; + var names = Object.keys(props); + style.selector(selector); // apply selector + + for (var j = 0; j < names.length; j++) { + var name = names[j]; + var value = props[name]; + style.css(name, value); // apply property + } + } + + return style; +}; + +// accessible cy.style() function +styfn$4.fromJson = function (json) { + var style = this; + style.resetToDefault(); + style.appendFromJson(json); + return style; +}; + +// get json from cy.style() api +styfn$4.json = function () { + var json = []; + for (var i = this.defaultLength; i < this.length; i++) { + var cxt = this[i]; + var selector = cxt.selector; + var props = cxt.properties; + var css = {}; + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + css[prop.name] = prop.strValue; + } + json.push({ + selector: !selector ? 'core' : selector.toString(), + style: css + }); + } + return json; +}; + +var styfn$3 = {}; +styfn$3.appendFromString = function (string) { + var self = this; + var style = this; + var remaining = '' + string; + var selAndBlockStr; + var blockRem; + var propAndValStr; + + // remove comments from the style string + remaining = remaining.replace(/[/][*](\s|.)+?[*][/]/g, ''); + function removeSelAndBlockFromRemaining() { + // remove the parsed selector and block from the remaining text to parse + if (remaining.length > selAndBlockStr.length) { + remaining = remaining.substr(selAndBlockStr.length); + } else { + remaining = ''; + } + } + function removePropAndValFromRem() { + // remove the parsed property and value from the remaining block text to parse + if (blockRem.length > propAndValStr.length) { + blockRem = blockRem.substr(propAndValStr.length); + } else { + blockRem = ''; + } + } + for (;;) { + var nothingLeftToParse = remaining.match(/^\s*$/); + if (nothingLeftToParse) { + break; + } + var selAndBlock = remaining.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/); + if (!selAndBlock) { + warn('Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: ' + remaining); + break; + } + selAndBlockStr = selAndBlock[0]; + + // parse the selector + var selectorStr = selAndBlock[1]; + if (selectorStr !== 'core') { + var selector = new Selector(selectorStr); + if (selector.invalid) { + warn('Skipping parsing of block: Invalid selector found in string stylesheet: ' + selectorStr); + + // skip this selector and block + removeSelAndBlockFromRemaining(); + continue; + } + } + + // parse the block of properties and values + var blockStr = selAndBlock[2]; + var invalidBlock = false; + blockRem = blockStr; + var props = []; + for (;;) { + var _nothingLeftToParse = blockRem.match(/^\s*$/); + if (_nothingLeftToParse) { + break; + } + var propAndVal = blockRem.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/); + if (!propAndVal) { + warn('Skipping parsing of block: Invalid formatting of style property and value definitions found in:' + blockStr); + invalidBlock = true; + break; + } + propAndValStr = propAndVal[0]; + var propStr = propAndVal[1]; + var valStr = propAndVal[2]; + var prop = self.properties[propStr]; + if (!prop) { + warn('Skipping property: Invalid property name in: ' + propAndValStr); + + // skip this property in the block + removePropAndValFromRem(); + continue; + } + var parsedProp = style.parse(propStr, valStr); + if (!parsedProp) { + warn('Skipping property: Invalid property definition in: ' + propAndValStr); + + // skip this property in the block + removePropAndValFromRem(); + continue; + } + props.push({ + name: propStr, + val: valStr + }); + removePropAndValFromRem(); + } + if (invalidBlock) { + removeSelAndBlockFromRemaining(); + break; + } + + // put the parsed block in the style + style.selector(selectorStr); + for (var i = 0; i < props.length; i++) { + var _prop = props[i]; + style.css(_prop.name, _prop.val); + } + removeSelAndBlockFromRemaining(); + } + return style; +}; +styfn$3.fromString = function (string) { + var style = this; + style.resetToDefault(); + style.appendFromString(string); + return style; +}; + +var styfn$2 = {}; +(function () { + var number$1 = number; + var rgba = rgbaNoBackRefs; + var hsla = hslaNoBackRefs; + var hex3$1 = hex3; + var hex6$1 = hex6; + var data = function data(prefix) { + return '^' + prefix + '\\s*\\(\\s*([\\w\\.]+)\\s*\\)$'; + }; + var mapData = function mapData(prefix) { + var mapArg = number$1 + '|\\w+|' + rgba + '|' + hsla + '|' + hex3$1 + '|' + hex6$1; + return '^' + prefix + '\\s*\\(([\\w\\.]+)\\s*\\,\\s*(' + number$1 + ')\\s*\\,\\s*(' + number$1 + ')\\s*,\\s*(' + mapArg + ')\\s*\\,\\s*(' + mapArg + ')\\)$'; + }; + var urlRegexes = ['^url\\s*\\(\\s*[\'"]?(.+?)[\'"]?\\s*\\)$', '^(none)$', '^(.+)$']; + + // each visual style property has a type and needs to be validated according to it + styfn$2.types = { + time: { + number: true, + min: 0, + units: 's|ms', + implicitUnits: 'ms' + }, + percent: { + number: true, + min: 0, + max: 100, + units: '%', + implicitUnits: '%' + }, + percentages: { + number: true, + min: 0, + max: 100, + units: '%', + implicitUnits: '%', + multiple: true + }, + zeroOneNumber: { + number: true, + min: 0, + max: 1, + unitless: true + }, + zeroOneNumbers: { + number: true, + min: 0, + max: 1, + unitless: true, + multiple: true + }, + nOneOneNumber: { + number: true, + min: -1, + max: 1, + unitless: true + }, + nonNegativeInt: { + number: true, + min: 0, + integer: true, + unitless: true + }, + nonNegativeNumber: { + number: true, + min: 0, + unitless: true + }, + position: { + enums: ['parent', 'origin'] + }, + nodeSize: { + number: true, + min: 0, + enums: ['label'] + }, + number: { + number: true, + unitless: true + }, + numbers: { + number: true, + unitless: true, + multiple: true + }, + positiveNumber: { + number: true, + unitless: true, + min: 0, + strictMin: true + }, + size: { + number: true, + min: 0 + }, + bidirectionalSize: { + number: true + }, + // allows negative + bidirectionalSizeMaybePercent: { + number: true, + allowPercent: true + }, + // allows negative + bidirectionalSizes: { + number: true, + multiple: true + }, + // allows negative + sizeMaybePercent: { + number: true, + min: 0, + allowPercent: true + }, + axisDirection: { + enums: ['horizontal', 'leftward', 'rightward', 'vertical', 'upward', 'downward', 'auto'] + }, + paddingRelativeTo: { + enums: ['width', 'height', 'average', 'min', 'max'] + }, + bgWH: { + number: true, + min: 0, + allowPercent: true, + enums: ['auto'], + multiple: true + }, + bgPos: { + number: true, + allowPercent: true, + multiple: true + }, + bgRelativeTo: { + enums: ['inner', 'include-padding'], + multiple: true + }, + bgRepeat: { + enums: ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'], + multiple: true + }, + bgFit: { + enums: ['none', 'contain', 'cover'], + multiple: true + }, + bgCrossOrigin: { + enums: ['anonymous', 'use-credentials', 'null'], + multiple: true + }, + bgClip: { + enums: ['none', 'node'], + multiple: true + }, + bgContainment: { + enums: ['inside', 'over'], + multiple: true + }, + color: { + color: true + }, + colors: { + color: true, + multiple: true + }, + fill: { + enums: ['solid', 'linear-gradient', 'radial-gradient'] + }, + bool: { + enums: ['yes', 'no'] + }, + bools: { + enums: ['yes', 'no'], + multiple: true + }, + lineStyle: { + enums: ['solid', 'dotted', 'dashed'] + }, + lineCap: { + enums: ['butt', 'round', 'square'] + }, + linePosition: { + enums: ['center', 'inside', 'outside'] + }, + lineJoin: { + enums: ['round', 'bevel', 'miter'] + }, + borderStyle: { + enums: ['solid', 'dotted', 'dashed', 'double'] + }, + curveStyle: { + enums: ['bezier', 'unbundled-bezier', 'haystack', 'segments', 'straight', 'straight-triangle', 'taxi', 'round-segments', 'round-taxi'] + }, + radiusType: { + enums: ['arc-radius', 'influence-radius'], + multiple: true + }, + fontFamily: { + regex: '^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$' + }, + fontStyle: { + enums: ['italic', 'normal', 'oblique'] + }, + fontWeight: { + enums: ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '800', '900', 100, 200, 300, 400, 500, 600, 700, 800, 900] + }, + textDecoration: { + enums: ['none', 'underline', 'overline', 'line-through'] + }, + textTransform: { + enums: ['none', 'uppercase', 'lowercase'] + }, + textWrap: { + enums: ['none', 'wrap', 'ellipsis'] + }, + textOverflowWrap: { + enums: ['whitespace', 'anywhere'] + }, + textBackgroundShape: { + enums: ['rectangle', 'roundrectangle', 'round-rectangle'] + }, + nodeShape: { + enums: ['rectangle', 'roundrectangle', 'round-rectangle', 'cutrectangle', 'cut-rectangle', 'bottomroundrectangle', 'bottom-round-rectangle', 'barrel', 'ellipse', 'triangle', 'round-triangle', 'square', 'pentagon', 'round-pentagon', 'hexagon', 'round-hexagon', 'concavehexagon', 'concave-hexagon', 'heptagon', 'round-heptagon', 'octagon', 'round-octagon', 'tag', 'round-tag', 'star', 'diamond', 'round-diamond', 'vee', 'rhomboid', 'right-rhomboid', 'polygon'] + }, + overlayShape: { + enums: ['roundrectangle', 'round-rectangle', 'ellipse'] + }, + cornerRadius: { + number: true, + min: 0, + units: 'px|em', + implicitUnits: 'px', + enums: ['auto'] + }, + compoundIncludeLabels: { + enums: ['include', 'exclude'] + }, + arrowShape: { + enums: ['tee', 'triangle', 'triangle-tee', 'circle-triangle', 'triangle-cross', 'triangle-backcurve', 'vee', 'square', 'circle', 'diamond', 'chevron', 'none'] + }, + arrowFill: { + enums: ['filled', 'hollow'] + }, + arrowWidth: { + number: true, + units: '%|px|em', + implicitUnits: 'px', + enums: ['match-line'] + }, + display: { + enums: ['element', 'none'] + }, + visibility: { + enums: ['hidden', 'visible'] + }, + zCompoundDepth: { + enums: ['bottom', 'orphan', 'auto', 'top'] + }, + zIndexCompare: { + enums: ['auto', 'manual'] + }, + valign: { + enums: ['top', 'center', 'bottom'] + }, + halign: { + enums: ['left', 'center', 'right'] + }, + justification: { + enums: ['left', 'center', 'right', 'auto'] + }, + text: { + string: true + }, + data: { + mapping: true, + regex: data('data') + }, + layoutData: { + mapping: true, + regex: data('layoutData') + }, + scratch: { + mapping: true, + regex: data('scratch') + }, + mapData: { + mapping: true, + regex: mapData('mapData') + }, + mapLayoutData: { + mapping: true, + regex: mapData('mapLayoutData') + }, + mapScratch: { + mapping: true, + regex: mapData('mapScratch') + }, + fn: { + mapping: true, + fn: true + }, + url: { + regexes: urlRegexes, + singleRegexMatchValue: true + }, + urls: { + regexes: urlRegexes, + singleRegexMatchValue: true, + multiple: true + }, + propList: { + propList: true + }, + angle: { + number: true, + units: 'deg|rad', + implicitUnits: 'rad' + }, + textRotation: { + number: true, + units: 'deg|rad', + implicitUnits: 'rad', + enums: ['none', 'autorotate'] + }, + polygonPointList: { + number: true, + multiple: true, + evenMultiple: true, + min: -1, + max: 1, + unitless: true + }, + edgeDistances: { + enums: ['intersection', 'node-position', 'endpoints'] + }, + edgeEndpoint: { + number: true, + multiple: true, + units: '%|px|em|deg|rad', + implicitUnits: 'px', + enums: ['inside-to-node', 'outside-to-node', 'outside-to-node-or-label', 'outside-to-line', 'outside-to-line-or-label'], + singleEnum: true, + validate: function validate(valArr, unitsArr) { + switch (valArr.length) { + case 2: + // can be % or px only + return unitsArr[0] !== 'deg' && unitsArr[0] !== 'rad' && unitsArr[1] !== 'deg' && unitsArr[1] !== 'rad'; + case 1: + // can be enum, deg, or rad only + return string(valArr[0]) || unitsArr[0] === 'deg' || unitsArr[0] === 'rad'; + default: + return false; + } + } + }, + easing: { + regexes: ['^(spring)\\s*\\(\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*\\)$', '^(cubic-bezier)\\s*\\(\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*\\)$'], + enums: ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'ease-in-sine', 'ease-out-sine', 'ease-in-out-sine', 'ease-in-quad', 'ease-out-quad', 'ease-in-out-quad', 'ease-in-cubic', 'ease-out-cubic', 'ease-in-out-cubic', 'ease-in-quart', 'ease-out-quart', 'ease-in-out-quart', 'ease-in-quint', 'ease-out-quint', 'ease-in-out-quint', 'ease-in-expo', 'ease-out-expo', 'ease-in-out-expo', 'ease-in-circ', 'ease-out-circ', 'ease-in-out-circ'] + }, + gradientDirection: { + enums: ['to-bottom', 'to-top', 'to-left', 'to-right', 'to-bottom-right', 'to-bottom-left', 'to-top-right', 'to-top-left', 'to-right-bottom', 'to-left-bottom', 'to-right-top', 'to-left-top' // different order + ] + }, + + boundsExpansion: { + number: true, + multiple: true, + min: 0, + validate: function validate(valArr) { + var length = valArr.length; + return length === 1 || length === 2 || length === 4; + } + } + }; + var diff = { + zeroNonZero: function zeroNonZero(val1, val2) { + if ((val1 == null || val2 == null) && val1 !== val2) { + return true; // null cases could represent any value + } + if (val1 == 0 && val2 != 0) { + return true; + } else if (val1 != 0 && val2 == 0) { + return true; + } else { + return false; + } + }, + any: function any(val1, val2) { + return val1 != val2; + }, + emptyNonEmpty: function emptyNonEmpty(str1, str2) { + var empty1 = emptyString(str1); + var empty2 = emptyString(str2); + return empty1 && !empty2 || !empty1 && empty2; + } + }; + + // define visual style properties + // + // - n.b. adding a new group of props may require updates to updateStyleHints() + // - adding new props to an existing group gets handled automatically + + var t = styfn$2.types; + var mainLabel = [{ + name: 'label', + type: t.text, + triggersBounds: diff.any, + triggersZOrder: diff.emptyNonEmpty + }, { + name: 'text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }]; + var sourceLabel = [{ + name: 'source-label', + type: t.text, + triggersBounds: diff.any + }, { + name: 'source-text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'source-text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'source-text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'source-text-offset', + type: t.size, + triggersBounds: diff.any + }]; + var targetLabel = [{ + name: 'target-label', + type: t.text, + triggersBounds: diff.any + }, { + name: 'target-text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'target-text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'target-text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'target-text-offset', + type: t.size, + triggersBounds: diff.any + }]; + var labelDimensions = [{ + name: 'font-family', + type: t.fontFamily, + triggersBounds: diff.any + }, { + name: 'font-style', + type: t.fontStyle, + triggersBounds: diff.any + }, { + name: 'font-weight', + type: t.fontWeight, + triggersBounds: diff.any + }, { + name: 'font-size', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-transform', + type: t.textTransform, + triggersBounds: diff.any + }, { + name: 'text-wrap', + type: t.textWrap, + triggersBounds: diff.any + }, { + name: 'text-overflow-wrap', + type: t.textOverflowWrap, + triggersBounds: diff.any + }, { + name: 'text-max-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-outline-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'line-height', + type: t.positiveNumber, + triggersBounds: diff.any + }]; + var commonLabel = [{ + name: 'text-valign', + type: t.valign, + triggersBounds: diff.any + }, { + name: 'text-halign', + type: t.halign, + triggersBounds: diff.any + }, { + name: 'color', + type: t.color + }, { + name: 'text-outline-color', + type: t.color + }, { + name: 'text-outline-opacity', + type: t.zeroOneNumber + }, { + name: 'text-background-color', + type: t.color + }, { + name: 'text-background-opacity', + type: t.zeroOneNumber + }, { + name: 'text-background-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-border-opacity', + type: t.zeroOneNumber + }, { + name: 'text-border-color', + type: t.color + }, { + name: 'text-border-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-border-style', + type: t.borderStyle, + triggersBounds: diff.any + }, { + name: 'text-background-shape', + type: t.textBackgroundShape, + triggersBounds: diff.any + }, { + name: 'text-justification', + type: t.justification + }]; + var behavior = [{ + name: 'events', + type: t.bool, + triggersZOrder: diff.any + }, { + name: 'text-events', + type: t.bool, + triggersZOrder: diff.any + }]; + var visibility = [{ + name: 'display', + type: t.display, + triggersZOrder: diff.any, + triggersBounds: diff.any, + triggersBoundsOfConnectedEdges: true + }, { + name: 'visibility', + type: t.visibility, + triggersZOrder: diff.any + }, { + name: 'opacity', + type: t.zeroOneNumber, + triggersZOrder: diff.zeroNonZero + }, { + name: 'text-opacity', + type: t.zeroOneNumber + }, { + name: 'min-zoomed-font-size', + type: t.size + }, { + name: 'z-compound-depth', + type: t.zCompoundDepth, + triggersZOrder: diff.any + }, { + name: 'z-index-compare', + type: t.zIndexCompare, + triggersZOrder: diff.any + }, { + name: 'z-index', + type: t.number, + triggersZOrder: diff.any + }]; + var overlay = [{ + name: 'overlay-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'overlay-color', + type: t.color + }, { + name: 'overlay-opacity', + type: t.zeroOneNumber, + triggersBounds: diff.zeroNonZero + }, { + name: 'overlay-shape', + type: t.overlayShape, + triggersBounds: diff.any + }, { + name: 'overlay-corner-radius', + type: t.cornerRadius + }]; + var underlay = [{ + name: 'underlay-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'underlay-color', + type: t.color + }, { + name: 'underlay-opacity', + type: t.zeroOneNumber, + triggersBounds: diff.zeroNonZero + }, { + name: 'underlay-shape', + type: t.overlayShape, + triggersBounds: diff.any + }, { + name: 'underlay-corner-radius', + type: t.cornerRadius + }]; + var transition = [{ + name: 'transition-property', + type: t.propList + }, { + name: 'transition-duration', + type: t.time + }, { + name: 'transition-delay', + type: t.time + }, { + name: 'transition-timing-function', + type: t.easing + }]; + var nodeSizeHashOverride = function nodeSizeHashOverride(ele, parsedProp) { + if (parsedProp.value === 'label') { + return -ele.poolIndex(); // no hash key hits is using label size (hitrate for perf probably low anyway) + } else { + return parsedProp.pfValue; + } + }; + var nodeBody = [{ + name: 'height', + type: t.nodeSize, + triggersBounds: diff.any, + hashOverride: nodeSizeHashOverride + }, { + name: 'width', + type: t.nodeSize, + triggersBounds: diff.any, + hashOverride: nodeSizeHashOverride + }, { + name: 'shape', + type: t.nodeShape, + triggersBounds: diff.any + }, { + name: 'shape-polygon-points', + type: t.polygonPointList, + triggersBounds: diff.any + }, { + name: 'corner-radius', + type: t.cornerRadius + }, { + name: 'background-color', + type: t.color + }, { + name: 'background-fill', + type: t.fill + }, { + name: 'background-opacity', + type: t.zeroOneNumber + }, { + name: 'background-blacken', + type: t.nOneOneNumber + }, { + name: 'background-gradient-stop-colors', + type: t.colors + }, { + name: 'background-gradient-stop-positions', + type: t.percentages + }, { + name: 'background-gradient-direction', + type: t.gradientDirection + }, { + name: 'padding', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'padding-relative-to', + type: t.paddingRelativeTo, + triggersBounds: diff.any + }, { + name: 'bounds-expansion', + type: t.boundsExpansion, + triggersBounds: diff.any + }]; + var nodeBorder = [{ + name: 'border-color', + type: t.color + }, { + name: 'border-opacity', + type: t.zeroOneNumber + }, { + name: 'border-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'border-style', + type: t.borderStyle + }, { + name: 'border-cap', + type: t.lineCap + }, { + name: 'border-join', + type: t.lineJoin + }, { + name: 'border-dash-pattern', + type: t.numbers + }, { + name: 'border-dash-offset', + type: t.number + }, { + name: 'border-position', + type: t.linePosition + }]; + var nodeOutline = [{ + name: 'outline-color', + type: t.color + }, { + name: 'outline-opacity', + type: t.zeroOneNumber + }, { + name: 'outline-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'outline-style', + type: t.borderStyle + }, { + name: 'outline-offset', + type: t.size, + triggersBounds: diff.any + }]; + var backgroundImage = [{ + name: 'background-image', + type: t.urls + }, { + name: 'background-image-crossorigin', + type: t.bgCrossOrigin + }, { + name: 'background-image-opacity', + type: t.zeroOneNumbers + }, { + name: 'background-image-containment', + type: t.bgContainment + }, { + name: 'background-image-smoothing', + type: t.bools + }, { + name: 'background-position-x', + type: t.bgPos + }, { + name: 'background-position-y', + type: t.bgPos + }, { + name: 'background-width-relative-to', + type: t.bgRelativeTo + }, { + name: 'background-height-relative-to', + type: t.bgRelativeTo + }, { + name: 'background-repeat', + type: t.bgRepeat + }, { + name: 'background-fit', + type: t.bgFit + }, { + name: 'background-clip', + type: t.bgClip + }, { + name: 'background-width', + type: t.bgWH + }, { + name: 'background-height', + type: t.bgWH + }, { + name: 'background-offset-x', + type: t.bgPos + }, { + name: 'background-offset-y', + type: t.bgPos + }]; + var compound = [{ + name: 'position', + type: t.position, + triggersBounds: diff.any + }, { + name: 'compound-sizing-wrt-labels', + type: t.compoundIncludeLabels, + triggersBounds: diff.any + }, { + name: 'min-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'min-width-bias-left', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-width-bias-right', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-height', + type: t.size, + triggersBounds: diff.any + }, { + name: 'min-height-bias-top', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-height-bias-bottom', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }]; + var edgeLine = [{ + name: 'line-style', + type: t.lineStyle + }, { + name: 'line-color', + type: t.color + }, { + name: 'line-fill', + type: t.fill + }, { + name: 'line-cap', + type: t.lineCap + }, { + name: 'line-opacity', + type: t.zeroOneNumber + }, { + name: 'line-dash-pattern', + type: t.numbers + }, { + name: 'line-dash-offset', + type: t.number + }, { + name: 'line-gradient-stop-colors', + type: t.colors + }, { + name: 'line-gradient-stop-positions', + type: t.percentages + }, { + name: 'curve-style', + type: t.curveStyle, + triggersBounds: diff.any, + triggersBoundsOfParallelBeziers: true + }, { + name: 'haystack-radius', + type: t.zeroOneNumber, + triggersBounds: diff.any + }, { + name: 'source-endpoint', + type: t.edgeEndpoint, + triggersBounds: diff.any + }, { + name: 'target-endpoint', + type: t.edgeEndpoint, + triggersBounds: diff.any + }, { + name: 'control-point-step-size', + type: t.size, + triggersBounds: diff.any + }, { + name: 'control-point-distances', + type: t.bidirectionalSizes, + triggersBounds: diff.any + }, { + name: 'control-point-weights', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'segment-distances', + type: t.bidirectionalSizes, + triggersBounds: diff.any + }, { + name: 'segment-weights', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'segment-radii', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'radius-type', + type: t.radiusType, + triggersBounds: diff.any + }, { + name: 'taxi-turn', + type: t.bidirectionalSizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'taxi-turn-min-distance', + type: t.size, + triggersBounds: diff.any + }, { + name: 'taxi-direction', + type: t.axisDirection, + triggersBounds: diff.any + }, { + name: 'taxi-radius', + type: t.number, + triggersBounds: diff.any + }, { + name: 'edge-distances', + type: t.edgeDistances, + triggersBounds: diff.any + }, { + name: 'arrow-scale', + type: t.positiveNumber, + triggersBounds: diff.any + }, { + name: 'loop-direction', + type: t.angle, + triggersBounds: diff.any + }, { + name: 'loop-sweep', + type: t.angle, + triggersBounds: diff.any + }, { + name: 'source-distance-from-node', + type: t.size, + triggersBounds: diff.any + }, { + name: 'target-distance-from-node', + type: t.size, + triggersBounds: diff.any + }]; + var ghost = [{ + name: 'ghost', + type: t.bool, + triggersBounds: diff.any + }, { + name: 'ghost-offset-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'ghost-offset-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'ghost-opacity', + type: t.zeroOneNumber + }]; + var core = [{ + name: 'selection-box-color', + type: t.color + }, { + name: 'selection-box-opacity', + type: t.zeroOneNumber + }, { + name: 'selection-box-border-color', + type: t.color + }, { + name: 'selection-box-border-width', + type: t.size + }, { + name: 'active-bg-color', + type: t.color + }, { + name: 'active-bg-opacity', + type: t.zeroOneNumber + }, { + name: 'active-bg-size', + type: t.size + }, { + name: 'outside-texture-bg-color', + type: t.color + }, { + name: 'outside-texture-bg-opacity', + type: t.zeroOneNumber + }]; + + // pie backgrounds for nodes + var pie = []; + styfn$2.pieBackgroundN = 16; // because the pie properties are numbered, give access to a constant N (for renderer use) + pie.push({ + name: 'pie-size', + type: t.sizeMaybePercent + }); + for (var i = 1; i <= styfn$2.pieBackgroundN; i++) { + pie.push({ + name: 'pie-' + i + '-background-color', + type: t.color + }); + pie.push({ + name: 'pie-' + i + '-background-size', + type: t.percent + }); + pie.push({ + name: 'pie-' + i + '-background-opacity', + type: t.zeroOneNumber + }); + } + + // edge arrows + var edgeArrow = []; + var arrowPrefixes = styfn$2.arrowPrefixes = ['source', 'mid-source', 'target', 'mid-target']; + [{ + name: 'arrow-shape', + type: t.arrowShape, + triggersBounds: diff.any + }, { + name: 'arrow-color', + type: t.color + }, { + name: 'arrow-fill', + type: t.arrowFill + }, { + name: 'arrow-width', + type: t.arrowWidth + }].forEach(function (prop) { + arrowPrefixes.forEach(function (prefix) { + var name = prefix + '-' + prop.name; + var type = prop.type, + triggersBounds = prop.triggersBounds; + edgeArrow.push({ + name: name, + type: type, + triggersBounds: triggersBounds + }); + }); + }, {}); + var props = styfn$2.properties = [].concat(behavior, transition, visibility, overlay, underlay, ghost, commonLabel, labelDimensions, mainLabel, sourceLabel, targetLabel, nodeBody, nodeBorder, nodeOutline, backgroundImage, pie, compound, edgeLine, edgeArrow, core); + var propGroups = styfn$2.propertyGroups = { + // common to all eles + behavior: behavior, + transition: transition, + visibility: visibility, + overlay: overlay, + underlay: underlay, + ghost: ghost, + // labels + commonLabel: commonLabel, + labelDimensions: labelDimensions, + mainLabel: mainLabel, + sourceLabel: sourceLabel, + targetLabel: targetLabel, + // node props + nodeBody: nodeBody, + nodeBorder: nodeBorder, + nodeOutline: nodeOutline, + backgroundImage: backgroundImage, + pie: pie, + compound: compound, + // edge props + edgeLine: edgeLine, + edgeArrow: edgeArrow, + core: core + }; + var propGroupNames = styfn$2.propertyGroupNames = {}; + var propGroupKeys = styfn$2.propertyGroupKeys = Object.keys(propGroups); + propGroupKeys.forEach(function (key) { + propGroupNames[key] = propGroups[key].map(function (prop) { + return prop.name; + }); + propGroups[key].forEach(function (prop) { + return prop.groupKey = key; + }); + }); + + // define aliases + var aliases = styfn$2.aliases = [{ + name: 'content', + pointsTo: 'label' + }, { + name: 'control-point-distance', + pointsTo: 'control-point-distances' + }, { + name: 'control-point-weight', + pointsTo: 'control-point-weights' + }, { + name: 'segment-distance', + pointsTo: 'segment-distances' + }, { + name: 'segment-weight', + pointsTo: 'segment-weights' + }, { + name: 'segment-radius', + pointsTo: 'segment-radii' + }, { + name: 'edge-text-rotation', + pointsTo: 'text-rotation' + }, { + name: 'padding-left', + pointsTo: 'padding' + }, { + name: 'padding-right', + pointsTo: 'padding' + }, { + name: 'padding-top', + pointsTo: 'padding' + }, { + name: 'padding-bottom', + pointsTo: 'padding' + }]; + + // list of property names + styfn$2.propertyNames = props.map(function (p) { + return p.name; + }); + + // allow access of properties by name ( e.g. style.properties.height ) + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + props[prop.name] = prop; // allow lookup by name + } + + // map aliases + for (var _i2 = 0; _i2 < aliases.length; _i2++) { + var alias = aliases[_i2]; + var pointsToProp = props[alias.pointsTo]; + var aliasProp = { + name: alias.name, + alias: true, + pointsTo: pointsToProp + }; + + // add alias prop for parsing + props.push(aliasProp); + props[alias.name] = aliasProp; // allow lookup by name + } +})(); + +styfn$2.getDefaultProperty = function (name) { + return this.getDefaultProperties()[name]; +}; +styfn$2.getDefaultProperties = function () { + var _p = this._private; + if (_p.defaultProperties != null) { + return _p.defaultProperties; + } + var rawProps = extend({ + // core props + 'selection-box-color': '#ddd', + 'selection-box-opacity': 0.65, + 'selection-box-border-color': '#aaa', + 'selection-box-border-width': 1, + 'active-bg-color': 'black', + 'active-bg-opacity': 0.15, + 'active-bg-size': 30, + 'outside-texture-bg-color': '#000', + 'outside-texture-bg-opacity': 0.125, + // common node/edge props + 'events': 'yes', + 'text-events': 'no', + 'text-valign': 'top', + 'text-halign': 'center', + 'text-justification': 'auto', + 'line-height': 1, + 'color': '#000', + 'text-outline-color': '#000', + 'text-outline-width': 0, + 'text-outline-opacity': 1, + 'text-opacity': 1, + 'text-decoration': 'none', + 'text-transform': 'none', + 'text-wrap': 'none', + 'text-overflow-wrap': 'whitespace', + 'text-max-width': 9999, + 'text-background-color': '#000', + 'text-background-opacity': 0, + 'text-background-shape': 'rectangle', + 'text-background-padding': 0, + 'text-border-opacity': 0, + 'text-border-width': 0, + 'text-border-style': 'solid', + 'text-border-color': '#000', + 'font-family': 'Helvetica Neue, Helvetica, sans-serif', + 'font-style': 'normal', + 'font-weight': 'normal', + 'font-size': 16, + 'min-zoomed-font-size': 0, + 'text-rotation': 'none', + 'source-text-rotation': 'none', + 'target-text-rotation': 'none', + 'visibility': 'visible', + 'display': 'element', + 'opacity': 1, + 'z-compound-depth': 'auto', + 'z-index-compare': 'auto', + 'z-index': 0, + 'label': '', + 'text-margin-x': 0, + 'text-margin-y': 0, + 'source-label': '', + 'source-text-offset': 0, + 'source-text-margin-x': 0, + 'source-text-margin-y': 0, + 'target-label': '', + 'target-text-offset': 0, + 'target-text-margin-x': 0, + 'target-text-margin-y': 0, + 'overlay-opacity': 0, + 'overlay-color': '#000', + 'overlay-padding': 10, + 'overlay-shape': 'round-rectangle', + 'overlay-corner-radius': 'auto', + 'underlay-opacity': 0, + 'underlay-color': '#000', + 'underlay-padding': 10, + 'underlay-shape': 'round-rectangle', + 'underlay-corner-radius': 'auto', + 'transition-property': 'none', + 'transition-duration': 0, + 'transition-delay': 0, + 'transition-timing-function': 'linear', + // node props + 'background-blacken': 0, + 'background-color': '#999', + 'background-fill': 'solid', + 'background-opacity': 1, + 'background-image': 'none', + 'background-image-crossorigin': 'anonymous', + 'background-image-opacity': 1, + 'background-image-containment': 'inside', + 'background-image-smoothing': 'yes', + 'background-position-x': '50%', + 'background-position-y': '50%', + 'background-offset-x': 0, + 'background-offset-y': 0, + 'background-width-relative-to': 'include-padding', + 'background-height-relative-to': 'include-padding', + 'background-repeat': 'no-repeat', + 'background-fit': 'none', + 'background-clip': 'node', + 'background-width': 'auto', + 'background-height': 'auto', + 'border-color': '#000', + 'border-opacity': 1, + 'border-width': 0, + 'border-style': 'solid', + 'border-dash-pattern': [4, 2], + 'border-dash-offset': 0, + 'border-cap': 'butt', + 'border-join': 'miter', + 'border-position': 'center', + 'outline-color': '#999', + 'outline-opacity': 1, + 'outline-width': 0, + 'outline-offset': 0, + 'outline-style': 'solid', + 'height': 30, + 'width': 30, + 'shape': 'ellipse', + 'shape-polygon-points': '-1, -1, 1, -1, 1, 1, -1, 1', + 'corner-radius': 'auto', + 'bounds-expansion': 0, + // node gradient + 'background-gradient-direction': 'to-bottom', + 'background-gradient-stop-colors': '#999', + 'background-gradient-stop-positions': '0%', + // ghost props + 'ghost': 'no', + 'ghost-offset-y': 0, + 'ghost-offset-x': 0, + 'ghost-opacity': 0, + // compound props + 'padding': 0, + 'padding-relative-to': 'width', + 'position': 'origin', + 'compound-sizing-wrt-labels': 'include', + 'min-width': 0, + 'min-width-bias-left': 0, + 'min-width-bias-right': 0, + 'min-height': 0, + 'min-height-bias-top': 0, + 'min-height-bias-bottom': 0 + }, { + // node pie bg + 'pie-size': '100%' + }, [{ + name: 'pie-{{i}}-background-color', + value: 'black' + }, { + name: 'pie-{{i}}-background-size', + value: '0%' + }, { + name: 'pie-{{i}}-background-opacity', + value: 1 + }].reduce(function (css, prop) { + for (var i = 1; i <= styfn$2.pieBackgroundN; i++) { + var name = prop.name.replace('{{i}}', i); + var val = prop.value; + css[name] = val; + } + return css; + }, {}), { + // edge props + 'line-style': 'solid', + 'line-color': '#999', + 'line-fill': 'solid', + 'line-cap': 'butt', + 'line-opacity': 1, + 'line-gradient-stop-colors': '#999', + 'line-gradient-stop-positions': '0%', + 'control-point-step-size': 40, + 'control-point-weights': 0.5, + 'segment-weights': 0.5, + 'segment-distances': 20, + 'segment-radii': 15, + 'radius-type': 'arc-radius', + 'taxi-turn': '50%', + 'taxi-radius': 15, + 'taxi-turn-min-distance': 10, + 'taxi-direction': 'auto', + 'edge-distances': 'intersection', + 'curve-style': 'haystack', + 'haystack-radius': 0, + 'arrow-scale': 1, + 'loop-direction': '-45deg', + 'loop-sweep': '-90deg', + 'source-distance-from-node': 0, + 'target-distance-from-node': 0, + 'source-endpoint': 'outside-to-node', + 'target-endpoint': 'outside-to-node', + 'line-dash-pattern': [6, 3], + 'line-dash-offset': 0 + }, [{ + name: 'arrow-shape', + value: 'none' + }, { + name: 'arrow-color', + value: '#999' + }, { + name: 'arrow-fill', + value: 'filled' + }, { + name: 'arrow-width', + value: 1 + }].reduce(function (css, prop) { + styfn$2.arrowPrefixes.forEach(function (prefix) { + var name = prefix + '-' + prop.name; + var val = prop.value; + css[name] = val; + }); + return css; + }, {})); + var parsedProps = {}; + for (var i = 0; i < this.properties.length; i++) { + var prop = this.properties[i]; + if (prop.pointsTo) { + continue; + } + var name = prop.name; + var val = rawProps[name]; + var parsedProp = this.parse(name, val); + parsedProps[name] = parsedProp; + } + _p.defaultProperties = parsedProps; + return _p.defaultProperties; +}; +styfn$2.addDefaultStylesheet = function () { + this.selector(':parent').css({ + 'shape': 'rectangle', + 'padding': 10, + 'background-color': '#eee', + 'border-color': '#ccc', + 'border-width': 1 + }).selector('edge').css({ + 'width': 3 + }).selector(':loop').css({ + 'curve-style': 'bezier' + }).selector('edge:compound').css({ + 'curve-style': 'bezier', + 'source-endpoint': 'outside-to-line', + 'target-endpoint': 'outside-to-line' + }).selector(':selected').css({ + 'background-color': '#0169D9', + 'line-color': '#0169D9', + 'source-arrow-color': '#0169D9', + 'target-arrow-color': '#0169D9', + 'mid-source-arrow-color': '#0169D9', + 'mid-target-arrow-color': '#0169D9' + }).selector(':parent:selected').css({ + 'background-color': '#CCE1F9', + 'border-color': '#aec8e5' + }).selector(':active').css({ + 'overlay-color': 'black', + 'overlay-padding': 10, + 'overlay-opacity': 0.25 + }); + this.defaultLength = this.length; +}; + +var styfn$1 = {}; + +// a caching layer for property parsing +styfn$1.parse = function (name, value, propIsBypass, propIsFlat) { + var self = this; + + // function values can't be cached in all cases, and there isn't much benefit of caching them anyway + if (fn$6(value)) { + return self.parseImplWarn(name, value, propIsBypass, propIsFlat); + } + var flatKey = propIsFlat === 'mapping' || propIsFlat === true || propIsFlat === false || propIsFlat == null ? 'dontcare' : propIsFlat; + var bypassKey = propIsBypass ? 't' : 'f'; + var valueKey = '' + value; + var argHash = hashStrings(name, valueKey, bypassKey, flatKey); + var propCache = self.propCache = self.propCache || []; + var ret; + if (!(ret = propCache[argHash])) { + ret = propCache[argHash] = self.parseImplWarn(name, value, propIsBypass, propIsFlat); + } + + // - bypasses can't be shared b/c the value can be changed by animations or otherwise overridden + // - mappings can't be shared b/c mappings are per-element + if (propIsBypass || propIsFlat === 'mapping') { + // need a copy since props are mutated later in their lifecycles + ret = copy(ret); + if (ret) { + ret.value = copy(ret.value); // because it could be an array, e.g. colour + } + } + + return ret; +}; +styfn$1.parseImplWarn = function (name, value, propIsBypass, propIsFlat) { + var prop = this.parseImpl(name, value, propIsBypass, propIsFlat); + if (!prop && value != null) { + warn("The style property `".concat(name, ": ").concat(value, "` is invalid")); + } + if (prop && (prop.name === 'width' || prop.name === 'height') && value === 'label') { + warn('The style value of `label` is deprecated for `' + prop.name + '`'); + } + return prop; +}; + +// parse a property; return null on invalid; return parsed property otherwise +// fields : +// - name : the name of the property +// - value : the parsed, native-typed value of the property +// - strValue : a string value that represents the property value in valid css +// - bypass : true iff the property is a bypass property +styfn$1.parseImpl = function (name, value, propIsBypass, propIsFlat) { + var self = this; + name = camel2dash(name); // make sure the property name is in dash form (e.g. 'property-name' not 'propertyName') + + var property = self.properties[name]; + var passedValue = value; + var types = self.types; + if (!property) { + return null; + } // return null on property of unknown name + if (value === undefined) { + return null; + } // can't assign undefined + + // the property may be an alias + if (property.alias) { + property = property.pointsTo; + name = property.name; + } + var valueIsString = string(value); + if (valueIsString) { + // trim the value to make parsing easier + value = value.trim(); + } + var type = property.type; + if (!type) { + return null; + } // no type, no luck + + // check if bypass is null or empty string (i.e. indication to delete bypass property) + if (propIsBypass && (value === '' || value === null)) { + return { + name: name, + value: value, + bypass: true, + deleteBypass: true + }; + } + + // check if value is a function used as a mapper + if (fn$6(value)) { + return { + name: name, + value: value, + strValue: 'fn', + mapped: types.fn, + bypass: propIsBypass + }; + } + + // check if value is mapped + var data, mapData; + if (!valueIsString || propIsFlat || value.length < 7 || value[1] !== 'a') ; else if (value.length >= 7 && value[0] === 'd' && (data = new RegExp(types.data.regex).exec(value))) { + if (propIsBypass) { + return false; + } // mappers not allowed in bypass + + var mapped = types.data; + return { + name: name, + value: data, + strValue: '' + value, + mapped: mapped, + field: data[1], + bypass: propIsBypass + }; + } else if (value.length >= 10 && value[0] === 'm' && (mapData = new RegExp(types.mapData.regex).exec(value))) { + if (propIsBypass) { + return false; + } // mappers not allowed in bypass + if (type.multiple) { + return false; + } // impossible to map to num + + var _mapped = types.mapData; + + // we can map only if the type is a colour or a number + if (!(type.color || type.number)) { + return false; + } + var valueMin = this.parse(name, mapData[4]); // parse to validate + if (!valueMin || valueMin.mapped) { + return false; + } // can't be invalid or mapped + + var valueMax = this.parse(name, mapData[5]); // parse to validate + if (!valueMax || valueMax.mapped) { + return false; + } // can't be invalid or mapped + + // check if valueMin and valueMax are the same + if (valueMin.pfValue === valueMax.pfValue || valueMin.strValue === valueMax.strValue) { + warn('`' + name + ': ' + value + '` is not a valid mapper because the output range is zero; converting to `' + name + ': ' + valueMin.strValue + '`'); + return this.parse(name, valueMin.strValue); // can't make much of a mapper without a range + } else if (type.color) { + var c1 = valueMin.value; + var c2 = valueMax.value; + var same = c1[0] === c2[0] // red + && c1[1] === c2[1] // green + && c1[2] === c2[2] // blue + && ( + // optional alpha + c1[3] === c2[3] // same alpha outright + || (c1[3] == null || c1[3] === 1 // full opacity for colour 1? + ) && (c2[3] == null || c2[3] === 1) // full opacity for colour 2? + ); + + if (same) { + return false; + } // can't make a mapper without a range + } + + return { + name: name, + value: mapData, + strValue: '' + value, + mapped: _mapped, + field: mapData[1], + fieldMin: parseFloat(mapData[2]), + // min & max are numeric + fieldMax: parseFloat(mapData[3]), + valueMin: valueMin.value, + valueMax: valueMax.value, + bypass: propIsBypass + }; + } + if (type.multiple && propIsFlat !== 'multiple') { + var vals; + if (valueIsString) { + vals = value.split(/\s+/); + } else if (array(value)) { + vals = value; + } else { + vals = [value]; + } + if (type.evenMultiple && vals.length % 2 !== 0) { + return null; + } + var valArr = []; + var unitsArr = []; + var pfValArr = []; + var strVal = ''; + var hasEnum = false; + for (var i = 0; i < vals.length; i++) { + var p = self.parse(name, vals[i], propIsBypass, 'multiple'); + hasEnum = hasEnum || string(p.value); + valArr.push(p.value); + pfValArr.push(p.pfValue != null ? p.pfValue : p.value); + unitsArr.push(p.units); + strVal += (i > 0 ? ' ' : '') + p.strValue; + } + if (type.validate && !type.validate(valArr, unitsArr)) { + return null; + } + if (type.singleEnum && hasEnum) { + if (valArr.length === 1 && string(valArr[0])) { + return { + name: name, + value: valArr[0], + strValue: valArr[0], + bypass: propIsBypass + }; + } else { + return null; + } + } + return { + name: name, + value: valArr, + pfValue: pfValArr, + strValue: strVal, + bypass: propIsBypass, + units: unitsArr + }; + } + + // several types also allow enums + var checkEnums = function checkEnums() { + for (var _i = 0; _i < type.enums.length; _i++) { + var en = type.enums[_i]; + if (en === value) { + return { + name: name, + value: value, + strValue: '' + value, + bypass: propIsBypass + }; + } + } + return null; + }; + + // check the type and return the appropriate object + if (type.number) { + var units; + var implicitUnits = 'px'; // not set => px + + if (type.units) { + // use specified units if set + units = type.units; + } + if (type.implicitUnits) { + implicitUnits = type.implicitUnits; + } + if (!type.unitless) { + if (valueIsString) { + var unitsRegex = 'px|em' + (type.allowPercent ? '|\\%' : ''); + if (units) { + unitsRegex = units; + } // only allow explicit units if so set + var match = value.match('^(' + number + ')(' + unitsRegex + ')?' + '$'); + if (match) { + value = match[1]; + units = match[2] || implicitUnits; + } + } else if (!units || type.implicitUnits) { + units = implicitUnits; // implicitly px if unspecified + } + } + + value = parseFloat(value); + + // if not a number and enums not allowed, then the value is invalid + if (isNaN(value) && type.enums === undefined) { + return null; + } + + // check if this number type also accepts special keywords in place of numbers + // (i.e. `left`, `auto`, etc) + if (isNaN(value) && type.enums !== undefined) { + value = passedValue; + return checkEnums(); + } + + // check if value must be an integer + if (type.integer && !integer(value)) { + return null; + } + + // check value is within range + if (type.min !== undefined && (value < type.min || type.strictMin && value === type.min) || type.max !== undefined && (value > type.max || type.strictMax && value === type.max)) { + return null; + } + var ret = { + name: name, + value: value, + strValue: '' + value + (units ? units : ''), + units: units, + bypass: propIsBypass + }; + + // normalise value in pixels + if (type.unitless || units !== 'px' && units !== 'em') { + ret.pfValue = value; + } else { + ret.pfValue = units === 'px' || !units ? value : this.getEmSizeInPixels() * value; + } + + // normalise value in ms + if (units === 'ms' || units === 's') { + ret.pfValue = units === 'ms' ? value : 1000 * value; + } + + // normalise value in rad + if (units === 'deg' || units === 'rad') { + ret.pfValue = units === 'rad' ? value : deg2rad(value); + } + + // normalize value in % + if (units === '%') { + ret.pfValue = value / 100; + } + return ret; + } else if (type.propList) { + var props = []; + var propsStr = '' + value; + if (propsStr === 'none') ; else { + // go over each prop + + var propsSplit = propsStr.split(/\s*,\s*|\s+/); + for (var _i2 = 0; _i2 < propsSplit.length; _i2++) { + var propName = propsSplit[_i2].trim(); + if (self.properties[propName]) { + props.push(propName); + } else { + warn('`' + propName + '` is not a valid property name'); + } + } + if (props.length === 0) { + return null; + } + } + return { + name: name, + value: props, + strValue: props.length === 0 ? 'none' : props.join(' '), + bypass: propIsBypass + }; + } else if (type.color) { + var tuple = color2tuple(value); + if (!tuple) { + return null; + } + return { + name: name, + value: tuple, + pfValue: tuple, + strValue: 'rgb(' + tuple[0] + ',' + tuple[1] + ',' + tuple[2] + ')', + // n.b. no spaces b/c of multiple support + bypass: propIsBypass + }; + } else if (type.regex || type.regexes) { + // first check enums + if (type.enums) { + var enumProp = checkEnums(); + if (enumProp) { + return enumProp; + } + } + var regexes = type.regexes ? type.regexes : [type.regex]; + for (var _i3 = 0; _i3 < regexes.length; _i3++) { + var regex = new RegExp(regexes[_i3]); // make a regex from the type string + var m = regex.exec(value); + if (m) { + // regex matches + return { + name: name, + value: type.singleRegexMatchValue ? m[1] : m, + strValue: '' + value, + bypass: propIsBypass + }; + } + } + return null; // didn't match any + } else if (type.string) { + // just return + return { + name: name, + value: '' + value, + strValue: '' + value, + bypass: propIsBypass + }; + } else if (type.enums) { + // check enums last because it's a combo type in others + return checkEnums(); + } else { + return null; // not a type we can handle + } +}; + +var Style = function Style(cy) { + if (!(this instanceof Style)) { + return new Style(cy); + } + if (!core(cy)) { + error('A style must have a core reference'); + return; + } + this._private = { + cy: cy, + coreStyle: {} + }; + this.length = 0; + this.resetToDefault(); +}; +var styfn = Style.prototype; +styfn.instanceString = function () { + return 'style'; +}; + +// remove all contexts +styfn.clear = function () { + var _p = this._private; + var cy = _p.cy; + var eles = cy.elements(); + for (var i = 0; i < this.length; i++) { + this[i] = undefined; + } + this.length = 0; + _p.contextStyles = {}; + _p.propDiffs = {}; + this.cleanElements(eles, true); + eles.forEach(function (ele) { + var ele_p = ele[0]._private; + ele_p.styleDirty = true; + ele_p.appliedInitStyle = false; + }); + return this; // chaining +}; + +styfn.resetToDefault = function () { + this.clear(); + this.addDefaultStylesheet(); + return this; +}; + +// builds a style object for the 'core' selector +styfn.core = function (propName) { + return this._private.coreStyle[propName] || this.getDefaultProperty(propName); +}; + +// create a new context from the specified selector string and switch to that context +styfn.selector = function (selectorStr) { + // 'core' is a special case and does not need a selector + var selector = selectorStr === 'core' ? null : new Selector(selectorStr); + var i = this.length++; // new context means new index + this[i] = { + selector: selector, + properties: [], + mappedProperties: [], + index: i + }; + return this; // chaining +}; + +// add one or many css rules to the current context +styfn.css = function () { + var self = this; + var args = arguments; + if (args.length === 1) { + var map = args[0]; + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var mapVal = map[prop.name]; + if (mapVal === undefined) { + mapVal = map[dash2camel(prop.name)]; + } + if (mapVal !== undefined) { + this.cssRule(prop.name, mapVal); + } + } + } else if (args.length === 2) { + this.cssRule(args[0], args[1]); + } + + // do nothing if args are invalid + + return this; // chaining +}; + +styfn.style = styfn.css; + +// add a single css rule to the current context +styfn.cssRule = function (name, value) { + // name-value pair + var property = this.parse(name, value); + + // add property to current context if valid + if (property) { + var i = this.length - 1; + this[i].properties.push(property); + this[i].properties[property.name] = property; // allow access by name as well + + if (property.name.match(/pie-(\d+)-background-size/) && property.value) { + this._private.hasPie = true; + } + if (property.mapped) { + this[i].mappedProperties.push(property); + } + + // add to core style if necessary + var currentSelectorIsCore = !this[i].selector; + if (currentSelectorIsCore) { + this._private.coreStyle[property.name] = property; + } + } + return this; // chaining +}; + +styfn.append = function (style) { + if (stylesheet(style)) { + style.appendToStyle(this); + } else if (array(style)) { + this.appendFromJson(style); + } else if (string(style)) { + this.appendFromString(style); + } // you probably wouldn't want to append a Style, since you'd duplicate the default parts + + return this; +}; + +// static function +Style.fromJson = function (cy, json) { + var style = new Style(cy); + style.fromJson(json); + return style; +}; +Style.fromString = function (cy, string) { + return new Style(cy).fromString(string); +}; +[styfn$8, styfn$7, styfn$6, styfn$5, styfn$4, styfn$3, styfn$2, styfn$1].forEach(function (props) { + extend(styfn, props); +}); +Style.types = styfn.types; +Style.properties = styfn.properties; +Style.propertyGroups = styfn.propertyGroups; +Style.propertyGroupNames = styfn.propertyGroupNames; +Style.propertyGroupKeys = styfn.propertyGroupKeys; + +var corefn$2 = { + style: function style(newStyle) { + if (newStyle) { + var s = this.setStyle(newStyle); + s.update(); + } + return this._private.style; + }, + setStyle: function setStyle(style) { + var _p = this._private; + if (stylesheet(style)) { + _p.style = style.generateStyle(this); + } else if (array(style)) { + _p.style = Style.fromJson(this, style); + } else if (string(style)) { + _p.style = Style.fromString(this, style); + } else { + _p.style = Style(this); + } + return _p.style; + }, + // e.g. cy.data() changed => recalc ele mappers + updateStyle: function updateStyle() { + this.mutableElements().updateStyle(); // just send to all eles + } +}; + +var defaultSelectionType = 'single'; +var corefn$1 = { + autolock: function autolock(bool) { + if (bool !== undefined) { + this._private.autolock = bool ? true : false; + } else { + return this._private.autolock; + } + return this; // chaining + }, + + autoungrabify: function autoungrabify(bool) { + if (bool !== undefined) { + this._private.autoungrabify = bool ? true : false; + } else { + return this._private.autoungrabify; + } + return this; // chaining + }, + + autounselectify: function autounselectify(bool) { + if (bool !== undefined) { + this._private.autounselectify = bool ? true : false; + } else { + return this._private.autounselectify; + } + return this; // chaining + }, + + selectionType: function selectionType(selType) { + var _p = this._private; + if (_p.selectionType == null) { + _p.selectionType = defaultSelectionType; + } + if (selType !== undefined) { + if (selType === 'additive' || selType === 'single') { + _p.selectionType = selType; + } + } else { + return _p.selectionType; + } + return this; + }, + panningEnabled: function panningEnabled(bool) { + if (bool !== undefined) { + this._private.panningEnabled = bool ? true : false; + } else { + return this._private.panningEnabled; + } + return this; // chaining + }, + + userPanningEnabled: function userPanningEnabled(bool) { + if (bool !== undefined) { + this._private.userPanningEnabled = bool ? true : false; + } else { + return this._private.userPanningEnabled; + } + return this; // chaining + }, + + zoomingEnabled: function zoomingEnabled(bool) { + if (bool !== undefined) { + this._private.zoomingEnabled = bool ? true : false; + } else { + return this._private.zoomingEnabled; + } + return this; // chaining + }, + + userZoomingEnabled: function userZoomingEnabled(bool) { + if (bool !== undefined) { + this._private.userZoomingEnabled = bool ? true : false; + } else { + return this._private.userZoomingEnabled; + } + return this; // chaining + }, + + boxSelectionEnabled: function boxSelectionEnabled(bool) { + if (bool !== undefined) { + this._private.boxSelectionEnabled = bool ? true : false; + } else { + return this._private.boxSelectionEnabled; + } + return this; // chaining + }, + + pan: function pan() { + var args = arguments; + var pan = this._private.pan; + var dim, val, dims, x, y; + switch (args.length) { + case 0: + // .pan() + return pan; + case 1: + if (string(args[0])) { + // .pan('x') + dim = args[0]; + return pan[dim]; + } else if (plainObject(args[0])) { + // .pan({ x: 0, y: 100 }) + if (!this._private.panningEnabled) { + return this; + } + dims = args[0]; + x = dims.x; + y = dims.y; + if (number$1(x)) { + pan.x = x; + } + if (number$1(y)) { + pan.y = y; + } + this.emit('pan viewport'); + } + break; + case 2: + // .pan('x', 100) + if (!this._private.panningEnabled) { + return this; + } + dim = args[0]; + val = args[1]; + if ((dim === 'x' || dim === 'y') && number$1(val)) { + pan[dim] = val; + } + this.emit('pan viewport'); + break; + // invalid + } + + this.notify('viewport'); + return this; // chaining + }, + + panBy: function panBy(arg0, arg1) { + var args = arguments; + var pan = this._private.pan; + var dim, val, dims, x, y; + if (!this._private.panningEnabled) { + return this; + } + switch (args.length) { + case 1: + if (plainObject(arg0)) { + // .panBy({ x: 0, y: 100 }) + dims = args[0]; + x = dims.x; + y = dims.y; + if (number$1(x)) { + pan.x += x; + } + if (number$1(y)) { + pan.y += y; + } + this.emit('pan viewport'); + } + break; + case 2: + // .panBy('x', 100) + dim = arg0; + val = arg1; + if ((dim === 'x' || dim === 'y') && number$1(val)) { + pan[dim] += val; + } + this.emit('pan viewport'); + break; + // invalid + } + + this.notify('viewport'); + return this; // chaining + }, + + fit: function fit(elements, padding) { + var viewportState = this.getFitViewport(elements, padding); + if (viewportState) { + var _p = this._private; + _p.zoom = viewportState.zoom; + _p.pan = viewportState.pan; + this.emit('pan zoom viewport'); + this.notify('viewport'); + } + return this; // chaining + }, + + getFitViewport: function getFitViewport(elements, padding) { + if (number$1(elements) && padding === undefined) { + // elements is optional + padding = elements; + elements = undefined; + } + if (!this._private.panningEnabled || !this._private.zoomingEnabled) { + return; + } + var bb; + if (string(elements)) { + var sel = elements; + elements = this.$(sel); + } else if (boundingBox(elements)) { + // assume bb + var bbe = elements; + bb = { + x1: bbe.x1, + y1: bbe.y1, + x2: bbe.x2, + y2: bbe.y2 + }; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + } else if (!elementOrCollection(elements)) { + elements = this.mutableElements(); + } + if (elementOrCollection(elements) && elements.empty()) { + return; + } // can't fit to nothing + + bb = bb || elements.boundingBox(); + var w = this.width(); + var h = this.height(); + var zoom; + padding = number$1(padding) ? padding : 0; + if (!isNaN(w) && !isNaN(h) && w > 0 && h > 0 && !isNaN(bb.w) && !isNaN(bb.h) && bb.w > 0 && bb.h > 0) { + zoom = Math.min((w - 2 * padding) / bb.w, (h - 2 * padding) / bb.h); + + // crop zoom + zoom = zoom > this._private.maxZoom ? this._private.maxZoom : zoom; + zoom = zoom < this._private.minZoom ? this._private.minZoom : zoom; + var pan = { + // now pan to middle + x: (w - zoom * (bb.x1 + bb.x2)) / 2, + y: (h - zoom * (bb.y1 + bb.y2)) / 2 + }; + return { + zoom: zoom, + pan: pan + }; + } + return; + }, + zoomRange: function zoomRange(min, max) { + var _p = this._private; + if (max == null) { + var opts = min; + min = opts.min; + max = opts.max; + } + if (number$1(min) && number$1(max) && min <= max) { + _p.minZoom = min; + _p.maxZoom = max; + } else if (number$1(min) && max === undefined && min <= _p.maxZoom) { + _p.minZoom = min; + } else if (number$1(max) && min === undefined && max >= _p.minZoom) { + _p.maxZoom = max; + } + return this; + }, + minZoom: function minZoom(zoom) { + if (zoom === undefined) { + return this._private.minZoom; + } else { + return this.zoomRange({ + min: zoom + }); + } + }, + maxZoom: function maxZoom(zoom) { + if (zoom === undefined) { + return this._private.maxZoom; + } else { + return this.zoomRange({ + max: zoom + }); + } + }, + getZoomedViewport: function getZoomedViewport(params) { + var _p = this._private; + var currentPan = _p.pan; + var currentZoom = _p.zoom; + var pos; // in rendered px + var zoom; + var bail = false; + if (!_p.zoomingEnabled) { + // zooming disabled + bail = true; + } + if (number$1(params)) { + // then set the zoom + zoom = params; + } else if (plainObject(params)) { + // then zoom about a point + zoom = params.level; + if (params.position != null) { + pos = modelToRenderedPosition(params.position, currentZoom, currentPan); + } else if (params.renderedPosition != null) { + pos = params.renderedPosition; + } + if (pos != null && !_p.panningEnabled) { + // panning disabled + bail = true; + } + } + + // crop zoom + zoom = zoom > _p.maxZoom ? _p.maxZoom : zoom; + zoom = zoom < _p.minZoom ? _p.minZoom : zoom; + + // can't zoom with invalid params + if (bail || !number$1(zoom) || zoom === currentZoom || pos != null && (!number$1(pos.x) || !number$1(pos.y))) { + return null; + } + if (pos != null) { + // set zoom about position + var pan1 = currentPan; + var zoom1 = currentZoom; + var zoom2 = zoom; + var pan2 = { + x: -zoom2 / zoom1 * (pos.x - pan1.x) + pos.x, + y: -zoom2 / zoom1 * (pos.y - pan1.y) + pos.y + }; + return { + zoomed: true, + panned: true, + zoom: zoom2, + pan: pan2 + }; + } else { + // just set the zoom + return { + zoomed: true, + panned: false, + zoom: zoom, + pan: currentPan + }; + } + }, + zoom: function zoom(params) { + if (params === undefined) { + // get + return this._private.zoom; + } else { + // set + var vp = this.getZoomedViewport(params); + var _p = this._private; + if (vp == null || !vp.zoomed) { + return this; + } + _p.zoom = vp.zoom; + if (vp.panned) { + _p.pan.x = vp.pan.x; + _p.pan.y = vp.pan.y; + } + this.emit('zoom' + (vp.panned ? ' pan' : '') + ' viewport'); + this.notify('viewport'); + return this; // chaining + } + }, + + viewport: function viewport(opts) { + var _p = this._private; + var zoomDefd = true; + var panDefd = true; + var events = []; // to trigger + var zoomFailed = false; + var panFailed = false; + if (!opts) { + return this; + } + if (!number$1(opts.zoom)) { + zoomDefd = false; + } + if (!plainObject(opts.pan)) { + panDefd = false; + } + if (!zoomDefd && !panDefd) { + return this; + } + if (zoomDefd) { + var z = opts.zoom; + if (z < _p.minZoom || z > _p.maxZoom || !_p.zoomingEnabled) { + zoomFailed = true; + } else { + _p.zoom = z; + events.push('zoom'); + } + } + if (panDefd && (!zoomFailed || !opts.cancelOnFailedZoom) && _p.panningEnabled) { + var p = opts.pan; + if (number$1(p.x)) { + _p.pan.x = p.x; + panFailed = false; + } + if (number$1(p.y)) { + _p.pan.y = p.y; + panFailed = false; + } + if (!panFailed) { + events.push('pan'); + } + } + if (events.length > 0) { + events.push('viewport'); + this.emit(events.join(' ')); + this.notify('viewport'); + } + return this; // chaining + }, + + center: function center(elements) { + var pan = this.getCenterPan(elements); + if (pan) { + this._private.pan = pan; + this.emit('pan viewport'); + this.notify('viewport'); + } + return this; // chaining + }, + + getCenterPan: function getCenterPan(elements, zoom) { + if (!this._private.panningEnabled) { + return; + } + if (string(elements)) { + var selector = elements; + elements = this.mutableElements().filter(selector); + } else if (!elementOrCollection(elements)) { + elements = this.mutableElements(); + } + if (elements.length === 0) { + return; + } // can't centre pan to nothing + + var bb = elements.boundingBox(); + var w = this.width(); + var h = this.height(); + zoom = zoom === undefined ? this._private.zoom : zoom; + var pan = { + // middle + x: (w - zoom * (bb.x1 + bb.x2)) / 2, + y: (h - zoom * (bb.y1 + bb.y2)) / 2 + }; + return pan; + }, + reset: function reset() { + if (!this._private.panningEnabled || !this._private.zoomingEnabled) { + return this; + } + this.viewport({ + pan: { + x: 0, + y: 0 + }, + zoom: 1 + }); + return this; // chaining + }, + + invalidateSize: function invalidateSize() { + this._private.sizeCache = null; + }, + size: function size() { + var _p = this._private; + var container = _p.container; + var cy = this; + return _p.sizeCache = _p.sizeCache || (container ? function () { + var style = cy.window().getComputedStyle(container); + var val = function val(name) { + return parseFloat(style.getPropertyValue(name)); + }; + return { + width: container.clientWidth - val('padding-left') - val('padding-right'), + height: container.clientHeight - val('padding-top') - val('padding-bottom') + }; + }() : { + // fallback if no container (not 0 b/c can be used for dividing etc) + width: 1, + height: 1 + }); + }, + width: function width() { + return this.size().width; + }, + height: function height() { + return this.size().height; + }, + extent: function extent() { + var pan = this._private.pan; + var zoom = this._private.zoom; + var rb = this.renderedExtent(); + var b = { + x1: (rb.x1 - pan.x) / zoom, + x2: (rb.x2 - pan.x) / zoom, + y1: (rb.y1 - pan.y) / zoom, + y2: (rb.y2 - pan.y) / zoom + }; + b.w = b.x2 - b.x1; + b.h = b.y2 - b.y1; + return b; + }, + renderedExtent: function renderedExtent() { + var width = this.width(); + var height = this.height(); + return { + x1: 0, + y1: 0, + x2: width, + y2: height, + w: width, + h: height + }; + }, + multiClickDebounceTime: function multiClickDebounceTime(_int) { + if (_int) this._private.multiClickDebounceTime = _int;else return this._private.multiClickDebounceTime; + return this; // chaining + } +}; + +// aliases +corefn$1.centre = corefn$1.center; + +// backwards compatibility +corefn$1.autolockNodes = corefn$1.autolock; +corefn$1.autoungrabifyNodes = corefn$1.autoungrabify; + +var fn = { + data: define.data({ + field: 'data', + bindingEvent: 'data', + allowBinding: true, + allowSetting: true, + settingEvent: 'data', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeData: define.removeData({ + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }), + scratch: define.data({ + field: 'scratch', + bindingEvent: 'scratch', + allowBinding: true, + allowSetting: true, + settingEvent: 'scratch', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeScratch: define.removeData({ + field: 'scratch', + event: 'scratch', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }) +}; + +// aliases +fn.attr = fn.data; +fn.removeAttr = fn.removeData; + +var Core = function Core(opts) { + var cy = this; + opts = extend({}, opts); + var container = opts.container; + + // allow for passing a wrapped jquery object + // e.g. cytoscape({ container: $('#cy') }) + if (container && !htmlElement(container) && htmlElement(container[0])) { + container = container[0]; + } + var reg = container ? container._cyreg : null; // e.g. already registered some info (e.g. readies) via jquery + reg = reg || {}; + if (reg && reg.cy) { + reg.cy.destroy(); + reg = {}; // old instance => replace reg completely + } + + var readies = reg.readies = reg.readies || []; + if (container) { + container._cyreg = reg; + } // make sure container assoc'd reg points to this cy + reg.cy = cy; + var head = _window !== undefined && container !== undefined && !opts.headless; + var options = opts; + options.layout = extend({ + name: head ? 'grid' : 'null' + }, options.layout); + options.renderer = extend({ + name: head ? 'canvas' : 'null' + }, options.renderer); + var defVal = function defVal(def, val, altVal) { + if (val !== undefined) { + return val; + } else if (altVal !== undefined) { + return altVal; + } else { + return def; + } + }; + var _p = this._private = { + container: container, + // html dom ele container + ready: false, + // whether ready has been triggered + options: options, + // cached options + elements: new Collection(this), + // elements in the graph + listeners: [], + // list of listeners + aniEles: new Collection(this), + // elements being animated + data: options.data || {}, + // data for the core + scratch: {}, + // scratch object for core + layout: null, + renderer: null, + destroyed: false, + // whether destroy was called + notificationsEnabled: true, + // whether notifications are sent to the renderer + minZoom: 1e-50, + maxZoom: 1e50, + zoomingEnabled: defVal(true, options.zoomingEnabled), + userZoomingEnabled: defVal(true, options.userZoomingEnabled), + panningEnabled: defVal(true, options.panningEnabled), + userPanningEnabled: defVal(true, options.userPanningEnabled), + boxSelectionEnabled: defVal(true, options.boxSelectionEnabled), + autolock: defVal(false, options.autolock, options.autolockNodes), + autoungrabify: defVal(false, options.autoungrabify, options.autoungrabifyNodes), + autounselectify: defVal(false, options.autounselectify), + styleEnabled: options.styleEnabled === undefined ? head : options.styleEnabled, + zoom: number$1(options.zoom) ? options.zoom : 1, + pan: { + x: plainObject(options.pan) && number$1(options.pan.x) ? options.pan.x : 0, + y: plainObject(options.pan) && number$1(options.pan.y) ? options.pan.y : 0 + }, + animation: { + // object for currently-running animations + current: [], + queue: [] + }, + hasCompoundNodes: false, + multiClickDebounceTime: defVal(250, options.multiClickDebounceTime) + }; + this.createEmitter(); + + // set selection type + this.selectionType(options.selectionType); + + // init zoom bounds + this.zoomRange({ + min: options.minZoom, + max: options.maxZoom + }); + var loadExtData = function loadExtData(extData, next) { + var anyIsPromise = extData.some(promise); + if (anyIsPromise) { + return Promise$1.all(extData).then(next); // load all data asynchronously, then exec rest of init + } else { + next(extData); // exec synchronously for convenience + } + }; + + // start with the default stylesheet so we have something before loading an external stylesheet + if (_p.styleEnabled) { + cy.setStyle([]); + } + + // create the renderer + var rendererOptions = extend({}, options, options.renderer); // allow rendering hints in top level options + cy.initRenderer(rendererOptions); + var setElesAndLayout = function setElesAndLayout(elements, onload, ondone) { + cy.notifications(false); + + // remove old elements + var oldEles = cy.mutableElements(); + if (oldEles.length > 0) { + oldEles.remove(); + } + if (elements != null) { + if (plainObject(elements) || array(elements)) { + cy.add(elements); + } + } + cy.one('layoutready', function (e) { + cy.notifications(true); + cy.emit(e); // we missed this event by turning notifications off, so pass it on + + cy.one('load', onload); + cy.emitAndNotify('load'); + }).one('layoutstop', function () { + cy.one('done', ondone); + cy.emit('done'); + }); + var layoutOpts = extend({}, cy._private.options.layout); + layoutOpts.eles = cy.elements(); + cy.layout(layoutOpts).run(); + }; + loadExtData([options.style, options.elements], function (thens) { + var initStyle = thens[0]; + var initEles = thens[1]; + + // init style + if (_p.styleEnabled) { + cy.style().append(initStyle); + } + + // initial load + setElesAndLayout(initEles, function () { + // onready + cy.startAnimationLoop(); + _p.ready = true; + + // if a ready callback is specified as an option, the bind it + if (fn$6(options.ready)) { + cy.on('ready', options.ready); + } + + // bind all the ready handlers registered before creating this instance + for (var i = 0; i < readies.length; i++) { + var fn = readies[i]; + cy.on('ready', fn); + } + if (reg) { + reg.readies = []; + } // clear b/c we've bound them all and don't want to keep it around in case a new core uses the same div etc + + cy.emit('ready'); + }, options.done); + }); +}; +var corefn = Core.prototype; // short alias + +extend(corefn, { + instanceString: function instanceString() { + return 'core'; + }, + isReady: function isReady() { + return this._private.ready; + }, + destroyed: function destroyed() { + return this._private.destroyed; + }, + ready: function ready(fn) { + if (this.isReady()) { + this.emitter().emit('ready', [], fn); // just calls fn as though triggered via ready event + } else { + this.on('ready', fn); + } + return this; + }, + destroy: function destroy() { + var cy = this; + if (cy.destroyed()) return; + cy.stopAnimationLoop(); + cy.destroyRenderer(); + this.emit('destroy'); + cy._private.destroyed = true; + return cy; + }, + hasElementWithId: function hasElementWithId(id) { + return this._private.elements.hasElementWithId(id); + }, + getElementById: function getElementById(id) { + return this._private.elements.getElementById(id); + }, + hasCompoundNodes: function hasCompoundNodes() { + return this._private.hasCompoundNodes; + }, + headless: function headless() { + return this._private.renderer.isHeadless(); + }, + styleEnabled: function styleEnabled() { + return this._private.styleEnabled; + }, + addToPool: function addToPool(eles) { + this._private.elements.merge(eles); + return this; // chaining + }, + + removeFromPool: function removeFromPool(eles) { + this._private.elements.unmerge(eles); + return this; + }, + container: function container() { + return this._private.container || null; + }, + window: function window() { + var container = this._private.container; + if (container == null) return _window; + var ownerDocument = this._private.container.ownerDocument; + if (ownerDocument === undefined || ownerDocument == null) { + return _window; + } + return ownerDocument.defaultView || _window; + }, + mount: function mount(container) { + if (container == null) { + return; + } + var cy = this; + var _p = cy._private; + var options = _p.options; + if (!htmlElement(container) && htmlElement(container[0])) { + container = container[0]; + } + cy.stopAnimationLoop(); + cy.destroyRenderer(); + _p.container = container; + _p.styleEnabled = true; + cy.invalidateSize(); + cy.initRenderer(extend({}, options, options.renderer, { + // allow custom renderer name to be re-used, otherwise use canvas + name: options.renderer.name === 'null' ? 'canvas' : options.renderer.name + })); + cy.startAnimationLoop(); + cy.style(options.style); + cy.emit('mount'); + return cy; + }, + unmount: function unmount() { + var cy = this; + cy.stopAnimationLoop(); + cy.destroyRenderer(); + cy.initRenderer({ + name: 'null' + }); + cy.emit('unmount'); + return cy; + }, + options: function options() { + return copy(this._private.options); + }, + json: function json(obj) { + var cy = this; + var _p = cy._private; + var eles = cy.mutableElements(); + var getFreshRef = function getFreshRef(ele) { + return cy.getElementById(ele.id()); + }; + if (plainObject(obj)) { + // set + + cy.startBatch(); + if (obj.elements) { + var idInJson = {}; + var updateEles = function updateEles(jsons, gr) { + var toAdd = []; + var toMod = []; + for (var i = 0; i < jsons.length; i++) { + var json = jsons[i]; + if (!json.data.id) { + warn('cy.json() cannot handle elements without an ID attribute'); + continue; + } + var id = '' + json.data.id; // id must be string + var ele = cy.getElementById(id); + idInJson[id] = true; + if (ele.length !== 0) { + // existing element should be updated + toMod.push({ + ele: ele, + json: json + }); + } else { + // otherwise should be added + if (gr) { + json.group = gr; + toAdd.push(json); + } else { + toAdd.push(json); + } + } + } + cy.add(toAdd); + for (var _i = 0; _i < toMod.length; _i++) { + var _toMod$_i = toMod[_i], + _ele = _toMod$_i.ele, + _json = _toMod$_i.json; + _ele.json(_json); + } + }; + if (array(obj.elements)) { + // elements: [] + updateEles(obj.elements); + } else { + // elements: { nodes: [], edges: [] } + var grs = ['nodes', 'edges']; + for (var i = 0; i < grs.length; i++) { + var gr = grs[i]; + var elements = obj.elements[gr]; + if (array(elements)) { + updateEles(elements, gr); + } + } + } + var parentsToRemove = cy.collection(); + eles.filter(function (ele) { + return !idInJson[ele.id()]; + }).forEach(function (ele) { + if (ele.isParent()) { + parentsToRemove.merge(ele); + } else { + ele.remove(); + } + }); + + // so that children are not removed w/parent + parentsToRemove.forEach(function (ele) { + return ele.children().move({ + parent: null + }); + }); + + // intermediate parents may be moved by prior line, so make sure we remove by fresh refs + parentsToRemove.forEach(function (ele) { + return getFreshRef(ele).remove(); + }); + } + if (obj.style) { + cy.style(obj.style); + } + if (obj.zoom != null && obj.zoom !== _p.zoom) { + cy.zoom(obj.zoom); + } + if (obj.pan) { + if (obj.pan.x !== _p.pan.x || obj.pan.y !== _p.pan.y) { + cy.pan(obj.pan); + } + } + if (obj.data) { + cy.data(obj.data); + } + var fields = ['minZoom', 'maxZoom', 'zoomingEnabled', 'userZoomingEnabled', 'panningEnabled', 'userPanningEnabled', 'boxSelectionEnabled', 'autolock', 'autoungrabify', 'autounselectify', 'multiClickDebounceTime']; + for (var _i2 = 0; _i2 < fields.length; _i2++) { + var f = fields[_i2]; + if (obj[f] != null) { + cy[f](obj[f]); + } + } + cy.endBatch(); + return this; // chaining + } else { + // get + var flat = !!obj; + var json = {}; + if (flat) { + json.elements = this.elements().map(function (ele) { + return ele.json(); + }); + } else { + json.elements = {}; + eles.forEach(function (ele) { + var group = ele.group(); + if (!json.elements[group]) { + json.elements[group] = []; + } + json.elements[group].push(ele.json()); + }); + } + if (this._private.styleEnabled) { + json.style = cy.style().json(); + } + json.data = copy(cy.data()); + var options = _p.options; + json.zoomingEnabled = _p.zoomingEnabled; + json.userZoomingEnabled = _p.userZoomingEnabled; + json.zoom = _p.zoom; + json.minZoom = _p.minZoom; + json.maxZoom = _p.maxZoom; + json.panningEnabled = _p.panningEnabled; + json.userPanningEnabled = _p.userPanningEnabled; + json.pan = copy(_p.pan); + json.boxSelectionEnabled = _p.boxSelectionEnabled; + json.renderer = copy(options.renderer); + json.hideEdgesOnViewport = options.hideEdgesOnViewport; + json.textureOnViewport = options.textureOnViewport; + json.wheelSensitivity = options.wheelSensitivity; + json.motionBlur = options.motionBlur; + json.multiClickDebounceTime = options.multiClickDebounceTime; + return json; + } + } +}); +corefn.$id = corefn.getElementById; +[corefn$9, corefn$8, elesfn, corefn$7, corefn$6, corefn$5, corefn$4, corefn$3, corefn$2, corefn$1, fn].forEach(function (props) { + extend(corefn, props); +}); + +/* eslint-disable no-unused-vars */ +var defaults$7 = { + fit: true, + // whether to fit the viewport to the graph + directed: false, + // whether the tree is directed downwards (or edges can point in any direction if false) + padding: 30, + // padding on fit + circle: false, + // put depths in concentric circles if true, put depths top down if false + grid: false, + // whether to create an even grid into which the DAG is placed (circle:false only) + spacingFactor: 1.75, + // positive spacing factor, larger => more space between nodes (N.B. n/a if causes overlap) + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + roots: undefined, + // the roots of the trees + depthSort: undefined, + // a sorting function to order nodes at equal depth. e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled, + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +var deprecatedOptionDefaults = { + maximal: false, + // whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only); setting acyclic to true sets maximal to true also + acyclic: false // whether the tree is acyclic and thus a node could be shifted (due to the maximal option) multiple times without causing an infinite loop; setting to true sets maximal to true also; if you are uncertain whether a tree is acyclic, set to false to avoid potential infinite loops +}; + +/* eslint-enable */ + +var getInfo = function getInfo(ele) { + return ele.scratch('breadthfirst'); +}; +var setInfo = function setInfo(ele, obj) { + return ele.scratch('breadthfirst', obj); +}; +function BreadthFirstLayout(options) { + this.options = extend({}, defaults$7, deprecatedOptionDefaults, options); +} +BreadthFirstLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().filter(function (n) { + return !n.isParent(); + }); + var graph = eles; + var directed = options.directed; + var maximal = options.acyclic || options.maximal || options.maximalAdjustments > 0; // maximalAdjustments for compat. w/ old code; also, setting acyclic to true sets maximal to true + + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var roots; + if (elementOrCollection(options.roots)) { + roots = options.roots; + } else if (array(options.roots)) { + var rootsArray = []; + for (var i = 0; i < options.roots.length; i++) { + var id = options.roots[i]; + var ele = cy.getElementById(id); + rootsArray.push(ele); + } + roots = cy.collection(rootsArray); + } else if (string(options.roots)) { + roots = cy.$(options.roots); + } else { + if (directed) { + roots = nodes.roots(); + } else { + var components = eles.components(); + roots = cy.collection(); + var _loop = function _loop(_i) { + var comp = components[_i]; + var maxDegree = comp.maxDegree(false); + var compRoots = comp.filter(function (ele) { + return ele.degree(false) === maxDegree; + }); + roots = roots.add(compRoots); + }; + for (var _i = 0; _i < components.length; _i++) { + _loop(_i); + } + } + } + var depths = []; + var foundByBfs = {}; + var addToDepth = function addToDepth(ele, d) { + if (depths[d] == null) { + depths[d] = []; + } + var i = depths[d].length; + depths[d].push(ele); + setInfo(ele, { + index: i, + depth: d + }); + }; + var changeDepth = function changeDepth(ele, newDepth) { + var _getInfo = getInfo(ele), + depth = _getInfo.depth, + index = _getInfo.index; + depths[depth][index] = null; + addToDepth(ele, newDepth); + }; + + // find the depths of the nodes + graph.bfs({ + roots: roots, + directed: options.directed, + visit: function visit(node, edge, pNode, i, depth) { + var ele = node[0]; + var id = ele.id(); + addToDepth(ele, depth); + foundByBfs[id] = true; + } + }); + + // check for nodes not found by bfs + var orphanNodes = []; + for (var _i2 = 0; _i2 < nodes.length; _i2++) { + var _ele = nodes[_i2]; + if (foundByBfs[_ele.id()]) { + continue; + } else { + orphanNodes.push(_ele); + } + } + + // assign the nodes a depth and index + + var assignDepthsAt = function assignDepthsAt(i) { + var eles = depths[i]; + for (var j = 0; j < eles.length; j++) { + var _ele2 = eles[j]; + if (_ele2 == null) { + eles.splice(j, 1); + j--; + continue; + } + setInfo(_ele2, { + depth: i, + index: j + }); + } + }; + var assignDepths = function assignDepths() { + for (var _i3 = 0; _i3 < depths.length; _i3++) { + assignDepthsAt(_i3); + } + }; + var adjustMaximally = function adjustMaximally(ele, shifted) { + var eInfo = getInfo(ele); + var incomers = ele.incomers().filter(function (el) { + return el.isNode() && eles.has(el); + }); + var maxDepth = -1; + var id = ele.id(); + for (var k = 0; k < incomers.length; k++) { + var incmr = incomers[k]; + var iInfo = getInfo(incmr); + maxDepth = Math.max(maxDepth, iInfo.depth); + } + if (eInfo.depth <= maxDepth) { + if (!options.acyclic && shifted[id]) { + return null; + } + var newDepth = maxDepth + 1; + changeDepth(ele, newDepth); + shifted[id] = newDepth; + return true; + } + return false; + }; + + // for the directed case, try to make the edges all go down (i.e. depth i => depth i + 1) + if (directed && maximal) { + var Q = []; + var shifted = {}; + var enqueue = function enqueue(n) { + return Q.push(n); + }; + var dequeue = function dequeue() { + return Q.shift(); + }; + nodes.forEach(function (n) { + return Q.push(n); + }); + while (Q.length > 0) { + var _ele3 = dequeue(); + var didShift = adjustMaximally(_ele3, shifted); + if (didShift) { + _ele3.outgoers().filter(function (el) { + return el.isNode() && eles.has(el); + }).forEach(enqueue); + } else if (didShift === null) { + warn('Detected double maximal shift for node `' + _ele3.id() + '`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.'); + break; // exit on failure + } + } + } + + assignDepths(); // clear holes + + // find min distance we need to leave between nodes + var minDistance = 0; + if (options.avoidOverlap) { + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + var n = nodes[_i4]; + var nbb = n.layoutDimensions(options); + var w = nbb.w; + var h = nbb.h; + minDistance = Math.max(minDistance, w, h); + } + } + + // get the weighted percent for an element based on its connectivity to other levels + var cachedWeightedPercent = {}; + var getWeightedPercent = function getWeightedPercent(ele) { + if (cachedWeightedPercent[ele.id()]) { + return cachedWeightedPercent[ele.id()]; + } + var eleDepth = getInfo(ele).depth; + var neighbors = ele.neighborhood(); + var percent = 0; + var samples = 0; + for (var _i5 = 0; _i5 < neighbors.length; _i5++) { + var neighbor = neighbors[_i5]; + if (neighbor.isEdge() || neighbor.isParent() || !nodes.has(neighbor)) { + continue; + } + var bf = getInfo(neighbor); + if (bf == null) { + continue; + } + var index = bf.index; + var depth = bf.depth; + + // unassigned neighbours shouldn't affect the ordering + if (index == null || depth == null) { + continue; + } + var nDepth = depths[depth].length; + if (depth < eleDepth) { + // only get influenced by elements above + percent += index / nDepth; + samples++; + } + } + samples = Math.max(1, samples); + percent = percent / samples; + if (samples === 0) { + // put lone nodes at the start + percent = 0; + } + cachedWeightedPercent[ele.id()] = percent; + return percent; + }; + + // rearrange the indices in each depth level based on connectivity + + var sortFn = function sortFn(a, b) { + var apct = getWeightedPercent(a); + var bpct = getWeightedPercent(b); + var diff = apct - bpct; + if (diff === 0) { + return ascending(a.id(), b.id()); // make sure sort doesn't have don't-care comparisons + } else { + return diff; + } + }; + if (options.depthSort !== undefined) { + sortFn = options.depthSort; + } + + // sort each level to make connected nodes closer + for (var _i6 = 0; _i6 < depths.length; _i6++) { + depths[_i6].sort(sortFn); + assignDepthsAt(_i6); + } + + // assign orphan nodes to a new top-level depth + var orphanDepth = []; + for (var _i7 = 0; _i7 < orphanNodes.length; _i7++) { + orphanDepth.push(orphanNodes[_i7]); + } + depths.unshift(orphanDepth); + assignDepths(); + var biggestDepthSize = 0; + for (var _i8 = 0; _i8 < depths.length; _i8++) { + biggestDepthSize = Math.max(depths[_i8].length, biggestDepthSize); + } + var center = { + x: bb.x1 + bb.w / 2, + y: bb.x1 + bb.h / 2 + }; + var maxDepthSize = depths.reduce(function (max, eles) { + return Math.max(max, eles.length); + }, 0); + var getPosition = function getPosition(ele) { + var _getInfo2 = getInfo(ele), + depth = _getInfo2.depth, + index = _getInfo2.index; + var depthSize = depths[depth].length; + var distanceX = Math.max(bb.w / ((options.grid ? maxDepthSize : depthSize) + 1), minDistance); + var distanceY = Math.max(bb.h / (depths.length + 1), minDistance); + var radiusStepSize = Math.min(bb.w / 2 / depths.length, bb.h / 2 / depths.length); + radiusStepSize = Math.max(radiusStepSize, minDistance); + if (!options.circle) { + var epos = { + x: center.x + (index + 1 - (depthSize + 1) / 2) * distanceX, + y: (depth + 1) * distanceY + }; + return epos; + } else { + var radius = radiusStepSize * depth + radiusStepSize - (depths.length > 0 && depths[0].length <= 3 ? radiusStepSize / 2 : 0); + var theta = 2 * Math.PI / depths[depth].length * index; + if (depth === 0 && depths[0].length === 1) { + radius = 1; + } + return { + x: center.x + radius * Math.cos(theta), + y: center.y + radius * Math.sin(theta) + }; + } + }; + eles.nodes().layoutPositions(this, options, getPosition); + return this; // chaining +}; + +var defaults$6 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // the padding on fit + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox and radius if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + radius: undefined, + // the radius of the circle + startAngle: 3 / 2 * Math.PI, + // where nodes start in radians + sweep: undefined, + // how many radians should be between the first and last node (defaults to full circle) + clockwise: true, + // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) + sort: undefined, + // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function CircleLayout(options) { + this.options = extend({}, defaults$6, options); +} +CircleLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var clockwise = options.counterclockwise !== undefined ? !options.counterclockwise : options.clockwise; + var nodes = eles.nodes().not(':parent'); + if (options.sort) { + nodes = nodes.sort(options.sort); + } + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var center = { + x: bb.x1 + bb.w / 2, + y: bb.y1 + bb.h / 2 + }; + var sweep = options.sweep === undefined ? 2 * Math.PI - 2 * Math.PI / nodes.length : options.sweep; + var dTheta = sweep / Math.max(1, nodes.length - 1); + var r; + var minDistance = 0; + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + var nbb = n.layoutDimensions(options); + var w = nbb.w; + var h = nbb.h; + minDistance = Math.max(minDistance, w, h); + } + if (number$1(options.radius)) { + r = options.radius; + } else if (nodes.length <= 1) { + r = 0; + } else { + r = Math.min(bb.h, bb.w) / 2 - minDistance; + } + + // calculate the radius + if (nodes.length > 1 && options.avoidOverlap) { + // but only if more than one node (can't overlap) + minDistance *= 1.75; // just to have some nice spacing + + var dcos = Math.cos(dTheta) - Math.cos(0); + var dsin = Math.sin(dTheta) - Math.sin(0); + var rMin = Math.sqrt(minDistance * minDistance / (dcos * dcos + dsin * dsin)); // s.t. no nodes overlapping + r = Math.max(rMin, r); + } + var getPos = function getPos(ele, i) { + var theta = options.startAngle + i * dTheta * (clockwise ? 1 : -1); + var rx = r * Math.cos(theta); + var ry = r * Math.sin(theta); + var pos = { + x: center.x + rx, + y: center.y + ry + }; + return pos; + }; + eles.nodes().layoutPositions(this, options, getPos); + return this; // chaining +}; + +var defaults$5 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // the padding on fit + startAngle: 3 / 2 * Math.PI, + // where nodes start in radians + sweep: undefined, + // how many radians should be between the first and last node (defaults to full circle) + clockwise: true, + // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) + equidistant: false, + // whether levels have an equal radial distance betwen them, may cause bounding box overflow + minNodeSpacing: 10, + // min spacing between outside of nodes (used for radius adjustment) + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + height: undefined, + // height of layout area (overrides container height) + width: undefined, + // width of layout area (overrides container width) + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + concentric: function concentric(node) { + // returns numeric value for each node, placing higher nodes in levels towards the centre + return node.degree(); + }, + levelWidth: function levelWidth(nodes) { + // the variation of concentric values in each level + return nodes.maxDegree() / 4; + }, + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function ConcentricLayout(options) { + this.options = extend({}, defaults$5, options); +} +ConcentricLayout.prototype.run = function () { + var params = this.options; + var options = params; + var clockwise = options.counterclockwise !== undefined ? !options.counterclockwise : options.clockwise; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().not(':parent'); + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var center = { + x: bb.x1 + bb.w / 2, + y: bb.y1 + bb.h / 2 + }; + var nodeValues = []; // { node, value } + var maxNodeSize = 0; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var value = void 0; + + // calculate the node value + value = options.concentric(node); + nodeValues.push({ + value: value, + node: node + }); + + // for style mapping + node._private.scratch.concentric = value; + } + + // in case we used the `concentric` in style + nodes.updateStyle(); + + // calculate max size now based on potentially updated mappers + for (var _i = 0; _i < nodes.length; _i++) { + var _node = nodes[_i]; + var nbb = _node.layoutDimensions(options); + maxNodeSize = Math.max(maxNodeSize, nbb.w, nbb.h); + } + + // sort node values in descreasing order + nodeValues.sort(function (a, b) { + return b.value - a.value; + }); + var levelWidth = options.levelWidth(nodes); + + // put the values into levels + var levels = [[]]; + var currentLevel = levels[0]; + for (var _i2 = 0; _i2 < nodeValues.length; _i2++) { + var val = nodeValues[_i2]; + if (currentLevel.length > 0) { + var diff = Math.abs(currentLevel[0].value - val.value); + if (diff >= levelWidth) { + currentLevel = []; + levels.push(currentLevel); + } + } + currentLevel.push(val); + } + + // create positions from levels + + var minDist = maxNodeSize + options.minNodeSpacing; // min dist between nodes + + if (!options.avoidOverlap) { + // then strictly constrain to bb + var firstLvlHasMulti = levels.length > 0 && levels[0].length > 1; + var maxR = Math.min(bb.w, bb.h) / 2 - minDist; + var rStep = maxR / (levels.length + firstLvlHasMulti ? 1 : 0); + minDist = Math.min(minDist, rStep); + } + + // find the metrics for each level + var r = 0; + for (var _i3 = 0; _i3 < levels.length; _i3++) { + var level = levels[_i3]; + var sweep = options.sweep === undefined ? 2 * Math.PI - 2 * Math.PI / level.length : options.sweep; + var dTheta = level.dTheta = sweep / Math.max(1, level.length - 1); + + // calculate the radius + if (level.length > 1 && options.avoidOverlap) { + // but only if more than one node (can't overlap) + var dcos = Math.cos(dTheta) - Math.cos(0); + var dsin = Math.sin(dTheta) - Math.sin(0); + var rMin = Math.sqrt(minDist * minDist / (dcos * dcos + dsin * dsin)); // s.t. no nodes overlapping + + r = Math.max(rMin, r); + } + level.r = r; + r += minDist; + } + if (options.equidistant) { + var rDeltaMax = 0; + var _r = 0; + for (var _i4 = 0; _i4 < levels.length; _i4++) { + var _level = levels[_i4]; + var rDelta = _level.r - _r; + rDeltaMax = Math.max(rDeltaMax, rDelta); + } + _r = 0; + for (var _i5 = 0; _i5 < levels.length; _i5++) { + var _level2 = levels[_i5]; + if (_i5 === 0) { + _r = _level2.r; + } + _level2.r = _r; + _r += rDeltaMax; + } + } + + // calculate the node positions + var pos = {}; // id => position + for (var _i6 = 0; _i6 < levels.length; _i6++) { + var _level3 = levels[_i6]; + var _dTheta = _level3.dTheta; + var _r2 = _level3.r; + for (var j = 0; j < _level3.length; j++) { + var _val = _level3[j]; + var theta = options.startAngle + (clockwise ? 1 : -1) * _dTheta * j; + var p = { + x: center.x + _r2 * Math.cos(theta), + y: center.y + _r2 * Math.sin(theta) + }; + pos[_val.node.id()] = p; + } + } + + // position the nodes + eles.nodes().layoutPositions(this, options, function (ele) { + var id = ele.id(); + return pos[id]; + }); + return this; // chaining +}; + +/* +The CoSE layout was written by Gerardo Huck. +https://www.linkedin.com/in/gerardohuck/ + +Based on the following article: +http://dl.acm.org/citation.cfm?id=1498047 + +Modifications tracked on Github. +*/ +var DEBUG; + +/** + * @brief : default layout options + */ +var defaults$4 = { + // Called on `layoutready` + ready: function ready() {}, + // Called on `layoutstop` + stop: function stop() {}, + // Whether to animate while running the layout + // true : Animate continuously as the layout is running + // false : Just show the end result + // 'end' : Animate with the end result, from the initial positions to the end positions + animate: true, + // Easing of the animation for animate:'end' + animationEasing: undefined, + // The duration of the animation for animate:'end' + animationDuration: undefined, + // A function that determines whether the node should be animated + // All nodes animated by default on animate enabled + // Non-animated nodes are positioned immediately when the layout starts + animateFilter: function animateFilter(node, i) { + return true; + }, + // The layout animates only after this many milliseconds for animate:true + // (prevents flashing on fast runs) + animationThreshold: 250, + // Number of iterations between consecutive screen positions update + refresh: 20, + // Whether to fit the network view after when done + fit: true, + // Padding on fit + padding: 30, + // Constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + boundingBox: undefined, + // Excludes the label when calculating node bounding boxes for the layout algorithm + nodeDimensionsIncludeLabels: false, + // Randomize the initial positions of the nodes (true) or use existing positions (false) + randomize: false, + // Extra spacing between components in non-compound graphs + componentSpacing: 40, + // Node repulsion (non overlapping) multiplier + nodeRepulsion: function nodeRepulsion(node) { + return 2048; + }, + // Node repulsion (overlapping) multiplier + nodeOverlap: 4, + // Ideal edge (non nested) length + idealEdgeLength: function idealEdgeLength(edge) { + return 32; + }, + // Divisor to compute edge forces + edgeElasticity: function edgeElasticity(edge) { + return 32; + }, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 1.2, + // Gravity force (constant) + gravity: 1, + // Maximum number of iterations to perform + numIter: 1000, + // Initial temperature (maximum node displacement) + initialTemp: 1000, + // Cooling factor (how the temperature is reduced between consecutive iterations + coolingFactor: 0.99, + // Lower temperature threshold (below this point the layout will end) + minTemp: 1.0 +}; + +/** + * @brief : constructor + * @arg options : object containing layout options + */ +function CoseLayout(options) { + this.options = extend({}, defaults$4, options); + this.options.layout = this; + + // Exclude any edge that has a source or target node that is not in the set of passed-in nodes + var nodes = this.options.eles.nodes(); + var edges = this.options.eles.edges(); + var notEdges = edges.filter(function (e) { + var sourceId = e.source().data('id'); + var targetId = e.target().data('id'); + var hasSource = nodes.some(function (n) { + return n.data('id') === sourceId; + }); + var hasTarget = nodes.some(function (n) { + return n.data('id') === targetId; + }); + return !hasSource || !hasTarget; + }); + this.options.eles = this.options.eles.not(notEdges); +} + +/** + * @brief : runs the layout + */ +CoseLayout.prototype.run = function () { + var options = this.options; + var cy = options.cy; + var layout = this; + layout.stopped = false; + if (options.animate === true || options.animate === false) { + layout.emit({ + type: 'layoutstart', + layout: layout + }); + } + + // Set DEBUG - Global variable + if (true === options.debug) { + DEBUG = true; + } else { + DEBUG = false; + } + + // Initialize layout info + var layoutInfo = createLayoutInfo(cy, layout, options); + + // Show LayoutInfo contents if debugging + if (DEBUG) { + printLayoutInfo(layoutInfo); + } + + // If required, randomize node positions + if (options.randomize) { + randomizePositions(layoutInfo); + } + var startTime = performanceNow(); + var refresh = function refresh() { + refreshPositions(layoutInfo, cy, options); + + // Fit the graph if necessary + if (true === options.fit) { + cy.fit(options.padding); + } + }; + var mainLoop = function mainLoop(i) { + if (layout.stopped || i >= options.numIter) { + // logDebug("Layout manually stopped. Stopping computation in step " + i); + return false; + } + + // Do one step in the phisical simulation + step(layoutInfo, options); + + // Update temperature + layoutInfo.temperature = layoutInfo.temperature * options.coolingFactor; + // logDebug("New temperature: " + layoutInfo.temperature); + + if (layoutInfo.temperature < options.minTemp) { + // logDebug("Temperature drop below minimum threshold. Stopping computation in step " + i); + return false; + } + return true; + }; + var done = function done() { + if (options.animate === true || options.animate === false) { + refresh(); + + // Layout has finished + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + } else { + var nodes = options.eles.nodes(); + var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes); + nodes.layoutPositions(layout, options, getScaledPos); + } + }; + var i = 0; + var loopRet = true; + if (options.animate === true) { + var frame = function frame() { + var f = 0; + while (loopRet && f < options.refresh) { + loopRet = mainLoop(i); + i++; + f++; + } + if (!loopRet) { + // it's done + separateComponents(layoutInfo, options); + done(); + } else { + var now = performanceNow(); + if (now - startTime >= options.animationThreshold) { + refresh(); + } + requestAnimationFrame$1(frame); + } + }; + frame(); + } else { + while (loopRet) { + loopRet = mainLoop(i); + i++; + } + separateComponents(layoutInfo, options); + done(); + } + return this; // chaining +}; + +/** + * @brief : called on continuous layouts to stop them before they finish + */ +CoseLayout.prototype.stop = function () { + this.stopped = true; + if (this.thread) { + this.thread.stop(); + } + this.emit('layoutstop'); + return this; // chaining +}; + +CoseLayout.prototype.destroy = function () { + if (this.thread) { + this.thread.stop(); + } + return this; // chaining +}; + +/** + * @brief : Creates an object which is contains all the data + * used in the layout process + * @arg cy : cytoscape.js object + * @return : layoutInfo object initialized + */ +var createLayoutInfo = function createLayoutInfo(cy, layout, options) { + // Shortcut + var edges = options.eles.edges(); + var nodes = options.eles.nodes(); + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var layoutInfo = { + isCompound: cy.hasCompoundNodes(), + layoutNodes: [], + idToIndex: {}, + nodeSize: nodes.size(), + graphSet: [], + indexToGraph: [], + layoutEdges: [], + edgeSize: edges.size(), + temperature: options.initialTemp, + clientWidth: bb.w, + clientHeight: bb.h, + boundingBox: bb + }; + var components = options.eles.components(); + var id2cmptId = {}; + for (var i = 0; i < components.length; i++) { + var component = components[i]; + for (var j = 0; j < component.length; j++) { + var node = component[j]; + id2cmptId[node.id()] = i; + } + } + + // Iterate over all nodes, creating layout nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = nodes[i]; + var nbb = n.layoutDimensions(options); + var tempNode = {}; + tempNode.isLocked = n.locked(); + tempNode.id = n.data('id'); + tempNode.parentId = n.data('parent'); + tempNode.cmptId = id2cmptId[n.id()]; + tempNode.children = []; + tempNode.positionX = n.position('x'); + tempNode.positionY = n.position('y'); + tempNode.offsetX = 0; + tempNode.offsetY = 0; + tempNode.height = nbb.w; + tempNode.width = nbb.h; + tempNode.maxX = tempNode.positionX + tempNode.width / 2; + tempNode.minX = tempNode.positionX - tempNode.width / 2; + tempNode.maxY = tempNode.positionY + tempNode.height / 2; + tempNode.minY = tempNode.positionY - tempNode.height / 2; + tempNode.padLeft = parseFloat(n.style('padding')); + tempNode.padRight = parseFloat(n.style('padding')); + tempNode.padTop = parseFloat(n.style('padding')); + tempNode.padBottom = parseFloat(n.style('padding')); + + // forces + tempNode.nodeRepulsion = fn$6(options.nodeRepulsion) ? options.nodeRepulsion(n) : options.nodeRepulsion; + + // Add new node + layoutInfo.layoutNodes.push(tempNode); + // Add entry to id-index map + layoutInfo.idToIndex[tempNode.id] = i; + } + + // Inline implementation of a queue, used for traversing the graph in BFS order + var queue = []; + var start = 0; // Points to the start the queue + var end = -1; // Points to the end of the queue + + var tempGraph = []; + + // Second pass to add child information and + // initialize queue for hierarchical traversal + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + var p_id = n.parentId; + // Check if node n has a parent node + if (null != p_id) { + // Add node Id to parent's list of children + layoutInfo.layoutNodes[layoutInfo.idToIndex[p_id]].children.push(n.id); + } else { + // If a node doesn't have a parent, then it's in the root graph + queue[++end] = n.id; + tempGraph.push(n.id); + } + } + + // Add root graph to graphSet + layoutInfo.graphSet.push(tempGraph); + + // Traverse the graph, level by level, + while (start <= end) { + // Get the node to visit and remove it from queue + var node_id = queue[start++]; + var node_ix = layoutInfo.idToIndex[node_id]; + var node = layoutInfo.layoutNodes[node_ix]; + var children = node.children; + if (children.length > 0) { + // Add children nodes as a new graph to graph set + layoutInfo.graphSet.push(children); + // Add children to que queue to be visited + for (var i = 0; i < children.length; i++) { + queue[++end] = children[i]; + } + } + } + + // Create indexToGraph map + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + for (var j = 0; j < graph.length; j++) { + var index = layoutInfo.idToIndex[graph[j]]; + layoutInfo.indexToGraph[index] = i; + } + } + + // Iterate over all edges, creating Layout Edges + for (var i = 0; i < layoutInfo.edgeSize; i++) { + var e = edges[i]; + var tempEdge = {}; + tempEdge.id = e.data('id'); + tempEdge.sourceId = e.data('source'); + tempEdge.targetId = e.data('target'); + + // Compute ideal length + var idealLength = fn$6(options.idealEdgeLength) ? options.idealEdgeLength(e) : options.idealEdgeLength; + var elasticity = fn$6(options.edgeElasticity) ? options.edgeElasticity(e) : options.edgeElasticity; + + // Check if it's an inter graph edge + var sourceIx = layoutInfo.idToIndex[tempEdge.sourceId]; + var targetIx = layoutInfo.idToIndex[tempEdge.targetId]; + var sourceGraph = layoutInfo.indexToGraph[sourceIx]; + var targetGraph = layoutInfo.indexToGraph[targetIx]; + if (sourceGraph != targetGraph) { + // Find lowest common graph ancestor + var lca = findLCA(tempEdge.sourceId, tempEdge.targetId, layoutInfo); + + // Compute sum of node depths, relative to lca graph + var lcaGraph = layoutInfo.graphSet[lca]; + var depth = 0; + + // Source depth + var tempNode = layoutInfo.layoutNodes[sourceIx]; + while (-1 === lcaGraph.indexOf(tempNode.id)) { + tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]]; + depth++; + } + + // Target depth + tempNode = layoutInfo.layoutNodes[targetIx]; + while (-1 === lcaGraph.indexOf(tempNode.id)) { + tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]]; + depth++; + } + + // logDebug('LCA of nodes ' + tempEdge.sourceId + ' and ' + tempEdge.targetId + + // ". Index: " + lca + " Contents: " + lcaGraph.toString() + + // ". Depth: " + depth); + + // Update idealLength + idealLength *= depth * options.nestingFactor; + } + tempEdge.idealLength = idealLength; + tempEdge.elasticity = elasticity; + layoutInfo.layoutEdges.push(tempEdge); + } + + // Finally, return layoutInfo object + return layoutInfo; +}; + +/** + * @brief : This function finds the index of the lowest common + * graph ancestor between 2 nodes in the subtree + * (from the graph hierarchy induced tree) whose + * root is graphIx + * + * @arg node1: node1's ID + * @arg node2: node2's ID + * @arg layoutInfo: layoutInfo object + * + */ +var findLCA = function findLCA(node1, node2, layoutInfo) { + // Find their common ancester, starting from the root graph + var res = findLCA_aux(node1, node2, 0, layoutInfo); + if (2 > res.count) { + // If aux function couldn't find the common ancester, + // then it is the root graph + return 0; + } else { + return res.graph; + } +}; + +/** + * @brief : Auxiliary function used for LCA computation + * + * @arg node1 : node1's ID + * @arg node2 : node2's ID + * @arg graphIx : subgraph index + * @arg layoutInfo : layoutInfo object + * + * @return : object of the form {count: X, graph: Y}, where: + * X is the number of ancestors (max: 2) found in + * graphIx (and it's subgraphs), + * Y is the graph index of the lowest graph containing + * all X nodes + */ +var findLCA_aux = function findLCA_aux(node1, node2, graphIx, layoutInfo) { + var graph = layoutInfo.graphSet[graphIx]; + // If both nodes belongs to graphIx + if (-1 < graph.indexOf(node1) && -1 < graph.indexOf(node2)) { + return { + count: 2, + graph: graphIx + }; + } + + // Make recursive calls for all subgraphs + var c = 0; + for (var i = 0; i < graph.length; i++) { + var nodeId = graph[i]; + var nodeIx = layoutInfo.idToIndex[nodeId]; + var children = layoutInfo.layoutNodes[nodeIx].children; + + // If the node has no child, skip it + if (0 === children.length) { + continue; + } + var childGraphIx = layoutInfo.indexToGraph[layoutInfo.idToIndex[children[0]]]; + var result = findLCA_aux(node1, node2, childGraphIx, layoutInfo); + if (0 === result.count) { + // Neither node1 nor node2 are present in this subgraph + continue; + } else if (1 === result.count) { + // One of (node1, node2) is present in this subgraph + c++; + if (2 === c) { + // We've already found both nodes, no need to keep searching + break; + } + } else { + // Both nodes are present in this subgraph + return result; + } + } + return { + count: c, + graph: graphIx + }; +}; + +/** + * @brief: printsLayoutInfo into js console + * Only used for debbuging + */ +var printLayoutInfo; + +/** + * @brief : Randomizes the position of all nodes + */ +var randomizePositions = function randomizePositions(layoutInfo, cy) { + var width = layoutInfo.clientWidth; + var height = layoutInfo.clientHeight; + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + + // No need to randomize compound nodes or locked nodes + if (0 === n.children.length && !n.isLocked) { + n.positionX = Math.random() * width; + n.positionY = Math.random() * height; + } + } +}; +var getScaleInBoundsFn = function getScaleInBoundsFn(layoutInfo, options, nodes) { + var bb = layoutInfo.boundingBox; + var coseBB = { + x1: Infinity, + x2: -Infinity, + y1: Infinity, + y2: -Infinity + }; + if (options.boundingBox) { + nodes.forEach(function (node) { + var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[node.data('id')]]; + coseBB.x1 = Math.min(coseBB.x1, lnode.positionX); + coseBB.x2 = Math.max(coseBB.x2, lnode.positionX); + coseBB.y1 = Math.min(coseBB.y1, lnode.positionY); + coseBB.y2 = Math.max(coseBB.y2, lnode.positionY); + }); + coseBB.w = coseBB.x2 - coseBB.x1; + coseBB.h = coseBB.y2 - coseBB.y1; + } + return function (ele, i) { + var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[ele.data('id')]]; + if (options.boundingBox) { + // then add extra bounding box constraint + var pctX = (lnode.positionX - coseBB.x1) / coseBB.w; + var pctY = (lnode.positionY - coseBB.y1) / coseBB.h; + return { + x: bb.x1 + pctX * bb.w, + y: bb.y1 + pctY * bb.h + }; + } else { + return { + x: lnode.positionX, + y: lnode.positionY + }; + } + }; +}; + +/** + * @brief : Updates the positions of nodes in the network + * @arg layoutInfo : LayoutInfo object + * @arg cy : Cytoscape object + * @arg options : Layout options + */ +var refreshPositions = function refreshPositions(layoutInfo, cy, options) { + // var s = 'Refreshing positions'; + // logDebug(s); + + var layout = options.layout; + var nodes = options.eles.nodes(); + var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes); + nodes.positions(getScaledPos); + + // Trigger layoutReady only on first call + if (true !== layoutInfo.ready) { + // s = 'Triggering layoutready'; + // logDebug(s); + layoutInfo.ready = true; + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: this + }); + } +}; + +/** + * @brief : Logs a debug message in JS console, if DEBUG is ON + */ +// var logDebug = function(text) { +// if (DEBUG) { +// console.debug(text); +// } +// }; + +/** + * @brief : Performs one iteration of the physical simulation + * @arg layoutInfo : LayoutInfo object already initialized + * @arg cy : Cytoscape object + * @arg options : Layout options + */ +var step = function step(layoutInfo, options, _step) { + // var s = "\n\n###############################"; + // s += "\nSTEP: " + step; + // s += "\n###############################\n"; + // logDebug(s); + + // Calculate node repulsions + calculateNodeForces(layoutInfo, options); + // Calculate edge forces + calculateEdgeForces(layoutInfo); + // Calculate gravity forces + calculateGravityForces(layoutInfo, options); + // Propagate forces from parent to child + propagateForces(layoutInfo); + // Update positions based on calculated forces + updatePositions(layoutInfo); +}; + +/** + * @brief : Computes the node repulsion forces + */ +var calculateNodeForces = function calculateNodeForces(layoutInfo, options) { + // Go through each of the graphs in graphSet + // Nodes only repel each other if they belong to the same graph + // var s = 'calculateNodeForces'; + // logDebug(s); + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + var numNodes = graph.length; + + // s = "Set: " + graph.toString(); + // logDebug(s); + + // Now get all the pairs of nodes + // Only get each pair once, (A, B) = (B, A) + for (var j = 0; j < numNodes; j++) { + var node1 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; + for (var k = j + 1; k < numNodes; k++) { + var node2 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[k]]]; + nodeRepulsion(node1, node2, layoutInfo, options); + } + } + } +}; +var randomDistance = function randomDistance(max) { + return -max + 2 * max * Math.random(); +}; + +/** + * @brief : Compute the node repulsion forces between a pair of nodes + */ +var nodeRepulsion = function nodeRepulsion(node1, node2, layoutInfo, options) { + // var s = "Node repulsion. Node1: " + node1.id + " Node2: " + node2.id; + + var cmptId1 = node1.cmptId; + var cmptId2 = node2.cmptId; + if (cmptId1 !== cmptId2 && !layoutInfo.isCompound) { + return; + } + + // Get direction of line connecting both node centers + var directionX = node2.positionX - node1.positionX; + var directionY = node2.positionY - node1.positionY; + var maxRandDist = 1; + // s += "\ndirectionX: " + directionX + ", directionY: " + directionY; + + // If both centers are the same, apply a random force + if (0 === directionX && 0 === directionY) { + directionX = randomDistance(maxRandDist); + directionY = randomDistance(maxRandDist); + } + var overlap = nodesOverlap(node1, node2, directionX, directionY); + if (overlap > 0) { + // s += "\nNodes DO overlap."; + // s += "\nOverlap: " + overlap; + // If nodes overlap, repulsion force is proportional + // to the overlap + var force = options.nodeOverlap * overlap; + + // Compute the module and components of the force vector + var distance = Math.sqrt(directionX * directionX + directionY * directionY); + // s += "\nDistance: " + distance; + var forceX = force * directionX / distance; + var forceY = force * directionY / distance; + } else { + // s += "\nNodes do NOT overlap."; + // If there's no overlap, force is inversely proportional + // to squared distance + + // Get clipping points for both nodes + var point1 = findClippingPoint(node1, directionX, directionY); + var point2 = findClippingPoint(node2, -1 * directionX, -1 * directionY); + + // Use clipping points to compute distance + var distanceX = point2.x - point1.x; + var distanceY = point2.y - point1.y; + var distanceSqr = distanceX * distanceX + distanceY * distanceY; + var distance = Math.sqrt(distanceSqr); + // s += "\nDistance: " + distance; + + // Compute the module and components of the force vector + var force = (node1.nodeRepulsion + node2.nodeRepulsion) / distanceSqr; + var forceX = force * distanceX / distance; + var forceY = force * distanceY / distance; + } + + // Apply force + if (!node1.isLocked) { + node1.offsetX -= forceX; + node1.offsetY -= forceY; + } + if (!node2.isLocked) { + node2.offsetX += forceX; + node2.offsetY += forceY; + } + + // s += "\nForceX: " + forceX + " ForceY: " + forceY; + // logDebug(s); + + return; +}; + +/** + * @brief : Determines whether two nodes overlap or not + * @return : Amount of overlapping (0 => no overlap) + */ +var nodesOverlap = function nodesOverlap(node1, node2, dX, dY) { + if (dX > 0) { + var overlapX = node1.maxX - node2.minX; + } else { + var overlapX = node2.maxX - node1.minX; + } + if (dY > 0) { + var overlapY = node1.maxY - node2.minY; + } else { + var overlapY = node2.maxY - node1.minY; + } + if (overlapX >= 0 && overlapY >= 0) { + return Math.sqrt(overlapX * overlapX + overlapY * overlapY); + } else { + return 0; + } +}; + +/** + * @brief : Finds the point in which an edge (direction dX, dY) intersects + * the rectangular bounding box of it's source/target node + */ +var findClippingPoint = function findClippingPoint(node, dX, dY) { + // Shorcuts + var X = node.positionX; + var Y = node.positionY; + var H = node.height || 1; + var W = node.width || 1; + var dirSlope = dY / dX; + var nodeSlope = H / W; + + // var s = 'Computing clipping point of node ' + node.id + + // " . Height: " + H + ", Width: " + W + + // "\nDirection " + dX + ", " + dY; + // + // Compute intersection + var res = {}; + + // Case: Vertical direction (up) + if (0 === dX && 0 < dY) { + res.x = X; + // s += "\nUp direction"; + res.y = Y + H / 2; + return res; + } + + // Case: Vertical direction (down) + if (0 === dX && 0 > dY) { + res.x = X; + res.y = Y + H / 2; + // s += "\nDown direction"; + + return res; + } + + // Case: Intersects the right border + if (0 < dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) { + res.x = X + W / 2; + res.y = Y + W * dY / 2 / dX; + // s += "\nRightborder"; + + return res; + } + + // Case: Intersects the left border + if (0 > dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) { + res.x = X - W / 2; + res.y = Y - W * dY / 2 / dX; + // s += "\nLeftborder"; + + return res; + } + + // Case: Intersects the top border + if (0 < dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) { + res.x = X + H * dX / 2 / dY; + res.y = Y + H / 2; + // s += "\nTop border"; + + return res; + } + + // Case: Intersects the bottom border + if (0 > dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) { + res.x = X - H * dX / 2 / dY; + res.y = Y - H / 2; + // s += "\nBottom border"; + + return res; + } + + // s += "\nClipping point found at " + res.x + ", " + res.y; + // logDebug(s); + return res; +}; + +/** + * @brief : Calculates all edge forces + */ +var calculateEdgeForces = function calculateEdgeForces(layoutInfo, options) { + // Iterate over all edges + for (var i = 0; i < layoutInfo.edgeSize; i++) { + // Get edge, source & target nodes + var edge = layoutInfo.layoutEdges[i]; + var sourceIx = layoutInfo.idToIndex[edge.sourceId]; + var source = layoutInfo.layoutNodes[sourceIx]; + var targetIx = layoutInfo.idToIndex[edge.targetId]; + var target = layoutInfo.layoutNodes[targetIx]; + + // Get direction of line connecting both node centers + var directionX = target.positionX - source.positionX; + var directionY = target.positionY - source.positionY; + + // If both centers are the same, do nothing. + // A random force has already been applied as node repulsion + if (0 === directionX && 0 === directionY) { + continue; + } + + // Get clipping points for both nodes + var point1 = findClippingPoint(source, directionX, directionY); + var point2 = findClippingPoint(target, -1 * directionX, -1 * directionY); + var lx = point2.x - point1.x; + var ly = point2.y - point1.y; + var l = Math.sqrt(lx * lx + ly * ly); + var force = Math.pow(edge.idealLength - l, 2) / edge.elasticity; + if (0 !== l) { + var forceX = force * lx / l; + var forceY = force * ly / l; + } else { + var forceX = 0; + var forceY = 0; + } + + // Add this force to target and source nodes + if (!source.isLocked) { + source.offsetX += forceX; + source.offsetY += forceY; + } + if (!target.isLocked) { + target.offsetX -= forceX; + target.offsetY -= forceY; + } + + // var s = 'Edge force between nodes ' + source.id + ' and ' + target.id; + // s += "\nDistance: " + l + " Force: (" + forceX + ", " + forceY + ")"; + // logDebug(s); + } +}; + +/** + * @brief : Computes gravity forces for all nodes + */ +var calculateGravityForces = function calculateGravityForces(layoutInfo, options) { + if (options.gravity === 0) { + return; + } + var distThreshold = 1; + + // var s = 'calculateGravityForces'; + // logDebug(s); + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + var numNodes = graph.length; + + // s = "Set: " + graph.toString(); + // logDebug(s); + + // Compute graph center + if (0 === i) { + var centerX = layoutInfo.clientHeight / 2; + var centerY = layoutInfo.clientWidth / 2; + } else { + // Get Parent node for this graph, and use its position as center + var temp = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[0]]]; + var parent = layoutInfo.layoutNodes[layoutInfo.idToIndex[temp.parentId]]; + var centerX = parent.positionX; + var centerY = parent.positionY; + } + // s = "Center found at: " + centerX + ", " + centerY; + // logDebug(s); + + // Apply force to all nodes in graph + for (var j = 0; j < numNodes; j++) { + var node = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; + // s = "Node: " + node.id; + + if (node.isLocked) { + continue; + } + var dx = centerX - node.positionX; + var dy = centerY - node.positionY; + var d = Math.sqrt(dx * dx + dy * dy); + if (d > distThreshold) { + var fx = options.gravity * dx / d; + var fy = options.gravity * dy / d; + node.offsetX += fx; + node.offsetY += fy; + // s += ": Applied force: " + fx + ", " + fy; + } + // logDebug(s); + } + } +}; + +/** + * @brief : This function propagates the existing offsets from + * parent nodes to its descendents. + * @arg layoutInfo : layoutInfo Object + * @arg cy : cytoscape Object + * @arg options : Layout options + */ +var propagateForces = function propagateForces(layoutInfo, options) { + // Inline implementation of a queue, used for traversing the graph in BFS order + var queue = []; + var start = 0; // Points to the start the queue + var end = -1; // Points to the end of the queue + + // logDebug('propagateForces'); + + // Start by visiting the nodes in the root graph + queue.push.apply(queue, layoutInfo.graphSet[0]); + end += layoutInfo.graphSet[0].length; + + // Traverse the graph, level by level, + while (start <= end) { + // Get the node to visit and remove it from queue + var nodeId = queue[start++]; + var nodeIndex = layoutInfo.idToIndex[nodeId]; + var node = layoutInfo.layoutNodes[nodeIndex]; + var children = node.children; + + // We only need to process the node if it's compound + if (0 < children.length && !node.isLocked) { + var offX = node.offsetX; + var offY = node.offsetY; + + // var s = "Propagating offset from parent node : " + node.id + + // ". OffsetX: " + offX + ". OffsetY: " + offY; + // s += "\n Children: " + children.toString(); + // logDebug(s); + + for (var i = 0; i < children.length; i++) { + var childNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[children[i]]]; + // Propagate offset + childNode.offsetX += offX; + childNode.offsetY += offY; + // Add children to queue to be visited + queue[++end] = children[i]; + } + + // Reset parent offsets + node.offsetX = 0; + node.offsetY = 0; + } + } +}; + +/** + * @brief : Updates the layout model positions, based on + * the accumulated forces + */ +var updatePositions = function updatePositions(layoutInfo, options) { + // var s = 'Updating positions'; + // logDebug(s); + + // Reset boundaries for compound nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length) { + // logDebug("Resetting boundaries of compound node: " + n.id); + n.maxX = undefined; + n.minX = undefined; + n.maxY = undefined; + n.minY = undefined; + } + } + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length || n.isLocked) { + // No need to set compound or locked node position + // logDebug("Skipping position update of node: " + n.id); + continue; + } + // s = "Node: " + n.id + " Previous position: (" + + // n.positionX + ", " + n.positionY + ")."; + + // Limit displacement in order to improve stability + var tempForce = limitForce(n.offsetX, n.offsetY, layoutInfo.temperature); + n.positionX += tempForce.x; + n.positionY += tempForce.y; + n.offsetX = 0; + n.offsetY = 0; + n.minX = n.positionX - n.width; + n.maxX = n.positionX + n.width; + n.minY = n.positionY - n.height; + n.maxY = n.positionY + n.height; + // s += " New Position: (" + n.positionX + ", " + n.positionY + ")."; + // logDebug(s); + + // Update ancestry boudaries + updateAncestryBoundaries(n, layoutInfo); + } + + // Update size, position of compund nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length && !n.isLocked) { + n.positionX = (n.maxX + n.minX) / 2; + n.positionY = (n.maxY + n.minY) / 2; + n.width = n.maxX - n.minX; + n.height = n.maxY - n.minY; + // s = "Updating position, size of compound node " + n.id; + // s += "\nPositionX: " + n.positionX + ", PositionY: " + n.positionY; + // s += "\nWidth: " + n.width + ", Height: " + n.height; + // logDebug(s); + } + } +}; + +/** + * @brief : Limits a force (forceX, forceY) to be not + * greater (in modulo) than max. + 8 Preserves force direction. + */ +var limitForce = function limitForce(forceX, forceY, max) { + // var s = "Limiting force: (" + forceX + ", " + forceY + "). Max: " + max; + var force = Math.sqrt(forceX * forceX + forceY * forceY); + if (force > max) { + var res = { + x: max * forceX / force, + y: max * forceY / force + }; + } else { + var res = { + x: forceX, + y: forceY + }; + } + + // s += ".\nResult: (" + res.x + ", " + res.y + ")"; + // logDebug(s); + + return res; +}; + +/** + * @brief : Function used for keeping track of compound node + * sizes, since they should bound all their subnodes. + */ +var updateAncestryBoundaries = function updateAncestryBoundaries(node, layoutInfo) { + // var s = "Propagating new position/size of node " + node.id; + var parentId = node.parentId; + if (null == parentId) { + // If there's no parent, we are done + // s += ". No parent node."; + // logDebug(s); + return; + } + + // Get Parent Node + var p = layoutInfo.layoutNodes[layoutInfo.idToIndex[parentId]]; + var flag = false; + + // MaxX + if (null == p.maxX || node.maxX + p.padRight > p.maxX) { + p.maxX = node.maxX + p.padRight; + flag = true; + // s += "\nNew maxX for parent node " + p.id + ": " + p.maxX; + } + + // MinX + if (null == p.minX || node.minX - p.padLeft < p.minX) { + p.minX = node.minX - p.padLeft; + flag = true; + // s += "\nNew minX for parent node " + p.id + ": " + p.minX; + } + + // MaxY + if (null == p.maxY || node.maxY + p.padBottom > p.maxY) { + p.maxY = node.maxY + p.padBottom; + flag = true; + // s += "\nNew maxY for parent node " + p.id + ": " + p.maxY; + } + + // MinY + if (null == p.minY || node.minY - p.padTop < p.minY) { + p.minY = node.minY - p.padTop; + flag = true; + // s += "\nNew minY for parent node " + p.id + ": " + p.minY; + } + + // If updated boundaries, propagate changes upward + if (flag) { + // logDebug(s); + return updateAncestryBoundaries(p, layoutInfo); + } + + // s += ". No changes in boundaries/position of parent node " + p.id; + // logDebug(s); + return; +}; +var separateComponents = function separateComponents(layoutInfo, options) { + var nodes = layoutInfo.layoutNodes; + var components = []; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var cid = node.cmptId; + var component = components[cid] = components[cid] || []; + component.push(node); + } + var totalA = 0; + for (var i = 0; i < components.length; i++) { + var c = components[i]; + if (!c) { + continue; + } + c.x1 = Infinity; + c.x2 = -Infinity; + c.y1 = Infinity; + c.y2 = -Infinity; + for (var j = 0; j < c.length; j++) { + var n = c[j]; + c.x1 = Math.min(c.x1, n.positionX - n.width / 2); + c.x2 = Math.max(c.x2, n.positionX + n.width / 2); + c.y1 = Math.min(c.y1, n.positionY - n.height / 2); + c.y2 = Math.max(c.y2, n.positionY + n.height / 2); + } + c.w = c.x2 - c.x1; + c.h = c.y2 - c.y1; + totalA += c.w * c.h; + } + components.sort(function (c1, c2) { + return c2.w * c2.h - c1.w * c1.h; + }); + var x = 0; + var y = 0; + var usedW = 0; + var rowH = 0; + var maxRowW = Math.sqrt(totalA) * layoutInfo.clientWidth / layoutInfo.clientHeight; + for (var i = 0; i < components.length; i++) { + var c = components[i]; + if (!c) { + continue; + } + for (var j = 0; j < c.length; j++) { + var n = c[j]; + if (!n.isLocked) { + n.positionX += x - c.x1; + n.positionY += y - c.y1; + } + } + x += c.w + options.componentSpacing; + usedW += c.w + options.componentSpacing; + rowH = Math.max(rowH, c.h); + if (usedW > maxRowW) { + y += rowH + options.componentSpacing; + x = 0; + usedW = 0; + rowH = 0; + } + } +}; + +var defaults$3 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // padding used on fit + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + avoidOverlapPadding: 10, + // extra spacing around nodes when avoidOverlap: true + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + condense: false, + // uses all available space on false, uses minimal space on true + rows: undefined, + // force num of rows in the grid + cols: undefined, + // force num of columns in the grid + position: function position(node) {}, + // returns { row, col } for element + sort: undefined, + // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function GridLayout(options) { + this.options = extend({}, defaults$3, options); +} +GridLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().not(':parent'); + if (options.sort) { + nodes = nodes.sort(options.sort); + } + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + if (bb.h === 0 || bb.w === 0) { + eles.nodes().layoutPositions(this, options, function (ele) { + return { + x: bb.x1, + y: bb.y1 + }; + }); + } else { + // width/height * splits^2 = cells where splits is number of times to split width + var cells = nodes.size(); + var splits = Math.sqrt(cells * bb.h / bb.w); + var rows = Math.round(splits); + var cols = Math.round(bb.w / bb.h * splits); + var small = function small(val) { + if (val == null) { + return Math.min(rows, cols); + } else { + var min = Math.min(rows, cols); + if (min == rows) { + rows = val; + } else { + cols = val; + } + } + }; + var large = function large(val) { + if (val == null) { + return Math.max(rows, cols); + } else { + var max = Math.max(rows, cols); + if (max == rows) { + rows = val; + } else { + cols = val; + } + } + }; + var oRows = options.rows; + var oCols = options.cols != null ? options.cols : options.columns; + + // if rows or columns were set in options, use those values + if (oRows != null && oCols != null) { + rows = oRows; + cols = oCols; + } else if (oRows != null && oCols == null) { + rows = oRows; + cols = Math.ceil(cells / rows); + } else if (oRows == null && oCols != null) { + cols = oCols; + rows = Math.ceil(cells / cols); + } + + // otherwise use the automatic values and adjust accordingly + + // if rounding was up, see if we can reduce rows or columns + else if (cols * rows > cells) { + var sm = small(); + var lg = large(); + + // reducing the small side takes away the most cells, so try it first + if ((sm - 1) * lg >= cells) { + small(sm - 1); + } else if ((lg - 1) * sm >= cells) { + large(lg - 1); + } + } else { + // if rounding was too low, add rows or columns + while (cols * rows < cells) { + var _sm = small(); + var _lg = large(); + + // try to add to larger side first (adds less in multiplication) + if ((_lg + 1) * _sm >= cells) { + large(_lg + 1); + } else { + small(_sm + 1); + } + } + } + var cellWidth = bb.w / cols; + var cellHeight = bb.h / rows; + if (options.condense) { + cellWidth = 0; + cellHeight = 0; + } + if (options.avoidOverlap) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var pos = node._private.position; + if (pos.x == null || pos.y == null) { + // for bb + pos.x = 0; + pos.y = 0; + } + var nbb = node.layoutDimensions(options); + var p = options.avoidOverlapPadding; + var w = nbb.w + p; + var h = nbb.h + p; + cellWidth = Math.max(cellWidth, w); + cellHeight = Math.max(cellHeight, h); + } + } + var cellUsed = {}; // e.g. 'c-0-2' => true + + var used = function used(row, col) { + return cellUsed['c-' + row + '-' + col] ? true : false; + }; + var use = function use(row, col) { + cellUsed['c-' + row + '-' + col] = true; + }; + + // to keep track of current cell position + var row = 0; + var col = 0; + var moveToNextCell = function moveToNextCell() { + col++; + if (col >= cols) { + col = 0; + row++; + } + }; + + // get a cache of all the manual positions + var id2manPos = {}; + for (var _i = 0; _i < nodes.length; _i++) { + var _node = nodes[_i]; + var rcPos = options.position(_node); + if (rcPos && (rcPos.row !== undefined || rcPos.col !== undefined)) { + // must have at least row or col def'd + var _pos = { + row: rcPos.row, + col: rcPos.col + }; + if (_pos.col === undefined) { + // find unused col + _pos.col = 0; + while (used(_pos.row, _pos.col)) { + _pos.col++; + } + } else if (_pos.row === undefined) { + // find unused row + _pos.row = 0; + while (used(_pos.row, _pos.col)) { + _pos.row++; + } + } + id2manPos[_node.id()] = _pos; + use(_pos.row, _pos.col); + } + } + var getPos = function getPos(element, i) { + var x, y; + if (element.locked() || element.isParent()) { + return false; + } + + // see if we have a manual position set + var rcPos = id2manPos[element.id()]; + if (rcPos) { + x = rcPos.col * cellWidth + cellWidth / 2 + bb.x1; + y = rcPos.row * cellHeight + cellHeight / 2 + bb.y1; + } else { + // otherwise set automatically + + while (used(row, col)) { + moveToNextCell(); + } + x = col * cellWidth + cellWidth / 2 + bb.x1; + y = row * cellHeight + cellHeight / 2 + bb.y1; + use(row, col); + moveToNextCell(); + } + return { + x: x, + y: y + }; + }; + nodes.layoutPositions(this, options, getPos); + } + return this; // chaining +}; + +// default layout options +var defaults$2 = { + ready: function ready() {}, + // on layoutready + stop: function stop() {} // on layoutstop +}; + +// constructor +// options : object containing layout options +function NullLayout(options) { + this.options = extend({}, defaults$2, options); +} + +// runs the layout +NullLayout.prototype.run = function () { + var options = this.options; + var eles = options.eles; // elements to consider in the layout + var layout = this; + + // cy is automatically populated for us in the constructor + // (disable eslint for next line as this serves as example layout code to external developers) + // eslint-disable-next-line no-unused-vars + options.cy; + layout.emit('layoutstart'); + + // puts all nodes at (0, 0) + // n.b. most layouts would use layoutPositions(), instead of positions() and manual events + eles.nodes().positions(function () { + return { + x: 0, + y: 0 + }; + }); + + // trigger layoutready when each node has had its position set at least once + layout.one('layoutready', options.ready); + layout.emit('layoutready'); + + // trigger layoutstop when the layout stops (e.g. finishes) + layout.one('layoutstop', options.stop); + layout.emit('layoutstop'); + return this; // chaining +}; + +// called on continuous layouts to stop them before they finish +NullLayout.prototype.stop = function () { + return this; // chaining +}; + +var defaults$1 = { + positions: undefined, + // map of (node id) => (position obj); or function(node){ return somPos; } + zoom: undefined, + // the zoom level to set (prob want fit = false if set) + pan: undefined, + // the pan level to set (prob want fit = false if set) + fit: true, + // whether to fit to viewport + padding: 30, + // padding on fit + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function PresetLayout(options) { + this.options = extend({}, defaults$1, options); +} +PresetLayout.prototype.run = function () { + var options = this.options; + var eles = options.eles; + var nodes = eles.nodes(); + var posIsFn = fn$6(options.positions); + function getPosition(node) { + if (options.positions == null) { + return copyPosition(node.position()); + } + if (posIsFn) { + return options.positions(node); + } + var pos = options.positions[node._private.data.id]; + if (pos == null) { + return null; + } + return pos; + } + nodes.layoutPositions(this, options, function (node, i) { + var position = getPosition(node); + if (node.locked() || position == null) { + return false; + } + return position; + }); + return this; // chaining +}; + +var defaults = { + fit: true, + // whether to fit to viewport + padding: 30, + // fit padding + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function RandomLayout(options) { + this.options = extend({}, defaults, options); +} +RandomLayout.prototype.run = function () { + var options = this.options; + var cy = options.cy; + var eles = options.eles; + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var getPos = function getPos(node, i) { + return { + x: bb.x1 + Math.round(Math.random() * bb.w), + y: bb.y1 + Math.round(Math.random() * bb.h) + }; + }; + eles.nodes().layoutPositions(this, options, getPos); + return this; // chaining +}; + +var layout = [{ + name: 'breadthfirst', + impl: BreadthFirstLayout +}, { + name: 'circle', + impl: CircleLayout +}, { + name: 'concentric', + impl: ConcentricLayout +}, { + name: 'cose', + impl: CoseLayout +}, { + name: 'grid', + impl: GridLayout +}, { + name: 'null', + impl: NullLayout +}, { + name: 'preset', + impl: PresetLayout +}, { + name: 'random', + impl: RandomLayout +}]; + +function NullRenderer(options) { + this.options = options; + this.notifications = 0; // for testing +} + +var noop = function noop() {}; +var throwImgErr = function throwImgErr() { + throw new Error('A headless instance can not render images'); +}; +NullRenderer.prototype = { + recalculateRenderedStyle: noop, + notify: function notify() { + this.notifications++; + }, + init: noop, + isHeadless: function isHeadless() { + return true; + }, + png: throwImgErr, + jpg: throwImgErr +}; + +var BRp$f = {}; +BRp$f.arrowShapeWidth = 0.3; +BRp$f.registerArrowShapes = function () { + var arrowShapes = this.arrowShapes = {}; + var renderer = this; + + // Contract for arrow shapes: + // 0, 0 is arrow tip + // (0, 1) is direction towards node + // (1, 0) is right + // + // functional api: + // collide: check x, y in shape + // roughCollide: called before collide, no false negatives + // draw: draw + // spacing: dist(arrowTip, nodeBoundary) + // gap: dist(edgeTip, nodeBoundary), edgeTip may != arrowTip + + var bbCollide = function bbCollide(x, y, size, angle, translation, edgeWidth, padding) { + var x1 = translation.x - size / 2 - padding; + var x2 = translation.x + size / 2 + padding; + var y1 = translation.y - size / 2 - padding; + var y2 = translation.y + size / 2 + padding; + var inside = x1 <= x && x <= x2 && y1 <= y && y <= y2; + return inside; + }; + var transform = function transform(x, y, size, angle, translation) { + var xRotated = x * Math.cos(angle) - y * Math.sin(angle); + var yRotated = x * Math.sin(angle) + y * Math.cos(angle); + var xScaled = xRotated * size; + var yScaled = yRotated * size; + var xTranslated = xScaled + translation.x; + var yTranslated = yScaled + translation.y; + return { + x: xTranslated, + y: yTranslated + }; + }; + var transformPoints = function transformPoints(pts, size, angle, translation) { + var retPts = []; + for (var i = 0; i < pts.length; i += 2) { + var x = pts[i]; + var y = pts[i + 1]; + retPts.push(transform(x, y, size, angle, translation)); + } + return retPts; + }; + var pointsToArr = function pointsToArr(pts) { + var ret = []; + for (var i = 0; i < pts.length; i++) { + var p = pts[i]; + ret.push(p.x, p.y); + } + return ret; + }; + var standardGap = function standardGap(edge) { + return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').pfValue * 2; + }; + var defineArrowShape = function defineArrowShape(name, defn) { + if (string(defn)) { + defn = arrowShapes[defn]; + } + arrowShapes[name] = extend({ + name: name, + points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3], + collide: function collide(x, y, size, angle, translation, padding) { + var points = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, points); + return inside; + }, + roughCollide: bbCollide, + draw: function draw(context, size, angle, translation) { + var points = transformPoints(this.points, size, angle, translation); + renderer.arrowShapeImpl('polygon')(context, points); + }, + spacing: function spacing(edge) { + return 0; + }, + gap: standardGap + }, defn); + }; + defineArrowShape('none', { + collide: falsify, + roughCollide: falsify, + draw: noop$1, + spacing: zeroify, + gap: zeroify + }); + defineArrowShape('triangle', { + points: [-0.15, -0.3, 0, 0, 0.15, -0.3] + }); + defineArrowShape('arrow', 'triangle'); + defineArrowShape('triangle-backcurve', { + points: arrowShapes['triangle'].points, + controlPoint: [0, -0.15], + roughCollide: bbCollide, + draw: function draw(context, size, angle, translation, edgeWidth) { + var ptsTrans = transformPoints(this.points, size, angle, translation); + var ctrlPt = this.controlPoint; + var ctrlPtTrans = transform(ctrlPt[0], ctrlPt[1], size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, ptsTrans, ctrlPtTrans); + }, + gap: function gap(edge) { + return standardGap(edge) * 0.8; + } + }); + defineArrowShape('triangle-tee', { + points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0], + pointsTee: [-0.15, -0.4, -0.15, -0.5, 0.15, -0.5, 0.15, -0.4], + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var teePts = pointsToArr(transformPoints(this.pointsTee, size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, triPts) || pointInsidePolygonPoints(x, y, teePts); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.points, size, angle, translation); + var teePts = transformPoints(this.pointsTee, size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, teePts); + } + }); + defineArrowShape('circle-triangle', { + radius: 0.15, + pointsTr: [0, -0.15, 0.15, -0.45, -0.15, -0.45, 0, -0.15], + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var t = translation; + var circleInside = Math.pow(t.x - x, 2) + Math.pow(t.y - y, 2) <= Math.pow((size + 2 * padding) * this.radius, 2); + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + return pointInsidePolygonPoints(x, y, triPts) || circleInside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.pointsTr, size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, translation.x, translation.y, this.radius * size); + }, + spacing: function spacing(edge) { + return renderer.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.radius; + } + }); + defineArrowShape('triangle-cross', { + points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0], + baseCrossLinePts: [-0.15, -0.4, + // first half of the rectangle + -0.15, -0.4, 0.15, -0.4, + // second half of the rectangle + 0.15, -0.4], + crossLinePts: function crossLinePts(size, edgeWidth) { + // shift points so that the distance between the cross points matches edge width + var p = this.baseCrossLinePts.slice(); + var shiftFactor = edgeWidth / size; + var y0 = 3; + var y1 = 5; + p[y0] = p[y0] - shiftFactor; + p[y1] = p[y1] - shiftFactor; + return p; + }, + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var teePts = pointsToArr(transformPoints(this.crossLinePts(size, edgeWidth), size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, triPts) || pointInsidePolygonPoints(x, y, teePts); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.points, size, angle, translation); + var crossLinePts = transformPoints(this.crossLinePts(size, edgeWidth), size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, crossLinePts); + } + }); + defineArrowShape('vee', { + points: [-0.15, -0.3, 0, 0, 0.15, -0.3, 0, -0.15], + gap: function gap(edge) { + return standardGap(edge) * 0.525; + } + }); + defineArrowShape('circle', { + radius: 0.15, + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var t = translation; + var inside = Math.pow(t.x - x, 2) + Math.pow(t.y - y, 2) <= Math.pow((size + 2 * padding) * this.radius, 2); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + renderer.arrowShapeImpl(this.name)(context, translation.x, translation.y, this.radius * size); + }, + spacing: function spacing(edge) { + return renderer.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.radius; + } + }); + defineArrowShape('tee', { + points: [-0.15, 0, -0.15, -0.1, 0.15, -0.1, 0.15, 0], + spacing: function spacing(edge) { + return 1; + }, + gap: function gap(edge) { + return 1; + } + }); + defineArrowShape('square', { + points: [-0.15, 0.00, 0.15, 0.00, 0.15, -0.3, -0.15, -0.3] + }); + defineArrowShape('diamond', { + points: [-0.15, -0.15, 0, -0.3, 0.15, -0.15, 0, 0], + gap: function gap(edge) { + return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').value; + } + }); + defineArrowShape('chevron', { + points: [0, 0, -0.15, -0.15, -0.1, -0.2, 0, -0.1, 0.1, -0.2, 0.15, -0.15], + gap: function gap(edge) { + return 0.95 * edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').value; + } + }); +}; + +var BRp$e = {}; + +// Project mouse +BRp$e.projectIntoViewport = function (clientX, clientY) { + var cy = this.cy; + var offsets = this.findContainerClientCoords(); + var offsetLeft = offsets[0]; + var offsetTop = offsets[1]; + var scale = offsets[4]; + var pan = cy.pan(); + var zoom = cy.zoom(); + var x = ((clientX - offsetLeft) / scale - pan.x) / zoom; + var y = ((clientY - offsetTop) / scale - pan.y) / zoom; + return [x, y]; +}; +BRp$e.findContainerClientCoords = function () { + if (this.containerBB) { + return this.containerBB; + } + var container = this.container; + var rect = container.getBoundingClientRect(); + var style = this.cy.window().getComputedStyle(container); + var styleValue = function styleValue(name) { + return parseFloat(style.getPropertyValue(name)); + }; + var padding = { + left: styleValue('padding-left'), + right: styleValue('padding-right'), + top: styleValue('padding-top'), + bottom: styleValue('padding-bottom') + }; + var border = { + left: styleValue('border-left-width'), + right: styleValue('border-right-width'), + top: styleValue('border-top-width'), + bottom: styleValue('border-bottom-width') + }; + var clientWidth = container.clientWidth; + var clientHeight = container.clientHeight; + var paddingHor = padding.left + padding.right; + var paddingVer = padding.top + padding.bottom; + var borderHor = border.left + border.right; + var scale = rect.width / (clientWidth + borderHor); + var unscaledW = clientWidth - paddingHor; + var unscaledH = clientHeight - paddingVer; + var left = rect.left + padding.left + border.left; + var top = rect.top + padding.top + border.top; + return this.containerBB = [left, top, unscaledW, unscaledH, scale]; +}; +BRp$e.invalidateContainerClientCoordsCache = function () { + this.containerBB = null; +}; +BRp$e.findNearestElement = function (x, y, interactiveElementsOnly, isTouch) { + return this.findNearestElements(x, y, interactiveElementsOnly, isTouch)[0]; +}; +BRp$e.findNearestElements = function (x, y, interactiveElementsOnly, isTouch) { + var self = this; + var r = this; + var eles = r.getCachedZSortedEles(); + var near = []; // 1 node max, 1 edge max + var zoom = r.cy.zoom(); + var hasCompounds = r.cy.hasCompoundNodes(); + var edgeThreshold = (isTouch ? 24 : 8) / zoom; + var nodeThreshold = (isTouch ? 8 : 2) / zoom; + var labelThreshold = (isTouch ? 8 : 2) / zoom; + var minSqDist = Infinity; + var nearEdge; + var nearNode; + if (interactiveElementsOnly) { + eles = eles.interactive; + } + function addEle(ele, sqDist) { + if (ele.isNode()) { + if (nearNode) { + return; // can't replace node + } else { + nearNode = ele; + near.push(ele); + } + } + if (ele.isEdge() && (sqDist == null || sqDist < minSqDist)) { + if (nearEdge) { + // then replace existing edge + // can replace only if same z-index + if (nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value && nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value) { + for (var i = 0; i < near.length; i++) { + if (near[i].isEdge()) { + near[i] = ele; + nearEdge = ele; + minSqDist = sqDist != null ? sqDist : minSqDist; + break; + } + } + } + } else { + near.push(ele); + nearEdge = ele; + minSqDist = sqDist != null ? sqDist : minSqDist; + } + } + } + function checkNode(node) { + var width = node.outerWidth() + 2 * nodeThreshold; + var height = node.outerHeight() + 2 * nodeThreshold; + var hw = width / 2; + var hh = height / 2; + var pos = node.position(); + var cornerRadius = node.pstyle('corner-radius').value === 'auto' ? 'auto' : node.pstyle('corner-radius').pfValue; + var rs = node._private.rscratch; + if (pos.x - hw <= x && x <= pos.x + hw // bb check x + && pos.y - hh <= y && y <= pos.y + hh // bb check y + ) { + var shape = r.nodeShapes[self.getNodeShape(node)]; + if (shape.checkPoint(x, y, 0, width, height, pos.x, pos.y, cornerRadius, rs)) { + addEle(node, 0); + return true; + } + } + } + function checkEdge(edge) { + var _p = edge._private; + var rs = _p.rscratch; + var styleWidth = edge.pstyle('width').pfValue; + var scale = edge.pstyle('arrow-scale').value; + var width = styleWidth / 2 + edgeThreshold; // more like a distance radius from centre + var widthSq = width * width; + var width2 = width * 2; + var src = _p.source; + var tgt = _p.target; + var sqDist; + if (rs.edgeType === 'segments' || rs.edgeType === 'straight' || rs.edgeType === 'haystack') { + var pts = rs.allpts; + for (var i = 0; i + 3 < pts.length; i += 2) { + if (inLineVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], width2) && widthSq > (sqDist = sqdistToFiniteLine(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3]))) { + addEle(edge, sqDist); + return true; + } + } + } else if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') { + var pts = rs.allpts; + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + if (inBezierVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5], width2) && widthSq > (sqDist = sqdistToQuadraticBezier(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5]))) { + addEle(edge, sqDist); + return true; + } + } + } + + // if we're close to the edge but didn't hit it, maybe we hit its arrows + + var src = src || _p.source; + var tgt = tgt || _p.target; + var arSize = self.getArrowWidth(styleWidth, scale); + var arrows = [{ + name: 'source', + x: rs.arrowStartX, + y: rs.arrowStartY, + angle: rs.srcArrowAngle + }, { + name: 'target', + x: rs.arrowEndX, + y: rs.arrowEndY, + angle: rs.tgtArrowAngle + }, { + name: 'mid-source', + x: rs.midX, + y: rs.midY, + angle: rs.midsrcArrowAngle + }, { + name: 'mid-target', + x: rs.midX, + y: rs.midY, + angle: rs.midtgtArrowAngle + }]; + for (var i = 0; i < arrows.length; i++) { + var ar = arrows[i]; + var shape = r.arrowShapes[edge.pstyle(ar.name + '-arrow-shape').value]; + var edgeWidth = edge.pstyle('width').pfValue; + if (shape.roughCollide(x, y, arSize, ar.angle, { + x: ar.x, + y: ar.y + }, edgeWidth, edgeThreshold) && shape.collide(x, y, arSize, ar.angle, { + x: ar.x, + y: ar.y + }, edgeWidth, edgeThreshold)) { + addEle(edge); + return true; + } + } + + // for compound graphs, hitting edge may actually want a connected node instead (b/c edge may have greater z-index precedence) + if (hasCompounds && near.length > 0) { + checkNode(src); + checkNode(tgt); + } + } + function preprop(obj, name, pre) { + return getPrefixedProperty(obj, name, pre); + } + function checkLabel(ele, prefix) { + var _p = ele._private; + var th = labelThreshold; + var prefixDash; + if (prefix) { + prefixDash = prefix + '-'; + } else { + prefixDash = ''; + } + ele.boundingBox(); + var bb = _p.labelBounds[prefix || 'main']; + var text = ele.pstyle(prefixDash + 'label').value; + var eventsEnabled = ele.pstyle('text-events').strValue === 'yes'; + if (!eventsEnabled || !text) { + return; + } + var lx = preprop(_p.rscratch, 'labelX', prefix); + var ly = preprop(_p.rscratch, 'labelY', prefix); + var theta = preprop(_p.rscratch, 'labelAngle', prefix); + var ox = ele.pstyle(prefixDash + 'text-margin-x').pfValue; + var oy = ele.pstyle(prefixDash + 'text-margin-y').pfValue; + var lx1 = bb.x1 - th - ox; // (-ox, -oy) as bb already includes margin + var lx2 = bb.x2 + th - ox; // and rotation is about (lx, ly) + var ly1 = bb.y1 - th - oy; + var ly2 = bb.y2 + th - oy; + if (theta) { + var cos = Math.cos(theta); + var sin = Math.sin(theta); + var rotate = function rotate(x, y) { + x = x - lx; + y = y - ly; + return { + x: x * cos - y * sin + lx, + y: x * sin + y * cos + ly + }; + }; + var px1y1 = rotate(lx1, ly1); + var px1y2 = rotate(lx1, ly2); + var px2y1 = rotate(lx2, ly1); + var px2y2 = rotate(lx2, ly2); + var points = [ + // with the margin added after the rotation is applied + px1y1.x + ox, px1y1.y + oy, px2y1.x + ox, px2y1.y + oy, px2y2.x + ox, px2y2.y + oy, px1y2.x + ox, px1y2.y + oy]; + if (pointInsidePolygonPoints(x, y, points)) { + addEle(ele); + return true; + } + } else { + // do a cheaper bb check + if (inBoundingBox(bb, x, y)) { + addEle(ele); + return true; + } + } + } + for (var i = eles.length - 1; i >= 0; i--) { + // reverse order for precedence + var ele = eles[i]; + if (ele.isNode()) { + checkNode(ele) || checkLabel(ele); + } else { + // then edge + checkEdge(ele) || checkLabel(ele) || checkLabel(ele, 'source') || checkLabel(ele, 'target'); + } + } + return near; +}; + +// 'Give me everything from this box' +BRp$e.getAllInBox = function (x1, y1, x2, y2) { + var eles = this.getCachedZSortedEles().interactive; + var box = []; + var x1c = Math.min(x1, x2); + var x2c = Math.max(x1, x2); + var y1c = Math.min(y1, y2); + var y2c = Math.max(y1, y2); + x1 = x1c; + x2 = x2c; + y1 = y1c; + y2 = y2c; + var boxBb = makeBoundingBox({ + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }); + for (var e = 0; e < eles.length; e++) { + var ele = eles[e]; + if (ele.isNode()) { + var node = ele; + var nodeBb = node.boundingBox({ + includeNodes: true, + includeEdges: false, + includeLabels: false + }); + if (boundingBoxesIntersect(boxBb, nodeBb) && !boundingBoxInBoundingBox(nodeBb, boxBb)) { + box.push(node); + } + } else { + var edge = ele; + var _p = edge._private; + var rs = _p.rscratch; + if (rs.startX != null && rs.startY != null && !inBoundingBox(boxBb, rs.startX, rs.startY)) { + continue; + } + if (rs.endX != null && rs.endY != null && !inBoundingBox(boxBb, rs.endX, rs.endY)) { + continue; + } + if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound' || rs.edgeType === 'segments' || rs.edgeType === 'haystack') { + var pts = _p.rstyle.bezierPts || _p.rstyle.linePts || _p.rstyle.haystackPts; + var allInside = true; + for (var i = 0; i < pts.length; i++) { + if (!pointInBoundingBox(boxBb, pts[i])) { + allInside = false; + break; + } + } + if (allInside) { + box.push(edge); + } + } else if (rs.edgeType === 'haystack' || rs.edgeType === 'straight') { + box.push(edge); + } + } + } + return box; +}; + +var BRp$d = {}; +BRp$d.calculateArrowAngles = function (edge) { + var rs = edge._private.rscratch; + var isHaystack = rs.edgeType === 'haystack'; + var isBezier = rs.edgeType === 'bezier'; + var isMultibezier = rs.edgeType === 'multibezier'; + var isSegments = rs.edgeType === 'segments'; + var isCompound = rs.edgeType === 'compound'; + var isSelf = rs.edgeType === 'self'; + + // Displacement gives direction for arrowhead orientation + var dispX, dispY; + var startX, startY, endX, endY, midX, midY; + if (isHaystack) { + startX = rs.haystackPts[0]; + startY = rs.haystackPts[1]; + endX = rs.haystackPts[2]; + endY = rs.haystackPts[3]; + } else { + startX = rs.arrowStartX; + startY = rs.arrowStartY; + endX = rs.arrowEndX; + endY = rs.arrowEndY; + } + midX = rs.midX; + midY = rs.midY; + + // source + // + + if (isSegments) { + dispX = startX - rs.segpts[0]; + dispY = startY - rs.segpts[1]; + } else if (isMultibezier || isCompound || isSelf || isBezier) { + var pts = rs.allpts; + var bX = qbezierAt(pts[0], pts[2], pts[4], 0.1); + var bY = qbezierAt(pts[1], pts[3], pts[5], 0.1); + dispX = startX - bX; + dispY = startY - bY; + } else { + dispX = startX - midX; + dispY = startY - midY; + } + rs.srcArrowAngle = getAngleFromDisp(dispX, dispY); + + // mid target + // + + var midX = rs.midX; + var midY = rs.midY; + if (isHaystack) { + midX = (startX + endX) / 2; + midY = (startY + endY) / 2; + } + dispX = endX - startX; + dispY = endY - startY; + if (isSegments) { + var pts = rs.allpts; + if (pts.length / 2 % 2 === 0) { + var i2 = pts.length / 2; + var i1 = i2 - 2; + dispX = pts[i2] - pts[i1]; + dispY = pts[i2 + 1] - pts[i1 + 1]; + } else if (rs.isRound) { + dispX = rs.midVector[1]; + dispY = -rs.midVector[0]; + } else { + var i2 = pts.length / 2 - 1; + var i1 = i2 - 2; + dispX = pts[i2] - pts[i1]; + dispY = pts[i2 + 1] - pts[i1 + 1]; + } + } else if (isMultibezier || isCompound || isSelf) { + var pts = rs.allpts; + var cpts = rs.ctrlpts; + var bp0x, bp0y; + var bp1x, bp1y; + if (cpts.length / 2 % 2 === 0) { + var p0 = pts.length / 2 - 1; // startpt + var ic = p0 + 2; + var p1 = ic + 2; + bp0x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.0); + bp0y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.0); + bp1x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.0001); + bp1y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.0001); + } else { + var ic = pts.length / 2 - 1; // ctrpt + var p0 = ic - 2; // startpt + var p1 = ic + 2; // endpt + + bp0x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.4999); + bp0y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.4999); + bp1x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.5); + bp1y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.5); + } + dispX = bp1x - bp0x; + dispY = bp1y - bp0y; + } + rs.midtgtArrowAngle = getAngleFromDisp(dispX, dispY); + rs.midDispX = dispX; + rs.midDispY = dispY; + + // mid source + // + + dispX *= -1; + dispY *= -1; + if (isSegments) { + var pts = rs.allpts; + if (pts.length / 2 % 2 === 0) ; else if (!rs.isRound) { + var i2 = pts.length / 2 - 1; + var i3 = i2 + 2; + dispX = -(pts[i3] - pts[i2]); + dispY = -(pts[i3 + 1] - pts[i2 + 1]); + } + } + rs.midsrcArrowAngle = getAngleFromDisp(dispX, dispY); + + // target + // + + if (isSegments) { + dispX = endX - rs.segpts[rs.segpts.length - 2]; + dispY = endY - rs.segpts[rs.segpts.length - 1]; + } else if (isMultibezier || isCompound || isSelf || isBezier) { + var pts = rs.allpts; + var l = pts.length; + var bX = qbezierAt(pts[l - 6], pts[l - 4], pts[l - 2], 0.9); + var bY = qbezierAt(pts[l - 5], pts[l - 3], pts[l - 1], 0.9); + dispX = endX - bX; + dispY = endY - bY; + } else { + dispX = endX - midX; + dispY = endY - midY; + } + rs.tgtArrowAngle = getAngleFromDisp(dispX, dispY); +}; +BRp$d.getArrowWidth = BRp$d.getArrowHeight = function (edgeWidth, scale) { + var cache = this.arrowWidthCache = this.arrowWidthCache || {}; + var cachedVal = cache[edgeWidth + ', ' + scale]; + if (cachedVal) { + return cachedVal; + } + cachedVal = Math.max(Math.pow(edgeWidth * 13.37, 0.9), 29) * scale; + cache[edgeWidth + ', ' + scale] = cachedVal; + return cachedVal; +}; + +/** + * Explained by Blindman67 at https://stackoverflow.com/a/44856925/11028828 + */ + +// Declare reused variable to avoid reallocating variables every time the function is called +var x, + y, + v1 = {}, + v2 = {}, + sinA, + sinA90, + radDirection, + drawDirection, + angle, + halfAngle, + cRadius, + lenOut, + radius, + limit; +var startX, startY, stopX, stopY; +var lastPoint; + +// convert 2 points into vector form, polar form, and normalised +var asVec = function asVec(p, pp, v) { + v.x = pp.x - p.x; + v.y = pp.y - p.y; + v.len = Math.sqrt(v.x * v.x + v.y * v.y); + v.nx = v.x / v.len; + v.ny = v.y / v.len; + v.ang = Math.atan2(v.ny, v.nx); +}; +var invertVec = function invertVec(originalV, invertedV) { + invertedV.x = originalV.x * -1; + invertedV.y = originalV.y * -1; + invertedV.nx = originalV.nx * -1; + invertedV.ny = originalV.ny * -1; + invertedV.ang = originalV.ang > 0 ? -(Math.PI - originalV.ang) : Math.PI + originalV.ang; +}; +var calcCornerArc = function calcCornerArc(previousPoint, currentPoint, nextPoint, radiusMax, isArcRadius) { + //----------------------------------------- + // Part 1 + previousPoint !== lastPoint ? asVec(currentPoint, previousPoint, v1) : invertVec(v2, v1); // Avoid recalculating vec if it is the invert of the last one calculated + asVec(currentPoint, nextPoint, v2); + sinA = v1.nx * v2.ny - v1.ny * v2.nx; + sinA90 = v1.nx * v2.nx - v1.ny * -v2.ny; + angle = Math.asin(Math.max(-1, Math.min(1, sinA))); + if (Math.abs(angle) < 1e-6) { + x = currentPoint.x; + y = currentPoint.y; + cRadius = radius = 0; + return; + } + //----------------------------------------- + radDirection = 1; + drawDirection = false; + if (sinA90 < 0) { + if (angle < 0) { + angle = Math.PI + angle; + } else { + angle = Math.PI - angle; + radDirection = -1; + drawDirection = true; + } + } else { + if (angle > 0) { + radDirection = -1; + drawDirection = true; + } + } + if (currentPoint.radius !== undefined) { + radius = currentPoint.radius; + } else { + radius = radiusMax; + } + //----------------------------------------- + // Part 2 + halfAngle = angle / 2; + //----------------------------------------- + + limit = Math.min(v1.len / 2, v2.len / 2); + if (isArcRadius) { + //----------------------------------------- + // Part 3 + lenOut = Math.abs(Math.cos(halfAngle) * radius / Math.sin(halfAngle)); + + //----------------------------------------- + // Special part A + if (lenOut > limit) { + lenOut = limit; + cRadius = Math.abs(lenOut * Math.sin(halfAngle) / Math.cos(halfAngle)); + } else { + cRadius = radius; + } + } else { + lenOut = Math.min(limit, radius); + cRadius = Math.abs(lenOut * Math.sin(halfAngle) / Math.cos(halfAngle)); + } + //----------------------------------------- + + //----------------------------------------- + // Part 4 + stopX = currentPoint.x + v2.nx * lenOut; + stopY = currentPoint.y + v2.ny * lenOut; + //----------------------------------------- + // Part 5 + x = stopX - v2.ny * cRadius * radDirection; + y = stopY + v2.nx * cRadius * radDirection; + //----------------------------------------- + // Additional Part : calculate start point E + startX = currentPoint.x + v1.nx * lenOut; + startY = currentPoint.y + v1.ny * lenOut; + + // Save last point to avoid recalculating vector when not needed + lastPoint = currentPoint; +}; + +/** + * Draw corner provided by {@link getRoundCorner} + * + * @param ctx :CanvasRenderingContext2D + * @param roundCorner {{cx:number, cy:number, radius:number, endAngle: number, startAngle: number, counterClockwise: boolean}} + */ +function drawPreparedRoundCorner(ctx, roundCorner) { + if (roundCorner.radius === 0) ctx.lineTo(roundCorner.cx, roundCorner.cy);else ctx.arc(roundCorner.cx, roundCorner.cy, roundCorner.radius, roundCorner.startAngle, roundCorner.endAngle, roundCorner.counterClockwise); +} + +/** + * Get round corner from a point and its previous and next neighbours in a path + * + * @param previousPoint {{x: number, y:number, radius: number?}} + * @param currentPoint {{x: number, y:number, radius: number?}} + * @param nextPoint {{x: number, y:number, radius: number?}} + * @param radiusMax :number + * @param isArcRadius :boolean + * @return {{ + * cx:number, cy:number, radius:number, + * startX:number, startY:number, + * stopX:number, stopY: number, + * endAngle: number, startAngle: number, counterClockwise: boolean + * }} + */ +function getRoundCorner(previousPoint, currentPoint, nextPoint, radiusMax) { + var isArcRadius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + if (radiusMax === 0 || currentPoint.radius === 0) return { + cx: currentPoint.x, + cy: currentPoint.y, + radius: 0, + startX: currentPoint.x, + startY: currentPoint.y, + stopX: currentPoint.x, + stopY: currentPoint.y, + startAngle: undefined, + endAngle: undefined, + counterClockwise: undefined + }; + calcCornerArc(previousPoint, currentPoint, nextPoint, radiusMax, isArcRadius); + return { + cx: x, + cy: y, + radius: cRadius, + startX: startX, + startY: startY, + stopX: stopX, + stopY: stopY, + startAngle: v1.ang + Math.PI / 2 * radDirection, + endAngle: v2.ang - Math.PI / 2 * radDirection, + counterClockwise: drawDirection + }; +} + +var BRp$c = {}; +BRp$c.findMidptPtsEtc = function (edge, pairInfo) { + var posPts = pairInfo.posPts, + intersectionPts = pairInfo.intersectionPts, + vectorNormInverse = pairInfo.vectorNormInverse; + var midptPts; + + // n.b. assumes all edges in bezier bundle have same endpoints specified + var srcManEndpt = edge.pstyle('source-endpoint'); + var tgtManEndpt = edge.pstyle('target-endpoint'); + var haveManualEndPts = srcManEndpt.units != null && tgtManEndpt.units != null; + var recalcVectorNormInverse = function recalcVectorNormInverse(x1, y1, x2, y2) { + var dy = y2 - y1; + var dx = x2 - x1; + var l = Math.sqrt(dx * dx + dy * dy); + return { + x: -dy / l, + y: dx / l + }; + }; + var edgeDistances = edge.pstyle('edge-distances').value; + switch (edgeDistances) { + case 'node-position': + midptPts = posPts; + break; + case 'intersection': + midptPts = intersectionPts; + break; + case 'endpoints': + { + if (haveManualEndPts) { + var _this$manualEndptToPx = this.manualEndptToPx(edge.source()[0], srcManEndpt), + _this$manualEndptToPx2 = _slicedToArray(_this$manualEndptToPx, 2), + x1 = _this$manualEndptToPx2[0], + y1 = _this$manualEndptToPx2[1]; + var _this$manualEndptToPx3 = this.manualEndptToPx(edge.target()[0], tgtManEndpt), + _this$manualEndptToPx4 = _slicedToArray(_this$manualEndptToPx3, 2), + x2 = _this$manualEndptToPx4[0], + y2 = _this$manualEndptToPx4[1]; + var endPts = { + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }; + vectorNormInverse = recalcVectorNormInverse(x1, y1, x2, y2); + midptPts = endPts; + } else { + warn("Edge ".concat(edge.id(), " has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")); + midptPts = intersectionPts; // back to default + } + + break; + } + } + return { + midptPts: midptPts, + vectorNormInverse: vectorNormInverse + }; +}; +BRp$c.findHaystackPoints = function (edges) { + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var _p = edge._private; + var rs = _p.rscratch; + if (!rs.haystack) { + var angle = Math.random() * 2 * Math.PI; + rs.source = { + x: Math.cos(angle), + y: Math.sin(angle) + }; + angle = Math.random() * 2 * Math.PI; + rs.target = { + x: Math.cos(angle), + y: Math.sin(angle) + }; + } + var src = _p.source; + var tgt = _p.target; + var srcPos = src.position(); + var tgtPos = tgt.position(); + var srcW = src.width(); + var tgtW = tgt.width(); + var srcH = src.height(); + var tgtH = tgt.height(); + var radius = edge.pstyle('haystack-radius').value; + var halfRadius = radius / 2; // b/c have to half width/height + + rs.haystackPts = rs.allpts = [rs.source.x * srcW * halfRadius + srcPos.x, rs.source.y * srcH * halfRadius + srcPos.y, rs.target.x * tgtW * halfRadius + tgtPos.x, rs.target.y * tgtH * halfRadius + tgtPos.y]; + rs.midX = (rs.allpts[0] + rs.allpts[2]) / 2; + rs.midY = (rs.allpts[1] + rs.allpts[3]) / 2; + + // always override as haystack in case set to different type previously + rs.edgeType = 'haystack'; + rs.haystack = true; + this.storeEdgeProjections(edge); + this.calculateArrowAngles(edge); + this.recalculateEdgeLabelProjections(edge); + this.calculateLabelAngles(edge); + } +}; +BRp$c.findSegmentsPoints = function (edge, pairInfo) { + // Segments (multiple straight lines) + + var rs = edge._private.rscratch; + var segmentWs = edge.pstyle('segment-weights'); + var segmentDs = edge.pstyle('segment-distances'); + var segmentRs = edge.pstyle('segment-radii'); + var segmentTs = edge.pstyle('radius-type'); + var segmentsN = Math.min(segmentWs.pfValue.length, segmentDs.pfValue.length); + var lastRadius = segmentRs.pfValue[segmentRs.pfValue.length - 1]; + var lastRadiusType = segmentTs.pfValue[segmentTs.pfValue.length - 1]; + rs.edgeType = 'segments'; + rs.segpts = []; + rs.radii = []; + rs.isArcRadius = []; + for (var s = 0; s < segmentsN; s++) { + var w = segmentWs.pfValue[s]; + var d = segmentDs.pfValue[s]; + var w1 = 1 - w; + var w2 = w; + var _this$findMidptPtsEtc = this.findMidptPtsEtc(edge, pairInfo), + midptPts = _this$findMidptPtsEtc.midptPts, + vectorNormInverse = _this$findMidptPtsEtc.vectorNormInverse; + var adjustedMidpt = { + x: midptPts.x1 * w1 + midptPts.x2 * w2, + y: midptPts.y1 * w1 + midptPts.y2 * w2 + }; + rs.segpts.push(adjustedMidpt.x + vectorNormInverse.x * d, adjustedMidpt.y + vectorNormInverse.y * d); + rs.radii.push(segmentRs.pfValue[s] !== undefined ? segmentRs.pfValue[s] : lastRadius); + rs.isArcRadius.push((segmentTs.pfValue[s] !== undefined ? segmentTs.pfValue[s] : lastRadiusType) === 'arc-radius'); + } +}; +BRp$c.findLoopPoints = function (edge, pairInfo, i, edgeIsUnbundled) { + // Self-edge + + var rs = edge._private.rscratch; + var dirCounts = pairInfo.dirCounts, + srcPos = pairInfo.srcPos; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var loopDir = edge.pstyle('loop-direction').pfValue; + var loopSwp = edge.pstyle('loop-sweep').pfValue; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + rs.edgeType = 'self'; + var j = i; + var loopDist = stepSize; + if (edgeIsUnbundled) { + j = 0; + loopDist = ctrlptDist; + } + var loopAngle = loopDir - Math.PI / 2; + var outAngle = loopAngle - loopSwp / 2; + var inAngle = loopAngle + loopSwp / 2; + + // increase by step size for overlapping loops, keyed on direction and sweep values + var dc = String(loopDir + '_' + loopSwp); + j = dirCounts[dc] === undefined ? dirCounts[dc] = 0 : ++dirCounts[dc]; + rs.ctrlpts = [srcPos.x + Math.cos(outAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.y + Math.sin(outAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.x + Math.cos(inAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.y + Math.sin(inAngle) * 1.4 * loopDist * (j / 3 + 1)]; +}; +BRp$c.findCompoundLoopPoints = function (edge, pairInfo, i, edgeIsUnbundled) { + // Compound edge + + var rs = edge._private.rscratch; + rs.edgeType = 'compound'; + var srcPos = pairInfo.srcPos, + tgtPos = pairInfo.tgtPos, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var j = i; + var loopDist = stepSize; + if (edgeIsUnbundled) { + j = 0; + loopDist = ctrlptDist; + } + var loopW = 50; + var loopaPos = { + x: srcPos.x - srcW / 2, + y: srcPos.y - srcH / 2 + }; + var loopbPos = { + x: tgtPos.x - tgtW / 2, + y: tgtPos.y - tgtH / 2 + }; + var loopPos = { + x: Math.min(loopaPos.x, loopbPos.x), + y: Math.min(loopaPos.y, loopbPos.y) + }; + + // avoids cases with impossible beziers + var minCompoundStretch = 0.5; + var compoundStretchA = Math.max(minCompoundStretch, Math.log(srcW * 0.01)); + var compoundStretchB = Math.max(minCompoundStretch, Math.log(tgtW * 0.01)); + rs.ctrlpts = [loopPos.x, loopPos.y - (1 + Math.pow(loopW, 1.12) / 100) * loopDist * (j / 3 + 1) * compoundStretchA, loopPos.x - (1 + Math.pow(loopW, 1.12) / 100) * loopDist * (j / 3 + 1) * compoundStretchB, loopPos.y]; +}; +BRp$c.findStraightEdgePoints = function (edge) { + // Straight edge within bundle + + edge._private.rscratch.edgeType = 'straight'; +}; +BRp$c.findBezierPoints = function (edge, pairInfo, i, edgeIsUnbundled, edgeIsSwapped) { + var rs = edge._private.rscratch; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptWs = edge.pstyle('control-point-weights'); + var bezierN = ctrlptDists && ctrlptWs ? Math.min(ctrlptDists.value.length, ctrlptWs.value.length) : 1; + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var ctrlptWeight = ctrlptWs.value[0]; + + // (Multi)bezier + + var multi = edgeIsUnbundled; + rs.edgeType = multi ? 'multibezier' : 'bezier'; + rs.ctrlpts = []; + for (var b = 0; b < bezierN; b++) { + var normctrlptDist = (0.5 - pairInfo.eles.length / 2 + i) * stepSize * (edgeIsSwapped ? -1 : 1); + var manctrlptDist = void 0; + var sign = signum(normctrlptDist); + if (multi) { + ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[b] : stepSize; // fall back on step size + ctrlptWeight = ctrlptWs.value[b]; + } + if (edgeIsUnbundled) { + // multi or single unbundled + manctrlptDist = ctrlptDist; + } else { + manctrlptDist = ctrlptDist !== undefined ? sign * ctrlptDist : undefined; + } + var distanceFromMidpoint = manctrlptDist !== undefined ? manctrlptDist : normctrlptDist; + var w1 = 1 - ctrlptWeight; + var w2 = ctrlptWeight; + var _this$findMidptPtsEtc2 = this.findMidptPtsEtc(edge, pairInfo), + midptPts = _this$findMidptPtsEtc2.midptPts, + vectorNormInverse = _this$findMidptPtsEtc2.vectorNormInverse; + var adjustedMidpt = { + x: midptPts.x1 * w1 + midptPts.x2 * w2, + y: midptPts.y1 * w1 + midptPts.y2 * w2 + }; + rs.ctrlpts.push(adjustedMidpt.x + vectorNormInverse.x * distanceFromMidpoint, adjustedMidpt.y + vectorNormInverse.y * distanceFromMidpoint); + } +}; +BRp$c.findTaxiPoints = function (edge, pairInfo) { + // Taxicab geometry with two turns maximum + + var rs = edge._private.rscratch; + rs.edgeType = 'segments'; + var VERTICAL = 'vertical'; + var HORIZONTAL = 'horizontal'; + var LEFTWARD = 'leftward'; + var RIGHTWARD = 'rightward'; + var DOWNWARD = 'downward'; + var UPWARD = 'upward'; + var AUTO = 'auto'; + var posPts = pairInfo.posPts, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH; + var edgeDistances = edge.pstyle('edge-distances').value; + var dIncludesNodeBody = edgeDistances !== 'node-position'; + var taxiDir = edge.pstyle('taxi-direction').value; + var rawTaxiDir = taxiDir; // unprocessed value + var taxiTurn = edge.pstyle('taxi-turn'); + var turnIsPercent = taxiTurn.units === '%'; + var taxiTurnPfVal = taxiTurn.pfValue; + var turnIsNegative = taxiTurnPfVal < 0; // i.e. from target side + var minD = edge.pstyle('taxi-turn-min-distance').pfValue; + var dw = dIncludesNodeBody ? (srcW + tgtW) / 2 : 0; + var dh = dIncludesNodeBody ? (srcH + tgtH) / 2 : 0; + var pdx = posPts.x2 - posPts.x1; + var pdy = posPts.y2 - posPts.y1; + + // take away the effective w/h from the magnitude of the delta value + var subDWH = function subDWH(dxy, dwh) { + if (dxy > 0) { + return Math.max(dxy - dwh, 0); + } else { + return Math.min(dxy + dwh, 0); + } + }; + var dx = subDWH(pdx, dw); + var dy = subDWH(pdy, dh); + var isExplicitDir = false; + if (rawTaxiDir === AUTO) { + taxiDir = Math.abs(dx) > Math.abs(dy) ? HORIZONTAL : VERTICAL; + } else if (rawTaxiDir === UPWARD || rawTaxiDir === DOWNWARD) { + taxiDir = VERTICAL; + isExplicitDir = true; + } else if (rawTaxiDir === LEFTWARD || rawTaxiDir === RIGHTWARD) { + taxiDir = HORIZONTAL; + isExplicitDir = true; + } + var isVert = taxiDir === VERTICAL; + var l = isVert ? dy : dx; + var pl = isVert ? pdy : pdx; + var sgnL = signum(pl); + var forcedDir = false; + if (!(isExplicitDir && (turnIsPercent || turnIsNegative)) // forcing in this case would cause weird growing in the opposite direction + && (rawTaxiDir === DOWNWARD && pl < 0 || rawTaxiDir === UPWARD && pl > 0 || rawTaxiDir === LEFTWARD && pl > 0 || rawTaxiDir === RIGHTWARD && pl < 0)) { + sgnL *= -1; + l = sgnL * Math.abs(l); + forcedDir = true; + } + var d; + if (turnIsPercent) { + var p = taxiTurnPfVal < 0 ? 1 + taxiTurnPfVal : taxiTurnPfVal; + d = p * l; + } else { + var k = taxiTurnPfVal < 0 ? l : 0; + d = k + taxiTurnPfVal * sgnL; + } + var getIsTooClose = function getIsTooClose(d) { + return Math.abs(d) < minD || Math.abs(d) >= Math.abs(l); + }; + var isTooCloseSrc = getIsTooClose(d); + var isTooCloseTgt = getIsTooClose(Math.abs(l) - Math.abs(d)); + var isTooClose = isTooCloseSrc || isTooCloseTgt; + if (isTooClose && !forcedDir) { + // non-ideal routing + if (isVert) { + // vertical fallbacks + var lShapeInsideSrc = Math.abs(pl) <= srcH / 2; + var lShapeInsideTgt = Math.abs(pdx) <= tgtW / 2; + if (lShapeInsideSrc) { + // horizontal Z-shape (direction not respected) + var x = (posPts.x1 + posPts.x2) / 2; + var y1 = posPts.y1, + y2 = posPts.y2; + rs.segpts = [x, y1, x, y2]; + } else if (lShapeInsideTgt) { + // vertical Z-shape (distance not respected) + var y = (posPts.y1 + posPts.y2) / 2; + var x1 = posPts.x1, + x2 = posPts.x2; + rs.segpts = [x1, y, x2, y]; + } else { + // L-shape fallback (turn distance not respected, but works well with tree siblings) + rs.segpts = [posPts.x1, posPts.y2]; + } + } else { + // horizontal fallbacks + var _lShapeInsideSrc = Math.abs(pl) <= srcW / 2; + var _lShapeInsideTgt = Math.abs(pdy) <= tgtH / 2; + if (_lShapeInsideSrc) { + // vertical Z-shape (direction not respected) + var _y = (posPts.y1 + posPts.y2) / 2; + var _x = posPts.x1, + _x2 = posPts.x2; + rs.segpts = [_x, _y, _x2, _y]; + } else if (_lShapeInsideTgt) { + // horizontal Z-shape (turn distance not respected) + var _x3 = (posPts.x1 + posPts.x2) / 2; + var _y2 = posPts.y1, + _y3 = posPts.y2; + rs.segpts = [_x3, _y2, _x3, _y3]; + } else { + // L-shape (turn distance not respected, but works well for tree siblings) + rs.segpts = [posPts.x2, posPts.y1]; + } + } + } else { + // ideal routing + if (isVert) { + var _y4 = posPts.y1 + d + (dIncludesNodeBody ? srcH / 2 * sgnL : 0); + var _x4 = posPts.x1, + _x5 = posPts.x2; + rs.segpts = [_x4, _y4, _x5, _y4]; + } else { + // horizontal + var _x6 = posPts.x1 + d + (dIncludesNodeBody ? srcW / 2 * sgnL : 0); + var _y5 = posPts.y1, + _y6 = posPts.y2; + rs.segpts = [_x6, _y5, _x6, _y6]; + } + } + if (rs.isRound) { + var radius = edge.pstyle('taxi-radius').value; + var isArcRadius = edge.pstyle('radius-type').value[0] === 'arc-radius'; + rs.radii = new Array(rs.segpts.length / 2).fill(radius); + rs.isArcRadius = new Array(rs.segpts.length / 2).fill(isArcRadius); + } +}; +BRp$c.tryToCorrectInvalidPoints = function (edge, pairInfo) { + var rs = edge._private.rscratch; + + // can only correct beziers for now... + if (rs.edgeType === 'bezier') { + var srcPos = pairInfo.srcPos, + tgtPos = pairInfo.tgtPos, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH, + srcShape = pairInfo.srcShape, + tgtShape = pairInfo.tgtShape, + srcCornerRadius = pairInfo.srcCornerRadius, + tgtCornerRadius = pairInfo.tgtCornerRadius, + srcRs = pairInfo.srcRs, + tgtRs = pairInfo.tgtRs; + var badStart = !number$1(rs.startX) || !number$1(rs.startY); + var badAStart = !number$1(rs.arrowStartX) || !number$1(rs.arrowStartY); + var badEnd = !number$1(rs.endX) || !number$1(rs.endY); + var badAEnd = !number$1(rs.arrowEndX) || !number$1(rs.arrowEndY); + var minCpADistFactor = 3; + var arrowW = this.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.arrowShapeWidth; + var minCpADist = minCpADistFactor * arrowW; + var startACpDist = dist({ + x: rs.ctrlpts[0], + y: rs.ctrlpts[1] + }, { + x: rs.startX, + y: rs.startY + }); + var closeStartACp = startACpDist < minCpADist; + var endACpDist = dist({ + x: rs.ctrlpts[0], + y: rs.ctrlpts[1] + }, { + x: rs.endX, + y: rs.endY + }); + var closeEndACp = endACpDist < minCpADist; + var overlapping = false; + if (badStart || badAStart || closeStartACp) { + overlapping = true; + + // project control point along line from src centre to outside the src shape + // (otherwise intersection will yield nothing) + var cpD = { + // delta + x: rs.ctrlpts[0] - srcPos.x, + y: rs.ctrlpts[1] - srcPos.y + }; + var cpL = Math.sqrt(cpD.x * cpD.x + cpD.y * cpD.y); // length of line + var cpM = { + // normalised delta + x: cpD.x / cpL, + y: cpD.y / cpL + }; + var radius = Math.max(srcW, srcH); + var cpProj = { + // *2 radius guarantees outside shape + x: rs.ctrlpts[0] + cpM.x * 2 * radius, + y: rs.ctrlpts[1] + cpM.y * 2 * radius + }; + var srcCtrlPtIntn = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, cpProj.x, cpProj.y, 0, srcCornerRadius, srcRs); + if (closeStartACp) { + rs.ctrlpts[0] = rs.ctrlpts[0] + cpM.x * (minCpADist - startACpDist); + rs.ctrlpts[1] = rs.ctrlpts[1] + cpM.y * (minCpADist - startACpDist); + } else { + rs.ctrlpts[0] = srcCtrlPtIntn[0] + cpM.x * minCpADist; + rs.ctrlpts[1] = srcCtrlPtIntn[1] + cpM.y * minCpADist; + } + } + if (badEnd || badAEnd || closeEndACp) { + overlapping = true; + + // project control point along line from tgt centre to outside the tgt shape + // (otherwise intersection will yield nothing) + var _cpD = { + // delta + x: rs.ctrlpts[0] - tgtPos.x, + y: rs.ctrlpts[1] - tgtPos.y + }; + var _cpL = Math.sqrt(_cpD.x * _cpD.x + _cpD.y * _cpD.y); // length of line + var _cpM = { + // normalised delta + x: _cpD.x / _cpL, + y: _cpD.y / _cpL + }; + var _radius = Math.max(srcW, srcH); + var _cpProj = { + // *2 radius guarantees outside shape + x: rs.ctrlpts[0] + _cpM.x * 2 * _radius, + y: rs.ctrlpts[1] + _cpM.y * 2 * _radius + }; + var tgtCtrlPtIntn = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, _cpProj.x, _cpProj.y, 0, tgtCornerRadius, tgtRs); + if (closeEndACp) { + rs.ctrlpts[0] = rs.ctrlpts[0] + _cpM.x * (minCpADist - endACpDist); + rs.ctrlpts[1] = rs.ctrlpts[1] + _cpM.y * (minCpADist - endACpDist); + } else { + rs.ctrlpts[0] = tgtCtrlPtIntn[0] + _cpM.x * minCpADist; + rs.ctrlpts[1] = tgtCtrlPtIntn[1] + _cpM.y * minCpADist; + } + } + if (overlapping) { + // recalc endpts + this.findEndpoints(edge); + } + } +}; +BRp$c.storeAllpts = function (edge) { + var rs = edge._private.rscratch; + if (rs.edgeType === 'multibezier' || rs.edgeType === 'bezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') { + rs.allpts = []; + rs.allpts.push(rs.startX, rs.startY); + for (var b = 0; b + 1 < rs.ctrlpts.length; b += 2) { + // ctrl pt itself + rs.allpts.push(rs.ctrlpts[b], rs.ctrlpts[b + 1]); + + // the midpt between ctrlpts as intermediate destination pts + if (b + 3 < rs.ctrlpts.length) { + rs.allpts.push((rs.ctrlpts[b] + rs.ctrlpts[b + 2]) / 2, (rs.ctrlpts[b + 1] + rs.ctrlpts[b + 3]) / 2); + } + } + rs.allpts.push(rs.endX, rs.endY); + var m, mt; + if (rs.ctrlpts.length / 2 % 2 === 0) { + m = rs.allpts.length / 2 - 1; + rs.midX = rs.allpts[m]; + rs.midY = rs.allpts[m + 1]; + } else { + m = rs.allpts.length / 2 - 3; + mt = 0.5; + rs.midX = qbezierAt(rs.allpts[m], rs.allpts[m + 2], rs.allpts[m + 4], mt); + rs.midY = qbezierAt(rs.allpts[m + 1], rs.allpts[m + 3], rs.allpts[m + 5], mt); + } + } else if (rs.edgeType === 'straight') { + // need to calc these after endpts + rs.allpts = [rs.startX, rs.startY, rs.endX, rs.endY]; + + // default midpt for labels etc + rs.midX = (rs.startX + rs.endX + rs.arrowStartX + rs.arrowEndX) / 4; + rs.midY = (rs.startY + rs.endY + rs.arrowStartY + rs.arrowEndY) / 4; + } else if (rs.edgeType === 'segments') { + rs.allpts = []; + rs.allpts.push(rs.startX, rs.startY); + rs.allpts.push.apply(rs.allpts, rs.segpts); + rs.allpts.push(rs.endX, rs.endY); + if (rs.isRound) { + rs.roundCorners = []; + for (var i = 2; i + 3 < rs.allpts.length; i += 2) { + var radius = rs.radii[i / 2 - 1]; + var isArcRadius = rs.isArcRadius[i / 2 - 1]; + rs.roundCorners.push(getRoundCorner({ + x: rs.allpts[i - 2], + y: rs.allpts[i - 1] + }, { + x: rs.allpts[i], + y: rs.allpts[i + 1], + radius: radius + }, { + x: rs.allpts[i + 2], + y: rs.allpts[i + 3] + }, radius, isArcRadius)); + } + } + if (rs.segpts.length % 4 === 0) { + var i2 = rs.segpts.length / 2; + var i1 = i2 - 2; + rs.midX = (rs.segpts[i1] + rs.segpts[i2]) / 2; + rs.midY = (rs.segpts[i1 + 1] + rs.segpts[i2 + 1]) / 2; + } else { + var _i = rs.segpts.length / 2 - 1; + if (!rs.isRound) { + rs.midX = rs.segpts[_i]; + rs.midY = rs.segpts[_i + 1]; + } else { + var point = { + x: rs.segpts[_i], + y: rs.segpts[_i + 1] + }; + var corner = rs.roundCorners[_i / 2]; + var v = [point.x - corner.cx, point.y - corner.cy]; + var factor = corner.radius / Math.sqrt(Math.pow(v[0], 2) + Math.pow(v[1], 2)); + v = v.map(function (c) { + return c * factor; + }); + rs.midX = corner.cx + v[0]; + rs.midY = corner.cy + v[1]; + rs.midVector = v; + } + } + } +}; +BRp$c.checkForInvalidEdgeWarning = function (edge) { + var rs = edge[0]._private.rscratch; + if (rs.nodesOverlap || number$1(rs.startX) && number$1(rs.startY) && number$1(rs.endX) && number$1(rs.endY)) { + rs.loggedErr = false; + } else { + if (!rs.loggedErr) { + rs.loggedErr = true; + warn('Edge `' + edge.id() + '` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap.'); + } + } +}; +BRp$c.findEdgeControlPoints = function (edges) { + var _this = this; + if (!edges || edges.length === 0) { + return; + } + var r = this; + var cy = r.cy; + var hasCompounds = cy.hasCompoundNodes(); + var hashTable = { + map: new Map$2(), + get: function get(pairId) { + var map2 = this.map.get(pairId[0]); + if (map2 != null) { + return map2.get(pairId[1]); + } else { + return null; + } + }, + set: function set(pairId, val) { + var map2 = this.map.get(pairId[0]); + if (map2 == null) { + map2 = new Map$2(); + this.map.set(pairId[0], map2); + } + map2.set(pairId[1], val); + } + }; + var pairIds = []; + var haystackEdges = []; + + // create a table of edge (src, tgt) => list of edges between them + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var _p = edge._private; + var curveStyle = edge.pstyle('curve-style').value; + + // ignore edges who are not to be displayed + // they shouldn't take up space + if (edge.removed() || !edge.takesUpSpace()) { + continue; + } + if (curveStyle === 'haystack') { + haystackEdges.push(edge); + continue; + } + var edgeIsUnbundled = curveStyle === 'unbundled-bezier' || curveStyle.endsWith('segments') || curveStyle === 'straight' || curveStyle === 'straight-triangle' || curveStyle.endsWith('taxi'); + var edgeIsBezier = curveStyle === 'unbundled-bezier' || curveStyle === 'bezier'; + var src = _p.source; + var tgt = _p.target; + var srcIndex = src.poolIndex(); + var tgtIndex = tgt.poolIndex(); + var pairId = [srcIndex, tgtIndex].sort(); + var tableEntry = hashTable.get(pairId); + if (tableEntry == null) { + tableEntry = { + eles: [] + }; + hashTable.set(pairId, tableEntry); + pairIds.push(pairId); + } + tableEntry.eles.push(edge); + if (edgeIsUnbundled) { + tableEntry.hasUnbundled = true; + } + if (edgeIsBezier) { + tableEntry.hasBezier = true; + } + } + + // for each pair (src, tgt), create the ctrl pts + // Nested for loop is OK; total number of iterations for both loops = edgeCount + var _loop = function _loop(p) { + var pairId = pairIds[p]; + var pairInfo = hashTable.get(pairId); + var swappedpairInfo = void 0; + if (!pairInfo.hasUnbundled) { + var pllEdges = pairInfo.eles[0].parallelEdges().filter(function (e) { + return e.isBundledBezier(); + }); + clearArray(pairInfo.eles); + pllEdges.forEach(function (edge) { + return pairInfo.eles.push(edge); + }); + + // for each pair id, the edges should be sorted by index + pairInfo.eles.sort(function (edge1, edge2) { + return edge1.poolIndex() - edge2.poolIndex(); + }); + } + var firstEdge = pairInfo.eles[0]; + var src = firstEdge.source(); + var tgt = firstEdge.target(); + + // make sure src/tgt distinction is consistent w.r.t. pairId + if (src.poolIndex() > tgt.poolIndex()) { + var temp = src; + src = tgt; + tgt = temp; + } + var srcPos = pairInfo.srcPos = src.position(); + var tgtPos = pairInfo.tgtPos = tgt.position(); + var srcW = pairInfo.srcW = src.outerWidth(); + var srcH = pairInfo.srcH = src.outerHeight(); + var tgtW = pairInfo.tgtW = tgt.outerWidth(); + var tgtH = pairInfo.tgtH = tgt.outerHeight(); + var srcShape = pairInfo.srcShape = r.nodeShapes[_this.getNodeShape(src)]; + var tgtShape = pairInfo.tgtShape = r.nodeShapes[_this.getNodeShape(tgt)]; + var srcCornerRadius = pairInfo.srcCornerRadius = src.pstyle('corner-radius').value === 'auto' ? 'auto' : src.pstyle('corner-radius').pfValue; + var tgtCornerRadius = pairInfo.tgtCornerRadius = tgt.pstyle('corner-radius').value === 'auto' ? 'auto' : tgt.pstyle('corner-radius').pfValue; + var tgtRs = pairInfo.tgtRs = tgt._private.rscratch; + var srcRs = pairInfo.srcRs = src._private.rscratch; + pairInfo.dirCounts = { + 'north': 0, + 'west': 0, + 'south': 0, + 'east': 0, + 'northwest': 0, + 'southwest': 0, + 'northeast': 0, + 'southeast': 0 + }; + for (var _i2 = 0; _i2 < pairInfo.eles.length; _i2++) { + var _edge = pairInfo.eles[_i2]; + var rs = _edge[0]._private.rscratch; + var _curveStyle = _edge.pstyle('curve-style').value; + var _edgeIsUnbundled = _curveStyle === 'unbundled-bezier' || _curveStyle.endsWith('segments') || _curveStyle.endsWith('taxi'); + + // whether the normalised pair order is the reverse of the edge's src-tgt order + var edgeIsSwapped = !src.same(_edge.source()); + if (!pairInfo.calculatedIntersection && src !== tgt && (pairInfo.hasBezier || pairInfo.hasUnbundled)) { + pairInfo.calculatedIntersection = true; + + // pt outside src shape to calc distance/displacement from src to tgt + var srcOutside = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, tgtPos.x, tgtPos.y, 0, srcCornerRadius, srcRs); + var srcIntn = pairInfo.srcIntn = srcOutside; + + // pt outside tgt shape to calc distance/displacement from src to tgt + var tgtOutside = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, srcPos.x, srcPos.y, 0, tgtCornerRadius, tgtRs); + var tgtIntn = pairInfo.tgtIntn = tgtOutside; + var intersectionPts = pairInfo.intersectionPts = { + x1: srcOutside[0], + x2: tgtOutside[0], + y1: srcOutside[1], + y2: tgtOutside[1] + }; + var posPts = pairInfo.posPts = { + x1: srcPos.x, + x2: tgtPos.x, + y1: srcPos.y, + y2: tgtPos.y + }; + var dy = tgtOutside[1] - srcOutside[1]; + var dx = tgtOutside[0] - srcOutside[0]; + var l = Math.sqrt(dx * dx + dy * dy); + var vector = pairInfo.vector = { + x: dx, + y: dy + }; + var vectorNorm = pairInfo.vectorNorm = { + x: vector.x / l, + y: vector.y / l + }; + var vectorNormInverse = { + x: -vectorNorm.y, + y: vectorNorm.x + }; + + // if node shapes overlap, then no ctrl pts to draw + pairInfo.nodesOverlap = !number$1(l) || tgtShape.checkPoint(srcOutside[0], srcOutside[1], 0, tgtW, tgtH, tgtPos.x, tgtPos.y, tgtCornerRadius, tgtRs) || srcShape.checkPoint(tgtOutside[0], tgtOutside[1], 0, srcW, srcH, srcPos.x, srcPos.y, srcCornerRadius, srcRs); + pairInfo.vectorNormInverse = vectorNormInverse; + swappedpairInfo = { + nodesOverlap: pairInfo.nodesOverlap, + dirCounts: pairInfo.dirCounts, + calculatedIntersection: true, + hasBezier: pairInfo.hasBezier, + hasUnbundled: pairInfo.hasUnbundled, + eles: pairInfo.eles, + srcPos: tgtPos, + tgtPos: srcPos, + srcW: tgtW, + srcH: tgtH, + tgtW: srcW, + tgtH: srcH, + srcIntn: tgtIntn, + tgtIntn: srcIntn, + srcShape: tgtShape, + tgtShape: srcShape, + posPts: { + x1: posPts.x2, + y1: posPts.y2, + x2: posPts.x1, + y2: posPts.y1 + }, + intersectionPts: { + x1: intersectionPts.x2, + y1: intersectionPts.y2, + x2: intersectionPts.x1, + y2: intersectionPts.y1 + }, + vector: { + x: -vector.x, + y: -vector.y + }, + vectorNorm: { + x: -vectorNorm.x, + y: -vectorNorm.y + }, + vectorNormInverse: { + x: -vectorNormInverse.x, + y: -vectorNormInverse.y + } + }; + } + var passedPairInfo = edgeIsSwapped ? swappedpairInfo : pairInfo; + rs.nodesOverlap = passedPairInfo.nodesOverlap; + rs.srcIntn = passedPairInfo.srcIntn; + rs.tgtIntn = passedPairInfo.tgtIntn; + rs.isRound = _curveStyle.startsWith('round'); + if (hasCompounds && (src.isParent() || src.isChild() || tgt.isParent() || tgt.isChild()) && (src.parents().anySame(tgt) || tgt.parents().anySame(src) || src.same(tgt) && src.isParent())) { + _this.findCompoundLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled); + } else if (src === tgt) { + _this.findLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled); + } else if (_curveStyle.endsWith('segments')) { + _this.findSegmentsPoints(_edge, passedPairInfo); + } else if (_curveStyle.endsWith('taxi')) { + _this.findTaxiPoints(_edge, passedPairInfo); + } else if (_curveStyle === 'straight' || !_edgeIsUnbundled && pairInfo.eles.length % 2 === 1 && _i2 === Math.floor(pairInfo.eles.length / 2)) { + _this.findStraightEdgePoints(_edge); + } else { + _this.findBezierPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled, edgeIsSwapped); + } + _this.findEndpoints(_edge); + _this.tryToCorrectInvalidPoints(_edge, passedPairInfo); + _this.checkForInvalidEdgeWarning(_edge); + _this.storeAllpts(_edge); + _this.storeEdgeProjections(_edge); + _this.calculateArrowAngles(_edge); + _this.recalculateEdgeLabelProjections(_edge); + _this.calculateLabelAngles(_edge); + } // for pair edges + }; + for (var p = 0; p < pairIds.length; p++) { + _loop(p); + } // for pair ids + + // haystacks avoid the expense of pairInfo stuff (intersections etc.) + this.findHaystackPoints(haystackEdges); +}; +function getPts(pts) { + var retPts = []; + if (pts == null) { + return; + } + for (var i = 0; i < pts.length; i += 2) { + var x = pts[i]; + var y = pts[i + 1]; + retPts.push({ + x: x, + y: y + }); + } + return retPts; +} +BRp$c.getSegmentPoints = function (edge) { + var rs = edge[0]._private.rscratch; + var type = rs.edgeType; + if (type === 'segments') { + this.recalculateRenderedStyle(edge); + return getPts(rs.segpts); + } +}; +BRp$c.getControlPoints = function (edge) { + var rs = edge[0]._private.rscratch; + var type = rs.edgeType; + if (type === 'bezier' || type === 'multibezier' || type === 'self' || type === 'compound') { + this.recalculateRenderedStyle(edge); + return getPts(rs.ctrlpts); + } +}; +BRp$c.getEdgeMidpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + return { + x: rs.midX, + y: rs.midY + }; +}; + +var BRp$b = {}; +BRp$b.manualEndptToPx = function (node, prop) { + var r = this; + var npos = node.position(); + var w = node.outerWidth(); + var h = node.outerHeight(); + var rs = node._private.rscratch; + if (prop.value.length === 2) { + var p = [prop.pfValue[0], prop.pfValue[1]]; + if (prop.units[0] === '%') { + p[0] = p[0] * w; + } + if (prop.units[1] === '%') { + p[1] = p[1] * h; + } + p[0] += npos.x; + p[1] += npos.y; + return p; + } else { + var angle = prop.pfValue[0]; + angle = -Math.PI / 2 + angle; // start at 12 o'clock + + var l = 2 * Math.max(w, h); + var _p = [npos.x + Math.cos(angle) * l, npos.y + Math.sin(angle) * l]; + return r.nodeShapes[this.getNodeShape(node)].intersectLine(npos.x, npos.y, w, h, _p[0], _p[1], 0, node.pstyle('corner-radius').value === 'auto' ? 'auto' : node.pstyle('corner-radius').pfValue, rs); + } +}; +BRp$b.findEndpoints = function (edge) { + var r = this; + var intersect; + var source = edge.source()[0]; + var target = edge.target()[0]; + var srcPos = source.position(); + var tgtPos = target.position(); + var tgtArShape = edge.pstyle('target-arrow-shape').value; + var srcArShape = edge.pstyle('source-arrow-shape').value; + var tgtDist = edge.pstyle('target-distance-from-node').pfValue; + var srcDist = edge.pstyle('source-distance-from-node').pfValue; + var srcRs = source._private.rscratch; + var tgtRs = target._private.rscratch; + var curveStyle = edge.pstyle('curve-style').value; + var rs = edge._private.rscratch; + var et = rs.edgeType; + var taxi = curveStyle === 'taxi'; + var self = et === 'self' || et === 'compound'; + var bezier = et === 'bezier' || et === 'multibezier' || self; + var multi = et !== 'bezier'; + var lines = et === 'straight' || et === 'segments'; + var segments = et === 'segments'; + var hasEndpts = bezier || multi || lines; + var overrideEndpts = self || taxi; + var srcManEndpt = edge.pstyle('source-endpoint'); + var srcManEndptVal = overrideEndpts ? 'outside-to-node' : srcManEndpt.value; + var srcCornerRadius = source.pstyle('corner-radius').value === 'auto' ? 'auto' : source.pstyle('corner-radius').pfValue; + var tgtManEndpt = edge.pstyle('target-endpoint'); + var tgtManEndptVal = overrideEndpts ? 'outside-to-node' : tgtManEndpt.value; + var tgtCornerRadius = target.pstyle('corner-radius').value === 'auto' ? 'auto' : target.pstyle('corner-radius').pfValue; + rs.srcManEndpt = srcManEndpt; + rs.tgtManEndpt = tgtManEndpt; + var p1; // last known point of edge on target side + var p2; // last known point of edge on source side + + var p1_i; // point to intersect with target shape + var p2_i; // point to intersect with source shape + + if (bezier) { + var cpStart = [rs.ctrlpts[0], rs.ctrlpts[1]]; + var cpEnd = multi ? [rs.ctrlpts[rs.ctrlpts.length - 2], rs.ctrlpts[rs.ctrlpts.length - 1]] : cpStart; + p1 = cpEnd; + p2 = cpStart; + } else if (lines) { + var srcArrowFromPt = !segments ? [tgtPos.x, tgtPos.y] : rs.segpts.slice(0, 2); + var tgtArrowFromPt = !segments ? [srcPos.x, srcPos.y] : rs.segpts.slice(rs.segpts.length - 2); + p1 = tgtArrowFromPt; + p2 = srcArrowFromPt; + } + if (tgtManEndptVal === 'inside-to-node') { + intersect = [tgtPos.x, tgtPos.y]; + } else if (tgtManEndpt.units) { + intersect = this.manualEndptToPx(target, tgtManEndpt); + } else if (tgtManEndptVal === 'outside-to-line') { + intersect = rs.tgtIntn; // use cached value from ctrlpt calc + } else { + if (tgtManEndptVal === 'outside-to-node' || tgtManEndptVal === 'outside-to-node-or-label') { + p1_i = p1; + } else if (tgtManEndptVal === 'outside-to-line' || tgtManEndptVal === 'outside-to-line-or-label') { + p1_i = [srcPos.x, srcPos.y]; + } + intersect = r.nodeShapes[this.getNodeShape(target)].intersectLine(tgtPos.x, tgtPos.y, target.outerWidth(), target.outerHeight(), p1_i[0], p1_i[1], 0, tgtCornerRadius, tgtRs); + if (tgtManEndptVal === 'outside-to-node-or-label' || tgtManEndptVal === 'outside-to-line-or-label') { + var trs = target._private.rscratch; + var lw = trs.labelWidth; + var lh = trs.labelHeight; + var lx = trs.labelX; + var ly = trs.labelY; + var lw2 = lw / 2; + var lh2 = lh / 2; + var va = target.pstyle('text-valign').value; + if (va === 'top') { + ly -= lh2; + } else if (va === 'bottom') { + ly += lh2; + } + var ha = target.pstyle('text-halign').value; + if (ha === 'left') { + lx -= lw2; + } else if (ha === 'right') { + lx += lw2; + } + var labelIntersect = polygonIntersectLine(p1_i[0], p1_i[1], [lx - lw2, ly - lh2, lx + lw2, ly - lh2, lx + lw2, ly + lh2, lx - lw2, ly + lh2], tgtPos.x, tgtPos.y); + if (labelIntersect.length > 0) { + var refPt = srcPos; + var intSqdist = sqdist(refPt, array2point(intersect)); + var labIntSqdist = sqdist(refPt, array2point(labelIntersect)); + var minSqDist = intSqdist; + if (labIntSqdist < intSqdist) { + intersect = labelIntersect; + minSqDist = labIntSqdist; + } + if (labelIntersect.length > 2) { + var labInt2SqDist = sqdist(refPt, { + x: labelIntersect[2], + y: labelIntersect[3] + }); + if (labInt2SqDist < minSqDist) { + intersect = [labelIntersect[2], labelIntersect[3]]; + } + } + } + } + } + var arrowEnd = shortenIntersection(intersect, p1, r.arrowShapes[tgtArShape].spacing(edge) + tgtDist); + var edgeEnd = shortenIntersection(intersect, p1, r.arrowShapes[tgtArShape].gap(edge) + tgtDist); + rs.endX = edgeEnd[0]; + rs.endY = edgeEnd[1]; + rs.arrowEndX = arrowEnd[0]; + rs.arrowEndY = arrowEnd[1]; + if (srcManEndptVal === 'inside-to-node') { + intersect = [srcPos.x, srcPos.y]; + } else if (srcManEndpt.units) { + intersect = this.manualEndptToPx(source, srcManEndpt); + } else if (srcManEndptVal === 'outside-to-line') { + intersect = rs.srcIntn; // use cached value from ctrlpt calc + } else { + if (srcManEndptVal === 'outside-to-node' || srcManEndptVal === 'outside-to-node-or-label') { + p2_i = p2; + } else if (srcManEndptVal === 'outside-to-line' || srcManEndptVal === 'outside-to-line-or-label') { + p2_i = [tgtPos.x, tgtPos.y]; + } + intersect = r.nodeShapes[this.getNodeShape(source)].intersectLine(srcPos.x, srcPos.y, source.outerWidth(), source.outerHeight(), p2_i[0], p2_i[1], 0, srcCornerRadius, srcRs); + if (srcManEndptVal === 'outside-to-node-or-label' || srcManEndptVal === 'outside-to-line-or-label') { + var srs = source._private.rscratch; + var _lw = srs.labelWidth; + var _lh = srs.labelHeight; + var _lx = srs.labelX; + var _ly = srs.labelY; + var _lw2 = _lw / 2; + var _lh2 = _lh / 2; + var _va = source.pstyle('text-valign').value; + if (_va === 'top') { + _ly -= _lh2; + } else if (_va === 'bottom') { + _ly += _lh2; + } + var _ha = source.pstyle('text-halign').value; + if (_ha === 'left') { + _lx -= _lw2; + } else if (_ha === 'right') { + _lx += _lw2; + } + var _labelIntersect = polygonIntersectLine(p2_i[0], p2_i[1], [_lx - _lw2, _ly - _lh2, _lx + _lw2, _ly - _lh2, _lx + _lw2, _ly + _lh2, _lx - _lw2, _ly + _lh2], srcPos.x, srcPos.y); + if (_labelIntersect.length > 0) { + var _refPt = tgtPos; + var _intSqdist = sqdist(_refPt, array2point(intersect)); + var _labIntSqdist = sqdist(_refPt, array2point(_labelIntersect)); + var _minSqDist = _intSqdist; + if (_labIntSqdist < _intSqdist) { + intersect = [_labelIntersect[0], _labelIntersect[1]]; + _minSqDist = _labIntSqdist; + } + if (_labelIntersect.length > 2) { + var _labInt2SqDist = sqdist(_refPt, { + x: _labelIntersect[2], + y: _labelIntersect[3] + }); + if (_labInt2SqDist < _minSqDist) { + intersect = [_labelIntersect[2], _labelIntersect[3]]; + } + } + } + } + } + var arrowStart = shortenIntersection(intersect, p2, r.arrowShapes[srcArShape].spacing(edge) + srcDist); + var edgeStart = shortenIntersection(intersect, p2, r.arrowShapes[srcArShape].gap(edge) + srcDist); + rs.startX = edgeStart[0]; + rs.startY = edgeStart[1]; + rs.arrowStartX = arrowStart[0]; + rs.arrowStartY = arrowStart[1]; + if (hasEndpts) { + if (!number$1(rs.startX) || !number$1(rs.startY) || !number$1(rs.endX) || !number$1(rs.endY)) { + rs.badLine = true; + } else { + rs.badLine = false; + } + } +}; +BRp$b.getSourceEndpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + switch (rs.edgeType) { + case 'haystack': + return { + x: rs.haystackPts[0], + y: rs.haystackPts[1] + }; + default: + return { + x: rs.arrowStartX, + y: rs.arrowStartY + }; + } +}; +BRp$b.getTargetEndpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + switch (rs.edgeType) { + case 'haystack': + return { + x: rs.haystackPts[2], + y: rs.haystackPts[3] + }; + default: + return { + x: rs.arrowEndX, + y: rs.arrowEndY + }; + } +}; + +var BRp$a = {}; +function pushBezierPts(r, edge, pts) { + var qbezierAt$1 = function qbezierAt$1(p1, p2, p3, t) { + return qbezierAt(p1, p2, p3, t); + }; + var _p = edge._private; + var bpts = _p.rstyle.bezierPts; + for (var i = 0; i < r.bezierProjPcts.length; i++) { + var p = r.bezierProjPcts[i]; + bpts.push({ + x: qbezierAt$1(pts[0], pts[2], pts[4], p), + y: qbezierAt$1(pts[1], pts[3], pts[5], p) + }); + } +} +BRp$a.storeEdgeProjections = function (edge) { + var _p = edge._private; + var rs = _p.rscratch; + var et = rs.edgeType; + + // clear the cached points state + _p.rstyle.bezierPts = null; + _p.rstyle.linePts = null; + _p.rstyle.haystackPts = null; + if (et === 'multibezier' || et === 'bezier' || et === 'self' || et === 'compound') { + _p.rstyle.bezierPts = []; + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + pushBezierPts(this, edge, rs.allpts.slice(i, i + 6)); + } + } else if (et === 'segments') { + var lpts = _p.rstyle.linePts = []; + for (var i = 0; i + 1 < rs.allpts.length; i += 2) { + lpts.push({ + x: rs.allpts[i], + y: rs.allpts[i + 1] + }); + } + } else if (et === 'haystack') { + var hpts = rs.haystackPts; + _p.rstyle.haystackPts = [{ + x: hpts[0], + y: hpts[1] + }, { + x: hpts[2], + y: hpts[3] + }]; + } + _p.rstyle.arrowWidth = this.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.arrowShapeWidth; +}; +BRp$a.recalculateEdgeProjections = function (edges) { + this.findEdgeControlPoints(edges); +}; + +/* global document */ + +var BRp$9 = {}; +BRp$9.recalculateNodeLabelProjection = function (node) { + var content = node.pstyle('label').strValue; + if (emptyString(content)) { + return; + } + var textX, textY; + var _p = node._private; + var nodeWidth = node.width(); + var nodeHeight = node.height(); + var padding = node.padding(); + var nodePos = node.position(); + var textHalign = node.pstyle('text-halign').strValue; + var textValign = node.pstyle('text-valign').strValue; + var rs = _p.rscratch; + var rstyle = _p.rstyle; + switch (textHalign) { + case 'left': + textX = nodePos.x - nodeWidth / 2 - padding; + break; + case 'right': + textX = nodePos.x + nodeWidth / 2 + padding; + break; + default: + // e.g. center + textX = nodePos.x; + } + switch (textValign) { + case 'top': + textY = nodePos.y - nodeHeight / 2 - padding; + break; + case 'bottom': + textY = nodePos.y + nodeHeight / 2 + padding; + break; + default: + // e.g. middle + textY = nodePos.y; + } + rs.labelX = textX; + rs.labelY = textY; + rstyle.labelX = textX; + rstyle.labelY = textY; + this.calculateLabelAngles(node); + this.applyLabelDimensions(node); +}; +var lineAngleFromDelta = function lineAngleFromDelta(dx, dy) { + var angle = Math.atan(dy / dx); + if (dx === 0 && angle < 0) { + angle = angle * -1; + } + return angle; +}; +var lineAngle = function lineAngle(p0, p1) { + var dx = p1.x - p0.x; + var dy = p1.y - p0.y; + return lineAngleFromDelta(dx, dy); +}; +var bezierAngle = function bezierAngle(p0, p1, p2, t) { + var t0 = bound(0, t - 0.001, 1); + var t1 = bound(0, t + 0.001, 1); + var lp0 = qbezierPtAt(p0, p1, p2, t0); + var lp1 = qbezierPtAt(p0, p1, p2, t1); + return lineAngle(lp0, lp1); +}; +BRp$9.recalculateEdgeLabelProjections = function (edge) { + var p; + var _p = edge._private; + var rs = _p.rscratch; + var r = this; + var content = { + mid: edge.pstyle('label').strValue, + source: edge.pstyle('source-label').strValue, + target: edge.pstyle('target-label').strValue + }; + if (content.mid || content.source || content.target) ; else { + return; // no labels => no calcs + } + + // add center point to style so bounding box calculations can use it + // + p = { + x: rs.midX, + y: rs.midY + }; + var setRs = function setRs(propName, prefix, value) { + setPrefixedProperty(_p.rscratch, propName, prefix, value); + setPrefixedProperty(_p.rstyle, propName, prefix, value); + }; + setRs('labelX', null, p.x); + setRs('labelY', null, p.y); + var midAngle = lineAngleFromDelta(rs.midDispX, rs.midDispY); + setRs('labelAutoAngle', null, midAngle); + var createControlPointInfo = function createControlPointInfo() { + if (createControlPointInfo.cache) { + return createControlPointInfo.cache; + } // use cache so only 1x per edge + + var ctrlpts = []; + + // store each ctrlpt info init + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + var p0 = { + x: rs.allpts[i], + y: rs.allpts[i + 1] + }; + var p1 = { + x: rs.allpts[i + 2], + y: rs.allpts[i + 3] + }; // ctrlpt + var p2 = { + x: rs.allpts[i + 4], + y: rs.allpts[i + 5] + }; + ctrlpts.push({ + p0: p0, + p1: p1, + p2: p2, + startDist: 0, + length: 0, + segments: [] + }); + } + var bpts = _p.rstyle.bezierPts; + var nProjs = r.bezierProjPcts.length; + function addSegment(cp, p0, p1, t0, t1) { + var length = dist(p0, p1); + var prevSegment = cp.segments[cp.segments.length - 1]; + var segment = { + p0: p0, + p1: p1, + t0: t0, + t1: t1, + startDist: prevSegment ? prevSegment.startDist + prevSegment.length : 0, + length: length + }; + cp.segments.push(segment); + cp.length += length; + } + + // update each ctrlpt with segment info + for (var _i = 0; _i < ctrlpts.length; _i++) { + var cp = ctrlpts[_i]; + var prevCp = ctrlpts[_i - 1]; + if (prevCp) { + cp.startDist = prevCp.startDist + prevCp.length; + } + addSegment(cp, cp.p0, bpts[_i * nProjs], 0, r.bezierProjPcts[0]); // first + + for (var j = 0; j < nProjs - 1; j++) { + addSegment(cp, bpts[_i * nProjs + j], bpts[_i * nProjs + j + 1], r.bezierProjPcts[j], r.bezierProjPcts[j + 1]); + } + addSegment(cp, bpts[_i * nProjs + nProjs - 1], cp.p2, r.bezierProjPcts[nProjs - 1], 1); // last + } + + return createControlPointInfo.cache = ctrlpts; + }; + var calculateEndProjection = function calculateEndProjection(prefix) { + var angle; + var isSrc = prefix === 'source'; + if (!content[prefix]) { + return; + } + var offset = edge.pstyle(prefix + '-text-offset').pfValue; + switch (rs.edgeType) { + case 'self': + case 'compound': + case 'bezier': + case 'multibezier': + { + var cps = createControlPointInfo(); + var selected; + var startDist = 0; + var totalDist = 0; + + // find the segment we're on + for (var i = 0; i < cps.length; i++) { + var _cp = cps[isSrc ? i : cps.length - 1 - i]; + for (var j = 0; j < _cp.segments.length; j++) { + var _seg = _cp.segments[isSrc ? j : _cp.segments.length - 1 - j]; + var lastSeg = i === cps.length - 1 && j === _cp.segments.length - 1; + startDist = totalDist; + totalDist += _seg.length; + if (totalDist >= offset || lastSeg) { + selected = { + cp: _cp, + segment: _seg + }; + break; + } + } + if (selected) { + break; + } + } + var cp = selected.cp; + var seg = selected.segment; + var tSegment = (offset - startDist) / seg.length; + var segDt = seg.t1 - seg.t0; + var t = isSrc ? seg.t0 + segDt * tSegment : seg.t1 - segDt * tSegment; + t = bound(0, t, 1); + p = qbezierPtAt(cp.p0, cp.p1, cp.p2, t); + angle = bezierAngle(cp.p0, cp.p1, cp.p2, t); + break; + } + case 'straight': + case 'segments': + case 'haystack': + { + var d = 0, + di, + d0; + var p0, p1; + var l = rs.allpts.length; + for (var _i2 = 0; _i2 + 3 < l; _i2 += 2) { + if (isSrc) { + p0 = { + x: rs.allpts[_i2], + y: rs.allpts[_i2 + 1] + }; + p1 = { + x: rs.allpts[_i2 + 2], + y: rs.allpts[_i2 + 3] + }; + } else { + p0 = { + x: rs.allpts[l - 2 - _i2], + y: rs.allpts[l - 1 - _i2] + }; + p1 = { + x: rs.allpts[l - 4 - _i2], + y: rs.allpts[l - 3 - _i2] + }; + } + di = dist(p0, p1); + d0 = d; + d += di; + if (d >= offset) { + break; + } + } + var pD = offset - d0; + var _t = pD / di; + _t = bound(0, _t, 1); + p = lineAt(p0, p1, _t); + angle = lineAngle(p0, p1); + break; + } + } + setRs('labelX', prefix, p.x); + setRs('labelY', prefix, p.y); + setRs('labelAutoAngle', prefix, angle); + }; + calculateEndProjection('source'); + calculateEndProjection('target'); + this.applyLabelDimensions(edge); +}; +BRp$9.applyLabelDimensions = function (ele) { + this.applyPrefixedLabelDimensions(ele); + if (ele.isEdge()) { + this.applyPrefixedLabelDimensions(ele, 'source'); + this.applyPrefixedLabelDimensions(ele, 'target'); + } +}; +BRp$9.applyPrefixedLabelDimensions = function (ele, prefix) { + var _p = ele._private; + var text = this.getLabelText(ele, prefix); + var labelDims = this.calculateLabelDimensions(ele, text); + var lineHeight = ele.pstyle('line-height').pfValue; + var textWrap = ele.pstyle('text-wrap').strValue; + var lines = getPrefixedProperty(_p.rscratch, 'labelWrapCachedLines', prefix) || []; + var numLines = textWrap !== 'wrap' ? 1 : Math.max(lines.length, 1); + var normPerLineHeight = labelDims.height / numLines; + var labelLineHeight = normPerLineHeight * lineHeight; + var width = labelDims.width; + var height = labelDims.height + (numLines - 1) * (lineHeight - 1) * normPerLineHeight; + setPrefixedProperty(_p.rstyle, 'labelWidth', prefix, width); + setPrefixedProperty(_p.rscratch, 'labelWidth', prefix, width); + setPrefixedProperty(_p.rstyle, 'labelHeight', prefix, height); + setPrefixedProperty(_p.rscratch, 'labelHeight', prefix, height); + setPrefixedProperty(_p.rscratch, 'labelLineHeight', prefix, labelLineHeight); +}; +BRp$9.getLabelText = function (ele, prefix) { + var _p = ele._private; + var pfd = prefix ? prefix + '-' : ''; + var text = ele.pstyle(pfd + 'label').strValue; + var textTransform = ele.pstyle('text-transform').value; + var rscratch = function rscratch(propName, value) { + if (value) { + setPrefixedProperty(_p.rscratch, propName, prefix, value); + return value; + } else { + return getPrefixedProperty(_p.rscratch, propName, prefix); + } + }; + + // for empty text, skip all processing + if (!text) { + return ''; + } + if (textTransform == 'none') ; else if (textTransform == 'uppercase') { + text = text.toUpperCase(); + } else if (textTransform == 'lowercase') { + text = text.toLowerCase(); + } + var wrapStyle = ele.pstyle('text-wrap').value; + if (wrapStyle === 'wrap') { + var labelKey = rscratch('labelKey'); + + // save recalc if the label is the same as before + if (labelKey != null && rscratch('labelWrapKey') === labelKey) { + return rscratch('labelWrapCachedText'); + } + var zwsp = "\u200B"; + var lines = text.split('\n'); + var maxW = ele.pstyle('text-max-width').pfValue; + var overflow = ele.pstyle('text-overflow-wrap').value; + var overflowAny = overflow === 'anywhere'; + var wrappedLines = []; + var wordsRegex = /[\s\u200b]+/; + var wordSeparator = overflowAny ? '' : ' '; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var lineDims = this.calculateLabelDimensions(ele, line); + var lineW = lineDims.width; + if (overflowAny) { + var processedLine = line.split('').join(zwsp); + line = processedLine; + } + if (lineW > maxW) { + // line is too long + var words = line.split(wordsRegex); + var subline = ''; + for (var w = 0; w < words.length; w++) { + var word = words[w]; + var testLine = subline.length === 0 ? word : subline + wordSeparator + word; + var testDims = this.calculateLabelDimensions(ele, testLine); + var testW = testDims.width; + if (testW <= maxW) { + // word fits on current line + subline += word + wordSeparator; + } else { + // word starts new line + if (subline) { + wrappedLines.push(subline); + } + subline = word + wordSeparator; + } + } + + // if there's remaining text, put it in a wrapped line + if (!subline.match(/^[\s\u200b]+$/)) { + wrappedLines.push(subline); + } + } else { + // line is already short enough + wrappedLines.push(line); + } + } // for + + rscratch('labelWrapCachedLines', wrappedLines); + text = rscratch('labelWrapCachedText', wrappedLines.join('\n')); + rscratch('labelWrapKey', labelKey); + } else if (wrapStyle === 'ellipsis') { + var _maxW = ele.pstyle('text-max-width').pfValue; + var ellipsized = ''; + var ellipsis = "\u2026"; + var incLastCh = false; + if (this.calculateLabelDimensions(ele, text).width < _maxW) { + // the label already fits + return text; + } + for (var i = 0; i < text.length; i++) { + var widthWithNextCh = this.calculateLabelDimensions(ele, ellipsized + text[i] + ellipsis).width; + if (widthWithNextCh > _maxW) { + break; + } + ellipsized += text[i]; + if (i === text.length - 1) { + incLastCh = true; + } + } + if (!incLastCh) { + ellipsized += ellipsis; + } + return ellipsized; + } // if ellipsize + + return text; +}; +BRp$9.getLabelJustification = function (ele) { + var justification = ele.pstyle('text-justification').strValue; + var textHalign = ele.pstyle('text-halign').strValue; + if (justification === 'auto') { + if (ele.isNode()) { + switch (textHalign) { + case 'left': + return 'right'; + case 'right': + return 'left'; + default: + return 'center'; + } + } else { + return 'center'; + } + } else { + return justification; + } +}; +BRp$9.calculateLabelDimensions = function (ele, text) { + var r = this; + var cacheKey = hashString(text, ele._private.labelDimsKey); + var cache = r.labelDimCache || (r.labelDimCache = []); + var existingVal = cache[cacheKey]; + if (existingVal != null) { + return existingVal; + } + var padding = 0; // add padding around text dims, as the measurement isn't that accurate + var fStyle = ele.pstyle('font-style').strValue; + var size = ele.pstyle('font-size').pfValue; + var family = ele.pstyle('font-family').strValue; + var weight = ele.pstyle('font-weight').strValue; + var canvas = this.labelCalcCanvas; + var c2d = this.labelCalcCanvasContext; + if (!canvas) { + canvas = this.labelCalcCanvas = document.createElement('canvas'); + c2d = this.labelCalcCanvasContext = canvas.getContext('2d'); + var ds = canvas.style; + ds.position = 'absolute'; + ds.left = '-9999px'; + ds.top = '-9999px'; + ds.zIndex = '-1'; + ds.visibility = 'hidden'; + ds.pointerEvents = 'none'; + } + c2d.font = "".concat(fStyle, " ").concat(weight, " ").concat(size, "px ").concat(family); + var width = 0; + var height = 0; + var lines = text.split('\n'); + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + var metrics = c2d.measureText(line); + var w = Math.ceil(metrics.width); + var h = size; + width = Math.max(w, width); + height += h; + } + width += padding; + height += padding; + return cache[cacheKey] = { + width: width, + height: height + }; +}; +BRp$9.calculateLabelAngle = function (ele, prefix) { + var _p = ele._private; + var rs = _p.rscratch; + var isEdge = ele.isEdge(); + var prefixDash = prefix ? prefix + '-' : ''; + var rot = ele.pstyle(prefixDash + 'text-rotation'); + var rotStr = rot.strValue; + if (rotStr === 'none') { + return 0; + } else if (isEdge && rotStr === 'autorotate') { + return rs.labelAutoAngle; + } else if (rotStr === 'autorotate') { + return 0; + } else { + return rot.pfValue; + } +}; +BRp$9.calculateLabelAngles = function (ele) { + var r = this; + var isEdge = ele.isEdge(); + var _p = ele._private; + var rs = _p.rscratch; + rs.labelAngle = r.calculateLabelAngle(ele); + if (isEdge) { + rs.sourceLabelAngle = r.calculateLabelAngle(ele, 'source'); + rs.targetLabelAngle = r.calculateLabelAngle(ele, 'target'); + } +}; + +var BRp$8 = {}; +var TOO_SMALL_CUT_RECT = 28; +var warnedCutRect = false; +BRp$8.getNodeShape = function (node) { + var r = this; + var shape = node.pstyle('shape').value; + if (shape === 'cutrectangle' && (node.width() < TOO_SMALL_CUT_RECT || node.height() < TOO_SMALL_CUT_RECT)) { + if (!warnedCutRect) { + warn('The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead'); + warnedCutRect = true; + } + return 'rectangle'; + } + if (node.isParent()) { + if (shape === 'rectangle' || shape === 'roundrectangle' || shape === 'round-rectangle' || shape === 'cutrectangle' || shape === 'cut-rectangle' || shape === 'barrel') { + return shape; + } else { + return 'rectangle'; + } + } + if (shape === 'polygon') { + var points = node.pstyle('shape-polygon-points').value; + return r.nodeShapes.makePolygon(points).name; + } + return shape; +}; + +var BRp$7 = {}; +BRp$7.registerCalculationListeners = function () { + var cy = this.cy; + var elesToUpdate = cy.collection(); + var r = this; + var enqueue = function enqueue(eles) { + var dirtyStyleCaches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + elesToUpdate.merge(eles); + if (dirtyStyleCaches) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var rstyle = _p.rstyle; + rstyle.clean = false; + rstyle.cleanConnected = false; + } + } + }; + r.binder(cy).on('bounds.* dirty.*', function onDirtyBounds(e) { + var ele = e.target; + enqueue(ele); + }).on('style.* background.*', function onDirtyStyle(e) { + var ele = e.target; + enqueue(ele, false); + }); + var updateEleCalcs = function updateEleCalcs(willDraw) { + if (willDraw) { + var fns = r.onUpdateEleCalcsFns; + + // because we need to have up-to-date style (e.g. stylesheet mappers) + // before calculating rendered style (and pstyle might not be called yet) + elesToUpdate.cleanStyle(); + for (var i = 0; i < elesToUpdate.length; i++) { + var ele = elesToUpdate[i]; + var rstyle = ele._private.rstyle; + if (ele.isNode() && !rstyle.cleanConnected) { + enqueue(ele.connectedEdges()); + rstyle.cleanConnected = true; + } + } + if (fns) { + for (var _i = 0; _i < fns.length; _i++) { + var fn = fns[_i]; + fn(willDraw, elesToUpdate); + } + } + r.recalculateRenderedStyle(elesToUpdate); + elesToUpdate = cy.collection(); + } + }; + r.flushRenderedStyleQueue = function () { + updateEleCalcs(true); + }; + r.beforeRender(updateEleCalcs, r.beforeRenderPriorities.eleCalcs); +}; +BRp$7.onUpdateEleCalcs = function (fn) { + var fns = this.onUpdateEleCalcsFns = this.onUpdateEleCalcsFns || []; + fns.push(fn); +}; +BRp$7.recalculateRenderedStyle = function (eles, useCache) { + var isCleanConnected = function isCleanConnected(ele) { + return ele._private.rstyle.cleanConnected; + }; + var edges = []; + var nodes = []; + + // the renderer can't be used for calcs when destroyed, e.g. ele.boundingBox() + if (this.destroyed) { + return; + } + + // use cache by default for perf + if (useCache === undefined) { + useCache = true; + } + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var rstyle = _p.rstyle; + + // an edge may be implicitly dirty b/c of one of its connected nodes + // (and a request for recalc may come in between frames) + if (ele.isEdge() && (!isCleanConnected(ele.source()) || !isCleanConnected(ele.target()))) { + rstyle.clean = false; + } + + // only update if dirty and in graph + if (useCache && rstyle.clean || ele.removed()) { + continue; + } + + // only update if not display: none + if (ele.pstyle('display').value === 'none') { + continue; + } + if (_p.group === 'nodes') { + nodes.push(ele); + } else { + // edges + edges.push(ele); + } + rstyle.clean = true; + } + + // update node data from projections + for (var _i2 = 0; _i2 < nodes.length; _i2++) { + var _ele = nodes[_i2]; + var _p2 = _ele._private; + var _rstyle = _p2.rstyle; + var pos = _ele.position(); + this.recalculateNodeLabelProjection(_ele); + _rstyle.nodeX = pos.x; + _rstyle.nodeY = pos.y; + _rstyle.nodeW = _ele.pstyle('width').pfValue; + _rstyle.nodeH = _ele.pstyle('height').pfValue; + } + this.recalculateEdgeProjections(edges); + + // update edge data from projections + for (var _i3 = 0; _i3 < edges.length; _i3++) { + var _ele2 = edges[_i3]; + var _p3 = _ele2._private; + var _rstyle2 = _p3.rstyle; + var rs = _p3.rscratch; + + // update rstyle positions + _rstyle2.srcX = rs.arrowStartX; + _rstyle2.srcY = rs.arrowStartY; + _rstyle2.tgtX = rs.arrowEndX; + _rstyle2.tgtY = rs.arrowEndY; + _rstyle2.midX = rs.midX; + _rstyle2.midY = rs.midY; + _rstyle2.labelAngle = rs.labelAngle; + _rstyle2.sourceLabelAngle = rs.sourceLabelAngle; + _rstyle2.targetLabelAngle = rs.targetLabelAngle; + } +}; + +var BRp$6 = {}; +BRp$6.updateCachedGrabbedEles = function () { + var eles = this.cachedZSortedEles; + if (!eles) { + // just let this be recalculated on the next z sort tick + return; + } + eles.drag = []; + eles.nondrag = []; + var grabTargets = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var rs = ele._private.rscratch; + if (ele.grabbed() && !ele.isParent()) { + grabTargets.push(ele); + } else if (rs.inDragLayer) { + eles.drag.push(ele); + } else { + eles.nondrag.push(ele); + } + } + + // put the grab target nodes last so it's on top of its neighbourhood + for (var i = 0; i < grabTargets.length; i++) { + var ele = grabTargets[i]; + eles.drag.push(ele); + } +}; +BRp$6.invalidateCachedZSortedEles = function () { + this.cachedZSortedEles = null; +}; +BRp$6.getCachedZSortedEles = function (forceRecalc) { + if (forceRecalc || !this.cachedZSortedEles) { + var eles = this.cy.mutableElements().toArray(); + eles.sort(zIndexSort); + eles.interactive = eles.filter(function (ele) { + return ele.interactive(); + }); + this.cachedZSortedEles = eles; + this.updateCachedGrabbedEles(); + } else { + eles = this.cachedZSortedEles; + } + return eles; +}; + +var BRp$5 = {}; +[BRp$e, BRp$d, BRp$c, BRp$b, BRp$a, BRp$9, BRp$8, BRp$7, BRp$6].forEach(function (props) { + extend(BRp$5, props); +}); + +var BRp$4 = {}; +BRp$4.getCachedImage = function (url, crossOrigin, onLoad) { + var r = this; + var imageCache = r.imageCache = r.imageCache || {}; + var cache = imageCache[url]; + if (cache) { + if (!cache.image.complete) { + cache.image.addEventListener('load', onLoad); + } + return cache.image; + } else { + cache = imageCache[url] = imageCache[url] || {}; + var image = cache.image = new Image(); // eslint-disable-line no-undef + + image.addEventListener('load', onLoad); + image.addEventListener('error', function () { + image.error = true; + }); + + // #1582 safari doesn't load data uris with crossOrigin properly + // https://bugs.webkit.org/show_bug.cgi?id=123978 + var dataUriPrefix = 'data:'; + var isDataUri = url.substring(0, dataUriPrefix.length).toLowerCase() === dataUriPrefix; + if (!isDataUri) { + // if crossorigin is 'null'(stringified), then manually set it to null + crossOrigin = crossOrigin === 'null' ? null : crossOrigin; + image.crossOrigin = crossOrigin; // prevent tainted canvas + } + + image.src = url; + return image; + } +}; + +var BRp$3 = {}; + +/* global document, window, ResizeObserver, MutationObserver */ + +BRp$3.registerBinding = function (target, event, handler, useCapture) { + // eslint-disable-line no-unused-vars + var args = Array.prototype.slice.apply(arguments, [1]); // copy + var b = this.binder(target); + return b.on.apply(b, args); +}; +BRp$3.binder = function (tgt) { + var r = this; + var containerWindow = r.cy.window(); + var tgtIsDom = tgt === containerWindow || tgt === containerWindow.document || tgt === containerWindow.document.body || domElement(tgt); + if (r.supportsPassiveEvents == null) { + // from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection + var supportsPassive = false; + try { + var opts = Object.defineProperty({}, 'passive', { + get: function get() { + supportsPassive = true; + return true; + } + }); + containerWindow.addEventListener('test', null, opts); + } catch (err) { + // not supported + } + r.supportsPassiveEvents = supportsPassive; + } + var on = function on(event, handler, useCapture) { + var args = Array.prototype.slice.call(arguments); + if (tgtIsDom && r.supportsPassiveEvents) { + // replace useCapture w/ opts obj + args[2] = { + capture: useCapture != null ? useCapture : false, + passive: false, + once: false + }; + } + r.bindings.push({ + target: tgt, + args: args + }); + (tgt.addEventListener || tgt.on).apply(tgt, args); + return this; + }; + return { + on: on, + addEventListener: on, + addListener: on, + bind: on + }; +}; +BRp$3.nodeIsDraggable = function (node) { + return node && node.isNode() && !node.locked() && node.grabbable(); +}; +BRp$3.nodeIsGrabbable = function (node) { + return this.nodeIsDraggable(node) && node.interactive(); +}; +BRp$3.load = function () { + var r = this; + var containerWindow = r.cy.window(); + var isSelected = function isSelected(ele) { + return ele.selected(); + }; + var triggerEvents = function triggerEvents(target, names, e, position) { + if (target == null) { + target = r.cy; + } + for (var i = 0; i < names.length; i++) { + var name = names[i]; + target.emit({ + originalEvent: e, + type: name, + position: position + }); + } + }; + var isMultSelKeyDown = function isMultSelKeyDown(e) { + return e.shiftKey || e.metaKey || e.ctrlKey; // maybe e.altKey + }; + + var allowPanningPassthrough = function allowPanningPassthrough(down, downs) { + var allowPassthrough = true; + if (r.cy.hasCompoundNodes() && down && down.pannable()) { + // a grabbable compound node below the ele => no passthrough panning + for (var i = 0; downs && i < downs.length; i++) { + var down = downs[i]; + + //if any parent node in event hierarchy isn't pannable, reject passthrough + if (down.isNode() && down.isParent() && !down.pannable()) { + allowPassthrough = false; + break; + } + } + } else { + allowPassthrough = true; + } + return allowPassthrough; + }; + var setGrabbed = function setGrabbed(ele) { + ele[0]._private.grabbed = true; + }; + var setFreed = function setFreed(ele) { + ele[0]._private.grabbed = false; + }; + var setInDragLayer = function setInDragLayer(ele) { + ele[0]._private.rscratch.inDragLayer = true; + }; + var setOutDragLayer = function setOutDragLayer(ele) { + ele[0]._private.rscratch.inDragLayer = false; + }; + var setGrabTarget = function setGrabTarget(ele) { + ele[0]._private.rscratch.isGrabTarget = true; + }; + var removeGrabTarget = function removeGrabTarget(ele) { + ele[0]._private.rscratch.isGrabTarget = false; + }; + var addToDragList = function addToDragList(ele, opts) { + var list = opts.addToList; + var listHasEle = list.has(ele); + if (!listHasEle && ele.grabbable() && !ele.locked()) { + list.merge(ele); + setGrabbed(ele); + } + }; + + // helper function to determine which child nodes and inner edges + // of a compound node to be dragged as well as the grabbed and selected nodes + var addDescendantsToDrag = function addDescendantsToDrag(node, opts) { + if (!node.cy().hasCompoundNodes()) { + return; + } + if (opts.inDragLayer == null && opts.addToList == null) { + return; + } // nothing to do + + var innerNodes = node.descendants(); + if (opts.inDragLayer) { + innerNodes.forEach(setInDragLayer); + innerNodes.connectedEdges().forEach(setInDragLayer); + } + if (opts.addToList) { + addToDragList(innerNodes, opts); + } + }; + + // adds the given nodes and its neighbourhood to the drag layer + var addNodesToDrag = function addNodesToDrag(nodes, opts) { + opts = opts || {}; + var hasCompoundNodes = nodes.cy().hasCompoundNodes(); + if (opts.inDragLayer) { + nodes.forEach(setInDragLayer); + nodes.neighborhood().stdFilter(function (ele) { + return !hasCompoundNodes || ele.isEdge(); + }).forEach(setInDragLayer); + } + if (opts.addToList) { + nodes.forEach(function (ele) { + addToDragList(ele, opts); + }); + } + addDescendantsToDrag(nodes, opts); // always add to drag + + // also add nodes and edges related to the topmost ancestor + updateAncestorsInDragLayer(nodes, { + inDragLayer: opts.inDragLayer + }); + r.updateCachedGrabbedEles(); + }; + var addNodeToDrag = addNodesToDrag; + var freeDraggedElements = function freeDraggedElements(grabbedEles) { + if (!grabbedEles) { + return; + } + + // just go over all elements rather than doing a bunch of (possibly expensive) traversals + r.getCachedZSortedEles().forEach(function (ele) { + setFreed(ele); + setOutDragLayer(ele); + removeGrabTarget(ele); + }); + r.updateCachedGrabbedEles(); + }; + + // helper function to determine which ancestor nodes and edges should go + // to the drag layer (or should be removed from drag layer). + var updateAncestorsInDragLayer = function updateAncestorsInDragLayer(node, opts) { + if (opts.inDragLayer == null && opts.addToList == null) { + return; + } // nothing to do + + if (!node.cy().hasCompoundNodes()) { + return; + } + + // find top-level parent + var parent = node.ancestors().orphans(); + + // no parent node: no nodes to add to the drag layer + if (parent.same(node)) { + return; + } + var nodes = parent.descendants().spawnSelf().merge(parent).unmerge(node).unmerge(node.descendants()); + var edges = nodes.connectedEdges(); + if (opts.inDragLayer) { + edges.forEach(setInDragLayer); + nodes.forEach(setInDragLayer); + } + if (opts.addToList) { + nodes.forEach(function (ele) { + addToDragList(ele, opts); + }); + } + }; + var blurActiveDomElement = function blurActiveDomElement() { + if (document.activeElement != null && document.activeElement.blur != null) { + document.activeElement.blur(); + } + }; + var haveMutationsApi = typeof MutationObserver !== 'undefined'; + var haveResizeObserverApi = typeof ResizeObserver !== 'undefined'; + + // watch for when the cy container is removed from the dom + if (haveMutationsApi) { + r.removeObserver = new MutationObserver(function (mutns) { + // eslint-disable-line no-undef + for (var i = 0; i < mutns.length; i++) { + var mutn = mutns[i]; + var rNodes = mutn.removedNodes; + if (rNodes) { + for (var j = 0; j < rNodes.length; j++) { + var rNode = rNodes[j]; + if (rNode === r.container) { + r.destroy(); + break; + } + } + } + } + }); + if (r.container.parentNode) { + r.removeObserver.observe(r.container.parentNode, { + childList: true + }); + } + } else { + r.registerBinding(r.container, 'DOMNodeRemoved', function (e) { + // eslint-disable-line no-unused-vars + r.destroy(); + }); + } + var onResize = debounce_1(function () { + r.cy.resize(); + }, 100); + if (haveMutationsApi) { + r.styleObserver = new MutationObserver(onResize); // eslint-disable-line no-undef + + r.styleObserver.observe(r.container, { + attributes: true + }); + } + + // auto resize + r.registerBinding(containerWindow, 'resize', onResize); // eslint-disable-line no-undef + + if (haveResizeObserverApi) { + r.resizeObserver = new ResizeObserver(onResize); // eslint-disable-line no-undef + + r.resizeObserver.observe(r.container); + } + var forEachUp = function forEachUp(domEle, fn) { + while (domEle != null) { + fn(domEle); + domEle = domEle.parentNode; + } + }; + var invalidateCoords = function invalidateCoords() { + r.invalidateContainerClientCoordsCache(); + }; + forEachUp(r.container, function (domEle) { + r.registerBinding(domEle, 'transitionend', invalidateCoords); + r.registerBinding(domEle, 'animationend', invalidateCoords); + r.registerBinding(domEle, 'scroll', invalidateCoords); + }); + + // stop right click menu from appearing on cy + r.registerBinding(r.container, 'contextmenu', function (e) { + e.preventDefault(); + }); + var inBoxSelection = function inBoxSelection() { + return r.selection[4] !== 0; + }; + var eventInContainer = function eventInContainer(e) { + // save cycles if mouse events aren't to be captured + var containerPageCoords = r.findContainerClientCoords(); + var x = containerPageCoords[0]; + var y = containerPageCoords[1]; + var width = containerPageCoords[2]; + var height = containerPageCoords[3]; + var positions = e.touches ? e.touches : [e]; + var atLeastOnePosInside = false; + for (var i = 0; i < positions.length; i++) { + var p = positions[i]; + if (x <= p.clientX && p.clientX <= x + width && y <= p.clientY && p.clientY <= y + height) { + atLeastOnePosInside = true; + break; + } + } + if (!atLeastOnePosInside) { + return false; + } + var container = r.container; + var target = e.target; + var tParent = target.parentNode; + var containerIsTarget = false; + while (tParent) { + if (tParent === container) { + containerIsTarget = true; + break; + } + tParent = tParent.parentNode; + } + if (!containerIsTarget) { + return false; + } // if target is outisde cy container, then this event is not for us + + return true; + }; + + // Primary key + r.registerBinding(r.container, 'mousedown', function mousedownHandler(e) { + if (!eventInContainer(e)) { + return; + } + e.preventDefault(); + blurActiveDomElement(); + r.hoverData.capture = true; + r.hoverData.which = e.which; + var cy = r.cy; + var gpos = [e.clientX, e.clientY]; + var pos = r.projectIntoViewport(gpos[0], gpos[1]); + var select = r.selection; + var nears = r.findNearestElements(pos[0], pos[1], true, false); + var near = nears[0]; + var draggedElements = r.dragData.possibleDragElements; + r.hoverData.mdownPos = pos; + r.hoverData.mdownGPos = gpos; + var checkForTaphold = function checkForTaphold() { + r.hoverData.tapholdCancelled = false; + clearTimeout(r.hoverData.tapholdTimeout); + r.hoverData.tapholdTimeout = setTimeout(function () { + if (r.hoverData.tapholdCancelled) { + return; + } else { + var ele = r.hoverData.down; + if (ele) { + ele.emit({ + originalEvent: e, + type: 'taphold', + position: { + x: pos[0], + y: pos[1] + } + }); + } else { + cy.emit({ + originalEvent: e, + type: 'taphold', + position: { + x: pos[0], + y: pos[1] + } + }); + } + } + }, r.tapholdDuration); + }; + + // Right click button + if (e.which == 3) { + r.hoverData.cxtStarted = true; + var cxtEvt = { + originalEvent: e, + type: 'cxttapstart', + position: { + x: pos[0], + y: pos[1] + } + }; + if (near) { + near.activate(); + near.emit(cxtEvt); + r.hoverData.down = near; + } else { + cy.emit(cxtEvt); + } + r.hoverData.downTime = new Date().getTime(); + r.hoverData.cxtDragged = false; + + // Primary button + } else if (e.which == 1) { + if (near) { + near.activate(); + } + + // Element dragging + { + // If something is under the cursor and it is draggable, prepare to grab it + if (near != null) { + if (r.nodeIsGrabbable(near)) { + var makeEvent = function makeEvent(type) { + return { + originalEvent: e, + type: type, + position: { + x: pos[0], + y: pos[1] + } + }; + }; + var triggerGrab = function triggerGrab(ele) { + ele.emit(makeEvent('grab')); + }; + setGrabTarget(near); + if (!near.selected()) { + draggedElements = r.dragData.possibleDragElements = cy.collection(); + addNodeToDrag(near, { + addToList: draggedElements + }); + near.emit(makeEvent('grabon')).emit(makeEvent('grab')); + } else { + draggedElements = r.dragData.possibleDragElements = cy.collection(); + var selectedNodes = cy.$(function (ele) { + return ele.isNode() && ele.selected() && r.nodeIsGrabbable(ele); + }); + addNodesToDrag(selectedNodes, { + addToList: draggedElements + }); + near.emit(makeEvent('grabon')); + selectedNodes.forEach(triggerGrab); + } + r.redrawHint('eles', true); + r.redrawHint('drag', true); + } + } + r.hoverData.down = near; + r.hoverData.downs = nears; + r.hoverData.downTime = new Date().getTime(); + } + triggerEvents(near, ['mousedown', 'tapstart', 'vmousedown'], e, { + x: pos[0], + y: pos[1] + }); + if (near == null) { + select[4] = 1; + r.data.bgActivePosistion = { + x: pos[0], + y: pos[1] + }; + r.redrawHint('select', true); + r.redraw(); + } else if (near.pannable()) { + select[4] = 1; // for future pan + } + + checkForTaphold(); + } + + // Initialize selection box coordinates + select[0] = select[2] = pos[0]; + select[1] = select[3] = pos[1]; + }, false); + r.registerBinding(containerWindow, 'mousemove', function mousemoveHandler(e) { + // eslint-disable-line no-undef + var capture = r.hoverData.capture; + if (!capture && !eventInContainer(e)) { + return; + } + var preventDefault = false; + var cy = r.cy; + var zoom = cy.zoom(); + var gpos = [e.clientX, e.clientY]; + var pos = r.projectIntoViewport(gpos[0], gpos[1]); + var mdownPos = r.hoverData.mdownPos; + var mdownGPos = r.hoverData.mdownGPos; + var select = r.selection; + var near = null; + if (!r.hoverData.draggingEles && !r.hoverData.dragging && !r.hoverData.selecting) { + near = r.findNearestElement(pos[0], pos[1], true, false); + } + var last = r.hoverData.last; + var down = r.hoverData.down; + var disp = [pos[0] - select[2], pos[1] - select[3]]; + var draggedElements = r.dragData.possibleDragElements; + var isOverThresholdDrag; + if (mdownGPos) { + var dx = gpos[0] - mdownGPos[0]; + var dx2 = dx * dx; + var dy = gpos[1] - mdownGPos[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + r.hoverData.isOverThresholdDrag = isOverThresholdDrag = dist2 >= r.desktopTapThreshold2; + } + var multSelKeyDown = isMultSelKeyDown(e); + if (isOverThresholdDrag) { + r.hoverData.tapholdCancelled = true; + } + var updateDragDelta = function updateDragDelta() { + var dragDelta = r.hoverData.dragDelta = r.hoverData.dragDelta || []; + if (dragDelta.length === 0) { + dragDelta.push(disp[0]); + dragDelta.push(disp[1]); + } else { + dragDelta[0] += disp[0]; + dragDelta[1] += disp[1]; + } + }; + preventDefault = true; + triggerEvents(near, ['mousemove', 'vmousemove', 'tapdrag'], e, { + x: pos[0], + y: pos[1] + }); + var goIntoBoxMode = function goIntoBoxMode() { + r.data.bgActivePosistion = undefined; + if (!r.hoverData.selecting) { + cy.emit({ + originalEvent: e, + type: 'boxstart', + position: { + x: pos[0], + y: pos[1] + } + }); + } + select[4] = 1; + r.hoverData.selecting = true; + r.redrawHint('select', true); + r.redraw(); + }; + + // trigger context drag if rmouse down + if (r.hoverData.which === 3) { + // but only if over threshold + if (isOverThresholdDrag) { + var cxtEvt = { + originalEvent: e, + type: 'cxtdrag', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + r.hoverData.cxtDragged = true; + if (!r.hoverData.cxtOver || near !== r.hoverData.cxtOver) { + if (r.hoverData.cxtOver) { + r.hoverData.cxtOver.emit({ + originalEvent: e, + type: 'cxtdragout', + position: { + x: pos[0], + y: pos[1] + } + }); + } + r.hoverData.cxtOver = near; + if (near) { + near.emit({ + originalEvent: e, + type: 'cxtdragover', + position: { + x: pos[0], + y: pos[1] + } + }); + } + } + } + + // Check if we are drag panning the entire graph + } else if (r.hoverData.dragging) { + preventDefault = true; + if (cy.panningEnabled() && cy.userPanningEnabled()) { + var deltaP; + if (r.hoverData.justStartedPan) { + var mdPos = r.hoverData.mdownPos; + deltaP = { + x: (pos[0] - mdPos[0]) * zoom, + y: (pos[1] - mdPos[1]) * zoom + }; + r.hoverData.justStartedPan = false; + } else { + deltaP = { + x: disp[0] * zoom, + y: disp[1] * zoom + }; + } + cy.panBy(deltaP); + cy.emit('dragpan'); + r.hoverData.dragged = true; + } + + // Needs reproject due to pan changing viewport + pos = r.projectIntoViewport(e.clientX, e.clientY); + + // Checks primary button down & out of time & mouse not moved much + } else if (select[4] == 1 && (down == null || down.pannable())) { + if (isOverThresholdDrag) { + if (!r.hoverData.dragging && cy.boxSelectionEnabled() && (multSelKeyDown || !cy.panningEnabled() || !cy.userPanningEnabled())) { + goIntoBoxMode(); + } else if (!r.hoverData.selecting && cy.panningEnabled() && cy.userPanningEnabled()) { + var allowPassthrough = allowPanningPassthrough(down, r.hoverData.downs); + if (allowPassthrough) { + r.hoverData.dragging = true; + r.hoverData.justStartedPan = true; + select[4] = 0; + r.data.bgActivePosistion = array2point(mdownPos); + r.redrawHint('select', true); + r.redraw(); + } + } + if (down && down.pannable() && down.active()) { + down.unactivate(); + } + } + } else { + if (down && down.pannable() && down.active()) { + down.unactivate(); + } + if ((!down || !down.grabbed()) && near != last) { + if (last) { + triggerEvents(last, ['mouseout', 'tapdragout'], e, { + x: pos[0], + y: pos[1] + }); + } + if (near) { + triggerEvents(near, ['mouseover', 'tapdragover'], e, { + x: pos[0], + y: pos[1] + }); + } + r.hoverData.last = near; + } + if (down) { + if (isOverThresholdDrag) { + // then we can take action + + if (cy.boxSelectionEnabled() && multSelKeyDown) { + // then selection overrides + if (down && down.grabbed()) { + freeDraggedElements(draggedElements); + down.emit('freeon'); + draggedElements.emit('free'); + if (r.dragData.didDrag) { + down.emit('dragfreeon'); + draggedElements.emit('dragfree'); + } + } + goIntoBoxMode(); + } else if (down && down.grabbed() && r.nodeIsDraggable(down)) { + // drag node + var justStartedDrag = !r.dragData.didDrag; + if (justStartedDrag) { + r.redrawHint('eles', true); + } + r.dragData.didDrag = true; // indicate that we actually did drag the node + + // now, add the elements to the drag layer if not done already + if (!r.hoverData.draggingEles) { + addNodesToDrag(draggedElements, { + inDragLayer: true + }); + } + var totalShift = { + x: 0, + y: 0 + }; + if (number$1(disp[0]) && number$1(disp[1])) { + totalShift.x += disp[0]; + totalShift.y += disp[1]; + if (justStartedDrag) { + var dragDelta = r.hoverData.dragDelta; + if (dragDelta && number$1(dragDelta[0]) && number$1(dragDelta[1])) { + totalShift.x += dragDelta[0]; + totalShift.y += dragDelta[1]; + } + } + } + r.hoverData.draggingEles = true; + draggedElements.silentShift(totalShift).emit('position drag'); + r.redrawHint('drag', true); + r.redraw(); + } + } else { + // otherwise save drag delta for when we actually start dragging so the relative grab pos is constant + updateDragDelta(); + } + } + + // prevent the dragging from triggering text selection on the page + preventDefault = true; + } + select[2] = pos[0]; + select[3] = pos[1]; + if (preventDefault) { + if (e.stopPropagation) e.stopPropagation(); + if (e.preventDefault) e.preventDefault(); + return false; + } + }, false); + var clickTimeout, didDoubleClick, prevClickTimeStamp; + r.registerBinding(containerWindow, 'mouseup', function mouseupHandler(e) { + // eslint-disable-line no-undef + var capture = r.hoverData.capture; + if (!capture) { + return; + } + r.hoverData.capture = false; + var cy = r.cy; + var pos = r.projectIntoViewport(e.clientX, e.clientY); + var select = r.selection; + var near = r.findNearestElement(pos[0], pos[1], true, false); + var draggedElements = r.dragData.possibleDragElements; + var down = r.hoverData.down; + var multSelKeyDown = isMultSelKeyDown(e); + if (r.data.bgActivePosistion) { + r.redrawHint('select', true); + r.redraw(); + } + r.hoverData.tapholdCancelled = true; + r.data.bgActivePosistion = undefined; // not active bg now + + if (down) { + down.unactivate(); + } + if (r.hoverData.which === 3) { + var cxtEvt = { + originalEvent: e, + type: 'cxttapend', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + if (!r.hoverData.cxtDragged) { + var cxtTap = { + originalEvent: e, + type: 'cxttap', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtTap); + } else { + cy.emit(cxtTap); + } + } + r.hoverData.cxtDragged = false; + r.hoverData.which = null; + } else if (r.hoverData.which === 1) { + triggerEvents(near, ['mouseup', 'tapend', 'vmouseup'], e, { + x: pos[0], + y: pos[1] + }); + if (!r.dragData.didDrag && + // didn't move a node around + !r.hoverData.dragged && + // didn't pan + !r.hoverData.selecting && + // not box selection + !r.hoverData.isOverThresholdDrag // didn't move too much + ) { + triggerEvents(down, ["click", "tap", "vclick"], e, { + x: pos[0], + y: pos[1] + }); + didDoubleClick = false; + if (e.timeStamp - prevClickTimeStamp <= cy.multiClickDebounceTime()) { + clickTimeout && clearTimeout(clickTimeout); + didDoubleClick = true; + prevClickTimeStamp = null; + triggerEvents(down, ["dblclick", "dbltap", "vdblclick"], e, { + x: pos[0], + y: pos[1] + }); + } else { + clickTimeout = setTimeout(function () { + if (didDoubleClick) return; + triggerEvents(down, ["oneclick", "onetap", "voneclick"], e, { + x: pos[0], + y: pos[1] + }); + }, cy.multiClickDebounceTime()); + prevClickTimeStamp = e.timeStamp; + } + } + + // Deselect all elements if nothing is currently under the mouse cursor and we aren't dragging something + if (down == null // not mousedown on node + && !r.dragData.didDrag // didn't move the node around + && !r.hoverData.selecting // not box selection + && !r.hoverData.dragged // didn't pan + && !isMultSelKeyDown(e)) { + cy.$(isSelected).unselect(['tapunselect']); + if (draggedElements.length > 0) { + r.redrawHint('eles', true); + } + r.dragData.possibleDragElements = draggedElements = cy.collection(); + } + + // Single selection + if (near == down && !r.dragData.didDrag && !r.hoverData.selecting) { + if (near != null && near._private.selectable) { + if (r.hoverData.dragging) ; else if (cy.selectionType() === 'additive' || multSelKeyDown) { + if (near.selected()) { + near.unselect(['tapunselect']); + } else { + near.select(['tapselect']); + } + } else { + if (!multSelKeyDown) { + cy.$(isSelected).unmerge(near).unselect(['tapunselect']); + near.select(['tapselect']); + } + } + r.redrawHint('eles', true); + } + } + if (r.hoverData.selecting) { + var box = cy.collection(r.getAllInBox(select[0], select[1], select[2], select[3])); + r.redrawHint('select', true); + if (box.length > 0) { + r.redrawHint('eles', true); + } + cy.emit({ + type: 'boxend', + originalEvent: e, + position: { + x: pos[0], + y: pos[1] + } + }); + var eleWouldBeSelected = function eleWouldBeSelected(ele) { + return ele.selectable() && !ele.selected(); + }; + if (cy.selectionType() === 'additive') { + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + } else { + if (!multSelKeyDown) { + cy.$(isSelected).unmerge(box).unselect(); + } + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + } + + // always need redraw in case eles unselectable + r.redraw(); + } + + // Cancel drag pan + if (r.hoverData.dragging) { + r.hoverData.dragging = false; + r.redrawHint('select', true); + r.redrawHint('eles', true); + r.redraw(); + } + if (!select[4]) { + r.redrawHint('drag', true); + r.redrawHint('eles', true); + var downWasGrabbed = down && down.grabbed(); + freeDraggedElements(draggedElements); + if (downWasGrabbed) { + down.emit('freeon'); + draggedElements.emit('free'); + if (r.dragData.didDrag) { + down.emit('dragfreeon'); + draggedElements.emit('dragfree'); + } + } + } + } // else not right mouse + + select[4] = 0; + r.hoverData.down = null; + r.hoverData.cxtStarted = false; + r.hoverData.draggingEles = false; + r.hoverData.selecting = false; + r.hoverData.isOverThresholdDrag = false; + r.dragData.didDrag = false; + r.hoverData.dragged = false; + r.hoverData.dragDelta = []; + r.hoverData.mdownPos = null; + r.hoverData.mdownGPos = null; + }, false); + var wheelHandler = function wheelHandler(e) { + if (r.scrollingPage) { + return; + } // while scrolling, ignore wheel-to-zoom + + var cy = r.cy; + var zoom = cy.zoom(); + var pan = cy.pan(); + var pos = r.projectIntoViewport(e.clientX, e.clientY); + var rpos = [pos[0] * zoom + pan.x, pos[1] * zoom + pan.y]; + if (r.hoverData.draggingEles || r.hoverData.dragging || r.hoverData.cxtStarted || inBoxSelection()) { + // if pan dragging or cxt dragging, wheel movements make no zoom + e.preventDefault(); + return; + } + if (cy.panningEnabled() && cy.userPanningEnabled() && cy.zoomingEnabled() && cy.userZoomingEnabled()) { + e.preventDefault(); + r.data.wheelZooming = true; + clearTimeout(r.data.wheelTimeout); + r.data.wheelTimeout = setTimeout(function () { + r.data.wheelZooming = false; + r.redrawHint('eles', true); + r.redraw(); + }, 150); + var diff; + if (e.deltaY != null) { + diff = e.deltaY / -250; + } else if (e.wheelDeltaY != null) { + diff = e.wheelDeltaY / 1000; + } else { + diff = e.wheelDelta / 1000; + } + diff = diff * r.wheelSensitivity; + var needsWheelFix = e.deltaMode === 1; + if (needsWheelFix) { + // fixes slow wheel events on ff/linux and ff/windows + diff *= 33; + } + var newZoom = cy.zoom() * Math.pow(10, diff); + if (e.type === 'gesturechange') { + newZoom = r.gestureStartZoom * e.scale; + } + cy.zoom({ + level: newZoom, + renderedPosition: { + x: rpos[0], + y: rpos[1] + } + }); + cy.emit(e.type === 'gesturechange' ? 'pinchzoom' : 'scrollzoom'); + } + }; + + // Functions to help with whether mouse wheel should trigger zooming + // -- + r.registerBinding(r.container, 'wheel', wheelHandler, true); + + // disable nonstandard wheel events + // r.registerBinding(r.container, 'mousewheel', wheelHandler, true); + // r.registerBinding(r.container, 'DOMMouseScroll', wheelHandler, true); + // r.registerBinding(r.container, 'MozMousePixelScroll', wheelHandler, true); // older firefox + + r.registerBinding(containerWindow, 'scroll', function scrollHandler(e) { + // eslint-disable-line no-unused-vars + r.scrollingPage = true; + clearTimeout(r.scrollingPageTimeout); + r.scrollingPageTimeout = setTimeout(function () { + r.scrollingPage = false; + }, 250); + }, true); + + // desktop safari pinch to zoom start + r.registerBinding(r.container, 'gesturestart', function gestureStartHandler(e) { + r.gestureStartZoom = r.cy.zoom(); + if (!r.hasTouchStarted) { + // don't affect touch devices like iphone + e.preventDefault(); + } + }, true); + r.registerBinding(r.container, 'gesturechange', function (e) { + if (!r.hasTouchStarted) { + // don't affect touch devices like iphone + wheelHandler(e); + } + }, true); + + // Functions to help with handling mouseout/mouseover on the Cytoscape container + // Handle mouseout on Cytoscape container + r.registerBinding(r.container, 'mouseout', function mouseOutHandler(e) { + var pos = r.projectIntoViewport(e.clientX, e.clientY); + r.cy.emit({ + originalEvent: e, + type: 'mouseout', + position: { + x: pos[0], + y: pos[1] + } + }); + }, false); + r.registerBinding(r.container, 'mouseover', function mouseOverHandler(e) { + var pos = r.projectIntoViewport(e.clientX, e.clientY); + r.cy.emit({ + originalEvent: e, + type: 'mouseover', + position: { + x: pos[0], + y: pos[1] + } + }); + }, false); + var f1x1, f1y1, f2x1, f2y1; // starting points for pinch-to-zoom + var distance1, distance1Sq; // initial distance between finger 1 and finger 2 for pinch-to-zoom + var center1, modelCenter1; // center point on start pinch to zoom + var offsetLeft, offsetTop; + var containerWidth, containerHeight; + var twoFingersStartInside; + var distance = function distance(x1, y1, x2, y2) { + return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + }; + var distanceSq = function distanceSq(x1, y1, x2, y2) { + return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); + }; + var touchstartHandler; + r.registerBinding(r.container, 'touchstart', touchstartHandler = function touchstartHandler(e) { + r.hasTouchStarted = true; + if (!eventInContainer(e)) { + return; + } + blurActiveDomElement(); + r.touchData.capture = true; + r.data.bgActivePosistion = undefined; + var cy = r.cy; + var now = r.touchData.now; + var earlier = r.touchData.earlier; + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + + // record starting points for pinch-to-zoom + if (e.touches[1]) { + r.touchData.singleTouchMoved = true; + freeDraggedElements(r.dragData.touchDragEles); + var offsets = r.findContainerClientCoords(); + offsetLeft = offsets[0]; + offsetTop = offsets[1]; + containerWidth = offsets[2]; + containerHeight = offsets[3]; + f1x1 = e.touches[0].clientX - offsetLeft; + f1y1 = e.touches[0].clientY - offsetTop; + f2x1 = e.touches[1].clientX - offsetLeft; + f2y1 = e.touches[1].clientY - offsetTop; + twoFingersStartInside = 0 <= f1x1 && f1x1 <= containerWidth && 0 <= f2x1 && f2x1 <= containerWidth && 0 <= f1y1 && f1y1 <= containerHeight && 0 <= f2y1 && f2y1 <= containerHeight; + var pan = cy.pan(); + var zoom = cy.zoom(); + distance1 = distance(f1x1, f1y1, f2x1, f2y1); + distance1Sq = distanceSq(f1x1, f1y1, f2x1, f2y1); + center1 = [(f1x1 + f2x1) / 2, (f1y1 + f2y1) / 2]; + modelCenter1 = [(center1[0] - pan.x) / zoom, (center1[1] - pan.y) / zoom]; + + // consider context tap + var cxtDistThreshold = 200; + var cxtDistThresholdSq = cxtDistThreshold * cxtDistThreshold; + if (distance1Sq < cxtDistThresholdSq && !e.touches[2]) { + var near1 = r.findNearestElement(now[0], now[1], true, true); + var near2 = r.findNearestElement(now[2], now[3], true, true); + if (near1 && near1.isNode()) { + near1.activate().emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + r.touchData.start = near1; + } else if (near2 && near2.isNode()) { + near2.activate().emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + r.touchData.start = near2; + } else { + cy.emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxt = true; + r.touchData.cxtDragged = false; + r.data.bgActivePosistion = undefined; + r.redraw(); + return; + } + } + if (e.touches[2]) { + // ignore + + // safari on ios pans the page otherwise (normally you should be able to preventdefault on touchmove...) + if (cy.boxSelectionEnabled()) { + e.preventDefault(); + } + } else if (e.touches[1]) ; else if (e.touches[0]) { + var nears = r.findNearestElements(now[0], now[1], true, true); + var near = nears[0]; + if (near != null) { + near.activate(); + r.touchData.start = near; + r.touchData.starts = nears; + if (r.nodeIsGrabbable(near)) { + var draggedEles = r.dragData.touchDragEles = cy.collection(); + var selectedNodes = null; + r.redrawHint('eles', true); + r.redrawHint('drag', true); + if (near.selected()) { + // reset drag elements, since near will be added again + + selectedNodes = cy.$(function (ele) { + return ele.selected() && r.nodeIsGrabbable(ele); + }); + addNodesToDrag(selectedNodes, { + addToList: draggedEles + }); + } else { + addNodeToDrag(near, { + addToList: draggedEles + }); + } + setGrabTarget(near); + var makeEvent = function makeEvent(type) { + return { + originalEvent: e, + type: type, + position: { + x: now[0], + y: now[1] + } + }; + }; + near.emit(makeEvent('grabon')); + if (selectedNodes) { + selectedNodes.forEach(function (n) { + n.emit(makeEvent('grab')); + }); + } else { + near.emit(makeEvent('grab')); + } + } + } + triggerEvents(near, ['touchstart', 'tapstart', 'vmousedown'], e, { + x: now[0], + y: now[1] + }); + if (near == null) { + r.data.bgActivePosistion = { + x: pos[0], + y: pos[1] + }; + r.redrawHint('select', true); + r.redraw(); + } + + // Tap, taphold + // ----- + + r.touchData.singleTouchMoved = false; + r.touchData.singleTouchStartTime = +new Date(); + clearTimeout(r.touchData.tapholdTimeout); + r.touchData.tapholdTimeout = setTimeout(function () { + if (r.touchData.singleTouchMoved === false && !r.pinching // if pinching, then taphold unselect shouldn't take effect + && !r.touchData.selecting // box selection shouldn't allow taphold through + ) { + triggerEvents(r.touchData.start, ['taphold'], e, { + x: now[0], + y: now[1] + }); + } + }, r.tapholdDuration); + } + if (e.touches.length >= 1) { + var sPos = r.touchData.startPosition = [null, null, null, null, null, null]; + for (var i = 0; i < now.length; i++) { + sPos[i] = earlier[i] = now[i]; + } + var touch0 = e.touches[0]; + r.touchData.startGPosition = [touch0.clientX, touch0.clientY]; + } + }, false); + var touchmoveHandler; + r.registerBinding(window, 'touchmove', touchmoveHandler = function touchmoveHandler(e) { + // eslint-disable-line no-undef + var capture = r.touchData.capture; + if (!capture && !eventInContainer(e)) { + return; + } + var select = r.selection; + var cy = r.cy; + var now = r.touchData.now; + var earlier = r.touchData.earlier; + var zoom = cy.zoom(); + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + var startGPos = r.touchData.startGPosition; + var isOverThresholdDrag; + if (capture && e.touches[0] && startGPos) { + var disp = []; + for (var j = 0; j < now.length; j++) { + disp[j] = now[j] - earlier[j]; + } + var dx = e.touches[0].clientX - startGPos[0]; + var dx2 = dx * dx; + var dy = e.touches[0].clientY - startGPos[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + isOverThresholdDrag = dist2 >= r.touchTapThreshold2; + } + + // context swipe cancelling + if (capture && r.touchData.cxt) { + e.preventDefault(); + var f1x2 = e.touches[0].clientX - offsetLeft, + f1y2 = e.touches[0].clientY - offsetTop; + var f2x2 = e.touches[1].clientX - offsetLeft, + f2y2 = e.touches[1].clientY - offsetTop; + // var distance2 = distance( f1x2, f1y2, f2x2, f2y2 ); + var distance2Sq = distanceSq(f1x2, f1y2, f2x2, f2y2); + var factorSq = distance2Sq / distance1Sq; + var distThreshold = 150; + var distThresholdSq = distThreshold * distThreshold; + var factorThreshold = 1.5; + var factorThresholdSq = factorThreshold * factorThreshold; + + // cancel ctx gestures if the distance b/t the fingers increases + if (factorSq >= factorThresholdSq || distance2Sq >= distThresholdSq) { + r.touchData.cxt = false; + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var cxtEvt = { + originalEvent: e, + type: 'cxttapend', + position: { + x: now[0], + y: now[1] + } + }; + if (r.touchData.start) { + r.touchData.start.unactivate().emit(cxtEvt); + r.touchData.start = null; + } else { + cy.emit(cxtEvt); + } + } + } + + // context swipe + if (capture && r.touchData.cxt) { + var cxtEvt = { + originalEvent: e, + type: 'cxtdrag', + position: { + x: now[0], + y: now[1] + } + }; + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + if (r.touchData.start) { + r.touchData.start.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxtDragged = true; + var near = r.findNearestElement(now[0], now[1], true, true); + if (!r.touchData.cxtOver || near !== r.touchData.cxtOver) { + if (r.touchData.cxtOver) { + r.touchData.cxtOver.emit({ + originalEvent: e, + type: 'cxtdragout', + position: { + x: now[0], + y: now[1] + } + }); + } + r.touchData.cxtOver = near; + if (near) { + near.emit({ + originalEvent: e, + type: 'cxtdragover', + position: { + x: now[0], + y: now[1] + } + }); + } + } + + // box selection + } else if (capture && e.touches[2] && cy.boxSelectionEnabled()) { + e.preventDefault(); + r.data.bgActivePosistion = undefined; + this.lastThreeTouch = +new Date(); + if (!r.touchData.selecting) { + cy.emit({ + originalEvent: e, + type: 'boxstart', + position: { + x: now[0], + y: now[1] + } + }); + } + r.touchData.selecting = true; + r.touchData.didSelect = true; + select[4] = 1; + if (!select || select.length === 0 || select[0] === undefined) { + select[0] = (now[0] + now[2] + now[4]) / 3; + select[1] = (now[1] + now[3] + now[5]) / 3; + select[2] = (now[0] + now[2] + now[4]) / 3 + 1; + select[3] = (now[1] + now[3] + now[5]) / 3 + 1; + } else { + select[2] = (now[0] + now[2] + now[4]) / 3; + select[3] = (now[1] + now[3] + now[5]) / 3; + } + r.redrawHint('select', true); + r.redraw(); + + // pinch to zoom + } else if (capture && e.touches[1] && !r.touchData.didSelect // don't allow box selection to degrade to pinch-to-zoom + && cy.zoomingEnabled() && cy.panningEnabled() && cy.userZoomingEnabled() && cy.userPanningEnabled()) { + // two fingers => pinch to zoom + e.preventDefault(); + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var draggedEles = r.dragData.touchDragEles; + if (draggedEles) { + r.redrawHint('drag', true); + for (var i = 0; i < draggedEles.length; i++) { + var de_p = draggedEles[i]._private; + de_p.grabbed = false; + de_p.rscratch.inDragLayer = false; + } + } + var _start = r.touchData.start; + + // (x2, y2) for fingers 1 and 2 + var f1x2 = e.touches[0].clientX - offsetLeft, + f1y2 = e.touches[0].clientY - offsetTop; + var f2x2 = e.touches[1].clientX - offsetLeft, + f2y2 = e.touches[1].clientY - offsetTop; + var distance2 = distance(f1x2, f1y2, f2x2, f2y2); + // var distance2Sq = distanceSq( f1x2, f1y2, f2x2, f2y2 ); + // var factor = Math.sqrt( distance2Sq ) / Math.sqrt( distance1Sq ); + var factor = distance2 / distance1; + if (twoFingersStartInside) { + // delta finger1 + var df1x = f1x2 - f1x1; + var df1y = f1y2 - f1y1; + + // delta finger 2 + var df2x = f2x2 - f2x1; + var df2y = f2y2 - f2y1; + + // translation is the normalised vector of the two fingers movement + // i.e. so pinching cancels out and moving together pans + var tx = (df1x + df2x) / 2; + var ty = (df1y + df2y) / 2; + + // now calculate the zoom + var zoom1 = cy.zoom(); + var zoom2 = zoom1 * factor; + var pan1 = cy.pan(); + + // the model center point converted to the current rendered pos + var ctrx = modelCenter1[0] * zoom1 + pan1.x; + var ctry = modelCenter1[1] * zoom1 + pan1.y; + var pan2 = { + x: -zoom2 / zoom1 * (ctrx - pan1.x - tx) + ctrx, + y: -zoom2 / zoom1 * (ctry - pan1.y - ty) + ctry + }; + + // remove dragged eles + if (_start && _start.active()) { + var draggedEles = r.dragData.touchDragEles; + freeDraggedElements(draggedEles); + r.redrawHint('drag', true); + r.redrawHint('eles', true); + _start.unactivate().emit('freeon'); + draggedEles.emit('free'); + if (r.dragData.didDrag) { + _start.emit('dragfreeon'); + draggedEles.emit('dragfree'); + } + } + cy.viewport({ + zoom: zoom2, + pan: pan2, + cancelOnFailedZoom: true + }); + cy.emit('pinchzoom'); + distance1 = distance2; + f1x1 = f1x2; + f1y1 = f1y2; + f2x1 = f2x2; + f2y1 = f2y2; + r.pinching = true; + } + + // Re-project + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + } else if (e.touches[0] && !r.touchData.didSelect // don't allow box selection to degrade to single finger events like panning + ) { + var start = r.touchData.start; + var last = r.touchData.last; + var near; + if (!r.hoverData.draggingEles && !r.swipePanning) { + near = r.findNearestElement(now[0], now[1], true, true); + } + if (capture && start != null) { + e.preventDefault(); + } + + // dragging nodes + if (capture && start != null && r.nodeIsDraggable(start)) { + if (isOverThresholdDrag) { + // then dragging can happen + var draggedEles = r.dragData.touchDragEles; + var justStartedDrag = !r.dragData.didDrag; + if (justStartedDrag) { + addNodesToDrag(draggedEles, { + inDragLayer: true + }); + } + r.dragData.didDrag = true; + var totalShift = { + x: 0, + y: 0 + }; + if (number$1(disp[0]) && number$1(disp[1])) { + totalShift.x += disp[0]; + totalShift.y += disp[1]; + if (justStartedDrag) { + r.redrawHint('eles', true); + var dragDelta = r.touchData.dragDelta; + if (dragDelta && number$1(dragDelta[0]) && number$1(dragDelta[1])) { + totalShift.x += dragDelta[0]; + totalShift.y += dragDelta[1]; + } + } + } + r.hoverData.draggingEles = true; + draggedEles.silentShift(totalShift).emit('position drag'); + r.redrawHint('drag', true); + if (r.touchData.startPosition[0] == earlier[0] && r.touchData.startPosition[1] == earlier[1]) { + r.redrawHint('eles', true); + } + r.redraw(); + } else { + // otherwise keep track of drag delta for later + var dragDelta = r.touchData.dragDelta = r.touchData.dragDelta || []; + if (dragDelta.length === 0) { + dragDelta.push(disp[0]); + dragDelta.push(disp[1]); + } else { + dragDelta[0] += disp[0]; + dragDelta[1] += disp[1]; + } + } + } + + // touchmove + { + triggerEvents(start || near, ['touchmove', 'tapdrag', 'vmousemove'], e, { + x: now[0], + y: now[1] + }); + if ((!start || !start.grabbed()) && near != last) { + if (last) { + last.emit({ + originalEvent: e, + type: 'tapdragout', + position: { + x: now[0], + y: now[1] + } + }); + } + if (near) { + near.emit({ + originalEvent: e, + type: 'tapdragover', + position: { + x: now[0], + y: now[1] + } + }); + } + } + r.touchData.last = near; + } + + // check to cancel taphold + if (capture) { + for (var i = 0; i < now.length; i++) { + if (now[i] && r.touchData.startPosition[i] && isOverThresholdDrag) { + r.touchData.singleTouchMoved = true; + } + } + } + + // panning + if (capture && (start == null || start.pannable()) && cy.panningEnabled() && cy.userPanningEnabled()) { + var allowPassthrough = allowPanningPassthrough(start, r.touchData.starts); + if (allowPassthrough) { + e.preventDefault(); + if (!r.data.bgActivePosistion) { + r.data.bgActivePosistion = array2point(r.touchData.startPosition); + } + if (r.swipePanning) { + cy.panBy({ + x: disp[0] * zoom, + y: disp[1] * zoom + }); + cy.emit('dragpan'); + } else if (isOverThresholdDrag) { + r.swipePanning = true; + cy.panBy({ + x: dx * zoom, + y: dy * zoom + }); + cy.emit('dragpan'); + if (start) { + start.unactivate(); + r.redrawHint('select', true); + r.touchData.start = null; + } + } + } + + // Re-project + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + } + for (var j = 0; j < now.length; j++) { + earlier[j] = now[j]; + } + + // the active bg indicator should be removed when making a swipe that is neither for dragging nodes or panning + if (capture && e.touches.length > 0 && !r.hoverData.draggingEles && !r.swipePanning && r.data.bgActivePosistion != null) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + r.redraw(); + } + }, false); + var touchcancelHandler; + r.registerBinding(containerWindow, 'touchcancel', touchcancelHandler = function touchcancelHandler(e) { + // eslint-disable-line no-unused-vars + var start = r.touchData.start; + r.touchData.capture = false; + if (start) { + start.unactivate(); + } + }); + var touchendHandler, didDoubleTouch, touchTimeout, prevTouchTimeStamp; + r.registerBinding(containerWindow, 'touchend', touchendHandler = function touchendHandler(e) { + // eslint-disable-line no-unused-vars + var start = r.touchData.start; + var capture = r.touchData.capture; + if (capture) { + if (e.touches.length === 0) { + r.touchData.capture = false; + } + e.preventDefault(); + } else { + return; + } + var select = r.selection; + r.swipePanning = false; + r.hoverData.draggingEles = false; + var cy = r.cy; + var zoom = cy.zoom(); + var now = r.touchData.now; + var earlier = r.touchData.earlier; + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + if (start) { + start.unactivate(); + } + var ctxTapend; + if (r.touchData.cxt) { + ctxTapend = { + originalEvent: e, + type: 'cxttapend', + position: { + x: now[0], + y: now[1] + } + }; + if (start) { + start.emit(ctxTapend); + } else { + cy.emit(ctxTapend); + } + if (!r.touchData.cxtDragged) { + var ctxTap = { + originalEvent: e, + type: 'cxttap', + position: { + x: now[0], + y: now[1] + } + }; + if (start) { + start.emit(ctxTap); + } else { + cy.emit(ctxTap); + } + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxt = false; + r.touchData.start = null; + r.redraw(); + return; + } + + // no more box selection if we don't have three fingers + if (!e.touches[2] && cy.boxSelectionEnabled() && r.touchData.selecting) { + r.touchData.selecting = false; + var box = cy.collection(r.getAllInBox(select[0], select[1], select[2], select[3])); + select[0] = undefined; + select[1] = undefined; + select[2] = undefined; + select[3] = undefined; + select[4] = 0; + r.redrawHint('select', true); + cy.emit({ + type: 'boxend', + originalEvent: e, + position: { + x: now[0], + y: now[1] + } + }); + var eleWouldBeSelected = function eleWouldBeSelected(ele) { + return ele.selectable() && !ele.selected(); + }; + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + if (box.nonempty()) { + r.redrawHint('eles', true); + } + r.redraw(); + } + if (start != null) { + start.unactivate(); + } + if (e.touches[2]) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + } else if (e.touches[1]) ; else if (e.touches[0]) ; else if (!e.touches[0]) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var draggedEles = r.dragData.touchDragEles; + if (start != null) { + var startWasGrabbed = start._private.grabbed; + freeDraggedElements(draggedEles); + r.redrawHint('drag', true); + r.redrawHint('eles', true); + if (startWasGrabbed) { + start.emit('freeon'); + draggedEles.emit('free'); + if (r.dragData.didDrag) { + start.emit('dragfreeon'); + draggedEles.emit('dragfree'); + } + } + triggerEvents(start, ['touchend', 'tapend', 'vmouseup', 'tapdragout'], e, { + x: now[0], + y: now[1] + }); + start.unactivate(); + r.touchData.start = null; + } else { + var near = r.findNearestElement(now[0], now[1], true, true); + triggerEvents(near, ['touchend', 'tapend', 'vmouseup', 'tapdragout'], e, { + x: now[0], + y: now[1] + }); + } + var dx = r.touchData.startPosition[0] - now[0]; + var dx2 = dx * dx; + var dy = r.touchData.startPosition[1] - now[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + var rdist2 = dist2 * zoom * zoom; + + // Tap event, roughly same as mouse click event for touch + if (!r.touchData.singleTouchMoved) { + if (!start) { + cy.$(':selected').unselect(['tapunselect']); + } + triggerEvents(start, ['tap', 'vclick'], e, { + x: now[0], + y: now[1] + }); + didDoubleTouch = false; + if (e.timeStamp - prevTouchTimeStamp <= cy.multiClickDebounceTime()) { + touchTimeout && clearTimeout(touchTimeout); + didDoubleTouch = true; + prevTouchTimeStamp = null; + triggerEvents(start, ['dbltap', 'vdblclick'], e, { + x: now[0], + y: now[1] + }); + } else { + touchTimeout = setTimeout(function () { + if (didDoubleTouch) return; + triggerEvents(start, ['onetap', 'voneclick'], e, { + x: now[0], + y: now[1] + }); + }, cy.multiClickDebounceTime()); + prevTouchTimeStamp = e.timeStamp; + } + } + + // Prepare to select the currently touched node, only if it hasn't been dragged past a certain distance + if (start != null && !r.dragData.didDrag // didn't drag nodes around + && start._private.selectable && rdist2 < r.touchTapThreshold2 && !r.pinching // pinch to zoom should not affect selection + ) { + if (cy.selectionType() === 'single') { + cy.$(isSelected).unmerge(start).unselect(['tapunselect']); + start.select(['tapselect']); + } else { + if (start.selected()) { + start.unselect(['tapunselect']); + } else { + start.select(['tapselect']); + } + } + r.redrawHint('eles', true); + } + r.touchData.singleTouchMoved = true; + } + for (var j = 0; j < now.length; j++) { + earlier[j] = now[j]; + } + r.dragData.didDrag = false; // reset for next touchstart + + if (e.touches.length === 0) { + r.touchData.dragDelta = []; + r.touchData.startPosition = [null, null, null, null, null, null]; + r.touchData.startGPosition = null; + r.touchData.didSelect = false; + } + if (e.touches.length < 2) { + if (e.touches.length === 1) { + // the old start global pos'n may not be the same finger that remains + r.touchData.startGPosition = [e.touches[0].clientX, e.touches[0].clientY]; + } + r.pinching = false; + r.redrawHint('eles', true); + r.redraw(); + } + + //r.redraw(); + }, false); + + // fallback compatibility layer for ms pointer events + if (typeof TouchEvent === 'undefined') { + var pointers = []; + var makeTouch = function makeTouch(e) { + return { + clientX: e.clientX, + clientY: e.clientY, + force: 1, + identifier: e.pointerId, + pageX: e.pageX, + pageY: e.pageY, + radiusX: e.width / 2, + radiusY: e.height / 2, + screenX: e.screenX, + screenY: e.screenY, + target: e.target + }; + }; + var makePointer = function makePointer(e) { + return { + event: e, + touch: makeTouch(e) + }; + }; + var addPointer = function addPointer(e) { + pointers.push(makePointer(e)); + }; + var removePointer = function removePointer(e) { + for (var i = 0; i < pointers.length; i++) { + var p = pointers[i]; + if (p.event.pointerId === e.pointerId) { + pointers.splice(i, 1); + return; + } + } + }; + var updatePointer = function updatePointer(e) { + var p = pointers.filter(function (p) { + return p.event.pointerId === e.pointerId; + })[0]; + p.event = e; + p.touch = makeTouch(e); + }; + var addTouchesToEvent = function addTouchesToEvent(e) { + e.touches = pointers.map(function (p) { + return p.touch; + }); + }; + var pointerIsMouse = function pointerIsMouse(e) { + return e.pointerType === 'mouse' || e.pointerType === 4; + }; + r.registerBinding(r.container, 'pointerdown', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + e.preventDefault(); + addPointer(e); + addTouchesToEvent(e); + touchstartHandler(e); + }); + r.registerBinding(r.container, 'pointerup', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + removePointer(e); + addTouchesToEvent(e); + touchendHandler(e); + }); + r.registerBinding(r.container, 'pointercancel', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + removePointer(e); + addTouchesToEvent(e); + touchcancelHandler(e); + }); + r.registerBinding(r.container, 'pointermove', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + e.preventDefault(); + updatePointer(e); + addTouchesToEvent(e); + touchmoveHandler(e); + }); + } +}; + +var BRp$2 = {}; +BRp$2.generatePolygon = function (name, points) { + return this.nodeShapes[name] = { + renderer: this, + name: name, + points: points, + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl('polygon', context, centerX, centerY, width, height, this.points); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return polygonIntersectLine(x, y, this.points, nodeX, nodeY, width / 2, height / 2, padding); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + return pointInsidePolygon(x, y, this.points, centerX, centerY, width, height, [0, -1], padding); + } + }; +}; +BRp$2.generateEllipse = function () { + return this.nodeShapes['ellipse'] = { + renderer: this, + name: 'ellipse', + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return intersectLineEllipse(x, y, nodeX, nodeY, width / 2 + padding, height / 2 + padding); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + return checkInEllipse(x, y, width, height, centerX, centerY, padding); + } + }; +}; +BRp$2.generateRoundPolygon = function (name, points) { + return this.nodeShapes[name] = { + renderer: this, + name: name, + points: points, + getOrCreateCorners: function getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, field) { + if (rs[field] !== undefined && rs[field + '-cx'] === centerX && rs[field + '-cy'] === centerY) { + return rs[field]; + } + rs[field] = new Array(points.length / 2); + rs[field + '-cx'] = centerX; + rs[field + '-cy'] = centerY; + var halfW = width / 2; + var halfH = height / 2; + cornerRadius = cornerRadius === 'auto' ? getRoundPolygonRadius(width, height) : cornerRadius; + var p = new Array(points.length / 2); + for (var _i = 0; _i < points.length / 2; _i++) { + p[_i] = { + x: centerX + halfW * points[_i * 2], + y: centerY + halfH * points[_i * 2 + 1] + }; + } + var i, + p1, + p2, + p3, + len = p.length; + p1 = p[len - 1]; + // for each point + for (i = 0; i < len; i++) { + p2 = p[i % len]; + p3 = p[(i + 1) % len]; + rs[field][i] = getRoundCorner(p1, p2, p3, cornerRadius); + p1 = p2; + p2 = p3; + } + return rs[field]; + }, + draw: function draw(context, centerX, centerY, width, height, cornerRadius, rs) { + this.renderer.nodeShapeImpl('round-polygon', context, centerX, centerY, width, height, this.points, this.getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, 'drawCorners')); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius, rs) { + return roundPolygonIntersectLine(x, y, this.points, nodeX, nodeY, width, height, padding, this.getOrCreateCorners(nodeX, nodeY, width, height, cornerRadius, rs, 'corners')); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius, rs) { + return pointInsideRoundPolygon(x, y, this.points, centerX, centerY, width, height, this.getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, 'corners')); + } + }; +}; +BRp$2.generateRoundRectangle = function () { + return this.nodeShapes['round-rectangle'] = this.nodeShapes['roundrectangle'] = { + renderer: this, + name: 'round-rectangle', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, this.points, cornerRadius); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding, cornerRadius); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(width, height) : cornerRadius; + cornerRadius = Math.min(halfWidth, halfHeight, cornerRadius); + var diam = cornerRadius * 2; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - diam, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - diam, height, [0, -1], padding)) { + return true; + } + + // Check top left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - halfWidth + cornerRadius, centerY - halfHeight + cornerRadius, padding)) { + return true; + } + + // Check top right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + halfWidth - cornerRadius, centerY - halfHeight + cornerRadius, padding)) { + return true; + } + + // Check bottom right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + halfWidth - cornerRadius, centerY + halfHeight - cornerRadius, padding)) { + return true; + } + + // Check bottom left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - halfWidth + cornerRadius, centerY + halfHeight - cornerRadius, padding)) { + return true; + } + return false; + } + }; +}; +BRp$2.generateCutRectangle = function () { + return this.nodeShapes['cut-rectangle'] = this.nodeShapes['cutrectangle'] = { + renderer: this, + name: 'cut-rectangle', + cornerLength: getCutRectangleCornerLength(), + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, null, cornerRadius); + }, + generateCutTrianglePts: function generateCutTrianglePts(width, height, centerX, centerY, cornerRadius) { + var cl = cornerRadius === 'auto' ? this.cornerLength : cornerRadius; + var hh = height / 2; + var hw = width / 2; + var xBegin = centerX - hw; + var xEnd = centerX + hw; + var yBegin = centerY - hh; + var yEnd = centerY + hh; + + // points are in clockwise order, inner (imaginary) triangle pt on [4, 5] + return { + topLeft: [xBegin, yBegin + cl, xBegin + cl, yBegin, xBegin + cl, yBegin + cl], + topRight: [xEnd - cl, yBegin, xEnd, yBegin + cl, xEnd - cl, yBegin + cl], + bottomRight: [xEnd, yEnd - cl, xEnd - cl, yEnd, xEnd - cl, yEnd - cl], + bottomLeft: [xBegin + cl, yEnd, xBegin, yEnd - cl, xBegin + cl, yEnd - cl] + }; + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + var cPts = this.generateCutTrianglePts(width + 2 * padding, height + 2 * padding, nodeX, nodeY, cornerRadius); + var pts = [].concat.apply([], [cPts.topLeft.splice(0, 4), cPts.topRight.splice(0, 4), cPts.bottomRight.splice(0, 4), cPts.bottomLeft.splice(0, 4)]); + return polygonIntersectLine(x, y, pts, nodeX, nodeY); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var cl = cornerRadius === 'auto' ? this.cornerLength : cornerRadius; + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - 2 * cl, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - 2 * cl, height, [0, -1], padding)) { + return true; + } + var cutTrianglePts = this.generateCutTrianglePts(width, height, centerX, centerY); + return pointInsidePolygonPoints(x, y, cutTrianglePts.topLeft) || pointInsidePolygonPoints(x, y, cutTrianglePts.topRight) || pointInsidePolygonPoints(x, y, cutTrianglePts.bottomRight) || pointInsidePolygonPoints(x, y, cutTrianglePts.bottomLeft); + } + }; +}; +BRp$2.generateBarrel = function () { + return this.nodeShapes['barrel'] = { + renderer: this, + name: 'barrel', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + // use two fixed t values for the bezier curve approximation + + var t0 = 0.15; + var t1 = 0.5; + var t2 = 0.85; + var bPts = this.generateBarrelBezierPts(width + 2 * padding, height + 2 * padding, nodeX, nodeY); + var approximateBarrelCurvePts = function approximateBarrelCurvePts(pts) { + // approximate curve pts based on the two t values + var m0 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t0); + var m1 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t1); + var m2 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t2); + return [pts[0], pts[1], m0.x, m0.y, m1.x, m1.y, m2.x, m2.y, pts[4], pts[5]]; + }; + var pts = [].concat(approximateBarrelCurvePts(bPts.topLeft), approximateBarrelCurvePts(bPts.topRight), approximateBarrelCurvePts(bPts.bottomRight), approximateBarrelCurvePts(bPts.bottomLeft)); + return polygonIntersectLine(x, y, pts, nodeX, nodeY); + }, + generateBarrelBezierPts: function generateBarrelBezierPts(width, height, centerX, centerY) { + var hh = height / 2; + var hw = width / 2; + var xBegin = centerX - hw; + var xEnd = centerX + hw; + var yBegin = centerY - hh; + var yEnd = centerY + hh; + var curveConstants = getBarrelCurveConstants(width, height); + var hOffset = curveConstants.heightOffset; + var wOffset = curveConstants.widthOffset; + var ctrlPtXOffset = curveConstants.ctrlPtOffsetPct * width; + + // points are in clockwise order, inner (imaginary) control pt on [4, 5] + var pts = { + topLeft: [xBegin, yBegin + hOffset, xBegin + ctrlPtXOffset, yBegin, xBegin + wOffset, yBegin], + topRight: [xEnd - wOffset, yBegin, xEnd - ctrlPtXOffset, yBegin, xEnd, yBegin + hOffset], + bottomRight: [xEnd, yEnd - hOffset, xEnd - ctrlPtXOffset, yEnd, xEnd - wOffset, yEnd], + bottomLeft: [xBegin + wOffset, yEnd, xBegin + ctrlPtXOffset, yEnd, xBegin, yEnd - hOffset] + }; + pts.topLeft.isTop = true; + pts.topRight.isTop = true; + pts.bottomLeft.isBottom = true; + pts.bottomRight.isBottom = true; + return pts; + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var curveConstants = getBarrelCurveConstants(width, height); + var hOffset = curveConstants.heightOffset; + var wOffset = curveConstants.widthOffset; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - 2 * hOffset, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - 2 * wOffset, height, [0, -1], padding)) { + return true; + } + var barrelCurvePts = this.generateBarrelBezierPts(width, height, centerX, centerY); + var getCurveT = function getCurveT(x, y, curvePts) { + var x0 = curvePts[4]; + var x1 = curvePts[2]; + var x2 = curvePts[0]; + var y0 = curvePts[5]; + // var y1 = curvePts[ 3 ]; + var y2 = curvePts[1]; + var xMin = Math.min(x0, x2); + var xMax = Math.max(x0, x2); + var yMin = Math.min(y0, y2); + var yMax = Math.max(y0, y2); + if (xMin <= x && x <= xMax && yMin <= y && y <= yMax) { + var coeff = bezierPtsToQuadCoeff(x0, x1, x2); + var roots = solveQuadratic(coeff[0], coeff[1], coeff[2], x); + var validRoots = roots.filter(function (r) { + return 0 <= r && r <= 1; + }); + if (validRoots.length > 0) { + return validRoots[0]; + } + } + return null; + }; + var curveRegions = Object.keys(barrelCurvePts); + for (var i = 0; i < curveRegions.length; i++) { + var corner = curveRegions[i]; + var cornerPts = barrelCurvePts[corner]; + var t = getCurveT(x, y, cornerPts); + if (t == null) { + continue; + } + var y0 = cornerPts[5]; + var y1 = cornerPts[3]; + var y2 = cornerPts[1]; + var bezY = qbezierAt(y0, y1, y2, t); + if (cornerPts.isTop && bezY <= y) { + return true; + } + if (cornerPts.isBottom && y <= bezY) { + return true; + } + } + return false; + } + }; +}; +BRp$2.generateBottomRoundrectangle = function () { + return this.nodeShapes['bottom-round-rectangle'] = this.nodeShapes['bottomroundrectangle'] = { + renderer: this, + name: 'bottom-round-rectangle', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, this.points, cornerRadius); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + var topStartX = nodeX - (width / 2 + padding); + var topStartY = nodeY - (height / 2 + padding); + var topEndY = topStartY; + var topEndX = nodeX + (width / 2 + padding); + var topIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false); + if (topIntersections.length > 0) { + return topIntersections; + } + return roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding, cornerRadius); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(width, height) : cornerRadius; + var diam = 2 * cornerRadius; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - diam, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - diam, height, [0, -1], padding)) { + return true; + } + + // check non-rounded top side + var outerWidth = width / 2 + 2 * padding; + var outerHeight = height / 2 + 2 * padding; + var points = [centerX - outerWidth, centerY - outerHeight, centerX - outerWidth, centerY, centerX + outerWidth, centerY, centerX + outerWidth, centerY - outerHeight]; + if (pointInsidePolygonPoints(x, y, points)) { + return true; + } + + // Check bottom right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + width / 2 - cornerRadius, centerY + height / 2 - cornerRadius, padding)) { + return true; + } + + // Check bottom left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - width / 2 + cornerRadius, centerY + height / 2 - cornerRadius, padding)) { + return true; + } + return false; + } + }; +}; +BRp$2.registerNodeShapes = function () { + var nodeShapes = this.nodeShapes = {}; + var renderer = this; + this.generateEllipse(); + this.generatePolygon('triangle', generateUnitNgonPointsFitToSquare(3, 0)); + this.generateRoundPolygon('round-triangle', generateUnitNgonPointsFitToSquare(3, 0)); + this.generatePolygon('rectangle', generateUnitNgonPointsFitToSquare(4, 0)); + nodeShapes['square'] = nodeShapes['rectangle']; + this.generateRoundRectangle(); + this.generateCutRectangle(); + this.generateBarrel(); + this.generateBottomRoundrectangle(); + { + var diamondPoints = [0, 1, 1, 0, 0, -1, -1, 0]; + this.generatePolygon('diamond', diamondPoints); + this.generateRoundPolygon('round-diamond', diamondPoints); + } + this.generatePolygon('pentagon', generateUnitNgonPointsFitToSquare(5, 0)); + this.generateRoundPolygon('round-pentagon', generateUnitNgonPointsFitToSquare(5, 0)); + this.generatePolygon('hexagon', generateUnitNgonPointsFitToSquare(6, 0)); + this.generateRoundPolygon('round-hexagon', generateUnitNgonPointsFitToSquare(6, 0)); + this.generatePolygon('heptagon', generateUnitNgonPointsFitToSquare(7, 0)); + this.generateRoundPolygon('round-heptagon', generateUnitNgonPointsFitToSquare(7, 0)); + this.generatePolygon('octagon', generateUnitNgonPointsFitToSquare(8, 0)); + this.generateRoundPolygon('round-octagon', generateUnitNgonPointsFitToSquare(8, 0)); + var star5Points = new Array(20); + { + var outerPoints = generateUnitNgonPoints(5, 0); + var innerPoints = generateUnitNgonPoints(5, Math.PI / 5); + + // Outer radius is 1; inner radius of star is smaller + var innerRadius = 0.5 * (3 - Math.sqrt(5)); + innerRadius *= 1.57; + for (var i = 0; i < innerPoints.length / 2; i++) { + innerPoints[i * 2] *= innerRadius; + innerPoints[i * 2 + 1] *= innerRadius; + } + for (var i = 0; i < 20 / 4; i++) { + star5Points[i * 4] = outerPoints[i * 2]; + star5Points[i * 4 + 1] = outerPoints[i * 2 + 1]; + star5Points[i * 4 + 2] = innerPoints[i * 2]; + star5Points[i * 4 + 3] = innerPoints[i * 2 + 1]; + } + } + star5Points = fitPolygonToSquare(star5Points); + this.generatePolygon('star', star5Points); + this.generatePolygon('vee', [-1, -1, 0, -0.333, 1, -1, 0, 1]); + this.generatePolygon('rhomboid', [-1, -1, 0.333, -1, 1, 1, -0.333, 1]); + this.generatePolygon('right-rhomboid', [-0.333, -1, 1, -1, 0.333, 1, -1, 1]); + this.nodeShapes['concavehexagon'] = this.generatePolygon('concave-hexagon', [-1, -0.95, -0.75, 0, -1, 0.95, 1, 0.95, 0.75, 0, 1, -0.95]); + { + var tagPoints = [-1, -1, 0.25, -1, 1, 0, 0.25, 1, -1, 1]; + this.generatePolygon('tag', tagPoints); + this.generateRoundPolygon('round-tag', tagPoints); + } + nodeShapes.makePolygon = function (points) { + // use caching on user-specified polygons so they are as fast as native shapes + + var key = points.join('$'); + var name = 'polygon-' + key; + var shape; + if (shape = this[name]) { + // got cached shape + return shape; + } + + // create and cache new shape + return renderer.generatePolygon(name, points); + }; +}; + +var BRp$1 = {}; +BRp$1.timeToRender = function () { + return this.redrawTotalTime / this.redrawCount; +}; +BRp$1.redraw = function (options) { + options = options || staticEmptyObject(); + var r = this; + if (r.averageRedrawTime === undefined) { + r.averageRedrawTime = 0; + } + if (r.lastRedrawTime === undefined) { + r.lastRedrawTime = 0; + } + if (r.lastDrawTime === undefined) { + r.lastDrawTime = 0; + } + r.requestedFrame = true; + r.renderOptions = options; +}; +BRp$1.beforeRender = function (fn, priority) { + // the renderer can't add tick callbacks when destroyed + if (this.destroyed) { + return; + } + if (priority == null) { + error('Priority is not optional for beforeRender'); + } + var cbs = this.beforeRenderCallbacks; + cbs.push({ + fn: fn, + priority: priority + }); + + // higher priority callbacks executed first + cbs.sort(function (a, b) { + return b.priority - a.priority; + }); +}; +var beforeRenderCallbacks = function beforeRenderCallbacks(r, willDraw, startTime) { + var cbs = r.beforeRenderCallbacks; + for (var i = 0; i < cbs.length; i++) { + cbs[i].fn(willDraw, startTime); + } +}; +BRp$1.startRenderLoop = function () { + var r = this; + var cy = r.cy; + if (r.renderLoopStarted) { + return; + } else { + r.renderLoopStarted = true; + } + var renderFn = function renderFn(requestTime) { + if (r.destroyed) { + return; + } + if (cy.batching()) ; else if (r.requestedFrame && !r.skipFrame) { + beforeRenderCallbacks(r, true, requestTime); + var startTime = performanceNow(); + r.render(r.renderOptions); + var endTime = r.lastDrawTime = performanceNow(); + if (r.averageRedrawTime === undefined) { + r.averageRedrawTime = endTime - startTime; + } + if (r.redrawCount === undefined) { + r.redrawCount = 0; + } + r.redrawCount++; + if (r.redrawTotalTime === undefined) { + r.redrawTotalTime = 0; + } + var duration = endTime - startTime; + r.redrawTotalTime += duration; + r.lastRedrawTime = duration; + + // use a weighted average with a bias from the previous average so we don't spike so easily + r.averageRedrawTime = r.averageRedrawTime / 2 + duration / 2; + r.requestedFrame = false; + } else { + beforeRenderCallbacks(r, false, requestTime); + } + r.skipFrame = false; + requestAnimationFrame$1(renderFn); + }; + requestAnimationFrame$1(renderFn); +}; + +var BaseRenderer = function BaseRenderer(options) { + this.init(options); +}; +var BR = BaseRenderer; +var BRp = BR.prototype; +BRp.clientFunctions = ['redrawHint', 'render', 'renderTo', 'matchCanvasSize', 'nodeShapeImpl', 'arrowShapeImpl']; +BRp.init = function (options) { + var r = this; + r.options = options; + r.cy = options.cy; + var ctr = r.container = options.cy.container(); + var containerWindow = r.cy.window(); + + // prepend a stylesheet in the head such that + if (containerWindow) { + var document = containerWindow.document; + var head = document.head; + var stylesheetId = '__________cytoscape_stylesheet'; + var className = '__________cytoscape_container'; + var stylesheetAlreadyExists = document.getElementById(stylesheetId) != null; + if (ctr.className.indexOf(className) < 0) { + ctr.className = (ctr.className || '') + ' ' + className; + } + if (!stylesheetAlreadyExists) { + var stylesheet = document.createElement('style'); + stylesheet.id = stylesheetId; + stylesheet.textContent = '.' + className + ' { position: relative; }'; + head.insertBefore(stylesheet, head.children[0]); // first so lowest priority + } + + var computedStyle = containerWindow.getComputedStyle(ctr); + var position = computedStyle.getPropertyValue('position'); + if (position === 'static') { + warn('A Cytoscape container has style position:static and so can not use UI extensions properly'); + } + } + r.selection = [undefined, undefined, undefined, undefined, 0]; // Coordinates for selection box, plus enabled flag + + r.bezierProjPcts = [0.05, 0.225, 0.4, 0.5, 0.6, 0.775, 0.95]; + + //--Pointer-related data + r.hoverData = { + down: null, + last: null, + downTime: null, + triggerMode: null, + dragging: false, + initialPan: [null, null], + capture: false + }; + r.dragData = { + possibleDragElements: [] + }; + r.touchData = { + start: null, + capture: false, + // These 3 fields related to tap, taphold events + startPosition: [null, null, null, null, null, null], + singleTouchStartTime: null, + singleTouchMoved: true, + now: [null, null, null, null, null, null], + earlier: [null, null, null, null, null, null] + }; + r.redraws = 0; + r.showFps = options.showFps; + r.debug = options.debug; + r.hideEdgesOnViewport = options.hideEdgesOnViewport; + r.textureOnViewport = options.textureOnViewport; + r.wheelSensitivity = options.wheelSensitivity; + r.motionBlurEnabled = options.motionBlur; // on by default + r.forcedPixelRatio = number$1(options.pixelRatio) ? options.pixelRatio : null; + r.motionBlur = options.motionBlur; // for initial kick off + r.motionBlurOpacity = options.motionBlurOpacity; + r.motionBlurTransparency = 1 - r.motionBlurOpacity; + r.motionBlurPxRatio = 1; + r.mbPxRBlurry = 1; //0.8; + r.minMbLowQualFrames = 4; + r.fullQualityMb = false; + r.clearedForMotionBlur = []; + r.desktopTapThreshold = options.desktopTapThreshold; + r.desktopTapThreshold2 = options.desktopTapThreshold * options.desktopTapThreshold; + r.touchTapThreshold = options.touchTapThreshold; + r.touchTapThreshold2 = options.touchTapThreshold * options.touchTapThreshold; + r.tapholdDuration = 500; + r.bindings = []; + r.beforeRenderCallbacks = []; + r.beforeRenderPriorities = { + // higher priority execs before lower one + animations: 400, + eleCalcs: 300, + eleTxrDeq: 200, + lyrTxrDeq: 150, + lyrTxrSkip: 100 + }; + r.registerNodeShapes(); + r.registerArrowShapes(); + r.registerCalculationListeners(); +}; +BRp.notify = function (eventName, eles) { + var r = this; + var cy = r.cy; + + // the renderer can't be notified after it's destroyed + if (this.destroyed) { + return; + } + if (eventName === 'init') { + r.load(); + return; + } + if (eventName === 'destroy') { + r.destroy(); + return; + } + if (eventName === 'add' || eventName === 'remove' || eventName === 'move' && cy.hasCompoundNodes() || eventName === 'load' || eventName === 'zorder' || eventName === 'mount') { + r.invalidateCachedZSortedEles(); + } + if (eventName === 'viewport') { + r.redrawHint('select', true); + } + if (eventName === 'load' || eventName === 'resize' || eventName === 'mount') { + r.invalidateContainerClientCoordsCache(); + r.matchCanvasSize(r.container); + } + r.redrawHint('eles', true); + r.redrawHint('drag', true); + this.startRenderLoop(); + this.redraw(); +}; +BRp.destroy = function () { + var r = this; + r.destroyed = true; + r.cy.stopAnimationLoop(); + for (var i = 0; i < r.bindings.length; i++) { + var binding = r.bindings[i]; + var b = binding; + var tgt = b.target; + (tgt.off || tgt.removeEventListener).apply(tgt, b.args); + } + r.bindings = []; + r.beforeRenderCallbacks = []; + r.onUpdateEleCalcsFns = []; + if (r.removeObserver) { + r.removeObserver.disconnect(); + } + if (r.styleObserver) { + r.styleObserver.disconnect(); + } + if (r.resizeObserver) { + r.resizeObserver.disconnect(); + } + if (r.labelCalcDiv) { + try { + document.body.removeChild(r.labelCalcDiv); // eslint-disable-line no-undef + } catch (e) { + // ie10 issue #1014 + } + } +}; +BRp.isHeadless = function () { + return false; +}; +[BRp$f, BRp$5, BRp$4, BRp$3, BRp$2, BRp$1].forEach(function (props) { + extend(BRp, props); +}); + +var fullFpsTime = 1000 / 60; // assume 60 frames per second + +var defs = { + setupDequeueing: function setupDequeueing(opts) { + return function setupDequeueingImpl() { + var self = this; + var r = this.renderer; + if (self.dequeueingSetup) { + return; + } else { + self.dequeueingSetup = true; + } + var queueRedraw = debounce_1(function () { + r.redrawHint('eles', true); + r.redrawHint('drag', true); + r.redraw(); + }, opts.deqRedrawThreshold); + var dequeue = function dequeue(willDraw, frameStartTime) { + var startTime = performanceNow(); + var avgRenderTime = r.averageRedrawTime; + var renderTime = r.lastRedrawTime; + var deqd = []; + var extent = r.cy.extent(); + var pixelRatio = r.getPixelRatio(); + + // if we aren't in a tick that causes a draw, then the rendered style + // queue won't automatically be flushed before dequeueing starts + if (!willDraw) { + r.flushRenderedStyleQueue(); + } + while (true) { + // eslint-disable-line no-constant-condition + var now = performanceNow(); + var duration = now - startTime; + var frameDuration = now - frameStartTime; + if (renderTime < fullFpsTime) { + // if we're rendering faster than the ideal fps, then do dequeueing + // during all of the remaining frame time + + var timeAvailable = fullFpsTime - (willDraw ? avgRenderTime : 0); + if (frameDuration >= opts.deqFastCost * timeAvailable) { + break; + } + } else { + if (willDraw) { + if (duration >= opts.deqCost * renderTime || duration >= opts.deqAvgCost * avgRenderTime) { + break; + } + } else if (frameDuration >= opts.deqNoDrawCost * fullFpsTime) { + break; + } + } + var thisDeqd = opts.deq(self, pixelRatio, extent); + if (thisDeqd.length > 0) { + for (var i = 0; i < thisDeqd.length; i++) { + deqd.push(thisDeqd[i]); + } + } else { + break; + } + } + + // callbacks on dequeue + if (deqd.length > 0) { + opts.onDeqd(self, deqd); + if (!willDraw && opts.shouldRedraw(self, deqd, pixelRatio, extent)) { + queueRedraw(); + } + } + }; + var priority = opts.priority || noop$1; + r.beforeRender(dequeue, priority(self)); + }; + } +}; + +// Allows lookups for (ele, lvl) => cache. +// Uses keys so elements may share the same cache. +var ElementTextureCacheLookup = /*#__PURE__*/function () { + function ElementTextureCacheLookup(getKey) { + var doesEleInvalidateKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : falsify; + _classCallCheck(this, ElementTextureCacheLookup); + this.idsByKey = new Map$2(); + this.keyForId = new Map$2(); + this.cachesByLvl = new Map$2(); + this.lvls = []; + this.getKey = getKey; + this.doesEleInvalidateKey = doesEleInvalidateKey; + } + _createClass(ElementTextureCacheLookup, [{ + key: "getIdsFor", + value: function getIdsFor(key) { + if (key == null) { + error("Can not get id list for null key"); + } + var idsByKey = this.idsByKey; + var ids = this.idsByKey.get(key); + if (!ids) { + ids = new Set$1(); + idsByKey.set(key, ids); + } + return ids; + } + }, { + key: "addIdForKey", + value: function addIdForKey(key, id) { + if (key != null) { + this.getIdsFor(key).add(id); + } + } + }, { + key: "deleteIdForKey", + value: function deleteIdForKey(key, id) { + if (key != null) { + this.getIdsFor(key)["delete"](id); + } + } + }, { + key: "getNumberOfIdsForKey", + value: function getNumberOfIdsForKey(key) { + if (key == null) { + return 0; + } else { + return this.getIdsFor(key).size; + } + } + }, { + key: "updateKeyMappingFor", + value: function updateKeyMappingFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + var currKey = this.getKey(ele); + this.deleteIdForKey(prevKey, id); + this.addIdForKey(currKey, id); + this.keyForId.set(id, currKey); + } + }, { + key: "deleteKeyMappingFor", + value: function deleteKeyMappingFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + this.deleteIdForKey(prevKey, id); + this.keyForId["delete"](id); + } + }, { + key: "keyHasChangedFor", + value: function keyHasChangedFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + var newKey = this.getKey(ele); + return prevKey !== newKey; + } + }, { + key: "isInvalid", + value: function isInvalid(ele) { + return this.keyHasChangedFor(ele) || this.doesEleInvalidateKey(ele); + } + }, { + key: "getCachesAt", + value: function getCachesAt(lvl) { + var cachesByLvl = this.cachesByLvl, + lvls = this.lvls; + var caches = cachesByLvl.get(lvl); + if (!caches) { + caches = new Map$2(); + cachesByLvl.set(lvl, caches); + lvls.push(lvl); + } + return caches; + } + }, { + key: "getCache", + value: function getCache(key, lvl) { + return this.getCachesAt(lvl).get(key); + } + }, { + key: "get", + value: function get(ele, lvl) { + var key = this.getKey(ele); + var cache = this.getCache(key, lvl); + + // getting for an element may need to add to the id list b/c eles can share keys + if (cache != null) { + this.updateKeyMappingFor(ele); + } + return cache; + } + }, { + key: "getForCachedKey", + value: function getForCachedKey(ele, lvl) { + var key = this.keyForId.get(ele.id()); // n.b. use cached key, not newly computed key + var cache = this.getCache(key, lvl); + return cache; + } + }, { + key: "hasCache", + value: function hasCache(key, lvl) { + return this.getCachesAt(lvl).has(key); + } + }, { + key: "has", + value: function has(ele, lvl) { + var key = this.getKey(ele); + return this.hasCache(key, lvl); + } + }, { + key: "setCache", + value: function setCache(key, lvl, cache) { + cache.key = key; + this.getCachesAt(lvl).set(key, cache); + } + }, { + key: "set", + value: function set(ele, lvl, cache) { + var key = this.getKey(ele); + this.setCache(key, lvl, cache); + this.updateKeyMappingFor(ele); + } + }, { + key: "deleteCache", + value: function deleteCache(key, lvl) { + this.getCachesAt(lvl)["delete"](key); + } + }, { + key: "delete", + value: function _delete(ele, lvl) { + var key = this.getKey(ele); + this.deleteCache(key, lvl); + } + }, { + key: "invalidateKey", + value: function invalidateKey(key) { + var _this = this; + this.lvls.forEach(function (lvl) { + return _this.deleteCache(key, lvl); + }); + } + + // returns true if no other eles reference the invalidated cache (n.b. other eles may need the cache with the same key) + }, { + key: "invalidate", + value: function invalidate(ele) { + var id = ele.id(); + var key = this.keyForId.get(id); // n.b. use stored key rather than current (potential key) + + this.deleteKeyMappingFor(ele); + var entireKeyInvalidated = this.doesEleInvalidateKey(ele); + if (entireKeyInvalidated) { + // clear mapping for current key + this.invalidateKey(key); + } + return entireKeyInvalidated || this.getNumberOfIdsForKey(key) === 0; + } + }]); + return ElementTextureCacheLookup; +}(); + +var minTxrH = 25; // the size of the texture cache for small height eles (special case) +var txrStepH = 50; // the min size of the regular cache, and the size it increases with each step up +var minLvl$1 = -4; // when scaling smaller than that we don't need to re-render +var maxLvl$1 = 3; // when larger than this scale just render directly (caching is not helpful) +var maxZoom$1 = 7.99; // beyond this zoom level, layered textures are not used +var eleTxrSpacing = 8; // spacing between elements on textures to avoid blitting overlaps +var defTxrWidth = 1024; // default/minimum texture width +var maxTxrW = 1024; // the maximum width of a texture +var maxTxrH = 1024; // the maximum height of a texture +var minUtility = 0.2; // if usage of texture is less than this, it is retired +var maxFullness = 0.8; // fullness of texture after which queue removal is checked +var maxFullnessChecks = 10; // dequeued after this many checks +var deqCost$1 = 0.15; // % of add'l rendering cost allowed for dequeuing ele caches each frame +var deqAvgCost$1 = 0.1; // % of add'l rendering cost compared to average overall redraw time +var deqNoDrawCost$1 = 0.9; // % of avg frame time that can be used for dequeueing when not drawing +var deqFastCost$1 = 0.9; // % of frame time to be used when >60fps +var deqRedrawThreshold$1 = 100; // time to batch redraws together from dequeueing to allow more dequeueing calcs to happen in the meanwhile +var maxDeqSize$1 = 1; // number of eles to dequeue and render at higher texture in each batch + +var getTxrReasons = { + dequeue: 'dequeue', + downscale: 'downscale', + highQuality: 'highQuality' +}; +var initDefaults = defaults$g({ + getKey: null, + doesEleInvalidateKey: falsify, + drawElement: null, + getBoundingBox: null, + getRotationPoint: null, + getRotationOffset: null, + isVisible: trueify, + allowEdgeTxrCaching: true, + allowParentTxrCaching: true +}); +var ElementTextureCache = function ElementTextureCache(renderer, initOptions) { + var self = this; + self.renderer = renderer; + self.onDequeues = []; + var opts = initDefaults(initOptions); + extend(self, opts); + self.lookup = new ElementTextureCacheLookup(opts.getKey, opts.doesEleInvalidateKey); + self.setupDequeueing(); +}; +var ETCp = ElementTextureCache.prototype; +ETCp.reasons = getTxrReasons; + +// the list of textures in which new subtextures for elements can be placed +ETCp.getTextureQueue = function (txrH) { + var self = this; + self.eleImgCaches = self.eleImgCaches || {}; + return self.eleImgCaches[txrH] = self.eleImgCaches[txrH] || []; +}; + +// the list of usused textures which can be recycled (in use in texture queue) +ETCp.getRetiredTextureQueue = function (txrH) { + var self = this; + var rtxtrQs = self.eleImgCaches.retired = self.eleImgCaches.retired || {}; + var rtxtrQ = rtxtrQs[txrH] = rtxtrQs[txrH] || []; + return rtxtrQ; +}; + +// queue of element draw requests at different scale levels +ETCp.getElementQueue = function () { + var self = this; + var q = self.eleCacheQueue = self.eleCacheQueue || new heap(function (a, b) { + return b.reqs - a.reqs; + }); + return q; +}; + +// queue of element draw requests at different scale levels (element id lookup) +ETCp.getElementKeyToQueue = function () { + var self = this; + var k2q = self.eleKeyToCacheQueue = self.eleKeyToCacheQueue || {}; + return k2q; +}; +ETCp.getElement = function (ele, bb, pxRatio, lvl, reason) { + var self = this; + var r = this.renderer; + var zoom = r.cy.zoom(); + var lookup = this.lookup; + if (!bb || bb.w === 0 || bb.h === 0 || isNaN(bb.w) || isNaN(bb.h) || !ele.visible() || ele.removed()) { + return null; + } + if (!self.allowEdgeTxrCaching && ele.isEdge() || !self.allowParentTxrCaching && ele.isParent()) { + return null; + } + if (lvl == null) { + lvl = Math.ceil(log2(zoom * pxRatio)); + } + if (lvl < minLvl$1) { + lvl = minLvl$1; + } else if (zoom >= maxZoom$1 || lvl > maxLvl$1) { + return null; + } + var scale = Math.pow(2, lvl); + var eleScaledH = bb.h * scale; + var eleScaledW = bb.w * scale; + var scaledLabelShown = r.eleTextBiggerThanMin(ele, scale); + if (!this.isVisible(ele, scaledLabelShown)) { + return null; + } + var eleCache = lookup.get(ele, lvl); + + // if this get was on an unused/invalidated cache, then restore the texture usage metric + if (eleCache && eleCache.invalidated) { + eleCache.invalidated = false; + eleCache.texture.invalidatedWidth -= eleCache.width; + } + if (eleCache) { + return eleCache; + } + var txrH; // which texture height this ele belongs to + + if (eleScaledH <= minTxrH) { + txrH = minTxrH; + } else if (eleScaledH <= txrStepH) { + txrH = txrStepH; + } else { + txrH = Math.ceil(eleScaledH / txrStepH) * txrStepH; + } + if (eleScaledH > maxTxrH || eleScaledW > maxTxrW) { + return null; // caching large elements is not efficient + } + + var txrQ = self.getTextureQueue(txrH); + + // first try the second last one in case it has space at the end + var txr = txrQ[txrQ.length - 2]; + var addNewTxr = function addNewTxr() { + return self.recycleTexture(txrH, eleScaledW) || self.addTexture(txrH, eleScaledW); + }; + + // try the last one if there is no second last one + if (!txr) { + txr = txrQ[txrQ.length - 1]; + } + + // if the last one doesn't exist, we need a first one + if (!txr) { + txr = addNewTxr(); + } + + // if there's no room in the current texture, we need a new one + if (txr.width - txr.usedWidth < eleScaledW) { + txr = addNewTxr(); + } + var scalableFrom = function scalableFrom(otherCache) { + return otherCache && otherCache.scaledLabelShown === scaledLabelShown; + }; + var deqing = reason && reason === getTxrReasons.dequeue; + var highQualityReq = reason && reason === getTxrReasons.highQuality; + var downscaleReq = reason && reason === getTxrReasons.downscale; + var higherCache; // the nearest cache with a higher level + for (var l = lvl + 1; l <= maxLvl$1; l++) { + var c = lookup.get(ele, l); + if (c) { + higherCache = c; + break; + } + } + var oneUpCache = higherCache && higherCache.level === lvl + 1 ? higherCache : null; + var downscale = function downscale() { + txr.context.drawImage(oneUpCache.texture.canvas, oneUpCache.x, 0, oneUpCache.width, oneUpCache.height, txr.usedWidth, 0, eleScaledW, eleScaledH); + }; + + // reset ele area in texture + txr.context.setTransform(1, 0, 0, 1, 0, 0); + txr.context.clearRect(txr.usedWidth, 0, eleScaledW, txrH); + if (scalableFrom(oneUpCache)) { + // then we can relatively cheaply rescale the existing image w/o rerendering + downscale(); + } else if (scalableFrom(higherCache)) { + // then use the higher cache for now and queue the next level down + // to cheaply scale towards the smaller level + + if (highQualityReq) { + for (var _l = higherCache.level; _l > lvl; _l--) { + oneUpCache = self.getElement(ele, bb, pxRatio, _l, getTxrReasons.downscale); + } + downscale(); + } else { + self.queueElement(ele, higherCache.level - 1); + return higherCache; + } + } else { + var lowerCache; // the nearest cache with a lower level + if (!deqing && !highQualityReq && !downscaleReq) { + for (var _l2 = lvl - 1; _l2 >= minLvl$1; _l2--) { + var _c = lookup.get(ele, _l2); + if (_c) { + lowerCache = _c; + break; + } + } + } + if (scalableFrom(lowerCache)) { + // then use the lower quality cache for now and queue the better one for later + + self.queueElement(ele, lvl); + return lowerCache; + } + txr.context.translate(txr.usedWidth, 0); + txr.context.scale(scale, scale); + this.drawElement(txr.context, ele, bb, scaledLabelShown, false); + txr.context.scale(1 / scale, 1 / scale); + txr.context.translate(-txr.usedWidth, 0); + } + eleCache = { + x: txr.usedWidth, + texture: txr, + level: lvl, + scale: scale, + width: eleScaledW, + height: eleScaledH, + scaledLabelShown: scaledLabelShown + }; + txr.usedWidth += Math.ceil(eleScaledW + eleTxrSpacing); + txr.eleCaches.push(eleCache); + lookup.set(ele, lvl, eleCache); + self.checkTextureFullness(txr); + return eleCache; +}; +ETCp.invalidateElements = function (eles) { + for (var i = 0; i < eles.length; i++) { + this.invalidateElement(eles[i]); + } +}; +ETCp.invalidateElement = function (ele) { + var self = this; + var lookup = self.lookup; + var caches = []; + var invalid = lookup.isInvalid(ele); + if (!invalid) { + return; // override the invalidation request if the element key has not changed + } + + for (var lvl = minLvl$1; lvl <= maxLvl$1; lvl++) { + var cache = lookup.getForCachedKey(ele, lvl); + if (cache) { + caches.push(cache); + } + } + var noOtherElesUseCache = lookup.invalidate(ele); + if (noOtherElesUseCache) { + for (var i = 0; i < caches.length; i++) { + var _cache = caches[i]; + var txr = _cache.texture; + + // remove space from the texture it belongs to + txr.invalidatedWidth += _cache.width; + + // mark the cache as invalidated + _cache.invalidated = true; + + // retire the texture if its utility is low + self.checkTextureUtility(txr); + } + } + + // remove from queue since the old req was for the old state + self.removeFromQueue(ele); +}; +ETCp.checkTextureUtility = function (txr) { + // invalidate all entries in the cache if the cache size is small + if (txr.invalidatedWidth >= minUtility * txr.width) { + this.retireTexture(txr); + } +}; +ETCp.checkTextureFullness = function (txr) { + // if texture has been mostly filled and passed over several times, remove + // it from the queue so we don't need to waste time looking at it to put new things + + var self = this; + var txrQ = self.getTextureQueue(txr.height); + if (txr.usedWidth / txr.width > maxFullness && txr.fullnessChecks >= maxFullnessChecks) { + removeFromArray(txrQ, txr); + } else { + txr.fullnessChecks++; + } +}; +ETCp.retireTexture = function (txr) { + var self = this; + var txrH = txr.height; + var txrQ = self.getTextureQueue(txrH); + var lookup = this.lookup; + + // retire the texture from the active / searchable queue: + + removeFromArray(txrQ, txr); + txr.retired = true; + + // remove the refs from the eles to the caches: + + var eleCaches = txr.eleCaches; + for (var i = 0; i < eleCaches.length; i++) { + var eleCache = eleCaches[i]; + lookup.deleteCache(eleCache.key, eleCache.level); + } + clearArray(eleCaches); + + // add the texture to a retired queue so it can be recycled in future: + + var rtxtrQ = self.getRetiredTextureQueue(txrH); + rtxtrQ.push(txr); +}; +ETCp.addTexture = function (txrH, minW) { + var self = this; + var txrQ = self.getTextureQueue(txrH); + var txr = {}; + txrQ.push(txr); + txr.eleCaches = []; + txr.height = txrH; + txr.width = Math.max(defTxrWidth, minW); + txr.usedWidth = 0; + txr.invalidatedWidth = 0; + txr.fullnessChecks = 0; + txr.canvas = self.renderer.makeOffscreenCanvas(txr.width, txr.height); + txr.context = txr.canvas.getContext('2d'); + return txr; +}; +ETCp.recycleTexture = function (txrH, minW) { + var self = this; + var txrQ = self.getTextureQueue(txrH); + var rtxtrQ = self.getRetiredTextureQueue(txrH); + for (var i = 0; i < rtxtrQ.length; i++) { + var txr = rtxtrQ[i]; + if (txr.width >= minW) { + txr.retired = false; + txr.usedWidth = 0; + txr.invalidatedWidth = 0; + txr.fullnessChecks = 0; + clearArray(txr.eleCaches); + txr.context.setTransform(1, 0, 0, 1, 0, 0); + txr.context.clearRect(0, 0, txr.width, txr.height); + removeFromArray(rtxtrQ, txr); + txrQ.push(txr); + return txr; + } + } +}; +ETCp.queueElement = function (ele, lvl) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var key = this.getKey(ele); + var existingReq = k2q[key]; + if (existingReq) { + // use the max lvl b/c in between lvls are cheap to make + existingReq.level = Math.max(existingReq.level, lvl); + existingReq.eles.merge(ele); + existingReq.reqs++; + q.updateItem(existingReq); + } else { + var req = { + eles: ele.spawn().merge(ele), + level: lvl, + reqs: 1, + key: key + }; + q.push(req); + k2q[key] = req; + } +}; +ETCp.dequeue = function (pxRatio /*, extent*/) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var dequeued = []; + var lookup = self.lookup; + for (var i = 0; i < maxDeqSize$1; i++) { + if (q.size() > 0) { + var req = q.pop(); + var key = req.key; + var ele = req.eles[0]; // all eles have the same key + var cacheExists = lookup.hasCache(ele, req.level); + + // clear out the key to req lookup + k2q[key] = null; + + // dequeueing isn't necessary with an existing cache + if (cacheExists) { + continue; + } + dequeued.push(req); + var bb = self.getBoundingBox(ele); + self.getElement(ele, bb, pxRatio, req.level, getTxrReasons.dequeue); + } else { + break; + } + } + return dequeued; +}; +ETCp.removeFromQueue = function (ele) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var key = this.getKey(ele); + var req = k2q[key]; + if (req != null) { + if (req.eles.length === 1) { + // remove if last ele in the req + // bring to front of queue + req.reqs = MAX_INT$1; + q.updateItem(req); + q.pop(); // remove from queue + + k2q[key] = null; // remove from lookup map + } else { + // otherwise just remove ele from req + req.eles.unmerge(ele); + } + } +}; +ETCp.onDequeue = function (fn) { + this.onDequeues.push(fn); +}; +ETCp.offDequeue = function (fn) { + removeFromArray(this.onDequeues, fn); +}; +ETCp.setupDequeueing = defs.setupDequeueing({ + deqRedrawThreshold: deqRedrawThreshold$1, + deqCost: deqCost$1, + deqAvgCost: deqAvgCost$1, + deqNoDrawCost: deqNoDrawCost$1, + deqFastCost: deqFastCost$1, + deq: function deq(self, pxRatio, extent) { + return self.dequeue(pxRatio, extent); + }, + onDeqd: function onDeqd(self, deqd) { + for (var i = 0; i < self.onDequeues.length; i++) { + var fn = self.onDequeues[i]; + fn(deqd); + } + }, + shouldRedraw: function shouldRedraw(self, deqd, pxRatio, extent) { + for (var i = 0; i < deqd.length; i++) { + var eles = deqd[i].eles; + for (var j = 0; j < eles.length; j++) { + var bb = eles[j].boundingBox(); + if (boundingBoxesIntersect(bb, extent)) { + return true; + } + } + } + return false; + }, + priority: function priority(self) { + return self.renderer.beforeRenderPriorities.eleTxrDeq; + } +}); + +var defNumLayers = 1; // default number of layers to use +var minLvl = -4; // when scaling smaller than that we don't need to re-render +var maxLvl = 2; // when larger than this scale just render directly (caching is not helpful) +var maxZoom = 3.99; // beyond this zoom level, layered textures are not used +var deqRedrawThreshold = 50; // time to batch redraws together from dequeueing to allow more dequeueing calcs to happen in the meanwhile +var refineEleDebounceTime = 50; // time to debounce sharper ele texture updates +var deqCost = 0.15; // % of add'l rendering cost allowed for dequeuing ele caches each frame +var deqAvgCost = 0.1; // % of add'l rendering cost compared to average overall redraw time +var deqNoDrawCost = 0.9; // % of avg frame time that can be used for dequeueing when not drawing +var deqFastCost = 0.9; // % of frame time to be used when >60fps +var maxDeqSize = 1; // number of eles to dequeue and render at higher texture in each batch +var invalidThreshold = 250; // time threshold for disabling b/c of invalidations +var maxLayerArea = 4000 * 4000; // layers can't be bigger than this +var useHighQualityEleTxrReqs = true; // whether to use high quality ele txr requests (generally faster and cheaper in the longterm) + +// var log = function(){ console.log.apply( console, arguments ); }; + +var LayeredTextureCache = function LayeredTextureCache(renderer) { + var self = this; + var r = self.renderer = renderer; + var cy = r.cy; + self.layersByLevel = {}; // e.g. 2 => [ layer1, layer2, ..., layerN ] + + self.firstGet = true; + self.lastInvalidationTime = performanceNow() - 2 * invalidThreshold; + self.skipping = false; + self.eleTxrDeqs = cy.collection(); + self.scheduleElementRefinement = debounce_1(function () { + self.refineElementTextures(self.eleTxrDeqs); + self.eleTxrDeqs.unmerge(self.eleTxrDeqs); + }, refineEleDebounceTime); + r.beforeRender(function (willDraw, now) { + if (now - self.lastInvalidationTime <= invalidThreshold) { + self.skipping = true; + } else { + self.skipping = false; + } + }, r.beforeRenderPriorities.lyrTxrSkip); + var qSort = function qSort(a, b) { + return b.reqs - a.reqs; + }; + self.layersQueue = new heap(qSort); + self.setupDequeueing(); +}; +var LTCp = LayeredTextureCache.prototype; +var layerIdPool = 0; +var MAX_INT = Math.pow(2, 53) - 1; +LTCp.makeLayer = function (bb, lvl) { + var scale = Math.pow(2, lvl); + var w = Math.ceil(bb.w * scale); + var h = Math.ceil(bb.h * scale); + var canvas = this.renderer.makeOffscreenCanvas(w, h); + var layer = { + id: layerIdPool = ++layerIdPool % MAX_INT, + bb: bb, + level: lvl, + width: w, + height: h, + canvas: canvas, + context: canvas.getContext('2d'), + eles: [], + elesQueue: [], + reqs: 0 + }; + + // log('make layer %s with w %s and h %s and lvl %s', layer.id, layer.width, layer.height, layer.level); + + var cxt = layer.context; + var dx = -layer.bb.x1; + var dy = -layer.bb.y1; + + // do the transform on creation to save cycles (it's the same for all eles) + cxt.scale(scale, scale); + cxt.translate(dx, dy); + return layer; +}; +LTCp.getLayers = function (eles, pxRatio, lvl) { + var self = this; + var r = self.renderer; + var cy = r.cy; + var zoom = cy.zoom(); + var firstGet = self.firstGet; + self.firstGet = false; + + // log('--\nget layers with %s eles', eles.length); + //log eles.map(function(ele){ return ele.id() }) ); + + if (lvl == null) { + lvl = Math.ceil(log2(zoom * pxRatio)); + if (lvl < minLvl) { + lvl = minLvl; + } else if (zoom >= maxZoom || lvl > maxLvl) { + return null; + } + } + self.validateLayersElesOrdering(lvl, eles); + var layersByLvl = self.layersByLevel; + var scale = Math.pow(2, lvl); + var layers = layersByLvl[lvl] = layersByLvl[lvl] || []; + var bb; + var lvlComplete = self.levelIsComplete(lvl, eles); + var tmpLayers; + var checkTempLevels = function checkTempLevels() { + var canUseAsTmpLvl = function canUseAsTmpLvl(l) { + self.validateLayersElesOrdering(l, eles); + if (self.levelIsComplete(l, eles)) { + tmpLayers = layersByLvl[l]; + return true; + } + }; + var checkLvls = function checkLvls(dir) { + if (tmpLayers) { + return; + } + for (var l = lvl + dir; minLvl <= l && l <= maxLvl; l += dir) { + if (canUseAsTmpLvl(l)) { + break; + } + } + }; + checkLvls(+1); + checkLvls(-1); + + // remove the invalid layers; they will be replaced as needed later in this function + for (var i = layers.length - 1; i >= 0; i--) { + var layer = layers[i]; + if (layer.invalid) { + removeFromArray(layers, layer); + } + } + }; + if (!lvlComplete) { + // if the current level is incomplete, then use the closest, best quality layerset temporarily + // and later queue the current layerset so we can get the proper quality level soon + + checkTempLevels(); + } else { + // log('level complete, using existing layers\n--'); + return layers; + } + var getBb = function getBb() { + if (!bb) { + bb = makeBoundingBox(); + for (var i = 0; i < eles.length; i++) { + updateBoundingBox(bb, eles[i].boundingBox()); + } + } + return bb; + }; + var makeLayer = function makeLayer(opts) { + opts = opts || {}; + var after = opts.after; + getBb(); + var area = bb.w * scale * (bb.h * scale); + if (area > maxLayerArea) { + return null; + } + var layer = self.makeLayer(bb, lvl); + if (after != null) { + var index = layers.indexOf(after) + 1; + layers.splice(index, 0, layer); + } else if (opts.insert === undefined || opts.insert) { + // no after specified => first layer made so put at start + layers.unshift(layer); + } + + // if( tmpLayers ){ + //self.queueLayer( layer ); + // } + + return layer; + }; + if (self.skipping && !firstGet) { + // log('skip layers'); + return null; + } + + // log('do layers'); + + var layer = null; + var maxElesPerLayer = eles.length / defNumLayers; + var allowLazyQueueing = !firstGet; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var rs = ele._private.rscratch; + var caches = rs.imgLayerCaches = rs.imgLayerCaches || {}; + + // log('look at ele', ele.id()); + + var existingLayer = caches[lvl]; + if (existingLayer) { + // reuse layer for later eles + // log('reuse layer for', ele.id()); + layer = existingLayer; + continue; + } + if (!layer || layer.eles.length >= maxElesPerLayer || !boundingBoxInBoundingBox(layer.bb, ele.boundingBox())) { + // log('make new layer for ele %s', ele.id()); + + layer = makeLayer({ + insert: true, + after: layer + }); + + // if now layer can be built then we can't use layers at this level + if (!layer) { + return null; + } + + // log('new layer with id %s', layer.id); + } + + if (tmpLayers || allowLazyQueueing) { + // log('queue ele %s in layer %s', ele.id(), layer.id); + self.queueLayer(layer, ele); + } else { + // log('draw ele %s in layer %s', ele.id(), layer.id); + self.drawEleInLayer(layer, ele, lvl, pxRatio); + } + layer.eles.push(ele); + caches[lvl] = layer; + } + + // log('--'); + + if (tmpLayers) { + // then we only queued the current layerset and can't draw it yet + return tmpLayers; + } + if (allowLazyQueueing) { + // log('lazy queue level', lvl); + return null; + } + return layers; +}; + +// a layer may want to use an ele cache of a higher level to avoid blurriness +// so the layer level might not equal the ele level +LTCp.getEleLevelForLayerLevel = function (lvl, pxRatio) { + return lvl; +}; +LTCp.drawEleInLayer = function (layer, ele, lvl, pxRatio) { + var self = this; + var r = this.renderer; + var context = layer.context; + var bb = ele.boundingBox(); + if (bb.w === 0 || bb.h === 0 || !ele.visible()) { + return; + } + lvl = self.getEleLevelForLayerLevel(lvl, pxRatio); + { + r.setImgSmoothing(context, false); + } + { + r.drawCachedElement(context, ele, null, null, lvl, useHighQualityEleTxrReqs); + } + { + r.setImgSmoothing(context, true); + } +}; +LTCp.levelIsComplete = function (lvl, eles) { + var self = this; + var layers = self.layersByLevel[lvl]; + if (!layers || layers.length === 0) { + return false; + } + var numElesInLayers = 0; + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + + // if there are any eles needed to be drawn yet, the level is not complete + if (layer.reqs > 0) { + return false; + } + + // if the layer is invalid, the level is not complete + if (layer.invalid) { + return false; + } + numElesInLayers += layer.eles.length; + } + + // we should have exactly the number of eles passed in to be complete + if (numElesInLayers !== eles.length) { + return false; + } + return true; +}; +LTCp.validateLayersElesOrdering = function (lvl, eles) { + var layers = this.layersByLevel[lvl]; + if (!layers) { + return; + } + + // if in a layer the eles are not in the same order, then the layer is invalid + // (i.e. there is an ele in between the eles in the layer) + + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + var offset = -1; + + // find the offset + for (var j = 0; j < eles.length; j++) { + if (layer.eles[0] === eles[j]) { + offset = j; + break; + } + } + if (offset < 0) { + // then the layer has nonexistent elements and is invalid + this.invalidateLayer(layer); + continue; + } + + // the eles in the layer must be in the same continuous order, else the layer is invalid + + var o = offset; + for (var j = 0; j < layer.eles.length; j++) { + if (layer.eles[j] !== eles[o + j]) { + // log('invalidate based on ordering', layer.id); + + this.invalidateLayer(layer); + break; + } + } + } +}; +LTCp.updateElementsInLayers = function (eles, update) { + var self = this; + var isEles = element(eles[0]); + + // collect udpated elements (cascaded from the layers) and update each + // layer itself along the way + for (var i = 0; i < eles.length; i++) { + var req = isEles ? null : eles[i]; + var ele = isEles ? eles[i] : eles[i].ele; + var rs = ele._private.rscratch; + var caches = rs.imgLayerCaches = rs.imgLayerCaches || {}; + for (var l = minLvl; l <= maxLvl; l++) { + var layer = caches[l]; + if (!layer) { + continue; + } + + // if update is a request from the ele cache, then it affects only + // the matching level + if (req && self.getEleLevelForLayerLevel(layer.level) !== req.level) { + continue; + } + update(layer, ele, req); + } + } +}; +LTCp.haveLayers = function () { + var self = this; + var haveLayers = false; + for (var l = minLvl; l <= maxLvl; l++) { + var layers = self.layersByLevel[l]; + if (layers && layers.length > 0) { + haveLayers = true; + break; + } + } + return haveLayers; +}; +LTCp.invalidateElements = function (eles) { + var self = this; + if (eles.length === 0) { + return; + } + self.lastInvalidationTime = performanceNow(); + + // log('update invalidate layer time from eles'); + + if (eles.length === 0 || !self.haveLayers()) { + return; + } + self.updateElementsInLayers(eles, function invalAssocLayers(layer, ele, req) { + self.invalidateLayer(layer); + }); +}; +LTCp.invalidateLayer = function (layer) { + // log('update invalidate layer time'); + + this.lastInvalidationTime = performanceNow(); + if (layer.invalid) { + return; + } // save cycles + + var lvl = layer.level; + var eles = layer.eles; + var layers = this.layersByLevel[lvl]; + + // log('invalidate layer', layer.id ); + + removeFromArray(layers, layer); + // layer.eles = []; + + layer.elesQueue = []; + layer.invalid = true; + if (layer.replacement) { + layer.replacement.invalid = true; + } + for (var i = 0; i < eles.length; i++) { + var caches = eles[i]._private.rscratch.imgLayerCaches; + if (caches) { + caches[lvl] = null; + } + } +}; +LTCp.refineElementTextures = function (eles) { + var self = this; + + // log('refine', eles.length); + + self.updateElementsInLayers(eles, function refineEachEle(layer, ele, req) { + var rLyr = layer.replacement; + if (!rLyr) { + rLyr = layer.replacement = self.makeLayer(layer.bb, layer.level); + rLyr.replaces = layer; + rLyr.eles = layer.eles; + + // log('make replacement layer %s for %s with level %s', rLyr.id, layer.id, rLyr.level); + } + + if (!rLyr.reqs) { + for (var i = 0; i < rLyr.eles.length; i++) { + self.queueLayer(rLyr, rLyr.eles[i]); + } + + // log('queue replacement layer refinement', rLyr.id); + } + }); +}; + +LTCp.enqueueElementRefinement = function (ele) { + this.eleTxrDeqs.merge(ele); + this.scheduleElementRefinement(); +}; +LTCp.queueLayer = function (layer, ele) { + var self = this; + var q = self.layersQueue; + var elesQ = layer.elesQueue; + var hasId = elesQ.hasId = elesQ.hasId || {}; + + // if a layer is going to be replaced, queuing is a waste of time + if (layer.replacement) { + return; + } + if (ele) { + if (hasId[ele.id()]) { + return; + } + elesQ.push(ele); + hasId[ele.id()] = true; + } + if (layer.reqs) { + layer.reqs++; + q.updateItem(layer); + } else { + layer.reqs = 1; + q.push(layer); + } +}; +LTCp.dequeue = function (pxRatio) { + var self = this; + var q = self.layersQueue; + var deqd = []; + var eleDeqs = 0; + while (eleDeqs < maxDeqSize) { + if (q.size() === 0) { + break; + } + var layer = q.peek(); + + // if a layer has been or will be replaced, then don't waste time with it + if (layer.replacement) { + // log('layer %s in queue skipped b/c it already has a replacement', layer.id); + q.pop(); + continue; + } + + // if this is a replacement layer that has been superceded, then forget it + if (layer.replaces && layer !== layer.replaces.replacement) { + // log('layer is no longer the most uptodate replacement; dequeued', layer.id) + q.pop(); + continue; + } + if (layer.invalid) { + // log('replacement layer %s is invalid; dequeued', layer.id); + q.pop(); + continue; + } + var ele = layer.elesQueue.shift(); + if (ele) { + // log('dequeue layer %s', layer.id); + + self.drawEleInLayer(layer, ele, layer.level, pxRatio); + eleDeqs++; + } + if (deqd.length === 0) { + // we need only one entry in deqd to queue redrawing etc + deqd.push(true); + } + + // if the layer has all its eles done, then remove from the queue + if (layer.elesQueue.length === 0) { + q.pop(); + layer.reqs = 0; + + // log('dequeue of layer %s complete', layer.id); + + // when a replacement layer is dequeued, it replaces the old layer in the level + if (layer.replaces) { + self.applyLayerReplacement(layer); + } + self.requestRedraw(); + } + } + return deqd; +}; +LTCp.applyLayerReplacement = function (layer) { + var self = this; + var layersInLevel = self.layersByLevel[layer.level]; + var replaced = layer.replaces; + var index = layersInLevel.indexOf(replaced); + + // if the replaced layer is not in the active list for the level, then replacing + // refs would be a mistake (i.e. overwriting the true active layer) + if (index < 0 || replaced.invalid) { + // log('replacement layer would have no effect', layer.id); + return; + } + layersInLevel[index] = layer; // replace level ref + + // replace refs in eles + for (var i = 0; i < layer.eles.length; i++) { + var _p = layer.eles[i]._private; + var cache = _p.imgLayerCaches = _p.imgLayerCaches || {}; + if (cache) { + cache[layer.level] = layer; + } + } + + // log('apply replacement layer %s over %s', layer.id, replaced.id); + + self.requestRedraw(); +}; +LTCp.requestRedraw = debounce_1(function () { + var r = this.renderer; + r.redrawHint('eles', true); + r.redrawHint('drag', true); + r.redraw(); +}, 100); +LTCp.setupDequeueing = defs.setupDequeueing({ + deqRedrawThreshold: deqRedrawThreshold, + deqCost: deqCost, + deqAvgCost: deqAvgCost, + deqNoDrawCost: deqNoDrawCost, + deqFastCost: deqFastCost, + deq: function deq(self, pxRatio) { + return self.dequeue(pxRatio); + }, + onDeqd: noop$1, + shouldRedraw: trueify, + priority: function priority(self) { + return self.renderer.beforeRenderPriorities.lyrTxrDeq; + } +}); + +var CRp$a = {}; +var impl; +function polygon(context, points) { + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + context.lineTo(pt.x, pt.y); + } +} +function triangleBackcurve(context, points, controlPoint) { + var firstPt; + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + if (i === 0) { + firstPt = pt; + } + context.lineTo(pt.x, pt.y); + } + context.quadraticCurveTo(controlPoint.x, controlPoint.y, firstPt.x, firstPt.y); +} +function triangleTee(context, trianglePoints, teePoints) { + if (context.beginPath) { + context.beginPath(); + } + var triPts = trianglePoints; + for (var i = 0; i < triPts.length; i++) { + var pt = triPts[i]; + context.lineTo(pt.x, pt.y); + } + var teePts = teePoints; + var firstTeePt = teePoints[0]; + context.moveTo(firstTeePt.x, firstTeePt.y); + for (var i = 1; i < teePts.length; i++) { + var pt = teePts[i]; + context.lineTo(pt.x, pt.y); + } + if (context.closePath) { + context.closePath(); + } +} +function circleTriangle(context, trianglePoints, rx, ry, r) { + if (context.beginPath) { + context.beginPath(); + } + context.arc(rx, ry, r, 0, Math.PI * 2, false); + var triPts = trianglePoints; + var firstTrPt = triPts[0]; + context.moveTo(firstTrPt.x, firstTrPt.y); + for (var i = 0; i < triPts.length; i++) { + var pt = triPts[i]; + context.lineTo(pt.x, pt.y); + } + if (context.closePath) { + context.closePath(); + } +} +function circle(context, rx, ry, r) { + context.arc(rx, ry, r, 0, Math.PI * 2, false); +} +CRp$a.arrowShapeImpl = function (name) { + return (impl || (impl = { + 'polygon': polygon, + 'triangle-backcurve': triangleBackcurve, + 'triangle-tee': triangleTee, + 'circle-triangle': circleTriangle, + 'triangle-cross': triangleTee, + 'circle': circle + }))[name]; +}; + +var CRp$9 = {}; +CRp$9.drawElement = function (context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity) { + var r = this; + if (ele.isNode()) { + r.drawNode(context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity); + } else { + r.drawEdge(context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity); + } +}; +CRp$9.drawElementOverlay = function (context, ele) { + var r = this; + if (ele.isNode()) { + r.drawNodeOverlay(context, ele); + } else { + r.drawEdgeOverlay(context, ele); + } +}; +CRp$9.drawElementUnderlay = function (context, ele) { + var r = this; + if (ele.isNode()) { + r.drawNodeUnderlay(context, ele); + } else { + r.drawEdgeUnderlay(context, ele); + } +}; +CRp$9.drawCachedElementPortion = function (context, ele, eleTxrCache, pxRatio, lvl, reason, getRotation, getOpacity) { + var r = this; + var bb = eleTxrCache.getBoundingBox(ele); + if (bb.w === 0 || bb.h === 0) { + return; + } // ignore zero size case + + var eleCache = eleTxrCache.getElement(ele, bb, pxRatio, lvl, reason); + if (eleCache != null) { + var opacity = getOpacity(r, ele); + if (opacity === 0) { + return; + } + var theta = getRotation(r, ele); + var x1 = bb.x1, + y1 = bb.y1, + w = bb.w, + h = bb.h; + var x, y, sx, sy, smooth; + if (theta !== 0) { + var rotPt = eleTxrCache.getRotationPoint(ele); + sx = rotPt.x; + sy = rotPt.y; + context.translate(sx, sy); + context.rotate(theta); + smooth = r.getImgSmoothing(context); + if (!smooth) { + r.setImgSmoothing(context, true); + } + var off = eleTxrCache.getRotationOffset(ele); + x = off.x; + y = off.y; + } else { + x = x1; + y = y1; + } + var oldGlobalAlpha; + if (opacity !== 1) { + oldGlobalAlpha = context.globalAlpha; + context.globalAlpha = oldGlobalAlpha * opacity; + } + context.drawImage(eleCache.texture.canvas, eleCache.x, 0, eleCache.width, eleCache.height, x, y, w, h); + if (opacity !== 1) { + context.globalAlpha = oldGlobalAlpha; + } + if (theta !== 0) { + context.rotate(-theta); + context.translate(-sx, -sy); + if (!smooth) { + r.setImgSmoothing(context, false); + } + } + } else { + eleTxrCache.drawElement(context, ele); // direct draw fallback + } +}; + +var getZeroRotation = function getZeroRotation() { + return 0; +}; +var getLabelRotation = function getLabelRotation(r, ele) { + return r.getTextAngle(ele, null); +}; +var getSourceLabelRotation = function getSourceLabelRotation(r, ele) { + return r.getTextAngle(ele, 'source'); +}; +var getTargetLabelRotation = function getTargetLabelRotation(r, ele) { + return r.getTextAngle(ele, 'target'); +}; +var getOpacity = function getOpacity(r, ele) { + return ele.effectiveOpacity(); +}; +var getTextOpacity = function getTextOpacity(e, ele) { + return ele.pstyle('text-opacity').pfValue * ele.effectiveOpacity(); +}; +CRp$9.drawCachedElement = function (context, ele, pxRatio, extent, lvl, requestHighQuality) { + var r = this; + var _r$data = r.data, + eleTxrCache = _r$data.eleTxrCache, + lblTxrCache = _r$data.lblTxrCache, + slbTxrCache = _r$data.slbTxrCache, + tlbTxrCache = _r$data.tlbTxrCache; + var bb = ele.boundingBox(); + var reason = requestHighQuality === true ? eleTxrCache.reasons.highQuality : null; + if (bb.w === 0 || bb.h === 0 || !ele.visible()) { + return; + } + if (!extent || boundingBoxesIntersect(bb, extent)) { + var isEdge = ele.isEdge(); + var badLine = ele.element()._private.rscratch.badLine; + r.drawElementUnderlay(context, ele); + r.drawCachedElementPortion(context, ele, eleTxrCache, pxRatio, lvl, reason, getZeroRotation, getOpacity); + if (!isEdge || !badLine) { + r.drawCachedElementPortion(context, ele, lblTxrCache, pxRatio, lvl, reason, getLabelRotation, getTextOpacity); + } + if (isEdge && !badLine) { + r.drawCachedElementPortion(context, ele, slbTxrCache, pxRatio, lvl, reason, getSourceLabelRotation, getTextOpacity); + r.drawCachedElementPortion(context, ele, tlbTxrCache, pxRatio, lvl, reason, getTargetLabelRotation, getTextOpacity); + } + r.drawElementOverlay(context, ele); + } +}; +CRp$9.drawElements = function (context, eles) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + r.drawElement(context, ele); + } +}; +CRp$9.drawCachedElements = function (context, eles, pxRatio, extent) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + r.drawCachedElement(context, ele, pxRatio, extent); + } +}; +CRp$9.drawCachedNodes = function (context, eles, pxRatio, extent) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + r.drawCachedElement(context, ele, pxRatio, extent); + } +}; +CRp$9.drawLayeredElements = function (context, eles, pxRatio, extent) { + var r = this; + var layers = r.data.lyrTxrCache.getLayers(eles, pxRatio); + if (layers) { + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + var bb = layer.bb; + if (bb.w === 0 || bb.h === 0) { + continue; + } + context.drawImage(layer.canvas, bb.x1, bb.y1, bb.w, bb.h); + } + } else { + // fall back on plain caching if no layers + r.drawCachedElements(context, eles, pxRatio, extent); + } +}; + +var CRp$8 = {}; +CRp$8.drawEdge = function (context, edge, shiftToOriginWithBb) { + var drawLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var shouldDrawOverlay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var shouldDrawOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + var rs = edge._private.rscratch; + if (shouldDrawOpacity && !edge.visible()) { + return; + } + + // if bezier ctrl pts can not be calculated, then die + if (rs.badLine || rs.allpts == null || isNaN(rs.allpts[0])) { + // isNaN in case edge is impossible and browser bugs (e.g. safari) + return; + } + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + var opacity = shouldDrawOpacity ? edge.pstyle('opacity').value : 1; + var lineOpacity = shouldDrawOpacity ? edge.pstyle('line-opacity').value : 1; + var curveStyle = edge.pstyle('curve-style').value; + var lineStyle = edge.pstyle('line-style').value; + var edgeWidth = edge.pstyle('width').pfValue; + var lineCap = edge.pstyle('line-cap').value; + var effectiveLineOpacity = opacity * lineOpacity; + // separate arrow opacity would require arrow-opacity property + var effectiveArrowOpacity = opacity * lineOpacity; + var drawLine = function drawLine() { + var strokeOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : effectiveLineOpacity; + if (curveStyle === 'straight-triangle') { + r.eleStrokeStyle(context, edge, strokeOpacity); + r.drawEdgeTrianglePath(edge, context, rs.allpts); + } else { + context.lineWidth = edgeWidth; + context.lineCap = lineCap; + r.eleStrokeStyle(context, edge, strokeOpacity); + r.drawEdgePath(edge, context, rs.allpts, lineStyle); + context.lineCap = 'butt'; // reset for other drawing functions + } + }; + + var drawOverlay = function drawOverlay() { + if (!shouldDrawOverlay) { + return; + } + r.drawEdgeOverlay(context, edge); + }; + var drawUnderlay = function drawUnderlay() { + if (!shouldDrawOverlay) { + return; + } + r.drawEdgeUnderlay(context, edge); + }; + var drawArrows = function drawArrows() { + var arrowOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : effectiveArrowOpacity; + r.drawArrowheads(context, edge, arrowOpacity); + }; + var drawText = function drawText() { + r.drawElementText(context, edge, null, drawLabel); + }; + context.lineJoin = 'round'; + var ghost = edge.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = edge.pstyle('ghost-offset-x').pfValue; + var gy = edge.pstyle('ghost-offset-y').pfValue; + var ghostOpacity = edge.pstyle('ghost-opacity').value; + var effectiveGhostOpacity = effectiveLineOpacity * ghostOpacity; + context.translate(gx, gy); + drawLine(effectiveGhostOpacity); + drawArrows(effectiveGhostOpacity); + context.translate(-gx, -gy); + } + drawUnderlay(); + drawLine(); + drawArrows(); + drawOverlay(); + drawText(); + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +var drawEdgeOverlayUnderlay = function drawEdgeOverlayUnderlay(overlayOrUnderlay) { + if (!['overlay', 'underlay'].includes(overlayOrUnderlay)) { + throw new Error('Invalid state'); + } + return function (context, edge) { + if (!edge.visible()) { + return; + } + var opacity = edge.pstyle("".concat(overlayOrUnderlay, "-opacity")).value; + if (opacity === 0) { + return; + } + var r = this; + var usePaths = r.usePaths(); + var rs = edge._private.rscratch; + var padding = edge.pstyle("".concat(overlayOrUnderlay, "-padding")).pfValue; + var width = 2 * padding; + var color = edge.pstyle("".concat(overlayOrUnderlay, "-color")).value; + context.lineWidth = width; + if (rs.edgeType === 'self' && !usePaths) { + context.lineCap = 'butt'; + } else { + context.lineCap = 'round'; + } + r.colorStrokeStyle(context, color[0], color[1], color[2], opacity); + r.drawEdgePath(edge, context, rs.allpts, 'solid'); + }; +}; +CRp$8.drawEdgeOverlay = drawEdgeOverlayUnderlay('overlay'); +CRp$8.drawEdgeUnderlay = drawEdgeOverlayUnderlay('underlay'); +CRp$8.drawEdgePath = function (edge, context, pts, type) { + var rs = edge._private.rscratch; + var canvasCxt = context; + var path; + var pathCacheHit = false; + var usePaths = this.usePaths(); + var lineDashPattern = edge.pstyle('line-dash-pattern').pfValue; + var lineDashOffset = edge.pstyle('line-dash-offset').pfValue; + if (usePaths) { + var pathCacheKey = pts.join('$'); + var keyMatches = rs.pathCacheKey && rs.pathCacheKey === pathCacheKey; + if (keyMatches) { + path = context = rs.pathCache; + pathCacheHit = true; + } else { + path = context = new Path2D(); + rs.pathCacheKey = pathCacheKey; + rs.pathCache = path; + } + } + if (canvasCxt.setLineDash) { + // for very outofdate browsers + switch (type) { + case 'dotted': + canvasCxt.setLineDash([1, 1]); + break; + case 'dashed': + canvasCxt.setLineDash(lineDashPattern); + canvasCxt.lineDashOffset = lineDashOffset; + break; + case 'solid': + canvasCxt.setLineDash([]); + break; + } + } + if (!pathCacheHit && !rs.badLine) { + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(pts[0], pts[1]); + switch (rs.edgeType) { + case 'bezier': + case 'self': + case 'compound': + case 'multibezier': + for (var i = 2; i + 3 < pts.length; i += 4) { + context.quadraticCurveTo(pts[i], pts[i + 1], pts[i + 2], pts[i + 3]); + } + break; + case 'straight': + case 'haystack': + for (var _i = 2; _i + 1 < pts.length; _i += 2) { + context.lineTo(pts[_i], pts[_i + 1]); + } + break; + case 'segments': + if (rs.isRound) { + var _iterator = _createForOfIteratorHelper(rs.roundCorners), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var corner = _step.value; + drawPreparedRoundCorner(context, corner); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + context.lineTo(pts[pts.length - 2], pts[pts.length - 1]); + } else { + for (var _i2 = 2; _i2 + 1 < pts.length; _i2 += 2) { + context.lineTo(pts[_i2], pts[_i2 + 1]); + } + } + break; + } + } + context = canvasCxt; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + + // reset any line dashes + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } +}; +CRp$8.drawEdgeTrianglePath = function (edge, context, pts) { + // use line stroke style for triangle fill style + context.fillStyle = context.strokeStyle; + var edgeWidth = edge.pstyle('width').pfValue; + for (var i = 0; i + 1 < pts.length; i += 2) { + var vector = [pts[i + 2] - pts[i], pts[i + 3] - pts[i + 1]]; + var length = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + var normal = [vector[1] / length, -vector[0] / length]; + var triangleHead = [normal[0] * edgeWidth / 2, normal[1] * edgeWidth / 2]; + context.beginPath(); + context.moveTo(pts[i] - triangleHead[0], pts[i + 1] - triangleHead[1]); + context.lineTo(pts[i] + triangleHead[0], pts[i + 1] + triangleHead[1]); + context.lineTo(pts[i + 2], pts[i + 3]); + context.closePath(); + context.fill(); + } +}; +CRp$8.drawArrowheads = function (context, edge, opacity) { + var rs = edge._private.rscratch; + var isHaystack = rs.edgeType === 'haystack'; + if (!isHaystack) { + this.drawArrowhead(context, edge, 'source', rs.arrowStartX, rs.arrowStartY, rs.srcArrowAngle, opacity); + } + this.drawArrowhead(context, edge, 'mid-target', rs.midX, rs.midY, rs.midtgtArrowAngle, opacity); + this.drawArrowhead(context, edge, 'mid-source', rs.midX, rs.midY, rs.midsrcArrowAngle, opacity); + if (!isHaystack) { + this.drawArrowhead(context, edge, 'target', rs.arrowEndX, rs.arrowEndY, rs.tgtArrowAngle, opacity); + } +}; +CRp$8.drawArrowhead = function (context, edge, prefix, x, y, angle, opacity) { + if (isNaN(x) || x == null || isNaN(y) || y == null || isNaN(angle) || angle == null) { + return; + } + var self = this; + var arrowShape = edge.pstyle(prefix + '-arrow-shape').value; + if (arrowShape === 'none') { + return; + } + var arrowClearFill = edge.pstyle(prefix + '-arrow-fill').value === 'hollow' ? 'both' : 'filled'; + var arrowFill = edge.pstyle(prefix + '-arrow-fill').value; + var edgeWidth = edge.pstyle('width').pfValue; + var pArrowWidth = edge.pstyle(prefix + '-arrow-width'); + var arrowWidth = pArrowWidth.value === 'match-line' ? edgeWidth : pArrowWidth.pfValue; + if (pArrowWidth.units === '%') arrowWidth *= edgeWidth; + var edgeOpacity = edge.pstyle('opacity').value; + if (opacity === undefined) { + opacity = edgeOpacity; + } + var gco = context.globalCompositeOperation; + if (opacity !== 1 || arrowFill === 'hollow') { + // then extra clear is needed + context.globalCompositeOperation = 'destination-out'; + self.colorFillStyle(context, 255, 255, 255, 1); + self.colorStrokeStyle(context, 255, 255, 255, 1); + self.drawArrowShape(edge, context, arrowClearFill, edgeWidth, arrowShape, arrowWidth, x, y, angle); + context.globalCompositeOperation = gco; + } // otherwise, the opaque arrow clears it for free :) + + var color = edge.pstyle(prefix + '-arrow-color').value; + self.colorFillStyle(context, color[0], color[1], color[2], opacity); + self.colorStrokeStyle(context, color[0], color[1], color[2], opacity); + self.drawArrowShape(edge, context, arrowFill, edgeWidth, arrowShape, arrowWidth, x, y, angle); +}; +CRp$8.drawArrowShape = function (edge, context, fill, edgeWidth, shape, shapeWidth, x, y, angle) { + var r = this; + var usePaths = this.usePaths() && shape !== 'triangle-cross'; + var pathCacheHit = false; + var path; + var canvasContext = context; + var translation = { + x: x, + y: y + }; + var scale = edge.pstyle('arrow-scale').value; + var size = this.getArrowWidth(edgeWidth, scale); + var shapeImpl = r.arrowShapes[shape]; + if (usePaths) { + var cache = r.arrowPathCache = r.arrowPathCache || []; + var key = hashString(shape); + var cachedPath = cache[key]; + if (cachedPath != null) { + path = context = cachedPath; + pathCacheHit = true; + } else { + path = context = new Path2D(); + cache[key] = path; + } + } + if (!pathCacheHit) { + if (context.beginPath) { + context.beginPath(); + } + if (usePaths) { + // store in the path cache with values easily manipulated later + shapeImpl.draw(context, 1, 0, { + x: 0, + y: 0 + }, 1); + } else { + shapeImpl.draw(context, size, angle, translation, edgeWidth); + } + if (context.closePath) { + context.closePath(); + } + } + context = canvasContext; + if (usePaths) { + // set transform to arrow position/orientation + context.translate(x, y); + context.rotate(angle); + context.scale(size, size); + } + if (fill === 'filled' || fill === 'both') { + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + } + if (fill === 'hollow' || fill === 'both') { + context.lineWidth = shapeWidth / (usePaths ? size : 1); + context.lineJoin = 'miter'; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + } + if (usePaths) { + // reset transform by applying inverse + context.scale(1 / size, 1 / size); + context.rotate(-angle); + context.translate(-x, -y); + } +}; + +var CRp$7 = {}; +CRp$7.safeDrawImage = function (context, img, ix, iy, iw, ih, x, y, w, h) { + // detect problematic cases for old browsers with bad images (cheaper than try-catch) + if (iw <= 0 || ih <= 0 || w <= 0 || h <= 0) { + return; + } + try { + context.drawImage(img, ix, iy, iw, ih, x, y, w, h); + } catch (e) { + warn(e); + } +}; +CRp$7.drawInscribedImage = function (context, img, node, index, nodeOpacity) { + var r = this; + var pos = node.position(); + var nodeX = pos.x; + var nodeY = pos.y; + var styleObj = node.cy().style(); + var getIndexedStyle = styleObj.getIndexedStyle.bind(styleObj); + var fit = getIndexedStyle(node, 'background-fit', 'value', index); + var repeat = getIndexedStyle(node, 'background-repeat', 'value', index); + var nodeW = node.width(); + var nodeH = node.height(); + var paddingX2 = node.padding() * 2; + var nodeTW = nodeW + (getIndexedStyle(node, 'background-width-relative-to', 'value', index) === 'inner' ? 0 : paddingX2); + var nodeTH = nodeH + (getIndexedStyle(node, 'background-height-relative-to', 'value', index) === 'inner' ? 0 : paddingX2); + var rs = node._private.rscratch; + var clip = getIndexedStyle(node, 'background-clip', 'value', index); + var shouldClip = clip === 'node'; + var imgOpacity = getIndexedStyle(node, 'background-image-opacity', 'value', index) * nodeOpacity; + var smooth = getIndexedStyle(node, 'background-image-smoothing', 'value', index); + var cornerRadius = node.pstyle('corner-radius').value; + if (cornerRadius !== 'auto') cornerRadius = node.pstyle('corner-radius').pfValue; + var imgW = img.width || img.cachedW; + var imgH = img.height || img.cachedH; + + // workaround for broken browsers like ie + if (null == imgW || null == imgH) { + document.body.appendChild(img); // eslint-disable-line no-undef + + imgW = img.cachedW = img.width || img.offsetWidth; + imgH = img.cachedH = img.height || img.offsetHeight; + document.body.removeChild(img); // eslint-disable-line no-undef + } + + var w = imgW; + var h = imgH; + if (getIndexedStyle(node, 'background-width', 'value', index) !== 'auto') { + if (getIndexedStyle(node, 'background-width', 'units', index) === '%') { + w = getIndexedStyle(node, 'background-width', 'pfValue', index) * nodeTW; + } else { + w = getIndexedStyle(node, 'background-width', 'pfValue', index); + } + } + if (getIndexedStyle(node, 'background-height', 'value', index) !== 'auto') { + if (getIndexedStyle(node, 'background-height', 'units', index) === '%') { + h = getIndexedStyle(node, 'background-height', 'pfValue', index) * nodeTH; + } else { + h = getIndexedStyle(node, 'background-height', 'pfValue', index); + } + } + if (w === 0 || h === 0) { + return; // no point in drawing empty image (and chrome is broken in this case) + } + + if (fit === 'contain') { + var scale = Math.min(nodeTW / w, nodeTH / h); + w *= scale; + h *= scale; + } else if (fit === 'cover') { + var scale = Math.max(nodeTW / w, nodeTH / h); + w *= scale; + h *= scale; + } + var x = nodeX - nodeTW / 2; // left + var posXUnits = getIndexedStyle(node, 'background-position-x', 'units', index); + var posXPfVal = getIndexedStyle(node, 'background-position-x', 'pfValue', index); + if (posXUnits === '%') { + x += (nodeTW - w) * posXPfVal; + } else { + x += posXPfVal; + } + var offXUnits = getIndexedStyle(node, 'background-offset-x', 'units', index); + var offXPfVal = getIndexedStyle(node, 'background-offset-x', 'pfValue', index); + if (offXUnits === '%') { + x += (nodeTW - w) * offXPfVal; + } else { + x += offXPfVal; + } + var y = nodeY - nodeTH / 2; // top + var posYUnits = getIndexedStyle(node, 'background-position-y', 'units', index); + var posYPfVal = getIndexedStyle(node, 'background-position-y', 'pfValue', index); + if (posYUnits === '%') { + y += (nodeTH - h) * posYPfVal; + } else { + y += posYPfVal; + } + var offYUnits = getIndexedStyle(node, 'background-offset-y', 'units', index); + var offYPfVal = getIndexedStyle(node, 'background-offset-y', 'pfValue', index); + if (offYUnits === '%') { + y += (nodeTH - h) * offYPfVal; + } else { + y += offYPfVal; + } + if (rs.pathCache) { + x -= nodeX; + y -= nodeY; + nodeX = 0; + nodeY = 0; + } + var gAlpha = context.globalAlpha; + context.globalAlpha = imgOpacity; + var smoothingEnabled = r.getImgSmoothing(context); + var isSmoothingSwitched = false; + if (smooth === 'no' && smoothingEnabled) { + r.setImgSmoothing(context, false); + isSmoothingSwitched = true; + } else if (smooth === 'yes' && !smoothingEnabled) { + r.setImgSmoothing(context, true); + isSmoothingSwitched = true; + } + if (repeat === 'no-repeat') { + if (shouldClip) { + context.save(); + if (rs.pathCache) { + context.clip(rs.pathCache); + } else { + r.nodeShapes[r.getNodeShape(node)].draw(context, nodeX, nodeY, nodeTW, nodeTH, cornerRadius, rs); + context.clip(); + } + } + r.safeDrawImage(context, img, 0, 0, imgW, imgH, x, y, w, h); + if (shouldClip) { + context.restore(); + } + } else { + var pattern = context.createPattern(img, repeat); + context.fillStyle = pattern; + r.nodeShapes[r.getNodeShape(node)].draw(context, nodeX, nodeY, nodeTW, nodeTH, cornerRadius, rs); + context.translate(x, y); + context.fill(); + context.translate(-x, -y); + } + context.globalAlpha = gAlpha; + if (isSmoothingSwitched) { + r.setImgSmoothing(context, smoothingEnabled); + } +}; + +var CRp$6 = {}; +CRp$6.eleTextBiggerThanMin = function (ele, scale) { + if (!scale) { + var zoom = ele.cy().zoom(); + var pxRatio = this.getPixelRatio(); + var lvl = Math.ceil(log2(zoom * pxRatio)); // the effective texture level + + scale = Math.pow(2, lvl); + } + var computedSize = ele.pstyle('font-size').pfValue * scale; + var minSize = ele.pstyle('min-zoomed-font-size').pfValue; + if (computedSize < minSize) { + return false; + } + return true; +}; +CRp$6.drawElementText = function (context, ele, shiftToOriginWithBb, force, prefix) { + var useEleOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + if (force == null) { + if (useEleOpacity && !r.eleTextBiggerThanMin(ele)) { + return; + } + } else if (force === false) { + return; + } + if (ele.isNode()) { + var label = ele.pstyle('label'); + if (!label || !label.value) { + return; + } + var justification = r.getLabelJustification(ele); + context.textAlign = justification; + context.textBaseline = 'bottom'; + } else { + var badLine = ele.element()._private.rscratch.badLine; + var _label = ele.pstyle('label'); + var srcLabel = ele.pstyle('source-label'); + var tgtLabel = ele.pstyle('target-label'); + if (badLine || (!_label || !_label.value) && (!srcLabel || !srcLabel.value) && (!tgtLabel || !tgtLabel.value)) { + return; + } + context.textAlign = 'center'; + context.textBaseline = 'bottom'; + } + var applyRotation = !shiftToOriginWithBb; + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + if (prefix == null) { + r.drawText(context, ele, null, applyRotation, useEleOpacity); + if (ele.isEdge()) { + r.drawText(context, ele, 'source', applyRotation, useEleOpacity); + r.drawText(context, ele, 'target', applyRotation, useEleOpacity); + } + } else { + r.drawText(context, ele, prefix, applyRotation, useEleOpacity); + } + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +CRp$6.getFontCache = function (context) { + var cache; + this.fontCaches = this.fontCaches || []; + for (var i = 0; i < this.fontCaches.length; i++) { + cache = this.fontCaches[i]; + if (cache.context === context) { + return cache; + } + } + cache = { + context: context + }; + this.fontCaches.push(cache); + return cache; +}; + +// set up canvas context with font +// returns transformed text string +CRp$6.setupTextStyle = function (context, ele) { + var useEleOpacity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + // Font style + var labelStyle = ele.pstyle('font-style').strValue; + var labelSize = ele.pstyle('font-size').pfValue + 'px'; + var labelFamily = ele.pstyle('font-family').strValue; + var labelWeight = ele.pstyle('font-weight').strValue; + var opacity = useEleOpacity ? ele.effectiveOpacity() * ele.pstyle('text-opacity').value : 1; + var outlineOpacity = ele.pstyle('text-outline-opacity').value * opacity; + var color = ele.pstyle('color').value; + var outlineColor = ele.pstyle('text-outline-color').value; + context.font = labelStyle + ' ' + labelWeight + ' ' + labelSize + ' ' + labelFamily; + context.lineJoin = 'round'; // so text outlines aren't jagged + + this.colorFillStyle(context, color[0], color[1], color[2], opacity); + this.colorStrokeStyle(context, outlineColor[0], outlineColor[1], outlineColor[2], outlineOpacity); +}; + +// TODO ensure re-used +function roundRect(ctx, x, y, width, height) { + var radius = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 5; + var stroke = arguments.length > 6 ? arguments[6] : undefined; + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + if (stroke) ctx.stroke();else ctx.fill(); +} +CRp$6.getTextAngle = function (ele, prefix) { + var theta; + var _p = ele._private; + var rscratch = _p.rscratch; + var pdash = prefix ? prefix + '-' : ''; + var rotation = ele.pstyle(pdash + 'text-rotation'); + var textAngle = getPrefixedProperty(rscratch, 'labelAngle', prefix); + if (rotation.strValue === 'autorotate') { + theta = ele.isEdge() ? textAngle : 0; + } else if (rotation.strValue === 'none') { + theta = 0; + } else { + theta = rotation.pfValue; + } + return theta; +}; +CRp$6.drawText = function (context, ele, prefix) { + var applyRotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var useEleOpacity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var _p = ele._private; + var rscratch = _p.rscratch; + var parentOpacity = useEleOpacity ? ele.effectiveOpacity() : 1; + if (useEleOpacity && (parentOpacity === 0 || ele.pstyle('text-opacity').value === 0)) { + return; + } + + // use 'main' as an alias for the main label (i.e. null prefix) + if (prefix === 'main') { + prefix = null; + } + var textX = getPrefixedProperty(rscratch, 'labelX', prefix); + var textY = getPrefixedProperty(rscratch, 'labelY', prefix); + var orgTextX, orgTextY; // used for rotation + var text = this.getLabelText(ele, prefix); + if (text != null && text !== '' && !isNaN(textX) && !isNaN(textY)) { + this.setupTextStyle(context, ele, useEleOpacity); + var pdash = prefix ? prefix + '-' : ''; + var textW = getPrefixedProperty(rscratch, 'labelWidth', prefix); + var textH = getPrefixedProperty(rscratch, 'labelHeight', prefix); + var marginX = ele.pstyle(pdash + 'text-margin-x').pfValue; + var marginY = ele.pstyle(pdash + 'text-margin-y').pfValue; + var isEdge = ele.isEdge(); + var halign = ele.pstyle('text-halign').value; + var valign = ele.pstyle('text-valign').value; + if (isEdge) { + halign = 'center'; + valign = 'center'; + } + textX += marginX; + textY += marginY; + var theta; + if (!applyRotation) { + theta = 0; + } else { + theta = this.getTextAngle(ele, prefix); + } + if (theta !== 0) { + orgTextX = textX; + orgTextY = textY; + context.translate(orgTextX, orgTextY); + context.rotate(theta); + textX = 0; + textY = 0; + } + switch (valign) { + case 'top': + break; + case 'center': + textY += textH / 2; + break; + case 'bottom': + textY += textH; + break; + } + var backgroundOpacity = ele.pstyle('text-background-opacity').value; + var borderOpacity = ele.pstyle('text-border-opacity').value; + var textBorderWidth = ele.pstyle('text-border-width').pfValue; + var backgroundPadding = ele.pstyle('text-background-padding').pfValue; + var styleShape = ele.pstyle('text-background-shape').strValue; + var rounded = styleShape.indexOf('round') === 0; + var roundRadius = 2; + if (backgroundOpacity > 0 || textBorderWidth > 0 && borderOpacity > 0) { + var bgX = textX - backgroundPadding; + switch (halign) { + case 'left': + bgX -= textW; + break; + case 'center': + bgX -= textW / 2; + break; + } + var bgY = textY - textH - backgroundPadding; + var bgW = textW + 2 * backgroundPadding; + var bgH = textH + 2 * backgroundPadding; + if (backgroundOpacity > 0) { + var textFill = context.fillStyle; + var textBackgroundColor = ele.pstyle('text-background-color').value; + context.fillStyle = 'rgba(' + textBackgroundColor[0] + ',' + textBackgroundColor[1] + ',' + textBackgroundColor[2] + ',' + backgroundOpacity * parentOpacity + ')'; + if (rounded) { + roundRect(context, bgX, bgY, bgW, bgH, roundRadius); + } else { + context.fillRect(bgX, bgY, bgW, bgH); + } + context.fillStyle = textFill; + } + if (textBorderWidth > 0 && borderOpacity > 0) { + var textStroke = context.strokeStyle; + var textLineWidth = context.lineWidth; + var textBorderColor = ele.pstyle('text-border-color').value; + var textBorderStyle = ele.pstyle('text-border-style').value; + context.strokeStyle = 'rgba(' + textBorderColor[0] + ',' + textBorderColor[1] + ',' + textBorderColor[2] + ',' + borderOpacity * parentOpacity + ')'; + context.lineWidth = textBorderWidth; + if (context.setLineDash) { + // for very outofdate browsers + switch (textBorderStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash([4, 2]); + break; + case 'double': + context.lineWidth = textBorderWidth / 4; // 50% reserved for white between the two borders + context.setLineDash([]); + break; + case 'solid': + context.setLineDash([]); + break; + } + } + if (rounded) { + roundRect(context, bgX, bgY, bgW, bgH, roundRadius, 'stroke'); + } else { + context.strokeRect(bgX, bgY, bgW, bgH); + } + if (textBorderStyle === 'double') { + var whiteWidth = textBorderWidth / 2; + if (rounded) { + roundRect(context, bgX + whiteWidth, bgY + whiteWidth, bgW - whiteWidth * 2, bgH - whiteWidth * 2, roundRadius, 'stroke'); + } else { + context.strokeRect(bgX + whiteWidth, bgY + whiteWidth, bgW - whiteWidth * 2, bgH - whiteWidth * 2); + } + } + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + context.lineWidth = textLineWidth; + context.strokeStyle = textStroke; + } + } + var lineWidth = 2 * ele.pstyle('text-outline-width').pfValue; // *2 b/c the stroke is drawn centred on the middle + + if (lineWidth > 0) { + context.lineWidth = lineWidth; + } + if (ele.pstyle('text-wrap').value === 'wrap') { + var lines = getPrefixedProperty(rscratch, 'labelWrapCachedLines', prefix); + var lineHeight = getPrefixedProperty(rscratch, 'labelLineHeight', prefix); + var halfTextW = textW / 2; + var justification = this.getLabelJustification(ele); + if (justification === 'auto') ; else if (halign === 'left') { + // auto justification : right + if (justification === 'left') { + textX += -textW; + } else if (justification === 'center') { + textX += -halfTextW; + } // else same as auto + } else if (halign === 'center') { + // auto justfication : center + if (justification === 'left') { + textX += -halfTextW; + } else if (justification === 'right') { + textX += halfTextW; + } // else same as auto + } else if (halign === 'right') { + // auto justification : left + if (justification === 'center') { + textX += halfTextW; + } else if (justification === 'right') { + textX += textW; + } // else same as auto + } + + switch (valign) { + case 'top': + textY -= (lines.length - 1) * lineHeight; + break; + case 'center': + case 'bottom': + textY -= (lines.length - 1) * lineHeight; + break; + } + for (var l = 0; l < lines.length; l++) { + if (lineWidth > 0) { + context.strokeText(lines[l], textX, textY); + } + context.fillText(lines[l], textX, textY); + textY += lineHeight; + } + } else { + if (lineWidth > 0) { + context.strokeText(text, textX, textY); + } + context.fillText(text, textX, textY); + } + if (theta !== 0) { + context.rotate(-theta); + context.translate(-orgTextX, -orgTextY); + } + } +}; + +/* global Path2D */ +var CRp$5 = {}; +CRp$5.drawNode = function (context, node, shiftToOriginWithBb) { + var drawLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var shouldDrawOverlay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var shouldDrawOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + var nodeWidth, nodeHeight; + var _p = node._private; + var rs = _p.rscratch; + var pos = node.position(); + if (!number$1(pos.x) || !number$1(pos.y)) { + return; // can't draw node with undefined position + } + + if (shouldDrawOpacity && !node.visible()) { + return; + } + var eleOpacity = shouldDrawOpacity ? node.effectiveOpacity() : 1; + var usePaths = r.usePaths(); + var path; + var pathCacheHit = false; + var padding = node.padding(); + nodeWidth = node.width() + 2 * padding; + nodeHeight = node.height() + 2 * padding; + + // + // setup shift + + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + + // + // load bg image + + var bgImgProp = node.pstyle('background-image'); + var urls = bgImgProp.value; + var urlDefined = new Array(urls.length); + var image = new Array(urls.length); + var numImages = 0; + for (var i = 0; i < urls.length; i++) { + var url = urls[i]; + var defd = urlDefined[i] = url != null && url !== 'none'; + if (defd) { + var bgImgCrossOrigin = node.cy().style().getIndexedStyle(node, 'background-image-crossorigin', 'value', i); + numImages++; + + // get image, and if not loaded then ask to redraw when later loaded + image[i] = r.getCachedImage(url, bgImgCrossOrigin, function () { + _p.backgroundTimestamp = Date.now(); + node.emitAndNotify('background'); + }); + } + } + + // + // setup styles + + var darkness = node.pstyle('background-blacken').value; + var borderWidth = node.pstyle('border-width').pfValue; + var bgOpacity = node.pstyle('background-opacity').value * eleOpacity; + var borderColor = node.pstyle('border-color').value; + var borderStyle = node.pstyle('border-style').value; + var borderJoin = node.pstyle('border-join').value; + var borderCap = node.pstyle('border-cap').value; + var borderPosition = node.pstyle('border-position').value; + var borderPattern = node.pstyle('border-dash-pattern').pfValue; + var borderOffset = node.pstyle('border-dash-offset').pfValue; + var borderOpacity = node.pstyle('border-opacity').value * eleOpacity; + var outlineWidth = node.pstyle('outline-width').pfValue; + var outlineColor = node.pstyle('outline-color').value; + var outlineStyle = node.pstyle('outline-style').value; + var outlineOpacity = node.pstyle('outline-opacity').value * eleOpacity; + var outlineOffset = node.pstyle('outline-offset').value; + var cornerRadius = node.pstyle('corner-radius').value; + if (cornerRadius !== 'auto') cornerRadius = node.pstyle('corner-radius').pfValue; + var setupShapeColor = function setupShapeColor() { + var bgOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bgOpacity; + r.eleFillStyle(context, node, bgOpy); + }; + var setupBorderColor = function setupBorderColor() { + var bdrOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : borderOpacity; + r.colorStrokeStyle(context, borderColor[0], borderColor[1], borderColor[2], bdrOpy); + }; + var setupOutlineColor = function setupOutlineColor() { + var otlnOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : outlineOpacity; + r.colorStrokeStyle(context, outlineColor[0], outlineColor[1], outlineColor[2], otlnOpy); + }; + + // + // setup shape + + var getPath = function getPath(width, height, shape, points) { + var pathCache = r.nodePathCache = r.nodePathCache || []; + var key = hashStrings(shape === 'polygon' ? shape + ',' + points.join(',') : shape, '' + height, '' + width, '' + cornerRadius); + var cachedPath = pathCache[key]; + var path; + var cacheHit = false; + if (cachedPath != null) { + path = cachedPath; + cacheHit = true; + rs.pathCache = path; + } else { + path = new Path2D(); + pathCache[key] = rs.pathCache = path; + } + return { + path: path, + cacheHit: cacheHit + }; + }; + var styleShape = node.pstyle('shape').strValue; + var shapePts = node.pstyle('shape-polygon-points').pfValue; + if (usePaths) { + context.translate(pos.x, pos.y); + var shapePath = getPath(nodeWidth, nodeHeight, styleShape, shapePts); + path = shapePath.path; + pathCacheHit = shapePath.cacheHit; + } + var drawShape = function drawShape() { + if (!pathCacheHit) { + var npos = pos; + if (usePaths) { + npos = { + x: 0, + y: 0 + }; + } + r.nodeShapes[r.getNodeShape(node)].draw(path || context, npos.x, npos.y, nodeWidth, nodeHeight, cornerRadius, rs); + } + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + }; + var drawImages = function drawImages() { + var nodeOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eleOpacity; + var inside = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var prevBging = _p.backgrounding; + var totalCompleted = 0; + for (var _i = 0; _i < image.length; _i++) { + var bgContainment = node.cy().style().getIndexedStyle(node, 'background-image-containment', 'value', _i); + if (inside && bgContainment === 'over' || !inside && bgContainment === 'inside') { + totalCompleted++; + continue; + } + if (urlDefined[_i] && image[_i].complete && !image[_i].error) { + totalCompleted++; + r.drawInscribedImage(context, image[_i], node, _i, nodeOpacity); + } + } + _p.backgrounding = !(totalCompleted === numImages); + if (prevBging !== _p.backgrounding) { + // update style b/c :backgrounding state changed + node.updateStyle(false); + } + }; + var drawPie = function drawPie() { + var redrawShape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var pieOpacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : eleOpacity; + if (r.hasPie(node)) { + r.drawPie(context, node, pieOpacity); + + // redraw/restore path if steps after pie need it + if (redrawShape) { + if (!usePaths) { + r.nodeShapes[r.getNodeShape(node)].draw(context, pos.x, pos.y, nodeWidth, nodeHeight, cornerRadius, rs); + } + } + } + }; + var darken = function darken() { + var darkenOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eleOpacity; + var opacity = (darkness > 0 ? darkness : -darkness) * darkenOpacity; + var c = darkness > 0 ? 0 : 255; + if (darkness !== 0) { + r.colorFillStyle(context, c, c, c, opacity); + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + } + }; + var drawBorder = function drawBorder() { + if (borderWidth > 0) { + context.lineWidth = borderWidth; + context.lineCap = borderCap; + context.lineJoin = borderJoin; + if (context.setLineDash) { + // for very outofdate browsers + switch (borderStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash(borderPattern); + context.lineDashOffset = borderOffset; + break; + case 'solid': + case 'double': + context.setLineDash([]); + break; + } + } + if (borderPosition !== 'center') { + context.save(); + context.lineWidth *= 2; + if (borderPosition === 'inside') { + usePaths ? context.clip(path) : context.clip(); + } else { + var region = new Path2D(); + region.rect(-nodeWidth / 2 - borderWidth, -nodeHeight / 2 - borderWidth, nodeWidth + 2 * borderWidth, nodeHeight + 2 * borderWidth); + region.addPath(path); + context.clip(region, 'evenodd'); + } + usePaths ? context.stroke(path) : context.stroke(); + context.restore(); + } else { + usePaths ? context.stroke(path) : context.stroke(); + } + if (borderStyle === 'double') { + context.lineWidth = borderWidth / 3; + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + context.globalCompositeOperation = gco; + } + + // reset in case we changed the border style + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + } + }; + var drawOutline = function drawOutline() { + if (outlineWidth > 0) { + context.lineWidth = outlineWidth; + context.lineCap = 'butt'; + if (context.setLineDash) { + // for very outofdate browsers + switch (outlineStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash([4, 2]); + break; + case 'solid': + case 'double': + context.setLineDash([]); + break; + } + } + var npos = pos; + if (usePaths) { + npos = { + x: 0, + y: 0 + }; + } + var shape = r.getNodeShape(node); + var bWidth = borderWidth; + if (borderPosition === 'inside') bWidth = 0; + if (borderPosition === 'outside') bWidth *= 2; + var scaleX = (nodeWidth + bWidth + (outlineWidth + outlineOffset)) / nodeWidth; + var scaleY = (nodeHeight + bWidth + (outlineWidth + outlineOffset)) / nodeHeight; + var sWidth = nodeWidth * scaleX; + var sHeight = nodeHeight * scaleY; + var points = r.nodeShapes[shape].points; + var _path; + if (usePaths) { + var outlinePath = getPath(sWidth, sHeight, shape, points); + _path = outlinePath.path; + } + + // draw the outline path, either by using expanded points or by scaling + // the dimensions, depending on shape + if (shape === "ellipse") { + r.drawEllipsePath(_path || context, npos.x, npos.y, sWidth, sHeight); + } else if (['round-diamond', 'round-heptagon', 'round-hexagon', 'round-octagon', 'round-pentagon', 'round-polygon', 'round-triangle', 'round-tag'].includes(shape)) { + var sMult = 0; + var offsetX = 0; + var offsetY = 0; + if (shape === 'round-diamond') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.4; + } else if (shape === 'round-heptagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.075; + offsetY = -(bWidth / 2 + outlineOffset + outlineWidth) / 35; + } else if (shape === 'round-hexagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.12; + } else if (shape === 'round-pentagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.13; + offsetY = -(bWidth / 2 + outlineOffset + outlineWidth) / 15; + } else if (shape === 'round-tag') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.12; + offsetX = (bWidth / 2 + outlineWidth + outlineOffset) * .07; + } else if (shape === 'round-triangle') { + sMult = (bWidth + outlineOffset + outlineWidth) * (Math.PI / 2); + offsetY = -(bWidth + outlineOffset / 2 + outlineWidth) / Math.PI; + } + if (sMult !== 0) { + scaleX = (nodeWidth + sMult) / nodeWidth; + sWidth = nodeWidth * scaleX; + if (!['round-hexagon', 'round-tag'].includes(shape)) { + scaleY = (nodeHeight + sMult) / nodeHeight; + sHeight = nodeHeight * scaleY; + } + } + cornerRadius = cornerRadius === 'auto' ? getRoundPolygonRadius(sWidth, sHeight) : cornerRadius; + var halfW = sWidth / 2; + var halfH = sHeight / 2; + var radius = cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2; + var p = new Array(points.length / 2); + var corners = new Array(points.length / 2); + for (var _i3 = 0; _i3 < points.length / 2; _i3++) { + p[_i3] = { + x: npos.x + offsetX + halfW * points[_i3 * 2], + y: npos.y + offsetY + halfH * points[_i3 * 2 + 1] + }; + } + var _i2, + p1, + p2, + p3, + len = p.length; + p1 = p[len - 1]; + // for each point + for (_i2 = 0; _i2 < len; _i2++) { + p2 = p[_i2 % len]; + p3 = p[(_i2 + 1) % len]; + corners[_i2] = getRoundCorner(p1, p2, p3, radius); + p1 = p2; + p2 = p3; + } + r.drawRoundPolygonPath(_path || context, npos.x + offsetX, npos.y + offsetY, nodeWidth * scaleX, nodeHeight * scaleY, points, corners); + } else if (['roundrectangle', 'round-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(sWidth, sHeight) : cornerRadius; + r.drawRoundRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2); + } else if (['cutrectangle', 'cut-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getCutRectangleCornerLength() : cornerRadius; + r.drawCutRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, null, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 4); + } else if (['bottomroundrectangle', 'bottom-round-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(sWidth, sHeight) : cornerRadius; + r.drawBottomRoundRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2); + } else if (shape === "barrel") { + r.drawBarrelPath(_path || context, npos.x, npos.y, sWidth, sHeight); + } else if (shape.startsWith("polygon") || ['rhomboid', 'right-rhomboid', 'round-tag', 'tag', 'vee'].includes(shape)) { + var pad = (bWidth + outlineWidth + outlineOffset) / nodeWidth; + points = joinLines(expandPolygon(points, pad)); + r.drawPolygonPath(_path || context, npos.x, npos.y, nodeWidth, nodeHeight, points); + } else { + var _pad = (bWidth + outlineWidth + outlineOffset) / nodeWidth; + points = joinLines(expandPolygon(points, -_pad)); + r.drawPolygonPath(_path || context, npos.x, npos.y, nodeWidth, nodeHeight, points); + } + if (usePaths) { + context.stroke(_path); + } else { + context.stroke(); + } + if (outlineStyle === 'double') { + context.lineWidth = bWidth / 3; + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + if (usePaths) { + context.stroke(_path); + } else { + context.stroke(); + } + context.globalCompositeOperation = gco; + } + + // reset in case we changed the border style + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + } + }; + var drawOverlay = function drawOverlay() { + if (shouldDrawOverlay) { + r.drawNodeOverlay(context, node, pos, nodeWidth, nodeHeight); + } + }; + var drawUnderlay = function drawUnderlay() { + if (shouldDrawOverlay) { + r.drawNodeUnderlay(context, node, pos, nodeWidth, nodeHeight); + } + }; + var drawText = function drawText() { + r.drawElementText(context, node, null, drawLabel); + }; + var ghost = node.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = node.pstyle('ghost-offset-x').pfValue; + var gy = node.pstyle('ghost-offset-y').pfValue; + var ghostOpacity = node.pstyle('ghost-opacity').value; + var effGhostOpacity = ghostOpacity * eleOpacity; + context.translate(gx, gy); + setupOutlineColor(); + drawOutline(); + setupShapeColor(ghostOpacity * bgOpacity); + drawShape(); + drawImages(effGhostOpacity, true); + setupBorderColor(ghostOpacity * borderOpacity); + drawBorder(); + drawPie(darkness !== 0 || borderWidth !== 0); + drawImages(effGhostOpacity, false); + darken(effGhostOpacity); + context.translate(-gx, -gy); + } + if (usePaths) { + context.translate(-pos.x, -pos.y); + } + drawUnderlay(); + if (usePaths) { + context.translate(pos.x, pos.y); + } + setupOutlineColor(); + drawOutline(); + setupShapeColor(); + drawShape(); + drawImages(eleOpacity, true); + setupBorderColor(); + drawBorder(); + drawPie(darkness !== 0 || borderWidth !== 0); + drawImages(eleOpacity, false); + darken(); + if (usePaths) { + context.translate(-pos.x, -pos.y); + } + drawText(); + drawOverlay(); + + // + // clean up shift + + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +var drawNodeOverlayUnderlay = function drawNodeOverlayUnderlay(overlayOrUnderlay) { + if (!['overlay', 'underlay'].includes(overlayOrUnderlay)) { + throw new Error('Invalid state'); + } + return function (context, node, pos, nodeWidth, nodeHeight) { + var r = this; + if (!node.visible()) { + return; + } + var padding = node.pstyle("".concat(overlayOrUnderlay, "-padding")).pfValue; + var opacity = node.pstyle("".concat(overlayOrUnderlay, "-opacity")).value; + var color = node.pstyle("".concat(overlayOrUnderlay, "-color")).value; + var shape = node.pstyle("".concat(overlayOrUnderlay, "-shape")).value; + var radius = node.pstyle("".concat(overlayOrUnderlay, "-corner-radius")).value; + if (opacity > 0) { + pos = pos || node.position(); + if (nodeWidth == null || nodeHeight == null) { + var _padding = node.padding(); + nodeWidth = node.width() + 2 * _padding; + nodeHeight = node.height() + 2 * _padding; + } + r.colorFillStyle(context, color[0], color[1], color[2], opacity); + r.nodeShapes[shape].draw(context, pos.x, pos.y, nodeWidth + padding * 2, nodeHeight + padding * 2, radius); + context.fill(); + } + }; +}; +CRp$5.drawNodeOverlay = drawNodeOverlayUnderlay('overlay'); +CRp$5.drawNodeUnderlay = drawNodeOverlayUnderlay('underlay'); + +// does the node have at least one pie piece? +CRp$5.hasPie = function (node) { + node = node[0]; // ensure ele ref + + return node._private.hasPie; +}; +CRp$5.drawPie = function (context, node, nodeOpacity, pos) { + node = node[0]; // ensure ele ref + pos = pos || node.position(); + var cyStyle = node.cy().style(); + var pieSize = node.pstyle('pie-size'); + var x = pos.x; + var y = pos.y; + var nodeW = node.width(); + var nodeH = node.height(); + var radius = Math.min(nodeW, nodeH) / 2; // must fit in node + var lastPercent = 0; // what % to continue drawing pie slices from on [0, 1] + var usePaths = this.usePaths(); + if (usePaths) { + x = 0; + y = 0; + } + if (pieSize.units === '%') { + radius = radius * pieSize.pfValue; + } else if (pieSize.pfValue !== undefined) { + radius = pieSize.pfValue / 2; + } + for (var i = 1; i <= cyStyle.pieBackgroundN; i++) { + // 1..N + var size = node.pstyle('pie-' + i + '-background-size').value; + var color = node.pstyle('pie-' + i + '-background-color').value; + var opacity = node.pstyle('pie-' + i + '-background-opacity').value * nodeOpacity; + var percent = size / 100; // map integer range [0, 100] to [0, 1] + + // percent can't push beyond 1 + if (percent + lastPercent > 1) { + percent = 1 - lastPercent; + } + var angleStart = 1.5 * Math.PI + 2 * Math.PI * lastPercent; // start at 12 o'clock and go clockwise + var angleDelta = 2 * Math.PI * percent; + var angleEnd = angleStart + angleDelta; + + // ignore if + // - zero size + // - we're already beyond the full circle + // - adding the current slice would go beyond the full circle + if (size === 0 || lastPercent >= 1 || lastPercent + percent > 1) { + continue; + } + context.beginPath(); + context.moveTo(x, y); + context.arc(x, y, radius, angleStart, angleEnd); + context.closePath(); + this.colorFillStyle(context, color[0], color[1], color[2], opacity); + context.fill(); + lastPercent += percent; + } +}; + +var CRp$4 = {}; +var motionBlurDelay = 100; + +// var isFirefox = typeof InstallTrigger !== 'undefined'; + +CRp$4.getPixelRatio = function () { + var context = this.data.contexts[0]; + if (this.forcedPixelRatio != null) { + return this.forcedPixelRatio; + } + var backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; + return (window.devicePixelRatio || 1) / backingStore; // eslint-disable-line no-undef +}; + +CRp$4.paintCache = function (context) { + var caches = this.paintCaches = this.paintCaches || []; + var needToCreateCache = true; + var cache; + for (var i = 0; i < caches.length; i++) { + cache = caches[i]; + if (cache.context === context) { + needToCreateCache = false; + break; + } + } + if (needToCreateCache) { + cache = { + context: context + }; + caches.push(cache); + } + return cache; +}; +CRp$4.createGradientStyleFor = function (context, shapeStyleName, ele, fill, opacity) { + var gradientStyle; + var usePaths = this.usePaths(); + var colors = ele.pstyle(shapeStyleName + '-gradient-stop-colors').value, + positions = ele.pstyle(shapeStyleName + '-gradient-stop-positions').pfValue; + if (fill === 'radial-gradient') { + if (ele.isEdge()) { + var start = ele.sourceEndpoint(), + end = ele.targetEndpoint(), + mid = ele.midpoint(); + var d1 = dist(start, mid); + var d2 = dist(end, mid); + gradientStyle = context.createRadialGradient(mid.x, mid.y, 0, mid.x, mid.y, Math.max(d1, d2)); + } else { + var pos = usePaths ? { + x: 0, + y: 0 + } : ele.position(), + width = ele.paddedWidth(), + height = ele.paddedHeight(); + gradientStyle = context.createRadialGradient(pos.x, pos.y, 0, pos.x, pos.y, Math.max(width, height)); + } + } else { + if (ele.isEdge()) { + var _start = ele.sourceEndpoint(), + _end = ele.targetEndpoint(); + gradientStyle = context.createLinearGradient(_start.x, _start.y, _end.x, _end.y); + } else { + var _pos = usePaths ? { + x: 0, + y: 0 + } : ele.position(), + _width = ele.paddedWidth(), + _height = ele.paddedHeight(), + halfWidth = _width / 2, + halfHeight = _height / 2; + var direction = ele.pstyle('background-gradient-direction').value; + switch (direction) { + case 'to-bottom': + gradientStyle = context.createLinearGradient(_pos.x, _pos.y - halfHeight, _pos.x, _pos.y + halfHeight); + break; + case 'to-top': + gradientStyle = context.createLinearGradient(_pos.x, _pos.y + halfHeight, _pos.x, _pos.y - halfHeight); + break; + case 'to-left': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y, _pos.x - halfWidth, _pos.y); + break; + case 'to-right': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y, _pos.x + halfWidth, _pos.y); + break; + case 'to-bottom-right': + case 'to-right-bottom': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y - halfHeight, _pos.x + halfWidth, _pos.y + halfHeight); + break; + case 'to-top-right': + case 'to-right-top': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y + halfHeight, _pos.x + halfWidth, _pos.y - halfHeight); + break; + case 'to-bottom-left': + case 'to-left-bottom': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y - halfHeight, _pos.x - halfWidth, _pos.y + halfHeight); + break; + case 'to-top-left': + case 'to-left-top': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y + halfHeight, _pos.x - halfWidth, _pos.y - halfHeight); + break; + } + } + } + if (!gradientStyle) return null; // invalid gradient style + + var hasPositions = positions.length === colors.length; + var length = colors.length; + for (var i = 0; i < length; i++) { + gradientStyle.addColorStop(hasPositions ? positions[i] : i / (length - 1), 'rgba(' + colors[i][0] + ',' + colors[i][1] + ',' + colors[i][2] + ',' + opacity + ')'); + } + return gradientStyle; +}; +CRp$4.gradientFillStyle = function (context, ele, fill, opacity) { + var gradientStyle = this.createGradientStyleFor(context, 'background', ele, fill, opacity); + if (!gradientStyle) return null; // error + context.fillStyle = gradientStyle; +}; +CRp$4.colorFillStyle = function (context, r, g, b, a) { + context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + // turn off for now, seems context does its own caching + + // var cache = this.paintCache(context); + + // var fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + + // if( cache.fillStyle !== fillStyle ){ + // context.fillStyle = cache.fillStyle = fillStyle; + // } +}; + +CRp$4.eleFillStyle = function (context, ele, opacity) { + var backgroundFill = ele.pstyle('background-fill').value; + if (backgroundFill === 'linear-gradient' || backgroundFill === 'radial-gradient') { + this.gradientFillStyle(context, ele, backgroundFill, opacity); + } else { + var backgroundColor = ele.pstyle('background-color').value; + this.colorFillStyle(context, backgroundColor[0], backgroundColor[1], backgroundColor[2], opacity); + } +}; +CRp$4.gradientStrokeStyle = function (context, ele, fill, opacity) { + var gradientStyle = this.createGradientStyleFor(context, 'line', ele, fill, opacity); + if (!gradientStyle) return null; // error + context.strokeStyle = gradientStyle; +}; +CRp$4.colorStrokeStyle = function (context, r, g, b, a) { + context.strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + // turn off for now, seems context does its own caching + + // var cache = this.paintCache(context); + + // var strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + + // if( cache.strokeStyle !== strokeStyle ){ + // context.strokeStyle = cache.strokeStyle = strokeStyle; + // } +}; + +CRp$4.eleStrokeStyle = function (context, ele, opacity) { + var lineFill = ele.pstyle('line-fill').value; + if (lineFill === 'linear-gradient' || lineFill === 'radial-gradient') { + this.gradientStrokeStyle(context, ele, lineFill, opacity); + } else { + var lineColor = ele.pstyle('line-color').value; + this.colorStrokeStyle(context, lineColor[0], lineColor[1], lineColor[2], opacity); + } +}; + +// Resize canvas +CRp$4.matchCanvasSize = function (container) { + var r = this; + var data = r.data; + var bb = r.findContainerClientCoords(); + var width = bb[2]; + var height = bb[3]; + var pixelRatio = r.getPixelRatio(); + var mbPxRatio = r.motionBlurPxRatio; + if (container === r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE] || container === r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG]) { + pixelRatio = mbPxRatio; + } + var canvasWidth = width * pixelRatio; + var canvasHeight = height * pixelRatio; + var canvas; + if (canvasWidth === r.canvasWidth && canvasHeight === r.canvasHeight) { + return; // save cycles if same + } + + r.fontCaches = null; // resizing resets the style + + var canvasContainer = data.canvasContainer; + canvasContainer.style.width = width + 'px'; + canvasContainer.style.height = height + 'px'; + for (var i = 0; i < r.CANVAS_LAYERS; i++) { + canvas = data.canvases[i]; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + } + for (var i = 0; i < r.BUFFER_COUNT; i++) { + canvas = data.bufferCanvases[i]; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + } + r.textureMult = 1; + if (pixelRatio <= 1) { + canvas = data.bufferCanvases[r.TEXTURE_BUFFER]; + r.textureMult = 2; + canvas.width = canvasWidth * r.textureMult; + canvas.height = canvasHeight * r.textureMult; + } + r.canvasWidth = canvasWidth; + r.canvasHeight = canvasHeight; +}; +CRp$4.renderTo = function (cxt, zoom, pan, pxRatio) { + this.render({ + forcedContext: cxt, + forcedZoom: zoom, + forcedPan: pan, + drawAllLayers: true, + forcedPxRatio: pxRatio + }); +}; +CRp$4.render = function (options) { + options = options || staticEmptyObject(); + var forcedContext = options.forcedContext; + var drawAllLayers = options.drawAllLayers; + var drawOnlyNodeLayer = options.drawOnlyNodeLayer; + var forcedZoom = options.forcedZoom; + var forcedPan = options.forcedPan; + var r = this; + var pixelRatio = options.forcedPxRatio === undefined ? this.getPixelRatio() : options.forcedPxRatio; + var cy = r.cy; + var data = r.data; + var needDraw = data.canvasNeedsRedraw; + var textureDraw = r.textureOnViewport && !forcedContext && (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming); + var motionBlur = options.motionBlur !== undefined ? options.motionBlur : r.motionBlur; + var mbPxRatio = r.motionBlurPxRatio; + var hasCompoundNodes = cy.hasCompoundNodes(); + var inNodeDragGesture = r.hoverData.draggingEles; + var inBoxSelection = r.hoverData.selecting || r.touchData.selecting ? true : false; + motionBlur = motionBlur && !forcedContext && r.motionBlurEnabled && !inBoxSelection; + var motionBlurFadeEffect = motionBlur; + if (!forcedContext) { + if (r.prevPxRatio !== pixelRatio) { + r.invalidateContainerClientCoordsCache(); + r.matchCanvasSize(r.container); + r.redrawHint('eles', true); + r.redrawHint('drag', true); + } + r.prevPxRatio = pixelRatio; + } + if (!forcedContext && r.motionBlurTimeout) { + clearTimeout(r.motionBlurTimeout); + } + if (motionBlur) { + if (r.mbFrames == null) { + r.mbFrames = 0; + } + r.mbFrames++; + if (r.mbFrames < 3) { + // need several frames before even high quality motionblur + motionBlurFadeEffect = false; + } + + // go to lower quality blurry frames when several m/b frames have been rendered (avoids flashing) + if (r.mbFrames > r.minMbLowQualFrames) { + //r.fullQualityMb = false; + r.motionBlurPxRatio = r.mbPxRBlurry; + } + } + if (r.clearingMotionBlur) { + r.motionBlurPxRatio = 1; + } + + // b/c drawToContext() may be async w.r.t. redraw(), keep track of last texture frame + // because a rogue async texture frame would clear needDraw + if (r.textureDrawLastFrame && !textureDraw) { + needDraw[r.NODE] = true; + needDraw[r.SELECT_BOX] = true; + } + var style = cy.style(); + var zoom = cy.zoom(); + var effectiveZoom = forcedZoom !== undefined ? forcedZoom : zoom; + var pan = cy.pan(); + var effectivePan = { + x: pan.x, + y: pan.y + }; + var vp = { + zoom: zoom, + pan: { + x: pan.x, + y: pan.y + } + }; + var prevVp = r.prevViewport; + var viewportIsDiff = prevVp === undefined || vp.zoom !== prevVp.zoom || vp.pan.x !== prevVp.pan.x || vp.pan.y !== prevVp.pan.y; + + // we want the low quality motionblur only when the viewport is being manipulated etc (where it's not noticed) + if (!viewportIsDiff && !(inNodeDragGesture && !hasCompoundNodes)) { + r.motionBlurPxRatio = 1; + } + if (forcedPan) { + effectivePan = forcedPan; + } + + // apply pixel ratio + + effectiveZoom *= pixelRatio; + effectivePan.x *= pixelRatio; + effectivePan.y *= pixelRatio; + var eles = r.getCachedZSortedEles(); + function mbclear(context, x, y, w, h) { + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + r.colorFillStyle(context, 255, 255, 255, r.motionBlurTransparency); + context.fillRect(x, y, w, h); + context.globalCompositeOperation = gco; + } + function setContextTransform(context, clear) { + var ePan, eZoom, w, h; + if (!r.clearingMotionBlur && (context === data.bufferContexts[r.MOTIONBLUR_BUFFER_NODE] || context === data.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG])) { + ePan = { + x: pan.x * mbPxRatio, + y: pan.y * mbPxRatio + }; + eZoom = zoom * mbPxRatio; + w = r.canvasWidth * mbPxRatio; + h = r.canvasHeight * mbPxRatio; + } else { + ePan = effectivePan; + eZoom = effectiveZoom; + w = r.canvasWidth; + h = r.canvasHeight; + } + context.setTransform(1, 0, 0, 1, 0, 0); + if (clear === 'motionBlur') { + mbclear(context, 0, 0, w, h); + } else if (!forcedContext && (clear === undefined || clear)) { + context.clearRect(0, 0, w, h); + } + if (!drawAllLayers) { + context.translate(ePan.x, ePan.y); + context.scale(eZoom, eZoom); + } + if (forcedPan) { + context.translate(forcedPan.x, forcedPan.y); + } + if (forcedZoom) { + context.scale(forcedZoom, forcedZoom); + } + } + if (!textureDraw) { + r.textureDrawLastFrame = false; + } + if (textureDraw) { + r.textureDrawLastFrame = true; + if (!r.textureCache) { + r.textureCache = {}; + r.textureCache.bb = cy.mutableElements().boundingBox(); + r.textureCache.texture = r.data.bufferCanvases[r.TEXTURE_BUFFER]; + var cxt = r.data.bufferContexts[r.TEXTURE_BUFFER]; + cxt.setTransform(1, 0, 0, 1, 0, 0); + cxt.clearRect(0, 0, r.canvasWidth * r.textureMult, r.canvasHeight * r.textureMult); + r.render({ + forcedContext: cxt, + drawOnlyNodeLayer: true, + forcedPxRatio: pixelRatio * r.textureMult + }); + var vp = r.textureCache.viewport = { + zoom: cy.zoom(), + pan: cy.pan(), + width: r.canvasWidth, + height: r.canvasHeight + }; + vp.mpan = { + x: (0 - vp.pan.x) / vp.zoom, + y: (0 - vp.pan.y) / vp.zoom + }; + } + needDraw[r.DRAG] = false; + needDraw[r.NODE] = false; + var context = data.contexts[r.NODE]; + var texture = r.textureCache.texture; + var vp = r.textureCache.viewport; + context.setTransform(1, 0, 0, 1, 0, 0); + if (motionBlur) { + mbclear(context, 0, 0, vp.width, vp.height); + } else { + context.clearRect(0, 0, vp.width, vp.height); + } + var outsideBgColor = style.core('outside-texture-bg-color').value; + var outsideBgOpacity = style.core('outside-texture-bg-opacity').value; + r.colorFillStyle(context, outsideBgColor[0], outsideBgColor[1], outsideBgColor[2], outsideBgOpacity); + context.fillRect(0, 0, vp.width, vp.height); + var zoom = cy.zoom(); + setContextTransform(context, false); + context.clearRect(vp.mpan.x, vp.mpan.y, vp.width / vp.zoom / pixelRatio, vp.height / vp.zoom / pixelRatio); + context.drawImage(texture, vp.mpan.x, vp.mpan.y, vp.width / vp.zoom / pixelRatio, vp.height / vp.zoom / pixelRatio); + } else if (r.textureOnViewport && !forcedContext) { + // clear the cache since we don't need it + r.textureCache = null; + } + var extent = cy.extent(); + var vpManip = r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming || r.hoverData.draggingEles || r.cy.animated(); + var hideEdges = r.hideEdgesOnViewport && vpManip; + var needMbClear = []; + needMbClear[r.NODE] = !needDraw[r.NODE] && motionBlur && !r.clearedForMotionBlur[r.NODE] || r.clearingMotionBlur; + if (needMbClear[r.NODE]) { + r.clearedForMotionBlur[r.NODE] = true; + } + needMbClear[r.DRAG] = !needDraw[r.DRAG] && motionBlur && !r.clearedForMotionBlur[r.DRAG] || r.clearingMotionBlur; + if (needMbClear[r.DRAG]) { + r.clearedForMotionBlur[r.DRAG] = true; + } + if (needDraw[r.NODE] || drawAllLayers || drawOnlyNodeLayer || needMbClear[r.NODE]) { + var useBuffer = motionBlur && !needMbClear[r.NODE] && mbPxRatio !== 1; + var context = forcedContext || (useBuffer ? r.data.bufferContexts[r.MOTIONBLUR_BUFFER_NODE] : data.contexts[r.NODE]); + var clear = motionBlur && !useBuffer ? 'motionBlur' : undefined; + setContextTransform(context, clear); + if (hideEdges) { + r.drawCachedNodes(context, eles.nondrag, pixelRatio, extent); + } else { + r.drawLayeredElements(context, eles.nondrag, pixelRatio, extent); + } + if (r.debug) { + r.drawDebugPoints(context, eles.nondrag); + } + if (!drawAllLayers && !motionBlur) { + needDraw[r.NODE] = false; + } + } + if (!drawOnlyNodeLayer && (needDraw[r.DRAG] || drawAllLayers || needMbClear[r.DRAG])) { + var useBuffer = motionBlur && !needMbClear[r.DRAG] && mbPxRatio !== 1; + var context = forcedContext || (useBuffer ? r.data.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG] : data.contexts[r.DRAG]); + setContextTransform(context, motionBlur && !useBuffer ? 'motionBlur' : undefined); + if (hideEdges) { + r.drawCachedNodes(context, eles.drag, pixelRatio, extent); + } else { + r.drawCachedElements(context, eles.drag, pixelRatio, extent); + } + if (r.debug) { + r.drawDebugPoints(context, eles.drag); + } + if (!drawAllLayers && !motionBlur) { + needDraw[r.DRAG] = false; + } + } + if (r.showFps || !drawOnlyNodeLayer && needDraw[r.SELECT_BOX] && !drawAllLayers) { + var context = forcedContext || data.contexts[r.SELECT_BOX]; + setContextTransform(context); + if (r.selection[4] == 1 && (r.hoverData.selecting || r.touchData.selecting)) { + var zoom = r.cy.zoom(); + var borderWidth = style.core('selection-box-border-width').value / zoom; + context.lineWidth = borderWidth; + context.fillStyle = 'rgba(' + style.core('selection-box-color').value[0] + ',' + style.core('selection-box-color').value[1] + ',' + style.core('selection-box-color').value[2] + ',' + style.core('selection-box-opacity').value + ')'; + context.fillRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]); + if (borderWidth > 0) { + context.strokeStyle = 'rgba(' + style.core('selection-box-border-color').value[0] + ',' + style.core('selection-box-border-color').value[1] + ',' + style.core('selection-box-border-color').value[2] + ',' + style.core('selection-box-opacity').value + ')'; + context.strokeRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]); + } + } + if (data.bgActivePosistion && !r.hoverData.selecting) { + var zoom = r.cy.zoom(); + var pos = data.bgActivePosistion; + context.fillStyle = 'rgba(' + style.core('active-bg-color').value[0] + ',' + style.core('active-bg-color').value[1] + ',' + style.core('active-bg-color').value[2] + ',' + style.core('active-bg-opacity').value + ')'; + context.beginPath(); + context.arc(pos.x, pos.y, style.core('active-bg-size').pfValue / zoom, 0, 2 * Math.PI); + context.fill(); + } + var timeToRender = r.lastRedrawTime; + if (r.showFps && timeToRender) { + timeToRender = Math.round(timeToRender); + var fps = Math.round(1000 / timeToRender); + context.setTransform(1, 0, 0, 1, 0, 0); + context.fillStyle = 'rgba(255, 0, 0, 0.75)'; + context.strokeStyle = 'rgba(255, 0, 0, 0.75)'; + context.lineWidth = 1; + context.fillText('1 frame = ' + timeToRender + ' ms = ' + fps + ' fps', 0, 20); + var maxFps = 60; + context.strokeRect(0, 30, 250, 20); + context.fillRect(0, 30, 250 * Math.min(fps / maxFps, 1), 20); + } + if (!drawAllLayers) { + needDraw[r.SELECT_BOX] = false; + } + } + + // motionblur: blit rendered blurry frames + if (motionBlur && mbPxRatio !== 1) { + var cxtNode = data.contexts[r.NODE]; + var txtNode = r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE]; + var cxtDrag = data.contexts[r.DRAG]; + var txtDrag = r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG]; + var drawMotionBlur = function drawMotionBlur(cxt, txt, needClear) { + cxt.setTransform(1, 0, 0, 1, 0, 0); + if (needClear || !motionBlurFadeEffect) { + cxt.clearRect(0, 0, r.canvasWidth, r.canvasHeight); + } else { + mbclear(cxt, 0, 0, r.canvasWidth, r.canvasHeight); + } + var pxr = mbPxRatio; + cxt.drawImage(txt, + // img + 0, 0, + // sx, sy + r.canvasWidth * pxr, r.canvasHeight * pxr, + // sw, sh + 0, 0, + // x, y + r.canvasWidth, r.canvasHeight // w, h + ); + }; + + if (needDraw[r.NODE] || needMbClear[r.NODE]) { + drawMotionBlur(cxtNode, txtNode, needMbClear[r.NODE]); + needDraw[r.NODE] = false; + } + if (needDraw[r.DRAG] || needMbClear[r.DRAG]) { + drawMotionBlur(cxtDrag, txtDrag, needMbClear[r.DRAG]); + needDraw[r.DRAG] = false; + } + } + r.prevViewport = vp; + if (r.clearingMotionBlur) { + r.clearingMotionBlur = false; + r.motionBlurCleared = true; + r.motionBlur = true; + } + if (motionBlur) { + r.motionBlurTimeout = setTimeout(function () { + r.motionBlurTimeout = null; + r.clearedForMotionBlur[r.NODE] = false; + r.clearedForMotionBlur[r.DRAG] = false; + r.motionBlur = false; + r.clearingMotionBlur = !textureDraw; + r.mbFrames = 0; + needDraw[r.NODE] = true; + needDraw[r.DRAG] = true; + r.redraw(); + }, motionBlurDelay); + } + if (!forcedContext) { + cy.emit('render'); + } +}; + +var CRp$3 = {}; + +// @O Polygon drawing +CRp$3.drawPolygonPath = function (context, x, y, width, height, points) { + var halfW = width / 2; + var halfH = height / 2; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(x + halfW * points[0], y + halfH * points[1]); + for (var i = 1; i < points.length / 2; i++) { + context.lineTo(x + halfW * points[i * 2], y + halfH * points[i * 2 + 1]); + } + context.closePath(); +}; +CRp$3.drawRoundPolygonPath = function (context, x, y, width, height, points, corners) { + corners.forEach(function (corner) { + return drawPreparedRoundCorner(context, corner); + }); + context.closePath(); +}; + +// Round rectangle drawing +CRp$3.drawRoundRectanglePath = function (context, x, y, width, height, radius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : Math.min(radius, halfHeight, halfWidth); + if (context.beginPath) { + context.beginPath(); + } + + // Start at top middle + context.moveTo(x, y - halfHeight); + // Arc from middle top to right side + context.arcTo(x + halfWidth, y - halfHeight, x + halfWidth, y, cornerRadius); + // Arc from right side to bottom + context.arcTo(x + halfWidth, y + halfHeight, x, y + halfHeight, cornerRadius); + // Arc from bottom to left side + context.arcTo(x - halfWidth, y + halfHeight, x - halfWidth, y, cornerRadius); + // Arc from left side to topBorder + context.arcTo(x - halfWidth, y - halfHeight, x, y - halfHeight, cornerRadius); + // Join line + context.lineTo(x, y - halfHeight); + context.closePath(); +}; +CRp$3.drawBottomRoundRectanglePath = function (context, x, y, width, height, radius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : radius; + if (context.beginPath) { + context.beginPath(); + } + + // Start at top middle + context.moveTo(x, y - halfHeight); + context.lineTo(x + halfWidth, y - halfHeight); + context.lineTo(x + halfWidth, y); + context.arcTo(x + halfWidth, y + halfHeight, x, y + halfHeight, cornerRadius); + context.arcTo(x - halfWidth, y + halfHeight, x - halfWidth, y, cornerRadius); + context.lineTo(x - halfWidth, y - halfHeight); + context.lineTo(x, y - halfHeight); + context.closePath(); +}; +CRp$3.drawCutRectanglePath = function (context, x, y, width, height, points, corners) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerLength = corners === 'auto' ? getCutRectangleCornerLength() : corners; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(x - halfWidth + cornerLength, y - halfHeight); + context.lineTo(x + halfWidth - cornerLength, y - halfHeight); + context.lineTo(x + halfWidth, y - halfHeight + cornerLength); + context.lineTo(x + halfWidth, y + halfHeight - cornerLength); + context.lineTo(x + halfWidth - cornerLength, y + halfHeight); + context.lineTo(x - halfWidth + cornerLength, y + halfHeight); + context.lineTo(x - halfWidth, y + halfHeight - cornerLength); + context.lineTo(x - halfWidth, y - halfHeight + cornerLength); + context.closePath(); +}; +CRp$3.drawBarrelPath = function (context, x, y, width, height) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var xBegin = x - halfWidth; + var xEnd = x + halfWidth; + var yBegin = y - halfHeight; + var yEnd = y + halfHeight; + var barrelCurveConstants = getBarrelCurveConstants(width, height); + var wOffset = barrelCurveConstants.widthOffset; + var hOffset = barrelCurveConstants.heightOffset; + var ctrlPtXOffset = barrelCurveConstants.ctrlPtOffsetPct * wOffset; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(xBegin, yBegin + hOffset); + context.lineTo(xBegin, yEnd - hOffset); + context.quadraticCurveTo(xBegin + ctrlPtXOffset, yEnd, xBegin + wOffset, yEnd); + context.lineTo(xEnd - wOffset, yEnd); + context.quadraticCurveTo(xEnd - ctrlPtXOffset, yEnd, xEnd, yEnd - hOffset); + context.lineTo(xEnd, yBegin + hOffset); + context.quadraticCurveTo(xEnd - ctrlPtXOffset, yBegin, xEnd - wOffset, yBegin); + context.lineTo(xBegin + wOffset, yBegin); + context.quadraticCurveTo(xBegin + ctrlPtXOffset, yBegin, xBegin, yBegin + hOffset); + context.closePath(); +}; +var sin0 = Math.sin(0); +var cos0 = Math.cos(0); +var sin = {}; +var cos = {}; +var ellipseStepSize = Math.PI / 40; +for (var i = 0 * Math.PI; i < 2 * Math.PI; i += ellipseStepSize) { + sin[i] = Math.sin(i); + cos[i] = Math.cos(i); +} +CRp$3.drawEllipsePath = function (context, centerX, centerY, width, height) { + if (context.beginPath) { + context.beginPath(); + } + if (context.ellipse) { + context.ellipse(centerX, centerY, width / 2, height / 2, 0, 0, 2 * Math.PI); + } else { + var xPos, yPos; + var rw = width / 2; + var rh = height / 2; + for (var i = 0 * Math.PI; i < 2 * Math.PI; i += ellipseStepSize) { + xPos = centerX - rw * sin[i] * sin0 + rw * cos[i] * cos0; + yPos = centerY + rh * cos[i] * sin0 + rh * sin[i] * cos0; + if (i === 0) { + context.moveTo(xPos, yPos); + } else { + context.lineTo(xPos, yPos); + } + } + } + context.closePath(); +}; + +/* global atob, ArrayBuffer, Uint8Array, Blob */ +var CRp$2 = {}; +CRp$2.createBuffer = function (w, h) { + var buffer = document.createElement('canvas'); // eslint-disable-line no-undef + buffer.width = w; + buffer.height = h; + return [buffer, buffer.getContext('2d')]; +}; +CRp$2.bufferCanvasImage = function (options) { + var cy = this.cy; + var eles = cy.mutableElements(); + var bb = eles.boundingBox(); + var ctrRect = this.findContainerClientCoords(); + var width = options.full ? Math.ceil(bb.w) : ctrRect[2]; + var height = options.full ? Math.ceil(bb.h) : ctrRect[3]; + var specdMaxDims = number$1(options.maxWidth) || number$1(options.maxHeight); + var pxRatio = this.getPixelRatio(); + var scale = 1; + if (options.scale !== undefined) { + width *= options.scale; + height *= options.scale; + scale = options.scale; + } else if (specdMaxDims) { + var maxScaleW = Infinity; + var maxScaleH = Infinity; + if (number$1(options.maxWidth)) { + maxScaleW = scale * options.maxWidth / width; + } + if (number$1(options.maxHeight)) { + maxScaleH = scale * options.maxHeight / height; + } + scale = Math.min(maxScaleW, maxScaleH); + width *= scale; + height *= scale; + } + if (!specdMaxDims) { + width *= pxRatio; + height *= pxRatio; + scale *= pxRatio; + } + var buffCanvas = document.createElement('canvas'); // eslint-disable-line no-undef + + buffCanvas.width = width; + buffCanvas.height = height; + buffCanvas.style.width = width + 'px'; + buffCanvas.style.height = height + 'px'; + var buffCxt = buffCanvas.getContext('2d'); + + // Rasterize the layers, but only if container has nonzero size + if (width > 0 && height > 0) { + buffCxt.clearRect(0, 0, width, height); + buffCxt.globalCompositeOperation = 'source-over'; + var zsortedEles = this.getCachedZSortedEles(); + if (options.full) { + // draw the full bounds of the graph + buffCxt.translate(-bb.x1 * scale, -bb.y1 * scale); + buffCxt.scale(scale, scale); + this.drawElements(buffCxt, zsortedEles); + buffCxt.scale(1 / scale, 1 / scale); + buffCxt.translate(bb.x1 * scale, bb.y1 * scale); + } else { + // draw the current view + var pan = cy.pan(); + var translation = { + x: pan.x * scale, + y: pan.y * scale + }; + scale *= cy.zoom(); + buffCxt.translate(translation.x, translation.y); + buffCxt.scale(scale, scale); + this.drawElements(buffCxt, zsortedEles); + buffCxt.scale(1 / scale, 1 / scale); + buffCxt.translate(-translation.x, -translation.y); + } + + // need to fill bg at end like this in order to fill cleared transparent pixels in jpgs + if (options.bg) { + buffCxt.globalCompositeOperation = 'destination-over'; + buffCxt.fillStyle = options.bg; + buffCxt.rect(0, 0, width, height); + buffCxt.fill(); + } + } + return buffCanvas; +}; +function b64ToBlob(b64, mimeType) { + var bytes = atob(b64); + var buff = new ArrayBuffer(bytes.length); + var buffUint8 = new Uint8Array(buff); + for (var i = 0; i < bytes.length; i++) { + buffUint8[i] = bytes.charCodeAt(i); + } + return new Blob([buff], { + type: mimeType + }); +} +function b64UriToB64(b64uri) { + var i = b64uri.indexOf(','); + return b64uri.substr(i + 1); +} +function output(options, canvas, mimeType) { + var getB64Uri = function getB64Uri() { + return canvas.toDataURL(mimeType, options.quality); + }; + switch (options.output) { + case 'blob-promise': + return new Promise$1(function (resolve, reject) { + try { + canvas.toBlob(function (blob) { + if (blob != null) { + resolve(blob); + } else { + reject(new Error('`canvas.toBlob()` sent a null value in its callback')); + } + }, mimeType, options.quality); + } catch (err) { + reject(err); + } + }); + case 'blob': + return b64ToBlob(b64UriToB64(getB64Uri()), mimeType); + case 'base64': + return b64UriToB64(getB64Uri()); + case 'base64uri': + default: + return getB64Uri(); + } +} +CRp$2.png = function (options) { + return output(options, this.bufferCanvasImage(options), 'image/png'); +}; +CRp$2.jpg = function (options) { + return output(options, this.bufferCanvasImage(options), 'image/jpeg'); +}; + +var CRp$1 = {}; +CRp$1.nodeShapeImpl = function (name, context, centerX, centerY, width, height, points, corners) { + switch (name) { + case 'ellipse': + return this.drawEllipsePath(context, centerX, centerY, width, height); + case 'polygon': + return this.drawPolygonPath(context, centerX, centerY, width, height, points); + case 'round-polygon': + return this.drawRoundPolygonPath(context, centerX, centerY, width, height, points, corners); + case 'roundrectangle': + case 'round-rectangle': + return this.drawRoundRectanglePath(context, centerX, centerY, width, height, corners); + case 'cutrectangle': + case 'cut-rectangle': + return this.drawCutRectanglePath(context, centerX, centerY, width, height, points, corners); + case 'bottomroundrectangle': + case 'bottom-round-rectangle': + return this.drawBottomRoundRectanglePath(context, centerX, centerY, width, height, corners); + case 'barrel': + return this.drawBarrelPath(context, centerX, centerY, width, height); + } +}; + +var CR = CanvasRenderer; +var CRp = CanvasRenderer.prototype; +CRp.CANVAS_LAYERS = 3; +// +CRp.SELECT_BOX = 0; +CRp.DRAG = 1; +CRp.NODE = 2; +CRp.BUFFER_COUNT = 3; +// +CRp.TEXTURE_BUFFER = 0; +CRp.MOTIONBLUR_BUFFER_NODE = 1; +CRp.MOTIONBLUR_BUFFER_DRAG = 2; +function CanvasRenderer(options) { + var r = this; + r.data = { + canvases: new Array(CRp.CANVAS_LAYERS), + contexts: new Array(CRp.CANVAS_LAYERS), + canvasNeedsRedraw: new Array(CRp.CANVAS_LAYERS), + bufferCanvases: new Array(CRp.BUFFER_COUNT), + bufferContexts: new Array(CRp.CANVAS_LAYERS) + }; + var tapHlOffAttr = '-webkit-tap-highlight-color'; + var tapHlOffStyle = 'rgba(0,0,0,0)'; + r.data.canvasContainer = document.createElement('div'); // eslint-disable-line no-undef + var containerStyle = r.data.canvasContainer.style; + r.data.canvasContainer.style[tapHlOffAttr] = tapHlOffStyle; + containerStyle.position = 'relative'; + containerStyle.zIndex = '0'; + containerStyle.overflow = 'hidden'; + var container = options.cy.container(); + container.appendChild(r.data.canvasContainer); + container.style[tapHlOffAttr] = tapHlOffStyle; + var styleMap = { + '-webkit-user-select': 'none', + '-moz-user-select': '-moz-none', + 'user-select': 'none', + '-webkit-tap-highlight-color': 'rgba(0,0,0,0)', + 'outline-style': 'none' + }; + if (ms()) { + styleMap['-ms-touch-action'] = 'none'; + styleMap['touch-action'] = 'none'; + } + for (var i = 0; i < CRp.CANVAS_LAYERS; i++) { + var canvas = r.data.canvases[i] = document.createElement('canvas'); // eslint-disable-line no-undef + r.data.contexts[i] = canvas.getContext('2d'); + Object.keys(styleMap).forEach(function (k) { + canvas.style[k] = styleMap[k]; + }); + canvas.style.position = 'absolute'; + canvas.setAttribute('data-id', 'layer' + i); + canvas.style.zIndex = String(CRp.CANVAS_LAYERS - i); + r.data.canvasContainer.appendChild(canvas); + r.data.canvasNeedsRedraw[i] = false; + } + r.data.topCanvas = r.data.canvases[0]; + r.data.canvases[CRp.NODE].setAttribute('data-id', 'layer' + CRp.NODE + '-node'); + r.data.canvases[CRp.SELECT_BOX].setAttribute('data-id', 'layer' + CRp.SELECT_BOX + '-selectbox'); + r.data.canvases[CRp.DRAG].setAttribute('data-id', 'layer' + CRp.DRAG + '-drag'); + for (var i = 0; i < CRp.BUFFER_COUNT; i++) { + r.data.bufferCanvases[i] = document.createElement('canvas'); // eslint-disable-line no-undef + r.data.bufferContexts[i] = r.data.bufferCanvases[i].getContext('2d'); + r.data.bufferCanvases[i].style.position = 'absolute'; + r.data.bufferCanvases[i].setAttribute('data-id', 'buffer' + i); + r.data.bufferCanvases[i].style.zIndex = String(-i - 1); + r.data.bufferCanvases[i].style.visibility = 'hidden'; + //r.data.canvasContainer.appendChild(r.data.bufferCanvases[i]); + } + + r.pathsEnabled = true; + var emptyBb = makeBoundingBox(); + var getBoxCenter = function getBoxCenter(bb) { + return { + x: (bb.x1 + bb.x2) / 2, + y: (bb.y1 + bb.y2) / 2 + }; + }; + var getCenterOffset = function getCenterOffset(bb) { + return { + x: -bb.w / 2, + y: -bb.h / 2 + }; + }; + var backgroundTimestampHasChanged = function backgroundTimestampHasChanged(ele) { + var _p = ele[0]._private; + var same = _p.oldBackgroundTimestamp === _p.backgroundTimestamp; + return !same; + }; + var getStyleKey = function getStyleKey(ele) { + return ele[0]._private.nodeKey; + }; + var getLabelKey = function getLabelKey(ele) { + return ele[0]._private.labelStyleKey; + }; + var getSourceLabelKey = function getSourceLabelKey(ele) { + return ele[0]._private.sourceLabelStyleKey; + }; + var getTargetLabelKey = function getTargetLabelKey(ele) { + return ele[0]._private.targetLabelStyleKey; + }; + var drawElement = function drawElement(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElement(context, ele, bb, false, false, useEleOpacity); + }; + var drawLabel = function drawLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'main', useEleOpacity); + }; + var drawSourceLabel = function drawSourceLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'source', useEleOpacity); + }; + var drawTargetLabel = function drawTargetLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'target', useEleOpacity); + }; + var getElementBox = function getElementBox(ele) { + ele.boundingBox(); + return ele[0]._private.bodyBounds; + }; + var getLabelBox = function getLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.main || emptyBb; + }; + var getSourceLabelBox = function getSourceLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.source || emptyBb; + }; + var getTargetLabelBox = function getTargetLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.target || emptyBb; + }; + var isLabelVisibleAtScale = function isLabelVisibleAtScale(ele, scaledLabelShown) { + return scaledLabelShown; + }; + var getElementRotationPoint = function getElementRotationPoint(ele) { + return getBoxCenter(getElementBox(ele)); + }; + var addTextMargin = function addTextMargin(prefix, pt, ele) { + var pre = prefix ? prefix + '-' : ''; + return { + x: pt.x + ele.pstyle(pre + 'text-margin-x').pfValue, + y: pt.y + ele.pstyle(pre + 'text-margin-y').pfValue + }; + }; + var getRsPt = function getRsPt(ele, x, y) { + var rs = ele[0]._private.rscratch; + return { + x: rs[x], + y: rs[y] + }; + }; + var getLabelRotationPoint = function getLabelRotationPoint(ele) { + return addTextMargin('', getRsPt(ele, 'labelX', 'labelY'), ele); + }; + var getSourceLabelRotationPoint = function getSourceLabelRotationPoint(ele) { + return addTextMargin('source', getRsPt(ele, 'sourceLabelX', 'sourceLabelY'), ele); + }; + var getTargetLabelRotationPoint = function getTargetLabelRotationPoint(ele) { + return addTextMargin('target', getRsPt(ele, 'targetLabelX', 'targetLabelY'), ele); + }; + var getElementRotationOffset = function getElementRotationOffset(ele) { + return getCenterOffset(getElementBox(ele)); + }; + var getSourceLabelRotationOffset = function getSourceLabelRotationOffset(ele) { + return getCenterOffset(getSourceLabelBox(ele)); + }; + var getTargetLabelRotationOffset = function getTargetLabelRotationOffset(ele) { + return getCenterOffset(getTargetLabelBox(ele)); + }; + var getLabelRotationOffset = function getLabelRotationOffset(ele) { + var bb = getLabelBox(ele); + var p = getCenterOffset(getLabelBox(ele)); + if (ele.isNode()) { + switch (ele.pstyle('text-halign').value) { + case 'left': + p.x = -bb.w; + break; + case 'right': + p.x = 0; + break; + } + switch (ele.pstyle('text-valign').value) { + case 'top': + p.y = -bb.h; + break; + case 'bottom': + p.y = 0; + break; + } + } + return p; + }; + var eleTxrCache = r.data.eleTxrCache = new ElementTextureCache(r, { + getKey: getStyleKey, + doesEleInvalidateKey: backgroundTimestampHasChanged, + drawElement: drawElement, + getBoundingBox: getElementBox, + getRotationPoint: getElementRotationPoint, + getRotationOffset: getElementRotationOffset, + allowEdgeTxrCaching: false, + allowParentTxrCaching: false + }); + var lblTxrCache = r.data.lblTxrCache = new ElementTextureCache(r, { + getKey: getLabelKey, + drawElement: drawLabel, + getBoundingBox: getLabelBox, + getRotationPoint: getLabelRotationPoint, + getRotationOffset: getLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var slbTxrCache = r.data.slbTxrCache = new ElementTextureCache(r, { + getKey: getSourceLabelKey, + drawElement: drawSourceLabel, + getBoundingBox: getSourceLabelBox, + getRotationPoint: getSourceLabelRotationPoint, + getRotationOffset: getSourceLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var tlbTxrCache = r.data.tlbTxrCache = new ElementTextureCache(r, { + getKey: getTargetLabelKey, + drawElement: drawTargetLabel, + getBoundingBox: getTargetLabelBox, + getRotationPoint: getTargetLabelRotationPoint, + getRotationOffset: getTargetLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var lyrTxrCache = r.data.lyrTxrCache = new LayeredTextureCache(r); + r.onUpdateEleCalcs(function invalidateTextureCaches(willDraw, eles) { + // each cache should check for sub-key diff to see that the update affects that cache particularly + eleTxrCache.invalidateElements(eles); + lblTxrCache.invalidateElements(eles); + slbTxrCache.invalidateElements(eles); + tlbTxrCache.invalidateElements(eles); + + // any change invalidates the layers + lyrTxrCache.invalidateElements(eles); + + // update the old bg timestamp so diffs can be done in the ele txr caches + for (var _i = 0; _i < eles.length; _i++) { + var _p = eles[_i]._private; + _p.oldBackgroundTimestamp = _p.backgroundTimestamp; + } + }); + var refineInLayers = function refineInLayers(reqs) { + for (var i = 0; i < reqs.length; i++) { + lyrTxrCache.enqueueElementRefinement(reqs[i].ele); + } + }; + eleTxrCache.onDequeue(refineInLayers); + lblTxrCache.onDequeue(refineInLayers); + slbTxrCache.onDequeue(refineInLayers); + tlbTxrCache.onDequeue(refineInLayers); +} +CRp.redrawHint = function (group, bool) { + var r = this; + switch (group) { + case 'eles': + r.data.canvasNeedsRedraw[CRp.NODE] = bool; + break; + case 'drag': + r.data.canvasNeedsRedraw[CRp.DRAG] = bool; + break; + case 'select': + r.data.canvasNeedsRedraw[CRp.SELECT_BOX] = bool; + break; + } +}; + +// whether to use Path2D caching for drawing +var pathsImpld = typeof Path2D !== 'undefined'; +CRp.path2dEnabled = function (on) { + if (on === undefined) { + return this.pathsEnabled; + } + this.pathsEnabled = on ? true : false; +}; +CRp.usePaths = function () { + return pathsImpld && this.pathsEnabled; +}; +CRp.setImgSmoothing = function (context, bool) { + if (context.imageSmoothingEnabled != null) { + context.imageSmoothingEnabled = bool; + } else { + context.webkitImageSmoothingEnabled = bool; + context.mozImageSmoothingEnabled = bool; + context.msImageSmoothingEnabled = bool; + } +}; +CRp.getImgSmoothing = function (context) { + if (context.imageSmoothingEnabled != null) { + return context.imageSmoothingEnabled; + } else { + return context.webkitImageSmoothingEnabled || context.mozImageSmoothingEnabled || context.msImageSmoothingEnabled; + } +}; +CRp.makeOffscreenCanvas = function (width, height) { + var canvas; + if ((typeof OffscreenCanvas === "undefined" ? "undefined" : _typeof(OffscreenCanvas)) !== ("undefined" )) { + canvas = new OffscreenCanvas(width, height); + } else { + canvas = document.createElement('canvas'); // eslint-disable-line no-undef + canvas.width = width; + canvas.height = height; + } + return canvas; +}; +[CRp$a, CRp$9, CRp$8, CRp$7, CRp$6, CRp$5, CRp$4, CRp$3, CRp$2, CRp$1].forEach(function (props) { + extend(CRp, props); +}); + +var renderer$1 = [{ + name: 'null', + impl: NullRenderer +}, { + name: 'base', + impl: BR +}, { + name: 'canvas', + impl: CR +}]; + +var incExts = [{ + type: 'layout', + extensions: layout +}, { + type: 'renderer', + extensions: renderer$1 +}]; + +// registered extensions to cytoscape, indexed by name +var extensions = {}; + +// registered modules for extensions, indexed by name +var modules = {}; +function setExtension(type, name, registrant) { + var ext = registrant; + var overrideErr = function overrideErr(field) { + warn('Can not register `' + name + '` for `' + type + '` since `' + field + '` already exists in the prototype and can not be overridden'); + }; + if (type === 'core') { + if (Core.prototype[name]) { + return overrideErr(name); + } else { + Core.prototype[name] = registrant; + } + } else if (type === 'collection') { + if (Collection.prototype[name]) { + return overrideErr(name); + } else { + Collection.prototype[name] = registrant; + } + } else if (type === 'layout') { + // fill in missing layout functions in the prototype + + var Layout = function Layout(options) { + this.options = options; + registrant.call(this, options); + + // make sure layout has _private for use w/ std apis like .on() + if (!plainObject(this._private)) { + this._private = {}; + } + this._private.cy = options.cy; + this._private.listeners = []; + this.createEmitter(); + }; + var layoutProto = Layout.prototype = Object.create(registrant.prototype); + var optLayoutFns = []; + for (var i = 0; i < optLayoutFns.length; i++) { + var fnName = optLayoutFns[i]; + layoutProto[fnName] = layoutProto[fnName] || function () { + return this; + }; + } + + // either .start() or .run() is defined, so autogen the other + if (layoutProto.start && !layoutProto.run) { + layoutProto.run = function () { + this.start(); + return this; + }; + } else if (!layoutProto.start && layoutProto.run) { + layoutProto.start = function () { + this.run(); + return this; + }; + } + var regStop = registrant.prototype.stop; + layoutProto.stop = function () { + var opts = this.options; + if (opts && opts.animate) { + var anis = this.animations; + if (anis) { + for (var _i = 0; _i < anis.length; _i++) { + anis[_i].stop(); + } + } + } + if (regStop) { + regStop.call(this); + } else { + this.emit('layoutstop'); + } + return this; + }; + if (!layoutProto.destroy) { + layoutProto.destroy = function () { + return this; + }; + } + layoutProto.cy = function () { + return this._private.cy; + }; + var getCy = function getCy(layout) { + return layout._private.cy; + }; + var emitterOpts = { + addEventFields: function addEventFields(layout, evt) { + evt.layout = layout; + evt.cy = getCy(layout); + evt.target = layout; + }, + bubble: function bubble() { + return true; + }, + parent: function parent(layout) { + return getCy(layout); + } + }; + extend(layoutProto, { + createEmitter: function createEmitter() { + this._private.emitter = new Emitter(emitterOpts, this); + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(evt, cb) { + this.emitter().on(evt, cb); + return this; + }, + one: function one(evt, cb) { + this.emitter().one(evt, cb); + return this; + }, + once: function once(evt, cb) { + this.emitter().one(evt, cb); + return this; + }, + removeListener: function removeListener(evt, cb) { + this.emitter().removeListener(evt, cb); + return this; + }, + removeAllListeners: function removeAllListeners() { + this.emitter().removeAllListeners(); + return this; + }, + emit: function emit(evt, params) { + this.emitter().emit(evt, params); + return this; + } + }); + define.eventAliasesOn(layoutProto); + ext = Layout; // replace with our wrapped layout + } else if (type === 'renderer' && name !== 'null' && name !== 'base') { + // user registered renderers inherit from base + + var BaseRenderer = getExtension('renderer', 'base'); + var bProto = BaseRenderer.prototype; + var RegistrantRenderer = registrant; + var rProto = registrant.prototype; + var Renderer = function Renderer() { + BaseRenderer.apply(this, arguments); + RegistrantRenderer.apply(this, arguments); + }; + var proto = Renderer.prototype; + for (var pName in bProto) { + var pVal = bProto[pName]; + var existsInR = rProto[pName] != null; + if (existsInR) { + return overrideErr(pName); + } + proto[pName] = pVal; // take impl from base + } + + for (var _pName in rProto) { + proto[_pName] = rProto[_pName]; // take impl from registrant + } + + bProto.clientFunctions.forEach(function (name) { + proto[name] = proto[name] || function () { + error('Renderer does not implement `renderer.' + name + '()` on its prototype'); + }; + }); + ext = Renderer; + } else if (type === '__proto__' || type === 'constructor' || type === 'prototype') { + // to avoid potential prototype pollution + return error(type + ' is an illegal type to be registered, possibly lead to prototype pollutions'); + } + return setMap({ + map: extensions, + keys: [type, name], + value: ext + }); +} +function getExtension(type, name) { + return getMap({ + map: extensions, + keys: [type, name] + }); +} +function setModule(type, name, moduleType, moduleName, registrant) { + return setMap({ + map: modules, + keys: [type, name, moduleType, moduleName], + value: registrant + }); +} +function getModule(type, name, moduleType, moduleName) { + return getMap({ + map: modules, + keys: [type, name, moduleType, moduleName] + }); +} +var extension = function extension() { + // e.g. extension('renderer', 'svg') + if (arguments.length === 2) { + return getExtension.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', { ... }) + else if (arguments.length === 3) { + return setExtension.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', 'nodeShape', 'ellipse') + else if (arguments.length === 4) { + return getModule.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', 'nodeShape', 'ellipse', { ... }) + else if (arguments.length === 5) { + return setModule.apply(null, arguments); + } else { + error('Invalid extension access syntax'); + } +}; + +// allows a core instance to access extensions internally +Core.prototype.extension = extension; + +// included extensions +incExts.forEach(function (group) { + group.extensions.forEach(function (ext) { + setExtension(group.type, ext.name, ext.impl); + }); +}); + +// a dummy stylesheet object that doesn't need a reference to the core +// (useful for init) +var Stylesheet = function Stylesheet() { + if (!(this instanceof Stylesheet)) { + return new Stylesheet(); + } + this.length = 0; +}; +var sheetfn = Stylesheet.prototype; +sheetfn.instanceString = function () { + return 'stylesheet'; +}; + +// just store the selector to be parsed later +sheetfn.selector = function (selector) { + var i = this.length++; + this[i] = { + selector: selector, + properties: [] + }; + return this; // chaining +}; + +// just store the property to be parsed later +sheetfn.css = function (name, value) { + var i = this.length - 1; + if (string(name)) { + this[i].properties.push({ + name: name, + value: value + }); + } else if (plainObject(name)) { + var map = name; + var propNames = Object.keys(map); + for (var j = 0; j < propNames.length; j++) { + var key = propNames[j]; + var mapVal = map[key]; + if (mapVal == null) { + continue; + } + var prop = Style.properties[key] || Style.properties[dash2camel(key)]; + if (prop == null) { + continue; + } + var _name = prop.name; + var _value = mapVal; + this[i].properties.push({ + name: _name, + value: _value + }); + } + } + return this; // chaining +}; + +sheetfn.style = sheetfn.css; + +// generate a real style object from the dummy stylesheet +sheetfn.generateStyle = function (cy) { + var style = new Style(cy); + return this.appendToStyle(style); +}; + +// append a dummy stylesheet object on a real style object +sheetfn.appendToStyle = function (style) { + for (var i = 0; i < this.length; i++) { + var context = this[i]; + var selector = context.selector; + var props = context.properties; + style.selector(selector); // apply selector + + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + style.css(prop.name, prop.value); // apply property + } + } + + return style; +}; + +var version = "3.29.2"; + +var cytoscape$1 = function cytoscape(options) { + // if no options specified, use default + if (options === undefined) { + options = {}; + } + + // create instance + if (plainObject(options)) { + return new Core(options); + } + + // allow for registration of extensions + else if (string(options)) { + return extension.apply(extension, arguments); + } +}; + +// e.g. cytoscape.use( require('cytoscape-foo'), bar ) +cytoscape$1.use = function (ext) { + var args = Array.prototype.slice.call(arguments, 1); // args to pass to ext + + args.unshift(cytoscape$1); // cytoscape is first arg to ext + + ext.apply(null, args); + return this; +}; +cytoscape$1.warnings = function (bool) { + return warnings(bool); +}; + +// replaced by build system +cytoscape$1.version = version; + +// expose public apis (mostly for extensions) +cytoscape$1.stylesheet = cytoscape$1.Stylesheet = Stylesheet; + +var cytoscapeCoseBilkent = {exports: {}}; + +var coseBase = {exports: {}}; + +var layoutBase = {exports: {}}; + +var hasRequiredLayoutBase; + +function requireLayoutBase () { + if (hasRequiredLayoutBase) return layoutBase.exports; + hasRequiredLayoutBase = 1; + (function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(); + })(commonjsGlobal$1, function() { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 26); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports, __webpack_require__) { + + + function LayoutConstants() {} + + /** + * Layout Quality: 0:draft, 1:default, 2:proof + */ + LayoutConstants.QUALITY = 1; + + /** + * Default parameters + */ + LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; + LayoutConstants.DEFAULT_INCREMENTAL = false; + LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; + LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; + LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; + LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; + + // ----------------------------------------------------------------------------- + // Section: General other constants + // ----------------------------------------------------------------------------- + /* + * Margins of a graph to be applied on bouding rectangle of its contents. We + * assume margins on all four sides to be uniform. + */ + LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; + + /* + * Whether to consider labels in node dimensions or not + */ + LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; + + /* + * Default dimension of a non-compound node. + */ + LayoutConstants.SIMPLE_NODE_SIZE = 40; + + /* + * Default dimension of a non-compound node. + */ + LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; + + /* + * Empty compound node size. When a compound node is empty, its both + * dimensions should be of this value. + */ + LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; + + /* + * Minimum length that an edge should take during layout + */ + LayoutConstants.MIN_EDGE_LENGTH = 1; + + /* + * World boundaries that layout operates on + */ + LayoutConstants.WORLD_BOUNDARY = 1000000; + + /* + * World boundaries that random positioning can be performed with + */ + LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000; + + /* + * Coordinates of the world center + */ + LayoutConstants.WORLD_CENTER_X = 1200; + LayoutConstants.WORLD_CENTER_Y = 900; + + module.exports = LayoutConstants; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var IGeometry = __webpack_require__(8); + var IMath = __webpack_require__(9); + + function LEdge(source, target, vEdge) { + LGraphObject.call(this, vEdge); + + this.isOverlapingSourceAndTarget = false; + this.vGraphObject = vEdge; + this.bendpoints = []; + this.source = source; + this.target = target; + } + + LEdge.prototype = Object.create(LGraphObject.prototype); + + for (var prop in LGraphObject) { + LEdge[prop] = LGraphObject[prop]; + } + + LEdge.prototype.getSource = function () { + return this.source; + }; + + LEdge.prototype.getTarget = function () { + return this.target; + }; + + LEdge.prototype.isInterGraph = function () { + return this.isInterGraph; + }; + + LEdge.prototype.getLength = function () { + return this.length; + }; + + LEdge.prototype.isOverlapingSourceAndTarget = function () { + return this.isOverlapingSourceAndTarget; + }; + + LEdge.prototype.getBendpoints = function () { + return this.bendpoints; + }; + + LEdge.prototype.getLca = function () { + return this.lca; + }; + + LEdge.prototype.getSourceInLca = function () { + return this.sourceInLca; + }; + + LEdge.prototype.getTargetInLca = function () { + return this.targetInLca; + }; + + LEdge.prototype.getOtherEnd = function (node) { + if (this.source === node) { + return this.target; + } else if (this.target === node) { + return this.source; + } else { + throw "Node is not incident with this edge"; + } + }; + + LEdge.prototype.getOtherEndInGraph = function (node, graph) { + var otherEnd = this.getOtherEnd(node); + var root = graph.getGraphManager().getRoot(); + + while (true) { + if (otherEnd.getOwner() == graph) { + return otherEnd; + } + + if (otherEnd.getOwner() == root) { + break; + } + + otherEnd = otherEnd.getOwner().getParent(); + } + + return null; + }; + + LEdge.prototype.updateLength = function () { + var clipPointCoordinates = new Array(4); + + this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates); + + if (!this.isOverlapingSourceAndTarget) { + this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; + this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + } + }; + + LEdge.prototype.updateLengthSimple = function () { + this.lengthX = this.target.getCenterX() - this.source.getCenterX(); + this.lengthY = this.target.getCenterY() - this.source.getCenterY(); + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + }; + + module.exports = LEdge; + + /***/ }), + /* 2 */ + /***/ (function(module, exports, __webpack_require__) { + + + function LGraphObject(vGraphObject) { + this.vGraphObject = vGraphObject; + } + + module.exports = LGraphObject; + + /***/ }), + /* 3 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var Integer = __webpack_require__(10); + var RectangleD = __webpack_require__(13); + var LayoutConstants = __webpack_require__(0); + var RandomSeed = __webpack_require__(16); + var PointD = __webpack_require__(4); + + function LNode(gm, loc, size, vNode) { + //Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode) + if (size == null && vNode == null) { + vNode = loc; + } + + LGraphObject.call(this, vNode); + + //Alternative constructor 2 : LNode(Layout layout, Object vNode) + if (gm.graphManager != null) gm = gm.graphManager; + + this.estimatedSize = Integer.MIN_VALUE; + this.inclusionTreeDepth = Integer.MAX_VALUE; + this.vGraphObject = vNode; + this.edges = []; + this.graphManager = gm; + + if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);else this.rect = new RectangleD(); + } + + LNode.prototype = Object.create(LGraphObject.prototype); + for (var prop in LGraphObject) { + LNode[prop] = LGraphObject[prop]; + } + + LNode.prototype.getEdges = function () { + return this.edges; + }; + + LNode.prototype.getChild = function () { + return this.child; + }; + + LNode.prototype.getOwner = function () { + // if (this.owner != null) { + // if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) { + // throw "assert failed"; + // } + // } + + return this.owner; + }; + + LNode.prototype.getWidth = function () { + return this.rect.width; + }; + + LNode.prototype.setWidth = function (width) { + this.rect.width = width; + }; + + LNode.prototype.getHeight = function () { + return this.rect.height; + }; + + LNode.prototype.setHeight = function (height) { + this.rect.height = height; + }; + + LNode.prototype.getCenterX = function () { + return this.rect.x + this.rect.width / 2; + }; + + LNode.prototype.getCenterY = function () { + return this.rect.y + this.rect.height / 2; + }; + + LNode.prototype.getCenter = function () { + return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2); + }; + + LNode.prototype.getLocation = function () { + return new PointD(this.rect.x, this.rect.y); + }; + + LNode.prototype.getRect = function () { + return this.rect; + }; + + LNode.prototype.getDiagonal = function () { + return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height); + }; + + /** + * This method returns half the diagonal length of this node. + */ + LNode.prototype.getHalfTheDiagonal = function () { + return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2; + }; + + LNode.prototype.setRect = function (upperLeft, dimension) { + this.rect.x = upperLeft.x; + this.rect.y = upperLeft.y; + this.rect.width = dimension.width; + this.rect.height = dimension.height; + }; + + LNode.prototype.setCenter = function (cx, cy) { + this.rect.x = cx - this.rect.width / 2; + this.rect.y = cy - this.rect.height / 2; + }; + + LNode.prototype.setLocation = function (x, y) { + this.rect.x = x; + this.rect.y = y; + }; + + LNode.prototype.moveBy = function (dx, dy) { + this.rect.x += dx; + this.rect.y += dy; + }; + + LNode.prototype.getEdgeListToNode = function (to) { + var edgeList = []; + var self = this; + + self.edges.forEach(function (edge) { + + if (edge.target == to) { + if (edge.source != self) throw "Incorrect edge source!"; + + edgeList.push(edge); + } + }); + + return edgeList; + }; + + LNode.prototype.getEdgesBetween = function (other) { + var edgeList = []; + + var self = this; + self.edges.forEach(function (edge) { + + if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target"; + + if (edge.target == other || edge.source == other) { + edgeList.push(edge); + } + }); + + return edgeList; + }; + + LNode.prototype.getNeighborsList = function () { + var neighbors = new Set(); + + var self = this; + self.edges.forEach(function (edge) { + + if (edge.source == self) { + neighbors.add(edge.target); + } else { + if (edge.target != self) { + throw "Incorrect incidency!"; + } + + neighbors.add(edge.source); + } + }); + + return neighbors; + }; + + LNode.prototype.withChildren = function () { + var withNeighborsList = new Set(); + var childNode; + var children; + + withNeighborsList.add(this); + + if (this.child != null) { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + children = childNode.withChildren(); + children.forEach(function (node) { + withNeighborsList.add(node); + }); + } + } + + return withNeighborsList; + }; + + LNode.prototype.getNoOfChildren = function () { + var noOfChildren = 0; + var childNode; + + if (this.child == null) { + noOfChildren = 1; + } else { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + + noOfChildren += childNode.getNoOfChildren(); + } + } + + if (noOfChildren == 0) { + noOfChildren = 1; + } + return noOfChildren; + }; + + LNode.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; + }; + + LNode.prototype.calcEstimatedSize = function () { + if (this.child == null) { + return this.estimatedSize = (this.rect.width + this.rect.height) / 2; + } else { + this.estimatedSize = this.child.calcEstimatedSize(); + this.rect.width = this.estimatedSize; + this.rect.height = this.estimatedSize; + + return this.estimatedSize; + } + }; + + LNode.prototype.scatter = function () { + var randomCenterX; + var randomCenterY; + + var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX; + + var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY; + + this.rect.x = randomCenterX; + this.rect.y = randomCenterY; + }; + + LNode.prototype.updateBounds = function () { + if (this.getChild() == null) { + throw "assert failed"; + } + if (this.getChild().getNodes().length != 0) { + // wrap the children nodes by re-arranging the boundaries + var childGraph = this.getChild(); + childGraph.updateBounds(true); + + this.rect.x = childGraph.getLeft(); + this.rect.y = childGraph.getTop(); + + this.setWidth(childGraph.getRight() - childGraph.getLeft()); + this.setHeight(childGraph.getBottom() - childGraph.getTop()); + + // Update compound bounds considering its label properties + if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = childGraph.getRight() - childGraph.getLeft(); + var height = childGraph.getBottom() - childGraph.getTop(); + + if (this.labelWidth > width) { + this.rect.x -= (this.labelWidth - width) / 2; + this.setWidth(this.labelWidth); + } + + if (this.labelHeight > height) { + if (this.labelPos == "center") { + this.rect.y -= (this.labelHeight - height) / 2; + } else if (this.labelPos == "top") { + this.rect.y -= this.labelHeight - height; + } + this.setHeight(this.labelHeight); + } + } + } + }; + + LNode.prototype.getInclusionTreeDepth = function () { + if (this.inclusionTreeDepth == Integer.MAX_VALUE) { + throw "assert failed"; + } + return this.inclusionTreeDepth; + }; + + LNode.prototype.transform = function (trans) { + var left = this.rect.x; + + if (left > LayoutConstants.WORLD_BOUNDARY) { + left = LayoutConstants.WORLD_BOUNDARY; + } else if (left < -LayoutConstants.WORLD_BOUNDARY) { + left = -LayoutConstants.WORLD_BOUNDARY; + } + + var top = this.rect.y; + + if (top > LayoutConstants.WORLD_BOUNDARY) { + top = LayoutConstants.WORLD_BOUNDARY; + } else if (top < -LayoutConstants.WORLD_BOUNDARY) { + top = -LayoutConstants.WORLD_BOUNDARY; + } + + var leftTop = new PointD(left, top); + var vLeftTop = trans.inverseTransformPoint(leftTop); + + this.setLocation(vLeftTop.x, vLeftTop.y); + }; + + LNode.prototype.getLeft = function () { + return this.rect.x; + }; + + LNode.prototype.getRight = function () { + return this.rect.x + this.rect.width; + }; + + LNode.prototype.getTop = function () { + return this.rect.y; + }; + + LNode.prototype.getBottom = function () { + return this.rect.y + this.rect.height; + }; + + LNode.prototype.getParent = function () { + if (this.owner == null) { + return null; + } + + return this.owner.getParent(); + }; + + module.exports = LNode; + + /***/ }), + /* 4 */ + /***/ (function(module, exports, __webpack_require__) { + + + function PointD(x, y) { + if (x == null && y == null) { + this.x = 0; + this.y = 0; + } else { + this.x = x; + this.y = y; + } + } + + PointD.prototype.getX = function () { + return this.x; + }; + + PointD.prototype.getY = function () { + return this.y; + }; + + PointD.prototype.setX = function (x) { + this.x = x; + }; + + PointD.prototype.setY = function (y) { + this.y = y; + }; + + PointD.prototype.getDifference = function (pt) { + return new DimensionD(this.x - pt.x, this.y - pt.y); + }; + + PointD.prototype.getCopy = function () { + return new PointD(this.x, this.y); + }; + + PointD.prototype.translate = function (dim) { + this.x += dim.width; + this.y += dim.height; + return this; + }; + + module.exports = PointD; + + /***/ }), + /* 5 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var Integer = __webpack_require__(10); + var LayoutConstants = __webpack_require__(0); + var LGraphManager = __webpack_require__(6); + var LNode = __webpack_require__(3); + var LEdge = __webpack_require__(1); + var RectangleD = __webpack_require__(13); + var Point = __webpack_require__(12); + var LinkedList = __webpack_require__(11); + + function LGraph(parent, obj2, vGraph) { + LGraphObject.call(this, vGraph); + this.estimatedSize = Integer.MIN_VALUE; + this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; + this.edges = []; + this.nodes = []; + this.isConnected = false; + this.parent = parent; + + if (obj2 != null && obj2 instanceof LGraphManager) { + this.graphManager = obj2; + } else if (obj2 != null && obj2 instanceof Layout) { + this.graphManager = obj2.graphManager; + } + } + + LGraph.prototype = Object.create(LGraphObject.prototype); + for (var prop in LGraphObject) { + LGraph[prop] = LGraphObject[prop]; + } + + LGraph.prototype.getNodes = function () { + return this.nodes; + }; + + LGraph.prototype.getEdges = function () { + return this.edges; + }; + + LGraph.prototype.getGraphManager = function () { + return this.graphManager; + }; + + LGraph.prototype.getParent = function () { + return this.parent; + }; + + LGraph.prototype.getLeft = function () { + return this.left; + }; + + LGraph.prototype.getRight = function () { + return this.right; + }; + + LGraph.prototype.getTop = function () { + return this.top; + }; + + LGraph.prototype.getBottom = function () { + return this.bottom; + }; + + LGraph.prototype.isConnected = function () { + return this.isConnected; + }; + + LGraph.prototype.add = function (obj1, sourceNode, targetNode) { + if (sourceNode == null && targetNode == null) { + var newNode = obj1; + if (this.graphManager == null) { + throw "Graph has no graph mgr!"; + } + if (this.getNodes().indexOf(newNode) > -1) { + throw "Node already in graph!"; + } + newNode.owner = this; + this.getNodes().push(newNode); + + return newNode; + } else { + var newEdge = obj1; + if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) { + throw "Source or target not in graph!"; + } + + if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { + throw "Both owners must be this graph!"; + } + + if (sourceNode.owner != targetNode.owner) { + return null; + } + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // set as intra-graph edge + newEdge.isInterGraph = false; + + // add to graph edge list + this.getEdges().push(newEdge); + + // add to incidency lists + sourceNode.edges.push(newEdge); + + if (targetNode != sourceNode) { + targetNode.edges.push(newEdge); + } + + return newEdge; + } + }; + + LGraph.prototype.remove = function (obj) { + var node = obj; + if (obj instanceof LNode) { + if (node == null) { + throw "Node is null!"; + } + if (!(node.owner != null && node.owner == this)) { + throw "Owner graph is invalid!"; + } + if (this.graphManager == null) { + throw "Owner graph manager is invalid!"; + } + // remove incident edges first (make a copy to do it safely) + var edgesToBeRemoved = node.edges.slice(); + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + + if (edge.isInterGraph) { + this.graphManager.remove(edge); + } else { + edge.source.owner.remove(edge); + } + } + + // now the node itself + var index = this.nodes.indexOf(node); + if (index == -1) { + throw "Node not in owner node list!"; + } + + this.nodes.splice(index, 1); + } else if (obj instanceof LEdge) { + var edge = obj; + if (edge == null) { + throw "Edge is null!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) { + throw "Source and/or target owner is invalid!"; + } + + var sourceIndex = edge.source.edges.indexOf(edge); + var targetIndex = edge.target.edges.indexOf(edge); + if (!(sourceIndex > -1 && targetIndex > -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + edge.source.edges.splice(sourceIndex, 1); + + if (edge.target != edge.source) { + edge.target.edges.splice(targetIndex, 1); + } + + var index = edge.source.owner.getEdges().indexOf(edge); + if (index == -1) { + throw "Not in owner's edge list!"; + } + + edge.source.owner.getEdges().splice(index, 1); + } + }; + + LGraph.prototype.updateLeftTop = function () { + var top = Integer.MAX_VALUE; + var left = Integer.MAX_VALUE; + var nodeTop; + var nodeLeft; + var margin; + + var nodes = this.getNodes(); + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeTop = lNode.getTop(); + nodeLeft = lNode.getLeft(); + + if (top > nodeTop) { + top = nodeTop; + } + + if (left > nodeLeft) { + left = nodeLeft; + } + } + + // Do we have any nodes in this graph? + if (top == Integer.MAX_VALUE) { + return null; + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = left - margin; + this.top = top - margin; + + // Apply the margins and return the result + return new Point(this.left, this.top); + }; + + LGraph.prototype.updateBounds = function (recursive) { + // calculate bounds + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + var margin; + + var nodes = this.nodes; + var s = nodes.length; + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + + if (recursive && lNode.child != null) { + lNode.updateBounds(); + } + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + if (left == Integer.MAX_VALUE) { + this.left = this.parent.getLeft(); + this.right = this.parent.getRight(); + this.top = this.parent.getTop(); + this.bottom = this.parent.getBottom(); + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = boundingRect.x - margin; + this.right = boundingRect.x + boundingRect.width + margin; + this.top = boundingRect.y - margin; + this.bottom = boundingRect.y + boundingRect.height + margin; + }; + + LGraph.calculateBounds = function (nodes) { + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + + return boundingRect; + }; + + LGraph.prototype.getInclusionTreeDepth = function () { + if (this == this.graphManager.getRoot()) { + return 1; + } else { + return this.parent.getInclusionTreeDepth(); + } + }; + + LGraph.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; + }; + + LGraph.prototype.calcEstimatedSize = function () { + var size = 0; + var nodes = this.nodes; + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + size += lNode.calcEstimatedSize(); + } + + if (size == 0) { + this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; + } else { + this.estimatedSize = size / Math.sqrt(this.nodes.length); + } + + return this.estimatedSize; + }; + + LGraph.prototype.updateConnected = function () { + var self = this; + if (this.nodes.length == 0) { + this.isConnected = true; + return; + } + + var queue = new LinkedList(); + var visited = new Set(); + var currentNode = this.nodes[0]; + var neighborEdges; + var currentNeighbor; + var childrenOfNode = currentNode.withChildren(); + childrenOfNode.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + + while (queue.length !== 0) { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + neighborEdges = currentNode.getEdges(); + var size = neighborEdges.length; + for (var i = 0; i < size; i++) { + var neighborEdge = neighborEdges[i]; + currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this); + + // Add unvisited neighbors to the list to visit + if (currentNeighbor != null && !visited.has(currentNeighbor)) { + var childrenOfNeighbor = currentNeighbor.withChildren(); + + childrenOfNeighbor.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + } + } + } + + this.isConnected = false; + + if (visited.size >= this.nodes.length) { + var noOfVisitedInThisGraph = 0; + + visited.forEach(function (visitedNode) { + if (visitedNode.owner == self) { + noOfVisitedInThisGraph++; + } + }); + + if (noOfVisitedInThisGraph == this.nodes.length) { + this.isConnected = true; + } + } + }; + + module.exports = LGraph; + + /***/ }), + /* 6 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraph; + var LEdge = __webpack_require__(1); + + function LGraphManager(layout) { + LGraph = __webpack_require__(5); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now. + this.layout = layout; + + this.graphs = []; + this.edges = []; + } + + LGraphManager.prototype.addRoot = function () { + var ngraph = this.layout.newGraph(); + var nnode = this.layout.newNode(null); + var root = this.add(ngraph, nnode); + this.setRootGraph(root); + return this.rootGraph; + }; + + LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) { + //there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge + if (newEdge == null && sourceNode == null && targetNode == null) { + if (newGraph == null) { + throw "Graph is null!"; + } + if (parentNode == null) { + throw "Parent node is null!"; + } + if (this.graphs.indexOf(newGraph) > -1) { + throw "Graph already in this graph mgr!"; + } + + this.graphs.push(newGraph); + + if (newGraph.parent != null) { + throw "Already has a parent!"; + } + if (parentNode.child != null) { + throw "Already has a child!"; + } + + newGraph.parent = parentNode; + parentNode.child = newGraph; + + return newGraph; + } else { + //change the order of the parameters + targetNode = newEdge; + sourceNode = parentNode; + newEdge = newGraph; + var sourceGraph = sourceNode.getOwner(); + var targetGraph = targetNode.getOwner(); + + if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { + throw "Source not in this graph mgr!"; + } + if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { + throw "Target not in this graph mgr!"; + } + + if (sourceGraph == targetGraph) { + newEdge.isInterGraph = false; + return sourceGraph.add(newEdge, sourceNode, targetNode); + } else { + newEdge.isInterGraph = true; + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // add edge to inter-graph edge list + if (this.edges.indexOf(newEdge) > -1) { + throw "Edge already in inter-graph edge list!"; + } + + this.edges.push(newEdge); + + // add edge to source and target incidency lists + if (!(newEdge.source != null && newEdge.target != null)) { + throw "Edge source and/or target is null!"; + } + + if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { + throw "Edge already in source and/or target incidency list!"; + } + + newEdge.source.edges.push(newEdge); + newEdge.target.edges.push(newEdge); + + return newEdge; + } + } + }; + + LGraphManager.prototype.remove = function (lObj) { + if (lObj instanceof LGraph) { + var graph = lObj; + if (graph.getGraphManager() != this) { + throw "Graph not in this graph mgr"; + } + if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) { + throw "Invalid parent node!"; + } + + // first the edges (make a copy to do it safely) + var edgesToBeRemoved = []; + + edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); + + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + graph.remove(edge); + } + + // then the nodes (make a copy to do it safely) + var nodesToBeRemoved = []; + + nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); + + var node; + s = nodesToBeRemoved.length; + for (var i = 0; i < s; i++) { + node = nodesToBeRemoved[i]; + graph.remove(node); + } + + // check if graph is the root + if (graph == this.rootGraph) { + this.setRootGraph(null); + } + + // now remove the graph itself + var index = this.graphs.indexOf(graph); + this.graphs.splice(index, 1); + + // also reset the parent of the graph + graph.parent = null; + } else if (lObj instanceof LEdge) { + edge = lObj; + if (edge == null) { + throw "Edge is null!"; + } + if (!edge.isInterGraph) { + throw "Not an inter-graph edge!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + + // remove edge from source and target nodes' incidency lists + + if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + var index = edge.source.edges.indexOf(edge); + edge.source.edges.splice(index, 1); + index = edge.target.edges.indexOf(edge); + edge.target.edges.splice(index, 1); + + // remove edge from owner graph manager's inter-graph edge list + + if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { + throw "Edge owner graph or owner graph manager is null!"; + } + if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { + throw "Not in owner graph manager's edge list!"; + } + + var index = edge.source.owner.getGraphManager().edges.indexOf(edge); + edge.source.owner.getGraphManager().edges.splice(index, 1); + } + }; + + LGraphManager.prototype.updateBounds = function () { + this.rootGraph.updateBounds(true); + }; + + LGraphManager.prototype.getGraphs = function () { + return this.graphs; + }; + + LGraphManager.prototype.getAllNodes = function () { + if (this.allNodes == null) { + var nodeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < s; i++) { + nodeList = nodeList.concat(graphs[i].getNodes()); + } + this.allNodes = nodeList; + } + return this.allNodes; + }; + + LGraphManager.prototype.resetAllNodes = function () { + this.allNodes = null; + }; + + LGraphManager.prototype.resetAllEdges = function () { + this.allEdges = null; + }; + + LGraphManager.prototype.resetAllNodesToApplyGravitation = function () { + this.allNodesToApplyGravitation = null; + }; + + LGraphManager.prototype.getAllEdges = function () { + if (this.allEdges == null) { + var edgeList = []; + var graphs = this.getGraphs(); + graphs.length; + for (var i = 0; i < graphs.length; i++) { + edgeList = edgeList.concat(graphs[i].getEdges()); + } + + edgeList = edgeList.concat(this.edges); + + this.allEdges = edgeList; + } + return this.allEdges; + }; + + LGraphManager.prototype.getAllNodesToApplyGravitation = function () { + return this.allNodesToApplyGravitation; + }; + + LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) { + if (this.allNodesToApplyGravitation != null) { + throw "assert failed"; + } + + this.allNodesToApplyGravitation = nodeList; + }; + + LGraphManager.prototype.getRoot = function () { + return this.rootGraph; + }; + + LGraphManager.prototype.setRootGraph = function (graph) { + if (graph.getGraphManager() != this) { + throw "Root not in this graph mgr!"; + } + + this.rootGraph = graph; + // root graph must have a root node associated with it for convenience + if (graph.parent == null) { + graph.parent = this.layout.newNode("Root node"); + } + }; + + LGraphManager.prototype.getLayout = function () { + return this.layout; + }; + + LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) { + if (!(firstNode != null && secondNode != null)) { + throw "assert failed"; + } + + if (firstNode == secondNode) { + return true; + } + // Is second node an ancestor of the first one? + var ownerGraph = firstNode.getOwner(); + var parentNode; + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == secondNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + // Is first node an ancestor of the second one? + ownerGraph = secondNode.getOwner(); + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == firstNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + + return false; + }; + + LGraphManager.prototype.calcLowestCommonAncestors = function () { + var edge; + var sourceNode; + var targetNode; + var sourceAncestorGraph; + var targetAncestorGraph; + + var edges = this.getAllEdges(); + var s = edges.length; + for (var i = 0; i < s; i++) { + edge = edges[i]; + + sourceNode = edge.source; + targetNode = edge.target; + edge.lca = null; + edge.sourceInLca = sourceNode; + edge.targetInLca = targetNode; + + if (sourceNode == targetNode) { + edge.lca = sourceNode.getOwner(); + continue; + } + + sourceAncestorGraph = sourceNode.getOwner(); + + while (edge.lca == null) { + edge.targetInLca = targetNode; + targetAncestorGraph = targetNode.getOwner(); + + while (edge.lca == null) { + if (targetAncestorGraph == sourceAncestorGraph) { + edge.lca = targetAncestorGraph; + break; + } + + if (targetAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca != null) { + throw "assert failed"; + } + edge.targetInLca = targetAncestorGraph.getParent(); + targetAncestorGraph = edge.targetInLca.getOwner(); + } + + if (sourceAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca == null) { + edge.sourceInLca = sourceAncestorGraph.getParent(); + sourceAncestorGraph = edge.sourceInLca.getOwner(); + } + } + + if (edge.lca == null) { + throw "assert failed"; + } + } + }; + + LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) { + if (firstNode == secondNode) { + return firstNode.getOwner(); + } + var firstOwnerGraph = firstNode.getOwner(); + + do { + if (firstOwnerGraph == null) { + break; + } + var secondOwnerGraph = secondNode.getOwner(); + + do { + if (secondOwnerGraph == null) { + break; + } + + if (secondOwnerGraph == firstOwnerGraph) { + return secondOwnerGraph; + } + secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); + } while (true); + + firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); + } while (true); + + return firstOwnerGraph; + }; + + LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) { + if (graph == null && depth == null) { + graph = this.rootGraph; + depth = 1; + } + var node; + + var nodes = graph.getNodes(); + var s = nodes.length; + for (var i = 0; i < s; i++) { + node = nodes[i]; + node.inclusionTreeDepth = depth; + + if (node.child != null) { + this.calcInclusionTreeDepths(node.child, depth + 1); + } + } + }; + + LGraphManager.prototype.includesInvalidEdge = function () { + var edge; + + var s = this.edges.length; + for (var i = 0; i < s; i++) { + edge = this.edges[i]; + + if (this.isOneAncestorOfOther(edge.source, edge.target)) { + return true; + } + } + return false; + }; + + module.exports = LGraphManager; + + /***/ }), + /* 7 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LayoutConstants = __webpack_require__(0); + + function FDLayoutConstants() {} + + //FDLayoutConstants inherits static props in LayoutConstants + for (var prop in LayoutConstants) { + FDLayoutConstants[prop] = LayoutConstants[prop]; + } + + FDLayoutConstants.MAX_ITERATIONS = 2500; + + FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; + FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45; + FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0; + FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4; + FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0; + FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8; + FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5; + FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true; + FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true; + FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3; + FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33; + FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000; + FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000; + FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0; + FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3; + FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; + FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100; + FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1; + FDLayoutConstants.MIN_EDGE_LENGTH = 1; + FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10; + + module.exports = FDLayoutConstants; + + /***/ }), + /* 8 */ + /***/ (function(module, exports, __webpack_require__) { + + + /** + * This class maintains a list of static geometry related utility methods. + * + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + + var Point = __webpack_require__(12); + + function IGeometry() {} + + /** + * This method calculates *half* the amount in x and y directions of the two + * input rectangles needed to separate them keeping their respective + * positioning, and returns the result in the input array. An input + * separation buffer added to the amount in both directions. We assume that + * the two rectangles do intersect. + */ + IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) { + if (!rectA.intersects(rectB)) { + throw "assert failed"; + } + + var directions = new Array(2); + + this.decideDirectionsForOverlappingNodes(rectA, rectB, directions); + + overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x); + overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y); + + // update the overlapping amounts for the following cases: + if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) { + /* Case x.1: + * + * rectA + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectB + */ + overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight()); + } else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) { + /* Case x.2: + * + * rectB + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectA + */ + overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight()); + } + if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) { + /* Case y.1: + * ________ rectA + * | + * | + * ______|____ rectB + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom()); + } else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) { + /* Case y.2: + * ________ rectB + * | + * | + * ______|____ rectA + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom()); + } + + // find slope of the line passes two centers + var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX())); + // if centers are overlapped + if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) { + // assume the slope is 1 (45 degree) + slope = 1.0; + } + + var moveByY = slope * overlapAmount[0]; + var moveByX = overlapAmount[1] / slope; + if (overlapAmount[0] < moveByX) { + moveByX = overlapAmount[0]; + } else { + moveByY = overlapAmount[1]; + } + // return half the amount so that if each rectangle is moved by these + // amounts in opposite directions, overlap will be resolved + overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer); + overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer); + }; + + /** + * This method decides the separation direction of overlapping nodes + * + * if directions[0] = -1, then rectA goes left + * if directions[0] = 1, then rectA goes right + * if directions[1] = -1, then rectA goes up + * if directions[1] = 1, then rectA goes down + */ + IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) { + if (rectA.getCenterX() < rectB.getCenterX()) { + directions[0] = -1; + } else { + directions[0] = 1; + } + + if (rectA.getCenterY() < rectB.getCenterY()) { + directions[1] = -1; + } else { + directions[1] = 1; + } + }; + + /** + * This method calculates the intersection (clipping) points of the two + * input rectangles with line segment defined by the centers of these two + * rectangles. The clipping points are saved in the input double array and + * whether or not the two rectangles overlap is returned. + */ + IGeometry.getIntersection2 = function (rectA, rectB, result) { + //result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB + var p1x = rectA.getCenterX(); + var p1y = rectA.getCenterY(); + var p2x = rectB.getCenterX(); + var p2y = rectB.getCenterY(); + + //if two rectangles intersect, then clipping points are centers + if (rectA.intersects(rectB)) { + result[0] = p1x; + result[1] = p1y; + result[2] = p2x; + result[3] = p2y; + return true; + } + //variables for rectA + var topLeftAx = rectA.getX(); + var topLeftAy = rectA.getY(); + var topRightAx = rectA.getRight(); + var bottomLeftAx = rectA.getX(); + var bottomLeftAy = rectA.getBottom(); + var bottomRightAx = rectA.getRight(); + var halfWidthA = rectA.getWidthHalf(); + var halfHeightA = rectA.getHeightHalf(); + //variables for rectB + var topLeftBx = rectB.getX(); + var topLeftBy = rectB.getY(); + var topRightBx = rectB.getRight(); + var bottomLeftBx = rectB.getX(); + var bottomLeftBy = rectB.getBottom(); + var bottomRightBx = rectB.getRight(); + var halfWidthB = rectB.getWidthHalf(); + var halfHeightB = rectB.getHeightHalf(); + + //flag whether clipping points are found + var clipPointAFound = false; + var clipPointBFound = false; + + // line is vertical + if (p1x === p2x) { + if (p1y > p2y) { + result[0] = p1x; + result[1] = topLeftAy; + result[2] = p2x; + result[3] = bottomLeftBy; + return false; + } else if (p1y < p2y) { + result[0] = p1x; + result[1] = bottomLeftAy; + result[2] = p2x; + result[3] = topLeftBy; + return false; + } else ; + } + // line is horizontal + else if (p1y === p2y) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = p1y; + result[2] = topRightBx; + result[3] = p2y; + return false; + } else if (p1x < p2x) { + result[0] = topRightAx; + result[1] = p1y; + result[2] = topLeftBx; + result[3] = p2y; + return false; + } else ; + } else { + //slopes of rectA's and rectB's diagonals + var slopeA = rectA.height / rectA.width; + var slopeB = rectB.height / rectB.width; + + //slope of line between center of rectA and center of rectB + var slopePrime = (p2y - p1y) / (p2x - p1x); + var cardinalDirectionA = void 0; + var cardinalDirectionB = void 0; + var tempPointAx = void 0; + var tempPointAy = void 0; + var tempPointBx = void 0; + var tempPointBy = void 0; + + //determine whether clipping point is the corner of nodeA + if (-slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = bottomLeftAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } else { + result[0] = topRightAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + } else if (slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = topLeftAy; + clipPointAFound = true; + } else { + result[0] = bottomRightAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + } + + //determine whether clipping point is the corner of nodeB + if (-slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = bottomLeftBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } else { + result[2] = topRightBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + } else if (slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = topLeftBx; + result[3] = topLeftBy; + clipPointBFound = true; + } else { + result[2] = bottomRightBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + } + + //if both clipping points are corners + if (clipPointAFound && clipPointBFound) { + return false; + } + + //determine Cardinal Direction of rectangles + if (p1x > p2x) { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2); + } else { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1); + } + } else { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3); + } else { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4); + } + } + //calculate clipping Point if it is not found before + if (!clipPointAFound) { + switch (cardinalDirectionA) { + case 1: + tempPointAy = topLeftAy; + tempPointAx = p1x + -halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 2: + tempPointAx = bottomRightAx; + tempPointAy = p1y + halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 3: + tempPointAy = bottomLeftAy; + tempPointAx = p1x + halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 4: + tempPointAx = bottomLeftAx; + tempPointAy = p1y + -halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + } + } + if (!clipPointBFound) { + switch (cardinalDirectionB) { + case 1: + tempPointBy = topLeftBy; + tempPointBx = p2x + -halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 2: + tempPointBx = bottomRightBx; + tempPointBy = p2y + halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 3: + tempPointBy = bottomLeftBy; + tempPointBx = p2x + halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 4: + tempPointBx = bottomLeftBx; + tempPointBy = p2y + -halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + } + } + } + return false; + }; + + /** + * This method returns in which cardinal direction does input point stays + * 1: North + * 2: East + * 3: South + * 4: West + */ + IGeometry.getCardinalDirection = function (slope, slopePrime, line) { + if (slope > slopePrime) { + return line; + } else { + return 1 + line % 4; + } + }; + + /** + * This method calculates the intersection of the two lines defined by + * point pairs (s1,s2) and (f1,f2). + */ + IGeometry.getIntersection = function (s1, s2, f1, f2) { + if (f2 == null) { + return this.getIntersection2(s1, s2, f1); + } + + var x1 = s1.x; + var y1 = s1.y; + var x2 = s2.x; + var y2 = s2.y; + var x3 = f1.x; + var y3 = f1.y; + var x4 = f2.x; + var y4 = f2.y; + var x = void 0, + y = void 0; // intersection point + var a1 = void 0, + a2 = void 0, + b1 = void 0, + b2 = void 0, + c1 = void 0, + c2 = void 0; // coefficients of line eqns. + var denom = void 0; + + a1 = y2 - y1; + b1 = x1 - x2; + c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 } + + a2 = y4 - y3; + b2 = x3 - x4; + c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 } + + denom = a1 * b2 - a2 * b1; + + if (denom === 0) { + return null; + } + + x = (b1 * c2 - b2 * c1) / denom; + y = (a2 * c1 - a1 * c2) / denom; + + return new Point(x, y); + }; + + /** + * This method finds and returns the angle of the vector from the + x-axis + * in clockwise direction (compatible w/ Java coordinate system!). + */ + IGeometry.angleOfVector = function (Cx, Cy, Nx, Ny) { + var C_angle = void 0; + + if (Cx !== Nx) { + C_angle = Math.atan((Ny - Cy) / (Nx - Cx)); + + if (Nx < Cx) { + C_angle += Math.PI; + } else if (Ny < Cy) { + C_angle += this.TWO_PI; + } + } else if (Ny < Cy) { + C_angle = this.ONE_AND_HALF_PI; // 270 degrees + } else { + C_angle = this.HALF_PI; // 90 degrees + } + + return C_angle; + }; + + /** + * This method checks whether the given two line segments (one with point + * p1 and p2, the other with point p3 and p4) intersect at a point other + * than these points. + */ + IGeometry.doIntersect = function (p1, p2, p3, p4) { + var a = p1.x; + var b = p1.y; + var c = p2.x; + var d = p2.y; + var p = p3.x; + var q = p3.y; + var r = p4.x; + var s = p4.y; + var det = (c - a) * (s - q) - (r - p) * (d - b); + + if (det === 0) { + return false; + } else { + var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det; + var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det; + return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1; + } + }; + + // ----------------------------------------------------------------------------- + // Section: Class Constants + // ----------------------------------------------------------------------------- + /** + * Some useful pre-calculated constants + */ + IGeometry.HALF_PI = 0.5 * Math.PI; + IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI; + IGeometry.TWO_PI = 2.0 * Math.PI; + IGeometry.THREE_PI = 3.0 * Math.PI; + + module.exports = IGeometry; + + /***/ }), + /* 9 */ + /***/ (function(module, exports, __webpack_require__) { + + + function IMath() {} + + /** + * This method returns the sign of the input value. + */ + IMath.sign = function (value) { + if (value > 0) { + return 1; + } else if (value < 0) { + return -1; + } else { + return 0; + } + }; + + IMath.floor = function (value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); + }; + + IMath.ceil = function (value) { + return value < 0 ? Math.floor(value) : Math.ceil(value); + }; + + module.exports = IMath; + + /***/ }), + /* 10 */ + /***/ (function(module, exports, __webpack_require__) { + + + function Integer() {} + + Integer.MAX_VALUE = 2147483647; + Integer.MIN_VALUE = -2147483648; + + module.exports = Integer; + + /***/ }), + /* 11 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var nodeFrom = function nodeFrom(value) { + return { value: value, next: null, prev: null }; + }; + + var add = function add(prev, node, next, list) { + if (prev !== null) { + prev.next = node; + } else { + list.head = node; + } + + if (next !== null) { + next.prev = node; + } else { + list.tail = node; + } + + node.prev = prev; + node.next = next; + + list.length++; + + return node; + }; + + var _remove = function _remove(node, list) { + var prev = node.prev, + next = node.next; + + + if (prev !== null) { + prev.next = next; + } else { + list.head = next; + } + + if (next !== null) { + next.prev = prev; + } else { + list.tail = prev; + } + + node.prev = node.next = null; + + list.length--; + + return node; + }; + + var LinkedList = function () { + function LinkedList(vals) { + var _this = this; + + _classCallCheck(this, LinkedList); + + this.length = 0; + this.head = null; + this.tail = null; + + if (vals != null) { + vals.forEach(function (v) { + return _this.push(v); + }); + } + } + + _createClass(LinkedList, [{ + key: "size", + value: function size() { + return this.length; + } + }, { + key: "insertBefore", + value: function insertBefore(val, otherNode) { + return add(otherNode.prev, nodeFrom(val), otherNode, this); + } + }, { + key: "insertAfter", + value: function insertAfter(val, otherNode) { + return add(otherNode, nodeFrom(val), otherNode.next, this); + } + }, { + key: "insertNodeBefore", + value: function insertNodeBefore(newNode, otherNode) { + return add(otherNode.prev, newNode, otherNode, this); + } + }, { + key: "insertNodeAfter", + value: function insertNodeAfter(newNode, otherNode) { + return add(otherNode, newNode, otherNode.next, this); + } + }, { + key: "push", + value: function push(val) { + return add(this.tail, nodeFrom(val), null, this); + } + }, { + key: "unshift", + value: function unshift(val) { + return add(null, nodeFrom(val), this.head, this); + } + }, { + key: "remove", + value: function remove(node) { + return _remove(node, this); + } + }, { + key: "pop", + value: function pop() { + return _remove(this.tail, this).value; + } + }, { + key: "popNode", + value: function popNode() { + return _remove(this.tail, this); + } + }, { + key: "shift", + value: function shift() { + return _remove(this.head, this).value; + } + }, { + key: "shiftNode", + value: function shiftNode() { + return _remove(this.head, this); + } + }, { + key: "get_object_at", + value: function get_object_at(index) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + return current.value; + } + } + }, { + key: "set_object_at", + value: function set_object_at(index, value) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + current.value = value; + } + } + }]); + + return LinkedList; + }(); + + module.exports = LinkedList; + + /***/ }), + /* 12 */ + /***/ (function(module, exports, __webpack_require__) { + + + /* + *This class is the javascript implementation of the Point.java class in jdk + */ + function Point(x, y, p) { + this.x = null; + this.y = null; + if (x == null && y == null && p == null) { + this.x = 0; + this.y = 0; + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + this.x = x; + this.y = y; + } else if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.x = p.x; + this.y = p.y; + } + } + + Point.prototype.getX = function () { + return this.x; + }; + + Point.prototype.getY = function () { + return this.y; + }; + + Point.prototype.getLocation = function () { + return new Point(this.x, this.y); + }; + + Point.prototype.setLocation = function (x, y, p) { + if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.setLocation(p.x, p.y); + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + //if both parameters are integer just move (x,y) location + if (parseInt(x) == x && parseInt(y) == y) { + this.move(x, y); + } else { + this.x = Math.floor(x + 0.5); + this.y = Math.floor(y + 0.5); + } + } + }; + + Point.prototype.move = function (x, y) { + this.x = x; + this.y = y; + }; + + Point.prototype.translate = function (dx, dy) { + this.x += dx; + this.y += dy; + }; + + Point.prototype.equals = function (obj) { + if (obj.constructor.name == "Point") { + var pt = obj; + return this.x == pt.x && this.y == pt.y; + } + return this == obj; + }; + + Point.prototype.toString = function () { + return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]"; + }; + + module.exports = Point; + + /***/ }), + /* 13 */ + /***/ (function(module, exports, __webpack_require__) { + + + function RectangleD(x, y, width, height) { + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + + if (x != null && y != null && width != null && height != null) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + } + + RectangleD.prototype.getX = function () { + return this.x; + }; + + RectangleD.prototype.setX = function (x) { + this.x = x; + }; + + RectangleD.prototype.getY = function () { + return this.y; + }; + + RectangleD.prototype.setY = function (y) { + this.y = y; + }; + + RectangleD.prototype.getWidth = function () { + return this.width; + }; + + RectangleD.prototype.setWidth = function (width) { + this.width = width; + }; + + RectangleD.prototype.getHeight = function () { + return this.height; + }; + + RectangleD.prototype.setHeight = function (height) { + this.height = height; + }; + + RectangleD.prototype.getRight = function () { + return this.x + this.width; + }; + + RectangleD.prototype.getBottom = function () { + return this.y + this.height; + }; + + RectangleD.prototype.intersects = function (a) { + if (this.getRight() < a.x) { + return false; + } + + if (this.getBottom() < a.y) { + return false; + } + + if (a.getRight() < this.x) { + return false; + } + + if (a.getBottom() < this.y) { + return false; + } + + return true; + }; + + RectangleD.prototype.getCenterX = function () { + return this.x + this.width / 2; + }; + + RectangleD.prototype.getMinX = function () { + return this.getX(); + }; + + RectangleD.prototype.getMaxX = function () { + return this.getX() + this.width; + }; + + RectangleD.prototype.getCenterY = function () { + return this.y + this.height / 2; + }; + + RectangleD.prototype.getMinY = function () { + return this.getY(); + }; + + RectangleD.prototype.getMaxY = function () { + return this.getY() + this.height; + }; + + RectangleD.prototype.getWidthHalf = function () { + return this.width / 2; + }; + + RectangleD.prototype.getHeightHalf = function () { + return this.height / 2; + }; + + module.exports = RectangleD; + + /***/ }), + /* 14 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function UniqueIDGeneretor() {} + + UniqueIDGeneretor.lastID = 0; + + UniqueIDGeneretor.createID = function (obj) { + if (UniqueIDGeneretor.isPrimitive(obj)) { + return obj; + } + if (obj.uniqueID != null) { + return obj.uniqueID; + } + obj.uniqueID = UniqueIDGeneretor.getString(); + UniqueIDGeneretor.lastID++; + return obj.uniqueID; + }; + + UniqueIDGeneretor.getString = function (id) { + if (id == null) id = UniqueIDGeneretor.lastID; + return "Object#" + id + ""; + }; + + UniqueIDGeneretor.isPrimitive = function (arg) { + var type = typeof arg === "undefined" ? "undefined" : _typeof(arg); + return arg == null || type != "object" && type != "function"; + }; + + module.exports = UniqueIDGeneretor; + + /***/ }), + /* 15 */ + /***/ (function(module, exports, __webpack_require__) { + + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var LayoutConstants = __webpack_require__(0); + var LGraphManager = __webpack_require__(6); + var LNode = __webpack_require__(3); + var LEdge = __webpack_require__(1); + var LGraph = __webpack_require__(5); + var PointD = __webpack_require__(4); + var Transform = __webpack_require__(17); + var Emitter = __webpack_require__(27); + + function Layout(isRemoteUse) { + Emitter.call(this); + + //Layout Quality: 0:draft, 1:default, 2:proof + this.layoutQuality = LayoutConstants.QUALITY; + //Whether layout should create bendpoints as needed or not + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + //Whether layout should be incremental or not + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + //Whether we animate from before to after layout node positions + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + //Whether we animate the layout process or not + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + //Number iterations that should be done between two successive animations + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + /** + * Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When + * they are, both spring and repulsion forces between two leaf nodes can be + * calculated without the expensive clipping point calculations, resulting + * in major speed-up. + */ + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + /** + * This is used for creation of bendpoints by using dummy nodes and edges. + * Maps an LEdge to its dummy bendpoint path. + */ + this.edgeToDummyNodes = new Map(); + this.graphManager = new LGraphManager(this); + this.isLayoutFinished = false; + this.isSubLayout = false; + this.isRemoteUse = false; + + if (isRemoteUse != null) { + this.isRemoteUse = isRemoteUse; + } + } + + Layout.RANDOM_SEED = 1; + + Layout.prototype = Object.create(Emitter.prototype); + + Layout.prototype.getGraphManager = function () { + return this.graphManager; + }; + + Layout.prototype.getAllNodes = function () { + return this.graphManager.getAllNodes(); + }; + + Layout.prototype.getAllEdges = function () { + return this.graphManager.getAllEdges(); + }; + + Layout.prototype.getAllNodesToApplyGravitation = function () { + return this.graphManager.getAllNodesToApplyGravitation(); + }; + + Layout.prototype.newGraphManager = function () { + var gm = new LGraphManager(this); + this.graphManager = gm; + return gm; + }; + + Layout.prototype.newGraph = function (vGraph) { + return new LGraph(null, this.graphManager, vGraph); + }; + + Layout.prototype.newNode = function (vNode) { + return new LNode(this.graphManager, vNode); + }; + + Layout.prototype.newEdge = function (vEdge) { + return new LEdge(null, null, vEdge); + }; + + Layout.prototype.checkLayoutSuccess = function () { + return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge(); + }; + + Layout.prototype.runLayout = function () { + this.isLayoutFinished = false; + + if (this.tilingPreLayout) { + this.tilingPreLayout(); + } + + this.initParameters(); + var isLayoutSuccessfull; + + if (this.checkLayoutSuccess()) { + isLayoutSuccessfull = false; + } else { + isLayoutSuccessfull = this.layout(); + } + + if (LayoutConstants.ANIMATE === 'during') { + // If this is a 'during' layout animation. Layout is not finished yet. + // We need to perform these in index.js when layout is really finished. + return false; + } + + if (isLayoutSuccessfull) { + if (!this.isSubLayout) { + this.doPostLayout(); + } + } + + if (this.tilingPostLayout) { + this.tilingPostLayout(); + } + + this.isLayoutFinished = true; + + return isLayoutSuccessfull; + }; + + /** + * This method performs the operations required after layout. + */ + Layout.prototype.doPostLayout = function () { + //assert !isSubLayout : "Should not be called on sub-layout!"; + // Propagate geometric changes to v-level objects + if (!this.incremental) { + this.transform(); + } + this.update(); + }; + + /** + * This method updates the geometry of the target graph according to + * calculated layout. + */ + Layout.prototype.update2 = function () { + // update bend points + if (this.createBendsAsNeeded) { + this.createBendpointsFromDummyNodes(); + + // reset all edges, since the topology has changed + this.graphManager.resetAllEdges(); + } + + // perform edge, node and root updates if layout is not called + // remotely + if (!this.isRemoteUse) { + var allEdges = this.graphManager.getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + allEdges[i]; + // this.update(edge); + } + var nodes = this.graphManager.getRoot().getNodes(); + for (var i = 0; i < nodes.length; i++) { + nodes[i]; + // this.update(node); + } + + // update root graph + this.update(this.graphManager.getRoot()); + } + }; + + Layout.prototype.update = function (obj) { + if (obj == null) { + this.update2(); + } else if (obj instanceof LNode) { + var node = obj; + if (node.getChild() != null) { + // since node is compound, recursively update child nodes + var nodes = node.getChild().getNodes(); + for (var i = 0; i < nodes.length; i++) { + update(nodes[i]); + } + } + + // if the l-level node is associated with a v-level graph object, + // then it is assumed that the v-level node implements the + // interface Updatable. + if (node.vGraphObject != null) { + // cast to Updatable without any type check + var vNode = node.vGraphObject; + + // call the update method of the interface + vNode.update(node); + } + } else if (obj instanceof LEdge) { + var edge = obj; + // if the l-level edge is associated with a v-level graph object, + // then it is assumed that the v-level edge implements the + // interface Updatable. + + if (edge.vGraphObject != null) { + // cast to Updatable without any type check + var vEdge = edge.vGraphObject; + + // call the update method of the interface + vEdge.update(edge); + } + } else if (obj instanceof LGraph) { + var graph = obj; + // if the l-level graph is associated with a v-level graph object, + // then it is assumed that the v-level object implements the + // interface Updatable. + + if (graph.vGraphObject != null) { + // cast to Updatable without any type check + var vGraph = graph.vGraphObject; + + // call the update method of the interface + vGraph.update(graph); + } + } + }; + + /** + * This method is used to set all layout parameters to default values + * determined at compile time. + */ + Layout.prototype.initParameters = function () { + if (!this.isSubLayout) { + this.layoutQuality = LayoutConstants.QUALITY; + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + } + + if (this.animationDuringLayout) { + this.animationOnLayout = false; + } + }; + + Layout.prototype.transform = function (newLeftTop) { + if (newLeftTop == undefined) { + this.transform(new PointD(0, 0)); + } else { + // create a transformation object (from Eclipse to layout). When an + // inverse transform is applied, we get upper-left coordinate of the + // drawing or the root graph at given input coordinate (some margins + // already included in calculation of left-top). + + var trans = new Transform(); + var leftTop = this.graphManager.getRoot().updateLeftTop(); + + if (leftTop != null) { + trans.setWorldOrgX(newLeftTop.x); + trans.setWorldOrgY(newLeftTop.y); + + trans.setDeviceOrgX(leftTop.x); + trans.setDeviceOrgY(leftTop.y); + + var nodes = this.getAllNodes(); + var node; + + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + node.transform(trans); + } + } + } + }; + + Layout.prototype.positionNodesRandomly = function (graph) { + + if (graph == undefined) { + //assert !this.incremental; + this.positionNodesRandomly(this.getGraphManager().getRoot()); + this.getGraphManager().getRoot().updateBounds(true); + } else { + var lNode; + var childGraph; + + var nodes = graph.getNodes(); + for (var i = 0; i < nodes.length; i++) { + lNode = nodes[i]; + childGraph = lNode.getChild(); + + if (childGraph == null) { + lNode.scatter(); + } else if (childGraph.getNodes().length == 0) { + lNode.scatter(); + } else { + this.positionNodesRandomly(childGraph); + lNode.updateBounds(); + } + } + } + }; + + /** + * This method returns a list of trees where each tree is represented as a + * list of l-nodes. The method returns a list of size 0 when: + * - The graph is not flat or + * - One of the component(s) of the graph is not a tree. + */ + Layout.prototype.getFlatForest = function () { + var flatForest = []; + var isForest = true; + + // Quick reference for all nodes in the graph manager associated with + // this layout. The list should not be changed. + var allNodes = this.graphManager.getRoot().getNodes(); + + // First be sure that the graph is flat + var isFlat = true; + + for (var i = 0; i < allNodes.length; i++) { + if (allNodes[i].getChild() != null) { + isFlat = false; + } + } + + // Return empty forest if the graph is not flat. + if (!isFlat) { + return flatForest; + } + + // Run BFS for each component of the graph. + + var visited = new Set(); + var toBeVisited = []; + var parents = new Map(); + var unProcessedNodes = []; + + unProcessedNodes = unProcessedNodes.concat(allNodes); + + // Each iteration of this loop finds a component of the graph and + // decides whether it is a tree or not. If it is a tree, adds it to the + // forest and continued with the next component. + + while (unProcessedNodes.length > 0 && isForest) { + toBeVisited.push(unProcessedNodes[0]); + + // Start the BFS. Each iteration of this loop visits a node in a + // BFS manner. + while (toBeVisited.length > 0 && isForest) { + //pool operation + var currentNode = toBeVisited[0]; + toBeVisited.splice(0, 1); + visited.add(currentNode); + + // Traverse all neighbors of this node + var neighborEdges = currentNode.getEdges(); + + for (var i = 0; i < neighborEdges.length; i++) { + var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode); + + // If BFS is not growing from this neighbor. + if (parents.get(currentNode) != currentNeighbor) { + // We haven't previously visited this neighbor. + if (!visited.has(currentNeighbor)) { + toBeVisited.push(currentNeighbor); + parents.set(currentNeighbor, currentNode); + } + // Since we have previously visited this neighbor and + // this neighbor is not parent of currentNode, given + // graph contains a component that is not tree, hence + // it is not a forest. + else { + isForest = false; + break; + } + } + } + } + + // The graph contains a component that is not a tree. Empty + // previously found trees. The method will end. + if (!isForest) { + flatForest = []; + } + // Save currently visited nodes as a tree in our forest. Reset + // visited and parents lists. Continue with the next component of + // the graph, if any. + else { + var temp = [].concat(_toConsumableArray(visited)); + flatForest.push(temp); + //flatForest = flatForest.concat(temp); + //unProcessedNodes.removeAll(visited); + for (var i = 0; i < temp.length; i++) { + var value = temp[i]; + var index = unProcessedNodes.indexOf(value); + if (index > -1) { + unProcessedNodes.splice(index, 1); + } + } + visited = new Set(); + parents = new Map(); + } + } + + return flatForest; + }; + + /** + * This method creates dummy nodes (an l-level node with minimal dimensions) + * for the given edge (one per bendpoint). The existing l-level structure + * is updated accordingly. + */ + Layout.prototype.createDummyNodesForBendpoints = function (edge) { + var dummyNodes = []; + var prev = edge.source; + + var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target); + + for (var i = 0; i < edge.bendpoints.length; i++) { + // create new dummy node + var dummyNode = this.newNode(null); + dummyNode.setRect(new Point(0, 0), new Dimension(1, 1)); + + graph.add(dummyNode); + + // create new dummy edge between prev and dummy node + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, dummyNode); + + dummyNodes.add(dummyNode); + prev = dummyNode; + } + + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, edge.target); + + this.edgeToDummyNodes.set(edge, dummyNodes); + + // remove real edge from graph manager if it is inter-graph + if (edge.isInterGraph()) { + this.graphManager.remove(edge); + } + // else, remove the edge from the current graph + else { + graph.remove(edge); + } + + return dummyNodes; + }; + + /** + * This method creates bendpoints for edges from the dummy nodes + * at l-level. + */ + Layout.prototype.createBendpointsFromDummyNodes = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges); + + for (var k = 0; k < edges.length; k++) { + var lEdge = edges[k]; + + if (lEdge.bendpoints.length > 0) { + var path = this.edgeToDummyNodes.get(lEdge); + + for (var i = 0; i < path.length; i++) { + var dummyNode = path[i]; + var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY()); + + // update bendpoint's location according to dummy node + var ebp = lEdge.bendpoints.get(i); + ebp.x = p.x; + ebp.y = p.y; + + // remove the dummy node, dummy edges incident with this + // dummy node is also removed (within the remove method) + dummyNode.getOwner().remove(dummyNode); + } + + // add the real edge to graph + this.graphManager.add(lEdge, lEdge.source, lEdge.target); + } + } + }; + + Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) { + if (minDiv != undefined && maxMul != undefined) { + var value = defaultValue; + + if (sliderValue <= 50) { + var minValue = defaultValue / minDiv; + value -= (defaultValue - minValue) / 50 * (50 - sliderValue); + } else { + var maxValue = defaultValue * maxMul; + value += (maxValue - defaultValue) / 50 * (sliderValue - 50); + } + + return value; + } else { + var a, b; + + if (sliderValue <= 50) { + a = 9.0 * defaultValue / 500.0; + b = defaultValue / 10.0; + } else { + a = 9.0 * defaultValue / 50.0; + b = -8 * defaultValue; + } + + return a * sliderValue + b; + } + }; + + /** + * This method finds and returns the center of the given nodes, assuming + * that the given nodes form a tree in themselves. + */ + Layout.findCenterOfTree = function (nodes) { + var list = []; + list = list.concat(nodes); + + var removedNodes = []; + var remainingDegrees = new Map(); + var foundCenter = false; + var centerNode = null; + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + var degree = node.getNeighborsList().size; + remainingDegrees.set(node, node.getNeighborsList().size); + + if (degree == 1) { + removedNodes.push(node); + } + } + + var tempList = []; + tempList = tempList.concat(removedNodes); + + while (!foundCenter) { + var tempList2 = []; + tempList2 = tempList2.concat(tempList); + tempList = []; + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + + var index = list.indexOf(node); + if (index >= 0) { + list.splice(index, 1); + } + + var neighbours = node.getNeighborsList(); + + neighbours.forEach(function (neighbour) { + if (removedNodes.indexOf(neighbour) < 0) { + var otherDegree = remainingDegrees.get(neighbour); + var newDegree = otherDegree - 1; + + if (newDegree == 1) { + tempList.push(neighbour); + } + + remainingDegrees.set(neighbour, newDegree); + } + }); + } + + removedNodes = removedNodes.concat(tempList); + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + } + + return centerNode; + }; + + /** + * During the coarsening process, this layout may be referenced by two graph managers + * this setter function grants access to change the currently being used graph manager + */ + Layout.prototype.setGraphManager = function (gm) { + this.graphManager = gm; + }; + + module.exports = Layout; + + /***/ }), + /* 16 */ + /***/ (function(module, exports, __webpack_require__) { + + + function RandomSeed() {} + // adapted from: https://stackoverflow.com/a/19303725 + RandomSeed.seed = 1; + RandomSeed.x = 0; + + RandomSeed.nextDouble = function () { + RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000; + return RandomSeed.x - Math.floor(RandomSeed.x); + }; + + module.exports = RandomSeed; + + /***/ }), + /* 17 */ + /***/ (function(module, exports, __webpack_require__) { + + + var PointD = __webpack_require__(4); + + function Transform(x, y) { + this.lworldOrgX = 0.0; + this.lworldOrgY = 0.0; + this.ldeviceOrgX = 0.0; + this.ldeviceOrgY = 0.0; + this.lworldExtX = 1.0; + this.lworldExtY = 1.0; + this.ldeviceExtX = 1.0; + this.ldeviceExtY = 1.0; + } + + Transform.prototype.getWorldOrgX = function () { + return this.lworldOrgX; + }; + + Transform.prototype.setWorldOrgX = function (wox) { + this.lworldOrgX = wox; + }; + + Transform.prototype.getWorldOrgY = function () { + return this.lworldOrgY; + }; + + Transform.prototype.setWorldOrgY = function (woy) { + this.lworldOrgY = woy; + }; + + Transform.prototype.getWorldExtX = function () { + return this.lworldExtX; + }; + + Transform.prototype.setWorldExtX = function (wex) { + this.lworldExtX = wex; + }; + + Transform.prototype.getWorldExtY = function () { + return this.lworldExtY; + }; + + Transform.prototype.setWorldExtY = function (wey) { + this.lworldExtY = wey; + }; + + /* Device related */ + + Transform.prototype.getDeviceOrgX = function () { + return this.ldeviceOrgX; + }; + + Transform.prototype.setDeviceOrgX = function (dox) { + this.ldeviceOrgX = dox; + }; + + Transform.prototype.getDeviceOrgY = function () { + return this.ldeviceOrgY; + }; + + Transform.prototype.setDeviceOrgY = function (doy) { + this.ldeviceOrgY = doy; + }; + + Transform.prototype.getDeviceExtX = function () { + return this.ldeviceExtX; + }; + + Transform.prototype.setDeviceExtX = function (dex) { + this.ldeviceExtX = dex; + }; + + Transform.prototype.getDeviceExtY = function () { + return this.ldeviceExtY; + }; + + Transform.prototype.setDeviceExtY = function (dey) { + this.ldeviceExtY = dey; + }; + + Transform.prototype.transformX = function (x) { + var xDevice = 0.0; + var worldExtX = this.lworldExtX; + if (worldExtX != 0.0) { + xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX; + } + + return xDevice; + }; + + Transform.prototype.transformY = function (y) { + var yDevice = 0.0; + var worldExtY = this.lworldExtY; + if (worldExtY != 0.0) { + yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY; + } + + return yDevice; + }; + + Transform.prototype.inverseTransformX = function (x) { + var xWorld = 0.0; + var deviceExtX = this.ldeviceExtX; + if (deviceExtX != 0.0) { + xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX; + } + + return xWorld; + }; + + Transform.prototype.inverseTransformY = function (y) { + var yWorld = 0.0; + var deviceExtY = this.ldeviceExtY; + if (deviceExtY != 0.0) { + yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY; + } + return yWorld; + }; + + Transform.prototype.inverseTransformPoint = function (inPoint) { + var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y)); + return outPoint; + }; + + module.exports = Transform; + + /***/ }), + /* 18 */ + /***/ (function(module, exports, __webpack_require__) { + + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var Layout = __webpack_require__(15); + var FDLayoutConstants = __webpack_require__(7); + var LayoutConstants = __webpack_require__(0); + var IGeometry = __webpack_require__(8); + var IMath = __webpack_require__(9); + + function FDLayout() { + Layout.call(this); + + this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100; + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.totalDisplacement = 0.0; + this.oldTotalDisplacement = 0.0; + this.maxIterations = FDLayoutConstants.MAX_ITERATIONS; + } + + FDLayout.prototype = Object.create(Layout.prototype); + + for (var prop in Layout) { + FDLayout[prop] = Layout[prop]; + } + + FDLayout.prototype.initParameters = function () { + Layout.prototype.initParameters.call(this, arguments); + + this.totalIterations = 0; + this.notAnimatedIterations = 0; + + this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION; + + this.grid = []; + }; + + FDLayout.prototype.calcIdealEdgeLengths = function () { + var edge; + var lcaDepth; + var source; + var target; + var sizeOfSourceInLca; + var sizeOfTargetInLca; + + var allEdges = this.getGraphManager().getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + + edge.idealLength = this.idealEdgeLength; + + if (edge.isInterGraph) { + source = edge.getSource(); + target = edge.getTarget(); + + sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize(); + sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize(); + + if (this.useSmartIdealEdgeLengthCalculation) { + edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE; + } + + lcaDepth = edge.getLca().getInclusionTreeDepth(); + + edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth); + } + } + }; + + FDLayout.prototype.initSpringEmbedder = function () { + + var s = this.getAllNodes().length; + if (this.incremental) { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL; + } else { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } else { + this.coolingFactor = 1.0; + } + this.initialCoolingFactor = this.coolingFactor; + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT; + } + + this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations); + + this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length; + + this.repulsionRange = this.calcRepulsionRange(); + }; + + FDLayout.prototype.calcSpringForces = function () { + var lEdges = this.getAllEdges(); + var edge; + + for (var i = 0; i < lEdges.length; i++) { + edge = lEdges[i]; + + this.calcSpringForce(edge, edge.idealLength); + } + }; + + FDLayout.prototype.calcRepulsionForces = function () { + var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + var i, j; + var nodeA, nodeB; + var lNodes = this.getAllNodes(); + var processedNodeSet; + + if (this.useFRGridVariant) { + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) { + this.updateGrid(); + } + + processedNodeSet = new Set(); + + // calculate repulsion forces between each nodes and its surrounding + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate); + processedNodeSet.add(nodeA); + } + } else { + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + + for (j = i + 1; j < lNodes.length; j++) { + nodeB = lNodes[j]; + + // If both nodes are not members of the same graph, skip. + if (nodeA.getOwner() != nodeB.getOwner()) { + continue; + } + + this.calcRepulsionForce(nodeA, nodeB); + } + } + } + }; + + FDLayout.prototype.calcGravitationalForces = function () { + var node; + var lNodes = this.getAllNodesToApplyGravitation(); + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + this.calcGravitationalForce(node); + } + }; + + FDLayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.move(); + } + }; + + FDLayout.prototype.calcSpringForce = function (edge, idealLength) { + var sourceNode = edge.getSource(); + var targetNode = edge.getTarget(); + + var length; + var springForce; + var springForceX; + var springForceY; + + // Update edge length + if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) { + edge.updateLengthSimple(); + } else { + edge.updateLength(); + + if (edge.isOverlapingSourceAndTarget) { + return; + } + } + + length = edge.getLength(); + + if (length == 0) return; + + // Calculate spring forces + springForce = this.springConstant * (length - idealLength); + + // Project force onto x and y axes + springForceX = springForce * (edge.lengthX / length); + springForceY = springForce * (edge.lengthY / length); + + // Apply forces on the end nodes + sourceNode.springForceX += springForceX; + sourceNode.springForceY += springForceY; + targetNode.springForceX -= springForceX; + targetNode.springForceY -= springForceY; + }; + + FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) { + var rectA = nodeA.getRect(); + var rectB = nodeB.getRect(); + var overlapAmount = new Array(2); + var clipPoints = new Array(4); + var distanceX; + var distanceY; + var distanceSquared; + var distance; + var repulsionForce; + var repulsionForceX; + var repulsionForceY; + + if (rectA.intersects(rectB)) // two nodes overlap + { + // calculate separation amount in x and y directions + IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0); + + repulsionForceX = 2 * overlapAmount[0]; + repulsionForceY = 2 * overlapAmount[1]; + + var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); + + // Apply forces on the two nodes + nodeA.repulsionForceX -= childrenConstant * repulsionForceX; + nodeA.repulsionForceY -= childrenConstant * repulsionForceY; + nodeB.repulsionForceX += childrenConstant * repulsionForceX; + nodeB.repulsionForceY += childrenConstant * repulsionForceY; + } else // no overlap + { + // calculate distance + + if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) // simply base repulsion on distance of node centers + { + distanceX = rectB.getCenterX() - rectA.getCenterX(); + distanceY = rectB.getCenterY() - rectA.getCenterY(); + } else // use clipping points + { + IGeometry.getIntersection(rectA, rectB, clipPoints); + + distanceX = clipPoints[2] - clipPoints[0]; + distanceY = clipPoints[3] - clipPoints[1]; + } + + // No repulsion range. FR grid variant should take care of this. + if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + distanceSquared = distanceX * distanceX + distanceY * distanceY; + distance = Math.sqrt(distanceSquared); + + repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; + + // Project force onto x and y axes + repulsionForceX = repulsionForce * distanceX / distance; + repulsionForceY = repulsionForce * distanceY / distance; + + // Apply forces on the two nodes + nodeA.repulsionForceX -= repulsionForceX; + nodeA.repulsionForceY -= repulsionForceY; + nodeB.repulsionForceX += repulsionForceX; + nodeB.repulsionForceY += repulsionForceY; + } + }; + + FDLayout.prototype.calcGravitationalForce = function (node) { + var ownerGraph; + var ownerCenterX; + var ownerCenterY; + var distanceX; + var distanceY; + var absDistanceX; + var absDistanceY; + var estimatedSize; + ownerGraph = node.getOwner(); + + ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2; + ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2; + distanceX = node.getCenterX() - ownerCenterX; + distanceY = node.getCenterY() - ownerCenterY; + absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; + absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; + + if (node.getOwner() == this.graphManager.getRoot()) // in the root graph + { + estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX; + node.gravitationForceY = -this.gravityConstant * distanceY; + } + } else // inside a compound + { + estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant; + node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant; + } + } + }; + + FDLayout.prototype.isConverged = function () { + var converged; + var oscilating = false; + + if (this.totalIterations > this.maxIterations / 3) { + oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2; + } + + converged = this.totalDisplacement < this.totalDisplacementThreshold; + + this.oldTotalDisplacement = this.totalDisplacement; + + return converged || oscilating; + }; + + FDLayout.prototype.animate = function () { + if (this.animationDuringLayout && !this.isSubLayout) { + if (this.notAnimatedIterations == this.animationPeriod) { + this.update(); + this.notAnimatedIterations = 0; + } else { + this.notAnimatedIterations++; + } + } + }; + + //This method calculates the number of children (weight) for all nodes + FDLayout.prototype.calcNoOfChildrenForAllNodes = function () { + var node; + var allNodes = this.graphManager.getAllNodes(); + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + node.noOfChildren = node.getNoOfChildren(); + } + }; + + // ----------------------------------------------------------------------------- + // Section: FR-Grid Variant Repulsion Force Calculation + // ----------------------------------------------------------------------------- + + FDLayout.prototype.calcGrid = function (graph) { + + var sizeX = 0; + var sizeY = 0; + + sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange)); + sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange)); + + var grid = new Array(sizeX); + + for (var i = 0; i < sizeX; i++) { + grid[i] = new Array(sizeY); + } + + for (var i = 0; i < sizeX; i++) { + for (var j = 0; j < sizeY; j++) { + grid[i][j] = new Array(); + } + } + + return grid; + }; + + FDLayout.prototype.addNodeToGrid = function (v, left, top) { + + var startX = 0; + var finishX = 0; + var startY = 0; + var finishY = 0; + + startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange)); + finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange)); + startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange)); + finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange)); + + for (var i = startX; i <= finishX; i++) { + for (var j = startY; j <= finishY; j++) { + this.grid[i][j].push(v); + v.setGridCoordinates(startX, finishX, startY, finishY); + } + } + }; + + FDLayout.prototype.updateGrid = function () { + var i; + var nodeA; + var lNodes = this.getAllNodes(); + + this.grid = this.calcGrid(this.graphManager.getRoot()); + + // put all nodes to proper grid cells + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop()); + } + }; + + FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) { + + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) { + var surrounding = new Set(); + nodeA.surrounding = new Array(); + var nodeB; + var grid = this.grid; + + for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) { + for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) { + if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) { + for (var k = 0; k < grid[i][j].length; k++) { + nodeB = grid[i][j][k]; + + // If both nodes are not members of the same graph, + // or both nodes are the same, skip. + if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) { + continue; + } + + // check if the repulsion force between + // nodeA and nodeB has already been calculated + if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) { + var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2); + var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2); + + // if the distance between nodeA and nodeB + // is less then calculation range + if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) { + //then add nodeB to surrounding of nodeA + surrounding.add(nodeB); + } + } + } + } + } + } + + nodeA.surrounding = [].concat(_toConsumableArray(surrounding)); + } + for (i = 0; i < nodeA.surrounding.length; i++) { + this.calcRepulsionForce(nodeA, nodeA.surrounding[i]); + } + }; + + FDLayout.prototype.calcRepulsionRange = function () { + return 0.0; + }; + + module.exports = FDLayout; + + /***/ }), + /* 19 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LEdge = __webpack_require__(1); + var FDLayoutConstants = __webpack_require__(7); + + function FDLayoutEdge(source, target, vEdge) { + LEdge.call(this, source, target, vEdge); + this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + } + + FDLayoutEdge.prototype = Object.create(LEdge.prototype); + + for (var prop in LEdge) { + FDLayoutEdge[prop] = LEdge[prop]; + } + + module.exports = FDLayoutEdge; + + /***/ }), + /* 20 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LNode = __webpack_require__(3); + + function FDLayoutNode(gm, loc, size, vNode) { + // alternative constructor is handled inside LNode + LNode.call(this, gm, loc, size, vNode); + //Spring, repulsion and gravitational forces acting on this node + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + //Amount by which this node is to be moved in this iteration + this.displacementX = 0; + this.displacementY = 0; + + //Start and finish grid coordinates that this node is fallen into + this.startX = 0; + this.finishX = 0; + this.startY = 0; + this.finishY = 0; + + //Geometric neighbors of this node + this.surrounding = []; + } + + FDLayoutNode.prototype = Object.create(LNode.prototype); + + for (var prop in LNode) { + FDLayoutNode[prop] = LNode[prop]; + } + + FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) { + this.startX = _startX; + this.finishX = _finishX; + this.startY = _startY; + this.finishY = _finishY; + }; + + module.exports = FDLayoutNode; + + /***/ }), + /* 21 */ + /***/ (function(module, exports, __webpack_require__) { + + + function DimensionD(width, height) { + this.width = 0; + this.height = 0; + if (width !== null && height !== null) { + this.height = height; + this.width = width; + } + } + + DimensionD.prototype.getWidth = function () { + return this.width; + }; + + DimensionD.prototype.setWidth = function (width) { + this.width = width; + }; + + DimensionD.prototype.getHeight = function () { + return this.height; + }; + + DimensionD.prototype.setHeight = function (height) { + this.height = height; + }; + + module.exports = DimensionD; + + /***/ }), + /* 22 */ + /***/ (function(module, exports, __webpack_require__) { + + + var UniqueIDGeneretor = __webpack_require__(14); + + function HashMap() { + this.map = {}; + this.keys = []; + } + + HashMap.prototype.put = function (key, value) { + var theId = UniqueIDGeneretor.createID(key); + if (!this.contains(theId)) { + this.map[theId] = value; + this.keys.push(key); + } + }; + + HashMap.prototype.contains = function (key) { + UniqueIDGeneretor.createID(key); + return this.map[key] != null; + }; + + HashMap.prototype.get = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[theId]; + }; + + HashMap.prototype.keySet = function () { + return this.keys; + }; + + module.exports = HashMap; + + /***/ }), + /* 23 */ + /***/ (function(module, exports, __webpack_require__) { + + + var UniqueIDGeneretor = __webpack_require__(14); + + function HashSet() { + this.set = {}; + } + + HashSet.prototype.add = function (obj) { + var theId = UniqueIDGeneretor.createID(obj); + if (!this.contains(theId)) this.set[theId] = obj; + }; + + HashSet.prototype.remove = function (obj) { + delete this.set[UniqueIDGeneretor.createID(obj)]; + }; + + HashSet.prototype.clear = function () { + this.set = {}; + }; + + HashSet.prototype.contains = function (obj) { + return this.set[UniqueIDGeneretor.createID(obj)] == obj; + }; + + HashSet.prototype.isEmpty = function () { + return this.size() === 0; + }; + + HashSet.prototype.size = function () { + return Object.keys(this.set).length; + }; + + //concats this.set to the given list + HashSet.prototype.addAllTo = function (list) { + var keys = Object.keys(this.set); + var length = keys.length; + for (var i = 0; i < length; i++) { + list.push(this.set[keys[i]]); + } + }; + + HashSet.prototype.size = function () { + return Object.keys(this.set).length; + }; + + HashSet.prototype.addAll = function (list) { + var s = list.length; + for (var i = 0; i < s; i++) { + var v = list[i]; + this.add(v); + } + }; + + module.exports = HashSet; + + /***/ }), + /* 24 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * A classic Quicksort algorithm with Hoare's partition + * - Works also on LinkedList objects + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + + var LinkedList = __webpack_require__(11); + + var Quicksort = function () { + function Quicksort(A, compareFunction) { + _classCallCheck(this, Quicksort); + + if (compareFunction !== null || compareFunction !== undefined) this.compareFunction = this._defaultCompareFunction; + + var length = void 0; + if (A instanceof LinkedList) length = A.size();else length = A.length; + + this._quicksort(A, 0, length - 1); + } + + _createClass(Quicksort, [{ + key: '_quicksort', + value: function _quicksort(A, p, r) { + if (p < r) { + var q = this._partition(A, p, r); + this._quicksort(A, p, q); + this._quicksort(A, q + 1, r); + } + } + }, { + key: '_partition', + value: function _partition(A, p, r) { + var x = this._get(A, p); + var i = p; + var j = r; + while (true) { + while (this.compareFunction(x, this._get(A, j))) { + j--; + }while (this.compareFunction(this._get(A, i), x)) { + i++; + }if (i < j) { + this._swap(A, i, j); + i++; + j--; + } else return j; + } + } + }, { + key: '_get', + value: function _get(object, index) { + if (object instanceof LinkedList) return object.get_object_at(index);else return object[index]; + } + }, { + key: '_set', + value: function _set(object, index, value) { + if (object instanceof LinkedList) object.set_object_at(index, value);else object[index] = value; + } + }, { + key: '_swap', + value: function _swap(A, i, j) { + var temp = this._get(A, i); + this._set(A, i, this._get(A, j)); + this._set(A, j, temp); + } + }, { + key: '_defaultCompareFunction', + value: function _defaultCompareFunction(a, b) { + return b > a; + } + }]); + + return Quicksort; + }(); + + module.exports = Quicksort; + + /***/ }), + /* 25 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string + * sequences by S.B.Needleman and C.D.Wunsch (1970). + * + * Aside from the inputs, you can assign the scores for, + * - Match: The two characters at the current index are same. + * - Mismatch: The two characters at the current index are different. + * - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string. + */ + + var NeedlemanWunsch = function () { + function NeedlemanWunsch(sequence1, sequence2) { + var match_score = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + var mismatch_penalty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1; + var gap_penalty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + + _classCallCheck(this, NeedlemanWunsch); + + this.sequence1 = sequence1; + this.sequence2 = sequence2; + this.match_score = match_score; + this.mismatch_penalty = mismatch_penalty; + this.gap_penalty = gap_penalty; + + // Just the remove redundancy + this.iMax = sequence1.length + 1; + this.jMax = sequence2.length + 1; + + // Grid matrix of scores + this.grid = new Array(this.iMax); + for (var i = 0; i < this.iMax; i++) { + this.grid[i] = new Array(this.jMax); + + for (var j = 0; j < this.jMax; j++) { + this.grid[i][j] = 0; + } + } + + // Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions) + this.tracebackGrid = new Array(this.iMax); + for (var _i = 0; _i < this.iMax; _i++) { + this.tracebackGrid[_i] = new Array(this.jMax); + + for (var _j = 0; _j < this.jMax; _j++) { + this.tracebackGrid[_i][_j] = [null, null, null]; + } + } + + // The aligned sequences (return multiple possibilities) + this.alignments = []; + + // Final alignment score + this.score = -1; + + // Calculate scores and tracebacks + this.computeGrids(); + } + + _createClass(NeedlemanWunsch, [{ + key: "getScore", + value: function getScore() { + return this.score; + } + }, { + key: "getAlignments", + value: function getAlignments() { + return this.alignments; + } + + // Main dynamic programming procedure + + }, { + key: "computeGrids", + value: function computeGrids() { + // Fill in the first row + for (var j = 1; j < this.jMax; j++) { + this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty; + this.tracebackGrid[0][j] = [false, false, true]; + } + + // Fill in the first column + for (var i = 1; i < this.iMax; i++) { + this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty; + this.tracebackGrid[i][0] = [false, true, false]; + } + + // Fill the rest of the grid + for (var _i2 = 1; _i2 < this.iMax; _i2++) { + for (var _j2 = 1; _j2 < this.jMax; _j2++) { + // Find the max score(s) among [`Diag`, `Up`, `Left`] + var diag = void 0; + if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty; + + var up = this.grid[_i2 - 1][_j2] + this.gap_penalty; + var left = this.grid[_i2][_j2 - 1] + this.gap_penalty; + + // If there exists multiple max values, capture them for multiple paths + var maxOf = [diag, up, left]; + var indices = this.arrayAllMaxIndexes(maxOf); + + // Update Grids + this.grid[_i2][_j2] = maxOf[indices[0]]; + this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)]; + } + } + + // Update alignment score + this.score = this.grid[this.iMax - 1][this.jMax - 1]; + } + + // Gets all possible valid sequence combinations + + }, { + key: "alignmentTraceback", + value: function alignmentTraceback() { + var inProcessAlignments = []; + + inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length], + seq1: "", + seq2: "" + }); + + while (inProcessAlignments[0]) { + var current = inProcessAlignments[0]; + var directions = this.tracebackGrid[current.pos[0]][current.pos[1]]; + + if (directions[0]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1] - 1], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + if (directions[1]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1]], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: '-' + current.seq2 + }); + } + if (directions[2]) { + inProcessAlignments.push({ pos: [current.pos[0], current.pos[1] - 1], + seq1: '-' + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + + if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({ sequence1: current.seq1, + sequence2: current.seq2 + }); + + inProcessAlignments.shift(); + } + + return this.alignments; + } + + // Helper Functions + + }, { + key: "getAllIndexes", + value: function getAllIndexes(arr, val) { + var indexes = [], + i = -1; + while ((i = arr.indexOf(val, i + 1)) !== -1) { + indexes.push(i); + } + return indexes; + } + }, { + key: "arrayAllMaxIndexes", + value: function arrayAllMaxIndexes(array) { + return this.getAllIndexes(array, Math.max.apply(null, array)); + } + }]); + + return NeedlemanWunsch; + }(); + + module.exports = NeedlemanWunsch; + + /***/ }), + /* 26 */ + /***/ (function(module, exports, __webpack_require__) { + + + var layoutBase = function layoutBase() { + return; + }; + + layoutBase.FDLayout = __webpack_require__(18); + layoutBase.FDLayoutConstants = __webpack_require__(7); + layoutBase.FDLayoutEdge = __webpack_require__(19); + layoutBase.FDLayoutNode = __webpack_require__(20); + layoutBase.DimensionD = __webpack_require__(21); + layoutBase.HashMap = __webpack_require__(22); + layoutBase.HashSet = __webpack_require__(23); + layoutBase.IGeometry = __webpack_require__(8); + layoutBase.IMath = __webpack_require__(9); + layoutBase.Integer = __webpack_require__(10); + layoutBase.Point = __webpack_require__(12); + layoutBase.PointD = __webpack_require__(4); + layoutBase.RandomSeed = __webpack_require__(16); + layoutBase.RectangleD = __webpack_require__(13); + layoutBase.Transform = __webpack_require__(17); + layoutBase.UniqueIDGeneretor = __webpack_require__(14); + layoutBase.Quicksort = __webpack_require__(24); + layoutBase.LinkedList = __webpack_require__(11); + layoutBase.LGraphObject = __webpack_require__(2); + layoutBase.LGraph = __webpack_require__(5); + layoutBase.LEdge = __webpack_require__(1); + layoutBase.LGraphManager = __webpack_require__(6); + layoutBase.LNode = __webpack_require__(3); + layoutBase.Layout = __webpack_require__(15); + layoutBase.LayoutConstants = __webpack_require__(0); + layoutBase.NeedlemanWunsch = __webpack_require__(25); + + module.exports = layoutBase; + + /***/ }), + /* 27 */ + /***/ (function(module, exports, __webpack_require__) { + + + function Emitter() { + this.listeners = []; + } + + var p = Emitter.prototype; + + p.addListener = function (event, callback) { + this.listeners.push({ + event: event, + callback: callback + }); + }; + + p.removeListener = function (event, callback) { + for (var i = this.listeners.length; i >= 0; i--) { + var l = this.listeners[i]; + + if (l.event === event && l.callback === callback) { + this.listeners.splice(i, 1); + } + } + }; + + p.emit = function (event, data) { + for (var i = 0; i < this.listeners.length; i++) { + var l = this.listeners[i]; + + if (event === l.event) { + l.callback(data); + } + } + }; + + module.exports = Emitter; + + /***/ }) + /******/ ]); + }); + } (layoutBase)); + return layoutBase.exports; +} + +var hasRequiredCoseBase; + +function requireCoseBase () { + if (hasRequiredCoseBase) return coseBase.exports; + hasRequiredCoseBase = 1; + (function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(requireLayoutBase()); + })(commonjsGlobal$1, function(__WEBPACK_EXTERNAL_MODULE_0__) { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 7); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants; + + function CoSEConstants() {} + + //CoSEConstants inherits static props in FDLayoutConstants + for (var prop in FDLayoutConstants) { + CoSEConstants[prop] = FDLayoutConstants[prop]; + } + + CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false; + CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60; + CoSEConstants.TILE = true; + CoSEConstants.TILING_PADDING_VERTICAL = 10; + CoSEConstants.TILING_PADDING_HORIZONTAL = 10; + CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout + + module.exports = CoSEConstants; + + /***/ }), + /* 2 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutEdge = __webpack_require__(0).FDLayoutEdge; + + function CoSEEdge(source, target, vEdge) { + FDLayoutEdge.call(this, source, target, vEdge); + } + + CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype); + for (var prop in FDLayoutEdge) { + CoSEEdge[prop] = FDLayoutEdge[prop]; + } + + module.exports = CoSEEdge; + + /***/ }), + /* 3 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraph = __webpack_require__(0).LGraph; + + function CoSEGraph(parent, graphMgr, vGraph) { + LGraph.call(this, parent, graphMgr, vGraph); + } + + CoSEGraph.prototype = Object.create(LGraph.prototype); + for (var prop in LGraph) { + CoSEGraph[prop] = LGraph[prop]; + } + + module.exports = CoSEGraph; + + /***/ }), + /* 4 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphManager = __webpack_require__(0).LGraphManager; + + function CoSEGraphManager(layout) { + LGraphManager.call(this, layout); + } + + CoSEGraphManager.prototype = Object.create(LGraphManager.prototype); + for (var prop in LGraphManager) { + CoSEGraphManager[prop] = LGraphManager[prop]; + } + + module.exports = CoSEGraphManager; + + /***/ }), + /* 5 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutNode = __webpack_require__(0).FDLayoutNode; + var IMath = __webpack_require__(0).IMath; + + function CoSENode(gm, loc, size, vNode) { + FDLayoutNode.call(this, gm, loc, size, vNode); + } + + CoSENode.prototype = Object.create(FDLayoutNode.prototype); + for (var prop in FDLayoutNode) { + CoSENode[prop] = FDLayoutNode[prop]; + } + + CoSENode.prototype.move = function () { + var layout = this.graphManager.getLayout(); + this.displacementX = layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren; + this.displacementY = layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren; + + if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX); + } + + if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY); + } + + // a simple node, just move it + if (this.child == null) { + this.moveBy(this.displacementX, this.displacementY); + } + // an empty compound node, again just move it + else if (this.child.getNodes().length == 0) { + this.moveBy(this.displacementX, this.displacementY); + } + // non-empty compound node, propogate movement to children as well + else { + this.propogateDisplacementToChildren(this.displacementX, this.displacementY); + } + + layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY); + + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + this.displacementX = 0; + this.displacementY = 0; + }; + + CoSENode.prototype.propogateDisplacementToChildren = function (dX, dY) { + var nodes = this.getChild().getNodes(); + var node; + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + if (node.getChild() == null) { + node.moveBy(dX, dY); + node.displacementX += dX; + node.displacementY += dY; + } else { + node.propogateDisplacementToChildren(dX, dY); + } + } + }; + + CoSENode.prototype.setPred1 = function (pred1) { + this.pred1 = pred1; + }; + + CoSENode.prototype.getPred1 = function () { + return pred1; + }; + + CoSENode.prototype.getPred2 = function () { + return pred2; + }; + + CoSENode.prototype.setNext = function (next) { + this.next = next; + }; + + CoSENode.prototype.getNext = function () { + return next; + }; + + CoSENode.prototype.setProcessed = function (processed) { + this.processed = processed; + }; + + CoSENode.prototype.isProcessed = function () { + return processed; + }; + + module.exports = CoSENode; + + /***/ }), + /* 6 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayout = __webpack_require__(0).FDLayout; + var CoSEGraphManager = __webpack_require__(4); + var CoSEGraph = __webpack_require__(3); + var CoSENode = __webpack_require__(5); + var CoSEEdge = __webpack_require__(2); + var CoSEConstants = __webpack_require__(1); + var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants; + var LayoutConstants = __webpack_require__(0).LayoutConstants; + var Point = __webpack_require__(0).Point; + var PointD = __webpack_require__(0).PointD; + var Layout = __webpack_require__(0).Layout; + var Integer = __webpack_require__(0).Integer; + var IGeometry = __webpack_require__(0).IGeometry; + var LGraph = __webpack_require__(0).LGraph; + var Transform = __webpack_require__(0).Transform; + + function CoSELayout() { + FDLayout.call(this); + + this.toBeTiled = {}; // Memorize if a node is to be tiled or is tiled + } + + CoSELayout.prototype = Object.create(FDLayout.prototype); + + for (var prop in FDLayout) { + CoSELayout[prop] = FDLayout[prop]; + } + + CoSELayout.prototype.newGraphManager = function () { + var gm = new CoSEGraphManager(this); + this.graphManager = gm; + return gm; + }; + + CoSELayout.prototype.newGraph = function (vGraph) { + return new CoSEGraph(null, this.graphManager, vGraph); + }; + + CoSELayout.prototype.newNode = function (vNode) { + return new CoSENode(this.graphManager, vNode); + }; + + CoSELayout.prototype.newEdge = function (vEdge) { + return new CoSEEdge(null, null, vEdge); + }; + + CoSELayout.prototype.initParameters = function () { + FDLayout.prototype.initParameters.call(this, arguments); + if (!this.isSubLayout) { + if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) { + this.idealEdgeLength = 10; + } else { + this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH; + } + + this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + + // variables for tree reduction support + this.prunedNodesAll = []; + this.growTreeIterations = 0; + this.afterGrowthIterations = 0; + this.isTreeGrowing = false; + this.isGrowthFinished = false; + + // variables for cooling + this.coolingCycle = 0; + this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD; + this.finalTemperature = FDLayoutConstants.CONVERGENCE_CHECK_PERIOD / this.maxIterations; + this.coolingAdjuster = 1; + } + }; + + CoSELayout.prototype.layout = function () { + var createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + if (createBendsAsNeeded) { + this.createBendpoints(); + this.graphManager.resetAllEdges(); + } + + this.level = 0; + return this.classicLayout(); + }; + + CoSELayout.prototype.classicLayout = function () { + this.nodesWithGravity = this.calculateNodesToApplyGravitationTo(); + this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity); + this.calcNoOfChildrenForAllNodes(); + this.graphManager.calcLowestCommonAncestors(); + this.graphManager.calcInclusionTreeDepths(); + this.graphManager.getRoot().calcEstimatedSize(); + this.calcIdealEdgeLengths(); + + if (!this.incremental) { + var forest = this.getFlatForest(); + + // The graph associated with this layout is flat and a forest + if (forest.length > 0) { + this.positionNodesRadially(forest); + } + // The graph associated with this layout is not flat or a forest + else { + // Reduce the trees when incremental mode is not enabled and graph is not a forest + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.positionNodesRandomly(); + } + } else { + if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) { + // Reduce the trees in incremental mode if only this constant is set to true + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + } + } + + this.initSpringEmbedder(); + this.runSpringEmbedder(); + + return true; + }; + + CoSELayout.prototype.tick = function () { + this.totalIterations++; + + if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.isConverged()) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + this.coolingCycle++; + + if (this.layoutQuality == 0) { + // quality - "draft" + this.coolingAdjuster = this.coolingCycle; + } else if (this.layoutQuality == 1) { + // quality - "default" + this.coolingAdjuster = this.coolingCycle / 3; + } + + // cooling schedule is based on http://www.btluke.com/simanf1.html -> cooling schedule 3 + this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature); + this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor)); + } + // Operations while tree is growing again + if (this.isTreeGrowing) { + if (this.growTreeIterations % 10 == 0) { + if (this.prunedNodesAll.length > 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + this.growTree(this.prunedNodesAll); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.graphManager.updateBounds(); + this.updateGrid(); + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + } else { + this.isTreeGrowing = false; + this.isGrowthFinished = true; + } + } + this.growTreeIterations++; + } + // Operations after growth is finished + if (this.isGrowthFinished) { + if (this.isConverged()) { + return true; + } + if (this.afterGrowthIterations % 10 == 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + } + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100); + this.afterGrowthIterations++; + } + + var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished; + var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished; + + this.totalDisplacement = 0; + this.graphManager.updateBounds(); + this.calcSpringForces(); + this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate); + this.calcGravitationalForces(); + this.moveNodes(); + this.animate(); + + return false; // Layout is not ended yet return false + }; + + CoSELayout.prototype.getPositionsData = function () { + var allNodes = this.graphManager.getAllNodes(); + var pData = {}; + for (var i = 0; i < allNodes.length; i++) { + var rect = allNodes[i].rect; + var id = allNodes[i].id; + pData[id] = { + id: id, + x: rect.getCenterX(), + y: rect.getCenterY(), + w: rect.width, + h: rect.height + }; + } + + return pData; + }; + + CoSELayout.prototype.runSpringEmbedder = function () { + this.initialAnimationPeriod = 25; + this.animationPeriod = this.initialAnimationPeriod; + var layoutEnded = false; + + // If aminate option is 'during' signal that layout is supposed to start iterating + if (FDLayoutConstants.ANIMATE === 'during') { + this.emit('layoutstarted'); + } else { + // If aminate option is 'during' tick() function will be called on index.js + while (!layoutEnded) { + layoutEnded = this.tick(); + } + + this.graphManager.updateBounds(); + } + }; + + CoSELayout.prototype.calculateNodesToApplyGravitationTo = function () { + var nodeList = []; + var graph; + + var graphs = this.graphManager.getGraphs(); + var size = graphs.length; + var i; + for (i = 0; i < size; i++) { + graph = graphs[i]; + + graph.updateConnected(); + + if (!graph.isConnected) { + nodeList = nodeList.concat(graph.getNodes()); + } + } + + return nodeList; + }; + + CoSELayout.prototype.createBendpoints = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + var visited = new Set(); + var i; + for (i = 0; i < edges.length; i++) { + var edge = edges[i]; + + if (!visited.has(edge)) { + var source = edge.getSource(); + var target = edge.getTarget(); + + if (source == target) { + edge.getBendpoints().push(new PointD()); + edge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(edge); + visited.add(edge); + } else { + var edgeList = []; + + edgeList = edgeList.concat(source.getEdgeListToNode(target)); + edgeList = edgeList.concat(target.getEdgeListToNode(source)); + + if (!visited.has(edgeList[0])) { + if (edgeList.length > 1) { + var k; + for (k = 0; k < edgeList.length; k++) { + var multiEdge = edgeList[k]; + multiEdge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(multiEdge); + } + } + edgeList.forEach(function (edge) { + visited.add(edge); + }); + } + } + } + + if (visited.size == edges.length) { + break; + } + } + }; + + CoSELayout.prototype.positionNodesRadially = function (forest) { + // We tile the trees to a grid row by row; first tree starts at (0,0) + var currentStartingPoint = new Point(0, 0); + var numberOfColumns = Math.ceil(Math.sqrt(forest.length)); + var height = 0; + var currentY = 0; + var currentX = 0; + var point = new PointD(0, 0); + + for (var i = 0; i < forest.length; i++) { + if (i % numberOfColumns == 0) { + // Start of a new row, make the x coordinate 0, increment the + // y coordinate with the max height of the previous row + currentX = 0; + currentY = height; + + if (i != 0) { + currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION; + } + + height = 0; + } + + var tree = forest[i]; + + // Find the center of the tree + var centerNode = Layout.findCenterOfTree(tree); + + // Set the staring point of the next tree + currentStartingPoint.x = currentX; + currentStartingPoint.y = currentY; + + // Do a radial layout starting with the center + point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint); + + if (point.y > height) { + height = Math.floor(point.y); + } + + currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION); + } + + this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2)); + }; + + CoSELayout.radialLayout = function (tree, centerNode, startingPoint) { + var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION); + CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep); + var bounds = LGraph.calculateBounds(tree); + + var transform = new Transform(); + transform.setDeviceOrgX(bounds.getMinX()); + transform.setDeviceOrgY(bounds.getMinY()); + transform.setWorldOrgX(startingPoint.x); + transform.setWorldOrgY(startingPoint.y); + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + node.transform(transform); + } + + var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY()); + + return transform.inverseTransformPoint(bottomRight); + }; + + CoSELayout.branchRadialLayout = function (node, parentOfNode, startAngle, endAngle, distance, radialSeparation) { + // First, position this node by finding its angle. + var halfInterval = (endAngle - startAngle + 1) / 2; + + if (halfInterval < 0) { + halfInterval += 180; + } + + var nodeAngle = (halfInterval + startAngle) % 360; + var teta = nodeAngle * IGeometry.TWO_PI / 360; + var x_ = distance * Math.cos(teta); + var y_ = distance * Math.sin(teta); + + node.setCenter(x_, y_); + + // Traverse all neighbors of this node and recursively call this + // function. + var neighborEdges = []; + neighborEdges = neighborEdges.concat(node.getEdges()); + var childCount = neighborEdges.length; + + if (parentOfNode != null) { + childCount--; + } + + var branchCount = 0; + + var incEdgesCount = neighborEdges.length; + var startIndex; + + var edges = node.getEdgesBetween(parentOfNode); + + // If there are multiple edges, prune them until there remains only one + // edge. + while (edges.length > 1) { + //neighborEdges.remove(edges.remove(0)); + var temp = edges[0]; + edges.splice(0, 1); + var index = neighborEdges.indexOf(temp); + if (index >= 0) { + neighborEdges.splice(index, 1); + } + incEdgesCount--; + childCount--; + } + + if (parentOfNode != null) { + //assert edges.length == 1; + startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount; + } else { + startIndex = 0; + } + + var stepAngle = Math.abs(endAngle - startAngle) / childCount; + + for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) { + var currentNeighbor = neighborEdges[i].getOtherEnd(node); + + // Don't back traverse to root node in current tree. + if (currentNeighbor == parentOfNode) { + continue; + } + + var childStartAngle = (startAngle + branchCount * stepAngle) % 360; + var childEndAngle = (childStartAngle + stepAngle) % 360; + + CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation); + + branchCount++; + } + }; + + CoSELayout.maxDiagonalInTree = function (tree) { + var maxDiagonal = Integer.MIN_VALUE; + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + var diagonal = node.getDiagonal(); + + if (diagonal > maxDiagonal) { + maxDiagonal = diagonal; + } + } + + return maxDiagonal; + }; + + CoSELayout.prototype.calcRepulsionRange = function () { + // formula is 2 x (level + 1) x idealEdgeLength + return 2 * (this.level + 1) * this.idealEdgeLength; + }; + + // Tiling methods + + // Group zero degree members whose parents are not to be tiled, create dummy parents where needed and fill memberGroups by their dummp parent id's + CoSELayout.prototype.groupZeroDegreeMembers = function () { + var self = this; + // array of [parent_id x oneDegreeNode_id] + var tempMemberGroups = {}; // A temporary map of parent node and its zero degree members + this.memberGroups = {}; // A map of dummy parent node and its zero degree members whose parents are not to be tiled + this.idToDummyNode = {}; // A map of id to dummy node + + var zeroDegree = []; // List of zero degree nodes whose parents are not to be tiled + var allNodes = this.graphManager.getAllNodes(); + + // Fill zero degree list + for (var i = 0; i < allNodes.length; i++) { + var node = allNodes[i]; + var parent = node.getParent(); + // If a node has zero degree and its parent is not to be tiled if exists add that node to zeroDegres list + if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == undefined || !this.getToBeTiled(parent))) { + zeroDegree.push(node); + } + } + + // Create a map of parent node and its zero degree members + for (var i = 0; i < zeroDegree.length; i++) { + var node = zeroDegree[i]; // Zero degree node itself + var p_id = node.getParent().id; // Parent id + + if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = []; + + tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node); // Push node to the list belongs to its parent in tempMemberGroups + } + + // If there are at least two nodes at a level, create a dummy compound for them + Object.keys(tempMemberGroups).forEach(function (p_id) { + if (tempMemberGroups[p_id].length > 1) { + var dummyCompoundId = "DummyCompound_" + p_id; // The id of dummy compound which will be created soon + self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id]; // Add dummy compound to memberGroups + + var parent = tempMemberGroups[p_id][0].getParent(); // The parent of zero degree nodes will be the parent of new dummy compound + + // Create a dummy compound with calculated id + var dummyCompound = new CoSENode(self.graphManager); + dummyCompound.id = dummyCompoundId; + dummyCompound.paddingLeft = parent.paddingLeft || 0; + dummyCompound.paddingRight = parent.paddingRight || 0; + dummyCompound.paddingBottom = parent.paddingBottom || 0; + dummyCompound.paddingTop = parent.paddingTop || 0; + + self.idToDummyNode[dummyCompoundId] = dummyCompound; + + var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound); + var parentGraph = parent.getChild(); + + // Add dummy compound to parent the graph + parentGraph.add(dummyCompound); + + // For each zero degree node in this level remove it from its parent graph and add it to the graph of dummy parent + for (var i = 0; i < tempMemberGroups[p_id].length; i++) { + var node = tempMemberGroups[p_id][i]; + + parentGraph.remove(node); + dummyParentGraph.add(node); + } + } + }); + }; + + CoSELayout.prototype.clearCompounds = function () { + var childGraphMap = {}; + var idToNode = {}; + + // Get compound ordering by finding the inner one first + this.performDFSOnCompounds(); + + for (var i = 0; i < this.compoundOrder.length; i++) { + + idToNode[this.compoundOrder[i].id] = this.compoundOrder[i]; + childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes()); + + // Remove children of compounds + this.graphManager.remove(this.compoundOrder[i].getChild()); + this.compoundOrder[i].child = null; + } + + this.graphManager.resetAllNodes(); + + // Tile the removed children + this.tileCompoundMembers(childGraphMap, idToNode); + }; + + CoSELayout.prototype.clearZeroDegreeMembers = function () { + var self = this; + var tiledZeroDegreePack = this.tiledZeroDegreePack = []; + + Object.keys(this.memberGroups).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound + + tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + // Set the width and height of the dummy compound as calculated + compoundNode.rect.width = tiledZeroDegreePack[id].width; + compoundNode.rect.height = tiledZeroDegreePack[id].height; + }); + }; + + CoSELayout.prototype.repopulateCompounds = function () { + for (var i = this.compoundOrder.length - 1; i >= 0; i--) { + var lCompoundNode = this.compoundOrder[i]; + var id = lCompoundNode.id; + var horizontalMargin = lCompoundNode.paddingLeft; + var verticalMargin = lCompoundNode.paddingTop; + + this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin); + } + }; + + CoSELayout.prototype.repopulateZeroDegreeMembers = function () { + var self = this; + var tiledPack = this.tiledZeroDegreePack; + + Object.keys(tiledPack).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound by its id + var horizontalMargin = compoundNode.paddingLeft; + var verticalMargin = compoundNode.paddingTop; + + // Adjust the positions of nodes wrt its compound + self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin); + }); + }; + + CoSELayout.prototype.getToBeTiled = function (node) { + var id = node.id; + //firstly check the previous results + if (this.toBeTiled[id] != null) { + return this.toBeTiled[id]; + } + + //only compound nodes are to be tiled + var childGraph = node.getChild(); + if (childGraph == null) { + this.toBeTiled[id] = false; + return false; + } + + var children = childGraph.getNodes(); // Get the children nodes + + //a compound node is not to be tiled if all of its compound children are not to be tiled + for (var i = 0; i < children.length; i++) { + var theChild = children[i]; + + if (this.getNodeDegree(theChild) > 0) { + this.toBeTiled[id] = false; + return false; + } + + //pass the children not having the compound structure + if (theChild.getChild() == null) { + this.toBeTiled[theChild.id] = false; + continue; + } + + if (!this.getToBeTiled(theChild)) { + this.toBeTiled[id] = false; + return false; + } + } + this.toBeTiled[id] = true; + return true; + }; + + // Get degree of a node depending of its edges and independent of its children + CoSELayout.prototype.getNodeDegree = function (node) { + node.id; + var edges = node.getEdges(); + var degree = 0; + + // For the edges connected + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + if (edge.getSource().id !== edge.getTarget().id) { + degree = degree + 1; + } + } + return degree; + }; + + // Get degree of a node with its children + CoSELayout.prototype.getNodeDegreeWithChildren = function (node) { + var degree = this.getNodeDegree(node); + if (node.getChild() == null) { + return degree; + } + var children = node.getChild().getNodes(); + for (var i = 0; i < children.length; i++) { + var child = children[i]; + degree += this.getNodeDegreeWithChildren(child); + } + return degree; + }; + + CoSELayout.prototype.performDFSOnCompounds = function () { + this.compoundOrder = []; + this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes()); + }; + + CoSELayout.prototype.fillCompexOrderByDFS = function (children) { + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.getChild() != null) { + this.fillCompexOrderByDFS(child.getChild().getNodes()); + } + if (this.getToBeTiled(child)) { + this.compoundOrder.push(child); + } + } + }; + + /** + * This method places each zero degree member wrt given (x,y) coordinates (top left). + */ + CoSELayout.prototype.adjustLocations = function (organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) { + x += compoundHorizontalMargin; + y += compoundVerticalMargin; + + var left = x; + + for (var i = 0; i < organization.rows.length; i++) { + var row = organization.rows[i]; + x = left; + var maxHeight = 0; + + for (var j = 0; j < row.length; j++) { + var lnode = row[j]; + + lnode.rect.x = x; // + lnode.rect.width / 2; + lnode.rect.y = y; // + lnode.rect.height / 2; + + x += lnode.rect.width + organization.horizontalPadding; + + if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height; + } + + y += maxHeight + organization.verticalPadding; + } + }; + + CoSELayout.prototype.tileCompoundMembers = function (childGraphMap, idToNode) { + var self = this; + this.tiledMemberPack = []; + + Object.keys(childGraphMap).forEach(function (id) { + // Get the compound node + var compoundNode = idToNode[id]; + + self.tiledMemberPack[id] = self.tileNodes(childGraphMap[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + compoundNode.rect.width = self.tiledMemberPack[id].width; + compoundNode.rect.height = self.tiledMemberPack[id].height; + }); + }; + + CoSELayout.prototype.tileNodes = function (nodes, minWidth) { + var verticalPadding = CoSEConstants.TILING_PADDING_VERTICAL; + var horizontalPadding = CoSEConstants.TILING_PADDING_HORIZONTAL; + var organization = { + rows: [], + rowWidth: [], + rowHeight: [], + width: 0, + height: minWidth, // assume minHeight equals to minWidth + verticalPadding: verticalPadding, + horizontalPadding: horizontalPadding + }; + + // Sort the nodes in ascending order of their areas + nodes.sort(function (n1, n2) { + if (n1.rect.width * n1.rect.height > n2.rect.width * n2.rect.height) return -1; + if (n1.rect.width * n1.rect.height < n2.rect.width * n2.rect.height) return 1; + return 0; + }); + + // Create the organization -> tile members + for (var i = 0; i < nodes.length; i++) { + var lNode = nodes[i]; + + if (organization.rows.length == 0) { + this.insertNodeToRow(organization, lNode, 0, minWidth); + } else if (this.canAddHorizontal(organization, lNode.rect.width, lNode.rect.height)) { + this.insertNodeToRow(organization, lNode, this.getShortestRowIndex(organization), minWidth); + } else { + this.insertNodeToRow(organization, lNode, organization.rows.length, minWidth); + } + + this.shiftToLastRow(organization); + } + + return organization; + }; + + CoSELayout.prototype.insertNodeToRow = function (organization, node, rowIndex, minWidth) { + var minCompoundSize = minWidth; + + // Add new row if needed + if (rowIndex == organization.rows.length) { + var secondDimension = []; + + organization.rows.push(secondDimension); + organization.rowWidth.push(minCompoundSize); + organization.rowHeight.push(0); + } + + // Update row width + var w = organization.rowWidth[rowIndex] + node.rect.width; + + if (organization.rows[rowIndex].length > 0) { + w += organization.horizontalPadding; + } + + organization.rowWidth[rowIndex] = w; + // Update compound width + if (organization.width < w) { + organization.width = w; + } + + // Update height + var h = node.rect.height; + if (rowIndex > 0) h += organization.verticalPadding; + + var extraHeight = 0; + if (h > organization.rowHeight[rowIndex]) { + extraHeight = organization.rowHeight[rowIndex]; + organization.rowHeight[rowIndex] = h; + extraHeight = organization.rowHeight[rowIndex] - extraHeight; + } + + organization.height += extraHeight; + + // Insert node + organization.rows[rowIndex].push(node); + }; + + //Scans the rows of an organization and returns the one with the min width + CoSELayout.prototype.getShortestRowIndex = function (organization) { + var r = -1; + var min = Number.MAX_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + if (organization.rowWidth[i] < min) { + r = i; + min = organization.rowWidth[i]; + } + } + return r; + }; + + //Scans the rows of an organization and returns the one with the max width + CoSELayout.prototype.getLongestRowIndex = function (organization) { + var r = -1; + var max = Number.MIN_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + + if (organization.rowWidth[i] > max) { + r = i; + max = organization.rowWidth[i]; + } + } + + return r; + }; + + /** + * This method checks whether adding extra width to the organization violates + * the aspect ratio(1) or not. + */ + CoSELayout.prototype.canAddHorizontal = function (organization, extraWidth, extraHeight) { + + var sri = this.getShortestRowIndex(organization); + + if (sri < 0) { + return true; + } + + var min = organization.rowWidth[sri]; + + if (min + organization.horizontalPadding + extraWidth <= organization.width) return true; + + var hDiff = 0; + + // Adding to an existing row + if (organization.rowHeight[sri] < extraHeight) { + if (sri > 0) hDiff = extraHeight + organization.verticalPadding - organization.rowHeight[sri]; + } + + var add_to_row_ratio; + if (organization.width - min >= extraWidth + organization.horizontalPadding) { + add_to_row_ratio = (organization.height + hDiff) / (min + extraWidth + organization.horizontalPadding); + } else { + add_to_row_ratio = (organization.height + hDiff) / organization.width; + } + + // Adding a new row for this node + hDiff = extraHeight + organization.verticalPadding; + var add_new_row_ratio; + if (organization.width < extraWidth) { + add_new_row_ratio = (organization.height + hDiff) / extraWidth; + } else { + add_new_row_ratio = (organization.height + hDiff) / organization.width; + } + + if (add_new_row_ratio < 1) add_new_row_ratio = 1 / add_new_row_ratio; + + if (add_to_row_ratio < 1) add_to_row_ratio = 1 / add_to_row_ratio; + + return add_to_row_ratio < add_new_row_ratio; + }; + + //If moving the last node from the longest row and adding it to the last + //row makes the bounding box smaller, do it. + CoSELayout.prototype.shiftToLastRow = function (organization) { + var longest = this.getLongestRowIndex(organization); + var last = organization.rowWidth.length - 1; + var row = organization.rows[longest]; + var node = row[row.length - 1]; + + var diff = node.width + organization.horizontalPadding; + + // Check if there is enough space on the last row + if (organization.width - organization.rowWidth[last] > diff && longest != last) { + // Remove the last element of the longest row + row.splice(-1, 1); + + // Push it to the last row + organization.rows[last].push(node); + + organization.rowWidth[longest] = organization.rowWidth[longest] - diff; + organization.rowWidth[last] = organization.rowWidth[last] + diff; + organization.width = organization.rowWidth[instance.getLongestRowIndex(organization)]; + + // Update heights of the organization + var maxHeight = Number.MIN_VALUE; + for (var i = 0; i < row.length; i++) { + if (row[i].height > maxHeight) maxHeight = row[i].height; + } + if (longest > 0) maxHeight += organization.verticalPadding; + + var prevTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + + organization.rowHeight[longest] = maxHeight; + if (organization.rowHeight[last] < node.height + organization.verticalPadding) organization.rowHeight[last] = node.height + organization.verticalPadding; + + var finalTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + organization.height += finalTotal - prevTotal; + + this.shiftToLastRow(organization); + } + }; + + CoSELayout.prototype.tilingPreLayout = function () { + if (CoSEConstants.TILE) { + // Find zero degree nodes and create a compound for each level + this.groupZeroDegreeMembers(); + // Tile and clear children of each compound + this.clearCompounds(); + // Separately tile and clear zero degree nodes for each level + this.clearZeroDegreeMembers(); + } + }; + + CoSELayout.prototype.tilingPostLayout = function () { + if (CoSEConstants.TILE) { + this.repopulateZeroDegreeMembers(); + this.repopulateCompounds(); + } + }; + + // ----------------------------------------------------------------------------- + // Section: Tree Reduction methods + // ----------------------------------------------------------------------------- + // Reduce trees + CoSELayout.prototype.reduceTrees = function () { + var prunedNodesAll = []; + var containsLeaf = true; + var node; + + while (containsLeaf) { + var allNodes = this.graphManager.getAllNodes(); + var prunedNodesInStepTemp = []; + containsLeaf = false; + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + if (node.getEdges().length == 1 && !node.getEdges()[0].isInterGraph && node.getChild() == null) { + prunedNodesInStepTemp.push([node, node.getEdges()[0], node.getOwner()]); + containsLeaf = true; + } + } + if (containsLeaf == true) { + var prunedNodesInStep = []; + for (var j = 0; j < prunedNodesInStepTemp.length; j++) { + if (prunedNodesInStepTemp[j][0].getEdges().length == 1) { + prunedNodesInStep.push(prunedNodesInStepTemp[j]); + prunedNodesInStepTemp[j][0].getOwner().remove(prunedNodesInStepTemp[j][0]); + } + } + prunedNodesAll.push(prunedNodesInStep); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + } + } + this.prunedNodesAll = prunedNodesAll; + }; + + // Grow tree one step + CoSELayout.prototype.growTree = function (prunedNodesAll) { + var lengthOfPrunedNodesInStep = prunedNodesAll.length; + var prunedNodesInStep = prunedNodesAll[lengthOfPrunedNodesInStep - 1]; + + var nodeData; + for (var i = 0; i < prunedNodesInStep.length; i++) { + nodeData = prunedNodesInStep[i]; + + this.findPlaceforPrunedNode(nodeData); + + nodeData[2].add(nodeData[0]); + nodeData[2].add(nodeData[1], nodeData[1].source, nodeData[1].target); + } + + prunedNodesAll.splice(prunedNodesAll.length - 1, 1); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + }; + + // Find an appropriate position to replace pruned node, this method can be improved + CoSELayout.prototype.findPlaceforPrunedNode = function (nodeData) { + + var gridForPrunedNode; + var nodeToConnect; + var prunedNode = nodeData[0]; + if (prunedNode == nodeData[1].source) { + nodeToConnect = nodeData[1].target; + } else { + nodeToConnect = nodeData[1].source; + } + var startGridX = nodeToConnect.startX; + var finishGridX = nodeToConnect.finishX; + var startGridY = nodeToConnect.startY; + var finishGridY = nodeToConnect.finishY; + + var upNodeCount = 0; + var downNodeCount = 0; + var rightNodeCount = 0; + var leftNodeCount = 0; + var controlRegions = [upNodeCount, rightNodeCount, downNodeCount, leftNodeCount]; + + if (startGridY > 0) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[0] += this.grid[i][startGridY - 1].length + this.grid[i][startGridY].length - 1; + } + } + if (finishGridX < this.grid.length - 1) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[1] += this.grid[finishGridX + 1][i].length + this.grid[finishGridX][i].length - 1; + } + } + if (finishGridY < this.grid[0].length - 1) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[2] += this.grid[i][finishGridY + 1].length + this.grid[i][finishGridY].length - 1; + } + } + if (startGridX > 0) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[3] += this.grid[startGridX - 1][i].length + this.grid[startGridX][i].length - 1; + } + } + var min = Integer.MAX_VALUE; + var minCount; + var minIndex; + for (var j = 0; j < controlRegions.length; j++) { + if (controlRegions[j] < min) { + min = controlRegions[j]; + minCount = 1; + minIndex = j; + } else if (controlRegions[j] == min) { + minCount++; + } + } + + if (minCount == 3 && min == 0) { + if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[2] == 0) { + gridForPrunedNode = 1; + } else if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 0; + } else if (controlRegions[0] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 3; + } else if (controlRegions[1] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 2; + } + } else if (minCount == 2 && min == 0) { + var random = Math.floor(Math.random() * 2); + if (controlRegions[0] == 0 && controlRegions[1] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 1; + } + } else if (controlRegions[0] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[0] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 3; + } + } else if (controlRegions[1] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[1] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 3; + } + } else { + if (random == 0) { + gridForPrunedNode = 2; + } else { + gridForPrunedNode = 3; + } + } + } else if (minCount == 4 && min == 0) { + var random = Math.floor(Math.random() * 4); + gridForPrunedNode = random; + } else { + gridForPrunedNode = minIndex; + } + + if (gridForPrunedNode == 0) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() - nodeToConnect.getHeight() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getHeight() / 2); + } else if (gridForPrunedNode == 1) { + prunedNode.setCenter(nodeToConnect.getCenterX() + nodeToConnect.getWidth() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } else if (gridForPrunedNode == 2) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() + nodeToConnect.getHeight() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getHeight() / 2); + } else { + prunedNode.setCenter(nodeToConnect.getCenterX() - nodeToConnect.getWidth() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } + }; + + module.exports = CoSELayout; + + /***/ }), + /* 7 */ + /***/ (function(module, exports, __webpack_require__) { + + + var coseBase = {}; + + coseBase.layoutBase = __webpack_require__(0); + coseBase.CoSEConstants = __webpack_require__(1); + coseBase.CoSEEdge = __webpack_require__(2); + coseBase.CoSEGraph = __webpack_require__(3); + coseBase.CoSEGraphManager = __webpack_require__(4); + coseBase.CoSELayout = __webpack_require__(6); + coseBase.CoSENode = __webpack_require__(5); + + module.exports = coseBase; + + /***/ }) + /******/ ]); + }); + } (coseBase)); + return coseBase.exports; +} + +(function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(requireCoseBase()); + })(commonjsGlobal$1, function(__WEBPACK_EXTERNAL_MODULE_0__) { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 1); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LayoutConstants = __webpack_require__(0).layoutBase.LayoutConstants; + var FDLayoutConstants = __webpack_require__(0).layoutBase.FDLayoutConstants; + var CoSEConstants = __webpack_require__(0).CoSEConstants; + var CoSELayout = __webpack_require__(0).CoSELayout; + var CoSENode = __webpack_require__(0).CoSENode; + var PointD = __webpack_require__(0).layoutBase.PointD; + var DimensionD = __webpack_require__(0).layoutBase.DimensionD; + + var defaults = { + // Called on `layoutready` + ready: function ready() {}, + // Called on `layoutstop` + stop: function stop() {}, + // 'draft', 'default' or 'proof" + // - 'draft' fast cooling rate + // - 'default' moderate cooling rate + // - "proof" slow cooling rate + quality: 'default', + // include labels in node dimensions + nodeDimensionsIncludeLabels: false, + // number of ticks per frame; higher is faster but more jerky + refresh: 30, + // Whether to fit the network view after when done + fit: true, + // Padding on fit + padding: 10, + // Whether to enable incremental mode + randomize: true, + // Node repulsion (non overlapping) multiplier + nodeRepulsion: 4500, + // Ideal edge (non nested) length + idealEdgeLength: 50, + // Divisor to compute edge forces + edgeElasticity: 0.45, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 0.1, + // Gravity force (constant) + gravity: 0.25, + // Maximum number of iterations to perform + numIter: 2500, + // For enabling tiling + tile: true, + // Type of layout animation. The option set is {'during', 'end', false} + animate: 'end', + // Duration for animate:end + animationDuration: 500, + // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingVertical: 10, + // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingHorizontal: 10, + // Gravity range (constant) for compounds + gravityRangeCompound: 1.5, + // Gravity force (constant) for compounds + gravityCompound: 1.0, + // Gravity range (constant) + gravityRange: 3.8, + // Initial cooling factor for incremental layout + initialEnergyOnIncremental: 0.5 + }; + + function extend(defaults, options) { + var obj = {}; + + for (var i in defaults) { + obj[i] = defaults[i]; + } + + for (var i in options) { + obj[i] = options[i]; + } + + return obj; + } + function _CoSELayout(_options) { + this.options = extend(defaults, _options); + getUserOptions(this.options); + } + + var getUserOptions = function getUserOptions(options) { + if (options.nodeRepulsion != null) CoSEConstants.DEFAULT_REPULSION_STRENGTH = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = options.nodeRepulsion; + if (options.idealEdgeLength != null) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength; + if (options.edgeElasticity != null) CoSEConstants.DEFAULT_SPRING_STRENGTH = FDLayoutConstants.DEFAULT_SPRING_STRENGTH = options.edgeElasticity; + if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor; + if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity; + if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter; + if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange; + if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound; + if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound; + if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental; + + if (options.quality == 'draft') LayoutConstants.QUALITY = 0;else if (options.quality == 'proof') LayoutConstants.QUALITY = 2;else LayoutConstants.QUALITY = 1; + + CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels; + CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize; + CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate; + CoSEConstants.TILE = options.tile; + CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === 'function' ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical; + CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === 'function' ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal; + }; + + _CoSELayout.prototype.run = function () { + var ready; + var frameId; + var options = this.options; + this.idToLNode = {}; + var layout = this.layout = new CoSELayout(); + var self = this; + + self.stopped = false; + + this.cy = this.options.cy; + + this.cy.trigger({ type: 'layoutstart', layout: this }); + + var gm = layout.newGraphManager(); + this.gm = gm; + + var nodes = this.options.eles.nodes(); + var edges = this.options.eles.edges(); + + this.root = gm.addRoot(); + this.processChildrenList(this.root, this.getTopMostNodes(nodes), layout); + + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var sourceNode = this.idToLNode[edge.data("source")]; + var targetNode = this.idToLNode[edge.data("target")]; + if (sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) { + var e1 = gm.add(layout.newEdge(), sourceNode, targetNode); + e1.id = edge.id(); + } + } + + var getPositions = function getPositions(ele, i) { + if (typeof ele === "number") { + ele = i; + } + var theId = ele.data('id'); + var lNode = self.idToLNode[theId]; + + return { + x: lNode.getRect().getCenterX(), + y: lNode.getRect().getCenterY() + }; + }; + + /* + * Reposition nodes in iterations animatedly + */ + var iterateAnimated = function iterateAnimated() { + // Thigs to perform after nodes are repositioned on screen + var afterReposition = function afterReposition() { + if (options.fit) { + options.cy.fit(options.eles, options.padding); + } + + if (!ready) { + ready = true; + self.cy.one('layoutready', options.ready); + self.cy.trigger({ type: 'layoutready', layout: self }); + } + }; + + var ticksPerFrame = self.options.refresh; + var isDone; + + for (var i = 0; i < ticksPerFrame && !isDone; i++) { + isDone = self.stopped || self.layout.tick(); + } + + // If layout is done + if (isDone) { + // If the layout is not a sublayout and it is successful perform post layout. + if (layout.checkLayoutSuccess() && !layout.isSubLayout) { + layout.doPostLayout(); + } + + // If layout has a tilingPostLayout function property call it. + if (layout.tilingPostLayout) { + layout.tilingPostLayout(); + } + + layout.isLayoutFinished = true; + + self.options.eles.nodes().positions(getPositions); + + afterReposition(); + + // trigger layoutstop when the layout stops (e.g. finishes) + self.cy.one('layoutstop', self.options.stop); + self.cy.trigger({ type: 'layoutstop', layout: self }); + + if (frameId) { + cancelAnimationFrame(frameId); + } + + ready = false; + return; + } + + var animationData = self.layout.getPositionsData(); // Get positions of layout nodes note that all nodes may not be layout nodes because of tiling + + // Position nodes, for the nodes whose id does not included in data (because they are removed from their parents and included in dummy compounds) + // use position of their ancestors or dummy ancestors + options.eles.nodes().positions(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + // If ele is a compound node, then its position will be defined by its children + if (!ele.isParent()) { + var theId = ele.id(); + var pNode = animationData[theId]; + var temp = ele; + // If pNode is undefined search until finding position data of its first ancestor (It may be dummy as well) + while (pNode == null) { + pNode = animationData[temp.data('parent')] || animationData['DummyCompound_' + temp.data('parent')]; + animationData[theId] = pNode; + temp = temp.parent()[0]; + if (temp == undefined) { + break; + } + } + if (pNode != null) { + return { + x: pNode.x, + y: pNode.y + }; + } else { + return { + x: ele.position('x'), + y: ele.position('y') + }; + } + } + }); + + afterReposition(); + + frameId = requestAnimationFrame(iterateAnimated); + }; + + /* + * Listen 'layoutstarted' event and start animated iteration if animate option is 'during' + */ + layout.addListener('layoutstarted', function () { + if (self.options.animate === 'during') { + frameId = requestAnimationFrame(iterateAnimated); + } + }); + + layout.runLayout(); // Run cose layout + + /* + * If animate option is not 'during' ('end' or false) perform these here (If it is 'during' similar things are already performed) + */ + if (this.options.animate !== "during") { + self.options.eles.nodes().not(":parent").layoutPositions(self, self.options, getPositions); // Use layout positions to reposition the nodes it considers the options parameter + ready = false; + } + + return this; // chaining + }; + + //Get the top most ones of a list of nodes + _CoSELayout.prototype.getTopMostNodes = function (nodes) { + var nodesMap = {}; + for (var i = 0; i < nodes.length; i++) { + nodesMap[nodes[i].id()] = true; + } + var roots = nodes.filter(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + var parent = ele.parent()[0]; + while (parent != null) { + if (nodesMap[parent.id()]) { + return false; + } + parent = parent.parent()[0]; + } + return true; + }); + + return roots; + }; + + _CoSELayout.prototype.processChildrenList = function (parent, children, layout) { + var size = children.length; + for (var i = 0; i < size; i++) { + var theChild = children[i]; + var children_of_children = theChild.children(); + var theNode; + + var dimensions = theChild.layoutDimensions({ + nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels + }); + + if (theChild.outerWidth() != null && theChild.outerHeight() != null) { + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position('x') - dimensions.w / 2, theChild.position('y') - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h)))); + } else { + theNode = parent.add(new CoSENode(this.graphManager)); + } + // Attach id to the layout node + theNode.id = theChild.data("id"); + // Attach the paddings of cy node to layout node + theNode.paddingLeft = parseInt(theChild.css('padding')); + theNode.paddingTop = parseInt(theChild.css('padding')); + theNode.paddingRight = parseInt(theChild.css('padding')); + theNode.paddingBottom = parseInt(theChild.css('padding')); + + //Attach the label properties to compound if labels will be included in node dimensions + if (this.options.nodeDimensionsIncludeLabels) { + if (theChild.isParent()) { + var labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false }).w; + var labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false }).h; + var labelPos = theChild.css("text-halign"); + theNode.labelWidth = labelWidth; + theNode.labelHeight = labelHeight; + theNode.labelPos = labelPos; + } + } + + // Map the layout node + this.idToLNode[theChild.data("id")] = theNode; + + if (isNaN(theNode.rect.x)) { + theNode.rect.x = 0; + } + + if (isNaN(theNode.rect.y)) { + theNode.rect.y = 0; + } + + if (children_of_children != null && children_of_children.length > 0) { + var theNewGraph; + theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode); + this.processChildrenList(theNewGraph, children_of_children, layout); + } + } + }; + + /** + * @brief : called on continuous layouts to stop them before they finish + */ + _CoSELayout.prototype.stop = function () { + this.stopped = true; + + return this; // chaining + }; + + var register = function register(cytoscape) { + // var Layout = getLayout( cytoscape ); + + cytoscape('layout', 'cose-bilkent', _CoSELayout); + }; + + // auto reg for globals + if (typeof cytoscape !== 'undefined') { + register(cytoscape); + } + + module.exports = register; + + /***/ }) + /******/ ]); + }); +} (cytoscapeCoseBilkent)); + +var cytoscapeCoseBilkentExports = cytoscapeCoseBilkent.exports; +var coseBilkent = /*@__PURE__*/getDefaultExportFromCjs(cytoscapeCoseBilkentExports); + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 4], $V1 = [1, 13], $V2 = [1, 12], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 20], $V6 = [1, 19], $V7 = [6, 7, 8], $V8 = [1, 26], $V9 = [1, 24], $Va = [1, 25], $Vb = [6, 7, 11], $Vc = [1, 6, 13, 15, 16, 19, 22], $Vd = [1, 33], $Ve = [1, 34], $Vf = [1, 6, 7, 11, 13, 15, 16, 19, 22]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mindMap": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "MINDMAP": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "node": 14, "ICON": 15, "CLASS": 16, "nodeWithId": 17, "nodeWithoutId": 18, "NODE_DSTART": 19, "NODE_DESCR": 20, "NODE_DEND": 21, "NODE_ID": 22, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" }, + productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 6: + case 7: + return yy; + case 8: + yy.getLogger().trace("Stop NL "); + break; + case 9: + yy.getLogger().trace("Stop EOF "); + break; + case 11: + yy.getLogger().trace("Stop NL2 "); + break; + case 12: + yy.getLogger().trace("Stop EOF2 "); + break; + case 15: + yy.getLogger().info("Node: ", $$[$0].id); + yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type); + break; + case 16: + yy.getLogger().trace("Icon: ", $$[$0]); + yy.decorateNode({ icon: $$[$0] }); + break; + case 17: + case 21: + yy.decorateNode({ class: $$[$0] }); + break; + case 18: + yy.getLogger().trace("SPACELIST"); + break; + case 19: + yy.getLogger().trace("Node: ", $$[$0].id); + yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type); + break; + case 20: + yy.decorateNode({ icon: $$[$0] }); + break; + case 25: + yy.getLogger().trace("node found ..", $$[$0 - 2]); + this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; + break; + case 26: + this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT }; + break; + case 27: + yy.getLogger().trace("node found ..", $$[$0 - 3]); + this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($V7, [2, 3]), { 1: [2, 2] }, o($V7, [2, 4]), o($V7, [2, 5]), { 1: [2, 6], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V1, 9: 22, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V8, 7: $V9, 10: 23, 11: $Va }, o($Vb, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: $V5, 22: $V6 }), o($Vb, [2, 18]), o($Vb, [2, 19]), o($Vb, [2, 20]), o($Vb, [2, 21]), o($Vb, [2, 23]), o($Vb, [2, 24]), o($Vb, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: $V8, 7: $V9, 10: 32, 11: $Va }, { 1: [2, 7], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($Vc, [2, 14], { 7: $Vd, 11: $Ve }), o($Vf, [2, 8]), o($Vf, [2, 9]), o($Vf, [2, 10]), o($Vb, [2, 15]), o($Vb, [2, 16]), o($Vb, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, o($Vc, [2, 13], { 7: $Vd, 11: $Ve }), o($Vf, [2, 11]), o($Vf, [2, 12]), { 21: [1, 37] }, o($Vb, [2, 25]), o($Vb, [2, 27])], + defaultActions: { 2: [2, 1], 6: [2, 2] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + yy.getLogger().trace("Found comment", yy_.yytext); + return 6; + case 1: + return 8; + case 2: + this.begin("CLASS"); + break; + case 3: + this.popState(); + return 16; + case 4: + this.popState(); + break; + case 5: + yy.getLogger().trace("Begin icon"); + this.begin("ICON"); + break; + case 6: + yy.getLogger().trace("SPACELINE"); + return 6; + case 7: + return 7; + case 8: + return 15; + case 9: + yy.getLogger().trace("end icon"); + this.popState(); + break; + case 10: + yy.getLogger().trace("Exploding node"); + this.begin("NODE"); + return 19; + case 11: + yy.getLogger().trace("Cloud"); + this.begin("NODE"); + return 19; + case 12: + yy.getLogger().trace("Explosion Bang"); + this.begin("NODE"); + return 19; + case 13: + yy.getLogger().trace("Cloud Bang"); + this.begin("NODE"); + return 19; + case 14: + this.begin("NODE"); + return 19; + case 15: + this.begin("NODE"); + return 19; + case 16: + this.begin("NODE"); + return 19; + case 17: + this.begin("NODE"); + return 19; + case 18: + return 13; + case 19: + return 22; + case 20: + return 11; + case 21: + this.begin("NSTR2"); + break; + case 22: + return "NODE_DESCR"; + case 23: + this.popState(); + break; + case 24: + yy.getLogger().trace("Starting NSTR"); + this.begin("NSTR"); + break; + case 25: + yy.getLogger().trace("description:", yy_.yytext); + return "NODE_DESCR"; + case 26: + this.popState(); + break; + case 27: + this.popState(); + yy.getLogger().trace("node end ))"); + return "NODE_DEND"; + case 28: + this.popState(); + yy.getLogger().trace("node end )"); + return "NODE_DEND"; + case 29: + this.popState(); + yy.getLogger().trace("node end ...", yy_.yytext); + return "NODE_DEND"; + case 30: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 31: + this.popState(); + yy.getLogger().trace("node end (-"); + return "NODE_DEND"; + case 32: + this.popState(); + yy.getLogger().trace("node end (-"); + return "NODE_DEND"; + case 33: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 34: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 35: + yy.getLogger().trace("Long description:", yy_.yytext); + return 20; + case 36: + yy.getLogger().trace("Long description:", yy_.yytext); + return 20; + } + }, + rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i], + conditions: { "CLASS": { "rules": [3, 4], "inclusive": false }, "ICON": { "rules": [8, 9], "inclusive": false }, "NSTR2": { "rules": [22, 23], "inclusive": false }, "NSTR": { "rules": [25, 26], "inclusive": false }, "NODE": { "rules": [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let nodes = []; +let cnt = 0; +let elements = {}; +const clear = () => { + nodes = []; + cnt = 0; + elements = {}; +}; +const getParent = function(level) { + for (let i = nodes.length - 1; i >= 0; i--) { + if (nodes[i].level < level) { + return nodes[i]; + } + } + return null; +}; +const getMindmap = () => { + return nodes.length > 0 ? nodes[0] : null; +}; +const addNode = (level, id, descr, type) => { + var _a, _b; + log$1.info("addNode", level, id, descr, type); + const conf = getConfig(); + let padding = ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig$2.mindmap.padding; + switch (type) { + case nodeType.ROUNDED_RECT: + case nodeType.RECT: + case nodeType.HEXAGON: + padding *= 2; + } + const node = { + id: cnt++, + nodeId: sanitizeText$2(id, conf), + level, + descr: sanitizeText$2(descr, conf), + type, + children: [], + width: ((_b = conf.mindmap) == null ? void 0 : _b.maxNodeWidth) ?? defaultConfig$2.mindmap.maxNodeWidth, + padding + }; + const parent = getParent(level); + if (parent) { + parent.children.push(node); + nodes.push(node); + } else { + if (nodes.length === 0) { + nodes.push(node); + } else { + throw new Error( + 'There can be only one root. No parent could be found for ("' + node.descr + '")' + ); + } + } +}; +const nodeType = { + DEFAULT: 0, + NO_BORDER: 0, + ROUNDED_RECT: 1, + RECT: 2, + CIRCLE: 3, + CLOUD: 4, + BANG: 5, + HEXAGON: 6 +}; +const getType = (startStr, endStr) => { + log$1.debug("In get type", startStr, endStr); + switch (startStr) { + case "[": + return nodeType.RECT; + case "(": + return endStr === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD; + case "((": + return nodeType.CIRCLE; + case ")": + return nodeType.CLOUD; + case "))": + return nodeType.BANG; + case "{{": + return nodeType.HEXAGON; + default: + return nodeType.DEFAULT; + } +}; +const setElementForId = (id, element) => { + elements[id] = element; +}; +const decorateNode = (decoration) => { + if (!decoration) { + return; + } + const config = getConfig(); + const node = nodes[nodes.length - 1]; + if (decoration.icon) { + node.icon = sanitizeText$2(decoration.icon, config); + } + if (decoration.class) { + node.class = sanitizeText$2(decoration.class, config); + } +}; +const type2Str = (type) => { + switch (type) { + case nodeType.DEFAULT: + return "no-border"; + case nodeType.RECT: + return "rect"; + case nodeType.ROUNDED_RECT: + return "rounded-rect"; + case nodeType.CIRCLE: + return "circle"; + case nodeType.CLOUD: + return "cloud"; + case nodeType.BANG: + return "bang"; + case nodeType.HEXAGON: + return "hexgon"; + default: + return "no-border"; + } +}; +const getLogger = () => log$1; +const getElementById = (id) => elements[id]; +const db = { + clear, + addNode, + getMindmap, + nodeType, + getType, + setElementForId, + decorateNode, + type2Str, + getLogger, + getElementById +}; +const db$1 = db; +const MAX_SECTIONS = 12; +const defaultBkg = function(db2, elem, node, section) { + const rd = 5; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` + ); + elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); +}; +const rectBkg = function(db2, elem, node) { + elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("width", node.width); +}; +const cloudBkg = function(db2, elem, node) { + const w = node.width; + const h = node.height; + const r1 = 0.15 * w; + const r2 = 0.25 * w; + const r3 = 0.35 * w; + const r4 = 0.2 * w; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 0 a${r1},${r1} 0 0,1 ${w * 0.25},${-1 * w * 0.1} + a${r3},${r3} 1 0,1 ${w * 0.4},${-1 * w * 0.1} + a${r2},${r2} 1 0,1 ${w * 0.35},${1 * w * 0.2} + + a${r1},${r1} 1 0,1 ${w * 0.15},${1 * h * 0.35} + a${r4},${r4} 1 0,1 ${-1 * w * 0.15},${1 * h * 0.65} + + a${r2},${r1} 1 0,1 ${-1 * w * 0.25},${w * 0.15} + a${r3},${r3} 1 0,1 ${-1 * w * 0.5},${0} + a${r1},${r1} 1 0,1 ${-1 * w * 0.25},${-1 * w * 0.15} + + a${r1},${r1} 1 0,1 ${-1 * w * 0.1},${-1 * h * 0.35} + a${r4},${r4} 1 0,1 ${w * 0.1},${-1 * h * 0.65} + + H0 V0 Z` + ); +}; +const bangBkg = function(db2, elem, node) { + const w = node.width; + const h = node.height; + const r = 0.15 * w; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 0 a${r},${r} 1 0,0 ${w * 0.25},${-1 * h * 0.1} + a${r},${r} 1 0,0 ${w * 0.25},${0} + a${r},${r} 1 0,0 ${w * 0.25},${0} + a${r},${r} 1 0,0 ${w * 0.25},${1 * h * 0.1} + + a${r},${r} 1 0,0 ${w * 0.15},${1 * h * 0.33} + a${r * 0.8},${r * 0.8} 1 0,0 ${0},${1 * h * 0.34} + a${r},${r} 1 0,0 ${-1 * w * 0.15},${1 * h * 0.33} + + a${r},${r} 1 0,0 ${-1 * w * 0.25},${h * 0.15} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${-1 * h * 0.15} + + a${r},${r} 1 0,0 ${-1 * w * 0.1},${-1 * h * 0.33} + a${r * 0.8},${r * 0.8} 1 0,0 ${0},${-1 * h * 0.34} + a${r},${r} 1 0,0 ${w * 0.1},${-1 * h * 0.33} + + H0 V0 Z` + ); +}; +const circleBkg = function(db2, elem, node) { + elem.append("circle").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("r", node.width / 2); +}; +function insertPolygonShape(parent, w, h, points, node) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("transform", "translate(" + (node.width - w) / 2 + ", " + h + ")"); +} +const hexagonBkg = function(_db, elem, node) { + const h = node.height; + const f = 4; + const m = h / f; + const w = node.width - node.padding + 2 * m; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + insertPolygonShape(elem, w, h, points, node); +}; +const roundedRectBkg = function(db2, elem, node) { + elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("rx", node.padding).attr("ry", node.padding).attr("width", node.width); +}; +const drawNode = function(db2, elem, node, fullSection, conf) { + const htmlLabels = conf.htmlLabels; + const section = fullSection % (MAX_SECTIONS - 1); + const nodeElem = elem.append("g"); + node.section = section; + let sectionClass = "section-" + section; + if (section < 0) { + sectionClass += " section-root"; + } + nodeElem.attr("class", (node.class ? node.class + " " : "") + "mindmap-node " + sectionClass); + const bkgElem = nodeElem.append("g"); + const textElem = nodeElem.append("g"); + const description = node.descr.replace(/()/g, "\n"); + createText(textElem, description, { + useHtmlLabels: htmlLabels, + width: node.width, + classes: "mindmap-node-label" + }); + if (!htmlLabels) { + textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle"); + } + const bbox = textElem.node().getBBox(); + const [fontSize] = parseFontSize(conf.fontSize); + node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; + node.width = bbox.width + 2 * node.padding; + if (node.icon) { + if (node.type === db2.nodeType.CIRCLE) { + node.height += 50; + node.width += 50; + const icon = nodeElem.append("foreignObject").attr("height", "50px").attr("width", node.width).attr("style", "text-align: center;"); + icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); + textElem.attr( + "transform", + "translate(" + node.width / 2 + ", " + (node.height / 2 - 1.5 * node.padding) + ")" + ); + } else { + node.width += 50; + const orgHeight = node.height; + node.height = Math.max(orgHeight, 60); + const heightDiff = Math.abs(node.height - orgHeight); + const icon = nodeElem.append("foreignObject").attr("width", "60px").attr("height", node.height).attr("style", "text-align: center;margin-top:" + heightDiff / 2 + "px;"); + icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); + textElem.attr( + "transform", + "translate(" + (25 + node.width / 2) + ", " + (heightDiff / 2 + node.padding / 2) + ")" + ); + } + } else { + if (!htmlLabels) { + const dx = node.width / 2; + const dy = node.padding / 2; + textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); + } else { + const dx = (node.width - bbox.width) / 2; + const dy = (node.height - bbox.height) / 2; + textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); + } + } + switch (node.type) { + case db2.nodeType.DEFAULT: + defaultBkg(db2, bkgElem, node, section); + break; + case db2.nodeType.ROUNDED_RECT: + roundedRectBkg(db2, bkgElem, node); + break; + case db2.nodeType.RECT: + rectBkg(db2, bkgElem, node); + break; + case db2.nodeType.CIRCLE: + bkgElem.attr("transform", "translate(" + node.width / 2 + ", " + +node.height / 2 + ")"); + circleBkg(db2, bkgElem, node); + break; + case db2.nodeType.CLOUD: + cloudBkg(db2, bkgElem, node); + break; + case db2.nodeType.BANG: + bangBkg(db2, bkgElem, node); + break; + case db2.nodeType.HEXAGON: + hexagonBkg(db2, bkgElem, node); + break; + } + db2.setElementForId(node.id, nodeElem); + return node.height; +}; +const positionNode = function(db2, node) { + const nodeElem = db2.getElementById(node.id); + const x = node.x || 0; + const y = node.y || 0; + nodeElem.attr("transform", "translate(" + x + "," + y + ")"); +}; +cytoscape$1.use(coseBilkent); +function drawNodes(db2, svg, mindmap, section, conf) { + drawNode(db2, svg, mindmap, section, conf); + if (mindmap.children) { + mindmap.children.forEach((child, index) => { + drawNodes(db2, svg, child, section < 0 ? index : section, conf); + }); + } +} +function drawEdges(edgesEl, cy) { + cy.edges().map((edge, id) => { + const data = edge.data(); + if (edge[0]._private.bodyBounds) { + const bounds = edge[0]._private.rscratch; + log$1.trace("Edge: ", id, data); + edgesEl.insert("path").attr( + "d", + `M ${bounds.startX},${bounds.startY} L ${bounds.midX},${bounds.midY} L${bounds.endX},${bounds.endY} ` + ).attr("class", "edge section-edge-" + data.section + " edge-depth-" + data.depth); + } + }); +} +function addNodes(mindmap, cy, conf, level) { + cy.add({ + group: "nodes", + data: { + id: mindmap.id.toString(), + labelText: mindmap.descr, + height: mindmap.height, + width: mindmap.width, + level, + nodeId: mindmap.id, + padding: mindmap.padding, + type: mindmap.type + }, + position: { + x: mindmap.x, + y: mindmap.y + } + }); + if (mindmap.children) { + mindmap.children.forEach((child) => { + addNodes(child, cy, conf, level + 1); + cy.add({ + group: "edges", + data: { + id: `${mindmap.id}_${child.id}`, + source: mindmap.id, + target: child.id, + depth: level, + section: child.section + } + }); + }); + } +} +function layoutMindmap(node, conf) { + return new Promise((resolve) => { + const renderEl = select("body").append("div").attr("id", "cy").attr("style", "display:none"); + const cy = cytoscape$1({ + container: document.getElementById("cy"), + // container to render in + style: [ + { + selector: "edge", + style: { + "curve-style": "bezier" + } + } + ] + }); + renderEl.remove(); + addNodes(node, cy, conf, 0); + cy.nodes().forEach(function(n) { + n.layoutDimensions = () => { + const data = n.data(); + return { w: data.width, h: data.height }; + }; + }); + cy.layout({ + name: "cose-bilkent", + // @ts-ignore Types for cose-bilkent are not correct? + quality: "proof", + styleEnabled: false, + animate: false + }).run(); + cy.ready((e) => { + log$1.info("Ready", e); + resolve(cy); + }); + }); +} +function positionNodes(db2, cy) { + cy.nodes().map((node, id) => { + const data = node.data(); + data.x = node.position().x; + data.y = node.position().y; + positionNode(db2, data); + const el = db2.getElementById(data.nodeId); + log$1.info("Id:", id, "Position: (", node.position().x, ", ", node.position().y, ")", data); + el.attr( + "transform", + `translate(${node.position().x - data.width / 2}, ${node.position().y - data.height / 2})` + ); + el.attr("attr", `apa-${id})`); + }); +} +const draw = async (text, id, _version, diagObj) => { + var _a, _b; + log$1.debug("Rendering mindmap diagram\n" + text); + const db2 = diagObj.db; + const mm = db2.getMindmap(); + if (!mm) { + return; + } + const conf = getConfig(); + conf.htmlLabels = false; + const svg = selectSvgElement(id); + const edgesElem = svg.append("g"); + edgesElem.attr("class", "mindmap-edges"); + const nodesElem = svg.append("g"); + nodesElem.attr("class", "mindmap-nodes"); + drawNodes(db2, nodesElem, mm, -1, conf); + const cy = await layoutMindmap(mm, conf); + drawEdges(edgesElem, cy); + positionNodes(db2, cy); + setupGraphViewbox$1( + void 0, + svg, + ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig$2.mindmap.padding, + ((_b = conf.mindmap) == null ? void 0 : _b.useMaxWidth) ?? defaultConfig$2.mindmap.useMaxWidth + ); +}; +const renderer = { + draw +}; +const genSections = (options) => { + let sections = ""; + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i]; + if (isDark(options["lineColor" + i])) { + options["lineColor" + i] = lighten(options["lineColor" + i], 20); + } else { + options["lineColor" + i] = darken(options["lineColor" + i], 20); + } + } + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + const sw = "" + (17 - 3 * i); + sections += ` + .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path { + fill: ${options["cScale" + i]}; + } + .section-${i - 1} text { + fill: ${options["cScaleLabel" + i]}; + } + .node-icon-${i - 1} { + font-size: 40px; + color: ${options["cScaleLabel" + i]}; + } + .section-edge-${i - 1}{ + stroke: ${options["cScale" + i]}; + } + .edge-depth-${i - 1}{ + stroke-width: ${sw}; + } + .section-${i - 1} line { + stroke: ${options["cScaleInv" + i]} ; + stroke-width: 3; + } + + .disabled, .disabled circle, .disabled text { + fill: lightgray; + } + .disabled text { + fill: #efefef; + } + `; + } + return sections; +}; +const getStyles = (options) => ` + .edge { + stroke-width: 3; + } + ${genSections(options)} + .section-root rect, .section-root path, .section-root circle, .section-root polygon { + fill: ${options.git0}; + } + .section-root text { + fill: ${options.gitBranchLabel0}; + } + .icon-container { + height:100%; + display: flex; + justify-content: center; + align-items: center; + } + .edge { + fill: none; + } + .mindmap-node-label { + dy: 1em; + alignment-baseline: middle; + text-anchor: middle; + dominant-baseline: middle; + text-align: center; + } +`; +const styles = getStyles; +const diagram = { + db: db$1, + renderer, + parser: parser$1, + styles +}; + +export { diagram }; diff --git a/libs/marked/mindmap-definition-307c710a-aXOOrvfG.js b/libs/marked/mindmap-definition-307c710a-aXOOrvfG.js new file mode 100644 index 0000000..af040fc --- /dev/null +++ b/libs/marked/mindmap-definition-307c710a-aXOOrvfG.js @@ -0,0 +1,38625 @@ +import { P as commonjsGlobal$1, Q as getDefaultExportFromCjs, l as log$1, c as getConfig, U as selectSvgElement, t as setupGraphViewbox$1, W as defaultConfig$2, d as sanitizeText$2, h as select, as as isDark, at as lighten, au as darken, Y as parseFontSize } from './index-Bd_FDXSq.js'; +import { a as createText } from './createText-ca0c5216-B9KlDTE8.js'; + +/** + * Copyright (c) 2016-2024, The Cytoscape Consortium. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the “Software”), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +function _typeof(obj) { + "@babel/helpers - typeof"; + + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); +} +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; +} +function _defineProperty$1(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} +function _iterableToArrayLimit(arr, i) { + var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; + if (_i == null) return; + var _arr = []; + var _n = true; + var _d = false; + var _s, _e; + try { + for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"] != null) _i["return"](); + } finally { + if (_d) throw _e; + } + } + return _arr; +} +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +function _createForOfIteratorHelper(o, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; + if (!it) { + if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { + if (it) o = it; + var i = 0; + var F = function () {}; + return { + s: F, + n: function () { + if (i >= o.length) return { + done: true + }; + return { + done: false, + value: o[i++] + }; + }, + e: function (e) { + throw e; + }, + f: F + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + var normalCompletion = true, + didErr = false, + err; + return { + s: function () { + it = it.call(o); + }, + n: function () { + var step = it.next(); + normalCompletion = step.done; + return step; + }, + e: function (e) { + didErr = true; + err = e; + }, + f: function () { + try { + if (!normalCompletion && it.return != null) it.return(); + } finally { + if (didErr) throw err; + } + } + }; +} + +var _window = typeof window === 'undefined' ? null : window; // eslint-disable-line no-undef + +var navigator = _window ? _window.navigator : null; +_window ? _window.document : null; +var typeofstr = _typeof(''); +var typeofobj = _typeof({}); +var typeoffn = _typeof(function () {}); +var typeofhtmlele = typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement); +var instanceStr = function instanceStr(obj) { + return obj && obj.instanceString && fn$6(obj.instanceString) ? obj.instanceString() : null; +}; + +var string = function string(obj) { + return obj != null && _typeof(obj) == typeofstr; +}; +var fn$6 = function fn(obj) { + return obj != null && _typeof(obj) === typeoffn; +}; +var array = function array(obj) { + return !elementOrCollection(obj) && (Array.isArray ? Array.isArray(obj) : obj != null && obj instanceof Array); +}; +var plainObject = function plainObject(obj) { + return obj != null && _typeof(obj) === typeofobj && !array(obj) && obj.constructor === Object; +}; +var object = function object(obj) { + return obj != null && _typeof(obj) === typeofobj; +}; +var number$1 = function number(obj) { + return obj != null && _typeof(obj) === _typeof(1) && !isNaN(obj); +}; +var integer = function integer(obj) { + return number$1(obj) && Math.floor(obj) === obj; +}; +var htmlElement = function htmlElement(obj) { + if ('undefined' === typeofhtmlele) { + return undefined; + } else { + return null != obj && obj instanceof HTMLElement; + } +}; +var elementOrCollection = function elementOrCollection(obj) { + return element(obj) || collection(obj); +}; +var element = function element(obj) { + return instanceStr(obj) === 'collection' && obj._private.single; +}; +var collection = function collection(obj) { + return instanceStr(obj) === 'collection' && !obj._private.single; +}; +var core = function core(obj) { + return instanceStr(obj) === 'core'; +}; +var stylesheet = function stylesheet(obj) { + return instanceStr(obj) === 'stylesheet'; +}; +var event = function event(obj) { + return instanceStr(obj) === 'event'; +}; +var emptyString = function emptyString(obj) { + if (obj === undefined || obj === null) { + // null is empty + return true; + } else if (obj === '' || obj.match(/^\s+$/)) { + return true; // empty string is empty + } + + return false; // otherwise, we don't know what we've got +}; +var domElement = function domElement(obj) { + if (typeof HTMLElement === 'undefined') { + return false; // we're not in a browser so it doesn't matter + } else { + return obj instanceof HTMLElement; + } +}; +var boundingBox = function boundingBox(obj) { + return plainObject(obj) && number$1(obj.x1) && number$1(obj.x2) && number$1(obj.y1) && number$1(obj.y2); +}; +var promise = function promise(obj) { + return object(obj) && fn$6(obj.then); +}; +var ms = function ms() { + return navigator && navigator.userAgent.match(/msie|trident|edge/i); +}; // probably a better way to detect this... + +var memoize$1 = function memoize(fn, keyFn) { + if (!keyFn) { + keyFn = function keyFn() { + if (arguments.length === 1) { + return arguments[0]; + } else if (arguments.length === 0) { + return 'undefined'; + } + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + return args.join('$'); + }; + } + var memoizedFn = function memoizedFn() { + var self = this; + var args = arguments; + var ret; + var k = keyFn.apply(self, args); + var cache = memoizedFn.cache; + if (!(ret = cache[k])) { + ret = cache[k] = fn.apply(self, args); + } + return ret; + }; + memoizedFn.cache = {}; + return memoizedFn; +}; + +var camel2dash = memoize$1(function (str) { + return str.replace(/([A-Z])/g, function (v) { + return '-' + v.toLowerCase(); + }); +}); +var dash2camel = memoize$1(function (str) { + return str.replace(/(-\w)/g, function (v) { + return v[1].toUpperCase(); + }); +}); +var prependCamel = memoize$1(function (prefix, str) { + return prefix + str[0].toUpperCase() + str.substring(1); +}, function (prefix, str) { + return prefix + '$' + str; +}); +var capitalize = function capitalize(str) { + if (emptyString(str)) { + return str; + } + return str.charAt(0).toUpperCase() + str.substring(1); +}; + +var number = '(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))'; +var rgba = 'rgb[a]?\\((' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)(?:\\s*,\\s*(' + number + '))?\\)'; +var rgbaNoBackRefs = 'rgb[a]?\\((?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)(?:\\s*,\\s*(?:' + number + '))?\\)'; +var hsla = 'hsl[a]?\\((' + number + ')\\s*,\\s*(' + number + '[%])\\s*,\\s*(' + number + '[%])(?:\\s*,\\s*(' + number + '))?\\)'; +var hslaNoBackRefs = 'hsl[a]?\\((?:' + number + ')\\s*,\\s*(?:' + number + '[%])\\s*,\\s*(?:' + number + '[%])(?:\\s*,\\s*(?:' + number + '))?\\)'; +var hex3 = '\\#[0-9a-fA-F]{3}'; +var hex6 = '\\#[0-9a-fA-F]{6}'; + +var ascending = function ascending(a, b) { + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } +}; +var descending = function descending(a, b) { + return -1 * ascending(a, b); +}; + +var extend = Object.assign != null ? Object.assign.bind(Object) : function (tgt) { + var args = arguments; + for (var i = 1; i < args.length; i++) { + var obj = args[i]; + if (obj == null) { + continue; + } + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; j++) { + var k = keys[j]; + tgt[k] = obj[k]; + } + } + return tgt; +}; + +// get [r, g, b] from #abc or #aabbcc +var hex2tuple = function hex2tuple(hex) { + if (!(hex.length === 4 || hex.length === 7) || hex[0] !== '#') { + return; + } + var shortHex = hex.length === 4; + var r, g, b; + var base = 16; + if (shortHex) { + r = parseInt(hex[1] + hex[1], base); + g = parseInt(hex[2] + hex[2], base); + b = parseInt(hex[3] + hex[3], base); + } else { + r = parseInt(hex[1] + hex[2], base); + g = parseInt(hex[3] + hex[4], base); + b = parseInt(hex[5] + hex[6], base); + } + return [r, g, b]; +}; + +// get [r, g, b, a] from hsl(0, 0, 0) or hsla(0, 0, 0, 0) +var hsl2tuple = function hsl2tuple(hsl) { + var ret; + var h, s, l, a, r, g, b; + function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; + return p; + } + var m = new RegExp('^' + hsla + '$').exec(hsl); + if (m) { + // get hue + h = parseInt(m[1]); + if (h < 0) { + h = (360 - -1 * h % 360) % 360; + } else if (h > 360) { + h = h % 360; + } + h /= 360; // normalise on [0, 1] + + s = parseFloat(m[2]); + if (s < 0 || s > 100) { + return; + } // saturation is [0, 100] + s = s / 100; // normalise on [0, 1] + + l = parseFloat(m[3]); + if (l < 0 || l > 100) { + return; + } // lightness is [0, 100] + l = l / 100; // normalise on [0, 1] + + a = m[4]; + if (a !== undefined) { + a = parseFloat(a); + if (a < 0 || a > 1) { + return; + } // alpha is [0, 1] + } + + // now, convert to rgb + // code from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript + if (s === 0) { + r = g = b = Math.round(l * 255); // achromatic + } else { + var q = l < 0.5 ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + r = Math.round(255 * hue2rgb(p, q, h + 1 / 3)); + g = Math.round(255 * hue2rgb(p, q, h)); + b = Math.round(255 * hue2rgb(p, q, h - 1 / 3)); + } + ret = [r, g, b, a]; + } + return ret; +}; + +// get [r, g, b, a] from rgb(0, 0, 0) or rgba(0, 0, 0, 0) +var rgb2tuple = function rgb2tuple(rgb) { + var ret; + var m = new RegExp('^' + rgba + '$').exec(rgb); + if (m) { + ret = []; + var isPct = []; + for (var i = 1; i <= 3; i++) { + var channel = m[i]; + if (channel[channel.length - 1] === '%') { + isPct[i] = true; + } + channel = parseFloat(channel); + if (isPct[i]) { + channel = channel / 100 * 255; // normalise to [0, 255] + } + + if (channel < 0 || channel > 255) { + return; + } // invalid channel value + + ret.push(Math.floor(channel)); + } + var atLeastOneIsPct = isPct[1] || isPct[2] || isPct[3]; + var allArePct = isPct[1] && isPct[2] && isPct[3]; + if (atLeastOneIsPct && !allArePct) { + return; + } // must all be percent values if one is + + var alpha = m[4]; + if (alpha !== undefined) { + alpha = parseFloat(alpha); + if (alpha < 0 || alpha > 1) { + return; + } // invalid alpha value + + ret.push(alpha); + } + } + return ret; +}; +var colorname2tuple = function colorname2tuple(color) { + return colors[color.toLowerCase()]; +}; +var color2tuple = function color2tuple(color) { + return (array(color) ? color : null) || colorname2tuple(color) || hex2tuple(color) || rgb2tuple(color) || hsl2tuple(color); +}; +var colors = { + // special colour names + transparent: [0, 0, 0, 0], + // NB alpha === 0 + + // regular colours + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + grey: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] +}; + +// sets the value in a map (map may not be built) +var setMap = function setMap(options) { + var obj = options.map; + var keys = options.keys; + var l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (plainObject(key)) { + throw Error('Tried to set map with object key'); + } + if (i < keys.length - 1) { + // extend the map if necessary + if (obj[key] == null) { + obj[key] = {}; + } + obj = obj[key]; + } else { + // set the value + obj[key] = options.value; + } + } +}; + +// gets the value in a map even if it's not built in places +var getMap = function getMap(options) { + var obj = options.map; + var keys = options.keys; + var l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (plainObject(key)) { + throw Error('Tried to get map with object key'); + } + obj = obj[key]; + if (obj == null) { + return obj; + } + } + return obj; +}; + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +var isObject_1 = isObject; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; + +var _freeGlobal = freeGlobal; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = _freeGlobal || freeSelf || Function('return this')(); + +var _root = root; + +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ +var now = function() { + return _root.Date.now(); +}; + +var now_1 = now; + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +var _trimmedEndIndex = trimmedEndIndex; + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +var _baseTrim = baseTrim; + +/** Built-in value references. */ +var Symbol$1 = _root.Symbol; + +var _Symbol = Symbol$1; + +/** Used for built-in method references. */ +var objectProto$5 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$4 = objectProto$5.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$5.toString; + +/** Built-in value references. */ +var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString$1.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +var _getRawTag = getRawTag; + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto$4.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +var _objectToString = objectToString; + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? _getRawTag(value) + : _objectToString(value); +} + +var _baseGetTag = baseGetTag; + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +var isObjectLike_1 = isObjectLike; + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike_1(value) && _baseGetTag(value) == symbolTag); +} + +var isSymbol_1 = isSymbol; + +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + +/** + * Converts `value` to a number. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 + */ +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol_1(value)) { + return NAN; + } + if (isObject_1(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject_1(other) ? (other + '') : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = _baseTrim(value); + var isBinary = reIsBinary.test(value); + return (isBinary || reIsOctal.test(value)) + ? freeParseInt(value.slice(2), isBinary ? 2 : 8) + : (reIsBadHex.test(value) ? NAN : +value); +} + +var toNumber_1 = toNumber; + +/** Error message constants. */ +var FUNC_ERROR_TEXT$1 = 'Expected a function'; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max, + nativeMin = Math.min; + +/** + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. + * + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. + * @example + * + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); + */ +function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$1); + } + wait = toNumber_1(wait) || 0; + if (isObject_1(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; + } + + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } + + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + timeWaiting = wait - timeSinceLastCall; + + return maxing + ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting; + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); + } + + function timerExpired() { + var time = now_1(); + if (shouldInvoke(time)) { + return trailingEdge(time); + } + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); + } + + function trailingEdge(time) { + timerId = undefined; + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } + + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } + + function flush() { + return timerId === undefined ? result : trailingEdge(now_1()); + } + + function debounced() { + var time = now_1(), + isInvoking = shouldInvoke(time); + + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + clearTimeout(timerId); + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } + } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; + } + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; +} + +var debounce_1 = debounce; + +var performance = _window ? _window.performance : null; +var pnow = performance && performance.now ? function () { + return performance.now(); +} : function () { + return Date.now(); +}; +var raf = function () { + if (_window) { + if (_window.requestAnimationFrame) { + return function (fn) { + _window.requestAnimationFrame(fn); + }; + } else if (_window.mozRequestAnimationFrame) { + return function (fn) { + _window.mozRequestAnimationFrame(fn); + }; + } else if (_window.webkitRequestAnimationFrame) { + return function (fn) { + _window.webkitRequestAnimationFrame(fn); + }; + } else if (_window.msRequestAnimationFrame) { + return function (fn) { + _window.msRequestAnimationFrame(fn); + }; + } + } + return function (fn) { + if (fn) { + setTimeout(function () { + fn(pnow()); + }, 1000 / 60); + } + }; +}(); +var requestAnimationFrame$1 = function requestAnimationFrame(fn) { + return raf(fn); +}; +var performanceNow = pnow; + +var DEFAULT_HASH_SEED = 9261; +var K = 65599; // 37 also works pretty well +var DEFAULT_HASH_SEED_ALT = 5381; +var hashIterableInts = function hashIterableInts(iterator) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED; + // sdbm/string-hash + var hash = seed; + var entry; + for (;;) { + entry = iterator.next(); + if (entry.done) { + break; + } + hash = hash * K + entry.value | 0; + } + return hash; +}; +var hashInt = function hashInt(num) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED; + // sdbm/string-hash + return seed * K + num | 0; +}; +var hashIntAlt = function hashIntAlt(num) { + var seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HASH_SEED_ALT; + // djb2/string-hash + return (seed << 5) + seed + num | 0; +}; +var combineHashes = function combineHashes(hash1, hash2) { + return hash1 * 0x200000 + hash2; +}; +var combineHashesArray = function combineHashesArray(hashes) { + return hashes[0] * 0x200000 + hashes[1]; +}; +var hashArrays = function hashArrays(hashes1, hashes2) { + return [hashInt(hashes1[0], hashes2[0]), hashIntAlt(hashes1[1], hashes2[1])]; +}; +var hashIntsArray = function hashIntsArray(ints, seed) { + var entry = { + value: 0, + done: false + }; + var i = 0; + var length = ints.length; + var iterator = { + next: function next() { + if (i < length) { + entry.value = ints[i++]; + } else { + entry.done = true; + } + return entry; + } + }; + return hashIterableInts(iterator, seed); +}; +var hashString = function hashString(str, seed) { + var entry = { + value: 0, + done: false + }; + var i = 0; + var length = str.length; + var iterator = { + next: function next() { + if (i < length) { + entry.value = str.charCodeAt(i++); + } else { + entry.done = true; + } + return entry; + } + }; + return hashIterableInts(iterator, seed); +}; +var hashStrings = function hashStrings() { + return hashStringsArray(arguments); +}; +var hashStringsArray = function hashStringsArray(strs) { + var hash; + for (var i = 0; i < strs.length; i++) { + var str = strs[i]; + if (i === 0) { + hash = hashString(str); + } else { + hash = hashString(str, hash); + } + } + return hash; +}; + +/*global console */ +var warningsEnabled = true; +var warnSupported = console.warn != null; // eslint-disable-line no-console +var traceSupported = console.trace != null; // eslint-disable-line no-console + +var MAX_INT$1 = Number.MAX_SAFE_INTEGER || 9007199254740991; +var trueify = function trueify() { + return true; +}; +var falsify = function falsify() { + return false; +}; +var zeroify = function zeroify() { + return 0; +}; +var noop$1 = function noop() {}; +var error = function error(msg) { + throw new Error(msg); +}; +var warnings = function warnings(enabled) { + if (enabled !== undefined) { + warningsEnabled = !!enabled; + } else { + return warningsEnabled; + } +}; +var warn = function warn(msg) { + /* eslint-disable no-console */ + if (!warnings()) { + return; + } + if (warnSupported) { + console.warn(msg); + } else { + console.log(msg); + if (traceSupported) { + console.trace(); + } + } +}; /* eslint-enable */ + +var clone = function clone(obj) { + return extend({}, obj); +}; + +// gets a shallow copy of the argument +var copy = function copy(obj) { + if (obj == null) { + return obj; + } + if (array(obj)) { + return obj.slice(); + } else if (plainObject(obj)) { + return clone(obj); + } else { + return obj; + } +}; +var copyArray$1 = function copyArray(arr) { + return arr.slice(); +}; +var uuid = function uuid(a, b /* placeholders */) { + for ( + // loop :) + b = a = ''; + // b - result , a - numeric letiable + a++ < 36; + // + b += a * 51 & 52 // if "a" is not 9 or 14 or 19 or 24 + ? + // return a random number or 4 + (a ^ 15 // if "a" is not 15 + ? + // generate a random number from 0 to 15 + 8 ^ Math.random() * (a ^ 20 ? 16 : 4) // unless "a" is 20, in which case a random number from 8 to 11 + : 4 // otherwise 4 + ).toString(16) : '-' // in other cases (if "a" is 9,14,19,24) insert "-" + ) { + } + return b; +}; +var _staticEmptyObject = {}; +var staticEmptyObject = function staticEmptyObject() { + return _staticEmptyObject; +}; +var defaults$g = function defaults(_defaults) { + var keys = Object.keys(_defaults); + return function (opts) { + var filledOpts = {}; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var optVal = opts == null ? undefined : opts[key]; + filledOpts[key] = optVal === undefined ? _defaults[key] : optVal; + } + return filledOpts; + }; +}; +var removeFromArray = function removeFromArray(arr, ele, oneCopy) { + for (var i = arr.length - 1; i >= 0; i--) { + if (arr[i] === ele) { + arr.splice(i, 1); + } + } +}; +var clearArray = function clearArray(arr) { + arr.splice(0, arr.length); +}; +var push = function push(arr, otherArr) { + for (var i = 0; i < otherArr.length; i++) { + var el = otherArr[i]; + arr.push(el); + } +}; +var getPrefixedProperty = function getPrefixedProperty(obj, propName, prefix) { + if (prefix) { + propName = prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth + } + + return obj[propName]; +}; +var setPrefixedProperty = function setPrefixedProperty(obj, propName, prefix, value) { + if (prefix) { + propName = prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth + } + + obj[propName] = value; +}; + +/* global Map */ +var ObjectMap = /*#__PURE__*/function () { + function ObjectMap() { + _classCallCheck(this, ObjectMap); + this._obj = {}; + } + _createClass(ObjectMap, [{ + key: "set", + value: function set(key, val) { + this._obj[key] = val; + return this; + } + }, { + key: "delete", + value: function _delete(key) { + this._obj[key] = undefined; + return this; + } + }, { + key: "clear", + value: function clear() { + this._obj = {}; + } + }, { + key: "has", + value: function has(key) { + return this._obj[key] !== undefined; + } + }, { + key: "get", + value: function get(key) { + return this._obj[key]; + } + }]); + return ObjectMap; +}(); +var Map$2 = typeof Map !== 'undefined' ? Map : ObjectMap; + +/* global Set */ + +var undef = "undefined" ; +var ObjectSet = /*#__PURE__*/function () { + function ObjectSet(arrayOrObjectSet) { + _classCallCheck(this, ObjectSet); + this._obj = Object.create(null); + this.size = 0; + if (arrayOrObjectSet != null) { + var arr; + if (arrayOrObjectSet.instanceString != null && arrayOrObjectSet.instanceString() === this.instanceString()) { + arr = arrayOrObjectSet.toArray(); + } else { + arr = arrayOrObjectSet; + } + for (var i = 0; i < arr.length; i++) { + this.add(arr[i]); + } + } + } + _createClass(ObjectSet, [{ + key: "instanceString", + value: function instanceString() { + return 'set'; + } + }, { + key: "add", + value: function add(val) { + var o = this._obj; + if (o[val] !== 1) { + o[val] = 1; + this.size++; + } + } + }, { + key: "delete", + value: function _delete(val) { + var o = this._obj; + if (o[val] === 1) { + o[val] = 0; + this.size--; + } + } + }, { + key: "clear", + value: function clear() { + this._obj = Object.create(null); + } + }, { + key: "has", + value: function has(val) { + return this._obj[val] === 1; + } + }, { + key: "toArray", + value: function toArray() { + var _this = this; + return Object.keys(this._obj).filter(function (key) { + return _this.has(key); + }); + } + }, { + key: "forEach", + value: function forEach(callback, thisArg) { + return this.toArray().forEach(callback, thisArg); + } + }]); + return ObjectSet; +}(); +var Set$1 = (typeof Set === "undefined" ? "undefined" : _typeof(Set)) !== undef ? Set : ObjectSet; + +// represents a node or an edge +var Element = function Element(cy, params) { + var restore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + if (cy === undefined || params === undefined || !core(cy)) { + error('An element must have a core reference and parameters set'); + return; + } + var group = params.group; + + // try to automatically infer the group if unspecified + if (group == null) { + if (params.data && params.data.source != null && params.data.target != null) { + group = 'edges'; + } else { + group = 'nodes'; + } + } + + // validate group + if (group !== 'nodes' && group !== 'edges') { + error('An element must be of type `nodes` or `edges`; you specified `' + group + '`'); + return; + } + + // make the element array-like, just like a collection + this.length = 1; + this[0] = this; + + // NOTE: when something is added here, add also to ele.json() + var _p = this._private = { + cy: cy, + single: true, + // indicates this is an element + data: params.data || {}, + // data object + position: params.position || { + x: 0, + y: 0 + }, + // (x, y) position pair + autoWidth: undefined, + // width and height of nodes calculated by the renderer when set to special 'auto' value + autoHeight: undefined, + autoPadding: undefined, + compoundBoundsClean: false, + // whether the compound dimensions need to be recalculated the next time dimensions are read + listeners: [], + // array of bound listeners + group: group, + // string; 'nodes' or 'edges' + style: {}, + // properties as set by the style + rstyle: {}, + // properties for style sent from the renderer to the core + styleCxts: [], + // applied style contexts from the styler + styleKeys: {}, + // per-group keys of style property values + removed: true, + // whether it's inside the vis; true if removed (set true here since we call restore) + selected: params.selected ? true : false, + // whether it's selected + selectable: params.selectable === undefined ? true : params.selectable ? true : false, + // whether it's selectable + locked: params.locked ? true : false, + // whether the element is locked (cannot be moved) + grabbed: false, + // whether the element is grabbed by the mouse; renderer sets this privately + grabbable: params.grabbable === undefined ? true : params.grabbable ? true : false, + // whether the element can be grabbed + pannable: params.pannable === undefined ? group === 'edges' ? true : false : params.pannable ? true : false, + // whether the element has passthrough panning enabled + active: false, + // whether the element is active from user interaction + classes: new Set$1(), + // map ( className => true ) + animation: { + // object for currently-running animations + current: [], + queue: [] + }, + rscratch: {}, + // object in which the renderer can store information + scratch: params.scratch || {}, + // scratch objects + edges: [], + // array of connected edges + children: [], + // array of children + parent: params.parent && params.parent.isNode() ? params.parent : null, + // parent ref + traversalCache: {}, + // cache of output of traversal functions + backgrounding: false, + // whether background images are loading + bbCache: null, + // cache of the current bounding box + bbCacheShift: { + x: 0, + y: 0 + }, + // shift applied to cached bb to be applied on next get + bodyBounds: null, + // bounds cache of element body, w/o overlay + overlayBounds: null, + // bounds cache of element body, including overlay + labelBounds: { + // bounds cache of labels + all: null, + source: null, + target: null, + main: null + }, + arrowBounds: { + // bounds cache of edge arrows + source: null, + target: null, + 'mid-source': null, + 'mid-target': null + } + }; + if (_p.position.x == null) { + _p.position.x = 0; + } + if (_p.position.y == null) { + _p.position.y = 0; + } + + // renderedPosition overrides if specified + if (params.renderedPosition) { + var rpos = params.renderedPosition; + var pan = cy.pan(); + var zoom = cy.zoom(); + _p.position = { + x: (rpos.x - pan.x) / zoom, + y: (rpos.y - pan.y) / zoom + }; + } + var classes = []; + if (array(params.classes)) { + classes = params.classes; + } else if (string(params.classes)) { + classes = params.classes.split(/\s+/); + } + for (var i = 0, l = classes.length; i < l; i++) { + var cls = classes[i]; + if (!cls || cls === '') { + continue; + } + _p.classes.add(cls); + } + this.createEmitter(); + var bypass = params.style || params.css; + if (bypass) { + warn('Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead.'); + this.style(bypass); + } + if (restore === undefined || restore) { + this.restore(); + } +}; + +var defineSearch = function defineSearch(params) { + params = { + bfs: params.bfs || !params.dfs, + dfs: params.dfs || !params.bfs + }; + + // from pseudocode on wikipedia + return function searchFn(roots, fn, directed) { + var options; + if (plainObject(roots) && !elementOrCollection(roots)) { + options = roots; + roots = options.roots || options.root; + fn = options.visit; + directed = options.directed; + } + directed = arguments.length === 2 && !fn$6(fn) ? fn : directed; + fn = fn$6(fn) ? fn : function () {}; + var cy = this._private.cy; + var v = roots = string(roots) ? this.filter(roots) : roots; + var Q = []; + var connectedNodes = []; + var connectedBy = {}; + var id2depth = {}; + var V = {}; + var j = 0; + var found; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + + // enqueue v + for (var i = 0; i < v.length; i++) { + var vi = v[i]; + var viId = vi.id(); + if (vi.isNode()) { + Q.unshift(vi); + if (params.bfs) { + V[viId] = true; + connectedNodes.push(vi); + } + id2depth[viId] = 0; + } + } + var _loop = function _loop() { + var v = params.bfs ? Q.shift() : Q.pop(); + var vId = v.id(); + if (params.dfs) { + if (V[vId]) { + return "continue"; + } + V[vId] = true; + connectedNodes.push(v); + } + var depth = id2depth[vId]; + var prevEdge = connectedBy[vId]; + var src = prevEdge != null ? prevEdge.source() : null; + var tgt = prevEdge != null ? prevEdge.target() : null; + var prevNode = prevEdge == null ? undefined : v.same(src) ? tgt[0] : src[0]; + var ret = void 0; + ret = fn(v, prevEdge, prevNode, j++, depth); + if (ret === true) { + found = v; + return "break"; + } + if (ret === false) { + return "break"; + } + var vwEdges = v.connectedEdges().filter(function (e) { + return (!directed || e.source().same(v)) && edges.has(e); + }); + for (var _i2 = 0; _i2 < vwEdges.length; _i2++) { + var e = vwEdges[_i2]; + var w = e.connectedNodes().filter(function (n) { + return !n.same(v) && nodes.has(n); + }); + var wId = w.id(); + if (w.length !== 0 && !V[wId]) { + w = w[0]; + Q.push(w); + if (params.bfs) { + V[wId] = true; + connectedNodes.push(w); + } + connectedBy[wId] = e; + id2depth[wId] = id2depth[vId] + 1; + } + } + }; + while (Q.length !== 0) { + var _ret = _loop(); + if (_ret === "continue") continue; + if (_ret === "break") break; + } + var connectedEles = cy.collection(); + for (var _i = 0; _i < connectedNodes.length; _i++) { + var node = connectedNodes[_i]; + var edge = connectedBy[node.id()]; + if (edge != null) { + connectedEles.push(edge); + } + connectedEles.push(node); + } + return { + path: cy.collection(connectedEles), + found: cy.collection(found) + }; + }; +}; + +// search, spanning trees, etc +var elesfn$v = { + breadthFirstSearch: defineSearch({ + bfs: true + }), + depthFirstSearch: defineSearch({ + dfs: true + }) +}; + +// nice, short mathematical alias +elesfn$v.bfs = elesfn$v.breadthFirstSearch; +elesfn$v.dfs = elesfn$v.depthFirstSearch; + +var heap$1 = createCommonjsModule(function (module, exports) { +// Generated by CoffeeScript 1.8.0 +(function() { + var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup; + + floor = Math.floor, min = Math.min; + + + /* + Default comparison function to be used + */ + + defaultCmp = function(x, y) { + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } + return 0; + }; + + + /* + Insert item x in list a, and keep it sorted assuming a is sorted. + + If x is already in a, insert it to the right of the rightmost x. + + Optional args lo (default 0) and hi (default a.length) bound the slice + of a to be searched. + */ + + insort = function(a, x, lo, hi, cmp) { + var mid; + if (lo == null) { + lo = 0; + } + if (cmp == null) { + cmp = defaultCmp; + } + if (lo < 0) { + throw new Error('lo must be non-negative'); + } + if (hi == null) { + hi = a.length; + } + while (lo < hi) { + mid = floor((lo + hi) / 2); + if (cmp(x, a[mid]) < 0) { + hi = mid; + } else { + lo = mid + 1; + } + } + return ([].splice.apply(a, [lo, lo - lo].concat(x)), x); + }; + + + /* + Push item onto heap, maintaining the heap invariant. + */ + + heappush = function(array, item, cmp) { + if (cmp == null) { + cmp = defaultCmp; + } + array.push(item); + return _siftdown(array, 0, array.length - 1, cmp); + }; + + + /* + Pop the smallest item off the heap, maintaining the heap invariant. + */ + + heappop = function(array, cmp) { + var lastelt, returnitem; + if (cmp == null) { + cmp = defaultCmp; + } + lastelt = array.pop(); + if (array.length) { + returnitem = array[0]; + array[0] = lastelt; + _siftup(array, 0, cmp); + } else { + returnitem = lastelt; + } + return returnitem; + }; + + + /* + Pop and return the current smallest value, and add the new item. + + This is more efficient than heappop() followed by heappush(), and can be + more appropriate when using a fixed size heap. Note that the value + returned may be larger than item! That constrains reasonable use of + this routine unless written as part of a conditional replacement: + if item > array[0] + item = heapreplace(array, item) + */ + + heapreplace = function(array, item, cmp) { + var returnitem; + if (cmp == null) { + cmp = defaultCmp; + } + returnitem = array[0]; + array[0] = item; + _siftup(array, 0, cmp); + return returnitem; + }; + + + /* + Fast version of a heappush followed by a heappop. + */ + + heappushpop = function(array, item, cmp) { + var _ref; + if (cmp == null) { + cmp = defaultCmp; + } + if (array.length && cmp(array[0], item) < 0) { + _ref = [array[0], item], item = _ref[0], array[0] = _ref[1]; + _siftup(array, 0, cmp); + } + return item; + }; + + + /* + Transform list into a heap, in-place, in O(array.length) time. + */ + + heapify = function(array, cmp) { + var i, _i, _len, _ref1, _results, _results1; + if (cmp == null) { + cmp = defaultCmp; + } + _ref1 = (function() { + _results1 = []; + for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); } + return _results1; + }).apply(this).reverse(); + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + i = _ref1[_i]; + _results.push(_siftup(array, i, cmp)); + } + return _results; + }; + + + /* + Update the position of the given item in the heap. + This function should be called every time the item is being modified. + */ + + updateItem = function(array, item, cmp) { + var pos; + if (cmp == null) { + cmp = defaultCmp; + } + pos = array.indexOf(item); + if (pos === -1) { + return; + } + _siftdown(array, 0, pos, cmp); + return _siftup(array, pos, cmp); + }; + + + /* + Find the n largest elements in a dataset. + */ + + nlargest = function(array, n, cmp) { + var elem, result, _i, _len, _ref; + if (cmp == null) { + cmp = defaultCmp; + } + result = array.slice(0, n); + if (!result.length) { + return result; + } + heapify(result, cmp); + _ref = array.slice(n); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elem = _ref[_i]; + heappushpop(result, elem, cmp); + } + return result.sort(cmp).reverse(); + }; + + + /* + Find the n smallest elements in a dataset. + */ + + nsmallest = function(array, n, cmp) { + var elem, los, result, _i, _j, _len, _ref, _ref1, _results; + if (cmp == null) { + cmp = defaultCmp; + } + if (n * 10 <= array.length) { + result = array.slice(0, n).sort(cmp); + if (!result.length) { + return result; + } + los = result[result.length - 1]; + _ref = array.slice(n); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + elem = _ref[_i]; + if (cmp(elem, los) < 0) { + insort(result, elem, 0, null, cmp); + result.pop(); + los = result[result.length - 1]; + } + } + return result; + } + heapify(array, cmp); + _results = []; + for (_j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; 0 <= _ref1 ? ++_j : --_j) { + _results.push(heappop(array, cmp)); + } + return _results; + }; + + _siftdown = function(array, startpos, pos, cmp) { + var newitem, parent, parentpos; + if (cmp == null) { + cmp = defaultCmp; + } + newitem = array[pos]; + while (pos > startpos) { + parentpos = (pos - 1) >> 1; + parent = array[parentpos]; + if (cmp(newitem, parent) < 0) { + array[pos] = parent; + pos = parentpos; + continue; + } + break; + } + return array[pos] = newitem; + }; + + _siftup = function(array, pos, cmp) { + var childpos, endpos, newitem, rightpos, startpos; + if (cmp == null) { + cmp = defaultCmp; + } + endpos = array.length; + startpos = pos; + newitem = array[pos]; + childpos = 2 * pos + 1; + while (childpos < endpos) { + rightpos = childpos + 1; + if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) { + childpos = rightpos; + } + array[pos] = array[childpos]; + pos = childpos; + childpos = 2 * pos + 1; + } + array[pos] = newitem; + return _siftdown(array, startpos, pos, cmp); + }; + + Heap = (function() { + Heap.push = heappush; + + Heap.pop = heappop; + + Heap.replace = heapreplace; + + Heap.pushpop = heappushpop; + + Heap.heapify = heapify; + + Heap.updateItem = updateItem; + + Heap.nlargest = nlargest; + + Heap.nsmallest = nsmallest; + + function Heap(cmp) { + this.cmp = cmp != null ? cmp : defaultCmp; + this.nodes = []; + } + + Heap.prototype.push = function(x) { + return heappush(this.nodes, x, this.cmp); + }; + + Heap.prototype.pop = function() { + return heappop(this.nodes, this.cmp); + }; + + Heap.prototype.peek = function() { + return this.nodes[0]; + }; + + Heap.prototype.contains = function(x) { + return this.nodes.indexOf(x) !== -1; + }; + + Heap.prototype.replace = function(x) { + return heapreplace(this.nodes, x, this.cmp); + }; + + Heap.prototype.pushpop = function(x) { + return heappushpop(this.nodes, x, this.cmp); + }; + + Heap.prototype.heapify = function() { + return heapify(this.nodes, this.cmp); + }; + + Heap.prototype.updateItem = function(x) { + return updateItem(this.nodes, x, this.cmp); + }; + + Heap.prototype.clear = function() { + return this.nodes = []; + }; + + Heap.prototype.empty = function() { + return this.nodes.length === 0; + }; + + Heap.prototype.size = function() { + return this.nodes.length; + }; + + Heap.prototype.clone = function() { + var heap; + heap = new Heap(); + heap.nodes = this.nodes.slice(0); + return heap; + }; + + Heap.prototype.toArray = function() { + return this.nodes.slice(0); + }; + + Heap.prototype.insert = Heap.prototype.push; + + Heap.prototype.top = Heap.prototype.peek; + + Heap.prototype.front = Heap.prototype.peek; + + Heap.prototype.has = Heap.prototype.contains; + + Heap.prototype.copy = Heap.prototype.clone; + + return Heap; + + })(); + + (function(root, factory) { + { + return module.exports = factory(); + } + })(this, function() { + return Heap; + }); + +}).call(commonjsGlobal); +}); + +var heap = heap$1; + +var dijkstraDefaults = defaults$g({ + root: null, + weight: function weight(edge) { + return 1; + }, + directed: false +}); +var elesfn$u = { + dijkstra: function dijkstra(options) { + if (!plainObject(options)) { + var args = arguments; + options = { + root: args[0], + weight: args[1], + directed: args[2] + }; + } + var _dijkstraDefaults = dijkstraDefaults(options), + root = _dijkstraDefaults.root, + weight = _dijkstraDefaults.weight, + directed = _dijkstraDefaults.directed; + var eles = this; + var weightFn = weight; + var source = string(root) ? this.filter(root)[0] : root[0]; + var dist = {}; + var prev = {}; + var knownDist = {}; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + edges.unmergeBy(function (ele) { + return ele.isLoop(); + }); + var getDist = function getDist(node) { + return dist[node.id()]; + }; + var setDist = function setDist(node, d) { + dist[node.id()] = d; + Q.updateItem(node); + }; + var Q = new heap(function (a, b) { + return getDist(a) - getDist(b); + }); + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + dist[node.id()] = node.same(source) ? 0 : Infinity; + Q.push(node); + } + var distBetween = function distBetween(u, v) { + var uvs = (directed ? u.edgesTo(v) : u.edgesWith(v)).intersect(edges); + var smallestDistance = Infinity; + var smallestEdge; + for (var _i = 0; _i < uvs.length; _i++) { + var edge = uvs[_i]; + var _weight = weightFn(edge); + if (_weight < smallestDistance || !smallestEdge) { + smallestDistance = _weight; + smallestEdge = edge; + } + } + return { + edge: smallestEdge, + dist: smallestDistance + }; + }; + while (Q.size() > 0) { + var u = Q.pop(); + var smalletsDist = getDist(u); + var uid = u.id(); + knownDist[uid] = smalletsDist; + if (smalletsDist === Infinity) { + continue; + } + var neighbors = u.neighborhood().intersect(nodes); + for (var _i2 = 0; _i2 < neighbors.length; _i2++) { + var v = neighbors[_i2]; + var vid = v.id(); + var vDist = distBetween(u, v); + var alt = smalletsDist + vDist.dist; + if (alt < getDist(v)) { + setDist(v, alt); + prev[vid] = { + node: u, + edge: vDist.edge + }; + } + } // for + } // while + + return { + distanceTo: function distanceTo(node) { + var target = string(node) ? nodes.filter(node)[0] : node[0]; + return knownDist[target.id()]; + }, + pathTo: function pathTo(node) { + var target = string(node) ? nodes.filter(node)[0] : node[0]; + var S = []; + var u = target; + var uid = u.id(); + if (target.length > 0) { + S.unshift(target); + while (prev[uid]) { + var p = prev[uid]; + S.unshift(p.edge); + S.unshift(p.node); + u = p.node; + uid = u.id(); + } + } + return eles.spawn(S); + } + }; + } +}; + +var elesfn$t = { + // kruskal's algorithm (finds min spanning tree, assuming undirected graph) + // implemented from pseudocode from wikipedia + kruskal: function kruskal(weightFn) { + weightFn = weightFn || function (edge) { + return 1; + }; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var numNodes = nodes.length; + var forest = new Array(numNodes); + var A = nodes; // assumes byGroup() creates new collections that can be safely mutated + + var findSetIndex = function findSetIndex(ele) { + for (var i = 0; i < forest.length; i++) { + var eles = forest[i]; + if (eles.has(ele)) { + return i; + } + } + }; + + // start with one forest per node + for (var i = 0; i < numNodes; i++) { + forest[i] = this.spawn(nodes[i]); + } + var S = edges.sort(function (a, b) { + return weightFn(a) - weightFn(b); + }); + for (var _i = 0; _i < S.length; _i++) { + var edge = S[_i]; + var u = edge.source()[0]; + var v = edge.target()[0]; + var setUIndex = findSetIndex(u); + var setVIndex = findSetIndex(v); + var setU = forest[setUIndex]; + var setV = forest[setVIndex]; + if (setUIndex !== setVIndex) { + A.merge(edge); + + // combine forests for u and v + setU.merge(setV); + forest.splice(setVIndex, 1); + } + } + return A; + } +}; + +var aStarDefaults = defaults$g({ + root: null, + goal: null, + weight: function weight(edge) { + return 1; + }, + heuristic: function heuristic(edge) { + return 0; + }, + directed: false +}); +var elesfn$s = { + // Implemented from pseudocode from wikipedia + aStar: function aStar(options) { + var cy = this.cy(); + var _aStarDefaults = aStarDefaults(options), + root = _aStarDefaults.root, + goal = _aStarDefaults.goal, + heuristic = _aStarDefaults.heuristic, + directed = _aStarDefaults.directed, + weight = _aStarDefaults.weight; + root = cy.collection(root)[0]; + goal = cy.collection(goal)[0]; + var sid = root.id(); + var tid = goal.id(); + var gScore = {}; + var fScore = {}; + var closedSetIds = {}; + var openSet = new heap(function (a, b) { + return fScore[a.id()] - fScore[b.id()]; + }); + var openSetIds = new Set$1(); + var cameFrom = {}; + var cameFromEdge = {}; + var addToOpenSet = function addToOpenSet(ele, id) { + openSet.push(ele); + openSetIds.add(id); + }; + var cMin, cMinId; + var popFromOpenSet = function popFromOpenSet() { + cMin = openSet.pop(); + cMinId = cMin.id(); + openSetIds["delete"](cMinId); + }; + var isInOpenSet = function isInOpenSet(id) { + return openSetIds.has(id); + }; + addToOpenSet(root, sid); + gScore[sid] = 0; + fScore[sid] = heuristic(root); + + // Counter + var steps = 0; + + // Main loop + while (openSet.size() > 0) { + popFromOpenSet(); + steps++; + + // If we've found our goal, then we are done + if (cMinId === tid) { + var path = []; + var pathNode = goal; + var pathNodeId = tid; + var pathEdge = cameFromEdge[pathNodeId]; + for (;;) { + path.unshift(pathNode); + if (pathEdge != null) { + path.unshift(pathEdge); + } + pathNode = cameFrom[pathNodeId]; + if (pathNode == null) { + break; + } + pathNodeId = pathNode.id(); + pathEdge = cameFromEdge[pathNodeId]; + } + return { + found: true, + distance: gScore[cMinId], + path: this.spawn(path), + steps: steps + }; + } + + // Add cMin to processed nodes + closedSetIds[cMinId] = true; + + // Update scores for neighbors of cMin + // Take into account if graph is directed or not + var vwEdges = cMin._private.edges; + for (var i = 0; i < vwEdges.length; i++) { + var e = vwEdges[i]; + + // edge must be in set of calling eles + if (!this.hasElementWithId(e.id())) { + continue; + } + + // cMin must be the source of edge if directed + if (directed && e.data('source') !== cMinId) { + continue; + } + var wSrc = e.source(); + var wTgt = e.target(); + var w = wSrc.id() !== cMinId ? wSrc : wTgt; + var wid = w.id(); + + // node must be in set of calling eles + if (!this.hasElementWithId(wid)) { + continue; + } + + // if node is in closedSet, ignore it + if (closedSetIds[wid]) { + continue; + } + + // New tentative score for node w + var tempScore = gScore[cMinId] + weight(e); + + // Update gScore for node w if: + // w not present in openSet + // OR + // tentative gScore is less than previous value + + // w not in openSet + if (!isInOpenSet(wid)) { + gScore[wid] = tempScore; + fScore[wid] = tempScore + heuristic(w); + addToOpenSet(w, wid); + cameFrom[wid] = cMin; + cameFromEdge[wid] = e; + continue; + } + + // w already in openSet, but with greater gScore + if (tempScore < gScore[wid]) { + gScore[wid] = tempScore; + fScore[wid] = tempScore + heuristic(w); + cameFrom[wid] = cMin; + cameFromEdge[wid] = e; + } + } // End of neighbors update + } // End of main loop + + // If we've reached here, then we've not reached our goal + return { + found: false, + distance: undefined, + path: undefined, + steps: steps + }; + } +}; // elesfn + +var floydWarshallDefaults = defaults$g({ + weight: function weight(edge) { + return 1; + }, + directed: false +}); +var elesfn$r = { + // Implemented from pseudocode from wikipedia + floydWarshall: function floydWarshall(options) { + var cy = this.cy(); + var _floydWarshallDefault = floydWarshallDefaults(options), + weight = _floydWarshallDefault.weight, + directed = _floydWarshallDefault.directed; + var weightFn = weight; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var N = nodes.length; + var Nsq = N * N; + var indexOf = function indexOf(node) { + return nodes.indexOf(node); + }; + var atIndex = function atIndex(i) { + return nodes[i]; + }; + + // Initialize distance matrix + var dist = new Array(Nsq); + for (var n = 0; n < Nsq; n++) { + var j = n % N; + var i = (n - j) / N; + if (i === j) { + dist[n] = 0; + } else { + dist[n] = Infinity; + } + } + + // Initialize matrix used for path reconstruction + // Initialize distance matrix + var next = new Array(Nsq); + var edgeNext = new Array(Nsq); + + // Process edges + for (var _i = 0; _i < edges.length; _i++) { + var edge = edges[_i]; + var src = edge.source()[0]; + var tgt = edge.target()[0]; + if (src === tgt) { + continue; + } // exclude loops + + var s = indexOf(src); + var t = indexOf(tgt); + var st = s * N + t; // source to target index + var _weight = weightFn(edge); + + // Check if already process another edge between same 2 nodes + if (dist[st] > _weight) { + dist[st] = _weight; + next[st] = t; + edgeNext[st] = edge; + } + + // If undirected graph, process 'reversed' edge + if (!directed) { + var ts = t * N + s; // target to source index + + if (!directed && dist[ts] > _weight) { + dist[ts] = _weight; + next[ts] = s; + edgeNext[ts] = edge; + } + } + } + + // Main loop + for (var k = 0; k < N; k++) { + for (var _i2 = 0; _i2 < N; _i2++) { + var ik = _i2 * N + k; + for (var _j = 0; _j < N; _j++) { + var ij = _i2 * N + _j; + var kj = k * N + _j; + if (dist[ik] + dist[kj] < dist[ij]) { + dist[ij] = dist[ik] + dist[kj]; + next[ij] = next[ik]; + } + } + } + } + var getArgEle = function getArgEle(ele) { + return (string(ele) ? cy.filter(ele) : ele)[0]; + }; + var indexOfArgEle = function indexOfArgEle(ele) { + return indexOf(getArgEle(ele)); + }; + var res = { + distance: function distance(from, to) { + var i = indexOfArgEle(from); + var j = indexOfArgEle(to); + return dist[i * N + j]; + }, + path: function path(from, to) { + var i = indexOfArgEle(from); + var j = indexOfArgEle(to); + var fromNode = atIndex(i); + if (i === j) { + return fromNode.collection(); + } + if (next[i * N + j] == null) { + return cy.collection(); + } + var path = cy.collection(); + var prev = i; + var edge; + path.merge(fromNode); + while (i !== j) { + prev = i; + i = next[i * N + j]; + edge = edgeNext[prev * N + i]; + path.merge(edge); + path.merge(atIndex(i)); + } + return path; + } + }; + return res; + } // floydWarshall +}; // elesfn + +var bellmanFordDefaults = defaults$g({ + weight: function weight(edge) { + return 1; + }, + directed: false, + root: null +}); +var elesfn$q = { + // Implemented from pseudocode from wikipedia + bellmanFord: function bellmanFord(options) { + var _this = this; + var _bellmanFordDefaults = bellmanFordDefaults(options), + weight = _bellmanFordDefaults.weight, + directed = _bellmanFordDefaults.directed, + root = _bellmanFordDefaults.root; + var weightFn = weight; + var eles = this; + var cy = this.cy(); + var _this$byGroup = this.byGroup(), + edges = _this$byGroup.edges, + nodes = _this$byGroup.nodes; + var numNodes = nodes.length; + var infoMap = new Map$2(); + var hasNegativeWeightCycle = false; + var negativeWeightCycles = []; + root = cy.collection(root)[0]; // in case selector passed + + edges.unmergeBy(function (edge) { + return edge.isLoop(); + }); + var numEdges = edges.length; + var getInfo = function getInfo(node) { + var obj = infoMap.get(node.id()); + if (!obj) { + obj = {}; + infoMap.set(node.id(), obj); + } + return obj; + }; + var getNodeFromTo = function getNodeFromTo(to) { + return (string(to) ? cy.$(to) : to)[0]; + }; + var distanceTo = function distanceTo(to) { + return getInfo(getNodeFromTo(to)).dist; + }; + var pathTo = function pathTo(to) { + var thisStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : root; + var end = getNodeFromTo(to); + var path = []; + var node = end; + for (;;) { + if (node == null) { + return _this.spawn(); + } + var _getInfo = getInfo(node), + edge = _getInfo.edge, + pred = _getInfo.pred; + path.unshift(node[0]); + if (node.same(thisStart) && path.length > 0) { + break; + } + if (edge != null) { + path.unshift(edge); + } + node = pred; + } + return eles.spawn(path); + }; + + // Initializations { dist, pred, edge } + for (var i = 0; i < numNodes; i++) { + var node = nodes[i]; + var info = getInfo(node); + if (node.same(root)) { + info.dist = 0; + } else { + info.dist = Infinity; + } + info.pred = null; + info.edge = null; + } + + // Edges relaxation + var replacedEdge = false; + var checkForEdgeReplacement = function checkForEdgeReplacement(node1, node2, edge, info1, info2, weight) { + var dist = info1.dist + weight; + if (dist < info2.dist && !edge.same(info1.edge)) { + info2.dist = dist; + info2.pred = node1; + info2.edge = edge; + replacedEdge = true; + } + }; + for (var _i = 1; _i < numNodes; _i++) { + replacedEdge = false; + for (var e = 0; e < numEdges; e++) { + var edge = edges[e]; + var src = edge.source(); + var tgt = edge.target(); + var _weight = weightFn(edge); + var srcInfo = getInfo(src); + var tgtInfo = getInfo(tgt); + checkForEdgeReplacement(src, tgt, edge, srcInfo, tgtInfo, _weight); + + // If undirected graph, we need to take into account the 'reverse' edge + if (!directed) { + checkForEdgeReplacement(tgt, src, edge, tgtInfo, srcInfo, _weight); + } + } + if (!replacedEdge) { + break; + } + } + if (replacedEdge) { + // Check for negative weight cycles + var negativeWeightCycleIds = []; + for (var _e = 0; _e < numEdges; _e++) { + var _edge = edges[_e]; + var _src = _edge.source(); + var _tgt = _edge.target(); + var _weight2 = weightFn(_edge); + var srcDist = getInfo(_src).dist; + var tgtDist = getInfo(_tgt).dist; + if (srcDist + _weight2 < tgtDist || !directed && tgtDist + _weight2 < srcDist) { + if (!hasNegativeWeightCycle) { + warn('Graph contains a negative weight cycle for Bellman-Ford'); + hasNegativeWeightCycle = true; + } + if (options.findNegativeWeightCycles !== false) { + var negativeNodes = []; + if (srcDist + _weight2 < tgtDist) { + negativeNodes.push(_src); + } + if (!directed && tgtDist + _weight2 < srcDist) { + negativeNodes.push(_tgt); + } + var numNegativeNodes = negativeNodes.length; + for (var n = 0; n < numNegativeNodes; n++) { + var start = negativeNodes[n]; + var cycle = [start]; + cycle.push(getInfo(start).edge); + var _node = getInfo(start).pred; + while (cycle.indexOf(_node) === -1) { + cycle.push(_node); + cycle.push(getInfo(_node).edge); + _node = getInfo(_node).pred; + } + cycle = cycle.slice(cycle.indexOf(_node)); + var smallestId = cycle[0].id(); + var smallestIndex = 0; + for (var c = 2; c < cycle.length; c += 2) { + if (cycle[c].id() < smallestId) { + smallestId = cycle[c].id(); + smallestIndex = c; + } + } + cycle = cycle.slice(smallestIndex).concat(cycle.slice(0, smallestIndex)); + cycle.push(cycle[0]); + var cycleId = cycle.map(function (el) { + return el.id(); + }).join(","); + if (negativeWeightCycleIds.indexOf(cycleId) === -1) { + negativeWeightCycles.push(eles.spawn(cycle)); + negativeWeightCycleIds.push(cycleId); + } + } + } else { + break; + } + } + } + } + return { + distanceTo: distanceTo, + pathTo: pathTo, + hasNegativeWeightCycle: hasNegativeWeightCycle, + negativeWeightCycles: negativeWeightCycles + }; + } // bellmanFord +}; // elesfn + +var sqrt2 = Math.sqrt(2); + +// Function which colapses 2 (meta) nodes into one +// Updates the remaining edge lists +// Receives as a paramater the edge which causes the collapse +var collapse = function collapse(edgeIndex, nodeMap, remainingEdges) { + if (remainingEdges.length === 0) { + error("Karger-Stein must be run on a connected (sub)graph"); + } + var edgeInfo = remainingEdges[edgeIndex]; + var sourceIn = edgeInfo[1]; + var targetIn = edgeInfo[2]; + var partition1 = nodeMap[sourceIn]; + var partition2 = nodeMap[targetIn]; + var newEdges = remainingEdges; // re-use array + + // Delete all edges between partition1 and partition2 + for (var i = newEdges.length - 1; i >= 0; i--) { + var edge = newEdges[i]; + var src = edge[1]; + var tgt = edge[2]; + if (nodeMap[src] === partition1 && nodeMap[tgt] === partition2 || nodeMap[src] === partition2 && nodeMap[tgt] === partition1) { + newEdges.splice(i, 1); + } + } + + // All edges pointing to partition2 should now point to partition1 + for (var _i = 0; _i < newEdges.length; _i++) { + var _edge = newEdges[_i]; + if (_edge[1] === partition2) { + // Check source + newEdges[_i] = _edge.slice(); // copy + newEdges[_i][1] = partition1; + } else if (_edge[2] === partition2) { + // Check target + newEdges[_i] = _edge.slice(); // copy + newEdges[_i][2] = partition1; + } + } + + // Move all nodes from partition2 to partition1 + for (var _i2 = 0; _i2 < nodeMap.length; _i2++) { + if (nodeMap[_i2] === partition2) { + nodeMap[_i2] = partition1; + } + } + return newEdges; +}; + +// Contracts a graph until we reach a certain number of meta nodes +var contractUntil = function contractUntil(metaNodeMap, remainingEdges, size, sizeLimit) { + while (size > sizeLimit) { + // Choose an edge randomly + var edgeIndex = Math.floor(Math.random() * remainingEdges.length); + + // Collapse graph based on edge + remainingEdges = collapse(edgeIndex, metaNodeMap, remainingEdges); + size--; + } + return remainingEdges; +}; +var elesfn$p = { + // Computes the minimum cut of an undirected graph + // Returns the correct answer with high probability + kargerStein: function kargerStein() { + var _this = this; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + edges.unmergeBy(function (edge) { + return edge.isLoop(); + }); + var numNodes = nodes.length; + var numEdges = edges.length; + var numIter = Math.ceil(Math.pow(Math.log(numNodes) / Math.LN2, 2)); + var stopSize = Math.floor(numNodes / sqrt2); + if (numNodes < 2) { + error('At least 2 nodes are required for Karger-Stein algorithm'); + return undefined; + } + + // Now store edge destination as indexes + // Format for each edge (edge index, source node index, target node index) + var edgeIndexes = []; + for (var i = 0; i < numEdges; i++) { + var e = edges[i]; + edgeIndexes.push([i, nodes.indexOf(e.source()), nodes.indexOf(e.target())]); + } + + // We will store the best cut found here + var minCutSize = Infinity; + var minCutEdgeIndexes = []; + var minCutNodeMap = new Array(numNodes); + + // Initial meta node partition + var metaNodeMap = new Array(numNodes); + var metaNodeMap2 = new Array(numNodes); + var copyNodesMap = function copyNodesMap(from, to) { + for (var _i3 = 0; _i3 < numNodes; _i3++) { + to[_i3] = from[_i3]; + } + }; + + // Main loop + for (var iter = 0; iter <= numIter; iter++) { + // Reset meta node partition + for (var _i4 = 0; _i4 < numNodes; _i4++) { + metaNodeMap[_i4] = _i4; + } + + // Contract until stop point (stopSize nodes) + var edgesState = contractUntil(metaNodeMap, edgeIndexes.slice(), numNodes, stopSize); + var edgesState2 = edgesState.slice(); // copy + + // Create a copy of the colapsed nodes state + copyNodesMap(metaNodeMap, metaNodeMap2); + + // Run 2 iterations starting in the stop state + var res1 = contractUntil(metaNodeMap, edgesState, stopSize, 2); + var res2 = contractUntil(metaNodeMap2, edgesState2, stopSize, 2); + + // Is any of the 2 results the best cut so far? + if (res1.length <= res2.length && res1.length < minCutSize) { + minCutSize = res1.length; + minCutEdgeIndexes = res1; + copyNodesMap(metaNodeMap, minCutNodeMap); + } else if (res2.length <= res1.length && res2.length < minCutSize) { + minCutSize = res2.length; + minCutEdgeIndexes = res2; + copyNodesMap(metaNodeMap2, minCutNodeMap); + } + } // end of main loop + + // Construct result + var cut = this.spawn(minCutEdgeIndexes.map(function (e) { + return edges[e[0]]; + })); + var partition1 = this.spawn(); + var partition2 = this.spawn(); + + // traverse metaNodeMap for best cut + var witnessNodePartition = minCutNodeMap[0]; + for (var _i5 = 0; _i5 < minCutNodeMap.length; _i5++) { + var partitionId = minCutNodeMap[_i5]; + var node = nodes[_i5]; + if (partitionId === witnessNodePartition) { + partition1.merge(node); + } else { + partition2.merge(node); + } + } + + // construct components corresponding to each disjoint subset of nodes + var constructComponent = function constructComponent(subset) { + var component = _this.spawn(); + subset.forEach(function (node) { + component.merge(node); + node.connectedEdges().forEach(function (edge) { + // ensure edge is within calling collection and edge is not in cut + if (_this.contains(edge) && !cut.contains(edge)) { + component.merge(edge); + } + }); + }); + return component; + }; + var components = [constructComponent(partition1), constructComponent(partition2)]; + var ret = { + cut: cut, + components: components, + // n.b. partitions are included to be compatible with the old api spec + // (could be removed in a future major version) + partition1: partition1, + partition2: partition2 + }; + return ret; + } +}; // elesfn + +var copyPosition = function copyPosition(p) { + return { + x: p.x, + y: p.y + }; +}; +var modelToRenderedPosition = function modelToRenderedPosition(p, zoom, pan) { + return { + x: p.x * zoom + pan.x, + y: p.y * zoom + pan.y + }; +}; +var renderedToModelPosition = function renderedToModelPosition(p, zoom, pan) { + return { + x: (p.x - pan.x) / zoom, + y: (p.y - pan.y) / zoom + }; +}; +var array2point = function array2point(arr) { + return { + x: arr[0], + y: arr[1] + }; +}; +var min = function min(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var min = Infinity; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + min = Math.min(val, min); + } + } + return min; +}; +var max = function max(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var max = -Infinity; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + max = Math.max(val, max); + } + } + return max; +}; +var mean = function mean(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var total = 0; + var n = 0; + for (var i = begin; i < end; i++) { + var val = arr[i]; + if (isFinite(val)) { + total += val; + n++; + } + } + return total / n; +}; +var median = function median(arr) { + var begin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : arr.length; + var copy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var sort = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var includeHoles = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + if (copy) { + arr = arr.slice(begin, end); + } else { + if (end < arr.length) { + arr.splice(end, arr.length - end); + } + if (begin > 0) { + arr.splice(0, begin); + } + } + + // all non finite (e.g. Infinity, NaN) elements must be -Infinity so they go to the start + var off = 0; // offset from non-finite values + for (var i = arr.length - 1; i >= 0; i--) { + var v = arr[i]; + if (includeHoles) { + if (!isFinite(v)) { + arr[i] = -Infinity; + off++; + } + } else { + // just remove it if we don't want to consider holes + arr.splice(i, 1); + } + } + if (sort) { + arr.sort(function (a, b) { + return a - b; + }); // requires copy = true if you don't want to change the orig + } + + var len = arr.length; + var mid = Math.floor(len / 2); + if (len % 2 !== 0) { + return arr[mid + 1 + off]; + } else { + return (arr[mid - 1 + off] + arr[mid + off]) / 2; + } +}; +var deg2rad = function deg2rad(deg) { + return Math.PI * deg / 180; +}; +var getAngleFromDisp = function getAngleFromDisp(dispX, dispY) { + return Math.atan2(dispY, dispX) - Math.PI / 2; +}; +var log2 = Math.log2 || function (n) { + return Math.log(n) / Math.log(2); +}; +var signum = function signum(x) { + if (x > 0) { + return 1; + } else if (x < 0) { + return -1; + } else { + return 0; + } +}; +var dist = function dist(p1, p2) { + return Math.sqrt(sqdist(p1, p2)); +}; +var sqdist = function sqdist(p1, p2) { + var dx = p2.x - p1.x; + var dy = p2.y - p1.y; + return dx * dx + dy * dy; +}; +var inPlaceSumNormalize = function inPlaceSumNormalize(v) { + var length = v.length; + + // First, get sum of all elements + var total = 0; + for (var i = 0; i < length; i++) { + total += v[i]; + } + + // Now, divide each by the sum of all elements + for (var _i = 0; _i < length; _i++) { + v[_i] = v[_i] / total; + } + return v; +}; + +// from http://en.wikipedia.org/wiki/Bézier_curve#Quadratic_curves +var qbezierAt = function qbezierAt(p0, p1, p2, t) { + return (1 - t) * (1 - t) * p0 + 2 * (1 - t) * t * p1 + t * t * p2; +}; +var qbezierPtAt = function qbezierPtAt(p0, p1, p2, t) { + return { + x: qbezierAt(p0.x, p1.x, p2.x, t), + y: qbezierAt(p0.y, p1.y, p2.y, t) + }; +}; +var lineAt = function lineAt(p0, p1, t, d) { + var vec = { + x: p1.x - p0.x, + y: p1.y - p0.y + }; + var vecDist = dist(p0, p1); + var normVec = { + x: vec.x / vecDist, + y: vec.y / vecDist + }; + t = t == null ? 0 : t; + d = d != null ? d : t * vecDist; + return { + x: p0.x + normVec.x * d, + y: p0.y + normVec.y * d + }; +}; +var bound = function bound(min, val, max) { + return Math.max(min, Math.min(max, val)); +}; + +// makes a full bb (x1, y1, x2, y2, w, h) from implicit params +var makeBoundingBox = function makeBoundingBox(bb) { + if (bb == null) { + return { + x1: Infinity, + y1: Infinity, + x2: -Infinity, + y2: -Infinity, + w: 0, + h: 0 + }; + } else if (bb.x1 != null && bb.y1 != null) { + if (bb.x2 != null && bb.y2 != null && bb.x2 >= bb.x1 && bb.y2 >= bb.y1) { + return { + x1: bb.x1, + y1: bb.y1, + x2: bb.x2, + y2: bb.y2, + w: bb.x2 - bb.x1, + h: bb.y2 - bb.y1 + }; + } else if (bb.w != null && bb.h != null && bb.w >= 0 && bb.h >= 0) { + return { + x1: bb.x1, + y1: bb.y1, + x2: bb.x1 + bb.w, + y2: bb.y1 + bb.h, + w: bb.w, + h: bb.h + }; + } + } +}; +var copyBoundingBox = function copyBoundingBox(bb) { + return { + x1: bb.x1, + x2: bb.x2, + w: bb.w, + y1: bb.y1, + y2: bb.y2, + h: bb.h + }; +}; +var clearBoundingBox = function clearBoundingBox(bb) { + bb.x1 = Infinity; + bb.y1 = Infinity; + bb.x2 = -Infinity; + bb.y2 = -Infinity; + bb.w = 0; + bb.h = 0; +}; +var shiftBoundingBox = function shiftBoundingBox(bb, dx, dy) { + return { + x1: bb.x1 + dx, + x2: bb.x2 + dx, + y1: bb.y1 + dy, + y2: bb.y2 + dy, + w: bb.w, + h: bb.h + }; +}; +var updateBoundingBox = function updateBoundingBox(bb1, bb2) { + // update bb1 with bb2 bounds + + bb1.x1 = Math.min(bb1.x1, bb2.x1); + bb1.x2 = Math.max(bb1.x2, bb2.x2); + bb1.w = bb1.x2 - bb1.x1; + bb1.y1 = Math.min(bb1.y1, bb2.y1); + bb1.y2 = Math.max(bb1.y2, bb2.y2); + bb1.h = bb1.y2 - bb1.y1; +}; +var expandBoundingBoxByPoint = function expandBoundingBoxByPoint(bb, x, y) { + bb.x1 = Math.min(bb.x1, x); + bb.x2 = Math.max(bb.x2, x); + bb.w = bb.x2 - bb.x1; + bb.y1 = Math.min(bb.y1, y); + bb.y2 = Math.max(bb.y2, y); + bb.h = bb.y2 - bb.y1; +}; +var expandBoundingBox = function expandBoundingBox(bb) { + var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + bb.x1 -= padding; + bb.x2 += padding; + bb.y1 -= padding; + bb.y2 += padding; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + return bb; +}; +var expandBoundingBoxSides = function expandBoundingBoxSides(bb) { + var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0]; + var top, right, bottom, left; + if (padding.length === 1) { + top = right = bottom = left = padding[0]; + } else if (padding.length === 2) { + top = bottom = padding[0]; + left = right = padding[1]; + } else if (padding.length === 4) { + var _padding = _slicedToArray(padding, 4); + top = _padding[0]; + right = _padding[1]; + bottom = _padding[2]; + left = _padding[3]; + } + bb.x1 -= left; + bb.x2 += right; + bb.y1 -= top; + bb.y2 += bottom; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + return bb; +}; + +// assign the values of bb2 into bb1 +var assignBoundingBox = function assignBoundingBox(bb1, bb2) { + bb1.x1 = bb2.x1; + bb1.y1 = bb2.y1; + bb1.x2 = bb2.x2; + bb1.y2 = bb2.y2; + bb1.w = bb1.x2 - bb1.x1; + bb1.h = bb1.y2 - bb1.y1; +}; +var boundingBoxesIntersect = function boundingBoxesIntersect(bb1, bb2) { + // case: one bb to right of other + if (bb1.x1 > bb2.x2) { + return false; + } + if (bb2.x1 > bb1.x2) { + return false; + } + + // case: one bb to left of other + if (bb1.x2 < bb2.x1) { + return false; + } + if (bb2.x2 < bb1.x1) { + return false; + } + + // case: one bb above other + if (bb1.y2 < bb2.y1) { + return false; + } + if (bb2.y2 < bb1.y1) { + return false; + } + + // case: one bb below other + if (bb1.y1 > bb2.y2) { + return false; + } + if (bb2.y1 > bb1.y2) { + return false; + } + + // otherwise, must have some overlap + return true; +}; +var inBoundingBox = function inBoundingBox(bb, x, y) { + return bb.x1 <= x && x <= bb.x2 && bb.y1 <= y && y <= bb.y2; +}; +var pointInBoundingBox = function pointInBoundingBox(bb, pt) { + return inBoundingBox(bb, pt.x, pt.y); +}; +var boundingBoxInBoundingBox = function boundingBoxInBoundingBox(bb1, bb2) { + return inBoundingBox(bb1, bb2.x1, bb2.y1) && inBoundingBox(bb1, bb2.x2, bb2.y2); +}; +var roundRectangleIntersectLine = function roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding) { + var radius = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'auto'; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : radius; + var halfWidth = width / 2; + var halfHeight = height / 2; + cornerRadius = Math.min(cornerRadius, halfWidth, halfHeight); + var doWidth = cornerRadius !== halfWidth, + doHeight = cornerRadius !== halfHeight; + + // Check intersections with straight line segments + var straightLineIntersections; + + // Top segment, left to right + if (doWidth) { + var topStartX = nodeX - halfWidth + cornerRadius - padding; + var topStartY = nodeY - halfHeight - padding; + var topEndX = nodeX + halfWidth - cornerRadius + padding; + var topEndY = topStartY; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Right segment, top to bottom + if (doHeight) { + var rightStartX = nodeX + halfWidth + padding; + var rightStartY = nodeY - halfHeight + cornerRadius - padding; + var rightEndX = rightStartX; + var rightEndY = nodeY + halfHeight - cornerRadius + padding; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, rightStartX, rightStartY, rightEndX, rightEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Bottom segment, left to right + if (doWidth) { + var bottomStartX = nodeX - halfWidth + cornerRadius - padding; + var bottomStartY = nodeY + halfHeight + padding; + var bottomEndX = nodeX + halfWidth - cornerRadius + padding; + var bottomEndY = bottomStartY; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, bottomStartX, bottomStartY, bottomEndX, bottomEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Left segment, top to bottom + if (doHeight) { + var leftStartX = nodeX - halfWidth - padding; + var leftStartY = nodeY - halfHeight + cornerRadius - padding; + var leftEndX = leftStartX; + var leftEndY = nodeY + halfHeight - cornerRadius + padding; + straightLineIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, leftStartX, leftStartY, leftEndX, leftEndY, false); + if (straightLineIntersections.length > 0) { + return straightLineIntersections; + } + } + + // Check intersections with arc segments + var arcIntersections; + + // Top Left + { + var topLeftCenterX = nodeX - halfWidth + cornerRadius; + var topLeftCenterY = nodeY - halfHeight + cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, topLeftCenterX, topLeftCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] <= topLeftCenterX && arcIntersections[1] <= topLeftCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Top Right + { + var topRightCenterX = nodeX + halfWidth - cornerRadius; + var topRightCenterY = nodeY - halfHeight + cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, topRightCenterX, topRightCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] >= topRightCenterX && arcIntersections[1] <= topRightCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Bottom Right + { + var bottomRightCenterX = nodeX + halfWidth - cornerRadius; + var bottomRightCenterY = nodeY + halfHeight - cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, bottomRightCenterX, bottomRightCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] >= bottomRightCenterX && arcIntersections[1] >= bottomRightCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + + // Bottom Left + { + var bottomLeftCenterX = nodeX - halfWidth + cornerRadius; + var bottomLeftCenterY = nodeY + halfHeight - cornerRadius; + arcIntersections = intersectLineCircle(x, y, nodeX, nodeY, bottomLeftCenterX, bottomLeftCenterY, cornerRadius + padding); + + // Ensure the intersection is on the desired quarter of the circle + if (arcIntersections.length > 0 && arcIntersections[0] <= bottomLeftCenterX && arcIntersections[1] >= bottomLeftCenterY) { + return [arcIntersections[0], arcIntersections[1]]; + } + } + return []; // if nothing +}; + +var inLineVicinity = function inLineVicinity(x, y, lx1, ly1, lx2, ly2, tolerance) { + var t = tolerance; + var x1 = Math.min(lx1, lx2); + var x2 = Math.max(lx1, lx2); + var y1 = Math.min(ly1, ly2); + var y2 = Math.max(ly1, ly2); + return x1 - t <= x && x <= x2 + t && y1 - t <= y && y <= y2 + t; +}; +var inBezierVicinity = function inBezierVicinity(x, y, x1, y1, x2, y2, x3, y3, tolerance) { + var bb = { + x1: Math.min(x1, x3, x2) - tolerance, + x2: Math.max(x1, x3, x2) + tolerance, + y1: Math.min(y1, y3, y2) - tolerance, + y2: Math.max(y1, y3, y2) + tolerance + }; + + // if outside the rough bounding box for the bezier, then it can't be a hit + if (x < bb.x1 || x > bb.x2 || y < bb.y1 || y > bb.y2) { + // console.log('bezier out of rough bb') + return false; + } else { + // console.log('do more expensive check'); + return true; + } +}; +var solveQuadratic = function solveQuadratic(a, b, c, val) { + c -= val; + var r = b * b - 4 * a * c; + if (r < 0) { + return []; + } + var sqrtR = Math.sqrt(r); + var denom = 2 * a; + var root1 = (-b + sqrtR) / denom; + var root2 = (-b - sqrtR) / denom; + return [root1, root2]; +}; +var solveCubic = function solveCubic(a, b, c, d, result) { + // Solves a cubic function, returns root in form [r1, i1, r2, i2, r3, i3], where + // r is the real component, i is the imaginary component + + // An implementation of the Cardano method from the year 1545 + // http://en.wikipedia.org/wiki/Cubic_function#The_nature_of_the_roots + + var epsilon = 0.00001; + + // avoid division by zero while keeping the overall expression close in value + if (a === 0) { + a = epsilon; + } + b /= a; + c /= a; + d /= a; + var discriminant, q, r, dum1, s, t, term1, r13; + q = (3.0 * c - b * b) / 9.0; + r = -(27.0 * d) + b * (9.0 * c - 2.0 * (b * b)); + r /= 54.0; + discriminant = q * q * q + r * r; + result[1] = 0; + term1 = b / 3.0; + if (discriminant > 0) { + s = r + Math.sqrt(discriminant); + s = s < 0 ? -Math.pow(-s, 1.0 / 3.0) : Math.pow(s, 1.0 / 3.0); + t = r - Math.sqrt(discriminant); + t = t < 0 ? -Math.pow(-t, 1.0 / 3.0) : Math.pow(t, 1.0 / 3.0); + result[0] = -term1 + s + t; + term1 += (s + t) / 2.0; + result[4] = result[2] = -term1; + term1 = Math.sqrt(3.0) * (-t + s) / 2; + result[3] = term1; + result[5] = -term1; + return; + } + result[5] = result[3] = 0; + if (discriminant === 0) { + r13 = r < 0 ? -Math.pow(-r, 1.0 / 3.0) : Math.pow(r, 1.0 / 3.0); + result[0] = -term1 + 2.0 * r13; + result[4] = result[2] = -(r13 + term1); + return; + } + q = -q; + dum1 = q * q * q; + dum1 = Math.acos(r / Math.sqrt(dum1)); + r13 = 2.0 * Math.sqrt(q); + result[0] = -term1 + r13 * Math.cos(dum1 / 3.0); + result[2] = -term1 + r13 * Math.cos((dum1 + 2.0 * Math.PI) / 3.0); + result[4] = -term1 + r13 * Math.cos((dum1 + 4.0 * Math.PI) / 3.0); + return; +}; +var sqdistToQuadraticBezier = function sqdistToQuadraticBezier(x, y, x1, y1, x2, y2, x3, y3) { + // Find minimum distance by using the minimum of the distance + // function between the given point and the curve + + // This gives the coefficients of the resulting cubic equation + // whose roots tell us where a possible minimum is + // (Coefficients are divided by 4) + + var a = 1.0 * x1 * x1 - 4 * x1 * x2 + 2 * x1 * x3 + 4 * x2 * x2 - 4 * x2 * x3 + x3 * x3 + y1 * y1 - 4 * y1 * y2 + 2 * y1 * y3 + 4 * y2 * y2 - 4 * y2 * y3 + y3 * y3; + var b = 1.0 * 9 * x1 * x2 - 3 * x1 * x1 - 3 * x1 * x3 - 6 * x2 * x2 + 3 * x2 * x3 + 9 * y1 * y2 - 3 * y1 * y1 - 3 * y1 * y3 - 6 * y2 * y2 + 3 * y2 * y3; + var c = 1.0 * 3 * x1 * x1 - 6 * x1 * x2 + x1 * x3 - x1 * x + 2 * x2 * x2 + 2 * x2 * x - x3 * x + 3 * y1 * y1 - 6 * y1 * y2 + y1 * y3 - y1 * y + 2 * y2 * y2 + 2 * y2 * y - y3 * y; + var d = 1.0 * x1 * x2 - x1 * x1 + x1 * x - x2 * x + y1 * y2 - y1 * y1 + y1 * y - y2 * y; + + // debug("coefficients: " + a / a + ", " + b / a + ", " + c / a + ", " + d / a); + + var roots = []; + + // Use the cubic solving algorithm + solveCubic(a, b, c, d, roots); + var zeroThreshold = 0.0000001; + var params = []; + for (var index = 0; index < 6; index += 2) { + if (Math.abs(roots[index + 1]) < zeroThreshold && roots[index] >= 0 && roots[index] <= 1.0) { + params.push(roots[index]); + } + } + params.push(1.0); + params.push(0.0); + var minDistanceSquared = -1; + var curX, curY, distSquared; + for (var i = 0; i < params.length; i++) { + curX = Math.pow(1.0 - params[i], 2.0) * x1 + 2.0 * (1 - params[i]) * params[i] * x2 + params[i] * params[i] * x3; + curY = Math.pow(1 - params[i], 2.0) * y1 + 2 * (1.0 - params[i]) * params[i] * y2 + params[i] * params[i] * y3; + distSquared = Math.pow(curX - x, 2) + Math.pow(curY - y, 2); + // debug('distance for param ' + params[i] + ": " + Math.sqrt(distSquared)); + if (minDistanceSquared >= 0) { + if (distSquared < minDistanceSquared) { + minDistanceSquared = distSquared; + } + } else { + minDistanceSquared = distSquared; + } + } + return minDistanceSquared; +}; +var sqdistToFiniteLine = function sqdistToFiniteLine(x, y, x1, y1, x2, y2) { + var offset = [x - x1, y - y1]; + var line = [x2 - x1, y2 - y1]; + var lineSq = line[0] * line[0] + line[1] * line[1]; + var hypSq = offset[0] * offset[0] + offset[1] * offset[1]; + var dotProduct = offset[0] * line[0] + offset[1] * line[1]; + var adjSq = dotProduct * dotProduct / lineSq; + if (dotProduct < 0) { + return hypSq; + } + if (adjSq > lineSq) { + return (x - x2) * (x - x2) + (y - y2) * (y - y2); + } + return hypSq - adjSq; +}; +var pointInsidePolygonPoints = function pointInsidePolygonPoints(x, y, points) { + var x1, y1, x2, y2; + var y3; + + // Intersect with vertical line through (x, y) + var up = 0; + // let down = 0; + for (var i = 0; i < points.length / 2; i++) { + x1 = points[i * 2]; + y1 = points[i * 2 + 1]; + if (i + 1 < points.length / 2) { + x2 = points[(i + 1) * 2]; + y2 = points[(i + 1) * 2 + 1]; + } else { + x2 = points[(i + 1 - points.length / 2) * 2]; + y2 = points[(i + 1 - points.length / 2) * 2 + 1]; + } + if (x1 == x && x2 == x) ; else if (x1 >= x && x >= x2 || x1 <= x && x <= x2) { + y3 = (x - x1) / (x2 - x1) * (y2 - y1) + y1; + if (y3 > y) { + up++; + } + + // if( y3 < y ){ + // down++; + // } + } else { + continue; + } + } + if (up % 2 === 0) { + return false; + } else { + return true; + } +}; +var pointInsidePolygon = function pointInsidePolygon(x, y, basePoints, centerX, centerY, width, height, direction, padding) { + var transformedPoints = new Array(basePoints.length); + + // Gives negative angle + var angle; + if (direction[0] != null) { + angle = Math.atan(direction[1] / direction[0]); + if (direction[0] < 0) { + angle = angle + Math.PI / 2; + } else { + angle = -angle - Math.PI / 2; + } + } else { + angle = direction; + } + var cos = Math.cos(-angle); + var sin = Math.sin(-angle); + + // console.log("base: " + basePoints); + for (var i = 0; i < transformedPoints.length / 2; i++) { + transformedPoints[i * 2] = width / 2 * (basePoints[i * 2] * cos - basePoints[i * 2 + 1] * sin); + transformedPoints[i * 2 + 1] = height / 2 * (basePoints[i * 2 + 1] * cos + basePoints[i * 2] * sin); + transformedPoints[i * 2] += centerX; + transformedPoints[i * 2 + 1] += centerY; + } + var points; + if (padding > 0) { + var expandedLineSet = expandPolygon(transformedPoints, -padding); + points = joinLines(expandedLineSet); + } else { + points = transformedPoints; + } + return pointInsidePolygonPoints(x, y, points); +}; +var pointInsideRoundPolygon = function pointInsideRoundPolygon(x, y, basePoints, centerX, centerY, width, height, corners) { + var cutPolygonPoints = new Array(basePoints.length * 2); + for (var i = 0; i < corners.length; i++) { + var corner = corners[i]; + cutPolygonPoints[i * 4 + 0] = corner.startX; + cutPolygonPoints[i * 4 + 1] = corner.startY; + cutPolygonPoints[i * 4 + 2] = corner.stopX; + cutPolygonPoints[i * 4 + 3] = corner.stopY; + var squaredDistance = Math.pow(corner.cx - x, 2) + Math.pow(corner.cy - y, 2); + if (squaredDistance <= Math.pow(corner.radius, 2)) { + return true; + } + } + return pointInsidePolygonPoints(x, y, cutPolygonPoints); +}; +var joinLines = function joinLines(lineSet) { + var vertices = new Array(lineSet.length / 2); + var currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY; + var nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY; + for (var i = 0; i < lineSet.length / 4; i++) { + currentLineStartX = lineSet[i * 4]; + currentLineStartY = lineSet[i * 4 + 1]; + currentLineEndX = lineSet[i * 4 + 2]; + currentLineEndY = lineSet[i * 4 + 3]; + if (i < lineSet.length / 4 - 1) { + nextLineStartX = lineSet[(i + 1) * 4]; + nextLineStartY = lineSet[(i + 1) * 4 + 1]; + nextLineEndX = lineSet[(i + 1) * 4 + 2]; + nextLineEndY = lineSet[(i + 1) * 4 + 3]; + } else { + nextLineStartX = lineSet[0]; + nextLineStartY = lineSet[1]; + nextLineEndX = lineSet[2]; + nextLineEndY = lineSet[3]; + } + var intersection = finiteLinesIntersect(currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY, nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY, true); + vertices[i * 2] = intersection[0]; + vertices[i * 2 + 1] = intersection[1]; + } + return vertices; +}; +var expandPolygon = function expandPolygon(points, pad) { + var expandedLineSet = new Array(points.length * 2); + var currentPointX, currentPointY, nextPointX, nextPointY; + for (var i = 0; i < points.length / 2; i++) { + currentPointX = points[i * 2]; + currentPointY = points[i * 2 + 1]; + if (i < points.length / 2 - 1) { + nextPointX = points[(i + 1) * 2]; + nextPointY = points[(i + 1) * 2 + 1]; + } else { + nextPointX = points[0]; + nextPointY = points[1]; + } + + // Current line: [currentPointX, currentPointY] to [nextPointX, nextPointY] + + // Assume CCW polygon winding + + var offsetX = nextPointY - currentPointY; + var offsetY = -(nextPointX - currentPointX); + + // Normalize + var offsetLength = Math.sqrt(offsetX * offsetX + offsetY * offsetY); + var normalizedOffsetX = offsetX / offsetLength; + var normalizedOffsetY = offsetY / offsetLength; + expandedLineSet[i * 4] = currentPointX + normalizedOffsetX * pad; + expandedLineSet[i * 4 + 1] = currentPointY + normalizedOffsetY * pad; + expandedLineSet[i * 4 + 2] = nextPointX + normalizedOffsetX * pad; + expandedLineSet[i * 4 + 3] = nextPointY + normalizedOffsetY * pad; + } + return expandedLineSet; +}; +var intersectLineEllipse = function intersectLineEllipse(x, y, centerX, centerY, ellipseWradius, ellipseHradius) { + var dispX = centerX - x; + var dispY = centerY - y; + dispX /= ellipseWradius; + dispY /= ellipseHradius; + var len = Math.sqrt(dispX * dispX + dispY * dispY); + var newLength = len - 1; + if (newLength < 0) { + return []; + } + var lenProportion = newLength / len; + return [(centerX - x) * lenProportion + x, (centerY - y) * lenProportion + y]; +}; +var checkInEllipse = function checkInEllipse(x, y, width, height, centerX, centerY, padding) { + x -= centerX; + y -= centerY; + x /= width / 2 + padding; + y /= height / 2 + padding; + return x * x + y * y <= 1; +}; + +// Returns intersections of increasing distance from line's start point +var intersectLineCircle = function intersectLineCircle(x1, y1, x2, y2, centerX, centerY, radius) { + // Calculate d, direction vector of line + var d = [x2 - x1, y2 - y1]; // Direction vector of line + var f = [x1 - centerX, y1 - centerY]; + var a = d[0] * d[0] + d[1] * d[1]; + var b = 2 * (f[0] * d[0] + f[1] * d[1]); + var c = f[0] * f[0] + f[1] * f[1] - radius * radius; + var discriminant = b * b - 4 * a * c; + if (discriminant < 0) { + return []; + } + var t1 = (-b + Math.sqrt(discriminant)) / (2 * a); + var t2 = (-b - Math.sqrt(discriminant)) / (2 * a); + var tMin = Math.min(t1, t2); + var tMax = Math.max(t1, t2); + var inRangeParams = []; + if (tMin >= 0 && tMin <= 1) { + inRangeParams.push(tMin); + } + if (tMax >= 0 && tMax <= 1) { + inRangeParams.push(tMax); + } + if (inRangeParams.length === 0) { + return []; + } + var nearIntersectionX = inRangeParams[0] * d[0] + x1; + var nearIntersectionY = inRangeParams[0] * d[1] + y1; + if (inRangeParams.length > 1) { + if (inRangeParams[0] == inRangeParams[1]) { + return [nearIntersectionX, nearIntersectionY]; + } else { + var farIntersectionX = inRangeParams[1] * d[0] + x1; + var farIntersectionY = inRangeParams[1] * d[1] + y1; + return [nearIntersectionX, nearIntersectionY, farIntersectionX, farIntersectionY]; + } + } else { + return [nearIntersectionX, nearIntersectionY]; + } +}; +var midOfThree = function midOfThree(a, b, c) { + if (b <= a && a <= c || c <= a && a <= b) { + return a; + } else if (a <= b && b <= c || c <= b && b <= a) { + return b; + } else { + return c; + } +}; + +// (x1,y1)=>(x2,y2) intersect with (x3,y3)=>(x4,y4) +var finiteLinesIntersect = function finiteLinesIntersect(x1, y1, x2, y2, x3, y3, x4, y4, infiniteLines) { + var dx13 = x1 - x3; + var dx21 = x2 - x1; + var dx43 = x4 - x3; + var dy13 = y1 - y3; + var dy21 = y2 - y1; + var dy43 = y4 - y3; + var ua_t = dx43 * dy13 - dy43 * dx13; + var ub_t = dx21 * dy13 - dy21 * dx13; + var u_b = dy43 * dx21 - dx43 * dy21; + if (u_b !== 0) { + var ua = ua_t / u_b; + var ub = ub_t / u_b; + var flptThreshold = 0.001; + var _min = 0 - flptThreshold; + var _max = 1 + flptThreshold; + if (_min <= ua && ua <= _max && _min <= ub && ub <= _max) { + return [x1 + ua * dx21, y1 + ua * dy21]; + } else { + if (!infiniteLines) { + return []; + } else { + return [x1 + ua * dx21, y1 + ua * dy21]; + } + } + } else { + if (ua_t === 0 || ub_t === 0) { + // Parallel, coincident lines. Check if overlap + + // Check endpoint of second line + if (midOfThree(x1, x2, x4) === x4) { + return [x4, y4]; + } + + // Check start point of second line + if (midOfThree(x1, x2, x3) === x3) { + return [x3, y3]; + } + + // Endpoint of first line + if (midOfThree(x3, x4, x2) === x2) { + return [x2, y2]; + } + return []; + } else { + // Parallel, non-coincident + return []; + } + } +}; + +// math.polygonIntersectLine( x, y, basePoints, centerX, centerY, width, height, padding ) +// intersect a node polygon (pts transformed) +// +// math.polygonIntersectLine( x, y, basePoints, centerX, centerY ) +// intersect the points (no transform) +var polygonIntersectLine = function polygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding) { + var intersections = []; + var intersection; + var transformedPoints = new Array(basePoints.length); + var doTransform = true; + if (width == null) { + doTransform = false; + } + var points; + if (doTransform) { + for (var i = 0; i < transformedPoints.length / 2; i++) { + transformedPoints[i * 2] = basePoints[i * 2] * width + centerX; + transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY; + } + if (padding > 0) { + var expandedLineSet = expandPolygon(transformedPoints, -padding); + points = joinLines(expandedLineSet); + } else { + points = transformedPoints; + } + } else { + points = basePoints; + } + var currentX, currentY, nextX, nextY; + for (var _i2 = 0; _i2 < points.length / 2; _i2++) { + currentX = points[_i2 * 2]; + currentY = points[_i2 * 2 + 1]; + if (_i2 < points.length / 2 - 1) { + nextX = points[(_i2 + 1) * 2]; + nextY = points[(_i2 + 1) * 2 + 1]; + } else { + nextX = points[0]; + nextY = points[1]; + } + intersection = finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + } + return intersections; +}; +var roundPolygonIntersectLine = function roundPolygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding, corners) { + var intersections = []; + var intersection; + var lines = new Array(basePoints.length * 2); + corners.forEach(function (corner, i) { + if (i === 0) { + lines[lines.length - 2] = corner.startX; + lines[lines.length - 1] = corner.startY; + } else { + lines[i * 4 - 2] = corner.startX; + lines[i * 4 - 1] = corner.startY; + } + lines[i * 4] = corner.stopX; + lines[i * 4 + 1] = corner.stopY; + intersection = intersectLineCircle(x, y, centerX, centerY, corner.cx, corner.cy, corner.radius); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + }); + for (var i = 0; i < lines.length / 4; i++) { + intersection = finiteLinesIntersect(x, y, centerX, centerY, lines[i * 4], lines[i * 4 + 1], lines[i * 4 + 2], lines[i * 4 + 3], false); + if (intersection.length !== 0) { + intersections.push(intersection[0], intersection[1]); + } + } + if (intersections.length > 2) { + var lowestIntersection = [intersections[0], intersections[1]]; + var lowestSquaredDistance = Math.pow(lowestIntersection[0] - x, 2) + Math.pow(lowestIntersection[1] - y, 2); + for (var _i3 = 1; _i3 < intersections.length / 2; _i3++) { + var squaredDistance = Math.pow(intersections[_i3 * 2] - x, 2) + Math.pow(intersections[_i3 * 2 + 1] - y, 2); + if (squaredDistance <= lowestSquaredDistance) { + lowestIntersection[0] = intersections[_i3 * 2]; + lowestIntersection[1] = intersections[_i3 * 2 + 1]; + lowestSquaredDistance = squaredDistance; + } + } + return lowestIntersection; + } + return intersections; +}; +var shortenIntersection = function shortenIntersection(intersection, offset, amount) { + var disp = [intersection[0] - offset[0], intersection[1] - offset[1]]; + var length = Math.sqrt(disp[0] * disp[0] + disp[1] * disp[1]); + var lenRatio = (length - amount) / length; + if (lenRatio < 0) { + lenRatio = 0.00001; + } + return [offset[0] + lenRatio * disp[0], offset[1] + lenRatio * disp[1]]; +}; +var generateUnitNgonPointsFitToSquare = function generateUnitNgonPointsFitToSquare(sides, rotationRadians) { + var points = generateUnitNgonPoints(sides, rotationRadians); + points = fitPolygonToSquare(points); + return points; +}; +var fitPolygonToSquare = function fitPolygonToSquare(points) { + var x, y; + var sides = points.length / 2; + var minX = Infinity, + minY = Infinity, + maxX = -Infinity, + maxY = -Infinity; + for (var i = 0; i < sides; i++) { + x = points[2 * i]; + y = points[2 * i + 1]; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + + // stretch factors + var sx = 2 / (maxX - minX); + var sy = 2 / (maxY - minY); + for (var _i4 = 0; _i4 < sides; _i4++) { + x = points[2 * _i4] = points[2 * _i4] * sx; + y = points[2 * _i4 + 1] = points[2 * _i4 + 1] * sy; + minX = Math.min(minX, x); + maxX = Math.max(maxX, x); + minY = Math.min(minY, y); + maxY = Math.max(maxY, y); + } + if (minY < -1) { + for (var _i5 = 0; _i5 < sides; _i5++) { + y = points[2 * _i5 + 1] = points[2 * _i5 + 1] + (-1 - minY); + } + } + return points; +}; +var generateUnitNgonPoints = function generateUnitNgonPoints(sides, rotationRadians) { + var increment = 1.0 / sides * 2 * Math.PI; + var startAngle = sides % 2 === 0 ? Math.PI / 2.0 + increment / 2.0 : Math.PI / 2.0; + startAngle += rotationRadians; + var points = new Array(sides * 2); + var currentAngle; + for (var i = 0; i < sides; i++) { + currentAngle = i * increment + startAngle; + points[2 * i] = Math.cos(currentAngle); // x + points[2 * i + 1] = Math.sin(-currentAngle); // y + } + + return points; +}; + +// Set the default radius, unless half of width or height is smaller than default +var getRoundRectangleRadius = function getRoundRectangleRadius(width, height) { + return Math.min(width / 4, height / 4, 8); +}; + +// Set the default radius +var getRoundPolygonRadius = function getRoundPolygonRadius(width, height) { + return Math.min(width / 10, height / 10, 8); +}; +var getCutRectangleCornerLength = function getCutRectangleCornerLength() { + return 8; +}; +var bezierPtsToQuadCoeff = function bezierPtsToQuadCoeff(p0, p1, p2) { + return [p0 - 2 * p1 + p2, 2 * (p1 - p0), p0]; +}; + +// get curve width, height, and control point position offsets as a percentage of node height / width +var getBarrelCurveConstants = function getBarrelCurveConstants(width, height) { + return { + heightOffset: Math.min(15, 0.05 * height), + widthOffset: Math.min(100, 0.25 * width), + ctrlPtOffsetPct: 0.05 + }; +}; + +var pageRankDefaults = defaults$g({ + dampingFactor: 0.8, + precision: 0.000001, + iterations: 200, + weight: function weight(edge) { + return 1; + } +}); +var elesfn$o = { + pageRank: function pageRank(options) { + var _pageRankDefaults = pageRankDefaults(options), + dampingFactor = _pageRankDefaults.dampingFactor, + precision = _pageRankDefaults.precision, + iterations = _pageRankDefaults.iterations, + weight = _pageRankDefaults.weight; + var cy = this._private.cy; + var _this$byGroup = this.byGroup(), + nodes = _this$byGroup.nodes, + edges = _this$byGroup.edges; + var numNodes = nodes.length; + var numNodesSqd = numNodes * numNodes; + var numEdges = edges.length; + + // Construct transposed adjacency matrix + // First lets have a zeroed matrix of the right size + // We'll also keep track of the sum of each column + var matrix = new Array(numNodesSqd); + var columnSum = new Array(numNodes); + var additionalProb = (1 - dampingFactor) / numNodes; + + // Create null matrix + for (var i = 0; i < numNodes; i++) { + for (var j = 0; j < numNodes; j++) { + var n = i * numNodes + j; + matrix[n] = 0; + } + columnSum[i] = 0; + } + + // Now, process edges + for (var _i = 0; _i < numEdges; _i++) { + var edge = edges[_i]; + var srcId = edge.data('source'); + var tgtId = edge.data('target'); + + // Don't include loops in the matrix + if (srcId === tgtId) { + continue; + } + var s = nodes.indexOfId(srcId); + var t = nodes.indexOfId(tgtId); + var w = weight(edge); + var _n = t * numNodes + s; + + // Update matrix + matrix[_n] += w; + + // Update column sum + columnSum[s] += w; + } + + // Add additional probability based on damping factor + // Also, take into account columns that have sum = 0 + var p = 1.0 / numNodes + additionalProb; // Shorthand + + // Traverse matrix, column by column + for (var _j = 0; _j < numNodes; _j++) { + if (columnSum[_j] === 0) { + // No 'links' out from node jth, assume equal probability for each possible node + for (var _i2 = 0; _i2 < numNodes; _i2++) { + var _n2 = _i2 * numNodes + _j; + matrix[_n2] = p; + } + } else { + // Node jth has outgoing link, compute normalized probabilities + for (var _i3 = 0; _i3 < numNodes; _i3++) { + var _n3 = _i3 * numNodes + _j; + matrix[_n3] = matrix[_n3] / columnSum[_j] + additionalProb; + } + } + } + + // Compute dominant eigenvector using power method + var eigenvector = new Array(numNodes); + var temp = new Array(numNodes); + var previous; + + // Start with a vector of all 1's + // Also, initialize a null vector which will be used as shorthand + for (var _i4 = 0; _i4 < numNodes; _i4++) { + eigenvector[_i4] = 1; + } + for (var iter = 0; iter < iterations; iter++) { + // Temp array with all 0's + for (var _i5 = 0; _i5 < numNodes; _i5++) { + temp[_i5] = 0; + } + + // Multiply matrix with previous result + for (var _i6 = 0; _i6 < numNodes; _i6++) { + for (var _j2 = 0; _j2 < numNodes; _j2++) { + var _n4 = _i6 * numNodes + _j2; + temp[_i6] += matrix[_n4] * eigenvector[_j2]; + } + } + inPlaceSumNormalize(temp); + previous = eigenvector; + eigenvector = temp; + temp = previous; + var diff = 0; + // Compute difference (squared module) of both vectors + for (var _i7 = 0; _i7 < numNodes; _i7++) { + var delta = previous[_i7] - eigenvector[_i7]; + diff += delta * delta; + } + + // If difference is less than the desired threshold, stop iterating + if (diff < precision) { + break; + } + } + + // Construct result + var res = { + rank: function rank(node) { + node = cy.collection(node)[0]; + return eigenvector[nodes.indexOf(node)]; + } + }; + return res; + } // pageRank +}; // elesfn + +var defaults$f = defaults$g({ + root: null, + weight: function weight(edge) { + return 1; + }, + directed: false, + alpha: 0 +}); +var elesfn$n = { + degreeCentralityNormalized: function degreeCentralityNormalized(options) { + options = defaults$f(options); + var cy = this.cy(); + var nodes = this.nodes(); + var numNodes = nodes.length; + if (!options.directed) { + var degrees = {}; + var maxDegree = 0; + for (var i = 0; i < numNodes; i++) { + var node = nodes[i]; + + // add current node to the current options object and call degreeCentrality + options.root = node; + var currDegree = this.degreeCentrality(options); + if (maxDegree < currDegree.degree) { + maxDegree = currDegree.degree; + } + degrees[node.id()] = currDegree.degree; + } + return { + degree: function degree(node) { + if (maxDegree === 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return degrees[node.id()] / maxDegree; + } + }; + } else { + var indegrees = {}; + var outdegrees = {}; + var maxIndegree = 0; + var maxOutdegree = 0; + for (var _i = 0; _i < numNodes; _i++) { + var _node = nodes[_i]; + var id = _node.id(); + + // add current node to the current options object and call degreeCentrality + options.root = _node; + var _currDegree = this.degreeCentrality(options); + if (maxIndegree < _currDegree.indegree) maxIndegree = _currDegree.indegree; + if (maxOutdegree < _currDegree.outdegree) maxOutdegree = _currDegree.outdegree; + indegrees[id] = _currDegree.indegree; + outdegrees[id] = _currDegree.outdegree; + } + return { + indegree: function indegree(node) { + if (maxIndegree == 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return indegrees[node.id()] / maxIndegree; + }, + outdegree: function outdegree(node) { + if (maxOutdegree === 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node); + } + return outdegrees[node.id()] / maxOutdegree; + } + }; + } + }, + // degreeCentralityNormalized + + // Implemented from the algorithm in Opsahl's paper + // "Node centrality in weighted networks: Generalizing degree and shortest paths" + // check the heading 2 "Degree" + degreeCentrality: function degreeCentrality(options) { + options = defaults$f(options); + var cy = this.cy(); + var callingEles = this; + var _options = options, + root = _options.root, + weight = _options.weight, + directed = _options.directed, + alpha = _options.alpha; + root = cy.collection(root)[0]; + if (!directed) { + var connEdges = root.connectedEdges().intersection(callingEles); + var k = connEdges.length; + var s = 0; + + // Now, sum edge weights + for (var i = 0; i < connEdges.length; i++) { + s += weight(connEdges[i]); + } + return { + degree: Math.pow(k, 1 - alpha) * Math.pow(s, alpha) + }; + } else { + var edges = root.connectedEdges(); + var incoming = edges.filter(function (edge) { + return edge.target().same(root) && callingEles.has(edge); + }); + var outgoing = edges.filter(function (edge) { + return edge.source().same(root) && callingEles.has(edge); + }); + var k_in = incoming.length; + var k_out = outgoing.length; + var s_in = 0; + var s_out = 0; + + // Now, sum incoming edge weights + for (var _i2 = 0; _i2 < incoming.length; _i2++) { + s_in += weight(incoming[_i2]); + } + + // Now, sum outgoing edge weights + for (var _i3 = 0; _i3 < outgoing.length; _i3++) { + s_out += weight(outgoing[_i3]); + } + return { + indegree: Math.pow(k_in, 1 - alpha) * Math.pow(s_in, alpha), + outdegree: Math.pow(k_out, 1 - alpha) * Math.pow(s_out, alpha) + }; + } + } // degreeCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$n.dc = elesfn$n.degreeCentrality; +elesfn$n.dcn = elesfn$n.degreeCentralityNormalised = elesfn$n.degreeCentralityNormalized; + +var defaults$e = defaults$g({ + harmonic: true, + weight: function weight() { + return 1; + }, + directed: false, + root: null +}); +var elesfn$m = { + closenessCentralityNormalized: function closenessCentralityNormalized(options) { + var _defaults = defaults$e(options), + harmonic = _defaults.harmonic, + weight = _defaults.weight, + directed = _defaults.directed; + var cy = this.cy(); + var closenesses = {}; + var maxCloseness = 0; + var nodes = this.nodes(); + var fw = this.floydWarshall({ + weight: weight, + directed: directed + }); + + // Compute closeness for every node and find the maximum closeness + for (var i = 0; i < nodes.length; i++) { + var currCloseness = 0; + var node_i = nodes[i]; + for (var j = 0; j < nodes.length; j++) { + if (i !== j) { + var d = fw.distance(node_i, nodes[j]); + if (harmonic) { + currCloseness += 1 / d; + } else { + currCloseness += d; + } + } + } + if (!harmonic) { + currCloseness = 1 / currCloseness; + } + if (maxCloseness < currCloseness) { + maxCloseness = currCloseness; + } + closenesses[node_i.id()] = currCloseness; + } + return { + closeness: function closeness(node) { + if (maxCloseness == 0) { + return 0; + } + if (string(node)) { + // from is a selector string + node = cy.filter(node)[0].id(); + } else { + // from is a node + node = node.id(); + } + return closenesses[node] / maxCloseness; + } + }; + }, + // Implemented from pseudocode from wikipedia + closenessCentrality: function closenessCentrality(options) { + var _defaults2 = defaults$e(options), + root = _defaults2.root, + weight = _defaults2.weight, + directed = _defaults2.directed, + harmonic = _defaults2.harmonic; + root = this.filter(root)[0]; + + // we need distance from this node to every other node + var dijkstra = this.dijkstra({ + root: root, + weight: weight, + directed: directed + }); + var totalDistance = 0; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + if (!n.same(root)) { + var d = dijkstra.distanceTo(n); + if (harmonic) { + totalDistance += 1 / d; + } else { + totalDistance += d; + } + } + } + return harmonic ? totalDistance : 1 / totalDistance; + } // closenessCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$m.cc = elesfn$m.closenessCentrality; +elesfn$m.ccn = elesfn$m.closenessCentralityNormalised = elesfn$m.closenessCentralityNormalized; + +var defaults$d = defaults$g({ + weight: null, + directed: false +}); +var elesfn$l = { + // Implemented from the algorithm in the paper "On Variants of Shortest-Path Betweenness Centrality and their Generic Computation" by Ulrik Brandes + betweennessCentrality: function betweennessCentrality(options) { + var _defaults = defaults$d(options), + directed = _defaults.directed, + weight = _defaults.weight; + var weighted = weight != null; + var cy = this.cy(); + + // starting + var V = this.nodes(); + var A = {}; + var _C = {}; + var max = 0; + var C = { + set: function set(key, val) { + _C[key] = val; + if (val > max) { + max = val; + } + }, + get: function get(key) { + return _C[key]; + } + }; + + // A contains the neighborhoods of every node + for (var i = 0; i < V.length; i++) { + var v = V[i]; + var vid = v.id(); + if (directed) { + A[vid] = v.outgoers().nodes(); // get outgoers of every node + } else { + A[vid] = v.openNeighborhood().nodes(); // get neighbors of every node + } + + C.set(vid, 0); + } + var _loop = function _loop(s) { + var sid = V[s].id(); + var S = []; // stack + var P = {}; + var g = {}; + var d = {}; + var Q = new heap(function (a, b) { + return d[a] - d[b]; + }); // queue + + // init dictionaries + for (var _i = 0; _i < V.length; _i++) { + var _vid = V[_i].id(); + P[_vid] = []; + g[_vid] = 0; + d[_vid] = Infinity; + } + g[sid] = 1; // sigma + d[sid] = 0; // distance to s + + Q.push(sid); + while (!Q.empty()) { + var _v = Q.pop(); + S.push(_v); + if (weighted) { + for (var j = 0; j < A[_v].length; j++) { + var w = A[_v][j]; + var vEle = cy.getElementById(_v); + var edge = void 0; + if (vEle.edgesTo(w).length > 0) { + edge = vEle.edgesTo(w)[0]; + } else { + edge = w.edgesTo(vEle)[0]; + } + var edgeWeight = weight(edge); + w = w.id(); + if (d[w] > d[_v] + edgeWeight) { + d[w] = d[_v] + edgeWeight; + if (Q.nodes.indexOf(w) < 0) { + //if w is not in Q + Q.push(w); + } else { + // update position if w is in Q + Q.updateItem(w); + } + g[w] = 0; + P[w] = []; + } + if (d[w] == d[_v] + edgeWeight) { + g[w] = g[w] + g[_v]; + P[w].push(_v); + } + } + } else { + for (var _j = 0; _j < A[_v].length; _j++) { + var _w = A[_v][_j].id(); + if (d[_w] == Infinity) { + Q.push(_w); + d[_w] = d[_v] + 1; + } + if (d[_w] == d[_v] + 1) { + g[_w] = g[_w] + g[_v]; + P[_w].push(_v); + } + } + } + } + var e = {}; + for (var _i2 = 0; _i2 < V.length; _i2++) { + e[V[_i2].id()] = 0; + } + while (S.length > 0) { + var _w2 = S.pop(); + for (var _j2 = 0; _j2 < P[_w2].length; _j2++) { + var _v2 = P[_w2][_j2]; + e[_v2] = e[_v2] + g[_v2] / g[_w2] * (1 + e[_w2]); + } + if (_w2 != V[s].id()) { + C.set(_w2, C.get(_w2) + e[_w2]); + } + } + }; + for (var s = 0; s < V.length; s++) { + _loop(s); + } + var ret = { + betweenness: function betweenness(node) { + var id = cy.collection(node).id(); + return C.get(id); + }, + betweennessNormalized: function betweennessNormalized(node) { + if (max == 0) { + return 0; + } + var id = cy.collection(node).id(); + return C.get(id) / max; + } + }; + + // alias + ret.betweennessNormalised = ret.betweennessNormalized; + return ret; + } // betweennessCentrality +}; // elesfn + +// nice, short mathematical alias +elesfn$l.bc = elesfn$l.betweennessCentrality; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 + +/* eslint-disable no-unused-vars */ +var defaults$c = defaults$g({ + expandFactor: 2, + // affects time of computation and cluster granularity to some extent: M * M + inflateFactor: 2, + // affects cluster granularity (the greater the value, the more clusters): M(i,j) / E(j) + multFactor: 1, + // optional self loops for each node. Use a neutral value to improve cluster computations. + maxIterations: 20, + // maximum number of iterations of the MCL algorithm in a single run + attributes: [ + // attributes/features used to group nodes, ie. similarity values between nodes + function (edge) { + return 1; + }] +}); +/* eslint-enable */ + +var setOptions$3 = function setOptions(options) { + return defaults$c(options); +}; +/* eslint-enable */ + +var getSimilarity$1 = function getSimilarity(edge, attributes) { + var total = 0; + for (var i = 0; i < attributes.length; i++) { + total += attributes[i](edge); + } + return total; +}; +var addLoops = function addLoops(M, n, val) { + for (var i = 0; i < n; i++) { + M[i * n + i] = val; + } +}; +var normalize = function normalize(M, n) { + var sum; + for (var col = 0; col < n; col++) { + sum = 0; + for (var row = 0; row < n; row++) { + sum += M[row * n + col]; + } + for (var _row = 0; _row < n; _row++) { + M[_row * n + col] = M[_row * n + col] / sum; + } + } +}; + +// TODO: blocked matrix multiplication? +var mmult = function mmult(A, B, n) { + var C = new Array(n * n); + for (var i = 0; i < n; i++) { + for (var j = 0; j < n; j++) { + C[i * n + j] = 0; + } + for (var k = 0; k < n; k++) { + for (var _j = 0; _j < n; _j++) { + C[i * n + _j] += A[i * n + k] * B[k * n + _j]; + } + } + } + return C; +}; +var expand = function expand(M, n, expandFactor /** power **/) { + var _M = M.slice(0); + for (var p = 1; p < expandFactor; p++) { + M = mmult(M, _M, n); + } + return M; +}; +var inflate = function inflate(M, n, inflateFactor /** r **/) { + var _M = new Array(n * n); + + // M(i,j) ^ inflatePower + for (var i = 0; i < n * n; i++) { + _M[i] = Math.pow(M[i], inflateFactor); + } + normalize(_M, n); + return _M; +}; +var hasConverged = function hasConverged(M, _M, n2, roundFactor) { + // Check that both matrices have the same elements (i,j) + for (var i = 0; i < n2; i++) { + var v1 = Math.round(M[i] * Math.pow(10, roundFactor)) / Math.pow(10, roundFactor); // truncate to 'roundFactor' decimal places + var v2 = Math.round(_M[i] * Math.pow(10, roundFactor)) / Math.pow(10, roundFactor); + if (v1 !== v2) { + return false; + } + } + return true; +}; +var assign$2 = function assign(M, n, nodes, cy) { + var clusters = []; + for (var i = 0; i < n; i++) { + var cluster = []; + for (var j = 0; j < n; j++) { + // Row-wise attractors and elements that they attract belong in same cluster + if (Math.round(M[i * n + j] * 1000) / 1000 > 0) { + cluster.push(nodes[j]); + } + } + if (cluster.length !== 0) { + clusters.push(cy.collection(cluster)); + } + } + return clusters; +}; +var isDuplicate = function isDuplicate(c1, c2) { + for (var i = 0; i < c1.length; i++) { + if (!c2[i] || c1[i].id() !== c2[i].id()) { + return false; + } + } + return true; +}; +var removeDuplicates = function removeDuplicates(clusters) { + for (var i = 0; i < clusters.length; i++) { + for (var j = 0; j < clusters.length; j++) { + if (i != j && isDuplicate(clusters[i], clusters[j])) { + clusters.splice(j, 1); + } + } + } + return clusters; +}; +var markovClustering = function markovClustering(options) { + var nodes = this.nodes(); + var edges = this.edges(); + var cy = this.cy(); + + // Set parameters of algorithm: + var opts = setOptions$3(options); + + // Map each node to its position in node array + var id2position = {}; + for (var i = 0; i < nodes.length; i++) { + id2position[nodes[i].id()] = i; + } + + // Generate stochastic matrix M from input graph G (should be symmetric/undirected) + var n = nodes.length, + n2 = n * n; + var M = new Array(n2), + _M; + for (var _i = 0; _i < n2; _i++) { + M[_i] = 0; + } + for (var e = 0; e < edges.length; e++) { + var edge = edges[e]; + var _i2 = id2position[edge.source().id()]; + var j = id2position[edge.target().id()]; + var sim = getSimilarity$1(edge, opts.attributes); + M[_i2 * n + j] += sim; // G should be symmetric and undirected + M[j * n + _i2] += sim; + } + + // Begin Markov cluster algorithm + + // Step 1: Add self loops to each node, ie. add multFactor to matrix diagonal + addLoops(M, n, opts.multFactor); + + // Step 2: M = normalize( M ); + normalize(M, n); + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + isStillMoving = false; + + // Step 3: + _M = expand(M, n, opts.expandFactor); + + // Step 4: + M = inflate(_M, n, opts.inflateFactor); + + // Step 5: check to see if ~steady state has been reached + if (!hasConverged(M, _M, n2, 4)) { + isStillMoving = true; + } + iterations++; + } + + // Build clusters from matrix + var clusters = assign$2(M, n, nodes, cy); + + // Remove duplicate clusters due to symmetry of graph and M matrix + clusters = removeDuplicates(clusters); + return clusters; +}; +var markovClustering$1 = { + markovClustering: markovClustering, + mcl: markovClustering +}; + +// Common distance metrics for clustering algorithms +var identity = function identity(x) { + return x; +}; +var absDiff = function absDiff(p, q) { + return Math.abs(q - p); +}; +var addAbsDiff = function addAbsDiff(total, p, q) { + return total + absDiff(p, q); +}; +var addSquaredDiff = function addSquaredDiff(total, p, q) { + return total + Math.pow(q - p, 2); +}; +var sqrt = function sqrt(x) { + return Math.sqrt(x); +}; +var maxAbsDiff = function maxAbsDiff(currentMax, p, q) { + return Math.max(currentMax, absDiff(p, q)); +}; +var getDistance = function getDistance(length, getP, getQ, init, visit) { + var post = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : identity; + var ret = init; + var p, q; + for (var dim = 0; dim < length; dim++) { + p = getP(dim); + q = getQ(dim); + ret = visit(ret, p, q); + } + return post(ret); +}; +var distances = { + euclidean: function euclidean(length, getP, getQ) { + if (length >= 2) { + return getDistance(length, getP, getQ, 0, addSquaredDiff, sqrt); + } else { + // for single attr case, more efficient to avoid sqrt + return getDistance(length, getP, getQ, 0, addAbsDiff); + } + }, + squaredEuclidean: function squaredEuclidean(length, getP, getQ) { + return getDistance(length, getP, getQ, 0, addSquaredDiff); + }, + manhattan: function manhattan(length, getP, getQ) { + return getDistance(length, getP, getQ, 0, addAbsDiff); + }, + max: function max(length, getP, getQ) { + return getDistance(length, getP, getQ, -Infinity, maxAbsDiff); + } +}; + +// in case the user accidentally doesn't use camel case +distances['squared-euclidean'] = distances['squaredEuclidean']; +distances['squaredeuclidean'] = distances['squaredEuclidean']; +function clusteringDistance (method, length, getP, getQ, nodeP, nodeQ) { + var impl; + if (fn$6(method)) { + impl = method; + } else { + impl = distances[method] || distances.euclidean; + } + if (length === 0 && fn$6(method)) { + return impl(nodeP, nodeQ); + } else { + return impl(length, getP, getQ, nodeP, nodeQ); + } +} + +var defaults$b = defaults$g({ + k: 2, + m: 2, + sensitivityThreshold: 0.0001, + distance: 'euclidean', + maxIterations: 10, + attributes: [], + testMode: false, + testCentroids: null +}); +var setOptions$2 = function setOptions(options) { + return defaults$b(options); +}; + +var getDist = function getDist(type, node, centroid, attributes, mode) { + var noNodeP = mode !== 'kMedoids'; + var getP = noNodeP ? function (i) { + return centroid[i]; + } : function (i) { + return attributes[i](centroid); + }; + var getQ = function getQ(i) { + return attributes[i](node); + }; + var nodeP = centroid; + var nodeQ = node; + return clusteringDistance(type, attributes.length, getP, getQ, nodeP, nodeQ); +}; +var randomCentroids = function randomCentroids(nodes, k, attributes) { + var ndim = attributes.length; + var min = new Array(ndim); + var max = new Array(ndim); + var centroids = new Array(k); + var centroid = null; + + // Find min, max values for each attribute dimension + for (var i = 0; i < ndim; i++) { + min[i] = nodes.min(attributes[i]).value; + max[i] = nodes.max(attributes[i]).value; + } + + // Build k centroids, each represented as an n-dim feature vector + for (var c = 0; c < k; c++) { + centroid = []; + for (var _i = 0; _i < ndim; _i++) { + centroid[_i] = Math.random() * (max[_i] - min[_i]) + min[_i]; // random initial value + } + + centroids[c] = centroid; + } + return centroids; +}; +var classify = function classify(node, centroids, distance, attributes, type) { + var min = Infinity; + var index = 0; + for (var i = 0; i < centroids.length; i++) { + var dist = getDist(distance, node, centroids[i], attributes, type); + if (dist < min) { + min = dist; + index = i; + } + } + return index; +}; +var buildCluster = function buildCluster(centroid, nodes, assignment) { + var cluster = []; + var node = null; + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + if (assignment[node.id()] === centroid) { + //console.log("Node " + node.id() + " is associated with medoid #: " + m); + cluster.push(node); + } + } + return cluster; +}; +var haveValuesConverged = function haveValuesConverged(v1, v2, sensitivityThreshold) { + return Math.abs(v2 - v1) <= sensitivityThreshold; +}; +var haveMatricesConverged = function haveMatricesConverged(v1, v2, sensitivityThreshold) { + for (var i = 0; i < v1.length; i++) { + for (var j = 0; j < v1[i].length; j++) { + var diff = Math.abs(v1[i][j] - v2[i][j]); + if (diff > sensitivityThreshold) { + return false; + } + } + } + return true; +}; +var seenBefore = function seenBefore(node, medoids, n) { + for (var i = 0; i < n; i++) { + if (node === medoids[i]) return true; + } + return false; +}; +var randomMedoids = function randomMedoids(nodes, k) { + var medoids = new Array(k); + + // For small data sets, the probability of medoid conflict is greater, + // so we need to check to see if we've already seen or chose this node before. + if (nodes.length < 50) { + // Randomly select k medoids from the n nodes + for (var i = 0; i < k; i++) { + var node = nodes[Math.floor(Math.random() * nodes.length)]; + + // If we've already chosen this node to be a medoid, don't choose it again (for small data sets). + // Instead choose a different random node. + while (seenBefore(node, medoids, i)) { + node = nodes[Math.floor(Math.random() * nodes.length)]; + } + medoids[i] = node; + } + } else { + // Relatively large data set, so pretty safe to not check and just select random nodes + for (var _i2 = 0; _i2 < k; _i2++) { + medoids[_i2] = nodes[Math.floor(Math.random() * nodes.length)]; + } + } + return medoids; +}; +var findCost = function findCost(potentialNewMedoid, cluster, attributes) { + var cost = 0; + for (var n = 0; n < cluster.length; n++) { + cost += getDist('manhattan', cluster[n], potentialNewMedoid, attributes, 'kMedoids'); + } + return cost; +}; +var kMeans = function kMeans(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var node = null; + + // Set parameters of algorithm: # of clusters, distance metric, etc. + var opts = setOptions$2(options); + + // Begin k-means algorithm + var clusters = new Array(opts.k); + var assignment = {}; + var centroids; + + // Step 1: Initialize centroid positions + if (opts.testMode) { + if (typeof opts.testCentroids === 'number') { + // TODO: implement a seeded random number generator. + opts.testCentroids; + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } else if (_typeof(opts.testCentroids) === 'object') { + centroids = opts.testCentroids; + } else { + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } + } else { + centroids = randomCentroids(nodes, opts.k, opts.attributes); + } + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + // Step 2: Assign nodes to the nearest centroid + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + // Determine which cluster this node belongs to: node id => cluster # + assignment[node.id()] = classify(node, centroids, opts.distance, opts.attributes, 'kMeans'); + } + + // Step 3: For each of the k clusters, update its centroid + isStillMoving = false; + for (var c = 0; c < opts.k; c++) { + // Get all nodes that belong to this cluster + var cluster = buildCluster(c, nodes, assignment); + if (cluster.length === 0) { + // If cluster is empty, break out early & move to next cluster + continue; + } + + // Update centroids by calculating avg of all nodes within the cluster. + var ndim = opts.attributes.length; + var centroid = centroids[c]; // [ dim_1, dim_2, dim_3, ... , dim_n ] + var newCentroid = new Array(ndim); + var sum = new Array(ndim); + for (var d = 0; d < ndim; d++) { + sum[d] = 0.0; + for (var i = 0; i < cluster.length; i++) { + node = cluster[i]; + sum[d] += opts.attributes[d](node); + } + newCentroid[d] = sum[d] / cluster.length; + + // Check to see if algorithm has converged, i.e. when centroids no longer change + if (!haveValuesConverged(newCentroid[d], centroid[d], opts.sensitivityThreshold)) { + isStillMoving = true; + } + } + centroids[c] = newCentroid; + clusters[c] = cy.collection(cluster); + } + iterations++; + } + return clusters; +}; +var kMedoids = function kMedoids(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var node = null; + var opts = setOptions$2(options); + + // Begin k-medoids algorithm + var clusters = new Array(opts.k); + var medoids; + var assignment = {}; + var curCost; + var minCosts = new Array(opts.k); // minimum cost configuration for each cluster + + // Step 1: Initialize k medoids + if (opts.testMode) { + if (typeof opts.testCentroids === 'number') ; else if (_typeof(opts.testCentroids) === 'object') { + medoids = opts.testCentroids; + } else { + medoids = randomMedoids(nodes, opts.k); + } + } else { + medoids = randomMedoids(nodes, opts.k); + } + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + // Step 2: Assign nodes to the nearest medoid + for (var n = 0; n < nodes.length; n++) { + node = nodes[n]; + // Determine which cluster this node belongs to: node id => cluster # + assignment[node.id()] = classify(node, medoids, opts.distance, opts.attributes, 'kMedoids'); + } + isStillMoving = false; + // Step 3: For each medoid m, and for each node associated with mediod m, + // select the node with the lowest configuration cost as new medoid. + for (var m = 0; m < medoids.length; m++) { + // Get all nodes that belong to this medoid + var cluster = buildCluster(m, nodes, assignment); + if (cluster.length === 0) { + // If cluster is empty, break out early & move to next cluster + continue; + } + minCosts[m] = findCost(medoids[m], cluster, opts.attributes); // original cost + + // Select different medoid if its configuration has the lowest cost + for (var _n = 0; _n < cluster.length; _n++) { + curCost = findCost(cluster[_n], cluster, opts.attributes); + if (curCost < minCosts[m]) { + minCosts[m] = curCost; + medoids[m] = cluster[_n]; + isStillMoving = true; + } + } + clusters[m] = cy.collection(cluster); + } + iterations++; + } + return clusters; +}; +var updateCentroids = function updateCentroids(centroids, nodes, U, weight, opts) { + var numerator, denominator; + for (var n = 0; n < nodes.length; n++) { + for (var c = 0; c < centroids.length; c++) { + weight[n][c] = Math.pow(U[n][c], opts.m); + } + } + for (var _c = 0; _c < centroids.length; _c++) { + for (var dim = 0; dim < opts.attributes.length; dim++) { + numerator = 0; + denominator = 0; + for (var _n2 = 0; _n2 < nodes.length; _n2++) { + numerator += weight[_n2][_c] * opts.attributes[dim](nodes[_n2]); + denominator += weight[_n2][_c]; + } + centroids[_c][dim] = numerator / denominator; + } + } +}; +var updateMembership = function updateMembership(U, _U, centroids, nodes, opts) { + // Save previous step + for (var i = 0; i < U.length; i++) { + _U[i] = U[i].slice(); + } + var sum, numerator, denominator; + var pow = 2 / (opts.m - 1); + for (var c = 0; c < centroids.length; c++) { + for (var n = 0; n < nodes.length; n++) { + sum = 0; + for (var k = 0; k < centroids.length; k++) { + // against all other centroids + numerator = getDist(opts.distance, nodes[n], centroids[c], opts.attributes, 'cmeans'); + denominator = getDist(opts.distance, nodes[n], centroids[k], opts.attributes, 'cmeans'); + sum += Math.pow(numerator / denominator, pow); + } + U[n][c] = 1 / sum; + } + } +}; +var assign$1 = function assign(nodes, U, opts, cy) { + var clusters = new Array(opts.k); + for (var c = 0; c < clusters.length; c++) { + clusters[c] = []; + } + var max; + var index; + for (var n = 0; n < U.length; n++) { + // for each node (U is N x C matrix) + max = -Infinity; + index = -1; + // Determine which cluster the node is most likely to belong in + for (var _c2 = 0; _c2 < U[0].length; _c2++) { + if (U[n][_c2] > max) { + max = U[n][_c2]; + index = _c2; + } + } + clusters[index].push(nodes[n]); + } + + // Turn every array into a collection of nodes + for (var _c3 = 0; _c3 < clusters.length; _c3++) { + clusters[_c3] = cy.collection(clusters[_c3]); + } + return clusters; +}; +var fuzzyCMeans = function fuzzyCMeans(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var opts = setOptions$2(options); + + // Begin fuzzy c-means algorithm + var clusters; + var centroids; + var U; + var _U; + var weight; + + // Step 1: Initialize letiables. + _U = new Array(nodes.length); + for (var i = 0; i < nodes.length; i++) { + // N x C matrix + _U[i] = new Array(opts.k); + } + U = new Array(nodes.length); + for (var _i3 = 0; _i3 < nodes.length; _i3++) { + // N x C matrix + U[_i3] = new Array(opts.k); + } + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + var total = 0; + for (var j = 0; j < opts.k; j++) { + U[_i4][j] = Math.random(); + total += U[_i4][j]; + } + for (var _j = 0; _j < opts.k; _j++) { + U[_i4][_j] = U[_i4][_j] / total; + } + } + centroids = new Array(opts.k); + for (var _i5 = 0; _i5 < opts.k; _i5++) { + centroids[_i5] = new Array(opts.attributes.length); + } + weight = new Array(nodes.length); + for (var _i6 = 0; _i6 < nodes.length; _i6++) { + // N x C matrix + weight[_i6] = new Array(opts.k); + } + // end init FCM + + var isStillMoving = true; + var iterations = 0; + while (isStillMoving && iterations < opts.maxIterations) { + isStillMoving = false; + + // Step 2: Calculate the centroids for each step. + updateCentroids(centroids, nodes, U, weight, opts); + + // Step 3: Update the partition matrix U. + updateMembership(U, _U, centroids, nodes, opts); + + // Step 4: Check for convergence. + if (!haveMatricesConverged(U, _U, opts.sensitivityThreshold)) { + isStillMoving = true; + } + iterations++; + } + + // Assign nodes to clusters with highest probability. + clusters = assign$1(nodes, U, opts, cy); + return { + clusters: clusters, + degreeOfMembership: U + }; +}; +var kClustering = { + kMeans: kMeans, + kMedoids: kMedoids, + fuzzyCMeans: fuzzyCMeans, + fcm: fuzzyCMeans +}; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 +var defaults$a = defaults$g({ + distance: 'euclidean', + // distance metric to compare nodes + linkage: 'min', + // linkage criterion : how to determine the distance between clusters of nodes + mode: 'threshold', + // mode:'threshold' => clusters must be threshold distance apart + threshold: Infinity, + // the distance threshold + // mode:'dendrogram' => the nodes are organised as leaves in a tree (siblings are close), merging makes clusters + addDendrogram: false, + // whether to add the dendrogram to the graph for viz + dendrogramDepth: 0, + // depth at which dendrogram branches are merged into the returned clusters + attributes: [] // array of attr functions +}); + +var linkageAliases = { + 'single': 'min', + 'complete': 'max' +}; +var setOptions$1 = function setOptions(options) { + var opts = defaults$a(options); + var preferredAlias = linkageAliases[opts.linkage]; + if (preferredAlias != null) { + opts.linkage = preferredAlias; + } + return opts; +}; +var mergeClosest = function mergeClosest(clusters, index, dists, mins, opts) { + // Find two closest clusters from cached mins + var minKey = 0; + var min = Infinity; + var dist; + var attrs = opts.attributes; + var getDist = function getDist(n1, n2) { + return clusteringDistance(opts.distance, attrs.length, function (i) { + return attrs[i](n1); + }, function (i) { + return attrs[i](n2); + }, n1, n2); + }; + for (var i = 0; i < clusters.length; i++) { + var key = clusters[i].key; + var _dist = dists[key][mins[key]]; + if (_dist < min) { + minKey = key; + min = _dist; + } + } + if (opts.mode === 'threshold' && min >= opts.threshold || opts.mode === 'dendrogram' && clusters.length === 1) { + return false; + } + var c1 = index[minKey]; + var c2 = index[mins[minKey]]; + var merged; + + // Merge two closest clusters + if (opts.mode === 'dendrogram') { + merged = { + left: c1, + right: c2, + key: c1.key + }; + } else { + merged = { + value: c1.value.concat(c2.value), + key: c1.key + }; + } + clusters[c1.index] = merged; + clusters.splice(c2.index, 1); + index[c1.key] = merged; + + // Update distances with new merged cluster + for (var _i = 0; _i < clusters.length; _i++) { + var cur = clusters[_i]; + if (c1.key === cur.key) { + dist = Infinity; + } else if (opts.linkage === 'min') { + dist = dists[c1.key][cur.key]; + if (dists[c1.key][cur.key] > dists[c2.key][cur.key]) { + dist = dists[c2.key][cur.key]; + } + } else if (opts.linkage === 'max') { + dist = dists[c1.key][cur.key]; + if (dists[c1.key][cur.key] < dists[c2.key][cur.key]) { + dist = dists[c2.key][cur.key]; + } + } else if (opts.linkage === 'mean') { + dist = (dists[c1.key][cur.key] * c1.size + dists[c2.key][cur.key] * c2.size) / (c1.size + c2.size); + } else { + if (opts.mode === 'dendrogram') dist = getDist(cur.value, c1.value);else dist = getDist(cur.value[0], c1.value[0]); + } + dists[c1.key][cur.key] = dists[cur.key][c1.key] = dist; // distance matrix is symmetric + } + + // Update cached mins + for (var _i2 = 0; _i2 < clusters.length; _i2++) { + var key1 = clusters[_i2].key; + if (mins[key1] === c1.key || mins[key1] === c2.key) { + var _min = key1; + for (var j = 0; j < clusters.length; j++) { + var key2 = clusters[j].key; + if (dists[key1][key2] < dists[key1][_min]) { + _min = key2; + } + } + mins[key1] = _min; + } + clusters[_i2].index = _i2; + } + + // Clean up meta data used for clustering + c1.key = c2.key = c1.index = c2.index = null; + return true; +}; +var getAllChildren = function getAllChildren(root, arr, cy) { + if (!root) return; + if (root.value) { + arr.push(root.value); + } else { + if (root.left) getAllChildren(root.left, arr); + if (root.right) getAllChildren(root.right, arr); + } +}; +var buildDendrogram = function buildDendrogram(root, cy) { + if (!root) return ''; + if (root.left && root.right) { + var leftStr = buildDendrogram(root.left, cy); + var rightStr = buildDendrogram(root.right, cy); + var node = cy.add({ + group: 'nodes', + data: { + id: leftStr + ',' + rightStr + } + }); + cy.add({ + group: 'edges', + data: { + source: leftStr, + target: node.id() + } + }); + cy.add({ + group: 'edges', + data: { + source: rightStr, + target: node.id() + } + }); + return node.id(); + } else if (root.value) { + return root.value.id(); + } +}; +var buildClustersFromTree = function buildClustersFromTree(root, k, cy) { + if (!root) return []; + var left = [], + right = [], + leaves = []; + if (k === 0) { + // don't cut tree, simply return all nodes as 1 single cluster + if (root.left) getAllChildren(root.left, left); + if (root.right) getAllChildren(root.right, right); + leaves = left.concat(right); + return [cy.collection(leaves)]; + } else if (k === 1) { + // cut at root + + if (root.value) { + // leaf node + return [cy.collection(root.value)]; + } else { + if (root.left) getAllChildren(root.left, left); + if (root.right) getAllChildren(root.right, right); + return [cy.collection(left), cy.collection(right)]; + } + } else { + if (root.value) { + return [cy.collection(root.value)]; + } else { + if (root.left) left = buildClustersFromTree(root.left, k - 1, cy); + if (root.right) right = buildClustersFromTree(root.right, k - 1, cy); + return left.concat(right); + } + } +}; + +var hierarchicalClustering = function hierarchicalClustering(options) { + var cy = this.cy(); + var nodes = this.nodes(); + + // Set parameters of algorithm: linkage type, distance metric, etc. + var opts = setOptions$1(options); + var attrs = opts.attributes; + var getDist = function getDist(n1, n2) { + return clusteringDistance(opts.distance, attrs.length, function (i) { + return attrs[i](n1); + }, function (i) { + return attrs[i](n2); + }, n1, n2); + }; + + // Begin hierarchical algorithm + var clusters = []; + var dists = []; // distances between each pair of clusters + var mins = []; // closest cluster for each cluster + var index = []; // hash of all clusters by key + + // In agglomerative (bottom-up) clustering, each node starts as its own cluster + for (var n = 0; n < nodes.length; n++) { + var cluster = { + value: opts.mode === 'dendrogram' ? nodes[n] : [nodes[n]], + key: n, + index: n + }; + clusters[n] = cluster; + index[n] = cluster; + dists[n] = []; + mins[n] = 0; + } + + // Calculate the distance between each pair of clusters + for (var i = 0; i < clusters.length; i++) { + for (var j = 0; j <= i; j++) { + var dist = void 0; + if (opts.mode === 'dendrogram') { + // modes store cluster values differently + dist = i === j ? Infinity : getDist(clusters[i].value, clusters[j].value); + } else { + dist = i === j ? Infinity : getDist(clusters[i].value[0], clusters[j].value[0]); + } + dists[i][j] = dist; + dists[j][i] = dist; + if (dist < dists[i][mins[i]]) { + mins[i] = j; // Cache mins: closest cluster to cluster i is cluster j + } + } + } + + // Find the closest pair of clusters and merge them into a single cluster. + // Update distances between new cluster and each of the old clusters, and loop until threshold reached. + var merged = mergeClosest(clusters, index, dists, mins, opts); + while (merged) { + merged = mergeClosest(clusters, index, dists, mins, opts); + } + var retClusters; + + // Dendrogram mode builds the hierarchy and adds intermediary nodes + edges + // in addition to returning the clusters. + if (opts.mode === 'dendrogram') { + retClusters = buildClustersFromTree(clusters[0], opts.dendrogramDepth, cy); + if (opts.addDendrogram) buildDendrogram(clusters[0], cy); + } else { + // Regular mode simply returns the clusters + + retClusters = new Array(clusters.length); + clusters.forEach(function (cluster, i) { + // Clean up meta data used for clustering + cluster.key = cluster.index = null; + retClusters[i] = cy.collection(cluster.value); + }); + } + return retClusters; +}; +var hierarchicalClustering$1 = { + hierarchicalClustering: hierarchicalClustering, + hca: hierarchicalClustering +}; + +// Implemented by Zoe Xi @zoexi for GSOC 2016 +var defaults$9 = defaults$g({ + distance: 'euclidean', + // distance metric to compare attributes between two nodes + preference: 'median', + // suitability of a data point to serve as an exemplar + damping: 0.8, + // damping factor between [0.5, 1) + maxIterations: 1000, + // max number of iterations to run + minIterations: 100, + // min number of iterations to run in order for clustering to stop + attributes: [// functions to quantify the similarity between any two points + // e.g. node => node.data('weight') + ] +}); +var setOptions = function setOptions(options) { + var dmp = options.damping; + var pref = options.preference; + if (!(0.5 <= dmp && dmp < 1)) { + error("Damping must range on [0.5, 1). Got: ".concat(dmp)); + } + var validPrefs = ['median', 'mean', 'min', 'max']; + if (!(validPrefs.some(function (v) { + return v === pref; + }) || number$1(pref))) { + error("Preference must be one of [".concat(validPrefs.map(function (p) { + return "'".concat(p, "'"); + }).join(', '), "] or a number. Got: ").concat(pref)); + } + return defaults$9(options); +}; + +var getSimilarity = function getSimilarity(type, n1, n2, attributes) { + var attr = function attr(n, i) { + return attributes[i](n); + }; + + // nb negative because similarity should have an inverse relationship to distance + return -clusteringDistance(type, attributes.length, function (i) { + return attr(n1, i); + }, function (i) { + return attr(n2, i); + }, n1, n2); +}; +var getPreference = function getPreference(S, preference) { + // larger preference = greater # of clusters + var p = null; + if (preference === 'median') { + p = median(S); + } else if (preference === 'mean') { + p = mean(S); + } else if (preference === 'min') { + p = min(S); + } else if (preference === 'max') { + p = max(S); + } else { + // Custom preference number, as set by user + p = preference; + } + return p; +}; +var findExemplars = function findExemplars(n, R, A) { + var indices = []; + for (var i = 0; i < n; i++) { + if (R[i * n + i] + A[i * n + i] > 0) { + indices.push(i); + } + } + return indices; +}; +var assignClusters = function assignClusters(n, S, exemplars) { + var clusters = []; + for (var i = 0; i < n; i++) { + var index = -1; + var max = -Infinity; + for (var ei = 0; ei < exemplars.length; ei++) { + var e = exemplars[ei]; + if (S[i * n + e] > max) { + index = e; + max = S[i * n + e]; + } + } + if (index > 0) { + clusters.push(index); + } + } + for (var _ei = 0; _ei < exemplars.length; _ei++) { + clusters[exemplars[_ei]] = exemplars[_ei]; + } + return clusters; +}; +var assign = function assign(n, S, exemplars) { + var clusters = assignClusters(n, S, exemplars); + for (var ei = 0; ei < exemplars.length; ei++) { + var ii = []; + for (var c = 0; c < clusters.length; c++) { + if (clusters[c] === exemplars[ei]) { + ii.push(c); + } + } + var maxI = -1; + var maxSum = -Infinity; + for (var i = 0; i < ii.length; i++) { + var sum = 0; + for (var j = 0; j < ii.length; j++) { + sum += S[ii[j] * n + ii[i]]; + } + if (sum > maxSum) { + maxI = i; + maxSum = sum; + } + } + exemplars[ei] = ii[maxI]; + } + clusters = assignClusters(n, S, exemplars); + return clusters; +}; +var affinityPropagation = function affinityPropagation(options) { + var cy = this.cy(); + var nodes = this.nodes(); + var opts = setOptions(options); + + // Map each node to its position in node array + var id2position = {}; + for (var i = 0; i < nodes.length; i++) { + id2position[nodes[i].id()] = i; + } + + // Begin affinity propagation algorithm + + var n; // number of data points + var n2; // size of matrices + var S; // similarity matrix (1D array) + var p; // preference/suitability of a data point to serve as an exemplar + var R; // responsibility matrix (1D array) + var A; // availability matrix (1D array) + + n = nodes.length; + n2 = n * n; + + // Initialize and build S similarity matrix + S = new Array(n2); + for (var _i = 0; _i < n2; _i++) { + S[_i] = -Infinity; // for cases where two data points shouldn't be linked together + } + + for (var _i2 = 0; _i2 < n; _i2++) { + for (var j = 0; j < n; j++) { + if (_i2 !== j) { + S[_i2 * n + j] = getSimilarity(opts.distance, nodes[_i2], nodes[j], opts.attributes); + } + } + } + + // Place preferences on the diagonal of S + p = getPreference(S, opts.preference); + for (var _i3 = 0; _i3 < n; _i3++) { + S[_i3 * n + _i3] = p; + } + + // Initialize R responsibility matrix + R = new Array(n2); + for (var _i4 = 0; _i4 < n2; _i4++) { + R[_i4] = 0.0; + } + + // Initialize A availability matrix + A = new Array(n2); + for (var _i5 = 0; _i5 < n2; _i5++) { + A[_i5] = 0.0; + } + var old = new Array(n); + var Rp = new Array(n); + var se = new Array(n); + for (var _i6 = 0; _i6 < n; _i6++) { + old[_i6] = 0.0; + Rp[_i6] = 0.0; + se[_i6] = 0; + } + var e = new Array(n * opts.minIterations); + for (var _i7 = 0; _i7 < e.length; _i7++) { + e[_i7] = 0; + } + var iter; + for (iter = 0; iter < opts.maxIterations; iter++) { + // main algorithmic loop + + // Update R responsibility matrix + for (var _i8 = 0; _i8 < n; _i8++) { + var max = -Infinity, + max2 = -Infinity, + maxI = -1, + AS = 0.0; + for (var _j = 0; _j < n; _j++) { + old[_j] = R[_i8 * n + _j]; + AS = A[_i8 * n + _j] + S[_i8 * n + _j]; + if (AS >= max) { + max2 = max; + max = AS; + maxI = _j; + } else if (AS > max2) { + max2 = AS; + } + } + for (var _j2 = 0; _j2 < n; _j2++) { + R[_i8 * n + _j2] = (1 - opts.damping) * (S[_i8 * n + _j2] - max) + opts.damping * old[_j2]; + } + R[_i8 * n + maxI] = (1 - opts.damping) * (S[_i8 * n + maxI] - max2) + opts.damping * old[maxI]; + } + + // Update A availability matrix + for (var _i9 = 0; _i9 < n; _i9++) { + var sum = 0; + for (var _j3 = 0; _j3 < n; _j3++) { + old[_j3] = A[_j3 * n + _i9]; + Rp[_j3] = Math.max(0, R[_j3 * n + _i9]); + sum += Rp[_j3]; + } + sum -= Rp[_i9]; + Rp[_i9] = R[_i9 * n + _i9]; + sum += Rp[_i9]; + for (var _j4 = 0; _j4 < n; _j4++) { + A[_j4 * n + _i9] = (1 - opts.damping) * Math.min(0, sum - Rp[_j4]) + opts.damping * old[_j4]; + } + A[_i9 * n + _i9] = (1 - opts.damping) * (sum - Rp[_i9]) + opts.damping * old[_i9]; + } + + // Check for convergence + var K = 0; + for (var _i10 = 0; _i10 < n; _i10++) { + var E = A[_i10 * n + _i10] + R[_i10 * n + _i10] > 0 ? 1 : 0; + e[iter % opts.minIterations * n + _i10] = E; + K += E; + } + if (K > 0 && (iter >= opts.minIterations - 1 || iter == opts.maxIterations - 1)) { + var _sum = 0; + for (var _i11 = 0; _i11 < n; _i11++) { + se[_i11] = 0; + for (var _j5 = 0; _j5 < opts.minIterations; _j5++) { + se[_i11] += e[_j5 * n + _i11]; + } + if (se[_i11] === 0 || se[_i11] === opts.minIterations) { + _sum++; + } + } + if (_sum === n) { + // then we have convergence + break; + } + } + } + + // Identify exemplars (cluster centers) + var exemplarsIndices = findExemplars(n, R, A); + + // Assign nodes to clusters + var clusterIndices = assign(n, S, exemplarsIndices); + var clusters = {}; + for (var c = 0; c < exemplarsIndices.length; c++) { + clusters[exemplarsIndices[c]] = []; + } + for (var _i12 = 0; _i12 < nodes.length; _i12++) { + var pos = id2position[nodes[_i12].id()]; + var clusterIndex = clusterIndices[pos]; + if (clusterIndex != null) { + // the node may have not been assigned a cluster if no valid attributes were specified + clusters[clusterIndex].push(nodes[_i12]); + } + } + var retClusters = new Array(exemplarsIndices.length); + for (var _c = 0; _c < exemplarsIndices.length; _c++) { + retClusters[_c] = cy.collection(clusters[exemplarsIndices[_c]]); + } + return retClusters; +}; +var affinityPropagation$1 = { + affinityPropagation: affinityPropagation, + ap: affinityPropagation +}; + +var hierholzerDefaults = defaults$g({ + root: undefined, + directed: false +}); +var elesfn$k = { + hierholzer: function hierholzer(options) { + if (!plainObject(options)) { + var args = arguments; + options = { + root: args[0], + directed: args[1] + }; + } + var _hierholzerDefaults = hierholzerDefaults(options), + root = _hierholzerDefaults.root, + directed = _hierholzerDefaults.directed; + var eles = this; + var dflag = false; + var oddIn; + var oddOut; + var startVertex; + if (root) startVertex = string(root) ? this.filter(root)[0].id() : root[0].id(); + var nodes = {}; + var edges = {}; + if (directed) { + eles.forEach(function (ele) { + var id = ele.id(); + if (ele.isNode()) { + var ind = ele.indegree(true); + var outd = ele.outdegree(true); + var d1 = ind - outd; + var d2 = outd - ind; + if (d1 == 1) { + if (oddIn) dflag = true;else oddIn = id; + } else if (d2 == 1) { + if (oddOut) dflag = true;else oddOut = id; + } else if (d2 > 1 || d1 > 1) { + dflag = true; + } + nodes[id] = []; + ele.outgoers().forEach(function (e) { + if (e.isEdge()) nodes[id].push(e.id()); + }); + } else { + edges[id] = [undefined, ele.target().id()]; + } + }); + } else { + eles.forEach(function (ele) { + var id = ele.id(); + if (ele.isNode()) { + var d = ele.degree(true); + if (d % 2) { + if (!oddIn) oddIn = id;else if (!oddOut) oddOut = id;else dflag = true; + } + nodes[id] = []; + ele.connectedEdges().forEach(function (e) { + return nodes[id].push(e.id()); + }); + } else { + edges[id] = [ele.source().id(), ele.target().id()]; + } + }); + } + var result = { + found: false, + trail: undefined + }; + if (dflag) return result;else if (oddOut && oddIn) { + if (directed) { + if (startVertex && oddOut != startVertex) { + return result; + } + startVertex = oddOut; + } else { + if (startVertex && oddOut != startVertex && oddIn != startVertex) { + return result; + } else if (!startVertex) { + startVertex = oddOut; + } + } + } else { + if (!startVertex) startVertex = eles[0].id(); + } + var walk = function walk(v) { + var currentNode = v; + var subtour = [v]; + var adj, adjTail, adjHead; + while (nodes[currentNode].length) { + adj = nodes[currentNode].shift(); + adjTail = edges[adj][0]; + adjHead = edges[adj][1]; + if (currentNode != adjHead) { + nodes[adjHead] = nodes[adjHead].filter(function (e) { + return e != adj; + }); + currentNode = adjHead; + } else if (!directed && currentNode != adjTail) { + nodes[adjTail] = nodes[adjTail].filter(function (e) { + return e != adj; + }); + currentNode = adjTail; + } + subtour.unshift(adj); + subtour.unshift(currentNode); + } + return subtour; + }; + var trail = []; + var subtour = []; + subtour = walk(startVertex); + while (subtour.length != 1) { + if (nodes[subtour[0]].length == 0) { + trail.unshift(eles.getElementById(subtour.shift())); + trail.unshift(eles.getElementById(subtour.shift())); + } else { + subtour = walk(subtour.shift()).concat(subtour); + } + } + trail.unshift(eles.getElementById(subtour.shift())); // final node + + for (var d in nodes) { + if (nodes[d].length) { + return result; + } + } + result.found = true; + result.trail = this.spawn(trail, true); + return result; + } +}; + +var hopcroftTarjanBiconnected = function hopcroftTarjanBiconnected() { + var eles = this; + var nodes = {}; + var id = 0; + var edgeCount = 0; + var components = []; + var stack = []; + var visitedEdges = {}; + var buildComponent = function buildComponent(x, y) { + var i = stack.length - 1; + var cutset = []; + var component = eles.spawn(); + while (stack[i].x != x || stack[i].y != y) { + cutset.push(stack.pop().edge); + i--; + } + cutset.push(stack.pop().edge); + cutset.forEach(function (edge) { + var connectedNodes = edge.connectedNodes().intersection(eles); + component.merge(edge); + connectedNodes.forEach(function (node) { + var nodeId = node.id(); + var connectedEdges = node.connectedEdges().intersection(eles); + component.merge(node); + if (!nodes[nodeId].cutVertex) { + component.merge(connectedEdges); + } else { + component.merge(connectedEdges.filter(function (edge) { + return edge.isLoop(); + })); + } + }); + }); + components.push(component); + }; + var biconnectedSearch = function biconnectedSearch(root, currentNode, parent) { + if (root === parent) edgeCount += 1; + nodes[currentNode] = { + id: id, + low: id++, + cutVertex: false + }; + var edges = eles.getElementById(currentNode).connectedEdges().intersection(eles); + if (edges.size() === 0) { + components.push(eles.spawn(eles.getElementById(currentNode))); + } else { + var sourceId, targetId, otherNodeId, edgeId; + edges.forEach(function (edge) { + sourceId = edge.source().id(); + targetId = edge.target().id(); + otherNodeId = sourceId === currentNode ? targetId : sourceId; + if (otherNodeId !== parent) { + edgeId = edge.id(); + if (!visitedEdges[edgeId]) { + visitedEdges[edgeId] = true; + stack.push({ + x: currentNode, + y: otherNodeId, + edge: edge + }); + } + if (!(otherNodeId in nodes)) { + biconnectedSearch(root, otherNodeId, currentNode); + nodes[currentNode].low = Math.min(nodes[currentNode].low, nodes[otherNodeId].low); + if (nodes[currentNode].id <= nodes[otherNodeId].low) { + nodes[currentNode].cutVertex = true; + buildComponent(currentNode, otherNodeId); + } + } else { + nodes[currentNode].low = Math.min(nodes[currentNode].low, nodes[otherNodeId].id); + } + } + }); + } + }; + eles.forEach(function (ele) { + if (ele.isNode()) { + var nodeId = ele.id(); + if (!(nodeId in nodes)) { + edgeCount = 0; + biconnectedSearch(nodeId, nodeId); + nodes[nodeId].cutVertex = edgeCount > 1; + } + } + }); + var cutVertices = Object.keys(nodes).filter(function (id) { + return nodes[id].cutVertex; + }).map(function (id) { + return eles.getElementById(id); + }); + return { + cut: eles.spawn(cutVertices), + components: components + }; +}; +var hopcroftTarjanBiconnected$1 = { + hopcroftTarjanBiconnected: hopcroftTarjanBiconnected, + htbc: hopcroftTarjanBiconnected, + htb: hopcroftTarjanBiconnected, + hopcroftTarjanBiconnectedComponents: hopcroftTarjanBiconnected +}; + +var tarjanStronglyConnected = function tarjanStronglyConnected() { + var eles = this; + var nodes = {}; + var index = 0; + var components = []; + var stack = []; + var cut = eles.spawn(eles); + var stronglyConnectedSearch = function stronglyConnectedSearch(sourceNodeId) { + stack.push(sourceNodeId); + nodes[sourceNodeId] = { + index: index, + low: index++, + explored: false + }; + var connectedEdges = eles.getElementById(sourceNodeId).connectedEdges().intersection(eles); + connectedEdges.forEach(function (edge) { + var targetNodeId = edge.target().id(); + if (targetNodeId !== sourceNodeId) { + if (!(targetNodeId in nodes)) { + stronglyConnectedSearch(targetNodeId); + } + if (!nodes[targetNodeId].explored) { + nodes[sourceNodeId].low = Math.min(nodes[sourceNodeId].low, nodes[targetNodeId].low); + } + } + }); + if (nodes[sourceNodeId].index === nodes[sourceNodeId].low) { + var componentNodes = eles.spawn(); + for (;;) { + var nodeId = stack.pop(); + componentNodes.merge(eles.getElementById(nodeId)); + nodes[nodeId].low = nodes[sourceNodeId].index; + nodes[nodeId].explored = true; + if (nodeId === sourceNodeId) { + break; + } + } + var componentEdges = componentNodes.edgesWith(componentNodes); + var component = componentNodes.merge(componentEdges); + components.push(component); + cut = cut.difference(component); + } + }; + eles.forEach(function (ele) { + if (ele.isNode()) { + var nodeId = ele.id(); + if (!(nodeId in nodes)) { + stronglyConnectedSearch(nodeId); + } + } + }); + return { + cut: cut, + components: components + }; +}; +var tarjanStronglyConnected$1 = { + tarjanStronglyConnected: tarjanStronglyConnected, + tsc: tarjanStronglyConnected, + tscc: tarjanStronglyConnected, + tarjanStronglyConnectedComponents: tarjanStronglyConnected +}; + +var elesfn$j = {}; +[elesfn$v, elesfn$u, elesfn$t, elesfn$s, elesfn$r, elesfn$q, elesfn$p, elesfn$o, elesfn$n, elesfn$m, elesfn$l, markovClustering$1, kClustering, hierarchicalClustering$1, affinityPropagation$1, elesfn$k, hopcroftTarjanBiconnected$1, tarjanStronglyConnected$1].forEach(function (props) { + extend(elesfn$j, props); +}); + +/*! +Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable +Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) +Licensed under The MIT License (http://opensource.org/licenses/MIT) +*/ + +/* promise states [Promises/A+ 2.1] */ +var STATE_PENDING = 0; /* [Promises/A+ 2.1.1] */ +var STATE_FULFILLED = 1; /* [Promises/A+ 2.1.2] */ +var STATE_REJECTED = 2; /* [Promises/A+ 2.1.3] */ + +/* promise object constructor */ +var api = function api(executor) { + /* optionally support non-constructor/plain-function call */ + if (!(this instanceof api)) return new api(executor); + + /* initialize object */ + this.id = 'Thenable/1.0.7'; + this.state = STATE_PENDING; /* initial state */ + this.fulfillValue = undefined; /* initial value */ /* [Promises/A+ 1.3, 2.1.2.2] */ + this.rejectReason = undefined; /* initial reason */ /* [Promises/A+ 1.5, 2.1.3.2] */ + this.onFulfilled = []; /* initial handlers */ + this.onRejected = []; /* initial handlers */ + + /* provide optional information-hiding proxy */ + this.proxy = { + then: this.then.bind(this) + }; + + /* support optional executor function */ + if (typeof executor === 'function') executor.call(this, this.fulfill.bind(this), this.reject.bind(this)); +}; + +/* promise API methods */ +api.prototype = { + /* promise resolving methods */ + fulfill: function fulfill(value) { + return deliver(this, STATE_FULFILLED, 'fulfillValue', value); + }, + reject: function reject(value) { + return deliver(this, STATE_REJECTED, 'rejectReason', value); + }, + /* "The then Method" [Promises/A+ 1.1, 1.2, 2.2] */ + then: function then(onFulfilled, onRejected) { + var curr = this; + var next = new api(); /* [Promises/A+ 2.2.7] */ + curr.onFulfilled.push(resolver(onFulfilled, next, 'fulfill')); /* [Promises/A+ 2.2.2/2.2.6] */ + curr.onRejected.push(resolver(onRejected, next, 'reject')); /* [Promises/A+ 2.2.3/2.2.6] */ + execute(curr); + return next.proxy; /* [Promises/A+ 2.2.7, 3.3] */ + } +}; + +/* deliver an action */ +var deliver = function deliver(curr, state, name, value) { + if (curr.state === STATE_PENDING) { + curr.state = state; /* [Promises/A+ 2.1.2.1, 2.1.3.1] */ + curr[name] = value; /* [Promises/A+ 2.1.2.2, 2.1.3.2] */ + execute(curr); + } + return curr; +}; + +/* execute all handlers */ +var execute = function execute(curr) { + if (curr.state === STATE_FULFILLED) execute_handlers(curr, 'onFulfilled', curr.fulfillValue);else if (curr.state === STATE_REJECTED) execute_handlers(curr, 'onRejected', curr.rejectReason); +}; + +/* execute particular set of handlers */ +var execute_handlers = function execute_handlers(curr, name, value) { + /* global setImmediate: true */ + /* global setTimeout: true */ + + /* short-circuit processing */ + if (curr[name].length === 0) return; + + /* iterate over all handlers, exactly once */ + var handlers = curr[name]; + curr[name] = []; /* [Promises/A+ 2.2.2.3, 2.2.3.3] */ + var func = function func() { + for (var i = 0; i < handlers.length; i++) { + handlers[i](value); + } /* [Promises/A+ 2.2.5] */ + }; + + /* execute procedure asynchronously */ /* [Promises/A+ 2.2.4, 3.1] */ + if (typeof setImmediate === 'function') setImmediate(func);else setTimeout(func, 0); +}; + +/* generate a resolver function */ +var resolver = function resolver(cb, next, method) { + return function (value) { + if (typeof cb !== 'function') /* [Promises/A+ 2.2.1, 2.2.7.3, 2.2.7.4] */ + next[method].call(next, value); /* [Promises/A+ 2.2.7.3, 2.2.7.4] */else { + var result; + try { + result = cb(value); + } /* [Promises/A+ 2.2.2.1, 2.2.3.1, 2.2.5, 3.2] */ catch (e) { + next.reject(e); /* [Promises/A+ 2.2.7.2] */ + return; + } + resolve(next, result); /* [Promises/A+ 2.2.7.1] */ + } + }; +}; + +/* "Promise Resolution Procedure" */ /* [Promises/A+ 2.3] */ +var resolve = function resolve(promise, x) { + /* sanity check arguments */ /* [Promises/A+ 2.3.1] */ + if (promise === x || promise.proxy === x) { + promise.reject(new TypeError('cannot resolve promise with itself')); + return; + } + + /* surgically check for a "then" method + (mainly to just call the "getter" of "then" only once) */ + var then; + if (_typeof(x) === 'object' && x !== null || typeof x === 'function') { + try { + then = x.then; + } /* [Promises/A+ 2.3.3.1, 3.5] */ catch (e) { + promise.reject(e); /* [Promises/A+ 2.3.3.2] */ + return; + } + } + + /* handle own Thenables [Promises/A+ 2.3.2] + and similar "thenables" [Promises/A+ 2.3.3] */ + if (typeof then === 'function') { + var resolved = false; + try { + /* call retrieved "then" method */ /* [Promises/A+ 2.3.3.3] */ + then.call(x, /* resolvePromise */ /* [Promises/A+ 2.3.3.3.1] */ + function (y) { + if (resolved) return; + resolved = true; /* [Promises/A+ 2.3.3.3.3] */ + if (y === x) /* [Promises/A+ 3.6] */ + promise.reject(new TypeError('circular thenable chain'));else resolve(promise, y); + }, /* rejectPromise */ /* [Promises/A+ 2.3.3.3.2] */ + function (r) { + if (resolved) return; + resolved = true; /* [Promises/A+ 2.3.3.3.3] */ + promise.reject(r); + }); + } catch (e) { + if (!resolved) /* [Promises/A+ 2.3.3.3.3] */ + promise.reject(e); /* [Promises/A+ 2.3.3.3.4] */ + } + + return; + } + + /* handle other values */ + promise.fulfill(x); /* [Promises/A+ 2.3.4, 2.3.3.4] */ +}; + +// so we always have Promise.all() +api.all = function (ps) { + return new api(function (resolveAll, rejectAll) { + var vals = new Array(ps.length); + var doneCount = 0; + var fulfill = function fulfill(i, val) { + vals[i] = val; + doneCount++; + if (doneCount === ps.length) { + resolveAll(vals); + } + }; + for (var i = 0; i < ps.length; i++) { + (function (i) { + var p = ps[i]; + var isPromise = p != null && p.then != null; + if (isPromise) { + p.then(function (val) { + fulfill(i, val); + }, function (err) { + rejectAll(err); + }); + } else { + var val = p; + fulfill(i, val); + } + })(i); + } + }); +}; +api.resolve = function (val) { + return new api(function (resolve, reject) { + resolve(val); + }); +}; +api.reject = function (val) { + return new api(function (resolve, reject) { + reject(val); + }); +}; +var Promise$1 = typeof Promise !== 'undefined' ? Promise : api; // eslint-disable-line no-undef + +var Animation = function Animation(target, opts, opts2) { + var isCore = core(target); + var isEle = !isCore; + var _p = this._private = extend({ + duration: 1000 + }, opts, opts2); + _p.target = target; + _p.style = _p.style || _p.css; + _p.started = false; + _p.playing = false; + _p.hooked = false; + _p.applying = false; + _p.progress = 0; + _p.completes = []; + _p.frames = []; + if (_p.complete && fn$6(_p.complete)) { + _p.completes.push(_p.complete); + } + if (isEle) { + var pos = target.position(); + _p.startPosition = _p.startPosition || { + x: pos.x, + y: pos.y + }; + _p.startStyle = _p.startStyle || target.cy().style().getAnimationStartStyle(target, _p.style); + } + if (isCore) { + var pan = target.pan(); + _p.startPan = { + x: pan.x, + y: pan.y + }; + _p.startZoom = target.zoom(); + } + + // for future timeline/animations impl + this.length = 1; + this[0] = this; +}; +var anifn = Animation.prototype; +extend(anifn, { + instanceString: function instanceString() { + return 'animation'; + }, + hook: function hook() { + var _p = this._private; + if (!_p.hooked) { + // add to target's animation queue + var q; + var tAni = _p.target._private.animation; + if (_p.queue) { + q = tAni.queue; + } else { + q = tAni.current; + } + q.push(this); + + // add to the animation loop pool + if (elementOrCollection(_p.target)) { + _p.target.cy().addToAnimationPool(_p.target); + } + _p.hooked = true; + } + return this; + }, + play: function play() { + var _p = this._private; + + // autorewind + if (_p.progress === 1) { + _p.progress = 0; + } + _p.playing = true; + _p.started = false; // needs to be started by animation loop + _p.stopped = false; + this.hook(); + + // the animation loop will start the animation... + + return this; + }, + playing: function playing() { + return this._private.playing; + }, + apply: function apply() { + var _p = this._private; + _p.applying = true; + _p.started = false; // needs to be started by animation loop + _p.stopped = false; + this.hook(); + + // the animation loop will apply the animation at this progress + + return this; + }, + applying: function applying() { + return this._private.applying; + }, + pause: function pause() { + var _p = this._private; + _p.playing = false; + _p.started = false; + return this; + }, + stop: function stop() { + var _p = this._private; + _p.playing = false; + _p.started = false; + _p.stopped = true; // to be removed from animation queues + + return this; + }, + rewind: function rewind() { + return this.progress(0); + }, + fastforward: function fastforward() { + return this.progress(1); + }, + time: function time(t) { + var _p = this._private; + if (t === undefined) { + return _p.progress * _p.duration; + } else { + return this.progress(t / _p.duration); + } + }, + progress: function progress(p) { + var _p = this._private; + var wasPlaying = _p.playing; + if (p === undefined) { + return _p.progress; + } else { + if (wasPlaying) { + this.pause(); + } + _p.progress = p; + _p.started = false; + if (wasPlaying) { + this.play(); + } + } + return this; + }, + completed: function completed() { + return this._private.progress === 1; + }, + reverse: function reverse() { + var _p = this._private; + var wasPlaying = _p.playing; + if (wasPlaying) { + this.pause(); + } + _p.progress = 1 - _p.progress; + _p.started = false; + var swap = function swap(a, b) { + var _pa = _p[a]; + if (_pa == null) { + return; + } + _p[a] = _p[b]; + _p[b] = _pa; + }; + swap('zoom', 'startZoom'); + swap('pan', 'startPan'); + swap('position', 'startPosition'); + + // swap styles + if (_p.style) { + for (var i = 0; i < _p.style.length; i++) { + var prop = _p.style[i]; + var name = prop.name; + var startStyleProp = _p.startStyle[name]; + _p.startStyle[name] = prop; + _p.style[i] = startStyleProp; + } + } + if (wasPlaying) { + this.play(); + } + return this; + }, + promise: function promise(type) { + var _p = this._private; + var arr; + switch (type) { + case 'frame': + arr = _p.frames; + break; + default: + case 'complete': + case 'completed': + arr = _p.completes; + } + return new Promise$1(function (resolve, reject) { + arr.push(function () { + resolve(); + }); + }); + } +}); +anifn.complete = anifn.completed; +anifn.run = anifn.play; +anifn.running = anifn.playing; + +var define$3 = { + animated: function animated() { + return function animatedImpl() { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return false; + } + var ele = all[0]; + if (ele) { + return ele._private.animation.current.length > 0; + } + }; + }, + // animated + + clearQueue: function clearQueue() { + return function clearQueueImpl() { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + ele._private.animation.queue = []; + } + return this; + }; + }, + // clearQueue + + delay: function delay() { + return function delayImpl(time, complete) { + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + return this.animate({ + delay: time, + duration: time, + complete: complete + }); + }; + }, + // delay + + delayAnimation: function delayAnimation() { + return function delayAnimationImpl(time, complete) { + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + return this.animation({ + delay: time, + duration: time, + complete: complete + }); + }; + }, + // delay + + animation: function animation() { + return function animationImpl(properties, params) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + var isCore = !selfIsArrayLike; + var isEles = !isCore; + if (!cy.styleEnabled()) { + return this; + } + var style = cy.style(); + properties = extend({}, properties, params); + var propertiesEmpty = Object.keys(properties).length === 0; + if (propertiesEmpty) { + return new Animation(all[0], properties); // nothing to animate + } + + if (properties.duration === undefined) { + properties.duration = 400; + } + switch (properties.duration) { + case 'slow': + properties.duration = 600; + break; + case 'fast': + properties.duration = 200; + break; + } + if (isEles) { + properties.style = style.getPropsList(properties.style || properties.css); + properties.css = undefined; + } + if (isEles && properties.renderedPosition != null) { + var rpos = properties.renderedPosition; + var pan = cy.pan(); + var zoom = cy.zoom(); + properties.position = renderedToModelPosition(rpos, zoom, pan); + } + + // override pan w/ panBy if set + if (isCore && properties.panBy != null) { + var panBy = properties.panBy; + var cyPan = cy.pan(); + properties.pan = { + x: cyPan.x + panBy.x, + y: cyPan.y + panBy.y + }; + } + + // override pan w/ center if set + var center = properties.center || properties.centre; + if (isCore && center != null) { + var centerPan = cy.getCenterPan(center.eles, properties.zoom); + if (centerPan != null) { + properties.pan = centerPan; + } + } + + // override pan & zoom w/ fit if set + if (isCore && properties.fit != null) { + var fit = properties.fit; + var fitVp = cy.getFitViewport(fit.eles || fit.boundingBox, fit.padding); + if (fitVp != null) { + properties.pan = fitVp.pan; + properties.zoom = fitVp.zoom; + } + } + + // override zoom (& potentially pan) w/ zoom obj if set + if (isCore && plainObject(properties.zoom)) { + var vp = cy.getZoomedViewport(properties.zoom); + if (vp != null) { + if (vp.zoomed) { + properties.zoom = vp.zoom; + } + if (vp.panned) { + properties.pan = vp.pan; + } + } else { + properties.zoom = null; // an inavalid zoom (e.g. no delta) gets automatically destroyed + } + } + + return new Animation(all[0], properties); + }; + }, + // animate + + animate: function animate() { + return function animateImpl(properties, params) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + if (params) { + properties = extend({}, properties, params); + } + + // manually hook and run the animation + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + var queue = ele.animated() && (properties.queue === undefined || properties.queue); + var ani = ele.animation(properties, queue ? { + queue: true + } : undefined); + ani.play(); + } + return this; // chaining + }; + }, + + // animate + + stop: function stop() { + return function stopImpl(clearQueue, jumpToEnd) { + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var cy = this._private.cy || this; + if (!cy.styleEnabled()) { + return this; + } + for (var i = 0; i < all.length; i++) { + var ele = all[i]; + var _p = ele._private; + var anis = _p.animation.current; + for (var j = 0; j < anis.length; j++) { + var ani = anis[j]; + var ani_p = ani._private; + if (jumpToEnd) { + // next iteration of the animation loop, the animation + // will go straight to the end and be removed + ani_p.duration = 0; + } + } + + // clear the queue of future animations + if (clearQueue) { + _p.animation.queue = []; + } + if (!jumpToEnd) { + _p.animation.current = []; + } + } + + // we have to notify (the animation loop doesn't do it for us on `stop`) + cy.notify('draw'); + return this; + }; + } // stop +}; // define + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +var isArray_1 = isArray; + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; + +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + if (isArray_1(value)) { + return false; + } + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol_1(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); +} + +var _isKey = isKey; + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject_1(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = _baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +var isFunction_1 = isFunction; + +/** Used to detect overreaching core-js shims. */ +var coreJsData = _root['__core-js_shared__']; + +var _coreJsData = coreJsData; + +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); + +/** + * Checks if `func` has its source masked. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. + */ +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); +} + +var _isMasked = isMasked; + +/** Used for built-in method references. */ +var funcProto$1 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$1 = funcProto$1.toString; + +/** + * Converts `func` to its source code. + * + * @private + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. + */ +function toSource(func) { + if (func != null) { + try { + return funcToString$1.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; +} + +var _toSource = toSource; + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto$3 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$3.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty$3).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); + +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject_1(value) || _isMasked(value)) { + return false; + } + var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor; + return pattern.test(_toSource(value)); +} + +var _baseIsNative = baseIsNative; + +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue$1(object, key) { + return object == null ? undefined : object[key]; +} + +var _getValue = getValue$1; + +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = _getValue(object, key); + return _baseIsNative(value) ? value : undefined; +} + +var _getNative = getNative; + +/* Built-in method references that are verified to be native. */ +var nativeCreate = _getNative(Object, 'create'); + +var _nativeCreate = nativeCreate; + +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = _nativeCreate ? _nativeCreate(null) : {}; + this.size = 0; +} + +var _hashClear = hashClear; + +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; +} + +var _hashDelete = hashDelete; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$2.hasOwnProperty; + +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (_nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED$1 ? undefined : result; + } + return hasOwnProperty$2.call(data, key) ? data[key] : undefined; +} + +var _hashGet = hashGet; + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$1.hasOwnProperty; + +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key); +} + +var _hashHas = hashHas; + +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; +} + +var _hashSet = hashSet; + +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = _hashClear; +Hash.prototype['delete'] = _hashDelete; +Hash.prototype.get = _hashGet; +Hash.prototype.has = _hashHas; +Hash.prototype.set = _hashSet; + +var _Hash = Hash; + +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} + +var _listCacheClear = listCacheClear; + +/** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ +function eq(value, other) { + return value === other || (value !== value && other !== other); +} + +var eq_1 = eq; + +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq_1(array[length][0], key)) { + return length; + } + } + return -1; +} + +var _assocIndexOf = assocIndexOf; + +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; + +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + return false; + } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + --this.size; + return true; +} + +var _listCacheDelete = listCacheDelete; + +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} + +var _listCacheGet = listCacheGet; + +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return _assocIndexOf(this.__data__, key) > -1; +} + +var _listCacheHas = listCacheHas; + +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = _assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; + } + return this; +} + +var _listCacheSet = listCacheSet; + +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `ListCache`. +ListCache.prototype.clear = _listCacheClear; +ListCache.prototype['delete'] = _listCacheDelete; +ListCache.prototype.get = _listCacheGet; +ListCache.prototype.has = _listCacheHas; +ListCache.prototype.set = _listCacheSet; + +var _ListCache = ListCache; + +/* Built-in method references that are verified to be native. */ +var Map$1 = _getNative(_root, 'Map'); + +var _Map = Map$1; + +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new _Hash, + 'map': new (_Map || _ListCache), + 'string': new _Hash + }; +} + +var _mapCacheClear = mapCacheClear; + +/** + * Checks if `value` is suitable for use as unique object key. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. + */ +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); +} + +var _isKeyable = isKeyable; + +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return _isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; +} + +var _getMapData = getMapData; + +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + var result = _getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; +} + +var _mapCacheDelete = mapCacheDelete; + +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return _getMapData(this, key).get(key); +} + +var _mapCacheGet = mapCacheGet; + +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return _getMapData(this, key).has(key); +} + +var _mapCacheHas = mapCacheHas; + +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + var data = _getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; +} + +var _mapCacheSet = mapCacheSet; + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `MapCache`. +MapCache.prototype.clear = _mapCacheClear; +MapCache.prototype['delete'] = _mapCacheDelete; +MapCache.prototype.get = _mapCacheGet; +MapCache.prototype.has = _mapCacheHas; +MapCache.prototype.set = _mapCacheSet; + +var _MapCache = MapCache; + +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; + +/** + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. + * + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; + */ +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; + + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize.Cache || _MapCache); + return memoized; +} + +// Expose `MapCache`. +memoize.Cache = _MapCache; + +var memoize_1 = memoize; + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + +/** + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. + * + * @private + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. + */ +function memoizeCapped(func) { + var result = memoize_1(func, function(key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; + }); + + var cache = result.cache; + return result; +} + +var _memoizeCapped = memoizeCapped; + +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + +/** + * Converts `string` to a property path array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. + */ +var stringToPath = _memoizeCapped(function(string) { + var result = []; + if (string.charCodeAt(0) === 46 /* . */) { + result.push(''); + } + string.replace(rePropName, function(match, number, quote, subString) { + result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +}); + +var _stringToPath = stringToPath; + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +var _arrayMap = arrayMap; + +/** Used as references for various `Number` constants. */ +var INFINITY$1 = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = _Symbol ? _Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray_1(value)) { + // Recursively convert values (susceptible to call stack limits). + return _arrayMap(value, baseToString) + ''; + } + if (isSymbol_1(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result; +} + +var _baseToString = baseToString; + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString$1(value) { + return value == null ? '' : _baseToString(value); +} + +var toString_1 = toString$1; + +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value, object) { + if (isArray_1(value)) { + return value; + } + return _isKey(value, object) ? [value] : _stringToPath(toString_1(value)); +} + +var _castPath = castPath; + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** + * Converts `value` to a string key if it's not a string or symbol. + * + * @private + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. + */ +function toKey(value) { + if (typeof value == 'string' || isSymbol_1(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +var _toKey = toKey; + +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = _castPath(path, object); + + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[_toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; +} + +var _baseGet = baseGet; + +/** + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' + */ +function get(object, path, defaultValue) { + var result = object == null ? undefined : _baseGet(object, path); + return result === undefined ? defaultValue : result; +} + +var get_1 = get; + +var defineProperty = (function() { + try { + var func = _getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}()); + +var _defineProperty = defineProperty; + +/** + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function baseAssignValue(object, key, value) { + if (key == '__proto__' && _defineProperty) { + _defineProperty(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; + } +} + +var _baseAssignValue = baseAssignValue; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. + * + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty.call(object, key) && eq_1(objValue, value)) || + (value === undefined && !(key in object))) { + _baseAssignValue(object, key, value); + } +} + +var _assignValue = assignValue; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +var _isIndex = isIndex; + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject_1(object)) { + return object; + } + path = _castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = _toKey(path[index]), + newValue = value; + + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject_1(objValue) + ? objValue + : (_isIndex(path[index + 1]) ? [] : {}); + } + } + _assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +var _baseSet = baseSet; + +/** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ +function set(object, path, value) { + return object == null ? object : _baseSet(object, path, value); +} + +var set_1 = set; + +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function copyArray(source, array) { + var index = -1, + length = source.length; + + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} + +var _copyArray = copyArray; + +/** + * Converts `value` to a property path array. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Util + * @param {*} value The value to convert. + * @returns {Array} Returns the new property path array. + * @example + * + * _.toPath('a.b.c'); + * // => ['a', 'b', 'c'] + * + * _.toPath('a[0].b.c'); + * // => ['a', '0', 'b', 'c'] + */ +function toPath(value) { + if (isArray_1(value)) { + return _arrayMap(value, _toKey); + } + return isSymbol_1(value) ? [value] : _copyArray(_stringToPath(toString_1(value))); +} + +var toPath_1 = toPath; + +var define$2 = { + // access data field + data: function data(params) { + var defaults = { + field: 'data', + bindingEvent: 'data', + allowBinding: false, + allowSetting: false, + allowGetting: false, + settingEvent: 'data', + settingTriggersEvent: false, + triggerFnName: 'trigger', + immutableKeys: {}, + // key => true if immutable + updateStyle: false, + beforeGet: function beforeGet(self) {}, + beforeSet: function beforeSet(self, obj) {}, + onSet: function onSet(self) {}, + canSet: function canSet(self) { + return true; + } + }; + params = extend({}, defaults, params); + return function dataImpl(name, value) { + var p = params; + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + var single = selfIsArrayLike ? self[0] : self; + + // .data('foo', ...) + if (string(name)) { + // set or get property + var isPathLike = name.indexOf('.') !== -1; // there might be a normal field with a dot + var path = isPathLike && toPath_1(name); + + // .data('foo') + if (p.allowGetting && value === undefined) { + // get + + var ret; + if (single) { + p.beforeGet(single); + + // check if it's path and a field with the same name doesn't exist + if (path && single._private[p.field][name] === undefined) { + ret = get_1(single._private[p.field], path); + } else { + ret = single._private[p.field][name]; + } + } + return ret; + + // .data('foo', 'bar') + } else if (p.allowSetting && value !== undefined) { + // set + var valid = !p.immutableKeys[name]; + if (valid) { + var change = _defineProperty$1({}, name, value); + p.beforeSet(self, change); + for (var i = 0, l = all.length; i < l; i++) { + var ele = all[i]; + if (p.canSet(ele)) { + if (path && single._private[p.field][name] === undefined) { + set_1(ele._private[p.field], path, value); + } else { + ele._private[p.field][name] = value; + } + } + } + + // update mappers if asked + if (p.updateStyle) { + self.updateStyle(); + } + + // call onSet callback + p.onSet(self); + if (p.settingTriggersEvent) { + self[p.triggerFnName](p.settingEvent); + } + } + } + + // .data({ 'foo': 'bar' }) + } else if (p.allowSetting && plainObject(name)) { + // extend + var obj = name; + var k, v; + var keys = Object.keys(obj); + p.beforeSet(self, obj); + for (var _i = 0; _i < keys.length; _i++) { + k = keys[_i]; + v = obj[k]; + var _valid = !p.immutableKeys[k]; + if (_valid) { + for (var j = 0; j < all.length; j++) { + var _ele = all[j]; + if (p.canSet(_ele)) { + _ele._private[p.field][k] = v; + } + } + } + } + + // update mappers if asked + if (p.updateStyle) { + self.updateStyle(); + } + + // call onSet callback + p.onSet(self); + if (p.settingTriggersEvent) { + self[p.triggerFnName](p.settingEvent); + } + + // .data(function(){ ... }) + } else if (p.allowBinding && fn$6(name)) { + // bind to event + var fn = name; + self.on(p.bindingEvent, fn); + + // .data() + } else if (p.allowGetting && name === undefined) { + // get whole object + var _ret; + if (single) { + p.beforeGet(single); + _ret = single._private[p.field]; + } + return _ret; + } + return self; // maintain chainability + }; // function + }, + + // data + + // remove data field + removeData: function removeData(params) { + var defaults = { + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: false, + immutableKeys: {} // key => true if immutable + }; + + params = extend({}, defaults, params); + return function removeDataImpl(names) { + var p = params; + var self = this; + var selfIsArrayLike = self.length !== undefined; + var all = selfIsArrayLike ? self : [self]; // put in array if not array-like + + // .removeData('foo bar') + if (string(names)) { + // then get the list of keys, and delete them + var keys = names.split(/\s+/); + var l = keys.length; + for (var i = 0; i < l; i++) { + // delete each non-empty key + var key = keys[i]; + if (emptyString(key)) { + continue; + } + var valid = !p.immutableKeys[key]; // not valid if immutable + if (valid) { + for (var i_a = 0, l_a = all.length; i_a < l_a; i_a++) { + all[i_a]._private[p.field][key] = undefined; + } + } + } + if (p.triggerEvent) { + self[p.triggerFnName](p.event); + } + + // .removeData() + } else if (names === undefined) { + // then delete all keys + + for (var _i_a = 0, _l_a = all.length; _i_a < _l_a; _i_a++) { + var _privateFields = all[_i_a]._private[p.field]; + var _keys = Object.keys(_privateFields); + for (var _i2 = 0; _i2 < _keys.length; _i2++) { + var _key = _keys[_i2]; + var validKeyToDelete = !p.immutableKeys[_key]; + if (validKeyToDelete) { + _privateFields[_key] = undefined; + } + } + } + if (p.triggerEvent) { + self[p.triggerFnName](p.event); + } + } + return self; // maintain chaining + }; // function + } // removeData +}; // define + +var define$1 = { + eventAliasesOn: function eventAliasesOn(proto) { + var p = proto; + p.addListener = p.listen = p.bind = p.on; + p.unlisten = p.unbind = p.off = p.removeListener; + p.trigger = p.emit; + + // this is just a wrapper alias of .on() + p.pon = p.promiseOn = function (events, selector) { + var self = this; + var args = Array.prototype.slice.call(arguments, 0); + return new Promise$1(function (resolve, reject) { + var callback = function callback(e) { + self.off.apply(self, offArgs); + resolve(e); + }; + var onArgs = args.concat([callback]); + var offArgs = onArgs.concat([]); + self.on.apply(self, onArgs); + }); + }; + } +}; // define + +// use this module to cherry pick functions into your prototype +var define = {}; +[define$3, define$2, define$1].forEach(function (m) { + extend(define, m); +}); + +var elesfn$i = { + animate: define.animate(), + animation: define.animation(), + animated: define.animated(), + clearQueue: define.clearQueue(), + delay: define.delay(), + delayAnimation: define.delayAnimation(), + stop: define.stop() +}; + +var elesfn$h = { + classes: function classes(_classes) { + var self = this; + if (_classes === undefined) { + var ret = []; + self[0]._private.classes.forEach(function (cls) { + return ret.push(cls); + }); + return ret; + } else if (!array(_classes)) { + // extract classes from string + _classes = (_classes || '').match(/\S+/g) || []; + } + var changed = []; + var classesSet = new Set$1(_classes); + + // check and update each ele + for (var j = 0; j < self.length; j++) { + var ele = self[j]; + var _p = ele._private; + var eleClasses = _p.classes; + var changedEle = false; + + // check if ele has all of the passed classes + for (var i = 0; i < _classes.length; i++) { + var cls = _classes[i]; + var eleHasClass = eleClasses.has(cls); + if (!eleHasClass) { + changedEle = true; + break; + } + } + + // check if ele has classes outside of those passed + if (!changedEle) { + changedEle = eleClasses.size !== _classes.length; + } + if (changedEle) { + _p.classes = classesSet; + changed.push(ele); + } + } + + // trigger update style on those eles that had class changes + if (changed.length > 0) { + this.spawn(changed).updateStyle().emit('class'); + } + return self; + }, + addClass: function addClass(classes) { + return this.toggleClass(classes, true); + }, + hasClass: function hasClass(className) { + var ele = this[0]; + return ele != null && ele._private.classes.has(className); + }, + toggleClass: function toggleClass(classes, toggle) { + if (!array(classes)) { + // extract classes from string + classes = classes.match(/\S+/g) || []; + } + var self = this; + var toggleUndefd = toggle === undefined; + var changed = []; // eles who had classes changed + + for (var i = 0, il = self.length; i < il; i++) { + var ele = self[i]; + var eleClasses = ele._private.classes; + var changedEle = false; + for (var j = 0; j < classes.length; j++) { + var cls = classes[j]; + var hasClass = eleClasses.has(cls); + var changedNow = false; + if (toggle || toggleUndefd && !hasClass) { + eleClasses.add(cls); + changedNow = true; + } else if (!toggle || toggleUndefd && hasClass) { + eleClasses["delete"](cls); + changedNow = true; + } + if (!changedEle && changedNow) { + changed.push(ele); + changedEle = true; + } + } // for j classes + } // for i eles + + // trigger update style on those eles that had class changes + if (changed.length > 0) { + this.spawn(changed).updateStyle().emit('class'); + } + return self; + }, + removeClass: function removeClass(classes) { + return this.toggleClass(classes, false); + }, + flashClass: function flashClass(classes, duration) { + var self = this; + if (duration == null) { + duration = 250; + } else if (duration === 0) { + return self; // nothing to do really + } + + self.addClass(classes); + setTimeout(function () { + self.removeClass(classes); + }, duration); + return self; + } +}; +elesfn$h.className = elesfn$h.classNames = elesfn$h.classes; + +// tokens in the query language +var tokens = { + metaChar: '[\\!\\"\\#\\$\\%\\&\\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]', + // chars we need to escape in let names, etc + comparatorOp: '=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=', + // binary comparison op (used in data selectors) + boolOp: '\\?|\\!|\\^', + // boolean (unary) operators (used in data selectors) + string: '"(?:\\\\"|[^"])*"' + '|' + "'(?:\\\\'|[^'])*'", + // string literals (used in data selectors) -- doublequotes | singlequotes + number: number, + // number literal (used in data selectors) --- e.g. 0.1234, 1234, 12e123 + meta: 'degree|indegree|outdegree', + // allowed metadata fields (i.e. allowed functions to use from Collection) + separator: '\\s*,\\s*', + // queries are separated by commas, e.g. edge[foo = 'bar'], node.someClass + descendant: '\\s+', + child: '\\s+>\\s+', + subject: '\\$', + group: 'node|edge|\\*', + directedEdge: '\\s+->\\s+', + undirectedEdge: '\\s+<->\\s+' +}; +tokens.variable = '(?:[\\w-.]|(?:\\\\' + tokens.metaChar + '))+'; // a variable name can have letters, numbers, dashes, and periods +tokens.className = '(?:[\\w-]|(?:\\\\' + tokens.metaChar + '))+'; // a class name has the same rules as a variable except it can't have a '.' in the name +tokens.value = tokens.string + '|' + tokens.number; // a value literal, either a string or number +tokens.id = tokens.variable; // an element id (follows variable conventions) + +(function () { + var ops, op, i; + + // add @ variants to comparatorOp + ops = tokens.comparatorOp.split('|'); + for (i = 0; i < ops.length; i++) { + op = ops[i]; + tokens.comparatorOp += '|@' + op; + } + + // add ! variants to comparatorOp + ops = tokens.comparatorOp.split('|'); + for (i = 0; i < ops.length; i++) { + op = ops[i]; + if (op.indexOf('!') >= 0) { + continue; + } // skip ops that explicitly contain ! + if (op === '=') { + continue; + } // skip = b/c != is explicitly defined + + tokens.comparatorOp += '|\\!' + op; + } +})(); + +/** + * Make a new query object + * + * @prop type {Type} The type enum (int) of the query + * @prop checks List of checks to make against an ele to test for a match + */ +var newQuery = function newQuery() { + return { + checks: [] + }; +}; + +/** + * A check type enum-like object. Uses integer values for fast match() lookup. + * The ordering does not matter as long as the ints are unique. + */ +var Type = { + /** E.g. node */ + GROUP: 0, + /** A collection of elements */ + COLLECTION: 1, + /** A filter(ele) function */ + FILTER: 2, + /** E.g. [foo > 1] */ + DATA_COMPARE: 3, + /** E.g. [foo] */ + DATA_EXIST: 4, + /** E.g. [?foo] */ + DATA_BOOL: 5, + /** E.g. [[degree > 2]] */ + META_COMPARE: 6, + /** E.g. :selected */ + STATE: 7, + /** E.g. #foo */ + ID: 8, + /** E.g. .foo */ + CLASS: 9, + /** E.g. #foo <-> #bar */ + UNDIRECTED_EDGE: 10, + /** E.g. #foo -> #bar */ + DIRECTED_EDGE: 11, + /** E.g. $#foo -> #bar */ + NODE_SOURCE: 12, + /** E.g. #foo -> $#bar */ + NODE_TARGET: 13, + /** E.g. $#foo <-> #bar */ + NODE_NEIGHBOR: 14, + /** E.g. #foo > #bar */ + CHILD: 15, + /** E.g. #foo #bar */ + DESCENDANT: 16, + /** E.g. $#foo > #bar */ + PARENT: 17, + /** E.g. $#foo #bar */ + ANCESTOR: 18, + /** E.g. #foo > $bar > #baz */ + COMPOUND_SPLIT: 19, + /** Always matches, useful placeholder for subject in `COMPOUND_SPLIT` */ + TRUE: 20 +}; + +var stateSelectors = [{ + selector: ':selected', + matches: function matches(ele) { + return ele.selected(); + } +}, { + selector: ':unselected', + matches: function matches(ele) { + return !ele.selected(); + } +}, { + selector: ':selectable', + matches: function matches(ele) { + return ele.selectable(); + } +}, { + selector: ':unselectable', + matches: function matches(ele) { + return !ele.selectable(); + } +}, { + selector: ':locked', + matches: function matches(ele) { + return ele.locked(); + } +}, { + selector: ':unlocked', + matches: function matches(ele) { + return !ele.locked(); + } +}, { + selector: ':visible', + matches: function matches(ele) { + return ele.visible(); + } +}, { + selector: ':hidden', + matches: function matches(ele) { + return !ele.visible(); + } +}, { + selector: ':transparent', + matches: function matches(ele) { + return ele.transparent(); + } +}, { + selector: ':grabbed', + matches: function matches(ele) { + return ele.grabbed(); + } +}, { + selector: ':free', + matches: function matches(ele) { + return !ele.grabbed(); + } +}, { + selector: ':removed', + matches: function matches(ele) { + return ele.removed(); + } +}, { + selector: ':inside', + matches: function matches(ele) { + return !ele.removed(); + } +}, { + selector: ':grabbable', + matches: function matches(ele) { + return ele.grabbable(); + } +}, { + selector: ':ungrabbable', + matches: function matches(ele) { + return !ele.grabbable(); + } +}, { + selector: ':animated', + matches: function matches(ele) { + return ele.animated(); + } +}, { + selector: ':unanimated', + matches: function matches(ele) { + return !ele.animated(); + } +}, { + selector: ':parent', + matches: function matches(ele) { + return ele.isParent(); + } +}, { + selector: ':childless', + matches: function matches(ele) { + return ele.isChildless(); + } +}, { + selector: ':child', + matches: function matches(ele) { + return ele.isChild(); + } +}, { + selector: ':orphan', + matches: function matches(ele) { + return ele.isOrphan(); + } +}, { + selector: ':nonorphan', + matches: function matches(ele) { + return ele.isChild(); + } +}, { + selector: ':compound', + matches: function matches(ele) { + if (ele.isNode()) { + return ele.isParent(); + } else { + return ele.source().isParent() || ele.target().isParent(); + } + } +}, { + selector: ':loop', + matches: function matches(ele) { + return ele.isLoop(); + } +}, { + selector: ':simple', + matches: function matches(ele) { + return ele.isSimple(); + } +}, { + selector: ':active', + matches: function matches(ele) { + return ele.active(); + } +}, { + selector: ':inactive', + matches: function matches(ele) { + return !ele.active(); + } +}, { + selector: ':backgrounding', + matches: function matches(ele) { + return ele.backgrounding(); + } +}, { + selector: ':nonbackgrounding', + matches: function matches(ele) { + return !ele.backgrounding(); + } +}].sort(function (a, b) { + // n.b. selectors that are starting substrings of others must have the longer ones first + return descending(a.selector, b.selector); +}); +var lookup = function () { + var selToFn = {}; + var s; + for (var i = 0; i < stateSelectors.length; i++) { + s = stateSelectors[i]; + selToFn[s.selector] = s.matches; + } + return selToFn; +}(); +var stateSelectorMatches = function stateSelectorMatches(sel, ele) { + return lookup[sel](ele); +}; +var stateSelectorRegex = '(' + stateSelectors.map(function (s) { + return s.selector; +}).join('|') + ')'; + +// when a token like a variable has escaped meta characters, we need to clean the backslashes out +// so that values get compared properly in Selector.filter() +var cleanMetaChars = function cleanMetaChars(str) { + return str.replace(new RegExp('\\\\(' + tokens.metaChar + ')', 'g'), function (match, $1) { + return $1; + }); +}; +var replaceLastQuery = function replaceLastQuery(selector, examiningQuery, replacementQuery) { + selector[selector.length - 1] = replacementQuery; +}; + +// NOTE: add new expression syntax here to have it recognised by the parser; +// - a query contains all adjacent (i.e. no separator in between) expressions; +// - the current query is stored in selector[i] +// - you need to check the query objects in match() for it actually filter properly, but that's pretty straight forward +var exprs = [{ + name: 'group', + // just used for identifying when debugging + query: true, + regex: '(' + tokens.group + ')', + populate: function populate(selector, query, _ref) { + var _ref2 = _slicedToArray(_ref, 1), + group = _ref2[0]; + query.checks.push({ + type: Type.GROUP, + value: group === '*' ? group : group + 's' + }); + } +}, { + name: 'state', + query: true, + regex: stateSelectorRegex, + populate: function populate(selector, query, _ref3) { + var _ref4 = _slicedToArray(_ref3, 1), + state = _ref4[0]; + query.checks.push({ + type: Type.STATE, + value: state + }); + } +}, { + name: 'id', + query: true, + regex: '\\#(' + tokens.id + ')', + populate: function populate(selector, query, _ref5) { + var _ref6 = _slicedToArray(_ref5, 1), + id = _ref6[0]; + query.checks.push({ + type: Type.ID, + value: cleanMetaChars(id) + }); + } +}, { + name: 'className', + query: true, + regex: '\\.(' + tokens.className + ')', + populate: function populate(selector, query, _ref7) { + var _ref8 = _slicedToArray(_ref7, 1), + className = _ref8[0]; + query.checks.push({ + type: Type.CLASS, + value: cleanMetaChars(className) + }); + } +}, { + name: 'dataExists', + query: true, + regex: '\\[\\s*(' + tokens.variable + ')\\s*\\]', + populate: function populate(selector, query, _ref9) { + var _ref10 = _slicedToArray(_ref9, 1), + variable = _ref10[0]; + query.checks.push({ + type: Type.DATA_EXIST, + field: cleanMetaChars(variable) + }); + } +}, { + name: 'dataCompare', + query: true, + regex: '\\[\\s*(' + tokens.variable + ')\\s*(' + tokens.comparatorOp + ')\\s*(' + tokens.value + ')\\s*\\]', + populate: function populate(selector, query, _ref11) { + var _ref12 = _slicedToArray(_ref11, 3), + variable = _ref12[0], + comparatorOp = _ref12[1], + value = _ref12[2]; + var valueIsString = new RegExp('^' + tokens.string + '$').exec(value) != null; + if (valueIsString) { + value = value.substring(1, value.length - 1); + } else { + value = parseFloat(value); + } + query.checks.push({ + type: Type.DATA_COMPARE, + field: cleanMetaChars(variable), + operator: comparatorOp, + value: value + }); + } +}, { + name: 'dataBool', + query: true, + regex: '\\[\\s*(' + tokens.boolOp + ')\\s*(' + tokens.variable + ')\\s*\\]', + populate: function populate(selector, query, _ref13) { + var _ref14 = _slicedToArray(_ref13, 2), + boolOp = _ref14[0], + variable = _ref14[1]; + query.checks.push({ + type: Type.DATA_BOOL, + field: cleanMetaChars(variable), + operator: boolOp + }); + } +}, { + name: 'metaCompare', + query: true, + regex: '\\[\\[\\s*(' + tokens.meta + ')\\s*(' + tokens.comparatorOp + ')\\s*(' + tokens.number + ')\\s*\\]\\]', + populate: function populate(selector, query, _ref15) { + var _ref16 = _slicedToArray(_ref15, 3), + meta = _ref16[0], + comparatorOp = _ref16[1], + number = _ref16[2]; + query.checks.push({ + type: Type.META_COMPARE, + field: cleanMetaChars(meta), + operator: comparatorOp, + value: parseFloat(number) + }); + } +}, { + name: 'nextQuery', + separator: true, + regex: tokens.separator, + populate: function populate(selector, query) { + var currentSubject = selector.currentSubject; + var edgeCount = selector.edgeCount; + var compoundCount = selector.compoundCount; + var lastQ = selector[selector.length - 1]; + if (currentSubject != null) { + lastQ.subject = currentSubject; + selector.currentSubject = null; + } + lastQ.edgeCount = edgeCount; + lastQ.compoundCount = compoundCount; + selector.edgeCount = 0; + selector.compoundCount = 0; + + // go on to next query + var nextQuery = selector[selector.length++] = newQuery(); + return nextQuery; // this is the new query to be filled by the following exprs + } +}, { + name: 'directedEdge', + separator: true, + regex: tokens.directedEdge, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // undirected edge + var edgeQuery = newQuery(); + var source = query; + var target = newQuery(); + edgeQuery.checks.push({ + type: Type.DIRECTED_EDGE, + source: source, + target: target + }); + + // the query in the selector should be the edge rather than the source + replaceLastQuery(selector, query, edgeQuery); + selector.edgeCount++; + + // we're now populating the target query with expressions that follow + return target; + } else { + // source/target + var srcTgtQ = newQuery(); + var _source = query; + var _target = newQuery(); + srcTgtQ.checks.push({ + type: Type.NODE_SOURCE, + source: _source, + target: _target + }); + + // the query in the selector should be the neighbourhood rather than the node + replaceLastQuery(selector, query, srcTgtQ); + selector.edgeCount++; + return _target; // now populating the target with the following expressions + } + } +}, { + name: 'undirectedEdge', + separator: true, + regex: tokens.undirectedEdge, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // undirected edge + var edgeQuery = newQuery(); + var source = query; + var target = newQuery(); + edgeQuery.checks.push({ + type: Type.UNDIRECTED_EDGE, + nodes: [source, target] + }); + + // the query in the selector should be the edge rather than the source + replaceLastQuery(selector, query, edgeQuery); + selector.edgeCount++; + + // we're now populating the target query with expressions that follow + return target; + } else { + // neighbourhood + var nhoodQ = newQuery(); + var node = query; + var neighbor = newQuery(); + nhoodQ.checks.push({ + type: Type.NODE_NEIGHBOR, + node: node, + neighbor: neighbor + }); + + // the query in the selector should be the neighbourhood rather than the node + replaceLastQuery(selector, query, nhoodQ); + return neighbor; // now populating the neighbor with following expressions + } + } +}, { + name: 'child', + separator: true, + regex: tokens.child, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // default: child query + var parentChildQuery = newQuery(); + var child = newQuery(); + var parent = selector[selector.length - 1]; + parentChildQuery.checks.push({ + type: Type.CHILD, + parent: parent, + child: child + }); + + // the query in the selector should be the '>' itself + replaceLastQuery(selector, query, parentChildQuery); + selector.compoundCount++; + + // we're now populating the child query with expressions that follow + return child; + } else if (selector.currentSubject === query) { + // compound split query + var compound = newQuery(); + var left = selector[selector.length - 1]; + var right = newQuery(); + var subject = newQuery(); + var _child = newQuery(); + var _parent = newQuery(); + + // set up the root compound q + compound.checks.push({ + type: Type.COMPOUND_SPLIT, + left: left, + right: right, + subject: subject + }); + + // populate the subject and replace the q at the old spot (within left) with TRUE + subject.checks = query.checks; // take the checks from the left + query.checks = [{ + type: Type.TRUE + }]; // checks under left refs the subject implicitly + + // set up the right q + _parent.checks.push({ + type: Type.TRUE + }); // parent implicitly refs the subject + right.checks.push({ + type: Type.PARENT, + // type is swapped on right side queries + parent: _parent, + child: _child // empty for now + }); + + replaceLastQuery(selector, left, compound); + + // update the ref since we moved things around for `query` + selector.currentSubject = subject; + selector.compoundCount++; + return _child; // now populating the right side's child + } else { + // parent query + // info for parent query + var _parent2 = newQuery(); + var _child2 = newQuery(); + var pcQChecks = [{ + type: Type.PARENT, + parent: _parent2, + child: _child2 + }]; + + // the parent-child query takes the place of the query previously being populated + _parent2.checks = query.checks; // the previous query contains the checks for the parent + query.checks = pcQChecks; // pc query takes over + + selector.compoundCount++; + return _child2; // we're now populating the child + } + } +}, { + name: 'descendant', + separator: true, + regex: tokens.descendant, + populate: function populate(selector, query) { + if (selector.currentSubject == null) { + // default: descendant query + var ancChQuery = newQuery(); + var descendant = newQuery(); + var ancestor = selector[selector.length - 1]; + ancChQuery.checks.push({ + type: Type.DESCENDANT, + ancestor: ancestor, + descendant: descendant + }); + + // the query in the selector should be the '>' itself + replaceLastQuery(selector, query, ancChQuery); + selector.compoundCount++; + + // we're now populating the descendant query with expressions that follow + return descendant; + } else if (selector.currentSubject === query) { + // compound split query + var compound = newQuery(); + var left = selector[selector.length - 1]; + var right = newQuery(); + var subject = newQuery(); + var _descendant = newQuery(); + var _ancestor = newQuery(); + + // set up the root compound q + compound.checks.push({ + type: Type.COMPOUND_SPLIT, + left: left, + right: right, + subject: subject + }); + + // populate the subject and replace the q at the old spot (within left) with TRUE + subject.checks = query.checks; // take the checks from the left + query.checks = [{ + type: Type.TRUE + }]; // checks under left refs the subject implicitly + + // set up the right q + _ancestor.checks.push({ + type: Type.TRUE + }); // ancestor implicitly refs the subject + right.checks.push({ + type: Type.ANCESTOR, + // type is swapped on right side queries + ancestor: _ancestor, + descendant: _descendant // empty for now + }); + + replaceLastQuery(selector, left, compound); + + // update the ref since we moved things around for `query` + selector.currentSubject = subject; + selector.compoundCount++; + return _descendant; // now populating the right side's descendant + } else { + // ancestor query + // info for parent query + var _ancestor2 = newQuery(); + var _descendant2 = newQuery(); + var adQChecks = [{ + type: Type.ANCESTOR, + ancestor: _ancestor2, + descendant: _descendant2 + }]; + + // the parent-child query takes the place of the query previously being populated + _ancestor2.checks = query.checks; // the previous query contains the checks for the parent + query.checks = adQChecks; // pc query takes over + + selector.compoundCount++; + return _descendant2; // we're now populating the child + } + } +}, { + name: 'subject', + modifier: true, + regex: tokens.subject, + populate: function populate(selector, query) { + if (selector.currentSubject != null && selector.currentSubject !== query) { + warn('Redefinition of subject in selector `' + selector.toString() + '`'); + return false; + } + selector.currentSubject = query; + var topQ = selector[selector.length - 1]; + var topChk = topQ.checks[0]; + var topType = topChk == null ? null : topChk.type; + if (topType === Type.DIRECTED_EDGE) { + // directed edge with subject on the target + + // change to target node check + topChk.type = Type.NODE_TARGET; + } else if (topType === Type.UNDIRECTED_EDGE) { + // undirected edge with subject on the second node + + // change to neighbor check + topChk.type = Type.NODE_NEIGHBOR; + topChk.node = topChk.nodes[1]; // second node is subject + topChk.neighbor = topChk.nodes[0]; + + // clean up unused fields for new type + topChk.nodes = null; + } + } +}]; +exprs.forEach(function (e) { + return e.regexObj = new RegExp('^' + e.regex); +}); + +/** + * Of all the expressions, find the first match in the remaining text. + * @param {string} remaining The remaining text to parse + * @returns The matched expression and the newly remaining text `{ expr, match, name, remaining }` + */ +var consumeExpr = function consumeExpr(remaining) { + var expr; + var match; + var name; + for (var j = 0; j < exprs.length; j++) { + var e = exprs[j]; + var n = e.name; + var m = remaining.match(e.regexObj); + if (m != null) { + match = m; + expr = e; + name = n; + var consumed = m[0]; + remaining = remaining.substring(consumed.length); + break; // we've consumed one expr, so we can return now + } + } + + return { + expr: expr, + match: match, + name: name, + remaining: remaining + }; +}; + +/** + * Consume all the leading whitespace + * @param {string} remaining The text to consume + * @returns The text with the leading whitespace removed + */ +var consumeWhitespace = function consumeWhitespace(remaining) { + var match = remaining.match(/^\s+/); + if (match) { + var consumed = match[0]; + remaining = remaining.substring(consumed.length); + } + return remaining; +}; + +/** + * Parse the string and store the parsed representation in the Selector. + * @param {string} selector The selector string + * @returns `true` if the selector was successfully parsed, `false` otherwise + */ +var parse = function parse(selector) { + var self = this; + var remaining = self.inputText = selector; + var currentQuery = self[0] = newQuery(); + self.length = 1; + remaining = consumeWhitespace(remaining); // get rid of leading whitespace + + for (;;) { + var exprInfo = consumeExpr(remaining); + if (exprInfo.expr == null) { + warn('The selector `' + selector + '`is invalid'); + return false; + } else { + var args = exprInfo.match.slice(1); + + // let the token populate the selector object in currentQuery + var ret = exprInfo.expr.populate(self, currentQuery, args); + if (ret === false) { + return false; // exit if population failed + } else if (ret != null) { + currentQuery = ret; // change the current query to be filled if the expr specifies + } + } + + remaining = exprInfo.remaining; + + // we're done when there's nothing left to parse + if (remaining.match(/^\s*$/)) { + break; + } + } + var lastQ = self[self.length - 1]; + if (self.currentSubject != null) { + lastQ.subject = self.currentSubject; + } + lastQ.edgeCount = self.edgeCount; + lastQ.compoundCount = self.compoundCount; + for (var i = 0; i < self.length; i++) { + var q = self[i]; + + // in future, this could potentially be allowed if there were operator precedence and detection of invalid combinations + if (q.compoundCount > 0 && q.edgeCount > 0) { + warn('The selector `' + selector + '` is invalid because it uses both a compound selector and an edge selector'); + return false; + } + if (q.edgeCount > 1) { + warn('The selector `' + selector + '` is invalid because it uses multiple edge selectors'); + return false; + } else if (q.edgeCount === 1) { + warn('The selector `' + selector + '` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.'); + } + } + return true; // success +}; + +/** + * Get the selector represented as a string. This value uses default formatting, + * so things like spacing may differ from the input text passed to the constructor. + * @returns {string} The selector string + */ +var toString = function toString() { + if (this.toStringCache != null) { + return this.toStringCache; + } + var clean = function clean(obj) { + if (obj == null) { + return ''; + } else { + return obj; + } + }; + var cleanVal = function cleanVal(val) { + if (string(val)) { + return '"' + val + '"'; + } else { + return clean(val); + } + }; + var space = function space(val) { + return ' ' + val + ' '; + }; + var checkToString = function checkToString(check, subject) { + var type = check.type, + value = check.value; + switch (type) { + case Type.GROUP: + { + var group = clean(value); + return group.substring(0, group.length - 1); + } + case Type.DATA_COMPARE: + { + var field = check.field, + operator = check.operator; + return '[' + field + space(clean(operator)) + cleanVal(value) + ']'; + } + case Type.DATA_BOOL: + { + var _operator = check.operator, + _field = check.field; + return '[' + clean(_operator) + _field + ']'; + } + case Type.DATA_EXIST: + { + var _field2 = check.field; + return '[' + _field2 + ']'; + } + case Type.META_COMPARE: + { + var _operator2 = check.operator, + _field3 = check.field; + return '[[' + _field3 + space(clean(_operator2)) + cleanVal(value) + ']]'; + } + case Type.STATE: + { + return value; + } + case Type.ID: + { + return '#' + value; + } + case Type.CLASS: + { + return '.' + value; + } + case Type.PARENT: + case Type.CHILD: + { + return queryToString(check.parent, subject) + space('>') + queryToString(check.child, subject); + } + case Type.ANCESTOR: + case Type.DESCENDANT: + { + return queryToString(check.ancestor, subject) + ' ' + queryToString(check.descendant, subject); + } + case Type.COMPOUND_SPLIT: + { + var lhs = queryToString(check.left, subject); + var sub = queryToString(check.subject, subject); + var rhs = queryToString(check.right, subject); + return lhs + (lhs.length > 0 ? ' ' : '') + sub + rhs; + } + case Type.TRUE: + { + return ''; + } + } + }; + var queryToString = function queryToString(query, subject) { + return query.checks.reduce(function (str, chk, i) { + return str + (subject === query && i === 0 ? '$' : '') + checkToString(chk, subject); + }, ''); + }; + var str = ''; + for (var i = 0; i < this.length; i++) { + var query = this[i]; + str += queryToString(query, query.subject); + if (this.length > 1 && i < this.length - 1) { + str += ', '; + } + } + this.toStringCache = str; + return str; +}; +var parse$1 = { + parse: parse, + toString: toString +}; + +var valCmp = function valCmp(fieldVal, operator, value) { + var matches; + var isFieldStr = string(fieldVal); + var isFieldNum = number$1(fieldVal); + var isValStr = string(value); + var fieldStr, valStr; + var caseInsensitive = false; + var notExpr = false; + var isIneqCmp = false; + if (operator.indexOf('!') >= 0) { + operator = operator.replace('!', ''); + notExpr = true; + } + if (operator.indexOf('@') >= 0) { + operator = operator.replace('@', ''); + caseInsensitive = true; + } + if (isFieldStr || isValStr || caseInsensitive) { + fieldStr = !isFieldStr && !isFieldNum ? '' : '' + fieldVal; + valStr = '' + value; + } + + // if we're doing a case insensitive comparison, then we're using a STRING comparison + // even if we're comparing numbers + if (caseInsensitive) { + fieldVal = fieldStr = fieldStr.toLowerCase(); + value = valStr = valStr.toLowerCase(); + } + switch (operator) { + case '*=': + matches = fieldStr.indexOf(valStr) >= 0; + break; + case '$=': + matches = fieldStr.indexOf(valStr, fieldStr.length - valStr.length) >= 0; + break; + case '^=': + matches = fieldStr.indexOf(valStr) === 0; + break; + case '=': + matches = fieldVal === value; + break; + case '>': + isIneqCmp = true; + matches = fieldVal > value; + break; + case '>=': + isIneqCmp = true; + matches = fieldVal >= value; + break; + case '<': + isIneqCmp = true; + matches = fieldVal < value; + break; + case '<=': + isIneqCmp = true; + matches = fieldVal <= value; + break; + default: + matches = false; + break; + } + + // apply the not op, but null vals for inequalities should always stay non-matching + if (notExpr && (fieldVal != null || !isIneqCmp)) { + matches = !matches; + } + return matches; +}; +var boolCmp = function boolCmp(fieldVal, operator) { + switch (operator) { + case '?': + return fieldVal ? true : false; + case '!': + return fieldVal ? false : true; + case '^': + return fieldVal === undefined; + } +}; +var existCmp = function existCmp(fieldVal) { + return fieldVal !== undefined; +}; +var data$1 = function data(ele, field) { + return ele.data(field); +}; +var meta = function meta(ele, field) { + return ele[field](); +}; + +/** A lookup of `match(check, ele)` functions by `Type` int */ +var match = []; + +/** + * Returns whether the query matches for the element + * @param query The `{ type, value, ... }` query object + * @param ele The element to compare against +*/ +var matches$1 = function matches(query, ele) { + return query.checks.every(function (chk) { + return match[chk.type](chk, ele); + }); +}; +match[Type.GROUP] = function (check, ele) { + var group = check.value; + return group === '*' || group === ele.group(); +}; +match[Type.STATE] = function (check, ele) { + var stateSelector = check.value; + return stateSelectorMatches(stateSelector, ele); +}; +match[Type.ID] = function (check, ele) { + var id = check.value; + return ele.id() === id; +}; +match[Type.CLASS] = function (check, ele) { + var cls = check.value; + return ele.hasClass(cls); +}; +match[Type.META_COMPARE] = function (check, ele) { + var field = check.field, + operator = check.operator, + value = check.value; + return valCmp(meta(ele, field), operator, value); +}; +match[Type.DATA_COMPARE] = function (check, ele) { + var field = check.field, + operator = check.operator, + value = check.value; + return valCmp(data$1(ele, field), operator, value); +}; +match[Type.DATA_BOOL] = function (check, ele) { + var field = check.field, + operator = check.operator; + return boolCmp(data$1(ele, field), operator); +}; +match[Type.DATA_EXIST] = function (check, ele) { + var field = check.field; + check.operator; + return existCmp(data$1(ele, field)); +}; +match[Type.UNDIRECTED_EDGE] = function (check, ele) { + var qA = check.nodes[0]; + var qB = check.nodes[1]; + var src = ele.source(); + var tgt = ele.target(); + return matches$1(qA, src) && matches$1(qB, tgt) || matches$1(qB, src) && matches$1(qA, tgt); +}; +match[Type.NODE_NEIGHBOR] = function (check, ele) { + return matches$1(check.node, ele) && ele.neighborhood().some(function (n) { + return n.isNode() && matches$1(check.neighbor, n); + }); +}; +match[Type.DIRECTED_EDGE] = function (check, ele) { + return matches$1(check.source, ele.source()) && matches$1(check.target, ele.target()); +}; +match[Type.NODE_SOURCE] = function (check, ele) { + return matches$1(check.source, ele) && ele.outgoers().some(function (n) { + return n.isNode() && matches$1(check.target, n); + }); +}; +match[Type.NODE_TARGET] = function (check, ele) { + return matches$1(check.target, ele) && ele.incomers().some(function (n) { + return n.isNode() && matches$1(check.source, n); + }); +}; +match[Type.CHILD] = function (check, ele) { + return matches$1(check.child, ele) && matches$1(check.parent, ele.parent()); +}; +match[Type.PARENT] = function (check, ele) { + return matches$1(check.parent, ele) && ele.children().some(function (c) { + return matches$1(check.child, c); + }); +}; +match[Type.DESCENDANT] = function (check, ele) { + return matches$1(check.descendant, ele) && ele.ancestors().some(function (a) { + return matches$1(check.ancestor, a); + }); +}; +match[Type.ANCESTOR] = function (check, ele) { + return matches$1(check.ancestor, ele) && ele.descendants().some(function (d) { + return matches$1(check.descendant, d); + }); +}; +match[Type.COMPOUND_SPLIT] = function (check, ele) { + return matches$1(check.subject, ele) && matches$1(check.left, ele) && matches$1(check.right, ele); +}; +match[Type.TRUE] = function () { + return true; +}; +match[Type.COLLECTION] = function (check, ele) { + var collection = check.value; + return collection.has(ele); +}; +match[Type.FILTER] = function (check, ele) { + var filter = check.value; + return filter(ele); +}; + +// filter an existing collection +var filter = function filter(collection) { + var self = this; + + // for 1 id #foo queries, just get the element + if (self.length === 1 && self[0].checks.length === 1 && self[0].checks[0].type === Type.ID) { + return collection.getElementById(self[0].checks[0].value).collection(); + } + var selectorFunction = function selectorFunction(element) { + for (var j = 0; j < self.length; j++) { + var query = self[j]; + if (matches$1(query, element)) { + return true; + } + } + return false; + }; + if (self.text() == null) { + selectorFunction = function selectorFunction() { + return true; + }; + } + return collection.filter(selectorFunction); +}; // filter + +// does selector match a single element? +var matches = function matches(ele) { + var self = this; + for (var j = 0; j < self.length; j++) { + var query = self[j]; + if (matches$1(query, ele)) { + return true; + } + } + return false; +}; // matches + +var matching = { + matches: matches, + filter: filter +}; + +var Selector = function Selector(selector) { + this.inputText = selector; + this.currentSubject = null; + this.compoundCount = 0; + this.edgeCount = 0; + this.length = 0; + if (selector == null || string(selector) && selector.match(/^\s*$/)) ; else if (elementOrCollection(selector)) { + this.addQuery({ + checks: [{ + type: Type.COLLECTION, + value: selector.collection() + }] + }); + } else if (fn$6(selector)) { + this.addQuery({ + checks: [{ + type: Type.FILTER, + value: selector + }] + }); + } else if (string(selector)) { + if (!this.parse(selector)) { + this.invalid = true; + } + } else { + error('A selector must be created from a string; found '); + } +}; +var selfn = Selector.prototype; +[parse$1, matching].forEach(function (p) { + return extend(selfn, p); +}); +selfn.text = function () { + return this.inputText; +}; +selfn.size = function () { + return this.length; +}; +selfn.eq = function (i) { + return this[i]; +}; +selfn.sameText = function (otherSel) { + return !this.invalid && !otherSel.invalid && this.text() === otherSel.text(); +}; +selfn.addQuery = function (q) { + this[this.length++] = q; +}; +selfn.selector = selfn.toString; + +var elesfn$g = { + allAre: function allAre(selector) { + var selObj = new Selector(selector); + return this.every(function (ele) { + return selObj.matches(ele); + }); + }, + is: function is(selector) { + var selObj = new Selector(selector); + return this.some(function (ele) { + return selObj.matches(ele); + }); + }, + some: function some(fn, thisArg) { + for (var i = 0; i < this.length; i++) { + var ret = !thisArg ? fn(this[i], i, this) : fn.apply(thisArg, [this[i], i, this]); + if (ret) { + return true; + } + } + return false; + }, + every: function every(fn, thisArg) { + for (var i = 0; i < this.length; i++) { + var ret = !thisArg ? fn(this[i], i, this) : fn.apply(thisArg, [this[i], i, this]); + if (!ret) { + return false; + } + } + return true; + }, + same: function same(collection) { + // cheap collection ref check + if (this === collection) { + return true; + } + collection = this.cy().collection(collection); + var thisLength = this.length; + var collectionLength = collection.length; + + // cheap length check + if (thisLength !== collectionLength) { + return false; + } + + // cheap element ref check + if (thisLength === 1) { + return this[0] === collection[0]; + } + return this.every(function (ele) { + return collection.hasElementWithId(ele.id()); + }); + }, + anySame: function anySame(collection) { + collection = this.cy().collection(collection); + return this.some(function (ele) { + return collection.hasElementWithId(ele.id()); + }); + }, + allAreNeighbors: function allAreNeighbors(collection) { + collection = this.cy().collection(collection); + var nhood = this.neighborhood(); + return collection.every(function (ele) { + return nhood.hasElementWithId(ele.id()); + }); + }, + contains: function contains(collection) { + collection = this.cy().collection(collection); + var self = this; + return collection.every(function (ele) { + return self.hasElementWithId(ele.id()); + }); + } +}; +elesfn$g.allAreNeighbours = elesfn$g.allAreNeighbors; +elesfn$g.has = elesfn$g.contains; +elesfn$g.equal = elesfn$g.equals = elesfn$g.same; + +var cache = function cache(fn, name) { + return function traversalCache(arg1, arg2, arg3, arg4) { + var selectorOrEles = arg1; + var eles = this; + var key; + if (selectorOrEles == null) { + key = ''; + } else if (elementOrCollection(selectorOrEles) && selectorOrEles.length === 1) { + key = selectorOrEles.id(); + } + if (eles.length === 1 && key) { + var _p = eles[0]._private; + var tch = _p.traversalCache = _p.traversalCache || {}; + var ch = tch[name] = tch[name] || []; + var hash = hashString(key); + var cacheHit = ch[hash]; + if (cacheHit) { + return cacheHit; + } else { + return ch[hash] = fn.call(eles, arg1, arg2, arg3, arg4); + } + } else { + return fn.call(eles, arg1, arg2, arg3, arg4); + } + }; +}; + +var elesfn$f = { + parent: function parent(selector) { + var parents = []; + + // optimisation for single ele call + if (this.length === 1) { + var parent = this[0]._private.parent; + if (parent) { + return parent; + } + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _parent = ele._private.parent; + if (_parent) { + parents.push(_parent); + } + } + return this.spawn(parents, true).filter(selector); + }, + parents: function parents(selector) { + var parents = []; + var eles = this.parent(); + while (eles.nonempty()) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + parents.push(ele); + } + eles = eles.parent(); + } + return this.spawn(parents, true).filter(selector); + }, + commonAncestors: function commonAncestors(selector) { + var ancestors; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var parents = ele.parents(); + ancestors = ancestors || parents; + ancestors = ancestors.intersect(parents); // current list must be common with current ele parents set + } + + return ancestors.filter(selector); + }, + orphans: function orphans(selector) { + return this.stdFilter(function (ele) { + return ele.isOrphan(); + }).filter(selector); + }, + nonorphans: function nonorphans(selector) { + return this.stdFilter(function (ele) { + return ele.isChild(); + }).filter(selector); + }, + children: cache(function (selector) { + var children = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var eleChildren = ele._private.children; + for (var j = 0; j < eleChildren.length; j++) { + children.push(eleChildren[j]); + } + } + return this.spawn(children, true).filter(selector); + }, 'children'), + siblings: function siblings(selector) { + return this.parent().children().not(this).filter(selector); + }, + isParent: function isParent() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.children.length !== 0; + } + }, + isChildless: function isChildless() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.children.length === 0; + } + }, + isChild: function isChild() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.parent != null; + } + }, + isOrphan: function isOrphan() { + var ele = this[0]; + if (ele) { + return ele.isNode() && ele._private.parent == null; + } + }, + descendants: function descendants(selector) { + var elements = []; + function add(eles) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + elements.push(ele); + if (ele.children().nonempty()) { + add(ele.children()); + } + } + } + add(this.children()); + return this.spawn(elements, true).filter(selector); + } +}; +function forEachCompound(eles, fn, includeSelf, recursiveStep) { + var q = []; + var did = new Set$1(); + var cy = eles.cy(); + var hasCompounds = cy.hasCompoundNodes(); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (includeSelf) { + q.push(ele); + } else if (hasCompounds) { + recursiveStep(q, did, ele); + } + } + while (q.length > 0) { + var _ele = q.shift(); + fn(_ele); + did.add(_ele.id()); + if (hasCompounds) { + recursiveStep(q, did, _ele); + } + } + return eles; +} +function addChildren(q, did, ele) { + if (ele.isParent()) { + var children = ele._private.children; + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (!did.has(child.id())) { + q.push(child); + } + } + } +} + +// very efficient version of eles.add( eles.descendants() ).forEach() +// for internal use +elesfn$f.forEachDown = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addChildren); +}; +function addParent(q, did, ele) { + if (ele.isChild()) { + var parent = ele._private.parent; + if (!did.has(parent.id())) { + q.push(parent); + } + } +} +elesfn$f.forEachUp = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addParent); +}; +function addParentAndChildren(q, did, ele) { + addParent(q, did, ele); + addChildren(q, did, ele); +} +elesfn$f.forEachUpAndDown = function (fn) { + var includeSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return forEachCompound(this, fn, includeSelf, addParentAndChildren); +}; + +// aliases +elesfn$f.ancestors = elesfn$f.parents; + +var fn$5, elesfn$e; +fn$5 = elesfn$e = { + data: define.data({ + field: 'data', + bindingEvent: 'data', + allowBinding: true, + allowSetting: true, + settingEvent: 'data', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + immutableKeys: { + 'id': true, + 'source': true, + 'target': true, + 'parent': true + }, + updateStyle: true + }), + removeData: define.removeData({ + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: true, + immutableKeys: { + 'id': true, + 'source': true, + 'target': true, + 'parent': true + }, + updateStyle: true + }), + scratch: define.data({ + field: 'scratch', + bindingEvent: 'scratch', + allowBinding: true, + allowSetting: true, + settingEvent: 'scratch', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeScratch: define.removeData({ + field: 'scratch', + event: 'scratch', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }), + rscratch: define.data({ + field: 'rscratch', + allowBinding: false, + allowSetting: true, + settingTriggersEvent: false, + allowGetting: true + }), + removeRscratch: define.removeData({ + field: 'rscratch', + triggerEvent: false + }), + id: function id() { + var ele = this[0]; + if (ele) { + return ele._private.data.id; + } + } +}; + +// aliases +fn$5.attr = fn$5.data; +fn$5.removeAttr = fn$5.removeData; +var data = elesfn$e; + +var elesfn$d = {}; +function defineDegreeFunction(callback) { + return function (includeLoops) { + var self = this; + if (includeLoops === undefined) { + includeLoops = true; + } + if (self.length === 0) { + return; + } + if (self.isNode() && !self.removed()) { + var degree = 0; + var node = self[0]; + var connectedEdges = node._private.edges; + for (var i = 0; i < connectedEdges.length; i++) { + var edge = connectedEdges[i]; + if (!includeLoops && edge.isLoop()) { + continue; + } + degree += callback(node, edge); + } + return degree; + } else { + return; + } + }; +} +extend(elesfn$d, { + degree: defineDegreeFunction(function (node, edge) { + if (edge.source().same(edge.target())) { + return 2; + } else { + return 1; + } + }), + indegree: defineDegreeFunction(function (node, edge) { + if (edge.target().same(node)) { + return 1; + } else { + return 0; + } + }), + outdegree: defineDegreeFunction(function (node, edge) { + if (edge.source().same(node)) { + return 1; + } else { + return 0; + } + }) +}); +function defineDegreeBoundsFunction(degreeFn, callback) { + return function (includeLoops) { + var ret; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + var ele = nodes[i]; + var degree = ele[degreeFn](includeLoops); + if (degree !== undefined && (ret === undefined || callback(degree, ret))) { + ret = degree; + } + } + return ret; + }; +} +extend(elesfn$d, { + minDegree: defineDegreeBoundsFunction('degree', function (degree, min) { + return degree < min; + }), + maxDegree: defineDegreeBoundsFunction('degree', function (degree, max) { + return degree > max; + }), + minIndegree: defineDegreeBoundsFunction('indegree', function (degree, min) { + return degree < min; + }), + maxIndegree: defineDegreeBoundsFunction('indegree', function (degree, max) { + return degree > max; + }), + minOutdegree: defineDegreeBoundsFunction('outdegree', function (degree, min) { + return degree < min; + }), + maxOutdegree: defineDegreeBoundsFunction('outdegree', function (degree, max) { + return degree > max; + }) +}); +extend(elesfn$d, { + totalDegree: function totalDegree(includeLoops) { + var total = 0; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + total += nodes[i].degree(includeLoops); + } + return total; + } +}); + +var fn$4, elesfn$c; +var beforePositionSet = function beforePositionSet(eles, newPos, silent) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.locked()) { + var oldPos = ele._private.position; + var delta = { + x: newPos.x != null ? newPos.x - oldPos.x : 0, + y: newPos.y != null ? newPos.y - oldPos.y : 0 + }; + if (ele.isParent() && !(delta.x === 0 && delta.y === 0)) { + ele.children().shift(delta, silent); + } + ele.dirtyBoundingBoxCache(); + } + } +}; +var positionDef = { + field: 'position', + bindingEvent: 'position', + allowBinding: true, + allowSetting: true, + settingEvent: 'position', + settingTriggersEvent: true, + triggerFnName: 'emitAndNotify', + allowGetting: true, + validKeys: ['x', 'y'], + beforeGet: function beforeGet(ele) { + ele.updateCompoundBounds(); + }, + beforeSet: function beforeSet(eles, newPos) { + beforePositionSet(eles, newPos, false); + }, + onSet: function onSet(eles) { + eles.dirtyCompoundBoundsCache(); + }, + canSet: function canSet(ele) { + return !ele.locked(); + } +}; +fn$4 = elesfn$c = { + position: define.data(positionDef), + // position but no notification to renderer + silentPosition: define.data(extend({}, positionDef, { + allowBinding: false, + allowSetting: true, + settingTriggersEvent: false, + allowGetting: false, + beforeSet: function beforeSet(eles, newPos) { + beforePositionSet(eles, newPos, true); + }, + onSet: function onSet(eles) { + eles.dirtyCompoundBoundsCache(); + } + })), + positions: function positions(pos, silent) { + if (plainObject(pos)) { + if (silent) { + this.silentPosition(pos); + } else { + this.position(pos); + } + } else if (fn$6(pos)) { + var _fn = pos; + var cy = this.cy(); + cy.startBatch(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _pos = void 0; + if (_pos = _fn(ele, i)) { + if (silent) { + ele.silentPosition(_pos); + } else { + ele.position(_pos); + } + } + } + cy.endBatch(); + } + return this; // chaining + }, + + silentPositions: function silentPositions(pos) { + return this.positions(pos, true); + }, + shift: function shift(dim, val, silent) { + var delta; + if (plainObject(dim)) { + delta = { + x: number$1(dim.x) ? dim.x : 0, + y: number$1(dim.y) ? dim.y : 0 + }; + silent = val; + } else if (string(dim) && number$1(val)) { + delta = { + x: 0, + y: 0 + }; + delta[dim] = val; + } + if (delta != null) { + var cy = this.cy(); + cy.startBatch(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + + // exclude any node that is a descendant of the calling collection + if (cy.hasCompoundNodes() && ele.isChild() && ele.ancestors().anySame(this)) { + continue; + } + var pos = ele.position(); + var newPos = { + x: pos.x + delta.x, + y: pos.y + delta.y + }; + if (silent) { + ele.silentPosition(newPos); + } else { + ele.position(newPos); + } + } + cy.endBatch(); + } + return this; + }, + silentShift: function silentShift(dim, val) { + if (plainObject(dim)) { + this.shift(dim, true); + } else if (string(dim) && number$1(val)) { + this.shift(dim, val, true); + } + return this; + }, + // get/set the rendered (i.e. on screen) positon of the element + renderedPosition: function renderedPosition(dim, val) { + var ele = this[0]; + var cy = this.cy(); + var zoom = cy.zoom(); + var pan = cy.pan(); + var rpos = plainObject(dim) ? dim : undefined; + var setting = rpos !== undefined || val !== undefined && string(dim); + if (ele && ele.isNode()) { + // must have an element and must be a node to return position + if (setting) { + for (var i = 0; i < this.length; i++) { + var _ele = this[i]; + if (val !== undefined) { + // set one dimension + _ele.position(dim, (val - pan[dim]) / zoom); + } else if (rpos !== undefined) { + // set whole position + _ele.position(renderedToModelPosition(rpos, zoom, pan)); + } + } + } else { + // getting + var pos = ele.position(); + rpos = modelToRenderedPosition(pos, zoom, pan); + if (dim === undefined) { + // then return the whole rendered position + return rpos; + } else { + // then return the specified dimension + return rpos[dim]; + } + } + } else if (!setting) { + return undefined; // for empty collection case + } + + return this; // chaining + }, + + // get/set the position relative to the parent + relativePosition: function relativePosition(dim, val) { + var ele = this[0]; + var cy = this.cy(); + var ppos = plainObject(dim) ? dim : undefined; + var setting = ppos !== undefined || val !== undefined && string(dim); + var hasCompoundNodes = cy.hasCompoundNodes(); + if (ele && ele.isNode()) { + // must have an element and must be a node to return position + if (setting) { + for (var i = 0; i < this.length; i++) { + var _ele2 = this[i]; + var parent = hasCompoundNodes ? _ele2.parent() : null; + var hasParent = parent && parent.length > 0; + var relativeToParent = hasParent; + if (hasParent) { + parent = parent[0]; + } + var origin = relativeToParent ? parent.position() : { + x: 0, + y: 0 + }; + if (val !== undefined) { + // set one dimension + _ele2.position(dim, val + origin[dim]); + } else if (ppos !== undefined) { + // set whole position + _ele2.position({ + x: ppos.x + origin.x, + y: ppos.y + origin.y + }); + } + } + } else { + // getting + var pos = ele.position(); + var _parent = hasCompoundNodes ? ele.parent() : null; + var _hasParent = _parent && _parent.length > 0; + var _relativeToParent = _hasParent; + if (_hasParent) { + _parent = _parent[0]; + } + var _origin = _relativeToParent ? _parent.position() : { + x: 0, + y: 0 + }; + ppos = { + x: pos.x - _origin.x, + y: pos.y - _origin.y + }; + if (dim === undefined) { + // then return the whole rendered position + return ppos; + } else { + // then return the specified dimension + return ppos[dim]; + } + } + } else if (!setting) { + return undefined; // for empty collection case + } + + return this; // chaining + } +}; + +// aliases +fn$4.modelPosition = fn$4.point = fn$4.position; +fn$4.modelPositions = fn$4.points = fn$4.positions; +fn$4.renderedPoint = fn$4.renderedPosition; +fn$4.relativePoint = fn$4.relativePosition; +var position = elesfn$c; + +var fn$3, elesfn$b; +fn$3 = elesfn$b = {}; +elesfn$b.renderedBoundingBox = function (options) { + var bb = this.boundingBox(options); + var cy = this.cy(); + var zoom = cy.zoom(); + var pan = cy.pan(); + var x1 = bb.x1 * zoom + pan.x; + var x2 = bb.x2 * zoom + pan.x; + var y1 = bb.y1 * zoom + pan.y; + var y2 = bb.y2 * zoom + pan.y; + return { + x1: x1, + x2: x2, + y1: y1, + y2: y2, + w: x2 - x1, + h: y2 - y1 + }; +}; +elesfn$b.dirtyCompoundBoundsCache = function () { + var silent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var cy = this.cy(); + if (!cy.styleEnabled() || !cy.hasCompoundNodes()) { + return this; + } + this.forEachUp(function (ele) { + if (ele.isParent()) { + var _p = ele._private; + _p.compoundBoundsClean = false; + _p.bbCache = null; + if (!silent) { + ele.emitAndNotify('bounds'); + } + } + }); + return this; +}; +elesfn$b.updateCompoundBounds = function () { + var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var cy = this.cy(); + + // not possible to do on non-compound graphs or with the style disabled + if (!cy.styleEnabled() || !cy.hasCompoundNodes()) { + return this; + } + + // save cycles when batching -- but bounds will be stale (or not exist yet) + if (!force && cy.batching()) { + return this; + } + function update(parent) { + if (!parent.isParent()) { + return; + } + var _p = parent._private; + var children = parent.children(); + var includeLabels = parent.pstyle('compound-sizing-wrt-labels').value === 'include'; + var min = { + width: { + val: parent.pstyle('min-width').pfValue, + left: parent.pstyle('min-width-bias-left'), + right: parent.pstyle('min-width-bias-right') + }, + height: { + val: parent.pstyle('min-height').pfValue, + top: parent.pstyle('min-height-bias-top'), + bottom: parent.pstyle('min-height-bias-bottom') + } + }; + var bb = children.boundingBox({ + includeLabels: includeLabels, + includeOverlays: false, + // updating the compound bounds happens outside of the regular + // cache cycle (i.e. before fired events) + useCache: false + }); + var pos = _p.position; + + // if children take up zero area then keep position and fall back on stylesheet w/h + if (bb.w === 0 || bb.h === 0) { + bb = { + w: parent.pstyle('width').pfValue, + h: parent.pstyle('height').pfValue + }; + bb.x1 = pos.x - bb.w / 2; + bb.x2 = pos.x + bb.w / 2; + bb.y1 = pos.y - bb.h / 2; + bb.y2 = pos.y + bb.h / 2; + } + function computeBiasValues(propDiff, propBias, propBiasComplement) { + var biasDiff = 0; + var biasComplementDiff = 0; + var biasTotal = propBias + propBiasComplement; + if (propDiff > 0 && biasTotal > 0) { + biasDiff = propBias / biasTotal * propDiff; + biasComplementDiff = propBiasComplement / biasTotal * propDiff; + } + return { + biasDiff: biasDiff, + biasComplementDiff: biasComplementDiff + }; + } + function computePaddingValues(width, height, paddingObject, relativeTo) { + // Assuming percentage is number from 0 to 1 + if (paddingObject.units === '%') { + switch (relativeTo) { + case 'width': + return width > 0 ? paddingObject.pfValue * width : 0; + case 'height': + return height > 0 ? paddingObject.pfValue * height : 0; + case 'average': + return width > 0 && height > 0 ? paddingObject.pfValue * (width + height) / 2 : 0; + case 'min': + return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * height : paddingObject.pfValue * width : 0; + case 'max': + return width > 0 && height > 0 ? width > height ? paddingObject.pfValue * width : paddingObject.pfValue * height : 0; + default: + return 0; + } + } else if (paddingObject.units === 'px') { + return paddingObject.pfValue; + } else { + return 0; + } + } + var leftVal = min.width.left.value; + if (min.width.left.units === 'px' && min.width.val > 0) { + leftVal = leftVal * 100 / min.width.val; + } + var rightVal = min.width.right.value; + if (min.width.right.units === 'px' && min.width.val > 0) { + rightVal = rightVal * 100 / min.width.val; + } + var topVal = min.height.top.value; + if (min.height.top.units === 'px' && min.height.val > 0) { + topVal = topVal * 100 / min.height.val; + } + var bottomVal = min.height.bottom.value; + if (min.height.bottom.units === 'px' && min.height.val > 0) { + bottomVal = bottomVal * 100 / min.height.val; + } + var widthBiasDiffs = computeBiasValues(min.width.val - bb.w, leftVal, rightVal); + var diffLeft = widthBiasDiffs.biasDiff; + var diffRight = widthBiasDiffs.biasComplementDiff; + var heightBiasDiffs = computeBiasValues(min.height.val - bb.h, topVal, bottomVal); + var diffTop = heightBiasDiffs.biasDiff; + var diffBottom = heightBiasDiffs.biasComplementDiff; + _p.autoPadding = computePaddingValues(bb.w, bb.h, parent.pstyle('padding'), parent.pstyle('padding-relative-to').value); + _p.autoWidth = Math.max(bb.w, min.width.val); + pos.x = (-diffLeft + bb.x1 + bb.x2 + diffRight) / 2; + _p.autoHeight = Math.max(bb.h, min.height.val); + pos.y = (-diffTop + bb.y1 + bb.y2 + diffBottom) / 2; + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _p = ele._private; + if (!_p.compoundBoundsClean || force) { + update(ele); + if (!cy.batching()) { + _p.compoundBoundsClean = true; + } + } + } + return this; +}; +var noninf = function noninf(x) { + if (x === Infinity || x === -Infinity) { + return 0; + } + return x; +}; +var updateBounds = function updateBounds(b, x1, y1, x2, y2) { + // don't update with zero area boxes + if (x2 - x1 === 0 || y2 - y1 === 0) { + return; + } + + // don't update with null dim + if (x1 == null || y1 == null || x2 == null || y2 == null) { + return; + } + b.x1 = x1 < b.x1 ? x1 : b.x1; + b.x2 = x2 > b.x2 ? x2 : b.x2; + b.y1 = y1 < b.y1 ? y1 : b.y1; + b.y2 = y2 > b.y2 ? y2 : b.y2; + b.w = b.x2 - b.x1; + b.h = b.y2 - b.y1; +}; +var updateBoundsFromBox = function updateBoundsFromBox(b, b2) { + if (b2 == null) { + return b; + } + return updateBounds(b, b2.x1, b2.y1, b2.x2, b2.y2); +}; +var prefixedProperty = function prefixedProperty(obj, field, prefix) { + return getPrefixedProperty(obj, field, prefix); +}; +var updateBoundsFromArrow = function updateBoundsFromArrow(bounds, ele, prefix) { + if (ele.cy().headless()) { + return; + } + var _p = ele._private; + var rstyle = _p.rstyle; + var halfArW = rstyle.arrowWidth / 2; + var arrowType = ele.pstyle(prefix + '-arrow-shape').value; + var x; + var y; + if (arrowType !== 'none') { + if (prefix === 'source') { + x = rstyle.srcX; + y = rstyle.srcY; + } else if (prefix === 'target') { + x = rstyle.tgtX; + y = rstyle.tgtY; + } else { + x = rstyle.midX; + y = rstyle.midY; + } + + // always store the individual arrow bounds + var bbs = _p.arrowBounds = _p.arrowBounds || {}; + var bb = bbs[prefix] = bbs[prefix] || {}; + bb.x1 = x - halfArW; + bb.y1 = y - halfArW; + bb.x2 = x + halfArW; + bb.y2 = y + halfArW; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + expandBoundingBox(bb, 1); + updateBounds(bounds, bb.x1, bb.y1, bb.x2, bb.y2); + } +}; +var updateBoundsFromLabel = function updateBoundsFromLabel(bounds, ele, prefix) { + if (ele.cy().headless()) { + return; + } + var prefixDash; + if (prefix) { + prefixDash = prefix + '-'; + } else { + prefixDash = ''; + } + var _p = ele._private; + var rstyle = _p.rstyle; + var label = ele.pstyle(prefixDash + 'label').strValue; + if (label) { + var halign = ele.pstyle('text-halign'); + var valign = ele.pstyle('text-valign'); + var labelWidth = prefixedProperty(rstyle, 'labelWidth', prefix); + var labelHeight = prefixedProperty(rstyle, 'labelHeight', prefix); + var labelX = prefixedProperty(rstyle, 'labelX', prefix); + var labelY = prefixedProperty(rstyle, 'labelY', prefix); + var marginX = ele.pstyle(prefixDash + 'text-margin-x').pfValue; + var marginY = ele.pstyle(prefixDash + 'text-margin-y').pfValue; + var isEdge = ele.isEdge(); + var rotation = ele.pstyle(prefixDash + 'text-rotation'); + var outlineWidth = ele.pstyle('text-outline-width').pfValue; + var borderWidth = ele.pstyle('text-border-width').pfValue; + var halfBorderWidth = borderWidth / 2; + var padding = ele.pstyle('text-background-padding').pfValue; + var marginOfError = 2; // expand to work around browser dimension inaccuracies + + var lh = labelHeight; + var lw = labelWidth; + var lw_2 = lw / 2; + var lh_2 = lh / 2; + var lx1, lx2, ly1, ly2; + if (isEdge) { + lx1 = labelX - lw_2; + lx2 = labelX + lw_2; + ly1 = labelY - lh_2; + ly2 = labelY + lh_2; + } else { + switch (halign.value) { + case 'left': + lx1 = labelX - lw; + lx2 = labelX; + break; + case 'center': + lx1 = labelX - lw_2; + lx2 = labelX + lw_2; + break; + case 'right': + lx1 = labelX; + lx2 = labelX + lw; + break; + } + switch (valign.value) { + case 'top': + ly1 = labelY - lh; + ly2 = labelY; + break; + case 'center': + ly1 = labelY - lh_2; + ly2 = labelY + lh_2; + break; + case 'bottom': + ly1 = labelY; + ly2 = labelY + lh; + break; + } + } + + // shift by margin and expand by outline and border + lx1 += marginX - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; + lx2 += marginX + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; + ly1 += marginY - Math.max(outlineWidth, halfBorderWidth) - padding - marginOfError; + ly2 += marginY + Math.max(outlineWidth, halfBorderWidth) + padding + marginOfError; + + // always store the unrotated label bounds separately + var bbPrefix = prefix || 'main'; + var bbs = _p.labelBounds; + var bb = bbs[bbPrefix] = bbs[bbPrefix] || {}; + bb.x1 = lx1; + bb.y1 = ly1; + bb.x2 = lx2; + bb.y2 = ly2; + bb.w = lx2 - lx1; + bb.h = ly2 - ly1; + var isAutorotate = isEdge && rotation.strValue === 'autorotate'; + var isPfValue = rotation.pfValue != null && rotation.pfValue !== 0; + if (isAutorotate || isPfValue) { + var theta = isAutorotate ? prefixedProperty(_p.rstyle, 'labelAngle', prefix) : rotation.pfValue; + var cos = Math.cos(theta); + var sin = Math.sin(theta); + + // rotation point (default value for center-center) + var xo = (lx1 + lx2) / 2; + var yo = (ly1 + ly2) / 2; + if (!isEdge) { + switch (halign.value) { + case 'left': + xo = lx2; + break; + case 'right': + xo = lx1; + break; + } + switch (valign.value) { + case 'top': + yo = ly2; + break; + case 'bottom': + yo = ly1; + break; + } + } + var rotate = function rotate(x, y) { + x = x - xo; + y = y - yo; + return { + x: x * cos - y * sin + xo, + y: x * sin + y * cos + yo + }; + }; + var px1y1 = rotate(lx1, ly1); + var px1y2 = rotate(lx1, ly2); + var px2y1 = rotate(lx2, ly1); + var px2y2 = rotate(lx2, ly2); + lx1 = Math.min(px1y1.x, px1y2.x, px2y1.x, px2y2.x); + lx2 = Math.max(px1y1.x, px1y2.x, px2y1.x, px2y2.x); + ly1 = Math.min(px1y1.y, px1y2.y, px2y1.y, px2y2.y); + ly2 = Math.max(px1y1.y, px1y2.y, px2y1.y, px2y2.y); + } + var bbPrefixRot = bbPrefix + 'Rot'; + var bbRot = bbs[bbPrefixRot] = bbs[bbPrefixRot] || {}; + bbRot.x1 = lx1; + bbRot.y1 = ly1; + bbRot.x2 = lx2; + bbRot.y2 = ly2; + bbRot.w = lx2 - lx1; + bbRot.h = ly2 - ly1; + updateBounds(bounds, lx1, ly1, lx2, ly2); + updateBounds(_p.labelBounds.all, lx1, ly1, lx2, ly2); + } + return bounds; +}; +var updateBoundsFromOutline = function updateBoundsFromOutline(bounds, ele) { + if (ele.cy().headless()) { + return; + } + var outlineOpacity = ele.pstyle('outline-opacity').value; + var outlineWidth = ele.pstyle('outline-width').value; + if (outlineOpacity > 0 && outlineWidth > 0) { + var outlineOffset = ele.pstyle('outline-offset').value; + var nodeShape = ele.pstyle('shape').value; + var outlineSize = outlineWidth + outlineOffset; + var scaleX = (bounds.w + outlineSize * 2) / bounds.w; + var scaleY = (bounds.h + outlineSize * 2) / bounds.h; + var xOffset = 0; + var yOffset = 0; + if (["diamond", "pentagon", "round-triangle"].includes(nodeShape)) { + scaleX = (bounds.w + outlineSize * 2.4) / bounds.w; + yOffset = -outlineSize / 3.6; + } else if (["concave-hexagon", "rhomboid", "right-rhomboid"].includes(nodeShape)) { + scaleX = (bounds.w + outlineSize * 2.4) / bounds.w; + } else if (nodeShape === "star") { + scaleX = (bounds.w + outlineSize * 2.8) / bounds.w; + scaleY = (bounds.h + outlineSize * 2.6) / bounds.h; + yOffset = -outlineSize / 3.8; + } else if (nodeShape === "triangle") { + scaleX = (bounds.w + outlineSize * 2.8) / bounds.w; + scaleY = (bounds.h + outlineSize * 2.4) / bounds.h; + yOffset = -outlineSize / 1.4; + } else if (nodeShape === "vee") { + scaleX = (bounds.w + outlineSize * 4.4) / bounds.w; + scaleY = (bounds.h + outlineSize * 3.8) / bounds.h; + yOffset = -outlineSize * .5; + } + var hDelta = bounds.h * scaleY - bounds.h; + var wDelta = bounds.w * scaleX - bounds.w; + expandBoundingBoxSides(bounds, [Math.ceil(hDelta / 2), Math.ceil(wDelta / 2)]); + if (xOffset != 0 || yOffset !== 0) { + var oBounds = shiftBoundingBox(bounds, xOffset, yOffset); + updateBoundingBox(bounds, oBounds); + } + } +}; + +// get the bounding box of the elements (in raw model position) +var boundingBoxImpl = function boundingBoxImpl(ele, options) { + var cy = ele._private.cy; + var styleEnabled = cy.styleEnabled(); + var headless = cy.headless(); + var bounds = makeBoundingBox(); + var _p = ele._private; + var isNode = ele.isNode(); + var isEdge = ele.isEdge(); + var ex1, ex2, ey1, ey2; // extrema of body / lines + var x, y; // node pos + var rstyle = _p.rstyle; + var manualExpansion = isNode && styleEnabled ? ele.pstyle('bounds-expansion').pfValue : [0]; + + // must use `display` prop only, as reading `compound.width()` causes recursion + // (other factors like width values will be considered later in this function anyway) + var isDisplayed = function isDisplayed(ele) { + return ele.pstyle('display').value !== 'none'; + }; + var displayed = !styleEnabled || isDisplayed(ele) + + // must take into account connected nodes b/c of implicit edge hiding on display:none node + && (!isEdge || isDisplayed(ele.source()) && isDisplayed(ele.target())); + if (displayed) { + // displayed suffices, since we will find zero area eles anyway + var overlayOpacity = 0; + var overlayPadding = 0; + if (styleEnabled && options.includeOverlays) { + overlayOpacity = ele.pstyle('overlay-opacity').value; + if (overlayOpacity !== 0) { + overlayPadding = ele.pstyle('overlay-padding').value; + } + } + var underlayOpacity = 0; + var underlayPadding = 0; + if (styleEnabled && options.includeUnderlays) { + underlayOpacity = ele.pstyle('underlay-opacity').value; + if (underlayOpacity !== 0) { + underlayPadding = ele.pstyle('underlay-padding').value; + } + } + var padding = Math.max(overlayPadding, underlayPadding); + var w = 0; + var wHalf = 0; + if (styleEnabled) { + w = ele.pstyle('width').pfValue; + wHalf = w / 2; + } + if (isNode && options.includeNodes) { + var pos = ele.position(); + x = pos.x; + y = pos.y; + var _w = ele.outerWidth(); + var halfW = _w / 2; + var h = ele.outerHeight(); + var halfH = h / 2; + + // handle node dimensions + ///////////////////////// + + ex1 = x - halfW; + ex2 = x + halfW; + ey1 = y - halfH; + ey2 = y + halfH; + updateBounds(bounds, ex1, ey1, ex2, ey2); + if (styleEnabled && options.includeOutlines) { + updateBoundsFromOutline(bounds, ele); + } + } else if (isEdge && options.includeEdges) { + if (styleEnabled && !headless) { + var curveStyle = ele.pstyle('curve-style').strValue; + + // handle edge dimensions (rough box estimate) + ////////////////////////////////////////////// + + ex1 = Math.min(rstyle.srcX, rstyle.midX, rstyle.tgtX); + ex2 = Math.max(rstyle.srcX, rstyle.midX, rstyle.tgtX); + ey1 = Math.min(rstyle.srcY, rstyle.midY, rstyle.tgtY); + ey2 = Math.max(rstyle.srcY, rstyle.midY, rstyle.tgtY); + + // take into account edge width + ex1 -= wHalf; + ex2 += wHalf; + ey1 -= wHalf; + ey2 += wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + + // precise edges + //////////////// + + if (curveStyle === 'haystack') { + var hpts = rstyle.haystackPts; + if (hpts && hpts.length === 2) { + ex1 = hpts[0].x; + ey1 = hpts[0].y; + ex2 = hpts[1].x; + ey2 = hpts[1].y; + if (ex1 > ex2) { + var temp = ex1; + ex1 = ex2; + ex2 = temp; + } + if (ey1 > ey2) { + var _temp = ey1; + ey1 = ey2; + ey2 = _temp; + } + updateBounds(bounds, ex1 - wHalf, ey1 - wHalf, ex2 + wHalf, ey2 + wHalf); + } + } else if (curveStyle === 'bezier' || curveStyle === 'unbundled-bezier' || curveStyle.endsWith('segments') || curveStyle.endsWith('taxi')) { + var pts; + switch (curveStyle) { + case 'bezier': + case 'unbundled-bezier': + pts = rstyle.bezierPts; + break; + case 'segments': + case 'taxi': + case 'round-segments': + case 'round-taxi': + pts = rstyle.linePts; + break; + } + if (pts != null) { + for (var j = 0; j < pts.length; j++) { + var pt = pts[j]; + ex1 = pt.x - wHalf; + ex2 = pt.x + wHalf; + ey1 = pt.y - wHalf; + ey2 = pt.y + wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + } + } + } // bezier-like or segment-like edge + } else { + // headless or style disabled + + // fallback on source and target positions + ////////////////////////////////////////// + + var n1 = ele.source(); + var n1pos = n1.position(); + var n2 = ele.target(); + var n2pos = n2.position(); + ex1 = n1pos.x; + ex2 = n2pos.x; + ey1 = n1pos.y; + ey2 = n2pos.y; + if (ex1 > ex2) { + var _temp2 = ex1; + ex1 = ex2; + ex2 = _temp2; + } + if (ey1 > ey2) { + var _temp3 = ey1; + ey1 = ey2; + ey2 = _temp3; + } + + // take into account edge width + ex1 -= wHalf; + ex2 += wHalf; + ey1 -= wHalf; + ey2 += wHalf; + updateBounds(bounds, ex1, ey1, ex2, ey2); + } // headless or style disabled + } // edges + + // handle edge arrow size + ///////////////////////// + + if (styleEnabled && options.includeEdges && isEdge) { + updateBoundsFromArrow(bounds, ele, 'mid-source'); + updateBoundsFromArrow(bounds, ele, 'mid-target'); + updateBoundsFromArrow(bounds, ele, 'source'); + updateBoundsFromArrow(bounds, ele, 'target'); + } + + // ghost + //////// + + if (styleEnabled) { + var ghost = ele.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = ele.pstyle('ghost-offset-x').pfValue; + var gy = ele.pstyle('ghost-offset-y').pfValue; + updateBounds(bounds, bounds.x1 + gx, bounds.y1 + gy, bounds.x2 + gx, bounds.y2 + gy); + } + } + + // always store the body bounds separately from the labels + var bbBody = _p.bodyBounds = _p.bodyBounds || {}; + assignBoundingBox(bbBody, bounds); + expandBoundingBoxSides(bbBody, manualExpansion); + expandBoundingBox(bbBody, 1); // expand to work around browser dimension inaccuracies + + // overlay + ////////// + + if (styleEnabled) { + ex1 = bounds.x1; + ex2 = bounds.x2; + ey1 = bounds.y1; + ey2 = bounds.y2; + updateBounds(bounds, ex1 - padding, ey1 - padding, ex2 + padding, ey2 + padding); + } + + // always store the body bounds separately from the labels + var bbOverlay = _p.overlayBounds = _p.overlayBounds || {}; + assignBoundingBox(bbOverlay, bounds); + expandBoundingBoxSides(bbOverlay, manualExpansion); + expandBoundingBox(bbOverlay, 1); // expand to work around browser dimension inaccuracies + + // handle label dimensions + ////////////////////////// + + var bbLabels = _p.labelBounds = _p.labelBounds || {}; + if (bbLabels.all != null) { + clearBoundingBox(bbLabels.all); + } else { + bbLabels.all = makeBoundingBox(); + } + if (styleEnabled && options.includeLabels) { + if (options.includeMainLabels) { + updateBoundsFromLabel(bounds, ele, null); + } + if (isEdge) { + if (options.includeSourceLabels) { + updateBoundsFromLabel(bounds, ele, 'source'); + } + if (options.includeTargetLabels) { + updateBoundsFromLabel(bounds, ele, 'target'); + } + } + } // style enabled for labels + } // if displayed + + bounds.x1 = noninf(bounds.x1); + bounds.y1 = noninf(bounds.y1); + bounds.x2 = noninf(bounds.x2); + bounds.y2 = noninf(bounds.y2); + bounds.w = noninf(bounds.x2 - bounds.x1); + bounds.h = noninf(bounds.y2 - bounds.y1); + if (bounds.w > 0 && bounds.h > 0 && displayed) { + expandBoundingBoxSides(bounds, manualExpansion); + + // expand bounds by 1 because antialiasing can increase the visual/effective size by 1 on all sides + expandBoundingBox(bounds, 1); + } + return bounds; +}; +var getKey = function getKey(opts) { + var i = 0; + var tf = function tf(val) { + return (val ? 1 : 0) << i++; + }; + var key = 0; + key += tf(opts.incudeNodes); + key += tf(opts.includeEdges); + key += tf(opts.includeLabels); + key += tf(opts.includeMainLabels); + key += tf(opts.includeSourceLabels); + key += tf(opts.includeTargetLabels); + key += tf(opts.includeOverlays); + key += tf(opts.includeOutlines); + return key; +}; +var getBoundingBoxPosKey = function getBoundingBoxPosKey(ele) { + if (ele.isEdge()) { + var p1 = ele.source().position(); + var p2 = ele.target().position(); + var r = function r(x) { + return Math.round(x); + }; + return hashIntsArray([r(p1.x), r(p1.y), r(p2.x), r(p2.y)]); + } else { + return 0; + } +}; +var cachedBoundingBoxImpl = function cachedBoundingBoxImpl(ele, opts) { + var _p = ele._private; + var bb; + var isEdge = ele.isEdge(); + var key = opts == null ? defBbOptsKey : getKey(opts); + var usingDefOpts = key === defBbOptsKey; + var currPosKey = getBoundingBoxPosKey(ele); + var isPosKeySame = _p.bbCachePosKey === currPosKey; + var useCache = opts.useCache && isPosKeySame; + var isDirty = function isDirty(ele) { + return ele._private.bbCache == null || ele._private.styleDirty; + }; + var needRecalc = !useCache || isDirty(ele) || isEdge && isDirty(ele.source()) || isDirty(ele.target()); + if (needRecalc) { + if (!isPosKeySame) { + ele.recalculateRenderedStyle(useCache); + } + bb = boundingBoxImpl(ele, defBbOpts); + _p.bbCache = bb; + _p.bbCachePosKey = currPosKey; + } else { + bb = _p.bbCache; + } + + // not using def opts => need to build up bb from combination of sub bbs + if (!usingDefOpts) { + var isNode = ele.isNode(); + bb = makeBoundingBox(); + if (opts.includeNodes && isNode || opts.includeEdges && !isNode) { + if (opts.includeOverlays) { + updateBoundsFromBox(bb, _p.overlayBounds); + } else { + updateBoundsFromBox(bb, _p.bodyBounds); + } + } + if (opts.includeLabels) { + if (opts.includeMainLabels && (!isEdge || opts.includeSourceLabels && opts.includeTargetLabels)) { + updateBoundsFromBox(bb, _p.labelBounds.all); + } else { + if (opts.includeMainLabels) { + updateBoundsFromBox(bb, _p.labelBounds.mainRot); + } + if (opts.includeSourceLabels) { + updateBoundsFromBox(bb, _p.labelBounds.sourceRot); + } + if (opts.includeTargetLabels) { + updateBoundsFromBox(bb, _p.labelBounds.targetRot); + } + } + } + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + } + return bb; +}; +var defBbOpts = { + includeNodes: true, + includeEdges: true, + includeLabels: true, + includeMainLabels: true, + includeSourceLabels: true, + includeTargetLabels: true, + includeOverlays: true, + includeUnderlays: true, + includeOutlines: true, + useCache: true +}; +var defBbOptsKey = getKey(defBbOpts); +var filledBbOpts = defaults$g(defBbOpts); +elesfn$b.boundingBox = function (options) { + var bounds; + + // the main usecase is ele.boundingBox() for a single element with no/def options + // specified s.t. the cache is used, so check for this case to make it faster by + // avoiding the overhead of the rest of the function + if (this.length === 1 && this[0]._private.bbCache != null && !this[0]._private.styleDirty && (options === undefined || options.useCache === undefined || options.useCache === true)) { + if (options === undefined) { + options = defBbOpts; + } else { + options = filledBbOpts(options); + } + bounds = cachedBoundingBoxImpl(this[0], options); + } else { + bounds = makeBoundingBox(); + options = options || defBbOpts; + var opts = filledBbOpts(options); + var eles = this; + var cy = eles.cy(); + var styleEnabled = cy.styleEnabled(); + if (styleEnabled) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var currPosKey = getBoundingBoxPosKey(ele); + var isPosKeySame = _p.bbCachePosKey === currPosKey; + var useCache = opts.useCache && isPosKeySame && !_p.styleDirty; + ele.recalculateRenderedStyle(useCache); + } + } + this.updateCompoundBounds(!options.useCache); + for (var _i = 0; _i < eles.length; _i++) { + var _ele = eles[_i]; + updateBoundsFromBox(bounds, cachedBoundingBoxImpl(_ele, opts)); + } + } + bounds.x1 = noninf(bounds.x1); + bounds.y1 = noninf(bounds.y1); + bounds.x2 = noninf(bounds.x2); + bounds.y2 = noninf(bounds.y2); + bounds.w = noninf(bounds.x2 - bounds.x1); + bounds.h = noninf(bounds.y2 - bounds.y1); + return bounds; +}; +elesfn$b.dirtyBoundingBoxCache = function () { + for (var i = 0; i < this.length; i++) { + var _p = this[i]._private; + _p.bbCache = null; + _p.bbCachePosKey = null; + _p.bodyBounds = null; + _p.overlayBounds = null; + _p.labelBounds.all = null; + _p.labelBounds.source = null; + _p.labelBounds.target = null; + _p.labelBounds.main = null; + _p.labelBounds.sourceRot = null; + _p.labelBounds.targetRot = null; + _p.labelBounds.mainRot = null; + _p.arrowBounds.source = null; + _p.arrowBounds.target = null; + _p.arrowBounds['mid-source'] = null; + _p.arrowBounds['mid-target'] = null; + } + this.emitAndNotify('bounds'); + return this; +}; + +// private helper to get bounding box for custom node positions +// - good for perf in certain cases but currently requires dirtying the rendered style +// - would be better to not modify the nodes but the nodes are read directly everywhere in the renderer... +// - try to use for only things like discrete layouts where the node position would change anyway +elesfn$b.boundingBoxAt = function (fn) { + var nodes = this.nodes(); + var cy = this.cy(); + var hasCompoundNodes = cy.hasCompoundNodes(); + var parents = cy.collection(); + if (hasCompoundNodes) { + parents = nodes.filter(function (node) { + return node.isParent(); + }); + nodes = nodes.not(parents); + } + if (plainObject(fn)) { + var obj = fn; + fn = function fn() { + return obj; + }; + } + var storeOldPos = function storeOldPos(node, i) { + return node._private.bbAtOldPos = fn(node, i); + }; + var getOldPos = function getOldPos(node) { + return node._private.bbAtOldPos; + }; + cy.startBatch(); + nodes.forEach(storeOldPos).silentPositions(fn); + if (hasCompoundNodes) { + parents.dirtyCompoundBoundsCache(); + parents.dirtyBoundingBoxCache(); + parents.updateCompoundBounds(true); // force update b/c we're inside a batch cycle + } + + var bb = copyBoundingBox(this.boundingBox({ + useCache: false + })); + nodes.silentPositions(getOldPos); + if (hasCompoundNodes) { + parents.dirtyCompoundBoundsCache(); + parents.dirtyBoundingBoxCache(); + parents.updateCompoundBounds(true); // force update b/c we're inside a batch cycle + } + + cy.endBatch(); + return bb; +}; +fn$3.boundingbox = fn$3.bb = fn$3.boundingBox; +fn$3.renderedBoundingbox = fn$3.renderedBoundingBox; +var bounds = elesfn$b; + +var fn$2, elesfn$a; +fn$2 = elesfn$a = {}; +var defineDimFns = function defineDimFns(opts) { + opts.uppercaseName = capitalize(opts.name); + opts.autoName = 'auto' + opts.uppercaseName; + opts.labelName = 'label' + opts.uppercaseName; + opts.outerName = 'outer' + opts.uppercaseName; + opts.uppercaseOuterName = capitalize(opts.outerName); + fn$2[opts.name] = function dimImpl() { + var ele = this[0]; + var _p = ele._private; + var cy = _p.cy; + var styleEnabled = cy._private.styleEnabled; + if (ele) { + if (styleEnabled) { + if (ele.isParent()) { + ele.updateCompoundBounds(); + return _p[opts.autoName] || 0; + } + var d = ele.pstyle(opts.name); + switch (d.strValue) { + case 'label': + ele.recalculateRenderedStyle(); + return _p.rstyle[opts.labelName] || 0; + default: + return d.pfValue; + } + } else { + return 1; + } + } + }; + fn$2['outer' + opts.uppercaseName] = function outerDimImpl() { + var ele = this[0]; + var _p = ele._private; + var cy = _p.cy; + var styleEnabled = cy._private.styleEnabled; + if (ele) { + if (styleEnabled) { + var dim = ele[opts.name](); + var border = ele.pstyle('border-width').pfValue; // n.b. 1/2 each side + var padding = 2 * ele.padding(); + return dim + border + padding; + } else { + return 1; + } + } + }; + fn$2['rendered' + opts.uppercaseName] = function renderedDimImpl() { + var ele = this[0]; + if (ele) { + var d = ele[opts.name](); + return d * this.cy().zoom(); + } + }; + fn$2['rendered' + opts.uppercaseOuterName] = function renderedOuterDimImpl() { + var ele = this[0]; + if (ele) { + var od = ele[opts.outerName](); + return od * this.cy().zoom(); + } + }; +}; +defineDimFns({ + name: 'width' +}); +defineDimFns({ + name: 'height' +}); +elesfn$a.padding = function () { + var ele = this[0]; + var _p = ele._private; + if (ele.isParent()) { + ele.updateCompoundBounds(); + if (_p.autoPadding !== undefined) { + return _p.autoPadding; + } else { + return ele.pstyle('padding').pfValue; + } + } else { + return ele.pstyle('padding').pfValue; + } +}; +elesfn$a.paddedHeight = function () { + var ele = this[0]; + return ele.height() + 2 * ele.padding(); +}; +elesfn$a.paddedWidth = function () { + var ele = this[0]; + return ele.width() + 2 * ele.padding(); +}; +var widthHeight = elesfn$a; + +var ifEdge = function ifEdge(ele, getValue) { + if (ele.isEdge()) { + return getValue(ele); + } +}; +var ifEdgeRenderedPosition = function ifEdgeRenderedPosition(ele, getPoint) { + if (ele.isEdge()) { + var cy = ele.cy(); + return modelToRenderedPosition(getPoint(ele), cy.zoom(), cy.pan()); + } +}; +var ifEdgeRenderedPositions = function ifEdgeRenderedPositions(ele, getPoints) { + if (ele.isEdge()) { + var cy = ele.cy(); + var pan = cy.pan(); + var zoom = cy.zoom(); + return getPoints(ele).map(function (p) { + return modelToRenderedPosition(p, zoom, pan); + }); + } +}; +var controlPoints = function controlPoints(ele) { + return ele.renderer().getControlPoints(ele); +}; +var segmentPoints = function segmentPoints(ele) { + return ele.renderer().getSegmentPoints(ele); +}; +var sourceEndpoint = function sourceEndpoint(ele) { + return ele.renderer().getSourceEndpoint(ele); +}; +var targetEndpoint = function targetEndpoint(ele) { + return ele.renderer().getTargetEndpoint(ele); +}; +var midpoint = function midpoint(ele) { + return ele.renderer().getEdgeMidpoint(ele); +}; +var pts = { + controlPoints: { + get: controlPoints, + mult: true + }, + segmentPoints: { + get: segmentPoints, + mult: true + }, + sourceEndpoint: { + get: sourceEndpoint + }, + targetEndpoint: { + get: targetEndpoint + }, + midpoint: { + get: midpoint + } +}; +var renderedName = function renderedName(name) { + return 'rendered' + name[0].toUpperCase() + name.substr(1); +}; +var edgePoints = Object.keys(pts).reduce(function (obj, name) { + var spec = pts[name]; + var rName = renderedName(name); + obj[name] = function () { + return ifEdge(this, spec.get); + }; + if (spec.mult) { + obj[rName] = function () { + return ifEdgeRenderedPositions(this, spec.get); + }; + } else { + obj[rName] = function () { + return ifEdgeRenderedPosition(this, spec.get); + }; + } + return obj; +}, {}); + +var dimensions = extend({}, position, bounds, widthHeight, edgePoints); + +/*! +Event object based on jQuery events, MIT license + +https://jquery.org/license/ +https://tldrlegal.com/license/mit-license +https://github.com/jquery/jquery/blob/master/src/event.js +*/ + +var Event = function Event(src, props) { + this.recycle(src, props); +}; +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +Event.prototype = { + instanceString: function instanceString() { + return 'event'; + }, + recycle: function recycle(src, props) { + this.isImmediatePropagationStopped = this.isPropagationStopped = this.isDefaultPrevented = returnFalse; + if (src != null && src.preventDefault) { + // Browser Event object + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented ? returnTrue : returnFalse; + } else if (src != null && src.type) { + // Plain object containing all event details + props = src; + } else { + // Event string + this.type = src; + } + + // Put explicitly provided properties onto the event object + if (props != null) { + // more efficient to manually copy fields we use + this.originalEvent = props.originalEvent; + this.type = props.type != null ? props.type : this.type; + this.cy = props.cy; + this.target = props.target; + this.position = props.position; + this.renderedPosition = props.renderedPosition; + this.namespace = props.namespace; + this.layout = props.layout; + } + if (this.cy != null && this.position != null && this.renderedPosition == null) { + // create a rendered position based on the passed position + var pos = this.position; + var zoom = this.cy.zoom(); + var pan = this.cy.pan(); + this.renderedPosition = { + x: pos.x * zoom + pan.x, + y: pos.y * zoom + pan.y + }; + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || Date.now(); + }, + preventDefault: function preventDefault() { + this.isDefaultPrevented = returnTrue; + var e = this.originalEvent; + if (!e) { + return; + } + + // if preventDefault exists run it on the original event + if (e.preventDefault) { + e.preventDefault(); + } + }, + stopPropagation: function stopPropagation() { + this.isPropagationStopped = returnTrue; + var e = this.originalEvent; + if (!e) { + return; + } + + // if stopPropagation exists run it on the original event + if (e.stopPropagation) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function stopImmediatePropagation() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +var eventRegex = /^([^.]+)(\.(?:[^.]+))?$/; // regex for matching event strings (e.g. "click.namespace") +var universalNamespace = '.*'; // matches as if no namespace specified and prevents users from unbinding accidentally + +var defaults$8 = { + qualifierCompare: function qualifierCompare(q1, q2) { + return q1 === q2; + }, + eventMatches: function eventMatches( /*context, listener, eventObj*/ + ) { + return true; + }, + addEventFields: function addEventFields( /*context, evt*/ + ) {}, + callbackContext: function callbackContext(context /*, listener, eventObj*/) { + return context; + }, + beforeEmit: function beforeEmit( /* context, listener, eventObj */ + ) {}, + afterEmit: function afterEmit( /* context, listener, eventObj */ + ) {}, + bubble: function bubble( /*context*/ + ) { + return false; + }, + parent: function parent( /*context*/ + ) { + return null; + }, + context: null +}; +var defaultsKeys = Object.keys(defaults$8); +var emptyOpts = {}; +function Emitter() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : emptyOpts; + var context = arguments.length > 1 ? arguments[1] : undefined; + // micro-optimisation vs Object.assign() -- reduces Element instantiation time + for (var i = 0; i < defaultsKeys.length; i++) { + var key = defaultsKeys[i]; + this[key] = opts[key] || defaults$8[key]; + } + this.context = context || this.context; + this.listeners = []; + this.emitting = 0; +} +var p = Emitter.prototype; +var forEachEvent = function forEachEvent(self, handler, events, qualifier, callback, conf, confOverrides) { + if (fn$6(qualifier)) { + callback = qualifier; + qualifier = null; + } + if (confOverrides) { + if (conf == null) { + conf = confOverrides; + } else { + conf = extend({}, conf, confOverrides); + } + } + var eventList = array(events) ? events : events.split(/\s+/); + for (var i = 0; i < eventList.length; i++) { + var evt = eventList[i]; + if (emptyString(evt)) { + continue; + } + var match = evt.match(eventRegex); // type[.namespace] + + if (match) { + var type = match[1]; + var namespace = match[2] ? match[2] : null; + var ret = handler(self, evt, type, namespace, qualifier, callback, conf); + if (ret === false) { + break; + } // allow exiting early + } + } +}; + +var makeEventObj = function makeEventObj(self, obj) { + self.addEventFields(self.context, obj); + return new Event(obj.type, obj); +}; +var forEachEventObj = function forEachEventObj(self, handler, events) { + if (event(events)) { + handler(self, events); + return; + } else if (plainObject(events)) { + handler(self, makeEventObj(self, events)); + return; + } + var eventList = array(events) ? events : events.split(/\s+/); + for (var i = 0; i < eventList.length; i++) { + var evt = eventList[i]; + if (emptyString(evt)) { + continue; + } + var match = evt.match(eventRegex); // type[.namespace] + + if (match) { + var type = match[1]; + var namespace = match[2] ? match[2] : null; + var eventObj = makeEventObj(self, { + type: type, + namespace: namespace, + target: self.context + }); + handler(self, eventObj); + } + } +}; +p.on = p.addListener = function (events, qualifier, callback, conf, confOverrides) { + forEachEvent(this, function (self, event, type, namespace, qualifier, callback, conf) { + if (fn$6(callback)) { + self.listeners.push({ + event: event, + // full event string + callback: callback, + // callback to run + type: type, + // the event type (e.g. 'click') + namespace: namespace, + // the event namespace (e.g. ".foo") + qualifier: qualifier, + // a restriction on whether to match this emitter + conf: conf // additional configuration + }); + } + }, events, qualifier, callback, conf, confOverrides); + return this; +}; +p.one = function (events, qualifier, callback, conf) { + return this.on(events, qualifier, callback, conf, { + one: true + }); +}; +p.removeListener = p.off = function (events, qualifier, callback, conf) { + var _this = this; + if (this.emitting !== 0) { + this.listeners = copyArray$1(this.listeners); + } + var listeners = this.listeners; + var _loop = function _loop(i) { + var listener = listeners[i]; + forEachEvent(_this, function (self, event, type, namespace, qualifier, callback /*, conf*/) { + if ((listener.type === type || events === '*') && (!namespace && listener.namespace !== '.*' || listener.namespace === namespace) && (!qualifier || self.qualifierCompare(listener.qualifier, qualifier)) && (!callback || listener.callback === callback)) { + listeners.splice(i, 1); + return false; + } + }, events, qualifier, callback, conf); + }; + for (var i = listeners.length - 1; i >= 0; i--) { + _loop(i); + } + return this; +}; +p.removeAllListeners = function () { + return this.removeListener('*'); +}; +p.emit = p.trigger = function (events, extraParams, manualCallback) { + var listeners = this.listeners; + var numListenersBeforeEmit = listeners.length; + this.emitting++; + if (!array(extraParams)) { + extraParams = [extraParams]; + } + forEachEventObj(this, function (self, eventObj) { + if (manualCallback != null) { + listeners = [{ + event: eventObj.event, + type: eventObj.type, + namespace: eventObj.namespace, + callback: manualCallback + }]; + numListenersBeforeEmit = listeners.length; + } + var _loop2 = function _loop2(i) { + var listener = listeners[i]; + if (listener.type === eventObj.type && (!listener.namespace || listener.namespace === eventObj.namespace || listener.namespace === universalNamespace) && self.eventMatches(self.context, listener, eventObj)) { + var args = [eventObj]; + if (extraParams != null) { + push(args, extraParams); + } + self.beforeEmit(self.context, listener, eventObj); + if (listener.conf && listener.conf.one) { + self.listeners = self.listeners.filter(function (l) { + return l !== listener; + }); + } + var context = self.callbackContext(self.context, listener, eventObj); + var ret = listener.callback.apply(context, args); + self.afterEmit(self.context, listener, eventObj); + if (ret === false) { + eventObj.stopPropagation(); + eventObj.preventDefault(); + } + } // if listener matches + }; + for (var i = 0; i < numListenersBeforeEmit; i++) { + _loop2(i); + } // for listener + + if (self.bubble(self.context) && !eventObj.isPropagationStopped()) { + self.parent(self.context).emit(eventObj, extraParams); + } + }, events); + this.emitting--; + return this; +}; + +var emitterOptions$1 = { + qualifierCompare: function qualifierCompare(selector1, selector2) { + if (selector1 == null || selector2 == null) { + return selector1 == null && selector2 == null; + } else { + return selector1.sameText(selector2); + } + }, + eventMatches: function eventMatches(ele, listener, eventObj) { + var selector = listener.qualifier; + if (selector != null) { + return ele !== eventObj.target && element(eventObj.target) && selector.matches(eventObj.target); + } + return true; + }, + addEventFields: function addEventFields(ele, evt) { + evt.cy = ele.cy(); + evt.target = ele; + }, + callbackContext: function callbackContext(ele, listener, eventObj) { + return listener.qualifier != null ? eventObj.target : ele; + }, + beforeEmit: function beforeEmit(context, listener /*, eventObj*/) { + if (listener.conf && listener.conf.once) { + listener.conf.onceCollection.removeListener(listener.event, listener.qualifier, listener.callback); + } + }, + bubble: function bubble() { + return true; + }, + parent: function parent(ele) { + return ele.isChild() ? ele.parent() : ele.cy(); + } +}; +var argSelector$1 = function argSelector(arg) { + if (string(arg)) { + return new Selector(arg); + } else { + return arg; + } +}; +var elesfn$9 = { + createEmitter: function createEmitter() { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var _p = ele._private; + if (!_p.emitter) { + _p.emitter = new Emitter(emitterOptions$1, ele); + } + } + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().on(events, argSel, callback); + } + return this; + }, + removeListener: function removeListener(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().removeListener(events, argSel, callback); + } + return this; + }, + removeAllListeners: function removeAllListeners() { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().removeAllListeners(); + } + return this; + }, + one: function one(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().one(events, argSel, callback); + } + return this; + }, + once: function once(events, selector, callback) { + var argSel = argSelector$1(selector); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().on(events, argSel, callback, { + once: true, + onceCollection: this + }); + } + }, + emit: function emit(events, extraParams) { + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + ele.emitter().emit(events, extraParams); + } + return this; + }, + emitAndNotify: function emitAndNotify(event, extraParams) { + // for internal use only + if (this.length === 0) { + return; + } // empty collections don't need to notify anything + + // notify renderer + this.cy().notify(event, this); + this.emit(event, extraParams); + return this; + } +}; +define.eventAliasesOn(elesfn$9); + +var elesfn$8 = { + nodes: function nodes(selector) { + return this.filter(function (ele) { + return ele.isNode(); + }).filter(selector); + }, + edges: function edges(selector) { + return this.filter(function (ele) { + return ele.isEdge(); + }).filter(selector); + }, + // internal helper to get nodes and edges as separate collections with single iteration over elements + byGroup: function byGroup() { + var nodes = this.spawn(); + var edges = this.spawn(); + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + if (ele.isNode()) { + nodes.push(ele); + } else { + edges.push(ele); + } + } + return { + nodes: nodes, + edges: edges + }; + }, + filter: function filter(_filter, thisArg) { + if (_filter === undefined) { + // check this first b/c it's the most common/performant case + return this; + } else if (string(_filter) || elementOrCollection(_filter)) { + return new Selector(_filter).filter(this); + } else if (fn$6(_filter)) { + var filterEles = this.spawn(); + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var include = thisArg ? _filter.apply(thisArg, [ele, i, eles]) : _filter(ele, i, eles); + if (include) { + filterEles.push(ele); + } + } + return filterEles; + } + return this.spawn(); // if not handled by above, give 'em an empty collection + }, + + not: function not(toRemove) { + if (!toRemove) { + return this; + } else { + if (string(toRemove)) { + toRemove = this.filter(toRemove); + } + var elements = this.spawn(); + for (var i = 0; i < this.length; i++) { + var element = this[i]; + var remove = toRemove.has(element); + if (!remove) { + elements.push(element); + } + } + return elements; + } + }, + absoluteComplement: function absoluteComplement() { + var cy = this.cy(); + return cy.mutableElements().not(this); + }, + intersect: function intersect(other) { + // if a selector is specified, then filter by it instead + if (string(other)) { + var selector = other; + return this.filter(selector); + } + var elements = this.spawn(); + var col1 = this; + var col2 = other; + var col1Smaller = this.length < other.length; + var colS = col1Smaller ? col1 : col2; + var colL = col1Smaller ? col2 : col1; + for (var i = 0; i < colS.length; i++) { + var ele = colS[i]; + if (colL.has(ele)) { + elements.push(ele); + } + } + return elements; + }, + xor: function xor(other) { + var cy = this._private.cy; + if (string(other)) { + other = cy.$(other); + } + var elements = this.spawn(); + var col1 = this; + var col2 = other; + var add = function add(col, other) { + for (var i = 0; i < col.length; i++) { + var ele = col[i]; + var id = ele._private.data.id; + var inOther = other.hasElementWithId(id); + if (!inOther) { + elements.push(ele); + } + } + }; + add(col1, col2); + add(col2, col1); + return elements; + }, + diff: function diff(other) { + var cy = this._private.cy; + if (string(other)) { + other = cy.$(other); + } + var left = this.spawn(); + var right = this.spawn(); + var both = this.spawn(); + var col1 = this; + var col2 = other; + var add = function add(col, other, retEles) { + for (var i = 0; i < col.length; i++) { + var ele = col[i]; + var id = ele._private.data.id; + var inOther = other.hasElementWithId(id); + if (inOther) { + both.merge(ele); + } else { + retEles.push(ele); + } + } + }; + add(col1, col2, left); + add(col2, col1, right); + return { + left: left, + right: right, + both: both + }; + }, + add: function add(toAdd) { + var cy = this._private.cy; + if (!toAdd) { + return this; + } + if (string(toAdd)) { + var selector = toAdd; + toAdd = cy.mutableElements().filter(selector); + } + var elements = this.spawnSelf(); + for (var i = 0; i < toAdd.length; i++) { + var ele = toAdd[i]; + var add = !this.has(ele); + if (add) { + elements.push(ele); + } + } + return elements; + }, + // in place merge on calling collection + merge: function merge(toAdd) { + var _p = this._private; + var cy = _p.cy; + if (!toAdd) { + return this; + } + if (toAdd && string(toAdd)) { + var selector = toAdd; + toAdd = cy.mutableElements().filter(selector); + } + var map = _p.map; + for (var i = 0; i < toAdd.length; i++) { + var toAddEle = toAdd[i]; + var id = toAddEle._private.data.id; + var add = !map.has(id); + if (add) { + var index = this.length++; + this[index] = toAddEle; + map.set(id, { + ele: toAddEle, + index: index + }); + } + } + return this; // chaining + }, + + unmergeAt: function unmergeAt(i) { + var ele = this[i]; + var id = ele.id(); + var _p = this._private; + var map = _p.map; + + // remove ele + this[i] = undefined; + map["delete"](id); + var unmergedLastEle = i === this.length - 1; + + // replace empty spot with last ele in collection + if (this.length > 1 && !unmergedLastEle) { + var lastEleI = this.length - 1; + var lastEle = this[lastEleI]; + var lastEleId = lastEle._private.data.id; + this[lastEleI] = undefined; + this[i] = lastEle; + map.set(lastEleId, { + ele: lastEle, + index: i + }); + } + + // the collection is now 1 ele smaller + this.length--; + return this; + }, + // remove single ele in place in calling collection + unmergeOne: function unmergeOne(ele) { + ele = ele[0]; + var _p = this._private; + var id = ele._private.data.id; + var map = _p.map; + var entry = map.get(id); + if (!entry) { + return this; // no need to remove + } + + var i = entry.index; + this.unmergeAt(i); + return this; + }, + // remove eles in place on calling collection + unmerge: function unmerge(toRemove) { + var cy = this._private.cy; + if (!toRemove) { + return this; + } + if (toRemove && string(toRemove)) { + var selector = toRemove; + toRemove = cy.mutableElements().filter(selector); + } + for (var i = 0; i < toRemove.length; i++) { + this.unmergeOne(toRemove[i]); + } + return this; // chaining + }, + + unmergeBy: function unmergeBy(toRmFn) { + for (var i = this.length - 1; i >= 0; i--) { + var ele = this[i]; + if (toRmFn(ele)) { + this.unmergeAt(i); + } + } + return this; + }, + map: function map(mapFn, thisArg) { + var arr = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var ret = thisArg ? mapFn.apply(thisArg, [ele, i, eles]) : mapFn(ele, i, eles); + arr.push(ret); + } + return arr; + }, + reduce: function reduce(fn, initialValue) { + var val = initialValue; + var eles = this; + for (var i = 0; i < eles.length; i++) { + val = fn(val, eles[i], i, eles); + } + return val; + }, + max: function max(valFn, thisArg) { + var max = -Infinity; + var maxEle; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var val = thisArg ? valFn.apply(thisArg, [ele, i, eles]) : valFn(ele, i, eles); + if (val > max) { + max = val; + maxEle = ele; + } + } + return { + value: max, + ele: maxEle + }; + }, + min: function min(valFn, thisArg) { + var min = Infinity; + var minEle; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var val = thisArg ? valFn.apply(thisArg, [ele, i, eles]) : valFn(ele, i, eles); + if (val < min) { + min = val; + minEle = ele; + } + } + return { + value: min, + ele: minEle + }; + } +}; + +// aliases +var fn$1 = elesfn$8; +fn$1['u'] = fn$1['|'] = fn$1['+'] = fn$1.union = fn$1.or = fn$1.add; +fn$1['\\'] = fn$1['!'] = fn$1['-'] = fn$1.difference = fn$1.relativeComplement = fn$1.subtract = fn$1.not; +fn$1['n'] = fn$1['&'] = fn$1['.'] = fn$1.and = fn$1.intersection = fn$1.intersect; +fn$1['^'] = fn$1['(+)'] = fn$1['(-)'] = fn$1.symmetricDifference = fn$1.symdiff = fn$1.xor; +fn$1.fnFilter = fn$1.filterFn = fn$1.stdFilter = fn$1.filter; +fn$1.complement = fn$1.abscomp = fn$1.absoluteComplement; + +var elesfn$7 = { + isNode: function isNode() { + return this.group() === 'nodes'; + }, + isEdge: function isEdge() { + return this.group() === 'edges'; + }, + isLoop: function isLoop() { + return this.isEdge() && this.source()[0] === this.target()[0]; + }, + isSimple: function isSimple() { + return this.isEdge() && this.source()[0] !== this.target()[0]; + }, + group: function group() { + var ele = this[0]; + if (ele) { + return ele._private.group; + } + } +}; + +/** + * Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges), + * and z-index (low to high). These styles affect how this applies: + * + * z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the + * same depth as the root of the compound graph, followed by the default value `auto` which draws in order from + * root to leaves of the compound graph. The last drawn is `top`. + * z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes. + * `manual` ignores this convention and draws based on the `z-index` value setting. + * z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher + * `z-index` will be drawn on top of an element with a lower `z-index`. + */ +var zIndexSort = function zIndexSort(a, b) { + var cy = a.cy(); + var hasCompoundNodes = cy.hasCompoundNodes(); + function getDepth(ele) { + var style = ele.pstyle('z-compound-depth'); + if (style.value === 'auto') { + return hasCompoundNodes ? ele.zDepth() : 0; + } else if (style.value === 'bottom') { + return -1; + } else if (style.value === 'top') { + return MAX_INT$1; + } + // 'orphan' + return 0; + } + var depthDiff = getDepth(a) - getDepth(b); + if (depthDiff !== 0) { + return depthDiff; + } + function getEleDepth(ele) { + var style = ele.pstyle('z-index-compare'); + if (style.value === 'auto') { + return ele.isNode() ? 1 : 0; + } + // 'manual' + return 0; + } + var eleDiff = getEleDepth(a) - getEleDepth(b); + if (eleDiff !== 0) { + return eleDiff; + } + var zDiff = a.pstyle('z-index').value - b.pstyle('z-index').value; + if (zDiff !== 0) { + return zDiff; + } + // compare indices in the core (order added to graph w/ last on top) + return a.poolIndex() - b.poolIndex(); +}; + +var elesfn$6 = { + forEach: function forEach(fn, thisArg) { + if (fn$6(fn)) { + var N = this.length; + for (var i = 0; i < N; i++) { + var ele = this[i]; + var ret = thisArg ? fn.apply(thisArg, [ele, i, this]) : fn(ele, i, this); + if (ret === false) { + break; + } // exit each early on return false + } + } + + return this; + }, + toArray: function toArray() { + var array = []; + for (var i = 0; i < this.length; i++) { + array.push(this[i]); + } + return array; + }, + slice: function slice(start, end) { + var array = []; + var thisSize = this.length; + if (end == null) { + end = thisSize; + } + if (start == null) { + start = 0; + } + if (start < 0) { + start = thisSize + start; + } + if (end < 0) { + end = thisSize + end; + } + for (var i = start; i >= 0 && i < end && i < thisSize; i++) { + array.push(this[i]); + } + return this.spawn(array); + }, + size: function size() { + return this.length; + }, + eq: function eq(i) { + return this[i] || this.spawn(); + }, + first: function first() { + return this[0] || this.spawn(); + }, + last: function last() { + return this[this.length - 1] || this.spawn(); + }, + empty: function empty() { + return this.length === 0; + }, + nonempty: function nonempty() { + return !this.empty(); + }, + sort: function sort(sortFn) { + if (!fn$6(sortFn)) { + return this; + } + var sorted = this.toArray().sort(sortFn); + return this.spawn(sorted); + }, + sortByZIndex: function sortByZIndex() { + return this.sort(zIndexSort); + }, + zDepth: function zDepth() { + var ele = this[0]; + if (!ele) { + return undefined; + } + + // let cy = ele.cy(); + var _p = ele._private; + var group = _p.group; + if (group === 'nodes') { + var depth = _p.data.parent ? ele.parents().size() : 0; + if (!ele.isParent()) { + return MAX_INT$1 - 1; // childless nodes always on top + } + + return depth; + } else { + var src = _p.source; + var tgt = _p.target; + var srcDepth = src.zDepth(); + var tgtDepth = tgt.zDepth(); + return Math.max(srcDepth, tgtDepth, 0); // depth of deepest parent + } + } +}; + +elesfn$6.each = elesfn$6.forEach; +var defineSymbolIterator = function defineSymbolIterator() { + var typeofUndef = "undefined" ; + var isIteratorSupported = (typeof Symbol === "undefined" ? "undefined" : _typeof(Symbol)) != typeofUndef && _typeof(Symbol.iterator) != typeofUndef; // eslint-disable-line no-undef + + if (isIteratorSupported) { + elesfn$6[Symbol.iterator] = function () { + var _this = this; + // eslint-disable-line no-undef + var entry = { + value: undefined, + done: false + }; + var i = 0; + var length = this.length; + return _defineProperty$1({ + next: function next() { + if (i < length) { + entry.value = _this[i++]; + } else { + entry.value = undefined; + entry.done = true; + } + return entry; + } + }, Symbol.iterator, function () { + // eslint-disable-line no-undef + return this; + }); + }; + } +}; +defineSymbolIterator(); + +var getLayoutDimensionOptions = defaults$g({ + nodeDimensionsIncludeLabels: false +}); +var elesfn$5 = { + // Calculates and returns node dimensions { x, y } based on options given + layoutDimensions: function layoutDimensions(options) { + options = getLayoutDimensionOptions(options); + var dims; + if (!this.takesUpSpace()) { + dims = { + w: 0, + h: 0 + }; + } else if (options.nodeDimensionsIncludeLabels) { + var bbDim = this.boundingBox(); + dims = { + w: bbDim.w, + h: bbDim.h + }; + } else { + dims = { + w: this.outerWidth(), + h: this.outerHeight() + }; + } + + // sanitise the dimensions for external layouts (avoid division by zero) + if (dims.w === 0 || dims.h === 0) { + dims.w = dims.h = 1; + } + return dims; + }, + // using standard layout options, apply position function (w/ or w/o animation) + layoutPositions: function layoutPositions(layout, options, fn) { + var nodes = this.nodes().filter(function (n) { + return !n.isParent(); + }); + var cy = this.cy(); + var layoutEles = options.eles; // nodes & edges + var getMemoizeKey = function getMemoizeKey(node) { + return node.id(); + }; + var fnMem = memoize$1(fn, getMemoizeKey); // memoized version of position function + + layout.emit({ + type: 'layoutstart', + layout: layout + }); + layout.animations = []; + var calculateSpacing = function calculateSpacing(spacing, nodesBb, pos) { + var center = { + x: nodesBb.x1 + nodesBb.w / 2, + y: nodesBb.y1 + nodesBb.h / 2 + }; + var spacingVector = { + // scale from center of bounding box (not necessarily 0,0) + x: (pos.x - center.x) * spacing, + y: (pos.y - center.y) * spacing + }; + return { + x: center.x + spacingVector.x, + y: center.y + spacingVector.y + }; + }; + var useSpacingFactor = options.spacingFactor && options.spacingFactor !== 1; + var spacingBb = function spacingBb() { + if (!useSpacingFactor) { + return null; + } + var bb = makeBoundingBox(); + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var pos = fnMem(node, i); + expandBoundingBoxByPoint(bb, pos.x, pos.y); + } + return bb; + }; + var bb = spacingBb(); + var getFinalPos = memoize$1(function (node, i) { + var newPos = fnMem(node, i); + if (useSpacingFactor) { + var spacing = Math.abs(options.spacingFactor); + newPos = calculateSpacing(spacing, bb, newPos); + } + if (options.transform != null) { + newPos = options.transform(node, newPos); + } + return newPos; + }, getMemoizeKey); + if (options.animate) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var newPos = getFinalPos(node, i); + var animateNode = options.animateFilter == null || options.animateFilter(node, i); + if (animateNode) { + var ani = node.animation({ + position: newPos, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(ani); + } else { + node.position(newPos); + } + } + if (options.fit) { + var fitAni = cy.animation({ + fit: { + boundingBox: layoutEles.boundingBoxAt(getFinalPos), + padding: options.padding + }, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(fitAni); + } else if (options.zoom !== undefined && options.pan !== undefined) { + var zoomPanAni = cy.animation({ + zoom: options.zoom, + pan: options.pan, + duration: options.animationDuration, + easing: options.animationEasing + }); + layout.animations.push(zoomPanAni); + } + layout.animations.forEach(function (ani) { + return ani.play(); + }); + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: layout + }); + Promise$1.all(layout.animations.map(function (ani) { + return ani.promise(); + })).then(function () { + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + }); + } else { + nodes.positions(getFinalPos); + if (options.fit) { + cy.fit(options.eles, options.padding); + } + if (options.zoom != null) { + cy.zoom(options.zoom); + } + if (options.pan) { + cy.pan(options.pan); + } + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: layout + }); + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + } + return this; // chaining + }, + + layout: function layout(options) { + var cy = this.cy(); + return cy.makeLayout(extend({}, options, { + eles: this + })); + } +}; + +// aliases: +elesfn$5.createLayout = elesfn$5.makeLayout = elesfn$5.layout; + +function styleCache(key, fn, ele) { + var _p = ele._private; + var cache = _p.styleCache = _p.styleCache || []; + var val; + if ((val = cache[key]) != null) { + return val; + } else { + val = cache[key] = fn(ele); + return val; + } +} +function cacheStyleFunction(key, fn) { + key = hashString(key); + return function cachedStyleFunction(ele) { + return styleCache(key, fn, ele); + }; +} +function cachePrototypeStyleFunction(key, fn) { + key = hashString(key); + var selfFn = function selfFn(ele) { + return fn.call(ele); + }; + return function cachedPrototypeStyleFunction() { + var ele = this[0]; + if (ele) { + return styleCache(key, selfFn, ele); + } + }; +} +var elesfn$4 = { + recalculateRenderedStyle: function recalculateRenderedStyle(useCache) { + var cy = this.cy(); + var renderer = cy.renderer(); + var styleEnabled = cy.styleEnabled(); + if (renderer && styleEnabled) { + renderer.recalculateRenderedStyle(this, useCache); + } + return this; + }, + dirtyStyleCache: function dirtyStyleCache() { + var cy = this.cy(); + var dirty = function dirty(ele) { + return ele._private.styleCache = null; + }; + if (cy.hasCompoundNodes()) { + var eles; + eles = this.spawnSelf().merge(this.descendants()).merge(this.parents()); + eles.merge(eles.connectedEdges()); + eles.forEach(dirty); + } else { + this.forEach(function (ele) { + dirty(ele); + ele.connectedEdges().forEach(dirty); + }); + } + return this; + }, + // fully updates (recalculates) the style for the elements + updateStyle: function updateStyle(notifyRenderer) { + var cy = this._private.cy; + if (!cy.styleEnabled()) { + return this; + } + if (cy.batching()) { + var bEles = cy._private.batchStyleEles; + bEles.merge(this); + return this; // chaining and exit early when batching + } + + var hasCompounds = cy.hasCompoundNodes(); + var updatedEles = this; + notifyRenderer = notifyRenderer || notifyRenderer === undefined ? true : false; + if (hasCompounds) { + // then add everything up and down for compound selector checks + updatedEles = this.spawnSelf().merge(this.descendants()).merge(this.parents()); + } + + // let changedEles = style.apply( updatedEles ); + var changedEles = updatedEles; + if (notifyRenderer) { + changedEles.emitAndNotify('style'); // let renderer know we changed style + } else { + changedEles.emit('style'); // just fire the event + } + + updatedEles.forEach(function (ele) { + return ele._private.styleDirty = true; + }); + return this; // chaining + }, + + // private: clears dirty flag and recalculates style + cleanStyle: function cleanStyle() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return; + } + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + if (ele._private.styleDirty) { + // n.b. this flag should be set before apply() to avoid potential infinite recursion + ele._private.styleDirty = false; + cy.style().apply(ele); + } + } + }, + // get the internal parsed style object for the specified property + parsedStyle: function parsedStyle(property) { + var includeNonDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var ele = this[0]; + var cy = ele.cy(); + if (!cy.styleEnabled()) { + return; + } + if (ele) { + this.cleanStyle(); + var overriddenStyle = ele._private.style[property]; + if (overriddenStyle != null) { + return overriddenStyle; + } else if (includeNonDefault) { + return cy.style().getDefaultProperty(property); + } else { + return null; + } + } + }, + numericStyle: function numericStyle(property) { + var ele = this[0]; + if (!ele.cy().styleEnabled()) { + return; + } + if (ele) { + var pstyle = ele.pstyle(property); + return pstyle.pfValue !== undefined ? pstyle.pfValue : pstyle.value; + } + }, + numericStyleUnits: function numericStyleUnits(property) { + var ele = this[0]; + if (!ele.cy().styleEnabled()) { + return; + } + if (ele) { + return ele.pstyle(property).units; + } + }, + // get the specified css property as a rendered value (i.e. on-screen value) + // or get the whole rendered style if no property specified (NB doesn't allow setting) + renderedStyle: function renderedStyle(property) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var ele = this[0]; + if (ele) { + return cy.style().getRenderedStyle(ele, property); + } + }, + // read the calculated css style of the element or override the style (via a bypass) + style: function style(name, value) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var updateTransitions = false; + var style = cy.style(); + if (plainObject(name)) { + // then extend the bypass + var props = name; + style.applyBypass(this, props, updateTransitions); + this.emitAndNotify('style'); // let the renderer know we've updated style + } else if (string(name)) { + if (value === undefined) { + // then get the property from the style + var ele = this[0]; + if (ele) { + return style.getStylePropertyValue(ele, name); + } else { + // empty collection => can't get any value + return; + } + } else { + // then set the bypass with the property value + style.applyBypass(this, name, value, updateTransitions); + this.emitAndNotify('style'); // let the renderer know we've updated style + } + } else if (name === undefined) { + var _ele = this[0]; + if (_ele) { + return style.getRawStyle(_ele); + } else { + // empty collection => can't get any value + return; + } + } + return this; // chaining + }, + + removeStyle: function removeStyle(names) { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return this; + } + var updateTransitions = false; + var style = cy.style(); + var eles = this; + if (names === undefined) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + style.removeAllBypasses(ele, updateTransitions); + } + } else { + names = names.split(/\s+/); + for (var _i = 0; _i < eles.length; _i++) { + var _ele2 = eles[_i]; + style.removeBypasses(_ele2, names, updateTransitions); + } + } + this.emitAndNotify('style'); // let the renderer know we've updated style + + return this; // chaining + }, + + show: function show() { + this.css('display', 'element'); + return this; // chaining + }, + + hide: function hide() { + this.css('display', 'none'); + return this; // chaining + }, + + effectiveOpacity: function effectiveOpacity() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return 1; + } + var hasCompoundNodes = cy.hasCompoundNodes(); + var ele = this[0]; + if (ele) { + var _p = ele._private; + var parentOpacity = ele.pstyle('opacity').value; + if (!hasCompoundNodes) { + return parentOpacity; + } + var parents = !_p.data.parent ? null : ele.parents(); + if (parents) { + for (var i = 0; i < parents.length; i++) { + var parent = parents[i]; + var opacity = parent.pstyle('opacity').value; + parentOpacity = opacity * parentOpacity; + } + } + return parentOpacity; + } + }, + transparent: function transparent() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return false; + } + var ele = this[0]; + var hasCompoundNodes = ele.cy().hasCompoundNodes(); + if (ele) { + if (!hasCompoundNodes) { + return ele.pstyle('opacity').value === 0; + } else { + return ele.effectiveOpacity() === 0; + } + } + }, + backgrounding: function backgrounding() { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return false; + } + var ele = this[0]; + return ele._private.backgrounding ? true : false; + } +}; +function checkCompound(ele, parentOk) { + var _p = ele._private; + var parents = _p.data.parent ? ele.parents() : null; + if (parents) { + for (var i = 0; i < parents.length; i++) { + var parent = parents[i]; + if (!parentOk(parent)) { + return false; + } + } + } + return true; +} +function defineDerivedStateFunction(specs) { + var ok = specs.ok; + var edgeOkViaNode = specs.edgeOkViaNode || specs.ok; + var parentOk = specs.parentOk || specs.ok; + return function () { + var cy = this.cy(); + if (!cy.styleEnabled()) { + return true; + } + var ele = this[0]; + var hasCompoundNodes = cy.hasCompoundNodes(); + if (ele) { + var _p = ele._private; + if (!ok(ele)) { + return false; + } + if (ele.isNode()) { + return !hasCompoundNodes || checkCompound(ele, parentOk); + } else { + var src = _p.source; + var tgt = _p.target; + return edgeOkViaNode(src) && (!hasCompoundNodes || checkCompound(src, edgeOkViaNode)) && (src === tgt || edgeOkViaNode(tgt) && (!hasCompoundNodes || checkCompound(tgt, edgeOkViaNode))); + } + } + }; +} +var eleTakesUpSpace = cacheStyleFunction('eleTakesUpSpace', function (ele) { + return ele.pstyle('display').value === 'element' && ele.width() !== 0 && (ele.isNode() ? ele.height() !== 0 : true); +}); +elesfn$4.takesUpSpace = cachePrototypeStyleFunction('takesUpSpace', defineDerivedStateFunction({ + ok: eleTakesUpSpace +})); +var eleInteractive = cacheStyleFunction('eleInteractive', function (ele) { + return ele.pstyle('events').value === 'yes' && ele.pstyle('visibility').value === 'visible' && eleTakesUpSpace(ele); +}); +var parentInteractive = cacheStyleFunction('parentInteractive', function (parent) { + return parent.pstyle('visibility').value === 'visible' && eleTakesUpSpace(parent); +}); +elesfn$4.interactive = cachePrototypeStyleFunction('interactive', defineDerivedStateFunction({ + ok: eleInteractive, + parentOk: parentInteractive, + edgeOkViaNode: eleTakesUpSpace +})); +elesfn$4.noninteractive = function () { + var ele = this[0]; + if (ele) { + return !ele.interactive(); + } +}; +var eleVisible = cacheStyleFunction('eleVisible', function (ele) { + return ele.pstyle('visibility').value === 'visible' && ele.pstyle('opacity').pfValue !== 0 && eleTakesUpSpace(ele); +}); +var edgeVisibleViaNode = eleTakesUpSpace; +elesfn$4.visible = cachePrototypeStyleFunction('visible', defineDerivedStateFunction({ + ok: eleVisible, + edgeOkViaNode: edgeVisibleViaNode +})); +elesfn$4.hidden = function () { + var ele = this[0]; + if (ele) { + return !ele.visible(); + } +}; +elesfn$4.isBundledBezier = cachePrototypeStyleFunction('isBundledBezier', function () { + if (!this.cy().styleEnabled()) { + return false; + } + return !this.removed() && this.pstyle('curve-style').value === 'bezier' && this.takesUpSpace(); +}); +elesfn$4.bypass = elesfn$4.css = elesfn$4.style; +elesfn$4.renderedCss = elesfn$4.renderedStyle; +elesfn$4.removeBypass = elesfn$4.removeCss = elesfn$4.removeStyle; +elesfn$4.pstyle = elesfn$4.parsedStyle; + +var elesfn$3 = {}; +function defineSwitchFunction(params) { + return function () { + var args = arguments; + var changedEles = []; + + // e.g. cy.nodes().select( data, handler ) + if (args.length === 2) { + var data = args[0]; + var handler = args[1]; + this.on(params.event, data, handler); + } + + // e.g. cy.nodes().select( handler ) + else if (args.length === 1 && fn$6(args[0])) { + var _handler = args[0]; + this.on(params.event, _handler); + } + + // e.g. cy.nodes().select() + // e.g. (private) cy.nodes().select(['tapselect']) + else if (args.length === 0 || args.length === 1 && array(args[0])) { + var addlEvents = args.length === 1 ? args[0] : null; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var able = !params.ableField || ele._private[params.ableField]; + var changed = ele._private[params.field] != params.value; + if (params.overrideAble) { + var overrideAble = params.overrideAble(ele); + if (overrideAble !== undefined) { + able = overrideAble; + if (!overrideAble) { + return this; + } // to save cycles assume not able for all on override + } + } + + if (able) { + ele._private[params.field] = params.value; + if (changed) { + changedEles.push(ele); + } + } + } + var changedColl = this.spawn(changedEles); + changedColl.updateStyle(); // change of state => possible change of style + changedColl.emit(params.event); + if (addlEvents) { + changedColl.emit(addlEvents); + } + } + return this; + }; +} +function defineSwitchSet(params) { + elesfn$3[params.field] = function () { + var ele = this[0]; + if (ele) { + if (params.overrideField) { + var val = params.overrideField(ele); + if (val !== undefined) { + return val; + } + } + return ele._private[params.field]; + } + }; + elesfn$3[params.on] = defineSwitchFunction({ + event: params.on, + field: params.field, + ableField: params.ableField, + overrideAble: params.overrideAble, + value: true + }); + elesfn$3[params.off] = defineSwitchFunction({ + event: params.off, + field: params.field, + ableField: params.ableField, + overrideAble: params.overrideAble, + value: false + }); +} +defineSwitchSet({ + field: 'locked', + overrideField: function overrideField(ele) { + return ele.cy().autolock() ? true : undefined; + }, + on: 'lock', + off: 'unlock' +}); +defineSwitchSet({ + field: 'grabbable', + overrideField: function overrideField(ele) { + return ele.cy().autoungrabify() || ele.pannable() ? false : undefined; + }, + on: 'grabify', + off: 'ungrabify' +}); +defineSwitchSet({ + field: 'selected', + ableField: 'selectable', + overrideAble: function overrideAble(ele) { + return ele.cy().autounselectify() ? false : undefined; + }, + on: 'select', + off: 'unselect' +}); +defineSwitchSet({ + field: 'selectable', + overrideField: function overrideField(ele) { + return ele.cy().autounselectify() ? false : undefined; + }, + on: 'selectify', + off: 'unselectify' +}); +elesfn$3.deselect = elesfn$3.unselect; +elesfn$3.grabbed = function () { + var ele = this[0]; + if (ele) { + return ele._private.grabbed; + } +}; +defineSwitchSet({ + field: 'active', + on: 'activate', + off: 'unactivate' +}); +defineSwitchSet({ + field: 'pannable', + on: 'panify', + off: 'unpanify' +}); +elesfn$3.inactive = function () { + var ele = this[0]; + if (ele) { + return !ele._private.active; + } +}; + +var elesfn$2 = {}; + +// DAG functions +//////////////// + +var defineDagExtremity = function defineDagExtremity(params) { + return function dagExtremityImpl(selector) { + var eles = this; + var ret = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + var disqualified = false; + var edges = ele.connectedEdges(); + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + var src = edge.source(); + var tgt = edge.target(); + if (params.noIncomingEdges && tgt === ele && src !== ele || params.noOutgoingEdges && src === ele && tgt !== ele) { + disqualified = true; + break; + } + } + if (!disqualified) { + ret.push(ele); + } + } + return this.spawn(ret, true).filter(selector); + }; +}; +var defineDagOneHop = function defineDagOneHop(params) { + return function (selector) { + var eles = this; + var oEles = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + var edges = ele.connectedEdges(); + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + var src = edge.source(); + var tgt = edge.target(); + if (params.outgoing && src === ele) { + oEles.push(edge); + oEles.push(tgt); + } else if (params.incoming && tgt === ele) { + oEles.push(edge); + oEles.push(src); + } + } + } + return this.spawn(oEles, true).filter(selector); + }; +}; +var defineDagAllHops = function defineDagAllHops(params) { + return function (selector) { + var eles = this; + var sEles = []; + var sElesIds = {}; + for (;;) { + var next = params.outgoing ? eles.outgoers() : eles.incomers(); + if (next.length === 0) { + break; + } // done if none left + + var newNext = false; + for (var i = 0; i < next.length; i++) { + var n = next[i]; + var nid = n.id(); + if (!sElesIds[nid]) { + sElesIds[nid] = true; + sEles.push(n); + newNext = true; + } + } + if (!newNext) { + break; + } // done if touched all outgoers already + + eles = next; + } + return this.spawn(sEles, true).filter(selector); + }; +}; +elesfn$2.clearTraversalCache = function () { + for (var i = 0; i < this.length; i++) { + this[i]._private.traversalCache = null; + } +}; +extend(elesfn$2, { + // get the root nodes in the DAG + roots: defineDagExtremity({ + noIncomingEdges: true + }), + // get the leaf nodes in the DAG + leaves: defineDagExtremity({ + noOutgoingEdges: true + }), + // normally called children in graph theory + // these nodes =edges=> outgoing nodes + outgoers: cache(defineDagOneHop({ + outgoing: true + }), 'outgoers'), + // aka DAG descendants + successors: defineDagAllHops({ + outgoing: true + }), + // normally called parents in graph theory + // these nodes <=edges= incoming nodes + incomers: cache(defineDagOneHop({ + incoming: true + }), 'incomers'), + // aka DAG ancestors + predecessors: defineDagAllHops({ + incoming: true + }) +}); + +// Neighbourhood functions +////////////////////////// + +extend(elesfn$2, { + neighborhood: cache(function (selector) { + var elements = []; + var nodes = this.nodes(); + for (var i = 0; i < nodes.length; i++) { + // for all nodes + var node = nodes[i]; + var connectedEdges = node.connectedEdges(); + + // for each connected edge, add the edge and the other node + for (var j = 0; j < connectedEdges.length; j++) { + var edge = connectedEdges[j]; + var src = edge.source(); + var tgt = edge.target(); + var otherNode = node === src ? tgt : src; + + // need check in case of loop + if (otherNode.length > 0) { + elements.push(otherNode[0]); // add node 1 hop away + } + + // add connected edge + elements.push(edge[0]); + } + } + return this.spawn(elements, true).filter(selector); + }, 'neighborhood'), + closedNeighborhood: function closedNeighborhood(selector) { + return this.neighborhood().add(this).filter(selector); + }, + openNeighborhood: function openNeighborhood(selector) { + return this.neighborhood(selector); + } +}); + +// aliases +elesfn$2.neighbourhood = elesfn$2.neighborhood; +elesfn$2.closedNeighbourhood = elesfn$2.closedNeighborhood; +elesfn$2.openNeighbourhood = elesfn$2.openNeighborhood; + +// Edge functions +///////////////// + +extend(elesfn$2, { + source: cache(function sourceImpl(selector) { + var ele = this[0]; + var src; + if (ele) { + src = ele._private.source || ele.cy().collection(); + } + return src && selector ? src.filter(selector) : src; + }, 'source'), + target: cache(function targetImpl(selector) { + var ele = this[0]; + var tgt; + if (ele) { + tgt = ele._private.target || ele.cy().collection(); + } + return tgt && selector ? tgt.filter(selector) : tgt; + }, 'target'), + sources: defineSourceFunction({ + attr: 'source' + }), + targets: defineSourceFunction({ + attr: 'target' + }) +}); +function defineSourceFunction(params) { + return function sourceImpl(selector) { + var sources = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var src = ele._private[params.attr]; + if (src) { + sources.push(src); + } + } + return this.spawn(sources, true).filter(selector); + }; +} +extend(elesfn$2, { + edgesWith: cache(defineEdgesWithFunction(), 'edgesWith'), + edgesTo: cache(defineEdgesWithFunction({ + thisIsSrc: true + }), 'edgesTo') +}); +function defineEdgesWithFunction(params) { + return function edgesWithImpl(otherNodes) { + var elements = []; + var cy = this._private.cy; + var p = params || {}; + + // get elements if a selector is specified + if (string(otherNodes)) { + otherNodes = cy.$(otherNodes); + } + for (var h = 0; h < otherNodes.length; h++) { + var edges = otherNodes[h]._private.edges; + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var edgeData = edge._private.data; + var thisToOther = this.hasElementWithId(edgeData.source) && otherNodes.hasElementWithId(edgeData.target); + var otherToThis = otherNodes.hasElementWithId(edgeData.source) && this.hasElementWithId(edgeData.target); + var edgeConnectsThisAndOther = thisToOther || otherToThis; + if (!edgeConnectsThisAndOther) { + continue; + } + if (p.thisIsSrc || p.thisIsTgt) { + if (p.thisIsSrc && !thisToOther) { + continue; + } + if (p.thisIsTgt && !otherToThis) { + continue; + } + } + elements.push(edge); + } + } + return this.spawn(elements, true); + }; +} +extend(elesfn$2, { + connectedEdges: cache(function (selector) { + var retEles = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var node = eles[i]; + if (!node.isNode()) { + continue; + } + var edges = node._private.edges; + for (var j = 0; j < edges.length; j++) { + var edge = edges[j]; + retEles.push(edge); + } + } + return this.spawn(retEles, true).filter(selector); + }, 'connectedEdges'), + connectedNodes: cache(function (selector) { + var retEles = []; + var eles = this; + for (var i = 0; i < eles.length; i++) { + var edge = eles[i]; + if (!edge.isEdge()) { + continue; + } + retEles.push(edge.source()[0]); + retEles.push(edge.target()[0]); + } + return this.spawn(retEles, true).filter(selector); + }, 'connectedNodes'), + parallelEdges: cache(defineParallelEdgesFunction(), 'parallelEdges'), + codirectedEdges: cache(defineParallelEdgesFunction({ + codirected: true + }), 'codirectedEdges') +}); +function defineParallelEdgesFunction(params) { + var defaults = { + codirected: false + }; + params = extend({}, defaults, params); + return function parallelEdgesImpl(selector) { + // micro-optimised for renderer + var elements = []; + var edges = this.edges(); + var p = params; + + // look at all the edges in the collection + for (var i = 0; i < edges.length; i++) { + var edge1 = edges[i]; + var edge1_p = edge1._private; + var src1 = edge1_p.source; + var srcid1 = src1._private.data.id; + var tgtid1 = edge1_p.data.target; + var srcEdges1 = src1._private.edges; + + // look at edges connected to the src node of this edge + for (var j = 0; j < srcEdges1.length; j++) { + var edge2 = srcEdges1[j]; + var edge2data = edge2._private.data; + var tgtid2 = edge2data.target; + var srcid2 = edge2data.source; + var codirected = tgtid2 === tgtid1 && srcid2 === srcid1; + var oppdirected = srcid1 === tgtid2 && tgtid1 === srcid2; + if (p.codirected && codirected || !p.codirected && (codirected || oppdirected)) { + elements.push(edge2); + } + } + } + return this.spawn(elements, true).filter(selector); + }; +} + +// Misc functions +///////////////// + +extend(elesfn$2, { + components: function components(root) { + var self = this; + var cy = self.cy(); + var visited = cy.collection(); + var unvisited = root == null ? self.nodes() : root.nodes(); + var components = []; + if (root != null && unvisited.empty()) { + // root may contain only edges + unvisited = root.sources(); // doesn't matter which node to use (undirected), so just use the source sides + } + + var visitInComponent = function visitInComponent(node, component) { + visited.merge(node); + unvisited.unmerge(node); + component.merge(node); + }; + if (unvisited.empty()) { + return self.spawn(); + } + var _loop = function _loop() { + // each iteration yields a component + var cmpt = cy.collection(); + components.push(cmpt); + var root = unvisited[0]; + visitInComponent(root, cmpt); + self.bfs({ + directed: false, + roots: root, + visit: function visit(v) { + return visitInComponent(v, cmpt); + } + }); + cmpt.forEach(function (node) { + node.connectedEdges().forEach(function (e) { + // connectedEdges() usually cached + if (self.has(e) && cmpt.has(e.source()) && cmpt.has(e.target())) { + // has() is cheap + cmpt.merge(e); // forEach() only considers nodes -- sets N at call time + } + }); + }); + }; + do { + _loop(); + } while (unvisited.length > 0); + return components; + }, + component: function component() { + var ele = this[0]; + return ele.cy().mutableElements().components(ele)[0]; + } +}); +elesfn$2.componentsOf = elesfn$2.components; + +// represents a set of nodes, edges, or both together +var Collection = function Collection(cy, elements) { + var unique = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var removed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + if (cy === undefined) { + error('A collection must have a reference to the core'); + return; + } + var map = new Map$2(); + var createdElements = false; + if (!elements) { + elements = []; + } else if (elements.length > 0 && plainObject(elements[0]) && !element(elements[0])) { + createdElements = true; + + // make elements from json and restore all at once later + var eles = []; + var elesIds = new Set$1(); + for (var i = 0, l = elements.length; i < l; i++) { + var json = elements[i]; + if (json.data == null) { + json.data = {}; + } + var _data = json.data; + + // make sure newly created elements have valid ids + if (_data.id == null) { + _data.id = uuid(); + } else if (cy.hasElementWithId(_data.id) || elesIds.has(_data.id)) { + continue; // can't create element if prior id already exists + } + + var ele = new Element(cy, json, false); + eles.push(ele); + elesIds.add(_data.id); + } + elements = eles; + } + this.length = 0; + for (var _i = 0, _l = elements.length; _i < _l; _i++) { + var element$1 = elements[_i][0]; // [0] in case elements is an array of collections, rather than array of elements + if (element$1 == null) { + continue; + } + var id = element$1._private.data.id; + if (!unique || !map.has(id)) { + if (unique) { + map.set(id, { + index: this.length, + ele: element$1 + }); + } + this[this.length] = element$1; + this.length++; + } + } + this._private = { + eles: this, + cy: cy, + get map() { + if (this.lazyMap == null) { + this.rebuildMap(); + } + return this.lazyMap; + }, + set map(m) { + this.lazyMap = m; + }, + rebuildMap: function rebuildMap() { + var m = this.lazyMap = new Map$2(); + var eles = this.eles; + for (var _i2 = 0; _i2 < eles.length; _i2++) { + var _ele = eles[_i2]; + m.set(_ele.id(), { + index: _i2, + ele: _ele + }); + } + } + }; + if (unique) { + this._private.map = map; + } + + // restore the elements if we created them from json + if (createdElements && !removed) { + this.restore(); + } +}; + +// Functions +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// keep the prototypes in sync (an element has the same functions as a collection) +// and use elefn and elesfn as shorthands to the prototypes +var elesfn$1 = Element.prototype = Collection.prototype = Object.create(Array.prototype); +elesfn$1.instanceString = function () { + return 'collection'; +}; +elesfn$1.spawn = function (eles, unique) { + return new Collection(this.cy(), eles, unique); +}; +elesfn$1.spawnSelf = function () { + return this.spawn(this); +}; +elesfn$1.cy = function () { + return this._private.cy; +}; +elesfn$1.renderer = function () { + return this._private.cy.renderer(); +}; +elesfn$1.element = function () { + return this[0]; +}; +elesfn$1.collection = function () { + if (collection(this)) { + return this; + } else { + // an element + return new Collection(this._private.cy, [this]); + } +}; +elesfn$1.unique = function () { + return new Collection(this._private.cy, this, true); +}; +elesfn$1.hasElementWithId = function (id) { + id = '' + id; // id must be string + + return this._private.map.has(id); +}; +elesfn$1.getElementById = function (id) { + id = '' + id; // id must be string + + var cy = this._private.cy; + var entry = this._private.map.get(id); + return entry ? entry.ele : new Collection(cy); // get ele or empty collection +}; + +elesfn$1.$id = elesfn$1.getElementById; +elesfn$1.poolIndex = function () { + var cy = this._private.cy; + var eles = cy._private.elements; + var id = this[0]._private.data.id; + return eles._private.map.get(id).index; +}; +elesfn$1.indexOf = function (ele) { + var id = ele[0]._private.data.id; + return this._private.map.get(id).index; +}; +elesfn$1.indexOfId = function (id) { + id = '' + id; // id must be string + + return this._private.map.get(id).index; +}; +elesfn$1.json = function (obj) { + var ele = this.element(); + var cy = this.cy(); + if (ele == null && obj) { + return this; + } // can't set to no eles + + if (ele == null) { + return undefined; + } // can't get from no eles + + var p = ele._private; + if (plainObject(obj)) { + // set + + cy.startBatch(); + if (obj.data) { + ele.data(obj.data); + var _data2 = p.data; + if (ele.isEdge()) { + // source and target are immutable via data() + var move = false; + var spec = {}; + var src = obj.data.source; + var tgt = obj.data.target; + if (src != null && src != _data2.source) { + spec.source = '' + src; // id must be string + move = true; + } + if (tgt != null && tgt != _data2.target) { + spec.target = '' + tgt; // id must be string + move = true; + } + if (move) { + ele = ele.move(spec); + } + } else { + // parent is immutable via data() + var newParentValSpecd = ('parent' in obj.data); + var parent = obj.data.parent; + if (newParentValSpecd && (parent != null || _data2.parent != null) && parent != _data2.parent) { + if (parent === undefined) { + // can't set undefined imperatively, so use null + parent = null; + } + if (parent != null) { + parent = '' + parent; // id must be string + } + + ele = ele.move({ + parent: parent + }); + } + } + } + if (obj.position) { + ele.position(obj.position); + } + + // ignore group -- immutable + + var checkSwitch = function checkSwitch(k, trueFnName, falseFnName) { + var obj_k = obj[k]; + if (obj_k != null && obj_k !== p[k]) { + if (obj_k) { + ele[trueFnName](); + } else { + ele[falseFnName](); + } + } + }; + checkSwitch('removed', 'remove', 'restore'); + checkSwitch('selected', 'select', 'unselect'); + checkSwitch('selectable', 'selectify', 'unselectify'); + checkSwitch('locked', 'lock', 'unlock'); + checkSwitch('grabbable', 'grabify', 'ungrabify'); + checkSwitch('pannable', 'panify', 'unpanify'); + if (obj.classes != null) { + ele.classes(obj.classes); + } + cy.endBatch(); + return this; + } else if (obj === undefined) { + // get + + var json = { + data: copy(p.data), + position: copy(p.position), + group: p.group, + removed: p.removed, + selected: p.selected, + selectable: p.selectable, + locked: p.locked, + grabbable: p.grabbable, + pannable: p.pannable, + classes: null + }; + json.classes = ''; + var i = 0; + p.classes.forEach(function (cls) { + return json.classes += i++ === 0 ? cls : ' ' + cls; + }); + return json; + } +}; +elesfn$1.jsons = function () { + var jsons = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var json = ele.json(); + jsons.push(json); + } + return jsons; +}; +elesfn$1.clone = function () { + var cy = this.cy(); + var elesArr = []; + for (var i = 0; i < this.length; i++) { + var ele = this[i]; + var json = ele.json(); + var clone = new Element(cy, json, false); // NB no restore + + elesArr.push(clone); + } + return new Collection(cy, elesArr); +}; +elesfn$1.copy = elesfn$1.clone; +elesfn$1.restore = function () { + var notifyRenderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var addToPool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var self = this; + var cy = self.cy(); + var cy_p = cy._private; + + // create arrays of nodes and edges, since we need to + // restore the nodes first + var nodes = []; + var edges = []; + var elements; + for (var _i3 = 0, l = self.length; _i3 < l; _i3++) { + var ele = self[_i3]; + if (addToPool && !ele.removed()) { + // don't need to handle this ele + continue; + } + + // keep nodes first in the array and edges after + if (ele.isNode()) { + // put to front of array if node + nodes.push(ele); + } else { + // put to end of array if edge + edges.push(ele); + } + } + elements = nodes.concat(edges); + var i; + var removeFromElements = function removeFromElements() { + elements.splice(i, 1); + i--; + }; + + // now, restore each element + for (i = 0; i < elements.length; i++) { + var _ele2 = elements[i]; + var _private = _ele2._private; + var _data3 = _private.data; + + // the traversal cache should start fresh when ele is added + _ele2.clearTraversalCache(); + + // set id and validate + if (!addToPool && !_private.removed) ; else if (_data3.id === undefined) { + _data3.id = uuid(); + } else if (number$1(_data3.id)) { + _data3.id = '' + _data3.id; // now it's a string + } else if (emptyString(_data3.id) || !string(_data3.id)) { + error('Can not create element with invalid string ID `' + _data3.id + '`'); + + // can't create element if it has empty string as id or non-string id + removeFromElements(); + continue; + } else if (cy.hasElementWithId(_data3.id)) { + error('Can not create second element with ID `' + _data3.id + '`'); + + // can't create element if one already has that id + removeFromElements(); + continue; + } + var id = _data3.id; // id is finalised, now let's keep a ref + + if (_ele2.isNode()) { + // extra checks for nodes + var pos = _private.position; + + // make sure the nodes have a defined position + + if (pos.x == null) { + pos.x = 0; + } + if (pos.y == null) { + pos.y = 0; + } + } + if (_ele2.isEdge()) { + // extra checks for edges + + var edge = _ele2; + var fields = ['source', 'target']; + var fieldsLength = fields.length; + var badSourceOrTarget = false; + for (var j = 0; j < fieldsLength; j++) { + var field = fields[j]; + var val = _data3[field]; + if (number$1(val)) { + val = _data3[field] = '' + _data3[field]; // now string + } + + if (val == null || val === '') { + // can't create if source or target is not defined properly + error('Can not create edge `' + id + '` with unspecified ' + field); + badSourceOrTarget = true; + } else if (!cy.hasElementWithId(val)) { + // can't create edge if one of its nodes doesn't exist + error('Can not create edge `' + id + '` with nonexistant ' + field + ' `' + val + '`'); + badSourceOrTarget = true; + } + } + if (badSourceOrTarget) { + removeFromElements(); + continue; + } // can't create this + + var src = cy.getElementById(_data3.source); + var tgt = cy.getElementById(_data3.target); + + // only one edge in node if loop + if (src.same(tgt)) { + src._private.edges.push(edge); + } else { + src._private.edges.push(edge); + tgt._private.edges.push(edge); + } + edge._private.source = src; + edge._private.target = tgt; + } // if is edge + + // create mock ids / indexes maps for element so it can be used like collections + _private.map = new Map$2(); + _private.map.set(id, { + ele: _ele2, + index: 0 + }); + _private.removed = false; + if (addToPool) { + cy.addToPool(_ele2); + } + } // for each element + + // do compound node sanity checks + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + // each node + var node = nodes[_i4]; + var _data4 = node._private.data; + if (number$1(_data4.parent)) { + // then automake string + _data4.parent = '' + _data4.parent; + } + var parentId = _data4.parent; + var specifiedParent = parentId != null; + if (specifiedParent || node._private.parent) { + var parent = node._private.parent ? cy.collection().merge(node._private.parent) : cy.getElementById(parentId); + if (parent.empty()) { + // non-existant parent; just remove it + _data4.parent = undefined; + } else if (parent[0].removed()) { + warn('Node added with missing parent, reference to parent removed'); + _data4.parent = undefined; + node._private.parent = null; + } else { + var selfAsParent = false; + var ancestor = parent; + while (!ancestor.empty()) { + if (node.same(ancestor)) { + // mark self as parent and remove from data + selfAsParent = true; + _data4.parent = undefined; // remove parent reference + + // exit or we loop forever + break; + } + ancestor = ancestor.parent(); + } + if (!selfAsParent) { + // connect with children + parent[0]._private.children.push(node); + node._private.parent = parent[0]; + + // let the core know we have a compound graph + cy_p.hasCompoundNodes = true; + } + } // else + } // if specified parent + } // for each node + + if (elements.length > 0) { + var restored = elements.length === self.length ? self : new Collection(cy, elements); + for (var _i5 = 0; _i5 < restored.length; _i5++) { + var _ele3 = restored[_i5]; + if (_ele3.isNode()) { + continue; + } + + // adding an edge invalidates the traversal caches for the parallel edges + _ele3.parallelEdges().clearTraversalCache(); + + // adding an edge invalidates the traversal cache for the connected nodes + _ele3.source().clearTraversalCache(); + _ele3.target().clearTraversalCache(); + } + var toUpdateStyle; + if (cy_p.hasCompoundNodes) { + toUpdateStyle = cy.collection().merge(restored).merge(restored.connectedNodes()).merge(restored.parent()); + } else { + toUpdateStyle = restored; + } + toUpdateStyle.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(notifyRenderer); + if (notifyRenderer) { + restored.emitAndNotify('add'); + } else if (addToPool) { + restored.emit('add'); + } + } + return self; // chainability +}; + +elesfn$1.removed = function () { + var ele = this[0]; + return ele && ele._private.removed; +}; +elesfn$1.inside = function () { + var ele = this[0]; + return ele && !ele._private.removed; +}; +elesfn$1.remove = function () { + var notifyRenderer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var removeFromPool = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var self = this; + var elesToRemove = []; + var elesToRemoveIds = {}; + var cy = self._private.cy; + + // add connected edges + function addConnectedEdges(node) { + var edges = node._private.edges; + for (var i = 0; i < edges.length; i++) { + add(edges[i]); + } + } + + // add descendant nodes + function addChildren(node) { + var children = node._private.children; + for (var i = 0; i < children.length; i++) { + add(children[i]); + } + } + function add(ele) { + var alreadyAdded = elesToRemoveIds[ele.id()]; + if (removeFromPool && ele.removed() || alreadyAdded) { + return; + } else { + elesToRemoveIds[ele.id()] = true; + } + if (ele.isNode()) { + elesToRemove.push(ele); // nodes are removed last + + addConnectedEdges(ele); + addChildren(ele); + } else { + elesToRemove.unshift(ele); // edges are removed first + } + } + + // make the list of elements to remove + // (may be removing more than specified due to connected edges etc) + + for (var i = 0, l = self.length; i < l; i++) { + var ele = self[i]; + add(ele); + } + function removeEdgeRef(node, edge) { + var connectedEdges = node._private.edges; + removeFromArray(connectedEdges, edge); + + // removing an edges invalidates the traversal cache for its nodes + node.clearTraversalCache(); + } + function removeParallelRef(pllEdge) { + // removing an edge invalidates the traversal caches for the parallel edges + pllEdge.clearTraversalCache(); + } + var alteredParents = []; + alteredParents.ids = {}; + function removeChildRef(parent, ele) { + ele = ele[0]; + parent = parent[0]; + var children = parent._private.children; + var pid = parent.id(); + removeFromArray(children, ele); // remove parent => child ref + + ele._private.parent = null; // remove child => parent ref + + if (!alteredParents.ids[pid]) { + alteredParents.ids[pid] = true; + alteredParents.push(parent); + } + } + self.dirtyCompoundBoundsCache(); + if (removeFromPool) { + cy.removeFromPool(elesToRemove); // remove from core pool + } + + for (var _i6 = 0; _i6 < elesToRemove.length; _i6++) { + var _ele4 = elesToRemove[_i6]; + if (_ele4.isEdge()) { + // remove references to this edge in its connected nodes + var src = _ele4.source()[0]; + var tgt = _ele4.target()[0]; + removeEdgeRef(src, _ele4); + removeEdgeRef(tgt, _ele4); + var pllEdges = _ele4.parallelEdges(); + for (var j = 0; j < pllEdges.length; j++) { + var pllEdge = pllEdges[j]; + removeParallelRef(pllEdge); + if (pllEdge.isBundledBezier()) { + pllEdge.dirtyBoundingBoxCache(); + } + } + } else { + // remove reference to parent + var parent = _ele4.parent(); + if (parent.length !== 0) { + removeChildRef(parent, _ele4); + } + } + if (removeFromPool) { + // mark as removed + _ele4._private.removed = true; + } + } + + // check to see if we have a compound graph or not + var elesStillInside = cy._private.elements; + cy._private.hasCompoundNodes = false; + for (var _i7 = 0; _i7 < elesStillInside.length; _i7++) { + var _ele5 = elesStillInside[_i7]; + if (_ele5.isParent()) { + cy._private.hasCompoundNodes = true; + break; + } + } + var removedElements = new Collection(this.cy(), elesToRemove); + if (removedElements.size() > 0) { + // must manually notify since trigger won't do this automatically once removed + + if (notifyRenderer) { + removedElements.emitAndNotify('remove'); + } else if (removeFromPool) { + removedElements.emit('remove'); + } + } + + // the parents who were modified by the removal need their style updated + for (var _i8 = 0; _i8 < alteredParents.length; _i8++) { + var _ele6 = alteredParents[_i8]; + if (!removeFromPool || !_ele6.removed()) { + _ele6.updateStyle(); + } + } + return removedElements; +}; +elesfn$1.move = function (struct) { + var cy = this._private.cy; + var eles = this; + + // just clean up refs, caches, etc. in the same way as when removing and then restoring + // (our calls to remove/restore do not remove from the graph or make events) + var notifyRenderer = false; + var modifyPool = false; + var toString = function toString(id) { + return id == null ? id : '' + id; + }; // id must be string + + if (struct.source !== undefined || struct.target !== undefined) { + var srcId = toString(struct.source); + var tgtId = toString(struct.target); + var srcExists = srcId != null && cy.hasElementWithId(srcId); + var tgtExists = tgtId != null && cy.hasElementWithId(tgtId); + if (srcExists || tgtExists) { + cy.batch(function () { + // avoid duplicate style updates + eles.remove(notifyRenderer, modifyPool); // clean up refs etc. + eles.emitAndNotify('moveout'); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _data5 = ele._private.data; + if (ele.isEdge()) { + if (srcExists) { + _data5.source = srcId; + } + if (tgtExists) { + _data5.target = tgtId; + } + } + } + eles.restore(notifyRenderer, modifyPool); // make new refs, style, etc. + }); + + eles.emitAndNotify('move'); + } + } else if (struct.parent !== undefined) { + // move node to new parent + var parentId = toString(struct.parent); + var parentExists = parentId === null || cy.hasElementWithId(parentId); + if (parentExists) { + var pidToAssign = parentId === null ? undefined : parentId; + cy.batch(function () { + // avoid duplicate style updates + var updated = eles.remove(notifyRenderer, modifyPool); // clean up refs etc. + updated.emitAndNotify('moveout'); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _data6 = ele._private.data; + if (ele.isNode()) { + _data6.parent = pidToAssign; + } + } + updated.restore(notifyRenderer, modifyPool); // make new refs, style, etc. + }); + + eles.emitAndNotify('move'); + } + } + return this; +}; +[elesfn$j, elesfn$i, elesfn$h, elesfn$g, elesfn$f, data, elesfn$d, dimensions, elesfn$9, elesfn$8, elesfn$7, elesfn$6, elesfn$5, elesfn$4, elesfn$3, elesfn$2].forEach(function (props) { + extend(elesfn$1, props); +}); + +var corefn$9 = { + add: function add(opts) { + var elements; + var cy = this; + + // add the elements + if (elementOrCollection(opts)) { + var eles = opts; + if (eles._private.cy === cy) { + // same instance => just restore + elements = eles.restore(); + } else { + // otherwise, copy from json + var jsons = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + jsons.push(ele.json()); + } + elements = new Collection(cy, jsons); + } + } + + // specify an array of options + else if (array(opts)) { + var _jsons = opts; + elements = new Collection(cy, _jsons); + } + + // specify via opts.nodes and opts.edges + else if (plainObject(opts) && (array(opts.nodes) || array(opts.edges))) { + var elesByGroup = opts; + var _jsons2 = []; + var grs = ['nodes', 'edges']; + for (var _i = 0, il = grs.length; _i < il; _i++) { + var group = grs[_i]; + var elesArray = elesByGroup[group]; + if (array(elesArray)) { + for (var j = 0, jl = elesArray.length; j < jl; j++) { + var json = extend({ + group: group + }, elesArray[j]); + _jsons2.push(json); + } + } + } + elements = new Collection(cy, _jsons2); + } + + // specify options for one element + else { + var _json = opts; + elements = new Element(cy, _json).collection(); + } + return elements; + }, + remove: function remove(collection) { + if (elementOrCollection(collection)) ; else if (string(collection)) { + var selector = collection; + collection = this.$(selector); + } + return collection.remove(); + } +}; + +/* global Float32Array */ + +/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ +function generateCubicBezier(mX1, mY1, mX2, mY2) { + var NEWTON_ITERATIONS = 4, + NEWTON_MIN_SLOPE = 0.001, + SUBDIVISION_PRECISION = 0.0000001, + SUBDIVISION_MAX_ITERATIONS = 10, + kSplineTableSize = 11, + kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), + float32ArraySupported = typeof Float32Array !== 'undefined'; + + /* Must contain four arguments. */ + if (arguments.length !== 4) { + return false; + } + + /* Arguments must be numbers. */ + for (var i = 0; i < 4; ++i) { + if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { + return false; + } + } + + /* X values must be in the [0, 1] range. */ + mX1 = Math.min(mX1, 1); + mX2 = Math.min(mX2, 1); + mX1 = Math.max(mX1, 0); + mX2 = Math.max(mX2, 0); + var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); + function A(aA1, aA2) { + return 1.0 - 3.0 * aA2 + 3.0 * aA1; + } + function B(aA1, aA2) { + return 3.0 * aA2 - 6.0 * aA1; + } + function C(aA1) { + return 3.0 * aA1; + } + function calcBezier(aT, aA1, aA2) { + return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; + } + function getSlope(aT, aA1, aA2) { + return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); + } + function newtonRaphsonIterate(aX, aGuessT) { + for (var _i = 0; _i < NEWTON_ITERATIONS; ++_i) { + var currentSlope = getSlope(aGuessT, mX1, mX2); + if (currentSlope === 0.0) { + return aGuessT; + } + var currentX = calcBezier(aGuessT, mX1, mX2) - aX; + aGuessT -= currentX / currentSlope; + } + return aGuessT; + } + function calcSampleValues() { + for (var _i2 = 0; _i2 < kSplineTableSize; ++_i2) { + mSampleValues[_i2] = calcBezier(_i2 * kSampleStepSize, mX1, mX2); + } + } + function binarySubdivide(aX, aA, aB) { + var currentX, + currentT, + i = 0; + do { + currentT = aA + (aB - aA) / 2.0; + currentX = calcBezier(currentT, mX1, mX2) - aX; + if (currentX > 0.0) { + aB = currentT; + } else { + aA = currentT; + } + } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); + return currentT; + } + function getTForX(aX) { + var intervalStart = 0.0, + currentSample = 1, + lastSample = kSplineTableSize - 1; + for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { + intervalStart += kSampleStepSize; + } + --currentSample; + var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]), + guessForT = intervalStart + dist * kSampleStepSize, + initialSlope = getSlope(guessForT, mX1, mX2); + if (initialSlope >= NEWTON_MIN_SLOPE) { + return newtonRaphsonIterate(aX, guessForT); + } else if (initialSlope === 0.0) { + return guessForT; + } else { + return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); + } + } + var _precomputed = false; + function precompute() { + _precomputed = true; + if (mX1 !== mY1 || mX2 !== mY2) { + calcSampleValues(); + } + } + var f = function f(aX) { + if (!_precomputed) { + precompute(); + } + if (mX1 === mY1 && mX2 === mY2) { + return aX; + } + if (aX === 0) { + return 0; + } + if (aX === 1) { + return 1; + } + return calcBezier(getTForX(aX), mY1, mY2); + }; + f.getControlPoints = function () { + return [{ + x: mX1, + y: mY1 + }, { + x: mX2, + y: mY2 + }]; + }; + var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; + f.toString = function () { + return str; + }; + return f; +} + +/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ +/* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass + then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ +var generateSpringRK4 = function () { + function springAccelerationForState(state) { + return -state.tension * state.x - state.friction * state.v; + } + function springEvaluateStateWithDerivative(initialState, dt, derivative) { + var state = { + x: initialState.x + derivative.dx * dt, + v: initialState.v + derivative.dv * dt, + tension: initialState.tension, + friction: initialState.friction + }; + return { + dx: state.v, + dv: springAccelerationForState(state) + }; + } + function springIntegrateState(state, dt) { + var a = { + dx: state.v, + dv: springAccelerationForState(state) + }, + b = springEvaluateStateWithDerivative(state, dt * 0.5, a), + c = springEvaluateStateWithDerivative(state, dt * 0.5, b), + d = springEvaluateStateWithDerivative(state, dt, c), + dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), + dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); + state.x = state.x + dxdt * dt; + state.v = state.v + dvdt * dt; + return state; + } + return function springRK4Factory(tension, friction, duration) { + var initState = { + x: -1, + v: 0, + tension: null, + friction: null + }, + path = [0], + time_lapsed = 0, + tolerance = 1 / 10000, + DT = 16 / 1000, + have_duration, + dt, + last_state; + tension = parseFloat(tension) || 500; + friction = parseFloat(friction) || 20; + duration = duration || null; + initState.tension = tension; + initState.friction = friction; + have_duration = duration !== null; + + /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ + if (have_duration) { + /* Run the simulation without a duration. */ + time_lapsed = springRK4Factory(tension, friction); + /* Compute the adjusted time delta. */ + dt = time_lapsed / duration * DT; + } else { + dt = DT; + } + for (;;) { + /* Next/step function .*/ + last_state = springIntegrateState(last_state || initState, dt); + /* Store the position. */ + path.push(1 + last_state.x); + time_lapsed += 16; + /* If the change threshold is reached, break. */ + if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { + break; + } + } + + /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the + computed path and returns a snapshot of the position according to a given percentComplete. */ + return !have_duration ? time_lapsed : function (percentComplete) { + return path[percentComplete * (path.length - 1) | 0]; + }; + }; +}(); + +var cubicBezier = function cubicBezier(t1, p1, t2, p2) { + var bezier = generateCubicBezier(t1, p1, t2, p2); + return function (start, end, percent) { + return start + (end - start) * bezier(percent); + }; +}; +var easings = { + 'linear': function linear(start, end, percent) { + return start + (end - start) * percent; + }, + // default easings + 'ease': cubicBezier(0.25, 0.1, 0.25, 1), + 'ease-in': cubicBezier(0.42, 0, 1, 1), + 'ease-out': cubicBezier(0, 0, 0.58, 1), + 'ease-in-out': cubicBezier(0.42, 0, 0.58, 1), + // sine + 'ease-in-sine': cubicBezier(0.47, 0, 0.745, 0.715), + 'ease-out-sine': cubicBezier(0.39, 0.575, 0.565, 1), + 'ease-in-out-sine': cubicBezier(0.445, 0.05, 0.55, 0.95), + // quad + 'ease-in-quad': cubicBezier(0.55, 0.085, 0.68, 0.53), + 'ease-out-quad': cubicBezier(0.25, 0.46, 0.45, 0.94), + 'ease-in-out-quad': cubicBezier(0.455, 0.03, 0.515, 0.955), + // cubic + 'ease-in-cubic': cubicBezier(0.55, 0.055, 0.675, 0.19), + 'ease-out-cubic': cubicBezier(0.215, 0.61, 0.355, 1), + 'ease-in-out-cubic': cubicBezier(0.645, 0.045, 0.355, 1), + // quart + 'ease-in-quart': cubicBezier(0.895, 0.03, 0.685, 0.22), + 'ease-out-quart': cubicBezier(0.165, 0.84, 0.44, 1), + 'ease-in-out-quart': cubicBezier(0.77, 0, 0.175, 1), + // quint + 'ease-in-quint': cubicBezier(0.755, 0.05, 0.855, 0.06), + 'ease-out-quint': cubicBezier(0.23, 1, 0.32, 1), + 'ease-in-out-quint': cubicBezier(0.86, 0, 0.07, 1), + // expo + 'ease-in-expo': cubicBezier(0.95, 0.05, 0.795, 0.035), + 'ease-out-expo': cubicBezier(0.19, 1, 0.22, 1), + 'ease-in-out-expo': cubicBezier(1, 0, 0, 1), + // circ + 'ease-in-circ': cubicBezier(0.6, 0.04, 0.98, 0.335), + 'ease-out-circ': cubicBezier(0.075, 0.82, 0.165, 1), + 'ease-in-out-circ': cubicBezier(0.785, 0.135, 0.15, 0.86), + // user param easings... + + 'spring': function spring(tension, friction, duration) { + if (duration === 0) { + // can't get a spring w/ duration 0 + return easings.linear; // duration 0 => jump to end so impl doesn't matter + } + + var spring = generateSpringRK4(tension, friction, duration); + return function (start, end, percent) { + return start + (end - start) * spring(percent); + }; + }, + 'cubic-bezier': cubicBezier +}; + +function getEasedValue(type, start, end, percent, easingFn) { + if (percent === 1) { + return end; + } + if (start === end) { + return end; + } + var val = easingFn(start, end, percent); + if (type == null) { + return val; + } + if (type.roundValue || type.color) { + val = Math.round(val); + } + if (type.min !== undefined) { + val = Math.max(val, type.min); + } + if (type.max !== undefined) { + val = Math.min(val, type.max); + } + return val; +} +function getValue(prop, spec) { + if (prop.pfValue != null || prop.value != null) { + if (prop.pfValue != null && (spec == null || spec.type.units !== '%')) { + return prop.pfValue; + } else { + return prop.value; + } + } else { + return prop; + } +} +function ease(startProp, endProp, percent, easingFn, propSpec) { + var type = propSpec != null ? propSpec.type : null; + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + var start = getValue(startProp, propSpec); + var end = getValue(endProp, propSpec); + if (number$1(start) && number$1(end)) { + return getEasedValue(type, start, end, percent, easingFn); + } else if (array(start) && array(end)) { + var easedArr = []; + for (var i = 0; i < end.length; i++) { + var si = start[i]; + var ei = end[i]; + if (si != null && ei != null) { + var val = getEasedValue(type, si, ei, percent, easingFn); + easedArr.push(val); + } else { + easedArr.push(ei); + } + } + return easedArr; + } + return undefined; +} + +function step$1(self, ani, now, isCore) { + var isEles = !isCore; + var _p = self._private; + var ani_p = ani._private; + var pEasing = ani_p.easing; + var startTime = ani_p.startTime; + var cy = isCore ? self : self.cy(); + var style = cy.style(); + if (!ani_p.easingImpl) { + if (pEasing == null) { + // use default + ani_p.easingImpl = easings['linear']; + } else { + // then define w/ name + var easingVals; + if (string(pEasing)) { + var easingProp = style.parse('transition-timing-function', pEasing); + easingVals = easingProp.value; + } else { + // then assume preparsed array + easingVals = pEasing; + } + var name, args; + if (string(easingVals)) { + name = easingVals; + args = []; + } else { + name = easingVals[1]; + args = easingVals.slice(2).map(function (n) { + return +n; + }); + } + if (args.length > 0) { + // create with args + if (name === 'spring') { + args.push(ani_p.duration); // need duration to generate spring + } + + ani_p.easingImpl = easings[name].apply(null, args); + } else { + // static impl by name + ani_p.easingImpl = easings[name]; + } + } + } + var easing = ani_p.easingImpl; + var percent; + if (ani_p.duration === 0) { + percent = 1; + } else { + percent = (now - startTime) / ani_p.duration; + } + if (ani_p.applying) { + percent = ani_p.progress; + } + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + if (ani_p.delay == null) { + // then update + + var startPos = ani_p.startPosition; + var endPos = ani_p.position; + if (endPos && isEles && !self.locked()) { + var newPos = {}; + if (valid(startPos.x, endPos.x)) { + newPos.x = ease(startPos.x, endPos.x, percent, easing); + } + if (valid(startPos.y, endPos.y)) { + newPos.y = ease(startPos.y, endPos.y, percent, easing); + } + self.position(newPos); + } + var startPan = ani_p.startPan; + var endPan = ani_p.pan; + var pan = _p.pan; + var animatingPan = endPan != null && isCore; + if (animatingPan) { + if (valid(startPan.x, endPan.x)) { + pan.x = ease(startPan.x, endPan.x, percent, easing); + } + if (valid(startPan.y, endPan.y)) { + pan.y = ease(startPan.y, endPan.y, percent, easing); + } + self.emit('pan'); + } + var startZoom = ani_p.startZoom; + var endZoom = ani_p.zoom; + var animatingZoom = endZoom != null && isCore; + if (animatingZoom) { + if (valid(startZoom, endZoom)) { + _p.zoom = bound(_p.minZoom, ease(startZoom, endZoom, percent, easing), _p.maxZoom); + } + self.emit('zoom'); + } + if (animatingPan || animatingZoom) { + self.emit('viewport'); + } + var props = ani_p.style; + if (props && props.length > 0 && isEles) { + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + var _name = prop.name; + var end = prop; + var start = ani_p.startStyle[_name]; + var propSpec = style.properties[start.name]; + var easedVal = ease(start, end, percent, easing, propSpec); + style.overrideBypass(self, _name, easedVal); + } // for props + + self.emit('style'); + } // if + } + + ani_p.progress = percent; + return percent; +} +function valid(start, end) { + if (start == null || end == null) { + return false; + } + if (number$1(start) && number$1(end)) { + return true; + } else if (start && end) { + return true; + } + return false; +} + +function startAnimation(self, ani, now, isCore) { + var ani_p = ani._private; + ani_p.started = true; + ani_p.startTime = now - ani_p.progress * ani_p.duration; +} + +function stepAll(now, cy) { + var eles = cy._private.aniEles; + var doneEles = []; + function stepOne(ele, isCore) { + var _p = ele._private; + var current = _p.animation.current; + var queue = _p.animation.queue; + var ranAnis = false; + + // if nothing currently animating, get something from the queue + if (current.length === 0) { + var next = queue.shift(); + if (next) { + current.push(next); + } + } + var callbacks = function callbacks(_callbacks) { + for (var j = _callbacks.length - 1; j >= 0; j--) { + var cb = _callbacks[j]; + cb(); + } + _callbacks.splice(0, _callbacks.length); + }; + + // step and remove if done + for (var i = current.length - 1; i >= 0; i--) { + var ani = current[i]; + var ani_p = ani._private; + if (ani_p.stopped) { + current.splice(i, 1); + ani_p.hooked = false; + ani_p.playing = false; + ani_p.started = false; + callbacks(ani_p.frames); + continue; + } + if (!ani_p.playing && !ani_p.applying) { + continue; + } + + // an apply() while playing shouldn't do anything + if (ani_p.playing && ani_p.applying) { + ani_p.applying = false; + } + if (!ani_p.started) { + startAnimation(ele, ani, now); + } + step$1(ele, ani, now, isCore); + if (ani_p.applying) { + ani_p.applying = false; + } + callbacks(ani_p.frames); + if (ani_p.step != null) { + ani_p.step(now); + } + if (ani.completed()) { + current.splice(i, 1); + ani_p.hooked = false; + ani_p.playing = false; + ani_p.started = false; + callbacks(ani_p.completes); + } + ranAnis = true; + } + if (!isCore && current.length === 0 && queue.length === 0) { + doneEles.push(ele); + } + return ranAnis; + } // stepElement + + // handle all eles + var ranEleAni = false; + for (var e = 0; e < eles.length; e++) { + var ele = eles[e]; + var handledThisEle = stepOne(ele); + ranEleAni = ranEleAni || handledThisEle; + } // each element + + var ranCoreAni = stepOne(cy, true); + + // notify renderer + if (ranEleAni || ranCoreAni) { + if (eles.length > 0) { + cy.notify('draw', eles); + } else { + cy.notify('draw'); + } + } + + // remove elements from list of currently animating if its queues are empty + eles.unmerge(doneEles); + cy.emit('step'); +} // stepAll + +var corefn$8 = { + // pull in animation functions + animate: define.animate(), + animation: define.animation(), + animated: define.animated(), + clearQueue: define.clearQueue(), + delay: define.delay(), + delayAnimation: define.delayAnimation(), + stop: define.stop(), + addToAnimationPool: function addToAnimationPool(eles) { + var cy = this; + if (!cy.styleEnabled()) { + return; + } // save cycles when no style used + + cy._private.aniEles.merge(eles); + }, + stopAnimationLoop: function stopAnimationLoop() { + this._private.animationsRunning = false; + }, + startAnimationLoop: function startAnimationLoop() { + var cy = this; + cy._private.animationsRunning = true; + if (!cy.styleEnabled()) { + return; + } // save cycles when no style used + + // NB the animation loop will exec in headless environments if style enabled + // and explicit cy.destroy() is necessary to stop the loop + + function headlessStep() { + if (!cy._private.animationsRunning) { + return; + } + requestAnimationFrame$1(function animationStep(now) { + stepAll(now, cy); + headlessStep(); + }); + } + var renderer = cy.renderer(); + if (renderer && renderer.beforeRender) { + // let the renderer schedule animations + renderer.beforeRender(function rendererAnimationStep(willDraw, now) { + stepAll(now, cy); + }, renderer.beforeRenderPriorities.animations); + } else { + // manage the animation loop ourselves + headlessStep(); // first call + } + } +}; + +var emitterOptions = { + qualifierCompare: function qualifierCompare(selector1, selector2) { + if (selector1 == null || selector2 == null) { + return selector1 == null && selector2 == null; + } else { + return selector1.sameText(selector2); + } + }, + eventMatches: function eventMatches(cy, listener, eventObj) { + var selector = listener.qualifier; + if (selector != null) { + return cy !== eventObj.target && element(eventObj.target) && selector.matches(eventObj.target); + } + return true; + }, + addEventFields: function addEventFields(cy, evt) { + evt.cy = cy; + evt.target = cy; + }, + callbackContext: function callbackContext(cy, listener, eventObj) { + return listener.qualifier != null ? eventObj.target : cy; + } +}; +var argSelector = function argSelector(arg) { + if (string(arg)) { + return new Selector(arg); + } else { + return arg; + } +}; +var elesfn = { + createEmitter: function createEmitter() { + var _p = this._private; + if (!_p.emitter) { + _p.emitter = new Emitter(emitterOptions, this); + } + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(events, selector, callback) { + this.emitter().on(events, argSelector(selector), callback); + return this; + }, + removeListener: function removeListener(events, selector, callback) { + this.emitter().removeListener(events, argSelector(selector), callback); + return this; + }, + removeAllListeners: function removeAllListeners() { + this.emitter().removeAllListeners(); + return this; + }, + one: function one(events, selector, callback) { + this.emitter().one(events, argSelector(selector), callback); + return this; + }, + once: function once(events, selector, callback) { + this.emitter().one(events, argSelector(selector), callback); + return this; + }, + emit: function emit(events, extraParams) { + this.emitter().emit(events, extraParams); + return this; + }, + emitAndNotify: function emitAndNotify(event, eles) { + this.emit(event); + this.notify(event, eles); + return this; + } +}; +define.eventAliasesOn(elesfn); + +var corefn$7 = { + png: function png(options) { + var renderer = this._private.renderer; + options = options || {}; + return renderer.png(options); + }, + jpg: function jpg(options) { + var renderer = this._private.renderer; + options = options || {}; + options.bg = options.bg || '#fff'; + return renderer.jpg(options); + } +}; +corefn$7.jpeg = corefn$7.jpg; + +var corefn$6 = { + layout: function layout(options) { + var cy = this; + if (options == null) { + error('Layout options must be specified to make a layout'); + return; + } + if (options.name == null) { + error('A `name` must be specified to make a layout'); + return; + } + var name = options.name; + var Layout = cy.extension('layout', name); + if (Layout == null) { + error('No such layout `' + name + '` found. Did you forget to import it and `cytoscape.use()` it?'); + return; + } + var eles; + if (string(options.eles)) { + eles = cy.$(options.eles); + } else { + eles = options.eles != null ? options.eles : cy.$(); + } + var layout = new Layout(extend({}, options, { + cy: cy, + eles: eles + })); + return layout; + } +}; +corefn$6.createLayout = corefn$6.makeLayout = corefn$6.layout; + +var corefn$5 = { + notify: function notify(eventName, eventEles) { + var _p = this._private; + if (this.batching()) { + _p.batchNotifications = _p.batchNotifications || {}; + var eles = _p.batchNotifications[eventName] = _p.batchNotifications[eventName] || this.collection(); + if (eventEles != null) { + eles.merge(eventEles); + } + return; // notifications are disabled during batching + } + + if (!_p.notificationsEnabled) { + return; + } // exit on disabled + + var renderer = this.renderer(); + + // exit if destroy() called on core or renderer in between frames #1499 #1528 + if (this.destroyed() || !renderer) { + return; + } + renderer.notify(eventName, eventEles); + }, + notifications: function notifications(bool) { + var p = this._private; + if (bool === undefined) { + return p.notificationsEnabled; + } else { + p.notificationsEnabled = bool ? true : false; + } + return this; + }, + noNotifications: function noNotifications(callback) { + this.notifications(false); + callback(); + this.notifications(true); + }, + batching: function batching() { + return this._private.batchCount > 0; + }, + startBatch: function startBatch() { + var _p = this._private; + if (_p.batchCount == null) { + _p.batchCount = 0; + } + if (_p.batchCount === 0) { + _p.batchStyleEles = this.collection(); + _p.batchNotifications = {}; + } + _p.batchCount++; + return this; + }, + endBatch: function endBatch() { + var _p = this._private; + if (_p.batchCount === 0) { + return this; + } + _p.batchCount--; + if (_p.batchCount === 0) { + // update style for dirty eles + _p.batchStyleEles.updateStyle(); + var renderer = this.renderer(); + + // notify the renderer of queued eles and event types + Object.keys(_p.batchNotifications).forEach(function (eventName) { + var eles = _p.batchNotifications[eventName]; + if (eles.empty()) { + renderer.notify(eventName); + } else { + renderer.notify(eventName, eles); + } + }); + } + return this; + }, + batch: function batch(callback) { + this.startBatch(); + callback(); + this.endBatch(); + return this; + }, + // for backwards compatibility + batchData: function batchData(map) { + var cy = this; + return this.batch(function () { + var ids = Object.keys(map); + for (var i = 0; i < ids.length; i++) { + var id = ids[i]; + var data = map[id]; + var ele = cy.getElementById(id); + ele.data(data); + } + }); + } +}; + +var rendererDefaults = defaults$g({ + hideEdgesOnViewport: false, + textureOnViewport: false, + motionBlur: false, + motionBlurOpacity: 0.05, + pixelRatio: undefined, + desktopTapThreshold: 4, + touchTapThreshold: 8, + wheelSensitivity: 1, + debug: false, + showFps: false +}); +var corefn$4 = { + renderTo: function renderTo(context, zoom, pan, pxRatio) { + var r = this._private.renderer; + r.renderTo(context, zoom, pan, pxRatio); + return this; + }, + renderer: function renderer() { + return this._private.renderer; + }, + forceRender: function forceRender() { + this.notify('draw'); + return this; + }, + resize: function resize() { + this.invalidateSize(); + this.emitAndNotify('resize'); + return this; + }, + initRenderer: function initRenderer(options) { + var cy = this; + var RendererProto = cy.extension('renderer', options.name); + if (RendererProto == null) { + error("Can not initialise: No such renderer `".concat(options.name, "` found. Did you forget to import it and `cytoscape.use()` it?")); + return; + } + if (options.wheelSensitivity !== undefined) { + warn("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine."); + } + var rOpts = rendererDefaults(options); + rOpts.cy = cy; + cy._private.renderer = new RendererProto(rOpts); + this.notify('init'); + }, + destroyRenderer: function destroyRenderer() { + var cy = this; + cy.notify('destroy'); // destroy the renderer + + var domEle = cy.container(); + if (domEle) { + domEle._cyreg = null; + while (domEle.childNodes.length > 0) { + domEle.removeChild(domEle.childNodes[0]); + } + } + cy._private.renderer = null; // to be extra safe, remove the ref + cy.mutableElements().forEach(function (ele) { + var _p = ele._private; + _p.rscratch = {}; + _p.rstyle = {}; + _p.animation.current = []; + _p.animation.queue = []; + }); + }, + onRender: function onRender(fn) { + return this.on('render', fn); + }, + offRender: function offRender(fn) { + return this.off('render', fn); + } +}; +corefn$4.invalidateDimensions = corefn$4.resize; + +var corefn$3 = { + // get a collection + // - empty collection on no args + // - collection of elements in the graph on selector arg + // - guarantee a returned collection when elements or collection specified + collection: function collection(eles, opts) { + if (string(eles)) { + return this.$(eles); + } else if (elementOrCollection(eles)) { + return eles.collection(); + } else if (array(eles)) { + if (!opts) { + opts = {}; + } + return new Collection(this, eles, opts.unique, opts.removed); + } + return new Collection(this); + }, + nodes: function nodes(selector) { + var nodes = this.$(function (ele) { + return ele.isNode(); + }); + if (selector) { + return nodes.filter(selector); + } + return nodes; + }, + edges: function edges(selector) { + var edges = this.$(function (ele) { + return ele.isEdge(); + }); + if (selector) { + return edges.filter(selector); + } + return edges; + }, + // search the graph like jQuery + $: function $(selector) { + var eles = this._private.elements; + if (selector) { + return eles.filter(selector); + } else { + return eles.spawnSelf(); + } + }, + mutableElements: function mutableElements() { + return this._private.elements; + } +}; + +// aliases +corefn$3.elements = corefn$3.filter = corefn$3.$; + +var styfn$8 = {}; + +// keys for style blocks, e.g. ttfftt +var TRUE = 't'; +var FALSE = 'f'; + +// (potentially expensive calculation) +// apply the style to the element based on +// - its bypass +// - what selectors match it +styfn$8.apply = function (eles) { + var self = this; + var _p = self._private; + var cy = _p.cy; + var updatedEles = cy.collection(); + for (var ie = 0; ie < eles.length; ie++) { + var ele = eles[ie]; + var cxtMeta = self.getContextMeta(ele); + if (cxtMeta.empty) { + continue; + } + var cxtStyle = self.getContextStyle(cxtMeta); + var app = self.applyContextStyle(cxtMeta, cxtStyle, ele); + if (ele._private.appliedInitStyle) { + self.updateTransitions(ele, app.diffProps); + } else { + ele._private.appliedInitStyle = true; + } + var hintsDiff = self.updateStyleHints(ele); + if (hintsDiff) { + updatedEles.push(ele); + } + } // for elements + + return updatedEles; +}; +styfn$8.getPropertiesDiff = function (oldCxtKey, newCxtKey) { + var self = this; + var cache = self._private.propDiffs = self._private.propDiffs || {}; + var dualCxtKey = oldCxtKey + '-' + newCxtKey; + var cachedVal = cache[dualCxtKey]; + if (cachedVal) { + return cachedVal; + } + var diffProps = []; + var addedProp = {}; + for (var i = 0; i < self.length; i++) { + var cxt = self[i]; + var oldHasCxt = oldCxtKey[i] === TRUE; + var newHasCxt = newCxtKey[i] === TRUE; + var cxtHasDiffed = oldHasCxt !== newHasCxt; + var cxtHasMappedProps = cxt.mappedProperties.length > 0; + if (cxtHasDiffed || newHasCxt && cxtHasMappedProps) { + var props = void 0; + if (cxtHasDiffed && cxtHasMappedProps) { + props = cxt.properties; // suffices b/c mappedProperties is a subset of properties + } else if (cxtHasDiffed) { + props = cxt.properties; // need to check them all + } else if (cxtHasMappedProps) { + props = cxt.mappedProperties; // only need to check mapped + } + + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + var name = prop.name; + + // if a later context overrides this property, then the fact that this context has switched/diffed doesn't matter + // (semi expensive check since it makes this function O(n^2) on context length, but worth it since overall result + // is cached) + var laterCxtOverrides = false; + for (var k = i + 1; k < self.length; k++) { + var laterCxt = self[k]; + var hasLaterCxt = newCxtKey[k] === TRUE; + if (!hasLaterCxt) { + continue; + } // can't override unless the context is active + + laterCxtOverrides = laterCxt.properties[prop.name] != null; + if (laterCxtOverrides) { + break; + } // exit early as long as one later context overrides + } + + if (!addedProp[name] && !laterCxtOverrides) { + addedProp[name] = true; + diffProps.push(name); + } + } // for props + } // if + } // for contexts + + cache[dualCxtKey] = diffProps; + return diffProps; +}; +styfn$8.getContextMeta = function (ele) { + var self = this; + var cxtKey = ''; + var diffProps; + var prevKey = ele._private.styleCxtKey || ''; + + // get the cxt key + for (var i = 0; i < self.length; i++) { + var context = self[i]; + var contextSelectorMatches = context.selector && context.selector.matches(ele); // NB: context.selector may be null for 'core' + + if (contextSelectorMatches) { + cxtKey += TRUE; + } else { + cxtKey += FALSE; + } + } // for context + + diffProps = self.getPropertiesDiff(prevKey, cxtKey); + ele._private.styleCxtKey = cxtKey; + return { + key: cxtKey, + diffPropNames: diffProps, + empty: diffProps.length === 0 + }; +}; + +// gets a computed ele style object based on matched contexts +styfn$8.getContextStyle = function (cxtMeta) { + var cxtKey = cxtMeta.key; + var self = this; + var cxtStyles = this._private.contextStyles = this._private.contextStyles || {}; + + // if already computed style, returned cached copy + if (cxtStyles[cxtKey]) { + return cxtStyles[cxtKey]; + } + var style = { + _private: { + key: cxtKey + } + }; + for (var i = 0; i < self.length; i++) { + var cxt = self[i]; + var hasCxt = cxtKey[i] === TRUE; + if (!hasCxt) { + continue; + } + for (var j = 0; j < cxt.properties.length; j++) { + var prop = cxt.properties[j]; + style[prop.name] = prop; + } + } + cxtStyles[cxtKey] = style; + return style; +}; +styfn$8.applyContextStyle = function (cxtMeta, cxtStyle, ele) { + var self = this; + var diffProps = cxtMeta.diffPropNames; + var retDiffProps = {}; + var types = self.types; + for (var i = 0; i < diffProps.length; i++) { + var diffPropName = diffProps[i]; + var cxtProp = cxtStyle[diffPropName]; + var eleProp = ele.pstyle(diffPropName); + if (!cxtProp) { + // no context prop means delete + if (!eleProp) { + continue; // no existing prop means nothing needs to be removed + // nb affects initial application on mapped values like control-point-distances + } else if (eleProp.bypass) { + cxtProp = { + name: diffPropName, + deleteBypassed: true + }; + } else { + cxtProp = { + name: diffPropName, + "delete": true + }; + } + } + + // save cycles when the context prop doesn't need to be applied + if (eleProp === cxtProp) { + continue; + } + + // save cycles when a mapped context prop doesn't need to be applied + if (cxtProp.mapped === types.fn // context prop is function mapper + && eleProp != null // some props can be null even by default (e.g. a prop that overrides another one) + && eleProp.mapping != null // ele prop is a concrete value from from a mapper + && eleProp.mapping.value === cxtProp.value // the current prop on the ele is a flat prop value for the function mapper + ) { + // NB don't write to cxtProp, as it's shared among eles (stored in stylesheet) + var mapping = eleProp.mapping; // can write to mapping, as it's a per-ele copy + var fnValue = mapping.fnValue = cxtProp.value(ele); // temporarily cache the value in case of a miss + + if (fnValue === mapping.prevFnValue) { + continue; + } + } + var retDiffProp = retDiffProps[diffPropName] = { + prev: eleProp + }; + self.applyParsedProperty(ele, cxtProp); + retDiffProp.next = ele.pstyle(diffPropName); + if (retDiffProp.next && retDiffProp.next.bypass) { + retDiffProp.next = retDiffProp.next.bypassed; + } + } + return { + diffProps: retDiffProps + }; +}; +styfn$8.updateStyleHints = function (ele) { + var _p = ele._private; + var self = this; + var propNames = self.propertyGroupNames; + var propGrKeys = self.propertyGroupKeys; + var propHash = function propHash(ele, propNames, seedKey) { + return self.getPropertiesHash(ele, propNames, seedKey); + }; + var oldStyleKey = _p.styleKey; + if (ele.removed()) { + return false; + } + var isNode = _p.group === 'nodes'; + + // get the style key hashes per prop group + // but lazily -- only use non-default prop values to reduce the number of hashes + // + + var overriddenStyles = ele._private.style; + propNames = Object.keys(overriddenStyles); + for (var i = 0; i < propGrKeys.length; i++) { + var grKey = propGrKeys[i]; + _p.styleKeys[grKey] = [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]; + } + var updateGrKey1 = function updateGrKey1(val, grKey) { + return _p.styleKeys[grKey][0] = hashInt(val, _p.styleKeys[grKey][0]); + }; + var updateGrKey2 = function updateGrKey2(val, grKey) { + return _p.styleKeys[grKey][1] = hashIntAlt(val, _p.styleKeys[grKey][1]); + }; + var updateGrKey = function updateGrKey(val, grKey) { + updateGrKey1(val, grKey); + updateGrKey2(val, grKey); + }; + var updateGrKeyWStr = function updateGrKeyWStr(strVal, grKey) { + for (var j = 0; j < strVal.length; j++) { + var ch = strVal.charCodeAt(j); + updateGrKey1(ch, grKey); + updateGrKey2(ch, grKey); + } + }; + + // - hashing works on 32 bit ints b/c we use bitwise ops + // - small numbers get cut off (e.g. 0.123 is seen as 0 by the hashing function) + // - raise up small numbers so more significant digits are seen by hashing + // - make small numbers larger than a normal value to avoid collisions + // - works in practice and it's relatively cheap + var N = 2000000000; + var cleanNum = function cleanNum(val) { + return -128 < val && val < 128 && Math.floor(val) !== val ? N - (val * 1024 | 0) : val; + }; + for (var _i = 0; _i < propNames.length; _i++) { + var name = propNames[_i]; + var parsedProp = overriddenStyles[name]; + if (parsedProp == null) { + continue; + } + var propInfo = this.properties[name]; + var type = propInfo.type; + var _grKey = propInfo.groupKey; + var normalizedNumberVal = void 0; + if (propInfo.hashOverride != null) { + normalizedNumberVal = propInfo.hashOverride(ele, parsedProp); + } else if (parsedProp.pfValue != null) { + normalizedNumberVal = parsedProp.pfValue; + } + + // might not be a number if it allows enums + var numberVal = propInfo.enums == null ? parsedProp.value : null; + var haveNormNum = normalizedNumberVal != null; + var haveUnitedNum = numberVal != null; + var haveNum = haveNormNum || haveUnitedNum; + var units = parsedProp.units; + + // numbers are cheaper to hash than strings + // 1 hash op vs n hash ops (for length n string) + if (type.number && haveNum && !type.multiple) { + var v = haveNormNum ? normalizedNumberVal : numberVal; + updateGrKey(cleanNum(v), _grKey); + if (!haveNormNum && units != null) { + updateGrKeyWStr(units, _grKey); + } + } else { + updateGrKeyWStr(parsedProp.strValue, _grKey); + } + } + + // overall style key + // + + var hash = [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]; + for (var _i2 = 0; _i2 < propGrKeys.length; _i2++) { + var _grKey2 = propGrKeys[_i2]; + var grHash = _p.styleKeys[_grKey2]; + hash[0] = hashInt(grHash[0], hash[0]); + hash[1] = hashIntAlt(grHash[1], hash[1]); + } + _p.styleKey = combineHashes(hash[0], hash[1]); + + // label dims + // + + var sk = _p.styleKeys; + _p.labelDimsKey = combineHashesArray(sk.labelDimensions); + var labelKeys = propHash(ele, ['label'], sk.labelDimensions); + _p.labelKey = combineHashesArray(labelKeys); + _p.labelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, labelKeys)); + if (!isNode) { + var sourceLabelKeys = propHash(ele, ['source-label'], sk.labelDimensions); + _p.sourceLabelKey = combineHashesArray(sourceLabelKeys); + _p.sourceLabelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, sourceLabelKeys)); + var targetLabelKeys = propHash(ele, ['target-label'], sk.labelDimensions); + _p.targetLabelKey = combineHashesArray(targetLabelKeys); + _p.targetLabelStyleKey = combineHashesArray(hashArrays(sk.commonLabel, targetLabelKeys)); + } + + // node + // + + if (isNode) { + var _p$styleKeys = _p.styleKeys, + nodeBody = _p$styleKeys.nodeBody, + nodeBorder = _p$styleKeys.nodeBorder, + nodeOutline = _p$styleKeys.nodeOutline, + backgroundImage = _p$styleKeys.backgroundImage, + compound = _p$styleKeys.compound, + pie = _p$styleKeys.pie; + var nodeKeys = [nodeBody, nodeBorder, nodeOutline, backgroundImage, compound, pie].filter(function (k) { + return k != null; + }).reduce(hashArrays, [DEFAULT_HASH_SEED, DEFAULT_HASH_SEED_ALT]); + _p.nodeKey = combineHashesArray(nodeKeys); + _p.hasPie = pie != null && pie[0] !== DEFAULT_HASH_SEED && pie[1] !== DEFAULT_HASH_SEED_ALT; + } + return oldStyleKey !== _p.styleKey; +}; +styfn$8.clearStyleHints = function (ele) { + var _p = ele._private; + _p.styleCxtKey = ''; + _p.styleKeys = {}; + _p.styleKey = null; + _p.labelKey = null; + _p.labelStyleKey = null; + _p.sourceLabelKey = null; + _p.sourceLabelStyleKey = null; + _p.targetLabelKey = null; + _p.targetLabelStyleKey = null; + _p.nodeKey = null; + _p.hasPie = null; +}; + +// apply a property to the style (for internal use) +// returns whether application was successful +// +// now, this function flattens the property, and here's how: +// +// for parsedProp:{ bypass: true, deleteBypass: true } +// no property is generated, instead the bypass property in the +// element's style is replaced by what's pointed to by the `bypassed` +// field in the bypass property (i.e. restoring the property the +// bypass was overriding) +// +// for parsedProp:{ mapped: truthy } +// the generated flattenedProp:{ mapping: prop } +// +// for parsedProp:{ bypass: true } +// the generated flattenedProp:{ bypassed: parsedProp } +styfn$8.applyParsedProperty = function (ele, parsedProp) { + var self = this; + var prop = parsedProp; + var style = ele._private.style; + var flatProp; + var types = self.types; + var type = self.properties[prop.name].type; + var propIsBypass = prop.bypass; + var origProp = style[prop.name]; + var origPropIsBypass = origProp && origProp.bypass; + var _p = ele._private; + var flatPropMapping = 'mapping'; + var getVal = function getVal(p) { + if (p == null) { + return null; + } else if (p.pfValue != null) { + return p.pfValue; + } else { + return p.value; + } + }; + var checkTriggers = function checkTriggers() { + var fromVal = getVal(origProp); + var toVal = getVal(prop); + self.checkTriggers(ele, prop.name, fromVal, toVal); + }; + + // edge sanity checks to prevent the client from making serious mistakes + if (parsedProp.name === 'curve-style' && ele.isEdge() && ( + // loops must be bundled beziers + parsedProp.value !== 'bezier' && ele.isLoop() || + // edges connected to compound nodes can not be haystacks + parsedProp.value === 'haystack' && (ele.source().isParent() || ele.target().isParent()))) { + prop = parsedProp = this.parse(parsedProp.name, 'bezier', propIsBypass); + } + if (prop["delete"]) { + // delete the property and use the default value on falsey value + style[prop.name] = undefined; + checkTriggers(); + return true; + } + if (prop.deleteBypassed) { + // delete the property that the + if (!origProp) { + checkTriggers(); + return true; // can't delete if no prop + } else if (origProp.bypass) { + // delete bypassed + origProp.bypassed = undefined; + checkTriggers(); + return true; + } else { + return false; // we're unsuccessful deleting the bypassed + } + } + + // check if we need to delete the current bypass + if (prop.deleteBypass) { + // then this property is just here to indicate we need to delete + if (!origProp) { + checkTriggers(); + return true; // property is already not defined + } else if (origProp.bypass) { + // then replace the bypass property with the original + // because the bypassed property was already applied (and therefore parsed), we can just replace it (no reapplying necessary) + style[prop.name] = origProp.bypassed; + checkTriggers(); + return true; + } else { + return false; // we're unsuccessful deleting the bypass + } + } + + var printMappingErr = function printMappingErr() { + warn('Do not assign mappings to elements without corresponding data (i.e. ele `' + ele.id() + '` has no mapping for property `' + prop.name + '` with data field `' + prop.field + '`); try a `[' + prop.field + ']` selector to limit scope to elements with `' + prop.field + '` defined'); + }; + + // put the property in the style objects + switch (prop.mapped) { + // flatten the property if mapped + case types.mapData: + { + // flatten the field (e.g. data.foo.bar) + var fields = prop.field.split('.'); + var fieldVal = _p.data; + for (var i = 0; i < fields.length && fieldVal; i++) { + var field = fields[i]; + fieldVal = fieldVal[field]; + } + if (fieldVal == null) { + printMappingErr(); + return false; + } + var percent; + if (!number$1(fieldVal)) { + // then don't apply and fall back on the existing style + warn('Do not use continuous mappers without specifying numeric data (i.e. `' + prop.field + ': ' + fieldVal + '` for `' + ele.id() + '` is non-numeric)'); + return false; + } else { + var fieldWidth = prop.fieldMax - prop.fieldMin; + if (fieldWidth === 0) { + // safety check -- not strictly necessary as no props of zero range should be passed here + percent = 0; + } else { + percent = (fieldVal - prop.fieldMin) / fieldWidth; + } + } + + // make sure to bound percent value + if (percent < 0) { + percent = 0; + } else if (percent > 1) { + percent = 1; + } + if (type.color) { + var r1 = prop.valueMin[0]; + var r2 = prop.valueMax[0]; + var g1 = prop.valueMin[1]; + var g2 = prop.valueMax[1]; + var b1 = prop.valueMin[2]; + var b2 = prop.valueMax[2]; + var a1 = prop.valueMin[3] == null ? 1 : prop.valueMin[3]; + var a2 = prop.valueMax[3] == null ? 1 : prop.valueMax[3]; + var clr = [Math.round(r1 + (r2 - r1) * percent), Math.round(g1 + (g2 - g1) * percent), Math.round(b1 + (b2 - b1) * percent), Math.round(a1 + (a2 - a1) * percent)]; + flatProp = { + // colours are simple, so just create the flat property instead of expensive string parsing + bypass: prop.bypass, + // we're a bypass if the mapping property is a bypass + name: prop.name, + value: clr, + strValue: 'rgb(' + clr[0] + ', ' + clr[1] + ', ' + clr[2] + ')' + }; + } else if (type.number) { + var calcValue = prop.valueMin + (prop.valueMax - prop.valueMin) * percent; + flatProp = this.parse(prop.name, calcValue, prop.bypass, flatPropMapping); + } else { + return false; // can only map to colours and numbers + } + + if (!flatProp) { + // if we can't flatten the property, then don't apply the property and fall back on the existing style + printMappingErr(); + return false; + } + flatProp.mapping = prop; // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + + // direct mapping + case types.data: + { + // flatten the field (e.g. data.foo.bar) + var _fields = prop.field.split('.'); + var _fieldVal = _p.data; + for (var _i3 = 0; _i3 < _fields.length && _fieldVal; _i3++) { + var _field = _fields[_i3]; + _fieldVal = _fieldVal[_field]; + } + if (_fieldVal != null) { + flatProp = this.parse(prop.name, _fieldVal, prop.bypass, flatPropMapping); + } + if (!flatProp) { + // if we can't flatten the property, then don't apply and fall back on the existing style + printMappingErr(); + return false; + } + flatProp.mapping = prop; // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + case types.fn: + { + var fn = prop.value; + var fnRetVal = prop.fnValue != null ? prop.fnValue : fn(ele); // check for cached value before calling function + + prop.prevFnValue = fnRetVal; + if (fnRetVal == null) { + warn('Custom function mappers may not return null (i.e. `' + prop.name + '` for ele `' + ele.id() + '` is null)'); + return false; + } + flatProp = this.parse(prop.name, fnRetVal, prop.bypass, flatPropMapping); + if (!flatProp) { + warn('Custom function mappers may not return invalid values for the property type (i.e. `' + prop.name + '` for ele `' + ele.id() + '` is invalid)'); + return false; + } + flatProp.mapping = copy(prop); // keep a reference to the mapping + prop = flatProp; // the flattened (mapped) property is the one we want + + break; + } + case undefined: + break; + // just set the property + + default: + return false; + // not a valid mapping + } + + // if the property is a bypass property, then link the resultant property to the original one + if (propIsBypass) { + if (origPropIsBypass) { + // then this bypass overrides the existing one + prop.bypassed = origProp.bypassed; // steal bypassed prop from old bypass + } else { + // then link the orig prop to the new bypass + prop.bypassed = origProp; + } + style[prop.name] = prop; // and set + } else { + // prop is not bypass + if (origPropIsBypass) { + // then keep the orig prop (since it's a bypass) and link to the new prop + origProp.bypassed = prop; + } else { + // then just replace the old prop with the new one + style[prop.name] = prop; + } + } + checkTriggers(); + return true; +}; +styfn$8.cleanElements = function (eles, keepBypasses) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + this.clearStyleHints(ele); + ele.dirtyCompoundBoundsCache(); + ele.dirtyBoundingBoxCache(); + if (!keepBypasses) { + ele._private.style = {}; + } else { + var style = ele._private.style; + var propNames = Object.keys(style); + for (var j = 0; j < propNames.length; j++) { + var propName = propNames[j]; + var eleProp = style[propName]; + if (eleProp != null) { + if (eleProp.bypass) { + eleProp.bypassed = null; + } else { + style[propName] = null; + } + } + } + } + } +}; + +// updates the visual style for all elements (useful for manual style modification after init) +styfn$8.update = function () { + var cy = this._private.cy; + var eles = cy.mutableElements(); + eles.updateStyle(); +}; + +// diffProps : { name => { prev, next } } +styfn$8.updateTransitions = function (ele, diffProps) { + var self = this; + var _p = ele._private; + var props = ele.pstyle('transition-property').value; + var duration = ele.pstyle('transition-duration').pfValue; + var delay = ele.pstyle('transition-delay').pfValue; + if (props.length > 0 && duration > 0) { + var style = {}; + + // build up the style to animate towards + var anyPrev = false; + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + var styProp = ele.pstyle(prop); + var diffProp = diffProps[prop]; + if (!diffProp) { + continue; + } + var prevProp = diffProp.prev; + var fromProp = prevProp; + var toProp = diffProp.next != null ? diffProp.next : styProp; + var diff = false; + var initVal = void 0; + var initDt = 0.000001; // delta time % value for initVal (allows animating out of init zero opacity) + + if (!fromProp) { + continue; + } + + // consider px values + if (number$1(fromProp.pfValue) && number$1(toProp.pfValue)) { + diff = toProp.pfValue - fromProp.pfValue; // nonzero is truthy + initVal = fromProp.pfValue + initDt * diff; + + // consider numerical values + } else if (number$1(fromProp.value) && number$1(toProp.value)) { + diff = toProp.value - fromProp.value; // nonzero is truthy + initVal = fromProp.value + initDt * diff; + + // consider colour values + } else if (array(fromProp.value) && array(toProp.value)) { + diff = fromProp.value[0] !== toProp.value[0] || fromProp.value[1] !== toProp.value[1] || fromProp.value[2] !== toProp.value[2]; + initVal = fromProp.strValue; + } + + // the previous value is good for an animation only if it's different + if (diff) { + style[prop] = toProp.strValue; // to val + this.applyBypass(ele, prop, initVal); // from val + anyPrev = true; + } + } // end if props allow ani + + // can't transition if there's nothing previous to transition from + if (!anyPrev) { + return; + } + _p.transitioning = true; + new Promise$1(function (resolve) { + if (delay > 0) { + ele.delayAnimation(delay).play().promise().then(resolve); + } else { + resolve(); + } + }).then(function () { + return ele.animation({ + style: style, + duration: duration, + easing: ele.pstyle('transition-timing-function').value, + queue: false + }).play().promise(); + }).then(function () { + // if( !isBypass ){ + self.removeBypasses(ele, props); + ele.emitAndNotify('style'); + // } + + _p.transitioning = false; + }); + } else if (_p.transitioning) { + this.removeBypasses(ele, props); + ele.emitAndNotify('style'); + _p.transitioning = false; + } +}; +styfn$8.checkTrigger = function (ele, name, fromValue, toValue, getTrigger, onTrigger) { + var prop = this.properties[name]; + var triggerCheck = getTrigger(prop); + if (triggerCheck != null && triggerCheck(fromValue, toValue)) { + onTrigger(prop); + } +}; +styfn$8.checkZOrderTrigger = function (ele, name, fromValue, toValue) { + var _this = this; + this.checkTrigger(ele, name, fromValue, toValue, function (prop) { + return prop.triggersZOrder; + }, function () { + _this._private.cy.notify('zorder', ele); + }); +}; +styfn$8.checkBoundsTrigger = function (ele, name, fromValue, toValue) { + this.checkTrigger(ele, name, fromValue, toValue, function (prop) { + return prop.triggersBounds; + }, function (prop) { + ele.dirtyCompoundBoundsCache(); + ele.dirtyBoundingBoxCache(); + + // if the prop change makes the bb of pll bezier edges invalid, + // then dirty the pll edge bb cache as well + if ( + // only for beziers -- so performance of other edges isn't affected + prop.triggersBoundsOfParallelBeziers && name === 'curve-style' && (fromValue === 'bezier' || toValue === 'bezier')) { + ele.parallelEdges().forEach(function (pllEdge) { + if (pllEdge.isBundledBezier()) { + pllEdge.dirtyBoundingBoxCache(); + } + }); + } + if (prop.triggersBoundsOfConnectedEdges && name === 'display' && (fromValue === 'none' || toValue === 'none')) { + ele.connectedEdges().forEach(function (edge) { + edge.dirtyBoundingBoxCache(); + }); + } + }); +}; +styfn$8.checkTriggers = function (ele, name, fromValue, toValue) { + ele.dirtyStyleCache(); + this.checkZOrderTrigger(ele, name, fromValue, toValue); + this.checkBoundsTrigger(ele, name, fromValue, toValue); +}; + +var styfn$7 = {}; + +// bypasses are applied to an existing style on an element, and just tacked on temporarily +// returns true iff application was successful for at least 1 specified property +styfn$7.applyBypass = function (eles, name, value, updateTransitions) { + var self = this; + var props = []; + var isBypass = true; + + // put all the properties (can specify one or many) in an array after parsing them + if (name === '*' || name === '**') { + // apply to all property names + + if (value !== undefined) { + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var _name = prop.name; + var parsedProp = this.parse(_name, value, true); + if (parsedProp) { + props.push(parsedProp); + } + } + } + } else if (string(name)) { + // then parse the single property + var _parsedProp = this.parse(name, value, true); + if (_parsedProp) { + props.push(_parsedProp); + } + } else if (plainObject(name)) { + // then parse each property + var specifiedProps = name; + updateTransitions = value; + var names = Object.keys(specifiedProps); + for (var _i = 0; _i < names.length; _i++) { + var _name2 = names[_i]; + var _value = specifiedProps[_name2]; + if (_value === undefined) { + // try camel case name too + _value = specifiedProps[dash2camel(_name2)]; + } + if (_value !== undefined) { + var _parsedProp2 = this.parse(_name2, _value, true); + if (_parsedProp2) { + props.push(_parsedProp2); + } + } + } + } else { + // can't do anything without well defined properties + return false; + } + + // we've failed if there are no valid properties + if (props.length === 0) { + return false; + } + + // now, apply the bypass properties on the elements + var ret = false; // return true if at least one succesful bypass applied + for (var _i2 = 0; _i2 < eles.length; _i2++) { + // for each ele + var ele = eles[_i2]; + var diffProps = {}; + var diffProp = void 0; + for (var j = 0; j < props.length; j++) { + // for each prop + var _prop = props[j]; + if (updateTransitions) { + var prevProp = ele.pstyle(_prop.name); + diffProp = diffProps[_prop.name] = { + prev: prevProp + }; + } + ret = this.applyParsedProperty(ele, copy(_prop)) || ret; + if (updateTransitions) { + diffProp.next = ele.pstyle(_prop.name); + } + } // for props + + if (ret) { + this.updateStyleHints(ele); + } + if (updateTransitions) { + this.updateTransitions(ele, diffProps, isBypass); + } + } // for eles + + return ret; +}; + +// only useful in specific cases like animation +styfn$7.overrideBypass = function (eles, name, value) { + name = camel2dash(name); + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var prop = ele._private.style[name]; + var type = this.properties[name].type; + var isColor = type.color; + var isMulti = type.mutiple; + var oldValue = !prop ? null : prop.pfValue != null ? prop.pfValue : prop.value; + if (!prop || !prop.bypass) { + // need a bypass if one doesn't exist + this.applyBypass(ele, name, value); + } else { + prop.value = value; + if (prop.pfValue != null) { + prop.pfValue = value; + } + if (isColor) { + prop.strValue = 'rgb(' + value.join(',') + ')'; + } else if (isMulti) { + prop.strValue = value.join(' '); + } else { + prop.strValue = '' + value; + } + this.updateStyleHints(ele); + } + this.checkTriggers(ele, name, oldValue, value); + } +}; +styfn$7.removeAllBypasses = function (eles, updateTransitions) { + return this.removeBypasses(eles, this.propertyNames, updateTransitions); +}; +styfn$7.removeBypasses = function (eles, props, updateTransitions) { + var isBypass = true; + for (var j = 0; j < eles.length; j++) { + var ele = eles[j]; + var diffProps = {}; + for (var i = 0; i < props.length; i++) { + var name = props[i]; + var prop = this.properties[name]; + var prevProp = ele.pstyle(prop.name); + if (!prevProp || !prevProp.bypass) { + // if a bypass doesn't exist for the prop, nothing needs to be removed + continue; + } + var value = ''; // empty => remove bypass + var parsedProp = this.parse(name, value, true); + var diffProp = diffProps[prop.name] = { + prev: prevProp + }; + this.applyParsedProperty(ele, parsedProp); + diffProp.next = ele.pstyle(prop.name); + } // for props + + this.updateStyleHints(ele); + if (updateTransitions) { + this.updateTransitions(ele, diffProps, isBypass); + } + } // for eles +}; + +var styfn$6 = {}; + +// gets what an em size corresponds to in pixels relative to a dom element +styfn$6.getEmSizeInPixels = function () { + var px = this.containerCss('font-size'); + if (px != null) { + return parseFloat(px); + } else { + return 1; // for headless + } +}; + +// gets css property from the core container +styfn$6.containerCss = function (propName) { + var cy = this._private.cy; + var domElement = cy.container(); + var containerWindow = cy.window(); + if (containerWindow && domElement && containerWindow.getComputedStyle) { + return containerWindow.getComputedStyle(domElement).getPropertyValue(propName); + } +}; + +var styfn$5 = {}; + +// gets the rendered style for an element +styfn$5.getRenderedStyle = function (ele, prop) { + if (prop) { + return this.getStylePropertyValue(ele, prop, true); + } else { + return this.getRawStyle(ele, true); + } +}; + +// gets the raw style for an element +styfn$5.getRawStyle = function (ele, isRenderedVal) { + var self = this; + ele = ele[0]; // insure it's an element + + if (ele) { + var rstyle = {}; + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var val = self.getStylePropertyValue(ele, prop.name, isRenderedVal); + if (val != null) { + rstyle[prop.name] = val; + rstyle[dash2camel(prop.name)] = val; + } + } + return rstyle; + } +}; +styfn$5.getIndexedStyle = function (ele, property, subproperty, index) { + var pstyle = ele.pstyle(property)[subproperty][index]; + return pstyle != null ? pstyle : ele.cy().style().getDefaultProperty(property)[subproperty][0]; +}; +styfn$5.getStylePropertyValue = function (ele, propName, isRenderedVal) { + var self = this; + ele = ele[0]; // insure it's an element + + if (ele) { + var prop = self.properties[propName]; + if (prop.alias) { + prop = prop.pointsTo; + } + var type = prop.type; + var styleProp = ele.pstyle(prop.name); + if (styleProp) { + var value = styleProp.value, + units = styleProp.units, + strValue = styleProp.strValue; + if (isRenderedVal && type.number && value != null && number$1(value)) { + var zoom = ele.cy().zoom(); + var getRenderedValue = function getRenderedValue(val) { + return val * zoom; + }; + var getValueStringWithUnits = function getValueStringWithUnits(val, units) { + return getRenderedValue(val) + units; + }; + var isArrayValue = array(value); + var haveUnits = isArrayValue ? units.every(function (u) { + return u != null; + }) : units != null; + if (haveUnits) { + if (isArrayValue) { + return value.map(function (v, i) { + return getValueStringWithUnits(v, units[i]); + }).join(' '); + } else { + return getValueStringWithUnits(value, units); + } + } else { + if (isArrayValue) { + return value.map(function (v) { + return string(v) ? v : '' + getRenderedValue(v); + }).join(' '); + } else { + return '' + getRenderedValue(value); + } + } + } else if (strValue != null) { + return strValue; + } + } + return null; + } +}; +styfn$5.getAnimationStartStyle = function (ele, aniProps) { + var rstyle = {}; + for (var i = 0; i < aniProps.length; i++) { + var aniProp = aniProps[i]; + var name = aniProp.name; + var styleProp = ele.pstyle(name); + if (styleProp !== undefined) { + // then make a prop of it + if (plainObject(styleProp)) { + styleProp = this.parse(name, styleProp.strValue); + } else { + styleProp = this.parse(name, styleProp); + } + } + if (styleProp) { + rstyle[name] = styleProp; + } + } + return rstyle; +}; +styfn$5.getPropsList = function (propsObj) { + var self = this; + var rstyle = []; + var style = propsObj; + var props = self.properties; + if (style) { + var names = Object.keys(style); + for (var i = 0; i < names.length; i++) { + var name = names[i]; + var val = style[name]; + var prop = props[name] || props[camel2dash(name)]; + var styleProp = this.parse(prop.name, val); + if (styleProp) { + rstyle.push(styleProp); + } + } + } + return rstyle; +}; +styfn$5.getNonDefaultPropertiesHash = function (ele, propNames, seed) { + var hash = seed.slice(); + var name, val, strVal, chVal; + var i, j; + for (i = 0; i < propNames.length; i++) { + name = propNames[i]; + val = ele.pstyle(name, false); + if (val == null) { + continue; + } else if (val.pfValue != null) { + hash[0] = hashInt(chVal, hash[0]); + hash[1] = hashIntAlt(chVal, hash[1]); + } else { + strVal = val.strValue; + for (j = 0; j < strVal.length; j++) { + chVal = strVal.charCodeAt(j); + hash[0] = hashInt(chVal, hash[0]); + hash[1] = hashIntAlt(chVal, hash[1]); + } + } + } + return hash; +}; +styfn$5.getPropertiesHash = styfn$5.getNonDefaultPropertiesHash; + +var styfn$4 = {}; +styfn$4.appendFromJson = function (json) { + var style = this; + for (var i = 0; i < json.length; i++) { + var context = json[i]; + var selector = context.selector; + var props = context.style || context.css; + var names = Object.keys(props); + style.selector(selector); // apply selector + + for (var j = 0; j < names.length; j++) { + var name = names[j]; + var value = props[name]; + style.css(name, value); // apply property + } + } + + return style; +}; + +// accessible cy.style() function +styfn$4.fromJson = function (json) { + var style = this; + style.resetToDefault(); + style.appendFromJson(json); + return style; +}; + +// get json from cy.style() api +styfn$4.json = function () { + var json = []; + for (var i = this.defaultLength; i < this.length; i++) { + var cxt = this[i]; + var selector = cxt.selector; + var props = cxt.properties; + var css = {}; + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + css[prop.name] = prop.strValue; + } + json.push({ + selector: !selector ? 'core' : selector.toString(), + style: css + }); + } + return json; +}; + +var styfn$3 = {}; +styfn$3.appendFromString = function (string) { + var self = this; + var style = this; + var remaining = '' + string; + var selAndBlockStr; + var blockRem; + var propAndValStr; + + // remove comments from the style string + remaining = remaining.replace(/[/][*](\s|.)+?[*][/]/g, ''); + function removeSelAndBlockFromRemaining() { + // remove the parsed selector and block from the remaining text to parse + if (remaining.length > selAndBlockStr.length) { + remaining = remaining.substr(selAndBlockStr.length); + } else { + remaining = ''; + } + } + function removePropAndValFromRem() { + // remove the parsed property and value from the remaining block text to parse + if (blockRem.length > propAndValStr.length) { + blockRem = blockRem.substr(propAndValStr.length); + } else { + blockRem = ''; + } + } + for (;;) { + var nothingLeftToParse = remaining.match(/^\s*$/); + if (nothingLeftToParse) { + break; + } + var selAndBlock = remaining.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/); + if (!selAndBlock) { + warn('Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: ' + remaining); + break; + } + selAndBlockStr = selAndBlock[0]; + + // parse the selector + var selectorStr = selAndBlock[1]; + if (selectorStr !== 'core') { + var selector = new Selector(selectorStr); + if (selector.invalid) { + warn('Skipping parsing of block: Invalid selector found in string stylesheet: ' + selectorStr); + + // skip this selector and block + removeSelAndBlockFromRemaining(); + continue; + } + } + + // parse the block of properties and values + var blockStr = selAndBlock[2]; + var invalidBlock = false; + blockRem = blockStr; + var props = []; + for (;;) { + var _nothingLeftToParse = blockRem.match(/^\s*$/); + if (_nothingLeftToParse) { + break; + } + var propAndVal = blockRem.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/); + if (!propAndVal) { + warn('Skipping parsing of block: Invalid formatting of style property and value definitions found in:' + blockStr); + invalidBlock = true; + break; + } + propAndValStr = propAndVal[0]; + var propStr = propAndVal[1]; + var valStr = propAndVal[2]; + var prop = self.properties[propStr]; + if (!prop) { + warn('Skipping property: Invalid property name in: ' + propAndValStr); + + // skip this property in the block + removePropAndValFromRem(); + continue; + } + var parsedProp = style.parse(propStr, valStr); + if (!parsedProp) { + warn('Skipping property: Invalid property definition in: ' + propAndValStr); + + // skip this property in the block + removePropAndValFromRem(); + continue; + } + props.push({ + name: propStr, + val: valStr + }); + removePropAndValFromRem(); + } + if (invalidBlock) { + removeSelAndBlockFromRemaining(); + break; + } + + // put the parsed block in the style + style.selector(selectorStr); + for (var i = 0; i < props.length; i++) { + var _prop = props[i]; + style.css(_prop.name, _prop.val); + } + removeSelAndBlockFromRemaining(); + } + return style; +}; +styfn$3.fromString = function (string) { + var style = this; + style.resetToDefault(); + style.appendFromString(string); + return style; +}; + +var styfn$2 = {}; +(function () { + var number$1 = number; + var rgba = rgbaNoBackRefs; + var hsla = hslaNoBackRefs; + var hex3$1 = hex3; + var hex6$1 = hex6; + var data = function data(prefix) { + return '^' + prefix + '\\s*\\(\\s*([\\w\\.]+)\\s*\\)$'; + }; + var mapData = function mapData(prefix) { + var mapArg = number$1 + '|\\w+|' + rgba + '|' + hsla + '|' + hex3$1 + '|' + hex6$1; + return '^' + prefix + '\\s*\\(([\\w\\.]+)\\s*\\,\\s*(' + number$1 + ')\\s*\\,\\s*(' + number$1 + ')\\s*,\\s*(' + mapArg + ')\\s*\\,\\s*(' + mapArg + ')\\)$'; + }; + var urlRegexes = ['^url\\s*\\(\\s*[\'"]?(.+?)[\'"]?\\s*\\)$', '^(none)$', '^(.+)$']; + + // each visual style property has a type and needs to be validated according to it + styfn$2.types = { + time: { + number: true, + min: 0, + units: 's|ms', + implicitUnits: 'ms' + }, + percent: { + number: true, + min: 0, + max: 100, + units: '%', + implicitUnits: '%' + }, + percentages: { + number: true, + min: 0, + max: 100, + units: '%', + implicitUnits: '%', + multiple: true + }, + zeroOneNumber: { + number: true, + min: 0, + max: 1, + unitless: true + }, + zeroOneNumbers: { + number: true, + min: 0, + max: 1, + unitless: true, + multiple: true + }, + nOneOneNumber: { + number: true, + min: -1, + max: 1, + unitless: true + }, + nonNegativeInt: { + number: true, + min: 0, + integer: true, + unitless: true + }, + nonNegativeNumber: { + number: true, + min: 0, + unitless: true + }, + position: { + enums: ['parent', 'origin'] + }, + nodeSize: { + number: true, + min: 0, + enums: ['label'] + }, + number: { + number: true, + unitless: true + }, + numbers: { + number: true, + unitless: true, + multiple: true + }, + positiveNumber: { + number: true, + unitless: true, + min: 0, + strictMin: true + }, + size: { + number: true, + min: 0 + }, + bidirectionalSize: { + number: true + }, + // allows negative + bidirectionalSizeMaybePercent: { + number: true, + allowPercent: true + }, + // allows negative + bidirectionalSizes: { + number: true, + multiple: true + }, + // allows negative + sizeMaybePercent: { + number: true, + min: 0, + allowPercent: true + }, + axisDirection: { + enums: ['horizontal', 'leftward', 'rightward', 'vertical', 'upward', 'downward', 'auto'] + }, + paddingRelativeTo: { + enums: ['width', 'height', 'average', 'min', 'max'] + }, + bgWH: { + number: true, + min: 0, + allowPercent: true, + enums: ['auto'], + multiple: true + }, + bgPos: { + number: true, + allowPercent: true, + multiple: true + }, + bgRelativeTo: { + enums: ['inner', 'include-padding'], + multiple: true + }, + bgRepeat: { + enums: ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'], + multiple: true + }, + bgFit: { + enums: ['none', 'contain', 'cover'], + multiple: true + }, + bgCrossOrigin: { + enums: ['anonymous', 'use-credentials', 'null'], + multiple: true + }, + bgClip: { + enums: ['none', 'node'], + multiple: true + }, + bgContainment: { + enums: ['inside', 'over'], + multiple: true + }, + color: { + color: true + }, + colors: { + color: true, + multiple: true + }, + fill: { + enums: ['solid', 'linear-gradient', 'radial-gradient'] + }, + bool: { + enums: ['yes', 'no'] + }, + bools: { + enums: ['yes', 'no'], + multiple: true + }, + lineStyle: { + enums: ['solid', 'dotted', 'dashed'] + }, + lineCap: { + enums: ['butt', 'round', 'square'] + }, + linePosition: { + enums: ['center', 'inside', 'outside'] + }, + lineJoin: { + enums: ['round', 'bevel', 'miter'] + }, + borderStyle: { + enums: ['solid', 'dotted', 'dashed', 'double'] + }, + curveStyle: { + enums: ['bezier', 'unbundled-bezier', 'haystack', 'segments', 'straight', 'straight-triangle', 'taxi', 'round-segments', 'round-taxi'] + }, + radiusType: { + enums: ['arc-radius', 'influence-radius'], + multiple: true + }, + fontFamily: { + regex: '^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$' + }, + fontStyle: { + enums: ['italic', 'normal', 'oblique'] + }, + fontWeight: { + enums: ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '800', '900', 100, 200, 300, 400, 500, 600, 700, 800, 900] + }, + textDecoration: { + enums: ['none', 'underline', 'overline', 'line-through'] + }, + textTransform: { + enums: ['none', 'uppercase', 'lowercase'] + }, + textWrap: { + enums: ['none', 'wrap', 'ellipsis'] + }, + textOverflowWrap: { + enums: ['whitespace', 'anywhere'] + }, + textBackgroundShape: { + enums: ['rectangle', 'roundrectangle', 'round-rectangle'] + }, + nodeShape: { + enums: ['rectangle', 'roundrectangle', 'round-rectangle', 'cutrectangle', 'cut-rectangle', 'bottomroundrectangle', 'bottom-round-rectangle', 'barrel', 'ellipse', 'triangle', 'round-triangle', 'square', 'pentagon', 'round-pentagon', 'hexagon', 'round-hexagon', 'concavehexagon', 'concave-hexagon', 'heptagon', 'round-heptagon', 'octagon', 'round-octagon', 'tag', 'round-tag', 'star', 'diamond', 'round-diamond', 'vee', 'rhomboid', 'right-rhomboid', 'polygon'] + }, + overlayShape: { + enums: ['roundrectangle', 'round-rectangle', 'ellipse'] + }, + cornerRadius: { + number: true, + min: 0, + units: 'px|em', + implicitUnits: 'px', + enums: ['auto'] + }, + compoundIncludeLabels: { + enums: ['include', 'exclude'] + }, + arrowShape: { + enums: ['tee', 'triangle', 'triangle-tee', 'circle-triangle', 'triangle-cross', 'triangle-backcurve', 'vee', 'square', 'circle', 'diamond', 'chevron', 'none'] + }, + arrowFill: { + enums: ['filled', 'hollow'] + }, + arrowWidth: { + number: true, + units: '%|px|em', + implicitUnits: 'px', + enums: ['match-line'] + }, + display: { + enums: ['element', 'none'] + }, + visibility: { + enums: ['hidden', 'visible'] + }, + zCompoundDepth: { + enums: ['bottom', 'orphan', 'auto', 'top'] + }, + zIndexCompare: { + enums: ['auto', 'manual'] + }, + valign: { + enums: ['top', 'center', 'bottom'] + }, + halign: { + enums: ['left', 'center', 'right'] + }, + justification: { + enums: ['left', 'center', 'right', 'auto'] + }, + text: { + string: true + }, + data: { + mapping: true, + regex: data('data') + }, + layoutData: { + mapping: true, + regex: data('layoutData') + }, + scratch: { + mapping: true, + regex: data('scratch') + }, + mapData: { + mapping: true, + regex: mapData('mapData') + }, + mapLayoutData: { + mapping: true, + regex: mapData('mapLayoutData') + }, + mapScratch: { + mapping: true, + regex: mapData('mapScratch') + }, + fn: { + mapping: true, + fn: true + }, + url: { + regexes: urlRegexes, + singleRegexMatchValue: true + }, + urls: { + regexes: urlRegexes, + singleRegexMatchValue: true, + multiple: true + }, + propList: { + propList: true + }, + angle: { + number: true, + units: 'deg|rad', + implicitUnits: 'rad' + }, + textRotation: { + number: true, + units: 'deg|rad', + implicitUnits: 'rad', + enums: ['none', 'autorotate'] + }, + polygonPointList: { + number: true, + multiple: true, + evenMultiple: true, + min: -1, + max: 1, + unitless: true + }, + edgeDistances: { + enums: ['intersection', 'node-position', 'endpoints'] + }, + edgeEndpoint: { + number: true, + multiple: true, + units: '%|px|em|deg|rad', + implicitUnits: 'px', + enums: ['inside-to-node', 'outside-to-node', 'outside-to-node-or-label', 'outside-to-line', 'outside-to-line-or-label'], + singleEnum: true, + validate: function validate(valArr, unitsArr) { + switch (valArr.length) { + case 2: + // can be % or px only + return unitsArr[0] !== 'deg' && unitsArr[0] !== 'rad' && unitsArr[1] !== 'deg' && unitsArr[1] !== 'rad'; + case 1: + // can be enum, deg, or rad only + return string(valArr[0]) || unitsArr[0] === 'deg' || unitsArr[0] === 'rad'; + default: + return false; + } + } + }, + easing: { + regexes: ['^(spring)\\s*\\(\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*\\)$', '^(cubic-bezier)\\s*\\(\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*,\\s*(' + number$1 + ')\\s*\\)$'], + enums: ['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'ease-in-sine', 'ease-out-sine', 'ease-in-out-sine', 'ease-in-quad', 'ease-out-quad', 'ease-in-out-quad', 'ease-in-cubic', 'ease-out-cubic', 'ease-in-out-cubic', 'ease-in-quart', 'ease-out-quart', 'ease-in-out-quart', 'ease-in-quint', 'ease-out-quint', 'ease-in-out-quint', 'ease-in-expo', 'ease-out-expo', 'ease-in-out-expo', 'ease-in-circ', 'ease-out-circ', 'ease-in-out-circ'] + }, + gradientDirection: { + enums: ['to-bottom', 'to-top', 'to-left', 'to-right', 'to-bottom-right', 'to-bottom-left', 'to-top-right', 'to-top-left', 'to-right-bottom', 'to-left-bottom', 'to-right-top', 'to-left-top' // different order + ] + }, + + boundsExpansion: { + number: true, + multiple: true, + min: 0, + validate: function validate(valArr) { + var length = valArr.length; + return length === 1 || length === 2 || length === 4; + } + } + }; + var diff = { + zeroNonZero: function zeroNonZero(val1, val2) { + if ((val1 == null || val2 == null) && val1 !== val2) { + return true; // null cases could represent any value + } + if (val1 == 0 && val2 != 0) { + return true; + } else if (val1 != 0 && val2 == 0) { + return true; + } else { + return false; + } + }, + any: function any(val1, val2) { + return val1 != val2; + }, + emptyNonEmpty: function emptyNonEmpty(str1, str2) { + var empty1 = emptyString(str1); + var empty2 = emptyString(str2); + return empty1 && !empty2 || !empty1 && empty2; + } + }; + + // define visual style properties + // + // - n.b. adding a new group of props may require updates to updateStyleHints() + // - adding new props to an existing group gets handled automatically + + var t = styfn$2.types; + var mainLabel = [{ + name: 'label', + type: t.text, + triggersBounds: diff.any, + triggersZOrder: diff.emptyNonEmpty + }, { + name: 'text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }]; + var sourceLabel = [{ + name: 'source-label', + type: t.text, + triggersBounds: diff.any + }, { + name: 'source-text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'source-text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'source-text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'source-text-offset', + type: t.size, + triggersBounds: diff.any + }]; + var targetLabel = [{ + name: 'target-label', + type: t.text, + triggersBounds: diff.any + }, { + name: 'target-text-rotation', + type: t.textRotation, + triggersBounds: diff.any + }, { + name: 'target-text-margin-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'target-text-margin-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'target-text-offset', + type: t.size, + triggersBounds: diff.any + }]; + var labelDimensions = [{ + name: 'font-family', + type: t.fontFamily, + triggersBounds: diff.any + }, { + name: 'font-style', + type: t.fontStyle, + triggersBounds: diff.any + }, { + name: 'font-weight', + type: t.fontWeight, + triggersBounds: diff.any + }, { + name: 'font-size', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-transform', + type: t.textTransform, + triggersBounds: diff.any + }, { + name: 'text-wrap', + type: t.textWrap, + triggersBounds: diff.any + }, { + name: 'text-overflow-wrap', + type: t.textOverflowWrap, + triggersBounds: diff.any + }, { + name: 'text-max-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-outline-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'line-height', + type: t.positiveNumber, + triggersBounds: diff.any + }]; + var commonLabel = [{ + name: 'text-valign', + type: t.valign, + triggersBounds: diff.any + }, { + name: 'text-halign', + type: t.halign, + triggersBounds: diff.any + }, { + name: 'color', + type: t.color + }, { + name: 'text-outline-color', + type: t.color + }, { + name: 'text-outline-opacity', + type: t.zeroOneNumber + }, { + name: 'text-background-color', + type: t.color + }, { + name: 'text-background-opacity', + type: t.zeroOneNumber + }, { + name: 'text-background-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-border-opacity', + type: t.zeroOneNumber + }, { + name: 'text-border-color', + type: t.color + }, { + name: 'text-border-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'text-border-style', + type: t.borderStyle, + triggersBounds: diff.any + }, { + name: 'text-background-shape', + type: t.textBackgroundShape, + triggersBounds: diff.any + }, { + name: 'text-justification', + type: t.justification + }]; + var behavior = [{ + name: 'events', + type: t.bool, + triggersZOrder: diff.any + }, { + name: 'text-events', + type: t.bool, + triggersZOrder: diff.any + }]; + var visibility = [{ + name: 'display', + type: t.display, + triggersZOrder: diff.any, + triggersBounds: diff.any, + triggersBoundsOfConnectedEdges: true + }, { + name: 'visibility', + type: t.visibility, + triggersZOrder: diff.any + }, { + name: 'opacity', + type: t.zeroOneNumber, + triggersZOrder: diff.zeroNonZero + }, { + name: 'text-opacity', + type: t.zeroOneNumber + }, { + name: 'min-zoomed-font-size', + type: t.size + }, { + name: 'z-compound-depth', + type: t.zCompoundDepth, + triggersZOrder: diff.any + }, { + name: 'z-index-compare', + type: t.zIndexCompare, + triggersZOrder: diff.any + }, { + name: 'z-index', + type: t.number, + triggersZOrder: diff.any + }]; + var overlay = [{ + name: 'overlay-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'overlay-color', + type: t.color + }, { + name: 'overlay-opacity', + type: t.zeroOneNumber, + triggersBounds: diff.zeroNonZero + }, { + name: 'overlay-shape', + type: t.overlayShape, + triggersBounds: diff.any + }, { + name: 'overlay-corner-radius', + type: t.cornerRadius + }]; + var underlay = [{ + name: 'underlay-padding', + type: t.size, + triggersBounds: diff.any + }, { + name: 'underlay-color', + type: t.color + }, { + name: 'underlay-opacity', + type: t.zeroOneNumber, + triggersBounds: diff.zeroNonZero + }, { + name: 'underlay-shape', + type: t.overlayShape, + triggersBounds: diff.any + }, { + name: 'underlay-corner-radius', + type: t.cornerRadius + }]; + var transition = [{ + name: 'transition-property', + type: t.propList + }, { + name: 'transition-duration', + type: t.time + }, { + name: 'transition-delay', + type: t.time + }, { + name: 'transition-timing-function', + type: t.easing + }]; + var nodeSizeHashOverride = function nodeSizeHashOverride(ele, parsedProp) { + if (parsedProp.value === 'label') { + return -ele.poolIndex(); // no hash key hits is using label size (hitrate for perf probably low anyway) + } else { + return parsedProp.pfValue; + } + }; + var nodeBody = [{ + name: 'height', + type: t.nodeSize, + triggersBounds: diff.any, + hashOverride: nodeSizeHashOverride + }, { + name: 'width', + type: t.nodeSize, + triggersBounds: diff.any, + hashOverride: nodeSizeHashOverride + }, { + name: 'shape', + type: t.nodeShape, + triggersBounds: diff.any + }, { + name: 'shape-polygon-points', + type: t.polygonPointList, + triggersBounds: diff.any + }, { + name: 'corner-radius', + type: t.cornerRadius + }, { + name: 'background-color', + type: t.color + }, { + name: 'background-fill', + type: t.fill + }, { + name: 'background-opacity', + type: t.zeroOneNumber + }, { + name: 'background-blacken', + type: t.nOneOneNumber + }, { + name: 'background-gradient-stop-colors', + type: t.colors + }, { + name: 'background-gradient-stop-positions', + type: t.percentages + }, { + name: 'background-gradient-direction', + type: t.gradientDirection + }, { + name: 'padding', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'padding-relative-to', + type: t.paddingRelativeTo, + triggersBounds: diff.any + }, { + name: 'bounds-expansion', + type: t.boundsExpansion, + triggersBounds: diff.any + }]; + var nodeBorder = [{ + name: 'border-color', + type: t.color + }, { + name: 'border-opacity', + type: t.zeroOneNumber + }, { + name: 'border-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'border-style', + type: t.borderStyle + }, { + name: 'border-cap', + type: t.lineCap + }, { + name: 'border-join', + type: t.lineJoin + }, { + name: 'border-dash-pattern', + type: t.numbers + }, { + name: 'border-dash-offset', + type: t.number + }, { + name: 'border-position', + type: t.linePosition + }]; + var nodeOutline = [{ + name: 'outline-color', + type: t.color + }, { + name: 'outline-opacity', + type: t.zeroOneNumber + }, { + name: 'outline-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'outline-style', + type: t.borderStyle + }, { + name: 'outline-offset', + type: t.size, + triggersBounds: diff.any + }]; + var backgroundImage = [{ + name: 'background-image', + type: t.urls + }, { + name: 'background-image-crossorigin', + type: t.bgCrossOrigin + }, { + name: 'background-image-opacity', + type: t.zeroOneNumbers + }, { + name: 'background-image-containment', + type: t.bgContainment + }, { + name: 'background-image-smoothing', + type: t.bools + }, { + name: 'background-position-x', + type: t.bgPos + }, { + name: 'background-position-y', + type: t.bgPos + }, { + name: 'background-width-relative-to', + type: t.bgRelativeTo + }, { + name: 'background-height-relative-to', + type: t.bgRelativeTo + }, { + name: 'background-repeat', + type: t.bgRepeat + }, { + name: 'background-fit', + type: t.bgFit + }, { + name: 'background-clip', + type: t.bgClip + }, { + name: 'background-width', + type: t.bgWH + }, { + name: 'background-height', + type: t.bgWH + }, { + name: 'background-offset-x', + type: t.bgPos + }, { + name: 'background-offset-y', + type: t.bgPos + }]; + var compound = [{ + name: 'position', + type: t.position, + triggersBounds: diff.any + }, { + name: 'compound-sizing-wrt-labels', + type: t.compoundIncludeLabels, + triggersBounds: diff.any + }, { + name: 'min-width', + type: t.size, + triggersBounds: diff.any + }, { + name: 'min-width-bias-left', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-width-bias-right', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-height', + type: t.size, + triggersBounds: diff.any + }, { + name: 'min-height-bias-top', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'min-height-bias-bottom', + type: t.sizeMaybePercent, + triggersBounds: diff.any + }]; + var edgeLine = [{ + name: 'line-style', + type: t.lineStyle + }, { + name: 'line-color', + type: t.color + }, { + name: 'line-fill', + type: t.fill + }, { + name: 'line-cap', + type: t.lineCap + }, { + name: 'line-opacity', + type: t.zeroOneNumber + }, { + name: 'line-dash-pattern', + type: t.numbers + }, { + name: 'line-dash-offset', + type: t.number + }, { + name: 'line-gradient-stop-colors', + type: t.colors + }, { + name: 'line-gradient-stop-positions', + type: t.percentages + }, { + name: 'curve-style', + type: t.curveStyle, + triggersBounds: diff.any, + triggersBoundsOfParallelBeziers: true + }, { + name: 'haystack-radius', + type: t.zeroOneNumber, + triggersBounds: diff.any + }, { + name: 'source-endpoint', + type: t.edgeEndpoint, + triggersBounds: diff.any + }, { + name: 'target-endpoint', + type: t.edgeEndpoint, + triggersBounds: diff.any + }, { + name: 'control-point-step-size', + type: t.size, + triggersBounds: diff.any + }, { + name: 'control-point-distances', + type: t.bidirectionalSizes, + triggersBounds: diff.any + }, { + name: 'control-point-weights', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'segment-distances', + type: t.bidirectionalSizes, + triggersBounds: diff.any + }, { + name: 'segment-weights', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'segment-radii', + type: t.numbers, + triggersBounds: diff.any + }, { + name: 'radius-type', + type: t.radiusType, + triggersBounds: diff.any + }, { + name: 'taxi-turn', + type: t.bidirectionalSizeMaybePercent, + triggersBounds: diff.any + }, { + name: 'taxi-turn-min-distance', + type: t.size, + triggersBounds: diff.any + }, { + name: 'taxi-direction', + type: t.axisDirection, + triggersBounds: diff.any + }, { + name: 'taxi-radius', + type: t.number, + triggersBounds: diff.any + }, { + name: 'edge-distances', + type: t.edgeDistances, + triggersBounds: diff.any + }, { + name: 'arrow-scale', + type: t.positiveNumber, + triggersBounds: diff.any + }, { + name: 'loop-direction', + type: t.angle, + triggersBounds: diff.any + }, { + name: 'loop-sweep', + type: t.angle, + triggersBounds: diff.any + }, { + name: 'source-distance-from-node', + type: t.size, + triggersBounds: diff.any + }, { + name: 'target-distance-from-node', + type: t.size, + triggersBounds: diff.any + }]; + var ghost = [{ + name: 'ghost', + type: t.bool, + triggersBounds: diff.any + }, { + name: 'ghost-offset-x', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'ghost-offset-y', + type: t.bidirectionalSize, + triggersBounds: diff.any + }, { + name: 'ghost-opacity', + type: t.zeroOneNumber + }]; + var core = [{ + name: 'selection-box-color', + type: t.color + }, { + name: 'selection-box-opacity', + type: t.zeroOneNumber + }, { + name: 'selection-box-border-color', + type: t.color + }, { + name: 'selection-box-border-width', + type: t.size + }, { + name: 'active-bg-color', + type: t.color + }, { + name: 'active-bg-opacity', + type: t.zeroOneNumber + }, { + name: 'active-bg-size', + type: t.size + }, { + name: 'outside-texture-bg-color', + type: t.color + }, { + name: 'outside-texture-bg-opacity', + type: t.zeroOneNumber + }]; + + // pie backgrounds for nodes + var pie = []; + styfn$2.pieBackgroundN = 16; // because the pie properties are numbered, give access to a constant N (for renderer use) + pie.push({ + name: 'pie-size', + type: t.sizeMaybePercent + }); + for (var i = 1; i <= styfn$2.pieBackgroundN; i++) { + pie.push({ + name: 'pie-' + i + '-background-color', + type: t.color + }); + pie.push({ + name: 'pie-' + i + '-background-size', + type: t.percent + }); + pie.push({ + name: 'pie-' + i + '-background-opacity', + type: t.zeroOneNumber + }); + } + + // edge arrows + var edgeArrow = []; + var arrowPrefixes = styfn$2.arrowPrefixes = ['source', 'mid-source', 'target', 'mid-target']; + [{ + name: 'arrow-shape', + type: t.arrowShape, + triggersBounds: diff.any + }, { + name: 'arrow-color', + type: t.color + }, { + name: 'arrow-fill', + type: t.arrowFill + }, { + name: 'arrow-width', + type: t.arrowWidth + }].forEach(function (prop) { + arrowPrefixes.forEach(function (prefix) { + var name = prefix + '-' + prop.name; + var type = prop.type, + triggersBounds = prop.triggersBounds; + edgeArrow.push({ + name: name, + type: type, + triggersBounds: triggersBounds + }); + }); + }, {}); + var props = styfn$2.properties = [].concat(behavior, transition, visibility, overlay, underlay, ghost, commonLabel, labelDimensions, mainLabel, sourceLabel, targetLabel, nodeBody, nodeBorder, nodeOutline, backgroundImage, pie, compound, edgeLine, edgeArrow, core); + var propGroups = styfn$2.propertyGroups = { + // common to all eles + behavior: behavior, + transition: transition, + visibility: visibility, + overlay: overlay, + underlay: underlay, + ghost: ghost, + // labels + commonLabel: commonLabel, + labelDimensions: labelDimensions, + mainLabel: mainLabel, + sourceLabel: sourceLabel, + targetLabel: targetLabel, + // node props + nodeBody: nodeBody, + nodeBorder: nodeBorder, + nodeOutline: nodeOutline, + backgroundImage: backgroundImage, + pie: pie, + compound: compound, + // edge props + edgeLine: edgeLine, + edgeArrow: edgeArrow, + core: core + }; + var propGroupNames = styfn$2.propertyGroupNames = {}; + var propGroupKeys = styfn$2.propertyGroupKeys = Object.keys(propGroups); + propGroupKeys.forEach(function (key) { + propGroupNames[key] = propGroups[key].map(function (prop) { + return prop.name; + }); + propGroups[key].forEach(function (prop) { + return prop.groupKey = key; + }); + }); + + // define aliases + var aliases = styfn$2.aliases = [{ + name: 'content', + pointsTo: 'label' + }, { + name: 'control-point-distance', + pointsTo: 'control-point-distances' + }, { + name: 'control-point-weight', + pointsTo: 'control-point-weights' + }, { + name: 'segment-distance', + pointsTo: 'segment-distances' + }, { + name: 'segment-weight', + pointsTo: 'segment-weights' + }, { + name: 'segment-radius', + pointsTo: 'segment-radii' + }, { + name: 'edge-text-rotation', + pointsTo: 'text-rotation' + }, { + name: 'padding-left', + pointsTo: 'padding' + }, { + name: 'padding-right', + pointsTo: 'padding' + }, { + name: 'padding-top', + pointsTo: 'padding' + }, { + name: 'padding-bottom', + pointsTo: 'padding' + }]; + + // list of property names + styfn$2.propertyNames = props.map(function (p) { + return p.name; + }); + + // allow access of properties by name ( e.g. style.properties.height ) + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + props[prop.name] = prop; // allow lookup by name + } + + // map aliases + for (var _i2 = 0; _i2 < aliases.length; _i2++) { + var alias = aliases[_i2]; + var pointsToProp = props[alias.pointsTo]; + var aliasProp = { + name: alias.name, + alias: true, + pointsTo: pointsToProp + }; + + // add alias prop for parsing + props.push(aliasProp); + props[alias.name] = aliasProp; // allow lookup by name + } +})(); + +styfn$2.getDefaultProperty = function (name) { + return this.getDefaultProperties()[name]; +}; +styfn$2.getDefaultProperties = function () { + var _p = this._private; + if (_p.defaultProperties != null) { + return _p.defaultProperties; + } + var rawProps = extend({ + // core props + 'selection-box-color': '#ddd', + 'selection-box-opacity': 0.65, + 'selection-box-border-color': '#aaa', + 'selection-box-border-width': 1, + 'active-bg-color': 'black', + 'active-bg-opacity': 0.15, + 'active-bg-size': 30, + 'outside-texture-bg-color': '#000', + 'outside-texture-bg-opacity': 0.125, + // common node/edge props + 'events': 'yes', + 'text-events': 'no', + 'text-valign': 'top', + 'text-halign': 'center', + 'text-justification': 'auto', + 'line-height': 1, + 'color': '#000', + 'text-outline-color': '#000', + 'text-outline-width': 0, + 'text-outline-opacity': 1, + 'text-opacity': 1, + 'text-decoration': 'none', + 'text-transform': 'none', + 'text-wrap': 'none', + 'text-overflow-wrap': 'whitespace', + 'text-max-width': 9999, + 'text-background-color': '#000', + 'text-background-opacity': 0, + 'text-background-shape': 'rectangle', + 'text-background-padding': 0, + 'text-border-opacity': 0, + 'text-border-width': 0, + 'text-border-style': 'solid', + 'text-border-color': '#000', + 'font-family': 'Helvetica Neue, Helvetica, sans-serif', + 'font-style': 'normal', + 'font-weight': 'normal', + 'font-size': 16, + 'min-zoomed-font-size': 0, + 'text-rotation': 'none', + 'source-text-rotation': 'none', + 'target-text-rotation': 'none', + 'visibility': 'visible', + 'display': 'element', + 'opacity': 1, + 'z-compound-depth': 'auto', + 'z-index-compare': 'auto', + 'z-index': 0, + 'label': '', + 'text-margin-x': 0, + 'text-margin-y': 0, + 'source-label': '', + 'source-text-offset': 0, + 'source-text-margin-x': 0, + 'source-text-margin-y': 0, + 'target-label': '', + 'target-text-offset': 0, + 'target-text-margin-x': 0, + 'target-text-margin-y': 0, + 'overlay-opacity': 0, + 'overlay-color': '#000', + 'overlay-padding': 10, + 'overlay-shape': 'round-rectangle', + 'overlay-corner-radius': 'auto', + 'underlay-opacity': 0, + 'underlay-color': '#000', + 'underlay-padding': 10, + 'underlay-shape': 'round-rectangle', + 'underlay-corner-radius': 'auto', + 'transition-property': 'none', + 'transition-duration': 0, + 'transition-delay': 0, + 'transition-timing-function': 'linear', + // node props + 'background-blacken': 0, + 'background-color': '#999', + 'background-fill': 'solid', + 'background-opacity': 1, + 'background-image': 'none', + 'background-image-crossorigin': 'anonymous', + 'background-image-opacity': 1, + 'background-image-containment': 'inside', + 'background-image-smoothing': 'yes', + 'background-position-x': '50%', + 'background-position-y': '50%', + 'background-offset-x': 0, + 'background-offset-y': 0, + 'background-width-relative-to': 'include-padding', + 'background-height-relative-to': 'include-padding', + 'background-repeat': 'no-repeat', + 'background-fit': 'none', + 'background-clip': 'node', + 'background-width': 'auto', + 'background-height': 'auto', + 'border-color': '#000', + 'border-opacity': 1, + 'border-width': 0, + 'border-style': 'solid', + 'border-dash-pattern': [4, 2], + 'border-dash-offset': 0, + 'border-cap': 'butt', + 'border-join': 'miter', + 'border-position': 'center', + 'outline-color': '#999', + 'outline-opacity': 1, + 'outline-width': 0, + 'outline-offset': 0, + 'outline-style': 'solid', + 'height': 30, + 'width': 30, + 'shape': 'ellipse', + 'shape-polygon-points': '-1, -1, 1, -1, 1, 1, -1, 1', + 'corner-radius': 'auto', + 'bounds-expansion': 0, + // node gradient + 'background-gradient-direction': 'to-bottom', + 'background-gradient-stop-colors': '#999', + 'background-gradient-stop-positions': '0%', + // ghost props + 'ghost': 'no', + 'ghost-offset-y': 0, + 'ghost-offset-x': 0, + 'ghost-opacity': 0, + // compound props + 'padding': 0, + 'padding-relative-to': 'width', + 'position': 'origin', + 'compound-sizing-wrt-labels': 'include', + 'min-width': 0, + 'min-width-bias-left': 0, + 'min-width-bias-right': 0, + 'min-height': 0, + 'min-height-bias-top': 0, + 'min-height-bias-bottom': 0 + }, { + // node pie bg + 'pie-size': '100%' + }, [{ + name: 'pie-{{i}}-background-color', + value: 'black' + }, { + name: 'pie-{{i}}-background-size', + value: '0%' + }, { + name: 'pie-{{i}}-background-opacity', + value: 1 + }].reduce(function (css, prop) { + for (var i = 1; i <= styfn$2.pieBackgroundN; i++) { + var name = prop.name.replace('{{i}}', i); + var val = prop.value; + css[name] = val; + } + return css; + }, {}), { + // edge props + 'line-style': 'solid', + 'line-color': '#999', + 'line-fill': 'solid', + 'line-cap': 'butt', + 'line-opacity': 1, + 'line-gradient-stop-colors': '#999', + 'line-gradient-stop-positions': '0%', + 'control-point-step-size': 40, + 'control-point-weights': 0.5, + 'segment-weights': 0.5, + 'segment-distances': 20, + 'segment-radii': 15, + 'radius-type': 'arc-radius', + 'taxi-turn': '50%', + 'taxi-radius': 15, + 'taxi-turn-min-distance': 10, + 'taxi-direction': 'auto', + 'edge-distances': 'intersection', + 'curve-style': 'haystack', + 'haystack-radius': 0, + 'arrow-scale': 1, + 'loop-direction': '-45deg', + 'loop-sweep': '-90deg', + 'source-distance-from-node': 0, + 'target-distance-from-node': 0, + 'source-endpoint': 'outside-to-node', + 'target-endpoint': 'outside-to-node', + 'line-dash-pattern': [6, 3], + 'line-dash-offset': 0 + }, [{ + name: 'arrow-shape', + value: 'none' + }, { + name: 'arrow-color', + value: '#999' + }, { + name: 'arrow-fill', + value: 'filled' + }, { + name: 'arrow-width', + value: 1 + }].reduce(function (css, prop) { + styfn$2.arrowPrefixes.forEach(function (prefix) { + var name = prefix + '-' + prop.name; + var val = prop.value; + css[name] = val; + }); + return css; + }, {})); + var parsedProps = {}; + for (var i = 0; i < this.properties.length; i++) { + var prop = this.properties[i]; + if (prop.pointsTo) { + continue; + } + var name = prop.name; + var val = rawProps[name]; + var parsedProp = this.parse(name, val); + parsedProps[name] = parsedProp; + } + _p.defaultProperties = parsedProps; + return _p.defaultProperties; +}; +styfn$2.addDefaultStylesheet = function () { + this.selector(':parent').css({ + 'shape': 'rectangle', + 'padding': 10, + 'background-color': '#eee', + 'border-color': '#ccc', + 'border-width': 1 + }).selector('edge').css({ + 'width': 3 + }).selector(':loop').css({ + 'curve-style': 'bezier' + }).selector('edge:compound').css({ + 'curve-style': 'bezier', + 'source-endpoint': 'outside-to-line', + 'target-endpoint': 'outside-to-line' + }).selector(':selected').css({ + 'background-color': '#0169D9', + 'line-color': '#0169D9', + 'source-arrow-color': '#0169D9', + 'target-arrow-color': '#0169D9', + 'mid-source-arrow-color': '#0169D9', + 'mid-target-arrow-color': '#0169D9' + }).selector(':parent:selected').css({ + 'background-color': '#CCE1F9', + 'border-color': '#aec8e5' + }).selector(':active').css({ + 'overlay-color': 'black', + 'overlay-padding': 10, + 'overlay-opacity': 0.25 + }); + this.defaultLength = this.length; +}; + +var styfn$1 = {}; + +// a caching layer for property parsing +styfn$1.parse = function (name, value, propIsBypass, propIsFlat) { + var self = this; + + // function values can't be cached in all cases, and there isn't much benefit of caching them anyway + if (fn$6(value)) { + return self.parseImplWarn(name, value, propIsBypass, propIsFlat); + } + var flatKey = propIsFlat === 'mapping' || propIsFlat === true || propIsFlat === false || propIsFlat == null ? 'dontcare' : propIsFlat; + var bypassKey = propIsBypass ? 't' : 'f'; + var valueKey = '' + value; + var argHash = hashStrings(name, valueKey, bypassKey, flatKey); + var propCache = self.propCache = self.propCache || []; + var ret; + if (!(ret = propCache[argHash])) { + ret = propCache[argHash] = self.parseImplWarn(name, value, propIsBypass, propIsFlat); + } + + // - bypasses can't be shared b/c the value can be changed by animations or otherwise overridden + // - mappings can't be shared b/c mappings are per-element + if (propIsBypass || propIsFlat === 'mapping') { + // need a copy since props are mutated later in their lifecycles + ret = copy(ret); + if (ret) { + ret.value = copy(ret.value); // because it could be an array, e.g. colour + } + } + + return ret; +}; +styfn$1.parseImplWarn = function (name, value, propIsBypass, propIsFlat) { + var prop = this.parseImpl(name, value, propIsBypass, propIsFlat); + if (!prop && value != null) { + warn("The style property `".concat(name, ": ").concat(value, "` is invalid")); + } + if (prop && (prop.name === 'width' || prop.name === 'height') && value === 'label') { + warn('The style value of `label` is deprecated for `' + prop.name + '`'); + } + return prop; +}; + +// parse a property; return null on invalid; return parsed property otherwise +// fields : +// - name : the name of the property +// - value : the parsed, native-typed value of the property +// - strValue : a string value that represents the property value in valid css +// - bypass : true iff the property is a bypass property +styfn$1.parseImpl = function (name, value, propIsBypass, propIsFlat) { + var self = this; + name = camel2dash(name); // make sure the property name is in dash form (e.g. 'property-name' not 'propertyName') + + var property = self.properties[name]; + var passedValue = value; + var types = self.types; + if (!property) { + return null; + } // return null on property of unknown name + if (value === undefined) { + return null; + } // can't assign undefined + + // the property may be an alias + if (property.alias) { + property = property.pointsTo; + name = property.name; + } + var valueIsString = string(value); + if (valueIsString) { + // trim the value to make parsing easier + value = value.trim(); + } + var type = property.type; + if (!type) { + return null; + } // no type, no luck + + // check if bypass is null or empty string (i.e. indication to delete bypass property) + if (propIsBypass && (value === '' || value === null)) { + return { + name: name, + value: value, + bypass: true, + deleteBypass: true + }; + } + + // check if value is a function used as a mapper + if (fn$6(value)) { + return { + name: name, + value: value, + strValue: 'fn', + mapped: types.fn, + bypass: propIsBypass + }; + } + + // check if value is mapped + var data, mapData; + if (!valueIsString || propIsFlat || value.length < 7 || value[1] !== 'a') ; else if (value.length >= 7 && value[0] === 'd' && (data = new RegExp(types.data.regex).exec(value))) { + if (propIsBypass) { + return false; + } // mappers not allowed in bypass + + var mapped = types.data; + return { + name: name, + value: data, + strValue: '' + value, + mapped: mapped, + field: data[1], + bypass: propIsBypass + }; + } else if (value.length >= 10 && value[0] === 'm' && (mapData = new RegExp(types.mapData.regex).exec(value))) { + if (propIsBypass) { + return false; + } // mappers not allowed in bypass + if (type.multiple) { + return false; + } // impossible to map to num + + var _mapped = types.mapData; + + // we can map only if the type is a colour or a number + if (!(type.color || type.number)) { + return false; + } + var valueMin = this.parse(name, mapData[4]); // parse to validate + if (!valueMin || valueMin.mapped) { + return false; + } // can't be invalid or mapped + + var valueMax = this.parse(name, mapData[5]); // parse to validate + if (!valueMax || valueMax.mapped) { + return false; + } // can't be invalid or mapped + + // check if valueMin and valueMax are the same + if (valueMin.pfValue === valueMax.pfValue || valueMin.strValue === valueMax.strValue) { + warn('`' + name + ': ' + value + '` is not a valid mapper because the output range is zero; converting to `' + name + ': ' + valueMin.strValue + '`'); + return this.parse(name, valueMin.strValue); // can't make much of a mapper without a range + } else if (type.color) { + var c1 = valueMin.value; + var c2 = valueMax.value; + var same = c1[0] === c2[0] // red + && c1[1] === c2[1] // green + && c1[2] === c2[2] // blue + && ( + // optional alpha + c1[3] === c2[3] // same alpha outright + || (c1[3] == null || c1[3] === 1 // full opacity for colour 1? + ) && (c2[3] == null || c2[3] === 1) // full opacity for colour 2? + ); + + if (same) { + return false; + } // can't make a mapper without a range + } + + return { + name: name, + value: mapData, + strValue: '' + value, + mapped: _mapped, + field: mapData[1], + fieldMin: parseFloat(mapData[2]), + // min & max are numeric + fieldMax: parseFloat(mapData[3]), + valueMin: valueMin.value, + valueMax: valueMax.value, + bypass: propIsBypass + }; + } + if (type.multiple && propIsFlat !== 'multiple') { + var vals; + if (valueIsString) { + vals = value.split(/\s+/); + } else if (array(value)) { + vals = value; + } else { + vals = [value]; + } + if (type.evenMultiple && vals.length % 2 !== 0) { + return null; + } + var valArr = []; + var unitsArr = []; + var pfValArr = []; + var strVal = ''; + var hasEnum = false; + for (var i = 0; i < vals.length; i++) { + var p = self.parse(name, vals[i], propIsBypass, 'multiple'); + hasEnum = hasEnum || string(p.value); + valArr.push(p.value); + pfValArr.push(p.pfValue != null ? p.pfValue : p.value); + unitsArr.push(p.units); + strVal += (i > 0 ? ' ' : '') + p.strValue; + } + if (type.validate && !type.validate(valArr, unitsArr)) { + return null; + } + if (type.singleEnum && hasEnum) { + if (valArr.length === 1 && string(valArr[0])) { + return { + name: name, + value: valArr[0], + strValue: valArr[0], + bypass: propIsBypass + }; + } else { + return null; + } + } + return { + name: name, + value: valArr, + pfValue: pfValArr, + strValue: strVal, + bypass: propIsBypass, + units: unitsArr + }; + } + + // several types also allow enums + var checkEnums = function checkEnums() { + for (var _i = 0; _i < type.enums.length; _i++) { + var en = type.enums[_i]; + if (en === value) { + return { + name: name, + value: value, + strValue: '' + value, + bypass: propIsBypass + }; + } + } + return null; + }; + + // check the type and return the appropriate object + if (type.number) { + var units; + var implicitUnits = 'px'; // not set => px + + if (type.units) { + // use specified units if set + units = type.units; + } + if (type.implicitUnits) { + implicitUnits = type.implicitUnits; + } + if (!type.unitless) { + if (valueIsString) { + var unitsRegex = 'px|em' + (type.allowPercent ? '|\\%' : ''); + if (units) { + unitsRegex = units; + } // only allow explicit units if so set + var match = value.match('^(' + number + ')(' + unitsRegex + ')?' + '$'); + if (match) { + value = match[1]; + units = match[2] || implicitUnits; + } + } else if (!units || type.implicitUnits) { + units = implicitUnits; // implicitly px if unspecified + } + } + + value = parseFloat(value); + + // if not a number and enums not allowed, then the value is invalid + if (isNaN(value) && type.enums === undefined) { + return null; + } + + // check if this number type also accepts special keywords in place of numbers + // (i.e. `left`, `auto`, etc) + if (isNaN(value) && type.enums !== undefined) { + value = passedValue; + return checkEnums(); + } + + // check if value must be an integer + if (type.integer && !integer(value)) { + return null; + } + + // check value is within range + if (type.min !== undefined && (value < type.min || type.strictMin && value === type.min) || type.max !== undefined && (value > type.max || type.strictMax && value === type.max)) { + return null; + } + var ret = { + name: name, + value: value, + strValue: '' + value + (units ? units : ''), + units: units, + bypass: propIsBypass + }; + + // normalise value in pixels + if (type.unitless || units !== 'px' && units !== 'em') { + ret.pfValue = value; + } else { + ret.pfValue = units === 'px' || !units ? value : this.getEmSizeInPixels() * value; + } + + // normalise value in ms + if (units === 'ms' || units === 's') { + ret.pfValue = units === 'ms' ? value : 1000 * value; + } + + // normalise value in rad + if (units === 'deg' || units === 'rad') { + ret.pfValue = units === 'rad' ? value : deg2rad(value); + } + + // normalize value in % + if (units === '%') { + ret.pfValue = value / 100; + } + return ret; + } else if (type.propList) { + var props = []; + var propsStr = '' + value; + if (propsStr === 'none') ; else { + // go over each prop + + var propsSplit = propsStr.split(/\s*,\s*|\s+/); + for (var _i2 = 0; _i2 < propsSplit.length; _i2++) { + var propName = propsSplit[_i2].trim(); + if (self.properties[propName]) { + props.push(propName); + } else { + warn('`' + propName + '` is not a valid property name'); + } + } + if (props.length === 0) { + return null; + } + } + return { + name: name, + value: props, + strValue: props.length === 0 ? 'none' : props.join(' '), + bypass: propIsBypass + }; + } else if (type.color) { + var tuple = color2tuple(value); + if (!tuple) { + return null; + } + return { + name: name, + value: tuple, + pfValue: tuple, + strValue: 'rgb(' + tuple[0] + ',' + tuple[1] + ',' + tuple[2] + ')', + // n.b. no spaces b/c of multiple support + bypass: propIsBypass + }; + } else if (type.regex || type.regexes) { + // first check enums + if (type.enums) { + var enumProp = checkEnums(); + if (enumProp) { + return enumProp; + } + } + var regexes = type.regexes ? type.regexes : [type.regex]; + for (var _i3 = 0; _i3 < regexes.length; _i3++) { + var regex = new RegExp(regexes[_i3]); // make a regex from the type string + var m = regex.exec(value); + if (m) { + // regex matches + return { + name: name, + value: type.singleRegexMatchValue ? m[1] : m, + strValue: '' + value, + bypass: propIsBypass + }; + } + } + return null; // didn't match any + } else if (type.string) { + // just return + return { + name: name, + value: '' + value, + strValue: '' + value, + bypass: propIsBypass + }; + } else if (type.enums) { + // check enums last because it's a combo type in others + return checkEnums(); + } else { + return null; // not a type we can handle + } +}; + +var Style = function Style(cy) { + if (!(this instanceof Style)) { + return new Style(cy); + } + if (!core(cy)) { + error('A style must have a core reference'); + return; + } + this._private = { + cy: cy, + coreStyle: {} + }; + this.length = 0; + this.resetToDefault(); +}; +var styfn = Style.prototype; +styfn.instanceString = function () { + return 'style'; +}; + +// remove all contexts +styfn.clear = function () { + var _p = this._private; + var cy = _p.cy; + var eles = cy.elements(); + for (var i = 0; i < this.length; i++) { + this[i] = undefined; + } + this.length = 0; + _p.contextStyles = {}; + _p.propDiffs = {}; + this.cleanElements(eles, true); + eles.forEach(function (ele) { + var ele_p = ele[0]._private; + ele_p.styleDirty = true; + ele_p.appliedInitStyle = false; + }); + return this; // chaining +}; + +styfn.resetToDefault = function () { + this.clear(); + this.addDefaultStylesheet(); + return this; +}; + +// builds a style object for the 'core' selector +styfn.core = function (propName) { + return this._private.coreStyle[propName] || this.getDefaultProperty(propName); +}; + +// create a new context from the specified selector string and switch to that context +styfn.selector = function (selectorStr) { + // 'core' is a special case and does not need a selector + var selector = selectorStr === 'core' ? null : new Selector(selectorStr); + var i = this.length++; // new context means new index + this[i] = { + selector: selector, + properties: [], + mappedProperties: [], + index: i + }; + return this; // chaining +}; + +// add one or many css rules to the current context +styfn.css = function () { + var self = this; + var args = arguments; + if (args.length === 1) { + var map = args[0]; + for (var i = 0; i < self.properties.length; i++) { + var prop = self.properties[i]; + var mapVal = map[prop.name]; + if (mapVal === undefined) { + mapVal = map[dash2camel(prop.name)]; + } + if (mapVal !== undefined) { + this.cssRule(prop.name, mapVal); + } + } + } else if (args.length === 2) { + this.cssRule(args[0], args[1]); + } + + // do nothing if args are invalid + + return this; // chaining +}; + +styfn.style = styfn.css; + +// add a single css rule to the current context +styfn.cssRule = function (name, value) { + // name-value pair + var property = this.parse(name, value); + + // add property to current context if valid + if (property) { + var i = this.length - 1; + this[i].properties.push(property); + this[i].properties[property.name] = property; // allow access by name as well + + if (property.name.match(/pie-(\d+)-background-size/) && property.value) { + this._private.hasPie = true; + } + if (property.mapped) { + this[i].mappedProperties.push(property); + } + + // add to core style if necessary + var currentSelectorIsCore = !this[i].selector; + if (currentSelectorIsCore) { + this._private.coreStyle[property.name] = property; + } + } + return this; // chaining +}; + +styfn.append = function (style) { + if (stylesheet(style)) { + style.appendToStyle(this); + } else if (array(style)) { + this.appendFromJson(style); + } else if (string(style)) { + this.appendFromString(style); + } // you probably wouldn't want to append a Style, since you'd duplicate the default parts + + return this; +}; + +// static function +Style.fromJson = function (cy, json) { + var style = new Style(cy); + style.fromJson(json); + return style; +}; +Style.fromString = function (cy, string) { + return new Style(cy).fromString(string); +}; +[styfn$8, styfn$7, styfn$6, styfn$5, styfn$4, styfn$3, styfn$2, styfn$1].forEach(function (props) { + extend(styfn, props); +}); +Style.types = styfn.types; +Style.properties = styfn.properties; +Style.propertyGroups = styfn.propertyGroups; +Style.propertyGroupNames = styfn.propertyGroupNames; +Style.propertyGroupKeys = styfn.propertyGroupKeys; + +var corefn$2 = { + style: function style(newStyle) { + if (newStyle) { + var s = this.setStyle(newStyle); + s.update(); + } + return this._private.style; + }, + setStyle: function setStyle(style) { + var _p = this._private; + if (stylesheet(style)) { + _p.style = style.generateStyle(this); + } else if (array(style)) { + _p.style = Style.fromJson(this, style); + } else if (string(style)) { + _p.style = Style.fromString(this, style); + } else { + _p.style = Style(this); + } + return _p.style; + }, + // e.g. cy.data() changed => recalc ele mappers + updateStyle: function updateStyle() { + this.mutableElements().updateStyle(); // just send to all eles + } +}; + +var defaultSelectionType = 'single'; +var corefn$1 = { + autolock: function autolock(bool) { + if (bool !== undefined) { + this._private.autolock = bool ? true : false; + } else { + return this._private.autolock; + } + return this; // chaining + }, + + autoungrabify: function autoungrabify(bool) { + if (bool !== undefined) { + this._private.autoungrabify = bool ? true : false; + } else { + return this._private.autoungrabify; + } + return this; // chaining + }, + + autounselectify: function autounselectify(bool) { + if (bool !== undefined) { + this._private.autounselectify = bool ? true : false; + } else { + return this._private.autounselectify; + } + return this; // chaining + }, + + selectionType: function selectionType(selType) { + var _p = this._private; + if (_p.selectionType == null) { + _p.selectionType = defaultSelectionType; + } + if (selType !== undefined) { + if (selType === 'additive' || selType === 'single') { + _p.selectionType = selType; + } + } else { + return _p.selectionType; + } + return this; + }, + panningEnabled: function panningEnabled(bool) { + if (bool !== undefined) { + this._private.panningEnabled = bool ? true : false; + } else { + return this._private.panningEnabled; + } + return this; // chaining + }, + + userPanningEnabled: function userPanningEnabled(bool) { + if (bool !== undefined) { + this._private.userPanningEnabled = bool ? true : false; + } else { + return this._private.userPanningEnabled; + } + return this; // chaining + }, + + zoomingEnabled: function zoomingEnabled(bool) { + if (bool !== undefined) { + this._private.zoomingEnabled = bool ? true : false; + } else { + return this._private.zoomingEnabled; + } + return this; // chaining + }, + + userZoomingEnabled: function userZoomingEnabled(bool) { + if (bool !== undefined) { + this._private.userZoomingEnabled = bool ? true : false; + } else { + return this._private.userZoomingEnabled; + } + return this; // chaining + }, + + boxSelectionEnabled: function boxSelectionEnabled(bool) { + if (bool !== undefined) { + this._private.boxSelectionEnabled = bool ? true : false; + } else { + return this._private.boxSelectionEnabled; + } + return this; // chaining + }, + + pan: function pan() { + var args = arguments; + var pan = this._private.pan; + var dim, val, dims, x, y; + switch (args.length) { + case 0: + // .pan() + return pan; + case 1: + if (string(args[0])) { + // .pan('x') + dim = args[0]; + return pan[dim]; + } else if (plainObject(args[0])) { + // .pan({ x: 0, y: 100 }) + if (!this._private.panningEnabled) { + return this; + } + dims = args[0]; + x = dims.x; + y = dims.y; + if (number$1(x)) { + pan.x = x; + } + if (number$1(y)) { + pan.y = y; + } + this.emit('pan viewport'); + } + break; + case 2: + // .pan('x', 100) + if (!this._private.panningEnabled) { + return this; + } + dim = args[0]; + val = args[1]; + if ((dim === 'x' || dim === 'y') && number$1(val)) { + pan[dim] = val; + } + this.emit('pan viewport'); + break; + // invalid + } + + this.notify('viewport'); + return this; // chaining + }, + + panBy: function panBy(arg0, arg1) { + var args = arguments; + var pan = this._private.pan; + var dim, val, dims, x, y; + if (!this._private.panningEnabled) { + return this; + } + switch (args.length) { + case 1: + if (plainObject(arg0)) { + // .panBy({ x: 0, y: 100 }) + dims = args[0]; + x = dims.x; + y = dims.y; + if (number$1(x)) { + pan.x += x; + } + if (number$1(y)) { + pan.y += y; + } + this.emit('pan viewport'); + } + break; + case 2: + // .panBy('x', 100) + dim = arg0; + val = arg1; + if ((dim === 'x' || dim === 'y') && number$1(val)) { + pan[dim] += val; + } + this.emit('pan viewport'); + break; + // invalid + } + + this.notify('viewport'); + return this; // chaining + }, + + fit: function fit(elements, padding) { + var viewportState = this.getFitViewport(elements, padding); + if (viewportState) { + var _p = this._private; + _p.zoom = viewportState.zoom; + _p.pan = viewportState.pan; + this.emit('pan zoom viewport'); + this.notify('viewport'); + } + return this; // chaining + }, + + getFitViewport: function getFitViewport(elements, padding) { + if (number$1(elements) && padding === undefined) { + // elements is optional + padding = elements; + elements = undefined; + } + if (!this._private.panningEnabled || !this._private.zoomingEnabled) { + return; + } + var bb; + if (string(elements)) { + var sel = elements; + elements = this.$(sel); + } else if (boundingBox(elements)) { + // assume bb + var bbe = elements; + bb = { + x1: bbe.x1, + y1: bbe.y1, + x2: bbe.x2, + y2: bbe.y2 + }; + bb.w = bb.x2 - bb.x1; + bb.h = bb.y2 - bb.y1; + } else if (!elementOrCollection(elements)) { + elements = this.mutableElements(); + } + if (elementOrCollection(elements) && elements.empty()) { + return; + } // can't fit to nothing + + bb = bb || elements.boundingBox(); + var w = this.width(); + var h = this.height(); + var zoom; + padding = number$1(padding) ? padding : 0; + if (!isNaN(w) && !isNaN(h) && w > 0 && h > 0 && !isNaN(bb.w) && !isNaN(bb.h) && bb.w > 0 && bb.h > 0) { + zoom = Math.min((w - 2 * padding) / bb.w, (h - 2 * padding) / bb.h); + + // crop zoom + zoom = zoom > this._private.maxZoom ? this._private.maxZoom : zoom; + zoom = zoom < this._private.minZoom ? this._private.minZoom : zoom; + var pan = { + // now pan to middle + x: (w - zoom * (bb.x1 + bb.x2)) / 2, + y: (h - zoom * (bb.y1 + bb.y2)) / 2 + }; + return { + zoom: zoom, + pan: pan + }; + } + return; + }, + zoomRange: function zoomRange(min, max) { + var _p = this._private; + if (max == null) { + var opts = min; + min = opts.min; + max = opts.max; + } + if (number$1(min) && number$1(max) && min <= max) { + _p.minZoom = min; + _p.maxZoom = max; + } else if (number$1(min) && max === undefined && min <= _p.maxZoom) { + _p.minZoom = min; + } else if (number$1(max) && min === undefined && max >= _p.minZoom) { + _p.maxZoom = max; + } + return this; + }, + minZoom: function minZoom(zoom) { + if (zoom === undefined) { + return this._private.minZoom; + } else { + return this.zoomRange({ + min: zoom + }); + } + }, + maxZoom: function maxZoom(zoom) { + if (zoom === undefined) { + return this._private.maxZoom; + } else { + return this.zoomRange({ + max: zoom + }); + } + }, + getZoomedViewport: function getZoomedViewport(params) { + var _p = this._private; + var currentPan = _p.pan; + var currentZoom = _p.zoom; + var pos; // in rendered px + var zoom; + var bail = false; + if (!_p.zoomingEnabled) { + // zooming disabled + bail = true; + } + if (number$1(params)) { + // then set the zoom + zoom = params; + } else if (plainObject(params)) { + // then zoom about a point + zoom = params.level; + if (params.position != null) { + pos = modelToRenderedPosition(params.position, currentZoom, currentPan); + } else if (params.renderedPosition != null) { + pos = params.renderedPosition; + } + if (pos != null && !_p.panningEnabled) { + // panning disabled + bail = true; + } + } + + // crop zoom + zoom = zoom > _p.maxZoom ? _p.maxZoom : zoom; + zoom = zoom < _p.minZoom ? _p.minZoom : zoom; + + // can't zoom with invalid params + if (bail || !number$1(zoom) || zoom === currentZoom || pos != null && (!number$1(pos.x) || !number$1(pos.y))) { + return null; + } + if (pos != null) { + // set zoom about position + var pan1 = currentPan; + var zoom1 = currentZoom; + var zoom2 = zoom; + var pan2 = { + x: -zoom2 / zoom1 * (pos.x - pan1.x) + pos.x, + y: -zoom2 / zoom1 * (pos.y - pan1.y) + pos.y + }; + return { + zoomed: true, + panned: true, + zoom: zoom2, + pan: pan2 + }; + } else { + // just set the zoom + return { + zoomed: true, + panned: false, + zoom: zoom, + pan: currentPan + }; + } + }, + zoom: function zoom(params) { + if (params === undefined) { + // get + return this._private.zoom; + } else { + // set + var vp = this.getZoomedViewport(params); + var _p = this._private; + if (vp == null || !vp.zoomed) { + return this; + } + _p.zoom = vp.zoom; + if (vp.panned) { + _p.pan.x = vp.pan.x; + _p.pan.y = vp.pan.y; + } + this.emit('zoom' + (vp.panned ? ' pan' : '') + ' viewport'); + this.notify('viewport'); + return this; // chaining + } + }, + + viewport: function viewport(opts) { + var _p = this._private; + var zoomDefd = true; + var panDefd = true; + var events = []; // to trigger + var zoomFailed = false; + var panFailed = false; + if (!opts) { + return this; + } + if (!number$1(opts.zoom)) { + zoomDefd = false; + } + if (!plainObject(opts.pan)) { + panDefd = false; + } + if (!zoomDefd && !panDefd) { + return this; + } + if (zoomDefd) { + var z = opts.zoom; + if (z < _p.minZoom || z > _p.maxZoom || !_p.zoomingEnabled) { + zoomFailed = true; + } else { + _p.zoom = z; + events.push('zoom'); + } + } + if (panDefd && (!zoomFailed || !opts.cancelOnFailedZoom) && _p.panningEnabled) { + var p = opts.pan; + if (number$1(p.x)) { + _p.pan.x = p.x; + panFailed = false; + } + if (number$1(p.y)) { + _p.pan.y = p.y; + panFailed = false; + } + if (!panFailed) { + events.push('pan'); + } + } + if (events.length > 0) { + events.push('viewport'); + this.emit(events.join(' ')); + this.notify('viewport'); + } + return this; // chaining + }, + + center: function center(elements) { + var pan = this.getCenterPan(elements); + if (pan) { + this._private.pan = pan; + this.emit('pan viewport'); + this.notify('viewport'); + } + return this; // chaining + }, + + getCenterPan: function getCenterPan(elements, zoom) { + if (!this._private.panningEnabled) { + return; + } + if (string(elements)) { + var selector = elements; + elements = this.mutableElements().filter(selector); + } else if (!elementOrCollection(elements)) { + elements = this.mutableElements(); + } + if (elements.length === 0) { + return; + } // can't centre pan to nothing + + var bb = elements.boundingBox(); + var w = this.width(); + var h = this.height(); + zoom = zoom === undefined ? this._private.zoom : zoom; + var pan = { + // middle + x: (w - zoom * (bb.x1 + bb.x2)) / 2, + y: (h - zoom * (bb.y1 + bb.y2)) / 2 + }; + return pan; + }, + reset: function reset() { + if (!this._private.panningEnabled || !this._private.zoomingEnabled) { + return this; + } + this.viewport({ + pan: { + x: 0, + y: 0 + }, + zoom: 1 + }); + return this; // chaining + }, + + invalidateSize: function invalidateSize() { + this._private.sizeCache = null; + }, + size: function size() { + var _p = this._private; + var container = _p.container; + var cy = this; + return _p.sizeCache = _p.sizeCache || (container ? function () { + var style = cy.window().getComputedStyle(container); + var val = function val(name) { + return parseFloat(style.getPropertyValue(name)); + }; + return { + width: container.clientWidth - val('padding-left') - val('padding-right'), + height: container.clientHeight - val('padding-top') - val('padding-bottom') + }; + }() : { + // fallback if no container (not 0 b/c can be used for dividing etc) + width: 1, + height: 1 + }); + }, + width: function width() { + return this.size().width; + }, + height: function height() { + return this.size().height; + }, + extent: function extent() { + var pan = this._private.pan; + var zoom = this._private.zoom; + var rb = this.renderedExtent(); + var b = { + x1: (rb.x1 - pan.x) / zoom, + x2: (rb.x2 - pan.x) / zoom, + y1: (rb.y1 - pan.y) / zoom, + y2: (rb.y2 - pan.y) / zoom + }; + b.w = b.x2 - b.x1; + b.h = b.y2 - b.y1; + return b; + }, + renderedExtent: function renderedExtent() { + var width = this.width(); + var height = this.height(); + return { + x1: 0, + y1: 0, + x2: width, + y2: height, + w: width, + h: height + }; + }, + multiClickDebounceTime: function multiClickDebounceTime(_int) { + if (_int) this._private.multiClickDebounceTime = _int;else return this._private.multiClickDebounceTime; + return this; // chaining + } +}; + +// aliases +corefn$1.centre = corefn$1.center; + +// backwards compatibility +corefn$1.autolockNodes = corefn$1.autolock; +corefn$1.autoungrabifyNodes = corefn$1.autoungrabify; + +var fn = { + data: define.data({ + field: 'data', + bindingEvent: 'data', + allowBinding: true, + allowSetting: true, + settingEvent: 'data', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeData: define.removeData({ + field: 'data', + event: 'data', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }), + scratch: define.data({ + field: 'scratch', + bindingEvent: 'scratch', + allowBinding: true, + allowSetting: true, + settingEvent: 'scratch', + settingTriggersEvent: true, + triggerFnName: 'trigger', + allowGetting: true, + updateStyle: true + }), + removeScratch: define.removeData({ + field: 'scratch', + event: 'scratch', + triggerFnName: 'trigger', + triggerEvent: true, + updateStyle: true + }) +}; + +// aliases +fn.attr = fn.data; +fn.removeAttr = fn.removeData; + +var Core = function Core(opts) { + var cy = this; + opts = extend({}, opts); + var container = opts.container; + + // allow for passing a wrapped jquery object + // e.g. cytoscape({ container: $('#cy') }) + if (container && !htmlElement(container) && htmlElement(container[0])) { + container = container[0]; + } + var reg = container ? container._cyreg : null; // e.g. already registered some info (e.g. readies) via jquery + reg = reg || {}; + if (reg && reg.cy) { + reg.cy.destroy(); + reg = {}; // old instance => replace reg completely + } + + var readies = reg.readies = reg.readies || []; + if (container) { + container._cyreg = reg; + } // make sure container assoc'd reg points to this cy + reg.cy = cy; + var head = _window !== undefined && container !== undefined && !opts.headless; + var options = opts; + options.layout = extend({ + name: head ? 'grid' : 'null' + }, options.layout); + options.renderer = extend({ + name: head ? 'canvas' : 'null' + }, options.renderer); + var defVal = function defVal(def, val, altVal) { + if (val !== undefined) { + return val; + } else if (altVal !== undefined) { + return altVal; + } else { + return def; + } + }; + var _p = this._private = { + container: container, + // html dom ele container + ready: false, + // whether ready has been triggered + options: options, + // cached options + elements: new Collection(this), + // elements in the graph + listeners: [], + // list of listeners + aniEles: new Collection(this), + // elements being animated + data: options.data || {}, + // data for the core + scratch: {}, + // scratch object for core + layout: null, + renderer: null, + destroyed: false, + // whether destroy was called + notificationsEnabled: true, + // whether notifications are sent to the renderer + minZoom: 1e-50, + maxZoom: 1e50, + zoomingEnabled: defVal(true, options.zoomingEnabled), + userZoomingEnabled: defVal(true, options.userZoomingEnabled), + panningEnabled: defVal(true, options.panningEnabled), + userPanningEnabled: defVal(true, options.userPanningEnabled), + boxSelectionEnabled: defVal(true, options.boxSelectionEnabled), + autolock: defVal(false, options.autolock, options.autolockNodes), + autoungrabify: defVal(false, options.autoungrabify, options.autoungrabifyNodes), + autounselectify: defVal(false, options.autounselectify), + styleEnabled: options.styleEnabled === undefined ? head : options.styleEnabled, + zoom: number$1(options.zoom) ? options.zoom : 1, + pan: { + x: plainObject(options.pan) && number$1(options.pan.x) ? options.pan.x : 0, + y: plainObject(options.pan) && number$1(options.pan.y) ? options.pan.y : 0 + }, + animation: { + // object for currently-running animations + current: [], + queue: [] + }, + hasCompoundNodes: false, + multiClickDebounceTime: defVal(250, options.multiClickDebounceTime) + }; + this.createEmitter(); + + // set selection type + this.selectionType(options.selectionType); + + // init zoom bounds + this.zoomRange({ + min: options.minZoom, + max: options.maxZoom + }); + var loadExtData = function loadExtData(extData, next) { + var anyIsPromise = extData.some(promise); + if (anyIsPromise) { + return Promise$1.all(extData).then(next); // load all data asynchronously, then exec rest of init + } else { + next(extData); // exec synchronously for convenience + } + }; + + // start with the default stylesheet so we have something before loading an external stylesheet + if (_p.styleEnabled) { + cy.setStyle([]); + } + + // create the renderer + var rendererOptions = extend({}, options, options.renderer); // allow rendering hints in top level options + cy.initRenderer(rendererOptions); + var setElesAndLayout = function setElesAndLayout(elements, onload, ondone) { + cy.notifications(false); + + // remove old elements + var oldEles = cy.mutableElements(); + if (oldEles.length > 0) { + oldEles.remove(); + } + if (elements != null) { + if (plainObject(elements) || array(elements)) { + cy.add(elements); + } + } + cy.one('layoutready', function (e) { + cy.notifications(true); + cy.emit(e); // we missed this event by turning notifications off, so pass it on + + cy.one('load', onload); + cy.emitAndNotify('load'); + }).one('layoutstop', function () { + cy.one('done', ondone); + cy.emit('done'); + }); + var layoutOpts = extend({}, cy._private.options.layout); + layoutOpts.eles = cy.elements(); + cy.layout(layoutOpts).run(); + }; + loadExtData([options.style, options.elements], function (thens) { + var initStyle = thens[0]; + var initEles = thens[1]; + + // init style + if (_p.styleEnabled) { + cy.style().append(initStyle); + } + + // initial load + setElesAndLayout(initEles, function () { + // onready + cy.startAnimationLoop(); + _p.ready = true; + + // if a ready callback is specified as an option, the bind it + if (fn$6(options.ready)) { + cy.on('ready', options.ready); + } + + // bind all the ready handlers registered before creating this instance + for (var i = 0; i < readies.length; i++) { + var fn = readies[i]; + cy.on('ready', fn); + } + if (reg) { + reg.readies = []; + } // clear b/c we've bound them all and don't want to keep it around in case a new core uses the same div etc + + cy.emit('ready'); + }, options.done); + }); +}; +var corefn = Core.prototype; // short alias + +extend(corefn, { + instanceString: function instanceString() { + return 'core'; + }, + isReady: function isReady() { + return this._private.ready; + }, + destroyed: function destroyed() { + return this._private.destroyed; + }, + ready: function ready(fn) { + if (this.isReady()) { + this.emitter().emit('ready', [], fn); // just calls fn as though triggered via ready event + } else { + this.on('ready', fn); + } + return this; + }, + destroy: function destroy() { + var cy = this; + if (cy.destroyed()) return; + cy.stopAnimationLoop(); + cy.destroyRenderer(); + this.emit('destroy'); + cy._private.destroyed = true; + return cy; + }, + hasElementWithId: function hasElementWithId(id) { + return this._private.elements.hasElementWithId(id); + }, + getElementById: function getElementById(id) { + return this._private.elements.getElementById(id); + }, + hasCompoundNodes: function hasCompoundNodes() { + return this._private.hasCompoundNodes; + }, + headless: function headless() { + return this._private.renderer.isHeadless(); + }, + styleEnabled: function styleEnabled() { + return this._private.styleEnabled; + }, + addToPool: function addToPool(eles) { + this._private.elements.merge(eles); + return this; // chaining + }, + + removeFromPool: function removeFromPool(eles) { + this._private.elements.unmerge(eles); + return this; + }, + container: function container() { + return this._private.container || null; + }, + window: function window() { + var container = this._private.container; + if (container == null) return _window; + var ownerDocument = this._private.container.ownerDocument; + if (ownerDocument === undefined || ownerDocument == null) { + return _window; + } + return ownerDocument.defaultView || _window; + }, + mount: function mount(container) { + if (container == null) { + return; + } + var cy = this; + var _p = cy._private; + var options = _p.options; + if (!htmlElement(container) && htmlElement(container[0])) { + container = container[0]; + } + cy.stopAnimationLoop(); + cy.destroyRenderer(); + _p.container = container; + _p.styleEnabled = true; + cy.invalidateSize(); + cy.initRenderer(extend({}, options, options.renderer, { + // allow custom renderer name to be re-used, otherwise use canvas + name: options.renderer.name === 'null' ? 'canvas' : options.renderer.name + })); + cy.startAnimationLoop(); + cy.style(options.style); + cy.emit('mount'); + return cy; + }, + unmount: function unmount() { + var cy = this; + cy.stopAnimationLoop(); + cy.destroyRenderer(); + cy.initRenderer({ + name: 'null' + }); + cy.emit('unmount'); + return cy; + }, + options: function options() { + return copy(this._private.options); + }, + json: function json(obj) { + var cy = this; + var _p = cy._private; + var eles = cy.mutableElements(); + var getFreshRef = function getFreshRef(ele) { + return cy.getElementById(ele.id()); + }; + if (plainObject(obj)) { + // set + + cy.startBatch(); + if (obj.elements) { + var idInJson = {}; + var updateEles = function updateEles(jsons, gr) { + var toAdd = []; + var toMod = []; + for (var i = 0; i < jsons.length; i++) { + var json = jsons[i]; + if (!json.data.id) { + warn('cy.json() cannot handle elements without an ID attribute'); + continue; + } + var id = '' + json.data.id; // id must be string + var ele = cy.getElementById(id); + idInJson[id] = true; + if (ele.length !== 0) { + // existing element should be updated + toMod.push({ + ele: ele, + json: json + }); + } else { + // otherwise should be added + if (gr) { + json.group = gr; + toAdd.push(json); + } else { + toAdd.push(json); + } + } + } + cy.add(toAdd); + for (var _i = 0; _i < toMod.length; _i++) { + var _toMod$_i = toMod[_i], + _ele = _toMod$_i.ele, + _json = _toMod$_i.json; + _ele.json(_json); + } + }; + if (array(obj.elements)) { + // elements: [] + updateEles(obj.elements); + } else { + // elements: { nodes: [], edges: [] } + var grs = ['nodes', 'edges']; + for (var i = 0; i < grs.length; i++) { + var gr = grs[i]; + var elements = obj.elements[gr]; + if (array(elements)) { + updateEles(elements, gr); + } + } + } + var parentsToRemove = cy.collection(); + eles.filter(function (ele) { + return !idInJson[ele.id()]; + }).forEach(function (ele) { + if (ele.isParent()) { + parentsToRemove.merge(ele); + } else { + ele.remove(); + } + }); + + // so that children are not removed w/parent + parentsToRemove.forEach(function (ele) { + return ele.children().move({ + parent: null + }); + }); + + // intermediate parents may be moved by prior line, so make sure we remove by fresh refs + parentsToRemove.forEach(function (ele) { + return getFreshRef(ele).remove(); + }); + } + if (obj.style) { + cy.style(obj.style); + } + if (obj.zoom != null && obj.zoom !== _p.zoom) { + cy.zoom(obj.zoom); + } + if (obj.pan) { + if (obj.pan.x !== _p.pan.x || obj.pan.y !== _p.pan.y) { + cy.pan(obj.pan); + } + } + if (obj.data) { + cy.data(obj.data); + } + var fields = ['minZoom', 'maxZoom', 'zoomingEnabled', 'userZoomingEnabled', 'panningEnabled', 'userPanningEnabled', 'boxSelectionEnabled', 'autolock', 'autoungrabify', 'autounselectify', 'multiClickDebounceTime']; + for (var _i2 = 0; _i2 < fields.length; _i2++) { + var f = fields[_i2]; + if (obj[f] != null) { + cy[f](obj[f]); + } + } + cy.endBatch(); + return this; // chaining + } else { + // get + var flat = !!obj; + var json = {}; + if (flat) { + json.elements = this.elements().map(function (ele) { + return ele.json(); + }); + } else { + json.elements = {}; + eles.forEach(function (ele) { + var group = ele.group(); + if (!json.elements[group]) { + json.elements[group] = []; + } + json.elements[group].push(ele.json()); + }); + } + if (this._private.styleEnabled) { + json.style = cy.style().json(); + } + json.data = copy(cy.data()); + var options = _p.options; + json.zoomingEnabled = _p.zoomingEnabled; + json.userZoomingEnabled = _p.userZoomingEnabled; + json.zoom = _p.zoom; + json.minZoom = _p.minZoom; + json.maxZoom = _p.maxZoom; + json.panningEnabled = _p.panningEnabled; + json.userPanningEnabled = _p.userPanningEnabled; + json.pan = copy(_p.pan); + json.boxSelectionEnabled = _p.boxSelectionEnabled; + json.renderer = copy(options.renderer); + json.hideEdgesOnViewport = options.hideEdgesOnViewport; + json.textureOnViewport = options.textureOnViewport; + json.wheelSensitivity = options.wheelSensitivity; + json.motionBlur = options.motionBlur; + json.multiClickDebounceTime = options.multiClickDebounceTime; + return json; + } + } +}); +corefn.$id = corefn.getElementById; +[corefn$9, corefn$8, elesfn, corefn$7, corefn$6, corefn$5, corefn$4, corefn$3, corefn$2, corefn$1, fn].forEach(function (props) { + extend(corefn, props); +}); + +/* eslint-disable no-unused-vars */ +var defaults$7 = { + fit: true, + // whether to fit the viewport to the graph + directed: false, + // whether the tree is directed downwards (or edges can point in any direction if false) + padding: 30, + // padding on fit + circle: false, + // put depths in concentric circles if true, put depths top down if false + grid: false, + // whether to create an even grid into which the DAG is placed (circle:false only) + spacingFactor: 1.75, + // positive spacing factor, larger => more space between nodes (N.B. n/a if causes overlap) + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + roots: undefined, + // the roots of the trees + depthSort: undefined, + // a sorting function to order nodes at equal depth. e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled, + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +var deprecatedOptionDefaults = { + maximal: false, + // whether to shift nodes down their natural BFS depths in order to avoid upwards edges (DAGS only); setting acyclic to true sets maximal to true also + acyclic: false // whether the tree is acyclic and thus a node could be shifted (due to the maximal option) multiple times without causing an infinite loop; setting to true sets maximal to true also; if you are uncertain whether a tree is acyclic, set to false to avoid potential infinite loops +}; + +/* eslint-enable */ + +var getInfo = function getInfo(ele) { + return ele.scratch('breadthfirst'); +}; +var setInfo = function setInfo(ele, obj) { + return ele.scratch('breadthfirst', obj); +}; +function BreadthFirstLayout(options) { + this.options = extend({}, defaults$7, deprecatedOptionDefaults, options); +} +BreadthFirstLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().filter(function (n) { + return !n.isParent(); + }); + var graph = eles; + var directed = options.directed; + var maximal = options.acyclic || options.maximal || options.maximalAdjustments > 0; // maximalAdjustments for compat. w/ old code; also, setting acyclic to true sets maximal to true + + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var roots; + if (elementOrCollection(options.roots)) { + roots = options.roots; + } else if (array(options.roots)) { + var rootsArray = []; + for (var i = 0; i < options.roots.length; i++) { + var id = options.roots[i]; + var ele = cy.getElementById(id); + rootsArray.push(ele); + } + roots = cy.collection(rootsArray); + } else if (string(options.roots)) { + roots = cy.$(options.roots); + } else { + if (directed) { + roots = nodes.roots(); + } else { + var components = eles.components(); + roots = cy.collection(); + var _loop = function _loop(_i) { + var comp = components[_i]; + var maxDegree = comp.maxDegree(false); + var compRoots = comp.filter(function (ele) { + return ele.degree(false) === maxDegree; + }); + roots = roots.add(compRoots); + }; + for (var _i = 0; _i < components.length; _i++) { + _loop(_i); + } + } + } + var depths = []; + var foundByBfs = {}; + var addToDepth = function addToDepth(ele, d) { + if (depths[d] == null) { + depths[d] = []; + } + var i = depths[d].length; + depths[d].push(ele); + setInfo(ele, { + index: i, + depth: d + }); + }; + var changeDepth = function changeDepth(ele, newDepth) { + var _getInfo = getInfo(ele), + depth = _getInfo.depth, + index = _getInfo.index; + depths[depth][index] = null; + addToDepth(ele, newDepth); + }; + + // find the depths of the nodes + graph.bfs({ + roots: roots, + directed: options.directed, + visit: function visit(node, edge, pNode, i, depth) { + var ele = node[0]; + var id = ele.id(); + addToDepth(ele, depth); + foundByBfs[id] = true; + } + }); + + // check for nodes not found by bfs + var orphanNodes = []; + for (var _i2 = 0; _i2 < nodes.length; _i2++) { + var _ele = nodes[_i2]; + if (foundByBfs[_ele.id()]) { + continue; + } else { + orphanNodes.push(_ele); + } + } + + // assign the nodes a depth and index + + var assignDepthsAt = function assignDepthsAt(i) { + var eles = depths[i]; + for (var j = 0; j < eles.length; j++) { + var _ele2 = eles[j]; + if (_ele2 == null) { + eles.splice(j, 1); + j--; + continue; + } + setInfo(_ele2, { + depth: i, + index: j + }); + } + }; + var assignDepths = function assignDepths() { + for (var _i3 = 0; _i3 < depths.length; _i3++) { + assignDepthsAt(_i3); + } + }; + var adjustMaximally = function adjustMaximally(ele, shifted) { + var eInfo = getInfo(ele); + var incomers = ele.incomers().filter(function (el) { + return el.isNode() && eles.has(el); + }); + var maxDepth = -1; + var id = ele.id(); + for (var k = 0; k < incomers.length; k++) { + var incmr = incomers[k]; + var iInfo = getInfo(incmr); + maxDepth = Math.max(maxDepth, iInfo.depth); + } + if (eInfo.depth <= maxDepth) { + if (!options.acyclic && shifted[id]) { + return null; + } + var newDepth = maxDepth + 1; + changeDepth(ele, newDepth); + shifted[id] = newDepth; + return true; + } + return false; + }; + + // for the directed case, try to make the edges all go down (i.e. depth i => depth i + 1) + if (directed && maximal) { + var Q = []; + var shifted = {}; + var enqueue = function enqueue(n) { + return Q.push(n); + }; + var dequeue = function dequeue() { + return Q.shift(); + }; + nodes.forEach(function (n) { + return Q.push(n); + }); + while (Q.length > 0) { + var _ele3 = dequeue(); + var didShift = adjustMaximally(_ele3, shifted); + if (didShift) { + _ele3.outgoers().filter(function (el) { + return el.isNode() && eles.has(el); + }).forEach(enqueue); + } else if (didShift === null) { + warn('Detected double maximal shift for node `' + _ele3.id() + '`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.'); + break; // exit on failure + } + } + } + + assignDepths(); // clear holes + + // find min distance we need to leave between nodes + var minDistance = 0; + if (options.avoidOverlap) { + for (var _i4 = 0; _i4 < nodes.length; _i4++) { + var n = nodes[_i4]; + var nbb = n.layoutDimensions(options); + var w = nbb.w; + var h = nbb.h; + minDistance = Math.max(minDistance, w, h); + } + } + + // get the weighted percent for an element based on its connectivity to other levels + var cachedWeightedPercent = {}; + var getWeightedPercent = function getWeightedPercent(ele) { + if (cachedWeightedPercent[ele.id()]) { + return cachedWeightedPercent[ele.id()]; + } + var eleDepth = getInfo(ele).depth; + var neighbors = ele.neighborhood(); + var percent = 0; + var samples = 0; + for (var _i5 = 0; _i5 < neighbors.length; _i5++) { + var neighbor = neighbors[_i5]; + if (neighbor.isEdge() || neighbor.isParent() || !nodes.has(neighbor)) { + continue; + } + var bf = getInfo(neighbor); + if (bf == null) { + continue; + } + var index = bf.index; + var depth = bf.depth; + + // unassigned neighbours shouldn't affect the ordering + if (index == null || depth == null) { + continue; + } + var nDepth = depths[depth].length; + if (depth < eleDepth) { + // only get influenced by elements above + percent += index / nDepth; + samples++; + } + } + samples = Math.max(1, samples); + percent = percent / samples; + if (samples === 0) { + // put lone nodes at the start + percent = 0; + } + cachedWeightedPercent[ele.id()] = percent; + return percent; + }; + + // rearrange the indices in each depth level based on connectivity + + var sortFn = function sortFn(a, b) { + var apct = getWeightedPercent(a); + var bpct = getWeightedPercent(b); + var diff = apct - bpct; + if (diff === 0) { + return ascending(a.id(), b.id()); // make sure sort doesn't have don't-care comparisons + } else { + return diff; + } + }; + if (options.depthSort !== undefined) { + sortFn = options.depthSort; + } + + // sort each level to make connected nodes closer + for (var _i6 = 0; _i6 < depths.length; _i6++) { + depths[_i6].sort(sortFn); + assignDepthsAt(_i6); + } + + // assign orphan nodes to a new top-level depth + var orphanDepth = []; + for (var _i7 = 0; _i7 < orphanNodes.length; _i7++) { + orphanDepth.push(orphanNodes[_i7]); + } + depths.unshift(orphanDepth); + assignDepths(); + var biggestDepthSize = 0; + for (var _i8 = 0; _i8 < depths.length; _i8++) { + biggestDepthSize = Math.max(depths[_i8].length, biggestDepthSize); + } + var center = { + x: bb.x1 + bb.w / 2, + y: bb.x1 + bb.h / 2 + }; + var maxDepthSize = depths.reduce(function (max, eles) { + return Math.max(max, eles.length); + }, 0); + var getPosition = function getPosition(ele) { + var _getInfo2 = getInfo(ele), + depth = _getInfo2.depth, + index = _getInfo2.index; + var depthSize = depths[depth].length; + var distanceX = Math.max(bb.w / ((options.grid ? maxDepthSize : depthSize) + 1), minDistance); + var distanceY = Math.max(bb.h / (depths.length + 1), minDistance); + var radiusStepSize = Math.min(bb.w / 2 / depths.length, bb.h / 2 / depths.length); + radiusStepSize = Math.max(radiusStepSize, minDistance); + if (!options.circle) { + var epos = { + x: center.x + (index + 1 - (depthSize + 1) / 2) * distanceX, + y: (depth + 1) * distanceY + }; + return epos; + } else { + var radius = radiusStepSize * depth + radiusStepSize - (depths.length > 0 && depths[0].length <= 3 ? radiusStepSize / 2 : 0); + var theta = 2 * Math.PI / depths[depth].length * index; + if (depth === 0 && depths[0].length === 1) { + radius = 1; + } + return { + x: center.x + radius * Math.cos(theta), + y: center.y + radius * Math.sin(theta) + }; + } + }; + eles.nodes().layoutPositions(this, options, getPosition); + return this; // chaining +}; + +var defaults$6 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // the padding on fit + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox and radius if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + radius: undefined, + // the radius of the circle + startAngle: 3 / 2 * Math.PI, + // where nodes start in radians + sweep: undefined, + // how many radians should be between the first and last node (defaults to full circle) + clockwise: true, + // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) + sort: undefined, + // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function CircleLayout(options) { + this.options = extend({}, defaults$6, options); +} +CircleLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var clockwise = options.counterclockwise !== undefined ? !options.counterclockwise : options.clockwise; + var nodes = eles.nodes().not(':parent'); + if (options.sort) { + nodes = nodes.sort(options.sort); + } + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var center = { + x: bb.x1 + bb.w / 2, + y: bb.y1 + bb.h / 2 + }; + var sweep = options.sweep === undefined ? 2 * Math.PI - 2 * Math.PI / nodes.length : options.sweep; + var dTheta = sweep / Math.max(1, nodes.length - 1); + var r; + var minDistance = 0; + for (var i = 0; i < nodes.length; i++) { + var n = nodes[i]; + var nbb = n.layoutDimensions(options); + var w = nbb.w; + var h = nbb.h; + minDistance = Math.max(minDistance, w, h); + } + if (number$1(options.radius)) { + r = options.radius; + } else if (nodes.length <= 1) { + r = 0; + } else { + r = Math.min(bb.h, bb.w) / 2 - minDistance; + } + + // calculate the radius + if (nodes.length > 1 && options.avoidOverlap) { + // but only if more than one node (can't overlap) + minDistance *= 1.75; // just to have some nice spacing + + var dcos = Math.cos(dTheta) - Math.cos(0); + var dsin = Math.sin(dTheta) - Math.sin(0); + var rMin = Math.sqrt(minDistance * minDistance / (dcos * dcos + dsin * dsin)); // s.t. no nodes overlapping + r = Math.max(rMin, r); + } + var getPos = function getPos(ele, i) { + var theta = options.startAngle + i * dTheta * (clockwise ? 1 : -1); + var rx = r * Math.cos(theta); + var ry = r * Math.sin(theta); + var pos = { + x: center.x + rx, + y: center.y + ry + }; + return pos; + }; + eles.nodes().layoutPositions(this, options, getPos); + return this; // chaining +}; + +var defaults$5 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // the padding on fit + startAngle: 3 / 2 * Math.PI, + // where nodes start in radians + sweep: undefined, + // how many radians should be between the first and last node (defaults to full circle) + clockwise: true, + // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false) + equidistant: false, + // whether levels have an equal radial distance betwen them, may cause bounding box overflow + minNodeSpacing: 10, + // min spacing between outside of nodes (used for radius adjustment) + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + height: undefined, + // height of layout area (overrides container height) + width: undefined, + // width of layout area (overrides container width) + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + concentric: function concentric(node) { + // returns numeric value for each node, placing higher nodes in levels towards the centre + return node.degree(); + }, + levelWidth: function levelWidth(nodes) { + // the variation of concentric values in each level + return nodes.maxDegree() / 4; + }, + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function ConcentricLayout(options) { + this.options = extend({}, defaults$5, options); +} +ConcentricLayout.prototype.run = function () { + var params = this.options; + var options = params; + var clockwise = options.counterclockwise !== undefined ? !options.counterclockwise : options.clockwise; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().not(':parent'); + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var center = { + x: bb.x1 + bb.w / 2, + y: bb.y1 + bb.h / 2 + }; + var nodeValues = []; // { node, value } + var maxNodeSize = 0; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var value = void 0; + + // calculate the node value + value = options.concentric(node); + nodeValues.push({ + value: value, + node: node + }); + + // for style mapping + node._private.scratch.concentric = value; + } + + // in case we used the `concentric` in style + nodes.updateStyle(); + + // calculate max size now based on potentially updated mappers + for (var _i = 0; _i < nodes.length; _i++) { + var _node = nodes[_i]; + var nbb = _node.layoutDimensions(options); + maxNodeSize = Math.max(maxNodeSize, nbb.w, nbb.h); + } + + // sort node values in descreasing order + nodeValues.sort(function (a, b) { + return b.value - a.value; + }); + var levelWidth = options.levelWidth(nodes); + + // put the values into levels + var levels = [[]]; + var currentLevel = levels[0]; + for (var _i2 = 0; _i2 < nodeValues.length; _i2++) { + var val = nodeValues[_i2]; + if (currentLevel.length > 0) { + var diff = Math.abs(currentLevel[0].value - val.value); + if (diff >= levelWidth) { + currentLevel = []; + levels.push(currentLevel); + } + } + currentLevel.push(val); + } + + // create positions from levels + + var minDist = maxNodeSize + options.minNodeSpacing; // min dist between nodes + + if (!options.avoidOverlap) { + // then strictly constrain to bb + var firstLvlHasMulti = levels.length > 0 && levels[0].length > 1; + var maxR = Math.min(bb.w, bb.h) / 2 - minDist; + var rStep = maxR / (levels.length + firstLvlHasMulti ? 1 : 0); + minDist = Math.min(minDist, rStep); + } + + // find the metrics for each level + var r = 0; + for (var _i3 = 0; _i3 < levels.length; _i3++) { + var level = levels[_i3]; + var sweep = options.sweep === undefined ? 2 * Math.PI - 2 * Math.PI / level.length : options.sweep; + var dTheta = level.dTheta = sweep / Math.max(1, level.length - 1); + + // calculate the radius + if (level.length > 1 && options.avoidOverlap) { + // but only if more than one node (can't overlap) + var dcos = Math.cos(dTheta) - Math.cos(0); + var dsin = Math.sin(dTheta) - Math.sin(0); + var rMin = Math.sqrt(minDist * minDist / (dcos * dcos + dsin * dsin)); // s.t. no nodes overlapping + + r = Math.max(rMin, r); + } + level.r = r; + r += minDist; + } + if (options.equidistant) { + var rDeltaMax = 0; + var _r = 0; + for (var _i4 = 0; _i4 < levels.length; _i4++) { + var _level = levels[_i4]; + var rDelta = _level.r - _r; + rDeltaMax = Math.max(rDeltaMax, rDelta); + } + _r = 0; + for (var _i5 = 0; _i5 < levels.length; _i5++) { + var _level2 = levels[_i5]; + if (_i5 === 0) { + _r = _level2.r; + } + _level2.r = _r; + _r += rDeltaMax; + } + } + + // calculate the node positions + var pos = {}; // id => position + for (var _i6 = 0; _i6 < levels.length; _i6++) { + var _level3 = levels[_i6]; + var _dTheta = _level3.dTheta; + var _r2 = _level3.r; + for (var j = 0; j < _level3.length; j++) { + var _val = _level3[j]; + var theta = options.startAngle + (clockwise ? 1 : -1) * _dTheta * j; + var p = { + x: center.x + _r2 * Math.cos(theta), + y: center.y + _r2 * Math.sin(theta) + }; + pos[_val.node.id()] = p; + } + } + + // position the nodes + eles.nodes().layoutPositions(this, options, function (ele) { + var id = ele.id(); + return pos[id]; + }); + return this; // chaining +}; + +/* +The CoSE layout was written by Gerardo Huck. +https://www.linkedin.com/in/gerardohuck/ + +Based on the following article: +http://dl.acm.org/citation.cfm?id=1498047 + +Modifications tracked on Github. +*/ +var DEBUG; + +/** + * @brief : default layout options + */ +var defaults$4 = { + // Called on `layoutready` + ready: function ready() {}, + // Called on `layoutstop` + stop: function stop() {}, + // Whether to animate while running the layout + // true : Animate continuously as the layout is running + // false : Just show the end result + // 'end' : Animate with the end result, from the initial positions to the end positions + animate: true, + // Easing of the animation for animate:'end' + animationEasing: undefined, + // The duration of the animation for animate:'end' + animationDuration: undefined, + // A function that determines whether the node should be animated + // All nodes animated by default on animate enabled + // Non-animated nodes are positioned immediately when the layout starts + animateFilter: function animateFilter(node, i) { + return true; + }, + // The layout animates only after this many milliseconds for animate:true + // (prevents flashing on fast runs) + animationThreshold: 250, + // Number of iterations between consecutive screen positions update + refresh: 20, + // Whether to fit the network view after when done + fit: true, + // Padding on fit + padding: 30, + // Constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + boundingBox: undefined, + // Excludes the label when calculating node bounding boxes for the layout algorithm + nodeDimensionsIncludeLabels: false, + // Randomize the initial positions of the nodes (true) or use existing positions (false) + randomize: false, + // Extra spacing between components in non-compound graphs + componentSpacing: 40, + // Node repulsion (non overlapping) multiplier + nodeRepulsion: function nodeRepulsion(node) { + return 2048; + }, + // Node repulsion (overlapping) multiplier + nodeOverlap: 4, + // Ideal edge (non nested) length + idealEdgeLength: function idealEdgeLength(edge) { + return 32; + }, + // Divisor to compute edge forces + edgeElasticity: function edgeElasticity(edge) { + return 32; + }, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 1.2, + // Gravity force (constant) + gravity: 1, + // Maximum number of iterations to perform + numIter: 1000, + // Initial temperature (maximum node displacement) + initialTemp: 1000, + // Cooling factor (how the temperature is reduced between consecutive iterations + coolingFactor: 0.99, + // Lower temperature threshold (below this point the layout will end) + minTemp: 1.0 +}; + +/** + * @brief : constructor + * @arg options : object containing layout options + */ +function CoseLayout(options) { + this.options = extend({}, defaults$4, options); + this.options.layout = this; + + // Exclude any edge that has a source or target node that is not in the set of passed-in nodes + var nodes = this.options.eles.nodes(); + var edges = this.options.eles.edges(); + var notEdges = edges.filter(function (e) { + var sourceId = e.source().data('id'); + var targetId = e.target().data('id'); + var hasSource = nodes.some(function (n) { + return n.data('id') === sourceId; + }); + var hasTarget = nodes.some(function (n) { + return n.data('id') === targetId; + }); + return !hasSource || !hasTarget; + }); + this.options.eles = this.options.eles.not(notEdges); +} + +/** + * @brief : runs the layout + */ +CoseLayout.prototype.run = function () { + var options = this.options; + var cy = options.cy; + var layout = this; + layout.stopped = false; + if (options.animate === true || options.animate === false) { + layout.emit({ + type: 'layoutstart', + layout: layout + }); + } + + // Set DEBUG - Global variable + if (true === options.debug) { + DEBUG = true; + } else { + DEBUG = false; + } + + // Initialize layout info + var layoutInfo = createLayoutInfo(cy, layout, options); + + // Show LayoutInfo contents if debugging + if (DEBUG) { + printLayoutInfo(layoutInfo); + } + + // If required, randomize node positions + if (options.randomize) { + randomizePositions(layoutInfo); + } + var startTime = performanceNow(); + var refresh = function refresh() { + refreshPositions(layoutInfo, cy, options); + + // Fit the graph if necessary + if (true === options.fit) { + cy.fit(options.padding); + } + }; + var mainLoop = function mainLoop(i) { + if (layout.stopped || i >= options.numIter) { + // logDebug("Layout manually stopped. Stopping computation in step " + i); + return false; + } + + // Do one step in the phisical simulation + step(layoutInfo, options); + + // Update temperature + layoutInfo.temperature = layoutInfo.temperature * options.coolingFactor; + // logDebug("New temperature: " + layoutInfo.temperature); + + if (layoutInfo.temperature < options.minTemp) { + // logDebug("Temperature drop below minimum threshold. Stopping computation in step " + i); + return false; + } + return true; + }; + var done = function done() { + if (options.animate === true || options.animate === false) { + refresh(); + + // Layout has finished + layout.one('layoutstop', options.stop); + layout.emit({ + type: 'layoutstop', + layout: layout + }); + } else { + var nodes = options.eles.nodes(); + var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes); + nodes.layoutPositions(layout, options, getScaledPos); + } + }; + var i = 0; + var loopRet = true; + if (options.animate === true) { + var frame = function frame() { + var f = 0; + while (loopRet && f < options.refresh) { + loopRet = mainLoop(i); + i++; + f++; + } + if (!loopRet) { + // it's done + separateComponents(layoutInfo, options); + done(); + } else { + var now = performanceNow(); + if (now - startTime >= options.animationThreshold) { + refresh(); + } + requestAnimationFrame$1(frame); + } + }; + frame(); + } else { + while (loopRet) { + loopRet = mainLoop(i); + i++; + } + separateComponents(layoutInfo, options); + done(); + } + return this; // chaining +}; + +/** + * @brief : called on continuous layouts to stop them before they finish + */ +CoseLayout.prototype.stop = function () { + this.stopped = true; + if (this.thread) { + this.thread.stop(); + } + this.emit('layoutstop'); + return this; // chaining +}; + +CoseLayout.prototype.destroy = function () { + if (this.thread) { + this.thread.stop(); + } + return this; // chaining +}; + +/** + * @brief : Creates an object which is contains all the data + * used in the layout process + * @arg cy : cytoscape.js object + * @return : layoutInfo object initialized + */ +var createLayoutInfo = function createLayoutInfo(cy, layout, options) { + // Shortcut + var edges = options.eles.edges(); + var nodes = options.eles.nodes(); + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var layoutInfo = { + isCompound: cy.hasCompoundNodes(), + layoutNodes: [], + idToIndex: {}, + nodeSize: nodes.size(), + graphSet: [], + indexToGraph: [], + layoutEdges: [], + edgeSize: edges.size(), + temperature: options.initialTemp, + clientWidth: bb.w, + clientHeight: bb.h, + boundingBox: bb + }; + var components = options.eles.components(); + var id2cmptId = {}; + for (var i = 0; i < components.length; i++) { + var component = components[i]; + for (var j = 0; j < component.length; j++) { + var node = component[j]; + id2cmptId[node.id()] = i; + } + } + + // Iterate over all nodes, creating layout nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = nodes[i]; + var nbb = n.layoutDimensions(options); + var tempNode = {}; + tempNode.isLocked = n.locked(); + tempNode.id = n.data('id'); + tempNode.parentId = n.data('parent'); + tempNode.cmptId = id2cmptId[n.id()]; + tempNode.children = []; + tempNode.positionX = n.position('x'); + tempNode.positionY = n.position('y'); + tempNode.offsetX = 0; + tempNode.offsetY = 0; + tempNode.height = nbb.w; + tempNode.width = nbb.h; + tempNode.maxX = tempNode.positionX + tempNode.width / 2; + tempNode.minX = tempNode.positionX - tempNode.width / 2; + tempNode.maxY = tempNode.positionY + tempNode.height / 2; + tempNode.minY = tempNode.positionY - tempNode.height / 2; + tempNode.padLeft = parseFloat(n.style('padding')); + tempNode.padRight = parseFloat(n.style('padding')); + tempNode.padTop = parseFloat(n.style('padding')); + tempNode.padBottom = parseFloat(n.style('padding')); + + // forces + tempNode.nodeRepulsion = fn$6(options.nodeRepulsion) ? options.nodeRepulsion(n) : options.nodeRepulsion; + + // Add new node + layoutInfo.layoutNodes.push(tempNode); + // Add entry to id-index map + layoutInfo.idToIndex[tempNode.id] = i; + } + + // Inline implementation of a queue, used for traversing the graph in BFS order + var queue = []; + var start = 0; // Points to the start the queue + var end = -1; // Points to the end of the queue + + var tempGraph = []; + + // Second pass to add child information and + // initialize queue for hierarchical traversal + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + var p_id = n.parentId; + // Check if node n has a parent node + if (null != p_id) { + // Add node Id to parent's list of children + layoutInfo.layoutNodes[layoutInfo.idToIndex[p_id]].children.push(n.id); + } else { + // If a node doesn't have a parent, then it's in the root graph + queue[++end] = n.id; + tempGraph.push(n.id); + } + } + + // Add root graph to graphSet + layoutInfo.graphSet.push(tempGraph); + + // Traverse the graph, level by level, + while (start <= end) { + // Get the node to visit and remove it from queue + var node_id = queue[start++]; + var node_ix = layoutInfo.idToIndex[node_id]; + var node = layoutInfo.layoutNodes[node_ix]; + var children = node.children; + if (children.length > 0) { + // Add children nodes as a new graph to graph set + layoutInfo.graphSet.push(children); + // Add children to que queue to be visited + for (var i = 0; i < children.length; i++) { + queue[++end] = children[i]; + } + } + } + + // Create indexToGraph map + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + for (var j = 0; j < graph.length; j++) { + var index = layoutInfo.idToIndex[graph[j]]; + layoutInfo.indexToGraph[index] = i; + } + } + + // Iterate over all edges, creating Layout Edges + for (var i = 0; i < layoutInfo.edgeSize; i++) { + var e = edges[i]; + var tempEdge = {}; + tempEdge.id = e.data('id'); + tempEdge.sourceId = e.data('source'); + tempEdge.targetId = e.data('target'); + + // Compute ideal length + var idealLength = fn$6(options.idealEdgeLength) ? options.idealEdgeLength(e) : options.idealEdgeLength; + var elasticity = fn$6(options.edgeElasticity) ? options.edgeElasticity(e) : options.edgeElasticity; + + // Check if it's an inter graph edge + var sourceIx = layoutInfo.idToIndex[tempEdge.sourceId]; + var targetIx = layoutInfo.idToIndex[tempEdge.targetId]; + var sourceGraph = layoutInfo.indexToGraph[sourceIx]; + var targetGraph = layoutInfo.indexToGraph[targetIx]; + if (sourceGraph != targetGraph) { + // Find lowest common graph ancestor + var lca = findLCA(tempEdge.sourceId, tempEdge.targetId, layoutInfo); + + // Compute sum of node depths, relative to lca graph + var lcaGraph = layoutInfo.graphSet[lca]; + var depth = 0; + + // Source depth + var tempNode = layoutInfo.layoutNodes[sourceIx]; + while (-1 === lcaGraph.indexOf(tempNode.id)) { + tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]]; + depth++; + } + + // Target depth + tempNode = layoutInfo.layoutNodes[targetIx]; + while (-1 === lcaGraph.indexOf(tempNode.id)) { + tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]]; + depth++; + } + + // logDebug('LCA of nodes ' + tempEdge.sourceId + ' and ' + tempEdge.targetId + + // ". Index: " + lca + " Contents: " + lcaGraph.toString() + + // ". Depth: " + depth); + + // Update idealLength + idealLength *= depth * options.nestingFactor; + } + tempEdge.idealLength = idealLength; + tempEdge.elasticity = elasticity; + layoutInfo.layoutEdges.push(tempEdge); + } + + // Finally, return layoutInfo object + return layoutInfo; +}; + +/** + * @brief : This function finds the index of the lowest common + * graph ancestor between 2 nodes in the subtree + * (from the graph hierarchy induced tree) whose + * root is graphIx + * + * @arg node1: node1's ID + * @arg node2: node2's ID + * @arg layoutInfo: layoutInfo object + * + */ +var findLCA = function findLCA(node1, node2, layoutInfo) { + // Find their common ancester, starting from the root graph + var res = findLCA_aux(node1, node2, 0, layoutInfo); + if (2 > res.count) { + // If aux function couldn't find the common ancester, + // then it is the root graph + return 0; + } else { + return res.graph; + } +}; + +/** + * @brief : Auxiliary function used for LCA computation + * + * @arg node1 : node1's ID + * @arg node2 : node2's ID + * @arg graphIx : subgraph index + * @arg layoutInfo : layoutInfo object + * + * @return : object of the form {count: X, graph: Y}, where: + * X is the number of ancestors (max: 2) found in + * graphIx (and it's subgraphs), + * Y is the graph index of the lowest graph containing + * all X nodes + */ +var findLCA_aux = function findLCA_aux(node1, node2, graphIx, layoutInfo) { + var graph = layoutInfo.graphSet[graphIx]; + // If both nodes belongs to graphIx + if (-1 < graph.indexOf(node1) && -1 < graph.indexOf(node2)) { + return { + count: 2, + graph: graphIx + }; + } + + // Make recursive calls for all subgraphs + var c = 0; + for (var i = 0; i < graph.length; i++) { + var nodeId = graph[i]; + var nodeIx = layoutInfo.idToIndex[nodeId]; + var children = layoutInfo.layoutNodes[nodeIx].children; + + // If the node has no child, skip it + if (0 === children.length) { + continue; + } + var childGraphIx = layoutInfo.indexToGraph[layoutInfo.idToIndex[children[0]]]; + var result = findLCA_aux(node1, node2, childGraphIx, layoutInfo); + if (0 === result.count) { + // Neither node1 nor node2 are present in this subgraph + continue; + } else if (1 === result.count) { + // One of (node1, node2) is present in this subgraph + c++; + if (2 === c) { + // We've already found both nodes, no need to keep searching + break; + } + } else { + // Both nodes are present in this subgraph + return result; + } + } + return { + count: c, + graph: graphIx + }; +}; + +/** + * @brief: printsLayoutInfo into js console + * Only used for debbuging + */ +var printLayoutInfo; + +/** + * @brief : Randomizes the position of all nodes + */ +var randomizePositions = function randomizePositions(layoutInfo, cy) { + var width = layoutInfo.clientWidth; + var height = layoutInfo.clientHeight; + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + + // No need to randomize compound nodes or locked nodes + if (0 === n.children.length && !n.isLocked) { + n.positionX = Math.random() * width; + n.positionY = Math.random() * height; + } + } +}; +var getScaleInBoundsFn = function getScaleInBoundsFn(layoutInfo, options, nodes) { + var bb = layoutInfo.boundingBox; + var coseBB = { + x1: Infinity, + x2: -Infinity, + y1: Infinity, + y2: -Infinity + }; + if (options.boundingBox) { + nodes.forEach(function (node) { + var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[node.data('id')]]; + coseBB.x1 = Math.min(coseBB.x1, lnode.positionX); + coseBB.x2 = Math.max(coseBB.x2, lnode.positionX); + coseBB.y1 = Math.min(coseBB.y1, lnode.positionY); + coseBB.y2 = Math.max(coseBB.y2, lnode.positionY); + }); + coseBB.w = coseBB.x2 - coseBB.x1; + coseBB.h = coseBB.y2 - coseBB.y1; + } + return function (ele, i) { + var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[ele.data('id')]]; + if (options.boundingBox) { + // then add extra bounding box constraint + var pctX = (lnode.positionX - coseBB.x1) / coseBB.w; + var pctY = (lnode.positionY - coseBB.y1) / coseBB.h; + return { + x: bb.x1 + pctX * bb.w, + y: bb.y1 + pctY * bb.h + }; + } else { + return { + x: lnode.positionX, + y: lnode.positionY + }; + } + }; +}; + +/** + * @brief : Updates the positions of nodes in the network + * @arg layoutInfo : LayoutInfo object + * @arg cy : Cytoscape object + * @arg options : Layout options + */ +var refreshPositions = function refreshPositions(layoutInfo, cy, options) { + // var s = 'Refreshing positions'; + // logDebug(s); + + var layout = options.layout; + var nodes = options.eles.nodes(); + var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes); + nodes.positions(getScaledPos); + + // Trigger layoutReady only on first call + if (true !== layoutInfo.ready) { + // s = 'Triggering layoutready'; + // logDebug(s); + layoutInfo.ready = true; + layout.one('layoutready', options.ready); + layout.emit({ + type: 'layoutready', + layout: this + }); + } +}; + +/** + * @brief : Logs a debug message in JS console, if DEBUG is ON + */ +// var logDebug = function(text) { +// if (DEBUG) { +// console.debug(text); +// } +// }; + +/** + * @brief : Performs one iteration of the physical simulation + * @arg layoutInfo : LayoutInfo object already initialized + * @arg cy : Cytoscape object + * @arg options : Layout options + */ +var step = function step(layoutInfo, options, _step) { + // var s = "\n\n###############################"; + // s += "\nSTEP: " + step; + // s += "\n###############################\n"; + // logDebug(s); + + // Calculate node repulsions + calculateNodeForces(layoutInfo, options); + // Calculate edge forces + calculateEdgeForces(layoutInfo); + // Calculate gravity forces + calculateGravityForces(layoutInfo, options); + // Propagate forces from parent to child + propagateForces(layoutInfo); + // Update positions based on calculated forces + updatePositions(layoutInfo); +}; + +/** + * @brief : Computes the node repulsion forces + */ +var calculateNodeForces = function calculateNodeForces(layoutInfo, options) { + // Go through each of the graphs in graphSet + // Nodes only repel each other if they belong to the same graph + // var s = 'calculateNodeForces'; + // logDebug(s); + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + var numNodes = graph.length; + + // s = "Set: " + graph.toString(); + // logDebug(s); + + // Now get all the pairs of nodes + // Only get each pair once, (A, B) = (B, A) + for (var j = 0; j < numNodes; j++) { + var node1 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; + for (var k = j + 1; k < numNodes; k++) { + var node2 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[k]]]; + nodeRepulsion(node1, node2, layoutInfo, options); + } + } + } +}; +var randomDistance = function randomDistance(max) { + return -max + 2 * max * Math.random(); +}; + +/** + * @brief : Compute the node repulsion forces between a pair of nodes + */ +var nodeRepulsion = function nodeRepulsion(node1, node2, layoutInfo, options) { + // var s = "Node repulsion. Node1: " + node1.id + " Node2: " + node2.id; + + var cmptId1 = node1.cmptId; + var cmptId2 = node2.cmptId; + if (cmptId1 !== cmptId2 && !layoutInfo.isCompound) { + return; + } + + // Get direction of line connecting both node centers + var directionX = node2.positionX - node1.positionX; + var directionY = node2.positionY - node1.positionY; + var maxRandDist = 1; + // s += "\ndirectionX: " + directionX + ", directionY: " + directionY; + + // If both centers are the same, apply a random force + if (0 === directionX && 0 === directionY) { + directionX = randomDistance(maxRandDist); + directionY = randomDistance(maxRandDist); + } + var overlap = nodesOverlap(node1, node2, directionX, directionY); + if (overlap > 0) { + // s += "\nNodes DO overlap."; + // s += "\nOverlap: " + overlap; + // If nodes overlap, repulsion force is proportional + // to the overlap + var force = options.nodeOverlap * overlap; + + // Compute the module and components of the force vector + var distance = Math.sqrt(directionX * directionX + directionY * directionY); + // s += "\nDistance: " + distance; + var forceX = force * directionX / distance; + var forceY = force * directionY / distance; + } else { + // s += "\nNodes do NOT overlap."; + // If there's no overlap, force is inversely proportional + // to squared distance + + // Get clipping points for both nodes + var point1 = findClippingPoint(node1, directionX, directionY); + var point2 = findClippingPoint(node2, -1 * directionX, -1 * directionY); + + // Use clipping points to compute distance + var distanceX = point2.x - point1.x; + var distanceY = point2.y - point1.y; + var distanceSqr = distanceX * distanceX + distanceY * distanceY; + var distance = Math.sqrt(distanceSqr); + // s += "\nDistance: " + distance; + + // Compute the module and components of the force vector + var force = (node1.nodeRepulsion + node2.nodeRepulsion) / distanceSqr; + var forceX = force * distanceX / distance; + var forceY = force * distanceY / distance; + } + + // Apply force + if (!node1.isLocked) { + node1.offsetX -= forceX; + node1.offsetY -= forceY; + } + if (!node2.isLocked) { + node2.offsetX += forceX; + node2.offsetY += forceY; + } + + // s += "\nForceX: " + forceX + " ForceY: " + forceY; + // logDebug(s); + + return; +}; + +/** + * @brief : Determines whether two nodes overlap or not + * @return : Amount of overlapping (0 => no overlap) + */ +var nodesOverlap = function nodesOverlap(node1, node2, dX, dY) { + if (dX > 0) { + var overlapX = node1.maxX - node2.minX; + } else { + var overlapX = node2.maxX - node1.minX; + } + if (dY > 0) { + var overlapY = node1.maxY - node2.minY; + } else { + var overlapY = node2.maxY - node1.minY; + } + if (overlapX >= 0 && overlapY >= 0) { + return Math.sqrt(overlapX * overlapX + overlapY * overlapY); + } else { + return 0; + } +}; + +/** + * @brief : Finds the point in which an edge (direction dX, dY) intersects + * the rectangular bounding box of it's source/target node + */ +var findClippingPoint = function findClippingPoint(node, dX, dY) { + // Shorcuts + var X = node.positionX; + var Y = node.positionY; + var H = node.height || 1; + var W = node.width || 1; + var dirSlope = dY / dX; + var nodeSlope = H / W; + + // var s = 'Computing clipping point of node ' + node.id + + // " . Height: " + H + ", Width: " + W + + // "\nDirection " + dX + ", " + dY; + // + // Compute intersection + var res = {}; + + // Case: Vertical direction (up) + if (0 === dX && 0 < dY) { + res.x = X; + // s += "\nUp direction"; + res.y = Y + H / 2; + return res; + } + + // Case: Vertical direction (down) + if (0 === dX && 0 > dY) { + res.x = X; + res.y = Y + H / 2; + // s += "\nDown direction"; + + return res; + } + + // Case: Intersects the right border + if (0 < dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) { + res.x = X + W / 2; + res.y = Y + W * dY / 2 / dX; + // s += "\nRightborder"; + + return res; + } + + // Case: Intersects the left border + if (0 > dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) { + res.x = X - W / 2; + res.y = Y - W * dY / 2 / dX; + // s += "\nLeftborder"; + + return res; + } + + // Case: Intersects the top border + if (0 < dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) { + res.x = X + H * dX / 2 / dY; + res.y = Y + H / 2; + // s += "\nTop border"; + + return res; + } + + // Case: Intersects the bottom border + if (0 > dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) { + res.x = X - H * dX / 2 / dY; + res.y = Y - H / 2; + // s += "\nBottom border"; + + return res; + } + + // s += "\nClipping point found at " + res.x + ", " + res.y; + // logDebug(s); + return res; +}; + +/** + * @brief : Calculates all edge forces + */ +var calculateEdgeForces = function calculateEdgeForces(layoutInfo, options) { + // Iterate over all edges + for (var i = 0; i < layoutInfo.edgeSize; i++) { + // Get edge, source & target nodes + var edge = layoutInfo.layoutEdges[i]; + var sourceIx = layoutInfo.idToIndex[edge.sourceId]; + var source = layoutInfo.layoutNodes[sourceIx]; + var targetIx = layoutInfo.idToIndex[edge.targetId]; + var target = layoutInfo.layoutNodes[targetIx]; + + // Get direction of line connecting both node centers + var directionX = target.positionX - source.positionX; + var directionY = target.positionY - source.positionY; + + // If both centers are the same, do nothing. + // A random force has already been applied as node repulsion + if (0 === directionX && 0 === directionY) { + continue; + } + + // Get clipping points for both nodes + var point1 = findClippingPoint(source, directionX, directionY); + var point2 = findClippingPoint(target, -1 * directionX, -1 * directionY); + var lx = point2.x - point1.x; + var ly = point2.y - point1.y; + var l = Math.sqrt(lx * lx + ly * ly); + var force = Math.pow(edge.idealLength - l, 2) / edge.elasticity; + if (0 !== l) { + var forceX = force * lx / l; + var forceY = force * ly / l; + } else { + var forceX = 0; + var forceY = 0; + } + + // Add this force to target and source nodes + if (!source.isLocked) { + source.offsetX += forceX; + source.offsetY += forceY; + } + if (!target.isLocked) { + target.offsetX -= forceX; + target.offsetY -= forceY; + } + + // var s = 'Edge force between nodes ' + source.id + ' and ' + target.id; + // s += "\nDistance: " + l + " Force: (" + forceX + ", " + forceY + ")"; + // logDebug(s); + } +}; + +/** + * @brief : Computes gravity forces for all nodes + */ +var calculateGravityForces = function calculateGravityForces(layoutInfo, options) { + if (options.gravity === 0) { + return; + } + var distThreshold = 1; + + // var s = 'calculateGravityForces'; + // logDebug(s); + for (var i = 0; i < layoutInfo.graphSet.length; i++) { + var graph = layoutInfo.graphSet[i]; + var numNodes = graph.length; + + // s = "Set: " + graph.toString(); + // logDebug(s); + + // Compute graph center + if (0 === i) { + var centerX = layoutInfo.clientHeight / 2; + var centerY = layoutInfo.clientWidth / 2; + } else { + // Get Parent node for this graph, and use its position as center + var temp = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[0]]]; + var parent = layoutInfo.layoutNodes[layoutInfo.idToIndex[temp.parentId]]; + var centerX = parent.positionX; + var centerY = parent.positionY; + } + // s = "Center found at: " + centerX + ", " + centerY; + // logDebug(s); + + // Apply force to all nodes in graph + for (var j = 0; j < numNodes; j++) { + var node = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; + // s = "Node: " + node.id; + + if (node.isLocked) { + continue; + } + var dx = centerX - node.positionX; + var dy = centerY - node.positionY; + var d = Math.sqrt(dx * dx + dy * dy); + if (d > distThreshold) { + var fx = options.gravity * dx / d; + var fy = options.gravity * dy / d; + node.offsetX += fx; + node.offsetY += fy; + // s += ": Applied force: " + fx + ", " + fy; + } + // logDebug(s); + } + } +}; + +/** + * @brief : This function propagates the existing offsets from + * parent nodes to its descendents. + * @arg layoutInfo : layoutInfo Object + * @arg cy : cytoscape Object + * @arg options : Layout options + */ +var propagateForces = function propagateForces(layoutInfo, options) { + // Inline implementation of a queue, used for traversing the graph in BFS order + var queue = []; + var start = 0; // Points to the start the queue + var end = -1; // Points to the end of the queue + + // logDebug('propagateForces'); + + // Start by visiting the nodes in the root graph + queue.push.apply(queue, layoutInfo.graphSet[0]); + end += layoutInfo.graphSet[0].length; + + // Traverse the graph, level by level, + while (start <= end) { + // Get the node to visit and remove it from queue + var nodeId = queue[start++]; + var nodeIndex = layoutInfo.idToIndex[nodeId]; + var node = layoutInfo.layoutNodes[nodeIndex]; + var children = node.children; + + // We only need to process the node if it's compound + if (0 < children.length && !node.isLocked) { + var offX = node.offsetX; + var offY = node.offsetY; + + // var s = "Propagating offset from parent node : " + node.id + + // ". OffsetX: " + offX + ". OffsetY: " + offY; + // s += "\n Children: " + children.toString(); + // logDebug(s); + + for (var i = 0; i < children.length; i++) { + var childNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[children[i]]]; + // Propagate offset + childNode.offsetX += offX; + childNode.offsetY += offY; + // Add children to queue to be visited + queue[++end] = children[i]; + } + + // Reset parent offsets + node.offsetX = 0; + node.offsetY = 0; + } + } +}; + +/** + * @brief : Updates the layout model positions, based on + * the accumulated forces + */ +var updatePositions = function updatePositions(layoutInfo, options) { + // var s = 'Updating positions'; + // logDebug(s); + + // Reset boundaries for compound nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length) { + // logDebug("Resetting boundaries of compound node: " + n.id); + n.maxX = undefined; + n.minX = undefined; + n.maxY = undefined; + n.minY = undefined; + } + } + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length || n.isLocked) { + // No need to set compound or locked node position + // logDebug("Skipping position update of node: " + n.id); + continue; + } + // s = "Node: " + n.id + " Previous position: (" + + // n.positionX + ", " + n.positionY + ")."; + + // Limit displacement in order to improve stability + var tempForce = limitForce(n.offsetX, n.offsetY, layoutInfo.temperature); + n.positionX += tempForce.x; + n.positionY += tempForce.y; + n.offsetX = 0; + n.offsetY = 0; + n.minX = n.positionX - n.width; + n.maxX = n.positionX + n.width; + n.minY = n.positionY - n.height; + n.maxY = n.positionY + n.height; + // s += " New Position: (" + n.positionX + ", " + n.positionY + ")."; + // logDebug(s); + + // Update ancestry boudaries + updateAncestryBoundaries(n, layoutInfo); + } + + // Update size, position of compund nodes + for (var i = 0; i < layoutInfo.nodeSize; i++) { + var n = layoutInfo.layoutNodes[i]; + if (0 < n.children.length && !n.isLocked) { + n.positionX = (n.maxX + n.minX) / 2; + n.positionY = (n.maxY + n.minY) / 2; + n.width = n.maxX - n.minX; + n.height = n.maxY - n.minY; + // s = "Updating position, size of compound node " + n.id; + // s += "\nPositionX: " + n.positionX + ", PositionY: " + n.positionY; + // s += "\nWidth: " + n.width + ", Height: " + n.height; + // logDebug(s); + } + } +}; + +/** + * @brief : Limits a force (forceX, forceY) to be not + * greater (in modulo) than max. + 8 Preserves force direction. + */ +var limitForce = function limitForce(forceX, forceY, max) { + // var s = "Limiting force: (" + forceX + ", " + forceY + "). Max: " + max; + var force = Math.sqrt(forceX * forceX + forceY * forceY); + if (force > max) { + var res = { + x: max * forceX / force, + y: max * forceY / force + }; + } else { + var res = { + x: forceX, + y: forceY + }; + } + + // s += ".\nResult: (" + res.x + ", " + res.y + ")"; + // logDebug(s); + + return res; +}; + +/** + * @brief : Function used for keeping track of compound node + * sizes, since they should bound all their subnodes. + */ +var updateAncestryBoundaries = function updateAncestryBoundaries(node, layoutInfo) { + // var s = "Propagating new position/size of node " + node.id; + var parentId = node.parentId; + if (null == parentId) { + // If there's no parent, we are done + // s += ". No parent node."; + // logDebug(s); + return; + } + + // Get Parent Node + var p = layoutInfo.layoutNodes[layoutInfo.idToIndex[parentId]]; + var flag = false; + + // MaxX + if (null == p.maxX || node.maxX + p.padRight > p.maxX) { + p.maxX = node.maxX + p.padRight; + flag = true; + // s += "\nNew maxX for parent node " + p.id + ": " + p.maxX; + } + + // MinX + if (null == p.minX || node.minX - p.padLeft < p.minX) { + p.minX = node.minX - p.padLeft; + flag = true; + // s += "\nNew minX for parent node " + p.id + ": " + p.minX; + } + + // MaxY + if (null == p.maxY || node.maxY + p.padBottom > p.maxY) { + p.maxY = node.maxY + p.padBottom; + flag = true; + // s += "\nNew maxY for parent node " + p.id + ": " + p.maxY; + } + + // MinY + if (null == p.minY || node.minY - p.padTop < p.minY) { + p.minY = node.minY - p.padTop; + flag = true; + // s += "\nNew minY for parent node " + p.id + ": " + p.minY; + } + + // If updated boundaries, propagate changes upward + if (flag) { + // logDebug(s); + return updateAncestryBoundaries(p, layoutInfo); + } + + // s += ". No changes in boundaries/position of parent node " + p.id; + // logDebug(s); + return; +}; +var separateComponents = function separateComponents(layoutInfo, options) { + var nodes = layoutInfo.layoutNodes; + var components = []; + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var cid = node.cmptId; + var component = components[cid] = components[cid] || []; + component.push(node); + } + var totalA = 0; + for (var i = 0; i < components.length; i++) { + var c = components[i]; + if (!c) { + continue; + } + c.x1 = Infinity; + c.x2 = -Infinity; + c.y1 = Infinity; + c.y2 = -Infinity; + for (var j = 0; j < c.length; j++) { + var n = c[j]; + c.x1 = Math.min(c.x1, n.positionX - n.width / 2); + c.x2 = Math.max(c.x2, n.positionX + n.width / 2); + c.y1 = Math.min(c.y1, n.positionY - n.height / 2); + c.y2 = Math.max(c.y2, n.positionY + n.height / 2); + } + c.w = c.x2 - c.x1; + c.h = c.y2 - c.y1; + totalA += c.w * c.h; + } + components.sort(function (c1, c2) { + return c2.w * c2.h - c1.w * c1.h; + }); + var x = 0; + var y = 0; + var usedW = 0; + var rowH = 0; + var maxRowW = Math.sqrt(totalA) * layoutInfo.clientWidth / layoutInfo.clientHeight; + for (var i = 0; i < components.length; i++) { + var c = components[i]; + if (!c) { + continue; + } + for (var j = 0; j < c.length; j++) { + var n = c[j]; + if (!n.isLocked) { + n.positionX += x - c.x1; + n.positionY += y - c.y1; + } + } + x += c.w + options.componentSpacing; + usedW += c.w + options.componentSpacing; + rowH = Math.max(rowH, c.h); + if (usedW > maxRowW) { + y += rowH + options.componentSpacing; + x = 0; + usedW = 0; + rowH = 0; + } + } +}; + +var defaults$3 = { + fit: true, + // whether to fit the viewport to the graph + padding: 30, + // padding used on fit + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + avoidOverlap: true, + // prevents node overlap, may overflow boundingBox if not enough space + avoidOverlapPadding: 10, + // extra spacing around nodes when avoidOverlap: true + nodeDimensionsIncludeLabels: false, + // Excludes the label when calculating node bounding boxes for the layout algorithm + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + condense: false, + // uses all available space on false, uses minimal space on true + rows: undefined, + // force num of rows in the grid + cols: undefined, + // force num of columns in the grid + position: function position(node) {}, + // returns { row, col } for element + sort: undefined, + // a sorting function to order the nodes; e.g. function(a, b){ return a.data('weight') - b.data('weight') } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function GridLayout(options) { + this.options = extend({}, defaults$3, options); +} +GridLayout.prototype.run = function () { + var params = this.options; + var options = params; + var cy = params.cy; + var eles = options.eles; + var nodes = eles.nodes().not(':parent'); + if (options.sort) { + nodes = nodes.sort(options.sort); + } + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + if (bb.h === 0 || bb.w === 0) { + eles.nodes().layoutPositions(this, options, function (ele) { + return { + x: bb.x1, + y: bb.y1 + }; + }); + } else { + // width/height * splits^2 = cells where splits is number of times to split width + var cells = nodes.size(); + var splits = Math.sqrt(cells * bb.h / bb.w); + var rows = Math.round(splits); + var cols = Math.round(bb.w / bb.h * splits); + var small = function small(val) { + if (val == null) { + return Math.min(rows, cols); + } else { + var min = Math.min(rows, cols); + if (min == rows) { + rows = val; + } else { + cols = val; + } + } + }; + var large = function large(val) { + if (val == null) { + return Math.max(rows, cols); + } else { + var max = Math.max(rows, cols); + if (max == rows) { + rows = val; + } else { + cols = val; + } + } + }; + var oRows = options.rows; + var oCols = options.cols != null ? options.cols : options.columns; + + // if rows or columns were set in options, use those values + if (oRows != null && oCols != null) { + rows = oRows; + cols = oCols; + } else if (oRows != null && oCols == null) { + rows = oRows; + cols = Math.ceil(cells / rows); + } else if (oRows == null && oCols != null) { + cols = oCols; + rows = Math.ceil(cells / cols); + } + + // otherwise use the automatic values and adjust accordingly + + // if rounding was up, see if we can reduce rows or columns + else if (cols * rows > cells) { + var sm = small(); + var lg = large(); + + // reducing the small side takes away the most cells, so try it first + if ((sm - 1) * lg >= cells) { + small(sm - 1); + } else if ((lg - 1) * sm >= cells) { + large(lg - 1); + } + } else { + // if rounding was too low, add rows or columns + while (cols * rows < cells) { + var _sm = small(); + var _lg = large(); + + // try to add to larger side first (adds less in multiplication) + if ((_lg + 1) * _sm >= cells) { + large(_lg + 1); + } else { + small(_sm + 1); + } + } + } + var cellWidth = bb.w / cols; + var cellHeight = bb.h / rows; + if (options.condense) { + cellWidth = 0; + cellHeight = 0; + } + if (options.avoidOverlap) { + for (var i = 0; i < nodes.length; i++) { + var node = nodes[i]; + var pos = node._private.position; + if (pos.x == null || pos.y == null) { + // for bb + pos.x = 0; + pos.y = 0; + } + var nbb = node.layoutDimensions(options); + var p = options.avoidOverlapPadding; + var w = nbb.w + p; + var h = nbb.h + p; + cellWidth = Math.max(cellWidth, w); + cellHeight = Math.max(cellHeight, h); + } + } + var cellUsed = {}; // e.g. 'c-0-2' => true + + var used = function used(row, col) { + return cellUsed['c-' + row + '-' + col] ? true : false; + }; + var use = function use(row, col) { + cellUsed['c-' + row + '-' + col] = true; + }; + + // to keep track of current cell position + var row = 0; + var col = 0; + var moveToNextCell = function moveToNextCell() { + col++; + if (col >= cols) { + col = 0; + row++; + } + }; + + // get a cache of all the manual positions + var id2manPos = {}; + for (var _i = 0; _i < nodes.length; _i++) { + var _node = nodes[_i]; + var rcPos = options.position(_node); + if (rcPos && (rcPos.row !== undefined || rcPos.col !== undefined)) { + // must have at least row or col def'd + var _pos = { + row: rcPos.row, + col: rcPos.col + }; + if (_pos.col === undefined) { + // find unused col + _pos.col = 0; + while (used(_pos.row, _pos.col)) { + _pos.col++; + } + } else if (_pos.row === undefined) { + // find unused row + _pos.row = 0; + while (used(_pos.row, _pos.col)) { + _pos.row++; + } + } + id2manPos[_node.id()] = _pos; + use(_pos.row, _pos.col); + } + } + var getPos = function getPos(element, i) { + var x, y; + if (element.locked() || element.isParent()) { + return false; + } + + // see if we have a manual position set + var rcPos = id2manPos[element.id()]; + if (rcPos) { + x = rcPos.col * cellWidth + cellWidth / 2 + bb.x1; + y = rcPos.row * cellHeight + cellHeight / 2 + bb.y1; + } else { + // otherwise set automatically + + while (used(row, col)) { + moveToNextCell(); + } + x = col * cellWidth + cellWidth / 2 + bb.x1; + y = row * cellHeight + cellHeight / 2 + bb.y1; + use(row, col); + moveToNextCell(); + } + return { + x: x, + y: y + }; + }; + nodes.layoutPositions(this, options, getPos); + } + return this; // chaining +}; + +// default layout options +var defaults$2 = { + ready: function ready() {}, + // on layoutready + stop: function stop() {} // on layoutstop +}; + +// constructor +// options : object containing layout options +function NullLayout(options) { + this.options = extend({}, defaults$2, options); +} + +// runs the layout +NullLayout.prototype.run = function () { + var options = this.options; + var eles = options.eles; // elements to consider in the layout + var layout = this; + + // cy is automatically populated for us in the constructor + // (disable eslint for next line as this serves as example layout code to external developers) + // eslint-disable-next-line no-unused-vars + options.cy; + layout.emit('layoutstart'); + + // puts all nodes at (0, 0) + // n.b. most layouts would use layoutPositions(), instead of positions() and manual events + eles.nodes().positions(function () { + return { + x: 0, + y: 0 + }; + }); + + // trigger layoutready when each node has had its position set at least once + layout.one('layoutready', options.ready); + layout.emit('layoutready'); + + // trigger layoutstop when the layout stops (e.g. finishes) + layout.one('layoutstop', options.stop); + layout.emit('layoutstop'); + return this; // chaining +}; + +// called on continuous layouts to stop them before they finish +NullLayout.prototype.stop = function () { + return this; // chaining +}; + +var defaults$1 = { + positions: undefined, + // map of (node id) => (position obj); or function(node){ return somPos; } + zoom: undefined, + // the zoom level to set (prob want fit = false if set) + pan: undefined, + // the pan level to set (prob want fit = false if set) + fit: true, + // whether to fit to viewport + padding: 30, + // padding on fit + spacingFactor: undefined, + // Applies a multiplicative factor (>0) to expand or compress the overall area that the nodes take up + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function PresetLayout(options) { + this.options = extend({}, defaults$1, options); +} +PresetLayout.prototype.run = function () { + var options = this.options; + var eles = options.eles; + var nodes = eles.nodes(); + var posIsFn = fn$6(options.positions); + function getPosition(node) { + if (options.positions == null) { + return copyPosition(node.position()); + } + if (posIsFn) { + return options.positions(node); + } + var pos = options.positions[node._private.data.id]; + if (pos == null) { + return null; + } + return pos; + } + nodes.layoutPositions(this, options, function (node, i) { + var position = getPosition(node); + if (node.locked() || position == null) { + return false; + } + return position; + }); + return this; // chaining +}; + +var defaults = { + fit: true, + // whether to fit to viewport + padding: 30, + // fit padding + boundingBox: undefined, + // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h } + animate: false, + // whether to transition the node positions + animationDuration: 500, + // duration of animation in ms if enabled + animationEasing: undefined, + // easing of animation if enabled + animateFilter: function animateFilter(node, i) { + return true; + }, + // a function that determines whether the node should be animated. All nodes animated by default on animate enabled. Non-animated nodes are positioned immediately when the layout starts + ready: undefined, + // callback on layoutready + stop: undefined, + // callback on layoutstop + transform: function transform(node, position) { + return position; + } // transform a given node position. Useful for changing flow direction in discrete layouts +}; + +function RandomLayout(options) { + this.options = extend({}, defaults, options); +} +RandomLayout.prototype.run = function () { + var options = this.options; + var cy = options.cy; + var eles = options.eles; + var bb = makeBoundingBox(options.boundingBox ? options.boundingBox : { + x1: 0, + y1: 0, + w: cy.width(), + h: cy.height() + }); + var getPos = function getPos(node, i) { + return { + x: bb.x1 + Math.round(Math.random() * bb.w), + y: bb.y1 + Math.round(Math.random() * bb.h) + }; + }; + eles.nodes().layoutPositions(this, options, getPos); + return this; // chaining +}; + +var layout = [{ + name: 'breadthfirst', + impl: BreadthFirstLayout +}, { + name: 'circle', + impl: CircleLayout +}, { + name: 'concentric', + impl: ConcentricLayout +}, { + name: 'cose', + impl: CoseLayout +}, { + name: 'grid', + impl: GridLayout +}, { + name: 'null', + impl: NullLayout +}, { + name: 'preset', + impl: PresetLayout +}, { + name: 'random', + impl: RandomLayout +}]; + +function NullRenderer(options) { + this.options = options; + this.notifications = 0; // for testing +} + +var noop = function noop() {}; +var throwImgErr = function throwImgErr() { + throw new Error('A headless instance can not render images'); +}; +NullRenderer.prototype = { + recalculateRenderedStyle: noop, + notify: function notify() { + this.notifications++; + }, + init: noop, + isHeadless: function isHeadless() { + return true; + }, + png: throwImgErr, + jpg: throwImgErr +}; + +var BRp$f = {}; +BRp$f.arrowShapeWidth = 0.3; +BRp$f.registerArrowShapes = function () { + var arrowShapes = this.arrowShapes = {}; + var renderer = this; + + // Contract for arrow shapes: + // 0, 0 is arrow tip + // (0, 1) is direction towards node + // (1, 0) is right + // + // functional api: + // collide: check x, y in shape + // roughCollide: called before collide, no false negatives + // draw: draw + // spacing: dist(arrowTip, nodeBoundary) + // gap: dist(edgeTip, nodeBoundary), edgeTip may != arrowTip + + var bbCollide = function bbCollide(x, y, size, angle, translation, edgeWidth, padding) { + var x1 = translation.x - size / 2 - padding; + var x2 = translation.x + size / 2 + padding; + var y1 = translation.y - size / 2 - padding; + var y2 = translation.y + size / 2 + padding; + var inside = x1 <= x && x <= x2 && y1 <= y && y <= y2; + return inside; + }; + var transform = function transform(x, y, size, angle, translation) { + var xRotated = x * Math.cos(angle) - y * Math.sin(angle); + var yRotated = x * Math.sin(angle) + y * Math.cos(angle); + var xScaled = xRotated * size; + var yScaled = yRotated * size; + var xTranslated = xScaled + translation.x; + var yTranslated = yScaled + translation.y; + return { + x: xTranslated, + y: yTranslated + }; + }; + var transformPoints = function transformPoints(pts, size, angle, translation) { + var retPts = []; + for (var i = 0; i < pts.length; i += 2) { + var x = pts[i]; + var y = pts[i + 1]; + retPts.push(transform(x, y, size, angle, translation)); + } + return retPts; + }; + var pointsToArr = function pointsToArr(pts) { + var ret = []; + for (var i = 0; i < pts.length; i++) { + var p = pts[i]; + ret.push(p.x, p.y); + } + return ret; + }; + var standardGap = function standardGap(edge) { + return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').pfValue * 2; + }; + var defineArrowShape = function defineArrowShape(name, defn) { + if (string(defn)) { + defn = arrowShapes[defn]; + } + arrowShapes[name] = extend({ + name: name, + points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3], + collide: function collide(x, y, size, angle, translation, padding) { + var points = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, points); + return inside; + }, + roughCollide: bbCollide, + draw: function draw(context, size, angle, translation) { + var points = transformPoints(this.points, size, angle, translation); + renderer.arrowShapeImpl('polygon')(context, points); + }, + spacing: function spacing(edge) { + return 0; + }, + gap: standardGap + }, defn); + }; + defineArrowShape('none', { + collide: falsify, + roughCollide: falsify, + draw: noop$1, + spacing: zeroify, + gap: zeroify + }); + defineArrowShape('triangle', { + points: [-0.15, -0.3, 0, 0, 0.15, -0.3] + }); + defineArrowShape('arrow', 'triangle'); + defineArrowShape('triangle-backcurve', { + points: arrowShapes['triangle'].points, + controlPoint: [0, -0.15], + roughCollide: bbCollide, + draw: function draw(context, size, angle, translation, edgeWidth) { + var ptsTrans = transformPoints(this.points, size, angle, translation); + var ctrlPt = this.controlPoint; + var ctrlPtTrans = transform(ctrlPt[0], ctrlPt[1], size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, ptsTrans, ctrlPtTrans); + }, + gap: function gap(edge) { + return standardGap(edge) * 0.8; + } + }); + defineArrowShape('triangle-tee', { + points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0], + pointsTee: [-0.15, -0.4, -0.15, -0.5, 0.15, -0.5, 0.15, -0.4], + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var teePts = pointsToArr(transformPoints(this.pointsTee, size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, triPts) || pointInsidePolygonPoints(x, y, teePts); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.points, size, angle, translation); + var teePts = transformPoints(this.pointsTee, size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, teePts); + } + }); + defineArrowShape('circle-triangle', { + radius: 0.15, + pointsTr: [0, -0.15, 0.15, -0.45, -0.15, -0.45, 0, -0.15], + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var t = translation; + var circleInside = Math.pow(t.x - x, 2) + Math.pow(t.y - y, 2) <= Math.pow((size + 2 * padding) * this.radius, 2); + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + return pointInsidePolygonPoints(x, y, triPts) || circleInside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.pointsTr, size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, translation.x, translation.y, this.radius * size); + }, + spacing: function spacing(edge) { + return renderer.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.radius; + } + }); + defineArrowShape('triangle-cross', { + points: [0, 0, 0.15, -0.3, -0.15, -0.3, 0, 0], + baseCrossLinePts: [-0.15, -0.4, + // first half of the rectangle + -0.15, -0.4, 0.15, -0.4, + // second half of the rectangle + 0.15, -0.4], + crossLinePts: function crossLinePts(size, edgeWidth) { + // shift points so that the distance between the cross points matches edge width + var p = this.baseCrossLinePts.slice(); + var shiftFactor = edgeWidth / size; + var y0 = 3; + var y1 = 5; + p[y0] = p[y0] - shiftFactor; + p[y1] = p[y1] - shiftFactor; + return p; + }, + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var triPts = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation)); + var teePts = pointsToArr(transformPoints(this.crossLinePts(size, edgeWidth), size + 2 * padding, angle, translation)); + var inside = pointInsidePolygonPoints(x, y, triPts) || pointInsidePolygonPoints(x, y, teePts); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + var triPts = transformPoints(this.points, size, angle, translation); + var crossLinePts = transformPoints(this.crossLinePts(size, edgeWidth), size, angle, translation); + renderer.arrowShapeImpl(this.name)(context, triPts, crossLinePts); + } + }); + defineArrowShape('vee', { + points: [-0.15, -0.3, 0, 0, 0.15, -0.3, 0, -0.15], + gap: function gap(edge) { + return standardGap(edge) * 0.525; + } + }); + defineArrowShape('circle', { + radius: 0.15, + collide: function collide(x, y, size, angle, translation, edgeWidth, padding) { + var t = translation; + var inside = Math.pow(t.x - x, 2) + Math.pow(t.y - y, 2) <= Math.pow((size + 2 * padding) * this.radius, 2); + return inside; + }, + draw: function draw(context, size, angle, translation, edgeWidth) { + renderer.arrowShapeImpl(this.name)(context, translation.x, translation.y, this.radius * size); + }, + spacing: function spacing(edge) { + return renderer.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.radius; + } + }); + defineArrowShape('tee', { + points: [-0.15, 0, -0.15, -0.1, 0.15, -0.1, 0.15, 0], + spacing: function spacing(edge) { + return 1; + }, + gap: function gap(edge) { + return 1; + } + }); + defineArrowShape('square', { + points: [-0.15, 0.00, 0.15, 0.00, 0.15, -0.3, -0.15, -0.3] + }); + defineArrowShape('diamond', { + points: [-0.15, -0.15, 0, -0.3, 0.15, -0.15, 0, 0], + gap: function gap(edge) { + return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').value; + } + }); + defineArrowShape('chevron', { + points: [0, 0, -0.15, -0.15, -0.1, -0.2, 0, -0.1, 0.1, -0.2, 0.15, -0.15], + gap: function gap(edge) { + return 0.95 * edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').value; + } + }); +}; + +var BRp$e = {}; + +// Project mouse +BRp$e.projectIntoViewport = function (clientX, clientY) { + var cy = this.cy; + var offsets = this.findContainerClientCoords(); + var offsetLeft = offsets[0]; + var offsetTop = offsets[1]; + var scale = offsets[4]; + var pan = cy.pan(); + var zoom = cy.zoom(); + var x = ((clientX - offsetLeft) / scale - pan.x) / zoom; + var y = ((clientY - offsetTop) / scale - pan.y) / zoom; + return [x, y]; +}; +BRp$e.findContainerClientCoords = function () { + if (this.containerBB) { + return this.containerBB; + } + var container = this.container; + var rect = container.getBoundingClientRect(); + var style = this.cy.window().getComputedStyle(container); + var styleValue = function styleValue(name) { + return parseFloat(style.getPropertyValue(name)); + }; + var padding = { + left: styleValue('padding-left'), + right: styleValue('padding-right'), + top: styleValue('padding-top'), + bottom: styleValue('padding-bottom') + }; + var border = { + left: styleValue('border-left-width'), + right: styleValue('border-right-width'), + top: styleValue('border-top-width'), + bottom: styleValue('border-bottom-width') + }; + var clientWidth = container.clientWidth; + var clientHeight = container.clientHeight; + var paddingHor = padding.left + padding.right; + var paddingVer = padding.top + padding.bottom; + var borderHor = border.left + border.right; + var scale = rect.width / (clientWidth + borderHor); + var unscaledW = clientWidth - paddingHor; + var unscaledH = clientHeight - paddingVer; + var left = rect.left + padding.left + border.left; + var top = rect.top + padding.top + border.top; + return this.containerBB = [left, top, unscaledW, unscaledH, scale]; +}; +BRp$e.invalidateContainerClientCoordsCache = function () { + this.containerBB = null; +}; +BRp$e.findNearestElement = function (x, y, interactiveElementsOnly, isTouch) { + return this.findNearestElements(x, y, interactiveElementsOnly, isTouch)[0]; +}; +BRp$e.findNearestElements = function (x, y, interactiveElementsOnly, isTouch) { + var self = this; + var r = this; + var eles = r.getCachedZSortedEles(); + var near = []; // 1 node max, 1 edge max + var zoom = r.cy.zoom(); + var hasCompounds = r.cy.hasCompoundNodes(); + var edgeThreshold = (isTouch ? 24 : 8) / zoom; + var nodeThreshold = (isTouch ? 8 : 2) / zoom; + var labelThreshold = (isTouch ? 8 : 2) / zoom; + var minSqDist = Infinity; + var nearEdge; + var nearNode; + if (interactiveElementsOnly) { + eles = eles.interactive; + } + function addEle(ele, sqDist) { + if (ele.isNode()) { + if (nearNode) { + return; // can't replace node + } else { + nearNode = ele; + near.push(ele); + } + } + if (ele.isEdge() && (sqDist == null || sqDist < minSqDist)) { + if (nearEdge) { + // then replace existing edge + // can replace only if same z-index + if (nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value && nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value) { + for (var i = 0; i < near.length; i++) { + if (near[i].isEdge()) { + near[i] = ele; + nearEdge = ele; + minSqDist = sqDist != null ? sqDist : minSqDist; + break; + } + } + } + } else { + near.push(ele); + nearEdge = ele; + minSqDist = sqDist != null ? sqDist : minSqDist; + } + } + } + function checkNode(node) { + var width = node.outerWidth() + 2 * nodeThreshold; + var height = node.outerHeight() + 2 * nodeThreshold; + var hw = width / 2; + var hh = height / 2; + var pos = node.position(); + var cornerRadius = node.pstyle('corner-radius').value === 'auto' ? 'auto' : node.pstyle('corner-radius').pfValue; + var rs = node._private.rscratch; + if (pos.x - hw <= x && x <= pos.x + hw // bb check x + && pos.y - hh <= y && y <= pos.y + hh // bb check y + ) { + var shape = r.nodeShapes[self.getNodeShape(node)]; + if (shape.checkPoint(x, y, 0, width, height, pos.x, pos.y, cornerRadius, rs)) { + addEle(node, 0); + return true; + } + } + } + function checkEdge(edge) { + var _p = edge._private; + var rs = _p.rscratch; + var styleWidth = edge.pstyle('width').pfValue; + var scale = edge.pstyle('arrow-scale').value; + var width = styleWidth / 2 + edgeThreshold; // more like a distance radius from centre + var widthSq = width * width; + var width2 = width * 2; + var src = _p.source; + var tgt = _p.target; + var sqDist; + if (rs.edgeType === 'segments' || rs.edgeType === 'straight' || rs.edgeType === 'haystack') { + var pts = rs.allpts; + for (var i = 0; i + 3 < pts.length; i += 2) { + if (inLineVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], width2) && widthSq > (sqDist = sqdistToFiniteLine(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3]))) { + addEle(edge, sqDist); + return true; + } + } + } else if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') { + var pts = rs.allpts; + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + if (inBezierVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5], width2) && widthSq > (sqDist = sqdistToQuadraticBezier(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5]))) { + addEle(edge, sqDist); + return true; + } + } + } + + // if we're close to the edge but didn't hit it, maybe we hit its arrows + + var src = src || _p.source; + var tgt = tgt || _p.target; + var arSize = self.getArrowWidth(styleWidth, scale); + var arrows = [{ + name: 'source', + x: rs.arrowStartX, + y: rs.arrowStartY, + angle: rs.srcArrowAngle + }, { + name: 'target', + x: rs.arrowEndX, + y: rs.arrowEndY, + angle: rs.tgtArrowAngle + }, { + name: 'mid-source', + x: rs.midX, + y: rs.midY, + angle: rs.midsrcArrowAngle + }, { + name: 'mid-target', + x: rs.midX, + y: rs.midY, + angle: rs.midtgtArrowAngle + }]; + for (var i = 0; i < arrows.length; i++) { + var ar = arrows[i]; + var shape = r.arrowShapes[edge.pstyle(ar.name + '-arrow-shape').value]; + var edgeWidth = edge.pstyle('width').pfValue; + if (shape.roughCollide(x, y, arSize, ar.angle, { + x: ar.x, + y: ar.y + }, edgeWidth, edgeThreshold) && shape.collide(x, y, arSize, ar.angle, { + x: ar.x, + y: ar.y + }, edgeWidth, edgeThreshold)) { + addEle(edge); + return true; + } + } + + // for compound graphs, hitting edge may actually want a connected node instead (b/c edge may have greater z-index precedence) + if (hasCompounds && near.length > 0) { + checkNode(src); + checkNode(tgt); + } + } + function preprop(obj, name, pre) { + return getPrefixedProperty(obj, name, pre); + } + function checkLabel(ele, prefix) { + var _p = ele._private; + var th = labelThreshold; + var prefixDash; + if (prefix) { + prefixDash = prefix + '-'; + } else { + prefixDash = ''; + } + ele.boundingBox(); + var bb = _p.labelBounds[prefix || 'main']; + var text = ele.pstyle(prefixDash + 'label').value; + var eventsEnabled = ele.pstyle('text-events').strValue === 'yes'; + if (!eventsEnabled || !text) { + return; + } + var lx = preprop(_p.rscratch, 'labelX', prefix); + var ly = preprop(_p.rscratch, 'labelY', prefix); + var theta = preprop(_p.rscratch, 'labelAngle', prefix); + var ox = ele.pstyle(prefixDash + 'text-margin-x').pfValue; + var oy = ele.pstyle(prefixDash + 'text-margin-y').pfValue; + var lx1 = bb.x1 - th - ox; // (-ox, -oy) as bb already includes margin + var lx2 = bb.x2 + th - ox; // and rotation is about (lx, ly) + var ly1 = bb.y1 - th - oy; + var ly2 = bb.y2 + th - oy; + if (theta) { + var cos = Math.cos(theta); + var sin = Math.sin(theta); + var rotate = function rotate(x, y) { + x = x - lx; + y = y - ly; + return { + x: x * cos - y * sin + lx, + y: x * sin + y * cos + ly + }; + }; + var px1y1 = rotate(lx1, ly1); + var px1y2 = rotate(lx1, ly2); + var px2y1 = rotate(lx2, ly1); + var px2y2 = rotate(lx2, ly2); + var points = [ + // with the margin added after the rotation is applied + px1y1.x + ox, px1y1.y + oy, px2y1.x + ox, px2y1.y + oy, px2y2.x + ox, px2y2.y + oy, px1y2.x + ox, px1y2.y + oy]; + if (pointInsidePolygonPoints(x, y, points)) { + addEle(ele); + return true; + } + } else { + // do a cheaper bb check + if (inBoundingBox(bb, x, y)) { + addEle(ele); + return true; + } + } + } + for (var i = eles.length - 1; i >= 0; i--) { + // reverse order for precedence + var ele = eles[i]; + if (ele.isNode()) { + checkNode(ele) || checkLabel(ele); + } else { + // then edge + checkEdge(ele) || checkLabel(ele) || checkLabel(ele, 'source') || checkLabel(ele, 'target'); + } + } + return near; +}; + +// 'Give me everything from this box' +BRp$e.getAllInBox = function (x1, y1, x2, y2) { + var eles = this.getCachedZSortedEles().interactive; + var box = []; + var x1c = Math.min(x1, x2); + var x2c = Math.max(x1, x2); + var y1c = Math.min(y1, y2); + var y2c = Math.max(y1, y2); + x1 = x1c; + x2 = x2c; + y1 = y1c; + y2 = y2c; + var boxBb = makeBoundingBox({ + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }); + for (var e = 0; e < eles.length; e++) { + var ele = eles[e]; + if (ele.isNode()) { + var node = ele; + var nodeBb = node.boundingBox({ + includeNodes: true, + includeEdges: false, + includeLabels: false + }); + if (boundingBoxesIntersect(boxBb, nodeBb) && !boundingBoxInBoundingBox(nodeBb, boxBb)) { + box.push(node); + } + } else { + var edge = ele; + var _p = edge._private; + var rs = _p.rscratch; + if (rs.startX != null && rs.startY != null && !inBoundingBox(boxBb, rs.startX, rs.startY)) { + continue; + } + if (rs.endX != null && rs.endY != null && !inBoundingBox(boxBb, rs.endX, rs.endY)) { + continue; + } + if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound' || rs.edgeType === 'segments' || rs.edgeType === 'haystack') { + var pts = _p.rstyle.bezierPts || _p.rstyle.linePts || _p.rstyle.haystackPts; + var allInside = true; + for (var i = 0; i < pts.length; i++) { + if (!pointInBoundingBox(boxBb, pts[i])) { + allInside = false; + break; + } + } + if (allInside) { + box.push(edge); + } + } else if (rs.edgeType === 'haystack' || rs.edgeType === 'straight') { + box.push(edge); + } + } + } + return box; +}; + +var BRp$d = {}; +BRp$d.calculateArrowAngles = function (edge) { + var rs = edge._private.rscratch; + var isHaystack = rs.edgeType === 'haystack'; + var isBezier = rs.edgeType === 'bezier'; + var isMultibezier = rs.edgeType === 'multibezier'; + var isSegments = rs.edgeType === 'segments'; + var isCompound = rs.edgeType === 'compound'; + var isSelf = rs.edgeType === 'self'; + + // Displacement gives direction for arrowhead orientation + var dispX, dispY; + var startX, startY, endX, endY, midX, midY; + if (isHaystack) { + startX = rs.haystackPts[0]; + startY = rs.haystackPts[1]; + endX = rs.haystackPts[2]; + endY = rs.haystackPts[3]; + } else { + startX = rs.arrowStartX; + startY = rs.arrowStartY; + endX = rs.arrowEndX; + endY = rs.arrowEndY; + } + midX = rs.midX; + midY = rs.midY; + + // source + // + + if (isSegments) { + dispX = startX - rs.segpts[0]; + dispY = startY - rs.segpts[1]; + } else if (isMultibezier || isCompound || isSelf || isBezier) { + var pts = rs.allpts; + var bX = qbezierAt(pts[0], pts[2], pts[4], 0.1); + var bY = qbezierAt(pts[1], pts[3], pts[5], 0.1); + dispX = startX - bX; + dispY = startY - bY; + } else { + dispX = startX - midX; + dispY = startY - midY; + } + rs.srcArrowAngle = getAngleFromDisp(dispX, dispY); + + // mid target + // + + var midX = rs.midX; + var midY = rs.midY; + if (isHaystack) { + midX = (startX + endX) / 2; + midY = (startY + endY) / 2; + } + dispX = endX - startX; + dispY = endY - startY; + if (isSegments) { + var pts = rs.allpts; + if (pts.length / 2 % 2 === 0) { + var i2 = pts.length / 2; + var i1 = i2 - 2; + dispX = pts[i2] - pts[i1]; + dispY = pts[i2 + 1] - pts[i1 + 1]; + } else if (rs.isRound) { + dispX = rs.midVector[1]; + dispY = -rs.midVector[0]; + } else { + var i2 = pts.length / 2 - 1; + var i1 = i2 - 2; + dispX = pts[i2] - pts[i1]; + dispY = pts[i2 + 1] - pts[i1 + 1]; + } + } else if (isMultibezier || isCompound || isSelf) { + var pts = rs.allpts; + var cpts = rs.ctrlpts; + var bp0x, bp0y; + var bp1x, bp1y; + if (cpts.length / 2 % 2 === 0) { + var p0 = pts.length / 2 - 1; // startpt + var ic = p0 + 2; + var p1 = ic + 2; + bp0x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.0); + bp0y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.0); + bp1x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.0001); + bp1y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.0001); + } else { + var ic = pts.length / 2 - 1; // ctrpt + var p0 = ic - 2; // startpt + var p1 = ic + 2; // endpt + + bp0x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.4999); + bp0y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.4999); + bp1x = qbezierAt(pts[p0], pts[ic], pts[p1], 0.5); + bp1y = qbezierAt(pts[p0 + 1], pts[ic + 1], pts[p1 + 1], 0.5); + } + dispX = bp1x - bp0x; + dispY = bp1y - bp0y; + } + rs.midtgtArrowAngle = getAngleFromDisp(dispX, dispY); + rs.midDispX = dispX; + rs.midDispY = dispY; + + // mid source + // + + dispX *= -1; + dispY *= -1; + if (isSegments) { + var pts = rs.allpts; + if (pts.length / 2 % 2 === 0) ; else if (!rs.isRound) { + var i2 = pts.length / 2 - 1; + var i3 = i2 + 2; + dispX = -(pts[i3] - pts[i2]); + dispY = -(pts[i3 + 1] - pts[i2 + 1]); + } + } + rs.midsrcArrowAngle = getAngleFromDisp(dispX, dispY); + + // target + // + + if (isSegments) { + dispX = endX - rs.segpts[rs.segpts.length - 2]; + dispY = endY - rs.segpts[rs.segpts.length - 1]; + } else if (isMultibezier || isCompound || isSelf || isBezier) { + var pts = rs.allpts; + var l = pts.length; + var bX = qbezierAt(pts[l - 6], pts[l - 4], pts[l - 2], 0.9); + var bY = qbezierAt(pts[l - 5], pts[l - 3], pts[l - 1], 0.9); + dispX = endX - bX; + dispY = endY - bY; + } else { + dispX = endX - midX; + dispY = endY - midY; + } + rs.tgtArrowAngle = getAngleFromDisp(dispX, dispY); +}; +BRp$d.getArrowWidth = BRp$d.getArrowHeight = function (edgeWidth, scale) { + var cache = this.arrowWidthCache = this.arrowWidthCache || {}; + var cachedVal = cache[edgeWidth + ', ' + scale]; + if (cachedVal) { + return cachedVal; + } + cachedVal = Math.max(Math.pow(edgeWidth * 13.37, 0.9), 29) * scale; + cache[edgeWidth + ', ' + scale] = cachedVal; + return cachedVal; +}; + +/** + * Explained by Blindman67 at https://stackoverflow.com/a/44856925/11028828 + */ + +// Declare reused variable to avoid reallocating variables every time the function is called +var x, + y, + v1 = {}, + v2 = {}, + sinA, + sinA90, + radDirection, + drawDirection, + angle, + halfAngle, + cRadius, + lenOut, + radius, + limit; +var startX, startY, stopX, stopY; +var lastPoint; + +// convert 2 points into vector form, polar form, and normalised +var asVec = function asVec(p, pp, v) { + v.x = pp.x - p.x; + v.y = pp.y - p.y; + v.len = Math.sqrt(v.x * v.x + v.y * v.y); + v.nx = v.x / v.len; + v.ny = v.y / v.len; + v.ang = Math.atan2(v.ny, v.nx); +}; +var invertVec = function invertVec(originalV, invertedV) { + invertedV.x = originalV.x * -1; + invertedV.y = originalV.y * -1; + invertedV.nx = originalV.nx * -1; + invertedV.ny = originalV.ny * -1; + invertedV.ang = originalV.ang > 0 ? -(Math.PI - originalV.ang) : Math.PI + originalV.ang; +}; +var calcCornerArc = function calcCornerArc(previousPoint, currentPoint, nextPoint, radiusMax, isArcRadius) { + //----------------------------------------- + // Part 1 + previousPoint !== lastPoint ? asVec(currentPoint, previousPoint, v1) : invertVec(v2, v1); // Avoid recalculating vec if it is the invert of the last one calculated + asVec(currentPoint, nextPoint, v2); + sinA = v1.nx * v2.ny - v1.ny * v2.nx; + sinA90 = v1.nx * v2.nx - v1.ny * -v2.ny; + angle = Math.asin(Math.max(-1, Math.min(1, sinA))); + if (Math.abs(angle) < 1e-6) { + x = currentPoint.x; + y = currentPoint.y; + cRadius = radius = 0; + return; + } + //----------------------------------------- + radDirection = 1; + drawDirection = false; + if (sinA90 < 0) { + if (angle < 0) { + angle = Math.PI + angle; + } else { + angle = Math.PI - angle; + radDirection = -1; + drawDirection = true; + } + } else { + if (angle > 0) { + radDirection = -1; + drawDirection = true; + } + } + if (currentPoint.radius !== undefined) { + radius = currentPoint.radius; + } else { + radius = radiusMax; + } + //----------------------------------------- + // Part 2 + halfAngle = angle / 2; + //----------------------------------------- + + limit = Math.min(v1.len / 2, v2.len / 2); + if (isArcRadius) { + //----------------------------------------- + // Part 3 + lenOut = Math.abs(Math.cos(halfAngle) * radius / Math.sin(halfAngle)); + + //----------------------------------------- + // Special part A + if (lenOut > limit) { + lenOut = limit; + cRadius = Math.abs(lenOut * Math.sin(halfAngle) / Math.cos(halfAngle)); + } else { + cRadius = radius; + } + } else { + lenOut = Math.min(limit, radius); + cRadius = Math.abs(lenOut * Math.sin(halfAngle) / Math.cos(halfAngle)); + } + //----------------------------------------- + + //----------------------------------------- + // Part 4 + stopX = currentPoint.x + v2.nx * lenOut; + stopY = currentPoint.y + v2.ny * lenOut; + //----------------------------------------- + // Part 5 + x = stopX - v2.ny * cRadius * radDirection; + y = stopY + v2.nx * cRadius * radDirection; + //----------------------------------------- + // Additional Part : calculate start point E + startX = currentPoint.x + v1.nx * lenOut; + startY = currentPoint.y + v1.ny * lenOut; + + // Save last point to avoid recalculating vector when not needed + lastPoint = currentPoint; +}; + +/** + * Draw corner provided by {@link getRoundCorner} + * + * @param ctx :CanvasRenderingContext2D + * @param roundCorner {{cx:number, cy:number, radius:number, endAngle: number, startAngle: number, counterClockwise: boolean}} + */ +function drawPreparedRoundCorner(ctx, roundCorner) { + if (roundCorner.radius === 0) ctx.lineTo(roundCorner.cx, roundCorner.cy);else ctx.arc(roundCorner.cx, roundCorner.cy, roundCorner.radius, roundCorner.startAngle, roundCorner.endAngle, roundCorner.counterClockwise); +} + +/** + * Get round corner from a point and its previous and next neighbours in a path + * + * @param previousPoint {{x: number, y:number, radius: number?}} + * @param currentPoint {{x: number, y:number, radius: number?}} + * @param nextPoint {{x: number, y:number, radius: number?}} + * @param radiusMax :number + * @param isArcRadius :boolean + * @return {{ + * cx:number, cy:number, radius:number, + * startX:number, startY:number, + * stopX:number, stopY: number, + * endAngle: number, startAngle: number, counterClockwise: boolean + * }} + */ +function getRoundCorner(previousPoint, currentPoint, nextPoint, radiusMax) { + var isArcRadius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + if (radiusMax === 0 || currentPoint.radius === 0) return { + cx: currentPoint.x, + cy: currentPoint.y, + radius: 0, + startX: currentPoint.x, + startY: currentPoint.y, + stopX: currentPoint.x, + stopY: currentPoint.y, + startAngle: undefined, + endAngle: undefined, + counterClockwise: undefined + }; + calcCornerArc(previousPoint, currentPoint, nextPoint, radiusMax, isArcRadius); + return { + cx: x, + cy: y, + radius: cRadius, + startX: startX, + startY: startY, + stopX: stopX, + stopY: stopY, + startAngle: v1.ang + Math.PI / 2 * radDirection, + endAngle: v2.ang - Math.PI / 2 * radDirection, + counterClockwise: drawDirection + }; +} + +var BRp$c = {}; +BRp$c.findMidptPtsEtc = function (edge, pairInfo) { + var posPts = pairInfo.posPts, + intersectionPts = pairInfo.intersectionPts, + vectorNormInverse = pairInfo.vectorNormInverse; + var midptPts; + + // n.b. assumes all edges in bezier bundle have same endpoints specified + var srcManEndpt = edge.pstyle('source-endpoint'); + var tgtManEndpt = edge.pstyle('target-endpoint'); + var haveManualEndPts = srcManEndpt.units != null && tgtManEndpt.units != null; + var recalcVectorNormInverse = function recalcVectorNormInverse(x1, y1, x2, y2) { + var dy = y2 - y1; + var dx = x2 - x1; + var l = Math.sqrt(dx * dx + dy * dy); + return { + x: -dy / l, + y: dx / l + }; + }; + var edgeDistances = edge.pstyle('edge-distances').value; + switch (edgeDistances) { + case 'node-position': + midptPts = posPts; + break; + case 'intersection': + midptPts = intersectionPts; + break; + case 'endpoints': + { + if (haveManualEndPts) { + var _this$manualEndptToPx = this.manualEndptToPx(edge.source()[0], srcManEndpt), + _this$manualEndptToPx2 = _slicedToArray(_this$manualEndptToPx, 2), + x1 = _this$manualEndptToPx2[0], + y1 = _this$manualEndptToPx2[1]; + var _this$manualEndptToPx3 = this.manualEndptToPx(edge.target()[0], tgtManEndpt), + _this$manualEndptToPx4 = _slicedToArray(_this$manualEndptToPx3, 2), + x2 = _this$manualEndptToPx4[0], + y2 = _this$manualEndptToPx4[1]; + var endPts = { + x1: x1, + y1: y1, + x2: x2, + y2: y2 + }; + vectorNormInverse = recalcVectorNormInverse(x1, y1, x2, y2); + midptPts = endPts; + } else { + warn("Edge ".concat(edge.id(), " has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")); + midptPts = intersectionPts; // back to default + } + + break; + } + } + return { + midptPts: midptPts, + vectorNormInverse: vectorNormInverse + }; +}; +BRp$c.findHaystackPoints = function (edges) { + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var _p = edge._private; + var rs = _p.rscratch; + if (!rs.haystack) { + var angle = Math.random() * 2 * Math.PI; + rs.source = { + x: Math.cos(angle), + y: Math.sin(angle) + }; + angle = Math.random() * 2 * Math.PI; + rs.target = { + x: Math.cos(angle), + y: Math.sin(angle) + }; + } + var src = _p.source; + var tgt = _p.target; + var srcPos = src.position(); + var tgtPos = tgt.position(); + var srcW = src.width(); + var tgtW = tgt.width(); + var srcH = src.height(); + var tgtH = tgt.height(); + var radius = edge.pstyle('haystack-radius').value; + var halfRadius = radius / 2; // b/c have to half width/height + + rs.haystackPts = rs.allpts = [rs.source.x * srcW * halfRadius + srcPos.x, rs.source.y * srcH * halfRadius + srcPos.y, rs.target.x * tgtW * halfRadius + tgtPos.x, rs.target.y * tgtH * halfRadius + tgtPos.y]; + rs.midX = (rs.allpts[0] + rs.allpts[2]) / 2; + rs.midY = (rs.allpts[1] + rs.allpts[3]) / 2; + + // always override as haystack in case set to different type previously + rs.edgeType = 'haystack'; + rs.haystack = true; + this.storeEdgeProjections(edge); + this.calculateArrowAngles(edge); + this.recalculateEdgeLabelProjections(edge); + this.calculateLabelAngles(edge); + } +}; +BRp$c.findSegmentsPoints = function (edge, pairInfo) { + // Segments (multiple straight lines) + + var rs = edge._private.rscratch; + var segmentWs = edge.pstyle('segment-weights'); + var segmentDs = edge.pstyle('segment-distances'); + var segmentRs = edge.pstyle('segment-radii'); + var segmentTs = edge.pstyle('radius-type'); + var segmentsN = Math.min(segmentWs.pfValue.length, segmentDs.pfValue.length); + var lastRadius = segmentRs.pfValue[segmentRs.pfValue.length - 1]; + var lastRadiusType = segmentTs.pfValue[segmentTs.pfValue.length - 1]; + rs.edgeType = 'segments'; + rs.segpts = []; + rs.radii = []; + rs.isArcRadius = []; + for (var s = 0; s < segmentsN; s++) { + var w = segmentWs.pfValue[s]; + var d = segmentDs.pfValue[s]; + var w1 = 1 - w; + var w2 = w; + var _this$findMidptPtsEtc = this.findMidptPtsEtc(edge, pairInfo), + midptPts = _this$findMidptPtsEtc.midptPts, + vectorNormInverse = _this$findMidptPtsEtc.vectorNormInverse; + var adjustedMidpt = { + x: midptPts.x1 * w1 + midptPts.x2 * w2, + y: midptPts.y1 * w1 + midptPts.y2 * w2 + }; + rs.segpts.push(adjustedMidpt.x + vectorNormInverse.x * d, adjustedMidpt.y + vectorNormInverse.y * d); + rs.radii.push(segmentRs.pfValue[s] !== undefined ? segmentRs.pfValue[s] : lastRadius); + rs.isArcRadius.push((segmentTs.pfValue[s] !== undefined ? segmentTs.pfValue[s] : lastRadiusType) === 'arc-radius'); + } +}; +BRp$c.findLoopPoints = function (edge, pairInfo, i, edgeIsUnbundled) { + // Self-edge + + var rs = edge._private.rscratch; + var dirCounts = pairInfo.dirCounts, + srcPos = pairInfo.srcPos; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var loopDir = edge.pstyle('loop-direction').pfValue; + var loopSwp = edge.pstyle('loop-sweep').pfValue; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + rs.edgeType = 'self'; + var j = i; + var loopDist = stepSize; + if (edgeIsUnbundled) { + j = 0; + loopDist = ctrlptDist; + } + var loopAngle = loopDir - Math.PI / 2; + var outAngle = loopAngle - loopSwp / 2; + var inAngle = loopAngle + loopSwp / 2; + + // increase by step size for overlapping loops, keyed on direction and sweep values + var dc = String(loopDir + '_' + loopSwp); + j = dirCounts[dc] === undefined ? dirCounts[dc] = 0 : ++dirCounts[dc]; + rs.ctrlpts = [srcPos.x + Math.cos(outAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.y + Math.sin(outAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.x + Math.cos(inAngle) * 1.4 * loopDist * (j / 3 + 1), srcPos.y + Math.sin(inAngle) * 1.4 * loopDist * (j / 3 + 1)]; +}; +BRp$c.findCompoundLoopPoints = function (edge, pairInfo, i, edgeIsUnbundled) { + // Compound edge + + var rs = edge._private.rscratch; + rs.edgeType = 'compound'; + var srcPos = pairInfo.srcPos, + tgtPos = pairInfo.tgtPos, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var j = i; + var loopDist = stepSize; + if (edgeIsUnbundled) { + j = 0; + loopDist = ctrlptDist; + } + var loopW = 50; + var loopaPos = { + x: srcPos.x - srcW / 2, + y: srcPos.y - srcH / 2 + }; + var loopbPos = { + x: tgtPos.x - tgtW / 2, + y: tgtPos.y - tgtH / 2 + }; + var loopPos = { + x: Math.min(loopaPos.x, loopbPos.x), + y: Math.min(loopaPos.y, loopbPos.y) + }; + + // avoids cases with impossible beziers + var minCompoundStretch = 0.5; + var compoundStretchA = Math.max(minCompoundStretch, Math.log(srcW * 0.01)); + var compoundStretchB = Math.max(minCompoundStretch, Math.log(tgtW * 0.01)); + rs.ctrlpts = [loopPos.x, loopPos.y - (1 + Math.pow(loopW, 1.12) / 100) * loopDist * (j / 3 + 1) * compoundStretchA, loopPos.x - (1 + Math.pow(loopW, 1.12) / 100) * loopDist * (j / 3 + 1) * compoundStretchB, loopPos.y]; +}; +BRp$c.findStraightEdgePoints = function (edge) { + // Straight edge within bundle + + edge._private.rscratch.edgeType = 'straight'; +}; +BRp$c.findBezierPoints = function (edge, pairInfo, i, edgeIsUnbundled, edgeIsSwapped) { + var rs = edge._private.rscratch; + var stepSize = edge.pstyle('control-point-step-size').pfValue; + var ctrlptDists = edge.pstyle('control-point-distances'); + var ctrlptWs = edge.pstyle('control-point-weights'); + var bezierN = ctrlptDists && ctrlptWs ? Math.min(ctrlptDists.value.length, ctrlptWs.value.length) : 1; + var ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[0] : undefined; + var ctrlptWeight = ctrlptWs.value[0]; + + // (Multi)bezier + + var multi = edgeIsUnbundled; + rs.edgeType = multi ? 'multibezier' : 'bezier'; + rs.ctrlpts = []; + for (var b = 0; b < bezierN; b++) { + var normctrlptDist = (0.5 - pairInfo.eles.length / 2 + i) * stepSize * (edgeIsSwapped ? -1 : 1); + var manctrlptDist = void 0; + var sign = signum(normctrlptDist); + if (multi) { + ctrlptDist = ctrlptDists ? ctrlptDists.pfValue[b] : stepSize; // fall back on step size + ctrlptWeight = ctrlptWs.value[b]; + } + if (edgeIsUnbundled) { + // multi or single unbundled + manctrlptDist = ctrlptDist; + } else { + manctrlptDist = ctrlptDist !== undefined ? sign * ctrlptDist : undefined; + } + var distanceFromMidpoint = manctrlptDist !== undefined ? manctrlptDist : normctrlptDist; + var w1 = 1 - ctrlptWeight; + var w2 = ctrlptWeight; + var _this$findMidptPtsEtc2 = this.findMidptPtsEtc(edge, pairInfo), + midptPts = _this$findMidptPtsEtc2.midptPts, + vectorNormInverse = _this$findMidptPtsEtc2.vectorNormInverse; + var adjustedMidpt = { + x: midptPts.x1 * w1 + midptPts.x2 * w2, + y: midptPts.y1 * w1 + midptPts.y2 * w2 + }; + rs.ctrlpts.push(adjustedMidpt.x + vectorNormInverse.x * distanceFromMidpoint, adjustedMidpt.y + vectorNormInverse.y * distanceFromMidpoint); + } +}; +BRp$c.findTaxiPoints = function (edge, pairInfo) { + // Taxicab geometry with two turns maximum + + var rs = edge._private.rscratch; + rs.edgeType = 'segments'; + var VERTICAL = 'vertical'; + var HORIZONTAL = 'horizontal'; + var LEFTWARD = 'leftward'; + var RIGHTWARD = 'rightward'; + var DOWNWARD = 'downward'; + var UPWARD = 'upward'; + var AUTO = 'auto'; + var posPts = pairInfo.posPts, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH; + var edgeDistances = edge.pstyle('edge-distances').value; + var dIncludesNodeBody = edgeDistances !== 'node-position'; + var taxiDir = edge.pstyle('taxi-direction').value; + var rawTaxiDir = taxiDir; // unprocessed value + var taxiTurn = edge.pstyle('taxi-turn'); + var turnIsPercent = taxiTurn.units === '%'; + var taxiTurnPfVal = taxiTurn.pfValue; + var turnIsNegative = taxiTurnPfVal < 0; // i.e. from target side + var minD = edge.pstyle('taxi-turn-min-distance').pfValue; + var dw = dIncludesNodeBody ? (srcW + tgtW) / 2 : 0; + var dh = dIncludesNodeBody ? (srcH + tgtH) / 2 : 0; + var pdx = posPts.x2 - posPts.x1; + var pdy = posPts.y2 - posPts.y1; + + // take away the effective w/h from the magnitude of the delta value + var subDWH = function subDWH(dxy, dwh) { + if (dxy > 0) { + return Math.max(dxy - dwh, 0); + } else { + return Math.min(dxy + dwh, 0); + } + }; + var dx = subDWH(pdx, dw); + var dy = subDWH(pdy, dh); + var isExplicitDir = false; + if (rawTaxiDir === AUTO) { + taxiDir = Math.abs(dx) > Math.abs(dy) ? HORIZONTAL : VERTICAL; + } else if (rawTaxiDir === UPWARD || rawTaxiDir === DOWNWARD) { + taxiDir = VERTICAL; + isExplicitDir = true; + } else if (rawTaxiDir === LEFTWARD || rawTaxiDir === RIGHTWARD) { + taxiDir = HORIZONTAL; + isExplicitDir = true; + } + var isVert = taxiDir === VERTICAL; + var l = isVert ? dy : dx; + var pl = isVert ? pdy : pdx; + var sgnL = signum(pl); + var forcedDir = false; + if (!(isExplicitDir && (turnIsPercent || turnIsNegative)) // forcing in this case would cause weird growing in the opposite direction + && (rawTaxiDir === DOWNWARD && pl < 0 || rawTaxiDir === UPWARD && pl > 0 || rawTaxiDir === LEFTWARD && pl > 0 || rawTaxiDir === RIGHTWARD && pl < 0)) { + sgnL *= -1; + l = sgnL * Math.abs(l); + forcedDir = true; + } + var d; + if (turnIsPercent) { + var p = taxiTurnPfVal < 0 ? 1 + taxiTurnPfVal : taxiTurnPfVal; + d = p * l; + } else { + var k = taxiTurnPfVal < 0 ? l : 0; + d = k + taxiTurnPfVal * sgnL; + } + var getIsTooClose = function getIsTooClose(d) { + return Math.abs(d) < minD || Math.abs(d) >= Math.abs(l); + }; + var isTooCloseSrc = getIsTooClose(d); + var isTooCloseTgt = getIsTooClose(Math.abs(l) - Math.abs(d)); + var isTooClose = isTooCloseSrc || isTooCloseTgt; + if (isTooClose && !forcedDir) { + // non-ideal routing + if (isVert) { + // vertical fallbacks + var lShapeInsideSrc = Math.abs(pl) <= srcH / 2; + var lShapeInsideTgt = Math.abs(pdx) <= tgtW / 2; + if (lShapeInsideSrc) { + // horizontal Z-shape (direction not respected) + var x = (posPts.x1 + posPts.x2) / 2; + var y1 = posPts.y1, + y2 = posPts.y2; + rs.segpts = [x, y1, x, y2]; + } else if (lShapeInsideTgt) { + // vertical Z-shape (distance not respected) + var y = (posPts.y1 + posPts.y2) / 2; + var x1 = posPts.x1, + x2 = posPts.x2; + rs.segpts = [x1, y, x2, y]; + } else { + // L-shape fallback (turn distance not respected, but works well with tree siblings) + rs.segpts = [posPts.x1, posPts.y2]; + } + } else { + // horizontal fallbacks + var _lShapeInsideSrc = Math.abs(pl) <= srcW / 2; + var _lShapeInsideTgt = Math.abs(pdy) <= tgtH / 2; + if (_lShapeInsideSrc) { + // vertical Z-shape (direction not respected) + var _y = (posPts.y1 + posPts.y2) / 2; + var _x = posPts.x1, + _x2 = posPts.x2; + rs.segpts = [_x, _y, _x2, _y]; + } else if (_lShapeInsideTgt) { + // horizontal Z-shape (turn distance not respected) + var _x3 = (posPts.x1 + posPts.x2) / 2; + var _y2 = posPts.y1, + _y3 = posPts.y2; + rs.segpts = [_x3, _y2, _x3, _y3]; + } else { + // L-shape (turn distance not respected, but works well for tree siblings) + rs.segpts = [posPts.x2, posPts.y1]; + } + } + } else { + // ideal routing + if (isVert) { + var _y4 = posPts.y1 + d + (dIncludesNodeBody ? srcH / 2 * sgnL : 0); + var _x4 = posPts.x1, + _x5 = posPts.x2; + rs.segpts = [_x4, _y4, _x5, _y4]; + } else { + // horizontal + var _x6 = posPts.x1 + d + (dIncludesNodeBody ? srcW / 2 * sgnL : 0); + var _y5 = posPts.y1, + _y6 = posPts.y2; + rs.segpts = [_x6, _y5, _x6, _y6]; + } + } + if (rs.isRound) { + var radius = edge.pstyle('taxi-radius').value; + var isArcRadius = edge.pstyle('radius-type').value[0] === 'arc-radius'; + rs.radii = new Array(rs.segpts.length / 2).fill(radius); + rs.isArcRadius = new Array(rs.segpts.length / 2).fill(isArcRadius); + } +}; +BRp$c.tryToCorrectInvalidPoints = function (edge, pairInfo) { + var rs = edge._private.rscratch; + + // can only correct beziers for now... + if (rs.edgeType === 'bezier') { + var srcPos = pairInfo.srcPos, + tgtPos = pairInfo.tgtPos, + srcW = pairInfo.srcW, + srcH = pairInfo.srcH, + tgtW = pairInfo.tgtW, + tgtH = pairInfo.tgtH, + srcShape = pairInfo.srcShape, + tgtShape = pairInfo.tgtShape, + srcCornerRadius = pairInfo.srcCornerRadius, + tgtCornerRadius = pairInfo.tgtCornerRadius, + srcRs = pairInfo.srcRs, + tgtRs = pairInfo.tgtRs; + var badStart = !number$1(rs.startX) || !number$1(rs.startY); + var badAStart = !number$1(rs.arrowStartX) || !number$1(rs.arrowStartY); + var badEnd = !number$1(rs.endX) || !number$1(rs.endY); + var badAEnd = !number$1(rs.arrowEndX) || !number$1(rs.arrowEndY); + var minCpADistFactor = 3; + var arrowW = this.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.arrowShapeWidth; + var minCpADist = minCpADistFactor * arrowW; + var startACpDist = dist({ + x: rs.ctrlpts[0], + y: rs.ctrlpts[1] + }, { + x: rs.startX, + y: rs.startY + }); + var closeStartACp = startACpDist < minCpADist; + var endACpDist = dist({ + x: rs.ctrlpts[0], + y: rs.ctrlpts[1] + }, { + x: rs.endX, + y: rs.endY + }); + var closeEndACp = endACpDist < minCpADist; + var overlapping = false; + if (badStart || badAStart || closeStartACp) { + overlapping = true; + + // project control point along line from src centre to outside the src shape + // (otherwise intersection will yield nothing) + var cpD = { + // delta + x: rs.ctrlpts[0] - srcPos.x, + y: rs.ctrlpts[1] - srcPos.y + }; + var cpL = Math.sqrt(cpD.x * cpD.x + cpD.y * cpD.y); // length of line + var cpM = { + // normalised delta + x: cpD.x / cpL, + y: cpD.y / cpL + }; + var radius = Math.max(srcW, srcH); + var cpProj = { + // *2 radius guarantees outside shape + x: rs.ctrlpts[0] + cpM.x * 2 * radius, + y: rs.ctrlpts[1] + cpM.y * 2 * radius + }; + var srcCtrlPtIntn = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, cpProj.x, cpProj.y, 0, srcCornerRadius, srcRs); + if (closeStartACp) { + rs.ctrlpts[0] = rs.ctrlpts[0] + cpM.x * (minCpADist - startACpDist); + rs.ctrlpts[1] = rs.ctrlpts[1] + cpM.y * (minCpADist - startACpDist); + } else { + rs.ctrlpts[0] = srcCtrlPtIntn[0] + cpM.x * minCpADist; + rs.ctrlpts[1] = srcCtrlPtIntn[1] + cpM.y * minCpADist; + } + } + if (badEnd || badAEnd || closeEndACp) { + overlapping = true; + + // project control point along line from tgt centre to outside the tgt shape + // (otherwise intersection will yield nothing) + var _cpD = { + // delta + x: rs.ctrlpts[0] - tgtPos.x, + y: rs.ctrlpts[1] - tgtPos.y + }; + var _cpL = Math.sqrt(_cpD.x * _cpD.x + _cpD.y * _cpD.y); // length of line + var _cpM = { + // normalised delta + x: _cpD.x / _cpL, + y: _cpD.y / _cpL + }; + var _radius = Math.max(srcW, srcH); + var _cpProj = { + // *2 radius guarantees outside shape + x: rs.ctrlpts[0] + _cpM.x * 2 * _radius, + y: rs.ctrlpts[1] + _cpM.y * 2 * _radius + }; + var tgtCtrlPtIntn = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, _cpProj.x, _cpProj.y, 0, tgtCornerRadius, tgtRs); + if (closeEndACp) { + rs.ctrlpts[0] = rs.ctrlpts[0] + _cpM.x * (minCpADist - endACpDist); + rs.ctrlpts[1] = rs.ctrlpts[1] + _cpM.y * (minCpADist - endACpDist); + } else { + rs.ctrlpts[0] = tgtCtrlPtIntn[0] + _cpM.x * minCpADist; + rs.ctrlpts[1] = tgtCtrlPtIntn[1] + _cpM.y * minCpADist; + } + } + if (overlapping) { + // recalc endpts + this.findEndpoints(edge); + } + } +}; +BRp$c.storeAllpts = function (edge) { + var rs = edge._private.rscratch; + if (rs.edgeType === 'multibezier' || rs.edgeType === 'bezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') { + rs.allpts = []; + rs.allpts.push(rs.startX, rs.startY); + for (var b = 0; b + 1 < rs.ctrlpts.length; b += 2) { + // ctrl pt itself + rs.allpts.push(rs.ctrlpts[b], rs.ctrlpts[b + 1]); + + // the midpt between ctrlpts as intermediate destination pts + if (b + 3 < rs.ctrlpts.length) { + rs.allpts.push((rs.ctrlpts[b] + rs.ctrlpts[b + 2]) / 2, (rs.ctrlpts[b + 1] + rs.ctrlpts[b + 3]) / 2); + } + } + rs.allpts.push(rs.endX, rs.endY); + var m, mt; + if (rs.ctrlpts.length / 2 % 2 === 0) { + m = rs.allpts.length / 2 - 1; + rs.midX = rs.allpts[m]; + rs.midY = rs.allpts[m + 1]; + } else { + m = rs.allpts.length / 2 - 3; + mt = 0.5; + rs.midX = qbezierAt(rs.allpts[m], rs.allpts[m + 2], rs.allpts[m + 4], mt); + rs.midY = qbezierAt(rs.allpts[m + 1], rs.allpts[m + 3], rs.allpts[m + 5], mt); + } + } else if (rs.edgeType === 'straight') { + // need to calc these after endpts + rs.allpts = [rs.startX, rs.startY, rs.endX, rs.endY]; + + // default midpt for labels etc + rs.midX = (rs.startX + rs.endX + rs.arrowStartX + rs.arrowEndX) / 4; + rs.midY = (rs.startY + rs.endY + rs.arrowStartY + rs.arrowEndY) / 4; + } else if (rs.edgeType === 'segments') { + rs.allpts = []; + rs.allpts.push(rs.startX, rs.startY); + rs.allpts.push.apply(rs.allpts, rs.segpts); + rs.allpts.push(rs.endX, rs.endY); + if (rs.isRound) { + rs.roundCorners = []; + for (var i = 2; i + 3 < rs.allpts.length; i += 2) { + var radius = rs.radii[i / 2 - 1]; + var isArcRadius = rs.isArcRadius[i / 2 - 1]; + rs.roundCorners.push(getRoundCorner({ + x: rs.allpts[i - 2], + y: rs.allpts[i - 1] + }, { + x: rs.allpts[i], + y: rs.allpts[i + 1], + radius: radius + }, { + x: rs.allpts[i + 2], + y: rs.allpts[i + 3] + }, radius, isArcRadius)); + } + } + if (rs.segpts.length % 4 === 0) { + var i2 = rs.segpts.length / 2; + var i1 = i2 - 2; + rs.midX = (rs.segpts[i1] + rs.segpts[i2]) / 2; + rs.midY = (rs.segpts[i1 + 1] + rs.segpts[i2 + 1]) / 2; + } else { + var _i = rs.segpts.length / 2 - 1; + if (!rs.isRound) { + rs.midX = rs.segpts[_i]; + rs.midY = rs.segpts[_i + 1]; + } else { + var point = { + x: rs.segpts[_i], + y: rs.segpts[_i + 1] + }; + var corner = rs.roundCorners[_i / 2]; + var v = [point.x - corner.cx, point.y - corner.cy]; + var factor = corner.radius / Math.sqrt(Math.pow(v[0], 2) + Math.pow(v[1], 2)); + v = v.map(function (c) { + return c * factor; + }); + rs.midX = corner.cx + v[0]; + rs.midY = corner.cy + v[1]; + rs.midVector = v; + } + } + } +}; +BRp$c.checkForInvalidEdgeWarning = function (edge) { + var rs = edge[0]._private.rscratch; + if (rs.nodesOverlap || number$1(rs.startX) && number$1(rs.startY) && number$1(rs.endX) && number$1(rs.endY)) { + rs.loggedErr = false; + } else { + if (!rs.loggedErr) { + rs.loggedErr = true; + warn('Edge `' + edge.id() + '` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap.'); + } + } +}; +BRp$c.findEdgeControlPoints = function (edges) { + var _this = this; + if (!edges || edges.length === 0) { + return; + } + var r = this; + var cy = r.cy; + var hasCompounds = cy.hasCompoundNodes(); + var hashTable = { + map: new Map$2(), + get: function get(pairId) { + var map2 = this.map.get(pairId[0]); + if (map2 != null) { + return map2.get(pairId[1]); + } else { + return null; + } + }, + set: function set(pairId, val) { + var map2 = this.map.get(pairId[0]); + if (map2 == null) { + map2 = new Map$2(); + this.map.set(pairId[0], map2); + } + map2.set(pairId[1], val); + } + }; + var pairIds = []; + var haystackEdges = []; + + // create a table of edge (src, tgt) => list of edges between them + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var _p = edge._private; + var curveStyle = edge.pstyle('curve-style').value; + + // ignore edges who are not to be displayed + // they shouldn't take up space + if (edge.removed() || !edge.takesUpSpace()) { + continue; + } + if (curveStyle === 'haystack') { + haystackEdges.push(edge); + continue; + } + var edgeIsUnbundled = curveStyle === 'unbundled-bezier' || curveStyle.endsWith('segments') || curveStyle === 'straight' || curveStyle === 'straight-triangle' || curveStyle.endsWith('taxi'); + var edgeIsBezier = curveStyle === 'unbundled-bezier' || curveStyle === 'bezier'; + var src = _p.source; + var tgt = _p.target; + var srcIndex = src.poolIndex(); + var tgtIndex = tgt.poolIndex(); + var pairId = [srcIndex, tgtIndex].sort(); + var tableEntry = hashTable.get(pairId); + if (tableEntry == null) { + tableEntry = { + eles: [] + }; + hashTable.set(pairId, tableEntry); + pairIds.push(pairId); + } + tableEntry.eles.push(edge); + if (edgeIsUnbundled) { + tableEntry.hasUnbundled = true; + } + if (edgeIsBezier) { + tableEntry.hasBezier = true; + } + } + + // for each pair (src, tgt), create the ctrl pts + // Nested for loop is OK; total number of iterations for both loops = edgeCount + var _loop = function _loop(p) { + var pairId = pairIds[p]; + var pairInfo = hashTable.get(pairId); + var swappedpairInfo = void 0; + if (!pairInfo.hasUnbundled) { + var pllEdges = pairInfo.eles[0].parallelEdges().filter(function (e) { + return e.isBundledBezier(); + }); + clearArray(pairInfo.eles); + pllEdges.forEach(function (edge) { + return pairInfo.eles.push(edge); + }); + + // for each pair id, the edges should be sorted by index + pairInfo.eles.sort(function (edge1, edge2) { + return edge1.poolIndex() - edge2.poolIndex(); + }); + } + var firstEdge = pairInfo.eles[0]; + var src = firstEdge.source(); + var tgt = firstEdge.target(); + + // make sure src/tgt distinction is consistent w.r.t. pairId + if (src.poolIndex() > tgt.poolIndex()) { + var temp = src; + src = tgt; + tgt = temp; + } + var srcPos = pairInfo.srcPos = src.position(); + var tgtPos = pairInfo.tgtPos = tgt.position(); + var srcW = pairInfo.srcW = src.outerWidth(); + var srcH = pairInfo.srcH = src.outerHeight(); + var tgtW = pairInfo.tgtW = tgt.outerWidth(); + var tgtH = pairInfo.tgtH = tgt.outerHeight(); + var srcShape = pairInfo.srcShape = r.nodeShapes[_this.getNodeShape(src)]; + var tgtShape = pairInfo.tgtShape = r.nodeShapes[_this.getNodeShape(tgt)]; + var srcCornerRadius = pairInfo.srcCornerRadius = src.pstyle('corner-radius').value === 'auto' ? 'auto' : src.pstyle('corner-radius').pfValue; + var tgtCornerRadius = pairInfo.tgtCornerRadius = tgt.pstyle('corner-radius').value === 'auto' ? 'auto' : tgt.pstyle('corner-radius').pfValue; + var tgtRs = pairInfo.tgtRs = tgt._private.rscratch; + var srcRs = pairInfo.srcRs = src._private.rscratch; + pairInfo.dirCounts = { + 'north': 0, + 'west': 0, + 'south': 0, + 'east': 0, + 'northwest': 0, + 'southwest': 0, + 'northeast': 0, + 'southeast': 0 + }; + for (var _i2 = 0; _i2 < pairInfo.eles.length; _i2++) { + var _edge = pairInfo.eles[_i2]; + var rs = _edge[0]._private.rscratch; + var _curveStyle = _edge.pstyle('curve-style').value; + var _edgeIsUnbundled = _curveStyle === 'unbundled-bezier' || _curveStyle.endsWith('segments') || _curveStyle.endsWith('taxi'); + + // whether the normalised pair order is the reverse of the edge's src-tgt order + var edgeIsSwapped = !src.same(_edge.source()); + if (!pairInfo.calculatedIntersection && src !== tgt && (pairInfo.hasBezier || pairInfo.hasUnbundled)) { + pairInfo.calculatedIntersection = true; + + // pt outside src shape to calc distance/displacement from src to tgt + var srcOutside = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, tgtPos.x, tgtPos.y, 0, srcCornerRadius, srcRs); + var srcIntn = pairInfo.srcIntn = srcOutside; + + // pt outside tgt shape to calc distance/displacement from src to tgt + var tgtOutside = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, srcPos.x, srcPos.y, 0, tgtCornerRadius, tgtRs); + var tgtIntn = pairInfo.tgtIntn = tgtOutside; + var intersectionPts = pairInfo.intersectionPts = { + x1: srcOutside[0], + x2: tgtOutside[0], + y1: srcOutside[1], + y2: tgtOutside[1] + }; + var posPts = pairInfo.posPts = { + x1: srcPos.x, + x2: tgtPos.x, + y1: srcPos.y, + y2: tgtPos.y + }; + var dy = tgtOutside[1] - srcOutside[1]; + var dx = tgtOutside[0] - srcOutside[0]; + var l = Math.sqrt(dx * dx + dy * dy); + var vector = pairInfo.vector = { + x: dx, + y: dy + }; + var vectorNorm = pairInfo.vectorNorm = { + x: vector.x / l, + y: vector.y / l + }; + var vectorNormInverse = { + x: -vectorNorm.y, + y: vectorNorm.x + }; + + // if node shapes overlap, then no ctrl pts to draw + pairInfo.nodesOverlap = !number$1(l) || tgtShape.checkPoint(srcOutside[0], srcOutside[1], 0, tgtW, tgtH, tgtPos.x, tgtPos.y, tgtCornerRadius, tgtRs) || srcShape.checkPoint(tgtOutside[0], tgtOutside[1], 0, srcW, srcH, srcPos.x, srcPos.y, srcCornerRadius, srcRs); + pairInfo.vectorNormInverse = vectorNormInverse; + swappedpairInfo = { + nodesOverlap: pairInfo.nodesOverlap, + dirCounts: pairInfo.dirCounts, + calculatedIntersection: true, + hasBezier: pairInfo.hasBezier, + hasUnbundled: pairInfo.hasUnbundled, + eles: pairInfo.eles, + srcPos: tgtPos, + tgtPos: srcPos, + srcW: tgtW, + srcH: tgtH, + tgtW: srcW, + tgtH: srcH, + srcIntn: tgtIntn, + tgtIntn: srcIntn, + srcShape: tgtShape, + tgtShape: srcShape, + posPts: { + x1: posPts.x2, + y1: posPts.y2, + x2: posPts.x1, + y2: posPts.y1 + }, + intersectionPts: { + x1: intersectionPts.x2, + y1: intersectionPts.y2, + x2: intersectionPts.x1, + y2: intersectionPts.y1 + }, + vector: { + x: -vector.x, + y: -vector.y + }, + vectorNorm: { + x: -vectorNorm.x, + y: -vectorNorm.y + }, + vectorNormInverse: { + x: -vectorNormInverse.x, + y: -vectorNormInverse.y + } + }; + } + var passedPairInfo = edgeIsSwapped ? swappedpairInfo : pairInfo; + rs.nodesOverlap = passedPairInfo.nodesOverlap; + rs.srcIntn = passedPairInfo.srcIntn; + rs.tgtIntn = passedPairInfo.tgtIntn; + rs.isRound = _curveStyle.startsWith('round'); + if (hasCompounds && (src.isParent() || src.isChild() || tgt.isParent() || tgt.isChild()) && (src.parents().anySame(tgt) || tgt.parents().anySame(src) || src.same(tgt) && src.isParent())) { + _this.findCompoundLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled); + } else if (src === tgt) { + _this.findLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled); + } else if (_curveStyle.endsWith('segments')) { + _this.findSegmentsPoints(_edge, passedPairInfo); + } else if (_curveStyle.endsWith('taxi')) { + _this.findTaxiPoints(_edge, passedPairInfo); + } else if (_curveStyle === 'straight' || !_edgeIsUnbundled && pairInfo.eles.length % 2 === 1 && _i2 === Math.floor(pairInfo.eles.length / 2)) { + _this.findStraightEdgePoints(_edge); + } else { + _this.findBezierPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled, edgeIsSwapped); + } + _this.findEndpoints(_edge); + _this.tryToCorrectInvalidPoints(_edge, passedPairInfo); + _this.checkForInvalidEdgeWarning(_edge); + _this.storeAllpts(_edge); + _this.storeEdgeProjections(_edge); + _this.calculateArrowAngles(_edge); + _this.recalculateEdgeLabelProjections(_edge); + _this.calculateLabelAngles(_edge); + } // for pair edges + }; + for (var p = 0; p < pairIds.length; p++) { + _loop(p); + } // for pair ids + + // haystacks avoid the expense of pairInfo stuff (intersections etc.) + this.findHaystackPoints(haystackEdges); +}; +function getPts(pts) { + var retPts = []; + if (pts == null) { + return; + } + for (var i = 0; i < pts.length; i += 2) { + var x = pts[i]; + var y = pts[i + 1]; + retPts.push({ + x: x, + y: y + }); + } + return retPts; +} +BRp$c.getSegmentPoints = function (edge) { + var rs = edge[0]._private.rscratch; + var type = rs.edgeType; + if (type === 'segments') { + this.recalculateRenderedStyle(edge); + return getPts(rs.segpts); + } +}; +BRp$c.getControlPoints = function (edge) { + var rs = edge[0]._private.rscratch; + var type = rs.edgeType; + if (type === 'bezier' || type === 'multibezier' || type === 'self' || type === 'compound') { + this.recalculateRenderedStyle(edge); + return getPts(rs.ctrlpts); + } +}; +BRp$c.getEdgeMidpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + return { + x: rs.midX, + y: rs.midY + }; +}; + +var BRp$b = {}; +BRp$b.manualEndptToPx = function (node, prop) { + var r = this; + var npos = node.position(); + var w = node.outerWidth(); + var h = node.outerHeight(); + var rs = node._private.rscratch; + if (prop.value.length === 2) { + var p = [prop.pfValue[0], prop.pfValue[1]]; + if (prop.units[0] === '%') { + p[0] = p[0] * w; + } + if (prop.units[1] === '%') { + p[1] = p[1] * h; + } + p[0] += npos.x; + p[1] += npos.y; + return p; + } else { + var angle = prop.pfValue[0]; + angle = -Math.PI / 2 + angle; // start at 12 o'clock + + var l = 2 * Math.max(w, h); + var _p = [npos.x + Math.cos(angle) * l, npos.y + Math.sin(angle) * l]; + return r.nodeShapes[this.getNodeShape(node)].intersectLine(npos.x, npos.y, w, h, _p[0], _p[1], 0, node.pstyle('corner-radius').value === 'auto' ? 'auto' : node.pstyle('corner-radius').pfValue, rs); + } +}; +BRp$b.findEndpoints = function (edge) { + var r = this; + var intersect; + var source = edge.source()[0]; + var target = edge.target()[0]; + var srcPos = source.position(); + var tgtPos = target.position(); + var tgtArShape = edge.pstyle('target-arrow-shape').value; + var srcArShape = edge.pstyle('source-arrow-shape').value; + var tgtDist = edge.pstyle('target-distance-from-node').pfValue; + var srcDist = edge.pstyle('source-distance-from-node').pfValue; + var srcRs = source._private.rscratch; + var tgtRs = target._private.rscratch; + var curveStyle = edge.pstyle('curve-style').value; + var rs = edge._private.rscratch; + var et = rs.edgeType; + var taxi = curveStyle === 'taxi'; + var self = et === 'self' || et === 'compound'; + var bezier = et === 'bezier' || et === 'multibezier' || self; + var multi = et !== 'bezier'; + var lines = et === 'straight' || et === 'segments'; + var segments = et === 'segments'; + var hasEndpts = bezier || multi || lines; + var overrideEndpts = self || taxi; + var srcManEndpt = edge.pstyle('source-endpoint'); + var srcManEndptVal = overrideEndpts ? 'outside-to-node' : srcManEndpt.value; + var srcCornerRadius = source.pstyle('corner-radius').value === 'auto' ? 'auto' : source.pstyle('corner-radius').pfValue; + var tgtManEndpt = edge.pstyle('target-endpoint'); + var tgtManEndptVal = overrideEndpts ? 'outside-to-node' : tgtManEndpt.value; + var tgtCornerRadius = target.pstyle('corner-radius').value === 'auto' ? 'auto' : target.pstyle('corner-radius').pfValue; + rs.srcManEndpt = srcManEndpt; + rs.tgtManEndpt = tgtManEndpt; + var p1; // last known point of edge on target side + var p2; // last known point of edge on source side + + var p1_i; // point to intersect with target shape + var p2_i; // point to intersect with source shape + + if (bezier) { + var cpStart = [rs.ctrlpts[0], rs.ctrlpts[1]]; + var cpEnd = multi ? [rs.ctrlpts[rs.ctrlpts.length - 2], rs.ctrlpts[rs.ctrlpts.length - 1]] : cpStart; + p1 = cpEnd; + p2 = cpStart; + } else if (lines) { + var srcArrowFromPt = !segments ? [tgtPos.x, tgtPos.y] : rs.segpts.slice(0, 2); + var tgtArrowFromPt = !segments ? [srcPos.x, srcPos.y] : rs.segpts.slice(rs.segpts.length - 2); + p1 = tgtArrowFromPt; + p2 = srcArrowFromPt; + } + if (tgtManEndptVal === 'inside-to-node') { + intersect = [tgtPos.x, tgtPos.y]; + } else if (tgtManEndpt.units) { + intersect = this.manualEndptToPx(target, tgtManEndpt); + } else if (tgtManEndptVal === 'outside-to-line') { + intersect = rs.tgtIntn; // use cached value from ctrlpt calc + } else { + if (tgtManEndptVal === 'outside-to-node' || tgtManEndptVal === 'outside-to-node-or-label') { + p1_i = p1; + } else if (tgtManEndptVal === 'outside-to-line' || tgtManEndptVal === 'outside-to-line-or-label') { + p1_i = [srcPos.x, srcPos.y]; + } + intersect = r.nodeShapes[this.getNodeShape(target)].intersectLine(tgtPos.x, tgtPos.y, target.outerWidth(), target.outerHeight(), p1_i[0], p1_i[1], 0, tgtCornerRadius, tgtRs); + if (tgtManEndptVal === 'outside-to-node-or-label' || tgtManEndptVal === 'outside-to-line-or-label') { + var trs = target._private.rscratch; + var lw = trs.labelWidth; + var lh = trs.labelHeight; + var lx = trs.labelX; + var ly = trs.labelY; + var lw2 = lw / 2; + var lh2 = lh / 2; + var va = target.pstyle('text-valign').value; + if (va === 'top') { + ly -= lh2; + } else if (va === 'bottom') { + ly += lh2; + } + var ha = target.pstyle('text-halign').value; + if (ha === 'left') { + lx -= lw2; + } else if (ha === 'right') { + lx += lw2; + } + var labelIntersect = polygonIntersectLine(p1_i[0], p1_i[1], [lx - lw2, ly - lh2, lx + lw2, ly - lh2, lx + lw2, ly + lh2, lx - lw2, ly + lh2], tgtPos.x, tgtPos.y); + if (labelIntersect.length > 0) { + var refPt = srcPos; + var intSqdist = sqdist(refPt, array2point(intersect)); + var labIntSqdist = sqdist(refPt, array2point(labelIntersect)); + var minSqDist = intSqdist; + if (labIntSqdist < intSqdist) { + intersect = labelIntersect; + minSqDist = labIntSqdist; + } + if (labelIntersect.length > 2) { + var labInt2SqDist = sqdist(refPt, { + x: labelIntersect[2], + y: labelIntersect[3] + }); + if (labInt2SqDist < minSqDist) { + intersect = [labelIntersect[2], labelIntersect[3]]; + } + } + } + } + } + var arrowEnd = shortenIntersection(intersect, p1, r.arrowShapes[tgtArShape].spacing(edge) + tgtDist); + var edgeEnd = shortenIntersection(intersect, p1, r.arrowShapes[tgtArShape].gap(edge) + tgtDist); + rs.endX = edgeEnd[0]; + rs.endY = edgeEnd[1]; + rs.arrowEndX = arrowEnd[0]; + rs.arrowEndY = arrowEnd[1]; + if (srcManEndptVal === 'inside-to-node') { + intersect = [srcPos.x, srcPos.y]; + } else if (srcManEndpt.units) { + intersect = this.manualEndptToPx(source, srcManEndpt); + } else if (srcManEndptVal === 'outside-to-line') { + intersect = rs.srcIntn; // use cached value from ctrlpt calc + } else { + if (srcManEndptVal === 'outside-to-node' || srcManEndptVal === 'outside-to-node-or-label') { + p2_i = p2; + } else if (srcManEndptVal === 'outside-to-line' || srcManEndptVal === 'outside-to-line-or-label') { + p2_i = [tgtPos.x, tgtPos.y]; + } + intersect = r.nodeShapes[this.getNodeShape(source)].intersectLine(srcPos.x, srcPos.y, source.outerWidth(), source.outerHeight(), p2_i[0], p2_i[1], 0, srcCornerRadius, srcRs); + if (srcManEndptVal === 'outside-to-node-or-label' || srcManEndptVal === 'outside-to-line-or-label') { + var srs = source._private.rscratch; + var _lw = srs.labelWidth; + var _lh = srs.labelHeight; + var _lx = srs.labelX; + var _ly = srs.labelY; + var _lw2 = _lw / 2; + var _lh2 = _lh / 2; + var _va = source.pstyle('text-valign').value; + if (_va === 'top') { + _ly -= _lh2; + } else if (_va === 'bottom') { + _ly += _lh2; + } + var _ha = source.pstyle('text-halign').value; + if (_ha === 'left') { + _lx -= _lw2; + } else if (_ha === 'right') { + _lx += _lw2; + } + var _labelIntersect = polygonIntersectLine(p2_i[0], p2_i[1], [_lx - _lw2, _ly - _lh2, _lx + _lw2, _ly - _lh2, _lx + _lw2, _ly + _lh2, _lx - _lw2, _ly + _lh2], srcPos.x, srcPos.y); + if (_labelIntersect.length > 0) { + var _refPt = tgtPos; + var _intSqdist = sqdist(_refPt, array2point(intersect)); + var _labIntSqdist = sqdist(_refPt, array2point(_labelIntersect)); + var _minSqDist = _intSqdist; + if (_labIntSqdist < _intSqdist) { + intersect = [_labelIntersect[0], _labelIntersect[1]]; + _minSqDist = _labIntSqdist; + } + if (_labelIntersect.length > 2) { + var _labInt2SqDist = sqdist(_refPt, { + x: _labelIntersect[2], + y: _labelIntersect[3] + }); + if (_labInt2SqDist < _minSqDist) { + intersect = [_labelIntersect[2], _labelIntersect[3]]; + } + } + } + } + } + var arrowStart = shortenIntersection(intersect, p2, r.arrowShapes[srcArShape].spacing(edge) + srcDist); + var edgeStart = shortenIntersection(intersect, p2, r.arrowShapes[srcArShape].gap(edge) + srcDist); + rs.startX = edgeStart[0]; + rs.startY = edgeStart[1]; + rs.arrowStartX = arrowStart[0]; + rs.arrowStartY = arrowStart[1]; + if (hasEndpts) { + if (!number$1(rs.startX) || !number$1(rs.startY) || !number$1(rs.endX) || !number$1(rs.endY)) { + rs.badLine = true; + } else { + rs.badLine = false; + } + } +}; +BRp$b.getSourceEndpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + switch (rs.edgeType) { + case 'haystack': + return { + x: rs.haystackPts[0], + y: rs.haystackPts[1] + }; + default: + return { + x: rs.arrowStartX, + y: rs.arrowStartY + }; + } +}; +BRp$b.getTargetEndpoint = function (edge) { + var rs = edge[0]._private.rscratch; + this.recalculateRenderedStyle(edge); + switch (rs.edgeType) { + case 'haystack': + return { + x: rs.haystackPts[2], + y: rs.haystackPts[3] + }; + default: + return { + x: rs.arrowEndX, + y: rs.arrowEndY + }; + } +}; + +var BRp$a = {}; +function pushBezierPts(r, edge, pts) { + var qbezierAt$1 = function qbezierAt$1(p1, p2, p3, t) { + return qbezierAt(p1, p2, p3, t); + }; + var _p = edge._private; + var bpts = _p.rstyle.bezierPts; + for (var i = 0; i < r.bezierProjPcts.length; i++) { + var p = r.bezierProjPcts[i]; + bpts.push({ + x: qbezierAt$1(pts[0], pts[2], pts[4], p), + y: qbezierAt$1(pts[1], pts[3], pts[5], p) + }); + } +} +BRp$a.storeEdgeProjections = function (edge) { + var _p = edge._private; + var rs = _p.rscratch; + var et = rs.edgeType; + + // clear the cached points state + _p.rstyle.bezierPts = null; + _p.rstyle.linePts = null; + _p.rstyle.haystackPts = null; + if (et === 'multibezier' || et === 'bezier' || et === 'self' || et === 'compound') { + _p.rstyle.bezierPts = []; + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + pushBezierPts(this, edge, rs.allpts.slice(i, i + 6)); + } + } else if (et === 'segments') { + var lpts = _p.rstyle.linePts = []; + for (var i = 0; i + 1 < rs.allpts.length; i += 2) { + lpts.push({ + x: rs.allpts[i], + y: rs.allpts[i + 1] + }); + } + } else if (et === 'haystack') { + var hpts = rs.haystackPts; + _p.rstyle.haystackPts = [{ + x: hpts[0], + y: hpts[1] + }, { + x: hpts[2], + y: hpts[3] + }]; + } + _p.rstyle.arrowWidth = this.getArrowWidth(edge.pstyle('width').pfValue, edge.pstyle('arrow-scale').value) * this.arrowShapeWidth; +}; +BRp$a.recalculateEdgeProjections = function (edges) { + this.findEdgeControlPoints(edges); +}; + +/* global document */ + +var BRp$9 = {}; +BRp$9.recalculateNodeLabelProjection = function (node) { + var content = node.pstyle('label').strValue; + if (emptyString(content)) { + return; + } + var textX, textY; + var _p = node._private; + var nodeWidth = node.width(); + var nodeHeight = node.height(); + var padding = node.padding(); + var nodePos = node.position(); + var textHalign = node.pstyle('text-halign').strValue; + var textValign = node.pstyle('text-valign').strValue; + var rs = _p.rscratch; + var rstyle = _p.rstyle; + switch (textHalign) { + case 'left': + textX = nodePos.x - nodeWidth / 2 - padding; + break; + case 'right': + textX = nodePos.x + nodeWidth / 2 + padding; + break; + default: + // e.g. center + textX = nodePos.x; + } + switch (textValign) { + case 'top': + textY = nodePos.y - nodeHeight / 2 - padding; + break; + case 'bottom': + textY = nodePos.y + nodeHeight / 2 + padding; + break; + default: + // e.g. middle + textY = nodePos.y; + } + rs.labelX = textX; + rs.labelY = textY; + rstyle.labelX = textX; + rstyle.labelY = textY; + this.calculateLabelAngles(node); + this.applyLabelDimensions(node); +}; +var lineAngleFromDelta = function lineAngleFromDelta(dx, dy) { + var angle = Math.atan(dy / dx); + if (dx === 0 && angle < 0) { + angle = angle * -1; + } + return angle; +}; +var lineAngle = function lineAngle(p0, p1) { + var dx = p1.x - p0.x; + var dy = p1.y - p0.y; + return lineAngleFromDelta(dx, dy); +}; +var bezierAngle = function bezierAngle(p0, p1, p2, t) { + var t0 = bound(0, t - 0.001, 1); + var t1 = bound(0, t + 0.001, 1); + var lp0 = qbezierPtAt(p0, p1, p2, t0); + var lp1 = qbezierPtAt(p0, p1, p2, t1); + return lineAngle(lp0, lp1); +}; +BRp$9.recalculateEdgeLabelProjections = function (edge) { + var p; + var _p = edge._private; + var rs = _p.rscratch; + var r = this; + var content = { + mid: edge.pstyle('label').strValue, + source: edge.pstyle('source-label').strValue, + target: edge.pstyle('target-label').strValue + }; + if (content.mid || content.source || content.target) ; else { + return; // no labels => no calcs + } + + // add center point to style so bounding box calculations can use it + // + p = { + x: rs.midX, + y: rs.midY + }; + var setRs = function setRs(propName, prefix, value) { + setPrefixedProperty(_p.rscratch, propName, prefix, value); + setPrefixedProperty(_p.rstyle, propName, prefix, value); + }; + setRs('labelX', null, p.x); + setRs('labelY', null, p.y); + var midAngle = lineAngleFromDelta(rs.midDispX, rs.midDispY); + setRs('labelAutoAngle', null, midAngle); + var createControlPointInfo = function createControlPointInfo() { + if (createControlPointInfo.cache) { + return createControlPointInfo.cache; + } // use cache so only 1x per edge + + var ctrlpts = []; + + // store each ctrlpt info init + for (var i = 0; i + 5 < rs.allpts.length; i += 4) { + var p0 = { + x: rs.allpts[i], + y: rs.allpts[i + 1] + }; + var p1 = { + x: rs.allpts[i + 2], + y: rs.allpts[i + 3] + }; // ctrlpt + var p2 = { + x: rs.allpts[i + 4], + y: rs.allpts[i + 5] + }; + ctrlpts.push({ + p0: p0, + p1: p1, + p2: p2, + startDist: 0, + length: 0, + segments: [] + }); + } + var bpts = _p.rstyle.bezierPts; + var nProjs = r.bezierProjPcts.length; + function addSegment(cp, p0, p1, t0, t1) { + var length = dist(p0, p1); + var prevSegment = cp.segments[cp.segments.length - 1]; + var segment = { + p0: p0, + p1: p1, + t0: t0, + t1: t1, + startDist: prevSegment ? prevSegment.startDist + prevSegment.length : 0, + length: length + }; + cp.segments.push(segment); + cp.length += length; + } + + // update each ctrlpt with segment info + for (var _i = 0; _i < ctrlpts.length; _i++) { + var cp = ctrlpts[_i]; + var prevCp = ctrlpts[_i - 1]; + if (prevCp) { + cp.startDist = prevCp.startDist + prevCp.length; + } + addSegment(cp, cp.p0, bpts[_i * nProjs], 0, r.bezierProjPcts[0]); // first + + for (var j = 0; j < nProjs - 1; j++) { + addSegment(cp, bpts[_i * nProjs + j], bpts[_i * nProjs + j + 1], r.bezierProjPcts[j], r.bezierProjPcts[j + 1]); + } + addSegment(cp, bpts[_i * nProjs + nProjs - 1], cp.p2, r.bezierProjPcts[nProjs - 1], 1); // last + } + + return createControlPointInfo.cache = ctrlpts; + }; + var calculateEndProjection = function calculateEndProjection(prefix) { + var angle; + var isSrc = prefix === 'source'; + if (!content[prefix]) { + return; + } + var offset = edge.pstyle(prefix + '-text-offset').pfValue; + switch (rs.edgeType) { + case 'self': + case 'compound': + case 'bezier': + case 'multibezier': + { + var cps = createControlPointInfo(); + var selected; + var startDist = 0; + var totalDist = 0; + + // find the segment we're on + for (var i = 0; i < cps.length; i++) { + var _cp = cps[isSrc ? i : cps.length - 1 - i]; + for (var j = 0; j < _cp.segments.length; j++) { + var _seg = _cp.segments[isSrc ? j : _cp.segments.length - 1 - j]; + var lastSeg = i === cps.length - 1 && j === _cp.segments.length - 1; + startDist = totalDist; + totalDist += _seg.length; + if (totalDist >= offset || lastSeg) { + selected = { + cp: _cp, + segment: _seg + }; + break; + } + } + if (selected) { + break; + } + } + var cp = selected.cp; + var seg = selected.segment; + var tSegment = (offset - startDist) / seg.length; + var segDt = seg.t1 - seg.t0; + var t = isSrc ? seg.t0 + segDt * tSegment : seg.t1 - segDt * tSegment; + t = bound(0, t, 1); + p = qbezierPtAt(cp.p0, cp.p1, cp.p2, t); + angle = bezierAngle(cp.p0, cp.p1, cp.p2, t); + break; + } + case 'straight': + case 'segments': + case 'haystack': + { + var d = 0, + di, + d0; + var p0, p1; + var l = rs.allpts.length; + for (var _i2 = 0; _i2 + 3 < l; _i2 += 2) { + if (isSrc) { + p0 = { + x: rs.allpts[_i2], + y: rs.allpts[_i2 + 1] + }; + p1 = { + x: rs.allpts[_i2 + 2], + y: rs.allpts[_i2 + 3] + }; + } else { + p0 = { + x: rs.allpts[l - 2 - _i2], + y: rs.allpts[l - 1 - _i2] + }; + p1 = { + x: rs.allpts[l - 4 - _i2], + y: rs.allpts[l - 3 - _i2] + }; + } + di = dist(p0, p1); + d0 = d; + d += di; + if (d >= offset) { + break; + } + } + var pD = offset - d0; + var _t = pD / di; + _t = bound(0, _t, 1); + p = lineAt(p0, p1, _t); + angle = lineAngle(p0, p1); + break; + } + } + setRs('labelX', prefix, p.x); + setRs('labelY', prefix, p.y); + setRs('labelAutoAngle', prefix, angle); + }; + calculateEndProjection('source'); + calculateEndProjection('target'); + this.applyLabelDimensions(edge); +}; +BRp$9.applyLabelDimensions = function (ele) { + this.applyPrefixedLabelDimensions(ele); + if (ele.isEdge()) { + this.applyPrefixedLabelDimensions(ele, 'source'); + this.applyPrefixedLabelDimensions(ele, 'target'); + } +}; +BRp$9.applyPrefixedLabelDimensions = function (ele, prefix) { + var _p = ele._private; + var text = this.getLabelText(ele, prefix); + var labelDims = this.calculateLabelDimensions(ele, text); + var lineHeight = ele.pstyle('line-height').pfValue; + var textWrap = ele.pstyle('text-wrap').strValue; + var lines = getPrefixedProperty(_p.rscratch, 'labelWrapCachedLines', prefix) || []; + var numLines = textWrap !== 'wrap' ? 1 : Math.max(lines.length, 1); + var normPerLineHeight = labelDims.height / numLines; + var labelLineHeight = normPerLineHeight * lineHeight; + var width = labelDims.width; + var height = labelDims.height + (numLines - 1) * (lineHeight - 1) * normPerLineHeight; + setPrefixedProperty(_p.rstyle, 'labelWidth', prefix, width); + setPrefixedProperty(_p.rscratch, 'labelWidth', prefix, width); + setPrefixedProperty(_p.rstyle, 'labelHeight', prefix, height); + setPrefixedProperty(_p.rscratch, 'labelHeight', prefix, height); + setPrefixedProperty(_p.rscratch, 'labelLineHeight', prefix, labelLineHeight); +}; +BRp$9.getLabelText = function (ele, prefix) { + var _p = ele._private; + var pfd = prefix ? prefix + '-' : ''; + var text = ele.pstyle(pfd + 'label').strValue; + var textTransform = ele.pstyle('text-transform').value; + var rscratch = function rscratch(propName, value) { + if (value) { + setPrefixedProperty(_p.rscratch, propName, prefix, value); + return value; + } else { + return getPrefixedProperty(_p.rscratch, propName, prefix); + } + }; + + // for empty text, skip all processing + if (!text) { + return ''; + } + if (textTransform == 'none') ; else if (textTransform == 'uppercase') { + text = text.toUpperCase(); + } else if (textTransform == 'lowercase') { + text = text.toLowerCase(); + } + var wrapStyle = ele.pstyle('text-wrap').value; + if (wrapStyle === 'wrap') { + var labelKey = rscratch('labelKey'); + + // save recalc if the label is the same as before + if (labelKey != null && rscratch('labelWrapKey') === labelKey) { + return rscratch('labelWrapCachedText'); + } + var zwsp = "\u200B"; + var lines = text.split('\n'); + var maxW = ele.pstyle('text-max-width').pfValue; + var overflow = ele.pstyle('text-overflow-wrap').value; + var overflowAny = overflow === 'anywhere'; + var wrappedLines = []; + var wordsRegex = /[\s\u200b]+/; + var wordSeparator = overflowAny ? '' : ' '; + for (var l = 0; l < lines.length; l++) { + var line = lines[l]; + var lineDims = this.calculateLabelDimensions(ele, line); + var lineW = lineDims.width; + if (overflowAny) { + var processedLine = line.split('').join(zwsp); + line = processedLine; + } + if (lineW > maxW) { + // line is too long + var words = line.split(wordsRegex); + var subline = ''; + for (var w = 0; w < words.length; w++) { + var word = words[w]; + var testLine = subline.length === 0 ? word : subline + wordSeparator + word; + var testDims = this.calculateLabelDimensions(ele, testLine); + var testW = testDims.width; + if (testW <= maxW) { + // word fits on current line + subline += word + wordSeparator; + } else { + // word starts new line + if (subline) { + wrappedLines.push(subline); + } + subline = word + wordSeparator; + } + } + + // if there's remaining text, put it in a wrapped line + if (!subline.match(/^[\s\u200b]+$/)) { + wrappedLines.push(subline); + } + } else { + // line is already short enough + wrappedLines.push(line); + } + } // for + + rscratch('labelWrapCachedLines', wrappedLines); + text = rscratch('labelWrapCachedText', wrappedLines.join('\n')); + rscratch('labelWrapKey', labelKey); + } else if (wrapStyle === 'ellipsis') { + var _maxW = ele.pstyle('text-max-width').pfValue; + var ellipsized = ''; + var ellipsis = "\u2026"; + var incLastCh = false; + if (this.calculateLabelDimensions(ele, text).width < _maxW) { + // the label already fits + return text; + } + for (var i = 0; i < text.length; i++) { + var widthWithNextCh = this.calculateLabelDimensions(ele, ellipsized + text[i] + ellipsis).width; + if (widthWithNextCh > _maxW) { + break; + } + ellipsized += text[i]; + if (i === text.length - 1) { + incLastCh = true; + } + } + if (!incLastCh) { + ellipsized += ellipsis; + } + return ellipsized; + } // if ellipsize + + return text; +}; +BRp$9.getLabelJustification = function (ele) { + var justification = ele.pstyle('text-justification').strValue; + var textHalign = ele.pstyle('text-halign').strValue; + if (justification === 'auto') { + if (ele.isNode()) { + switch (textHalign) { + case 'left': + return 'right'; + case 'right': + return 'left'; + default: + return 'center'; + } + } else { + return 'center'; + } + } else { + return justification; + } +}; +BRp$9.calculateLabelDimensions = function (ele, text) { + var r = this; + var cacheKey = hashString(text, ele._private.labelDimsKey); + var cache = r.labelDimCache || (r.labelDimCache = []); + var existingVal = cache[cacheKey]; + if (existingVal != null) { + return existingVal; + } + var padding = 0; // add padding around text dims, as the measurement isn't that accurate + var fStyle = ele.pstyle('font-style').strValue; + var size = ele.pstyle('font-size').pfValue; + var family = ele.pstyle('font-family').strValue; + var weight = ele.pstyle('font-weight').strValue; + var canvas = this.labelCalcCanvas; + var c2d = this.labelCalcCanvasContext; + if (!canvas) { + canvas = this.labelCalcCanvas = document.createElement('canvas'); + c2d = this.labelCalcCanvasContext = canvas.getContext('2d'); + var ds = canvas.style; + ds.position = 'absolute'; + ds.left = '-9999px'; + ds.top = '-9999px'; + ds.zIndex = '-1'; + ds.visibility = 'hidden'; + ds.pointerEvents = 'none'; + } + c2d.font = "".concat(fStyle, " ").concat(weight, " ").concat(size, "px ").concat(family); + var width = 0; + var height = 0; + var lines = text.split('\n'); + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + var metrics = c2d.measureText(line); + var w = Math.ceil(metrics.width); + var h = size; + width = Math.max(w, width); + height += h; + } + width += padding; + height += padding; + return cache[cacheKey] = { + width: width, + height: height + }; +}; +BRp$9.calculateLabelAngle = function (ele, prefix) { + var _p = ele._private; + var rs = _p.rscratch; + var isEdge = ele.isEdge(); + var prefixDash = prefix ? prefix + '-' : ''; + var rot = ele.pstyle(prefixDash + 'text-rotation'); + var rotStr = rot.strValue; + if (rotStr === 'none') { + return 0; + } else if (isEdge && rotStr === 'autorotate') { + return rs.labelAutoAngle; + } else if (rotStr === 'autorotate') { + return 0; + } else { + return rot.pfValue; + } +}; +BRp$9.calculateLabelAngles = function (ele) { + var r = this; + var isEdge = ele.isEdge(); + var _p = ele._private; + var rs = _p.rscratch; + rs.labelAngle = r.calculateLabelAngle(ele); + if (isEdge) { + rs.sourceLabelAngle = r.calculateLabelAngle(ele, 'source'); + rs.targetLabelAngle = r.calculateLabelAngle(ele, 'target'); + } +}; + +var BRp$8 = {}; +var TOO_SMALL_CUT_RECT = 28; +var warnedCutRect = false; +BRp$8.getNodeShape = function (node) { + var r = this; + var shape = node.pstyle('shape').value; + if (shape === 'cutrectangle' && (node.width() < TOO_SMALL_CUT_RECT || node.height() < TOO_SMALL_CUT_RECT)) { + if (!warnedCutRect) { + warn('The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead'); + warnedCutRect = true; + } + return 'rectangle'; + } + if (node.isParent()) { + if (shape === 'rectangle' || shape === 'roundrectangle' || shape === 'round-rectangle' || shape === 'cutrectangle' || shape === 'cut-rectangle' || shape === 'barrel') { + return shape; + } else { + return 'rectangle'; + } + } + if (shape === 'polygon') { + var points = node.pstyle('shape-polygon-points').value; + return r.nodeShapes.makePolygon(points).name; + } + return shape; +}; + +var BRp$7 = {}; +BRp$7.registerCalculationListeners = function () { + var cy = this.cy; + var elesToUpdate = cy.collection(); + var r = this; + var enqueue = function enqueue(eles) { + var dirtyStyleCaches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + elesToUpdate.merge(eles); + if (dirtyStyleCaches) { + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var rstyle = _p.rstyle; + rstyle.clean = false; + rstyle.cleanConnected = false; + } + } + }; + r.binder(cy).on('bounds.* dirty.*', function onDirtyBounds(e) { + var ele = e.target; + enqueue(ele); + }).on('style.* background.*', function onDirtyStyle(e) { + var ele = e.target; + enqueue(ele, false); + }); + var updateEleCalcs = function updateEleCalcs(willDraw) { + if (willDraw) { + var fns = r.onUpdateEleCalcsFns; + + // because we need to have up-to-date style (e.g. stylesheet mappers) + // before calculating rendered style (and pstyle might not be called yet) + elesToUpdate.cleanStyle(); + for (var i = 0; i < elesToUpdate.length; i++) { + var ele = elesToUpdate[i]; + var rstyle = ele._private.rstyle; + if (ele.isNode() && !rstyle.cleanConnected) { + enqueue(ele.connectedEdges()); + rstyle.cleanConnected = true; + } + } + if (fns) { + for (var _i = 0; _i < fns.length; _i++) { + var fn = fns[_i]; + fn(willDraw, elesToUpdate); + } + } + r.recalculateRenderedStyle(elesToUpdate); + elesToUpdate = cy.collection(); + } + }; + r.flushRenderedStyleQueue = function () { + updateEleCalcs(true); + }; + r.beforeRender(updateEleCalcs, r.beforeRenderPriorities.eleCalcs); +}; +BRp$7.onUpdateEleCalcs = function (fn) { + var fns = this.onUpdateEleCalcsFns = this.onUpdateEleCalcsFns || []; + fns.push(fn); +}; +BRp$7.recalculateRenderedStyle = function (eles, useCache) { + var isCleanConnected = function isCleanConnected(ele) { + return ele._private.rstyle.cleanConnected; + }; + var edges = []; + var nodes = []; + + // the renderer can't be used for calcs when destroyed, e.g. ele.boundingBox() + if (this.destroyed) { + return; + } + + // use cache by default for perf + if (useCache === undefined) { + useCache = true; + } + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var _p = ele._private; + var rstyle = _p.rstyle; + + // an edge may be implicitly dirty b/c of one of its connected nodes + // (and a request for recalc may come in between frames) + if (ele.isEdge() && (!isCleanConnected(ele.source()) || !isCleanConnected(ele.target()))) { + rstyle.clean = false; + } + + // only update if dirty and in graph + if (useCache && rstyle.clean || ele.removed()) { + continue; + } + + // only update if not display: none + if (ele.pstyle('display').value === 'none') { + continue; + } + if (_p.group === 'nodes') { + nodes.push(ele); + } else { + // edges + edges.push(ele); + } + rstyle.clean = true; + } + + // update node data from projections + for (var _i2 = 0; _i2 < nodes.length; _i2++) { + var _ele = nodes[_i2]; + var _p2 = _ele._private; + var _rstyle = _p2.rstyle; + var pos = _ele.position(); + this.recalculateNodeLabelProjection(_ele); + _rstyle.nodeX = pos.x; + _rstyle.nodeY = pos.y; + _rstyle.nodeW = _ele.pstyle('width').pfValue; + _rstyle.nodeH = _ele.pstyle('height').pfValue; + } + this.recalculateEdgeProjections(edges); + + // update edge data from projections + for (var _i3 = 0; _i3 < edges.length; _i3++) { + var _ele2 = edges[_i3]; + var _p3 = _ele2._private; + var _rstyle2 = _p3.rstyle; + var rs = _p3.rscratch; + + // update rstyle positions + _rstyle2.srcX = rs.arrowStartX; + _rstyle2.srcY = rs.arrowStartY; + _rstyle2.tgtX = rs.arrowEndX; + _rstyle2.tgtY = rs.arrowEndY; + _rstyle2.midX = rs.midX; + _rstyle2.midY = rs.midY; + _rstyle2.labelAngle = rs.labelAngle; + _rstyle2.sourceLabelAngle = rs.sourceLabelAngle; + _rstyle2.targetLabelAngle = rs.targetLabelAngle; + } +}; + +var BRp$6 = {}; +BRp$6.updateCachedGrabbedEles = function () { + var eles = this.cachedZSortedEles; + if (!eles) { + // just let this be recalculated on the next z sort tick + return; + } + eles.drag = []; + eles.nondrag = []; + var grabTargets = []; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var rs = ele._private.rscratch; + if (ele.grabbed() && !ele.isParent()) { + grabTargets.push(ele); + } else if (rs.inDragLayer) { + eles.drag.push(ele); + } else { + eles.nondrag.push(ele); + } + } + + // put the grab target nodes last so it's on top of its neighbourhood + for (var i = 0; i < grabTargets.length; i++) { + var ele = grabTargets[i]; + eles.drag.push(ele); + } +}; +BRp$6.invalidateCachedZSortedEles = function () { + this.cachedZSortedEles = null; +}; +BRp$6.getCachedZSortedEles = function (forceRecalc) { + if (forceRecalc || !this.cachedZSortedEles) { + var eles = this.cy.mutableElements().toArray(); + eles.sort(zIndexSort); + eles.interactive = eles.filter(function (ele) { + return ele.interactive(); + }); + this.cachedZSortedEles = eles; + this.updateCachedGrabbedEles(); + } else { + eles = this.cachedZSortedEles; + } + return eles; +}; + +var BRp$5 = {}; +[BRp$e, BRp$d, BRp$c, BRp$b, BRp$a, BRp$9, BRp$8, BRp$7, BRp$6].forEach(function (props) { + extend(BRp$5, props); +}); + +var BRp$4 = {}; +BRp$4.getCachedImage = function (url, crossOrigin, onLoad) { + var r = this; + var imageCache = r.imageCache = r.imageCache || {}; + var cache = imageCache[url]; + if (cache) { + if (!cache.image.complete) { + cache.image.addEventListener('load', onLoad); + } + return cache.image; + } else { + cache = imageCache[url] = imageCache[url] || {}; + var image = cache.image = new Image(); // eslint-disable-line no-undef + + image.addEventListener('load', onLoad); + image.addEventListener('error', function () { + image.error = true; + }); + + // #1582 safari doesn't load data uris with crossOrigin properly + // https://bugs.webkit.org/show_bug.cgi?id=123978 + var dataUriPrefix = 'data:'; + var isDataUri = url.substring(0, dataUriPrefix.length).toLowerCase() === dataUriPrefix; + if (!isDataUri) { + // if crossorigin is 'null'(stringified), then manually set it to null + crossOrigin = crossOrigin === 'null' ? null : crossOrigin; + image.crossOrigin = crossOrigin; // prevent tainted canvas + } + + image.src = url; + return image; + } +}; + +var BRp$3 = {}; + +/* global document, window, ResizeObserver, MutationObserver */ + +BRp$3.registerBinding = function (target, event, handler, useCapture) { + // eslint-disable-line no-unused-vars + var args = Array.prototype.slice.apply(arguments, [1]); // copy + var b = this.binder(target); + return b.on.apply(b, args); +}; +BRp$3.binder = function (tgt) { + var r = this; + var containerWindow = r.cy.window(); + var tgtIsDom = tgt === containerWindow || tgt === containerWindow.document || tgt === containerWindow.document.body || domElement(tgt); + if (r.supportsPassiveEvents == null) { + // from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection + var supportsPassive = false; + try { + var opts = Object.defineProperty({}, 'passive', { + get: function get() { + supportsPassive = true; + return true; + } + }); + containerWindow.addEventListener('test', null, opts); + } catch (err) { + // not supported + } + r.supportsPassiveEvents = supportsPassive; + } + var on = function on(event, handler, useCapture) { + var args = Array.prototype.slice.call(arguments); + if (tgtIsDom && r.supportsPassiveEvents) { + // replace useCapture w/ opts obj + args[2] = { + capture: useCapture != null ? useCapture : false, + passive: false, + once: false + }; + } + r.bindings.push({ + target: tgt, + args: args + }); + (tgt.addEventListener || tgt.on).apply(tgt, args); + return this; + }; + return { + on: on, + addEventListener: on, + addListener: on, + bind: on + }; +}; +BRp$3.nodeIsDraggable = function (node) { + return node && node.isNode() && !node.locked() && node.grabbable(); +}; +BRp$3.nodeIsGrabbable = function (node) { + return this.nodeIsDraggable(node) && node.interactive(); +}; +BRp$3.load = function () { + var r = this; + var containerWindow = r.cy.window(); + var isSelected = function isSelected(ele) { + return ele.selected(); + }; + var triggerEvents = function triggerEvents(target, names, e, position) { + if (target == null) { + target = r.cy; + } + for (var i = 0; i < names.length; i++) { + var name = names[i]; + target.emit({ + originalEvent: e, + type: name, + position: position + }); + } + }; + var isMultSelKeyDown = function isMultSelKeyDown(e) { + return e.shiftKey || e.metaKey || e.ctrlKey; // maybe e.altKey + }; + + var allowPanningPassthrough = function allowPanningPassthrough(down, downs) { + var allowPassthrough = true; + if (r.cy.hasCompoundNodes() && down && down.pannable()) { + // a grabbable compound node below the ele => no passthrough panning + for (var i = 0; downs && i < downs.length; i++) { + var down = downs[i]; + + //if any parent node in event hierarchy isn't pannable, reject passthrough + if (down.isNode() && down.isParent() && !down.pannable()) { + allowPassthrough = false; + break; + } + } + } else { + allowPassthrough = true; + } + return allowPassthrough; + }; + var setGrabbed = function setGrabbed(ele) { + ele[0]._private.grabbed = true; + }; + var setFreed = function setFreed(ele) { + ele[0]._private.grabbed = false; + }; + var setInDragLayer = function setInDragLayer(ele) { + ele[0]._private.rscratch.inDragLayer = true; + }; + var setOutDragLayer = function setOutDragLayer(ele) { + ele[0]._private.rscratch.inDragLayer = false; + }; + var setGrabTarget = function setGrabTarget(ele) { + ele[0]._private.rscratch.isGrabTarget = true; + }; + var removeGrabTarget = function removeGrabTarget(ele) { + ele[0]._private.rscratch.isGrabTarget = false; + }; + var addToDragList = function addToDragList(ele, opts) { + var list = opts.addToList; + var listHasEle = list.has(ele); + if (!listHasEle && ele.grabbable() && !ele.locked()) { + list.merge(ele); + setGrabbed(ele); + } + }; + + // helper function to determine which child nodes and inner edges + // of a compound node to be dragged as well as the grabbed and selected nodes + var addDescendantsToDrag = function addDescendantsToDrag(node, opts) { + if (!node.cy().hasCompoundNodes()) { + return; + } + if (opts.inDragLayer == null && opts.addToList == null) { + return; + } // nothing to do + + var innerNodes = node.descendants(); + if (opts.inDragLayer) { + innerNodes.forEach(setInDragLayer); + innerNodes.connectedEdges().forEach(setInDragLayer); + } + if (opts.addToList) { + addToDragList(innerNodes, opts); + } + }; + + // adds the given nodes and its neighbourhood to the drag layer + var addNodesToDrag = function addNodesToDrag(nodes, opts) { + opts = opts || {}; + var hasCompoundNodes = nodes.cy().hasCompoundNodes(); + if (opts.inDragLayer) { + nodes.forEach(setInDragLayer); + nodes.neighborhood().stdFilter(function (ele) { + return !hasCompoundNodes || ele.isEdge(); + }).forEach(setInDragLayer); + } + if (opts.addToList) { + nodes.forEach(function (ele) { + addToDragList(ele, opts); + }); + } + addDescendantsToDrag(nodes, opts); // always add to drag + + // also add nodes and edges related to the topmost ancestor + updateAncestorsInDragLayer(nodes, { + inDragLayer: opts.inDragLayer + }); + r.updateCachedGrabbedEles(); + }; + var addNodeToDrag = addNodesToDrag; + var freeDraggedElements = function freeDraggedElements(grabbedEles) { + if (!grabbedEles) { + return; + } + + // just go over all elements rather than doing a bunch of (possibly expensive) traversals + r.getCachedZSortedEles().forEach(function (ele) { + setFreed(ele); + setOutDragLayer(ele); + removeGrabTarget(ele); + }); + r.updateCachedGrabbedEles(); + }; + + // helper function to determine which ancestor nodes and edges should go + // to the drag layer (or should be removed from drag layer). + var updateAncestorsInDragLayer = function updateAncestorsInDragLayer(node, opts) { + if (opts.inDragLayer == null && opts.addToList == null) { + return; + } // nothing to do + + if (!node.cy().hasCompoundNodes()) { + return; + } + + // find top-level parent + var parent = node.ancestors().orphans(); + + // no parent node: no nodes to add to the drag layer + if (parent.same(node)) { + return; + } + var nodes = parent.descendants().spawnSelf().merge(parent).unmerge(node).unmerge(node.descendants()); + var edges = nodes.connectedEdges(); + if (opts.inDragLayer) { + edges.forEach(setInDragLayer); + nodes.forEach(setInDragLayer); + } + if (opts.addToList) { + nodes.forEach(function (ele) { + addToDragList(ele, opts); + }); + } + }; + var blurActiveDomElement = function blurActiveDomElement() { + if (document.activeElement != null && document.activeElement.blur != null) { + document.activeElement.blur(); + } + }; + var haveMutationsApi = typeof MutationObserver !== 'undefined'; + var haveResizeObserverApi = typeof ResizeObserver !== 'undefined'; + + // watch for when the cy container is removed from the dom + if (haveMutationsApi) { + r.removeObserver = new MutationObserver(function (mutns) { + // eslint-disable-line no-undef + for (var i = 0; i < mutns.length; i++) { + var mutn = mutns[i]; + var rNodes = mutn.removedNodes; + if (rNodes) { + for (var j = 0; j < rNodes.length; j++) { + var rNode = rNodes[j]; + if (rNode === r.container) { + r.destroy(); + break; + } + } + } + } + }); + if (r.container.parentNode) { + r.removeObserver.observe(r.container.parentNode, { + childList: true + }); + } + } else { + r.registerBinding(r.container, 'DOMNodeRemoved', function (e) { + // eslint-disable-line no-unused-vars + r.destroy(); + }); + } + var onResize = debounce_1(function () { + r.cy.resize(); + }, 100); + if (haveMutationsApi) { + r.styleObserver = new MutationObserver(onResize); // eslint-disable-line no-undef + + r.styleObserver.observe(r.container, { + attributes: true + }); + } + + // auto resize + r.registerBinding(containerWindow, 'resize', onResize); // eslint-disable-line no-undef + + if (haveResizeObserverApi) { + r.resizeObserver = new ResizeObserver(onResize); // eslint-disable-line no-undef + + r.resizeObserver.observe(r.container); + } + var forEachUp = function forEachUp(domEle, fn) { + while (domEle != null) { + fn(domEle); + domEle = domEle.parentNode; + } + }; + var invalidateCoords = function invalidateCoords() { + r.invalidateContainerClientCoordsCache(); + }; + forEachUp(r.container, function (domEle) { + r.registerBinding(domEle, 'transitionend', invalidateCoords); + r.registerBinding(domEle, 'animationend', invalidateCoords); + r.registerBinding(domEle, 'scroll', invalidateCoords); + }); + + // stop right click menu from appearing on cy + r.registerBinding(r.container, 'contextmenu', function (e) { + e.preventDefault(); + }); + var inBoxSelection = function inBoxSelection() { + return r.selection[4] !== 0; + }; + var eventInContainer = function eventInContainer(e) { + // save cycles if mouse events aren't to be captured + var containerPageCoords = r.findContainerClientCoords(); + var x = containerPageCoords[0]; + var y = containerPageCoords[1]; + var width = containerPageCoords[2]; + var height = containerPageCoords[3]; + var positions = e.touches ? e.touches : [e]; + var atLeastOnePosInside = false; + for (var i = 0; i < positions.length; i++) { + var p = positions[i]; + if (x <= p.clientX && p.clientX <= x + width && y <= p.clientY && p.clientY <= y + height) { + atLeastOnePosInside = true; + break; + } + } + if (!atLeastOnePosInside) { + return false; + } + var container = r.container; + var target = e.target; + var tParent = target.parentNode; + var containerIsTarget = false; + while (tParent) { + if (tParent === container) { + containerIsTarget = true; + break; + } + tParent = tParent.parentNode; + } + if (!containerIsTarget) { + return false; + } // if target is outisde cy container, then this event is not for us + + return true; + }; + + // Primary key + r.registerBinding(r.container, 'mousedown', function mousedownHandler(e) { + if (!eventInContainer(e)) { + return; + } + e.preventDefault(); + blurActiveDomElement(); + r.hoverData.capture = true; + r.hoverData.which = e.which; + var cy = r.cy; + var gpos = [e.clientX, e.clientY]; + var pos = r.projectIntoViewport(gpos[0], gpos[1]); + var select = r.selection; + var nears = r.findNearestElements(pos[0], pos[1], true, false); + var near = nears[0]; + var draggedElements = r.dragData.possibleDragElements; + r.hoverData.mdownPos = pos; + r.hoverData.mdownGPos = gpos; + var checkForTaphold = function checkForTaphold() { + r.hoverData.tapholdCancelled = false; + clearTimeout(r.hoverData.tapholdTimeout); + r.hoverData.tapholdTimeout = setTimeout(function () { + if (r.hoverData.tapholdCancelled) { + return; + } else { + var ele = r.hoverData.down; + if (ele) { + ele.emit({ + originalEvent: e, + type: 'taphold', + position: { + x: pos[0], + y: pos[1] + } + }); + } else { + cy.emit({ + originalEvent: e, + type: 'taphold', + position: { + x: pos[0], + y: pos[1] + } + }); + } + } + }, r.tapholdDuration); + }; + + // Right click button + if (e.which == 3) { + r.hoverData.cxtStarted = true; + var cxtEvt = { + originalEvent: e, + type: 'cxttapstart', + position: { + x: pos[0], + y: pos[1] + } + }; + if (near) { + near.activate(); + near.emit(cxtEvt); + r.hoverData.down = near; + } else { + cy.emit(cxtEvt); + } + r.hoverData.downTime = new Date().getTime(); + r.hoverData.cxtDragged = false; + + // Primary button + } else if (e.which == 1) { + if (near) { + near.activate(); + } + + // Element dragging + { + // If something is under the cursor and it is draggable, prepare to grab it + if (near != null) { + if (r.nodeIsGrabbable(near)) { + var makeEvent = function makeEvent(type) { + return { + originalEvent: e, + type: type, + position: { + x: pos[0], + y: pos[1] + } + }; + }; + var triggerGrab = function triggerGrab(ele) { + ele.emit(makeEvent('grab')); + }; + setGrabTarget(near); + if (!near.selected()) { + draggedElements = r.dragData.possibleDragElements = cy.collection(); + addNodeToDrag(near, { + addToList: draggedElements + }); + near.emit(makeEvent('grabon')).emit(makeEvent('grab')); + } else { + draggedElements = r.dragData.possibleDragElements = cy.collection(); + var selectedNodes = cy.$(function (ele) { + return ele.isNode() && ele.selected() && r.nodeIsGrabbable(ele); + }); + addNodesToDrag(selectedNodes, { + addToList: draggedElements + }); + near.emit(makeEvent('grabon')); + selectedNodes.forEach(triggerGrab); + } + r.redrawHint('eles', true); + r.redrawHint('drag', true); + } + } + r.hoverData.down = near; + r.hoverData.downs = nears; + r.hoverData.downTime = new Date().getTime(); + } + triggerEvents(near, ['mousedown', 'tapstart', 'vmousedown'], e, { + x: pos[0], + y: pos[1] + }); + if (near == null) { + select[4] = 1; + r.data.bgActivePosistion = { + x: pos[0], + y: pos[1] + }; + r.redrawHint('select', true); + r.redraw(); + } else if (near.pannable()) { + select[4] = 1; // for future pan + } + + checkForTaphold(); + } + + // Initialize selection box coordinates + select[0] = select[2] = pos[0]; + select[1] = select[3] = pos[1]; + }, false); + r.registerBinding(containerWindow, 'mousemove', function mousemoveHandler(e) { + // eslint-disable-line no-undef + var capture = r.hoverData.capture; + if (!capture && !eventInContainer(e)) { + return; + } + var preventDefault = false; + var cy = r.cy; + var zoom = cy.zoom(); + var gpos = [e.clientX, e.clientY]; + var pos = r.projectIntoViewport(gpos[0], gpos[1]); + var mdownPos = r.hoverData.mdownPos; + var mdownGPos = r.hoverData.mdownGPos; + var select = r.selection; + var near = null; + if (!r.hoverData.draggingEles && !r.hoverData.dragging && !r.hoverData.selecting) { + near = r.findNearestElement(pos[0], pos[1], true, false); + } + var last = r.hoverData.last; + var down = r.hoverData.down; + var disp = [pos[0] - select[2], pos[1] - select[3]]; + var draggedElements = r.dragData.possibleDragElements; + var isOverThresholdDrag; + if (mdownGPos) { + var dx = gpos[0] - mdownGPos[0]; + var dx2 = dx * dx; + var dy = gpos[1] - mdownGPos[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + r.hoverData.isOverThresholdDrag = isOverThresholdDrag = dist2 >= r.desktopTapThreshold2; + } + var multSelKeyDown = isMultSelKeyDown(e); + if (isOverThresholdDrag) { + r.hoverData.tapholdCancelled = true; + } + var updateDragDelta = function updateDragDelta() { + var dragDelta = r.hoverData.dragDelta = r.hoverData.dragDelta || []; + if (dragDelta.length === 0) { + dragDelta.push(disp[0]); + dragDelta.push(disp[1]); + } else { + dragDelta[0] += disp[0]; + dragDelta[1] += disp[1]; + } + }; + preventDefault = true; + triggerEvents(near, ['mousemove', 'vmousemove', 'tapdrag'], e, { + x: pos[0], + y: pos[1] + }); + var goIntoBoxMode = function goIntoBoxMode() { + r.data.bgActivePosistion = undefined; + if (!r.hoverData.selecting) { + cy.emit({ + originalEvent: e, + type: 'boxstart', + position: { + x: pos[0], + y: pos[1] + } + }); + } + select[4] = 1; + r.hoverData.selecting = true; + r.redrawHint('select', true); + r.redraw(); + }; + + // trigger context drag if rmouse down + if (r.hoverData.which === 3) { + // but only if over threshold + if (isOverThresholdDrag) { + var cxtEvt = { + originalEvent: e, + type: 'cxtdrag', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + r.hoverData.cxtDragged = true; + if (!r.hoverData.cxtOver || near !== r.hoverData.cxtOver) { + if (r.hoverData.cxtOver) { + r.hoverData.cxtOver.emit({ + originalEvent: e, + type: 'cxtdragout', + position: { + x: pos[0], + y: pos[1] + } + }); + } + r.hoverData.cxtOver = near; + if (near) { + near.emit({ + originalEvent: e, + type: 'cxtdragover', + position: { + x: pos[0], + y: pos[1] + } + }); + } + } + } + + // Check if we are drag panning the entire graph + } else if (r.hoverData.dragging) { + preventDefault = true; + if (cy.panningEnabled() && cy.userPanningEnabled()) { + var deltaP; + if (r.hoverData.justStartedPan) { + var mdPos = r.hoverData.mdownPos; + deltaP = { + x: (pos[0] - mdPos[0]) * zoom, + y: (pos[1] - mdPos[1]) * zoom + }; + r.hoverData.justStartedPan = false; + } else { + deltaP = { + x: disp[0] * zoom, + y: disp[1] * zoom + }; + } + cy.panBy(deltaP); + cy.emit('dragpan'); + r.hoverData.dragged = true; + } + + // Needs reproject due to pan changing viewport + pos = r.projectIntoViewport(e.clientX, e.clientY); + + // Checks primary button down & out of time & mouse not moved much + } else if (select[4] == 1 && (down == null || down.pannable())) { + if (isOverThresholdDrag) { + if (!r.hoverData.dragging && cy.boxSelectionEnabled() && (multSelKeyDown || !cy.panningEnabled() || !cy.userPanningEnabled())) { + goIntoBoxMode(); + } else if (!r.hoverData.selecting && cy.panningEnabled() && cy.userPanningEnabled()) { + var allowPassthrough = allowPanningPassthrough(down, r.hoverData.downs); + if (allowPassthrough) { + r.hoverData.dragging = true; + r.hoverData.justStartedPan = true; + select[4] = 0; + r.data.bgActivePosistion = array2point(mdownPos); + r.redrawHint('select', true); + r.redraw(); + } + } + if (down && down.pannable() && down.active()) { + down.unactivate(); + } + } + } else { + if (down && down.pannable() && down.active()) { + down.unactivate(); + } + if ((!down || !down.grabbed()) && near != last) { + if (last) { + triggerEvents(last, ['mouseout', 'tapdragout'], e, { + x: pos[0], + y: pos[1] + }); + } + if (near) { + triggerEvents(near, ['mouseover', 'tapdragover'], e, { + x: pos[0], + y: pos[1] + }); + } + r.hoverData.last = near; + } + if (down) { + if (isOverThresholdDrag) { + // then we can take action + + if (cy.boxSelectionEnabled() && multSelKeyDown) { + // then selection overrides + if (down && down.grabbed()) { + freeDraggedElements(draggedElements); + down.emit('freeon'); + draggedElements.emit('free'); + if (r.dragData.didDrag) { + down.emit('dragfreeon'); + draggedElements.emit('dragfree'); + } + } + goIntoBoxMode(); + } else if (down && down.grabbed() && r.nodeIsDraggable(down)) { + // drag node + var justStartedDrag = !r.dragData.didDrag; + if (justStartedDrag) { + r.redrawHint('eles', true); + } + r.dragData.didDrag = true; // indicate that we actually did drag the node + + // now, add the elements to the drag layer if not done already + if (!r.hoverData.draggingEles) { + addNodesToDrag(draggedElements, { + inDragLayer: true + }); + } + var totalShift = { + x: 0, + y: 0 + }; + if (number$1(disp[0]) && number$1(disp[1])) { + totalShift.x += disp[0]; + totalShift.y += disp[1]; + if (justStartedDrag) { + var dragDelta = r.hoverData.dragDelta; + if (dragDelta && number$1(dragDelta[0]) && number$1(dragDelta[1])) { + totalShift.x += dragDelta[0]; + totalShift.y += dragDelta[1]; + } + } + } + r.hoverData.draggingEles = true; + draggedElements.silentShift(totalShift).emit('position drag'); + r.redrawHint('drag', true); + r.redraw(); + } + } else { + // otherwise save drag delta for when we actually start dragging so the relative grab pos is constant + updateDragDelta(); + } + } + + // prevent the dragging from triggering text selection on the page + preventDefault = true; + } + select[2] = pos[0]; + select[3] = pos[1]; + if (preventDefault) { + if (e.stopPropagation) e.stopPropagation(); + if (e.preventDefault) e.preventDefault(); + return false; + } + }, false); + var clickTimeout, didDoubleClick, prevClickTimeStamp; + r.registerBinding(containerWindow, 'mouseup', function mouseupHandler(e) { + // eslint-disable-line no-undef + var capture = r.hoverData.capture; + if (!capture) { + return; + } + r.hoverData.capture = false; + var cy = r.cy; + var pos = r.projectIntoViewport(e.clientX, e.clientY); + var select = r.selection; + var near = r.findNearestElement(pos[0], pos[1], true, false); + var draggedElements = r.dragData.possibleDragElements; + var down = r.hoverData.down; + var multSelKeyDown = isMultSelKeyDown(e); + if (r.data.bgActivePosistion) { + r.redrawHint('select', true); + r.redraw(); + } + r.hoverData.tapholdCancelled = true; + r.data.bgActivePosistion = undefined; // not active bg now + + if (down) { + down.unactivate(); + } + if (r.hoverData.which === 3) { + var cxtEvt = { + originalEvent: e, + type: 'cxttapend', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + if (!r.hoverData.cxtDragged) { + var cxtTap = { + originalEvent: e, + type: 'cxttap', + position: { + x: pos[0], + y: pos[1] + } + }; + if (down) { + down.emit(cxtTap); + } else { + cy.emit(cxtTap); + } + } + r.hoverData.cxtDragged = false; + r.hoverData.which = null; + } else if (r.hoverData.which === 1) { + triggerEvents(near, ['mouseup', 'tapend', 'vmouseup'], e, { + x: pos[0], + y: pos[1] + }); + if (!r.dragData.didDrag && + // didn't move a node around + !r.hoverData.dragged && + // didn't pan + !r.hoverData.selecting && + // not box selection + !r.hoverData.isOverThresholdDrag // didn't move too much + ) { + triggerEvents(down, ["click", "tap", "vclick"], e, { + x: pos[0], + y: pos[1] + }); + didDoubleClick = false; + if (e.timeStamp - prevClickTimeStamp <= cy.multiClickDebounceTime()) { + clickTimeout && clearTimeout(clickTimeout); + didDoubleClick = true; + prevClickTimeStamp = null; + triggerEvents(down, ["dblclick", "dbltap", "vdblclick"], e, { + x: pos[0], + y: pos[1] + }); + } else { + clickTimeout = setTimeout(function () { + if (didDoubleClick) return; + triggerEvents(down, ["oneclick", "onetap", "voneclick"], e, { + x: pos[0], + y: pos[1] + }); + }, cy.multiClickDebounceTime()); + prevClickTimeStamp = e.timeStamp; + } + } + + // Deselect all elements if nothing is currently under the mouse cursor and we aren't dragging something + if (down == null // not mousedown on node + && !r.dragData.didDrag // didn't move the node around + && !r.hoverData.selecting // not box selection + && !r.hoverData.dragged // didn't pan + && !isMultSelKeyDown(e)) { + cy.$(isSelected).unselect(['tapunselect']); + if (draggedElements.length > 0) { + r.redrawHint('eles', true); + } + r.dragData.possibleDragElements = draggedElements = cy.collection(); + } + + // Single selection + if (near == down && !r.dragData.didDrag && !r.hoverData.selecting) { + if (near != null && near._private.selectable) { + if (r.hoverData.dragging) ; else if (cy.selectionType() === 'additive' || multSelKeyDown) { + if (near.selected()) { + near.unselect(['tapunselect']); + } else { + near.select(['tapselect']); + } + } else { + if (!multSelKeyDown) { + cy.$(isSelected).unmerge(near).unselect(['tapunselect']); + near.select(['tapselect']); + } + } + r.redrawHint('eles', true); + } + } + if (r.hoverData.selecting) { + var box = cy.collection(r.getAllInBox(select[0], select[1], select[2], select[3])); + r.redrawHint('select', true); + if (box.length > 0) { + r.redrawHint('eles', true); + } + cy.emit({ + type: 'boxend', + originalEvent: e, + position: { + x: pos[0], + y: pos[1] + } + }); + var eleWouldBeSelected = function eleWouldBeSelected(ele) { + return ele.selectable() && !ele.selected(); + }; + if (cy.selectionType() === 'additive') { + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + } else { + if (!multSelKeyDown) { + cy.$(isSelected).unmerge(box).unselect(); + } + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + } + + // always need redraw in case eles unselectable + r.redraw(); + } + + // Cancel drag pan + if (r.hoverData.dragging) { + r.hoverData.dragging = false; + r.redrawHint('select', true); + r.redrawHint('eles', true); + r.redraw(); + } + if (!select[4]) { + r.redrawHint('drag', true); + r.redrawHint('eles', true); + var downWasGrabbed = down && down.grabbed(); + freeDraggedElements(draggedElements); + if (downWasGrabbed) { + down.emit('freeon'); + draggedElements.emit('free'); + if (r.dragData.didDrag) { + down.emit('dragfreeon'); + draggedElements.emit('dragfree'); + } + } + } + } // else not right mouse + + select[4] = 0; + r.hoverData.down = null; + r.hoverData.cxtStarted = false; + r.hoverData.draggingEles = false; + r.hoverData.selecting = false; + r.hoverData.isOverThresholdDrag = false; + r.dragData.didDrag = false; + r.hoverData.dragged = false; + r.hoverData.dragDelta = []; + r.hoverData.mdownPos = null; + r.hoverData.mdownGPos = null; + }, false); + var wheelHandler = function wheelHandler(e) { + if (r.scrollingPage) { + return; + } // while scrolling, ignore wheel-to-zoom + + var cy = r.cy; + var zoom = cy.zoom(); + var pan = cy.pan(); + var pos = r.projectIntoViewport(e.clientX, e.clientY); + var rpos = [pos[0] * zoom + pan.x, pos[1] * zoom + pan.y]; + if (r.hoverData.draggingEles || r.hoverData.dragging || r.hoverData.cxtStarted || inBoxSelection()) { + // if pan dragging or cxt dragging, wheel movements make no zoom + e.preventDefault(); + return; + } + if (cy.panningEnabled() && cy.userPanningEnabled() && cy.zoomingEnabled() && cy.userZoomingEnabled()) { + e.preventDefault(); + r.data.wheelZooming = true; + clearTimeout(r.data.wheelTimeout); + r.data.wheelTimeout = setTimeout(function () { + r.data.wheelZooming = false; + r.redrawHint('eles', true); + r.redraw(); + }, 150); + var diff; + if (e.deltaY != null) { + diff = e.deltaY / -250; + } else if (e.wheelDeltaY != null) { + diff = e.wheelDeltaY / 1000; + } else { + diff = e.wheelDelta / 1000; + } + diff = diff * r.wheelSensitivity; + var needsWheelFix = e.deltaMode === 1; + if (needsWheelFix) { + // fixes slow wheel events on ff/linux and ff/windows + diff *= 33; + } + var newZoom = cy.zoom() * Math.pow(10, diff); + if (e.type === 'gesturechange') { + newZoom = r.gestureStartZoom * e.scale; + } + cy.zoom({ + level: newZoom, + renderedPosition: { + x: rpos[0], + y: rpos[1] + } + }); + cy.emit(e.type === 'gesturechange' ? 'pinchzoom' : 'scrollzoom'); + } + }; + + // Functions to help with whether mouse wheel should trigger zooming + // -- + r.registerBinding(r.container, 'wheel', wheelHandler, true); + + // disable nonstandard wheel events + // r.registerBinding(r.container, 'mousewheel', wheelHandler, true); + // r.registerBinding(r.container, 'DOMMouseScroll', wheelHandler, true); + // r.registerBinding(r.container, 'MozMousePixelScroll', wheelHandler, true); // older firefox + + r.registerBinding(containerWindow, 'scroll', function scrollHandler(e) { + // eslint-disable-line no-unused-vars + r.scrollingPage = true; + clearTimeout(r.scrollingPageTimeout); + r.scrollingPageTimeout = setTimeout(function () { + r.scrollingPage = false; + }, 250); + }, true); + + // desktop safari pinch to zoom start + r.registerBinding(r.container, 'gesturestart', function gestureStartHandler(e) { + r.gestureStartZoom = r.cy.zoom(); + if (!r.hasTouchStarted) { + // don't affect touch devices like iphone + e.preventDefault(); + } + }, true); + r.registerBinding(r.container, 'gesturechange', function (e) { + if (!r.hasTouchStarted) { + // don't affect touch devices like iphone + wheelHandler(e); + } + }, true); + + // Functions to help with handling mouseout/mouseover on the Cytoscape container + // Handle mouseout on Cytoscape container + r.registerBinding(r.container, 'mouseout', function mouseOutHandler(e) { + var pos = r.projectIntoViewport(e.clientX, e.clientY); + r.cy.emit({ + originalEvent: e, + type: 'mouseout', + position: { + x: pos[0], + y: pos[1] + } + }); + }, false); + r.registerBinding(r.container, 'mouseover', function mouseOverHandler(e) { + var pos = r.projectIntoViewport(e.clientX, e.clientY); + r.cy.emit({ + originalEvent: e, + type: 'mouseover', + position: { + x: pos[0], + y: pos[1] + } + }); + }, false); + var f1x1, f1y1, f2x1, f2y1; // starting points for pinch-to-zoom + var distance1, distance1Sq; // initial distance between finger 1 and finger 2 for pinch-to-zoom + var center1, modelCenter1; // center point on start pinch to zoom + var offsetLeft, offsetTop; + var containerWidth, containerHeight; + var twoFingersStartInside; + var distance = function distance(x1, y1, x2, y2) { + return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + }; + var distanceSq = function distanceSq(x1, y1, x2, y2) { + return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); + }; + var touchstartHandler; + r.registerBinding(r.container, 'touchstart', touchstartHandler = function touchstartHandler(e) { + r.hasTouchStarted = true; + if (!eventInContainer(e)) { + return; + } + blurActiveDomElement(); + r.touchData.capture = true; + r.data.bgActivePosistion = undefined; + var cy = r.cy; + var now = r.touchData.now; + var earlier = r.touchData.earlier; + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + + // record starting points for pinch-to-zoom + if (e.touches[1]) { + r.touchData.singleTouchMoved = true; + freeDraggedElements(r.dragData.touchDragEles); + var offsets = r.findContainerClientCoords(); + offsetLeft = offsets[0]; + offsetTop = offsets[1]; + containerWidth = offsets[2]; + containerHeight = offsets[3]; + f1x1 = e.touches[0].clientX - offsetLeft; + f1y1 = e.touches[0].clientY - offsetTop; + f2x1 = e.touches[1].clientX - offsetLeft; + f2y1 = e.touches[1].clientY - offsetTop; + twoFingersStartInside = 0 <= f1x1 && f1x1 <= containerWidth && 0 <= f2x1 && f2x1 <= containerWidth && 0 <= f1y1 && f1y1 <= containerHeight && 0 <= f2y1 && f2y1 <= containerHeight; + var pan = cy.pan(); + var zoom = cy.zoom(); + distance1 = distance(f1x1, f1y1, f2x1, f2y1); + distance1Sq = distanceSq(f1x1, f1y1, f2x1, f2y1); + center1 = [(f1x1 + f2x1) / 2, (f1y1 + f2y1) / 2]; + modelCenter1 = [(center1[0] - pan.x) / zoom, (center1[1] - pan.y) / zoom]; + + // consider context tap + var cxtDistThreshold = 200; + var cxtDistThresholdSq = cxtDistThreshold * cxtDistThreshold; + if (distance1Sq < cxtDistThresholdSq && !e.touches[2]) { + var near1 = r.findNearestElement(now[0], now[1], true, true); + var near2 = r.findNearestElement(now[2], now[3], true, true); + if (near1 && near1.isNode()) { + near1.activate().emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + r.touchData.start = near1; + } else if (near2 && near2.isNode()) { + near2.activate().emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + r.touchData.start = near2; + } else { + cy.emit({ + originalEvent: e, + type: 'cxttapstart', + position: { + x: now[0], + y: now[1] + } + }); + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxt = true; + r.touchData.cxtDragged = false; + r.data.bgActivePosistion = undefined; + r.redraw(); + return; + } + } + if (e.touches[2]) { + // ignore + + // safari on ios pans the page otherwise (normally you should be able to preventdefault on touchmove...) + if (cy.boxSelectionEnabled()) { + e.preventDefault(); + } + } else if (e.touches[1]) ; else if (e.touches[0]) { + var nears = r.findNearestElements(now[0], now[1], true, true); + var near = nears[0]; + if (near != null) { + near.activate(); + r.touchData.start = near; + r.touchData.starts = nears; + if (r.nodeIsGrabbable(near)) { + var draggedEles = r.dragData.touchDragEles = cy.collection(); + var selectedNodes = null; + r.redrawHint('eles', true); + r.redrawHint('drag', true); + if (near.selected()) { + // reset drag elements, since near will be added again + + selectedNodes = cy.$(function (ele) { + return ele.selected() && r.nodeIsGrabbable(ele); + }); + addNodesToDrag(selectedNodes, { + addToList: draggedEles + }); + } else { + addNodeToDrag(near, { + addToList: draggedEles + }); + } + setGrabTarget(near); + var makeEvent = function makeEvent(type) { + return { + originalEvent: e, + type: type, + position: { + x: now[0], + y: now[1] + } + }; + }; + near.emit(makeEvent('grabon')); + if (selectedNodes) { + selectedNodes.forEach(function (n) { + n.emit(makeEvent('grab')); + }); + } else { + near.emit(makeEvent('grab')); + } + } + } + triggerEvents(near, ['touchstart', 'tapstart', 'vmousedown'], e, { + x: now[0], + y: now[1] + }); + if (near == null) { + r.data.bgActivePosistion = { + x: pos[0], + y: pos[1] + }; + r.redrawHint('select', true); + r.redraw(); + } + + // Tap, taphold + // ----- + + r.touchData.singleTouchMoved = false; + r.touchData.singleTouchStartTime = +new Date(); + clearTimeout(r.touchData.tapholdTimeout); + r.touchData.tapholdTimeout = setTimeout(function () { + if (r.touchData.singleTouchMoved === false && !r.pinching // if pinching, then taphold unselect shouldn't take effect + && !r.touchData.selecting // box selection shouldn't allow taphold through + ) { + triggerEvents(r.touchData.start, ['taphold'], e, { + x: now[0], + y: now[1] + }); + } + }, r.tapholdDuration); + } + if (e.touches.length >= 1) { + var sPos = r.touchData.startPosition = [null, null, null, null, null, null]; + for (var i = 0; i < now.length; i++) { + sPos[i] = earlier[i] = now[i]; + } + var touch0 = e.touches[0]; + r.touchData.startGPosition = [touch0.clientX, touch0.clientY]; + } + }, false); + var touchmoveHandler; + r.registerBinding(window, 'touchmove', touchmoveHandler = function touchmoveHandler(e) { + // eslint-disable-line no-undef + var capture = r.touchData.capture; + if (!capture && !eventInContainer(e)) { + return; + } + var select = r.selection; + var cy = r.cy; + var now = r.touchData.now; + var earlier = r.touchData.earlier; + var zoom = cy.zoom(); + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + var startGPos = r.touchData.startGPosition; + var isOverThresholdDrag; + if (capture && e.touches[0] && startGPos) { + var disp = []; + for (var j = 0; j < now.length; j++) { + disp[j] = now[j] - earlier[j]; + } + var dx = e.touches[0].clientX - startGPos[0]; + var dx2 = dx * dx; + var dy = e.touches[0].clientY - startGPos[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + isOverThresholdDrag = dist2 >= r.touchTapThreshold2; + } + + // context swipe cancelling + if (capture && r.touchData.cxt) { + e.preventDefault(); + var f1x2 = e.touches[0].clientX - offsetLeft, + f1y2 = e.touches[0].clientY - offsetTop; + var f2x2 = e.touches[1].clientX - offsetLeft, + f2y2 = e.touches[1].clientY - offsetTop; + // var distance2 = distance( f1x2, f1y2, f2x2, f2y2 ); + var distance2Sq = distanceSq(f1x2, f1y2, f2x2, f2y2); + var factorSq = distance2Sq / distance1Sq; + var distThreshold = 150; + var distThresholdSq = distThreshold * distThreshold; + var factorThreshold = 1.5; + var factorThresholdSq = factorThreshold * factorThreshold; + + // cancel ctx gestures if the distance b/t the fingers increases + if (factorSq >= factorThresholdSq || distance2Sq >= distThresholdSq) { + r.touchData.cxt = false; + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var cxtEvt = { + originalEvent: e, + type: 'cxttapend', + position: { + x: now[0], + y: now[1] + } + }; + if (r.touchData.start) { + r.touchData.start.unactivate().emit(cxtEvt); + r.touchData.start = null; + } else { + cy.emit(cxtEvt); + } + } + } + + // context swipe + if (capture && r.touchData.cxt) { + var cxtEvt = { + originalEvent: e, + type: 'cxtdrag', + position: { + x: now[0], + y: now[1] + } + }; + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + if (r.touchData.start) { + r.touchData.start.emit(cxtEvt); + } else { + cy.emit(cxtEvt); + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxtDragged = true; + var near = r.findNearestElement(now[0], now[1], true, true); + if (!r.touchData.cxtOver || near !== r.touchData.cxtOver) { + if (r.touchData.cxtOver) { + r.touchData.cxtOver.emit({ + originalEvent: e, + type: 'cxtdragout', + position: { + x: now[0], + y: now[1] + } + }); + } + r.touchData.cxtOver = near; + if (near) { + near.emit({ + originalEvent: e, + type: 'cxtdragover', + position: { + x: now[0], + y: now[1] + } + }); + } + } + + // box selection + } else if (capture && e.touches[2] && cy.boxSelectionEnabled()) { + e.preventDefault(); + r.data.bgActivePosistion = undefined; + this.lastThreeTouch = +new Date(); + if (!r.touchData.selecting) { + cy.emit({ + originalEvent: e, + type: 'boxstart', + position: { + x: now[0], + y: now[1] + } + }); + } + r.touchData.selecting = true; + r.touchData.didSelect = true; + select[4] = 1; + if (!select || select.length === 0 || select[0] === undefined) { + select[0] = (now[0] + now[2] + now[4]) / 3; + select[1] = (now[1] + now[3] + now[5]) / 3; + select[2] = (now[0] + now[2] + now[4]) / 3 + 1; + select[3] = (now[1] + now[3] + now[5]) / 3 + 1; + } else { + select[2] = (now[0] + now[2] + now[4]) / 3; + select[3] = (now[1] + now[3] + now[5]) / 3; + } + r.redrawHint('select', true); + r.redraw(); + + // pinch to zoom + } else if (capture && e.touches[1] && !r.touchData.didSelect // don't allow box selection to degrade to pinch-to-zoom + && cy.zoomingEnabled() && cy.panningEnabled() && cy.userZoomingEnabled() && cy.userPanningEnabled()) { + // two fingers => pinch to zoom + e.preventDefault(); + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var draggedEles = r.dragData.touchDragEles; + if (draggedEles) { + r.redrawHint('drag', true); + for (var i = 0; i < draggedEles.length; i++) { + var de_p = draggedEles[i]._private; + de_p.grabbed = false; + de_p.rscratch.inDragLayer = false; + } + } + var _start = r.touchData.start; + + // (x2, y2) for fingers 1 and 2 + var f1x2 = e.touches[0].clientX - offsetLeft, + f1y2 = e.touches[0].clientY - offsetTop; + var f2x2 = e.touches[1].clientX - offsetLeft, + f2y2 = e.touches[1].clientY - offsetTop; + var distance2 = distance(f1x2, f1y2, f2x2, f2y2); + // var distance2Sq = distanceSq( f1x2, f1y2, f2x2, f2y2 ); + // var factor = Math.sqrt( distance2Sq ) / Math.sqrt( distance1Sq ); + var factor = distance2 / distance1; + if (twoFingersStartInside) { + // delta finger1 + var df1x = f1x2 - f1x1; + var df1y = f1y2 - f1y1; + + // delta finger 2 + var df2x = f2x2 - f2x1; + var df2y = f2y2 - f2y1; + + // translation is the normalised vector of the two fingers movement + // i.e. so pinching cancels out and moving together pans + var tx = (df1x + df2x) / 2; + var ty = (df1y + df2y) / 2; + + // now calculate the zoom + var zoom1 = cy.zoom(); + var zoom2 = zoom1 * factor; + var pan1 = cy.pan(); + + // the model center point converted to the current rendered pos + var ctrx = modelCenter1[0] * zoom1 + pan1.x; + var ctry = modelCenter1[1] * zoom1 + pan1.y; + var pan2 = { + x: -zoom2 / zoom1 * (ctrx - pan1.x - tx) + ctrx, + y: -zoom2 / zoom1 * (ctry - pan1.y - ty) + ctry + }; + + // remove dragged eles + if (_start && _start.active()) { + var draggedEles = r.dragData.touchDragEles; + freeDraggedElements(draggedEles); + r.redrawHint('drag', true); + r.redrawHint('eles', true); + _start.unactivate().emit('freeon'); + draggedEles.emit('free'); + if (r.dragData.didDrag) { + _start.emit('dragfreeon'); + draggedEles.emit('dragfree'); + } + } + cy.viewport({ + zoom: zoom2, + pan: pan2, + cancelOnFailedZoom: true + }); + cy.emit('pinchzoom'); + distance1 = distance2; + f1x1 = f1x2; + f1y1 = f1y2; + f2x1 = f2x2; + f2y1 = f2y2; + r.pinching = true; + } + + // Re-project + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + } else if (e.touches[0] && !r.touchData.didSelect // don't allow box selection to degrade to single finger events like panning + ) { + var start = r.touchData.start; + var last = r.touchData.last; + var near; + if (!r.hoverData.draggingEles && !r.swipePanning) { + near = r.findNearestElement(now[0], now[1], true, true); + } + if (capture && start != null) { + e.preventDefault(); + } + + // dragging nodes + if (capture && start != null && r.nodeIsDraggable(start)) { + if (isOverThresholdDrag) { + // then dragging can happen + var draggedEles = r.dragData.touchDragEles; + var justStartedDrag = !r.dragData.didDrag; + if (justStartedDrag) { + addNodesToDrag(draggedEles, { + inDragLayer: true + }); + } + r.dragData.didDrag = true; + var totalShift = { + x: 0, + y: 0 + }; + if (number$1(disp[0]) && number$1(disp[1])) { + totalShift.x += disp[0]; + totalShift.y += disp[1]; + if (justStartedDrag) { + r.redrawHint('eles', true); + var dragDelta = r.touchData.dragDelta; + if (dragDelta && number$1(dragDelta[0]) && number$1(dragDelta[1])) { + totalShift.x += dragDelta[0]; + totalShift.y += dragDelta[1]; + } + } + } + r.hoverData.draggingEles = true; + draggedEles.silentShift(totalShift).emit('position drag'); + r.redrawHint('drag', true); + if (r.touchData.startPosition[0] == earlier[0] && r.touchData.startPosition[1] == earlier[1]) { + r.redrawHint('eles', true); + } + r.redraw(); + } else { + // otherwise keep track of drag delta for later + var dragDelta = r.touchData.dragDelta = r.touchData.dragDelta || []; + if (dragDelta.length === 0) { + dragDelta.push(disp[0]); + dragDelta.push(disp[1]); + } else { + dragDelta[0] += disp[0]; + dragDelta[1] += disp[1]; + } + } + } + + // touchmove + { + triggerEvents(start || near, ['touchmove', 'tapdrag', 'vmousemove'], e, { + x: now[0], + y: now[1] + }); + if ((!start || !start.grabbed()) && near != last) { + if (last) { + last.emit({ + originalEvent: e, + type: 'tapdragout', + position: { + x: now[0], + y: now[1] + } + }); + } + if (near) { + near.emit({ + originalEvent: e, + type: 'tapdragover', + position: { + x: now[0], + y: now[1] + } + }); + } + } + r.touchData.last = near; + } + + // check to cancel taphold + if (capture) { + for (var i = 0; i < now.length; i++) { + if (now[i] && r.touchData.startPosition[i] && isOverThresholdDrag) { + r.touchData.singleTouchMoved = true; + } + } + } + + // panning + if (capture && (start == null || start.pannable()) && cy.panningEnabled() && cy.userPanningEnabled()) { + var allowPassthrough = allowPanningPassthrough(start, r.touchData.starts); + if (allowPassthrough) { + e.preventDefault(); + if (!r.data.bgActivePosistion) { + r.data.bgActivePosistion = array2point(r.touchData.startPosition); + } + if (r.swipePanning) { + cy.panBy({ + x: disp[0] * zoom, + y: disp[1] * zoom + }); + cy.emit('dragpan'); + } else if (isOverThresholdDrag) { + r.swipePanning = true; + cy.panBy({ + x: dx * zoom, + y: dy * zoom + }); + cy.emit('dragpan'); + if (start) { + start.unactivate(); + r.redrawHint('select', true); + r.touchData.start = null; + } + } + } + + // Re-project + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + } + for (var j = 0; j < now.length; j++) { + earlier[j] = now[j]; + } + + // the active bg indicator should be removed when making a swipe that is neither for dragging nodes or panning + if (capture && e.touches.length > 0 && !r.hoverData.draggingEles && !r.swipePanning && r.data.bgActivePosistion != null) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + r.redraw(); + } + }, false); + var touchcancelHandler; + r.registerBinding(containerWindow, 'touchcancel', touchcancelHandler = function touchcancelHandler(e) { + // eslint-disable-line no-unused-vars + var start = r.touchData.start; + r.touchData.capture = false; + if (start) { + start.unactivate(); + } + }); + var touchendHandler, didDoubleTouch, touchTimeout, prevTouchTimeStamp; + r.registerBinding(containerWindow, 'touchend', touchendHandler = function touchendHandler(e) { + // eslint-disable-line no-unused-vars + var start = r.touchData.start; + var capture = r.touchData.capture; + if (capture) { + if (e.touches.length === 0) { + r.touchData.capture = false; + } + e.preventDefault(); + } else { + return; + } + var select = r.selection; + r.swipePanning = false; + r.hoverData.draggingEles = false; + var cy = r.cy; + var zoom = cy.zoom(); + var now = r.touchData.now; + var earlier = r.touchData.earlier; + if (e.touches[0]) { + var pos = r.projectIntoViewport(e.touches[0].clientX, e.touches[0].clientY); + now[0] = pos[0]; + now[1] = pos[1]; + } + if (e.touches[1]) { + var pos = r.projectIntoViewport(e.touches[1].clientX, e.touches[1].clientY); + now[2] = pos[0]; + now[3] = pos[1]; + } + if (e.touches[2]) { + var pos = r.projectIntoViewport(e.touches[2].clientX, e.touches[2].clientY); + now[4] = pos[0]; + now[5] = pos[1]; + } + if (start) { + start.unactivate(); + } + var ctxTapend; + if (r.touchData.cxt) { + ctxTapend = { + originalEvent: e, + type: 'cxttapend', + position: { + x: now[0], + y: now[1] + } + }; + if (start) { + start.emit(ctxTapend); + } else { + cy.emit(ctxTapend); + } + if (!r.touchData.cxtDragged) { + var ctxTap = { + originalEvent: e, + type: 'cxttap', + position: { + x: now[0], + y: now[1] + } + }; + if (start) { + start.emit(ctxTap); + } else { + cy.emit(ctxTap); + } + } + if (r.touchData.start) { + r.touchData.start._private.grabbed = false; + } + r.touchData.cxt = false; + r.touchData.start = null; + r.redraw(); + return; + } + + // no more box selection if we don't have three fingers + if (!e.touches[2] && cy.boxSelectionEnabled() && r.touchData.selecting) { + r.touchData.selecting = false; + var box = cy.collection(r.getAllInBox(select[0], select[1], select[2], select[3])); + select[0] = undefined; + select[1] = undefined; + select[2] = undefined; + select[3] = undefined; + select[4] = 0; + r.redrawHint('select', true); + cy.emit({ + type: 'boxend', + originalEvent: e, + position: { + x: now[0], + y: now[1] + } + }); + var eleWouldBeSelected = function eleWouldBeSelected(ele) { + return ele.selectable() && !ele.selected(); + }; + box.emit('box').stdFilter(eleWouldBeSelected).select().emit('boxselect'); + if (box.nonempty()) { + r.redrawHint('eles', true); + } + r.redraw(); + } + if (start != null) { + start.unactivate(); + } + if (e.touches[2]) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + } else if (e.touches[1]) ; else if (e.touches[0]) ; else if (!e.touches[0]) { + r.data.bgActivePosistion = undefined; + r.redrawHint('select', true); + var draggedEles = r.dragData.touchDragEles; + if (start != null) { + var startWasGrabbed = start._private.grabbed; + freeDraggedElements(draggedEles); + r.redrawHint('drag', true); + r.redrawHint('eles', true); + if (startWasGrabbed) { + start.emit('freeon'); + draggedEles.emit('free'); + if (r.dragData.didDrag) { + start.emit('dragfreeon'); + draggedEles.emit('dragfree'); + } + } + triggerEvents(start, ['touchend', 'tapend', 'vmouseup', 'tapdragout'], e, { + x: now[0], + y: now[1] + }); + start.unactivate(); + r.touchData.start = null; + } else { + var near = r.findNearestElement(now[0], now[1], true, true); + triggerEvents(near, ['touchend', 'tapend', 'vmouseup', 'tapdragout'], e, { + x: now[0], + y: now[1] + }); + } + var dx = r.touchData.startPosition[0] - now[0]; + var dx2 = dx * dx; + var dy = r.touchData.startPosition[1] - now[1]; + var dy2 = dy * dy; + var dist2 = dx2 + dy2; + var rdist2 = dist2 * zoom * zoom; + + // Tap event, roughly same as mouse click event for touch + if (!r.touchData.singleTouchMoved) { + if (!start) { + cy.$(':selected').unselect(['tapunselect']); + } + triggerEvents(start, ['tap', 'vclick'], e, { + x: now[0], + y: now[1] + }); + didDoubleTouch = false; + if (e.timeStamp - prevTouchTimeStamp <= cy.multiClickDebounceTime()) { + touchTimeout && clearTimeout(touchTimeout); + didDoubleTouch = true; + prevTouchTimeStamp = null; + triggerEvents(start, ['dbltap', 'vdblclick'], e, { + x: now[0], + y: now[1] + }); + } else { + touchTimeout = setTimeout(function () { + if (didDoubleTouch) return; + triggerEvents(start, ['onetap', 'voneclick'], e, { + x: now[0], + y: now[1] + }); + }, cy.multiClickDebounceTime()); + prevTouchTimeStamp = e.timeStamp; + } + } + + // Prepare to select the currently touched node, only if it hasn't been dragged past a certain distance + if (start != null && !r.dragData.didDrag // didn't drag nodes around + && start._private.selectable && rdist2 < r.touchTapThreshold2 && !r.pinching // pinch to zoom should not affect selection + ) { + if (cy.selectionType() === 'single') { + cy.$(isSelected).unmerge(start).unselect(['tapunselect']); + start.select(['tapselect']); + } else { + if (start.selected()) { + start.unselect(['tapunselect']); + } else { + start.select(['tapselect']); + } + } + r.redrawHint('eles', true); + } + r.touchData.singleTouchMoved = true; + } + for (var j = 0; j < now.length; j++) { + earlier[j] = now[j]; + } + r.dragData.didDrag = false; // reset for next touchstart + + if (e.touches.length === 0) { + r.touchData.dragDelta = []; + r.touchData.startPosition = [null, null, null, null, null, null]; + r.touchData.startGPosition = null; + r.touchData.didSelect = false; + } + if (e.touches.length < 2) { + if (e.touches.length === 1) { + // the old start global pos'n may not be the same finger that remains + r.touchData.startGPosition = [e.touches[0].clientX, e.touches[0].clientY]; + } + r.pinching = false; + r.redrawHint('eles', true); + r.redraw(); + } + + //r.redraw(); + }, false); + + // fallback compatibility layer for ms pointer events + if (typeof TouchEvent === 'undefined') { + var pointers = []; + var makeTouch = function makeTouch(e) { + return { + clientX: e.clientX, + clientY: e.clientY, + force: 1, + identifier: e.pointerId, + pageX: e.pageX, + pageY: e.pageY, + radiusX: e.width / 2, + radiusY: e.height / 2, + screenX: e.screenX, + screenY: e.screenY, + target: e.target + }; + }; + var makePointer = function makePointer(e) { + return { + event: e, + touch: makeTouch(e) + }; + }; + var addPointer = function addPointer(e) { + pointers.push(makePointer(e)); + }; + var removePointer = function removePointer(e) { + for (var i = 0; i < pointers.length; i++) { + var p = pointers[i]; + if (p.event.pointerId === e.pointerId) { + pointers.splice(i, 1); + return; + } + } + }; + var updatePointer = function updatePointer(e) { + var p = pointers.filter(function (p) { + return p.event.pointerId === e.pointerId; + })[0]; + p.event = e; + p.touch = makeTouch(e); + }; + var addTouchesToEvent = function addTouchesToEvent(e) { + e.touches = pointers.map(function (p) { + return p.touch; + }); + }; + var pointerIsMouse = function pointerIsMouse(e) { + return e.pointerType === 'mouse' || e.pointerType === 4; + }; + r.registerBinding(r.container, 'pointerdown', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + e.preventDefault(); + addPointer(e); + addTouchesToEvent(e); + touchstartHandler(e); + }); + r.registerBinding(r.container, 'pointerup', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + removePointer(e); + addTouchesToEvent(e); + touchendHandler(e); + }); + r.registerBinding(r.container, 'pointercancel', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + removePointer(e); + addTouchesToEvent(e); + touchcancelHandler(e); + }); + r.registerBinding(r.container, 'pointermove', function (e) { + if (pointerIsMouse(e)) { + return; + } // mouse already handled + + e.preventDefault(); + updatePointer(e); + addTouchesToEvent(e); + touchmoveHandler(e); + }); + } +}; + +var BRp$2 = {}; +BRp$2.generatePolygon = function (name, points) { + return this.nodeShapes[name] = { + renderer: this, + name: name, + points: points, + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl('polygon', context, centerX, centerY, width, height, this.points); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return polygonIntersectLine(x, y, this.points, nodeX, nodeY, width / 2, height / 2, padding); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + return pointInsidePolygon(x, y, this.points, centerX, centerY, width, height, [0, -1], padding); + } + }; +}; +BRp$2.generateEllipse = function () { + return this.nodeShapes['ellipse'] = { + renderer: this, + name: 'ellipse', + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return intersectLineEllipse(x, y, nodeX, nodeY, width / 2 + padding, height / 2 + padding); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + return checkInEllipse(x, y, width, height, centerX, centerY, padding); + } + }; +}; +BRp$2.generateRoundPolygon = function (name, points) { + return this.nodeShapes[name] = { + renderer: this, + name: name, + points: points, + getOrCreateCorners: function getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, field) { + if (rs[field] !== undefined && rs[field + '-cx'] === centerX && rs[field + '-cy'] === centerY) { + return rs[field]; + } + rs[field] = new Array(points.length / 2); + rs[field + '-cx'] = centerX; + rs[field + '-cy'] = centerY; + var halfW = width / 2; + var halfH = height / 2; + cornerRadius = cornerRadius === 'auto' ? getRoundPolygonRadius(width, height) : cornerRadius; + var p = new Array(points.length / 2); + for (var _i = 0; _i < points.length / 2; _i++) { + p[_i] = { + x: centerX + halfW * points[_i * 2], + y: centerY + halfH * points[_i * 2 + 1] + }; + } + var i, + p1, + p2, + p3, + len = p.length; + p1 = p[len - 1]; + // for each point + for (i = 0; i < len; i++) { + p2 = p[i % len]; + p3 = p[(i + 1) % len]; + rs[field][i] = getRoundCorner(p1, p2, p3, cornerRadius); + p1 = p2; + p2 = p3; + } + return rs[field]; + }, + draw: function draw(context, centerX, centerY, width, height, cornerRadius, rs) { + this.renderer.nodeShapeImpl('round-polygon', context, centerX, centerY, width, height, this.points, this.getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, 'drawCorners')); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius, rs) { + return roundPolygonIntersectLine(x, y, this.points, nodeX, nodeY, width, height, padding, this.getOrCreateCorners(nodeX, nodeY, width, height, cornerRadius, rs, 'corners')); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius, rs) { + return pointInsideRoundPolygon(x, y, this.points, centerX, centerY, width, height, this.getOrCreateCorners(centerX, centerY, width, height, cornerRadius, rs, 'corners')); + } + }; +}; +BRp$2.generateRoundRectangle = function () { + return this.nodeShapes['round-rectangle'] = this.nodeShapes['roundrectangle'] = { + renderer: this, + name: 'round-rectangle', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, this.points, cornerRadius); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + return roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding, cornerRadius); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(width, height) : cornerRadius; + cornerRadius = Math.min(halfWidth, halfHeight, cornerRadius); + var diam = cornerRadius * 2; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - diam, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - diam, height, [0, -1], padding)) { + return true; + } + + // Check top left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - halfWidth + cornerRadius, centerY - halfHeight + cornerRadius, padding)) { + return true; + } + + // Check top right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + halfWidth - cornerRadius, centerY - halfHeight + cornerRadius, padding)) { + return true; + } + + // Check bottom right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + halfWidth - cornerRadius, centerY + halfHeight - cornerRadius, padding)) { + return true; + } + + // Check bottom left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - halfWidth + cornerRadius, centerY + halfHeight - cornerRadius, padding)) { + return true; + } + return false; + } + }; +}; +BRp$2.generateCutRectangle = function () { + return this.nodeShapes['cut-rectangle'] = this.nodeShapes['cutrectangle'] = { + renderer: this, + name: 'cut-rectangle', + cornerLength: getCutRectangleCornerLength(), + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, null, cornerRadius); + }, + generateCutTrianglePts: function generateCutTrianglePts(width, height, centerX, centerY, cornerRadius) { + var cl = cornerRadius === 'auto' ? this.cornerLength : cornerRadius; + var hh = height / 2; + var hw = width / 2; + var xBegin = centerX - hw; + var xEnd = centerX + hw; + var yBegin = centerY - hh; + var yEnd = centerY + hh; + + // points are in clockwise order, inner (imaginary) triangle pt on [4, 5] + return { + topLeft: [xBegin, yBegin + cl, xBegin + cl, yBegin, xBegin + cl, yBegin + cl], + topRight: [xEnd - cl, yBegin, xEnd, yBegin + cl, xEnd - cl, yBegin + cl], + bottomRight: [xEnd, yEnd - cl, xEnd - cl, yEnd, xEnd - cl, yEnd - cl], + bottomLeft: [xBegin + cl, yEnd, xBegin, yEnd - cl, xBegin + cl, yEnd - cl] + }; + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + var cPts = this.generateCutTrianglePts(width + 2 * padding, height + 2 * padding, nodeX, nodeY, cornerRadius); + var pts = [].concat.apply([], [cPts.topLeft.splice(0, 4), cPts.topRight.splice(0, 4), cPts.bottomRight.splice(0, 4), cPts.bottomLeft.splice(0, 4)]); + return polygonIntersectLine(x, y, pts, nodeX, nodeY); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var cl = cornerRadius === 'auto' ? this.cornerLength : cornerRadius; + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - 2 * cl, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - 2 * cl, height, [0, -1], padding)) { + return true; + } + var cutTrianglePts = this.generateCutTrianglePts(width, height, centerX, centerY); + return pointInsidePolygonPoints(x, y, cutTrianglePts.topLeft) || pointInsidePolygonPoints(x, y, cutTrianglePts.topRight) || pointInsidePolygonPoints(x, y, cutTrianglePts.bottomRight) || pointInsidePolygonPoints(x, y, cutTrianglePts.bottomLeft); + } + }; +}; +BRp$2.generateBarrel = function () { + return this.nodeShapes['barrel'] = { + renderer: this, + name: 'barrel', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + // use two fixed t values for the bezier curve approximation + + var t0 = 0.15; + var t1 = 0.5; + var t2 = 0.85; + var bPts = this.generateBarrelBezierPts(width + 2 * padding, height + 2 * padding, nodeX, nodeY); + var approximateBarrelCurvePts = function approximateBarrelCurvePts(pts) { + // approximate curve pts based on the two t values + var m0 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t0); + var m1 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t1); + var m2 = qbezierPtAt({ + x: pts[0], + y: pts[1] + }, { + x: pts[2], + y: pts[3] + }, { + x: pts[4], + y: pts[5] + }, t2); + return [pts[0], pts[1], m0.x, m0.y, m1.x, m1.y, m2.x, m2.y, pts[4], pts[5]]; + }; + var pts = [].concat(approximateBarrelCurvePts(bPts.topLeft), approximateBarrelCurvePts(bPts.topRight), approximateBarrelCurvePts(bPts.bottomRight), approximateBarrelCurvePts(bPts.bottomLeft)); + return polygonIntersectLine(x, y, pts, nodeX, nodeY); + }, + generateBarrelBezierPts: function generateBarrelBezierPts(width, height, centerX, centerY) { + var hh = height / 2; + var hw = width / 2; + var xBegin = centerX - hw; + var xEnd = centerX + hw; + var yBegin = centerY - hh; + var yEnd = centerY + hh; + var curveConstants = getBarrelCurveConstants(width, height); + var hOffset = curveConstants.heightOffset; + var wOffset = curveConstants.widthOffset; + var ctrlPtXOffset = curveConstants.ctrlPtOffsetPct * width; + + // points are in clockwise order, inner (imaginary) control pt on [4, 5] + var pts = { + topLeft: [xBegin, yBegin + hOffset, xBegin + ctrlPtXOffset, yBegin, xBegin + wOffset, yBegin], + topRight: [xEnd - wOffset, yBegin, xEnd - ctrlPtXOffset, yBegin, xEnd, yBegin + hOffset], + bottomRight: [xEnd, yEnd - hOffset, xEnd - ctrlPtXOffset, yEnd, xEnd - wOffset, yEnd], + bottomLeft: [xBegin + wOffset, yEnd, xBegin + ctrlPtXOffset, yEnd, xBegin, yEnd - hOffset] + }; + pts.topLeft.isTop = true; + pts.topRight.isTop = true; + pts.bottomLeft.isBottom = true; + pts.bottomRight.isBottom = true; + return pts; + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + var curveConstants = getBarrelCurveConstants(width, height); + var hOffset = curveConstants.heightOffset; + var wOffset = curveConstants.widthOffset; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - 2 * hOffset, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - 2 * wOffset, height, [0, -1], padding)) { + return true; + } + var barrelCurvePts = this.generateBarrelBezierPts(width, height, centerX, centerY); + var getCurveT = function getCurveT(x, y, curvePts) { + var x0 = curvePts[4]; + var x1 = curvePts[2]; + var x2 = curvePts[0]; + var y0 = curvePts[5]; + // var y1 = curvePts[ 3 ]; + var y2 = curvePts[1]; + var xMin = Math.min(x0, x2); + var xMax = Math.max(x0, x2); + var yMin = Math.min(y0, y2); + var yMax = Math.max(y0, y2); + if (xMin <= x && x <= xMax && yMin <= y && y <= yMax) { + var coeff = bezierPtsToQuadCoeff(x0, x1, x2); + var roots = solveQuadratic(coeff[0], coeff[1], coeff[2], x); + var validRoots = roots.filter(function (r) { + return 0 <= r && r <= 1; + }); + if (validRoots.length > 0) { + return validRoots[0]; + } + } + return null; + }; + var curveRegions = Object.keys(barrelCurvePts); + for (var i = 0; i < curveRegions.length; i++) { + var corner = curveRegions[i]; + var cornerPts = barrelCurvePts[corner]; + var t = getCurveT(x, y, cornerPts); + if (t == null) { + continue; + } + var y0 = cornerPts[5]; + var y1 = cornerPts[3]; + var y2 = cornerPts[1]; + var bezY = qbezierAt(y0, y1, y2, t); + if (cornerPts.isTop && bezY <= y) { + return true; + } + if (cornerPts.isBottom && y <= bezY) { + return true; + } + } + return false; + } + }; +}; +BRp$2.generateBottomRoundrectangle = function () { + return this.nodeShapes['bottom-round-rectangle'] = this.nodeShapes['bottomroundrectangle'] = { + renderer: this, + name: 'bottom-round-rectangle', + points: generateUnitNgonPointsFitToSquare(4, 0), + draw: function draw(context, centerX, centerY, width, height, cornerRadius) { + this.renderer.nodeShapeImpl(this.name, context, centerX, centerY, width, height, this.points, cornerRadius); + }, + intersectLine: function intersectLine(nodeX, nodeY, width, height, x, y, padding, cornerRadius) { + var topStartX = nodeX - (width / 2 + padding); + var topStartY = nodeY - (height / 2 + padding); + var topEndY = topStartY; + var topEndX = nodeX + (width / 2 + padding); + var topIntersections = finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false); + if (topIntersections.length > 0) { + return topIntersections; + } + return roundRectangleIntersectLine(x, y, nodeX, nodeY, width, height, padding, cornerRadius); + }, + checkPoint: function checkPoint(x, y, padding, width, height, centerX, centerY, cornerRadius) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(width, height) : cornerRadius; + var diam = 2 * cornerRadius; + + // Check hBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width, height - diam, [0, -1], padding)) { + return true; + } + + // Check vBox + if (pointInsidePolygon(x, y, this.points, centerX, centerY, width - diam, height, [0, -1], padding)) { + return true; + } + + // check non-rounded top side + var outerWidth = width / 2 + 2 * padding; + var outerHeight = height / 2 + 2 * padding; + var points = [centerX - outerWidth, centerY - outerHeight, centerX - outerWidth, centerY, centerX + outerWidth, centerY, centerX + outerWidth, centerY - outerHeight]; + if (pointInsidePolygonPoints(x, y, points)) { + return true; + } + + // Check bottom right quarter circle + if (checkInEllipse(x, y, diam, diam, centerX + width / 2 - cornerRadius, centerY + height / 2 - cornerRadius, padding)) { + return true; + } + + // Check bottom left quarter circle + if (checkInEllipse(x, y, diam, diam, centerX - width / 2 + cornerRadius, centerY + height / 2 - cornerRadius, padding)) { + return true; + } + return false; + } + }; +}; +BRp$2.registerNodeShapes = function () { + var nodeShapes = this.nodeShapes = {}; + var renderer = this; + this.generateEllipse(); + this.generatePolygon('triangle', generateUnitNgonPointsFitToSquare(3, 0)); + this.generateRoundPolygon('round-triangle', generateUnitNgonPointsFitToSquare(3, 0)); + this.generatePolygon('rectangle', generateUnitNgonPointsFitToSquare(4, 0)); + nodeShapes['square'] = nodeShapes['rectangle']; + this.generateRoundRectangle(); + this.generateCutRectangle(); + this.generateBarrel(); + this.generateBottomRoundrectangle(); + { + var diamondPoints = [0, 1, 1, 0, 0, -1, -1, 0]; + this.generatePolygon('diamond', diamondPoints); + this.generateRoundPolygon('round-diamond', diamondPoints); + } + this.generatePolygon('pentagon', generateUnitNgonPointsFitToSquare(5, 0)); + this.generateRoundPolygon('round-pentagon', generateUnitNgonPointsFitToSquare(5, 0)); + this.generatePolygon('hexagon', generateUnitNgonPointsFitToSquare(6, 0)); + this.generateRoundPolygon('round-hexagon', generateUnitNgonPointsFitToSquare(6, 0)); + this.generatePolygon('heptagon', generateUnitNgonPointsFitToSquare(7, 0)); + this.generateRoundPolygon('round-heptagon', generateUnitNgonPointsFitToSquare(7, 0)); + this.generatePolygon('octagon', generateUnitNgonPointsFitToSquare(8, 0)); + this.generateRoundPolygon('round-octagon', generateUnitNgonPointsFitToSquare(8, 0)); + var star5Points = new Array(20); + { + var outerPoints = generateUnitNgonPoints(5, 0); + var innerPoints = generateUnitNgonPoints(5, Math.PI / 5); + + // Outer radius is 1; inner radius of star is smaller + var innerRadius = 0.5 * (3 - Math.sqrt(5)); + innerRadius *= 1.57; + for (var i = 0; i < innerPoints.length / 2; i++) { + innerPoints[i * 2] *= innerRadius; + innerPoints[i * 2 + 1] *= innerRadius; + } + for (var i = 0; i < 20 / 4; i++) { + star5Points[i * 4] = outerPoints[i * 2]; + star5Points[i * 4 + 1] = outerPoints[i * 2 + 1]; + star5Points[i * 4 + 2] = innerPoints[i * 2]; + star5Points[i * 4 + 3] = innerPoints[i * 2 + 1]; + } + } + star5Points = fitPolygonToSquare(star5Points); + this.generatePolygon('star', star5Points); + this.generatePolygon('vee', [-1, -1, 0, -0.333, 1, -1, 0, 1]); + this.generatePolygon('rhomboid', [-1, -1, 0.333, -1, 1, 1, -0.333, 1]); + this.generatePolygon('right-rhomboid', [-0.333, -1, 1, -1, 0.333, 1, -1, 1]); + this.nodeShapes['concavehexagon'] = this.generatePolygon('concave-hexagon', [-1, -0.95, -0.75, 0, -1, 0.95, 1, 0.95, 0.75, 0, 1, -0.95]); + { + var tagPoints = [-1, -1, 0.25, -1, 1, 0, 0.25, 1, -1, 1]; + this.generatePolygon('tag', tagPoints); + this.generateRoundPolygon('round-tag', tagPoints); + } + nodeShapes.makePolygon = function (points) { + // use caching on user-specified polygons so they are as fast as native shapes + + var key = points.join('$'); + var name = 'polygon-' + key; + var shape; + if (shape = this[name]) { + // got cached shape + return shape; + } + + // create and cache new shape + return renderer.generatePolygon(name, points); + }; +}; + +var BRp$1 = {}; +BRp$1.timeToRender = function () { + return this.redrawTotalTime / this.redrawCount; +}; +BRp$1.redraw = function (options) { + options = options || staticEmptyObject(); + var r = this; + if (r.averageRedrawTime === undefined) { + r.averageRedrawTime = 0; + } + if (r.lastRedrawTime === undefined) { + r.lastRedrawTime = 0; + } + if (r.lastDrawTime === undefined) { + r.lastDrawTime = 0; + } + r.requestedFrame = true; + r.renderOptions = options; +}; +BRp$1.beforeRender = function (fn, priority) { + // the renderer can't add tick callbacks when destroyed + if (this.destroyed) { + return; + } + if (priority == null) { + error('Priority is not optional for beforeRender'); + } + var cbs = this.beforeRenderCallbacks; + cbs.push({ + fn: fn, + priority: priority + }); + + // higher priority callbacks executed first + cbs.sort(function (a, b) { + return b.priority - a.priority; + }); +}; +var beforeRenderCallbacks = function beforeRenderCallbacks(r, willDraw, startTime) { + var cbs = r.beforeRenderCallbacks; + for (var i = 0; i < cbs.length; i++) { + cbs[i].fn(willDraw, startTime); + } +}; +BRp$1.startRenderLoop = function () { + var r = this; + var cy = r.cy; + if (r.renderLoopStarted) { + return; + } else { + r.renderLoopStarted = true; + } + var renderFn = function renderFn(requestTime) { + if (r.destroyed) { + return; + } + if (cy.batching()) ; else if (r.requestedFrame && !r.skipFrame) { + beforeRenderCallbacks(r, true, requestTime); + var startTime = performanceNow(); + r.render(r.renderOptions); + var endTime = r.lastDrawTime = performanceNow(); + if (r.averageRedrawTime === undefined) { + r.averageRedrawTime = endTime - startTime; + } + if (r.redrawCount === undefined) { + r.redrawCount = 0; + } + r.redrawCount++; + if (r.redrawTotalTime === undefined) { + r.redrawTotalTime = 0; + } + var duration = endTime - startTime; + r.redrawTotalTime += duration; + r.lastRedrawTime = duration; + + // use a weighted average with a bias from the previous average so we don't spike so easily + r.averageRedrawTime = r.averageRedrawTime / 2 + duration / 2; + r.requestedFrame = false; + } else { + beforeRenderCallbacks(r, false, requestTime); + } + r.skipFrame = false; + requestAnimationFrame$1(renderFn); + }; + requestAnimationFrame$1(renderFn); +}; + +var BaseRenderer = function BaseRenderer(options) { + this.init(options); +}; +var BR = BaseRenderer; +var BRp = BR.prototype; +BRp.clientFunctions = ['redrawHint', 'render', 'renderTo', 'matchCanvasSize', 'nodeShapeImpl', 'arrowShapeImpl']; +BRp.init = function (options) { + var r = this; + r.options = options; + r.cy = options.cy; + var ctr = r.container = options.cy.container(); + var containerWindow = r.cy.window(); + + // prepend a stylesheet in the head such that + if (containerWindow) { + var document = containerWindow.document; + var head = document.head; + var stylesheetId = '__________cytoscape_stylesheet'; + var className = '__________cytoscape_container'; + var stylesheetAlreadyExists = document.getElementById(stylesheetId) != null; + if (ctr.className.indexOf(className) < 0) { + ctr.className = (ctr.className || '') + ' ' + className; + } + if (!stylesheetAlreadyExists) { + var stylesheet = document.createElement('style'); + stylesheet.id = stylesheetId; + stylesheet.textContent = '.' + className + ' { position: relative; }'; + head.insertBefore(stylesheet, head.children[0]); // first so lowest priority + } + + var computedStyle = containerWindow.getComputedStyle(ctr); + var position = computedStyle.getPropertyValue('position'); + if (position === 'static') { + warn('A Cytoscape container has style position:static and so can not use UI extensions properly'); + } + } + r.selection = [undefined, undefined, undefined, undefined, 0]; // Coordinates for selection box, plus enabled flag + + r.bezierProjPcts = [0.05, 0.225, 0.4, 0.5, 0.6, 0.775, 0.95]; + + //--Pointer-related data + r.hoverData = { + down: null, + last: null, + downTime: null, + triggerMode: null, + dragging: false, + initialPan: [null, null], + capture: false + }; + r.dragData = { + possibleDragElements: [] + }; + r.touchData = { + start: null, + capture: false, + // These 3 fields related to tap, taphold events + startPosition: [null, null, null, null, null, null], + singleTouchStartTime: null, + singleTouchMoved: true, + now: [null, null, null, null, null, null], + earlier: [null, null, null, null, null, null] + }; + r.redraws = 0; + r.showFps = options.showFps; + r.debug = options.debug; + r.hideEdgesOnViewport = options.hideEdgesOnViewport; + r.textureOnViewport = options.textureOnViewport; + r.wheelSensitivity = options.wheelSensitivity; + r.motionBlurEnabled = options.motionBlur; // on by default + r.forcedPixelRatio = number$1(options.pixelRatio) ? options.pixelRatio : null; + r.motionBlur = options.motionBlur; // for initial kick off + r.motionBlurOpacity = options.motionBlurOpacity; + r.motionBlurTransparency = 1 - r.motionBlurOpacity; + r.motionBlurPxRatio = 1; + r.mbPxRBlurry = 1; //0.8; + r.minMbLowQualFrames = 4; + r.fullQualityMb = false; + r.clearedForMotionBlur = []; + r.desktopTapThreshold = options.desktopTapThreshold; + r.desktopTapThreshold2 = options.desktopTapThreshold * options.desktopTapThreshold; + r.touchTapThreshold = options.touchTapThreshold; + r.touchTapThreshold2 = options.touchTapThreshold * options.touchTapThreshold; + r.tapholdDuration = 500; + r.bindings = []; + r.beforeRenderCallbacks = []; + r.beforeRenderPriorities = { + // higher priority execs before lower one + animations: 400, + eleCalcs: 300, + eleTxrDeq: 200, + lyrTxrDeq: 150, + lyrTxrSkip: 100 + }; + r.registerNodeShapes(); + r.registerArrowShapes(); + r.registerCalculationListeners(); +}; +BRp.notify = function (eventName, eles) { + var r = this; + var cy = r.cy; + + // the renderer can't be notified after it's destroyed + if (this.destroyed) { + return; + } + if (eventName === 'init') { + r.load(); + return; + } + if (eventName === 'destroy') { + r.destroy(); + return; + } + if (eventName === 'add' || eventName === 'remove' || eventName === 'move' && cy.hasCompoundNodes() || eventName === 'load' || eventName === 'zorder' || eventName === 'mount') { + r.invalidateCachedZSortedEles(); + } + if (eventName === 'viewport') { + r.redrawHint('select', true); + } + if (eventName === 'load' || eventName === 'resize' || eventName === 'mount') { + r.invalidateContainerClientCoordsCache(); + r.matchCanvasSize(r.container); + } + r.redrawHint('eles', true); + r.redrawHint('drag', true); + this.startRenderLoop(); + this.redraw(); +}; +BRp.destroy = function () { + var r = this; + r.destroyed = true; + r.cy.stopAnimationLoop(); + for (var i = 0; i < r.bindings.length; i++) { + var binding = r.bindings[i]; + var b = binding; + var tgt = b.target; + (tgt.off || tgt.removeEventListener).apply(tgt, b.args); + } + r.bindings = []; + r.beforeRenderCallbacks = []; + r.onUpdateEleCalcsFns = []; + if (r.removeObserver) { + r.removeObserver.disconnect(); + } + if (r.styleObserver) { + r.styleObserver.disconnect(); + } + if (r.resizeObserver) { + r.resizeObserver.disconnect(); + } + if (r.labelCalcDiv) { + try { + document.body.removeChild(r.labelCalcDiv); // eslint-disable-line no-undef + } catch (e) { + // ie10 issue #1014 + } + } +}; +BRp.isHeadless = function () { + return false; +}; +[BRp$f, BRp$5, BRp$4, BRp$3, BRp$2, BRp$1].forEach(function (props) { + extend(BRp, props); +}); + +var fullFpsTime = 1000 / 60; // assume 60 frames per second + +var defs = { + setupDequeueing: function setupDequeueing(opts) { + return function setupDequeueingImpl() { + var self = this; + var r = this.renderer; + if (self.dequeueingSetup) { + return; + } else { + self.dequeueingSetup = true; + } + var queueRedraw = debounce_1(function () { + r.redrawHint('eles', true); + r.redrawHint('drag', true); + r.redraw(); + }, opts.deqRedrawThreshold); + var dequeue = function dequeue(willDraw, frameStartTime) { + var startTime = performanceNow(); + var avgRenderTime = r.averageRedrawTime; + var renderTime = r.lastRedrawTime; + var deqd = []; + var extent = r.cy.extent(); + var pixelRatio = r.getPixelRatio(); + + // if we aren't in a tick that causes a draw, then the rendered style + // queue won't automatically be flushed before dequeueing starts + if (!willDraw) { + r.flushRenderedStyleQueue(); + } + while (true) { + // eslint-disable-line no-constant-condition + var now = performanceNow(); + var duration = now - startTime; + var frameDuration = now - frameStartTime; + if (renderTime < fullFpsTime) { + // if we're rendering faster than the ideal fps, then do dequeueing + // during all of the remaining frame time + + var timeAvailable = fullFpsTime - (willDraw ? avgRenderTime : 0); + if (frameDuration >= opts.deqFastCost * timeAvailable) { + break; + } + } else { + if (willDraw) { + if (duration >= opts.deqCost * renderTime || duration >= opts.deqAvgCost * avgRenderTime) { + break; + } + } else if (frameDuration >= opts.deqNoDrawCost * fullFpsTime) { + break; + } + } + var thisDeqd = opts.deq(self, pixelRatio, extent); + if (thisDeqd.length > 0) { + for (var i = 0; i < thisDeqd.length; i++) { + deqd.push(thisDeqd[i]); + } + } else { + break; + } + } + + // callbacks on dequeue + if (deqd.length > 0) { + opts.onDeqd(self, deqd); + if (!willDraw && opts.shouldRedraw(self, deqd, pixelRatio, extent)) { + queueRedraw(); + } + } + }; + var priority = opts.priority || noop$1; + r.beforeRender(dequeue, priority(self)); + }; + } +}; + +// Allows lookups for (ele, lvl) => cache. +// Uses keys so elements may share the same cache. +var ElementTextureCacheLookup = /*#__PURE__*/function () { + function ElementTextureCacheLookup(getKey) { + var doesEleInvalidateKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : falsify; + _classCallCheck(this, ElementTextureCacheLookup); + this.idsByKey = new Map$2(); + this.keyForId = new Map$2(); + this.cachesByLvl = new Map$2(); + this.lvls = []; + this.getKey = getKey; + this.doesEleInvalidateKey = doesEleInvalidateKey; + } + _createClass(ElementTextureCacheLookup, [{ + key: "getIdsFor", + value: function getIdsFor(key) { + if (key == null) { + error("Can not get id list for null key"); + } + var idsByKey = this.idsByKey; + var ids = this.idsByKey.get(key); + if (!ids) { + ids = new Set$1(); + idsByKey.set(key, ids); + } + return ids; + } + }, { + key: "addIdForKey", + value: function addIdForKey(key, id) { + if (key != null) { + this.getIdsFor(key).add(id); + } + } + }, { + key: "deleteIdForKey", + value: function deleteIdForKey(key, id) { + if (key != null) { + this.getIdsFor(key)["delete"](id); + } + } + }, { + key: "getNumberOfIdsForKey", + value: function getNumberOfIdsForKey(key) { + if (key == null) { + return 0; + } else { + return this.getIdsFor(key).size; + } + } + }, { + key: "updateKeyMappingFor", + value: function updateKeyMappingFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + var currKey = this.getKey(ele); + this.deleteIdForKey(prevKey, id); + this.addIdForKey(currKey, id); + this.keyForId.set(id, currKey); + } + }, { + key: "deleteKeyMappingFor", + value: function deleteKeyMappingFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + this.deleteIdForKey(prevKey, id); + this.keyForId["delete"](id); + } + }, { + key: "keyHasChangedFor", + value: function keyHasChangedFor(ele) { + var id = ele.id(); + var prevKey = this.keyForId.get(id); + var newKey = this.getKey(ele); + return prevKey !== newKey; + } + }, { + key: "isInvalid", + value: function isInvalid(ele) { + return this.keyHasChangedFor(ele) || this.doesEleInvalidateKey(ele); + } + }, { + key: "getCachesAt", + value: function getCachesAt(lvl) { + var cachesByLvl = this.cachesByLvl, + lvls = this.lvls; + var caches = cachesByLvl.get(lvl); + if (!caches) { + caches = new Map$2(); + cachesByLvl.set(lvl, caches); + lvls.push(lvl); + } + return caches; + } + }, { + key: "getCache", + value: function getCache(key, lvl) { + return this.getCachesAt(lvl).get(key); + } + }, { + key: "get", + value: function get(ele, lvl) { + var key = this.getKey(ele); + var cache = this.getCache(key, lvl); + + // getting for an element may need to add to the id list b/c eles can share keys + if (cache != null) { + this.updateKeyMappingFor(ele); + } + return cache; + } + }, { + key: "getForCachedKey", + value: function getForCachedKey(ele, lvl) { + var key = this.keyForId.get(ele.id()); // n.b. use cached key, not newly computed key + var cache = this.getCache(key, lvl); + return cache; + } + }, { + key: "hasCache", + value: function hasCache(key, lvl) { + return this.getCachesAt(lvl).has(key); + } + }, { + key: "has", + value: function has(ele, lvl) { + var key = this.getKey(ele); + return this.hasCache(key, lvl); + } + }, { + key: "setCache", + value: function setCache(key, lvl, cache) { + cache.key = key; + this.getCachesAt(lvl).set(key, cache); + } + }, { + key: "set", + value: function set(ele, lvl, cache) { + var key = this.getKey(ele); + this.setCache(key, lvl, cache); + this.updateKeyMappingFor(ele); + } + }, { + key: "deleteCache", + value: function deleteCache(key, lvl) { + this.getCachesAt(lvl)["delete"](key); + } + }, { + key: "delete", + value: function _delete(ele, lvl) { + var key = this.getKey(ele); + this.deleteCache(key, lvl); + } + }, { + key: "invalidateKey", + value: function invalidateKey(key) { + var _this = this; + this.lvls.forEach(function (lvl) { + return _this.deleteCache(key, lvl); + }); + } + + // returns true if no other eles reference the invalidated cache (n.b. other eles may need the cache with the same key) + }, { + key: "invalidate", + value: function invalidate(ele) { + var id = ele.id(); + var key = this.keyForId.get(id); // n.b. use stored key rather than current (potential key) + + this.deleteKeyMappingFor(ele); + var entireKeyInvalidated = this.doesEleInvalidateKey(ele); + if (entireKeyInvalidated) { + // clear mapping for current key + this.invalidateKey(key); + } + return entireKeyInvalidated || this.getNumberOfIdsForKey(key) === 0; + } + }]); + return ElementTextureCacheLookup; +}(); + +var minTxrH = 25; // the size of the texture cache for small height eles (special case) +var txrStepH = 50; // the min size of the regular cache, and the size it increases with each step up +var minLvl$1 = -4; // when scaling smaller than that we don't need to re-render +var maxLvl$1 = 3; // when larger than this scale just render directly (caching is not helpful) +var maxZoom$1 = 7.99; // beyond this zoom level, layered textures are not used +var eleTxrSpacing = 8; // spacing between elements on textures to avoid blitting overlaps +var defTxrWidth = 1024; // default/minimum texture width +var maxTxrW = 1024; // the maximum width of a texture +var maxTxrH = 1024; // the maximum height of a texture +var minUtility = 0.2; // if usage of texture is less than this, it is retired +var maxFullness = 0.8; // fullness of texture after which queue removal is checked +var maxFullnessChecks = 10; // dequeued after this many checks +var deqCost$1 = 0.15; // % of add'l rendering cost allowed for dequeuing ele caches each frame +var deqAvgCost$1 = 0.1; // % of add'l rendering cost compared to average overall redraw time +var deqNoDrawCost$1 = 0.9; // % of avg frame time that can be used for dequeueing when not drawing +var deqFastCost$1 = 0.9; // % of frame time to be used when >60fps +var deqRedrawThreshold$1 = 100; // time to batch redraws together from dequeueing to allow more dequeueing calcs to happen in the meanwhile +var maxDeqSize$1 = 1; // number of eles to dequeue and render at higher texture in each batch + +var getTxrReasons = { + dequeue: 'dequeue', + downscale: 'downscale', + highQuality: 'highQuality' +}; +var initDefaults = defaults$g({ + getKey: null, + doesEleInvalidateKey: falsify, + drawElement: null, + getBoundingBox: null, + getRotationPoint: null, + getRotationOffset: null, + isVisible: trueify, + allowEdgeTxrCaching: true, + allowParentTxrCaching: true +}); +var ElementTextureCache = function ElementTextureCache(renderer, initOptions) { + var self = this; + self.renderer = renderer; + self.onDequeues = []; + var opts = initDefaults(initOptions); + extend(self, opts); + self.lookup = new ElementTextureCacheLookup(opts.getKey, opts.doesEleInvalidateKey); + self.setupDequeueing(); +}; +var ETCp = ElementTextureCache.prototype; +ETCp.reasons = getTxrReasons; + +// the list of textures in which new subtextures for elements can be placed +ETCp.getTextureQueue = function (txrH) { + var self = this; + self.eleImgCaches = self.eleImgCaches || {}; + return self.eleImgCaches[txrH] = self.eleImgCaches[txrH] || []; +}; + +// the list of usused textures which can be recycled (in use in texture queue) +ETCp.getRetiredTextureQueue = function (txrH) { + var self = this; + var rtxtrQs = self.eleImgCaches.retired = self.eleImgCaches.retired || {}; + var rtxtrQ = rtxtrQs[txrH] = rtxtrQs[txrH] || []; + return rtxtrQ; +}; + +// queue of element draw requests at different scale levels +ETCp.getElementQueue = function () { + var self = this; + var q = self.eleCacheQueue = self.eleCacheQueue || new heap(function (a, b) { + return b.reqs - a.reqs; + }); + return q; +}; + +// queue of element draw requests at different scale levels (element id lookup) +ETCp.getElementKeyToQueue = function () { + var self = this; + var k2q = self.eleKeyToCacheQueue = self.eleKeyToCacheQueue || {}; + return k2q; +}; +ETCp.getElement = function (ele, bb, pxRatio, lvl, reason) { + var self = this; + var r = this.renderer; + var zoom = r.cy.zoom(); + var lookup = this.lookup; + if (!bb || bb.w === 0 || bb.h === 0 || isNaN(bb.w) || isNaN(bb.h) || !ele.visible() || ele.removed()) { + return null; + } + if (!self.allowEdgeTxrCaching && ele.isEdge() || !self.allowParentTxrCaching && ele.isParent()) { + return null; + } + if (lvl == null) { + lvl = Math.ceil(log2(zoom * pxRatio)); + } + if (lvl < minLvl$1) { + lvl = minLvl$1; + } else if (zoom >= maxZoom$1 || lvl > maxLvl$1) { + return null; + } + var scale = Math.pow(2, lvl); + var eleScaledH = bb.h * scale; + var eleScaledW = bb.w * scale; + var scaledLabelShown = r.eleTextBiggerThanMin(ele, scale); + if (!this.isVisible(ele, scaledLabelShown)) { + return null; + } + var eleCache = lookup.get(ele, lvl); + + // if this get was on an unused/invalidated cache, then restore the texture usage metric + if (eleCache && eleCache.invalidated) { + eleCache.invalidated = false; + eleCache.texture.invalidatedWidth -= eleCache.width; + } + if (eleCache) { + return eleCache; + } + var txrH; // which texture height this ele belongs to + + if (eleScaledH <= minTxrH) { + txrH = minTxrH; + } else if (eleScaledH <= txrStepH) { + txrH = txrStepH; + } else { + txrH = Math.ceil(eleScaledH / txrStepH) * txrStepH; + } + if (eleScaledH > maxTxrH || eleScaledW > maxTxrW) { + return null; // caching large elements is not efficient + } + + var txrQ = self.getTextureQueue(txrH); + + // first try the second last one in case it has space at the end + var txr = txrQ[txrQ.length - 2]; + var addNewTxr = function addNewTxr() { + return self.recycleTexture(txrH, eleScaledW) || self.addTexture(txrH, eleScaledW); + }; + + // try the last one if there is no second last one + if (!txr) { + txr = txrQ[txrQ.length - 1]; + } + + // if the last one doesn't exist, we need a first one + if (!txr) { + txr = addNewTxr(); + } + + // if there's no room in the current texture, we need a new one + if (txr.width - txr.usedWidth < eleScaledW) { + txr = addNewTxr(); + } + var scalableFrom = function scalableFrom(otherCache) { + return otherCache && otherCache.scaledLabelShown === scaledLabelShown; + }; + var deqing = reason && reason === getTxrReasons.dequeue; + var highQualityReq = reason && reason === getTxrReasons.highQuality; + var downscaleReq = reason && reason === getTxrReasons.downscale; + var higherCache; // the nearest cache with a higher level + for (var l = lvl + 1; l <= maxLvl$1; l++) { + var c = lookup.get(ele, l); + if (c) { + higherCache = c; + break; + } + } + var oneUpCache = higherCache && higherCache.level === lvl + 1 ? higherCache : null; + var downscale = function downscale() { + txr.context.drawImage(oneUpCache.texture.canvas, oneUpCache.x, 0, oneUpCache.width, oneUpCache.height, txr.usedWidth, 0, eleScaledW, eleScaledH); + }; + + // reset ele area in texture + txr.context.setTransform(1, 0, 0, 1, 0, 0); + txr.context.clearRect(txr.usedWidth, 0, eleScaledW, txrH); + if (scalableFrom(oneUpCache)) { + // then we can relatively cheaply rescale the existing image w/o rerendering + downscale(); + } else if (scalableFrom(higherCache)) { + // then use the higher cache for now and queue the next level down + // to cheaply scale towards the smaller level + + if (highQualityReq) { + for (var _l = higherCache.level; _l > lvl; _l--) { + oneUpCache = self.getElement(ele, bb, pxRatio, _l, getTxrReasons.downscale); + } + downscale(); + } else { + self.queueElement(ele, higherCache.level - 1); + return higherCache; + } + } else { + var lowerCache; // the nearest cache with a lower level + if (!deqing && !highQualityReq && !downscaleReq) { + for (var _l2 = lvl - 1; _l2 >= minLvl$1; _l2--) { + var _c = lookup.get(ele, _l2); + if (_c) { + lowerCache = _c; + break; + } + } + } + if (scalableFrom(lowerCache)) { + // then use the lower quality cache for now and queue the better one for later + + self.queueElement(ele, lvl); + return lowerCache; + } + txr.context.translate(txr.usedWidth, 0); + txr.context.scale(scale, scale); + this.drawElement(txr.context, ele, bb, scaledLabelShown, false); + txr.context.scale(1 / scale, 1 / scale); + txr.context.translate(-txr.usedWidth, 0); + } + eleCache = { + x: txr.usedWidth, + texture: txr, + level: lvl, + scale: scale, + width: eleScaledW, + height: eleScaledH, + scaledLabelShown: scaledLabelShown + }; + txr.usedWidth += Math.ceil(eleScaledW + eleTxrSpacing); + txr.eleCaches.push(eleCache); + lookup.set(ele, lvl, eleCache); + self.checkTextureFullness(txr); + return eleCache; +}; +ETCp.invalidateElements = function (eles) { + for (var i = 0; i < eles.length; i++) { + this.invalidateElement(eles[i]); + } +}; +ETCp.invalidateElement = function (ele) { + var self = this; + var lookup = self.lookup; + var caches = []; + var invalid = lookup.isInvalid(ele); + if (!invalid) { + return; // override the invalidation request if the element key has not changed + } + + for (var lvl = minLvl$1; lvl <= maxLvl$1; lvl++) { + var cache = lookup.getForCachedKey(ele, lvl); + if (cache) { + caches.push(cache); + } + } + var noOtherElesUseCache = lookup.invalidate(ele); + if (noOtherElesUseCache) { + for (var i = 0; i < caches.length; i++) { + var _cache = caches[i]; + var txr = _cache.texture; + + // remove space from the texture it belongs to + txr.invalidatedWidth += _cache.width; + + // mark the cache as invalidated + _cache.invalidated = true; + + // retire the texture if its utility is low + self.checkTextureUtility(txr); + } + } + + // remove from queue since the old req was for the old state + self.removeFromQueue(ele); +}; +ETCp.checkTextureUtility = function (txr) { + // invalidate all entries in the cache if the cache size is small + if (txr.invalidatedWidth >= minUtility * txr.width) { + this.retireTexture(txr); + } +}; +ETCp.checkTextureFullness = function (txr) { + // if texture has been mostly filled and passed over several times, remove + // it from the queue so we don't need to waste time looking at it to put new things + + var self = this; + var txrQ = self.getTextureQueue(txr.height); + if (txr.usedWidth / txr.width > maxFullness && txr.fullnessChecks >= maxFullnessChecks) { + removeFromArray(txrQ, txr); + } else { + txr.fullnessChecks++; + } +}; +ETCp.retireTexture = function (txr) { + var self = this; + var txrH = txr.height; + var txrQ = self.getTextureQueue(txrH); + var lookup = this.lookup; + + // retire the texture from the active / searchable queue: + + removeFromArray(txrQ, txr); + txr.retired = true; + + // remove the refs from the eles to the caches: + + var eleCaches = txr.eleCaches; + for (var i = 0; i < eleCaches.length; i++) { + var eleCache = eleCaches[i]; + lookup.deleteCache(eleCache.key, eleCache.level); + } + clearArray(eleCaches); + + // add the texture to a retired queue so it can be recycled in future: + + var rtxtrQ = self.getRetiredTextureQueue(txrH); + rtxtrQ.push(txr); +}; +ETCp.addTexture = function (txrH, minW) { + var self = this; + var txrQ = self.getTextureQueue(txrH); + var txr = {}; + txrQ.push(txr); + txr.eleCaches = []; + txr.height = txrH; + txr.width = Math.max(defTxrWidth, minW); + txr.usedWidth = 0; + txr.invalidatedWidth = 0; + txr.fullnessChecks = 0; + txr.canvas = self.renderer.makeOffscreenCanvas(txr.width, txr.height); + txr.context = txr.canvas.getContext('2d'); + return txr; +}; +ETCp.recycleTexture = function (txrH, minW) { + var self = this; + var txrQ = self.getTextureQueue(txrH); + var rtxtrQ = self.getRetiredTextureQueue(txrH); + for (var i = 0; i < rtxtrQ.length; i++) { + var txr = rtxtrQ[i]; + if (txr.width >= minW) { + txr.retired = false; + txr.usedWidth = 0; + txr.invalidatedWidth = 0; + txr.fullnessChecks = 0; + clearArray(txr.eleCaches); + txr.context.setTransform(1, 0, 0, 1, 0, 0); + txr.context.clearRect(0, 0, txr.width, txr.height); + removeFromArray(rtxtrQ, txr); + txrQ.push(txr); + return txr; + } + } +}; +ETCp.queueElement = function (ele, lvl) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var key = this.getKey(ele); + var existingReq = k2q[key]; + if (existingReq) { + // use the max lvl b/c in between lvls are cheap to make + existingReq.level = Math.max(existingReq.level, lvl); + existingReq.eles.merge(ele); + existingReq.reqs++; + q.updateItem(existingReq); + } else { + var req = { + eles: ele.spawn().merge(ele), + level: lvl, + reqs: 1, + key: key + }; + q.push(req); + k2q[key] = req; + } +}; +ETCp.dequeue = function (pxRatio /*, extent*/) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var dequeued = []; + var lookup = self.lookup; + for (var i = 0; i < maxDeqSize$1; i++) { + if (q.size() > 0) { + var req = q.pop(); + var key = req.key; + var ele = req.eles[0]; // all eles have the same key + var cacheExists = lookup.hasCache(ele, req.level); + + // clear out the key to req lookup + k2q[key] = null; + + // dequeueing isn't necessary with an existing cache + if (cacheExists) { + continue; + } + dequeued.push(req); + var bb = self.getBoundingBox(ele); + self.getElement(ele, bb, pxRatio, req.level, getTxrReasons.dequeue); + } else { + break; + } + } + return dequeued; +}; +ETCp.removeFromQueue = function (ele) { + var self = this; + var q = self.getElementQueue(); + var k2q = self.getElementKeyToQueue(); + var key = this.getKey(ele); + var req = k2q[key]; + if (req != null) { + if (req.eles.length === 1) { + // remove if last ele in the req + // bring to front of queue + req.reqs = MAX_INT$1; + q.updateItem(req); + q.pop(); // remove from queue + + k2q[key] = null; // remove from lookup map + } else { + // otherwise just remove ele from req + req.eles.unmerge(ele); + } + } +}; +ETCp.onDequeue = function (fn) { + this.onDequeues.push(fn); +}; +ETCp.offDequeue = function (fn) { + removeFromArray(this.onDequeues, fn); +}; +ETCp.setupDequeueing = defs.setupDequeueing({ + deqRedrawThreshold: deqRedrawThreshold$1, + deqCost: deqCost$1, + deqAvgCost: deqAvgCost$1, + deqNoDrawCost: deqNoDrawCost$1, + deqFastCost: deqFastCost$1, + deq: function deq(self, pxRatio, extent) { + return self.dequeue(pxRatio, extent); + }, + onDeqd: function onDeqd(self, deqd) { + for (var i = 0; i < self.onDequeues.length; i++) { + var fn = self.onDequeues[i]; + fn(deqd); + } + }, + shouldRedraw: function shouldRedraw(self, deqd, pxRatio, extent) { + for (var i = 0; i < deqd.length; i++) { + var eles = deqd[i].eles; + for (var j = 0; j < eles.length; j++) { + var bb = eles[j].boundingBox(); + if (boundingBoxesIntersect(bb, extent)) { + return true; + } + } + } + return false; + }, + priority: function priority(self) { + return self.renderer.beforeRenderPriorities.eleTxrDeq; + } +}); + +var defNumLayers = 1; // default number of layers to use +var minLvl = -4; // when scaling smaller than that we don't need to re-render +var maxLvl = 2; // when larger than this scale just render directly (caching is not helpful) +var maxZoom = 3.99; // beyond this zoom level, layered textures are not used +var deqRedrawThreshold = 50; // time to batch redraws together from dequeueing to allow more dequeueing calcs to happen in the meanwhile +var refineEleDebounceTime = 50; // time to debounce sharper ele texture updates +var deqCost = 0.15; // % of add'l rendering cost allowed for dequeuing ele caches each frame +var deqAvgCost = 0.1; // % of add'l rendering cost compared to average overall redraw time +var deqNoDrawCost = 0.9; // % of avg frame time that can be used for dequeueing when not drawing +var deqFastCost = 0.9; // % of frame time to be used when >60fps +var maxDeqSize = 1; // number of eles to dequeue and render at higher texture in each batch +var invalidThreshold = 250; // time threshold for disabling b/c of invalidations +var maxLayerArea = 4000 * 4000; // layers can't be bigger than this +var useHighQualityEleTxrReqs = true; // whether to use high quality ele txr requests (generally faster and cheaper in the longterm) + +// var log = function(){ console.log.apply( console, arguments ); }; + +var LayeredTextureCache = function LayeredTextureCache(renderer) { + var self = this; + var r = self.renderer = renderer; + var cy = r.cy; + self.layersByLevel = {}; // e.g. 2 => [ layer1, layer2, ..., layerN ] + + self.firstGet = true; + self.lastInvalidationTime = performanceNow() - 2 * invalidThreshold; + self.skipping = false; + self.eleTxrDeqs = cy.collection(); + self.scheduleElementRefinement = debounce_1(function () { + self.refineElementTextures(self.eleTxrDeqs); + self.eleTxrDeqs.unmerge(self.eleTxrDeqs); + }, refineEleDebounceTime); + r.beforeRender(function (willDraw, now) { + if (now - self.lastInvalidationTime <= invalidThreshold) { + self.skipping = true; + } else { + self.skipping = false; + } + }, r.beforeRenderPriorities.lyrTxrSkip); + var qSort = function qSort(a, b) { + return b.reqs - a.reqs; + }; + self.layersQueue = new heap(qSort); + self.setupDequeueing(); +}; +var LTCp = LayeredTextureCache.prototype; +var layerIdPool = 0; +var MAX_INT = Math.pow(2, 53) - 1; +LTCp.makeLayer = function (bb, lvl) { + var scale = Math.pow(2, lvl); + var w = Math.ceil(bb.w * scale); + var h = Math.ceil(bb.h * scale); + var canvas = this.renderer.makeOffscreenCanvas(w, h); + var layer = { + id: layerIdPool = ++layerIdPool % MAX_INT, + bb: bb, + level: lvl, + width: w, + height: h, + canvas: canvas, + context: canvas.getContext('2d'), + eles: [], + elesQueue: [], + reqs: 0 + }; + + // log('make layer %s with w %s and h %s and lvl %s', layer.id, layer.width, layer.height, layer.level); + + var cxt = layer.context; + var dx = -layer.bb.x1; + var dy = -layer.bb.y1; + + // do the transform on creation to save cycles (it's the same for all eles) + cxt.scale(scale, scale); + cxt.translate(dx, dy); + return layer; +}; +LTCp.getLayers = function (eles, pxRatio, lvl) { + var self = this; + var r = self.renderer; + var cy = r.cy; + var zoom = cy.zoom(); + var firstGet = self.firstGet; + self.firstGet = false; + + // log('--\nget layers with %s eles', eles.length); + //log eles.map(function(ele){ return ele.id() }) ); + + if (lvl == null) { + lvl = Math.ceil(log2(zoom * pxRatio)); + if (lvl < minLvl) { + lvl = minLvl; + } else if (zoom >= maxZoom || lvl > maxLvl) { + return null; + } + } + self.validateLayersElesOrdering(lvl, eles); + var layersByLvl = self.layersByLevel; + var scale = Math.pow(2, lvl); + var layers = layersByLvl[lvl] = layersByLvl[lvl] || []; + var bb; + var lvlComplete = self.levelIsComplete(lvl, eles); + var tmpLayers; + var checkTempLevels = function checkTempLevels() { + var canUseAsTmpLvl = function canUseAsTmpLvl(l) { + self.validateLayersElesOrdering(l, eles); + if (self.levelIsComplete(l, eles)) { + tmpLayers = layersByLvl[l]; + return true; + } + }; + var checkLvls = function checkLvls(dir) { + if (tmpLayers) { + return; + } + for (var l = lvl + dir; minLvl <= l && l <= maxLvl; l += dir) { + if (canUseAsTmpLvl(l)) { + break; + } + } + }; + checkLvls(+1); + checkLvls(-1); + + // remove the invalid layers; they will be replaced as needed later in this function + for (var i = layers.length - 1; i >= 0; i--) { + var layer = layers[i]; + if (layer.invalid) { + removeFromArray(layers, layer); + } + } + }; + if (!lvlComplete) { + // if the current level is incomplete, then use the closest, best quality layerset temporarily + // and later queue the current layerset so we can get the proper quality level soon + + checkTempLevels(); + } else { + // log('level complete, using existing layers\n--'); + return layers; + } + var getBb = function getBb() { + if (!bb) { + bb = makeBoundingBox(); + for (var i = 0; i < eles.length; i++) { + updateBoundingBox(bb, eles[i].boundingBox()); + } + } + return bb; + }; + var makeLayer = function makeLayer(opts) { + opts = opts || {}; + var after = opts.after; + getBb(); + var area = bb.w * scale * (bb.h * scale); + if (area > maxLayerArea) { + return null; + } + var layer = self.makeLayer(bb, lvl); + if (after != null) { + var index = layers.indexOf(after) + 1; + layers.splice(index, 0, layer); + } else if (opts.insert === undefined || opts.insert) { + // no after specified => first layer made so put at start + layers.unshift(layer); + } + + // if( tmpLayers ){ + //self.queueLayer( layer ); + // } + + return layer; + }; + if (self.skipping && !firstGet) { + // log('skip layers'); + return null; + } + + // log('do layers'); + + var layer = null; + var maxElesPerLayer = eles.length / defNumLayers; + var allowLazyQueueing = !firstGet; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + var rs = ele._private.rscratch; + var caches = rs.imgLayerCaches = rs.imgLayerCaches || {}; + + // log('look at ele', ele.id()); + + var existingLayer = caches[lvl]; + if (existingLayer) { + // reuse layer for later eles + // log('reuse layer for', ele.id()); + layer = existingLayer; + continue; + } + if (!layer || layer.eles.length >= maxElesPerLayer || !boundingBoxInBoundingBox(layer.bb, ele.boundingBox())) { + // log('make new layer for ele %s', ele.id()); + + layer = makeLayer({ + insert: true, + after: layer + }); + + // if now layer can be built then we can't use layers at this level + if (!layer) { + return null; + } + + // log('new layer with id %s', layer.id); + } + + if (tmpLayers || allowLazyQueueing) { + // log('queue ele %s in layer %s', ele.id(), layer.id); + self.queueLayer(layer, ele); + } else { + // log('draw ele %s in layer %s', ele.id(), layer.id); + self.drawEleInLayer(layer, ele, lvl, pxRatio); + } + layer.eles.push(ele); + caches[lvl] = layer; + } + + // log('--'); + + if (tmpLayers) { + // then we only queued the current layerset and can't draw it yet + return tmpLayers; + } + if (allowLazyQueueing) { + // log('lazy queue level', lvl); + return null; + } + return layers; +}; + +// a layer may want to use an ele cache of a higher level to avoid blurriness +// so the layer level might not equal the ele level +LTCp.getEleLevelForLayerLevel = function (lvl, pxRatio) { + return lvl; +}; +LTCp.drawEleInLayer = function (layer, ele, lvl, pxRatio) { + var self = this; + var r = this.renderer; + var context = layer.context; + var bb = ele.boundingBox(); + if (bb.w === 0 || bb.h === 0 || !ele.visible()) { + return; + } + lvl = self.getEleLevelForLayerLevel(lvl, pxRatio); + { + r.setImgSmoothing(context, false); + } + { + r.drawCachedElement(context, ele, null, null, lvl, useHighQualityEleTxrReqs); + } + { + r.setImgSmoothing(context, true); + } +}; +LTCp.levelIsComplete = function (lvl, eles) { + var self = this; + var layers = self.layersByLevel[lvl]; + if (!layers || layers.length === 0) { + return false; + } + var numElesInLayers = 0; + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + + // if there are any eles needed to be drawn yet, the level is not complete + if (layer.reqs > 0) { + return false; + } + + // if the layer is invalid, the level is not complete + if (layer.invalid) { + return false; + } + numElesInLayers += layer.eles.length; + } + + // we should have exactly the number of eles passed in to be complete + if (numElesInLayers !== eles.length) { + return false; + } + return true; +}; +LTCp.validateLayersElesOrdering = function (lvl, eles) { + var layers = this.layersByLevel[lvl]; + if (!layers) { + return; + } + + // if in a layer the eles are not in the same order, then the layer is invalid + // (i.e. there is an ele in between the eles in the layer) + + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + var offset = -1; + + // find the offset + for (var j = 0; j < eles.length; j++) { + if (layer.eles[0] === eles[j]) { + offset = j; + break; + } + } + if (offset < 0) { + // then the layer has nonexistent elements and is invalid + this.invalidateLayer(layer); + continue; + } + + // the eles in the layer must be in the same continuous order, else the layer is invalid + + var o = offset; + for (var j = 0; j < layer.eles.length; j++) { + if (layer.eles[j] !== eles[o + j]) { + // log('invalidate based on ordering', layer.id); + + this.invalidateLayer(layer); + break; + } + } + } +}; +LTCp.updateElementsInLayers = function (eles, update) { + var self = this; + var isEles = element(eles[0]); + + // collect udpated elements (cascaded from the layers) and update each + // layer itself along the way + for (var i = 0; i < eles.length; i++) { + var req = isEles ? null : eles[i]; + var ele = isEles ? eles[i] : eles[i].ele; + var rs = ele._private.rscratch; + var caches = rs.imgLayerCaches = rs.imgLayerCaches || {}; + for (var l = minLvl; l <= maxLvl; l++) { + var layer = caches[l]; + if (!layer) { + continue; + } + + // if update is a request from the ele cache, then it affects only + // the matching level + if (req && self.getEleLevelForLayerLevel(layer.level) !== req.level) { + continue; + } + update(layer, ele, req); + } + } +}; +LTCp.haveLayers = function () { + var self = this; + var haveLayers = false; + for (var l = minLvl; l <= maxLvl; l++) { + var layers = self.layersByLevel[l]; + if (layers && layers.length > 0) { + haveLayers = true; + break; + } + } + return haveLayers; +}; +LTCp.invalidateElements = function (eles) { + var self = this; + if (eles.length === 0) { + return; + } + self.lastInvalidationTime = performanceNow(); + + // log('update invalidate layer time from eles'); + + if (eles.length === 0 || !self.haveLayers()) { + return; + } + self.updateElementsInLayers(eles, function invalAssocLayers(layer, ele, req) { + self.invalidateLayer(layer); + }); +}; +LTCp.invalidateLayer = function (layer) { + // log('update invalidate layer time'); + + this.lastInvalidationTime = performanceNow(); + if (layer.invalid) { + return; + } // save cycles + + var lvl = layer.level; + var eles = layer.eles; + var layers = this.layersByLevel[lvl]; + + // log('invalidate layer', layer.id ); + + removeFromArray(layers, layer); + // layer.eles = []; + + layer.elesQueue = []; + layer.invalid = true; + if (layer.replacement) { + layer.replacement.invalid = true; + } + for (var i = 0; i < eles.length; i++) { + var caches = eles[i]._private.rscratch.imgLayerCaches; + if (caches) { + caches[lvl] = null; + } + } +}; +LTCp.refineElementTextures = function (eles) { + var self = this; + + // log('refine', eles.length); + + self.updateElementsInLayers(eles, function refineEachEle(layer, ele, req) { + var rLyr = layer.replacement; + if (!rLyr) { + rLyr = layer.replacement = self.makeLayer(layer.bb, layer.level); + rLyr.replaces = layer; + rLyr.eles = layer.eles; + + // log('make replacement layer %s for %s with level %s', rLyr.id, layer.id, rLyr.level); + } + + if (!rLyr.reqs) { + for (var i = 0; i < rLyr.eles.length; i++) { + self.queueLayer(rLyr, rLyr.eles[i]); + } + + // log('queue replacement layer refinement', rLyr.id); + } + }); +}; + +LTCp.enqueueElementRefinement = function (ele) { + this.eleTxrDeqs.merge(ele); + this.scheduleElementRefinement(); +}; +LTCp.queueLayer = function (layer, ele) { + var self = this; + var q = self.layersQueue; + var elesQ = layer.elesQueue; + var hasId = elesQ.hasId = elesQ.hasId || {}; + + // if a layer is going to be replaced, queuing is a waste of time + if (layer.replacement) { + return; + } + if (ele) { + if (hasId[ele.id()]) { + return; + } + elesQ.push(ele); + hasId[ele.id()] = true; + } + if (layer.reqs) { + layer.reqs++; + q.updateItem(layer); + } else { + layer.reqs = 1; + q.push(layer); + } +}; +LTCp.dequeue = function (pxRatio) { + var self = this; + var q = self.layersQueue; + var deqd = []; + var eleDeqs = 0; + while (eleDeqs < maxDeqSize) { + if (q.size() === 0) { + break; + } + var layer = q.peek(); + + // if a layer has been or will be replaced, then don't waste time with it + if (layer.replacement) { + // log('layer %s in queue skipped b/c it already has a replacement', layer.id); + q.pop(); + continue; + } + + // if this is a replacement layer that has been superceded, then forget it + if (layer.replaces && layer !== layer.replaces.replacement) { + // log('layer is no longer the most uptodate replacement; dequeued', layer.id) + q.pop(); + continue; + } + if (layer.invalid) { + // log('replacement layer %s is invalid; dequeued', layer.id); + q.pop(); + continue; + } + var ele = layer.elesQueue.shift(); + if (ele) { + // log('dequeue layer %s', layer.id); + + self.drawEleInLayer(layer, ele, layer.level, pxRatio); + eleDeqs++; + } + if (deqd.length === 0) { + // we need only one entry in deqd to queue redrawing etc + deqd.push(true); + } + + // if the layer has all its eles done, then remove from the queue + if (layer.elesQueue.length === 0) { + q.pop(); + layer.reqs = 0; + + // log('dequeue of layer %s complete', layer.id); + + // when a replacement layer is dequeued, it replaces the old layer in the level + if (layer.replaces) { + self.applyLayerReplacement(layer); + } + self.requestRedraw(); + } + } + return deqd; +}; +LTCp.applyLayerReplacement = function (layer) { + var self = this; + var layersInLevel = self.layersByLevel[layer.level]; + var replaced = layer.replaces; + var index = layersInLevel.indexOf(replaced); + + // if the replaced layer is not in the active list for the level, then replacing + // refs would be a mistake (i.e. overwriting the true active layer) + if (index < 0 || replaced.invalid) { + // log('replacement layer would have no effect', layer.id); + return; + } + layersInLevel[index] = layer; // replace level ref + + // replace refs in eles + for (var i = 0; i < layer.eles.length; i++) { + var _p = layer.eles[i]._private; + var cache = _p.imgLayerCaches = _p.imgLayerCaches || {}; + if (cache) { + cache[layer.level] = layer; + } + } + + // log('apply replacement layer %s over %s', layer.id, replaced.id); + + self.requestRedraw(); +}; +LTCp.requestRedraw = debounce_1(function () { + var r = this.renderer; + r.redrawHint('eles', true); + r.redrawHint('drag', true); + r.redraw(); +}, 100); +LTCp.setupDequeueing = defs.setupDequeueing({ + deqRedrawThreshold: deqRedrawThreshold, + deqCost: deqCost, + deqAvgCost: deqAvgCost, + deqNoDrawCost: deqNoDrawCost, + deqFastCost: deqFastCost, + deq: function deq(self, pxRatio) { + return self.dequeue(pxRatio); + }, + onDeqd: noop$1, + shouldRedraw: trueify, + priority: function priority(self) { + return self.renderer.beforeRenderPriorities.lyrTxrDeq; + } +}); + +var CRp$a = {}; +var impl; +function polygon(context, points) { + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + context.lineTo(pt.x, pt.y); + } +} +function triangleBackcurve(context, points, controlPoint) { + var firstPt; + for (var i = 0; i < points.length; i++) { + var pt = points[i]; + if (i === 0) { + firstPt = pt; + } + context.lineTo(pt.x, pt.y); + } + context.quadraticCurveTo(controlPoint.x, controlPoint.y, firstPt.x, firstPt.y); +} +function triangleTee(context, trianglePoints, teePoints) { + if (context.beginPath) { + context.beginPath(); + } + var triPts = trianglePoints; + for (var i = 0; i < triPts.length; i++) { + var pt = triPts[i]; + context.lineTo(pt.x, pt.y); + } + var teePts = teePoints; + var firstTeePt = teePoints[0]; + context.moveTo(firstTeePt.x, firstTeePt.y); + for (var i = 1; i < teePts.length; i++) { + var pt = teePts[i]; + context.lineTo(pt.x, pt.y); + } + if (context.closePath) { + context.closePath(); + } +} +function circleTriangle(context, trianglePoints, rx, ry, r) { + if (context.beginPath) { + context.beginPath(); + } + context.arc(rx, ry, r, 0, Math.PI * 2, false); + var triPts = trianglePoints; + var firstTrPt = triPts[0]; + context.moveTo(firstTrPt.x, firstTrPt.y); + for (var i = 0; i < triPts.length; i++) { + var pt = triPts[i]; + context.lineTo(pt.x, pt.y); + } + if (context.closePath) { + context.closePath(); + } +} +function circle(context, rx, ry, r) { + context.arc(rx, ry, r, 0, Math.PI * 2, false); +} +CRp$a.arrowShapeImpl = function (name) { + return (impl || (impl = { + 'polygon': polygon, + 'triangle-backcurve': triangleBackcurve, + 'triangle-tee': triangleTee, + 'circle-triangle': circleTriangle, + 'triangle-cross': triangleTee, + 'circle': circle + }))[name]; +}; + +var CRp$9 = {}; +CRp$9.drawElement = function (context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity) { + var r = this; + if (ele.isNode()) { + r.drawNode(context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity); + } else { + r.drawEdge(context, ele, shiftToOriginWithBb, showLabel, showOverlay, showOpacity); + } +}; +CRp$9.drawElementOverlay = function (context, ele) { + var r = this; + if (ele.isNode()) { + r.drawNodeOverlay(context, ele); + } else { + r.drawEdgeOverlay(context, ele); + } +}; +CRp$9.drawElementUnderlay = function (context, ele) { + var r = this; + if (ele.isNode()) { + r.drawNodeUnderlay(context, ele); + } else { + r.drawEdgeUnderlay(context, ele); + } +}; +CRp$9.drawCachedElementPortion = function (context, ele, eleTxrCache, pxRatio, lvl, reason, getRotation, getOpacity) { + var r = this; + var bb = eleTxrCache.getBoundingBox(ele); + if (bb.w === 0 || bb.h === 0) { + return; + } // ignore zero size case + + var eleCache = eleTxrCache.getElement(ele, bb, pxRatio, lvl, reason); + if (eleCache != null) { + var opacity = getOpacity(r, ele); + if (opacity === 0) { + return; + } + var theta = getRotation(r, ele); + var x1 = bb.x1, + y1 = bb.y1, + w = bb.w, + h = bb.h; + var x, y, sx, sy, smooth; + if (theta !== 0) { + var rotPt = eleTxrCache.getRotationPoint(ele); + sx = rotPt.x; + sy = rotPt.y; + context.translate(sx, sy); + context.rotate(theta); + smooth = r.getImgSmoothing(context); + if (!smooth) { + r.setImgSmoothing(context, true); + } + var off = eleTxrCache.getRotationOffset(ele); + x = off.x; + y = off.y; + } else { + x = x1; + y = y1; + } + var oldGlobalAlpha; + if (opacity !== 1) { + oldGlobalAlpha = context.globalAlpha; + context.globalAlpha = oldGlobalAlpha * opacity; + } + context.drawImage(eleCache.texture.canvas, eleCache.x, 0, eleCache.width, eleCache.height, x, y, w, h); + if (opacity !== 1) { + context.globalAlpha = oldGlobalAlpha; + } + if (theta !== 0) { + context.rotate(-theta); + context.translate(-sx, -sy); + if (!smooth) { + r.setImgSmoothing(context, false); + } + } + } else { + eleTxrCache.drawElement(context, ele); // direct draw fallback + } +}; + +var getZeroRotation = function getZeroRotation() { + return 0; +}; +var getLabelRotation = function getLabelRotation(r, ele) { + return r.getTextAngle(ele, null); +}; +var getSourceLabelRotation = function getSourceLabelRotation(r, ele) { + return r.getTextAngle(ele, 'source'); +}; +var getTargetLabelRotation = function getTargetLabelRotation(r, ele) { + return r.getTextAngle(ele, 'target'); +}; +var getOpacity = function getOpacity(r, ele) { + return ele.effectiveOpacity(); +}; +var getTextOpacity = function getTextOpacity(e, ele) { + return ele.pstyle('text-opacity').pfValue * ele.effectiveOpacity(); +}; +CRp$9.drawCachedElement = function (context, ele, pxRatio, extent, lvl, requestHighQuality) { + var r = this; + var _r$data = r.data, + eleTxrCache = _r$data.eleTxrCache, + lblTxrCache = _r$data.lblTxrCache, + slbTxrCache = _r$data.slbTxrCache, + tlbTxrCache = _r$data.tlbTxrCache; + var bb = ele.boundingBox(); + var reason = requestHighQuality === true ? eleTxrCache.reasons.highQuality : null; + if (bb.w === 0 || bb.h === 0 || !ele.visible()) { + return; + } + if (!extent || boundingBoxesIntersect(bb, extent)) { + var isEdge = ele.isEdge(); + var badLine = ele.element()._private.rscratch.badLine; + r.drawElementUnderlay(context, ele); + r.drawCachedElementPortion(context, ele, eleTxrCache, pxRatio, lvl, reason, getZeroRotation, getOpacity); + if (!isEdge || !badLine) { + r.drawCachedElementPortion(context, ele, lblTxrCache, pxRatio, lvl, reason, getLabelRotation, getTextOpacity); + } + if (isEdge && !badLine) { + r.drawCachedElementPortion(context, ele, slbTxrCache, pxRatio, lvl, reason, getSourceLabelRotation, getTextOpacity); + r.drawCachedElementPortion(context, ele, tlbTxrCache, pxRatio, lvl, reason, getTargetLabelRotation, getTextOpacity); + } + r.drawElementOverlay(context, ele); + } +}; +CRp$9.drawElements = function (context, eles) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + r.drawElement(context, ele); + } +}; +CRp$9.drawCachedElements = function (context, eles, pxRatio, extent) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + r.drawCachedElement(context, ele, pxRatio, extent); + } +}; +CRp$9.drawCachedNodes = function (context, eles, pxRatio, extent) { + var r = this; + for (var i = 0; i < eles.length; i++) { + var ele = eles[i]; + if (!ele.isNode()) { + continue; + } + r.drawCachedElement(context, ele, pxRatio, extent); + } +}; +CRp$9.drawLayeredElements = function (context, eles, pxRatio, extent) { + var r = this; + var layers = r.data.lyrTxrCache.getLayers(eles, pxRatio); + if (layers) { + for (var i = 0; i < layers.length; i++) { + var layer = layers[i]; + var bb = layer.bb; + if (bb.w === 0 || bb.h === 0) { + continue; + } + context.drawImage(layer.canvas, bb.x1, bb.y1, bb.w, bb.h); + } + } else { + // fall back on plain caching if no layers + r.drawCachedElements(context, eles, pxRatio, extent); + } +}; + +var CRp$8 = {}; +CRp$8.drawEdge = function (context, edge, shiftToOriginWithBb) { + var drawLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var shouldDrawOverlay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var shouldDrawOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + var rs = edge._private.rscratch; + if (shouldDrawOpacity && !edge.visible()) { + return; + } + + // if bezier ctrl pts can not be calculated, then die + if (rs.badLine || rs.allpts == null || isNaN(rs.allpts[0])) { + // isNaN in case edge is impossible and browser bugs (e.g. safari) + return; + } + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + var opacity = shouldDrawOpacity ? edge.pstyle('opacity').value : 1; + var lineOpacity = shouldDrawOpacity ? edge.pstyle('line-opacity').value : 1; + var curveStyle = edge.pstyle('curve-style').value; + var lineStyle = edge.pstyle('line-style').value; + var edgeWidth = edge.pstyle('width').pfValue; + var lineCap = edge.pstyle('line-cap').value; + var effectiveLineOpacity = opacity * lineOpacity; + // separate arrow opacity would require arrow-opacity property + var effectiveArrowOpacity = opacity * lineOpacity; + var drawLine = function drawLine() { + var strokeOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : effectiveLineOpacity; + if (curveStyle === 'straight-triangle') { + r.eleStrokeStyle(context, edge, strokeOpacity); + r.drawEdgeTrianglePath(edge, context, rs.allpts); + } else { + context.lineWidth = edgeWidth; + context.lineCap = lineCap; + r.eleStrokeStyle(context, edge, strokeOpacity); + r.drawEdgePath(edge, context, rs.allpts, lineStyle); + context.lineCap = 'butt'; // reset for other drawing functions + } + }; + + var drawOverlay = function drawOverlay() { + if (!shouldDrawOverlay) { + return; + } + r.drawEdgeOverlay(context, edge); + }; + var drawUnderlay = function drawUnderlay() { + if (!shouldDrawOverlay) { + return; + } + r.drawEdgeUnderlay(context, edge); + }; + var drawArrows = function drawArrows() { + var arrowOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : effectiveArrowOpacity; + r.drawArrowheads(context, edge, arrowOpacity); + }; + var drawText = function drawText() { + r.drawElementText(context, edge, null, drawLabel); + }; + context.lineJoin = 'round'; + var ghost = edge.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = edge.pstyle('ghost-offset-x').pfValue; + var gy = edge.pstyle('ghost-offset-y').pfValue; + var ghostOpacity = edge.pstyle('ghost-opacity').value; + var effectiveGhostOpacity = effectiveLineOpacity * ghostOpacity; + context.translate(gx, gy); + drawLine(effectiveGhostOpacity); + drawArrows(effectiveGhostOpacity); + context.translate(-gx, -gy); + } + drawUnderlay(); + drawLine(); + drawArrows(); + drawOverlay(); + drawText(); + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +var drawEdgeOverlayUnderlay = function drawEdgeOverlayUnderlay(overlayOrUnderlay) { + if (!['overlay', 'underlay'].includes(overlayOrUnderlay)) { + throw new Error('Invalid state'); + } + return function (context, edge) { + if (!edge.visible()) { + return; + } + var opacity = edge.pstyle("".concat(overlayOrUnderlay, "-opacity")).value; + if (opacity === 0) { + return; + } + var r = this; + var usePaths = r.usePaths(); + var rs = edge._private.rscratch; + var padding = edge.pstyle("".concat(overlayOrUnderlay, "-padding")).pfValue; + var width = 2 * padding; + var color = edge.pstyle("".concat(overlayOrUnderlay, "-color")).value; + context.lineWidth = width; + if (rs.edgeType === 'self' && !usePaths) { + context.lineCap = 'butt'; + } else { + context.lineCap = 'round'; + } + r.colorStrokeStyle(context, color[0], color[1], color[2], opacity); + r.drawEdgePath(edge, context, rs.allpts, 'solid'); + }; +}; +CRp$8.drawEdgeOverlay = drawEdgeOverlayUnderlay('overlay'); +CRp$8.drawEdgeUnderlay = drawEdgeOverlayUnderlay('underlay'); +CRp$8.drawEdgePath = function (edge, context, pts, type) { + var rs = edge._private.rscratch; + var canvasCxt = context; + var path; + var pathCacheHit = false; + var usePaths = this.usePaths(); + var lineDashPattern = edge.pstyle('line-dash-pattern').pfValue; + var lineDashOffset = edge.pstyle('line-dash-offset').pfValue; + if (usePaths) { + var pathCacheKey = pts.join('$'); + var keyMatches = rs.pathCacheKey && rs.pathCacheKey === pathCacheKey; + if (keyMatches) { + path = context = rs.pathCache; + pathCacheHit = true; + } else { + path = context = new Path2D(); + rs.pathCacheKey = pathCacheKey; + rs.pathCache = path; + } + } + if (canvasCxt.setLineDash) { + // for very outofdate browsers + switch (type) { + case 'dotted': + canvasCxt.setLineDash([1, 1]); + break; + case 'dashed': + canvasCxt.setLineDash(lineDashPattern); + canvasCxt.lineDashOffset = lineDashOffset; + break; + case 'solid': + canvasCxt.setLineDash([]); + break; + } + } + if (!pathCacheHit && !rs.badLine) { + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(pts[0], pts[1]); + switch (rs.edgeType) { + case 'bezier': + case 'self': + case 'compound': + case 'multibezier': + for (var i = 2; i + 3 < pts.length; i += 4) { + context.quadraticCurveTo(pts[i], pts[i + 1], pts[i + 2], pts[i + 3]); + } + break; + case 'straight': + case 'haystack': + for (var _i = 2; _i + 1 < pts.length; _i += 2) { + context.lineTo(pts[_i], pts[_i + 1]); + } + break; + case 'segments': + if (rs.isRound) { + var _iterator = _createForOfIteratorHelper(rs.roundCorners), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var corner = _step.value; + drawPreparedRoundCorner(context, corner); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + context.lineTo(pts[pts.length - 2], pts[pts.length - 1]); + } else { + for (var _i2 = 2; _i2 + 1 < pts.length; _i2 += 2) { + context.lineTo(pts[_i2], pts[_i2 + 1]); + } + } + break; + } + } + context = canvasCxt; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + + // reset any line dashes + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } +}; +CRp$8.drawEdgeTrianglePath = function (edge, context, pts) { + // use line stroke style for triangle fill style + context.fillStyle = context.strokeStyle; + var edgeWidth = edge.pstyle('width').pfValue; + for (var i = 0; i + 1 < pts.length; i += 2) { + var vector = [pts[i + 2] - pts[i], pts[i + 3] - pts[i + 1]]; + var length = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + var normal = [vector[1] / length, -vector[0] / length]; + var triangleHead = [normal[0] * edgeWidth / 2, normal[1] * edgeWidth / 2]; + context.beginPath(); + context.moveTo(pts[i] - triangleHead[0], pts[i + 1] - triangleHead[1]); + context.lineTo(pts[i] + triangleHead[0], pts[i + 1] + triangleHead[1]); + context.lineTo(pts[i + 2], pts[i + 3]); + context.closePath(); + context.fill(); + } +}; +CRp$8.drawArrowheads = function (context, edge, opacity) { + var rs = edge._private.rscratch; + var isHaystack = rs.edgeType === 'haystack'; + if (!isHaystack) { + this.drawArrowhead(context, edge, 'source', rs.arrowStartX, rs.arrowStartY, rs.srcArrowAngle, opacity); + } + this.drawArrowhead(context, edge, 'mid-target', rs.midX, rs.midY, rs.midtgtArrowAngle, opacity); + this.drawArrowhead(context, edge, 'mid-source', rs.midX, rs.midY, rs.midsrcArrowAngle, opacity); + if (!isHaystack) { + this.drawArrowhead(context, edge, 'target', rs.arrowEndX, rs.arrowEndY, rs.tgtArrowAngle, opacity); + } +}; +CRp$8.drawArrowhead = function (context, edge, prefix, x, y, angle, opacity) { + if (isNaN(x) || x == null || isNaN(y) || y == null || isNaN(angle) || angle == null) { + return; + } + var self = this; + var arrowShape = edge.pstyle(prefix + '-arrow-shape').value; + if (arrowShape === 'none') { + return; + } + var arrowClearFill = edge.pstyle(prefix + '-arrow-fill').value === 'hollow' ? 'both' : 'filled'; + var arrowFill = edge.pstyle(prefix + '-arrow-fill').value; + var edgeWidth = edge.pstyle('width').pfValue; + var pArrowWidth = edge.pstyle(prefix + '-arrow-width'); + var arrowWidth = pArrowWidth.value === 'match-line' ? edgeWidth : pArrowWidth.pfValue; + if (pArrowWidth.units === '%') arrowWidth *= edgeWidth; + var edgeOpacity = edge.pstyle('opacity').value; + if (opacity === undefined) { + opacity = edgeOpacity; + } + var gco = context.globalCompositeOperation; + if (opacity !== 1 || arrowFill === 'hollow') { + // then extra clear is needed + context.globalCompositeOperation = 'destination-out'; + self.colorFillStyle(context, 255, 255, 255, 1); + self.colorStrokeStyle(context, 255, 255, 255, 1); + self.drawArrowShape(edge, context, arrowClearFill, edgeWidth, arrowShape, arrowWidth, x, y, angle); + context.globalCompositeOperation = gco; + } // otherwise, the opaque arrow clears it for free :) + + var color = edge.pstyle(prefix + '-arrow-color').value; + self.colorFillStyle(context, color[0], color[1], color[2], opacity); + self.colorStrokeStyle(context, color[0], color[1], color[2], opacity); + self.drawArrowShape(edge, context, arrowFill, edgeWidth, arrowShape, arrowWidth, x, y, angle); +}; +CRp$8.drawArrowShape = function (edge, context, fill, edgeWidth, shape, shapeWidth, x, y, angle) { + var r = this; + var usePaths = this.usePaths() && shape !== 'triangle-cross'; + var pathCacheHit = false; + var path; + var canvasContext = context; + var translation = { + x: x, + y: y + }; + var scale = edge.pstyle('arrow-scale').value; + var size = this.getArrowWidth(edgeWidth, scale); + var shapeImpl = r.arrowShapes[shape]; + if (usePaths) { + var cache = r.arrowPathCache = r.arrowPathCache || []; + var key = hashString(shape); + var cachedPath = cache[key]; + if (cachedPath != null) { + path = context = cachedPath; + pathCacheHit = true; + } else { + path = context = new Path2D(); + cache[key] = path; + } + } + if (!pathCacheHit) { + if (context.beginPath) { + context.beginPath(); + } + if (usePaths) { + // store in the path cache with values easily manipulated later + shapeImpl.draw(context, 1, 0, { + x: 0, + y: 0 + }, 1); + } else { + shapeImpl.draw(context, size, angle, translation, edgeWidth); + } + if (context.closePath) { + context.closePath(); + } + } + context = canvasContext; + if (usePaths) { + // set transform to arrow position/orientation + context.translate(x, y); + context.rotate(angle); + context.scale(size, size); + } + if (fill === 'filled' || fill === 'both') { + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + } + if (fill === 'hollow' || fill === 'both') { + context.lineWidth = shapeWidth / (usePaths ? size : 1); + context.lineJoin = 'miter'; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + } + if (usePaths) { + // reset transform by applying inverse + context.scale(1 / size, 1 / size); + context.rotate(-angle); + context.translate(-x, -y); + } +}; + +var CRp$7 = {}; +CRp$7.safeDrawImage = function (context, img, ix, iy, iw, ih, x, y, w, h) { + // detect problematic cases for old browsers with bad images (cheaper than try-catch) + if (iw <= 0 || ih <= 0 || w <= 0 || h <= 0) { + return; + } + try { + context.drawImage(img, ix, iy, iw, ih, x, y, w, h); + } catch (e) { + warn(e); + } +}; +CRp$7.drawInscribedImage = function (context, img, node, index, nodeOpacity) { + var r = this; + var pos = node.position(); + var nodeX = pos.x; + var nodeY = pos.y; + var styleObj = node.cy().style(); + var getIndexedStyle = styleObj.getIndexedStyle.bind(styleObj); + var fit = getIndexedStyle(node, 'background-fit', 'value', index); + var repeat = getIndexedStyle(node, 'background-repeat', 'value', index); + var nodeW = node.width(); + var nodeH = node.height(); + var paddingX2 = node.padding() * 2; + var nodeTW = nodeW + (getIndexedStyle(node, 'background-width-relative-to', 'value', index) === 'inner' ? 0 : paddingX2); + var nodeTH = nodeH + (getIndexedStyle(node, 'background-height-relative-to', 'value', index) === 'inner' ? 0 : paddingX2); + var rs = node._private.rscratch; + var clip = getIndexedStyle(node, 'background-clip', 'value', index); + var shouldClip = clip === 'node'; + var imgOpacity = getIndexedStyle(node, 'background-image-opacity', 'value', index) * nodeOpacity; + var smooth = getIndexedStyle(node, 'background-image-smoothing', 'value', index); + var cornerRadius = node.pstyle('corner-radius').value; + if (cornerRadius !== 'auto') cornerRadius = node.pstyle('corner-radius').pfValue; + var imgW = img.width || img.cachedW; + var imgH = img.height || img.cachedH; + + // workaround for broken browsers like ie + if (null == imgW || null == imgH) { + document.body.appendChild(img); // eslint-disable-line no-undef + + imgW = img.cachedW = img.width || img.offsetWidth; + imgH = img.cachedH = img.height || img.offsetHeight; + document.body.removeChild(img); // eslint-disable-line no-undef + } + + var w = imgW; + var h = imgH; + if (getIndexedStyle(node, 'background-width', 'value', index) !== 'auto') { + if (getIndexedStyle(node, 'background-width', 'units', index) === '%') { + w = getIndexedStyle(node, 'background-width', 'pfValue', index) * nodeTW; + } else { + w = getIndexedStyle(node, 'background-width', 'pfValue', index); + } + } + if (getIndexedStyle(node, 'background-height', 'value', index) !== 'auto') { + if (getIndexedStyle(node, 'background-height', 'units', index) === '%') { + h = getIndexedStyle(node, 'background-height', 'pfValue', index) * nodeTH; + } else { + h = getIndexedStyle(node, 'background-height', 'pfValue', index); + } + } + if (w === 0 || h === 0) { + return; // no point in drawing empty image (and chrome is broken in this case) + } + + if (fit === 'contain') { + var scale = Math.min(nodeTW / w, nodeTH / h); + w *= scale; + h *= scale; + } else if (fit === 'cover') { + var scale = Math.max(nodeTW / w, nodeTH / h); + w *= scale; + h *= scale; + } + var x = nodeX - nodeTW / 2; // left + var posXUnits = getIndexedStyle(node, 'background-position-x', 'units', index); + var posXPfVal = getIndexedStyle(node, 'background-position-x', 'pfValue', index); + if (posXUnits === '%') { + x += (nodeTW - w) * posXPfVal; + } else { + x += posXPfVal; + } + var offXUnits = getIndexedStyle(node, 'background-offset-x', 'units', index); + var offXPfVal = getIndexedStyle(node, 'background-offset-x', 'pfValue', index); + if (offXUnits === '%') { + x += (nodeTW - w) * offXPfVal; + } else { + x += offXPfVal; + } + var y = nodeY - nodeTH / 2; // top + var posYUnits = getIndexedStyle(node, 'background-position-y', 'units', index); + var posYPfVal = getIndexedStyle(node, 'background-position-y', 'pfValue', index); + if (posYUnits === '%') { + y += (nodeTH - h) * posYPfVal; + } else { + y += posYPfVal; + } + var offYUnits = getIndexedStyle(node, 'background-offset-y', 'units', index); + var offYPfVal = getIndexedStyle(node, 'background-offset-y', 'pfValue', index); + if (offYUnits === '%') { + y += (nodeTH - h) * offYPfVal; + } else { + y += offYPfVal; + } + if (rs.pathCache) { + x -= nodeX; + y -= nodeY; + nodeX = 0; + nodeY = 0; + } + var gAlpha = context.globalAlpha; + context.globalAlpha = imgOpacity; + var smoothingEnabled = r.getImgSmoothing(context); + var isSmoothingSwitched = false; + if (smooth === 'no' && smoothingEnabled) { + r.setImgSmoothing(context, false); + isSmoothingSwitched = true; + } else if (smooth === 'yes' && !smoothingEnabled) { + r.setImgSmoothing(context, true); + isSmoothingSwitched = true; + } + if (repeat === 'no-repeat') { + if (shouldClip) { + context.save(); + if (rs.pathCache) { + context.clip(rs.pathCache); + } else { + r.nodeShapes[r.getNodeShape(node)].draw(context, nodeX, nodeY, nodeTW, nodeTH, cornerRadius, rs); + context.clip(); + } + } + r.safeDrawImage(context, img, 0, 0, imgW, imgH, x, y, w, h); + if (shouldClip) { + context.restore(); + } + } else { + var pattern = context.createPattern(img, repeat); + context.fillStyle = pattern; + r.nodeShapes[r.getNodeShape(node)].draw(context, nodeX, nodeY, nodeTW, nodeTH, cornerRadius, rs); + context.translate(x, y); + context.fill(); + context.translate(-x, -y); + } + context.globalAlpha = gAlpha; + if (isSmoothingSwitched) { + r.setImgSmoothing(context, smoothingEnabled); + } +}; + +var CRp$6 = {}; +CRp$6.eleTextBiggerThanMin = function (ele, scale) { + if (!scale) { + var zoom = ele.cy().zoom(); + var pxRatio = this.getPixelRatio(); + var lvl = Math.ceil(log2(zoom * pxRatio)); // the effective texture level + + scale = Math.pow(2, lvl); + } + var computedSize = ele.pstyle('font-size').pfValue * scale; + var minSize = ele.pstyle('min-zoomed-font-size').pfValue; + if (computedSize < minSize) { + return false; + } + return true; +}; +CRp$6.drawElementText = function (context, ele, shiftToOriginWithBb, force, prefix) { + var useEleOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + if (force == null) { + if (useEleOpacity && !r.eleTextBiggerThanMin(ele)) { + return; + } + } else if (force === false) { + return; + } + if (ele.isNode()) { + var label = ele.pstyle('label'); + if (!label || !label.value) { + return; + } + var justification = r.getLabelJustification(ele); + context.textAlign = justification; + context.textBaseline = 'bottom'; + } else { + var badLine = ele.element()._private.rscratch.badLine; + var _label = ele.pstyle('label'); + var srcLabel = ele.pstyle('source-label'); + var tgtLabel = ele.pstyle('target-label'); + if (badLine || (!_label || !_label.value) && (!srcLabel || !srcLabel.value) && (!tgtLabel || !tgtLabel.value)) { + return; + } + context.textAlign = 'center'; + context.textBaseline = 'bottom'; + } + var applyRotation = !shiftToOriginWithBb; + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + if (prefix == null) { + r.drawText(context, ele, null, applyRotation, useEleOpacity); + if (ele.isEdge()) { + r.drawText(context, ele, 'source', applyRotation, useEleOpacity); + r.drawText(context, ele, 'target', applyRotation, useEleOpacity); + } + } else { + r.drawText(context, ele, prefix, applyRotation, useEleOpacity); + } + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +CRp$6.getFontCache = function (context) { + var cache; + this.fontCaches = this.fontCaches || []; + for (var i = 0; i < this.fontCaches.length; i++) { + cache = this.fontCaches[i]; + if (cache.context === context) { + return cache; + } + } + cache = { + context: context + }; + this.fontCaches.push(cache); + return cache; +}; + +// set up canvas context with font +// returns transformed text string +CRp$6.setupTextStyle = function (context, ele) { + var useEleOpacity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + // Font style + var labelStyle = ele.pstyle('font-style').strValue; + var labelSize = ele.pstyle('font-size').pfValue + 'px'; + var labelFamily = ele.pstyle('font-family').strValue; + var labelWeight = ele.pstyle('font-weight').strValue; + var opacity = useEleOpacity ? ele.effectiveOpacity() * ele.pstyle('text-opacity').value : 1; + var outlineOpacity = ele.pstyle('text-outline-opacity').value * opacity; + var color = ele.pstyle('color').value; + var outlineColor = ele.pstyle('text-outline-color').value; + context.font = labelStyle + ' ' + labelWeight + ' ' + labelSize + ' ' + labelFamily; + context.lineJoin = 'round'; // so text outlines aren't jagged + + this.colorFillStyle(context, color[0], color[1], color[2], opacity); + this.colorStrokeStyle(context, outlineColor[0], outlineColor[1], outlineColor[2], outlineOpacity); +}; + +// TODO ensure re-used +function roundRect(ctx, x, y, width, height) { + var radius = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 5; + var stroke = arguments.length > 6 ? arguments[6] : undefined; + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + if (stroke) ctx.stroke();else ctx.fill(); +} +CRp$6.getTextAngle = function (ele, prefix) { + var theta; + var _p = ele._private; + var rscratch = _p.rscratch; + var pdash = prefix ? prefix + '-' : ''; + var rotation = ele.pstyle(pdash + 'text-rotation'); + var textAngle = getPrefixedProperty(rscratch, 'labelAngle', prefix); + if (rotation.strValue === 'autorotate') { + theta = ele.isEdge() ? textAngle : 0; + } else if (rotation.strValue === 'none') { + theta = 0; + } else { + theta = rotation.pfValue; + } + return theta; +}; +CRp$6.drawText = function (context, ele, prefix) { + var applyRotation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var useEleOpacity = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var _p = ele._private; + var rscratch = _p.rscratch; + var parentOpacity = useEleOpacity ? ele.effectiveOpacity() : 1; + if (useEleOpacity && (parentOpacity === 0 || ele.pstyle('text-opacity').value === 0)) { + return; + } + + // use 'main' as an alias for the main label (i.e. null prefix) + if (prefix === 'main') { + prefix = null; + } + var textX = getPrefixedProperty(rscratch, 'labelX', prefix); + var textY = getPrefixedProperty(rscratch, 'labelY', prefix); + var orgTextX, orgTextY; // used for rotation + var text = this.getLabelText(ele, prefix); + if (text != null && text !== '' && !isNaN(textX) && !isNaN(textY)) { + this.setupTextStyle(context, ele, useEleOpacity); + var pdash = prefix ? prefix + '-' : ''; + var textW = getPrefixedProperty(rscratch, 'labelWidth', prefix); + var textH = getPrefixedProperty(rscratch, 'labelHeight', prefix); + var marginX = ele.pstyle(pdash + 'text-margin-x').pfValue; + var marginY = ele.pstyle(pdash + 'text-margin-y').pfValue; + var isEdge = ele.isEdge(); + var halign = ele.pstyle('text-halign').value; + var valign = ele.pstyle('text-valign').value; + if (isEdge) { + halign = 'center'; + valign = 'center'; + } + textX += marginX; + textY += marginY; + var theta; + if (!applyRotation) { + theta = 0; + } else { + theta = this.getTextAngle(ele, prefix); + } + if (theta !== 0) { + orgTextX = textX; + orgTextY = textY; + context.translate(orgTextX, orgTextY); + context.rotate(theta); + textX = 0; + textY = 0; + } + switch (valign) { + case 'top': + break; + case 'center': + textY += textH / 2; + break; + case 'bottom': + textY += textH; + break; + } + var backgroundOpacity = ele.pstyle('text-background-opacity').value; + var borderOpacity = ele.pstyle('text-border-opacity').value; + var textBorderWidth = ele.pstyle('text-border-width').pfValue; + var backgroundPadding = ele.pstyle('text-background-padding').pfValue; + var styleShape = ele.pstyle('text-background-shape').strValue; + var rounded = styleShape.indexOf('round') === 0; + var roundRadius = 2; + if (backgroundOpacity > 0 || textBorderWidth > 0 && borderOpacity > 0) { + var bgX = textX - backgroundPadding; + switch (halign) { + case 'left': + bgX -= textW; + break; + case 'center': + bgX -= textW / 2; + break; + } + var bgY = textY - textH - backgroundPadding; + var bgW = textW + 2 * backgroundPadding; + var bgH = textH + 2 * backgroundPadding; + if (backgroundOpacity > 0) { + var textFill = context.fillStyle; + var textBackgroundColor = ele.pstyle('text-background-color').value; + context.fillStyle = 'rgba(' + textBackgroundColor[0] + ',' + textBackgroundColor[1] + ',' + textBackgroundColor[2] + ',' + backgroundOpacity * parentOpacity + ')'; + if (rounded) { + roundRect(context, bgX, bgY, bgW, bgH, roundRadius); + } else { + context.fillRect(bgX, bgY, bgW, bgH); + } + context.fillStyle = textFill; + } + if (textBorderWidth > 0 && borderOpacity > 0) { + var textStroke = context.strokeStyle; + var textLineWidth = context.lineWidth; + var textBorderColor = ele.pstyle('text-border-color').value; + var textBorderStyle = ele.pstyle('text-border-style').value; + context.strokeStyle = 'rgba(' + textBorderColor[0] + ',' + textBorderColor[1] + ',' + textBorderColor[2] + ',' + borderOpacity * parentOpacity + ')'; + context.lineWidth = textBorderWidth; + if (context.setLineDash) { + // for very outofdate browsers + switch (textBorderStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash([4, 2]); + break; + case 'double': + context.lineWidth = textBorderWidth / 4; // 50% reserved for white between the two borders + context.setLineDash([]); + break; + case 'solid': + context.setLineDash([]); + break; + } + } + if (rounded) { + roundRect(context, bgX, bgY, bgW, bgH, roundRadius, 'stroke'); + } else { + context.strokeRect(bgX, bgY, bgW, bgH); + } + if (textBorderStyle === 'double') { + var whiteWidth = textBorderWidth / 2; + if (rounded) { + roundRect(context, bgX + whiteWidth, bgY + whiteWidth, bgW - whiteWidth * 2, bgH - whiteWidth * 2, roundRadius, 'stroke'); + } else { + context.strokeRect(bgX + whiteWidth, bgY + whiteWidth, bgW - whiteWidth * 2, bgH - whiteWidth * 2); + } + } + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + context.lineWidth = textLineWidth; + context.strokeStyle = textStroke; + } + } + var lineWidth = 2 * ele.pstyle('text-outline-width').pfValue; // *2 b/c the stroke is drawn centred on the middle + + if (lineWidth > 0) { + context.lineWidth = lineWidth; + } + if (ele.pstyle('text-wrap').value === 'wrap') { + var lines = getPrefixedProperty(rscratch, 'labelWrapCachedLines', prefix); + var lineHeight = getPrefixedProperty(rscratch, 'labelLineHeight', prefix); + var halfTextW = textW / 2; + var justification = this.getLabelJustification(ele); + if (justification === 'auto') ; else if (halign === 'left') { + // auto justification : right + if (justification === 'left') { + textX += -textW; + } else if (justification === 'center') { + textX += -halfTextW; + } // else same as auto + } else if (halign === 'center') { + // auto justfication : center + if (justification === 'left') { + textX += -halfTextW; + } else if (justification === 'right') { + textX += halfTextW; + } // else same as auto + } else if (halign === 'right') { + // auto justification : left + if (justification === 'center') { + textX += halfTextW; + } else if (justification === 'right') { + textX += textW; + } // else same as auto + } + + switch (valign) { + case 'top': + textY -= (lines.length - 1) * lineHeight; + break; + case 'center': + case 'bottom': + textY -= (lines.length - 1) * lineHeight; + break; + } + for (var l = 0; l < lines.length; l++) { + if (lineWidth > 0) { + context.strokeText(lines[l], textX, textY); + } + context.fillText(lines[l], textX, textY); + textY += lineHeight; + } + } else { + if (lineWidth > 0) { + context.strokeText(text, textX, textY); + } + context.fillText(text, textX, textY); + } + if (theta !== 0) { + context.rotate(-theta); + context.translate(-orgTextX, -orgTextY); + } + } +}; + +/* global Path2D */ +var CRp$5 = {}; +CRp$5.drawNode = function (context, node, shiftToOriginWithBb) { + var drawLabel = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; + var shouldDrawOverlay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; + var shouldDrawOpacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true; + var r = this; + var nodeWidth, nodeHeight; + var _p = node._private; + var rs = _p.rscratch; + var pos = node.position(); + if (!number$1(pos.x) || !number$1(pos.y)) { + return; // can't draw node with undefined position + } + + if (shouldDrawOpacity && !node.visible()) { + return; + } + var eleOpacity = shouldDrawOpacity ? node.effectiveOpacity() : 1; + var usePaths = r.usePaths(); + var path; + var pathCacheHit = false; + var padding = node.padding(); + nodeWidth = node.width() + 2 * padding; + nodeHeight = node.height() + 2 * padding; + + // + // setup shift + + var bb; + if (shiftToOriginWithBb) { + bb = shiftToOriginWithBb; + context.translate(-bb.x1, -bb.y1); + } + + // + // load bg image + + var bgImgProp = node.pstyle('background-image'); + var urls = bgImgProp.value; + var urlDefined = new Array(urls.length); + var image = new Array(urls.length); + var numImages = 0; + for (var i = 0; i < urls.length; i++) { + var url = urls[i]; + var defd = urlDefined[i] = url != null && url !== 'none'; + if (defd) { + var bgImgCrossOrigin = node.cy().style().getIndexedStyle(node, 'background-image-crossorigin', 'value', i); + numImages++; + + // get image, and if not loaded then ask to redraw when later loaded + image[i] = r.getCachedImage(url, bgImgCrossOrigin, function () { + _p.backgroundTimestamp = Date.now(); + node.emitAndNotify('background'); + }); + } + } + + // + // setup styles + + var darkness = node.pstyle('background-blacken').value; + var borderWidth = node.pstyle('border-width').pfValue; + var bgOpacity = node.pstyle('background-opacity').value * eleOpacity; + var borderColor = node.pstyle('border-color').value; + var borderStyle = node.pstyle('border-style').value; + var borderJoin = node.pstyle('border-join').value; + var borderCap = node.pstyle('border-cap').value; + var borderPosition = node.pstyle('border-position').value; + var borderPattern = node.pstyle('border-dash-pattern').pfValue; + var borderOffset = node.pstyle('border-dash-offset').pfValue; + var borderOpacity = node.pstyle('border-opacity').value * eleOpacity; + var outlineWidth = node.pstyle('outline-width').pfValue; + var outlineColor = node.pstyle('outline-color').value; + var outlineStyle = node.pstyle('outline-style').value; + var outlineOpacity = node.pstyle('outline-opacity').value * eleOpacity; + var outlineOffset = node.pstyle('outline-offset').value; + var cornerRadius = node.pstyle('corner-radius').value; + if (cornerRadius !== 'auto') cornerRadius = node.pstyle('corner-radius').pfValue; + var setupShapeColor = function setupShapeColor() { + var bgOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bgOpacity; + r.eleFillStyle(context, node, bgOpy); + }; + var setupBorderColor = function setupBorderColor() { + var bdrOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : borderOpacity; + r.colorStrokeStyle(context, borderColor[0], borderColor[1], borderColor[2], bdrOpy); + }; + var setupOutlineColor = function setupOutlineColor() { + var otlnOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : outlineOpacity; + r.colorStrokeStyle(context, outlineColor[0], outlineColor[1], outlineColor[2], otlnOpy); + }; + + // + // setup shape + + var getPath = function getPath(width, height, shape, points) { + var pathCache = r.nodePathCache = r.nodePathCache || []; + var key = hashStrings(shape === 'polygon' ? shape + ',' + points.join(',') : shape, '' + height, '' + width, '' + cornerRadius); + var cachedPath = pathCache[key]; + var path; + var cacheHit = false; + if (cachedPath != null) { + path = cachedPath; + cacheHit = true; + rs.pathCache = path; + } else { + path = new Path2D(); + pathCache[key] = rs.pathCache = path; + } + return { + path: path, + cacheHit: cacheHit + }; + }; + var styleShape = node.pstyle('shape').strValue; + var shapePts = node.pstyle('shape-polygon-points').pfValue; + if (usePaths) { + context.translate(pos.x, pos.y); + var shapePath = getPath(nodeWidth, nodeHeight, styleShape, shapePts); + path = shapePath.path; + pathCacheHit = shapePath.cacheHit; + } + var drawShape = function drawShape() { + if (!pathCacheHit) { + var npos = pos; + if (usePaths) { + npos = { + x: 0, + y: 0 + }; + } + r.nodeShapes[r.getNodeShape(node)].draw(path || context, npos.x, npos.y, nodeWidth, nodeHeight, cornerRadius, rs); + } + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + }; + var drawImages = function drawImages() { + var nodeOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eleOpacity; + var inside = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var prevBging = _p.backgrounding; + var totalCompleted = 0; + for (var _i = 0; _i < image.length; _i++) { + var bgContainment = node.cy().style().getIndexedStyle(node, 'background-image-containment', 'value', _i); + if (inside && bgContainment === 'over' || !inside && bgContainment === 'inside') { + totalCompleted++; + continue; + } + if (urlDefined[_i] && image[_i].complete && !image[_i].error) { + totalCompleted++; + r.drawInscribedImage(context, image[_i], node, _i, nodeOpacity); + } + } + _p.backgrounding = !(totalCompleted === numImages); + if (prevBging !== _p.backgrounding) { + // update style b/c :backgrounding state changed + node.updateStyle(false); + } + }; + var drawPie = function drawPie() { + var redrawShape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + var pieOpacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : eleOpacity; + if (r.hasPie(node)) { + r.drawPie(context, node, pieOpacity); + + // redraw/restore path if steps after pie need it + if (redrawShape) { + if (!usePaths) { + r.nodeShapes[r.getNodeShape(node)].draw(context, pos.x, pos.y, nodeWidth, nodeHeight, cornerRadius, rs); + } + } + } + }; + var darken = function darken() { + var darkenOpacity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : eleOpacity; + var opacity = (darkness > 0 ? darkness : -darkness) * darkenOpacity; + var c = darkness > 0 ? 0 : 255; + if (darkness !== 0) { + r.colorFillStyle(context, c, c, c, opacity); + if (usePaths) { + context.fill(path); + } else { + context.fill(); + } + } + }; + var drawBorder = function drawBorder() { + if (borderWidth > 0) { + context.lineWidth = borderWidth; + context.lineCap = borderCap; + context.lineJoin = borderJoin; + if (context.setLineDash) { + // for very outofdate browsers + switch (borderStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash(borderPattern); + context.lineDashOffset = borderOffset; + break; + case 'solid': + case 'double': + context.setLineDash([]); + break; + } + } + if (borderPosition !== 'center') { + context.save(); + context.lineWidth *= 2; + if (borderPosition === 'inside') { + usePaths ? context.clip(path) : context.clip(); + } else { + var region = new Path2D(); + region.rect(-nodeWidth / 2 - borderWidth, -nodeHeight / 2 - borderWidth, nodeWidth + 2 * borderWidth, nodeHeight + 2 * borderWidth); + region.addPath(path); + context.clip(region, 'evenodd'); + } + usePaths ? context.stroke(path) : context.stroke(); + context.restore(); + } else { + usePaths ? context.stroke(path) : context.stroke(); + } + if (borderStyle === 'double') { + context.lineWidth = borderWidth / 3; + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + if (usePaths) { + context.stroke(path); + } else { + context.stroke(); + } + context.globalCompositeOperation = gco; + } + + // reset in case we changed the border style + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + } + }; + var drawOutline = function drawOutline() { + if (outlineWidth > 0) { + context.lineWidth = outlineWidth; + context.lineCap = 'butt'; + if (context.setLineDash) { + // for very outofdate browsers + switch (outlineStyle) { + case 'dotted': + context.setLineDash([1, 1]); + break; + case 'dashed': + context.setLineDash([4, 2]); + break; + case 'solid': + case 'double': + context.setLineDash([]); + break; + } + } + var npos = pos; + if (usePaths) { + npos = { + x: 0, + y: 0 + }; + } + var shape = r.getNodeShape(node); + var bWidth = borderWidth; + if (borderPosition === 'inside') bWidth = 0; + if (borderPosition === 'outside') bWidth *= 2; + var scaleX = (nodeWidth + bWidth + (outlineWidth + outlineOffset)) / nodeWidth; + var scaleY = (nodeHeight + bWidth + (outlineWidth + outlineOffset)) / nodeHeight; + var sWidth = nodeWidth * scaleX; + var sHeight = nodeHeight * scaleY; + var points = r.nodeShapes[shape].points; + var _path; + if (usePaths) { + var outlinePath = getPath(sWidth, sHeight, shape, points); + _path = outlinePath.path; + } + + // draw the outline path, either by using expanded points or by scaling + // the dimensions, depending on shape + if (shape === "ellipse") { + r.drawEllipsePath(_path || context, npos.x, npos.y, sWidth, sHeight); + } else if (['round-diamond', 'round-heptagon', 'round-hexagon', 'round-octagon', 'round-pentagon', 'round-polygon', 'round-triangle', 'round-tag'].includes(shape)) { + var sMult = 0; + var offsetX = 0; + var offsetY = 0; + if (shape === 'round-diamond') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.4; + } else if (shape === 'round-heptagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.075; + offsetY = -(bWidth / 2 + outlineOffset + outlineWidth) / 35; + } else if (shape === 'round-hexagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.12; + } else if (shape === 'round-pentagon') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.13; + offsetY = -(bWidth / 2 + outlineOffset + outlineWidth) / 15; + } else if (shape === 'round-tag') { + sMult = (bWidth + outlineOffset + outlineWidth) * 1.12; + offsetX = (bWidth / 2 + outlineWidth + outlineOffset) * .07; + } else if (shape === 'round-triangle') { + sMult = (bWidth + outlineOffset + outlineWidth) * (Math.PI / 2); + offsetY = -(bWidth + outlineOffset / 2 + outlineWidth) / Math.PI; + } + if (sMult !== 0) { + scaleX = (nodeWidth + sMult) / nodeWidth; + sWidth = nodeWidth * scaleX; + if (!['round-hexagon', 'round-tag'].includes(shape)) { + scaleY = (nodeHeight + sMult) / nodeHeight; + sHeight = nodeHeight * scaleY; + } + } + cornerRadius = cornerRadius === 'auto' ? getRoundPolygonRadius(sWidth, sHeight) : cornerRadius; + var halfW = sWidth / 2; + var halfH = sHeight / 2; + var radius = cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2; + var p = new Array(points.length / 2); + var corners = new Array(points.length / 2); + for (var _i3 = 0; _i3 < points.length / 2; _i3++) { + p[_i3] = { + x: npos.x + offsetX + halfW * points[_i3 * 2], + y: npos.y + offsetY + halfH * points[_i3 * 2 + 1] + }; + } + var _i2, + p1, + p2, + p3, + len = p.length; + p1 = p[len - 1]; + // for each point + for (_i2 = 0; _i2 < len; _i2++) { + p2 = p[_i2 % len]; + p3 = p[(_i2 + 1) % len]; + corners[_i2] = getRoundCorner(p1, p2, p3, radius); + p1 = p2; + p2 = p3; + } + r.drawRoundPolygonPath(_path || context, npos.x + offsetX, npos.y + offsetY, nodeWidth * scaleX, nodeHeight * scaleY, points, corners); + } else if (['roundrectangle', 'round-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(sWidth, sHeight) : cornerRadius; + r.drawRoundRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2); + } else if (['cutrectangle', 'cut-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getCutRectangleCornerLength() : cornerRadius; + r.drawCutRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, null, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 4); + } else if (['bottomroundrectangle', 'bottom-round-rectangle'].includes(shape)) { + cornerRadius = cornerRadius === 'auto' ? getRoundRectangleRadius(sWidth, sHeight) : cornerRadius; + r.drawBottomRoundRectanglePath(_path || context, npos.x, npos.y, sWidth, sHeight, cornerRadius + (bWidth + outlineWidth + outlineOffset) / 2); + } else if (shape === "barrel") { + r.drawBarrelPath(_path || context, npos.x, npos.y, sWidth, sHeight); + } else if (shape.startsWith("polygon") || ['rhomboid', 'right-rhomboid', 'round-tag', 'tag', 'vee'].includes(shape)) { + var pad = (bWidth + outlineWidth + outlineOffset) / nodeWidth; + points = joinLines(expandPolygon(points, pad)); + r.drawPolygonPath(_path || context, npos.x, npos.y, nodeWidth, nodeHeight, points); + } else { + var _pad = (bWidth + outlineWidth + outlineOffset) / nodeWidth; + points = joinLines(expandPolygon(points, -_pad)); + r.drawPolygonPath(_path || context, npos.x, npos.y, nodeWidth, nodeHeight, points); + } + if (usePaths) { + context.stroke(_path); + } else { + context.stroke(); + } + if (outlineStyle === 'double') { + context.lineWidth = bWidth / 3; + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + if (usePaths) { + context.stroke(_path); + } else { + context.stroke(); + } + context.globalCompositeOperation = gco; + } + + // reset in case we changed the border style + if (context.setLineDash) { + // for very outofdate browsers + context.setLineDash([]); + } + } + }; + var drawOverlay = function drawOverlay() { + if (shouldDrawOverlay) { + r.drawNodeOverlay(context, node, pos, nodeWidth, nodeHeight); + } + }; + var drawUnderlay = function drawUnderlay() { + if (shouldDrawOverlay) { + r.drawNodeUnderlay(context, node, pos, nodeWidth, nodeHeight); + } + }; + var drawText = function drawText() { + r.drawElementText(context, node, null, drawLabel); + }; + var ghost = node.pstyle('ghost').value === 'yes'; + if (ghost) { + var gx = node.pstyle('ghost-offset-x').pfValue; + var gy = node.pstyle('ghost-offset-y').pfValue; + var ghostOpacity = node.pstyle('ghost-opacity').value; + var effGhostOpacity = ghostOpacity * eleOpacity; + context.translate(gx, gy); + setupOutlineColor(); + drawOutline(); + setupShapeColor(ghostOpacity * bgOpacity); + drawShape(); + drawImages(effGhostOpacity, true); + setupBorderColor(ghostOpacity * borderOpacity); + drawBorder(); + drawPie(darkness !== 0 || borderWidth !== 0); + drawImages(effGhostOpacity, false); + darken(effGhostOpacity); + context.translate(-gx, -gy); + } + if (usePaths) { + context.translate(-pos.x, -pos.y); + } + drawUnderlay(); + if (usePaths) { + context.translate(pos.x, pos.y); + } + setupOutlineColor(); + drawOutline(); + setupShapeColor(); + drawShape(); + drawImages(eleOpacity, true); + setupBorderColor(); + drawBorder(); + drawPie(darkness !== 0 || borderWidth !== 0); + drawImages(eleOpacity, false); + darken(); + if (usePaths) { + context.translate(-pos.x, -pos.y); + } + drawText(); + drawOverlay(); + + // + // clean up shift + + if (shiftToOriginWithBb) { + context.translate(bb.x1, bb.y1); + } +}; +var drawNodeOverlayUnderlay = function drawNodeOverlayUnderlay(overlayOrUnderlay) { + if (!['overlay', 'underlay'].includes(overlayOrUnderlay)) { + throw new Error('Invalid state'); + } + return function (context, node, pos, nodeWidth, nodeHeight) { + var r = this; + if (!node.visible()) { + return; + } + var padding = node.pstyle("".concat(overlayOrUnderlay, "-padding")).pfValue; + var opacity = node.pstyle("".concat(overlayOrUnderlay, "-opacity")).value; + var color = node.pstyle("".concat(overlayOrUnderlay, "-color")).value; + var shape = node.pstyle("".concat(overlayOrUnderlay, "-shape")).value; + var radius = node.pstyle("".concat(overlayOrUnderlay, "-corner-radius")).value; + if (opacity > 0) { + pos = pos || node.position(); + if (nodeWidth == null || nodeHeight == null) { + var _padding = node.padding(); + nodeWidth = node.width() + 2 * _padding; + nodeHeight = node.height() + 2 * _padding; + } + r.colorFillStyle(context, color[0], color[1], color[2], opacity); + r.nodeShapes[shape].draw(context, pos.x, pos.y, nodeWidth + padding * 2, nodeHeight + padding * 2, radius); + context.fill(); + } + }; +}; +CRp$5.drawNodeOverlay = drawNodeOverlayUnderlay('overlay'); +CRp$5.drawNodeUnderlay = drawNodeOverlayUnderlay('underlay'); + +// does the node have at least one pie piece? +CRp$5.hasPie = function (node) { + node = node[0]; // ensure ele ref + + return node._private.hasPie; +}; +CRp$5.drawPie = function (context, node, nodeOpacity, pos) { + node = node[0]; // ensure ele ref + pos = pos || node.position(); + var cyStyle = node.cy().style(); + var pieSize = node.pstyle('pie-size'); + var x = pos.x; + var y = pos.y; + var nodeW = node.width(); + var nodeH = node.height(); + var radius = Math.min(nodeW, nodeH) / 2; // must fit in node + var lastPercent = 0; // what % to continue drawing pie slices from on [0, 1] + var usePaths = this.usePaths(); + if (usePaths) { + x = 0; + y = 0; + } + if (pieSize.units === '%') { + radius = radius * pieSize.pfValue; + } else if (pieSize.pfValue !== undefined) { + radius = pieSize.pfValue / 2; + } + for (var i = 1; i <= cyStyle.pieBackgroundN; i++) { + // 1..N + var size = node.pstyle('pie-' + i + '-background-size').value; + var color = node.pstyle('pie-' + i + '-background-color').value; + var opacity = node.pstyle('pie-' + i + '-background-opacity').value * nodeOpacity; + var percent = size / 100; // map integer range [0, 100] to [0, 1] + + // percent can't push beyond 1 + if (percent + lastPercent > 1) { + percent = 1 - lastPercent; + } + var angleStart = 1.5 * Math.PI + 2 * Math.PI * lastPercent; // start at 12 o'clock and go clockwise + var angleDelta = 2 * Math.PI * percent; + var angleEnd = angleStart + angleDelta; + + // ignore if + // - zero size + // - we're already beyond the full circle + // - adding the current slice would go beyond the full circle + if (size === 0 || lastPercent >= 1 || lastPercent + percent > 1) { + continue; + } + context.beginPath(); + context.moveTo(x, y); + context.arc(x, y, radius, angleStart, angleEnd); + context.closePath(); + this.colorFillStyle(context, color[0], color[1], color[2], opacity); + context.fill(); + lastPercent += percent; + } +}; + +var CRp$4 = {}; +var motionBlurDelay = 100; + +// var isFirefox = typeof InstallTrigger !== 'undefined'; + +CRp$4.getPixelRatio = function () { + var context = this.data.contexts[0]; + if (this.forcedPixelRatio != null) { + return this.forcedPixelRatio; + } + var backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; + return (window.devicePixelRatio || 1) / backingStore; // eslint-disable-line no-undef +}; + +CRp$4.paintCache = function (context) { + var caches = this.paintCaches = this.paintCaches || []; + var needToCreateCache = true; + var cache; + for (var i = 0; i < caches.length; i++) { + cache = caches[i]; + if (cache.context === context) { + needToCreateCache = false; + break; + } + } + if (needToCreateCache) { + cache = { + context: context + }; + caches.push(cache); + } + return cache; +}; +CRp$4.createGradientStyleFor = function (context, shapeStyleName, ele, fill, opacity) { + var gradientStyle; + var usePaths = this.usePaths(); + var colors = ele.pstyle(shapeStyleName + '-gradient-stop-colors').value, + positions = ele.pstyle(shapeStyleName + '-gradient-stop-positions').pfValue; + if (fill === 'radial-gradient') { + if (ele.isEdge()) { + var start = ele.sourceEndpoint(), + end = ele.targetEndpoint(), + mid = ele.midpoint(); + var d1 = dist(start, mid); + var d2 = dist(end, mid); + gradientStyle = context.createRadialGradient(mid.x, mid.y, 0, mid.x, mid.y, Math.max(d1, d2)); + } else { + var pos = usePaths ? { + x: 0, + y: 0 + } : ele.position(), + width = ele.paddedWidth(), + height = ele.paddedHeight(); + gradientStyle = context.createRadialGradient(pos.x, pos.y, 0, pos.x, pos.y, Math.max(width, height)); + } + } else { + if (ele.isEdge()) { + var _start = ele.sourceEndpoint(), + _end = ele.targetEndpoint(); + gradientStyle = context.createLinearGradient(_start.x, _start.y, _end.x, _end.y); + } else { + var _pos = usePaths ? { + x: 0, + y: 0 + } : ele.position(), + _width = ele.paddedWidth(), + _height = ele.paddedHeight(), + halfWidth = _width / 2, + halfHeight = _height / 2; + var direction = ele.pstyle('background-gradient-direction').value; + switch (direction) { + case 'to-bottom': + gradientStyle = context.createLinearGradient(_pos.x, _pos.y - halfHeight, _pos.x, _pos.y + halfHeight); + break; + case 'to-top': + gradientStyle = context.createLinearGradient(_pos.x, _pos.y + halfHeight, _pos.x, _pos.y - halfHeight); + break; + case 'to-left': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y, _pos.x - halfWidth, _pos.y); + break; + case 'to-right': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y, _pos.x + halfWidth, _pos.y); + break; + case 'to-bottom-right': + case 'to-right-bottom': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y - halfHeight, _pos.x + halfWidth, _pos.y + halfHeight); + break; + case 'to-top-right': + case 'to-right-top': + gradientStyle = context.createLinearGradient(_pos.x - halfWidth, _pos.y + halfHeight, _pos.x + halfWidth, _pos.y - halfHeight); + break; + case 'to-bottom-left': + case 'to-left-bottom': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y - halfHeight, _pos.x - halfWidth, _pos.y + halfHeight); + break; + case 'to-top-left': + case 'to-left-top': + gradientStyle = context.createLinearGradient(_pos.x + halfWidth, _pos.y + halfHeight, _pos.x - halfWidth, _pos.y - halfHeight); + break; + } + } + } + if (!gradientStyle) return null; // invalid gradient style + + var hasPositions = positions.length === colors.length; + var length = colors.length; + for (var i = 0; i < length; i++) { + gradientStyle.addColorStop(hasPositions ? positions[i] : i / (length - 1), 'rgba(' + colors[i][0] + ',' + colors[i][1] + ',' + colors[i][2] + ',' + opacity + ')'); + } + return gradientStyle; +}; +CRp$4.gradientFillStyle = function (context, ele, fill, opacity) { + var gradientStyle = this.createGradientStyleFor(context, 'background', ele, fill, opacity); + if (!gradientStyle) return null; // error + context.fillStyle = gradientStyle; +}; +CRp$4.colorFillStyle = function (context, r, g, b, a) { + context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + // turn off for now, seems context does its own caching + + // var cache = this.paintCache(context); + + // var fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + + // if( cache.fillStyle !== fillStyle ){ + // context.fillStyle = cache.fillStyle = fillStyle; + // } +}; + +CRp$4.eleFillStyle = function (context, ele, opacity) { + var backgroundFill = ele.pstyle('background-fill').value; + if (backgroundFill === 'linear-gradient' || backgroundFill === 'radial-gradient') { + this.gradientFillStyle(context, ele, backgroundFill, opacity); + } else { + var backgroundColor = ele.pstyle('background-color').value; + this.colorFillStyle(context, backgroundColor[0], backgroundColor[1], backgroundColor[2], opacity); + } +}; +CRp$4.gradientStrokeStyle = function (context, ele, fill, opacity) { + var gradientStyle = this.createGradientStyleFor(context, 'line', ele, fill, opacity); + if (!gradientStyle) return null; // error + context.strokeStyle = gradientStyle; +}; +CRp$4.colorStrokeStyle = function (context, r, g, b, a) { + context.strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + // turn off for now, seems context does its own caching + + // var cache = this.paintCache(context); + + // var strokeStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + + // if( cache.strokeStyle !== strokeStyle ){ + // context.strokeStyle = cache.strokeStyle = strokeStyle; + // } +}; + +CRp$4.eleStrokeStyle = function (context, ele, opacity) { + var lineFill = ele.pstyle('line-fill').value; + if (lineFill === 'linear-gradient' || lineFill === 'radial-gradient') { + this.gradientStrokeStyle(context, ele, lineFill, opacity); + } else { + var lineColor = ele.pstyle('line-color').value; + this.colorStrokeStyle(context, lineColor[0], lineColor[1], lineColor[2], opacity); + } +}; + +// Resize canvas +CRp$4.matchCanvasSize = function (container) { + var r = this; + var data = r.data; + var bb = r.findContainerClientCoords(); + var width = bb[2]; + var height = bb[3]; + var pixelRatio = r.getPixelRatio(); + var mbPxRatio = r.motionBlurPxRatio; + if (container === r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE] || container === r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG]) { + pixelRatio = mbPxRatio; + } + var canvasWidth = width * pixelRatio; + var canvasHeight = height * pixelRatio; + var canvas; + if (canvasWidth === r.canvasWidth && canvasHeight === r.canvasHeight) { + return; // save cycles if same + } + + r.fontCaches = null; // resizing resets the style + + var canvasContainer = data.canvasContainer; + canvasContainer.style.width = width + 'px'; + canvasContainer.style.height = height + 'px'; + for (var i = 0; i < r.CANVAS_LAYERS; i++) { + canvas = data.canvases[i]; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + } + for (var i = 0; i < r.BUFFER_COUNT; i++) { + canvas = data.bufferCanvases[i]; + canvas.width = canvasWidth; + canvas.height = canvasHeight; + canvas.style.width = width + 'px'; + canvas.style.height = height + 'px'; + } + r.textureMult = 1; + if (pixelRatio <= 1) { + canvas = data.bufferCanvases[r.TEXTURE_BUFFER]; + r.textureMult = 2; + canvas.width = canvasWidth * r.textureMult; + canvas.height = canvasHeight * r.textureMult; + } + r.canvasWidth = canvasWidth; + r.canvasHeight = canvasHeight; +}; +CRp$4.renderTo = function (cxt, zoom, pan, pxRatio) { + this.render({ + forcedContext: cxt, + forcedZoom: zoom, + forcedPan: pan, + drawAllLayers: true, + forcedPxRatio: pxRatio + }); +}; +CRp$4.render = function (options) { + options = options || staticEmptyObject(); + var forcedContext = options.forcedContext; + var drawAllLayers = options.drawAllLayers; + var drawOnlyNodeLayer = options.drawOnlyNodeLayer; + var forcedZoom = options.forcedZoom; + var forcedPan = options.forcedPan; + var r = this; + var pixelRatio = options.forcedPxRatio === undefined ? this.getPixelRatio() : options.forcedPxRatio; + var cy = r.cy; + var data = r.data; + var needDraw = data.canvasNeedsRedraw; + var textureDraw = r.textureOnViewport && !forcedContext && (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming); + var motionBlur = options.motionBlur !== undefined ? options.motionBlur : r.motionBlur; + var mbPxRatio = r.motionBlurPxRatio; + var hasCompoundNodes = cy.hasCompoundNodes(); + var inNodeDragGesture = r.hoverData.draggingEles; + var inBoxSelection = r.hoverData.selecting || r.touchData.selecting ? true : false; + motionBlur = motionBlur && !forcedContext && r.motionBlurEnabled && !inBoxSelection; + var motionBlurFadeEffect = motionBlur; + if (!forcedContext) { + if (r.prevPxRatio !== pixelRatio) { + r.invalidateContainerClientCoordsCache(); + r.matchCanvasSize(r.container); + r.redrawHint('eles', true); + r.redrawHint('drag', true); + } + r.prevPxRatio = pixelRatio; + } + if (!forcedContext && r.motionBlurTimeout) { + clearTimeout(r.motionBlurTimeout); + } + if (motionBlur) { + if (r.mbFrames == null) { + r.mbFrames = 0; + } + r.mbFrames++; + if (r.mbFrames < 3) { + // need several frames before even high quality motionblur + motionBlurFadeEffect = false; + } + + // go to lower quality blurry frames when several m/b frames have been rendered (avoids flashing) + if (r.mbFrames > r.minMbLowQualFrames) { + //r.fullQualityMb = false; + r.motionBlurPxRatio = r.mbPxRBlurry; + } + } + if (r.clearingMotionBlur) { + r.motionBlurPxRatio = 1; + } + + // b/c drawToContext() may be async w.r.t. redraw(), keep track of last texture frame + // because a rogue async texture frame would clear needDraw + if (r.textureDrawLastFrame && !textureDraw) { + needDraw[r.NODE] = true; + needDraw[r.SELECT_BOX] = true; + } + var style = cy.style(); + var zoom = cy.zoom(); + var effectiveZoom = forcedZoom !== undefined ? forcedZoom : zoom; + var pan = cy.pan(); + var effectivePan = { + x: pan.x, + y: pan.y + }; + var vp = { + zoom: zoom, + pan: { + x: pan.x, + y: pan.y + } + }; + var prevVp = r.prevViewport; + var viewportIsDiff = prevVp === undefined || vp.zoom !== prevVp.zoom || vp.pan.x !== prevVp.pan.x || vp.pan.y !== prevVp.pan.y; + + // we want the low quality motionblur only when the viewport is being manipulated etc (where it's not noticed) + if (!viewportIsDiff && !(inNodeDragGesture && !hasCompoundNodes)) { + r.motionBlurPxRatio = 1; + } + if (forcedPan) { + effectivePan = forcedPan; + } + + // apply pixel ratio + + effectiveZoom *= pixelRatio; + effectivePan.x *= pixelRatio; + effectivePan.y *= pixelRatio; + var eles = r.getCachedZSortedEles(); + function mbclear(context, x, y, w, h) { + var gco = context.globalCompositeOperation; + context.globalCompositeOperation = 'destination-out'; + r.colorFillStyle(context, 255, 255, 255, r.motionBlurTransparency); + context.fillRect(x, y, w, h); + context.globalCompositeOperation = gco; + } + function setContextTransform(context, clear) { + var ePan, eZoom, w, h; + if (!r.clearingMotionBlur && (context === data.bufferContexts[r.MOTIONBLUR_BUFFER_NODE] || context === data.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG])) { + ePan = { + x: pan.x * mbPxRatio, + y: pan.y * mbPxRatio + }; + eZoom = zoom * mbPxRatio; + w = r.canvasWidth * mbPxRatio; + h = r.canvasHeight * mbPxRatio; + } else { + ePan = effectivePan; + eZoom = effectiveZoom; + w = r.canvasWidth; + h = r.canvasHeight; + } + context.setTransform(1, 0, 0, 1, 0, 0); + if (clear === 'motionBlur') { + mbclear(context, 0, 0, w, h); + } else if (!forcedContext && (clear === undefined || clear)) { + context.clearRect(0, 0, w, h); + } + if (!drawAllLayers) { + context.translate(ePan.x, ePan.y); + context.scale(eZoom, eZoom); + } + if (forcedPan) { + context.translate(forcedPan.x, forcedPan.y); + } + if (forcedZoom) { + context.scale(forcedZoom, forcedZoom); + } + } + if (!textureDraw) { + r.textureDrawLastFrame = false; + } + if (textureDraw) { + r.textureDrawLastFrame = true; + if (!r.textureCache) { + r.textureCache = {}; + r.textureCache.bb = cy.mutableElements().boundingBox(); + r.textureCache.texture = r.data.bufferCanvases[r.TEXTURE_BUFFER]; + var cxt = r.data.bufferContexts[r.TEXTURE_BUFFER]; + cxt.setTransform(1, 0, 0, 1, 0, 0); + cxt.clearRect(0, 0, r.canvasWidth * r.textureMult, r.canvasHeight * r.textureMult); + r.render({ + forcedContext: cxt, + drawOnlyNodeLayer: true, + forcedPxRatio: pixelRatio * r.textureMult + }); + var vp = r.textureCache.viewport = { + zoom: cy.zoom(), + pan: cy.pan(), + width: r.canvasWidth, + height: r.canvasHeight + }; + vp.mpan = { + x: (0 - vp.pan.x) / vp.zoom, + y: (0 - vp.pan.y) / vp.zoom + }; + } + needDraw[r.DRAG] = false; + needDraw[r.NODE] = false; + var context = data.contexts[r.NODE]; + var texture = r.textureCache.texture; + var vp = r.textureCache.viewport; + context.setTransform(1, 0, 0, 1, 0, 0); + if (motionBlur) { + mbclear(context, 0, 0, vp.width, vp.height); + } else { + context.clearRect(0, 0, vp.width, vp.height); + } + var outsideBgColor = style.core('outside-texture-bg-color').value; + var outsideBgOpacity = style.core('outside-texture-bg-opacity').value; + r.colorFillStyle(context, outsideBgColor[0], outsideBgColor[1], outsideBgColor[2], outsideBgOpacity); + context.fillRect(0, 0, vp.width, vp.height); + var zoom = cy.zoom(); + setContextTransform(context, false); + context.clearRect(vp.mpan.x, vp.mpan.y, vp.width / vp.zoom / pixelRatio, vp.height / vp.zoom / pixelRatio); + context.drawImage(texture, vp.mpan.x, vp.mpan.y, vp.width / vp.zoom / pixelRatio, vp.height / vp.zoom / pixelRatio); + } else if (r.textureOnViewport && !forcedContext) { + // clear the cache since we don't need it + r.textureCache = null; + } + var extent = cy.extent(); + var vpManip = r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming || r.hoverData.draggingEles || r.cy.animated(); + var hideEdges = r.hideEdgesOnViewport && vpManip; + var needMbClear = []; + needMbClear[r.NODE] = !needDraw[r.NODE] && motionBlur && !r.clearedForMotionBlur[r.NODE] || r.clearingMotionBlur; + if (needMbClear[r.NODE]) { + r.clearedForMotionBlur[r.NODE] = true; + } + needMbClear[r.DRAG] = !needDraw[r.DRAG] && motionBlur && !r.clearedForMotionBlur[r.DRAG] || r.clearingMotionBlur; + if (needMbClear[r.DRAG]) { + r.clearedForMotionBlur[r.DRAG] = true; + } + if (needDraw[r.NODE] || drawAllLayers || drawOnlyNodeLayer || needMbClear[r.NODE]) { + var useBuffer = motionBlur && !needMbClear[r.NODE] && mbPxRatio !== 1; + var context = forcedContext || (useBuffer ? r.data.bufferContexts[r.MOTIONBLUR_BUFFER_NODE] : data.contexts[r.NODE]); + var clear = motionBlur && !useBuffer ? 'motionBlur' : undefined; + setContextTransform(context, clear); + if (hideEdges) { + r.drawCachedNodes(context, eles.nondrag, pixelRatio, extent); + } else { + r.drawLayeredElements(context, eles.nondrag, pixelRatio, extent); + } + if (r.debug) { + r.drawDebugPoints(context, eles.nondrag); + } + if (!drawAllLayers && !motionBlur) { + needDraw[r.NODE] = false; + } + } + if (!drawOnlyNodeLayer && (needDraw[r.DRAG] || drawAllLayers || needMbClear[r.DRAG])) { + var useBuffer = motionBlur && !needMbClear[r.DRAG] && mbPxRatio !== 1; + var context = forcedContext || (useBuffer ? r.data.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG] : data.contexts[r.DRAG]); + setContextTransform(context, motionBlur && !useBuffer ? 'motionBlur' : undefined); + if (hideEdges) { + r.drawCachedNodes(context, eles.drag, pixelRatio, extent); + } else { + r.drawCachedElements(context, eles.drag, pixelRatio, extent); + } + if (r.debug) { + r.drawDebugPoints(context, eles.drag); + } + if (!drawAllLayers && !motionBlur) { + needDraw[r.DRAG] = false; + } + } + if (r.showFps || !drawOnlyNodeLayer && needDraw[r.SELECT_BOX] && !drawAllLayers) { + var context = forcedContext || data.contexts[r.SELECT_BOX]; + setContextTransform(context); + if (r.selection[4] == 1 && (r.hoverData.selecting || r.touchData.selecting)) { + var zoom = r.cy.zoom(); + var borderWidth = style.core('selection-box-border-width').value / zoom; + context.lineWidth = borderWidth; + context.fillStyle = 'rgba(' + style.core('selection-box-color').value[0] + ',' + style.core('selection-box-color').value[1] + ',' + style.core('selection-box-color').value[2] + ',' + style.core('selection-box-opacity').value + ')'; + context.fillRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]); + if (borderWidth > 0) { + context.strokeStyle = 'rgba(' + style.core('selection-box-border-color').value[0] + ',' + style.core('selection-box-border-color').value[1] + ',' + style.core('selection-box-border-color').value[2] + ',' + style.core('selection-box-opacity').value + ')'; + context.strokeRect(r.selection[0], r.selection[1], r.selection[2] - r.selection[0], r.selection[3] - r.selection[1]); + } + } + if (data.bgActivePosistion && !r.hoverData.selecting) { + var zoom = r.cy.zoom(); + var pos = data.bgActivePosistion; + context.fillStyle = 'rgba(' + style.core('active-bg-color').value[0] + ',' + style.core('active-bg-color').value[1] + ',' + style.core('active-bg-color').value[2] + ',' + style.core('active-bg-opacity').value + ')'; + context.beginPath(); + context.arc(pos.x, pos.y, style.core('active-bg-size').pfValue / zoom, 0, 2 * Math.PI); + context.fill(); + } + var timeToRender = r.lastRedrawTime; + if (r.showFps && timeToRender) { + timeToRender = Math.round(timeToRender); + var fps = Math.round(1000 / timeToRender); + context.setTransform(1, 0, 0, 1, 0, 0); + context.fillStyle = 'rgba(255, 0, 0, 0.75)'; + context.strokeStyle = 'rgba(255, 0, 0, 0.75)'; + context.lineWidth = 1; + context.fillText('1 frame = ' + timeToRender + ' ms = ' + fps + ' fps', 0, 20); + var maxFps = 60; + context.strokeRect(0, 30, 250, 20); + context.fillRect(0, 30, 250 * Math.min(fps / maxFps, 1), 20); + } + if (!drawAllLayers) { + needDraw[r.SELECT_BOX] = false; + } + } + + // motionblur: blit rendered blurry frames + if (motionBlur && mbPxRatio !== 1) { + var cxtNode = data.contexts[r.NODE]; + var txtNode = r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE]; + var cxtDrag = data.contexts[r.DRAG]; + var txtDrag = r.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG]; + var drawMotionBlur = function drawMotionBlur(cxt, txt, needClear) { + cxt.setTransform(1, 0, 0, 1, 0, 0); + if (needClear || !motionBlurFadeEffect) { + cxt.clearRect(0, 0, r.canvasWidth, r.canvasHeight); + } else { + mbclear(cxt, 0, 0, r.canvasWidth, r.canvasHeight); + } + var pxr = mbPxRatio; + cxt.drawImage(txt, + // img + 0, 0, + // sx, sy + r.canvasWidth * pxr, r.canvasHeight * pxr, + // sw, sh + 0, 0, + // x, y + r.canvasWidth, r.canvasHeight // w, h + ); + }; + + if (needDraw[r.NODE] || needMbClear[r.NODE]) { + drawMotionBlur(cxtNode, txtNode, needMbClear[r.NODE]); + needDraw[r.NODE] = false; + } + if (needDraw[r.DRAG] || needMbClear[r.DRAG]) { + drawMotionBlur(cxtDrag, txtDrag, needMbClear[r.DRAG]); + needDraw[r.DRAG] = false; + } + } + r.prevViewport = vp; + if (r.clearingMotionBlur) { + r.clearingMotionBlur = false; + r.motionBlurCleared = true; + r.motionBlur = true; + } + if (motionBlur) { + r.motionBlurTimeout = setTimeout(function () { + r.motionBlurTimeout = null; + r.clearedForMotionBlur[r.NODE] = false; + r.clearedForMotionBlur[r.DRAG] = false; + r.motionBlur = false; + r.clearingMotionBlur = !textureDraw; + r.mbFrames = 0; + needDraw[r.NODE] = true; + needDraw[r.DRAG] = true; + r.redraw(); + }, motionBlurDelay); + } + if (!forcedContext) { + cy.emit('render'); + } +}; + +var CRp$3 = {}; + +// @O Polygon drawing +CRp$3.drawPolygonPath = function (context, x, y, width, height, points) { + var halfW = width / 2; + var halfH = height / 2; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(x + halfW * points[0], y + halfH * points[1]); + for (var i = 1; i < points.length / 2; i++) { + context.lineTo(x + halfW * points[i * 2], y + halfH * points[i * 2 + 1]); + } + context.closePath(); +}; +CRp$3.drawRoundPolygonPath = function (context, x, y, width, height, points, corners) { + corners.forEach(function (corner) { + return drawPreparedRoundCorner(context, corner); + }); + context.closePath(); +}; + +// Round rectangle drawing +CRp$3.drawRoundRectanglePath = function (context, x, y, width, height, radius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : Math.min(radius, halfHeight, halfWidth); + if (context.beginPath) { + context.beginPath(); + } + + // Start at top middle + context.moveTo(x, y - halfHeight); + // Arc from middle top to right side + context.arcTo(x + halfWidth, y - halfHeight, x + halfWidth, y, cornerRadius); + // Arc from right side to bottom + context.arcTo(x + halfWidth, y + halfHeight, x, y + halfHeight, cornerRadius); + // Arc from bottom to left side + context.arcTo(x - halfWidth, y + halfHeight, x - halfWidth, y, cornerRadius); + // Arc from left side to topBorder + context.arcTo(x - halfWidth, y - halfHeight, x, y - halfHeight, cornerRadius); + // Join line + context.lineTo(x, y - halfHeight); + context.closePath(); +}; +CRp$3.drawBottomRoundRectanglePath = function (context, x, y, width, height, radius) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerRadius = radius === 'auto' ? getRoundRectangleRadius(width, height) : radius; + if (context.beginPath) { + context.beginPath(); + } + + // Start at top middle + context.moveTo(x, y - halfHeight); + context.lineTo(x + halfWidth, y - halfHeight); + context.lineTo(x + halfWidth, y); + context.arcTo(x + halfWidth, y + halfHeight, x, y + halfHeight, cornerRadius); + context.arcTo(x - halfWidth, y + halfHeight, x - halfWidth, y, cornerRadius); + context.lineTo(x - halfWidth, y - halfHeight); + context.lineTo(x, y - halfHeight); + context.closePath(); +}; +CRp$3.drawCutRectanglePath = function (context, x, y, width, height, points, corners) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var cornerLength = corners === 'auto' ? getCutRectangleCornerLength() : corners; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(x - halfWidth + cornerLength, y - halfHeight); + context.lineTo(x + halfWidth - cornerLength, y - halfHeight); + context.lineTo(x + halfWidth, y - halfHeight + cornerLength); + context.lineTo(x + halfWidth, y + halfHeight - cornerLength); + context.lineTo(x + halfWidth - cornerLength, y + halfHeight); + context.lineTo(x - halfWidth + cornerLength, y + halfHeight); + context.lineTo(x - halfWidth, y + halfHeight - cornerLength); + context.lineTo(x - halfWidth, y - halfHeight + cornerLength); + context.closePath(); +}; +CRp$3.drawBarrelPath = function (context, x, y, width, height) { + var halfWidth = width / 2; + var halfHeight = height / 2; + var xBegin = x - halfWidth; + var xEnd = x + halfWidth; + var yBegin = y - halfHeight; + var yEnd = y + halfHeight; + var barrelCurveConstants = getBarrelCurveConstants(width, height); + var wOffset = barrelCurveConstants.widthOffset; + var hOffset = barrelCurveConstants.heightOffset; + var ctrlPtXOffset = barrelCurveConstants.ctrlPtOffsetPct * wOffset; + if (context.beginPath) { + context.beginPath(); + } + context.moveTo(xBegin, yBegin + hOffset); + context.lineTo(xBegin, yEnd - hOffset); + context.quadraticCurveTo(xBegin + ctrlPtXOffset, yEnd, xBegin + wOffset, yEnd); + context.lineTo(xEnd - wOffset, yEnd); + context.quadraticCurveTo(xEnd - ctrlPtXOffset, yEnd, xEnd, yEnd - hOffset); + context.lineTo(xEnd, yBegin + hOffset); + context.quadraticCurveTo(xEnd - ctrlPtXOffset, yBegin, xEnd - wOffset, yBegin); + context.lineTo(xBegin + wOffset, yBegin); + context.quadraticCurveTo(xBegin + ctrlPtXOffset, yBegin, xBegin, yBegin + hOffset); + context.closePath(); +}; +var sin0 = Math.sin(0); +var cos0 = Math.cos(0); +var sin = {}; +var cos = {}; +var ellipseStepSize = Math.PI / 40; +for (var i = 0 * Math.PI; i < 2 * Math.PI; i += ellipseStepSize) { + sin[i] = Math.sin(i); + cos[i] = Math.cos(i); +} +CRp$3.drawEllipsePath = function (context, centerX, centerY, width, height) { + if (context.beginPath) { + context.beginPath(); + } + if (context.ellipse) { + context.ellipse(centerX, centerY, width / 2, height / 2, 0, 0, 2 * Math.PI); + } else { + var xPos, yPos; + var rw = width / 2; + var rh = height / 2; + for (var i = 0 * Math.PI; i < 2 * Math.PI; i += ellipseStepSize) { + xPos = centerX - rw * sin[i] * sin0 + rw * cos[i] * cos0; + yPos = centerY + rh * cos[i] * sin0 + rh * sin[i] * cos0; + if (i === 0) { + context.moveTo(xPos, yPos); + } else { + context.lineTo(xPos, yPos); + } + } + } + context.closePath(); +}; + +/* global atob, ArrayBuffer, Uint8Array, Blob */ +var CRp$2 = {}; +CRp$2.createBuffer = function (w, h) { + var buffer = document.createElement('canvas'); // eslint-disable-line no-undef + buffer.width = w; + buffer.height = h; + return [buffer, buffer.getContext('2d')]; +}; +CRp$2.bufferCanvasImage = function (options) { + var cy = this.cy; + var eles = cy.mutableElements(); + var bb = eles.boundingBox(); + var ctrRect = this.findContainerClientCoords(); + var width = options.full ? Math.ceil(bb.w) : ctrRect[2]; + var height = options.full ? Math.ceil(bb.h) : ctrRect[3]; + var specdMaxDims = number$1(options.maxWidth) || number$1(options.maxHeight); + var pxRatio = this.getPixelRatio(); + var scale = 1; + if (options.scale !== undefined) { + width *= options.scale; + height *= options.scale; + scale = options.scale; + } else if (specdMaxDims) { + var maxScaleW = Infinity; + var maxScaleH = Infinity; + if (number$1(options.maxWidth)) { + maxScaleW = scale * options.maxWidth / width; + } + if (number$1(options.maxHeight)) { + maxScaleH = scale * options.maxHeight / height; + } + scale = Math.min(maxScaleW, maxScaleH); + width *= scale; + height *= scale; + } + if (!specdMaxDims) { + width *= pxRatio; + height *= pxRatio; + scale *= pxRatio; + } + var buffCanvas = document.createElement('canvas'); // eslint-disable-line no-undef + + buffCanvas.width = width; + buffCanvas.height = height; + buffCanvas.style.width = width + 'px'; + buffCanvas.style.height = height + 'px'; + var buffCxt = buffCanvas.getContext('2d'); + + // Rasterize the layers, but only if container has nonzero size + if (width > 0 && height > 0) { + buffCxt.clearRect(0, 0, width, height); + buffCxt.globalCompositeOperation = 'source-over'; + var zsortedEles = this.getCachedZSortedEles(); + if (options.full) { + // draw the full bounds of the graph + buffCxt.translate(-bb.x1 * scale, -bb.y1 * scale); + buffCxt.scale(scale, scale); + this.drawElements(buffCxt, zsortedEles); + buffCxt.scale(1 / scale, 1 / scale); + buffCxt.translate(bb.x1 * scale, bb.y1 * scale); + } else { + // draw the current view + var pan = cy.pan(); + var translation = { + x: pan.x * scale, + y: pan.y * scale + }; + scale *= cy.zoom(); + buffCxt.translate(translation.x, translation.y); + buffCxt.scale(scale, scale); + this.drawElements(buffCxt, zsortedEles); + buffCxt.scale(1 / scale, 1 / scale); + buffCxt.translate(-translation.x, -translation.y); + } + + // need to fill bg at end like this in order to fill cleared transparent pixels in jpgs + if (options.bg) { + buffCxt.globalCompositeOperation = 'destination-over'; + buffCxt.fillStyle = options.bg; + buffCxt.rect(0, 0, width, height); + buffCxt.fill(); + } + } + return buffCanvas; +}; +function b64ToBlob(b64, mimeType) { + var bytes = atob(b64); + var buff = new ArrayBuffer(bytes.length); + var buffUint8 = new Uint8Array(buff); + for (var i = 0; i < bytes.length; i++) { + buffUint8[i] = bytes.charCodeAt(i); + } + return new Blob([buff], { + type: mimeType + }); +} +function b64UriToB64(b64uri) { + var i = b64uri.indexOf(','); + return b64uri.substr(i + 1); +} +function output(options, canvas, mimeType) { + var getB64Uri = function getB64Uri() { + return canvas.toDataURL(mimeType, options.quality); + }; + switch (options.output) { + case 'blob-promise': + return new Promise$1(function (resolve, reject) { + try { + canvas.toBlob(function (blob) { + if (blob != null) { + resolve(blob); + } else { + reject(new Error('`canvas.toBlob()` sent a null value in its callback')); + } + }, mimeType, options.quality); + } catch (err) { + reject(err); + } + }); + case 'blob': + return b64ToBlob(b64UriToB64(getB64Uri()), mimeType); + case 'base64': + return b64UriToB64(getB64Uri()); + case 'base64uri': + default: + return getB64Uri(); + } +} +CRp$2.png = function (options) { + return output(options, this.bufferCanvasImage(options), 'image/png'); +}; +CRp$2.jpg = function (options) { + return output(options, this.bufferCanvasImage(options), 'image/jpeg'); +}; + +var CRp$1 = {}; +CRp$1.nodeShapeImpl = function (name, context, centerX, centerY, width, height, points, corners) { + switch (name) { + case 'ellipse': + return this.drawEllipsePath(context, centerX, centerY, width, height); + case 'polygon': + return this.drawPolygonPath(context, centerX, centerY, width, height, points); + case 'round-polygon': + return this.drawRoundPolygonPath(context, centerX, centerY, width, height, points, corners); + case 'roundrectangle': + case 'round-rectangle': + return this.drawRoundRectanglePath(context, centerX, centerY, width, height, corners); + case 'cutrectangle': + case 'cut-rectangle': + return this.drawCutRectanglePath(context, centerX, centerY, width, height, points, corners); + case 'bottomroundrectangle': + case 'bottom-round-rectangle': + return this.drawBottomRoundRectanglePath(context, centerX, centerY, width, height, corners); + case 'barrel': + return this.drawBarrelPath(context, centerX, centerY, width, height); + } +}; + +var CR = CanvasRenderer; +var CRp = CanvasRenderer.prototype; +CRp.CANVAS_LAYERS = 3; +// +CRp.SELECT_BOX = 0; +CRp.DRAG = 1; +CRp.NODE = 2; +CRp.BUFFER_COUNT = 3; +// +CRp.TEXTURE_BUFFER = 0; +CRp.MOTIONBLUR_BUFFER_NODE = 1; +CRp.MOTIONBLUR_BUFFER_DRAG = 2; +function CanvasRenderer(options) { + var r = this; + r.data = { + canvases: new Array(CRp.CANVAS_LAYERS), + contexts: new Array(CRp.CANVAS_LAYERS), + canvasNeedsRedraw: new Array(CRp.CANVAS_LAYERS), + bufferCanvases: new Array(CRp.BUFFER_COUNT), + bufferContexts: new Array(CRp.CANVAS_LAYERS) + }; + var tapHlOffAttr = '-webkit-tap-highlight-color'; + var tapHlOffStyle = 'rgba(0,0,0,0)'; + r.data.canvasContainer = document.createElement('div'); // eslint-disable-line no-undef + var containerStyle = r.data.canvasContainer.style; + r.data.canvasContainer.style[tapHlOffAttr] = tapHlOffStyle; + containerStyle.position = 'relative'; + containerStyle.zIndex = '0'; + containerStyle.overflow = 'hidden'; + var container = options.cy.container(); + container.appendChild(r.data.canvasContainer); + container.style[tapHlOffAttr] = tapHlOffStyle; + var styleMap = { + '-webkit-user-select': 'none', + '-moz-user-select': '-moz-none', + 'user-select': 'none', + '-webkit-tap-highlight-color': 'rgba(0,0,0,0)', + 'outline-style': 'none' + }; + if (ms()) { + styleMap['-ms-touch-action'] = 'none'; + styleMap['touch-action'] = 'none'; + } + for (var i = 0; i < CRp.CANVAS_LAYERS; i++) { + var canvas = r.data.canvases[i] = document.createElement('canvas'); // eslint-disable-line no-undef + r.data.contexts[i] = canvas.getContext('2d'); + Object.keys(styleMap).forEach(function (k) { + canvas.style[k] = styleMap[k]; + }); + canvas.style.position = 'absolute'; + canvas.setAttribute('data-id', 'layer' + i); + canvas.style.zIndex = String(CRp.CANVAS_LAYERS - i); + r.data.canvasContainer.appendChild(canvas); + r.data.canvasNeedsRedraw[i] = false; + } + r.data.topCanvas = r.data.canvases[0]; + r.data.canvases[CRp.NODE].setAttribute('data-id', 'layer' + CRp.NODE + '-node'); + r.data.canvases[CRp.SELECT_BOX].setAttribute('data-id', 'layer' + CRp.SELECT_BOX + '-selectbox'); + r.data.canvases[CRp.DRAG].setAttribute('data-id', 'layer' + CRp.DRAG + '-drag'); + for (var i = 0; i < CRp.BUFFER_COUNT; i++) { + r.data.bufferCanvases[i] = document.createElement('canvas'); // eslint-disable-line no-undef + r.data.bufferContexts[i] = r.data.bufferCanvases[i].getContext('2d'); + r.data.bufferCanvases[i].style.position = 'absolute'; + r.data.bufferCanvases[i].setAttribute('data-id', 'buffer' + i); + r.data.bufferCanvases[i].style.zIndex = String(-i - 1); + r.data.bufferCanvases[i].style.visibility = 'hidden'; + //r.data.canvasContainer.appendChild(r.data.bufferCanvases[i]); + } + + r.pathsEnabled = true; + var emptyBb = makeBoundingBox(); + var getBoxCenter = function getBoxCenter(bb) { + return { + x: (bb.x1 + bb.x2) / 2, + y: (bb.y1 + bb.y2) / 2 + }; + }; + var getCenterOffset = function getCenterOffset(bb) { + return { + x: -bb.w / 2, + y: -bb.h / 2 + }; + }; + var backgroundTimestampHasChanged = function backgroundTimestampHasChanged(ele) { + var _p = ele[0]._private; + var same = _p.oldBackgroundTimestamp === _p.backgroundTimestamp; + return !same; + }; + var getStyleKey = function getStyleKey(ele) { + return ele[0]._private.nodeKey; + }; + var getLabelKey = function getLabelKey(ele) { + return ele[0]._private.labelStyleKey; + }; + var getSourceLabelKey = function getSourceLabelKey(ele) { + return ele[0]._private.sourceLabelStyleKey; + }; + var getTargetLabelKey = function getTargetLabelKey(ele) { + return ele[0]._private.targetLabelStyleKey; + }; + var drawElement = function drawElement(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElement(context, ele, bb, false, false, useEleOpacity); + }; + var drawLabel = function drawLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'main', useEleOpacity); + }; + var drawSourceLabel = function drawSourceLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'source', useEleOpacity); + }; + var drawTargetLabel = function drawTargetLabel(context, ele, bb, scaledLabelShown, useEleOpacity) { + return r.drawElementText(context, ele, bb, scaledLabelShown, 'target', useEleOpacity); + }; + var getElementBox = function getElementBox(ele) { + ele.boundingBox(); + return ele[0]._private.bodyBounds; + }; + var getLabelBox = function getLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.main || emptyBb; + }; + var getSourceLabelBox = function getSourceLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.source || emptyBb; + }; + var getTargetLabelBox = function getTargetLabelBox(ele) { + ele.boundingBox(); + return ele[0]._private.labelBounds.target || emptyBb; + }; + var isLabelVisibleAtScale = function isLabelVisibleAtScale(ele, scaledLabelShown) { + return scaledLabelShown; + }; + var getElementRotationPoint = function getElementRotationPoint(ele) { + return getBoxCenter(getElementBox(ele)); + }; + var addTextMargin = function addTextMargin(prefix, pt, ele) { + var pre = prefix ? prefix + '-' : ''; + return { + x: pt.x + ele.pstyle(pre + 'text-margin-x').pfValue, + y: pt.y + ele.pstyle(pre + 'text-margin-y').pfValue + }; + }; + var getRsPt = function getRsPt(ele, x, y) { + var rs = ele[0]._private.rscratch; + return { + x: rs[x], + y: rs[y] + }; + }; + var getLabelRotationPoint = function getLabelRotationPoint(ele) { + return addTextMargin('', getRsPt(ele, 'labelX', 'labelY'), ele); + }; + var getSourceLabelRotationPoint = function getSourceLabelRotationPoint(ele) { + return addTextMargin('source', getRsPt(ele, 'sourceLabelX', 'sourceLabelY'), ele); + }; + var getTargetLabelRotationPoint = function getTargetLabelRotationPoint(ele) { + return addTextMargin('target', getRsPt(ele, 'targetLabelX', 'targetLabelY'), ele); + }; + var getElementRotationOffset = function getElementRotationOffset(ele) { + return getCenterOffset(getElementBox(ele)); + }; + var getSourceLabelRotationOffset = function getSourceLabelRotationOffset(ele) { + return getCenterOffset(getSourceLabelBox(ele)); + }; + var getTargetLabelRotationOffset = function getTargetLabelRotationOffset(ele) { + return getCenterOffset(getTargetLabelBox(ele)); + }; + var getLabelRotationOffset = function getLabelRotationOffset(ele) { + var bb = getLabelBox(ele); + var p = getCenterOffset(getLabelBox(ele)); + if (ele.isNode()) { + switch (ele.pstyle('text-halign').value) { + case 'left': + p.x = -bb.w; + break; + case 'right': + p.x = 0; + break; + } + switch (ele.pstyle('text-valign').value) { + case 'top': + p.y = -bb.h; + break; + case 'bottom': + p.y = 0; + break; + } + } + return p; + }; + var eleTxrCache = r.data.eleTxrCache = new ElementTextureCache(r, { + getKey: getStyleKey, + doesEleInvalidateKey: backgroundTimestampHasChanged, + drawElement: drawElement, + getBoundingBox: getElementBox, + getRotationPoint: getElementRotationPoint, + getRotationOffset: getElementRotationOffset, + allowEdgeTxrCaching: false, + allowParentTxrCaching: false + }); + var lblTxrCache = r.data.lblTxrCache = new ElementTextureCache(r, { + getKey: getLabelKey, + drawElement: drawLabel, + getBoundingBox: getLabelBox, + getRotationPoint: getLabelRotationPoint, + getRotationOffset: getLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var slbTxrCache = r.data.slbTxrCache = new ElementTextureCache(r, { + getKey: getSourceLabelKey, + drawElement: drawSourceLabel, + getBoundingBox: getSourceLabelBox, + getRotationPoint: getSourceLabelRotationPoint, + getRotationOffset: getSourceLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var tlbTxrCache = r.data.tlbTxrCache = new ElementTextureCache(r, { + getKey: getTargetLabelKey, + drawElement: drawTargetLabel, + getBoundingBox: getTargetLabelBox, + getRotationPoint: getTargetLabelRotationPoint, + getRotationOffset: getTargetLabelRotationOffset, + isVisible: isLabelVisibleAtScale + }); + var lyrTxrCache = r.data.lyrTxrCache = new LayeredTextureCache(r); + r.onUpdateEleCalcs(function invalidateTextureCaches(willDraw, eles) { + // each cache should check for sub-key diff to see that the update affects that cache particularly + eleTxrCache.invalidateElements(eles); + lblTxrCache.invalidateElements(eles); + slbTxrCache.invalidateElements(eles); + tlbTxrCache.invalidateElements(eles); + + // any change invalidates the layers + lyrTxrCache.invalidateElements(eles); + + // update the old bg timestamp so diffs can be done in the ele txr caches + for (var _i = 0; _i < eles.length; _i++) { + var _p = eles[_i]._private; + _p.oldBackgroundTimestamp = _p.backgroundTimestamp; + } + }); + var refineInLayers = function refineInLayers(reqs) { + for (var i = 0; i < reqs.length; i++) { + lyrTxrCache.enqueueElementRefinement(reqs[i].ele); + } + }; + eleTxrCache.onDequeue(refineInLayers); + lblTxrCache.onDequeue(refineInLayers); + slbTxrCache.onDequeue(refineInLayers); + tlbTxrCache.onDequeue(refineInLayers); +} +CRp.redrawHint = function (group, bool) { + var r = this; + switch (group) { + case 'eles': + r.data.canvasNeedsRedraw[CRp.NODE] = bool; + break; + case 'drag': + r.data.canvasNeedsRedraw[CRp.DRAG] = bool; + break; + case 'select': + r.data.canvasNeedsRedraw[CRp.SELECT_BOX] = bool; + break; + } +}; + +// whether to use Path2D caching for drawing +var pathsImpld = typeof Path2D !== 'undefined'; +CRp.path2dEnabled = function (on) { + if (on === undefined) { + return this.pathsEnabled; + } + this.pathsEnabled = on ? true : false; +}; +CRp.usePaths = function () { + return pathsImpld && this.pathsEnabled; +}; +CRp.setImgSmoothing = function (context, bool) { + if (context.imageSmoothingEnabled != null) { + context.imageSmoothingEnabled = bool; + } else { + context.webkitImageSmoothingEnabled = bool; + context.mozImageSmoothingEnabled = bool; + context.msImageSmoothingEnabled = bool; + } +}; +CRp.getImgSmoothing = function (context) { + if (context.imageSmoothingEnabled != null) { + return context.imageSmoothingEnabled; + } else { + return context.webkitImageSmoothingEnabled || context.mozImageSmoothingEnabled || context.msImageSmoothingEnabled; + } +}; +CRp.makeOffscreenCanvas = function (width, height) { + var canvas; + if ((typeof OffscreenCanvas === "undefined" ? "undefined" : _typeof(OffscreenCanvas)) !== ("undefined" )) { + canvas = new OffscreenCanvas(width, height); + } else { + canvas = document.createElement('canvas'); // eslint-disable-line no-undef + canvas.width = width; + canvas.height = height; + } + return canvas; +}; +[CRp$a, CRp$9, CRp$8, CRp$7, CRp$6, CRp$5, CRp$4, CRp$3, CRp$2, CRp$1].forEach(function (props) { + extend(CRp, props); +}); + +var renderer$1 = [{ + name: 'null', + impl: NullRenderer +}, { + name: 'base', + impl: BR +}, { + name: 'canvas', + impl: CR +}]; + +var incExts = [{ + type: 'layout', + extensions: layout +}, { + type: 'renderer', + extensions: renderer$1 +}]; + +// registered extensions to cytoscape, indexed by name +var extensions = {}; + +// registered modules for extensions, indexed by name +var modules = {}; +function setExtension(type, name, registrant) { + var ext = registrant; + var overrideErr = function overrideErr(field) { + warn('Can not register `' + name + '` for `' + type + '` since `' + field + '` already exists in the prototype and can not be overridden'); + }; + if (type === 'core') { + if (Core.prototype[name]) { + return overrideErr(name); + } else { + Core.prototype[name] = registrant; + } + } else if (type === 'collection') { + if (Collection.prototype[name]) { + return overrideErr(name); + } else { + Collection.prototype[name] = registrant; + } + } else if (type === 'layout') { + // fill in missing layout functions in the prototype + + var Layout = function Layout(options) { + this.options = options; + registrant.call(this, options); + + // make sure layout has _private for use w/ std apis like .on() + if (!plainObject(this._private)) { + this._private = {}; + } + this._private.cy = options.cy; + this._private.listeners = []; + this.createEmitter(); + }; + var layoutProto = Layout.prototype = Object.create(registrant.prototype); + var optLayoutFns = []; + for (var i = 0; i < optLayoutFns.length; i++) { + var fnName = optLayoutFns[i]; + layoutProto[fnName] = layoutProto[fnName] || function () { + return this; + }; + } + + // either .start() or .run() is defined, so autogen the other + if (layoutProto.start && !layoutProto.run) { + layoutProto.run = function () { + this.start(); + return this; + }; + } else if (!layoutProto.start && layoutProto.run) { + layoutProto.start = function () { + this.run(); + return this; + }; + } + var regStop = registrant.prototype.stop; + layoutProto.stop = function () { + var opts = this.options; + if (opts && opts.animate) { + var anis = this.animations; + if (anis) { + for (var _i = 0; _i < anis.length; _i++) { + anis[_i].stop(); + } + } + } + if (regStop) { + regStop.call(this); + } else { + this.emit('layoutstop'); + } + return this; + }; + if (!layoutProto.destroy) { + layoutProto.destroy = function () { + return this; + }; + } + layoutProto.cy = function () { + return this._private.cy; + }; + var getCy = function getCy(layout) { + return layout._private.cy; + }; + var emitterOpts = { + addEventFields: function addEventFields(layout, evt) { + evt.layout = layout; + evt.cy = getCy(layout); + evt.target = layout; + }, + bubble: function bubble() { + return true; + }, + parent: function parent(layout) { + return getCy(layout); + } + }; + extend(layoutProto, { + createEmitter: function createEmitter() { + this._private.emitter = new Emitter(emitterOpts, this); + return this; + }, + emitter: function emitter() { + return this._private.emitter; + }, + on: function on(evt, cb) { + this.emitter().on(evt, cb); + return this; + }, + one: function one(evt, cb) { + this.emitter().one(evt, cb); + return this; + }, + once: function once(evt, cb) { + this.emitter().one(evt, cb); + return this; + }, + removeListener: function removeListener(evt, cb) { + this.emitter().removeListener(evt, cb); + return this; + }, + removeAllListeners: function removeAllListeners() { + this.emitter().removeAllListeners(); + return this; + }, + emit: function emit(evt, params) { + this.emitter().emit(evt, params); + return this; + } + }); + define.eventAliasesOn(layoutProto); + ext = Layout; // replace with our wrapped layout + } else if (type === 'renderer' && name !== 'null' && name !== 'base') { + // user registered renderers inherit from base + + var BaseRenderer = getExtension('renderer', 'base'); + var bProto = BaseRenderer.prototype; + var RegistrantRenderer = registrant; + var rProto = registrant.prototype; + var Renderer = function Renderer() { + BaseRenderer.apply(this, arguments); + RegistrantRenderer.apply(this, arguments); + }; + var proto = Renderer.prototype; + for (var pName in bProto) { + var pVal = bProto[pName]; + var existsInR = rProto[pName] != null; + if (existsInR) { + return overrideErr(pName); + } + proto[pName] = pVal; // take impl from base + } + + for (var _pName in rProto) { + proto[_pName] = rProto[_pName]; // take impl from registrant + } + + bProto.clientFunctions.forEach(function (name) { + proto[name] = proto[name] || function () { + error('Renderer does not implement `renderer.' + name + '()` on its prototype'); + }; + }); + ext = Renderer; + } else if (type === '__proto__' || type === 'constructor' || type === 'prototype') { + // to avoid potential prototype pollution + return error(type + ' is an illegal type to be registered, possibly lead to prototype pollutions'); + } + return setMap({ + map: extensions, + keys: [type, name], + value: ext + }); +} +function getExtension(type, name) { + return getMap({ + map: extensions, + keys: [type, name] + }); +} +function setModule(type, name, moduleType, moduleName, registrant) { + return setMap({ + map: modules, + keys: [type, name, moduleType, moduleName], + value: registrant + }); +} +function getModule(type, name, moduleType, moduleName) { + return getMap({ + map: modules, + keys: [type, name, moduleType, moduleName] + }); +} +var extension = function extension() { + // e.g. extension('renderer', 'svg') + if (arguments.length === 2) { + return getExtension.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', { ... }) + else if (arguments.length === 3) { + return setExtension.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', 'nodeShape', 'ellipse') + else if (arguments.length === 4) { + return getModule.apply(null, arguments); + } + + // e.g. extension('renderer', 'svg', 'nodeShape', 'ellipse', { ... }) + else if (arguments.length === 5) { + return setModule.apply(null, arguments); + } else { + error('Invalid extension access syntax'); + } +}; + +// allows a core instance to access extensions internally +Core.prototype.extension = extension; + +// included extensions +incExts.forEach(function (group) { + group.extensions.forEach(function (ext) { + setExtension(group.type, ext.name, ext.impl); + }); +}); + +// a dummy stylesheet object that doesn't need a reference to the core +// (useful for init) +var Stylesheet = function Stylesheet() { + if (!(this instanceof Stylesheet)) { + return new Stylesheet(); + } + this.length = 0; +}; +var sheetfn = Stylesheet.prototype; +sheetfn.instanceString = function () { + return 'stylesheet'; +}; + +// just store the selector to be parsed later +sheetfn.selector = function (selector) { + var i = this.length++; + this[i] = { + selector: selector, + properties: [] + }; + return this; // chaining +}; + +// just store the property to be parsed later +sheetfn.css = function (name, value) { + var i = this.length - 1; + if (string(name)) { + this[i].properties.push({ + name: name, + value: value + }); + } else if (plainObject(name)) { + var map = name; + var propNames = Object.keys(map); + for (var j = 0; j < propNames.length; j++) { + var key = propNames[j]; + var mapVal = map[key]; + if (mapVal == null) { + continue; + } + var prop = Style.properties[key] || Style.properties[dash2camel(key)]; + if (prop == null) { + continue; + } + var _name = prop.name; + var _value = mapVal; + this[i].properties.push({ + name: _name, + value: _value + }); + } + } + return this; // chaining +}; + +sheetfn.style = sheetfn.css; + +// generate a real style object from the dummy stylesheet +sheetfn.generateStyle = function (cy) { + var style = new Style(cy); + return this.appendToStyle(style); +}; + +// append a dummy stylesheet object on a real style object +sheetfn.appendToStyle = function (style) { + for (var i = 0; i < this.length; i++) { + var context = this[i]; + var selector = context.selector; + var props = context.properties; + style.selector(selector); // apply selector + + for (var j = 0; j < props.length; j++) { + var prop = props[j]; + style.css(prop.name, prop.value); // apply property + } + } + + return style; +}; + +var version = "3.29.2"; + +var cytoscape$1 = function cytoscape(options) { + // if no options specified, use default + if (options === undefined) { + options = {}; + } + + // create instance + if (plainObject(options)) { + return new Core(options); + } + + // allow for registration of extensions + else if (string(options)) { + return extension.apply(extension, arguments); + } +}; + +// e.g. cytoscape.use( require('cytoscape-foo'), bar ) +cytoscape$1.use = function (ext) { + var args = Array.prototype.slice.call(arguments, 1); // args to pass to ext + + args.unshift(cytoscape$1); // cytoscape is first arg to ext + + ext.apply(null, args); + return this; +}; +cytoscape$1.warnings = function (bool) { + return warnings(bool); +}; + +// replaced by build system +cytoscape$1.version = version; + +// expose public apis (mostly for extensions) +cytoscape$1.stylesheet = cytoscape$1.Stylesheet = Stylesheet; + +var cytoscapeCoseBilkent = {exports: {}}; + +var coseBase = {exports: {}}; + +var layoutBase = {exports: {}}; + +var hasRequiredLayoutBase; + +function requireLayoutBase () { + if (hasRequiredLayoutBase) return layoutBase.exports; + hasRequiredLayoutBase = 1; + (function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(); + })(commonjsGlobal$1, function() { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 26); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports, __webpack_require__) { + + + function LayoutConstants() {} + + /** + * Layout Quality: 0:draft, 1:default, 2:proof + */ + LayoutConstants.QUALITY = 1; + + /** + * Default parameters + */ + LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false; + LayoutConstants.DEFAULT_INCREMENTAL = false; + LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT = true; + LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT = false; + LayoutConstants.DEFAULT_ANIMATION_PERIOD = 50; + LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false; + + // ----------------------------------------------------------------------------- + // Section: General other constants + // ----------------------------------------------------------------------------- + /* + * Margins of a graph to be applied on bouding rectangle of its contents. We + * assume margins on all four sides to be uniform. + */ + LayoutConstants.DEFAULT_GRAPH_MARGIN = 15; + + /* + * Whether to consider labels in node dimensions or not + */ + LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false; + + /* + * Default dimension of a non-compound node. + */ + LayoutConstants.SIMPLE_NODE_SIZE = 40; + + /* + * Default dimension of a non-compound node. + */ + LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2; + + /* + * Empty compound node size. When a compound node is empty, its both + * dimensions should be of this value. + */ + LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40; + + /* + * Minimum length that an edge should take during layout + */ + LayoutConstants.MIN_EDGE_LENGTH = 1; + + /* + * World boundaries that layout operates on + */ + LayoutConstants.WORLD_BOUNDARY = 1000000; + + /* + * World boundaries that random positioning can be performed with + */ + LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000; + + /* + * Coordinates of the world center + */ + LayoutConstants.WORLD_CENTER_X = 1200; + LayoutConstants.WORLD_CENTER_Y = 900; + + module.exports = LayoutConstants; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var IGeometry = __webpack_require__(8); + var IMath = __webpack_require__(9); + + function LEdge(source, target, vEdge) { + LGraphObject.call(this, vEdge); + + this.isOverlapingSourceAndTarget = false; + this.vGraphObject = vEdge; + this.bendpoints = []; + this.source = source; + this.target = target; + } + + LEdge.prototype = Object.create(LGraphObject.prototype); + + for (var prop in LGraphObject) { + LEdge[prop] = LGraphObject[prop]; + } + + LEdge.prototype.getSource = function () { + return this.source; + }; + + LEdge.prototype.getTarget = function () { + return this.target; + }; + + LEdge.prototype.isInterGraph = function () { + return this.isInterGraph; + }; + + LEdge.prototype.getLength = function () { + return this.length; + }; + + LEdge.prototype.isOverlapingSourceAndTarget = function () { + return this.isOverlapingSourceAndTarget; + }; + + LEdge.prototype.getBendpoints = function () { + return this.bendpoints; + }; + + LEdge.prototype.getLca = function () { + return this.lca; + }; + + LEdge.prototype.getSourceInLca = function () { + return this.sourceInLca; + }; + + LEdge.prototype.getTargetInLca = function () { + return this.targetInLca; + }; + + LEdge.prototype.getOtherEnd = function (node) { + if (this.source === node) { + return this.target; + } else if (this.target === node) { + return this.source; + } else { + throw "Node is not incident with this edge"; + } + }; + + LEdge.prototype.getOtherEndInGraph = function (node, graph) { + var otherEnd = this.getOtherEnd(node); + var root = graph.getGraphManager().getRoot(); + + while (true) { + if (otherEnd.getOwner() == graph) { + return otherEnd; + } + + if (otherEnd.getOwner() == root) { + break; + } + + otherEnd = otherEnd.getOwner().getParent(); + } + + return null; + }; + + LEdge.prototype.updateLength = function () { + var clipPointCoordinates = new Array(4); + + this.isOverlapingSourceAndTarget = IGeometry.getIntersection(this.target.getRect(), this.source.getRect(), clipPointCoordinates); + + if (!this.isOverlapingSourceAndTarget) { + this.lengthX = clipPointCoordinates[0] - clipPointCoordinates[2]; + this.lengthY = clipPointCoordinates[1] - clipPointCoordinates[3]; + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + } + }; + + LEdge.prototype.updateLengthSimple = function () { + this.lengthX = this.target.getCenterX() - this.source.getCenterX(); + this.lengthY = this.target.getCenterY() - this.source.getCenterY(); + + if (Math.abs(this.lengthX) < 1.0) { + this.lengthX = IMath.sign(this.lengthX); + } + + if (Math.abs(this.lengthY) < 1.0) { + this.lengthY = IMath.sign(this.lengthY); + } + + this.length = Math.sqrt(this.lengthX * this.lengthX + this.lengthY * this.lengthY); + }; + + module.exports = LEdge; + + /***/ }), + /* 2 */ + /***/ (function(module, exports, __webpack_require__) { + + + function LGraphObject(vGraphObject) { + this.vGraphObject = vGraphObject; + } + + module.exports = LGraphObject; + + /***/ }), + /* 3 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var Integer = __webpack_require__(10); + var RectangleD = __webpack_require__(13); + var LayoutConstants = __webpack_require__(0); + var RandomSeed = __webpack_require__(16); + var PointD = __webpack_require__(4); + + function LNode(gm, loc, size, vNode) { + //Alternative constructor 1 : LNode(LGraphManager gm, Point loc, Dimension size, Object vNode) + if (size == null && vNode == null) { + vNode = loc; + } + + LGraphObject.call(this, vNode); + + //Alternative constructor 2 : LNode(Layout layout, Object vNode) + if (gm.graphManager != null) gm = gm.graphManager; + + this.estimatedSize = Integer.MIN_VALUE; + this.inclusionTreeDepth = Integer.MAX_VALUE; + this.vGraphObject = vNode; + this.edges = []; + this.graphManager = gm; + + if (size != null && loc != null) this.rect = new RectangleD(loc.x, loc.y, size.width, size.height);else this.rect = new RectangleD(); + } + + LNode.prototype = Object.create(LGraphObject.prototype); + for (var prop in LGraphObject) { + LNode[prop] = LGraphObject[prop]; + } + + LNode.prototype.getEdges = function () { + return this.edges; + }; + + LNode.prototype.getChild = function () { + return this.child; + }; + + LNode.prototype.getOwner = function () { + // if (this.owner != null) { + // if (!(this.owner == null || this.owner.getNodes().indexOf(this) > -1)) { + // throw "assert failed"; + // } + // } + + return this.owner; + }; + + LNode.prototype.getWidth = function () { + return this.rect.width; + }; + + LNode.prototype.setWidth = function (width) { + this.rect.width = width; + }; + + LNode.prototype.getHeight = function () { + return this.rect.height; + }; + + LNode.prototype.setHeight = function (height) { + this.rect.height = height; + }; + + LNode.prototype.getCenterX = function () { + return this.rect.x + this.rect.width / 2; + }; + + LNode.prototype.getCenterY = function () { + return this.rect.y + this.rect.height / 2; + }; + + LNode.prototype.getCenter = function () { + return new PointD(this.rect.x + this.rect.width / 2, this.rect.y + this.rect.height / 2); + }; + + LNode.prototype.getLocation = function () { + return new PointD(this.rect.x, this.rect.y); + }; + + LNode.prototype.getRect = function () { + return this.rect; + }; + + LNode.prototype.getDiagonal = function () { + return Math.sqrt(this.rect.width * this.rect.width + this.rect.height * this.rect.height); + }; + + /** + * This method returns half the diagonal length of this node. + */ + LNode.prototype.getHalfTheDiagonal = function () { + return Math.sqrt(this.rect.height * this.rect.height + this.rect.width * this.rect.width) / 2; + }; + + LNode.prototype.setRect = function (upperLeft, dimension) { + this.rect.x = upperLeft.x; + this.rect.y = upperLeft.y; + this.rect.width = dimension.width; + this.rect.height = dimension.height; + }; + + LNode.prototype.setCenter = function (cx, cy) { + this.rect.x = cx - this.rect.width / 2; + this.rect.y = cy - this.rect.height / 2; + }; + + LNode.prototype.setLocation = function (x, y) { + this.rect.x = x; + this.rect.y = y; + }; + + LNode.prototype.moveBy = function (dx, dy) { + this.rect.x += dx; + this.rect.y += dy; + }; + + LNode.prototype.getEdgeListToNode = function (to) { + var edgeList = []; + var self = this; + + self.edges.forEach(function (edge) { + + if (edge.target == to) { + if (edge.source != self) throw "Incorrect edge source!"; + + edgeList.push(edge); + } + }); + + return edgeList; + }; + + LNode.prototype.getEdgesBetween = function (other) { + var edgeList = []; + + var self = this; + self.edges.forEach(function (edge) { + + if (!(edge.source == self || edge.target == self)) throw "Incorrect edge source and/or target"; + + if (edge.target == other || edge.source == other) { + edgeList.push(edge); + } + }); + + return edgeList; + }; + + LNode.prototype.getNeighborsList = function () { + var neighbors = new Set(); + + var self = this; + self.edges.forEach(function (edge) { + + if (edge.source == self) { + neighbors.add(edge.target); + } else { + if (edge.target != self) { + throw "Incorrect incidency!"; + } + + neighbors.add(edge.source); + } + }); + + return neighbors; + }; + + LNode.prototype.withChildren = function () { + var withNeighborsList = new Set(); + var childNode; + var children; + + withNeighborsList.add(this); + + if (this.child != null) { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + children = childNode.withChildren(); + children.forEach(function (node) { + withNeighborsList.add(node); + }); + } + } + + return withNeighborsList; + }; + + LNode.prototype.getNoOfChildren = function () { + var noOfChildren = 0; + var childNode; + + if (this.child == null) { + noOfChildren = 1; + } else { + var nodes = this.child.getNodes(); + for (var i = 0; i < nodes.length; i++) { + childNode = nodes[i]; + + noOfChildren += childNode.getNoOfChildren(); + } + } + + if (noOfChildren == 0) { + noOfChildren = 1; + } + return noOfChildren; + }; + + LNode.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; + }; + + LNode.prototype.calcEstimatedSize = function () { + if (this.child == null) { + return this.estimatedSize = (this.rect.width + this.rect.height) / 2; + } else { + this.estimatedSize = this.child.calcEstimatedSize(); + this.rect.width = this.estimatedSize; + this.rect.height = this.estimatedSize; + + return this.estimatedSize; + } + }; + + LNode.prototype.scatter = function () { + var randomCenterX; + var randomCenterY; + + var minX = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxX = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterX = LayoutConstants.WORLD_CENTER_X + RandomSeed.nextDouble() * (maxX - minX) + minX; + + var minY = -LayoutConstants.INITIAL_WORLD_BOUNDARY; + var maxY = LayoutConstants.INITIAL_WORLD_BOUNDARY; + randomCenterY = LayoutConstants.WORLD_CENTER_Y + RandomSeed.nextDouble() * (maxY - minY) + minY; + + this.rect.x = randomCenterX; + this.rect.y = randomCenterY; + }; + + LNode.prototype.updateBounds = function () { + if (this.getChild() == null) { + throw "assert failed"; + } + if (this.getChild().getNodes().length != 0) { + // wrap the children nodes by re-arranging the boundaries + var childGraph = this.getChild(); + childGraph.updateBounds(true); + + this.rect.x = childGraph.getLeft(); + this.rect.y = childGraph.getTop(); + + this.setWidth(childGraph.getRight() - childGraph.getLeft()); + this.setHeight(childGraph.getBottom() - childGraph.getTop()); + + // Update compound bounds considering its label properties + if (LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS) { + + var width = childGraph.getRight() - childGraph.getLeft(); + var height = childGraph.getBottom() - childGraph.getTop(); + + if (this.labelWidth > width) { + this.rect.x -= (this.labelWidth - width) / 2; + this.setWidth(this.labelWidth); + } + + if (this.labelHeight > height) { + if (this.labelPos == "center") { + this.rect.y -= (this.labelHeight - height) / 2; + } else if (this.labelPos == "top") { + this.rect.y -= this.labelHeight - height; + } + this.setHeight(this.labelHeight); + } + } + } + }; + + LNode.prototype.getInclusionTreeDepth = function () { + if (this.inclusionTreeDepth == Integer.MAX_VALUE) { + throw "assert failed"; + } + return this.inclusionTreeDepth; + }; + + LNode.prototype.transform = function (trans) { + var left = this.rect.x; + + if (left > LayoutConstants.WORLD_BOUNDARY) { + left = LayoutConstants.WORLD_BOUNDARY; + } else if (left < -LayoutConstants.WORLD_BOUNDARY) { + left = -LayoutConstants.WORLD_BOUNDARY; + } + + var top = this.rect.y; + + if (top > LayoutConstants.WORLD_BOUNDARY) { + top = LayoutConstants.WORLD_BOUNDARY; + } else if (top < -LayoutConstants.WORLD_BOUNDARY) { + top = -LayoutConstants.WORLD_BOUNDARY; + } + + var leftTop = new PointD(left, top); + var vLeftTop = trans.inverseTransformPoint(leftTop); + + this.setLocation(vLeftTop.x, vLeftTop.y); + }; + + LNode.prototype.getLeft = function () { + return this.rect.x; + }; + + LNode.prototype.getRight = function () { + return this.rect.x + this.rect.width; + }; + + LNode.prototype.getTop = function () { + return this.rect.y; + }; + + LNode.prototype.getBottom = function () { + return this.rect.y + this.rect.height; + }; + + LNode.prototype.getParent = function () { + if (this.owner == null) { + return null; + } + + return this.owner.getParent(); + }; + + module.exports = LNode; + + /***/ }), + /* 4 */ + /***/ (function(module, exports, __webpack_require__) { + + + function PointD(x, y) { + if (x == null && y == null) { + this.x = 0; + this.y = 0; + } else { + this.x = x; + this.y = y; + } + } + + PointD.prototype.getX = function () { + return this.x; + }; + + PointD.prototype.getY = function () { + return this.y; + }; + + PointD.prototype.setX = function (x) { + this.x = x; + }; + + PointD.prototype.setY = function (y) { + this.y = y; + }; + + PointD.prototype.getDifference = function (pt) { + return new DimensionD(this.x - pt.x, this.y - pt.y); + }; + + PointD.prototype.getCopy = function () { + return new PointD(this.x, this.y); + }; + + PointD.prototype.translate = function (dim) { + this.x += dim.width; + this.y += dim.height; + return this; + }; + + module.exports = PointD; + + /***/ }), + /* 5 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphObject = __webpack_require__(2); + var Integer = __webpack_require__(10); + var LayoutConstants = __webpack_require__(0); + var LGraphManager = __webpack_require__(6); + var LNode = __webpack_require__(3); + var LEdge = __webpack_require__(1); + var RectangleD = __webpack_require__(13); + var Point = __webpack_require__(12); + var LinkedList = __webpack_require__(11); + + function LGraph(parent, obj2, vGraph) { + LGraphObject.call(this, vGraph); + this.estimatedSize = Integer.MIN_VALUE; + this.margin = LayoutConstants.DEFAULT_GRAPH_MARGIN; + this.edges = []; + this.nodes = []; + this.isConnected = false; + this.parent = parent; + + if (obj2 != null && obj2 instanceof LGraphManager) { + this.graphManager = obj2; + } else if (obj2 != null && obj2 instanceof Layout) { + this.graphManager = obj2.graphManager; + } + } + + LGraph.prototype = Object.create(LGraphObject.prototype); + for (var prop in LGraphObject) { + LGraph[prop] = LGraphObject[prop]; + } + + LGraph.prototype.getNodes = function () { + return this.nodes; + }; + + LGraph.prototype.getEdges = function () { + return this.edges; + }; + + LGraph.prototype.getGraphManager = function () { + return this.graphManager; + }; + + LGraph.prototype.getParent = function () { + return this.parent; + }; + + LGraph.prototype.getLeft = function () { + return this.left; + }; + + LGraph.prototype.getRight = function () { + return this.right; + }; + + LGraph.prototype.getTop = function () { + return this.top; + }; + + LGraph.prototype.getBottom = function () { + return this.bottom; + }; + + LGraph.prototype.isConnected = function () { + return this.isConnected; + }; + + LGraph.prototype.add = function (obj1, sourceNode, targetNode) { + if (sourceNode == null && targetNode == null) { + var newNode = obj1; + if (this.graphManager == null) { + throw "Graph has no graph mgr!"; + } + if (this.getNodes().indexOf(newNode) > -1) { + throw "Node already in graph!"; + } + newNode.owner = this; + this.getNodes().push(newNode); + + return newNode; + } else { + var newEdge = obj1; + if (!(this.getNodes().indexOf(sourceNode) > -1 && this.getNodes().indexOf(targetNode) > -1)) { + throw "Source or target not in graph!"; + } + + if (!(sourceNode.owner == targetNode.owner && sourceNode.owner == this)) { + throw "Both owners must be this graph!"; + } + + if (sourceNode.owner != targetNode.owner) { + return null; + } + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // set as intra-graph edge + newEdge.isInterGraph = false; + + // add to graph edge list + this.getEdges().push(newEdge); + + // add to incidency lists + sourceNode.edges.push(newEdge); + + if (targetNode != sourceNode) { + targetNode.edges.push(newEdge); + } + + return newEdge; + } + }; + + LGraph.prototype.remove = function (obj) { + var node = obj; + if (obj instanceof LNode) { + if (node == null) { + throw "Node is null!"; + } + if (!(node.owner != null && node.owner == this)) { + throw "Owner graph is invalid!"; + } + if (this.graphManager == null) { + throw "Owner graph manager is invalid!"; + } + // remove incident edges first (make a copy to do it safely) + var edgesToBeRemoved = node.edges.slice(); + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + + if (edge.isInterGraph) { + this.graphManager.remove(edge); + } else { + edge.source.owner.remove(edge); + } + } + + // now the node itself + var index = this.nodes.indexOf(node); + if (index == -1) { + throw "Node not in owner node list!"; + } + + this.nodes.splice(index, 1); + } else if (obj instanceof LEdge) { + var edge = obj; + if (edge == null) { + throw "Edge is null!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + if (!(edge.source.owner != null && edge.target.owner != null && edge.source.owner == this && edge.target.owner == this)) { + throw "Source and/or target owner is invalid!"; + } + + var sourceIndex = edge.source.edges.indexOf(edge); + var targetIndex = edge.target.edges.indexOf(edge); + if (!(sourceIndex > -1 && targetIndex > -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + edge.source.edges.splice(sourceIndex, 1); + + if (edge.target != edge.source) { + edge.target.edges.splice(targetIndex, 1); + } + + var index = edge.source.owner.getEdges().indexOf(edge); + if (index == -1) { + throw "Not in owner's edge list!"; + } + + edge.source.owner.getEdges().splice(index, 1); + } + }; + + LGraph.prototype.updateLeftTop = function () { + var top = Integer.MAX_VALUE; + var left = Integer.MAX_VALUE; + var nodeTop; + var nodeLeft; + var margin; + + var nodes = this.getNodes(); + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeTop = lNode.getTop(); + nodeLeft = lNode.getLeft(); + + if (top > nodeTop) { + top = nodeTop; + } + + if (left > nodeLeft) { + left = nodeLeft; + } + } + + // Do we have any nodes in this graph? + if (top == Integer.MAX_VALUE) { + return null; + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = left - margin; + this.top = top - margin; + + // Apply the margins and return the result + return new Point(this.left, this.top); + }; + + LGraph.prototype.updateBounds = function (recursive) { + // calculate bounds + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + var margin; + + var nodes = this.nodes; + var s = nodes.length; + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + + if (recursive && lNode.child != null) { + lNode.updateBounds(); + } + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + if (left == Integer.MAX_VALUE) { + this.left = this.parent.getLeft(); + this.right = this.parent.getRight(); + this.top = this.parent.getTop(); + this.bottom = this.parent.getBottom(); + } + + if (nodes[0].getParent().paddingLeft != undefined) { + margin = nodes[0].getParent().paddingLeft; + } else { + margin = this.margin; + } + + this.left = boundingRect.x - margin; + this.right = boundingRect.x + boundingRect.width + margin; + this.top = boundingRect.y - margin; + this.bottom = boundingRect.y + boundingRect.height + margin; + }; + + LGraph.calculateBounds = function (nodes) { + var left = Integer.MAX_VALUE; + var right = -Integer.MAX_VALUE; + var top = Integer.MAX_VALUE; + var bottom = -Integer.MAX_VALUE; + var nodeLeft; + var nodeRight; + var nodeTop; + var nodeBottom; + + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + nodeLeft = lNode.getLeft(); + nodeRight = lNode.getRight(); + nodeTop = lNode.getTop(); + nodeBottom = lNode.getBottom(); + + if (left > nodeLeft) { + left = nodeLeft; + } + + if (right < nodeRight) { + right = nodeRight; + } + + if (top > nodeTop) { + top = nodeTop; + } + + if (bottom < nodeBottom) { + bottom = nodeBottom; + } + } + + var boundingRect = new RectangleD(left, top, right - left, bottom - top); + + return boundingRect; + }; + + LGraph.prototype.getInclusionTreeDepth = function () { + if (this == this.graphManager.getRoot()) { + return 1; + } else { + return this.parent.getInclusionTreeDepth(); + } + }; + + LGraph.prototype.getEstimatedSize = function () { + if (this.estimatedSize == Integer.MIN_VALUE) { + throw "assert failed"; + } + return this.estimatedSize; + }; + + LGraph.prototype.calcEstimatedSize = function () { + var size = 0; + var nodes = this.nodes; + var s = nodes.length; + + for (var i = 0; i < s; i++) { + var lNode = nodes[i]; + size += lNode.calcEstimatedSize(); + } + + if (size == 0) { + this.estimatedSize = LayoutConstants.EMPTY_COMPOUND_NODE_SIZE; + } else { + this.estimatedSize = size / Math.sqrt(this.nodes.length); + } + + return this.estimatedSize; + }; + + LGraph.prototype.updateConnected = function () { + var self = this; + if (this.nodes.length == 0) { + this.isConnected = true; + return; + } + + var queue = new LinkedList(); + var visited = new Set(); + var currentNode = this.nodes[0]; + var neighborEdges; + var currentNeighbor; + var childrenOfNode = currentNode.withChildren(); + childrenOfNode.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + + while (queue.length !== 0) { + currentNode = queue.shift(); + + // Traverse all neighbors of this node + neighborEdges = currentNode.getEdges(); + var size = neighborEdges.length; + for (var i = 0; i < size; i++) { + var neighborEdge = neighborEdges[i]; + currentNeighbor = neighborEdge.getOtherEndInGraph(currentNode, this); + + // Add unvisited neighbors to the list to visit + if (currentNeighbor != null && !visited.has(currentNeighbor)) { + var childrenOfNeighbor = currentNeighbor.withChildren(); + + childrenOfNeighbor.forEach(function (node) { + queue.push(node); + visited.add(node); + }); + } + } + } + + this.isConnected = false; + + if (visited.size >= this.nodes.length) { + var noOfVisitedInThisGraph = 0; + + visited.forEach(function (visitedNode) { + if (visitedNode.owner == self) { + noOfVisitedInThisGraph++; + } + }); + + if (noOfVisitedInThisGraph == this.nodes.length) { + this.isConnected = true; + } + } + }; + + module.exports = LGraph; + + /***/ }), + /* 6 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraph; + var LEdge = __webpack_require__(1); + + function LGraphManager(layout) { + LGraph = __webpack_require__(5); // It may be better to initilize this out of this function but it gives an error (Right-hand side of 'instanceof' is not callable) now. + this.layout = layout; + + this.graphs = []; + this.edges = []; + } + + LGraphManager.prototype.addRoot = function () { + var ngraph = this.layout.newGraph(); + var nnode = this.layout.newNode(null); + var root = this.add(ngraph, nnode); + this.setRootGraph(root); + return this.rootGraph; + }; + + LGraphManager.prototype.add = function (newGraph, parentNode, newEdge, sourceNode, targetNode) { + //there are just 2 parameters are passed then it adds an LGraph else it adds an LEdge + if (newEdge == null && sourceNode == null && targetNode == null) { + if (newGraph == null) { + throw "Graph is null!"; + } + if (parentNode == null) { + throw "Parent node is null!"; + } + if (this.graphs.indexOf(newGraph) > -1) { + throw "Graph already in this graph mgr!"; + } + + this.graphs.push(newGraph); + + if (newGraph.parent != null) { + throw "Already has a parent!"; + } + if (parentNode.child != null) { + throw "Already has a child!"; + } + + newGraph.parent = parentNode; + parentNode.child = newGraph; + + return newGraph; + } else { + //change the order of the parameters + targetNode = newEdge; + sourceNode = parentNode; + newEdge = newGraph; + var sourceGraph = sourceNode.getOwner(); + var targetGraph = targetNode.getOwner(); + + if (!(sourceGraph != null && sourceGraph.getGraphManager() == this)) { + throw "Source not in this graph mgr!"; + } + if (!(targetGraph != null && targetGraph.getGraphManager() == this)) { + throw "Target not in this graph mgr!"; + } + + if (sourceGraph == targetGraph) { + newEdge.isInterGraph = false; + return sourceGraph.add(newEdge, sourceNode, targetNode); + } else { + newEdge.isInterGraph = true; + + // set source and target + newEdge.source = sourceNode; + newEdge.target = targetNode; + + // add edge to inter-graph edge list + if (this.edges.indexOf(newEdge) > -1) { + throw "Edge already in inter-graph edge list!"; + } + + this.edges.push(newEdge); + + // add edge to source and target incidency lists + if (!(newEdge.source != null && newEdge.target != null)) { + throw "Edge source and/or target is null!"; + } + + if (!(newEdge.source.edges.indexOf(newEdge) == -1 && newEdge.target.edges.indexOf(newEdge) == -1)) { + throw "Edge already in source and/or target incidency list!"; + } + + newEdge.source.edges.push(newEdge); + newEdge.target.edges.push(newEdge); + + return newEdge; + } + } + }; + + LGraphManager.prototype.remove = function (lObj) { + if (lObj instanceof LGraph) { + var graph = lObj; + if (graph.getGraphManager() != this) { + throw "Graph not in this graph mgr"; + } + if (!(graph == this.rootGraph || graph.parent != null && graph.parent.graphManager == this)) { + throw "Invalid parent node!"; + } + + // first the edges (make a copy to do it safely) + var edgesToBeRemoved = []; + + edgesToBeRemoved = edgesToBeRemoved.concat(graph.getEdges()); + + var edge; + var s = edgesToBeRemoved.length; + for (var i = 0; i < s; i++) { + edge = edgesToBeRemoved[i]; + graph.remove(edge); + } + + // then the nodes (make a copy to do it safely) + var nodesToBeRemoved = []; + + nodesToBeRemoved = nodesToBeRemoved.concat(graph.getNodes()); + + var node; + s = nodesToBeRemoved.length; + for (var i = 0; i < s; i++) { + node = nodesToBeRemoved[i]; + graph.remove(node); + } + + // check if graph is the root + if (graph == this.rootGraph) { + this.setRootGraph(null); + } + + // now remove the graph itself + var index = this.graphs.indexOf(graph); + this.graphs.splice(index, 1); + + // also reset the parent of the graph + graph.parent = null; + } else if (lObj instanceof LEdge) { + edge = lObj; + if (edge == null) { + throw "Edge is null!"; + } + if (!edge.isInterGraph) { + throw "Not an inter-graph edge!"; + } + if (!(edge.source != null && edge.target != null)) { + throw "Source and/or target is null!"; + } + + // remove edge from source and target nodes' incidency lists + + if (!(edge.source.edges.indexOf(edge) != -1 && edge.target.edges.indexOf(edge) != -1)) { + throw "Source and/or target doesn't know this edge!"; + } + + var index = edge.source.edges.indexOf(edge); + edge.source.edges.splice(index, 1); + index = edge.target.edges.indexOf(edge); + edge.target.edges.splice(index, 1); + + // remove edge from owner graph manager's inter-graph edge list + + if (!(edge.source.owner != null && edge.source.owner.getGraphManager() != null)) { + throw "Edge owner graph or owner graph manager is null!"; + } + if (edge.source.owner.getGraphManager().edges.indexOf(edge) == -1) { + throw "Not in owner graph manager's edge list!"; + } + + var index = edge.source.owner.getGraphManager().edges.indexOf(edge); + edge.source.owner.getGraphManager().edges.splice(index, 1); + } + }; + + LGraphManager.prototype.updateBounds = function () { + this.rootGraph.updateBounds(true); + }; + + LGraphManager.prototype.getGraphs = function () { + return this.graphs; + }; + + LGraphManager.prototype.getAllNodes = function () { + if (this.allNodes == null) { + var nodeList = []; + var graphs = this.getGraphs(); + var s = graphs.length; + for (var i = 0; i < s; i++) { + nodeList = nodeList.concat(graphs[i].getNodes()); + } + this.allNodes = nodeList; + } + return this.allNodes; + }; + + LGraphManager.prototype.resetAllNodes = function () { + this.allNodes = null; + }; + + LGraphManager.prototype.resetAllEdges = function () { + this.allEdges = null; + }; + + LGraphManager.prototype.resetAllNodesToApplyGravitation = function () { + this.allNodesToApplyGravitation = null; + }; + + LGraphManager.prototype.getAllEdges = function () { + if (this.allEdges == null) { + var edgeList = []; + var graphs = this.getGraphs(); + graphs.length; + for (var i = 0; i < graphs.length; i++) { + edgeList = edgeList.concat(graphs[i].getEdges()); + } + + edgeList = edgeList.concat(this.edges); + + this.allEdges = edgeList; + } + return this.allEdges; + }; + + LGraphManager.prototype.getAllNodesToApplyGravitation = function () { + return this.allNodesToApplyGravitation; + }; + + LGraphManager.prototype.setAllNodesToApplyGravitation = function (nodeList) { + if (this.allNodesToApplyGravitation != null) { + throw "assert failed"; + } + + this.allNodesToApplyGravitation = nodeList; + }; + + LGraphManager.prototype.getRoot = function () { + return this.rootGraph; + }; + + LGraphManager.prototype.setRootGraph = function (graph) { + if (graph.getGraphManager() != this) { + throw "Root not in this graph mgr!"; + } + + this.rootGraph = graph; + // root graph must have a root node associated with it for convenience + if (graph.parent == null) { + graph.parent = this.layout.newNode("Root node"); + } + }; + + LGraphManager.prototype.getLayout = function () { + return this.layout; + }; + + LGraphManager.prototype.isOneAncestorOfOther = function (firstNode, secondNode) { + if (!(firstNode != null && secondNode != null)) { + throw "assert failed"; + } + + if (firstNode == secondNode) { + return true; + } + // Is second node an ancestor of the first one? + var ownerGraph = firstNode.getOwner(); + var parentNode; + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == secondNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + // Is first node an ancestor of the second one? + ownerGraph = secondNode.getOwner(); + + do { + parentNode = ownerGraph.getParent(); + + if (parentNode == null) { + break; + } + + if (parentNode == firstNode) { + return true; + } + + ownerGraph = parentNode.getOwner(); + if (ownerGraph == null) { + break; + } + } while (true); + + return false; + }; + + LGraphManager.prototype.calcLowestCommonAncestors = function () { + var edge; + var sourceNode; + var targetNode; + var sourceAncestorGraph; + var targetAncestorGraph; + + var edges = this.getAllEdges(); + var s = edges.length; + for (var i = 0; i < s; i++) { + edge = edges[i]; + + sourceNode = edge.source; + targetNode = edge.target; + edge.lca = null; + edge.sourceInLca = sourceNode; + edge.targetInLca = targetNode; + + if (sourceNode == targetNode) { + edge.lca = sourceNode.getOwner(); + continue; + } + + sourceAncestorGraph = sourceNode.getOwner(); + + while (edge.lca == null) { + edge.targetInLca = targetNode; + targetAncestorGraph = targetNode.getOwner(); + + while (edge.lca == null) { + if (targetAncestorGraph == sourceAncestorGraph) { + edge.lca = targetAncestorGraph; + break; + } + + if (targetAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca != null) { + throw "assert failed"; + } + edge.targetInLca = targetAncestorGraph.getParent(); + targetAncestorGraph = edge.targetInLca.getOwner(); + } + + if (sourceAncestorGraph == this.rootGraph) { + break; + } + + if (edge.lca == null) { + edge.sourceInLca = sourceAncestorGraph.getParent(); + sourceAncestorGraph = edge.sourceInLca.getOwner(); + } + } + + if (edge.lca == null) { + throw "assert failed"; + } + } + }; + + LGraphManager.prototype.calcLowestCommonAncestor = function (firstNode, secondNode) { + if (firstNode == secondNode) { + return firstNode.getOwner(); + } + var firstOwnerGraph = firstNode.getOwner(); + + do { + if (firstOwnerGraph == null) { + break; + } + var secondOwnerGraph = secondNode.getOwner(); + + do { + if (secondOwnerGraph == null) { + break; + } + + if (secondOwnerGraph == firstOwnerGraph) { + return secondOwnerGraph; + } + secondOwnerGraph = secondOwnerGraph.getParent().getOwner(); + } while (true); + + firstOwnerGraph = firstOwnerGraph.getParent().getOwner(); + } while (true); + + return firstOwnerGraph; + }; + + LGraphManager.prototype.calcInclusionTreeDepths = function (graph, depth) { + if (graph == null && depth == null) { + graph = this.rootGraph; + depth = 1; + } + var node; + + var nodes = graph.getNodes(); + var s = nodes.length; + for (var i = 0; i < s; i++) { + node = nodes[i]; + node.inclusionTreeDepth = depth; + + if (node.child != null) { + this.calcInclusionTreeDepths(node.child, depth + 1); + } + } + }; + + LGraphManager.prototype.includesInvalidEdge = function () { + var edge; + + var s = this.edges.length; + for (var i = 0; i < s; i++) { + edge = this.edges[i]; + + if (this.isOneAncestorOfOther(edge.source, edge.target)) { + return true; + } + } + return false; + }; + + module.exports = LGraphManager; + + /***/ }), + /* 7 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LayoutConstants = __webpack_require__(0); + + function FDLayoutConstants() {} + + //FDLayoutConstants inherits static props in LayoutConstants + for (var prop in LayoutConstants) { + FDLayoutConstants[prop] = LayoutConstants[prop]; + } + + FDLayoutConstants.MAX_ITERATIONS = 2500; + + FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50; + FDLayoutConstants.DEFAULT_SPRING_STRENGTH = 0.45; + FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = 4500.0; + FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = 0.4; + FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = 1.0; + FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = 3.8; + FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = 1.5; + FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION = true; + FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION = true; + FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = 0.3; + FDLayoutConstants.COOLING_ADAPTATION_FACTOR = 0.33; + FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT = 1000; + FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT = 5000; + FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL = 100.0; + FDLayoutConstants.MAX_NODE_DISPLACEMENT = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL * 3; + FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0; + FDLayoutConstants.CONVERGENCE_CHECK_PERIOD = 100; + FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = 0.1; + FDLayoutConstants.MIN_EDGE_LENGTH = 1; + FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD = 10; + + module.exports = FDLayoutConstants; + + /***/ }), + /* 8 */ + /***/ (function(module, exports, __webpack_require__) { + + + /** + * This class maintains a list of static geometry related utility methods. + * + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + + var Point = __webpack_require__(12); + + function IGeometry() {} + + /** + * This method calculates *half* the amount in x and y directions of the two + * input rectangles needed to separate them keeping their respective + * positioning, and returns the result in the input array. An input + * separation buffer added to the amount in both directions. We assume that + * the two rectangles do intersect. + */ + IGeometry.calcSeparationAmount = function (rectA, rectB, overlapAmount, separationBuffer) { + if (!rectA.intersects(rectB)) { + throw "assert failed"; + } + + var directions = new Array(2); + + this.decideDirectionsForOverlappingNodes(rectA, rectB, directions); + + overlapAmount[0] = Math.min(rectA.getRight(), rectB.getRight()) - Math.max(rectA.x, rectB.x); + overlapAmount[1] = Math.min(rectA.getBottom(), rectB.getBottom()) - Math.max(rectA.y, rectB.y); + + // update the overlapping amounts for the following cases: + if (rectA.getX() <= rectB.getX() && rectA.getRight() >= rectB.getRight()) { + /* Case x.1: + * + * rectA + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectB + */ + overlapAmount[0] += Math.min(rectB.getX() - rectA.getX(), rectA.getRight() - rectB.getRight()); + } else if (rectB.getX() <= rectA.getX() && rectB.getRight() >= rectA.getRight()) { + /* Case x.2: + * + * rectB + * | | + * | _________ | + * | | | | + * |________|_______|______| + * | | + * | | + * rectA + */ + overlapAmount[0] += Math.min(rectA.getX() - rectB.getX(), rectB.getRight() - rectA.getRight()); + } + if (rectA.getY() <= rectB.getY() && rectA.getBottom() >= rectB.getBottom()) { + /* Case y.1: + * ________ rectA + * | + * | + * ______|____ rectB + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectB.getY() - rectA.getY(), rectA.getBottom() - rectB.getBottom()); + } else if (rectB.getY() <= rectA.getY() && rectB.getBottom() >= rectA.getBottom()) { + /* Case y.2: + * ________ rectB + * | + * | + * ______|____ rectA + * | | + * | | + * ______|____| + * | + * | + * |________ + * + */ + overlapAmount[1] += Math.min(rectA.getY() - rectB.getY(), rectB.getBottom() - rectA.getBottom()); + } + + // find slope of the line passes two centers + var slope = Math.abs((rectB.getCenterY() - rectA.getCenterY()) / (rectB.getCenterX() - rectA.getCenterX())); + // if centers are overlapped + if (rectB.getCenterY() === rectA.getCenterY() && rectB.getCenterX() === rectA.getCenterX()) { + // assume the slope is 1 (45 degree) + slope = 1.0; + } + + var moveByY = slope * overlapAmount[0]; + var moveByX = overlapAmount[1] / slope; + if (overlapAmount[0] < moveByX) { + moveByX = overlapAmount[0]; + } else { + moveByY = overlapAmount[1]; + } + // return half the amount so that if each rectangle is moved by these + // amounts in opposite directions, overlap will be resolved + overlapAmount[0] = -1 * directions[0] * (moveByX / 2 + separationBuffer); + overlapAmount[1] = -1 * directions[1] * (moveByY / 2 + separationBuffer); + }; + + /** + * This method decides the separation direction of overlapping nodes + * + * if directions[0] = -1, then rectA goes left + * if directions[0] = 1, then rectA goes right + * if directions[1] = -1, then rectA goes up + * if directions[1] = 1, then rectA goes down + */ + IGeometry.decideDirectionsForOverlappingNodes = function (rectA, rectB, directions) { + if (rectA.getCenterX() < rectB.getCenterX()) { + directions[0] = -1; + } else { + directions[0] = 1; + } + + if (rectA.getCenterY() < rectB.getCenterY()) { + directions[1] = -1; + } else { + directions[1] = 1; + } + }; + + /** + * This method calculates the intersection (clipping) points of the two + * input rectangles with line segment defined by the centers of these two + * rectangles. The clipping points are saved in the input double array and + * whether or not the two rectangles overlap is returned. + */ + IGeometry.getIntersection2 = function (rectA, rectB, result) { + //result[0-1] will contain clipPoint of rectA, result[2-3] will contain clipPoint of rectB + var p1x = rectA.getCenterX(); + var p1y = rectA.getCenterY(); + var p2x = rectB.getCenterX(); + var p2y = rectB.getCenterY(); + + //if two rectangles intersect, then clipping points are centers + if (rectA.intersects(rectB)) { + result[0] = p1x; + result[1] = p1y; + result[2] = p2x; + result[3] = p2y; + return true; + } + //variables for rectA + var topLeftAx = rectA.getX(); + var topLeftAy = rectA.getY(); + var topRightAx = rectA.getRight(); + var bottomLeftAx = rectA.getX(); + var bottomLeftAy = rectA.getBottom(); + var bottomRightAx = rectA.getRight(); + var halfWidthA = rectA.getWidthHalf(); + var halfHeightA = rectA.getHeightHalf(); + //variables for rectB + var topLeftBx = rectB.getX(); + var topLeftBy = rectB.getY(); + var topRightBx = rectB.getRight(); + var bottomLeftBx = rectB.getX(); + var bottomLeftBy = rectB.getBottom(); + var bottomRightBx = rectB.getRight(); + var halfWidthB = rectB.getWidthHalf(); + var halfHeightB = rectB.getHeightHalf(); + + //flag whether clipping points are found + var clipPointAFound = false; + var clipPointBFound = false; + + // line is vertical + if (p1x === p2x) { + if (p1y > p2y) { + result[0] = p1x; + result[1] = topLeftAy; + result[2] = p2x; + result[3] = bottomLeftBy; + return false; + } else if (p1y < p2y) { + result[0] = p1x; + result[1] = bottomLeftAy; + result[2] = p2x; + result[3] = topLeftBy; + return false; + } else ; + } + // line is horizontal + else if (p1y === p2y) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = p1y; + result[2] = topRightBx; + result[3] = p2y; + return false; + } else if (p1x < p2x) { + result[0] = topRightAx; + result[1] = p1y; + result[2] = topLeftBx; + result[3] = p2y; + return false; + } else ; + } else { + //slopes of rectA's and rectB's diagonals + var slopeA = rectA.height / rectA.width; + var slopeB = rectB.height / rectB.width; + + //slope of line between center of rectA and center of rectB + var slopePrime = (p2y - p1y) / (p2x - p1x); + var cardinalDirectionA = void 0; + var cardinalDirectionB = void 0; + var tempPointAx = void 0; + var tempPointAy = void 0; + var tempPointBx = void 0; + var tempPointBy = void 0; + + //determine whether clipping point is the corner of nodeA + if (-slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = bottomLeftAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } else { + result[0] = topRightAx; + result[1] = topLeftAy; + clipPointAFound = true; + } + } else if (slopeA === slopePrime) { + if (p1x > p2x) { + result[0] = topLeftAx; + result[1] = topLeftAy; + clipPointAFound = true; + } else { + result[0] = bottomRightAx; + result[1] = bottomLeftAy; + clipPointAFound = true; + } + } + + //determine whether clipping point is the corner of nodeB + if (-slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = bottomLeftBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } else { + result[2] = topRightBx; + result[3] = topLeftBy; + clipPointBFound = true; + } + } else if (slopeB === slopePrime) { + if (p2x > p1x) { + result[2] = topLeftBx; + result[3] = topLeftBy; + clipPointBFound = true; + } else { + result[2] = bottomRightBx; + result[3] = bottomLeftBy; + clipPointBFound = true; + } + } + + //if both clipping points are corners + if (clipPointAFound && clipPointBFound) { + return false; + } + + //determine Cardinal Direction of rectangles + if (p1x > p2x) { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 4); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 2); + } else { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 3); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 1); + } + } else { + if (p1y > p2y) { + cardinalDirectionA = this.getCardinalDirection(-slopeA, slopePrime, 1); + cardinalDirectionB = this.getCardinalDirection(-slopeB, slopePrime, 3); + } else { + cardinalDirectionA = this.getCardinalDirection(slopeA, slopePrime, 2); + cardinalDirectionB = this.getCardinalDirection(slopeB, slopePrime, 4); + } + } + //calculate clipping Point if it is not found before + if (!clipPointAFound) { + switch (cardinalDirectionA) { + case 1: + tempPointAy = topLeftAy; + tempPointAx = p1x + -halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 2: + tempPointAx = bottomRightAx; + tempPointAy = p1y + halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 3: + tempPointAy = bottomLeftAy; + tempPointAx = p1x + halfHeightA / slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + case 4: + tempPointAx = bottomLeftAx; + tempPointAy = p1y + -halfWidthA * slopePrime; + result[0] = tempPointAx; + result[1] = tempPointAy; + break; + } + } + if (!clipPointBFound) { + switch (cardinalDirectionB) { + case 1: + tempPointBy = topLeftBy; + tempPointBx = p2x + -halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 2: + tempPointBx = bottomRightBx; + tempPointBy = p2y + halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 3: + tempPointBy = bottomLeftBy; + tempPointBx = p2x + halfHeightB / slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + case 4: + tempPointBx = bottomLeftBx; + tempPointBy = p2y + -halfWidthB * slopePrime; + result[2] = tempPointBx; + result[3] = tempPointBy; + break; + } + } + } + return false; + }; + + /** + * This method returns in which cardinal direction does input point stays + * 1: North + * 2: East + * 3: South + * 4: West + */ + IGeometry.getCardinalDirection = function (slope, slopePrime, line) { + if (slope > slopePrime) { + return line; + } else { + return 1 + line % 4; + } + }; + + /** + * This method calculates the intersection of the two lines defined by + * point pairs (s1,s2) and (f1,f2). + */ + IGeometry.getIntersection = function (s1, s2, f1, f2) { + if (f2 == null) { + return this.getIntersection2(s1, s2, f1); + } + + var x1 = s1.x; + var y1 = s1.y; + var x2 = s2.x; + var y2 = s2.y; + var x3 = f1.x; + var y3 = f1.y; + var x4 = f2.x; + var y4 = f2.y; + var x = void 0, + y = void 0; // intersection point + var a1 = void 0, + a2 = void 0, + b1 = void 0, + b2 = void 0, + c1 = void 0, + c2 = void 0; // coefficients of line eqns. + var denom = void 0; + + a1 = y2 - y1; + b1 = x1 - x2; + c1 = x2 * y1 - x1 * y2; // { a1*x + b1*y + c1 = 0 is line 1 } + + a2 = y4 - y3; + b2 = x3 - x4; + c2 = x4 * y3 - x3 * y4; // { a2*x + b2*y + c2 = 0 is line 2 } + + denom = a1 * b2 - a2 * b1; + + if (denom === 0) { + return null; + } + + x = (b1 * c2 - b2 * c1) / denom; + y = (a2 * c1 - a1 * c2) / denom; + + return new Point(x, y); + }; + + /** + * This method finds and returns the angle of the vector from the + x-axis + * in clockwise direction (compatible w/ Java coordinate system!). + */ + IGeometry.angleOfVector = function (Cx, Cy, Nx, Ny) { + var C_angle = void 0; + + if (Cx !== Nx) { + C_angle = Math.atan((Ny - Cy) / (Nx - Cx)); + + if (Nx < Cx) { + C_angle += Math.PI; + } else if (Ny < Cy) { + C_angle += this.TWO_PI; + } + } else if (Ny < Cy) { + C_angle = this.ONE_AND_HALF_PI; // 270 degrees + } else { + C_angle = this.HALF_PI; // 90 degrees + } + + return C_angle; + }; + + /** + * This method checks whether the given two line segments (one with point + * p1 and p2, the other with point p3 and p4) intersect at a point other + * than these points. + */ + IGeometry.doIntersect = function (p1, p2, p3, p4) { + var a = p1.x; + var b = p1.y; + var c = p2.x; + var d = p2.y; + var p = p3.x; + var q = p3.y; + var r = p4.x; + var s = p4.y; + var det = (c - a) * (s - q) - (r - p) * (d - b); + + if (det === 0) { + return false; + } else { + var lambda = ((s - q) * (r - a) + (p - r) * (s - b)) / det; + var gamma = ((b - d) * (r - a) + (c - a) * (s - b)) / det; + return 0 < lambda && lambda < 1 && 0 < gamma && gamma < 1; + } + }; + + // ----------------------------------------------------------------------------- + // Section: Class Constants + // ----------------------------------------------------------------------------- + /** + * Some useful pre-calculated constants + */ + IGeometry.HALF_PI = 0.5 * Math.PI; + IGeometry.ONE_AND_HALF_PI = 1.5 * Math.PI; + IGeometry.TWO_PI = 2.0 * Math.PI; + IGeometry.THREE_PI = 3.0 * Math.PI; + + module.exports = IGeometry; + + /***/ }), + /* 9 */ + /***/ (function(module, exports, __webpack_require__) { + + + function IMath() {} + + /** + * This method returns the sign of the input value. + */ + IMath.sign = function (value) { + if (value > 0) { + return 1; + } else if (value < 0) { + return -1; + } else { + return 0; + } + }; + + IMath.floor = function (value) { + return value < 0 ? Math.ceil(value) : Math.floor(value); + }; + + IMath.ceil = function (value) { + return value < 0 ? Math.floor(value) : Math.ceil(value); + }; + + module.exports = IMath; + + /***/ }), + /* 10 */ + /***/ (function(module, exports, __webpack_require__) { + + + function Integer() {} + + Integer.MAX_VALUE = 2147483647; + Integer.MIN_VALUE = -2147483648; + + module.exports = Integer; + + /***/ }), + /* 11 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var nodeFrom = function nodeFrom(value) { + return { value: value, next: null, prev: null }; + }; + + var add = function add(prev, node, next, list) { + if (prev !== null) { + prev.next = node; + } else { + list.head = node; + } + + if (next !== null) { + next.prev = node; + } else { + list.tail = node; + } + + node.prev = prev; + node.next = next; + + list.length++; + + return node; + }; + + var _remove = function _remove(node, list) { + var prev = node.prev, + next = node.next; + + + if (prev !== null) { + prev.next = next; + } else { + list.head = next; + } + + if (next !== null) { + next.prev = prev; + } else { + list.tail = prev; + } + + node.prev = node.next = null; + + list.length--; + + return node; + }; + + var LinkedList = function () { + function LinkedList(vals) { + var _this = this; + + _classCallCheck(this, LinkedList); + + this.length = 0; + this.head = null; + this.tail = null; + + if (vals != null) { + vals.forEach(function (v) { + return _this.push(v); + }); + } + } + + _createClass(LinkedList, [{ + key: "size", + value: function size() { + return this.length; + } + }, { + key: "insertBefore", + value: function insertBefore(val, otherNode) { + return add(otherNode.prev, nodeFrom(val), otherNode, this); + } + }, { + key: "insertAfter", + value: function insertAfter(val, otherNode) { + return add(otherNode, nodeFrom(val), otherNode.next, this); + } + }, { + key: "insertNodeBefore", + value: function insertNodeBefore(newNode, otherNode) { + return add(otherNode.prev, newNode, otherNode, this); + } + }, { + key: "insertNodeAfter", + value: function insertNodeAfter(newNode, otherNode) { + return add(otherNode, newNode, otherNode.next, this); + } + }, { + key: "push", + value: function push(val) { + return add(this.tail, nodeFrom(val), null, this); + } + }, { + key: "unshift", + value: function unshift(val) { + return add(null, nodeFrom(val), this.head, this); + } + }, { + key: "remove", + value: function remove(node) { + return _remove(node, this); + } + }, { + key: "pop", + value: function pop() { + return _remove(this.tail, this).value; + } + }, { + key: "popNode", + value: function popNode() { + return _remove(this.tail, this); + } + }, { + key: "shift", + value: function shift() { + return _remove(this.head, this).value; + } + }, { + key: "shiftNode", + value: function shiftNode() { + return _remove(this.head, this); + } + }, { + key: "get_object_at", + value: function get_object_at(index) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + return current.value; + } + } + }, { + key: "set_object_at", + value: function set_object_at(index, value) { + if (index <= this.length()) { + var i = 1; + var current = this.head; + while (i < index) { + current = current.next; + i++; + } + current.value = value; + } + } + }]); + + return LinkedList; + }(); + + module.exports = LinkedList; + + /***/ }), + /* 12 */ + /***/ (function(module, exports, __webpack_require__) { + + + /* + *This class is the javascript implementation of the Point.java class in jdk + */ + function Point(x, y, p) { + this.x = null; + this.y = null; + if (x == null && y == null && p == null) { + this.x = 0; + this.y = 0; + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + this.x = x; + this.y = y; + } else if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.x = p.x; + this.y = p.y; + } + } + + Point.prototype.getX = function () { + return this.x; + }; + + Point.prototype.getY = function () { + return this.y; + }; + + Point.prototype.getLocation = function () { + return new Point(this.x, this.y); + }; + + Point.prototype.setLocation = function (x, y, p) { + if (x.constructor.name == 'Point' && y == null && p == null) { + p = x; + this.setLocation(p.x, p.y); + } else if (typeof x == 'number' && typeof y == 'number' && p == null) { + //if both parameters are integer just move (x,y) location + if (parseInt(x) == x && parseInt(y) == y) { + this.move(x, y); + } else { + this.x = Math.floor(x + 0.5); + this.y = Math.floor(y + 0.5); + } + } + }; + + Point.prototype.move = function (x, y) { + this.x = x; + this.y = y; + }; + + Point.prototype.translate = function (dx, dy) { + this.x += dx; + this.y += dy; + }; + + Point.prototype.equals = function (obj) { + if (obj.constructor.name == "Point") { + var pt = obj; + return this.x == pt.x && this.y == pt.y; + } + return this == obj; + }; + + Point.prototype.toString = function () { + return new Point().constructor.name + "[x=" + this.x + ",y=" + this.y + "]"; + }; + + module.exports = Point; + + /***/ }), + /* 13 */ + /***/ (function(module, exports, __webpack_require__) { + + + function RectangleD(x, y, width, height) { + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + + if (x != null && y != null && width != null && height != null) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + } + + RectangleD.prototype.getX = function () { + return this.x; + }; + + RectangleD.prototype.setX = function (x) { + this.x = x; + }; + + RectangleD.prototype.getY = function () { + return this.y; + }; + + RectangleD.prototype.setY = function (y) { + this.y = y; + }; + + RectangleD.prototype.getWidth = function () { + return this.width; + }; + + RectangleD.prototype.setWidth = function (width) { + this.width = width; + }; + + RectangleD.prototype.getHeight = function () { + return this.height; + }; + + RectangleD.prototype.setHeight = function (height) { + this.height = height; + }; + + RectangleD.prototype.getRight = function () { + return this.x + this.width; + }; + + RectangleD.prototype.getBottom = function () { + return this.y + this.height; + }; + + RectangleD.prototype.intersects = function (a) { + if (this.getRight() < a.x) { + return false; + } + + if (this.getBottom() < a.y) { + return false; + } + + if (a.getRight() < this.x) { + return false; + } + + if (a.getBottom() < this.y) { + return false; + } + + return true; + }; + + RectangleD.prototype.getCenterX = function () { + return this.x + this.width / 2; + }; + + RectangleD.prototype.getMinX = function () { + return this.getX(); + }; + + RectangleD.prototype.getMaxX = function () { + return this.getX() + this.width; + }; + + RectangleD.prototype.getCenterY = function () { + return this.y + this.height / 2; + }; + + RectangleD.prototype.getMinY = function () { + return this.getY(); + }; + + RectangleD.prototype.getMaxY = function () { + return this.getY() + this.height; + }; + + RectangleD.prototype.getWidthHalf = function () { + return this.width / 2; + }; + + RectangleD.prototype.getHeightHalf = function () { + return this.height / 2; + }; + + module.exports = RectangleD; + + /***/ }), + /* 14 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function UniqueIDGeneretor() {} + + UniqueIDGeneretor.lastID = 0; + + UniqueIDGeneretor.createID = function (obj) { + if (UniqueIDGeneretor.isPrimitive(obj)) { + return obj; + } + if (obj.uniqueID != null) { + return obj.uniqueID; + } + obj.uniqueID = UniqueIDGeneretor.getString(); + UniqueIDGeneretor.lastID++; + return obj.uniqueID; + }; + + UniqueIDGeneretor.getString = function (id) { + if (id == null) id = UniqueIDGeneretor.lastID; + return "Object#" + id + ""; + }; + + UniqueIDGeneretor.isPrimitive = function (arg) { + var type = typeof arg === "undefined" ? "undefined" : _typeof(arg); + return arg == null || type != "object" && type != "function"; + }; + + module.exports = UniqueIDGeneretor; + + /***/ }), + /* 15 */ + /***/ (function(module, exports, __webpack_require__) { + + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var LayoutConstants = __webpack_require__(0); + var LGraphManager = __webpack_require__(6); + var LNode = __webpack_require__(3); + var LEdge = __webpack_require__(1); + var LGraph = __webpack_require__(5); + var PointD = __webpack_require__(4); + var Transform = __webpack_require__(17); + var Emitter = __webpack_require__(27); + + function Layout(isRemoteUse) { + Emitter.call(this); + + //Layout Quality: 0:draft, 1:default, 2:proof + this.layoutQuality = LayoutConstants.QUALITY; + //Whether layout should create bendpoints as needed or not + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + //Whether layout should be incremental or not + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + //Whether we animate from before to after layout node positions + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + //Whether we animate the layout process or not + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + //Number iterations that should be done between two successive animations + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + /** + * Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When + * they are, both spring and repulsion forces between two leaf nodes can be + * calculated without the expensive clipping point calculations, resulting + * in major speed-up. + */ + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + /** + * This is used for creation of bendpoints by using dummy nodes and edges. + * Maps an LEdge to its dummy bendpoint path. + */ + this.edgeToDummyNodes = new Map(); + this.graphManager = new LGraphManager(this); + this.isLayoutFinished = false; + this.isSubLayout = false; + this.isRemoteUse = false; + + if (isRemoteUse != null) { + this.isRemoteUse = isRemoteUse; + } + } + + Layout.RANDOM_SEED = 1; + + Layout.prototype = Object.create(Emitter.prototype); + + Layout.prototype.getGraphManager = function () { + return this.graphManager; + }; + + Layout.prototype.getAllNodes = function () { + return this.graphManager.getAllNodes(); + }; + + Layout.prototype.getAllEdges = function () { + return this.graphManager.getAllEdges(); + }; + + Layout.prototype.getAllNodesToApplyGravitation = function () { + return this.graphManager.getAllNodesToApplyGravitation(); + }; + + Layout.prototype.newGraphManager = function () { + var gm = new LGraphManager(this); + this.graphManager = gm; + return gm; + }; + + Layout.prototype.newGraph = function (vGraph) { + return new LGraph(null, this.graphManager, vGraph); + }; + + Layout.prototype.newNode = function (vNode) { + return new LNode(this.graphManager, vNode); + }; + + Layout.prototype.newEdge = function (vEdge) { + return new LEdge(null, null, vEdge); + }; + + Layout.prototype.checkLayoutSuccess = function () { + return this.graphManager.getRoot() == null || this.graphManager.getRoot().getNodes().length == 0 || this.graphManager.includesInvalidEdge(); + }; + + Layout.prototype.runLayout = function () { + this.isLayoutFinished = false; + + if (this.tilingPreLayout) { + this.tilingPreLayout(); + } + + this.initParameters(); + var isLayoutSuccessfull; + + if (this.checkLayoutSuccess()) { + isLayoutSuccessfull = false; + } else { + isLayoutSuccessfull = this.layout(); + } + + if (LayoutConstants.ANIMATE === 'during') { + // If this is a 'during' layout animation. Layout is not finished yet. + // We need to perform these in index.js when layout is really finished. + return false; + } + + if (isLayoutSuccessfull) { + if (!this.isSubLayout) { + this.doPostLayout(); + } + } + + if (this.tilingPostLayout) { + this.tilingPostLayout(); + } + + this.isLayoutFinished = true; + + return isLayoutSuccessfull; + }; + + /** + * This method performs the operations required after layout. + */ + Layout.prototype.doPostLayout = function () { + //assert !isSubLayout : "Should not be called on sub-layout!"; + // Propagate geometric changes to v-level objects + if (!this.incremental) { + this.transform(); + } + this.update(); + }; + + /** + * This method updates the geometry of the target graph according to + * calculated layout. + */ + Layout.prototype.update2 = function () { + // update bend points + if (this.createBendsAsNeeded) { + this.createBendpointsFromDummyNodes(); + + // reset all edges, since the topology has changed + this.graphManager.resetAllEdges(); + } + + // perform edge, node and root updates if layout is not called + // remotely + if (!this.isRemoteUse) { + var allEdges = this.graphManager.getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + allEdges[i]; + // this.update(edge); + } + var nodes = this.graphManager.getRoot().getNodes(); + for (var i = 0; i < nodes.length; i++) { + nodes[i]; + // this.update(node); + } + + // update root graph + this.update(this.graphManager.getRoot()); + } + }; + + Layout.prototype.update = function (obj) { + if (obj == null) { + this.update2(); + } else if (obj instanceof LNode) { + var node = obj; + if (node.getChild() != null) { + // since node is compound, recursively update child nodes + var nodes = node.getChild().getNodes(); + for (var i = 0; i < nodes.length; i++) { + update(nodes[i]); + } + } + + // if the l-level node is associated with a v-level graph object, + // then it is assumed that the v-level node implements the + // interface Updatable. + if (node.vGraphObject != null) { + // cast to Updatable without any type check + var vNode = node.vGraphObject; + + // call the update method of the interface + vNode.update(node); + } + } else if (obj instanceof LEdge) { + var edge = obj; + // if the l-level edge is associated with a v-level graph object, + // then it is assumed that the v-level edge implements the + // interface Updatable. + + if (edge.vGraphObject != null) { + // cast to Updatable without any type check + var vEdge = edge.vGraphObject; + + // call the update method of the interface + vEdge.update(edge); + } + } else if (obj instanceof LGraph) { + var graph = obj; + // if the l-level graph is associated with a v-level graph object, + // then it is assumed that the v-level object implements the + // interface Updatable. + + if (graph.vGraphObject != null) { + // cast to Updatable without any type check + var vGraph = graph.vGraphObject; + + // call the update method of the interface + vGraph.update(graph); + } + } + }; + + /** + * This method is used to set all layout parameters to default values + * determined at compile time. + */ + Layout.prototype.initParameters = function () { + if (!this.isSubLayout) { + this.layoutQuality = LayoutConstants.QUALITY; + this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT; + this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD; + this.animationOnLayout = LayoutConstants.DEFAULT_ANIMATION_ON_LAYOUT; + this.incremental = LayoutConstants.DEFAULT_INCREMENTAL; + this.createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES; + } + + if (this.animationDuringLayout) { + this.animationOnLayout = false; + } + }; + + Layout.prototype.transform = function (newLeftTop) { + if (newLeftTop == undefined) { + this.transform(new PointD(0, 0)); + } else { + // create a transformation object (from Eclipse to layout). When an + // inverse transform is applied, we get upper-left coordinate of the + // drawing or the root graph at given input coordinate (some margins + // already included in calculation of left-top). + + var trans = new Transform(); + var leftTop = this.graphManager.getRoot().updateLeftTop(); + + if (leftTop != null) { + trans.setWorldOrgX(newLeftTop.x); + trans.setWorldOrgY(newLeftTop.y); + + trans.setDeviceOrgX(leftTop.x); + trans.setDeviceOrgY(leftTop.y); + + var nodes = this.getAllNodes(); + var node; + + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + node.transform(trans); + } + } + } + }; + + Layout.prototype.positionNodesRandomly = function (graph) { + + if (graph == undefined) { + //assert !this.incremental; + this.positionNodesRandomly(this.getGraphManager().getRoot()); + this.getGraphManager().getRoot().updateBounds(true); + } else { + var lNode; + var childGraph; + + var nodes = graph.getNodes(); + for (var i = 0; i < nodes.length; i++) { + lNode = nodes[i]; + childGraph = lNode.getChild(); + + if (childGraph == null) { + lNode.scatter(); + } else if (childGraph.getNodes().length == 0) { + lNode.scatter(); + } else { + this.positionNodesRandomly(childGraph); + lNode.updateBounds(); + } + } + } + }; + + /** + * This method returns a list of trees where each tree is represented as a + * list of l-nodes. The method returns a list of size 0 when: + * - The graph is not flat or + * - One of the component(s) of the graph is not a tree. + */ + Layout.prototype.getFlatForest = function () { + var flatForest = []; + var isForest = true; + + // Quick reference for all nodes in the graph manager associated with + // this layout. The list should not be changed. + var allNodes = this.graphManager.getRoot().getNodes(); + + // First be sure that the graph is flat + var isFlat = true; + + for (var i = 0; i < allNodes.length; i++) { + if (allNodes[i].getChild() != null) { + isFlat = false; + } + } + + // Return empty forest if the graph is not flat. + if (!isFlat) { + return flatForest; + } + + // Run BFS for each component of the graph. + + var visited = new Set(); + var toBeVisited = []; + var parents = new Map(); + var unProcessedNodes = []; + + unProcessedNodes = unProcessedNodes.concat(allNodes); + + // Each iteration of this loop finds a component of the graph and + // decides whether it is a tree or not. If it is a tree, adds it to the + // forest and continued with the next component. + + while (unProcessedNodes.length > 0 && isForest) { + toBeVisited.push(unProcessedNodes[0]); + + // Start the BFS. Each iteration of this loop visits a node in a + // BFS manner. + while (toBeVisited.length > 0 && isForest) { + //pool operation + var currentNode = toBeVisited[0]; + toBeVisited.splice(0, 1); + visited.add(currentNode); + + // Traverse all neighbors of this node + var neighborEdges = currentNode.getEdges(); + + for (var i = 0; i < neighborEdges.length; i++) { + var currentNeighbor = neighborEdges[i].getOtherEnd(currentNode); + + // If BFS is not growing from this neighbor. + if (parents.get(currentNode) != currentNeighbor) { + // We haven't previously visited this neighbor. + if (!visited.has(currentNeighbor)) { + toBeVisited.push(currentNeighbor); + parents.set(currentNeighbor, currentNode); + } + // Since we have previously visited this neighbor and + // this neighbor is not parent of currentNode, given + // graph contains a component that is not tree, hence + // it is not a forest. + else { + isForest = false; + break; + } + } + } + } + + // The graph contains a component that is not a tree. Empty + // previously found trees. The method will end. + if (!isForest) { + flatForest = []; + } + // Save currently visited nodes as a tree in our forest. Reset + // visited and parents lists. Continue with the next component of + // the graph, if any. + else { + var temp = [].concat(_toConsumableArray(visited)); + flatForest.push(temp); + //flatForest = flatForest.concat(temp); + //unProcessedNodes.removeAll(visited); + for (var i = 0; i < temp.length; i++) { + var value = temp[i]; + var index = unProcessedNodes.indexOf(value); + if (index > -1) { + unProcessedNodes.splice(index, 1); + } + } + visited = new Set(); + parents = new Map(); + } + } + + return flatForest; + }; + + /** + * This method creates dummy nodes (an l-level node with minimal dimensions) + * for the given edge (one per bendpoint). The existing l-level structure + * is updated accordingly. + */ + Layout.prototype.createDummyNodesForBendpoints = function (edge) { + var dummyNodes = []; + var prev = edge.source; + + var graph = this.graphManager.calcLowestCommonAncestor(edge.source, edge.target); + + for (var i = 0; i < edge.bendpoints.length; i++) { + // create new dummy node + var dummyNode = this.newNode(null); + dummyNode.setRect(new Point(0, 0), new Dimension(1, 1)); + + graph.add(dummyNode); + + // create new dummy edge between prev and dummy node + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, dummyNode); + + dummyNodes.add(dummyNode); + prev = dummyNode; + } + + var dummyEdge = this.newEdge(null); + this.graphManager.add(dummyEdge, prev, edge.target); + + this.edgeToDummyNodes.set(edge, dummyNodes); + + // remove real edge from graph manager if it is inter-graph + if (edge.isInterGraph()) { + this.graphManager.remove(edge); + } + // else, remove the edge from the current graph + else { + graph.remove(edge); + } + + return dummyNodes; + }; + + /** + * This method creates bendpoints for edges from the dummy nodes + * at l-level. + */ + Layout.prototype.createBendpointsFromDummyNodes = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + edges = [].concat(_toConsumableArray(this.edgeToDummyNodes.keys())).concat(edges); + + for (var k = 0; k < edges.length; k++) { + var lEdge = edges[k]; + + if (lEdge.bendpoints.length > 0) { + var path = this.edgeToDummyNodes.get(lEdge); + + for (var i = 0; i < path.length; i++) { + var dummyNode = path[i]; + var p = new PointD(dummyNode.getCenterX(), dummyNode.getCenterY()); + + // update bendpoint's location according to dummy node + var ebp = lEdge.bendpoints.get(i); + ebp.x = p.x; + ebp.y = p.y; + + // remove the dummy node, dummy edges incident with this + // dummy node is also removed (within the remove method) + dummyNode.getOwner().remove(dummyNode); + } + + // add the real edge to graph + this.graphManager.add(lEdge, lEdge.source, lEdge.target); + } + } + }; + + Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) { + if (minDiv != undefined && maxMul != undefined) { + var value = defaultValue; + + if (sliderValue <= 50) { + var minValue = defaultValue / minDiv; + value -= (defaultValue - minValue) / 50 * (50 - sliderValue); + } else { + var maxValue = defaultValue * maxMul; + value += (maxValue - defaultValue) / 50 * (sliderValue - 50); + } + + return value; + } else { + var a, b; + + if (sliderValue <= 50) { + a = 9.0 * defaultValue / 500.0; + b = defaultValue / 10.0; + } else { + a = 9.0 * defaultValue / 50.0; + b = -8 * defaultValue; + } + + return a * sliderValue + b; + } + }; + + /** + * This method finds and returns the center of the given nodes, assuming + * that the given nodes form a tree in themselves. + */ + Layout.findCenterOfTree = function (nodes) { + var list = []; + list = list.concat(nodes); + + var removedNodes = []; + var remainingDegrees = new Map(); + var foundCenter = false; + var centerNode = null; + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + var degree = node.getNeighborsList().size; + remainingDegrees.set(node, node.getNeighborsList().size); + + if (degree == 1) { + removedNodes.push(node); + } + } + + var tempList = []; + tempList = tempList.concat(removedNodes); + + while (!foundCenter) { + var tempList2 = []; + tempList2 = tempList2.concat(tempList); + tempList = []; + + for (var i = 0; i < list.length; i++) { + var node = list[i]; + + var index = list.indexOf(node); + if (index >= 0) { + list.splice(index, 1); + } + + var neighbours = node.getNeighborsList(); + + neighbours.forEach(function (neighbour) { + if (removedNodes.indexOf(neighbour) < 0) { + var otherDegree = remainingDegrees.get(neighbour); + var newDegree = otherDegree - 1; + + if (newDegree == 1) { + tempList.push(neighbour); + } + + remainingDegrees.set(neighbour, newDegree); + } + }); + } + + removedNodes = removedNodes.concat(tempList); + + if (list.length == 1 || list.length == 2) { + foundCenter = true; + centerNode = list[0]; + } + } + + return centerNode; + }; + + /** + * During the coarsening process, this layout may be referenced by two graph managers + * this setter function grants access to change the currently being used graph manager + */ + Layout.prototype.setGraphManager = function (gm) { + this.graphManager = gm; + }; + + module.exports = Layout; + + /***/ }), + /* 16 */ + /***/ (function(module, exports, __webpack_require__) { + + + function RandomSeed() {} + // adapted from: https://stackoverflow.com/a/19303725 + RandomSeed.seed = 1; + RandomSeed.x = 0; + + RandomSeed.nextDouble = function () { + RandomSeed.x = Math.sin(RandomSeed.seed++) * 10000; + return RandomSeed.x - Math.floor(RandomSeed.x); + }; + + module.exports = RandomSeed; + + /***/ }), + /* 17 */ + /***/ (function(module, exports, __webpack_require__) { + + + var PointD = __webpack_require__(4); + + function Transform(x, y) { + this.lworldOrgX = 0.0; + this.lworldOrgY = 0.0; + this.ldeviceOrgX = 0.0; + this.ldeviceOrgY = 0.0; + this.lworldExtX = 1.0; + this.lworldExtY = 1.0; + this.ldeviceExtX = 1.0; + this.ldeviceExtY = 1.0; + } + + Transform.prototype.getWorldOrgX = function () { + return this.lworldOrgX; + }; + + Transform.prototype.setWorldOrgX = function (wox) { + this.lworldOrgX = wox; + }; + + Transform.prototype.getWorldOrgY = function () { + return this.lworldOrgY; + }; + + Transform.prototype.setWorldOrgY = function (woy) { + this.lworldOrgY = woy; + }; + + Transform.prototype.getWorldExtX = function () { + return this.lworldExtX; + }; + + Transform.prototype.setWorldExtX = function (wex) { + this.lworldExtX = wex; + }; + + Transform.prototype.getWorldExtY = function () { + return this.lworldExtY; + }; + + Transform.prototype.setWorldExtY = function (wey) { + this.lworldExtY = wey; + }; + + /* Device related */ + + Transform.prototype.getDeviceOrgX = function () { + return this.ldeviceOrgX; + }; + + Transform.prototype.setDeviceOrgX = function (dox) { + this.ldeviceOrgX = dox; + }; + + Transform.prototype.getDeviceOrgY = function () { + return this.ldeviceOrgY; + }; + + Transform.prototype.setDeviceOrgY = function (doy) { + this.ldeviceOrgY = doy; + }; + + Transform.prototype.getDeviceExtX = function () { + return this.ldeviceExtX; + }; + + Transform.prototype.setDeviceExtX = function (dex) { + this.ldeviceExtX = dex; + }; + + Transform.prototype.getDeviceExtY = function () { + return this.ldeviceExtY; + }; + + Transform.prototype.setDeviceExtY = function (dey) { + this.ldeviceExtY = dey; + }; + + Transform.prototype.transformX = function (x) { + var xDevice = 0.0; + var worldExtX = this.lworldExtX; + if (worldExtX != 0.0) { + xDevice = this.ldeviceOrgX + (x - this.lworldOrgX) * this.ldeviceExtX / worldExtX; + } + + return xDevice; + }; + + Transform.prototype.transformY = function (y) { + var yDevice = 0.0; + var worldExtY = this.lworldExtY; + if (worldExtY != 0.0) { + yDevice = this.ldeviceOrgY + (y - this.lworldOrgY) * this.ldeviceExtY / worldExtY; + } + + return yDevice; + }; + + Transform.prototype.inverseTransformX = function (x) { + var xWorld = 0.0; + var deviceExtX = this.ldeviceExtX; + if (deviceExtX != 0.0) { + xWorld = this.lworldOrgX + (x - this.ldeviceOrgX) * this.lworldExtX / deviceExtX; + } + + return xWorld; + }; + + Transform.prototype.inverseTransformY = function (y) { + var yWorld = 0.0; + var deviceExtY = this.ldeviceExtY; + if (deviceExtY != 0.0) { + yWorld = this.lworldOrgY + (y - this.ldeviceOrgY) * this.lworldExtY / deviceExtY; + } + return yWorld; + }; + + Transform.prototype.inverseTransformPoint = function (inPoint) { + var outPoint = new PointD(this.inverseTransformX(inPoint.x), this.inverseTransformY(inPoint.y)); + return outPoint; + }; + + module.exports = Transform; + + /***/ }), + /* 18 */ + /***/ (function(module, exports, __webpack_require__) { + + + function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + + var Layout = __webpack_require__(15); + var FDLayoutConstants = __webpack_require__(7); + var LayoutConstants = __webpack_require__(0); + var IGeometry = __webpack_require__(8); + var IMath = __webpack_require__(9); + + function FDLayout() { + Layout.call(this); + + this.useSmartIdealEdgeLengthCalculation = FDLayoutConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.idealEdgeLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + this.displacementThresholdPerNode = 3.0 * FDLayoutConstants.DEFAULT_EDGE_LENGTH / 100; + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.initialCoolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + this.totalDisplacement = 0.0; + this.oldTotalDisplacement = 0.0; + this.maxIterations = FDLayoutConstants.MAX_ITERATIONS; + } + + FDLayout.prototype = Object.create(Layout.prototype); + + for (var prop in Layout) { + FDLayout[prop] = Layout[prop]; + } + + FDLayout.prototype.initParameters = function () { + Layout.prototype.initParameters.call(this, arguments); + + this.totalIterations = 0; + this.notAnimatedIterations = 0; + + this.useFRGridVariant = FDLayoutConstants.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION; + + this.grid = []; + }; + + FDLayout.prototype.calcIdealEdgeLengths = function () { + var edge; + var lcaDepth; + var source; + var target; + var sizeOfSourceInLca; + var sizeOfTargetInLca; + + var allEdges = this.getGraphManager().getAllEdges(); + for (var i = 0; i < allEdges.length; i++) { + edge = allEdges[i]; + + edge.idealLength = this.idealEdgeLength; + + if (edge.isInterGraph) { + source = edge.getSource(); + target = edge.getTarget(); + + sizeOfSourceInLca = edge.getSourceInLca().getEstimatedSize(); + sizeOfTargetInLca = edge.getTargetInLca().getEstimatedSize(); + + if (this.useSmartIdealEdgeLengthCalculation) { + edge.idealLength += sizeOfSourceInLca + sizeOfTargetInLca - 2 * LayoutConstants.SIMPLE_NODE_SIZE; + } + + lcaDepth = edge.getLca().getInclusionTreeDepth(); + + edge.idealLength += FDLayoutConstants.DEFAULT_EDGE_LENGTH * FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR * (source.getInclusionTreeDepth() + target.getInclusionTreeDepth() - 2 * lcaDepth); + } + } + }; + + FDLayout.prototype.initSpringEmbedder = function () { + + var s = this.getAllNodes().length; + if (this.incremental) { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(this.coolingFactor * FDLayoutConstants.COOLING_ADAPTATION_FACTOR, this.coolingFactor - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * this.coolingFactor * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT_INCREMENTAL; + } else { + if (s > FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) { + this.coolingFactor = Math.max(FDLayoutConstants.COOLING_ADAPTATION_FACTOR, 1.0 - (s - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) / (FDLayoutConstants.ADAPTATION_UPPER_NODE_LIMIT - FDLayoutConstants.ADAPTATION_LOWER_NODE_LIMIT) * (1 - FDLayoutConstants.COOLING_ADAPTATION_FACTOR)); + } else { + this.coolingFactor = 1.0; + } + this.initialCoolingFactor = this.coolingFactor; + this.maxNodeDisplacement = FDLayoutConstants.MAX_NODE_DISPLACEMENT; + } + + this.maxIterations = Math.max(this.getAllNodes().length * 5, this.maxIterations); + + this.totalDisplacementThreshold = this.displacementThresholdPerNode * this.getAllNodes().length; + + this.repulsionRange = this.calcRepulsionRange(); + }; + + FDLayout.prototype.calcSpringForces = function () { + var lEdges = this.getAllEdges(); + var edge; + + for (var i = 0; i < lEdges.length; i++) { + edge = lEdges[i]; + + this.calcSpringForce(edge, edge.idealLength); + } + }; + + FDLayout.prototype.calcRepulsionForces = function () { + var gridUpdateAllowed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + var forceToNodeSurroundingUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + + var i, j; + var nodeA, nodeB; + var lNodes = this.getAllNodes(); + var processedNodeSet; + + if (this.useFRGridVariant) { + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed) { + this.updateGrid(); + } + + processedNodeSet = new Set(); + + // calculate repulsion forces between each nodes and its surrounding + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.calculateRepulsionForceOfANode(nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate); + processedNodeSet.add(nodeA); + } + } else { + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + + for (j = i + 1; j < lNodes.length; j++) { + nodeB = lNodes[j]; + + // If both nodes are not members of the same graph, skip. + if (nodeA.getOwner() != nodeB.getOwner()) { + continue; + } + + this.calcRepulsionForce(nodeA, nodeB); + } + } + } + }; + + FDLayout.prototype.calcGravitationalForces = function () { + var node; + var lNodes = this.getAllNodesToApplyGravitation(); + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + this.calcGravitationalForce(node); + } + }; + + FDLayout.prototype.moveNodes = function () { + var lNodes = this.getAllNodes(); + var node; + + for (var i = 0; i < lNodes.length; i++) { + node = lNodes[i]; + node.move(); + } + }; + + FDLayout.prototype.calcSpringForce = function (edge, idealLength) { + var sourceNode = edge.getSource(); + var targetNode = edge.getTarget(); + + var length; + var springForce; + var springForceX; + var springForceY; + + // Update edge length + if (this.uniformLeafNodeSizes && sourceNode.getChild() == null && targetNode.getChild() == null) { + edge.updateLengthSimple(); + } else { + edge.updateLength(); + + if (edge.isOverlapingSourceAndTarget) { + return; + } + } + + length = edge.getLength(); + + if (length == 0) return; + + // Calculate spring forces + springForce = this.springConstant * (length - idealLength); + + // Project force onto x and y axes + springForceX = springForce * (edge.lengthX / length); + springForceY = springForce * (edge.lengthY / length); + + // Apply forces on the end nodes + sourceNode.springForceX += springForceX; + sourceNode.springForceY += springForceY; + targetNode.springForceX -= springForceX; + targetNode.springForceY -= springForceY; + }; + + FDLayout.prototype.calcRepulsionForce = function (nodeA, nodeB) { + var rectA = nodeA.getRect(); + var rectB = nodeB.getRect(); + var overlapAmount = new Array(2); + var clipPoints = new Array(4); + var distanceX; + var distanceY; + var distanceSquared; + var distance; + var repulsionForce; + var repulsionForceX; + var repulsionForceY; + + if (rectA.intersects(rectB)) // two nodes overlap + { + // calculate separation amount in x and y directions + IGeometry.calcSeparationAmount(rectA, rectB, overlapAmount, FDLayoutConstants.DEFAULT_EDGE_LENGTH / 2.0); + + repulsionForceX = 2 * overlapAmount[0]; + repulsionForceY = 2 * overlapAmount[1]; + + var childrenConstant = nodeA.noOfChildren * nodeB.noOfChildren / (nodeA.noOfChildren + nodeB.noOfChildren); + + // Apply forces on the two nodes + nodeA.repulsionForceX -= childrenConstant * repulsionForceX; + nodeA.repulsionForceY -= childrenConstant * repulsionForceY; + nodeB.repulsionForceX += childrenConstant * repulsionForceX; + nodeB.repulsionForceY += childrenConstant * repulsionForceY; + } else // no overlap + { + // calculate distance + + if (this.uniformLeafNodeSizes && nodeA.getChild() == null && nodeB.getChild() == null) // simply base repulsion on distance of node centers + { + distanceX = rectB.getCenterX() - rectA.getCenterX(); + distanceY = rectB.getCenterY() - rectA.getCenterY(); + } else // use clipping points + { + IGeometry.getIntersection(rectA, rectB, clipPoints); + + distanceX = clipPoints[2] - clipPoints[0]; + distanceY = clipPoints[3] - clipPoints[1]; + } + + // No repulsion range. FR grid variant should take care of this. + if (Math.abs(distanceX) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceX = IMath.sign(distanceX) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + if (Math.abs(distanceY) < FDLayoutConstants.MIN_REPULSION_DIST) { + distanceY = IMath.sign(distanceY) * FDLayoutConstants.MIN_REPULSION_DIST; + } + + distanceSquared = distanceX * distanceX + distanceY * distanceY; + distance = Math.sqrt(distanceSquared); + + repulsionForce = this.repulsionConstant * nodeA.noOfChildren * nodeB.noOfChildren / distanceSquared; + + // Project force onto x and y axes + repulsionForceX = repulsionForce * distanceX / distance; + repulsionForceY = repulsionForce * distanceY / distance; + + // Apply forces on the two nodes + nodeA.repulsionForceX -= repulsionForceX; + nodeA.repulsionForceY -= repulsionForceY; + nodeB.repulsionForceX += repulsionForceX; + nodeB.repulsionForceY += repulsionForceY; + } + }; + + FDLayout.prototype.calcGravitationalForce = function (node) { + var ownerGraph; + var ownerCenterX; + var ownerCenterY; + var distanceX; + var distanceY; + var absDistanceX; + var absDistanceY; + var estimatedSize; + ownerGraph = node.getOwner(); + + ownerCenterX = (ownerGraph.getRight() + ownerGraph.getLeft()) / 2; + ownerCenterY = (ownerGraph.getTop() + ownerGraph.getBottom()) / 2; + distanceX = node.getCenterX() - ownerCenterX; + distanceY = node.getCenterY() - ownerCenterY; + absDistanceX = Math.abs(distanceX) + node.getWidth() / 2; + absDistanceY = Math.abs(distanceY) + node.getHeight() / 2; + + if (node.getOwner() == this.graphManager.getRoot()) // in the root graph + { + estimatedSize = ownerGraph.getEstimatedSize() * this.gravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX; + node.gravitationForceY = -this.gravityConstant * distanceY; + } + } else // inside a compound + { + estimatedSize = ownerGraph.getEstimatedSize() * this.compoundGravityRangeFactor; + + if (absDistanceX > estimatedSize || absDistanceY > estimatedSize) { + node.gravitationForceX = -this.gravityConstant * distanceX * this.compoundGravityConstant; + node.gravitationForceY = -this.gravityConstant * distanceY * this.compoundGravityConstant; + } + } + }; + + FDLayout.prototype.isConverged = function () { + var converged; + var oscilating = false; + + if (this.totalIterations > this.maxIterations / 3) { + oscilating = Math.abs(this.totalDisplacement - this.oldTotalDisplacement) < 2; + } + + converged = this.totalDisplacement < this.totalDisplacementThreshold; + + this.oldTotalDisplacement = this.totalDisplacement; + + return converged || oscilating; + }; + + FDLayout.prototype.animate = function () { + if (this.animationDuringLayout && !this.isSubLayout) { + if (this.notAnimatedIterations == this.animationPeriod) { + this.update(); + this.notAnimatedIterations = 0; + } else { + this.notAnimatedIterations++; + } + } + }; + + //This method calculates the number of children (weight) for all nodes + FDLayout.prototype.calcNoOfChildrenForAllNodes = function () { + var node; + var allNodes = this.graphManager.getAllNodes(); + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + node.noOfChildren = node.getNoOfChildren(); + } + }; + + // ----------------------------------------------------------------------------- + // Section: FR-Grid Variant Repulsion Force Calculation + // ----------------------------------------------------------------------------- + + FDLayout.prototype.calcGrid = function (graph) { + + var sizeX = 0; + var sizeY = 0; + + sizeX = parseInt(Math.ceil((graph.getRight() - graph.getLeft()) / this.repulsionRange)); + sizeY = parseInt(Math.ceil((graph.getBottom() - graph.getTop()) / this.repulsionRange)); + + var grid = new Array(sizeX); + + for (var i = 0; i < sizeX; i++) { + grid[i] = new Array(sizeY); + } + + for (var i = 0; i < sizeX; i++) { + for (var j = 0; j < sizeY; j++) { + grid[i][j] = new Array(); + } + } + + return grid; + }; + + FDLayout.prototype.addNodeToGrid = function (v, left, top) { + + var startX = 0; + var finishX = 0; + var startY = 0; + var finishY = 0; + + startX = parseInt(Math.floor((v.getRect().x - left) / this.repulsionRange)); + finishX = parseInt(Math.floor((v.getRect().width + v.getRect().x - left) / this.repulsionRange)); + startY = parseInt(Math.floor((v.getRect().y - top) / this.repulsionRange)); + finishY = parseInt(Math.floor((v.getRect().height + v.getRect().y - top) / this.repulsionRange)); + + for (var i = startX; i <= finishX; i++) { + for (var j = startY; j <= finishY; j++) { + this.grid[i][j].push(v); + v.setGridCoordinates(startX, finishX, startY, finishY); + } + } + }; + + FDLayout.prototype.updateGrid = function () { + var i; + var nodeA; + var lNodes = this.getAllNodes(); + + this.grid = this.calcGrid(this.graphManager.getRoot()); + + // put all nodes to proper grid cells + for (i = 0; i < lNodes.length; i++) { + nodeA = lNodes[i]; + this.addNodeToGrid(nodeA, this.graphManager.getRoot().getLeft(), this.graphManager.getRoot().getTop()); + } + }; + + FDLayout.prototype.calculateRepulsionForceOfANode = function (nodeA, processedNodeSet, gridUpdateAllowed, forceToNodeSurroundingUpdate) { + + if (this.totalIterations % FDLayoutConstants.GRID_CALCULATION_CHECK_PERIOD == 1 && gridUpdateAllowed || forceToNodeSurroundingUpdate) { + var surrounding = new Set(); + nodeA.surrounding = new Array(); + var nodeB; + var grid = this.grid; + + for (var i = nodeA.startX - 1; i < nodeA.finishX + 2; i++) { + for (var j = nodeA.startY - 1; j < nodeA.finishY + 2; j++) { + if (!(i < 0 || j < 0 || i >= grid.length || j >= grid[0].length)) { + for (var k = 0; k < grid[i][j].length; k++) { + nodeB = grid[i][j][k]; + + // If both nodes are not members of the same graph, + // or both nodes are the same, skip. + if (nodeA.getOwner() != nodeB.getOwner() || nodeA == nodeB) { + continue; + } + + // check if the repulsion force between + // nodeA and nodeB has already been calculated + if (!processedNodeSet.has(nodeB) && !surrounding.has(nodeB)) { + var distanceX = Math.abs(nodeA.getCenterX() - nodeB.getCenterX()) - (nodeA.getWidth() / 2 + nodeB.getWidth() / 2); + var distanceY = Math.abs(nodeA.getCenterY() - nodeB.getCenterY()) - (nodeA.getHeight() / 2 + nodeB.getHeight() / 2); + + // if the distance between nodeA and nodeB + // is less then calculation range + if (distanceX <= this.repulsionRange && distanceY <= this.repulsionRange) { + //then add nodeB to surrounding of nodeA + surrounding.add(nodeB); + } + } + } + } + } + } + + nodeA.surrounding = [].concat(_toConsumableArray(surrounding)); + } + for (i = 0; i < nodeA.surrounding.length; i++) { + this.calcRepulsionForce(nodeA, nodeA.surrounding[i]); + } + }; + + FDLayout.prototype.calcRepulsionRange = function () { + return 0.0; + }; + + module.exports = FDLayout; + + /***/ }), + /* 19 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LEdge = __webpack_require__(1); + var FDLayoutConstants = __webpack_require__(7); + + function FDLayoutEdge(source, target, vEdge) { + LEdge.call(this, source, target, vEdge); + this.idealLength = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + } + + FDLayoutEdge.prototype = Object.create(LEdge.prototype); + + for (var prop in LEdge) { + FDLayoutEdge[prop] = LEdge[prop]; + } + + module.exports = FDLayoutEdge; + + /***/ }), + /* 20 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LNode = __webpack_require__(3); + + function FDLayoutNode(gm, loc, size, vNode) { + // alternative constructor is handled inside LNode + LNode.call(this, gm, loc, size, vNode); + //Spring, repulsion and gravitational forces acting on this node + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + //Amount by which this node is to be moved in this iteration + this.displacementX = 0; + this.displacementY = 0; + + //Start and finish grid coordinates that this node is fallen into + this.startX = 0; + this.finishX = 0; + this.startY = 0; + this.finishY = 0; + + //Geometric neighbors of this node + this.surrounding = []; + } + + FDLayoutNode.prototype = Object.create(LNode.prototype); + + for (var prop in LNode) { + FDLayoutNode[prop] = LNode[prop]; + } + + FDLayoutNode.prototype.setGridCoordinates = function (_startX, _finishX, _startY, _finishY) { + this.startX = _startX; + this.finishX = _finishX; + this.startY = _startY; + this.finishY = _finishY; + }; + + module.exports = FDLayoutNode; + + /***/ }), + /* 21 */ + /***/ (function(module, exports, __webpack_require__) { + + + function DimensionD(width, height) { + this.width = 0; + this.height = 0; + if (width !== null && height !== null) { + this.height = height; + this.width = width; + } + } + + DimensionD.prototype.getWidth = function () { + return this.width; + }; + + DimensionD.prototype.setWidth = function (width) { + this.width = width; + }; + + DimensionD.prototype.getHeight = function () { + return this.height; + }; + + DimensionD.prototype.setHeight = function (height) { + this.height = height; + }; + + module.exports = DimensionD; + + /***/ }), + /* 22 */ + /***/ (function(module, exports, __webpack_require__) { + + + var UniqueIDGeneretor = __webpack_require__(14); + + function HashMap() { + this.map = {}; + this.keys = []; + } + + HashMap.prototype.put = function (key, value) { + var theId = UniqueIDGeneretor.createID(key); + if (!this.contains(theId)) { + this.map[theId] = value; + this.keys.push(key); + } + }; + + HashMap.prototype.contains = function (key) { + UniqueIDGeneretor.createID(key); + return this.map[key] != null; + }; + + HashMap.prototype.get = function (key) { + var theId = UniqueIDGeneretor.createID(key); + return this.map[theId]; + }; + + HashMap.prototype.keySet = function () { + return this.keys; + }; + + module.exports = HashMap; + + /***/ }), + /* 23 */ + /***/ (function(module, exports, __webpack_require__) { + + + var UniqueIDGeneretor = __webpack_require__(14); + + function HashSet() { + this.set = {}; + } + + HashSet.prototype.add = function (obj) { + var theId = UniqueIDGeneretor.createID(obj); + if (!this.contains(theId)) this.set[theId] = obj; + }; + + HashSet.prototype.remove = function (obj) { + delete this.set[UniqueIDGeneretor.createID(obj)]; + }; + + HashSet.prototype.clear = function () { + this.set = {}; + }; + + HashSet.prototype.contains = function (obj) { + return this.set[UniqueIDGeneretor.createID(obj)] == obj; + }; + + HashSet.prototype.isEmpty = function () { + return this.size() === 0; + }; + + HashSet.prototype.size = function () { + return Object.keys(this.set).length; + }; + + //concats this.set to the given list + HashSet.prototype.addAllTo = function (list) { + var keys = Object.keys(this.set); + var length = keys.length; + for (var i = 0; i < length; i++) { + list.push(this.set[keys[i]]); + } + }; + + HashSet.prototype.size = function () { + return Object.keys(this.set).length; + }; + + HashSet.prototype.addAll = function (list) { + var s = list.length; + for (var i = 0; i < s; i++) { + var v = list[i]; + this.add(v); + } + }; + + module.exports = HashSet; + + /***/ }), + /* 24 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * A classic Quicksort algorithm with Hoare's partition + * - Works also on LinkedList objects + * + * Copyright: i-Vis Research Group, Bilkent University, 2007 - present + */ + + var LinkedList = __webpack_require__(11); + + var Quicksort = function () { + function Quicksort(A, compareFunction) { + _classCallCheck(this, Quicksort); + + if (compareFunction !== null || compareFunction !== undefined) this.compareFunction = this._defaultCompareFunction; + + var length = void 0; + if (A instanceof LinkedList) length = A.size();else length = A.length; + + this._quicksort(A, 0, length - 1); + } + + _createClass(Quicksort, [{ + key: '_quicksort', + value: function _quicksort(A, p, r) { + if (p < r) { + var q = this._partition(A, p, r); + this._quicksort(A, p, q); + this._quicksort(A, q + 1, r); + } + } + }, { + key: '_partition', + value: function _partition(A, p, r) { + var x = this._get(A, p); + var i = p; + var j = r; + while (true) { + while (this.compareFunction(x, this._get(A, j))) { + j--; + }while (this.compareFunction(this._get(A, i), x)) { + i++; + }if (i < j) { + this._swap(A, i, j); + i++; + j--; + } else return j; + } + } + }, { + key: '_get', + value: function _get(object, index) { + if (object instanceof LinkedList) return object.get_object_at(index);else return object[index]; + } + }, { + key: '_set', + value: function _set(object, index, value) { + if (object instanceof LinkedList) object.set_object_at(index, value);else object[index] = value; + } + }, { + key: '_swap', + value: function _swap(A, i, j) { + var temp = this._get(A, i); + this._set(A, i, this._get(A, j)); + this._set(A, j, temp); + } + }, { + key: '_defaultCompareFunction', + value: function _defaultCompareFunction(a, b) { + return b > a; + } + }]); + + return Quicksort; + }(); + + module.exports = Quicksort; + + /***/ }), + /* 25 */ + /***/ (function(module, exports, __webpack_require__) { + + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + /** + * Needleman-Wunsch algorithm is an procedure to compute the optimal global alignment of two string + * sequences by S.B.Needleman and C.D.Wunsch (1970). + * + * Aside from the inputs, you can assign the scores for, + * - Match: The two characters at the current index are same. + * - Mismatch: The two characters at the current index are different. + * - Insertion/Deletion(gaps): The best alignment involves one letter aligning to a gap in the other string. + */ + + var NeedlemanWunsch = function () { + function NeedlemanWunsch(sequence1, sequence2) { + var match_score = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + var mismatch_penalty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1; + var gap_penalty = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : -1; + + _classCallCheck(this, NeedlemanWunsch); + + this.sequence1 = sequence1; + this.sequence2 = sequence2; + this.match_score = match_score; + this.mismatch_penalty = mismatch_penalty; + this.gap_penalty = gap_penalty; + + // Just the remove redundancy + this.iMax = sequence1.length + 1; + this.jMax = sequence2.length + 1; + + // Grid matrix of scores + this.grid = new Array(this.iMax); + for (var i = 0; i < this.iMax; i++) { + this.grid[i] = new Array(this.jMax); + + for (var j = 0; j < this.jMax; j++) { + this.grid[i][j] = 0; + } + } + + // Traceback matrix (2D array, each cell is an array of boolean values for [`Diag`, `Up`, `Left`] positions) + this.tracebackGrid = new Array(this.iMax); + for (var _i = 0; _i < this.iMax; _i++) { + this.tracebackGrid[_i] = new Array(this.jMax); + + for (var _j = 0; _j < this.jMax; _j++) { + this.tracebackGrid[_i][_j] = [null, null, null]; + } + } + + // The aligned sequences (return multiple possibilities) + this.alignments = []; + + // Final alignment score + this.score = -1; + + // Calculate scores and tracebacks + this.computeGrids(); + } + + _createClass(NeedlemanWunsch, [{ + key: "getScore", + value: function getScore() { + return this.score; + } + }, { + key: "getAlignments", + value: function getAlignments() { + return this.alignments; + } + + // Main dynamic programming procedure + + }, { + key: "computeGrids", + value: function computeGrids() { + // Fill in the first row + for (var j = 1; j < this.jMax; j++) { + this.grid[0][j] = this.grid[0][j - 1] + this.gap_penalty; + this.tracebackGrid[0][j] = [false, false, true]; + } + + // Fill in the first column + for (var i = 1; i < this.iMax; i++) { + this.grid[i][0] = this.grid[i - 1][0] + this.gap_penalty; + this.tracebackGrid[i][0] = [false, true, false]; + } + + // Fill the rest of the grid + for (var _i2 = 1; _i2 < this.iMax; _i2++) { + for (var _j2 = 1; _j2 < this.jMax; _j2++) { + // Find the max score(s) among [`Diag`, `Up`, `Left`] + var diag = void 0; + if (this.sequence1[_i2 - 1] === this.sequence2[_j2 - 1]) diag = this.grid[_i2 - 1][_j2 - 1] + this.match_score;else diag = this.grid[_i2 - 1][_j2 - 1] + this.mismatch_penalty; + + var up = this.grid[_i2 - 1][_j2] + this.gap_penalty; + var left = this.grid[_i2][_j2 - 1] + this.gap_penalty; + + // If there exists multiple max values, capture them for multiple paths + var maxOf = [diag, up, left]; + var indices = this.arrayAllMaxIndexes(maxOf); + + // Update Grids + this.grid[_i2][_j2] = maxOf[indices[0]]; + this.tracebackGrid[_i2][_j2] = [indices.includes(0), indices.includes(1), indices.includes(2)]; + } + } + + // Update alignment score + this.score = this.grid[this.iMax - 1][this.jMax - 1]; + } + + // Gets all possible valid sequence combinations + + }, { + key: "alignmentTraceback", + value: function alignmentTraceback() { + var inProcessAlignments = []; + + inProcessAlignments.push({ pos: [this.sequence1.length, this.sequence2.length], + seq1: "", + seq2: "" + }); + + while (inProcessAlignments[0]) { + var current = inProcessAlignments[0]; + var directions = this.tracebackGrid[current.pos[0]][current.pos[1]]; + + if (directions[0]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1] - 1], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + if (directions[1]) { + inProcessAlignments.push({ pos: [current.pos[0] - 1, current.pos[1]], + seq1: this.sequence1[current.pos[0] - 1] + current.seq1, + seq2: '-' + current.seq2 + }); + } + if (directions[2]) { + inProcessAlignments.push({ pos: [current.pos[0], current.pos[1] - 1], + seq1: '-' + current.seq1, + seq2: this.sequence2[current.pos[1] - 1] + current.seq2 + }); + } + + if (current.pos[0] === 0 && current.pos[1] === 0) this.alignments.push({ sequence1: current.seq1, + sequence2: current.seq2 + }); + + inProcessAlignments.shift(); + } + + return this.alignments; + } + + // Helper Functions + + }, { + key: "getAllIndexes", + value: function getAllIndexes(arr, val) { + var indexes = [], + i = -1; + while ((i = arr.indexOf(val, i + 1)) !== -1) { + indexes.push(i); + } + return indexes; + } + }, { + key: "arrayAllMaxIndexes", + value: function arrayAllMaxIndexes(array) { + return this.getAllIndexes(array, Math.max.apply(null, array)); + } + }]); + + return NeedlemanWunsch; + }(); + + module.exports = NeedlemanWunsch; + + /***/ }), + /* 26 */ + /***/ (function(module, exports, __webpack_require__) { + + + var layoutBase = function layoutBase() { + return; + }; + + layoutBase.FDLayout = __webpack_require__(18); + layoutBase.FDLayoutConstants = __webpack_require__(7); + layoutBase.FDLayoutEdge = __webpack_require__(19); + layoutBase.FDLayoutNode = __webpack_require__(20); + layoutBase.DimensionD = __webpack_require__(21); + layoutBase.HashMap = __webpack_require__(22); + layoutBase.HashSet = __webpack_require__(23); + layoutBase.IGeometry = __webpack_require__(8); + layoutBase.IMath = __webpack_require__(9); + layoutBase.Integer = __webpack_require__(10); + layoutBase.Point = __webpack_require__(12); + layoutBase.PointD = __webpack_require__(4); + layoutBase.RandomSeed = __webpack_require__(16); + layoutBase.RectangleD = __webpack_require__(13); + layoutBase.Transform = __webpack_require__(17); + layoutBase.UniqueIDGeneretor = __webpack_require__(14); + layoutBase.Quicksort = __webpack_require__(24); + layoutBase.LinkedList = __webpack_require__(11); + layoutBase.LGraphObject = __webpack_require__(2); + layoutBase.LGraph = __webpack_require__(5); + layoutBase.LEdge = __webpack_require__(1); + layoutBase.LGraphManager = __webpack_require__(6); + layoutBase.LNode = __webpack_require__(3); + layoutBase.Layout = __webpack_require__(15); + layoutBase.LayoutConstants = __webpack_require__(0); + layoutBase.NeedlemanWunsch = __webpack_require__(25); + + module.exports = layoutBase; + + /***/ }), + /* 27 */ + /***/ (function(module, exports, __webpack_require__) { + + + function Emitter() { + this.listeners = []; + } + + var p = Emitter.prototype; + + p.addListener = function (event, callback) { + this.listeners.push({ + event: event, + callback: callback + }); + }; + + p.removeListener = function (event, callback) { + for (var i = this.listeners.length; i >= 0; i--) { + var l = this.listeners[i]; + + if (l.event === event && l.callback === callback) { + this.listeners.splice(i, 1); + } + } + }; + + p.emit = function (event, data) { + for (var i = 0; i < this.listeners.length; i++) { + var l = this.listeners[i]; + + if (event === l.event) { + l.callback(data); + } + } + }; + + module.exports = Emitter; + + /***/ }) + /******/ ]); + }); + } (layoutBase)); + return layoutBase.exports; +} + +var hasRequiredCoseBase; + +function requireCoseBase () { + if (hasRequiredCoseBase) return coseBase.exports; + hasRequiredCoseBase = 1; + (function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(requireLayoutBase()); + })(commonjsGlobal$1, function(__WEBPACK_EXTERNAL_MODULE_0__) { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 7); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants; + + function CoSEConstants() {} + + //CoSEConstants inherits static props in FDLayoutConstants + for (var prop in FDLayoutConstants) { + CoSEConstants[prop] = FDLayoutConstants[prop]; + } + + CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false; + CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH; + CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60; + CoSEConstants.TILE = true; + CoSEConstants.TILING_PADDING_VERTICAL = 10; + CoSEConstants.TILING_PADDING_HORIZONTAL = 10; + CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout + + module.exports = CoSEConstants; + + /***/ }), + /* 2 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutEdge = __webpack_require__(0).FDLayoutEdge; + + function CoSEEdge(source, target, vEdge) { + FDLayoutEdge.call(this, source, target, vEdge); + } + + CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype); + for (var prop in FDLayoutEdge) { + CoSEEdge[prop] = FDLayoutEdge[prop]; + } + + module.exports = CoSEEdge; + + /***/ }), + /* 3 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraph = __webpack_require__(0).LGraph; + + function CoSEGraph(parent, graphMgr, vGraph) { + LGraph.call(this, parent, graphMgr, vGraph); + } + + CoSEGraph.prototype = Object.create(LGraph.prototype); + for (var prop in LGraph) { + CoSEGraph[prop] = LGraph[prop]; + } + + module.exports = CoSEGraph; + + /***/ }), + /* 4 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LGraphManager = __webpack_require__(0).LGraphManager; + + function CoSEGraphManager(layout) { + LGraphManager.call(this, layout); + } + + CoSEGraphManager.prototype = Object.create(LGraphManager.prototype); + for (var prop in LGraphManager) { + CoSEGraphManager[prop] = LGraphManager[prop]; + } + + module.exports = CoSEGraphManager; + + /***/ }), + /* 5 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayoutNode = __webpack_require__(0).FDLayoutNode; + var IMath = __webpack_require__(0).IMath; + + function CoSENode(gm, loc, size, vNode) { + FDLayoutNode.call(this, gm, loc, size, vNode); + } + + CoSENode.prototype = Object.create(FDLayoutNode.prototype); + for (var prop in FDLayoutNode) { + CoSENode[prop] = FDLayoutNode[prop]; + } + + CoSENode.prototype.move = function () { + var layout = this.graphManager.getLayout(); + this.displacementX = layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren; + this.displacementY = layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren; + + if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX); + } + + if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) { + this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY); + } + + // a simple node, just move it + if (this.child == null) { + this.moveBy(this.displacementX, this.displacementY); + } + // an empty compound node, again just move it + else if (this.child.getNodes().length == 0) { + this.moveBy(this.displacementX, this.displacementY); + } + // non-empty compound node, propogate movement to children as well + else { + this.propogateDisplacementToChildren(this.displacementX, this.displacementY); + } + + layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY); + + this.springForceX = 0; + this.springForceY = 0; + this.repulsionForceX = 0; + this.repulsionForceY = 0; + this.gravitationForceX = 0; + this.gravitationForceY = 0; + this.displacementX = 0; + this.displacementY = 0; + }; + + CoSENode.prototype.propogateDisplacementToChildren = function (dX, dY) { + var nodes = this.getChild().getNodes(); + var node; + for (var i = 0; i < nodes.length; i++) { + node = nodes[i]; + if (node.getChild() == null) { + node.moveBy(dX, dY); + node.displacementX += dX; + node.displacementY += dY; + } else { + node.propogateDisplacementToChildren(dX, dY); + } + } + }; + + CoSENode.prototype.setPred1 = function (pred1) { + this.pred1 = pred1; + }; + + CoSENode.prototype.getPred1 = function () { + return pred1; + }; + + CoSENode.prototype.getPred2 = function () { + return pred2; + }; + + CoSENode.prototype.setNext = function (next) { + this.next = next; + }; + + CoSENode.prototype.getNext = function () { + return next; + }; + + CoSENode.prototype.setProcessed = function (processed) { + this.processed = processed; + }; + + CoSENode.prototype.isProcessed = function () { + return processed; + }; + + module.exports = CoSENode; + + /***/ }), + /* 6 */ + /***/ (function(module, exports, __webpack_require__) { + + + var FDLayout = __webpack_require__(0).FDLayout; + var CoSEGraphManager = __webpack_require__(4); + var CoSEGraph = __webpack_require__(3); + var CoSENode = __webpack_require__(5); + var CoSEEdge = __webpack_require__(2); + var CoSEConstants = __webpack_require__(1); + var FDLayoutConstants = __webpack_require__(0).FDLayoutConstants; + var LayoutConstants = __webpack_require__(0).LayoutConstants; + var Point = __webpack_require__(0).Point; + var PointD = __webpack_require__(0).PointD; + var Layout = __webpack_require__(0).Layout; + var Integer = __webpack_require__(0).Integer; + var IGeometry = __webpack_require__(0).IGeometry; + var LGraph = __webpack_require__(0).LGraph; + var Transform = __webpack_require__(0).Transform; + + function CoSELayout() { + FDLayout.call(this); + + this.toBeTiled = {}; // Memorize if a node is to be tiled or is tiled + } + + CoSELayout.prototype = Object.create(FDLayout.prototype); + + for (var prop in FDLayout) { + CoSELayout[prop] = FDLayout[prop]; + } + + CoSELayout.prototype.newGraphManager = function () { + var gm = new CoSEGraphManager(this); + this.graphManager = gm; + return gm; + }; + + CoSELayout.prototype.newGraph = function (vGraph) { + return new CoSEGraph(null, this.graphManager, vGraph); + }; + + CoSELayout.prototype.newNode = function (vNode) { + return new CoSENode(this.graphManager, vNode); + }; + + CoSELayout.prototype.newEdge = function (vEdge) { + return new CoSEEdge(null, null, vEdge); + }; + + CoSELayout.prototype.initParameters = function () { + FDLayout.prototype.initParameters.call(this, arguments); + if (!this.isSubLayout) { + if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) { + this.idealEdgeLength = 10; + } else { + this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH; + } + + this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION; + this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH; + this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH; + this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH; + this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH; + this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR; + this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR; + + // variables for tree reduction support + this.prunedNodesAll = []; + this.growTreeIterations = 0; + this.afterGrowthIterations = 0; + this.isTreeGrowing = false; + this.isGrowthFinished = false; + + // variables for cooling + this.coolingCycle = 0; + this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD; + this.finalTemperature = FDLayoutConstants.CONVERGENCE_CHECK_PERIOD / this.maxIterations; + this.coolingAdjuster = 1; + } + }; + + CoSELayout.prototype.layout = function () { + var createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED; + if (createBendsAsNeeded) { + this.createBendpoints(); + this.graphManager.resetAllEdges(); + } + + this.level = 0; + return this.classicLayout(); + }; + + CoSELayout.prototype.classicLayout = function () { + this.nodesWithGravity = this.calculateNodesToApplyGravitationTo(); + this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity); + this.calcNoOfChildrenForAllNodes(); + this.graphManager.calcLowestCommonAncestors(); + this.graphManager.calcInclusionTreeDepths(); + this.graphManager.getRoot().calcEstimatedSize(); + this.calcIdealEdgeLengths(); + + if (!this.incremental) { + var forest = this.getFlatForest(); + + // The graph associated with this layout is flat and a forest + if (forest.length > 0) { + this.positionNodesRadially(forest); + } + // The graph associated with this layout is not flat or a forest + else { + // Reduce the trees when incremental mode is not enabled and graph is not a forest + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.positionNodesRandomly(); + } + } else { + if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) { + // Reduce the trees in incremental mode if only this constant is set to true + this.reduceTrees(); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + } + } + + this.initSpringEmbedder(); + this.runSpringEmbedder(); + + return true; + }; + + CoSELayout.prototype.tick = function () { + this.totalIterations++; + + if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) { + if (this.isConverged()) { + if (this.prunedNodesAll.length > 0) { + this.isTreeGrowing = true; + } else { + return true; + } + } + + this.coolingCycle++; + + if (this.layoutQuality == 0) { + // quality - "draft" + this.coolingAdjuster = this.coolingCycle; + } else if (this.layoutQuality == 1) { + // quality - "default" + this.coolingAdjuster = this.coolingCycle / 3; + } + + // cooling schedule is based on http://www.btluke.com/simanf1.html -> cooling schedule 3 + this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature); + this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor)); + } + // Operations while tree is growing again + if (this.isTreeGrowing) { + if (this.growTreeIterations % 10 == 0) { + if (this.prunedNodesAll.length > 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + this.growTree(this.prunedNodesAll); + // Update nodes that gravity will be applied + this.graphManager.resetAllNodesToApplyGravitation(); + var allNodes = new Set(this.getAllNodes()); + var intersection = this.nodesWithGravity.filter(function (x) { + return allNodes.has(x); + }); + this.graphManager.setAllNodesToApplyGravitation(intersection); + + this.graphManager.updateBounds(); + this.updateGrid(); + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL; + } else { + this.isTreeGrowing = false; + this.isGrowthFinished = true; + } + } + this.growTreeIterations++; + } + // Operations after growth is finished + if (this.isGrowthFinished) { + if (this.isConverged()) { + return true; + } + if (this.afterGrowthIterations % 10 == 0) { + this.graphManager.updateBounds(); + this.updateGrid(); + } + this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100); + this.afterGrowthIterations++; + } + + var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished; + var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished; + + this.totalDisplacement = 0; + this.graphManager.updateBounds(); + this.calcSpringForces(); + this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate); + this.calcGravitationalForces(); + this.moveNodes(); + this.animate(); + + return false; // Layout is not ended yet return false + }; + + CoSELayout.prototype.getPositionsData = function () { + var allNodes = this.graphManager.getAllNodes(); + var pData = {}; + for (var i = 0; i < allNodes.length; i++) { + var rect = allNodes[i].rect; + var id = allNodes[i].id; + pData[id] = { + id: id, + x: rect.getCenterX(), + y: rect.getCenterY(), + w: rect.width, + h: rect.height + }; + } + + return pData; + }; + + CoSELayout.prototype.runSpringEmbedder = function () { + this.initialAnimationPeriod = 25; + this.animationPeriod = this.initialAnimationPeriod; + var layoutEnded = false; + + // If aminate option is 'during' signal that layout is supposed to start iterating + if (FDLayoutConstants.ANIMATE === 'during') { + this.emit('layoutstarted'); + } else { + // If aminate option is 'during' tick() function will be called on index.js + while (!layoutEnded) { + layoutEnded = this.tick(); + } + + this.graphManager.updateBounds(); + } + }; + + CoSELayout.prototype.calculateNodesToApplyGravitationTo = function () { + var nodeList = []; + var graph; + + var graphs = this.graphManager.getGraphs(); + var size = graphs.length; + var i; + for (i = 0; i < size; i++) { + graph = graphs[i]; + + graph.updateConnected(); + + if (!graph.isConnected) { + nodeList = nodeList.concat(graph.getNodes()); + } + } + + return nodeList; + }; + + CoSELayout.prototype.createBendpoints = function () { + var edges = []; + edges = edges.concat(this.graphManager.getAllEdges()); + var visited = new Set(); + var i; + for (i = 0; i < edges.length; i++) { + var edge = edges[i]; + + if (!visited.has(edge)) { + var source = edge.getSource(); + var target = edge.getTarget(); + + if (source == target) { + edge.getBendpoints().push(new PointD()); + edge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(edge); + visited.add(edge); + } else { + var edgeList = []; + + edgeList = edgeList.concat(source.getEdgeListToNode(target)); + edgeList = edgeList.concat(target.getEdgeListToNode(source)); + + if (!visited.has(edgeList[0])) { + if (edgeList.length > 1) { + var k; + for (k = 0; k < edgeList.length; k++) { + var multiEdge = edgeList[k]; + multiEdge.getBendpoints().push(new PointD()); + this.createDummyNodesForBendpoints(multiEdge); + } + } + edgeList.forEach(function (edge) { + visited.add(edge); + }); + } + } + } + + if (visited.size == edges.length) { + break; + } + } + }; + + CoSELayout.prototype.positionNodesRadially = function (forest) { + // We tile the trees to a grid row by row; first tree starts at (0,0) + var currentStartingPoint = new Point(0, 0); + var numberOfColumns = Math.ceil(Math.sqrt(forest.length)); + var height = 0; + var currentY = 0; + var currentX = 0; + var point = new PointD(0, 0); + + for (var i = 0; i < forest.length; i++) { + if (i % numberOfColumns == 0) { + // Start of a new row, make the x coordinate 0, increment the + // y coordinate with the max height of the previous row + currentX = 0; + currentY = height; + + if (i != 0) { + currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION; + } + + height = 0; + } + + var tree = forest[i]; + + // Find the center of the tree + var centerNode = Layout.findCenterOfTree(tree); + + // Set the staring point of the next tree + currentStartingPoint.x = currentX; + currentStartingPoint.y = currentY; + + // Do a radial layout starting with the center + point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint); + + if (point.y > height) { + height = Math.floor(point.y); + } + + currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION); + } + + this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2)); + }; + + CoSELayout.radialLayout = function (tree, centerNode, startingPoint) { + var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION); + CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep); + var bounds = LGraph.calculateBounds(tree); + + var transform = new Transform(); + transform.setDeviceOrgX(bounds.getMinX()); + transform.setDeviceOrgY(bounds.getMinY()); + transform.setWorldOrgX(startingPoint.x); + transform.setWorldOrgY(startingPoint.y); + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + node.transform(transform); + } + + var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY()); + + return transform.inverseTransformPoint(bottomRight); + }; + + CoSELayout.branchRadialLayout = function (node, parentOfNode, startAngle, endAngle, distance, radialSeparation) { + // First, position this node by finding its angle. + var halfInterval = (endAngle - startAngle + 1) / 2; + + if (halfInterval < 0) { + halfInterval += 180; + } + + var nodeAngle = (halfInterval + startAngle) % 360; + var teta = nodeAngle * IGeometry.TWO_PI / 360; + var x_ = distance * Math.cos(teta); + var y_ = distance * Math.sin(teta); + + node.setCenter(x_, y_); + + // Traverse all neighbors of this node and recursively call this + // function. + var neighborEdges = []; + neighborEdges = neighborEdges.concat(node.getEdges()); + var childCount = neighborEdges.length; + + if (parentOfNode != null) { + childCount--; + } + + var branchCount = 0; + + var incEdgesCount = neighborEdges.length; + var startIndex; + + var edges = node.getEdgesBetween(parentOfNode); + + // If there are multiple edges, prune them until there remains only one + // edge. + while (edges.length > 1) { + //neighborEdges.remove(edges.remove(0)); + var temp = edges[0]; + edges.splice(0, 1); + var index = neighborEdges.indexOf(temp); + if (index >= 0) { + neighborEdges.splice(index, 1); + } + incEdgesCount--; + childCount--; + } + + if (parentOfNode != null) { + //assert edges.length == 1; + startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount; + } else { + startIndex = 0; + } + + var stepAngle = Math.abs(endAngle - startAngle) / childCount; + + for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) { + var currentNeighbor = neighborEdges[i].getOtherEnd(node); + + // Don't back traverse to root node in current tree. + if (currentNeighbor == parentOfNode) { + continue; + } + + var childStartAngle = (startAngle + branchCount * stepAngle) % 360; + var childEndAngle = (childStartAngle + stepAngle) % 360; + + CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation); + + branchCount++; + } + }; + + CoSELayout.maxDiagonalInTree = function (tree) { + var maxDiagonal = Integer.MIN_VALUE; + + for (var i = 0; i < tree.length; i++) { + var node = tree[i]; + var diagonal = node.getDiagonal(); + + if (diagonal > maxDiagonal) { + maxDiagonal = diagonal; + } + } + + return maxDiagonal; + }; + + CoSELayout.prototype.calcRepulsionRange = function () { + // formula is 2 x (level + 1) x idealEdgeLength + return 2 * (this.level + 1) * this.idealEdgeLength; + }; + + // Tiling methods + + // Group zero degree members whose parents are not to be tiled, create dummy parents where needed and fill memberGroups by their dummp parent id's + CoSELayout.prototype.groupZeroDegreeMembers = function () { + var self = this; + // array of [parent_id x oneDegreeNode_id] + var tempMemberGroups = {}; // A temporary map of parent node and its zero degree members + this.memberGroups = {}; // A map of dummy parent node and its zero degree members whose parents are not to be tiled + this.idToDummyNode = {}; // A map of id to dummy node + + var zeroDegree = []; // List of zero degree nodes whose parents are not to be tiled + var allNodes = this.graphManager.getAllNodes(); + + // Fill zero degree list + for (var i = 0; i < allNodes.length; i++) { + var node = allNodes[i]; + var parent = node.getParent(); + // If a node has zero degree and its parent is not to be tiled if exists add that node to zeroDegres list + if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == undefined || !this.getToBeTiled(parent))) { + zeroDegree.push(node); + } + } + + // Create a map of parent node and its zero degree members + for (var i = 0; i < zeroDegree.length; i++) { + var node = zeroDegree[i]; // Zero degree node itself + var p_id = node.getParent().id; // Parent id + + if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = []; + + tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node); // Push node to the list belongs to its parent in tempMemberGroups + } + + // If there are at least two nodes at a level, create a dummy compound for them + Object.keys(tempMemberGroups).forEach(function (p_id) { + if (tempMemberGroups[p_id].length > 1) { + var dummyCompoundId = "DummyCompound_" + p_id; // The id of dummy compound which will be created soon + self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id]; // Add dummy compound to memberGroups + + var parent = tempMemberGroups[p_id][0].getParent(); // The parent of zero degree nodes will be the parent of new dummy compound + + // Create a dummy compound with calculated id + var dummyCompound = new CoSENode(self.graphManager); + dummyCompound.id = dummyCompoundId; + dummyCompound.paddingLeft = parent.paddingLeft || 0; + dummyCompound.paddingRight = parent.paddingRight || 0; + dummyCompound.paddingBottom = parent.paddingBottom || 0; + dummyCompound.paddingTop = parent.paddingTop || 0; + + self.idToDummyNode[dummyCompoundId] = dummyCompound; + + var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound); + var parentGraph = parent.getChild(); + + // Add dummy compound to parent the graph + parentGraph.add(dummyCompound); + + // For each zero degree node in this level remove it from its parent graph and add it to the graph of dummy parent + for (var i = 0; i < tempMemberGroups[p_id].length; i++) { + var node = tempMemberGroups[p_id][i]; + + parentGraph.remove(node); + dummyParentGraph.add(node); + } + } + }); + }; + + CoSELayout.prototype.clearCompounds = function () { + var childGraphMap = {}; + var idToNode = {}; + + // Get compound ordering by finding the inner one first + this.performDFSOnCompounds(); + + for (var i = 0; i < this.compoundOrder.length; i++) { + + idToNode[this.compoundOrder[i].id] = this.compoundOrder[i]; + childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes()); + + // Remove children of compounds + this.graphManager.remove(this.compoundOrder[i].getChild()); + this.compoundOrder[i].child = null; + } + + this.graphManager.resetAllNodes(); + + // Tile the removed children + this.tileCompoundMembers(childGraphMap, idToNode); + }; + + CoSELayout.prototype.clearZeroDegreeMembers = function () { + var self = this; + var tiledZeroDegreePack = this.tiledZeroDegreePack = []; + + Object.keys(this.memberGroups).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound + + tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + // Set the width and height of the dummy compound as calculated + compoundNode.rect.width = tiledZeroDegreePack[id].width; + compoundNode.rect.height = tiledZeroDegreePack[id].height; + }); + }; + + CoSELayout.prototype.repopulateCompounds = function () { + for (var i = this.compoundOrder.length - 1; i >= 0; i--) { + var lCompoundNode = this.compoundOrder[i]; + var id = lCompoundNode.id; + var horizontalMargin = lCompoundNode.paddingLeft; + var verticalMargin = lCompoundNode.paddingTop; + + this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin); + } + }; + + CoSELayout.prototype.repopulateZeroDegreeMembers = function () { + var self = this; + var tiledPack = this.tiledZeroDegreePack; + + Object.keys(tiledPack).forEach(function (id) { + var compoundNode = self.idToDummyNode[id]; // Get the dummy compound by its id + var horizontalMargin = compoundNode.paddingLeft; + var verticalMargin = compoundNode.paddingTop; + + // Adjust the positions of nodes wrt its compound + self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin); + }); + }; + + CoSELayout.prototype.getToBeTiled = function (node) { + var id = node.id; + //firstly check the previous results + if (this.toBeTiled[id] != null) { + return this.toBeTiled[id]; + } + + //only compound nodes are to be tiled + var childGraph = node.getChild(); + if (childGraph == null) { + this.toBeTiled[id] = false; + return false; + } + + var children = childGraph.getNodes(); // Get the children nodes + + //a compound node is not to be tiled if all of its compound children are not to be tiled + for (var i = 0; i < children.length; i++) { + var theChild = children[i]; + + if (this.getNodeDegree(theChild) > 0) { + this.toBeTiled[id] = false; + return false; + } + + //pass the children not having the compound structure + if (theChild.getChild() == null) { + this.toBeTiled[theChild.id] = false; + continue; + } + + if (!this.getToBeTiled(theChild)) { + this.toBeTiled[id] = false; + return false; + } + } + this.toBeTiled[id] = true; + return true; + }; + + // Get degree of a node depending of its edges and independent of its children + CoSELayout.prototype.getNodeDegree = function (node) { + node.id; + var edges = node.getEdges(); + var degree = 0; + + // For the edges connected + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + if (edge.getSource().id !== edge.getTarget().id) { + degree = degree + 1; + } + } + return degree; + }; + + // Get degree of a node with its children + CoSELayout.prototype.getNodeDegreeWithChildren = function (node) { + var degree = this.getNodeDegree(node); + if (node.getChild() == null) { + return degree; + } + var children = node.getChild().getNodes(); + for (var i = 0; i < children.length; i++) { + var child = children[i]; + degree += this.getNodeDegreeWithChildren(child); + } + return degree; + }; + + CoSELayout.prototype.performDFSOnCompounds = function () { + this.compoundOrder = []; + this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes()); + }; + + CoSELayout.prototype.fillCompexOrderByDFS = function (children) { + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.getChild() != null) { + this.fillCompexOrderByDFS(child.getChild().getNodes()); + } + if (this.getToBeTiled(child)) { + this.compoundOrder.push(child); + } + } + }; + + /** + * This method places each zero degree member wrt given (x,y) coordinates (top left). + */ + CoSELayout.prototype.adjustLocations = function (organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) { + x += compoundHorizontalMargin; + y += compoundVerticalMargin; + + var left = x; + + for (var i = 0; i < organization.rows.length; i++) { + var row = organization.rows[i]; + x = left; + var maxHeight = 0; + + for (var j = 0; j < row.length; j++) { + var lnode = row[j]; + + lnode.rect.x = x; // + lnode.rect.width / 2; + lnode.rect.y = y; // + lnode.rect.height / 2; + + x += lnode.rect.width + organization.horizontalPadding; + + if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height; + } + + y += maxHeight + organization.verticalPadding; + } + }; + + CoSELayout.prototype.tileCompoundMembers = function (childGraphMap, idToNode) { + var self = this; + this.tiledMemberPack = []; + + Object.keys(childGraphMap).forEach(function (id) { + // Get the compound node + var compoundNode = idToNode[id]; + + self.tiledMemberPack[id] = self.tileNodes(childGraphMap[id], compoundNode.paddingLeft + compoundNode.paddingRight); + + compoundNode.rect.width = self.tiledMemberPack[id].width; + compoundNode.rect.height = self.tiledMemberPack[id].height; + }); + }; + + CoSELayout.prototype.tileNodes = function (nodes, minWidth) { + var verticalPadding = CoSEConstants.TILING_PADDING_VERTICAL; + var horizontalPadding = CoSEConstants.TILING_PADDING_HORIZONTAL; + var organization = { + rows: [], + rowWidth: [], + rowHeight: [], + width: 0, + height: minWidth, // assume minHeight equals to minWidth + verticalPadding: verticalPadding, + horizontalPadding: horizontalPadding + }; + + // Sort the nodes in ascending order of their areas + nodes.sort(function (n1, n2) { + if (n1.rect.width * n1.rect.height > n2.rect.width * n2.rect.height) return -1; + if (n1.rect.width * n1.rect.height < n2.rect.width * n2.rect.height) return 1; + return 0; + }); + + // Create the organization -> tile members + for (var i = 0; i < nodes.length; i++) { + var lNode = nodes[i]; + + if (organization.rows.length == 0) { + this.insertNodeToRow(organization, lNode, 0, minWidth); + } else if (this.canAddHorizontal(organization, lNode.rect.width, lNode.rect.height)) { + this.insertNodeToRow(organization, lNode, this.getShortestRowIndex(organization), minWidth); + } else { + this.insertNodeToRow(organization, lNode, organization.rows.length, minWidth); + } + + this.shiftToLastRow(organization); + } + + return organization; + }; + + CoSELayout.prototype.insertNodeToRow = function (organization, node, rowIndex, minWidth) { + var minCompoundSize = minWidth; + + // Add new row if needed + if (rowIndex == organization.rows.length) { + var secondDimension = []; + + organization.rows.push(secondDimension); + organization.rowWidth.push(minCompoundSize); + organization.rowHeight.push(0); + } + + // Update row width + var w = organization.rowWidth[rowIndex] + node.rect.width; + + if (organization.rows[rowIndex].length > 0) { + w += organization.horizontalPadding; + } + + organization.rowWidth[rowIndex] = w; + // Update compound width + if (organization.width < w) { + organization.width = w; + } + + // Update height + var h = node.rect.height; + if (rowIndex > 0) h += organization.verticalPadding; + + var extraHeight = 0; + if (h > organization.rowHeight[rowIndex]) { + extraHeight = organization.rowHeight[rowIndex]; + organization.rowHeight[rowIndex] = h; + extraHeight = organization.rowHeight[rowIndex] - extraHeight; + } + + organization.height += extraHeight; + + // Insert node + organization.rows[rowIndex].push(node); + }; + + //Scans the rows of an organization and returns the one with the min width + CoSELayout.prototype.getShortestRowIndex = function (organization) { + var r = -1; + var min = Number.MAX_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + if (organization.rowWidth[i] < min) { + r = i; + min = organization.rowWidth[i]; + } + } + return r; + }; + + //Scans the rows of an organization and returns the one with the max width + CoSELayout.prototype.getLongestRowIndex = function (organization) { + var r = -1; + var max = Number.MIN_VALUE; + + for (var i = 0; i < organization.rows.length; i++) { + + if (organization.rowWidth[i] > max) { + r = i; + max = organization.rowWidth[i]; + } + } + + return r; + }; + + /** + * This method checks whether adding extra width to the organization violates + * the aspect ratio(1) or not. + */ + CoSELayout.prototype.canAddHorizontal = function (organization, extraWidth, extraHeight) { + + var sri = this.getShortestRowIndex(organization); + + if (sri < 0) { + return true; + } + + var min = organization.rowWidth[sri]; + + if (min + organization.horizontalPadding + extraWidth <= organization.width) return true; + + var hDiff = 0; + + // Adding to an existing row + if (organization.rowHeight[sri] < extraHeight) { + if (sri > 0) hDiff = extraHeight + organization.verticalPadding - organization.rowHeight[sri]; + } + + var add_to_row_ratio; + if (organization.width - min >= extraWidth + organization.horizontalPadding) { + add_to_row_ratio = (organization.height + hDiff) / (min + extraWidth + organization.horizontalPadding); + } else { + add_to_row_ratio = (organization.height + hDiff) / organization.width; + } + + // Adding a new row for this node + hDiff = extraHeight + organization.verticalPadding; + var add_new_row_ratio; + if (organization.width < extraWidth) { + add_new_row_ratio = (organization.height + hDiff) / extraWidth; + } else { + add_new_row_ratio = (organization.height + hDiff) / organization.width; + } + + if (add_new_row_ratio < 1) add_new_row_ratio = 1 / add_new_row_ratio; + + if (add_to_row_ratio < 1) add_to_row_ratio = 1 / add_to_row_ratio; + + return add_to_row_ratio < add_new_row_ratio; + }; + + //If moving the last node from the longest row and adding it to the last + //row makes the bounding box smaller, do it. + CoSELayout.prototype.shiftToLastRow = function (organization) { + var longest = this.getLongestRowIndex(organization); + var last = organization.rowWidth.length - 1; + var row = organization.rows[longest]; + var node = row[row.length - 1]; + + var diff = node.width + organization.horizontalPadding; + + // Check if there is enough space on the last row + if (organization.width - organization.rowWidth[last] > diff && longest != last) { + // Remove the last element of the longest row + row.splice(-1, 1); + + // Push it to the last row + organization.rows[last].push(node); + + organization.rowWidth[longest] = organization.rowWidth[longest] - diff; + organization.rowWidth[last] = organization.rowWidth[last] + diff; + organization.width = organization.rowWidth[instance.getLongestRowIndex(organization)]; + + // Update heights of the organization + var maxHeight = Number.MIN_VALUE; + for (var i = 0; i < row.length; i++) { + if (row[i].height > maxHeight) maxHeight = row[i].height; + } + if (longest > 0) maxHeight += organization.verticalPadding; + + var prevTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + + organization.rowHeight[longest] = maxHeight; + if (organization.rowHeight[last] < node.height + organization.verticalPadding) organization.rowHeight[last] = node.height + organization.verticalPadding; + + var finalTotal = organization.rowHeight[longest] + organization.rowHeight[last]; + organization.height += finalTotal - prevTotal; + + this.shiftToLastRow(organization); + } + }; + + CoSELayout.prototype.tilingPreLayout = function () { + if (CoSEConstants.TILE) { + // Find zero degree nodes and create a compound for each level + this.groupZeroDegreeMembers(); + // Tile and clear children of each compound + this.clearCompounds(); + // Separately tile and clear zero degree nodes for each level + this.clearZeroDegreeMembers(); + } + }; + + CoSELayout.prototype.tilingPostLayout = function () { + if (CoSEConstants.TILE) { + this.repopulateZeroDegreeMembers(); + this.repopulateCompounds(); + } + }; + + // ----------------------------------------------------------------------------- + // Section: Tree Reduction methods + // ----------------------------------------------------------------------------- + // Reduce trees + CoSELayout.prototype.reduceTrees = function () { + var prunedNodesAll = []; + var containsLeaf = true; + var node; + + while (containsLeaf) { + var allNodes = this.graphManager.getAllNodes(); + var prunedNodesInStepTemp = []; + containsLeaf = false; + + for (var i = 0; i < allNodes.length; i++) { + node = allNodes[i]; + if (node.getEdges().length == 1 && !node.getEdges()[0].isInterGraph && node.getChild() == null) { + prunedNodesInStepTemp.push([node, node.getEdges()[0], node.getOwner()]); + containsLeaf = true; + } + } + if (containsLeaf == true) { + var prunedNodesInStep = []; + for (var j = 0; j < prunedNodesInStepTemp.length; j++) { + if (prunedNodesInStepTemp[j][0].getEdges().length == 1) { + prunedNodesInStep.push(prunedNodesInStepTemp[j]); + prunedNodesInStepTemp[j][0].getOwner().remove(prunedNodesInStepTemp[j][0]); + } + } + prunedNodesAll.push(prunedNodesInStep); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + } + } + this.prunedNodesAll = prunedNodesAll; + }; + + // Grow tree one step + CoSELayout.prototype.growTree = function (prunedNodesAll) { + var lengthOfPrunedNodesInStep = prunedNodesAll.length; + var prunedNodesInStep = prunedNodesAll[lengthOfPrunedNodesInStep - 1]; + + var nodeData; + for (var i = 0; i < prunedNodesInStep.length; i++) { + nodeData = prunedNodesInStep[i]; + + this.findPlaceforPrunedNode(nodeData); + + nodeData[2].add(nodeData[0]); + nodeData[2].add(nodeData[1], nodeData[1].source, nodeData[1].target); + } + + prunedNodesAll.splice(prunedNodesAll.length - 1, 1); + this.graphManager.resetAllNodes(); + this.graphManager.resetAllEdges(); + }; + + // Find an appropriate position to replace pruned node, this method can be improved + CoSELayout.prototype.findPlaceforPrunedNode = function (nodeData) { + + var gridForPrunedNode; + var nodeToConnect; + var prunedNode = nodeData[0]; + if (prunedNode == nodeData[1].source) { + nodeToConnect = nodeData[1].target; + } else { + nodeToConnect = nodeData[1].source; + } + var startGridX = nodeToConnect.startX; + var finishGridX = nodeToConnect.finishX; + var startGridY = nodeToConnect.startY; + var finishGridY = nodeToConnect.finishY; + + var upNodeCount = 0; + var downNodeCount = 0; + var rightNodeCount = 0; + var leftNodeCount = 0; + var controlRegions = [upNodeCount, rightNodeCount, downNodeCount, leftNodeCount]; + + if (startGridY > 0) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[0] += this.grid[i][startGridY - 1].length + this.grid[i][startGridY].length - 1; + } + } + if (finishGridX < this.grid.length - 1) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[1] += this.grid[finishGridX + 1][i].length + this.grid[finishGridX][i].length - 1; + } + } + if (finishGridY < this.grid[0].length - 1) { + for (var i = startGridX; i <= finishGridX; i++) { + controlRegions[2] += this.grid[i][finishGridY + 1].length + this.grid[i][finishGridY].length - 1; + } + } + if (startGridX > 0) { + for (var i = startGridY; i <= finishGridY; i++) { + controlRegions[3] += this.grid[startGridX - 1][i].length + this.grid[startGridX][i].length - 1; + } + } + var min = Integer.MAX_VALUE; + var minCount; + var minIndex; + for (var j = 0; j < controlRegions.length; j++) { + if (controlRegions[j] < min) { + min = controlRegions[j]; + minCount = 1; + minIndex = j; + } else if (controlRegions[j] == min) { + minCount++; + } + } + + if (minCount == 3 && min == 0) { + if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[2] == 0) { + gridForPrunedNode = 1; + } else if (controlRegions[0] == 0 && controlRegions[1] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 0; + } else if (controlRegions[0] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 3; + } else if (controlRegions[1] == 0 && controlRegions[2] == 0 && controlRegions[3] == 0) { + gridForPrunedNode = 2; + } + } else if (minCount == 2 && min == 0) { + var random = Math.floor(Math.random() * 2); + if (controlRegions[0] == 0 && controlRegions[1] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 1; + } + } else if (controlRegions[0] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[0] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 0; + } else { + gridForPrunedNode = 3; + } + } else if (controlRegions[1] == 0 && controlRegions[2] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 2; + } + } else if (controlRegions[1] == 0 && controlRegions[3] == 0) { + if (random == 0) { + gridForPrunedNode = 1; + } else { + gridForPrunedNode = 3; + } + } else { + if (random == 0) { + gridForPrunedNode = 2; + } else { + gridForPrunedNode = 3; + } + } + } else if (minCount == 4 && min == 0) { + var random = Math.floor(Math.random() * 4); + gridForPrunedNode = random; + } else { + gridForPrunedNode = minIndex; + } + + if (gridForPrunedNode == 0) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() - nodeToConnect.getHeight() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getHeight() / 2); + } else if (gridForPrunedNode == 1) { + prunedNode.setCenter(nodeToConnect.getCenterX() + nodeToConnect.getWidth() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } else if (gridForPrunedNode == 2) { + prunedNode.setCenter(nodeToConnect.getCenterX(), nodeToConnect.getCenterY() + nodeToConnect.getHeight() / 2 + FDLayoutConstants.DEFAULT_EDGE_LENGTH + prunedNode.getHeight() / 2); + } else { + prunedNode.setCenter(nodeToConnect.getCenterX() - nodeToConnect.getWidth() / 2 - FDLayoutConstants.DEFAULT_EDGE_LENGTH - prunedNode.getWidth() / 2, nodeToConnect.getCenterY()); + } + }; + + module.exports = CoSELayout; + + /***/ }), + /* 7 */ + /***/ (function(module, exports, __webpack_require__) { + + + var coseBase = {}; + + coseBase.layoutBase = __webpack_require__(0); + coseBase.CoSEConstants = __webpack_require__(1); + coseBase.CoSEEdge = __webpack_require__(2); + coseBase.CoSEGraph = __webpack_require__(3); + coseBase.CoSEGraphManager = __webpack_require__(4); + coseBase.CoSELayout = __webpack_require__(6); + coseBase.CoSENode = __webpack_require__(5); + + module.exports = coseBase; + + /***/ }) + /******/ ]); + }); + } (coseBase)); + return coseBase.exports; +} + +(function (module, exports) { + (function webpackUniversalModuleDefinition(root, factory) { + module.exports = factory(requireCoseBase()); + })(commonjsGlobal$1, function(__WEBPACK_EXTERNAL_MODULE_0__) { + return /******/ (function(modules) { // webpackBootstrap + /******/ // The module cache + /******/ var installedModules = {}; + /******/ + /******/ // The require function + /******/ function __webpack_require__(moduleId) { + /******/ + /******/ // Check if module is in cache + /******/ if(installedModules[moduleId]) { + /******/ return installedModules[moduleId].exports; + /******/ } + /******/ // Create a new module (and put it into the cache) + /******/ var module = installedModules[moduleId] = { + /******/ i: moduleId, + /******/ l: false, + /******/ exports: {} + /******/ }; + /******/ + /******/ // Execute the module function + /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + /******/ + /******/ // Flag the module as loaded + /******/ module.l = true; + /******/ + /******/ // Return the exports of the module + /******/ return module.exports; + /******/ } + /******/ + /******/ + /******/ // expose the modules object (__webpack_modules__) + /******/ __webpack_require__.m = modules; + /******/ + /******/ // expose the module cache + /******/ __webpack_require__.c = installedModules; + /******/ + /******/ // identity function for calling harmony imports with the correct context + /******/ __webpack_require__.i = function(value) { return value; }; + /******/ + /******/ // define getter function for harmony exports + /******/ __webpack_require__.d = function(exports, name, getter) { + /******/ if(!__webpack_require__.o(exports, name)) { + /******/ Object.defineProperty(exports, name, { + /******/ configurable: false, + /******/ enumerable: true, + /******/ get: getter + /******/ }); + /******/ } + /******/ }; + /******/ + /******/ // getDefaultExport function for compatibility with non-harmony modules + /******/ __webpack_require__.n = function(module) { + /******/ var getter = module && module.__esModule ? + /******/ function getDefault() { return module['default']; } : + /******/ function getModuleExports() { return module; }; + /******/ __webpack_require__.d(getter, 'a', getter); + /******/ return getter; + /******/ }; + /******/ + /******/ // Object.prototype.hasOwnProperty.call + /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; + /******/ + /******/ // __webpack_public_path__ + /******/ __webpack_require__.p = ""; + /******/ + /******/ // Load entry module and return exports + /******/ return __webpack_require__(__webpack_require__.s = 1); + /******/ }) + /************************************************************************/ + /******/ ([ + /* 0 */ + /***/ (function(module, exports) { + + module.exports = __WEBPACK_EXTERNAL_MODULE_0__; + + /***/ }), + /* 1 */ + /***/ (function(module, exports, __webpack_require__) { + + + var LayoutConstants = __webpack_require__(0).layoutBase.LayoutConstants; + var FDLayoutConstants = __webpack_require__(0).layoutBase.FDLayoutConstants; + var CoSEConstants = __webpack_require__(0).CoSEConstants; + var CoSELayout = __webpack_require__(0).CoSELayout; + var CoSENode = __webpack_require__(0).CoSENode; + var PointD = __webpack_require__(0).layoutBase.PointD; + var DimensionD = __webpack_require__(0).layoutBase.DimensionD; + + var defaults = { + // Called on `layoutready` + ready: function ready() {}, + // Called on `layoutstop` + stop: function stop() {}, + // 'draft', 'default' or 'proof" + // - 'draft' fast cooling rate + // - 'default' moderate cooling rate + // - "proof" slow cooling rate + quality: 'default', + // include labels in node dimensions + nodeDimensionsIncludeLabels: false, + // number of ticks per frame; higher is faster but more jerky + refresh: 30, + // Whether to fit the network view after when done + fit: true, + // Padding on fit + padding: 10, + // Whether to enable incremental mode + randomize: true, + // Node repulsion (non overlapping) multiplier + nodeRepulsion: 4500, + // Ideal edge (non nested) length + idealEdgeLength: 50, + // Divisor to compute edge forces + edgeElasticity: 0.45, + // Nesting factor (multiplier) to compute ideal edge length for nested edges + nestingFactor: 0.1, + // Gravity force (constant) + gravity: 0.25, + // Maximum number of iterations to perform + numIter: 2500, + // For enabling tiling + tile: true, + // Type of layout animation. The option set is {'during', 'end', false} + animate: 'end', + // Duration for animate:end + animationDuration: 500, + // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingVertical: 10, + // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function) + tilingPaddingHorizontal: 10, + // Gravity range (constant) for compounds + gravityRangeCompound: 1.5, + // Gravity force (constant) for compounds + gravityCompound: 1.0, + // Gravity range (constant) + gravityRange: 3.8, + // Initial cooling factor for incremental layout + initialEnergyOnIncremental: 0.5 + }; + + function extend(defaults, options) { + var obj = {}; + + for (var i in defaults) { + obj[i] = defaults[i]; + } + + for (var i in options) { + obj[i] = options[i]; + } + + return obj; + } + function _CoSELayout(_options) { + this.options = extend(defaults, _options); + getUserOptions(this.options); + } + + var getUserOptions = function getUserOptions(options) { + if (options.nodeRepulsion != null) CoSEConstants.DEFAULT_REPULSION_STRENGTH = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH = options.nodeRepulsion; + if (options.idealEdgeLength != null) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength; + if (options.edgeElasticity != null) CoSEConstants.DEFAULT_SPRING_STRENGTH = FDLayoutConstants.DEFAULT_SPRING_STRENGTH = options.edgeElasticity; + if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor; + if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity; + if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter; + if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange; + if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound; + if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound; + if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental; + + if (options.quality == 'draft') LayoutConstants.QUALITY = 0;else if (options.quality == 'proof') LayoutConstants.QUALITY = 2;else LayoutConstants.QUALITY = 1; + + CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels; + CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize; + CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate; + CoSEConstants.TILE = options.tile; + CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === 'function' ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical; + CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === 'function' ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal; + }; + + _CoSELayout.prototype.run = function () { + var ready; + var frameId; + var options = this.options; + this.idToLNode = {}; + var layout = this.layout = new CoSELayout(); + var self = this; + + self.stopped = false; + + this.cy = this.options.cy; + + this.cy.trigger({ type: 'layoutstart', layout: this }); + + var gm = layout.newGraphManager(); + this.gm = gm; + + var nodes = this.options.eles.nodes(); + var edges = this.options.eles.edges(); + + this.root = gm.addRoot(); + this.processChildrenList(this.root, this.getTopMostNodes(nodes), layout); + + for (var i = 0; i < edges.length; i++) { + var edge = edges[i]; + var sourceNode = this.idToLNode[edge.data("source")]; + var targetNode = this.idToLNode[edge.data("target")]; + if (sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) { + var e1 = gm.add(layout.newEdge(), sourceNode, targetNode); + e1.id = edge.id(); + } + } + + var getPositions = function getPositions(ele, i) { + if (typeof ele === "number") { + ele = i; + } + var theId = ele.data('id'); + var lNode = self.idToLNode[theId]; + + return { + x: lNode.getRect().getCenterX(), + y: lNode.getRect().getCenterY() + }; + }; + + /* + * Reposition nodes in iterations animatedly + */ + var iterateAnimated = function iterateAnimated() { + // Thigs to perform after nodes are repositioned on screen + var afterReposition = function afterReposition() { + if (options.fit) { + options.cy.fit(options.eles, options.padding); + } + + if (!ready) { + ready = true; + self.cy.one('layoutready', options.ready); + self.cy.trigger({ type: 'layoutready', layout: self }); + } + }; + + var ticksPerFrame = self.options.refresh; + var isDone; + + for (var i = 0; i < ticksPerFrame && !isDone; i++) { + isDone = self.stopped || self.layout.tick(); + } + + // If layout is done + if (isDone) { + // If the layout is not a sublayout and it is successful perform post layout. + if (layout.checkLayoutSuccess() && !layout.isSubLayout) { + layout.doPostLayout(); + } + + // If layout has a tilingPostLayout function property call it. + if (layout.tilingPostLayout) { + layout.tilingPostLayout(); + } + + layout.isLayoutFinished = true; + + self.options.eles.nodes().positions(getPositions); + + afterReposition(); + + // trigger layoutstop when the layout stops (e.g. finishes) + self.cy.one('layoutstop', self.options.stop); + self.cy.trigger({ type: 'layoutstop', layout: self }); + + if (frameId) { + cancelAnimationFrame(frameId); + } + + ready = false; + return; + } + + var animationData = self.layout.getPositionsData(); // Get positions of layout nodes note that all nodes may not be layout nodes because of tiling + + // Position nodes, for the nodes whose id does not included in data (because they are removed from their parents and included in dummy compounds) + // use position of their ancestors or dummy ancestors + options.eles.nodes().positions(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + // If ele is a compound node, then its position will be defined by its children + if (!ele.isParent()) { + var theId = ele.id(); + var pNode = animationData[theId]; + var temp = ele; + // If pNode is undefined search until finding position data of its first ancestor (It may be dummy as well) + while (pNode == null) { + pNode = animationData[temp.data('parent')] || animationData['DummyCompound_' + temp.data('parent')]; + animationData[theId] = pNode; + temp = temp.parent()[0]; + if (temp == undefined) { + break; + } + } + if (pNode != null) { + return { + x: pNode.x, + y: pNode.y + }; + } else { + return { + x: ele.position('x'), + y: ele.position('y') + }; + } + } + }); + + afterReposition(); + + frameId = requestAnimationFrame(iterateAnimated); + }; + + /* + * Listen 'layoutstarted' event and start animated iteration if animate option is 'during' + */ + layout.addListener('layoutstarted', function () { + if (self.options.animate === 'during') { + frameId = requestAnimationFrame(iterateAnimated); + } + }); + + layout.runLayout(); // Run cose layout + + /* + * If animate option is not 'during' ('end' or false) perform these here (If it is 'during' similar things are already performed) + */ + if (this.options.animate !== "during") { + self.options.eles.nodes().not(":parent").layoutPositions(self, self.options, getPositions); // Use layout positions to reposition the nodes it considers the options parameter + ready = false; + } + + return this; // chaining + }; + + //Get the top most ones of a list of nodes + _CoSELayout.prototype.getTopMostNodes = function (nodes) { + var nodesMap = {}; + for (var i = 0; i < nodes.length; i++) { + nodesMap[nodes[i].id()] = true; + } + var roots = nodes.filter(function (ele, i) { + if (typeof ele === "number") { + ele = i; + } + var parent = ele.parent()[0]; + while (parent != null) { + if (nodesMap[parent.id()]) { + return false; + } + parent = parent.parent()[0]; + } + return true; + }); + + return roots; + }; + + _CoSELayout.prototype.processChildrenList = function (parent, children, layout) { + var size = children.length; + for (var i = 0; i < size; i++) { + var theChild = children[i]; + var children_of_children = theChild.children(); + var theNode; + + var dimensions = theChild.layoutDimensions({ + nodeDimensionsIncludeLabels: this.options.nodeDimensionsIncludeLabels + }); + + if (theChild.outerWidth() != null && theChild.outerHeight() != null) { + theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position('x') - dimensions.w / 2, theChild.position('y') - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h)))); + } else { + theNode = parent.add(new CoSENode(this.graphManager)); + } + // Attach id to the layout node + theNode.id = theChild.data("id"); + // Attach the paddings of cy node to layout node + theNode.paddingLeft = parseInt(theChild.css('padding')); + theNode.paddingTop = parseInt(theChild.css('padding')); + theNode.paddingRight = parseInt(theChild.css('padding')); + theNode.paddingBottom = parseInt(theChild.css('padding')); + + //Attach the label properties to compound if labels will be included in node dimensions + if (this.options.nodeDimensionsIncludeLabels) { + if (theChild.isParent()) { + var labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false }).w; + var labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false }).h; + var labelPos = theChild.css("text-halign"); + theNode.labelWidth = labelWidth; + theNode.labelHeight = labelHeight; + theNode.labelPos = labelPos; + } + } + + // Map the layout node + this.idToLNode[theChild.data("id")] = theNode; + + if (isNaN(theNode.rect.x)) { + theNode.rect.x = 0; + } + + if (isNaN(theNode.rect.y)) { + theNode.rect.y = 0; + } + + if (children_of_children != null && children_of_children.length > 0) { + var theNewGraph; + theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode); + this.processChildrenList(theNewGraph, children_of_children, layout); + } + } + }; + + /** + * @brief : called on continuous layouts to stop them before they finish + */ + _CoSELayout.prototype.stop = function () { + this.stopped = true; + + return this; // chaining + }; + + var register = function register(cytoscape) { + // var Layout = getLayout( cytoscape ); + + cytoscape('layout', 'cose-bilkent', _CoSELayout); + }; + + // auto reg for globals + if (typeof cytoscape !== 'undefined') { + register(cytoscape); + } + + module.exports = register; + + /***/ }) + /******/ ]); + }); +} (cytoscapeCoseBilkent)); + +var cytoscapeCoseBilkentExports = cytoscapeCoseBilkent.exports; +var coseBilkent = /*@__PURE__*/getDefaultExportFromCjs(cytoscapeCoseBilkentExports); + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 4], $V1 = [1, 13], $V2 = [1, 12], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 20], $V6 = [1, 19], $V7 = [6, 7, 8], $V8 = [1, 26], $V9 = [1, 24], $Va = [1, 25], $Vb = [6, 7, 11], $Vc = [1, 6, 13, 15, 16, 19, 22], $Vd = [1, 33], $Ve = [1, 34], $Vf = [1, 6, 7, 11, 13, 15, 16, 19, 22]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mindMap": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "MINDMAP": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "node": 14, "ICON": 15, "CLASS": 16, "nodeWithId": 17, "nodeWithoutId": 18, "NODE_DSTART": 19, "NODE_DESCR": 20, "NODE_DEND": 21, "NODE_ID": 22, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" }, + productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 6: + case 7: + return yy; + case 8: + yy.getLogger().trace("Stop NL "); + break; + case 9: + yy.getLogger().trace("Stop EOF "); + break; + case 11: + yy.getLogger().trace("Stop NL2 "); + break; + case 12: + yy.getLogger().trace("Stop EOF2 "); + break; + case 15: + yy.getLogger().info("Node: ", $$[$0].id); + yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type); + break; + case 16: + yy.getLogger().trace("Icon: ", $$[$0]); + yy.decorateNode({ icon: $$[$0] }); + break; + case 17: + case 21: + yy.decorateNode({ class: $$[$0] }); + break; + case 18: + yy.getLogger().trace("SPACELIST"); + break; + case 19: + yy.getLogger().trace("Node: ", $$[$0].id); + yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type); + break; + case 20: + yy.decorateNode({ icon: $$[$0] }); + break; + case 25: + yy.getLogger().trace("node found ..", $$[$0 - 2]); + this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; + break; + case 26: + this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT }; + break; + case 27: + yy.getLogger().trace("node found ..", $$[$0 - 3]); + this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) }; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($V7, [2, 3]), { 1: [2, 2] }, o($V7, [2, 4]), o($V7, [2, 5]), { 1: [2, 6], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V1, 9: 22, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V8, 7: $V9, 10: 23, 11: $Va }, o($Vb, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: $V5, 22: $V6 }), o($Vb, [2, 18]), o($Vb, [2, 19]), o($Vb, [2, 20]), o($Vb, [2, 21]), o($Vb, [2, 23]), o($Vb, [2, 24]), o($Vb, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: $V8, 7: $V9, 10: 32, 11: $Va }, { 1: [2, 7], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($Vc, [2, 14], { 7: $Vd, 11: $Ve }), o($Vf, [2, 8]), o($Vf, [2, 9]), o($Vf, [2, 10]), o($Vb, [2, 15]), o($Vb, [2, 16]), o($Vb, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, o($Vc, [2, 13], { 7: $Vd, 11: $Ve }), o($Vf, [2, 11]), o($Vf, [2, 12]), { 21: [1, 37] }, o($Vb, [2, 25]), o($Vb, [2, 27])], + defaultActions: { 2: [2, 1], 6: [2, 2] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + yy.getLogger().trace("Found comment", yy_.yytext); + return 6; + case 1: + return 8; + case 2: + this.begin("CLASS"); + break; + case 3: + this.popState(); + return 16; + case 4: + this.popState(); + break; + case 5: + yy.getLogger().trace("Begin icon"); + this.begin("ICON"); + break; + case 6: + yy.getLogger().trace("SPACELINE"); + return 6; + case 7: + return 7; + case 8: + return 15; + case 9: + yy.getLogger().trace("end icon"); + this.popState(); + break; + case 10: + yy.getLogger().trace("Exploding node"); + this.begin("NODE"); + return 19; + case 11: + yy.getLogger().trace("Cloud"); + this.begin("NODE"); + return 19; + case 12: + yy.getLogger().trace("Explosion Bang"); + this.begin("NODE"); + return 19; + case 13: + yy.getLogger().trace("Cloud Bang"); + this.begin("NODE"); + return 19; + case 14: + this.begin("NODE"); + return 19; + case 15: + this.begin("NODE"); + return 19; + case 16: + this.begin("NODE"); + return 19; + case 17: + this.begin("NODE"); + return 19; + case 18: + return 13; + case 19: + return 22; + case 20: + return 11; + case 21: + this.begin("NSTR2"); + break; + case 22: + return "NODE_DESCR"; + case 23: + this.popState(); + break; + case 24: + yy.getLogger().trace("Starting NSTR"); + this.begin("NSTR"); + break; + case 25: + yy.getLogger().trace("description:", yy_.yytext); + return "NODE_DESCR"; + case 26: + this.popState(); + break; + case 27: + this.popState(); + yy.getLogger().trace("node end ))"); + return "NODE_DEND"; + case 28: + this.popState(); + yy.getLogger().trace("node end )"); + return "NODE_DEND"; + case 29: + this.popState(); + yy.getLogger().trace("node end ...", yy_.yytext); + return "NODE_DEND"; + case 30: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 31: + this.popState(); + yy.getLogger().trace("node end (-"); + return "NODE_DEND"; + case 32: + this.popState(); + yy.getLogger().trace("node end (-"); + return "NODE_DEND"; + case 33: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 34: + this.popState(); + yy.getLogger().trace("node end (("); + return "NODE_DEND"; + case 35: + yy.getLogger().trace("Long description:", yy_.yytext); + return 20; + case 36: + yy.getLogger().trace("Long description:", yy_.yytext); + return 20; + } + }, + rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i], + conditions: { "CLASS": { "rules": [3, 4], "inclusive": false }, "ICON": { "rules": [8, 9], "inclusive": false }, "NSTR2": { "rules": [22, 23], "inclusive": false }, "NSTR": { "rules": [25, 26], "inclusive": false }, "NODE": { "rules": [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let nodes = []; +let cnt = 0; +let elements = {}; +const clear = () => { + nodes = []; + cnt = 0; + elements = {}; +}; +const getParent = function(level) { + for (let i = nodes.length - 1; i >= 0; i--) { + if (nodes[i].level < level) { + return nodes[i]; + } + } + return null; +}; +const getMindmap = () => { + return nodes.length > 0 ? nodes[0] : null; +}; +const addNode = (level, id, descr, type) => { + var _a, _b; + log$1.info("addNode", level, id, descr, type); + const conf = getConfig(); + let padding = ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig$2.mindmap.padding; + switch (type) { + case nodeType.ROUNDED_RECT: + case nodeType.RECT: + case nodeType.HEXAGON: + padding *= 2; + } + const node = { + id: cnt++, + nodeId: sanitizeText$2(id, conf), + level, + descr: sanitizeText$2(descr, conf), + type, + children: [], + width: ((_b = conf.mindmap) == null ? void 0 : _b.maxNodeWidth) ?? defaultConfig$2.mindmap.maxNodeWidth, + padding + }; + const parent = getParent(level); + if (parent) { + parent.children.push(node); + nodes.push(node); + } else { + if (nodes.length === 0) { + nodes.push(node); + } else { + throw new Error( + 'There can be only one root. No parent could be found for ("' + node.descr + '")' + ); + } + } +}; +const nodeType = { + DEFAULT: 0, + NO_BORDER: 0, + ROUNDED_RECT: 1, + RECT: 2, + CIRCLE: 3, + CLOUD: 4, + BANG: 5, + HEXAGON: 6 +}; +const getType = (startStr, endStr) => { + log$1.debug("In get type", startStr, endStr); + switch (startStr) { + case "[": + return nodeType.RECT; + case "(": + return endStr === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD; + case "((": + return nodeType.CIRCLE; + case ")": + return nodeType.CLOUD; + case "))": + return nodeType.BANG; + case "{{": + return nodeType.HEXAGON; + default: + return nodeType.DEFAULT; + } +}; +const setElementForId = (id, element) => { + elements[id] = element; +}; +const decorateNode = (decoration) => { + if (!decoration) { + return; + } + const config = getConfig(); + const node = nodes[nodes.length - 1]; + if (decoration.icon) { + node.icon = sanitizeText$2(decoration.icon, config); + } + if (decoration.class) { + node.class = sanitizeText$2(decoration.class, config); + } +}; +const type2Str = (type) => { + switch (type) { + case nodeType.DEFAULT: + return "no-border"; + case nodeType.RECT: + return "rect"; + case nodeType.ROUNDED_RECT: + return "rounded-rect"; + case nodeType.CIRCLE: + return "circle"; + case nodeType.CLOUD: + return "cloud"; + case nodeType.BANG: + return "bang"; + case nodeType.HEXAGON: + return "hexgon"; + default: + return "no-border"; + } +}; +const getLogger = () => log$1; +const getElementById = (id) => elements[id]; +const db = { + clear, + addNode, + getMindmap, + nodeType, + getType, + setElementForId, + decorateNode, + type2Str, + getLogger, + getElementById +}; +const db$1 = db; +const MAX_SECTIONS = 12; +const defaultBkg = function(db2, elem, node, section) { + const rd = 5; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` + ); + elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); +}; +const rectBkg = function(db2, elem, node) { + elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("width", node.width); +}; +const cloudBkg = function(db2, elem, node) { + const w = node.width; + const h = node.height; + const r1 = 0.15 * w; + const r2 = 0.25 * w; + const r3 = 0.35 * w; + const r4 = 0.2 * w; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 0 a${r1},${r1} 0 0,1 ${w * 0.25},${-1 * w * 0.1} + a${r3},${r3} 1 0,1 ${w * 0.4},${-1 * w * 0.1} + a${r2},${r2} 1 0,1 ${w * 0.35},${1 * w * 0.2} + + a${r1},${r1} 1 0,1 ${w * 0.15},${1 * h * 0.35} + a${r4},${r4} 1 0,1 ${-1 * w * 0.15},${1 * h * 0.65} + + a${r2},${r1} 1 0,1 ${-1 * w * 0.25},${w * 0.15} + a${r3},${r3} 1 0,1 ${-1 * w * 0.5},${0} + a${r1},${r1} 1 0,1 ${-1 * w * 0.25},${-1 * w * 0.15} + + a${r1},${r1} 1 0,1 ${-1 * w * 0.1},${-1 * h * 0.35} + a${r4},${r4} 1 0,1 ${w * 0.1},${-1 * h * 0.65} + + H0 V0 Z` + ); +}; +const bangBkg = function(db2, elem, node) { + const w = node.width; + const h = node.height; + const r = 0.15 * w; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr( + "d", + `M0 0 a${r},${r} 1 0,0 ${w * 0.25},${-1 * h * 0.1} + a${r},${r} 1 0,0 ${w * 0.25},${0} + a${r},${r} 1 0,0 ${w * 0.25},${0} + a${r},${r} 1 0,0 ${w * 0.25},${1 * h * 0.1} + + a${r},${r} 1 0,0 ${w * 0.15},${1 * h * 0.33} + a${r * 0.8},${r * 0.8} 1 0,0 ${0},${1 * h * 0.34} + a${r},${r} 1 0,0 ${-1 * w * 0.15},${1 * h * 0.33} + + a${r},${r} 1 0,0 ${-1 * w * 0.25},${h * 0.15} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${0} + a${r},${r} 1 0,0 ${-1 * w * 0.25},${-1 * h * 0.15} + + a${r},${r} 1 0,0 ${-1 * w * 0.1},${-1 * h * 0.33} + a${r * 0.8},${r * 0.8} 1 0,0 ${0},${-1 * h * 0.34} + a${r},${r} 1 0,0 ${w * 0.1},${-1 * h * 0.33} + + H0 V0 Z` + ); +}; +const circleBkg = function(db2, elem, node) { + elem.append("circle").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("r", node.width / 2); +}; +function insertPolygonShape(parent, w, h, points, node) { + return parent.insert("polygon", ":first-child").attr( + "points", + points.map(function(d) { + return d.x + "," + d.y; + }).join(" ") + ).attr("transform", "translate(" + (node.width - w) / 2 + ", " + h + ")"); +} +const hexagonBkg = function(_db, elem, node) { + const h = node.height; + const f = 4; + const m = h / f; + const w = node.width - node.padding + 2 * m; + const points = [ + { x: m, y: 0 }, + { x: w - m, y: 0 }, + { x: w, y: -h / 2 }, + { x: w - m, y: -h }, + { x: m, y: -h }, + { x: 0, y: -h / 2 } + ]; + insertPolygonShape(elem, w, h, points, node); +}; +const roundedRectBkg = function(db2, elem, node) { + elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + db2.type2Str(node.type)).attr("height", node.height).attr("rx", node.padding).attr("ry", node.padding).attr("width", node.width); +}; +const drawNode = function(db2, elem, node, fullSection, conf) { + const htmlLabels = conf.htmlLabels; + const section = fullSection % (MAX_SECTIONS - 1); + const nodeElem = elem.append("g"); + node.section = section; + let sectionClass = "section-" + section; + if (section < 0) { + sectionClass += " section-root"; + } + nodeElem.attr("class", (node.class ? node.class + " " : "") + "mindmap-node " + sectionClass); + const bkgElem = nodeElem.append("g"); + const textElem = nodeElem.append("g"); + const description = node.descr.replace(/()/g, "\n"); + createText(textElem, description, { + useHtmlLabels: htmlLabels, + width: node.width, + classes: "mindmap-node-label" + }); + if (!htmlLabels) { + textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle"); + } + const bbox = textElem.node().getBBox(); + const [fontSize] = parseFontSize(conf.fontSize); + node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; + node.width = bbox.width + 2 * node.padding; + if (node.icon) { + if (node.type === db2.nodeType.CIRCLE) { + node.height += 50; + node.width += 50; + const icon = nodeElem.append("foreignObject").attr("height", "50px").attr("width", node.width).attr("style", "text-align: center;"); + icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); + textElem.attr( + "transform", + "translate(" + node.width / 2 + ", " + (node.height / 2 - 1.5 * node.padding) + ")" + ); + } else { + node.width += 50; + const orgHeight = node.height; + node.height = Math.max(orgHeight, 60); + const heightDiff = Math.abs(node.height - orgHeight); + const icon = nodeElem.append("foreignObject").attr("width", "60px").attr("height", node.height).attr("style", "text-align: center;margin-top:" + heightDiff / 2 + "px;"); + icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon); + textElem.attr( + "transform", + "translate(" + (25 + node.width / 2) + ", " + (heightDiff / 2 + node.padding / 2) + ")" + ); + } + } else { + if (!htmlLabels) { + const dx = node.width / 2; + const dy = node.padding / 2; + textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); + } else { + const dx = (node.width - bbox.width) / 2; + const dy = (node.height - bbox.height) / 2; + textElem.attr("transform", "translate(" + dx + ", " + dy + ")"); + } + } + switch (node.type) { + case db2.nodeType.DEFAULT: + defaultBkg(db2, bkgElem, node, section); + break; + case db2.nodeType.ROUNDED_RECT: + roundedRectBkg(db2, bkgElem, node); + break; + case db2.nodeType.RECT: + rectBkg(db2, bkgElem, node); + break; + case db2.nodeType.CIRCLE: + bkgElem.attr("transform", "translate(" + node.width / 2 + ", " + +node.height / 2 + ")"); + circleBkg(db2, bkgElem, node); + break; + case db2.nodeType.CLOUD: + cloudBkg(db2, bkgElem, node); + break; + case db2.nodeType.BANG: + bangBkg(db2, bkgElem, node); + break; + case db2.nodeType.HEXAGON: + hexagonBkg(db2, bkgElem, node); + break; + } + db2.setElementForId(node.id, nodeElem); + return node.height; +}; +const positionNode = function(db2, node) { + const nodeElem = db2.getElementById(node.id); + const x = node.x || 0; + const y = node.y || 0; + nodeElem.attr("transform", "translate(" + x + "," + y + ")"); +}; +cytoscape$1.use(coseBilkent); +function drawNodes(db2, svg, mindmap, section, conf) { + drawNode(db2, svg, mindmap, section, conf); + if (mindmap.children) { + mindmap.children.forEach((child, index) => { + drawNodes(db2, svg, child, section < 0 ? index : section, conf); + }); + } +} +function drawEdges(edgesEl, cy) { + cy.edges().map((edge, id) => { + const data = edge.data(); + if (edge[0]._private.bodyBounds) { + const bounds = edge[0]._private.rscratch; + log$1.trace("Edge: ", id, data); + edgesEl.insert("path").attr( + "d", + `M ${bounds.startX},${bounds.startY} L ${bounds.midX},${bounds.midY} L${bounds.endX},${bounds.endY} ` + ).attr("class", "edge section-edge-" + data.section + " edge-depth-" + data.depth); + } + }); +} +function addNodes(mindmap, cy, conf, level) { + cy.add({ + group: "nodes", + data: { + id: mindmap.id.toString(), + labelText: mindmap.descr, + height: mindmap.height, + width: mindmap.width, + level, + nodeId: mindmap.id, + padding: mindmap.padding, + type: mindmap.type + }, + position: { + x: mindmap.x, + y: mindmap.y + } + }); + if (mindmap.children) { + mindmap.children.forEach((child) => { + addNodes(child, cy, conf, level + 1); + cy.add({ + group: "edges", + data: { + id: `${mindmap.id}_${child.id}`, + source: mindmap.id, + target: child.id, + depth: level, + section: child.section + } + }); + }); + } +} +function layoutMindmap(node, conf) { + return new Promise((resolve) => { + const renderEl = select("body").append("div").attr("id", "cy").attr("style", "display:none"); + const cy = cytoscape$1({ + container: document.getElementById("cy"), + // container to render in + style: [ + { + selector: "edge", + style: { + "curve-style": "bezier" + } + } + ] + }); + renderEl.remove(); + addNodes(node, cy, conf, 0); + cy.nodes().forEach(function(n) { + n.layoutDimensions = () => { + const data = n.data(); + return { w: data.width, h: data.height }; + }; + }); + cy.layout({ + name: "cose-bilkent", + // @ts-ignore Types for cose-bilkent are not correct? + quality: "proof", + styleEnabled: false, + animate: false + }).run(); + cy.ready((e) => { + log$1.info("Ready", e); + resolve(cy); + }); + }); +} +function positionNodes(db2, cy) { + cy.nodes().map((node, id) => { + const data = node.data(); + data.x = node.position().x; + data.y = node.position().y; + positionNode(db2, data); + const el = db2.getElementById(data.nodeId); + log$1.info("Id:", id, "Position: (", node.position().x, ", ", node.position().y, ")", data); + el.attr( + "transform", + `translate(${node.position().x - data.width / 2}, ${node.position().y - data.height / 2})` + ); + el.attr("attr", `apa-${id})`); + }); +} +const draw = async (text, id, _version, diagObj) => { + var _a, _b; + log$1.debug("Rendering mindmap diagram\n" + text); + const db2 = diagObj.db; + const mm = db2.getMindmap(); + if (!mm) { + return; + } + const conf = getConfig(); + conf.htmlLabels = false; + const svg = selectSvgElement(id); + const edgesElem = svg.append("g"); + edgesElem.attr("class", "mindmap-edges"); + const nodesElem = svg.append("g"); + nodesElem.attr("class", "mindmap-nodes"); + drawNodes(db2, nodesElem, mm, -1, conf); + const cy = await layoutMindmap(mm, conf); + drawEdges(edgesElem, cy); + positionNodes(db2, cy); + setupGraphViewbox$1( + void 0, + svg, + ((_a = conf.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig$2.mindmap.padding, + ((_b = conf.mindmap) == null ? void 0 : _b.useMaxWidth) ?? defaultConfig$2.mindmap.useMaxWidth + ); +}; +const renderer = { + draw +}; +const genSections = (options) => { + let sections = ""; + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i]; + if (isDark(options["lineColor" + i])) { + options["lineColor" + i] = lighten(options["lineColor" + i], 20); + } else { + options["lineColor" + i] = darken(options["lineColor" + i], 20); + } + } + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + const sw = "" + (17 - 3 * i); + sections += ` + .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path { + fill: ${options["cScale" + i]}; + } + .section-${i - 1} text { + fill: ${options["cScaleLabel" + i]}; + } + .node-icon-${i - 1} { + font-size: 40px; + color: ${options["cScaleLabel" + i]}; + } + .section-edge-${i - 1}{ + stroke: ${options["cScale" + i]}; + } + .edge-depth-${i - 1}{ + stroke-width: ${sw}; + } + .section-${i - 1} line { + stroke: ${options["cScaleInv" + i]} ; + stroke-width: 3; + } + + .disabled, .disabled circle, .disabled text { + fill: lightgray; + } + .disabled text { + fill: #efefef; + } + `; + } + return sections; +}; +const getStyles = (options) => ` + .edge { + stroke-width: 3; + } + ${genSections(options)} + .section-root rect, .section-root path, .section-root circle, .section-root polygon { + fill: ${options.git0}; + } + .section-root text { + fill: ${options.gitBranchLabel0}; + } + .icon-container { + height:100%; + display: flex; + justify-content: center; + align-items: center; + } + .edge { + fill: none; + } + .mindmap-node-label { + dy: 1em; + alignment-baseline: middle; + text-anchor: middle; + dominant-baseline: middle; + text-align: center; + } +`; +const styles = getStyles; +const diagram = { + db: db$1, + renderer, + parser: parser$1, + styles +}; + +export { diagram }; diff --git a/libs/marked/ordinal-X8I8fqLF.js b/libs/marked/ordinal-X8I8fqLF.js new file mode 100644 index 0000000..36d6057 --- /dev/null +++ b/libs/marked/ordinal-X8I8fqLF.js @@ -0,0 +1,92 @@ +import { i as initRange } from './init-zpY4DTin.js'; + +class InternMap extends Map { + constructor(entries, key = keyof) { + super(); + Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}}); + if (entries != null) for (const [key, value] of entries) this.set(key, value); + } + get(key) { + return super.get(intern_get(this, key)); + } + has(key) { + return super.has(intern_get(this, key)); + } + set(key, value) { + return super.set(intern_set(this, key), value); + } + delete(key) { + return super.delete(intern_delete(this, key)); + } +} + +function intern_get({_intern, _key}, value) { + const key = _key(value); + return _intern.has(key) ? _intern.get(key) : value; +} + +function intern_set({_intern, _key}, value) { + const key = _key(value); + if (_intern.has(key)) return _intern.get(key); + _intern.set(key, value); + return value; +} + +function intern_delete({_intern, _key}, value) { + const key = _key(value); + if (_intern.has(key)) { + value = _intern.get(key); + _intern.delete(key); + } + return value; +} + +function keyof(value) { + return value !== null && typeof value === "object" ? value.valueOf() : value; +} + +const implicit = Symbol("implicit"); + +function ordinal() { + var index = new InternMap(), + domain = [], + range = [], + unknown = implicit; + + function scale(d) { + let i = index.get(d); + if (i === undefined) { + if (unknown !== implicit) return unknown; + index.set(d, i = domain.push(d) - 1); + } + return range[i % range.length]; + } + + scale.domain = function(_) { + if (!arguments.length) return domain.slice(); + domain = [], index = new InternMap(); + for (const value of _) { + if (index.has(value)) continue; + index.set(value, domain.push(value) - 1); + } + return scale; + }; + + scale.range = function(_) { + return arguments.length ? (range = Array.from(_), scale) : range.slice(); + }; + + scale.unknown = function(_) { + return arguments.length ? (unknown = _, scale) : unknown; + }; + + scale.copy = function() { + return ordinal(domain, range).unknown(unknown); + }; + + initRange.apply(scale, arguments); + + return scale; +} + +export { ordinal as o }; diff --git a/libs/marked/path-BZ3S9nBE.js b/libs/marked/path-BZ3S9nBE.js new file mode 100644 index 0000000..bda0477 --- /dev/null +++ b/libs/marked/path-BZ3S9nBE.js @@ -0,0 +1,171 @@ +const pi = Math.PI, + tau = 2 * pi, + epsilon = 1e-6, + tauEpsilon = tau - epsilon; + +function append(strings) { + this._ += strings[0]; + for (let i = 1, n = strings.length; i < n; ++i) { + this._ += arguments[i] + strings[i]; + } +} + +function appendRound(digits) { + let d = Math.floor(digits); + if (!(d >= 0)) throw new Error(`invalid digits: ${digits}`); + if (d > 15) return append; + const k = 10 ** d; + return function(strings) { + this._ += strings[0]; + for (let i = 1, n = strings.length; i < n; ++i) { + this._ += Math.round(arguments[i] * k) / k + strings[i]; + } + }; +} + +class Path { + constructor(digits) { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; + this._append = digits == null ? append : appendRound(digits); + } + moveTo(x, y) { + this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`; + } + closePath() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._append`Z`; + } + } + lineTo(x, y) { + this._append`L${this._x1 = +x},${this._y1 = +y}`; + } + quadraticCurveTo(x1, y1, x, y) { + this._append`Q${+x1},${+y1},${this._x1 = +x},${this._y1 = +y}`; + } + bezierCurveTo(x1, y1, x2, y2, x, y) { + this._append`C${+x1},${+y1},${+x2},${+y2},${this._x1 = +x},${this._y1 = +y}`; + } + arcTo(x1, y1, x2, y2, r) { + x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; + + // Is the radius negative? Error. + if (r < 0) throw new Error(`negative radius: ${r}`); + + let x0 = this._x1, + y0 = this._y1, + x21 = x2 - x1, + y21 = y2 - y1, + x01 = x0 - x1, + y01 = y0 - y1, + l01_2 = x01 * x01 + y01 * y01; + + // Is this path empty? Move to (x1,y1). + if (this._x1 === null) { + this._append`M${this._x1 = x1},${this._y1 = y1}`; + } + + // Or, is (x1,y1) coincident with (x0,y0)? Do nothing. + else if (!(l01_2 > epsilon)); + + // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear? + // Equivalently, is (x1,y1) coincident with (x2,y2)? + // Or, is the radius zero? Line to (x1,y1). + else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) { + this._append`L${this._x1 = x1},${this._y1 = y1}`; + } + + // Otherwise, draw an arc! + else { + let x20 = x2 - x0, + y20 = y2 - y0, + l21_2 = x21 * x21 + y21 * y21, + l20_2 = x20 * x20 + y20 * y20, + l21 = Math.sqrt(l21_2), + l01 = Math.sqrt(l01_2), + l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), + t01 = l / l01, + t21 = l / l21; + + // If the start tangent is not coincident with (x0,y0), line to. + if (Math.abs(t01 - 1) > epsilon) { + this._append`L${x1 + t01 * x01},${y1 + t01 * y01}`; + } + + this._append`A${r},${r},0,0,${+(y01 * x20 > x01 * y20)},${this._x1 = x1 + t21 * x21},${this._y1 = y1 + t21 * y21}`; + } + } + arc(x, y, r, a0, a1, ccw) { + x = +x, y = +y, r = +r, ccw = !!ccw; + + // Is the radius negative? Error. + if (r < 0) throw new Error(`negative radius: ${r}`); + + let dx = r * Math.cos(a0), + dy = r * Math.sin(a0), + x0 = x + dx, + y0 = y + dy, + cw = 1 ^ ccw, + da = ccw ? a0 - a1 : a1 - a0; + + // Is this path empty? Move to (x0,y0). + if (this._x1 === null) { + this._append`M${x0},${y0}`; + } + + // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). + else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) { + this._append`L${x0},${y0}`; + } + + // Is this arc empty? We’re done. + if (!r) return; + + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau + tau; + + // Is this a complete circle? Draw two arcs to complete the circle. + if (da > tauEpsilon) { + this._append`A${r},${r},0,1,${cw},${x - dx},${y - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`; + } + + // Is this arc non-empty? Draw an arc! + else if (da > epsilon) { + this._append`A${r},${r},0,${+(da >= pi)},${cw},${this._x1 = x + r * Math.cos(a1)},${this._y1 = y + r * Math.sin(a1)}`; + } + } + rect(x, y, w, h) { + this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${w = +w}v${+h}h${-w}Z`; + } + toString() { + return this._; + } +} + +function constant(x) { + return function constant() { + return x; + }; +} + +function withPath(shape) { + let digits = 3; + + shape.digits = function(_) { + if (!arguments.length) return digits; + if (_ == null) { + digits = null; + } else { + const d = Math.floor(_); + if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`); + digits = d; + } + return shape; + }; + + return () => new Path(digits); +} + +export { constant as c, withPath as w }; diff --git a/libs/marked/pieDiagram-bb1d19e5-CDMXSh7k.js b/libs/marked/pieDiagram-bb1d19e5-CDMXSh7k.js new file mode 100644 index 0000000..c945846 --- /dev/null +++ b/libs/marked/pieDiagram-bb1d19e5-CDMXSh7k.js @@ -0,0 +1,800 @@ +import { V as tau, W as defaultConfig$2, C as setDiagramTitle, D as getDiagramTitle, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, E as clear$1, d as sanitizeText$2, c as getConfig$1, l as log$1, X as cleanAndMerge, U as selectSvgElement, Y as parseFontSize, i as configureSvgSize } from './index-Bd_FDXSq.js'; +import { a as arc } from './arc-DhQC9rXN.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { a as array } from './array-DJxSMw-N.js'; +import { c as constant } from './path-BZ3S9nBE.js'; +import './init-zpY4DTin.js'; + +function descending(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +} + +function identity(d) { + return d; +} + +function pie() { + var value = identity, + sortValues = descending, + sort = null, + startAngle = constant(0), + endAngle = constant(tau), + padAngle = constant(0); + + function pie(data) { + var i, + n = (data = array(data)).length, + j, + k, + sum = 0, + index = new Array(n), + arcs = new Array(n), + a0 = +startAngle.apply(this, arguments), + da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), + a1, + p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), + pa = p * (da < 0 ? -1 : 1), + v; + + for (i = 0; i < n; ++i) { + if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) { + sum += v; + } + } + + // Optionally sort the arcs by previously-computed values or by data. + if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); }); + else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); }); + + // Compute the arcs! They are stored in the original data's order. + for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) { + j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = { + data: data[j], + index: i, + value: v, + startAngle: a0, + endAngle: a1, + padAngle: p + }; + } + + return arcs; + } + + pie.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value; + }; + + pie.sortValues = function(_) { + return arguments.length ? (sortValues = _, sort = null, pie) : sortValues; + }; + + pie.sort = function(_) { + return arguments.length ? (sort = _, sortValues = null, pie) : sort; + }; + + pie.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle; + }; + + pie.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle; + }; + + pie.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle; + }; + + return pie; +} + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 10, 12, 14, 16, 18, 19, 20, 21, 22], $V5 = [2, 4], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 20, 21, 22], $V7 = [20, 21, 22], $V8 = [2, 7], $V9 = [1, 12], $Va = [1, 13], $Vb = [1, 14], $Vc = [1, 15], $Vd = [1, 16], $Ve = [1, 17]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "PIE": 5, "document": 6, "showData": 7, "line": 8, "statement": 9, "txt": 10, "value": 11, "title": 12, "title_value": 13, "acc_title": 14, "acc_title_value": 15, "acc_descr": 16, "acc_descr_value": 17, "acc_descr_multiline_value": 18, "section": 19, "NEWLINE": 20, ";": 21, "EOF": 22, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "PIE", 7: "showData", 10: "txt", 11: "value", 12: "title", 13: "title_value", 14: "acc_title", 15: "acc_title_value", 16: "acc_descr", 17: "acc_descr_value", 18: "acc_descr_multiline_value", 19: "section", 20: "NEWLINE", 21: ";", 22: "EOF" }, + productions_: [0, [3, 2], [3, 2], [3, 3], [6, 0], [6, 2], [8, 2], [9, 0], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [4, 1], [4, 1], [4, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setShowData(true); + break; + case 6: + this.$ = $$[$0 - 1]; + break; + case 8: + yy.addSection($$[$0 - 1], yy.cleanupValue($$[$0])); + break; + case 9: + this.$ = $$[$0].trim(); + yy.setDiagramTitle(this.$); + break; + case 10: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 11: + case 12: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 13: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 20: $V1, 21: $V2, 22: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 20: $V1, 21: $V2, 22: $V3 }, o($V4, $V5, { 6: 8, 7: [1, 9] }), o($V6, [2, 14]), o($V6, [2, 15]), o($V6, [2, 16]), { 1: [2, 1] }, o($V7, $V8, { 8: 10, 9: 11, 1: [2, 2], 10: $V9, 12: $Va, 14: $Vb, 16: $Vc, 18: $Vd, 19: $Ve }), o($V4, $V5, { 6: 18 }), o($V4, [2, 5]), { 4: 19, 20: $V1, 21: $V2, 22: $V3 }, { 11: [1, 20] }, { 13: [1, 21] }, { 15: [1, 22] }, { 17: [1, 23] }, o($V7, [2, 12]), o($V7, [2, 13]), o($V7, $V8, { 8: 10, 9: 11, 1: [2, 3], 10: $V9, 12: $Va, 14: $Vb, 16: $Vc, 18: $Vd, 19: $Ve }), o($V4, [2, 6]), o($V7, [2, 8]), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11])], + defaultActions: { 7: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 20; + case 3: + break; + case 4: + break; + case 5: + this.begin("title"); + return 12; + case 6: + this.popState(); + return "title_value"; + case 7: + this.begin("acc_title"); + return 14; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 16; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + this.begin("string"); + break; + case 15: + this.popState(); + break; + case 16: + return "txt"; + case 17: + return 5; + case 18: + return 7; + case 19: + return "value"; + case 20: + return 22; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:[\s]+)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:pie\b)/i, /^(?:showData\b)/i, /^(?::[\s]*[\d]+(?:\.[\d]+)?)/i, /^(?:$)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [6], "inclusive": false }, "string": { "rules": [15, 16], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 7, 9, 11, 14, 17, 18, 19, 20], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const DEFAULT_PIE_CONFIG = defaultConfig$2.pie; +const DEFAULT_PIE_DB = { + sections: {}, + showData: false, + config: DEFAULT_PIE_CONFIG +}; +let sections = DEFAULT_PIE_DB.sections; +let showData = DEFAULT_PIE_DB.showData; +const config = structuredClone(DEFAULT_PIE_CONFIG); +const getConfig = () => structuredClone(config); +const clear = () => { + sections = structuredClone(DEFAULT_PIE_DB.sections); + showData = DEFAULT_PIE_DB.showData; + clear$1(); +}; +const addSection = (label, value) => { + label = sanitizeText$2(label, getConfig$1()); + if (sections[label] === void 0) { + sections[label] = value; + log$1.debug(`added new section: ${label}, with value: ${value}`); + } +}; +const getSections = () => sections; +const cleanupValue = (value) => { + if (value.substring(0, 1) === ":") { + value = value.substring(1).trim(); + } + return Number(value.trim()); +}; +const setShowData = (toggle) => { + showData = toggle; +}; +const getShowData = () => showData; +const db = { + getConfig, + clear, + setDiagramTitle, + getDiagramTitle, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addSection, + getSections, + cleanupValue, + setShowData, + getShowData +}; +const getStyles = (options) => ` + .pieCircle{ + stroke: ${options.pieStrokeColor}; + stroke-width : ${options.pieStrokeWidth}; + opacity : ${options.pieOpacity}; + } + .pieOuterCircle{ + stroke: ${options.pieOuterStrokeColor}; + stroke-width: ${options.pieOuterStrokeWidth}; + fill: none; + } + .pieTitleText { + text-anchor: middle; + font-size: ${options.pieTitleTextSize}; + fill: ${options.pieTitleTextColor}; + font-family: ${options.fontFamily}; + } + .slice { + font-family: ${options.fontFamily}; + fill: ${options.pieSectionTextColor}; + font-size:${options.pieSectionTextSize}; + // fill: white; + } + .legend text { + fill: ${options.pieLegendTextColor}; + font-family: ${options.fontFamily}; + font-size: ${options.pieLegendTextSize}; + } +`; +const styles = getStyles; +const createPieArcs = (sections2) => { + const pieData = Object.entries(sections2).map((element) => { + return { + label: element[0], + value: element[1] + }; + }).sort((a, b) => { + return b.value - a.value; + }); + const pie$1 = pie().value( + (d3Section) => d3Section.value + ); + return pie$1(pieData); +}; +const draw = (text, id, _version, diagObj) => { + log$1.debug("rendering pie chart\n" + text); + const db2 = diagObj.db; + const globalConfig = getConfig$1(); + const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie); + const MARGIN = 40; + const LEGEND_RECT_SIZE = 18; + const LEGEND_SPACING = 4; + const height = 450; + const pieWidth = height; + const svg = selectSvgElement(id); + const group = svg.append("g"); + const sections2 = db2.getSections(); + group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")"); + const { themeVariables } = globalConfig; + let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth); + outerStrokeWidth ?? (outerStrokeWidth = 2); + const textPosition = pieConfig.textPosition; + const radius = Math.min(pieWidth, height) / 2 - MARGIN; + const arcGenerator = arc().innerRadius(0).outerRadius(radius); + const labelArcGenerator = arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition); + group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle"); + const arcs = createPieArcs(sections2); + const myGeneratedColors = [ + themeVariables.pie1, + themeVariables.pie2, + themeVariables.pie3, + themeVariables.pie4, + themeVariables.pie5, + themeVariables.pie6, + themeVariables.pie7, + themeVariables.pie8, + themeVariables.pie9, + themeVariables.pie10, + themeVariables.pie11, + themeVariables.pie12 + ]; + const color = ordinal(myGeneratedColors); + group.selectAll("mySlices").data(arcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => { + return color(datum.data.label); + }).attr("class", "pieCircle"); + let sum = 0; + Object.keys(sections2).forEach((key) => { + sum += sections2[key]; + }); + group.selectAll("mySlices").data(arcs).enter().append("text").text((datum) => { + return (datum.data.value / sum * 100).toFixed(0) + "%"; + }).attr("transform", (datum) => { + return "translate(" + labelArcGenerator.centroid(datum) + ")"; + }).style("text-anchor", "middle").attr("class", "slice"); + group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText"); + const legend = group.selectAll(".legend").data(color.domain()).enter().append("g").attr("class", "legend").attr("transform", (_datum, index) => { + const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING; + const offset = height2 * color.domain().length / 2; + const horizontal = 12 * LEGEND_RECT_SIZE; + const vertical = index * height2 - offset; + return "translate(" + horizontal + "," + vertical + ")"; + }); + legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", color).style("stroke", color); + legend.data(arcs).append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((datum) => { + const { label, value } = datum.data; + if (db2.getShowData()) { + return `${label} [${value}]`; + } + return label; + }); + const longestTextWidth = Math.max( + ...legend.selectAll("text").nodes().map((node) => (node == null ? void 0 : node.getBoundingClientRect().width) ?? 0) + ); + const totalWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth; + svg.attr("viewBox", `0 0 ${totalWidth} ${height}`); + configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth); +}; +const renderer = { draw }; +const diagram = { + parser: parser$1, + db, + renderer, + styles +}; + +export { diagram }; diff --git a/libs/marked/pieDiagram-bb1d19e5-CL3Vsrzt.js b/libs/marked/pieDiagram-bb1d19e5-CL3Vsrzt.js new file mode 100644 index 0000000..ba178bb --- /dev/null +++ b/libs/marked/pieDiagram-bb1d19e5-CL3Vsrzt.js @@ -0,0 +1,800 @@ +import { V as tau, W as defaultConfig$2, C as setDiagramTitle, D as getDiagramTitle, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, E as clear$1, d as sanitizeText$2, c as getConfig$1, l as log$1, X as cleanAndMerge, U as selectSvgElement, Y as parseFontSize, i as configureSvgSize } from './index-CN3YjQ0n.js'; +import { a as arc } from './arc-CNdYl1O_.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { a as array } from './array-DJxSMw-N.js'; +import { c as constant } from './path-BZ3S9nBE.js'; +import './init-zpY4DTin.js'; + +function descending(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +} + +function identity(d) { + return d; +} + +function pie() { + var value = identity, + sortValues = descending, + sort = null, + startAngle = constant(0), + endAngle = constant(tau), + padAngle = constant(0); + + function pie(data) { + var i, + n = (data = array(data)).length, + j, + k, + sum = 0, + index = new Array(n), + arcs = new Array(n), + a0 = +startAngle.apply(this, arguments), + da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), + a1, + p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), + pa = p * (da < 0 ? -1 : 1), + v; + + for (i = 0; i < n; ++i) { + if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) { + sum += v; + } + } + + // Optionally sort the arcs by previously-computed values or by data. + if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); }); + else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); }); + + // Compute the arcs! They are stored in the original data's order. + for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) { + j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = { + data: data[j], + index: i, + value: v, + startAngle: a0, + endAngle: a1, + padAngle: p + }; + } + + return arcs; + } + + pie.value = function(_) { + return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value; + }; + + pie.sortValues = function(_) { + return arguments.length ? (sortValues = _, sort = null, pie) : sortValues; + }; + + pie.sort = function(_) { + return arguments.length ? (sort = _, sortValues = null, pie) : sort; + }; + + pie.startAngle = function(_) { + return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle; + }; + + pie.endAngle = function(_) { + return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle; + }; + + pie.padAngle = function(_) { + return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle; + }; + + return pie; +} + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 10, 12, 14, 16, 18, 19, 20, 21, 22], $V5 = [2, 4], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 20, 21, 22], $V7 = [20, 21, 22], $V8 = [2, 7], $V9 = [1, 12], $Va = [1, 13], $Vb = [1, 14], $Vc = [1, 15], $Vd = [1, 16], $Ve = [1, 17]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "PIE": 5, "document": 6, "showData": 7, "line": 8, "statement": 9, "txt": 10, "value": 11, "title": 12, "title_value": 13, "acc_title": 14, "acc_title_value": 15, "acc_descr": 16, "acc_descr_value": 17, "acc_descr_multiline_value": 18, "section": 19, "NEWLINE": 20, ";": 21, "EOF": 22, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "PIE", 7: "showData", 10: "txt", 11: "value", 12: "title", 13: "title_value", 14: "acc_title", 15: "acc_title_value", 16: "acc_descr", 17: "acc_descr_value", 18: "acc_descr_multiline_value", 19: "section", 20: "NEWLINE", 21: ";", 22: "EOF" }, + productions_: [0, [3, 2], [3, 2], [3, 3], [6, 0], [6, 2], [8, 2], [9, 0], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [4, 1], [4, 1], [4, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setShowData(true); + break; + case 6: + this.$ = $$[$0 - 1]; + break; + case 8: + yy.addSection($$[$0 - 1], yy.cleanupValue($$[$0])); + break; + case 9: + this.$ = $$[$0].trim(); + yy.setDiagramTitle(this.$); + break; + case 10: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 11: + case 12: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 13: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 20: $V1, 21: $V2, 22: $V3 }, { 1: [3] }, { 3: 7, 4: 2, 5: $V0, 20: $V1, 21: $V2, 22: $V3 }, o($V4, $V5, { 6: 8, 7: [1, 9] }), o($V6, [2, 14]), o($V6, [2, 15]), o($V6, [2, 16]), { 1: [2, 1] }, o($V7, $V8, { 8: 10, 9: 11, 1: [2, 2], 10: $V9, 12: $Va, 14: $Vb, 16: $Vc, 18: $Vd, 19: $Ve }), o($V4, $V5, { 6: 18 }), o($V4, [2, 5]), { 4: 19, 20: $V1, 21: $V2, 22: $V3 }, { 11: [1, 20] }, { 13: [1, 21] }, { 15: [1, 22] }, { 17: [1, 23] }, o($V7, [2, 12]), o($V7, [2, 13]), o($V7, $V8, { 8: 10, 9: 11, 1: [2, 3], 10: $V9, 12: $Va, 14: $Vb, 16: $Vc, 18: $Vd, 19: $Ve }), o($V4, [2, 6]), o($V7, [2, 8]), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11])], + defaultActions: { 7: [2, 1] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 20; + case 3: + break; + case 4: + break; + case 5: + this.begin("title"); + return 12; + case 6: + this.popState(); + return "title_value"; + case 7: + this.begin("acc_title"); + return 14; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 16; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + this.begin("string"); + break; + case 15: + this.popState(); + break; + case 16: + return "txt"; + case 17: + return 5; + case 18: + return 7; + case 19: + return "value"; + case 20: + return 22; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:[\s]+)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:pie\b)/i, /^(?:showData\b)/i, /^(?::[\s]*[\d]+(?:\.[\d]+)?)/i, /^(?:$)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [6], "inclusive": false }, "string": { "rules": [15, 16], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 7, 9, 11, 14, 17, 18, 19, 20], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const DEFAULT_PIE_CONFIG = defaultConfig$2.pie; +const DEFAULT_PIE_DB = { + sections: {}, + showData: false, + config: DEFAULT_PIE_CONFIG +}; +let sections = DEFAULT_PIE_DB.sections; +let showData = DEFAULT_PIE_DB.showData; +const config = structuredClone(DEFAULT_PIE_CONFIG); +const getConfig = () => structuredClone(config); +const clear = () => { + sections = structuredClone(DEFAULT_PIE_DB.sections); + showData = DEFAULT_PIE_DB.showData; + clear$1(); +}; +const addSection = (label, value) => { + label = sanitizeText$2(label, getConfig$1()); + if (sections[label] === void 0) { + sections[label] = value; + log$1.debug(`added new section: ${label}, with value: ${value}`); + } +}; +const getSections = () => sections; +const cleanupValue = (value) => { + if (value.substring(0, 1) === ":") { + value = value.substring(1).trim(); + } + return Number(value.trim()); +}; +const setShowData = (toggle) => { + showData = toggle; +}; +const getShowData = () => showData; +const db = { + getConfig, + clear, + setDiagramTitle, + getDiagramTitle, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addSection, + getSections, + cleanupValue, + setShowData, + getShowData +}; +const getStyles = (options) => ` + .pieCircle{ + stroke: ${options.pieStrokeColor}; + stroke-width : ${options.pieStrokeWidth}; + opacity : ${options.pieOpacity}; + } + .pieOuterCircle{ + stroke: ${options.pieOuterStrokeColor}; + stroke-width: ${options.pieOuterStrokeWidth}; + fill: none; + } + .pieTitleText { + text-anchor: middle; + font-size: ${options.pieTitleTextSize}; + fill: ${options.pieTitleTextColor}; + font-family: ${options.fontFamily}; + } + .slice { + font-family: ${options.fontFamily}; + fill: ${options.pieSectionTextColor}; + font-size:${options.pieSectionTextSize}; + // fill: white; + } + .legend text { + fill: ${options.pieLegendTextColor}; + font-family: ${options.fontFamily}; + font-size: ${options.pieLegendTextSize}; + } +`; +const styles = getStyles; +const createPieArcs = (sections2) => { + const pieData = Object.entries(sections2).map((element) => { + return { + label: element[0], + value: element[1] + }; + }).sort((a, b) => { + return b.value - a.value; + }); + const pie$1 = pie().value( + (d3Section) => d3Section.value + ); + return pie$1(pieData); +}; +const draw = (text, id, _version, diagObj) => { + log$1.debug("rendering pie chart\n" + text); + const db2 = diagObj.db; + const globalConfig = getConfig$1(); + const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie); + const MARGIN = 40; + const LEGEND_RECT_SIZE = 18; + const LEGEND_SPACING = 4; + const height = 450; + const pieWidth = height; + const svg = selectSvgElement(id); + const group = svg.append("g"); + const sections2 = db2.getSections(); + group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")"); + const { themeVariables } = globalConfig; + let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth); + outerStrokeWidth ?? (outerStrokeWidth = 2); + const textPosition = pieConfig.textPosition; + const radius = Math.min(pieWidth, height) / 2 - MARGIN; + const arcGenerator = arc().innerRadius(0).outerRadius(radius); + const labelArcGenerator = arc().innerRadius(radius * textPosition).outerRadius(radius * textPosition); + group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle"); + const arcs = createPieArcs(sections2); + const myGeneratedColors = [ + themeVariables.pie1, + themeVariables.pie2, + themeVariables.pie3, + themeVariables.pie4, + themeVariables.pie5, + themeVariables.pie6, + themeVariables.pie7, + themeVariables.pie8, + themeVariables.pie9, + themeVariables.pie10, + themeVariables.pie11, + themeVariables.pie12 + ]; + const color = ordinal(myGeneratedColors); + group.selectAll("mySlices").data(arcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => { + return color(datum.data.label); + }).attr("class", "pieCircle"); + let sum = 0; + Object.keys(sections2).forEach((key) => { + sum += sections2[key]; + }); + group.selectAll("mySlices").data(arcs).enter().append("text").text((datum) => { + return (datum.data.value / sum * 100).toFixed(0) + "%"; + }).attr("transform", (datum) => { + return "translate(" + labelArcGenerator.centroid(datum) + ")"; + }).style("text-anchor", "middle").attr("class", "slice"); + group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText"); + const legend = group.selectAll(".legend").data(color.domain()).enter().append("g").attr("class", "legend").attr("transform", (_datum, index) => { + const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING; + const offset = height2 * color.domain().length / 2; + const horizontal = 12 * LEGEND_RECT_SIZE; + const vertical = index * height2 - offset; + return "translate(" + horizontal + "," + vertical + ")"; + }); + legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", color).style("stroke", color); + legend.data(arcs).append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((datum) => { + const { label, value } = datum.data; + if (db2.getShowData()) { + return `${label} [${value}]`; + } + return label; + }); + const longestTextWidth = Math.max( + ...legend.selectAll("text").nodes().map((node) => (node == null ? void 0 : node.getBoundingClientRect().width) ?? 0) + ); + const totalWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth; + svg.attr("viewBox", `0 0 ${totalWidth} ${height}`); + configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth); +}; +const renderer = { draw }; +const diagram = { + parser: parser$1, + db, + renderer, + styles +}; + +export { diagram }; diff --git a/libs/marked/quadrantDiagram-c759a472-BdBXdWkW.js b/libs/marked/quadrantDiagram-c759a472-BdBXdWkW.js new file mode 100644 index 0000000..a1ef2d6 --- /dev/null +++ b/libs/marked/quadrantDiagram-c759a472-BdBXdWkW.js @@ -0,0 +1,1199 @@ +import { Z as getThemeVariables$2, c as getConfig, W as defaultConfig$2, l as log$1, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, a as getAccDescription, b as setAccDescription, E as clear$1, h as select, i as configureSvgSize, d as sanitizeText$2 } from './index-Bd_FDXSq.js'; +import { l as linear } from './linear-DNP-QGmo.js'; +import './init-zpY4DTin.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 7], $V5 = [1, 5, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V6 = [1, 5, 6, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V7 = [32, 33, 34], $V8 = [2, 7], $V9 = [1, 13], $Va = [1, 17], $Vb = [1, 18], $Vc = [1, 19], $Vd = [1, 20], $Ve = [1, 21], $Vf = [1, 22], $Vg = [1, 23], $Vh = [1, 24], $Vi = [1, 25], $Vj = [1, 26], $Vk = [1, 27], $Vl = [1, 30], $Vm = [1, 31], $Vn = [1, 32], $Vo = [1, 33], $Vp = [1, 34], $Vq = [1, 35], $Vr = [1, 36], $Vs = [1, 37], $Vt = [1, 38], $Vu = [1, 39], $Vv = [1, 40], $Vw = [1, 41], $Vx = [1, 42], $Vy = [1, 57], $Vz = [1, 58], $VA = [5, 22, 26, 32, 33, 34, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "SPACE": 5, "QUADRANT": 6, "document": 7, "line": 8, "statement": 9, "axisDetails": 10, "quadrantDetails": 11, "points": 12, "title": 13, "title_value": 14, "acc_title": 15, "acc_title_value": 16, "acc_descr": 17, "acc_descr_value": 18, "acc_descr_multiline_value": 19, "section": 20, "text": 21, "point_start": 22, "point_x": 23, "point_y": 24, "X-AXIS": 25, "AXIS-TEXT-DELIMITER": 26, "Y-AXIS": 27, "QUADRANT_1": 28, "QUADRANT_2": 29, "QUADRANT_3": 30, "QUADRANT_4": 31, "NEWLINE": 32, "SEMI": 33, "EOF": 34, "alphaNumToken": 35, "textNoTagsToken": 36, "STR": 37, "MD_STR": 38, "alphaNum": 39, "PUNCTUATION": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "COMMA": 44, "PLUS": 45, "EQUALS": 46, "MULT": 47, "DOT": 48, "BRKT": 49, "UNDERSCORE": 50, "MINUS": 51, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "SPACE", 6: "QUADRANT", 13: "title", 14: "title_value", 15: "acc_title", 16: "acc_title_value", 17: "acc_descr", 18: "acc_descr_value", 19: "acc_descr_multiline_value", 20: "section", 22: "point_start", 23: "point_x", 24: "point_y", 25: "X-AXIS", 26: "AXIS-TEXT-DELIMITER", 27: "Y-AXIS", 28: "QUADRANT_1", 29: "QUADRANT_2", 30: "QUADRANT_3", 31: "QUADRANT_4", 32: "NEWLINE", 33: "SEMI", 34: "EOF", 37: "STR", 38: "MD_STR", 40: "PUNCTUATION", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "COMMA", 45: "PLUS", 46: "EQUALS", 47: "MULT", 48: "DOT", 49: "BRKT", 50: "UNDERSCORE", 51: "MINUS" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [9, 0], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [12, 4], [10, 4], [10, 3], [10, 2], [10, 4], [10, 3], [10, 2], [11, 2], [11, 2], [11, 2], [11, 2], [4, 1], [4, 1], [4, 1], [21, 1], [21, 2], [21, 1], [21, 1], [39, 1], [39, 2], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [36, 1], [36, 1], [36, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 12: + this.$ = $$[$0].trim(); + yy.setDiagramTitle(this.$); + break; + case 13: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 14: + case 15: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 16: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 17: + yy.addPoint($$[$0 - 3], $$[$0 - 1], $$[$0]); + break; + case 18: + yy.setXAxisLeftText($$[$0 - 2]); + yy.setXAxisRightText($$[$0]); + break; + case 19: + $$[$0 - 1].text += " ⟶ "; + yy.setXAxisLeftText($$[$0 - 1]); + break; + case 20: + yy.setXAxisLeftText($$[$0]); + break; + case 21: + yy.setYAxisBottomText($$[$0 - 2]); + yy.setYAxisTopText($$[$0]); + break; + case 22: + $$[$0 - 1].text += " ⟶ "; + yy.setYAxisBottomText($$[$0 - 1]); + break; + case 23: + yy.setYAxisBottomText($$[$0]); + break; + case 24: + yy.setQuadrant1Text($$[$0]); + break; + case 25: + yy.setQuadrant2Text($$[$0]); + break; + case 26: + yy.setQuadrant3Text($$[$0]); + break; + case 27: + yy.setQuadrant4Text($$[$0]); + break; + case 31: + this.$ = { text: $$[$0], type: "text" }; + break; + case 32: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 33: + this.$ = { text: $$[$0], type: "text" }; + break; + case 34: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 35: + this.$ = $$[$0]; + break; + case 36: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 1: [3] }, { 3: 8, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 3: 9, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, o($V5, [2, 4], { 7: 10 }), o($V6, [2, 28]), o($V6, [2, 29]), o($V6, [2, 30]), { 1: [2, 1] }, { 1: [2, 2] }, o($V7, $V8, { 8: 11, 9: 12, 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 1: [2, 3], 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V5, [2, 5]), { 4: 43, 32: $V2, 33: $V3, 34: $V4 }, o($V7, $V8, { 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 9: 44, 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11]), { 14: [1, 45] }, { 16: [1, 46] }, { 18: [1, 47] }, o($V7, [2, 15]), o($V7, [2, 16]), { 21: 48, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 49, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 50, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 51, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 52, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 53, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 5: $Vy, 22: [1, 54], 35: 56, 36: 55, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }, o($VA, [2, 31]), o($VA, [2, 33]), o($VA, [2, 34]), o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), o($VA, [2, 40]), o($VA, [2, 41]), o($VA, [2, 42]), o($VA, [2, 43]), o($VA, [2, 44]), o($VA, [2, 45]), o($VA, [2, 46]), o($VA, [2, 47]), o($V5, [2, 6]), o($V7, [2, 8]), o($V7, [2, 12]), o($V7, [2, 13]), o($V7, [2, 14]), o($V7, [2, 20], { 36: 55, 35: 56, 5: $Vy, 26: [1, 59], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 23], { 36: 55, 35: 56, 5: $Vy, 26: [1, 60], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 24], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 25], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 26], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 27], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), { 23: [1, 61] }, o($VA, [2, 32]), o($VA, [2, 48]), o($VA, [2, 49]), o($VA, [2, 50]), o($V7, [2, 19], { 35: 29, 21: 62, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 22], { 35: 29, 21: 63, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), { 24: [1, 64] }, o($V7, [2, 18], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 21], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 17])], + defaultActions: { 8: [2, 1], 9: [2, 2] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 32; + case 3: + break; + case 4: + this.begin("title"); + return 13; + case 5: + this.popState(); + return "title_value"; + case 6: + this.begin("acc_title"); + return 15; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 17; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + return 25; + case 14: + return 27; + case 15: + return 26; + case 16: + return 28; + case 17: + return 29; + case 18: + return 30; + case 19: + return 31; + case 20: + this.begin("md_string"); + break; + case 21: + return "MD_STR"; + case 22: + this.popState(); + break; + case 23: + this.begin("string"); + break; + case 24: + this.popState(); + break; + case 25: + return "STR"; + case 26: + this.begin("point_start"); + return 22; + case 27: + this.begin("point_x"); + return 23; + case 28: + this.popState(); + break; + case 29: + this.popState(); + this.begin("point_y"); + break; + case 30: + this.popState(); + return 24; + case 31: + return 6; + case 32: + return 43; + case 33: + return "COLON"; + case 34: + return 45; + case 35: + return 44; + case 36: + return 46; + case 37: + return 46; + case 38: + return 47; + case 39: + return 49; + case 40: + return 50; + case 41: + return 48; + case 42: + return 41; + case 43: + return 51; + case 44: + return 42; + case 45: + return 5; + case 46: + return 33; + case 47: + return 40; + case 48: + return 34; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?: *x-axis *)/i, /^(?: *y-axis *)/i, /^(?: *--+> *)/i, /^(?: *quadrant-1 *)/i, /^(?: *quadrant-2 *)/i, /^(?: *quadrant-3 *)/i, /^(?: *quadrant-4 *)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\s*:\s*\[\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?:\s*\] *)/i, /^(?:\s*,\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?: *quadrantChart *)/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s)/i, /^(?:;)/i, /^(?:[!"#$%&'*+,-.`?\\_/])/i, /^(?:$)/i], + conditions: { "point_y": { "rules": [30], "inclusive": false }, "point_x": { "rules": [29], "inclusive": false }, "point_start": { "rules": [27, 28], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "title": { "rules": [5], "inclusive": false }, "md_string": { "rules": [21, 22], "inclusive": false }, "string": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 23, 26, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const defaultThemeVariables = getThemeVariables$2(); +class QuadrantBuilder { + constructor() { + this.config = this.getDefaultConfig(); + this.themeConfig = this.getDefaultThemeConfig(); + this.data = this.getDefaultData(); + } + getDefaultData() { + return { + titleText: "", + quadrant1Text: "", + quadrant2Text: "", + quadrant3Text: "", + quadrant4Text: "", + xAxisLeftText: "", + xAxisRightText: "", + yAxisBottomText: "", + yAxisTopText: "", + points: [] + }; + } + getDefaultConfig() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r; + return { + showXAxis: true, + showYAxis: true, + showTitle: true, + chartHeight: ((_a = defaultConfig$2.quadrantChart) == null ? void 0 : _a.chartWidth) || 500, + chartWidth: ((_b = defaultConfig$2.quadrantChart) == null ? void 0 : _b.chartHeight) || 500, + titlePadding: ((_c = defaultConfig$2.quadrantChart) == null ? void 0 : _c.titlePadding) || 10, + titleFontSize: ((_d = defaultConfig$2.quadrantChart) == null ? void 0 : _d.titleFontSize) || 20, + quadrantPadding: ((_e = defaultConfig$2.quadrantChart) == null ? void 0 : _e.quadrantPadding) || 5, + xAxisLabelPadding: ((_f = defaultConfig$2.quadrantChart) == null ? void 0 : _f.xAxisLabelPadding) || 5, + yAxisLabelPadding: ((_g = defaultConfig$2.quadrantChart) == null ? void 0 : _g.yAxisLabelPadding) || 5, + xAxisLabelFontSize: ((_h = defaultConfig$2.quadrantChart) == null ? void 0 : _h.xAxisLabelFontSize) || 16, + yAxisLabelFontSize: ((_i = defaultConfig$2.quadrantChart) == null ? void 0 : _i.yAxisLabelFontSize) || 16, + quadrantLabelFontSize: ((_j = defaultConfig$2.quadrantChart) == null ? void 0 : _j.quadrantLabelFontSize) || 16, + quadrantTextTopPadding: ((_k = defaultConfig$2.quadrantChart) == null ? void 0 : _k.quadrantTextTopPadding) || 5, + pointTextPadding: ((_l = defaultConfig$2.quadrantChart) == null ? void 0 : _l.pointTextPadding) || 5, + pointLabelFontSize: ((_m = defaultConfig$2.quadrantChart) == null ? void 0 : _m.pointLabelFontSize) || 12, + pointRadius: ((_n = defaultConfig$2.quadrantChart) == null ? void 0 : _n.pointRadius) || 5, + xAxisPosition: ((_o = defaultConfig$2.quadrantChart) == null ? void 0 : _o.xAxisPosition) || "top", + yAxisPosition: ((_p = defaultConfig$2.quadrantChart) == null ? void 0 : _p.yAxisPosition) || "left", + quadrantInternalBorderStrokeWidth: ((_q = defaultConfig$2.quadrantChart) == null ? void 0 : _q.quadrantInternalBorderStrokeWidth) || 1, + quadrantExternalBorderStrokeWidth: ((_r = defaultConfig$2.quadrantChart) == null ? void 0 : _r.quadrantExternalBorderStrokeWidth) || 2 + }; + } + getDefaultThemeConfig() { + return { + quadrant1Fill: defaultThemeVariables.quadrant1Fill, + quadrant2Fill: defaultThemeVariables.quadrant2Fill, + quadrant3Fill: defaultThemeVariables.quadrant3Fill, + quadrant4Fill: defaultThemeVariables.quadrant4Fill, + quadrant1TextFill: defaultThemeVariables.quadrant1TextFill, + quadrant2TextFill: defaultThemeVariables.quadrant2TextFill, + quadrant3TextFill: defaultThemeVariables.quadrant3TextFill, + quadrant4TextFill: defaultThemeVariables.quadrant4TextFill, + quadrantPointFill: defaultThemeVariables.quadrantPointFill, + quadrantPointTextFill: defaultThemeVariables.quadrantPointTextFill, + quadrantXAxisTextFill: defaultThemeVariables.quadrantXAxisTextFill, + quadrantYAxisTextFill: defaultThemeVariables.quadrantYAxisTextFill, + quadrantTitleFill: defaultThemeVariables.quadrantTitleFill, + quadrantInternalBorderStrokeFill: defaultThemeVariables.quadrantInternalBorderStrokeFill, + quadrantExternalBorderStrokeFill: defaultThemeVariables.quadrantExternalBorderStrokeFill + }; + } + clear() { + this.config = this.getDefaultConfig(); + this.themeConfig = this.getDefaultThemeConfig(); + this.data = this.getDefaultData(); + log$1.info("clear called"); + } + setData(data) { + this.data = { ...this.data, ...data }; + } + addPoints(points) { + this.data.points = [...points, ...this.data.points]; + } + setConfig(config2) { + log$1.trace("setConfig called with: ", config2); + this.config = { ...this.config, ...config2 }; + } + setThemeConfig(themeConfig) { + log$1.trace("setThemeConfig called with: ", themeConfig); + this.themeConfig = { ...this.themeConfig, ...themeConfig }; + } + calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle) { + const xAxisSpaceCalculation = this.config.xAxisLabelPadding * 2 + this.config.xAxisLabelFontSize; + const xAxisSpace = { + top: xAxisPosition === "top" && showXAxis ? xAxisSpaceCalculation : 0, + bottom: xAxisPosition === "bottom" && showXAxis ? xAxisSpaceCalculation : 0 + }; + const yAxisSpaceCalculation = this.config.yAxisLabelPadding * 2 + this.config.yAxisLabelFontSize; + const yAxisSpace = { + left: this.config.yAxisPosition === "left" && showYAxis ? yAxisSpaceCalculation : 0, + right: this.config.yAxisPosition === "right" && showYAxis ? yAxisSpaceCalculation : 0 + }; + const titleSpaceCalculation = this.config.titleFontSize + this.config.titlePadding * 2; + const titleSpace = { + top: showTitle ? titleSpaceCalculation : 0 + }; + const quadrantLeft = this.config.quadrantPadding + yAxisSpace.left; + const quadrantTop = this.config.quadrantPadding + xAxisSpace.top + titleSpace.top; + const quadrantWidth = this.config.chartWidth - this.config.quadrantPadding * 2 - yAxisSpace.left - yAxisSpace.right; + const quadrantHeight = this.config.chartHeight - this.config.quadrantPadding * 2 - xAxisSpace.top - xAxisSpace.bottom - titleSpace.top; + const quadrantHalfWidth = quadrantWidth / 2; + const quadrantHalfHeight = quadrantHeight / 2; + const quadrantSpace = { + quadrantLeft, + quadrantTop, + quadrantWidth, + quadrantHalfWidth, + quadrantHeight, + quadrantHalfHeight + }; + return { + xAxisSpace, + yAxisSpace, + titleSpace, + quadrantSpace + }; + } + getAxisLabels(xAxisPosition, showXAxis, showYAxis, spaceData) { + const { quadrantSpace, titleSpace } = spaceData; + const { + quadrantHalfHeight, + quadrantHeight, + quadrantLeft, + quadrantHalfWidth, + quadrantTop, + quadrantWidth + } = quadrantSpace; + const drawXAxisLabelsInMiddle = Boolean(this.data.xAxisRightText); + const drawYAxisLabelsInMiddle = Boolean(this.data.yAxisTopText); + const axisLabels = []; + if (this.data.xAxisLeftText && showXAxis) { + axisLabels.push({ + text: this.data.xAxisLeftText, + fill: this.themeConfig.quadrantXAxisTextFill, + x: quadrantLeft + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0), + y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding, + fontSize: this.config.xAxisLabelFontSize, + verticalPos: drawXAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: 0 + }); + } + if (this.data.xAxisRightText && showXAxis) { + axisLabels.push({ + text: this.data.xAxisRightText, + fill: this.themeConfig.quadrantXAxisTextFill, + x: quadrantLeft + quadrantHalfWidth + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0), + y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding, + fontSize: this.config.xAxisLabelFontSize, + verticalPos: drawXAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: 0 + }); + } + if (this.data.yAxisBottomText && showYAxis) { + axisLabels.push({ + text: this.data.yAxisBottomText, + fill: this.themeConfig.quadrantYAxisTextFill, + x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding, + y: quadrantTop + quadrantHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0), + fontSize: this.config.yAxisLabelFontSize, + verticalPos: drawYAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: -90 + }); + } + if (this.data.yAxisTopText && showYAxis) { + axisLabels.push({ + text: this.data.yAxisTopText, + fill: this.themeConfig.quadrantYAxisTextFill, + x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding, + y: quadrantTop + quadrantHalfHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0), + fontSize: this.config.yAxisLabelFontSize, + verticalPos: drawYAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: -90 + }); + } + return axisLabels; + } + getQuadrants(spaceData) { + const { quadrantSpace } = spaceData; + const { quadrantHalfHeight, quadrantLeft, quadrantHalfWidth, quadrantTop } = quadrantSpace; + const quadrants = [ + { + text: { + text: this.data.quadrant1Text, + fill: this.themeConfig.quadrant1TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft + quadrantHalfWidth, + y: quadrantTop, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant1Fill + }, + { + text: { + text: this.data.quadrant2Text, + fill: this.themeConfig.quadrant2TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft, + y: quadrantTop, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant2Fill + }, + { + text: { + text: this.data.quadrant3Text, + fill: this.themeConfig.quadrant3TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft, + y: quadrantTop + quadrantHalfHeight, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant3Fill + }, + { + text: { + text: this.data.quadrant4Text, + fill: this.themeConfig.quadrant4TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft + quadrantHalfWidth, + y: quadrantTop + quadrantHalfHeight, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant4Fill + } + ]; + for (const quadrant of quadrants) { + quadrant.text.x = quadrant.x + quadrant.width / 2; + if (this.data.points.length === 0) { + quadrant.text.y = quadrant.y + quadrant.height / 2; + quadrant.text.horizontalPos = "middle"; + } else { + quadrant.text.y = quadrant.y + this.config.quadrantTextTopPadding; + quadrant.text.horizontalPos = "top"; + } + } + return quadrants; + } + getQuadrantPoints(spaceData) { + const { quadrantSpace } = spaceData; + const { quadrantHeight, quadrantLeft, quadrantTop, quadrantWidth } = quadrantSpace; + const xAxis = linear().domain([0, 1]).range([quadrantLeft, quadrantWidth + quadrantLeft]); + const yAxis = linear().domain([0, 1]).range([quadrantHeight + quadrantTop, quadrantTop]); + const points = this.data.points.map((point) => { + const props = { + x: xAxis(point.x), + y: yAxis(point.y), + fill: this.themeConfig.quadrantPointFill, + radius: this.config.pointRadius, + text: { + text: point.text, + fill: this.themeConfig.quadrantPointTextFill, + x: xAxis(point.x), + y: yAxis(point.y) + this.config.pointTextPadding, + verticalPos: "center", + horizontalPos: "top", + fontSize: this.config.pointLabelFontSize, + rotation: 0 + } + }; + return props; + }); + return points; + } + getBorders(spaceData) { + const halfExternalBorderWidth = this.config.quadrantExternalBorderStrokeWidth / 2; + const { quadrantSpace } = spaceData; + const { + quadrantHalfHeight, + quadrantHeight, + quadrantLeft, + quadrantHalfWidth, + quadrantTop, + quadrantWidth + } = quadrantSpace; + const borderLines = [ + // top border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft - halfExternalBorderWidth, + y1: quadrantTop, + x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth, + y2: quadrantTop + }, + // right border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft + quadrantWidth, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft + quadrantWidth, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // bottom border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft - halfExternalBorderWidth, + y1: quadrantTop + quadrantHeight, + x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth, + y2: quadrantTop + quadrantHeight + }, + // left border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // vertical inner border + { + strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill, + strokeWidth: this.config.quadrantInternalBorderStrokeWidth, + x1: quadrantLeft + quadrantHalfWidth, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft + quadrantHalfWidth, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // horizontal inner border + { + strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill, + strokeWidth: this.config.quadrantInternalBorderStrokeWidth, + x1: quadrantLeft + halfExternalBorderWidth, + y1: quadrantTop + quadrantHalfHeight, + x2: quadrantLeft + quadrantWidth - halfExternalBorderWidth, + y2: quadrantTop + quadrantHalfHeight + } + ]; + return borderLines; + } + getTitle(showTitle) { + if (showTitle) { + return { + text: this.data.titleText, + fill: this.themeConfig.quadrantTitleFill, + fontSize: this.config.titleFontSize, + horizontalPos: "top", + verticalPos: "center", + rotation: 0, + y: this.config.titlePadding, + x: this.config.chartWidth / 2 + }; + } + return; + } + build() { + const showXAxis = this.config.showXAxis && !!(this.data.xAxisLeftText || this.data.xAxisRightText); + const showYAxis = this.config.showYAxis && !!(this.data.yAxisTopText || this.data.yAxisBottomText); + const showTitle = this.config.showTitle && !!this.data.titleText; + const xAxisPosition = this.data.points.length > 0 ? "bottom" : this.config.xAxisPosition; + const calculatedSpace = this.calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle); + return { + points: this.getQuadrantPoints(calculatedSpace), + quadrants: this.getQuadrants(calculatedSpace), + axisLabels: this.getAxisLabels(xAxisPosition, showXAxis, showYAxis, calculatedSpace), + borderLines: this.getBorders(calculatedSpace), + title: this.getTitle(showTitle) + }; + } +} +const config = getConfig(); +function textSanitizer(text) { + return sanitizeText$2(text.trim(), config); +} +const quadrantBuilder = new QuadrantBuilder(); +function setQuadrant1Text(textObj) { + quadrantBuilder.setData({ quadrant1Text: textSanitizer(textObj.text) }); +} +function setQuadrant2Text(textObj) { + quadrantBuilder.setData({ quadrant2Text: textSanitizer(textObj.text) }); +} +function setQuadrant3Text(textObj) { + quadrantBuilder.setData({ quadrant3Text: textSanitizer(textObj.text) }); +} +function setQuadrant4Text(textObj) { + quadrantBuilder.setData({ quadrant4Text: textSanitizer(textObj.text) }); +} +function setXAxisLeftText(textObj) { + quadrantBuilder.setData({ xAxisLeftText: textSanitizer(textObj.text) }); +} +function setXAxisRightText(textObj) { + quadrantBuilder.setData({ xAxisRightText: textSanitizer(textObj.text) }); +} +function setYAxisTopText(textObj) { + quadrantBuilder.setData({ yAxisTopText: textSanitizer(textObj.text) }); +} +function setYAxisBottomText(textObj) { + quadrantBuilder.setData({ yAxisBottomText: textSanitizer(textObj.text) }); +} +function addPoint(textObj, x, y) { + quadrantBuilder.addPoints([{ x, y, text: textSanitizer(textObj.text) }]); +} +function setWidth(width) { + quadrantBuilder.setConfig({ chartWidth: width }); +} +function setHeight(height) { + quadrantBuilder.setConfig({ chartHeight: height }); +} +function getQuadrantData() { + const config2 = getConfig(); + const { themeVariables, quadrantChart: quadrantChartConfig } = config2; + if (quadrantChartConfig) { + quadrantBuilder.setConfig(quadrantChartConfig); + } + quadrantBuilder.setThemeConfig({ + quadrant1Fill: themeVariables.quadrant1Fill, + quadrant2Fill: themeVariables.quadrant2Fill, + quadrant3Fill: themeVariables.quadrant3Fill, + quadrant4Fill: themeVariables.quadrant4Fill, + quadrant1TextFill: themeVariables.quadrant1TextFill, + quadrant2TextFill: themeVariables.quadrant2TextFill, + quadrant3TextFill: themeVariables.quadrant3TextFill, + quadrant4TextFill: themeVariables.quadrant4TextFill, + quadrantPointFill: themeVariables.quadrantPointFill, + quadrantPointTextFill: themeVariables.quadrantPointTextFill, + quadrantXAxisTextFill: themeVariables.quadrantXAxisTextFill, + quadrantYAxisTextFill: themeVariables.quadrantYAxisTextFill, + quadrantExternalBorderStrokeFill: themeVariables.quadrantExternalBorderStrokeFill, + quadrantInternalBorderStrokeFill: themeVariables.quadrantInternalBorderStrokeFill, + quadrantTitleFill: themeVariables.quadrantTitleFill + }); + quadrantBuilder.setData({ titleText: getDiagramTitle() }); + return quadrantBuilder.build(); +} +const clear = function() { + quadrantBuilder.clear(); + clear$1(); +}; +const db = { + setWidth, + setHeight, + setQuadrant1Text, + setQuadrant2Text, + setQuadrant3Text, + setQuadrant4Text, + setXAxisLeftText, + setXAxisRightText, + setYAxisTopText, + setYAxisBottomText, + addPoint, + getQuadrantData, + clear, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + getAccDescription, + setAccDescription +}; +const draw = (txt, id, _version, diagObj) => { + var _a, _b, _c; + function getDominantBaseLine(horizontalPos) { + return horizontalPos === "top" ? "hanging" : "middle"; + } + function getTextAnchor(verticalPos) { + return verticalPos === "left" ? "start" : "middle"; + } + function getTransformation(data) { + return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`; + } + const conf = getConfig(); + log$1.debug("Rendering quadrant chart\n" + txt); + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const group = svg.append("g").attr("class", "main"); + const width = ((_a = conf.quadrantChart) == null ? void 0 : _a.chartWidth) || 500; + const height = ((_b = conf.quadrantChart) == null ? void 0 : _b.chartHeight) || 500; + configureSvgSize(svg, height, width, ((_c = conf.quadrantChart) == null ? void 0 : _c.useMaxWidth) || true); + svg.attr("viewBox", "0 0 " + width + " " + height); + diagObj.db.setHeight(height); + diagObj.db.setWidth(width); + const quadrantData = diagObj.db.getQuadrantData(); + const quadrantsGroup = group.append("g").attr("class", "quadrants"); + const borderGroup = group.append("g").attr("class", "border"); + const dataPointGroup = group.append("g").attr("class", "data-points"); + const labelGroup = group.append("g").attr("class", "labels"); + const titleGroup = group.append("g").attr("class", "title"); + if (quadrantData.title) { + titleGroup.append("text").attr("x", 0).attr("y", 0).attr("fill", quadrantData.title.fill).attr("font-size", quadrantData.title.fontSize).attr("dominant-baseline", getDominantBaseLine(quadrantData.title.horizontalPos)).attr("text-anchor", getTextAnchor(quadrantData.title.verticalPos)).attr("transform", getTransformation(quadrantData.title)).text(quadrantData.title.text); + } + if (quadrantData.borderLines) { + borderGroup.selectAll("line").data(quadrantData.borderLines).enter().append("line").attr("x1", (data) => data.x1).attr("y1", (data) => data.y1).attr("x2", (data) => data.x2).attr("y2", (data) => data.y2).style("stroke", (data) => data.strokeFill).style("stroke-width", (data) => data.strokeWidth); + } + const quadrants = quadrantsGroup.selectAll("g.quadrant").data(quadrantData.quadrants).enter().append("g").attr("class", "quadrant"); + quadrants.append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill); + quadrants.append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr( + "dominant-baseline", + (data) => getDominantBaseLine(data.text.horizontalPos) + ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)).text((data) => data.text.text); + const labels = labelGroup.selectAll("g.label").data(quadrantData.axisLabels).enter().append("g").attr("class", "label"); + labels.append("text").attr("x", 0).attr("y", 0).text((data) => data.text).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.horizontalPos)).attr("text-anchor", (data) => getTextAnchor(data.verticalPos)).attr("transform", (data) => getTransformation(data)); + const dataPoints = dataPointGroup.selectAll("g.data-point").data(quadrantData.points).enter().append("g").attr("class", "data-point"); + dataPoints.append("circle").attr("cx", (data) => data.x).attr("cy", (data) => data.y).attr("r", (data) => data.radius).attr("fill", (data) => data.fill); + dataPoints.append("text").attr("x", 0).attr("y", 0).text((data) => data.text.text).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr( + "dominant-baseline", + (data) => getDominantBaseLine(data.text.horizontalPos) + ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)); +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles: () => "" +}; + +export { diagram }; diff --git a/libs/marked/quadrantDiagram-c759a472-BtTVtR58.js b/libs/marked/quadrantDiagram-c759a472-BtTVtR58.js new file mode 100644 index 0000000..715e5b6 --- /dev/null +++ b/libs/marked/quadrantDiagram-c759a472-BtTVtR58.js @@ -0,0 +1,1199 @@ +import { Z as getThemeVariables$2, c as getConfig, W as defaultConfig$2, l as log$1, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, a as getAccDescription, b as setAccDescription, E as clear$1, h as select, i as configureSvgSize, d as sanitizeText$2 } from './index-CN3YjQ0n.js'; +import { l as linear } from './linear--P89MwVW.js'; +import './init-zpY4DTin.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [1, 7], $V5 = [1, 5, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V6 = [1, 5, 6, 13, 15, 17, 19, 20, 25, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $V7 = [32, 33, 34], $V8 = [2, 7], $V9 = [1, 13], $Va = [1, 17], $Vb = [1, 18], $Vc = [1, 19], $Vd = [1, 20], $Ve = [1, 21], $Vf = [1, 22], $Vg = [1, 23], $Vh = [1, 24], $Vi = [1, 25], $Vj = [1, 26], $Vk = [1, 27], $Vl = [1, 30], $Vm = [1, 31], $Vn = [1, 32], $Vo = [1, 33], $Vp = [1, 34], $Vq = [1, 35], $Vr = [1, 36], $Vs = [1, 37], $Vt = [1, 38], $Vu = [1, 39], $Vv = [1, 40], $Vw = [1, 41], $Vx = [1, 42], $Vy = [1, 57], $Vz = [1, 58], $VA = [5, 22, 26, 32, 33, 34, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "SPACE": 5, "QUADRANT": 6, "document": 7, "line": 8, "statement": 9, "axisDetails": 10, "quadrantDetails": 11, "points": 12, "title": 13, "title_value": 14, "acc_title": 15, "acc_title_value": 16, "acc_descr": 17, "acc_descr_value": 18, "acc_descr_multiline_value": 19, "section": 20, "text": 21, "point_start": 22, "point_x": 23, "point_y": 24, "X-AXIS": 25, "AXIS-TEXT-DELIMITER": 26, "Y-AXIS": 27, "QUADRANT_1": 28, "QUADRANT_2": 29, "QUADRANT_3": 30, "QUADRANT_4": 31, "NEWLINE": 32, "SEMI": 33, "EOF": 34, "alphaNumToken": 35, "textNoTagsToken": 36, "STR": 37, "MD_STR": 38, "alphaNum": 39, "PUNCTUATION": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "COMMA": 44, "PLUS": 45, "EQUALS": 46, "MULT": 47, "DOT": 48, "BRKT": 49, "UNDERSCORE": 50, "MINUS": 51, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "SPACE", 6: "QUADRANT", 13: "title", 14: "title_value", 15: "acc_title", 16: "acc_title_value", 17: "acc_descr", 18: "acc_descr_value", 19: "acc_descr_multiline_value", 20: "section", 22: "point_start", 23: "point_x", 24: "point_y", 25: "X-AXIS", 26: "AXIS-TEXT-DELIMITER", 27: "Y-AXIS", 28: "QUADRANT_1", 29: "QUADRANT_2", 30: "QUADRANT_3", 31: "QUADRANT_4", 32: "NEWLINE", 33: "SEMI", 34: "EOF", 37: "STR", 38: "MD_STR", 40: "PUNCTUATION", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "COMMA", 45: "PLUS", 46: "EQUALS", 47: "MULT", 48: "DOT", 49: "BRKT", 50: "UNDERSCORE", 51: "MINUS" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [9, 0], [9, 2], [9, 1], [9, 1], [9, 1], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [12, 4], [10, 4], [10, 3], [10, 2], [10, 4], [10, 3], [10, 2], [11, 2], [11, 2], [11, 2], [11, 2], [4, 1], [4, 1], [4, 1], [21, 1], [21, 2], [21, 1], [21, 1], [39, 1], [39, 2], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [35, 1], [36, 1], [36, 1], [36, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 12: + this.$ = $$[$0].trim(); + yy.setDiagramTitle(this.$); + break; + case 13: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 14: + case 15: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 16: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 17: + yy.addPoint($$[$0 - 3], $$[$0 - 1], $$[$0]); + break; + case 18: + yy.setXAxisLeftText($$[$0 - 2]); + yy.setXAxisRightText($$[$0]); + break; + case 19: + $$[$0 - 1].text += " ⟶ "; + yy.setXAxisLeftText($$[$0 - 1]); + break; + case 20: + yy.setXAxisLeftText($$[$0]); + break; + case 21: + yy.setYAxisBottomText($$[$0 - 2]); + yy.setYAxisTopText($$[$0]); + break; + case 22: + $$[$0 - 1].text += " ⟶ "; + yy.setYAxisBottomText($$[$0 - 1]); + break; + case 23: + yy.setYAxisBottomText($$[$0]); + break; + case 24: + yy.setQuadrant1Text($$[$0]); + break; + case 25: + yy.setQuadrant2Text($$[$0]); + break; + case 26: + yy.setQuadrant3Text($$[$0]); + break; + case 27: + yy.setQuadrant4Text($$[$0]); + break; + case 31: + this.$ = { text: $$[$0], type: "text" }; + break; + case 32: + this.$ = { text: $$[$0 - 1].text + "" + $$[$0], type: $$[$0 - 1].type }; + break; + case 33: + this.$ = { text: $$[$0], type: "text" }; + break; + case 34: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 35: + this.$ = $$[$0]; + break; + case 36: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 1: [3] }, { 3: 8, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, { 3: 9, 4: 2, 5: $V0, 6: $V1, 32: $V2, 33: $V3, 34: $V4 }, o($V5, [2, 4], { 7: 10 }), o($V6, [2, 28]), o($V6, [2, 29]), o($V6, [2, 30]), { 1: [2, 1] }, { 1: [2, 2] }, o($V7, $V8, { 8: 11, 9: 12, 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 1: [2, 3], 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V5, [2, 5]), { 4: 43, 32: $V2, 33: $V3, 34: $V4 }, o($V7, $V8, { 10: 14, 11: 15, 12: 16, 21: 28, 35: 29, 9: 44, 5: $V9, 13: $Va, 15: $Vb, 17: $Vc, 19: $Vd, 20: $Ve, 25: $Vf, 27: $Vg, 28: $Vh, 29: $Vi, 30: $Vj, 31: $Vk, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 9]), o($V7, [2, 10]), o($V7, [2, 11]), { 14: [1, 45] }, { 16: [1, 46] }, { 18: [1, 47] }, o($V7, [2, 15]), o($V7, [2, 16]), { 21: 48, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 49, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 50, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 51, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 52, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 21: 53, 35: 29, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }, { 5: $Vy, 22: [1, 54], 35: 56, 36: 55, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }, o($VA, [2, 31]), o($VA, [2, 33]), o($VA, [2, 34]), o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), o($VA, [2, 40]), o($VA, [2, 41]), o($VA, [2, 42]), o($VA, [2, 43]), o($VA, [2, 44]), o($VA, [2, 45]), o($VA, [2, 46]), o($VA, [2, 47]), o($V5, [2, 6]), o($V7, [2, 8]), o($V7, [2, 12]), o($V7, [2, 13]), o($V7, [2, 14]), o($V7, [2, 20], { 36: 55, 35: 56, 5: $Vy, 26: [1, 59], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 23], { 36: 55, 35: 56, 5: $Vy, 26: [1, 60], 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 24], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 25], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 26], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 27], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), { 23: [1, 61] }, o($VA, [2, 32]), o($VA, [2, 48]), o($VA, [2, 49]), o($VA, [2, 50]), o($V7, [2, 19], { 35: 29, 21: 62, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), o($V7, [2, 22], { 35: 29, 21: 63, 37: $Vl, 38: $Vm, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx }), { 24: [1, 64] }, o($V7, [2, 18], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 21], { 36: 55, 35: 56, 5: $Vy, 40: $Vn, 41: $Vo, 42: $Vp, 43: $Vq, 44: $Vr, 45: $Vs, 46: $Vt, 47: $Vu, 48: $Vv, 49: $Vw, 50: $Vx, 51: $Vz }), o($V7, [2, 17])], + defaultActions: { 8: [2, 1], 9: [2, 2] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 32; + case 3: + break; + case 4: + this.begin("title"); + return 13; + case 5: + this.popState(); + return "title_value"; + case 6: + this.begin("acc_title"); + return 15; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 17; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + return 25; + case 14: + return 27; + case 15: + return 26; + case 16: + return 28; + case 17: + return 29; + case 18: + return 30; + case 19: + return 31; + case 20: + this.begin("md_string"); + break; + case 21: + return "MD_STR"; + case 22: + this.popState(); + break; + case 23: + this.begin("string"); + break; + case 24: + this.popState(); + break; + case 25: + return "STR"; + case 26: + this.begin("point_start"); + return 22; + case 27: + this.begin("point_x"); + return 23; + case 28: + this.popState(); + break; + case 29: + this.popState(); + this.begin("point_y"); + break; + case 30: + this.popState(); + return 24; + case 31: + return 6; + case 32: + return 43; + case 33: + return "COLON"; + case 34: + return 45; + case 35: + return 44; + case 36: + return 46; + case 37: + return 46; + case 38: + return 47; + case 39: + return 49; + case 40: + return 50; + case 41: + return 48; + case 42: + return 41; + case 43: + return 51; + case 44: + return 42; + case 45: + return 5; + case 46: + return 33; + case 47: + return 40; + case 48: + return 34; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?: *x-axis *)/i, /^(?: *y-axis *)/i, /^(?: *--+> *)/i, /^(?: *quadrant-1 *)/i, /^(?: *quadrant-2 *)/i, /^(?: *quadrant-3 *)/i, /^(?: *quadrant-4 *)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\s*:\s*\[\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?:\s*\] *)/i, /^(?:\s*,\s*)/i, /^(?:(1)|(0(.\d+)?))/i, /^(?: *quadrantChart *)/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s)/i, /^(?:;)/i, /^(?:[!"#$%&'*+,-.`?\\_/])/i, /^(?:$)/i], + conditions: { "point_y": { "rules": [30], "inclusive": false }, "point_x": { "rules": [29], "inclusive": false }, "point_start": { "rules": [27, 28], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12], "inclusive": false }, "acc_descr": { "rules": [9], "inclusive": false }, "acc_title": { "rules": [7], "inclusive": false }, "title": { "rules": [5], "inclusive": false }, "md_string": { "rules": [21, 22], "inclusive": false }, "string": { "rules": [24, 25], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 6, 8, 10, 13, 14, 15, 16, 17, 18, 19, 20, 23, 26, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const defaultThemeVariables = getThemeVariables$2(); +class QuadrantBuilder { + constructor() { + this.config = this.getDefaultConfig(); + this.themeConfig = this.getDefaultThemeConfig(); + this.data = this.getDefaultData(); + } + getDefaultData() { + return { + titleText: "", + quadrant1Text: "", + quadrant2Text: "", + quadrant3Text: "", + quadrant4Text: "", + xAxisLeftText: "", + xAxisRightText: "", + yAxisBottomText: "", + yAxisTopText: "", + points: [] + }; + } + getDefaultConfig() { + var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r; + return { + showXAxis: true, + showYAxis: true, + showTitle: true, + chartHeight: ((_a = defaultConfig$2.quadrantChart) == null ? void 0 : _a.chartWidth) || 500, + chartWidth: ((_b = defaultConfig$2.quadrantChart) == null ? void 0 : _b.chartHeight) || 500, + titlePadding: ((_c = defaultConfig$2.quadrantChart) == null ? void 0 : _c.titlePadding) || 10, + titleFontSize: ((_d = defaultConfig$2.quadrantChart) == null ? void 0 : _d.titleFontSize) || 20, + quadrantPadding: ((_e = defaultConfig$2.quadrantChart) == null ? void 0 : _e.quadrantPadding) || 5, + xAxisLabelPadding: ((_f = defaultConfig$2.quadrantChart) == null ? void 0 : _f.xAxisLabelPadding) || 5, + yAxisLabelPadding: ((_g = defaultConfig$2.quadrantChart) == null ? void 0 : _g.yAxisLabelPadding) || 5, + xAxisLabelFontSize: ((_h = defaultConfig$2.quadrantChart) == null ? void 0 : _h.xAxisLabelFontSize) || 16, + yAxisLabelFontSize: ((_i = defaultConfig$2.quadrantChart) == null ? void 0 : _i.yAxisLabelFontSize) || 16, + quadrantLabelFontSize: ((_j = defaultConfig$2.quadrantChart) == null ? void 0 : _j.quadrantLabelFontSize) || 16, + quadrantTextTopPadding: ((_k = defaultConfig$2.quadrantChart) == null ? void 0 : _k.quadrantTextTopPadding) || 5, + pointTextPadding: ((_l = defaultConfig$2.quadrantChart) == null ? void 0 : _l.pointTextPadding) || 5, + pointLabelFontSize: ((_m = defaultConfig$2.quadrantChart) == null ? void 0 : _m.pointLabelFontSize) || 12, + pointRadius: ((_n = defaultConfig$2.quadrantChart) == null ? void 0 : _n.pointRadius) || 5, + xAxisPosition: ((_o = defaultConfig$2.quadrantChart) == null ? void 0 : _o.xAxisPosition) || "top", + yAxisPosition: ((_p = defaultConfig$2.quadrantChart) == null ? void 0 : _p.yAxisPosition) || "left", + quadrantInternalBorderStrokeWidth: ((_q = defaultConfig$2.quadrantChart) == null ? void 0 : _q.quadrantInternalBorderStrokeWidth) || 1, + quadrantExternalBorderStrokeWidth: ((_r = defaultConfig$2.quadrantChart) == null ? void 0 : _r.quadrantExternalBorderStrokeWidth) || 2 + }; + } + getDefaultThemeConfig() { + return { + quadrant1Fill: defaultThemeVariables.quadrant1Fill, + quadrant2Fill: defaultThemeVariables.quadrant2Fill, + quadrant3Fill: defaultThemeVariables.quadrant3Fill, + quadrant4Fill: defaultThemeVariables.quadrant4Fill, + quadrant1TextFill: defaultThemeVariables.quadrant1TextFill, + quadrant2TextFill: defaultThemeVariables.quadrant2TextFill, + quadrant3TextFill: defaultThemeVariables.quadrant3TextFill, + quadrant4TextFill: defaultThemeVariables.quadrant4TextFill, + quadrantPointFill: defaultThemeVariables.quadrantPointFill, + quadrantPointTextFill: defaultThemeVariables.quadrantPointTextFill, + quadrantXAxisTextFill: defaultThemeVariables.quadrantXAxisTextFill, + quadrantYAxisTextFill: defaultThemeVariables.quadrantYAxisTextFill, + quadrantTitleFill: defaultThemeVariables.quadrantTitleFill, + quadrantInternalBorderStrokeFill: defaultThemeVariables.quadrantInternalBorderStrokeFill, + quadrantExternalBorderStrokeFill: defaultThemeVariables.quadrantExternalBorderStrokeFill + }; + } + clear() { + this.config = this.getDefaultConfig(); + this.themeConfig = this.getDefaultThemeConfig(); + this.data = this.getDefaultData(); + log$1.info("clear called"); + } + setData(data) { + this.data = { ...this.data, ...data }; + } + addPoints(points) { + this.data.points = [...points, ...this.data.points]; + } + setConfig(config2) { + log$1.trace("setConfig called with: ", config2); + this.config = { ...this.config, ...config2 }; + } + setThemeConfig(themeConfig) { + log$1.trace("setThemeConfig called with: ", themeConfig); + this.themeConfig = { ...this.themeConfig, ...themeConfig }; + } + calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle) { + const xAxisSpaceCalculation = this.config.xAxisLabelPadding * 2 + this.config.xAxisLabelFontSize; + const xAxisSpace = { + top: xAxisPosition === "top" && showXAxis ? xAxisSpaceCalculation : 0, + bottom: xAxisPosition === "bottom" && showXAxis ? xAxisSpaceCalculation : 0 + }; + const yAxisSpaceCalculation = this.config.yAxisLabelPadding * 2 + this.config.yAxisLabelFontSize; + const yAxisSpace = { + left: this.config.yAxisPosition === "left" && showYAxis ? yAxisSpaceCalculation : 0, + right: this.config.yAxisPosition === "right" && showYAxis ? yAxisSpaceCalculation : 0 + }; + const titleSpaceCalculation = this.config.titleFontSize + this.config.titlePadding * 2; + const titleSpace = { + top: showTitle ? titleSpaceCalculation : 0 + }; + const quadrantLeft = this.config.quadrantPadding + yAxisSpace.left; + const quadrantTop = this.config.quadrantPadding + xAxisSpace.top + titleSpace.top; + const quadrantWidth = this.config.chartWidth - this.config.quadrantPadding * 2 - yAxisSpace.left - yAxisSpace.right; + const quadrantHeight = this.config.chartHeight - this.config.quadrantPadding * 2 - xAxisSpace.top - xAxisSpace.bottom - titleSpace.top; + const quadrantHalfWidth = quadrantWidth / 2; + const quadrantHalfHeight = quadrantHeight / 2; + const quadrantSpace = { + quadrantLeft, + quadrantTop, + quadrantWidth, + quadrantHalfWidth, + quadrantHeight, + quadrantHalfHeight + }; + return { + xAxisSpace, + yAxisSpace, + titleSpace, + quadrantSpace + }; + } + getAxisLabels(xAxisPosition, showXAxis, showYAxis, spaceData) { + const { quadrantSpace, titleSpace } = spaceData; + const { + quadrantHalfHeight, + quadrantHeight, + quadrantLeft, + quadrantHalfWidth, + quadrantTop, + quadrantWidth + } = quadrantSpace; + const drawXAxisLabelsInMiddle = Boolean(this.data.xAxisRightText); + const drawYAxisLabelsInMiddle = Boolean(this.data.yAxisTopText); + const axisLabels = []; + if (this.data.xAxisLeftText && showXAxis) { + axisLabels.push({ + text: this.data.xAxisLeftText, + fill: this.themeConfig.quadrantXAxisTextFill, + x: quadrantLeft + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0), + y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding, + fontSize: this.config.xAxisLabelFontSize, + verticalPos: drawXAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: 0 + }); + } + if (this.data.xAxisRightText && showXAxis) { + axisLabels.push({ + text: this.data.xAxisRightText, + fill: this.themeConfig.quadrantXAxisTextFill, + x: quadrantLeft + quadrantHalfWidth + (drawXAxisLabelsInMiddle ? quadrantHalfWidth / 2 : 0), + y: xAxisPosition === "top" ? this.config.xAxisLabelPadding + titleSpace.top : this.config.xAxisLabelPadding + quadrantTop + quadrantHeight + this.config.quadrantPadding, + fontSize: this.config.xAxisLabelFontSize, + verticalPos: drawXAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: 0 + }); + } + if (this.data.yAxisBottomText && showYAxis) { + axisLabels.push({ + text: this.data.yAxisBottomText, + fill: this.themeConfig.quadrantYAxisTextFill, + x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding, + y: quadrantTop + quadrantHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0), + fontSize: this.config.yAxisLabelFontSize, + verticalPos: drawYAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: -90 + }); + } + if (this.data.yAxisTopText && showYAxis) { + axisLabels.push({ + text: this.data.yAxisTopText, + fill: this.themeConfig.quadrantYAxisTextFill, + x: this.config.yAxisPosition === "left" ? this.config.yAxisLabelPadding : this.config.yAxisLabelPadding + quadrantLeft + quadrantWidth + this.config.quadrantPadding, + y: quadrantTop + quadrantHalfHeight - (drawYAxisLabelsInMiddle ? quadrantHalfHeight / 2 : 0), + fontSize: this.config.yAxisLabelFontSize, + verticalPos: drawYAxisLabelsInMiddle ? "center" : "left", + horizontalPos: "top", + rotation: -90 + }); + } + return axisLabels; + } + getQuadrants(spaceData) { + const { quadrantSpace } = spaceData; + const { quadrantHalfHeight, quadrantLeft, quadrantHalfWidth, quadrantTop } = quadrantSpace; + const quadrants = [ + { + text: { + text: this.data.quadrant1Text, + fill: this.themeConfig.quadrant1TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft + quadrantHalfWidth, + y: quadrantTop, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant1Fill + }, + { + text: { + text: this.data.quadrant2Text, + fill: this.themeConfig.quadrant2TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft, + y: quadrantTop, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant2Fill + }, + { + text: { + text: this.data.quadrant3Text, + fill: this.themeConfig.quadrant3TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft, + y: quadrantTop + quadrantHalfHeight, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant3Fill + }, + { + text: { + text: this.data.quadrant4Text, + fill: this.themeConfig.quadrant4TextFill, + x: 0, + y: 0, + fontSize: this.config.quadrantLabelFontSize, + verticalPos: "center", + horizontalPos: "middle", + rotation: 0 + }, + x: quadrantLeft + quadrantHalfWidth, + y: quadrantTop + quadrantHalfHeight, + width: quadrantHalfWidth, + height: quadrantHalfHeight, + fill: this.themeConfig.quadrant4Fill + } + ]; + for (const quadrant of quadrants) { + quadrant.text.x = quadrant.x + quadrant.width / 2; + if (this.data.points.length === 0) { + quadrant.text.y = quadrant.y + quadrant.height / 2; + quadrant.text.horizontalPos = "middle"; + } else { + quadrant.text.y = quadrant.y + this.config.quadrantTextTopPadding; + quadrant.text.horizontalPos = "top"; + } + } + return quadrants; + } + getQuadrantPoints(spaceData) { + const { quadrantSpace } = spaceData; + const { quadrantHeight, quadrantLeft, quadrantTop, quadrantWidth } = quadrantSpace; + const xAxis = linear().domain([0, 1]).range([quadrantLeft, quadrantWidth + quadrantLeft]); + const yAxis = linear().domain([0, 1]).range([quadrantHeight + quadrantTop, quadrantTop]); + const points = this.data.points.map((point) => { + const props = { + x: xAxis(point.x), + y: yAxis(point.y), + fill: this.themeConfig.quadrantPointFill, + radius: this.config.pointRadius, + text: { + text: point.text, + fill: this.themeConfig.quadrantPointTextFill, + x: xAxis(point.x), + y: yAxis(point.y) + this.config.pointTextPadding, + verticalPos: "center", + horizontalPos: "top", + fontSize: this.config.pointLabelFontSize, + rotation: 0 + } + }; + return props; + }); + return points; + } + getBorders(spaceData) { + const halfExternalBorderWidth = this.config.quadrantExternalBorderStrokeWidth / 2; + const { quadrantSpace } = spaceData; + const { + quadrantHalfHeight, + quadrantHeight, + quadrantLeft, + quadrantHalfWidth, + quadrantTop, + quadrantWidth + } = quadrantSpace; + const borderLines = [ + // top border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft - halfExternalBorderWidth, + y1: quadrantTop, + x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth, + y2: quadrantTop + }, + // right border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft + quadrantWidth, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft + quadrantWidth, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // bottom border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft - halfExternalBorderWidth, + y1: quadrantTop + quadrantHeight, + x2: quadrantLeft + quadrantWidth + halfExternalBorderWidth, + y2: quadrantTop + quadrantHeight + }, + // left border + { + strokeFill: this.themeConfig.quadrantExternalBorderStrokeFill, + strokeWidth: this.config.quadrantExternalBorderStrokeWidth, + x1: quadrantLeft, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // vertical inner border + { + strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill, + strokeWidth: this.config.quadrantInternalBorderStrokeWidth, + x1: quadrantLeft + quadrantHalfWidth, + y1: quadrantTop + halfExternalBorderWidth, + x2: quadrantLeft + quadrantHalfWidth, + y2: quadrantTop + quadrantHeight - halfExternalBorderWidth + }, + // horizontal inner border + { + strokeFill: this.themeConfig.quadrantInternalBorderStrokeFill, + strokeWidth: this.config.quadrantInternalBorderStrokeWidth, + x1: quadrantLeft + halfExternalBorderWidth, + y1: quadrantTop + quadrantHalfHeight, + x2: quadrantLeft + quadrantWidth - halfExternalBorderWidth, + y2: quadrantTop + quadrantHalfHeight + } + ]; + return borderLines; + } + getTitle(showTitle) { + if (showTitle) { + return { + text: this.data.titleText, + fill: this.themeConfig.quadrantTitleFill, + fontSize: this.config.titleFontSize, + horizontalPos: "top", + verticalPos: "center", + rotation: 0, + y: this.config.titlePadding, + x: this.config.chartWidth / 2 + }; + } + return; + } + build() { + const showXAxis = this.config.showXAxis && !!(this.data.xAxisLeftText || this.data.xAxisRightText); + const showYAxis = this.config.showYAxis && !!(this.data.yAxisTopText || this.data.yAxisBottomText); + const showTitle = this.config.showTitle && !!this.data.titleText; + const xAxisPosition = this.data.points.length > 0 ? "bottom" : this.config.xAxisPosition; + const calculatedSpace = this.calculateSpace(xAxisPosition, showXAxis, showYAxis, showTitle); + return { + points: this.getQuadrantPoints(calculatedSpace), + quadrants: this.getQuadrants(calculatedSpace), + axisLabels: this.getAxisLabels(xAxisPosition, showXAxis, showYAxis, calculatedSpace), + borderLines: this.getBorders(calculatedSpace), + title: this.getTitle(showTitle) + }; + } +} +const config = getConfig(); +function textSanitizer(text) { + return sanitizeText$2(text.trim(), config); +} +const quadrantBuilder = new QuadrantBuilder(); +function setQuadrant1Text(textObj) { + quadrantBuilder.setData({ quadrant1Text: textSanitizer(textObj.text) }); +} +function setQuadrant2Text(textObj) { + quadrantBuilder.setData({ quadrant2Text: textSanitizer(textObj.text) }); +} +function setQuadrant3Text(textObj) { + quadrantBuilder.setData({ quadrant3Text: textSanitizer(textObj.text) }); +} +function setQuadrant4Text(textObj) { + quadrantBuilder.setData({ quadrant4Text: textSanitizer(textObj.text) }); +} +function setXAxisLeftText(textObj) { + quadrantBuilder.setData({ xAxisLeftText: textSanitizer(textObj.text) }); +} +function setXAxisRightText(textObj) { + quadrantBuilder.setData({ xAxisRightText: textSanitizer(textObj.text) }); +} +function setYAxisTopText(textObj) { + quadrantBuilder.setData({ yAxisTopText: textSanitizer(textObj.text) }); +} +function setYAxisBottomText(textObj) { + quadrantBuilder.setData({ yAxisBottomText: textSanitizer(textObj.text) }); +} +function addPoint(textObj, x, y) { + quadrantBuilder.addPoints([{ x, y, text: textSanitizer(textObj.text) }]); +} +function setWidth(width) { + quadrantBuilder.setConfig({ chartWidth: width }); +} +function setHeight(height) { + quadrantBuilder.setConfig({ chartHeight: height }); +} +function getQuadrantData() { + const config2 = getConfig(); + const { themeVariables, quadrantChart: quadrantChartConfig } = config2; + if (quadrantChartConfig) { + quadrantBuilder.setConfig(quadrantChartConfig); + } + quadrantBuilder.setThemeConfig({ + quadrant1Fill: themeVariables.quadrant1Fill, + quadrant2Fill: themeVariables.quadrant2Fill, + quadrant3Fill: themeVariables.quadrant3Fill, + quadrant4Fill: themeVariables.quadrant4Fill, + quadrant1TextFill: themeVariables.quadrant1TextFill, + quadrant2TextFill: themeVariables.quadrant2TextFill, + quadrant3TextFill: themeVariables.quadrant3TextFill, + quadrant4TextFill: themeVariables.quadrant4TextFill, + quadrantPointFill: themeVariables.quadrantPointFill, + quadrantPointTextFill: themeVariables.quadrantPointTextFill, + quadrantXAxisTextFill: themeVariables.quadrantXAxisTextFill, + quadrantYAxisTextFill: themeVariables.quadrantYAxisTextFill, + quadrantExternalBorderStrokeFill: themeVariables.quadrantExternalBorderStrokeFill, + quadrantInternalBorderStrokeFill: themeVariables.quadrantInternalBorderStrokeFill, + quadrantTitleFill: themeVariables.quadrantTitleFill + }); + quadrantBuilder.setData({ titleText: getDiagramTitle() }); + return quadrantBuilder.build(); +} +const clear = function() { + quadrantBuilder.clear(); + clear$1(); +}; +const db = { + setWidth, + setHeight, + setQuadrant1Text, + setQuadrant2Text, + setQuadrant3Text, + setQuadrant4Text, + setXAxisLeftText, + setXAxisRightText, + setYAxisTopText, + setYAxisBottomText, + addPoint, + getQuadrantData, + clear, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + getAccDescription, + setAccDescription +}; +const draw = (txt, id, _version, diagObj) => { + var _a, _b, _c; + function getDominantBaseLine(horizontalPos) { + return horizontalPos === "top" ? "hanging" : "middle"; + } + function getTextAnchor(verticalPos) { + return verticalPos === "left" ? "start" : "middle"; + } + function getTransformation(data) { + return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`; + } + const conf = getConfig(); + log$1.debug("Rendering quadrant chart\n" + txt); + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const group = svg.append("g").attr("class", "main"); + const width = ((_a = conf.quadrantChart) == null ? void 0 : _a.chartWidth) || 500; + const height = ((_b = conf.quadrantChart) == null ? void 0 : _b.chartHeight) || 500; + configureSvgSize(svg, height, width, ((_c = conf.quadrantChart) == null ? void 0 : _c.useMaxWidth) || true); + svg.attr("viewBox", "0 0 " + width + " " + height); + diagObj.db.setHeight(height); + diagObj.db.setWidth(width); + const quadrantData = diagObj.db.getQuadrantData(); + const quadrantsGroup = group.append("g").attr("class", "quadrants"); + const borderGroup = group.append("g").attr("class", "border"); + const dataPointGroup = group.append("g").attr("class", "data-points"); + const labelGroup = group.append("g").attr("class", "labels"); + const titleGroup = group.append("g").attr("class", "title"); + if (quadrantData.title) { + titleGroup.append("text").attr("x", 0).attr("y", 0).attr("fill", quadrantData.title.fill).attr("font-size", quadrantData.title.fontSize).attr("dominant-baseline", getDominantBaseLine(quadrantData.title.horizontalPos)).attr("text-anchor", getTextAnchor(quadrantData.title.verticalPos)).attr("transform", getTransformation(quadrantData.title)).text(quadrantData.title.text); + } + if (quadrantData.borderLines) { + borderGroup.selectAll("line").data(quadrantData.borderLines).enter().append("line").attr("x1", (data) => data.x1).attr("y1", (data) => data.y1).attr("x2", (data) => data.x2).attr("y2", (data) => data.y2).style("stroke", (data) => data.strokeFill).style("stroke-width", (data) => data.strokeWidth); + } + const quadrants = quadrantsGroup.selectAll("g.quadrant").data(quadrantData.quadrants).enter().append("g").attr("class", "quadrant"); + quadrants.append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill); + quadrants.append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr( + "dominant-baseline", + (data) => getDominantBaseLine(data.text.horizontalPos) + ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)).text((data) => data.text.text); + const labels = labelGroup.selectAll("g.label").data(quadrantData.axisLabels).enter().append("g").attr("class", "label"); + labels.append("text").attr("x", 0).attr("y", 0).text((data) => data.text).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.horizontalPos)).attr("text-anchor", (data) => getTextAnchor(data.verticalPos)).attr("transform", (data) => getTransformation(data)); + const dataPoints = dataPointGroup.selectAll("g.data-point").data(quadrantData.points).enter().append("g").attr("class", "data-point"); + dataPoints.append("circle").attr("cx", (data) => data.x).attr("cy", (data) => data.y).attr("r", (data) => data.radius).attr("fill", (data) => data.fill); + dataPoints.append("text").attr("x", 0).attr("y", 0).text((data) => data.text.text).attr("fill", (data) => data.text.fill).attr("font-size", (data) => data.text.fontSize).attr( + "dominant-baseline", + (data) => getDominantBaseLine(data.text.horizontalPos) + ).attr("text-anchor", (data) => getTextAnchor(data.text.verticalPos)).attr("transform", (data) => getTransformation(data.text)); +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles: () => "" +}; + +export { diagram }; diff --git a/libs/marked/requirementDiagram-87253d64-HAYNZ486.js b/libs/marked/requirementDiagram-87253d64-HAYNZ486.js new file mode 100644 index 0000000..30257d7 --- /dev/null +++ b/libs/marked/requirementDiagram-87253d64-HAYNZ486.js @@ -0,0 +1,1091 @@ +import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, l as log$1, E as clear$1, h as select, i as configureSvgSize, j as common$1 } from './index-CN3YjQ0n.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { l as layout } from './layout-BOZlZI7g.js'; +import { l as line } from './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [5, 6, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63], $V5 = [1, 18], $V6 = [2, 7], $V7 = [1, 22], $V8 = [1, 23], $V9 = [1, 24], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 20], $Ve = [1, 28], $Vf = [1, 29], $Vg = [62, 63], $Vh = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 51, 53, 62, 63], $Vi = [1, 47], $Vj = [1, 48], $Vk = [1, 49], $Vl = [1, 50], $Vm = [1, 51], $Vn = [1, 52], $Vo = [1, 53], $Vp = [53, 54], $Vq = [1, 64], $Vr = [1, 60], $Vs = [1, 61], $Vt = [1, 62], $Vu = [1, 63], $Vv = [1, 65], $Vw = [1, 69], $Vx = [1, 70], $Vy = [1, 67], $Vz = [1, 68], $VA = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "directive": 4, "NEWLINE": 5, "RD": 6, "diagram": 7, "EOF": 8, "acc_title": 9, "acc_title_value": 10, "acc_descr": 11, "acc_descr_value": 12, "acc_descr_multiline_value": 13, "requirementDef": 14, "elementDef": 15, "relationshipDef": 16, "requirementType": 17, "requirementName": 18, "STRUCT_START": 19, "requirementBody": 20, "ID": 21, "COLONSEP": 22, "id": 23, "TEXT": 24, "text": 25, "RISK": 26, "riskLevel": 27, "VERIFYMTHD": 28, "verifyType": 29, "STRUCT_STOP": 30, "REQUIREMENT": 31, "FUNCTIONAL_REQUIREMENT": 32, "INTERFACE_REQUIREMENT": 33, "PERFORMANCE_REQUIREMENT": 34, "PHYSICAL_REQUIREMENT": 35, "DESIGN_CONSTRAINT": 36, "LOW_RISK": 37, "MED_RISK": 38, "HIGH_RISK": 39, "VERIFY_ANALYSIS": 40, "VERIFY_DEMONSTRATION": 41, "VERIFY_INSPECTION": 42, "VERIFY_TEST": 43, "ELEMENT": 44, "elementName": 45, "elementBody": 46, "TYPE": 47, "type": 48, "DOCREF": 49, "ref": 50, "END_ARROW_L": 51, "relationship": 52, "LINE": 53, "END_ARROW_R": 54, "CONTAINS": 55, "COPIES": 56, "DERIVES": 57, "SATISFIES": 58, "VERIFIES": 59, "REFINES": 60, "TRACES": 61, "unqString": 62, "qString": 63, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "NEWLINE", 6: "RD", 8: "EOF", 9: "acc_title", 10: "acc_title_value", 11: "acc_descr", 12: "acc_descr_value", 13: "acc_descr_multiline_value", 19: "STRUCT_START", 21: "ID", 22: "COLONSEP", 24: "TEXT", 26: "RISK", 28: "VERIFYMTHD", 30: "STRUCT_STOP", 31: "REQUIREMENT", 32: "FUNCTIONAL_REQUIREMENT", 33: "INTERFACE_REQUIREMENT", 34: "PERFORMANCE_REQUIREMENT", 35: "PHYSICAL_REQUIREMENT", 36: "DESIGN_CONSTRAINT", 37: "LOW_RISK", 38: "MED_RISK", 39: "HIGH_RISK", 40: "VERIFY_ANALYSIS", 41: "VERIFY_DEMONSTRATION", 42: "VERIFY_INSPECTION", 43: "VERIFY_TEST", 44: "ELEMENT", 47: "TYPE", 49: "DOCREF", 51: "END_ARROW_L", 53: "LINE", 54: "END_ARROW_R", 55: "CONTAINS", 56: "COPIES", 57: "DERIVES", 58: "SATISFIES", 59: "VERIFIES", 60: "REFINES", 61: "TRACES", 62: "unqString", 63: "qString" }, + productions_: [0, [3, 3], [3, 2], [3, 4], [4, 2], [4, 2], [4, 1], [7, 0], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [14, 5], [20, 5], [20, 5], [20, 5], [20, 5], [20, 2], [20, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [27, 1], [27, 1], [27, 1], [29, 1], [29, 1], [29, 1], [29, 1], [15, 5], [46, 5], [46, 5], [46, 2], [46, 1], [16, 5], [16, 5], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [18, 1], [18, 1], [23, 1], [23, 1], [25, 1], [25, 1], [45, 1], [45, 1], [48, 1], [48, 1], [50, 1], [50, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 4: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 5: + case 6: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 7: + this.$ = []; + break; + case 13: + yy.addRequirement($$[$0 - 3], $$[$0 - 4]); + break; + case 14: + yy.setNewReqId($$[$0 - 2]); + break; + case 15: + yy.setNewReqText($$[$0 - 2]); + break; + case 16: + yy.setNewReqRisk($$[$0 - 2]); + break; + case 17: + yy.setNewReqVerifyMethod($$[$0 - 2]); + break; + case 20: + this.$ = yy.RequirementType.REQUIREMENT; + break; + case 21: + this.$ = yy.RequirementType.FUNCTIONAL_REQUIREMENT; + break; + case 22: + this.$ = yy.RequirementType.INTERFACE_REQUIREMENT; + break; + case 23: + this.$ = yy.RequirementType.PERFORMANCE_REQUIREMENT; + break; + case 24: + this.$ = yy.RequirementType.PHYSICAL_REQUIREMENT; + break; + case 25: + this.$ = yy.RequirementType.DESIGN_CONSTRAINT; + break; + case 26: + this.$ = yy.RiskLevel.LOW_RISK; + break; + case 27: + this.$ = yy.RiskLevel.MED_RISK; + break; + case 28: + this.$ = yy.RiskLevel.HIGH_RISK; + break; + case 29: + this.$ = yy.VerifyType.VERIFY_ANALYSIS; + break; + case 30: + this.$ = yy.VerifyType.VERIFY_DEMONSTRATION; + break; + case 31: + this.$ = yy.VerifyType.VERIFY_INSPECTION; + break; + case 32: + this.$ = yy.VerifyType.VERIFY_TEST; + break; + case 33: + yy.addElement($$[$0 - 3]); + break; + case 34: + yy.setNewElementType($$[$0 - 2]); + break; + case 35: + yy.setNewElementDocRef($$[$0 - 2]); + break; + case 38: + yy.addRelationship($$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 39: + yy.addRelationship($$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 40: + this.$ = yy.Relationships.CONTAINS; + break; + case 41: + this.$ = yy.Relationships.COPIES; + break; + case 42: + this.$ = yy.Relationships.DERIVES; + break; + case 43: + this.$ = yy.Relationships.SATISFIES; + break; + case 44: + this.$ = yy.Relationships.VERIFIES; + break; + case 45: + this.$ = yy.Relationships.REFINES; + break; + case 46: + this.$ = yy.Relationships.TRACES; + break; + } + }, + table: [{ 3: 1, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [3] }, { 3: 8, 4: 2, 5: [1, 7], 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 5: [1, 9] }, { 10: [1, 10] }, { 12: [1, 11] }, o($V4, [2, 6]), { 3: 12, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [2, 2] }, { 4: 17, 5: $V5, 7: 13, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 1] }, { 8: [1, 30] }, { 4: 17, 5: $V5, 7: 31, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 32, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 33, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 34, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 35, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 18: 36, 62: [1, 37], 63: [1, 38] }, { 45: 39, 62: [1, 40], 63: [1, 41] }, { 51: [1, 42], 53: [1, 43] }, o($Vg, [2, 20]), o($Vg, [2, 21]), o($Vg, [2, 22]), o($Vg, [2, 23]), o($Vg, [2, 24]), o($Vg, [2, 25]), o($Vh, [2, 49]), o($Vh, [2, 50]), { 1: [2, 3] }, { 8: [2, 8] }, { 8: [2, 9] }, { 8: [2, 10] }, { 8: [2, 11] }, { 8: [2, 12] }, { 19: [1, 44] }, { 19: [2, 47] }, { 19: [2, 48] }, { 19: [1, 45] }, { 19: [2, 53] }, { 19: [2, 54] }, { 52: 46, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 52: 54, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 5: [1, 55] }, { 5: [1, 56] }, { 53: [1, 57] }, o($Vp, [2, 40]), o($Vp, [2, 41]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), { 54: [1, 58] }, { 5: $Vq, 20: 59, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 66, 47: $Vy, 49: $Vz }, { 23: 71, 62: $Ve, 63: $Vf }, { 23: 72, 62: $Ve, 63: $Vf }, o($VA, [2, 13]), { 22: [1, 73] }, { 22: [1, 74] }, { 22: [1, 75] }, { 22: [1, 76] }, { 5: $Vq, 20: 77, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, o($VA, [2, 19]), o($VA, [2, 33]), { 22: [1, 78] }, { 22: [1, 79] }, { 5: $Vw, 30: $Vx, 46: 80, 47: $Vy, 49: $Vz }, o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), { 23: 81, 62: $Ve, 63: $Vf }, { 25: 82, 62: [1, 83], 63: [1, 84] }, { 27: 85, 37: [1, 86], 38: [1, 87], 39: [1, 88] }, { 29: 89, 40: [1, 90], 41: [1, 91], 42: [1, 92], 43: [1, 93] }, o($VA, [2, 18]), { 48: 94, 62: [1, 95], 63: [1, 96] }, { 50: 97, 62: [1, 98], 63: [1, 99] }, o($VA, [2, 36]), { 5: [1, 100] }, { 5: [1, 101] }, { 5: [2, 51] }, { 5: [2, 52] }, { 5: [1, 102] }, { 5: [2, 26] }, { 5: [2, 27] }, { 5: [2, 28] }, { 5: [1, 103] }, { 5: [2, 29] }, { 5: [2, 30] }, { 5: [2, 31] }, { 5: [2, 32] }, { 5: [1, 104] }, { 5: [2, 55] }, { 5: [2, 56] }, { 5: [1, 105] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: $Vq, 20: 106, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 107, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 108, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 109, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 110, 47: $Vy, 49: $Vz }, { 5: $Vw, 30: $Vx, 46: 111, 47: $Vy, 49: $Vz }, o($VA, [2, 14]), o($VA, [2, 15]), o($VA, [2, 16]), o($VA, [2, 17]), o($VA, [2, 34]), o($VA, [2, 35])], + defaultActions: { 8: [2, 2], 12: [2, 1], 30: [2, 3], 31: [2, 8], 32: [2, 9], 33: [2, 10], 34: [2, 11], 35: [2, 12], 37: [2, 47], 38: [2, 48], 40: [2, 53], 41: [2, 54], 83: [2, 51], 84: [2, 52], 86: [2, 26], 87: [2, 27], 88: [2, 28], 90: [2, 29], 91: [2, 30], 92: [2, 31], 93: [2, 32], 95: [2, 55], 96: [2, 56], 98: [2, 57], 99: [2, 58] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return "title"; + case 1: + this.begin("acc_title"); + return 9; + case 2: + this.popState(); + return "acc_title_value"; + case 3: + this.begin("acc_descr"); + return 11; + case 4: + this.popState(); + return "acc_descr_value"; + case 5: + this.begin("acc_descr_multiline"); + break; + case 6: + this.popState(); + break; + case 7: + return "acc_descr_multiline_value"; + case 8: + return 5; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + return 8; + case 13: + return 6; + case 14: + return 19; + case 15: + return 30; + case 16: + return 22; + case 17: + return 21; + case 18: + return 24; + case 19: + return 26; + case 20: + return 28; + case 21: + return 31; + case 22: + return 32; + case 23: + return 33; + case 24: + return 34; + case 25: + return 35; + case 26: + return 36; + case 27: + return 37; + case 28: + return 38; + case 29: + return 39; + case 30: + return 40; + case 31: + return 41; + case 32: + return 42; + case 33: + return 43; + case 34: + return 44; + case 35: + return 55; + case 36: + return 56; + case 37: + return 57; + case 38: + return 58; + case 39: + return 59; + case 40: + return 60; + case 41: + return 61; + case 42: + return 47; + case 43: + return 49; + case 44: + return 51; + case 45: + return 54; + case 46: + return 53; + case 47: + this.begin("string"); + break; + case 48: + this.popState(); + break; + case 49: + return "qString"; + case 50: + yy_.yytext = yy_.yytext.trim(); + return 62; + } + }, + rules: [/^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:$)/i, /^(?:requirementDiagram\b)/i, /^(?:\{)/i, /^(?:\})/i, /^(?::)/i, /^(?:id\b)/i, /^(?:text\b)/i, /^(?:risk\b)/i, /^(?:verifyMethod\b)/i, /^(?:requirement\b)/i, /^(?:functionalRequirement\b)/i, /^(?:interfaceRequirement\b)/i, /^(?:performanceRequirement\b)/i, /^(?:physicalRequirement\b)/i, /^(?:designConstraint\b)/i, /^(?:low\b)/i, /^(?:medium\b)/i, /^(?:high\b)/i, /^(?:analysis\b)/i, /^(?:demonstration\b)/i, /^(?:inspection\b)/i, /^(?:test\b)/i, /^(?:element\b)/i, /^(?:contains\b)/i, /^(?:copies\b)/i, /^(?:derives\b)/i, /^(?:satisfies\b)/i, /^(?:verifies\b)/i, /^(?:refines\b)/i, /^(?:traces\b)/i, /^(?:type\b)/i, /^(?:docref\b)/i, /^(?:<-)/i, /^(?:->)/i, /^(?:-)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[\w][^\r\n\{\<\>\-\=]*)/i], + conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "unqString": { "rules": [], "inclusive": false }, "token": { "rules": [], "inclusive": false }, "string": { "rules": [48, 49], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 50], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let relations = []; +let latestRequirement = {}; +let requirements = {}; +let latestElement = {}; +let elements = {}; +const RequirementType = { + REQUIREMENT: "Requirement", + FUNCTIONAL_REQUIREMENT: "Functional Requirement", + INTERFACE_REQUIREMENT: "Interface Requirement", + PERFORMANCE_REQUIREMENT: "Performance Requirement", + PHYSICAL_REQUIREMENT: "Physical Requirement", + DESIGN_CONSTRAINT: "Design Constraint" +}; +const RiskLevel = { + LOW_RISK: "Low", + MED_RISK: "Medium", + HIGH_RISK: "High" +}; +const VerifyType = { + VERIFY_ANALYSIS: "Analysis", + VERIFY_DEMONSTRATION: "Demonstration", + VERIFY_INSPECTION: "Inspection", + VERIFY_TEST: "Test" +}; +const Relationships = { + CONTAINS: "contains", + COPIES: "copies", + DERIVES: "derives", + SATISFIES: "satisfies", + VERIFIES: "verifies", + REFINES: "refines", + TRACES: "traces" +}; +const addRequirement = (name, type) => { + if (requirements[name] === void 0) { + requirements[name] = { + name, + type, + id: latestRequirement.id, + text: latestRequirement.text, + risk: latestRequirement.risk, + verifyMethod: latestRequirement.verifyMethod + }; + } + latestRequirement = {}; + return requirements[name]; +}; +const getRequirements = () => requirements; +const setNewReqId = (id) => { + if (latestRequirement !== void 0) { + latestRequirement.id = id; + } +}; +const setNewReqText = (text) => { + if (latestRequirement !== void 0) { + latestRequirement.text = text; + } +}; +const setNewReqRisk = (risk) => { + if (latestRequirement !== void 0) { + latestRequirement.risk = risk; + } +}; +const setNewReqVerifyMethod = (verifyMethod) => { + if (latestRequirement !== void 0) { + latestRequirement.verifyMethod = verifyMethod; + } +}; +const addElement = (name) => { + if (elements[name] === void 0) { + elements[name] = { + name, + type: latestElement.type, + docRef: latestElement.docRef + }; + log$1.info("Added new requirement: ", name); + } + latestElement = {}; + return elements[name]; +}; +const getElements = () => elements; +const setNewElementType = (type) => { + if (latestElement !== void 0) { + latestElement.type = type; + } +}; +const setNewElementDocRef = (docRef) => { + if (latestElement !== void 0) { + latestElement.docRef = docRef; + } +}; +const addRelationship = (type, src, dst) => { + relations.push({ + type, + src, + dst + }); +}; +const getRelationships = () => relations; +const clear = () => { + relations = []; + latestRequirement = {}; + requirements = {}; + latestElement = {}; + elements = {}; + clear$1(); +}; +const db = { + RequirementType, + RiskLevel, + VerifyType, + Relationships, + getConfig: () => getConfig().req, + addRequirement, + getRequirements, + setNewReqId, + setNewReqText, + setNewReqRisk, + setNewReqVerifyMethod, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addElement, + getElements, + setNewElementType, + setNewElementDocRef, + addRelationship, + getRelationships, + clear +}; +const getStyles = (options) => ` + + marker { + fill: ${options.relationColor}; + stroke: ${options.relationColor}; + } + + marker.cross { + stroke: ${options.lineColor}; + } + + svg { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + } + + .reqBox { + fill: ${options.requirementBackground}; + fill-opacity: 1.0; + stroke: ${options.requirementBorderColor}; + stroke-width: ${options.requirementBorderSize}; + } + + .reqTitle, .reqLabel{ + fill: ${options.requirementTextColor}; + } + .reqLabelBox { + fill: ${options.relationLabelBackground}; + fill-opacity: 1.0; + } + + .req-title-line { + stroke: ${options.requirementBorderColor}; + stroke-width: ${options.requirementBorderSize}; + } + .relationshipLine { + stroke: ${options.relationColor}; + stroke-width: 1; + } + .relationshipLabel { + fill: ${options.relationLabelColor}; + } + +`; +const styles = getStyles; +const ReqMarkers = { + CONTAINS: "contains", + ARROW: "arrow" +}; +const insertLineEndings = (parentNode, conf2) => { + let containsNode = parentNode.append("defs").append("marker").attr("id", ReqMarkers.CONTAINS + "_line_ending").attr("refX", 0).attr("refY", conf2.line_height / 2).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("g"); + containsNode.append("circle").attr("cx", conf2.line_height / 2).attr("cy", conf2.line_height / 2).attr("r", conf2.line_height / 2).attr("fill", "none"); + containsNode.append("line").attr("x1", 0).attr("x2", conf2.line_height).attr("y1", conf2.line_height / 2).attr("y2", conf2.line_height / 2).attr("stroke-width", 1); + containsNode.append("line").attr("y1", 0).attr("y2", conf2.line_height).attr("x1", conf2.line_height / 2).attr("x2", conf2.line_height / 2).attr("stroke-width", 1); + parentNode.append("defs").append("marker").attr("id", ReqMarkers.ARROW + "_line_ending").attr("refX", conf2.line_height).attr("refY", 0.5 * conf2.line_height).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("path").attr( + "d", + `M0,0 + L${conf2.line_height},${conf2.line_height / 2} + M${conf2.line_height},${conf2.line_height / 2} + L0,${conf2.line_height}` + ).attr("stroke-width", 1); +}; +const markers = { + ReqMarkers, + insertLineEndings +}; +let conf = {}; +let relCnt = 0; +const newRectNode = (parentNode, id) => { + return parentNode.insert("rect", "#" + id).attr("class", "req reqBox").attr("x", 0).attr("y", 0).attr("width", conf.rect_min_width + "px").attr("height", conf.rect_min_height + "px"); +}; +const newTitleNode = (parentNode, id, txts) => { + let x = conf.rect_min_width / 2; + let title = parentNode.append("text").attr("class", "req reqLabel reqTitle").attr("id", id).attr("x", x).attr("y", conf.rect_padding).attr("dominant-baseline", "hanging"); + let i = 0; + txts.forEach((textStr) => { + if (i == 0) { + title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", 0).text(textStr); + } else { + title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", conf.line_height * 0.75).text(textStr); + } + i++; + }); + let yPadding = 1.5 * conf.rect_padding; + let linePadding = i * conf.line_height * 0.75; + let totalY = yPadding + linePadding; + parentNode.append("line").attr("class", "req-title-line").attr("x1", "0").attr("x2", conf.rect_min_width).attr("y1", totalY).attr("y2", totalY); + return { + titleNode: title, + y: totalY + }; +}; +const newBodyNode = (parentNode, id, txts, yStart) => { + let body = parentNode.append("text").attr("class", "req reqLabel").attr("id", id).attr("x", conf.rect_padding).attr("y", yStart).attr("dominant-baseline", "hanging"); + let currentRow = 0; + const charLimit = 30; + let wrappedTxts = []; + txts.forEach((textStr) => { + let currentTextLen = textStr.length; + while (currentTextLen > charLimit && currentRow < 3) { + let firstPart = textStr.substring(0, charLimit); + textStr = textStr.substring(charLimit, textStr.length); + currentTextLen = textStr.length; + wrappedTxts[wrappedTxts.length] = firstPart; + currentRow++; + } + if (currentRow == 3) { + let lastStr = wrappedTxts[wrappedTxts.length - 1]; + wrappedTxts[wrappedTxts.length - 1] = lastStr.substring(0, lastStr.length - 4) + "..."; + } else { + wrappedTxts[wrappedTxts.length] = textStr; + } + currentRow = 0; + }); + wrappedTxts.forEach((textStr) => { + body.append("tspan").attr("x", conf.rect_padding).attr("dy", conf.line_height).text(textStr); + }); + return body; +}; +const addEdgeLabel = (parentNode, svgPath, conf2, txt) => { + const len = svgPath.node().getTotalLength(); + const labelPoint = svgPath.node().getPointAtLength(len * 0.5); + const labelId = "rel" + relCnt; + relCnt++; + const labelNode = parentNode.append("text").attr("class", "req relationshipLabel").attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(txt); + const labelBBox = labelNode.node().getBBox(); + parentNode.insert("rect", "#" + labelId).attr("class", "req reqLabelBox").attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height).attr("fill", "white").attr("fill-opacity", "85%"); +}; +const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) { + const edge = g.edge(elementString(rel.src), elementString(rel.dst)); + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }); + const svgPath = svg.insert("path", "#" + insert).attr("class", "er relationshipLine").attr("d", lineFunction(edge.points)).attr("fill", "none"); + if (rel.type == diagObj.db.Relationships.CONTAINS) { + svgPath.attr( + "marker-start", + "url(" + common$1.getUrl(conf.arrowMarkerAbsolute) + "#" + rel.type + "_line_ending)" + ); + } else { + svgPath.attr("stroke-dasharray", "10,7"); + svgPath.attr( + "marker-end", + "url(" + common$1.getUrl(conf.arrowMarkerAbsolute) + "#" + markers.ReqMarkers.ARROW + "_line_ending)" + ); + } + addEdgeLabel(svg, svgPath, conf, `<<${rel.type}>>`); + return; +}; +const drawReqs = (reqs, graph, svgNode) => { + Object.keys(reqs).forEach((reqName) => { + let req = reqs[reqName]; + reqName = elementString(reqName); + log$1.info("Added new requirement: ", reqName); + const groupNode = svgNode.append("g").attr("id", reqName); + const textId = "req-" + reqName; + const rectNode = newRectNode(groupNode, textId); + let titleNodeInfo = newTitleNode(groupNode, reqName + "_title", [ + `<<${req.type}>>`, + `${req.name}` + ]); + newBodyNode( + groupNode, + reqName + "_body", + [ + `Id: ${req.id}`, + `Text: ${req.text}`, + `Risk: ${req.risk}`, + `Verification: ${req.verifyMethod}` + ], + titleNodeInfo.y + ); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(reqName, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id: reqName + }); + }); +}; +const drawElements = (els, graph, svgNode) => { + Object.keys(els).forEach((elName) => { + let el = els[elName]; + const id = elementString(elName); + const groupNode = svgNode.append("g").attr("id", id); + const textId = "element-" + id; + const rectNode = newRectNode(groupNode, textId); + let titleNodeInfo = newTitleNode(groupNode, textId + "_title", [`<>`, `${elName}`]); + newBodyNode( + groupNode, + textId + "_body", + [`Type: ${el.type || "Not Specified"}`, `Doc Ref: ${el.docRef || "None"}`], + titleNodeInfo.y + ); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(id, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id + }); + }); +}; +const addRelationships = (relationships, g) => { + relationships.forEach(function(r) { + let src = elementString(r.src); + let dst = elementString(r.dst); + g.setEdge(src, dst, { relationship: r }); + }); + return relationships; +}; +const adjustEntities = function(svgNode, graph) { + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + svgNode.select("#" + v); + svgNode.select("#" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )" + ); + } + }); + return; +}; +const elementString = (str) => { + return str.replace(/\s/g, "").replace(/\./g, "_"); +}; +const draw = (text, id, _version, diagObj) => { + conf = getConfig().requirement; + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id='${id}']`); + markers.insertLineEndings(svg, conf); + const g = new Graph({ + multigraph: false, + compound: false, + directed: true + }).setGraph({ + rankdir: conf.layoutDirection, + marginx: 20, + marginy: 20, + nodesep: 100, + edgesep: 100, + ranksep: 100 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let requirements2 = diagObj.db.getRequirements(); + let elements2 = diagObj.db.getElements(); + let relationships = diagObj.db.getRelationships(); + drawReqs(requirements2, g, svg); + drawElements(elements2, g, svg); + addRelationships(relationships, g); + layout(g); + adjustEntities(svg, g); + relationships.forEach(function(rel) { + drawRelationshipFromLayout(svg, rel, g, id, diagObj); + }); + const padding = conf.rect_padding; + const svgBounds = svg.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(svg, height, width, conf.useMaxWidth); + svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles +}; + +export { diagram }; diff --git a/libs/marked/requirementDiagram-87253d64-kJ-VaOjM.js b/libs/marked/requirementDiagram-87253d64-kJ-VaOjM.js new file mode 100644 index 0000000..d68cfc9 --- /dev/null +++ b/libs/marked/requirementDiagram-87253d64-kJ-VaOjM.js @@ -0,0 +1,1091 @@ +import { c as getConfig, s as setAccTitle, g as getAccTitle, b as setAccDescription, a as getAccDescription, l as log$1, E as clear$1, h as select, i as configureSvgSize, j as common$1 } from './index-Bd_FDXSq.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { l as layout } from './layout-BnytXFfq.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 3], $V1 = [1, 4], $V2 = [1, 5], $V3 = [1, 6], $V4 = [5, 6, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63], $V5 = [1, 18], $V6 = [2, 7], $V7 = [1, 22], $V8 = [1, 23], $V9 = [1, 24], $Va = [1, 25], $Vb = [1, 26], $Vc = [1, 27], $Vd = [1, 20], $Ve = [1, 28], $Vf = [1, 29], $Vg = [62, 63], $Vh = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 51, 53, 62, 63], $Vi = [1, 47], $Vj = [1, 48], $Vk = [1, 49], $Vl = [1, 50], $Vm = [1, 51], $Vn = [1, 52], $Vo = [1, 53], $Vp = [53, 54], $Vq = [1, 64], $Vr = [1, 60], $Vs = [1, 61], $Vt = [1, 62], $Vu = [1, 63], $Vv = [1, 65], $Vw = [1, 69], $Vx = [1, 70], $Vy = [1, 67], $Vz = [1, 68], $VA = [5, 8, 9, 11, 13, 31, 32, 33, 34, 35, 36, 44, 62, 63]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "directive": 4, "NEWLINE": 5, "RD": 6, "diagram": 7, "EOF": 8, "acc_title": 9, "acc_title_value": 10, "acc_descr": 11, "acc_descr_value": 12, "acc_descr_multiline_value": 13, "requirementDef": 14, "elementDef": 15, "relationshipDef": 16, "requirementType": 17, "requirementName": 18, "STRUCT_START": 19, "requirementBody": 20, "ID": 21, "COLONSEP": 22, "id": 23, "TEXT": 24, "text": 25, "RISK": 26, "riskLevel": 27, "VERIFYMTHD": 28, "verifyType": 29, "STRUCT_STOP": 30, "REQUIREMENT": 31, "FUNCTIONAL_REQUIREMENT": 32, "INTERFACE_REQUIREMENT": 33, "PERFORMANCE_REQUIREMENT": 34, "PHYSICAL_REQUIREMENT": 35, "DESIGN_CONSTRAINT": 36, "LOW_RISK": 37, "MED_RISK": 38, "HIGH_RISK": 39, "VERIFY_ANALYSIS": 40, "VERIFY_DEMONSTRATION": 41, "VERIFY_INSPECTION": 42, "VERIFY_TEST": 43, "ELEMENT": 44, "elementName": 45, "elementBody": 46, "TYPE": 47, "type": 48, "DOCREF": 49, "ref": 50, "END_ARROW_L": 51, "relationship": 52, "LINE": 53, "END_ARROW_R": 54, "CONTAINS": 55, "COPIES": 56, "DERIVES": 57, "SATISFIES": 58, "VERIFIES": 59, "REFINES": 60, "TRACES": 61, "unqString": 62, "qString": 63, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "NEWLINE", 6: "RD", 8: "EOF", 9: "acc_title", 10: "acc_title_value", 11: "acc_descr", 12: "acc_descr_value", 13: "acc_descr_multiline_value", 19: "STRUCT_START", 21: "ID", 22: "COLONSEP", 24: "TEXT", 26: "RISK", 28: "VERIFYMTHD", 30: "STRUCT_STOP", 31: "REQUIREMENT", 32: "FUNCTIONAL_REQUIREMENT", 33: "INTERFACE_REQUIREMENT", 34: "PERFORMANCE_REQUIREMENT", 35: "PHYSICAL_REQUIREMENT", 36: "DESIGN_CONSTRAINT", 37: "LOW_RISK", 38: "MED_RISK", 39: "HIGH_RISK", 40: "VERIFY_ANALYSIS", 41: "VERIFY_DEMONSTRATION", 42: "VERIFY_INSPECTION", 43: "VERIFY_TEST", 44: "ELEMENT", 47: "TYPE", 49: "DOCREF", 51: "END_ARROW_L", 53: "LINE", 54: "END_ARROW_R", 55: "CONTAINS", 56: "COPIES", 57: "DERIVES", 58: "SATISFIES", 59: "VERIFIES", 60: "REFINES", 61: "TRACES", 62: "unqString", 63: "qString" }, + productions_: [0, [3, 3], [3, 2], [3, 4], [4, 2], [4, 2], [4, 1], [7, 0], [7, 2], [7, 2], [7, 2], [7, 2], [7, 2], [14, 5], [20, 5], [20, 5], [20, 5], [20, 5], [20, 2], [20, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [17, 1], [27, 1], [27, 1], [27, 1], [29, 1], [29, 1], [29, 1], [29, 1], [15, 5], [46, 5], [46, 5], [46, 2], [46, 1], [16, 5], [16, 5], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [52, 1], [18, 1], [18, 1], [23, 1], [23, 1], [25, 1], [25, 1], [45, 1], [45, 1], [48, 1], [48, 1], [50, 1], [50, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 4: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 5: + case 6: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 7: + this.$ = []; + break; + case 13: + yy.addRequirement($$[$0 - 3], $$[$0 - 4]); + break; + case 14: + yy.setNewReqId($$[$0 - 2]); + break; + case 15: + yy.setNewReqText($$[$0 - 2]); + break; + case 16: + yy.setNewReqRisk($$[$0 - 2]); + break; + case 17: + yy.setNewReqVerifyMethod($$[$0 - 2]); + break; + case 20: + this.$ = yy.RequirementType.REQUIREMENT; + break; + case 21: + this.$ = yy.RequirementType.FUNCTIONAL_REQUIREMENT; + break; + case 22: + this.$ = yy.RequirementType.INTERFACE_REQUIREMENT; + break; + case 23: + this.$ = yy.RequirementType.PERFORMANCE_REQUIREMENT; + break; + case 24: + this.$ = yy.RequirementType.PHYSICAL_REQUIREMENT; + break; + case 25: + this.$ = yy.RequirementType.DESIGN_CONSTRAINT; + break; + case 26: + this.$ = yy.RiskLevel.LOW_RISK; + break; + case 27: + this.$ = yy.RiskLevel.MED_RISK; + break; + case 28: + this.$ = yy.RiskLevel.HIGH_RISK; + break; + case 29: + this.$ = yy.VerifyType.VERIFY_ANALYSIS; + break; + case 30: + this.$ = yy.VerifyType.VERIFY_DEMONSTRATION; + break; + case 31: + this.$ = yy.VerifyType.VERIFY_INSPECTION; + break; + case 32: + this.$ = yy.VerifyType.VERIFY_TEST; + break; + case 33: + yy.addElement($$[$0 - 3]); + break; + case 34: + yy.setNewElementType($$[$0 - 2]); + break; + case 35: + yy.setNewElementDocRef($$[$0 - 2]); + break; + case 38: + yy.addRelationship($$[$0 - 2], $$[$0], $$[$0 - 4]); + break; + case 39: + yy.addRelationship($$[$0 - 2], $$[$0 - 4], $$[$0]); + break; + case 40: + this.$ = yy.Relationships.CONTAINS; + break; + case 41: + this.$ = yy.Relationships.COPIES; + break; + case 42: + this.$ = yy.Relationships.DERIVES; + break; + case 43: + this.$ = yy.Relationships.SATISFIES; + break; + case 44: + this.$ = yy.Relationships.VERIFIES; + break; + case 45: + this.$ = yy.Relationships.REFINES; + break; + case 46: + this.$ = yy.Relationships.TRACES; + break; + } + }, + table: [{ 3: 1, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [3] }, { 3: 8, 4: 2, 5: [1, 7], 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 5: [1, 9] }, { 10: [1, 10] }, { 12: [1, 11] }, o($V4, [2, 6]), { 3: 12, 4: 2, 6: $V0, 9: $V1, 11: $V2, 13: $V3 }, { 1: [2, 2] }, { 4: 17, 5: $V5, 7: 13, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 1] }, { 8: [1, 30] }, { 4: 17, 5: $V5, 7: 31, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 32, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 33, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 34, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 4: 17, 5: $V5, 7: 35, 8: $V6, 9: $V1, 11: $V2, 13: $V3, 14: 14, 15: 15, 16: 16, 17: 19, 23: 21, 31: $V7, 32: $V8, 33: $V9, 34: $Va, 35: $Vb, 36: $Vc, 44: $Vd, 62: $Ve, 63: $Vf }, { 18: 36, 62: [1, 37], 63: [1, 38] }, { 45: 39, 62: [1, 40], 63: [1, 41] }, { 51: [1, 42], 53: [1, 43] }, o($Vg, [2, 20]), o($Vg, [2, 21]), o($Vg, [2, 22]), o($Vg, [2, 23]), o($Vg, [2, 24]), o($Vg, [2, 25]), o($Vh, [2, 49]), o($Vh, [2, 50]), { 1: [2, 3] }, { 8: [2, 8] }, { 8: [2, 9] }, { 8: [2, 10] }, { 8: [2, 11] }, { 8: [2, 12] }, { 19: [1, 44] }, { 19: [2, 47] }, { 19: [2, 48] }, { 19: [1, 45] }, { 19: [2, 53] }, { 19: [2, 54] }, { 52: 46, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 52: 54, 55: $Vi, 56: $Vj, 57: $Vk, 58: $Vl, 59: $Vm, 60: $Vn, 61: $Vo }, { 5: [1, 55] }, { 5: [1, 56] }, { 53: [1, 57] }, o($Vp, [2, 40]), o($Vp, [2, 41]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), { 54: [1, 58] }, { 5: $Vq, 20: 59, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 66, 47: $Vy, 49: $Vz }, { 23: 71, 62: $Ve, 63: $Vf }, { 23: 72, 62: $Ve, 63: $Vf }, o($VA, [2, 13]), { 22: [1, 73] }, { 22: [1, 74] }, { 22: [1, 75] }, { 22: [1, 76] }, { 5: $Vq, 20: 77, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, o($VA, [2, 19]), o($VA, [2, 33]), { 22: [1, 78] }, { 22: [1, 79] }, { 5: $Vw, 30: $Vx, 46: 80, 47: $Vy, 49: $Vz }, o($VA, [2, 37]), o($VA, [2, 38]), o($VA, [2, 39]), { 23: 81, 62: $Ve, 63: $Vf }, { 25: 82, 62: [1, 83], 63: [1, 84] }, { 27: 85, 37: [1, 86], 38: [1, 87], 39: [1, 88] }, { 29: 89, 40: [1, 90], 41: [1, 91], 42: [1, 92], 43: [1, 93] }, o($VA, [2, 18]), { 48: 94, 62: [1, 95], 63: [1, 96] }, { 50: 97, 62: [1, 98], 63: [1, 99] }, o($VA, [2, 36]), { 5: [1, 100] }, { 5: [1, 101] }, { 5: [2, 51] }, { 5: [2, 52] }, { 5: [1, 102] }, { 5: [2, 26] }, { 5: [2, 27] }, { 5: [2, 28] }, { 5: [1, 103] }, { 5: [2, 29] }, { 5: [2, 30] }, { 5: [2, 31] }, { 5: [2, 32] }, { 5: [1, 104] }, { 5: [2, 55] }, { 5: [2, 56] }, { 5: [1, 105] }, { 5: [2, 57] }, { 5: [2, 58] }, { 5: $Vq, 20: 106, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 107, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 108, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vq, 20: 109, 21: $Vr, 24: $Vs, 26: $Vt, 28: $Vu, 30: $Vv }, { 5: $Vw, 30: $Vx, 46: 110, 47: $Vy, 49: $Vz }, { 5: $Vw, 30: $Vx, 46: 111, 47: $Vy, 49: $Vz }, o($VA, [2, 14]), o($VA, [2, 15]), o($VA, [2, 16]), o($VA, [2, 17]), o($VA, [2, 34]), o($VA, [2, 35])], + defaultActions: { 8: [2, 2], 12: [2, 1], 30: [2, 3], 31: [2, 8], 32: [2, 9], 33: [2, 10], 34: [2, 11], 35: [2, 12], 37: [2, 47], 38: [2, 48], 40: [2, 53], 41: [2, 54], 83: [2, 51], 84: [2, 52], 86: [2, 26], 87: [2, 27], 88: [2, 28], 90: [2, 29], 91: [2, 30], 92: [2, 31], 93: [2, 32], 95: [2, 55], 96: [2, 56], 98: [2, 57], 99: [2, 58] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return "title"; + case 1: + this.begin("acc_title"); + return 9; + case 2: + this.popState(); + return "acc_title_value"; + case 3: + this.begin("acc_descr"); + return 11; + case 4: + this.popState(); + return "acc_descr_value"; + case 5: + this.begin("acc_descr_multiline"); + break; + case 6: + this.popState(); + break; + case 7: + return "acc_descr_multiline_value"; + case 8: + return 5; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + return 8; + case 13: + return 6; + case 14: + return 19; + case 15: + return 30; + case 16: + return 22; + case 17: + return 21; + case 18: + return 24; + case 19: + return 26; + case 20: + return 28; + case 21: + return 31; + case 22: + return 32; + case 23: + return 33; + case 24: + return 34; + case 25: + return 35; + case 26: + return 36; + case 27: + return 37; + case 28: + return 38; + case 29: + return 39; + case 30: + return 40; + case 31: + return 41; + case 32: + return 42; + case 33: + return 43; + case 34: + return 44; + case 35: + return 55; + case 36: + return 56; + case 37: + return 57; + case 38: + return 58; + case 39: + return 59; + case 40: + return 60; + case 41: + return 61; + case 42: + return 47; + case 43: + return 49; + case 44: + return 51; + case 45: + return 54; + case 46: + return 53; + case 47: + this.begin("string"); + break; + case 48: + this.popState(); + break; + case 49: + return "qString"; + case 50: + yy_.yytext = yy_.yytext.trim(); + return 62; + } + }, + rules: [/^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:(\r?\n)+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:$)/i, /^(?:requirementDiagram\b)/i, /^(?:\{)/i, /^(?:\})/i, /^(?::)/i, /^(?:id\b)/i, /^(?:text\b)/i, /^(?:risk\b)/i, /^(?:verifyMethod\b)/i, /^(?:requirement\b)/i, /^(?:functionalRequirement\b)/i, /^(?:interfaceRequirement\b)/i, /^(?:performanceRequirement\b)/i, /^(?:physicalRequirement\b)/i, /^(?:designConstraint\b)/i, /^(?:low\b)/i, /^(?:medium\b)/i, /^(?:high\b)/i, /^(?:analysis\b)/i, /^(?:demonstration\b)/i, /^(?:inspection\b)/i, /^(?:test\b)/i, /^(?:element\b)/i, /^(?:contains\b)/i, /^(?:copies\b)/i, /^(?:derives\b)/i, /^(?:satisfies\b)/i, /^(?:verifies\b)/i, /^(?:refines\b)/i, /^(?:traces\b)/i, /^(?:type\b)/i, /^(?:docref\b)/i, /^(?:<-)/i, /^(?:->)/i, /^(?:-)/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[\w][^\r\n\{\<\>\-\=]*)/i], + conditions: { "acc_descr_multiline": { "rules": [6, 7], "inclusive": false }, "acc_descr": { "rules": [4], "inclusive": false }, "acc_title": { "rules": [2], "inclusive": false }, "unqString": { "rules": [], "inclusive": false }, "token": { "rules": [], "inclusive": false }, "string": { "rules": [48, 49], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 50], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let relations = []; +let latestRequirement = {}; +let requirements = {}; +let latestElement = {}; +let elements = {}; +const RequirementType = { + REQUIREMENT: "Requirement", + FUNCTIONAL_REQUIREMENT: "Functional Requirement", + INTERFACE_REQUIREMENT: "Interface Requirement", + PERFORMANCE_REQUIREMENT: "Performance Requirement", + PHYSICAL_REQUIREMENT: "Physical Requirement", + DESIGN_CONSTRAINT: "Design Constraint" +}; +const RiskLevel = { + LOW_RISK: "Low", + MED_RISK: "Medium", + HIGH_RISK: "High" +}; +const VerifyType = { + VERIFY_ANALYSIS: "Analysis", + VERIFY_DEMONSTRATION: "Demonstration", + VERIFY_INSPECTION: "Inspection", + VERIFY_TEST: "Test" +}; +const Relationships = { + CONTAINS: "contains", + COPIES: "copies", + DERIVES: "derives", + SATISFIES: "satisfies", + VERIFIES: "verifies", + REFINES: "refines", + TRACES: "traces" +}; +const addRequirement = (name, type) => { + if (requirements[name] === void 0) { + requirements[name] = { + name, + type, + id: latestRequirement.id, + text: latestRequirement.text, + risk: latestRequirement.risk, + verifyMethod: latestRequirement.verifyMethod + }; + } + latestRequirement = {}; + return requirements[name]; +}; +const getRequirements = () => requirements; +const setNewReqId = (id) => { + if (latestRequirement !== void 0) { + latestRequirement.id = id; + } +}; +const setNewReqText = (text) => { + if (latestRequirement !== void 0) { + latestRequirement.text = text; + } +}; +const setNewReqRisk = (risk) => { + if (latestRequirement !== void 0) { + latestRequirement.risk = risk; + } +}; +const setNewReqVerifyMethod = (verifyMethod) => { + if (latestRequirement !== void 0) { + latestRequirement.verifyMethod = verifyMethod; + } +}; +const addElement = (name) => { + if (elements[name] === void 0) { + elements[name] = { + name, + type: latestElement.type, + docRef: latestElement.docRef + }; + log$1.info("Added new requirement: ", name); + } + latestElement = {}; + return elements[name]; +}; +const getElements = () => elements; +const setNewElementType = (type) => { + if (latestElement !== void 0) { + latestElement.type = type; + } +}; +const setNewElementDocRef = (docRef) => { + if (latestElement !== void 0) { + latestElement.docRef = docRef; + } +}; +const addRelationship = (type, src, dst) => { + relations.push({ + type, + src, + dst + }); +}; +const getRelationships = () => relations; +const clear = () => { + relations = []; + latestRequirement = {}; + requirements = {}; + latestElement = {}; + elements = {}; + clear$1(); +}; +const db = { + RequirementType, + RiskLevel, + VerifyType, + Relationships, + getConfig: () => getConfig().req, + addRequirement, + getRequirements, + setNewReqId, + setNewReqText, + setNewReqRisk, + setNewReqVerifyMethod, + setAccTitle, + getAccTitle, + setAccDescription, + getAccDescription, + addElement, + getElements, + setNewElementType, + setNewElementDocRef, + addRelationship, + getRelationships, + clear +}; +const getStyles = (options) => ` + + marker { + fill: ${options.relationColor}; + stroke: ${options.relationColor}; + } + + marker.cross { + stroke: ${options.lineColor}; + } + + svg { + font-family: ${options.fontFamily}; + font-size: ${options.fontSize}; + } + + .reqBox { + fill: ${options.requirementBackground}; + fill-opacity: 1.0; + stroke: ${options.requirementBorderColor}; + stroke-width: ${options.requirementBorderSize}; + } + + .reqTitle, .reqLabel{ + fill: ${options.requirementTextColor}; + } + .reqLabelBox { + fill: ${options.relationLabelBackground}; + fill-opacity: 1.0; + } + + .req-title-line { + stroke: ${options.requirementBorderColor}; + stroke-width: ${options.requirementBorderSize}; + } + .relationshipLine { + stroke: ${options.relationColor}; + stroke-width: 1; + } + .relationshipLabel { + fill: ${options.relationLabelColor}; + } + +`; +const styles = getStyles; +const ReqMarkers = { + CONTAINS: "contains", + ARROW: "arrow" +}; +const insertLineEndings = (parentNode, conf2) => { + let containsNode = parentNode.append("defs").append("marker").attr("id", ReqMarkers.CONTAINS + "_line_ending").attr("refX", 0).attr("refY", conf2.line_height / 2).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("g"); + containsNode.append("circle").attr("cx", conf2.line_height / 2).attr("cy", conf2.line_height / 2).attr("r", conf2.line_height / 2).attr("fill", "none"); + containsNode.append("line").attr("x1", 0).attr("x2", conf2.line_height).attr("y1", conf2.line_height / 2).attr("y2", conf2.line_height / 2).attr("stroke-width", 1); + containsNode.append("line").attr("y1", 0).attr("y2", conf2.line_height).attr("x1", conf2.line_height / 2).attr("x2", conf2.line_height / 2).attr("stroke-width", 1); + parentNode.append("defs").append("marker").attr("id", ReqMarkers.ARROW + "_line_ending").attr("refX", conf2.line_height).attr("refY", 0.5 * conf2.line_height).attr("markerWidth", conf2.line_height).attr("markerHeight", conf2.line_height).attr("orient", "auto").append("path").attr( + "d", + `M0,0 + L${conf2.line_height},${conf2.line_height / 2} + M${conf2.line_height},${conf2.line_height / 2} + L0,${conf2.line_height}` + ).attr("stroke-width", 1); +}; +const markers = { + ReqMarkers, + insertLineEndings +}; +let conf = {}; +let relCnt = 0; +const newRectNode = (parentNode, id) => { + return parentNode.insert("rect", "#" + id).attr("class", "req reqBox").attr("x", 0).attr("y", 0).attr("width", conf.rect_min_width + "px").attr("height", conf.rect_min_height + "px"); +}; +const newTitleNode = (parentNode, id, txts) => { + let x = conf.rect_min_width / 2; + let title = parentNode.append("text").attr("class", "req reqLabel reqTitle").attr("id", id).attr("x", x).attr("y", conf.rect_padding).attr("dominant-baseline", "hanging"); + let i = 0; + txts.forEach((textStr) => { + if (i == 0) { + title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", 0).text(textStr); + } else { + title.append("tspan").attr("text-anchor", "middle").attr("x", conf.rect_min_width / 2).attr("dy", conf.line_height * 0.75).text(textStr); + } + i++; + }); + let yPadding = 1.5 * conf.rect_padding; + let linePadding = i * conf.line_height * 0.75; + let totalY = yPadding + linePadding; + parentNode.append("line").attr("class", "req-title-line").attr("x1", "0").attr("x2", conf.rect_min_width).attr("y1", totalY).attr("y2", totalY); + return { + titleNode: title, + y: totalY + }; +}; +const newBodyNode = (parentNode, id, txts, yStart) => { + let body = parentNode.append("text").attr("class", "req reqLabel").attr("id", id).attr("x", conf.rect_padding).attr("y", yStart).attr("dominant-baseline", "hanging"); + let currentRow = 0; + const charLimit = 30; + let wrappedTxts = []; + txts.forEach((textStr) => { + let currentTextLen = textStr.length; + while (currentTextLen > charLimit && currentRow < 3) { + let firstPart = textStr.substring(0, charLimit); + textStr = textStr.substring(charLimit, textStr.length); + currentTextLen = textStr.length; + wrappedTxts[wrappedTxts.length] = firstPart; + currentRow++; + } + if (currentRow == 3) { + let lastStr = wrappedTxts[wrappedTxts.length - 1]; + wrappedTxts[wrappedTxts.length - 1] = lastStr.substring(0, lastStr.length - 4) + "..."; + } else { + wrappedTxts[wrappedTxts.length] = textStr; + } + currentRow = 0; + }); + wrappedTxts.forEach((textStr) => { + body.append("tspan").attr("x", conf.rect_padding).attr("dy", conf.line_height).text(textStr); + }); + return body; +}; +const addEdgeLabel = (parentNode, svgPath, conf2, txt) => { + const len = svgPath.node().getTotalLength(); + const labelPoint = svgPath.node().getPointAtLength(len * 0.5); + const labelId = "rel" + relCnt; + relCnt++; + const labelNode = parentNode.append("text").attr("class", "req relationshipLabel").attr("id", labelId).attr("x", labelPoint.x).attr("y", labelPoint.y).attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(txt); + const labelBBox = labelNode.node().getBBox(); + parentNode.insert("rect", "#" + labelId).attr("class", "req reqLabelBox").attr("x", labelPoint.x - labelBBox.width / 2).attr("y", labelPoint.y - labelBBox.height / 2).attr("width", labelBBox.width).attr("height", labelBBox.height).attr("fill", "white").attr("fill-opacity", "85%"); +}; +const drawRelationshipFromLayout = function(svg, rel, g, insert, diagObj) { + const edge = g.edge(elementString(rel.src), elementString(rel.dst)); + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }); + const svgPath = svg.insert("path", "#" + insert).attr("class", "er relationshipLine").attr("d", lineFunction(edge.points)).attr("fill", "none"); + if (rel.type == diagObj.db.Relationships.CONTAINS) { + svgPath.attr( + "marker-start", + "url(" + common$1.getUrl(conf.arrowMarkerAbsolute) + "#" + rel.type + "_line_ending)" + ); + } else { + svgPath.attr("stroke-dasharray", "10,7"); + svgPath.attr( + "marker-end", + "url(" + common$1.getUrl(conf.arrowMarkerAbsolute) + "#" + markers.ReqMarkers.ARROW + "_line_ending)" + ); + } + addEdgeLabel(svg, svgPath, conf, `<<${rel.type}>>`); + return; +}; +const drawReqs = (reqs, graph, svgNode) => { + Object.keys(reqs).forEach((reqName) => { + let req = reqs[reqName]; + reqName = elementString(reqName); + log$1.info("Added new requirement: ", reqName); + const groupNode = svgNode.append("g").attr("id", reqName); + const textId = "req-" + reqName; + const rectNode = newRectNode(groupNode, textId); + let titleNodeInfo = newTitleNode(groupNode, reqName + "_title", [ + `<<${req.type}>>`, + `${req.name}` + ]); + newBodyNode( + groupNode, + reqName + "_body", + [ + `Id: ${req.id}`, + `Text: ${req.text}`, + `Risk: ${req.risk}`, + `Verification: ${req.verifyMethod}` + ], + titleNodeInfo.y + ); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(reqName, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id: reqName + }); + }); +}; +const drawElements = (els, graph, svgNode) => { + Object.keys(els).forEach((elName) => { + let el = els[elName]; + const id = elementString(elName); + const groupNode = svgNode.append("g").attr("id", id); + const textId = "element-" + id; + const rectNode = newRectNode(groupNode, textId); + let titleNodeInfo = newTitleNode(groupNode, textId + "_title", [`<>`, `${elName}`]); + newBodyNode( + groupNode, + textId + "_body", + [`Type: ${el.type || "Not Specified"}`, `Doc Ref: ${el.docRef || "None"}`], + titleNodeInfo.y + ); + const rectBBox = rectNode.node().getBBox(); + graph.setNode(id, { + width: rectBBox.width, + height: rectBBox.height, + shape: "rect", + id + }); + }); +}; +const addRelationships = (relationships, g) => { + relationships.forEach(function(r) { + let src = elementString(r.src); + let dst = elementString(r.dst); + g.setEdge(src, dst, { relationship: r }); + }); + return relationships; +}; +const adjustEntities = function(svgNode, graph) { + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + svgNode.select("#" + v); + svgNode.select("#" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y - graph.node(v).height / 2) + " )" + ); + } + }); + return; +}; +const elementString = (str) => { + return str.replace(/\s/g, "").replace(/\./g, "_"); +}; +const draw = (text, id, _version, diagObj) => { + conf = getConfig().requirement; + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id='${id}']`); + markers.insertLineEndings(svg, conf); + const g = new Graph({ + multigraph: false, + compound: false, + directed: true + }).setGraph({ + rankdir: conf.layoutDirection, + marginx: 20, + marginy: 20, + nodesep: 100, + edgesep: 100, + ranksep: 100 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let requirements2 = diagObj.db.getRequirements(); + let elements2 = diagObj.db.getElements(); + let relationships = diagObj.db.getRelationships(); + drawReqs(requirements2, g, svg); + drawElements(elements2, g, svg); + addRelationships(relationships, g); + layout(g); + adjustEntities(svg, g); + relationships.forEach(function(rel) { + drawRelationshipFromLayout(svg, rel, g, id, diagObj); + }); + const padding = conf.rect_padding; + const svgBounds = svg.node().getBBox(); + const width = svgBounds.width + padding * 2; + const height = svgBounds.height + padding * 2; + configureSvgSize(svg, height, width, conf.useMaxWidth); + svg.attr("viewBox", `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`); +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles +}; + +export { diagram }; diff --git a/libs/marked/sankeyDiagram-707fac0f-Cjcgj_Iu.js b/libs/marked/sankeyDiagram-707fac0f-Cjcgj_Iu.js new file mode 100644 index 0000000..9234372 --- /dev/null +++ b/libs/marked/sankeyDiagram-707fac0f-Cjcgj_Iu.js @@ -0,0 +1,1320 @@ +import { c as getConfig, g as getAccTitle, s as setAccTitle, a as getAccDescription, b as setAccDescription, D as getDiagramTitle, C as setDiagramTitle, E as clear$1, j as common$1, aq as defaultConfig, h as select, t as setupGraphViewbox$1 } from './index-CN3YjQ0n.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { s as schemeTableau10 } from './Tableau10-CkeCzOvH.js'; +import './init-zpY4DTin.js'; + +function max(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +function sum(values, valueof) { + let sum = 0; + if (valueof === undefined) { + for (let value of values) { + if (value = +value) { + sum += value; + } + } + } else { + let index = -1; + for (let value of values) { + if (value = +valueof(value, ++index, values)) { + sum += value; + } + } + } + return sum; +} + +function targetDepth(d) { + return d.target.depth; +} + +function left(node) { + return node.depth; +} + +function right(node, n) { + return n - 1 - node.height; +} + +function justify(node, n) { + return node.sourceLinks.length ? node.depth : n - 1; +} + +function center(node) { + return node.targetLinks.length ? node.depth + : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 + : 0; +} + +function constant$1(x) { + return function() { + return x; + }; +} + +function ascendingSourceBreadth(a, b) { + return ascendingBreadth(a.source, b.source) || a.index - b.index; +} + +function ascendingTargetBreadth(a, b) { + return ascendingBreadth(a.target, b.target) || a.index - b.index; +} + +function ascendingBreadth(a, b) { + return a.y0 - b.y0; +} + +function value(d) { + return d.value; +} + +function defaultId(d) { + return d.index; +} + +function defaultNodes(graph) { + return graph.nodes; +} + +function defaultLinks(graph) { + return graph.links; +} + +function find(nodeById, id) { + const node = nodeById.get(id); + if (!node) throw new Error("missing: " + id); + return node; +} + +function computeLinkBreadths({nodes}) { + for (const node of nodes) { + let y0 = node.y0; + let y1 = y0; + for (const link of node.sourceLinks) { + link.y0 = y0 + link.width / 2; + y0 += link.width; + } + for (const link of node.targetLinks) { + link.y1 = y1 + link.width / 2; + y1 += link.width; + } + } +} + +function Sankey() { + let x0 = 0, y0 = 0, x1 = 1, y1 = 1; // extent + let dx = 24; // nodeWidth + let dy = 8, py; // nodePadding + let id = defaultId; + let align = justify; + let sort; + let linkSort; + let nodes = defaultNodes; + let links = defaultLinks; + let iterations = 6; + + function sankey() { + const graph = {nodes: nodes.apply(null, arguments), links: links.apply(null, arguments)}; + computeNodeLinks(graph); + computeNodeValues(graph); + computeNodeDepths(graph); + computeNodeHeights(graph); + computeNodeBreadths(graph); + computeLinkBreadths(graph); + return graph; + } + + sankey.update = function(graph) { + computeLinkBreadths(graph); + return graph; + }; + + sankey.nodeId = function(_) { + return arguments.length ? (id = typeof _ === "function" ? _ : constant$1(_), sankey) : id; + }; + + sankey.nodeAlign = function(_) { + return arguments.length ? (align = typeof _ === "function" ? _ : constant$1(_), sankey) : align; + }; + + sankey.nodeSort = function(_) { + return arguments.length ? (sort = _, sankey) : sort; + }; + + sankey.nodeWidth = function(_) { + return arguments.length ? (dx = +_, sankey) : dx; + }; + + sankey.nodePadding = function(_) { + return arguments.length ? (dy = py = +_, sankey) : dy; + }; + + sankey.nodes = function(_) { + return arguments.length ? (nodes = typeof _ === "function" ? _ : constant$1(_), sankey) : nodes; + }; + + sankey.links = function(_) { + return arguments.length ? (links = typeof _ === "function" ? _ : constant$1(_), sankey) : links; + }; + + sankey.linkSort = function(_) { + return arguments.length ? (linkSort = _, sankey) : linkSort; + }; + + sankey.size = function(_) { + return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0]; + }; + + sankey.extent = function(_) { + return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]]; + }; + + sankey.iterations = function(_) { + return arguments.length ? (iterations = +_, sankey) : iterations; + }; + + function computeNodeLinks({nodes, links}) { + for (const [i, node] of nodes.entries()) { + node.index = i; + node.sourceLinks = []; + node.targetLinks = []; + } + const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d])); + for (const [i, link] of links.entries()) { + link.index = i; + let {source, target} = link; + if (typeof source !== "object") source = link.source = find(nodeById, source); + if (typeof target !== "object") target = link.target = find(nodeById, target); + source.sourceLinks.push(link); + target.targetLinks.push(link); + } + if (linkSort != null) { + for (const {sourceLinks, targetLinks} of nodes) { + sourceLinks.sort(linkSort); + targetLinks.sort(linkSort); + } + } + } + + function computeNodeValues({nodes}) { + for (const node of nodes) { + node.value = node.fixedValue === undefined + ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value)) + : node.fixedValue; + } + } + + function computeNodeDepths({nodes}) { + const n = nodes.length; + let current = new Set(nodes); + let next = new Set; + let x = 0; + while (current.size) { + for (const node of current) { + node.depth = x; + for (const {target} of node.sourceLinks) { + next.add(target); + } + } + if (++x > n) throw new Error("circular link"); + current = next; + next = new Set; + } + } + + function computeNodeHeights({nodes}) { + const n = nodes.length; + let current = new Set(nodes); + let next = new Set; + let x = 0; + while (current.size) { + for (const node of current) { + node.height = x; + for (const {source} of node.targetLinks) { + next.add(source); + } + } + if (++x > n) throw new Error("circular link"); + current = next; + next = new Set; + } + } + + function computeNodeLayers({nodes}) { + const x = max(nodes, d => d.depth) + 1; + const kx = (x1 - x0 - dx) / (x - 1); + const columns = new Array(x); + for (const node of nodes) { + const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x)))); + node.layer = i; + node.x0 = x0 + i * kx; + node.x1 = node.x0 + dx; + if (columns[i]) columns[i].push(node); + else columns[i] = [node]; + } + if (sort) for (const column of columns) { + column.sort(sort); + } + return columns; + } + + function initializeNodeBreadths(columns) { + const ky = min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum(c, value)); + for (const nodes of columns) { + let y = y0; + for (const node of nodes) { + node.y0 = y; + node.y1 = y + node.value * ky; + y = node.y1 + py; + for (const link of node.sourceLinks) { + link.width = link.value * ky; + } + } + y = (y1 - y + py) / (nodes.length + 1); + for (let i = 0; i < nodes.length; ++i) { + const node = nodes[i]; + node.y0 += y * (i + 1); + node.y1 += y * (i + 1); + } + reorderLinks(nodes); + } + } + + function computeNodeBreadths(graph) { + const columns = computeNodeLayers(graph); + py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1)); + initializeNodeBreadths(columns); + for (let i = 0; i < iterations; ++i) { + const alpha = Math.pow(0.99, i); + const beta = Math.max(1 - alpha, (i + 1) / iterations); + relaxRightToLeft(columns, alpha, beta); + relaxLeftToRight(columns, alpha, beta); + } + } + + // Reposition each node based on its incoming (target) links. + function relaxLeftToRight(columns, alpha, beta) { + for (let i = 1, n = columns.length; i < n; ++i) { + const column = columns[i]; + for (const target of column) { + let y = 0; + let w = 0; + for (const {source, value} of target.targetLinks) { + let v = value * (target.layer - source.layer); + y += targetTop(source, target) * v; + w += v; + } + if (!(w > 0)) continue; + let dy = (y / w - target.y0) * alpha; + target.y0 += dy; + target.y1 += dy; + reorderNodeLinks(target); + } + if (sort === undefined) column.sort(ascendingBreadth); + resolveCollisions(column, beta); + } + } + + // Reposition each node based on its outgoing (source) links. + function relaxRightToLeft(columns, alpha, beta) { + for (let n = columns.length, i = n - 2; i >= 0; --i) { + const column = columns[i]; + for (const source of column) { + let y = 0; + let w = 0; + for (const {target, value} of source.sourceLinks) { + let v = value * (target.layer - source.layer); + y += sourceTop(source, target) * v; + w += v; + } + if (!(w > 0)) continue; + let dy = (y / w - source.y0) * alpha; + source.y0 += dy; + source.y1 += dy; + reorderNodeLinks(source); + } + if (sort === undefined) column.sort(ascendingBreadth); + resolveCollisions(column, beta); + } + } + + function resolveCollisions(nodes, alpha) { + const i = nodes.length >> 1; + const subject = nodes[i]; + resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha); + resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha); + resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha); + resolveCollisionsTopToBottom(nodes, y0, 0, alpha); + } + + // Push any overlapping nodes down. + function resolveCollisionsTopToBottom(nodes, y, i, alpha) { + for (; i < nodes.length; ++i) { + const node = nodes[i]; + const dy = (y - node.y0) * alpha; + if (dy > 1e-6) node.y0 += dy, node.y1 += dy; + y = node.y1 + py; + } + } + + // Push any overlapping nodes up. + function resolveCollisionsBottomToTop(nodes, y, i, alpha) { + for (; i >= 0; --i) { + const node = nodes[i]; + const dy = (node.y1 - y) * alpha; + if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy; + y = node.y0 - py; + } + } + + function reorderNodeLinks({sourceLinks, targetLinks}) { + if (linkSort === undefined) { + for (const {source: {sourceLinks}} of targetLinks) { + sourceLinks.sort(ascendingTargetBreadth); + } + for (const {target: {targetLinks}} of sourceLinks) { + targetLinks.sort(ascendingSourceBreadth); + } + } + } + + function reorderLinks(nodes) { + if (linkSort === undefined) { + for (const {sourceLinks, targetLinks} of nodes) { + sourceLinks.sort(ascendingTargetBreadth); + targetLinks.sort(ascendingSourceBreadth); + } + } + } + + // Returns the target.y0 that would produce an ideal link from source to target. + function targetTop(source, target) { + let y = source.y0 - (source.sourceLinks.length - 1) * py / 2; + for (const {target: node, width} of source.sourceLinks) { + if (node === target) break; + y += width + py; + } + for (const {source: node, width} of target.targetLinks) { + if (node === source) break; + y -= width; + } + return y; + } + + // Returns the source.y0 that would produce an ideal link from source to target. + function sourceTop(source, target) { + let y = target.y0 - (target.targetLinks.length - 1) * py / 2; + for (const {source: node, width} of target.targetLinks) { + if (node === source) break; + y += width + py; + } + for (const {target: node, width} of source.sourceLinks) { + if (node === target) break; + y -= width; + } + return y; + } + + return sankey; +} + +var pi = Math.PI, + tau = 2 * pi, + epsilon = 1e-6, + tauEpsilon = tau - epsilon; + +function Path() { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; +} + +function path() { + return new Path; +} + +Path.prototype = path.prototype = { + constructor: Path, + moveTo: function(x, y) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y); + }, + closePath: function() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._ += "Z"; + } + }, + lineTo: function(x, y) { + this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y); + }, + quadraticCurveTo: function(x1, y1, x, y) { + this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { + this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + arcTo: function(x1, y1, x2, y2, r) { + x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; + var x0 = this._x1, + y0 = this._y1, + x21 = x2 - x1, + y21 = y2 - y1, + x01 = x0 - x1, + y01 = y0 - y1, + l01_2 = x01 * x01 + y01 * y01; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x1,y1). + if (this._x1 === null) { + this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Or, is (x1,y1) coincident with (x0,y0)? Do nothing. + else if (!(l01_2 > epsilon)); + + // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear? + // Equivalently, is (x1,y1) coincident with (x2,y2)? + // Or, is the radius zero? Line to (x1,y1). + else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) { + this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Otherwise, draw an arc! + else { + var x20 = x2 - x0, + y20 = y2 - y0, + l21_2 = x21 * x21 + y21 * y21, + l20_2 = x20 * x20 + y20 * y20, + l21 = Math.sqrt(l21_2), + l01 = Math.sqrt(l01_2), + l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), + t01 = l / l01, + t21 = l / l21; + + // If the start tangent is not coincident with (x0,y0), line to. + if (Math.abs(t01 - 1) > epsilon) { + this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01); + } + + this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21); + } + }, + arc: function(x, y, r, a0, a1, ccw) { + x = +x, y = +y, r = +r, ccw = !!ccw; + var dx = r * Math.cos(a0), + dy = r * Math.sin(a0), + x0 = x + dx, + y0 = y + dy, + cw = 1 ^ ccw, + da = ccw ? a0 - a1 : a1 - a0; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x0,y0). + if (this._x1 === null) { + this._ += "M" + x0 + "," + y0; + } + + // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). + else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) { + this._ += "L" + x0 + "," + y0; + } + + // Is this arc empty? We’re done. + if (!r) return; + + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau + tau; + + // Is this a complete circle? Draw two arcs to complete the circle. + if (da > tauEpsilon) { + this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0); + } + + // Is this arc non-empty? Draw an arc! + else if (da > epsilon) { + this._ += "A" + r + "," + r + ",0," + (+(da >= pi)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1)); + } + }, + rect: function(x, y, w, h) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z"; + }, + toString: function() { + return this._; + } +}; + +function constant(x) { + return function constant() { + return x; + }; +} + +function x(p) { + return p[0]; +} + +function y(p) { + return p[1]; +} + +var slice = Array.prototype.slice; + +function linkSource(d) { + return d.source; +} + +function linkTarget(d) { + return d.target; +} + +function link(curve) { + var source = linkSource, + target = linkTarget, + x$1 = x, + y$1 = y, + context = null; + + function link() { + var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv); + if (!context) context = buffer = path(); + curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv)); + if (buffer) return context = null, buffer + "" || null; + } + + link.source = function(_) { + return arguments.length ? (source = _, link) : source; + }; + + link.target = function(_) { + return arguments.length ? (target = _, link) : target; + }; + + link.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link) : x$1; + }; + + link.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link) : y$1; + }; + + link.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), link) : context; + }; + + return link; +} + +function curveHorizontal(context, x0, y0, x1, y1) { + context.moveTo(x0, y0); + context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1); +} + +function linkHorizontal() { + return link(curveHorizontal); +} + +function horizontalSource(d) { + return [d.source.x1, d.y0]; +} + +function horizontalTarget(d) { + return [d.target.x0, d.y1]; +} + +function sankeyLinkHorizontal() { + return linkHorizontal() + .source(horizontalSource) + .target(horizontalTarget); +} + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SANKEY": 4, "NEWLINE": 5, "csv": 6, "opt_eof": 7, "record": 8, "csv_tail": 9, "EOF": 10, "field[source]": 11, "COMMA": 12, "field[target]": 13, "field[value]": 14, "field": 15, "escaped": 16, "non_escaped": 17, "DQUOTE": 18, "ESCAPED_TEXT": 19, "NON_ESCAPED_TEXT": 20, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" }, + productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 7: + const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"')); + const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"')); + const value = parseFloat($$[$0].trim()); + yy.addLink(source, target, value); + break; + case 8: + case 9: + case 11: + this.$ = $$[$0]; + break; + case 10: + this.$ = $$[$0 - 1]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])], + defaultActions: { 11: [2, 1], 12: [2, 5] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.pushState("csv"); + return 4; + case 1: + return 10; + case 2: + return 5; + case 3: + return 12; + case 4: + this.pushState("escaped_text"); + return 18; + case 5: + return 20; + case 6: + this.popState("escaped_text"); + return 18; + case 7: + return 19; + } + }, + rules: [/^(?:sankey-beta\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i], + conditions: { "csv": { "rules": [1, 2, 3, 4, 5, 6, 7], "inclusive": false }, "escaped_text": { "rules": [6, 7], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let links = []; +let nodes = []; +let nodesMap = {}; +const clear = () => { + links = []; + nodes = []; + nodesMap = {}; + clear$1(); +}; +class SankeyLink { + constructor(source, target, value = 0) { + this.source = source; + this.target = target; + this.value = value; + } +} +const addLink = (source, target, value) => { + links.push(new SankeyLink(source, target, value)); +}; +class SankeyNode { + constructor(ID) { + this.ID = ID; + } +} +const findOrCreateNode = (ID) => { + ID = common$1.sanitizeText(ID, getConfig()); + if (!nodesMap[ID]) { + nodesMap[ID] = new SankeyNode(ID); + nodes.push(nodesMap[ID]); + } + return nodesMap[ID]; +}; +const getNodes = () => nodes; +const getLinks = () => links; +const getGraph = () => ({ + nodes: nodes.map((node) => ({ id: node.ID })), + links: links.map((link) => ({ + source: link.source.ID, + target: link.target.ID, + value: link.value + })) +}); +const db = { + nodesMap, + getConfig: () => getConfig().sankey, + getNodes, + getLinks, + getGraph, + addLink, + findOrCreateNode, + getAccTitle, + setAccTitle, + getAccDescription, + setAccDescription, + getDiagramTitle, + setDiagramTitle, + clear +}; +const _Uid = class _Uid2 { + static next(name) { + return new _Uid2(name + ++_Uid2.count); + } + constructor(id) { + this.id = id; + this.href = `#${id}`; + } + toString() { + return "url(" + this.href + ")"; + } +}; +_Uid.count = 0; +let Uid = _Uid; +const alignmentsMap = { + left: left, + right: right, + center: center, + justify: justify +}; +const draw = function(text, id, _version, diagObj) { + const { securityLevel, sankey: conf } = getConfig(); + const defaultSankeyConfig = defaultConfig.sankey; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const width = (conf == null ? void 0 : conf.width) ?? defaultSankeyConfig.width; + const height = (conf == null ? void 0 : conf.height) ?? defaultSankeyConfig.width; + const useMaxWidth = (conf == null ? void 0 : conf.useMaxWidth) ?? defaultSankeyConfig.useMaxWidth; + const nodeAlignment = (conf == null ? void 0 : conf.nodeAlignment) ?? defaultSankeyConfig.nodeAlignment; + const prefix = (conf == null ? void 0 : conf.prefix) ?? defaultSankeyConfig.prefix; + const suffix = (conf == null ? void 0 : conf.suffix) ?? defaultSankeyConfig.suffix; + const showValues = (conf == null ? void 0 : conf.showValues) ?? defaultSankeyConfig.showValues; + const graph = diagObj.db.getGraph(); + const nodeAlign = alignmentsMap[nodeAlignment]; + const nodeWidth = 10; + const sankey$1 = Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(10 + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([ + [0, 0], + [width, height] + ]); + sankey$1(graph); + const colorScheme = ordinal(schemeTableau10); + svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) { + return "translate(" + d.x0 + "," + d.y0 + ")"; + }).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => { + return d.y1 - d.y0; + }).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => colorScheme(d.id)); + const getText = ({ id: id2, value }) => { + if (!showValues) { + return id2; + } + return `${id2} +${prefix}${Math.round(value * 100) / 100}${suffix}`; + }; + svg.append("g").attr("class", "node-labels").attr("font-family", "sans-serif").attr("font-size", 14).selectAll("text").data(graph.nodes).join("text").attr("x", (d) => d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => d.x0 < width / 2 ? "start" : "end").text(getText); + const link = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply"); + const linkColor = (conf == null ? void 0 : conf.linkColor) || "gradient"; + if (linkColor === "gradient") { + const gradient = link.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0); + gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => colorScheme(d.source.id)); + gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => colorScheme(d.target.id)); + } + let coloring; + switch (linkColor) { + case "gradient": + coloring = (d) => d.uid; + break; + case "source": + coloring = (d) => colorScheme(d.source.id); + break; + case "target": + coloring = (d) => colorScheme(d.target.id); + break; + default: + coloring = linkColor; + } + link.append("path").attr("d", sankeyLinkHorizontal()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width)); + setupGraphViewbox$1(void 0, svg, 0, useMaxWidth); +}; +const renderer = { + draw +}; +const prepareTextForParsing = (text) => { + const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, "\n").trim(); + return textToParse; +}; +const originalParse = parser$1.parse.bind(parser$1); +parser$1.parse = (text) => originalParse(prepareTextForParsing(text)); +const diagram = { + parser: parser$1, + db, + renderer +}; + +export { diagram }; diff --git a/libs/marked/sankeyDiagram-707fac0f-RRYrH95D.js b/libs/marked/sankeyDiagram-707fac0f-RRYrH95D.js new file mode 100644 index 0000000..38a6ad5 --- /dev/null +++ b/libs/marked/sankeyDiagram-707fac0f-RRYrH95D.js @@ -0,0 +1,1320 @@ +import { c as getConfig, g as getAccTitle, s as setAccTitle, a as getAccDescription, b as setAccDescription, D as getDiagramTitle, C as setDiagramTitle, E as clear$1, j as common$1, aq as defaultConfig, h as select, t as setupGraphViewbox$1 } from './index-Bd_FDXSq.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { s as schemeTableau10 } from './Tableau10-CkeCzOvH.js'; +import './init-zpY4DTin.js'; + +function max(values, valueof) { + let max; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (max < value || (max === undefined && value >= value))) { + max = value; + } + } + } + return max; +} + +function min(values, valueof) { + let min; + if (valueof === undefined) { + for (const value of values) { + if (value != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } else { + let index = -1; + for (let value of values) { + if ((value = valueof(value, ++index, values)) != null + && (min > value || (min === undefined && value >= value))) { + min = value; + } + } + } + return min; +} + +function sum(values, valueof) { + let sum = 0; + if (valueof === undefined) { + for (let value of values) { + if (value = +value) { + sum += value; + } + } + } else { + let index = -1; + for (let value of values) { + if (value = +valueof(value, ++index, values)) { + sum += value; + } + } + } + return sum; +} + +function targetDepth(d) { + return d.target.depth; +} + +function left(node) { + return node.depth; +} + +function right(node, n) { + return n - 1 - node.height; +} + +function justify(node, n) { + return node.sourceLinks.length ? node.depth : n - 1; +} + +function center(node) { + return node.targetLinks.length ? node.depth + : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 + : 0; +} + +function constant$1(x) { + return function() { + return x; + }; +} + +function ascendingSourceBreadth(a, b) { + return ascendingBreadth(a.source, b.source) || a.index - b.index; +} + +function ascendingTargetBreadth(a, b) { + return ascendingBreadth(a.target, b.target) || a.index - b.index; +} + +function ascendingBreadth(a, b) { + return a.y0 - b.y0; +} + +function value(d) { + return d.value; +} + +function defaultId(d) { + return d.index; +} + +function defaultNodes(graph) { + return graph.nodes; +} + +function defaultLinks(graph) { + return graph.links; +} + +function find(nodeById, id) { + const node = nodeById.get(id); + if (!node) throw new Error("missing: " + id); + return node; +} + +function computeLinkBreadths({nodes}) { + for (const node of nodes) { + let y0 = node.y0; + let y1 = y0; + for (const link of node.sourceLinks) { + link.y0 = y0 + link.width / 2; + y0 += link.width; + } + for (const link of node.targetLinks) { + link.y1 = y1 + link.width / 2; + y1 += link.width; + } + } +} + +function Sankey() { + let x0 = 0, y0 = 0, x1 = 1, y1 = 1; // extent + let dx = 24; // nodeWidth + let dy = 8, py; // nodePadding + let id = defaultId; + let align = justify; + let sort; + let linkSort; + let nodes = defaultNodes; + let links = defaultLinks; + let iterations = 6; + + function sankey() { + const graph = {nodes: nodes.apply(null, arguments), links: links.apply(null, arguments)}; + computeNodeLinks(graph); + computeNodeValues(graph); + computeNodeDepths(graph); + computeNodeHeights(graph); + computeNodeBreadths(graph); + computeLinkBreadths(graph); + return graph; + } + + sankey.update = function(graph) { + computeLinkBreadths(graph); + return graph; + }; + + sankey.nodeId = function(_) { + return arguments.length ? (id = typeof _ === "function" ? _ : constant$1(_), sankey) : id; + }; + + sankey.nodeAlign = function(_) { + return arguments.length ? (align = typeof _ === "function" ? _ : constant$1(_), sankey) : align; + }; + + sankey.nodeSort = function(_) { + return arguments.length ? (sort = _, sankey) : sort; + }; + + sankey.nodeWidth = function(_) { + return arguments.length ? (dx = +_, sankey) : dx; + }; + + sankey.nodePadding = function(_) { + return arguments.length ? (dy = py = +_, sankey) : dy; + }; + + sankey.nodes = function(_) { + return arguments.length ? (nodes = typeof _ === "function" ? _ : constant$1(_), sankey) : nodes; + }; + + sankey.links = function(_) { + return arguments.length ? (links = typeof _ === "function" ? _ : constant$1(_), sankey) : links; + }; + + sankey.linkSort = function(_) { + return arguments.length ? (linkSort = _, sankey) : linkSort; + }; + + sankey.size = function(_) { + return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0]; + }; + + sankey.extent = function(_) { + return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]]; + }; + + sankey.iterations = function(_) { + return arguments.length ? (iterations = +_, sankey) : iterations; + }; + + function computeNodeLinks({nodes, links}) { + for (const [i, node] of nodes.entries()) { + node.index = i; + node.sourceLinks = []; + node.targetLinks = []; + } + const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d])); + for (const [i, link] of links.entries()) { + link.index = i; + let {source, target} = link; + if (typeof source !== "object") source = link.source = find(nodeById, source); + if (typeof target !== "object") target = link.target = find(nodeById, target); + source.sourceLinks.push(link); + target.targetLinks.push(link); + } + if (linkSort != null) { + for (const {sourceLinks, targetLinks} of nodes) { + sourceLinks.sort(linkSort); + targetLinks.sort(linkSort); + } + } + } + + function computeNodeValues({nodes}) { + for (const node of nodes) { + node.value = node.fixedValue === undefined + ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value)) + : node.fixedValue; + } + } + + function computeNodeDepths({nodes}) { + const n = nodes.length; + let current = new Set(nodes); + let next = new Set; + let x = 0; + while (current.size) { + for (const node of current) { + node.depth = x; + for (const {target} of node.sourceLinks) { + next.add(target); + } + } + if (++x > n) throw new Error("circular link"); + current = next; + next = new Set; + } + } + + function computeNodeHeights({nodes}) { + const n = nodes.length; + let current = new Set(nodes); + let next = new Set; + let x = 0; + while (current.size) { + for (const node of current) { + node.height = x; + for (const {source} of node.targetLinks) { + next.add(source); + } + } + if (++x > n) throw new Error("circular link"); + current = next; + next = new Set; + } + } + + function computeNodeLayers({nodes}) { + const x = max(nodes, d => d.depth) + 1; + const kx = (x1 - x0 - dx) / (x - 1); + const columns = new Array(x); + for (const node of nodes) { + const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x)))); + node.layer = i; + node.x0 = x0 + i * kx; + node.x1 = node.x0 + dx; + if (columns[i]) columns[i].push(node); + else columns[i] = [node]; + } + if (sort) for (const column of columns) { + column.sort(sort); + } + return columns; + } + + function initializeNodeBreadths(columns) { + const ky = min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum(c, value)); + for (const nodes of columns) { + let y = y0; + for (const node of nodes) { + node.y0 = y; + node.y1 = y + node.value * ky; + y = node.y1 + py; + for (const link of node.sourceLinks) { + link.width = link.value * ky; + } + } + y = (y1 - y + py) / (nodes.length + 1); + for (let i = 0; i < nodes.length; ++i) { + const node = nodes[i]; + node.y0 += y * (i + 1); + node.y1 += y * (i + 1); + } + reorderLinks(nodes); + } + } + + function computeNodeBreadths(graph) { + const columns = computeNodeLayers(graph); + py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1)); + initializeNodeBreadths(columns); + for (let i = 0; i < iterations; ++i) { + const alpha = Math.pow(0.99, i); + const beta = Math.max(1 - alpha, (i + 1) / iterations); + relaxRightToLeft(columns, alpha, beta); + relaxLeftToRight(columns, alpha, beta); + } + } + + // Reposition each node based on its incoming (target) links. + function relaxLeftToRight(columns, alpha, beta) { + for (let i = 1, n = columns.length; i < n; ++i) { + const column = columns[i]; + for (const target of column) { + let y = 0; + let w = 0; + for (const {source, value} of target.targetLinks) { + let v = value * (target.layer - source.layer); + y += targetTop(source, target) * v; + w += v; + } + if (!(w > 0)) continue; + let dy = (y / w - target.y0) * alpha; + target.y0 += dy; + target.y1 += dy; + reorderNodeLinks(target); + } + if (sort === undefined) column.sort(ascendingBreadth); + resolveCollisions(column, beta); + } + } + + // Reposition each node based on its outgoing (source) links. + function relaxRightToLeft(columns, alpha, beta) { + for (let n = columns.length, i = n - 2; i >= 0; --i) { + const column = columns[i]; + for (const source of column) { + let y = 0; + let w = 0; + for (const {target, value} of source.sourceLinks) { + let v = value * (target.layer - source.layer); + y += sourceTop(source, target) * v; + w += v; + } + if (!(w > 0)) continue; + let dy = (y / w - source.y0) * alpha; + source.y0 += dy; + source.y1 += dy; + reorderNodeLinks(source); + } + if (sort === undefined) column.sort(ascendingBreadth); + resolveCollisions(column, beta); + } + } + + function resolveCollisions(nodes, alpha) { + const i = nodes.length >> 1; + const subject = nodes[i]; + resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha); + resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha); + resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha); + resolveCollisionsTopToBottom(nodes, y0, 0, alpha); + } + + // Push any overlapping nodes down. + function resolveCollisionsTopToBottom(nodes, y, i, alpha) { + for (; i < nodes.length; ++i) { + const node = nodes[i]; + const dy = (y - node.y0) * alpha; + if (dy > 1e-6) node.y0 += dy, node.y1 += dy; + y = node.y1 + py; + } + } + + // Push any overlapping nodes up. + function resolveCollisionsBottomToTop(nodes, y, i, alpha) { + for (; i >= 0; --i) { + const node = nodes[i]; + const dy = (node.y1 - y) * alpha; + if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy; + y = node.y0 - py; + } + } + + function reorderNodeLinks({sourceLinks, targetLinks}) { + if (linkSort === undefined) { + for (const {source: {sourceLinks}} of targetLinks) { + sourceLinks.sort(ascendingTargetBreadth); + } + for (const {target: {targetLinks}} of sourceLinks) { + targetLinks.sort(ascendingSourceBreadth); + } + } + } + + function reorderLinks(nodes) { + if (linkSort === undefined) { + for (const {sourceLinks, targetLinks} of nodes) { + sourceLinks.sort(ascendingTargetBreadth); + targetLinks.sort(ascendingSourceBreadth); + } + } + } + + // Returns the target.y0 that would produce an ideal link from source to target. + function targetTop(source, target) { + let y = source.y0 - (source.sourceLinks.length - 1) * py / 2; + for (const {target: node, width} of source.sourceLinks) { + if (node === target) break; + y += width + py; + } + for (const {source: node, width} of target.targetLinks) { + if (node === source) break; + y -= width; + } + return y; + } + + // Returns the source.y0 that would produce an ideal link from source to target. + function sourceTop(source, target) { + let y = target.y0 - (target.targetLinks.length - 1) * py / 2; + for (const {source: node, width} of target.targetLinks) { + if (node === source) break; + y += width + py; + } + for (const {target: node, width} of source.sourceLinks) { + if (node === target) break; + y -= width; + } + return y; + } + + return sankey; +} + +var pi = Math.PI, + tau = 2 * pi, + epsilon = 1e-6, + tauEpsilon = tau - epsilon; + +function Path() { + this._x0 = this._y0 = // start of current subpath + this._x1 = this._y1 = null; // end of current subpath + this._ = ""; +} + +function path() { + return new Path; +} + +Path.prototype = path.prototype = { + constructor: Path, + moveTo: function(x, y) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y); + }, + closePath: function() { + if (this._x1 !== null) { + this._x1 = this._x0, this._y1 = this._y0; + this._ += "Z"; + } + }, + lineTo: function(x, y) { + this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y); + }, + quadraticCurveTo: function(x1, y1, x, y) { + this._ += "Q" + (+x1) + "," + (+y1) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + bezierCurveTo: function(x1, y1, x2, y2, x, y) { + this._ += "C" + (+x1) + "," + (+y1) + "," + (+x2) + "," + (+y2) + "," + (this._x1 = +x) + "," + (this._y1 = +y); + }, + arcTo: function(x1, y1, x2, y2, r) { + x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r; + var x0 = this._x1, + y0 = this._y1, + x21 = x2 - x1, + y21 = y2 - y1, + x01 = x0 - x1, + y01 = y0 - y1, + l01_2 = x01 * x01 + y01 * y01; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x1,y1). + if (this._x1 === null) { + this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Or, is (x1,y1) coincident with (x0,y0)? Do nothing. + else if (!(l01_2 > epsilon)); + + // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear? + // Equivalently, is (x1,y1) coincident with (x2,y2)? + // Or, is the radius zero? Line to (x1,y1). + else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) { + this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1); + } + + // Otherwise, draw an arc! + else { + var x20 = x2 - x0, + y20 = y2 - y0, + l21_2 = x21 * x21 + y21 * y21, + l20_2 = x20 * x20 + y20 * y20, + l21 = Math.sqrt(l21_2), + l01 = Math.sqrt(l01_2), + l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), + t01 = l / l01, + t21 = l / l21; + + // If the start tangent is not coincident with (x0,y0), line to. + if (Math.abs(t01 - 1) > epsilon) { + this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01); + } + + this._ += "A" + r + "," + r + ",0,0," + (+(y01 * x20 > x01 * y20)) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21); + } + }, + arc: function(x, y, r, a0, a1, ccw) { + x = +x, y = +y, r = +r, ccw = !!ccw; + var dx = r * Math.cos(a0), + dy = r * Math.sin(a0), + x0 = x + dx, + y0 = y + dy, + cw = 1 ^ ccw, + da = ccw ? a0 - a1 : a1 - a0; + + // Is the radius negative? Error. + if (r < 0) throw new Error("negative radius: " + r); + + // Is this path empty? Move to (x0,y0). + if (this._x1 === null) { + this._ += "M" + x0 + "," + y0; + } + + // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0). + else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) { + this._ += "L" + x0 + "," + y0; + } + + // Is this arc empty? We’re done. + if (!r) return; + + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau + tau; + + // Is this a complete circle? Draw two arcs to complete the circle. + if (da > tauEpsilon) { + this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0); + } + + // Is this arc non-empty? Draw an arc! + else if (da > epsilon) { + this._ += "A" + r + "," + r + ",0," + (+(da >= pi)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1)); + } + }, + rect: function(x, y, w, h) { + this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + (+w) + "v" + (+h) + "h" + (-w) + "Z"; + }, + toString: function() { + return this._; + } +}; + +function constant(x) { + return function constant() { + return x; + }; +} + +function x(p) { + return p[0]; +} + +function y(p) { + return p[1]; +} + +var slice = Array.prototype.slice; + +function linkSource(d) { + return d.source; +} + +function linkTarget(d) { + return d.target; +} + +function link(curve) { + var source = linkSource, + target = linkTarget, + x$1 = x, + y$1 = y, + context = null; + + function link() { + var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv); + if (!context) context = buffer = path(); + curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv)); + if (buffer) return context = null, buffer + "" || null; + } + + link.source = function(_) { + return arguments.length ? (source = _, link) : source; + }; + + link.target = function(_) { + return arguments.length ? (target = _, link) : target; + }; + + link.x = function(_) { + return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link) : x$1; + }; + + link.y = function(_) { + return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link) : y$1; + }; + + link.context = function(_) { + return arguments.length ? ((context = _ == null ? null : _), link) : context; + }; + + return link; +} + +function curveHorizontal(context, x0, y0, x1, y1) { + context.moveTo(x0, y0); + context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1); +} + +function linkHorizontal() { + return link(curveHorizontal); +} + +function horizontalSource(d) { + return [d.source.x1, d.y0]; +} + +function horizontalTarget(d) { + return [d.target.x0, d.y1]; +} + +function sankeyLinkHorizontal() { + return linkHorizontal() + .source(horizontalSource) + .target(horizontalTarget); +} + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SANKEY": 4, "NEWLINE": 5, "csv": 6, "opt_eof": 7, "record": 8, "csv_tail": 9, "EOF": 10, "field[source]": 11, "COMMA": 12, "field[target]": 13, "field[value]": 14, "field": 15, "escaped": 16, "non_escaped": 17, "DQUOTE": 18, "ESCAPED_TEXT": 19, "NON_ESCAPED_TEXT": 20, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" }, + productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 7: + const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"')); + const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"')); + const value = parseFloat($$[$0].trim()); + yy.addLink(source, target, value); + break; + case 8: + case 9: + case 11: + this.$ = $$[$0]; + break; + case 10: + this.$ = $$[$0 - 1]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])], + defaultActions: { 11: [2, 1], 12: [2, 5] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + this.pushState("csv"); + return 4; + case 1: + return 10; + case 2: + return 5; + case 3: + return 12; + case 4: + this.pushState("escaped_text"); + return 18; + case 5: + return 20; + case 6: + this.popState("escaped_text"); + return 18; + case 7: + return 19; + } + }, + rules: [/^(?:sankey-beta\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i], + conditions: { "csv": { "rules": [1, 2, 3, 4, 5, 6, 7], "inclusive": false }, "escaped_text": { "rules": [6, 7], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let links = []; +let nodes = []; +let nodesMap = {}; +const clear = () => { + links = []; + nodes = []; + nodesMap = {}; + clear$1(); +}; +class SankeyLink { + constructor(source, target, value = 0) { + this.source = source; + this.target = target; + this.value = value; + } +} +const addLink = (source, target, value) => { + links.push(new SankeyLink(source, target, value)); +}; +class SankeyNode { + constructor(ID) { + this.ID = ID; + } +} +const findOrCreateNode = (ID) => { + ID = common$1.sanitizeText(ID, getConfig()); + if (!nodesMap[ID]) { + nodesMap[ID] = new SankeyNode(ID); + nodes.push(nodesMap[ID]); + } + return nodesMap[ID]; +}; +const getNodes = () => nodes; +const getLinks = () => links; +const getGraph = () => ({ + nodes: nodes.map((node) => ({ id: node.ID })), + links: links.map((link) => ({ + source: link.source.ID, + target: link.target.ID, + value: link.value + })) +}); +const db = { + nodesMap, + getConfig: () => getConfig().sankey, + getNodes, + getLinks, + getGraph, + addLink, + findOrCreateNode, + getAccTitle, + setAccTitle, + getAccDescription, + setAccDescription, + getDiagramTitle, + setDiagramTitle, + clear +}; +const _Uid = class _Uid2 { + static next(name) { + return new _Uid2(name + ++_Uid2.count); + } + constructor(id) { + this.id = id; + this.href = `#${id}`; + } + toString() { + return "url(" + this.href + ")"; + } +}; +_Uid.count = 0; +let Uid = _Uid; +const alignmentsMap = { + left: left, + right: right, + center: center, + justify: justify +}; +const draw = function(text, id, _version, diagObj) { + const { securityLevel, sankey: conf } = getConfig(); + const defaultSankeyConfig = defaultConfig.sankey; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const width = (conf == null ? void 0 : conf.width) ?? defaultSankeyConfig.width; + const height = (conf == null ? void 0 : conf.height) ?? defaultSankeyConfig.width; + const useMaxWidth = (conf == null ? void 0 : conf.useMaxWidth) ?? defaultSankeyConfig.useMaxWidth; + const nodeAlignment = (conf == null ? void 0 : conf.nodeAlignment) ?? defaultSankeyConfig.nodeAlignment; + const prefix = (conf == null ? void 0 : conf.prefix) ?? defaultSankeyConfig.prefix; + const suffix = (conf == null ? void 0 : conf.suffix) ?? defaultSankeyConfig.suffix; + const showValues = (conf == null ? void 0 : conf.showValues) ?? defaultSankeyConfig.showValues; + const graph = diagObj.db.getGraph(); + const nodeAlign = alignmentsMap[nodeAlignment]; + const nodeWidth = 10; + const sankey$1 = Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(10 + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([ + [0, 0], + [width, height] + ]); + sankey$1(graph); + const colorScheme = ordinal(schemeTableau10); + svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) { + return "translate(" + d.x0 + "," + d.y0 + ")"; + }).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => { + return d.y1 - d.y0; + }).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => colorScheme(d.id)); + const getText = ({ id: id2, value }) => { + if (!showValues) { + return id2; + } + return `${id2} +${prefix}${Math.round(value * 100) / 100}${suffix}`; + }; + svg.append("g").attr("class", "node-labels").attr("font-family", "sans-serif").attr("font-size", 14).selectAll("text").data(graph.nodes).join("text").attr("x", (d) => d.x0 < width / 2 ? d.x1 + 6 : d.x0 - 6).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => d.x0 < width / 2 ? "start" : "end").text(getText); + const link = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply"); + const linkColor = (conf == null ? void 0 : conf.linkColor) || "gradient"; + if (linkColor === "gradient") { + const gradient = link.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0); + gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => colorScheme(d.source.id)); + gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => colorScheme(d.target.id)); + } + let coloring; + switch (linkColor) { + case "gradient": + coloring = (d) => d.uid; + break; + case "source": + coloring = (d) => colorScheme(d.source.id); + break; + case "target": + coloring = (d) => colorScheme(d.target.id); + break; + default: + coloring = linkColor; + } + link.append("path").attr("d", sankeyLinkHorizontal()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width)); + setupGraphViewbox$1(void 0, svg, 0, useMaxWidth); +}; +const renderer = { + draw +}; +const prepareTextForParsing = (text) => { + const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, "\n").trim(); + return textToParse; +}; +const originalParse = parser$1.parse.bind(parser$1); +parser$1.parse = (text) => originalParse(prepareTextForParsing(text)); +const diagram = { + parser: parser$1, + db, + renderer +}; + +export { diagram }; diff --git a/libs/marked/sequenceDiagram-6894f283-B41gUBOj.js b/libs/marked/sequenceDiagram-6894f283-B41gUBOj.js new file mode 100644 index 0000000..163f3fb --- /dev/null +++ b/libs/marked/sequenceDiagram-6894f283-B41gUBOj.js @@ -0,0 +1,3336 @@ +import { g as getAccTitle, D as getDiagramTitle, C as setDiagramTitle, c as getConfig, s as setAccTitle, b as setAccDescription, a as getAccDescription, E as clear$1, l as log$1, d as sanitizeText$2, j as common$1, e as assignWithDepth$1, h as select, i as configureSvgSize, A as utils, a4 as hasKatex, a5 as calculateMathMLDimensions, m as dist, r as renderKatex, _ as getConfig$1, Y as parseFontSize, a6 as ZERO_WIDTH_SPACE } from './index-CN3YjQ0n.js'; +import { d as drawRect$1, a as drawBackgroundRect$1, g as getNoteRect$1, b as getTextObj$1, c as drawEmbeddedImage, e as drawImage } from './svgDrawCommon-5e1cfd1d-BKN147IX.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 13], $V7 = [1, 14], $V8 = [1, 16], $V9 = [1, 17], $Va = [1, 18], $Vb = [1, 24], $Vc = [1, 25], $Vd = [1, 26], $Ve = [1, 27], $Vf = [1, 28], $Vg = [1, 29], $Vh = [1, 30], $Vi = [1, 31], $Vj = [1, 32], $Vk = [1, 33], $Vl = [1, 34], $Vm = [1, 35], $Vn = [1, 36], $Vo = [1, 37], $Vp = [1, 38], $Vq = [1, 39], $Vr = [1, 41], $Vs = [1, 42], $Vt = [1, 43], $Vu = [1, 44], $Vv = [1, 45], $Vw = [1, 46], $Vx = [1, 4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], $Vy = [4, 5, 16, 50, 52, 53], $Vz = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VA = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VB = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 48, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VC = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VD = [68, 69, 70], $VE = [1, 120]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SPACE": 4, "NEWLINE": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "box_section": 10, "box_line": 11, "participant_statement": 12, "create": 13, "box": 14, "restOfLine": 15, "end": 16, "signal": 17, "autonumber": 18, "NUM": 19, "off": 20, "activate": 21, "actor": 22, "deactivate": 23, "note_statement": 24, "links_statement": 25, "link_statement": 26, "properties_statement": 27, "details_statement": 28, "title": 29, "legacy_title": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "loop": 36, "rect": 37, "opt": 38, "alt": 39, "else_sections": 40, "par": 41, "par_sections": 42, "par_over": 43, "critical": 44, "option_sections": 45, "break": 46, "option": 47, "and": 48, "else": 49, "participant": 50, "AS": 51, "participant_actor": 52, "destroy": 53, "note": 54, "placement": 55, "text2": 56, "over": 57, "actor_pair": 58, "links": 59, "link": 60, "properties": 61, "details": 62, "spaceList": 63, ",": 64, "left_of": 65, "right_of": 66, "signaltype": 67, "+": 68, "-": 69, "ACTOR": 70, "SOLID_OPEN_ARROW": 71, "DOTTED_OPEN_ARROW": 72, "SOLID_ARROW": 73, "DOTTED_ARROW": 74, "SOLID_CROSS": 75, "DOTTED_CROSS": 76, "SOLID_POINT": 77, "DOTTED_POINT": 78, "TXT": 79, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 6: "SD", 13: "create", 14: "box", 15: "restOfLine", 16: "end", 18: "autonumber", 19: "NUM", 20: "off", 21: "activate", 23: "deactivate", 29: "title", 30: "legacy_title", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 36: "loop", 37: "rect", 38: "opt", 39: "alt", 41: "par", 43: "par_over", 44: "critical", 46: "break", 47: "option", 48: "and", 49: "else", 50: "participant", 51: "AS", 52: "participant_actor", 53: "destroy", 54: "note", 57: "over", 59: "links", 60: "link", 61: "properties", 62: "details", 64: ",", 65: "left_of", 66: "right_of", 68: "+", 69: "-", 70: "ACTOR", 71: "SOLID_OPEN_ARROW", 72: "DOTTED_OPEN_ARROW", 73: "SOLID_ARROW", 74: "DOTTED_ARROW", 75: "SOLID_CROSS", 76: "DOTTED_CROSS", 77: "SOLID_POINT", 78: "DOTTED_POINT", 79: "TXT" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [10, 0], [10, 2], [11, 2], [11, 1], [11, 1], [9, 1], [9, 2], [9, 4], [9, 2], [9, 4], [9, 3], [9, 3], [9, 2], [9, 3], [9, 3], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [45, 1], [45, 4], [42, 1], [42, 4], [40, 1], [40, 4], [12, 5], [12, 3], [12, 5], [12, 3], [12, 3], [24, 4], [24, 4], [25, 3], [26, 3], [27, 3], [28, 3], [63, 2], [63, 1], [58, 3], [58, 1], [55, 1], [55, 1], [17, 5], [17, 5], [17, 4], [22, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [56, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.apply($$[$0]); + return $$[$0]; + case 4: + case 9: + this.$ = []; + break; + case 5: + case 10: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 6: + case 7: + case 11: + case 12: + this.$ = $$[$0]; + break; + case 8: + case 13: + this.$ = []; + break; + case 15: + $$[$0].type = "createParticipant"; + this.$ = $$[$0]; + break; + case 16: + $$[$0 - 1].unshift({ type: "boxStart", boxData: yy.parseBoxData($$[$0 - 2]) }); + $$[$0 - 1].push({ type: "boxEnd", boxText: $$[$0 - 2] }); + this.$ = $$[$0 - 1]; + break; + case 18: + this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 2]), sequenceIndexStep: Number($$[$0 - 1]), sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 19: + this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 1]), sequenceIndexStep: 1, sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 20: + this.$ = { type: "sequenceIndex", sequenceVisible: false, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 21: + this.$ = { type: "sequenceIndex", sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 22: + this.$ = { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] }; + break; + case 23: + this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1] }; + break; + case 29: + yy.setDiagramTitle($$[$0].substring(6)); + this.$ = $$[$0].substring(6); + break; + case 30: + yy.setDiagramTitle($$[$0].substring(7)); + this.$ = $$[$0].substring(7); + break; + case 31: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 32: + case 33: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 34: + $$[$0 - 1].unshift({ type: "loopStart", loopText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.LOOP_START }); + $$[$0 - 1].push({ type: "loopEnd", loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END }); + this.$ = $$[$0 - 1]; + break; + case 35: + $$[$0 - 1].unshift({ type: "rectStart", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_START }); + $$[$0 - 1].push({ type: "rectEnd", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_END }); + this.$ = $$[$0 - 1]; + break; + case 36: + $$[$0 - 1].unshift({ type: "optStart", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_START }); + $$[$0 - 1].push({ type: "optEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_END }); + this.$ = $$[$0 - 1]; + break; + case 37: + $$[$0 - 1].unshift({ type: "altStart", altText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.ALT_START }); + $$[$0 - 1].push({ type: "altEnd", signalType: yy.LINETYPE.ALT_END }); + this.$ = $$[$0 - 1]; + break; + case 38: + $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_START }); + $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END }); + this.$ = $$[$0 - 1]; + break; + case 39: + $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_OVER_START }); + $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END }); + this.$ = $$[$0 - 1]; + break; + case 40: + $$[$0 - 1].unshift({ type: "criticalStart", criticalText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.CRITICAL_START }); + $$[$0 - 1].push({ type: "criticalEnd", signalType: yy.LINETYPE.CRITICAL_END }); + this.$ = $$[$0 - 1]; + break; + case 41: + $$[$0 - 1].unshift({ type: "breakStart", breakText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_START }); + $$[$0 - 1].push({ type: "breakEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_END }); + this.$ = $$[$0 - 1]; + break; + case 43: + this.$ = $$[$0 - 3].concat([{ type: "option", optionText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.CRITICAL_OPTION }, $$[$0]]); + break; + case 45: + this.$ = $$[$0 - 3].concat([{ type: "and", parText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.PAR_AND }, $$[$0]]); + break; + case 47: + this.$ = $$[$0 - 3].concat([{ type: "else", altText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.ALT_ELSE }, $$[$0]]); + break; + case 48: + $$[$0 - 3].draw = "participant"; + $$[$0 - 3].type = "addParticipant"; + $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]); + this.$ = $$[$0 - 3]; + break; + case 49: + $$[$0 - 1].draw = "participant"; + $$[$0 - 1].type = "addParticipant"; + this.$ = $$[$0 - 1]; + break; + case 50: + $$[$0 - 3].draw = "actor"; + $$[$0 - 3].type = "addParticipant"; + $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]); + this.$ = $$[$0 - 3]; + break; + case 51: + $$[$0 - 1].draw = "actor"; + $$[$0 - 1].type = "addParticipant"; + this.$ = $$[$0 - 1]; + break; + case 52: + $$[$0 - 1].type = "destroyParticipant"; + this.$ = $$[$0 - 1]; + break; + case 53: + this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 54: + $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2); + $$[$0 - 2][0] = $$[$0 - 2][0].actor; + $$[$0 - 2][1] = $$[$0 - 2][1].actor; + this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }]; + break; + case 55: + this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 56: + this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 57: + this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 58: + this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 61: + this.$ = [$$[$0 - 2], $$[$0]]; + break; + case 62: + this.$ = $$[$0]; + break; + case 63: + this.$ = yy.PLACEMENT.LEFTOF; + break; + case 64: + this.$ = yy.PLACEMENT.RIGHTOF; + break; + case 65: + this.$ = [ + $$[$0 - 4], + $$[$0 - 1], + { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0], activate: true }, + { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] } + ]; + break; + case 66: + this.$ = [ + $$[$0 - 4], + $$[$0 - 1], + { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] }, + { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4] } + ]; + break; + case 67: + this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }]; + break; + case 68: + this.$ = { type: "addParticipant", actor: $$[$0] }; + break; + case 69: + this.$ = yy.LINETYPE.SOLID_OPEN; + break; + case 70: + this.$ = yy.LINETYPE.DOTTED_OPEN; + break; + case 71: + this.$ = yy.LINETYPE.SOLID; + break; + case 72: + this.$ = yy.LINETYPE.DOTTED; + break; + case 73: + this.$ = yy.LINETYPE.SOLID_CROSS; + break; + case 74: + this.$ = yy.LINETYPE.DOTTED_CROSS; + break; + case 75: + this.$ = yy.LINETYPE.SOLID_POINT; + break; + case 76: + this.$ = yy.LINETYPE.DOTTED_POINT; + break; + case 77: + this.$ = yy.parseMessage($$[$0].trim().substring(1)); + break; + } + }, + table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 13, 14, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, o($Vx, [2, 5]), { 9: 47, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, o($Vx, [2, 7]), o($Vx, [2, 8]), o($Vx, [2, 14]), { 12: 48, 50: $Vo, 52: $Vp, 53: $Vq }, { 15: [1, 49] }, { 5: [1, 50] }, { 5: [1, 53], 19: [1, 51], 20: [1, 52] }, { 22: 54, 70: $Vw }, { 22: 55, 70: $Vw }, { 5: [1, 56] }, { 5: [1, 57] }, { 5: [1, 58] }, { 5: [1, 59] }, { 5: [1, 60] }, o($Vx, [2, 29]), o($Vx, [2, 30]), { 32: [1, 61] }, { 34: [1, 62] }, o($Vx, [2, 33]), { 15: [1, 63] }, { 15: [1, 64] }, { 15: [1, 65] }, { 15: [1, 66] }, { 15: [1, 67] }, { 15: [1, 68] }, { 15: [1, 69] }, { 15: [1, 70] }, { 22: 71, 70: $Vw }, { 22: 72, 70: $Vw }, { 22: 73, 70: $Vw }, { 67: 74, 71: [1, 75], 72: [1, 76], 73: [1, 77], 74: [1, 78], 75: [1, 79], 76: [1, 80], 77: [1, 81], 78: [1, 82] }, { 55: 83, 57: [1, 84], 65: [1, 85], 66: [1, 86] }, { 22: 87, 70: $Vw }, { 22: 88, 70: $Vw }, { 22: 89, 70: $Vw }, { 22: 90, 70: $Vw }, o([5, 51, 64, 71, 72, 73, 74, 75, 76, 77, 78, 79], [2, 68]), o($Vx, [2, 6]), o($Vx, [2, 15]), o($Vy, [2, 9], { 10: 91 }), o($Vx, [2, 17]), { 5: [1, 93], 19: [1, 92] }, { 5: [1, 94] }, o($Vx, [2, 21]), { 5: [1, 95] }, { 5: [1, 96] }, o($Vx, [2, 24]), o($Vx, [2, 25]), o($Vx, [2, 26]), o($Vx, [2, 27]), o($Vx, [2, 28]), o($Vx, [2, 31]), o($Vx, [2, 32]), o($Vz, $V3, { 7: 97 }), o($Vz, $V3, { 7: 98 }), o($Vz, $V3, { 7: 99 }), o($VA, $V3, { 40: 100, 7: 101 }), o($VB, $V3, { 42: 102, 7: 103 }), o($VB, $V3, { 7: 103, 42: 104 }), o($VC, $V3, { 45: 105, 7: 106 }), o($Vz, $V3, { 7: 107 }), { 5: [1, 109], 51: [1, 108] }, { 5: [1, 111], 51: [1, 110] }, { 5: [1, 112] }, { 22: 115, 68: [1, 113], 69: [1, 114], 70: $Vw }, o($VD, [2, 69]), o($VD, [2, 70]), o($VD, [2, 71]), o($VD, [2, 72]), o($VD, [2, 73]), o($VD, [2, 74]), o($VD, [2, 75]), o($VD, [2, 76]), { 22: 116, 70: $Vw }, { 22: 118, 58: 117, 70: $Vw }, { 70: [2, 63] }, { 70: [2, 64] }, { 56: 119, 79: $VE }, { 56: 121, 79: $VE }, { 56: 122, 79: $VE }, { 56: 123, 79: $VE }, { 4: [1, 126], 5: [1, 128], 11: 125, 12: 127, 16: [1, 124], 50: $Vo, 52: $Vp, 53: $Vq }, { 5: [1, 129] }, o($Vx, [2, 19]), o($Vx, [2, 20]), o($Vx, [2, 22]), o($Vx, [2, 23]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 130], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 131], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 132], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 133] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 46], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 49: [1, 134], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 135] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 44], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 48: [1, 136], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 137] }, { 16: [1, 138] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 42], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 47: [1, 139], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 140], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 15: [1, 141] }, o($Vx, [2, 49]), { 15: [1, 142] }, o($Vx, [2, 51]), o($Vx, [2, 52]), { 22: 143, 70: $Vw }, { 22: 144, 70: $Vw }, { 56: 145, 79: $VE }, { 56: 146, 79: $VE }, { 56: 147, 79: $VE }, { 64: [1, 148], 79: [2, 62] }, { 5: [2, 55] }, { 5: [2, 77] }, { 5: [2, 56] }, { 5: [2, 57] }, { 5: [2, 58] }, o($Vx, [2, 16]), o($Vy, [2, 10]), { 12: 149, 50: $Vo, 52: $Vp, 53: $Vq }, o($Vy, [2, 12]), o($Vy, [2, 13]), o($Vx, [2, 18]), o($Vx, [2, 34]), o($Vx, [2, 35]), o($Vx, [2, 36]), o($Vx, [2, 37]), { 15: [1, 150] }, o($Vx, [2, 38]), { 15: [1, 151] }, o($Vx, [2, 39]), o($Vx, [2, 40]), { 15: [1, 152] }, o($Vx, [2, 41]), { 5: [1, 153] }, { 5: [1, 154] }, { 56: 155, 79: $VE }, { 56: 156, 79: $VE }, { 5: [2, 67] }, { 5: [2, 53] }, { 5: [2, 54] }, { 22: 157, 70: $Vw }, o($Vy, [2, 11]), o($VA, $V3, { 7: 101, 40: 158 }), o($VB, $V3, { 7: 103, 42: 159 }), o($VC, $V3, { 7: 106, 45: 160 }), o($Vx, [2, 48]), o($Vx, [2, 50]), { 5: [2, 65] }, { 5: [2, 66] }, { 79: [2, 61] }, { 16: [2, 47] }, { 16: [2, 45] }, { 16: [2, 43] }], + defaultActions: { 5: [2, 1], 6: [2, 2], 85: [2, 63], 86: [2, 64], 119: [2, 55], 120: [2, 77], 121: [2, 56], 122: [2, 57], 123: [2, 58], 145: [2, 67], 146: [2, 53], 147: [2, 54], 155: [2, 65], 156: [2, 66], 157: [2, 61], 158: [2, 47], 159: [2, 45], 160: [2, 43] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state2, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state2 = stack[stack.length - 1]; + if (this.defaultActions[state2]) { + action = this.defaultActions[state2]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state2] && table[state2][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state2]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state2 + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 5; + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + return 19; + case 7: + this.begin("LINE"); + return 14; + case 8: + this.begin("ID"); + return 50; + case 9: + this.begin("ID"); + return 52; + case 10: + return 13; + case 11: + this.begin("ID"); + return 53; + case 12: + yy_.yytext = yy_.yytext.trim(); + this.begin("ALIAS"); + return 70; + case 13: + this.popState(); + this.popState(); + this.begin("LINE"); + return 51; + case 14: + this.popState(); + this.popState(); + return 5; + case 15: + this.begin("LINE"); + return 36; + case 16: + this.begin("LINE"); + return 37; + case 17: + this.begin("LINE"); + return 38; + case 18: + this.begin("LINE"); + return 39; + case 19: + this.begin("LINE"); + return 49; + case 20: + this.begin("LINE"); + return 41; + case 21: + this.begin("LINE"); + return 43; + case 22: + this.begin("LINE"); + return 48; + case 23: + this.begin("LINE"); + return 44; + case 24: + this.begin("LINE"); + return 47; + case 25: + this.begin("LINE"); + return 46; + case 26: + this.popState(); + return 15; + case 27: + return 16; + case 28: + return 65; + case 29: + return 66; + case 30: + return 59; + case 31: + return 60; + case 32: + return 61; + case 33: + return 62; + case 34: + return 57; + case 35: + return 54; + case 36: + this.begin("ID"); + return 21; + case 37: + this.begin("ID"); + return 23; + case 38: + return 29; + case 39: + return 30; + case 40: + this.begin("acc_title"); + return 31; + case 41: + this.popState(); + return "acc_title_value"; + case 42: + this.begin("acc_descr"); + return 33; + case 43: + this.popState(); + return "acc_descr_value"; + case 44: + this.begin("acc_descr_multiline"); + break; + case 45: + this.popState(); + break; + case 46: + return "acc_descr_multiline_value"; + case 47: + return 6; + case 48: + return 18; + case 49: + return 20; + case 50: + return 64; + case 51: + return 5; + case 52: + yy_.yytext = yy_.yytext.trim(); + return 70; + case 53: + return 73; + case 54: + return 74; + case 55: + return 71; + case 56: + return 72; + case 57: + return 75; + case 58: + return 76; + case 59: + return 77; + case 60: + return 78; + case 61: + return 79; + case 62: + return 68; + case 63: + return 69; + case 64: + return 5; + case 65: + return "INVALID"; + } + }, + rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \n]+))/i, /^(?:box\b)/i, /^(?:participant\b)/i, /^(?:actor\b)/i, /^(?:create\b)/i, /^(?:destroy\b)/i, /^(?:[^\->:\n,;]+?([\-]*[^\->:\n,;]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:rect\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:par_over\b)/i, /^(?:and\b)/i, /^(?:critical\b)/i, /^(?:option\b)/i, /^(?:break\b)/i, /^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:links\b)/i, /^(?:link\b)/i, /^(?:properties\b)/i, /^(?:details\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:title:\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:sequenceDiagram\b)/i, /^(?:autonumber\b)/i, /^(?:off\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^\+\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+\->:\n,;]+)*)/i, /^(?:->>)/i, /^(?:-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [45, 46], "inclusive": false }, "acc_descr": { "rules": [43], "inclusive": false }, "acc_title": { "rules": [41], "inclusive": false }, "ID": { "rules": [2, 3, 12], "inclusive": false }, "ALIAS": { "rules": [2, 3, 13, 14], "inclusive": false }, "LINE": { "rules": [2, 3, 26], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +class ImperativeState { + /** + * @param init - Function that creates the default state. + */ + constructor(init) { + this.init = init; + this.records = this.init(); + } + reset() { + this.records = this.init(); + } +} +const state = new ImperativeState(() => ({ + prevActor: void 0, + actors: {}, + createdActors: {}, + destroyedActors: {}, + boxes: [], + messages: [], + notes: [], + sequenceNumbersEnabled: false, + wrapEnabled: void 0, + currentBox: void 0, + lastCreated: void 0, + lastDestroyed: void 0 +})); +const addBox = function(data) { + state.records.boxes.push({ + name: data.text, + wrap: data.wrap === void 0 && autoWrap() || !!data.wrap, + fill: data.color, + actorKeys: [] + }); + state.records.currentBox = state.records.boxes.slice(-1)[0]; +}; +const addActor = function(id, name, description, type) { + let assignedBox = state.records.currentBox; + const old = state.records.actors[id]; + if (old) { + if (state.records.currentBox && old.box && state.records.currentBox !== old.box) { + throw new Error( + "A same participant should only be defined in one Box: " + old.name + " can't be in '" + old.box.name + "' and in '" + state.records.currentBox.name + "' at the same time." + ); + } + assignedBox = old.box ? old.box : state.records.currentBox; + old.box = assignedBox; + if (old && name === old.name && description == null) { + return; + } + } + if (description == null || description.text == null) { + description = { text: name, wrap: null, type }; + } + if (type == null || description.text == null) { + description = { text: name, wrap: null, type }; + } + state.records.actors[id] = { + box: assignedBox, + name, + description: description.text, + wrap: description.wrap === void 0 && autoWrap() || !!description.wrap, + prevActor: state.records.prevActor, + links: {}, + properties: {}, + actorCnt: null, + rectData: null, + type: type || "participant" + }; + if (state.records.prevActor && state.records.actors[state.records.prevActor]) { + state.records.actors[state.records.prevActor].nextActor = id; + } + if (state.records.currentBox) { + state.records.currentBox.actorKeys.push(id); + } + state.records.prevActor = id; +}; +const activationCount = (part) => { + let i; + let count = 0; + for (i = 0; i < state.records.messages.length; i++) { + if (state.records.messages[i].type === LINETYPE.ACTIVE_START && state.records.messages[i].from.actor === part) { + count++; + } + if (state.records.messages[i].type === LINETYPE.ACTIVE_END && state.records.messages[i].from.actor === part) { + count--; + } + } + return count; +}; +const addMessage = function(idFrom, idTo, message, answer) { + state.records.messages.push({ + from: idFrom, + to: idTo, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + answer + }); +}; +const addSignal = function(idFrom, idTo, message = { text: void 0, wrap: void 0 }, messageType, activate = false) { + if (messageType === LINETYPE.ACTIVE_END) { + const cnt = activationCount(idFrom.actor); + if (cnt < 1) { + let error = new Error("Trying to inactivate an inactive participant (" + idFrom.actor + ")"); + error.hash = { + text: "->>-", + token: "->>-", + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["'ACTIVE_PARTICIPANT'"] + }; + throw error; + } + } + state.records.messages.push({ + from: idFrom, + to: idTo, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + type: messageType, + activate + }); + return true; +}; +const hasAtLeastOneBox = function() { + return state.records.boxes.length > 0; +}; +const hasAtLeastOneBoxWithTitle = function() { + return state.records.boxes.some((b) => b.name); +}; +const getMessages = function() { + return state.records.messages; +}; +const getBoxes = function() { + return state.records.boxes; +}; +const getActors = function() { + return state.records.actors; +}; +const getCreatedActors = function() { + return state.records.createdActors; +}; +const getDestroyedActors = function() { + return state.records.destroyedActors; +}; +const getActor = function(id) { + return state.records.actors[id]; +}; +const getActorKeys = function() { + return Object.keys(state.records.actors); +}; +const enableSequenceNumbers = function() { + state.records.sequenceNumbersEnabled = true; +}; +const disableSequenceNumbers = function() { + state.records.sequenceNumbersEnabled = false; +}; +const showSequenceNumbers = () => state.records.sequenceNumbersEnabled; +const setWrap = function(wrapSetting) { + state.records.wrapEnabled = wrapSetting; +}; +const autoWrap = () => { + if (state.records.wrapEnabled !== void 0) { + return state.records.wrapEnabled; + } + return getConfig().sequence.wrap; +}; +const clear = function() { + state.reset(); + clear$1(); +}; +const parseMessage = function(str) { + const _str = str.trim(); + const message = { + text: _str.replace(/^:?(?:no)?wrap:/, "").trim(), + wrap: _str.match(/^:?wrap:/) !== null ? true : _str.match(/^:?nowrap:/) !== null ? false : void 0 + }; + log$1.debug("parseMessage:", message); + return message; +}; +const parseBoxData = function(str) { + const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/); + let color = match != null && match[1] ? match[1].trim() : "transparent"; + let title = match != null && match[2] ? match[2].trim() : void 0; + if (window && window.CSS) { + if (!window.CSS.supports("color", color)) { + color = "transparent"; + title = str.trim(); + } + } else { + const style = new Option().style; + style.color = color; + if (style.color !== color) { + color = "transparent"; + title = str.trim(); + } + } + return { + color, + text: title !== void 0 ? sanitizeText$2(title.replace(/^:?(?:no)?wrap:/, ""), getConfig()) : void 0, + wrap: title !== void 0 ? title.match(/^:?wrap:/) !== null ? true : title.match(/^:?nowrap:/) !== null ? false : void 0 : void 0 + }; +}; +const LINETYPE = { + SOLID: 0, + DOTTED: 1, + NOTE: 2, + SOLID_CROSS: 3, + DOTTED_CROSS: 4, + SOLID_OPEN: 5, + DOTTED_OPEN: 6, + LOOP_START: 10, + LOOP_END: 11, + ALT_START: 12, + ALT_ELSE: 13, + ALT_END: 14, + OPT_START: 15, + OPT_END: 16, + ACTIVE_START: 17, + ACTIVE_END: 18, + PAR_START: 19, + PAR_AND: 20, + PAR_END: 21, + RECT_START: 22, + RECT_END: 23, + SOLID_POINT: 24, + DOTTED_POINT: 25, + AUTONUMBER: 26, + CRITICAL_START: 27, + CRITICAL_OPTION: 28, + CRITICAL_END: 29, + BREAK_START: 30, + BREAK_END: 31, + PAR_OVER_START: 32 +}; +const ARROWTYPE = { + FILLED: 0, + OPEN: 1 +}; +const PLACEMENT = { + LEFTOF: 0, + RIGHTOF: 1, + OVER: 2 +}; +const addNote = function(actor, placement, message) { + const note = { + actor, + placement, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap + }; + const actors = [].concat(actor, actor); + state.records.notes.push(note); + state.records.messages.push({ + from: actors[0], + to: actors[1], + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + type: LINETYPE.NOTE, + placement + }); +}; +const addLinks = function(actorId, text) { + const actor = getActor(actorId); + try { + let sanitizedText = sanitizeText$2(text.text, getConfig()); + sanitizedText = sanitizedText.replace(/&/g, "&"); + sanitizedText = sanitizedText.replace(/=/g, "="); + const links = JSON.parse(sanitizedText); + insertLinks(actor, links); + } catch (e) { + log$1.error("error while parsing actor link text", e); + } +}; +const addALink = function(actorId, text) { + const actor = getActor(actorId); + try { + const links = {}; + let sanitizedText = sanitizeText$2(text.text, getConfig()); + var sep = sanitizedText.indexOf("@"); + sanitizedText = sanitizedText.replace(/&/g, "&"); + sanitizedText = sanitizedText.replace(/=/g, "="); + var label = sanitizedText.slice(0, sep - 1).trim(); + var link = sanitizedText.slice(sep + 1).trim(); + links[label] = link; + insertLinks(actor, links); + } catch (e) { + log$1.error("error while parsing actor link text", e); + } +}; +function insertLinks(actor, links) { + if (actor.links == null) { + actor.links = links; + } else { + for (let key in links) { + actor.links[key] = links[key]; + } + } +} +const addProperties = function(actorId, text) { + const actor = getActor(actorId); + try { + let sanitizedText = sanitizeText$2(text.text, getConfig()); + const properties = JSON.parse(sanitizedText); + insertProperties(actor, properties); + } catch (e) { + log$1.error("error while parsing actor properties text", e); + } +}; +function insertProperties(actor, properties) { + if (actor.properties == null) { + actor.properties = properties; + } else { + for (let key in properties) { + actor.properties[key] = properties[key]; + } + } +} +function boxEnd() { + state.records.currentBox = void 0; +} +const addDetails = function(actorId, text) { + const actor = getActor(actorId); + const elem = document.getElementById(text.text); + try { + const text2 = elem.innerHTML; + const details = JSON.parse(text2); + if (details["properties"]) { + insertProperties(actor, details["properties"]); + } + if (details["links"]) { + insertLinks(actor, details["links"]); + } + } catch (e) { + log$1.error("error while parsing actor details text", e); + } +}; +const getActorProperty = function(actor, key) { + if (actor !== void 0 && actor.properties !== void 0) { + return actor.properties[key]; + } + return void 0; +}; +const apply = function(param) { + if (Array.isArray(param)) { + param.forEach(function(item) { + apply(item); + }); + } else { + switch (param.type) { + case "sequenceIndex": + state.records.messages.push({ + from: void 0, + to: void 0, + message: { + start: param.sequenceIndex, + step: param.sequenceIndexStep, + visible: param.sequenceVisible + }, + wrap: false, + type: param.signalType + }); + break; + case "addParticipant": + addActor(param.actor, param.actor, param.description, param.draw); + break; + case "createParticipant": + if (state.records.actors[param.actor]) { + throw new Error( + "It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior" + ); + } + state.records.lastCreated = param.actor; + addActor(param.actor, param.actor, param.description, param.draw); + state.records.createdActors[param.actor] = state.records.messages.length; + break; + case "destroyParticipant": + state.records.lastDestroyed = param.actor; + state.records.destroyedActors[param.actor] = state.records.messages.length; + break; + case "activeStart": + addSignal(param.actor, void 0, void 0, param.signalType); + break; + case "activeEnd": + addSignal(param.actor, void 0, void 0, param.signalType); + break; + case "addNote": + addNote(param.actor, param.placement, param.text); + break; + case "addLinks": + addLinks(param.actor, param.text); + break; + case "addALink": + addALink(param.actor, param.text); + break; + case "addProperties": + addProperties(param.actor, param.text); + break; + case "addDetails": + addDetails(param.actor, param.text); + break; + case "addMessage": + if (state.records.lastCreated) { + if (param.to !== state.records.lastCreated) { + throw new Error( + "The created participant " + state.records.lastCreated + " does not have an associated creating message after its declaration. Please check the sequence diagram." + ); + } else { + state.records.lastCreated = void 0; + } + } else if (state.records.lastDestroyed) { + if (param.to !== state.records.lastDestroyed && param.from !== state.records.lastDestroyed) { + throw new Error( + "The destroyed participant " + state.records.lastDestroyed + " does not have an associated destroying message after its declaration. Please check the sequence diagram." + ); + } else { + state.records.lastDestroyed = void 0; + } + } + addSignal(param.from, param.to, param.msg, param.signalType, param.activate); + break; + case "boxStart": + addBox(param.boxData); + break; + case "boxEnd": + boxEnd(); + break; + case "loopStart": + addSignal(void 0, void 0, param.loopText, param.signalType); + break; + case "loopEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "rectStart": + addSignal(void 0, void 0, param.color, param.signalType); + break; + case "rectEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "optStart": + addSignal(void 0, void 0, param.optText, param.signalType); + break; + case "optEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "altStart": + addSignal(void 0, void 0, param.altText, param.signalType); + break; + case "else": + addSignal(void 0, void 0, param.altText, param.signalType); + break; + case "altEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "setAccTitle": + setAccTitle(param.text); + break; + case "parStart": + addSignal(void 0, void 0, param.parText, param.signalType); + break; + case "and": + addSignal(void 0, void 0, param.parText, param.signalType); + break; + case "parEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "criticalStart": + addSignal(void 0, void 0, param.criticalText, param.signalType); + break; + case "option": + addSignal(void 0, void 0, param.optionText, param.signalType); + break; + case "criticalEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "breakStart": + addSignal(void 0, void 0, param.breakText, param.signalType); + break; + case "breakEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + } + } +}; +const db = { + addActor, + addMessage, + addSignal, + addLinks, + addDetails, + addProperties, + autoWrap, + setWrap, + enableSequenceNumbers, + disableSequenceNumbers, + showSequenceNumbers, + getMessages, + getActors, + getCreatedActors, + getDestroyedActors, + getActor, + getActorKeys, + getActorProperty, + getAccTitle, + getBoxes, + getDiagramTitle, + setDiagramTitle, + getConfig: () => getConfig().sequence, + clear, + parseMessage, + parseBoxData, + LINETYPE, + ARROWTYPE, + PLACEMENT, + addNote, + setAccTitle, + apply, + setAccDescription, + getAccDescription, + hasAtLeastOneBox, + hasAtLeastOneBoxWithTitle +}; +const getStyles = (options) => `.actor { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + } + + text.actor > tspan { + fill: ${options.actorTextColor}; + stroke: none; + } + + .actor-line { + stroke: ${options.actorLineColor}; + } + + .messageLine0 { + stroke-width: 1.5; + stroke-dasharray: none; + stroke: ${options.signalColor}; + } + + .messageLine1 { + stroke-width: 1.5; + stroke-dasharray: 2, 2; + stroke: ${options.signalColor}; + } + + #arrowhead path { + fill: ${options.signalColor}; + stroke: ${options.signalColor}; + } + + .sequenceNumber { + fill: ${options.sequenceNumberColor}; + } + + #sequencenumber { + fill: ${options.signalColor}; + } + + #crosshead path { + fill: ${options.signalColor}; + stroke: ${options.signalColor}; + } + + .messageText { + fill: ${options.signalTextColor}; + stroke: none; + } + + .labelBox { + stroke: ${options.labelBoxBorderColor}; + fill: ${options.labelBoxBkgColor}; + } + + .labelText, .labelText > tspan { + fill: ${options.labelTextColor}; + stroke: none; + } + + .loopText, .loopText > tspan { + fill: ${options.loopTextColor}; + stroke: none; + } + + .loopLine { + stroke-width: 2px; + stroke-dasharray: 2, 2; + stroke: ${options.labelBoxBorderColor}; + fill: ${options.labelBoxBorderColor}; + } + + .note { + //stroke: #decc93; + stroke: ${options.noteBorderColor}; + fill: ${options.noteBkgColor}; + } + + .noteText, .noteText > tspan { + fill: ${options.noteTextColor}; + stroke: none; + } + + .activation0 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .activation1 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .activation2 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .actorPopupMenu { + position: absolute; + } + + .actorPopupMenuPanel { + position: absolute; + fill: ${options.actorBkg}; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4)); +} + .actor-man line { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + } + .actor-man circle, line { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + stroke-width: 2px; + } +`; +const styles = getStyles; +const ACTOR_TYPE_WIDTH = 18 * 2; +const TOP_ACTOR_CLASS = "actor-top"; +const BOTTOM_ACTOR_CLASS = "actor-bottom"; +const drawRect = function(elem, rectData) { + return drawRect$1(elem, rectData); +}; +const drawPopup = function(elem, actor, minMenuWidth, textAttrs, forceMenus) { + if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) { + return { height: 0, width: 0 }; + } + const links = actor.links; + const actorCnt2 = actor.actorCnt; + const rectData = actor.rectData; + var displayValue = "none"; + if (forceMenus) { + displayValue = "block !important"; + } + const g = elem.append("g"); + g.attr("id", "actor" + actorCnt2 + "_popup"); + g.attr("class", "actorPopupMenu"); + g.attr("display", displayValue); + var actorClass = ""; + if (rectData.class !== void 0) { + actorClass = " " + rectData.class; + } + let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth; + const rectElem = g.append("rect"); + rectElem.attr("class", "actorPopupMenuPanel" + actorClass); + rectElem.attr("x", rectData.x); + rectElem.attr("y", rectData.height); + rectElem.attr("fill", rectData.fill); + rectElem.attr("stroke", rectData.stroke); + rectElem.attr("width", menuWidth); + rectElem.attr("height", rectData.height); + rectElem.attr("rx", rectData.rx); + rectElem.attr("ry", rectData.ry); + if (links != null) { + var linkY = 20; + for (let key in links) { + var linkElem = g.append("a"); + var sanitizedLink = dist.sanitizeUrl(links[key]); + linkElem.attr("xlink:href", sanitizedLink); + linkElem.attr("target", "_blank"); + _drawMenuItemTextCandidateFunc(textAttrs)( + key, + linkElem, + rectData.x + 10, + rectData.height + linkY, + menuWidth, + 20, + { class: "actor" }, + textAttrs + ); + linkY += 30; + } + } + rectElem.attr("height", linkY); + return { height: rectData.height + linkY, width: menuWidth }; +}; +const popupMenuToggle = function(popId) { + return "var pu = document.getElementById('" + popId + "'); if (pu != null) { pu.style.display = pu.style.display == 'block' ? 'none' : 'block'; }"; +}; +const drawKatex = async function(elem, textData, msgModel = null) { + let textElem = elem.append("foreignObject"); + const lines = await renderKatex(textData.text, getConfig$1()); + const divElem = textElem.append("xhtml:div").attr("style", "width: fit-content;").attr("xmlns", "http://www.w3.org/1999/xhtml").html(lines); + const dim = divElem.node().getBoundingClientRect(); + textElem.attr("height", Math.round(dim.height)).attr("width", Math.round(dim.width)); + if (textData.class === "noteText") { + const rectElem = elem.node().firstChild; + rectElem.setAttribute("height", dim.height + 2 * textData.textMargin); + const rectDim = rectElem.getBBox(); + textElem.attr("x", Math.round(rectDim.x + rectDim.width / 2 - dim.width / 2)).attr("y", Math.round(rectDim.y + rectDim.height / 2 - dim.height / 2)); + } else if (msgModel) { + let { startx, stopx, starty } = msgModel; + if (startx > stopx) { + const temp = startx; + startx = stopx; + stopx = temp; + } + textElem.attr("x", Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2)); + if (textData.class === "loopText") { + textElem.attr("y", Math.round(starty)); + } else { + textElem.attr("y", Math.round(starty - dim.height)); + } + } + return [textElem]; +}; +const drawText = function(elem, textData) { + let prevTextHeight = 0; + let textHeight = 0; + const lines = textData.text.split(common$1.lineBreakRegex); + const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize); + let textElems = []; + let dy = 0; + let yfunc = () => textData.y; + if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) { + switch (textData.valign) { + case "top": + case "start": + yfunc = () => Math.round(textData.y + textData.textMargin); + break; + case "middle": + case "center": + yfunc = () => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2); + break; + case "bottom": + case "end": + yfunc = () => Math.round( + textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin + ); + break; + } + } + if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) { + switch (textData.anchor) { + case "left": + case "start": + textData.x = Math.round(textData.x + textData.textMargin); + textData.anchor = "start"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + case "middle": + case "center": + textData.x = Math.round(textData.x + textData.width / 2); + textData.anchor = "middle"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + case "right": + case "end": + textData.x = Math.round(textData.x + textData.width - textData.textMargin); + textData.anchor = "end"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + } + } + for (let [i, line] of lines.entries()) { + if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) { + dy = i * _textFontSize; + } + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", yfunc()); + if (textData.anchor !== void 0) { + textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline); + } + if (textData.fontFamily !== void 0) { + textElem.style("font-family", textData.fontFamily); + } + if (_textFontSizePx !== void 0) { + textElem.style("font-size", _textFontSizePx); + } + if (textData.fontWeight !== void 0) { + textElem.style("font-weight", textData.fontWeight); + } + if (textData.fill !== void 0) { + textElem.attr("fill", textData.fill); + } + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + if (textData.dy !== void 0) { + textElem.attr("dy", textData.dy); + } else if (dy !== 0) { + textElem.attr("dy", dy); + } + const text = line || ZERO_WIDTH_SPACE; + if (textData.tspan) { + const span = textElem.append("tspan"); + span.attr("x", textData.x); + if (textData.fill !== void 0) { + span.attr("fill", textData.fill); + } + span.text(text); + } else { + textElem.text(text); + } + if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) { + textHeight += (textElem._groups || textElem)[0][0].getBBox().height; + prevTextHeight = textHeight; + } + textElems.push(textElem); + } + return textElems; +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.height / 2; + drawText(elem, txtObject); + return polygon; +}; +let actorCnt = -1; +const fixLifeLineHeights = (diagram2, actors, actorKeys, conf2) => { + if (!diagram2.select) { + return; + } + actorKeys.forEach((actorKey) => { + const actor = actors[actorKey]; + const actorDOM = diagram2.select("#actor" + actor.actorCnt); + if (!conf2.mirrorActors && actor.stopy) { + actorDOM.attr("y2", actor.stopy + actor.height / 2); + } else if (conf2.mirrorActors) { + actorDOM.attr("y2", actor.stopy); + } + }); +}; +const drawActorTypeParticipant = async function(elem, actor, conf2, isFooter) { + const actorY = isFooter ? actor.stopy : actor.starty; + const center = actor.x + actor.width / 2; + const centerY = actorY + 5; + const boxplusLineGroup = elem.append("g").lower(); + var g = boxplusLineGroup; + if (!isFooter) { + actorCnt++; + if (Object.keys(actor.links || {}).length && !conf2.forceMenus) { + g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer"); + } + g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"); + g = boxplusLineGroup.append("g"); + actor.actorCnt = actorCnt; + if (actor.links != null) { + g.attr("id", "root-" + actorCnt); + } + } + const rect = getNoteRect$1(); + var cssclass = "actor"; + if (actor.properties != null && actor.properties["class"]) { + cssclass = actor.properties["class"]; + } else { + rect.fill = "#eaeaea"; + } + if (isFooter) { + cssclass += ` ${BOTTOM_ACTOR_CLASS}`; + } else { + cssclass += ` ${TOP_ACTOR_CLASS}`; + } + rect.x = actor.x; + rect.y = actorY; + rect.width = actor.width; + rect.height = actor.height; + rect.class = cssclass; + rect.rx = 3; + rect.ry = 3; + rect.name = actor.name; + const rectElem = drawRect(g, rect); + actor.rectData = rect; + if (actor.properties != null && actor.properties["icon"]) { + const iconSrc = actor.properties["icon"].trim(); + if (iconSrc.charAt(0) === "@") { + drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1)); + } else { + drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc); + } + } + await _drawTextCandidateFunc(conf2, hasKatex(actor.description))( + actor.description, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "actor" }, + conf2 + ); + let height = actor.height; + if (rectElem.node) { + const bounds2 = rectElem.node().getBBox(); + actor.height = bounds2.height; + height = bounds2.height; + } + return height; +}; +const drawActorTypeActor = async function(elem, actor, conf2, isFooter) { + const actorY = isFooter ? actor.stopy : actor.starty; + const center = actor.x + actor.width / 2; + const centerY = actorY + 80; + elem.lower(); + if (!isFooter) { + actorCnt++; + elem.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"); + actor.actorCnt = actorCnt; + } + const actElem = elem.append("g"); + let cssClass = "actor-man"; + if (isFooter) { + cssClass += ` ${BOTTOM_ACTOR_CLASS}`; + } else { + cssClass += ` ${TOP_ACTOR_CLASS}`; + } + actElem.attr("class", cssClass); + actElem.attr("name", actor.name); + const rect = getNoteRect$1(); + rect.x = actor.x; + rect.y = actorY; + rect.fill = "#eaeaea"; + rect.width = actor.width; + rect.height = actor.height; + rect.class = "actor"; + rect.rx = 3; + rect.ry = 3; + actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actorY + 25).attr("x2", center).attr("y2", actorY + 45); + actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 33).attr("x2", center + ACTOR_TYPE_WIDTH / 2).attr("y2", actorY + 33); + actElem.append("line").attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 60).attr("x2", center).attr("y2", actorY + 45); + actElem.append("line").attr("x1", center).attr("y1", actorY + 45).attr("x2", center + ACTOR_TYPE_WIDTH / 2 - 2).attr("y2", actorY + 60); + const circle = actElem.append("circle"); + circle.attr("cx", actor.x + actor.width / 2); + circle.attr("cy", actorY + 10); + circle.attr("r", 15); + circle.attr("width", actor.width); + circle.attr("height", actor.height); + const bounds2 = actElem.node().getBBox(); + actor.height = bounds2.height; + await _drawTextCandidateFunc(conf2, hasKatex(actor.description))( + actor.description, + actElem, + rect.x, + rect.y + 35, + rect.width, + rect.height, + { class: "actor" }, + conf2 + ); + return actor.height; +}; +const drawActor = async function(elem, actor, conf2, isFooter) { + switch (actor.type) { + case "actor": + return await drawActorTypeActor(elem, actor, conf2, isFooter); + case "participant": + return await drawActorTypeParticipant(elem, actor, conf2, isFooter); + } +}; +const drawBox = async function(elem, box, conf2) { + const boxplusTextGroup = elem.append("g"); + const g = boxplusTextGroup; + drawBackgroundRect(g, box); + if (box.name) { + await _drawTextCandidateFunc(conf2)( + box.name, + g, + box.x, + box.y + (box.textMaxHeight || 0) / 2, + box.width, + 0, + { class: "text" }, + conf2 + ); + } + g.lower(); +}; +const anchorElement = function(elem) { + return elem.append("g"); +}; +const drawActivation = function(elem, bounds2, verticalPos, conf2, actorActivations2) { + const rect = getNoteRect$1(); + const g = bounds2.anchored; + rect.x = bounds2.startx; + rect.y = bounds2.starty; + rect.class = "activation" + actorActivations2 % 3; + rect.width = bounds2.stopx - bounds2.startx; + rect.height = verticalPos - bounds2.starty; + drawRect(g, rect); +}; +const drawLoop = async function(elem, loopModel, labelText, conf2) { + const { + boxMargin, + boxTextMargin, + labelBoxHeight, + labelBoxWidth, + messageFontFamily: fontFamily, + messageFontSize: fontSize, + messageFontWeight: fontWeight + } = conf2; + const g = elem.append("g"); + const drawLoopLine = function(startx, starty, stopx, stopy) { + return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine"); + }; + drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty); + drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy); + drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy); + drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy); + if (loopModel.sections !== void 0) { + loopModel.sections.forEach(function(item) { + drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style( + "stroke-dasharray", + "3, 3" + ); + }); + } + let txt = getTextObj$1(); + txt.text = labelText; + txt.x = loopModel.startx; + txt.y = loopModel.starty; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.tspan = false; + txt.width = labelBoxWidth || 50; + txt.height = labelBoxHeight || 20; + txt.textMargin = boxTextMargin; + txt.class = "labelText"; + drawLabel(g, txt); + txt = getTextObj(); + txt.text = loopModel.title; + txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2; + txt.y = loopModel.starty + boxMargin + boxTextMargin; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.textMargin = boxTextMargin; + txt.class = "loopText"; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.wrap = true; + let textElem = hasKatex(txt.text) ? await drawKatex(g, txt, loopModel) : drawText(g, txt); + if (loopModel.sectionTitles !== void 0) { + for (const [idx, item] of Object.entries(loopModel.sectionTitles)) { + if (item.message) { + txt.text = item.message; + txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2; + txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin; + txt.class = "loopText"; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.tspan = false; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.wrap = loopModel.wrap; + if (hasKatex(txt.text)) { + loopModel.starty = loopModel.sections[idx].y; + await drawKatex(g, txt, loopModel); + } else { + drawText(g, txt); + } + let sectionHeight = Math.round( + textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr) + ); + loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin); + } + } + } + loopModel.height = Math.round(loopModel.stopy - loopModel.starty); + return g; +}; +const drawBackgroundRect = function(elem, bounds2) { + drawBackgroundRect$1(elem, bounds2); +}; +const insertDatabaseIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z" + ); +}; +const insertComputerIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z" + ); +}; +const insertClockIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z" + ); +}; +const insertArrowHead = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 7.9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +}; +const insertArrowFilledHead = function(elem) { + elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 15.5).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const insertSequenceNumber = function(elem) { + elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6); +}; +const insertArrowCrossHead = function(elem) { + const defs = elem.append("defs"); + const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 4.5); + marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1pt").attr("d", "M 1,2 L 6,7 M 6,2 L 1,7"); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + anchor: void 0, + style: "#666", + width: void 0, + height: void 0, + textMargin: 0, + rx: 0, + ry: 0, + tspan: true, + valign: void 0 + }; +}; +const getNoteRect = function() { + return { + x: 0, + y: 0, + fill: "#EDF2AE", + stroke: "#666", + width: 100, + anchor: "start", + height: 100, + rx: 0, + ry: 0 + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { actorFontSize, actorFontFamily, actorFontWeight } = conf2; + const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize); + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").style("font-size", _actorFontSizePx).style("font-weight", actorFontWeight).style("font-family", actorFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + async function byKatex(content, g, x, y, width, height, textAttrs, conf2) { + const dim = await calculateMathMLDimensions(content, getConfig$1()); + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x + width / 2 - dim.width / 2).attr("y", y + height / 2 - dim.height / 2).attr("width", dim.width).attr("height", dim.height); + const text = f.append("xhtml:div").style("height", "100%").style("width", "100%"); + text.append("div").style("text-align", "center").style("vertical-align", "middle").html(await renderKatex(content, getConfig$1())); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2, hasKatex2 = false) { + if (hasKatex2) { + return byKatex; + } + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const _drawMenuItemTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { actorFontSize, actorFontFamily, actorFontWeight } = conf2; + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").style("font-size", actorFontSize).style("font-weight", actorFontWeight).style("font-family", actorFontFamily); + text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const svgDraw = { + drawRect, + drawText, + drawLabel, + drawActor, + drawBox, + drawPopup, + anchorElement, + drawActivation, + drawLoop, + drawBackgroundRect, + insertArrowHead, + insertArrowFilledHead, + insertSequenceNumber, + insertArrowCrossHead, + insertDatabaseIcon, + insertComputerIcon, + insertClockIcon, + getTextObj, + getNoteRect, + fixLifeLineHeights, + sanitizeUrl: dist.sanitizeUrl +}; +let conf = {}; +const bounds = { + data: { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }, + verticalPos: 0, + sequenceItems: [], + activations: [], + models: { + getHeight: function() { + return Math.max.apply( + null, + this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0) + ) + (this.loops.length === 0 ? 0 : this.loops.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.messages.length === 0 ? 0 : this.messages.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.notes.length === 0 ? 0 : this.notes.map((it) => it.height || 0).reduce((acc, h) => acc + h)); + }, + clear: function() { + this.actors = []; + this.boxes = []; + this.loops = []; + this.messages = []; + this.notes = []; + }, + addBox: function(boxModel) { + this.boxes.push(boxModel); + }, + addActor: function(actorModel) { + this.actors.push(actorModel); + }, + addLoop: function(loopModel) { + this.loops.push(loopModel); + }, + addMessage: function(msgModel) { + this.messages.push(msgModel); + }, + addNote: function(noteModel) { + this.notes.push(noteModel); + }, + lastActor: function() { + return this.actors[this.actors.length - 1]; + }, + lastLoop: function() { + return this.loops[this.loops.length - 1]; + }, + lastMessage: function() { + return this.messages[this.messages.length - 1]; + }, + lastNote: function() { + return this.notes[this.notes.length - 1]; + }, + actors: [], + boxes: [], + loops: [], + messages: [], + notes: [] + }, + init: function() { + this.sequenceItems = []; + this.activations = []; + this.models.clear(); + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }; + this.verticalPos = 0; + setConf(getConfig()); + }, + updateVal: function(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + }, + updateBounds: function(startx, starty, stopx, stopy) { + const _self = this; + let cnt = 0; + function updateFn(type) { + return function updateItemBounds(item) { + cnt++; + const n = _self.sequenceItems.length - cnt + 1; + _self.updateVal(item, "starty", starty - n * conf.boxMargin, Math.min); + _self.updateVal(item, "stopy", stopy + n * conf.boxMargin, Math.max); + _self.updateVal(bounds.data, "startx", startx - n * conf.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopx", stopx + n * conf.boxMargin, Math.max); + if (!(type === "activation")) { + _self.updateVal(item, "startx", startx - n * conf.boxMargin, Math.min); + _self.updateVal(item, "stopx", stopx + n * conf.boxMargin, Math.max); + _self.updateVal(bounds.data, "starty", starty - n * conf.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopy", stopy + n * conf.boxMargin, Math.max); + } + }; + } + this.sequenceItems.forEach(updateFn()); + this.activations.forEach(updateFn("activation")); + }, + insert: function(startx, starty, stopx, stopy) { + const _startx = common$1.getMin(startx, stopx); + const _stopx = common$1.getMax(startx, stopx); + const _starty = common$1.getMin(starty, stopy); + const _stopy = common$1.getMax(starty, stopy); + this.updateVal(bounds.data, "startx", _startx, Math.min); + this.updateVal(bounds.data, "starty", _starty, Math.min); + this.updateVal(bounds.data, "stopx", _stopx, Math.max); + this.updateVal(bounds.data, "stopy", _stopy, Math.max); + this.updateBounds(_startx, _starty, _stopx, _stopy); + }, + newActivation: function(message, diagram2, actors) { + const actorRect = actors[message.from.actor]; + const stackedSize = actorActivations(message.from.actor).length || 0; + const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2; + this.activations.push({ + startx: x, + starty: this.verticalPos + 2, + stopx: x + conf.activationWidth, + stopy: void 0, + actor: message.from.actor, + anchored: svgDraw.anchorElement(diagram2) + }); + }, + endActivation: function(message) { + const lastActorActivationIdx = this.activations.map(function(activation) { + return activation.actor; + }).lastIndexOf(message.from.actor); + return this.activations.splice(lastActorActivationIdx, 1)[0]; + }, + createLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) { + return { + startx: void 0, + starty: this.verticalPos, + stopx: void 0, + stopy: void 0, + title: title.message, + wrap: title.wrap, + width: title.width, + height: 0, + fill + }; + }, + newLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) { + this.sequenceItems.push(this.createLoop(title, fill)); + }, + endLoop: function() { + return this.sequenceItems.pop(); + }, + isLoopOverlap: function() { + return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false; + }, + addSectionToLoop: function(message) { + const loop = this.sequenceItems.pop(); + loop.sections = loop.sections || []; + loop.sectionTitles = loop.sectionTitles || []; + loop.sections.push({ y: bounds.getVerticalPos(), height: 0 }); + loop.sectionTitles.push(message); + this.sequenceItems.push(loop); + }, + saveVerticalPos: function() { + if (this.isLoopOverlap()) { + this.savedVerticalPos = this.verticalPos; + } + }, + resetVerticalPos: function() { + if (this.isLoopOverlap()) { + this.verticalPos = this.savedVerticalPos; + } + }, + bumpVerticalPos: function(bump) { + this.verticalPos = this.verticalPos + bump; + this.data.stopy = common$1.getMax(this.data.stopy, this.verticalPos); + }, + getVerticalPos: function() { + return this.verticalPos; + }, + getBounds: function() { + return { bounds: this.data, models: this.models }; + } +}; +const drawNote = async function(elem, noteModel) { + bounds.bumpVerticalPos(conf.boxMargin); + noteModel.height = conf.boxMargin; + noteModel.starty = bounds.getVerticalPos(); + const rect = getNoteRect$1(); + rect.x = noteModel.startx; + rect.y = noteModel.starty; + rect.width = noteModel.width || conf.width; + rect.class = "note"; + const g = elem.append("g"); + const rectElem = svgDraw.drawRect(g, rect); + const textObj = getTextObj$1(); + textObj.x = noteModel.startx; + textObj.y = noteModel.starty; + textObj.width = rect.width; + textObj.dy = "1em"; + textObj.text = noteModel.message; + textObj.class = "noteText"; + textObj.fontFamily = conf.noteFontFamily; + textObj.fontSize = conf.noteFontSize; + textObj.fontWeight = conf.noteFontWeight; + textObj.anchor = conf.noteAlign; + textObj.textMargin = conf.noteMargin; + textObj.valign = "center"; + const textElem = hasKatex(textObj.text) ? await drawKatex(g, textObj) : drawText(g, textObj); + const textHeight = Math.round( + textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr) + ); + rectElem.attr("height", textHeight + 2 * conf.noteMargin); + noteModel.height += textHeight + 2 * conf.noteMargin; + bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin); + noteModel.stopy = noteModel.starty + textHeight + 2 * conf.noteMargin; + noteModel.stopx = noteModel.startx + rect.width; + bounds.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy); + bounds.models.addNote(noteModel); +}; +const messageFont = (cnf) => { + return { + fontFamily: cnf.messageFontFamily, + fontSize: cnf.messageFontSize, + fontWeight: cnf.messageFontWeight + }; +}; +const noteFont = (cnf) => { + return { + fontFamily: cnf.noteFontFamily, + fontSize: cnf.noteFontSize, + fontWeight: cnf.noteFontWeight + }; +}; +const actorFont = (cnf) => { + return { + fontFamily: cnf.actorFontFamily, + fontSize: cnf.actorFontSize, + fontWeight: cnf.actorFontWeight + }; +}; +async function boundMessage(_diagram, msgModel) { + bounds.bumpVerticalPos(10); + const { startx, stopx, message } = msgModel; + const lines = common$1.splitBreaks(message).length; + const isKatexMsg = hasKatex(message); + const textDims = isKatexMsg ? await calculateMathMLDimensions(message, getConfig()) : utils.calculateTextDimensions(message, messageFont(conf)); + if (!isKatexMsg) { + const lineHeight = textDims.height / lines; + msgModel.height += lineHeight; + bounds.bumpVerticalPos(lineHeight); + } + let lineStartY; + let totalOffset = textDims.height - 10; + const textWidth = textDims.width; + if (startx === stopx) { + lineStartY = bounds.getVerticalPos() + totalOffset; + if (!conf.rightAngles) { + totalOffset += conf.boxMargin; + lineStartY = bounds.getVerticalPos() + totalOffset; + } + totalOffset += 30; + const dx = common$1.getMax(textWidth / 2, conf.width / 2); + bounds.insert( + startx - dx, + bounds.getVerticalPos() - 10 + totalOffset, + stopx + dx, + bounds.getVerticalPos() + 30 + totalOffset + ); + } else { + totalOffset += conf.boxMargin; + lineStartY = bounds.getVerticalPos() + totalOffset; + bounds.insert(startx, lineStartY - 10, stopx, lineStartY); + } + bounds.bumpVerticalPos(totalOffset); + msgModel.height += totalOffset; + msgModel.stopy = msgModel.starty + msgModel.height; + bounds.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy); + return lineStartY; +} +const drawMessage = async function(diagram2, msgModel, lineStartY, diagObj) { + const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel; + const textDims = utils.calculateTextDimensions(message, messageFont(conf)); + const textObj = getTextObj$1(); + textObj.x = startx; + textObj.y = starty + 10; + textObj.width = stopx - startx; + textObj.class = "messageText"; + textObj.dy = "1em"; + textObj.text = message; + textObj.fontFamily = conf.messageFontFamily; + textObj.fontSize = conf.messageFontSize; + textObj.fontWeight = conf.messageFontWeight; + textObj.anchor = conf.messageAlign; + textObj.valign = "center"; + textObj.textMargin = conf.wrapPadding; + textObj.tspan = false; + hasKatex(textObj.text) ? await drawKatex(diagram2, textObj, { startx, stopx, starty: lineStartY }) : drawText(diagram2, textObj); + const textWidth = textDims.width; + let line; + if (startx === stopx) { + if (conf.rightAngles) { + line = diagram2.append("path").attr( + "d", + `M ${startx},${lineStartY} H ${startx + common$1.getMax(conf.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}` + ); + } else { + line = diagram2.append("path").attr( + "d", + "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20) + ); + } + } else { + line = diagram2.append("line"); + line.attr("x1", startx); + line.attr("y1", lineStartY); + line.attr("x2", stopx); + line.attr("y2", lineStartY); + } + if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN) { + line.style("stroke-dasharray", "3, 3"); + line.attr("class", "messageLine1"); + } else { + line.attr("class", "messageLine0"); + } + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + line.attr("stroke-width", 2); + line.attr("stroke", "none"); + line.style("fill", "none"); + if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) { + line.attr("marker-end", "url(" + url + "#filled-head)"); + } + if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) { + line.attr("marker-end", "url(" + url + "#crosshead)"); + } + if (sequenceVisible || conf.showSequenceNumbers) { + line.attr("marker-start", "url(" + url + "#sequencenumber)"); + diagram2.append("text").attr("x", startx).attr("y", lineStartY + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(sequenceIndex); + } +}; +const addActorRenderingData = async function(diagram2, actors, createdActors, actorKeys, verticalPos, messages, isFooter) { + let prevWidth = 0; + let prevMargin = 0; + let prevBox = void 0; + let maxHeight = 0; + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + const box = actor.box; + if (prevBox && prevBox != box) { + { + bounds.models.addBox(prevBox); + } + prevMargin += conf.boxMargin + prevBox.margin; + } + if (box && box != prevBox) { + { + box.x = prevWidth + prevMargin; + box.y = verticalPos; + } + prevMargin += box.margin; + } + actor.width = actor.width || conf.width; + actor.height = common$1.getMax(actor.height || conf.height, conf.height); + actor.margin = actor.margin || conf.actorMargin; + maxHeight = common$1.getMax(maxHeight, actor.height); + if (createdActors[actor.name]) { + prevMargin += actor.width / 2; + } + actor.x = prevWidth + prevMargin; + actor.starty = bounds.getVerticalPos(); + bounds.insert(actor.x, verticalPos, actor.x + actor.width, actor.height); + prevWidth += actor.width + prevMargin; + if (actor.box) { + actor.box.width = prevWidth + box.margin - actor.box.x; + } + prevMargin = actor.margin; + prevBox = actor.box; + bounds.models.addActor(actor); + } + if (prevBox && !isFooter) { + bounds.models.addBox(prevBox); + } + bounds.bumpVerticalPos(maxHeight); +}; +const drawActors = async function(diagram2, actors, actorKeys, isFooter) { + if (!isFooter) { + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + await svgDraw.drawActor(diagram2, actor, conf, false); + } + } else { + let maxHeight = 0; + bounds.bumpVerticalPos(conf.boxMargin * 2); + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + if (!actor.stopy) { + actor.stopy = bounds.getVerticalPos(); + } + const height = await svgDraw.drawActor(diagram2, actor, conf, true); + maxHeight = common$1.getMax(maxHeight, height); + } + bounds.bumpVerticalPos(maxHeight + conf.boxMargin); + } +}; +const drawActorsPopup = function(diagram2, actors, actorKeys, doc) { + let maxHeight = 0; + let maxWidth = 0; + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + const minMenuWidth = getRequiredPopupWidth(actor); + const menuDimensions = svgDraw.drawPopup( + diagram2, + actor, + minMenuWidth, + conf, + conf.forceMenus, + doc + ); + if (menuDimensions.height > maxHeight) { + maxHeight = menuDimensions.height; + } + if (menuDimensions.width + actor.x > maxWidth) { + maxWidth = menuDimensions.width + actor.x; + } + } + return { maxHeight, maxWidth }; +}; +const setConf = function(cnf) { + assignWithDepth$1(conf, cnf); + if (cnf.fontFamily) { + conf.actorFontFamily = conf.noteFontFamily = conf.messageFontFamily = cnf.fontFamily; + } + if (cnf.fontSize) { + conf.actorFontSize = conf.noteFontSize = conf.messageFontSize = cnf.fontSize; + } + if (cnf.fontWeight) { + conf.actorFontWeight = conf.noteFontWeight = conf.messageFontWeight = cnf.fontWeight; + } +}; +const actorActivations = function(actor) { + return bounds.activations.filter(function(activation) { + return activation.actor === actor; + }); +}; +const activationBounds = function(actor, actors) { + const actorObj = actors[actor]; + const activations = actorActivations(actor); + const left = activations.reduce(function(acc, activation) { + return common$1.getMin(acc, activation.startx); + }, actorObj.x + actorObj.width / 2 - 1); + const right = activations.reduce(function(acc, activation) { + return common$1.getMax(acc, activation.stopx); + }, actorObj.x + actorObj.width / 2 + 1); + return [left, right]; +}; +function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) { + bounds.bumpVerticalPos(preMargin); + let heightAdjust = postMargin; + if (msg.id && msg.message && loopWidths[msg.id]) { + const loopWidth = loopWidths[msg.id].width; + const textConf = messageFont(conf); + msg.message = utils.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf.wrapPadding, textConf); + msg.width = loopWidth; + msg.wrap = true; + const textDims = utils.calculateTextDimensions(msg.message, textConf); + const totalOffset = common$1.getMax(textDims.height, conf.labelBoxHeight); + heightAdjust = postMargin + totalOffset; + log$1.debug(`${totalOffset} - ${msg.message}`); + } + addLoopFn(msg); + bounds.bumpVerticalPos(heightAdjust); +} +function adjustCreatedDestroyedData(msg, msgModel, lineStartY, index, actors, createdActors, destroyedActors) { + function receiverAdjustment(actor, adjustment) { + if (actor.x < actors[msg.from].x) { + bounds.insert( + msgModel.stopx - adjustment, + msgModel.starty, + msgModel.startx, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.stopx = msgModel.stopx + adjustment; + } else { + bounds.insert( + msgModel.startx, + msgModel.starty, + msgModel.stopx + adjustment, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.stopx = msgModel.stopx - adjustment; + } + } + function senderAdjustment(actor, adjustment) { + if (actor.x < actors[msg.to].x) { + bounds.insert( + msgModel.startx - adjustment, + msgModel.starty, + msgModel.stopx, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.startx = msgModel.startx + adjustment; + } else { + bounds.insert( + msgModel.stopx, + msgModel.starty, + msgModel.startx + adjustment, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.startx = msgModel.startx - adjustment; + } + } + if (createdActors[msg.to] == index) { + const actor = actors[msg.to]; + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; + receiverAdjustment(actor, adjustment); + actor.starty = lineStartY - actor.height / 2; + bounds.bumpVerticalPos(actor.height / 2); + } else if (destroyedActors[msg.from] == index) { + const actor = actors[msg.from]; + if (conf.mirrorActors) { + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 : actor.width / 2; + senderAdjustment(actor, adjustment); + } + actor.stopy = lineStartY - actor.height / 2; + bounds.bumpVerticalPos(actor.height / 2); + } else if (destroyedActors[msg.to] == index) { + const actor = actors[msg.to]; + if (conf.mirrorActors) { + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; + receiverAdjustment(actor, adjustment); + } + actor.stopy = lineStartY - actor.height / 2; + bounds.bumpVerticalPos(actor.height / 2); + } +} +const draw = async function(_text, id, _version, diagObj) { + const { securityLevel, sequence } = getConfig(); + conf = sequence; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + bounds.init(); + log$1.debug(diagObj.db); + const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const actors = diagObj.db.getActors(); + const createdActors = diagObj.db.getCreatedActors(); + const destroyedActors = diagObj.db.getDestroyedActors(); + const boxes = diagObj.db.getBoxes(); + let actorKeys = diagObj.db.getActorKeys(); + const messages = diagObj.db.getMessages(); + const title = diagObj.db.getDiagramTitle(); + const hasBoxes = diagObj.db.hasAtLeastOneBox(); + const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle(); + const maxMessageWidthPerActor = await getMaxMessageWidthPerActor(actors, messages, diagObj); + conf.height = await calculateActorMargins(actors, maxMessageWidthPerActor, boxes); + svgDraw.insertComputerIcon(diagram2); + svgDraw.insertDatabaseIcon(diagram2); + svgDraw.insertClockIcon(diagram2); + if (hasBoxes) { + bounds.bumpVerticalPos(conf.boxMargin); + if (hasBoxTitles) { + bounds.bumpVerticalPos(boxes[0].textMaxHeight); + } + } + if (conf.hideUnusedParticipants === true) { + const newActors = /* @__PURE__ */ new Set(); + messages.forEach((message) => { + newActors.add(message.from); + newActors.add(message.to); + }); + actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey)); + } + await addActorRenderingData(diagram2, actors, createdActors, actorKeys, 0, messages, false); + const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj); + svgDraw.insertArrowHead(diagram2); + svgDraw.insertArrowCrossHead(diagram2); + svgDraw.insertArrowFilledHead(diagram2); + svgDraw.insertSequenceNumber(diagram2); + function activeEnd(msg, verticalPos) { + const activationData = bounds.endActivation(msg); + if (activationData.starty + 18 > verticalPos) { + activationData.starty = verticalPos - 6; + verticalPos += 12; + } + svgDraw.drawActivation( + diagram2, + activationData, + verticalPos, + conf, + actorActivations(msg.from.actor).length + ); + bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos); + } + let sequenceIndex = 1; + let sequenceIndexStep = 1; + const messagesToDraw = []; + const backgrounds = []; + let index = 0; + for (const msg of messages) { + let loopModel, noteModel, msgModel; + switch (msg.type) { + case diagObj.db.LINETYPE.NOTE: + bounds.resetVerticalPos(); + noteModel = msg.noteModel; + await drawNote(diagram2, noteModel); + break; + case diagObj.db.LINETYPE.ACTIVE_START: + bounds.newActivation(msg, diagram2, actors); + break; + case diagObj.db.LINETYPE.ACTIVE_END: + activeEnd(msg, bounds.getVerticalPos()); + break; + case diagObj.db.LINETYPE.LOOP_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.LOOP_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "loop", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.RECT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin, + (message) => bounds.newLoop(void 0, message.message) + ); + break; + case diagObj.db.LINETYPE.RECT_END: + loopModel = bounds.endLoop(); + backgrounds.push(loopModel); + bounds.models.addLoop(loopModel); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + break; + case diagObj.db.LINETYPE.OPT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.OPT_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "opt", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.ALT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.ALT_ELSE: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin + conf.boxTextMargin, + conf.boxMargin, + (message) => bounds.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.ALT_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "alt", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.PAR_START: + case diagObj.db.LINETYPE.PAR_OVER_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + bounds.saveVerticalPos(); + break; + case diagObj.db.LINETYPE.PAR_AND: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin + conf.boxTextMargin, + conf.boxMargin, + (message) => bounds.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.PAR_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "par", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.AUTONUMBER: + sequenceIndex = msg.message.start || sequenceIndex; + sequenceIndexStep = msg.message.step || sequenceIndexStep; + if (msg.message.visible) { + diagObj.db.enableSequenceNumbers(); + } else { + diagObj.db.disableSequenceNumbers(); + } + break; + case diagObj.db.LINETYPE.CRITICAL_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.CRITICAL_OPTION: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin + conf.boxTextMargin, + conf.boxMargin, + (message) => bounds.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.CRITICAL_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "critical", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.BREAK_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.BREAK_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "break", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + default: + try { + msgModel = msg.msgModel; + msgModel.starty = bounds.getVerticalPos(); + msgModel.sequenceIndex = sequenceIndex; + msgModel.sequenceVisible = diagObj.db.showSequenceNumbers(); + const lineStartY = await boundMessage(diagram2, msgModel); + adjustCreatedDestroyedData( + msg, + msgModel, + lineStartY, + index, + actors, + createdActors, + destroyedActors + ); + messagesToDraw.push({ messageModel: msgModel, lineStartY }); + bounds.models.addMessage(msgModel); + } catch (e) { + log$1.error("error while drawing message", e); + } + } + if ([ + diagObj.db.LINETYPE.SOLID_OPEN, + diagObj.db.LINETYPE.DOTTED_OPEN, + diagObj.db.LINETYPE.SOLID, + diagObj.db.LINETYPE.DOTTED, + diagObj.db.LINETYPE.SOLID_CROSS, + diagObj.db.LINETYPE.DOTTED_CROSS, + diagObj.db.LINETYPE.SOLID_POINT, + diagObj.db.LINETYPE.DOTTED_POINT + ].includes(msg.type)) { + sequenceIndex = sequenceIndex + sequenceIndexStep; + } + index++; + } + log$1.debug("createdActors", createdActors); + log$1.debug("destroyedActors", destroyedActors); + await drawActors(diagram2, actors, actorKeys, false); + for (const e of messagesToDraw) { + await drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj); + } + if (conf.mirrorActors) { + await drawActors(diagram2, actors, actorKeys, true); + } + backgrounds.forEach((e) => svgDraw.drawBackgroundRect(diagram2, e)); + fixLifeLineHeights(diagram2, actors, actorKeys, conf); + for (const box2 of bounds.models.boxes) { + box2.height = bounds.getVerticalPos() - box2.y; + bounds.insert(box2.x, box2.y, box2.x + box2.width, box2.height); + box2.startx = box2.x; + box2.starty = box2.y; + box2.stopx = box2.startx + box2.width; + box2.stopy = box2.starty + box2.height; + box2.stroke = "rgb(0,0,0, 0.5)"; + await svgDraw.drawBox(diagram2, box2, conf); + } + if (hasBoxes) { + bounds.bumpVerticalPos(conf.boxMargin); + } + const requiredBoxSize = drawActorsPopup(diagram2, actors, actorKeys, doc); + const { bounds: box } = bounds.getBounds(); + let boxHeight = box.stopy - box.starty; + if (boxHeight < requiredBoxSize.maxHeight) { + boxHeight = requiredBoxSize.maxHeight; + } + let height = boxHeight + 2 * conf.diagramMarginY; + if (conf.mirrorActors) { + height = height - conf.boxMargin + conf.bottomMarginAdj; + } + let boxWidth = box.stopx - box.startx; + if (boxWidth < requiredBoxSize.maxWidth) { + boxWidth = requiredBoxSize.maxWidth; + } + const width = boxWidth + 2 * conf.diagramMarginX; + if (title) { + diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf.diagramMarginX).attr("y", -25); + } + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const extraVertForTitle = title ? 40 : 0; + diagram2.attr( + "viewBox", + box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle) + ); + log$1.debug(`models:`, bounds.models); +}; +async function getMaxMessageWidthPerActor(actors, messages, diagObj) { + const maxMessageWidthPerActor = {}; + for (const msg of messages) { + if (actors[msg.to] && actors[msg.from]) { + const actor = actors[msg.to]; + if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) { + continue; + } + if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) { + continue; + } + const isNote = msg.placement !== void 0; + const isMessage = !isNote; + const textFont = isNote ? noteFont(conf) : messageFont(conf); + const wrappedMessage = msg.wrap ? utils.wrapLabel(msg.message, conf.width - 2 * conf.wrapPadding, textFont) : msg.message; + const messageDimensions = hasKatex(wrappedMessage) ? await calculateMathMLDimensions(msg.message, getConfig()) : utils.calculateTextDimensions(wrappedMessage, textFont); + const messageWidth = messageDimensions.width + 2 * conf.wrapPadding; + if (isMessage && msg.from === actor.nextActor) { + maxMessageWidthPerActor[msg.to] = common$1.getMax( + maxMessageWidthPerActor[msg.to] || 0, + messageWidth + ); + } else if (isMessage && msg.from === actor.prevActor) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth + ); + } else if (isMessage && msg.from === msg.to) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth / 2 + ); + maxMessageWidthPerActor[msg.to] = common$1.getMax( + maxMessageWidthPerActor[msg.to] || 0, + messageWidth / 2 + ); + } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth + ); + } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { + maxMessageWidthPerActor[actor.prevActor] = common$1.getMax( + maxMessageWidthPerActor[actor.prevActor] || 0, + messageWidth + ); + } else if (msg.placement === diagObj.db.PLACEMENT.OVER) { + if (actor.prevActor) { + maxMessageWidthPerActor[actor.prevActor] = common$1.getMax( + maxMessageWidthPerActor[actor.prevActor] || 0, + messageWidth / 2 + ); + } + if (actor.nextActor) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth / 2 + ); + } + } + } + } + log$1.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor); + return maxMessageWidthPerActor; +} +const getRequiredPopupWidth = function(actor) { + let requiredPopupWidth = 0; + const textFont = actorFont(conf); + for (const key in actor.links) { + const labelDimensions = utils.calculateTextDimensions(key, textFont); + const labelWidth = labelDimensions.width + 2 * conf.wrapPadding + 2 * conf.boxMargin; + if (requiredPopupWidth < labelWidth) { + requiredPopupWidth = labelWidth; + } + } + return requiredPopupWidth; +}; +async function calculateActorMargins(actors, actorToMessageWidth, boxes) { + let maxHeight = 0; + for (const prop of Object.keys(actors)) { + const actor = actors[prop]; + if (actor.wrap) { + actor.description = utils.wrapLabel( + actor.description, + conf.width - 2 * conf.wrapPadding, + actorFont(conf) + ); + } + const actDims = hasKatex(actor.description) ? await calculateMathMLDimensions(actor.description, getConfig()) : utils.calculateTextDimensions(actor.description, actorFont(conf)); + actor.width = actor.wrap ? conf.width : common$1.getMax(conf.width, actDims.width + 2 * conf.wrapPadding); + actor.height = actor.wrap ? common$1.getMax(actDims.height, conf.height) : conf.height; + maxHeight = common$1.getMax(maxHeight, actor.height); + } + for (const actorKey in actorToMessageWidth) { + const actor = actors[actorKey]; + if (!actor) { + continue; + } + const nextActor = actors[actor.nextActor]; + if (!nextActor) { + const messageWidth2 = actorToMessageWidth[actorKey]; + const actorWidth2 = messageWidth2 + conf.actorMargin - actor.width / 2; + actor.margin = common$1.getMax(actorWidth2, conf.actorMargin); + continue; + } + const messageWidth = actorToMessageWidth[actorKey]; + const actorWidth = messageWidth + conf.actorMargin - actor.width / 2 - nextActor.width / 2; + actor.margin = common$1.getMax(actorWidth, conf.actorMargin); + } + let maxBoxHeight = 0; + boxes.forEach((box) => { + const textFont = messageFont(conf); + let totalWidth = box.actorKeys.reduce((total, aKey) => { + return total += actors[aKey].width + (actors[aKey].margin || 0); + }, 0); + totalWidth -= 2 * conf.boxTextMargin; + if (box.wrap) { + box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont); + } + const boxMsgDimensions = utils.calculateTextDimensions(box.name, textFont); + maxBoxHeight = common$1.getMax(boxMsgDimensions.height, maxBoxHeight); + const minWidth = common$1.getMax(totalWidth, boxMsgDimensions.width + 2 * conf.wrapPadding); + box.margin = conf.boxTextMargin; + if (totalWidth < minWidth) { + const missing = (minWidth - totalWidth) / 2; + box.margin += missing; + } + }); + boxes.forEach((box) => box.textMaxHeight = maxBoxHeight); + return common$1.getMax(maxHeight, conf.height); +} +const buildNoteModel = async function(msg, actors, diagObj) { + const startx = actors[msg.from].x; + const stopx = actors[msg.to].x; + const shouldWrap = msg.wrap && msg.message; + let textDimensions = hasKatex(msg.message) ? await calculateMathMLDimensions(msg.message, getConfig()) : utils.calculateTextDimensions( + shouldWrap ? utils.wrapLabel(msg.message, conf.width, noteFont(conf)) : msg.message, + noteFont(conf) + ); + const noteModel = { + width: shouldWrap ? conf.width : common$1.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin), + height: 0, + startx: actors[msg.from].x, + stopx: 0, + starty: 0, + stopy: 0, + message: msg.message + }; + if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) { + noteModel.width = shouldWrap ? common$1.getMax(conf.width, textDimensions.width) : common$1.getMax( + actors[msg.from].width / 2 + actors[msg.to].width / 2, + textDimensions.width + 2 * conf.noteMargin + ); + noteModel.startx = startx + (actors[msg.from].width + conf.actorMargin) / 2; + } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { + noteModel.width = shouldWrap ? common$1.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common$1.getMax( + actors[msg.from].width / 2 + actors[msg.to].width / 2, + textDimensions.width + 2 * conf.noteMargin + ); + noteModel.startx = startx - noteModel.width + (actors[msg.from].width - conf.actorMargin) / 2; + } else if (msg.to === msg.from) { + textDimensions = utils.calculateTextDimensions( + shouldWrap ? utils.wrapLabel( + msg.message, + common$1.getMax(conf.width, actors[msg.from].width), + noteFont(conf) + ) : msg.message, + noteFont(conf) + ); + noteModel.width = shouldWrap ? common$1.getMax(conf.width, actors[msg.from].width) : common$1.getMax( + actors[msg.from].width, + conf.width, + textDimensions.width + 2 * conf.noteMargin + ); + noteModel.startx = startx + (actors[msg.from].width - noteModel.width) / 2; + } else { + noteModel.width = Math.abs(startx + actors[msg.from].width / 2 - (stopx + actors[msg.to].width / 2)) + conf.actorMargin; + noteModel.startx = startx < stopx ? startx + actors[msg.from].width / 2 - conf.actorMargin / 2 : stopx + actors[msg.to].width / 2 - conf.actorMargin / 2; + } + if (shouldWrap) { + noteModel.message = utils.wrapLabel( + msg.message, + noteModel.width - 2 * conf.wrapPadding, + noteFont(conf) + ); + } + log$1.debug( + `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]` + ); + return noteModel; +}; +const buildMessageModel = function(msg, actors, diagObj) { + if (![ + diagObj.db.LINETYPE.SOLID_OPEN, + diagObj.db.LINETYPE.DOTTED_OPEN, + diagObj.db.LINETYPE.SOLID, + diagObj.db.LINETYPE.DOTTED, + diagObj.db.LINETYPE.SOLID_CROSS, + diagObj.db.LINETYPE.DOTTED_CROSS, + diagObj.db.LINETYPE.SOLID_POINT, + diagObj.db.LINETYPE.DOTTED_POINT + ].includes(msg.type)) { + return {}; + } + const [fromLeft, fromRight] = activationBounds(msg.from, actors); + const [toLeft, toRight] = activationBounds(msg.to, actors); + const isArrowToRight = fromLeft <= toLeft; + const startx = isArrowToRight ? fromRight : fromLeft; + let stopx = isArrowToRight ? toLeft : toRight; + const isArrowToActivation = Math.abs(toLeft - toRight) > 2; + const adjustValue = (value) => { + return isArrowToRight ? -value : value; + }; + if (msg.from === msg.to) { + stopx = startx; + } else { + if (msg.activate && !isArrowToActivation) { + stopx += adjustValue(conf.activationWidth / 2 - 1); + } + if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) { + stopx += adjustValue(3); + } + } + const allBounds = [fromLeft, fromRight, toLeft, toRight]; + const boundedWidth = Math.abs(startx - stopx); + if (msg.wrap && msg.message) { + msg.message = utils.wrapLabel( + msg.message, + common$1.getMax(boundedWidth + 2 * conf.wrapPadding, conf.width), + messageFont(conf) + ); + } + const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf)); + return { + width: common$1.getMax( + msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding, + boundedWidth + 2 * conf.wrapPadding, + conf.width + ), + height: 0, + startx, + stopx, + starty: 0, + stopy: 0, + message: msg.message, + type: msg.type, + wrap: msg.wrap, + fromBounds: Math.min.apply(null, allBounds), + toBounds: Math.max.apply(null, allBounds) + }; +}; +const calculateLoopBounds = async function(messages, actors, _maxWidthPerActor, diagObj) { + const loops = {}; + const stack = []; + let current, noteModel, msgModel; + for (const msg of messages) { + msg.id = utils.random({ length: 10 }); + switch (msg.type) { + case diagObj.db.LINETYPE.LOOP_START: + case diagObj.db.LINETYPE.ALT_START: + case diagObj.db.LINETYPE.OPT_START: + case diagObj.db.LINETYPE.PAR_START: + case diagObj.db.LINETYPE.PAR_OVER_START: + case diagObj.db.LINETYPE.CRITICAL_START: + case diagObj.db.LINETYPE.BREAK_START: + stack.push({ + id: msg.id, + msg: msg.message, + from: Number.MAX_SAFE_INTEGER, + to: Number.MIN_SAFE_INTEGER, + width: 0 + }); + break; + case diagObj.db.LINETYPE.ALT_ELSE: + case diagObj.db.LINETYPE.PAR_AND: + case diagObj.db.LINETYPE.CRITICAL_OPTION: + if (msg.message) { + current = stack.pop(); + loops[current.id] = current; + loops[msg.id] = current; + stack.push(current); + } + break; + case diagObj.db.LINETYPE.LOOP_END: + case diagObj.db.LINETYPE.ALT_END: + case diagObj.db.LINETYPE.OPT_END: + case diagObj.db.LINETYPE.PAR_END: + case diagObj.db.LINETYPE.CRITICAL_END: + case diagObj.db.LINETYPE.BREAK_END: + current = stack.pop(); + loops[current.id] = current; + break; + case diagObj.db.LINETYPE.ACTIVE_START: + { + const actorRect = actors[msg.from ? msg.from.actor : msg.to.actor]; + const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length; + const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2; + const toAdd = { + startx: x, + stopx: x + conf.activationWidth, + actor: msg.from.actor, + enabled: true + }; + bounds.activations.push(toAdd); + } + break; + case diagObj.db.LINETYPE.ACTIVE_END: + { + const lastActorActivationIdx = bounds.activations.map((a) => a.actor).lastIndexOf(msg.from.actor); + delete bounds.activations.splice(lastActorActivationIdx, 1)[0]; + } + break; + } + const isNote = msg.placement !== void 0; + if (isNote) { + noteModel = await buildNoteModel(msg, actors, diagObj); + msg.noteModel = noteModel; + stack.forEach((stk) => { + current = stk; + current.from = common$1.getMin(current.from, noteModel.startx); + current.to = common$1.getMax(current.to, noteModel.startx + noteModel.width); + current.width = common$1.getMax(current.width, Math.abs(current.from - current.to)) - conf.labelBoxWidth; + }); + } else { + msgModel = buildMessageModel(msg, actors, diagObj); + msg.msgModel = msgModel; + if (msgModel.startx && msgModel.stopx && stack.length > 0) { + stack.forEach((stk) => { + current = stk; + if (msgModel.startx === msgModel.stopx) { + const from = actors[msg.from]; + const to = actors[msg.to]; + current.from = common$1.getMin( + from.x - msgModel.width / 2, + from.x - from.width / 2, + current.from + ); + current.to = common$1.getMax( + to.x + msgModel.width / 2, + to.x + from.width / 2, + current.to + ); + current.width = common$1.getMax(current.width, Math.abs(current.to - current.from)) - conf.labelBoxWidth; + } else { + current.from = common$1.getMin(msgModel.startx, current.from); + current.to = common$1.getMax(msgModel.stopx, current.to); + current.width = common$1.getMax(current.width, msgModel.width) - conf.labelBoxWidth; + } + }); + } + } + } + bounds.activations = []; + log$1.debug("Loop type widths:", loops); + return loops; +}; +const renderer = { + bounds, + drawActors, + drawActorsPopup, + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: ({ wrap }) => { + db.setWrap(wrap); + } +}; + +export { diagram }; diff --git a/libs/marked/sequenceDiagram-6894f283-C15d_y26.js b/libs/marked/sequenceDiagram-6894f283-C15d_y26.js new file mode 100644 index 0000000..40671d8 --- /dev/null +++ b/libs/marked/sequenceDiagram-6894f283-C15d_y26.js @@ -0,0 +1,3336 @@ +import { g as getAccTitle, D as getDiagramTitle, C as setDiagramTitle, c as getConfig, s as setAccTitle, b as setAccDescription, a as getAccDescription, E as clear$1, l as log$1, d as sanitizeText$2, j as common$1, e as assignWithDepth$1, h as select, i as configureSvgSize, A as utils, a4 as hasKatex, a5 as calculateMathMLDimensions, m as dist, r as renderKatex, _ as getConfig$1, Y as parseFontSize, a6 as ZERO_WIDTH_SPACE } from './index-Bd_FDXSq.js'; +import { d as drawRect$1, a as drawBackgroundRect$1, g as getNoteRect$1, b as getTextObj$1, c as drawEmbeddedImage, e as drawImage } from './svgDrawCommon-5e1cfd1d-CHZPGcFQ.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 13], $V7 = [1, 14], $V8 = [1, 16], $V9 = [1, 17], $Va = [1, 18], $Vb = [1, 24], $Vc = [1, 25], $Vd = [1, 26], $Ve = [1, 27], $Vf = [1, 28], $Vg = [1, 29], $Vh = [1, 30], $Vi = [1, 31], $Vj = [1, 32], $Vk = [1, 33], $Vl = [1, 34], $Vm = [1, 35], $Vn = [1, 36], $Vo = [1, 37], $Vp = [1, 38], $Vq = [1, 39], $Vr = [1, 41], $Vs = [1, 42], $Vt = [1, 43], $Vu = [1, 44], $Vv = [1, 45], $Vw = [1, 46], $Vx = [1, 4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], $Vy = [4, 5, 16, 50, 52, 53], $Vz = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VA = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 49, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VB = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 48, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VC = [4, 5, 13, 14, 16, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 47, 50, 52, 53, 54, 59, 60, 61, 62, 70], $VD = [68, 69, 70], $VE = [1, 120]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SPACE": 4, "NEWLINE": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "box_section": 10, "box_line": 11, "participant_statement": 12, "create": 13, "box": 14, "restOfLine": 15, "end": 16, "signal": 17, "autonumber": 18, "NUM": 19, "off": 20, "activate": 21, "actor": 22, "deactivate": 23, "note_statement": 24, "links_statement": 25, "link_statement": 26, "properties_statement": 27, "details_statement": 28, "title": 29, "legacy_title": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "loop": 36, "rect": 37, "opt": 38, "alt": 39, "else_sections": 40, "par": 41, "par_sections": 42, "par_over": 43, "critical": 44, "option_sections": 45, "break": 46, "option": 47, "and": 48, "else": 49, "participant": 50, "AS": 51, "participant_actor": 52, "destroy": 53, "note": 54, "placement": 55, "text2": 56, "over": 57, "actor_pair": 58, "links": 59, "link": 60, "properties": 61, "details": 62, "spaceList": 63, ",": 64, "left_of": 65, "right_of": 66, "signaltype": 67, "+": 68, "-": 69, "ACTOR": 70, "SOLID_OPEN_ARROW": 71, "DOTTED_OPEN_ARROW": 72, "SOLID_ARROW": 73, "DOTTED_ARROW": 74, "SOLID_CROSS": 75, "DOTTED_CROSS": 76, "SOLID_POINT": 77, "DOTTED_POINT": 78, "TXT": 79, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACE", 5: "NEWLINE", 6: "SD", 13: "create", 14: "box", 15: "restOfLine", 16: "end", 18: "autonumber", 19: "NUM", 20: "off", 21: "activate", 23: "deactivate", 29: "title", 30: "legacy_title", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 36: "loop", 37: "rect", 38: "opt", 39: "alt", 41: "par", 43: "par_over", 44: "critical", 46: "break", 47: "option", 48: "and", 49: "else", 50: "participant", 51: "AS", 52: "participant_actor", 53: "destroy", 54: "note", 57: "over", 59: "links", 60: "link", 61: "properties", 62: "details", 64: ",", 65: "left_of", 66: "right_of", 68: "+", 69: "-", 70: "ACTOR", 71: "SOLID_OPEN_ARROW", 72: "DOTTED_OPEN_ARROW", 73: "SOLID_ARROW", 74: "DOTTED_ARROW", 75: "SOLID_CROSS", 76: "DOTTED_CROSS", 77: "SOLID_POINT", 78: "DOTTED_POINT", 79: "TXT" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [10, 0], [10, 2], [11, 2], [11, 1], [11, 1], [9, 1], [9, 2], [9, 4], [9, 2], [9, 4], [9, 3], [9, 3], [9, 2], [9, 3], [9, 3], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [9, 4], [45, 1], [45, 4], [42, 1], [42, 4], [40, 1], [40, 4], [12, 5], [12, 3], [12, 5], [12, 3], [12, 3], [24, 4], [24, 4], [25, 3], [26, 3], [27, 3], [28, 3], [63, 2], [63, 1], [58, 3], [58, 1], [55, 1], [55, 1], [17, 5], [17, 5], [17, 4], [22, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [67, 1], [56, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.apply($$[$0]); + return $$[$0]; + case 4: + case 9: + this.$ = []; + break; + case 5: + case 10: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 6: + case 7: + case 11: + case 12: + this.$ = $$[$0]; + break; + case 8: + case 13: + this.$ = []; + break; + case 15: + $$[$0].type = "createParticipant"; + this.$ = $$[$0]; + break; + case 16: + $$[$0 - 1].unshift({ type: "boxStart", boxData: yy.parseBoxData($$[$0 - 2]) }); + $$[$0 - 1].push({ type: "boxEnd", boxText: $$[$0 - 2] }); + this.$ = $$[$0 - 1]; + break; + case 18: + this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 2]), sequenceIndexStep: Number($$[$0 - 1]), sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 19: + this.$ = { type: "sequenceIndex", sequenceIndex: Number($$[$0 - 1]), sequenceIndexStep: 1, sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 20: + this.$ = { type: "sequenceIndex", sequenceVisible: false, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 21: + this.$ = { type: "sequenceIndex", sequenceVisible: true, signalType: yy.LINETYPE.AUTONUMBER }; + break; + case 22: + this.$ = { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] }; + break; + case 23: + this.$ = { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 1] }; + break; + case 29: + yy.setDiagramTitle($$[$0].substring(6)); + this.$ = $$[$0].substring(6); + break; + case 30: + yy.setDiagramTitle($$[$0].substring(7)); + this.$ = $$[$0].substring(7); + break; + case 31: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 32: + case 33: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 34: + $$[$0 - 1].unshift({ type: "loopStart", loopText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.LOOP_START }); + $$[$0 - 1].push({ type: "loopEnd", loopText: $$[$0 - 2], signalType: yy.LINETYPE.LOOP_END }); + this.$ = $$[$0 - 1]; + break; + case 35: + $$[$0 - 1].unshift({ type: "rectStart", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_START }); + $$[$0 - 1].push({ type: "rectEnd", color: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.RECT_END }); + this.$ = $$[$0 - 1]; + break; + case 36: + $$[$0 - 1].unshift({ type: "optStart", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_START }); + $$[$0 - 1].push({ type: "optEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.OPT_END }); + this.$ = $$[$0 - 1]; + break; + case 37: + $$[$0 - 1].unshift({ type: "altStart", altText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.ALT_START }); + $$[$0 - 1].push({ type: "altEnd", signalType: yy.LINETYPE.ALT_END }); + this.$ = $$[$0 - 1]; + break; + case 38: + $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_START }); + $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END }); + this.$ = $$[$0 - 1]; + break; + case 39: + $$[$0 - 1].unshift({ type: "parStart", parText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.PAR_OVER_START }); + $$[$0 - 1].push({ type: "parEnd", signalType: yy.LINETYPE.PAR_END }); + this.$ = $$[$0 - 1]; + break; + case 40: + $$[$0 - 1].unshift({ type: "criticalStart", criticalText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.CRITICAL_START }); + $$[$0 - 1].push({ type: "criticalEnd", signalType: yy.LINETYPE.CRITICAL_END }); + this.$ = $$[$0 - 1]; + break; + case 41: + $$[$0 - 1].unshift({ type: "breakStart", breakText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_START }); + $$[$0 - 1].push({ type: "breakEnd", optText: yy.parseMessage($$[$0 - 2]), signalType: yy.LINETYPE.BREAK_END }); + this.$ = $$[$0 - 1]; + break; + case 43: + this.$ = $$[$0 - 3].concat([{ type: "option", optionText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.CRITICAL_OPTION }, $$[$0]]); + break; + case 45: + this.$ = $$[$0 - 3].concat([{ type: "and", parText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.PAR_AND }, $$[$0]]); + break; + case 47: + this.$ = $$[$0 - 3].concat([{ type: "else", altText: yy.parseMessage($$[$0 - 1]), signalType: yy.LINETYPE.ALT_ELSE }, $$[$0]]); + break; + case 48: + $$[$0 - 3].draw = "participant"; + $$[$0 - 3].type = "addParticipant"; + $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]); + this.$ = $$[$0 - 3]; + break; + case 49: + $$[$0 - 1].draw = "participant"; + $$[$0 - 1].type = "addParticipant"; + this.$ = $$[$0 - 1]; + break; + case 50: + $$[$0 - 3].draw = "actor"; + $$[$0 - 3].type = "addParticipant"; + $$[$0 - 3].description = yy.parseMessage($$[$0 - 1]); + this.$ = $$[$0 - 3]; + break; + case 51: + $$[$0 - 1].draw = "actor"; + $$[$0 - 1].type = "addParticipant"; + this.$ = $$[$0 - 1]; + break; + case 52: + $$[$0 - 1].type = "destroyParticipant"; + this.$ = $$[$0 - 1]; + break; + case 53: + this.$ = [$$[$0 - 1], { type: "addNote", placement: $$[$0 - 2], actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 54: + $$[$0 - 2] = [].concat($$[$0 - 1], $$[$0 - 1]).slice(0, 2); + $$[$0 - 2][0] = $$[$0 - 2][0].actor; + $$[$0 - 2][1] = $$[$0 - 2][1].actor; + this.$ = [$$[$0 - 1], { type: "addNote", placement: yy.PLACEMENT.OVER, actor: $$[$0 - 2].slice(0, 2), text: $$[$0] }]; + break; + case 55: + this.$ = [$$[$0 - 1], { type: "addLinks", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 56: + this.$ = [$$[$0 - 1], { type: "addALink", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 57: + this.$ = [$$[$0 - 1], { type: "addProperties", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 58: + this.$ = [$$[$0 - 1], { type: "addDetails", actor: $$[$0 - 1].actor, text: $$[$0] }]; + break; + case 61: + this.$ = [$$[$0 - 2], $$[$0]]; + break; + case 62: + this.$ = $$[$0]; + break; + case 63: + this.$ = yy.PLACEMENT.LEFTOF; + break; + case 64: + this.$ = yy.PLACEMENT.RIGHTOF; + break; + case 65: + this.$ = [ + $$[$0 - 4], + $$[$0 - 1], + { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0], activate: true }, + { type: "activeStart", signalType: yy.LINETYPE.ACTIVE_START, actor: $$[$0 - 1] } + ]; + break; + case 66: + this.$ = [ + $$[$0 - 4], + $$[$0 - 1], + { type: "addMessage", from: $$[$0 - 4].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 3], msg: $$[$0] }, + { type: "activeEnd", signalType: yy.LINETYPE.ACTIVE_END, actor: $$[$0 - 4] } + ]; + break; + case 67: + this.$ = [$$[$0 - 3], $$[$0 - 1], { type: "addMessage", from: $$[$0 - 3].actor, to: $$[$0 - 1].actor, signalType: $$[$0 - 2], msg: $$[$0] }]; + break; + case 68: + this.$ = { type: "addParticipant", actor: $$[$0] }; + break; + case 69: + this.$ = yy.LINETYPE.SOLID_OPEN; + break; + case 70: + this.$ = yy.LINETYPE.DOTTED_OPEN; + break; + case 71: + this.$ = yy.LINETYPE.SOLID; + break; + case 72: + this.$ = yy.LINETYPE.DOTTED; + break; + case 73: + this.$ = yy.LINETYPE.SOLID_CROSS; + break; + case 74: + this.$ = yy.LINETYPE.DOTTED_CROSS; + break; + case 75: + this.$ = yy.LINETYPE.SOLID_POINT; + break; + case 76: + this.$ = yy.LINETYPE.DOTTED_POINT; + break; + case 77: + this.$ = yy.parseMessage($$[$0].trim().substring(1)); + break; + } + }, + table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 13, 14, 18, 21, 23, 29, 30, 31, 33, 35, 36, 37, 38, 39, 41, 43, 44, 46, 50, 52, 53, 54, 59, 60, 61, 62, 70], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, o($Vx, [2, 5]), { 9: 47, 12: 12, 13: $V6, 14: $V7, 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, o($Vx, [2, 7]), o($Vx, [2, 8]), o($Vx, [2, 14]), { 12: 48, 50: $Vo, 52: $Vp, 53: $Vq }, { 15: [1, 49] }, { 5: [1, 50] }, { 5: [1, 53], 19: [1, 51], 20: [1, 52] }, { 22: 54, 70: $Vw }, { 22: 55, 70: $Vw }, { 5: [1, 56] }, { 5: [1, 57] }, { 5: [1, 58] }, { 5: [1, 59] }, { 5: [1, 60] }, o($Vx, [2, 29]), o($Vx, [2, 30]), { 32: [1, 61] }, { 34: [1, 62] }, o($Vx, [2, 33]), { 15: [1, 63] }, { 15: [1, 64] }, { 15: [1, 65] }, { 15: [1, 66] }, { 15: [1, 67] }, { 15: [1, 68] }, { 15: [1, 69] }, { 15: [1, 70] }, { 22: 71, 70: $Vw }, { 22: 72, 70: $Vw }, { 22: 73, 70: $Vw }, { 67: 74, 71: [1, 75], 72: [1, 76], 73: [1, 77], 74: [1, 78], 75: [1, 79], 76: [1, 80], 77: [1, 81], 78: [1, 82] }, { 55: 83, 57: [1, 84], 65: [1, 85], 66: [1, 86] }, { 22: 87, 70: $Vw }, { 22: 88, 70: $Vw }, { 22: 89, 70: $Vw }, { 22: 90, 70: $Vw }, o([5, 51, 64, 71, 72, 73, 74, 75, 76, 77, 78, 79], [2, 68]), o($Vx, [2, 6]), o($Vx, [2, 15]), o($Vy, [2, 9], { 10: 91 }), o($Vx, [2, 17]), { 5: [1, 93], 19: [1, 92] }, { 5: [1, 94] }, o($Vx, [2, 21]), { 5: [1, 95] }, { 5: [1, 96] }, o($Vx, [2, 24]), o($Vx, [2, 25]), o($Vx, [2, 26]), o($Vx, [2, 27]), o($Vx, [2, 28]), o($Vx, [2, 31]), o($Vx, [2, 32]), o($Vz, $V3, { 7: 97 }), o($Vz, $V3, { 7: 98 }), o($Vz, $V3, { 7: 99 }), o($VA, $V3, { 40: 100, 7: 101 }), o($VB, $V3, { 42: 102, 7: 103 }), o($VB, $V3, { 7: 103, 42: 104 }), o($VC, $V3, { 45: 105, 7: 106 }), o($Vz, $V3, { 7: 107 }), { 5: [1, 109], 51: [1, 108] }, { 5: [1, 111], 51: [1, 110] }, { 5: [1, 112] }, { 22: 115, 68: [1, 113], 69: [1, 114], 70: $Vw }, o($VD, [2, 69]), o($VD, [2, 70]), o($VD, [2, 71]), o($VD, [2, 72]), o($VD, [2, 73]), o($VD, [2, 74]), o($VD, [2, 75]), o($VD, [2, 76]), { 22: 116, 70: $Vw }, { 22: 118, 58: 117, 70: $Vw }, { 70: [2, 63] }, { 70: [2, 64] }, { 56: 119, 79: $VE }, { 56: 121, 79: $VE }, { 56: 122, 79: $VE }, { 56: 123, 79: $VE }, { 4: [1, 126], 5: [1, 128], 11: 125, 12: 127, 16: [1, 124], 50: $Vo, 52: $Vp, 53: $Vq }, { 5: [1, 129] }, o($Vx, [2, 19]), o($Vx, [2, 20]), o($Vx, [2, 22]), o($Vx, [2, 23]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 130], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 131], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 132], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 133] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 46], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 49: [1, 134], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 135] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 44], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 48: [1, 136], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 16: [1, 137] }, { 16: [1, 138] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [2, 42], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 47: [1, 139], 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 12: 12, 13: $V6, 14: $V7, 16: [1, 140], 17: 15, 18: $V8, 21: $V9, 22: 40, 23: $Va, 24: 19, 25: 20, 26: 21, 27: 22, 28: 23, 29: $Vb, 30: $Vc, 31: $Vd, 33: $Ve, 35: $Vf, 36: $Vg, 37: $Vh, 38: $Vi, 39: $Vj, 41: $Vk, 43: $Vl, 44: $Vm, 46: $Vn, 50: $Vo, 52: $Vp, 53: $Vq, 54: $Vr, 59: $Vs, 60: $Vt, 61: $Vu, 62: $Vv, 70: $Vw }, { 15: [1, 141] }, o($Vx, [2, 49]), { 15: [1, 142] }, o($Vx, [2, 51]), o($Vx, [2, 52]), { 22: 143, 70: $Vw }, { 22: 144, 70: $Vw }, { 56: 145, 79: $VE }, { 56: 146, 79: $VE }, { 56: 147, 79: $VE }, { 64: [1, 148], 79: [2, 62] }, { 5: [2, 55] }, { 5: [2, 77] }, { 5: [2, 56] }, { 5: [2, 57] }, { 5: [2, 58] }, o($Vx, [2, 16]), o($Vy, [2, 10]), { 12: 149, 50: $Vo, 52: $Vp, 53: $Vq }, o($Vy, [2, 12]), o($Vy, [2, 13]), o($Vx, [2, 18]), o($Vx, [2, 34]), o($Vx, [2, 35]), o($Vx, [2, 36]), o($Vx, [2, 37]), { 15: [1, 150] }, o($Vx, [2, 38]), { 15: [1, 151] }, o($Vx, [2, 39]), o($Vx, [2, 40]), { 15: [1, 152] }, o($Vx, [2, 41]), { 5: [1, 153] }, { 5: [1, 154] }, { 56: 155, 79: $VE }, { 56: 156, 79: $VE }, { 5: [2, 67] }, { 5: [2, 53] }, { 5: [2, 54] }, { 22: 157, 70: $Vw }, o($Vy, [2, 11]), o($VA, $V3, { 7: 101, 40: 158 }), o($VB, $V3, { 7: 103, 42: 159 }), o($VC, $V3, { 7: 106, 45: 160 }), o($Vx, [2, 48]), o($Vx, [2, 50]), { 5: [2, 65] }, { 5: [2, 66] }, { 79: [2, 61] }, { 16: [2, 47] }, { 16: [2, 45] }, { 16: [2, 43] }], + defaultActions: { 5: [2, 1], 6: [2, 2], 85: [2, 63], 86: [2, 64], 119: [2, 55], 120: [2, 77], 121: [2, 56], 122: [2, 57], 123: [2, 58], 145: [2, 67], 146: [2, 53], 147: [2, 54], 155: [2, 65], 156: [2, 66], 157: [2, 61], 158: [2, 47], 159: [2, 45], 160: [2, 43] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state2, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state2 = stack[stack.length - 1]; + if (this.defaultActions[state2]) { + action = this.defaultActions[state2]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state2] && table[state2][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state2]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state2 + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 5; + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + break; + case 6: + return 19; + case 7: + this.begin("LINE"); + return 14; + case 8: + this.begin("ID"); + return 50; + case 9: + this.begin("ID"); + return 52; + case 10: + return 13; + case 11: + this.begin("ID"); + return 53; + case 12: + yy_.yytext = yy_.yytext.trim(); + this.begin("ALIAS"); + return 70; + case 13: + this.popState(); + this.popState(); + this.begin("LINE"); + return 51; + case 14: + this.popState(); + this.popState(); + return 5; + case 15: + this.begin("LINE"); + return 36; + case 16: + this.begin("LINE"); + return 37; + case 17: + this.begin("LINE"); + return 38; + case 18: + this.begin("LINE"); + return 39; + case 19: + this.begin("LINE"); + return 49; + case 20: + this.begin("LINE"); + return 41; + case 21: + this.begin("LINE"); + return 43; + case 22: + this.begin("LINE"); + return 48; + case 23: + this.begin("LINE"); + return 44; + case 24: + this.begin("LINE"); + return 47; + case 25: + this.begin("LINE"); + return 46; + case 26: + this.popState(); + return 15; + case 27: + return 16; + case 28: + return 65; + case 29: + return 66; + case 30: + return 59; + case 31: + return 60; + case 32: + return 61; + case 33: + return 62; + case 34: + return 57; + case 35: + return 54; + case 36: + this.begin("ID"); + return 21; + case 37: + this.begin("ID"); + return 23; + case 38: + return 29; + case 39: + return 30; + case 40: + this.begin("acc_title"); + return 31; + case 41: + this.popState(); + return "acc_title_value"; + case 42: + this.begin("acc_descr"); + return 33; + case 43: + this.popState(); + return "acc_descr_value"; + case 44: + this.begin("acc_descr_multiline"); + break; + case 45: + this.popState(); + break; + case 46: + return "acc_descr_multiline_value"; + case 47: + return 6; + case 48: + return 18; + case 49: + return 20; + case 50: + return 64; + case 51: + return 5; + case 52: + yy_.yytext = yy_.yytext.trim(); + return 70; + case 53: + return 73; + case 54: + return 74; + case 55: + return 71; + case 56: + return 72; + case 57: + return 75; + case 58: + return 76; + case 59: + return 77; + case 60: + return 78; + case 61: + return 79; + case 62: + return 68; + case 63: + return 69; + case 64: + return 5; + case 65: + return "INVALID"; + } + }, + rules: [/^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[0-9]+(?=[ \n]+))/i, /^(?:box\b)/i, /^(?:participant\b)/i, /^(?:actor\b)/i, /^(?:create\b)/i, /^(?:destroy\b)/i, /^(?:[^\->:\n,;]+?([\-]*[^\->:\n,;]+?)*?(?=((?!\n)\s)+as(?!\n)\s|[#\n;]|$))/i, /^(?:as\b)/i, /^(?:(?:))/i, /^(?:loop\b)/i, /^(?:rect\b)/i, /^(?:opt\b)/i, /^(?:alt\b)/i, /^(?:else\b)/i, /^(?:par\b)/i, /^(?:par_over\b)/i, /^(?:and\b)/i, /^(?:critical\b)/i, /^(?:option\b)/i, /^(?:break\b)/i, /^(?:(?:[:]?(?:no)?wrap)?[^#\n;]*)/i, /^(?:end\b)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:links\b)/i, /^(?:link\b)/i, /^(?:properties\b)/i, /^(?:details\b)/i, /^(?:over\b)/i, /^(?:note\b)/i, /^(?:activate\b)/i, /^(?:deactivate\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:title:\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:sequenceDiagram\b)/i, /^(?:autonumber\b)/i, /^(?:off\b)/i, /^(?:,)/i, /^(?:;)/i, /^(?:[^\+\->:\n,;]+((?!(-x|--x|-\)|--\)))[\-]*[^\+\->:\n,;]+)*)/i, /^(?:->>)/i, /^(?:-->>)/i, /^(?:->)/i, /^(?:-->)/i, /^(?:-[x])/i, /^(?:--[x])/i, /^(?:-[\)])/i, /^(?:--[\)])/i, /^(?::(?:(?:no)?wrap)?[^#\n;]+)/i, /^(?:\+)/i, /^(?:-)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [45, 46], "inclusive": false }, "acc_descr": { "rules": [43], "inclusive": false }, "acc_title": { "rules": [41], "inclusive": false }, "ID": { "rules": [2, 3, 12], "inclusive": false }, "ALIAS": { "rules": [2, 3, 13, 14], "inclusive": false }, "LINE": { "rules": [2, 3, 26], "inclusive": false }, "INITIAL": { "rules": [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +class ImperativeState { + /** + * @param init - Function that creates the default state. + */ + constructor(init) { + this.init = init; + this.records = this.init(); + } + reset() { + this.records = this.init(); + } +} +const state = new ImperativeState(() => ({ + prevActor: void 0, + actors: {}, + createdActors: {}, + destroyedActors: {}, + boxes: [], + messages: [], + notes: [], + sequenceNumbersEnabled: false, + wrapEnabled: void 0, + currentBox: void 0, + lastCreated: void 0, + lastDestroyed: void 0 +})); +const addBox = function(data) { + state.records.boxes.push({ + name: data.text, + wrap: data.wrap === void 0 && autoWrap() || !!data.wrap, + fill: data.color, + actorKeys: [] + }); + state.records.currentBox = state.records.boxes.slice(-1)[0]; +}; +const addActor = function(id, name, description, type) { + let assignedBox = state.records.currentBox; + const old = state.records.actors[id]; + if (old) { + if (state.records.currentBox && old.box && state.records.currentBox !== old.box) { + throw new Error( + "A same participant should only be defined in one Box: " + old.name + " can't be in '" + old.box.name + "' and in '" + state.records.currentBox.name + "' at the same time." + ); + } + assignedBox = old.box ? old.box : state.records.currentBox; + old.box = assignedBox; + if (old && name === old.name && description == null) { + return; + } + } + if (description == null || description.text == null) { + description = { text: name, wrap: null, type }; + } + if (type == null || description.text == null) { + description = { text: name, wrap: null, type }; + } + state.records.actors[id] = { + box: assignedBox, + name, + description: description.text, + wrap: description.wrap === void 0 && autoWrap() || !!description.wrap, + prevActor: state.records.prevActor, + links: {}, + properties: {}, + actorCnt: null, + rectData: null, + type: type || "participant" + }; + if (state.records.prevActor && state.records.actors[state.records.prevActor]) { + state.records.actors[state.records.prevActor].nextActor = id; + } + if (state.records.currentBox) { + state.records.currentBox.actorKeys.push(id); + } + state.records.prevActor = id; +}; +const activationCount = (part) => { + let i; + let count = 0; + for (i = 0; i < state.records.messages.length; i++) { + if (state.records.messages[i].type === LINETYPE.ACTIVE_START && state.records.messages[i].from.actor === part) { + count++; + } + if (state.records.messages[i].type === LINETYPE.ACTIVE_END && state.records.messages[i].from.actor === part) { + count--; + } + } + return count; +}; +const addMessage = function(idFrom, idTo, message, answer) { + state.records.messages.push({ + from: idFrom, + to: idTo, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + answer + }); +}; +const addSignal = function(idFrom, idTo, message = { text: void 0, wrap: void 0 }, messageType, activate = false) { + if (messageType === LINETYPE.ACTIVE_END) { + const cnt = activationCount(idFrom.actor); + if (cnt < 1) { + let error = new Error("Trying to inactivate an inactive participant (" + idFrom.actor + ")"); + error.hash = { + text: "->>-", + token: "->>-", + line: "1", + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ["'ACTIVE_PARTICIPANT'"] + }; + throw error; + } + } + state.records.messages.push({ + from: idFrom, + to: idTo, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + type: messageType, + activate + }); + return true; +}; +const hasAtLeastOneBox = function() { + return state.records.boxes.length > 0; +}; +const hasAtLeastOneBoxWithTitle = function() { + return state.records.boxes.some((b) => b.name); +}; +const getMessages = function() { + return state.records.messages; +}; +const getBoxes = function() { + return state.records.boxes; +}; +const getActors = function() { + return state.records.actors; +}; +const getCreatedActors = function() { + return state.records.createdActors; +}; +const getDestroyedActors = function() { + return state.records.destroyedActors; +}; +const getActor = function(id) { + return state.records.actors[id]; +}; +const getActorKeys = function() { + return Object.keys(state.records.actors); +}; +const enableSequenceNumbers = function() { + state.records.sequenceNumbersEnabled = true; +}; +const disableSequenceNumbers = function() { + state.records.sequenceNumbersEnabled = false; +}; +const showSequenceNumbers = () => state.records.sequenceNumbersEnabled; +const setWrap = function(wrapSetting) { + state.records.wrapEnabled = wrapSetting; +}; +const autoWrap = () => { + if (state.records.wrapEnabled !== void 0) { + return state.records.wrapEnabled; + } + return getConfig().sequence.wrap; +}; +const clear = function() { + state.reset(); + clear$1(); +}; +const parseMessage = function(str) { + const _str = str.trim(); + const message = { + text: _str.replace(/^:?(?:no)?wrap:/, "").trim(), + wrap: _str.match(/^:?wrap:/) !== null ? true : _str.match(/^:?nowrap:/) !== null ? false : void 0 + }; + log$1.debug("parseMessage:", message); + return message; +}; +const parseBoxData = function(str) { + const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/); + let color = match != null && match[1] ? match[1].trim() : "transparent"; + let title = match != null && match[2] ? match[2].trim() : void 0; + if (window && window.CSS) { + if (!window.CSS.supports("color", color)) { + color = "transparent"; + title = str.trim(); + } + } else { + const style = new Option().style; + style.color = color; + if (style.color !== color) { + color = "transparent"; + title = str.trim(); + } + } + return { + color, + text: title !== void 0 ? sanitizeText$2(title.replace(/^:?(?:no)?wrap:/, ""), getConfig()) : void 0, + wrap: title !== void 0 ? title.match(/^:?wrap:/) !== null ? true : title.match(/^:?nowrap:/) !== null ? false : void 0 : void 0 + }; +}; +const LINETYPE = { + SOLID: 0, + DOTTED: 1, + NOTE: 2, + SOLID_CROSS: 3, + DOTTED_CROSS: 4, + SOLID_OPEN: 5, + DOTTED_OPEN: 6, + LOOP_START: 10, + LOOP_END: 11, + ALT_START: 12, + ALT_ELSE: 13, + ALT_END: 14, + OPT_START: 15, + OPT_END: 16, + ACTIVE_START: 17, + ACTIVE_END: 18, + PAR_START: 19, + PAR_AND: 20, + PAR_END: 21, + RECT_START: 22, + RECT_END: 23, + SOLID_POINT: 24, + DOTTED_POINT: 25, + AUTONUMBER: 26, + CRITICAL_START: 27, + CRITICAL_OPTION: 28, + CRITICAL_END: 29, + BREAK_START: 30, + BREAK_END: 31, + PAR_OVER_START: 32 +}; +const ARROWTYPE = { + FILLED: 0, + OPEN: 1 +}; +const PLACEMENT = { + LEFTOF: 0, + RIGHTOF: 1, + OVER: 2 +}; +const addNote = function(actor, placement, message) { + const note = { + actor, + placement, + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap + }; + const actors = [].concat(actor, actor); + state.records.notes.push(note); + state.records.messages.push({ + from: actors[0], + to: actors[1], + message: message.text, + wrap: message.wrap === void 0 && autoWrap() || !!message.wrap, + type: LINETYPE.NOTE, + placement + }); +}; +const addLinks = function(actorId, text) { + const actor = getActor(actorId); + try { + let sanitizedText = sanitizeText$2(text.text, getConfig()); + sanitizedText = sanitizedText.replace(/&/g, "&"); + sanitizedText = sanitizedText.replace(/=/g, "="); + const links = JSON.parse(sanitizedText); + insertLinks(actor, links); + } catch (e) { + log$1.error("error while parsing actor link text", e); + } +}; +const addALink = function(actorId, text) { + const actor = getActor(actorId); + try { + const links = {}; + let sanitizedText = sanitizeText$2(text.text, getConfig()); + var sep = sanitizedText.indexOf("@"); + sanitizedText = sanitizedText.replace(/&/g, "&"); + sanitizedText = sanitizedText.replace(/=/g, "="); + var label = sanitizedText.slice(0, sep - 1).trim(); + var link = sanitizedText.slice(sep + 1).trim(); + links[label] = link; + insertLinks(actor, links); + } catch (e) { + log$1.error("error while parsing actor link text", e); + } +}; +function insertLinks(actor, links) { + if (actor.links == null) { + actor.links = links; + } else { + for (let key in links) { + actor.links[key] = links[key]; + } + } +} +const addProperties = function(actorId, text) { + const actor = getActor(actorId); + try { + let sanitizedText = sanitizeText$2(text.text, getConfig()); + const properties = JSON.parse(sanitizedText); + insertProperties(actor, properties); + } catch (e) { + log$1.error("error while parsing actor properties text", e); + } +}; +function insertProperties(actor, properties) { + if (actor.properties == null) { + actor.properties = properties; + } else { + for (let key in properties) { + actor.properties[key] = properties[key]; + } + } +} +function boxEnd() { + state.records.currentBox = void 0; +} +const addDetails = function(actorId, text) { + const actor = getActor(actorId); + const elem = document.getElementById(text.text); + try { + const text2 = elem.innerHTML; + const details = JSON.parse(text2); + if (details["properties"]) { + insertProperties(actor, details["properties"]); + } + if (details["links"]) { + insertLinks(actor, details["links"]); + } + } catch (e) { + log$1.error("error while parsing actor details text", e); + } +}; +const getActorProperty = function(actor, key) { + if (actor !== void 0 && actor.properties !== void 0) { + return actor.properties[key]; + } + return void 0; +}; +const apply = function(param) { + if (Array.isArray(param)) { + param.forEach(function(item) { + apply(item); + }); + } else { + switch (param.type) { + case "sequenceIndex": + state.records.messages.push({ + from: void 0, + to: void 0, + message: { + start: param.sequenceIndex, + step: param.sequenceIndexStep, + visible: param.sequenceVisible + }, + wrap: false, + type: param.signalType + }); + break; + case "addParticipant": + addActor(param.actor, param.actor, param.description, param.draw); + break; + case "createParticipant": + if (state.records.actors[param.actor]) { + throw new Error( + "It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior" + ); + } + state.records.lastCreated = param.actor; + addActor(param.actor, param.actor, param.description, param.draw); + state.records.createdActors[param.actor] = state.records.messages.length; + break; + case "destroyParticipant": + state.records.lastDestroyed = param.actor; + state.records.destroyedActors[param.actor] = state.records.messages.length; + break; + case "activeStart": + addSignal(param.actor, void 0, void 0, param.signalType); + break; + case "activeEnd": + addSignal(param.actor, void 0, void 0, param.signalType); + break; + case "addNote": + addNote(param.actor, param.placement, param.text); + break; + case "addLinks": + addLinks(param.actor, param.text); + break; + case "addALink": + addALink(param.actor, param.text); + break; + case "addProperties": + addProperties(param.actor, param.text); + break; + case "addDetails": + addDetails(param.actor, param.text); + break; + case "addMessage": + if (state.records.lastCreated) { + if (param.to !== state.records.lastCreated) { + throw new Error( + "The created participant " + state.records.lastCreated + " does not have an associated creating message after its declaration. Please check the sequence diagram." + ); + } else { + state.records.lastCreated = void 0; + } + } else if (state.records.lastDestroyed) { + if (param.to !== state.records.lastDestroyed && param.from !== state.records.lastDestroyed) { + throw new Error( + "The destroyed participant " + state.records.lastDestroyed + " does not have an associated destroying message after its declaration. Please check the sequence diagram." + ); + } else { + state.records.lastDestroyed = void 0; + } + } + addSignal(param.from, param.to, param.msg, param.signalType, param.activate); + break; + case "boxStart": + addBox(param.boxData); + break; + case "boxEnd": + boxEnd(); + break; + case "loopStart": + addSignal(void 0, void 0, param.loopText, param.signalType); + break; + case "loopEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "rectStart": + addSignal(void 0, void 0, param.color, param.signalType); + break; + case "rectEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "optStart": + addSignal(void 0, void 0, param.optText, param.signalType); + break; + case "optEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "altStart": + addSignal(void 0, void 0, param.altText, param.signalType); + break; + case "else": + addSignal(void 0, void 0, param.altText, param.signalType); + break; + case "altEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "setAccTitle": + setAccTitle(param.text); + break; + case "parStart": + addSignal(void 0, void 0, param.parText, param.signalType); + break; + case "and": + addSignal(void 0, void 0, param.parText, param.signalType); + break; + case "parEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "criticalStart": + addSignal(void 0, void 0, param.criticalText, param.signalType); + break; + case "option": + addSignal(void 0, void 0, param.optionText, param.signalType); + break; + case "criticalEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + case "breakStart": + addSignal(void 0, void 0, param.breakText, param.signalType); + break; + case "breakEnd": + addSignal(void 0, void 0, void 0, param.signalType); + break; + } + } +}; +const db = { + addActor, + addMessage, + addSignal, + addLinks, + addDetails, + addProperties, + autoWrap, + setWrap, + enableSequenceNumbers, + disableSequenceNumbers, + showSequenceNumbers, + getMessages, + getActors, + getCreatedActors, + getDestroyedActors, + getActor, + getActorKeys, + getActorProperty, + getAccTitle, + getBoxes, + getDiagramTitle, + setDiagramTitle, + getConfig: () => getConfig().sequence, + clear, + parseMessage, + parseBoxData, + LINETYPE, + ARROWTYPE, + PLACEMENT, + addNote, + setAccTitle, + apply, + setAccDescription, + getAccDescription, + hasAtLeastOneBox, + hasAtLeastOneBoxWithTitle +}; +const getStyles = (options) => `.actor { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + } + + text.actor > tspan { + fill: ${options.actorTextColor}; + stroke: none; + } + + .actor-line { + stroke: ${options.actorLineColor}; + } + + .messageLine0 { + stroke-width: 1.5; + stroke-dasharray: none; + stroke: ${options.signalColor}; + } + + .messageLine1 { + stroke-width: 1.5; + stroke-dasharray: 2, 2; + stroke: ${options.signalColor}; + } + + #arrowhead path { + fill: ${options.signalColor}; + stroke: ${options.signalColor}; + } + + .sequenceNumber { + fill: ${options.sequenceNumberColor}; + } + + #sequencenumber { + fill: ${options.signalColor}; + } + + #crosshead path { + fill: ${options.signalColor}; + stroke: ${options.signalColor}; + } + + .messageText { + fill: ${options.signalTextColor}; + stroke: none; + } + + .labelBox { + stroke: ${options.labelBoxBorderColor}; + fill: ${options.labelBoxBkgColor}; + } + + .labelText, .labelText > tspan { + fill: ${options.labelTextColor}; + stroke: none; + } + + .loopText, .loopText > tspan { + fill: ${options.loopTextColor}; + stroke: none; + } + + .loopLine { + stroke-width: 2px; + stroke-dasharray: 2, 2; + stroke: ${options.labelBoxBorderColor}; + fill: ${options.labelBoxBorderColor}; + } + + .note { + //stroke: #decc93; + stroke: ${options.noteBorderColor}; + fill: ${options.noteBkgColor}; + } + + .noteText, .noteText > tspan { + fill: ${options.noteTextColor}; + stroke: none; + } + + .activation0 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .activation1 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .activation2 { + fill: ${options.activationBkgColor}; + stroke: ${options.activationBorderColor}; + } + + .actorPopupMenu { + position: absolute; + } + + .actorPopupMenuPanel { + position: absolute; + fill: ${options.actorBkg}; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4)); +} + .actor-man line { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + } + .actor-man circle, line { + stroke: ${options.actorBorder}; + fill: ${options.actorBkg}; + stroke-width: 2px; + } +`; +const styles = getStyles; +const ACTOR_TYPE_WIDTH = 18 * 2; +const TOP_ACTOR_CLASS = "actor-top"; +const BOTTOM_ACTOR_CLASS = "actor-bottom"; +const drawRect = function(elem, rectData) { + return drawRect$1(elem, rectData); +}; +const drawPopup = function(elem, actor, minMenuWidth, textAttrs, forceMenus) { + if (actor.links === void 0 || actor.links === null || Object.keys(actor.links).length === 0) { + return { height: 0, width: 0 }; + } + const links = actor.links; + const actorCnt2 = actor.actorCnt; + const rectData = actor.rectData; + var displayValue = "none"; + if (forceMenus) { + displayValue = "block !important"; + } + const g = elem.append("g"); + g.attr("id", "actor" + actorCnt2 + "_popup"); + g.attr("class", "actorPopupMenu"); + g.attr("display", displayValue); + var actorClass = ""; + if (rectData.class !== void 0) { + actorClass = " " + rectData.class; + } + let menuWidth = rectData.width > minMenuWidth ? rectData.width : minMenuWidth; + const rectElem = g.append("rect"); + rectElem.attr("class", "actorPopupMenuPanel" + actorClass); + rectElem.attr("x", rectData.x); + rectElem.attr("y", rectData.height); + rectElem.attr("fill", rectData.fill); + rectElem.attr("stroke", rectData.stroke); + rectElem.attr("width", menuWidth); + rectElem.attr("height", rectData.height); + rectElem.attr("rx", rectData.rx); + rectElem.attr("ry", rectData.ry); + if (links != null) { + var linkY = 20; + for (let key in links) { + var linkElem = g.append("a"); + var sanitizedLink = dist.sanitizeUrl(links[key]); + linkElem.attr("xlink:href", sanitizedLink); + linkElem.attr("target", "_blank"); + _drawMenuItemTextCandidateFunc(textAttrs)( + key, + linkElem, + rectData.x + 10, + rectData.height + linkY, + menuWidth, + 20, + { class: "actor" }, + textAttrs + ); + linkY += 30; + } + } + rectElem.attr("height", linkY); + return { height: rectData.height + linkY, width: menuWidth }; +}; +const popupMenuToggle = function(popId) { + return "var pu = document.getElementById('" + popId + "'); if (pu != null) { pu.style.display = pu.style.display == 'block' ? 'none' : 'block'; }"; +}; +const drawKatex = async function(elem, textData, msgModel = null) { + let textElem = elem.append("foreignObject"); + const lines = await renderKatex(textData.text, getConfig$1()); + const divElem = textElem.append("xhtml:div").attr("style", "width: fit-content;").attr("xmlns", "http://www.w3.org/1999/xhtml").html(lines); + const dim = divElem.node().getBoundingClientRect(); + textElem.attr("height", Math.round(dim.height)).attr("width", Math.round(dim.width)); + if (textData.class === "noteText") { + const rectElem = elem.node().firstChild; + rectElem.setAttribute("height", dim.height + 2 * textData.textMargin); + const rectDim = rectElem.getBBox(); + textElem.attr("x", Math.round(rectDim.x + rectDim.width / 2 - dim.width / 2)).attr("y", Math.round(rectDim.y + rectDim.height / 2 - dim.height / 2)); + } else if (msgModel) { + let { startx, stopx, starty } = msgModel; + if (startx > stopx) { + const temp = startx; + startx = stopx; + stopx = temp; + } + textElem.attr("x", Math.round(startx + Math.abs(startx - stopx) / 2 - dim.width / 2)); + if (textData.class === "loopText") { + textElem.attr("y", Math.round(starty)); + } else { + textElem.attr("y", Math.round(starty - dim.height)); + } + } + return [textElem]; +}; +const drawText = function(elem, textData) { + let prevTextHeight = 0; + let textHeight = 0; + const lines = textData.text.split(common$1.lineBreakRegex); + const [_textFontSize, _textFontSizePx] = parseFontSize(textData.fontSize); + let textElems = []; + let dy = 0; + let yfunc = () => textData.y; + if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) { + switch (textData.valign) { + case "top": + case "start": + yfunc = () => Math.round(textData.y + textData.textMargin); + break; + case "middle": + case "center": + yfunc = () => Math.round(textData.y + (prevTextHeight + textHeight + textData.textMargin) / 2); + break; + case "bottom": + case "end": + yfunc = () => Math.round( + textData.y + (prevTextHeight + textHeight + 2 * textData.textMargin) - textData.textMargin + ); + break; + } + } + if (textData.anchor !== void 0 && textData.textMargin !== void 0 && textData.width !== void 0) { + switch (textData.anchor) { + case "left": + case "start": + textData.x = Math.round(textData.x + textData.textMargin); + textData.anchor = "start"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + case "middle": + case "center": + textData.x = Math.round(textData.x + textData.width / 2); + textData.anchor = "middle"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + case "right": + case "end": + textData.x = Math.round(textData.x + textData.width - textData.textMargin); + textData.anchor = "end"; + textData.dominantBaseline = "middle"; + textData.alignmentBaseline = "middle"; + break; + } + } + for (let [i, line] of lines.entries()) { + if (textData.textMargin !== void 0 && textData.textMargin === 0 && _textFontSize !== void 0) { + dy = i * _textFontSize; + } + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", yfunc()); + if (textData.anchor !== void 0) { + textElem.attr("text-anchor", textData.anchor).attr("dominant-baseline", textData.dominantBaseline).attr("alignment-baseline", textData.alignmentBaseline); + } + if (textData.fontFamily !== void 0) { + textElem.style("font-family", textData.fontFamily); + } + if (_textFontSizePx !== void 0) { + textElem.style("font-size", _textFontSizePx); + } + if (textData.fontWeight !== void 0) { + textElem.style("font-weight", textData.fontWeight); + } + if (textData.fill !== void 0) { + textElem.attr("fill", textData.fill); + } + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + if (textData.dy !== void 0) { + textElem.attr("dy", textData.dy); + } else if (dy !== 0) { + textElem.attr("dy", dy); + } + const text = line || ZERO_WIDTH_SPACE; + if (textData.tspan) { + const span = textElem.append("tspan"); + span.attr("x", textData.x); + if (textData.fill !== void 0) { + span.attr("fill", textData.fill); + } + span.text(text); + } else { + textElem.text(text); + } + if (textData.valign !== void 0 && textData.textMargin !== void 0 && textData.textMargin > 0) { + textHeight += (textElem._groups || textElem)[0][0].getBBox().height; + prevTextHeight = textHeight; + } + textElems.push(textElem); + } + return textElems; +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, txtObject.width, txtObject.height, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.height / 2; + drawText(elem, txtObject); + return polygon; +}; +let actorCnt = -1; +const fixLifeLineHeights = (diagram2, actors, actorKeys, conf2) => { + if (!diagram2.select) { + return; + } + actorKeys.forEach((actorKey) => { + const actor = actors[actorKey]; + const actorDOM = diagram2.select("#actor" + actor.actorCnt); + if (!conf2.mirrorActors && actor.stopy) { + actorDOM.attr("y2", actor.stopy + actor.height / 2); + } else if (conf2.mirrorActors) { + actorDOM.attr("y2", actor.stopy); + } + }); +}; +const drawActorTypeParticipant = async function(elem, actor, conf2, isFooter) { + const actorY = isFooter ? actor.stopy : actor.starty; + const center = actor.x + actor.width / 2; + const centerY = actorY + 5; + const boxplusLineGroup = elem.append("g").lower(); + var g = boxplusLineGroup; + if (!isFooter) { + actorCnt++; + if (Object.keys(actor.links || {}).length && !conf2.forceMenus) { + g.attr("onclick", popupMenuToggle(`actor${actorCnt}_popup`)).attr("cursor", "pointer"); + } + g.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"); + g = boxplusLineGroup.append("g"); + actor.actorCnt = actorCnt; + if (actor.links != null) { + g.attr("id", "root-" + actorCnt); + } + } + const rect = getNoteRect$1(); + var cssclass = "actor"; + if (actor.properties != null && actor.properties["class"]) { + cssclass = actor.properties["class"]; + } else { + rect.fill = "#eaeaea"; + } + if (isFooter) { + cssclass += ` ${BOTTOM_ACTOR_CLASS}`; + } else { + cssclass += ` ${TOP_ACTOR_CLASS}`; + } + rect.x = actor.x; + rect.y = actorY; + rect.width = actor.width; + rect.height = actor.height; + rect.class = cssclass; + rect.rx = 3; + rect.ry = 3; + rect.name = actor.name; + const rectElem = drawRect(g, rect); + actor.rectData = rect; + if (actor.properties != null && actor.properties["icon"]) { + const iconSrc = actor.properties["icon"].trim(); + if (iconSrc.charAt(0) === "@") { + drawEmbeddedImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc.substr(1)); + } else { + drawImage(g, rect.x + rect.width - 20, rect.y + 10, iconSrc); + } + } + await _drawTextCandidateFunc(conf2, hasKatex(actor.description))( + actor.description, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "actor" }, + conf2 + ); + let height = actor.height; + if (rectElem.node) { + const bounds2 = rectElem.node().getBBox(); + actor.height = bounds2.height; + height = bounds2.height; + } + return height; +}; +const drawActorTypeActor = async function(elem, actor, conf2, isFooter) { + const actorY = isFooter ? actor.stopy : actor.starty; + const center = actor.x + actor.width / 2; + const centerY = actorY + 80; + elem.lower(); + if (!isFooter) { + actorCnt++; + elem.append("line").attr("id", "actor" + actorCnt).attr("x1", center).attr("y1", centerY).attr("x2", center).attr("y2", 2e3).attr("class", "actor-line").attr("class", "200").attr("stroke-width", "0.5px").attr("stroke", "#999"); + actor.actorCnt = actorCnt; + } + const actElem = elem.append("g"); + let cssClass = "actor-man"; + if (isFooter) { + cssClass += ` ${BOTTOM_ACTOR_CLASS}`; + } else { + cssClass += ` ${TOP_ACTOR_CLASS}`; + } + actElem.attr("class", cssClass); + actElem.attr("name", actor.name); + const rect = getNoteRect$1(); + rect.x = actor.x; + rect.y = actorY; + rect.fill = "#eaeaea"; + rect.width = actor.width; + rect.height = actor.height; + rect.class = "actor"; + rect.rx = 3; + rect.ry = 3; + actElem.append("line").attr("id", "actor-man-torso" + actorCnt).attr("x1", center).attr("y1", actorY + 25).attr("x2", center).attr("y2", actorY + 45); + actElem.append("line").attr("id", "actor-man-arms" + actorCnt).attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 33).attr("x2", center + ACTOR_TYPE_WIDTH / 2).attr("y2", actorY + 33); + actElem.append("line").attr("x1", center - ACTOR_TYPE_WIDTH / 2).attr("y1", actorY + 60).attr("x2", center).attr("y2", actorY + 45); + actElem.append("line").attr("x1", center).attr("y1", actorY + 45).attr("x2", center + ACTOR_TYPE_WIDTH / 2 - 2).attr("y2", actorY + 60); + const circle = actElem.append("circle"); + circle.attr("cx", actor.x + actor.width / 2); + circle.attr("cy", actorY + 10); + circle.attr("r", 15); + circle.attr("width", actor.width); + circle.attr("height", actor.height); + const bounds2 = actElem.node().getBBox(); + actor.height = bounds2.height; + await _drawTextCandidateFunc(conf2, hasKatex(actor.description))( + actor.description, + actElem, + rect.x, + rect.y + 35, + rect.width, + rect.height, + { class: "actor" }, + conf2 + ); + return actor.height; +}; +const drawActor = async function(elem, actor, conf2, isFooter) { + switch (actor.type) { + case "actor": + return await drawActorTypeActor(elem, actor, conf2, isFooter); + case "participant": + return await drawActorTypeParticipant(elem, actor, conf2, isFooter); + } +}; +const drawBox = async function(elem, box, conf2) { + const boxplusTextGroup = elem.append("g"); + const g = boxplusTextGroup; + drawBackgroundRect(g, box); + if (box.name) { + await _drawTextCandidateFunc(conf2)( + box.name, + g, + box.x, + box.y + (box.textMaxHeight || 0) / 2, + box.width, + 0, + { class: "text" }, + conf2 + ); + } + g.lower(); +}; +const anchorElement = function(elem) { + return elem.append("g"); +}; +const drawActivation = function(elem, bounds2, verticalPos, conf2, actorActivations2) { + const rect = getNoteRect$1(); + const g = bounds2.anchored; + rect.x = bounds2.startx; + rect.y = bounds2.starty; + rect.class = "activation" + actorActivations2 % 3; + rect.width = bounds2.stopx - bounds2.startx; + rect.height = verticalPos - bounds2.starty; + drawRect(g, rect); +}; +const drawLoop = async function(elem, loopModel, labelText, conf2) { + const { + boxMargin, + boxTextMargin, + labelBoxHeight, + labelBoxWidth, + messageFontFamily: fontFamily, + messageFontSize: fontSize, + messageFontWeight: fontWeight + } = conf2; + const g = elem.append("g"); + const drawLoopLine = function(startx, starty, stopx, stopy) { + return g.append("line").attr("x1", startx).attr("y1", starty).attr("x2", stopx).attr("y2", stopy).attr("class", "loopLine"); + }; + drawLoopLine(loopModel.startx, loopModel.starty, loopModel.stopx, loopModel.starty); + drawLoopLine(loopModel.stopx, loopModel.starty, loopModel.stopx, loopModel.stopy); + drawLoopLine(loopModel.startx, loopModel.stopy, loopModel.stopx, loopModel.stopy); + drawLoopLine(loopModel.startx, loopModel.starty, loopModel.startx, loopModel.stopy); + if (loopModel.sections !== void 0) { + loopModel.sections.forEach(function(item) { + drawLoopLine(loopModel.startx, item.y, loopModel.stopx, item.y).style( + "stroke-dasharray", + "3, 3" + ); + }); + } + let txt = getTextObj$1(); + txt.text = labelText; + txt.x = loopModel.startx; + txt.y = loopModel.starty; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.tspan = false; + txt.width = labelBoxWidth || 50; + txt.height = labelBoxHeight || 20; + txt.textMargin = boxTextMargin; + txt.class = "labelText"; + drawLabel(g, txt); + txt = getTextObj(); + txt.text = loopModel.title; + txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2; + txt.y = loopModel.starty + boxMargin + boxTextMargin; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.textMargin = boxTextMargin; + txt.class = "loopText"; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.wrap = true; + let textElem = hasKatex(txt.text) ? await drawKatex(g, txt, loopModel) : drawText(g, txt); + if (loopModel.sectionTitles !== void 0) { + for (const [idx, item] of Object.entries(loopModel.sectionTitles)) { + if (item.message) { + txt.text = item.message; + txt.x = loopModel.startx + (loopModel.stopx - loopModel.startx) / 2; + txt.y = loopModel.sections[idx].y + boxMargin + boxTextMargin; + txt.class = "loopText"; + txt.anchor = "middle"; + txt.valign = "middle"; + txt.tspan = false; + txt.fontFamily = fontFamily; + txt.fontSize = fontSize; + txt.fontWeight = fontWeight; + txt.wrap = loopModel.wrap; + if (hasKatex(txt.text)) { + loopModel.starty = loopModel.sections[idx].y; + await drawKatex(g, txt, loopModel); + } else { + drawText(g, txt); + } + let sectionHeight = Math.round( + textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr) + ); + loopModel.sections[idx].height += sectionHeight - (boxMargin + boxTextMargin); + } + } + } + loopModel.height = Math.round(loopModel.stopy - loopModel.starty); + return g; +}; +const drawBackgroundRect = function(elem, bounds2) { + drawBackgroundRect$1(elem, bounds2); +}; +const insertDatabaseIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "database").attr("fill-rule", "evenodd").attr("clip-rule", "evenodd").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12.258.001l.256.004.255.005.253.008.251.01.249.012.247.015.246.016.242.019.241.02.239.023.236.024.233.027.231.028.229.031.225.032.223.034.22.036.217.038.214.04.211.041.208.043.205.045.201.046.198.048.194.05.191.051.187.053.183.054.18.056.175.057.172.059.168.06.163.061.16.063.155.064.15.066.074.033.073.033.071.034.07.034.069.035.068.035.067.035.066.035.064.036.064.036.062.036.06.036.06.037.058.037.058.037.055.038.055.038.053.038.052.038.051.039.05.039.048.039.047.039.045.04.044.04.043.04.041.04.04.041.039.041.037.041.036.041.034.041.033.042.032.042.03.042.029.042.027.042.026.043.024.043.023.043.021.043.02.043.018.044.017.043.015.044.013.044.012.044.011.045.009.044.007.045.006.045.004.045.002.045.001.045v17l-.001.045-.002.045-.004.045-.006.045-.007.045-.009.044-.011.045-.012.044-.013.044-.015.044-.017.043-.018.044-.02.043-.021.043-.023.043-.024.043-.026.043-.027.042-.029.042-.03.042-.032.042-.033.042-.034.041-.036.041-.037.041-.039.041-.04.041-.041.04-.043.04-.044.04-.045.04-.047.039-.048.039-.05.039-.051.039-.052.038-.053.038-.055.038-.055.038-.058.037-.058.037-.06.037-.06.036-.062.036-.064.036-.064.036-.066.035-.067.035-.068.035-.069.035-.07.034-.071.034-.073.033-.074.033-.15.066-.155.064-.16.063-.163.061-.168.06-.172.059-.175.057-.18.056-.183.054-.187.053-.191.051-.194.05-.198.048-.201.046-.205.045-.208.043-.211.041-.214.04-.217.038-.22.036-.223.034-.225.032-.229.031-.231.028-.233.027-.236.024-.239.023-.241.02-.242.019-.246.016-.247.015-.249.012-.251.01-.253.008-.255.005-.256.004-.258.001-.258-.001-.256-.004-.255-.005-.253-.008-.251-.01-.249-.012-.247-.015-.245-.016-.243-.019-.241-.02-.238-.023-.236-.024-.234-.027-.231-.028-.228-.031-.226-.032-.223-.034-.22-.036-.217-.038-.214-.04-.211-.041-.208-.043-.204-.045-.201-.046-.198-.048-.195-.05-.19-.051-.187-.053-.184-.054-.179-.056-.176-.057-.172-.059-.167-.06-.164-.061-.159-.063-.155-.064-.151-.066-.074-.033-.072-.033-.072-.034-.07-.034-.069-.035-.068-.035-.067-.035-.066-.035-.064-.036-.063-.036-.062-.036-.061-.036-.06-.037-.058-.037-.057-.037-.056-.038-.055-.038-.053-.038-.052-.038-.051-.039-.049-.039-.049-.039-.046-.039-.046-.04-.044-.04-.043-.04-.041-.04-.04-.041-.039-.041-.037-.041-.036-.041-.034-.041-.033-.042-.032-.042-.03-.042-.029-.042-.027-.042-.026-.043-.024-.043-.023-.043-.021-.043-.02-.043-.018-.044-.017-.043-.015-.044-.013-.044-.012-.044-.011-.045-.009-.044-.007-.045-.006-.045-.004-.045-.002-.045-.001-.045v-17l.001-.045.002-.045.004-.045.006-.045.007-.045.009-.044.011-.045.012-.044.013-.044.015-.044.017-.043.018-.044.02-.043.021-.043.023-.043.024-.043.026-.043.027-.042.029-.042.03-.042.032-.042.033-.042.034-.041.036-.041.037-.041.039-.041.04-.041.041-.04.043-.04.044-.04.046-.04.046-.039.049-.039.049-.039.051-.039.052-.038.053-.038.055-.038.056-.038.057-.037.058-.037.06-.037.061-.036.062-.036.063-.036.064-.036.066-.035.067-.035.068-.035.069-.035.07-.034.072-.034.072-.033.074-.033.151-.066.155-.064.159-.063.164-.061.167-.06.172-.059.176-.057.179-.056.184-.054.187-.053.19-.051.195-.05.198-.048.201-.046.204-.045.208-.043.211-.041.214-.04.217-.038.22-.036.223-.034.226-.032.228-.031.231-.028.234-.027.236-.024.238-.023.241-.02.243-.019.245-.016.247-.015.249-.012.251-.01.253-.008.255-.005.256-.004.258-.001.258.001zm-9.258 20.499v.01l.001.021.003.021.004.022.005.021.006.022.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.023.018.024.019.024.021.024.022.025.023.024.024.025.052.049.056.05.061.051.066.051.07.051.075.051.079.052.084.052.088.052.092.052.097.052.102.051.105.052.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.048.144.049.147.047.152.047.155.047.16.045.163.045.167.043.171.043.176.041.178.041.183.039.187.039.19.037.194.035.197.035.202.033.204.031.209.03.212.029.216.027.219.025.222.024.226.021.23.02.233.018.236.016.24.015.243.012.246.01.249.008.253.005.256.004.259.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.021.224-.024.22-.026.216-.027.212-.028.21-.031.205-.031.202-.034.198-.034.194-.036.191-.037.187-.039.183-.04.179-.04.175-.042.172-.043.168-.044.163-.045.16-.046.155-.046.152-.047.148-.048.143-.049.139-.049.136-.05.131-.05.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.053.083-.051.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.05.023-.024.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.023.01-.022.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.127l-.077.055-.08.053-.083.054-.085.053-.087.052-.09.052-.093.051-.095.05-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.045-.118.044-.12.043-.122.042-.124.042-.126.041-.128.04-.13.04-.132.038-.134.038-.135.037-.138.037-.139.035-.142.035-.143.034-.144.033-.147.032-.148.031-.15.03-.151.03-.153.029-.154.027-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.01-.179.008-.179.008-.181.006-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.006-.179-.008-.179-.008-.178-.01-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.027-.153-.029-.151-.03-.15-.03-.148-.031-.146-.032-.145-.033-.143-.034-.141-.035-.14-.035-.137-.037-.136-.037-.134-.038-.132-.038-.13-.04-.128-.04-.126-.041-.124-.042-.122-.042-.12-.044-.117-.043-.116-.045-.113-.045-.112-.046-.109-.047-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.05-.093-.052-.09-.051-.087-.052-.085-.053-.083-.054-.08-.054-.077-.054v4.127zm0-5.654v.011l.001.021.003.021.004.021.005.022.006.022.007.022.009.022.01.022.011.023.012.023.013.023.015.024.016.023.017.024.018.024.019.024.021.024.022.024.023.025.024.024.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.052.11.051.114.051.119.052.123.05.127.051.131.05.135.049.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.044.171.042.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.022.23.02.233.018.236.016.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.012.241-.015.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.048.139-.05.136-.049.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.051.051-.049.023-.025.023-.024.021-.025.02-.024.019-.024.018-.024.017-.024.015-.023.014-.023.013-.024.012-.022.01-.023.01-.023.008-.022.006-.022.006-.022.004-.021.004-.022.001-.021.001-.021v-4.139l-.077.054-.08.054-.083.054-.085.052-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.049-.105.048-.106.047-.109.047-.111.046-.114.045-.115.044-.118.044-.12.044-.122.042-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.035-.143.033-.144.033-.147.033-.148.031-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.025-.161.024-.162.023-.163.022-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.011-.178.009-.179.009-.179.007-.181.007-.182.005-.182.004-.184.003-.184.002h-.37l-.184-.002-.184-.003-.182-.004-.182-.005-.181-.007-.179-.007-.179-.009-.178-.009-.176-.011-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.022-.162-.023-.161-.024-.159-.025-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.031-.146-.033-.145-.033-.143-.033-.141-.035-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.04-.126-.041-.124-.042-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.047-.105-.048-.102-.049-.1-.049-.097-.05-.095-.051-.093-.051-.09-.051-.087-.053-.085-.052-.083-.054-.08-.054-.077-.054v4.139zm0-5.666v.011l.001.02.003.022.004.021.005.022.006.021.007.022.009.023.01.022.011.023.012.023.013.023.015.023.016.024.017.024.018.023.019.024.021.025.022.024.023.024.024.025.052.05.056.05.061.05.066.051.07.051.075.052.079.051.084.052.088.052.092.052.097.052.102.052.105.051.11.052.114.051.119.051.123.051.127.05.131.05.135.05.139.049.144.048.147.048.152.047.155.046.16.045.163.045.167.043.171.043.176.042.178.04.183.04.187.038.19.037.194.036.197.034.202.033.204.032.209.03.212.028.216.027.219.025.222.024.226.021.23.02.233.018.236.017.24.014.243.012.246.01.249.008.253.006.256.003.259.001.26-.001.257-.003.254-.006.25-.008.247-.01.244-.013.241-.014.237-.016.233-.018.231-.02.226-.022.224-.024.22-.025.216-.027.212-.029.21-.03.205-.032.202-.033.198-.035.194-.036.191-.037.187-.039.183-.039.179-.041.175-.042.172-.043.168-.044.163-.045.16-.045.155-.047.152-.047.148-.048.143-.049.139-.049.136-.049.131-.051.126-.05.123-.051.118-.052.114-.051.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.052.07-.051.065-.051.06-.051.056-.05.051-.049.023-.025.023-.025.021-.024.02-.024.019-.024.018-.024.017-.024.015-.023.014-.024.013-.023.012-.023.01-.022.01-.023.008-.022.006-.022.006-.022.004-.022.004-.021.001-.021.001-.021v-4.153l-.077.054-.08.054-.083.053-.085.053-.087.053-.09.051-.093.051-.095.051-.097.05-.1.049-.102.048-.105.048-.106.048-.109.046-.111.046-.114.046-.115.044-.118.044-.12.043-.122.043-.124.042-.126.041-.128.04-.13.039-.132.039-.134.038-.135.037-.138.036-.139.036-.142.034-.143.034-.144.033-.147.032-.148.032-.15.03-.151.03-.153.028-.154.028-.156.027-.158.026-.159.024-.161.024-.162.023-.163.023-.165.021-.166.02-.167.019-.169.018-.169.017-.171.016-.173.015-.173.014-.175.013-.175.012-.177.01-.178.01-.179.009-.179.007-.181.006-.182.006-.182.004-.184.003-.184.001-.185.001-.185-.001-.184-.001-.184-.003-.182-.004-.182-.006-.181-.006-.179-.007-.179-.009-.178-.01-.176-.01-.176-.012-.175-.013-.173-.014-.172-.015-.171-.016-.17-.017-.169-.018-.167-.019-.166-.02-.165-.021-.163-.023-.162-.023-.161-.024-.159-.024-.157-.026-.156-.027-.155-.028-.153-.028-.151-.03-.15-.03-.148-.032-.146-.032-.145-.033-.143-.034-.141-.034-.14-.036-.137-.036-.136-.037-.134-.038-.132-.039-.13-.039-.128-.041-.126-.041-.124-.041-.122-.043-.12-.043-.117-.044-.116-.044-.113-.046-.112-.046-.109-.046-.106-.048-.105-.048-.102-.048-.1-.05-.097-.049-.095-.051-.093-.051-.09-.052-.087-.052-.085-.053-.083-.053-.08-.054-.077-.054v4.153zm8.74-8.179l-.257.004-.254.005-.25.008-.247.011-.244.012-.241.014-.237.016-.233.018-.231.021-.226.022-.224.023-.22.026-.216.027-.212.028-.21.031-.205.032-.202.033-.198.034-.194.036-.191.038-.187.038-.183.04-.179.041-.175.042-.172.043-.168.043-.163.045-.16.046-.155.046-.152.048-.148.048-.143.048-.139.049-.136.05-.131.05-.126.051-.123.051-.118.051-.114.052-.11.052-.106.052-.101.052-.096.052-.092.052-.088.052-.083.052-.079.052-.074.051-.07.052-.065.051-.06.05-.056.05-.051.05-.023.025-.023.024-.021.024-.02.025-.019.024-.018.024-.017.023-.015.024-.014.023-.013.023-.012.023-.01.023-.01.022-.008.022-.006.023-.006.021-.004.022-.004.021-.001.021-.001.021.001.021.001.021.004.021.004.022.006.021.006.023.008.022.01.022.01.023.012.023.013.023.014.023.015.024.017.023.018.024.019.024.02.025.021.024.023.024.023.025.051.05.056.05.06.05.065.051.07.052.074.051.079.052.083.052.088.052.092.052.096.052.101.052.106.052.11.052.114.052.118.051.123.051.126.051.131.05.136.05.139.049.143.048.148.048.152.048.155.046.16.046.163.045.168.043.172.043.175.042.179.041.183.04.187.038.191.038.194.036.198.034.202.033.205.032.21.031.212.028.216.027.22.026.224.023.226.022.231.021.233.018.237.016.241.014.244.012.247.011.25.008.254.005.257.004.26.001.26-.001.257-.004.254-.005.25-.008.247-.011.244-.012.241-.014.237-.016.233-.018.231-.021.226-.022.224-.023.22-.026.216-.027.212-.028.21-.031.205-.032.202-.033.198-.034.194-.036.191-.038.187-.038.183-.04.179-.041.175-.042.172-.043.168-.043.163-.045.16-.046.155-.046.152-.048.148-.048.143-.048.139-.049.136-.05.131-.05.126-.051.123-.051.118-.051.114-.052.11-.052.106-.052.101-.052.096-.052.092-.052.088-.052.083-.052.079-.052.074-.051.07-.052.065-.051.06-.05.056-.05.051-.05.023-.025.023-.024.021-.024.02-.025.019-.024.018-.024.017-.023.015-.024.014-.023.013-.023.012-.023.01-.023.01-.022.008-.022.006-.023.006-.021.004-.022.004-.021.001-.021.001-.021-.001-.021-.001-.021-.004-.021-.004-.022-.006-.021-.006-.023-.008-.022-.01-.022-.01-.023-.012-.023-.013-.023-.014-.023-.015-.024-.017-.023-.018-.024-.019-.024-.02-.025-.021-.024-.023-.024-.023-.025-.051-.05-.056-.05-.06-.05-.065-.051-.07-.052-.074-.051-.079-.052-.083-.052-.088-.052-.092-.052-.096-.052-.101-.052-.106-.052-.11-.052-.114-.052-.118-.051-.123-.051-.126-.051-.131-.05-.136-.05-.139-.049-.143-.048-.148-.048-.152-.048-.155-.046-.16-.046-.163-.045-.168-.043-.172-.043-.175-.042-.179-.041-.183-.04-.187-.038-.191-.038-.194-.036-.198-.034-.202-.033-.205-.032-.21-.031-.212-.028-.216-.027-.22-.026-.224-.023-.226-.022-.231-.021-.233-.018-.237-.016-.241-.014-.244-.012-.247-.011-.25-.008-.254-.005-.257-.004-.26-.001-.26.001z" + ); +}; +const insertComputerIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "computer").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M2 2v13h20v-13h-20zm18 11h-16v-9h16v9zm-10.228 6l.466-1h3.524l.467 1h-4.457zm14.228 3h-24l2-6h2.104l-1.33 4h18.45l-1.297-4h2.073l2 6zm-5-10h-14v-7h14v7z" + ); +}; +const insertClockIcon = function(elem) { + elem.append("defs").append("symbol").attr("id", "clock").attr("width", "24").attr("height", "24").append("path").attr("transform", "scale(.5)").attr( + "d", + "M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5.848 12.459c.202.038.202.333.001.372-1.907.361-6.045 1.111-6.547 1.111-.719 0-1.301-.582-1.301-1.301 0-.512.77-5.447 1.125-7.445.034-.192.312-.181.343.014l.985 6.238 5.394 1.011z" + ); +}; +const insertArrowHead = function(elem) { + elem.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 7.9).attr("refY", 5).attr("markerUnits", "userSpaceOnUse").attr("markerWidth", 12).attr("markerHeight", 12).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z"); +}; +const insertArrowFilledHead = function(elem) { + elem.append("defs").append("marker").attr("id", "filled-head").attr("refX", 15.5).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 18,7 L9,13 L14,7 L9,1 Z"); +}; +const insertSequenceNumber = function(elem) { + elem.append("defs").append("marker").attr("id", "sequencenumber").attr("refX", 15).attr("refY", 15).attr("markerWidth", 60).attr("markerHeight", 40).attr("orient", "auto").append("circle").attr("cx", 15).attr("cy", 15).attr("r", 6); +}; +const insertArrowCrossHead = function(elem) { + const defs = elem.append("defs"); + const marker = defs.append("marker").attr("id", "crosshead").attr("markerWidth", 15).attr("markerHeight", 8).attr("orient", "auto").attr("refX", 4).attr("refY", 4.5); + marker.append("path").attr("fill", "none").attr("stroke", "#000000").style("stroke-dasharray", "0, 0").attr("stroke-width", "1pt").attr("d", "M 1,2 L 6,7 M 6,2 L 1,7"); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + anchor: void 0, + style: "#666", + width: void 0, + height: void 0, + textMargin: 0, + rx: 0, + ry: 0, + tspan: true, + valign: void 0 + }; +}; +const getNoteRect = function() { + return { + x: 0, + y: 0, + fill: "#EDF2AE", + stroke: "#666", + width: 100, + anchor: "start", + height: 100, + rx: 0, + ry: 0 + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { actorFontSize, actorFontFamily, actorFontWeight } = conf2; + const [_actorFontSize, _actorFontSizePx] = parseFontSize(actorFontSize); + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * _actorFontSize - _actorFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).style("text-anchor", "middle").style("font-size", _actorFontSizePx).style("font-weight", actorFontWeight).style("font-family", actorFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + async function byKatex(content, g, x, y, width, height, textAttrs, conf2) { + const dim = await calculateMathMLDimensions(content, getConfig$1()); + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x + width / 2 - dim.width / 2).attr("y", y + height / 2 - dim.height / 2).attr("width", dim.width).attr("height", dim.height); + const text = f.append("xhtml:div").style("height", "100%").style("width", "100%"); + text.append("div").style("text-align", "center").style("vertical-align", "middle").html(await renderKatex(content, getConfig$1())); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2, hasKatex2 = false) { + if (hasKatex2) { + return byKatex; + } + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const _drawMenuItemTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs) { + const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf2) { + const { actorFontSize, actorFontFamily, actorFontWeight } = conf2; + const lines = content.split(common$1.lineBreakRegex); + for (let i = 0; i < lines.length; i++) { + const dy = i * actorFontSize - actorFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x).attr("y", y).style("text-anchor", "start").style("font-size", actorFontSize).style("font-weight", actorFontWeight).style("font-family", actorFontFamily); + text.append("tspan").attr("x", x).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf2) { + const s = g.append("switch"); + const f = s.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, s, x, y, width, height, textAttrs, conf2); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (fromTextAttrsDict.hasOwnProperty(key)) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf2) { + return conf2.textPlacement === "fo" ? byFo : conf2.textPlacement === "old" ? byText : byTspan; + }; +}(); +const svgDraw = { + drawRect, + drawText, + drawLabel, + drawActor, + drawBox, + drawPopup, + anchorElement, + drawActivation, + drawLoop, + drawBackgroundRect, + insertArrowHead, + insertArrowFilledHead, + insertSequenceNumber, + insertArrowCrossHead, + insertDatabaseIcon, + insertComputerIcon, + insertClockIcon, + getTextObj, + getNoteRect, + fixLifeLineHeights, + sanitizeUrl: dist.sanitizeUrl +}; +let conf = {}; +const bounds = { + data: { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }, + verticalPos: 0, + sequenceItems: [], + activations: [], + models: { + getHeight: function() { + return Math.max.apply( + null, + this.actors.length === 0 ? [0] : this.actors.map((actor) => actor.height || 0) + ) + (this.loops.length === 0 ? 0 : this.loops.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.messages.length === 0 ? 0 : this.messages.map((it) => it.height || 0).reduce((acc, h) => acc + h)) + (this.notes.length === 0 ? 0 : this.notes.map((it) => it.height || 0).reduce((acc, h) => acc + h)); + }, + clear: function() { + this.actors = []; + this.boxes = []; + this.loops = []; + this.messages = []; + this.notes = []; + }, + addBox: function(boxModel) { + this.boxes.push(boxModel); + }, + addActor: function(actorModel) { + this.actors.push(actorModel); + }, + addLoop: function(loopModel) { + this.loops.push(loopModel); + }, + addMessage: function(msgModel) { + this.messages.push(msgModel); + }, + addNote: function(noteModel) { + this.notes.push(noteModel); + }, + lastActor: function() { + return this.actors[this.actors.length - 1]; + }, + lastLoop: function() { + return this.loops[this.loops.length - 1]; + }, + lastMessage: function() { + return this.messages[this.messages.length - 1]; + }, + lastNote: function() { + return this.notes[this.notes.length - 1]; + }, + actors: [], + boxes: [], + loops: [], + messages: [], + notes: [] + }, + init: function() { + this.sequenceItems = []; + this.activations = []; + this.models.clear(); + this.data = { + startx: void 0, + stopx: void 0, + starty: void 0, + stopy: void 0 + }; + this.verticalPos = 0; + setConf(getConfig()); + }, + updateVal: function(obj, key, val, fun) { + if (obj[key] === void 0) { + obj[key] = val; + } else { + obj[key] = fun(val, obj[key]); + } + }, + updateBounds: function(startx, starty, stopx, stopy) { + const _self = this; + let cnt = 0; + function updateFn(type) { + return function updateItemBounds(item) { + cnt++; + const n = _self.sequenceItems.length - cnt + 1; + _self.updateVal(item, "starty", starty - n * conf.boxMargin, Math.min); + _self.updateVal(item, "stopy", stopy + n * conf.boxMargin, Math.max); + _self.updateVal(bounds.data, "startx", startx - n * conf.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopx", stopx + n * conf.boxMargin, Math.max); + if (!(type === "activation")) { + _self.updateVal(item, "startx", startx - n * conf.boxMargin, Math.min); + _self.updateVal(item, "stopx", stopx + n * conf.boxMargin, Math.max); + _self.updateVal(bounds.data, "starty", starty - n * conf.boxMargin, Math.min); + _self.updateVal(bounds.data, "stopy", stopy + n * conf.boxMargin, Math.max); + } + }; + } + this.sequenceItems.forEach(updateFn()); + this.activations.forEach(updateFn("activation")); + }, + insert: function(startx, starty, stopx, stopy) { + const _startx = common$1.getMin(startx, stopx); + const _stopx = common$1.getMax(startx, stopx); + const _starty = common$1.getMin(starty, stopy); + const _stopy = common$1.getMax(starty, stopy); + this.updateVal(bounds.data, "startx", _startx, Math.min); + this.updateVal(bounds.data, "starty", _starty, Math.min); + this.updateVal(bounds.data, "stopx", _stopx, Math.max); + this.updateVal(bounds.data, "stopy", _stopy, Math.max); + this.updateBounds(_startx, _starty, _stopx, _stopy); + }, + newActivation: function(message, diagram2, actors) { + const actorRect = actors[message.from.actor]; + const stackedSize = actorActivations(message.from.actor).length || 0; + const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2; + this.activations.push({ + startx: x, + starty: this.verticalPos + 2, + stopx: x + conf.activationWidth, + stopy: void 0, + actor: message.from.actor, + anchored: svgDraw.anchorElement(diagram2) + }); + }, + endActivation: function(message) { + const lastActorActivationIdx = this.activations.map(function(activation) { + return activation.actor; + }).lastIndexOf(message.from.actor); + return this.activations.splice(lastActorActivationIdx, 1)[0]; + }, + createLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) { + return { + startx: void 0, + starty: this.verticalPos, + stopx: void 0, + stopy: void 0, + title: title.message, + wrap: title.wrap, + width: title.width, + height: 0, + fill + }; + }, + newLoop: function(title = { message: void 0, wrap: false, width: void 0 }, fill) { + this.sequenceItems.push(this.createLoop(title, fill)); + }, + endLoop: function() { + return this.sequenceItems.pop(); + }, + isLoopOverlap: function() { + return this.sequenceItems.length ? this.sequenceItems[this.sequenceItems.length - 1].overlap : false; + }, + addSectionToLoop: function(message) { + const loop = this.sequenceItems.pop(); + loop.sections = loop.sections || []; + loop.sectionTitles = loop.sectionTitles || []; + loop.sections.push({ y: bounds.getVerticalPos(), height: 0 }); + loop.sectionTitles.push(message); + this.sequenceItems.push(loop); + }, + saveVerticalPos: function() { + if (this.isLoopOverlap()) { + this.savedVerticalPos = this.verticalPos; + } + }, + resetVerticalPos: function() { + if (this.isLoopOverlap()) { + this.verticalPos = this.savedVerticalPos; + } + }, + bumpVerticalPos: function(bump) { + this.verticalPos = this.verticalPos + bump; + this.data.stopy = common$1.getMax(this.data.stopy, this.verticalPos); + }, + getVerticalPos: function() { + return this.verticalPos; + }, + getBounds: function() { + return { bounds: this.data, models: this.models }; + } +}; +const drawNote = async function(elem, noteModel) { + bounds.bumpVerticalPos(conf.boxMargin); + noteModel.height = conf.boxMargin; + noteModel.starty = bounds.getVerticalPos(); + const rect = getNoteRect$1(); + rect.x = noteModel.startx; + rect.y = noteModel.starty; + rect.width = noteModel.width || conf.width; + rect.class = "note"; + const g = elem.append("g"); + const rectElem = svgDraw.drawRect(g, rect); + const textObj = getTextObj$1(); + textObj.x = noteModel.startx; + textObj.y = noteModel.starty; + textObj.width = rect.width; + textObj.dy = "1em"; + textObj.text = noteModel.message; + textObj.class = "noteText"; + textObj.fontFamily = conf.noteFontFamily; + textObj.fontSize = conf.noteFontSize; + textObj.fontWeight = conf.noteFontWeight; + textObj.anchor = conf.noteAlign; + textObj.textMargin = conf.noteMargin; + textObj.valign = "center"; + const textElem = hasKatex(textObj.text) ? await drawKatex(g, textObj) : drawText(g, textObj); + const textHeight = Math.round( + textElem.map((te) => (te._groups || te)[0][0].getBBox().height).reduce((acc, curr) => acc + curr) + ); + rectElem.attr("height", textHeight + 2 * conf.noteMargin); + noteModel.height += textHeight + 2 * conf.noteMargin; + bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin); + noteModel.stopy = noteModel.starty + textHeight + 2 * conf.noteMargin; + noteModel.stopx = noteModel.startx + rect.width; + bounds.insert(noteModel.startx, noteModel.starty, noteModel.stopx, noteModel.stopy); + bounds.models.addNote(noteModel); +}; +const messageFont = (cnf) => { + return { + fontFamily: cnf.messageFontFamily, + fontSize: cnf.messageFontSize, + fontWeight: cnf.messageFontWeight + }; +}; +const noteFont = (cnf) => { + return { + fontFamily: cnf.noteFontFamily, + fontSize: cnf.noteFontSize, + fontWeight: cnf.noteFontWeight + }; +}; +const actorFont = (cnf) => { + return { + fontFamily: cnf.actorFontFamily, + fontSize: cnf.actorFontSize, + fontWeight: cnf.actorFontWeight + }; +}; +async function boundMessage(_diagram, msgModel) { + bounds.bumpVerticalPos(10); + const { startx, stopx, message } = msgModel; + const lines = common$1.splitBreaks(message).length; + const isKatexMsg = hasKatex(message); + const textDims = isKatexMsg ? await calculateMathMLDimensions(message, getConfig()) : utils.calculateTextDimensions(message, messageFont(conf)); + if (!isKatexMsg) { + const lineHeight = textDims.height / lines; + msgModel.height += lineHeight; + bounds.bumpVerticalPos(lineHeight); + } + let lineStartY; + let totalOffset = textDims.height - 10; + const textWidth = textDims.width; + if (startx === stopx) { + lineStartY = bounds.getVerticalPos() + totalOffset; + if (!conf.rightAngles) { + totalOffset += conf.boxMargin; + lineStartY = bounds.getVerticalPos() + totalOffset; + } + totalOffset += 30; + const dx = common$1.getMax(textWidth / 2, conf.width / 2); + bounds.insert( + startx - dx, + bounds.getVerticalPos() - 10 + totalOffset, + stopx + dx, + bounds.getVerticalPos() + 30 + totalOffset + ); + } else { + totalOffset += conf.boxMargin; + lineStartY = bounds.getVerticalPos() + totalOffset; + bounds.insert(startx, lineStartY - 10, stopx, lineStartY); + } + bounds.bumpVerticalPos(totalOffset); + msgModel.height += totalOffset; + msgModel.stopy = msgModel.starty + msgModel.height; + bounds.insert(msgModel.fromBounds, msgModel.starty, msgModel.toBounds, msgModel.stopy); + return lineStartY; +} +const drawMessage = async function(diagram2, msgModel, lineStartY, diagObj) { + const { startx, stopx, starty, message, type, sequenceIndex, sequenceVisible } = msgModel; + const textDims = utils.calculateTextDimensions(message, messageFont(conf)); + const textObj = getTextObj$1(); + textObj.x = startx; + textObj.y = starty + 10; + textObj.width = stopx - startx; + textObj.class = "messageText"; + textObj.dy = "1em"; + textObj.text = message; + textObj.fontFamily = conf.messageFontFamily; + textObj.fontSize = conf.messageFontSize; + textObj.fontWeight = conf.messageFontWeight; + textObj.anchor = conf.messageAlign; + textObj.valign = "center"; + textObj.textMargin = conf.wrapPadding; + textObj.tspan = false; + hasKatex(textObj.text) ? await drawKatex(diagram2, textObj, { startx, stopx, starty: lineStartY }) : drawText(diagram2, textObj); + const textWidth = textDims.width; + let line; + if (startx === stopx) { + if (conf.rightAngles) { + line = diagram2.append("path").attr( + "d", + `M ${startx},${lineStartY} H ${startx + common$1.getMax(conf.width / 2, textWidth / 2)} V ${lineStartY + 25} H ${startx}` + ); + } else { + line = diagram2.append("path").attr( + "d", + "M " + startx + "," + lineStartY + " C " + (startx + 60) + "," + (lineStartY - 10) + " " + (startx + 60) + "," + (lineStartY + 30) + " " + startx + "," + (lineStartY + 20) + ); + } + } else { + line = diagram2.append("line"); + line.attr("x1", startx); + line.attr("y1", lineStartY); + line.attr("x2", stopx); + line.attr("y2", lineStartY); + } + if (type === diagObj.db.LINETYPE.DOTTED || type === diagObj.db.LINETYPE.DOTTED_CROSS || type === diagObj.db.LINETYPE.DOTTED_POINT || type === diagObj.db.LINETYPE.DOTTED_OPEN) { + line.style("stroke-dasharray", "3, 3"); + line.attr("class", "messageLine1"); + } else { + line.attr("class", "messageLine0"); + } + let url = ""; + if (conf.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + line.attr("stroke-width", 2); + line.attr("stroke", "none"); + line.style("fill", "none"); + if (type === diagObj.db.LINETYPE.SOLID || type === diagObj.db.LINETYPE.DOTTED) { + line.attr("marker-end", "url(" + url + "#arrowhead)"); + } + if (type === diagObj.db.LINETYPE.SOLID_POINT || type === diagObj.db.LINETYPE.DOTTED_POINT) { + line.attr("marker-end", "url(" + url + "#filled-head)"); + } + if (type === diagObj.db.LINETYPE.SOLID_CROSS || type === diagObj.db.LINETYPE.DOTTED_CROSS) { + line.attr("marker-end", "url(" + url + "#crosshead)"); + } + if (sequenceVisible || conf.showSequenceNumbers) { + line.attr("marker-start", "url(" + url + "#sequencenumber)"); + diagram2.append("text").attr("x", startx).attr("y", lineStartY + 4).attr("font-family", "sans-serif").attr("font-size", "12px").attr("text-anchor", "middle").attr("class", "sequenceNumber").text(sequenceIndex); + } +}; +const addActorRenderingData = async function(diagram2, actors, createdActors, actorKeys, verticalPos, messages, isFooter) { + let prevWidth = 0; + let prevMargin = 0; + let prevBox = void 0; + let maxHeight = 0; + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + const box = actor.box; + if (prevBox && prevBox != box) { + { + bounds.models.addBox(prevBox); + } + prevMargin += conf.boxMargin + prevBox.margin; + } + if (box && box != prevBox) { + { + box.x = prevWidth + prevMargin; + box.y = verticalPos; + } + prevMargin += box.margin; + } + actor.width = actor.width || conf.width; + actor.height = common$1.getMax(actor.height || conf.height, conf.height); + actor.margin = actor.margin || conf.actorMargin; + maxHeight = common$1.getMax(maxHeight, actor.height); + if (createdActors[actor.name]) { + prevMargin += actor.width / 2; + } + actor.x = prevWidth + prevMargin; + actor.starty = bounds.getVerticalPos(); + bounds.insert(actor.x, verticalPos, actor.x + actor.width, actor.height); + prevWidth += actor.width + prevMargin; + if (actor.box) { + actor.box.width = prevWidth + box.margin - actor.box.x; + } + prevMargin = actor.margin; + prevBox = actor.box; + bounds.models.addActor(actor); + } + if (prevBox && !isFooter) { + bounds.models.addBox(prevBox); + } + bounds.bumpVerticalPos(maxHeight); +}; +const drawActors = async function(diagram2, actors, actorKeys, isFooter) { + if (!isFooter) { + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + await svgDraw.drawActor(diagram2, actor, conf, false); + } + } else { + let maxHeight = 0; + bounds.bumpVerticalPos(conf.boxMargin * 2); + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + if (!actor.stopy) { + actor.stopy = bounds.getVerticalPos(); + } + const height = await svgDraw.drawActor(diagram2, actor, conf, true); + maxHeight = common$1.getMax(maxHeight, height); + } + bounds.bumpVerticalPos(maxHeight + conf.boxMargin); + } +}; +const drawActorsPopup = function(diagram2, actors, actorKeys, doc) { + let maxHeight = 0; + let maxWidth = 0; + for (const actorKey of actorKeys) { + const actor = actors[actorKey]; + const minMenuWidth = getRequiredPopupWidth(actor); + const menuDimensions = svgDraw.drawPopup( + diagram2, + actor, + minMenuWidth, + conf, + conf.forceMenus, + doc + ); + if (menuDimensions.height > maxHeight) { + maxHeight = menuDimensions.height; + } + if (menuDimensions.width + actor.x > maxWidth) { + maxWidth = menuDimensions.width + actor.x; + } + } + return { maxHeight, maxWidth }; +}; +const setConf = function(cnf) { + assignWithDepth$1(conf, cnf); + if (cnf.fontFamily) { + conf.actorFontFamily = conf.noteFontFamily = conf.messageFontFamily = cnf.fontFamily; + } + if (cnf.fontSize) { + conf.actorFontSize = conf.noteFontSize = conf.messageFontSize = cnf.fontSize; + } + if (cnf.fontWeight) { + conf.actorFontWeight = conf.noteFontWeight = conf.messageFontWeight = cnf.fontWeight; + } +}; +const actorActivations = function(actor) { + return bounds.activations.filter(function(activation) { + return activation.actor === actor; + }); +}; +const activationBounds = function(actor, actors) { + const actorObj = actors[actor]; + const activations = actorActivations(actor); + const left = activations.reduce(function(acc, activation) { + return common$1.getMin(acc, activation.startx); + }, actorObj.x + actorObj.width / 2 - 1); + const right = activations.reduce(function(acc, activation) { + return common$1.getMax(acc, activation.stopx); + }, actorObj.x + actorObj.width / 2 + 1); + return [left, right]; +}; +function adjustLoopHeightForWrap(loopWidths, msg, preMargin, postMargin, addLoopFn) { + bounds.bumpVerticalPos(preMargin); + let heightAdjust = postMargin; + if (msg.id && msg.message && loopWidths[msg.id]) { + const loopWidth = loopWidths[msg.id].width; + const textConf = messageFont(conf); + msg.message = utils.wrapLabel(`[${msg.message}]`, loopWidth - 2 * conf.wrapPadding, textConf); + msg.width = loopWidth; + msg.wrap = true; + const textDims = utils.calculateTextDimensions(msg.message, textConf); + const totalOffset = common$1.getMax(textDims.height, conf.labelBoxHeight); + heightAdjust = postMargin + totalOffset; + log$1.debug(`${totalOffset} - ${msg.message}`); + } + addLoopFn(msg); + bounds.bumpVerticalPos(heightAdjust); +} +function adjustCreatedDestroyedData(msg, msgModel, lineStartY, index, actors, createdActors, destroyedActors) { + function receiverAdjustment(actor, adjustment) { + if (actor.x < actors[msg.from].x) { + bounds.insert( + msgModel.stopx - adjustment, + msgModel.starty, + msgModel.startx, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.stopx = msgModel.stopx + adjustment; + } else { + bounds.insert( + msgModel.startx, + msgModel.starty, + msgModel.stopx + adjustment, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.stopx = msgModel.stopx - adjustment; + } + } + function senderAdjustment(actor, adjustment) { + if (actor.x < actors[msg.to].x) { + bounds.insert( + msgModel.startx - adjustment, + msgModel.starty, + msgModel.stopx, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.startx = msgModel.startx + adjustment; + } else { + bounds.insert( + msgModel.stopx, + msgModel.starty, + msgModel.startx + adjustment, + msgModel.stopy + actor.height / 2 + conf.noteMargin + ); + msgModel.startx = msgModel.startx - adjustment; + } + } + if (createdActors[msg.to] == index) { + const actor = actors[msg.to]; + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; + receiverAdjustment(actor, adjustment); + actor.starty = lineStartY - actor.height / 2; + bounds.bumpVerticalPos(actor.height / 2); + } else if (destroyedActors[msg.from] == index) { + const actor = actors[msg.from]; + if (conf.mirrorActors) { + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 : actor.width / 2; + senderAdjustment(actor, adjustment); + } + actor.stopy = lineStartY - actor.height / 2; + bounds.bumpVerticalPos(actor.height / 2); + } else if (destroyedActors[msg.to] == index) { + const actor = actors[msg.to]; + if (conf.mirrorActors) { + const adjustment = actor.type == "actor" ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; + receiverAdjustment(actor, adjustment); + } + actor.stopy = lineStartY - actor.height / 2; + bounds.bumpVerticalPos(actor.height / 2); + } +} +const draw = async function(_text, id, _version, diagObj) { + const { securityLevel, sequence } = getConfig(); + conf = sequence; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + bounds.init(); + log$1.debug(diagObj.db); + const diagram2 = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select(`[id="${id}"]`); + const actors = diagObj.db.getActors(); + const createdActors = diagObj.db.getCreatedActors(); + const destroyedActors = diagObj.db.getDestroyedActors(); + const boxes = diagObj.db.getBoxes(); + let actorKeys = diagObj.db.getActorKeys(); + const messages = diagObj.db.getMessages(); + const title = diagObj.db.getDiagramTitle(); + const hasBoxes = diagObj.db.hasAtLeastOneBox(); + const hasBoxTitles = diagObj.db.hasAtLeastOneBoxWithTitle(); + const maxMessageWidthPerActor = await getMaxMessageWidthPerActor(actors, messages, diagObj); + conf.height = await calculateActorMargins(actors, maxMessageWidthPerActor, boxes); + svgDraw.insertComputerIcon(diagram2); + svgDraw.insertDatabaseIcon(diagram2); + svgDraw.insertClockIcon(diagram2); + if (hasBoxes) { + bounds.bumpVerticalPos(conf.boxMargin); + if (hasBoxTitles) { + bounds.bumpVerticalPos(boxes[0].textMaxHeight); + } + } + if (conf.hideUnusedParticipants === true) { + const newActors = /* @__PURE__ */ new Set(); + messages.forEach((message) => { + newActors.add(message.from); + newActors.add(message.to); + }); + actorKeys = actorKeys.filter((actorKey) => newActors.has(actorKey)); + } + await addActorRenderingData(diagram2, actors, createdActors, actorKeys, 0, messages, false); + const loopWidths = await calculateLoopBounds(messages, actors, maxMessageWidthPerActor, diagObj); + svgDraw.insertArrowHead(diagram2); + svgDraw.insertArrowCrossHead(diagram2); + svgDraw.insertArrowFilledHead(diagram2); + svgDraw.insertSequenceNumber(diagram2); + function activeEnd(msg, verticalPos) { + const activationData = bounds.endActivation(msg); + if (activationData.starty + 18 > verticalPos) { + activationData.starty = verticalPos - 6; + verticalPos += 12; + } + svgDraw.drawActivation( + diagram2, + activationData, + verticalPos, + conf, + actorActivations(msg.from.actor).length + ); + bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos); + } + let sequenceIndex = 1; + let sequenceIndexStep = 1; + const messagesToDraw = []; + const backgrounds = []; + let index = 0; + for (const msg of messages) { + let loopModel, noteModel, msgModel; + switch (msg.type) { + case diagObj.db.LINETYPE.NOTE: + bounds.resetVerticalPos(); + noteModel = msg.noteModel; + await drawNote(diagram2, noteModel); + break; + case diagObj.db.LINETYPE.ACTIVE_START: + bounds.newActivation(msg, diagram2, actors); + break; + case diagObj.db.LINETYPE.ACTIVE_END: + activeEnd(msg, bounds.getVerticalPos()); + break; + case diagObj.db.LINETYPE.LOOP_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.LOOP_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "loop", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.RECT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin, + (message) => bounds.newLoop(void 0, message.message) + ); + break; + case diagObj.db.LINETYPE.RECT_END: + loopModel = bounds.endLoop(); + backgrounds.push(loopModel); + bounds.models.addLoop(loopModel); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + break; + case diagObj.db.LINETYPE.OPT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.OPT_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "opt", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.ALT_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.ALT_ELSE: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin + conf.boxTextMargin, + conf.boxMargin, + (message) => bounds.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.ALT_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "alt", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.PAR_START: + case diagObj.db.LINETYPE.PAR_OVER_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + bounds.saveVerticalPos(); + break; + case diagObj.db.LINETYPE.PAR_AND: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin + conf.boxTextMargin, + conf.boxMargin, + (message) => bounds.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.PAR_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "par", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.AUTONUMBER: + sequenceIndex = msg.message.start || sequenceIndex; + sequenceIndexStep = msg.message.step || sequenceIndexStep; + if (msg.message.visible) { + diagObj.db.enableSequenceNumbers(); + } else { + diagObj.db.disableSequenceNumbers(); + } + break; + case diagObj.db.LINETYPE.CRITICAL_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.CRITICAL_OPTION: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin + conf.boxTextMargin, + conf.boxMargin, + (message) => bounds.addSectionToLoop(message) + ); + break; + case diagObj.db.LINETYPE.CRITICAL_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "critical", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + case diagObj.db.LINETYPE.BREAK_START: + adjustLoopHeightForWrap( + loopWidths, + msg, + conf.boxMargin, + conf.boxMargin + conf.boxTextMargin, + (message) => bounds.newLoop(message) + ); + break; + case diagObj.db.LINETYPE.BREAK_END: + loopModel = bounds.endLoop(); + await svgDraw.drawLoop(diagram2, loopModel, "break", conf); + bounds.bumpVerticalPos(loopModel.stopy - bounds.getVerticalPos()); + bounds.models.addLoop(loopModel); + break; + default: + try { + msgModel = msg.msgModel; + msgModel.starty = bounds.getVerticalPos(); + msgModel.sequenceIndex = sequenceIndex; + msgModel.sequenceVisible = diagObj.db.showSequenceNumbers(); + const lineStartY = await boundMessage(diagram2, msgModel); + adjustCreatedDestroyedData( + msg, + msgModel, + lineStartY, + index, + actors, + createdActors, + destroyedActors + ); + messagesToDraw.push({ messageModel: msgModel, lineStartY }); + bounds.models.addMessage(msgModel); + } catch (e) { + log$1.error("error while drawing message", e); + } + } + if ([ + diagObj.db.LINETYPE.SOLID_OPEN, + diagObj.db.LINETYPE.DOTTED_OPEN, + diagObj.db.LINETYPE.SOLID, + diagObj.db.LINETYPE.DOTTED, + diagObj.db.LINETYPE.SOLID_CROSS, + diagObj.db.LINETYPE.DOTTED_CROSS, + diagObj.db.LINETYPE.SOLID_POINT, + diagObj.db.LINETYPE.DOTTED_POINT + ].includes(msg.type)) { + sequenceIndex = sequenceIndex + sequenceIndexStep; + } + index++; + } + log$1.debug("createdActors", createdActors); + log$1.debug("destroyedActors", destroyedActors); + await drawActors(diagram2, actors, actorKeys, false); + for (const e of messagesToDraw) { + await drawMessage(diagram2, e.messageModel, e.lineStartY, diagObj); + } + if (conf.mirrorActors) { + await drawActors(diagram2, actors, actorKeys, true); + } + backgrounds.forEach((e) => svgDraw.drawBackgroundRect(diagram2, e)); + fixLifeLineHeights(diagram2, actors, actorKeys, conf); + for (const box2 of bounds.models.boxes) { + box2.height = bounds.getVerticalPos() - box2.y; + bounds.insert(box2.x, box2.y, box2.x + box2.width, box2.height); + box2.startx = box2.x; + box2.starty = box2.y; + box2.stopx = box2.startx + box2.width; + box2.stopy = box2.starty + box2.height; + box2.stroke = "rgb(0,0,0, 0.5)"; + await svgDraw.drawBox(diagram2, box2, conf); + } + if (hasBoxes) { + bounds.bumpVerticalPos(conf.boxMargin); + } + const requiredBoxSize = drawActorsPopup(diagram2, actors, actorKeys, doc); + const { bounds: box } = bounds.getBounds(); + let boxHeight = box.stopy - box.starty; + if (boxHeight < requiredBoxSize.maxHeight) { + boxHeight = requiredBoxSize.maxHeight; + } + let height = boxHeight + 2 * conf.diagramMarginY; + if (conf.mirrorActors) { + height = height - conf.boxMargin + conf.bottomMarginAdj; + } + let boxWidth = box.stopx - box.startx; + if (boxWidth < requiredBoxSize.maxWidth) { + boxWidth = requiredBoxSize.maxWidth; + } + const width = boxWidth + 2 * conf.diagramMarginX; + if (title) { + diagram2.append("text").text(title).attr("x", (box.stopx - box.startx) / 2 - 2 * conf.diagramMarginX).attr("y", -25); + } + configureSvgSize(diagram2, height, width, conf.useMaxWidth); + const extraVertForTitle = title ? 40 : 0; + diagram2.attr( + "viewBox", + box.startx - conf.diagramMarginX + " -" + (conf.diagramMarginY + extraVertForTitle) + " " + width + " " + (height + extraVertForTitle) + ); + log$1.debug(`models:`, bounds.models); +}; +async function getMaxMessageWidthPerActor(actors, messages, diagObj) { + const maxMessageWidthPerActor = {}; + for (const msg of messages) { + if (actors[msg.to] && actors[msg.from]) { + const actor = actors[msg.to]; + if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) { + continue; + } + if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF && !actor.nextActor) { + continue; + } + const isNote = msg.placement !== void 0; + const isMessage = !isNote; + const textFont = isNote ? noteFont(conf) : messageFont(conf); + const wrappedMessage = msg.wrap ? utils.wrapLabel(msg.message, conf.width - 2 * conf.wrapPadding, textFont) : msg.message; + const messageDimensions = hasKatex(wrappedMessage) ? await calculateMathMLDimensions(msg.message, getConfig()) : utils.calculateTextDimensions(wrappedMessage, textFont); + const messageWidth = messageDimensions.width + 2 * conf.wrapPadding; + if (isMessage && msg.from === actor.nextActor) { + maxMessageWidthPerActor[msg.to] = common$1.getMax( + maxMessageWidthPerActor[msg.to] || 0, + messageWidth + ); + } else if (isMessage && msg.from === actor.prevActor) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth + ); + } else if (isMessage && msg.from === msg.to) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth / 2 + ); + maxMessageWidthPerActor[msg.to] = common$1.getMax( + maxMessageWidthPerActor[msg.to] || 0, + messageWidth / 2 + ); + } else if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth + ); + } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { + maxMessageWidthPerActor[actor.prevActor] = common$1.getMax( + maxMessageWidthPerActor[actor.prevActor] || 0, + messageWidth + ); + } else if (msg.placement === diagObj.db.PLACEMENT.OVER) { + if (actor.prevActor) { + maxMessageWidthPerActor[actor.prevActor] = common$1.getMax( + maxMessageWidthPerActor[actor.prevActor] || 0, + messageWidth / 2 + ); + } + if (actor.nextActor) { + maxMessageWidthPerActor[msg.from] = common$1.getMax( + maxMessageWidthPerActor[msg.from] || 0, + messageWidth / 2 + ); + } + } + } + } + log$1.debug("maxMessageWidthPerActor:", maxMessageWidthPerActor); + return maxMessageWidthPerActor; +} +const getRequiredPopupWidth = function(actor) { + let requiredPopupWidth = 0; + const textFont = actorFont(conf); + for (const key in actor.links) { + const labelDimensions = utils.calculateTextDimensions(key, textFont); + const labelWidth = labelDimensions.width + 2 * conf.wrapPadding + 2 * conf.boxMargin; + if (requiredPopupWidth < labelWidth) { + requiredPopupWidth = labelWidth; + } + } + return requiredPopupWidth; +}; +async function calculateActorMargins(actors, actorToMessageWidth, boxes) { + let maxHeight = 0; + for (const prop of Object.keys(actors)) { + const actor = actors[prop]; + if (actor.wrap) { + actor.description = utils.wrapLabel( + actor.description, + conf.width - 2 * conf.wrapPadding, + actorFont(conf) + ); + } + const actDims = hasKatex(actor.description) ? await calculateMathMLDimensions(actor.description, getConfig()) : utils.calculateTextDimensions(actor.description, actorFont(conf)); + actor.width = actor.wrap ? conf.width : common$1.getMax(conf.width, actDims.width + 2 * conf.wrapPadding); + actor.height = actor.wrap ? common$1.getMax(actDims.height, conf.height) : conf.height; + maxHeight = common$1.getMax(maxHeight, actor.height); + } + for (const actorKey in actorToMessageWidth) { + const actor = actors[actorKey]; + if (!actor) { + continue; + } + const nextActor = actors[actor.nextActor]; + if (!nextActor) { + const messageWidth2 = actorToMessageWidth[actorKey]; + const actorWidth2 = messageWidth2 + conf.actorMargin - actor.width / 2; + actor.margin = common$1.getMax(actorWidth2, conf.actorMargin); + continue; + } + const messageWidth = actorToMessageWidth[actorKey]; + const actorWidth = messageWidth + conf.actorMargin - actor.width / 2 - nextActor.width / 2; + actor.margin = common$1.getMax(actorWidth, conf.actorMargin); + } + let maxBoxHeight = 0; + boxes.forEach((box) => { + const textFont = messageFont(conf); + let totalWidth = box.actorKeys.reduce((total, aKey) => { + return total += actors[aKey].width + (actors[aKey].margin || 0); + }, 0); + totalWidth -= 2 * conf.boxTextMargin; + if (box.wrap) { + box.name = utils.wrapLabel(box.name, totalWidth - 2 * conf.wrapPadding, textFont); + } + const boxMsgDimensions = utils.calculateTextDimensions(box.name, textFont); + maxBoxHeight = common$1.getMax(boxMsgDimensions.height, maxBoxHeight); + const minWidth = common$1.getMax(totalWidth, boxMsgDimensions.width + 2 * conf.wrapPadding); + box.margin = conf.boxTextMargin; + if (totalWidth < minWidth) { + const missing = (minWidth - totalWidth) / 2; + box.margin += missing; + } + }); + boxes.forEach((box) => box.textMaxHeight = maxBoxHeight); + return common$1.getMax(maxHeight, conf.height); +} +const buildNoteModel = async function(msg, actors, diagObj) { + const startx = actors[msg.from].x; + const stopx = actors[msg.to].x; + const shouldWrap = msg.wrap && msg.message; + let textDimensions = hasKatex(msg.message) ? await calculateMathMLDimensions(msg.message, getConfig()) : utils.calculateTextDimensions( + shouldWrap ? utils.wrapLabel(msg.message, conf.width, noteFont(conf)) : msg.message, + noteFont(conf) + ); + const noteModel = { + width: shouldWrap ? conf.width : common$1.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin), + height: 0, + startx: actors[msg.from].x, + stopx: 0, + starty: 0, + stopy: 0, + message: msg.message + }; + if (msg.placement === diagObj.db.PLACEMENT.RIGHTOF) { + noteModel.width = shouldWrap ? common$1.getMax(conf.width, textDimensions.width) : common$1.getMax( + actors[msg.from].width / 2 + actors[msg.to].width / 2, + textDimensions.width + 2 * conf.noteMargin + ); + noteModel.startx = startx + (actors[msg.from].width + conf.actorMargin) / 2; + } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { + noteModel.width = shouldWrap ? common$1.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common$1.getMax( + actors[msg.from].width / 2 + actors[msg.to].width / 2, + textDimensions.width + 2 * conf.noteMargin + ); + noteModel.startx = startx - noteModel.width + (actors[msg.from].width - conf.actorMargin) / 2; + } else if (msg.to === msg.from) { + textDimensions = utils.calculateTextDimensions( + shouldWrap ? utils.wrapLabel( + msg.message, + common$1.getMax(conf.width, actors[msg.from].width), + noteFont(conf) + ) : msg.message, + noteFont(conf) + ); + noteModel.width = shouldWrap ? common$1.getMax(conf.width, actors[msg.from].width) : common$1.getMax( + actors[msg.from].width, + conf.width, + textDimensions.width + 2 * conf.noteMargin + ); + noteModel.startx = startx + (actors[msg.from].width - noteModel.width) / 2; + } else { + noteModel.width = Math.abs(startx + actors[msg.from].width / 2 - (stopx + actors[msg.to].width / 2)) + conf.actorMargin; + noteModel.startx = startx < stopx ? startx + actors[msg.from].width / 2 - conf.actorMargin / 2 : stopx + actors[msg.to].width / 2 - conf.actorMargin / 2; + } + if (shouldWrap) { + noteModel.message = utils.wrapLabel( + msg.message, + noteModel.width - 2 * conf.wrapPadding, + noteFont(conf) + ); + } + log$1.debug( + `NM:[${noteModel.startx},${noteModel.stopx},${noteModel.starty},${noteModel.stopy}:${noteModel.width},${noteModel.height}=${msg.message}]` + ); + return noteModel; +}; +const buildMessageModel = function(msg, actors, diagObj) { + if (![ + diagObj.db.LINETYPE.SOLID_OPEN, + diagObj.db.LINETYPE.DOTTED_OPEN, + diagObj.db.LINETYPE.SOLID, + diagObj.db.LINETYPE.DOTTED, + diagObj.db.LINETYPE.SOLID_CROSS, + diagObj.db.LINETYPE.DOTTED_CROSS, + diagObj.db.LINETYPE.SOLID_POINT, + diagObj.db.LINETYPE.DOTTED_POINT + ].includes(msg.type)) { + return {}; + } + const [fromLeft, fromRight] = activationBounds(msg.from, actors); + const [toLeft, toRight] = activationBounds(msg.to, actors); + const isArrowToRight = fromLeft <= toLeft; + const startx = isArrowToRight ? fromRight : fromLeft; + let stopx = isArrowToRight ? toLeft : toRight; + const isArrowToActivation = Math.abs(toLeft - toRight) > 2; + const adjustValue = (value) => { + return isArrowToRight ? -value : value; + }; + if (msg.from === msg.to) { + stopx = startx; + } else { + if (msg.activate && !isArrowToActivation) { + stopx += adjustValue(conf.activationWidth / 2 - 1); + } + if (![diagObj.db.LINETYPE.SOLID_OPEN, diagObj.db.LINETYPE.DOTTED_OPEN].includes(msg.type)) { + stopx += adjustValue(3); + } + } + const allBounds = [fromLeft, fromRight, toLeft, toRight]; + const boundedWidth = Math.abs(startx - stopx); + if (msg.wrap && msg.message) { + msg.message = utils.wrapLabel( + msg.message, + common$1.getMax(boundedWidth + 2 * conf.wrapPadding, conf.width), + messageFont(conf) + ); + } + const msgDims = utils.calculateTextDimensions(msg.message, messageFont(conf)); + return { + width: common$1.getMax( + msg.wrap ? 0 : msgDims.width + 2 * conf.wrapPadding, + boundedWidth + 2 * conf.wrapPadding, + conf.width + ), + height: 0, + startx, + stopx, + starty: 0, + stopy: 0, + message: msg.message, + type: msg.type, + wrap: msg.wrap, + fromBounds: Math.min.apply(null, allBounds), + toBounds: Math.max.apply(null, allBounds) + }; +}; +const calculateLoopBounds = async function(messages, actors, _maxWidthPerActor, diagObj) { + const loops = {}; + const stack = []; + let current, noteModel, msgModel; + for (const msg of messages) { + msg.id = utils.random({ length: 10 }); + switch (msg.type) { + case diagObj.db.LINETYPE.LOOP_START: + case diagObj.db.LINETYPE.ALT_START: + case diagObj.db.LINETYPE.OPT_START: + case diagObj.db.LINETYPE.PAR_START: + case diagObj.db.LINETYPE.PAR_OVER_START: + case diagObj.db.LINETYPE.CRITICAL_START: + case diagObj.db.LINETYPE.BREAK_START: + stack.push({ + id: msg.id, + msg: msg.message, + from: Number.MAX_SAFE_INTEGER, + to: Number.MIN_SAFE_INTEGER, + width: 0 + }); + break; + case diagObj.db.LINETYPE.ALT_ELSE: + case diagObj.db.LINETYPE.PAR_AND: + case diagObj.db.LINETYPE.CRITICAL_OPTION: + if (msg.message) { + current = stack.pop(); + loops[current.id] = current; + loops[msg.id] = current; + stack.push(current); + } + break; + case diagObj.db.LINETYPE.LOOP_END: + case diagObj.db.LINETYPE.ALT_END: + case diagObj.db.LINETYPE.OPT_END: + case diagObj.db.LINETYPE.PAR_END: + case diagObj.db.LINETYPE.CRITICAL_END: + case diagObj.db.LINETYPE.BREAK_END: + current = stack.pop(); + loops[current.id] = current; + break; + case diagObj.db.LINETYPE.ACTIVE_START: + { + const actorRect = actors[msg.from ? msg.from.actor : msg.to.actor]; + const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length; + const x = actorRect.x + actorRect.width / 2 + (stackedSize - 1) * conf.activationWidth / 2; + const toAdd = { + startx: x, + stopx: x + conf.activationWidth, + actor: msg.from.actor, + enabled: true + }; + bounds.activations.push(toAdd); + } + break; + case diagObj.db.LINETYPE.ACTIVE_END: + { + const lastActorActivationIdx = bounds.activations.map((a) => a.actor).lastIndexOf(msg.from.actor); + delete bounds.activations.splice(lastActorActivationIdx, 1)[0]; + } + break; + } + const isNote = msg.placement !== void 0; + if (isNote) { + noteModel = await buildNoteModel(msg, actors, diagObj); + msg.noteModel = noteModel; + stack.forEach((stk) => { + current = stk; + current.from = common$1.getMin(current.from, noteModel.startx); + current.to = common$1.getMax(current.to, noteModel.startx + noteModel.width); + current.width = common$1.getMax(current.width, Math.abs(current.from - current.to)) - conf.labelBoxWidth; + }); + } else { + msgModel = buildMessageModel(msg, actors, diagObj); + msg.msgModel = msgModel; + if (msgModel.startx && msgModel.stopx && stack.length > 0) { + stack.forEach((stk) => { + current = stk; + if (msgModel.startx === msgModel.stopx) { + const from = actors[msg.from]; + const to = actors[msg.to]; + current.from = common$1.getMin( + from.x - msgModel.width / 2, + from.x - from.width / 2, + current.from + ); + current.to = common$1.getMax( + to.x + msgModel.width / 2, + to.x + from.width / 2, + current.to + ); + current.width = common$1.getMax(current.width, Math.abs(current.to - current.from)) - conf.labelBoxWidth; + } else { + current.from = common$1.getMin(msgModel.startx, current.from); + current.to = common$1.getMax(msgModel.stopx, current.to); + current.width = common$1.getMax(current.width, msgModel.width) - conf.labelBoxWidth; + } + }); + } + } + } + bounds.activations = []; + log$1.debug("Loop type widths:", loops); + return loops; +}; +const renderer = { + bounds, + drawActors, + drawActorsPopup, + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: ({ wrap }) => { + db.setWrap(wrap); + } +}; + +export { diagram }; diff --git a/libs/marked/stateDiagram-5dee940d-CIjdI-3m.js b/libs/marked/stateDiagram-5dee940d-CIjdI-3m.js new file mode 100644 index 0000000..2dbe7f4 --- /dev/null +++ b/libs/marked/stateDiagram-5dee940d-CIjdI-3m.js @@ -0,0 +1,453 @@ +import { p as parser$1, d as db, s as styles } from './styles-0784dbeb-Bdyg1j0L.js'; +import { c as getConfig, h as select, l as log$1, i as configureSvgSize, j as common$1, F as curveBasis, A as utils } from './index-CN3YjQ0n.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { l as layout } from './layout-BOZlZI7g.js'; +import { l as line } from './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +const drawStartState = (g) => g.append("circle").attr("class", "start-state").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit); +const drawDivider = (g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig().state.textHeight).attr("class", "divider").attr("x2", getConfig().state.textHeight * 2).attr("y1", 0).attr("y2", 0); +const drawSimpleState = (g, stateDef) => { + const state = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 2 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id); + const classBox = state.node().getBBox(); + g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", classBox.width + 2 * getConfig().state.padding).attr("height", classBox.height + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius); + return state; +}; +const drawDescrState = (g, stateDef) => { + const addTspan = function(textEl, txt, isFirst2) { + const tSpan = textEl.append("tspan").attr("x", 2 * getConfig().state.padding).text(txt); + if (!isFirst2) { + tSpan.attr("dy", getConfig().state.textHeight); + } + }; + const title = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 1.3 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]); + const titleBox = title.node().getBBox(); + const titleHeight = titleBox.height; + const description = g.append("text").attr("x", getConfig().state.padding).attr( + "y", + titleHeight + getConfig().state.padding * 0.4 + getConfig().state.dividerMargin + getConfig().state.textHeight + ).attr("class", "state-description"); + let isFirst = true; + let isSecond = true; + stateDef.descriptions.forEach(function(descr) { + if (!isFirst) { + addTspan(description, descr, isSecond); + isSecond = false; + } + isFirst = false; + }); + const descrLine = g.append("line").attr("x1", getConfig().state.padding).attr("y1", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("y2", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("class", "descr-divider"); + const descrBox = description.node().getBBox(); + const width = Math.max(descrBox.width, titleBox.width); + descrLine.attr("x2", width + 3 * getConfig().state.padding); + g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", width + 2 * getConfig().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius); + return g; +}; +const addTitleAndBox = (g, stateDef, altBkg) => { + const pad = getConfig().state.padding; + const dblPad = 2 * getConfig().state.padding; + const orgBox = g.node().getBBox(); + const orgWidth = orgBox.width; + const orgX = orgBox.x; + const title = g.append("text").attr("x", 0).attr("y", getConfig().state.titleShift).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id); + const titleBox = title.node().getBBox(); + const titleWidth = titleBox.width + dblPad; + let width = Math.max(titleWidth, orgWidth); + if (width === orgWidth) { + width = width + dblPad; + } + let startX; + const graphBox = g.node().getBBox(); + if (stateDef.doc) + ; + startX = orgX - pad; + if (titleWidth > orgWidth) { + startX = (orgWidth - width) / 2 + pad; + } + if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) { + startX = orgX - (titleWidth - orgWidth) / 2; + } + const lineY = 1 - getConfig().state.textHeight; + g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr( + "height", + graphBox.height + getConfig().state.textHeight + getConfig().state.titleShift + 1 + ).attr("rx", "0"); + title.attr("x", startX + pad); + if (titleWidth <= orgWidth) { + title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad); + } + g.insert("rect", ":first-child").attr("x", startX).attr( + "y", + getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding + ).attr("width", width).attr("height", getConfig().state.textHeight * 3).attr("rx", getConfig().state.radius); + g.insert("rect", ":first-child").attr("x", startX).attr( + "y", + getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding + ).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig().state.textHeight).attr("rx", getConfig().state.radius); + return g; +}; +const drawEndState = (g) => { + g.append("circle").attr("class", "end-state-outer").attr("r", getConfig().state.sizeUnit + getConfig().state.miniPadding).attr( + "cx", + getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding + ).attr( + "cy", + getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding + ); + return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit + 2).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit + 2); +}; +const drawForkJoinState = (g, stateDef) => { + let width = getConfig().state.forkWidth; + let height = getConfig().state.forkHeight; + if (stateDef.parentId) { + let tmp = width; + width = height; + height = tmp; + } + return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig().state.padding).attr("y", getConfig().state.padding); +}; +const _drawLongText = (_text, x, y, g) => { + let textHeight = 0; + const textElem = g.append("text"); + textElem.style("text-anchor", "start"); + textElem.attr("class", "noteText"); + let text = _text.replace(/\r\n/g, "
    "); + text = text.replace(/\n/g, "
    "); + const lines = text.split(common$1.lineBreakRegex); + let tHeight = 1.25 * getConfig().state.noteMargin; + for (const line2 of lines) { + const txt = line2.trim(); + if (txt.length > 0) { + const span = textElem.append("tspan"); + span.text(txt); + if (tHeight === 0) { + const textBounds = span.node().getBBox(); + tHeight += textBounds.height; + } + textHeight += tHeight; + span.attr("x", x + getConfig().state.noteMargin); + span.attr("y", y + textHeight + 1.25 * getConfig().state.noteMargin); + } + } + return { textWidth: textElem.node().getBBox().width, textHeight }; +}; +const drawNote = (text, g) => { + g.attr("class", "state-note"); + const note = g.append("rect").attr("x", 0).attr("y", getConfig().state.padding); + const rectElem = g.append("g"); + const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem); + note.attr("height", textHeight + 2 * getConfig().state.noteMargin); + note.attr("width", textWidth + getConfig().state.noteMargin * 2); + return note; +}; +const drawState = function(elem, stateDef) { + const id = stateDef.id; + const stateInfo = { + id, + label: stateDef.id, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", id).attr("class", "stateGroup"); + if (stateDef.type === "start") { + drawStartState(g); + } + if (stateDef.type === "end") { + drawEndState(g); + } + if (stateDef.type === "fork" || stateDef.type === "join") { + drawForkJoinState(g, stateDef); + } + if (stateDef.type === "note") { + drawNote(stateDef.note.text, g); + } + if (stateDef.type === "divider") { + drawDivider(g); + } + if (stateDef.type === "default" && stateDef.descriptions.length === 0) { + drawSimpleState(g, stateDef); + } + if (stateDef.type === "default" && stateDef.descriptions.length > 0) { + drawDescrState(g, stateDef); + } + const stateBox = g.node().getBBox(); + stateInfo.width = stateBox.width + 2 * getConfig().state.padding; + stateInfo.height = stateBox.height + 2 * getConfig().state.padding; + return stateInfo; +}; +let edgeCount = 0; +const drawEdge = function(elem, path, relation) { + const getRelationType = function(type) { + switch (type) { + case db.relationType.AGGREGATION: + return "aggregation"; + case db.relationType.EXTENSION: + return "extension"; + case db.relationType.COMPOSITION: + return "composition"; + case db.relationType.DEPENDENCY: + return "dependency"; + } + }; + path.points = path.points.filter((p) => !Number.isNaN(p.y)); + const lineData = path.points; + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition"); + let url = ""; + if (getConfig().state.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + svgPath.attr( + "marker-end", + "url(" + url + "#" + getRelationType(db.relationType.DEPENDENCY) + "End)" + ); + if (relation.title !== void 0) { + const label = elem.append("g").attr("class", "stateLabel"); + const { x, y } = utils.calcLabelPosition(path.points); + const rows = common$1.getRows(relation.title); + let titleHeight = 0; + const titleRows = []; + let maxWidth = 0; + let minX = 0; + for (let i = 0; i <= rows.length; i++) { + const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight); + const boundsTmp = title.node().getBBox(); + maxWidth = Math.max(maxWidth, boundsTmp.width); + minX = Math.min(minX, boundsTmp.x); + log$1.info(boundsTmp.x, x, y + titleHeight); + if (titleHeight === 0) { + const titleBox = title.node().getBBox(); + titleHeight = titleBox.height; + log$1.info("Title height", titleHeight, y); + } + titleRows.push(title); + } + let boxHeight = titleHeight * rows.length; + if (rows.length > 1) { + const heightAdj = (rows.length - 1) * titleHeight * 0.5; + titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj)); + boxHeight = titleHeight * rows.length; + } + const bounds = label.node().getBBox(); + label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig().state.padding).attr("height", boxHeight + getConfig().state.padding); + log$1.info(bounds); + } + edgeCount++; +}; +let conf; +const transformationLog = {}; +const setConf = function() { +}; +const insertMarkers = function(elem) { + elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z"); +}; +const draw = function(text, id, _version, diagObj) { + conf = getConfig().state; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + log$1.debug("Rendering diagram " + text); + const diagram2 = root.select(`[id='${id}']`); + insertMarkers(diagram2); + const rootDoc = diagObj.db.getRootDoc(); + renderDoc(rootDoc, diagram2, void 0, false, root, doc, diagObj); + const padding = conf.padding; + const bounds = diagram2.node().getBBox(); + const width = bounds.width + padding * 2; + const height = bounds.height + padding * 2; + const svgWidth = width * 1.75; + configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth); + diagram2.attr( + "viewBox", + `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height + ); +}; +const getLabelWidth = (text) => { + return text ? text.length * conf.fontSizeFactor : 1; +}; +const renderDoc = (doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => { + const graph = new Graph({ + compound: true, + multigraph: true + }); + let i; + let edgeFreeDoc = true; + for (i = 0; i < doc.length; i++) { + if (doc[i].stmt === "relation") { + edgeFreeDoc = false; + break; + } + } + if (parentId) { + graph.setGraph({ + rankdir: "LR", + multigraph: true, + compound: true, + // acyclicer: 'greedy', + ranker: "tight-tree", + ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor, + nodeSep: edgeFreeDoc ? 1 : 50, + isMultiGraph: true + // ranksep: 5, + // nodesep: 1 + }); + } else { + graph.setGraph({ + rankdir: "TB", + multigraph: true, + compound: true, + // isCompound: true, + // acyclicer: 'greedy', + // ranker: 'longest-path' + ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor, + nodeSep: edgeFreeDoc ? 1 : 50, + ranker: "tight-tree", + // ranker: 'network-simplex' + isMultiGraph: true + }); + } + graph.setDefaultEdgeLabel(function() { + return {}; + }); + diagObj.db.extract(doc); + const states = diagObj.db.getStates(); + const relations = diagObj.db.getRelations(); + const keys2 = Object.keys(states); + for (const key of keys2) { + const stateDef = states[key]; + if (parentId) { + stateDef.parentId = parentId; + } + let node; + if (stateDef.doc) { + let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup"); + node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj); + { + sub = addTitleAndBox(sub, stateDef, altBkg); + let boxBounds = sub.node().getBBox(); + node.width = boxBounds.width; + node.height = boxBounds.height + conf.padding / 2; + transformationLog[stateDef.id] = { y: conf.compositTitleSize }; + } + } else { + node = drawState(diagram2, stateDef); + } + if (stateDef.note) { + const noteDef = { + descriptions: [], + id: stateDef.id + "-note", + note: stateDef.note, + type: "note" + }; + const note = drawState(diagram2, noteDef); + if (stateDef.note.position === "left of") { + graph.setNode(node.id + "-note", note); + graph.setNode(node.id, node); + } else { + graph.setNode(node.id, node); + graph.setNode(node.id + "-note", note); + } + graph.setParent(node.id, node.id + "-group"); + graph.setParent(node.id + "-note", node.id + "-group"); + } else { + graph.setNode(node.id, node); + } + } + log$1.debug("Count=", graph.nodeCount(), graph); + let cnt = 0; + relations.forEach(function(relation) { + cnt++; + log$1.debug("Setting edge", relation); + graph.setEdge( + relation.id1, + relation.id2, + { + relation, + width: getLabelWidth(relation.title), + height: conf.labelHeight * common$1.getRows(relation.title).length, + labelpos: "c" + }, + "id" + cnt + ); + }); + layout(graph); + log$1.debug("Graph after layout", graph.nodes()); + const svgElem = diagram2.node(); + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + log$1.warn("Node " + v + ": " + JSON.stringify(graph.node(v))); + root.select("#" + svgElem.id + " #" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )" + ); + root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2); + const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider"); + dividers.forEach((divider) => { + const parent = divider.parentElement; + let pWidth = 0; + let pShift = 0; + if (parent) { + if (parent.parentElement) { + pWidth = parent.parentElement.getBBox().width; + } + pShift = parseInt(parent.getAttribute("data-x-shift"), 10); + if (Number.isNaN(pShift)) { + pShift = 0; + } + } + divider.setAttribute("x1", 0 - pShift + 8); + divider.setAttribute("x2", pWidth - pShift - 8); + }); + } else { + log$1.debug("No Node " + v + ": " + JSON.stringify(graph.node(v))); + } + }); + let stateBox = svgElem.getBBox(); + graph.edges().forEach(function(e) { + if (e !== void 0 && graph.edge(e) !== void 0) { + log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e))); + drawEdge(diagram2, graph.edge(e), graph.edge(e).relation); + } + }); + stateBox = svgElem.getBBox(); + const stateInfo = { + id: parentId ? parentId : "root", + label: parentId ? parentId : "root", + width: 0, + height: 0 + }; + stateInfo.width = stateBox.width + 2 * conf.padding; + stateInfo.height = stateBox.height + 2 * conf.padding; + log$1.debug("Doc rendered", stateInfo, graph); + return stateInfo; +}; +const renderer = { + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.state) { + cnf.state = {}; + } + cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/stateDiagram-5dee940d-D8Ibqruy.js b/libs/marked/stateDiagram-5dee940d-D8Ibqruy.js new file mode 100644 index 0000000..ecbd152 --- /dev/null +++ b/libs/marked/stateDiagram-5dee940d-D8Ibqruy.js @@ -0,0 +1,453 @@ +import { p as parser$1, d as db, s as styles } from './styles-0784dbeb-C6NnWPLx.js'; +import { c as getConfig, h as select, l as log$1, i as configureSvgSize, j as common$1, F as curveBasis, A as utils } from './index-Bd_FDXSq.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { l as layout } from './layout-BnytXFfq.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +const drawStartState = (g) => g.append("circle").attr("class", "start-state").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit); +const drawDivider = (g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig().state.textHeight).attr("class", "divider").attr("x2", getConfig().state.textHeight * 2).attr("y1", 0).attr("y2", 0); +const drawSimpleState = (g, stateDef) => { + const state = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 2 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id); + const classBox = state.node().getBBox(); + g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", classBox.width + 2 * getConfig().state.padding).attr("height", classBox.height + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius); + return state; +}; +const drawDescrState = (g, stateDef) => { + const addTspan = function(textEl, txt, isFirst2) { + const tSpan = textEl.append("tspan").attr("x", 2 * getConfig().state.padding).text(txt); + if (!isFirst2) { + tSpan.attr("dy", getConfig().state.textHeight); + } + }; + const title = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 1.3 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]); + const titleBox = title.node().getBBox(); + const titleHeight = titleBox.height; + const description = g.append("text").attr("x", getConfig().state.padding).attr( + "y", + titleHeight + getConfig().state.padding * 0.4 + getConfig().state.dividerMargin + getConfig().state.textHeight + ).attr("class", "state-description"); + let isFirst = true; + let isSecond = true; + stateDef.descriptions.forEach(function(descr) { + if (!isFirst) { + addTspan(description, descr, isSecond); + isSecond = false; + } + isFirst = false; + }); + const descrLine = g.append("line").attr("x1", getConfig().state.padding).attr("y1", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("y2", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("class", "descr-divider"); + const descrBox = description.node().getBBox(); + const width = Math.max(descrBox.width, titleBox.width); + descrLine.attr("x2", width + 3 * getConfig().state.padding); + g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", width + 2 * getConfig().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius); + return g; +}; +const addTitleAndBox = (g, stateDef, altBkg) => { + const pad = getConfig().state.padding; + const dblPad = 2 * getConfig().state.padding; + const orgBox = g.node().getBBox(); + const orgWidth = orgBox.width; + const orgX = orgBox.x; + const title = g.append("text").attr("x", 0).attr("y", getConfig().state.titleShift).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id); + const titleBox = title.node().getBBox(); + const titleWidth = titleBox.width + dblPad; + let width = Math.max(titleWidth, orgWidth); + if (width === orgWidth) { + width = width + dblPad; + } + let startX; + const graphBox = g.node().getBBox(); + if (stateDef.doc) + ; + startX = orgX - pad; + if (titleWidth > orgWidth) { + startX = (orgWidth - width) / 2 + pad; + } + if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) { + startX = orgX - (titleWidth - orgWidth) / 2; + } + const lineY = 1 - getConfig().state.textHeight; + g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr( + "height", + graphBox.height + getConfig().state.textHeight + getConfig().state.titleShift + 1 + ).attr("rx", "0"); + title.attr("x", startX + pad); + if (titleWidth <= orgWidth) { + title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad); + } + g.insert("rect", ":first-child").attr("x", startX).attr( + "y", + getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding + ).attr("width", width).attr("height", getConfig().state.textHeight * 3).attr("rx", getConfig().state.radius); + g.insert("rect", ":first-child").attr("x", startX).attr( + "y", + getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding + ).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig().state.textHeight).attr("rx", getConfig().state.radius); + return g; +}; +const drawEndState = (g) => { + g.append("circle").attr("class", "end-state-outer").attr("r", getConfig().state.sizeUnit + getConfig().state.miniPadding).attr( + "cx", + getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding + ).attr( + "cy", + getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding + ); + return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit + 2).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit + 2); +}; +const drawForkJoinState = (g, stateDef) => { + let width = getConfig().state.forkWidth; + let height = getConfig().state.forkHeight; + if (stateDef.parentId) { + let tmp = width; + width = height; + height = tmp; + } + return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig().state.padding).attr("y", getConfig().state.padding); +}; +const _drawLongText = (_text, x, y, g) => { + let textHeight = 0; + const textElem = g.append("text"); + textElem.style("text-anchor", "start"); + textElem.attr("class", "noteText"); + let text = _text.replace(/\r\n/g, "
    "); + text = text.replace(/\n/g, "
    "); + const lines = text.split(common$1.lineBreakRegex); + let tHeight = 1.25 * getConfig().state.noteMargin; + for (const line2 of lines) { + const txt = line2.trim(); + if (txt.length > 0) { + const span = textElem.append("tspan"); + span.text(txt); + if (tHeight === 0) { + const textBounds = span.node().getBBox(); + tHeight += textBounds.height; + } + textHeight += tHeight; + span.attr("x", x + getConfig().state.noteMargin); + span.attr("y", y + textHeight + 1.25 * getConfig().state.noteMargin); + } + } + return { textWidth: textElem.node().getBBox().width, textHeight }; +}; +const drawNote = (text, g) => { + g.attr("class", "state-note"); + const note = g.append("rect").attr("x", 0).attr("y", getConfig().state.padding); + const rectElem = g.append("g"); + const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem); + note.attr("height", textHeight + 2 * getConfig().state.noteMargin); + note.attr("width", textWidth + getConfig().state.noteMargin * 2); + return note; +}; +const drawState = function(elem, stateDef) { + const id = stateDef.id; + const stateInfo = { + id, + label: stateDef.id, + width: 0, + height: 0 + }; + const g = elem.append("g").attr("id", id).attr("class", "stateGroup"); + if (stateDef.type === "start") { + drawStartState(g); + } + if (stateDef.type === "end") { + drawEndState(g); + } + if (stateDef.type === "fork" || stateDef.type === "join") { + drawForkJoinState(g, stateDef); + } + if (stateDef.type === "note") { + drawNote(stateDef.note.text, g); + } + if (stateDef.type === "divider") { + drawDivider(g); + } + if (stateDef.type === "default" && stateDef.descriptions.length === 0) { + drawSimpleState(g, stateDef); + } + if (stateDef.type === "default" && stateDef.descriptions.length > 0) { + drawDescrState(g, stateDef); + } + const stateBox = g.node().getBBox(); + stateInfo.width = stateBox.width + 2 * getConfig().state.padding; + stateInfo.height = stateBox.height + 2 * getConfig().state.padding; + return stateInfo; +}; +let edgeCount = 0; +const drawEdge = function(elem, path, relation) { + const getRelationType = function(type) { + switch (type) { + case db.relationType.AGGREGATION: + return "aggregation"; + case db.relationType.EXTENSION: + return "extension"; + case db.relationType.COMPOSITION: + return "composition"; + case db.relationType.DEPENDENCY: + return "dependency"; + } + }; + path.points = path.points.filter((p) => !Number.isNaN(p.y)); + const lineData = path.points; + const lineFunction = line().x(function(d) { + return d.x; + }).y(function(d) { + return d.y; + }).curve(curveBasis); + const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition"); + let url = ""; + if (getConfig().state.arrowMarkerAbsolute) { + url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; + url = url.replace(/\(/g, "\\("); + url = url.replace(/\)/g, "\\)"); + } + svgPath.attr( + "marker-end", + "url(" + url + "#" + getRelationType(db.relationType.DEPENDENCY) + "End)" + ); + if (relation.title !== void 0) { + const label = elem.append("g").attr("class", "stateLabel"); + const { x, y } = utils.calcLabelPosition(path.points); + const rows = common$1.getRows(relation.title); + let titleHeight = 0; + const titleRows = []; + let maxWidth = 0; + let minX = 0; + for (let i = 0; i <= rows.length; i++) { + const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight); + const boundsTmp = title.node().getBBox(); + maxWidth = Math.max(maxWidth, boundsTmp.width); + minX = Math.min(minX, boundsTmp.x); + log$1.info(boundsTmp.x, x, y + titleHeight); + if (titleHeight === 0) { + const titleBox = title.node().getBBox(); + titleHeight = titleBox.height; + log$1.info("Title height", titleHeight, y); + } + titleRows.push(title); + } + let boxHeight = titleHeight * rows.length; + if (rows.length > 1) { + const heightAdj = (rows.length - 1) * titleHeight * 0.5; + titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj)); + boxHeight = titleHeight * rows.length; + } + const bounds = label.node().getBBox(); + label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig().state.padding).attr("height", boxHeight + getConfig().state.padding); + log$1.info(bounds); + } + edgeCount++; +}; +let conf; +const transformationLog = {}; +const setConf = function() { +}; +const insertMarkers = function(elem) { + elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z"); +}; +const draw = function(text, id, _version, diagObj) { + conf = getConfig().state; + const securityLevel = getConfig().securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + log$1.debug("Rendering diagram " + text); + const diagram2 = root.select(`[id='${id}']`); + insertMarkers(diagram2); + const rootDoc = diagObj.db.getRootDoc(); + renderDoc(rootDoc, diagram2, void 0, false, root, doc, diagObj); + const padding = conf.padding; + const bounds = diagram2.node().getBBox(); + const width = bounds.width + padding * 2; + const height = bounds.height + padding * 2; + const svgWidth = width * 1.75; + configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth); + diagram2.attr( + "viewBox", + `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height + ); +}; +const getLabelWidth = (text) => { + return text ? text.length * conf.fontSizeFactor : 1; +}; +const renderDoc = (doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => { + const graph = new Graph({ + compound: true, + multigraph: true + }); + let i; + let edgeFreeDoc = true; + for (i = 0; i < doc.length; i++) { + if (doc[i].stmt === "relation") { + edgeFreeDoc = false; + break; + } + } + if (parentId) { + graph.setGraph({ + rankdir: "LR", + multigraph: true, + compound: true, + // acyclicer: 'greedy', + ranker: "tight-tree", + ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor, + nodeSep: edgeFreeDoc ? 1 : 50, + isMultiGraph: true + // ranksep: 5, + // nodesep: 1 + }); + } else { + graph.setGraph({ + rankdir: "TB", + multigraph: true, + compound: true, + // isCompound: true, + // acyclicer: 'greedy', + // ranker: 'longest-path' + ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor, + nodeSep: edgeFreeDoc ? 1 : 50, + ranker: "tight-tree", + // ranker: 'network-simplex' + isMultiGraph: true + }); + } + graph.setDefaultEdgeLabel(function() { + return {}; + }); + diagObj.db.extract(doc); + const states = diagObj.db.getStates(); + const relations = diagObj.db.getRelations(); + const keys2 = Object.keys(states); + for (const key of keys2) { + const stateDef = states[key]; + if (parentId) { + stateDef.parentId = parentId; + } + let node; + if (stateDef.doc) { + let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup"); + node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj); + { + sub = addTitleAndBox(sub, stateDef, altBkg); + let boxBounds = sub.node().getBBox(); + node.width = boxBounds.width; + node.height = boxBounds.height + conf.padding / 2; + transformationLog[stateDef.id] = { y: conf.compositTitleSize }; + } + } else { + node = drawState(diagram2, stateDef); + } + if (stateDef.note) { + const noteDef = { + descriptions: [], + id: stateDef.id + "-note", + note: stateDef.note, + type: "note" + }; + const note = drawState(diagram2, noteDef); + if (stateDef.note.position === "left of") { + graph.setNode(node.id + "-note", note); + graph.setNode(node.id, node); + } else { + graph.setNode(node.id, node); + graph.setNode(node.id + "-note", note); + } + graph.setParent(node.id, node.id + "-group"); + graph.setParent(node.id + "-note", node.id + "-group"); + } else { + graph.setNode(node.id, node); + } + } + log$1.debug("Count=", graph.nodeCount(), graph); + let cnt = 0; + relations.forEach(function(relation) { + cnt++; + log$1.debug("Setting edge", relation); + graph.setEdge( + relation.id1, + relation.id2, + { + relation, + width: getLabelWidth(relation.title), + height: conf.labelHeight * common$1.getRows(relation.title).length, + labelpos: "c" + }, + "id" + cnt + ); + }); + layout(graph); + log$1.debug("Graph after layout", graph.nodes()); + const svgElem = diagram2.node(); + graph.nodes().forEach(function(v) { + if (v !== void 0 && graph.node(v) !== void 0) { + log$1.warn("Node " + v + ": " + JSON.stringify(graph.node(v))); + root.select("#" + svgElem.id + " #" + v).attr( + "transform", + "translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )" + ); + root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2); + const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider"); + dividers.forEach((divider) => { + const parent = divider.parentElement; + let pWidth = 0; + let pShift = 0; + if (parent) { + if (parent.parentElement) { + pWidth = parent.parentElement.getBBox().width; + } + pShift = parseInt(parent.getAttribute("data-x-shift"), 10); + if (Number.isNaN(pShift)) { + pShift = 0; + } + } + divider.setAttribute("x1", 0 - pShift + 8); + divider.setAttribute("x2", pWidth - pShift - 8); + }); + } else { + log$1.debug("No Node " + v + ": " + JSON.stringify(graph.node(v))); + } + }); + let stateBox = svgElem.getBBox(); + graph.edges().forEach(function(e) { + if (e !== void 0 && graph.edge(e) !== void 0) { + log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e))); + drawEdge(diagram2, graph.edge(e), graph.edge(e).relation); + } + }); + stateBox = svgElem.getBBox(); + const stateInfo = { + id: parentId ? parentId : "root", + label: parentId ? parentId : "root", + width: 0, + height: 0 + }; + stateInfo.width = stateBox.width + 2 * conf.padding; + stateInfo.height = stateBox.height + 2 * conf.padding; + log$1.debug("Doc rendered", stateInfo, graph); + return stateInfo; +}; +const renderer = { + setConf, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.state) { + cnf.state = {}; + } + cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/stateDiagram-v2-1992cada-BiJohYZs.js b/libs/marked/stateDiagram-v2-1992cada-BiJohYZs.js new file mode 100644 index 0000000..8904d13 --- /dev/null +++ b/libs/marked/stateDiagram-v2-1992cada-BiJohYZs.js @@ -0,0 +1,325 @@ +import { p as parser$1, d as db, s as styles, D as DEFAULT_STATE_TYPE, a as DIVIDER_TYPE, S as STMT_RELATION, b as STMT_STATE, c as DEFAULT_NESTED_DOC_DIR } from './styles-0784dbeb-Bdyg1j0L.js'; +import { G as Graph } from './graph-DadsyNmk.js'; +import { l as log$1, c as getConfig, h as select, A as utils, i as configureSvgSize, j as common$1 } from './index-CN3YjQ0n.js'; +import { r as render } from './index-01f381cb-CDFlKdjO.js'; +import './layout-BOZlZI7g.js'; +import './clone-B4k62NSz.js'; +import './edges-066a5561-a6s42o55.js'; +import './createText-ca0c5216-DF05SDfj.js'; +import './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +const SHAPE_STATE = "rect"; +const SHAPE_STATE_WITH_DESC = "rectWithTitle"; +const SHAPE_START = "start"; +const SHAPE_END = "end"; +const SHAPE_DIVIDER = "divider"; +const SHAPE_GROUP = "roundedWithTitle"; +const SHAPE_NOTE = "note"; +const SHAPE_NOTEGROUP = "noteGroup"; +const CSS_DIAGRAM = "statediagram"; +const CSS_STATE = "state"; +const CSS_DIAGRAM_STATE = `${CSS_DIAGRAM}-${CSS_STATE}`; +const CSS_EDGE = "transition"; +const CSS_NOTE = "note"; +const CSS_NOTE_EDGE = "note-edge"; +const CSS_EDGE_NOTE_EDGE = `${CSS_EDGE} ${CSS_NOTE_EDGE}`; +const CSS_DIAGRAM_NOTE = `${CSS_DIAGRAM}-${CSS_NOTE}`; +const CSS_CLUSTER = "cluster"; +const CSS_DIAGRAM_CLUSTER = `${CSS_DIAGRAM}-${CSS_CLUSTER}`; +const CSS_CLUSTER_ALT = "cluster-alt"; +const CSS_DIAGRAM_CLUSTER_ALT = `${CSS_DIAGRAM}-${CSS_CLUSTER_ALT}`; +const PARENT = "parent"; +const NOTE = "note"; +const DOMID_STATE = "state"; +const DOMID_TYPE_SPACER = "----"; +const NOTE_ID = `${DOMID_TYPE_SPACER}${NOTE}`; +const PARENT_ID = `${DOMID_TYPE_SPACER}${PARENT}`; +const G_EDGE_STYLE = "fill:none"; +const G_EDGE_ARROWHEADSTYLE = "fill: #333"; +const G_EDGE_LABELPOS = "c"; +const G_EDGE_LABELTYPE = "text"; +const G_EDGE_THICKNESS = "normal"; +let nodeDb = {}; +let graphItemCount = 0; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + cnf[key]; + } +}; +const getClasses = function(text, diagramObj) { + diagramObj.db.extract(diagramObj.db.getRootDocV2()); + return diagramObj.db.getClasses(); +}; +function getClassesFromDbInfo(dbInfoItem) { + if (dbInfoItem === void 0 || dbInfoItem === null) { + return ""; + } else { + if (dbInfoItem.classes) { + return dbInfoItem.classes.join(" "); + } else { + return ""; + } + } +} +function stateDomId(itemId = "", counter = 0, type = "", typeSpacer = DOMID_TYPE_SPACER) { + const typeStr = type !== null && type.length > 0 ? `${typeSpacer}${type}` : ""; + return `${DOMID_STATE}-${itemId}${typeStr}-${counter}`; +} +const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => { + const itemId = parsedItem.id; + const classStr = getClassesFromDbInfo(diagramStates[itemId]); + if (itemId !== "root") { + let shape = SHAPE_STATE; + if (parsedItem.start === true) { + shape = SHAPE_START; + } + if (parsedItem.start === false) { + shape = SHAPE_END; + } + if (parsedItem.type !== DEFAULT_STATE_TYPE) { + shape = parsedItem.type; + } + if (!nodeDb[itemId]) { + nodeDb[itemId] = { + id: itemId, + shape, + description: common$1.sanitizeText(itemId, getConfig()), + classes: `${classStr} ${CSS_DIAGRAM_STATE}` + }; + } + const newNode = nodeDb[itemId]; + if (parsedItem.description) { + if (Array.isArray(newNode.description)) { + newNode.shape = SHAPE_STATE_WITH_DESC; + newNode.description.push(parsedItem.description); + } else { + if (newNode.description.length > 0) { + newNode.shape = SHAPE_STATE_WITH_DESC; + if (newNode.description === itemId) { + newNode.description = [parsedItem.description]; + } else { + newNode.description = [newNode.description, parsedItem.description]; + } + } else { + newNode.shape = SHAPE_STATE; + newNode.description = parsedItem.description; + } + } + newNode.description = common$1.sanitizeTextOrArray(newNode.description, getConfig()); + } + if (newNode.description.length === 1 && newNode.shape === SHAPE_STATE_WITH_DESC) { + newNode.shape = SHAPE_STATE; + } + if (!newNode.type && parsedItem.doc) { + log$1.info("Setting cluster for ", itemId, getDir(parsedItem)); + newNode.type = "group"; + newNode.dir = getDir(parsedItem); + newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP; + newNode.classes = newNode.classes + " " + CSS_DIAGRAM_CLUSTER + " " + (altFlag ? CSS_DIAGRAM_CLUSTER_ALT : ""); + } + const nodeData = { + labelStyle: "", + shape: newNode.shape, + labelText: newNode.description, + // typeof newNode.description === 'object' + // ? newNode.description[0] + // : newNode.description, + classes: newNode.classes, + style: "", + //styles.style, + id: itemId, + dir: newNode.dir, + domId: stateDomId(itemId, graphItemCount), + type: newNode.type, + padding: 15 + //getConfig().flowchart.padding + }; + nodeData.centerLabel = true; + if (parsedItem.note) { + const noteData = { + labelStyle: "", + shape: SHAPE_NOTE, + labelText: parsedItem.note.text, + classes: CSS_DIAGRAM_NOTE, + // useHtmlLabels: false, + style: "", + // styles.style, + id: itemId + NOTE_ID + "-" + graphItemCount, + domId: stateDomId(itemId, graphItemCount, NOTE), + type: newNode.type, + padding: 15 + //getConfig().flowchart.padding + }; + const groupData = { + labelStyle: "", + shape: SHAPE_NOTEGROUP, + labelText: parsedItem.note.text, + classes: newNode.classes, + style: "", + // styles.style, + id: itemId + PARENT_ID, + domId: stateDomId(itemId, graphItemCount, PARENT), + type: "group", + padding: 0 + //getConfig().flowchart.padding + }; + graphItemCount++; + const parentNodeId = itemId + PARENT_ID; + g.setNode(parentNodeId, groupData); + g.setNode(noteData.id, noteData); + g.setNode(itemId, nodeData); + g.setParent(itemId, parentNodeId); + g.setParent(noteData.id, parentNodeId); + let from = itemId; + let to = noteData.id; + if (parsedItem.note.position === "left of") { + from = noteData.id; + to = itemId; + } + g.setEdge(from, to, { + arrowhead: "none", + arrowType: "", + style: G_EDGE_STYLE, + labelStyle: "", + classes: CSS_EDGE_NOTE_EDGE, + arrowheadStyle: G_EDGE_ARROWHEADSTYLE, + labelpos: G_EDGE_LABELPOS, + labelType: G_EDGE_LABELTYPE, + thickness: G_EDGE_THICKNESS + }); + } else { + g.setNode(itemId, nodeData); + } + } + if (parent && parent.id !== "root") { + log$1.trace("Setting node ", itemId, " to be child of its parent ", parent.id); + g.setParent(itemId, parent.id); + } + if (parsedItem.doc) { + log$1.trace("Adding nodes children "); + setupDoc(g, parsedItem, parsedItem.doc, diagramStates, diagramDb, !altFlag); + } +}; +const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) => { + log$1.trace("items", doc); + doc.forEach((item) => { + switch (item.stmt) { + case STMT_STATE: + setupNode(g, parentParsedItem, item, diagramStates, diagramDb, altFlag); + break; + case DEFAULT_STATE_TYPE: + setupNode(g, parentParsedItem, item, diagramStates, diagramDb, altFlag); + break; + case STMT_RELATION: + { + setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); + setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); + const edgeData = { + id: "edge" + graphItemCount, + arrowhead: "normal", + arrowTypeEnd: "arrow_barb", + style: G_EDGE_STYLE, + labelStyle: "", + label: common$1.sanitizeText(item.description, getConfig()), + arrowheadStyle: G_EDGE_ARROWHEADSTYLE, + labelpos: G_EDGE_LABELPOS, + labelType: G_EDGE_LABELTYPE, + thickness: G_EDGE_THICKNESS, + classes: CSS_EDGE + }; + g.setEdge(item.state1.id, item.state2.id, edgeData, graphItemCount); + graphItemCount++; + } + break; + } + }); +}; +const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => { + let dir = defaultDir; + if (parsedItem.doc) { + for (let i = 0; i < parsedItem.doc.length; i++) { + const parsedItemDoc = parsedItem.doc[i]; + if (parsedItemDoc.stmt === "dir") { + dir = parsedItemDoc.value; + } + } + } + return dir; +}; +const draw = async function(text, id, _version, diag) { + log$1.info("Drawing state diagram (v2)", id); + nodeDb = {}; + diag.db.getDirection(); + const { securityLevel, state: conf } = getConfig(); + const nodeSpacing = conf.nodeSpacing || 50; + const rankSpacing = conf.rankSpacing || 50; + log$1.info(diag.db.getRootDocV2()); + diag.db.extract(diag.db.getRootDocV2()); + log$1.info(diag.db.getRootDocV2()); + const diagramStates = diag.db.getStates(); + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: getDir(diag.db.getRootDocV2()), + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + setupNode(g, void 0, diag.db.getRootDocV2(), diagramStates, diag.db, true); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render(element, g, ["barb"], CSS_DIAGRAM, id); + const padding = 8; + utils.insertTitle(svg, "statediagramTitleText", conf.titleTopMargin, diag.db.getDiagramTitle()); + const bounds = svg.node().getBBox(); + const width = bounds.width + padding * 2; + const height = bounds.height + padding * 2; + svg.attr("class", CSS_DIAGRAM); + const svgBounds = svg.node().getBBox(); + configureSvgSize(svg, height, width, conf.useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`; + log$1.debug(`viewBox ${vBox}`); + svg.attr("viewBox", vBox); + const labels = document.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = document.createElementNS("http://www.w3.org/2000/svg", SHAPE_STATE); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } +}; +const renderer = { + setConf, + getClasses, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.state) { + cnf.state = {}; + } + cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/stateDiagram-v2-1992cada-C3cfgmsi.js b/libs/marked/stateDiagram-v2-1992cada-C3cfgmsi.js new file mode 100644 index 0000000..3dc62f5 --- /dev/null +++ b/libs/marked/stateDiagram-v2-1992cada-C3cfgmsi.js @@ -0,0 +1,325 @@ +import { p as parser$1, d as db, s as styles, D as DEFAULT_STATE_TYPE, a as DIVIDER_TYPE, S as STMT_RELATION, b as STMT_STATE, c as DEFAULT_NESTED_DOC_DIR } from './styles-0784dbeb-C6NnWPLx.js'; +import { G as Graph } from './graph-KZW2Npeo.js'; +import { l as log$1, c as getConfig, h as select, A as utils, i as configureSvgSize, j as common$1 } from './index-Bd_FDXSq.js'; +import { r as render } from './index-01f381cb-BCBEZMaa.js'; +import './layout-BnytXFfq.js'; +import './clone-B-QllgkM.js'; +import './edges-066a5561-Bqw9g7uz.js'; +import './createText-ca0c5216-B9KlDTE8.js'; +import './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +const SHAPE_STATE = "rect"; +const SHAPE_STATE_WITH_DESC = "rectWithTitle"; +const SHAPE_START = "start"; +const SHAPE_END = "end"; +const SHAPE_DIVIDER = "divider"; +const SHAPE_GROUP = "roundedWithTitle"; +const SHAPE_NOTE = "note"; +const SHAPE_NOTEGROUP = "noteGroup"; +const CSS_DIAGRAM = "statediagram"; +const CSS_STATE = "state"; +const CSS_DIAGRAM_STATE = `${CSS_DIAGRAM}-${CSS_STATE}`; +const CSS_EDGE = "transition"; +const CSS_NOTE = "note"; +const CSS_NOTE_EDGE = "note-edge"; +const CSS_EDGE_NOTE_EDGE = `${CSS_EDGE} ${CSS_NOTE_EDGE}`; +const CSS_DIAGRAM_NOTE = `${CSS_DIAGRAM}-${CSS_NOTE}`; +const CSS_CLUSTER = "cluster"; +const CSS_DIAGRAM_CLUSTER = `${CSS_DIAGRAM}-${CSS_CLUSTER}`; +const CSS_CLUSTER_ALT = "cluster-alt"; +const CSS_DIAGRAM_CLUSTER_ALT = `${CSS_DIAGRAM}-${CSS_CLUSTER_ALT}`; +const PARENT = "parent"; +const NOTE = "note"; +const DOMID_STATE = "state"; +const DOMID_TYPE_SPACER = "----"; +const NOTE_ID = `${DOMID_TYPE_SPACER}${NOTE}`; +const PARENT_ID = `${DOMID_TYPE_SPACER}${PARENT}`; +const G_EDGE_STYLE = "fill:none"; +const G_EDGE_ARROWHEADSTYLE = "fill: #333"; +const G_EDGE_LABELPOS = "c"; +const G_EDGE_LABELTYPE = "text"; +const G_EDGE_THICKNESS = "normal"; +let nodeDb = {}; +let graphItemCount = 0; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + cnf[key]; + } +}; +const getClasses = function(text, diagramObj) { + diagramObj.db.extract(diagramObj.db.getRootDocV2()); + return diagramObj.db.getClasses(); +}; +function getClassesFromDbInfo(dbInfoItem) { + if (dbInfoItem === void 0 || dbInfoItem === null) { + return ""; + } else { + if (dbInfoItem.classes) { + return dbInfoItem.classes.join(" "); + } else { + return ""; + } + } +} +function stateDomId(itemId = "", counter = 0, type = "", typeSpacer = DOMID_TYPE_SPACER) { + const typeStr = type !== null && type.length > 0 ? `${typeSpacer}${type}` : ""; + return `${DOMID_STATE}-${itemId}${typeStr}-${counter}`; +} +const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => { + const itemId = parsedItem.id; + const classStr = getClassesFromDbInfo(diagramStates[itemId]); + if (itemId !== "root") { + let shape = SHAPE_STATE; + if (parsedItem.start === true) { + shape = SHAPE_START; + } + if (parsedItem.start === false) { + shape = SHAPE_END; + } + if (parsedItem.type !== DEFAULT_STATE_TYPE) { + shape = parsedItem.type; + } + if (!nodeDb[itemId]) { + nodeDb[itemId] = { + id: itemId, + shape, + description: common$1.sanitizeText(itemId, getConfig()), + classes: `${classStr} ${CSS_DIAGRAM_STATE}` + }; + } + const newNode = nodeDb[itemId]; + if (parsedItem.description) { + if (Array.isArray(newNode.description)) { + newNode.shape = SHAPE_STATE_WITH_DESC; + newNode.description.push(parsedItem.description); + } else { + if (newNode.description.length > 0) { + newNode.shape = SHAPE_STATE_WITH_DESC; + if (newNode.description === itemId) { + newNode.description = [parsedItem.description]; + } else { + newNode.description = [newNode.description, parsedItem.description]; + } + } else { + newNode.shape = SHAPE_STATE; + newNode.description = parsedItem.description; + } + } + newNode.description = common$1.sanitizeTextOrArray(newNode.description, getConfig()); + } + if (newNode.description.length === 1 && newNode.shape === SHAPE_STATE_WITH_DESC) { + newNode.shape = SHAPE_STATE; + } + if (!newNode.type && parsedItem.doc) { + log$1.info("Setting cluster for ", itemId, getDir(parsedItem)); + newNode.type = "group"; + newNode.dir = getDir(parsedItem); + newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP; + newNode.classes = newNode.classes + " " + CSS_DIAGRAM_CLUSTER + " " + (altFlag ? CSS_DIAGRAM_CLUSTER_ALT : ""); + } + const nodeData = { + labelStyle: "", + shape: newNode.shape, + labelText: newNode.description, + // typeof newNode.description === 'object' + // ? newNode.description[0] + // : newNode.description, + classes: newNode.classes, + style: "", + //styles.style, + id: itemId, + dir: newNode.dir, + domId: stateDomId(itemId, graphItemCount), + type: newNode.type, + padding: 15 + //getConfig().flowchart.padding + }; + nodeData.centerLabel = true; + if (parsedItem.note) { + const noteData = { + labelStyle: "", + shape: SHAPE_NOTE, + labelText: parsedItem.note.text, + classes: CSS_DIAGRAM_NOTE, + // useHtmlLabels: false, + style: "", + // styles.style, + id: itemId + NOTE_ID + "-" + graphItemCount, + domId: stateDomId(itemId, graphItemCount, NOTE), + type: newNode.type, + padding: 15 + //getConfig().flowchart.padding + }; + const groupData = { + labelStyle: "", + shape: SHAPE_NOTEGROUP, + labelText: parsedItem.note.text, + classes: newNode.classes, + style: "", + // styles.style, + id: itemId + PARENT_ID, + domId: stateDomId(itemId, graphItemCount, PARENT), + type: "group", + padding: 0 + //getConfig().flowchart.padding + }; + graphItemCount++; + const parentNodeId = itemId + PARENT_ID; + g.setNode(parentNodeId, groupData); + g.setNode(noteData.id, noteData); + g.setNode(itemId, nodeData); + g.setParent(itemId, parentNodeId); + g.setParent(noteData.id, parentNodeId); + let from = itemId; + let to = noteData.id; + if (parsedItem.note.position === "left of") { + from = noteData.id; + to = itemId; + } + g.setEdge(from, to, { + arrowhead: "none", + arrowType: "", + style: G_EDGE_STYLE, + labelStyle: "", + classes: CSS_EDGE_NOTE_EDGE, + arrowheadStyle: G_EDGE_ARROWHEADSTYLE, + labelpos: G_EDGE_LABELPOS, + labelType: G_EDGE_LABELTYPE, + thickness: G_EDGE_THICKNESS + }); + } else { + g.setNode(itemId, nodeData); + } + } + if (parent && parent.id !== "root") { + log$1.trace("Setting node ", itemId, " to be child of its parent ", parent.id); + g.setParent(itemId, parent.id); + } + if (parsedItem.doc) { + log$1.trace("Adding nodes children "); + setupDoc(g, parsedItem, parsedItem.doc, diagramStates, diagramDb, !altFlag); + } +}; +const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) => { + log$1.trace("items", doc); + doc.forEach((item) => { + switch (item.stmt) { + case STMT_STATE: + setupNode(g, parentParsedItem, item, diagramStates, diagramDb, altFlag); + break; + case DEFAULT_STATE_TYPE: + setupNode(g, parentParsedItem, item, diagramStates, diagramDb, altFlag); + break; + case STMT_RELATION: + { + setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); + setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); + const edgeData = { + id: "edge" + graphItemCount, + arrowhead: "normal", + arrowTypeEnd: "arrow_barb", + style: G_EDGE_STYLE, + labelStyle: "", + label: common$1.sanitizeText(item.description, getConfig()), + arrowheadStyle: G_EDGE_ARROWHEADSTYLE, + labelpos: G_EDGE_LABELPOS, + labelType: G_EDGE_LABELTYPE, + thickness: G_EDGE_THICKNESS, + classes: CSS_EDGE + }; + g.setEdge(item.state1.id, item.state2.id, edgeData, graphItemCount); + graphItemCount++; + } + break; + } + }); +}; +const getDir = (parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => { + let dir = defaultDir; + if (parsedItem.doc) { + for (let i = 0; i < parsedItem.doc.length; i++) { + const parsedItemDoc = parsedItem.doc[i]; + if (parsedItemDoc.stmt === "dir") { + dir = parsedItemDoc.value; + } + } + } + return dir; +}; +const draw = async function(text, id, _version, diag) { + log$1.info("Drawing state diagram (v2)", id); + nodeDb = {}; + diag.db.getDirection(); + const { securityLevel, state: conf } = getConfig(); + const nodeSpacing = conf.nodeSpacing || 50; + const rankSpacing = conf.rankSpacing || 50; + log$1.info(diag.db.getRootDocV2()); + diag.db.extract(diag.db.getRootDocV2()); + log$1.info(diag.db.getRootDocV2()); + const diagramStates = diag.db.getStates(); + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: getDir(diag.db.getRootDocV2()), + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 8, + marginy: 8 + }).setDefaultEdgeLabel(function() { + return {}; + }); + setupNode(g, void 0, diag.db.getRootDocV2(), diagramStates, diag.db, true); + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render(element, g, ["barb"], CSS_DIAGRAM, id); + const padding = 8; + utils.insertTitle(svg, "statediagramTitleText", conf.titleTopMargin, diag.db.getDiagramTitle()); + const bounds = svg.node().getBBox(); + const width = bounds.width + padding * 2; + const height = bounds.height + padding * 2; + svg.attr("class", CSS_DIAGRAM); + const svgBounds = svg.node().getBBox(); + configureSvgSize(svg, height, width, conf.useMaxWidth); + const vBox = `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`; + log$1.debug(`viewBox ${vBox}`); + svg.attr("viewBox", vBox); + const labels = document.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = document.createElementNS("http://www.w3.org/2000/svg", SHAPE_STATE); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } +}; +const renderer = { + setConf, + getClasses, + draw +}; +const diagram = { + parser: parser$1, + db, + renderer, + styles, + init: (cnf) => { + if (!cnf.state) { + cnf.state = {}; + } + cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute; + db.clear(); + } +}; + +export { diagram }; diff --git a/libs/marked/styles-0784dbeb-Bdyg1j0L.js b/libs/marked/styles-0784dbeb-Bdyg1j0L.js new file mode 100644 index 0000000..45b1e53 --- /dev/null +++ b/libs/marked/styles-0784dbeb-Bdyg1j0L.js @@ -0,0 +1,1356 @@ +import { c as getConfig, g as getAccTitle, s as setAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, j as common$1, E as clear$1, a7 as generateId } from './index-CN3YjQ0n.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 15], $V7 = [1, 16], $V8 = [1, 17], $V9 = [1, 18], $Va = [1, 30], $Vb = [1, 19], $Vc = [1, 20], $Vd = [1, 21], $Ve = [1, 22], $Vf = [1, 23], $Vg = [1, 25], $Vh = [1, 26], $Vi = [1, 27], $Vj = [1, 28], $Vk = [1, 29], $Vl = [1, 32], $Vm = [1, 33], $Vn = [1, 34], $Vo = [1, 35], $Vp = [1, 31], $Vq = [1, 4, 5, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $Vr = [1, 4, 5, 13, 14, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $Vs = [4, 5, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SPACE": 4, "NL": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "classDefStatement": 10, "cssClassStatement": 11, "idStatement": 12, "DESCR": 13, "-->": 14, "HIDE_EMPTY": 15, "scale": 16, "WIDTH": 17, "COMPOSIT_STATE": 18, "STRUCT_START": 19, "STRUCT_STOP": 20, "STATE_DESCR": 21, "AS": 22, "ID": 23, "FORK": 24, "JOIN": 25, "CHOICE": 26, "CONCURRENT": 27, "note": 28, "notePosition": 29, "NOTE_TEXT": 30, "direction": 31, "acc_title": 32, "acc_title_value": 33, "acc_descr": 34, "acc_descr_value": 35, "acc_descr_multiline_value": 36, "classDef": 37, "CLASSDEF_ID": 38, "CLASSDEF_STYLEOPTS": 39, "DEFAULT": 40, "class": 41, "CLASSENTITY_IDS": 42, "STYLECLASS": 43, "direction_tb": 44, "direction_bt": 45, "direction_rl": 46, "direction_lr": 47, "eol": 48, ";": 49, "EDGE_STATE": 50, "STYLE_SEPARATOR": 51, "left_of": 52, "right_of": 53, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACE", 5: "NL", 6: "SD", 13: "DESCR", 14: "-->", 15: "HIDE_EMPTY", 16: "scale", 17: "WIDTH", 18: "COMPOSIT_STATE", 19: "STRUCT_START", 20: "STRUCT_STOP", 21: "STATE_DESCR", 22: "AS", 23: "ID", 24: "FORK", 25: "JOIN", 26: "CHOICE", 27: "CONCURRENT", 28: "note", 30: "NOTE_TEXT", 32: "acc_title", 33: "acc_title_value", 34: "acc_descr", 35: "acc_descr_value", 36: "acc_descr_multiline_value", 37: "classDef", 38: "CLASSDEF_ID", 39: "CLASSDEF_STYLEOPTS", 40: "DEFAULT", 41: "class", 42: "CLASSENTITY_IDS", 43: "STYLECLASS", 44: "direction_tb", 45: "direction_bt", 46: "direction_rl", 47: "direction_lr", 49: ";", 50: "EDGE_STATE", 51: "STYLE_SEPARATOR", 52: "left_of", 53: "right_of" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 3], [9, 4], [9, 1], [9, 2], [9, 1], [9, 4], [9, 3], [9, 6], [9, 1], [9, 1], [9, 1], [9, 1], [9, 4], [9, 4], [9, 1], [9, 2], [9, 2], [9, 1], [10, 3], [10, 3], [11, 3], [31, 1], [31, 1], [31, 1], [31, 1], [48, 1], [48, 1], [12, 1], [12, 1], [12, 3], [12, 3], [29, 1], [29, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setRootDoc($$[$0]); + return $$[$0]; + case 4: + this.$ = []; + break; + case 5: + if ($$[$0] != "nl") { + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + } + break; + case 6: + case 7: + this.$ = $$[$0]; + break; + case 8: + this.$ = "nl"; + break; + case 11: + this.$ = $$[$0]; + break; + case 12: + const stateStmt = $$[$0 - 1]; + stateStmt.description = yy.trimColon($$[$0]); + this.$ = stateStmt; + break; + case 13: + this.$ = { stmt: "relation", state1: $$[$0 - 2], state2: $$[$0] }; + break; + case 14: + const relDescription = yy.trimColon($$[$0]); + this.$ = { stmt: "relation", state1: $$[$0 - 3], state2: $$[$0 - 1], description: relDescription }; + break; + case 18: + this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: "", doc: $$[$0 - 1] }; + break; + case 19: + var id = $$[$0]; + var description = $$[$0 - 2].trim(); + if ($$[$0].match(":")) { + var parts = $$[$0].split(":"); + id = parts[0]; + description = [description, parts[1]]; + } + this.$ = { stmt: "state", id, type: "default", description }; + break; + case 20: + this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: $$[$0 - 5], doc: $$[$0 - 1] }; + break; + case 21: + this.$ = { stmt: "state", id: $$[$0], type: "fork" }; + break; + case 22: + this.$ = { stmt: "state", id: $$[$0], type: "join" }; + break; + case 23: + this.$ = { stmt: "state", id: $$[$0], type: "choice" }; + break; + case 24: + this.$ = { stmt: "state", id: yy.getDividerId(), type: "divider" }; + break; + case 25: + this.$ = { stmt: "state", id: $$[$0 - 1].trim(), note: { position: $$[$0 - 2].trim(), text: $$[$0].trim() } }; + break; + case 28: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 29: + case 30: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 31: + case 32: + this.$ = { stmt: "classDef", id: $$[$0 - 1].trim(), classes: $$[$0].trim() }; + break; + case 33: + this.$ = { stmt: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; + break; + case 34: + yy.setDirection("TB"); + this.$ = { stmt: "dir", value: "TB" }; + break; + case 35: + yy.setDirection("BT"); + this.$ = { stmt: "dir", value: "BT" }; + break; + case 36: + yy.setDirection("RL"); + this.$ = { stmt: "dir", value: "RL" }; + break; + case 37: + yy.setDirection("LR"); + this.$ = { stmt: "dir", value: "LR" }; + break; + case 40: + case 41: + this.$ = { stmt: "state", id: $$[$0].trim(), type: "default", description: "" }; + break; + case 42: + this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" }; + break; + case 43: + this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" }; + break; + } + }, + table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 15, 16, 18, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 5]), { 9: 36, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 7]), o($Vq, [2, 8]), o($Vq, [2, 9]), o($Vq, [2, 10]), o($Vq, [2, 11], { 13: [1, 37], 14: [1, 38] }), o($Vq, [2, 15]), { 17: [1, 39] }, o($Vq, [2, 17], { 19: [1, 40] }), { 22: [1, 41] }, o($Vq, [2, 21]), o($Vq, [2, 22]), o($Vq, [2, 23]), o($Vq, [2, 24]), { 29: 42, 30: [1, 43], 52: [1, 44], 53: [1, 45] }, o($Vq, [2, 27]), { 33: [1, 46] }, { 35: [1, 47] }, o($Vq, [2, 30]), { 38: [1, 48], 40: [1, 49] }, { 42: [1, 50] }, o($Vr, [2, 40], { 51: [1, 51] }), o($Vr, [2, 41], { 51: [1, 52] }), o($Vq, [2, 34]), o($Vq, [2, 35]), o($Vq, [2, 36]), o($Vq, [2, 37]), o($Vq, [2, 6]), o($Vq, [2, 12]), { 12: 53, 23: $Va, 50: $Vp }, o($Vq, [2, 16]), o($Vs, $V3, { 7: 54 }), { 23: [1, 55] }, { 23: [1, 56] }, { 22: [1, 57] }, { 23: [2, 44] }, { 23: [2, 45] }, o($Vq, [2, 28]), o($Vq, [2, 29]), { 39: [1, 58] }, { 39: [1, 59] }, { 43: [1, 60] }, { 23: [1, 61] }, { 23: [1, 62] }, o($Vq, [2, 13], { 13: [1, 63] }), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 20: [1, 64], 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 19], { 19: [1, 65] }), { 30: [1, 66] }, { 23: [1, 67] }, o($Vq, [2, 31]), o($Vq, [2, 32]), o($Vq, [2, 33]), o($Vr, [2, 42]), o($Vr, [2, 43]), o($Vq, [2, 14]), o($Vq, [2, 18]), o($Vs, $V3, { 7: 68 }), o($Vq, [2, 25]), o($Vq, [2, 26]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 20: [1, 69], 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 20])], + defaultActions: { 5: [2, 1], 6: [2, 2], 44: [2, 44], 45: [2, 45] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 40; + case 1: + return 44; + case 2: + return 45; + case 3: + return 46; + case 4: + return 47; + case 5: + break; + case 6: + break; + case 7: + return 5; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + this.pushState("SCALE"); + return 16; + case 13: + return 17; + case 14: + this.popState(); + break; + case 15: + this.begin("acc_title"); + return 32; + case 16: + this.popState(); + return "acc_title_value"; + case 17: + this.begin("acc_descr"); + return 34; + case 18: + this.popState(); + return "acc_descr_value"; + case 19: + this.begin("acc_descr_multiline"); + break; + case 20: + this.popState(); + break; + case 21: + return "acc_descr_multiline_value"; + case 22: + this.pushState("CLASSDEF"); + return 37; + case 23: + this.popState(); + this.pushState("CLASSDEFID"); + return "DEFAULT_CLASSDEF_ID"; + case 24: + this.popState(); + this.pushState("CLASSDEFID"); + return 38; + case 25: + this.popState(); + return 39; + case 26: + this.pushState("CLASS"); + return 41; + case 27: + this.popState(); + this.pushState("CLASS_STYLE"); + return 42; + case 28: + this.popState(); + return 43; + case 29: + this.pushState("SCALE"); + return 16; + case 30: + return 17; + case 31: + this.popState(); + break; + case 32: + this.pushState("STATE"); + break; + case 33: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 24; + case 34: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 25; + case 35: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -10).trim(); + return 26; + case 36: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 24; + case 37: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 25; + case 38: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -10).trim(); + return 26; + case 39: + return 44; + case 40: + return 45; + case 41: + return 46; + case 42: + return 47; + case 43: + this.pushState("STATE_STRING"); + break; + case 44: + this.pushState("STATE_ID"); + return "AS"; + case 45: + this.popState(); + return "ID"; + case 46: + this.popState(); + break; + case 47: + return "STATE_DESCR"; + case 48: + return 18; + case 49: + this.popState(); + break; + case 50: + this.popState(); + this.pushState("struct"); + return 19; + case 51: + break; + case 52: + this.popState(); + return 20; + case 53: + break; + case 54: + this.begin("NOTE"); + return 28; + case 55: + this.popState(); + this.pushState("NOTE_ID"); + return 52; + case 56: + this.popState(); + this.pushState("NOTE_ID"); + return 53; + case 57: + this.popState(); + this.pushState("FLOATING_NOTE"); + break; + case 58: + this.popState(); + this.pushState("FLOATING_NOTE_ID"); + return "AS"; + case 59: + break; + case 60: + return "NOTE_TEXT"; + case 61: + this.popState(); + return "ID"; + case 62: + this.popState(); + this.pushState("NOTE_TEXT"); + return 23; + case 63: + this.popState(); + yy_.yytext = yy_.yytext.substr(2).trim(); + return 30; + case 64: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 30; + case 65: + return 6; + case 66: + return 6; + case 67: + return 15; + case 68: + return 50; + case 69: + return 23; + case 70: + yy_.yytext = yy_.yytext.trim(); + return 13; + case 71: + return 14; + case 72: + return 27; + case 73: + return 51; + case 74: + return 5; + case 75: + return "INVALID"; + } + }, + rules: [/^(?:default\b)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:classDef\s+)/i, /^(?:DEFAULT\s+)/i, /^(?:\w+\s+)/i, /^(?:[^\n]*)/i, /^(?:class\s+)/i, /^(?:(\w+)+((,\s*\w+)*))/i, /^(?:[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:state\s+)/i, /^(?:.*<>)/i, /^(?:.*<>)/i, /^(?:.*<>)/i, /^(?:.*\[\[fork\]\])/i, /^(?:.*\[\[join\]\])/i, /^(?:.*\[\[choice\]\])/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:["])/i, /^(?:\s*as\s+)/i, /^(?:[^\n\{]*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n\s\{]+)/i, /^(?:\n)/i, /^(?:\{)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:\})/i, /^(?:[\n])/i, /^(?:note\s+)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:")/i, /^(?:\s*as\s*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n]*)/i, /^(?:\s*[^:\n\s\-]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:[\s\S]*?end note\b)/i, /^(?:stateDiagram\s+)/i, /^(?:stateDiagram-v2\s+)/i, /^(?:hide empty description\b)/i, /^(?:\[\*\])/i, /^(?:[^:\n\s\-\{]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:-->)/i, /^(?:--)/i, /^(?::::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "LINE": { "rules": [9, 10], "inclusive": false }, "struct": { "rules": [9, 10, 22, 26, 32, 39, 40, 41, 42, 51, 52, 53, 54, 68, 69, 70, 71, 72], "inclusive": false }, "FLOATING_NOTE_ID": { "rules": [61], "inclusive": false }, "FLOATING_NOTE": { "rules": [58, 59, 60], "inclusive": false }, "NOTE_TEXT": { "rules": [63, 64], "inclusive": false }, "NOTE_ID": { "rules": [62], "inclusive": false }, "NOTE": { "rules": [55, 56, 57], "inclusive": false }, "CLASS_STYLE": { "rules": [28], "inclusive": false }, "CLASS": { "rules": [27], "inclusive": false }, "CLASSDEFID": { "rules": [25], "inclusive": false }, "CLASSDEF": { "rules": [23, 24], "inclusive": false }, "acc_descr_multiline": { "rules": [20, 21], "inclusive": false }, "acc_descr": { "rules": [18], "inclusive": false }, "acc_title": { "rules": [16], "inclusive": false }, "SCALE": { "rules": [13, 14, 30, 31], "inclusive": false }, "ALIAS": { "rules": [], "inclusive": false }, "STATE_ID": { "rules": [45], "inclusive": false }, "STATE_STRING": { "rules": [46, 47], "inclusive": false }, "FORK_STATE": { "rules": [], "inclusive": false }, "STATE": { "rules": [9, 10, 33, 34, 35, 36, 37, 38, 43, 44, 48, 49, 50], "inclusive": false }, "ID": { "rules": [9, 10], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 15, 17, 19, 22, 26, 29, 32, 50, 54, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const DEFAULT_DIAGRAM_DIRECTION = "LR"; +const DEFAULT_NESTED_DOC_DIR = "TB"; +const STMT_STATE = "state"; +const STMT_RELATION = "relation"; +const STMT_CLASSDEF = "classDef"; +const STMT_APPLYCLASS = "applyClass"; +const DEFAULT_STATE_TYPE = "default"; +const DIVIDER_TYPE = "divider"; +const START_NODE = "[*]"; +const START_TYPE = "start"; +const END_NODE = START_NODE; +const END_TYPE = "end"; +const COLOR_KEYWORD = "color"; +const FILL_KEYWORD = "fill"; +const BG_FILL = "bgFill"; +const STYLECLASS_SEP = ","; +function newClassesList() { + return {}; +} +let direction = DEFAULT_DIAGRAM_DIRECTION; +let rootDoc = []; +let classes = newClassesList(); +const newDoc = () => { + return { + relations: [], + states: {}, + documents: {} + }; +}; +let documents = { + root: newDoc() +}; +let currentDocument = documents.root; +let startEndCount = 0; +let dividerCnt = 0; +const lineType = { + LINE: 0, + DOTTED_LINE: 1 +}; +const relationType = { + AGGREGATION: 0, + EXTENSION: 1, + COMPOSITION: 2, + DEPENDENCY: 3 +}; +const clone = (o) => JSON.parse(JSON.stringify(o)); +const setRootDoc = (o) => { + log$1.info("Setting root doc", o); + rootDoc = o; +}; +const getRootDoc = () => rootDoc; +const docTranslator = (parent, node, first) => { + if (node.stmt === STMT_RELATION) { + docTranslator(parent, node.state1, true); + docTranslator(parent, node.state2, false); + } else { + if (node.stmt === STMT_STATE) { + if (node.id === "[*]") { + node.id = first ? parent.id + "_start" : parent.id + "_end"; + node.start = first; + } else { + node.id = node.id.trim(); + } + } + if (node.doc) { + const doc = []; + let currentDoc = []; + let i; + for (i = 0; i < node.doc.length; i++) { + if (node.doc[i].type === DIVIDER_TYPE) { + const newNode = clone(node.doc[i]); + newNode.doc = clone(currentDoc); + doc.push(newNode); + currentDoc = []; + } else { + currentDoc.push(node.doc[i]); + } + } + if (doc.length > 0 && currentDoc.length > 0) { + const newNode = { + stmt: STMT_STATE, + id: generateId(), + type: "divider", + doc: clone(currentDoc) + }; + doc.push(clone(newNode)); + node.doc = doc; + } + node.doc.forEach((docNode) => docTranslator(node, docNode, true)); + } + } +}; +const getRootDocV2 = () => { + docTranslator({ id: "root" }, { id: "root", doc: rootDoc }, true); + return { id: "root", doc: rootDoc }; +}; +const extract = (_doc) => { + let doc; + if (_doc.doc) { + doc = _doc.doc; + } else { + doc = _doc; + } + log$1.info(doc); + clear(true); + log$1.info("Extract", doc); + doc.forEach((item) => { + switch (item.stmt) { + case STMT_STATE: + addState( + item.id.trim(), + item.type, + item.doc, + item.description, + item.note, + item.classes, + item.styles, + item.textStyles + ); + break; + case STMT_RELATION: + addRelation(item.state1, item.state2, item.description); + break; + case STMT_CLASSDEF: + addStyleClass(item.id.trim(), item.classes); + break; + case STMT_APPLYCLASS: + setCssClass(item.id.trim(), item.styleClass); + break; + } + }); +}; +const addState = function(id, type = DEFAULT_STATE_TYPE, doc = null, descr = null, note = null, classes2 = null, styles2 = null, textStyles = null) { + const trimmedId = id == null ? void 0 : id.trim(); + if (currentDocument.states[trimmedId] === void 0) { + log$1.info("Adding state ", trimmedId, descr); + currentDocument.states[trimmedId] = { + id: trimmedId, + descriptions: [], + type, + doc, + note, + classes: [], + styles: [], + textStyles: [] + }; + } else { + if (!currentDocument.states[trimmedId].doc) { + currentDocument.states[trimmedId].doc = doc; + } + if (!currentDocument.states[trimmedId].type) { + currentDocument.states[trimmedId].type = type; + } + } + if (descr) { + log$1.info("Setting state description", trimmedId, descr); + if (typeof descr === "string") { + addDescription(trimmedId, descr.trim()); + } + if (typeof descr === "object") { + descr.forEach((des) => addDescription(trimmedId, des.trim())); + } + } + if (note) { + currentDocument.states[trimmedId].note = note; + currentDocument.states[trimmedId].note.text = common$1.sanitizeText( + currentDocument.states[trimmedId].note.text, + getConfig() + ); + } + if (classes2) { + log$1.info("Setting state classes", trimmedId, classes2); + const classesList = typeof classes2 === "string" ? [classes2] : classes2; + classesList.forEach((cssClass) => setCssClass(trimmedId, cssClass.trim())); + } + if (styles2) { + log$1.info("Setting state styles", trimmedId, styles2); + const stylesList = typeof styles2 === "string" ? [styles2] : styles2; + stylesList.forEach((style) => setStyle(trimmedId, style.trim())); + } + if (textStyles) { + log$1.info("Setting state styles", trimmedId, styles2); + const textStylesList = typeof textStyles === "string" ? [textStyles] : textStyles; + textStylesList.forEach((textStyle) => setTextStyle(trimmedId, textStyle.trim())); + } +}; +const clear = function(saveCommon) { + documents = { + root: newDoc() + }; + currentDocument = documents.root; + startEndCount = 0; + classes = newClassesList(); + if (!saveCommon) { + clear$1(); + } +}; +const getState = function(id) { + return currentDocument.states[id]; +}; +const getStates = function() { + return currentDocument.states; +}; +const logDocuments = function() { + log$1.info("Documents = ", documents); +}; +const getRelations = function() { + return currentDocument.relations; +}; +function startIdIfNeeded(id = "") { + let fixedId = id; + if (id === START_NODE) { + startEndCount++; + fixedId = `${START_TYPE}${startEndCount}`; + } + return fixedId; +} +function startTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) { + return id === START_NODE ? START_TYPE : type; +} +function endIdIfNeeded(id = "") { + let fixedId = id; + if (id === END_NODE) { + startEndCount++; + fixedId = `${END_TYPE}${startEndCount}`; + } + return fixedId; +} +function endTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) { + return id === END_NODE ? END_TYPE : type; +} +function addRelationObjs(item1, item2, relationTitle) { + let id1 = startIdIfNeeded(item1.id.trim()); + let type1 = startTypeIfNeeded(item1.id.trim(), item1.type); + let id2 = startIdIfNeeded(item2.id.trim()); + let type2 = startTypeIfNeeded(item2.id.trim(), item2.type); + addState( + id1, + type1, + item1.doc, + item1.description, + item1.note, + item1.classes, + item1.styles, + item1.textStyles + ); + addState( + id2, + type2, + item2.doc, + item2.description, + item2.note, + item2.classes, + item2.styles, + item2.textStyles + ); + currentDocument.relations.push({ + id1, + id2, + relationTitle: common$1.sanitizeText(relationTitle, getConfig()) + }); +} +const addRelation = function(item1, item2, title) { + if (typeof item1 === "object") { + addRelationObjs(item1, item2, title); + } else { + const id1 = startIdIfNeeded(item1.trim()); + const type1 = startTypeIfNeeded(item1); + const id2 = endIdIfNeeded(item2.trim()); + const type2 = endTypeIfNeeded(item2); + addState(id1, type1); + addState(id2, type2); + currentDocument.relations.push({ + id1, + id2, + title: common$1.sanitizeText(title, getConfig()) + }); + } +}; +const addDescription = function(id, descr) { + const theState = currentDocument.states[id]; + const _descr = descr.startsWith(":") ? descr.replace(":", "").trim() : descr; + theState.descriptions.push(common$1.sanitizeText(_descr, getConfig())); +}; +const cleanupLabel = function(label) { + if (label.substring(0, 1) === ":") { + return label.substr(2).trim(); + } else { + return label.trim(); + } +}; +const getDividerId = () => { + dividerCnt++; + return "divider-id-" + dividerCnt; +}; +const addStyleClass = function(id, styleAttributes = "") { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + const foundClass = classes[id]; + if (styleAttributes !== void 0 && styleAttributes !== null) { + styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { + const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); + if (attrib.match(COLOR_KEYWORD)) { + const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL); + const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD); + foundClass.textStyles.push(newStyle2); + } + foundClass.styles.push(fixedAttrib); + }); + } +}; +const getClasses = function() { + return classes; +}; +const setCssClass = function(itemIds, cssClassName) { + itemIds.split(",").forEach(function(id) { + let foundState = getState(id); + if (foundState === void 0) { + const trimmedId = id.trim(); + addState(trimmedId); + foundState = getState(trimmedId); + } + foundState.classes.push(cssClassName); + }); +}; +const setStyle = function(itemId, styleText) { + const item = getState(itemId); + if (item !== void 0) { + item.textStyles.push(styleText); + } +}; +const setTextStyle = function(itemId, cssClassName) { + const item = getState(itemId); + if (item !== void 0) { + item.textStyles.push(cssClassName); + } +}; +const getDirection = () => direction; +const setDirection = (dir) => { + direction = dir; +}; +const trimColon = (str) => str && str[0] === ":" ? str.substr(1).trim() : str.trim(); +const db = { + getConfig: () => getConfig().state, + addState, + clear, + getState, + getStates, + getRelations, + getClasses, + getDirection, + addRelation, + getDividerId, + setDirection, + cleanupLabel, + lineType, + relationType, + logDocuments, + getRootDoc, + setRootDoc, + getRootDocV2, + extract, + trimColon, + getAccTitle, + setAccTitle, + getAccDescription, + setAccDescription, + addStyleClass, + setCssClass, + addDescription, + setDiagramTitle, + getDiagramTitle +}; +const getStyles = (options) => ` +defs #statediagram-barbEnd { + fill: ${options.transitionColor}; + stroke: ${options.transitionColor}; + } +g.stateGroup text { + fill: ${options.nodeBorder}; + stroke: none; + font-size: 10px; +} +g.stateGroup text { + fill: ${options.textColor}; + stroke: none; + font-size: 10px; + +} +g.stateGroup .state-title { + font-weight: bolder; + fill: ${options.stateLabelColor}; +} + +g.stateGroup rect { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; +} + +g.stateGroup line { + stroke: ${options.lineColor}; + stroke-width: 1; +} + +.transition { + stroke: ${options.transitionColor}; + stroke-width: 1; + fill: none; +} + +.stateGroup .composit { + fill: ${options.background}; + border-bottom: 1px +} + +.stateGroup .alt-composit { + fill: #e0e0e0; + border-bottom: 1px +} + +.state-note { + stroke: ${options.noteBorderColor}; + fill: ${options.noteBkgColor}; + + text { + fill: ${options.noteTextColor}; + stroke: none; + font-size: 10px; + } +} + +.stateLabel .box { + stroke: none; + stroke-width: 0; + fill: ${options.mainBkg}; + opacity: 0.5; +} + +.edgeLabel .label rect { + fill: ${options.labelBackgroundColor}; + opacity: 0.5; +} +.edgeLabel .label text { + fill: ${options.transitionLabelColor || options.tertiaryTextColor}; +} +.label div .edgeLabel { + color: ${options.transitionLabelColor || options.tertiaryTextColor}; +} + +.stateLabel text { + fill: ${options.stateLabelColor}; + font-size: 10px; + font-weight: bold; +} + +.node circle.state-start { + fill: ${options.specialStateColor}; + stroke: ${options.specialStateColor}; +} + +.node .fork-join { + fill: ${options.specialStateColor}; + stroke: ${options.specialStateColor}; +} + +.node circle.state-end { + fill: ${options.innerEndBackground}; + stroke: ${options.background}; + stroke-width: 1.5 +} +.end-state-inner { + fill: ${options.compositeBackground || options.background}; + // stroke: ${options.background}; + stroke-width: 1.5 +} + +.node rect { + fill: ${options.stateBkg || options.mainBkg}; + stroke: ${options.stateBorder || options.nodeBorder}; + stroke-width: 1px; +} +.node polygon { + fill: ${options.mainBkg}; + stroke: ${options.stateBorder || options.nodeBorder};; + stroke-width: 1px; +} +#statediagram-barbEnd { + fill: ${options.lineColor}; +} + +.statediagram-cluster rect { + fill: ${options.compositeTitleBackground}; + stroke: ${options.stateBorder || options.nodeBorder}; + stroke-width: 1px; +} + +.cluster-label, .nodeLabel { + color: ${options.stateLabelColor}; +} + +.statediagram-cluster rect.outer { + rx: 5px; + ry: 5px; +} +.statediagram-state .divider { + stroke: ${options.stateBorder || options.nodeBorder}; +} + +.statediagram-state .title-state { + rx: 5px; + ry: 5px; +} +.statediagram-cluster.statediagram-cluster .inner { + fill: ${options.compositeBackground || options.background}; +} +.statediagram-cluster.statediagram-cluster-alt .inner { + fill: ${options.altBackground ? options.altBackground : "#efefef"}; +} + +.statediagram-cluster .inner { + rx:0; + ry:0; +} + +.statediagram-state rect.basic { + rx: 5px; + ry: 5px; +} +.statediagram-state rect.divider { + stroke-dasharray: 10,10; + fill: ${options.altBackground ? options.altBackground : "#efefef"}; +} + +.note-edge { + stroke-dasharray: 5; +} + +.statediagram-note rect { + fill: ${options.noteBkgColor}; + stroke: ${options.noteBorderColor}; + stroke-width: 1px; + rx: 0; + ry: 0; +} +.statediagram-note rect { + fill: ${options.noteBkgColor}; + stroke: ${options.noteBorderColor}; + stroke-width: 1px; + rx: 0; + ry: 0; +} + +.statediagram-note text { + fill: ${options.noteTextColor}; +} + +.statediagram-note .nodeLabel { + color: ${options.noteTextColor}; +} +.statediagram .edgeLabel { + color: red; // ${options.noteTextColor}; +} + +#dependencyStart, #dependencyEnd { + fill: ${options.lineColor}; + stroke: ${options.lineColor}; + stroke-width: 1; +} + +.statediagramTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; +} +`; +const styles = getStyles; + +export { DEFAULT_STATE_TYPE as D, STMT_RELATION as S, DIVIDER_TYPE as a, STMT_STATE as b, DEFAULT_NESTED_DOC_DIR as c, db as d, parser$1 as p, styles as s }; diff --git a/libs/marked/styles-0784dbeb-C6NnWPLx.js b/libs/marked/styles-0784dbeb-C6NnWPLx.js new file mode 100644 index 0000000..284a891 --- /dev/null +++ b/libs/marked/styles-0784dbeb-C6NnWPLx.js @@ -0,0 +1,1356 @@ +import { c as getConfig, g as getAccTitle, s as setAccTitle, a as getAccDescription, b as setAccDescription, C as setDiagramTitle, D as getDiagramTitle, l as log$1, j as common$1, E as clear$1, a7 as generateId } from './index-Bd_FDXSq.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 15], $V7 = [1, 16], $V8 = [1, 17], $V9 = [1, 18], $Va = [1, 30], $Vb = [1, 19], $Vc = [1, 20], $Vd = [1, 21], $Ve = [1, 22], $Vf = [1, 23], $Vg = [1, 25], $Vh = [1, 26], $Vi = [1, 27], $Vj = [1, 28], $Vk = [1, 29], $Vl = [1, 32], $Vm = [1, 33], $Vn = [1, 34], $Vo = [1, 35], $Vp = [1, 31], $Vq = [1, 4, 5, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $Vr = [1, 4, 5, 13, 14, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $Vs = [4, 5, 15, 16, 18, 20, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "SPACE": 4, "NL": 5, "SD": 6, "document": 7, "line": 8, "statement": 9, "classDefStatement": 10, "cssClassStatement": 11, "idStatement": 12, "DESCR": 13, "-->": 14, "HIDE_EMPTY": 15, "scale": 16, "WIDTH": 17, "COMPOSIT_STATE": 18, "STRUCT_START": 19, "STRUCT_STOP": 20, "STATE_DESCR": 21, "AS": 22, "ID": 23, "FORK": 24, "JOIN": 25, "CHOICE": 26, "CONCURRENT": 27, "note": 28, "notePosition": 29, "NOTE_TEXT": 30, "direction": 31, "acc_title": 32, "acc_title_value": 33, "acc_descr": 34, "acc_descr_value": 35, "acc_descr_multiline_value": 36, "classDef": 37, "CLASSDEF_ID": 38, "CLASSDEF_STYLEOPTS": 39, "DEFAULT": 40, "class": 41, "CLASSENTITY_IDS": 42, "STYLECLASS": 43, "direction_tb": 44, "direction_bt": 45, "direction_rl": 46, "direction_lr": 47, "eol": 48, ";": 49, "EDGE_STATE": 50, "STYLE_SEPARATOR": 51, "left_of": 52, "right_of": 53, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "SPACE", 5: "NL", 6: "SD", 13: "DESCR", 14: "-->", 15: "HIDE_EMPTY", 16: "scale", 17: "WIDTH", 18: "COMPOSIT_STATE", 19: "STRUCT_START", 20: "STRUCT_STOP", 21: "STATE_DESCR", 22: "AS", 23: "ID", 24: "FORK", 25: "JOIN", 26: "CHOICE", 27: "CONCURRENT", 28: "note", 30: "NOTE_TEXT", 32: "acc_title", 33: "acc_title_value", 34: "acc_descr", 35: "acc_descr_value", 36: "acc_descr_multiline_value", 37: "classDef", 38: "CLASSDEF_ID", 39: "CLASSDEF_STYLEOPTS", 40: "DEFAULT", 41: "class", 42: "CLASSENTITY_IDS", 43: "STYLECLASS", 44: "direction_tb", 45: "direction_bt", 46: "direction_rl", 47: "direction_lr", 49: ";", 50: "EDGE_STATE", 51: "STYLE_SEPARATOR", 52: "left_of", 53: "right_of" }, + productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 3], [9, 4], [9, 1], [9, 2], [9, 1], [9, 4], [9, 3], [9, 6], [9, 1], [9, 1], [9, 1], [9, 1], [9, 4], [9, 4], [9, 1], [9, 2], [9, 2], [9, 1], [10, 3], [10, 3], [11, 3], [31, 1], [31, 1], [31, 1], [31, 1], [48, 1], [48, 1], [12, 1], [12, 1], [12, 3], [12, 3], [29, 1], [29, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 3: + yy.setRootDoc($$[$0]); + return $$[$0]; + case 4: + this.$ = []; + break; + case 5: + if ($$[$0] != "nl") { + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + } + break; + case 6: + case 7: + this.$ = $$[$0]; + break; + case 8: + this.$ = "nl"; + break; + case 11: + this.$ = $$[$0]; + break; + case 12: + const stateStmt = $$[$0 - 1]; + stateStmt.description = yy.trimColon($$[$0]); + this.$ = stateStmt; + break; + case 13: + this.$ = { stmt: "relation", state1: $$[$0 - 2], state2: $$[$0] }; + break; + case 14: + const relDescription = yy.trimColon($$[$0]); + this.$ = { stmt: "relation", state1: $$[$0 - 3], state2: $$[$0 - 1], description: relDescription }; + break; + case 18: + this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: "", doc: $$[$0 - 1] }; + break; + case 19: + var id = $$[$0]; + var description = $$[$0 - 2].trim(); + if ($$[$0].match(":")) { + var parts = $$[$0].split(":"); + id = parts[0]; + description = [description, parts[1]]; + } + this.$ = { stmt: "state", id, type: "default", description }; + break; + case 20: + this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: $$[$0 - 5], doc: $$[$0 - 1] }; + break; + case 21: + this.$ = { stmt: "state", id: $$[$0], type: "fork" }; + break; + case 22: + this.$ = { stmt: "state", id: $$[$0], type: "join" }; + break; + case 23: + this.$ = { stmt: "state", id: $$[$0], type: "choice" }; + break; + case 24: + this.$ = { stmt: "state", id: yy.getDividerId(), type: "divider" }; + break; + case 25: + this.$ = { stmt: "state", id: $$[$0 - 1].trim(), note: { position: $$[$0 - 2].trim(), text: $$[$0].trim() } }; + break; + case 28: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 29: + case 30: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 31: + case 32: + this.$ = { stmt: "classDef", id: $$[$0 - 1].trim(), classes: $$[$0].trim() }; + break; + case 33: + this.$ = { stmt: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() }; + break; + case 34: + yy.setDirection("TB"); + this.$ = { stmt: "dir", value: "TB" }; + break; + case 35: + yy.setDirection("BT"); + this.$ = { stmt: "dir", value: "BT" }; + break; + case 36: + yy.setDirection("RL"); + this.$ = { stmt: "dir", value: "RL" }; + break; + case 37: + yy.setDirection("LR"); + this.$ = { stmt: "dir", value: "LR" }; + break; + case 40: + case 41: + this.$ = { stmt: "state", id: $$[$0].trim(), type: "default", description: "" }; + break; + case 42: + this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" }; + break; + case 43: + this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" }; + break; + } + }, + table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 15, 16, 18, 21, 23, 24, 25, 26, 27, 28, 32, 34, 36, 37, 41, 44, 45, 46, 47, 50], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 5]), { 9: 36, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 7]), o($Vq, [2, 8]), o($Vq, [2, 9]), o($Vq, [2, 10]), o($Vq, [2, 11], { 13: [1, 37], 14: [1, 38] }), o($Vq, [2, 15]), { 17: [1, 39] }, o($Vq, [2, 17], { 19: [1, 40] }), { 22: [1, 41] }, o($Vq, [2, 21]), o($Vq, [2, 22]), o($Vq, [2, 23]), o($Vq, [2, 24]), { 29: 42, 30: [1, 43], 52: [1, 44], 53: [1, 45] }, o($Vq, [2, 27]), { 33: [1, 46] }, { 35: [1, 47] }, o($Vq, [2, 30]), { 38: [1, 48], 40: [1, 49] }, { 42: [1, 50] }, o($Vr, [2, 40], { 51: [1, 51] }), o($Vr, [2, 41], { 51: [1, 52] }), o($Vq, [2, 34]), o($Vq, [2, 35]), o($Vq, [2, 36]), o($Vq, [2, 37]), o($Vq, [2, 6]), o($Vq, [2, 12]), { 12: 53, 23: $Va, 50: $Vp }, o($Vq, [2, 16]), o($Vs, $V3, { 7: 54 }), { 23: [1, 55] }, { 23: [1, 56] }, { 22: [1, 57] }, { 23: [2, 44] }, { 23: [2, 45] }, o($Vq, [2, 28]), o($Vq, [2, 29]), { 39: [1, 58] }, { 39: [1, 59] }, { 43: [1, 60] }, { 23: [1, 61] }, { 23: [1, 62] }, o($Vq, [2, 13], { 13: [1, 63] }), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 20: [1, 64], 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 19], { 19: [1, 65] }), { 30: [1, 66] }, { 23: [1, 67] }, o($Vq, [2, 31]), o($Vq, [2, 32]), o($Vq, [2, 33]), o($Vr, [2, 42]), o($Vr, [2, 43]), o($Vq, [2, 14]), o($Vq, [2, 18]), o($Vs, $V3, { 7: 68 }), o($Vq, [2, 25]), o($Vq, [2, 26]), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 15: $V6, 16: $V7, 18: $V8, 20: [1, 69], 21: $V9, 23: $Va, 24: $Vb, 25: $Vc, 26: $Vd, 27: $Ve, 28: $Vf, 31: 24, 32: $Vg, 34: $Vh, 36: $Vi, 37: $Vj, 41: $Vk, 44: $Vl, 45: $Vm, 46: $Vn, 47: $Vo, 50: $Vp }, o($Vq, [2, 20])], + defaultActions: { 5: [2, 1], 6: [2, 2], 44: [2, 44], 45: [2, 45] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 40; + case 1: + return 44; + case 2: + return 45; + case 3: + return 46; + case 4: + return 47; + case 5: + break; + case 6: + break; + case 7: + return 5; + case 8: + break; + case 9: + break; + case 10: + break; + case 11: + break; + case 12: + this.pushState("SCALE"); + return 16; + case 13: + return 17; + case 14: + this.popState(); + break; + case 15: + this.begin("acc_title"); + return 32; + case 16: + this.popState(); + return "acc_title_value"; + case 17: + this.begin("acc_descr"); + return 34; + case 18: + this.popState(); + return "acc_descr_value"; + case 19: + this.begin("acc_descr_multiline"); + break; + case 20: + this.popState(); + break; + case 21: + return "acc_descr_multiline_value"; + case 22: + this.pushState("CLASSDEF"); + return 37; + case 23: + this.popState(); + this.pushState("CLASSDEFID"); + return "DEFAULT_CLASSDEF_ID"; + case 24: + this.popState(); + this.pushState("CLASSDEFID"); + return 38; + case 25: + this.popState(); + return 39; + case 26: + this.pushState("CLASS"); + return 41; + case 27: + this.popState(); + this.pushState("CLASS_STYLE"); + return 42; + case 28: + this.popState(); + return 43; + case 29: + this.pushState("SCALE"); + return 16; + case 30: + return 17; + case 31: + this.popState(); + break; + case 32: + this.pushState("STATE"); + break; + case 33: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 24; + case 34: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 25; + case 35: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -10).trim(); + return 26; + case 36: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 24; + case 37: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 25; + case 38: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -10).trim(); + return 26; + case 39: + return 44; + case 40: + return 45; + case 41: + return 46; + case 42: + return 47; + case 43: + this.pushState("STATE_STRING"); + break; + case 44: + this.pushState("STATE_ID"); + return "AS"; + case 45: + this.popState(); + return "ID"; + case 46: + this.popState(); + break; + case 47: + return "STATE_DESCR"; + case 48: + return 18; + case 49: + this.popState(); + break; + case 50: + this.popState(); + this.pushState("struct"); + return 19; + case 51: + break; + case 52: + this.popState(); + return 20; + case 53: + break; + case 54: + this.begin("NOTE"); + return 28; + case 55: + this.popState(); + this.pushState("NOTE_ID"); + return 52; + case 56: + this.popState(); + this.pushState("NOTE_ID"); + return 53; + case 57: + this.popState(); + this.pushState("FLOATING_NOTE"); + break; + case 58: + this.popState(); + this.pushState("FLOATING_NOTE_ID"); + return "AS"; + case 59: + break; + case 60: + return "NOTE_TEXT"; + case 61: + this.popState(); + return "ID"; + case 62: + this.popState(); + this.pushState("NOTE_TEXT"); + return 23; + case 63: + this.popState(); + yy_.yytext = yy_.yytext.substr(2).trim(); + return 30; + case 64: + this.popState(); + yy_.yytext = yy_.yytext.slice(0, -8).trim(); + return 30; + case 65: + return 6; + case 66: + return 6; + case 67: + return 15; + case 68: + return 50; + case 69: + return 23; + case 70: + yy_.yytext = yy_.yytext.trim(); + return 13; + case 71: + return 14; + case 72: + return 27; + case 73: + return 51; + case 74: + return 5; + case 75: + return "INVALID"; + } + }, + rules: [/^(?:default\b)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:classDef\s+)/i, /^(?:DEFAULT\s+)/i, /^(?:\w+\s+)/i, /^(?:[^\n]*)/i, /^(?:class\s+)/i, /^(?:(\w+)+((,\s*\w+)*))/i, /^(?:[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:state\s+)/i, /^(?:.*<>)/i, /^(?:.*<>)/i, /^(?:.*<>)/i, /^(?:.*\[\[fork\]\])/i, /^(?:.*\[\[join\]\])/i, /^(?:.*\[\[choice\]\])/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:["])/i, /^(?:\s*as\s+)/i, /^(?:[^\n\{]*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n\s\{]+)/i, /^(?:\n)/i, /^(?:\{)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:\})/i, /^(?:[\n])/i, /^(?:note\s+)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:")/i, /^(?:\s*as\s*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n]*)/i, /^(?:\s*[^:\n\s\-]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:[\s\S]*?end note\b)/i, /^(?:stateDiagram\s+)/i, /^(?:stateDiagram-v2\s+)/i, /^(?:hide empty description\b)/i, /^(?:\[\*\])/i, /^(?:[^:\n\s\-\{]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:-->)/i, /^(?:--)/i, /^(?::::)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "LINE": { "rules": [9, 10], "inclusive": false }, "struct": { "rules": [9, 10, 22, 26, 32, 39, 40, 41, 42, 51, 52, 53, 54, 68, 69, 70, 71, 72], "inclusive": false }, "FLOATING_NOTE_ID": { "rules": [61], "inclusive": false }, "FLOATING_NOTE": { "rules": [58, 59, 60], "inclusive": false }, "NOTE_TEXT": { "rules": [63, 64], "inclusive": false }, "NOTE_ID": { "rules": [62], "inclusive": false }, "NOTE": { "rules": [55, 56, 57], "inclusive": false }, "CLASS_STYLE": { "rules": [28], "inclusive": false }, "CLASS": { "rules": [27], "inclusive": false }, "CLASSDEFID": { "rules": [25], "inclusive": false }, "CLASSDEF": { "rules": [23, 24], "inclusive": false }, "acc_descr_multiline": { "rules": [20, 21], "inclusive": false }, "acc_descr": { "rules": [18], "inclusive": false }, "acc_title": { "rules": [16], "inclusive": false }, "SCALE": { "rules": [13, 14, 30, 31], "inclusive": false }, "ALIAS": { "rules": [], "inclusive": false }, "STATE_ID": { "rules": [45], "inclusive": false }, "STATE_STRING": { "rules": [46, 47], "inclusive": false }, "FORK_STATE": { "rules": [], "inclusive": false }, "STATE": { "rules": [9, 10, 33, 34, 35, 36, 37, 38, 43, 44, 48, 49, 50], "inclusive": false }, "ID": { "rules": [9, 10], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 15, 17, 19, 22, 26, 29, 32, 50, 54, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const DEFAULT_DIAGRAM_DIRECTION = "LR"; +const DEFAULT_NESTED_DOC_DIR = "TB"; +const STMT_STATE = "state"; +const STMT_RELATION = "relation"; +const STMT_CLASSDEF = "classDef"; +const STMT_APPLYCLASS = "applyClass"; +const DEFAULT_STATE_TYPE = "default"; +const DIVIDER_TYPE = "divider"; +const START_NODE = "[*]"; +const START_TYPE = "start"; +const END_NODE = START_NODE; +const END_TYPE = "end"; +const COLOR_KEYWORD = "color"; +const FILL_KEYWORD = "fill"; +const BG_FILL = "bgFill"; +const STYLECLASS_SEP = ","; +function newClassesList() { + return {}; +} +let direction = DEFAULT_DIAGRAM_DIRECTION; +let rootDoc = []; +let classes = newClassesList(); +const newDoc = () => { + return { + relations: [], + states: {}, + documents: {} + }; +}; +let documents = { + root: newDoc() +}; +let currentDocument = documents.root; +let startEndCount = 0; +let dividerCnt = 0; +const lineType = { + LINE: 0, + DOTTED_LINE: 1 +}; +const relationType = { + AGGREGATION: 0, + EXTENSION: 1, + COMPOSITION: 2, + DEPENDENCY: 3 +}; +const clone = (o) => JSON.parse(JSON.stringify(o)); +const setRootDoc = (o) => { + log$1.info("Setting root doc", o); + rootDoc = o; +}; +const getRootDoc = () => rootDoc; +const docTranslator = (parent, node, first) => { + if (node.stmt === STMT_RELATION) { + docTranslator(parent, node.state1, true); + docTranslator(parent, node.state2, false); + } else { + if (node.stmt === STMT_STATE) { + if (node.id === "[*]") { + node.id = first ? parent.id + "_start" : parent.id + "_end"; + node.start = first; + } else { + node.id = node.id.trim(); + } + } + if (node.doc) { + const doc = []; + let currentDoc = []; + let i; + for (i = 0; i < node.doc.length; i++) { + if (node.doc[i].type === DIVIDER_TYPE) { + const newNode = clone(node.doc[i]); + newNode.doc = clone(currentDoc); + doc.push(newNode); + currentDoc = []; + } else { + currentDoc.push(node.doc[i]); + } + } + if (doc.length > 0 && currentDoc.length > 0) { + const newNode = { + stmt: STMT_STATE, + id: generateId(), + type: "divider", + doc: clone(currentDoc) + }; + doc.push(clone(newNode)); + node.doc = doc; + } + node.doc.forEach((docNode) => docTranslator(node, docNode, true)); + } + } +}; +const getRootDocV2 = () => { + docTranslator({ id: "root" }, { id: "root", doc: rootDoc }, true); + return { id: "root", doc: rootDoc }; +}; +const extract = (_doc) => { + let doc; + if (_doc.doc) { + doc = _doc.doc; + } else { + doc = _doc; + } + log$1.info(doc); + clear(true); + log$1.info("Extract", doc); + doc.forEach((item) => { + switch (item.stmt) { + case STMT_STATE: + addState( + item.id.trim(), + item.type, + item.doc, + item.description, + item.note, + item.classes, + item.styles, + item.textStyles + ); + break; + case STMT_RELATION: + addRelation(item.state1, item.state2, item.description); + break; + case STMT_CLASSDEF: + addStyleClass(item.id.trim(), item.classes); + break; + case STMT_APPLYCLASS: + setCssClass(item.id.trim(), item.styleClass); + break; + } + }); +}; +const addState = function(id, type = DEFAULT_STATE_TYPE, doc = null, descr = null, note = null, classes2 = null, styles2 = null, textStyles = null) { + const trimmedId = id == null ? void 0 : id.trim(); + if (currentDocument.states[trimmedId] === void 0) { + log$1.info("Adding state ", trimmedId, descr); + currentDocument.states[trimmedId] = { + id: trimmedId, + descriptions: [], + type, + doc, + note, + classes: [], + styles: [], + textStyles: [] + }; + } else { + if (!currentDocument.states[trimmedId].doc) { + currentDocument.states[trimmedId].doc = doc; + } + if (!currentDocument.states[trimmedId].type) { + currentDocument.states[trimmedId].type = type; + } + } + if (descr) { + log$1.info("Setting state description", trimmedId, descr); + if (typeof descr === "string") { + addDescription(trimmedId, descr.trim()); + } + if (typeof descr === "object") { + descr.forEach((des) => addDescription(trimmedId, des.trim())); + } + } + if (note) { + currentDocument.states[trimmedId].note = note; + currentDocument.states[trimmedId].note.text = common$1.sanitizeText( + currentDocument.states[trimmedId].note.text, + getConfig() + ); + } + if (classes2) { + log$1.info("Setting state classes", trimmedId, classes2); + const classesList = typeof classes2 === "string" ? [classes2] : classes2; + classesList.forEach((cssClass) => setCssClass(trimmedId, cssClass.trim())); + } + if (styles2) { + log$1.info("Setting state styles", trimmedId, styles2); + const stylesList = typeof styles2 === "string" ? [styles2] : styles2; + stylesList.forEach((style) => setStyle(trimmedId, style.trim())); + } + if (textStyles) { + log$1.info("Setting state styles", trimmedId, styles2); + const textStylesList = typeof textStyles === "string" ? [textStyles] : textStyles; + textStylesList.forEach((textStyle) => setTextStyle(trimmedId, textStyle.trim())); + } +}; +const clear = function(saveCommon) { + documents = { + root: newDoc() + }; + currentDocument = documents.root; + startEndCount = 0; + classes = newClassesList(); + if (!saveCommon) { + clear$1(); + } +}; +const getState = function(id) { + return currentDocument.states[id]; +}; +const getStates = function() { + return currentDocument.states; +}; +const logDocuments = function() { + log$1.info("Documents = ", documents); +}; +const getRelations = function() { + return currentDocument.relations; +}; +function startIdIfNeeded(id = "") { + let fixedId = id; + if (id === START_NODE) { + startEndCount++; + fixedId = `${START_TYPE}${startEndCount}`; + } + return fixedId; +} +function startTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) { + return id === START_NODE ? START_TYPE : type; +} +function endIdIfNeeded(id = "") { + let fixedId = id; + if (id === END_NODE) { + startEndCount++; + fixedId = `${END_TYPE}${startEndCount}`; + } + return fixedId; +} +function endTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) { + return id === END_NODE ? END_TYPE : type; +} +function addRelationObjs(item1, item2, relationTitle) { + let id1 = startIdIfNeeded(item1.id.trim()); + let type1 = startTypeIfNeeded(item1.id.trim(), item1.type); + let id2 = startIdIfNeeded(item2.id.trim()); + let type2 = startTypeIfNeeded(item2.id.trim(), item2.type); + addState( + id1, + type1, + item1.doc, + item1.description, + item1.note, + item1.classes, + item1.styles, + item1.textStyles + ); + addState( + id2, + type2, + item2.doc, + item2.description, + item2.note, + item2.classes, + item2.styles, + item2.textStyles + ); + currentDocument.relations.push({ + id1, + id2, + relationTitle: common$1.sanitizeText(relationTitle, getConfig()) + }); +} +const addRelation = function(item1, item2, title) { + if (typeof item1 === "object") { + addRelationObjs(item1, item2, title); + } else { + const id1 = startIdIfNeeded(item1.trim()); + const type1 = startTypeIfNeeded(item1); + const id2 = endIdIfNeeded(item2.trim()); + const type2 = endTypeIfNeeded(item2); + addState(id1, type1); + addState(id2, type2); + currentDocument.relations.push({ + id1, + id2, + title: common$1.sanitizeText(title, getConfig()) + }); + } +}; +const addDescription = function(id, descr) { + const theState = currentDocument.states[id]; + const _descr = descr.startsWith(":") ? descr.replace(":", "").trim() : descr; + theState.descriptions.push(common$1.sanitizeText(_descr, getConfig())); +}; +const cleanupLabel = function(label) { + if (label.substring(0, 1) === ":") { + return label.substr(2).trim(); + } else { + return label.trim(); + } +}; +const getDividerId = () => { + dividerCnt++; + return "divider-id-" + dividerCnt; +}; +const addStyleClass = function(id, styleAttributes = "") { + if (classes[id] === void 0) { + classes[id] = { id, styles: [], textStyles: [] }; + } + const foundClass = classes[id]; + if (styleAttributes !== void 0 && styleAttributes !== null) { + styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { + const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim(); + if (attrib.match(COLOR_KEYWORD)) { + const newStyle1 = fixedAttrib.replace(FILL_KEYWORD, BG_FILL); + const newStyle2 = newStyle1.replace(COLOR_KEYWORD, FILL_KEYWORD); + foundClass.textStyles.push(newStyle2); + } + foundClass.styles.push(fixedAttrib); + }); + } +}; +const getClasses = function() { + return classes; +}; +const setCssClass = function(itemIds, cssClassName) { + itemIds.split(",").forEach(function(id) { + let foundState = getState(id); + if (foundState === void 0) { + const trimmedId = id.trim(); + addState(trimmedId); + foundState = getState(trimmedId); + } + foundState.classes.push(cssClassName); + }); +}; +const setStyle = function(itemId, styleText) { + const item = getState(itemId); + if (item !== void 0) { + item.textStyles.push(styleText); + } +}; +const setTextStyle = function(itemId, cssClassName) { + const item = getState(itemId); + if (item !== void 0) { + item.textStyles.push(cssClassName); + } +}; +const getDirection = () => direction; +const setDirection = (dir) => { + direction = dir; +}; +const trimColon = (str) => str && str[0] === ":" ? str.substr(1).trim() : str.trim(); +const db = { + getConfig: () => getConfig().state, + addState, + clear, + getState, + getStates, + getRelations, + getClasses, + getDirection, + addRelation, + getDividerId, + setDirection, + cleanupLabel, + lineType, + relationType, + logDocuments, + getRootDoc, + setRootDoc, + getRootDocV2, + extract, + trimColon, + getAccTitle, + setAccTitle, + getAccDescription, + setAccDescription, + addStyleClass, + setCssClass, + addDescription, + setDiagramTitle, + getDiagramTitle +}; +const getStyles = (options) => ` +defs #statediagram-barbEnd { + fill: ${options.transitionColor}; + stroke: ${options.transitionColor}; + } +g.stateGroup text { + fill: ${options.nodeBorder}; + stroke: none; + font-size: 10px; +} +g.stateGroup text { + fill: ${options.textColor}; + stroke: none; + font-size: 10px; + +} +g.stateGroup .state-title { + font-weight: bolder; + fill: ${options.stateLabelColor}; +} + +g.stateGroup rect { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; +} + +g.stateGroup line { + stroke: ${options.lineColor}; + stroke-width: 1; +} + +.transition { + stroke: ${options.transitionColor}; + stroke-width: 1; + fill: none; +} + +.stateGroup .composit { + fill: ${options.background}; + border-bottom: 1px +} + +.stateGroup .alt-composit { + fill: #e0e0e0; + border-bottom: 1px +} + +.state-note { + stroke: ${options.noteBorderColor}; + fill: ${options.noteBkgColor}; + + text { + fill: ${options.noteTextColor}; + stroke: none; + font-size: 10px; + } +} + +.stateLabel .box { + stroke: none; + stroke-width: 0; + fill: ${options.mainBkg}; + opacity: 0.5; +} + +.edgeLabel .label rect { + fill: ${options.labelBackgroundColor}; + opacity: 0.5; +} +.edgeLabel .label text { + fill: ${options.transitionLabelColor || options.tertiaryTextColor}; +} +.label div .edgeLabel { + color: ${options.transitionLabelColor || options.tertiaryTextColor}; +} + +.stateLabel text { + fill: ${options.stateLabelColor}; + font-size: 10px; + font-weight: bold; +} + +.node circle.state-start { + fill: ${options.specialStateColor}; + stroke: ${options.specialStateColor}; +} + +.node .fork-join { + fill: ${options.specialStateColor}; + stroke: ${options.specialStateColor}; +} + +.node circle.state-end { + fill: ${options.innerEndBackground}; + stroke: ${options.background}; + stroke-width: 1.5 +} +.end-state-inner { + fill: ${options.compositeBackground || options.background}; + // stroke: ${options.background}; + stroke-width: 1.5 +} + +.node rect { + fill: ${options.stateBkg || options.mainBkg}; + stroke: ${options.stateBorder || options.nodeBorder}; + stroke-width: 1px; +} +.node polygon { + fill: ${options.mainBkg}; + stroke: ${options.stateBorder || options.nodeBorder};; + stroke-width: 1px; +} +#statediagram-barbEnd { + fill: ${options.lineColor}; +} + +.statediagram-cluster rect { + fill: ${options.compositeTitleBackground}; + stroke: ${options.stateBorder || options.nodeBorder}; + stroke-width: 1px; +} + +.cluster-label, .nodeLabel { + color: ${options.stateLabelColor}; +} + +.statediagram-cluster rect.outer { + rx: 5px; + ry: 5px; +} +.statediagram-state .divider { + stroke: ${options.stateBorder || options.nodeBorder}; +} + +.statediagram-state .title-state { + rx: 5px; + ry: 5px; +} +.statediagram-cluster.statediagram-cluster .inner { + fill: ${options.compositeBackground || options.background}; +} +.statediagram-cluster.statediagram-cluster-alt .inner { + fill: ${options.altBackground ? options.altBackground : "#efefef"}; +} + +.statediagram-cluster .inner { + rx:0; + ry:0; +} + +.statediagram-state rect.basic { + rx: 5px; + ry: 5px; +} +.statediagram-state rect.divider { + stroke-dasharray: 10,10; + fill: ${options.altBackground ? options.altBackground : "#efefef"}; +} + +.note-edge { + stroke-dasharray: 5; +} + +.statediagram-note rect { + fill: ${options.noteBkgColor}; + stroke: ${options.noteBorderColor}; + stroke-width: 1px; + rx: 0; + ry: 0; +} +.statediagram-note rect { + fill: ${options.noteBkgColor}; + stroke: ${options.noteBorderColor}; + stroke-width: 1px; + rx: 0; + ry: 0; +} + +.statediagram-note text { + fill: ${options.noteTextColor}; +} + +.statediagram-note .nodeLabel { + color: ${options.noteTextColor}; +} +.statediagram .edgeLabel { + color: red; // ${options.noteTextColor}; +} + +#dependencyStart, #dependencyEnd { + fill: ${options.lineColor}; + stroke: ${options.lineColor}; + stroke-width: 1; +} + +.statediagramTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; +} +`; +const styles = getStyles; + +export { DEFAULT_STATE_TYPE as D, STMT_RELATION as S, DIVIDER_TYPE as a, STMT_STATE as b, DEFAULT_NESTED_DOC_DIR as c, db as d, parser$1 as p, styles as s }; diff --git a/libs/marked/styles-483fbfea-Bj8pmBPH.js b/libs/marked/styles-483fbfea-Bj8pmBPH.js new file mode 100644 index 0000000..4d37f89 --- /dev/null +++ b/libs/marked/styles-483fbfea-Bj8pmBPH.js @@ -0,0 +1,586 @@ +import { G as Graph } from './graph-DadsyNmk.js'; +import { S as Selection, v as root, x as array, y as isPlainObject, z as isFunction, o as getStylesFromArray, l as log$1, p as evaluate, c as getConfig, j as common$1, r as renderKatex, q as interpolateToCurve, n as curveLinear, h as select, A as utils, t as setupGraphViewbox$1, B as rgba } from './index-CN3YjQ0n.js'; +import { r as render } from './index-01f381cb-CDFlKdjO.js'; +import { c as channel } from './channel-DcrZctv4.js'; + +function selectAll(selector) { + return typeof selector === "string" + ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) + : new Selection([array(selector)], root); +} + +/* + * Returns true if the specified node in the graph is a subgraph node. A + * subgraph node is one that contains other nodes. + */ +function isSubgraph(g, v) { + return !!g.children(v).length; +} + +function edgeToId(e) { + return escapeId(e.v) + ':' + escapeId(e.w) + ':' + escapeId(e.name); +} + +var ID_DELIM = /:/g; +function escapeId(str) { + return str ? String(str).replace(ID_DELIM, '\\:') : ''; +} + +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr('style', styleFn); + } +} + +function applyClass(dom, classFn, otherClasses) { + if (classFn) { + dom.attr('class', classFn).attr('class', otherClasses + ' ' + dom.attr('class')); + } +} + +function applyTransition(selection, g) { + var graph = g.graph(); + + if (isPlainObject(graph)) { + var transition = graph.transition; + if (isFunction(transition)) { + return transition(selection); + } + } + + return selection; +} + +function addHtmlLabel(root, node) { + var fo = root.append('foreignObject').attr('width', '100000'); + + var div = fo.append('xhtml:div'); + div.attr('xmlns', 'http://www.w3.org/1999/xhtml'); + + var label = node.label; + switch (typeof label) { + case 'function': + div.insert(label); + break; + case 'object': + // Currently we assume this is a DOM object. + div.insert(function () { + return label; + }); + break; + default: + div.html(label); + } + + applyStyle(div, node.labelStyle); + div.style('display', 'inline-block'); + // Fix for firefox + div.style('white-space', 'nowrap'); + + var client = div.node().getBoundingClientRect(); + fo.attr('width', client.width).attr('height', client.height); + + return fo; +} + +const conf = {}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf[key] = cnf[key]; + } +}; +const addVertices = async function(vert, g, svgId, root, doc, diagObj) { + const svg = root.select(`[id="${svgId}"]`); + const keys = Object.keys(vert); + for (const id of keys) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + classStr = classStr + " flowchart-label"; + const styles = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + let vertexNode; + log$1.info("vertex", vertex, vertex.labelType); + if (vertex.labelType === "markdown") { + log$1.info("vertex", vertex, vertex.labelType); + } else { + if (evaluate(getConfig().flowchart.htmlLabels)) { + const node = { + label: vertexText + }; + vertexNode = addHtmlLabel(svg, node).node(); + vertexNode.parentNode.removeChild(vertexNode); + } else { + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", styles.labelStyle.replace("color:", "fill:")); + const rows = vertexText.split(common$1.lineBreakRegex); + for (const row of rows) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "1"); + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + vertexNode = svgLabel; + } + } + let radius = 0; + let _shape = ""; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + case "doublecircle": + _shape = "doublecircle"; + break; + default: + _shape = "rect"; + } + const labelText = await renderKatex(vertexText, getConfig()); + g.setNode(vertex.id, { + labelStyle: styles.labelStyle, + shape: _shape, + labelText, + labelType: vertex.labelType, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + link: vertex.link, + linkTarget: vertex.linkTarget, + tooltip: diagObj.db.getTooltip(vertex.id) || "", + domId: diagObj.db.lookUpDomId(vertex.id), + haveCallback: vertex.haveCallback, + width: vertex.type === "group" ? 500 : void 0, + dir: vertex.dir, + type: vertex.type, + props: vertex.props, + padding: getConfig().flowchart.padding + }); + log$1.info("setNode", { + labelStyle: styles.labelStyle, + labelType: vertex.labelType, + shape: _shape, + labelText, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + domId: diagObj.db.lookUpDomId(vertex.id), + width: vertex.type === "group" ? 500 : void 0, + type: vertex.type, + dir: vertex.dir, + props: vertex.props, + padding: getConfig().flowchart.padding + }); + } +}; +const addEdges = async function(edges, g, diagObj) { + log$1.info("abc78 edges = ", edges); + let cnt = 0; + let linkIdCnt = {}; + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + for (const edge of edges) { + cnt++; + const linkIdBase = "L-" + edge.start + "-" + edge.end; + if (linkIdCnt[linkIdBase] === void 0) { + linkIdCnt[linkIdBase] = 0; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } else { + linkIdCnt[linkIdBase]++; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } + let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase]; + log$1.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]); + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = { style: "", labelStyle: "" }; + edgeData.minlen = edge.length || 1; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + edgeData.arrowTypeStart = "arrow_open"; + edgeData.arrowTypeEnd = "arrow_open"; + switch (edge.type) { + case "double_arrow_cross": + edgeData.arrowTypeStart = "arrow_cross"; + case "arrow_cross": + edgeData.arrowTypeEnd = "arrow_cross"; + break; + case "double_arrow_point": + edgeData.arrowTypeStart = "arrow_point"; + case "arrow_point": + edgeData.arrowTypeEnd = "arrow_point"; + break; + case "double_arrow_circle": + edgeData.arrowTypeStart = "arrow_circle"; + case "arrow_circle": + edgeData.arrowTypeEnd = "arrow_circle"; + break; + } + let style = ""; + let labelStyle = ""; + switch (edge.stroke) { + case "normal": + style = "fill:none;"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + edgeData.thickness = "normal"; + edgeData.pattern = "solid"; + break; + case "dotted": + edgeData.thickness = "normal"; + edgeData.pattern = "dotted"; + edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + edgeData.thickness = "thick"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 3.5px;fill:none;"; + break; + case "invisible": + edgeData.thickness = "invisible"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 0;fill:none;"; + break; + } + if (edge.style !== void 0) { + const styles = getStylesFromArray(edge.style); + style = styles.style; + labelStyle = styles.labelStyle; + } + edgeData.style = edgeData.style += style; + edgeData.labelStyle = edgeData.labelStyle += labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + } + edgeData.labelType = edge.labelType; + edgeData.label = await renderKatex(edge.text.replace(common$1.lineBreakRegex, "\n"), getConfig()); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + edgeData.id = linkId; + edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd; + g.setEdge(edge.start, edge.end, edgeData, cnt); + } +}; +const getClasses = function(text, diagObj) { + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + log$1.info("Drawing flowchart"); + let dir = diagObj.db.getDirection(); + if (dir === void 0) { + dir = "TD"; + } + const { securityLevel, flowchart: conf2 } = getConfig(); + const nodeSpacing = conf2.nodeSpacing || 50; + const rankSpacing = conf2.rankSpacing || 50; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 0, + marginy: 0 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + log$1.info("Subgraphs - ", subGraphs); + for (let i2 = subGraphs.length - 1; i2 >= 0; i2--) { + subG = subGraphs[i2]; + log$1.info("Subgraph - ", subG); + diagObj.db.addVertex( + subG.id, + { text: subG.title, type: subG.labelType }, + "group", + void 0, + subG.classes, + subG.dir + ); + } + const vert = diagObj.db.getVertices(); + const edges = diagObj.db.getEdges(); + log$1.info("Edges", edges); + let i = 0; + for (i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + selectAll("cluster").append("text"); + for (let j = 0; j < subG.nodes.length; j++) { + log$1.info("Setting up subgraphs", subG.nodes[j], subG.id); + g.setParent(subG.nodes[j], subG.id); + } + } + await addVertices(vert, g, id, root, doc, diagObj); + await addEdges(edges, g); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render(element, g, ["point", "circle", "cross"], "flowchart", id); + utils.insertTitle(svg, "flowchartTitleText", conf2.titleTopMargin, diagObj.db.getDiagramTitle()); + setupGraphViewbox$1(g, svg, conf2.diagramPadding, conf2.useMaxWidth); + diagObj.db.indexNodes("subGraph" + i); + if (!conf2.htmlLabels) { + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } + const keys = Object.keys(vert); + keys.forEach(function(key) { + const vertex = vert[key]; + if (vertex.link) { + const node = select("#" + id + ' [id="' + key + '"]'); + if (node) { + const link = doc.createElementNS("http://www.w3.org/2000/svg", "a"); + link.setAttributeNS("http://www.w3.org/2000/svg", "class", vertex.classes.join(" ")); + link.setAttributeNS("http://www.w3.org/2000/svg", "href", vertex.link); + link.setAttributeNS("http://www.w3.org/2000/svg", "rel", "noopener"); + if (securityLevel === "sandbox") { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", "_top"); + } else if (vertex.linkTarget) { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", vertex.linkTarget); + } + const linkNode = node.insert(function() { + return link; + }, ":first-child"); + const shape = node.select(".label-container"); + if (shape) { + linkNode.append(function() { + return shape.node(); + }); + } + const label = node.select(".label"); + if (label) { + linkNode.append(function() { + return label.node(); + }); + } + } + } + }); +}; +const flowRendererV2 = { + setConf, + addVertices, + addEdges, + getClasses, + draw +}; +const fade = (color, opacity) => { + const channel$1 = channel; + const r = channel$1(color, "r"); + const g = channel$1(color, "g"); + const b = channel$1(color, "b"); + return rgba(r, g, b, opacity); +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span,p { + color: ${options.titleColor}; + } + + .label text,span,p { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + .flowchart-label text { + text-anchor: middle; + } + // .flowchart-label .text-outer-tspan { + // text-anchor: middle; + // } + // .flowchart-label .text-inner-tspan { + // text-anchor: start; + // } + + .node .katex path { + fill: #000; + stroke: #000; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + /* For html labels only */ + .labelBkg { + background-color: ${fade(options.edgeLabelBackground, 0.5)}; + // background-color: + } + + .cluster rect { + fill: ${options.clusterBkg}; + stroke: ${options.clusterBorder}; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span,p { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } +`; +const flowStyles = getStyles; + +export { applyStyle as a, addHtmlLabel as b, applyTransition as c, applyClass as d, edgeToId as e, flowRendererV2 as f, flowStyles as g, isSubgraph as i, selectAll as s }; diff --git a/libs/marked/styles-483fbfea-DDPjh658.js b/libs/marked/styles-483fbfea-DDPjh658.js new file mode 100644 index 0000000..b859d32 --- /dev/null +++ b/libs/marked/styles-483fbfea-DDPjh658.js @@ -0,0 +1,586 @@ +import { G as Graph } from './graph-KZW2Npeo.js'; +import { S as Selection, v as root, x as array, y as isPlainObject, z as isFunction, o as getStylesFromArray, l as log$1, p as evaluate, c as getConfig, j as common$1, r as renderKatex, q as interpolateToCurve, n as curveLinear, h as select, A as utils, t as setupGraphViewbox$1, B as rgba } from './index-Bd_FDXSq.js'; +import { r as render } from './index-01f381cb-BCBEZMaa.js'; +import { c as channel } from './channel-BxFDB0yY.js'; + +function selectAll(selector) { + return typeof selector === "string" + ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) + : new Selection([array(selector)], root); +} + +/* + * Returns true if the specified node in the graph is a subgraph node. A + * subgraph node is one that contains other nodes. + */ +function isSubgraph(g, v) { + return !!g.children(v).length; +} + +function edgeToId(e) { + return escapeId(e.v) + ':' + escapeId(e.w) + ':' + escapeId(e.name); +} + +var ID_DELIM = /:/g; +function escapeId(str) { + return str ? String(str).replace(ID_DELIM, '\\:') : ''; +} + +function applyStyle(dom, styleFn) { + if (styleFn) { + dom.attr('style', styleFn); + } +} + +function applyClass(dom, classFn, otherClasses) { + if (classFn) { + dom.attr('class', classFn).attr('class', otherClasses + ' ' + dom.attr('class')); + } +} + +function applyTransition(selection, g) { + var graph = g.graph(); + + if (isPlainObject(graph)) { + var transition = graph.transition; + if (isFunction(transition)) { + return transition(selection); + } + } + + return selection; +} + +function addHtmlLabel(root, node) { + var fo = root.append('foreignObject').attr('width', '100000'); + + var div = fo.append('xhtml:div'); + div.attr('xmlns', 'http://www.w3.org/1999/xhtml'); + + var label = node.label; + switch (typeof label) { + case 'function': + div.insert(label); + break; + case 'object': + // Currently we assume this is a DOM object. + div.insert(function () { + return label; + }); + break; + default: + div.html(label); + } + + applyStyle(div, node.labelStyle); + div.style('display', 'inline-block'); + // Fix for firefox + div.style('white-space', 'nowrap'); + + var client = div.node().getBoundingClientRect(); + fo.attr('width', client.width).attr('height', client.height); + + return fo; +} + +const conf = {}; +const setConf = function(cnf) { + const keys = Object.keys(cnf); + for (const key of keys) { + conf[key] = cnf[key]; + } +}; +const addVertices = async function(vert, g, svgId, root, doc, diagObj) { + const svg = root.select(`[id="${svgId}"]`); + const keys = Object.keys(vert); + for (const id of keys) { + const vertex = vert[id]; + let classStr = "default"; + if (vertex.classes.length > 0) { + classStr = vertex.classes.join(" "); + } + classStr = classStr + " flowchart-label"; + const styles = getStylesFromArray(vertex.styles); + let vertexText = vertex.text !== void 0 ? vertex.text : vertex.id; + let vertexNode; + log$1.info("vertex", vertex, vertex.labelType); + if (vertex.labelType === "markdown") { + log$1.info("vertex", vertex, vertex.labelType); + } else { + if (evaluate(getConfig().flowchart.htmlLabels)) { + const node = { + label: vertexText + }; + vertexNode = addHtmlLabel(svg, node).node(); + vertexNode.parentNode.removeChild(vertexNode); + } else { + const svgLabel = doc.createElementNS("http://www.w3.org/2000/svg", "text"); + svgLabel.setAttribute("style", styles.labelStyle.replace("color:", "fill:")); + const rows = vertexText.split(common$1.lineBreakRegex); + for (const row of rows) { + const tspan = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); + tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"); + tspan.setAttribute("dy", "1em"); + tspan.setAttribute("x", "1"); + tspan.textContent = row; + svgLabel.appendChild(tspan); + } + vertexNode = svgLabel; + } + } + let radius = 0; + let _shape = ""; + switch (vertex.type) { + case "round": + radius = 5; + _shape = "rect"; + break; + case "square": + _shape = "rect"; + break; + case "diamond": + _shape = "question"; + break; + case "hexagon": + _shape = "hexagon"; + break; + case "odd": + _shape = "rect_left_inv_arrow"; + break; + case "lean_right": + _shape = "lean_right"; + break; + case "lean_left": + _shape = "lean_left"; + break; + case "trapezoid": + _shape = "trapezoid"; + break; + case "inv_trapezoid": + _shape = "inv_trapezoid"; + break; + case "odd_right": + _shape = "rect_left_inv_arrow"; + break; + case "circle": + _shape = "circle"; + break; + case "ellipse": + _shape = "ellipse"; + break; + case "stadium": + _shape = "stadium"; + break; + case "subroutine": + _shape = "subroutine"; + break; + case "cylinder": + _shape = "cylinder"; + break; + case "group": + _shape = "rect"; + break; + case "doublecircle": + _shape = "doublecircle"; + break; + default: + _shape = "rect"; + } + const labelText = await renderKatex(vertexText, getConfig()); + g.setNode(vertex.id, { + labelStyle: styles.labelStyle, + shape: _shape, + labelText, + labelType: vertex.labelType, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + link: vertex.link, + linkTarget: vertex.linkTarget, + tooltip: diagObj.db.getTooltip(vertex.id) || "", + domId: diagObj.db.lookUpDomId(vertex.id), + haveCallback: vertex.haveCallback, + width: vertex.type === "group" ? 500 : void 0, + dir: vertex.dir, + type: vertex.type, + props: vertex.props, + padding: getConfig().flowchart.padding + }); + log$1.info("setNode", { + labelStyle: styles.labelStyle, + labelType: vertex.labelType, + shape: _shape, + labelText, + rx: radius, + ry: radius, + class: classStr, + style: styles.style, + id: vertex.id, + domId: diagObj.db.lookUpDomId(vertex.id), + width: vertex.type === "group" ? 500 : void 0, + type: vertex.type, + dir: vertex.dir, + props: vertex.props, + padding: getConfig().flowchart.padding + }); + } +}; +const addEdges = async function(edges, g, diagObj) { + log$1.info("abc78 edges = ", edges); + let cnt = 0; + let linkIdCnt = {}; + let defaultStyle; + let defaultLabelStyle; + if (edges.defaultStyle !== void 0) { + const defaultStyles = getStylesFromArray(edges.defaultStyle); + defaultStyle = defaultStyles.style; + defaultLabelStyle = defaultStyles.labelStyle; + } + for (const edge of edges) { + cnt++; + const linkIdBase = "L-" + edge.start + "-" + edge.end; + if (linkIdCnt[linkIdBase] === void 0) { + linkIdCnt[linkIdBase] = 0; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } else { + linkIdCnt[linkIdBase]++; + log$1.info("abc78 new entry", linkIdBase, linkIdCnt[linkIdBase]); + } + let linkId = linkIdBase + "-" + linkIdCnt[linkIdBase]; + log$1.info("abc78 new link id to be used is", linkIdBase, linkId, linkIdCnt[linkIdBase]); + const linkNameStart = "LS-" + edge.start; + const linkNameEnd = "LE-" + edge.end; + const edgeData = { style: "", labelStyle: "" }; + edgeData.minlen = edge.length || 1; + if (edge.type === "arrow_open") { + edgeData.arrowhead = "none"; + } else { + edgeData.arrowhead = "normal"; + } + edgeData.arrowTypeStart = "arrow_open"; + edgeData.arrowTypeEnd = "arrow_open"; + switch (edge.type) { + case "double_arrow_cross": + edgeData.arrowTypeStart = "arrow_cross"; + case "arrow_cross": + edgeData.arrowTypeEnd = "arrow_cross"; + break; + case "double_arrow_point": + edgeData.arrowTypeStart = "arrow_point"; + case "arrow_point": + edgeData.arrowTypeEnd = "arrow_point"; + break; + case "double_arrow_circle": + edgeData.arrowTypeStart = "arrow_circle"; + case "arrow_circle": + edgeData.arrowTypeEnd = "arrow_circle"; + break; + } + let style = ""; + let labelStyle = ""; + switch (edge.stroke) { + case "normal": + style = "fill:none;"; + if (defaultStyle !== void 0) { + style = defaultStyle; + } + if (defaultLabelStyle !== void 0) { + labelStyle = defaultLabelStyle; + } + edgeData.thickness = "normal"; + edgeData.pattern = "solid"; + break; + case "dotted": + edgeData.thickness = "normal"; + edgeData.pattern = "dotted"; + edgeData.style = "fill:none;stroke-width:2px;stroke-dasharray:3;"; + break; + case "thick": + edgeData.thickness = "thick"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 3.5px;fill:none;"; + break; + case "invisible": + edgeData.thickness = "invisible"; + edgeData.pattern = "solid"; + edgeData.style = "stroke-width: 0;fill:none;"; + break; + } + if (edge.style !== void 0) { + const styles = getStylesFromArray(edge.style); + style = styles.style; + labelStyle = styles.labelStyle; + } + edgeData.style = edgeData.style += style; + edgeData.labelStyle = edgeData.labelStyle += labelStyle; + if (edge.interpolate !== void 0) { + edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear); + } else if (edges.defaultInterpolate !== void 0) { + edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear); + } else { + edgeData.curve = interpolateToCurve(conf.curve, curveLinear); + } + if (edge.text === void 0) { + if (edge.style !== void 0) { + edgeData.arrowheadStyle = "fill: #333"; + } + } else { + edgeData.arrowheadStyle = "fill: #333"; + edgeData.labelpos = "c"; + } + edgeData.labelType = edge.labelType; + edgeData.label = await renderKatex(edge.text.replace(common$1.lineBreakRegex, "\n"), getConfig()); + if (edge.style === void 0) { + edgeData.style = edgeData.style || "stroke: #333; stroke-width: 1.5px;fill:none;"; + } + edgeData.labelStyle = edgeData.labelStyle.replace("color:", "fill:"); + edgeData.id = linkId; + edgeData.classes = "flowchart-link " + linkNameStart + " " + linkNameEnd; + g.setEdge(edge.start, edge.end, edgeData, cnt); + } +}; +const getClasses = function(text, diagObj) { + return diagObj.db.getClasses(); +}; +const draw = async function(text, id, _version, diagObj) { + log$1.info("Drawing flowchart"); + let dir = diagObj.db.getDirection(); + if (dir === void 0) { + dir = "TD"; + } + const { securityLevel, flowchart: conf2 } = getConfig(); + const nodeSpacing = conf2.nodeSpacing || 50; + const rankSpacing = conf2.rankSpacing || 50; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document; + const g = new Graph({ + multigraph: true, + compound: true + }).setGraph({ + rankdir: dir, + nodesep: nodeSpacing, + ranksep: rankSpacing, + marginx: 0, + marginy: 0 + }).setDefaultEdgeLabel(function() { + return {}; + }); + let subG; + const subGraphs = diagObj.db.getSubGraphs(); + log$1.info("Subgraphs - ", subGraphs); + for (let i2 = subGraphs.length - 1; i2 >= 0; i2--) { + subG = subGraphs[i2]; + log$1.info("Subgraph - ", subG); + diagObj.db.addVertex( + subG.id, + { text: subG.title, type: subG.labelType }, + "group", + void 0, + subG.classes, + subG.dir + ); + } + const vert = diagObj.db.getVertices(); + const edges = diagObj.db.getEdges(); + log$1.info("Edges", edges); + let i = 0; + for (i = subGraphs.length - 1; i >= 0; i--) { + subG = subGraphs[i]; + selectAll("cluster").append("text"); + for (let j = 0; j < subG.nodes.length; j++) { + log$1.info("Setting up subgraphs", subG.nodes[j], subG.id); + g.setParent(subG.nodes[j], subG.id); + } + } + await addVertices(vert, g, id, root, doc, diagObj); + await addEdges(edges, g); + const svg = root.select(`[id="${id}"]`); + const element = root.select("#" + id + " g"); + await render(element, g, ["point", "circle", "cross"], "flowchart", id); + utils.insertTitle(svg, "flowchartTitleText", conf2.titleTopMargin, diagObj.db.getDiagramTitle()); + setupGraphViewbox$1(g, svg, conf2.diagramPadding, conf2.useMaxWidth); + diagObj.db.indexNodes("subGraph" + i); + if (!conf2.htmlLabels) { + const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); + for (const label of labels) { + const dim = label.getBBox(); + const rect = doc.createElementNS("http://www.w3.org/2000/svg", "rect"); + rect.setAttribute("rx", 0); + rect.setAttribute("ry", 0); + rect.setAttribute("width", dim.width); + rect.setAttribute("height", dim.height); + label.insertBefore(rect, label.firstChild); + } + } + const keys = Object.keys(vert); + keys.forEach(function(key) { + const vertex = vert[key]; + if (vertex.link) { + const node = select("#" + id + ' [id="' + key + '"]'); + if (node) { + const link = doc.createElementNS("http://www.w3.org/2000/svg", "a"); + link.setAttributeNS("http://www.w3.org/2000/svg", "class", vertex.classes.join(" ")); + link.setAttributeNS("http://www.w3.org/2000/svg", "href", vertex.link); + link.setAttributeNS("http://www.w3.org/2000/svg", "rel", "noopener"); + if (securityLevel === "sandbox") { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", "_top"); + } else if (vertex.linkTarget) { + link.setAttributeNS("http://www.w3.org/2000/svg", "target", vertex.linkTarget); + } + const linkNode = node.insert(function() { + return link; + }, ":first-child"); + const shape = node.select(".label-container"); + if (shape) { + linkNode.append(function() { + return shape.node(); + }); + } + const label = node.select(".label"); + if (label) { + linkNode.append(function() { + return label.node(); + }); + } + } + } + }); +}; +const flowRendererV2 = { + setConf, + addVertices, + addEdges, + getClasses, + draw +}; +const fade = (color, opacity) => { + const channel$1 = channel; + const r = channel$1(color, "r"); + const g = channel$1(color, "g"); + const b = channel$1(color, "b"); + return rgba(r, g, b, opacity); +}; +const getStyles = (options) => `.label { + font-family: ${options.fontFamily}; + color: ${options.nodeTextColor || options.textColor}; + } + .cluster-label text { + fill: ${options.titleColor}; + } + .cluster-label span,p { + color: ${options.titleColor}; + } + + .label text,span,p { + fill: ${options.nodeTextColor || options.textColor}; + color: ${options.nodeTextColor || options.textColor}; + } + + .node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + .flowchart-label text { + text-anchor: middle; + } + // .flowchart-label .text-outer-tspan { + // text-anchor: middle; + // } + // .flowchart-label .text-inner-tspan { + // text-anchor: start; + // } + + .node .katex path { + fill: #000; + stroke: #000; + stroke-width: 1px; + } + + .node .label { + text-align: center; + } + .node.clickable { + cursor: pointer; + } + + .arrowheadPath { + fill: ${options.arrowheadColor}; + } + + .edgePath .path { + stroke: ${options.lineColor}; + stroke-width: 2.0px; + } + + .flowchart-link { + stroke: ${options.lineColor}; + fill: none; + } + + .edgeLabel { + background-color: ${options.edgeLabelBackground}; + rect { + opacity: 0.5; + background-color: ${options.edgeLabelBackground}; + fill: ${options.edgeLabelBackground}; + } + text-align: center; + } + + /* For html labels only */ + .labelBkg { + background-color: ${fade(options.edgeLabelBackground, 0.5)}; + // background-color: + } + + .cluster rect { + fill: ${options.clusterBkg}; + stroke: ${options.clusterBorder}; + stroke-width: 1px; + } + + .cluster text { + fill: ${options.titleColor}; + } + + .cluster span,p { + color: ${options.titleColor}; + } + /* .cluster div { + color: ${options.titleColor}; + } */ + + div.mermaidTooltip { + position: absolute; + text-align: center; + max-width: 200px; + padding: 2px; + font-family: ${options.fontFamily}; + font-size: 12px; + background: ${options.tertiaryColor}; + border: 1px solid ${options.border2}; + border-radius: 2px; + pointer-events: none; + z-index: 100; + } + + .flowchartTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; + } +`; +const flowStyles = getStyles; + +export { applyStyle as a, addHtmlLabel as b, applyTransition as c, applyClass as d, edgeToId as e, flowRendererV2 as f, flowStyles as g, isSubgraph as i, selectAll as s }; diff --git a/libs/marked/styles-b83b31c9-BFSyAItk.js b/libs/marked/styles-b83b31c9-BFSyAItk.js new file mode 100644 index 0000000..f0bc446 --- /dev/null +++ b/libs/marked/styles-b83b31c9-BFSyAItk.js @@ -0,0 +1,1481 @@ +import { s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, c as getConfig, C as setDiagramTitle, D as getDiagramTitle, j as common$1, E as clear$1, l as log$1, A as utils, h as select, d as sanitizeText$2, G as parseGenericTypes } from './index-CN3YjQ0n.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 17], $V1 = [1, 18], $V2 = [1, 19], $V3 = [1, 39], $V4 = [1, 40], $V5 = [1, 25], $V6 = [1, 23], $V7 = [1, 24], $V8 = [1, 31], $V9 = [1, 32], $Va = [1, 33], $Vb = [1, 34], $Vc = [1, 35], $Vd = [1, 36], $Ve = [1, 26], $Vf = [1, 27], $Vg = [1, 28], $Vh = [1, 29], $Vi = [1, 43], $Vj = [1, 30], $Vk = [1, 42], $Vl = [1, 44], $Vm = [1, 41], $Vn = [1, 45], $Vo = [1, 9], $Vp = [1, 8, 9], $Vq = [1, 56], $Vr = [1, 57], $Vs = [1, 58], $Vt = [1, 59], $Vu = [1, 60], $Vv = [1, 61], $Vw = [1, 62], $Vx = [1, 8, 9, 39], $Vy = [1, 74], $Vz = [1, 8, 9, 12, 13, 21, 37, 39, 42, 59, 60, 61, 62, 63, 64, 65, 70, 72], $VA = [1, 8, 9, 12, 13, 19, 21, 37, 39, 42, 46, 59, 60, 61, 62, 63, 64, 65, 70, 72, 74, 80, 95, 97, 98], $VB = [13, 74, 80, 95, 97, 98], $VC = [13, 64, 65, 74, 80, 95, 97, 98], $VD = [13, 59, 60, 61, 62, 63, 74, 80, 95, 97, 98], $VE = [1, 93], $VF = [1, 110], $VG = [1, 108], $VH = [1, 102], $VI = [1, 103], $VJ = [1, 104], $VK = [1, 105], $VL = [1, 106], $VM = [1, 107], $VN = [1, 109], $VO = [1, 8, 9, 37, 39, 42], $VP = [1, 8, 9, 21], $VQ = [1, 8, 9, 78], $VR = [1, 8, 9, 21, 73, 74, 78, 80, 81, 82, 83, 84, 85]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mermaidDoc": 4, "statements": 5, "graphConfig": 6, "CLASS_DIAGRAM": 7, "NEWLINE": 8, "EOF": 9, "statement": 10, "classLabel": 11, "SQS": 12, "STR": 13, "SQE": 14, "namespaceName": 15, "alphaNumToken": 16, "className": 17, "classLiteralName": 18, "GENERICTYPE": 19, "relationStatement": 20, "LABEL": 21, "namespaceStatement": 22, "classStatement": 23, "memberStatement": 24, "annotationStatement": 25, "clickStatement": 26, "styleStatement": 27, "cssClassStatement": 28, "noteStatement": 29, "direction": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "namespaceIdentifier": 36, "STRUCT_START": 37, "classStatements": 38, "STRUCT_STOP": 39, "NAMESPACE": 40, "classIdentifier": 41, "STYLE_SEPARATOR": 42, "members": 43, "CLASS": 44, "ANNOTATION_START": 45, "ANNOTATION_END": 46, "MEMBER": 47, "SEPARATOR": 48, "relation": 49, "NOTE_FOR": 50, "noteText": 51, "NOTE": 52, "direction_tb": 53, "direction_bt": 54, "direction_rl": 55, "direction_lr": 56, "relationType": 57, "lineType": 58, "AGGREGATION": 59, "EXTENSION": 60, "COMPOSITION": 61, "DEPENDENCY": 62, "LOLLIPOP": 63, "LINE": 64, "DOTTED_LINE": 65, "CALLBACK": 66, "LINK": 67, "LINK_TARGET": 68, "CLICK": 69, "CALLBACK_NAME": 70, "CALLBACK_ARGS": 71, "HREF": 72, "STYLE": 73, "ALPHA": 74, "stylesOpt": 75, "CSSCLASS": 76, "style": 77, "COMMA": 78, "styleComponent": 79, "NUM": 80, "COLON": 81, "UNIT": 82, "SPACE": 83, "BRKT": 84, "PCT": 85, "commentToken": 86, "textToken": 87, "graphCodeTokens": 88, "textNoTagsToken": 89, "TAGSTART": 90, "TAGEND": 91, "==": 92, "--": 93, "DEFAULT": 94, "MINUS": 95, "keywords": 96, "UNICODE_TEXT": 97, "BQUOTE_STR": 98, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 7: "CLASS_DIAGRAM", 8: "NEWLINE", 9: "EOF", 12: "SQS", 13: "STR", 14: "SQE", 19: "GENERICTYPE", 21: "LABEL", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 37: "STRUCT_START", 39: "STRUCT_STOP", 40: "NAMESPACE", 42: "STYLE_SEPARATOR", 44: "CLASS", 45: "ANNOTATION_START", 46: "ANNOTATION_END", 47: "MEMBER", 48: "SEPARATOR", 50: "NOTE_FOR", 52: "NOTE", 53: "direction_tb", 54: "direction_bt", 55: "direction_rl", 56: "direction_lr", 59: "AGGREGATION", 60: "EXTENSION", 61: "COMPOSITION", 62: "DEPENDENCY", 63: "LOLLIPOP", 64: "LINE", 65: "DOTTED_LINE", 66: "CALLBACK", 67: "LINK", 68: "LINK_TARGET", 69: "CLICK", 70: "CALLBACK_NAME", 71: "CALLBACK_ARGS", 72: "HREF", 73: "STYLE", 74: "ALPHA", 76: "CSSCLASS", 78: "COMMA", 80: "NUM", 81: "COLON", 82: "UNIT", 83: "SPACE", 84: "BRKT", 85: "PCT", 88: "graphCodeTokens", 90: "TAGSTART", 91: "TAGEND", 92: "==", 93: "--", 94: "DEFAULT", 95: "MINUS", 96: "keywords", 97: "UNICODE_TEXT", 98: "BQUOTE_STR" }, + productions_: [0, [3, 1], [3, 1], [4, 1], [6, 4], [5, 1], [5, 2], [5, 3], [11, 3], [15, 1], [15, 2], [17, 1], [17, 1], [17, 2], [17, 2], [17, 2], [10, 1], [10, 2], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [22, 4], [22, 5], [36, 2], [38, 1], [38, 2], [38, 3], [23, 1], [23, 3], [23, 4], [23, 6], [41, 2], [41, 3], [25, 4], [43, 1], [43, 2], [24, 1], [24, 2], [24, 1], [24, 1], [20, 3], [20, 4], [20, 4], [20, 5], [29, 3], [29, 2], [30, 1], [30, 1], [30, 1], [30, 1], [49, 3], [49, 2], [49, 2], [49, 1], [57, 1], [57, 1], [57, 1], [57, 1], [57, 1], [58, 1], [58, 1], [26, 3], [26, 4], [26, 3], [26, 4], [26, 4], [26, 5], [26, 3], [26, 4], [26, 4], [26, 5], [26, 4], [26, 5], [26, 5], [26, 6], [27, 3], [28, 3], [75, 1], [75, 3], [77, 1], [77, 2], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [86, 1], [86, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [89, 1], [89, 1], [89, 1], [89, 1], [16, 1], [16, 1], [16, 1], [16, 1], [18, 1], [51, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 8: + this.$ = $$[$0 - 1]; + break; + case 9: + case 11: + case 12: + this.$ = $$[$0]; + break; + case 10: + case 13: + this.$ = $$[$0 - 1] + $$[$0]; + break; + case 14: + case 15: + this.$ = $$[$0 - 1] + "~" + $$[$0] + "~"; + break; + case 16: + yy.addRelation($$[$0]); + break; + case 17: + $$[$0 - 1].title = yy.cleanupLabel($$[$0]); + yy.addRelation($$[$0 - 1]); + break; + case 27: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 28: + case 29: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 30: + yy.addClassesToNamespace($$[$0 - 3], $$[$0 - 1]); + break; + case 31: + yy.addClassesToNamespace($$[$0 - 4], $$[$0 - 1]); + break; + case 32: + this.$ = $$[$0]; + yy.addNamespace($$[$0]); + break; + case 33: + this.$ = [$$[$0]]; + break; + case 34: + this.$ = [$$[$0 - 1]]; + break; + case 35: + $$[$0].unshift($$[$0 - 2]); + this.$ = $$[$0]; + break; + case 37: + yy.setCssClass($$[$0 - 2], $$[$0]); + break; + case 38: + yy.addMembers($$[$0 - 3], $$[$0 - 1]); + break; + case 39: + yy.setCssClass($$[$0 - 5], $$[$0 - 3]); + yy.addMembers($$[$0 - 5], $$[$0 - 1]); + break; + case 40: + this.$ = $$[$0]; + yy.addClass($$[$0]); + break; + case 41: + this.$ = $$[$0 - 1]; + yy.addClass($$[$0 - 1]); + yy.setClassLabel($$[$0 - 1], $$[$0]); + break; + case 42: + yy.addAnnotation($$[$0], $$[$0 - 2]); + break; + case 43: + this.$ = [$$[$0]]; + break; + case 44: + $$[$0].push($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 45: + break; + case 46: + yy.addMember($$[$0 - 1], yy.cleanupLabel($$[$0])); + break; + case 47: + break; + case 48: + break; + case 49: + this.$ = { "id1": $$[$0 - 2], "id2": $$[$0], relation: $$[$0 - 1], relationTitle1: "none", relationTitle2: "none" }; + break; + case 50: + this.$ = { id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 1], relationTitle1: $$[$0 - 2], relationTitle2: "none" }; + break; + case 51: + this.$ = { id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: "none", relationTitle2: $$[$0 - 1] }; + break; + case 52: + this.$ = { id1: $$[$0 - 4], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: $$[$0 - 3], relationTitle2: $$[$0 - 1] }; + break; + case 53: + yy.addNote($$[$0], $$[$0 - 1]); + break; + case 54: + yy.addNote($$[$0]); + break; + case 55: + yy.setDirection("TB"); + break; + case 56: + yy.setDirection("BT"); + break; + case 57: + yy.setDirection("RL"); + break; + case 58: + yy.setDirection("LR"); + break; + case 59: + this.$ = { type1: $$[$0 - 2], type2: $$[$0], lineType: $$[$0 - 1] }; + break; + case 60: + this.$ = { type1: "none", type2: $$[$0], lineType: $$[$0 - 1] }; + break; + case 61: + this.$ = { type1: $$[$0 - 1], type2: "none", lineType: $$[$0] }; + break; + case 62: + this.$ = { type1: "none", type2: "none", lineType: $$[$0] }; + break; + case 63: + this.$ = yy.relationType.AGGREGATION; + break; + case 64: + this.$ = yy.relationType.EXTENSION; + break; + case 65: + this.$ = yy.relationType.COMPOSITION; + break; + case 66: + this.$ = yy.relationType.DEPENDENCY; + break; + case 67: + this.$ = yy.relationType.LOLLIPOP; + break; + case 68: + this.$ = yy.lineType.LINE; + break; + case 69: + this.$ = yy.lineType.DOTTED_LINE; + break; + case 70: + case 76: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 1], $$[$0]); + break; + case 71: + case 77: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 2], $$[$0]); + break; + case 72: + this.$ = $$[$0 - 2]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 73: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 74: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 2], $$[$0]); + break; + case 75: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 2], $$[$0]); + yy.setTooltip($$[$0 - 3], $$[$0 - 1]); + break; + case 78: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 79: + this.$ = $$[$0 - 4]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 80: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 81: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 1], $$[$0]); + break; + case 82: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 1]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 83: + this.$ = $$[$0 - 5]; + yy.setLink($$[$0 - 4], $$[$0 - 2], $$[$0]); + yy.setTooltip($$[$0 - 4], $$[$0 - 1]); + break; + case 84: + this.$ = $$[$0 - 2]; + yy.setCssStyle($$[$0 - 1], $$[$0]); + break; + case 85: + yy.setCssClass($$[$0 - 1], $$[$0]); + break; + case 86: + this.$ = [$$[$0]]; + break; + case 87: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 89: + this.$ = $$[$0 - 1] + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: 4, 7: [1, 6], 10: 5, 16: 37, 17: 20, 18: 38, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 31: $V0, 33: $V1, 35: $V2, 36: 21, 40: $V3, 41: 22, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 1: [3] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3] }, o($Vo, [2, 5], { 8: [1, 46] }), { 8: [1, 47] }, o($Vp, [2, 16], { 21: [1, 48] }), o($Vp, [2, 18]), o($Vp, [2, 19]), o($Vp, [2, 20]), o($Vp, [2, 21]), o($Vp, [2, 22]), o($Vp, [2, 23]), o($Vp, [2, 24]), o($Vp, [2, 25]), o($Vp, [2, 26]), { 32: [1, 49] }, { 34: [1, 50] }, o($Vp, [2, 29]), o($Vp, [2, 45], { 49: 51, 57: 54, 58: 55, 13: [1, 52], 21: [1, 53], 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu, 64: $Vv, 65: $Vw }), { 37: [1, 63] }, o($Vx, [2, 36], { 37: [1, 65], 42: [1, 64] }), o($Vp, [2, 47]), o($Vp, [2, 48]), { 16: 66, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 16: 37, 17: 67, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 16: 37, 17: 68, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 16: 37, 17: 69, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 74: [1, 70] }, { 13: [1, 71] }, { 16: 37, 17: 72, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 13: $Vy, 51: 73 }, o($Vp, [2, 55]), o($Vp, [2, 56]), o($Vp, [2, 57]), o($Vp, [2, 58]), o($Vz, [2, 11], { 16: 37, 18: 38, 17: 75, 19: [1, 76], 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }), o($Vz, [2, 12], { 19: [1, 77] }), { 15: 78, 16: 79, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 16: 37, 17: 80, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VA, [2, 112]), o($VA, [2, 113]), o($VA, [2, 114]), o($VA, [2, 115]), o([1, 8, 9, 12, 13, 19, 21, 37, 39, 42, 59, 60, 61, 62, 63, 64, 65, 70, 72], [2, 116]), o($Vo, [2, 6], { 10: 5, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 17: 20, 36: 21, 41: 22, 16: 37, 18: 38, 5: 81, 31: $V0, 33: $V1, 35: $V2, 40: $V3, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }), { 5: 82, 10: 5, 16: 37, 17: 20, 18: 38, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 31: $V0, 33: $V1, 35: $V2, 36: 21, 40: $V3, 41: 22, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($Vp, [2, 17]), o($Vp, [2, 27]), o($Vp, [2, 28]), { 13: [1, 84], 16: 37, 17: 83, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 49: 85, 57: 54, 58: 55, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu, 64: $Vv, 65: $Vw }, o($Vp, [2, 46]), { 58: 86, 64: $Vv, 65: $Vw }, o($VB, [2, 62], { 57: 87, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu }), o($VC, [2, 63]), o($VC, [2, 64]), o($VC, [2, 65]), o($VC, [2, 66]), o($VC, [2, 67]), o($VD, [2, 68]), o($VD, [2, 69]), { 8: [1, 89], 23: 90, 38: 88, 41: 22, 44: $V4 }, { 16: 91, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 43: 92, 47: $VE }, { 46: [1, 94] }, { 13: [1, 95] }, { 13: [1, 96] }, { 70: [1, 97], 72: [1, 98] }, { 21: $VF, 73: $VG, 74: $VH, 75: 99, 77: 100, 79: 101, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }, { 74: [1, 111] }, { 13: $Vy, 51: 112 }, o($Vp, [2, 54]), o($Vp, [2, 117]), o($Vz, [2, 13]), o($Vz, [2, 14]), o($Vz, [2, 15]), { 37: [2, 32] }, { 15: 113, 16: 79, 37: [2, 9], 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, o($VO, [2, 40], { 11: 114, 12: [1, 115] }), o($Vo, [2, 7]), { 9: [1, 116] }, o($VP, [2, 49]), { 16: 37, 17: 117, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 13: [1, 119], 16: 37, 17: 118, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VB, [2, 61], { 57: 120, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu }), o($VB, [2, 60]), { 39: [1, 121] }, { 23: 90, 38: 122, 41: 22, 44: $V4 }, { 8: [1, 123], 39: [2, 33] }, o($Vx, [2, 37], { 37: [1, 124] }), { 39: [1, 125] }, { 39: [2, 43], 43: 126, 47: $VE }, { 16: 37, 17: 127, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($Vp, [2, 70], { 13: [1, 128] }), o($Vp, [2, 72], { 13: [1, 130], 68: [1, 129] }), o($Vp, [2, 76], { 13: [1, 131], 71: [1, 132] }), { 13: [1, 133] }, o($Vp, [2, 84], { 78: [1, 134] }), o($VQ, [2, 86], { 79: 135, 21: $VF, 73: $VG, 74: $VH, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }), o($VR, [2, 88]), o($VR, [2, 90]), o($VR, [2, 91]), o($VR, [2, 92]), o($VR, [2, 93]), o($VR, [2, 94]), o($VR, [2, 95]), o($VR, [2, 96]), o($VR, [2, 97]), o($VR, [2, 98]), o($Vp, [2, 85]), o($Vp, [2, 53]), { 37: [2, 10] }, o($VO, [2, 41]), { 13: [1, 136] }, { 1: [2, 4] }, o($VP, [2, 51]), o($VP, [2, 50]), { 16: 37, 17: 137, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VB, [2, 59]), o($Vp, [2, 30]), { 39: [1, 138] }, { 23: 90, 38: 139, 39: [2, 34], 41: 22, 44: $V4 }, { 43: 140, 47: $VE }, o($Vx, [2, 38]), { 39: [2, 44] }, o($Vp, [2, 42]), o($Vp, [2, 71]), o($Vp, [2, 73]), o($Vp, [2, 74], { 68: [1, 141] }), o($Vp, [2, 77]), o($Vp, [2, 78], { 13: [1, 142] }), o($Vp, [2, 80], { 13: [1, 144], 68: [1, 143] }), { 21: $VF, 73: $VG, 74: $VH, 77: 145, 79: 101, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }, o($VR, [2, 89]), { 14: [1, 146] }, o($VP, [2, 52]), o($Vp, [2, 31]), { 39: [2, 35] }, { 39: [1, 147] }, o($Vp, [2, 75]), o($Vp, [2, 79]), o($Vp, [2, 81]), o($Vp, [2, 82], { 68: [1, 148] }), o($VQ, [2, 87], { 79: 135, 21: $VF, 73: $VG, 74: $VH, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }), o($VO, [2, 8]), o($Vx, [2, 39]), o($Vp, [2, 83])], + defaultActions: { 2: [2, 1], 3: [2, 2], 4: [2, 3], 78: [2, 32], 113: [2, 10], 116: [2, 4], 126: [2, 44], 139: [2, 35] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 53; + case 1: + return 54; + case 2: + return 55; + case 3: + return 56; + case 4: + break; + case 5: + break; + case 6: + this.begin("acc_title"); + return 31; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 33; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + return 8; + case 14: + break; + case 15: + return 7; + case 16: + return 7; + case 17: + return "EDGE_STATE"; + case 18: + this.begin("callback_name"); + break; + case 19: + this.popState(); + break; + case 20: + this.popState(); + this.begin("callback_args"); + break; + case 21: + return 70; + case 22: + this.popState(); + break; + case 23: + return 71; + case 24: + this.popState(); + break; + case 25: + return "STR"; + case 26: + this.begin("string"); + break; + case 27: + return 73; + case 28: + this.begin("namespace"); + return 40; + case 29: + this.popState(); + return 8; + case 30: + break; + case 31: + this.begin("namespace-body"); + return 37; + case 32: + this.popState(); + return 39; + case 33: + return "EOF_IN_STRUCT"; + case 34: + return 8; + case 35: + break; + case 36: + return "EDGE_STATE"; + case 37: + this.begin("class"); + return 44; + case 38: + this.popState(); + return 8; + case 39: + break; + case 40: + this.popState(); + this.popState(); + return 39; + case 41: + this.begin("class-body"); + return 37; + case 42: + this.popState(); + return 39; + case 43: + return "EOF_IN_STRUCT"; + case 44: + return "EDGE_STATE"; + case 45: + return "OPEN_IN_STRUCT"; + case 46: + break; + case 47: + return "MEMBER"; + case 48: + return 76; + case 49: + return 66; + case 50: + return 67; + case 51: + return 69; + case 52: + return 50; + case 53: + return 52; + case 54: + return 45; + case 55: + return 46; + case 56: + return 72; + case 57: + this.popState(); + break; + case 58: + return "GENERICTYPE"; + case 59: + this.begin("generic"); + break; + case 60: + this.popState(); + break; + case 61: + return "BQUOTE_STR"; + case 62: + this.begin("bqstring"); + break; + case 63: + return 68; + case 64: + return 68; + case 65: + return 68; + case 66: + return 68; + case 67: + return 60; + case 68: + return 60; + case 69: + return 62; + case 70: + return 62; + case 71: + return 61; + case 72: + return 59; + case 73: + return 63; + case 74: + return 64; + case 75: + return 65; + case 76: + return 21; + case 77: + return 42; + case 78: + return 95; + case 79: + return "DOT"; + case 80: + return "PLUS"; + case 81: + return 81; + case 82: + return 78; + case 83: + return 84; + case 84: + return 84; + case 85: + return 85; + case 86: + return "EQUALS"; + case 87: + return "EQUALS"; + case 88: + return 74; + case 89: + return 12; + case 90: + return 14; + case 91: + return "PUNCTUATION"; + case 92: + return 80; + case 93: + return 97; + case 94: + return 83; + case 95: + return 83; + case 96: + return 9; + } + }, + rules: [/^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/, /^(?:%%[^\n]*(\r?\n)*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:classDiagram-v2\b)/, /^(?:classDiagram\b)/, /^(?:\[\*\])/, /^(?:call[\s]+)/, /^(?:\([\s]*\))/, /^(?:\()/, /^(?:[^(]*)/, /^(?:\))/, /^(?:[^)]*)/, /^(?:["])/, /^(?:[^"]*)/, /^(?:["])/, /^(?:style\b)/, /^(?:namespace\b)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:[{])/, /^(?:[}])/, /^(?:$)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:\[\*\])/, /^(?:class\b)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:[}])/, /^(?:[{])/, /^(?:[}])/, /^(?:$)/, /^(?:\[\*\])/, /^(?:[{])/, /^(?:[\n])/, /^(?:[^{}\n]*)/, /^(?:cssClass\b)/, /^(?:callback\b)/, /^(?:link\b)/, /^(?:click\b)/, /^(?:note for\b)/, /^(?:note\b)/, /^(?:<<)/, /^(?:>>)/, /^(?:href\b)/, /^(?:[~])/, /^(?:[^~]*)/, /^(?:~)/, /^(?:[`])/, /^(?:[^`]+)/, /^(?:[`])/, /^(?:_self\b)/, /^(?:_blank\b)/, /^(?:_parent\b)/, /^(?:_top\b)/, /^(?:\s*<\|)/, /^(?:\s*\|>)/, /^(?:\s*>)/, /^(?:\s*<)/, /^(?:\s*\*)/, /^(?:\s*o\b)/, /^(?:\s*\(\))/, /^(?:--)/, /^(?:\.\.)/, /^(?::{1}[^:\n;]+)/, /^(?::{3})/, /^(?:-)/, /^(?:\.)/, /^(?:\+)/, /^(?::)/, /^(?:,)/, /^(?:#)/, /^(?:#)/, /^(?:%)/, /^(?:=)/, /^(?:=)/, /^(?:\w+)/, /^(?:\[)/, /^(?:\])/, /^(?:[!"#$%&'*+,-.`?\\/])/, /^(?:[0-9]+)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\s)/, /^(?:\s)/, /^(?:$)/], + conditions: { "namespace-body": { "rules": [26, 32, 33, 34, 35, 36, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "namespace": { "rules": [26, 28, 29, 30, 31, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "class-body": { "rules": [26, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "class": { "rules": [26, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_descr": { "rules": [9, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_title": { "rules": [7, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "callback_args": { "rules": [22, 23, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "callback_name": { "rules": [19, 20, 21, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "href": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "struct": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "generic": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "bqstring": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "string": { "rules": [24, 25, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 26, 27, 28, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const visibilityValues = ["#", "+", "~", "-", ""]; +class ClassMember { + constructor(input, memberType) { + this.memberType = memberType; + this.visibility = ""; + this.classifier = ""; + const sanitizedInput = sanitizeText$2(input, getConfig()); + this.parseMember(sanitizedInput); + } + getDisplayDetails() { + let displayText = this.visibility + parseGenericTypes(this.id); + if (this.memberType === "method") { + displayText += `(${parseGenericTypes(this.parameters.trim())})`; + if (this.returnType) { + displayText += " : " + parseGenericTypes(this.returnType); + } + } + displayText = displayText.trim(); + const cssStyle = this.parseClassifier(); + return { + displayText, + cssStyle + }; + } + parseMember(input) { + let potentialClassifier = ""; + if (this.memberType === "method") { + const methodRegEx = /([#+~-])?(.+)\((.*)\)([\s$*])?(.*)([$*])?/; + const match = input.match(methodRegEx); + if (match) { + const detectedVisibility = match[1] ? match[1].trim() : ""; + if (visibilityValues.includes(detectedVisibility)) { + this.visibility = detectedVisibility; + } + this.id = match[2].trim(); + this.parameters = match[3] ? match[3].trim() : ""; + potentialClassifier = match[4] ? match[4].trim() : ""; + this.returnType = match[5] ? match[5].trim() : ""; + if (potentialClassifier === "") { + const lastChar = this.returnType.substring(this.returnType.length - 1); + if (lastChar.match(/[$*]/)) { + potentialClassifier = lastChar; + this.returnType = this.returnType.substring(0, this.returnType.length - 1); + } + } + } + } else { + const length = input.length; + const firstChar = input.substring(0, 1); + const lastChar = input.substring(length - 1); + if (visibilityValues.includes(firstChar)) { + this.visibility = firstChar; + } + if (lastChar.match(/[$*]/)) { + potentialClassifier = lastChar; + } + this.id = input.substring( + this.visibility === "" ? 0 : 1, + potentialClassifier === "" ? length : length - 1 + ); + } + this.classifier = potentialClassifier; + } + parseClassifier() { + switch (this.classifier) { + case "*": + return "font-style:italic;"; + case "$": + return "text-decoration:underline;"; + default: + return ""; + } + } +} +const MERMAID_DOM_ID_PREFIX = "classId-"; +let relations = []; +let classes = {}; +let notes = []; +let classCounter = 0; +let namespaces = {}; +let namespaceCounter = 0; +let functions = []; +const sanitizeText = (txt) => common$1.sanitizeText(txt, getConfig()); +const splitClassNameAndType = function(_id) { + const id = common$1.sanitizeText(_id, getConfig()); + let genericType = ""; + let className = id; + if (id.indexOf("~") > 0) { + const split = id.split("~"); + className = sanitizeText(split[0]); + genericType = sanitizeText(split[1]); + } + return { className, type: genericType }; +}; +const setClassLabel = function(_id, label) { + const id = common$1.sanitizeText(_id, getConfig()); + if (label) { + label = sanitizeText(label); + } + const { className } = splitClassNameAndType(id); + classes[className].label = label; +}; +const addClass = function(_id) { + const id = common$1.sanitizeText(_id, getConfig()); + const { className, type } = splitClassNameAndType(id); + if (Object.hasOwn(classes, className)) { + return; + } + const name = common$1.sanitizeText(className, getConfig()); + classes[name] = { + id: name, + type, + label: name, + cssClasses: [], + methods: [], + members: [], + annotations: [], + styles: [], + domId: MERMAID_DOM_ID_PREFIX + name + "-" + classCounter + }; + classCounter++; +}; +const lookUpDomId = function(_id) { + const id = common$1.sanitizeText(_id, getConfig()); + if (id in classes) { + return classes[id].domId; + } + throw new Error("Class not found: " + id); +}; +const clear = function() { + relations = []; + classes = {}; + notes = []; + functions = []; + functions.push(setupToolTips); + namespaces = {}; + namespaceCounter = 0; + clear$1(); +}; +const getClass = function(id) { + return classes[id]; +}; +const getClasses = function() { + return classes; +}; +const getRelations = function() { + return relations; +}; +const getNotes = function() { + return notes; +}; +const addRelation = function(relation) { + log$1.debug("Adding relation: " + JSON.stringify(relation)); + addClass(relation.id1); + addClass(relation.id2); + relation.id1 = splitClassNameAndType(relation.id1).className; + relation.id2 = splitClassNameAndType(relation.id2).className; + relation.relationTitle1 = common$1.sanitizeText(relation.relationTitle1.trim(), getConfig()); + relation.relationTitle2 = common$1.sanitizeText(relation.relationTitle2.trim(), getConfig()); + relations.push(relation); +}; +const addAnnotation = function(className, annotation) { + const validatedClassName = splitClassNameAndType(className).className; + classes[validatedClassName].annotations.push(annotation); +}; +const addMember = function(className, member) { + addClass(className); + const validatedClassName = splitClassNameAndType(className).className; + const theClass = classes[validatedClassName]; + if (typeof member === "string") { + const memberString = member.trim(); + if (memberString.startsWith("<<") && memberString.endsWith(">>")) { + theClass.annotations.push(sanitizeText(memberString.substring(2, memberString.length - 2))); + } else if (memberString.indexOf(")") > 0) { + theClass.methods.push(new ClassMember(memberString, "method")); + } else if (memberString) { + theClass.members.push(new ClassMember(memberString, "attribute")); + } + } +}; +const addMembers = function(className, members) { + if (Array.isArray(members)) { + members.reverse(); + members.forEach((member) => addMember(className, member)); + } +}; +const addNote = function(text, className) { + const note = { + id: `note${notes.length}`, + class: className, + text + }; + notes.push(note); +}; +const cleanupLabel = function(label) { + if (label.startsWith(":")) { + label = label.substring(1); + } + return sanitizeText(label.trim()); +}; +const setCssClass = function(ids, className) { + ids.split(",").forEach(function(_id) { + let id = _id; + if (_id[0].match(/\d/)) { + id = MERMAID_DOM_ID_PREFIX + id; + } + if (classes[id] !== void 0) { + classes[id].cssClasses.push(className); + } + }); +}; +const setTooltip = function(ids, tooltip) { + ids.split(",").forEach(function(id) { + if (tooltip !== void 0) { + classes[id].tooltip = sanitizeText(tooltip); + } + }); +}; +const getTooltip = function(id, namespace) { + if (namespace) { + return namespaces[namespace].classes[id].tooltip; + } + return classes[id].tooltip; +}; +const setLink = function(ids, linkStr, target) { + const config = getConfig(); + ids.split(",").forEach(function(_id) { + let id = _id; + if (_id[0].match(/\d/)) { + id = MERMAID_DOM_ID_PREFIX + id; + } + if (classes[id] !== void 0) { + classes[id].link = utils.formatUrl(linkStr, config); + if (config.securityLevel === "sandbox") { + classes[id].linkTarget = "_top"; + } else if (typeof target === "string") { + classes[id].linkTarget = sanitizeText(target); + } else { + classes[id].linkTarget = "_blank"; + } + } + }); + setCssClass(ids, "clickable"); +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFunc(id, functionName, functionArgs); + classes[id].haveCallback = true; + }); + setCssClass(ids, "clickable"); +}; +const setClickFunc = function(_domId, functionName, functionArgs) { + const domId = common$1.sanitizeText(_domId, getConfig()); + const config = getConfig(); + if (config.securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + const id = domId; + if (classes[id] !== void 0) { + const elemId = lookUpDomId(id); + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(elemId); + } + functions.push(function() { + const elem = document.querySelector(`[id="${elemId}"]`); + if (elem !== null) { + elem.addEventListener( + "click", + function() { + utils.runFunc(functionName, ...argList); + }, + false + ); + } + }); + } +}; +const bindFunctions = function(element) { + functions.forEach(function(fun) { + fun(element); + }); +}; +const lineType = { + LINE: 0, + DOTTED_LINE: 1 +}; +const relationType = { + AGGREGATION: 0, + EXTENSION: 1, + COMPOSITION: 2, + DEPENDENCY: 3, + LOLLIPOP: 4 +}; +const setupToolTips = function(element) { + let tooltipElem = select(".mermaidTooltip"); + if ((tooltipElem._groups || tooltipElem)[0][0] === null) { + tooltipElem = select("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0); + } + const svg = select(element).select("svg"); + const nodes = svg.selectAll("g.node"); + nodes.on("mouseover", function() { + const el = select(this); + const title = el.attr("title"); + if (title === null) { + return; + } + const rect = this.getBoundingClientRect(); + tooltipElem.transition().duration(200).style("opacity", ".9"); + tooltipElem.text(el.attr("title")).style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.top - 14 + document.body.scrollTop + "px"); + tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, "
    ")); + el.classed("hover", true); + }).on("mouseout", function() { + tooltipElem.transition().duration(500).style("opacity", 0); + const el = select(this); + el.classed("hover", false); + }); +}; +functions.push(setupToolTips); +let direction = "TB"; +const getDirection = () => direction; +const setDirection = (dir) => { + direction = dir; +}; +const addNamespace = function(id) { + if (namespaces[id] !== void 0) { + return; + } + namespaces[id] = { + id, + classes: {}, + children: {}, + domId: MERMAID_DOM_ID_PREFIX + id + "-" + namespaceCounter + }; + namespaceCounter++; +}; +const getNamespace = function(name) { + return namespaces[name]; +}; +const getNamespaces = function() { + return namespaces; +}; +const addClassesToNamespace = function(id, classNames) { + if (namespaces[id] === void 0) { + return; + } + for (const name of classNames) { + const { className } = splitClassNameAndType(name); + classes[className].parent = id; + namespaces[id].classes[className] = classes[className]; + } +}; +const setCssStyle = function(id, styles2) { + const thisClass = classes[id]; + if (!styles2 || !thisClass) { + return; + } + for (const s of styles2) { + if (s.includes(",")) { + thisClass.styles.push(...s.split(",")); + } else { + thisClass.styles.push(s); + } + } +}; +const db = { + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + getConfig: () => getConfig().class, + addClass, + bindFunctions, + clear, + getClass, + getClasses, + getNotes, + addAnnotation, + addNote, + getRelations, + addRelation, + getDirection, + setDirection, + addMember, + addMembers, + cleanupLabel, + lineType, + relationType, + setClickEvent, + setCssClass, + setLink, + getTooltip, + setTooltip, + lookUpDomId, + setDiagramTitle, + getDiagramTitle, + setClassLabel, + addNamespace, + addClassesToNamespace, + getNamespace, + getNamespaces, + setCssStyle +}; +const getStyles = (options) => `g.classGroup text { + fill: ${options.nodeBorder || options.classText}; + stroke: none; + font-family: ${options.fontFamily}; + font-size: 10px; + + .title { + font-weight: bolder; + } + +} + +.nodeLabel, .edgeLabel { + color: ${options.classText}; +} +.edgeLabel .label rect { + fill: ${options.mainBkg}; +} +.label text { + fill: ${options.classText}; +} +.edgeLabel .label span { + background: ${options.mainBkg}; +} + +.classTitle { + font-weight: bolder; +} +.node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + +.divider { + stroke: ${options.nodeBorder}; + stroke-width: 1; +} + +g.clickable { + cursor: pointer; +} + +g.classGroup rect { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; +} + +g.classGroup line { + stroke: ${options.nodeBorder}; + stroke-width: 1; +} + +.classLabel .box { + stroke: none; + stroke-width: 0; + fill: ${options.mainBkg}; + opacity: 0.5; +} + +.classLabel .label { + fill: ${options.nodeBorder}; + font-size: 10px; +} + +.relation { + stroke: ${options.lineColor}; + stroke-width: 1; + fill: none; +} + +.dashed-line{ + stroke-dasharray: 3; +} + +.dotted-line{ + stroke-dasharray: 1 2; +} + +#compositionStart, .composition { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#compositionEnd, .composition { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#dependencyStart, .dependency { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#dependencyStart, .dependency { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#extensionStart, .extension { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#extensionEnd, .extension { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#aggregationStart, .aggregation { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#aggregationEnd, .aggregation { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#lollipopStart, .lollipop { + fill: ${options.mainBkg} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#lollipopEnd, .lollipop { + fill: ${options.mainBkg} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +.edgeTerminals { + font-size: 11px; + line-height: initial; +} + +.classTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; +} +`; +const styles = getStyles; + +export { db as d, parser$1 as p, styles as s }; diff --git a/libs/marked/styles-b83b31c9-CoATnBwl.js b/libs/marked/styles-b83b31c9-CoATnBwl.js new file mode 100644 index 0000000..aab9d9e --- /dev/null +++ b/libs/marked/styles-b83b31c9-CoATnBwl.js @@ -0,0 +1,1481 @@ +import { s as setAccTitle, g as getAccTitle, a as getAccDescription, b as setAccDescription, c as getConfig, C as setDiagramTitle, D as getDiagramTitle, j as common$1, E as clear$1, l as log$1, A as utils, h as select, d as sanitizeText$2, G as parseGenericTypes } from './index-Bd_FDXSq.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 17], $V1 = [1, 18], $V2 = [1, 19], $V3 = [1, 39], $V4 = [1, 40], $V5 = [1, 25], $V6 = [1, 23], $V7 = [1, 24], $V8 = [1, 31], $V9 = [1, 32], $Va = [1, 33], $Vb = [1, 34], $Vc = [1, 35], $Vd = [1, 36], $Ve = [1, 26], $Vf = [1, 27], $Vg = [1, 28], $Vh = [1, 29], $Vi = [1, 43], $Vj = [1, 30], $Vk = [1, 42], $Vl = [1, 44], $Vm = [1, 41], $Vn = [1, 45], $Vo = [1, 9], $Vp = [1, 8, 9], $Vq = [1, 56], $Vr = [1, 57], $Vs = [1, 58], $Vt = [1, 59], $Vu = [1, 60], $Vv = [1, 61], $Vw = [1, 62], $Vx = [1, 8, 9, 39], $Vy = [1, 74], $Vz = [1, 8, 9, 12, 13, 21, 37, 39, 42, 59, 60, 61, 62, 63, 64, 65, 70, 72], $VA = [1, 8, 9, 12, 13, 19, 21, 37, 39, 42, 46, 59, 60, 61, 62, 63, 64, 65, 70, 72, 74, 80, 95, 97, 98], $VB = [13, 74, 80, 95, 97, 98], $VC = [13, 64, 65, 74, 80, 95, 97, 98], $VD = [13, 59, 60, 61, 62, 63, 74, 80, 95, 97, 98], $VE = [1, 93], $VF = [1, 110], $VG = [1, 108], $VH = [1, 102], $VI = [1, 103], $VJ = [1, 104], $VK = [1, 105], $VL = [1, 106], $VM = [1, 107], $VN = [1, 109], $VO = [1, 8, 9, 37, 39, 42], $VP = [1, 8, 9, 21], $VQ = [1, 8, 9, 78], $VR = [1, 8, 9, 21, 73, 74, 78, 80, 81, 82, 83, 84, 85]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "mermaidDoc": 4, "statements": 5, "graphConfig": 6, "CLASS_DIAGRAM": 7, "NEWLINE": 8, "EOF": 9, "statement": 10, "classLabel": 11, "SQS": 12, "STR": 13, "SQE": 14, "namespaceName": 15, "alphaNumToken": 16, "className": 17, "classLiteralName": 18, "GENERICTYPE": 19, "relationStatement": 20, "LABEL": 21, "namespaceStatement": 22, "classStatement": 23, "memberStatement": 24, "annotationStatement": 25, "clickStatement": 26, "styleStatement": 27, "cssClassStatement": 28, "noteStatement": 29, "direction": 30, "acc_title": 31, "acc_title_value": 32, "acc_descr": 33, "acc_descr_value": 34, "acc_descr_multiline_value": 35, "namespaceIdentifier": 36, "STRUCT_START": 37, "classStatements": 38, "STRUCT_STOP": 39, "NAMESPACE": 40, "classIdentifier": 41, "STYLE_SEPARATOR": 42, "members": 43, "CLASS": 44, "ANNOTATION_START": 45, "ANNOTATION_END": 46, "MEMBER": 47, "SEPARATOR": 48, "relation": 49, "NOTE_FOR": 50, "noteText": 51, "NOTE": 52, "direction_tb": 53, "direction_bt": 54, "direction_rl": 55, "direction_lr": 56, "relationType": 57, "lineType": 58, "AGGREGATION": 59, "EXTENSION": 60, "COMPOSITION": 61, "DEPENDENCY": 62, "LOLLIPOP": 63, "LINE": 64, "DOTTED_LINE": 65, "CALLBACK": 66, "LINK": 67, "LINK_TARGET": 68, "CLICK": 69, "CALLBACK_NAME": 70, "CALLBACK_ARGS": 71, "HREF": 72, "STYLE": 73, "ALPHA": 74, "stylesOpt": 75, "CSSCLASS": 76, "style": 77, "COMMA": 78, "styleComponent": 79, "NUM": 80, "COLON": 81, "UNIT": 82, "SPACE": 83, "BRKT": 84, "PCT": 85, "commentToken": 86, "textToken": 87, "graphCodeTokens": 88, "textNoTagsToken": 89, "TAGSTART": 90, "TAGEND": 91, "==": 92, "--": 93, "DEFAULT": 94, "MINUS": 95, "keywords": 96, "UNICODE_TEXT": 97, "BQUOTE_STR": 98, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 7: "CLASS_DIAGRAM", 8: "NEWLINE", 9: "EOF", 12: "SQS", 13: "STR", 14: "SQE", 19: "GENERICTYPE", 21: "LABEL", 31: "acc_title", 32: "acc_title_value", 33: "acc_descr", 34: "acc_descr_value", 35: "acc_descr_multiline_value", 37: "STRUCT_START", 39: "STRUCT_STOP", 40: "NAMESPACE", 42: "STYLE_SEPARATOR", 44: "CLASS", 45: "ANNOTATION_START", 46: "ANNOTATION_END", 47: "MEMBER", 48: "SEPARATOR", 50: "NOTE_FOR", 52: "NOTE", 53: "direction_tb", 54: "direction_bt", 55: "direction_rl", 56: "direction_lr", 59: "AGGREGATION", 60: "EXTENSION", 61: "COMPOSITION", 62: "DEPENDENCY", 63: "LOLLIPOP", 64: "LINE", 65: "DOTTED_LINE", 66: "CALLBACK", 67: "LINK", 68: "LINK_TARGET", 69: "CLICK", 70: "CALLBACK_NAME", 71: "CALLBACK_ARGS", 72: "HREF", 73: "STYLE", 74: "ALPHA", 76: "CSSCLASS", 78: "COMMA", 80: "NUM", 81: "COLON", 82: "UNIT", 83: "SPACE", 84: "BRKT", 85: "PCT", 88: "graphCodeTokens", 90: "TAGSTART", 91: "TAGEND", 92: "==", 93: "--", 94: "DEFAULT", 95: "MINUS", 96: "keywords", 97: "UNICODE_TEXT", 98: "BQUOTE_STR" }, + productions_: [0, [3, 1], [3, 1], [4, 1], [6, 4], [5, 1], [5, 2], [5, 3], [11, 3], [15, 1], [15, 2], [17, 1], [17, 1], [17, 2], [17, 2], [17, 2], [10, 1], [10, 2], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [10, 1], [22, 4], [22, 5], [36, 2], [38, 1], [38, 2], [38, 3], [23, 1], [23, 3], [23, 4], [23, 6], [41, 2], [41, 3], [25, 4], [43, 1], [43, 2], [24, 1], [24, 2], [24, 1], [24, 1], [20, 3], [20, 4], [20, 4], [20, 5], [29, 3], [29, 2], [30, 1], [30, 1], [30, 1], [30, 1], [49, 3], [49, 2], [49, 2], [49, 1], [57, 1], [57, 1], [57, 1], [57, 1], [57, 1], [58, 1], [58, 1], [26, 3], [26, 4], [26, 3], [26, 4], [26, 4], [26, 5], [26, 3], [26, 4], [26, 4], [26, 5], [26, 4], [26, 5], [26, 5], [26, 6], [27, 3], [28, 3], [75, 1], [75, 3], [77, 1], [77, 2], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [79, 1], [86, 1], [86, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [87, 1], [89, 1], [89, 1], [89, 1], [89, 1], [16, 1], [16, 1], [16, 1], [16, 1], [18, 1], [51, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 8: + this.$ = $$[$0 - 1]; + break; + case 9: + case 11: + case 12: + this.$ = $$[$0]; + break; + case 10: + case 13: + this.$ = $$[$0 - 1] + $$[$0]; + break; + case 14: + case 15: + this.$ = $$[$0 - 1] + "~" + $$[$0] + "~"; + break; + case 16: + yy.addRelation($$[$0]); + break; + case 17: + $$[$0 - 1].title = yy.cleanupLabel($$[$0]); + yy.addRelation($$[$0 - 1]); + break; + case 27: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 28: + case 29: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 30: + yy.addClassesToNamespace($$[$0 - 3], $$[$0 - 1]); + break; + case 31: + yy.addClassesToNamespace($$[$0 - 4], $$[$0 - 1]); + break; + case 32: + this.$ = $$[$0]; + yy.addNamespace($$[$0]); + break; + case 33: + this.$ = [$$[$0]]; + break; + case 34: + this.$ = [$$[$0 - 1]]; + break; + case 35: + $$[$0].unshift($$[$0 - 2]); + this.$ = $$[$0]; + break; + case 37: + yy.setCssClass($$[$0 - 2], $$[$0]); + break; + case 38: + yy.addMembers($$[$0 - 3], $$[$0 - 1]); + break; + case 39: + yy.setCssClass($$[$0 - 5], $$[$0 - 3]); + yy.addMembers($$[$0 - 5], $$[$0 - 1]); + break; + case 40: + this.$ = $$[$0]; + yy.addClass($$[$0]); + break; + case 41: + this.$ = $$[$0 - 1]; + yy.addClass($$[$0 - 1]); + yy.setClassLabel($$[$0 - 1], $$[$0]); + break; + case 42: + yy.addAnnotation($$[$0], $$[$0 - 2]); + break; + case 43: + this.$ = [$$[$0]]; + break; + case 44: + $$[$0].push($$[$0 - 1]); + this.$ = $$[$0]; + break; + case 45: + break; + case 46: + yy.addMember($$[$0 - 1], yy.cleanupLabel($$[$0])); + break; + case 47: + break; + case 48: + break; + case 49: + this.$ = { "id1": $$[$0 - 2], "id2": $$[$0], relation: $$[$0 - 1], relationTitle1: "none", relationTitle2: "none" }; + break; + case 50: + this.$ = { id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 1], relationTitle1: $$[$0 - 2], relationTitle2: "none" }; + break; + case 51: + this.$ = { id1: $$[$0 - 3], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: "none", relationTitle2: $$[$0 - 1] }; + break; + case 52: + this.$ = { id1: $$[$0 - 4], id2: $$[$0], relation: $$[$0 - 2], relationTitle1: $$[$0 - 3], relationTitle2: $$[$0 - 1] }; + break; + case 53: + yy.addNote($$[$0], $$[$0 - 1]); + break; + case 54: + yy.addNote($$[$0]); + break; + case 55: + yy.setDirection("TB"); + break; + case 56: + yy.setDirection("BT"); + break; + case 57: + yy.setDirection("RL"); + break; + case 58: + yy.setDirection("LR"); + break; + case 59: + this.$ = { type1: $$[$0 - 2], type2: $$[$0], lineType: $$[$0 - 1] }; + break; + case 60: + this.$ = { type1: "none", type2: $$[$0], lineType: $$[$0 - 1] }; + break; + case 61: + this.$ = { type1: $$[$0 - 1], type2: "none", lineType: $$[$0] }; + break; + case 62: + this.$ = { type1: "none", type2: "none", lineType: $$[$0] }; + break; + case 63: + this.$ = yy.relationType.AGGREGATION; + break; + case 64: + this.$ = yy.relationType.EXTENSION; + break; + case 65: + this.$ = yy.relationType.COMPOSITION; + break; + case 66: + this.$ = yy.relationType.DEPENDENCY; + break; + case 67: + this.$ = yy.relationType.LOLLIPOP; + break; + case 68: + this.$ = yy.lineType.LINE; + break; + case 69: + this.$ = yy.lineType.DOTTED_LINE; + break; + case 70: + case 76: + this.$ = $$[$0 - 2]; + yy.setClickEvent($$[$0 - 1], $$[$0]); + break; + case 71: + case 77: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 2], $$[$0]); + break; + case 72: + this.$ = $$[$0 - 2]; + yy.setLink($$[$0 - 1], $$[$0]); + break; + case 73: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 74: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 2], $$[$0]); + break; + case 75: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 2], $$[$0]); + yy.setTooltip($$[$0 - 3], $$[$0 - 1]); + break; + case 78: + this.$ = $$[$0 - 3]; + yy.setClickEvent($$[$0 - 2], $$[$0 - 1], $$[$0]); + break; + case 79: + this.$ = $$[$0 - 4]; + yy.setClickEvent($$[$0 - 3], $$[$0 - 2], $$[$0 - 1]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 80: + this.$ = $$[$0 - 3]; + yy.setLink($$[$0 - 2], $$[$0]); + break; + case 81: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 1], $$[$0]); + break; + case 82: + this.$ = $$[$0 - 4]; + yy.setLink($$[$0 - 3], $$[$0 - 1]); + yy.setTooltip($$[$0 - 3], $$[$0]); + break; + case 83: + this.$ = $$[$0 - 5]; + yy.setLink($$[$0 - 4], $$[$0 - 2], $$[$0]); + yy.setTooltip($$[$0 - 4], $$[$0 - 1]); + break; + case 84: + this.$ = $$[$0 - 2]; + yy.setCssStyle($$[$0 - 1], $$[$0]); + break; + case 85: + yy.setCssClass($$[$0 - 1], $$[$0]); + break; + case 86: + this.$ = [$$[$0]]; + break; + case 87: + $$[$0 - 2].push($$[$0]); + this.$ = $$[$0 - 2]; + break; + case 89: + this.$ = $$[$0 - 1] + $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: 2, 5: 3, 6: 4, 7: [1, 6], 10: 5, 16: 37, 17: 20, 18: 38, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 31: $V0, 33: $V1, 35: $V2, 36: 21, 40: $V3, 41: 22, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 1: [3] }, { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3] }, o($Vo, [2, 5], { 8: [1, 46] }), { 8: [1, 47] }, o($Vp, [2, 16], { 21: [1, 48] }), o($Vp, [2, 18]), o($Vp, [2, 19]), o($Vp, [2, 20]), o($Vp, [2, 21]), o($Vp, [2, 22]), o($Vp, [2, 23]), o($Vp, [2, 24]), o($Vp, [2, 25]), o($Vp, [2, 26]), { 32: [1, 49] }, { 34: [1, 50] }, o($Vp, [2, 29]), o($Vp, [2, 45], { 49: 51, 57: 54, 58: 55, 13: [1, 52], 21: [1, 53], 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu, 64: $Vv, 65: $Vw }), { 37: [1, 63] }, o($Vx, [2, 36], { 37: [1, 65], 42: [1, 64] }), o($Vp, [2, 47]), o($Vp, [2, 48]), { 16: 66, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 16: 37, 17: 67, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 16: 37, 17: 68, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 16: 37, 17: 69, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 74: [1, 70] }, { 13: [1, 71] }, { 16: 37, 17: 72, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 13: $Vy, 51: 73 }, o($Vp, [2, 55]), o($Vp, [2, 56]), o($Vp, [2, 57]), o($Vp, [2, 58]), o($Vz, [2, 11], { 16: 37, 18: 38, 17: 75, 19: [1, 76], 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }), o($Vz, [2, 12], { 19: [1, 77] }), { 15: 78, 16: 79, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 16: 37, 17: 80, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VA, [2, 112]), o($VA, [2, 113]), o($VA, [2, 114]), o($VA, [2, 115]), o([1, 8, 9, 12, 13, 19, 21, 37, 39, 42, 59, 60, 61, 62, 63, 64, 65, 70, 72], [2, 116]), o($Vo, [2, 6], { 10: 5, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 17: 20, 36: 21, 41: 22, 16: 37, 18: 38, 5: 81, 31: $V0, 33: $V1, 35: $V2, 40: $V3, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }), { 5: 82, 10: 5, 16: 37, 17: 20, 18: 38, 20: 7, 22: 8, 23: 9, 24: 10, 25: 11, 26: 12, 27: 13, 28: 14, 29: 15, 30: 16, 31: $V0, 33: $V1, 35: $V2, 36: 21, 40: $V3, 41: 22, 44: $V4, 45: $V5, 47: $V6, 48: $V7, 50: $V8, 52: $V9, 53: $Va, 54: $Vb, 55: $Vc, 56: $Vd, 66: $Ve, 67: $Vf, 69: $Vg, 73: $Vh, 74: $Vi, 76: $Vj, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($Vp, [2, 17]), o($Vp, [2, 27]), o($Vp, [2, 28]), { 13: [1, 84], 16: 37, 17: 83, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 49: 85, 57: 54, 58: 55, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu, 64: $Vv, 65: $Vw }, o($Vp, [2, 46]), { 58: 86, 64: $Vv, 65: $Vw }, o($VB, [2, 62], { 57: 87, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu }), o($VC, [2, 63]), o($VC, [2, 64]), o($VC, [2, 65]), o($VC, [2, 66]), o($VC, [2, 67]), o($VD, [2, 68]), o($VD, [2, 69]), { 8: [1, 89], 23: 90, 38: 88, 41: 22, 44: $V4 }, { 16: 91, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, { 43: 92, 47: $VE }, { 46: [1, 94] }, { 13: [1, 95] }, { 13: [1, 96] }, { 70: [1, 97], 72: [1, 98] }, { 21: $VF, 73: $VG, 74: $VH, 75: 99, 77: 100, 79: 101, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }, { 74: [1, 111] }, { 13: $Vy, 51: 112 }, o($Vp, [2, 54]), o($Vp, [2, 117]), o($Vz, [2, 13]), o($Vz, [2, 14]), o($Vz, [2, 15]), { 37: [2, 32] }, { 15: 113, 16: 79, 37: [2, 9], 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm }, o($VO, [2, 40], { 11: 114, 12: [1, 115] }), o($Vo, [2, 7]), { 9: [1, 116] }, o($VP, [2, 49]), { 16: 37, 17: 117, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, { 13: [1, 119], 16: 37, 17: 118, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VB, [2, 61], { 57: 120, 59: $Vq, 60: $Vr, 61: $Vs, 62: $Vt, 63: $Vu }), o($VB, [2, 60]), { 39: [1, 121] }, { 23: 90, 38: 122, 41: 22, 44: $V4 }, { 8: [1, 123], 39: [2, 33] }, o($Vx, [2, 37], { 37: [1, 124] }), { 39: [1, 125] }, { 39: [2, 43], 43: 126, 47: $VE }, { 16: 37, 17: 127, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($Vp, [2, 70], { 13: [1, 128] }), o($Vp, [2, 72], { 13: [1, 130], 68: [1, 129] }), o($Vp, [2, 76], { 13: [1, 131], 71: [1, 132] }), { 13: [1, 133] }, o($Vp, [2, 84], { 78: [1, 134] }), o($VQ, [2, 86], { 79: 135, 21: $VF, 73: $VG, 74: $VH, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }), o($VR, [2, 88]), o($VR, [2, 90]), o($VR, [2, 91]), o($VR, [2, 92]), o($VR, [2, 93]), o($VR, [2, 94]), o($VR, [2, 95]), o($VR, [2, 96]), o($VR, [2, 97]), o($VR, [2, 98]), o($Vp, [2, 85]), o($Vp, [2, 53]), { 37: [2, 10] }, o($VO, [2, 41]), { 13: [1, 136] }, { 1: [2, 4] }, o($VP, [2, 51]), o($VP, [2, 50]), { 16: 37, 17: 137, 18: 38, 74: $Vi, 80: $Vk, 95: $Vl, 97: $Vm, 98: $Vn }, o($VB, [2, 59]), o($Vp, [2, 30]), { 39: [1, 138] }, { 23: 90, 38: 139, 39: [2, 34], 41: 22, 44: $V4 }, { 43: 140, 47: $VE }, o($Vx, [2, 38]), { 39: [2, 44] }, o($Vp, [2, 42]), o($Vp, [2, 71]), o($Vp, [2, 73]), o($Vp, [2, 74], { 68: [1, 141] }), o($Vp, [2, 77]), o($Vp, [2, 78], { 13: [1, 142] }), o($Vp, [2, 80], { 13: [1, 144], 68: [1, 143] }), { 21: $VF, 73: $VG, 74: $VH, 77: 145, 79: 101, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }, o($VR, [2, 89]), { 14: [1, 146] }, o($VP, [2, 52]), o($Vp, [2, 31]), { 39: [2, 35] }, { 39: [1, 147] }, o($Vp, [2, 75]), o($Vp, [2, 79]), o($Vp, [2, 81]), o($Vp, [2, 82], { 68: [1, 148] }), o($VQ, [2, 87], { 79: 135, 21: $VF, 73: $VG, 74: $VH, 80: $VI, 81: $VJ, 82: $VK, 83: $VL, 84: $VM, 85: $VN }), o($VO, [2, 8]), o($Vx, [2, 39]), o($Vp, [2, 83])], + defaultActions: { 2: [2, 1], 3: [2, 2], 4: [2, 3], 78: [2, 32], 113: [2, 10], 116: [2, 4], 126: [2, 44], 139: [2, 35] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: {}, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + return 53; + case 1: + return 54; + case 2: + return 55; + case 3: + return 56; + case 4: + break; + case 5: + break; + case 6: + this.begin("acc_title"); + return 31; + case 7: + this.popState(); + return "acc_title_value"; + case 8: + this.begin("acc_descr"); + return 33; + case 9: + this.popState(); + return "acc_descr_value"; + case 10: + this.begin("acc_descr_multiline"); + break; + case 11: + this.popState(); + break; + case 12: + return "acc_descr_multiline_value"; + case 13: + return 8; + case 14: + break; + case 15: + return 7; + case 16: + return 7; + case 17: + return "EDGE_STATE"; + case 18: + this.begin("callback_name"); + break; + case 19: + this.popState(); + break; + case 20: + this.popState(); + this.begin("callback_args"); + break; + case 21: + return 70; + case 22: + this.popState(); + break; + case 23: + return 71; + case 24: + this.popState(); + break; + case 25: + return "STR"; + case 26: + this.begin("string"); + break; + case 27: + return 73; + case 28: + this.begin("namespace"); + return 40; + case 29: + this.popState(); + return 8; + case 30: + break; + case 31: + this.begin("namespace-body"); + return 37; + case 32: + this.popState(); + return 39; + case 33: + return "EOF_IN_STRUCT"; + case 34: + return 8; + case 35: + break; + case 36: + return "EDGE_STATE"; + case 37: + this.begin("class"); + return 44; + case 38: + this.popState(); + return 8; + case 39: + break; + case 40: + this.popState(); + this.popState(); + return 39; + case 41: + this.begin("class-body"); + return 37; + case 42: + this.popState(); + return 39; + case 43: + return "EOF_IN_STRUCT"; + case 44: + return "EDGE_STATE"; + case 45: + return "OPEN_IN_STRUCT"; + case 46: + break; + case 47: + return "MEMBER"; + case 48: + return 76; + case 49: + return 66; + case 50: + return 67; + case 51: + return 69; + case 52: + return 50; + case 53: + return 52; + case 54: + return 45; + case 55: + return 46; + case 56: + return 72; + case 57: + this.popState(); + break; + case 58: + return "GENERICTYPE"; + case 59: + this.begin("generic"); + break; + case 60: + this.popState(); + break; + case 61: + return "BQUOTE_STR"; + case 62: + this.begin("bqstring"); + break; + case 63: + return 68; + case 64: + return 68; + case 65: + return 68; + case 66: + return 68; + case 67: + return 60; + case 68: + return 60; + case 69: + return 62; + case 70: + return 62; + case 71: + return 61; + case 72: + return 59; + case 73: + return 63; + case 74: + return 64; + case 75: + return 65; + case 76: + return 21; + case 77: + return 42; + case 78: + return 95; + case 79: + return "DOT"; + case 80: + return "PLUS"; + case 81: + return 81; + case 82: + return 78; + case 83: + return 84; + case 84: + return 84; + case 85: + return 85; + case 86: + return "EQUALS"; + case 87: + return "EQUALS"; + case 88: + return 74; + case 89: + return 12; + case 90: + return 14; + case 91: + return "PUNCTUATION"; + case 92: + return 80; + case 93: + return 97; + case 94: + return 83; + case 95: + return 83; + case 96: + return 9; + } + }, + rules: [/^(?:.*direction\s+TB[^\n]*)/, /^(?:.*direction\s+BT[^\n]*)/, /^(?:.*direction\s+RL[^\n]*)/, /^(?:.*direction\s+LR[^\n]*)/, /^(?:%%(?!\{)*[^\n]*(\r?\n?)+)/, /^(?:%%[^\n]*(\r?\n)*)/, /^(?:accTitle\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*:\s*)/, /^(?:(?!\n||)*[^\n]*)/, /^(?:accDescr\s*\{\s*)/, /^(?:[\}])/, /^(?:[^\}]*)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:classDiagram-v2\b)/, /^(?:classDiagram\b)/, /^(?:\[\*\])/, /^(?:call[\s]+)/, /^(?:\([\s]*\))/, /^(?:\()/, /^(?:[^(]*)/, /^(?:\))/, /^(?:[^)]*)/, /^(?:["])/, /^(?:[^"]*)/, /^(?:["])/, /^(?:style\b)/, /^(?:namespace\b)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:[{])/, /^(?:[}])/, /^(?:$)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:\[\*\])/, /^(?:class\b)/, /^(?:\s*(\r?\n)+)/, /^(?:\s+)/, /^(?:[}])/, /^(?:[{])/, /^(?:[}])/, /^(?:$)/, /^(?:\[\*\])/, /^(?:[{])/, /^(?:[\n])/, /^(?:[^{}\n]*)/, /^(?:cssClass\b)/, /^(?:callback\b)/, /^(?:link\b)/, /^(?:click\b)/, /^(?:note for\b)/, /^(?:note\b)/, /^(?:<<)/, /^(?:>>)/, /^(?:href\b)/, /^(?:[~])/, /^(?:[^~]*)/, /^(?:~)/, /^(?:[`])/, /^(?:[^`]+)/, /^(?:[`])/, /^(?:_self\b)/, /^(?:_blank\b)/, /^(?:_parent\b)/, /^(?:_top\b)/, /^(?:\s*<\|)/, /^(?:\s*\|>)/, /^(?:\s*>)/, /^(?:\s*<)/, /^(?:\s*\*)/, /^(?:\s*o\b)/, /^(?:\s*\(\))/, /^(?:--)/, /^(?:\.\.)/, /^(?::{1}[^:\n;]+)/, /^(?::{3})/, /^(?:-)/, /^(?:\.)/, /^(?:\+)/, /^(?::)/, /^(?:,)/, /^(?:#)/, /^(?:#)/, /^(?:%)/, /^(?:=)/, /^(?:=)/, /^(?:\w+)/, /^(?:\[)/, /^(?:\])/, /^(?:[!"#$%&'*+,-.`?\\/])/, /^(?:[0-9]+)/, /^(?:[\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC])/, /^(?:\s)/, /^(?:\s)/, /^(?:$)/], + conditions: { "namespace-body": { "rules": [26, 32, 33, 34, 35, 36, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "namespace": { "rules": [26, 28, 29, 30, 31, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "class-body": { "rules": [26, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "class": { "rules": [26, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_descr_multiline": { "rules": [11, 12, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_descr": { "rules": [9, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "acc_title": { "rules": [7, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "callback_args": { "rules": [22, 23, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "callback_name": { "rules": [19, 20, 21, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "href": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "struct": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "generic": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "bqstring": { "rules": [26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "string": { "rules": [24, 25, 26, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 96], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 14, 15, 16, 17, 18, 26, 27, 28, 37, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +const visibilityValues = ["#", "+", "~", "-", ""]; +class ClassMember { + constructor(input, memberType) { + this.memberType = memberType; + this.visibility = ""; + this.classifier = ""; + const sanitizedInput = sanitizeText$2(input, getConfig()); + this.parseMember(sanitizedInput); + } + getDisplayDetails() { + let displayText = this.visibility + parseGenericTypes(this.id); + if (this.memberType === "method") { + displayText += `(${parseGenericTypes(this.parameters.trim())})`; + if (this.returnType) { + displayText += " : " + parseGenericTypes(this.returnType); + } + } + displayText = displayText.trim(); + const cssStyle = this.parseClassifier(); + return { + displayText, + cssStyle + }; + } + parseMember(input) { + let potentialClassifier = ""; + if (this.memberType === "method") { + const methodRegEx = /([#+~-])?(.+)\((.*)\)([\s$*])?(.*)([$*])?/; + const match = input.match(methodRegEx); + if (match) { + const detectedVisibility = match[1] ? match[1].trim() : ""; + if (visibilityValues.includes(detectedVisibility)) { + this.visibility = detectedVisibility; + } + this.id = match[2].trim(); + this.parameters = match[3] ? match[3].trim() : ""; + potentialClassifier = match[4] ? match[4].trim() : ""; + this.returnType = match[5] ? match[5].trim() : ""; + if (potentialClassifier === "") { + const lastChar = this.returnType.substring(this.returnType.length - 1); + if (lastChar.match(/[$*]/)) { + potentialClassifier = lastChar; + this.returnType = this.returnType.substring(0, this.returnType.length - 1); + } + } + } + } else { + const length = input.length; + const firstChar = input.substring(0, 1); + const lastChar = input.substring(length - 1); + if (visibilityValues.includes(firstChar)) { + this.visibility = firstChar; + } + if (lastChar.match(/[$*]/)) { + potentialClassifier = lastChar; + } + this.id = input.substring( + this.visibility === "" ? 0 : 1, + potentialClassifier === "" ? length : length - 1 + ); + } + this.classifier = potentialClassifier; + } + parseClassifier() { + switch (this.classifier) { + case "*": + return "font-style:italic;"; + case "$": + return "text-decoration:underline;"; + default: + return ""; + } + } +} +const MERMAID_DOM_ID_PREFIX = "classId-"; +let relations = []; +let classes = {}; +let notes = []; +let classCounter = 0; +let namespaces = {}; +let namespaceCounter = 0; +let functions = []; +const sanitizeText = (txt) => common$1.sanitizeText(txt, getConfig()); +const splitClassNameAndType = function(_id) { + const id = common$1.sanitizeText(_id, getConfig()); + let genericType = ""; + let className = id; + if (id.indexOf("~") > 0) { + const split = id.split("~"); + className = sanitizeText(split[0]); + genericType = sanitizeText(split[1]); + } + return { className, type: genericType }; +}; +const setClassLabel = function(_id, label) { + const id = common$1.sanitizeText(_id, getConfig()); + if (label) { + label = sanitizeText(label); + } + const { className } = splitClassNameAndType(id); + classes[className].label = label; +}; +const addClass = function(_id) { + const id = common$1.sanitizeText(_id, getConfig()); + const { className, type } = splitClassNameAndType(id); + if (Object.hasOwn(classes, className)) { + return; + } + const name = common$1.sanitizeText(className, getConfig()); + classes[name] = { + id: name, + type, + label: name, + cssClasses: [], + methods: [], + members: [], + annotations: [], + styles: [], + domId: MERMAID_DOM_ID_PREFIX + name + "-" + classCounter + }; + classCounter++; +}; +const lookUpDomId = function(_id) { + const id = common$1.sanitizeText(_id, getConfig()); + if (id in classes) { + return classes[id].domId; + } + throw new Error("Class not found: " + id); +}; +const clear = function() { + relations = []; + classes = {}; + notes = []; + functions = []; + functions.push(setupToolTips); + namespaces = {}; + namespaceCounter = 0; + clear$1(); +}; +const getClass = function(id) { + return classes[id]; +}; +const getClasses = function() { + return classes; +}; +const getRelations = function() { + return relations; +}; +const getNotes = function() { + return notes; +}; +const addRelation = function(relation) { + log$1.debug("Adding relation: " + JSON.stringify(relation)); + addClass(relation.id1); + addClass(relation.id2); + relation.id1 = splitClassNameAndType(relation.id1).className; + relation.id2 = splitClassNameAndType(relation.id2).className; + relation.relationTitle1 = common$1.sanitizeText(relation.relationTitle1.trim(), getConfig()); + relation.relationTitle2 = common$1.sanitizeText(relation.relationTitle2.trim(), getConfig()); + relations.push(relation); +}; +const addAnnotation = function(className, annotation) { + const validatedClassName = splitClassNameAndType(className).className; + classes[validatedClassName].annotations.push(annotation); +}; +const addMember = function(className, member) { + addClass(className); + const validatedClassName = splitClassNameAndType(className).className; + const theClass = classes[validatedClassName]; + if (typeof member === "string") { + const memberString = member.trim(); + if (memberString.startsWith("<<") && memberString.endsWith(">>")) { + theClass.annotations.push(sanitizeText(memberString.substring(2, memberString.length - 2))); + } else if (memberString.indexOf(")") > 0) { + theClass.methods.push(new ClassMember(memberString, "method")); + } else if (memberString) { + theClass.members.push(new ClassMember(memberString, "attribute")); + } + } +}; +const addMembers = function(className, members) { + if (Array.isArray(members)) { + members.reverse(); + members.forEach((member) => addMember(className, member)); + } +}; +const addNote = function(text, className) { + const note = { + id: `note${notes.length}`, + class: className, + text + }; + notes.push(note); +}; +const cleanupLabel = function(label) { + if (label.startsWith(":")) { + label = label.substring(1); + } + return sanitizeText(label.trim()); +}; +const setCssClass = function(ids, className) { + ids.split(",").forEach(function(_id) { + let id = _id; + if (_id[0].match(/\d/)) { + id = MERMAID_DOM_ID_PREFIX + id; + } + if (classes[id] !== void 0) { + classes[id].cssClasses.push(className); + } + }); +}; +const setTooltip = function(ids, tooltip) { + ids.split(",").forEach(function(id) { + if (tooltip !== void 0) { + classes[id].tooltip = sanitizeText(tooltip); + } + }); +}; +const getTooltip = function(id, namespace) { + if (namespace) { + return namespaces[namespace].classes[id].tooltip; + } + return classes[id].tooltip; +}; +const setLink = function(ids, linkStr, target) { + const config = getConfig(); + ids.split(",").forEach(function(_id) { + let id = _id; + if (_id[0].match(/\d/)) { + id = MERMAID_DOM_ID_PREFIX + id; + } + if (classes[id] !== void 0) { + classes[id].link = utils.formatUrl(linkStr, config); + if (config.securityLevel === "sandbox") { + classes[id].linkTarget = "_top"; + } else if (typeof target === "string") { + classes[id].linkTarget = sanitizeText(target); + } else { + classes[id].linkTarget = "_blank"; + } + } + }); + setCssClass(ids, "clickable"); +}; +const setClickEvent = function(ids, functionName, functionArgs) { + ids.split(",").forEach(function(id) { + setClickFunc(id, functionName, functionArgs); + classes[id].haveCallback = true; + }); + setCssClass(ids, "clickable"); +}; +const setClickFunc = function(_domId, functionName, functionArgs) { + const domId = common$1.sanitizeText(_domId, getConfig()); + const config = getConfig(); + if (config.securityLevel !== "loose") { + return; + } + if (functionName === void 0) { + return; + } + const id = domId; + if (classes[id] !== void 0) { + const elemId = lookUpDomId(id); + let argList = []; + if (typeof functionArgs === "string") { + argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/); + for (let i = 0; i < argList.length; i++) { + let item = argList[i].trim(); + if (item.charAt(0) === '"' && item.charAt(item.length - 1) === '"') { + item = item.substr(1, item.length - 2); + } + argList[i] = item; + } + } + if (argList.length === 0) { + argList.push(elemId); + } + functions.push(function() { + const elem = document.querySelector(`[id="${elemId}"]`); + if (elem !== null) { + elem.addEventListener( + "click", + function() { + utils.runFunc(functionName, ...argList); + }, + false + ); + } + }); + } +}; +const bindFunctions = function(element) { + functions.forEach(function(fun) { + fun(element); + }); +}; +const lineType = { + LINE: 0, + DOTTED_LINE: 1 +}; +const relationType = { + AGGREGATION: 0, + EXTENSION: 1, + COMPOSITION: 2, + DEPENDENCY: 3, + LOLLIPOP: 4 +}; +const setupToolTips = function(element) { + let tooltipElem = select(".mermaidTooltip"); + if ((tooltipElem._groups || tooltipElem)[0][0] === null) { + tooltipElem = select("body").append("div").attr("class", "mermaidTooltip").style("opacity", 0); + } + const svg = select(element).select("svg"); + const nodes = svg.selectAll("g.node"); + nodes.on("mouseover", function() { + const el = select(this); + const title = el.attr("title"); + if (title === null) { + return; + } + const rect = this.getBoundingClientRect(); + tooltipElem.transition().duration(200).style("opacity", ".9"); + tooltipElem.text(el.attr("title")).style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.top - 14 + document.body.scrollTop + "px"); + tooltipElem.html(tooltipElem.html().replace(/<br\/>/g, "
    ")); + el.classed("hover", true); + }).on("mouseout", function() { + tooltipElem.transition().duration(500).style("opacity", 0); + const el = select(this); + el.classed("hover", false); + }); +}; +functions.push(setupToolTips); +let direction = "TB"; +const getDirection = () => direction; +const setDirection = (dir) => { + direction = dir; +}; +const addNamespace = function(id) { + if (namespaces[id] !== void 0) { + return; + } + namespaces[id] = { + id, + classes: {}, + children: {}, + domId: MERMAID_DOM_ID_PREFIX + id + "-" + namespaceCounter + }; + namespaceCounter++; +}; +const getNamespace = function(name) { + return namespaces[name]; +}; +const getNamespaces = function() { + return namespaces; +}; +const addClassesToNamespace = function(id, classNames) { + if (namespaces[id] === void 0) { + return; + } + for (const name of classNames) { + const { className } = splitClassNameAndType(name); + classes[className].parent = id; + namespaces[id].classes[className] = classes[className]; + } +}; +const setCssStyle = function(id, styles2) { + const thisClass = classes[id]; + if (!styles2 || !thisClass) { + return; + } + for (const s of styles2) { + if (s.includes(",")) { + thisClass.styles.push(...s.split(",")); + } else { + thisClass.styles.push(s); + } + } +}; +const db = { + setAccTitle, + getAccTitle, + getAccDescription, + setAccDescription, + getConfig: () => getConfig().class, + addClass, + bindFunctions, + clear, + getClass, + getClasses, + getNotes, + addAnnotation, + addNote, + getRelations, + addRelation, + getDirection, + setDirection, + addMember, + addMembers, + cleanupLabel, + lineType, + relationType, + setClickEvent, + setCssClass, + setLink, + getTooltip, + setTooltip, + lookUpDomId, + setDiagramTitle, + getDiagramTitle, + setClassLabel, + addNamespace, + addClassesToNamespace, + getNamespace, + getNamespaces, + setCssStyle +}; +const getStyles = (options) => `g.classGroup text { + fill: ${options.nodeBorder || options.classText}; + stroke: none; + font-family: ${options.fontFamily}; + font-size: 10px; + + .title { + font-weight: bolder; + } + +} + +.nodeLabel, .edgeLabel { + color: ${options.classText}; +} +.edgeLabel .label rect { + fill: ${options.mainBkg}; +} +.label text { + fill: ${options.classText}; +} +.edgeLabel .label span { + background: ${options.mainBkg}; +} + +.classTitle { + font-weight: bolder; +} +.node rect, + .node circle, + .node ellipse, + .node polygon, + .node path { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; + stroke-width: 1px; + } + + +.divider { + stroke: ${options.nodeBorder}; + stroke-width: 1; +} + +g.clickable { + cursor: pointer; +} + +g.classGroup rect { + fill: ${options.mainBkg}; + stroke: ${options.nodeBorder}; +} + +g.classGroup line { + stroke: ${options.nodeBorder}; + stroke-width: 1; +} + +.classLabel .box { + stroke: none; + stroke-width: 0; + fill: ${options.mainBkg}; + opacity: 0.5; +} + +.classLabel .label { + fill: ${options.nodeBorder}; + font-size: 10px; +} + +.relation { + stroke: ${options.lineColor}; + stroke-width: 1; + fill: none; +} + +.dashed-line{ + stroke-dasharray: 3; +} + +.dotted-line{ + stroke-dasharray: 1 2; +} + +#compositionStart, .composition { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#compositionEnd, .composition { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#dependencyStart, .dependency { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#dependencyStart, .dependency { + fill: ${options.lineColor} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#extensionStart, .extension { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#extensionEnd, .extension { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#aggregationStart, .aggregation { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#aggregationEnd, .aggregation { + fill: transparent !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#lollipopStart, .lollipop { + fill: ${options.mainBkg} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +#lollipopEnd, .lollipop { + fill: ${options.mainBkg} !important; + stroke: ${options.lineColor} !important; + stroke-width: 1; +} + +.edgeTerminals { + font-size: 11px; + line-height: initial; +} + +.classTitleText { + text-anchor: middle; + font-size: 18px; + fill: ${options.textColor}; +} +`; +const styles = getStyles; + +export { db as d, parser$1 as p, styles as s }; diff --git a/libs/marked/svgDrawCommon-5e1cfd1d-BKN147IX.js b/libs/marked/svgDrawCommon-5e1cfd1d-BKN147IX.js new file mode 100644 index 0000000..cd19719 --- /dev/null +++ b/libs/marked/svgDrawCommon-5e1cfd1d-BKN147IX.js @@ -0,0 +1,94 @@ +import { ap as lineBreakRegex, m as dist } from './index-CN3YjQ0n.js'; + +const drawRect = (element, rectData) => { + const rectElement = element.append("rect"); + rectElement.attr("x", rectData.x); + rectElement.attr("y", rectData.y); + rectElement.attr("fill", rectData.fill); + rectElement.attr("stroke", rectData.stroke); + rectElement.attr("width", rectData.width); + rectElement.attr("height", rectData.height); + if (rectData.name) { + rectElement.attr("name", rectData.name); + } + rectData.rx !== void 0 && rectElement.attr("rx", rectData.rx); + rectData.ry !== void 0 && rectElement.attr("ry", rectData.ry); + if (rectData.attrs !== void 0) { + for (const attrKey in rectData.attrs) { + rectElement.attr(attrKey, rectData.attrs[attrKey]); + } + } + rectData.class !== void 0 && rectElement.attr("class", rectData.class); + return rectElement; +}; +const drawBackgroundRect = (element, bounds) => { + const rectData = { + x: bounds.startx, + y: bounds.starty, + width: bounds.stopx - bounds.startx, + height: bounds.stopy - bounds.starty, + fill: bounds.fill, + stroke: bounds.stroke, + class: "rect" + }; + const rectElement = drawRect(element, rectData); + rectElement.lower(); +}; +const drawText = (element, textData) => { + const nText = textData.text.replace(lineBreakRegex, " "); + const textElem = element.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.attr("class", "legend"); + textElem.style("text-anchor", textData.anchor); + textData.class !== void 0 && textElem.attr("class", textData.class); + const tspan = textElem.append("tspan"); + tspan.attr("x", textData.x + textData.textMargin * 2); + tspan.text(nText); + return textElem; +}; +const drawImage = (elem, x, y, link) => { + const imageElement = elem.append("image"); + imageElement.attr("x", x); + imageElement.attr("y", y); + const sanitizedLink = dist.sanitizeUrl(link); + imageElement.attr("xlink:href", sanitizedLink); +}; +const drawEmbeddedImage = (element, x, y, link) => { + const imageElement = element.append("use"); + imageElement.attr("x", x); + imageElement.attr("y", y); + const sanitizedLink = dist.sanitizeUrl(link); + imageElement.attr("xlink:href", `#${sanitizedLink}`); +}; +const getNoteRect = () => { + const noteRectData = { + x: 0, + y: 0, + width: 100, + height: 100, + fill: "#EDF2AE", + stroke: "#666", + anchor: "start", + rx: 0, + ry: 0 + }; + return noteRectData; +}; +const getTextObj = () => { + const testObject = { + x: 0, + y: 0, + width: 100, + height: 100, + "text-anchor": "start", + style: "#666", + textMargin: 0, + rx: 0, + ry: 0, + tspan: true + }; + return testObject; +}; + +export { drawBackgroundRect as a, getTextObj as b, drawEmbeddedImage as c, drawRect as d, drawImage as e, drawText as f, getNoteRect as g }; diff --git a/libs/marked/svgDrawCommon-5e1cfd1d-CHZPGcFQ.js b/libs/marked/svgDrawCommon-5e1cfd1d-CHZPGcFQ.js new file mode 100644 index 0000000..3f47c6b --- /dev/null +++ b/libs/marked/svgDrawCommon-5e1cfd1d-CHZPGcFQ.js @@ -0,0 +1,94 @@ +import { ap as lineBreakRegex, m as dist } from './index-Bd_FDXSq.js'; + +const drawRect = (element, rectData) => { + const rectElement = element.append("rect"); + rectElement.attr("x", rectData.x); + rectElement.attr("y", rectData.y); + rectElement.attr("fill", rectData.fill); + rectElement.attr("stroke", rectData.stroke); + rectElement.attr("width", rectData.width); + rectElement.attr("height", rectData.height); + if (rectData.name) { + rectElement.attr("name", rectData.name); + } + rectData.rx !== void 0 && rectElement.attr("rx", rectData.rx); + rectData.ry !== void 0 && rectElement.attr("ry", rectData.ry); + if (rectData.attrs !== void 0) { + for (const attrKey in rectData.attrs) { + rectElement.attr(attrKey, rectData.attrs[attrKey]); + } + } + rectData.class !== void 0 && rectElement.attr("class", rectData.class); + return rectElement; +}; +const drawBackgroundRect = (element, bounds) => { + const rectData = { + x: bounds.startx, + y: bounds.starty, + width: bounds.stopx - bounds.startx, + height: bounds.stopy - bounds.starty, + fill: bounds.fill, + stroke: bounds.stroke, + class: "rect" + }; + const rectElement = drawRect(element, rectData); + rectElement.lower(); +}; +const drawText = (element, textData) => { + const nText = textData.text.replace(lineBreakRegex, " "); + const textElem = element.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.attr("class", "legend"); + textElem.style("text-anchor", textData.anchor); + textData.class !== void 0 && textElem.attr("class", textData.class); + const tspan = textElem.append("tspan"); + tspan.attr("x", textData.x + textData.textMargin * 2); + tspan.text(nText); + return textElem; +}; +const drawImage = (elem, x, y, link) => { + const imageElement = elem.append("image"); + imageElement.attr("x", x); + imageElement.attr("y", y); + const sanitizedLink = dist.sanitizeUrl(link); + imageElement.attr("xlink:href", sanitizedLink); +}; +const drawEmbeddedImage = (element, x, y, link) => { + const imageElement = element.append("use"); + imageElement.attr("x", x); + imageElement.attr("y", y); + const sanitizedLink = dist.sanitizeUrl(link); + imageElement.attr("xlink:href", `#${sanitizedLink}`); +}; +const getNoteRect = () => { + const noteRectData = { + x: 0, + y: 0, + width: 100, + height: 100, + fill: "#EDF2AE", + stroke: "#666", + anchor: "start", + rx: 0, + ry: 0 + }; + return noteRectData; +}; +const getTextObj = () => { + const testObject = { + x: 0, + y: 0, + width: 100, + height: 100, + "text-anchor": "start", + style: "#666", + textMargin: 0, + rx: 0, + ry: 0, + tspan: true + }; + return testObject; +}; + +export { drawBackgroundRect as a, getTextObj as b, drawEmbeddedImage as c, drawRect as d, drawImage as e, drawText as f, getNoteRect as g }; diff --git a/libs/marked/timeline-definition-bf702344-CKi_og6o.js b/libs/marked/timeline-definition-bf702344-CKi_og6o.js new file mode 100644 index 0000000..b6e4875 --- /dev/null +++ b/libs/marked/timeline-definition-bf702344-CKi_og6o.js @@ -0,0 +1,1211 @@ +import { ar as commonDb, E as clear$1, c as getConfig, l as log$1, h as select, t as setupGraphViewbox$1, as as isDark, at as lighten, au as darken } from './index-CN3YjQ0n.js'; +import { a as arc } from './arc-CNdYl1O_.js'; +import './path-BZ3S9nBE.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 11, 12, 14, 16, 17, 20, 21], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12], $V5 = [1, 13], $V6 = [1, 16], $V7 = [1, 17]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "timeline": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "title": 11, "acc_title": 12, "acc_title_value": 13, "acc_descr": 14, "acc_descr_value": 15, "acc_descr_multiline_value": 16, "section": 17, "period_statement": 18, "event_statement": 19, "period": 20, "event": 21, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "timeline", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 20: "period", 21: "event" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 1], [18, 1], [19, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.getCommonDb().setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 9: + this.$ = $$[$0].trim(); + yy.getCommonDb().setAccTitle(this.$); + break; + case 10: + case 11: + this.$ = $$[$0].trim(); + yy.getCommonDb().setAccDescription(this.$); + break; + case 12: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 15: + yy.addTask($$[$0], 0, ""); + this.$ = $$[$0]; + break; + case 16: + yy.addEvent($$[$0].substr(2)); + this.$ = $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: 14, 19: 15, 20: $V6, 21: $V7 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 18, 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: 14, 19: 15, 20: $V6, 21: $V7 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), { 13: [1, 19] }, { 15: [1, 20] }, o($V0, [2, 11]), o($V0, [2, 12]), o($V0, [2, 13]), o($V0, [2, 14]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 4]), o($V0, [2, 9]), o($V0, [2, 10])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 10; + case 3: + break; + case 4: + break; + case 5: + return 4; + case 6: + return 11; + case 7: + this.begin("acc_title"); + return 12; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 14; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 17; + case 15: + return 21; + case 16: + return 20; + case 17: + return 6; + case 18: + return "INVALID"; + } + }, + rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:timeline\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?::\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let currentSection = ""; +let currentTaskId = 0; +const sections = []; +const tasks = []; +const rawTasks = []; +const getCommonDb = () => commonDb; +const clear = function() { + sections.length = 0; + tasks.length = 0; + currentSection = ""; + rawTasks.length = 0; + clear$1(); +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 100; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks.push(...rawTasks); + return tasks; +}; +const addTask = function(period, length, event) { + const rawTask = { + id: currentTaskId++, + section: currentSection, + type: currentSection, + task: period, + score: length ? length : 0, + //if event is defined, then add it the events array + events: event ? [event] : [] + }; + rawTasks.push(rawTask); +}; +const addEvent = function(event) { + const currentTask = rawTasks.find((task) => task.id === currentTaskId - 1); + currentTask.events.push(event); +}; +const addTaskOrg = function(descr) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const timelineDb = { + clear, + getCommonDb, + addSection, + getSections, + getTasks, + addTask, + addTaskOrg, + addEvent +}; +const db = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + addEvent, + addSection, + addTask, + addTaskOrg, + clear, + default: timelineDb, + getCommonDb, + getSections, + getTasks +}, Symbol.toStringTag, { value: "Module" })); +const MAX_SECTIONS = 12; +const drawRect = function(elem, rectData) { + const rectElem = elem.append("rect"); + rectElem.attr("x", rectData.x); + rectElem.attr("y", rectData.y); + rectElem.attr("fill", rectData.fill); + rectElem.attr("stroke", rectData.stroke); + rectElem.attr("width", rectData.width); + rectElem.attr("height", rectData.height); + rectElem.attr("rx", rectData.rx); + rectElem.attr("ry", rectData.ry); + if (rectData.class !== void 0) { + rectElem.attr("class", rectData.class); + } + return rectElem; +}; +const drawFace = function(element, faceData) { + const radius = 15; + const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible"); + const face = element.append("g"); + face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + function smile(face2) { + const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")"); + } + function sad(face2) { + const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")"); + } + function ambivalent(face2) { + face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666"); + } + if (faceData.score > 3) { + smile(face); + } else if (faceData.score < 3) { + sad(face); + } else { + ambivalent(face); + } + return circleElement; +}; +const drawCircle = function(element, circleData) { + const circleElement = element.append("circle"); + circleElement.attr("cx", circleData.cx); + circleElement.attr("cy", circleData.cy); + circleElement.attr("class", "actor-" + circleData.pos); + circleElement.attr("fill", circleData.fill); + circleElement.attr("stroke", circleData.stroke); + circleElement.attr("r", circleData.r); + if (circleElement.class !== void 0) { + circleElement.attr("class", circleElement.class); + } + if (circleData.title !== void 0) { + circleElement.append("title").text(circleData.title); + } + return circleElement; +}; +const drawText = function(elem, textData) { + const nText = textData.text.replace(//gi, " "); + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.attr("class", "legend"); + textElem.style("text-anchor", textData.anchor); + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + const span = textElem.append("tspan"); + span.attr("x", textData.x + textData.textMargin * 2); + span.text(nText); + return textElem; +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.labelMargin; + txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin; + drawText(elem, txtObject); +}; +const drawSection = function(elem, section, conf) { + const g = elem.append("g"); + const rect = getNoteRect(); + rect.x = section.x; + rect.y = section.y; + rect.fill = section.fill; + rect.width = conf.width; + rect.height = conf.height; + rect.class = "journey-section section-type-" + section.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + _drawTextCandidateFunc(conf)( + section.text, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "journey-section section-type-" + section.num }, + conf, + section.colour + ); +}; +let taskCount = -1; +const drawTask = function(elem, task, conf) { + const center = task.x + conf.width / 2; + const g = elem.append("g"); + taskCount++; + const maxHeight = 300 + 5 * 30; + g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"); + drawFace(g, { + cx: center, + cy: 300 + (5 - task.score) * 30, + score: task.score + }); + const rect = getNoteRect(); + rect.x = task.x; + rect.y = task.y; + rect.fill = task.fill; + rect.width = conf.width; + rect.height = conf.height; + rect.class = "task task-type-" + task.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + task.x + 14; + _drawTextCandidateFunc(conf)( + task.task, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "task" }, + conf, + task.colour + ); +}; +const drawBackgroundRect = function(elem, bounds) { + const rectElem = drawRect(elem, { + x: bounds.startx, + y: bounds.starty, + width: bounds.stopx - bounds.startx, + height: bounds.stopy - bounds.starty, + fill: bounds.fill, + class: "rect" + }); + rectElem.lower(); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + "text-anchor": "start", + width: 100, + height: 100, + textMargin: 0, + rx: 0, + ry: 0 + }; +}; +const getNoteRect = function() { + return { + x: 0, + y: 0, + width: 100, + anchor: "start", + height: 100, + rx: 0, + ry: 0 + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs, colour) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) { + const { taskFontSize, taskFontFamily } = conf; + const lines = content.split(//gi); + for (let i = 0; i < lines.length; i++) { + const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf) { + const body = g.append("switch"); + const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed"); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, body, x, y, width, height, textAttrs, conf); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (key in fromTextAttrsDict) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf) { + return conf.textPlacement === "fo" ? byFo : conf.textPlacement === "old" ? byText : byTspan; + }; +}(); +const initGraphics = function(graphics) { + graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z"); +}; +function wrap(text, width) { + text.each(function() { + var text2 = select(this), words = text2.text().split(/(\s+|
    )/).reverse(), word, line = [], lineHeight = 1.1, y = text2.attr("y"), dy = parseFloat(text2.attr("dy")), tspan = text2.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", dy + "em"); + for (let j = 0; j < words.length; j++) { + word = words[words.length - 1 - j]; + line.push(word); + tspan.text(line.join(" ").trim()); + if (tspan.node().getComputedTextLength() > width || word === "
    ") { + line.pop(); + tspan.text(line.join(" ").trim()); + if (word === "
    ") { + line = [""]; + } else { + line = [word]; + } + tspan = text2.append("tspan").attr("x", 0).attr("y", y).attr("dy", lineHeight + "em").text(word); + } + } + }); +} +const drawNode = function(elem, node, fullSection, conf) { + const section = fullSection % MAX_SECTIONS - 1; + const nodeElem = elem.append("g"); + node.section = section; + nodeElem.attr( + "class", + (node.class ? node.class + " " : "") + "timeline-node " + ("section-" + section) + ); + const bkgElem = nodeElem.append("g"); + const textElem = nodeElem.append("g"); + const txt = textElem.append("text").text(node.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(wrap, node.width); + const bbox = txt.node().getBBox(); + const fontSize = conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; + node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; + node.height = Math.max(node.height, node.maxHeight); + node.width = node.width + 2 * node.padding; + textElem.attr("transform", "translate(" + node.width / 2 + ", " + node.padding / 2 + ")"); + defaultBkg(bkgElem, node, section); + return node; +}; +const getVirtualNodeHeight = function(elem, node, conf) { + const textElem = elem.append("g"); + const txt = textElem.append("text").text(node.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(wrap, node.width); + const bbox = txt.node().getBBox(); + const fontSize = conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; + textElem.remove(); + return bbox.height + fontSize * 1.1 * 0.5 + node.padding; +}; +const defaultBkg = function(elem, node, section) { + const rd = 5; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + node.type).attr( + "d", + `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` + ); + elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); +}; +const svgDraw = { + drawRect, + drawCircle, + drawSection, + drawText, + drawLabel, + drawTask, + drawBackgroundRect, + getTextObj, + getNoteRect, + initGraphics, + drawNode, + getVirtualNodeHeight +}; +const draw = function(text, id, version, diagObj) { + var _a, _b; + const conf = getConfig(); + const LEFT_MARGIN = conf.leftMargin ?? 50; + log$1.debug("timeline", diagObj.db); + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select("#" + id); + svg.append("g"); + const tasks2 = diagObj.db.getTasks(); + const title = diagObj.db.getCommonDb().getDiagramTitle(); + log$1.debug("task", tasks2); + svgDraw.initGraphics(svg); + const sections2 = diagObj.db.getSections(); + log$1.debug("sections", sections2); + let maxSectionHeight = 0; + let maxTaskHeight = 0; + let depthY = 0; + let sectionBeginY = 0; + let masterX = 50 + LEFT_MARGIN; + let masterY = 50; + sectionBeginY = 50; + let sectionNumber = 0; + let hasSections = true; + sections2.forEach(function(section) { + const sectionNode = { + number: sectionNumber, + descr: section, + section: sectionNumber, + width: 150, + padding: 20, + maxHeight: maxSectionHeight + }; + const sectionHeight = svgDraw.getVirtualNodeHeight(svg, sectionNode, conf); + log$1.debug("sectionHeight before draw", sectionHeight); + maxSectionHeight = Math.max(maxSectionHeight, sectionHeight + 20); + }); + let maxEventCount = 0; + let maxEventLineLength = 0; + log$1.debug("tasks.length", tasks2.length); + for (const [i, task] of tasks2.entries()) { + const taskNode = { + number: i, + descr: task, + section: task.section, + width: 150, + padding: 20, + maxHeight: maxTaskHeight + }; + const taskHeight = svgDraw.getVirtualNodeHeight(svg, taskNode, conf); + log$1.debug("taskHeight before draw", taskHeight); + maxTaskHeight = Math.max(maxTaskHeight, taskHeight + 20); + maxEventCount = Math.max(maxEventCount, task.events.length); + let maxEventLineLengthTemp = 0; + for (let j = 0; j < task.events.length; j++) { + const event = task.events[j]; + const eventNode = { + descr: event, + section: task.section, + number: task.section, + width: 150, + padding: 20, + maxHeight: 50 + }; + maxEventLineLengthTemp += svgDraw.getVirtualNodeHeight(svg, eventNode, conf); + } + maxEventLineLength = Math.max(maxEventLineLength, maxEventLineLengthTemp); + } + log$1.debug("maxSectionHeight before draw", maxSectionHeight); + log$1.debug("maxTaskHeight before draw", maxTaskHeight); + if (sections2 && sections2.length > 0) { + sections2.forEach((section) => { + const tasksForSection = tasks2.filter((task) => task.section === section); + const sectionNode = { + number: sectionNumber, + descr: section, + section: sectionNumber, + width: 200 * Math.max(tasksForSection.length, 1) - 50, + padding: 20, + maxHeight: maxSectionHeight + }; + log$1.debug("sectionNode", sectionNode); + const sectionNodeWrapper = svg.append("g"); + const node = svgDraw.drawNode(sectionNodeWrapper, sectionNode, sectionNumber, conf); + log$1.debug("sectionNode output", node); + sectionNodeWrapper.attr("transform", `translate(${masterX}, ${sectionBeginY})`); + masterY += maxSectionHeight + 50; + if (tasksForSection.length > 0) { + drawTasks( + svg, + tasksForSection, + sectionNumber, + masterX, + masterY, + maxTaskHeight, + conf, + maxEventCount, + maxEventLineLength, + maxSectionHeight, + false + ); + } + masterX += 200 * Math.max(tasksForSection.length, 1); + masterY = sectionBeginY; + sectionNumber++; + }); + } else { + hasSections = false; + drawTasks( + svg, + tasks2, + sectionNumber, + masterX, + masterY, + maxTaskHeight, + conf, + maxEventCount, + maxEventLineLength, + maxSectionHeight, + true + ); + } + const box = svg.node().getBBox(); + log$1.debug("bounds", box); + if (title) { + svg.append("text").text(title).attr("x", box.width / 2 - LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20); + } + depthY = hasSections ? maxSectionHeight + maxTaskHeight + 150 : maxTaskHeight + 100; + const lineWrapper = svg.append("g").attr("class", "lineWrapper"); + lineWrapper.append("line").attr("x1", LEFT_MARGIN).attr("y1", depthY).attr("x2", box.width + 3 * LEFT_MARGIN).attr("y2", depthY).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"); + setupGraphViewbox$1( + void 0, + svg, + ((_a = conf.timeline) == null ? void 0 : _a.padding) ?? 50, + ((_b = conf.timeline) == null ? void 0 : _b.useMaxWidth) ?? false + ); +}; +const drawTasks = function(diagram2, tasks2, sectionColor, masterX, masterY, maxTaskHeight, conf, maxEventCount, maxEventLineLength, maxSectionHeight, isWithoutSections) { + var _a; + for (const task of tasks2) { + const taskNode = { + descr: task.task, + section: sectionColor, + number: sectionColor, + width: 150, + padding: 20, + maxHeight: maxTaskHeight + }; + log$1.debug("taskNode", taskNode); + const taskWrapper = diagram2.append("g").attr("class", "taskWrapper"); + const node = svgDraw.drawNode(taskWrapper, taskNode, sectionColor, conf); + const taskHeight = node.height; + log$1.debug("taskHeight after draw", taskHeight); + taskWrapper.attr("transform", `translate(${masterX}, ${masterY})`); + maxTaskHeight = Math.max(maxTaskHeight, taskHeight); + if (task.events) { + const lineWrapper = diagram2.append("g").attr("class", "lineWrapper"); + let lineLength = maxTaskHeight; + masterY += 100; + lineLength = lineLength + drawEvents(diagram2, task.events, sectionColor, masterX, masterY, conf); + masterY -= 100; + lineWrapper.append("line").attr("x1", masterX + 190 / 2).attr("y1", masterY + maxTaskHeight).attr("x2", masterX + 190 / 2).attr( + "y2", + masterY + maxTaskHeight + (isWithoutSections ? maxTaskHeight : maxSectionHeight) + maxEventLineLength + 120 + ).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", "url(#arrowhead)").attr("stroke-dasharray", "5,5"); + } + masterX = masterX + 200; + if (isWithoutSections && !((_a = conf.timeline) == null ? void 0 : _a.disableMulticolor)) { + sectionColor++; + } + } + masterY = masterY - 10; +}; +const drawEvents = function(diagram2, events, sectionColor, masterX, masterY, conf) { + let maxEventHeight = 0; + const eventBeginY = masterY; + masterY = masterY + 100; + for (const event of events) { + const eventNode = { + descr: event, + section: sectionColor, + number: sectionColor, + width: 150, + padding: 20, + maxHeight: 50 + }; + log$1.debug("eventNode", eventNode); + const eventWrapper = diagram2.append("g").attr("class", "eventWrapper"); + const node = svgDraw.drawNode(eventWrapper, eventNode, sectionColor, conf); + const eventHeight = node.height; + maxEventHeight = maxEventHeight + eventHeight; + eventWrapper.attr("transform", `translate(${masterX}, ${masterY})`); + masterY = masterY + 10 + eventHeight; + } + masterY = eventBeginY; + return maxEventHeight; +}; +const renderer = { + setConf: () => { + }, + draw +}; +const genSections = (options) => { + let sections2 = ""; + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i]; + if (isDark(options["lineColor" + i])) { + options["lineColor" + i] = lighten(options["lineColor" + i], 20); + } else { + options["lineColor" + i] = darken(options["lineColor" + i], 20); + } + } + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + const sw = "" + (17 - 3 * i); + sections2 += ` + .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} path { + fill: ${options["cScale" + i]}; + } + .section-${i - 1} text { + fill: ${options["cScaleLabel" + i]}; + } + .node-icon-${i - 1} { + font-size: 40px; + color: ${options["cScaleLabel" + i]}; + } + .section-edge-${i - 1}{ + stroke: ${options["cScale" + i]}; + } + .edge-depth-${i - 1}{ + stroke-width: ${sw}; + } + .section-${i - 1} line { + stroke: ${options["cScaleInv" + i]} ; + stroke-width: 3; + } + + .lineWrapper line{ + stroke: ${options["cScaleLabel" + i]} ; + } + + .disabled, .disabled circle, .disabled text { + fill: lightgray; + } + .disabled text { + fill: #efefef; + } + `; + } + return sections2; +}; +const getStyles = (options) => ` + .edge { + stroke-width: 3; + } + ${genSections(options)} + .section-root rect, .section-root path, .section-root circle { + fill: ${options.git0}; + } + .section-root text { + fill: ${options.gitBranchLabel0}; + } + .icon-container { + height:100%; + display: flex; + justify-content: center; + align-items: center; + } + .edge { + fill: none; + } + .eventWrapper { + filter: brightness(120%); + } +`; +const styles = getStyles; +const diagram = { + db, + renderer, + parser: parser$1, + styles +}; + +export { diagram }; diff --git a/libs/marked/timeline-definition-bf702344-DseYwjcq.js b/libs/marked/timeline-definition-bf702344-DseYwjcq.js new file mode 100644 index 0000000..ca4b57d --- /dev/null +++ b/libs/marked/timeline-definition-bf702344-DseYwjcq.js @@ -0,0 +1,1211 @@ +import { ar as commonDb, E as clear$1, c as getConfig, l as log$1, h as select, t as setupGraphViewbox$1, as as isDark, at as lighten, au as darken } from './index-Bd_FDXSq.js'; +import { a as arc } from './arc-DhQC9rXN.js'; +import './path-BZ3S9nBE.js'; + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [6, 8, 10, 11, 12, 14, 16, 17, 20, 21], $V1 = [1, 9], $V2 = [1, 10], $V3 = [1, 11], $V4 = [1, 12], $V5 = [1, 13], $V6 = [1, 16], $V7 = [1, 17]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "timeline": 4, "document": 5, "EOF": 6, "line": 7, "SPACE": 8, "statement": 9, "NEWLINE": 10, "title": 11, "acc_title": 12, "acc_title_value": 13, "acc_descr": 14, "acc_descr_value": 15, "acc_descr_multiline_value": 16, "section": 17, "period_statement": 18, "event_statement": 19, "period": 20, "event": 21, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 4: "timeline", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 20: "period", 21: "event" }, + productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 1], [18, 1], [19, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 1: + return $$[$0 - 1]; + case 2: + this.$ = []; + break; + case 3: + $$[$0 - 1].push($$[$0]); + this.$ = $$[$0 - 1]; + break; + case 4: + case 5: + this.$ = $$[$0]; + break; + case 6: + case 7: + this.$ = []; + break; + case 8: + yy.getCommonDb().setDiagramTitle($$[$0].substr(6)); + this.$ = $$[$0].substr(6); + break; + case 9: + this.$ = $$[$0].trim(); + yy.getCommonDb().setAccTitle(this.$); + break; + case 10: + case 11: + this.$ = $$[$0].trim(); + yy.getCommonDb().setAccDescription(this.$); + break; + case 12: + yy.addSection($$[$0].substr(8)); + this.$ = $$[$0].substr(8); + break; + case 15: + yy.addTask($$[$0], 0, ""); + this.$ = $$[$0]; + break; + case 16: + yy.addEvent($$[$0].substr(2)); + this.$ = $$[$0]; + break; + } + }, + table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, o($V0, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: 14, 19: 15, 20: $V6, 21: $V7 }, o($V0, [2, 7], { 1: [2, 1] }), o($V0, [2, 3]), { 9: 18, 11: $V1, 12: $V2, 14: $V3, 16: $V4, 17: $V5, 18: 14, 19: 15, 20: $V6, 21: $V7 }, o($V0, [2, 5]), o($V0, [2, 6]), o($V0, [2, 8]), { 13: [1, 19] }, { 15: [1, 20] }, o($V0, [2, 11]), o($V0, [2, 12]), o($V0, [2, 13]), o($V0, [2, 14]), o($V0, [2, 15]), o($V0, [2, 16]), o($V0, [2, 4]), o($V0, [2, 9]), o($V0, [2, 10])], + defaultActions: {}, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + return 10; + case 3: + break; + case 4: + break; + case 5: + return 4; + case 6: + return 11; + case 7: + this.begin("acc_title"); + return 12; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.begin("acc_descr"); + return 14; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.begin("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 17; + case 15: + return 21; + case 16: + return 20; + case 17: + return 6; + case 18: + return "INVALID"; + } + }, + rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:timeline\b)/i, /^(?:title\s[^#\n;]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^#:\n;]+)/i, /^(?::\s[^#:\n;]+)/i, /^(?:[^#:\n;]+)/i, /^(?:$)/i, /^(?:.)/i], + conditions: { "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +let currentSection = ""; +let currentTaskId = 0; +const sections = []; +const tasks = []; +const rawTasks = []; +const getCommonDb = () => commonDb; +const clear = function() { + sections.length = 0; + tasks.length = 0; + currentSection = ""; + rawTasks.length = 0; + clear$1(); +}; +const addSection = function(txt) { + currentSection = txt; + sections.push(txt); +}; +const getSections = function() { + return sections; +}; +const getTasks = function() { + let allItemsProcessed = compileTasks(); + const maxDepth = 100; + let iterationCount = 0; + while (!allItemsProcessed && iterationCount < maxDepth) { + allItemsProcessed = compileTasks(); + iterationCount++; + } + tasks.push(...rawTasks); + return tasks; +}; +const addTask = function(period, length, event) { + const rawTask = { + id: currentTaskId++, + section: currentSection, + type: currentSection, + task: period, + score: length ? length : 0, + //if event is defined, then add it the events array + events: event ? [event] : [] + }; + rawTasks.push(rawTask); +}; +const addEvent = function(event) { + const currentTask = rawTasks.find((task) => task.id === currentTaskId - 1); + currentTask.events.push(event); +}; +const addTaskOrg = function(descr) { + const newTask = { + section: currentSection, + type: currentSection, + description: descr, + task: descr, + classes: [] + }; + tasks.push(newTask); +}; +const compileTasks = function() { + const compileTask = function(pos) { + return rawTasks[pos].processed; + }; + let allProcessed = true; + for (const [i, rawTask] of rawTasks.entries()) { + compileTask(i); + allProcessed = allProcessed && rawTask.processed; + } + return allProcessed; +}; +const timelineDb = { + clear, + getCommonDb, + addSection, + getSections, + getTasks, + addTask, + addTaskOrg, + addEvent +}; +const db = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + addEvent, + addSection, + addTask, + addTaskOrg, + clear, + default: timelineDb, + getCommonDb, + getSections, + getTasks +}, Symbol.toStringTag, { value: "Module" })); +const MAX_SECTIONS = 12; +const drawRect = function(elem, rectData) { + const rectElem = elem.append("rect"); + rectElem.attr("x", rectData.x); + rectElem.attr("y", rectData.y); + rectElem.attr("fill", rectData.fill); + rectElem.attr("stroke", rectData.stroke); + rectElem.attr("width", rectData.width); + rectElem.attr("height", rectData.height); + rectElem.attr("rx", rectData.rx); + rectElem.attr("ry", rectData.ry); + if (rectData.class !== void 0) { + rectElem.attr("class", rectData.class); + } + return rectElem; +}; +const drawFace = function(element, faceData) { + const radius = 15; + const circleElement = element.append("circle").attr("cx", faceData.cx).attr("cy", faceData.cy).attr("class", "face").attr("r", radius).attr("stroke-width", 2).attr("overflow", "visible"); + const face = element.append("g"); + face.append("circle").attr("cx", faceData.cx - radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + face.append("circle").attr("cx", faceData.cx + radius / 3).attr("cy", faceData.cy - radius / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"); + function smile(face2) { + const arc$1 = arc().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 2) + ")"); + } + function sad(face2) { + const arc$1 = arc().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); + face2.append("path").attr("class", "mouth").attr("d", arc$1).attr("transform", "translate(" + faceData.cx + "," + (faceData.cy + 7) + ")"); + } + function ambivalent(face2) { + face2.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", faceData.cx - 5).attr("y1", faceData.cy + 7).attr("x2", faceData.cx + 5).attr("y2", faceData.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666"); + } + if (faceData.score > 3) { + smile(face); + } else if (faceData.score < 3) { + sad(face); + } else { + ambivalent(face); + } + return circleElement; +}; +const drawCircle = function(element, circleData) { + const circleElement = element.append("circle"); + circleElement.attr("cx", circleData.cx); + circleElement.attr("cy", circleData.cy); + circleElement.attr("class", "actor-" + circleData.pos); + circleElement.attr("fill", circleData.fill); + circleElement.attr("stroke", circleData.stroke); + circleElement.attr("r", circleData.r); + if (circleElement.class !== void 0) { + circleElement.attr("class", circleElement.class); + } + if (circleData.title !== void 0) { + circleElement.append("title").text(circleData.title); + } + return circleElement; +}; +const drawText = function(elem, textData) { + const nText = textData.text.replace(//gi, " "); + const textElem = elem.append("text"); + textElem.attr("x", textData.x); + textElem.attr("y", textData.y); + textElem.attr("class", "legend"); + textElem.style("text-anchor", textData.anchor); + if (textData.class !== void 0) { + textElem.attr("class", textData.class); + } + const span = textElem.append("tspan"); + span.attr("x", textData.x + textData.textMargin * 2); + span.text(nText); + return textElem; +}; +const drawLabel = function(elem, txtObject) { + function genPoints(x, y, width, height, cut) { + return x + "," + y + " " + (x + width) + "," + y + " " + (x + width) + "," + (y + height - cut) + " " + (x + width - cut * 1.2) + "," + (y + height) + " " + x + "," + (y + height); + } + const polygon = elem.append("polygon"); + polygon.attr("points", genPoints(txtObject.x, txtObject.y, 50, 20, 7)); + polygon.attr("class", "labelBox"); + txtObject.y = txtObject.y + txtObject.labelMargin; + txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin; + drawText(elem, txtObject); +}; +const drawSection = function(elem, section, conf) { + const g = elem.append("g"); + const rect = getNoteRect(); + rect.x = section.x; + rect.y = section.y; + rect.fill = section.fill; + rect.width = conf.width; + rect.height = conf.height; + rect.class = "journey-section section-type-" + section.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + _drawTextCandidateFunc(conf)( + section.text, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "journey-section section-type-" + section.num }, + conf, + section.colour + ); +}; +let taskCount = -1; +const drawTask = function(elem, task, conf) { + const center = task.x + conf.width / 2; + const g = elem.append("g"); + taskCount++; + const maxHeight = 300 + 5 * 30; + g.append("line").attr("id", "task" + taskCount).attr("x1", center).attr("y1", task.y).attr("x2", center).attr("y2", maxHeight).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"); + drawFace(g, { + cx: center, + cy: 300 + (5 - task.score) * 30, + score: task.score + }); + const rect = getNoteRect(); + rect.x = task.x; + rect.y = task.y; + rect.fill = task.fill; + rect.width = conf.width; + rect.height = conf.height; + rect.class = "task task-type-" + task.num; + rect.rx = 3; + rect.ry = 3; + drawRect(g, rect); + task.x + 14; + _drawTextCandidateFunc(conf)( + task.task, + g, + rect.x, + rect.y, + rect.width, + rect.height, + { class: "task" }, + conf, + task.colour + ); +}; +const drawBackgroundRect = function(elem, bounds) { + const rectElem = drawRect(elem, { + x: bounds.startx, + y: bounds.starty, + width: bounds.stopx - bounds.startx, + height: bounds.stopy - bounds.starty, + fill: bounds.fill, + class: "rect" + }); + rectElem.lower(); +}; +const getTextObj = function() { + return { + x: 0, + y: 0, + fill: void 0, + "text-anchor": "start", + width: 100, + height: 100, + textMargin: 0, + rx: 0, + ry: 0 + }; +}; +const getNoteRect = function() { + return { + x: 0, + y: 0, + width: 100, + anchor: "start", + height: 100, + rx: 0, + ry: 0 + }; +}; +const _drawTextCandidateFunc = function() { + function byText(content, g, x, y, width, height, textAttrs, colour) { + const text = g.append("text").attr("x", x + width / 2).attr("y", y + height / 2 + 5).style("font-color", colour).style("text-anchor", "middle").text(content); + _setTextAttrs(text, textAttrs); + } + function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) { + const { taskFontSize, taskFontFamily } = conf; + const lines = content.split(//gi); + for (let i = 0; i < lines.length; i++) { + const dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2; + const text = g.append("text").attr("x", x + width / 2).attr("y", y).attr("fill", colour).style("text-anchor", "middle").style("font-size", taskFontSize).style("font-family", taskFontFamily); + text.append("tspan").attr("x", x + width / 2).attr("dy", dy).text(lines[i]); + text.attr("y", y + height / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"); + _setTextAttrs(text, textAttrs); + } + } + function byFo(content, g, x, y, width, height, textAttrs, conf) { + const body = g.append("switch"); + const f = body.append("foreignObject").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("position", "fixed"); + const text = f.append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%"); + text.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(content); + byTspan(content, body, x, y, width, height, textAttrs, conf); + _setTextAttrs(text, textAttrs); + } + function _setTextAttrs(toText, fromTextAttrsDict) { + for (const key in fromTextAttrsDict) { + if (key in fromTextAttrsDict) { + toText.attr(key, fromTextAttrsDict[key]); + } + } + } + return function(conf) { + return conf.textPlacement === "fo" ? byFo : conf.textPlacement === "old" ? byText : byTspan; + }; +}(); +const initGraphics = function(graphics) { + graphics.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z"); +}; +function wrap(text, width) { + text.each(function() { + var text2 = select(this), words = text2.text().split(/(\s+|
    )/).reverse(), word, line = [], lineHeight = 1.1, y = text2.attr("y"), dy = parseFloat(text2.attr("dy")), tspan = text2.text(null).append("tspan").attr("x", 0).attr("y", y).attr("dy", dy + "em"); + for (let j = 0; j < words.length; j++) { + word = words[words.length - 1 - j]; + line.push(word); + tspan.text(line.join(" ").trim()); + if (tspan.node().getComputedTextLength() > width || word === "
    ") { + line.pop(); + tspan.text(line.join(" ").trim()); + if (word === "
    ") { + line = [""]; + } else { + line = [word]; + } + tspan = text2.append("tspan").attr("x", 0).attr("y", y).attr("dy", lineHeight + "em").text(word); + } + } + }); +} +const drawNode = function(elem, node, fullSection, conf) { + const section = fullSection % MAX_SECTIONS - 1; + const nodeElem = elem.append("g"); + node.section = section; + nodeElem.attr( + "class", + (node.class ? node.class + " " : "") + "timeline-node " + ("section-" + section) + ); + const bkgElem = nodeElem.append("g"); + const textElem = nodeElem.append("g"); + const txt = textElem.append("text").text(node.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(wrap, node.width); + const bbox = txt.node().getBBox(); + const fontSize = conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; + node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding; + node.height = Math.max(node.height, node.maxHeight); + node.width = node.width + 2 * node.padding; + textElem.attr("transform", "translate(" + node.width / 2 + ", " + node.padding / 2 + ")"); + defaultBkg(bkgElem, node, section); + return node; +}; +const getVirtualNodeHeight = function(elem, node, conf) { + const textElem = elem.append("g"); + const txt = textElem.append("text").text(node.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(wrap, node.width); + const bbox = txt.node().getBBox(); + const fontSize = conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize; + textElem.remove(); + return bbox.height + fontSize * 1.1 * 0.5 + node.padding; +}; +const defaultBkg = function(elem, node, section) { + const rd = 5; + elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + node.type).attr( + "d", + `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z` + ); + elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height); +}; +const svgDraw = { + drawRect, + drawCircle, + drawSection, + drawText, + drawLabel, + drawTask, + drawBackgroundRect, + getTextObj, + getNoteRect, + initGraphics, + drawNode, + getVirtualNodeHeight +}; +const draw = function(text, id, version, diagObj) { + var _a, _b; + const conf = getConfig(); + const LEFT_MARGIN = conf.leftMargin ?? 50; + log$1.debug("timeline", diagObj.db); + const securityLevel = conf.securityLevel; + let sandboxElement; + if (securityLevel === "sandbox") { + sandboxElement = select("#i" + id); + } + const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body"); + const svg = root.select("#" + id); + svg.append("g"); + const tasks2 = diagObj.db.getTasks(); + const title = diagObj.db.getCommonDb().getDiagramTitle(); + log$1.debug("task", tasks2); + svgDraw.initGraphics(svg); + const sections2 = diagObj.db.getSections(); + log$1.debug("sections", sections2); + let maxSectionHeight = 0; + let maxTaskHeight = 0; + let depthY = 0; + let sectionBeginY = 0; + let masterX = 50 + LEFT_MARGIN; + let masterY = 50; + sectionBeginY = 50; + let sectionNumber = 0; + let hasSections = true; + sections2.forEach(function(section) { + const sectionNode = { + number: sectionNumber, + descr: section, + section: sectionNumber, + width: 150, + padding: 20, + maxHeight: maxSectionHeight + }; + const sectionHeight = svgDraw.getVirtualNodeHeight(svg, sectionNode, conf); + log$1.debug("sectionHeight before draw", sectionHeight); + maxSectionHeight = Math.max(maxSectionHeight, sectionHeight + 20); + }); + let maxEventCount = 0; + let maxEventLineLength = 0; + log$1.debug("tasks.length", tasks2.length); + for (const [i, task] of tasks2.entries()) { + const taskNode = { + number: i, + descr: task, + section: task.section, + width: 150, + padding: 20, + maxHeight: maxTaskHeight + }; + const taskHeight = svgDraw.getVirtualNodeHeight(svg, taskNode, conf); + log$1.debug("taskHeight before draw", taskHeight); + maxTaskHeight = Math.max(maxTaskHeight, taskHeight + 20); + maxEventCount = Math.max(maxEventCount, task.events.length); + let maxEventLineLengthTemp = 0; + for (let j = 0; j < task.events.length; j++) { + const event = task.events[j]; + const eventNode = { + descr: event, + section: task.section, + number: task.section, + width: 150, + padding: 20, + maxHeight: 50 + }; + maxEventLineLengthTemp += svgDraw.getVirtualNodeHeight(svg, eventNode, conf); + } + maxEventLineLength = Math.max(maxEventLineLength, maxEventLineLengthTemp); + } + log$1.debug("maxSectionHeight before draw", maxSectionHeight); + log$1.debug("maxTaskHeight before draw", maxTaskHeight); + if (sections2 && sections2.length > 0) { + sections2.forEach((section) => { + const tasksForSection = tasks2.filter((task) => task.section === section); + const sectionNode = { + number: sectionNumber, + descr: section, + section: sectionNumber, + width: 200 * Math.max(tasksForSection.length, 1) - 50, + padding: 20, + maxHeight: maxSectionHeight + }; + log$1.debug("sectionNode", sectionNode); + const sectionNodeWrapper = svg.append("g"); + const node = svgDraw.drawNode(sectionNodeWrapper, sectionNode, sectionNumber, conf); + log$1.debug("sectionNode output", node); + sectionNodeWrapper.attr("transform", `translate(${masterX}, ${sectionBeginY})`); + masterY += maxSectionHeight + 50; + if (tasksForSection.length > 0) { + drawTasks( + svg, + tasksForSection, + sectionNumber, + masterX, + masterY, + maxTaskHeight, + conf, + maxEventCount, + maxEventLineLength, + maxSectionHeight, + false + ); + } + masterX += 200 * Math.max(tasksForSection.length, 1); + masterY = sectionBeginY; + sectionNumber++; + }); + } else { + hasSections = false; + drawTasks( + svg, + tasks2, + sectionNumber, + masterX, + masterY, + maxTaskHeight, + conf, + maxEventCount, + maxEventLineLength, + maxSectionHeight, + true + ); + } + const box = svg.node().getBBox(); + log$1.debug("bounds", box); + if (title) { + svg.append("text").text(title).attr("x", box.width / 2 - LEFT_MARGIN).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20); + } + depthY = hasSections ? maxSectionHeight + maxTaskHeight + 150 : maxTaskHeight + 100; + const lineWrapper = svg.append("g").attr("class", "lineWrapper"); + lineWrapper.append("line").attr("x1", LEFT_MARGIN).attr("y1", depthY).attr("x2", box.width + 3 * LEFT_MARGIN).attr("y2", depthY).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"); + setupGraphViewbox$1( + void 0, + svg, + ((_a = conf.timeline) == null ? void 0 : _a.padding) ?? 50, + ((_b = conf.timeline) == null ? void 0 : _b.useMaxWidth) ?? false + ); +}; +const drawTasks = function(diagram2, tasks2, sectionColor, masterX, masterY, maxTaskHeight, conf, maxEventCount, maxEventLineLength, maxSectionHeight, isWithoutSections) { + var _a; + for (const task of tasks2) { + const taskNode = { + descr: task.task, + section: sectionColor, + number: sectionColor, + width: 150, + padding: 20, + maxHeight: maxTaskHeight + }; + log$1.debug("taskNode", taskNode); + const taskWrapper = diagram2.append("g").attr("class", "taskWrapper"); + const node = svgDraw.drawNode(taskWrapper, taskNode, sectionColor, conf); + const taskHeight = node.height; + log$1.debug("taskHeight after draw", taskHeight); + taskWrapper.attr("transform", `translate(${masterX}, ${masterY})`); + maxTaskHeight = Math.max(maxTaskHeight, taskHeight); + if (task.events) { + const lineWrapper = diagram2.append("g").attr("class", "lineWrapper"); + let lineLength = maxTaskHeight; + masterY += 100; + lineLength = lineLength + drawEvents(diagram2, task.events, sectionColor, masterX, masterY, conf); + masterY -= 100; + lineWrapper.append("line").attr("x1", masterX + 190 / 2).attr("y1", masterY + maxTaskHeight).attr("x2", masterX + 190 / 2).attr( + "y2", + masterY + maxTaskHeight + (isWithoutSections ? maxTaskHeight : maxSectionHeight) + maxEventLineLength + 120 + ).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", "url(#arrowhead)").attr("stroke-dasharray", "5,5"); + } + masterX = masterX + 200; + if (isWithoutSections && !((_a = conf.timeline) == null ? void 0 : _a.disableMulticolor)) { + sectionColor++; + } + } + masterY = masterY - 10; +}; +const drawEvents = function(diagram2, events, sectionColor, masterX, masterY, conf) { + let maxEventHeight = 0; + const eventBeginY = masterY; + masterY = masterY + 100; + for (const event of events) { + const eventNode = { + descr: event, + section: sectionColor, + number: sectionColor, + width: 150, + padding: 20, + maxHeight: 50 + }; + log$1.debug("eventNode", eventNode); + const eventWrapper = diagram2.append("g").attr("class", "eventWrapper"); + const node = svgDraw.drawNode(eventWrapper, eventNode, sectionColor, conf); + const eventHeight = node.height; + maxEventHeight = maxEventHeight + eventHeight; + eventWrapper.attr("transform", `translate(${masterX}, ${masterY})`); + masterY = masterY + 10 + eventHeight; + } + masterY = eventBeginY; + return maxEventHeight; +}; +const renderer = { + setConf: () => { + }, + draw +}; +const genSections = (options) => { + let sections2 = ""; + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i]; + if (isDark(options["lineColor" + i])) { + options["lineColor" + i] = lighten(options["lineColor" + i], 20); + } else { + options["lineColor" + i] = darken(options["lineColor" + i], 20); + } + } + for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) { + const sw = "" + (17 - 3 * i); + sections2 += ` + .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} path { + fill: ${options["cScale" + i]}; + } + .section-${i - 1} text { + fill: ${options["cScaleLabel" + i]}; + } + .node-icon-${i - 1} { + font-size: 40px; + color: ${options["cScaleLabel" + i]}; + } + .section-edge-${i - 1}{ + stroke: ${options["cScale" + i]}; + } + .edge-depth-${i - 1}{ + stroke-width: ${sw}; + } + .section-${i - 1} line { + stroke: ${options["cScaleInv" + i]} ; + stroke-width: 3; + } + + .lineWrapper line{ + stroke: ${options["cScaleLabel" + i]} ; + } + + .disabled, .disabled circle, .disabled text { + fill: lightgray; + } + .disabled text { + fill: #efefef; + } + `; + } + return sections2; +}; +const getStyles = (options) => ` + .edge { + stroke-width: 3; + } + ${genSections(options)} + .section-root rect, .section-root path, .section-root circle { + fill: ${options.git0}; + } + .section-root text { + fill: ${options.gitBranchLabel0}; + } + .icon-container { + height:100%; + display: flex; + justify-content: center; + align-items: center; + } + .edge { + fill: none; + } + .eventWrapper { + filter: brightness(120%); + } +`; +const styles = getStyles; +const diagram = { + db, + renderer, + parser: parser$1, + styles +}; + +export { diagram }; diff --git a/libs/marked/xychartDiagram-f11f50a6-CiMOLwkr.js b/libs/marked/xychartDiagram-f11f50a6-CiMOLwkr.js new file mode 100644 index 0000000..3b95f9d --- /dev/null +++ b/libs/marked/xychartDiagram-f11f50a6-CiMOLwkr.js @@ -0,0 +1,1834 @@ +import { Z as getThemeVariables$2, _ as getConfig$1, X as cleanAndMerge, W as defaultConfig$2, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, a as getAccDescription, b as setAccDescription, E as clear$1, l as log$1, U as selectSvgElement, i as configureSvgSize, d as sanitizeText$2 } from './index-CN3YjQ0n.js'; +import { c as computeDimensionOfText } from './createText-ca0c5216-DF05SDfj.js'; +import { i as initRange } from './init-zpY4DTin.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { l as linear } from './linear--P89MwVW.js'; +import { l as line } from './line-D1aCvau7.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +function range(start, stop, step) { + start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; + + var i = -1, + n = Math.max(0, Math.ceil((stop - start) / step)) | 0, + range = new Array(n); + + while (++i < n) { + range[i] = start + i * step; + } + + return range; +} + +function band() { + var scale = ordinal().unknown(undefined), + domain = scale.domain, + ordinalRange = scale.range, + r0 = 0, + r1 = 1, + step, + bandwidth, + round = false, + paddingInner = 0, + paddingOuter = 0, + align = 0.5; + + delete scale.unknown; + + function rescale() { + var n = domain().length, + reverse = r1 < r0, + start = reverse ? r1 : r0, + stop = reverse ? r0 : r1; + step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2); + if (round) step = Math.floor(step); + start += (stop - start - step * (n - paddingInner)) * align; + bandwidth = step * (1 - paddingInner); + if (round) start = Math.round(start), bandwidth = Math.round(bandwidth); + var values = range(n).map(function(i) { return start + step * i; }); + return ordinalRange(reverse ? values.reverse() : values); + } + + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); + }; + + scale.range = function(_) { + return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1]; + }; + + scale.rangeRound = function(_) { + return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale(); + }; + + scale.bandwidth = function() { + return bandwidth; + }; + + scale.step = function() { + return step; + }; + + scale.round = function(_) { + return arguments.length ? (round = !!_, rescale()) : round; + }; + + scale.padding = function(_) { + return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner; + }; + + scale.paddingInner = function(_) { + return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner; + }; + + scale.paddingOuter = function(_) { + return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter; + }; + + scale.align = function(_) { + return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align; + }; + + scale.copy = function() { + return band(domain(), [r0, r1]) + .round(round) + .paddingInner(paddingInner) + .paddingOuter(paddingOuter) + .align(align); + }; + + return initRange.apply(rescale(), arguments); +} + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 10, 12, 14, 16, 18, 19, 21, 23], $V1 = [2, 6], $V2 = [1, 3], $V3 = [1, 5], $V4 = [1, 6], $V5 = [1, 7], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $V7 = [1, 25], $V8 = [1, 26], $V9 = [1, 28], $Va = [1, 29], $Vb = [1, 30], $Vc = [1, 31], $Vd = [1, 32], $Ve = [1, 33], $Vf = [1, 34], $Vg = [1, 35], $Vh = [1, 36], $Vi = [1, 37], $Vj = [1, 43], $Vk = [1, 42], $Vl = [1, 47], $Vm = [1, 50], $Vn = [1, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $Vo = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36], $Vp = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $Vq = [1, 64]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "XYCHART": 5, "chartConfig": 6, "document": 7, "CHART_ORIENTATION": 8, "statement": 9, "title": 10, "text": 11, "X_AXIS": 12, "parseXAxis": 13, "Y_AXIS": 14, "parseYAxis": 15, "LINE": 16, "plotData": 17, "BAR": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "SQUARE_BRACES_START": 24, "commaSeparatedNumbers": 25, "SQUARE_BRACES_END": 26, "NUMBER_WITH_DECIMAL": 27, "COMMA": 28, "xAxisData": 29, "bandData": 30, "ARROW_DELIMITER": 31, "commaSeparatedTexts": 32, "yAxisData": 33, "NEWLINE": 34, "SEMI": 35, "EOF": 36, "alphaNum": 37, "STR": 38, "MD_STR": 39, "alphaNumToken": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "PLUS": 44, "EQUALS": 45, "MULT": 46, "DOT": 47, "BRKT": 48, "MINUS": 49, "UNDERSCORE": 50, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "XYCHART", 8: "CHART_ORIENTATION", 10: "title", 12: "X_AXIS", 14: "Y_AXIS", 16: "LINE", 18: "BAR", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "SQUARE_BRACES_START", 26: "SQUARE_BRACES_END", 27: "NUMBER_WITH_DECIMAL", 28: "COMMA", 31: "ARROW_DELIMITER", 34: "NEWLINE", 35: "SEMI", 36: "EOF", 38: "STR", 39: "MD_STR", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "PLUS", 45: "EQUALS", 46: "MULT", 47: "DOT", 48: "BRKT", 49: "MINUS", 50: "UNDERSCORE" }, + productions_: [0, [3, 2], [3, 3], [3, 2], [3, 1], [6, 1], [7, 0], [7, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 3], [9, 2], [9, 3], [9, 2], [9, 2], [9, 1], [17, 3], [25, 3], [25, 1], [13, 1], [13, 2], [13, 1], [29, 1], [29, 3], [30, 3], [32, 3], [32, 1], [15, 1], [15, 2], [15, 1], [33, 3], [4, 1], [4, 1], [4, 1], [11, 1], [11, 1], [11, 1], [37, 1], [37, 2], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 5: + yy.setOrientation($$[$0]); + break; + case 9: + yy.setDiagramTitle($$[$0].text.trim()); + break; + case 12: + yy.setLineData({ text: "", type: "text" }, $$[$0]); + break; + case 13: + yy.setLineData($$[$0 - 1], $$[$0]); + break; + case 14: + yy.setBarData({ text: "", type: "text" }, $$[$0]); + break; + case 15: + yy.setBarData($$[$0 - 1], $$[$0]); + break; + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + this.$ = $$[$0 - 1]; + break; + case 20: + this.$ = [Number($$[$0 - 2]), ...$$[$0]]; + break; + case 21: + this.$ = [Number($$[$0])]; + break; + case 22: + yy.setXAxisTitle($$[$0]); + break; + case 23: + yy.setXAxisTitle($$[$0 - 1]); + break; + case 24: + yy.setXAxisTitle({ type: "text", text: "" }); + break; + case 25: + yy.setXAxisBand($$[$0]); + break; + case 26: + yy.setXAxisRangeData(Number($$[$0 - 2]), Number($$[$0])); + break; + case 27: + this.$ = $$[$0 - 1]; + break; + case 28: + this.$ = [$$[$0 - 2], ...$$[$0]]; + break; + case 29: + this.$ = [$$[$0]]; + break; + case 30: + yy.setYAxisTitle($$[$0]); + break; + case 31: + yy.setYAxisTitle($$[$0 - 1]); + break; + case 32: + yy.setYAxisTitle({ type: "text", text: "" }); + break; + case 33: + yy.setYAxisRangeData(Number($$[$0 - 2]), Number($$[$0])); + break; + case 37: + this.$ = { text: $$[$0], type: "text" }; + break; + case 38: + this.$ = { text: $$[$0], type: "text" }; + break; + case 39: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 40: + this.$ = $$[$0]; + break; + case 41: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + } + }, + table: [o($V0, $V1, { 3: 1, 4: 2, 7: 4, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [3] }, o($V0, $V1, { 4: 2, 7: 4, 3: 8, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), o($V0, $V1, { 4: 2, 7: 4, 6: 9, 3: 10, 5: $V2, 8: [1, 11], 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 4], 9: 12, 10: [1, 13], 12: [1, 14], 14: [1, 15], 16: [1, 16], 18: [1, 17], 19: [1, 18], 21: [1, 19], 23: [1, 20] }, o($V6, [2, 34]), o($V6, [2, 35]), o($V6, [2, 36]), { 1: [2, 1] }, o($V0, $V1, { 4: 2, 7: 4, 3: 21, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 3] }, o($V6, [2, 5]), o($V0, [2, 7], { 4: 22, 34: $V3, 35: $V4, 36: $V5 }), { 11: 23, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 39, 13: 38, 24: $Vj, 27: $Vk, 29: 40, 30: 41, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 45, 15: 44, 27: $Vl, 33: 46, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 49, 17: 48, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 52, 17: 51, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 20: [1, 53] }, { 22: [1, 54] }, o($Vn, [2, 18]), { 1: [2, 2] }, o($Vn, [2, 8]), o($Vn, [2, 9]), o($Vo, [2, 37], { 40: 55, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }), o($Vo, [2, 38]), o($Vo, [2, 39]), o($Vp, [2, 40]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), o($Vp, [2, 47]), o($Vp, [2, 48]), o($Vp, [2, 49]), o($Vp, [2, 50]), o($Vp, [2, 51]), o($Vn, [2, 10]), o($Vn, [2, 22], { 30: 41, 29: 56, 24: $Vj, 27: $Vk }), o($Vn, [2, 24]), o($Vn, [2, 25]), { 31: [1, 57] }, { 11: 59, 32: 58, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 11]), o($Vn, [2, 30], { 33: 60, 27: $Vl }), o($Vn, [2, 32]), { 31: [1, 61] }, o($Vn, [2, 12]), { 17: 62, 24: $Vm }, { 25: 63, 27: $Vq }, o($Vn, [2, 14]), { 17: 65, 24: $Vm }, o($Vn, [2, 16]), o($Vn, [2, 17]), o($Vp, [2, 41]), o($Vn, [2, 23]), { 27: [1, 66] }, { 26: [1, 67] }, { 26: [2, 29], 28: [1, 68] }, o($Vn, [2, 31]), { 27: [1, 69] }, o($Vn, [2, 13]), { 26: [1, 70] }, { 26: [2, 21], 28: [1, 71] }, o($Vn, [2, 15]), o($Vn, [2, 26]), o($Vn, [2, 27]), { 11: 59, 32: 72, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 33]), o($Vn, [2, 19]), { 25: 73, 27: $Vq }, { 26: [2, 28] }, { 26: [2, 20] }], + defaultActions: { 8: [2, 1], 10: [2, 3], 21: [2, 2], 72: [2, 28], 73: [2, 20] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + this.popState(); + return 34; + case 3: + this.popState(); + return 34; + case 4: + return 34; + case 5: + break; + case 6: + return 10; + case 7: + this.pushState("acc_title"); + return 19; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.pushState("acc_descr"); + return 21; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.pushState("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 5; + case 15: + return 8; + case 16: + this.pushState("axis_data"); + return "X_AXIS"; + case 17: + this.pushState("axis_data"); + return "Y_AXIS"; + case 18: + this.pushState("axis_band_data"); + return 24; + case 19: + return 31; + case 20: + this.pushState("data"); + return 16; + case 21: + this.pushState("data"); + return 18; + case 22: + this.pushState("data_inner"); + return 24; + case 23: + return 27; + case 24: + this.popState(); + return 26; + case 25: + this.popState(); + break; + case 26: + this.pushState("string"); + break; + case 27: + this.popState(); + break; + case 28: + return "STR"; + case 29: + return 24; + case 30: + return 26; + case 31: + return 43; + case 32: + return "COLON"; + case 33: + return 44; + case 34: + return 28; + case 35: + return 45; + case 36: + return 46; + case 37: + return 48; + case 38: + return 50; + case 39: + return 47; + case 40: + return 41; + case 41: + return 49; + case 42: + return 42; + case 43: + break; + case 44: + return 35; + case 45: + return 36; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:(\r?\n))/i, /^(?:(\r?\n))/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:\{)/i, /^(?:[^\}]*)/i, /^(?:xychart-beta\b)/i, /^(?:(?:vertical|horizontal))/i, /^(?:x-axis\b)/i, /^(?:y-axis\b)/i, /^(?:\[)/i, /^(?:-->)/i, /^(?:line\b)/i, /^(?:bar\b)/i, /^(?:\[)/i, /^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i, /^(?:\])/i, /^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n\(\?:`))/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s+)/i, /^(?:;)/i, /^(?:$)/i], + conditions: { "data_inner": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "data": { "rules": [0, 1, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 22, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "axis_band_data": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "axis_data": { "rules": [0, 1, 2, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [], "inclusive": false }, "md_string": { "rules": [], "inclusive": false }, "string": { "rules": [27, 28], "inclusive": false }, "INITIAL": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +function isBarPlot(data) { + return data.type === "bar"; +} +function isBandAxisData(data) { + return data.type === "band"; +} +function isLinearAxisData(data) { + return data.type === "linear"; +} +class TextDimensionCalculatorWithFont { + constructor(parentGroup) { + this.parentGroup = parentGroup; + } + getMaxDimension(texts, fontSize) { + if (!this.parentGroup) { + return { + width: texts.reduce((acc, cur) => Math.max(cur.length, acc), 0) * fontSize, + height: fontSize + }; + } + const dimension = { + width: 0, + height: 0 + }; + const elem = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", fontSize); + for (const t of texts) { + const bbox = computeDimensionOfText(elem, 1, t); + const width = bbox ? bbox.width : t.length * fontSize; + const height = bbox ? bbox.height : fontSize; + dimension.width = Math.max(dimension.width, width); + dimension.height = Math.max(dimension.height, height); + } + elem.remove(); + return dimension; + } +} +const BAR_WIDTH_TO_TICK_WIDTH_RATIO = 0.7; +const MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL = 0.2; +class BaseAxis { + constructor(axisConfig, title, textDimensionCalculator, axisThemeConfig) { + this.axisConfig = axisConfig; + this.title = title; + this.textDimensionCalculator = textDimensionCalculator; + this.axisThemeConfig = axisThemeConfig; + this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }; + this.axisPosition = "left"; + this.showTitle = false; + this.showLabel = false; + this.showTick = false; + this.showAxisLine = false; + this.outerPadding = 0; + this.titleTextHeight = 0; + this.labelTextHeight = 0; + this.range = [0, 10]; + this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }; + this.axisPosition = "left"; + } + setRange(range) { + this.range = range; + if (this.axisPosition === "left" || this.axisPosition === "right") { + this.boundingRect.height = range[1] - range[0]; + } else { + this.boundingRect.width = range[1] - range[0]; + } + this.recalculateScale(); + } + getRange() { + return [this.range[0] + this.outerPadding, this.range[1] - this.outerPadding]; + } + setAxisPosition(axisPosition) { + this.axisPosition = axisPosition; + this.setRange(this.range); + } + getTickDistance() { + const range = this.getRange(); + return Math.abs(range[0] - range[1]) / this.getTickValues().length; + } + getAxisOuterPadding() { + return this.outerPadding; + } + getLabelDimension() { + return this.textDimensionCalculator.getMaxDimension( + this.getTickValues().map((tick) => tick.toString()), + this.axisConfig.labelFontSize + ); + } + recalculateOuterPaddingToDrawBar() { + if (BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() > this.outerPadding * 2) { + this.outerPadding = Math.floor(BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() / 2); + } + this.recalculateScale(); + } + calculateSpaceIfDrawnHorizontally(availableSpace) { + let availableHeight = availableSpace.height; + if (this.axisConfig.showAxisLine && availableHeight > this.axisConfig.axisLineWidth) { + availableHeight -= this.axisConfig.axisLineWidth; + this.showAxisLine = true; + } + if (this.axisConfig.showLabel) { + const spaceRequired = this.getLabelDimension(); + const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.width; + this.outerPadding = Math.min(spaceRequired.width / 2, maxPadding); + const heightRequired = spaceRequired.height + this.axisConfig.labelPadding * 2; + this.labelTextHeight = spaceRequired.height; + if (heightRequired <= availableHeight) { + availableHeight -= heightRequired; + this.showLabel = true; + } + } + if (this.axisConfig.showTick && availableHeight >= this.axisConfig.tickLength) { + this.showTick = true; + availableHeight -= this.axisConfig.tickLength; + } + if (this.axisConfig.showTitle && this.title) { + const spaceRequired = this.textDimensionCalculator.getMaxDimension( + [this.title], + this.axisConfig.titleFontSize + ); + const heightRequired = spaceRequired.height + this.axisConfig.titlePadding * 2; + this.titleTextHeight = spaceRequired.height; + if (heightRequired <= availableHeight) { + availableHeight -= heightRequired; + this.showTitle = true; + } + } + this.boundingRect.width = availableSpace.width; + this.boundingRect.height = availableSpace.height - availableHeight; + } + calculateSpaceIfDrawnVertical(availableSpace) { + let availableWidth = availableSpace.width; + if (this.axisConfig.showAxisLine && availableWidth > this.axisConfig.axisLineWidth) { + availableWidth -= this.axisConfig.axisLineWidth; + this.showAxisLine = true; + } + if (this.axisConfig.showLabel) { + const spaceRequired = this.getLabelDimension(); + const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.height; + this.outerPadding = Math.min(spaceRequired.height / 2, maxPadding); + const widthRequired = spaceRequired.width + this.axisConfig.labelPadding * 2; + if (widthRequired <= availableWidth) { + availableWidth -= widthRequired; + this.showLabel = true; + } + } + if (this.axisConfig.showTick && availableWidth >= this.axisConfig.tickLength) { + this.showTick = true; + availableWidth -= this.axisConfig.tickLength; + } + if (this.axisConfig.showTitle && this.title) { + const spaceRequired = this.textDimensionCalculator.getMaxDimension( + [this.title], + this.axisConfig.titleFontSize + ); + const widthRequired = spaceRequired.height + this.axisConfig.titlePadding * 2; + this.titleTextHeight = spaceRequired.height; + if (widthRequired <= availableWidth) { + availableWidth -= widthRequired; + this.showTitle = true; + } + } + this.boundingRect.width = availableSpace.width - availableWidth; + this.boundingRect.height = availableSpace.height; + } + calculateSpace(availableSpace) { + if (this.axisPosition === "left" || this.axisPosition === "right") { + this.calculateSpaceIfDrawnVertical(availableSpace); + } else { + this.calculateSpaceIfDrawnHorizontally(availableSpace); + } + this.recalculateScale(); + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + getDrawableElementsForLeftAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["left-axis", "axisl-line"], + data: [ + { + path: `M ${x},${this.boundingRect.y} L ${x},${this.boundingRect.y + this.boundingRect.height} `, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["left-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.boundingRect.x + this.boundingRect.width - (this.showLabel ? this.axisConfig.labelPadding : 0) - (this.showTick ? this.axisConfig.tickLength : 0) - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0), + y: this.getScaleValue(tick), + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "middle", + horizontalPos: "right" + })) + }); + } + if (this.showTick) { + const x = this.boundingRect.x + this.boundingRect.width - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0); + drawableElement.push({ + type: "path", + groupTexts: ["left-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${x},${this.getScaleValue(tick)} L ${x - this.axisConfig.tickLength},${this.getScaleValue(tick)}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["left-axis", "title"], + data: [ + { + text: this.title, + x: this.boundingRect.x + this.axisConfig.titlePadding, + y: this.boundingRect.y + this.boundingRect.height / 2, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 270, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElementsForBottomAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["bottom-axis", "axis-line"], + data: [ + { + path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["bottom-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.getScaleValue(tick), + y: this.boundingRect.y + this.axisConfig.labelPadding + (this.showTick ? this.axisConfig.tickLength : 0) + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0), + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + })) + }); + } + if (this.showTick) { + const y = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0); + drawableElement.push({ + type: "path", + groupTexts: ["bottom-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${this.getScaleValue(tick)},${y} L ${this.getScaleValue(tick)},${y + this.axisConfig.tickLength}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["bottom-axis", "title"], + data: [ + { + text: this.title, + x: this.range[0] + (this.range[1] - this.range[0]) / 2, + y: this.boundingRect.y + this.boundingRect.height - this.axisConfig.titlePadding - this.titleTextHeight, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElementsForTopAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["top-axis", "axis-line"], + data: [ + { + path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["top-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.getScaleValue(tick), + y: this.boundingRect.y + (this.showTitle ? this.titleTextHeight + this.axisConfig.titlePadding * 2 : 0) + this.axisConfig.labelPadding, + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + })) + }); + } + if (this.showTick) { + const y = this.boundingRect.y; + drawableElement.push({ + type: "path", + groupTexts: ["top-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${this.getScaleValue(tick)},${y + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(tick)},${y + this.boundingRect.height - this.axisConfig.tickLength - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["top-axis", "title"], + data: [ + { + text: this.title, + x: this.boundingRect.x + this.boundingRect.width / 2, + y: this.boundingRect.y + this.axisConfig.titlePadding, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElements() { + if (this.axisPosition === "left") { + return this.getDrawableElementsForLeftAxis(); + } + if (this.axisPosition === "right") { + throw Error("Drawing of right axis is not implemented"); + } + if (this.axisPosition === "bottom") { + return this.getDrawableElementsForBottomAxis(); + } + if (this.axisPosition === "top") { + return this.getDrawableElementsForTopAxis(); + } + return []; + } +} +class BandAxis extends BaseAxis { + constructor(axisConfig, axisThemeConfig, categories, title, textDimensionCalculator) { + super(axisConfig, title, textDimensionCalculator, axisThemeConfig); + this.categories = categories; + this.scale = band().domain(this.categories).range(this.getRange()); + } + setRange(range) { + super.setRange(range); + } + recalculateScale() { + this.scale = band().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5); + log$1.trace("BandAxis axis final categories, range: ", this.categories, this.getRange()); + } + getTickValues() { + return this.categories; + } + getScaleValue(value) { + return this.scale(value) || this.getRange()[0]; + } +} +class LinearAxis extends BaseAxis { + constructor(axisConfig, axisThemeConfig, domain, title, textDimensionCalculator) { + super(axisConfig, title, textDimensionCalculator, axisThemeConfig); + this.domain = domain; + this.scale = linear().domain(this.domain).range(this.getRange()); + } + getTickValues() { + return this.scale.ticks(); + } + recalculateScale() { + const domain = [...this.domain]; + if (this.axisPosition === "left") { + domain.reverse(); + } + this.scale = linear().domain(domain).range(this.getRange()); + } + getScaleValue(value) { + return this.scale(value); + } +} +function getAxis(data, axisConfig, axisThemeConfig, tmpSVGGroup2) { + const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2); + if (isBandAxisData(data)) { + return new BandAxis( + axisConfig, + axisThemeConfig, + data.categories, + data.title, + textDimensionCalculator + ); + } + return new LinearAxis( + axisConfig, + axisThemeConfig, + [data.min, data.max], + data.title, + textDimensionCalculator + ); +} +class ChartTitle { + constructor(textDimensionCalculator, chartConfig, chartData, chartThemeConfig) { + this.textDimensionCalculator = textDimensionCalculator; + this.chartConfig = chartConfig; + this.chartData = chartData; + this.chartThemeConfig = chartThemeConfig; + this.boundingRect = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + this.showChartTitle = false; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + calculateSpace(availableSpace) { + const titleDimension = this.textDimensionCalculator.getMaxDimension( + [this.chartData.title], + this.chartConfig.titleFontSize + ); + const widthRequired = Math.max(titleDimension.width, availableSpace.width); + const heightRequired = titleDimension.height + 2 * this.chartConfig.titlePadding; + if (titleDimension.width <= widthRequired && titleDimension.height <= heightRequired && this.chartConfig.showTitle && this.chartData.title) { + this.boundingRect.width = widthRequired; + this.boundingRect.height = heightRequired; + this.showChartTitle = true; + } + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + getDrawableElements() { + const drawableElem = []; + if (this.showChartTitle) { + drawableElem.push({ + groupTexts: ["chart-title"], + type: "text", + data: [ + { + fontSize: this.chartConfig.titleFontSize, + text: this.chartData.title, + verticalPos: "middle", + horizontalPos: "center", + x: this.boundingRect.x + this.boundingRect.width / 2, + y: this.boundingRect.y + this.boundingRect.height / 2, + fill: this.chartThemeConfig.titleColor, + rotation: 0 + } + ] + }); + } + return drawableElem; + } +} +function getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) { + const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2); + return new ChartTitle(textDimensionCalculator, chartConfig, chartData, chartThemeConfig); +} +class LinePlot { + constructor(plotData, xAxis, yAxis, orientation, plotIndex2) { + this.plotData = plotData; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.orientation = orientation; + this.plotIndex = plotIndex2; + } + getDrawableElement() { + const finalData = this.plotData.data.map((d) => [ + this.xAxis.getScaleValue(d[0]), + this.yAxis.getScaleValue(d[1]) + ]); + let path; + if (this.orientation === "horizontal") { + path = line().y((d) => d[0]).x((d) => d[1])(finalData); + } else { + path = line().x((d) => d[0]).y((d) => d[1])(finalData); + } + if (!path) { + return []; + } + return [ + { + groupTexts: ["plot", `line-plot-${this.plotIndex}`], + type: "path", + data: [ + { + path, + strokeFill: this.plotData.strokeFill, + strokeWidth: this.plotData.strokeWidth + } + ] + } + ]; + } +} +class BarPlot { + constructor(barData, boundingRect, xAxis, yAxis, orientation, plotIndex2) { + this.barData = barData; + this.boundingRect = boundingRect; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.orientation = orientation; + this.plotIndex = plotIndex2; + } + getDrawableElement() { + const finalData = this.barData.data.map((d) => [ + this.xAxis.getScaleValue(d[0]), + this.yAxis.getScaleValue(d[1]) + ]); + const barPaddingPercent = 0.05; + const barWidth = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * (1 - barPaddingPercent); + const barWidthHalf = barWidth / 2; + if (this.orientation === "horizontal") { + return [ + { + groupTexts: ["plot", `bar-plot-${this.plotIndex}`], + type: "rect", + data: finalData.map((data) => ({ + x: this.boundingRect.x, + y: data[0] - barWidthHalf, + height: barWidth, + width: data[1] - this.boundingRect.x, + fill: this.barData.fill, + strokeWidth: 0, + strokeFill: this.barData.fill + })) + } + ]; + } + return [ + { + groupTexts: ["plot", `bar-plot-${this.plotIndex}`], + type: "rect", + data: finalData.map((data) => ({ + x: data[0] - barWidthHalf, + y: data[1], + width: barWidth, + height: this.boundingRect.y + this.boundingRect.height - data[1], + fill: this.barData.fill, + strokeWidth: 0, + strokeFill: this.barData.fill + })) + } + ]; + } +} +class BasePlot { + constructor(chartConfig, chartData, chartThemeConfig) { + this.chartConfig = chartConfig; + this.chartData = chartData; + this.chartThemeConfig = chartThemeConfig; + this.boundingRect = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + } + setAxes(xAxis, yAxis) { + this.xAxis = xAxis; + this.yAxis = yAxis; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + calculateSpace(availableSpace) { + this.boundingRect.width = availableSpace.width; + this.boundingRect.height = availableSpace.height; + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + getDrawableElements() { + if (!(this.xAxis && this.yAxis)) { + throw Error("Axes must be passed to render Plots"); + } + const drawableElem = []; + for (const [i, plot] of this.chartData.plots.entries()) { + switch (plot.type) { + case "line": + { + const linePlot = new LinePlot( + plot, + this.xAxis, + this.yAxis, + this.chartConfig.chartOrientation, + i + ); + drawableElem.push(...linePlot.getDrawableElement()); + } + break; + case "bar": + { + const barPlot = new BarPlot( + plot, + this.boundingRect, + this.xAxis, + this.yAxis, + this.chartConfig.chartOrientation, + i + ); + drawableElem.push(...barPlot.getDrawableElement()); + } + break; + } + } + return drawableElem; + } +} +function getPlotComponent(chartConfig, chartData, chartThemeConfig) { + return new BasePlot(chartConfig, chartData, chartThemeConfig); +} +class Orchestrator { + constructor(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) { + this.chartConfig = chartConfig; + this.chartData = chartData; + this.componentStore = { + title: getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2), + plot: getPlotComponent(chartConfig, chartData, chartThemeConfig), + xAxis: getAxis( + chartData.xAxis, + chartConfig.xAxis, + { + titleColor: chartThemeConfig.xAxisTitleColor, + labelColor: chartThemeConfig.xAxisLabelColor, + tickColor: chartThemeConfig.xAxisTickColor, + axisLineColor: chartThemeConfig.xAxisLineColor + }, + tmpSVGGroup2 + ), + yAxis: getAxis( + chartData.yAxis, + chartConfig.yAxis, + { + titleColor: chartThemeConfig.yAxisTitleColor, + labelColor: chartThemeConfig.yAxisLabelColor, + tickColor: chartThemeConfig.yAxisTickColor, + axisLineColor: chartThemeConfig.yAxisLineColor + }, + tmpSVGGroup2 + ) + }; + } + calculateVerticalSpace() { + let availableWidth = this.chartConfig.width; + let availableHeight = this.chartConfig.height; + let plotX = 0; + let plotY = 0; + let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100); + let chartHeight = Math.floor( + availableHeight * this.chartConfig.plotReservedSpacePercent / 100 + ); + let spaceUsed = this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + availableWidth -= spaceUsed.width; + availableHeight -= spaceUsed.height; + spaceUsed = this.componentStore.title.calculateSpace({ + width: this.chartConfig.width, + height: availableHeight + }); + plotY = spaceUsed.height; + availableHeight -= spaceUsed.height; + this.componentStore.xAxis.setAxisPosition("bottom"); + spaceUsed = this.componentStore.xAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableHeight -= spaceUsed.height; + this.componentStore.yAxis.setAxisPosition("left"); + spaceUsed = this.componentStore.yAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + plotX = spaceUsed.width; + availableWidth -= spaceUsed.width; + if (availableWidth > 0) { + chartWidth += availableWidth; + availableWidth = 0; + } + if (availableHeight > 0) { + chartHeight += availableHeight; + availableHeight = 0; + } + this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY }); + this.componentStore.xAxis.setRange([plotX, plotX + chartWidth]); + this.componentStore.xAxis.setBoundingBoxXY({ x: plotX, y: plotY + chartHeight }); + this.componentStore.yAxis.setRange([plotY, plotY + chartHeight]); + this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: plotY }); + if (this.chartData.plots.some((p) => isBarPlot(p))) { + this.componentStore.xAxis.recalculateOuterPaddingToDrawBar(); + } + } + calculateHorizontalSpace() { + let availableWidth = this.chartConfig.width; + let availableHeight = this.chartConfig.height; + let titleYEnd = 0; + let plotX = 0; + let plotY = 0; + let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100); + let chartHeight = Math.floor( + availableHeight * this.chartConfig.plotReservedSpacePercent / 100 + ); + let spaceUsed = this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + availableWidth -= spaceUsed.width; + availableHeight -= spaceUsed.height; + spaceUsed = this.componentStore.title.calculateSpace({ + width: this.chartConfig.width, + height: availableHeight + }); + titleYEnd = spaceUsed.height; + availableHeight -= spaceUsed.height; + this.componentStore.xAxis.setAxisPosition("left"); + spaceUsed = this.componentStore.xAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableWidth -= spaceUsed.width; + plotX = spaceUsed.width; + this.componentStore.yAxis.setAxisPosition("top"); + spaceUsed = this.componentStore.yAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableHeight -= spaceUsed.height; + plotY = titleYEnd + spaceUsed.height; + if (availableWidth > 0) { + chartWidth += availableWidth; + availableWidth = 0; + } + if (availableHeight > 0) { + chartHeight += availableHeight; + availableHeight = 0; + } + this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY }); + this.componentStore.yAxis.setRange([plotX, plotX + chartWidth]); + this.componentStore.yAxis.setBoundingBoxXY({ x: plotX, y: titleYEnd }); + this.componentStore.xAxis.setRange([plotY, plotY + chartHeight]); + this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: plotY }); + if (this.chartData.plots.some((p) => isBarPlot(p))) { + this.componentStore.xAxis.recalculateOuterPaddingToDrawBar(); + } + } + calculateSpace() { + if (this.chartConfig.chartOrientation === "horizontal") { + this.calculateHorizontalSpace(); + } else { + this.calculateVerticalSpace(); + } + } + getDrawableElement() { + this.calculateSpace(); + const drawableElem = []; + this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis); + for (const component of Object.values(this.componentStore)) { + drawableElem.push(...component.getDrawableElements()); + } + return drawableElem; + } +} +class XYChartBuilder { + static build(config, chartData, chartThemeConfig, tmpSVGGroup2) { + const orchestrator = new Orchestrator(config, chartData, chartThemeConfig, tmpSVGGroup2); + return orchestrator.getDrawableElement(); + } +} +let plotIndex = 0; +let tmpSVGGroup; +let xyChartConfig = getChartDefaultConfig(); +let xyChartThemeConfig = getChartDefaultThemeConfig(); +let xyChartData = getChartDefaultData(); +let plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim()); +let hasSetXAxis = false; +let hasSetYAxis = false; +function getChartDefaultThemeConfig() { + const defaultThemeVariables = getThemeVariables$2(); + const config = getConfig$1(); + return cleanAndMerge(defaultThemeVariables.xyChart, config.themeVariables.xyChart); +} +function getChartDefaultConfig() { + const config = getConfig$1(); + return cleanAndMerge( + defaultConfig$2.xyChart, + config.xyChart + ); +} +function getChartDefaultData() { + return { + yAxis: { + type: "linear", + title: "", + min: Infinity, + max: -Infinity + }, + xAxis: { + type: "band", + title: "", + categories: [] + }, + title: "", + plots: [] + }; +} +function textSanitizer(text) { + const config = getConfig$1(); + return sanitizeText$2(text.trim(), config); +} +function setTmpSVGG(SVGG) { + tmpSVGGroup = SVGG; +} +function setOrientation(orientation) { + if (orientation === "horizontal") { + xyChartConfig.chartOrientation = "horizontal"; + } else { + xyChartConfig.chartOrientation = "vertical"; + } +} +function setXAxisTitle(title) { + xyChartData.xAxis.title = textSanitizer(title.text); +} +function setXAxisRangeData(min, max) { + xyChartData.xAxis = { type: "linear", title: xyChartData.xAxis.title, min, max }; + hasSetXAxis = true; +} +function setXAxisBand(categories) { + xyChartData.xAxis = { + type: "band", + title: xyChartData.xAxis.title, + categories: categories.map((c) => textSanitizer(c.text)) + }; + hasSetXAxis = true; +} +function setYAxisTitle(title) { + xyChartData.yAxis.title = textSanitizer(title.text); +} +function setYAxisRangeData(min, max) { + xyChartData.yAxis = { type: "linear", title: xyChartData.yAxis.title, min, max }; + hasSetYAxis = true; +} +function setYAxisRangeFromPlotData(data) { + const minValue = Math.min(...data); + const maxValue = Math.max(...data); + const prevMinValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Infinity; + const prevMaxValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.max : -Infinity; + xyChartData.yAxis = { + type: "linear", + title: xyChartData.yAxis.title, + min: Math.min(prevMinValue, minValue), + max: Math.max(prevMaxValue, maxValue) + }; +} +function transformDataWithoutCategory(data) { + let retData = []; + if (data.length === 0) { + return retData; + } + if (!hasSetXAxis) { + const prevMinValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.min : Infinity; + const prevMaxValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.max : -Infinity; + setXAxisRangeData(Math.min(prevMinValue, 1), Math.max(prevMaxValue, data.length)); + } + if (!hasSetYAxis) { + setYAxisRangeFromPlotData(data); + } + if (isBandAxisData(xyChartData.xAxis)) { + retData = xyChartData.xAxis.categories.map((c, i) => [c, data[i]]); + } + if (isLinearAxisData(xyChartData.xAxis)) { + const min = xyChartData.xAxis.min; + const max = xyChartData.xAxis.max; + const step = (max - min + 1) / data.length; + const categories = []; + for (let i = min; i <= max; i += step) { + categories.push(`${i}`); + } + retData = categories.map((c, i) => [c, data[i]]); + } + return retData; +} +function getPlotColorFromPalette(plotIndex2) { + return plotColorPalette[plotIndex2 === 0 ? 0 : plotIndex2 % plotColorPalette.length]; +} +function setLineData(title, data) { + const plotData = transformDataWithoutCategory(data); + xyChartData.plots.push({ + type: "line", + strokeFill: getPlotColorFromPalette(plotIndex), + strokeWidth: 2, + data: plotData + }); + plotIndex++; +} +function setBarData(title, data) { + const plotData = transformDataWithoutCategory(data); + xyChartData.plots.push({ + type: "bar", + fill: getPlotColorFromPalette(plotIndex), + data: plotData + }); + plotIndex++; +} +function getDrawableElem() { + if (xyChartData.plots.length === 0) { + throw Error("No Plot to render, please provide a plot with some data"); + } + xyChartData.title = getDiagramTitle(); + return XYChartBuilder.build(xyChartConfig, xyChartData, xyChartThemeConfig, tmpSVGGroup); +} +function getChartThemeConfig() { + return xyChartThemeConfig; +} +function getChartConfig() { + return xyChartConfig; +} +const clear = function() { + clear$1(); + plotIndex = 0; + xyChartConfig = getChartDefaultConfig(); + xyChartData = getChartDefaultData(); + xyChartThemeConfig = getChartDefaultThemeConfig(); + plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim()); + hasSetXAxis = false; + hasSetYAxis = false; +}; +const db = { + getDrawableElem, + clear, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + getAccDescription, + setAccDescription, + setOrientation, + setXAxisTitle, + setXAxisRangeData, + setXAxisBand, + setYAxisTitle, + setYAxisRangeData, + setLineData, + setBarData, + setTmpSVGG, + getChartThemeConfig, + getChartConfig +}; +const draw = (txt, id, _version, diagObj) => { + const db2 = diagObj.db; + const themeConfig = db2.getChartThemeConfig(); + const chartConfig = db2.getChartConfig(); + function getDominantBaseLine(horizontalPos) { + return horizontalPos === "top" ? "text-before-edge" : "middle"; + } + function getTextAnchor(verticalPos) { + return verticalPos === "left" ? "start" : verticalPos === "right" ? "end" : "middle"; + } + function getTextTransformation(data) { + return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`; + } + log$1.debug("Rendering xychart chart\n" + txt); + const svg = selectSvgElement(id); + const group = svg.append("g").attr("class", "main"); + const background = group.append("rect").attr("width", chartConfig.width).attr("height", chartConfig.height).attr("class", "background"); + configureSvgSize(svg, chartConfig.height, chartConfig.width, true); + svg.attr("viewBox", `0 0 ${chartConfig.width} ${chartConfig.height}`); + background.attr("fill", themeConfig.backgroundColor); + db2.setTmpSVGG(svg.append("g").attr("class", "mermaid-tmp-group")); + const shapes = db2.getDrawableElem(); + const groups = {}; + function getGroup(gList) { + let elem = group; + let prefix = ""; + for (const [i] of gList.entries()) { + let parent = group; + if (i > 0 && groups[prefix]) { + parent = groups[prefix]; + } + prefix += gList[i]; + elem = groups[prefix]; + if (!elem) { + elem = groups[prefix] = parent.append("g").attr("class", gList[i]); + } + } + return elem; + } + for (const shape of shapes) { + if (shape.data.length === 0) { + continue; + } + const shapeGroup = getGroup(shape.groupTexts); + switch (shape.type) { + case "rect": + shapeGroup.selectAll("rect").data(shape.data).enter().append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill).attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth); + break; + case "text": + shapeGroup.selectAll("text").data(shape.data).enter().append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.verticalPos)).attr("text-anchor", (data) => getTextAnchor(data.horizontalPos)).attr("transform", (data) => getTextTransformation(data)).text((data) => data.text); + break; + case "path": + shapeGroup.selectAll("path").data(shape.data).enter().append("path").attr("d", (data) => data.path).attr("fill", (data) => data.fill ? data.fill : "none").attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth); + break; + } + } +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer +}; + +export { diagram }; diff --git a/libs/marked/xychartDiagram-f11f50a6-fh9SQxEm.js b/libs/marked/xychartDiagram-f11f50a6-fh9SQxEm.js new file mode 100644 index 0000000..8f0cf05 --- /dev/null +++ b/libs/marked/xychartDiagram-f11f50a6-fh9SQxEm.js @@ -0,0 +1,1834 @@ +import { Z as getThemeVariables$2, _ as getConfig$1, X as cleanAndMerge, W as defaultConfig$2, s as setAccTitle, g as getAccTitle, C as setDiagramTitle, D as getDiagramTitle, a as getAccDescription, b as setAccDescription, E as clear$1, l as log$1, U as selectSvgElement, i as configureSvgSize, d as sanitizeText$2 } from './index-Bd_FDXSq.js'; +import { c as computeDimensionOfText } from './createText-ca0c5216-B9KlDTE8.js'; +import { i as initRange } from './init-zpY4DTin.js'; +import { o as ordinal } from './ordinal-X8I8fqLF.js'; +import { l as linear } from './linear-DNP-QGmo.js'; +import { l as line } from './line-DUwhS6kk.js'; +import './array-DJxSMw-N.js'; +import './path-BZ3S9nBE.js'; + +function range(start, stop, step) { + start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step; + + var i = -1, + n = Math.max(0, Math.ceil((stop - start) / step)) | 0, + range = new Array(n); + + while (++i < n) { + range[i] = start + i * step; + } + + return range; +} + +function band() { + var scale = ordinal().unknown(undefined), + domain = scale.domain, + ordinalRange = scale.range, + r0 = 0, + r1 = 1, + step, + bandwidth, + round = false, + paddingInner = 0, + paddingOuter = 0, + align = 0.5; + + delete scale.unknown; + + function rescale() { + var n = domain().length, + reverse = r1 < r0, + start = reverse ? r1 : r0, + stop = reverse ? r0 : r1; + step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2); + if (round) step = Math.floor(step); + start += (stop - start - step * (n - paddingInner)) * align; + bandwidth = step * (1 - paddingInner); + if (round) start = Math.round(start), bandwidth = Math.round(bandwidth); + var values = range(n).map(function(i) { return start + step * i; }); + return ordinalRange(reverse ? values.reverse() : values); + } + + scale.domain = function(_) { + return arguments.length ? (domain(_), rescale()) : domain(); + }; + + scale.range = function(_) { + return arguments.length ? ([r0, r1] = _, r0 = +r0, r1 = +r1, rescale()) : [r0, r1]; + }; + + scale.rangeRound = function(_) { + return [r0, r1] = _, r0 = +r0, r1 = +r1, round = true, rescale(); + }; + + scale.bandwidth = function() { + return bandwidth; + }; + + scale.step = function() { + return step; + }; + + scale.round = function(_) { + return arguments.length ? (round = !!_, rescale()) : round; + }; + + scale.padding = function(_) { + return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_), rescale()) : paddingInner; + }; + + scale.paddingInner = function(_) { + return arguments.length ? (paddingInner = Math.min(1, _), rescale()) : paddingInner; + }; + + scale.paddingOuter = function(_) { + return arguments.length ? (paddingOuter = +_, rescale()) : paddingOuter; + }; + + scale.align = function(_) { + return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align; + }; + + scale.copy = function() { + return band(domain(), [r0, r1]) + .round(round) + .paddingInner(paddingInner) + .paddingOuter(paddingOuter) + .align(align); + }; + + return initRange.apply(rescale(), arguments); +} + +var parser = function() { + var o = function(k, v, o2, l) { + for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) + ; + return o2; + }, $V0 = [1, 10, 12, 14, 16, 18, 19, 21, 23], $V1 = [2, 6], $V2 = [1, 3], $V3 = [1, 5], $V4 = [1, 6], $V5 = [1, 7], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $V7 = [1, 25], $V8 = [1, 26], $V9 = [1, 28], $Va = [1, 29], $Vb = [1, 30], $Vc = [1, 31], $Vd = [1, 32], $Ve = [1, 33], $Vf = [1, 34], $Vg = [1, 35], $Vh = [1, 36], $Vi = [1, 37], $Vj = [1, 43], $Vk = [1, 42], $Vl = [1, 47], $Vm = [1, 50], $Vn = [1, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], $Vo = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36], $Vp = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], $Vq = [1, 64]; + var parser2 = { + trace: function trace() { + }, + yy: {}, + symbols_: { "error": 2, "start": 3, "eol": 4, "XYCHART": 5, "chartConfig": 6, "document": 7, "CHART_ORIENTATION": 8, "statement": 9, "title": 10, "text": 11, "X_AXIS": 12, "parseXAxis": 13, "Y_AXIS": 14, "parseYAxis": 15, "LINE": 16, "plotData": 17, "BAR": 18, "acc_title": 19, "acc_title_value": 20, "acc_descr": 21, "acc_descr_value": 22, "acc_descr_multiline_value": 23, "SQUARE_BRACES_START": 24, "commaSeparatedNumbers": 25, "SQUARE_BRACES_END": 26, "NUMBER_WITH_DECIMAL": 27, "COMMA": 28, "xAxisData": 29, "bandData": 30, "ARROW_DELIMITER": 31, "commaSeparatedTexts": 32, "yAxisData": 33, "NEWLINE": 34, "SEMI": 35, "EOF": 36, "alphaNum": 37, "STR": 38, "MD_STR": 39, "alphaNumToken": 40, "AMP": 41, "NUM": 42, "ALPHA": 43, "PLUS": 44, "EQUALS": 45, "MULT": 46, "DOT": 47, "BRKT": 48, "MINUS": 49, "UNDERSCORE": 50, "$accept": 0, "$end": 1 }, + terminals_: { 2: "error", 5: "XYCHART", 8: "CHART_ORIENTATION", 10: "title", 12: "X_AXIS", 14: "Y_AXIS", 16: "LINE", 18: "BAR", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "SQUARE_BRACES_START", 26: "SQUARE_BRACES_END", 27: "NUMBER_WITH_DECIMAL", 28: "COMMA", 31: "ARROW_DELIMITER", 34: "NEWLINE", 35: "SEMI", 36: "EOF", 38: "STR", 39: "MD_STR", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "PLUS", 45: "EQUALS", 46: "MULT", 47: "DOT", 48: "BRKT", 49: "MINUS", 50: "UNDERSCORE" }, + productions_: [0, [3, 2], [3, 3], [3, 2], [3, 1], [6, 1], [7, 0], [7, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 3], [9, 2], [9, 3], [9, 2], [9, 2], [9, 1], [17, 3], [25, 3], [25, 1], [13, 1], [13, 2], [13, 1], [29, 1], [29, 3], [30, 3], [32, 3], [32, 1], [15, 1], [15, 2], [15, 1], [33, 3], [4, 1], [4, 1], [4, 1], [11, 1], [11, 1], [11, 1], [37, 1], [37, 2], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1]], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { + var $0 = $$.length - 1; + switch (yystate) { + case 5: + yy.setOrientation($$[$0]); + break; + case 9: + yy.setDiagramTitle($$[$0].text.trim()); + break; + case 12: + yy.setLineData({ text: "", type: "text" }, $$[$0]); + break; + case 13: + yy.setLineData($$[$0 - 1], $$[$0]); + break; + case 14: + yy.setBarData({ text: "", type: "text" }, $$[$0]); + break; + case 15: + yy.setBarData($$[$0 - 1], $$[$0]); + break; + case 16: + this.$ = $$[$0].trim(); + yy.setAccTitle(this.$); + break; + case 17: + case 18: + this.$ = $$[$0].trim(); + yy.setAccDescription(this.$); + break; + case 19: + this.$ = $$[$0 - 1]; + break; + case 20: + this.$ = [Number($$[$0 - 2]), ...$$[$0]]; + break; + case 21: + this.$ = [Number($$[$0])]; + break; + case 22: + yy.setXAxisTitle($$[$0]); + break; + case 23: + yy.setXAxisTitle($$[$0 - 1]); + break; + case 24: + yy.setXAxisTitle({ type: "text", text: "" }); + break; + case 25: + yy.setXAxisBand($$[$0]); + break; + case 26: + yy.setXAxisRangeData(Number($$[$0 - 2]), Number($$[$0])); + break; + case 27: + this.$ = $$[$0 - 1]; + break; + case 28: + this.$ = [$$[$0 - 2], ...$$[$0]]; + break; + case 29: + this.$ = [$$[$0]]; + break; + case 30: + yy.setYAxisTitle($$[$0]); + break; + case 31: + yy.setYAxisTitle($$[$0 - 1]); + break; + case 32: + yy.setYAxisTitle({ type: "text", text: "" }); + break; + case 33: + yy.setYAxisRangeData(Number($$[$0 - 2]), Number($$[$0])); + break; + case 37: + this.$ = { text: $$[$0], type: "text" }; + break; + case 38: + this.$ = { text: $$[$0], type: "text" }; + break; + case 39: + this.$ = { text: $$[$0], type: "markdown" }; + break; + case 40: + this.$ = $$[$0]; + break; + case 41: + this.$ = $$[$0 - 1] + "" + $$[$0]; + break; + } + }, + table: [o($V0, $V1, { 3: 1, 4: 2, 7: 4, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [3] }, o($V0, $V1, { 4: 2, 7: 4, 3: 8, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), o($V0, $V1, { 4: 2, 7: 4, 6: 9, 3: 10, 5: $V2, 8: [1, 11], 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 4], 9: 12, 10: [1, 13], 12: [1, 14], 14: [1, 15], 16: [1, 16], 18: [1, 17], 19: [1, 18], 21: [1, 19], 23: [1, 20] }, o($V6, [2, 34]), o($V6, [2, 35]), o($V6, [2, 36]), { 1: [2, 1] }, o($V0, $V1, { 4: 2, 7: 4, 3: 21, 5: $V2, 34: $V3, 35: $V4, 36: $V5 }), { 1: [2, 3] }, o($V6, [2, 5]), o($V0, [2, 7], { 4: 22, 34: $V3, 35: $V4, 36: $V5 }), { 11: 23, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 39, 13: 38, 24: $Vj, 27: $Vk, 29: 40, 30: 41, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 45, 15: 44, 27: $Vl, 33: 46, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 49, 17: 48, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 11: 52, 17: 51, 24: $Vm, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, { 20: [1, 53] }, { 22: [1, 54] }, o($Vn, [2, 18]), { 1: [2, 2] }, o($Vn, [2, 8]), o($Vn, [2, 9]), o($Vo, [2, 37], { 40: 55, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }), o($Vo, [2, 38]), o($Vo, [2, 39]), o($Vp, [2, 40]), o($Vp, [2, 42]), o($Vp, [2, 43]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), o($Vp, [2, 47]), o($Vp, [2, 48]), o($Vp, [2, 49]), o($Vp, [2, 50]), o($Vp, [2, 51]), o($Vn, [2, 10]), o($Vn, [2, 22], { 30: 41, 29: 56, 24: $Vj, 27: $Vk }), o($Vn, [2, 24]), o($Vn, [2, 25]), { 31: [1, 57] }, { 11: 59, 32: 58, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 11]), o($Vn, [2, 30], { 33: 60, 27: $Vl }), o($Vn, [2, 32]), { 31: [1, 61] }, o($Vn, [2, 12]), { 17: 62, 24: $Vm }, { 25: 63, 27: $Vq }, o($Vn, [2, 14]), { 17: 65, 24: $Vm }, o($Vn, [2, 16]), o($Vn, [2, 17]), o($Vp, [2, 41]), o($Vn, [2, 23]), { 27: [1, 66] }, { 26: [1, 67] }, { 26: [2, 29], 28: [1, 68] }, o($Vn, [2, 31]), { 27: [1, 69] }, o($Vn, [2, 13]), { 26: [1, 70] }, { 26: [2, 21], 28: [1, 71] }, o($Vn, [2, 15]), o($Vn, [2, 26]), o($Vn, [2, 27]), { 11: 59, 32: 72, 37: 24, 38: $V7, 39: $V8, 40: 27, 41: $V9, 42: $Va, 43: $Vb, 44: $Vc, 45: $Vd, 46: $Ve, 47: $Vf, 48: $Vg, 49: $Vh, 50: $Vi }, o($Vn, [2, 33]), o($Vn, [2, 19]), { 25: 73, 27: $Vq }, { 26: [2, 28] }, { 26: [2, 20] }], + defaultActions: { 8: [2, 1], 10: [2, 3], 21: [2, 2], 72: [2, 28], 73: [2, 20] }, + parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var error = new Error(str); + error.hash = hash; + throw error; + } + }, + parse: function parse(input) { + var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1; + var args = lstack.slice.call(arguments, 1); + var lexer2 = Object.create(this.lexer); + var sharedState = { yy: {} }; + for (var k in this.yy) { + if (Object.prototype.hasOwnProperty.call(this.yy, k)) { + sharedState.yy[k] = this.yy[k]; + } + } + lexer2.setInput(input, sharedState.yy); + sharedState.yy.lexer = lexer2; + sharedState.yy.parser = this; + if (typeof lexer2.yylloc == "undefined") { + lexer2.yylloc = {}; + } + var yyloc = lexer2.yylloc; + lstack.push(yyloc); + var ranges = lexer2.options && lexer2.options.ranges; + if (typeof sharedState.yy.parseError === "function") { + this.parseError = sharedState.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function lex() { + var token; + token = tstack.pop() || lexer2.lex() || EOF; + if (typeof token !== "number") { + if (token instanceof Array) { + tstack = token; + token = tstack.pop(); + } + token = self.symbols_[token] || token; + } + return token; + } + var symbol, state, action, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == "undefined") { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + var errStr = ""; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push("'" + this.terminals_[p] + "'"); + } + } + if (lexer2.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, { + text: lexer2.match, + token: this.terminals_[symbol] || symbol, + line: lexer2.yylineno, + loc: yyloc, + expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(lexer2.yytext); + lstack.push(lexer2.yylloc); + stack.push(action[1]); + symbol = null; + { + yyleng = lexer2.yyleng; + yytext = lexer2.yytext; + yylineno = lexer2.yylineno; + yyloc = lexer2.yylloc; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.apply(yyval, [ + yytext, + yyleng, + yylineno, + sharedState.yy, + action[1], + vstack, + lstack + ].concat(args)); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; + } + }; + var lexer = function() { + var lexer2 = { + EOF: 1, + parseError: function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, + // resets the lexer, sets new input + setInput: function(input, yy) { + this.yy = yy || this.yy || {}; + this._input = input; + this._more = this._backtrack = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ""; + this.conditionStack = ["INITIAL"]; + this.yylloc = { + first_line: 1, + first_column: 0, + last_line: 1, + last_column: 0 + }; + if (this.options.ranges) { + this.yylloc.range = [0, 0]; + } + this.offset = 0; + return this; + }, + // consumes and returns one char from the input + input: function() { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) { + this.yylloc.range[1]++; + } + this._input = this._input.slice(1); + return ch; + }, + // unshifts one char (or a string) into the input + unput: function(ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length - 1); + this.matched = this.matched.substr(0, this.matched.length - 1); + if (lines.length - 1) { + this.yylineno -= lines.length - 1; + } + var r = this.yylloc.range; + this.yylloc = { + first_line: this.yylloc.first_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.first_column, + last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len + }; + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + this.yyleng = this.yytext.length; + return this; + }, + // When called from action, caches matched text and appends it on next action + more: function() { + this._more = true; + return this; + }, + // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. + reject: function() { + if (this.options.backtrack_lexer) { + this._backtrack = true; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + return this; + }, + // retain first n characters of the match + less: function(n) { + this.unput(this.match.slice(n)); + }, + // displays already matched input, i.e. for error messages + pastInput: function() { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, ""); + }, + // displays upcoming input, i.e. for error messages + upcomingInput: function() { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20 - next.length); + } + return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, ""); + }, + // displays the character position where the lexing error occurred, i.e. for error messages + showPosition: function() { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c + "^"; + }, + // test the lexed token: return FALSE when not a match, otherwise return token + test_match: function(match, indexed_rule) { + var token, lines, backup; + if (this.options.backtrack_lexer) { + backup = { + yylineno: this.yylineno, + yylloc: { + first_line: this.yylloc.first_line, + last_line: this.last_line, + first_column: this.yylloc.first_column, + last_column: this.yylloc.last_column + }, + yytext: this.yytext, + match: this.match, + matches: this.matches, + matched: this.matched, + yyleng: this.yyleng, + offset: this.offset, + _more: this._more, + _input: this._input, + yy: this.yy, + conditionStack: this.conditionStack.slice(0), + done: this.done + }; + if (this.options.ranges) { + backup.yylloc.range = this.yylloc.range.slice(0); + } + } + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno += lines.length; + } + this.yylloc = { + first_line: this.yylloc.last_line, + last_line: this.yylineno + 1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length + }; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._backtrack = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); + if (this.done && this._input) { + this.done = false; + } + if (token) { + return token; + } else if (this._backtrack) { + for (var k in backup) { + this[k] = backup[k]; + } + return false; + } + return false; + }, + // return next match in input + next: function() { + if (this.done) { + return this.EOF; + } + if (!this._input) { + this.done = true; + } + var token, match, tempMatch, index; + if (!this._more) { + this.yytext = ""; + this.match = ""; + } + var rules = this._currentRules(); + for (var i = 0; i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (this.options.backtrack_lexer) { + token = this.test_match(tempMatch, rules[i]); + if (token !== false) { + return token; + } else if (this._backtrack) { + match = false; + continue; + } else { + return false; + } + } else if (!this.options.flex) { + break; + } + } + } + if (match) { + token = this.test_match(match, rules[index]); + if (token !== false) { + return token; + } + return false; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), { + text: "", + token: null, + line: this.yylineno + }); + } + }, + // return next match that has a token + lex: function lex() { + var r = this.next(); + if (r) { + return r; + } else { + return this.lex(); + } + }, + // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) + begin: function begin(condition) { + this.conditionStack.push(condition); + }, + // pop the previously active lexer condition state off the condition stack + popState: function popState() { + var n = this.conditionStack.length - 1; + if (n > 0) { + return this.conditionStack.pop(); + } else { + return this.conditionStack[0]; + } + }, + // produce the lexer rule set which is active for the currently active lexer condition state + _currentRules: function _currentRules() { + if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { + return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; + } else { + return this.conditions["INITIAL"].rules; + } + }, + // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available + topState: function topState(n) { + n = this.conditionStack.length - 1 - Math.abs(n || 0); + if (n >= 0) { + return this.conditionStack[n]; + } else { + return "INITIAL"; + } + }, + // alias for begin(condition) + pushState: function pushState(condition) { + this.begin(condition); + }, + // return the number of states currently on the stack + stateStackSize: function stateStackSize() { + return this.conditionStack.length; + }, + options: { "case-insensitive": true }, + performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { + switch ($avoiding_name_collisions) { + case 0: + break; + case 1: + break; + case 2: + this.popState(); + return 34; + case 3: + this.popState(); + return 34; + case 4: + return 34; + case 5: + break; + case 6: + return 10; + case 7: + this.pushState("acc_title"); + return 19; + case 8: + this.popState(); + return "acc_title_value"; + case 9: + this.pushState("acc_descr"); + return 21; + case 10: + this.popState(); + return "acc_descr_value"; + case 11: + this.pushState("acc_descr_multiline"); + break; + case 12: + this.popState(); + break; + case 13: + return "acc_descr_multiline_value"; + case 14: + return 5; + case 15: + return 8; + case 16: + this.pushState("axis_data"); + return "X_AXIS"; + case 17: + this.pushState("axis_data"); + return "Y_AXIS"; + case 18: + this.pushState("axis_band_data"); + return 24; + case 19: + return 31; + case 20: + this.pushState("data"); + return 16; + case 21: + this.pushState("data"); + return 18; + case 22: + this.pushState("data_inner"); + return 24; + case 23: + return 27; + case 24: + this.popState(); + return 26; + case 25: + this.popState(); + break; + case 26: + this.pushState("string"); + break; + case 27: + this.popState(); + break; + case 28: + return "STR"; + case 29: + return 24; + case 30: + return 26; + case 31: + return 43; + case 32: + return "COLON"; + case 33: + return 44; + case 34: + return 28; + case 35: + return 45; + case 36: + return 46; + case 37: + return 48; + case 38: + return 50; + case 39: + return 47; + case 40: + return 41; + case 41: + return 49; + case 42: + return 42; + case 43: + break; + case 44: + return 35; + case 45: + return 36; + } + }, + rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:(\r?\n))/i, /^(?:(\r?\n))/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:\{)/i, /^(?:[^\}]*)/i, /^(?:xychart-beta\b)/i, /^(?:(?:vertical|horizontal))/i, /^(?:x-axis\b)/i, /^(?:y-axis\b)/i, /^(?:\[)/i, /^(?:-->)/i, /^(?:line\b)/i, /^(?:bar\b)/i, /^(?:\[)/i, /^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i, /^(?:\])/i, /^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n\(\?:`))/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s+)/i, /^(?:;)/i, /^(?:$)/i], + conditions: { "data_inner": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "data": { "rules": [0, 1, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 22, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "axis_band_data": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "axis_data": { "rules": [0, 1, 2, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true }, "acc_descr_multiline": { "rules": [12, 13], "inclusive": false }, "acc_descr": { "rules": [10], "inclusive": false }, "acc_title": { "rules": [8], "inclusive": false }, "title": { "rules": [], "inclusive": false }, "md_string": { "rules": [], "inclusive": false }, "string": { "rules": [27, 28], "inclusive": false }, "INITIAL": { "rules": [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 20, 21, 25, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45], "inclusive": true } } + }; + return lexer2; + }(); + parser2.lexer = lexer; + function Parser() { + this.yy = {}; + } + Parser.prototype = parser2; + parser2.Parser = Parser; + return new Parser(); +}(); +parser.parser = parser; +const parser$1 = parser; +function isBarPlot(data) { + return data.type === "bar"; +} +function isBandAxisData(data) { + return data.type === "band"; +} +function isLinearAxisData(data) { + return data.type === "linear"; +} +class TextDimensionCalculatorWithFont { + constructor(parentGroup) { + this.parentGroup = parentGroup; + } + getMaxDimension(texts, fontSize) { + if (!this.parentGroup) { + return { + width: texts.reduce((acc, cur) => Math.max(cur.length, acc), 0) * fontSize, + height: fontSize + }; + } + const dimension = { + width: 0, + height: 0 + }; + const elem = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", fontSize); + for (const t of texts) { + const bbox = computeDimensionOfText(elem, 1, t); + const width = bbox ? bbox.width : t.length * fontSize; + const height = bbox ? bbox.height : fontSize; + dimension.width = Math.max(dimension.width, width); + dimension.height = Math.max(dimension.height, height); + } + elem.remove(); + return dimension; + } +} +const BAR_WIDTH_TO_TICK_WIDTH_RATIO = 0.7; +const MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL = 0.2; +class BaseAxis { + constructor(axisConfig, title, textDimensionCalculator, axisThemeConfig) { + this.axisConfig = axisConfig; + this.title = title; + this.textDimensionCalculator = textDimensionCalculator; + this.axisThemeConfig = axisThemeConfig; + this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }; + this.axisPosition = "left"; + this.showTitle = false; + this.showLabel = false; + this.showTick = false; + this.showAxisLine = false; + this.outerPadding = 0; + this.titleTextHeight = 0; + this.labelTextHeight = 0; + this.range = [0, 10]; + this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }; + this.axisPosition = "left"; + } + setRange(range) { + this.range = range; + if (this.axisPosition === "left" || this.axisPosition === "right") { + this.boundingRect.height = range[1] - range[0]; + } else { + this.boundingRect.width = range[1] - range[0]; + } + this.recalculateScale(); + } + getRange() { + return [this.range[0] + this.outerPadding, this.range[1] - this.outerPadding]; + } + setAxisPosition(axisPosition) { + this.axisPosition = axisPosition; + this.setRange(this.range); + } + getTickDistance() { + const range = this.getRange(); + return Math.abs(range[0] - range[1]) / this.getTickValues().length; + } + getAxisOuterPadding() { + return this.outerPadding; + } + getLabelDimension() { + return this.textDimensionCalculator.getMaxDimension( + this.getTickValues().map((tick) => tick.toString()), + this.axisConfig.labelFontSize + ); + } + recalculateOuterPaddingToDrawBar() { + if (BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() > this.outerPadding * 2) { + this.outerPadding = Math.floor(BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() / 2); + } + this.recalculateScale(); + } + calculateSpaceIfDrawnHorizontally(availableSpace) { + let availableHeight = availableSpace.height; + if (this.axisConfig.showAxisLine && availableHeight > this.axisConfig.axisLineWidth) { + availableHeight -= this.axisConfig.axisLineWidth; + this.showAxisLine = true; + } + if (this.axisConfig.showLabel) { + const spaceRequired = this.getLabelDimension(); + const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.width; + this.outerPadding = Math.min(spaceRequired.width / 2, maxPadding); + const heightRequired = spaceRequired.height + this.axisConfig.labelPadding * 2; + this.labelTextHeight = spaceRequired.height; + if (heightRequired <= availableHeight) { + availableHeight -= heightRequired; + this.showLabel = true; + } + } + if (this.axisConfig.showTick && availableHeight >= this.axisConfig.tickLength) { + this.showTick = true; + availableHeight -= this.axisConfig.tickLength; + } + if (this.axisConfig.showTitle && this.title) { + const spaceRequired = this.textDimensionCalculator.getMaxDimension( + [this.title], + this.axisConfig.titleFontSize + ); + const heightRequired = spaceRequired.height + this.axisConfig.titlePadding * 2; + this.titleTextHeight = spaceRequired.height; + if (heightRequired <= availableHeight) { + availableHeight -= heightRequired; + this.showTitle = true; + } + } + this.boundingRect.width = availableSpace.width; + this.boundingRect.height = availableSpace.height - availableHeight; + } + calculateSpaceIfDrawnVertical(availableSpace) { + let availableWidth = availableSpace.width; + if (this.axisConfig.showAxisLine && availableWidth > this.axisConfig.axisLineWidth) { + availableWidth -= this.axisConfig.axisLineWidth; + this.showAxisLine = true; + } + if (this.axisConfig.showLabel) { + const spaceRequired = this.getLabelDimension(); + const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.height; + this.outerPadding = Math.min(spaceRequired.height / 2, maxPadding); + const widthRequired = spaceRequired.width + this.axisConfig.labelPadding * 2; + if (widthRequired <= availableWidth) { + availableWidth -= widthRequired; + this.showLabel = true; + } + } + if (this.axisConfig.showTick && availableWidth >= this.axisConfig.tickLength) { + this.showTick = true; + availableWidth -= this.axisConfig.tickLength; + } + if (this.axisConfig.showTitle && this.title) { + const spaceRequired = this.textDimensionCalculator.getMaxDimension( + [this.title], + this.axisConfig.titleFontSize + ); + const widthRequired = spaceRequired.height + this.axisConfig.titlePadding * 2; + this.titleTextHeight = spaceRequired.height; + if (widthRequired <= availableWidth) { + availableWidth -= widthRequired; + this.showTitle = true; + } + } + this.boundingRect.width = availableSpace.width - availableWidth; + this.boundingRect.height = availableSpace.height; + } + calculateSpace(availableSpace) { + if (this.axisPosition === "left" || this.axisPosition === "right") { + this.calculateSpaceIfDrawnVertical(availableSpace); + } else { + this.calculateSpaceIfDrawnHorizontally(availableSpace); + } + this.recalculateScale(); + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + getDrawableElementsForLeftAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["left-axis", "axisl-line"], + data: [ + { + path: `M ${x},${this.boundingRect.y} L ${x},${this.boundingRect.y + this.boundingRect.height} `, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["left-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.boundingRect.x + this.boundingRect.width - (this.showLabel ? this.axisConfig.labelPadding : 0) - (this.showTick ? this.axisConfig.tickLength : 0) - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0), + y: this.getScaleValue(tick), + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "middle", + horizontalPos: "right" + })) + }); + } + if (this.showTick) { + const x = this.boundingRect.x + this.boundingRect.width - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0); + drawableElement.push({ + type: "path", + groupTexts: ["left-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${x},${this.getScaleValue(tick)} L ${x - this.axisConfig.tickLength},${this.getScaleValue(tick)}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["left-axis", "title"], + data: [ + { + text: this.title, + x: this.boundingRect.x + this.axisConfig.titlePadding, + y: this.boundingRect.y + this.boundingRect.height / 2, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 270, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElementsForBottomAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["bottom-axis", "axis-line"], + data: [ + { + path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["bottom-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.getScaleValue(tick), + y: this.boundingRect.y + this.axisConfig.labelPadding + (this.showTick ? this.axisConfig.tickLength : 0) + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0), + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + })) + }); + } + if (this.showTick) { + const y = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0); + drawableElement.push({ + type: "path", + groupTexts: ["bottom-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${this.getScaleValue(tick)},${y} L ${this.getScaleValue(tick)},${y + this.axisConfig.tickLength}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["bottom-axis", "title"], + data: [ + { + text: this.title, + x: this.range[0] + (this.range[1] - this.range[0]) / 2, + y: this.boundingRect.y + this.boundingRect.height - this.axisConfig.titlePadding - this.titleTextHeight, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElementsForTopAxis() { + const drawableElement = []; + if (this.showAxisLine) { + const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2; + drawableElement.push({ + type: "path", + groupTexts: ["top-axis", "axis-line"], + data: [ + { + path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`, + strokeFill: this.axisThemeConfig.axisLineColor, + strokeWidth: this.axisConfig.axisLineWidth + } + ] + }); + } + if (this.showLabel) { + drawableElement.push({ + type: "text", + groupTexts: ["top-axis", "label"], + data: this.getTickValues().map((tick) => ({ + text: tick.toString(), + x: this.getScaleValue(tick), + y: this.boundingRect.y + (this.showTitle ? this.titleTextHeight + this.axisConfig.titlePadding * 2 : 0) + this.axisConfig.labelPadding, + fill: this.axisThemeConfig.labelColor, + fontSize: this.axisConfig.labelFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + })) + }); + } + if (this.showTick) { + const y = this.boundingRect.y; + drawableElement.push({ + type: "path", + groupTexts: ["top-axis", "ticks"], + data: this.getTickValues().map((tick) => ({ + path: `M ${this.getScaleValue(tick)},${y + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(tick)},${y + this.boundingRect.height - this.axisConfig.tickLength - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)}`, + strokeFill: this.axisThemeConfig.tickColor, + strokeWidth: this.axisConfig.tickWidth + })) + }); + } + if (this.showTitle) { + drawableElement.push({ + type: "text", + groupTexts: ["top-axis", "title"], + data: [ + { + text: this.title, + x: this.boundingRect.x + this.boundingRect.width / 2, + y: this.boundingRect.y + this.axisConfig.titlePadding, + fill: this.axisThemeConfig.titleColor, + fontSize: this.axisConfig.titleFontSize, + rotation: 0, + verticalPos: "top", + horizontalPos: "center" + } + ] + }); + } + return drawableElement; + } + getDrawableElements() { + if (this.axisPosition === "left") { + return this.getDrawableElementsForLeftAxis(); + } + if (this.axisPosition === "right") { + throw Error("Drawing of right axis is not implemented"); + } + if (this.axisPosition === "bottom") { + return this.getDrawableElementsForBottomAxis(); + } + if (this.axisPosition === "top") { + return this.getDrawableElementsForTopAxis(); + } + return []; + } +} +class BandAxis extends BaseAxis { + constructor(axisConfig, axisThemeConfig, categories, title, textDimensionCalculator) { + super(axisConfig, title, textDimensionCalculator, axisThemeConfig); + this.categories = categories; + this.scale = band().domain(this.categories).range(this.getRange()); + } + setRange(range) { + super.setRange(range); + } + recalculateScale() { + this.scale = band().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5); + log$1.trace("BandAxis axis final categories, range: ", this.categories, this.getRange()); + } + getTickValues() { + return this.categories; + } + getScaleValue(value) { + return this.scale(value) || this.getRange()[0]; + } +} +class LinearAxis extends BaseAxis { + constructor(axisConfig, axisThemeConfig, domain, title, textDimensionCalculator) { + super(axisConfig, title, textDimensionCalculator, axisThemeConfig); + this.domain = domain; + this.scale = linear().domain(this.domain).range(this.getRange()); + } + getTickValues() { + return this.scale.ticks(); + } + recalculateScale() { + const domain = [...this.domain]; + if (this.axisPosition === "left") { + domain.reverse(); + } + this.scale = linear().domain(domain).range(this.getRange()); + } + getScaleValue(value) { + return this.scale(value); + } +} +function getAxis(data, axisConfig, axisThemeConfig, tmpSVGGroup2) { + const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2); + if (isBandAxisData(data)) { + return new BandAxis( + axisConfig, + axisThemeConfig, + data.categories, + data.title, + textDimensionCalculator + ); + } + return new LinearAxis( + axisConfig, + axisThemeConfig, + [data.min, data.max], + data.title, + textDimensionCalculator + ); +} +class ChartTitle { + constructor(textDimensionCalculator, chartConfig, chartData, chartThemeConfig) { + this.textDimensionCalculator = textDimensionCalculator; + this.chartConfig = chartConfig; + this.chartData = chartData; + this.chartThemeConfig = chartThemeConfig; + this.boundingRect = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + this.showChartTitle = false; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + calculateSpace(availableSpace) { + const titleDimension = this.textDimensionCalculator.getMaxDimension( + [this.chartData.title], + this.chartConfig.titleFontSize + ); + const widthRequired = Math.max(titleDimension.width, availableSpace.width); + const heightRequired = titleDimension.height + 2 * this.chartConfig.titlePadding; + if (titleDimension.width <= widthRequired && titleDimension.height <= heightRequired && this.chartConfig.showTitle && this.chartData.title) { + this.boundingRect.width = widthRequired; + this.boundingRect.height = heightRequired; + this.showChartTitle = true; + } + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + getDrawableElements() { + const drawableElem = []; + if (this.showChartTitle) { + drawableElem.push({ + groupTexts: ["chart-title"], + type: "text", + data: [ + { + fontSize: this.chartConfig.titleFontSize, + text: this.chartData.title, + verticalPos: "middle", + horizontalPos: "center", + x: this.boundingRect.x + this.boundingRect.width / 2, + y: this.boundingRect.y + this.boundingRect.height / 2, + fill: this.chartThemeConfig.titleColor, + rotation: 0 + } + ] + }); + } + return drawableElem; + } +} +function getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) { + const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2); + return new ChartTitle(textDimensionCalculator, chartConfig, chartData, chartThemeConfig); +} +class LinePlot { + constructor(plotData, xAxis, yAxis, orientation, plotIndex2) { + this.plotData = plotData; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.orientation = orientation; + this.plotIndex = plotIndex2; + } + getDrawableElement() { + const finalData = this.plotData.data.map((d) => [ + this.xAxis.getScaleValue(d[0]), + this.yAxis.getScaleValue(d[1]) + ]); + let path; + if (this.orientation === "horizontal") { + path = line().y((d) => d[0]).x((d) => d[1])(finalData); + } else { + path = line().x((d) => d[0]).y((d) => d[1])(finalData); + } + if (!path) { + return []; + } + return [ + { + groupTexts: ["plot", `line-plot-${this.plotIndex}`], + type: "path", + data: [ + { + path, + strokeFill: this.plotData.strokeFill, + strokeWidth: this.plotData.strokeWidth + } + ] + } + ]; + } +} +class BarPlot { + constructor(barData, boundingRect, xAxis, yAxis, orientation, plotIndex2) { + this.barData = barData; + this.boundingRect = boundingRect; + this.xAxis = xAxis; + this.yAxis = yAxis; + this.orientation = orientation; + this.plotIndex = plotIndex2; + } + getDrawableElement() { + const finalData = this.barData.data.map((d) => [ + this.xAxis.getScaleValue(d[0]), + this.yAxis.getScaleValue(d[1]) + ]); + const barPaddingPercent = 0.05; + const barWidth = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * (1 - barPaddingPercent); + const barWidthHalf = barWidth / 2; + if (this.orientation === "horizontal") { + return [ + { + groupTexts: ["plot", `bar-plot-${this.plotIndex}`], + type: "rect", + data: finalData.map((data) => ({ + x: this.boundingRect.x, + y: data[0] - barWidthHalf, + height: barWidth, + width: data[1] - this.boundingRect.x, + fill: this.barData.fill, + strokeWidth: 0, + strokeFill: this.barData.fill + })) + } + ]; + } + return [ + { + groupTexts: ["plot", `bar-plot-${this.plotIndex}`], + type: "rect", + data: finalData.map((data) => ({ + x: data[0] - barWidthHalf, + y: data[1], + width: barWidth, + height: this.boundingRect.y + this.boundingRect.height - data[1], + fill: this.barData.fill, + strokeWidth: 0, + strokeFill: this.barData.fill + })) + } + ]; + } +} +class BasePlot { + constructor(chartConfig, chartData, chartThemeConfig) { + this.chartConfig = chartConfig; + this.chartData = chartData; + this.chartThemeConfig = chartThemeConfig; + this.boundingRect = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + } + setAxes(xAxis, yAxis) { + this.xAxis = xAxis; + this.yAxis = yAxis; + } + setBoundingBoxXY(point) { + this.boundingRect.x = point.x; + this.boundingRect.y = point.y; + } + calculateSpace(availableSpace) { + this.boundingRect.width = availableSpace.width; + this.boundingRect.height = availableSpace.height; + return { + width: this.boundingRect.width, + height: this.boundingRect.height + }; + } + getDrawableElements() { + if (!(this.xAxis && this.yAxis)) { + throw Error("Axes must be passed to render Plots"); + } + const drawableElem = []; + for (const [i, plot] of this.chartData.plots.entries()) { + switch (plot.type) { + case "line": + { + const linePlot = new LinePlot( + plot, + this.xAxis, + this.yAxis, + this.chartConfig.chartOrientation, + i + ); + drawableElem.push(...linePlot.getDrawableElement()); + } + break; + case "bar": + { + const barPlot = new BarPlot( + plot, + this.boundingRect, + this.xAxis, + this.yAxis, + this.chartConfig.chartOrientation, + i + ); + drawableElem.push(...barPlot.getDrawableElement()); + } + break; + } + } + return drawableElem; + } +} +function getPlotComponent(chartConfig, chartData, chartThemeConfig) { + return new BasePlot(chartConfig, chartData, chartThemeConfig); +} +class Orchestrator { + constructor(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) { + this.chartConfig = chartConfig; + this.chartData = chartData; + this.componentStore = { + title: getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2), + plot: getPlotComponent(chartConfig, chartData, chartThemeConfig), + xAxis: getAxis( + chartData.xAxis, + chartConfig.xAxis, + { + titleColor: chartThemeConfig.xAxisTitleColor, + labelColor: chartThemeConfig.xAxisLabelColor, + tickColor: chartThemeConfig.xAxisTickColor, + axisLineColor: chartThemeConfig.xAxisLineColor + }, + tmpSVGGroup2 + ), + yAxis: getAxis( + chartData.yAxis, + chartConfig.yAxis, + { + titleColor: chartThemeConfig.yAxisTitleColor, + labelColor: chartThemeConfig.yAxisLabelColor, + tickColor: chartThemeConfig.yAxisTickColor, + axisLineColor: chartThemeConfig.yAxisLineColor + }, + tmpSVGGroup2 + ) + }; + } + calculateVerticalSpace() { + let availableWidth = this.chartConfig.width; + let availableHeight = this.chartConfig.height; + let plotX = 0; + let plotY = 0; + let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100); + let chartHeight = Math.floor( + availableHeight * this.chartConfig.plotReservedSpacePercent / 100 + ); + let spaceUsed = this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + availableWidth -= spaceUsed.width; + availableHeight -= spaceUsed.height; + spaceUsed = this.componentStore.title.calculateSpace({ + width: this.chartConfig.width, + height: availableHeight + }); + plotY = spaceUsed.height; + availableHeight -= spaceUsed.height; + this.componentStore.xAxis.setAxisPosition("bottom"); + spaceUsed = this.componentStore.xAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableHeight -= spaceUsed.height; + this.componentStore.yAxis.setAxisPosition("left"); + spaceUsed = this.componentStore.yAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + plotX = spaceUsed.width; + availableWidth -= spaceUsed.width; + if (availableWidth > 0) { + chartWidth += availableWidth; + availableWidth = 0; + } + if (availableHeight > 0) { + chartHeight += availableHeight; + availableHeight = 0; + } + this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY }); + this.componentStore.xAxis.setRange([plotX, plotX + chartWidth]); + this.componentStore.xAxis.setBoundingBoxXY({ x: plotX, y: plotY + chartHeight }); + this.componentStore.yAxis.setRange([plotY, plotY + chartHeight]); + this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: plotY }); + if (this.chartData.plots.some((p) => isBarPlot(p))) { + this.componentStore.xAxis.recalculateOuterPaddingToDrawBar(); + } + } + calculateHorizontalSpace() { + let availableWidth = this.chartConfig.width; + let availableHeight = this.chartConfig.height; + let titleYEnd = 0; + let plotX = 0; + let plotY = 0; + let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100); + let chartHeight = Math.floor( + availableHeight * this.chartConfig.plotReservedSpacePercent / 100 + ); + let spaceUsed = this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + availableWidth -= spaceUsed.width; + availableHeight -= spaceUsed.height; + spaceUsed = this.componentStore.title.calculateSpace({ + width: this.chartConfig.width, + height: availableHeight + }); + titleYEnd = spaceUsed.height; + availableHeight -= spaceUsed.height; + this.componentStore.xAxis.setAxisPosition("left"); + spaceUsed = this.componentStore.xAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableWidth -= spaceUsed.width; + plotX = spaceUsed.width; + this.componentStore.yAxis.setAxisPosition("top"); + spaceUsed = this.componentStore.yAxis.calculateSpace({ + width: availableWidth, + height: availableHeight + }); + availableHeight -= spaceUsed.height; + plotY = titleYEnd + spaceUsed.height; + if (availableWidth > 0) { + chartWidth += availableWidth; + availableWidth = 0; + } + if (availableHeight > 0) { + chartHeight += availableHeight; + availableHeight = 0; + } + this.componentStore.plot.calculateSpace({ + width: chartWidth, + height: chartHeight + }); + this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY }); + this.componentStore.yAxis.setRange([plotX, plotX + chartWidth]); + this.componentStore.yAxis.setBoundingBoxXY({ x: plotX, y: titleYEnd }); + this.componentStore.xAxis.setRange([plotY, plotY + chartHeight]); + this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: plotY }); + if (this.chartData.plots.some((p) => isBarPlot(p))) { + this.componentStore.xAxis.recalculateOuterPaddingToDrawBar(); + } + } + calculateSpace() { + if (this.chartConfig.chartOrientation === "horizontal") { + this.calculateHorizontalSpace(); + } else { + this.calculateVerticalSpace(); + } + } + getDrawableElement() { + this.calculateSpace(); + const drawableElem = []; + this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis); + for (const component of Object.values(this.componentStore)) { + drawableElem.push(...component.getDrawableElements()); + } + return drawableElem; + } +} +class XYChartBuilder { + static build(config, chartData, chartThemeConfig, tmpSVGGroup2) { + const orchestrator = new Orchestrator(config, chartData, chartThemeConfig, tmpSVGGroup2); + return orchestrator.getDrawableElement(); + } +} +let plotIndex = 0; +let tmpSVGGroup; +let xyChartConfig = getChartDefaultConfig(); +let xyChartThemeConfig = getChartDefaultThemeConfig(); +let xyChartData = getChartDefaultData(); +let plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim()); +let hasSetXAxis = false; +let hasSetYAxis = false; +function getChartDefaultThemeConfig() { + const defaultThemeVariables = getThemeVariables$2(); + const config = getConfig$1(); + return cleanAndMerge(defaultThemeVariables.xyChart, config.themeVariables.xyChart); +} +function getChartDefaultConfig() { + const config = getConfig$1(); + return cleanAndMerge( + defaultConfig$2.xyChart, + config.xyChart + ); +} +function getChartDefaultData() { + return { + yAxis: { + type: "linear", + title: "", + min: Infinity, + max: -Infinity + }, + xAxis: { + type: "band", + title: "", + categories: [] + }, + title: "", + plots: [] + }; +} +function textSanitizer(text) { + const config = getConfig$1(); + return sanitizeText$2(text.trim(), config); +} +function setTmpSVGG(SVGG) { + tmpSVGGroup = SVGG; +} +function setOrientation(orientation) { + if (orientation === "horizontal") { + xyChartConfig.chartOrientation = "horizontal"; + } else { + xyChartConfig.chartOrientation = "vertical"; + } +} +function setXAxisTitle(title) { + xyChartData.xAxis.title = textSanitizer(title.text); +} +function setXAxisRangeData(min, max) { + xyChartData.xAxis = { type: "linear", title: xyChartData.xAxis.title, min, max }; + hasSetXAxis = true; +} +function setXAxisBand(categories) { + xyChartData.xAxis = { + type: "band", + title: xyChartData.xAxis.title, + categories: categories.map((c) => textSanitizer(c.text)) + }; + hasSetXAxis = true; +} +function setYAxisTitle(title) { + xyChartData.yAxis.title = textSanitizer(title.text); +} +function setYAxisRangeData(min, max) { + xyChartData.yAxis = { type: "linear", title: xyChartData.yAxis.title, min, max }; + hasSetYAxis = true; +} +function setYAxisRangeFromPlotData(data) { + const minValue = Math.min(...data); + const maxValue = Math.max(...data); + const prevMinValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Infinity; + const prevMaxValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.max : -Infinity; + xyChartData.yAxis = { + type: "linear", + title: xyChartData.yAxis.title, + min: Math.min(prevMinValue, minValue), + max: Math.max(prevMaxValue, maxValue) + }; +} +function transformDataWithoutCategory(data) { + let retData = []; + if (data.length === 0) { + return retData; + } + if (!hasSetXAxis) { + const prevMinValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.min : Infinity; + const prevMaxValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.max : -Infinity; + setXAxisRangeData(Math.min(prevMinValue, 1), Math.max(prevMaxValue, data.length)); + } + if (!hasSetYAxis) { + setYAxisRangeFromPlotData(data); + } + if (isBandAxisData(xyChartData.xAxis)) { + retData = xyChartData.xAxis.categories.map((c, i) => [c, data[i]]); + } + if (isLinearAxisData(xyChartData.xAxis)) { + const min = xyChartData.xAxis.min; + const max = xyChartData.xAxis.max; + const step = (max - min + 1) / data.length; + const categories = []; + for (let i = min; i <= max; i += step) { + categories.push(`${i}`); + } + retData = categories.map((c, i) => [c, data[i]]); + } + return retData; +} +function getPlotColorFromPalette(plotIndex2) { + return plotColorPalette[plotIndex2 === 0 ? 0 : plotIndex2 % plotColorPalette.length]; +} +function setLineData(title, data) { + const plotData = transformDataWithoutCategory(data); + xyChartData.plots.push({ + type: "line", + strokeFill: getPlotColorFromPalette(plotIndex), + strokeWidth: 2, + data: plotData + }); + plotIndex++; +} +function setBarData(title, data) { + const plotData = transformDataWithoutCategory(data); + xyChartData.plots.push({ + type: "bar", + fill: getPlotColorFromPalette(plotIndex), + data: plotData + }); + plotIndex++; +} +function getDrawableElem() { + if (xyChartData.plots.length === 0) { + throw Error("No Plot to render, please provide a plot with some data"); + } + xyChartData.title = getDiagramTitle(); + return XYChartBuilder.build(xyChartConfig, xyChartData, xyChartThemeConfig, tmpSVGGroup); +} +function getChartThemeConfig() { + return xyChartThemeConfig; +} +function getChartConfig() { + return xyChartConfig; +} +const clear = function() { + clear$1(); + plotIndex = 0; + xyChartConfig = getChartDefaultConfig(); + xyChartData = getChartDefaultData(); + xyChartThemeConfig = getChartDefaultThemeConfig(); + plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim()); + hasSetXAxis = false; + hasSetYAxis = false; +}; +const db = { + getDrawableElem, + clear, + setAccTitle, + getAccTitle, + setDiagramTitle, + getDiagramTitle, + getAccDescription, + setAccDescription, + setOrientation, + setXAxisTitle, + setXAxisRangeData, + setXAxisBand, + setYAxisTitle, + setYAxisRangeData, + setLineData, + setBarData, + setTmpSVGG, + getChartThemeConfig, + getChartConfig +}; +const draw = (txt, id, _version, diagObj) => { + const db2 = diagObj.db; + const themeConfig = db2.getChartThemeConfig(); + const chartConfig = db2.getChartConfig(); + function getDominantBaseLine(horizontalPos) { + return horizontalPos === "top" ? "text-before-edge" : "middle"; + } + function getTextAnchor(verticalPos) { + return verticalPos === "left" ? "start" : verticalPos === "right" ? "end" : "middle"; + } + function getTextTransformation(data) { + return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`; + } + log$1.debug("Rendering xychart chart\n" + txt); + const svg = selectSvgElement(id); + const group = svg.append("g").attr("class", "main"); + const background = group.append("rect").attr("width", chartConfig.width).attr("height", chartConfig.height).attr("class", "background"); + configureSvgSize(svg, chartConfig.height, chartConfig.width, true); + svg.attr("viewBox", `0 0 ${chartConfig.width} ${chartConfig.height}`); + background.attr("fill", themeConfig.backgroundColor); + db2.setTmpSVGG(svg.append("g").attr("class", "mermaid-tmp-group")); + const shapes = db2.getDrawableElem(); + const groups = {}; + function getGroup(gList) { + let elem = group; + let prefix = ""; + for (const [i] of gList.entries()) { + let parent = group; + if (i > 0 && groups[prefix]) { + parent = groups[prefix]; + } + prefix += gList[i]; + elem = groups[prefix]; + if (!elem) { + elem = groups[prefix] = parent.append("g").attr("class", gList[i]); + } + } + return elem; + } + for (const shape of shapes) { + if (shape.data.length === 0) { + continue; + } + const shapeGroup = getGroup(shape.groupTexts); + switch (shape.type) { + case "rect": + shapeGroup.selectAll("rect").data(shape.data).enter().append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill).attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth); + break; + case "text": + shapeGroup.selectAll("text").data(shape.data).enter().append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.verticalPos)).attr("text-anchor", (data) => getTextAnchor(data.horizontalPos)).attr("transform", (data) => getTextTransformation(data)).text((data) => data.text); + break; + case "path": + shapeGroup.selectAll("path").data(shape.data).enter().append("path").attr("d", (data) => data.path).attr("fill", (data) => data.fill ? data.fill : "none").attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth); + break; + } + } +}; +const renderer = { + draw +}; +const diagram = { + parser: parser$1, + db, + renderer +}; + +export { diagram }; diff --git a/web/index.md b/web/index.md index 7609927..49f8684 100644 --- a/web/index.md +++ b/web/index.md @@ -54,6 +54,12 @@ - [BabylonJS](https://www.babylonjs.com/) - [笔记](/cg/babylonjs/index.md) +### [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) +新版的剪切接口,是新标准 +```javascript +document.execCommand('copy'); // 旧的方法调用系统接口 +``` + ## library